,cwe_id,source,target,project_and_commit_id,cve_id,original_address,time 0,CWE-119,"CWE-119 bool initiate_stratum ( struct pool * pool ) { bool ret = false , recvd = false , noresume = false , sockd = false ; char s [ RBUFSIZE ] , * sret = NULL , * nonce1 , * sessionid ; json_t * val = NULL , * res_val , * err_val ; json_error_t err ; int n2size ; resend : if ( ! setup_stratum_socket ( pool ) ) { sockd = false ; goto out ; } sockd = true ; if ( recvd ) { clear_sock ( pool ) ; sprintf ( s , ""{\\""id\\"":%d,\\""method\\"":\\""mining.subscribe\\"",\\""params\\"":[]}"" , swork_id ++ ) ; } else { if ( pool -> sessionid ) sprintf ( s , ""{\\""id\\"":%d,\\""method\\"":\\""mining.subscribe\\"",\\""params\\"":[\\"""" PACKAGE ""/"" VERSION ""\\"",\\""%s\\""]}"" , swork_id ++ , pool -> sessionid ) ; else sprintf ( s , ""{\\""id\\"":%d,\\""method\\"":\\""mining.subscribe\\"",\\""params\\"":[\\"""" PACKAGE ""/"" VERSION ""\\""]}"" , swork_id ++ ) ; } if ( __stratum_send ( pool , s , strlen ( s ) ) != SEND_OK ) { applog ( LOG_DEBUG , ""Failedtosendsininitiate_stratum"" ) ; goto out ; } if ( ! socket_full ( pool , DEFAULT_SOCKWAIT ) ) { applog ( LOG_DEBUG , ""Timedoutwaitingforresponseininitiate_stratum"" ) ; goto out ; } sret = recv_line ( pool ) ; if ( ! sret ) goto out ; recvd = true ; val = JSON_LOADS ( sret , & err ) ; free ( sret ) ; if ( ! val ) { applog ( LOG_INFO , ""JSONdecodefailed(%d):%s"" , err . line , err . text ) ; goto out ; } res_val = json_object_get ( val , ""result"" ) ; err_val = json_object_get ( val , ""error"" ) ; if ( ! res_val || json_is_null ( res_val ) || ( err_val && ! json_is_null ( err_val ) ) ) { char * ss ; if ( err_val ) ss = json_dumps ( err_val , JSON_INDENT ( 3 ) ) ; else ss = strdup ( ""(unknownreason)"" ) ; applog ( LOG_INFO , ""JSON-RPCdecodefailed:%s"" , ss ) ; free ( ss ) ; goto out ; } sessionid = get_sessionid ( res_val ) ; if ( ! sessionid ) applog ( LOG_DEBUG , ""Failedtogetsessionidininitiate_stratum"" ) ; nonce1 = json_array_string ( res_val , 1 ) ; if ( ! nonce1 ) { applog ( LOG_INFO , ""Failedtogetnonce1ininitiate_stratum"" ) ; free ( sessionid ) ; goto out ; } n2size = json_integer_value ( json_array_get ( res_val , 2 ) ) ; if ( ! n2size ) { applog ( LOG_INFO , ""Failedtogetn2sizeininitiate_stratum"" ) ; free ( sessionid ) ; free ( nonce1 ) ; goto out ; } cg_wlock ( & pool -> data_lock ) ; pool -> sessionid = sessionid ; pool -> nonce1 = nonce1 ; pool -> n1_len = strlen ( nonce1 ) / 2 ; free ( pool -> nonce1bin ) ; pool -> nonce1bin = calloc ( pool -> n1_len , 1 ) ; if ( unlikely ( ! pool -> nonce1bin ) ) quithere ( 1 , ""Failedtocallocpool->nonce1bin"" ) ; hex2bin ( pool -> nonce1bin , pool -> nonce1 , pool -> n1_len ) ; pool -> n2size = n2size ; cg_wunlock ( & pool -> data_lock ) ; if ( sessionid ) applog ( LOG_DEBUG , ""Pool%dstratumsessionid:%s"" , pool -> pool_no , pool -> sessionid ) ; ret = true ; out : if ( ret ) { if ( ! pool -> stratum_url ) pool -> stratum_url = pool -> sockaddr_url ; pool -> stratum_active = true ; pool -> sdiff = 1 ; if ( opt_protocol ) { applog ( LOG_DEBUG , ""Pool%dconfirmedmining.subscribewithextranonce1%sextran2size%d"" , pool -> pool_no , pool -> nonce1 , pool -> n2size ) ; } } else { if ( recvd && ! noresume ) { cg_wlock ( & pool -> data_lock ) ; free ( pool -> sessionid ) ; free ( pool -> nonce1 ) ; pool -> sessionid = pool -> nonce1 = NULL ; cg_wunlock ( & pool -> data_lock ) ; applog ( LOG_DEBUG , ""Failedtoresumestratum,tryingafresh"" ) ; noresume = true ; json_decref ( val ) ; goto resend ; } applog ( LOG_DEBUG , ""Initiatestratumfailed"" ) ; if ( sockd ) suspend_stratum ( pool ) ; } json_decref ( val ) ; return ret ; } "," if ( ! valid_hex ( nonce1 ) ) { applog ( LOG_INFO , ""Failedtogetvalidnonce1ininitiate_stratum"" ) ; free ; if ( n2size < 2 || n2size > 16 ) { applog ( LOG_INFO , ""Failedtogetvalidn2sizeininitiate_stratum"" ) ; free ",sgminer-dev@sgminer/e1c5050734123973b99d181c45e74b2cbb00272e,CVE-2014-4502,https://github.com/sgminer-dev/sgminer/commit/e1c5050734123973b99d181c45e74b2cbb00272e,2014-07-23T14:55Z 1,CWE-125,"CWE-125 void eap_print ( netdissect_options * ndo , register const u_char * cp , u_int length ) { const struct eap_frame_t * eap ; const u_char * tptr ; u_int tlen , type , subtype ; int count = 0 , len ; tptr = cp ; tlen = length ; eap = ( const struct eap_frame_t * ) cp ; ND_TCHECK ( * eap ) ; if ( ndo -> ndo_vflag < 1 ) { ND_PRINT ( ( ndo , ""%s(%u)v%u,len%u"" , tok2str ( eap_frame_type_values , ""unknown"" , eap -> type ) , eap -> type , eap -> version , EXTRACT_16BITS ( eap -> length ) ) ) ; return ; } ND_PRINT ( ( ndo , ""%s(%u)v%u,len%u"" , tok2str ( eap_frame_type_values , ""unknown"" , eap -> type ) , eap -> type , eap -> version , EXTRACT_16BITS ( eap -> length ) ) ) ; tptr += sizeof ( const struct eap_frame_t ) ; tlen -= sizeof ( const struct eap_frame_t ) ; switch ( eap -> type ) { case EAP_FRAME_TYPE_PACKET : type = * ( tptr ) ; len = EXTRACT_16BITS ( tptr + 2 ) ; ND_PRINT ( ( ndo , "",%s(%u),id%u,len%u"" , tok2str ( eap_code_values , ""unknown"" , type ) , type , * ( tptr + 1 ) , len ) ) ; ND_TCHECK2 ( * tptr , len ) ; if ( type <= 2 ) { subtype = * ( tptr + 4 ) ; ND_PRINT ( ( ndo , ""\\n\\t\\tType%s(%u)"" , tok2str ( eap_type_values , ""unknown"" , * ( tptr + 4 ) ) , * ( tptr + 4 ) ) ) ; switch ( subtype ) { case EAP_TYPE_IDENTITY : if ( len - 5 > 0 ) { ND_PRINT ( ( ndo , "",Identity:"" ) ) ; safeputs ( ndo , tptr + 5 , len - 5 ) ; } break ; case EAP_TYPE_NOTIFICATION : if ( len - 5 > 0 ) { ND_PRINT ( ( ndo , "",Notification:"" ) ) ; safeputs ( ndo , tptr + 5 , len - 5 ) ; } break ; case EAP_TYPE_NAK : count = 5 ; while ( count < len ) { ND_PRINT ( ( ndo , ""%s(%u),"" , tok2str ( eap_type_values , ""unknown"" , * ( tptr + count ) ) , * ( tptr + count ) ) ) ; count ++ ; } break ; case EAP_TYPE_TTLS : ND_PRINT ( ( ndo , ""TTLSv%u"" , EAP_TTLS_VERSION ( * ( tptr + 5 ) ) ) ) ; case EAP_TYPE_TLS : ND_PRINT ( ( ndo , ""flags[%s]0x%02x,"" , bittok2str ( eap_tls_flags_values , ""none"" , * ( tptr + 5 ) ) , * ( tptr + 5 ) ) ) ; if ( EAP_TLS_EXTRACT_BIT_L ( * ( tptr + 5 ) ) ) { ND_PRINT ( ( ndo , ""len%u"" , EXTRACT_32BITS ( tptr + 6 ) ) ) ; } break ; case EAP_TYPE_FAST : ND_PRINT ( ( ndo , ""FASTv%u"" , EAP_TTLS_VERSION ( * ( tptr + 5 ) ) ) ) ; ND_PRINT ( ( ndo , ""flags[%s]0x%02x,"" , bittok2str ( eap_tls_flags_values , ""none"" , * ( tptr + 5 ) ) , * ( tptr + 5 ) ) ) ; if ( EAP_TLS_EXTRACT_BIT_L ( * ( tptr + 5 ) ) ) { ND_PRINT ( ( ndo , ""len%u"" , EXTRACT_32BITS ( tptr + 6 ) ) ) ; } break ; case EAP_TYPE_AKA : case EAP_TYPE_SIM : ND_PRINT ( ( ndo , ""subtype[%s]0x%02x,"" , tok2str ( eap_aka_subtype_values , ""unknown"" , * ( tptr + 5 ) ) , * ( tptr + 5 ) ) ) ; break ; case EAP_TYPE_MD5_CHALLENGE : case EAP_TYPE_OTP : case EAP_TYPE_GTC : case EAP_TYPE_EXPANDED_TYPES : case EAP_TYPE_EXPERIMENTAL : default : break ; } } break ; case EAP_FRAME_TYPE_LOGOFF : case EAP_FRAME_TYPE_ENCAP_ASF_ALERT : default : break ; } return ; trunc : ND_PRINT ( ( ndo , ""\\n\\t[|EAP]"" ) ) ; } "," case EAP_FRAME_TYPE_PACKET : ND_TCHECK_8BITS ( tptr ) ; * ( tptr ) ; ND_TCHECK_16BITS ( tptr + 2 2 ) { ND_TCHECK_8BITS ( tptr + 4 ) ; , ""unknown"" , subtype ) , subtype ) ) ; len ) { ND_TCHECK_8BITS ( tptr + count ) ; case EAP_TYPE_TTLS : case EAP_TYPE_TLS : ND_TCHECK_8BITS ( tptr + 5 ) ; if ( subtype == EAP_TYPE_TTLS ) ) ) ; ND_PRINT ( ( ) ) { ND_TCHECK_32BITS ( tptr + 6 ) ; case EAP_TYPE_FAST : ND_TCHECK_8BITS ( tptr + 5 ) ; ) ) { ND_TCHECK_32BITS ( tptr + 6 ) ; case EAP_TYPE_SIM : ND_TCHECK_8BITS ( tptr + 5 ) ; ",the-tcpdump-group@tcpdump/985122081165753c7442bd7824c473eb9ff56308,CVE-2017-13015,https://github.com/the-tcpdump-group/tcpdump/commit/985122081165753c7442bd7824c473eb9ff56308,2017-09-14T06:29Z 2,CWE-401,"CWE-401 int ath9k_wmi_cmd ( struct wmi * wmi , enum wmi_cmd_id cmd_id , u8 * cmd_buf , u32 cmd_len , u8 * rsp_buf , u32 rsp_len , u32 timeout ) { struct ath_hw * ah = wmi -> drv_priv -> ah ; struct ath_common * common = ath9k_hw_common ( ah ) ; u16 headroom = sizeof ( struct htc_frame_hdr ) + sizeof ( struct wmi_cmd_hdr ) ; struct sk_buff * skb ; unsigned long time_left ; int ret = 0 ; if ( ah -> ah_flags & AH_UNPLUGGED ) return 0 ; skb = alloc_skb ( headroom + cmd_len , GFP_ATOMIC ) ; if ( ! skb ) return - ENOMEM ; skb_reserve ( skb , headroom ) ; if ( cmd_len != 0 && cmd_buf != NULL ) { skb_put_data ( skb , cmd_buf , cmd_len ) ; } mutex_lock ( & wmi -> op_mutex ) ; if ( unlikely ( wmi -> stopped ) ) { ret = - EPROTO ; goto out ; } wmi -> cmd_rsp_buf = rsp_buf ; wmi -> cmd_rsp_len = rsp_len ; ret = ath9k_wmi_cmd_issue ( wmi , skb , cmd_id , cmd_len ) ; if ( ret ) goto out ; time_left = wait_for_completion_timeout ( & wmi -> cmd_wait , timeout ) ; if ( ! time_left ) { ath_dbg ( common , WMI , ""TimeoutwaitingforWMIcommand:%s\\n"" , wmi_cmd_to_name ( cmd_id ) ) ; mutex_unlock ( & wmi -> op_mutex ) ; return - ETIMEDOUT ; } mutex_unlock ( & wmi -> op_mutex ) ; return 0 ; out : ath_dbg ( common , WMI , ""WMIfailurefor:%s\\n"" , wmi_cmd_to_name ( cmd_id ) ) ; mutex_unlock ( & wmi -> op_mutex ) ; kfree_skb ( skb ) ; return ret ; } "," op_mutex ) ; kfree_skb ( skb ) ; ",torvalds@linux/728c1e2a05e4b5fc52fab3421dce772a806612a2,CVE-2019-19074,https://github.com/torvalds/linux/commit/728c1e2a05e4b5fc52fab3421dce772a806612a2,2019-11-18T06:15Z 3,CWE-399,"CWE-399 static int yam_ioctl ( struct net_device * dev , struct ifreq * ifr , int cmd ) { struct yam_port * yp = netdev_priv ( dev ) ; struct yamdrv_ioctl_cfg yi ; struct yamdrv_ioctl_mcs * ym ; int ioctl_cmd ; if ( copy_from_user ( & ioctl_cmd , ifr -> ifr_data , sizeof ( int ) ) ) return - EFAULT ; if ( yp -> magic != YAM_MAGIC ) return - EINVAL ; if ( ! capable ( CAP_NET_ADMIN ) ) return - EPERM ; if ( cmd != SIOCDEVPRIVATE ) return - EINVAL ; switch ( ioctl_cmd ) { case SIOCYAMRESERVED : return - EINVAL ; case SIOCYAMSMCS : if ( netif_running ( dev ) ) return - EINVAL ; if ( ( ym = kmalloc ( sizeof ( struct yamdrv_ioctl_mcs ) , GFP_KERNEL ) ) == NULL ) return - ENOBUFS ; if ( copy_from_user ( ym , ifr -> ifr_data , sizeof ( struct yamdrv_ioctl_mcs ) ) ) { kfree ( ym ) ; return - EFAULT ; } if ( ym -> bitrate > YAM_MAXBITRATE ) { kfree ( ym ) ; return - EINVAL ; } add_mcs ( ym -> bits , ym -> bitrate , 0 ) ; kfree ( ym ) ; break ; case SIOCYAMSCFG : if ( ! capable ( CAP_SYS_RAWIO ) ) return - EPERM ; if ( copy_from_user ( & yi , ifr -> ifr_data , sizeof ( struct yamdrv_ioctl_cfg ) ) ) return - EFAULT ; if ( ( yi . cfg . mask & YAM_IOBASE ) && netif_running ( dev ) ) return - EINVAL ; if ( ( yi . cfg . mask & YAM_IRQ ) && netif_running ( dev ) ) return - EINVAL ; if ( ( yi . cfg . mask & YAM_BITRATE ) && netif_running ( dev ) ) return - EINVAL ; if ( ( yi . cfg . mask & YAM_BAUDRATE ) && netif_running ( dev ) ) return - EINVAL ; if ( yi . cfg . mask & YAM_IOBASE ) { yp -> iobase = yi . cfg . iobase ; dev -> base_addr = yi . cfg . iobase ; } if ( yi . cfg . mask & YAM_IRQ ) { if ( yi . cfg . irq > 15 ) return - EINVAL ; yp -> irq = yi . cfg . irq ; dev -> irq = yi . cfg . irq ; } if ( yi . cfg . mask & YAM_BITRATE ) { if ( yi . cfg . bitrate > YAM_MAXBITRATE ) return - EINVAL ; yp -> bitrate = yi . cfg . bitrate ; } if ( yi . cfg . mask & YAM_BAUDRATE ) { if ( yi . cfg . baudrate > YAM_MAXBAUDRATE ) return - EINVAL ; yp -> baudrate = yi . cfg . baudrate ; } if ( yi . cfg . mask & YAM_MODE ) { if ( yi . cfg . mode > YAM_MAXMODE ) return - EINVAL ; yp -> dupmode = yi . cfg . mode ; } if ( yi . cfg . mask & YAM_HOLDDLY ) { if ( yi . cfg . holddly > YAM_MAXHOLDDLY ) return - EINVAL ; yp -> holdd = yi . cfg . holddly ; } if ( yi . cfg . mask & YAM_TXDELAY ) { if ( yi . cfg . txdelay > YAM_MAXTXDELAY ) return - EINVAL ; yp -> txd = yi . cfg . txdelay ; } if ( yi . cfg . mask & YAM_TXTAIL ) { if ( yi . cfg . txtail > YAM_MAXTXTAIL ) return - EINVAL ; yp -> txtail = yi . cfg . txtail ; } if ( yi . cfg . mask & YAM_PERSIST ) { if ( yi . cfg . persist > YAM_MAXPERSIST ) return - EINVAL ; yp -> pers = yi . cfg . persist ; } if ( yi . cfg . mask & YAM_SLOTTIME ) { if ( yi . cfg . slottime > YAM_MAXSLOTTIME ) return - EINVAL ; yp -> slot = yi . cfg . slottime ; yp -> slotcnt = yp -> slot / 10 ; } break ; case SIOCYAMGCFG : yi . cfg . mask = 0xffffffff ; yi . cfg . iobase = yp -> iobase ; yi . cfg . irq = yp -> irq ; yi . cfg . bitrate = yp -> bitrate ; yi . cfg . baudrate = yp -> baudrate ; yi . cfg . mode = yp -> dupmode ; yi . cfg . txdelay = yp -> txd ; yi . cfg . holddly = yp -> holdd ; yi . cfg . txtail = yp -> txtail ; yi . cfg . persist = yp -> pers ; yi . cfg . slottime = yp -> slot ; if ( copy_to_user ( ifr -> ifr_data , & yi , sizeof ( struct yamdrv_ioctl_cfg ) ) ) return - EFAULT ; break ; default : return - EINVAL ; } return 0 ; } "," case SIOCYAMGCFG : memset ( & yi , 0 , sizeof ( yi ) ) ; ",torvalds@linux/8e3fbf870481eb53b2d3a322d1fc395ad8b367ed,CVE-2014-1446,https://github.com/torvalds/linux/commit/8e3fbf870481eb53b2d3a322d1fc395ad8b367ed,2014-01-18T22:55Z 4,CWE-189,"CWE-189 static struct sk_buff * udp6_ufo_fragment ( struct sk_buff * skb , netdev_features_t features ) { struct sk_buff * segs = ERR_PTR ( - EINVAL ) ; unsigned int mss ; unsigned int unfrag_ip6hlen , unfrag_len ; struct frag_hdr * fptr ; u8 * packet_start , * prevhdr ; u8 nexthdr ; u8 frag_hdr_sz = sizeof ( struct frag_hdr ) ; int offset ; __wsum csum ; int tnl_hlen ; mss = skb_shinfo ( skb ) -> gso_size ; if ( unlikely ( skb -> len <= mss ) ) goto out ; if ( skb_gso_ok ( skb , features | NETIF_F_GSO_ROBUST ) ) { int type = skb_shinfo ( skb ) -> gso_type ; if ( unlikely ( type & ~ ( SKB_GSO_UDP | SKB_GSO_DODGY | SKB_GSO_UDP_TUNNEL | SKB_GSO_GRE | SKB_GSO_IPIP | SKB_GSO_SIT | SKB_GSO_MPLS ) || ! ( type & ( SKB_GSO_UDP ) ) ) ) goto out ; skb_shinfo ( skb ) -> gso_segs = DIV_ROUND_UP ( skb -> len , mss ) ; segs = NULL ; goto out ; } if ( skb -> encapsulation && skb_shinfo ( skb ) -> gso_type & SKB_GSO_UDP_TUNNEL ) segs = skb_udp_tunnel_segment ( skb , features ) ; else { offset = skb_checksum_start_offset ( skb ) ; csum = skb_checksum ( skb , offset , skb -> len - offset , 0 ) ; offset += skb -> csum_offset ; * ( __sum16 * ) ( skb -> data + offset ) = csum_fold ( csum ) ; skb -> ip_summed = CHECKSUM_NONE ; tnl_hlen = skb_tnl_header_len ( skb ) ; if ( skb_headroom ( skb ) < ( tnl_hlen + frag_hdr_sz ) ) { if ( gso_pskb_expand_head ( skb , tnl_hlen + frag_hdr_sz ) ) goto out ; } unfrag_ip6hlen = ip6_find_1stfragopt ( skb , & prevhdr ) ; nexthdr = * prevhdr ; * prevhdr = NEXTHDR_FRAGMENT ; unfrag_len = ( skb_network_header ( skb ) - skb_mac_header ( skb ) ) + unfrag_ip6hlen + tnl_hlen ; packet_start = ( u8 * ) skb -> head + SKB_GSO_CB ( skb ) -> mac_offset ; memmove ( packet_start - frag_hdr_sz , packet_start , unfrag_len ) ; SKB_GSO_CB ( skb ) -> mac_offset -= frag_hdr_sz ; skb -> mac_header -= frag_hdr_sz ; skb -> network_header -= frag_hdr_sz ; fptr = ( struct frag_hdr * ) ( skb_network_header ( skb ) + unfrag_ip6hlen ) ; fptr -> nexthdr = nexthdr ; fptr -> reserved = 0 ; ipv6_select_ident ( fptr , ( struct rt6_info * ) skb_dst ( skb ) ) ; segs = skb_segment ( skb , features ) ; } out : return segs ; } "," ; if ( skb -> mac_header < ( tnl_hlen ",torvalds@linux/0e033e04c2678dbbe74a46b23fffb7bb918c288e,CVE-2013-4563,https://github.com/torvalds/linux/commit/0e033e04c2678dbbe74a46b23fffb7bb918c288e,2013-11-20T13:19Z 5,CWE-834,"CWE-834 static int read_tfra ( MOVContext * mov , AVIOContext * f ) { MOVFragmentIndex * index = NULL ; int version , fieldlength , i , j ; int64_t pos = avio_tell ( f ) ; uint32_t size = avio_rb32 ( f ) ; void * tmp ; if ( avio_rb32 ( f ) != MKBETAG ( 't' , 'f' , 'r' , 'a' ) ) { return 1 ; } av_log ( mov -> fc , AV_LOG_VERBOSE , ""foundtfra\\n"" ) ; index = av_mallocz ( sizeof ( MOVFragmentIndex ) ) ; if ( ! index ) { return AVERROR ( ENOMEM ) ; } tmp = av_realloc_array ( mov -> fragment_index_data , mov -> fragment_index_count + 1 , sizeof ( MOVFragmentIndex * ) ) ; if ( ! tmp ) { av_freep ( & index ) ; return AVERROR ( ENOMEM ) ; } mov -> fragment_index_data = tmp ; mov -> fragment_index_data [ mov -> fragment_index_count ++ ] = index ; version = avio_r8 ( f ) ; avio_rb24 ( f ) ; index -> track_id = avio_rb32 ( f ) ; fieldlength = avio_rb32 ( f ) ; index -> item_count = avio_rb32 ( f ) ; index -> items = av_mallocz_array ( index -> item_count , sizeof ( MOVFragmentIndexItem ) ) ; if ( ! index -> items ) { index -> item_count = 0 ; return AVERROR ( ENOMEM ) ; } for ( i = 0 ; i < index -> item_count ; i ++ ) { int64_t time , offset ; if ( version == 1 ) { time = avio_rb64 ( f ) ; offset = avio_rb64 ( f ) ; } else { time = avio_rb32 ( f ) ; offset = avio_rb32 ( f ) ; } index -> items [ i ] . time = time ; index -> items [ i ] . moof_offset = offset ; for ( j = 0 ; j < ( ( fieldlength >> 4 ) & 3 ) + 1 ; j ++ ) avio_r8 ( f ) ; for ( j = 0 ; j < ( ( fieldlength >> 2 ) & 3 ) + 1 ; j ++ ) avio_r8 ( f ) ; for ( j = 0 ; j < ( ( fieldlength >> 0 ) & 3 ) + 1 ; j ++ ) avio_r8 ( f ) ; } avio_seek ( f , pos + size , SEEK_SET ) ; return 0 ; } "," , offset ; if ( avio_feof ( f ) ) { index -> item_count = 0 ; av_freep ( & index -> items ) ; return AVERROR_INVALIDDATA ; } ",FFmpeg@FFmpeg/9cb4eb772839c5e1de2855d126bf74ff16d13382,CVE-2017-14222,https://github.com/FFmpeg/FFmpeg/commit/9cb4eb772839c5e1de2855d126bf74ff16d13382,2017-09-09T01:29Z 6,CWE-119,"CWE-119 static struct se_portal_group * vhost_scsi_make_tpg ( struct se_wwn * wwn , struct config_group * group , const char * name ) { struct vhost_scsi_tport * tport = container_of ( wwn , struct vhost_scsi_tport , tport_wwn ) ; struct vhost_scsi_tpg * tpg ; unsigned long tpgt ; int ret ; if ( strstr ( name , ""tpgt_"" ) != name ) return ERR_PTR ( - EINVAL ) ; if ( kstrtoul ( name + 5 , 10 , & tpgt ) || tpgt > UINT_MAX ) return ERR_PTR ( - EINVAL ) ; tpg = kzalloc ( sizeof ( struct vhost_scsi_tpg ) , GFP_KERNEL ) ; if ( ! tpg ) { pr_err ( ""Unabletoallocatestructvhost_scsi_tpg"" ) ; return ERR_PTR ( - ENOMEM ) ; } mutex_init ( & tpg -> tv_tpg_mutex ) ; INIT_LIST_HEAD ( & tpg -> tv_tpg_list ) ; tpg -> tport = tport ; tpg -> tport_tpgt = tpgt ; ret = core_tpg_register ( & vhost_scsi_fabric_configfs -> tf_ops , wwn , & tpg -> se_tpg , tpg , TRANSPORT_TPG_TYPE_NORMAL ) ; if ( ret < 0 ) { kfree ( tpg ) ; return NULL ; } mutex_lock ( & vhost_scsi_mutex ) ; list_add_tail ( & tpg -> tv_tpg_list , & vhost_scsi_list ) ; mutex_unlock ( & vhost_scsi_mutex ) ; return & tpg -> se_tpg ; } "," * tpg ; u16 tpgt ; int ; if ( kstrtou16 ( name + ) || tpgt >= VHOST_SCSI_MAX_TARGET ) return ERR_PTR ",torvalds@linux/59c816c1f24df0204e01851431d3bab3eb76719c,CVE-2015-4036,https://github.com/torvalds/linux/commit/59c816c1f24df0204e01851431d3bab3eb76719c,2015-08-31T20:59Z 7,CWE-416,"CWE-416 void CleanWriters ( GF_List * writers ) { while ( gf_list_count ( writers ) ) { TrackWriter * writer = ( TrackWriter * ) gf_list_get ( writers , 0 ) ; gf_isom_box_del ( writer -> stco ) ; gf_isom_box_del ( ( GF_Box * ) writer -> stsc ) ; gf_free ( writer ) ; gf_list_rem ( writers , 0 ) ; } } "," writers , 0 ) ; gf_list_del_item ( writer -> stbl -> child_boxes , writer -> stco ) ; gf_list_del_item ( writer -> stbl -> child_boxes , writer -> stsc ",gpac@gpac/5aba27604d957e960d8069d85ccaf868f8a7b07a,CVE-2020-35980,https://github.com/gpac/gpac/commit/5aba27604d957e960d8069d85ccaf868f8a7b07a,2021-04-21T16:15Z 8,CWE-20,"CWE-20 void kvm_lapic_sync_from_vapic ( struct kvm_vcpu * vcpu ) { u32 data ; void * vapic ; if ( test_bit ( KVM_APIC_PV_EOI_PENDING , & vcpu -> arch . apic_attention ) ) apic_sync_pv_eoi_from_guest ( vcpu , vcpu -> arch . apic ) ; if ( ! test_bit ( KVM_APIC_CHECK_VAPIC , & vcpu -> arch . apic_attention ) ) return ; vapic = kmap_atomic ( vcpu -> arch . apic -> vapic_page ) ; data = * ( u32 * ) ( vapic + offset_in_page ( vcpu -> arch . apic -> vapic_addr ) ) ; kunmap_atomic ( vapic ) ; apic_set_tpr ( vcpu -> arch . apic , data & 0xff ) ; } "," { u32 data ; if ( ) return ; kvm_read_guest_cached ( vcpu -> kvm , & vcpu -> arch . apic -> vapic_cache , & data , sizeof ( u32 ) ) ; apic_set_tpr ",torvalds@linux/fda4e2e85589191b123d31cdc21fd33ee70f50fd,CVE-2013-6368,https://github.com/torvalds/linux/commit/fda4e2e85589191b123d31cdc21fd33ee70f50fd,2013-12-14T18:08Z 9,CWE-20,"CWE-20 int arch_dup_task_struct ( struct task_struct * dst , struct task_struct * src ) { flush_fp_to_thread ( src ) ; flush_altivec_to_thread ( src ) ; flush_vsx_to_thread ( src ) ; flush_spe_to_thread ( src ) ; * dst = * src ; clear_task_ebb ( dst ) ; return 0 ; } "," src ) ; __switch_to_tm ( src ) ; tm_recheckpoint_new_task ( src ) ; ",torvalds@linux/621b5060e823301d0cba4cb52a7ee3491922d291,CVE-2014-2673,https://github.com/torvalds/linux/commit/621b5060e823301d0cba4cb52a7ee3491922d291,2014-04-01T06:35Z 10,CWE-119,"CWE-119 cJSON * cJSON_GetArrayItem ( cJSON * array , int item ) { cJSON * c = array -> child ; while ( c && item > 0 ) { -- item ; c = c -> next ; } return c ; } "," c = array ? array -> child : 0 ; while ( > 0 ) item -- , c = c -> next ; return c ; ",esnet@iperf/91f2fa59e8ed80dfbf400add0164ee0e508e412a,CVE-2016-4303,https://github.com/esnet/iperf/commit/91f2fa59e8ed80dfbf400add0164ee0e508e412a,2016-09-26T14:59Z 11,CWE-20,"CWE-20 static ext3_fsblk_t get_sb_block ( void * * data , struct super_block * sb ) { ext3_fsblk_t sb_block ; char * options = ( char * ) * data ; if ( ! options || strncmp ( options , ""sb="" , 3 ) != 0 ) return 1 ; options += 3 ; sb_block = simple_strtoul ( options , & options , 0 ) ; if ( * options && * options != ',' ) { ext3_msg ( sb , ""error:invalidsbspecification:%s"" , ( char * ) * data ) ; return 1 ; } if ( * options == ',' ) options ++ ; * data = ( void * ) options ; return sb_block ; } "," ( sb , KERN_ERR , ",torvalds@linux/8d0c2d10dd72c5292eda7a06231056a4c972e4cc,CVE-2013-1848,https://github.com/torvalds/linux/commit/8d0c2d10dd72c5292eda7a06231056a4c972e4cc,2013-03-22T11:59Z 12,CWE-000,"CWE-000 static struct sk_buff * udp6_ufo_fragment ( struct sk_buff * skb , u32 features ) { struct sk_buff * segs = ERR_PTR ( - EINVAL ) ; unsigned int mss ; unsigned int unfrag_ip6hlen , unfrag_len ; struct frag_hdr * fptr ; u8 * mac_start , * prevhdr ; u8 nexthdr ; u8 frag_hdr_sz = sizeof ( struct frag_hdr ) ; int offset ; __wsum csum ; mss = skb_shinfo ( skb ) -> gso_size ; if ( unlikely ( skb -> len <= mss ) ) goto out ; if ( skb_gso_ok ( skb , features | NETIF_F_GSO_ROBUST ) ) { int type = skb_shinfo ( skb ) -> gso_type ; if ( unlikely ( type & ~ ( SKB_GSO_UDP | SKB_GSO_DODGY ) || ! ( type & ( SKB_GSO_UDP ) ) ) ) goto out ; skb_shinfo ( skb ) -> gso_segs = DIV_ROUND_UP ( skb -> len , mss ) ; segs = NULL ; goto out ; } offset = skb_checksum_start_offset ( skb ) ; csum = skb_checksum ( skb , offset , skb -> len - offset , 0 ) ; offset += skb -> csum_offset ; * ( __sum16 * ) ( skb -> data + offset ) = csum_fold ( csum ) ; skb -> ip_summed = CHECKSUM_NONE ; if ( ( skb_mac_header ( skb ) < skb -> head + frag_hdr_sz ) && pskb_expand_head ( skb , frag_hdr_sz , 0 , GFP_ATOMIC ) ) goto out ; unfrag_ip6hlen = ip6_find_1stfragopt ( skb , & prevhdr ) ; nexthdr = * prevhdr ; * prevhdr = NEXTHDR_FRAGMENT ; unfrag_len = skb_network_header ( skb ) - skb_mac_header ( skb ) + unfrag_ip6hlen ; mac_start = skb_mac_header ( skb ) ; memmove ( mac_start - frag_hdr_sz , mac_start , unfrag_len ) ; skb -> mac_header -= frag_hdr_sz ; skb -> network_header -= frag_hdr_sz ; fptr = ( struct frag_hdr * ) ( skb_network_header ( skb ) + unfrag_ip6hlen ) ; fptr -> nexthdr = nexthdr ; fptr -> reserved = 0 ; ipv6_select_ident ( fptr ) ; segs = skb_segment ( skb , features ) ; out : return segs ; } "," ipv6_select_ident ( fptr , ( struct rt6_info * ) skb_dst ( skb ) ",torvalds@linux/87c48fa3b4630905f98268dde838ee43626a060c,CVE-2011-2699,https://github.com/torvalds/linux/commit/87c48fa3b4630905f98268dde838ee43626a060c,2012-05-24T23:55Z 13,CWE-400,"CWE-400 void __perf_sw_event ( u32 event_id , u64 nr , int nmi , struct pt_regs * regs , u64 addr ) { struct perf_sample_data data ; int rctx ; preempt_disable_notrace ( ) ; rctx = perf_swevent_get_recursion_context ( ) ; if ( rctx < 0 ) return ; perf_sample_data_init ( & data , addr ) ; do_perf_sw_event ( PERF_TYPE_SOFTWARE , event_id , nr , nmi , & data , regs ) ; perf_swevent_put_recursion_context ( rctx ) ; preempt_enable_notrace ( ) ; } "," u64 nr , struct pt_regs * , nr , & data , ",torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,CVE-2011-2918,https://github.com/torvalds/linux/commit/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,2012-05-24T23:55Z 14,CWE-119,"CWE-119 static grub_disk_addr_t grub_ext2_read_block ( grub_fshelp_node_t node , grub_disk_addr_t fileblock ) { struct grub_ext2_data * data = node -> data ; struct grub_ext2_inode * inode = & node -> inode ; int blknr = - 1 ; unsigned int blksz = EXT2_BLOCK_SIZE ( data ) ; int log2_blksz = LOG2_EXT2_BLOCK_SIZE ( data ) ; if ( grub_le_to_cpu32 ( inode -> flags ) & EXT4_EXTENTS_FLAG ) { # ifndef _MSC_VER char buf [ EXT2_BLOCK_SIZE ( data ) ] ; # else char * buf = grub_malloc ( EXT2_BLOCK_SIZE ( data ) ) ; # endif struct grub_ext4_extent_header * leaf ; struct grub_ext4_extent * ext ; int i ; leaf = grub_ext4_find_leaf ( data , buf , ( struct grub_ext4_extent_header * ) inode -> blocks . dir_blocks , fileblock ) ; if ( ! leaf ) { grub_error ( GRUB_ERR_BAD_FS , ""invalidextent"" ) ; return - 1 ; } ext = ( struct grub_ext4_extent * ) ( leaf + 1 ) ; for ( i = 0 ; i < grub_le_to_cpu16 ( leaf -> entries ) ; i ++ ) { if ( fileblock < grub_le_to_cpu32 ( ext [ i ] . block ) ) break ; } if ( -- i >= 0 ) { fileblock -= grub_le_to_cpu32 ( ext [ i ] . block ) ; if ( fileblock >= grub_le_to_cpu16 ( ext [ i ] . len ) ) return 0 ; else { grub_disk_addr_t start ; start = grub_le_to_cpu16 ( ext [ i ] . start_hi ) ; start = ( start << 32 ) + grub_le_to_cpu32 ( ext [ i ] . start ) ; return fileblock + start ; } } else { grub_error ( GRUB_ERR_BAD_FS , ""somethingwrongwithextent"" ) ; return - 1 ; } } if ( fileblock < INDIRECT_BLOCKS ) { blknr = grub_le_to_cpu32 ( inode -> blocks . dir_blocks [ fileblock ] ) ; } else if ( fileblock < INDIRECT_BLOCKS + blksz / 4 ) { grub_uint32_t * indir ; indir = grub_malloc ( blksz ) ; if ( ! indir ) return grub_errno ; if ( grub_disk_read ( data -> disk , ( ( grub_disk_addr_t ) grub_le_to_cpu32 ( inode -> blocks . indir_block ) ) << log2_blksz , 0 , blksz , indir ) ) return grub_errno ; blknr = grub_le_to_cpu32 ( indir [ fileblock - INDIRECT_BLOCKS ] ) ; grub_free ( indir ) ; } else if ( fileblock < ( grub_disk_addr_t ) ( INDIRECT_BLOCKS + blksz / 4 ) * ( grub_disk_addr_t ) ( blksz / 4 + 1 ) ) { unsigned int perblock = blksz / 4 ; unsigned int rblock = fileblock - ( INDIRECT_BLOCKS + blksz / 4 ) ; grub_uint32_t * indir ; indir = grub_malloc ( blksz ) ; if ( ! indir ) return grub_errno ; if ( grub_disk_read ( data -> disk , ( ( grub_disk_addr_t ) grub_le_to_cpu32 ( inode -> blocks . double_indir_block ) ) << log2_blksz , 0 , blksz , indir ) ) return grub_errno ; if ( grub_disk_read ( data -> disk , ( ( grub_disk_addr_t ) grub_le_to_cpu32 ( indir [ rblock / perblock ] ) ) << log2_blksz , 0 , blksz , indir ) ) return grub_errno ; blknr = grub_le_to_cpu32 ( indir [ rblock % perblock ] ) ; grub_free ( indir ) ; } else { grub_error ( GRUB_ERR_NOT_IMPLEMENTED_YET , ""ext2fsdoesn\'tsupporttripleindirectblocks"" ) ; } return blknr ; } "," EXT4_EXTENTS_FLAG ) { char * buf = grub_malloc ( EXT2_BLOCK_SIZE ( data ( data ) ) ; if ( ! buf ) { return - 1 ; } struct grub_ext4_extent_header * GRUB_ERR_BAD_FS , ""invalidextent"" ) ; free ( buf len ) ) { free ( buf ) ; return 0 ; } start ) ; free ( buf ) ; ""somethingwrongwithextent"" ) ; free ( buf ) ; 1 ; } free ( buf ) ; ! indir ) { return grub_errno ; } indir ) ) { return grub_errno ; } ! indir ) { return grub_errno ; } indir ) ) { return grub_errno ; } indir ) ) { return grub_errno ; } ",radare@radare2/65000a7fd9eea62359e6d6714f17b94a99a82edd,CVE-2017-9763,https://github.com/radare/radare2/commit/65000a7fd9eea62359e6d6714f17b94a99a82edd,2017-06-19T16:29Z 15,CWE-119,"CWE-119 static void fdct16 ( const int16_t in [ 16 ] , int16_t out [ 16 ] ) { int step1 [ 8 ] ; int step2 [ 8 ] ; int step3 [ 8 ] ; int input [ 8 ] ; int temp1 , temp2 ; input [ 0 ] = in [ 0 ] + in [ 15 ] ; input [ 1 ] = in [ 1 ] + in [ 14 ] ; input [ 2 ] = in [ 2 ] + in [ 13 ] ; input [ 3 ] = in [ 3 ] + in [ 12 ] ; input [ 4 ] = in [ 4 ] + in [ 11 ] ; input [ 5 ] = in [ 5 ] + in [ 10 ] ; input [ 6 ] = in [ 6 ] + in [ 9 ] ; input [ 7 ] = in [ 7 ] + in [ 8 ] ; step1 [ 0 ] = in [ 7 ] - in [ 8 ] ; step1 [ 1 ] = in [ 6 ] - in [ 9 ] ; step1 [ 2 ] = in [ 5 ] - in [ 10 ] ; step1 [ 3 ] = in [ 4 ] - in [ 11 ] ; step1 [ 4 ] = in [ 3 ] - in [ 12 ] ; step1 [ 5 ] = in [ 2 ] - in [ 13 ] ; step1 [ 6 ] = in [ 1 ] - in [ 14 ] ; step1 [ 7 ] = in [ 0 ] - in [ 15 ] ; { int s0 , s1 , s2 , s3 , s4 , s5 , s6 , s7 ; int t0 , t1 , t2 , t3 ; int x0 , x1 , x2 , x3 ; s0 = input [ 0 ] + input [ 7 ] ; s1 = input [ 1 ] + input [ 6 ] ; s2 = input [ 2 ] + input [ 5 ] ; s3 = input [ 3 ] + input [ 4 ] ; s4 = input [ 3 ] - input [ 4 ] ; s5 = input [ 2 ] - input [ 5 ] ; s6 = input [ 1 ] - input [ 6 ] ; s7 = input [ 0 ] - input [ 7 ] ; x0 = s0 + s3 ; x1 = s1 + s2 ; x2 = s1 - s2 ; x3 = s0 - s3 ; t0 = ( x0 + x1 ) * cospi_16_64 ; t1 = ( x0 - x1 ) * cospi_16_64 ; t2 = x3 * cospi_8_64 + x2 * cospi_24_64 ; t3 = x3 * cospi_24_64 - x2 * cospi_8_64 ; out [ 0 ] = fdct_round_shift ( t0 ) ; out [ 4 ] = fdct_round_shift ( t2 ) ; out [ 8 ] = fdct_round_shift ( t1 ) ; out [ 12 ] = fdct_round_shift ( t3 ) ; t0 = ( s6 - s5 ) * cospi_16_64 ; t1 = ( s6 + s5 ) * cospi_16_64 ; t2 = fdct_round_shift ( t0 ) ; t3 = fdct_round_shift ( t1 ) ; x0 = s4 + t2 ; x1 = s4 - t2 ; x2 = s7 - t3 ; x3 = s7 + t3 ; t0 = x0 * cospi_28_64 + x3 * cospi_4_64 ; t1 = x1 * cospi_12_64 + x2 * cospi_20_64 ; t2 = x2 * cospi_12_64 + x1 * - cospi_20_64 ; t3 = x3 * cospi_28_64 + x0 * - cospi_4_64 ; out [ 2 ] = fdct_round_shift ( t0 ) ; out [ 6 ] = fdct_round_shift ( t2 ) ; out [ 10 ] = fdct_round_shift ( t1 ) ; out [ 14 ] = fdct_round_shift ( t3 ) ; } temp1 = ( step1 [ 5 ] - step1 [ 2 ] ) * cospi_16_64 ; temp2 = ( step1 [ 4 ] - step1 [ 3 ] ) * cospi_16_64 ; step2 [ 2 ] = fdct_round_shift ( temp1 ) ; step2 [ 3 ] = fdct_round_shift ( temp2 ) ; temp1 = ( step1 [ 4 ] + step1 [ 3 ] ) * cospi_16_64 ; temp2 = ( step1 [ 5 ] + step1 [ 2 ] ) * cospi_16_64 ; step2 [ 4 ] = fdct_round_shift ( temp1 ) ; step2 [ 5 ] = fdct_round_shift ( temp2 ) ; step3 [ 0 ] = step1 [ 0 ] + step2 [ 3 ] ; step3 [ 1 ] = step1 [ 1 ] + step2 [ 2 ] ; step3 [ 2 ] = step1 [ 1 ] - step2 [ 2 ] ; step3 [ 3 ] = step1 [ 0 ] - step2 [ 3 ] ; step3 [ 4 ] = step1 [ 7 ] - step2 [ 4 ] ; step3 [ 5 ] = step1 [ 6 ] - step2 [ 5 ] ; step3 [ 6 ] = step1 [ 6 ] + step2 [ 5 ] ; step3 [ 7 ] = step1 [ 7 ] + step2 [ 4 ] ; temp1 = step3 [ 1 ] * - cospi_8_64 + step3 [ 6 ] * cospi_24_64 ; temp2 = step3 [ 2 ] * - cospi_24_64 - step3 [ 5 ] * cospi_8_64 ; step2 [ 1 ] = fdct_round_shift ( temp1 ) ; step2 [ 2 ] = fdct_round_shift ( temp2 ) ; temp1 = step3 [ 2 ] * - cospi_8_64 + step3 [ 5 ] * cospi_24_64 ; temp2 = step3 [ 1 ] * cospi_24_64 + step3 [ 6 ] * cospi_8_64 ; step2 [ 5 ] = fdct_round_shift ( temp1 ) ; step2 [ 6 ] = fdct_round_shift ( temp2 ) ; step1 [ 0 ] = step3 [ 0 ] + step2 [ 1 ] ; step1 [ 1 ] = step3 [ 0 ] - step2 [ 1 ] ; step1 [ 2 ] = step3 [ 3 ] - step2 [ 2 ] ; step1 [ 3 ] = step3 [ 3 ] + step2 [ 2 ] ; step1 [ 4 ] = step3 [ 4 ] + step2 [ 5 ] ; step1 [ 5 ] = step3 [ 4 ] - step2 [ 5 ] ; step1 [ 6 ] = step3 [ 7 ] - step2 [ 6 ] ; step1 [ 7 ] = step3 [ 7 ] + step2 [ 6 ] ; temp1 = step1 [ 0 ] * cospi_30_64 + step1 [ 7 ] * cospi_2_64 ; temp2 = step1 [ 1 ] * cospi_14_64 + step1 [ 6 ] * cospi_18_64 ; out [ 1 ] = fdct_round_shift ( temp1 ) ; out [ 9 ] = fdct_round_shift ( temp2 ) ; temp1 = step1 [ 2 ] * cospi_22_64 + step1 [ 5 ] * cospi_10_64 ; temp2 = step1 [ 3 ] * cospi_6_64 + step1 [ 4 ] * cospi_26_64 ; out [ 5 ] = fdct_round_shift ( temp1 ) ; out [ 13 ] = fdct_round_shift ( temp2 ) ; temp1 = step1 [ 3 ] * - cospi_26_64 + step1 [ 4 ] * cospi_6_64 ; temp2 = step1 [ 2 ] * - cospi_10_64 + step1 [ 5 ] * cospi_22_64 ; out [ 3 ] = fdct_round_shift ( temp1 ) ; out [ 11 ] = fdct_round_shift ( temp2 ) ; temp1 = step1 [ 1 ] * - cospi_18_64 + step1 [ 6 ] * cospi_14_64 ; temp2 = step1 [ 0 ] * - cospi_2_64 + step1 [ 7 ] * cospi_30_64 ; out [ 7 ] = fdct_round_shift ( temp1 ) ; out [ 15 ] = fdct_round_shift ( temp2 ) ; } "," fdct16 ( const tran_low_t in [ 16 16 ] , tran_low_t out [ 16 ] ) { tran_high_t step1 [ 8 8 ] ; tran_high_t step2 [ 8 8 ] ; tran_high_t step3 [ 8 8 ] ; tran_high_t input [ 8 8 ] ; tran_high_t temp1 , temp2 ] ; { tran_high_t s0 , s1 , s7 ; tran_high_t t0 , t1 , t3 ; tran_high_t x0 , x1 0 ] = ( tran_low_t ) 4 ] = ( tran_low_t ) 8 ] = ( tran_low_t ) 12 ] = ( tran_low_t ) 2 ] = ( tran_low_t ) 6 ] = ( tran_low_t ) 10 ] = ( tran_low_t ) 14 ] = ( tran_low_t ) 2 ] * cospi_24_64 + step3 [ 5 2 ] * cospi_8_64 - step3 [ 5 [ 3 ] + step2 [ 2 ] ; step1 [ 3 ] = step3 [ 3 ] - step2 [ 2 ] ; step1 [ 4 ] = step3 [ 4 ] - step2 [ 5 ] ; step1 [ 5 ] = step3 [ 4 ] + step2 [ 5 1 ] = ( tran_low_t ) 9 ] = ( tran_low_t ) 5 ] = ( tran_low_t ) 13 ] = ( tran_low_t ) 3 ] = ( tran_low_t ) 11 ] = ( tran_low_t ) 7 ] = ( tran_low_t ) 15 ] = ( tran_low_t ) ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 16,CWE-20,"CWE-20 int bpf_check ( struct bpf_prog * * prog , union bpf_attr * attr ) { struct bpf_verifier_env * env ; struct bpf_verifer_log * log ; int ret = - EINVAL ; if ( ARRAY_SIZE ( bpf_verifier_ops ) == 0 ) return - EINVAL ; env = kzalloc ( sizeof ( struct bpf_verifier_env ) , GFP_KERNEL ) ; if ( ! env ) return - ENOMEM ; log = & env -> log ; env -> insn_aux_data = vzalloc ( sizeof ( struct bpf_insn_aux_data ) * ( * prog ) -> len ) ; ret = - ENOMEM ; if ( ! env -> insn_aux_data ) goto err_free_env ; env -> prog = * prog ; env -> ops = bpf_verifier_ops [ env -> prog -> type ] ; mutex_lock ( & bpf_verifier_lock ) ; if ( attr -> log_level || attr -> log_buf || attr -> log_size ) { log -> level = attr -> log_level ; log -> ubuf = ( char __user * ) ( unsigned long ) attr -> log_buf ; log -> len_total = attr -> log_size ; ret = - EINVAL ; if ( log -> len_total < 128 || log -> len_total > UINT_MAX >> 8 || ! log -> level || ! log -> ubuf ) goto err_unlock ; } env -> strict_alignment = ! ! ( attr -> prog_flags & BPF_F_STRICT_ALIGNMENT ) ; if ( ! IS_ENABLED ( CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS ) ) env -> strict_alignment = true ; if ( env -> prog -> aux -> offload ) { ret = bpf_prog_offload_verifier_prep ( env ) ; if ( ret ) goto err_unlock ; } ret = replace_map_fd_with_map_ptr ( env ) ; if ( ret < 0 ) goto skip_full_check ; env -> explored_states = kcalloc ( env -> prog -> len , sizeof ( struct bpf_verifier_state_list * ) , GFP_USER ) ; ret = - ENOMEM ; if ( ! env -> explored_states ) goto skip_full_check ; ret = check_cfg ( env ) ; if ( ret < 0 ) goto skip_full_check ; env -> allow_ptr_leaks = capable ( CAP_SYS_ADMIN ) ; ret = do_check ( env ) ; if ( env -> cur_state ) { free_verifier_state ( env -> cur_state , true ) ; env -> cur_state = NULL ; } skip_full_check : while ( ! pop_stack ( env , NULL , NULL ) ) ; free_states ( env ) ; if ( ret == 0 ) ret = convert_ctx_accesses ( env ) ; if ( ret == 0 ) ret = fixup_bpf_calls ( env ) ; if ( log -> level && bpf_verifier_log_full ( log ) ) ret = - ENOSPC ; if ( log -> level && ! log -> ubuf ) { ret = - EFAULT ; goto err_release_maps ; } if ( ret == 0 && env -> used_map_cnt ) { env -> prog -> aux -> used_maps = kmalloc_array ( env -> used_map_cnt , sizeof ( env -> used_maps [ 0 ] ) , GFP_KERNEL ) ; if ( ! env -> prog -> aux -> used_maps ) { ret = - ENOMEM ; goto err_release_maps ; } memcpy ( env -> prog -> aux -> used_maps , env -> used_maps , sizeof ( env -> used_maps [ 0 ] ) * env -> used_map_cnt ) ; env -> prog -> aux -> used_map_cnt = env -> used_map_cnt ; convert_pseudo_ld_imm64 ( env ) ; } err_release_maps : if ( ! env -> prog -> aux -> used_maps ) release_maps ( env ) ; * prog = env -> prog ; err_unlock : mutex_unlock ( & bpf_verifier_lock ) ; vfree ( env -> insn_aux_data ) ; err_free_env : kfree ( env ) ; return ret ; } "," == 0 ) sanitize_dead_code ( env ) ; if ( ret == 0 ) ",torvalds@linux/c131187db2d3fa2f8bf32fdf4e9a4ef805168467,CVE-2017-17862,https://github.com/torvalds/linux/commit/c131187db2d3fa2f8bf32fdf4e9a4ef805168467,2017-12-27T17:08Z 17,CWE-835,"CWE-835 int WavpackSetConfiguration64 ( WavpackContext * wpc , WavpackConfig * config , int64_t total_samples , const unsigned char * chan_ids ) { uint32_t flags , bps = 0 ; uint32_t chan_mask = config -> channel_mask ; int num_chans = config -> num_channels ; int i ; wpc -> stream_version = ( config -> flags & CONFIG_COMPATIBLE_WRITE ) ? CUR_STREAM_VERS : MAX_STREAM_VERS ; if ( ( config -> qmode & QMODE_DSD_AUDIO ) && config -> bytes_per_sample == 1 && config -> bits_per_sample == 8 ) { # ifdef ENABLE_DSD wpc -> dsd_multiplier = 1 ; flags = DSD_FLAG ; for ( i = 14 ; i >= 0 ; -- i ) if ( config -> sample_rate % sample_rates [ i ] == 0 ) { int divisor = config -> sample_rate / sample_rates [ i ] ; if ( divisor && ( divisor & ( divisor - 1 ) ) == 0 ) { config -> sample_rate /= divisor ; wpc -> dsd_multiplier = divisor ; break ; } } if ( config -> flags & CONFIG_HYBRID_FLAG ) { strcpy ( wpc -> error_message , ""hybridmodenotavailableforDSD!"" ) ; return FALSE ; } config -> flags &= ( CONFIG_HIGH_FLAG | CONFIG_MD5_CHECKSUM | CONFIG_PAIR_UNDEF_CHANS ) ; config -> float_norm_exp = config -> xmode = 0 ; # else strcpy ( wpc -> error_message , ""libwavpacknotconfiguredforDSD!"" ) ; return FALSE ; # endif } else flags = config -> bytes_per_sample - 1 ; wpc -> total_samples = total_samples ; wpc -> config . sample_rate = config -> sample_rate ; wpc -> config . num_channels = config -> num_channels ; wpc -> config . channel_mask = config -> channel_mask ; wpc -> config . bits_per_sample = config -> bits_per_sample ; wpc -> config . bytes_per_sample = config -> bytes_per_sample ; wpc -> config . block_samples = config -> block_samples ; wpc -> config . flags = config -> flags ; wpc -> config . qmode = config -> qmode ; if ( config -> flags & CONFIG_VERY_HIGH_FLAG ) wpc -> config . flags |= CONFIG_HIGH_FLAG ; for ( i = 0 ; i < 15 ; ++ i ) if ( wpc -> config . sample_rate == sample_rates [ i ] ) break ; flags |= i << SRATE_LSB ; if ( ! ( flags & DSD_FLAG ) ) { if ( config -> float_norm_exp ) { wpc -> config . float_norm_exp = config -> float_norm_exp ; wpc -> config . flags |= CONFIG_FLOAT_DATA ; flags |= FLOAT_DATA ; } else flags |= ( ( config -> bytes_per_sample * 8 ) - config -> bits_per_sample ) << SHIFT_LSB ; if ( config -> flags & CONFIG_HYBRID_FLAG ) { flags |= HYBRID_FLAG | HYBRID_BITRATE | HYBRID_BALANCE ; if ( ! ( wpc -> config . flags & CONFIG_SHAPE_OVERRIDE ) ) { wpc -> config . flags |= CONFIG_HYBRID_SHAPE | CONFIG_AUTO_SHAPING ; flags |= HYBRID_SHAPE | NEW_SHAPING ; } else if ( wpc -> config . flags & CONFIG_HYBRID_SHAPE ) { wpc -> config . shaping_weight = config -> shaping_weight ; flags |= HYBRID_SHAPE | NEW_SHAPING ; } if ( wpc -> config . flags & ( CONFIG_CROSS_DECORR | CONFIG_OPTIMIZE_WVC ) ) flags |= CROSS_DECORR ; if ( config -> flags & CONFIG_BITRATE_KBPS ) { bps = ( uint32_t ) floor ( config -> bitrate * 256000.0 / config -> sample_rate / config -> num_channels + 0.5 ) ; if ( bps > ( 64 << 8 ) ) bps = 64 << 8 ; } else bps = ( uint32_t ) floor ( config -> bitrate * 256.0 + 0.5 ) ; } else flags |= CROSS_DECORR ; if ( ! ( config -> flags & CONFIG_JOINT_OVERRIDE ) || ( config -> flags & CONFIG_JOINT_STEREO ) ) flags |= JOINT_STEREO ; if ( config -> flags & CONFIG_CREATE_WVC ) wpc -> wvc_flag = TRUE ; } if ( chan_ids ) { int lastchan = 0 , mask_copy = chan_mask ; if ( ( int ) strlen ( ( char * ) chan_ids ) > num_chans ) { strcpy ( wpc -> error_message , ""chan_idslongerthannumchannels!"" ) ; return FALSE ; } while ( * chan_ids ) if ( * chan_ids <= 32 && * chan_ids > lastchan && ( mask_copy & ( 1 << ( * chan_ids - 1 ) ) ) ) { mask_copy &= ~ ( 1 << ( * chan_ids - 1 ) ) ; lastchan = * chan_ids ++ ; } else break ; for ( i = 0 ; chan_ids [ i ] ; i ++ ) if ( chan_ids [ i ] != 0xff ) { wpc -> channel_identities = ( unsigned char * ) strdup ( ( char * ) chan_ids ) ; break ; } } for ( wpc -> current_stream = 0 ; num_chans ; wpc -> current_stream ++ ) { WavpackStream * wps = malloc ( sizeof ( WavpackStream ) ) ; unsigned char left_chan_id = 0 , right_chan_id = 0 ; int pos , chans = 1 ; wpc -> streams = realloc ( wpc -> streams , ( wpc -> current_stream + 1 ) * sizeof ( wpc -> streams [ 0 ] ) ) ; wpc -> streams [ wpc -> current_stream ] = wps ; CLEAR ( * wps ) ; if ( chan_mask ) for ( pos = 0 ; pos < 32 ; ++ pos ) if ( chan_mask & ( 1 << pos ) ) { if ( left_chan_id ) { right_chan_id = pos + 1 ; break ; } else { chan_mask &= ~ ( 1 << pos ) ; left_chan_id = pos + 1 ; } } while ( ! right_chan_id && chan_ids && * chan_ids ) if ( left_chan_id ) right_chan_id = * chan_ids ; else left_chan_id = * chan_ids ++ ; if ( ! left_chan_id ) left_chan_id = right_chan_id = 0xff ; else if ( ! right_chan_id ) right_chan_id = 0xff ; if ( num_chans >= 2 ) { if ( ( config -> flags & CONFIG_PAIR_UNDEF_CHANS ) && left_chan_id == 0xff && right_chan_id == 0xff ) chans = 2 ; else for ( i = 0 ; i < NUM_STEREO_PAIRS ; ++ i ) if ( ( left_chan_id == stereo_pairs [ i ] . a && right_chan_id == stereo_pairs [ i ] . b ) || ( left_chan_id == stereo_pairs [ i ] . b && right_chan_id == stereo_pairs [ i ] . a ) ) { if ( right_chan_id <= 32 && ( chan_mask & ( 1 << ( right_chan_id - 1 ) ) ) ) chan_mask &= ~ ( 1 << ( right_chan_id - 1 ) ) ; else if ( chan_ids && * chan_ids == right_chan_id ) chan_ids ++ ; chans = 2 ; break ; } } num_chans -= chans ; if ( num_chans && wpc -> current_stream == NEW_MAX_STREAMS - 1 ) break ; memcpy ( wps -> wphdr . ckID , ""wvpk"" , 4 ) ; wps -> wphdr . ckSize = sizeof ( WavpackHeader ) - 8 ; SET_TOTAL_SAMPLES ( wps -> wphdr , wpc -> total_samples ) ; wps -> wphdr . version = wpc -> stream_version ; wps -> wphdr . flags = flags ; wps -> bits = bps ; if ( ! wpc -> current_stream ) wps -> wphdr . flags |= INITIAL_BLOCK ; if ( ! num_chans ) wps -> wphdr . flags |= FINAL_BLOCK ; if ( chans == 1 ) { wps -> wphdr . flags &= ~ ( JOINT_STEREO | CROSS_DECORR | HYBRID_BALANCE ) ; wps -> wphdr . flags |= MONO_FLAG ; } } wpc -> num_streams = wpc -> current_stream ; wpc -> current_stream = 0 ; if ( num_chans ) { strcpy ( wpc -> error_message , ""toomanychannels!"" ) ; return FALSE ; } if ( config -> flags & CONFIG_EXTRA_MODE ) wpc -> config . xmode = config -> xmode ? config -> xmode : 1 ; return TRUE ; } "," int i ; if ( ! config -> sample_rate ) { strcpy ( wpc -> error_message , ""sampleratecannotbezero!"" ) ; return FALSE ; } ",dbry@WavPack/070ef6f138956d9ea9612e69586152339dbefe51,CVE-2018-19840,https://github.com/dbry/WavPack/commit/070ef6f138956d9ea9612e69586152339dbefe51,2018-12-04T09:29Z 18,CWE-787,"CWE-787 int sr_do_ioctl ( Scsi_CD * cd , struct packet_command * cgc ) { struct scsi_device * SDev ; struct scsi_sense_hdr sshdr ; int result , err = 0 , retries = 0 ; SDev = cd -> device ; retry : if ( ! scsi_block_when_processing_errors ( SDev ) ) { err = - ENODEV ; goto out ; } result = scsi_execute ( SDev , cgc -> cmd , cgc -> data_direction , cgc -> buffer , cgc -> buflen , ( unsigned char * ) cgc -> sense , & sshdr , cgc -> timeout , IOCTL_RETRIES , 0 , 0 , NULL ) ; if ( driver_byte ( result ) != 0 ) { switch ( sshdr . sense_key ) { case UNIT_ATTENTION : SDev -> changed = 1 ; if ( ! cgc -> quiet ) sr_printk ( KERN_INFO , cd , ""discchangedetected.\\n"" ) ; if ( retries ++ < 10 ) goto retry ; err = - ENOMEDIUM ; break ; case NOT_READY : if ( sshdr . asc == 0x04 && sshdr . ascq == 0x01 ) { if ( ! cgc -> quiet ) sr_printk ( KERN_INFO , cd , ""CDROMnotreadyyet.\\n"" ) ; if ( retries ++ < 10 ) { ssleep ( 2 ) ; goto retry ; } else { err = - ENOMEDIUM ; break ; } } if ( ! cgc -> quiet ) sr_printk ( KERN_INFO , cd , ""CDROMnotready.Makesurethere"" ""isadiscinthedrive.\\n"" ) ; err = - ENOMEDIUM ; break ; case ILLEGAL_REQUEST : err = - EIO ; if ( sshdr . asc == 0x20 && sshdr . ascq == 0x00 ) err = - EDRIVE_CANT_DO_THIS ; break ; default : err = - EIO ; } } out : cgc -> stat = err ; return err ; } "," = 0 ; unsigned char sense_buffer [ SCSI_SENSE_BUFFERSIZE ] , * senseptr = NULL ; cd -> device ; if ( cgc -> sense ) senseptr = sense_buffer -> buflen , senseptr , & sshdr , cgc -> timeout , IOCTL_RETRIES , 0 , 0 , NULL ) ; if ( cgc -> sense ) memcpy ( cgc -> sense , sense_buffer , sizeof ( * cgc -> sense cgc -> sense ) ) ; if ",torvalds@linux/f7068114d45ec55996b9040e98111afa56e010fe,CVE-2018-11506,https://github.com/torvalds/linux/commit/f7068114d45ec55996b9040e98111afa56e010fe,2018-05-28T04:29Z 19,CWE-119,"CWE-119 int CLASS parse_jpeg ( int offset ) { int len , save , hlen , mark ; fseek ( ifp , offset , SEEK_SET ) ; if ( fgetc ( ifp ) != 0xff || fgetc ( ifp ) != 0xd8 ) return 0 ; while ( fgetc ( ifp ) == 0xff && ( mark = fgetc ( ifp ) ) != 0xda ) { order = 0x4d4d ; len = get2 ( ) - 2 ; save = ftell ( ifp ) ; if ( mark == 0xc0 || mark == 0xc3 || mark == 0xc9 ) { fgetc ( ifp ) ; raw_height = get2 ( ) ; raw_width = get2 ( ) ; } order = get2 ( ) ; hlen = get4 ( ) ; if ( get4 ( ) == 0x48454150 ) { # ifdef LIBRAW_LIBRARY_BUILD imgdata . lens . makernotes . CameraMount = LIBRAW_MOUNT_FixedLens ; imgdata . lens . makernotes . LensMount = LIBRAW_MOUNT_FixedLens ; # endif parse_ciff ( save + hlen , len - hlen , 0 ) ; } if ( parse_tiff ( save + 6 ) ) apply_tiff ( ) ; fseek ( ifp , save + len , SEEK_SET ) ; } return 1 ; } "," ) == 0x48454150 # ifdef LIBRAW_LIBRARY_BUILD # ifdef LIBRAW_LIBRARY_BUILD && ( save + hlen ) >= 0 && ( save + hlen ) <= ifp -> size ( ) # endif ) { # ifdef LIBRAW_LIBRARY_BUILD ",LibRaw@LibRaw/d7c3d2cb460be10a3ea7b32e9443a83c243b2251,CVE-2017-6887,https://github.com/LibRaw/LibRaw/commit/d7c3d2cb460be10a3ea7b32e9443a83c243b2251,2017-05-16T16:29Z 20,CWE-119,"CWE-119 static void search_filter_level ( const YV12_BUFFER_CONFIG * sd , VP9_COMP * cpi , int partial_frame ) { VP9_COMMON * const cm = & cpi -> common ; struct loopfilter * const lf = & cm -> lf ; const int min_filter_level = 0 ; const int max_filter_level = get_max_filter_level ( cpi ) ; int best_err ; int filt_best ; int filt_direction = 0 ; int filt_mid = clamp ( lf -> filter_level , min_filter_level , max_filter_level ) ; int filter_step = filt_mid < 16 ? 4 : filt_mid / 4 ; int ss_err [ MAX_LOOP_FILTER + 1 ] ; vpx_memset ( ss_err , 0xFF , sizeof ( ss_err ) ) ; vpx_yv12_copy_y ( cm -> frame_to_show , & cpi -> last_frame_uf ) ; best_err = try_filter_frame ( sd , cpi , filt_mid , partial_frame ) ; filt_best = filt_mid ; ss_err [ filt_mid ] = best_err ; while ( filter_step > 0 ) { const int filt_high = MIN ( filt_mid + filter_step , max_filter_level ) ; const int filt_low = MAX ( filt_mid - filter_step , min_filter_level ) ; int filt_err ; int bias = ( best_err >> ( 15 - ( filt_mid / 8 ) ) ) * filter_step ; if ( cpi -> twopass . section_intra_rating < 20 ) bias = bias * cpi -> twopass . section_intra_rating / 20 ; if ( cm -> tx_mode != ONLY_4X4 ) bias >>= 1 ; if ( filt_direction <= 0 && filt_low != filt_mid ) { if ( ss_err [ filt_low ] < 0 ) { filt_err = try_filter_frame ( sd , cpi , filt_low , partial_frame ) ; ss_err [ filt_low ] = filt_err ; } else { filt_err = ss_err [ filt_low ] ; } if ( ( filt_err - bias ) < best_err ) { if ( filt_err < best_err ) best_err = filt_err ; filt_best = filt_low ; } } if ( filt_direction >= 0 && filt_high != filt_mid ) { if ( ss_err [ filt_high ] < 0 ) { filt_err = try_filter_frame ( sd , cpi , filt_high , partial_frame ) ; ss_err [ filt_high ] = filt_err ; } else { filt_err = ss_err [ filt_high ] ; } if ( filt_err < ( best_err - bias ) ) { best_err = filt_err ; filt_best = filt_high ; } } if ( filt_best == filt_mid ) { filter_step /= 2 ; filt_direction = 0 ; } else { filt_direction = ( filt_best < filt_mid ) ? - 1 : 1 ; filt_mid = filt_best ; } } lf -> filter_level = filt_best ; } "," static int search_filter_level ( const partial_frame ) { const -> common ; const ) ; int filt_direction = 0 filt_direction = 0 ; int64_t best_err ; int filt_best / 4 ; int64_t ss_err [ MAX_LOOP_FILTER 1 ] ; memset ( ss_err , min_filter_level ) ; int64_t bias = ( filter_step ; if ( ( cpi -> oxcf . pass == 2 ) && < 20 ) ) bias = ( bias * cpi twopass . section_intra_rating ) 0 ) { ss_err [ filt_low ] = try_filter_frame ( partial_frame ) ; } if ( ( ss_err [ filt_low ] - bias ) { if ( ss_err [ filt_low ] < best_err ) best_err = ss_err [ filt_low ] ; filt_best = 0 ) { ss_err [ filt_high ] = try_filter_frame ( partial_frame ) ; } if ( ss_err [ filt_high ] < ( best_err { best_err = ss_err [ filt_high ] ; filt_best = ; } } return filt_best ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 21,CWE-787,"CWE-787 int mp_unpack_full ( lua_State * L , int limit , int offset ) { size_t len ; const char * s ; mp_cur c ; int cnt ; int decode_all = ( ! limit && ! offset ) ; s = luaL_checklstring ( L , 1 , & len ) ; if ( offset < 0 || limit < 0 ) return luaL_error ( L , ""Invalidrequesttounpackwithoffsetof%dandlimitof%d."" , offset , len ) ; else if ( offset > len ) return luaL_error ( L , ""Startoffset%dgreaterthaninputlength%d."" , offset , len ) ; if ( decode_all ) limit = INT_MAX ; mp_cur_init ( & c , ( const unsigned char * ) s + offset , len - offset ) ; for ( cnt = 0 ; c . left > 0 && cnt < limit ; cnt ++ ) { mp_decode_to_lua_type ( L , & c ) ; if ( c . err == MP_CUR_ERROR_EOF ) { return luaL_error ( L , ""Missingbytesininput."" ) ; } else if ( c . err == MP_CUR_ERROR_BADFMT ) { return luaL_error ( L , ""Baddataformatininput."" ) ; } } if ( ! decode_all ) { int offset = len - c . left ; lua_pushinteger ( L , c . left == 0 ? - 1 : offset ) ; lua_insert ( L , 2 ) ; cnt += 1 ; } return cnt ; } "," . left ; luaL_checkstack ( L , 1 , ""infunctionmp_unpack_full"" ) ; ",antirez@redis/5ccb6f7a791bf3490357b00a898885759d98bab0,CVE-2018-11218,https://github.com/antirez/redis/commit/5ccb6f7a791bf3490357b00a898885759d98bab0,2018-06-17T17:29Z 22,CWE-119,"CWE-119 static void encode_mv_component ( vp9_writer * w , int comp , const nmv_component * mvcomp , int usehp ) { int offset ; const int sign = comp < 0 ; const int mag = sign ? - comp : comp ; const int mv_class = vp9_get_mv_class ( mag - 1 , & offset ) ; const int d = offset >> 3 ; const int fr = ( offset >> 1 ) & 3 ; const int hp = offset & 1 ; assert ( comp != 0 ) ; vp9_write ( w , sign , mvcomp -> sign ) ; vp9_write_token ( w , vp9_mv_class_tree , mvcomp -> classes , & mv_class_encodings [ mv_class ] ) ; if ( mv_class == MV_CLASS_0 ) { vp9_write_token ( w , vp9_mv_class0_tree , mvcomp -> class0 , & mv_class0_encodings [ d ] ) ; } else { int i ; const int n = mv_class + CLASS0_BITS - 1 ; for ( i = 0 ; i < n ; ++ i ) vp9_write ( w , ( d >> i ) & 1 , mvcomp -> bits [ i ] ) ; } vp9_write_token ( w , vp9_mv_fp_tree , mv_class == MV_CLASS_0 ? mvcomp -> class0_fp [ d ] : mvcomp -> fp , & mv_fp_encodings [ fr ] ) ; if ( usehp ) vp9_write ( w , hp , mv_class == MV_CLASS_0 ? mvcomp -> class0_hp : mvcomp -> hp ) ; } "," void encode_mv_component ( vpx_writer * w , 0 ) ; vpx_write ( w , ++ i ) vpx_write ( w , ( usehp ) vpx_write ( w , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 23,CWE-476,"CWE-476 static unsigned int seedsize ( struct crypto_alg * alg ) { struct rng_alg * ralg = container_of ( alg , struct rng_alg , base ) ; return alg -> cra_rng . rng_make_random ? alg -> cra_rng . seedsize : ralg -> seedsize ; } "," ) ; return ralg -> seedsize ",torvalds@linux/94f1bb15bed84ad6c893916b7e7b9db6f1d7eec6,CVE-2017-15116,https://github.com/torvalds/linux/commit/94f1bb15bed84ad6c893916b7e7b9db6f1d7eec6,2017-11-30T18:29Z 24,CWE-200,"CWE-200 static int pptp_connect ( struct socket * sock , struct sockaddr * uservaddr , int sockaddr_len , int flags ) { struct sock * sk = sock -> sk ; struct sockaddr_pppox * sp = ( struct sockaddr_pppox * ) uservaddr ; struct pppox_sock * po = pppox_sk ( sk ) ; struct pptp_opt * opt = & po -> proto . pptp ; struct rtable * rt ; struct flowi4 fl4 ; int error = 0 ; if ( sp -> sa_protocol != PX_PROTO_PPTP ) return - EINVAL ; if ( lookup_chan_dst ( sp -> sa_addr . pptp . call_id , sp -> sa_addr . pptp . sin_addr . s_addr ) ) return - EALREADY ; lock_sock ( sk ) ; if ( sk -> sk_state & PPPOX_CONNECTED ) { error = - EBUSY ; goto end ; } if ( sk -> sk_state & PPPOX_DEAD ) { error = - EALREADY ; goto end ; } if ( ! opt -> src_addr . sin_addr . s_addr || ! sp -> sa_addr . pptp . sin_addr . s_addr ) { error = - EINVAL ; goto end ; } po -> chan . private = sk ; po -> chan . ops = & pptp_chan_ops ; rt = ip_route_output_ports ( sock_net ( sk ) , & fl4 , sk , opt -> dst_addr . sin_addr . s_addr , opt -> src_addr . sin_addr . s_addr , 0 , 0 , IPPROTO_GRE , RT_CONN_FLAGS ( sk ) , 0 ) ; if ( IS_ERR ( rt ) ) { error = - EHOSTUNREACH ; goto end ; } sk_setup_caps ( sk , & rt -> dst ) ; po -> chan . mtu = dst_mtu ( & rt -> dst ) ; if ( ! po -> chan . mtu ) po -> chan . mtu = PPP_MRU ; ip_rt_put ( rt ) ; po -> chan . mtu -= PPTP_HEADER_OVERHEAD ; po -> chan . hdrlen = 2 + sizeof ( struct pptp_gre_header ) ; error = ppp_register_channel ( & po -> chan ) ; if ( error ) { pr_err ( ""PPTP:failedtoregisterPPPchannel(%d)\\n"" , error ) ; goto end ; } opt -> dst_addr = sp -> sa_addr . pptp ; sk -> sk_state = PPPOX_CONNECTED ; end : release_sock ( sk ) ; return error ; } "," ; if ( sockaddr_len < sizeof ( struct sockaddr_pppox ) ) return - EINVAL ; if ( ",torvalds@linux/09ccfd238e5a0e670d8178cf50180ea81ae09ae1,CVE-2015-8569,https://github.com/torvalds/linux/commit/09ccfd238e5a0e670d8178cf50180ea81ae09ae1,2015-12-28T11:59Z 25,CWE-20,"CWE-20 error_t coapClientSetRxBlockSize ( CoapClientRequest * request , uint_t blockSize ) { if ( request == NULL ) return ERROR_INVALID_PARAMETER ; osAcquireMutex ( & request -> context -> mutex ) ; if ( blockSize == 16 ) request -> rxBlockSzx = COAP_BLOCK_SIZE_16 ; else if ( blockSize == 32 ) request -> rxBlockSzx = COAP_BLOCK_SIZE_32 ; else if ( blockSize == 64 ) request -> rxBlockSzx = COAP_BLOCK_SIZE_64 ; else if ( blockSize == 128 ) request -> rxBlockSzx = COAP_BLOCK_SIZE_128 ; else if ( blockSize == 256 ) request -> rxBlockSzx = COAP_BLOCK_SIZE_256 ; else if ( blockSize == 512 ) request -> rxBlockSzx = COAP_BLOCK_SIZE_512 ; else request -> rxBlockSzx = COAP_BLOCK_SIZE_1024 ; if ( request -> rxBlockSzx > coapClientGetMaxBlockSize ( ) ) request -> rxBlockSzx = coapClientGetMaxBlockSize ( ) ; osReleaseMutex ( & request -> context -> mutex ) ; return NO_ERROR ; } "," == 16 ) { = COAP_BLOCK_SIZE_16 ; } == 32 ) { = COAP_BLOCK_SIZE_32 ; } == 64 ) { = COAP_BLOCK_SIZE_64 ; } == 128 ) { = COAP_BLOCK_SIZE_128 ; } == 256 ) { = COAP_BLOCK_SIZE_256 ; } == 512 ) { = COAP_BLOCK_SIZE_512 ; } else { request -> rxBlockSzx = COAP_BLOCK_SIZE_1024 ; } ( ) ) { ( ) ; } ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 26,CWE-476,"CWE-476 int main ( int argc , char * * argv ) { int fmtid ; int id ; char * infile ; jas_stream_t * instream ; jas_image_t * image ; int width ; int height ; int depth ; int numcmpts ; int verbose ; char * fmtname ; if ( jas_init ( ) ) { abort ( ) ; } cmdname = argv [ 0 ] ; infile = 0 ; verbose = 0 ; while ( ( id = jas_getopt ( argc , argv , opts ) ) >= 0 ) { switch ( id ) { case OPT_VERBOSE : verbose = 1 ; break ; case OPT_VERSION : printf ( ""%s\\n"" , JAS_VERSION ) ; exit ( EXIT_SUCCESS ) ; break ; case OPT_INFILE : infile = jas_optarg ; break ; case OPT_HELP : default : usage ( ) ; break ; } } if ( infile ) { if ( ! ( instream = jas_stream_fopen ( infile , ""rb"" ) ) ) { fprintf ( stderr , ""cannotopeninputimagefile%s\\n"" , infile ) ; exit ( EXIT_FAILURE ) ; } } else { if ( ! ( instream = jas_stream_fdopen ( 0 , ""rb"" ) ) ) { fprintf ( stderr , ""cannotopenstandardinput\\n"" ) ; exit ( EXIT_FAILURE ) ; } } if ( ( fmtid = jas_image_getfmt ( instream ) ) < 0 ) { fprintf ( stderr , ""unknownimageformat\\n"" ) ; } if ( ! ( image = jas_image_decode ( instream , fmtid , 0 ) ) ) { fprintf ( stderr , ""cannotloadimage\\n"" ) ; return EXIT_FAILURE ; } jas_stream_close ( instream ) ; numcmpts = jas_image_numcmpts ( image ) ; width = jas_image_cmptwidth ( image , 0 ) ; height = jas_image_cmptheight ( image , 0 ) ; depth = jas_image_cmptprec ( image , 0 ) ; if ( ! ( fmtname = jas_image_fmttostr ( fmtid ) ) ) { abort ( ) ; } printf ( ""%s%d%d%d%d%ld\\n"" , fmtname , numcmpts , width , height , depth , ( long ) jas_image_rawsize ( image ) ) ; jas_image_destroy ( image ) ; jas_image_clearfmts ( ) ; return EXIT_SUCCESS ; } "," char * fmtname ; int debug = 0 ; debug = 0 ; break ; case OPT_DEBUG : debug = atoi ( jas_optarg ) ; break ; case ; } } jas_setdbglevel ( debug ) ; ) ) { jas_stream_close ( instream ) ; ",mdadams@jasper/8f62b4761711d036fd8964df256b938c809b7fca,CVE-2016-8690,https://github.com/mdadams/jasper/commit/8f62b4761711d036fd8964df256b938c809b7fca,2017-02-15T19:59Z 27,CWE-000,"CWE-000 asmlinkage void bad_mode ( struct pt_regs * regs , int reason , unsigned int esr ) { console_verbose ( ) ; pr_crit ( ""Badmodein%shandlerdetected,code0x%08x\\n"" , handler [ reason ] , esr ) ; die ( ""Oops-badmode"" , regs , 0 ) ; local_irq_disable ( ) ; panic ( ""badmode"" ) ; } "," esr ) { siginfo_t info ; void __user * pc = ( void __user * ) instruction_pointer ( regs ) ; esr ) ; __show_regs ( regs ) ; info . si_signo = SIGILL ; info . si_errno = 0 ; info . si_code = ILL_ILLOPC ; info . si_addr = pc ; arm64_notify_die ( ""Oops-badmode"" , , regs , & info , 0 ) ; } ",torvalds@linux/9955ac47f4ba1c95ecb6092aeaefb40a22e99268,CVE-2013-4220,https://github.com/torvalds/linux/commit/9955ac47f4ba1c95ecb6092aeaefb40a22e99268,2013-08-25T03:27Z 28,CWE-125,"CWE-125 static void l2tp_ppp_discon_cc_print ( netdissect_options * ndo , const u_char * dat , u_int length ) { const uint16_t * ptr = ( const uint16_t * ) dat ; ND_PRINT ( ( ndo , ""%04x,"" , EXTRACT_16BITS ( ptr ) ) ) ; ptr ++ ; ND_PRINT ( ( ndo , ""%04x"" , EXTRACT_16BITS ( ptr ) ) ) ; ptr ++ ; ND_PRINT ( ( ndo , ""%s"" , tok2str ( l2tp_cc_direction2str , ""Direction-#%u"" , * ( ( const u_char * ) ptr ++ ) ) ) ) ; if ( length > 5 ) { ND_PRINT ( ( ndo , """" ) ) ; print_string ( ndo , ( const u_char * ) ptr , length - 5 ) ; } } "," ) dat ; if ( length < 5 ) { ND_PRINT ( ( ndo , ""AVPtooshort"" ) ) ; return ; } , EXTRACT_16BITS ( dat ) ) ) ) ) ; dat += 2 ; length -= 2 ; ND_PRINT ( , EXTRACT_16BITS ( dat ) ) ) ) ) ; dat += 2 ; length -= 2 ; ND_PRINT ( , ""Direction-#%u"" , EXTRACT_8BITS ( ptr ) ) ) ) ) ; ptr ++ ; length -- ; if ( length != 0 ) { ND_PRINT ptr , length ) ; } ",the-tcpdump-group@tcpdump/cc4a7391c616be7a64ed65742ef9ed3f106eb165,CVE-2017-13006,https://github.com/the-tcpdump-group/tcpdump/commit/cc4a7391c616be7a64ed65742ef9ed3f106eb165,2017-09-14T06:29Z 29,CWE-125,"CWE-125 static int uas_switch_interface ( struct usb_device * udev , struct usb_interface * intf ) { int alt ; alt = uas_find_uas_alt_setting ( intf ) ; if ( alt < 0 ) return alt ; return usb_set_interface ( udev , intf -> altsetting [ 0 ] . desc . bInterfaceNumber , alt ) ; } "," intf ) { struct usb_host_interface * alt ; alt ; if ( ! alt ) return - ENODEV ; return usb_set_interface ( udev , alt -> desc . bInterfaceNumber bInterfaceNumber , alt -> desc . bAlternateSetting ",torvalds@linux/786de92b3cb26012d3d0f00ee37adf14527f35c4,CVE-2017-16530,https://github.com/torvalds/linux/commit/786de92b3cb26012d3d0f00ee37adf14527f35c4,2017-11-04T01:29Z 30,CWE-17,"CWE-17 static void udf_pc_to_char ( struct super_block * sb , unsigned char * from , int fromlen , unsigned char * to ) { struct pathComponent * pc ; int elen = 0 ; unsigned char * p = to ; while ( elen < fromlen ) { pc = ( struct pathComponent * ) ( from + elen ) ; switch ( pc -> componentType ) { case 1 : if ( pc -> lengthComponentIdent > 0 ) break ; case 2 : p = to ; * p ++ = '/' ; break ; case 3 : memcpy ( p , ""../"" , 3 ) ; p += 3 ; break ; case 4 : memcpy ( p , ""./"" , 2 ) ; p += 2 ; break ; case 5 : p += udf_get_filename ( sb , pc -> componentIdent , p , pc -> lengthComponentIdent ) ; * p ++ = '/' ; break ; } elen += sizeof ( struct pathComponent ) + pc -> lengthComponentIdent ; } if ( p > to + 1 ) p [ - 1 ] = '\\0' ; else p [ 0 ] = '\\0' ; } "," static int udf_pc_to_char ( struct char * to , int tolen = 0 ; int comp_len ; p = to ; tolen -- case 2 : if ( tolen == 0 ) return - ENAMETOOLONG ; = '/' ; tolen -- ; break ; case 3 : if ( tolen < 3 ) return - ENAMETOOLONG ; memcpy ( p += 3 ; tolen -= 3 ; case 4 : if ( tolen < 2 ) return - ENAMETOOLONG ; += 2 ; tolen -= 2 ; case 5 : comp_len = udf_get_filename ( sb , pc -> componentIdent , pc -> lengthComponentIdent , p , tolen ) ; p += comp_len ; tolen -= comp_len ; if ( tolen == 0 ) return - ENAMETOOLONG ; * p ++ = '/' ; tolen -- = '\\0' ; return 0 ; ",torvalds@linux/0e5cc9a40ada6046e6bc3bdfcd0c0d7e4b706b14,CVE-2014-9731,https://github.com/torvalds/linux/commit/0e5cc9a40ada6046e6bc3bdfcd0c0d7e4b706b14,2015-08-31T10:59Z 31,CWE-119,"CWE-119 void loadServerConfigFromString ( char * config ) { char * err = NULL ; int linenum = 0 , totlines , i ; int slaveof_linenum = 0 ; sds * lines ; lines = sdssplitlen ( config , strlen ( config ) , ""\\n"" , 1 , & totlines ) ; for ( i = 0 ; i < totlines ; i ++ ) { sds * argv ; int argc ; linenum = i + 1 ; lines [ i ] = sdstrim ( lines [ i ] , ""\\t\\r\\n"" ) ; if ( lines [ i ] [ 0 ] == '#' || lines [ i ] [ 0 ] == '\\0' ) continue ; argv = sdssplitargs ( lines [ i ] , & argc ) ; if ( argv == NULL ) { err = ""Unbalancedquotesinconfigurationline"" ; goto loaderr ; } if ( argc == 0 ) { sdsfreesplitres ( argv , argc ) ; continue ; } sdstolower ( argv [ 0 ] ) ; if ( ! strcasecmp ( argv [ 0 ] , ""timeout"" ) && argc == 2 ) { server . maxidletime = atoi ( argv [ 1 ] ) ; if ( server . maxidletime < 0 ) { err = ""Invalidtimeoutvalue"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""tcp-keepalive"" ) && argc == 2 ) { server . tcpkeepalive = atoi ( argv [ 1 ] ) ; if ( server . tcpkeepalive < 0 ) { err = ""Invalidtcp-keepalivevalue"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""protected-mode"" ) && argc == 2 ) { if ( ( server . protected_mode = yesnotoi ( argv [ 1 ] ) ) == - 1 ) { err = ""argumentmustbe\'yes\'or\'no\'"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""port"" ) && argc == 2 ) { server . port = atoi ( argv [ 1 ] ) ; if ( server . port < 0 || server . port > 65535 ) { err = ""Invalidport"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""tcp-backlog"" ) && argc == 2 ) { server . tcp_backlog = atoi ( argv [ 1 ] ) ; if ( server . tcp_backlog < 0 ) { err = ""Invalidbacklogvalue"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""bind"" ) && argc >= 2 ) { int j , addresses = argc - 1 ; if ( addresses > CONFIG_BINDADDR_MAX ) { err = ""Toomanybindaddressesspecified"" ; goto loaderr ; } for ( j = 0 ; j < addresses ; j ++ ) server . bindaddr [ j ] = zstrdup ( argv [ j + 1 ] ) ; server . bindaddr_count = addresses ; } else if ( ! strcasecmp ( argv [ 0 ] , ""unixsocket"" ) && argc == 2 ) { server . unixsocket = zstrdup ( argv [ 1 ] ) ; } else if ( ! strcasecmp ( argv [ 0 ] , ""unixsocketperm"" ) && argc == 2 ) { errno = 0 ; server . unixsocketperm = ( mode_t ) strtol ( argv [ 1 ] , NULL , 8 ) ; if ( errno || server . unixsocketperm > 0777 ) { err = ""Invalidsocketfilepermissions"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""save"" ) ) { if ( argc == 3 ) { int seconds = atoi ( argv [ 1 ] ) ; int changes = atoi ( argv [ 2 ] ) ; if ( seconds < 1 || changes < 0 ) { err = ""Invalidsaveparameters"" ; goto loaderr ; } appendServerSaveParams ( seconds , changes ) ; } else if ( argc == 2 && ! strcasecmp ( argv [ 1 ] , """" ) ) { resetServerSaveParams ( ) ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""dir"" ) && argc == 2 ) { if ( chdir ( argv [ 1 ] ) == - 1 ) { serverLog ( LL_WARNING , ""Can\'tchdirto\'%s\':%s"" , argv [ 1 ] , strerror ( errno ) ) ; exit ( 1 ) ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""loglevel"" ) && argc == 2 ) { server . verbosity = configEnumGetValue ( loglevel_enum , argv [ 1 ] ) ; if ( server . verbosity == INT_MIN ) { err = ""Invalidloglevel."" ""Mustbeoneofdebug,verbose,notice,warning"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""logfile"" ) && argc == 2 ) { FILE * logfp ; zfree ( server . logfile ) ; server . logfile = zstrdup ( argv [ 1 ] ) ; if ( server . logfile [ 0 ] != '\\0' ) { logfp = fopen ( server . logfile , ""a"" ) ; if ( logfp == NULL ) { err = sdscatprintf ( sdsempty ( ) , ""Can\'topenthelogfile:%s"" , strerror ( errno ) ) ; goto loaderr ; } fclose ( logfp ) ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""syslog-enabled"" ) && argc == 2 ) { if ( ( server . syslog_enabled = yesnotoi ( argv [ 1 ] ) ) == - 1 ) { err = ""argumentmustbe\'yes\'or\'no\'"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""syslog-ident"" ) && argc == 2 ) { if ( server . syslog_ident ) zfree ( server . syslog_ident ) ; server . syslog_ident = zstrdup ( argv [ 1 ] ) ; } else if ( ! strcasecmp ( argv [ 0 ] , ""syslog-facility"" ) && argc == 2 ) { server . syslog_facility = configEnumGetValue ( syslog_facility_enum , argv [ 1 ] ) ; if ( server . syslog_facility == INT_MIN ) { err = ""Invalidlogfacility.MustbeoneofUSERorbetweenLOCAL0-LOCAL7"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""databases"" ) && argc == 2 ) { server . dbnum = atoi ( argv [ 1 ] ) ; if ( server . dbnum < 1 ) { err = ""Invalidnumberofdatabases"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""include"" ) && argc == 2 ) { loadServerConfig ( argv [ 1 ] , NULL ) ; } else if ( ! strcasecmp ( argv [ 0 ] , ""maxclients"" ) && argc == 2 ) { server . maxclients = atoi ( argv [ 1 ] ) ; if ( server . maxclients < 1 ) { err = ""Invalidmaxclientslimit"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""maxmemory"" ) && argc == 2 ) { server . maxmemory = memtoll ( argv [ 1 ] , NULL ) ; } else if ( ! strcasecmp ( argv [ 0 ] , ""maxmemory-policy"" ) && argc == 2 ) { server . maxmemory_policy = configEnumGetValue ( maxmemory_policy_enum , argv [ 1 ] ) ; if ( server . maxmemory_policy == INT_MIN ) { err = ""Invalidmaxmemorypolicy"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""maxmemory-samples"" ) && argc == 2 ) { server . maxmemory_samples = atoi ( argv [ 1 ] ) ; if ( server . maxmemory_samples <= 0 ) { err = ""maxmemory-samplesmustbe1orgreater"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""lfu-log-factor"" ) && argc == 2 ) { server . lfu_log_factor = atoi ( argv [ 1 ] ) ; if ( server . maxmemory_samples < 0 ) { err = ""lfu-log-factormustbe0orgreater"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""lfu-decay-time"" ) && argc == 2 ) { server . lfu_decay_time = atoi ( argv [ 1 ] ) ; if ( server . maxmemory_samples < 1 ) { err = ""lfu-decay-timemustbe0orgreater"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""slaveof"" ) && argc == 3 ) { slaveof_linenum = linenum ; server . masterhost = sdsnew ( argv [ 1 ] ) ; server . masterport = atoi ( argv [ 2 ] ) ; server . repl_state = REPL_STATE_CONNECT ; } else if ( ! strcasecmp ( argv [ 0 ] , ""repl-ping-slave-period"" ) && argc == 2 ) { server . repl_ping_slave_period = atoi ( argv [ 1 ] ) ; if ( server . repl_ping_slave_period <= 0 ) { err = ""repl-ping-slave-periodmustbe1orgreater"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""repl-timeout"" ) && argc == 2 ) { server . repl_timeout = atoi ( argv [ 1 ] ) ; if ( server . repl_timeout <= 0 ) { err = ""repl-timeoutmustbe1orgreater"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""repl-disable-tcp-nodelay"" ) && argc == 2 ) { if ( ( server . repl_disable_tcp_nodelay = yesnotoi ( argv [ 1 ] ) ) == - 1 ) { err = ""argumentmustbe\'yes\'or\'no\'"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""repl-diskless-sync"" ) && argc == 2 ) { if ( ( server . repl_diskless_sync = yesnotoi ( argv [ 1 ] ) ) == - 1 ) { err = ""argumentmustbe\'yes\'or\'no\'"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""repl-diskless-sync-delay"" ) && argc == 2 ) { server . repl_diskless_sync_delay = atoi ( argv [ 1 ] ) ; if ( server . repl_diskless_sync_delay < 0 ) { err = ""repl-diskless-sync-delaycan\'tbenegative"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""repl-backlog-size"" ) && argc == 2 ) { long long size = memtoll ( argv [ 1 ] , NULL ) ; if ( size <= 0 ) { err = ""repl-backlog-sizemustbe1orgreater."" ; goto loaderr ; } resizeReplicationBacklog ( size ) ; } else if ( ! strcasecmp ( argv [ 0 ] , ""repl-backlog-ttl"" ) && argc == 2 ) { server . repl_backlog_time_limit = atoi ( argv [ 1 ] ) ; if ( server . repl_backlog_time_limit < 0 ) { err = ""repl-backlog-ttlcan\'tbenegative"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""masterauth"" ) && argc == 2 ) { zfree ( server . masterauth ) ; server . masterauth = zstrdup ( argv [ 1 ] ) ; } else if ( ! strcasecmp ( argv [ 0 ] , ""slave-serve-stale-data"" ) && argc == 2 ) { if ( ( server . repl_serve_stale_data = yesnotoi ( argv [ 1 ] ) ) == - 1 ) { err = ""argumentmustbe\'yes\'or\'no\'"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""slave-read-only"" ) && argc == 2 ) { if ( ( server . repl_slave_ro = yesnotoi ( argv [ 1 ] ) ) == - 1 ) { err = ""argumentmustbe\'yes\'or\'no\'"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""rdbcompression"" ) && argc == 2 ) { if ( ( server . rdb_compression = yesnotoi ( argv [ 1 ] ) ) == - 1 ) { err = ""argumentmustbe\'yes\'or\'no\'"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""rdbchecksum"" ) && argc == 2 ) { if ( ( server . rdb_checksum = yesnotoi ( argv [ 1 ] ) ) == - 1 ) { err = ""argumentmustbe\'yes\'or\'no\'"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""activerehashing"" ) && argc == 2 ) { if ( ( server . activerehashing = yesnotoi ( argv [ 1 ] ) ) == - 1 ) { err = ""argumentmustbe\'yes\'or\'no\'"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""lazyfree-lazy-eviction"" ) && argc == 2 ) { if ( ( server . lazyfree_lazy_eviction = yesnotoi ( argv [ 1 ] ) ) == - 1 ) { err = ""argumentmustbe\'yes\'or\'no\'"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""lazyfree-lazy-expire"" ) && argc == 2 ) { if ( ( server . lazyfree_lazy_expire = yesnotoi ( argv [ 1 ] ) ) == - 1 ) { err = ""argumentmustbe\'yes\'or\'no\'"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""lazyfree-lazy-server-del"" ) && argc == 2 ) { if ( ( server . lazyfree_lazy_server_del = yesnotoi ( argv [ 1 ] ) ) == - 1 ) { err = ""argumentmustbe\'yes\'or\'no\'"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""slave-lazy-flush"" ) && argc == 2 ) { if ( ( server . repl_slave_lazy_flush = yesnotoi ( argv [ 1 ] ) ) == - 1 ) { err = ""argumentmustbe\'yes\'or\'no\'"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""daemonize"" ) && argc == 2 ) { if ( ( server . daemonize = yesnotoi ( argv [ 1 ] ) ) == - 1 ) { err = ""argumentmustbe\'yes\'or\'no\'"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""hz"" ) && argc == 2 ) { server . hz = atoi ( argv [ 1 ] ) ; if ( server . hz < CONFIG_MIN_HZ ) server . hz = CONFIG_MIN_HZ ; if ( server . hz > CONFIG_MAX_HZ ) server . hz = CONFIG_MAX_HZ ; } else if ( ! strcasecmp ( argv [ 0 ] , ""appendonly"" ) && argc == 2 ) { int yes ; if ( ( yes = yesnotoi ( argv [ 1 ] ) ) == - 1 ) { err = ""argumentmustbe\'yes\'or\'no\'"" ; goto loaderr ; } server . aof_state = yes ? AOF_ON : AOF_OFF ; } else if ( ! strcasecmp ( argv [ 0 ] , ""appendfilename"" ) && argc == 2 ) { if ( ! pathIsBaseName ( argv [ 1 ] ) ) { err = ""appendfilenamecan\'tbeapath,justafilename"" ; goto loaderr ; } zfree ( server . aof_filename ) ; server . aof_filename = zstrdup ( argv [ 1 ] ) ; } else if ( ! strcasecmp ( argv [ 0 ] , ""no-appendfsync-on-rewrite"" ) && argc == 2 ) { if ( ( server . aof_no_fsync_on_rewrite = yesnotoi ( argv [ 1 ] ) ) == - 1 ) { err = ""argumentmustbe\'yes\'or\'no\'"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""appendfsync"" ) && argc == 2 ) { server . aof_fsync = configEnumGetValue ( aof_fsync_enum , argv [ 1 ] ) ; if ( server . aof_fsync == INT_MIN ) { err = ""argumentmustbe\'no\',\'always\'or\'everysec\'"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""auto-aof-rewrite-percentage"" ) && argc == 2 ) { server . aof_rewrite_perc = atoi ( argv [ 1 ] ) ; if ( server . aof_rewrite_perc < 0 ) { err = ""InvalidnegativepercentageforAOFautorewrite"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""auto-aof-rewrite-min-size"" ) && argc == 2 ) { server . aof_rewrite_min_size = memtoll ( argv [ 1 ] , NULL ) ; } else if ( ! strcasecmp ( argv [ 0 ] , ""aof-rewrite-incremental-fsync"" ) && argc == 2 ) { if ( ( server . aof_rewrite_incremental_fsync = yesnotoi ( argv [ 1 ] ) ) == - 1 ) { err = ""argumentmustbe\'yes\'or\'no\'"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""aof-load-truncated"" ) && argc == 2 ) { if ( ( server . aof_load_truncated = yesnotoi ( argv [ 1 ] ) ) == - 1 ) { err = ""argumentmustbe\'yes\'or\'no\'"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""aof-use-rdb-preamble"" ) && argc == 2 ) { if ( ( server . aof_use_rdb_preamble = yesnotoi ( argv [ 1 ] ) ) == - 1 ) { err = ""argumentmustbe\'yes\'or\'no\'"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""requirepass"" ) && argc == 2 ) { if ( strlen ( argv [ 1 ] ) > CONFIG_AUTHPASS_MAX_LEN ) { err = ""PasswordislongerthanCONFIG_AUTHPASS_MAX_LEN"" ; goto loaderr ; } server . requirepass = zstrdup ( argv [ 1 ] ) ; } else if ( ! strcasecmp ( argv [ 0 ] , ""pidfile"" ) && argc == 2 ) { zfree ( server . pidfile ) ; server . pidfile = zstrdup ( argv [ 1 ] ) ; } else if ( ! strcasecmp ( argv [ 0 ] , ""dbfilename"" ) && argc == 2 ) { if ( ! pathIsBaseName ( argv [ 1 ] ) ) { err = ""dbfilenamecan\'tbeapath,justafilename"" ; goto loaderr ; } zfree ( server . rdb_filename ) ; server . rdb_filename = zstrdup ( argv [ 1 ] ) ; } else if ( ! strcasecmp ( argv [ 0 ] , ""hash-max-ziplist-entries"" ) && argc == 2 ) { server . hash_max_ziplist_entries = memtoll ( argv [ 1 ] , NULL ) ; } else if ( ! strcasecmp ( argv [ 0 ] , ""hash-max-ziplist-value"" ) && argc == 2 ) { server . hash_max_ziplist_value = memtoll ( argv [ 1 ] , NULL ) ; } else if ( ! strcasecmp ( argv [ 0 ] , ""list-max-ziplist-entries"" ) && argc == 2 ) { } else if ( ! strcasecmp ( argv [ 0 ] , ""list-max-ziplist-value"" ) && argc == 2 ) { } else if ( ! strcasecmp ( argv [ 0 ] , ""list-max-ziplist-size"" ) && argc == 2 ) { server . list_max_ziplist_size = atoi ( argv [ 1 ] ) ; } else if ( ! strcasecmp ( argv [ 0 ] , ""list-compress-depth"" ) && argc == 2 ) { server . list_compress_depth = atoi ( argv [ 1 ] ) ; } else if ( ! strcasecmp ( argv [ 0 ] , ""set-max-intset-entries"" ) && argc == 2 ) { server . set_max_intset_entries = memtoll ( argv [ 1 ] , NULL ) ; } else if ( ! strcasecmp ( argv [ 0 ] , ""zset-max-ziplist-entries"" ) && argc == 2 ) { server . zset_max_ziplist_entries = memtoll ( argv [ 1 ] , NULL ) ; } else if ( ! strcasecmp ( argv [ 0 ] , ""zset-max-ziplist-value"" ) && argc == 2 ) { server . zset_max_ziplist_value = memtoll ( argv [ 1 ] , NULL ) ; } else if ( ! strcasecmp ( argv [ 0 ] , ""hll-sparse-max-bytes"" ) && argc == 2 ) { server . hll_sparse_max_bytes = memtoll ( argv [ 1 ] , NULL ) ; } else if ( ! strcasecmp ( argv [ 0 ] , ""rename-command"" ) && argc == 3 ) { struct redisCommand * cmd = lookupCommand ( argv [ 1 ] ) ; int retval ; if ( ! cmd ) { err = ""Nosuchcommandinrename-command"" ; goto loaderr ; } retval = dictDelete ( server . commands , argv [ 1 ] ) ; serverAssert ( retval == DICT_OK ) ; if ( sdslen ( argv [ 2 ] ) != 0 ) { sds copy = sdsdup ( argv [ 2 ] ) ; retval = dictAdd ( server . commands , copy , cmd ) ; if ( retval != DICT_OK ) { sdsfree ( copy ) ; err = ""Targetcommandnamealreadyexists"" ; goto loaderr ; } } } else if ( ! strcasecmp ( argv [ 0 ] , ""cluster-enabled"" ) && argc == 2 ) { if ( ( server . cluster_enabled = yesnotoi ( argv [ 1 ] ) ) == - 1 ) { err = ""argumentmustbe\'yes\'or\'no\'"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""cluster-config-file"" ) && argc == 2 ) { zfree ( server . cluster_configfile ) ; server . cluster_configfile = zstrdup ( argv [ 1 ] ) ; } else if ( ! strcasecmp ( argv [ 0 ] , ""cluster-announce-ip"" ) && argc == 2 ) { zfree ( server . cluster_announce_ip ) ; server . cluster_announce_ip = zstrdup ( argv [ 1 ] ) ; } else if ( ! strcasecmp ( argv [ 0 ] , ""cluster-announce-port"" ) && argc == 2 ) { server . cluster_announce_port = atoi ( argv [ 1 ] ) ; if ( server . cluster_announce_port < 0 || server . cluster_announce_port > 65535 ) { err = ""Invalidport"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""cluster-announce-bus-port"" ) && argc == 2 ) { server . cluster_announce_bus_port = atoi ( argv [ 1 ] ) ; if ( server . cluster_announce_bus_port < 0 || server . cluster_announce_bus_port > 65535 ) { err = ""Invalidport"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""cluster-require-full-coverage"" ) && argc == 2 ) { if ( ( server . cluster_require_full_coverage = yesnotoi ( argv [ 1 ] ) ) == - 1 ) { err = ""argumentmustbe\'yes\'or\'no\'"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""cluster-node-timeout"" ) && argc == 2 ) { server . cluster_node_timeout = strtoll ( argv [ 1 ] , NULL , 10 ) ; if ( server . cluster_node_timeout <= 0 ) { err = ""clusternodetimeoutmustbe1orgreater"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""cluster-migration-barrier"" ) && argc == 2 ) { server . cluster_migration_barrier = atoi ( argv [ 1 ] ) ; if ( server . cluster_migration_barrier < 0 ) { err = ""clustermigrationbarriermustzeroorpositive"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""cluster-slave-validity-factor"" ) && argc == 2 ) { server . cluster_slave_validity_factor = atoi ( argv [ 1 ] ) ; if ( server . cluster_slave_validity_factor < 0 ) { err = ""clusterslavevalidityfactormustbezeroorpositive"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""lua-time-limit"" ) && argc == 2 ) { server . lua_time_limit = strtoll ( argv [ 1 ] , NULL , 10 ) ; } else if ( ! strcasecmp ( argv [ 0 ] , ""slowlog-log-slower-than"" ) && argc == 2 ) { server . slowlog_log_slower_than = strtoll ( argv [ 1 ] , NULL , 10 ) ; } else if ( ! strcasecmp ( argv [ 0 ] , ""latency-monitor-threshold"" ) && argc == 2 ) { server . latency_monitor_threshold = strtoll ( argv [ 1 ] , NULL , 10 ) ; if ( server . latency_monitor_threshold < 0 ) { err = ""Thelatencythresholdcan\'tbenegative"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""slowlog-max-len"" ) && argc == 2 ) { server . slowlog_max_len = strtoll ( argv [ 1 ] , NULL , 10 ) ; } else if ( ! strcasecmp ( argv [ 0 ] , ""client-output-buffer-limit"" ) && argc == 5 ) { int class = getClientTypeByName ( argv [ 1 ] ) ; unsigned long long hard , soft ; int soft_seconds ; if ( class == - 1 ) { err = ""Unrecognizedclientlimitclass"" ; goto loaderr ; } hard = memtoll ( argv [ 2 ] , NULL ) ; soft = memtoll ( argv [ 3 ] , NULL ) ; soft_seconds = atoi ( argv [ 4 ] ) ; if ( soft_seconds < 0 ) { err = ""Negativenumberofsecondsinsoftlimitisinvalid"" ; goto loaderr ; } server . client_obuf_limits [ class ] . hard_limit_bytes = hard ; server . client_obuf_limits [ class ] . soft_limit_bytes = soft ; server . client_obuf_limits [ class ] . soft_limit_seconds = soft_seconds ; } else if ( ! strcasecmp ( argv [ 0 ] , ""stop-writes-on-bgsave-error"" ) && argc == 2 ) { if ( ( server . stop_writes_on_bgsave_err = yesnotoi ( argv [ 1 ] ) ) == - 1 ) { err = ""argumentmustbe\'yes\'or\'no\'"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""slave-priority"" ) && argc == 2 ) { server . slave_priority = atoi ( argv [ 1 ] ) ; } else if ( ! strcasecmp ( argv [ 0 ] , ""slave-announce-ip"" ) && argc == 2 ) { zfree ( server . slave_announce_ip ) ; server . slave_announce_ip = zstrdup ( argv [ 1 ] ) ; } else if ( ! strcasecmp ( argv [ 0 ] , ""slave-announce-port"" ) && argc == 2 ) { server . slave_announce_port = atoi ( argv [ 1 ] ) ; if ( server . slave_announce_port < 0 || server . slave_announce_port > 65535 ) { err = ""Invalidport"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""min-slaves-to-write"" ) && argc == 2 ) { server . repl_min_slaves_to_write = atoi ( argv [ 1 ] ) ; if ( server . repl_min_slaves_to_write < 0 ) { err = ""Invalidvalueformin-slaves-to-write."" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""min-slaves-max-lag"" ) && argc == 2 ) { server . repl_min_slaves_max_lag = atoi ( argv [ 1 ] ) ; if ( server . repl_min_slaves_max_lag < 0 ) { err = ""Invalidvalueformin-slaves-max-lag."" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""notify-keyspace-events"" ) && argc == 2 ) { int flags = keyspaceEventsStringToFlags ( argv [ 1 ] ) ; if ( flags == - 1 ) { err = ""Invalideventclasscharacter.Use\'g$lshzxeA\'."" ; goto loaderr ; } server . notify_keyspace_events = flags ; } else if ( ! strcasecmp ( argv [ 0 ] , ""supervised"" ) && argc == 2 ) { server . supervised_mode = configEnumGetValue ( supervised_mode_enum , argv [ 1 ] ) ; if ( server . supervised_mode == INT_MIN ) { err = ""Invalidoptionfor\'supervised\'."" ""Allowedvalues:\'upstart\',\'systemd\',\'auto\',or\'no\'"" ; goto loaderr ; } } else if ( ! strcasecmp ( argv [ 0 ] , ""loadmodule"" ) && argc >= 2 ) { queueLoadModule ( argv [ 1 ] , & argv [ 2 ] , argc - 2 ) ; } else if ( ! strcasecmp ( argv [ 0 ] , ""sentinel"" ) ) { if ( argc != 1 ) { if ( ! server . sentinel_mode ) { err = ""sentineldirectivewhilenotinsentinelmode"" ; goto loaderr ; } err = sentinelHandleConfiguration ( argv + 1 , argc - 1 ) ; if ( err ) goto loaderr ; } } else { err = ""Baddirectiveorwrongnumberofarguments"" ; goto loaderr ; } sdsfreesplitres ( argv , argc ) ; } if ( server . cluster_enabled && server . masterhost ) { linenum = slaveof_linenum ; i = linenum - 1 ; err = ""slaveofdirectivenotallowedinclustermode"" ; goto loaderr ; } sdsfreesplitres ( lines , totlines ) ; return ; loaderr : fprintf ( stderr , ""\\n***FATALCONFIGFILEERROR***\\n"" ) ; fprintf ( stderr , ""Readingtheconfigurationfile,atline%d\\n"" , linenum ) ; fprintf ( stderr , "">>>\'%s\'\\n"" , lines [ i ] ) ; fprintf ( stderr , ""%s\\n"" , err ) ; exit ( 1 ) ; } "," == - 1 || class == CLIENT_TYPE_MASTER ) { err = ""Unrecognizedclientlimitclass:theuserspecified"" ""aninvalidone,or\'master\'whichhasnobufferlimits."" ; goto loaderr ",antirez@redis/6d9f8e2462fc2c426d48c941edeb78e5df7d2977,CVE-2016-8339,https://github.com/antirez/redis/commit/6d9f8e2462fc2c426d48c941edeb78e5df7d2977,2016-10-28T14:59Z 32,CWE-119,"CWE-119 static struct nvmet_fc_tgt_queue * nvmet_fc_find_target_queue ( struct nvmet_fc_tgtport * tgtport , u64 connection_id ) { struct nvmet_fc_tgt_assoc * assoc ; struct nvmet_fc_tgt_queue * queue ; u64 association_id = nvmet_fc_getassociationid ( connection_id ) ; u16 qid = nvmet_fc_getqueueid ( connection_id ) ; unsigned long flags ; spin_lock_irqsave ( & tgtport -> lock , flags ) ; list_for_each_entry ( assoc , & tgtport -> assoc_list , a_list ) { if ( association_id == assoc -> association_id ) { queue = assoc -> queues [ qid ] ; if ( queue && ( ! atomic_read ( & queue -> connected ) || ! nvmet_fc_tgt_q_get ( queue ) ) ) queue = NULL ; spin_unlock_irqrestore ( & tgtport -> lock , flags ) ; return queue ; } } spin_unlock_irqrestore ( & tgtport -> lock , flags ) ; return NULL ; } "," unsigned long flags ; if ( qid > NVMET_NR_QUEUES ) return NULL ",torvalds@linux/0c319d3a144d4b8f1ea2047fd614d2149b68f889,CVE-2017-18379,https://github.com/torvalds/linux/commit/0c319d3a144d4b8f1ea2047fd614d2149b68f889,2019-07-27T22:15Z 33,CWE-476,"CWE-476 static int tower_probe ( struct usb_interface * interface , const struct usb_device_id * id ) { struct device * idev = & interface -> dev ; struct usb_device * udev = interface_to_usbdev ( interface ) ; struct lego_usb_tower * dev = NULL ; struct usb_host_interface * iface_desc ; struct usb_endpoint_descriptor * endpoint ; struct tower_get_version_reply get_version_reply ; int i ; int retval = - ENOMEM ; int result ; dev = kmalloc ( sizeof ( struct lego_usb_tower ) , GFP_KERNEL ) ; if ( ! dev ) goto exit ; mutex_init ( & dev -> lock ) ; dev -> udev = udev ; dev -> open_count = 0 ; dev -> read_buffer = NULL ; dev -> read_buffer_length = 0 ; dev -> read_packet_length = 0 ; spin_lock_init ( & dev -> read_buffer_lock ) ; dev -> packet_timeout_jiffies = msecs_to_jiffies ( packet_timeout ) ; dev -> read_last_arrival = jiffies ; init_waitqueue_head ( & dev -> read_wait ) ; init_waitqueue_head ( & dev -> write_wait ) ; dev -> interrupt_in_buffer = NULL ; dev -> interrupt_in_endpoint = NULL ; dev -> interrupt_in_urb = NULL ; dev -> interrupt_in_running = 0 ; dev -> interrupt_in_done = 0 ; dev -> interrupt_out_buffer = NULL ; dev -> interrupt_out_endpoint = NULL ; dev -> interrupt_out_urb = NULL ; dev -> interrupt_out_busy = 0 ; iface_desc = interface -> cur_altsetting ; for ( i = 0 ; i < iface_desc -> desc . bNumEndpoints ; ++ i ) { endpoint = & iface_desc -> endpoint [ i ] . desc ; if ( usb_endpoint_xfer_int ( endpoint ) ) { if ( usb_endpoint_dir_in ( endpoint ) ) dev -> interrupt_in_endpoint = endpoint ; else dev -> interrupt_out_endpoint = endpoint ; } } if ( dev -> interrupt_in_endpoint == NULL ) { dev_err ( idev , ""interruptinendpointnotfound\\n"" ) ; goto error ; } if ( dev -> interrupt_out_endpoint == NULL ) { dev_err ( idev , ""interruptoutendpointnotfound\\n"" ) ; goto error ; } dev -> read_buffer = kmalloc ( read_buffer_size , GFP_KERNEL ) ; if ( ! dev -> read_buffer ) goto error ; dev -> interrupt_in_buffer = kmalloc ( usb_endpoint_maxp ( dev -> interrupt_in_endpoint ) , GFP_KERNEL ) ; if ( ! dev -> interrupt_in_buffer ) goto error ; dev -> interrupt_in_urb = usb_alloc_urb ( 0 , GFP_KERNEL ) ; if ( ! dev -> interrupt_in_urb ) goto error ; dev -> interrupt_out_buffer = kmalloc ( write_buffer_size , GFP_KERNEL ) ; if ( ! dev -> interrupt_out_buffer ) goto error ; dev -> interrupt_out_urb = usb_alloc_urb ( 0 , GFP_KERNEL ) ; if ( ! dev -> interrupt_out_urb ) goto error ; dev -> interrupt_in_interval = interrupt_in_interval ? interrupt_in_interval : dev -> interrupt_in_endpoint -> bInterval ; dev -> interrupt_out_interval = interrupt_out_interval ? interrupt_out_interval : dev -> interrupt_out_endpoint -> bInterval ; usb_set_intfdata ( interface , dev ) ; retval = usb_register_dev ( interface , & tower_class ) ; if ( retval ) { dev_err ( idev , ""Notabletogetaminorforthisdevice.\\n"" ) ; usb_set_intfdata ( interface , NULL ) ; goto error ; } dev -> minor = interface -> minor ; dev_info ( & interface -> dev , ""LEGOUSBTower#%dnowattachedtomajor"" ""%dminor%d\\n"" , ( dev -> minor - LEGO_USB_TOWER_MINOR_BASE ) , USB_MAJOR , dev -> minor ) ; result = usb_control_msg ( udev , usb_rcvctrlpipe ( udev , 0 ) , LEGO_USB_TOWER_REQUEST_GET_VERSION , USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_DEVICE , 0 , 0 , & get_version_reply , sizeof ( get_version_reply ) , 1000 ) ; if ( result < 0 ) { dev_err ( idev , ""LEGOUSBTowergetversioncontrolrequestfailed\\n"" ) ; retval = result ; goto error ; } dev_info ( & interface -> dev , ""LEGOUSBTowerfirmwareversionis%d.%d"" ""build%d\\n"" , get_version_reply . major , get_version_reply . minor , le16_to_cpu ( get_version_reply . build_no ) ) ; exit : return retval ; error : tower_delete ( dev ) ; return retval ; } "," -> bInterval ; result = usb_control_msg ) ) ; usb_set_intfdata ( interface , dev ) ; retval = usb_register_dev ( interface , & tower_class ) ; if ( retval ) { dev_err ( idev , ""Notabletogetaminorforthisdevice.\\n"" ) ; usb_set_intfdata ( interface , NULL ) ; goto error ; } dev -> minor = interface -> minor ; dev_info ( & interface -> dev , ""LEGOUSBTower#%dnowattachedtomajor"" ""%dminor%d\\n"" , ( dev -> minor - LEGO_USB_TOWER_MINOR_BASE ) , USB_MAJOR , dev -> minor ) ; ",torvalds@linux/2fae9e5a7babada041e2e161699ade2447a01989,CVE-2017-15102,https://github.com/torvalds/linux/commit/2fae9e5a7babada041e2e161699ade2447a01989,2017-11-15T21:29Z 34,CWE-476,"CWE-476 static Sdb * store_versioninfo_gnu_verdef ( ELFOBJ * bin , Elf_ ( Shdr ) * shdr , int sz ) { const char * section_name = """" ; const char * link_section_name = """" ; char * end = NULL ; Elf_ ( Shdr ) * link_shdr = NULL ; ut8 dfs [ sizeof ( Elf_ ( Verdef ) ) ] = { 0 } ; Sdb * sdb ; int cnt , i ; if ( shdr -> sh_link > bin -> ehdr . e_shnum ) { return false ; } link_shdr = & bin -> shdr [ shdr -> sh_link ] ; if ( shdr -> sh_size < 1 || shdr -> sh_size > SIZE_MAX ) { return false ; } Elf_ ( Verdef ) * defs = calloc ( shdr -> sh_size , sizeof ( char ) ) ; if ( ! defs ) { return false ; } if ( bin -> shstrtab && shdr -> sh_name < bin -> shstrtab_size ) { section_name = & bin -> shstrtab [ shdr -> sh_name ] ; } if ( link_shdr && bin -> shstrtab && link_shdr -> sh_name < bin -> shstrtab_size ) { link_section_name = & bin -> shstrtab [ link_shdr -> sh_name ] ; } if ( ! defs ) { bprintf ( ""Warning:Cannotallocatememory(CheckElf_(Verdef))\\n"" ) ; return NULL ; } sdb = sdb_new0 ( ) ; end = ( char * ) defs + shdr -> sh_size ; sdb_set ( sdb , ""section_name"" , section_name , 0 ) ; sdb_num_set ( sdb , ""entries"" , shdr -> sh_info , 0 ) ; sdb_num_set ( sdb , ""addr"" , shdr -> sh_addr , 0 ) ; sdb_num_set ( sdb , ""offset"" , shdr -> sh_offset , 0 ) ; sdb_num_set ( sdb , ""link"" , shdr -> sh_link , 0 ) ; sdb_set ( sdb , ""link_section_name"" , link_section_name , 0 ) ; for ( cnt = 0 , i = 0 ; i >= 0 && cnt < shdr -> sh_info && ( end - ( char * ) defs > i ) ; ++ cnt ) { Sdb * sdb_verdef = sdb_new0 ( ) ; char * vstart = ( ( char * ) defs ) + i ; char key [ 32 ] = { 0 } ; Elf_ ( Verdef ) * verdef = ( Elf_ ( Verdef ) * ) vstart ; Elf_ ( Verdaux ) aux = { 0 } ; int j = 0 ; int isum = 0 ; r_buf_read_at ( bin -> b , shdr -> sh_offset + i , dfs , sizeof ( Elf_ ( Verdef ) ) ) ; verdef -> vd_version = READ16 ( dfs , j ) verdef -> vd_flags = READ16 ( dfs , j ) verdef -> vd_ndx = READ16 ( dfs , j ) verdef -> vd_cnt = READ16 ( dfs , j ) verdef -> vd_hash = READ32 ( dfs , j ) verdef -> vd_aux = READ32 ( dfs , j ) verdef -> vd_next = READ32 ( dfs , j ) int vdaux = verdef -> vd_aux ; if ( vdaux < 1 || ( char * ) UINTPTR_MAX - vstart < vdaux ) { sdb_free ( sdb_verdef ) ; goto out_error ; } vstart += vdaux ; if ( vstart > end || end - vstart < sizeof ( Elf_ ( Verdaux ) ) ) { sdb_free ( sdb_verdef ) ; goto out_error ; } j = 0 ; aux . vda_name = READ32 ( vstart , j ) aux . vda_next = READ32 ( vstart , j ) isum = i + verdef -> vd_aux ; if ( aux . vda_name > bin -> dynstr_size ) { sdb_free ( sdb_verdef ) ; goto out_error ; } sdb_num_set ( sdb_verdef , ""idx"" , i , 0 ) ; sdb_num_set ( sdb_verdef , ""vd_version"" , verdef -> vd_version , 0 ) ; sdb_num_set ( sdb_verdef , ""vd_ndx"" , verdef -> vd_ndx , 0 ) ; sdb_num_set ( sdb_verdef , ""vd_cnt"" , verdef -> vd_cnt , 0 ) ; sdb_set ( sdb_verdef , ""vda_name"" , & bin -> dynstr [ aux . vda_name ] , 0 ) ; sdb_set ( sdb_verdef , ""flags"" , get_ver_flags ( verdef -> vd_flags ) , 0 ) ; for ( j = 1 ; j < verdef -> vd_cnt ; ++ j ) { int k ; Sdb * sdb_parent = sdb_new0 ( ) ; isum += aux . vda_next ; vstart += aux . vda_next ; if ( vstart > end || end - vstart < sizeof ( Elf_ ( Verdaux ) ) ) { sdb_free ( sdb_verdef ) ; sdb_free ( sdb_parent ) ; goto out_error ; } k = 0 ; aux . vda_name = READ32 ( vstart , k ) aux . vda_next = READ32 ( vstart , k ) if ( aux . vda_name > bin -> dynstr_size ) { sdb_free ( sdb_verdef ) ; sdb_free ( sdb_parent ) ; goto out_error ; } sdb_num_set ( sdb_parent , ""idx"" , isum , 0 ) ; sdb_num_set ( sdb_parent , ""parent"" , j , 0 ) ; sdb_set ( sdb_parent , ""vda_name"" , & bin -> dynstr [ aux . vda_name ] , 0 ) ; snprintf ( key , sizeof ( key ) , ""parent%d"" , j - 1 ) ; sdb_ns_set ( sdb_verdef , key , sdb_parent ) ; } snprintf ( key , sizeof ( key ) , ""verdef%d"" , cnt ) ; sdb_ns_set ( sdb , key , sdb_verdef ) ; if ( ! verdef -> vd_next ) { sdb_free ( sdb_verdef ) ; goto out_error ; } if ( ( st32 ) verdef -> vd_next < 1 ) { eprintf ( ""Warning:Invalidvd_nextintheELFversion\\n"" ) ; break ; } i += verdef -> vd_next ; } free ( defs ) ; return sdb ; out_error : free ( defs ) ; sdb_free ( sdb ) ; return NULL ; } "," < 1 || vstart + vdaux < vstart ) { sdb_free ",radare@radare2/d21e91f075a7a7a8ed23baa5c1bb1fac48313882,CVE-2017-16359,https://github.com/radare/radare2/commit/d21e91f075a7a7a8ed23baa5c1bb1fac48313882,2017-11-01T17:29Z 35,CWE-862,"CWE-862 static void construct_get_dest_keyring ( struct key * * _dest_keyring ) { struct request_key_auth * rka ; const struct cred * cred = current_cred ( ) ; struct key * dest_keyring = * _dest_keyring , * authkey ; kenter ( ""%p"" , dest_keyring ) ; if ( dest_keyring ) { key_get ( dest_keyring ) ; } else { switch ( cred -> jit_keyring ) { case KEY_REQKEY_DEFL_DEFAULT : case KEY_REQKEY_DEFL_REQUESTOR_KEYRING : if ( cred -> request_key_auth ) { authkey = cred -> request_key_auth ; down_read ( & authkey -> sem ) ; rka = authkey -> payload . data [ 0 ] ; if ( ! test_bit ( KEY_FLAG_REVOKED , & authkey -> flags ) ) dest_keyring = key_get ( rka -> dest_keyring ) ; up_read ( & authkey -> sem ) ; if ( dest_keyring ) break ; } case KEY_REQKEY_DEFL_THREAD_KEYRING : dest_keyring = key_get ( cred -> thread_keyring ) ; if ( dest_keyring ) break ; case KEY_REQKEY_DEFL_PROCESS_KEYRING : dest_keyring = key_get ( cred -> process_keyring ) ; if ( dest_keyring ) break ; case KEY_REQKEY_DEFL_SESSION_KEYRING : rcu_read_lock ( ) ; dest_keyring = key_get ( rcu_dereference ( cred -> session_keyring ) ) ; rcu_read_unlock ( ) ; if ( dest_keyring ) break ; case KEY_REQKEY_DEFL_USER_SESSION_KEYRING : dest_keyring = key_get ( cred -> user -> session_keyring ) ; break ; case KEY_REQKEY_DEFL_USER_KEYRING : dest_keyring = key_get ( cred -> user -> uid_keyring ) ; break ; case KEY_REQKEY_DEFL_GROUP_KEYRING : default : BUG ( ) ; } } * _dest_keyring = dest_keyring ; kleave ( ""[dk%d]"" , key_serial ( dest_keyring ) ) ; return ; } "," static int construct_get_dest_keyring ( struct * authkey ; int ret ; } else { bool do_perm_check = true ; ( dest_keyring ) { do_perm_check = false ; break ; } } case KEY_REQKEY_DEFL_THREAD_KEYRING ) ; } if ( dest_keyring && do_perm_check ) { ret = key_permission ( make_key_ref ( dest_keyring , 1 ) , KEY_NEED_WRITE ) ; if ( ret ) { key_put ( dest_keyring ) ; return ret ; } } ) ; return 0 ",torvalds@linux/4dca6ea1d9432052afb06baf2e3ae78188a4410b,CVE-2017-17807,https://github.com/torvalds/linux/commit/4dca6ea1d9432052afb06baf2e3ae78188a4410b,2017-12-20T23:29Z 36,CWE-763,"CWE-763 static OM_uint32 init_ctx_new ( OM_uint32 * minor_status , spnego_gss_cred_id_t spcred , gss_ctx_id_t * ctx , send_token_flag * tokflag ) { OM_uint32 ret ; spnego_gss_ctx_id_t sc = NULL ; sc = create_spnego_ctx ( ) ; if ( sc == NULL ) return GSS_S_FAILURE ; ret = get_negotiable_mechs ( minor_status , spcred , GSS_C_INITIATE , & sc -> mech_set ) ; if ( ret != GSS_S_COMPLETE ) goto cleanup ; sc -> internal_mech = & sc -> mech_set -> elements [ 0 ] ; if ( put_mech_set ( sc -> mech_set , & sc -> DER_mechTypes ) < 0 ) { ret = GSS_S_FAILURE ; goto cleanup ; } sc -> ctx_handle = GSS_C_NO_CONTEXT ; * ctx = ( gss_ctx_id_t ) sc ; sc = NULL ; * tokflag = INIT_TOKEN_SEND ; ret = GSS_S_CONTINUE_NEEDED ; cleanup : release_spnego_ctx ( & sc ) ; return ret ; } "," = create_spnego_ctx ( 1 ",krb5@krb5/b51b33f2bc5d1497ddf5bd107f791c101695000d,CVE-2015-2695,https://github.com/krb5/krb5/commit/b51b33f2bc5d1497ddf5bd107f791c101695000d,2015-11-09T03:59Z 37,CWE-416,"CWE-416 static int l2tp_ip_bind ( struct sock * sk , struct sockaddr * uaddr , int addr_len ) { struct inet_sock * inet = inet_sk ( sk ) ; struct sockaddr_l2tpip * addr = ( struct sockaddr_l2tpip * ) uaddr ; struct net * net = sock_net ( sk ) ; int ret ; int chk_addr_ret ; if ( ! sock_flag ( sk , SOCK_ZAPPED ) ) return - EINVAL ; if ( addr_len < sizeof ( struct sockaddr_l2tpip ) ) return - EINVAL ; if ( addr -> l2tp_family != AF_INET ) return - EINVAL ; ret = - EADDRINUSE ; read_lock_bh ( & l2tp_ip_lock ) ; if ( __l2tp_ip_bind_lookup ( net , addr -> l2tp_addr . s_addr , sk -> sk_bound_dev_if , addr -> l2tp_conn_id ) ) goto out_in_use ; read_unlock_bh ( & l2tp_ip_lock ) ; lock_sock ( sk ) ; if ( sk -> sk_state != TCP_CLOSE || addr_len < sizeof ( struct sockaddr_l2tpip ) ) goto out ; chk_addr_ret = inet_addr_type ( net , addr -> l2tp_addr . s_addr ) ; ret = - EADDRNOTAVAIL ; if ( addr -> l2tp_addr . s_addr && chk_addr_ret != RTN_LOCAL && chk_addr_ret != RTN_MULTICAST && chk_addr_ret != RTN_BROADCAST ) goto out ; if ( addr -> l2tp_addr . s_addr ) inet -> inet_rcv_saddr = inet -> inet_saddr = addr -> l2tp_addr . s_addr ; if ( chk_addr_ret == RTN_MULTICAST || chk_addr_ret == RTN_BROADCAST ) inet -> inet_saddr = 0 ; sk_dst_reset ( sk ) ; l2tp_ip_sk ( sk ) -> conn_id = addr -> l2tp_conn_id ; write_lock_bh ( & l2tp_ip_lock ) ; sk_add_bind_node ( sk , & l2tp_ip_bind_table ) ; sk_del_node_init ( sk ) ; write_unlock_bh ( & l2tp_ip_lock ) ; ret = 0 ; sock_reset_flag ( sk , SOCK_ZAPPED ) ; out : release_sock ( sk ) ; return ret ; out_in_use : read_unlock_bh ( & l2tp_ip_lock ) ; return ret ; } "," ; if ( addr_len < sizeof ( struct sockaddr_l2tpip ) ) return ; if ( addr -> l2tp_family != AF_INET ) return - - EINVAL ; ret = - ( sk ) ; if ( ! sock_flag ( sk , SOCK_ZAPPED ) ) goto out ",torvalds@linux/32c231164b762dddefa13af5a0101032c70b50ef,CVE-2016-10200,https://github.com/torvalds/linux/commit/32c231164b762dddefa13af5a0101032c70b50ef,2017-03-07T21:59Z 38,CWE-264,"CWE-264 static unsigned int stack_maxrandom_size ( void ) { unsigned int max = 0 ; if ( ( current -> flags & PF_RANDOMIZE ) && ! ( current -> personality & ADDR_NO_RANDOMIZE ) ) { max = ( ( - 1U ) & STACK_RND_MASK ) << PAGE_SHIFT ; } return max ; } "," static unsigned long stack_maxrandom_size ( void ) { unsigned long max = 0 ( ( - 1UL ) & STACK_RND_MASK ",torvalds@linux/4e7c22d447bb6d7e37bfe39ff658486ae78e8d77,CVE-2015-1593,https://github.com/torvalds/linux/commit/4e7c22d447bb6d7e37bfe39ff658486ae78e8d77,2015-03-16T10:59Z 39,CWE-20,"CWE-20 static void activate_desktop_file ( ActivateParameters * parameters , NautilusFile * file ) { ActivateParametersDesktop * parameters_desktop ; char * primary , * secondary , * display_name ; GtkWidget * dialog ; GdkScreen * screen ; char * uri ; screen = gtk_widget_get_screen ( GTK_WIDGET ( parameters -> parent_window ) ) ; if ( ! nautilus_file_is_trusted_link ( file ) ) { parameters_desktop = g_new0 ( ActivateParametersDesktop , 1 ) ; if ( parameters -> parent_window ) { parameters_desktop -> parent_window = parameters -> parent_window ; g_object_add_weak_pointer ( G_OBJECT ( parameters_desktop -> parent_window ) , ( gpointer * ) & parameters_desktop -> parent_window ) ; } parameters_desktop -> file = nautilus_file_ref ( file ) ; primary = _ ( ""Untrustedapplicationlauncher"" ) ; display_name = nautilus_file_get_display_name ( file ) ; secondary = g_strdup_printf ( _ ( ""Theapplicationlauncher“%s”hasnotbeenmarkedastrusted."" ""Ifyoudonotknowthesourceofthisfile,launchingitmaybeunsafe."" ) , display_name ) ; dialog = gtk_message_dialog_new ( parameters -> parent_window , 0 , GTK_MESSAGE_WARNING , GTK_BUTTONS_NONE , NULL ) ; g_object_set ( dialog , ""text"" , primary , ""secondary-text"" , secondary , NULL ) ; gtk_dialog_add_button ( GTK_DIALOG ( dialog ) , _ ( ""_LaunchAnyway"" ) , RESPONSE_RUN ) ; if ( nautilus_file_can_set_permissions ( file ) ) { gtk_dialog_add_button ( GTK_DIALOG ( dialog ) , _ ( ""Markas_Trusted"" ) , RESPONSE_MARK_TRUSTED ) ; } gtk_dialog_add_button ( GTK_DIALOG ( dialog ) , _ ( ""_Cancel"" ) , GTK_RESPONSE_CANCEL ) ; gtk_dialog_set_default_response ( GTK_DIALOG ( dialog ) , GTK_RESPONSE_CANCEL ) ; g_signal_connect ( dialog , ""response"" , G_CALLBACK ( untrusted_launcher_response_callback ) , parameters_desktop ) ; gtk_widget_show ( dialog ) ; g_free ( display_name ) ; g_free ( secondary ) ; return ; } uri = nautilus_file_get_uri ( file ) ; DEBUG ( ""Launchingtrustedlauncher%s"" , uri ) ; nautilus_launch_desktop_file ( screen , uri , NULL , parameters -> parent_window ) ; g_free ( uri ) ; } "," , _ ( ""_Cancel"" ) , GTK_RESPONSE_CANCEL ) ; gtk_dialog_set_default_response ( GTK_DIALOG ( dialog ) , GTK_RESPONSE_CANCEL ) ; if , _ ( ""Trustand_Launch"" ) , GTK_RESPONSE_OK ) ; } ) ; } g_signal_connect ( dialog ",GNOME@nautilus/1630f53481f445ada0a455e9979236d31a8d3bb0,CVE-2017-14604,https://github.com/GNOME/nautilus/commit/1630f53481f445ada0a455e9979236d31a8d3bb0,2017-09-20T08:29Z 40,CWE-416,"CWE-416 char * my_asctime ( time_t t ) { struct tm * tm ; char * str ; int len ; tm = localtime ( & t ) ; str = g_strdup ( asctime ( tm ) ) ; len = strlen ( str ) ; if ( len > 0 ) str [ len - 1 ] = '\\0' ; return str ; } "," ( & t ) ; if ( tm == NULL ) return g_strdup ( ""???"" ",irssi@irssi/5e26325317c72a04c1610ad952974e206384d291,CVE-2017-10966,https://github.com/irssi/irssi/commit/5e26325317c72a04c1610ad952974e206384d291,2017-07-07T14:29Z 41,CWE-787,"CWE-787 static void add_password ( AUTH_HDR * request , unsigned char type , CONST char * password , char * secret ) { MD5_CTX md5_secret , my_md5 ; unsigned char misc [ AUTH_VECTOR_LEN ] ; int i ; int length = strlen ( password ) ; unsigned char hashed [ 256 + AUTH_PASS_LEN ] ; unsigned char * vector ; attribute_t * attr ; if ( length > MAXPASS ) { length = MAXPASS ; } if ( length == 0 ) { length = AUTH_PASS_LEN ; } if ( ( length & ( AUTH_PASS_LEN - 1 ) ) != 0 ) { length += ( AUTH_PASS_LEN - 1 ) ; length &= ~ ( AUTH_PASS_LEN - 1 ) ; } memset ( hashed , 0 , length ) ; memcpy ( hashed , password , strlen ( password ) ) ; attr = find_attribute ( request , PW_PASSWORD ) ; if ( type == PW_PASSWORD ) { vector = request -> vector ; } else { vector = attr -> data ; } MD5Init ( & md5_secret ) ; MD5Update ( & md5_secret , ( unsigned char * ) secret , strlen ( secret ) ) ; my_md5 = md5_secret ; MD5Update ( & my_md5 , vector , AUTH_VECTOR_LEN ) ; MD5Final ( misc , & my_md5 ) ; xor ( hashed , misc , AUTH_PASS_LEN ) ; for ( i = 1 ; i < ( length >> 4 ) ; i ++ ) { my_md5 = md5_secret ; MD5Update ( & my_md5 , & hashed [ ( i - 1 ) * AUTH_PASS_LEN ] , AUTH_PASS_LEN ) ; MD5Final ( misc , & my_md5 ) ; xor ( & hashed [ i * AUTH_PASS_LEN ] , misc , AUTH_PASS_LEN ) ; } if ( type == PW_OLD_PASSWORD ) { attr = find_attribute ( request , PW_OLD_PASSWORD ) ; } if ( ! attr ) { add_attribute ( request , type , hashed , length ) ; } else { memcpy ( attr -> data , hashed , length ) ; } } "," , password , length ) ; attr ",FreeRADIUS@pam_radius/01173ec2426627dbb1e0d96c06c3ffa0b14d36d0,CVE-2015-9542,https://github.com/FreeRADIUS/pam_radius/commit/01173ec2426627dbb1e0d96c06c3ffa0b14d36d0,2020-02-24T15:15Z 42,CWE-119,"CWE-119 static int m88rs2000_frontend_attach ( struct dvb_usb_adapter * d ) { u8 obuf [ ] = { 0x51 } ; u8 ibuf [ ] = { 0 } ; if ( dvb_usb_generic_rw ( d -> dev , obuf , 1 , ibuf , 1 , 0 ) < 0 ) err ( ""command0x51transferfailed."" ) ; d -> fe_adap [ 0 ] . fe = dvb_attach ( m88rs2000_attach , & s421_m88rs2000_config , & d -> dev -> i2c_adap ) ; if ( d -> fe_adap [ 0 ] . fe == NULL ) return - EIO ; if ( dvb_attach ( ts2020_attach , d -> fe_adap [ 0 ] . fe , & dw2104_ts2020_config , & d -> dev -> i2c_adap ) ) { info ( ""AttachedRS2000/TS2020!"" ) ; return 0 ; } info ( ""FailedtoattachRS2000/TS2020!"" ) ; return - EIO ; } "," struct dvb_usb_adapter * adap ) { struct dvb_usb_device * d = adap -> dev ; struct dw2102_state * state = d -> priv ; mutex_lock ( & d -> data_mutex ) ; state -> data [ 0 ] = 0x51 ; if ( dvb_usb_generic_rw ( d , state -> data , 1 , , 1 , state -> data , 1 , ""command0x51transferfailed."" ) ; mutex_unlock ( & d -> data_mutex ) ; adap -> fe_adap [ & d -> i2c_adap ) ; ; if ( adap -> fe_adap [ ( ts2020_attach , adap -> fe_adap [ , & d -> i2c_adap ) ",torvalds@linux/606142af57dad981b78707234cfbd15f9f7b7125,CVE-2017-8062,https://github.com/torvalds/linux/commit/606142af57dad981b78707234cfbd15f9f7b7125,2017-04-23T05:59Z 43,CWE-362,"CWE-362 void sctp_generate_heartbeat_event ( unsigned long data ) { int error = 0 ; struct sctp_transport * transport = ( struct sctp_transport * ) data ; struct sctp_association * asoc = transport -> asoc ; struct net * net = sock_net ( asoc -> base . sk ) ; bh_lock_sock ( asoc -> base . sk ) ; if ( sock_owned_by_user ( asoc -> base . sk ) ) { pr_debug ( ""%s:sockisbusy\\n"" , __func__ ) ; if ( ! mod_timer ( & transport -> hb_timer , jiffies + ( HZ / 20 ) ) ) sctp_transport_hold ( transport ) ; goto out_unlock ; } if ( transport -> dead ) goto out_unlock ; error = sctp_do_sm ( net , SCTP_EVENT_T_TIMEOUT , SCTP_ST_TIMEOUT ( SCTP_EVENT_TIMEOUT_HEARTBEAT ) , asoc -> state , asoc -> ep , asoc , transport , GFP_ATOMIC ) ; if ( error ) asoc -> base . sk -> sk_err = - error ; out_unlock : bh_unlock_sock ( asoc -> base . sk ) ; sctp_transport_put ( transport ) ; } "," asoc ; struct sock * sk = asoc -> base . sk ; struct = sock_net ( sk ) ; ; bh_lock_sock ( sk ) ; ( sock_owned_by_user ( sk ) ) ( error ) sk -> sk_err : bh_unlock_sock ( sk ) ; ",torvalds@linux/635682a14427d241bab7bbdeebb48a7d7b91638e,CVE-2015-8767,https://github.com/torvalds/linux/commit/635682a14427d241bab7bbdeebb48a7d7b91638e,2016-02-08T03:59Z 44,CWE-200,"CWE-200 inline int web_client_api_request_v1_data ( RRDHOST * host , struct web_client * w , char * url ) { debug ( D_WEB_CLIENT , ""%llu:APIv1datawithURL\'%s\'"" , w -> id , url ) ; int ret = 400 ; BUFFER * dimensions = NULL ; buffer_flush ( w -> response . data ) ; char * google_version = ""0.6"" , * google_reqId = ""0"" , * google_sig = ""0"" , * google_out = ""json"" , * responseHandler = NULL , * outFileName = NULL ; time_t last_timestamp_in_data = 0 , google_timestamp = 0 ; char * chart = NULL , * before_str = NULL , * after_str = NULL , * group_time_str = NULL , * points_str = NULL ; int group = RRDR_GROUPING_AVERAGE ; uint32_t format = DATASOURCE_JSON ; uint32_t options = 0x00000000 ; while ( url ) { char * value = mystrsep ( & url , ""?&"" ) ; if ( ! value || ! * value ) continue ; char * name = mystrsep ( & value , ""="" ) ; if ( ! name || ! * name ) continue ; if ( ! value || ! * value ) continue ; debug ( D_WEB_CLIENT , ""%llu:APIv1dataqueryparam\'%s\'withvalue\'%s\'"" , w -> id , name , value ) ; if ( ! strcmp ( name , ""chart"" ) ) chart = value ; else if ( ! strcmp ( name , ""dimension"" ) || ! strcmp ( name , ""dim"" ) || ! strcmp ( name , ""dimensions"" ) || ! strcmp ( name , ""dims"" ) ) { if ( ! dimensions ) dimensions = buffer_create ( 100 ) ; buffer_strcat ( dimensions , ""|"" ) ; buffer_strcat ( dimensions , value ) ; } else if ( ! strcmp ( name , ""after"" ) ) after_str = value ; else if ( ! strcmp ( name , ""before"" ) ) before_str = value ; else if ( ! strcmp ( name , ""points"" ) ) points_str = value ; else if ( ! strcmp ( name , ""gtime"" ) ) group_time_str = value ; else if ( ! strcmp ( name , ""group"" ) ) { group = web_client_api_request_v1_data_group ( value , RRDR_GROUPING_AVERAGE ) ; } else if ( ! strcmp ( name , ""format"" ) ) { format = web_client_api_request_v1_data_format ( value ) ; } else if ( ! strcmp ( name , ""options"" ) ) { options |= web_client_api_request_v1_data_options ( value ) ; } else if ( ! strcmp ( name , ""callback"" ) ) { responseHandler = value ; } else if ( ! strcmp ( name , ""filename"" ) ) { outFileName = value ; } else if ( ! strcmp ( name , ""tqx"" ) ) { char * tqx_name , * tqx_value ; while ( value ) { tqx_value = mystrsep ( & value , "";"" ) ; if ( ! tqx_value || ! * tqx_value ) continue ; tqx_name = mystrsep ( & tqx_value , "":"" ) ; if ( ! tqx_name || ! * tqx_name ) continue ; if ( ! tqx_value || ! * tqx_value ) continue ; if ( ! strcmp ( tqx_name , ""version"" ) ) google_version = tqx_value ; else if ( ! strcmp ( tqx_name , ""reqId"" ) ) google_reqId = tqx_value ; else if ( ! strcmp ( tqx_name , ""sig"" ) ) { google_sig = tqx_value ; google_timestamp = strtoul ( google_sig , NULL , 0 ) ; } else if ( ! strcmp ( tqx_name , ""out"" ) ) { google_out = tqx_value ; format = web_client_api_request_v1_data_google_format ( google_out ) ; } else if ( ! strcmp ( tqx_name , ""responseHandler"" ) ) responseHandler = tqx_value ; else if ( ! strcmp ( tqx_name , ""outFileName"" ) ) outFileName = tqx_value ; } } } if ( ! chart || ! * chart ) { buffer_sprintf ( w -> response . data , ""Nochartidisgivenattherequest."" ) ; goto cleanup ; } RRDSET * st = rrdset_find ( host , chart ) ; if ( ! st ) st = rrdset_find_byname ( host , chart ) ; if ( ! st ) { buffer_strcat ( w -> response . data , ""Chartisnotfound:"" ) ; buffer_strcat_htmlescape ( w -> response . data , chart ) ; ret = 404 ; goto cleanup ; } st -> last_accessed_time = now_realtime_sec ( ) ; long long before = ( before_str && * before_str ) ? str2l ( before_str ) : 0 ; long long after = ( after_str && * after_str ) ? str2l ( after_str ) : 0 ; int points = ( points_str && * points_str ) ? str2i ( points_str ) : 0 ; long group_time = ( group_time_str && * group_time_str ) ? str2l ( group_time_str ) : 0 ; debug ( D_WEB_CLIENT , ""%llu:APIcommand\'data\'forchart\'%s\',dimensions\'%s\',after\'%lld\',before\'%lld\',points\'%d\',group\'%d\',format\'%u\',options\'0x%08x\'"" , w -> id , chart , ( dimensions ) ? buffer_tostring ( dimensions ) : """" , after , before , points , group , format , options ) ; if ( outFileName && * outFileName ) { buffer_sprintf ( w -> response . header , ""Content-Disposition:attachment;filename=\\""%s\\""\\r\\n"" , outFileName ) ; debug ( D_WEB_CLIENT , ""%llu:generatingoutfilenameheader:\'%s\'"" , w -> id , outFileName ) ; } if ( format == DATASOURCE_DATATABLE_JSONP ) { if ( responseHandler == NULL ) responseHandler = ""google.visualization.Query.setResponse"" ; debug ( D_WEB_CLIENT_ACCESS , ""%llu:GOOGLEJSON/JSONP:version=\'%s\',reqId=\'%s\',sig=\'%s\',out=\'%s\',responseHandler=\'%s\',outFileName=\'%s\'"" , w -> id , google_version , google_reqId , google_sig , google_out , responseHandler , outFileName ) ; buffer_sprintf ( w -> response . data , ""%s({version:\'%s\',reqId:\'%s\',status:\'ok\',sig:\'%ld\',table:"" , responseHandler , google_version , google_reqId , st -> last_updated . tv_sec ) ; } else if ( format == DATASOURCE_JSONP ) { if ( responseHandler == NULL ) responseHandler = ""callback"" ; buffer_strcat ( w -> response . data , responseHandler ) ; buffer_strcat ( w -> response . data , ""("" ) ; } ret = rrdset2anything_api_v1 ( st , w -> response . data , dimensions , format , points , after , before , group , group_time , options , & last_timestamp_in_data ) ; if ( format == DATASOURCE_DATATABLE_JSONP ) { if ( google_timestamp < last_timestamp_in_data ) buffer_strcat ( w -> response . data , ""});"" ) ; else { buffer_flush ( w -> response . data ) ; buffer_sprintf ( w -> response . data , ""%s({version:\'%s\',reqId:\'%s\',status:\'error\',errors:[{reason:\'not_modified\',message:\'Datanotmodified\'}]});"" , responseHandler , google_version , google_reqId ) ; } } else if ( format == DATASOURCE_JSONP ) buffer_strcat ( w -> response . data , "");"" ) ; cleanup : buffer_free ( dimensions ) ; return ret ; } "," } } } fix_google_param ( google_out ) ; fix_google_param ( google_sig ) ; fix_google_param ( google_reqId ) ; fix_google_param ( google_version ) ; fix_google_param ( responseHandler ) ; fix_google_param ( outFileName ) ; ",netdata@netdata/92327c9ec211bd1616315abcb255861b130b97ca,CVE-2018-18839,https://github.com/netdata/netdata/commit/92327c9ec211bd1616315abcb255861b130b97ca,2019-06-18T16:15Z 45,CWE-119,"CWE-119 static void horAcc8 ( TIFF * tif , uint8 * cp0 , tmsize_t cc ) { tmsize_t stride = PredictorState ( tif ) -> stride ; unsigned char * cp = ( unsigned char * ) cp0 ; assert ( ( cc % stride ) == 0 ) ; if ( cc > stride ) { if ( stride == 3 ) { unsigned int cr = cp [ 0 ] ; unsigned int cg = cp [ 1 ] ; unsigned int cb = cp [ 2 ] ; cc -= 3 ; cp += 3 ; while ( cc > 0 ) { cp [ 0 ] = ( unsigned char ) ( ( cr += cp [ 0 ] ) & 0xff ) ; cp [ 1 ] = ( unsigned char ) ( ( cg += cp [ 1 ] ) & 0xff ) ; cp [ 2 ] = ( unsigned char ) ( ( cb += cp [ 2 ] ) & 0xff ) ; cc -= 3 ; cp += 3 ; } } else if ( stride == 4 ) { unsigned int cr = cp [ 0 ] ; unsigned int cg = cp [ 1 ] ; unsigned int cb = cp [ 2 ] ; unsigned int ca = cp [ 3 ] ; cc -= 4 ; cp += 4 ; while ( cc > 0 ) { cp [ 0 ] = ( unsigned char ) ( ( cr += cp [ 0 ] ) & 0xff ) ; cp [ 1 ] = ( unsigned char ) ( ( cg += cp [ 1 ] ) & 0xff ) ; cp [ 2 ] = ( unsigned char ) ( ( cb += cp [ 2 ] ) & 0xff ) ; cp [ 3 ] = ( unsigned char ) ( ( ca += cp [ 3 ] ) & 0xff ) ; cc -= 4 ; cp += 4 ; } } else { cc -= stride ; do { REPEAT4 ( stride , cp [ stride ] = ( unsigned char ) ( ( cp [ stride ] + * cp ) & 0xff ) ; cp ++ ) cc -= stride ; } while ( cc > 0 ) ; } } } "," static int horAcc8 ( TIFF ) cp0 ; if ( ( cc % stride ) != 0 ) { TIFFErrorExt ( tif -> tif_clientdata , ""horAcc8"" , ""%s"" , ""(cc%stride)!=0"" ) ; return 0 ; } if ( cc ; } } return 1 ; ",vadz@libtiff/3ca657a8793dd011bf869695d72ad31c779c3cc1,CVE-2016-9535,https://github.com/vadz/libtiff/commit/3ca657a8793dd011bf869695d72ad31c779c3cc1,2016-11-22T19:59Z 46,CWE-119,"CWE-119 DECLAREcpFunc ( cpContig2SeparateByRow ) { tsize_t scanlinesizein = TIFFScanlineSize ( in ) ; tsize_t scanlinesizeout = TIFFScanlineSize ( out ) ; tdata_t inbuf ; tdata_t outbuf ; register uint8 * inp , * outp ; register uint32 n ; uint32 row ; tsample_t s ; inbuf = _TIFFmalloc ( scanlinesizein ) ; outbuf = _TIFFmalloc ( scanlinesizeout ) ; if ( ! inbuf || ! outbuf ) goto bad ; _TIFFmemset ( inbuf , 0 , scanlinesizein ) ; _TIFFmemset ( outbuf , 0 , scanlinesizeout ) ; for ( s = 0 ; s < spp ; s ++ ) { for ( row = 0 ; row < imagelength ; row ++ ) { if ( TIFFReadScanline ( in , inbuf , row , 0 ) < 0 && ! ignore ) { TIFFError ( TIFFFileName ( in ) , ""Error,can\'treadscanline%lu"" , ( unsigned long ) row ) ; goto bad ; } inp = ( ( uint8 * ) inbuf ) + s ; outp = ( uint8 * ) outbuf ; for ( n = imagewidth ; n -- > 0 ; ) { * outp ++ = * inp ; inp += spp ; } if ( TIFFWriteScanline ( out , outbuf , row , s ) < 0 ) { TIFFError ( TIFFFileName ( out ) , ""Error,can\'twritescanline%lu"" , ( unsigned long ) row ) ; goto bad ; } } } if ( inbuf ) _TIFFfree ( inbuf ) ; if ( outbuf ) _TIFFfree ( outbuf ) ; return 1 ; bad : if ( inbuf ) _TIFFfree ( inbuf ) ; if ( outbuf ) _TIFFfree ( outbuf ) ; return 0 ; } "," tsample_t s ; uint16 bps = 0 ; ( void ) TIFFGetField ( in , TIFFTAG_BITSPERSAMPLE , & bps ) ; if ( bps != 8 ) { TIFFError ( TIFFFileName ( in ) , ""Error,canonlyhandleBitsPerSample=8in%s"" , ""cpContig2SeparateByRow"" ) ; return 0 ; } ",vadz@libtiff/5c080298d59efa53264d7248bbe3a04660db6ef7,CVE-2017-5225,https://github.com/vadz/libtiff/commit/5c080298d59efa53264d7248bbe3a04660db6ef7,2017-01-12T11:59Z 47,CWE-399,"CWE-399 static void free_huge_page ( struct page * page ) { struct hstate * h = page_hstate ( page ) ; int nid = page_to_nid ( page ) ; struct address_space * mapping ; mapping = ( struct address_space * ) page_private ( page ) ; set_page_private ( page , 0 ) ; page -> mapping = NULL ; BUG_ON ( page_count ( page ) ) ; BUG_ON ( page_mapcount ( page ) ) ; INIT_LIST_HEAD ( & page -> lru ) ; spin_lock ( & hugetlb_lock ) ; if ( h -> surplus_huge_pages_node [ nid ] && huge_page_order ( h ) < MAX_ORDER ) { update_and_free_page ( h , page ) ; h -> surplus_huge_pages -- ; h -> surplus_huge_pages_node [ nid ] -- ; } else { enqueue_huge_page ( h , page ) ; } spin_unlock ( & hugetlb_lock ) ; if ( mapping ) hugetlb_put_quota ( mapping , 1 ) ; } "," ) ; struct hugepage_subpool * spool = ( struct hugepage_subpool * ) page_private hugetlb_lock ) ; hugepage_subpool_put_pages ( spool , 1 ) ",torvalds@linux/90481622d75715bfcb68501280a917dbfe516029,CVE-2012-2133,https://github.com/torvalds/linux/commit/90481622d75715bfcb68501280a917dbfe516029,2012-07-03T16:40Z 48,CWE-835,"CWE-835 static int read_part_of_packet ( AVFormatContext * s , int64_t * pts , int * len , int * strid , int read_packet ) { AVIOContext * pb = s -> pb ; PVAContext * pvactx = s -> priv_data ; int syncword , streamid , reserved , flags , length , pts_flag ; int64_t pva_pts = AV_NOPTS_VALUE , startpos ; int ret ; recover : startpos = avio_tell ( pb ) ; syncword = avio_rb16 ( pb ) ; streamid = avio_r8 ( pb ) ; avio_r8 ( pb ) ; reserved = avio_r8 ( pb ) ; flags = avio_r8 ( pb ) ; length = avio_rb16 ( pb ) ; pts_flag = flags & 0x10 ; if ( syncword != PVA_MAGIC ) { pva_log ( s , AV_LOG_ERROR , ""invalidsyncword\\n"" ) ; return AVERROR ( EIO ) ; } if ( streamid != PVA_VIDEO_PAYLOAD && streamid != PVA_AUDIO_PAYLOAD ) { pva_log ( s , AV_LOG_ERROR , ""invalidstreamid\\n"" ) ; return AVERROR ( EIO ) ; } if ( reserved != 0x55 ) { pva_log ( s , AV_LOG_WARNING , ""expectedreservedbytetobe0x55\\n"" ) ; } if ( length > PVA_MAX_PAYLOAD_LENGTH ) { pva_log ( s , AV_LOG_ERROR , ""invalidpayloadlength%u\\n"" , length ) ; return AVERROR ( EIO ) ; } if ( streamid == PVA_VIDEO_PAYLOAD && pts_flag ) { pva_pts = avio_rb32 ( pb ) ; length -= 4 ; } else if ( streamid == PVA_AUDIO_PAYLOAD ) { if ( ! pvactx -> continue_pes ) { int pes_signal , pes_header_data_length , pes_packet_length , pes_flags ; unsigned char pes_header_data [ 256 ] ; pes_signal = avio_rb24 ( pb ) ; avio_r8 ( pb ) ; pes_packet_length = avio_rb16 ( pb ) ; pes_flags = avio_rb16 ( pb ) ; pes_header_data_length = avio_r8 ( pb ) ; if ( pes_signal != 1 || pes_header_data_length == 0 ) { pva_log ( s , AV_LOG_WARNING , ""expectednonemptysignaledPESpacket,"" ""tryingtorecover\\n"" ) ; avio_skip ( pb , length - 9 ) ; if ( ! read_packet ) return AVERROR ( EIO ) ; goto recover ; } ret = avio_read ( pb , pes_header_data , pes_header_data_length ) ; if ( ret != pes_header_data_length ) return ret < 0 ? ret : AVERROR_INVALIDDATA ; length -= 9 + pes_header_data_length ; pes_packet_length -= 3 + pes_header_data_length ; pvactx -> continue_pes = pes_packet_length ; if ( pes_flags & 0x80 && ( pes_header_data [ 0 ] & 0xf0 ) == 0x20 ) { if ( pes_header_data_length < 5 ) { pva_log ( s , AV_LOG_ERROR , ""headertooshort\\n"" ) ; avio_skip ( pb , length ) ; return AVERROR_INVALIDDATA ; } pva_pts = ff_parse_pes_pts ( pes_header_data ) ; } } pvactx -> continue_pes -= length ; if ( pvactx -> continue_pes < 0 ) { pva_log ( s , AV_LOG_WARNING , ""audiodatacorruption\\n"" ) ; pvactx -> continue_pes = 0 ; } } if ( pva_pts != AV_NOPTS_VALUE ) av_add_index_entry ( s -> streams [ streamid - 1 ] , startpos , pva_pts , 0 , 0 , AVINDEX_KEYFRAME ) ; * pts = pva_pts ; * len = length ; * strid = streamid ; return 0 ; } "," ; if ( avio_feof ( pb ) ) { return AVERROR_EOF ; } if ( ",FFmpeg@FFmpeg/9807d3976be0e92e4ece3b4b1701be894cd7c2e1,CVE-2018-1999012,https://github.com/FFmpeg/FFmpeg/commit/9807d3976be0e92e4ece3b4b1701be894cd7c2e1,2018-07-23T15:29Z 49,CWE-119,"CWE-119 enum nss_status _nss_mymachines_getpwnam_r ( const char * name , struct passwd * pwd , char * buffer , size_t buflen , int * errnop ) { _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL ; _cleanup_bus_message_unref_ sd_bus_message * reply = NULL ; _cleanup_bus_flush_close_unref_ sd_bus * bus = NULL ; const char * p , * e , * machine ; uint32_t mapped ; uid_t uid ; size_t l ; int r ; assert ( name ) ; assert ( pwd ) ; p = startswith ( name , ""vu-"" ) ; if ( ! p ) goto not_found ; e = strrchr ( p , '-' ) ; if ( ! e || e == p ) goto not_found ; r = parse_uid ( e + 1 , & uid ) ; if ( r < 0 ) goto not_found ; machine = strndupa ( p , e - p ) ; if ( ! machine_name_is_valid ( machine ) ) goto not_found ; r = sd_bus_open_system ( & bus ) ; if ( r < 0 ) goto fail ; r = sd_bus_call_method ( bus , ""org.freedesktop.machine1"" , ""/org/freedesktop/machine1"" , ""org.freedesktop.machine1.Manager"" , ""MapFromMachineUser"" , & error , & reply , ""su"" , machine , ( uint32_t ) uid ) ; if ( r < 0 ) { if ( sd_bus_error_has_name ( & error , BUS_ERROR_NO_SUCH_USER_MAPPING ) ) goto not_found ; goto fail ; } r = sd_bus_message_read ( reply , ""u"" , & mapped ) ; if ( r < 0 ) goto fail ; l = strlen ( name ) ; if ( buflen < l + 1 ) { * errnop = ENOMEM ; return NSS_STATUS_TRYAGAIN ; } memcpy ( buffer , name , l + 1 ) ; pwd -> pw_name = buffer ; pwd -> pw_uid = mapped ; pwd -> pw_gid = 65534 ; pwd -> pw_gecos = buffer ; pwd -> pw_passwd = ( char * ) ""*"" ; pwd -> pw_dir = ( char * ) ""/"" ; pwd -> pw_shell = ( char * ) ""/sbin/nologin"" ; * errnop = 0 ; return NSS_STATUS_SUCCESS ; not_found : * errnop = 0 ; return NSS_STATUS_NOTFOUND ; fail : * errnop = - r ; return NSS_STATUS_UNAVAIL ; } "," e == p ) goto not_found ; if ( e - p > HOST_NAME_MAX - 1 ",keszybz@systemd/cb31827d62066a04b02111df3052949fda4b6888,CVE-2015-7510,https://github.com/keszybz/systemd/commit/cb31827d62066a04b02111df3052949fda4b6888,2017-09-25T21:29Z 50,CWE-416,"CWE-416 void generic_pipe_buf_get ( struct pipe_inode_info * pipe , struct pipe_buffer * buf ) { get_page ( buf -> page ) ; } "," bool generic_pipe_buf_get ( struct buf ) { return try_get_page ( buf -> ",torvalds@linux/15fab63e1e57be9fdb5eec1bbc5916e9825e9acb,CVE-2019-11487,https://github.com/torvalds/linux/commit/15fab63e1e57be9fdb5eec1bbc5916e9825e9acb,2019-04-23T22:29Z 51,CWE-125,"CWE-125 static const u_char * ikev2_t_print ( netdissect_options * ndo , int tcount , const struct isakmp_gen * ext , u_int item_len , const u_char * ep ) { const struct ikev2_t * p ; struct ikev2_t t ; uint16_t t_id ; const u_char * cp ; const char * idstr ; const struct attrmap * map ; size_t nmap ; const u_char * ep2 ; p = ( const struct ikev2_t * ) ext ; ND_TCHECK ( * p ) ; UNALIGNED_MEMCPY ( & t , ext , sizeof ( t ) ) ; ikev2_pay_print ( ndo , NPSTR ( ISAKMP_NPTYPE_T ) , t . h . critical ) ; t_id = ntohs ( t . t_id ) ; map = NULL ; nmap = 0 ; switch ( t . t_type ) { case IV2_T_ENCR : idstr = STR_OR_ID ( t_id , esp_p_map ) ; map = encr_t_map ; nmap = sizeof ( encr_t_map ) / sizeof ( encr_t_map [ 0 ] ) ; break ; case IV2_T_PRF : idstr = STR_OR_ID ( t_id , prf_p_map ) ; break ; case IV2_T_INTEG : idstr = STR_OR_ID ( t_id , integ_p_map ) ; break ; case IV2_T_DH : idstr = STR_OR_ID ( t_id , dh_p_map ) ; break ; case IV2_T_ESN : idstr = STR_OR_ID ( t_id , esn_p_map ) ; break ; default : idstr = NULL ; break ; } if ( idstr ) ND_PRINT ( ( ndo , ""#%utype=%sid=%s"" , tcount , STR_OR_ID ( t . t_type , ikev2_t_type_map ) , idstr ) ) ; else ND_PRINT ( ( ndo , ""#%utype=%sid=%u"" , tcount , STR_OR_ID ( t . t_type , ikev2_t_type_map ) , t . t_id ) ) ; cp = ( const u_char * ) ( p + 1 ) ; ep2 = ( const u_char * ) p + item_len ; while ( cp < ep && cp < ep2 ) { if ( map && nmap ) { cp = ikev1_attrmap_print ( ndo , cp , ( ep < ep2 ) ? ep : ep2 , map , nmap ) ; } else cp = ikev1_attr_print ( ndo , cp , ( ep < ep2 ) ? ep : ep2 ) ; } if ( ep < ep2 ) ND_PRINT ( ( ndo , ""..."" ) ) ; return cp ; trunc : ND_PRINT ( ( ndo , ""[|%s]"" , NPSTR ( ISAKMP_NPTYPE_T ) ) ) ; return NULL ; } "," , cp , ep2 , map , nmap ) ; } else cp = ikev1_attr_print ( ndo , cp , ep2 ) ; if ( cp == NULL ) goto trunc ; } if < ep2 ) ND_PRINT ( ( ",the-tcpdump-group@tcpdump/e0a5a02b0fc1900a69d6c37ed0aab36fb8494e6d,CVE-2017-13039,https://github.com/the-tcpdump-group/tcpdump/commit/e0a5a02b0fc1900a69d6c37ed0aab36fb8494e6d,2017-09-14T06:29Z 52,CWE-264,"CWE-264 int inode_change_ok ( const struct inode * inode , struct iattr * attr ) { unsigned int ia_valid = attr -> ia_valid ; if ( ia_valid & ATTR_SIZE ) { int error = inode_newsize_ok ( inode , attr -> ia_size ) ; if ( error ) return error ; } if ( ia_valid & ATTR_FORCE ) return 0 ; if ( ( ia_valid & ATTR_UID ) && ( ! uid_eq ( current_fsuid ( ) , inode -> i_uid ) || ! uid_eq ( attr -> ia_uid , inode -> i_uid ) ) && ! inode_capable ( inode , CAP_CHOWN ) ) return - EPERM ; if ( ( ia_valid & ATTR_GID ) && ( ! uid_eq ( current_fsuid ( ) , inode -> i_uid ) || ( ! in_group_p ( attr -> ia_gid ) && ! gid_eq ( attr -> ia_gid , inode -> i_gid ) ) ) && ! inode_capable ( inode , CAP_CHOWN ) ) return - EPERM ; if ( ia_valid & ATTR_MODE ) { if ( ! inode_owner_or_capable ( inode ) ) return - EPERM ; if ( ! in_group_p ( ( ia_valid & ATTR_GID ) ? attr -> ia_gid : inode -> i_gid ) && ! inode_capable ( inode , CAP_FSETID ) ) attr -> ia_mode &= ~ S_ISGID ; } if ( ia_valid & ( ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_TIMES_SET ) ) { if ( ! inode_owner_or_capable ( inode ) ) return - EPERM ; } return 0 ; } "," ) && ! capable_wrt_inode_uidgid ( inode , ) && ! capable_wrt_inode_uidgid ( inode , ) && ! capable_wrt_inode_uidgid ( inode , ",torvalds@linux/23adbe12ef7d3d4195e80800ab36b37bee28cd03,CVE-2014-4014,https://github.com/torvalds/linux/commit/23adbe12ef7d3d4195e80800ab36b37bee28cd03,2014-06-23T11:21Z 53,CWE-284,"CWE-284 static bool has_byte ( const eager_reader_t * reader ) { assert ( reader != NULL ) ; fd_set read_fds ; FD_ZERO ( & read_fds ) ; FD_SET ( reader -> bytes_available_fd , & read_fds ) ; struct timeval timeout ; timeout . tv_sec = 0 ; timeout . tv_usec = 0 ; select ( reader -> bytes_available_fd + 1 , & read_fds , NULL , NULL , & timeout ) ; return FD_ISSET ( reader -> bytes_available_fd , & read_fds ) ; } "," = 0 ; TEMP_FAILURE_RETRY ( & timeout ) ) ",system@bt/472271b153c5dc53c28beac55480a8d8434b2d5c,CVE-2016-3839,https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c,2016-08-05T20:59Z 54,CWE-400,"CWE-400 static void fpm_child_init ( struct fpm_worker_pool_s * wp ) { fpm_globals . max_requests = wp -> config -> pm_max_requests ; if ( 0 > fpm_stdio_init_child ( wp ) || 0 > fpm_log_init_child ( wp ) || 0 > fpm_status_init_child ( wp ) || 0 > fpm_unix_init_child ( wp ) || 0 > fpm_signals_init_child ( ) || 0 > fpm_env_init_child ( wp ) || 0 > fpm_php_init_child ( wp ) ) { zlog ( ZLOG_ERROR , ""[pool%s]childfailedtoinitialize"" , wp -> config -> name ) ; exit ( FPM_EXIT_SOFTWARE ) ; } } "," config -> pm_max_requests ; fpm_globals . listening_socket = dup ( wp -> listening_socket ) ",php@php-src/69dee5c732fe982c82edb17d0dbc3e79a47748d8,CVE-2015-9253,https://github.com/php/php-src/commit/69dee5c732fe982c82edb17d0dbc3e79a47748d8,2018-02-19T19:29Z 55,CWE-119,"CWE-119 static int detect_transition_to_still ( struct twopass_rc * twopass , int frame_interval , int still_interval , double loop_decay_rate , double last_decay_rate ) { int trans_to_still = 0 ; if ( frame_interval > MIN_GF_INTERVAL && loop_decay_rate >= 0.999 && last_decay_rate < 0.9 ) { int j ; const FIRSTPASS_STATS * position = twopass -> stats_in ; FIRSTPASS_STATS tmp_next_frame ; for ( j = 0 ; j < still_interval ; ++ j ) { if ( EOF == input_stats ( twopass , & tmp_next_frame ) ) break ; if ( tmp_next_frame . pcnt_inter - tmp_next_frame . pcnt_motion < 0.999 ) break ; } reset_fpf_position ( twopass , position ) ; if ( j == still_interval ) trans_to_still = 1 ; } return trans_to_still ; } "," int detect_transition_to_still ( VP9_COMP * cpi , int frame_interval last_decay_rate ) { TWO_PASS * const twopass = & cpi -> twopass ; RATE_CONTROL * const rc = & cpi -> rc ; if ( ( frame_interval > rc -> min_gf_interval && loop_decay_rate >= int j ; for ( j j ) { const FIRSTPASS_STATS * stats = & twopass -> stats_in [ j ] ; if ( stats >= twopass -> stats_in_end ) break ; ; if ( stats -> pcnt_inter - stats -> pcnt_motion < 0.999 break ; } return j == still_interval j == still_interval ; } return ; } return 0 ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 56,CWE-416,"CWE-416 int __ext4_journal_stop ( const char * where , unsigned int line , handle_t * handle ) { struct super_block * sb ; int err ; int rc ; if ( ! ext4_handle_valid ( handle ) ) { ext4_put_nojournal ( handle ) ; return 0 ; } if ( ! handle -> h_transaction ) { err = jbd2_journal_stop ( handle ) ; return handle -> h_err ? handle -> h_err : err ; } sb = handle -> h_transaction -> t_journal -> j_private ; err = handle -> h_err ; rc = jbd2_journal_stop ( handle ) ; if ( ! err ) err = rc ; if ( err ) __ext4_std_error ( sb , where , line , err ) ; return err ; } "," 0 ; } err = handle -> h_err ; h_transaction ) { rc = jbd2_journal_stop ( ) ; return err ? err : rc ; } sb t_journal -> j_private ; rc = ",torvalds@linux/6934da9238da947628be83635e365df41064b09b,CVE-2015-8961,https://github.com/torvalds/linux/commit/6934da9238da947628be83635e365df41064b09b,2016-11-16T05:59Z 57,CWE-000,"CWE-000 static int ext4_end_io_nolock ( ext4_io_end_t * io ) { struct inode * inode = io -> inode ; loff_t offset = io -> offset ; ssize_t size = io -> size ; int ret = 0 ; ext4_debug ( ""ext4_end_io_nolock:io0x%pfrominode%lu,list->next0x%p,"" ""list->prev0x%p\\n"" , io , inode -> i_ino , io -> list . next , io -> list . prev ) ; if ( list_empty ( & io -> list ) ) return ret ; if ( io -> flag != EXT4_IO_UNWRITTEN ) return ret ; if ( offset + size <= i_size_read ( inode ) ) ret = ext4_convert_unwritten_extents ( inode , offset , size ) ; if ( ret < 0 ) { printk ( KERN_EMERG ""%s:failedtoconvertunwritten"" ""extentstowrittenextents,erroris%d"" ""ioisstilloninode%luaiodiolist\\n"" , __func__ , ret , inode -> i_ino ) ; return ret ; } io -> flag = 0 ; return ret ; } "," return ret ; ret = ext4_convert_unwritten_extents ",torvalds@linux/744692dc059845b2a3022119871846e74d4f6e11,CVE-2015-8324,https://github.com/torvalds/linux/commit/744692dc059845b2a3022119871846e74d4f6e11,2016-05-02T10:59Z 58,CWE-19,"CWE-19 STATIC int xfs_attr3_leaf_add_work ( struct xfs_buf * bp , struct xfs_attr3_icleaf_hdr * ichdr , struct xfs_da_args * args , int mapindex ) { struct xfs_attr_leafblock * leaf ; struct xfs_attr_leaf_entry * entry ; struct xfs_attr_leaf_name_local * name_loc ; struct xfs_attr_leaf_name_remote * name_rmt ; struct xfs_mount * mp ; int tmp ; int i ; trace_xfs_attr_leaf_add_work ( args ) ; leaf = bp -> b_addr ; ASSERT ( mapindex >= 0 && mapindex < XFS_ATTR_LEAF_MAPSIZE ) ; ASSERT ( args -> index >= 0 && args -> index <= ichdr -> count ) ; entry = & xfs_attr3_leaf_entryp ( leaf ) [ args -> index ] ; if ( args -> index < ichdr -> count ) { tmp = ichdr -> count - args -> index ; tmp *= sizeof ( xfs_attr_leaf_entry_t ) ; memmove ( entry + 1 , entry , tmp ) ; xfs_trans_log_buf ( args -> trans , bp , XFS_DA_LOGRANGE ( leaf , entry , tmp + sizeof ( * entry ) ) ) ; } ichdr -> count ++ ; mp = args -> trans -> t_mountp ; ASSERT ( ichdr -> freemap [ mapindex ] . base < XFS_LBSIZE ( mp ) ) ; ASSERT ( ( ichdr -> freemap [ mapindex ] . base & 0x3 ) == 0 ) ; ASSERT ( ichdr -> freemap [ mapindex ] . size >= xfs_attr_leaf_newentsize ( args -> namelen , args -> valuelen , mp -> m_sb . sb_blocksize , NULL ) ) ; ASSERT ( ichdr -> freemap [ mapindex ] . size < XFS_LBSIZE ( mp ) ) ; ASSERT ( ( ichdr -> freemap [ mapindex ] . size & 0x3 ) == 0 ) ; ichdr -> freemap [ mapindex ] . size -= xfs_attr_leaf_newentsize ( args -> namelen , args -> valuelen , mp -> m_sb . sb_blocksize , & tmp ) ; entry -> nameidx = cpu_to_be16 ( ichdr -> freemap [ mapindex ] . base + ichdr -> freemap [ mapindex ] . size ) ; entry -> hashval = cpu_to_be32 ( args -> hashval ) ; entry -> flags = tmp ? XFS_ATTR_LOCAL : 0 ; entry -> flags |= XFS_ATTR_NSP_ARGS_TO_ONDISK ( args -> flags ) ; if ( args -> op_flags & XFS_DA_OP_RENAME ) { entry -> flags |= XFS_ATTR_INCOMPLETE ; if ( ( args -> blkno2 == args -> blkno ) && ( args -> index2 <= args -> index ) ) { args -> index2 ++ ; } } xfs_trans_log_buf ( args -> trans , bp , XFS_DA_LOGRANGE ( leaf , entry , sizeof ( * entry ) ) ) ; ASSERT ( ( args -> index == 0 ) || ( be32_to_cpu ( entry -> hashval ) >= be32_to_cpu ( ( entry - 1 ) -> hashval ) ) ) ; ASSERT ( ( args -> index == ichdr -> count - 1 ) || ( be32_to_cpu ( entry -> hashval ) <= be32_to_cpu ( ( entry + 1 ) -> hashval ) ) ) ; if ( entry -> flags & XFS_ATTR_LOCAL ) { name_loc = xfs_attr3_leaf_name_local ( leaf , args -> index ) ; name_loc -> namelen = args -> namelen ; name_loc -> valuelen = cpu_to_be16 ( args -> valuelen ) ; memcpy ( ( char * ) name_loc -> nameval , args -> name , args -> namelen ) ; memcpy ( ( char * ) & name_loc -> nameval [ args -> namelen ] , args -> value , be16_to_cpu ( name_loc -> valuelen ) ) ; } else { name_rmt = xfs_attr3_leaf_name_remote ( leaf , args -> index ) ; name_rmt -> namelen = args -> namelen ; memcpy ( ( char * ) name_rmt -> name , args -> name , args -> namelen ) ; entry -> flags |= XFS_ATTR_INCOMPLETE ; name_rmt -> valuelen = 0 ; name_rmt -> valueblk = 0 ; args -> rmtblkno = 1 ; args -> rmtblkcnt = xfs_attr3_rmt_blocks ( mp , args -> valuelen ) ; } xfs_trans_log_buf ( args -> trans , bp , XFS_DA_LOGRANGE ( leaf , xfs_attr3_leaf_name ( leaf , args -> index ) , xfs_attr_leaf_entsize ( leaf , args -> index ) ) ) ; if ( be16_to_cpu ( entry -> nameidx ) < ichdr -> firstused ) ichdr -> firstused = be16_to_cpu ( entry -> nameidx ) ; ASSERT ( ichdr -> firstused >= ichdr -> count * sizeof ( xfs_attr_leaf_entry_t ) + xfs_attr3_leaf_hdr_size ( leaf ) ) ; tmp = ( ichdr -> count - 1 ) * sizeof ( xfs_attr_leaf_entry_t ) + xfs_attr3_leaf_hdr_size ( leaf ) ; for ( i = 0 ; i < XFS_ATTR_LEAF_MAPSIZE ; i ++ ) { if ( ichdr -> freemap [ i ] . base == tmp ) { ichdr -> freemap [ i ] . base += sizeof ( xfs_attr_leaf_entry_t ) ; ichdr -> freemap [ i ] . size -= sizeof ( xfs_attr_leaf_entry_t ) ; } } ichdr -> usedbytes += xfs_attr_leaf_entsize ( leaf , args -> index ) ; return 0 ; } "," valuelen ) ; args -> rmtvaluelen = args -> valuelen ; ",torvalds@linux/8275cdd0e7ac550dcce2b3ef6d2fb3b808c1ae59,CVE-2015-0274,https://github.com/torvalds/linux/commit/8275cdd0e7ac550dcce2b3ef6d2fb3b808c1ae59,2015-03-16T10:59Z 59,CWE-269,"CWE-269 struct crypto_alg * crypto_larval_lookup ( const char * name , u32 type , u32 mask ) { struct crypto_alg * alg ; if ( ! name ) return ERR_PTR ( - ENOENT ) ; mask &= ~ ( CRYPTO_ALG_LARVAL | CRYPTO_ALG_DEAD ) ; type &= mask ; alg = crypto_alg_lookup ( name , type , mask ) ; if ( ! alg ) { request_module ( ""%s"" , name ) ; if ( ! ( ( type ^ CRYPTO_ALG_NEED_FALLBACK ) & mask & CRYPTO_ALG_NEED_FALLBACK ) ) request_module ( ""%s-all"" , name ) ; alg = crypto_alg_lookup ( name , type , mask ) ; } if ( alg ) return crypto_is_larval ( alg ) ? crypto_larval_wait ( alg ) : alg ; return crypto_larval_add ( name , type , mask ) ; } "," { request_module ( ""crypto-%s"" , name ) ) request_module ( ""crypto-%s-all"" , name ) ",torvalds@linux/5d26a105b5a73e5635eae0629b42fa0a90e07b7b,CVE-2013-7421,https://github.com/torvalds/linux/commit/5d26a105b5a73e5635eae0629b42fa0a90e07b7b,2015-03-02T11:59Z 60,CWE-125,"CWE-125 static int isis_print_mt_capability_subtlv ( netdissect_options * ndo , const uint8_t * tptr , int len ) { int stlv_type , stlv_len , tmp ; while ( len > 2 ) { stlv_type = * ( tptr ++ ) ; stlv_len = * ( tptr ++ ) ; ND_PRINT ( ( ndo , ""\\n\\t%ssubTLV#%u,length:%u"" , tok2str ( isis_mt_capability_subtlv_values , ""unknown"" , stlv_type ) , stlv_type , stlv_len ) ) ; len = len - 2 ; switch ( stlv_type ) { case ISIS_SUBTLV_SPB_INSTANCE : ND_TCHECK2 ( * tptr , ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN ) ; ND_PRINT ( ( ndo , ""\\n\\tCISTRoot-ID:%08x"" , EXTRACT_32BITS ( tptr ) ) ) ; tptr = tptr + 4 ; ND_PRINT ( ( ndo , ""%08x"" , EXTRACT_32BITS ( tptr ) ) ) ; tptr = tptr + 4 ; ND_PRINT ( ( ndo , "",PathCost:%08x"" , EXTRACT_32BITS ( tptr ) ) ) ; tptr = tptr + 4 ; ND_PRINT ( ( ndo , "",Prio:%d"" , EXTRACT_16BITS ( tptr ) ) ) ; tptr = tptr + 2 ; ND_PRINT ( ( ndo , ""\\n\\tRES:%d"" , EXTRACT_16BITS ( tptr ) >> 5 ) ) ; ND_PRINT ( ( ndo , "",V:%d"" , ( EXTRACT_16BITS ( tptr ) >> 4 ) & 0x0001 ) ) ; ND_PRINT ( ( ndo , "",SPSource-ID:%d"" , ( EXTRACT_32BITS ( tptr ) & 0x000fffff ) ) ) ; tptr = tptr + 4 ; ND_PRINT ( ( ndo , "",NoofTrees:%x"" , * ( tptr ) ) ) ; tmp = * ( tptr ++ ) ; len = len - ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN ; while ( tmp ) { ND_TCHECK2 ( * tptr , ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN ) ; ND_PRINT ( ( ndo , ""\\n\\tU:%d,M:%d,A:%d,RES:%d"" , * ( tptr ) >> 7 , ( * ( tptr ) >> 6 ) & 0x01 , ( * ( tptr ) >> 5 ) & 0x01 , ( * ( tptr ) & 0x1f ) ) ) ; tptr ++ ; ND_PRINT ( ( ndo , "",ECT:%08x"" , EXTRACT_32BITS ( tptr ) ) ) ; tptr = tptr + 4 ; ND_PRINT ( ( ndo , "",BVID:%d,SPVID:%d"" , ( EXTRACT_24BITS ( tptr ) >> 12 ) & 0x000fff , EXTRACT_24BITS ( tptr ) & 0x000fff ) ) ; tptr = tptr + 3 ; len = len - ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN ; tmp -- ; } break ; case ISIS_SUBTLV_SPBM_SI : ND_TCHECK2 ( * tptr , 8 ) ; ND_PRINT ( ( ndo , ""\\n\\tBMAC:%08x"" , EXTRACT_32BITS ( tptr ) ) ) ; tptr = tptr + 4 ; ND_PRINT ( ( ndo , ""%04x"" , EXTRACT_16BITS ( tptr ) ) ) ; tptr = tptr + 2 ; ND_PRINT ( ( ndo , "",RES:%d,VID:%d"" , EXTRACT_16BITS ( tptr ) >> 12 , ( EXTRACT_16BITS ( tptr ) ) & 0x0fff ) ) ; tptr = tptr + 2 ; len = len - 8 ; stlv_len = stlv_len - 8 ; while ( stlv_len >= 4 ) { ND_TCHECK2 ( * tptr , 4 ) ; ND_PRINT ( ( ndo , ""\\n\\tT:%d,R:%d,RES:%d,ISID:%d"" , ( EXTRACT_32BITS ( tptr ) >> 31 ) , ( EXTRACT_32BITS ( tptr ) >> 30 ) & 0x01 , ( EXTRACT_32BITS ( tptr ) >> 24 ) & 0x03f , ( EXTRACT_32BITS ( tptr ) ) & 0x0ffffff ) ) ; tptr = tptr + 4 ; len = len - 4 ; stlv_len = stlv_len - 4 ; } break ; default : break ; } } return 0 ; trunc : ND_PRINT ( ( ndo , ""\\n\\t\\t"" ) ) ; ND_PRINT ( ( ndo , ""%s"" , tstr ) ) ; return ( 1 ) ; } "," 2 ) { ND_TCHECK2 ( * tptr , 2 ) ; len - 2 ; if ( len < stlv_len ) goto trunc ; ND_TCHECK2 ( * ( tptr ) , stlv_len ) case ISIS_SUBTLV_SPB_INSTANCE : if ( stlv_len < ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN ) goto trunc ; ND_PRINT ( - ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN ; stlv_len = stlv_len - ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN ; tmp ) { if ( stlv_len < ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN ) goto trunc ; ND_PRINT ( len = len - ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN ; stlv_len = stlv_len case ISIS_SUBTLV_SPBM_SI : if ( stlv_len < 8 ) goto trunc ; ND_PRINT ( break ; } tptr += stlv_len ; len -= stlv_len ; ",the-tcpdump-group@tcpdump/b20e1639dbac84b3fcb393858521c13ad47a9d70,CVE-2017-13026,https://github.com/the-tcpdump-group/tcpdump/commit/b20e1639dbac84b3fcb393858521c13ad47a9d70,2017-09-14T06:29Z 61,CWE-000,"CWE-000 static void dispatch_cmd ( conn c ) { int r , i , timeout = - 1 ; size_t z ; unsigned int count ; job j ; unsigned char type ; char * size_buf , * delay_buf , * ttr_buf , * pri_buf , * end_buf , * name ; unsigned int pri , body_size ; usec delay , ttr ; uint64_t id ; tube t = NULL ; c -> cmd [ c -> cmd_len - 2 ] = '\\0' ; if ( strlen ( c -> cmd ) != c -> cmd_len - 2 ) { return reply_msg ( c , MSG_BAD_FORMAT ) ; } type = which_cmd ( c ) ; dprintf ( ""got%scommand:\\""%s\\""\\n"" , op_names [ ( int ) type ] , c -> cmd ) ; switch ( type ) { case OP_PUT : r = read_pri ( & pri , c -> cmd + 4 , & delay_buf ) ; if ( r ) return reply_msg ( c , MSG_BAD_FORMAT ) ; r = read_delay ( & delay , delay_buf , & ttr_buf ) ; if ( r ) return reply_msg ( c , MSG_BAD_FORMAT ) ; r = read_ttr ( & ttr , ttr_buf , & size_buf ) ; if ( r ) return reply_msg ( c , MSG_BAD_FORMAT ) ; errno = 0 ; body_size = strtoul ( size_buf , & end_buf , 10 ) ; if ( errno ) return reply_msg ( c , MSG_BAD_FORMAT ) ; if ( body_size > job_data_size_limit ) { return reply_msg ( c , MSG_JOB_TOO_BIG ) ; } if ( end_buf [ 0 ] != '\\0' ) return reply_msg ( c , MSG_BAD_FORMAT ) ; conn_set_producer ( c ) ; c -> in_job = make_job ( pri , delay , ttr ? : 1 , body_size + 2 , c -> use ) ; if ( ! c -> in_job ) { twarnx ( ""servererror:"" MSG_OUT_OF_MEMORY ) ; return skip ( c , body_size + 2 , MSG_OUT_OF_MEMORY ) ; } fill_extra_data ( c ) ; maybe_enqueue_incoming_job ( c ) ; break ; case OP_PEEK_READY : if ( c -> cmd_len != CMD_PEEK_READY_LEN + 2 ) { return reply_msg ( c , MSG_BAD_FORMAT ) ; } op_ct [ type ] ++ ; j = job_copy ( pq_peek ( & c -> use -> ready ) ) ; if ( ! j ) return reply ( c , MSG_NOTFOUND , MSG_NOTFOUND_LEN , STATE_SENDWORD ) ; reply_job ( c , j , MSG_FOUND ) ; break ; case OP_PEEK_DELAYED : if ( c -> cmd_len != CMD_PEEK_DELAYED_LEN + 2 ) { return reply_msg ( c , MSG_BAD_FORMAT ) ; } op_ct [ type ] ++ ; j = job_copy ( pq_peek ( & c -> use -> delay ) ) ; if ( ! j ) return reply ( c , MSG_NOTFOUND , MSG_NOTFOUND_LEN , STATE_SENDWORD ) ; reply_job ( c , j , MSG_FOUND ) ; break ; case OP_PEEK_BURIED : if ( c -> cmd_len != CMD_PEEK_BURIED_LEN + 2 ) { return reply_msg ( c , MSG_BAD_FORMAT ) ; } op_ct [ type ] ++ ; j = job_copy ( buried_job_p ( c -> use ) ? j = c -> use -> buried . next : NULL ) ; if ( ! j ) return reply ( c , MSG_NOTFOUND , MSG_NOTFOUND_LEN , STATE_SENDWORD ) ; reply_job ( c , j , MSG_FOUND ) ; break ; case OP_PEEKJOB : errno = 0 ; id = strtoull ( c -> cmd + CMD_PEEKJOB_LEN , & end_buf , 10 ) ; if ( errno ) return reply_msg ( c , MSG_BAD_FORMAT ) ; op_ct [ type ] ++ ; j = job_copy ( peek_job ( id ) ) ; if ( ! j ) return reply ( c , MSG_NOTFOUND , MSG_NOTFOUND_LEN , STATE_SENDWORD ) ; reply_job ( c , j , MSG_FOUND ) ; break ; case OP_RESERVE_TIMEOUT : errno = 0 ; timeout = strtol ( c -> cmd + CMD_RESERVE_TIMEOUT_LEN , & end_buf , 10 ) ; if ( errno ) return reply_msg ( c , MSG_BAD_FORMAT ) ; case OP_RESERVE : if ( type == OP_RESERVE && c -> cmd_len != CMD_RESERVE_LEN + 2 ) { return reply_msg ( c , MSG_BAD_FORMAT ) ; } op_ct [ type ] ++ ; conn_set_worker ( c ) ; if ( conn_has_close_deadline ( c ) && ! conn_ready ( c ) ) { return reply_msg ( c , MSG_DEADLINE_SOON ) ; } wait_for_job ( c , timeout ) ; process_queue ( ) ; break ; case OP_DELETE : errno = 0 ; id = strtoull ( c -> cmd + CMD_DELETE_LEN , & end_buf , 10 ) ; if ( errno ) return reply_msg ( c , MSG_BAD_FORMAT ) ; op_ct [ type ] ++ ; j = job_find ( id ) ; j = remove_reserved_job ( c , j ) ? : remove_ready_job ( j ) ? : remove_buried_job ( j ) ; if ( ! j ) return reply ( c , MSG_NOTFOUND , MSG_NOTFOUND_LEN , STATE_SENDWORD ) ; j -> state = JOB_STATE_INVALID ; r = binlog_write_job ( j ) ; job_free ( j ) ; if ( ! r ) return reply_serr ( c , MSG_INTERNAL_ERROR ) ; reply ( c , MSG_DELETED , MSG_DELETED_LEN , STATE_SENDWORD ) ; break ; case OP_RELEASE : errno = 0 ; id = strtoull ( c -> cmd + CMD_RELEASE_LEN , & pri_buf , 10 ) ; if ( errno ) return reply_msg ( c , MSG_BAD_FORMAT ) ; r = read_pri ( & pri , pri_buf , & delay_buf ) ; if ( r ) return reply_msg ( c , MSG_BAD_FORMAT ) ; r = read_delay ( & delay , delay_buf , NULL ) ; if ( r ) return reply_msg ( c , MSG_BAD_FORMAT ) ; op_ct [ type ] ++ ; j = remove_reserved_job ( c , job_find ( id ) ) ; if ( ! j ) return reply ( c , MSG_NOTFOUND , MSG_NOTFOUND_LEN , STATE_SENDWORD ) ; if ( delay ) { z = binlog_reserve_space_update ( j ) ; if ( ! z ) return reply_serr ( c , MSG_OUT_OF_MEMORY ) ; j -> reserved_binlog_space += z ; } j -> pri = pri ; j -> delay = delay ; j -> release_ct ++ ; r = enqueue_job ( j , delay , ! ! delay ) ; if ( r < 0 ) return reply_serr ( c , MSG_INTERNAL_ERROR ) ; if ( r == 1 ) { return reply ( c , MSG_RELEASED , MSG_RELEASED_LEN , STATE_SENDWORD ) ; } bury_job ( j , 0 ) ; reply ( c , MSG_BURIED , MSG_BURIED_LEN , STATE_SENDWORD ) ; break ; case OP_BURY : errno = 0 ; id = strtoull ( c -> cmd + CMD_BURY_LEN , & pri_buf , 10 ) ; if ( errno ) return reply_msg ( c , MSG_BAD_FORMAT ) ; r = read_pri ( & pri , pri_buf , NULL ) ; if ( r ) return reply_msg ( c , MSG_BAD_FORMAT ) ; op_ct [ type ] ++ ; j = remove_reserved_job ( c , job_find ( id ) ) ; if ( ! j ) return reply ( c , MSG_NOTFOUND , MSG_NOTFOUND_LEN , STATE_SENDWORD ) ; j -> pri = pri ; r = bury_job ( j , 1 ) ; if ( ! r ) return reply_serr ( c , MSG_INTERNAL_ERROR ) ; reply ( c , MSG_BURIED , MSG_BURIED_LEN , STATE_SENDWORD ) ; break ; case OP_KICK : errno = 0 ; count = strtoul ( c -> cmd + CMD_KICK_LEN , & end_buf , 10 ) ; if ( end_buf == c -> cmd + CMD_KICK_LEN ) { return reply_msg ( c , MSG_BAD_FORMAT ) ; } if ( errno ) return reply_msg ( c , MSG_BAD_FORMAT ) ; op_ct [ type ] ++ ; i = kick_jobs ( c -> use , count ) ; return reply_line ( c , STATE_SENDWORD , ""KICKED%u\\r\\n"" , i ) ; case OP_TOUCH : errno = 0 ; id = strtoull ( c -> cmd + CMD_TOUCH_LEN , & end_buf , 10 ) ; if ( errno ) return twarn ( ""strtoull"" ) , reply_msg ( c , MSG_BAD_FORMAT ) ; op_ct [ type ] ++ ; j = touch_job ( c , job_find ( id ) ) ; if ( j ) { reply ( c , MSG_TOUCHED , MSG_TOUCHED_LEN , STATE_SENDWORD ) ; } else { return reply ( c , MSG_NOTFOUND , MSG_NOTFOUND_LEN , STATE_SENDWORD ) ; } break ; case OP_STATS : if ( c -> cmd_len != CMD_STATS_LEN + 2 ) { return reply_msg ( c , MSG_BAD_FORMAT ) ; } op_ct [ type ] ++ ; do_stats ( c , fmt_stats , NULL ) ; break ; case OP_JOBSTATS : errno = 0 ; id = strtoull ( c -> cmd + CMD_JOBSTATS_LEN , & end_buf , 10 ) ; if ( errno ) return reply_msg ( c , MSG_BAD_FORMAT ) ; op_ct [ type ] ++ ; j = peek_job ( id ) ; if ( ! j ) return reply ( c , MSG_NOTFOUND , MSG_NOTFOUND_LEN , STATE_SENDWORD ) ; if ( ! j -> tube ) return reply_serr ( c , MSG_INTERNAL_ERROR ) ; do_stats ( c , ( fmt_fn ) fmt_job_stats , j ) ; break ; case OP_STATS_TUBE : name = c -> cmd + CMD_STATS_TUBE_LEN ; if ( ! name_is_ok ( name , 200 ) ) return reply_msg ( c , MSG_BAD_FORMAT ) ; op_ct [ type ] ++ ; t = tube_find ( name ) ; if ( ! t ) return reply_msg ( c , MSG_NOTFOUND ) ; do_stats ( c , ( fmt_fn ) fmt_stats_tube , t ) ; t = NULL ; break ; case OP_LIST_TUBES : if ( c -> cmd_len != CMD_LIST_TUBES_LEN + 2 ) { return reply_msg ( c , MSG_BAD_FORMAT ) ; } op_ct [ type ] ++ ; do_list_tubes ( c , & tubes ) ; break ; case OP_LIST_TUBE_USED : if ( c -> cmd_len != CMD_LIST_TUBE_USED_LEN + 2 ) { return reply_msg ( c , MSG_BAD_FORMAT ) ; } op_ct [ type ] ++ ; reply_line ( c , STATE_SENDWORD , ""USING%s\\r\\n"" , c -> use -> name ) ; break ; case OP_LIST_TUBES_WATCHED : if ( c -> cmd_len != CMD_LIST_TUBES_WATCHED_LEN + 2 ) { return reply_msg ( c , MSG_BAD_FORMAT ) ; } op_ct [ type ] ++ ; do_list_tubes ( c , & c -> watch ) ; break ; case OP_USE : name = c -> cmd + CMD_USE_LEN ; if ( ! name_is_ok ( name , 200 ) ) return reply_msg ( c , MSG_BAD_FORMAT ) ; op_ct [ type ] ++ ; TUBE_ASSIGN ( t , tube_find_or_make ( name ) ) ; if ( ! t ) return reply_serr ( c , MSG_OUT_OF_MEMORY ) ; c -> use -> using_ct -- ; TUBE_ASSIGN ( c -> use , t ) ; TUBE_ASSIGN ( t , NULL ) ; c -> use -> using_ct ++ ; reply_line ( c , STATE_SENDWORD , ""USING%s\\r\\n"" , c -> use -> name ) ; break ; case OP_WATCH : name = c -> cmd + CMD_WATCH_LEN ; if ( ! name_is_ok ( name , 200 ) ) return reply_msg ( c , MSG_BAD_FORMAT ) ; op_ct [ type ] ++ ; TUBE_ASSIGN ( t , tube_find_or_make ( name ) ) ; if ( ! t ) return reply_serr ( c , MSG_OUT_OF_MEMORY ) ; r = 1 ; if ( ! ms_contains ( & c -> watch , t ) ) r = ms_append ( & c -> watch , t ) ; TUBE_ASSIGN ( t , NULL ) ; if ( ! r ) return reply_serr ( c , MSG_OUT_OF_MEMORY ) ; reply_line ( c , STATE_SENDWORD , ""WATCHING%d\\r\\n"" , c -> watch . used ) ; break ; case OP_IGNORE : name = c -> cmd + CMD_IGNORE_LEN ; if ( ! name_is_ok ( name , 200 ) ) return reply_msg ( c , MSG_BAD_FORMAT ) ; op_ct [ type ] ++ ; t = NULL ; for ( i = 0 ; i < c -> watch . used ; i ++ ) { t = c -> watch . items [ i ] ; if ( strncmp ( t -> name , name , MAX_TUBE_NAME_LEN ) == 0 ) break ; t = NULL ; } if ( t && c -> watch . used < 2 ) return reply_msg ( c , MSG_NOT_IGNORED ) ; if ( t ) ms_remove ( & c -> watch , t ) ; t = NULL ; reply_line ( c , STATE_SENDWORD , ""WATCHING%d\\r\\n"" , c -> watch . used ) ; break ; case OP_QUIT : conn_close ( c ) ; break ; case OP_PAUSE_TUBE : op_ct [ type ] ++ ; r = read_tube_name ( & name , c -> cmd + CMD_PAUSE_TUBE_LEN , & delay_buf ) ; if ( r ) return reply_msg ( c , MSG_BAD_FORMAT ) ; r = read_delay ( & delay , delay_buf , NULL ) ; if ( r ) return reply_msg ( c , MSG_BAD_FORMAT ) ; * delay_buf = '\\0' ; t = tube_find ( name ) ; if ( ! t ) return reply_msg ( c , MSG_NOTFOUND ) ; t -> deadline_at = now_usec ( ) + delay ; t -> pause = delay ; t -> stat . pause_ct ++ ; set_main_delay_timeout ( ) ; reply_line ( c , STATE_SENDWORD , ""PAUSED\\r\\n"" ) ; break ; default : return reply_msg ( c , MSG_UNKNOWN_COMMAND ) ; } } "," ) { return skip ( c , body_size + 2 , MSG_JOB_TOO_BIG ) ",kr@beanstalkd/2e8e8c6387ecdf5923dfc4d7718d18eba1b0873d,CVE-2010-2060,https://github.com/kr/beanstalkd/commit/2e8e8c6387ecdf5923dfc4d7718d18eba1b0873d,2010-06-08T00:30Z 62,CWE-200,"CWE-200 long dgnc_mgmt_ioctl ( struct file * file , unsigned int cmd , unsigned long arg ) { unsigned long flags ; void __user * uarg = ( void __user * ) arg ; switch ( cmd ) { case DIGI_GETDD : { struct digi_dinfo ddi ; spin_lock_irqsave ( & dgnc_global_lock , flags ) ; ddi . dinfo_nboards = dgnc_NumBoards ; sprintf ( ddi . dinfo_version , ""%s"" , DG_PART ) ; spin_unlock_irqrestore ( & dgnc_global_lock , flags ) ; if ( copy_to_user ( uarg , & ddi , sizeof ( ddi ) ) ) return - EFAULT ; break ; } case DIGI_GETBD : { int brd ; struct digi_info di ; if ( copy_from_user ( & brd , uarg , sizeof ( int ) ) ) return - EFAULT ; if ( brd < 0 || brd >= dgnc_NumBoards ) return - ENODEV ; memset ( & di , 0 , sizeof ( di ) ) ; di . info_bdnum = brd ; spin_lock_irqsave ( & dgnc_Board [ brd ] -> bd_lock , flags ) ; di . info_bdtype = dgnc_Board [ brd ] -> dpatype ; di . info_bdstate = dgnc_Board [ brd ] -> dpastatus ; di . info_ioport = 0 ; di . info_physaddr = ( ulong ) dgnc_Board [ brd ] -> membase ; di . info_physsize = ( ulong ) dgnc_Board [ brd ] -> membase - dgnc_Board [ brd ] -> membase_end ; if ( dgnc_Board [ brd ] -> state != BOARD_FAILED ) di . info_nports = dgnc_Board [ brd ] -> nasync ; else di . info_nports = 0 ; spin_unlock_irqrestore ( & dgnc_Board [ brd ] -> bd_lock , flags ) ; if ( copy_to_user ( uarg , & di , sizeof ( di ) ) ) return - EFAULT ; break ; } case DIGI_GET_NI_INFO : { struct channel_t * ch ; struct ni_info ni ; unsigned char mstat = 0 ; uint board = 0 ; uint channel = 0 ; if ( copy_from_user ( & ni , uarg , sizeof ( ni ) ) ) return - EFAULT ; board = ni . board ; channel = ni . channel ; if ( board >= dgnc_NumBoards ) return - ENODEV ; if ( channel >= dgnc_Board [ board ] -> nasync ) return - ENODEV ; ch = dgnc_Board [ board ] -> channels [ channel ] ; if ( ! ch || ch -> magic != DGNC_CHANNEL_MAGIC ) return - ENODEV ; memset ( & ni , 0 , sizeof ( ni ) ) ; ni . board = board ; ni . channel = channel ; spin_lock_irqsave ( & ch -> ch_lock , flags ) ; mstat = ( ch -> ch_mostat | ch -> ch_mistat ) ; if ( mstat & UART_MCR_DTR ) { ni . mstat |= TIOCM_DTR ; ni . dtr = TIOCM_DTR ; } if ( mstat & UART_MCR_RTS ) { ni . mstat |= TIOCM_RTS ; ni . rts = TIOCM_RTS ; } if ( mstat & UART_MSR_CTS ) { ni . mstat |= TIOCM_CTS ; ni . cts = TIOCM_CTS ; } if ( mstat & UART_MSR_RI ) { ni . mstat |= TIOCM_RI ; ni . ri = TIOCM_RI ; } if ( mstat & UART_MSR_DCD ) { ni . mstat |= TIOCM_CD ; ni . dcd = TIOCM_CD ; } if ( mstat & UART_MSR_DSR ) ni . mstat |= TIOCM_DSR ; ni . iflag = ch -> ch_c_iflag ; ni . oflag = ch -> ch_c_oflag ; ni . cflag = ch -> ch_c_cflag ; ni . lflag = ch -> ch_c_lflag ; if ( ch -> ch_digi . digi_flags & CTSPACE || ch -> ch_c_cflag & CRTSCTS ) ni . hflow = 1 ; else ni . hflow = 0 ; if ( ( ch -> ch_flags & CH_STOPI ) || ( ch -> ch_flags & CH_FORCED_STOPI ) ) ni . recv_stopped = 1 ; else ni . recv_stopped = 0 ; if ( ( ch -> ch_flags & CH_STOP ) || ( ch -> ch_flags & CH_FORCED_STOP ) ) ni . xmit_stopped = 1 ; else ni . xmit_stopped = 0 ; ni . curtx = ch -> ch_txcount ; ni . currx = ch -> ch_rxcount ; ni . baud = ch -> ch_old_baud ; spin_unlock_irqrestore ( & ch -> ch_lock , flags ) ; if ( copy_to_user ( uarg , & ni , sizeof ( ni ) ) ) return - EFAULT ; break ; } } return 0 ; } "," flags ) ; memset ( & ddi , 0 , sizeof ( ddi ) ) ; ",torvalds@linux/4b6184336ebb5c8dc1eae7f7ab46ee608a748b05,CVE-2015-7885,https://github.com/torvalds/linux/commit/4b6184336ebb5c8dc1eae7f7ab46ee608a748b05,2015-12-28T11:59Z 63,CWE-125,"CWE-125 static int mp_capable_print ( netdissect_options * ndo , const u_char * opt , u_int opt_len , u_char flags ) { const struct mp_capable * mpc = ( const struct mp_capable * ) opt ; if ( ! ( opt_len == 12 && flags & TH_SYN ) && ! ( opt_len == 20 && ( flags & ( TH_SYN | TH_ACK ) ) == TH_ACK ) ) return 0 ; if ( MP_CAPABLE_OPT_VERSION ( mpc -> sub_ver ) != 0 ) { ND_PRINT ( ( ndo , ""UnknownVersion(%d)"" , MP_CAPABLE_OPT_VERSION ( mpc -> sub_ver ) ) ) ; return 1 ; } if ( mpc -> flags & MP_CAPABLE_C ) ND_PRINT ( ( ndo , ""csum"" ) ) ; ND_PRINT ( ( ndo , ""{0x%"" PRIx64 , EXTRACT_64BITS ( mpc -> sender_key ) ) ) ; if ( opt_len == 20 ) ND_PRINT ( ( ndo , "",0x%"" PRIx64 , EXTRACT_64BITS ( mpc -> receiver_key ) ) ) ; ND_PRINT ( ( ndo , ""}"" ) ) ; return 1 ; } "," == 12 && ( flags & TH_SYN ) ",the-tcpdump-group@tcpdump/4c3aee4bb0294c232d56b6d34e9eeb74f630fe8c,CVE-2017-13040,https://github.com/the-tcpdump-group/tcpdump/commit/4c3aee4bb0294c232d56b6d34e9eeb74f630fe8c,2017-09-14T06:29Z 64,CWE-264,"CWE-264 static int attach_child_main ( void * data ) { struct attach_clone_payload * payload = ( struct attach_clone_payload * ) data ; int ipc_socket = payload -> ipc_socket ; int procfd = payload -> procfd ; lxc_attach_options_t * options = payload -> options ; struct lxc_proc_context_info * init_ctx = payload -> init_ctx ; # if HAVE_SYS_PERSONALITY_H long new_personality ; # endif int ret ; int status ; int expected ; long flags ; int fd ; uid_t new_uid ; gid_t new_gid ; expected = 0 ; status = - 1 ; ret = lxc_read_nointr_expect ( ipc_socket , & status , sizeof ( status ) , & expected ) ; if ( ret <= 0 ) { ERROR ( ""errorusingIPCtoreceivenotificationfrominitialprocess(0)"" ) ; shutdown ( ipc_socket , SHUT_RDWR ) ; rexit ( - 1 ) ; } if ( ! ( options -> namespaces & CLONE_NEWNS ) && ( options -> attach_flags & LXC_ATTACH_REMOUNT_PROC_SYS ) ) { ret = lxc_attach_remount_sys_proc ( ) ; if ( ret < 0 ) { shutdown ( ipc_socket , SHUT_RDWR ) ; rexit ( - 1 ) ; } } # if HAVE_SYS_PERSONALITY_H if ( options -> personality < 0 ) new_personality = init_ctx -> personality ; else new_personality = options -> personality ; if ( options -> attach_flags & LXC_ATTACH_SET_PERSONALITY ) { ret = personality ( new_personality ) ; if ( ret < 0 ) { SYSERROR ( ""couldnotensurecorrectarchitecture"" ) ; shutdown ( ipc_socket , SHUT_RDWR ) ; rexit ( - 1 ) ; } } # endif if ( options -> attach_flags & LXC_ATTACH_DROP_CAPABILITIES ) { ret = lxc_attach_drop_privs ( init_ctx ) ; if ( ret < 0 ) { ERROR ( ""couldnotdropprivileges"" ) ; shutdown ( ipc_socket , SHUT_RDWR ) ; rexit ( - 1 ) ; } } ret = lxc_attach_set_environment ( options -> env_policy , options -> extra_env_vars , options -> extra_keep_env ) ; if ( ret < 0 ) { ERROR ( ""couldnotsetinitialenvironmentforattachedprocess"" ) ; shutdown ( ipc_socket , SHUT_RDWR ) ; rexit ( - 1 ) ; } new_uid = 0 ; new_gid = 0 ; if ( options -> namespaces & CLONE_NEWUSER ) lxc_attach_get_init_uidgid ( & new_uid , & new_gid ) ; if ( options -> uid != ( uid_t ) - 1 ) new_uid = options -> uid ; if ( options -> gid != ( gid_t ) - 1 ) new_gid = options -> gid ; if ( options -> stdin_fd && isatty ( options -> stdin_fd ) ) { if ( setsid ( ) < 0 ) { SYSERROR ( ""unabletosetsid"" ) ; shutdown ( ipc_socket , SHUT_RDWR ) ; rexit ( - 1 ) ; } if ( ioctl ( options -> stdin_fd , TIOCSCTTY , ( char * ) NULL ) < 0 ) { SYSERROR ( ""unabletoTIOCSTTY"" ) ; shutdown ( ipc_socket , SHUT_RDWR ) ; rexit ( - 1 ) ; } } if ( ( new_gid != 0 || options -> namespaces & CLONE_NEWUSER ) ) { if ( setgid ( new_gid ) || setgroups ( 0 , NULL ) ) { SYSERROR ( ""switchingtocontainergid"" ) ; shutdown ( ipc_socket , SHUT_RDWR ) ; rexit ( - 1 ) ; } } if ( ( new_uid != 0 || options -> namespaces & CLONE_NEWUSER ) && setuid ( new_uid ) ) { SYSERROR ( ""switchingtocontaineruid"" ) ; shutdown ( ipc_socket , SHUT_RDWR ) ; rexit ( - 1 ) ; } status = 1 ; ret = lxc_write_nointr ( ipc_socket , & status , sizeof ( status ) ) ; if ( ret != sizeof ( status ) ) { ERROR ( ""errorusingIPCtonotifyinitialprocessforinitialization(1)"" ) ; shutdown ( ipc_socket , SHUT_RDWR ) ; rexit ( - 1 ) ; } expected = 2 ; status = - 1 ; ret = lxc_read_nointr_expect ( ipc_socket , & status , sizeof ( status ) , & expected ) ; if ( ret <= 0 ) { ERROR ( ""errorusingIPCtoreceivefinalnotificationfrominitialprocess(2)"" ) ; shutdown ( ipc_socket , SHUT_RDWR ) ; rexit ( - 1 ) ; } shutdown ( ipc_socket , SHUT_RDWR ) ; close ( ipc_socket ) ; if ( ( init_ctx -> container && init_ctx -> container -> lxc_conf && init_ctx -> container -> lxc_conf -> no_new_privs ) || ( options -> attach_flags & LXC_ATTACH_NO_NEW_PRIVS ) ) { if ( prctl ( PR_SET_NO_NEW_PRIVS , 1 , 0 , 0 , 0 ) < 0 ) { SYSERROR ( ""PR_SET_NO_NEW_PRIVScouldnotbeset."" ""Processcanuseexecve()gainable"" ""privileges."" ) ; rexit ( - 1 ) ; } INFO ( ""PR_SET_NO_NEW_PRIVSisset.Processcannotuseexecve()"" ""gainableprivileges."" ) ; } if ( ( options -> namespaces & CLONE_NEWNS ) && ( options -> attach_flags & LXC_ATTACH_LSM ) && init_ctx -> lsm_label ) { int on_exec ; on_exec = options -> attach_flags & LXC_ATTACH_LSM_EXEC ? 1 : 0 ; if ( lsm_set_label_at ( procfd , on_exec , init_ctx -> lsm_label ) < 0 ) { rexit ( - 1 ) ; } } if ( init_ctx -> container && init_ctx -> container -> lxc_conf && init_ctx -> container -> lxc_conf -> seccomp && ( lxc_seccomp_load ( init_ctx -> container -> lxc_conf ) != 0 ) ) { ERROR ( ""Loadingseccomppolicy"" ) ; rexit ( - 1 ) ; } lxc_proc_put_context_info ( init_ctx ) ; if ( options -> stdin_fd >= 0 && options -> stdin_fd != 0 ) dup2 ( options -> stdin_fd , 0 ) ; if ( options -> stdout_fd >= 0 && options -> stdout_fd != 1 ) dup2 ( options -> stdout_fd , 1 ) ; if ( options -> stderr_fd >= 0 && options -> stderr_fd != 2 ) dup2 ( options -> stderr_fd , 2 ) ; if ( options -> stdin_fd > 2 ) close ( options -> stdin_fd ) ; if ( options -> stdout_fd > 2 ) close ( options -> stdout_fd ) ; if ( options -> stderr_fd > 2 ) close ( options -> stderr_fd ) ; for ( fd = 0 ; fd <= 2 ; fd ++ ) { flags = fcntl ( fd , F_GETFL ) ; if ( flags < 0 ) continue ; if ( flags & FD_CLOEXEC ) if ( fcntl ( fd , F_SETFL , flags & ~ FD_CLOEXEC ) < 0 ) SYSERROR ( ""UnabletoclearCLOEXECfromfd"" ) ; } close ( procfd ) ; rexit ( payload -> exec_function ( payload -> exec_payload ) ) ; } "," -> ipc_socket ; lxc_attach_options_t * options int fd ; int lsm_labelfd ; { ERROR ( ""ErrorusingIPCtoreceivenotificationfrominitialprocess(0):%s."" , strerror ( errno ) ) ; shutdown { ERROR ( ""ErrorusingIPCtonotifyinitialprocessforinitialization(1):%s."" , strerror ( errno ) ) ; shutdown { ERROR ( ""ErrorusingIPCtoreceivemessagefrominitialprocess"" ""thatitisdonepre-initializing(2):%s"" , strerror ( errno ) ) ; shutdown ( ipc_socket , SHUT_RDWR ) ; rexit ( - 1 ) ; } if ( ( ""privileges."" ) ; shutdown ( ipc_socket , SHUT_RDWR ) ; ( ""PR_SET_NO_NEW_PRIVSisset.Processcannotuseexecve()"" ""gainableprivileges."" ) ; } status = 3 ; ret = lxc_write_nointr ( ipc_socket , & status , sizeof ( status ) ) ; if ( ret <= 0 ) { ERROR ( ""ErrorusingIPCtotellparenttosetupLSMlabels(3):%s."" , strerror ( errno ) ) ; shutdown ( ipc_socket , SHUT_RDWR ) ; rexit ( - 1 int on_exec ; ret = lxc_abstract_unix_recv_fd ( ipc_socket , & lsm_labelfd , NULL , 0 ) ; if ( ret <= 0 ) { ERROR ( ""ErrorusingIPCforparenttotellusLSMlabelfd(4):%s."" , strerror ( errno ) ) ; shutdown ( ipc_socket , SHUT_RDWR ) ; rexit ( - 1 ) ; } ( lsm_set_label_at ( lsm_labelfd , on_exec , 0 ) { SYSERROR ( ""FailedtosetLSMlabel."" ) ; shutdown ( ipc_socket , SHUT_RDWR ) ; close ( lsm_labelfd ) ; rexit ( - 1 ) ; } close ( lsm_labelfd ) ; } if ( ""Loadingseccomppolicy"" ) ; shutdown ( ipc_socket , SHUT_RDWR ) ; rexit ( - 1 ) ; } shutdown ( ipc_socket , SHUT_RDWR ) ; close ( ipc_socket ) ; lxc_proc_put_context_info ( init_ctx ) ; } rexit ( payload ",lxc@lxc/81f466d05f2a89cb4f122ef7f593ff3f279b165c,CVE-2016-8649,https://github.com/lxc/lxc/commit/81f466d05f2a89cb4f122ef7f593ff3f279b165c,2017-05-01T06:59Z 65,CWE-125,"CWE-125 static int ng_pkt ( git_pkt * * out , const char * line , size_t len ) { git_pkt_ng * pkt ; const char * ptr ; size_t alloclen ; pkt = git__malloc ( sizeof ( * pkt ) ) ; GITERR_CHECK_ALLOC ( pkt ) ; pkt -> ref = NULL ; pkt -> type = GIT_PKT_NG ; line += 3 ; if ( ! ( ptr = strchr ( line , '' ) ) ) goto out_err ; len = ptr - line ; GITERR_CHECK_ALLOC_ADD ( & alloclen , len , 1 ) ; pkt -> ref = git__malloc ( alloclen ) ; GITERR_CHECK_ALLOC ( pkt -> ref ) ; memcpy ( pkt -> ref , line , len ) ; pkt -> ref [ len ] = '\\0' ; line = ptr + 1 ; if ( ! ( ptr = strchr ( line , '\\n' ) ) ) goto out_err ; len = ptr - line ; GITERR_CHECK_ALLOC_ADD ( & alloclen , len , 1 ) ; pkt -> msg = git__malloc ( alloclen ) ; GITERR_CHECK_ALLOC ( pkt -> msg ) ; memcpy ( pkt -> msg , line , len ) ; pkt -> msg [ len ] = '\\0' ; * out = ( git_pkt * ) pkt ; return 0 ; out_err : giterr_set ( GITERR_NET , ""invalidpacketline"" ) ; git__free ( pkt -> ref ) ; git__free ( pkt ) ; return - 1 ; } "," = GIT_PKT_NG ; if ( len < 3 ) goto out_err ; += 3 ; len -= 3 ; ( ptr = memchr ( line , line , '' , len = '\\0' ; if ( len < 1 ) goto out_err ; + 1 ; len -= 1 ; ( ptr = memchr ( line , line , '\\n' , len ",libgit2@libgit2/1f9a8510e1d2f20ed7334eeeddb92c4dd8e7c649,CVE-2018-15501,https://github.com/libgit2/libgit2/commit/1f9a8510e1d2f20ed7334eeeddb92c4dd8e7c649,2018-08-18T02:29Z 66,CWE-119,"CWE-119 static OPJ_BOOL bmp_read_info_header ( FILE * IN , OPJ_BITMAPINFOHEADER * header ) { memset ( header , 0 , sizeof ( * header ) ) ; header -> biSize = ( OPJ_UINT32 ) getc ( IN ) ; header -> biSize |= ( OPJ_UINT32 ) getc ( IN ) << 8 ; header -> biSize |= ( OPJ_UINT32 ) getc ( IN ) << 16 ; header -> biSize |= ( OPJ_UINT32 ) getc ( IN ) << 24 ; switch ( header -> biSize ) { case 12U : case 40U : case 52U : case 56U : case 108U : case 124U : break ; default : fprintf ( stderr , ""Error,unknownBMPheadersize%d\\n"" , header -> biSize ) ; return OPJ_FALSE ; } header -> biWidth = ( OPJ_UINT32 ) getc ( IN ) ; header -> biWidth |= ( OPJ_UINT32 ) getc ( IN ) << 8 ; header -> biWidth |= ( OPJ_UINT32 ) getc ( IN ) << 16 ; header -> biWidth |= ( OPJ_UINT32 ) getc ( IN ) << 24 ; header -> biHeight = ( OPJ_UINT32 ) getc ( IN ) ; header -> biHeight |= ( OPJ_UINT32 ) getc ( IN ) << 8 ; header -> biHeight |= ( OPJ_UINT32 ) getc ( IN ) << 16 ; header -> biHeight |= ( OPJ_UINT32 ) getc ( IN ) << 24 ; header -> biPlanes = ( OPJ_UINT16 ) getc ( IN ) ; header -> biPlanes |= ( OPJ_UINT16 ) ( ( OPJ_UINT32 ) getc ( IN ) << 8 ) ; header -> biBitCount = ( OPJ_UINT16 ) getc ( IN ) ; header -> biBitCount |= ( OPJ_UINT16 ) ( ( OPJ_UINT32 ) getc ( IN ) << 8 ) ; if ( header -> biSize >= 40U ) { header -> biCompression = ( OPJ_UINT32 ) getc ( IN ) ; header -> biCompression |= ( OPJ_UINT32 ) getc ( IN ) << 8 ; header -> biCompression |= ( OPJ_UINT32 ) getc ( IN ) << 16 ; header -> biCompression |= ( OPJ_UINT32 ) getc ( IN ) << 24 ; header -> biSizeImage = ( OPJ_UINT32 ) getc ( IN ) ; header -> biSizeImage |= ( OPJ_UINT32 ) getc ( IN ) << 8 ; header -> biSizeImage |= ( OPJ_UINT32 ) getc ( IN ) << 16 ; header -> biSizeImage |= ( OPJ_UINT32 ) getc ( IN ) << 24 ; header -> biXpelsPerMeter = ( OPJ_UINT32 ) getc ( IN ) ; header -> biXpelsPerMeter |= ( OPJ_UINT32 ) getc ( IN ) << 8 ; header -> biXpelsPerMeter |= ( OPJ_UINT32 ) getc ( IN ) << 16 ; header -> biXpelsPerMeter |= ( OPJ_UINT32 ) getc ( IN ) << 24 ; header -> biYpelsPerMeter = ( OPJ_UINT32 ) getc ( IN ) ; header -> biYpelsPerMeter |= ( OPJ_UINT32 ) getc ( IN ) << 8 ; header -> biYpelsPerMeter |= ( OPJ_UINT32 ) getc ( IN ) << 16 ; header -> biYpelsPerMeter |= ( OPJ_UINT32 ) getc ( IN ) << 24 ; header -> biClrUsed = ( OPJ_UINT32 ) getc ( IN ) ; header -> biClrUsed |= ( OPJ_UINT32 ) getc ( IN ) << 8 ; header -> biClrUsed |= ( OPJ_UINT32 ) getc ( IN ) << 16 ; header -> biClrUsed |= ( OPJ_UINT32 ) getc ( IN ) << 24 ; header -> biClrImportant = ( OPJ_UINT32 ) getc ( IN ) ; header -> biClrImportant |= ( OPJ_UINT32 ) getc ( IN ) << 8 ; header -> biClrImportant |= ( OPJ_UINT32 ) getc ( IN ) << 16 ; header -> biClrImportant |= ( OPJ_UINT32 ) getc ( IN ) << 24 ; } if ( header -> biSize >= 56U ) { header -> biRedMask = ( OPJ_UINT32 ) getc ( IN ) ; header -> biRedMask |= ( OPJ_UINT32 ) getc ( IN ) << 8 ; header -> biRedMask |= ( OPJ_UINT32 ) getc ( IN ) << 16 ; header -> biRedMask |= ( OPJ_UINT32 ) getc ( IN ) << 24 ; header -> biGreenMask = ( OPJ_UINT32 ) getc ( IN ) ; header -> biGreenMask |= ( OPJ_UINT32 ) getc ( IN ) << 8 ; header -> biGreenMask |= ( OPJ_UINT32 ) getc ( IN ) << 16 ; header -> biGreenMask |= ( OPJ_UINT32 ) getc ( IN ) << 24 ; header -> biBlueMask = ( OPJ_UINT32 ) getc ( IN ) ; header -> biBlueMask |= ( OPJ_UINT32 ) getc ( IN ) << 8 ; header -> biBlueMask |= ( OPJ_UINT32 ) getc ( IN ) << 16 ; header -> biBlueMask |= ( OPJ_UINT32 ) getc ( IN ) << 24 ; header -> biAlphaMask = ( OPJ_UINT32 ) getc ( IN ) ; header -> biAlphaMask |= ( OPJ_UINT32 ) getc ( IN ) << 8 ; header -> biAlphaMask |= ( OPJ_UINT32 ) getc ( IN ) << 16 ; header -> biAlphaMask |= ( OPJ_UINT32 ) getc ( IN ) << 24 ; } if ( header -> biSize >= 108U ) { header -> biColorSpaceType = ( OPJ_UINT32 ) getc ( IN ) ; header -> biColorSpaceType |= ( OPJ_UINT32 ) getc ( IN ) << 8 ; header -> biColorSpaceType |= ( OPJ_UINT32 ) getc ( IN ) << 16 ; header -> biColorSpaceType |= ( OPJ_UINT32 ) getc ( IN ) << 24 ; if ( fread ( & ( header -> biColorSpaceEP ) , 1U , sizeof ( header -> biColorSpaceEP ) , IN ) != sizeof ( header -> biColorSpaceEP ) ) { fprintf ( stderr , ""Error,can\'treadBMPheader\\n"" ) ; return OPJ_FALSE ; } header -> biRedGamma = ( OPJ_UINT32 ) getc ( IN ) ; header -> biRedGamma |= ( OPJ_UINT32 ) getc ( IN ) << 8 ; header -> biRedGamma |= ( OPJ_UINT32 ) getc ( IN ) << 16 ; header -> biRedGamma |= ( OPJ_UINT32 ) getc ( IN ) << 24 ; header -> biGreenGamma = ( OPJ_UINT32 ) getc ( IN ) ; header -> biGreenGamma |= ( OPJ_UINT32 ) getc ( IN ) << 8 ; header -> biGreenGamma |= ( OPJ_UINT32 ) getc ( IN ) << 16 ; header -> biGreenGamma |= ( OPJ_UINT32 ) getc ( IN ) << 24 ; header -> biBlueGamma = ( OPJ_UINT32 ) getc ( IN ) ; header -> biBlueGamma |= ( OPJ_UINT32 ) getc ( IN ) << 8 ; header -> biBlueGamma |= ( OPJ_UINT32 ) getc ( IN ) << 16 ; header -> biBlueGamma |= ( OPJ_UINT32 ) getc ( IN ) << 24 ; } if ( header -> biSize >= 124U ) { header -> biIntent = ( OPJ_UINT32 ) getc ( IN ) ; header -> biIntent |= ( OPJ_UINT32 ) getc ( IN ) << 8 ; header -> biIntent |= ( OPJ_UINT32 ) getc ( IN ) << 16 ; header -> biIntent |= ( OPJ_UINT32 ) getc ( IN ) << 24 ; header -> biIccProfileData = ( OPJ_UINT32 ) getc ( IN ) ; header -> biIccProfileData |= ( OPJ_UINT32 ) getc ( IN ) << 8 ; header -> biIccProfileData |= ( OPJ_UINT32 ) getc ( IN ) << 16 ; header -> biIccProfileData |= ( OPJ_UINT32 ) getc ( IN ) << 24 ; header -> biIccProfileSize = ( OPJ_UINT32 ) getc ( IN ) ; header -> biIccProfileSize |= ( OPJ_UINT32 ) getc ( IN ) << 8 ; header -> biIccProfileSize |= ( OPJ_UINT32 ) getc ( IN ) << 16 ; header -> biIccProfileSize |= ( OPJ_UINT32 ) getc ( IN ) << 24 ; header -> biReserved = ( OPJ_UINT32 ) getc ( IN ) ; header -> biReserved |= ( OPJ_UINT32 ) getc ( IN ) << 8 ; header -> biReserved |= ( OPJ_UINT32 ) getc ( IN ) << 16 ; header -> biReserved |= ( OPJ_UINT32 ) getc ( IN ) << 24 ; } return OPJ_TRUE ; } "," ( header -> biBitCount == 0 ) { fprintf ( stderr , ""Error,invalidbiBitCount%d\\n"" , 0 ) ; return OPJ_FALSE ; } if ( header -> ",uclouvain@openjpeg/baf0c1ad4572daa89caa3b12985bdd93530f0dd7,CVE-2017-12982,https://github.com/uclouvain/openjpeg/commit/baf0c1ad4572daa89caa3b12985bdd93530f0dd7,2017-08-21T07:29Z 67,CWE-000,"CWE-000 static void sas_discover_domain ( struct work_struct * work ) { struct domain_device * dev ; int error = 0 ; struct sas_discovery_event * ev = to_sas_discovery_event ( work ) ; struct asd_sas_port * port = ev -> port ; clear_bit ( DISCE_DISCOVER_DOMAIN , & port -> disc . pending ) ; if ( port -> port_dev ) return ; error = sas_get_port_device ( port ) ; if ( error ) return ; dev = port -> port_dev ; SAS_DPRINTK ( ""DOINGDISCOVERYonport%d,pid:%d\\n"" , port -> id , task_pid_nr ( current ) ) ; switch ( dev -> dev_type ) { case SAS_END_DEVICE : error = sas_discover_end_dev ( dev ) ; break ; case SAS_EDGE_EXPANDER_DEVICE : case SAS_FANOUT_EXPANDER_DEVICE : error = sas_discover_root_expander ( dev ) ; break ; case SAS_SATA_DEV : case SAS_SATA_PM : # ifdef CONFIG_SCSI_SAS_ATA error = sas_discover_sata ( dev ) ; break ; # else SAS_DPRINTK ( ""ATAdeviceseenbutCONFIG_SCSI_SAS_ATA=Nsocannotattach\\n"" ) ; # endif default : error = - ENXIO ; SAS_DPRINTK ( ""unhandleddevice%d\\n"" , dev -> dev_type ) ; break ; } if ( error ) { sas_rphy_free ( dev -> rphy ) ; list_del_init ( & dev -> disco_list_node ) ; spin_lock_irq ( & port -> dev_list_lock ) ; list_del_init ( & dev -> dev_list_node ) ; spin_unlock_irq ( & port -> dev_list_lock ) ; sas_put_device ( dev ) ; port -> port_dev = NULL ; } SAS_DPRINTK ( ""DONEDISCOVERYonport%d,pid:%d,result:%d\\n"" , port -> id , task_pid_nr ( current ) , error ) ; } "," NULL ; } sas_probe_devices ( port ) ; ",torvalds@linux/0558f33c06bb910e2879e355192227a8e8f0219d,CVE-2017-18232,https://github.com/torvalds/linux/commit/0558f33c06bb910e2879e355192227a8e8f0219d,2018-03-15T04:29Z 68,CWE-415,"CWE-415 static Image * ReadTGAImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { Image * image ; MagickBooleanType status ; PixelInfo pixel ; Quantum index ; register Quantum * q ; register ssize_t i , x ; size_t base , flag , offset , real , skip ; ssize_t count , y ; TGAInfo tga_info ; unsigned char j , k , pixels [ 4 ] , runlength ; unsigned int alpha_bits ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } count = ReadBlob ( image , 1 , & tga_info . id_length ) ; tga_info . colormap_type = ( unsigned char ) ReadBlobByte ( image ) ; tga_info . image_type = ( TGAImageType ) ReadBlobByte ( image ) ; if ( ( count != 1 ) || ( ( tga_info . image_type != TGAColormap ) && ( tga_info . image_type != TGARGB ) && ( tga_info . image_type != TGAMonochrome ) && ( tga_info . image_type != TGARLEColormap ) && ( tga_info . image_type != TGARLERGB ) && ( tga_info . image_type != TGARLEMonochrome ) ) || ( ( ( tga_info . image_type == TGAColormap ) || ( tga_info . image_type == TGARLEColormap ) ) && ( tga_info . colormap_type == 0 ) ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; tga_info . colormap_index = ReadBlobLSBShort ( image ) ; tga_info . colormap_length = ReadBlobLSBShort ( image ) ; tga_info . colormap_size = ( unsigned char ) ReadBlobByte ( image ) ; tga_info . x_origin = ReadBlobLSBShort ( image ) ; tga_info . y_origin = ReadBlobLSBShort ( image ) ; tga_info . width = ( unsigned short ) ReadBlobLSBShort ( image ) ; tga_info . height = ( unsigned short ) ReadBlobLSBShort ( image ) ; tga_info . bits_per_pixel = ( unsigned char ) ReadBlobByte ( image ) ; tga_info . attributes = ( unsigned char ) ReadBlobByte ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; if ( ( ( ( tga_info . bits_per_pixel <= 1 ) || ( tga_info . bits_per_pixel >= 17 ) ) && ( tga_info . bits_per_pixel != 24 ) && ( tga_info . bits_per_pixel != 32 ) ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; image -> columns = tga_info . width ; image -> rows = tga_info . height ; alpha_bits = ( tga_info . attributes & 0x0FU ) ; image -> alpha_trait = ( alpha_bits > 0 ) || ( tga_info . bits_per_pixel == 32 ) || ( tga_info . colormap_size == 32 ) ? BlendPixelTrait : UndefinedPixelTrait ; if ( ( tga_info . image_type != TGAColormap ) && ( tga_info . image_type != TGARLEColormap ) ) image -> depth = ( size_t ) ( ( tga_info . bits_per_pixel <= 8 ) ? 8 : ( tga_info . bits_per_pixel <= 16 ) ? 5 : ( tga_info . bits_per_pixel == 24 ) ? 8 : ( tga_info . bits_per_pixel == 32 ) ? 8 : 8 ) ; else image -> depth = ( size_t ) ( ( tga_info . colormap_size <= 8 ) ? 8 : ( tga_info . colormap_size <= 16 ) ? 5 : ( tga_info . colormap_size == 24 ) ? 8 : ( tga_info . colormap_size == 32 ) ? 8 : 8 ) ; if ( ( tga_info . image_type == TGAColormap ) || ( tga_info . image_type == TGAMonochrome ) || ( tga_info . image_type == TGARLEColormap ) || ( tga_info . image_type == TGARLEMonochrome ) ) image -> storage_class = PseudoClass ; image -> compression = NoCompression ; if ( ( tga_info . image_type == TGARLEColormap ) || ( tga_info . image_type == TGARLEMonochrome ) || ( tga_info . image_type == TGARLERGB ) ) image -> compression = RLECompression ; if ( image -> storage_class == PseudoClass ) { if ( tga_info . colormap_type != 0 ) image -> colors = tga_info . colormap_index + tga_info . colormap_length ; else { size_t one ; one = 1 ; image -> colors = one << tga_info . bits_per_pixel ; if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; } } if ( tga_info . id_length != 0 ) { char * comment ; size_t length ; length = ( size_t ) tga_info . id_length ; comment = ( char * ) NULL ; if ( ~ length >= ( MagickPathExtent - 1 ) ) comment = ( char * ) AcquireQuantumMemory ( length + MagickPathExtent , sizeof ( * comment ) ) ; if ( comment == ( char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; count = ReadBlob ( image , tga_info . id_length , ( unsigned char * ) comment ) ; comment [ tga_info . id_length ] = '\\0' ; ( void ) SetImageProperty ( image , ""comment"" , comment , exception ) ; comment = DestroyString ( comment ) ; } if ( image_info -> ping != MagickFalse ) { ( void ) CloseBlob ( image ) ; return ( image ) ; } status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; ( void ) ResetMagickMemory ( & pixel , 0 , sizeof ( pixel ) ) ; pixel . alpha = ( MagickRealType ) OpaqueAlpha ; if ( tga_info . colormap_type != 0 ) { if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; for ( i = 0 ; i < ( ssize_t ) tga_info . colormap_index ; i ++ ) image -> colormap [ i ] = pixel ; for ( ; i < ( ssize_t ) image -> colors ; i ++ ) { switch ( tga_info . colormap_size ) { case 8 : default : { pixel . red = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; pixel . green = pixel . red ; pixel . blue = pixel . red ; break ; } case 15 : case 16 : { QuantumAny range ; j = ( unsigned char ) ReadBlobByte ( image ) ; k = ( unsigned char ) ReadBlobByte ( image ) ; range = GetQuantumRange ( 5UL ) ; pixel . red = ( MagickRealType ) ScaleAnyToQuantum ( 1UL * ( k & 0x7c ) >> 2 , range ) ; pixel . green = ( MagickRealType ) ScaleAnyToQuantum ( ( 1UL * ( k & 0x03 ) << 3 ) + ( 1UL * ( j & 0xe0 ) >> 5 ) , range ) ; pixel . blue = ( MagickRealType ) ScaleAnyToQuantum ( 1UL * ( j & 0x1f ) , range ) ; break ; } case 24 : { pixel . blue = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; pixel . green = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; pixel . red = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; break ; } case 32 : { pixel . blue = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; pixel . green = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; pixel . red = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; pixel . alpha = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; break ; } } image -> colormap [ i ] = pixel ; } } base = 0 ; flag = 0 ; skip = MagickFalse ; real = 0 ; index = 0 ; runlength = 0 ; offset = 0 ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { real = offset ; if ( ( ( unsigned char ) ( tga_info . attributes & 0x20 ) >> 5 ) == 0 ) real = image -> rows - real - 1 ; q = QueueAuthenticPixels ( image , 0 , ( ssize_t ) real , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { if ( ( tga_info . image_type == TGARLEColormap ) || ( tga_info . image_type == TGARLERGB ) || ( tga_info . image_type == TGARLEMonochrome ) ) { if ( runlength != 0 ) { runlength -- ; skip = flag != 0 ; } else { count = ReadBlob ( image , 1 , & runlength ) ; if ( count != 1 ) ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; flag = runlength & 0x80 ; if ( flag != 0 ) runlength -= 128 ; skip = MagickFalse ; } } if ( skip == MagickFalse ) switch ( tga_info . bits_per_pixel ) { case 8 : default : { index = ( Quantum ) ReadBlobByte ( image ) ; if ( tga_info . colormap_type != 0 ) pixel = image -> colormap [ ( ssize_t ) ConstrainColormapIndex ( image , ( ssize_t ) index , exception ) ] ; else { pixel . red = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) index ) ; pixel . green = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) index ) ; pixel . blue = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) index ) ; } break ; } case 15 : case 16 : { QuantumAny range ; if ( ReadBlob ( image , 2 , pixels ) != 2 ) ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; j = pixels [ 0 ] ; k = pixels [ 1 ] ; range = GetQuantumRange ( 5UL ) ; pixel . red = ( MagickRealType ) ScaleAnyToQuantum ( 1UL * ( k & 0x7c ) >> 2 , range ) ; pixel . green = ( MagickRealType ) ScaleAnyToQuantum ( ( 1UL * ( k & 0x03 ) << 3 ) + ( 1UL * ( j & 0xe0 ) >> 5 ) , range ) ; pixel . blue = ( MagickRealType ) ScaleAnyToQuantum ( 1UL * ( j & 0x1f ) , range ) ; if ( image -> alpha_trait != UndefinedPixelTrait ) pixel . alpha = ( MagickRealType ) ( ( k & 0x80 ) == 0 ? ( Quantum ) TransparentAlpha : ( Quantum ) OpaqueAlpha ) ; if ( image -> storage_class == PseudoClass ) index = ( Quantum ) ConstrainColormapIndex ( image , ( ( ssize_t ) ( k << 8 ) ) + j , exception ) ; break ; } case 24 : { if ( ReadBlob ( image , 3 , pixels ) != 3 ) ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; pixel . blue = ( MagickRealType ) ScaleCharToQuantum ( pixels [ 0 ] ) ; pixel . green = ( MagickRealType ) ScaleCharToQuantum ( pixels [ 1 ] ) ; pixel . red = ( MagickRealType ) ScaleCharToQuantum ( pixels [ 2 ] ) ; break ; } case 32 : { if ( ReadBlob ( image , 4 , pixels ) != 4 ) ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; pixel . blue = ( MagickRealType ) ScaleCharToQuantum ( pixels [ 0 ] ) ; pixel . green = ( MagickRealType ) ScaleCharToQuantum ( pixels [ 1 ] ) ; pixel . red = ( MagickRealType ) ScaleCharToQuantum ( pixels [ 2 ] ) ; pixel . alpha = ( MagickRealType ) ScaleCharToQuantum ( pixels [ 3 ] ) ; break ; } } if ( status == MagickFalse ) ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; if ( image -> storage_class == PseudoClass ) SetPixelIndex ( image , index , q ) ; SetPixelRed ( image , ClampToQuantum ( pixel . red ) , q ) ; SetPixelGreen ( image , ClampToQuantum ( pixel . green ) , q ) ; SetPixelBlue ( image , ClampToQuantum ( pixel . blue ) , q ) ; if ( image -> alpha_trait != UndefinedPixelTrait ) SetPixelAlpha ( image , ClampToQuantum ( pixel . alpha ) , q ) ; q += GetPixelChannels ( image ) ; } if ( ( ( unsigned char ) ( tga_info . attributes & 0xc0 ) >> 6 ) == 2 ) offset += 2 ; else offset ++ ; if ( offset >= image -> rows ) { base ++ ; offset = base ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } if ( EOFBlob ( image ) != MagickFalse ) ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," 0 ) { if ( image -> colors < tga_info . colormap_index ) image -> colors = tga_info . colormap_index ; ",ImageMagick@ImageMagick/4f68e9661518463fca523c9726bb5d940a2aa6d8,CVE-2015-8894,https://github.com/ImageMagick/ImageMagick/commit/4f68e9661518463fca523c9726bb5d940a2aa6d8,2017-03-15T19:59Z 69,CWE-190,"CWE-190 static int jas_iccgetuint32 ( jas_stream_t * in , jas_iccuint32_t * val ) { ulonglong tmp ; if ( jas_iccgetuint ( in , 4 , & tmp ) ) return - 1 ; * val = tmp ; return 0 ; } "," val ) { jas_ulonglong tmp ; if ",mdadams@jasper/d42b2388f7f8e0332c846675133acea151fc557a,CVE-2016-9557,https://github.com/mdadams/jasper/commit/d42b2388f7f8e0332c846675133acea151fc557a,2017-03-23T18:59Z 70,CWE-399,"CWE-399 static int wanxl_ioctl ( struct net_device * dev , struct ifreq * ifr , int cmd ) { const size_t size = sizeof ( sync_serial_settings ) ; sync_serial_settings line ; port_t * port = dev_to_port ( dev ) ; if ( cmd != SIOCWANDEV ) return hdlc_ioctl ( dev , ifr , cmd ) ; switch ( ifr -> ifr_settings . type ) { case IF_GET_IFACE : ifr -> ifr_settings . type = IF_IFACE_SYNC_SERIAL ; if ( ifr -> ifr_settings . size < size ) { ifr -> ifr_settings . size = size ; return - ENOBUFS ; } line . clock_type = get_status ( port ) -> clocking ; line . clock_rate = 0 ; line . loopback = 0 ; if ( copy_to_user ( ifr -> ifr_settings . ifs_ifsu . sync , & line , size ) ) return - EFAULT ; return 0 ; case IF_IFACE_SYNC_SERIAL : if ( ! capable ( CAP_NET_ADMIN ) ) return - EPERM ; if ( dev -> flags & IFF_UP ) return - EBUSY ; if ( copy_from_user ( & line , ifr -> ifr_settings . ifs_ifsu . sync , size ) ) return - EFAULT ; if ( line . clock_type != CLOCK_EXT && line . clock_type != CLOCK_TXFROMRX ) return - EINVAL ; if ( line . loopback != 0 ) return - EINVAL ; get_status ( port ) -> clocking = line . clock_type ; return 0 ; default : return hdlc_ioctl ( dev , ifr , cmd ) ; } } "," ENOBUFS ; } memset ( & line , 0 , sizeof ( line ) ) ; ",torvalds@linux/2b13d06c9584b4eb773f1e80bbaedab9a1c344e1,CVE-2014-1445,https://github.com/torvalds/linux/commit/2b13d06c9584b4eb773f1e80bbaedab9a1c344e1,2014-01-18T22:55Z 71,CWE-264,"CWE-264 int scsi_cmd_blk_ioctl ( struct block_device * bd , fmode_t mode , unsigned int cmd , void __user * arg ) { return scsi_cmd_ioctl ( bd -> bd_disk -> queue , bd -> bd_disk , mode , cmd , arg ) ; } "," arg ) { int ret ; ret = scsi_verify_blk_ioctl ( bd , cmd ) ; if ( ret < 0 ) return ret ; ",torvalds@linux/0bfc96cb77224736dfa35c3c555d37b3646ef35e,CVE-2011-4127,https://github.com/torvalds/linux/commit/0bfc96cb77224736dfa35c3c555d37b3646ef35e,2012-07-03T16:40Z 72,CWE-125,"CWE-125 void nego_process_negotiation_request ( rdpNego * nego , wStream * s ) { BYTE flags ; UINT16 length ; Stream_Read_UINT8 ( s , flags ) ; Stream_Read_UINT16 ( s , length ) ; Stream_Read_UINT32 ( s , nego -> RequestedProtocols ) ; WLog_DBG ( TAG , ""RDP_NEG_REQ:RequestedProtocol:0x%08"" PRIX32 """" , nego -> RequestedProtocols ) ; nego -> state = NEGO_STATE_FINAL ; } "," BOOL nego_process_negotiation_request ( rdpNego ; UINT16 length ; if ( Stream_GetRemainingLength ( s ) < 7 ) return FALSE = NEGO_STATE_FINAL ; return TRUE ; ",FreeRDP@FreeRDP/6b485b146a1b9d6ce72dfd7b5f36456c166e7a16,CVE-2020-11089,https://github.com/FreeRDP/FreeRDP/commit/6b485b146a1b9d6ce72dfd7b5f36456c166e7a16,2020-05-29T20:15Z 73,CWE-119,"CWE-119 int qeth_snmp_command ( struct qeth_card * card , char __user * udata ) { struct qeth_cmd_buffer * iob ; struct qeth_ipa_cmd * cmd ; struct qeth_snmp_ureq * ureq ; int req_len ; struct qeth_arp_query_info qinfo = { 0 , } ; int rc = 0 ; QETH_CARD_TEXT ( card , 3 , ""snmpcmd"" ) ; if ( card -> info . guestlan ) return - EOPNOTSUPP ; if ( ( ! qeth_adp_supported ( card , IPA_SETADP_SET_SNMP_CONTROL ) ) && ( ! card -> options . layer2 ) ) { return - EOPNOTSUPP ; } if ( copy_from_user ( & req_len , udata + sizeof ( int ) , sizeof ( int ) ) ) return - EFAULT ; ureq = memdup_user ( udata , req_len + sizeof ( struct qeth_snmp_ureq_hdr ) ) ; if ( IS_ERR ( ureq ) ) { QETH_CARD_TEXT ( card , 2 , ""snmpnome"" ) ; return PTR_ERR ( ureq ) ; } qinfo . udata_len = ureq -> hdr . data_len ; qinfo . udata = kzalloc ( qinfo . udata_len , GFP_KERNEL ) ; if ( ! qinfo . udata ) { kfree ( ureq ) ; return - ENOMEM ; } qinfo . udata_offset = sizeof ( struct qeth_snmp_ureq_hdr ) ; iob = qeth_get_adapter_cmd ( card , IPA_SETADP_SET_SNMP_CONTROL , QETH_SNMP_SETADP_CMDLENGTH + req_len ) ; cmd = ( struct qeth_ipa_cmd * ) ( iob -> data + IPA_PDU_HEADER_SIZE ) ; memcpy ( & cmd -> data . setadapterparms . data . snmp , & ureq -> cmd , req_len ) ; rc = qeth_send_ipa_snmp_cmd ( card , iob , QETH_SETADP_BASE_LEN + req_len , qeth_snmp_command_cb , ( void * ) & qinfo ) ; if ( rc ) QETH_DBF_MESSAGE ( 2 , ""SNMPcommandfailedon%s:(0x%x)\\n"" , QETH_CARD_IFNAME ( card ) , rc ) ; else { if ( copy_to_user ( udata , qinfo . udata , qinfo . udata_len ) ) rc = - EFAULT ; } kfree ( ureq ) ; kfree ( qinfo . udata ) ; return rc ; } "," * ureq ; unsigned return - EFAULT ; if ( req_len > ( QETH_BUFSIZE - IPA_PDU_HEADER_SIZE - sizeof ( struct qeth_ipacmd_hdr ) - sizeof ( struct qeth_ipacmd_setadpparms_hdr ) ) ) return - EINVAL ",torvalds@linux/6fb392b1a63ae36c31f62bc3fc8630b49d602b62,CVE-2013-6381,https://github.com/torvalds/linux/commit/6fb392b1a63ae36c31f62bc3fc8630b49d602b62,2013-11-27T04:43Z 74,CWE-190,"CWE-190 int jas_stream_pad ( jas_stream_t * stream , int n , int c ) { int m ; m = n ; for ( m = n ; m > 0 ; -- m ) { if ( jas_stream_putc ( stream , c ) == EOF ) return n - m ; } return n ; } "," int m ; if ( n < 0 ) { jas_deprecated ( ""negativecountforjas_stream_pad"" ) ; } ",mdadams@jasper/634ce8e8a5accc0fa05dd2c20d42b4749d4b2735,CVE-2016-9262,https://github.com/mdadams/jasper/commit/634ce8e8a5accc0fa05dd2c20d42b4749d4b2735,2017-03-23T18:59Z 75,CWE-787,"CWE-787 static int track_header ( VividasDemuxContext * viv , AVFormatContext * s , uint8_t * buf , int size ) { int i , j , ret ; int64_t off ; int val_1 ; int num_video ; AVIOContext pb0 , * pb = & pb0 ; ffio_init_context ( pb , buf , size , 0 , NULL , NULL , NULL , NULL ) ; ffio_read_varlen ( pb ) ; avio_r8 ( pb ) ; val_1 = ffio_read_varlen ( pb ) ; for ( i = 0 ; i < val_1 ; i ++ ) { int c = avio_r8 ( pb ) ; if ( avio_feof ( pb ) ) return AVERROR_EOF ; for ( j = 0 ; j < c ; j ++ ) { if ( avio_feof ( pb ) ) return AVERROR_EOF ; avio_r8 ( pb ) ; avio_r8 ( pb ) ; } } avio_r8 ( pb ) ; off = avio_tell ( pb ) ; off += ffio_read_varlen ( pb ) ; avio_r8 ( pb ) ; num_video = avio_r8 ( pb ) ; avio_seek ( pb , off , SEEK_SET ) ; if ( num_video != 1 ) { av_log ( s , AV_LOG_ERROR , ""numberofvideotracks%disnot1\\n"" , num_video ) ; return AVERROR_PATCHWELCOME ; } for ( i = 0 ; i < num_video ; i ++ ) { AVStream * st = avformat_new_stream ( s , NULL ) ; int num , den ; if ( ! st ) return AVERROR ( ENOMEM ) ; st -> id = i ; st -> codecpar -> codec_type = AVMEDIA_TYPE_VIDEO ; st -> codecpar -> codec_id = AV_CODEC_ID_VP6 ; off = avio_tell ( pb ) ; off += ffio_read_varlen ( pb ) ; avio_r8 ( pb ) ; avio_r8 ( pb ) ; num = avio_rl32 ( pb ) ; den = avio_rl32 ( pb ) ; avpriv_set_pts_info ( st , 64 , num , den ) ; st -> nb_frames = avio_rl32 ( pb ) ; st -> codecpar -> width = avio_rl16 ( pb ) ; st -> codecpar -> height = avio_rl16 ( pb ) ; avio_r8 ( pb ) ; avio_rl32 ( pb ) ; avio_seek ( pb , off , SEEK_SET ) ; } off = avio_tell ( pb ) ; off += ffio_read_varlen ( pb ) ; avio_r8 ( pb ) ; viv -> num_audio = avio_r8 ( pb ) ; avio_seek ( pb , off , SEEK_SET ) ; if ( viv -> num_audio != 1 ) av_log ( s , AV_LOG_WARNING , ""numberofaudiotracks%disnot1\\n"" , viv -> num_audio ) ; for ( i = 0 ; i < viv -> num_audio ; i ++ ) { int q ; AVStream * st = avformat_new_stream ( s , NULL ) ; if ( ! st ) return AVERROR ( ENOMEM ) ; st -> id = num_video + i ; st -> codecpar -> codec_type = AVMEDIA_TYPE_AUDIO ; st -> codecpar -> codec_id = AV_CODEC_ID_VORBIS ; off = avio_tell ( pb ) ; off += ffio_read_varlen ( pb ) ; avio_r8 ( pb ) ; avio_r8 ( pb ) ; avio_rl16 ( pb ) ; st -> codecpar -> channels = avio_rl16 ( pb ) ; st -> codecpar -> sample_rate = avio_rl32 ( pb ) ; avio_seek ( pb , 10 , SEEK_CUR ) ; q = avio_r8 ( pb ) ; avio_seek ( pb , q , SEEK_CUR ) ; avio_r8 ( pb ) ; if ( avio_tell ( pb ) < off ) { int num_data ; int xd_size = 0 ; int data_len [ 256 ] ; int offset = 1 ; uint8_t * p ; ffio_read_varlen ( pb ) ; avio_r8 ( pb ) ; ffio_read_varlen ( pb ) ; num_data = avio_r8 ( pb ) ; for ( j = 0 ; j < num_data ; j ++ ) { uint64_t len = ffio_read_varlen ( pb ) ; if ( len > INT_MAX / 2 - xd_size ) { return AVERROR_INVALIDDATA ; } data_len [ j ] = len ; xd_size += len ; } ret = ff_alloc_extradata ( st -> codecpar , 64 + xd_size + xd_size / 255 ) ; if ( ret < 0 ) return ret ; p = st -> codecpar -> extradata ; p [ 0 ] = 2 ; for ( j = 0 ; j < num_data - 1 ; j ++ ) { unsigned delta = av_xiphlacing ( & p [ offset ] , data_len [ j ] ) ; if ( delta > data_len [ j ] ) { return AVERROR_INVALIDDATA ; } offset += delta ; } for ( j = 0 ; j < num_data ; j ++ ) { int ret = avio_read ( pb , & p [ offset ] , data_len [ j ] ) ; if ( ret < data_len [ j ] ) { st -> codecpar -> extradata_size = 0 ; av_freep ( & st -> codecpar -> extradata ) ; break ; } offset += data_len [ j ] ; } if ( offset < st -> codecpar -> extradata_size ) st -> codecpar -> extradata_size = offset ; } } return 0 ; } "," int xd_size = 1 ; int data_len xd_size += len + 1 + len / 255 ; } ret = ff_alloc_extradata ( st -> codecpar , xd_size ) ; if ] ) ; av_assert0 ( delta <= xd_size - offset ) ; offset += delta break ; } av_assert0 ( data_len [ j ] <= xd_size - offset ) ; ",FFmpeg@FFmpeg/27a99e2c7d450fef15594671eef4465c8a166bd7,CVE-2020-35964,https://github.com/FFmpeg/FFmpeg/commit/27a99e2c7d450fef15594671eef4465c8a166bd7,2021-01-03T19:15Z 76,CWE-125,"CWE-125 static int mxf_parse_structural_metadata ( MXFContext * mxf ) { MXFPackage * material_package = NULL ; int i , j , k , ret ; av_log ( mxf -> fc , AV_LOG_TRACE , ""metadatasetscount%d\\n"" , mxf -> metadata_sets_count ) ; for ( i = 0 ; i < mxf -> packages_count ; i ++ ) { material_package = mxf_resolve_strong_ref ( mxf , & mxf -> packages_refs [ i ] , MaterialPackage ) ; if ( material_package ) break ; } if ( ! material_package ) { av_log ( mxf -> fc , AV_LOG_ERROR , ""nomaterialpackagefound\\n"" ) ; return AVERROR_INVALIDDATA ; } mxf_add_umid_metadata ( & mxf -> fc -> metadata , ""material_package_umid"" , material_package ) ; if ( material_package -> name && material_package -> name [ 0 ] ) av_dict_set ( & mxf -> fc -> metadata , ""material_package_name"" , material_package -> name , 0 ) ; mxf_parse_package_comments ( mxf , & mxf -> fc -> metadata , material_package ) ; for ( i = 0 ; i < material_package -> tracks_count ; i ++ ) { MXFPackage * source_package = NULL ; MXFTrack * material_track = NULL ; MXFTrack * source_track = NULL ; MXFTrack * temp_track = NULL ; MXFDescriptor * descriptor = NULL ; MXFStructuralComponent * component = NULL ; MXFTimecodeComponent * mxf_tc = NULL ; UID * essence_container_ul = NULL ; const MXFCodecUL * codec_ul = NULL ; const MXFCodecUL * container_ul = NULL ; const MXFCodecUL * pix_fmt_ul = NULL ; AVStream * st ; AVTimecode tc ; int flags ; if ( ! ( material_track = mxf_resolve_strong_ref ( mxf , & material_package -> tracks_refs [ i ] , Track ) ) ) { av_log ( mxf -> fc , AV_LOG_ERROR , ""couldnotresolvematerialtrackstrongref\\n"" ) ; continue ; } if ( ( component = mxf_resolve_strong_ref ( mxf , & material_track -> sequence_ref , TimecodeComponent ) ) ) { mxf_tc = ( MXFTimecodeComponent * ) component ; flags = mxf_tc -> drop_frame == 1 ? AV_TIMECODE_FLAG_DROPFRAME : 0 ; if ( av_timecode_init ( & tc , mxf_tc -> rate , flags , mxf_tc -> start_frame , mxf -> fc ) == 0 ) { mxf_add_timecode_metadata ( & mxf -> fc -> metadata , ""timecode"" , & tc ) ; } } if ( ! ( material_track -> sequence = mxf_resolve_strong_ref ( mxf , & material_track -> sequence_ref , Sequence ) ) ) { av_log ( mxf -> fc , AV_LOG_ERROR , ""couldnotresolvematerialtracksequencestrongref\\n"" ) ; continue ; } for ( j = 0 ; j < material_track -> sequence -> structural_components_count ; j ++ ) { component = mxf_resolve_strong_ref ( mxf , & material_track -> sequence -> structural_components_refs [ j ] , TimecodeComponent ) ; if ( ! component ) continue ; mxf_tc = ( MXFTimecodeComponent * ) component ; flags = mxf_tc -> drop_frame == 1 ? AV_TIMECODE_FLAG_DROPFRAME : 0 ; if ( av_timecode_init ( & tc , mxf_tc -> rate , flags , mxf_tc -> start_frame , mxf -> fc ) == 0 ) { mxf_add_timecode_metadata ( & mxf -> fc -> metadata , ""timecode"" , & tc ) ; break ; } } if ( material_track -> sequence -> structural_components_count > 1 ) av_log ( mxf -> fc , AV_LOG_WARNING , ""materialtrack%d:has%dcomponents\\n"" , material_track -> track_id , material_track -> sequence -> structural_components_count ) ; for ( j = 0 ; j < material_track -> sequence -> structural_components_count ; j ++ ) { component = mxf_resolve_sourceclip ( mxf , & material_track -> sequence -> structural_components_refs [ j ] ) ; if ( ! component ) continue ; source_package = mxf_resolve_source_package ( mxf , component -> source_package_ul , component -> source_package_uid ) ; if ( ! source_package ) { av_log ( mxf -> fc , AV_LOG_TRACE , ""materialtrack%d:nocorrespondingsourcepackagefound\\n"" , material_track -> track_id ) ; continue ; } for ( k = 0 ; k < source_package -> tracks_count ; k ++ ) { if ( ! ( temp_track = mxf_resolve_strong_ref ( mxf , & source_package -> tracks_refs [ k ] , Track ) ) ) { av_log ( mxf -> fc , AV_LOG_ERROR , ""couldnotresolvesourcetrackstrongref\\n"" ) ; ret = AVERROR_INVALIDDATA ; goto fail_and_free ; } if ( temp_track -> track_id == component -> source_track_id ) { source_track = temp_track ; break ; } } if ( ! source_track ) { av_log ( mxf -> fc , AV_LOG_ERROR , ""materialtrack%d:nocorrespondingsourcetrackfound\\n"" , material_track -> track_id ) ; break ; } for ( k = 0 ; k < mxf -> essence_container_data_count ; k ++ ) { MXFEssenceContainerData * essence_data ; if ( ! ( essence_data = mxf_resolve_strong_ref ( mxf , & mxf -> essence_container_data_refs [ k ] , EssenceContainerData ) ) ) { av_log ( mxf , AV_LOG_TRACE , ""couldnotresolveessencecontainerdatastrongref\\n"" ) ; continue ; } if ( ! memcmp ( component -> source_package_ul , essence_data -> package_ul , sizeof ( UID ) ) && ! memcmp ( component -> source_package_uid , essence_data -> package_uid , sizeof ( UID ) ) ) { source_track -> body_sid = essence_data -> body_sid ; source_track -> index_sid = essence_data -> index_sid ; break ; } } if ( source_track && component ) break ; } if ( ! source_track || ! component || ! source_package ) { if ( ( ret = mxf_add_metadata_stream ( mxf , material_track ) ) ) goto fail_and_free ; continue ; } if ( ! ( source_track -> sequence = mxf_resolve_strong_ref ( mxf , & source_track -> sequence_ref , Sequence ) ) ) { av_log ( mxf -> fc , AV_LOG_ERROR , ""couldnotresolvesourcetracksequencestrongref\\n"" ) ; ret = AVERROR_INVALIDDATA ; goto fail_and_free ; } if ( memcmp ( material_track -> sequence -> data_definition_ul , source_track -> sequence -> data_definition_ul , 16 ) ) { av_log ( mxf -> fc , AV_LOG_ERROR , ""materialtrack%d:DataDefinitionmismatch\\n"" , material_track -> track_id ) ; continue ; } st = avformat_new_stream ( mxf -> fc , NULL ) ; if ( ! st ) { av_log ( mxf -> fc , AV_LOG_ERROR , ""couldnotallocatestream\\n"" ) ; ret = AVERROR ( ENOMEM ) ; goto fail_and_free ; } st -> id = material_track -> track_id ; st -> priv_data = source_track ; source_package -> descriptor = mxf_resolve_strong_ref ( mxf , & source_package -> descriptor_ref , AnyType ) ; descriptor = mxf_resolve_multidescriptor ( mxf , source_package -> descriptor , source_track -> track_id ) ; if ( descriptor && descriptor -> duration != AV_NOPTS_VALUE ) source_track -> original_duration = st -> duration = FFMIN ( descriptor -> duration , component -> duration ) ; else source_track -> original_duration = st -> duration = component -> duration ; if ( st -> duration == - 1 ) st -> duration = AV_NOPTS_VALUE ; st -> start_time = component -> start_position ; if ( material_track -> edit_rate . num <= 0 || material_track -> edit_rate . den <= 0 ) { av_log ( mxf -> fc , AV_LOG_WARNING , ""Invalideditrate(%d/%d)foundonstream#%d,"" ""defaultingto25/1\\n"" , material_track -> edit_rate . num , material_track -> edit_rate . den , st -> index ) ; material_track -> edit_rate = ( AVRational ) { 25 , 1 } ; } avpriv_set_pts_info ( st , 64 , material_track -> edit_rate . den , material_track -> edit_rate . num ) ; source_track -> edit_rate = material_track -> edit_rate ; PRINT_KEY ( mxf -> fc , ""datadefinitionul"" , source_track -> sequence -> data_definition_ul ) ; codec_ul = mxf_get_codec_ul ( ff_mxf_data_definition_uls , & source_track -> sequence -> data_definition_ul ) ; st -> codecpar -> codec_type = codec_ul -> id ; if ( ! descriptor ) { av_log ( mxf -> fc , AV_LOG_INFO , ""sourcetrack%d:stream%d,nodescriptorfound\\n"" , source_track -> track_id , st -> index ) ; continue ; } PRINT_KEY ( mxf -> fc , ""essencecodecul"" , descriptor -> essence_codec_ul ) ; PRINT_KEY ( mxf -> fc , ""essencecontainerul"" , descriptor -> essence_container_ul ) ; essence_container_ul = & descriptor -> essence_container_ul ; source_track -> wrapping = ( mxf -> op == OPAtom ) ? ClipWrapped : mxf_get_wrapping_kind ( essence_container_ul ) ; if ( source_track -> wrapping == UnknownWrapped ) av_log ( mxf -> fc , AV_LOG_INFO , ""wrappingofstream%disunknown\\n"" , st -> index ) ; if ( IS_KLV_KEY ( essence_container_ul , mxf_encrypted_essence_container ) ) { av_log ( mxf -> fc , AV_LOG_INFO , ""brokenencryptedmxffile\\n"" ) ; for ( k = 0 ; k < mxf -> metadata_sets_count ; k ++ ) { MXFMetadataSet * metadata = mxf -> metadata_sets [ k ] ; if ( metadata -> type == CryptoContext ) { essence_container_ul = & ( ( MXFCryptoContext * ) metadata ) -> source_container_ul ; break ; } } } codec_ul = mxf_get_codec_ul ( ff_mxf_codec_uls , & descriptor -> essence_codec_ul ) ; st -> codecpar -> codec_id = ( enum AVCodecID ) codec_ul -> id ; if ( st -> codecpar -> codec_id == AV_CODEC_ID_NONE ) { codec_ul = mxf_get_codec_ul ( ff_mxf_codec_uls , & descriptor -> codec_ul ) ; st -> codecpar -> codec_id = ( enum AVCodecID ) codec_ul -> id ; } av_log ( mxf -> fc , AV_LOG_VERBOSE , ""%s:UniversalLabel:"" , avcodec_get_name ( st -> codecpar -> codec_id ) ) ; for ( k = 0 ; k < 16 ; k ++ ) { av_log ( mxf -> fc , AV_LOG_VERBOSE , ""%.2x"" , descriptor -> essence_codec_ul [ k ] ) ; if ( ! ( k + 1 & 19 ) || k == 5 ) av_log ( mxf -> fc , AV_LOG_VERBOSE , ""."" ) ; } av_log ( mxf -> fc , AV_LOG_VERBOSE , ""\\n"" ) ; mxf_add_umid_metadata ( & st -> metadata , ""file_package_umid"" , source_package ) ; if ( source_package -> name && source_package -> name [ 0 ] ) av_dict_set ( & st -> metadata , ""file_package_name"" , source_package -> name , 0 ) ; if ( material_track -> name && material_track -> name [ 0 ] ) av_dict_set ( & st -> metadata , ""track_name"" , material_track -> name , 0 ) ; mxf_parse_physical_source_package ( mxf , source_track , st ) ; if ( st -> codecpar -> codec_type == AVMEDIA_TYPE_VIDEO ) { source_track -> intra_only = mxf_is_intra_only ( descriptor ) ; container_ul = mxf_get_codec_ul ( mxf_picture_essence_container_uls , essence_container_ul ) ; if ( st -> codecpar -> codec_id == AV_CODEC_ID_NONE ) st -> codecpar -> codec_id = container_ul -> id ; st -> codecpar -> width = descriptor -> width ; st -> codecpar -> height = descriptor -> height ; switch ( descriptor -> frame_layout ) { case FullFrame : st -> codecpar -> field_order = AV_FIELD_PROGRESSIVE ; break ; case OneField : av_log ( mxf -> fc , AV_LOG_INFO , ""OneFieldframelayoutisn\'tcurrentlysupported\\n"" ) ; break ; case MixedFields : break ; case SegmentedFrame : st -> codecpar -> field_order = AV_FIELD_PROGRESSIVE ; case SeparateFields : av_log ( mxf -> fc , AV_LOG_DEBUG , ""video_line_map:(%d,%d),field_dominance:%d\\n"" , descriptor -> video_line_map [ 0 ] , descriptor -> video_line_map [ 1 ] , descriptor -> field_dominance ) ; if ( ( descriptor -> video_line_map [ 0 ] > 0 ) && ( descriptor -> video_line_map [ 1 ] > 0 ) ) { if ( ( descriptor -> video_line_map [ 0 ] + descriptor -> video_line_map [ 1 ] ) % 2 ) { switch ( descriptor -> field_dominance ) { case MXF_FIELD_DOMINANCE_DEFAULT : case MXF_FIELD_DOMINANCE_FF : st -> codecpar -> field_order = AV_FIELD_TT ; break ; case MXF_FIELD_DOMINANCE_FL : st -> codecpar -> field_order = AV_FIELD_TB ; break ; default : avpriv_request_sample ( mxf -> fc , ""Fielddominance%dsupport"" , descriptor -> field_dominance ) ; } } else { switch ( descriptor -> field_dominance ) { case MXF_FIELD_DOMINANCE_DEFAULT : case MXF_FIELD_DOMINANCE_FF : st -> codecpar -> field_order = AV_FIELD_BB ; break ; case MXF_FIELD_DOMINANCE_FL : st -> codecpar -> field_order = AV_FIELD_BT ; break ; default : avpriv_request_sample ( mxf -> fc , ""Fielddominance%dsupport"" , descriptor -> field_dominance ) ; } } } st -> codecpar -> height *= 2 ; break ; default : av_log ( mxf -> fc , AV_LOG_INFO , ""Unknownframelayouttype:%d\\n"" , descriptor -> frame_layout ) ; } if ( st -> codecpar -> codec_id == AV_CODEC_ID_RAWVIDEO ) { st -> codecpar -> format = descriptor -> pix_fmt ; if ( st -> codecpar -> format == AV_PIX_FMT_NONE ) { pix_fmt_ul = mxf_get_codec_ul ( ff_mxf_pixel_format_uls , & descriptor -> essence_codec_ul ) ; st -> codecpar -> format = ( enum AVPixelFormat ) pix_fmt_ul -> id ; if ( st -> codecpar -> format == AV_PIX_FMT_NONE ) { st -> codecpar -> codec_tag = mxf_get_codec_ul ( ff_mxf_codec_tag_uls , & descriptor -> essence_codec_ul ) -> id ; if ( ! st -> codecpar -> codec_tag ) { if ( descriptor -> horiz_subsampling == 2 && descriptor -> vert_subsampling == 1 && descriptor -> component_depth == 8 ) { st -> codecpar -> format = AV_PIX_FMT_UYVY422 ; } } } } } st -> need_parsing = AVSTREAM_PARSE_HEADERS ; if ( material_track -> sequence -> origin ) { av_dict_set_int ( & st -> metadata , ""material_track_origin"" , material_track -> sequence -> origin , 0 ) ; } if ( source_track -> sequence -> origin ) { av_dict_set_int ( & st -> metadata , ""source_track_origin"" , source_track -> sequence -> origin , 0 ) ; } if ( descriptor -> aspect_ratio . num && descriptor -> aspect_ratio . den ) st -> display_aspect_ratio = descriptor -> aspect_ratio ; } else if ( st -> codecpar -> codec_type == AVMEDIA_TYPE_AUDIO ) { container_ul = mxf_get_codec_ul ( mxf_sound_essence_container_uls , essence_container_ul ) ; if ( st -> codecpar -> codec_id == AV_CODEC_ID_NONE || ( st -> codecpar -> codec_id == AV_CODEC_ID_PCM_ALAW && ( enum AVCodecID ) container_ul -> id != AV_CODEC_ID_NONE ) ) st -> codecpar -> codec_id = ( enum AVCodecID ) container_ul -> id ; st -> codecpar -> channels = descriptor -> channels ; st -> codecpar -> bits_per_coded_sample = descriptor -> bits_per_sample ; if ( descriptor -> sample_rate . den > 0 ) { st -> codecpar -> sample_rate = descriptor -> sample_rate . num / descriptor -> sample_rate . den ; avpriv_set_pts_info ( st , 64 , descriptor -> sample_rate . den , descriptor -> sample_rate . num ) ; } else { av_log ( mxf -> fc , AV_LOG_WARNING , ""invalidsamplerate(%d/%d)"" ""foundforstream#%d,timebaseforcedto1/48000\\n"" , descriptor -> sample_rate . num , descriptor -> sample_rate . den , st -> index ) ; avpriv_set_pts_info ( st , 64 , 1 , 48000 ) ; } if ( st -> duration != AV_NOPTS_VALUE ) st -> duration = av_rescale_q ( st -> duration , av_inv_q ( material_track -> edit_rate ) , st -> time_base ) ; if ( st -> codecpar -> codec_id == AV_CODEC_ID_PCM_S16LE ) { if ( descriptor -> bits_per_sample > 16 && descriptor -> bits_per_sample <= 24 ) st -> codecpar -> codec_id = AV_CODEC_ID_PCM_S24LE ; else if ( descriptor -> bits_per_sample == 32 ) st -> codecpar -> codec_id = AV_CODEC_ID_PCM_S32LE ; } else if ( st -> codecpar -> codec_id == AV_CODEC_ID_PCM_S16BE ) { if ( descriptor -> bits_per_sample > 16 && descriptor -> bits_per_sample <= 24 ) st -> codecpar -> codec_id = AV_CODEC_ID_PCM_S24BE ; else if ( descriptor -> bits_per_sample == 32 ) st -> codecpar -> codec_id = AV_CODEC_ID_PCM_S32BE ; } else if ( st -> codecpar -> codec_id == AV_CODEC_ID_MP2 ) { st -> need_parsing = AVSTREAM_PARSE_FULL ; } } else if ( st -> codecpar -> codec_type == AVMEDIA_TYPE_DATA ) { enum AVMediaType type ; container_ul = mxf_get_codec_ul ( mxf_data_essence_container_uls , essence_container_ul ) ; if ( st -> codecpar -> codec_id == AV_CODEC_ID_NONE ) st -> codecpar -> codec_id = container_ul -> id ; type = avcodec_get_type ( st -> codecpar -> codec_id ) ; if ( type == AVMEDIA_TYPE_SUBTITLE ) st -> codecpar -> codec_type = type ; if ( container_ul -> desc ) av_dict_set ( & st -> metadata , ""data_type"" , container_ul -> desc , 0 ) ; } if ( descriptor -> extradata ) { if ( ! ff_alloc_extradata ( st -> codecpar , descriptor -> extradata_size ) ) { memcpy ( st -> codecpar -> extradata , descriptor -> extradata , descriptor -> extradata_size ) ; } } else if ( st -> codecpar -> codec_id == AV_CODEC_ID_H264 ) { int coded_width = mxf_get_codec_ul ( mxf_intra_only_picture_coded_width , & descriptor -> essence_codec_ul ) -> id ; if ( coded_width ) st -> codecpar -> width = coded_width ; ret = ff_generate_avci_extradata ( st ) ; if ( ret < 0 ) return ret ; } if ( st -> codecpar -> codec_type != AVMEDIA_TYPE_DATA && source_track -> wrapping != FrameWrapped ) { st -> need_parsing = AVSTREAM_PARSE_TIMESTAMPS ; } } ret = 0 ; fail_and_free : return ret ; } "," av_log ( mxf -> fc ",FFmpeg@FFmpeg/bab0716c7f4793ec42e05a5aa7e80d82a0dd4e75,CVE-2018-1999014,https://github.com/FFmpeg/FFmpeg/commit/bab0716c7f4793ec42e05a5aa7e80d82a0dd4e75,2018-07-23T15:29Z 77,CWE-59,"CWE-59 static int mount_entry_on_relative_rootfs ( struct mntent * mntent , const char * rootfs ) { char path [ MAXPATHLEN ] ; int ret ; ret = snprintf ( path , sizeof ( path ) , ""%s/%s"" , rootfs , mntent -> mnt_dir ) ; if ( ret >= sizeof ( path ) ) { ERROR ( ""pathnametoolong"" ) ; return - 1 ; } return mount_entry_on_generic ( mntent , path ) ; } "," mntent , path , rootfs ",lxc@lxc/592fd47a6245508b79fe6ac819fe6d3b2c1289be,CVE-2015-1335,https://github.com/lxc/lxc/commit/592fd47a6245508b79fe6ac819fe6d3b2c1289be,2015-10-01T20:59Z 78,CWE-119,"CWE-119 int id3_skip ( SF_PRIVATE * psf ) { unsigned char buf [ 10 ] ; memset ( buf , 0 , sizeof ( buf ) ) ; psf_binheader_readf ( psf , ""pb"" , 0 , buf , 10 ) ; if ( buf [ 0 ] == 'I' && buf [ 1 ] == 'D' && buf [ 2 ] == '3' ) { int offset = buf [ 6 ] & 0x7f ; offset = ( offset << 7 ) | ( buf [ 7 ] & 0x7f ) ; offset = ( offset << 7 ) | ( buf [ 8 ] & 0x7f ) ; offset = ( offset << 7 ) | ( buf [ 9 ] & 0x7f ) ; psf_log_printf ( psf , ""ID3length:%d\\n--------------------\\n"" , offset ) ; if ( offset < 0 ) return 0 ; psf -> fileoffset += offset + 10 ; psf_binheader_readf ( psf , ""p"" , psf -> fileoffset ) ; return 1 ; } ; return 0 ; } "," + 10 ; if ( psf -> fileoffset < psf -> filelength ) { ; } ; } ; ",erikd@libsndfile/f457b7b5ecfe91697ed01cfc825772c4d8de1236,CVE-2017-7586,https://github.com/erikd/libsndfile/commit/f457b7b5ecfe91697ed01cfc825772c4d8de1236,2017-04-07T20:59Z 79,CWE-125,"CWE-125 static int juniper_parse_header ( netdissect_options * ndo , const u_char * p , const struct pcap_pkthdr * h , struct juniper_l2info_t * l2info ) { const struct juniper_cookie_table_t * lp = juniper_cookie_table ; u_int idx , jnx_ext_len , jnx_header_len = 0 ; uint8_t tlv_type , tlv_len ; uint32_t control_word ; int tlv_value ; const u_char * tptr ; l2info -> header_len = 0 ; l2info -> cookie_len = 0 ; l2info -> proto = 0 ; l2info -> length = h -> len ; l2info -> caplen = h -> caplen ; ND_TCHECK2 ( p [ 0 ] , 4 ) ; l2info -> flags = p [ 3 ] ; l2info -> direction = p [ 3 ] & JUNIPER_BPF_PKT_IN ; if ( EXTRACT_24BITS ( p ) != JUNIPER_MGC_NUMBER ) { ND_PRINT ( ( ndo , ""nomagic-numberfound!"" ) ) ; return 0 ; } if ( ndo -> ndo_eflag ) ND_PRINT ( ( ndo , ""%3s"" , tok2str ( juniper_direction_values , ""---"" , l2info -> direction ) ) ) ; jnx_header_len = 4 ; if ( ndo -> ndo_vflag > 1 ) ND_PRINT ( ( ndo , ""\\n\\tJuniperPCAPFlags[%s]"" , bittok2str ( jnx_flag_values , ""none"" , l2info -> flags ) ) ) ; if ( ( l2info -> flags & JUNIPER_BPF_EXT ) == JUNIPER_BPF_EXT ) { tptr = p + jnx_header_len ; ND_TCHECK2 ( tptr [ 0 ] , 2 ) ; jnx_ext_len = EXTRACT_16BITS ( tptr ) ; jnx_header_len += 2 ; tptr += 2 ; jnx_header_len += jnx_ext_len ; if ( ndo -> ndo_vflag > 1 ) ND_PRINT ( ( ndo , "",PCAPExtension(s)totallength%u"" , jnx_ext_len ) ) ; ND_TCHECK2 ( tptr [ 0 ] , jnx_ext_len ) ; while ( jnx_ext_len > JUNIPER_EXT_TLV_OVERHEAD ) { tlv_type = * ( tptr ++ ) ; tlv_len = * ( tptr ++ ) ; tlv_value = 0 ; if ( tlv_type == 0 || tlv_len == 0 ) break ; if ( tlv_len + JUNIPER_EXT_TLV_OVERHEAD > jnx_ext_len ) goto trunc ; if ( ndo -> ndo_vflag > 1 ) ND_PRINT ( ( ndo , ""\\n\\t%sExtensionTLV#%u,length%u,value"" , tok2str ( jnx_ext_tlv_values , ""Unknown"" , tlv_type ) , tlv_type , tlv_len ) ) ; tlv_value = juniper_read_tlv_value ( tptr , tlv_type , tlv_len ) ; switch ( tlv_type ) { case JUNIPER_EXT_TLV_IFD_NAME : break ; case JUNIPER_EXT_TLV_IFD_MEDIATYPE : case JUNIPER_EXT_TLV_TTP_IFD_MEDIATYPE : if ( tlv_value != - 1 ) { if ( ndo -> ndo_vflag > 1 ) ND_PRINT ( ( ndo , ""%s(%u)"" , tok2str ( juniper_ifmt_values , ""Unknown"" , tlv_value ) , tlv_value ) ) ; } break ; case JUNIPER_EXT_TLV_IFL_ENCAPS : case JUNIPER_EXT_TLV_TTP_IFL_ENCAPS : if ( tlv_value != - 1 ) { if ( ndo -> ndo_vflag > 1 ) ND_PRINT ( ( ndo , ""%s(%u)"" , tok2str ( juniper_ifle_values , ""Unknown"" , tlv_value ) , tlv_value ) ) ; } break ; case JUNIPER_EXT_TLV_IFL_IDX : case JUNIPER_EXT_TLV_IFL_UNIT : case JUNIPER_EXT_TLV_IFD_IDX : default : if ( tlv_value != - 1 ) { if ( ndo -> ndo_vflag > 1 ) ND_PRINT ( ( ndo , ""%u"" , tlv_value ) ) ; } break ; } tptr += tlv_len ; jnx_ext_len -= tlv_len + JUNIPER_EXT_TLV_OVERHEAD ; } if ( ndo -> ndo_vflag > 1 ) ND_PRINT ( ( ndo , ""\\n\\t-----originalpacket-----\\n\\t"" ) ) ; } if ( ( l2info -> flags & JUNIPER_BPF_NO_L2 ) == JUNIPER_BPF_NO_L2 ) { if ( ndo -> ndo_eflag ) ND_PRINT ( ( ndo , ""no-L2-hdr,"" ) ) ; ND_TCHECK2 ( p [ jnx_header_len + 4 ] , 1 ) ; if ( ip_heuristic_guess ( ndo , p + jnx_header_len + 4 , l2info -> length - ( jnx_header_len + 4 ) ) == 0 ) ND_PRINT ( ( ndo , ""noIP-hdrfound!"" ) ) ; l2info -> header_len = jnx_header_len + 4 ; return 0 ; } l2info -> header_len = jnx_header_len ; p += l2info -> header_len ; l2info -> length -= l2info -> header_len ; l2info -> caplen -= l2info -> header_len ; ND_TCHECK ( p [ 0 ] ) ; while ( lp -> s != NULL ) { if ( lp -> pictype == l2info -> pictype ) { l2info -> cookie_len += lp -> cookie_len ; switch ( p [ 0 ] ) { case LS_COOKIE_ID : l2info -> cookie_type = LS_COOKIE_ID ; l2info -> cookie_len += 2 ; break ; case AS_COOKIE_ID : l2info -> cookie_type = AS_COOKIE_ID ; l2info -> cookie_len = 8 ; break ; default : l2info -> bundle = l2info -> cookie [ 0 ] ; break ; } # ifdef DLT_JUNIPER_MFR if ( l2info -> pictype == DLT_JUNIPER_MFR && ( p [ 0 ] & MFR_BE_MASK ) == MFR_BE_MASK ) { l2info -> cookie_len = 0 ; } # endif l2info -> header_len += l2info -> cookie_len ; l2info -> length -= l2info -> cookie_len ; l2info -> caplen -= l2info -> cookie_len ; if ( ndo -> ndo_eflag ) ND_PRINT ( ( ndo , ""%s-PIC,cookie-len%u"" , lp -> s , l2info -> cookie_len ) ) ; if ( l2info -> cookie_len > 0 ) { ND_TCHECK2 ( p [ 0 ] , l2info -> cookie_len ) ; if ( ndo -> ndo_eflag ) ND_PRINT ( ( ndo , "",cookie0x"" ) ) ; for ( idx = 0 ; idx < l2info -> cookie_len ; idx ++ ) { l2info -> cookie [ idx ] = p [ idx ] ; if ( ndo -> ndo_eflag ) ND_PRINT ( ( ndo , ""%02x"" , p [ idx ] ) ) ; } } if ( ndo -> ndo_eflag ) ND_PRINT ( ( ndo , "":"" ) ) ; l2info -> proto = EXTRACT_16BITS ( p + l2info -> cookie_len ) ; break ; } ++ lp ; } p += l2info -> cookie_len ; switch ( l2info -> pictype ) { # ifdef DLT_JUNIPER_MLPPP case DLT_JUNIPER_MLPPP : switch ( l2info -> cookie_type ) { case LS_COOKIE_ID : l2info -> bundle = l2info -> cookie [ 1 ] ; break ; case AS_COOKIE_ID : l2info -> bundle = ( EXTRACT_16BITS ( & l2info -> cookie [ 6 ] ) >> 3 ) & 0xfff ; l2info -> proto = ( l2info -> cookie [ 5 ] ) & JUNIPER_LSQ_L3_PROTO_MASK ; break ; default : l2info -> bundle = l2info -> cookie [ 0 ] ; break ; } break ; # endif # ifdef DLT_JUNIPER_MLFR case DLT_JUNIPER_MLFR : switch ( l2info -> cookie_type ) { case LS_COOKIE_ID : ND_TCHECK2 ( p [ 0 ] , 2 ) ; l2info -> bundle = l2info -> cookie [ 1 ] ; l2info -> proto = EXTRACT_16BITS ( p ) ; l2info -> header_len += 2 ; l2info -> length -= 2 ; l2info -> caplen -= 2 ; break ; case AS_COOKIE_ID : l2info -> bundle = ( EXTRACT_16BITS ( & l2info -> cookie [ 6 ] ) >> 3 ) & 0xfff ; l2info -> proto = ( l2info -> cookie [ 5 ] ) & JUNIPER_LSQ_L3_PROTO_MASK ; break ; default : l2info -> bundle = l2info -> cookie [ 0 ] ; l2info -> header_len += 2 ; l2info -> length -= 2 ; l2info -> caplen -= 2 ; break ; } break ; # endif # ifdef DLT_JUNIPER_MFR case DLT_JUNIPER_MFR : switch ( l2info -> cookie_type ) { case LS_COOKIE_ID : ND_TCHECK2 ( p [ 0 ] , 2 ) ; l2info -> bundle = l2info -> cookie [ 1 ] ; l2info -> proto = EXTRACT_16BITS ( p ) ; l2info -> header_len += 2 ; l2info -> length -= 2 ; l2info -> caplen -= 2 ; break ; case AS_COOKIE_ID : l2info -> bundle = ( EXTRACT_16BITS ( & l2info -> cookie [ 6 ] ) >> 3 ) & 0xfff ; l2info -> proto = ( l2info -> cookie [ 5 ] ) & JUNIPER_LSQ_L3_PROTO_MASK ; break ; default : l2info -> bundle = l2info -> cookie [ 0 ] ; break ; } break ; # endif # ifdef DLT_JUNIPER_ATM2 case DLT_JUNIPER_ATM2 : ND_TCHECK2 ( p [ 0 ] , 4 ) ; if ( l2info -> cookie [ 7 ] & ATM2_PKT_TYPE_MASK ) { control_word = EXTRACT_32BITS ( p ) ; switch ( control_word ) { case 0 : case 0x08000000 : case 0x08380000 : l2info -> header_len += 4 ; break ; default : break ; } if ( ndo -> ndo_eflag ) ND_PRINT ( ( ndo , ""control-word0x%08x"" , control_word ) ) ; } break ; # endif # ifdef DLT_JUNIPER_GGSN case DLT_JUNIPER_GGSN : break ; # endif # ifdef DLT_JUNIPER_ATM1 case DLT_JUNIPER_ATM1 : break ; # endif # ifdef DLT_JUNIPER_PPP case DLT_JUNIPER_PPP : break ; # endif # ifdef DLT_JUNIPER_CHDLC case DLT_JUNIPER_CHDLC : break ; # endif # ifdef DLT_JUNIPER_ETHER case DLT_JUNIPER_ETHER : break ; # endif # ifdef DLT_JUNIPER_FRELAY case DLT_JUNIPER_FRELAY : break ; # endif default : ND_PRINT ( ( ndo , ""UnknownJuniperDLT_type%u:"" , l2info -> pictype ) ) ; break ; } if ( ndo -> ndo_eflag > 1 ) ND_PRINT ( ( ndo , ""hlen%u,proto0x%04x,"" , l2info -> header_len , l2info -> proto ) ) ; return 1 ; trunc : ND_PRINT ( ( ndo , ""[|juniper_hdr],length%u"" , h -> len ) ) ; return 0 ; } "," ) ) ; ND_TCHECK_16BITS ( p + l2info -> cookie_len ) ; ",the-tcpdump-group@tcpdump/42073d54c53a496be40ae84152bbfe2c923ac7bc,CVE-2017-13004,https://github.com/the-tcpdump-group/tcpdump/commit/42073d54c53a496be40ae84152bbfe2c923ac7bc,2017-09-14T06:29Z 80,CWE-787,"CWE-787 static unsigned int ipv6_defrag ( void * priv , struct sk_buff * skb , const struct nf_hook_state * state ) { int err ; # if IS_ENABLED ( CONFIG_NF_CONNTRACK ) if ( skb -> nfct && ! nf_ct_is_template ( ( struct nf_conn * ) skb -> nfct ) ) return NF_ACCEPT ; # endif err = nf_ct_frag6_gather ( state -> net , skb , nf_ct6_defrag_user ( state -> hook , skb ) ) ; if ( err == - EINPROGRESS ) return NF_STOLEN ; return NF_ACCEPT ; } "," NF_STOLEN ; return err == 0 ? NF_ACCEPT : NF_DROP ; } ",torvalds@linux/9b57da0630c9fd36ed7a20fc0f98dc82cc0777fa,CVE-2016-9755,https://github.com/torvalds/linux/commit/9b57da0630c9fd36ed7a20fc0f98dc82cc0777fa,2016-12-28T07:59Z 81,CWE-200,"CWE-200 static int xfrm_alloc_replay_state_esn ( struct xfrm_replay_state_esn * * replay_esn , struct xfrm_replay_state_esn * * preplay_esn , struct nlattr * rta ) { struct xfrm_replay_state_esn * p , * pp , * up ; if ( ! rta ) return 0 ; up = nla_data ( rta ) ; p = kmemdup ( up , xfrm_replay_state_esn_len ( up ) , GFP_KERNEL ) ; if ( ! p ) return - ENOMEM ; pp = kmemdup ( up , xfrm_replay_state_esn_len ( up ) , GFP_KERNEL ) ; if ( ! pp ) { kfree ( p ) ; return - ENOMEM ; } * replay_esn = p ; * preplay_esn = pp ; return 0 ; } "," * up ; int klen , ulen ; rta ) ; klen = xfrm_replay_state_esn_len ( up ( up ) ; ulen = nla_len ( rta ) >= klen ? klen : sizeof ( * up ) ; p = kzalloc ( klen ; pp = kzalloc ( klen , GFP_KERNEL ) ENOMEM ; } memcpy ( p , up , ulen ) ; memcpy ( pp , up , ulen ) ; ",torvalds@linux/ecd7918745234e423dd87fcc0c077da557909720,CVE-2012-6536,https://github.com/torvalds/linux/commit/ecd7918745234e423dd87fcc0c077da557909720,2013-03-15T20:55Z 82,CWE-416,"CWE-416 int ipmi_si_mem_setup ( struct si_sm_io * io ) { unsigned long addr = io -> addr_data ; int mapsize , idx ; if ( ! addr ) return - ENODEV ; io -> io_cleanup = mem_cleanup ; switch ( io -> regsize ) { case 1 : io -> inputb = intf_mem_inb ; io -> outputb = intf_mem_outb ; break ; case 2 : io -> inputb = intf_mem_inw ; io -> outputb = intf_mem_outw ; break ; case 4 : io -> inputb = intf_mem_inl ; io -> outputb = intf_mem_outl ; break ; # ifdef readq case 8 : io -> inputb = mem_inq ; io -> outputb = mem_outq ; break ; # endif default : dev_warn ( io -> dev , ""Invalidregistersize:%d\\n"" , io -> regsize ) ; return - EINVAL ; } for ( idx = 0 ; idx < io -> io_size ; idx ++ ) { if ( request_mem_region ( addr + idx * io -> regspacing , io -> regsize , DEVICE_NAME ) == NULL ) { mem_region_cleanup ( io , idx ) ; return - EIO ; } } mapsize = ( ( io -> io_size * io -> regspacing ) - ( io -> regspacing - io -> regsize ) ) ; io -> addr = ioremap ( addr , mapsize ) ; if ( io -> addr == NULL ) { mem_region_cleanup ( io , io -> io_size ) ; return - EIO ; } return 0 ; } "," - ENODEV ; switch ( io EIO ; } io -> io_cleanup = mem_cleanup ; ",torvalds@linux/401e7e88d4ef80188ffa07095ac00456f901b8c4,CVE-2019-11811,https://github.com/torvalds/linux/commit/401e7e88d4ef80188ffa07095ac00456f901b8c4,2019-05-07T14:29Z 83,CWE-190,"CWE-190 static MagickRealType ApplyEvaluateOperator ( RandomInfo * random_info , const Quantum pixel , const MagickEvaluateOperator op , const MagickRealType value ) { MagickRealType result ; result = 0.0 ; switch ( op ) { case UndefinedEvaluateOperator : break ; case AbsEvaluateOperator : { result = ( MagickRealType ) fabs ( ( double ) ( pixel + value ) ) ; break ; } case AddEvaluateOperator : { result = ( MagickRealType ) ( pixel + value ) ; break ; } case AddModulusEvaluateOperator : { result = pixel + value ; result -= ( QuantumRange + 1.0 ) * floor ( ( double ) result / ( QuantumRange + 1.0 ) ) ; break ; } case AndEvaluateOperator : { result = ( MagickRealType ) ( ( size_t ) pixel & ( size_t ) ( value + 0.5 ) ) ; break ; } case CosineEvaluateOperator : { result = ( MagickRealType ) ( QuantumRange * ( 0.5 * cos ( ( double ) ( 2.0 * MagickPI * QuantumScale * pixel * value ) ) + 0.5 ) ) ; break ; } case DivideEvaluateOperator : { result = pixel / ( value == 0.0 ? 1.0 : value ) ; break ; } case ExponentialEvaluateOperator : { result = ( MagickRealType ) ( QuantumRange * exp ( ( double ) ( value * QuantumScale * pixel ) ) ) ; break ; } case GaussianNoiseEvaluateOperator : { result = ( MagickRealType ) GenerateDifferentialNoise ( random_info , pixel , GaussianNoise , value ) ; break ; } case ImpulseNoiseEvaluateOperator : { result = ( MagickRealType ) GenerateDifferentialNoise ( random_info , pixel , ImpulseNoise , value ) ; break ; } case LaplacianNoiseEvaluateOperator : { result = ( MagickRealType ) GenerateDifferentialNoise ( random_info , pixel , LaplacianNoise , value ) ; break ; } case LeftShiftEvaluateOperator : { result = ( MagickRealType ) ( ( size_t ) pixel << ( size_t ) ( value + 0.5 ) ) ; break ; } case LogEvaluateOperator : { if ( ( QuantumScale * pixel ) >= MagickEpsilon ) result = ( MagickRealType ) ( QuantumRange * log ( ( double ) ( QuantumScale * value * pixel + 1.0 ) ) / log ( ( double ) ( value + 1.0 ) ) ) ; break ; } case MaxEvaluateOperator : { result = ( MagickRealType ) EvaluateMax ( ( double ) pixel , value ) ; break ; } case MeanEvaluateOperator : { result = ( MagickRealType ) ( pixel + value ) ; break ; } case MedianEvaluateOperator : { result = ( MagickRealType ) ( pixel + value ) ; break ; } case MinEvaluateOperator : { result = ( MagickRealType ) MagickMin ( ( double ) pixel , value ) ; break ; } case MultiplicativeNoiseEvaluateOperator : { result = ( MagickRealType ) GenerateDifferentialNoise ( random_info , pixel , MultiplicativeGaussianNoise , value ) ; break ; } case MultiplyEvaluateOperator : { result = ( MagickRealType ) ( value * pixel ) ; break ; } case OrEvaluateOperator : { result = ( MagickRealType ) ( ( size_t ) pixel | ( size_t ) ( value + 0.5 ) ) ; break ; } case PoissonNoiseEvaluateOperator : { result = ( MagickRealType ) GenerateDifferentialNoise ( random_info , pixel , PoissonNoise , value ) ; break ; } case PowEvaluateOperator : { result = ( MagickRealType ) ( QuantumRange * pow ( ( double ) ( QuantumScale * pixel ) , ( double ) value ) ) ; break ; } case RightShiftEvaluateOperator : { result = ( MagickRealType ) ( ( size_t ) pixel >> ( size_t ) ( value + 0.5 ) ) ; break ; } case RootMeanSquareEvaluateOperator : { result = ( MagickRealType ) ( pixel * pixel + value ) ; break ; } case SetEvaluateOperator : { result = value ; break ; } case SineEvaluateOperator : { result = ( MagickRealType ) ( QuantumRange * ( 0.5 * sin ( ( double ) ( 2.0 * MagickPI * QuantumScale * pixel * value ) ) + 0.5 ) ) ; break ; } case SubtractEvaluateOperator : { result = ( MagickRealType ) ( pixel - value ) ; break ; } case SumEvaluateOperator : { result = ( MagickRealType ) ( pixel + value ) ; break ; } case ThresholdEvaluateOperator : { result = ( MagickRealType ) ( ( ( MagickRealType ) pixel <= value ) ? 0 : QuantumRange ) ; break ; } case ThresholdBlackEvaluateOperator : { result = ( MagickRealType ) ( ( ( MagickRealType ) pixel <= value ) ? 0 : pixel ) ; break ; } case ThresholdWhiteEvaluateOperator : { result = ( MagickRealType ) ( ( ( MagickRealType ) pixel > value ) ? QuantumRange : pixel ) ; break ; } case UniformNoiseEvaluateOperator : { result = ( MagickRealType ) GenerateDifferentialNoise ( random_info , pixel , UniformNoise , value ) ; break ; } case XorEvaluateOperator : { result = ( MagickRealType ) ( ( size_t ) pixel ^ ( size_t ) ( value + 0.5 ) ) ; break ; } } return ( result ) ; } "," ) ( ( ssize_t ) pixel & pixel & ( ssize_t ) ( value ) ( ( ssize_t ) pixel << pixel << ( ssize_t ) ( value ) ( ( ssize_t ) pixel | pixel | ( ssize_t ) ( value ) ( ( ssize_t ) pixel >> pixel >> ( ssize_t ) ( value ) ( ( ssize_t ) pixel ^ pixel ^ ( ssize_t ) ( value ",ImageMagick@ImageMagick6/3e21bc8a58b4ae38d24c7e283837cc279f35b6a5,CVE-2020-27764,https://github.com/ImageMagick/ImageMagick6/commit/3e21bc8a58b4ae38d24c7e283837cc279f35b6a5,2020-12-03T17:15Z 84,CWE-20,"CWE-20 bt_status_t btif_storage_add_bonded_device ( bt_bdaddr_t * remote_bd_addr , LINK_KEY link_key , uint8_t key_type , uint8_t pin_length ) { bdstr_t bdstr ; bdaddr_to_string ( remote_bd_addr , bdstr , sizeof ( bdstr ) ) ; int ret = btif_config_set_int ( bdstr , ""LinkKeyType"" , ( int ) key_type ) ; ret &= btif_config_set_int ( bdstr , ""PinLength"" , ( int ) pin_length ) ; ret &= btif_config_set_bin ( bdstr , ""LinkKey"" , link_key , sizeof ( LINK_KEY ) ) ; btif_config_flush ( ) ; return ret ? BT_STATUS_SUCCESS : BT_STATUS_FAIL ; } "," ) ) ; if ( is_restricted_mode ( ) ) { BTIF_TRACE_WARNING ( ""%s:\'%s\'pairingwillberemovedifunrestricted"" , __func__ , bdstr ) ; btif_config_set_int ( bdstr , ""Restricted"" , 1 ) ; } ",system@bt/37c88107679d36c419572732b4af6e18bb2f7dce,CVE-2016-3760,https://android.googlesource.com/platform/system/bt/+/37c88107679d36c419572732b4af6e18bb2f7dce,2016-07-11T02:00Z 85,CWE-119,"CWE-119 void jpc_qmfb_split_colres ( jpc_fix_t * a , int numrows , int numcols , int stride , int parity ) { int bufsize = JPC_CEILDIVPOW2 ( numrows , 1 ) ; jpc_fix_t splitbuf [ QMFB_SPLITBUFSIZE * JPC_QMFB_COLGRPSIZE ] ; jpc_fix_t * buf = splitbuf ; jpc_fix_t * srcptr ; jpc_fix_t * dstptr ; register jpc_fix_t * srcptr2 ; register jpc_fix_t * dstptr2 ; register int n ; register int i ; int m ; int hstartcol ; if ( bufsize > QMFB_SPLITBUFSIZE ) { if ( ! ( buf = jas_alloc2 ( bufsize , sizeof ( jpc_fix_t ) ) ) ) { abort ( ) ; } } if ( numrows >= 2 ) { hstartcol = ( numrows + 1 - parity ) >> 1 ; m = numrows - hstartcol ; n = m ; dstptr = buf ; srcptr = & a [ ( 1 - parity ) * stride ] ; while ( n -- > 0 ) { dstptr2 = dstptr ; srcptr2 = srcptr ; for ( i = 0 ; i < numcols ; ++ i ) { * dstptr2 = * srcptr2 ; ++ dstptr2 ; ++ srcptr2 ; } dstptr += numcols ; srcptr += stride << 1 ; } dstptr = & a [ ( 1 - parity ) * stride ] ; srcptr = & a [ ( 2 - parity ) * stride ] ; n = numrows - m - ( ! parity ) ; while ( n -- > 0 ) { dstptr2 = dstptr ; srcptr2 = srcptr ; for ( i = 0 ; i < numcols ; ++ i ) { * dstptr2 = * srcptr2 ; ++ dstptr2 ; ++ srcptr2 ; } dstptr += stride ; srcptr += stride << 1 ; } dstptr = & a [ hstartcol * stride ] ; srcptr = buf ; n = m ; while ( n -- > 0 ) { dstptr2 = dstptr ; srcptr2 = srcptr ; for ( i = 0 ; i < numcols ; ++ i ) { * dstptr2 = * srcptr2 ; ++ dstptr2 ; ++ srcptr2 ; } dstptr += stride ; srcptr += numcols ; } } if ( buf != splitbuf ) { jas_free ( buf ) ; } } "," ( buf = jas_alloc3 ( bufsize , numcols , sizeof ( ",mdadams@jasper/4a59cfaf9ab3d48fca4a15c0d2674bf7138e3d1a,CVE-2016-8654,https://github.com/mdadams/jasper/commit/4a59cfaf9ab3d48fca4a15c0d2674bf7138e3d1a,2018-08-01T16:29Z 86,CWE-119,"CWE-119 vpx_codec_err_t vpx_codec_enc_config_default ( vpx_codec_iface_t * iface , vpx_codec_enc_cfg_t * cfg , unsigned int usage ) { vpx_codec_err_t res ; vpx_codec_enc_cfg_map_t * map ; if ( ! iface || ! cfg || usage > INT_MAX ) res = VPX_CODEC_INVALID_PARAM ; else if ( ! ( iface -> caps & VPX_CODEC_CAP_ENCODER ) ) res = VPX_CODEC_INCAPABLE ; else { res = VPX_CODEC_INVALID_PARAM ; for ( map = iface -> enc . cfg_maps ; map -> usage >= 0 ; map ++ ) { if ( map -> usage == ( int ) usage ) { * cfg = map -> cfg ; cfg -> g_usage = usage ; res = VPX_CODEC_OK ; break ; } } } return res ; } "," vpx_codec_enc_cfg_map_t * map ; int i ; for ( i = 0 ; i < iface -> enc . cfg_map_count ; ++ i ) { enc . cfg_maps + i ; if ( map ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 87,CWE-20,"CWE-20 static int netbk_set_skb_gso ( struct xenvif * vif , struct sk_buff * skb , struct xen_netif_extra_info * gso ) { if ( ! gso -> u . gso . size ) { netdev_dbg ( vif -> dev , ""GSOsizemustnotbezero.\\n"" ) ; return - EINVAL ; } if ( gso -> u . gso . type != XEN_NETIF_GSO_TYPE_TCPV4 ) { netdev_dbg ( vif -> dev , ""BadGSOtype%d.\\n"" , gso -> u . gso . type ) ; return - EINVAL ; } skb_shinfo ( skb ) -> gso_size = gso -> u . gso . size ; skb_shinfo ( skb ) -> gso_type = SKB_GSO_TCPV4 ; skb_shinfo ( skb ) -> gso_type |= SKB_GSO_DODGY ; skb_shinfo ( skb ) -> gso_segs = 0 ; return 0 ; } "," size ) { netdev_err ( vif -> dev , ""GSOsizemustnotbezero.\\n"" ) ; netbk_fatal_tx_err ( vif XEN_NETIF_GSO_TYPE_TCPV4 ) { netdev_err ( vif -> gso . type ) ; netbk_fatal_tx_err ( vif ",torvalds@linux/48856286b64e4b66ec62b94e504d0b29c1ade664,CVE-2013-0216,https://github.com/torvalds/linux/commit/48856286b64e4b66ec62b94e504d0b29c1ade664,2013-02-18T04:41Z 88,CWE-119,"CWE-119 static void show_object ( struct object * object , struct strbuf * path , const char * last , void * data ) { struct bitmap * base = data ; int bitmap_pos ; bitmap_pos = bitmap_position ( object -> oid . hash ) ; if ( bitmap_pos < 0 ) { char * name = path_name ( path , last ) ; bitmap_pos = ext_index_add_object ( object , name ) ; free ( name ) ; } bitmap_set ( base , bitmap_pos ) ; } "," * object , const char * const char * name , void * < 0 ) bitmap_pos = ext_index_add_object name ) ; bitmap_set ( base ",git@git/de1e67d0703894cb6ea782e36abb63976ab07e60,CVE-2016-2315,https://github.com/git/git/commit/de1e67d0703894cb6ea782e36abb63976ab07e60,2016-04-08T14:59Z 89,CWE-77,"CWE-77 int do_command ( unsigned char c ) { static int dtr_up = 0 ; int newbaud , newflow , newparity , newbits ; const char * xfr_cmd ; char * fname ; int r ; switch ( c ) { case KEY_EXIT : return 1 ; case KEY_QUIT : term_set_hupcl ( tty_fd , 0 ) ; term_flush ( tty_fd ) ; term_apply ( tty_fd ) ; term_erase ( tty_fd ) ; return 1 ; case KEY_STATUS : show_status ( dtr_up ) ; break ; case KEY_PULSE : fd_printf ( STO , ""\\r\\n***pulseDTR***\\r\\n"" ) ; if ( term_pulse_dtr ( tty_fd ) < 0 ) fd_printf ( STO , ""***FAILED\\r\\n"" ) ; break ; case KEY_TOGGLE : if ( dtr_up ) r = term_lower_dtr ( tty_fd ) ; else r = term_raise_dtr ( tty_fd ) ; if ( r >= 0 ) dtr_up = ! dtr_up ; fd_printf ( STO , ""\\r\\n***DTR:%s***\\r\\n"" , dtr_up ? ""up"" : ""down"" ) ; break ; case KEY_BAUD_UP : case KEY_BAUD_DN : if ( c == KEY_BAUD_UP ) opts . baud = baud_up ( opts . baud ) ; else opts . baud = baud_down ( opts . baud ) ; term_set_baudrate ( tty_fd , opts . baud ) ; tty_q . len = 0 ; term_flush ( tty_fd ) ; term_apply ( tty_fd ) ; newbaud = term_get_baudrate ( tty_fd , NULL ) ; if ( opts . baud != newbaud ) { fd_printf ( STO , ""\\r\\n***baud:%d(%d)***\\r\\n"" , opts . baud , newbaud ) ; } else { fd_printf ( STO , ""\\r\\n***baud:%d***\\r\\n"" , opts . baud ) ; } set_tty_write_sz ( newbaud ) ; break ; case KEY_FLOW : opts . flow = flow_next ( opts . flow ) ; term_set_flowcntrl ( tty_fd , opts . flow ) ; tty_q . len = 0 ; term_flush ( tty_fd ) ; term_apply ( tty_fd ) ; newflow = term_get_flowcntrl ( tty_fd ) ; if ( opts . flow != newflow ) { fd_printf ( STO , ""\\r\\n***flow:%s(%s)***\\r\\n"" , flow_str [ opts . flow ] , flow_str [ newflow ] ) ; } else { fd_printf ( STO , ""\\r\\n***flow:%s***\\r\\n"" , flow_str [ opts . flow ] ) ; } break ; case KEY_PARITY : opts . parity = parity_next ( opts . parity ) ; term_set_parity ( tty_fd , opts . parity ) ; tty_q . len = 0 ; term_flush ( tty_fd ) ; term_apply ( tty_fd ) ; newparity = term_get_parity ( tty_fd ) ; if ( opts . parity != newparity ) { fd_printf ( STO , ""\\r\\n***parity:%s(%s)***\\r\\n"" , parity_str [ opts . parity ] , parity_str [ newparity ] ) ; } else { fd_printf ( STO , ""\\r\\n***parity:%s***\\r\\n"" , parity_str [ opts . parity ] ) ; } break ; case KEY_BITS : opts . databits = bits_next ( opts . databits ) ; term_set_databits ( tty_fd , opts . databits ) ; tty_q . len = 0 ; term_flush ( tty_fd ) ; term_apply ( tty_fd ) ; newbits = term_get_databits ( tty_fd ) ; if ( opts . databits != newbits ) { fd_printf ( STO , ""\\r\\n***databits:%d(%d)***\\r\\n"" , opts . databits , newbits ) ; } else { fd_printf ( STO , ""\\r\\n***databits:%d***\\r\\n"" , opts . databits ) ; } break ; case KEY_LECHO : opts . lecho = ! opts . lecho ; fd_printf ( STO , ""\\r\\n***localecho:%s***\\r\\n"" , opts . lecho ? ""yes"" : ""no"" ) ; break ; case KEY_SEND : case KEY_RECEIVE : xfr_cmd = ( c == KEY_SEND ) ? opts . send_cmd : opts . receive_cmd ; if ( xfr_cmd [ 0 ] == '\\0' ) { fd_printf ( STO , ""\\r\\n***commanddisabled***\\r\\n"" ) ; break ; } fname = read_filename ( ) ; if ( fname == NULL ) { fd_printf ( STO , ""***cannotreadfilename***\\r\\n"" ) ; break ; } run_cmd ( tty_fd , xfr_cmd , fname , NULL ) ; free ( fname ) ; break ; case KEY_BREAK : term_break ( tty_fd ) ; fd_printf ( STO , ""\\r\\n***breaksent***\\r\\n"" ) ; break ; default : break ; } return 0 ; } "," xfr_cmd , fname ) ; free ",npat-efault@picocom/1ebc60b20fbe9a02436d5cbbf8951714e749ddb1,CVE-2015-9059,https://github.com/npat-efault/picocom/commit/1ebc60b20fbe9a02436d5cbbf8951714e749ddb1,2017-05-28T00:29Z 90,CWE-416,"CWE-416 static void snd_usb_mixer_free ( struct usb_mixer_interface * mixer ) { kfree ( mixer -> id_elems ) ; if ( mixer -> urb ) { kfree ( mixer -> urb -> transfer_buffer ) ; usb_free_urb ( mixer -> urb ) ; } usb_free_urb ( mixer -> rc_urb ) ; kfree ( mixer -> rc_setup_packet ) ; kfree ( mixer ) ; } "," mixer ) { snd_usb_mixer_disconnect ( mixer ) ; ",torvalds@linux/124751d5e63c823092060074bd0abaae61aaa9c4,CVE-2017-16527,https://github.com/torvalds/linux/commit/124751d5e63c823092060074bd0abaae61aaa9c4,2017-11-04T01:29Z 91,CWE-416,"CWE-416 static int fanout_add ( struct sock * sk , u16 id , u16 type_flags ) { struct packet_sock * po = pkt_sk ( sk ) ; struct packet_fanout * f , * match ; u8 type = type_flags & 0xff ; u8 flags = type_flags >> 8 ; int err ; switch ( type ) { case PACKET_FANOUT_ROLLOVER : if ( type_flags & PACKET_FANOUT_FLAG_ROLLOVER ) return - EINVAL ; case PACKET_FANOUT_HASH : case PACKET_FANOUT_LB : case PACKET_FANOUT_CPU : case PACKET_FANOUT_RND : case PACKET_FANOUT_QM : case PACKET_FANOUT_CBPF : case PACKET_FANOUT_EBPF : break ; default : return - EINVAL ; } if ( ! po -> running ) return - EINVAL ; if ( po -> fanout ) return - EALREADY ; if ( type == PACKET_FANOUT_ROLLOVER || ( type_flags & PACKET_FANOUT_FLAG_ROLLOVER ) ) { po -> rollover = kzalloc ( sizeof ( * po -> rollover ) , GFP_KERNEL ) ; if ( ! po -> rollover ) return - ENOMEM ; atomic_long_set ( & po -> rollover -> num , 0 ) ; atomic_long_set ( & po -> rollover -> num_huge , 0 ) ; atomic_long_set ( & po -> rollover -> num_failed , 0 ) ; } mutex_lock ( & fanout_mutex ) ; match = NULL ; list_for_each_entry ( f , & fanout_list , list ) { if ( f -> id == id && read_pnet ( & f -> net ) == sock_net ( sk ) ) { match = f ; break ; } } err = - EINVAL ; if ( match && match -> flags != flags ) goto out ; if ( ! match ) { err = - ENOMEM ; match = kzalloc ( sizeof ( * match ) , GFP_KERNEL ) ; if ( ! match ) goto out ; write_pnet ( & match -> net , sock_net ( sk ) ) ; match -> id = id ; match -> type = type ; match -> flags = flags ; INIT_LIST_HEAD ( & match -> list ) ; spin_lock_init ( & match -> lock ) ; atomic_set ( & match -> sk_ref , 0 ) ; fanout_init_data ( match ) ; match -> prot_hook . type = po -> prot_hook . type ; match -> prot_hook . dev = po -> prot_hook . dev ; match -> prot_hook . func = packet_rcv_fanout ; match -> prot_hook . af_packet_priv = match ; match -> prot_hook . id_match = match_fanout_group ; dev_add_pack ( & match -> prot_hook ) ; list_add ( & match -> list , & fanout_list ) ; } err = - EINVAL ; if ( match -> type == type && match -> prot_hook . type == po -> prot_hook . type && match -> prot_hook . dev == po -> prot_hook . dev ) { err = - ENOSPC ; if ( atomic_read ( & match -> sk_ref ) < PACKET_FANOUT_MAX ) { __dev_remove_pack ( & po -> prot_hook ) ; po -> fanout = match ; atomic_inc ( & match -> sk_ref ) ; __fanout_link ( sk , po ) ; err = 0 ; } } out : mutex_unlock ( & fanout_mutex ) ; if ( err ) { kfree ( po -> rollover ) ; po -> rollover = NULL ; } return err ; } "," ) { struct packet_rollover * rollover = NULL ; struct EINVAL ; } mutex_lock ( & fanout_mutex ) ; err = - EINVAL ; -> running ) goto out ; err = - EALREADY ; if ( -> fanout ) goto out ; if ( ) ) { err = - ENOMEM ; rollover = kzalloc sizeof ( * rollover ) , if ( ! rollover ) goto out ; atomic_long_set ( atomic_long_set ( & rollover -> num atomic_long_set ( & rollover -> num_huge atomic_long_set ( & rollover -> num_failed 0 ) ; po -> rollover = rollover ; } match = NULL } out : if ( err && rollover ) { kfree ( rollover ) ; po -> rollover = NULL ; } fanout_mutex ) ; return err ; ",torvalds@linux/d199fab63c11998a602205f7ee7ff7c05c97164b,CVE-2017-6346,https://github.com/torvalds/linux/commit/d199fab63c11998a602205f7ee7ff7c05c97164b,2017-03-01T20:59Z 92,CWE-000,"CWE-000 static struct sock * sctp_v6_create_accept_sk ( struct sock * sk , struct sctp_association * asoc , bool kern ) { struct sock * newsk ; struct ipv6_pinfo * newnp , * np = inet6_sk ( sk ) ; struct sctp6_sock * newsctp6sk ; struct ipv6_txoptions * opt ; newsk = sk_alloc ( sock_net ( sk ) , PF_INET6 , GFP_KERNEL , sk -> sk_prot , kern ) ; if ( ! newsk ) goto out ; sock_init_data ( NULL , newsk ) ; sctp_copy_sock ( newsk , sk , asoc ) ; sock_reset_flag ( sk , SOCK_ZAPPED ) ; newsctp6sk = ( struct sctp6_sock * ) newsk ; inet_sk ( newsk ) -> pinet6 = & newsctp6sk -> inet6 ; sctp_sk ( newsk ) -> v4mapped = sctp_sk ( sk ) -> v4mapped ; newnp = inet6_sk ( newsk ) ; memcpy ( newnp , np , sizeof ( struct ipv6_pinfo ) ) ; rcu_read_lock ( ) ; opt = rcu_dereference ( np -> opt ) ; if ( opt ) opt = ipv6_dup_options ( newsk , opt ) ; RCU_INIT_POINTER ( newnp -> opt , opt ) ; rcu_read_unlock ( ) ; sctp_v6_to_sk_daddr ( & asoc -> peer . primary_addr , newsk ) ; newsk -> sk_v6_rcv_saddr = sk -> sk_v6_rcv_saddr ; sk_refcnt_debug_inc ( newsk ) ; if ( newsk -> sk_prot -> init ( newsk ) ) { sk_common_release ( newsk ) ; newsk = NULL ; } out : return newsk ; } "," ipv6_pinfo ) ) ; newnp -> ipv6_mc_list = NULL ; newnp -> ipv6_ac_list = NULL ; newnp -> ipv6_fl_list = NULL ",torvalds@linux/fdcee2cbb8438702ea1b328fb6e0ac5e9a40c7f8,CVE-2017-9075,https://github.com/torvalds/linux/commit/fdcee2cbb8438702ea1b328fb6e0ac5e9a40c7f8,2017-05-19T07:29Z 93,CWE-401,"CWE-401 static struct scatterlist * alloc_sgtable ( int size ) { int alloc_size , nents , i ; struct page * new_page ; struct scatterlist * iter ; struct scatterlist * table ; nents = DIV_ROUND_UP ( size , PAGE_SIZE ) ; table = kcalloc ( nents , sizeof ( * table ) , GFP_KERNEL ) ; if ( ! table ) return NULL ; sg_init_table ( table , nents ) ; iter = table ; for_each_sg ( table , iter , sg_nents ( table ) , i ) { new_page = alloc_page ( GFP_KERNEL ) ; if ( ! new_page ) { iter = table ; for_each_sg ( table , iter , sg_nents ( table ) , i ) { new_page = sg_page ( iter ) ; if ( new_page ) __free_page ( new_page ) ; } return NULL ; } alloc_size = min_t ( int , size , PAGE_SIZE ) ; size -= PAGE_SIZE ; sg_set_page ( iter , new_page , alloc_size , 0 ) ; } return table ; } "," ) ; } kfree ( table ) ; ",torvalds@linux/b4b814fec1a5a849383f7b3886b654a13abbda7d,CVE-2019-19058,https://github.com/torvalds/linux/commit/b4b814fec1a5a849383f7b3886b654a13abbda7d,2019-11-18T06:15Z 94,CWE-119,"CWE-119 void show_progress ( int frame_in , int frame_out , uint64_t dx_time ) { fprintf ( stderr , ""%ddecodedframes/%dshowedframesin%"" PRId64 ""us(%.2ffps)\\r"" , frame_in , frame_out , dx_time , ( double ) frame_out * 1000000.0 / ( double ) dx_time ) ; } "," static ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 95,CWE-416,"CWE-416 AV * dbd_st_fetch ( SV * sth , imp_sth_t * imp_sth ) { dTHX ; int num_fields , ChopBlanks , i , rc ; unsigned long * lengths ; AV * av ; int av_length , av_readonly ; MYSQL_ROW cols ; D_imp_dbh_from_sth ; MYSQL * svsock = imp_dbh -> pmysql ; imp_sth_fbh_t * fbh ; D_imp_xxh ( sth ) ; # if MYSQL_VERSION_ID >= SERVER_PREPARE_VERSION MYSQL_BIND * buffer ; # endif MYSQL_FIELD * fields ; if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\t->dbd_st_fetch\\n"" ) ; # if MYSQL_ASYNC if ( imp_dbh -> async_query_in_flight ) { if ( mysql_db_async_result ( sth , & imp_sth -> result ) <= 0 ) { return Nullav ; } } # endif # if MYSQL_VERSION_ID >= SERVER_PREPARE_VERSION if ( imp_sth -> use_server_side_prepare ) { if ( ! DBIc_ACTIVE ( imp_sth ) ) { do_error ( sth , JW_ERR_SEQUENCE , ""nostatementexecuting\\n"" , NULL ) ; return Nullav ; } if ( imp_sth -> fetch_done ) { do_error ( sth , JW_ERR_SEQUENCE , ""fetch()butfetchalreadydone"" , NULL ) ; return Nullav ; } if ( ! imp_sth -> done_desc ) { if ( ! dbd_describe ( sth , imp_sth ) ) { do_error ( sth , JW_ERR_SEQUENCE , ""Errorwhiledescriberesultset."" , NULL ) ; return Nullav ; } } } # endif ChopBlanks = DBIc_is ( imp_sth , DBIcf_ChopBlanks ) ; if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\t\\tdbd_st_fetchfor%p,chopblanks%d\\n"" , sth , ChopBlanks ) ; if ( ! imp_sth -> result ) { do_error ( sth , JW_ERR_SEQUENCE , ""fetch()withoutexecute()"" , NULL ) ; return Nullav ; } imp_dbh -> pmysql -> net . last_errno = 0 ; # if MYSQL_VERSION_ID >= SERVER_PREPARE_VERSION if ( imp_sth -> use_server_side_prepare ) { if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\t\\tdbd_st_fetchcallingmysql_fetch\\n"" ) ; if ( ( rc = mysql_stmt_fetch ( imp_sth -> stmt ) ) ) { if ( rc == 1 ) do_error ( sth , mysql_stmt_errno ( imp_sth -> stmt ) , mysql_stmt_error ( imp_sth -> stmt ) , mysql_stmt_sqlstate ( imp_sth -> stmt ) ) ; # if MYSQL_VERSION_ID >= MYSQL_VERSION_5_0 if ( rc == MYSQL_DATA_TRUNCATED ) { if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\t\\tdbd_st_fetchdatatruncated\\n"" ) ; goto process ; } # endif if ( rc == MYSQL_NO_DATA ) { imp_sth -> row_num = mysql_stmt_affected_rows ( imp_sth -> stmt ) ; imp_sth -> fetch_done = 1 ; if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\t\\tdbd_st_fetchnodata\\n"" ) ; } dbd_st_finish ( sth , imp_sth ) ; return Nullav ; } process : imp_sth -> currow ++ ; av = DBIc_DBISTATE ( imp_sth ) -> get_fbav ( imp_sth ) ; num_fields = mysql_stmt_field_count ( imp_sth -> stmt ) ; if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\t\\tdbd_st_fetchcalledmysql_fetch,rc%dnum_fields%d\\n"" , rc , num_fields ) ; for ( buffer = imp_sth -> buffer , fbh = imp_sth -> fbh , i = 0 ; i < num_fields ; i ++ , fbh ++ , buffer ++ ) { SV * sv = AvARRAY ( av ) [ i ] ; STRLEN len ; if ( fbh -> is_null ) ( void ) SvOK_off ( sv ) ; else { if ( fbh -> length > buffer -> buffer_length || fbh -> error ) { if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\t\\tRefetchBLOB/TEXTcolumn:%d,length:%lu,error:%d\\n"" , i , fbh -> length , fbh -> error ) ; Renew ( fbh -> data , fbh -> length , char ) ; buffer -> buffer_length = fbh -> length ; buffer -> buffer = ( char * ) fbh -> data ; if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) { int j ; int m = MIN ( * buffer -> length , buffer -> buffer_length ) ; char * ptr = ( char * ) buffer -> buffer ; PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\t\\tbeforebuffer->buffer:"" ) ; for ( j = 0 ; j < m ; j ++ ) { PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""%c"" , * ptr ++ ) ; } PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\n"" ) ; } if ( mysql_stmt_fetch_column ( imp_sth -> stmt , buffer , i , 0 ) ) do_error ( sth , mysql_stmt_errno ( imp_sth -> stmt ) , mysql_stmt_error ( imp_sth -> stmt ) , mysql_stmt_sqlstate ( imp_sth -> stmt ) ) ; if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) { int j ; int m = MIN ( * buffer -> length , buffer -> buffer_length ) ; char * ptr = ( char * ) buffer -> buffer ; PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\t\\tafterbuffer->buffer:"" ) ; for ( j = 0 ; j < m ; j ++ ) { PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""%c"" , * ptr ++ ) ; } PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\n"" ) ; } } switch ( buffer -> buffer_type ) { case MYSQL_TYPE_DOUBLE : if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\t\\tst_fetchdoubledata%f\\n"" , fbh -> ddata ) ; sv_setnv ( sv , fbh -> ddata ) ; break ; case MYSQL_TYPE_LONG : case MYSQL_TYPE_LONGLONG : if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\t\\tst_fetchintdata%"" IVdf "",unsigned?%d\\n"" , fbh -> ldata , buffer -> is_unsigned ) ; if ( buffer -> is_unsigned ) sv_setuv ( sv , fbh -> ldata ) ; else sv_setiv ( sv , fbh -> ldata ) ; break ; case MYSQL_TYPE_BIT : sv_setpvn ( sv , fbh -> data , fbh -> length ) ; break ; default : if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\t\\tERRORINst_fetch_string"" ) ; len = fbh -> length ; if ( ChopBlanks ) { if ( fbh -> charsetnr != 63 ) while ( len && fbh -> data [ len - 1 ] == '' ) { -- len ; } } sv_setpvn ( sv , fbh -> data , len ) ; # if defined ( sv_utf8_decode ) && MYSQL_VERSION_ID >= SERVER_PREPARE_VERSION # if MYSQL_VERSION_ID >= FIELD_CHARSETNR_VERSION if ( ( imp_dbh -> enable_utf8 || imp_dbh -> enable_utf8mb4 ) && fbh -> charsetnr != 63 ) # else if ( ( imp_dbh -> enable_utf8 || imp_dbh -> enable_utf8mb4 ) && ! ( fbh -> flags & BINARY_FLAG ) ) # endif sv_utf8_decode ( sv ) ; # endif break ; } } } if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\t<-dbd_st_fetch,%dcols\\n"" , num_fields ) ; return av ; } else { # endif imp_sth -> currow ++ ; if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) { PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\tdbd_st_fetchresultsetdetails\\n"" ) ; PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\timp_sth->result=%p\\n"" , imp_sth -> result ) ; PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\tmysql_num_fields=%u\\n"" , mysql_num_fields ( imp_sth -> result ) ) ; PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\tmysql_num_rows=%llu\\n"" , mysql_num_rows ( imp_sth -> result ) ) ; PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\tmysql_affected_rows=%llu\\n"" , mysql_affected_rows ( imp_dbh -> pmysql ) ) ; PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\tdbd_st_fetchfor%p,currow=%d\\n"" , sth , imp_sth -> currow ) ; } if ( ! ( cols = mysql_fetch_row ( imp_sth -> result ) ) ) { if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) { PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\tdbd_st_fetch,nomorerowstofetch"" ) ; } if ( mysql_errno ( imp_dbh -> pmysql ) ) do_error ( sth , mysql_errno ( imp_dbh -> pmysql ) , mysql_error ( imp_dbh -> pmysql ) , mysql_sqlstate ( imp_dbh -> pmysql ) ) ; # if MYSQL_VERSION_ID >= MULTIPLE_RESULT_SET_VERSION if ( ! mysql_more_results ( svsock ) ) # endif dbd_st_finish ( sth , imp_sth ) ; return Nullav ; } num_fields = mysql_num_fields ( imp_sth -> result ) ; fields = mysql_fetch_fields ( imp_sth -> result ) ; lengths = mysql_fetch_lengths ( imp_sth -> result ) ; if ( ( av = DBIc_FIELDS_AV ( imp_sth ) ) != Nullav ) { av_length = av_len ( av ) + 1 ; if ( av_length != num_fields ) { if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\t<-dbd_st_fetch,sizeofresultsarray(%d)!=num_fields(%d)\\n"" , av_length , num_fields ) ; if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\t<-dbd_st_fetch,resultfields(%d)\\n"" , DBIc_NUM_FIELDS ( imp_sth ) ) ; av_readonly = SvREADONLY ( av ) ; if ( av_readonly ) SvREADONLY_off ( av ) ; while ( av_length < num_fields ) { av_store ( av , av_length ++ , newSV ( 0 ) ) ; } while ( av_length > num_fields ) { SvREFCNT_dec ( av_pop ( av ) ) ; av_length -- ; } if ( av_readonly ) SvREADONLY_on ( av ) ; } } av = DBIc_DBISTATE ( imp_sth ) -> get_fbav ( imp_sth ) ; for ( i = 0 ; i < num_fields ; ++ i ) { char * col = cols [ i ] ; SV * sv = AvARRAY ( av ) [ i ] ; if ( col ) { STRLEN len = lengths [ i ] ; if ( ChopBlanks ) { while ( len && col [ len - 1 ] == '' ) { -- len ; } } sv_setpvn ( sv , col , len ) ; switch ( mysql_to_perl_type ( fields [ i ] . type ) ) { case MYSQL_TYPE_DOUBLE : ( void ) SvNV ( sv ) ; SvNOK_only ( sv ) ; break ; case MYSQL_TYPE_LONG : case MYSQL_TYPE_LONGLONG : if ( fields [ i ] . flags & UNSIGNED_FLAG ) { ( void ) SvUV ( sv ) ; SvIOK_only_UV ( sv ) ; } else { ( void ) SvIV ( sv ) ; SvIOK_only ( sv ) ; } break ; # if MYSQL_VERSION_ID > NEW_DATATYPE_VERSION case MYSQL_TYPE_BIT : break ; # endif default : # if defined ( sv_utf8_decode ) && MYSQL_VERSION_ID >= SERVER_PREPARE_VERSION if ( ( imp_dbh -> enable_utf8 || imp_dbh -> enable_utf8mb4 ) && fields [ i ] . charsetnr != 63 ) sv_utf8_decode ( sv ) ; # endif break ; } } else ( void ) SvOK_off ( sv ) ; } if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\t<-dbd_st_fetch,%dcols\\n"" , num_fields ) ; return av ; # if MYSQL_VERSION_ID >= SERVER_PREPARE_VERSION } # endif } "," ; buffer -> buffer = ( char * ) fbh -> data ; imp_sth -> stmt -> bind [ i ] . buffer_length = fbh -> length ; imp_sth -> stmt -> bind [ i ] . ",perl5-dbi@DBD-mysql/3619c170461a3107a258d1fd2d00ed4832adb1b1,CVE-2016-1251,https://github.com/perl5-dbi/DBD-mysql/commit/3619c170461a3107a258d1fd2d00ed4832adb1b1,2016-11-29T20:59Z 96,CWE-20,"CWE-20 error_t enc28j60SendPacket ( NetInterface * interface , const NetBuffer * buffer , size_t offset , NetTxAncillary * ancillary ) { size_t length ; length = netBufferGetLength ( buffer ) - offset ; if ( length > 1536 ) { osSetEvent ( & interface -> nicTxEvent ) ; return ERROR_INVALID_LENGTH ; } if ( ! interface -> linkState ) { osSetEvent ( & interface -> nicTxEvent ) ; return NO_ERROR ; } enc28j60SetBit ( interface , ENC28J60_REG_ECON1 , ECON1_TXRST ) ; enc28j60ClearBit ( interface , ENC28J60_REG_ECON1 , ECON1_TXRST ) ; enc28j60ClearBit ( interface , ENC28J60_REG_EIR , EIR_TXIF | EIR_TXERIF ) ; enc28j60WriteReg ( interface , ENC28J60_REG_ETXSTL , LSB ( ENC28J60_TX_BUFFER_START ) ) ; enc28j60WriteReg ( interface , ENC28J60_REG_ETXSTH , MSB ( ENC28J60_TX_BUFFER_START ) ) ; enc28j60WriteReg ( interface , ENC28J60_REG_EWRPTL , LSB ( ENC28J60_TX_BUFFER_START ) ) ; enc28j60WriteReg ( interface , ENC28J60_REG_EWRPTH , MSB ( ENC28J60_TX_BUFFER_START ) ) ; enc28j60WriteBuffer ( interface , buffer , offset ) ; enc28j60WriteReg ( interface , ENC28J60_REG_ETXNDL , LSB ( ENC28J60_TX_BUFFER_START + length ) ) ; enc28j60WriteReg ( interface , ENC28J60_REG_ETXNDH , MSB ( ENC28J60_TX_BUFFER_START + length ) ) ; enc28j60SetBit ( interface , ENC28J60_REG_ECON1 , ECON1_TXRTS ) ; return NO_ERROR ; } "," ( interface , ENC28J60_ECON1 , ENC28J60_ECON1_TXRST ) ; enc28j60ClearBit ( interface , ENC28J60_ECON1 , ENC28J60_ECON1_TXRST ) ; enc28j60ClearBit ( interface , ENC28J60_EIR , ENC28J60_EIR_TXIF | ENC28J60_EIR_TXERIF ) ; enc28j60WriteReg ( interface , ENC28J60_ETXSTL , LSB ( ( interface , ENC28J60_ETXSTH , MSB ( ( interface , ENC28J60_EWRPTL , LSB ( ( interface , ENC28J60_EWRPTH , MSB ( ( interface , ENC28J60_ETXNDL , LSB ( ( interface , ENC28J60_ETXNDH , MSB ( ( interface , ENC28J60_ECON1 , ENC28J60_ECON1_TXRTS ) ; return ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 97,CWE-125,"CWE-125 PyObject * ast2obj_arg ( void * _o ) { arg_ty o = ( arg_ty ) _o ; PyObject * result = NULL , * value = NULL ; if ( ! o ) { Py_RETURN_NONE ; } result = PyType_GenericNew ( arg_type , NULL , NULL ) ; if ( ! result ) return NULL ; value = ast2obj_identifier ( o -> arg ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_arg , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> annotation ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_annotation , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_int ( o -> lineno ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_lineno , value ) < 0 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_int ( o -> col_offset ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_col_offset , value ) < 0 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_int ( o -> end_lineno ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_end_lineno , value ) < 0 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_int ( o -> end_col_offset ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_end_col_offset , value ) < 0 ) goto failed ; Py_DECREF ( value ) ; return result ; failed : Py_XDECREF ( value ) ; Py_XDECREF ( result ) ; return NULL ; } "," ; value = ast2obj_string ( o -> type_comment ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_type_comment , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ",python@typed_ast/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,CVE-2019-19275,https://github.com/python/typed_ast/commit/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,2019-11-26T15:15Z 98,CWE-22,"CWE-22 void wiki_handle_rest_call ( HttpRequest * req , HttpResponse * res , char * func ) { if ( func != NULL && * func != '\\0' ) { if ( ! strcmp ( func , ""page/get"" ) ) { char * page = http_request_param_get ( req , ""page"" ) ; if ( page == NULL ) page = http_request_get_query_string ( req ) ; if ( page && ( access ( page , R_OK ) == 0 ) ) { http_response_printf ( res , ""%s"" , file_read ( page ) ) ; http_response_send ( res ) ; return ; } } else if ( ! strcmp ( func , ""page/set"" ) ) { char * wikitext = NULL , * page = NULL ; if ( ( ( wikitext = http_request_param_get ( req , ""text"" ) ) != NULL ) && ( ( page = http_request_param_get ( req , ""page"" ) ) != NULL ) ) { file_write ( page , wikitext ) ; http_response_printf ( res , ""success"" ) ; http_response_send ( res ) ; return ; } } else if ( ! strcmp ( func , ""page/delete"" ) ) { char * page = http_request_param_get ( req , ""page"" ) ; if ( page == NULL ) page = http_request_get_query_string ( req ) ; if ( page && ( unlink ( page ) > 0 ) ) { http_response_printf ( res , ""success"" ) ; http_response_send ( res ) ; return ; } } else if ( ! strcmp ( func , ""page/exists"" ) ) { char * page = http_request_param_get ( req , ""page"" ) ; if ( page == NULL ) page = http_request_get_query_string ( req ) ; if ( page && ( access ( page , R_OK ) == 0 ) ) { http_response_printf ( res , ""success"" ) ; http_response_send ( res ) ; return ; } } else if ( ! strcmp ( func , ""pages"" ) || ! strcmp ( func , ""search"" ) ) { WikiPageList * * pages = NULL ; int n_pages , i ; char * expr = http_request_param_get ( req , ""expr"" ) ; if ( expr == NULL ) expr = http_request_get_query_string ( req ) ; pages = wiki_get_pages ( & n_pages , expr ) ; if ( pages ) { for ( i = 0 ; i < n_pages ; i ++ ) { struct tm * pTm ; char datebuf [ 64 ] ; pTm = localtime ( & pages [ i ] -> mtime ) ; strftime ( datebuf , sizeof ( datebuf ) , ""%Y-%m-%d%H:%M"" , pTm ) ; http_response_printf ( res , ""%s\\t%s\\n"" , pages [ i ] -> name , datebuf ) ; } http_response_send ( res ) ; return ; } } } http_response_set_status ( res , 500 , ""Error"" ) ; http_response_printf ( res , ""Failed\\n"" ) ; http_response_send ( res ) ; return ; } "," ( page && page_name_is_good ( page ) && ) ) { if ( page_name_is_good ( page ) ) { ; return ; } ( page && page_name_is_good ( page ) && if ( page && page_name_is_good ( page ) ",yarolig@didiwiki/5e5c796617e1712905dc5462b94bd5e6c08d15ea,CVE-2013-7448,https://github.com/yarolig/didiwiki/commit/5e5c796617e1712905dc5462b94bd5e6c08d15ea,2016-02-23T19:59Z 99,CWE-000,"CWE-000 static int ext4_ext_handle_uninitialized_extents ( handle_t * handle , struct inode * inode , ext4_lblk_t iblock , unsigned int max_blocks , struct ext4_ext_path * path , int flags , unsigned int allocated , struct buffer_head * bh_result , ext4_fsblk_t newblock ) { int ret = 0 ; int err = 0 ; ext4_io_end_t * io = EXT4_I ( inode ) -> cur_aio_dio ; ext_debug ( ""ext4_ext_handle_uninitialized_extents:inode%lu,logical"" ""block%llu,max_blocks%u,flags%d,allocated%u"" , inode -> i_ino , ( unsigned long long ) iblock , max_blocks , flags , allocated ) ; ext4_ext_show_leaf ( inode , path ) ; if ( flags == EXT4_GET_BLOCKS_PRE_IO ) { ret = ext4_split_unwritten_extents ( handle , inode , path , iblock , max_blocks , flags ) ; if ( io ) io -> flag = EXT4_IO_UNWRITTEN ; else ext4_set_inode_state ( inode , EXT4_STATE_DIO_UNWRITTEN ) ; goto out ; } if ( flags == EXT4_GET_BLOCKS_CONVERT ) { ret = ext4_convert_unwritten_extents_endio ( handle , inode , path ) ; if ( ret >= 0 ) ext4_update_inode_fsync_trans ( handle , inode , 1 ) ; goto out2 ; } if ( flags & EXT4_GET_BLOCKS_UNINIT_EXT ) goto map_out ; if ( ( flags & EXT4_GET_BLOCKS_CREATE ) == 0 ) { set_buffer_unwritten ( bh_result ) ; goto out1 ; } ret = ext4_ext_convert_to_initialized ( handle , inode , path , iblock , max_blocks ) ; if ( ret >= 0 ) ext4_update_inode_fsync_trans ( handle , inode , 1 ) ; out : if ( ret <= 0 ) { err = ret ; goto out2 ; } else allocated = ret ; set_buffer_new ( bh_result ) ; if ( allocated > max_blocks ) { unmap_underlying_metadata_blocks ( inode -> i_sb -> s_bdev , newblock + max_blocks , allocated - max_blocks ) ; allocated = max_blocks ; } if ( flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE ) ext4_da_update_reserve_space ( inode , allocated , 0 ) ; map_out : set_buffer_mapped ( bh_result ) ; out1 : if ( allocated > max_blocks ) allocated = max_blocks ; ext4_ext_show_leaf ( inode , path ) ; bh_result -> b_bdev = inode -> i_sb -> s_bdev ; bh_result -> b_blocknr = newblock ; out2 : if ( path ) { ext4_ext_drop_refs ( path ) ; kfree ( path ) ; } return err ? err : allocated ; } "," ; if ( ( flags & EXT4_GET_BLOCKS_PRE_IO ) ) { ret = inode , EXT4_STATE_DIO_UNWRITTEN ) ; if ( ext4_should_dioread_nolock ( inode ) ) set_buffer_uninit ( bh_result } if ( ( flags & EXT4_GET_BLOCKS_CONVERT ) ) { ret ",torvalds@linux/744692dc059845b2a3022119871846e74d4f6e11,CVE-2015-8324,https://github.com/torvalds/linux/commit/744692dc059845b2a3022119871846e74d4f6e11,2016-05-02T10:59Z 100,CWE-125,"CWE-125 static int print_ipcp_config_options ( netdissect_options * ndo , const u_char * p , int length ) { int len , opt ; u_int compproto , ipcomp_subopttotallen , ipcomp_subopt , ipcomp_suboptlen ; if ( length < 2 ) return 0 ; ND_TCHECK2 ( * p , 2 ) ; len = p [ 1 ] ; opt = p [ 0 ] ; if ( length < len ) return 0 ; if ( len < 2 ) { ND_PRINT ( ( ndo , ""\\n\\t%sOption(0x%02x),length%u(lengthbogus,shouldbe>=2)"" , tok2str ( ipcpopt_values , ""unknown"" , opt ) , opt , len ) ) ; return 0 ; } ND_PRINT ( ( ndo , ""\\n\\t%sOption(0x%02x),length%u"" , tok2str ( ipcpopt_values , ""unknown"" , opt ) , opt , len ) ) ; switch ( opt ) { case IPCPOPT_2ADDR : if ( len != 10 ) { ND_PRINT ( ( ndo , ""(lengthbogus,shouldbe=10)"" ) ) ; return len ; } ND_TCHECK2 ( * ( p + 6 ) , 4 ) ; ND_PRINT ( ( ndo , "":src%s,dst%s"" , ipaddr_string ( ndo , p + 2 ) , ipaddr_string ( ndo , p + 6 ) ) ) ; break ; case IPCPOPT_IPCOMP : if ( len < 4 ) { ND_PRINT ( ( ndo , ""(lengthbogus,shouldbe>=4)"" ) ) ; return 0 ; } ND_TCHECK2 ( * ( p + 2 ) , 2 ) ; compproto = EXTRACT_16BITS ( p + 2 ) ; ND_PRINT ( ( ndo , "":%s(0x%02x):"" , tok2str ( ipcpopt_compproto_values , ""Unknown"" , compproto ) , compproto ) ) ; switch ( compproto ) { case PPP_VJC : break ; case IPCPOPT_IPCOMP_HDRCOMP : if ( len < IPCPOPT_IPCOMP_MINLEN ) { ND_PRINT ( ( ndo , ""(lengthbogus,shouldbe>=%u)"" , IPCPOPT_IPCOMP_MINLEN ) ) ; return 0 ; } ND_TCHECK2 ( * ( p + 2 ) , IPCPOPT_IPCOMP_MINLEN ) ; ND_PRINT ( ( ndo , ""\\n\\tTCPSpace%u,non-TCPSpace%u"" "",maxPeriod%u,maxTime%u,maxHdr%u"" , EXTRACT_16BITS ( p + 4 ) , EXTRACT_16BITS ( p + 6 ) , EXTRACT_16BITS ( p + 8 ) , EXTRACT_16BITS ( p + 10 ) , EXTRACT_16BITS ( p + 12 ) ) ) ; if ( len > IPCPOPT_IPCOMP_MINLEN ) { ipcomp_subopttotallen = len - IPCPOPT_IPCOMP_MINLEN ; p += IPCPOPT_IPCOMP_MINLEN ; ND_PRINT ( ( ndo , ""\\n\\tSuboptions,length%u"" , ipcomp_subopttotallen ) ) ; while ( ipcomp_subopttotallen >= 2 ) { ND_TCHECK2 ( * p , 2 ) ; ipcomp_subopt = * p ; ipcomp_suboptlen = * ( p + 1 ) ; if ( ipcomp_subopt == 0 || ipcomp_suboptlen == 0 ) break ; ND_PRINT ( ( ndo , ""\\n\\t\\t%sSuboption#%u,length%u"" , tok2str ( ipcpopt_compproto_subopt_values , ""Unknown"" , ipcomp_subopt ) , ipcomp_subopt , ipcomp_suboptlen ) ) ; ipcomp_subopttotallen -= ipcomp_suboptlen ; p += ipcomp_suboptlen ; } } break ; default : break ; } break ; case IPCPOPT_ADDR : case IPCPOPT_MOBILE4 : case IPCPOPT_PRIDNS : case IPCPOPT_PRINBNS : case IPCPOPT_SECDNS : case IPCPOPT_SECNBNS : if ( len != 6 ) { ND_PRINT ( ( ndo , ""(lengthbogus,shouldbe=6)"" ) ) ; return 0 ; } ND_TCHECK2 ( * ( p + 2 ) , 4 ) ; ND_PRINT ( ( ndo , "":%s"" , ipaddr_string ( ndo , p + 2 ) ) ) ; break ; default : if ( ndo -> ndo_vflag < 2 ) print_unknown_data ( ndo , & p [ 2 ] , ""\\n\\t"" , len - 2 ) ; break ; } if ( ndo -> ndo_vflag > 1 ) print_unknown_data ( ndo , & p [ 2 ] , ""\\n\\t"" , len - 2 ) ; return len ; trunc : ND_PRINT ( ( ndo , ""[|ipcp]"" ) ) ; return 0 ; } "," 0 ; } ND_TCHECK_16BITS ( p + 2 ) ; ",the-tcpdump-group@tcpdump/7029d15f148ef24bb7c6668bc640f5470d085e5a,CVE-2017-13029,https://github.com/the-tcpdump-group/tcpdump/commit/7029d15f148ef24bb7c6668bc640f5470d085e5a,2017-09-14T06:29Z 101,CWE-264,"CWE-264 static int cg_getattr ( const char * path , struct stat * sb ) { struct timespec now ; struct fuse_context * fc = fuse_get_context ( ) ; char * cgdir = NULL ; char * fpath = NULL , * path1 , * path2 ; struct cgfs_files * k = NULL ; const char * cgroup ; const char * controller = NULL ; int ret = - ENOENT ; if ( ! fc ) return - EIO ; memset ( sb , 0 , sizeof ( struct stat ) ) ; if ( clock_gettime ( CLOCK_REALTIME , & now ) < 0 ) return - EINVAL ; sb -> st_uid = sb -> st_gid = 0 ; sb -> st_atim = sb -> st_mtim = sb -> st_ctim = now ; sb -> st_size = 0 ; if ( strcmp ( path , ""/cgroup"" ) == 0 ) { sb -> st_mode = S_IFDIR | 00755 ; sb -> st_nlink = 2 ; return 0 ; } controller = pick_controller_from_path ( fc , path ) ; if ( ! controller ) return - EIO ; cgroup = find_cgroup_in_path ( path ) ; if ( ! cgroup ) { sb -> st_mode = S_IFDIR | 00755 ; sb -> st_nlink = 2 ; return 0 ; } get_cgdir_and_path ( cgroup , & cgdir , & fpath ) ; if ( ! fpath ) { path1 = ""/"" ; path2 = cgdir ; } else { path1 = cgdir ; path2 = fpath ; } if ( is_child_cgroup ( controller , path1 , path2 ) ) { if ( ! caller_is_in_ancestor ( fc -> pid , controller , cgroup , NULL ) ) { sb -> st_mode = S_IFDIR | 00555 ; sb -> st_nlink = 2 ; ret = 0 ; goto out ; } if ( ! fc_may_access ( fc , controller , cgroup , NULL , O_RDONLY ) ) { ret = - EACCES ; goto out ; } sb -> st_mode = S_IFDIR | 00755 ; k = cgfs_get_key ( controller , cgroup , ""tasks"" ) ; if ( ! k ) { sb -> st_uid = sb -> st_gid = 0 ; } else { sb -> st_uid = k -> uid ; sb -> st_gid = k -> gid ; } free_key ( k ) ; sb -> st_nlink = 2 ; ret = 0 ; goto out ; } if ( ( k = cgfs_get_key ( controller , path1 , path2 ) ) != NULL ) { sb -> st_mode = S_IFREG | k -> mode ; sb -> st_nlink = 1 ; sb -> st_uid = k -> uid ; sb -> st_gid = k -> gid ; sb -> st_size = 0 ; free_key ( k ) ; if ( ! caller_is_in_ancestor ( fc -> pid , controller , path1 , NULL ) ) { ret = - ENOENT ; goto out ; } if ( ! fc_may_access ( fc , controller , path1 , path2 , O_RDONLY ) ) { ret = - EACCES ; goto out ; } ret = 0 ; } out : free ( cgdir ) ; return ret ; } "," if ( ! caller_may_see_dir ( fc -> pid , controller , cgroup ) ) { ret = - ENOENT ; goto out ; } if ( ! ",lxc@lxcfs/a8b6c3e0537e90fba3c55910fd1b7229d54a60a7,CVE-2015-1342,https://github.com/lxc/lxcfs/commit/a8b6c3e0537e90fba3c55910fd1b7229d54a60a7,2015-12-07T20:59Z 102,CWE-119,"CWE-119 void vp8_de_noise ( VP8_COMMON * cm , YV12_BUFFER_CONFIG * source , YV12_BUFFER_CONFIG * post , int q , int low_var_thresh , int flag ) { double level = 6.0e-05 * q * q * q - .0067 * q * q + .306 * q + .0065 ; int ppl = ( int ) ( level + .5 ) ; int mb_rows = source -> y_width >> 4 ; int mb_cols = source -> y_height >> 4 ; unsigned char * limits = cm -> pp_limits_buffer ; ; int mbr , mbc ; ( void ) post ; ( void ) low_var_thresh ; ( void ) flag ; vpx_memset ( limits , ( unsigned char ) ppl , 16 * mb_cols ) ; for ( mbr = 0 ; mbr < mb_rows ; mbr ++ ) { vp8_post_proc_down_and_across_mb_row ( source -> y_buffer + 16 * mbr * source -> y_stride , source -> y_buffer + 16 * mbr * source -> y_stride , source -> y_stride , source -> y_stride , source -> y_width , limits , 16 ) ; vp8_post_proc_down_and_across_mb_row ( source -> u_buffer + 8 * mbr * source -> uv_stride , source -> u_buffer + 8 * mbr * source -> uv_stride , source -> uv_stride , source -> uv_stride , source -> uv_width , limits , 8 ) ; vp8_post_proc_down_and_across_mb_row ( source -> v_buffer + 8 * mbr * source -> uv_stride , source -> v_buffer + 8 * mbr * source -> uv_stride , source -> uv_stride , source -> uv_stride , source -> uv_width , limits , 8 ) ; } } "," , int flag , int uvfilter ) { int mbr ; double level = int mb_rows = cm -> mb_rows ; int mb_cols int mb_cols = cm -> mb_cols ; unsigned char pp_limits_buffer ; ; ( void ) ) flag ; memset ( limits , 16 ) ; if ( uvfilter == 1 ) { , limits , 8 ) ; } } } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 103,CWE-264,"CWE-264 static int raw_cmd_copyout ( int cmd , void __user * param , struct floppy_raw_cmd * ptr ) { int ret ; while ( ptr ) { ret = copy_to_user ( param , ptr , sizeof ( * ptr ) ) ; if ( ret ) return - EFAULT ; param += sizeof ( struct floppy_raw_cmd ) ; if ( ( ptr -> flags & FD_RAW_READ ) && ptr -> buffer_length ) { if ( ptr -> length >= 0 && ptr -> length <= ptr -> buffer_length ) { long length = ptr -> buffer_length - ptr -> length ; ret = fd_copyout ( ptr -> data , ptr -> kernel_data , length ) ; if ( ret ) return ret ; } } ptr = ptr -> next ; } return 0 ; } "," ptr ) { struct floppy_raw_cmd cmd = * ptr ; cmd . next = NULL ; cmd . kernel_data = NULL ; ( param , & cmd , sizeof ( , sizeof ( cmd ) ) ; ",torvalds@linux/2145e15e0557a01b9195d1c7199a1b92cb9be81f,CVE-2014-1738,https://github.com/torvalds/linux/commit/2145e15e0557a01b9195d1c7199a1b92cb9be81f,2014-05-11T21:55Z 104,CWE-264,"CWE-264 int cap_bprm_set_creds ( struct linux_binprm * bprm ) { const struct cred * old = current_cred ( ) ; struct cred * new = bprm -> cred ; bool effective , has_cap = false ; int ret ; effective = false ; ret = get_file_caps ( bprm , & effective , & has_cap ) ; if ( ret < 0 ) return ret ; if ( ! issecure ( SECURE_NOROOT ) ) { if ( has_cap && new -> uid != 0 && new -> euid == 0 ) { warn_setuid_and_fcaps_mixed ( bprm -> filename ) ; goto skip ; } if ( new -> euid == 0 || new -> uid == 0 ) { new -> cap_permitted = cap_combine ( old -> cap_bset , old -> cap_inheritable ) ; } if ( new -> euid == 0 ) effective = true ; } skip : if ( ( new -> euid != old -> uid || new -> egid != old -> gid || ! cap_issubset ( new -> cap_permitted , old -> cap_permitted ) ) && bprm -> unsafe & ~ LSM_UNSAFE_PTRACE_CAP ) { if ( ! capable ( CAP_SETUID ) ) { new -> euid = new -> uid ; new -> egid = new -> gid ; } new -> cap_permitted = cap_intersect ( new -> cap_permitted , old -> cap_permitted ) ; } new -> suid = new -> fsuid = new -> euid ; new -> sgid = new -> fsgid = new -> egid ; if ( effective ) new -> cap_effective = new -> cap_permitted ; else cap_clear ( new -> cap_effective ) ; bprm -> cap_effective = effective ; if ( ! cap_isclear ( new -> cap_effective ) ) { if ( ! cap_issubset ( CAP_FULL_SET , new -> cap_effective ) || new -> euid != 0 || new -> uid != 0 || issecure ( SECURE_NOROOT ) ) { ret = audit_log_bprm_fcaps ( bprm , new , old ) ; if ( ret < 0 ) return ret ; } } new -> securebits &= ~ issecure_mask ( SECURE_KEEP_CAPS ) ; return 0 ; } "," : if ( ! cap_issubset ( new -> cap_permitted , old -> cap_permitted ) ) bprm -> per_clear |= PER_CLEAR_ON_SETID ; if ( ",torvalds@linux/d52fc5dde171f030170a6cb78034d166b13c9445,CVE-2012-2123,https://github.com/torvalds/linux/commit/d52fc5dde171f030170a6cb78034d166b13c9445,2012-05-17T11:00Z 105,CWE-19,"CWE-19 static void ext4_xattr_cache_insert ( struct mb_cache * ext4_mb_cache , struct buffer_head * bh ) { __u32 hash = le32_to_cpu ( BHDR ( bh ) -> h_hash ) ; struct mb_cache_entry * ce ; int error ; ce = mb_cache_entry_alloc ( ext4_mb_cache , GFP_NOFS ) ; if ( ! ce ) { ea_bdebug ( bh , ""outofmemory"" ) ; return ; } error = mb_cache_entry_insert ( ce , bh -> b_bdev , bh -> b_blocknr , hash ) ; if ( error ) { mb_cache_entry_free ( ce ) ; if ( error == - EBUSY ) { ea_bdebug ( bh , ""alreadyincache"" ) ; error = 0 ; } } else { ea_bdebug ( bh , ""inserting[%x]"" , ( int ) hash ) ; mb_cache_entry_release ( ce ) ; } } "," ext4_xattr_cache_insert ( struct mb2_cache * ext4_mb_cache , h_hash ) ; int error ; int error ; error = mb2_cache_entry_create ( ext4_mb_cache , ext4_mb_cache , GFP_NOFS , hash , bh -> b_blocknr bh -> b_blocknr ) ; if error ) { if ( error - EBUSY ) ea_bdebug ( bh ""alreadyincache"" ) ; } else ea_bdebug ( bh hash ) ; } ",torvalds@linux/82939d7999dfc1f1998c4b1c12e2f19edbdff272,CVE-2015-8952,https://github.com/torvalds/linux/commit/82939d7999dfc1f1998c4b1c12e2f19edbdff272,2016-10-16T21:59Z 106,CWE-78,"CWE-78 R_API char * r_socket_http_post ( const char * url , const char * data , int * code , int * rlen ) { RSocket * s ; bool ssl = r_str_startswith ( url , ""https://"" ) ; char * uri = strdup ( url ) ; if ( ! uri ) { return NULL ; } char * host = strstr ( uri , ""://"" ) ; if ( ! host ) { free ( uri ) ; printf ( ""InvalidURI"" ) ; return NULL ; } host += 3 ; char * port = strchr ( host , ':' ) ; if ( ! port ) { port = ( ssl ) ? ""443"" : ""80"" ; } else { * port ++ = 0 ; } char * path = strchr ( host , '/' ) ; if ( ! path ) { path = """" ; } else { * path ++ = 0 ; } s = r_socket_new ( ssl ) ; if ( ! s ) { printf ( ""Cannotcreatesocket\\n"" ) ; free ( uri ) ; return NULL ; } if ( ! r_socket_connect_tcp ( s , host , port , 0 ) ) { eprintf ( ""Cannotconnectto%s:%s\\n"" , host , port ) ; free ( uri ) ; return NULL ; } r_socket_printf ( s , ""POST/%sHTTP/1.0\\r\\n"" ""User-Agent:radare2"" R2_VERSION ""\\r\\n"" ""Accept:*/*\\r\\n"" ""Host:%s\\r\\n"" ""Content-Length:%i\\r\\n"" ""Content-Type:application/x-www-form-urlencoded\\r\\n"" ""\\r\\n"" , path , host , ( int ) strlen ( data ) ) ; free ( uri ) ; r_socket_write ( s , ( void * ) data , strlen ( data ) ) ; return r_socket_http_answer ( s , code , rlen ) ; } "," ) ; return socket_http_answer ( s , code , rlen , 0 ",radareorg@radare2/04edfa82c1f3fa2bc3621ccdad2f93bdbf00e4f9,CVE-2020-15121,https://github.com/radareorg/radare2/commit/04edfa82c1f3fa2bc3621ccdad2f93bdbf00e4f9,2020-07-20T18:15Z 107,CWE-17,"CWE-17 static void f_parser ( lua_State * L , void * ud ) { int i ; Proto * tf ; Closure * cl ; struct SParser * p = cast ( struct SParser * , ud ) ; int c = luaZ_lookahead ( p -> z ) ; luaC_checkGC ( L ) ; tf = ( ( c == LUA_SIGNATURE [ 0 ] ) ? luaU_undump : luaY_parser ) ( L , p -> z , & p -> buff , p -> name ) ; cl = luaF_newLclosure ( L , tf -> nups , hvalue ( gt ( L ) ) ) ; cl -> l . p = tf ; for ( i = 0 ; i < tf -> nups ; i ++ ) cl -> l . upvals [ i ] = luaF_newupval ( L ) ; setclvalue ( L , L -> top , cl ) ; incr_top ( L ) ; } "," tf = ( luaY_parser ) ( ",antirez@redis/fdf9d455098f54f7666c702ae464e6ea21e25411,CVE-2015-4335,https://github.com/antirez/redis/commit/fdf9d455098f54f7666c702ae464e6ea21e25411,2015-06-09T14:59Z 108,CWE-000,"CWE-000 static int inet_create ( struct net * net , struct socket * sock , int protocol , int kern ) { struct sock * sk ; struct inet_protosw * answer ; struct inet_sock * inet ; struct proto * answer_prot ; unsigned char answer_flags ; int try_loading_module = 0 ; int err ; sock -> state = SS_UNCONNECTED ; lookup_protocol : err = - ESOCKTNOSUPPORT ; rcu_read_lock ( ) ; list_for_each_entry_rcu ( answer , & inetsw [ sock -> type ] , list ) { err = 0 ; if ( protocol == answer -> protocol ) { if ( protocol != IPPROTO_IP ) break ; } else { if ( IPPROTO_IP == protocol ) { protocol = answer -> protocol ; break ; } if ( IPPROTO_IP == answer -> protocol ) break ; } err = - EPROTONOSUPPORT ; } if ( unlikely ( err ) ) { if ( try_loading_module < 2 ) { rcu_read_unlock ( ) ; if ( ++ try_loading_module == 1 ) request_module ( ""net-pf-%d-proto-%d-type-%d"" , PF_INET , protocol , sock -> type ) ; else request_module ( ""net-pf-%d-proto-%d"" , PF_INET , protocol ) ; goto lookup_protocol ; } else goto out_rcu_unlock ; } err = - EPERM ; if ( sock -> type == SOCK_RAW && ! kern && ! ns_capable ( net -> user_ns , CAP_NET_RAW ) ) goto out_rcu_unlock ; sock -> ops = answer -> ops ; answer_prot = answer -> prot ; answer_flags = answer -> flags ; rcu_read_unlock ( ) ; WARN_ON ( ! answer_prot -> slab ) ; err = - ENOBUFS ; sk = sk_alloc ( net , PF_INET , GFP_KERNEL , answer_prot , kern ) ; if ( ! sk ) goto out ; err = 0 ; if ( INET_PROTOSW_REUSE & answer_flags ) sk -> sk_reuse = SK_CAN_REUSE ; inet = inet_sk ( sk ) ; inet -> is_icsk = ( INET_PROTOSW_ICSK & answer_flags ) != 0 ; inet -> nodefrag = 0 ; if ( SOCK_RAW == sock -> type ) { inet -> inet_num = protocol ; if ( IPPROTO_RAW == protocol ) inet -> hdrincl = 1 ; } if ( net -> ipv4 . sysctl_ip_no_pmtu_disc ) inet -> pmtudisc = IP_PMTUDISC_DONT ; else inet -> pmtudisc = IP_PMTUDISC_WANT ; inet -> inet_id = 0 ; sock_init_data ( sock , sk ) ; sk -> sk_destruct = inet_sock_destruct ; sk -> sk_protocol = protocol ; sk -> sk_backlog_rcv = sk -> sk_prot -> backlog_rcv ; inet -> uc_ttl = - 1 ; inet -> mc_loop = 1 ; inet -> mc_ttl = 1 ; inet -> mc_all = 1 ; inet -> mc_index = 0 ; inet -> mc_list = NULL ; inet -> rcv_tos = 0 ; sk_refcnt_debug_inc ( sk ) ; if ( inet -> inet_num ) { inet -> inet_sport = htons ( inet -> inet_num ) ; sk -> sk_prot -> hash ( sk ) ; } if ( sk -> sk_prot -> init ) { err = sk -> sk_prot -> init ( sk ) ; if ( err ) sk_common_release ( sk ) ; } out : return err ; out_rcu_unlock : rcu_read_unlock ( ) ; goto out ; } "," ; int err ; if ( protocol < 0 || protocol >= IPPROTO_MAX ) return - EINVAL ",torvalds@linux/79462ad02e861803b3840cc782248c7359451cd9,CVE-2015-8543,https://github.com/torvalds/linux/commit/79462ad02e861803b3840cc782248c7359451cd9,2015-12-28T11:59Z 109,CWE-362,"CWE-362 int ip_options_get_from_user ( struct net * net , struct ip_options * * optp , unsigned char __user * data , int optlen ) { struct ip_options * opt = ip_options_get_alloc ( optlen ) ; if ( ! opt ) return - ENOMEM ; if ( optlen && copy_from_user ( opt -> __data , data , optlen ) ) { kfree ( opt ) ; return - EFAULT ; } return ip_options_get_finish ( net , optp , opt , optlen ) ; } "," net , struct ip_options_rcu * * optp ) { struct ip_options_rcu * opt = ( opt -> opt . ",torvalds@linux/f6d8bd051c391c1c0458a30b2a7abcd939329259,CVE-2012-3552,https://github.com/torvalds/linux/commit/f6d8bd051c391c1c0458a30b2a7abcd939329259,2012-10-03T11:02Z 110,CWE-200,"CWE-200 static int rfcomm_get_dev_list ( void __user * arg ) { struct rfcomm_dev * dev ; struct rfcomm_dev_list_req * dl ; struct rfcomm_dev_info * di ; int n = 0 , size , err ; u16 dev_num ; BT_DBG ( """" ) ; if ( get_user ( dev_num , ( u16 __user * ) arg ) ) return - EFAULT ; if ( ! dev_num || dev_num > ( PAGE_SIZE * 4 ) / sizeof ( * di ) ) return - EINVAL ; size = sizeof ( * dl ) + dev_num * sizeof ( * di ) ; dl = kmalloc ( size , GFP_KERNEL ) ; if ( ! dl ) return - ENOMEM ; di = dl -> dev_info ; spin_lock ( & rfcomm_dev_lock ) ; list_for_each_entry ( dev , & rfcomm_dev_list , list ) { if ( test_bit ( RFCOMM_TTY_RELEASED , & dev -> flags ) ) continue ; ( di + n ) -> id = dev -> id ; ( di + n ) -> flags = dev -> flags ; ( di + n ) -> state = dev -> dlc -> state ; ( di + n ) -> channel = dev -> channel ; bacpy ( & ( di + n ) -> src , & dev -> src ) ; bacpy ( & ( di + n ) -> dst , & dev -> dst ) ; if ( ++ n >= dev_num ) break ; } spin_unlock ( & rfcomm_dev_lock ) ; dl -> dev_num = n ; size = sizeof ( * dl ) + n * sizeof ( * di ) ; err = copy_to_user ( arg , dl , size ) ; kfree ( dl ) ; return err ? - EFAULT : 0 ; } "," ; dl = kzalloc ( size , ",torvalds@linux/f9432c5ec8b1e9a09b9b0e5569e3c73db8de432a,CVE-2012-6545,https://github.com/torvalds/linux/commit/f9432c5ec8b1e9a09b9b0e5569e3c73db8de432a,2013-03-15T20:55Z 111,CWE-125,"CWE-125 static void rpl_dio_print ( netdissect_options * ndo , const u_char * bp , u_int length ) { const struct nd_rpl_dio * dio = ( const struct nd_rpl_dio * ) bp ; const char * dagid_str ; ND_TCHECK ( * dio ) ; dagid_str = ip6addr_string ( ndo , dio -> rpl_dagid ) ; ND_PRINT ( ( ndo , ""[dagid:%s,seq:%u,instance:%u,rank:%u,%smop:%s,prf:%u]"" , dagid_str , dio -> rpl_dtsn , dio -> rpl_instanceid , EXTRACT_16BITS ( & dio -> rpl_dagrank ) , RPL_DIO_GROUNDED ( dio -> rpl_mopprf ) ? ""grounded,"" : """" , tok2str ( rpl_mop_values , ""mop%u"" , RPL_DIO_MOP ( dio -> rpl_mopprf ) ) , RPL_DIO_PRF ( dio -> rpl_mopprf ) ) ) ; if ( ndo -> ndo_vflag > 1 ) { const struct rpl_dio_genoption * opt = ( const struct rpl_dio_genoption * ) & dio [ 1 ] ; rpl_dio_printopt ( ndo , opt , length ) ; } return ; trunc : ND_PRINT ( ( ndo , ""[|truncated]"" ) ) ; return ; } "," ( ndo , ""%s"" , rpl_tstr ) ) ; ",the-tcpdump-group@tcpdump/d7505276842e85bfd067fa21cdb32b8a2dc3c5e4,CVE-2018-14882,https://github.com/the-tcpdump-group/tcpdump/commit/d7505276842e85bfd067fa21cdb32b8a2dc3c5e4,2019-10-03T16:15Z 112,CWE-125,"CWE-125 static int rpki_rtr_pdu_print ( netdissect_options * ndo , const u_char * tptr , u_int indent ) { const rpki_rtr_pdu * pdu_header ; u_int pdu_type , pdu_len , hexdump ; const u_char * msg ; pdu_header = ( const rpki_rtr_pdu * ) tptr ; pdu_type = pdu_header -> pdu_type ; pdu_len = EXTRACT_32BITS ( pdu_header -> length ) ; ND_TCHECK2 ( * tptr , pdu_len ) ; hexdump = FALSE ; ND_PRINT ( ( ndo , ""%sRPKI-RTRv%u,%sPDU(%u),length:%u"" , indent_string ( 8 ) , pdu_header -> version , tok2str ( rpki_rtr_pdu_values , ""Unknown"" , pdu_type ) , pdu_type , pdu_len ) ) ; switch ( pdu_type ) { case RPKI_RTR_SERIAL_NOTIFY_PDU : case RPKI_RTR_SERIAL_QUERY_PDU : case RPKI_RTR_END_OF_DATA_PDU : msg = ( const u_char * ) ( pdu_header + 1 ) ; ND_PRINT ( ( ndo , ""%sSessionID:0x%04x,Serial:%u"" , indent_string ( indent + 2 ) , EXTRACT_16BITS ( pdu_header -> u . session_id ) , EXTRACT_32BITS ( msg ) ) ) ; break ; case RPKI_RTR_RESET_QUERY_PDU : case RPKI_RTR_CACHE_RESET_PDU : break ; case RPKI_RTR_CACHE_RESPONSE_PDU : ND_PRINT ( ( ndo , ""%sSessionID:0x%04x"" , indent_string ( indent + 2 ) , EXTRACT_16BITS ( pdu_header -> u . session_id ) ) ) ; break ; case RPKI_RTR_IPV4_PREFIX_PDU : { const rpki_rtr_pdu_ipv4_prefix * pdu ; pdu = ( const rpki_rtr_pdu_ipv4_prefix * ) tptr ; ND_PRINT ( ( ndo , ""%sIPv4Prefix%s/%u-%u,origin-as%u,flags0x%02x"" , indent_string ( indent + 2 ) , ipaddr_string ( ndo , pdu -> prefix ) , pdu -> prefix_length , pdu -> max_length , EXTRACT_32BITS ( pdu -> as ) , pdu -> flags ) ) ; } break ; case RPKI_RTR_IPV6_PREFIX_PDU : { const rpki_rtr_pdu_ipv6_prefix * pdu ; pdu = ( const rpki_rtr_pdu_ipv6_prefix * ) tptr ; ND_PRINT ( ( ndo , ""%sIPv6Prefix%s/%u-%u,origin-as%u,flags0x%02x"" , indent_string ( indent + 2 ) , ip6addr_string ( ndo , pdu -> prefix ) , pdu -> prefix_length , pdu -> max_length , EXTRACT_32BITS ( pdu -> as ) , pdu -> flags ) ) ; } break ; case RPKI_RTR_ERROR_REPORT_PDU : { const rpki_rtr_pdu_error_report * pdu ; u_int encapsulated_pdu_length , text_length , tlen , error_code ; pdu = ( const rpki_rtr_pdu_error_report * ) tptr ; encapsulated_pdu_length = EXTRACT_32BITS ( pdu -> encapsulated_pdu_length ) ; ND_TCHECK2 ( * tptr , encapsulated_pdu_length ) ; tlen = pdu_len ; error_code = EXTRACT_16BITS ( pdu -> pdu_header . u . error_code ) ; ND_PRINT ( ( ndo , ""%sErrorcode:%s(%u),EncapsulatedPDUlength:%u"" , indent_string ( indent + 2 ) , tok2str ( rpki_rtr_error_codes , ""Unknown"" , error_code ) , error_code , encapsulated_pdu_length ) ) ; tptr += sizeof ( * pdu ) ; tlen -= sizeof ( * pdu ) ; if ( encapsulated_pdu_length && ( encapsulated_pdu_length <= tlen ) ) { ND_PRINT ( ( ndo , ""%s-----encapsulatedPDU-----"" , indent_string ( indent + 4 ) ) ) ; if ( rpki_rtr_pdu_print ( ndo , tptr , indent + 2 ) ) goto trunc ; } tptr += encapsulated_pdu_length ; tlen -= encapsulated_pdu_length ; text_length = 0 ; if ( tlen > 4 ) { text_length = EXTRACT_32BITS ( tptr ) ; tptr += 4 ; tlen -= 4 ; } ND_TCHECK2 ( * tptr , text_length ) ; if ( text_length && ( text_length <= tlen ) ) { ND_PRINT ( ( ndo , ""%sErrortext:"" , indent_string ( indent + 2 ) ) ) ; if ( fn_printn ( ndo , tptr , text_length , ndo -> ndo_snapend ) ) goto trunc ; } } break ; default : hexdump = TRUE ; } if ( ndo -> ndo_vflag > 1 || ( ndo -> ndo_vflag && hexdump ) ) { print_unknown_data ( ndo , tptr , ""\\n\\t"" , pdu_len ) ; } return 0 ; trunc : return 1 ; } "," static u_int rpki_rtr_pdu_print ( netdissect_options * tptr , const u_int len , const u_char recurse , const * msg ; ND_TCHECK_8BITS ( tptr ) ; if ( * tptr != 0 ) { ND_PRINT ( ( ndo , ""%sRPKI-RTRv%u(unknown)"" , indent_string ( 8 ) , * tptr ) ) ; return len ; } if ( len < sizeof ( rpki_rtr_pdu ) ) { ND_PRINT ( ( ndo , ""(%ubytesistoofewtodecode)"" , len ) ) ; goto invalid ; } ND_TCHECK2 ( * tptr , sizeof ( rpki_rtr_pdu ) ) ; length ) ; hexdump = FALSE pdu_len ) ) ; if ( pdu_len < sizeof ( rpki_rtr_pdu ) || pdu_len > len ) goto invalid case RPKI_RTR_END_OF_DATA_PDU : if ( pdu_len != sizeof ( rpki_rtr_pdu ) + 4 ) goto invalid ; ND_TCHECK2 ( * tptr , pdu_len ) ; case RPKI_RTR_CACHE_RESET_PDU : if ( pdu_len != sizeof ( rpki_rtr_pdu ) ) goto invalid ; case RPKI_RTR_CACHE_RESPONSE_PDU : if ( pdu_len != sizeof ( rpki_rtr_pdu ) ) goto invalid ; * pdu ; if ( pdu_len != sizeof ( rpki_rtr_pdu ) + 12 ) goto invalid ; ND_TCHECK2 ( * tptr , pdu_len ) ; * pdu ; if ( pdu_len != sizeof ( rpki_rtr_pdu ) + 24 ) goto invalid ; ND_TCHECK2 ( * tptr , pdu_len ) ; , error_code ; tlen = sizeof ( rpki_rtr_pdu ) ; if ( pdu_len < tlen + 4 ) goto invalid ; ND_TCHECK2 ( * tptr , tlen + 4 ) ; encapsulated_pdu_length ) ; tlen += 4 ; error_code = ) ) ; if ( encapsulated_pdu_length if ( encapsulated_pdu_length ) { if ( pdu_len < tlen + encapsulated_pdu_length ) goto invalid ; if ( ! recurse ) { ND_TCHECK2 ( * tptr , tlen + encapsulated_pdu_length ) ; } else { ND_PRINT ( ) ) ; rpki_rtr_pdu_print ( ndo ndo , tptr + tlen , encapsulated_pdu_length , 0 + 2 ) ; } tlen += encapsulated_pdu_length ; += encapsulated_pdu_length ; } if ( pdu_len < tlen + 4 ) goto invalid ; ND_TCHECK2 ( * tptr , tlen + 4 ) ; text_length = ; text_length = EXTRACT_32BITS ( tptr EXTRACT_32BITS ( tptr + tlen ) ; tlen += 4 ; += 4 ; if ( text_length ) { if ( pdu_len < tlen + text_length ) goto invalid ; ND_PRINT ( ( ndo , ""%sErrortext:"" , indent_string ( indent + 2 ) ) ) ; if ( fn_printn ( ndo , tptr + tlen , text_length , ndo -> ndo_snapend ) ) goto trunc ; } } break ; default : ND_TCHECK2 ( * * tptr , pdu_len ) ; hexdump = TRUE ; } return pdu_len ; invalid : ND_PRINT ( ( ndo , ""%s"" , istr ) ) ; ND_TCHECK2 ( * tptr , len ) ; return len ; trunc : ; trunc : ND_PRINT ( ( ndo , ""\\n\\t%s"" , tstr ) ) ; return len ; } ",the-tcpdump-group@tcpdump/83c64fce3a5226b080e535f5131a8a318f30e79b,CVE-2017-13050,https://github.com/the-tcpdump-group/tcpdump/commit/83c64fce3a5226b080e535f5131a8a318f30e79b,2017-09-14T06:29Z 113,CWE-20,"CWE-20 int rose_rx_call_request ( struct sk_buff * skb , struct net_device * dev , struct rose_neigh * neigh , unsigned int lci ) { struct sock * sk ; struct sock * make ; struct rose_sock * make_rose ; struct rose_facilities_struct facilities ; int n , len ; skb -> sk = NULL ; memset ( & facilities , 0x00 , sizeof ( struct rose_facilities_struct ) ) ; len = ( ( ( skb -> data [ 3 ] >> 4 ) & 0x0F ) + 1 ) >> 1 ; len += ( ( ( skb -> data [ 3 ] >> 0 ) & 0x0F ) + 1 ) >> 1 ; if ( ! rose_parse_facilities ( skb -> data + len + 4 , & facilities ) ) { rose_transmit_clear_request ( neigh , lci , ROSE_INVALID_FACILITY , 76 ) ; return 0 ; } sk = rose_find_listener ( & facilities . source_addr , & facilities . source_call ) ; if ( sk == NULL || sk_acceptq_is_full ( sk ) || ( make = rose_make_new ( sk ) ) == NULL ) { rose_transmit_clear_request ( neigh , lci , ROSE_NETWORK_CONGESTION , 120 ) ; return 0 ; } skb -> sk = make ; make -> sk_state = TCP_ESTABLISHED ; make_rose = rose_sk ( make ) ; make_rose -> lci = lci ; make_rose -> dest_addr = facilities . dest_addr ; make_rose -> dest_call = facilities . dest_call ; make_rose -> dest_ndigis = facilities . dest_ndigis ; for ( n = 0 ; n < facilities . dest_ndigis ; n ++ ) make_rose -> dest_digis [ n ] = facilities . dest_digis [ n ] ; make_rose -> source_addr = facilities . source_addr ; make_rose -> source_call = facilities . source_call ; make_rose -> source_ndigis = facilities . source_ndigis ; for ( n = 0 ; n < facilities . source_ndigis ; n ++ ) make_rose -> source_digis [ n ] = facilities . source_digis [ n ] ; make_rose -> neighbour = neigh ; make_rose -> device = dev ; make_rose -> facilities = facilities ; make_rose -> neighbour -> use ++ ; if ( rose_sk ( sk ) -> defer ) { make_rose -> state = ROSE_STATE_5 ; } else { rose_write_internal ( make , ROSE_CALL_ACCEPTED ) ; make_rose -> state = ROSE_STATE_3 ; rose_start_idletimer ( make ) ; } make_rose -> condition = 0x00 ; make_rose -> vs = 0 ; make_rose -> va = 0 ; make_rose -> vr = 0 ; make_rose -> vl = 0 ; sk -> sk_ack_backlog ++ ; rose_insert_socket ( make ) ; skb_queue_head ( & sk -> sk_receive_queue , skb ) ; rose_start_heartbeat ( make ) ; if ( ! sock_flag ( sk , SOCK_DEAD ) ) sk -> sk_data_ready ( sk , skb -> len ) ; return 1 ; } "," ; int n ; skb -> rose_facilities_struct ) ) ; if ( -> data + ROSE_CALL_REQ_FACILITIES_OFF , skb -> len - ROSE_CALL_REQ_FACILITIES_OFF , & facilities ) ",torvalds@linux/e0bccd315db0c2f919e7fcf9cb60db21d9986f52,CVE-2011-4914,https://github.com/torvalds/linux/commit/e0bccd315db0c2f919e7fcf9cb60db21d9986f52,2012-06-21T23:55Z 114,CWE-284,"CWE-284 int socket_accept ( int fd , uint16_t port ) { # ifdef WIN32 int addr_len ; # else socklen_t addr_len ; # endif int result ; struct sockaddr_in addr ; memset ( & addr , 0 , sizeof ( addr ) ) ; addr . sin_family = AF_INET ; addr . sin_addr . s_addr = htonl ( INADDR_ANY ) ; addr . sin_port = htons ( port ) ; addr_len = sizeof ( addr ) ; result = accept ( fd , ( struct sockaddr * ) & addr , & addr_len ) ; return result ; } "," = htonl ( INADDR_LOOPBACK ) ; addr ",libimobiledevice@libimobiledevice/df1f5c4d70d0c19ad40072f5246ca457e7f9849e,CVE-2016-5104,https://github.com/libimobiledevice/libimobiledevice/commit/df1f5c4d70d0c19ad40072f5246ca457e7f9849e,2016-06-13T14:59Z 115,CWE-20,"CWE-20 static char_u * did_set_string_option ( int opt_idx , char_u * * varp , int new_value_alloced , char_u * oldval , char_u * errbuf , int opt_flags ) { char_u * errmsg = NULL ; char_u * s , * p ; int did_chartab = FALSE ; char_u * * gvarp ; long_u free_oldval = ( options [ opt_idx ] . flags & P_ALLOCED ) ; # ifdef FEAT_GUI int redraw_gui_only = FALSE ; # endif gvarp = ( char_u * * ) get_varp_scope ( & ( options [ opt_idx ] ) , OPT_GLOBAL ) ; if ( ( secure # ifdef HAVE_SANDBOX || sandbox != 0 # endif ) && ( options [ opt_idx ] . flags & P_SECURE ) ) { errmsg = e_secure ; } else if ( ( options [ opt_idx ] . flags & P_NFNAME ) && vim_strpbrk ( * varp , ( char_u * ) ""/\\\\*?[|<>"" ) != NULL ) { errmsg = e_invarg ; } else if ( varp == & T_NAME ) { if ( T_NAME [ 0 ] == NUL ) errmsg = ( char_u * ) N_ ( ""E529:Cannotset\'term\'toemptystring"" ) ; # ifdef FEAT_GUI if ( gui . in_use ) errmsg = ( char_u * ) N_ ( ""E530:CannotchangeterminGUI"" ) ; else if ( term_is_gui ( T_NAME ) ) errmsg = ( char_u * ) N_ ( ""E531:Use\\"":gui\\""tostarttheGUI"" ) ; # endif else if ( set_termname ( T_NAME ) == FAIL ) errmsg = ( char_u * ) N_ ( ""E522:Notfoundintermcap"" ) ; else redraw_later_clear ( ) ; } else if ( gvarp == & p_bkc ) { char_u * bkc = p_bkc ; unsigned int * flags = & bkc_flags ; if ( opt_flags & OPT_LOCAL ) { bkc = curbuf -> b_p_bkc ; flags = & curbuf -> b_bkc_flags ; } if ( ( opt_flags & OPT_LOCAL ) && * bkc == NUL ) * flags = 0 ; else { if ( opt_strings_flags ( bkc , p_bkc_values , flags , TRUE ) != OK ) errmsg = e_invarg ; if ( ( ( ( int ) * flags & BKC_AUTO ) != 0 ) + ( ( ( int ) * flags & BKC_YES ) != 0 ) + ( ( ( int ) * flags & BKC_NO ) != 0 ) != 1 ) { ( void ) opt_strings_flags ( oldval , p_bkc_values , flags , TRUE ) ; errmsg = e_invarg ; } } } else if ( varp == & p_bex || varp == & p_pm ) { if ( STRCMP ( * p_bex == '.' ? p_bex + 1 : p_bex , * p_pm == '.' ? p_pm + 1 : p_pm ) == 0 ) errmsg = ( char_u * ) N_ ( ""E589:\'backupext\'and\'patchmode\'areequal"" ) ; } # ifdef FEAT_LINEBREAK else if ( varp == & curwin -> w_p_briopt ) { if ( briopt_check ( curwin ) == FAIL ) errmsg = e_invarg ; } # endif else if ( varp == & p_isi || varp == & ( curbuf -> b_p_isk ) || varp == & p_isp || varp == & p_isf ) { if ( init_chartab ( ) == FAIL ) { did_chartab = TRUE ; errmsg = e_invarg ; } } else if ( varp == & p_hf ) { if ( didset_vim ) { vim_setenv ( ( char_u * ) ""VIM"" , ( char_u * ) """" ) ; didset_vim = FALSE ; } if ( didset_vimruntime ) { vim_setenv ( ( char_u * ) ""VIMRUNTIME"" , ( char_u * ) """" ) ; didset_vimruntime = FALSE ; } } # ifdef FEAT_SYN_HL else if ( varp == & curwin -> w_p_cc ) errmsg = check_colorcolumn ( curwin ) ; # endif # ifdef FEAT_MULTI_LANG else if ( varp == & p_hlg ) { for ( s = p_hlg ; * s != NUL ; s += 3 ) { if ( s [ 1 ] == NUL || ( ( s [ 2 ] != ',' || s [ 3 ] == NUL ) && s [ 2 ] != NUL ) ) { errmsg = e_invarg ; break ; } if ( s [ 2 ] == NUL ) break ; } } # endif else if ( varp == & p_hl ) { if ( highlight_changed ( ) == FAIL ) errmsg = e_invarg ; } else if ( gvarp == & p_nf ) { if ( check_opt_strings ( * varp , p_nf_values , TRUE ) != OK ) errmsg = e_invarg ; } # ifdef FEAT_SESSION else if ( varp == & p_ssop ) { if ( opt_strings_flags ( p_ssop , p_ssop_values , & ssop_flags , TRUE ) != OK ) errmsg = e_invarg ; if ( ( ssop_flags & SSOP_CURDIR ) && ( ssop_flags & SSOP_SESDIR ) ) { ( void ) opt_strings_flags ( oldval , p_ssop_values , & ssop_flags , TRUE ) ; errmsg = e_invarg ; } } else if ( varp == & p_vop ) { if ( opt_strings_flags ( p_vop , p_ssop_values , & vop_flags , TRUE ) != OK ) errmsg = e_invarg ; } # endif # ifdef FEAT_SCROLLBIND else if ( varp == & p_sbo ) { if ( check_opt_strings ( p_sbo , p_scbopt_values , TRUE ) != OK ) errmsg = e_invarg ; } # endif # ifdef FEAT_MBYTE else if ( varp == & p_ambw || varp == & p_emoji ) { if ( check_opt_strings ( p_ambw , p_ambw_values , FALSE ) != OK ) errmsg = e_invarg ; else if ( set_chars_option ( & p_lcs ) != NULL ) errmsg = ( char_u * ) _ ( ""E834:Conflictswithvalueof\'listchars\'"" ) ; # if defined ( FEAT_WINDOWS ) || defined ( FEAT_FOLDING ) else if ( set_chars_option ( & p_fcs ) != NULL ) errmsg = ( char_u * ) _ ( ""E835:Conflictswithvalueof\'fillchars\'"" ) ; # endif } # endif else if ( varp == & p_bg ) { if ( check_opt_strings ( p_bg , p_bg_values , FALSE ) == OK ) { # ifdef FEAT_EVAL int dark = ( * p_bg == 'd' ) ; # endif init_highlight ( FALSE , FALSE ) ; # ifdef FEAT_EVAL if ( dark != ( * p_bg == 'd' ) && get_var_value ( ( char_u * ) ""g:colors_name"" ) != NULL ) { do_unlet ( ( char_u * ) ""g:colors_name"" , TRUE ) ; free_string_option ( p_bg ) ; p_bg = vim_strsave ( ( char_u * ) ( dark ? ""dark"" : ""light"" ) ) ; check_string_option ( & p_bg ) ; init_highlight ( FALSE , FALSE ) ; } # endif } else errmsg = e_invarg ; } else if ( varp == & p_wim ) { if ( check_opt_wim ( ) == FAIL ) errmsg = e_invarg ; } # ifdef FEAT_CMDL_COMPL else if ( varp == & p_wop ) { if ( check_opt_strings ( p_wop , p_wop_values , TRUE ) != OK ) errmsg = e_invarg ; } # endif # ifdef FEAT_WAK else if ( varp == & p_wak ) { if ( * p_wak == NUL || check_opt_strings ( p_wak , p_wak_values , FALSE ) != OK ) errmsg = e_invarg ; # ifdef FEAT_MENU # ifdef FEAT_GUI_MOTIF else if ( gui . in_use ) gui_motif_set_mnemonics ( p_wak [ 0 ] == 'y' || p_wak [ 0 ] == 'm' ) ; # else # ifdef FEAT_GUI_GTK else if ( gui . in_use ) gui_gtk_set_mnemonics ( p_wak [ 0 ] == 'y' || p_wak [ 0 ] == 'm' ) ; # endif # endif # endif } # endif # ifdef FEAT_AUTOCMD else if ( varp == & p_ei ) { if ( check_ei ( ) == FAIL ) errmsg = e_invarg ; } # endif # ifdef FEAT_MBYTE else if ( varp == & p_enc || gvarp == & p_fenc || varp == & p_tenc ) { if ( gvarp == & p_fenc ) { if ( ! curbuf -> b_p_ma && opt_flags != OPT_GLOBAL ) errmsg = e_modifiable ; else if ( vim_strchr ( * varp , ',' ) != NULL ) errmsg = e_invarg ; else { # ifdef FEAT_TITLE redraw_titles ( ) ; # endif ml_setflags ( curbuf ) ; } } if ( errmsg == NULL ) { p = enc_canonize ( * varp ) ; if ( p != NULL ) { vim_free ( * varp ) ; * varp = p ; } if ( varp == & p_enc ) { errmsg = mb_init ( ) ; # ifdef FEAT_TITLE redraw_titles ( ) ; # endif } } # if defined ( FEAT_GUI_GTK ) if ( errmsg == NULL && varp == & p_tenc && gui . in_use ) { if ( STRCMP ( p_tenc , ""utf-8"" ) != 0 ) errmsg = ( char_u * ) N_ ( ""E617:CannotbechangedintheGTK+2GUI"" ) ; } # endif if ( errmsg == NULL ) { # ifdef FEAT_KEYMAP if ( varp == & p_enc && * curbuf -> b_p_keymap != NUL ) ( void ) keymap_init ( ) ; # endif if ( ( ( varp == & p_enc && * p_tenc != NUL ) || varp == & p_tenc ) ) { convert_setup ( & input_conv , p_tenc , p_enc ) ; convert_setup ( & output_conv , p_enc , p_tenc ) ; } # if defined ( WIN3264 ) && defined ( FEAT_MBYTE ) if ( varp == & p_enc ) init_homedir ( ) ; # endif } } # endif # if defined ( FEAT_POSTSCRIPT ) else if ( varp == & p_penc ) { p = enc_canonize ( p_penc ) ; if ( p != NULL ) { vim_free ( p_penc ) ; p_penc = p ; } else { for ( s = p_penc ; * s != NUL ; s ++ ) { if ( * s == '_' ) * s = '-' ; else * s = TOLOWER_ASC ( * s ) ; } } } # endif # if defined ( FEAT_XIM ) && defined ( FEAT_GUI_GTK ) else if ( varp == & p_imak ) { if ( gui . in_use && ! im_xim_isvalid_imactivate ( ) ) errmsg = e_invarg ; } # endif # ifdef FEAT_KEYMAP else if ( varp == & curbuf -> b_p_keymap ) { errmsg = keymap_init ( ) ; if ( errmsg == NULL ) { if ( * curbuf -> b_p_keymap != NUL ) { curbuf -> b_p_iminsert = B_IMODE_LMAP ; if ( curbuf -> b_p_imsearch != B_IMODE_USE_INSERT ) curbuf -> b_p_imsearch = B_IMODE_LMAP ; } else { if ( curbuf -> b_p_iminsert == B_IMODE_LMAP ) curbuf -> b_p_iminsert = B_IMODE_NONE ; if ( curbuf -> b_p_imsearch == B_IMODE_LMAP ) curbuf -> b_p_imsearch = B_IMODE_USE_INSERT ; } if ( ( opt_flags & OPT_LOCAL ) == 0 ) { set_iminsert_global ( ) ; set_imsearch_global ( ) ; } # ifdef FEAT_WINDOWS status_redraw_curbuf ( ) ; # endif } } # endif else if ( gvarp == & p_ff ) { if ( ! curbuf -> b_p_ma && ! ( opt_flags & OPT_GLOBAL ) ) errmsg = e_modifiable ; else if ( check_opt_strings ( * varp , p_ff_values , FALSE ) != OK ) errmsg = e_invarg ; else { if ( get_fileformat ( curbuf ) == EOL_DOS ) curbuf -> b_p_tx = TRUE ; else curbuf -> b_p_tx = FALSE ; # ifdef FEAT_TITLE redraw_titles ( ) ; # endif ml_setflags ( curbuf ) ; if ( get_fileformat ( curbuf ) == EOL_MAC || * oldval == 'm' ) redraw_curbuf_later ( NOT_VALID ) ; } } else if ( varp == & p_ffs ) { if ( check_opt_strings ( p_ffs , p_ff_values , TRUE ) != OK ) errmsg = e_invarg ; else { if ( * p_ffs == NUL ) p_ta = FALSE ; else p_ta = TRUE ; } } # if defined ( FEAT_CRYPT ) else if ( gvarp == & p_key ) { # if defined ( FEAT_CMDHIST ) remove_key_from_history ( ) ; # endif if ( STRCMP ( curbuf -> b_p_key , oldval ) != 0 ) ml_set_crypt_key ( curbuf , oldval , * curbuf -> b_p_cm == NUL ? p_cm : curbuf -> b_p_cm ) ; } else if ( gvarp == & p_cm ) { if ( opt_flags & OPT_LOCAL ) p = curbuf -> b_p_cm ; else p = p_cm ; if ( check_opt_strings ( p , p_cm_values , TRUE ) != OK ) errmsg = e_invarg ; else if ( crypt_self_test ( ) == FAIL ) errmsg = e_invarg ; else { if ( * p_cm == NUL ) { if ( new_value_alloced ) free_string_option ( p_cm ) ; p_cm = vim_strsave ( ( char_u * ) ""zip"" ) ; new_value_alloced = TRUE ; } if ( ( opt_flags & ( OPT_LOCAL | OPT_GLOBAL ) ) == 0 ) { free_string_option ( curbuf -> b_p_cm ) ; curbuf -> b_p_cm = empty_option ; } if ( ( opt_flags & OPT_LOCAL ) && * oldval == NUL ) s = p_cm ; else s = oldval ; if ( * curbuf -> b_p_cm == NUL ) p = p_cm ; else p = curbuf -> b_p_cm ; if ( STRCMP ( s , p ) != 0 ) ml_set_crypt_key ( curbuf , curbuf -> b_p_key , s ) ; if ( ( opt_flags & OPT_GLOBAL ) && STRCMP ( p_cm , oldval ) != 0 ) { buf_T * buf ; FOR_ALL_BUFFERS ( buf ) if ( buf != curbuf && * buf -> b_p_cm == NUL ) ml_set_crypt_key ( buf , buf -> b_p_key , oldval ) ; } } } # endif else if ( gvarp == & p_mps ) { # ifdef FEAT_MBYTE if ( has_mbyte ) { for ( p = * varp ; * p != NUL ; ++ p ) { int x2 = - 1 ; int x3 = - 1 ; if ( * p != NUL ) p += mb_ptr2len ( p ) ; if ( * p != NUL ) x2 = * p ++ ; if ( * p != NUL ) { x3 = mb_ptr2char ( p ) ; p += mb_ptr2len ( p ) ; } if ( x2 != ':' || x3 == - 1 || ( * p != NUL && * p != ',' ) ) { errmsg = e_invarg ; break ; } if ( * p == NUL ) break ; } } else # endif { for ( p = * varp ; * p != NUL ; p += 4 ) { if ( p [ 1 ] != ':' || p [ 2 ] == NUL || ( p [ 3 ] != NUL && p [ 3 ] != ',' ) ) { errmsg = e_invarg ; break ; } if ( p [ 3 ] == NUL ) break ; } } } # ifdef FEAT_COMMENTS else if ( gvarp == & p_com ) { for ( s = * varp ; * s ; ) { while ( * s && * s != ':' ) { if ( vim_strchr ( ( char_u * ) COM_ALL , * s ) == NULL && ! VIM_ISDIGIT ( * s ) && * s != '-' ) { errmsg = illegal_char ( errbuf , * s ) ; break ; } ++ s ; } if ( * s ++ == NUL ) errmsg = ( char_u * ) N_ ( ""E524:Missingcolon"" ) ; else if ( * s == ',' || * s == NUL ) errmsg = ( char_u * ) N_ ( ""E525:Zerolengthstring"" ) ; if ( errmsg != NULL ) break ; while ( * s && * s != ',' ) { if ( * s == '\\\\' && s [ 1 ] != NUL ) ++ s ; ++ s ; } s = skip_to_option_part ( s ) ; } } # endif else if ( varp == & p_lcs ) { errmsg = set_chars_option ( varp ) ; } # if defined ( FEAT_WINDOWS ) || defined ( FEAT_FOLDING ) else if ( varp == & p_fcs ) { errmsg = set_chars_option ( varp ) ; } # endif # ifdef FEAT_CMDWIN else if ( varp == & p_cedit ) { errmsg = check_cedit ( ) ; } # endif else if ( varp == & p_vfile ) { verbose_stop ( ) ; if ( * p_vfile != NUL && verbose_open ( ) == FAIL ) errmsg = e_invarg ; } # ifdef FEAT_VIMINFO else if ( varp == & p_viminfo ) { for ( s = p_viminfo ; * s ; ) { if ( vim_strchr ( ( char_u * ) ""!\\""%\'/:<@cfhnrs"" , * s ) == NULL ) { errmsg = illegal_char ( errbuf , * s ) ; break ; } if ( * s == 'n' ) { break ; } else if ( * s == 'r' ) { while ( * ++ s && * s != ',' ) ; } else if ( * s == '%' ) { while ( vim_isdigit ( * ++ s ) ) ; } else if ( * s == '!' || * s == 'h' || * s == 'c' ) ++ s ; else { while ( vim_isdigit ( * ++ s ) ) ; if ( ! VIM_ISDIGIT ( * ( s - 1 ) ) ) { if ( errbuf != NULL ) { sprintf ( ( char * ) errbuf , _ ( ""E526:Missingnumberafter<%s>"" ) , transchar_byte ( * ( s - 1 ) ) ) ; errmsg = errbuf ; } else errmsg = ( char_u * ) """" ; break ; } } if ( * s == ',' ) ++ s ; else if ( * s ) { if ( errbuf != NULL ) errmsg = ( char_u * ) N_ ( ""E527:Missingcomma"" ) ; else errmsg = ( char_u * ) """" ; break ; } } if ( * p_viminfo && errmsg == NULL && get_viminfo_parameter ( '\\'' ) < 0 ) errmsg = ( char_u * ) N_ ( ""E528:Mustspecifya\'value"" ) ; } # endif else if ( istermoption ( & options [ opt_idx ] ) && full_screen ) { if ( varp == & T_CCO ) { int colors = atoi ( ( char * ) T_CCO ) ; if ( colors != t_colors ) { t_colors = colors ; if ( t_colors <= 1 ) { if ( new_value_alloced ) vim_free ( T_CCO ) ; T_CCO = empty_option ; } init_highlight ( TRUE , FALSE ) ; } } ttest ( FALSE ) ; if ( varp == & T_ME ) { out_str ( T_ME ) ; redraw_later ( CLEAR ) ; # if defined ( WIN3264 ) && ! defined ( FEAT_GUI_W32 ) mch_set_normal_colors ( ) ; # endif } } # ifdef FEAT_LINEBREAK else if ( varp == & p_sbr ) { for ( s = p_sbr ; * s ; ) { if ( ptr2cells ( s ) != 1 ) errmsg = ( char_u * ) N_ ( ""E595:containsunprintableorwidecharacter"" ) ; mb_ptr_adv ( s ) ; } } # endif # ifdef FEAT_GUI else if ( varp == & p_guifont ) { if ( gui . in_use ) { p = p_guifont ; # if defined ( FEAT_GUI_GTK ) if ( STRCMP ( p , ""*"" ) == 0 ) { p = gui_mch_font_dialog ( oldval ) ; if ( new_value_alloced ) free_string_option ( p_guifont ) ; p_guifont = ( p != NULL ) ? p : vim_strsave ( oldval ) ; new_value_alloced = TRUE ; } # endif if ( p != NULL && gui_init_font ( p_guifont , FALSE ) != OK ) { # if defined ( FEAT_GUI_MSWIN ) || defined ( FEAT_GUI_PHOTON ) if ( STRCMP ( p_guifont , ""*"" ) == 0 ) { if ( new_value_alloced ) free_string_option ( p_guifont ) ; p_guifont = vim_strsave ( oldval ) ; new_value_alloced = TRUE ; } else # endif errmsg = ( char_u * ) N_ ( ""E596:Invalidfont(s)"" ) ; } } redraw_gui_only = TRUE ; } # ifdef FEAT_XFONTSET else if ( varp == & p_guifontset ) { if ( STRCMP ( p_guifontset , ""*"" ) == 0 ) errmsg = ( char_u * ) N_ ( ""E597:can\'tselectfontset"" ) ; else if ( gui . in_use && gui_init_font ( p_guifontset , TRUE ) != OK ) errmsg = ( char_u * ) N_ ( ""E598:Invalidfontset"" ) ; redraw_gui_only = TRUE ; } # endif # ifdef FEAT_MBYTE else if ( varp == & p_guifontwide ) { if ( STRCMP ( p_guifontwide , ""*"" ) == 0 ) errmsg = ( char_u * ) N_ ( ""E533:can\'tselectwidefont"" ) ; else if ( gui_get_wide_font ( ) == FAIL ) errmsg = ( char_u * ) N_ ( ""E534:Invalidwidefont"" ) ; redraw_gui_only = TRUE ; } # endif # endif # ifdef CURSOR_SHAPE else if ( varp == & p_guicursor ) errmsg = parse_shape_opt ( SHAPE_CURSOR ) ; # endif # ifdef FEAT_MOUSESHAPE else if ( varp == & p_mouseshape ) { errmsg = parse_shape_opt ( SHAPE_MOUSE ) ; update_mouseshape ( - 1 ) ; } # endif # ifdef FEAT_PRINTER else if ( varp == & p_popt ) errmsg = parse_printoptions ( ) ; # if defined ( FEAT_MBYTE ) && defined ( FEAT_POSTSCRIPT ) else if ( varp == & p_pmfn ) errmsg = parse_printmbfont ( ) ; # endif # endif # ifdef FEAT_LANGMAP else if ( varp == & p_langmap ) langmap_set ( ) ; # endif # ifdef FEAT_LINEBREAK else if ( varp == & p_breakat ) fill_breakat_flags ( ) ; # endif # ifdef FEAT_TITLE else if ( varp == & p_titlestring || varp == & p_iconstring ) { # ifdef FEAT_STL_OPT int flagval = ( varp == & p_titlestring ) ? STL_IN_TITLE : STL_IN_ICON ; if ( vim_strchr ( * varp , '%' ) && check_stl_option ( * varp ) == NULL ) stl_syntax |= flagval ; else stl_syntax &= ~ flagval ; # endif did_set_title ( varp == & p_iconstring ) ; } # endif # ifdef FEAT_GUI else if ( varp == & p_go ) { gui_init_which_components ( oldval ) ; redraw_gui_only = TRUE ; } # endif # if defined ( FEAT_GUI_TABLINE ) else if ( varp == & p_gtl ) { redraw_tabline = TRUE ; redraw_gui_only = TRUE ; } else if ( varp == & p_gtt ) { redraw_gui_only = TRUE ; } # endif # if defined ( FEAT_MOUSE_TTY ) && ( defined ( UNIX ) || defined ( VMS ) ) else if ( varp == & p_ttym ) { mch_setmouse ( FALSE ) ; if ( opt_strings_flags ( p_ttym , p_ttym_values , & ttym_flags , FALSE ) != OK ) errmsg = e_invarg ; else check_mouse_termcode ( ) ; if ( termcap_active ) setmouse ( ) ; } # endif else if ( varp == & p_sel ) { if ( * p_sel == NUL || check_opt_strings ( p_sel , p_sel_values , FALSE ) != OK ) errmsg = e_invarg ; } else if ( varp == & p_slm ) { if ( check_opt_strings ( p_slm , p_slm_values , TRUE ) != OK ) errmsg = e_invarg ; } # ifdef FEAT_BROWSE else if ( varp == & p_bsdir ) { if ( check_opt_strings ( p_bsdir , p_bsdir_values , FALSE ) != OK && ! mch_isdir ( p_bsdir ) ) errmsg = e_invarg ; } # endif else if ( varp == & p_km ) { if ( check_opt_strings ( p_km , p_km_values , TRUE ) != OK ) errmsg = e_invarg ; else { km_stopsel = ( vim_strchr ( p_km , 'o' ) != NULL ) ; km_startsel = ( vim_strchr ( p_km , 'a' ) != NULL ) ; } } else if ( varp == & p_mousem ) { if ( check_opt_strings ( p_mousem , p_mousem_values , FALSE ) != OK ) errmsg = e_invarg ; # if defined ( FEAT_GUI_MOTIF ) && defined ( FEAT_MENU ) && ( XmVersion <= 1002 ) else if ( * p_mousem != * oldval ) gui_motif_update_mousemodel ( root_menu ) ; # endif } else if ( varp == & p_swb ) { if ( opt_strings_flags ( p_swb , p_swb_values , & swb_flags , TRUE ) != OK ) errmsg = e_invarg ; } else if ( varp == & p_debug ) { if ( check_opt_strings ( p_debug , p_debug_values , TRUE ) != OK ) errmsg = e_invarg ; } else if ( varp == & p_dy ) { if ( opt_strings_flags ( p_dy , p_dy_values , & dy_flags , TRUE ) != OK ) errmsg = e_invarg ; else ( void ) init_chartab ( ) ; } # ifdef FEAT_WINDOWS else if ( varp == & p_ead ) { if ( check_opt_strings ( p_ead , p_ead_values , FALSE ) != OK ) errmsg = e_invarg ; } # endif # ifdef FEAT_CLIPBOARD else if ( varp == & p_cb ) errmsg = check_clipboard_option ( ) ; # endif # ifdef FEAT_SPELL else if ( varp == & ( curwin -> w_s -> b_p_spl ) || varp == & ( curwin -> w_s -> b_p_spf ) ) { errmsg = did_set_spell_option ( varp == & ( curwin -> w_s -> b_p_spf ) ) ; } else if ( varp == & ( curwin -> w_s -> b_p_spc ) ) { errmsg = compile_cap_prog ( curwin -> w_s ) ; } else if ( varp == & p_sps ) { if ( spell_check_sps ( ) != OK ) errmsg = e_invarg ; } else if ( varp == & p_msm ) { if ( spell_check_msm ( ) != OK ) errmsg = e_invarg ; } # endif # ifdef FEAT_QUICKFIX else if ( gvarp == & p_bh ) { if ( check_opt_strings ( curbuf -> b_p_bh , p_bufhidden_values , FALSE ) != OK ) errmsg = e_invarg ; } else if ( gvarp == & p_bt ) { if ( check_opt_strings ( curbuf -> b_p_bt , p_buftype_values , FALSE ) != OK ) errmsg = e_invarg ; else { # ifdef FEAT_WINDOWS if ( curwin -> w_status_height ) { curwin -> w_redr_status = TRUE ; redraw_later ( VALID ) ; } # endif curbuf -> b_help = ( curbuf -> b_p_bt [ 0 ] == 'h' ) ; # ifdef FEAT_TITLE redraw_titles ( ) ; # endif } } # endif # ifdef FEAT_STL_OPT else if ( gvarp == & p_stl || varp == & p_ruf ) { int wid ; if ( varp == & p_ruf ) ru_wid = 0 ; s = * varp ; if ( varp == & p_ruf && * s == '%' ) { if ( * ++ s == '-' ) s ++ ; wid = getdigits ( & s ) ; if ( wid && * s == '(' && ( errmsg = check_stl_option ( p_ruf ) ) == NULL ) ru_wid = wid ; else errmsg = check_stl_option ( p_ruf ) ; } else if ( varp == & p_ruf || s [ 0 ] != '%' || s [ 1 ] != '!' ) errmsg = check_stl_option ( s ) ; if ( varp == & p_ruf && errmsg == NULL ) comp_col ( ) ; } # endif # ifdef FEAT_INS_EXPAND else if ( gvarp == & p_cpt ) { for ( s = * varp ; * s ; ) { while ( * s == ',' || * s == '' ) s ++ ; if ( ! * s ) break ; if ( vim_strchr ( ( char_u * ) "".wbuksid]tU"" , * s ) == NULL ) { errmsg = illegal_char ( errbuf , * s ) ; break ; } if ( * ++ s != NUL && * s != ',' && * s != '' ) { if ( s [ - 1 ] == 'k' || s [ - 1 ] == 's' ) { while ( * s && * s != ',' && * s != '' ) { if ( * s == '\\\\' ) ++ s ; ++ s ; } } else { if ( errbuf != NULL ) { sprintf ( ( char * ) errbuf , _ ( ""E535:Illegalcharacterafter<%c>"" ) , * -- s ) ; errmsg = errbuf ; } else errmsg = ( char_u * ) """" ; break ; } } } } else if ( varp == & p_cot ) { if ( check_opt_strings ( p_cot , p_cot_values , TRUE ) != OK ) errmsg = e_invarg ; else completeopt_was_set ( ) ; } # endif # ifdef FEAT_SIGNS else if ( varp == & curwin -> w_p_scl ) { if ( check_opt_strings ( * varp , p_scl_values , FALSE ) != OK ) errmsg = e_invarg ; } # endif # if defined ( FEAT_TOOLBAR ) && ! defined ( FEAT_GUI_W32 ) else if ( varp == & p_toolbar ) { if ( opt_strings_flags ( p_toolbar , p_toolbar_values , & toolbar_flags , TRUE ) != OK ) errmsg = e_invarg ; else { out_flush ( ) ; gui_mch_show_toolbar ( ( toolbar_flags & ( TOOLBAR_TEXT | TOOLBAR_ICONS ) ) != 0 ) ; } } # endif # if defined ( FEAT_TOOLBAR ) && defined ( FEAT_GUI_GTK ) else if ( varp == & p_tbis ) { if ( opt_strings_flags ( p_tbis , p_tbis_values , & tbis_flags , FALSE ) != OK ) errmsg = e_invarg ; else { out_flush ( ) ; gui_mch_show_toolbar ( ( toolbar_flags & ( TOOLBAR_TEXT | TOOLBAR_ICONS ) ) != 0 ) ; } } # endif else if ( varp == & p_pt ) { if ( * p_pt ) { ( void ) replace_termcodes ( p_pt , & p , TRUE , TRUE , FALSE ) ; if ( p != NULL ) { if ( new_value_alloced ) free_string_option ( p_pt ) ; p_pt = p ; new_value_alloced = TRUE ; } } } else if ( varp == & p_bs ) { if ( VIM_ISDIGIT ( * p_bs ) ) { if ( * p_bs > '2' || p_bs [ 1 ] != NUL ) errmsg = e_invarg ; } else if ( check_opt_strings ( p_bs , p_bs_values , TRUE ) != OK ) errmsg = e_invarg ; } else if ( varp == & p_bo ) { if ( opt_strings_flags ( p_bo , p_bo_values , & bo_flags , TRUE ) != OK ) errmsg = e_invarg ; } else if ( gvarp == & p_tc ) { unsigned int * flags ; if ( opt_flags & OPT_LOCAL ) { p = curbuf -> b_p_tc ; flags = & curbuf -> b_tc_flags ; } else { p = p_tc ; flags = & tc_flags ; } if ( ( opt_flags & OPT_LOCAL ) && * p == NUL ) * flags = 0 ; else if ( * p == NUL || opt_strings_flags ( p , p_tc_values , flags , FALSE ) != OK ) errmsg = e_invarg ; } # ifdef FEAT_MBYTE else if ( varp == & p_cmp ) { if ( opt_strings_flags ( p_cmp , p_cmp_values , & cmp_flags , TRUE ) != OK ) errmsg = e_invarg ; } # endif # ifdef FEAT_DIFF else if ( varp == & p_dip ) { if ( diffopt_changed ( ) == FAIL ) errmsg = e_invarg ; } # endif # ifdef FEAT_FOLDING else if ( gvarp == & curwin -> w_allbuf_opt . wo_fdm ) { if ( check_opt_strings ( * varp , p_fdm_values , FALSE ) != OK || * curwin -> w_p_fdm == NUL ) errmsg = e_invarg ; else { foldUpdateAll ( curwin ) ; if ( foldmethodIsDiff ( curwin ) ) newFoldLevel ( ) ; } } # ifdef FEAT_EVAL else if ( varp == & curwin -> w_p_fde ) { if ( foldmethodIsExpr ( curwin ) ) foldUpdateAll ( curwin ) ; } # endif else if ( gvarp == & curwin -> w_allbuf_opt . wo_fmr ) { p = vim_strchr ( * varp , ',' ) ; if ( p == NULL ) errmsg = ( char_u * ) N_ ( ""E536:commarequired"" ) ; else if ( p == * varp || p [ 1 ] == NUL ) errmsg = e_invarg ; else if ( foldmethodIsMarker ( curwin ) ) foldUpdateAll ( curwin ) ; } else if ( gvarp == & p_cms ) { if ( * * varp != NUL && strstr ( ( char * ) * varp , ""%s"" ) == NULL ) errmsg = ( char_u * ) N_ ( ""E537:\'commentstring\'mustbeemptyorcontain%s"" ) ; } else if ( varp == & p_fdo ) { if ( opt_strings_flags ( p_fdo , p_fdo_values , & fdo_flags , TRUE ) != OK ) errmsg = e_invarg ; } else if ( varp == & p_fcl ) { if ( check_opt_strings ( p_fcl , p_fcl_values , TRUE ) != OK ) errmsg = e_invarg ; } else if ( gvarp == & curwin -> w_allbuf_opt . wo_fdi ) { if ( foldmethodIsIndent ( curwin ) ) foldUpdateAll ( curwin ) ; } # endif # ifdef FEAT_VIRTUALEDIT else if ( varp == & p_ve ) { if ( opt_strings_flags ( p_ve , p_ve_values , & ve_flags , TRUE ) != OK ) errmsg = e_invarg ; else if ( STRCMP ( p_ve , oldval ) != 0 ) { validate_virtcol ( ) ; coladvance ( curwin -> w_virtcol ) ; } } # endif # if defined ( FEAT_CSCOPE ) && defined ( FEAT_QUICKFIX ) else if ( varp == & p_csqf ) { if ( p_csqf != NULL ) { p = p_csqf ; while ( * p != NUL ) { if ( vim_strchr ( ( char_u * ) CSQF_CMDS , * p ) == NULL || p [ 1 ] == NUL || vim_strchr ( ( char_u * ) CSQF_FLAGS , p [ 1 ] ) == NULL || ( p [ 2 ] != NUL && p [ 2 ] != ',' ) ) { errmsg = e_invarg ; break ; } else if ( p [ 2 ] == NUL ) break ; else p += 3 ; } } } # endif # ifdef FEAT_CINDENT else if ( gvarp == & p_cino ) { parse_cino ( curbuf ) ; } # endif # if defined ( FEAT_RENDER_OPTIONS ) else if ( varp == & p_rop && gui . in_use ) { if ( ! gui_mch_set_rendering_options ( p_rop ) ) errmsg = e_invarg ; } # endif else { p = NULL ; if ( varp == & p_ww ) p = ( char_u * ) WW_ALL ; if ( varp == & p_shm ) p = ( char_u * ) SHM_ALL ; else if ( varp == & ( p_cpo ) ) p = ( char_u * ) CPO_ALL ; else if ( varp == & ( curbuf -> b_p_fo ) ) p = ( char_u * ) FO_ALL ; # ifdef FEAT_CONCEAL else if ( varp == & curwin -> w_p_cocu ) p = ( char_u * ) COCU_ALL ; # endif else if ( varp == & p_mouse ) { # ifdef FEAT_MOUSE p = ( char_u * ) MOUSE_ALL ; # else if ( * p_mouse != NUL ) errmsg = ( char_u * ) N_ ( ""E538:Nomousesupport"" ) ; # endif } # if defined ( FEAT_GUI ) else if ( varp == & p_go ) p = ( char_u * ) GO_ALL ; # endif if ( p != NULL ) { for ( s = * varp ; * s ; ++ s ) if ( vim_strchr ( p , * s ) == NULL ) { errmsg = illegal_char ( errbuf , * s ) ; break ; } } } if ( errmsg != NULL ) { if ( new_value_alloced ) free_string_option ( * varp ) ; * varp = oldval ; if ( did_chartab ) ( void ) init_chartab ( ) ; if ( varp == & p_hl ) ( void ) highlight_changed ( ) ; } else { # ifdef FEAT_EVAL set_option_scriptID_idx ( opt_idx , opt_flags , current_SID ) ; # endif if ( free_oldval ) free_string_option ( oldval ) ; if ( new_value_alloced ) options [ opt_idx ] . flags |= P_ALLOCED ; else options [ opt_idx ] . flags &= ~ P_ALLOCED ; if ( ( opt_flags & ( OPT_LOCAL | OPT_GLOBAL ) ) == 0 && ( ( int ) options [ opt_idx ] . indir & PV_BOTH ) ) { p = get_varp_scope ( & ( options [ opt_idx ] ) , OPT_LOCAL ) ; free_string_option ( * ( char_u * * ) p ) ; * ( char_u * * ) p = empty_option ; } else if ( ! ( opt_flags & OPT_LOCAL ) && opt_flags != OPT_GLOBAL ) set_string_option_global ( opt_idx , varp ) ; # ifdef FEAT_AUTOCMD # ifdef FEAT_SYN_HL if ( varp == & ( curbuf -> b_p_syn ) ) { apply_autocmds ( EVENT_SYNTAX , curbuf -> b_p_syn , curbuf -> b_fname , TRUE , curbuf ) ; } # endif else if ( varp == & ( curbuf -> b_p_ft ) ) { did_filetype = TRUE ; apply_autocmds ( EVENT_FILETYPE , curbuf -> b_p_ft , curbuf -> b_fname , TRUE , curbuf ) ; } # endif # ifdef FEAT_SPELL if ( varp == & ( curwin -> w_s -> b_p_spl ) ) { char_u fname [ 200 ] ; char_u * q = curwin -> w_s -> b_p_spl ; if ( STRNCMP ( q , ""cjk,"" , 4 ) == 0 ) q += 4 ; for ( p = q ; * p != NUL ; ++ p ) if ( vim_strchr ( ( char_u * ) ""_.,"" , * p ) != NULL ) break ; vim_snprintf ( ( char * ) fname , 200 , ""spell/%.*s.vim"" , ( int ) ( p - q ) , q ) ; source_runtime ( fname , DIP_ALL ) ; } # endif } # ifdef FEAT_MOUSE if ( varp == & p_mouse ) { # ifdef FEAT_MOUSE_TTY if ( * p_mouse == NUL ) mch_setmouse ( FALSE ) ; else # endif setmouse ( ) ; } # endif if ( curwin -> w_curswant != MAXCOL && ( options [ opt_idx ] . flags & ( P_CURSWANT | P_RALL ) ) != 0 ) curwin -> w_set_curswant = TRUE ; # ifdef FEAT_GUI if ( ! redraw_gui_only || gui . in_use ) # endif check_redraw ( options [ opt_idx ] . flags ) ; return errmsg ; } "," b_p_keymap ) { if ( ! valid_filetype ( * varp ) ) errmsg = e_invarg ; else gui_mch_set_rendering_options ( p_rop ) ) errmsg = e_invarg ; } # endif # ifdef FEAT_AUTOCMD else if ( gvarp == & p_ft ) { if ( ! valid_filetype ( * varp ) ) errmsg = e_invarg ; } # endif # ifdef FEAT_SYN_HL else if ( gvarp == & p_syn ) { if ( ! valid_filetype ( * varp ",vim@vim/d0b5138ba4bccff8a744c99836041ef6322ed39a,CVE-2016-1248,https://github.com/vim/vim/commit/d0b5138ba4bccff8a744c99836041ef6322ed39a,2016-11-23T15:59Z 116,CWE-285,"CWE-285 int ceph_set_acl ( struct inode * inode , struct posix_acl * acl , int type ) { int ret = 0 , size = 0 ; const char * name = NULL ; char * value = NULL ; struct iattr newattrs ; umode_t new_mode = inode -> i_mode , old_mode = inode -> i_mode ; switch ( type ) { case ACL_TYPE_ACCESS : name = XATTR_NAME_POSIX_ACL_ACCESS ; if ( acl ) { ret = posix_acl_equiv_mode ( acl , & new_mode ) ; if ( ret < 0 ) goto out ; if ( ret == 0 ) acl = NULL ; } break ; case ACL_TYPE_DEFAULT : if ( ! S_ISDIR ( inode -> i_mode ) ) { ret = acl ? - EINVAL : 0 ; goto out ; } name = XATTR_NAME_POSIX_ACL_DEFAULT ; break ; default : ret = - EINVAL ; goto out ; } if ( acl ) { size = posix_acl_xattr_size ( acl -> a_count ) ; value = kmalloc ( size , GFP_NOFS ) ; if ( ! value ) { ret = - ENOMEM ; goto out ; } ret = posix_acl_to_xattr ( & init_user_ns , acl , value , size ) ; if ( ret < 0 ) goto out_free ; } if ( new_mode != old_mode ) { newattrs . ia_mode = new_mode ; newattrs . ia_valid = ATTR_MODE ; ret = __ceph_setattr ( inode , & newattrs ) ; if ( ret ) goto out_free ; } ret = __ceph_setxattr ( inode , name , value , size , 0 ) ; if ( ret ) { if ( new_mode != old_mode ) { newattrs . ia_mode = old_mode ; newattrs . ia_valid = ATTR_MODE ; __ceph_setattr ( inode , & newattrs ) ; } goto out_free ; } ceph_set_cached_acl ( inode , type , acl ) ; out_free : kfree ( value ) ; out : return ret ; } "," { ret = posix_acl_update_mode ( inode , & new_mode , & acl ) ; if ( ret ) goto out ; } break ",torvalds@linux/073931017b49d9458aa351605b43a7e34598caef,CVE-2016-7097,https://github.com/torvalds/linux/commit/073931017b49d9458aa351605b43a7e34598caef,2016-10-16T21:59Z 117,CWE-476,"CWE-476 static ssize_t o2nm_node_ipv4_address_store ( struct config_item * item , const char * page , size_t count ) { struct o2nm_node * node = to_o2nm_node ( item ) ; struct o2nm_cluster * cluster = to_o2nm_cluster_from_node ( node ) ; int ret , i ; struct rb_node * * p , * parent ; unsigned int octets [ 4 ] ; __be32 ipv4_addr = 0 ; ret = sscanf ( page , ""%3u.%3u.%3u.%3u"" , & octets [ 3 ] , & octets [ 2 ] , & octets [ 1 ] , & octets [ 0 ] ) ; if ( ret != 4 ) return - EINVAL ; for ( i = 0 ; i < ARRAY_SIZE ( octets ) ; i ++ ) { if ( octets [ i ] > 255 ) return - ERANGE ; be32_add_cpu ( & ipv4_addr , octets [ i ] << ( i * 8 ) ) ; } ret = 0 ; write_lock ( & cluster -> cl_nodes_lock ) ; if ( o2nm_node_ip_tree_lookup ( cluster , ipv4_addr , & p , & parent ) ) ret = - EEXIST ; else if ( test_and_set_bit ( O2NM_NODE_ATTR_ADDRESS , & node -> nd_set_attributes ) ) ret = - EBUSY ; else { rb_link_node ( & node -> nd_ip_node , parent , p ) ; rb_insert_color ( & node -> nd_ip_node , & cluster -> cl_node_ip_tree ) ; } write_unlock ( & cluster -> cl_nodes_lock ) ; if ( ret ) return ret ; memcpy ( & node -> nd_ipv4_address , & ipv4_addr , sizeof ( ipv4_addr ) ) ; return count ; } "," o2nm_cluster * cluster ; int ret ) ; } o2nm_lock_subsystem ( ) ; cluster = to_o2nm_cluster_from_node ( node ) ; if ( ! cluster ) { o2nm_unlock_subsystem ( ) ; return - EINVAL ; } cl_nodes_lock ) ; o2nm_unlock_subsystem ( ) ; ",torvalds@linux/853bc26a7ea39e354b9f8889ae7ad1492ffa28d2,CVE-2017-18216,https://github.com/torvalds/linux/commit/853bc26a7ea39e354b9f8889ae7ad1492ffa28d2,2018-03-05T18:29Z 118,CWE-125,"CWE-125 u_int null_if_print ( netdissect_options * ndo , const struct pcap_pkthdr * h , const u_char * p ) { u_int length = h -> len ; u_int caplen = h -> caplen ; u_int family ; if ( caplen < NULL_HDRLEN ) { ND_PRINT ( ( ndo , ""[|null]"" ) ) ; return ( NULL_HDRLEN ) ; } memcpy ( ( char * ) & family , ( const char * ) p , sizeof ( family ) ) ; if ( ( family & 0xFFFF0000 ) != 0 ) family = SWAPLONG ( family ) ; if ( ndo -> ndo_eflag ) null_hdr_print ( ndo , family , length ) ; length -= NULL_HDRLEN ; caplen -= NULL_HDRLEN ; p += NULL_HDRLEN ; switch ( family ) { case BSD_AFNUM_INET : ip_print ( ndo , p , length ) ; break ; case BSD_AFNUM_INET6_BSD : case BSD_AFNUM_INET6_FREEBSD : case BSD_AFNUM_INET6_DARWIN : ip6_print ( ndo , p , length ) ; break ; case BSD_AFNUM_ISO : isoclns_print ( ndo , p , length , caplen ) ; break ; case BSD_AFNUM_APPLETALK : atalk_print ( ndo , p , length ) ; break ; case BSD_AFNUM_IPX : ipx_print ( ndo , p , length ) ; break ; default : if ( ! ndo -> ndo_eflag ) null_hdr_print ( ndo , family , length + NULL_HDRLEN ) ; if ( ! ndo -> ndo_suppress_default_print ) ND_DEFAULTPRINT ( p , caplen ) ; } return ( NULL_HDRLEN ) ; } "," p , length ) ; break ",the-tcpdump-group@tcpdump/1dcd10aceabbc03bf571ea32b892c522cbe923de,CVE-2017-12897,https://github.com/the-tcpdump-group/tcpdump/commit/1dcd10aceabbc03bf571ea32b892c522cbe923de,2017-09-14T06:29Z 119,CWE-22,"CWE-22 static int cleanup_pathname ( struct archive_write_disk * a ) { char * dest , * src ; char separator = '\\0' ; dest = src = a -> name ; if ( * src == '\\0' ) { archive_set_error ( & a -> archive , ARCHIVE_ERRNO_MISC , ""Invalidemptypathname"" ) ; return ( ARCHIVE_FAILED ) ; } # if defined ( __CYGWIN__ ) cleanup_pathname_win ( a ) ; # endif if ( * src == '/' ) separator = * src ++ ; for ( ; ; ) { if ( src [ 0 ] == '\\0' ) { break ; } else if ( src [ 0 ] == '/' ) { src ++ ; continue ; } else if ( src [ 0 ] == '.' ) { if ( src [ 1 ] == '\\0' ) { break ; } else if ( src [ 1 ] == '/' ) { src += 2 ; continue ; } else if ( src [ 1 ] == '.' ) { if ( src [ 2 ] == '/' || src [ 2 ] == '\\0' ) { if ( a -> flags & ARCHIVE_EXTRACT_SECURE_NODOTDOT ) { archive_set_error ( & a -> archive , ARCHIVE_ERRNO_MISC , ""Pathcontains\'..\'"" ) ; return ( ARCHIVE_FAILED ) ; } } } } if ( separator ) * dest ++ = '/' ; while ( * src != '\\0' && * src != '/' ) { * dest ++ = * src ++ ; } if ( * src == '\\0' ) break ; separator = * src ++ ; } if ( dest == a -> name ) { if ( separator ) * dest ++ = '/' ; else * dest ++ = '.' ; } * dest = '\\0' ; return ( ARCHIVE_OK ) ; } "," == '/' ) { if ( a -> flags & ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS ) { archive_set_error ( & a -> archive , ARCHIVE_ERRNO_MISC , ""Pathisabsolute"" ) ; return ( ARCHIVE_FAILED ) ; } separator = * src ++ ; } for ( ; ",libarchive@libarchive/59357157706d47c365b2227739e17daba3607526,CVE-2015-2304,https://github.com/libarchive/libarchive/commit/59357157706d47c365b2227739e17daba3607526,2015-03-15T19:59Z 120,CWE-522,"CWE-522 TPM_RC tpm_kdfa ( TSS2_SYS_CONTEXT * sapi_context , TPMI_ALG_HASH hashAlg , TPM2B * key , char * label , TPM2B * contextU , TPM2B * contextV , UINT16 bits , TPM2B_MAX_BUFFER * resultKey ) { TPM2B_DIGEST tmpResult ; TPM2B_DIGEST tpm2bLabel , tpm2bBits , tpm2b_i_2 ; UINT8 * tpm2bBitsPtr = & tpm2bBits . t . buffer [ 0 ] ; UINT8 * tpm2b_i_2Ptr = & tpm2b_i_2 . t . buffer [ 0 ] ; TPM2B_DIGEST * bufferList [ 8 ] ; UINT32 bitsSwizzled , i_Swizzled ; TPM_RC rval ; int i , j ; UINT16 bytes = bits / 8 ; resultKey -> t . size = 0 ; tpm2b_i_2 . t . size = 4 ; tpm2bBits . t . size = 4 ; bitsSwizzled = string_bytes_endian_convert_32 ( bits ) ; * ( UINT32 * ) tpm2bBitsPtr = bitsSwizzled ; for ( i = 0 ; label [ i ] != 0 ; i ++ ) ; tpm2bLabel . t . size = i + 1 ; for ( i = 0 ; i < tpm2bLabel . t . size ; i ++ ) { tpm2bLabel . t . buffer [ i ] = label [ i ] ; } resultKey -> t . size = 0 ; i = 1 ; while ( resultKey -> t . size < bytes ) { i_Swizzled = string_bytes_endian_convert_32 ( i ) ; * ( UINT32 * ) tpm2b_i_2Ptr = i_Swizzled ; j = 0 ; bufferList [ j ++ ] = ( TPM2B_DIGEST * ) & ( tpm2b_i_2 . b ) ; bufferList [ j ++ ] = ( TPM2B_DIGEST * ) & ( tpm2bLabel . b ) ; bufferList [ j ++ ] = ( TPM2B_DIGEST * ) contextU ; bufferList [ j ++ ] = ( TPM2B_DIGEST * ) contextV ; bufferList [ j ++ ] = ( TPM2B_DIGEST * ) & ( tpm2bBits . b ) ; bufferList [ j ++ ] = ( TPM2B_DIGEST * ) 0 ; rval = tpm_hmac ( sapi_context , hashAlg , key , ( TPM2B * * ) & ( bufferList [ 0 ] ) , & tmpResult ) ; if ( rval != TPM_RC_SUCCESS ) { return ( rval ) ; } bool res = string_bytes_concat_buffer ( resultKey , & ( tmpResult . b ) ) ; if ( ! res ) { return TSS2_SYS_RC_BAD_VALUE ; } } resultKey -> t . size = bytes ; return TPM_RC_SUCCESS ; } "," TPM_RC tpm_kdfa ( TPMI_ALG_HASH hashAlg , ) { TPM2B_DIGEST tpm2bLabel , tpm2bBits ; TPM_RC rval = TPM_RC_SUCCESS = 1 ; const EVP_MD * md = tpm_algorithm_to_openssl_digest ( hashAlg ) ; if ( ! md ) { LOG_ERR ( ""Algorithmnotsupportedforhmac:%x"" , hashAlg ) ; return TPM_RC_HASH ; } HMAC_CTX ctx ; HMAC_CTX_init ( & ctx ) ; int rc = HMAC_Init_ex ( & ctx , key -> buffer , key -> size , md , NULL ) ; if ( ! rc ) { LOG_ERR ( ""HMACInitfailed:%s"" , ERR_error_string ( rc , NULL ) ) ; return TPM_RC_MEMORY ; } bytes ) { TPM2B_DIGEST tmpResult ; bufferList [ j ] = ( TPM2B_DIGEST * ) 0 ; int c ; for ( c = 0 ; c < j ; c ++ ) { TPM2B_DIGEST * digest = bufferList [ c ] ; int rc = HMAC_Update ( & ctx , digest -> b . buffer , digest -> b . size ) ; if ( ! rc ) { LOG_ERR ( ""HMACUpdatefailed:%s"" , ERR_error_string ( rc , NULL ) ) ; rval = ; rval = TPM_RC_MEMORY ; goto err ; } } unsigned size = sizeof ( tmpResult . t . buffer ) ; int rc = HMAC_Final ( & ctx , tmpResult . t . buffer , & size ) ; if ; if ( ! rc ) { LOG_ERR ( ""HMACFinalfailed:%s"" , ERR_error_string ( rc , NULL ) ) ; rval = TPM_RC_MEMORY ; goto err ; } tmpResult . t . size = size ; bool res = res ) { rval = TSS2_SYS_RC_BAD_VALUE ; goto err ; } } resultKey -> t . size = bytes ; err : HMAC_CTX_cleanup ( & ctx ) ; return rval ; } ",01org@tpm2.0-tools/c5d72beaab1cbbbe68271f4bc4b6670d69985157,CVE-2017-7524,https://github.com/01org/tpm2.0-tools/commit/c5d72beaab1cbbbe68271f4bc4b6670d69985157,2017-06-27T14:29Z 121,CWE-190,"CWE-190 static jas_image_cmpt_t * jas_image_cmpt_create ( int_fast32_t tlx , int_fast32_t tly , int_fast32_t hstep , int_fast32_t vstep , int_fast32_t width , int_fast32_t height , uint_fast16_t depth , bool sgnd , uint_fast32_t inmem ) { jas_image_cmpt_t * cmpt ; size_t size ; cmpt = 0 ; if ( width < 0 || height < 0 || hstep <= 0 || vstep <= 0 ) { goto error ; } if ( ! jas_safe_intfast32_add ( tlx , width , 0 ) || ! jas_safe_intfast32_add ( tly , height , 0 ) ) { goto error ; } if ( ! ( cmpt = jas_malloc ( sizeof ( jas_image_cmpt_t ) ) ) ) { goto error ; } cmpt -> type_ = JAS_IMAGE_CT_UNKNOWN ; cmpt -> tlx_ = tlx ; cmpt -> tly_ = tly ; cmpt -> hstep_ = hstep ; cmpt -> vstep_ = vstep ; cmpt -> width_ = width ; cmpt -> height_ = height ; cmpt -> prec_ = depth ; cmpt -> sgnd_ = sgnd ; cmpt -> stream_ = 0 ; cmpt -> cps_ = ( depth + 7 ) / 8 ; if ( ! jas_safe_size_mul ( cmpt -> width_ , cmpt -> height_ , & size ) || ! jas_safe_size_mul ( size , cmpt -> cps_ , & size ) ) { goto error ; } cmpt -> stream_ = ( inmem ) ? jas_stream_memopen2 ( 0 , size ) : jas_stream_tmpfile ( ) ; if ( ! cmpt -> stream_ ) { goto error ; } if ( size > 0 ) { if ( size - 1 > LONG_MAX ) { goto error ; } if ( jas_stream_seek ( cmpt -> stream_ , size - 1 , SEEK_SET ) < 0 || jas_stream_putc ( cmpt -> stream_ , 0 ) == EOF || jas_stream_seek ( cmpt -> stream_ , 0 , SEEK_SET ) < 0 ) { goto error ; } } return cmpt ; error : if ( cmpt ) { jas_image_cmpt_destroy ( cmpt ) ; } return 0 ; } "," size_t size ; JAS_DBGLOG ( 100 , ( ""jas_image_cmpt_create(%ld,%ld,%ld,%ld,%ld,%ld,%d,%d,%d)\\n"" , JAS_CAST ( long , tlx ) , JAS_CAST ( long , tly ) , JAS_CAST ( long , hstep ) , JAS_CAST ( long , vstep ) , JAS_CAST ( long , width ) , JAS_CAST ( long , height ) , JAS_CAST ( int , depth ) , sgnd , inmem ) ) ; tly , height , 0 ) ) { goto error ; } if ( ! jas_safe_intfast32_mul3 ( width , height , depth if ( ! jas_safe_size_mul3 ( cmpt -> cmpt -> height_ , cmpt -> ",mdadams@jasper/d42b2388f7f8e0332c846675133acea151fc557a,CVE-2016-9557,https://github.com/mdadams/jasper/commit/d42b2388f7f8e0332c846675133acea151fc557a,2017-03-23T18:59Z 122,CWE-369,"CWE-369 tdata_t _TIFFmalloc ( tsize_t s ) { return ( malloc ( ( size_t ) s ) ) ; } "," s ) { if ( s == 0 ) return ( ( void * ) NULL ) ; ",vadz@libtiff/3c5eb8b1be544e41d2c336191bc4936300ad7543,CVE-2014-8130,https://github.com/vadz/libtiff/commit/3c5eb8b1be544e41d2c336191bc4936300ad7543,2018-03-12T02:29Z 123,CWE-264,"CWE-264 static ssize_t qib_write ( struct file * fp , const char __user * data , size_t count , loff_t * off ) { const struct qib_cmd __user * ucmd ; struct qib_ctxtdata * rcd ; const void __user * src ; size_t consumed , copy = 0 ; struct qib_cmd cmd ; ssize_t ret = 0 ; void * dest ; if ( count < sizeof ( cmd . type ) ) { ret = - EINVAL ; goto bail ; } ucmd = ( const struct qib_cmd __user * ) data ; if ( copy_from_user ( & cmd . type , & ucmd -> type , sizeof ( cmd . type ) ) ) { ret = - EFAULT ; goto bail ; } consumed = sizeof ( cmd . type ) ; switch ( cmd . type ) { case QIB_CMD_ASSIGN_CTXT : case QIB_CMD_USER_INIT : copy = sizeof ( cmd . cmd . user_info ) ; dest = & cmd . cmd . user_info ; src = & ucmd -> cmd . user_info ; break ; case QIB_CMD_RECV_CTRL : copy = sizeof ( cmd . cmd . recv_ctrl ) ; dest = & cmd . cmd . recv_ctrl ; src = & ucmd -> cmd . recv_ctrl ; break ; case QIB_CMD_CTXT_INFO : copy = sizeof ( cmd . cmd . ctxt_info ) ; dest = & cmd . cmd . ctxt_info ; src = & ucmd -> cmd . ctxt_info ; break ; case QIB_CMD_TID_UPDATE : case QIB_CMD_TID_FREE : copy = sizeof ( cmd . cmd . tid_info ) ; dest = & cmd . cmd . tid_info ; src = & ucmd -> cmd . tid_info ; break ; case QIB_CMD_SET_PART_KEY : copy = sizeof ( cmd . cmd . part_key ) ; dest = & cmd . cmd . part_key ; src = & ucmd -> cmd . part_key ; break ; case QIB_CMD_DISARM_BUFS : case QIB_CMD_PIOAVAILUPD : copy = 0 ; src = NULL ; dest = NULL ; break ; case QIB_CMD_POLL_TYPE : copy = sizeof ( cmd . cmd . poll_type ) ; dest = & cmd . cmd . poll_type ; src = & ucmd -> cmd . poll_type ; break ; case QIB_CMD_ARMLAUNCH_CTRL : copy = sizeof ( cmd . cmd . armlaunch_ctrl ) ; dest = & cmd . cmd . armlaunch_ctrl ; src = & ucmd -> cmd . armlaunch_ctrl ; break ; case QIB_CMD_SDMA_INFLIGHT : copy = sizeof ( cmd . cmd . sdma_inflight ) ; dest = & cmd . cmd . sdma_inflight ; src = & ucmd -> cmd . sdma_inflight ; break ; case QIB_CMD_SDMA_COMPLETE : copy = sizeof ( cmd . cmd . sdma_complete ) ; dest = & cmd . cmd . sdma_complete ; src = & ucmd -> cmd . sdma_complete ; break ; case QIB_CMD_ACK_EVENT : copy = sizeof ( cmd . cmd . event_mask ) ; dest = & cmd . cmd . event_mask ; src = & ucmd -> cmd . event_mask ; break ; default : ret = - EINVAL ; goto bail ; } if ( copy ) { if ( ( count - consumed ) < copy ) { ret = - EINVAL ; goto bail ; } if ( copy_from_user ( dest , src , copy ) ) { ret = - EFAULT ; goto bail ; } consumed += copy ; } rcd = ctxt_fp ( fp ) ; if ( ! rcd && cmd . type != QIB_CMD_ASSIGN_CTXT ) { ret = - EINVAL ; goto bail ; } switch ( cmd . type ) { case QIB_CMD_ASSIGN_CTXT : ret = qib_assign_ctxt ( fp , & cmd . cmd . user_info ) ; if ( ret ) goto bail ; break ; case QIB_CMD_USER_INIT : ret = qib_do_user_init ( fp , & cmd . cmd . user_info ) ; if ( ret ) goto bail ; ret = qib_get_base_info ( fp , ( void __user * ) ( unsigned long ) cmd . cmd . user_info . spu_base_info , cmd . cmd . user_info . spu_base_info_size ) ; break ; case QIB_CMD_RECV_CTRL : ret = qib_manage_rcvq ( rcd , subctxt_fp ( fp ) , cmd . cmd . recv_ctrl ) ; break ; case QIB_CMD_CTXT_INFO : ret = qib_ctxt_info ( fp , ( struct qib_ctxt_info __user * ) ( unsigned long ) cmd . cmd . ctxt_info ) ; break ; case QIB_CMD_TID_UPDATE : ret = qib_tid_update ( rcd , fp , & cmd . cmd . tid_info ) ; break ; case QIB_CMD_TID_FREE : ret = qib_tid_free ( rcd , subctxt_fp ( fp ) , & cmd . cmd . tid_info ) ; break ; case QIB_CMD_SET_PART_KEY : ret = qib_set_part_key ( rcd , cmd . cmd . part_key ) ; break ; case QIB_CMD_DISARM_BUFS : ( void ) qib_disarm_piobufs_ifneeded ( rcd ) ; ret = disarm_req_delay ( rcd ) ; break ; case QIB_CMD_PIOAVAILUPD : qib_force_pio_avail_update ( rcd -> dd ) ; break ; case QIB_CMD_POLL_TYPE : rcd -> poll_type = cmd . cmd . poll_type ; break ; case QIB_CMD_ARMLAUNCH_CTRL : rcd -> dd -> f_set_armlaunch ( rcd -> dd , cmd . cmd . armlaunch_ctrl ) ; break ; case QIB_CMD_SDMA_INFLIGHT : ret = qib_sdma_get_inflight ( user_sdma_queue_fp ( fp ) , ( u32 __user * ) ( unsigned long ) cmd . cmd . sdma_inflight ) ; break ; case QIB_CMD_SDMA_COMPLETE : ret = qib_sdma_get_complete ( rcd -> ppd , user_sdma_queue_fp ( fp ) , ( u32 __user * ) ( unsigned long ) cmd . cmd . sdma_complete ) ; break ; case QIB_CMD_ACK_EVENT : ret = qib_user_event_ack ( rcd , subctxt_fp ( fp ) , cmd . cmd . event_mask ) ; break ; } if ( ret >= 0 ) ret = consumed ; bail : return ret ; } "," ; if ( WARN_ON_ONCE ( ! ib_safe_file_access ( fp ) ) ) return - EACCES ; if ( ",torvalds@linux/e6bd18f57aad1a2d1ef40e646d03ed0f2515c9e3,CVE-2016-4565,https://github.com/torvalds/linux/commit/e6bd18f57aad1a2d1ef40e646d03ed0f2515c9e3,2016-05-23T10:59Z 124,CWE-200,"CWE-200 static Image * ReadMATImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { Image * image , * image2 = NULL , * rotated_image ; register Quantum * q ; unsigned int status ; MATHeader MATLAB_HDR ; size_t size ; size_t CellType ; QuantumInfo * quantum_info ; ImageInfo * clone_info ; int i ; ssize_t ldblk ; unsigned char * BImgBuff = NULL ; double MinVal , MaxVal ; unsigned z , z2 ; unsigned Frames ; int logging ; int sample_size ; MagickOffsetType filepos = 0x80 ; BlobInfo * blob ; size_t one ; unsigned int ( * ReadBlobXXXLong ) ( Image * image ) ; unsigned short ( * ReadBlobXXXShort ) ( Image * image ) ; void ( * ReadBlobDoublesXXX ) ( Image * image , size_t len , double * data ) ; void ( * ReadBlobFloatsXXX ) ( Image * image , size_t len , float * data ) ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; logging = LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""enter"" ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } clone_info = CloneImageInfo ( image_info ) ; if ( ReadBlob ( image , 124 , ( unsigned char * ) & MATLAB_HDR . identific ) != 124 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( strncmp ( MATLAB_HDR . identific , ""MATLAB"" , 6 ) != 0 ) { image2 = ReadMATImageV4 ( image_info , image , exception ) ; if ( image2 == NULL ) goto MATLAB_KO ; image = image2 ; goto END_OF_READING ; } MATLAB_HDR . Version = ReadBlobLSBShort ( image ) ; if ( ReadBlob ( image , 2 , ( unsigned char * ) & MATLAB_HDR . EndianIndicator ) != 2 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""Endian%c%c"" , MATLAB_HDR . EndianIndicator [ 0 ] , MATLAB_HDR . EndianIndicator [ 1 ] ) ; if ( ! strncmp ( MATLAB_HDR . EndianIndicator , ""IM"" , 2 ) ) { ReadBlobXXXLong = ReadBlobLSBLong ; ReadBlobXXXShort = ReadBlobLSBShort ; ReadBlobDoublesXXX = ReadBlobDoublesLSB ; ReadBlobFloatsXXX = ReadBlobFloatsLSB ; image -> endian = LSBEndian ; } else if ( ! strncmp ( MATLAB_HDR . EndianIndicator , ""MI"" , 2 ) ) { ReadBlobXXXLong = ReadBlobMSBLong ; ReadBlobXXXShort = ReadBlobMSBShort ; ReadBlobDoublesXXX = ReadBlobDoublesMSB ; ReadBlobFloatsXXX = ReadBlobFloatsMSB ; image -> endian = MSBEndian ; } else goto MATLAB_KO ; if ( strncmp ( MATLAB_HDR . identific , ""MATLAB"" , 6 ) ) MATLAB_KO : ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; filepos = TellBlob ( image ) ; while ( ! EOFBlob ( image ) ) { Frames = 1 ; ( void ) SeekBlob ( image , filepos , SEEK_SET ) ; MATLAB_HDR . DataType = ReadBlobXXXLong ( image ) ; if ( EOFBlob ( image ) ) break ; MATLAB_HDR . ObjectSize = ReadBlobXXXLong ( image ) ; if ( EOFBlob ( image ) ) break ; filepos += MATLAB_HDR . ObjectSize + 4 + 4 ; image2 = image ; # if defined ( MAGICKCORE_ZLIB_DELEGATE ) if ( MATLAB_HDR . DataType == miCOMPRESSED ) { image2 = DecompressBlock ( image , MATLAB_HDR . ObjectSize , clone_info , exception ) ; if ( image2 == NULL ) continue ; MATLAB_HDR . DataType = ReadBlobXXXLong ( image2 ) ; } # endif if ( MATLAB_HDR . DataType != miMATRIX ) continue ; MATLAB_HDR . unknown1 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . unknown2 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . unknown5 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . StructureClass = MATLAB_HDR . unknown5 & 0xFF ; MATLAB_HDR . StructureFlag = ( MATLAB_HDR . unknown5 >> 8 ) & 0xFF ; MATLAB_HDR . unknown3 = ReadBlobXXXLong ( image2 ) ; if ( image != image2 ) MATLAB_HDR . unknown4 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . unknown4 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . DimFlag = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . SizeX = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . SizeY = ReadBlobXXXLong ( image2 ) ; switch ( MATLAB_HDR . DimFlag ) { case 8 : z2 = z = 1 ; break ; case 12 : z2 = z = ReadBlobXXXLong ( image2 ) ; ( void ) ReadBlobXXXLong ( image2 ) ; if ( z != 3 ) ThrowReaderException ( CoderError , ""MultidimensionalMatricesAreNotSupported"" ) ; break ; case 16 : z2 = z = ReadBlobXXXLong ( image2 ) ; if ( z != 3 && z != 1 ) ThrowReaderException ( CoderError , ""MultidimensionalMatricesAreNotSupported"" ) ; Frames = ReadBlobXXXLong ( image2 ) ; if ( Frames == 0 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; break ; default : ThrowReaderException ( CoderError , ""MultidimensionalMatricesAreNotSupported"" ) ; } MATLAB_HDR . Flag1 = ReadBlobXXXShort ( image2 ) ; MATLAB_HDR . NameFlag = ReadBlobXXXShort ( image2 ) ; if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATLAB_HDR.StructureClass%d"" , MATLAB_HDR . StructureClass ) ; if ( MATLAB_HDR . StructureClass != mxCHAR_CLASS && MATLAB_HDR . StructureClass != mxSINGLE_CLASS && MATLAB_HDR . StructureClass != mxDOUBLE_CLASS && MATLAB_HDR . StructureClass != mxINT8_CLASS && MATLAB_HDR . StructureClass != mxUINT8_CLASS && MATLAB_HDR . StructureClass != mxINT16_CLASS && MATLAB_HDR . StructureClass != mxUINT16_CLASS && MATLAB_HDR . StructureClass != mxINT32_CLASS && MATLAB_HDR . StructureClass != mxUINT32_CLASS && MATLAB_HDR . StructureClass != mxINT64_CLASS && MATLAB_HDR . StructureClass != mxUINT64_CLASS ) ThrowReaderException ( CoderError , ""UnsupportedCellTypeInTheMatrix"" ) ; switch ( MATLAB_HDR . NameFlag ) { case 0 : size = ReadBlobXXXLong ( image2 ) ; size = 4 * ( ssize_t ) ( ( size + 3 + 1 ) / 4 ) ; ( void ) SeekBlob ( image2 , size , SEEK_CUR ) ; break ; case 1 : case 2 : case 3 : case 4 : ( void ) ReadBlob ( image2 , 4 , ( unsigned char * ) & size ) ; break ; default : goto MATLAB_KO ; } CellType = ReadBlobXXXLong ( image2 ) ; if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATLAB_HDR.CellType:%.20g"" , ( double ) CellType ) ; ( void ) ReadBlob ( image2 , 4 , ( unsigned char * ) & size ) ; NEXT_FRAME : switch ( CellType ) { case miINT8 : case miUINT8 : sample_size = 8 ; if ( MATLAB_HDR . StructureFlag & FLAG_LOGICAL ) image -> depth = 1 ; else image -> depth = 8 ; ldblk = ( ssize_t ) MATLAB_HDR . SizeX ; break ; case miINT16 : case miUINT16 : sample_size = 16 ; image -> depth = 16 ; ldblk = ( ssize_t ) ( 2 * MATLAB_HDR . SizeX ) ; break ; case miINT32 : case miUINT32 : sample_size = 32 ; image -> depth = 32 ; ldblk = ( ssize_t ) ( 4 * MATLAB_HDR . SizeX ) ; break ; case miINT64 : case miUINT64 : sample_size = 64 ; image -> depth = 64 ; ldblk = ( ssize_t ) ( 8 * MATLAB_HDR . SizeX ) ; break ; case miSINGLE : sample_size = 32 ; image -> depth = 32 ; ( void ) SetImageOption ( clone_info , ""quantum:format"" , ""floating-point"" ) ; if ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) { } ldblk = ( ssize_t ) ( 4 * MATLAB_HDR . SizeX ) ; break ; case miDOUBLE : sample_size = 64 ; image -> depth = 64 ; ( void ) SetImageOption ( clone_info , ""quantum:format"" , ""floating-point"" ) ; DisableMSCWarning ( 4127 ) if ( sizeof ( double ) != 8 ) RestoreMSCWarning ThrowReaderException ( CoderError , ""IncompatibleSizeOfDouble"" ) ; if ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) { } ldblk = ( ssize_t ) ( 8 * MATLAB_HDR . SizeX ) ; break ; default : ThrowReaderException ( CoderError , ""UnsupportedCellTypeInTheMatrix"" ) ; } ( void ) sample_size ; image -> columns = MATLAB_HDR . SizeX ; image -> rows = MATLAB_HDR . SizeY ; quantum_info = AcquireQuantumInfo ( clone_info , image ) ; if ( quantum_info == ( QuantumInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; one = 1 ; image -> colors = one << image -> depth ; if ( image -> columns == 0 || image -> rows == 0 ) goto MATLAB_KO ; if ( ( MATLAB_HDR . DimFlag == 8 ) && ( ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) == 0 ) ) { image -> type = GrayscaleType ; SetImageColorspace ( image , GRAYColorspace , exception ) ; } if ( image_info -> ping ) { size_t temp = image -> columns ; image -> columns = image -> rows ; image -> rows = temp ; goto done_reading ; } status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; BImgBuff = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) ( ldblk ) , sizeof ( double ) ) ; if ( BImgBuff == NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; MinVal = 0 ; MaxVal = 0 ; if ( CellType == miDOUBLE || CellType == miSINGLE ) { CalcMinMax ( image2 , image_info -> endian , MATLAB_HDR . SizeX , MATLAB_HDR . SizeY , CellType , ldblk , BImgBuff , & quantum_info -> minimum , & quantum_info -> maximum ) ; } if ( z == 1 ) z = 0 ; do { for ( i = 0 ; i < ( ssize_t ) MATLAB_HDR . SizeY ; i ++ ) { q = GetAuthenticPixels ( image , 0 , MATLAB_HDR . SizeY - i - 1 , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) { if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATsetimagepixelsreturnsunexpectedNULLonarow%u."" , ( unsigned ) ( MATLAB_HDR . SizeY - i - 1 ) ) ; goto done_reading ; } if ( ReadBlob ( image2 , ldblk , ( unsigned char * ) BImgBuff ) != ( ssize_t ) ldblk ) { if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATcannotreadscanrow%ufromafile."" , ( unsigned ) ( MATLAB_HDR . SizeY - i - 1 ) ) ; goto ExitLoop ; } if ( ( CellType == miINT8 || CellType == miUINT8 ) && ( MATLAB_HDR . StructureFlag & FLAG_LOGICAL ) ) { FixLogical ( ( unsigned char * ) BImgBuff , ldblk ) ; if ( ImportQuantumPixels ( image , ( CacheView * ) NULL , quantum_info , z2qtype [ z ] , BImgBuff , exception ) <= 0 ) { ImportQuantumPixelsFailed : if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATfailedtoImportQuantumPixelsforarow%u"" , ( unsigned ) ( MATLAB_HDR . SizeY - i - 1 ) ) ; break ; } } else { if ( ImportQuantumPixels ( image , ( CacheView * ) NULL , quantum_info , z2qtype [ z ] , BImgBuff , exception ) <= 0 ) goto ImportQuantumPixelsFailed ; if ( z <= 1 && ( CellType == miINT8 || CellType == miINT16 || CellType == miINT32 || CellType == miINT64 ) ) FixSignedValues ( image , q , MATLAB_HDR . SizeX ) ; } if ( ! SyncAuthenticPixels ( image , exception ) ) { if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATfailedtosyncimagepixelsforarow%u"" , ( unsigned ) ( MATLAB_HDR . SizeY - i - 1 ) ) ; goto ExitLoop ; } } } while ( z -- >= 2 ) ; quantum_info = DestroyQuantumInfo ( quantum_info ) ; ExitLoop : if ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) { CellType = ReadBlobXXXLong ( image2 ) ; i = ReadBlobXXXLong ( image2 ) ; if ( CellType == miDOUBLE || CellType == miSINGLE ) { CalcMinMax ( image2 , image_info -> endian , MATLAB_HDR . SizeX , MATLAB_HDR . SizeY , CellType , ldblk , BImgBuff , & MinVal , & MaxVal ) ; } if ( CellType == miDOUBLE ) for ( i = 0 ; i < ( ssize_t ) MATLAB_HDR . SizeY ; i ++ ) { ReadBlobDoublesXXX ( image2 , ldblk , ( double * ) BImgBuff ) ; InsertComplexDoubleRow ( image , ( double * ) BImgBuff , i , MinVal , MaxVal , exception ) ; } if ( CellType == miSINGLE ) for ( i = 0 ; i < ( ssize_t ) MATLAB_HDR . SizeY ; i ++ ) { ReadBlobFloatsXXX ( image2 , ldblk , ( float * ) BImgBuff ) ; InsertComplexFloatRow ( image , ( float * ) BImgBuff , i , MinVal , MaxVal , exception ) ; } } if ( ( MATLAB_HDR . DimFlag == 8 ) && ( ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) == 0 ) ) image -> type = GrayscaleType ; if ( image -> depth == 1 ) image -> type = BilevelType ; if ( image2 == image ) image2 = NULL ; rotated_image = RotateImage ( image , 90.0 , exception ) ; if ( rotated_image != ( Image * ) NULL ) { rotated_image -> page . x = 0 ; rotated_image -> page . y = 0 ; blob = rotated_image -> blob ; rotated_image -> blob = image -> blob ; rotated_image -> colors = image -> colors ; image -> blob = blob ; AppendImageToList ( & image , rotated_image ) ; DeleteImageFromList ( & image ) ; } done_reading : if ( image2 != NULL ) if ( image2 != image ) { DeleteImageFromList ( & image2 ) ; if ( clone_info ) { if ( clone_info -> file ) { fclose ( clone_info -> file ) ; clone_info -> file = NULL ; ( void ) remove_utf8 ( clone_info -> filename ) ; } } } AcquireNextImage ( image_info , image , exception ) ; if ( image -> next == ( Image * ) NULL ) break ; image = SyncNextImageInList ( image ) ; image -> columns = image -> rows = 0 ; image -> colors = 0 ; RelinquishMagickMemory ( BImgBuff ) ; BImgBuff = NULL ; if ( -- Frames > 0 ) { z = z2 ; if ( image2 == NULL ) image2 = image ; goto NEXT_FRAME ; } if ( ( image2 != NULL ) && ( image2 != image ) ) { DeleteImageFromList ( & image2 ) ; if ( clone_info ) { if ( clone_info -> file ) { fclose ( clone_info -> file ) ; clone_info -> file = NULL ; ( void ) remove_utf8 ( clone_info -> filename ) ; } } } } RelinquishMagickMemory ( BImgBuff ) ; END_OF_READING : clone_info = DestroyImageInfo ( clone_info ) ; CloseBlob ( image ) ; { Image * p ; ssize_t scene = 0 ; p = image ; image = NULL ; while ( p != ( Image * ) NULL ) { Image * tmp = p ; if ( ( p -> rows == 0 ) || ( p -> columns == 0 ) ) { p = p -> previous ; DeleteImageFromList ( & tmp ) ; } else { image = p ; p = p -> previous ; } } for ( p = image ; p != ( Image * ) NULL ; p = p -> next ) p -> scene = scene ++ ; } if ( clone_info != NULL ) { if ( clone_info -> file ) { fclose ( clone_info -> file ) ; clone_info -> file = NULL ; ( void ) remove_utf8 ( clone_info -> filename ) ; } DestroyImageInfo ( clone_info ) ; clone_info = NULL ; } if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""return"" ) ; if ( image == NULL ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; return ( image ) ; } "," ""MemoryAllocationFailed"" ) ; ( void ) ResetMagickMemory ( BImgBuff , 0 , ldblk * sizeof ( double ) ) ; ",ImageMagick@ImageMagick/51b0ae01709adc1e4a9245e158ef17b85a110960,CVE-2017-13143,https://github.com/ImageMagick/ImageMagick/commit/51b0ae01709adc1e4a9245e158ef17b85a110960,2017-08-23T06:29Z 125,CWE-416,"CWE-416 struct net * get_net_ns_by_id ( struct net * net , int id ) { struct net * peer ; if ( id < 0 ) return NULL ; rcu_read_lock ( ) ; spin_lock_bh ( & net -> nsid_lock ) ; peer = idr_find ( & net -> netns_ids , id ) ; if ( peer ) get_net ( peer ) ; spin_unlock_bh ( & net -> nsid_lock ) ; rcu_read_unlock ( ) ; return peer ; } "," ( peer ) peer = maybe_get_net ( peer ) ",torvalds@linux/21b5944350052d2583e82dd59b19a9ba94a007f0,CVE-2017-15129,https://github.com/torvalds/linux/commit/21b5944350052d2583e82dd59b19a9ba94a007f0,2018-01-09T19:29Z 126,CWE-000,"CWE-000 void * getHTTPResponse ( int s , int * size ) { char buf [ 2048 ] ; int n ; int endofheaders = 0 ; int chunked = 0 ; int content_length = - 1 ; unsigned int chunksize = 0 ; unsigned int bytestocopy = 0 ; char * header_buf ; unsigned int header_buf_len = 2048 ; unsigned int header_buf_used = 0 ; char * content_buf ; unsigned int content_buf_len = 2048 ; unsigned int content_buf_used = 0 ; char chunksize_buf [ 32 ] ; unsigned int chunksize_buf_index ; header_buf = malloc ( header_buf_len ) ; content_buf = malloc ( content_buf_len ) ; chunksize_buf [ 0 ] = '\\0' ; chunksize_buf_index = 0 ; while ( ( n = receivedata ( s , buf , 2048 , 5000 , NULL ) ) > 0 ) { if ( endofheaders == 0 ) { int i ; int linestart = 0 ; int colon = 0 ; int valuestart = 0 ; if ( header_buf_used + n > header_buf_len ) { header_buf = realloc ( header_buf , header_buf_used + n ) ; header_buf_len = header_buf_used + n ; } memcpy ( header_buf + header_buf_used , buf , n ) ; header_buf_used += n ; i = 0 ; while ( i < ( ( int ) header_buf_used - 1 ) && ( endofheaders == 0 ) ) { if ( header_buf [ i ] == '\\r' ) { i ++ ; if ( header_buf [ i ] == '\\n' ) { i ++ ; if ( i < ( int ) header_buf_used && header_buf [ i ] == '\\r' ) { i ++ ; if ( i < ( int ) header_buf_used && header_buf [ i ] == '\\n' ) { endofheaders = i + 1 ; } } } } else if ( header_buf [ i ] == '\\n' ) { i ++ ; if ( header_buf [ i ] == '\\n' ) { endofheaders = i + 1 ; } } i ++ ; } if ( endofheaders == 0 ) continue ; for ( i = 0 ; i < endofheaders - 1 ; i ++ ) { if ( colon <= linestart && header_buf [ i ] == ':' ) { colon = i ; while ( i < ( endofheaders - 1 ) && ( header_buf [ i + 1 ] == '' || header_buf [ i + 1 ] == '\\t' ) ) i ++ ; valuestart = i + 1 ; } else if ( header_buf [ i ] == '\\r' || header_buf [ i ] == '\\n' ) { if ( colon > linestart && valuestart > colon ) { # ifdef DEBUG printf ( ""header=\'%.*s\',value=\'%.*s\'\\n"" , colon - linestart , header_buf + linestart , i - valuestart , header_buf + valuestart ) ; # endif if ( 0 == strncasecmp ( header_buf + linestart , ""content-length"" , colon - linestart ) ) { content_length = atoi ( header_buf + valuestart ) ; # ifdef DEBUG printf ( ""Content-Length:%d\\n"" , content_length ) ; # endif } else if ( 0 == strncasecmp ( header_buf + linestart , ""transfer-encoding"" , colon - linestart ) && 0 == strncasecmp ( header_buf + valuestart , ""chunked"" , 7 ) ) { # ifdef DEBUG printf ( ""chunkedtransfer-encoding!\\n"" ) ; # endif chunked = 1 ; } } while ( header_buf [ i ] == '\\r' || header_buf [ i ] == '\\n' ) i ++ ; linestart = i ; colon = linestart ; valuestart = 0 ; } } n = header_buf_used - endofheaders ; memcpy ( buf , header_buf + endofheaders , n ) ; } if ( endofheaders ) { if ( chunked ) { int i = 0 ; while ( i < n ) { if ( chunksize == 0 ) { if ( chunksize_buf_index == 0 ) { if ( i < n && buf [ i ] == '\\r' ) i ++ ; if ( i < n && buf [ i ] == '\\n' ) i ++ ; } while ( i < n && isxdigit ( buf [ i ] ) && chunksize_buf_index < ( sizeof ( chunksize_buf ) - 1 ) ) { chunksize_buf [ chunksize_buf_index ++ ] = buf [ i ] ; chunksize_buf [ chunksize_buf_index ] = '\\0' ; i ++ ; } while ( i < n && buf [ i ] != '\\r' && buf [ i ] != '\\n' ) i ++ ; if ( i < n && buf [ i ] == '\\r' ) i ++ ; if ( i < n && buf [ i ] == '\\n' ) { unsigned int j ; for ( j = 0 ; j < chunksize_buf_index ; j ++ ) { if ( chunksize_buf [ j ] >= '0' && chunksize_buf [ j ] <= '9' ) chunksize = ( chunksize << 4 ) + ( chunksize_buf [ j ] - '0' ) ; else chunksize = ( chunksize << 4 ) + ( ( chunksize_buf [ j ] | 32 ) - 'a' + 10 ) ; } chunksize_buf [ 0 ] = '\\0' ; chunksize_buf_index = 0 ; i ++ ; } else { continue ; } # ifdef DEBUG printf ( ""chunksize=%u(%x)\\n"" , chunksize , chunksize ) ; # endif if ( chunksize == 0 ) { # ifdef DEBUG printf ( ""endofHTTPcontent-%d%d\\n"" , i , n ) ; # endif goto end_of_stream ; } } bytestocopy = ( ( int ) chunksize < ( n - i ) ) ? chunksize : ( unsigned int ) ( n - i ) ; if ( ( content_buf_used + bytestocopy ) > content_buf_len ) { if ( content_length >= ( int ) ( content_buf_used + bytestocopy ) ) { content_buf_len = content_length ; } else { content_buf_len = content_buf_used + bytestocopy ; } content_buf = ( char * ) realloc ( ( void * ) content_buf , content_buf_len ) ; } memcpy ( content_buf + content_buf_used , buf + i , bytestocopy ) ; content_buf_used += bytestocopy ; i += bytestocopy ; chunksize -= bytestocopy ; } } else { if ( content_length > 0 && ( int ) ( content_buf_used + n ) > content_length ) { n = content_length - content_buf_used ; } if ( content_buf_used + n > content_buf_len ) { if ( content_length >= ( int ) ( content_buf_used + n ) ) { content_buf_len = content_length ; } else { content_buf_len = content_buf_used + n ; } content_buf = ( char * ) realloc ( ( void * ) content_buf , content_buf_len ) ; } memcpy ( content_buf + content_buf_used , buf , n ) ; content_buf_used += n ; } } if ( content_length > 0 && ( int ) content_buf_used >= content_length ) { # ifdef DEBUG printf ( ""EndofHTTPcontent\\n"" ) ; # endif break ; } } end_of_stream : free ( header_buf ) ; header_buf = NULL ; * size = content_buf_used ; if ( content_buf_used == 0 ) { free ( content_buf ) ; content_buf = NULL ; } return content_buf ; } "," } while ( ( i < ( int ) header_buf_used ) && ( ] == '\\n' ) ",miniupnp@miniupnp/3a87aa2f10bd7f1408e1849bdb59c41dd63a9fe9,CVE-2014-3985,https://github.com/miniupnp/miniupnp/commit/3a87aa2f10bd7f1408e1849bdb59c41dd63a9fe9,2014-09-11T18:55Z 127,CWE-617,"CWE-617 static int _lldp_send ( struct lldpd * global , struct lldpd_hardware * hardware , u_int8_t c_id_subtype , char * c_id , int c_id_len , u_int8_t p_id_subtype , char * p_id , int p_id_len , int shutdown ) { struct lldpd_port * port ; struct lldpd_chassis * chassis ; struct lldpd_frame * frame ; int length ; u_int8_t * packet , * pos , * tlv ; struct lldpd_mgmt * mgmt ; int proto ; u_int8_t mcastaddr [ ] = LLDP_MULTICAST_ADDR ; # ifdef ENABLE_DOT1 const u_int8_t dot1 [ ] = LLDP_TLV_ORG_DOT1 ; struct lldpd_vlan * vlan ; struct lldpd_ppvid * ppvid ; struct lldpd_pi * pi ; # endif # ifdef ENABLE_DOT3 const u_int8_t dot3 [ ] = LLDP_TLV_ORG_DOT3 ; # endif # ifdef ENABLE_LLDPMED int i ; const u_int8_t med [ ] = LLDP_TLV_ORG_MED ; # endif # ifdef ENABLE_CUSTOM struct lldpd_custom * custom ; # endif port = & hardware -> h_lport ; chassis = port -> p_chassis ; length = hardware -> h_mtu ; if ( ( packet = ( u_int8_t * ) calloc ( 1 , length ) ) == NULL ) return ENOMEM ; pos = packet ; if ( ! ( POKE_BYTES ( mcastaddr , sizeof ( mcastaddr ) ) && POKE_BYTES ( & hardware -> h_lladdr , ETHER_ADDR_LEN ) && POKE_UINT16 ( ETHERTYPE_LLDP ) ) ) goto toobig ; if ( ! ( POKE_START_LLDP_TLV ( LLDP_TLV_CHASSIS_ID ) && POKE_UINT8 ( c_id_subtype ) && POKE_BYTES ( c_id , c_id_len ) && POKE_END_LLDP_TLV ) ) goto toobig ; if ( ! ( POKE_START_LLDP_TLV ( LLDP_TLV_PORT_ID ) && POKE_UINT8 ( p_id_subtype ) && POKE_BYTES ( p_id , p_id_len ) && POKE_END_LLDP_TLV ) ) goto toobig ; if ( ! ( POKE_START_LLDP_TLV ( LLDP_TLV_TTL ) && POKE_UINT16 ( shutdown ? 0 : chassis -> c_ttl ) && POKE_END_LLDP_TLV ) ) goto toobig ; if ( shutdown ) goto end ; if ( chassis -> c_name && * chassis -> c_name != '\\0' ) { if ( ! ( POKE_START_LLDP_TLV ( LLDP_TLV_SYSTEM_NAME ) && POKE_BYTES ( chassis -> c_name , strlen ( chassis -> c_name ) ) && POKE_END_LLDP_TLV ) ) goto toobig ; } if ( chassis -> c_descr && * chassis -> c_descr != '\\0' ) { if ( ! ( POKE_START_LLDP_TLV ( LLDP_TLV_SYSTEM_DESCR ) && POKE_BYTES ( chassis -> c_descr , strlen ( chassis -> c_descr ) ) && POKE_END_LLDP_TLV ) ) goto toobig ; } if ( global -> g_config . c_cap_advertise && chassis -> c_cap_available ) { if ( ! ( POKE_START_LLDP_TLV ( LLDP_TLV_SYSTEM_CAP ) && POKE_UINT16 ( chassis -> c_cap_available ) && POKE_UINT16 ( chassis -> c_cap_enabled ) && POKE_END_LLDP_TLV ) ) goto toobig ; } TAILQ_FOREACH ( mgmt , & chassis -> c_mgmt , m_entries ) { proto = lldpd_af_to_lldp_proto ( mgmt -> m_family ) ; assert ( proto != LLDP_MGMT_ADDR_NONE ) ; if ( ! ( POKE_START_LLDP_TLV ( LLDP_TLV_MGMT_ADDR ) && POKE_UINT8 ( mgmt -> m_addrsize + 1 ) && POKE_UINT8 ( proto ) && POKE_BYTES ( & mgmt -> m_addr , mgmt -> m_addrsize ) ) ) goto toobig ; if ( mgmt -> m_iface == 0 ) { if ( ! ( POKE_UINT8 ( LLDP_MGMT_IFACE_UNKNOWN ) && POKE_UINT32 ( 0 ) ) ) goto toobig ; } else { if ( ! ( POKE_UINT8 ( LLDP_MGMT_IFACE_IFINDEX ) && POKE_UINT32 ( mgmt -> m_iface ) ) ) goto toobig ; } if ( ! ( POKE_UINT8 ( 0 ) && POKE_END_LLDP_TLV ) ) goto toobig ; } if ( port -> p_descr && * port -> p_descr != '\\0' ) { if ( ! ( POKE_START_LLDP_TLV ( LLDP_TLV_PORT_DESCR ) && POKE_BYTES ( port -> p_descr , strlen ( port -> p_descr ) ) && POKE_END_LLDP_TLV ) ) goto toobig ; } # ifdef ENABLE_DOT1 if ( port -> p_pvid != 0 ) { if ( ! ( POKE_START_LLDP_TLV ( LLDP_TLV_ORG ) && POKE_BYTES ( dot1 , sizeof ( dot1 ) ) && POKE_UINT8 ( LLDP_TLV_DOT1_PVID ) && POKE_UINT16 ( port -> p_pvid ) && POKE_END_LLDP_TLV ) ) { goto toobig ; } } TAILQ_FOREACH ( ppvid , & port -> p_ppvids , p_entries ) { if ( ! ( POKE_START_LLDP_TLV ( LLDP_TLV_ORG ) && POKE_BYTES ( dot1 , sizeof ( dot1 ) ) && POKE_UINT8 ( LLDP_TLV_DOT1_PPVID ) && POKE_UINT8 ( ppvid -> p_cap_status ) && POKE_UINT16 ( ppvid -> p_ppvid ) && POKE_END_LLDP_TLV ) ) { goto toobig ; } } TAILQ_FOREACH ( vlan , & port -> p_vlans , v_entries ) { if ( ! ( POKE_START_LLDP_TLV ( LLDP_TLV_ORG ) && POKE_BYTES ( dot1 , sizeof ( dot1 ) ) && POKE_UINT8 ( LLDP_TLV_DOT1_VLANNAME ) && POKE_UINT16 ( vlan -> v_vid ) && POKE_UINT8 ( strlen ( vlan -> v_name ) ) && POKE_BYTES ( vlan -> v_name , strlen ( vlan -> v_name ) ) && POKE_END_LLDP_TLV ) ) goto toobig ; } TAILQ_FOREACH ( pi , & port -> p_pids , p_entries ) { if ( ! ( POKE_START_LLDP_TLV ( LLDP_TLV_ORG ) && POKE_BYTES ( dot1 , sizeof ( dot1 ) ) && POKE_UINT8 ( LLDP_TLV_DOT1_PI ) && POKE_UINT8 ( pi -> p_pi_len ) && POKE_BYTES ( pi -> p_pi , pi -> p_pi_len ) && POKE_END_LLDP_TLV ) ) goto toobig ; } # endif # ifdef ENABLE_DOT3 if ( ! ( POKE_START_LLDP_TLV ( LLDP_TLV_ORG ) && POKE_BYTES ( dot3 , sizeof ( dot3 ) ) && POKE_UINT8 ( LLDP_TLV_DOT3_LA ) && POKE_UINT8 ( ( port -> p_aggregid ) ? 3 : 1 ) && POKE_UINT32 ( port -> p_aggregid ) && POKE_END_LLDP_TLV ) ) goto toobig ; if ( ! ( POKE_START_LLDP_TLV ( LLDP_TLV_ORG ) && POKE_BYTES ( dot3 , sizeof ( dot3 ) ) && POKE_UINT8 ( LLDP_TLV_DOT3_MAC ) && POKE_UINT8 ( port -> p_macphy . autoneg_support | ( port -> p_macphy . autoneg_enabled << 1 ) ) && POKE_UINT16 ( port -> p_macphy . autoneg_advertised ) && POKE_UINT16 ( port -> p_macphy . mau_type ) && POKE_END_LLDP_TLV ) ) goto toobig ; if ( port -> p_mfs ) { if ( ! ( POKE_START_LLDP_TLV ( LLDP_TLV_ORG ) && POKE_BYTES ( dot3 , sizeof ( dot3 ) ) && POKE_UINT8 ( LLDP_TLV_DOT3_MFS ) && POKE_UINT16 ( port -> p_mfs ) && POKE_END_LLDP_TLV ) ) goto toobig ; } if ( port -> p_power . devicetype ) { if ( ! ( POKE_START_LLDP_TLV ( LLDP_TLV_ORG ) && POKE_BYTES ( dot3 , sizeof ( dot3 ) ) && POKE_UINT8 ( LLDP_TLV_DOT3_POWER ) && POKE_UINT8 ( ( ( ( ( 2 - port -> p_power . devicetype ) % ( 1 << 1 ) ) << 0 ) | ( ( port -> p_power . supported % ( 1 << 1 ) ) << 1 ) | ( ( port -> p_power . enabled % ( 1 << 1 ) ) << 2 ) | ( ( port -> p_power . paircontrol % ( 1 << 1 ) ) << 3 ) ) ) && POKE_UINT8 ( port -> p_power . pairs ) && POKE_UINT8 ( port -> p_power . class ) ) ) goto toobig ; if ( port -> p_power . powertype != LLDP_DOT3_POWER_8023AT_OFF ) { if ( ! ( POKE_UINT8 ( ( ( ( ( port -> p_power . powertype == LLDP_DOT3_POWER_8023AT_TYPE1 ) ? 1 : 0 ) << 7 ) | ( ( ( port -> p_power . devicetype == LLDP_DOT3_POWER_PSE ) ? 0 : 1 ) << 6 ) | ( ( port -> p_power . source % ( 1 << 2 ) ) << 4 ) | ( ( port -> p_power . priority % ( 1 << 2 ) ) << 0 ) ) ) && POKE_UINT16 ( port -> p_power . requested ) && POKE_UINT16 ( port -> p_power . allocated ) ) ) goto toobig ; } if ( ! ( POKE_END_LLDP_TLV ) ) goto toobig ; } # endif # ifdef ENABLE_LLDPMED if ( port -> p_med_cap_enabled ) { if ( ! ( POKE_START_LLDP_TLV ( LLDP_TLV_ORG ) && POKE_BYTES ( med , sizeof ( med ) ) && POKE_UINT8 ( LLDP_TLV_MED_CAP ) && POKE_UINT16 ( chassis -> c_med_cap_available ) && POKE_UINT8 ( chassis -> c_med_type ) && POKE_END_LLDP_TLV ) ) goto toobig ; # define LLDP_INVENTORY ( value , subtype ) if ( value ) { if ( ! ( POKE_START_LLDP_TLV ( LLDP_TLV_ORG ) && POKE_BYTES ( med , sizeof ( med ) ) && POKE_UINT8 ( subtype ) && POKE_BYTES ( value , ( strlen ( value ) > 32 ) ? 32 : strlen ( value ) ) && POKE_END_LLDP_TLV ) ) goto toobig ; } if ( port -> p_med_cap_enabled & LLDP_MED_CAP_IV ) { LLDP_INVENTORY ( chassis -> c_med_hw , LLDP_TLV_MED_IV_HW ) ; LLDP_INVENTORY ( chassis -> c_med_fw , LLDP_TLV_MED_IV_FW ) ; LLDP_INVENTORY ( chassis -> c_med_sw , LLDP_TLV_MED_IV_SW ) ; LLDP_INVENTORY ( chassis -> c_med_sn , LLDP_TLV_MED_IV_SN ) ; LLDP_INVENTORY ( chassis -> c_med_manuf , LLDP_TLV_MED_IV_MANUF ) ; LLDP_INVENTORY ( chassis -> c_med_model , LLDP_TLV_MED_IV_MODEL ) ; LLDP_INVENTORY ( chassis -> c_med_asset , LLDP_TLV_MED_IV_ASSET ) ; } for ( i = 0 ; i < LLDP_MED_LOCFORMAT_LAST ; i ++ ) { if ( port -> p_med_location [ i ] . format == i + 1 ) { if ( ! ( POKE_START_LLDP_TLV ( LLDP_TLV_ORG ) && POKE_BYTES ( med , sizeof ( med ) ) && POKE_UINT8 ( LLDP_TLV_MED_LOCATION ) && POKE_UINT8 ( port -> p_med_location [ i ] . format ) && POKE_BYTES ( port -> p_med_location [ i ] . data , port -> p_med_location [ i ] . data_len ) && POKE_END_LLDP_TLV ) ) goto toobig ; } } for ( i = 0 ; i < LLDP_MED_APPTYPE_LAST ; i ++ ) { if ( port -> p_med_policy [ i ] . type == i + 1 ) { if ( ! ( POKE_START_LLDP_TLV ( LLDP_TLV_ORG ) && POKE_BYTES ( med , sizeof ( med ) ) && POKE_UINT8 ( LLDP_TLV_MED_POLICY ) && POKE_UINT32 ( ( ( ( port -> p_med_policy [ i ] . type % ( 1 << 8 ) ) << 24 ) | ( ( port -> p_med_policy [ i ] . unknown % ( 1 << 1 ) ) << 23 ) | ( ( port -> p_med_policy [ i ] . tagged % ( 1 << 1 ) ) << 22 ) | ( ( port -> p_med_policy [ i ] . vid % ( 1 << 12 ) ) << 9 ) | ( ( port -> p_med_policy [ i ] . priority % ( 1 << 3 ) ) << 6 ) | ( ( port -> p_med_policy [ i ] . dscp % ( 1 << 6 ) ) << 0 ) ) ) && POKE_END_LLDP_TLV ) ) goto toobig ; } } if ( ( port -> p_med_power . devicetype == LLDP_MED_POW_TYPE_PSE ) || ( port -> p_med_power . devicetype == LLDP_MED_POW_TYPE_PD ) ) { int devicetype = 0 , source = 0 ; if ( ! ( POKE_START_LLDP_TLV ( LLDP_TLV_ORG ) && POKE_BYTES ( med , sizeof ( med ) ) && POKE_UINT8 ( LLDP_TLV_MED_MDI ) ) ) goto toobig ; switch ( port -> p_med_power . devicetype ) { case LLDP_MED_POW_TYPE_PSE : devicetype = 0 ; switch ( port -> p_med_power . source ) { case LLDP_MED_POW_SOURCE_PRIMARY : source = 1 ; break ; case LLDP_MED_POW_SOURCE_BACKUP : source = 2 ; break ; case LLDP_MED_POW_SOURCE_RESERVED : source = 3 ; break ; default : source = 0 ; break ; } break ; case LLDP_MED_POW_TYPE_PD : devicetype = 1 ; switch ( port -> p_med_power . source ) { case LLDP_MED_POW_SOURCE_PSE : source = 1 ; break ; case LLDP_MED_POW_SOURCE_LOCAL : source = 2 ; break ; case LLDP_MED_POW_SOURCE_BOTH : source = 3 ; break ; default : source = 0 ; break ; } break ; } if ( ! ( POKE_UINT8 ( ( ( ( devicetype % ( 1 << 2 ) ) << 6 ) | ( ( source % ( 1 << 2 ) ) << 4 ) | ( ( port -> p_med_power . priority % ( 1 << 4 ) ) << 0 ) ) ) && POKE_UINT16 ( port -> p_med_power . val ) && POKE_END_LLDP_TLV ) ) goto toobig ; } } # endif # ifdef ENABLE_CUSTOM TAILQ_FOREACH ( custom , & port -> p_custom_list , next ) { if ( ! ( POKE_START_LLDP_TLV ( LLDP_TLV_ORG ) && POKE_BYTES ( custom -> oui , sizeof ( custom -> oui ) ) && POKE_UINT8 ( custom -> subtype ) && POKE_BYTES ( custom -> oui_info , custom -> oui_info_len ) && POKE_END_LLDP_TLV ) ) goto toobig ; } # endif end : if ( ! ( POKE_START_LLDP_TLV ( LLDP_TLV_END ) && POKE_END_LLDP_TLV ) ) goto toobig ; if ( interfaces_send_helper ( global , hardware , ( char * ) packet , pos - packet ) == - 1 ) { log_warn ( ""lldp"" , ""unabletosendpacketonrealdevicefor%s"" , hardware -> h_ifname ) ; free ( packet ) ; return ENETDOWN ; } hardware -> h_tx_cnt ++ ; if ( ! shutdown && ( frame = ( struct lldpd_frame * ) malloc ( sizeof ( int ) + pos - packet ) ) != NULL ) { frame -> size = pos - packet ; memcpy ( & frame -> frame , packet , frame -> size ) ; if ( ( hardware -> h_lport . p_lastframe == NULL ) || ( hardware -> h_lport . p_lastframe -> size != frame -> size ) || ( memcmp ( hardware -> h_lport . p_lastframe -> frame , frame -> frame , frame -> size ) != 0 ) ) { free ( hardware -> h_lport . p_lastframe ) ; hardware -> h_lport . p_lastframe = frame ; hardware -> h_lport . p_lastchange = time ( NULL ) ; } else free ( frame ) ; } free ( packet ) ; return 0 ; toobig : free ( packet ) ; return E2BIG ; } "," m_family ) ; if ( proto == LLDP_MGMT_ADDR_NONE ) continue ; if ( ",vincentbernat@lldpd/793526f8884455f43daecd0a2c46772388417a00,CVE-2015-8012,https://github.com/vincentbernat/lldpd/commit/793526f8884455f43daecd0a2c46772388417a00,2020-01-28T19:15Z 128,CWE-310,"CWE-310 int asn1_ber_decoder ( const struct asn1_decoder * decoder , void * context , const unsigned char * data , size_t datalen ) { const unsigned char * machine = decoder -> machine ; const asn1_action_t * actions = decoder -> actions ; size_t machlen = decoder -> machlen ; enum asn1_opcode op ; unsigned char tag = 0 , csp = 0 , jsp = 0 , optag = 0 , hdr = 0 ; const char * errmsg ; size_t pc = 0 , dp = 0 , tdp = 0 , len = 0 ; int ret ; unsigned char flags = 0 ; # define FLAG_INDEFINITE_LENGTH 0x01 # define FLAG_MATCHED 0x02 # define FLAG_LAST_MATCHED 0x04 # define FLAG_CONS 0x20 # define NR_CONS_STACK 10 unsigned short cons_dp_stack [ NR_CONS_STACK ] ; unsigned short cons_datalen_stack [ NR_CONS_STACK ] ; unsigned char cons_hdrlen_stack [ NR_CONS_STACK ] ; # define NR_JUMP_STACK 10 unsigned char jump_stack [ NR_JUMP_STACK ] ; if ( datalen > 65535 ) return - EMSGSIZE ; next_op : pr_debug ( ""next_op:pc=\\e[32m%zu\\e[m/%zudp=\\e[33m%zu\\e[m/%zuC=%dJ=%d\\n"" , pc , machlen , dp , datalen , csp , jsp ) ; if ( unlikely ( pc >= machlen ) ) goto machine_overrun_error ; op = machine [ pc ] ; if ( unlikely ( pc + asn1_op_lengths [ op ] > machlen ) ) goto machine_overrun_error ; if ( op <= ASN1_OP__MATCHES_TAG ) { unsigned char tmp ; if ( ( op & ASN1_OP_MATCH__COND && flags & FLAG_MATCHED ) || dp == datalen ) { flags &= ~ FLAG_LAST_MATCHED ; pc += asn1_op_lengths [ op ] ; goto next_op ; } flags = 0 ; hdr = 2 ; if ( unlikely ( dp >= datalen - 1 ) ) goto data_overrun_error ; tag = data [ dp ++ ] ; if ( unlikely ( ( tag & 0x1f ) == ASN1_LONG_TAG ) ) goto long_tag_not_supported ; if ( op & ASN1_OP_MATCH__ANY ) { pr_debug ( ""-any%02x\\n"" , tag ) ; } else { optag = machine [ pc + 1 ] ; flags |= optag & FLAG_CONS ; tmp = optag ^ tag ; tmp &= ~ ( optag & ASN1_CONS_BIT ) ; pr_debug ( ""-match?%02x%02x%02x\\n"" , tag , optag , tmp ) ; if ( tmp != 0 ) { if ( op & ASN1_OP_MATCH__SKIP ) { pc += asn1_op_lengths [ op ] ; dp -- ; goto next_op ; } goto tag_mismatch ; } } flags |= FLAG_MATCHED ; len = data [ dp ++ ] ; if ( len > 0x7f ) { if ( unlikely ( len == ASN1_INDEFINITE_LENGTH ) ) { if ( unlikely ( ! ( tag & ASN1_CONS_BIT ) ) ) goto indefinite_len_primitive ; flags |= FLAG_INDEFINITE_LENGTH ; if ( unlikely ( 2 > datalen - dp ) ) goto data_overrun_error ; } else { int n = len - 0x80 ; if ( unlikely ( n > 2 ) ) goto length_too_long ; if ( unlikely ( dp >= datalen - n ) ) goto data_overrun_error ; hdr += n ; for ( len = 0 ; n > 0 ; n -- ) { len <<= 8 ; len |= data [ dp ++ ] ; } if ( unlikely ( len > datalen - dp ) ) goto data_overrun_error ; } } if ( flags & FLAG_CONS ) { if ( unlikely ( csp >= NR_CONS_STACK ) ) goto cons_stack_overflow ; cons_dp_stack [ csp ] = dp ; cons_hdrlen_stack [ csp ] = hdr ; if ( ! ( flags & FLAG_INDEFINITE_LENGTH ) ) { cons_datalen_stack [ csp ] = datalen ; datalen = dp + len ; } else { cons_datalen_stack [ csp ] = 0 ; } csp ++ ; } pr_debug ( ""-TAG:%02x%zu%s\\n"" , tag , len , flags & FLAG_CONS ? ""CONS"" : """" ) ; tdp = dp ; } switch ( op ) { case ASN1_OP_MATCH_ANY_ACT : case ASN1_OP_COND_MATCH_ANY_ACT : ret = actions [ machine [ pc + 1 ] ] ( context , hdr , tag , data + dp , len ) ; if ( ret < 0 ) return ret ; goto skip_data ; case ASN1_OP_MATCH_ACT : case ASN1_OP_MATCH_ACT_OR_SKIP : case ASN1_OP_COND_MATCH_ACT_OR_SKIP : ret = actions [ machine [ pc + 2 ] ] ( context , hdr , tag , data + dp , len ) ; if ( ret < 0 ) return ret ; goto skip_data ; case ASN1_OP_MATCH : case ASN1_OP_MATCH_OR_SKIP : case ASN1_OP_MATCH_ANY : case ASN1_OP_COND_MATCH_OR_SKIP : case ASN1_OP_COND_MATCH_ANY : skip_data : if ( ! ( flags & FLAG_CONS ) ) { if ( flags & FLAG_INDEFINITE_LENGTH ) { ret = asn1_find_indefinite_length ( data , datalen , & dp , & len , & errmsg ) ; if ( ret < 0 ) goto error ; } else { dp += len ; } pr_debug ( ""-LEAF:%zu\\n"" , len ) ; } pc += asn1_op_lengths [ op ] ; goto next_op ; case ASN1_OP_MATCH_JUMP : case ASN1_OP_MATCH_JUMP_OR_SKIP : case ASN1_OP_COND_MATCH_JUMP_OR_SKIP : pr_debug ( ""-MATCH_JUMP\\n"" ) ; if ( unlikely ( jsp == NR_JUMP_STACK ) ) goto jump_stack_overflow ; jump_stack [ jsp ++ ] = pc + asn1_op_lengths [ op ] ; pc = machine [ pc + 2 ] ; goto next_op ; case ASN1_OP_COND_FAIL : if ( unlikely ( ! ( flags & FLAG_MATCHED ) ) ) goto tag_mismatch ; pc += asn1_op_lengths [ op ] ; goto next_op ; case ASN1_OP_COMPLETE : if ( unlikely ( jsp != 0 || csp != 0 ) ) { pr_err ( ""ASN.1decodererror:Stacksnotemptyatcompletion(%u,%u)\\n"" , jsp , csp ) ; return - EBADMSG ; } return 0 ; case ASN1_OP_END_SET : case ASN1_OP_END_SET_ACT : if ( unlikely ( ! ( flags & FLAG_MATCHED ) ) ) goto tag_mismatch ; case ASN1_OP_END_SEQ : case ASN1_OP_END_SET_OF : case ASN1_OP_END_SEQ_OF : case ASN1_OP_END_SEQ_ACT : case ASN1_OP_END_SET_OF_ACT : case ASN1_OP_END_SEQ_OF_ACT : if ( unlikely ( csp <= 0 ) ) goto cons_stack_underflow ; csp -- ; tdp = cons_dp_stack [ csp ] ; hdr = cons_hdrlen_stack [ csp ] ; len = datalen ; datalen = cons_datalen_stack [ csp ] ; pr_debug ( ""-endconst=%zudp=%zul=%zu/%zu\\n"" , tdp , dp , len , datalen ) ; if ( datalen == 0 ) { datalen = len ; if ( unlikely ( datalen - dp < 2 ) ) goto data_overrun_error ; if ( data [ dp ++ ] != 0 ) { if ( op & ASN1_OP_END__OF ) { dp -- ; csp ++ ; pc = machine [ pc + 1 ] ; pr_debug ( ""-continue\\n"" ) ; goto next_op ; } goto missing_eoc ; } if ( data [ dp ++ ] != 0 ) goto invalid_eoc ; len = dp - tdp - 2 ; } else { if ( dp < len && ( op & ASN1_OP_END__OF ) ) { datalen = len ; csp ++ ; pc = machine [ pc + 1 ] ; pr_debug ( ""-continue\\n"" ) ; goto next_op ; } if ( dp != len ) goto cons_length_error ; len -= tdp ; pr_debug ( ""-conslenl=%zud=%zu\\n"" , len , dp - tdp ) ; } if ( op & ASN1_OP_END__ACT ) { unsigned char act ; if ( op & ASN1_OP_END__OF ) act = machine [ pc + 2 ] ; else act = machine [ pc + 1 ] ; ret = actions [ act ] ( context , hdr , 0 , data + tdp , len ) ; } pc += asn1_op_lengths [ op ] ; goto next_op ; case ASN1_OP_MAYBE_ACT : if ( ! ( flags & FLAG_LAST_MATCHED ) ) { pc += asn1_op_lengths [ op ] ; goto next_op ; } case ASN1_OP_ACT : ret = actions [ machine [ pc + 1 ] ] ( context , hdr , tag , data + tdp , len ) ; if ( ret < 0 ) return ret ; pc += asn1_op_lengths [ op ] ; goto next_op ; case ASN1_OP_RETURN : if ( unlikely ( jsp <= 0 ) ) goto jump_stack_underflow ; pc = jump_stack [ -- jsp ] ; flags |= FLAG_MATCHED | FLAG_LAST_MATCHED ; goto next_op ; default : break ; } pr_err ( ""ASN.1decodererror:Foundreservedopcode(%u)pc=%zu\\n"" , op , pc ) ; return - EBADMSG ; data_overrun_error : errmsg = ""Dataoverrunerror"" ; goto error ; machine_overrun_error : errmsg = ""Machineoverrunerror"" ; goto error ; jump_stack_underflow : errmsg = ""Jumpstackunderflow"" ; goto error ; jump_stack_overflow : errmsg = ""Jumpstackoverflow"" ; goto error ; cons_stack_underflow : errmsg = ""Consstackunderflow"" ; goto error ; cons_stack_overflow : errmsg = ""Consstackoverflow"" ; goto error ; cons_length_error : errmsg = ""Conslengtherror"" ; goto error ; missing_eoc : errmsg = ""MissingEOCinindefinitelencons"" ; goto error ; invalid_eoc : errmsg = ""InvalidlengthEOC"" ; goto error ; length_too_long : errmsg = ""Unsupportedlength"" ; goto error ; indefinite_len_primitive : errmsg = ""Indefinitelenprimitivenotpermitted"" ; goto error ; tag_mismatch : errmsg = ""Unexpectedtag"" ; goto error ; long_tag_not_supported : errmsg = ""Longtagnotsupported"" ; error : pr_debug ( ""\\nASN1:%s[m=%zud=%zuot=%02xt=%02xl=%zu]\\n"" , errmsg , pc , dp , optag , tag , len ) ; return - EBADMSG ; } "," FLAG_MATCHED ) || ( op & ASN1_OP_MATCH__SKIP && dp == datalen ) ",torvalds@linux/0d62e9dd6da45bbf0f33a8617afc5fe774c8f45f,CVE-2016-2053,https://github.com/torvalds/linux/commit/0d62e9dd6da45bbf0f33a8617afc5fe774c8f45f,2016-05-02T10:59Z 129,CWE-362,"CWE-362 static int sctp_init_sock ( struct sock * sk ) { struct net * net = sock_net ( sk ) ; struct sctp_sock * sp ; pr_debug ( ""%s:sk:%p\\n"" , __func__ , sk ) ; sp = sctp_sk ( sk ) ; switch ( sk -> sk_type ) { case SOCK_SEQPACKET : sp -> type = SCTP_SOCKET_UDP ; break ; case SOCK_STREAM : sp -> type = SCTP_SOCKET_TCP ; break ; default : return - ESOCKTNOSUPPORT ; } sp -> default_stream = 0 ; sp -> default_ppid = 0 ; sp -> default_flags = 0 ; sp -> default_context = 0 ; sp -> default_timetolive = 0 ; sp -> default_rcv_context = 0 ; sp -> max_burst = net -> sctp . max_burst ; sp -> sctp_hmac_alg = net -> sctp . sctp_hmac_alg ; sp -> initmsg . sinit_num_ostreams = sctp_max_outstreams ; sp -> initmsg . sinit_max_instreams = sctp_max_instreams ; sp -> initmsg . sinit_max_attempts = net -> sctp . max_retrans_init ; sp -> initmsg . sinit_max_init_timeo = net -> sctp . rto_max ; sp -> rtoinfo . srto_initial = net -> sctp . rto_initial ; sp -> rtoinfo . srto_max = net -> sctp . rto_max ; sp -> rtoinfo . srto_min = net -> sctp . rto_min ; sp -> assocparams . sasoc_asocmaxrxt = net -> sctp . max_retrans_association ; sp -> assocparams . sasoc_number_peer_destinations = 0 ; sp -> assocparams . sasoc_peer_rwnd = 0 ; sp -> assocparams . sasoc_local_rwnd = 0 ; sp -> assocparams . sasoc_cookie_life = net -> sctp . valid_cookie_life ; memset ( & sp -> subscribe , 0 , sizeof ( struct sctp_event_subscribe ) ) ; sp -> hbinterval = net -> sctp . hb_interval ; sp -> pathmaxrxt = net -> sctp . max_retrans_path ; sp -> pathmtu = 0 ; sp -> sackdelay = net -> sctp . sack_timeout ; sp -> sackfreq = 2 ; sp -> param_flags = SPP_HB_ENABLE | SPP_PMTUD_ENABLE | SPP_SACKDELAY_ENABLE ; sp -> disable_fragments = 0 ; sp -> nodelay = 0 ; sp -> recvrcvinfo = 0 ; sp -> recvnxtinfo = 0 ; sp -> v4mapped = 1 ; sp -> autoclose = 0 ; sp -> user_frag = 0 ; sp -> adaptation_ind = 0 ; sp -> pf = sctp_get_pf_specific ( sk -> sk_family ) ; atomic_set ( & sp -> pd_mode , 0 ) ; skb_queue_head_init ( & sp -> pd_lobby ) ; sp -> frag_interleave = 0 ; sp -> ep = sctp_endpoint_new ( sk , GFP_KERNEL ) ; if ( ! sp -> ep ) return - ENOMEM ; sp -> hmac = NULL ; sk -> sk_destruct = sctp_destruct_sock ; SCTP_DBG_OBJCNT_INC ( sock ) ; local_bh_disable ( ) ; percpu_counter_inc ( & sctp_sockets_allocated ) ; sock_prot_inuse_add ( net , sk -> sk_prot , 1 ) ; if ( net -> sctp . default_auto_asconf ) { list_add_tail ( & sp -> auto_asconf_list , & net -> sctp . auto_asconf_splist ) ; sp -> do_auto_asconf = 1 ; } else sp -> do_auto_asconf = 0 ; local_bh_enable ( ) ; return 0 ; } "," default_auto_asconf ) { spin_lock ( & sock_net ( sk ) -> sctp . addr_wq_lock ) ; do_auto_asconf = 1 ; spin_unlock ( & sock_net ( sk ) -> sctp . addr_wq_lock ) ; } else { = 0 ; } ",torvalds@linux/2d45a02d0166caf2627fe91897c6ffc3b19514c4,CVE-2015-3212,https://github.com/torvalds/linux/commit/2d45a02d0166caf2627fe91897c6ffc3b19514c4,2015-08-31T10:59Z 130,CWE-476,"CWE-476 static int mpeg4_decode_profile_level ( MpegEncContext * s , GetBitContext * gb ) { s -> avctx -> profile = get_bits ( gb , 4 ) ; s -> avctx -> level = get_bits ( gb , 4 ) ; if ( s -> avctx -> profile == 0 && s -> avctx -> level == 8 ) { s -> avctx -> level = 0 ; } return 0 ; } "," GetBitContext * gb , int * profile , int * level ) { * profile = get_bits 4 ) ; * level = get_bits ; if ( * profile == 0 == 0 && * level == 8 8 ) { * level = 0 ",FFmpeg@FFmpeg/2aa9047486dbff12d9e040f917e5f799ed2fd78b,CVE-2018-13301,https://github.com/FFmpeg/FFmpeg/commit/2aa9047486dbff12d9e040f917e5f799ed2fd78b,2018-07-05T17:29Z 131,CWE-125,"CWE-125 void snd_msndmidi_input_read ( void * mpuv ) { unsigned long flags ; struct snd_msndmidi * mpu = mpuv ; void * pwMIDQData = mpu -> dev -> mappedbase + MIDQ_DATA_BUFF ; spin_lock_irqsave ( & mpu -> input_lock , flags ) ; while ( readw ( mpu -> dev -> MIDQ + JQS_wTail ) != readw ( mpu -> dev -> MIDQ + JQS_wHead ) ) { u16 wTmp , val ; val = readw ( pwMIDQData + 2 * readw ( mpu -> dev -> MIDQ + JQS_wHead ) ) ; if ( test_bit ( MSNDMIDI_MODE_BIT_INPUT_TRIGGER , & mpu -> mode ) ) snd_rawmidi_receive ( mpu -> substream_input , ( unsigned char * ) & val , 1 ) ; wTmp = readw ( mpu -> dev -> MIDQ + JQS_wHead ) + 1 ; if ( wTmp > readw ( mpu -> dev -> MIDQ + JQS_wSize ) ) writew ( 0 , mpu -> dev -> MIDQ + JQS_wHead ) ; else writew ( wTmp , mpu -> dev -> MIDQ + JQS_wHead ) ; } spin_unlock_irqrestore ( & mpu -> input_lock , flags ) ; } "," + MIDQ_DATA_BUFF ; u16 head , tail , size ; flags ) ; head = readw ( mpu -> dev -> MIDQ + JQS_wHead ) ; tail = readw ( mpu -> dev -> MIDQ + JQS_wTail ) ; size = readw ( mpu -> dev -> MIDQ + JQS_wSize ) ; if ( head > size || tail > size ) goto out ; while ( head != tail ) { unsigned char val = readw ( pwMIDQData + 2 * head ) ; if ( test_bit ( MSNDMIDI_MODE_BIT_INPUT_TRIGGER , & mpu -> mode ) ) snd_rawmidi_receive ( mpu -> substream_input , & val , 1 ) 1 ) ; if ( ++ head > size ) head = 0 ; writew ( head , mpu -> dev + JQS_wHead ) ; } out : spin_unlock_irqrestore ( & ",torvalds@linux/20e2b791796bd68816fa115f12be5320de2b8021,CVE-2017-9985,https://github.com/torvalds/linux/commit/20e2b791796bd68816fa115f12be5320de2b8021,2017-06-28T06:29Z 132,CWE-264,"CWE-264 static int ima_lsm_rule_init ( struct ima_measure_rule_entry * entry , char * args , int lsm_rule , int audit_type ) { int result ; if ( entry -> lsm [ lsm_rule ] . rule ) return - EINVAL ; entry -> lsm [ lsm_rule ] . type = audit_type ; result = security_filter_rule_init ( entry -> lsm [ lsm_rule ] . type , Audit_equal , args , & entry -> lsm [ lsm_rule ] . rule ) ; return result ; } "," rule ) ; if ( ! entry -> lsm [ lsm_rule ] . rule ) return - EINVAL ; ",torvalds@linux/867c20265459d30a01b021a9c1e81fb4c5832aa9,CVE-2011-0006,https://github.com/torvalds/linux/commit/867c20265459d30a01b021a9c1e81fb4c5832aa9,2012-06-21T23:55Z 133,CWE-17,"CWE-17 void put_filp ( struct file * file ) { if ( atomic_long_dec_and_test ( & file -> f_count ) ) { security_file_free ( file ) ; file_sb_list_del ( file ) ; file_free ( file ) ; } } "," file ) ; file_free ( file ",torvalds@linux/eee5cc2702929fd41cce28058dc6d6717f723f87,CVE-2014-8172,https://github.com/torvalds/linux/commit/eee5cc2702929fd41cce28058dc6d6717f723f87,2015-03-16T10:59Z 134,CWE-20,"CWE-20 static void ikev2_parent_inI1outR1_continue ( struct pluto_crypto_req_cont * pcrc , struct pluto_crypto_req * r , err_t ugh ) { struct ke_continuation * ke = ( struct ke_continuation * ) pcrc ; struct msg_digest * md = ke -> md ; struct state * const st = md -> st ; stf_status e ; DBG ( DBG_CONTROLMORE , DBG_log ( ""ikev2parentinI1outR1:calculatedke+nonce,sendingR1"" ) ) ; if ( st == NULL ) { loglog ( RC_LOG_SERIOUS , ""%s:Requestwasdisconnectedfromstate"" , __FUNCTION__ ) ; if ( ke -> md ) release_md ( ke -> md ) ; return ; } passert ( ugh == NULL ) ; passert ( cur_state == NULL ) ; passert ( st != NULL ) ; passert ( st -> st_suspended_md == ke -> md ) ; set_suspended ( st , NULL ) ; set_cur_state ( st ) ; st -> st_calculating = FALSE ; e = ikev2_parent_inI1outR1_tail ( pcrc , r ) ; if ( ke -> md != NULL ) { complete_v2_state_transition ( & ke -> md , e ) ; if ( ke -> md ) release_md ( ke -> md ) ; } reset_globals ( ) ; passert ( GLOBALS_ARE_RESET ( ) ) ; } "," ( ) ; } ",libreswan@libreswan/2899351224fe2940aec37d7656e1e392c0fe07f0,CVE-2013-7294,https://github.com/libreswan/libreswan/commit/2899351224fe2940aec37d7656e1e392c0fe07f0,2014-01-16T05:05Z 135,CWE-79,"CWE-79 static int oidc_handle_session_management_iframe_rp ( request_rec * r , oidc_cfg * c , oidc_session_t * session , const char * client_id , const char * check_session_iframe ) { oidc_debug ( r , ""enter"" ) ; const char * java_script = ""type=\\""text/javascript\\"">\\n"" ""vartargetOrigin=\'%s\';\\n"" ""varmessage=\'%s\'+\'\'+\'%s\';\\n"" ""\tvartimerID;\\n"" ""\\n"" ""functioncheckSession(){\\n"" ""console.debug(\'checkSession:posting\'+message+\'to\'+targetOrigin);\\n"" ""varwin=window.parent.document.getElementById(\'%s\').contentWindow;\\n"" ""win.postMessage(message,targetOrigin);\\n"" ""}\\n"" ""\\n"" ""functionsetTimer(){\\n"" ""checkSession();\\n"" ""timerID=setInterval(\'checkSession()\',%s);\\n"" ""}\\n"" ""\\n"" ""functionreceiveMessage(e){\\n"" ""console.debug(\'receiveMessage:\'+e.data+\'from\'+e.origin);\\n"" ""if(e.origin!==targetOrigin){\\n"" ""console.debug(\'receiveMessage:cross-sitescriptingattack?\');\\n"" ""return;\\n"" ""}\\n"" ""if(e.data!=\'unchanged\'){\\n"" ""clearInterval(timerID);\\n"" ""if(e.data==\'changed\'){\\n"" ""\t\twindow.location.href=\'%s?session=check\';\\n"" ""}else{\\n"" ""\t\twindow.location.href=\'%s?session=logout\';\\n"" ""}\\n"" ""}\\n"" ""}\\n"" ""\\n"" ""window.addEventListener(\'message\',receiveMessage,false);\\n"" ""\\n"" ""\\n"" ; char * origin = apr_pstrdup ( r -> pool , check_session_iframe ) ; apr_uri_t uri ; apr_uri_parse ( r -> pool , check_session_iframe , & uri ) ; char * p = strstr ( origin , uri . path ) ; * p = '\\0' ; const char * op_iframe_id = ""openidc-op"" ; const char * session_state = oidc_session_get_session_state ( r , session ) ; if ( session_state == NULL ) { oidc_warn ( r , ""nosession_statefoundinthesession;theOPdoesprobablynotsupportsessionmanagement!?"" ) ; return DONE ; } char * s_poll_interval = NULL ; oidc_util_get_request_parameter ( r , ""poll"" , & s_poll_interval ) ; if ( s_poll_interval == NULL ) s_poll_interval = ""3000"" ; const char * redirect_uri = oidc_get_redirect_uri ( r , c ) ; java_script = apr_psprintf ( r -> pool , java_script , origin , client_id , session_state , op_iframe_id , s_poll_interval , redirect_uri , redirect_uri ) ; return oidc_util_html_send ( r , NULL , java_script , ""setTimer"" , NULL , DONE ) ; } "," ""\\n"" ""functionsetTimer(){\\n"" ""checkSession();\\n"" ""timerID=setInterval(\'checkSession()\',%d);\\n"" ""}\\n"" ""\\n"" ""functionreceiveMessage(e){\\n"" s_poll_interval ) ; int poll_interval = s_poll_interval ? strtol ( s_poll_interval , NULL , 10 ) : 0 ; if ( ( poll_interval <= 0 ) || ( poll_interval > 3600 * 24 ) ) poll_interval = 3000 ; const char , op_iframe_id , poll_interval , redirect_uri , ",zmartzone@mod_auth_openidc/132a4111bf3791e76437619a66336dce2ce4c79b,CVE-2019-1010247,https://github.com/zmartzone/mod_auth_openidc/commit/132a4111bf3791e76437619a66336dce2ce4c79b,2019-07-19T15:15Z 136,CWE-189,"CWE-189 static int decode_getacl ( struct xdr_stream * xdr , struct rpc_rqst * req , size_t * acl_len ) { __be32 * savep ; uint32_t attrlen , bitmap [ 3 ] = { 0 } ; struct kvec * iov = req -> rq_rcv_buf . head ; int status ; * acl_len = 0 ; if ( ( status = decode_op_hdr ( xdr , OP_GETATTR ) ) != 0 ) goto out ; if ( ( status = decode_attr_bitmap ( xdr , bitmap ) ) != 0 ) goto out ; if ( ( status = decode_attr_length ( xdr , & attrlen , & savep ) ) != 0 ) goto out ; if ( unlikely ( bitmap [ 0 ] & ( FATTR4_WORD0_ACL - 1U ) ) ) return - EIO ; if ( likely ( bitmap [ 0 ] & FATTR4_WORD0_ACL ) ) { size_t hdrlen ; u32 recvd ; hdrlen = ( u8 * ) xdr -> p - ( u8 * ) iov -> iov_base ; recvd = req -> rq_rcv_buf . len - hdrlen ; if ( attrlen > recvd ) { dprintk ( ""NFS:servercheatingingetattr"" ""aclreply:attrlen%u>recvd%u\\n"" , attrlen , recvd ) ; return - EINVAL ; } xdr_read_pages ( xdr , attrlen ) ; * acl_len = attrlen ; } else status = - EOPNOTSUPP ; out : return status ; } "," * req , struct nfs_getaclres * res ) { __be32 __be32 * savep , * bm_p int status ; res -> acl_len = 0 ) goto out ; bm_p = xdr -> p u32 recvd ; xdr -> p = bm_p ; res -> acl_data_offset = be32_to_cpup ( bm_p ) + 2 ; res -> acl_data_offset <<= 2 ; iov -> iov_base ; attrlen += res -> acl_data_offset recvd ) { if ( res -> acl_flags & NFS4_ACL_LEN_REQUEST ) { res -> acl_len = attrlen ; goto out ; } dprintk ( ""NFS:aclreply:attrlen%u>recvd%u\\n"" , attrlen , attrlen ) ; res -> acl_len = attrlen ",torvalds@linux/bf118a342f10dafe44b14451a1392c3254629a1f,CVE-2011-4131,https://github.com/torvalds/linux/commit/bf118a342f10dafe44b14451a1392c3254629a1f,2012-05-17T11:00Z 137,CWE-125,"CWE-125 static struct sk_buff * udp6_ufo_fragment ( struct sk_buff * skb , netdev_features_t features ) { struct sk_buff * segs = ERR_PTR ( - EINVAL ) ; unsigned int mss ; unsigned int unfrag_ip6hlen , unfrag_len ; struct frag_hdr * fptr ; u8 * packet_start , * prevhdr ; u8 nexthdr ; u8 frag_hdr_sz = sizeof ( struct frag_hdr ) ; __wsum csum ; int tnl_hlen ; mss = skb_shinfo ( skb ) -> gso_size ; if ( unlikely ( skb -> len <= mss ) ) goto out ; if ( skb_gso_ok ( skb , features | NETIF_F_GSO_ROBUST ) ) { skb_shinfo ( skb ) -> gso_segs = DIV_ROUND_UP ( skb -> len , mss ) ; if ( ! skb_shinfo ( skb ) -> ip6_frag_id ) ipv6_proxy_select_ident ( dev_net ( skb -> dev ) , skb ) ; segs = NULL ; goto out ; } if ( skb -> encapsulation && skb_shinfo ( skb ) -> gso_type & ( SKB_GSO_UDP_TUNNEL | SKB_GSO_UDP_TUNNEL_CSUM ) ) segs = skb_udp_tunnel_segment ( skb , features , true ) ; else { const struct ipv6hdr * ipv6h ; struct udphdr * uh ; if ( ! pskb_may_pull ( skb , sizeof ( struct udphdr ) ) ) goto out ; uh = udp_hdr ( skb ) ; ipv6h = ipv6_hdr ( skb ) ; uh -> check = 0 ; csum = skb_checksum ( skb , 0 , skb -> len , 0 ) ; uh -> check = udp_v6_check ( skb -> len , & ipv6h -> saddr , & ipv6h -> daddr , csum ) ; if ( uh -> check == 0 ) uh -> check = CSUM_MANGLED_0 ; skb -> ip_summed = CHECKSUM_NONE ; if ( ! skb -> encap_hdr_csum ) features |= NETIF_F_HW_CSUM ; tnl_hlen = skb_tnl_header_len ( skb ) ; if ( skb -> mac_header < ( tnl_hlen + frag_hdr_sz ) ) { if ( gso_pskb_expand_head ( skb , tnl_hlen + frag_hdr_sz ) ) goto out ; } unfrag_ip6hlen = ip6_find_1stfragopt ( skb , & prevhdr ) ; nexthdr = * prevhdr ; * prevhdr = NEXTHDR_FRAGMENT ; unfrag_len = ( skb_network_header ( skb ) - skb_mac_header ( skb ) ) + unfrag_ip6hlen + tnl_hlen ; packet_start = ( u8 * ) skb -> head + SKB_GSO_CB ( skb ) -> mac_offset ; memmove ( packet_start - frag_hdr_sz , packet_start , unfrag_len ) ; SKB_GSO_CB ( skb ) -> mac_offset -= frag_hdr_sz ; skb -> mac_header -= frag_hdr_sz ; skb -> network_header -= frag_hdr_sz ; fptr = ( struct frag_hdr * ) ( skb_network_header ( skb ) + unfrag_ip6hlen ) ; fptr -> nexthdr = nexthdr ; fptr -> reserved = 0 ; if ( ! skb_shinfo ( skb ) -> ip6_frag_id ) ipv6_proxy_select_ident ( dev_net ( skb -> dev ) , skb ) ; fptr -> identification = skb_shinfo ( skb ) -> ip6_frag_id ; segs = skb_segment ( skb , features ) ; } out : return segs ; } "," prevhdr ) ; if ( unfrag_ip6hlen < 0 ) return ERR_PTR ( unfrag_ip6hlen ) ; ",torvalds@linux/2423496af35d94a87156b063ea5cedffc10a70a1,CVE-2017-9074,https://github.com/torvalds/linux/commit/2423496af35d94a87156b063ea5cedffc10a70a1,2017-05-19T07:29Z 138,CWE-125,"CWE-125 GF_Err urn_Read ( GF_Box * s , GF_BitStream * bs ) { u32 i , to_read ; char * tmpName ; GF_DataEntryURNBox * ptr = ( GF_DataEntryURNBox * ) s ; if ( ! ptr -> size ) return GF_OK ; to_read = ( u32 ) ptr -> size ; tmpName = ( char * ) gf_malloc ( sizeof ( char ) * to_read ) ; if ( ! tmpName ) return GF_OUT_OF_MEM ; gf_bs_read_data ( bs , tmpName , to_read ) ; i = 0 ; while ( ( tmpName [ i ] != 0 ) && ( i < to_read ) ) { i ++ ; } if ( i == to_read ) { gf_free ( tmpName ) ; return GF_ISOM_INVALID_FILE ; } if ( i == to_read - 1 ) { ptr -> nameURN = tmpName ; ptr -> location = NULL ; return GF_OK ; } ptr -> nameURN = ( char * ) gf_malloc ( sizeof ( char ) * ( i + 1 ) ) ; if ( ! ptr -> nameURN ) { gf_free ( tmpName ) ; return GF_OUT_OF_MEM ; } ptr -> location = ( char * ) gf_malloc ( sizeof ( char ) * ( to_read - i - 1 ) ) ; if ( ! ptr -> location ) { gf_free ( tmpName ) ; gf_free ( ptr -> nameURN ) ; ptr -> nameURN = NULL ; return GF_OUT_OF_MEM ; } memcpy ( ptr -> nameURN , tmpName , i + 1 ) ; memcpy ( ptr -> location , tmpName + i + 1 , ( to_read - i - 1 ) ) ; gf_free ( tmpName ) ; return GF_OK ; } "," ; while ( ( i < to_read ) && != 0 ) ) { i ",gpac@gpac/bceb03fd2be95097a7b409ea59914f332fb6bc86,CVE-2018-13006,https://github.com/gpac/gpac/commit/bceb03fd2be95097a7b409ea59914f332fb6bc86,2018-06-29T14:29Z 139,CWE-189,"CWE-189 static inline void jiffies_to_compat_timeval ( unsigned long jiffies , struct compat_timeval * value ) { u64 nsec = ( u64 ) jiffies * TICK_NSEC ; long rem ; value -> tv_sec = div_long_long_rem ( nsec , NSEC_PER_SEC , & rem ) ; value -> tv_usec = rem / NSEC_PER_USEC ; } "," * TICK_NSEC ; u32 rem ; value -> tv_sec = div_u64_rem ( nsec , ",torvalds@linux/f8bd2258e2d520dff28c855658bd24bdafb5102d,CVE-2011-3209,https://github.com/torvalds/linux/commit/f8bd2258e2d520dff28c855658bd24bdafb5102d,2012-10-03T11:02Z 140,CWE-119,"CWE-119 static int filter_frame ( AVFilterLink * inlink , AVFrame * in ) { AVFilterContext * ctx = inlink -> dst ; FlipContext * s = ctx -> priv ; AVFilterLink * outlink = ctx -> outputs [ 0 ] ; AVFrame * out ; uint8_t * inrow , * outrow ; int i , j , plane , step ; out = ff_get_video_buffer ( outlink , outlink -> w , outlink -> h ) ; if ( ! out ) { av_frame_free ( & in ) ; return AVERROR ( ENOMEM ) ; } av_frame_copy_props ( out , in ) ; if ( av_pix_fmt_desc_get ( inlink -> format ) -> flags & AV_PIX_FMT_FLAG_PAL ) memcpy ( out -> data [ 1 ] , in -> data [ 1 ] , AVPALETTE_SIZE ) ; for ( plane = 0 ; plane < 4 && in -> data [ plane ] ; plane ++ ) { const int width = ( plane == 1 || plane == 2 ) ? FF_CEIL_RSHIFT ( inlink -> w , s -> hsub ) : inlink -> w ; const int height = ( plane == 1 || plane == 2 ) ? FF_CEIL_RSHIFT ( inlink -> h , s -> vsub ) : inlink -> h ; step = s -> max_step [ plane ] ; outrow = out -> data [ plane ] ; inrow = in -> data [ plane ] + ( width - 1 ) * step ; for ( i = 0 ; i < height ; i ++ ) { switch ( step ) { case 1 : for ( j = 0 ; j < width ; j ++ ) outrow [ j ] = inrow [ - j ] ; break ; case 2 : { uint16_t * outrow16 = ( uint16_t * ) outrow ; uint16_t * inrow16 = ( uint16_t * ) inrow ; for ( j = 0 ; j < width ; j ++ ) outrow16 [ j ] = inrow16 [ - j ] ; } break ; case 3 : { uint8_t * in = inrow ; uint8_t * out = outrow ; for ( j = 0 ; j < width ; j ++ , out += 3 , in -= 3 ) { int32_t v = AV_RB24 ( in ) ; AV_WB24 ( out , v ) ; } } break ; case 4 : { uint32_t * outrow32 = ( uint32_t * ) outrow ; uint32_t * inrow32 = ( uint32_t * ) inrow ; for ( j = 0 ; j < width ; j ++ ) outrow32 [ j ] = inrow32 [ - j ] ; } break ; default : for ( j = 0 ; j < width ; j ++ ) memcpy ( outrow + j * step , inrow - j * step , step ) ; } inrow += in -> linesize [ plane ] ; outrow += out -> linesize [ plane ] ; } } av_frame_free ( & in ) ; return ff_filter_frame ( outlink , out ) ; } "," [ plane ] && in -> linesize [ plane ] ",FFmpeg@FFmpeg/e43a0a232dbf6d3c161823c2e07c52e76227a1bc,CVE-2013-4263,https://github.com/FFmpeg/FFmpeg/commit/e43a0a232dbf6d3c161823c2e07c52e76227a1bc,2013-11-23T17:55Z 141,CWE-119,"CWE-119 BOOL SQLWriteFileDSN ( LPCSTR pszFileName , LPCSTR pszAppName , LPCSTR pszKeyName , LPCSTR pszString ) { HINI hIni ; char szFileName [ ODBC_FILENAME_MAX + 1 ] ; if ( pszFileName [ 0 ] == '/' ) { strncpy ( szFileName , sizeof ( szFileName ) - 5 , pszFileName ) ; } else { char szPath [ ODBC_FILENAME_MAX + 1 ] ; * szPath = '\\0' ; _odbcinst_FileINI ( szPath ) ; snprintf ( szFileName , sizeof ( szFileName ) - 5 , ""%s/%s"" , szPath , pszFileName ) ; } if ( strlen ( szFileName ) < 4 || strcmp ( szFileName + strlen ( szFileName ) - 4 , "".dsn"" ) ) { strcat ( szFileName , "".dsn"" ) ; } # ifdef __OS2__ if ( iniOpen ( & hIni , szFileName , ""#;"" , '[' , ']' , '=' , TRUE , 0L ) != INI_SUCCESS ) # else if ( iniOpen ( & hIni , szFileName , ""#;"" , '[' , ']' , '=' , TRUE ) != INI_SUCCESS ) # endif { inst_logPushMsg ( __FILE__ , __FILE__ , __LINE__ , LOG_CRITICAL , ODBC_ERROR_INVALID_PATH , """" ) ; return FALSE ; } if ( pszString == NULL && pszKeyName == NULL ) { if ( iniObjectSeek ( hIni , ( char * ) pszAppName ) == INI_SUCCESS ) { iniObjectDelete ( hIni ) ; } } else if ( pszString == NULL ) { if ( iniPropertySeek ( hIni , ( char * ) pszAppName , ( char * ) pszKeyName , """" ) == INI_SUCCESS ) { iniPropertyDelete ( hIni ) ; } } else { if ( iniObjectSeek ( hIni , ( char * ) pszAppName ) != INI_SUCCESS ) { iniObjectInsert ( hIni , ( char * ) pszAppName ) ; } if ( iniPropertySeek ( hIni , ( char * ) pszAppName , ( char * ) pszKeyName , """" ) == INI_SUCCESS ) { iniObjectSeek ( hIni , ( char * ) pszAppName ) ; iniPropertyUpdate ( hIni , ( char * ) pszKeyName , ( char * ) pszString ) ; } else { iniObjectSeek ( hIni , ( char * ) pszAppName ) ; iniPropertyInsert ( hIni , ( char * ) pszKeyName , ( char * ) pszString ) ; } } if ( iniCommit ( hIni ) != INI_SUCCESS ) { iniClose ( hIni ) ; inst_logPushMsg ( __FILE__ , __FILE__ , __LINE__ , LOG_CRITICAL , ODBC_ERROR_REQUEST_FAILED , """" ) ; return FALSE ; } iniClose ( hIni ) ; return TRUE ; } "," ( szFileName , pszFileName , ) - 5 ) ; } ",lurcher@unixODBC/45ef78e037f578b15fc58938a3a3251655e71d6f,CVE-2018-7485,https://github.com/lurcher/unixODBC/commit/45ef78e037f578b15fc58938a3a3251655e71d6f,2018-02-26T14:29Z 142,CWE-000,"CWE-000 static int makeDirDirective ( MaState * state , cchar * key , cchar * value ) { MprPath info ; char * auth , * dirs , * path , * perms , * tok ; cchar * dir , * group , * owner ; int gid , mode , uid ; if ( ! maTokenize ( state , value , ""%S?*"" , & auth , & dirs ) ) { return MPR_ERR_BAD_SYNTAX ; } uid = gid = 0 ; mode = 0750 ; if ( schr ( auth , ':' ) ) { owner = stok ( auth , "":"" , & tok ) ; if ( owner && * owner ) { if ( snumber ( owner ) ) { uid = ( int ) stoi ( owner ) ; } else if ( smatch ( owner , ""APPWEB"" ) ) { uid = HTTP -> uid ; } else { uid = userToID ( owner ) ; } } group = stok ( tok , "":"" , & perms ) ; if ( group && * group ) { if ( snumber ( group ) ) { gid = ( int ) stoi ( group ) ; } else if ( smatch ( owner , ""APPWEB"" ) ) { gid = HTTP -> gid ; } else { gid = groupToID ( group ) ; } } if ( perms && snumber ( perms ) ) { mode = ( int ) stoiradix ( perms , - 1 , NULL ) ; } else { mode = 0 ; } if ( gid < 0 || uid < 0 ) { return MPR_ERR_BAD_SYNTAX ; } } else { dirs = auth ; auth = 0 ; } tok = dirs ; for ( tok = sclone ( dirs ) ; ( dir = stok ( tok , "","" , & tok ) ) != 0 ; ) { path = httpMakePath ( state -> route , state -> configDir , dir ) ; if ( mprGetPathInfo ( path , & info ) == 0 && info . isDir ) { continue ; } if ( mprMakeDir ( path , mode , uid , gid , 1 ) < 0 ) { return MPR_ERR_BAD_SYNTAX ; } } return 0 ; } "," { owner = ssplit ( auth , } group = ssplit ( tok , ",embedthis@appweb/7e6a925f5e86a19a7934a94bbd6959101d0b84eb,CVE-2014-9708,https://github.com/embedthis/appweb/commit/7e6a925f5e86a19a7934a94bbd6959101d0b84eb,2015-03-31T14:59Z 143,CWE-119,"CWE-119 int cdf_read_property_info ( const cdf_stream_t * sst , const cdf_header_t * h , uint32_t offs , cdf_property_info_t * * info , size_t * count , size_t * maxcount ) { const cdf_section_header_t * shp ; cdf_section_header_t sh ; const uint8_t * p , * q , * e ; int16_t s16 ; int32_t s32 ; uint32_t u32 ; int64_t s64 ; uint64_t u64 ; cdf_timestamp_t tp ; size_t i , o , o4 , nelements , j ; cdf_property_info_t * inp ; if ( offs > UINT32_MAX / 4 ) { errno = EFTYPE ; goto out ; } shp = CAST ( const cdf_section_header_t * , ( const void * ) ( ( const char * ) sst -> sst_tab + offs ) ) ; if ( cdf_check_stream_offset ( sst , h , shp , sizeof ( * shp ) , __LINE__ ) == - 1 ) goto out ; sh . sh_len = CDF_TOLE4 ( shp -> sh_len ) ; # define CDF_SHLEN_LIMIT ( UINT32_MAX / 8 ) if ( sh . sh_len > CDF_SHLEN_LIMIT ) { errno = EFTYPE ; goto out ; } sh . sh_properties = CDF_TOLE4 ( shp -> sh_properties ) ; # define CDF_PROP_LIMIT ( UINT32_MAX / ( 4 * sizeof ( * inp ) ) ) if ( sh . sh_properties > CDF_PROP_LIMIT ) goto out ; DPRINTF ( ( ""sectionlen:%uproperties%u\\n"" , sh . sh_len , sh . sh_properties ) ) ; if ( * maxcount ) { if ( * maxcount > CDF_PROP_LIMIT ) goto out ; * maxcount += sh . sh_properties ; inp = CAST ( cdf_property_info_t * , realloc ( * info , * maxcount * sizeof ( * inp ) ) ) ; } else { * maxcount = sh . sh_properties ; inp = CAST ( cdf_property_info_t * , malloc ( * maxcount * sizeof ( * inp ) ) ) ; } if ( inp == NULL ) goto out ; * info = inp ; inp += * count ; * count += sh . sh_properties ; p = CAST ( const uint8_t * , ( const void * ) ( ( const char * ) ( const void * ) sst -> sst_tab + offs + sizeof ( sh ) ) ) ; e = CAST ( const uint8_t * , ( const void * ) ( ( ( const char * ) ( const void * ) shp ) + sh . sh_len ) ) ; if ( cdf_check_stream_offset ( sst , h , e , 0 , __LINE__ ) == - 1 ) goto out ; for ( i = 0 ; i < sh . sh_properties ; i ++ ) { q = ( const uint8_t * ) ( const void * ) ( ( const char * ) ( const void * ) p + CDF_GETUINT32 ( p , ( i << 1 ) + 1 ) ) - 2 * sizeof ( uint32_t ) ; if ( q > e ) { DPRINTF ( ( ""Ranoftheend%p>%p\\n"" , q , e ) ) ; goto out ; } inp [ i ] . pi_id = CDF_GETUINT32 ( p , i << 1 ) ; inp [ i ] . pi_type = CDF_GETUINT32 ( q , 0 ) ; DPRINTF ( ( ""%"" SIZE_T_FORMAT ""u)id=%xtype=%xoffs=0x%tx,0x%x\\n"" , i , inp [ i ] . pi_id , inp [ i ] . pi_type , q - p , CDF_GETUINT32 ( p , ( i << 1 ) + 1 ) ) ) ; if ( inp [ i ] . pi_type & CDF_VECTOR ) { nelements = CDF_GETUINT32 ( q , 1 ) ; o = 2 ; } else { nelements = 1 ; o = 1 ; } o4 = o * sizeof ( uint32_t ) ; if ( inp [ i ] . pi_type & ( CDF_ARRAY | CDF_BYREF | CDF_RESERVED ) ) goto unknown ; switch ( inp [ i ] . pi_type & CDF_TYPEMASK ) { case CDF_NULL : case CDF_EMPTY : break ; case CDF_SIGNED16 : if ( inp [ i ] . pi_type & CDF_VECTOR ) goto unknown ; ( void ) memcpy ( & s16 , & q [ o4 ] , sizeof ( s16 ) ) ; inp [ i ] . pi_s16 = CDF_TOLE2 ( s16 ) ; break ; case CDF_SIGNED32 : if ( inp [ i ] . pi_type & CDF_VECTOR ) goto unknown ; ( void ) memcpy ( & s32 , & q [ o4 ] , sizeof ( s32 ) ) ; inp [ i ] . pi_s32 = CDF_TOLE4 ( ( uint32_t ) s32 ) ; break ; case CDF_BOOL : case CDF_UNSIGNED32 : if ( inp [ i ] . pi_type & CDF_VECTOR ) goto unknown ; ( void ) memcpy ( & u32 , & q [ o4 ] , sizeof ( u32 ) ) ; inp [ i ] . pi_u32 = CDF_TOLE4 ( u32 ) ; break ; case CDF_SIGNED64 : if ( inp [ i ] . pi_type & CDF_VECTOR ) goto unknown ; ( void ) memcpy ( & s64 , & q [ o4 ] , sizeof ( s64 ) ) ; inp [ i ] . pi_s64 = CDF_TOLE8 ( ( uint64_t ) s64 ) ; break ; case CDF_UNSIGNED64 : if ( inp [ i ] . pi_type & CDF_VECTOR ) goto unknown ; ( void ) memcpy ( & u64 , & q [ o4 ] , sizeof ( u64 ) ) ; inp [ i ] . pi_u64 = CDF_TOLE8 ( ( uint64_t ) u64 ) ; break ; case CDF_FLOAT : if ( inp [ i ] . pi_type & CDF_VECTOR ) goto unknown ; ( void ) memcpy ( & u32 , & q [ o4 ] , sizeof ( u32 ) ) ; u32 = CDF_TOLE4 ( u32 ) ; memcpy ( & inp [ i ] . pi_f , & u32 , sizeof ( inp [ i ] . pi_f ) ) ; break ; case CDF_DOUBLE : if ( inp [ i ] . pi_type & CDF_VECTOR ) goto unknown ; ( void ) memcpy ( & u64 , & q [ o4 ] , sizeof ( u64 ) ) ; u64 = CDF_TOLE8 ( ( uint64_t ) u64 ) ; memcpy ( & inp [ i ] . pi_d , & u64 , sizeof ( inp [ i ] . pi_d ) ) ; break ; case CDF_LENGTH32_STRING : case CDF_LENGTH32_WSTRING : if ( nelements > 1 ) { size_t nelem = inp - * info ; if ( * maxcount > CDF_PROP_LIMIT || nelements > CDF_PROP_LIMIT ) goto out ; * maxcount += nelements ; inp = CAST ( cdf_property_info_t * , realloc ( * info , * maxcount * sizeof ( * inp ) ) ) ; if ( inp == NULL ) goto out ; * info = inp ; inp = * info + nelem ; } DPRINTF ( ( ""nelements=%"" SIZE_T_FORMAT ""u\\n"" , nelements ) ) ; for ( j = 0 ; j < nelements ; j ++ , i ++ ) { uint32_t l = CDF_GETUINT32 ( q , o ) ; inp [ i ] . pi_str . s_len = l ; inp [ i ] . pi_str . s_buf = ( const char * ) ( const void * ) ( & q [ o4 + sizeof ( l ) ] ) ; DPRINTF ( ( ""l=%d,r=%"" SIZE_T_FORMAT ""u,s=%s\\n"" , l , CDF_ROUND ( l , sizeof ( l ) ) , inp [ i ] . pi_str . s_buf ) ) ; if ( l & 1 ) l ++ ; o += l >> 1 ; if ( q + o >= e ) goto out ; o4 = o * sizeof ( uint32_t ) ; } i -- ; break ; case CDF_FILETIME : if ( inp [ i ] . pi_type & CDF_VECTOR ) goto unknown ; ( void ) memcpy ( & tp , & q [ o4 ] , sizeof ( tp ) ) ; inp [ i ] . pi_tp = CDF_TOLE8 ( ( uint64_t ) tp ) ; break ; case CDF_CLIPBOARD : if ( inp [ i ] . pi_type & CDF_VECTOR ) goto unknown ; break ; default : unknown : DPRINTF ( ( ""Don\'tknowhowtodealwith%x\\n"" , inp [ i ] . pi_type ) ) ; break ; } } return 0 ; out : free ( * info ) ; return - 1 ; } "," ++ ) { size_t ofs = CDF_GETUINT32 ( p , ( i << 1 ) + 1 ) ; ) p + ofs - 2 * sizeof ( uint32_t ) SIZE_T_FORMAT ""u)id=%xtype=%xoffs=0x%tx,0x%x\\n"" , i , inp [ i - p , offs ) ) ; ",glensc@file/1aec04dbf8a24b8a6ba64c4f74efa0628e36db0b,CVE-2012-1571,https://github.com/glensc/file/commit/1aec04dbf8a24b8a6ba64c4f74efa0628e36db0b,2012-07-17T21:55Z 144,CWE-362,"CWE-362 static int inet_sk_reselect_saddr ( struct sock * sk ) { struct inet_sock * inet = inet_sk ( sk ) ; __be32 old_saddr = inet -> inet_saddr ; __be32 daddr = inet -> inet_daddr ; struct flowi4 fl4 ; struct rtable * rt ; __be32 new_saddr ; if ( inet -> opt && inet -> opt -> srr ) daddr = inet -> opt -> faddr ; rt = ip_route_connect ( & fl4 , daddr , 0 , RT_CONN_FLAGS ( sk ) , sk -> sk_bound_dev_if , sk -> sk_protocol , inet -> inet_sport , inet -> inet_dport , sk , false ) ; if ( IS_ERR ( rt ) ) return PTR_ERR ( rt ) ; sk_setup_caps ( sk , & rt -> dst ) ; new_saddr = rt -> rt_src ; if ( new_saddr == old_saddr ) return 0 ; if ( sysctl_ip_dynaddr > 1 ) { printk ( KERN_INFO ""%s():shiftinginet->saddrfrom%pI4to%pI4\\n"" , __func__ , & old_saddr , & new_saddr ) ; } inet -> inet_saddr = inet -> inet_rcv_saddr = new_saddr ; __sk_prot_rehash ( sk ) ; return 0 ; } "," __be32 new_saddr ; struct ip_options_rcu * inet_opt ; inet_opt = rcu_dereference_protected ( inet -> inet_opt , sock_owned_by_user ( sk ) ) ; if ( inet_opt && inet_opt -> opt . srr ) daddr = inet_opt -> opt . faddr ; rt ",torvalds@linux/f6d8bd051c391c1c0458a30b2a7abcd939329259,CVE-2012-3552,https://github.com/torvalds/linux/commit/f6d8bd051c391c1c0458a30b2a7abcd939329259,2012-10-03T11:02Z 145,CWE-119,"CWE-119 static int check_entry_size_and_hooks ( struct ipt_entry * e , struct xt_table_info * newinfo , const unsigned char * base , const unsigned char * limit , const unsigned int * hook_entries , const unsigned int * underflows , unsigned int valid_hooks ) { unsigned int h ; int err ; if ( ( unsigned long ) e % __alignof__ ( struct ipt_entry ) != 0 || ( unsigned char * ) e + sizeof ( struct ipt_entry ) >= limit || ( unsigned char * ) e + e -> next_offset > limit ) { duprintf ( ""Badoffset%p\\n"" , e ) ; return - EINVAL ; } if ( e -> next_offset < sizeof ( struct ipt_entry ) + sizeof ( struct xt_entry_target ) ) { duprintf ( ""checking:element%psize%u\\n"" , e , e -> next_offset ) ; return - EINVAL ; } err = check_entry ( e ) ; if ( err ) return err ; for ( h = 0 ; h < NF_INET_NUMHOOKS ; h ++ ) { if ( ! ( valid_hooks & ( 1 << h ) ) ) continue ; if ( ( unsigned char * ) e - base == hook_entries [ h ] ) newinfo -> hook_entry [ h ] = hook_entries [ h ] ; if ( ( unsigned char * ) e - base == underflows [ h ] ) { if ( ! check_underflow ( e ) ) { pr_err ( ""Underflowsmustbeunconditionaland"" ""usetheSTANDARDtargetwith"" ""ACCEPT/DROP\\n"" ) ; return - EINVAL ; } newinfo -> underflow [ h ] = underflows [ h ] ; } } e -> counters = ( ( struct xt_counters ) { 0 , 0 } ) ; e -> comefrom = 0 ; return 0 ; } "," ) ) { pr_debug ( ""Underflowsmustbeunconditionaland"" ""usetheSTANDARDtargetwith"" ",torvalds@linux/54d83fc74aa9ec72794373cb47432c5f7fb1a309,CVE-2016-3134,https://github.com/torvalds/linux/commit/54d83fc74aa9ec72794373cb47432c5f7fb1a309,2016-04-27T17:59Z 146,CWE-125,"CWE-125 void eigrp_print ( netdissect_options * ndo , register const u_char * pptr , register u_int len ) { const struct eigrp_common_header * eigrp_com_header ; const struct eigrp_tlv_header * eigrp_tlv_header ; const u_char * tptr , * tlv_tptr ; u_int tlen , eigrp_tlv_len , eigrp_tlv_type , tlv_tlen , byte_length , bit_length ; uint8_t prefix [ 4 ] ; union { const struct eigrp_tlv_general_parm_t * eigrp_tlv_general_parm ; const struct eigrp_tlv_sw_version_t * eigrp_tlv_sw_version ; const struct eigrp_tlv_ip_int_t * eigrp_tlv_ip_int ; const struct eigrp_tlv_ip_ext_t * eigrp_tlv_ip_ext ; const struct eigrp_tlv_at_cable_setup_t * eigrp_tlv_at_cable_setup ; const struct eigrp_tlv_at_int_t * eigrp_tlv_at_int ; const struct eigrp_tlv_at_ext_t * eigrp_tlv_at_ext ; } tlv_ptr ; tptr = pptr ; eigrp_com_header = ( const struct eigrp_common_header * ) pptr ; ND_TCHECK ( * eigrp_com_header ) ; if ( eigrp_com_header -> version != EIGRP_VERSION ) { ND_PRINT ( ( ndo , ""EIGRPversion%upacketnotsupported"" , eigrp_com_header -> version ) ) ; return ; } if ( ndo -> ndo_vflag < 1 ) { ND_PRINT ( ( ndo , ""EIGRP%s,length:%u"" , tok2str ( eigrp_opcode_values , ""unknown(%u)"" , eigrp_com_header -> opcode ) , len ) ) ; return ; } tlen = len - sizeof ( struct eigrp_common_header ) ; ND_PRINT ( ( ndo , ""\\n\\tEIGRPv%u,opcode:%s(%u),chksum:0x%04x,Flags:[%s]\\n\\tseq:0x%08x,ack:0x%08x,AS:%u,length:%u"" , eigrp_com_header -> version , tok2str ( eigrp_opcode_values , ""unknown,type:%u"" , eigrp_com_header -> opcode ) , eigrp_com_header -> opcode , EXTRACT_16BITS ( & eigrp_com_header -> checksum ) , tok2str ( eigrp_common_header_flag_values , ""none"" , EXTRACT_32BITS ( & eigrp_com_header -> flags ) ) , EXTRACT_32BITS ( & eigrp_com_header -> seq ) , EXTRACT_32BITS ( & eigrp_com_header -> ack ) , EXTRACT_32BITS ( & eigrp_com_header -> asn ) , tlen ) ) ; tptr += sizeof ( const struct eigrp_common_header ) ; while ( tlen > 0 ) { ND_TCHECK2 ( * tptr , sizeof ( struct eigrp_tlv_header ) ) ; eigrp_tlv_header = ( const struct eigrp_tlv_header * ) tptr ; eigrp_tlv_len = EXTRACT_16BITS ( & eigrp_tlv_header -> length ) ; eigrp_tlv_type = EXTRACT_16BITS ( & eigrp_tlv_header -> type ) ; if ( eigrp_tlv_len < sizeof ( struct eigrp_tlv_header ) || eigrp_tlv_len > tlen ) { print_unknown_data ( ndo , tptr + sizeof ( struct eigrp_tlv_header ) , ""\\n\\t"" , tlen ) ; return ; } ND_PRINT ( ( ndo , ""\\n\\t%sTLV(0x%04x),length:%u"" , tok2str ( eigrp_tlv_values , ""Unknown"" , eigrp_tlv_type ) , eigrp_tlv_type , eigrp_tlv_len ) ) ; tlv_tptr = tptr + sizeof ( struct eigrp_tlv_header ) ; tlv_tlen = eigrp_tlv_len - sizeof ( struct eigrp_tlv_header ) ; ND_TCHECK2 ( * tptr , eigrp_tlv_len ) ; switch ( eigrp_tlv_type ) { case EIGRP_TLV_GENERAL_PARM : tlv_ptr . eigrp_tlv_general_parm = ( const struct eigrp_tlv_general_parm_t * ) tlv_tptr ; ND_PRINT ( ( ndo , ""\\n\\tholdtime:%us,k1%u,k2%u,k3%u,k4%u,k5%u"" , EXTRACT_16BITS ( tlv_ptr . eigrp_tlv_general_parm -> holdtime ) , tlv_ptr . eigrp_tlv_general_parm -> k1 , tlv_ptr . eigrp_tlv_general_parm -> k2 , tlv_ptr . eigrp_tlv_general_parm -> k3 , tlv_ptr . eigrp_tlv_general_parm -> k4 , tlv_ptr . eigrp_tlv_general_parm -> k5 ) ) ; break ; case EIGRP_TLV_SW_VERSION : tlv_ptr . eigrp_tlv_sw_version = ( const struct eigrp_tlv_sw_version_t * ) tlv_tptr ; ND_PRINT ( ( ndo , ""\\n\\tIOSversion:%u.%u,EIGRPversion%u.%u"" , tlv_ptr . eigrp_tlv_sw_version -> ios_major , tlv_ptr . eigrp_tlv_sw_version -> ios_minor , tlv_ptr . eigrp_tlv_sw_version -> eigrp_major , tlv_ptr . eigrp_tlv_sw_version -> eigrp_minor ) ) ; break ; case EIGRP_TLV_IP_INT : tlv_ptr . eigrp_tlv_ip_int = ( const struct eigrp_tlv_ip_int_t * ) tlv_tptr ; bit_length = tlv_ptr . eigrp_tlv_ip_int -> plen ; if ( bit_length > 32 ) { ND_PRINT ( ( ndo , ""\\n\\tillegalprefixlength%u"" , bit_length ) ) ; break ; } byte_length = ( bit_length + 7 ) / 8 ; memset ( prefix , 0 , 4 ) ; memcpy ( prefix , & tlv_ptr . eigrp_tlv_ip_int -> destination , byte_length ) ; ND_PRINT ( ( ndo , ""\\n\\tIPv4prefix:%15s/%u,nexthop:"" , ipaddr_string ( ndo , prefix ) , bit_length ) ) ; if ( EXTRACT_32BITS ( & tlv_ptr . eigrp_tlv_ip_int -> nexthop ) == 0 ) ND_PRINT ( ( ndo , ""self"" ) ) ; else ND_PRINT ( ( ndo , ""%s"" , ipaddr_string ( ndo , & tlv_ptr . eigrp_tlv_ip_int -> nexthop ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\tdelay%ums,bandwidth%uKbps,mtu%u,hop%u,reliability%u,load%u"" , ( EXTRACT_32BITS ( & tlv_ptr . eigrp_tlv_ip_int -> delay ) / 100 ) , EXTRACT_32BITS ( & tlv_ptr . eigrp_tlv_ip_int -> bandwidth ) , EXTRACT_24BITS ( & tlv_ptr . eigrp_tlv_ip_int -> mtu ) , tlv_ptr . eigrp_tlv_ip_int -> hopcount , tlv_ptr . eigrp_tlv_ip_int -> reliability , tlv_ptr . eigrp_tlv_ip_int -> load ) ) ; break ; case EIGRP_TLV_IP_EXT : tlv_ptr . eigrp_tlv_ip_ext = ( const struct eigrp_tlv_ip_ext_t * ) tlv_tptr ; bit_length = tlv_ptr . eigrp_tlv_ip_ext -> plen ; if ( bit_length > 32 ) { ND_PRINT ( ( ndo , ""\\n\\tillegalprefixlength%u"" , bit_length ) ) ; break ; } byte_length = ( bit_length + 7 ) / 8 ; memset ( prefix , 0 , 4 ) ; memcpy ( prefix , & tlv_ptr . eigrp_tlv_ip_ext -> destination , byte_length ) ; ND_PRINT ( ( ndo , ""\\n\\tIPv4prefix:%15s/%u,nexthop:"" , ipaddr_string ( ndo , prefix ) , bit_length ) ) ; if ( EXTRACT_32BITS ( & tlv_ptr . eigrp_tlv_ip_ext -> nexthop ) == 0 ) ND_PRINT ( ( ndo , ""self"" ) ) ; else ND_PRINT ( ( ndo , ""%s"" , ipaddr_string ( ndo , & tlv_ptr . eigrp_tlv_ip_ext -> nexthop ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\torigin-router%s,origin-as%u,origin-proto%s,flags[0x%02x],tag0x%08x,metric%u"" , ipaddr_string ( ndo , tlv_ptr . eigrp_tlv_ip_ext -> origin_router ) , EXTRACT_32BITS ( tlv_ptr . eigrp_tlv_ip_ext -> origin_as ) , tok2str ( eigrp_ext_proto_id_values , ""unknown"" , tlv_ptr . eigrp_tlv_ip_ext -> proto_id ) , tlv_ptr . eigrp_tlv_ip_ext -> flags , EXTRACT_32BITS ( tlv_ptr . eigrp_tlv_ip_ext -> tag ) , EXTRACT_32BITS ( tlv_ptr . eigrp_tlv_ip_ext -> metric ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\tdelay%ums,bandwidth%uKbps,mtu%u,hop%u,reliability%u,load%u"" , ( EXTRACT_32BITS ( & tlv_ptr . eigrp_tlv_ip_ext -> delay ) / 100 ) , EXTRACT_32BITS ( & tlv_ptr . eigrp_tlv_ip_ext -> bandwidth ) , EXTRACT_24BITS ( & tlv_ptr . eigrp_tlv_ip_ext -> mtu ) , tlv_ptr . eigrp_tlv_ip_ext -> hopcount , tlv_ptr . eigrp_tlv_ip_ext -> reliability , tlv_ptr . eigrp_tlv_ip_ext -> load ) ) ; break ; case EIGRP_TLV_AT_CABLE_SETUP : tlv_ptr . eigrp_tlv_at_cable_setup = ( const struct eigrp_tlv_at_cable_setup_t * ) tlv_tptr ; ND_PRINT ( ( ndo , ""\\n\\tCable-range:%u-%u,Router-ID%u"" , EXTRACT_16BITS ( & tlv_ptr . eigrp_tlv_at_cable_setup -> cable_start ) , EXTRACT_16BITS ( & tlv_ptr . eigrp_tlv_at_cable_setup -> cable_end ) , EXTRACT_32BITS ( & tlv_ptr . eigrp_tlv_at_cable_setup -> router_id ) ) ) ; break ; case EIGRP_TLV_AT_INT : tlv_ptr . eigrp_tlv_at_int = ( const struct eigrp_tlv_at_int_t * ) tlv_tptr ; ND_PRINT ( ( ndo , ""\\n\\tCable-Range:%u-%u,nexthop:"" , EXTRACT_16BITS ( & tlv_ptr . eigrp_tlv_at_int -> cable_start ) , EXTRACT_16BITS ( & tlv_ptr . eigrp_tlv_at_int -> cable_end ) ) ) ; if ( EXTRACT_32BITS ( & tlv_ptr . eigrp_tlv_at_int -> nexthop ) == 0 ) ND_PRINT ( ( ndo , ""self"" ) ) ; else ND_PRINT ( ( ndo , ""%u.%u"" , EXTRACT_16BITS ( & tlv_ptr . eigrp_tlv_at_int -> nexthop ) , EXTRACT_16BITS ( & tlv_ptr . eigrp_tlv_at_int -> nexthop [ 2 ] ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\tdelay%ums,bandwidth%uKbps,mtu%u,hop%u,reliability%u,load%u"" , ( EXTRACT_32BITS ( & tlv_ptr . eigrp_tlv_at_int -> delay ) / 100 ) , EXTRACT_32BITS ( & tlv_ptr . eigrp_tlv_at_int -> bandwidth ) , EXTRACT_24BITS ( & tlv_ptr . eigrp_tlv_at_int -> mtu ) , tlv_ptr . eigrp_tlv_at_int -> hopcount , tlv_ptr . eigrp_tlv_at_int -> reliability , tlv_ptr . eigrp_tlv_at_int -> load ) ) ; break ; case EIGRP_TLV_AT_EXT : tlv_ptr . eigrp_tlv_at_ext = ( const struct eigrp_tlv_at_ext_t * ) tlv_tptr ; ND_PRINT ( ( ndo , ""\\n\\tCable-Range:%u-%u,nexthop:"" , EXTRACT_16BITS ( & tlv_ptr . eigrp_tlv_at_ext -> cable_start ) , EXTRACT_16BITS ( & tlv_ptr . eigrp_tlv_at_ext -> cable_end ) ) ) ; if ( EXTRACT_32BITS ( & tlv_ptr . eigrp_tlv_at_ext -> nexthop ) == 0 ) ND_PRINT ( ( ndo , ""self"" ) ) ; else ND_PRINT ( ( ndo , ""%u.%u"" , EXTRACT_16BITS ( & tlv_ptr . eigrp_tlv_at_ext -> nexthop ) , EXTRACT_16BITS ( & tlv_ptr . eigrp_tlv_at_ext -> nexthop [ 2 ] ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\torigin-router%u,origin-as%u,origin-proto%s,flags[0x%02x],tag0x%08x,metric%u"" , EXTRACT_32BITS ( tlv_ptr . eigrp_tlv_at_ext -> origin_router ) , EXTRACT_32BITS ( tlv_ptr . eigrp_tlv_at_ext -> origin_as ) , tok2str ( eigrp_ext_proto_id_values , ""unknown"" , tlv_ptr . eigrp_tlv_at_ext -> proto_id ) , tlv_ptr . eigrp_tlv_at_ext -> flags , EXTRACT_32BITS ( tlv_ptr . eigrp_tlv_at_ext -> tag ) , EXTRACT_16BITS ( tlv_ptr . eigrp_tlv_at_ext -> metric ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\tdelay%ums,bandwidth%uKbps,mtu%u,hop%u,reliability%u,load%u"" , ( EXTRACT_32BITS ( & tlv_ptr . eigrp_tlv_at_ext -> delay ) / 100 ) , EXTRACT_32BITS ( & tlv_ptr . eigrp_tlv_at_ext -> bandwidth ) , EXTRACT_24BITS ( & tlv_ptr . eigrp_tlv_at_ext -> mtu ) , tlv_ptr . eigrp_tlv_at_ext -> hopcount , tlv_ptr . eigrp_tlv_at_ext -> reliability , tlv_ptr . eigrp_tlv_at_ext -> load ) ) ; break ; case EIGRP_TLV_AUTH : case EIGRP_TLV_SEQ : case EIGRP_TLV_MCAST_SEQ : case EIGRP_TLV_IPX_INT : case EIGRP_TLV_IPX_EXT : default : if ( ndo -> ndo_vflag <= 1 ) print_unknown_data ( ndo , tlv_tptr , ""\\n\\t"" , tlv_tlen ) ; break ; } if ( ndo -> ndo_vflag > 1 ) print_unknown_data ( ndo , tptr + sizeof ( struct eigrp_tlv_header ) , ""\\n\\t"" , eigrp_tlv_len - sizeof ( struct eigrp_tlv_header ) ) ; tptr += eigrp_tlv_len ; tlen -= eigrp_tlv_len ; } return ; trunc : ND_PRINT ( ( ndo , ""\\n\\t\\tpacketexceededsnapshot"" ) ) ; } "," return ; } if ( len < sizeof ( struct eigrp_common_header ) ) { ND_PRINT ( ( ndo , ""EIGRP%s,length:%u(tooshort,<%u)"" , tok2str ( eigrp_opcode_values , ""unknown(%u)"" , eigrp_com_header -> opcode ) , len , ( u_int ) sizeof ( struct eigrp_common_header ) ) ) ; return ; } ) ) ; if ( eigrp_tlv_len < sizeof ( struct eigrp_tlv_header ) ) { ND_PRINT ( ( ndo , ""(tooshort,<%u)"" , ( u_int ) sizeof ( struct eigrp_tlv_header ) ) ) ; break ; } ) tlv_tptr ; if ( tlv_tlen < sizeof ( * tlv_ptr . eigrp_tlv_general_parm ) ) { ND_PRINT ( ( ndo , ""(tooshort,<%u)"" , ( u_int ) ( sizeof ( struct eigrp_tlv_header ) + sizeof ( * tlv_ptr . eigrp_tlv_general_parm ) ) ) ) ; break ; } ) tlv_tptr ; if ( tlv_tlen < sizeof ( * tlv_ptr . eigrp_tlv_sw_version ) ) { ND_PRINT ( ( ndo , ""(tooshort,<%u)"" , ( u_int ) ( sizeof ( struct eigrp_tlv_header ) + sizeof ( * tlv_ptr . eigrp_tlv_sw_version ) ) ) ) ; break ; } ) tlv_tptr ; if ( tlv_tlen < sizeof ( * tlv_ptr . eigrp_tlv_ip_int ) ) { ND_PRINT ( ( ndo , ""(tooshort,<%u)"" , ( u_int ) ( sizeof ( struct eigrp_tlv_header ) + sizeof ( * tlv_ptr . eigrp_tlv_ip_int ) ) ) ) ; break ; } ) tlv_tptr ; if ( tlv_tlen < sizeof ( * tlv_ptr . eigrp_tlv_ip_ext ) ) { ND_PRINT ( ( ndo , ""(tooshort,<%u)"" , ( u_int ) ( sizeof ( struct eigrp_tlv_header ) + sizeof ( * tlv_ptr . eigrp_tlv_ip_ext ) ) ) ) ; break ; } ) tlv_tptr ; if ( tlv_tlen < sizeof ( * tlv_ptr . eigrp_tlv_at_cable_setup ) ) { ND_PRINT ( ( ndo , ""(tooshort,<%u)"" , ( u_int ) ( sizeof ( struct eigrp_tlv_header ) + sizeof ( * tlv_ptr . eigrp_tlv_at_cable_setup ) ) ) ) ; break ; } ) tlv_tptr ; if ( tlv_tlen < sizeof ( * tlv_ptr . eigrp_tlv_at_int ) ) { ND_PRINT ( ( ndo , ""(tooshort,<%u)"" , ( u_int ) ( sizeof ( struct eigrp_tlv_header ) + sizeof ( * tlv_ptr . eigrp_tlv_at_int ) ) ) ) ; break ; } ) tlv_tptr ; if ( tlv_tlen < sizeof ( * tlv_ptr . eigrp_tlv_at_ext ) ) { ND_PRINT ( ( ndo , ""(tooshort,<%u)"" , ( u_int ) ( sizeof ( struct eigrp_tlv_header ) + sizeof ( * tlv_ptr . eigrp_tlv_at_ext ) ) ) ) ; break ; } ",the-tcpdump-group@tcpdump/de981e6070d168b58ec1bb0713ded77ed4ad87f4,CVE-2017-12901,https://github.com/the-tcpdump-group/tcpdump/commit/de981e6070d168b58ec1bb0713ded77ed4ad87f4,2017-09-14T06:29Z 147,CWE-119,"CWE-119 void * vpx_memalign ( size_t align , size_t size ) { void * addr , * x = NULL ; # if CONFIG_MEM_MANAGER int number_aau ; if ( vpx_mm_create_heap_memory ( ) < 0 ) { _P ( printf ( ""[vpx][mm]ERRORvpx_memalign()Couldn\'tcreatememoryforHeap.\\n"" ) ; ) } number_aau = ( ( size + align - 1 + ADDRESS_STORAGE_SIZE ) >> SHIFT_HMM_ADDR_ALIGN_UNIT ) + 1 ; addr = hmm_alloc ( & hmm_d , number_aau ) ; # else addr = VPX_MALLOC_L ( size + align - 1 + ADDRESS_STORAGE_SIZE ) ; # endif if ( addr ) { x = align_addr ( ( unsigned char * ) addr + ADDRESS_STORAGE_SIZE , ( int ) align ) ; ( ( size_t * ) x ) [ - 1 ] = ( size_t ) addr ; } return x ; } "," = NULL ; addr = malloc ( size + ADDRESS_STORAGE_SIZE ) ; if ( addr ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 148,CWE-20,"CWE-20 static int parse_exports_table ( long long * table_start ) { int res ; int indexes = SQUASHFS_LOOKUP_BLOCKS ( sBlk . s . inodes ) ; long long export_index_table [ indexes ] ; res = read_fs_bytes ( fd , sBlk . s . lookup_table_start , SQUASHFS_LOOKUP_BLOCK_BYTES ( sBlk . s . inodes ) , export_index_table ) ; if ( res == FALSE ) { ERROR ( ""parse_exports_table:failedtoreadexportindextable\\n"" ) ; return FALSE ; } SQUASHFS_INSWAP_LOOKUP_BLOCKS ( export_index_table , indexes ) ; * table_start = export_index_table [ 0 ] ; return TRUE ; } "," = SQUASHFS_LOOKUP_BLOCKS ( ( long long ) sBlk . s . inodes ) ; int length = SQUASHFS_LOOKUP_BLOCK_BYTES ( ( long long ) ; long long * export_index_table ; if ( length != ( * table_start - sBlk . s . lookup_table_start ) ) { ERROR ( ""parse_exports_table:Badinodecountinsuperblock\\n"" ) ; return FALSE ; } export_index_table = alloc_index_table ( indexes ) ; res = . lookup_table_start , length , export_index_table ) ; ",plougher@squashfs-tools/f95864afe8833fe3ad782d714b41378e860977b1,CVE-2015-4646,https://github.com/plougher/squashfs-tools/commit/f95864afe8833fe3ad782d714b41378e860977b1,2017-04-13T17:59Z 149,CWE-000,"CWE-000 static int devzvol_readdir ( struct vnode * dvp , struct uio * uiop , struct cred * cred , int * eofp , caller_context_t * ct_unused , int flags_unused ) { struct sdev_node * sdvp = VTOSDEV ( dvp ) ; char * ptr ; sdcmn_err13 ( ( ""zvreaddirof\'%s\'%s\'"" , sdvp -> sdev_path , sdvp -> sdev_name ) ) ; if ( strcmp ( sdvp -> sdev_path , ZVOL_DIR ) == 0 ) { struct vnode * vp ; rw_exit ( & sdvp -> sdev_contents ) ; ( void ) devname_lookup_func ( sdvp , ""dsk"" , & vp , cred , devzvol_create_dir , SDEV_VATTR ) ; VN_RELE ( vp ) ; ( void ) devname_lookup_func ( sdvp , ""rdsk"" , & vp , cred , devzvol_create_dir , SDEV_VATTR ) ; VN_RELE ( vp ) ; rw_enter ( & sdvp -> sdev_contents , RW_READER ) ; return ( devname_readdir_func ( dvp , uiop , cred , eofp , 0 ) ) ; } if ( uiop -> uio_offset == 0 ) devzvol_prunedir ( sdvp ) ; ptr = sdvp -> sdev_path + strlen ( ZVOL_DIR ) ; if ( ( strcmp ( ptr , ""/dsk"" ) == 0 ) || ( strcmp ( ptr , ""/rdsk"" ) == 0 ) ) { rw_exit ( & sdvp -> sdev_contents ) ; devzvol_create_pool_dirs ( dvp ) ; rw_enter ( & sdvp -> sdev_contents , RW_READER ) ; return ( devname_readdir_func ( dvp , uiop , cred , eofp , 0 ) ) ; } ptr = strchr ( ptr + 1 , '/' ) + 1 ; rw_exit ( & sdvp -> sdev_contents ) ; sdev_iter_datasets ( dvp , ZFS_IOC_DATASET_LIST_NEXT , ptr ) ; rw_enter ( & sdvp -> sdev_contents , RW_READER ) ; return ( devname_readdir_func ( dvp , uiop , cred , eofp , 0 ) ) ; } "," , '/' ) ; if ( ptr == NULL ) return ( ENOENT ) ; ptr ++ ; rw_exit ( ",illumos@illumos-gate/d65686849024838243515b5c40ae2c479460b4b5,CVE-2014-9491,https://github.com/illumos/illumos-gate/commit/d65686849024838243515b5c40ae2c479460b4b5,2015-01-20T15:59Z 150,CWE-362,"CWE-362 static int ext4_split_unwritten_extents ( handle_t * handle , struct inode * inode , struct ext4_map_blocks * map , struct ext4_ext_path * path , int flags ) { ext4_lblk_t eof_block ; ext4_lblk_t ee_block ; struct ext4_extent * ex ; unsigned int ee_len ; int split_flag = 0 , depth ; ext_debug ( ""ext4_split_unwritten_extents:inode%lu,logical"" ""block%llu,max_blocks%u\\n"" , inode -> i_ino , ( unsigned long long ) map -> m_lblk , map -> m_len ) ; eof_block = ( inode -> i_size + inode -> i_sb -> s_blocksize - 1 ) >> inode -> i_sb -> s_blocksize_bits ; if ( eof_block < map -> m_lblk + map -> m_len ) eof_block = map -> m_lblk + map -> m_len ; depth = ext_depth ( inode ) ; ex = path [ depth ] . p_ext ; ee_block = le32_to_cpu ( ex -> ee_block ) ; ee_len = ext4_ext_get_actual_len ( ex ) ; split_flag |= ee_block + ee_len <= eof_block ? EXT4_EXT_MAY_ZEROOUT : 0 ; split_flag |= EXT4_EXT_MARK_UNINIT2 ; flags |= EXT4_GET_BLOCKS_PRE_IO ; return ext4_split_extent ( handle , inode , path , map , split_flag , flags ) ; } "," |= EXT4_EXT_MARK_UNINIT2 ; if ( flags & EXT4_GET_BLOCKS_CONVERT ) split_flag |= EXT4_EXT_DATA_VALID2 ; ",torvalds@linux/dee1f973ca341c266229faa5a1a5bb268bed3531,CVE-2012-4508,https://github.com/torvalds/linux/commit/dee1f973ca341c266229faa5a1a5bb268bed3531,2012-12-21T11:47Z 151,CWE-285,"CWE-285 int ceph_set_acl ( struct inode * inode , struct posix_acl * acl , int type ) { int ret = 0 , size = 0 ; const char * name = NULL ; char * value = NULL ; struct iattr newattrs ; umode_t new_mode = inode -> i_mode , old_mode = inode -> i_mode ; switch ( type ) { case ACL_TYPE_ACCESS : name = XATTR_NAME_POSIX_ACL_ACCESS ; if ( acl ) { ret = posix_acl_equiv_mode ( acl , & new_mode ) ; if ( ret < 0 ) goto out ; if ( ret == 0 ) acl = NULL ; } break ; case ACL_TYPE_DEFAULT : if ( ! S_ISDIR ( inode -> i_mode ) ) { ret = acl ? - EINVAL : 0 ; goto out ; } name = XATTR_NAME_POSIX_ACL_DEFAULT ; break ; default : ret = - EINVAL ; goto out ; } if ( acl ) { size = posix_acl_xattr_size ( acl -> a_count ) ; value = kmalloc ( size , GFP_NOFS ) ; if ( ! value ) { ret = - ENOMEM ; goto out ; } ret = posix_acl_to_xattr ( & init_user_ns , acl , value , size ) ; if ( ret < 0 ) goto out_free ; } if ( new_mode != old_mode ) { newattrs . ia_mode = new_mode ; newattrs . ia_valid = ATTR_MODE ; ret = __ceph_setattr ( inode , & newattrs ) ; if ( ret ) goto out_free ; } ret = __ceph_setxattr ( inode , name , value , size , 0 ) ; if ( ret ) { if ( new_mode != old_mode ) { newattrs . ia_mode = old_mode ; newattrs . ia_valid = ATTR_MODE ; __ceph_setattr ( inode , & newattrs ) ; } goto out_free ; } ceph_set_cached_acl ( inode , type , acl ) ; out_free : kfree ( value ) ; out : return ret ; } "," { ret = posix_acl_update_mode ( inode , & new_mode , & acl ) ; if ( ret ) goto out ; } break ",torvalds@linux/073931017b49d9458aa351605b43a7e34598caef,CVE-2016-7097,https://github.com/torvalds/linux/commit/073931017b49d9458aa351605b43a7e34598caef,2016-10-16T21:59Z 152,CWE-611,"CWE-611 static const char * cmd_hash_engine ( cmd_parms * cmd , void * _dcfg , const char * p1 ) { directory_config * dcfg = ( directory_config * ) _dcfg ; if ( dcfg == NULL ) return NULL ; if ( strcasecmp ( p1 , ""on"" ) == 0 ) { dcfg -> hash_is_enabled = HASH_ENABLED ; dcfg -> hash_enforcement = HASH_ENABLED ; } else if ( strcasecmp ( p1 , ""off"" ) == 0 ) { dcfg -> hash_is_enabled = HASH_DISABLED ; dcfg -> hash_enforcement = HASH_DISABLED ; } else return apr_psprintf ( cmd -> pool , ""ModSecurity:InvalidvalueforSecRuleEngine:%s"" , p1 ) ; return NULL ; } "," -> pool , ""ModSecurity:InvalidvalueforSexHashEngine:%s"" , p1 ) ",SpiderLabs@ModSecurity/d4d80b38aa85eccb26e3c61b04d16e8ca5de76fe,CVE-2013-1915,https://github.com/SpiderLabs/ModSecurity/commit/d4d80b38aa85eccb26e3c61b04d16e8ca5de76fe,2013-04-25T23:55Z 153,CWE-416,"CWE-416 int inet6_sk_rebuild_header ( struct sock * sk ) { struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct dst_entry * dst ; dst = __sk_dst_check ( sk , np -> dst_cookie ) ; if ( ! dst ) { struct inet_sock * inet = inet_sk ( sk ) ; struct in6_addr * final_p , final ; struct flowi6 fl6 ; memset ( & fl6 , 0 , sizeof ( fl6 ) ) ; fl6 . flowi6_proto = sk -> sk_protocol ; fl6 . daddr = sk -> sk_v6_daddr ; fl6 . saddr = np -> saddr ; fl6 . flowlabel = np -> flow_label ; fl6 . flowi6_oif = sk -> sk_bound_dev_if ; fl6 . flowi6_mark = sk -> sk_mark ; fl6 . fl6_dport = inet -> inet_dport ; 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 ) ) { sk -> sk_route_caps = 0 ; sk -> sk_err_soft = - PTR_ERR ( dst ) ; return PTR_ERR ( dst ) ; } __ip6_dst_store ( sk , dst , NULL , NULL ) ; } return 0 ; } "," ) ) ; rcu_read_lock ( ) ; & fl6 , rcu_dereference ( np -> opt ) , & final ) ; rcu_read_unlock ( ) ; dst ",torvalds@linux/45f6fad84cc305103b28d73482b344d7f5b76f39,CVE-2016-3841,https://github.com/torvalds/linux/commit/45f6fad84cc305103b28d73482b344d7f5b76f39,2016-08-06T20:59Z 154,CWE-119,"CWE-119 static int loadImage ( TIFF * in , struct image_data * image , struct dump_opts * dump , unsigned char * * read_ptr ) { uint32 i ; float xres = 0.0 , yres = 0.0 ; uint16 nstrips = 0 , ntiles = 0 , planar = 0 ; uint16 bps = 0 , spp = 0 , res_unit = 0 ; uint16 orientation = 0 ; uint16 input_compression = 0 , input_photometric = 0 ; uint16 subsampling_horiz , subsampling_vert ; uint32 width = 0 , length = 0 ; uint32 stsize = 0 , tlsize = 0 , buffsize = 0 , scanlinesize = 0 ; uint32 tw = 0 , tl = 0 ; uint32 tile_rowsize = 0 ; unsigned char * read_buff = NULL ; unsigned char * new_buff = NULL ; int readunit = 0 ; static uint32 prev_readsize = 0 ; TIFFGetFieldDefaulted ( in , TIFFTAG_BITSPERSAMPLE , & bps ) ; TIFFGetFieldDefaulted ( in , TIFFTAG_SAMPLESPERPIXEL , & spp ) ; TIFFGetFieldDefaulted ( in , TIFFTAG_PLANARCONFIG , & planar ) ; TIFFGetFieldDefaulted ( in , TIFFTAG_ORIENTATION , & orientation ) ; if ( ! TIFFGetFieldDefaulted ( in , TIFFTAG_PHOTOMETRIC , & input_photometric ) ) TIFFError ( ""loadImage"" , ""ImagelacksPhotometricinterpreationtag"" ) ; if ( ! TIFFGetField ( in , TIFFTAG_IMAGEWIDTH , & width ) ) TIFFError ( ""loadimage"" , ""Imagelacksimagewidthtag"" ) ; if ( ! TIFFGetField ( in , TIFFTAG_IMAGELENGTH , & length ) ) TIFFError ( ""loadimage"" , ""Imagelacksimagelengthtag"" ) ; TIFFGetFieldDefaulted ( in , TIFFTAG_XRESOLUTION , & xres ) ; TIFFGetFieldDefaulted ( in , TIFFTAG_YRESOLUTION , & yres ) ; if ( ! TIFFGetFieldDefaulted ( in , TIFFTAG_RESOLUTIONUNIT , & res_unit ) ) res_unit = RESUNIT_INCH ; if ( ! TIFFGetField ( in , TIFFTAG_COMPRESSION , & input_compression ) ) input_compression = COMPRESSION_NONE ; # ifdef DEBUG2 char compressionid [ 16 ] ; switch ( input_compression ) { case COMPRESSION_NONE : strcpy ( compressionid , ""None/dump"" ) ; break ; case COMPRESSION_CCITTRLE : strcpy ( compressionid , ""HuffmanRLE"" ) ; break ; case COMPRESSION_CCITTFAX3 : strcpy ( compressionid , ""Group3Fax"" ) ; break ; case COMPRESSION_CCITTFAX4 : strcpy ( compressionid , ""Group4Fax"" ) ; break ; case COMPRESSION_LZW : strcpy ( compressionid , ""LZW"" ) ; break ; case COMPRESSION_OJPEG : strcpy ( compressionid , ""OldJpeg"" ) ; break ; case COMPRESSION_JPEG : strcpy ( compressionid , ""NewJpeg"" ) ; break ; case COMPRESSION_NEXT : strcpy ( compressionid , ""NextRLE"" ) ; break ; case COMPRESSION_CCITTRLEW : strcpy ( compressionid , ""CITTRLEW"" ) ; break ; case COMPRESSION_PACKBITS : strcpy ( compressionid , ""MacPackbits"" ) ; break ; case COMPRESSION_THUNDERSCAN : strcpy ( compressionid , ""Thunderscan"" ) ; break ; case COMPRESSION_IT8CTPAD : strcpy ( compressionid , ""IT8padded"" ) ; break ; case COMPRESSION_IT8LW : strcpy ( compressionid , ""IT8RLE"" ) ; break ; case COMPRESSION_IT8MP : strcpy ( compressionid , ""IT8mono"" ) ; break ; case COMPRESSION_IT8BL : strcpy ( compressionid , ""IT8lineart"" ) ; break ; case COMPRESSION_PIXARFILM : strcpy ( compressionid , ""Pixar10bit"" ) ; break ; case COMPRESSION_PIXARLOG : strcpy ( compressionid , ""Pixar11bit"" ) ; break ; case COMPRESSION_DEFLATE : strcpy ( compressionid , ""Deflate"" ) ; break ; case COMPRESSION_ADOBE_DEFLATE : strcpy ( compressionid , ""Adobedeflate"" ) ; break ; default : strcpy ( compressionid , ""None/unknown"" ) ; break ; } TIFFError ( ""loadImage"" , ""Inputcompression%s"" , compressionid ) ; # endif scanlinesize = TIFFScanlineSize ( in ) ; image -> bps = bps ; image -> spp = spp ; image -> planar = planar ; image -> width = width ; image -> length = length ; image -> xres = xres ; image -> yres = yres ; image -> res_unit = res_unit ; image -> compression = input_compression ; image -> photometric = input_photometric ; # ifdef DEBUG2 char photometricid [ 12 ] ; switch ( input_photometric ) { case PHOTOMETRIC_MINISWHITE : strcpy ( photometricid , ""MinIsWhite"" ) ; break ; case PHOTOMETRIC_MINISBLACK : strcpy ( photometricid , ""MinIsBlack"" ) ; break ; case PHOTOMETRIC_RGB : strcpy ( photometricid , ""RGB"" ) ; break ; case PHOTOMETRIC_PALETTE : strcpy ( photometricid , ""Palette"" ) ; break ; case PHOTOMETRIC_MASK : strcpy ( photometricid , ""Mask"" ) ; break ; case PHOTOMETRIC_SEPARATED : strcpy ( photometricid , ""Separated"" ) ; break ; case PHOTOMETRIC_YCBCR : strcpy ( photometricid , ""YCBCR"" ) ; break ; case PHOTOMETRIC_CIELAB : strcpy ( photometricid , ""CIELab"" ) ; break ; case PHOTOMETRIC_ICCLAB : strcpy ( photometricid , ""ICCLab"" ) ; break ; case PHOTOMETRIC_ITULAB : strcpy ( photometricid , ""ITULab"" ) ; break ; case PHOTOMETRIC_LOGL : strcpy ( photometricid , ""LogL"" ) ; break ; case PHOTOMETRIC_LOGLUV : strcpy ( photometricid , ""LOGLuv"" ) ; break ; default : strcpy ( photometricid , ""Unknown"" ) ; break ; } TIFFError ( ""loadImage"" , ""Inputphotometricinterpretation%s"" , photometricid ) ; # endif image -> orientation = orientation ; switch ( orientation ) { case 0 : case ORIENTATION_TOPLEFT : image -> adjustments = 0 ; break ; case ORIENTATION_TOPRIGHT : image -> adjustments = MIRROR_HORIZ ; break ; case ORIENTATION_BOTRIGHT : image -> adjustments = ROTATECW_180 ; break ; case ORIENTATION_BOTLEFT : image -> adjustments = MIRROR_VERT ; break ; case ORIENTATION_LEFTTOP : image -> adjustments = MIRROR_VERT | ROTATECW_90 ; break ; case ORIENTATION_RIGHTTOP : image -> adjustments = ROTATECW_90 ; break ; case ORIENTATION_RIGHTBOT : image -> adjustments = MIRROR_VERT | ROTATECW_270 ; break ; case ORIENTATION_LEFTBOT : image -> adjustments = ROTATECW_270 ; break ; default : image -> adjustments = 0 ; image -> orientation = ORIENTATION_TOPLEFT ; } if ( ( bps == 0 ) || ( spp == 0 ) ) { TIFFError ( ""loadImage"" , ""Invalidsamplesperpixel(%d)orbitspersample(%d)"" , spp , bps ) ; return ( - 1 ) ; } if ( TIFFIsTiled ( in ) ) { readunit = TILE ; tlsize = TIFFTileSize ( in ) ; ntiles = TIFFNumberOfTiles ( in ) ; TIFFGetField ( in , TIFFTAG_TILEWIDTH , & tw ) ; TIFFGetField ( in , TIFFTAG_TILELENGTH , & tl ) ; tile_rowsize = TIFFTileRowSize ( in ) ; if ( ntiles == 0 || tlsize == 0 || tile_rowsize == 0 ) { TIFFError ( ""loadImage"" , ""Fileappearstobetiled,butthenumberoftiles,tilesize,ortilerowsizeiszero."" ) ; exit ( - 1 ) ; } buffsize = tlsize * ntiles ; if ( tlsize != ( buffsize / ntiles ) ) { TIFFError ( ""loadImage"" , ""Integeroverflowwhencalculatingbuffersize"" ) ; exit ( - 1 ) ; } if ( buffsize < ( uint32 ) ( ntiles * tl * tile_rowsize ) ) { buffsize = ntiles * tl * tile_rowsize ; if ( ntiles != ( buffsize / tl / tile_rowsize ) ) { TIFFError ( ""loadImage"" , ""Integeroverflowwhencalculatingbuffersize"" ) ; exit ( - 1 ) ; } # ifdef DEBUG2 TIFFError ( ""loadImage"" , ""Tilesize%uistoosmall,usingntiles*tilelength*tilerowsize%lu"" , tlsize , ( unsigned long ) buffsize ) ; # endif } if ( dump -> infile != NULL ) dump_info ( dump -> infile , dump -> format , """" , ""Tilesize:%u,NumberofTiles:%u,Tilerowsize:%u"" , tlsize , ntiles , tile_rowsize ) ; } else { uint32 buffsize_check ; readunit = STRIP ; TIFFGetFieldDefaulted ( in , TIFFTAG_ROWSPERSTRIP , & rowsperstrip ) ; stsize = TIFFStripSize ( in ) ; nstrips = TIFFNumberOfStrips ( in ) ; if ( nstrips == 0 || stsize == 0 ) { TIFFError ( ""loadImage"" , ""Fileappearstobestriped,butthenumberofstipesorstripesizeiszero."" ) ; exit ( - 1 ) ; } buffsize = stsize * nstrips ; if ( stsize != ( buffsize / nstrips ) ) { TIFFError ( ""loadImage"" , ""Integeroverflowwhencalculatingbuffersize"" ) ; exit ( - 1 ) ; } buffsize_check = ( ( length * width * spp * bps ) + 7 ) ; if ( length != ( ( buffsize_check - 7 ) / width / spp / bps ) ) { TIFFError ( ""loadImage"" , ""Integeroverflowdetected."" ) ; exit ( - 1 ) ; } if ( buffsize < ( uint32 ) ( ( ( length * width * spp * bps ) + 7 ) / 8 ) ) { buffsize = ( ( length * width * spp * bps ) + 7 ) / 8 ; # ifdef DEBUG2 TIFFError ( ""loadImage"" , ""Stripsize%uistoosmall,usingimagelength*width*spp*bps/8=%lu"" , stsize , ( unsigned long ) buffsize ) ; # endif } if ( dump -> infile != NULL ) dump_info ( dump -> infile , dump -> format , """" , ""Stripsize:%u,NumberofStrips:%u,RowsperStrip:%u,Scanlinesize:%u"" , stsize , nstrips , rowsperstrip , scanlinesize ) ; } if ( input_compression == COMPRESSION_JPEG ) { jpegcolormode = JPEGCOLORMODE_RGB ; TIFFSetField ( in , TIFFTAG_JPEGCOLORMODE , JPEGCOLORMODE_RGB ) ; } else { if ( input_photometric == PHOTOMETRIC_YCBCR ) { TIFFGetFieldDefaulted ( in , TIFFTAG_YCBCRSUBSAMPLING , & subsampling_horiz , & subsampling_vert ) ; if ( subsampling_horiz != 1 || subsampling_vert != 1 ) { TIFFError ( ""loadImage"" , ""Can\'tcopy/convertsubsampledimagewithsubsampling%dhoriz%dvert"" , subsampling_horiz , subsampling_vert ) ; return ( - 1 ) ; } } } read_buff = * read_ptr ; if ( ! read_buff ) read_buff = ( unsigned char * ) _TIFFmalloc ( buffsize + 3 ) ; else { if ( prev_readsize < buffsize ) { new_buff = _TIFFrealloc ( read_buff , buffsize + 3 ) ; if ( ! new_buff ) { free ( read_buff ) ; read_buff = ( unsigned char * ) _TIFFmalloc ( buffsize + 3 ) ; } else read_buff = new_buff ; } } if ( ! read_buff ) { TIFFError ( ""loadImage"" , ""Unabletoallocate/reallocatereadbuffer"" ) ; return ( - 1 ) ; } read_buff [ buffsize ] = 0 ; read_buff [ buffsize + 1 ] = 0 ; read_buff [ buffsize + 2 ] = 0 ; prev_readsize = buffsize ; * read_ptr = read_buff ; switch ( readunit ) { case STRIP : if ( planar == PLANARCONFIG_CONTIG ) { if ( ! ( readContigStripsIntoBuffer ( in , read_buff ) ) ) { TIFFError ( ""loadImage"" , ""Unabletoreadcontiguousstripsintobuffer"" ) ; return ( - 1 ) ; } } else { if ( ! ( readSeparateStripsIntoBuffer ( in , read_buff , length , width , spp , dump ) ) ) { TIFFError ( ""loadImage"" , ""Unabletoreadseparatestripsintobuffer"" ) ; return ( - 1 ) ; } } break ; case TILE : if ( planar == PLANARCONFIG_CONTIG ) { if ( ! ( readContigTilesIntoBuffer ( in , read_buff , length , width , tw , tl , spp , bps ) ) ) { TIFFError ( ""loadImage"" , ""Unabletoreadcontiguoustilesintobuffer"" ) ; return ( - 1 ) ; } } else { if ( ! ( readSeparateTilesIntoBuffer ( in , read_buff , length , width , tw , tl , spp , bps ) ) ) { TIFFError ( ""loadImage"" , ""Unabletoreadseparatetilesintobuffer"" ) ; return ( - 1 ) ; } } break ; default : TIFFError ( ""loadImage"" , ""Unsupportedimagefileformat"" ) ; return ( - 1 ) ; break ; } if ( ( dump -> infile != NULL ) && ( dump -> level == 2 ) ) { dump_info ( dump -> infile , dump -> format , ""loadImage"" , ""Imagewidth%d,length%d,Rawimagedata,%4dbytes"" , width , length , buffsize ) ; dump_info ( dump -> infile , dump -> format , """" , ""Bitspersample%d,Samplesperpixel%d"" , bps , spp ) ; for ( i = 0 ; i < length ; i ++ ) dump_buffer ( dump -> infile , dump -> format , 1 , scanlinesize , i , read_buff + ( i * scanlinesize ) ) ; } return ( 0 ) ; } "," = 0.0 ; uint32 nstrips = 0 , ntiles = 0 ; uint16 planar = 0 ! read_buff ) { if ( buffsize > 0xFFFFFFFFU - 3 ) { TIFFError ( ""loadImage"" , ""Unabletoallocate/reallocatereadbuffer"" ) ; return ( - 1 ) ; } 3 ) ; } buffsize ) { if ( buffsize > 0xFFFFFFFFU - 3 ) { TIFFError ( ""loadImage"" , ""Unabletoallocate/reallocatereadbuffer"" ) ; return ( - 1 ) ; } ",vadz@libtiff/83a4b92815ea04969d494416eaae3d4c6b338e4a,CVE-2016-9537,https://github.com/vadz/libtiff/commit/83a4b92815ea04969d494416eaae3d4c6b338e4a,2016-11-22T19:59Z 155,CWE-119,"CWE-119 static int parse_stream_params ( struct VpxEncoderConfig * global , struct stream_state * stream , char * * argv ) { char * * argi , * * argj ; struct arg arg ; static const arg_def_t * * ctrl_args = no_args ; static const int * ctrl_args_map = NULL ; struct stream_config * config = & stream -> config ; int eos_mark_found = 0 ; if ( 0 ) { # if CONFIG_VP8_ENCODER } else if ( strcmp ( global -> codec -> name , ""vp8"" ) == 0 ) { ctrl_args = vp8_args ; ctrl_args_map = vp8_arg_ctrl_map ; # endif # if CONFIG_VP9_ENCODER } else if ( strcmp ( global -> codec -> name , ""vp9"" ) == 0 ) { ctrl_args = vp9_args ; ctrl_args_map = vp9_arg_ctrl_map ; # endif } for ( argi = argj = argv ; ( * argj = * argi ) ; argi += arg . argv_step ) { arg . argv_step = 1 ; if ( eos_mark_found ) { argj ++ ; continue ; } else if ( ! strcmp ( * argj , ""--"" ) ) { eos_mark_found = 1 ; continue ; } if ( 0 ) { } else if ( arg_match ( & arg , & outputfile , argi ) ) { config -> out_fn = arg . val ; } else if ( arg_match ( & arg , & fpf_name , argi ) ) { config -> stats_fn = arg . val ; } else if ( arg_match ( & arg , & use_ivf , argi ) ) { config -> write_webm = 0 ; } else if ( arg_match ( & arg , & threads , argi ) ) { config -> cfg . g_threads = arg_parse_uint ( & arg ) ; } else if ( arg_match ( & arg , & profile , argi ) ) { config -> cfg . g_profile = arg_parse_uint ( & arg ) ; } else if ( arg_match ( & arg , & width , argi ) ) { config -> cfg . g_w = arg_parse_uint ( & arg ) ; } else if ( arg_match ( & arg , & height , argi ) ) { config -> cfg . g_h = arg_parse_uint ( & arg ) ; } else if ( arg_match ( & arg , & stereo_mode , argi ) ) { config -> stereo_fmt = arg_parse_enum_or_int ( & arg ) ; } else if ( arg_match ( & arg , & timebase , argi ) ) { config -> cfg . g_timebase = arg_parse_rational ( & arg ) ; validate_positive_rational ( arg . name , & config -> cfg . g_timebase ) ; } else if ( arg_match ( & arg , & error_resilient , argi ) ) { config -> cfg . g_error_resilient = arg_parse_uint ( & arg ) ; } else if ( arg_match ( & arg , & lag_in_frames , argi ) ) { config -> cfg . g_lag_in_frames = arg_parse_uint ( & arg ) ; if ( global -> deadline == VPX_DL_REALTIME && config -> cfg . g_lag_in_frames != 0 ) { warn ( ""non-zero%soptionignoredinrealtimemode.\\n"" , arg . name ) ; config -> cfg . g_lag_in_frames = 0 ; } } else if ( arg_match ( & arg , & dropframe_thresh , argi ) ) { config -> cfg . rc_dropframe_thresh = arg_parse_uint ( & arg ) ; } else if ( arg_match ( & arg , & resize_allowed , argi ) ) { config -> cfg . rc_resize_allowed = arg_parse_uint ( & arg ) ; } else if ( arg_match ( & arg , & resize_up_thresh , argi ) ) { config -> cfg . rc_resize_up_thresh = arg_parse_uint ( & arg ) ; } else if ( arg_match ( & arg , & resize_down_thresh , argi ) ) { config -> cfg . rc_resize_down_thresh = arg_parse_uint ( & arg ) ; } else if ( arg_match ( & arg , & end_usage , argi ) ) { config -> cfg . rc_end_usage = arg_parse_enum_or_int ( & arg ) ; } else if ( arg_match ( & arg , & target_bitrate , argi ) ) { config -> cfg . rc_target_bitrate = arg_parse_uint ( & arg ) ; } else if ( arg_match ( & arg , & min_quantizer , argi ) ) { config -> cfg . rc_min_quantizer = arg_parse_uint ( & arg ) ; } else if ( arg_match ( & arg , & max_quantizer , argi ) ) { config -> cfg . rc_max_quantizer = arg_parse_uint ( & arg ) ; } else if ( arg_match ( & arg , & undershoot_pct , argi ) ) { config -> cfg . rc_undershoot_pct = arg_parse_uint ( & arg ) ; } else if ( arg_match ( & arg , & overshoot_pct , argi ) ) { config -> cfg . rc_overshoot_pct = arg_parse_uint ( & arg ) ; } else if ( arg_match ( & arg , & buf_sz , argi ) ) { config -> cfg . rc_buf_sz = arg_parse_uint ( & arg ) ; } else if ( arg_match ( & arg , & buf_initial_sz , argi ) ) { config -> cfg . rc_buf_initial_sz = arg_parse_uint ( & arg ) ; } else if ( arg_match ( & arg , & buf_optimal_sz , argi ) ) { config -> cfg . rc_buf_optimal_sz = arg_parse_uint ( & arg ) ; } else if ( arg_match ( & arg , & bias_pct , argi ) ) { config -> cfg . rc_2pass_vbr_bias_pct = arg_parse_uint ( & arg ) ; if ( global -> passes < 2 ) warn ( ""option%signoredinone-passmode.\\n"" , arg . name ) ; } else if ( arg_match ( & arg , & minsection_pct , argi ) ) { config -> cfg . rc_2pass_vbr_minsection_pct = arg_parse_uint ( & arg ) ; if ( global -> passes < 2 ) warn ( ""option%signoredinone-passmode.\\n"" , arg . name ) ; } else if ( arg_match ( & arg , & maxsection_pct , argi ) ) { config -> cfg . rc_2pass_vbr_maxsection_pct = arg_parse_uint ( & arg ) ; if ( global -> passes < 2 ) warn ( ""option%signoredinone-passmode.\\n"" , arg . name ) ; } else if ( arg_match ( & arg , & kf_min_dist , argi ) ) { config -> cfg . kf_min_dist = arg_parse_uint ( & arg ) ; } else if ( arg_match ( & arg , & kf_max_dist , argi ) ) { config -> cfg . kf_max_dist = arg_parse_uint ( & arg ) ; config -> have_kf_max_dist = 1 ; } else if ( arg_match ( & arg , & kf_disabled , argi ) ) { config -> cfg . kf_mode = VPX_KF_DISABLED ; } else { int i , match = 0 ; for ( i = 0 ; ctrl_args [ i ] ; i ++ ) { if ( arg_match ( & arg , ctrl_args [ i ] , argi ) ) { int j ; match = 1 ; for ( j = 0 ; j < config -> arg_ctrl_cnt ; j ++ ) if ( config -> arg_ctrls [ j ] [ 0 ] == ctrl_args_map [ i ] ) break ; assert ( j < ARG_CTRL_CNT_MAX ) ; if ( j < ARG_CTRL_CNT_MAX ) { config -> arg_ctrls [ j ] [ 0 ] = ctrl_args_map [ i ] ; config -> arg_ctrls [ j ] [ 1 ] = arg_parse_enum_or_int ( & arg ) ; if ( j == config -> arg_ctrl_cnt ) config -> arg_ctrl_cnt ++ ; } } } if ( ! match ) argj ++ ; } } return eos_mark_found ; } "," = 0 ; # if CONFIG_VP9_HIGHBITDEPTH int test_16bit_internal = 0 ; # endif ; # endif # if CONFIG_VP10_ENCODER } else if ( strcmp ( global -> codec -> name , ""vp10"" ) == 0 ) { ctrl_args = vp10_args ; ctrl_args_map = vp10_arg_ctrl_map ; # endif } if ( arg_match ( & arg , & outputfile , argi ) ) { config -> out_fn = arg . val ; } else if ( arg_match ( & arg , & fpf_name , argi ) ) { config -> stats_fn = arg . val ; # if CONFIG_FP_MB_STATS } else if ( arg_match ( & arg , & fpmbf_name , argi ) ) { config -> fpmb_stats_fn = arg . val ; # endif } else if ( arg_match ( & arg , & use_webm , argi ) ) { # if CONFIG_WEBM_IO config -> write_webm = 1 ; # else die ( ""Error:--webmspecifiedbutwebmisdisabled."" ) ; # endif } else if ( arg_match ( & arg , & use_ivf , argi ) ) { config -> write_webm = 0 ; } else arg ) ; # if CONFIG_VP9_HIGHBITDEPTH } else if ( arg_match ( & arg , & bitdeptharg , argi ) ) { config -> cfg . g_bit_depth = arg_parse_enum_or_int ( & arg ) ; } else if ( arg_match ( & arg , & inbitdeptharg , argi ) ) { config -> cfg . g_input_bit_depth = arg_parse_uint ( & arg ) ; # endif # if CONFIG_WEBM_IO arg ) ; # endif arg , & resize_width , argi ) ) { config -> cfg . rc_scaled_width = arg_parse_uint ( & arg ) ; } else if ( arg_match ( & arg , & resize_height , argi ) ) { config -> cfg . rc_scaled_height = arg_parse_uint ( & arg ) ; } else if ( arg_match ( & arg , & = VPX_KF_DISABLED ; # if CONFIG_VP9_HIGHBITDEPTH } else if ( arg_match ( & arg , & test16bitinternalarg , argi ) ) { if ( strcmp ( global -> codec -> name , ""vp9"" ) == 0 || strcmp ( global -> codec -> name , ""vp10"" ) == 0 ) { test_16bit_internal = 1 ; } # endif ) if ( ctrl_args_map != NULL && ( j < ( int ) ; if ( ctrl_args_map != NULL && j < ( int ) ARG_CTRL_CNT_MAX ) { ; } } # if CONFIG_VP9_HIGHBITDEPTH if ( strcmp ( global -> codec -> name , ""vp9"" ) == 0 || strcmp ( global -> codec -> name , ""vp10"" ) == 0 ) { config -> use_16bit_internal = test_16bit_internal | ( config -> cfg . g_profile > 1 ) ; } # endif ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 156,CWE-264,"CWE-264 static int server_input_global_request ( int type , u_int32_t seq , void * ctxt ) { char * rtype ; int want_reply ; int r , success = 0 , allocated_listen_port = 0 ; struct sshbuf * resp = NULL ; rtype = packet_get_string ( NULL ) ; want_reply = packet_get_char ( ) ; debug ( ""server_input_global_request:rtype%swant_reply%d"" , rtype , want_reply ) ; if ( strcmp ( rtype , ""tcpip-forward"" ) == 0 ) { struct passwd * pw ; struct Forward fwd ; pw = the_authctxt -> pw ; if ( pw == NULL || ! the_authctxt -> valid ) fatal ( ""server_input_global_request:no/invaliduser"" ) ; memset ( & fwd , 0 , sizeof ( fwd ) ) ; fwd . listen_host = packet_get_string ( NULL ) ; fwd . listen_port = ( u_short ) packet_get_int ( ) ; debug ( ""server_input_global_request:tcpip-forwardlisten%sport%d"" , fwd . listen_host , fwd . listen_port ) ; if ( ( options . allow_tcp_forwarding & FORWARD_REMOTE ) == 0 || no_port_forwarding_flag || options . disable_forwarding || ( ! want_reply && fwd . listen_port == 0 ) || ( fwd . listen_port != 0 && ! bind_permitted ( fwd . listen_port , pw -> pw_uid ) ) ) { success = 0 ; packet_send_debug ( ""Serverhasdisabledportforwarding."" ) ; } else { success = channel_setup_remote_fwd_listener ( & fwd , & allocated_listen_port , & options . fwd_opts ) ; } free ( fwd . listen_host ) ; if ( ( resp = sshbuf_new ( ) ) == NULL ) fatal ( ""%s:sshbuf_new"" , __func__ ) ; if ( allocated_listen_port != 0 && ( r = sshbuf_put_u32 ( resp , allocated_listen_port ) ) != 0 ) fatal ( ""%s:sshbuf_put_u32:%s"" , __func__ , ssh_err ( r ) ) ; } else if ( strcmp ( rtype , ""cancel-tcpip-forward"" ) == 0 ) { struct Forward fwd ; memset ( & fwd , 0 , sizeof ( fwd ) ) ; fwd . listen_host = packet_get_string ( NULL ) ; fwd . listen_port = ( u_short ) packet_get_int ( ) ; debug ( ""%s:cancel-tcpip-forwardaddr%sport%d"" , __func__ , fwd . listen_host , fwd . listen_port ) ; success = channel_cancel_rport_listener ( & fwd ) ; free ( fwd . listen_host ) ; } else if ( strcmp ( rtype , ""streamlocal-forward@openssh.com"" ) == 0 ) { struct Forward fwd ; memset ( & fwd , 0 , sizeof ( fwd ) ) ; fwd . listen_path = packet_get_string ( NULL ) ; debug ( ""server_input_global_request:streamlocal-forwardlistenpath%s"" , fwd . listen_path ) ; if ( ( options . allow_streamlocal_forwarding & FORWARD_REMOTE ) == 0 || no_port_forwarding_flag || options . disable_forwarding ) { success = 0 ; packet_send_debug ( ""Serverhasdisabledportforwarding."" ) ; } else { success = channel_setup_remote_fwd_listener ( & fwd , NULL , & options . fwd_opts ) ; } free ( fwd . listen_path ) ; } else if ( strcmp ( rtype , ""cancel-streamlocal-forward@openssh.com"" ) == 0 ) { struct Forward fwd ; memset ( & fwd , 0 , sizeof ( fwd ) ) ; fwd . listen_path = packet_get_string ( NULL ) ; debug ( ""%s:cancel-streamlocal-forwardpath%s"" , __func__ , fwd . listen_path ) ; success = channel_cancel_rport_listener ( & fwd ) ; free ( fwd . listen_path ) ; } else if ( strcmp ( rtype , ""no-more-sessions@openssh.com"" ) == 0 ) { no_more_sessions = 1 ; success = 1 ; } else if ( strcmp ( rtype , ""hostkeys-prove-00@openssh.com"" ) == 0 ) { success = server_input_hostkeys_prove ( & resp ) ; } if ( want_reply ) { packet_start ( success ? SSH2_MSG_REQUEST_SUCCESS : SSH2_MSG_REQUEST_FAILURE ) ; if ( success && resp != NULL ) ssh_packet_put_raw ( active_state , sshbuf_ptr ( resp ) , sshbuf_len ( resp ) ) ; packet_send ( ) ; packet_write_wait ( ) ; } free ( rtype ) ; sshbuf_free ( resp ) ; return 0 ; } "," options . disable_forwarding || ! use_privsep ",openbsd@src/c76fac666ea038753294f2ac94d310f8adece9ce,CVE-2016-10010,https://github.com/openbsd/src/commit/c76fac666ea038753294f2ac94d310f8adece9ce,2017-01-05T02:59Z 157,CWE-264,"CWE-264 static void l2tp_eth_dev_setup ( struct net_device * dev ) { ether_setup ( dev ) ; dev -> netdev_ops = & l2tp_eth_netdev_ops ; dev -> destructor = free_netdev ; } "," ; dev -> priv_flags &= ~ IFF_TX_SKB_SHARING ; dev -> ",torvalds@linux/550fd08c2cebad61c548def135f67aba284c6162,CVE-2011-4112,https://github.com/torvalds/linux/commit/550fd08c2cebad61c548def135f67aba284c6162,2012-05-17T11:00Z 158,CWE-400,"CWE-400 static Image * ReadCINImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define MonoColorType 1 # define RGBColorType 3 char property [ MagickPathExtent ] ; CINInfo cin ; const unsigned char * pixels ; Image * image ; MagickBooleanType status ; MagickOffsetType offset ; QuantumInfo * quantum_info ; QuantumType quantum_type ; register ssize_t i ; register Quantum * q ; size_t length ; ssize_t count , y ; unsigned char magick [ 4 ] ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } offset = 0 ; count = ReadBlob ( image , 4 , magick ) ; offset += count ; if ( ( count != 4 ) || ( ( LocaleNCompare ( ( char * ) magick , ""\\200\\052\\137\\327"" , 4 ) != 0 ) ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; memset ( & cin , 0 , sizeof ( cin ) ) ; image -> endian = ( magick [ 0 ] == 0x80 ) && ( magick [ 1 ] == 0x2a ) && ( magick [ 2 ] == 0x5f ) && ( magick [ 3 ] == 0xd7 ) ? MSBEndian : LSBEndian ; cin . file . image_offset = ReadBlobLong ( image ) ; offset += 4 ; cin . file . generic_length = ReadBlobLong ( image ) ; offset += 4 ; cin . file . industry_length = ReadBlobLong ( image ) ; offset += 4 ; cin . file . user_length = ReadBlobLong ( image ) ; offset += 4 ; cin . file . file_size = ReadBlobLong ( image ) ; offset += 4 ; offset += ReadBlob ( image , sizeof ( cin . file . version ) , ( unsigned char * ) cin . file . version ) ; ( void ) CopyMagickString ( property , cin . file . version , sizeof ( cin . file . version ) ) ; ( void ) SetImageProperty ( image , ""dpx:file.version"" , property , exception ) ; offset += ReadBlob ( image , sizeof ( cin . file . filename ) , ( unsigned char * ) cin . file . filename ) ; ( void ) CopyMagickString ( property , cin . file . filename , sizeof ( cin . file . filename ) ) ; ( void ) SetImageProperty ( image , ""dpx:file.filename"" , property , exception ) ; offset += ReadBlob ( image , sizeof ( cin . file . create_date ) , ( unsigned char * ) cin . file . create_date ) ; ( void ) CopyMagickString ( property , cin . file . create_date , sizeof ( cin . file . create_date ) ) ; ( void ) SetImageProperty ( image , ""dpx:file.create_date"" , property , exception ) ; offset += ReadBlob ( image , sizeof ( cin . file . create_time ) , ( unsigned char * ) cin . file . create_time ) ; ( void ) CopyMagickString ( property , cin . file . create_time , sizeof ( cin . file . create_time ) ) ; ( void ) SetImageProperty ( image , ""dpx:file.create_time"" , property , exception ) ; offset += ReadBlob ( image , sizeof ( cin . file . reserve ) , ( unsigned char * ) cin . file . reserve ) ; cin . image . orientation = ( unsigned char ) ReadBlobByte ( image ) ; offset ++ ; if ( cin . image . orientation != ( unsigned char ) ( ~ 0 ) ) ( void ) FormatImageProperty ( image , ""dpx:image.orientation"" , ""%d"" , cin . image . orientation ) ; switch ( cin . image . orientation ) { default : case 0 : image -> orientation = TopLeftOrientation ; break ; case 1 : image -> orientation = TopRightOrientation ; break ; case 2 : image -> orientation = BottomLeftOrientation ; break ; case 3 : image -> orientation = BottomRightOrientation ; break ; case 4 : image -> orientation = LeftTopOrientation ; break ; case 5 : image -> orientation = RightTopOrientation ; break ; case 6 : image -> orientation = LeftBottomOrientation ; break ; case 7 : image -> orientation = RightBottomOrientation ; break ; } cin . image . number_channels = ( unsigned char ) ReadBlobByte ( image ) ; offset ++ ; offset += ReadBlob ( image , sizeof ( cin . image . reserve1 ) , ( unsigned char * ) cin . image . reserve1 ) ; for ( i = 0 ; i < 8 ; i ++ ) { cin . image . channel [ i ] . designator [ 0 ] = ( unsigned char ) ReadBlobByte ( image ) ; offset ++ ; cin . image . channel [ i ] . designator [ 1 ] = ( unsigned char ) ReadBlobByte ( image ) ; offset ++ ; cin . image . channel [ i ] . bits_per_pixel = ( unsigned char ) ReadBlobByte ( image ) ; offset ++ ; cin . image . channel [ i ] . reserve = ( unsigned char ) ReadBlobByte ( image ) ; offset ++ ; cin . image . channel [ i ] . pixels_per_line = ReadBlobLong ( image ) ; offset += 4 ; cin . image . channel [ i ] . lines_per_image = ReadBlobLong ( image ) ; offset += 4 ; cin . image . channel [ i ] . min_data = ReadBlobFloat ( image ) ; offset += 4 ; cin . image . channel [ i ] . min_quantity = ReadBlobFloat ( image ) ; offset += 4 ; cin . image . channel [ i ] . max_data = ReadBlobFloat ( image ) ; offset += 4 ; cin . image . channel [ i ] . max_quantity = ReadBlobFloat ( image ) ; offset += 4 ; } cin . image . white_point [ 0 ] = ReadBlobFloat ( image ) ; offset += 4 ; if ( IsFloatDefined ( cin . image . white_point [ 0 ] ) != MagickFalse ) image -> chromaticity . white_point . x = cin . image . white_point [ 0 ] ; cin . image . white_point [ 1 ] = ReadBlobFloat ( image ) ; offset += 4 ; if ( IsFloatDefined ( cin . image . white_point [ 1 ] ) != MagickFalse ) image -> chromaticity . white_point . y = cin . image . white_point [ 1 ] ; cin . image . red_primary_chromaticity [ 0 ] = ReadBlobFloat ( image ) ; offset += 4 ; if ( IsFloatDefined ( cin . image . red_primary_chromaticity [ 0 ] ) != MagickFalse ) image -> chromaticity . red_primary . x = cin . image . red_primary_chromaticity [ 0 ] ; cin . image . red_primary_chromaticity [ 1 ] = ReadBlobFloat ( image ) ; offset += 4 ; if ( IsFloatDefined ( cin . image . red_primary_chromaticity [ 1 ] ) != MagickFalse ) image -> chromaticity . red_primary . y = cin . image . red_primary_chromaticity [ 1 ] ; cin . image . green_primary_chromaticity [ 0 ] = ReadBlobFloat ( image ) ; offset += 4 ; if ( IsFloatDefined ( cin . image . green_primary_chromaticity [ 0 ] ) != MagickFalse ) image -> chromaticity . red_primary . x = cin . image . green_primary_chromaticity [ 0 ] ; cin . image . green_primary_chromaticity [ 1 ] = ReadBlobFloat ( image ) ; offset += 4 ; if ( IsFloatDefined ( cin . image . green_primary_chromaticity [ 1 ] ) != MagickFalse ) image -> chromaticity . green_primary . y = cin . image . green_primary_chromaticity [ 1 ] ; cin . image . blue_primary_chromaticity [ 0 ] = ReadBlobFloat ( image ) ; offset += 4 ; if ( IsFloatDefined ( cin . image . blue_primary_chromaticity [ 0 ] ) != MagickFalse ) image -> chromaticity . blue_primary . x = cin . image . blue_primary_chromaticity [ 0 ] ; cin . image . blue_primary_chromaticity [ 1 ] = ReadBlobFloat ( image ) ; offset += 4 ; if ( IsFloatDefined ( cin . image . blue_primary_chromaticity [ 1 ] ) != MagickFalse ) image -> chromaticity . blue_primary . y = cin . image . blue_primary_chromaticity [ 1 ] ; offset += ReadBlob ( image , sizeof ( cin . image . label ) , ( unsigned char * ) cin . image . label ) ; ( void ) CopyMagickString ( property , cin . image . label , sizeof ( cin . image . label ) ) ; ( void ) SetImageProperty ( image , ""dpx:image.label"" , property , exception ) ; offset += ReadBlob ( image , sizeof ( cin . image . reserve ) , ( unsigned char * ) cin . image . reserve ) ; cin . data_format . interleave = ( unsigned char ) ReadBlobByte ( image ) ; offset ++ ; cin . data_format . packing = ( unsigned char ) ReadBlobByte ( image ) ; offset ++ ; cin . data_format . sign = ( unsigned char ) ReadBlobByte ( image ) ; offset ++ ; cin . data_format . sense = ( unsigned char ) ReadBlobByte ( image ) ; offset ++ ; cin . data_format . line_pad = ReadBlobLong ( image ) ; offset += 4 ; cin . data_format . channel_pad = ReadBlobLong ( image ) ; offset += 4 ; offset += ReadBlob ( image , sizeof ( cin . data_format . reserve ) , ( unsigned char * ) cin . data_format . reserve ) ; cin . origination . x_offset = ReadBlobSignedLong ( image ) ; offset += 4 ; if ( ( size_t ) cin . origination . x_offset != ~ 0UL ) ( void ) FormatImageProperty ( image , ""dpx:origination.x_offset"" , ""%.20g"" , ( double ) cin . origination . x_offset ) ; cin . origination . y_offset = ( ssize_t ) ReadBlobLong ( image ) ; offset += 4 ; if ( ( size_t ) cin . origination . y_offset != ~ 0UL ) ( void ) FormatImageProperty ( image , ""dpx:origination.y_offset"" , ""%.20g"" , ( double ) cin . origination . y_offset ) ; offset += ReadBlob ( image , sizeof ( cin . origination . filename ) , ( unsigned char * ) cin . origination . filename ) ; ( void ) CopyMagickString ( property , cin . origination . filename , sizeof ( cin . origination . filename ) ) ; ( void ) SetImageProperty ( image , ""dpx:origination.filename"" , property , exception ) ; offset += ReadBlob ( image , sizeof ( cin . origination . create_date ) , ( unsigned char * ) cin . origination . create_date ) ; ( void ) CopyMagickString ( property , cin . origination . create_date , sizeof ( cin . origination . create_date ) ) ; ( void ) SetImageProperty ( image , ""dpx:origination.create_date"" , property , exception ) ; offset += ReadBlob ( image , sizeof ( cin . origination . create_time ) , ( unsigned char * ) cin . origination . create_time ) ; ( void ) CopyMagickString ( property , cin . origination . create_time , sizeof ( cin . origination . create_time ) ) ; ( void ) SetImageProperty ( image , ""dpx:origination.create_time"" , property , exception ) ; offset += ReadBlob ( image , sizeof ( cin . origination . device ) , ( unsigned char * ) cin . origination . device ) ; ( void ) CopyMagickString ( property , cin . origination . device , sizeof ( cin . origination . device ) ) ; ( void ) SetImageProperty ( image , ""dpx:origination.device"" , property , exception ) ; offset += ReadBlob ( image , sizeof ( cin . origination . model ) , ( unsigned char * ) cin . origination . model ) ; ( void ) CopyMagickString ( property , cin . origination . model , sizeof ( cin . origination . model ) ) ; ( void ) SetImageProperty ( image , ""dpx:origination.model"" , property , exception ) ; ( void ) memset ( cin . origination . serial , 0 , sizeof ( cin . origination . serial ) ) ; offset += ReadBlob ( image , sizeof ( cin . origination . serial ) , ( unsigned char * ) cin . origination . serial ) ; ( void ) CopyMagickString ( property , cin . origination . serial , sizeof ( cin . origination . serial ) ) ; ( void ) SetImageProperty ( image , ""dpx:origination.serial"" , property , exception ) ; cin . origination . x_pitch = ReadBlobFloat ( image ) ; offset += 4 ; cin . origination . y_pitch = ReadBlobFloat ( image ) ; offset += 4 ; cin . origination . gamma = ReadBlobFloat ( image ) ; offset += 4 ; if ( IsFloatDefined ( cin . origination . gamma ) != MagickFalse ) image -> gamma = cin . origination . gamma ; offset += ReadBlob ( image , sizeof ( cin . origination . reserve ) , ( unsigned char * ) cin . origination . reserve ) ; if ( ( cin . file . image_offset > 2048 ) && ( cin . file . user_length != 0 ) ) { int c ; cin . film . id = ReadBlobByte ( image ) ; offset ++ ; c = cin . film . id ; if ( c != ~ 0 ) ( void ) FormatImageProperty ( image , ""dpx:film.id"" , ""%d"" , cin . film . id ) ; cin . film . type = ReadBlobByte ( image ) ; offset ++ ; c = cin . film . type ; if ( c != ~ 0 ) ( void ) FormatImageProperty ( image , ""dpx:film.type"" , ""%d"" , cin . film . type ) ; cin . film . offset = ReadBlobByte ( image ) ; offset ++ ; c = cin . film . offset ; if ( c != ~ 0 ) ( void ) FormatImageProperty ( image , ""dpx:film.offset"" , ""%d"" , cin . film . offset ) ; cin . film . reserve1 = ReadBlobByte ( image ) ; offset ++ ; cin . film . prefix = ReadBlobLong ( image ) ; offset += 4 ; if ( cin . film . prefix != ~ 0UL ) ( void ) FormatImageProperty ( image , ""dpx:film.prefix"" , ""%.20g"" , ( double ) cin . film . prefix ) ; cin . film . count = ReadBlobLong ( image ) ; offset += 4 ; offset += ReadBlob ( image , sizeof ( cin . film . format ) , ( unsigned char * ) cin . film . format ) ; ( void ) CopyMagickString ( property , cin . film . format , sizeof ( cin . film . format ) ) ; ( void ) SetImageProperty ( image , ""dpx:film.format"" , property , exception ) ; cin . film . frame_position = ReadBlobLong ( image ) ; offset += 4 ; if ( cin . film . frame_position != ~ 0UL ) ( void ) FormatImageProperty ( image , ""dpx:film.frame_position"" , ""%.20g"" , ( double ) cin . film . frame_position ) ; cin . film . frame_rate = ReadBlobFloat ( image ) ; offset += 4 ; if ( IsFloatDefined ( cin . film . frame_rate ) != MagickFalse ) ( void ) FormatImageProperty ( image , ""dpx:film.frame_rate"" , ""%g"" , cin . film . frame_rate ) ; offset += ReadBlob ( image , sizeof ( cin . film . frame_id ) , ( unsigned char * ) cin . film . frame_id ) ; ( void ) CopyMagickString ( property , cin . film . frame_id , sizeof ( cin . film . frame_id ) ) ; ( void ) SetImageProperty ( image , ""dpx:film.frame_id"" , property , exception ) ; offset += ReadBlob ( image , sizeof ( cin . film . slate_info ) , ( unsigned char * ) cin . film . slate_info ) ; ( void ) CopyMagickString ( property , cin . film . slate_info , sizeof ( cin . film . slate_info ) ) ; ( void ) SetImageProperty ( image , ""dpx:film.slate_info"" , property , exception ) ; offset += ReadBlob ( image , sizeof ( cin . film . reserve ) , ( unsigned char * ) cin . film . reserve ) ; } if ( ( cin . file . image_offset > 2048 ) && ( cin . file . user_length != 0 ) ) { StringInfo * profile ; if ( cin . file . user_length > GetBlobSize ( image ) ) ThrowReaderException ( CorruptImageError , ""InsufficientImageDataInFile"" ) ; profile = BlobToStringInfo ( ( const unsigned char * ) NULL , cin . file . user_length ) ; if ( profile == ( StringInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; offset += ReadBlob ( image , GetStringInfoLength ( profile ) , GetStringInfoDatum ( profile ) ) ; ( void ) SetImageProfile ( image , ""dpx:user.data"" , profile , exception ) ; profile = DestroyStringInfo ( profile ) ; } image -> depth = cin . image . channel [ 0 ] . bits_per_pixel ; image -> columns = cin . image . channel [ 0 ] . pixels_per_line ; image -> rows = cin . image . channel [ 0 ] . lines_per_image ; if ( image_info -> ping != MagickFalse ) { ( void ) CloseBlob ( image ) ; return ( image ) ; } for ( ; offset < ( MagickOffsetType ) cin . file . image_offset ; offset ++ ) { int c ; c = ReadBlobByte ( image ) ; if ( c == EOF ) break ; } if ( offset < ( MagickOffsetType ) cin . file . image_offset ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; ( void ) SetImageBackgroundColor ( image , exception ) ; quantum_info = AcquireQuantumInfo ( image_info , image ) ; if ( quantum_info == ( QuantumInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; quantum_info -> quantum = 32 ; quantum_info -> pack = MagickFalse ; quantum_type = RGBQuantum ; length = GetQuantumExtent ( image , quantum_info , quantum_type ) ; length = GetBytesPerRow ( image -> columns , 3 , image -> depth , MagickTrue ) ; if ( cin . image . number_channels == 1 ) { quantum_type = GrayQuantum ; length = GetBytesPerRow ( image -> columns , 1 , image -> depth , MagickTrue ) ; } for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; pixels = ( const unsigned char * ) ReadBlobStream ( image , length , GetQuantumPixels ( quantum_info ) , & count ) ; if ( ( size_t ) count != length ) break ; ( void ) ImportQuantumPixels ( image , ( CacheView * ) NULL , quantum_info , quantum_type , pixels , exception ) ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } SetQuantumImageType ( image , quantum_type ) ; quantum_info = DestroyQuantumInfo ( quantum_info ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; SetImageColorspace ( image , LogColorspace , exception ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," ) ; } if ( ( ( MagickSizeType ) image -> columns * image -> rows ) > GetBlobSize ( image ) ) ThrowReaderException ( CorruptImageError , ""InsufficientImageDataInFile"" ) ; ",ImageMagick@ImageMagick/e3cdce6fe12193f235b8c0ae5efe6880a25eb957,CVE-2019-11470,https://github.com/ImageMagick/ImageMagick/commit/e3cdce6fe12193f235b8c0ae5efe6880a25eb957,2019-04-23T14:29Z 159,CWE-200,"CWE-200 static bool_t svcauth_gss_accept_sec_context ( struct svc_req * rqst , struct rpc_gss_init_res * gr ) { struct svc_rpc_gss_data * gd ; struct rpc_gss_cred * gc ; gss_buffer_desc recv_tok , seqbuf ; gss_OID mech ; OM_uint32 maj_stat = 0 , min_stat = 0 , ret_flags , seq ; log_debug ( ""insvcauth_gss_accept_context()"" ) ; gd = SVCAUTH_PRIVATE ( rqst -> rq_xprt -> xp_auth ) ; gc = ( struct rpc_gss_cred * ) rqst -> rq_clntcred ; memset ( gr , 0 , sizeof ( * gr ) ) ; memset ( & recv_tok , 0 , sizeof ( recv_tok ) ) ; if ( ! svc_getargs ( rqst -> rq_xprt , xdr_rpc_gss_init_args , ( caddr_t ) & recv_tok ) ) return ( FALSE ) ; gr -> gr_major = gss_accept_sec_context ( & gr -> gr_minor , & gd -> ctx , svcauth_gss_creds , & recv_tok , GSS_C_NO_CHANNEL_BINDINGS , & gd -> client_name , & mech , & gr -> gr_token , & ret_flags , NULL , NULL ) ; svc_freeargs ( rqst -> rq_xprt , xdr_rpc_gss_init_args , ( caddr_t ) & recv_tok ) ; log_status ( ""accept_sec_context"" , gr -> gr_major , gr -> gr_minor ) ; if ( gr -> gr_major != GSS_S_COMPLETE && gr -> gr_major != GSS_S_CONTINUE_NEEDED ) { badauth ( gr -> gr_major , gr -> gr_minor , rqst -> rq_xprt ) ; gd -> ctx = GSS_C_NO_CONTEXT ; goto errout ; } if ( ( gr -> gr_ctx . value = mem_alloc ( sizeof ( gss_union_ctx_id_desc ) ) ) == NULL ) { fprintf ( stderr , ""svcauth_gss_accept_context:outofmemory\\n"" ) ; goto errout ; } memcpy ( gr -> gr_ctx . value , gd -> ctx , sizeof ( gss_union_ctx_id_desc ) ) ; gr -> gr_ctx . length = sizeof ( gss_union_ctx_id_desc ) ; gr -> gr_win = sizeof ( gd -> seqmask ) * 8 ; gd -> sec . mech = mech ; gd -> sec . qop = GSS_C_QOP_DEFAULT ; gd -> sec . svc = gc -> gc_svc ; gd -> seq = gc -> gc_seq ; gd -> win = gr -> gr_win ; if ( gr -> gr_major == GSS_S_COMPLETE ) { # ifdef SPKM if ( ! g_OID_equal ( gss_mech_spkm3 , mech ) ) { # endif maj_stat = gss_display_name ( & min_stat , gd -> client_name , & gd -> cname , & gd -> sec . mech ) ; # ifdef SPKM } # endif if ( maj_stat != GSS_S_COMPLETE ) { log_status ( ""display_name"" , maj_stat , min_stat ) ; goto errout ; } # ifdef DEBUG # ifdef HAVE_HEIMDAL log_debug ( ""acceptedcontextfor%.*swith"" ""{},qop%d,svc%d>"" , gd -> cname . length , ( char * ) gd -> cname . value , gd -> sec . qop , gd -> sec . svc ) ; # else { gss_buffer_desc mechname ; gss_oid_to_str ( & min_stat , mech , & mechname ) ; log_debug ( ""acceptedcontextfor%.*swith"" ""%.*s,qop%d,svc%d>"" , gd -> cname . length , ( char * ) gd -> cname . value , mechname . length , ( char * ) mechname . value , gd -> sec . qop , gd -> sec . svc ) ; gss_release_buffer ( & min_stat , & mechname ) ; } # endif # endif seq = htonl ( gr -> gr_win ) ; seqbuf . value = & seq ; seqbuf . length = sizeof ( seq ) ; gss_release_buffer ( & min_stat , & gd -> checksum ) ; maj_stat = gss_sign ( & min_stat , gd -> ctx , GSS_C_QOP_DEFAULT , & seqbuf , & gd -> checksum ) ; if ( maj_stat != GSS_S_COMPLETE ) { goto errout ; } rqst -> rq_xprt -> xp_verf . oa_flavor = RPCSEC_GSS ; rqst -> rq_xprt -> xp_verf . oa_base = gd -> checksum . value ; rqst -> rq_xprt -> xp_verf . oa_length = gd -> checksum . length ; } return ( TRUE ) ; errout : gss_release_buffer ( & min_stat , & gr -> gr_token ) ; return ( FALSE ) ; } "," errout ; } gr -> gr_ctx . value = ""xxxx"" ; gr -> gr_ctx -> gr_ctx . length = 4 ; gr -> ",krb5@krb5/5bb8a6b9c9eb8dd22bc9526751610aaa255ead9c,CVE-2014-9423,https://github.com/krb5/krb5/commit/5bb8a6b9c9eb8dd22bc9526751610aaa255ead9c,2015-02-19T11:59Z 160,CWE-200,"CWE-200 static int ext4_ext_grow_indepth ( handle_t * handle , struct inode * inode , unsigned int flags ) { struct ext4_extent_header * neh ; struct buffer_head * bh ; ext4_fsblk_t newblock , goal = 0 ; struct ext4_super_block * es = EXT4_SB ( inode -> i_sb ) -> s_es ; int err = 0 ; if ( ext_depth ( inode ) ) goal = ext4_idx_pblock ( EXT_FIRST_INDEX ( ext_inode_hdr ( inode ) ) ) ; if ( goal > le32_to_cpu ( es -> s_first_data_block ) ) { flags |= EXT4_MB_HINT_TRY_GOAL ; goal -- ; } else goal = ext4_inode_to_goal_block ( inode ) ; newblock = ext4_new_meta_blocks ( handle , inode , goal , flags , NULL , & err ) ; if ( newblock == 0 ) return err ; bh = sb_getblk_gfp ( inode -> i_sb , newblock , __GFP_MOVABLE | GFP_NOFS ) ; if ( unlikely ( ! bh ) ) return - ENOMEM ; lock_buffer ( bh ) ; err = ext4_journal_get_create_access ( handle , bh ) ; if ( err ) { unlock_buffer ( bh ) ; goto out ; } memmove ( bh -> b_data , EXT4_I ( inode ) -> i_data , sizeof ( EXT4_I ( inode ) -> i_data ) ) ; neh = ext_block_hdr ( bh ) ; if ( ext_depth ( inode ) ) neh -> eh_max = cpu_to_le16 ( ext4_ext_space_block_idx ( inode , 0 ) ) ; else neh -> eh_max = cpu_to_le16 ( ext4_ext_space_block ( inode , 0 ) ) ; neh -> eh_magic = EXT4_EXT_MAGIC ; ext4_extent_block_csum_set ( inode , neh ) ; set_buffer_uptodate ( bh ) ; unlock_buffer ( bh ) ; err = ext4_handle_dirty_metadata ( handle , inode , bh ) ; if ( err ) goto out ; neh = ext_inode_hdr ( inode ) ; neh -> eh_entries = cpu_to_le16 ( 1 ) ; ext4_idx_store_pblock ( EXT_FIRST_INDEX ( neh ) , newblock ) ; if ( neh -> eh_depth == 0 ) { neh -> eh_max = cpu_to_le16 ( ext4_ext_space_root_idx ( inode , 0 ) ) ; EXT_FIRST_INDEX ( neh ) -> ei_block = EXT_FIRST_EXTENT ( neh ) -> ee_block ; } ext_debug ( ""newroot:num%d(%d),lblock%d,ptr%llu\\n"" , le16_to_cpu ( neh -> eh_entries ) , le16_to_cpu ( neh -> eh_max ) , le32_to_cpu ( EXT_FIRST_INDEX ( neh ) -> ei_block ) , ext4_idx_pblock ( EXT_FIRST_INDEX ( neh ) ) ) ; le16_add_cpu ( & neh -> eh_depth , 1 ) ; ext4_mark_inode_dirty ( handle , inode ) ; out : brelse ( bh ) ; return err ; } "," = 0 ; size_t ext_size = 0 ; out ; } ext_size = sizeof ( EXT4_I ( inode ) -> i_data ) ; -> i_data , ext_size ) ; memset ( bh -> b_data + ext_size , 0 , inode -> i_sb -> s_blocksize - ext_size ) ; neh ",torvalds@linux/592acbf16821288ecdc4192c47e3774a4c48bb64,CVE-2019-11833,https://github.com/torvalds/linux/commit/592acbf16821288ecdc4192c47e3774a4c48bb64,2019-05-15T13:29Z 161,CWE-295,"CWE-295 NOEXPORT int verify_callback ( int preverify_ok , X509_STORE_CTX * callback_ctx ) { SSL * ssl ; CLI * c ; ssl = X509_STORE_CTX_get_ex_data ( callback_ctx , SSL_get_ex_data_X509_STORE_CTX_idx ( ) ) ; c = SSL_get_ex_data ( ssl , index_ssl_cli ) ; if ( ! c -> opt -> option . verify_chain && ! c -> opt -> option . verify_peer ) { s_log ( LOG_INFO , ""Certificateverificationdisabled"" ) ; return 1 ; } if ( verify_checks ( c , preverify_ok , callback_ctx ) ) { SSL_SESSION * sess = SSL_get1_session ( c -> ssl ) ; if ( sess ) { int ok = SSL_SESSION_set_ex_data ( sess , index_session_authenticated , ( void * ) ( - 1 ) ) ; SSL_SESSION_free ( sess ) ; if ( ! ok ) { sslerror ( ""SSL_SESSION_set_ex_data"" ) ; return 0 ; } } return 1 ; } if ( c -> opt -> option . client || c -> opt -> protocol ) return 0 ; if ( c -> opt -> redirect_addr . names ) return 1 ; return 0 ; } "," callback_ctx ) ) return 1 ; if ( c -> opt -> option . client || c -> opt -> protocol ) return 0 ; if ( c -> opt -> redirect_addr . names ) , index_session_authenticated , NULL ) ; SSL_SESSION_free 1 ; } return 0 ; return 0 ; } ",mtrojnar@stunnel/ebad9ddc4efb2635f37174c9d800d06206f1edf9,CVE-2021-20230,https://github.com/mtrojnar/stunnel/commit/ebad9ddc4efb2635f37174c9d800d06206f1edf9,2021-02-23T17:15Z 162,CWE-264,"CWE-264 int create_user_ns ( struct cred * new ) { struct user_namespace * ns , * parent_ns = new -> user_ns ; kuid_t owner = new -> euid ; kgid_t group = new -> egid ; int ret ; if ( ! kuid_has_mapping ( parent_ns , owner ) || ! kgid_has_mapping ( parent_ns , group ) ) return - EPERM ; ns = kmem_cache_zalloc ( user_ns_cachep , GFP_KERNEL ) ; if ( ! ns ) return - ENOMEM ; ret = proc_alloc_inum ( & ns -> proc_inum ) ; if ( ret ) { kmem_cache_free ( user_ns_cachep , ns ) ; return ret ; } atomic_set ( & ns -> count , 1 ) ; ns -> parent = parent_ns ; ns -> owner = owner ; ns -> group = group ; set_cred_user_ns ( new , ns ) ; return 0 ; } "," ; int ret ; if ( current_chrooted ( ) ) return - EPERM ",torvalds@linux/3151527ee007b73a0ebd296010f1c0454a919c7d,CVE-2013-1956,https://github.com/torvalds/linux/commit/3151527ee007b73a0ebd296010f1c0454a919c7d,2013-04-24T19:55Z 163,CWE-203,"CWE-203 int secure_decrypt ( void * data , unsigned int data_length , int is_signed ) { at91_aes_key_size_t key_size ; unsigned int cmac_key [ 8 ] , cipher_key [ 8 ] ; unsigned int iv [ AT91_AES_IV_SIZE_WORD ] ; unsigned int computed_cmac [ AT91_AES_BLOCK_SIZE_WORD ] ; unsigned int fixed_length ; const unsigned int * cmac ; int rc = - 1 ; init_keys ( & key_size , cipher_key , cmac_key , iv ) ; at91_aes_init ( ) ; if ( is_signed ) { if ( at91_aes_cmac ( data_length , data , computed_cmac , key_size , cmac_key ) ) goto exit ; fixed_length = at91_aes_roundup ( data_length ) ; cmac = ( const unsigned int * ) ( ( char * ) data + fixed_length ) ; if ( memcmp ( cmac , computed_cmac , AT91_AES_BLOCK_SIZE_BYTE ) ) goto exit ; } if ( at91_aes_cbc ( data_length , data , data , 0 , key_size , cipher_key , iv ) ) goto exit ; rc = 0 ; exit : at91_aes_cleanup ( ) ; memset ( cmac_key , 0 , sizeof ( cmac_key ) ) ; memset ( cipher_key , 0 , sizeof ( cipher_key ) ) ; memset ( iv , 0 , sizeof ( iv ) ) ; return rc ; } "," ; if ( ! consttime_memequal ( cmac , ",linux4sam@at91bootstrap/7753914c9a622c245f3a3cf2af5e24b6a9904213,CVE-2020-11683,https://github.com/linux4sam/at91bootstrap/commit/7753914c9a622c245f3a3cf2af5e24b6a9904213,2020-09-14T14:15Z 164,CWE-20,"CWE-20 static int get_cox ( Jpeg2000DecoderContext * s , Jpeg2000CodingStyle * c ) { uint8_t byte ; if ( bytestream2_get_bytes_left ( & s -> g ) < 5 ) return AVERROR_INVALIDDATA ; c -> nreslevels = bytestream2_get_byteu ( & s -> g ) + 1 ; if ( c -> nreslevels >= JPEG2000_MAX_RESLEVELS ) { av_log ( s -> avctx , AV_LOG_ERROR , ""nreslevels%disinvalid\\n"" , c -> nreslevels ) ; return AVERROR_INVALIDDATA ; } if ( c -> nreslevels < s -> reduction_factor ) c -> nreslevels2decode = 1 ; else c -> nreslevels2decode = c -> nreslevels - s -> reduction_factor ; c -> log2_cblk_width = ( bytestream2_get_byteu ( & s -> g ) & 15 ) + 2 ; c -> log2_cblk_height = ( bytestream2_get_byteu ( & s -> g ) & 15 ) + 2 ; if ( c -> log2_cblk_width > 10 || c -> log2_cblk_height > 10 || c -> log2_cblk_width + c -> log2_cblk_height > 12 ) { av_log ( s -> avctx , AV_LOG_ERROR , ""cblksizeinvalid\\n"" ) ; return AVERROR_INVALIDDATA ; } if ( c -> log2_cblk_width > 6 || c -> log2_cblk_height > 6 ) { avpriv_request_sample ( s -> avctx , ""cblksize>64"" ) ; return AVERROR_PATCHWELCOME ; } c -> cblk_style = bytestream2_get_byteu ( & s -> g ) ; if ( c -> cblk_style != 0 ) { av_log ( s -> avctx , AV_LOG_WARNING , ""extracblkstyles%X\\n"" , c -> cblk_style ) ; } c -> transform = bytestream2_get_byteu ( & s -> g ) ; if ( ( s -> avctx -> flags & CODEC_FLAG_BITEXACT ) && ( c -> transform == FF_DWT97 ) ) c -> transform = FF_DWT97_INT ; if ( c -> csty & JPEG2000_CSTY_PREC ) { int i ; for ( i = 0 ; i < c -> nreslevels ; i ++ ) { byte = bytestream2_get_byte ( & s -> g ) ; c -> log2_prec_widths [ i ] = byte & 0x0F ; c -> log2_prec_heights [ i ] = ( byte >> 4 ) & 0x0F ; } } else { memset ( c -> log2_prec_widths , 15 , sizeof ( c -> log2_prec_widths ) ) ; memset ( c -> log2_prec_heights , 15 , sizeof ( c -> log2_prec_heights ) ) ; } return 0 ; } "," c -> nreslevels <= s -> reduction_factor -> reduction_factor ) { av_log ( s -> avctx , AV_LOG_ERROR , ""reduction_factortoolargeforthisbitstream,maxis%d\\n"" , c -> nreslevels - 1 ) ; s -> reduction_factor = c -> nreslevels - 1 ; return AVERROR ( EINVAL ) ; } c -> nreslevels2decode ",FFmpeg@FFmpeg/a1b9004b768bef606ee98d417bceb9392ceb788d,CVE-2013-7019,https://github.com/FFmpeg/FFmpeg/commit/a1b9004b768bef606ee98d417bceb9392ceb788d,2013-12-09T16:36Z 165,CWE-000,"CWE-000 qboolean S_AL_Init ( soundInterface_t * si ) { # ifdef USE_OPENAL const char * device = NULL ; const char * inputdevice = NULL ; int i ; if ( ! si ) { return qfalse ; } for ( i = 0 ; i < MAX_RAW_STREAMS ; i ++ ) { streamSourceHandles [ i ] = - 1 ; streamPlaying [ i ] = qfalse ; streamSources [ i ] = 0 ; streamNumBuffers [ i ] = 0 ; streamBufIndex [ i ] = 0 ; } s_alPrecache = Cvar_Get ( ""s_alPrecache"" , ""1"" , CVAR_ARCHIVE ) ; s_alGain = Cvar_Get ( ""s_alGain"" , ""1.0"" , CVAR_ARCHIVE ) ; s_alSources = Cvar_Get ( ""s_alSources"" , ""128"" , CVAR_ARCHIVE ) ; s_alDopplerFactor = Cvar_Get ( ""s_alDopplerFactor"" , ""1.0"" , CVAR_ARCHIVE ) ; s_alDopplerSpeed = Cvar_Get ( ""s_alDopplerSpeed"" , ""9000"" , CVAR_ARCHIVE ) ; s_alMinDistance = Cvar_Get ( ""s_alMinDistance"" , ""120"" , CVAR_CHEAT ) ; s_alMaxDistance = Cvar_Get ( ""s_alMaxDistance"" , ""1024"" , CVAR_CHEAT ) ; s_alRolloff = Cvar_Get ( ""s_alRolloff"" , ""2"" , CVAR_CHEAT ) ; s_alGraceDistance = Cvar_Get ( ""s_alGraceDistance"" , ""512"" , CVAR_CHEAT ) ; s_alDriver = Cvar_Get ( ""s_alDriver"" , ALDRIVER_DEFAULT , CVAR_ARCHIVE | CVAR_LATCH ) ; s_alInputDevice = Cvar_Get ( ""s_alInputDevice"" , """" , CVAR_ARCHIVE | CVAR_LATCH ) ; s_alDevice = Cvar_Get ( ""s_alDevice"" , """" , CVAR_ARCHIVE | CVAR_LATCH ) ; if ( ! QAL_Init ( s_alDriver -> string ) ) { # if defined ( _WIN32 ) if ( ! Q_stricmp ( s_alDriver -> string , ALDRIVER_DEFAULT ) && ! QAL_Init ( ""OpenAL64.dll"" ) ) { # elif defined ( __APPLE__ ) if ( ! Q_stricmp ( s_alDriver -> string , ALDRIVER_DEFAULT ) && ! QAL_Init ( ""/System/Library/Frameworks/OpenAL.framework/OpenAL"" ) ) { # else if ( ! Q_stricmp ( s_alDriver -> string , ALDRIVER_DEFAULT ) || ! QAL_Init ( ALDRIVER_DEFAULT ) ) { # endif return qfalse ; } } device = s_alDevice -> string ; if ( device && ! * device ) device = NULL ; inputdevice = s_alInputDevice -> string ; if ( inputdevice && ! * inputdevice ) inputdevice = NULL ; enumeration_all_ext = qalcIsExtensionPresent ( NULL , ""ALC_ENUMERATE_ALL_EXT"" ) ; enumeration_ext = qalcIsExtensionPresent ( NULL , ""ALC_ENUMERATION_EXT"" ) ; if ( enumeration_ext || enumeration_all_ext ) { char devicenames [ 16384 ] = """" ; const char * devicelist ; # ifdef _WIN32 const char * defaultdevice ; # endif int curlen ; if ( enumeration_all_ext ) { devicelist = qalcGetString ( NULL , ALC_ALL_DEVICES_SPECIFIER ) ; # ifdef _WIN32 defaultdevice = qalcGetString ( NULL , ALC_DEFAULT_ALL_DEVICES_SPECIFIER ) ; # endif } else { devicelist = qalcGetString ( NULL , ALC_DEVICE_SPECIFIER ) ; # ifdef _WIN32 defaultdevice = qalcGetString ( NULL , ALC_DEFAULT_DEVICE_SPECIFIER ) ; # endif enumeration_ext = qtrue ; } # ifdef _WIN32 if ( ! device && defaultdevice && ! strcmp ( defaultdevice , ""GenericHardware"" ) ) device = ""GenericSoftware"" ; # endif if ( devicelist ) { while ( ( curlen = strlen ( devicelist ) ) ) { Q_strcat ( devicenames , sizeof ( devicenames ) , devicelist ) ; Q_strcat ( devicenames , sizeof ( devicenames ) , ""\\n"" ) ; devicelist += curlen + 1 ; } } s_alAvailableDevices = Cvar_Get ( ""s_alAvailableDevices"" , devicenames , CVAR_ROM | CVAR_NORESTART ) ; } alDevice = qalcOpenDevice ( device ) ; if ( ! alDevice && device ) { Com_Printf ( ""FailedtoopenOpenALdevice\'%s\',tryingdefault.\\n"" , device ) ; alDevice = qalcOpenDevice ( NULL ) ; } if ( ! alDevice ) { QAL_Shutdown ( ) ; Com_Printf ( ""FailedtoopenOpenALdevice.\\n"" ) ; return qfalse ; } alContext = qalcCreateContext ( alDevice , NULL ) ; if ( ! alContext ) { QAL_Shutdown ( ) ; qalcCloseDevice ( alDevice ) ; Com_Printf ( ""FailedtocreateOpenALcontext.\\n"" ) ; return qfalse ; } qalcMakeContextCurrent ( alContext ) ; S_AL_BufferInit ( ) ; S_AL_SrcInit ( ) ; Com_Printf ( ""Allocated%dsources.\\n"" , srcCount ) ; qalDistanceModel ( AL_INVERSE_DISTANCE_CLAMPED ) ; qalDopplerFactor ( s_alDopplerFactor -> value ) ; qalSpeedOfSound ( s_alDopplerSpeed -> value ) ; # ifdef USE_VOIP s_alCapture = Cvar_Get ( ""s_alCapture"" , ""1"" , CVAR_ARCHIVE | CVAR_LATCH ) ; if ( ! s_alCapture -> integer ) { Com_Printf ( ""OpenALcapturesupportdisabledbyuser(\'+sets_alCapture1\'toenable)\\n"" ) ; } # if USE_MUMBLE else if ( cl_useMumble -> integer ) { Com_Printf ( ""OpenALcapturesupportdisabledforMumblesupport\\n"" ) ; } # endif else { # ifdef __APPLE__ if ( qalcCaptureOpenDevice == NULL ) # else if ( ! qalcIsExtensionPresent ( NULL , ""ALC_EXT_capture"" ) ) # endif { Com_Printf ( ""NoALC_EXT_capturesupport,can\'trecordaudio.\\n"" ) ; } else { char inputdevicenames [ 16384 ] = """" ; const char * inputdevicelist ; const char * defaultinputdevice ; int curlen ; capture_ext = qtrue ; inputdevicelist = qalcGetString ( NULL , ALC_CAPTURE_DEVICE_SPECIFIER ) ; defaultinputdevice = qalcGetString ( NULL , ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER ) ; if ( inputdevicelist ) { while ( ( curlen = strlen ( inputdevicelist ) ) ) { Q_strcat ( inputdevicenames , sizeof ( inputdevicenames ) , inputdevicelist ) ; Q_strcat ( inputdevicenames , sizeof ( inputdevicenames ) , ""\\n"" ) ; inputdevicelist += curlen + 1 ; } } s_alAvailableInputDevices = Cvar_Get ( ""s_alAvailableInputDevices"" , inputdevicenames , CVAR_ROM | CVAR_NORESTART ) ; Com_Printf ( ""OpenALdefaultcapturedeviceis\'%s\'\\n"" , defaultinputdevice ? defaultinputdevice : ""none"" ) ; alCaptureDevice = qalcCaptureOpenDevice ( inputdevice , 48000 , AL_FORMAT_MONO16 , VOIP_MAX_PACKET_SAMPLES * 4 ) ; if ( ! alCaptureDevice && inputdevice ) { Com_Printf ( ""FailedtoopenOpenALInputdevice\'%s\',tryingdefault.\\n"" , inputdevice ) ; alCaptureDevice = qalcCaptureOpenDevice ( NULL , 48000 , AL_FORMAT_MONO16 , VOIP_MAX_PACKET_SAMPLES * 4 ) ; } Com_Printf ( ""OpenALcapturedevice%s.\\n"" , ( alCaptureDevice == NULL ) ? ""failedtoopen"" : ""opened"" ) ; } } # endif si -> Shutdown = S_AL_Shutdown ; si -> StartSound = S_AL_StartSound ; si -> StartSoundEx = S_AL_StartSoundEx ; si -> StartLocalSound = S_AL_StartLocalSound ; si -> StartBackgroundTrack = S_AL_StartBackgroundTrack ; si -> StopBackgroundTrack = S_AL_StopBackgroundTrack ; si -> StartStreamingSound = S_AL_StartStreamingSound ; si -> GetVoiceAmplitude = S_AL_GetVoiceAmplitude ; si -> RawSamples = S_AL_RawSamples ; si -> StopAllSounds = S_AL_StopAllSounds ; si -> ClearLoopingSounds = S_AL_ClearLoopingSounds ; si -> AddLoopingSound = S_AL_AddLoopingSound ; si -> AddRealLoopingSound = S_AL_AddRealLoopingSound ; si -> StopLoopingSound = S_AL_StopLoopingSound ; si -> Respatialize = S_AL_Respatialize ; si -> UpdateEntityPosition = S_AL_UpdateEntityPosition ; si -> Update = S_AL_Update ; si -> DisableSounds = S_AL_DisableSounds ; si -> BeginRegistration = S_AL_BeginRegistration ; si -> RegisterSound = S_AL_RegisterSound ; si -> ClearSoundBuffer = S_AL_ClearSoundBuffer ; si -> SoundInfo = S_AL_SoundInfo ; si -> SoundList = S_AL_SoundList ; # ifdef USE_VOIP si -> StartCapture = S_AL_StartCapture ; si -> AvailableCaptureSamples = S_AL_AvailableCaptureSamples ; si -> Capture = S_AL_Capture ; si -> StopCapture = S_AL_StopCapture ; si -> MasterGain = S_AL_MasterGain ; # endif return qtrue ; # else return qfalse ; # endif } "," CVAR_ARCHIVE | CVAR_LATCH | CVAR_PROTECTED CVAR_LATCH ) ; if ( COM_CompareExtension ( s_alDriver -> string , "".pk3"" ) ) { Com_Printf ( ""RejectingDLLnamed\\""%s\\"""" , s_alDriver -> string ) ; return qfalse ; } ",JACoders@OpenJK/b248763e4878ef12d5835ece6600be8334f67da1,CVE-2017-6903,https://github.com/JACoders/OpenJK/commit/b248763e4878ef12d5835ece6600be8334f67da1,2017-03-14T22:59Z 166,CWE-119,"CWE-119 static int tpacket_rcv ( struct sk_buff * skb , struct net_device * dev , struct packet_type * pt , struct net_device * orig_dev ) { struct sock * sk ; struct packet_sock * po ; struct sockaddr_ll * sll ; union tpacket_uhdr h ; u8 * skb_head = skb -> data ; int skb_len = skb -> len ; unsigned int snaplen , res ; unsigned long status = TP_STATUS_USER ; unsigned short macoff , netoff , hdrlen ; struct sk_buff * copy_skb = NULL ; struct timespec ts ; __u32 ts_status ; bool is_drop_n_account = false ; BUILD_BUG_ON ( TPACKET_ALIGN ( sizeof ( * h . h2 ) ) != 32 ) ; BUILD_BUG_ON ( TPACKET_ALIGN ( sizeof ( * h . h3 ) ) != 48 ) ; if ( skb -> pkt_type == PACKET_LOOPBACK ) goto drop ; sk = pt -> af_packet_priv ; po = pkt_sk ( sk ) ; if ( ! net_eq ( dev_net ( dev ) , sock_net ( sk ) ) ) goto drop ; if ( dev -> header_ops ) { if ( sk -> sk_type != SOCK_DGRAM ) skb_push ( skb , skb -> data - skb_mac_header ( skb ) ) ; else if ( skb -> pkt_type == PACKET_OUTGOING ) { skb_pull ( skb , skb_network_offset ( skb ) ) ; } } snaplen = skb -> len ; res = run_filter ( skb , sk , snaplen ) ; if ( ! res ) goto drop_n_restore ; if ( skb -> ip_summed == CHECKSUM_PARTIAL ) status |= TP_STATUS_CSUMNOTREADY ; else if ( skb -> pkt_type != PACKET_OUTGOING && ( skb -> ip_summed == CHECKSUM_COMPLETE || skb_csum_unnecessary ( skb ) ) ) status |= TP_STATUS_CSUM_VALID ; if ( snaplen > res ) snaplen = res ; if ( sk -> sk_type == SOCK_DGRAM ) { macoff = netoff = TPACKET_ALIGN ( po -> tp_hdrlen ) + 16 + po -> tp_reserve ; } else { unsigned int maclen = skb_network_offset ( skb ) ; netoff = TPACKET_ALIGN ( po -> tp_hdrlen + ( maclen < 16 ? 16 : maclen ) ) + po -> tp_reserve ; if ( po -> has_vnet_hdr ) netoff += sizeof ( struct virtio_net_hdr ) ; macoff = netoff - maclen ; } if ( po -> tp_version <= TPACKET_V2 ) { if ( macoff + snaplen > po -> rx_ring . frame_size ) { if ( po -> copy_thresh && atomic_read ( & sk -> sk_rmem_alloc ) < sk -> sk_rcvbuf ) { if ( skb_shared ( skb ) ) { copy_skb = skb_clone ( skb , GFP_ATOMIC ) ; } else { copy_skb = skb_get ( skb ) ; skb_head = skb -> data ; } if ( copy_skb ) skb_set_owner_r ( copy_skb , sk ) ; } snaplen = po -> rx_ring . frame_size - macoff ; if ( ( int ) snaplen < 0 ) snaplen = 0 ; } } else if ( unlikely ( macoff + snaplen > GET_PBDQC_FROM_RB ( & po -> rx_ring ) -> max_frame_len ) ) { u32 nval ; nval = GET_PBDQC_FROM_RB ( & po -> rx_ring ) -> max_frame_len - macoff ; pr_err_once ( ""tpacket_rcv:packettoobig,clampedfrom%uto%u.macoff=%u\\n"" , snaplen , nval , macoff ) ; snaplen = nval ; if ( unlikely ( ( int ) snaplen < 0 ) ) { snaplen = 0 ; macoff = GET_PBDQC_FROM_RB ( & po -> rx_ring ) -> max_frame_len ; } } spin_lock ( & sk -> sk_receive_queue . lock ) ; h . raw = packet_current_rx_frame ( po , skb , TP_STATUS_KERNEL , ( macoff + snaplen ) ) ; if ( ! h . raw ) goto drop_n_account ; if ( po -> tp_version <= TPACKET_V2 ) { packet_increment_rx_head ( po , & po -> rx_ring ) ; if ( po -> stats . stats1 . tp_drops ) status |= TP_STATUS_LOSING ; } po -> stats . stats1 . tp_packets ++ ; if ( copy_skb ) { status |= TP_STATUS_COPY ; __skb_queue_tail ( & sk -> sk_receive_queue , copy_skb ) ; } spin_unlock ( & sk -> sk_receive_queue . lock ) ; if ( po -> has_vnet_hdr ) { if ( virtio_net_hdr_from_skb ( skb , h . raw + macoff - sizeof ( struct virtio_net_hdr ) , vio_le ( ) , true ) ) { spin_lock ( & sk -> sk_receive_queue . lock ) ; goto drop_n_account ; } } skb_copy_bits ( skb , 0 , h . raw + macoff , snaplen ) ; if ( ! ( ts_status = tpacket_get_timestamp ( skb , & ts , po -> tp_tstamp ) ) ) getnstimeofday ( & ts ) ; status |= ts_status ; switch ( po -> tp_version ) { case TPACKET_V1 : h . h1 -> tp_len = skb -> len ; h . h1 -> tp_snaplen = snaplen ; h . h1 -> tp_mac = macoff ; h . h1 -> tp_net = netoff ; h . h1 -> tp_sec = ts . tv_sec ; h . h1 -> tp_usec = ts . tv_nsec / NSEC_PER_USEC ; hdrlen = sizeof ( * h . h1 ) ; break ; case TPACKET_V2 : h . h2 -> tp_len = skb -> len ; h . h2 -> tp_snaplen = snaplen ; h . h2 -> tp_mac = macoff ; h . h2 -> tp_net = netoff ; h . h2 -> tp_sec = ts . tv_sec ; h . h2 -> tp_nsec = ts . tv_nsec ; if ( skb_vlan_tag_present ( skb ) ) { h . h2 -> tp_vlan_tci = skb_vlan_tag_get ( skb ) ; h . h2 -> tp_vlan_tpid = ntohs ( skb -> vlan_proto ) ; status |= TP_STATUS_VLAN_VALID | TP_STATUS_VLAN_TPID_VALID ; } else { h . h2 -> tp_vlan_tci = 0 ; h . h2 -> tp_vlan_tpid = 0 ; } memset ( h . h2 -> tp_padding , 0 , sizeof ( h . h2 -> tp_padding ) ) ; hdrlen = sizeof ( * h . h2 ) ; break ; case TPACKET_V3 : h . h3 -> tp_status |= status ; h . h3 -> tp_len = skb -> len ; h . h3 -> tp_snaplen = snaplen ; h . h3 -> tp_mac = macoff ; h . h3 -> tp_net = netoff ; h . h3 -> tp_sec = ts . tv_sec ; h . h3 -> tp_nsec = ts . tv_nsec ; memset ( h . h3 -> tp_padding , 0 , sizeof ( h . h3 -> tp_padding ) ) ; hdrlen = sizeof ( * h . h3 ) ; break ; default : BUG ( ) ; } sll = h . raw + TPACKET_ALIGN ( hdrlen ) ; sll -> sll_halen = dev_parse_header ( skb , sll -> sll_addr ) ; sll -> sll_family = AF_PACKET ; sll -> sll_hatype = dev -> type ; sll -> sll_protocol = skb -> protocol ; sll -> sll_pkttype = skb -> pkt_type ; if ( unlikely ( po -> origdev ) ) sll -> sll_ifindex = orig_dev -> ifindex ; else sll -> sll_ifindex = dev -> ifindex ; smp_mb ( ) ; # if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE == 1 if ( po -> tp_version <= TPACKET_V2 ) { u8 * start , * end ; end = ( u8 * ) PAGE_ALIGN ( ( unsigned long ) h . raw + macoff + snaplen ) ; for ( start = h . raw ; start < end ; start += PAGE_SIZE ) flush_dcache_page ( pgv_to_page ( start ) ) ; } smp_wmb ( ) ; # endif if ( po -> tp_version <= TPACKET_V2 ) { __packet_set_status ( po , h . raw , status ) ; sk -> sk_data_ready ( sk ) ; } else { prb_clear_blk_fill_status ( & po -> rx_ring ) ; } drop_n_restore : if ( skb_head != skb -> data && skb_shared ( skb ) ) { skb -> data = skb_head ; skb -> len = skb_len ; } drop : if ( ! is_drop_n_account ) consume_skb ( skb ) ; else kfree_skb ( skb ) ; return 0 ; drop_n_account : is_drop_n_account = true ; po -> stats . stats1 . tp_drops ++ ; spin_unlock ( & sk -> sk_receive_queue . lock ) ; sk -> sk_data_ready ( sk ) ; kfree_skb ( copy_skb ) ; goto drop_n_restore ; } "," ; bool is_drop_n_account = false ; bool do_vnet -> has_vnet_hdr ) { virtio_net_hdr ) ; do_vnet = true ; } < 0 ) { = 0 ; do_vnet = false ; } -> max_frame_len ; do_vnet = false ; ; if ( do_vnet ) { if ",torvalds@linux/edbd58be15a957f6a760c4a514cd475217eb97fd,CVE-2017-14497,https://github.com/torvalds/linux/commit/edbd58be15a957f6a760c4a514cd475217eb97fd,2017-09-15T18:29Z 167,CWE-000,"CWE-000 void sctp_assoc_update ( struct sctp_association * asoc , struct sctp_association * new ) { struct sctp_transport * trans ; struct list_head * pos , * temp ; asoc -> c = new -> c ; asoc -> peer . rwnd = new -> peer . rwnd ; asoc -> peer . sack_needed = new -> peer . sack_needed ; asoc -> peer . auth_capable = new -> peer . auth_capable ; asoc -> peer . i = new -> peer . i ; sctp_tsnmap_init ( & asoc -> peer . tsn_map , SCTP_TSN_MAP_INITIAL , asoc -> peer . i . initial_tsn , GFP_ATOMIC ) ; list_for_each_safe ( pos , temp , & asoc -> peer . transport_addr_list ) { trans = list_entry ( pos , struct sctp_transport , transports ) ; if ( ! sctp_assoc_lookup_paddr ( new , & trans -> ipaddr ) ) { sctp_assoc_rm_peer ( asoc , trans ) ; continue ; } if ( asoc -> state >= SCTP_STATE_ESTABLISHED ) sctp_transport_reset ( trans ) ; } if ( asoc -> state >= SCTP_STATE_ESTABLISHED ) { asoc -> next_tsn = new -> next_tsn ; asoc -> ctsn_ack_point = new -> ctsn_ack_point ; asoc -> adv_peer_ack_point = new -> adv_peer_ack_point ; sctp_ssnmap_clear ( asoc -> ssnmap ) ; sctp_ulpq_flush ( & asoc -> ulpq ) ; asoc -> overall_error_count = 0 ; } else { list_for_each_entry ( trans , & new -> peer . transport_addr_list , transports ) { if ( ! sctp_assoc_lookup_paddr ( asoc , & trans -> ipaddr ) ) sctp_assoc_add_peer ( asoc , & trans -> ipaddr , GFP_ATOMIC , trans -> state ) ; } asoc -> ctsn_ack_point = asoc -> next_tsn - 1 ; asoc -> adv_peer_ack_point = asoc -> ctsn_ack_point ; if ( ! asoc -> ssnmap ) { asoc -> ssnmap = new -> ssnmap ; new -> ssnmap = NULL ; } if ( ! asoc -> assoc_id ) { sctp_assoc_set_id ( asoc , GFP_ATOMIC ) ; } } kfree ( asoc -> peer . peer_random ) ; asoc -> peer . peer_random = new -> peer . peer_random ; new -> peer . peer_random = NULL ; kfree ( asoc -> peer . peer_chunks ) ; asoc -> peer . peer_chunks = new -> peer . peer_chunks ; new -> peer . peer_chunks = NULL ; kfree ( asoc -> peer . peer_hmacs ) ; asoc -> peer . peer_hmacs = new -> peer . peer_hmacs ; new -> peer . peer_hmacs = NULL ; sctp_auth_key_put ( asoc -> asoc_shared_key ) ; sctp_auth_asoc_init_active_key ( asoc , GFP_ATOMIC ) ; } "," = NULL ; sctp_auth_asoc_init_active_key ( asoc ",torvalds@linux/600ddd6825543962fb807884169e57b580dba208,CVE-2015-1421,https://github.com/torvalds/linux/commit/600ddd6825543962fb807884169e57b580dba208,2015-03-16T10:59Z 168,CWE-284,"CWE-284 static bool ndp_msg_check_valid ( struct ndp_msg * msg ) { size_t len = ndp_msg_payload_len ( msg ) ; enum ndp_msg_type msg_type = ndp_msg_type ( msg ) ; if ( len < ndp_msg_type_info ( msg_type ) -> raw_struct_size ) return false ; return true ; } "," return false ; if ( ndp_msg_type_info ( msg_type ) -> addrto_validate ) return ndp_msg_type_info ( msg_type ) -> addrto_validate ( & msg -> addrto ) ; else ",jpirko@libndp/2af9a55b38b55abbf05fd116ec097d4029115839,CVE-2016-3698,https://github.com/jpirko/libndp/commit/2af9a55b38b55abbf05fd116ec097d4029115839,2016-06-13T19:59Z 169,CWE-264,"CWE-264 int lsm_set_label_at ( int procfd , int on_exec , char * lsm_label ) { int labelfd = - 1 ; int ret = 0 ; const char * name ; char * command = NULL ; name = lsm_name ( ) ; if ( strcmp ( name , ""nop"" ) == 0 ) goto out ; if ( strcmp ( name , ""none"" ) == 0 ) goto out ; if ( strcmp ( name , ""AppArmor"" ) == 0 ) on_exec = 0 ; if ( on_exec ) { labelfd = openat ( procfd , ""self/attr/exec"" , O_RDWR ) ; } else { labelfd = openat ( procfd , ""self/attr/current"" , O_RDWR ) ; } if ( labelfd < 0 ) { SYSERROR ( ""UnabletoopenLSMlabel"" ) ; ret = - 1 ; goto out ; } if ( strcmp ( name , ""AppArmor"" ) == 0 ) { int size ; command = malloc ( strlen ( lsm_label ) + strlen ( ""changeprofile"" ) + 1 ) ; if ( ! command ) { SYSERROR ( ""Failedtowriteapparmorprofile"" ) ; ret = - 1 ; goto out ; } size = sprintf ( command , ""changeprofile%s"" , lsm_label ) ; if ( size < 0 ) { SYSERROR ( ""Failedtowriteapparmorprofile"" ) ; ret = - 1 ; goto out ; } if ( write ( labelfd , command , size + 1 ) < 0 ) { SYSERROR ( ""UnabletosetLSMlabel"" ) ; ret = - 1 ; goto out ; } } else if ( strcmp ( name , ""SELinux"" ) == 0 ) { if ( write ( labelfd , lsm_label , strlen ( lsm_label ) + 1 ) < 0 ) { SYSERROR ( ""UnabletosetLSMlabel"" ) ; ret = - 1 ; goto out ; } } else { ERROR ( ""UnabletorestorelabelforunknownLSM:%s"" , name ) ; ret = - 1 ; goto out ; } out : free ( command ) ; if ( labelfd != - 1 ) close ( labelfd ) ; return ret ; } "," static lsm_set_label_at ( int lsm_labelfd , int on_exec * lsm_label ) { int fret = - 1 = - 1 ; const char == 0 ) return 0 ; if ( == 0 ) return 0 ; if ( = 0 ; if ( strcmp ""Failedtowriteapparmorprofile"" ) ; goto out ; ""Failedtowriteapparmorprofile"" ) ; goto out ; ( write ( lsm_labelfd , command , { SYSERROR ( ""UnabletosetLSMlabel:%s."" , command ) ; goto out ; } INFO ( ""SetLSMlabelto:%s."" , command ) ; } else if ( strcmp ( name , ""SELinux"" ) == 0 ) { if ( write ( lsm_labelfd , lsm_label , strlen ( lsm_label ) + 1 ) < 0 ) { SYSERROR ( ""UnabletosetLSMlabel"" ) ; goto out ; } INFO ( ""SetLSMlabelto:%s."" , lsm_label ) ; } else { ERROR ( name ) ; goto out ; } fret = 0 ; out : free ; if ( lsm_labelfd != - 1 ) close ( lsm_labelfd ) ; return ) ; return fret ; } ",lxc@lxc/81f466d05f2a89cb4f122ef7f593ff3f279b165c,CVE-2016-8649,https://github.com/lxc/lxc/commit/81f466d05f2a89cb4f122ef7f593ff3f279b165c,2017-05-01T06:59Z 170,CWE-369,"CWE-369 static OPJ_BOOL opj_pi_next_cprl ( opj_pi_iterator_t * pi ) { opj_pi_comp_t * comp = NULL ; opj_pi_resolution_t * res = NULL ; OPJ_UINT32 index = 0 ; if ( ! pi -> first ) { comp = & pi -> comps [ pi -> compno ] ; goto LABEL_SKIP ; } else { pi -> first = 0 ; } for ( pi -> compno = pi -> poc . compno0 ; pi -> compno < pi -> poc . compno1 ; pi -> compno ++ ) { OPJ_UINT32 resno ; comp = & pi -> comps [ pi -> compno ] ; pi -> dx = 0 ; pi -> dy = 0 ; for ( resno = 0 ; resno < comp -> numresolutions ; resno ++ ) { OPJ_UINT32 dx , dy ; res = & comp -> resolutions [ resno ] ; dx = comp -> dx * ( 1u << ( res -> pdx + comp -> numresolutions - 1 - resno ) ) ; dy = comp -> dy * ( 1u << ( res -> pdy + comp -> numresolutions - 1 - resno ) ) ; pi -> dx = ! pi -> dx ? dx : opj_uint_min ( pi -> dx , dx ) ; pi -> dy = ! pi -> dy ? dy : opj_uint_min ( pi -> dy , dy ) ; } if ( ! pi -> tp_on ) { pi -> poc . ty0 = pi -> ty0 ; pi -> poc . tx0 = pi -> tx0 ; pi -> poc . ty1 = pi -> ty1 ; pi -> poc . tx1 = pi -> tx1 ; } for ( pi -> y = pi -> poc . ty0 ; pi -> y < pi -> poc . ty1 ; pi -> y += ( OPJ_INT32 ) ( pi -> dy - ( OPJ_UINT32 ) ( pi -> y % ( OPJ_INT32 ) pi -> dy ) ) ) { for ( pi -> x = pi -> poc . tx0 ; pi -> x < pi -> poc . tx1 ; pi -> x += ( OPJ_INT32 ) ( pi -> dx - ( OPJ_UINT32 ) ( pi -> x % ( OPJ_INT32 ) pi -> dx ) ) ) { for ( pi -> resno = pi -> poc . resno0 ; pi -> resno < opj_uint_min ( pi -> poc . resno1 , comp -> numresolutions ) ; pi -> resno ++ ) { OPJ_UINT32 levelno ; OPJ_INT32 trx0 , try0 ; OPJ_INT32 trx1 , try1 ; OPJ_UINT32 rpx , rpy ; OPJ_INT32 prci , prcj ; res = & comp -> resolutions [ pi -> resno ] ; levelno = comp -> numresolutions - 1 - pi -> resno ; trx0 = opj_int_ceildiv ( pi -> tx0 , ( OPJ_INT32 ) ( comp -> dx << levelno ) ) ; try0 = opj_int_ceildiv ( pi -> ty0 , ( OPJ_INT32 ) ( comp -> dy << levelno ) ) ; trx1 = opj_int_ceildiv ( pi -> tx1 , ( OPJ_INT32 ) ( comp -> dx << levelno ) ) ; try1 = opj_int_ceildiv ( pi -> ty1 , ( OPJ_INT32 ) ( comp -> dy << levelno ) ) ; rpx = res -> pdx + levelno ; rpy = res -> pdy + levelno ; if ( ! ( ( pi -> y % ( OPJ_INT32 ) ( comp -> dy << rpy ) == 0 ) || ( ( pi -> y == pi -> ty0 ) && ( ( try0 << levelno ) % ( 1 << rpy ) ) ) ) ) { continue ; } if ( ! ( ( pi -> x % ( OPJ_INT32 ) ( comp -> dx << rpx ) == 0 ) || ( ( pi -> x == pi -> tx0 ) && ( ( trx0 << levelno ) % ( 1 << rpx ) ) ) ) ) { continue ; } if ( ( res -> pw == 0 ) || ( res -> ph == 0 ) ) { continue ; } if ( ( trx0 == trx1 ) || ( try0 == try1 ) ) { continue ; } prci = opj_int_floordivpow2 ( opj_int_ceildiv ( pi -> x , ( OPJ_INT32 ) ( comp -> dx << levelno ) ) , ( OPJ_INT32 ) res -> pdx ) - opj_int_floordivpow2 ( trx0 , ( OPJ_INT32 ) res -> pdx ) ; prcj = opj_int_floordivpow2 ( opj_int_ceildiv ( pi -> y , ( OPJ_INT32 ) ( comp -> dy << levelno ) ) , ( OPJ_INT32 ) res -> pdy ) - opj_int_floordivpow2 ( try0 , ( OPJ_INT32 ) res -> pdy ) ; pi -> precno = ( OPJ_UINT32 ) ( prci + prcj * ( OPJ_INT32 ) res -> pw ) ; for ( pi -> layno = pi -> poc . layno0 ; pi -> layno < pi -> poc . layno1 ; pi -> layno ++ ) { index = pi -> layno * pi -> step_l + pi -> resno * pi -> step_r + pi -> compno * pi -> step_c + pi -> precno * pi -> step_p ; if ( ! pi -> include [ index ] ) { pi -> include [ index ] = 1 ; return OPJ_TRUE ; } LABEL_SKIP : ; } } } } } return OPJ_FALSE ; } "," ; if ( rpx >= 31 || ( ( comp -> dx << rpx ) >> rpx ) != comp -> dx || rpy >= 31 || ( ( comp -> dy << rpy ) >> rpy ) != comp -> dy ) { continue ; } if ( ",uclouvain@openjpeg/d27ccf01c68a31ad62b33d2dc1ba2bb1eeaafe7b,CVE-2016-10506,https://github.com/uclouvain/openjpeg/commit/d27ccf01c68a31ad62b33d2dc1ba2bb1eeaafe7b,2017-08-30T09:29Z 171,CWE-399,"CWE-399 static void record_and_restart ( struct perf_event * event , unsigned long val , struct pt_regs * regs , int nmi ) { u64 period = event -> hw . sample_period ; s64 prev , delta , left ; int record = 0 ; if ( event -> hw . state & PERF_HES_STOPPED ) { write_pmc ( event -> hw . idx , 0 ) ; return ; } prev = local64_read ( & event -> hw . prev_count ) ; delta = check_and_compute_delta ( prev , val ) ; local64_add ( delta , & event -> count ) ; val = 0 ; left = local64_read ( & event -> hw . period_left ) - delta ; if ( period ) { if ( left <= 0 ) { left += period ; if ( left <= 0 ) left = period ; record = 1 ; event -> hw . last_period = event -> hw . sample_period ; } if ( left < 0x80000000LL ) val = 0x80000000LL - left ; } write_pmc ( event -> hw . idx , val ) ; local64_set ( & event -> hw . prev_count , val ) ; local64_set ( & event -> hw . period_left , left ) ; perf_event_update_userpage ( event ) ; if ( record ) { struct perf_sample_data data ; perf_sample_data_init ( & data , ~ 0ULL ) ; data . period = event -> hw . last_period ; if ( event -> attr . sample_type & PERF_SAMPLE_ADDR ) perf_get_data_addr ( regs , & data . addr ) ; if ( perf_event_overflow ( event , nmi , & data , regs ) ) power_pmu_stop ( event , 0 ) ; } } "," pt_regs * regs ) { u64 ( event , & data , ",torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,CVE-2011-2918,https://github.com/torvalds/linux/commit/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,2012-05-24T23:55Z 172,CWE-119,"CWE-119 void vp9_twopass_postencode_update ( VP9_COMP * cpi ) { # ifdef DISABLE_RC_LONG_TERM_MEM const uint64_t bits_used = cpi -> rc . this_frame_target ; # else const uint64_t bits_used = cpi -> rc . projected_frame_size ; # endif cpi -> twopass . bits_left -= bits_used ; cpi -> twopass . bits_left = MAX ( cpi -> twopass . bits_left , 0 ) ; if ( cpi -> common . frame_type == KEY_FRAME ) { cpi -> twopass . kf_group_bits += cpi -> rc . this_frame_target - bits_used ; } else { cpi -> twopass . kf_group_bits -= bits_used ; cpi -> twopass . gf_group_bits -= bits_used ; cpi -> twopass . gf_group_bits = MAX ( cpi -> twopass . gf_group_bits , 0 ) ; } cpi -> twopass . kf_group_bits = MAX ( cpi -> twopass . kf_group_bits , 0 ) ; } "," cpi ) { TWO_PASS * const twopass = & cpi -> twopass ; RATE_CONTROL * const rc = & cpi -> rc ; const int bits_used = rc -> base_frame_target ; rc -> vbr_bits_off_target += rc -> base_frame_target - rc -> projected_frame_size ; twopass -> bits_left = MAX ( twopass -> bits_left - bits_used , 0 ) ; if ( rc -> total_actual_bits ) { rc -> rate_error_estimate = ( int ) ( ( rc -> vbr_bits_off_target * 100 ) / rc -> total_actual_bits ) ; rc -> rate_error_estimate = clamp ( rc -> rate_error_estimate , - 100 , 100 ) ; } else { rc -> rate_error_estimate = 0 ; } if ( cpi common . frame_type != KEY_FRAME && ! vp9_is_upper_layer_key_frame ( cpi ) ) { twopass -> kf_group_bits -= bits_used -= bits_used ; twopass -> last_kfgroup_zeromotion_pct = twopass -> kf_zeromotion_pct ; } twopass -> kf_group_bits = MAX ( = MAX ( twopass -> kf_group_bits , 0 ) 0 ) ; ++ twopass -> gf_group . index ; if ( ( cpi -> oxcf . rc_mode != VPX_Q ) && ( cpi -> twopass . gf_zeromotion_pct < VLOW_MOTION_THRESHOLD ) && ! cpi -> rc . is_src_frame_alt_ref ) { const int maxq_adj_limit = rc -> worst_quality - twopass -> active_worst_quality ; const int minq_adj_limit = ( cpi -> oxcf . rc_mode == VPX_CQ ? MINQ_ADJ_LIMIT_CQ : MINQ_ADJ_LIMIT ) ; if ( rc -> rate_error_estimate > cpi -> oxcf . under_shoot_pct ) { -- twopass -> extend_maxq ; if ( rc -> rolling_target_bits >= rc -> rolling_actual_bits ) ++ twopass -> extend_minq ; } else if ( rc -> rate_error_estimate < - cpi -> oxcf . over_shoot_pct ) { -- twopass -> extend_minq ; if ( rc -> rolling_target_bits < rc -> rolling_actual_bits ) ++ twopass -> extend_maxq ; } else { if ( rc -> projected_frame_size > ( 2 * rc -> base_frame_target ) && rc -> projected_frame_size > ( 2 * rc -> avg_frame_bandwidth ) ) ++ twopass -> extend_maxq ; if ( rc -> rolling_target_bits < rc -> rolling_actual_bits ) -- twopass -> extend_minq ; else if ( rc -> rolling_target_bits > rc -> rolling_actual_bits ) -- twopass -> extend_maxq ; } twopass -> extend_minq = clamp ( twopass -> extend_minq , 0 , minq_adj_limit ) ; twopass -> extend_maxq = clamp ( twopass -> extend_maxq , 0 , maxq_adj_limit ) ; if ( ! frame_is_kf_gf_arf ( cpi ) && ! cpi -> rc . is_src_frame_alt_ref ) { int fast_extra_thresh = rc -> base_frame_target / HIGH_UNDERSHOOT_RATIO ; if ( rc -> projected_frame_size < fast_extra_thresh ) { rc -> vbr_bits_off_target_fast += fast_extra_thresh - rc -> projected_frame_size ; rc -> vbr_bits_off_target_fast = MIN ( rc -> vbr_bits_off_target_fast , ( 4 * rc -> avg_frame_bandwidth ) ) ; if ( rc -> avg_frame_bandwidth ) { twopass -> extend_minq_fast = ( int ) ( rc -> vbr_bits_off_target_fast * 8 / rc -> avg_frame_bandwidth ) ; } twopass -> extend_minq_fast = MIN ( twopass -> extend_minq_fast , minq_adj_limit - twopass -> extend_minq ) ; } else if ( rc -> vbr_bits_off_target_fast ) { twopass -> extend_minq_fast = MIN ( twopass -> extend_minq_fast , minq_adj_limit - twopass -> extend_minq ) ; } else { twopass -> extend_minq_fast = 0 ; } } } } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 173,CWE-189,"CWE-189 Datum lquery_in ( PG_FUNCTION_ARGS ) { char * buf = ( char * ) PG_GETARG_POINTER ( 0 ) ; char * ptr ; int num = 0 , totallen = 0 , numOR = 0 ; int state = LQPRS_WAITLEVEL ; lquery * result ; nodeitem * lptr = NULL ; lquery_level * cur , * curqlevel , * tmpql ; lquery_variant * lrptr = NULL ; bool hasnot = false ; bool wasbad = false ; int charlen ; int pos = 0 ; ptr = buf ; while ( * ptr ) { charlen = pg_mblen ( ptr ) ; if ( charlen == 1 ) { if ( t_iseq ( ptr , '.' ) ) num ++ ; else if ( t_iseq ( ptr , '|' ) ) numOR ++ ; } ptr += charlen ; } num ++ ; curqlevel = tmpql = ( lquery_level * ) palloc0 ( ITEMSIZE * num ) ; ptr = buf ; while ( * ptr ) { charlen = pg_mblen ( ptr ) ; if ( state == LQPRS_WAITLEVEL ) { if ( ISALNUM ( ptr ) ) { GETVAR ( curqlevel ) = lptr = ( nodeitem * ) palloc0 ( sizeof ( nodeitem ) * ( numOR + 1 ) ) ; lptr -> start = ptr ; state = LQPRS_WAITDELIM ; curqlevel -> numvar = 1 ; } else if ( charlen == 1 && t_iseq ( ptr , '!' ) ) { GETVAR ( curqlevel ) = lptr = ( nodeitem * ) palloc0 ( sizeof ( nodeitem ) * ( numOR + 1 ) ) ; lptr -> start = ptr + 1 ; state = LQPRS_WAITDELIM ; curqlevel -> numvar = 1 ; curqlevel -> flag |= LQL_NOT ; hasnot = true ; } else if ( charlen == 1 && t_iseq ( ptr , '*' ) ) state = LQPRS_WAITOPEN ; else UNCHAR ; } else if ( state == LQPRS_WAITVAR ) { if ( ISALNUM ( ptr ) ) { lptr ++ ; lptr -> start = ptr ; state = LQPRS_WAITDELIM ; curqlevel -> numvar ++ ; } else UNCHAR ; } else if ( state == LQPRS_WAITDELIM ) { if ( charlen == 1 && t_iseq ( ptr , '@' ) ) { if ( lptr -> start == ptr ) UNCHAR ; lptr -> flag |= LVAR_INCASE ; curqlevel -> flag |= LVAR_INCASE ; } else if ( charlen == 1 && t_iseq ( ptr , '*' ) ) { if ( lptr -> start == ptr ) UNCHAR ; lptr -> flag |= LVAR_ANYEND ; curqlevel -> flag |= LVAR_ANYEND ; } else if ( charlen == 1 && t_iseq ( ptr , '%' ) ) { if ( lptr -> start == ptr ) UNCHAR ; lptr -> flag |= LVAR_SUBLEXEME ; curqlevel -> flag |= LVAR_SUBLEXEME ; } else if ( charlen == 1 && t_iseq ( ptr , '|' ) ) { lptr -> len = ptr - lptr -> start - ( ( lptr -> flag & LVAR_SUBLEXEME ) ? 1 : 0 ) - ( ( lptr -> flag & LVAR_INCASE ) ? 1 : 0 ) - ( ( lptr -> flag & LVAR_ANYEND ) ? 1 : 0 ) ; if ( lptr -> wlen > 255 ) ereport ( ERROR , ( errcode ( ERRCODE_NAME_TOO_LONG ) , errmsg ( ""nameoflevelistoolong"" ) , errdetail ( ""Namelengthis%d,must"" ""be<256,inposition%d."" , lptr -> wlen , pos ) ) ) ; state = LQPRS_WAITVAR ; } else if ( charlen == 1 && t_iseq ( ptr , '.' ) ) { lptr -> len = ptr - lptr -> start - ( ( lptr -> flag & LVAR_SUBLEXEME ) ? 1 : 0 ) - ( ( lptr -> flag & LVAR_INCASE ) ? 1 : 0 ) - ( ( lptr -> flag & LVAR_ANYEND ) ? 1 : 0 ) ; if ( lptr -> wlen > 255 ) ereport ( ERROR , ( errcode ( ERRCODE_NAME_TOO_LONG ) , errmsg ( ""nameoflevelistoolong"" ) , errdetail ( ""Namelengthis%d,must"" ""be<256,inposition%d."" , lptr -> wlen , pos ) ) ) ; state = LQPRS_WAITLEVEL ; curqlevel = NEXTLEV ( curqlevel ) ; } else if ( ISALNUM ( ptr ) ) { if ( lptr -> flag ) UNCHAR ; } else UNCHAR ; } else if ( state == LQPRS_WAITOPEN ) { if ( charlen == 1 && t_iseq ( ptr , '{' ) ) state = LQPRS_WAITFNUM ; else if ( charlen == 1 && t_iseq ( ptr , '.' ) ) { curqlevel -> low = 0 ; curqlevel -> high = 0xffff ; curqlevel = NEXTLEV ( curqlevel ) ; state = LQPRS_WAITLEVEL ; } else UNCHAR ; } else if ( state == LQPRS_WAITFNUM ) { if ( charlen == 1 && t_iseq ( ptr , ',' ) ) state = LQPRS_WAITSNUM ; else if ( t_isdigit ( ptr ) ) { curqlevel -> low = atoi ( ptr ) ; state = LQPRS_WAITND ; } else UNCHAR ; } else if ( state == LQPRS_WAITSNUM ) { if ( t_isdigit ( ptr ) ) { curqlevel -> high = atoi ( ptr ) ; state = LQPRS_WAITCLOSE ; } else if ( charlen == 1 && t_iseq ( ptr , '}' ) ) { curqlevel -> high = 0xffff ; state = LQPRS_WAITEND ; } else UNCHAR ; } else if ( state == LQPRS_WAITCLOSE ) { if ( charlen == 1 && t_iseq ( ptr , '}' ) ) state = LQPRS_WAITEND ; else if ( ! t_isdigit ( ptr ) ) UNCHAR ; } else if ( state == LQPRS_WAITND ) { if ( charlen == 1 && t_iseq ( ptr , '}' ) ) { curqlevel -> high = curqlevel -> low ; state = LQPRS_WAITEND ; } else if ( charlen == 1 && t_iseq ( ptr , ',' ) ) state = LQPRS_WAITSNUM ; else if ( ! t_isdigit ( ptr ) ) UNCHAR ; } else if ( state == LQPRS_WAITEND ) { if ( charlen == 1 && t_iseq ( ptr , '.' ) ) { state = LQPRS_WAITLEVEL ; curqlevel = NEXTLEV ( curqlevel ) ; } else UNCHAR ; } else elog ( ERROR , ""internalerrorinparser"" ) ; ptr += charlen ; if ( state == LQPRS_WAITDELIM ) lptr -> wlen ++ ; pos ++ ; } if ( state == LQPRS_WAITDELIM ) { if ( lptr -> start == ptr ) ereport ( ERROR , ( errcode ( ERRCODE_SYNTAX_ERROR ) , errmsg ( ""syntaxerror"" ) , errdetail ( ""Unexpectedendofline."" ) ) ) ; lptr -> len = ptr - lptr -> start - ( ( lptr -> flag & LVAR_SUBLEXEME ) ? 1 : 0 ) - ( ( lptr -> flag & LVAR_INCASE ) ? 1 : 0 ) - ( ( lptr -> flag & LVAR_ANYEND ) ? 1 : 0 ) ; if ( lptr -> len == 0 ) ereport ( ERROR , ( errcode ( ERRCODE_SYNTAX_ERROR ) , errmsg ( ""syntaxerror"" ) , errdetail ( ""Unexpectedendofline."" ) ) ) ; if ( lptr -> wlen > 255 ) ereport ( ERROR , ( errcode ( ERRCODE_NAME_TOO_LONG ) , errmsg ( ""nameoflevelistoolong"" ) , errdetail ( ""Namelengthis%d,must"" ""be<256,inposition%d."" , lptr -> wlen , pos ) ) ) ; } else if ( state == LQPRS_WAITOPEN ) curqlevel -> high = 0xffff ; else if ( state != LQPRS_WAITEND ) ereport ( ERROR , ( errcode ( ERRCODE_SYNTAX_ERROR ) , errmsg ( ""syntaxerror"" ) , errdetail ( ""Unexpectedendofline."" ) ) ) ; curqlevel = tmpql ; totallen = LQUERY_HDRSIZE ; while ( ( char * ) curqlevel - ( char * ) tmpql < num * ITEMSIZE ) { totallen += LQL_HDRSIZE ; if ( curqlevel -> numvar ) { lptr = GETVAR ( curqlevel ) ; while ( lptr - GETVAR ( curqlevel ) < curqlevel -> numvar ) { totallen += MAXALIGN ( LVAR_HDRSIZE + lptr -> len ) ; lptr ++ ; } } else if ( curqlevel -> low > curqlevel -> high ) ereport ( ERROR , ( errcode ( ERRCODE_SYNTAX_ERROR ) , errmsg ( ""syntaxerror"" ) , errdetail ( ""Lowlimit(%d)isgreaterthanupper(%d)."" , curqlevel -> low , curqlevel -> high ) ) ) ; curqlevel = NEXTLEV ( curqlevel ) ; } result = ( lquery * ) palloc0 ( totallen ) ; SET_VARSIZE ( result , totallen ) ; result -> numlevel = num ; result -> firstgood = 0 ; result -> flag = 0 ; if ( hasnot ) result -> flag |= LQUERY_HASNOT ; cur = LQUERY_FIRST ( result ) ; curqlevel = tmpql ; while ( ( char * ) curqlevel - ( char * ) tmpql < num * ITEMSIZE ) { memcpy ( cur , curqlevel , LQL_HDRSIZE ) ; cur -> totallen = LQL_HDRSIZE ; if ( curqlevel -> numvar ) { lrptr = LQL_FIRST ( cur ) ; lptr = GETVAR ( curqlevel ) ; while ( lptr - GETVAR ( curqlevel ) < curqlevel -> numvar ) { cur -> totallen += MAXALIGN ( LVAR_HDRSIZE + lptr -> len ) ; lrptr -> len = lptr -> len ; lrptr -> flag = lptr -> flag ; lrptr -> val = ltree_crc32_sz ( lptr -> start , lptr -> len ) ; memcpy ( lrptr -> name , lptr -> start , lptr -> len ) ; lptr ++ ; lrptr = LVAR_NEXT ( lrptr ) ; } pfree ( GETVAR ( curqlevel ) ) ; if ( cur -> numvar > 1 || cur -> flag != 0 ) wasbad = true ; else if ( wasbad == false ) ( result -> firstgood ) ++ ; } else wasbad = true ; curqlevel = NEXTLEV ( curqlevel ) ; cur = LQL_NEXT ( cur ) ; } pfree ( tmpql ) ; PG_RETURN_POINTER ( result ) ; } "," } num ++ ; if ( num > MaxAllocSize / ITEMSIZE ) ereport ( ERROR , ( errcode ( ERRCODE_PROGRAM_LIMIT_EXCEEDED ) , errmsg ( ""numberoflevels(%d)exceedsthemaximumallowed(%d)"" , num , ( int ) ( MaxAllocSize / ITEMSIZE ) ) ) ) ",postgres@postgres/31400a673325147e1205326008e32135a78b4d8a,CVE-2014-2669,https://github.com/postgres/postgres/commit/31400a673325147e1205326008e32135a78b4d8a,2014-03-31T14:58Z 174,CWE-19,"CWE-19 static struct buffer_head * ext4_xattr_cache_find ( struct inode * inode , struct ext4_xattr_header * header , struct mb_cache_entry * * pce ) { __u32 hash = le32_to_cpu ( header -> h_hash ) ; struct mb_cache_entry * ce ; struct mb_cache * ext4_mb_cache = EXT4_GET_MB_CACHE ( inode ) ; if ( ! header -> h_hash ) return NULL ; ea_idebug ( inode , ""lookingforcachedblocks[%x]"" , ( int ) hash ) ; again : ce = mb_cache_entry_find_first ( ext4_mb_cache , inode -> i_sb -> s_bdev , hash ) ; while ( ce ) { struct buffer_head * bh ; if ( IS_ERR ( ce ) ) { if ( PTR_ERR ( ce ) == - EAGAIN ) goto again ; break ; } bh = sb_bread ( inode -> i_sb , ce -> e_block ) ; if ( ! bh ) { EXT4_ERROR_INODE ( inode , ""block%lureaderror"" , ( unsigned long ) ce -> e_block ) ; } else if ( le32_to_cpu ( BHDR ( bh ) -> h_refcount ) >= EXT4_XATTR_REFCOUNT_MAX ) { ea_idebug ( inode , ""block%lurefcount%d>=%d"" , ( unsigned long ) ce -> e_block , le32_to_cpu ( BHDR ( bh ) -> h_refcount ) , EXT4_XATTR_REFCOUNT_MAX ) ; } else if ( ext4_xattr_cmp ( header , BHDR ( bh ) ) == 0 ) { * pce = ce ; return bh ; } brelse ( bh ) ; ce = mb_cache_entry_find_next ( ce , inode -> i_sb -> s_bdev , hash ) ; } return NULL ; } "," header , struct mb2_cache_entry * * pce ) ; struct mb2_cache_entry * ce ; struct mb2_cache * ext4_mb_cache = hash ) ; ce = mb2_cache_entry_find_first ( ext4_mb_cache , ( ext4_mb_cache , hash ) ; * bh ; bh = sb_bread ; ce = mb2_cache_entry_find_next ( ext4_mb_cache , ce ) ; } ",torvalds@linux/82939d7999dfc1f1998c4b1c12e2f19edbdff272,CVE-2015-8952,https://github.com/torvalds/linux/commit/82939d7999dfc1f1998c4b1c12e2f19edbdff272,2016-10-16T21:59Z 175,CWE-119,"CWE-119 static gboolean cosine_read ( wtap * wth , int * err , gchar * * err_info , gint64 * data_offset ) { gint64 offset ; int pkt_len ; char line [ COSINE_LINE_LENGTH ] ; offset = cosine_seek_next_packet ( wth , err , err_info , line ) ; if ( offset < 0 ) return FALSE ; * data_offset = offset ; pkt_len = parse_cosine_rec_hdr ( & wth -> phdr , line , err , err_info ) ; if ( pkt_len == - 1 ) return FALSE ; return parse_cosine_hex_dump ( wth -> fh , & wth -> phdr , pkt_len , wth -> frame_buffer , err , err_info ) ; } "," { gint64 offset ; char line = offset ; return parse_cosine_packet ( wth -> -> phdr , wth -> frame_buffer wth -> frame_buffer , line ",wireshark@wireshark/f5ec0afb766f19519ea9623152cca3bbe2229500,CVE-2016-5356,https://github.com/wireshark/wireshark/commit/f5ec0afb766f19519ea9623152cca3bbe2229500,2016-08-07T16:59Z 176,CWE-476,"CWE-476 static int add_push_report_sideband_pkt ( git_push * push , git_pkt_data * data_pkt , git_buf * data_pkt_buf ) { git_pkt * pkt ; const char * line , * line_end = NULL ; size_t line_len ; int error ; int reading_from_buf = data_pkt_buf -> size > 0 ; if ( reading_from_buf ) { git_buf_put ( data_pkt_buf , data_pkt -> data , data_pkt -> len ) ; line = data_pkt_buf -> ptr ; line_len = data_pkt_buf -> size ; } else { line = data_pkt -> data ; line_len = data_pkt -> len ; } while ( line_len > 0 ) { error = git_pkt_parse_line ( & pkt , line , & line_end , line_len ) ; if ( error == GIT_EBUFS ) { if ( ! reading_from_buf ) git_buf_put ( data_pkt_buf , line , line_len ) ; error = 0 ; goto done ; } else if ( error < 0 ) goto done ; line_len -= ( line_end - line ) ; line = line_end ; if ( pkt == NULL ) continue ; error = add_push_report_pkt ( push , pkt ) ; git_pkt_free ( pkt ) ; if ( error < 0 && error != GIT_ITEROVER ) goto done ; } error = 0 ; done : if ( reading_from_buf ) git_buf_consume ( data_pkt_buf , line_end ) ; return error ; } "," = line_end ; error = add_push_report_pkt ",libgit2@libgit2/2fdef641fd0dd2828bd948234ae86de75221a11a,CVE-2016-10129,https://github.com/libgit2/libgit2/commit/2fdef641fd0dd2828bd948234ae86de75221a11a,2017-03-24T15:59Z 177,CWE-000,"CWE-000 int ssl3_read_n ( SSL * s , int n , int max , int extend ) { int i , len , left ; long align = 0 ; unsigned char * pkt ; SSL3_BUFFER * rb ; if ( n <= 0 ) return n ; rb = & ( s -> s3 -> rbuf ) ; if ( rb -> buf == NULL ) if ( ! ssl3_setup_read_buffer ( s ) ) return - 1 ; left = rb -> left ; # if defined ( SSL3_ALIGN_PAYLOAD ) && SSL3_ALIGN_PAYLOAD != 0 align = ( long ) rb -> buf + SSL3_RT_HEADER_LENGTH ; align = ( - align ) & ( SSL3_ALIGN_PAYLOAD - 1 ) ; # endif if ( ! extend ) { if ( left == 0 ) rb -> offset = align ; else if ( align != 0 && left >= SSL3_RT_HEADER_LENGTH ) { pkt = rb -> buf + rb -> offset ; if ( pkt [ 0 ] == SSL3_RT_APPLICATION_DATA && ( pkt [ 3 ] << 8 | pkt [ 4 ] ) >= 128 ) { memmove ( rb -> buf + align , pkt , left ) ; rb -> offset = align ; } } s -> packet = rb -> buf + rb -> offset ; s -> packet_length = 0 ; } if ( SSL_IS_DTLS ( s ) ) { if ( left > 0 && n > left ) n = left ; } if ( left >= n ) { s -> packet_length += n ; rb -> left = left - n ; rb -> offset += n ; return ( n ) ; } len = s -> packet_length ; pkt = rb -> buf + align ; if ( s -> packet != pkt ) { memmove ( pkt , s -> packet , len + left ) ; s -> packet = pkt ; rb -> offset = len + align ; } if ( n > ( int ) ( rb -> len - rb -> offset ) ) { SSLerr ( SSL_F_SSL3_READ_N , ERR_R_INTERNAL_ERROR ) ; return - 1 ; } if ( ! s -> read_ahead ) max = n ; else { if ( max < n ) max = n ; if ( max > ( int ) ( rb -> len - rb -> offset ) ) max = rb -> len - rb -> offset ; } while ( left < n ) { clear_sys_error ( ) ; if ( s -> rbio != NULL ) { s -> rwstate = SSL_READING ; i = BIO_read ( s -> rbio , pkt + len + left , max - left ) ; } else { SSLerr ( SSL_F_SSL3_READ_N , SSL_R_READ_BIO_NOT_SET ) ; i = - 1 ; } if ( i <= 0 ) { rb -> left = left ; if ( s -> mode & SSL_MODE_RELEASE_BUFFERS && ! SSL_IS_DTLS ( s ) ) if ( len + left == 0 ) ssl3_release_read_buffer ( s ) ; return ( i ) ; } left += i ; if ( SSL_IS_DTLS ( s ) ) { if ( n > left ) n = left ; } } rb -> offset += n ; rb -> left = left - n ; s -> packet_length += n ; s -> rwstate = SSL_NOTHING ; return ( n ) ; } "," if ( left == 0 && extend ) return 0 ; if ( left ",openssl@openssl/feba02f3919495e1b960c33ba849e10e77d0785d,CVE-2014-3571,https://github.com/openssl/openssl/commit/feba02f3919495e1b960c33ba849e10e77d0785d,2015-01-09T02:59Z 178,CWE-119,"CWE-119 static grub_disk_addr_t grub_ext2_read_block ( grub_fshelp_node_t node , grub_disk_addr_t fileblock ) { struct grub_ext2_data * data = node -> data ; struct grub_ext2_inode * inode = & node -> inode ; int blknr = - 1 ; unsigned int blksz = EXT2_BLOCK_SIZE ( data ) ; int log2_blksz = LOG2_EXT2_BLOCK_SIZE ( data ) ; if ( grub_le_to_cpu32 ( inode -> flags ) & EXT4_EXTENTS_FLAG ) { # ifndef _MSC_VER char buf [ EXT2_BLOCK_SIZE ( data ) ] ; # else char * buf = grub_malloc ( EXT2_BLOCK_SIZE ( data ) ) ; # endif struct grub_ext4_extent_header * leaf ; struct grub_ext4_extent * ext ; int i ; leaf = grub_ext4_find_leaf ( data , buf , ( struct grub_ext4_extent_header * ) inode -> blocks . dir_blocks , fileblock ) ; if ( ! leaf ) { grub_error ( GRUB_ERR_BAD_FS , ""invalidextent"" ) ; return - 1 ; } ext = ( struct grub_ext4_extent * ) ( leaf + 1 ) ; for ( i = 0 ; i < grub_le_to_cpu16 ( leaf -> entries ) ; i ++ ) { if ( fileblock < grub_le_to_cpu32 ( ext [ i ] . block ) ) break ; } if ( -- i >= 0 ) { fileblock -= grub_le_to_cpu32 ( ext [ i ] . block ) ; if ( fileblock >= grub_le_to_cpu16 ( ext [ i ] . len ) ) return 0 ; else { grub_disk_addr_t start ; start = grub_le_to_cpu16 ( ext [ i ] . start_hi ) ; start = ( start << 32 ) + grub_le_to_cpu32 ( ext [ i ] . start ) ; return fileblock + start ; } } else { grub_error ( GRUB_ERR_BAD_FS , ""somethingwrongwithextent"" ) ; return - 1 ; } } if ( fileblock < INDIRECT_BLOCKS ) { blknr = grub_le_to_cpu32 ( inode -> blocks . dir_blocks [ fileblock ] ) ; } else if ( fileblock < INDIRECT_BLOCKS + blksz / 4 ) { grub_uint32_t * indir ; indir = grub_malloc ( blksz ) ; if ( ! indir ) return grub_errno ; if ( grub_disk_read ( data -> disk , ( ( grub_disk_addr_t ) grub_le_to_cpu32 ( inode -> blocks . indir_block ) ) << log2_blksz , 0 , blksz , indir ) ) return grub_errno ; blknr = grub_le_to_cpu32 ( indir [ fileblock - INDIRECT_BLOCKS ] ) ; grub_free ( indir ) ; } else if ( fileblock < ( grub_disk_addr_t ) ( INDIRECT_BLOCKS + blksz / 4 ) * ( grub_disk_addr_t ) ( blksz / 4 + 1 ) ) { unsigned int perblock = blksz / 4 ; unsigned int rblock = fileblock - ( INDIRECT_BLOCKS + blksz / 4 ) ; grub_uint32_t * indir ; indir = grub_malloc ( blksz ) ; if ( ! indir ) return grub_errno ; if ( grub_disk_read ( data -> disk , ( ( grub_disk_addr_t ) grub_le_to_cpu32 ( inode -> blocks . double_indir_block ) ) << log2_blksz , 0 , blksz , indir ) ) return grub_errno ; if ( grub_disk_read ( data -> disk , ( ( grub_disk_addr_t ) grub_le_to_cpu32 ( indir [ rblock / perblock ] ) ) << log2_blksz , 0 , blksz , indir ) ) return grub_errno ; blknr = grub_le_to_cpu32 ( indir [ rblock % perblock ] ) ; grub_free ( indir ) ; } else { grub_error ( GRUB_ERR_NOT_IMPLEMENTED_YET , ""ext2fsdoesn\'tsupporttripleindirectblocks"" ) ; } return blknr ; } "," EXT4_EXTENTS_FLAG ) { char * buf = grub_malloc ( EXT2_BLOCK_SIZE ( data ( data ) ) ; if ( ! buf ) { return - 1 ; } struct grub_ext4_extent_header * GRUB_ERR_BAD_FS , ""invalidextent"" ) ; free ( buf len ) ) { free ( buf ) ; return 0 ; } start ) ; free ( buf ) ; ""somethingwrongwithextent"" ) ; free ( buf ) ; 1 ; } free ( buf ) ; ! indir ) { return grub_errno ; } indir ) ) { return grub_errno ; } ! indir ) { return grub_errno ; } indir ) ) { return grub_errno ; } indir ) ) { return grub_errno ; } ",radare@radare2/65000a7fd9eea62359e6d6714f17b94a99a82edd,CVE-2017-9763,https://github.com/radare/radare2/commit/65000a7fd9eea62359e6d6714f17b94a99a82edd,2017-06-19T16:29Z 179,CWE-119,"CWE-119 static Image * ReadWPGImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { typedef struct { size_t FileId ; MagickOffsetType DataOffset ; unsigned int ProductType ; unsigned int FileType ; unsigned char MajorVersion ; unsigned char MinorVersion ; unsigned int EncryptKey ; unsigned int Reserved ; } WPGHeader ; typedef struct { unsigned char RecType ; size_t RecordLength ; } WPGRecord ; typedef struct { unsigned char Class ; unsigned char RecType ; size_t Extension ; size_t RecordLength ; } WPG2Record ; typedef struct { unsigned HorizontalUnits ; unsigned VerticalUnits ; unsigned char PosSizePrecision ; } WPG2Start ; typedef struct { unsigned int Width ; unsigned int Height ; unsigned int Depth ; unsigned int HorzRes ; unsigned int VertRes ; } WPGBitmapType1 ; typedef struct { unsigned int Width ; unsigned int Height ; unsigned char Depth ; unsigned char Compression ; } WPG2BitmapType1 ; typedef struct { unsigned int RotAngle ; unsigned int LowLeftX ; unsigned int LowLeftY ; unsigned int UpRightX ; unsigned int UpRightY ; unsigned int Width ; unsigned int Height ; unsigned int Depth ; unsigned int HorzRes ; unsigned int VertRes ; } WPGBitmapType2 ; typedef struct { unsigned int StartIndex ; unsigned int NumOfEntries ; } WPGColorMapRec ; Image * image ; unsigned int status ; WPGHeader Header ; WPGRecord Rec ; WPG2Record Rec2 ; WPG2Start StartWPG ; WPGBitmapType1 BitmapHeader1 ; WPG2BitmapType1 Bitmap2Header1 ; WPGBitmapType2 BitmapHeader2 ; WPGColorMapRec WPG_Palette ; int i , bpp , WPG2Flags ; ssize_t ldblk ; size_t one ; unsigned char * BImgBuff ; tCTM CTM ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; one = 1 ; image = AcquireImage ( image_info , exception ) ; image -> depth = 8 ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } Header . FileId = ReadBlobLSBLong ( image ) ; Header . DataOffset = ( MagickOffsetType ) ReadBlobLSBLong ( image ) ; Header . ProductType = ReadBlobLSBShort ( image ) ; Header . FileType = ReadBlobLSBShort ( image ) ; Header . MajorVersion = ReadBlobByte ( image ) ; Header . MinorVersion = ReadBlobByte ( image ) ; Header . EncryptKey = ReadBlobLSBShort ( image ) ; Header . Reserved = ReadBlobLSBShort ( image ) ; if ( Header . FileId != 0x435057FF || ( Header . ProductType >> 8 ) != 0x16 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( Header . EncryptKey != 0 ) ThrowReaderException ( CoderError , ""EncryptedWPGImageFileNotSupported"" ) ; image -> columns = 1 ; image -> rows = 1 ; image -> colors = 0 ; bpp = 0 ; BitmapHeader2 . RotAngle = 0 ; switch ( Header . FileType ) { case 1 : while ( ! EOFBlob ( image ) ) { ( void ) SeekBlob ( image , Header . DataOffset , SEEK_SET ) ; if ( EOFBlob ( image ) ) break ; Rec . RecType = ( i = ReadBlobByte ( image ) ) ; if ( i == EOF ) break ; Rd_WP_DWORD ( image , & Rec . RecordLength ) ; if ( EOFBlob ( image ) ) break ; Header . DataOffset = TellBlob ( image ) + Rec . RecordLength ; switch ( Rec . RecType ) { case 0x0B : BitmapHeader1 . Width = ReadBlobLSBShort ( image ) ; BitmapHeader1 . Height = ReadBlobLSBShort ( image ) ; if ( ( BitmapHeader1 . Width == 0 ) || ( BitmapHeader1 . Height == 0 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; BitmapHeader1 . Depth = ReadBlobLSBShort ( image ) ; BitmapHeader1 . HorzRes = ReadBlobLSBShort ( image ) ; BitmapHeader1 . VertRes = ReadBlobLSBShort ( image ) ; if ( BitmapHeader1 . HorzRes && BitmapHeader1 . VertRes ) { image -> units = PixelsPerCentimeterResolution ; image -> resolution . x = BitmapHeader1 . HorzRes / 470.0 ; image -> resolution . y = BitmapHeader1 . VertRes / 470.0 ; } image -> columns = BitmapHeader1 . Width ; image -> rows = BitmapHeader1 . Height ; bpp = BitmapHeader1 . Depth ; goto UnpackRaster ; case 0x0E : WPG_Palette . StartIndex = ReadBlobLSBShort ( image ) ; WPG_Palette . NumOfEntries = ReadBlobLSBShort ( image ) ; image -> colors = WPG_Palette . NumOfEntries ; if ( ! AcquireImageColormap ( image , image -> colors , exception ) ) goto NoMemory ; for ( i = WPG_Palette . StartIndex ; i < ( int ) WPG_Palette . NumOfEntries ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; } break ; case 0x11 : if ( Rec . RecordLength > 8 ) image = ExtractPostscript ( image , image_info , TellBlob ( image ) + 8 , ( ssize_t ) Rec . RecordLength - 8 , exception ) ; break ; case 0x14 : BitmapHeader2 . RotAngle = ReadBlobLSBShort ( image ) ; BitmapHeader2 . LowLeftX = ReadBlobLSBShort ( image ) ; BitmapHeader2 . LowLeftY = ReadBlobLSBShort ( image ) ; BitmapHeader2 . UpRightX = ReadBlobLSBShort ( image ) ; BitmapHeader2 . UpRightY = ReadBlobLSBShort ( image ) ; BitmapHeader2 . Width = ReadBlobLSBShort ( image ) ; BitmapHeader2 . Height = ReadBlobLSBShort ( image ) ; if ( ( BitmapHeader2 . Width == 0 ) || ( BitmapHeader2 . Height == 0 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; BitmapHeader2 . Depth = ReadBlobLSBShort ( image ) ; BitmapHeader2 . HorzRes = ReadBlobLSBShort ( image ) ; BitmapHeader2 . VertRes = ReadBlobLSBShort ( image ) ; image -> units = PixelsPerCentimeterResolution ; image -> page . width = ( unsigned int ) ( ( BitmapHeader2 . LowLeftX - BitmapHeader2 . UpRightX ) / 470.0 ) ; image -> page . height = ( unsigned int ) ( ( BitmapHeader2 . LowLeftX - BitmapHeader2 . UpRightY ) / 470.0 ) ; image -> page . x = ( int ) ( BitmapHeader2 . LowLeftX / 470.0 ) ; image -> page . y = ( int ) ( BitmapHeader2 . LowLeftX / 470.0 ) ; if ( BitmapHeader2 . HorzRes && BitmapHeader2 . VertRes ) { image -> resolution . x = BitmapHeader2 . HorzRes / 470.0 ; image -> resolution . y = BitmapHeader2 . VertRes / 470.0 ; } image -> columns = BitmapHeader2 . Width ; image -> rows = BitmapHeader2 . Height ; bpp = BitmapHeader2 . Depth ; UnpackRaster : if ( ( image -> colors == 0 ) && ( bpp != 24 ) ) { image -> colors = one << bpp ; if ( ! AcquireImageColormap ( image , image -> colors , exception ) ) { NoMemory : ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; } for ( i = 0 ; ( i < ( int ) image -> colors ) && ( i < 256 ) ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( WPG1_Palette [ i ] . Red ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( WPG1_Palette [ i ] . Green ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( WPG1_Palette [ i ] . Blue ) ; } } else { if ( bpp < 24 ) if ( ( image -> colors < ( one << bpp ) ) && ( bpp != 24 ) ) image -> colormap = ( PixelInfo * ) ResizeQuantumMemory ( image -> colormap , ( size_t ) ( one << bpp ) , sizeof ( * image -> colormap ) ) ; } if ( bpp == 1 ) { if ( image -> colormap [ 0 ] . red == 0 && image -> colormap [ 0 ] . green == 0 && image -> colormap [ 0 ] . blue == 0 && image -> colormap [ 1 ] . red == 0 && image -> colormap [ 1 ] . green == 0 && image -> colormap [ 1 ] . blue == 0 ) { image -> colormap [ 1 ] . red = image -> colormap [ 1 ] . green = image -> colormap [ 1 ] . blue = QuantumRange ; } } if ( UnpackWPGRaster ( image , bpp , exception ) < 0 ) { DecompressionFailed : ThrowReaderException ( CoderError , ""UnableToDecompressImage"" ) ; } if ( Rec . RecType == 0x14 && BitmapHeader2 . RotAngle != 0 && ! image_info -> ping ) { if ( BitmapHeader2 . RotAngle & 0x8000 ) { Image * flop_image ; flop_image = FlopImage ( image , exception ) ; if ( flop_image != ( Image * ) NULL ) { DuplicateBlob ( flop_image , image ) ; ( void ) RemoveLastImageFromList ( & image ) ; AppendImageToList ( & image , flop_image ) ; } } if ( BitmapHeader2 . RotAngle & 0x2000 ) { Image * flip_image ; flip_image = FlipImage ( image , exception ) ; if ( flip_image != ( Image * ) NULL ) { DuplicateBlob ( flip_image , image ) ; ( void ) RemoveLastImageFromList ( & image ) ; AppendImageToList ( & image , flip_image ) ; } } if ( BitmapHeader2 . RotAngle & 0x0FFF ) { Image * rotate_image ; rotate_image = RotateImage ( image , ( BitmapHeader2 . RotAngle & 0x0FFF ) , exception ) ; if ( rotate_image != ( Image * ) NULL ) { DuplicateBlob ( rotate_image , image ) ; ( void ) RemoveLastImageFromList ( & image ) ; AppendImageToList ( & image , rotate_image ) ; } } } AcquireNextImage ( image_info , image , exception ) ; image -> depth = 8 ; if ( image -> next == ( Image * ) NULL ) goto Finish ; image = SyncNextImageInList ( image ) ; image -> columns = image -> rows = 1 ; image -> colors = 0 ; break ; case 0x1B : if ( Rec . RecordLength > 0x3C ) image = ExtractPostscript ( image , image_info , TellBlob ( image ) + 0x3C , ( ssize_t ) Rec . RecordLength - 0x3C , exception ) ; break ; } } break ; case 2 : ( void ) memset ( CTM , 0 , sizeof ( CTM ) ) ; StartWPG . PosSizePrecision = 0 ; while ( ! EOFBlob ( image ) ) { ( void ) SeekBlob ( image , Header . DataOffset , SEEK_SET ) ; if ( EOFBlob ( image ) ) break ; Rec2 . Class = ( i = ReadBlobByte ( image ) ) ; if ( i == EOF ) break ; Rec2 . RecType = ( i = ReadBlobByte ( image ) ) ; if ( i == EOF ) break ; Rd_WP_DWORD ( image , & Rec2 . Extension ) ; Rd_WP_DWORD ( image , & Rec2 . RecordLength ) ; if ( EOFBlob ( image ) ) break ; Header . DataOffset = TellBlob ( image ) + Rec2 . RecordLength ; switch ( Rec2 . RecType ) { case 1 : StartWPG . HorizontalUnits = ReadBlobLSBShort ( image ) ; StartWPG . VerticalUnits = ReadBlobLSBShort ( image ) ; StartWPG . PosSizePrecision = ReadBlobByte ( image ) ; break ; case 0x0C : WPG_Palette . StartIndex = ReadBlobLSBShort ( image ) ; WPG_Palette . NumOfEntries = ReadBlobLSBShort ( image ) ; image -> colors = WPG_Palette . NumOfEntries ; if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; for ( i = WPG_Palette . StartIndex ; i < ( int ) WPG_Palette . NumOfEntries ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( ( char ) ReadBlobByte ( image ) ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( ( char ) ReadBlobByte ( image ) ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( ( char ) ReadBlobByte ( image ) ) ; ( void ) ReadBlobByte ( image ) ; } break ; case 0x0E : Bitmap2Header1 . Width = ReadBlobLSBShort ( image ) ; Bitmap2Header1 . Height = ReadBlobLSBShort ( image ) ; if ( ( Bitmap2Header1 . Width == 0 ) || ( Bitmap2Header1 . Height == 0 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; Bitmap2Header1 . Depth = ReadBlobByte ( image ) ; Bitmap2Header1 . Compression = ReadBlobByte ( image ) ; if ( Bitmap2Header1 . Compression > 1 ) continue ; switch ( Bitmap2Header1 . Depth ) { case 1 : bpp = 1 ; break ; case 2 : bpp = 2 ; break ; case 3 : bpp = 4 ; break ; case 4 : bpp = 8 ; break ; case 8 : bpp = 24 ; break ; default : continue ; } image -> columns = Bitmap2Header1 . Width ; image -> rows = Bitmap2Header1 . Height ; if ( ( image -> colors == 0 ) && ( bpp != 24 ) ) { size_t one ; one = 1 ; image -> colors = one << bpp ; if ( ! AcquireImageColormap ( image , image -> colors , exception ) ) goto NoMemory ; } else { if ( bpp < 24 ) if ( image -> colors < ( one << bpp ) && bpp != 24 ) image -> colormap = ( PixelInfo * ) ResizeQuantumMemory ( image -> colormap , ( size_t ) ( one << bpp ) , sizeof ( * image -> colormap ) ) ; } switch ( Bitmap2Header1 . Compression ) { case 0 : { ldblk = ( ssize_t ) ( ( bpp * image -> columns + 7 ) / 8 ) ; BImgBuff = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) ldblk + 1 , sizeof ( * BImgBuff ) ) ; if ( BImgBuff == ( unsigned char * ) NULL ) goto NoMemory ; for ( i = 0 ; i < ( ssize_t ) image -> rows ; i ++ ) { ( void ) ReadBlob ( image , ldblk , BImgBuff ) ; InsertRow ( image , BImgBuff , i , bpp , exception ) ; } if ( BImgBuff ) BImgBuff = ( unsigned char * ) RelinquishMagickMemory ( BImgBuff ) ; break ; } case 1 : { if ( UnpackWPG2Raster ( image , bpp , exception ) < 0 ) goto DecompressionFailed ; break ; } } if ( CTM [ 0 ] [ 0 ] < 0 && ! image_info -> ping ) { Image * flop_image ; flop_image = FlopImage ( image , exception ) ; if ( flop_image != ( Image * ) NULL ) { DuplicateBlob ( flop_image , image ) ; ( void ) RemoveLastImageFromList ( & image ) ; AppendImageToList ( & image , flop_image ) ; } } if ( CTM [ 1 ] [ 1 ] < 0 && ! image_info -> ping ) { Image * flip_image ; flip_image = FlipImage ( image , exception ) ; if ( flip_image != ( Image * ) NULL ) { DuplicateBlob ( flip_image , image ) ; ( void ) RemoveLastImageFromList ( & image ) ; AppendImageToList ( & image , flip_image ) ; } } AcquireNextImage ( image_info , image , exception ) ; image -> depth = 8 ; if ( image -> next == ( Image * ) NULL ) goto Finish ; image = SyncNextImageInList ( image ) ; image -> columns = image -> rows = 1 ; image -> colors = 0 ; break ; case 0x12 : i = ReadBlobLSBShort ( image ) ; if ( Rec2 . RecordLength > ( unsigned int ) i ) image = ExtractPostscript ( image , image_info , TellBlob ( image ) + i , ( ssize_t ) ( Rec2 . RecordLength - i - 2 ) , exception ) ; break ; case 0x1B : WPG2Flags = LoadWPG2Flags ( image , StartWPG . PosSizePrecision , NULL , & CTM ) ; ( void ) WPG2Flags ; break ; } } break ; default : { ThrowReaderException ( CoderError , ""DataEncodingSchemeIsNotSupported"" ) ; } } status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; Finish : ( void ) CloseBlob ( image ) ; { Image * p ; ssize_t scene = 0 ; p = image ; image = NULL ; while ( p != ( Image * ) NULL ) { Image * tmp = p ; if ( ( p -> rows == 0 ) || ( p -> columns == 0 ) ) { p = p -> previous ; DeleteImageFromList ( & tmp ) ; } else { image = p ; p = p -> previous ; } } for ( p = image ; p != ( Image * ) NULL ; p = p -> next ) p -> scene = ( size_t ) scene ++ ; } if ( image == ( Image * ) NULL ) ThrowReaderException ( CorruptImageError , ""ImageFileDoesNotContainAnyImageData"" ) ; return ( image ) ; } "," ; UnpackRaster : status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) break ; Bitmap2Header1 . Height ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) break ; } } Finish : ( ",ImageMagick@ImageMagick/fc43974d34318c834fbf78570ca1a3764ed8c7d7,CVE-2016-5688,https://github.com/ImageMagick/ImageMagick/commit/fc43974d34318c834fbf78570ca1a3764ed8c7d7,2016-12-13T15:59Z 180,CWE-362,"CWE-362 static long vbg_misc_device_ioctl ( struct file * filp , unsigned int req , unsigned long arg ) { struct vbg_session * session = filp -> private_data ; size_t returned_size , size ; struct vbg_ioctl_hdr hdr ; bool is_vmmdev_req ; int ret = 0 ; void * buf ; if ( copy_from_user ( & hdr , ( void * ) arg , sizeof ( hdr ) ) ) return - EFAULT ; if ( hdr . version != VBG_IOCTL_HDR_VERSION ) return - EINVAL ; if ( hdr . size_in < sizeof ( hdr ) || ( hdr . size_out && hdr . size_out < sizeof ( hdr ) ) ) return - EINVAL ; size = max ( hdr . size_in , hdr . size_out ) ; if ( _IOC_SIZE ( req ) && _IOC_SIZE ( req ) != size ) return - EINVAL ; if ( size > SZ_16M ) return - E2BIG ; is_vmmdev_req = ( req & ~ IOCSIZE_MASK ) == VBG_IOCTL_VMMDEV_REQUEST ( 0 ) || req == VBG_IOCTL_VMMDEV_REQUEST_BIG ; if ( is_vmmdev_req ) buf = vbg_req_alloc ( size , VBG_IOCTL_HDR_TYPE_DEFAULT ) ; else buf = kmalloc ( size , GFP_KERNEL ) ; if ( ! buf ) return - ENOMEM ; if ( copy_from_user ( buf , ( void * ) arg , hdr . size_in ) ) { ret = - EFAULT ; goto out ; } if ( hdr . size_in < size ) memset ( buf + hdr . size_in , 0 , size - hdr . size_in ) ; ret = vbg_core_ioctl ( session , req , buf ) ; if ( ret ) goto out ; returned_size = ( ( struct vbg_ioctl_hdr * ) buf ) -> size_out ; if ( returned_size > size ) { vbg_debug ( ""%s:toomuchoutputdata%zu>%zu\\n"" , __func__ , returned_size , size ) ; returned_size = size ; } if ( copy_to_user ( ( void * ) arg , buf , returned_size ) != 0 ) ret = - EFAULT ; out : if ( is_vmmdev_req ) vbg_req_free ( buf , size ) ; else kfree ( buf ) ; return ret ; } "," - ENOMEM ; * ( ( struct vbg_ioctl_hdr * ) buf ) = hdr ; copy_from_user ( buf + sizeof ( hdr ) * ) arg + sizeof ( hdr ) , hdr . size_in - sizeof ( hdr ) ) ) { ",torvalds@linux/bd23a7269834dc7c1f93e83535d16ebc44b75eba,CVE-2018-12633,https://github.com/torvalds/linux/commit/bd23a7269834dc7c1f93e83535d16ebc44b75eba,2018-06-22T00:29Z 181,CWE-119,"CWE-119 void jpc_qmfb_split_colgrp ( jpc_fix_t * a , int numrows , int stride , int parity ) { int bufsize = JPC_CEILDIVPOW2 ( numrows , 1 ) ; jpc_fix_t splitbuf [ QMFB_SPLITBUFSIZE * JPC_QMFB_COLGRPSIZE ] ; jpc_fix_t * buf = splitbuf ; jpc_fix_t * srcptr ; jpc_fix_t * dstptr ; register jpc_fix_t * srcptr2 ; register jpc_fix_t * dstptr2 ; register int n ; register int i ; int m ; int hstartcol ; if ( bufsize > QMFB_SPLITBUFSIZE ) { if ( ! ( buf = jas_alloc2 ( bufsize , sizeof ( jpc_fix_t ) ) ) ) { abort ( ) ; } } if ( numrows >= 2 ) { hstartcol = ( numrows + 1 - parity ) >> 1 ; m = numrows - hstartcol ; n = m ; dstptr = buf ; srcptr = & a [ ( 1 - parity ) * stride ] ; while ( n -- > 0 ) { dstptr2 = dstptr ; srcptr2 = srcptr ; for ( i = 0 ; i < JPC_QMFB_COLGRPSIZE ; ++ i ) { * dstptr2 = * srcptr2 ; ++ dstptr2 ; ++ srcptr2 ; } dstptr += JPC_QMFB_COLGRPSIZE ; srcptr += stride << 1 ; } dstptr = & a [ ( 1 - parity ) * stride ] ; srcptr = & a [ ( 2 - parity ) * stride ] ; n = numrows - m - ( ! parity ) ; while ( n -- > 0 ) { dstptr2 = dstptr ; srcptr2 = srcptr ; for ( i = 0 ; i < JPC_QMFB_COLGRPSIZE ; ++ i ) { * dstptr2 = * srcptr2 ; ++ dstptr2 ; ++ srcptr2 ; } dstptr += stride ; srcptr += stride << 1 ; } dstptr = & a [ hstartcol * stride ] ; srcptr = buf ; n = m ; while ( n -- > 0 ) { dstptr2 = dstptr ; srcptr2 = srcptr ; for ( i = 0 ; i < JPC_QMFB_COLGRPSIZE ; ++ i ) { * dstptr2 = * srcptr2 ; ++ dstptr2 ; ++ srcptr2 ; } dstptr += stride ; srcptr += JPC_QMFB_COLGRPSIZE ; } } if ( buf != splitbuf ) { jas_free ( buf ) ; } } "," m ; int hstartrow ; if ( ( buf = jas_alloc3 ( bufsize , ( bufsize , JPC_QMFB_COLGRPSIZE , 2 ) { hstartrow = ( numrows = numrows - hstartrow ; n = & a [ hstartrow * stride ] ",mdadams@jasper/4a59cfaf9ab3d48fca4a15c0d2674bf7138e3d1a,CVE-2016-8654,https://github.com/mdadams/jasper/commit/4a59cfaf9ab3d48fca4a15c0d2674bf7138e3d1a,2018-08-01T16:29Z 182,CWE-125,"CWE-125 static Image * ReadSUNImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define RMT_EQUAL_RGB 1 # define RMT_NONE 0 # define RMT_RAW 2 # define RT_STANDARD 1 # define RT_ENCODED 2 # define RT_FORMAT_RGB 3 typedef struct _SUNInfo { unsigned int magic , width , height , depth , length , type , maptype , maplength ; } SUNInfo ; Image * image ; int bit ; MagickBooleanType status ; MagickSizeType number_pixels ; register Quantum * q ; register ssize_t i , x ; register unsigned char * p ; size_t bytes_per_line , extent , height , length ; ssize_t count , y ; SUNInfo sun_info ; unsigned char * sun_data , * sun_pixels ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } ( void ) ResetMagickMemory ( & sun_info , 0 , sizeof ( sun_info ) ) ; sun_info . magic = ReadBlobMSBLong ( image ) ; do { if ( sun_info . magic != 0x59a66a95 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; sun_info . width = ReadBlobMSBLong ( image ) ; sun_info . height = ReadBlobMSBLong ( image ) ; sun_info . depth = ReadBlobMSBLong ( image ) ; sun_info . length = ReadBlobMSBLong ( image ) ; sun_info . type = ReadBlobMSBLong ( image ) ; sun_info . maptype = ReadBlobMSBLong ( image ) ; sun_info . maplength = ReadBlobMSBLong ( image ) ; extent = sun_info . height * sun_info . width ; if ( ( sun_info . height != 0 ) && ( sun_info . width != extent / sun_info . height ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ( sun_info . type != RT_STANDARD ) && ( sun_info . type != RT_ENCODED ) && ( sun_info . type != RT_FORMAT_RGB ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ( sun_info . maptype == RMT_NONE ) && ( sun_info . maplength != 0 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ( sun_info . depth == 0 ) || ( sun_info . depth > 32 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ( sun_info . maptype != RMT_NONE ) && ( sun_info . maptype != RMT_EQUAL_RGB ) && ( sun_info . maptype != RMT_RAW ) ) ThrowReaderException ( CoderError , ""ColormapTypeNotSupported"" ) ; image -> columns = sun_info . width ; image -> rows = sun_info . height ; image -> depth = sun_info . depth <= 8 ? sun_info . depth : MAGICKCORE_QUANTUM_DEPTH ; if ( sun_info . depth < 24 ) { size_t one ; image -> colors = sun_info . maplength ; one = 1 ; if ( sun_info . maptype == RMT_NONE ) image -> colors = one << sun_info . depth ; if ( sun_info . maptype == RMT_EQUAL_RGB ) image -> colors = sun_info . maplength / 3 ; if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; } switch ( sun_info . maptype ) { case RMT_NONE : break ; case RMT_EQUAL_RGB : { unsigned char * sun_colormap ; sun_colormap = ( unsigned char * ) AcquireQuantumMemory ( image -> colors , sizeof ( * sun_colormap ) ) ; if ( sun_colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; count = ReadBlob ( image , image -> colors , sun_colormap ) ; if ( count != ( ssize_t ) image -> colors ) ThrowReaderException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) image -> colormap [ i ] . red = ( MagickRealType ) ScaleCharToQuantum ( sun_colormap [ i ] ) ; count = ReadBlob ( image , image -> colors , sun_colormap ) ; if ( count != ( ssize_t ) image -> colors ) ThrowReaderException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) image -> colormap [ i ] . green = ( MagickRealType ) ScaleCharToQuantum ( sun_colormap [ i ] ) ; count = ReadBlob ( image , image -> colors , sun_colormap ) ; if ( count != ( ssize_t ) image -> colors ) ThrowReaderException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) image -> colormap [ i ] . blue = ( MagickRealType ) ScaleCharToQuantum ( sun_colormap [ i ] ) ; sun_colormap = ( unsigned char * ) RelinquishMagickMemory ( sun_colormap ) ; break ; } case RMT_RAW : { unsigned char * sun_colormap ; sun_colormap = ( unsigned char * ) AcquireQuantumMemory ( sun_info . maplength , sizeof ( * sun_colormap ) ) ; if ( sun_colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; count = ReadBlob ( image , sun_info . maplength , sun_colormap ) ; if ( count != ( ssize_t ) sun_info . maplength ) ThrowReaderException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; sun_colormap = ( unsigned char * ) RelinquishMagickMemory ( sun_colormap ) ; break ; } default : ThrowReaderException ( CoderError , ""ColormapTypeNotSupported"" ) ; } image -> alpha_trait = sun_info . depth == 32 ? BlendPixelTrait : UndefinedPixelTrait ; image -> columns = sun_info . width ; image -> rows = sun_info . height ; if ( image_info -> ping != MagickFalse ) { ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; if ( ( sun_info . length * sizeof ( * sun_data ) ) / sizeof ( * sun_data ) != sun_info . length || ! sun_info . length ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; number_pixels = ( MagickSizeType ) image -> columns * image -> rows ; if ( ( sun_info . type != RT_ENCODED ) && ( ( number_pixels * sun_info . depth ) > ( 8 * sun_info . length ) ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; bytes_per_line = sun_info . width * sun_info . depth ; sun_data = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) MagickMax ( sun_info . length , bytes_per_line * sun_info . width ) , sizeof ( * sun_data ) ) ; if ( sun_data == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; count = ( ssize_t ) ReadBlob ( image , sun_info . length , sun_data ) ; if ( count != ( ssize_t ) sun_info . length ) ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; height = sun_info . height ; if ( ( height == 0 ) || ( sun_info . width == 0 ) || ( sun_info . depth == 0 ) || ( ( bytes_per_line / sun_info . depth ) != sun_info . width ) ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; bytes_per_line += 15 ; bytes_per_line <<= 1 ; if ( ( bytes_per_line >> 1 ) != ( sun_info . width * sun_info . depth + 15 ) ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; bytes_per_line >>= 4 ; sun_pixels = ( unsigned char * ) AcquireQuantumMemory ( height , bytes_per_line * sizeof ( * sun_pixels ) ) ; if ( sun_pixels == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; if ( sun_info . type == RT_ENCODED ) ( void ) DecodeImage ( sun_data , sun_info . length , sun_pixels , bytes_per_line * height ) ; sun_data = ( unsigned char * ) RelinquishMagickMemory ( sun_data ) ; p = sun_pixels ; if ( sun_info . depth == 1 ) for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ( ssize_t ) image -> columns - 7 ) ; x += 8 ) { for ( bit = 7 ; bit >= 0 ; bit -- ) { SetPixelIndex ( image , ( Quantum ) ( ( * p ) & ( 0x01 << bit ) ? 0x00 : 0x01 ) , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } if ( ( image -> columns % 8 ) != 0 ) { for ( bit = 7 ; bit >= ( int ) ( 8 - ( image -> columns % 8 ) ) ; bit -- ) { SetPixelIndex ( image , ( Quantum ) ( ( * p ) & ( 0x01 << bit ) ? 0x00 : 0x01 ) , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } if ( ( ( ( image -> columns / 8 ) + ( image -> columns % 8 ? 1 : 0 ) ) % 2 ) != 0 ) p ++ ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } else if ( image -> storage_class == PseudoClass ) { if ( bytes_per_line == 0 ) bytes_per_line = image -> columns ; length = image -> rows * ( image -> columns + image -> columns % 2 ) ; if ( ( ( sun_info . type == RT_ENCODED ) && ( length > ( bytes_per_line * image -> rows ) ) ) || ( ( sun_info . type != RT_ENCODED ) && ( length > sun_info . length ) ) ) ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelIndex ( image , * p ++ , q ) ; q += GetPixelChannels ( image ) ; } if ( ( image -> columns % 2 ) != 0 ) p ++ ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } else { size_t bytes_per_pixel ; bytes_per_pixel = 3 ; if ( image -> alpha_trait != UndefinedPixelTrait ) bytes_per_pixel ++ ; if ( bytes_per_line == 0 ) bytes_per_line = bytes_per_pixel * image -> columns ; length = image -> rows * ( bytes_per_line + bytes_per_line % 2 ) ; if ( ( ( sun_info . type == RT_ENCODED ) && ( length > ( bytes_per_line * image -> rows ) ) ) || ( ( sun_info . type != RT_ENCODED ) && ( length > sun_info . length ) ) ) ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { if ( image -> alpha_trait != UndefinedPixelTrait ) SetPixelAlpha ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; if ( sun_info . type == RT_STANDARD ) { SetPixelBlue ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelGreen ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelRed ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; } else { SetPixelRed ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelGreen ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelBlue ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; } if ( image -> colors != 0 ) { SetPixelRed ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) GetPixelRed ( image , q ) ] . red ) , q ) ; SetPixelGreen ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) GetPixelGreen ( image , q ) ] . green ) , q ) ; SetPixelBlue ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) GetPixelBlue ( image , q ) ] . blue ) , q ) ; } q += GetPixelChannels ( image ) ; } if ( ( ( bytes_per_pixel * image -> columns ) % 2 ) != 0 ) p ++ ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } if ( image -> storage_class == PseudoClass ) ( void ) SyncImage ( image , exception ) ; sun_pixels = ( unsigned char * ) RelinquishMagickMemory ( sun_pixels ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; sun_info . magic = ReadBlobMSBLong ( image ) ; if ( sun_info . magic == 0x59a66a95 ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( sun_info . magic == 0x59a66a95 ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," ( ResourceLimitError , ""ImproperImageHeader"" ) ; number_pixels ( ResourceLimitError , ""ImproperImageHeader"" ) ; bytes_per_line ( ResourceLimitError , ""ImproperImageHeader"" ) ; bytes_per_line height ) ; else { if ( sun_info . length > ( height * bytes_per_line ) ) ThrowReaderException ( ResourceLimitError , ""ImproperImageHeader"" ) ; ( void ) CopyMagickMemory ( sun_pixels , sun_data , sun_info . length ) ; } ",ImageMagick@ImageMagick/6b4aff0f117b978502ee5bcd6e753c17aec5a961,CVE-2015-8958,https://github.com/ImageMagick/ImageMagick/commit/6b4aff0f117b978502ee5bcd6e753c17aec5a961,2017-04-20T18:59Z 183,CWE-20,"CWE-20 static Image * ReadRLEImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define SkipLinesOp 0x01 # define SetColorOp 0x02 # define SkipPixelsOp 0x03 # define ByteDataOp 0x05 # define RunDataOp 0x06 # define EOFOp 0x07 char magick [ 12 ] ; Image * image ; int opcode , operand , status ; MagickStatusType flags ; MagickSizeType number_pixels ; MemoryInfo * pixel_info ; Quantum index ; register ssize_t x ; register Quantum * q ; register ssize_t i ; register unsigned char * p ; size_t bits_per_pixel , map_length , number_colormaps , number_planes , number_planes_filled , one , pixel_info_length ; ssize_t count , offset , y ; unsigned char background_color [ 256 ] , * colormap , pixel , plane , * pixels ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; count = ReadBlob ( image , 2 , ( unsigned char * ) magick ) ; if ( ( count != 2 ) || ( memcmp ( magick , ""\\122\\314"" , 2 ) != 0 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; do { image -> page . x = ReadBlobLSBShort ( image ) ; image -> page . y = ReadBlobLSBShort ( image ) ; image -> columns = ReadBlobLSBShort ( image ) ; image -> rows = ReadBlobLSBShort ( image ) ; flags = ( MagickStatusType ) ReadBlobByte ( image ) ; image -> alpha_trait = flags & 0x04 ? BlendPixelTrait : UndefinedPixelTrait ; number_planes = ( size_t ) ReadBlobByte ( image ) ; bits_per_pixel = ( size_t ) ReadBlobByte ( image ) ; number_colormaps = ( size_t ) ReadBlobByte ( image ) ; map_length = ( unsigned char ) ReadBlobByte ( image ) ; if ( map_length >= 22 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; one = 1 ; map_length = one << map_length ; if ( ( number_planes == 0 ) || ( number_planes == 2 ) || ( ( flags & 0x04 ) && ( number_colormaps > 254 ) ) || ( bits_per_pixel != 8 ) || ( image -> columns == 0 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( flags & 0x02 ) { for ( i = 0 ; i < ( ssize_t ) number_planes ; i ++ ) background_color [ i ] = 0 ; ( void ) ReadBlobByte ( image ) ; } else { p = background_color ; for ( i = 0 ; i < ( ssize_t ) number_planes ; i ++ ) * p ++ = ( unsigned char ) ReadBlobByte ( image ) ; } if ( ( number_planes & 0x01 ) == 0 ) ( void ) ReadBlobByte ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } colormap = ( unsigned char * ) NULL ; if ( number_colormaps != 0 ) { colormap = ( unsigned char * ) AcquireQuantumMemory ( number_colormaps , 3 * map_length * sizeof ( * colormap ) ) ; if ( colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; p = colormap ; for ( i = 0 ; i < ( ssize_t ) number_colormaps ; i ++ ) for ( x = 0 ; x < ( ssize_t ) map_length ; x ++ ) * p ++ = ( unsigned char ) ScaleQuantumToChar ( ScaleShortToQuantum ( ReadBlobLSBShort ( image ) ) ) ; } if ( ( flags & 0x08 ) != 0 ) { char * comment ; size_t length ; length = ReadBlobLSBShort ( image ) ; if ( length != 0 ) { comment = ( char * ) AcquireQuantumMemory ( length , sizeof ( * comment ) ) ; if ( comment == ( char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; count = ReadBlob ( image , length - 1 , ( unsigned char * ) comment ) ; comment [ length - 1 ] = '\\0' ; ( void ) SetImageProperty ( image , ""comment"" , comment , exception ) ; comment = DestroyString ( comment ) ; if ( ( length & 0x01 ) == 0 ) ( void ) ReadBlobByte ( image ) ; } } if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; if ( image -> alpha_trait != UndefinedPixelTrait ) number_planes ++ ; number_pixels = ( MagickSizeType ) image -> columns * image -> rows ; number_planes_filled = ( number_planes % 2 == 0 ) ? number_planes : number_planes + 1 ; if ( ( number_pixels * number_planes_filled ) != ( size_t ) ( number_pixels * number_planes_filled ) ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; pixel_info = AcquireVirtualMemory ( image -> columns , image -> rows * MagickMax ( number_planes_filled , 4 ) * sizeof ( * pixels ) ) ; if ( pixel_info == ( MemoryInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; pixel_info_length = image -> columns * image -> rows * MagickMax ( number_planes_filled , 4 ) ; pixels = ( unsigned char * ) GetVirtualMemoryBlob ( pixel_info ) ; ( void ) ResetMagickMemory ( pixels , 0 , pixel_info_length ) ; if ( ( flags & 0x01 ) && ! ( flags & 0x02 ) ) { ssize_t j ; p = pixels ; for ( i = 0 ; i < ( ssize_t ) number_pixels ; i ++ ) { if ( image -> alpha_trait == UndefinedPixelTrait ) for ( j = 0 ; j < ( ssize_t ) number_planes ; j ++ ) * p ++ = background_color [ j ] ; else { for ( j = 0 ; j < ( ssize_t ) ( number_planes - 1 ) ; j ++ ) * p ++ = background_color [ j ] ; * p ++ = 0 ; } } } plane = 0 ; x = 0 ; y = 0 ; opcode = ReadBlobByte ( image ) ; do { switch ( opcode & 0x3f ) { case SkipLinesOp : { operand = ReadBlobByte ( image ) ; if ( opcode & 0x40 ) operand = ReadBlobLSBSignedShort ( image ) ; x = 0 ; y += operand ; break ; } case SetColorOp : { operand = ReadBlobByte ( image ) ; plane = ( unsigned char ) operand ; if ( plane == 255 ) plane = ( unsigned char ) ( number_planes - 1 ) ; x = 0 ; break ; } case SkipPixelsOp : { operand = ReadBlobByte ( image ) ; if ( opcode & 0x40 ) operand = ReadBlobLSBSignedShort ( image ) ; x += operand ; break ; } case ByteDataOp : { operand = ReadBlobByte ( image ) ; if ( opcode & 0x40 ) operand = ReadBlobLSBSignedShort ( image ) ; offset = ( ( image -> rows - y - 1 ) * image -> columns * number_planes ) + x * number_planes + plane ; operand ++ ; if ( ( offset < 0 ) || ( offset + ( ( size_t ) operand * number_planes ) > pixel_info_length ) ) { if ( number_colormaps != 0 ) colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; } p = pixels + offset ; for ( i = 0 ; i < ( ssize_t ) operand ; i ++ ) { pixel = ( unsigned char ) ReadBlobByte ( image ) ; if ( ( y < ( ssize_t ) image -> rows ) && ( ( x + i ) < ( ssize_t ) image -> columns ) ) * p = pixel ; p += number_planes ; } if ( operand & 0x01 ) ( void ) ReadBlobByte ( image ) ; x += operand ; break ; } case RunDataOp : { operand = ReadBlobByte ( image ) ; if ( opcode & 0x40 ) operand = ReadBlobLSBSignedShort ( image ) ; pixel = ( unsigned char ) ReadBlobByte ( image ) ; ( void ) ReadBlobByte ( image ) ; offset = ( ( image -> rows - y - 1 ) * image -> columns * number_planes ) + x * number_planes + plane ; operand ++ ; if ( ( offset < 0 ) || ( offset + ( ( size_t ) operand * number_planes ) > pixel_info_length ) ) { if ( number_colormaps != 0 ) colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; } p = pixels + offset ; for ( i = 0 ; i < ( ssize_t ) operand ; i ++ ) { if ( ( y < ( ssize_t ) image -> rows ) && ( ( x + i ) < ( ssize_t ) image -> columns ) ) * p = pixel ; p += number_planes ; } x += operand ; break ; } default : break ; } opcode = ReadBlobByte ( image ) ; } while ( ( ( opcode & 0x3f ) != EOFOp ) && ( opcode != EOF ) ) ; if ( number_colormaps != 0 ) { MagickStatusType mask ; mask = ( MagickStatusType ) ( map_length - 1 ) ; p = pixels ; x = ( ssize_t ) number_planes ; if ( number_colormaps == 1 ) for ( i = 0 ; i < ( ssize_t ) number_pixels ; i ++ ) { ValidateColormapValue ( image , * p & mask , & index , exception ) ; * p = colormap [ ( ssize_t ) index ] ; p ++ ; } else if ( ( number_planes >= 3 ) && ( number_colormaps >= 3 ) ) for ( i = 0 ; i < ( ssize_t ) number_pixels ; i ++ ) for ( x = 0 ; x < ( ssize_t ) number_planes ; x ++ ) { ValidateColormapValue ( image , ( size_t ) ( x * map_length + ( * p & mask ) ) , & index , exception ) ; * p = colormap [ ( ssize_t ) index ] ; p ++ ; } if ( ( i < ( ssize_t ) number_pixels ) || ( x < ( ssize_t ) number_planes ) ) { colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; } } if ( number_planes >= 3 ) { p = pixels ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelGreen ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelBlue ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; if ( image -> alpha_trait != UndefinedPixelTrait ) SetPixelAlpha ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } else { if ( number_colormaps == 0 ) map_length = 256 ; if ( AcquireImageColormap ( image , map_length , exception ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; p = colormap ; if ( number_colormaps == 1 ) for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { image -> colormap [ i ] . red = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) i ) ; image -> colormap [ i ] . green = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) i ) ; image -> colormap [ i ] . blue = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) i ) ; } else if ( number_colormaps > 1 ) for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { image -> colormap [ i ] . red = ( MagickRealType ) ScaleCharToQuantum ( * p ) ; image -> colormap [ i ] . green = ( MagickRealType ) ScaleCharToQuantum ( * ( p + map_length ) ) ; image -> colormap [ i ] . blue = ( MagickRealType ) ScaleCharToQuantum ( * ( p + map_length * 2 ) ) ; p ++ ; } p = pixels ; if ( image -> alpha_trait == UndefinedPixelTrait ) { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelIndex ( image , * p ++ , q ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } ( void ) SyncImage ( image , exception ) ; } else { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { ValidateColormapValue ( image , ( ssize_t ) * p ++ , & index , exception ) ; SetPixelRed ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) index ] . red ) , q ) ; ValidateColormapValue ( image , ( ssize_t ) * p ++ , & index , exception ) ; SetPixelGreen ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) index ] . green ) , q ) ; ValidateColormapValue ( image , ( ssize_t ) * p ++ , & index , exception ) ; SetPixelBlue ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) index ] . blue ) , q ) ; SetPixelAlpha ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; q += GetPixelChannels ( image ) ; } if ( x < ( ssize_t ) image -> columns ) break ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } image -> colormap = ( PixelInfo * ) RelinquishMagickMemory ( image -> colormap ) ; image -> storage_class = DirectClass ; image -> colors = 0 ; } } if ( number_colormaps != 0 ) colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; pixel_info = RelinquishVirtualMemory ( pixel_info ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; ( void ) ReadBlobByte ( image ) ; count = ReadBlob ( image , 2 , ( unsigned char * ) magick ) ; if ( ( count != 0 ) && ( memcmp ( magick , ""\\122\\314"" , 2 ) == 0 ) ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( ( count != 0 ) && ( memcmp ( magick , ""\\122\\314"" , 2 ) == 0 ) ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," define EOFOp 0x07 # define ThrowRLEException ( exception , message ) \\\n{ if ( colormap != ( unsigned char * ) NULL ) colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; if ( pixel_info != ( MemoryInfo * ) NULL ) pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( ( exception ) , ( message ) ) ; \\\n} ) ) ; colormap = ( unsigned char * ) NULL ; pixel_info = ( MemoryInfo * ) NULL ; . x = ( ssize_t ) . y = ( ssize_t ) ""ImproperImageHeader"" ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; != MagickFalse ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" CorruptImageError , ""UnexpectedEndOfFile"" ) ; if ( number_colormaps != 0 ) { colormap = ( char * ) AcquireQuantumMemory ( number_colormaps , 3 * map_length * sizeof ( * colormap ) ) ; if ( colormap == ( unsigned char char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; p = colormap ; for ( i = 0 ; i < ( ssize_t ) number_colormaps ; i ++ ) for ( x = 0 ; x < ( ssize_t ) map_length ; x ++ ) { * p ++ = ( unsigned char ( unsigned char ) ScaleQuantumToChar ( ) ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; } != MagickFalse ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" CorruptImageError , ""UnexpectedEndOfFile"" ) ; if ( ( image ) ; if ( opcode == EOF ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; if ( opcode == EOF ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; if ( opcode & 0x40 ) { image ) ; if ( opcode == EOF ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; } image ) ; if ( opcode == EOF ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; if ( opcode == EOF ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; if ( opcode & 0x40 ) { image ) ; if ( opcode == EOF ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; } if ( opcode == EOF ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; if ( opcode & 0x40 ) { image ) ; if ( opcode == EOF ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; } offset = ( ssize_t ) ( ( ( image number_planes + plane ) ) || ( ( offset + operand * number_planes number_planes ) > ( ssize_t ) if ( opcode == EOF ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; if ( opcode & 0x40 ) { image ) ; if ( opcode == EOF ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; } ; offset = ( ssize_t ) ( number_planes + plane ) ) || ( ( offset + operand * number_planes number_planes ) > ( ssize_t ) image ) ; if ( opcode == EOF ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; ( image , ( ssize_t ) ( p & mask ) image , ( ssize_t ) ( x ( image , ( Quantum ) ",ImageMagick@ImageMagick/f6240ee77847787f6d7618b669d3a2040a2d6d40,CVE-2017-9144,https://github.com/ImageMagick/ImageMagick/commit/f6240ee77847787f6d7618b669d3a2040a2d6d40,2017-05-22T14:29Z 184,CWE-19,"CWE-19 static void ext2_put_super ( struct super_block * sb ) { int db_count ; int i ; struct ext2_sb_info * sbi = EXT2_SB ( sb ) ; dquot_disable ( sb , - 1 , DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED ) ; ext2_xattr_put_super ( sb ) ; if ( ! ( sb -> s_flags & MS_RDONLY ) ) { struct ext2_super_block * es = sbi -> s_es ; spin_lock ( & sbi -> s_lock ) ; es -> s_state = cpu_to_le16 ( sbi -> s_mount_state ) ; spin_unlock ( & sbi -> s_lock ) ; ext2_sync_super ( sb , es , 1 ) ; } db_count = sbi -> s_gdb_count ; for ( i = 0 ; i < db_count ; i ++ ) if ( sbi -> s_group_desc [ i ] ) brelse ( sbi -> s_group_desc [ i ] ) ; kfree ( sbi -> s_group_desc ) ; kfree ( sbi -> s_debts ) ; percpu_counter_destroy ( & sbi -> s_freeblocks_counter ) ; percpu_counter_destroy ( & sbi -> s_freeinodes_counter ) ; percpu_counter_destroy ( & sbi -> s_dirs_counter ) ; brelse ( sbi -> s_sbh ) ; sb -> s_fs_info = NULL ; kfree ( sbi -> s_blockgroup_lock ) ; kfree ( sbi ) ; } "," DQUOT_LIMITS_ENABLED ) ; if ( sbi -> s_mb_cache ) { ext2_xattr_destroy_cache ( sbi -> s_mb_cache ) ; sbi -> s_mb_cache = NULL ; } if ( ! ",torvalds@linux/be0726d33cb8f411945884664924bed3cb8c70ee,CVE-2015-8952,https://github.com/torvalds/linux/commit/be0726d33cb8f411945884664924bed3cb8c70ee,2016-10-16T21:59Z 185,CWE-000,"CWE-000 static int gtco_probe ( struct usb_interface * usbinterface , const struct usb_device_id * id ) { struct gtco * gtco ; struct input_dev * input_dev ; struct hid_descriptor * hid_desc ; char * report ; int result = 0 , retry ; int error ; struct usb_endpoint_descriptor * endpoint ; gtco = kzalloc ( sizeof ( struct gtco ) , GFP_KERNEL ) ; input_dev = input_allocate_device ( ) ; if ( ! gtco || ! input_dev ) { dev_err ( & usbinterface -> dev , ""Nomorememory\\n"" ) ; error = - ENOMEM ; goto err_free_devs ; } gtco -> inputdevice = input_dev ; gtco -> usbdev = interface_to_usbdev ( usbinterface ) ; gtco -> intf = usbinterface ; gtco -> buffer = usb_alloc_coherent ( gtco -> usbdev , REPORT_MAX_SIZE , GFP_KERNEL , & gtco -> buf_dma ) ; if ( ! gtco -> buffer ) { dev_err ( & usbinterface -> dev , ""Nomorememoryforusbuffers\\n"" ) ; error = - ENOMEM ; goto err_free_devs ; } gtco -> urbinfo = usb_alloc_urb ( 0 , GFP_KERNEL ) ; if ( ! gtco -> urbinfo ) { dev_err ( & usbinterface -> dev , ""FailedtoallocateURB\\n"" ) ; error = - ENOMEM ; goto err_free_buf ; } endpoint = & usbinterface -> altsetting [ 0 ] . endpoint [ 0 ] . desc ; dev_dbg ( & usbinterface -> dev , ""gtco#interfaces:%d\\n"" , usbinterface -> num_altsetting ) ; dev_dbg ( & usbinterface -> dev , ""numendpoints:%d\\n"" , usbinterface -> cur_altsetting -> desc . bNumEndpoints ) ; dev_dbg ( & usbinterface -> dev , ""interfaceclass:%d\\n"" , usbinterface -> cur_altsetting -> desc . bInterfaceClass ) ; dev_dbg ( & usbinterface -> dev , ""endpoint:attribute:0x%xtype:0x%x\\n"" , endpoint -> bmAttributes , endpoint -> bDescriptorType ) ; if ( usb_endpoint_xfer_int ( endpoint ) ) dev_dbg ( & usbinterface -> dev , ""endpoint:wehaveinterruptendpoint\\n"" ) ; dev_dbg ( & usbinterface -> dev , ""endpointextralen:%d\\n"" , usbinterface -> altsetting [ 0 ] . extralen ) ; if ( usb_get_extra_descriptor ( usbinterface -> cur_altsetting , HID_DEVICE_TYPE , & hid_desc ) != 0 ) { dev_err ( & usbinterface -> dev , ""Can\'tretrieveextaUSBdescriptortogethidreportdescriptorlength\\n"" ) ; error = - EIO ; goto err_free_urb ; } dev_dbg ( & usbinterface -> dev , ""Extradescriptorsuccess:type:%dlen:%d\\n"" , hid_desc -> bDescriptorType , hid_desc -> wDescriptorLength ) ; report = kzalloc ( le16_to_cpu ( hid_desc -> wDescriptorLength ) , GFP_KERNEL ) ; if ( ! report ) { dev_err ( & usbinterface -> dev , ""Nomorememoryforreport\\n"" ) ; error = - ENOMEM ; goto err_free_urb ; } for ( retry = 0 ; retry < 3 ; retry ++ ) { result = usb_control_msg ( gtco -> usbdev , usb_rcvctrlpipe ( gtco -> usbdev , 0 ) , USB_REQ_GET_DESCRIPTOR , USB_RECIP_INTERFACE | USB_DIR_IN , REPORT_DEVICE_TYPE << 8 , 0 , report , le16_to_cpu ( hid_desc -> wDescriptorLength ) , 5000 ) ; dev_dbg ( & usbinterface -> dev , ""usb_control_msgresult:%d\\n"" , result ) ; if ( result == le16_to_cpu ( hid_desc -> wDescriptorLength ) ) { parse_hid_report_descriptor ( gtco , report , result ) ; break ; } } kfree ( report ) ; if ( result != le16_to_cpu ( hid_desc -> wDescriptorLength ) ) { dev_err ( & usbinterface -> dev , ""FailedtogetHIDReportDescriptorofsize:%d\\n"" , hid_desc -> wDescriptorLength ) ; error = - EIO ; goto err_free_urb ; } usb_make_path ( gtco -> usbdev , gtco -> usbpath , sizeof ( gtco -> usbpath ) ) ; strlcat ( gtco -> usbpath , ""/input0"" , sizeof ( gtco -> usbpath ) ) ; input_dev -> open = gtco_input_open ; input_dev -> close = gtco_input_close ; input_dev -> name = ""GTCO_CalComp"" ; input_dev -> phys = gtco -> usbpath ; input_set_drvdata ( input_dev , gtco ) ; gtco_setup_caps ( input_dev ) ; usb_to_input_id ( gtco -> usbdev , & input_dev -> id ) ; input_dev -> dev . parent = & usbinterface -> dev ; endpoint = & usbinterface -> altsetting [ 0 ] . endpoint [ 0 ] . desc ; usb_fill_int_urb ( gtco -> urbinfo , gtco -> usbdev , usb_rcvintpipe ( gtco -> usbdev , endpoint -> bEndpointAddress ) , gtco -> buffer , REPORT_MAX_SIZE , gtco_urb_callback , gtco , endpoint -> bInterval ) ; gtco -> urbinfo -> transfer_dma = gtco -> buf_dma ; gtco -> urbinfo -> transfer_flags |= URB_NO_TRANSFER_DMA_MAP ; usb_set_intfdata ( usbinterface , gtco ) ; error = input_register_device ( input_dev ) ; if ( error ) goto err_free_urb ; return 0 ; err_free_urb : usb_free_urb ( gtco -> urbinfo ) ; err_free_buf : usb_free_coherent ( gtco -> usbdev , REPORT_MAX_SIZE , gtco -> buffer , gtco -> buf_dma ) ; err_free_devs : input_free_device ( input_dev ) ; kfree ( gtco ) ; return error ; } "," err_free_buf ; } if ( usbinterface -> altsetting [ 0 ] . desc . bNumEndpoints < 1 ) { dev_err ( & usbinterface -> dev , ""Invalidnumberofendpoints\\n"" ) ; error = - EINVAL ; goto err_free_urb ; } ",torvalds@linux/162f98dea487206d9ab79fc12ed64700667a894d,CVE-2016-2187,https://github.com/torvalds/linux/commit/162f98dea487206d9ab79fc12ed64700667a894d,2016-05-02T10:59Z 186,CWE-269,"CWE-269 void bandwidth_pid ( pid_t pid , const char * command , const char * dev , int down , int up ) { EUID_ASSERT ( ) ; EUID_ROOT ( ) ; char * comm = pid_proc_comm ( pid ) ; EUID_USER ( ) ; if ( ! comm ) { fprintf ( stderr , ""Error:cannotfindsandbox\\n"" ) ; exit ( 1 ) ; } if ( strcmp ( comm , ""firejail"" ) != 0 ) { fprintf ( stderr , ""Error:cannotfindsandbox\\n"" ) ; exit ( 1 ) ; } free ( comm ) ; char * name ; if ( asprintf ( & name , ""/run/firejail/network/%d-netmap"" , pid ) == - 1 ) errExit ( ""asprintf"" ) ; struct stat s ; if ( stat ( name , & s ) == - 1 ) { fprintf ( stderr , ""Error:thesandboxdoesn\'tuseanewnetworknamespace\\n"" ) ; exit ( 1 ) ; } pid_t child ; if ( find_child ( pid , & child ) == - 1 ) { fprintf ( stderr , ""Error:cannotjointhenetworknamespace\\n"" ) ; exit ( 1 ) ; } EUID_ROOT ( ) ; if ( join_namespace ( child , ""net"" ) ) { fprintf ( stderr , ""Error:cannotjointhenetworknamespace\\n"" ) ; exit ( 1 ) ; } if ( strcmp ( command , ""set"" ) == 0 ) bandwidth_set ( pid , dev , down , up ) ; else if ( strcmp ( command , ""clear"" ) == 0 ) bandwidth_remove ( pid , dev ) ; char * devname = NULL ; if ( dev ) { char * fname ; if ( asprintf ( & fname , ""%s/%d-netmap"" , RUN_FIREJAIL_NETWORK_DIR , ( int ) pid ) == - 1 ) errExit ( ""asprintf"" ) ; FILE * fp = fopen ( fname , ""r"" ) ; if ( ! fp ) { fprintf ( stderr , ""Error:cannotreadnetworkmapfile%s\\n"" , fname ) ; exit ( 1 ) ; } char buf [ 1024 ] ; int len = strlen ( dev ) ; while ( fgets ( buf , 1024 , fp ) ) { char * ptr = strchr ( buf , '\\n' ) ; if ( ptr ) * ptr = '\\0' ; if ( * buf == '\\0' ) break ; if ( strncmp ( buf , dev , len ) == 0 && buf [ len ] == ':' ) { devname = strdup ( buf + len + 1 ) ; if ( ! devname ) errExit ( ""strdup"" ) ; if ( if_nametoindex ( devname ) == 0 ) { fprintf ( stderr , ""Error:cannotfindnetworkdevice%s\\n"" , devname ) ; exit ( 1 ) ; } break ; } } free ( fname ) ; fclose ( fp ) ; } char * cmd = NULL ; if ( devname ) { if ( strcmp ( command , ""set"" ) == 0 ) { if ( asprintf ( & cmd , ""%s/firejail/fshaper.sh--%s%s%d%d"" , LIBDIR , command , devname , down , up ) == - 1 ) errExit ( ""asprintf"" ) ; } else { if ( asprintf ( & cmd , ""%s/firejail/fshaper.sh--%s%s"" , LIBDIR , command , devname ) == - 1 ) errExit ( ""asprintf"" ) ; } } else { if ( asprintf ( & cmd , ""%s/firejail/fshaper.sh--%s"" , LIBDIR , command ) == - 1 ) errExit ( ""asprintf"" ) ; } assert ( cmd ) ; environ = NULL ; if ( setreuid ( 0 , 0 ) ) errExit ( ""setreuid"" ) ; if ( setregid ( 0 , 0 ) ) errExit ( ""setregid"" ) ; if ( ! cfg . shell ) cfg . shell = guess_shell ( ) ; if ( ! cfg . shell ) { fprintf ( stderr , ""Error:noPOSIXshellfound,pleaseuse--shellcommandlineoption\\n"" ) ; exit ( 1 ) ; } char * arg [ 4 ] ; arg [ 0 ] = cfg . shell ; arg [ 1 ] = ""-c"" ; arg [ 2 ] = cmd ; arg [ 3 ] = NULL ; clearenv ( ) ; execvp ( arg [ 0 ] , arg ) ; errExit ( ""execvp"" ) ; } "," ""setregid"" ) ; char * arg 0 ] = ""/bin/sh"" ; arg [ ",netblue30@firejail/5d43fdcd215203868d440ffc42036f5f5ffc89fc,CVE-2017-5207,https://github.com/netblue30/firejail/commit/5d43fdcd215203868d440ffc42036f5f5ffc89fc,2017-03-23T16:59Z 187,CWE-476,"CWE-476 static struct o2nm_cluster * to_o2nm_cluster_from_node ( struct o2nm_node * node ) { return to_o2nm_cluster ( node -> nd_item . ci_parent -> ci_parent ) ; } "," node ) { if ( node -> nd_item . ci_parent ) ci_parent ) ; else return NULL ; ",torvalds@linux/853bc26a7ea39e354b9f8889ae7ad1492ffa28d2,CVE-2017-18216,https://github.com/torvalds/linux/commit/853bc26a7ea39e354b9f8889ae7ad1492ffa28d2,2018-03-05T18:29Z 188,CWE-000,"CWE-000 static void nfs_set_open_stateid ( struct nfs4_state * state , nfs4_stateid * stateid , int open_flags ) { write_seqlock ( & state -> seqlock ) ; nfs_set_open_stateid_locked ( state , stateid , open_flags ) ; write_sequnlock ( & state -> seqlock ) ; } "," * stateid , fmode_t fmode ) { write_seqlock , stateid , fmode ) ; write_sequnlock ",torvalds@linux/dc0b027dfadfcb8a5504f7d8052754bf8d501ab9,CVE-2011-4324,https://github.com/torvalds/linux/commit/dc0b027dfadfcb8a5504f7d8052754bf8d501ab9,2012-06-21T23:55Z 189,CWE-834,"CWE-834 static int mv_read_header ( AVFormatContext * avctx ) { MvContext * mv = avctx -> priv_data ; AVIOContext * pb = avctx -> pb ; AVStream * ast = NULL , * vst = NULL ; int version , i ; int ret ; avio_skip ( pb , 4 ) ; version = avio_rb16 ( pb ) ; if ( version == 2 ) { uint64_t timestamp ; int v ; avio_skip ( pb , 22 ) ; ast = avformat_new_stream ( avctx , NULL ) ; if ( ! ast ) return AVERROR ( ENOMEM ) ; vst = avformat_new_stream ( avctx , NULL ) ; if ( ! vst ) return AVERROR ( ENOMEM ) ; avpriv_set_pts_info ( vst , 64 , 1 , 15 ) ; vst -> codecpar -> codec_type = AVMEDIA_TYPE_VIDEO ; vst -> avg_frame_rate = av_inv_q ( vst -> time_base ) ; vst -> nb_frames = avio_rb32 ( pb ) ; v = avio_rb32 ( pb ) ; switch ( v ) { case 1 : vst -> codecpar -> codec_id = AV_CODEC_ID_MVC1 ; break ; case 2 : vst -> codecpar -> format = AV_PIX_FMT_ARGB ; vst -> codecpar -> codec_id = AV_CODEC_ID_RAWVIDEO ; break ; default : avpriv_request_sample ( avctx , ""Videocompression%i"" , v ) ; break ; } vst -> codecpar -> codec_tag = 0 ; vst -> codecpar -> width = avio_rb32 ( pb ) ; vst -> codecpar -> height = avio_rb32 ( pb ) ; avio_skip ( pb , 12 ) ; ast -> codecpar -> codec_type = AVMEDIA_TYPE_AUDIO ; ast -> nb_frames = vst -> nb_frames ; ast -> codecpar -> sample_rate = avio_rb32 ( pb ) ; if ( ast -> codecpar -> sample_rate <= 0 ) { av_log ( avctx , AV_LOG_ERROR , ""Invalidsamplerate%d\\n"" , ast -> codecpar -> sample_rate ) ; return AVERROR_INVALIDDATA ; } avpriv_set_pts_info ( ast , 33 , 1 , ast -> codecpar -> sample_rate ) ; if ( set_channels ( avctx , ast , avio_rb32 ( pb ) ) < 0 ) return AVERROR_INVALIDDATA ; v = avio_rb32 ( pb ) ; if ( v == AUDIO_FORMAT_SIGNED ) { ast -> codecpar -> codec_id = AV_CODEC_ID_PCM_S16BE ; } else { avpriv_request_sample ( avctx , ""Audiocompression(format%i)"" , v ) ; } avio_skip ( pb , 12 ) ; var_read_metadata ( avctx , ""title"" , 0x80 ) ; var_read_metadata ( avctx , ""comment"" , 0x100 ) ; avio_skip ( pb , 0x80 ) ; timestamp = 0 ; for ( i = 0 ; i < vst -> nb_frames ; i ++ ) { uint32_t pos = avio_rb32 ( pb ) ; uint32_t asize = avio_rb32 ( pb ) ; uint32_t vsize = avio_rb32 ( pb ) ; avio_skip ( pb , 8 ) ; av_add_index_entry ( ast , pos , timestamp , asize , 0 , AVINDEX_KEYFRAME ) ; av_add_index_entry ( vst , pos + asize , i , vsize , 0 , AVINDEX_KEYFRAME ) ; timestamp += asize / ( ast -> codecpar -> channels * 2 ) ; } } else if ( ! version && avio_rb16 ( pb ) == 3 ) { avio_skip ( pb , 4 ) ; if ( ( ret = read_table ( avctx , NULL , parse_global_var ) ) < 0 ) return ret ; if ( mv -> nb_audio_tracks > 1 ) { avpriv_request_sample ( avctx , ""Multipleaudiostreamssupport"" ) ; return AVERROR_PATCHWELCOME ; } else if ( mv -> nb_audio_tracks ) { ast = avformat_new_stream ( avctx , NULL ) ; if ( ! ast ) return AVERROR ( ENOMEM ) ; ast -> codecpar -> codec_type = AVMEDIA_TYPE_AUDIO ; if ( ( read_table ( avctx , ast , parse_audio_var ) ) < 0 ) return ret ; if ( mv -> acompression == 100 && mv -> aformat == AUDIO_FORMAT_SIGNED && ast -> codecpar -> bits_per_coded_sample == 16 ) { ast -> codecpar -> codec_id = AV_CODEC_ID_PCM_S16BE ; } else { avpriv_request_sample ( avctx , ""Audiocompression%i(format%i,sr%i)"" , mv -> acompression , mv -> aformat , ast -> codecpar -> bits_per_coded_sample ) ; ast -> codecpar -> codec_id = AV_CODEC_ID_NONE ; } if ( ast -> codecpar -> channels <= 0 ) { av_log ( avctx , AV_LOG_ERROR , ""Novalidchannelcountfound.\\n"" ) ; return AVERROR_INVALIDDATA ; } } if ( mv -> nb_video_tracks > 1 ) { avpriv_request_sample ( avctx , ""Multiplevideostreamssupport"" ) ; return AVERROR_PATCHWELCOME ; } else if ( mv -> nb_video_tracks ) { vst = avformat_new_stream ( avctx , NULL ) ; if ( ! vst ) return AVERROR ( ENOMEM ) ; vst -> codecpar -> codec_type = AVMEDIA_TYPE_VIDEO ; if ( ( ret = read_table ( avctx , vst , parse_video_var ) ) < 0 ) return ret ; } if ( mv -> nb_audio_tracks ) read_index ( pb , ast ) ; if ( mv -> nb_video_tracks ) read_index ( pb , vst ) ; } else { avpriv_request_sample ( avctx , ""Version%i"" , version ) ; return AVERROR_PATCHWELCOME ; } return 0 ; } "," ( pb ) ; if ( avio_feof ( pb ) ) return AVERROR_INVALIDDATA ",FFmpeg@FFmpeg/4f05e2e2dc1a89f38cd9f0960a6561083d714f1e,CVE-2017-14055,https://github.com/FFmpeg/FFmpeg/commit/4f05e2e2dc1a89f38cd9f0960a6561083d714f1e,2017-08-31T15:29Z 190,CWE-189,"CWE-189 int cdf_read_property_info ( const cdf_stream_t * sst , const cdf_header_t * h , uint32_t offs , cdf_property_info_t * * info , size_t * count , size_t * maxcount ) { const cdf_section_header_t * shp ; cdf_section_header_t sh ; const uint8_t * p , * q , * e ; int16_t s16 ; int32_t s32 ; uint32_t u32 ; int64_t s64 ; uint64_t u64 ; cdf_timestamp_t tp ; size_t i , o , o4 , nelements , j ; cdf_property_info_t * inp ; if ( offs > UINT32_MAX / 4 ) { errno = EFTYPE ; goto out ; } shp = CAST ( const cdf_section_header_t * , ( const void * ) ( ( const char * ) sst -> sst_tab + offs ) ) ; if ( cdf_check_stream_offset ( sst , h , shp , sizeof ( * shp ) , __LINE__ ) == - 1 ) goto out ; sh . sh_len = CDF_TOLE4 ( shp -> sh_len ) ; # define CDF_SHLEN_LIMIT ( UINT32_MAX / 8 ) if ( sh . sh_len > CDF_SHLEN_LIMIT ) { errno = EFTYPE ; goto out ; } sh . sh_properties = CDF_TOLE4 ( shp -> sh_properties ) ; # define CDF_PROP_LIMIT ( UINT32_MAX / ( 4 * sizeof ( * inp ) ) ) if ( sh . sh_properties > CDF_PROP_LIMIT ) goto out ; DPRINTF ( ( ""sectionlen:%uproperties%u\\n"" , sh . sh_len , sh . sh_properties ) ) ; if ( * maxcount ) { if ( * maxcount > CDF_PROP_LIMIT ) goto out ; * maxcount += sh . sh_properties ; inp = CAST ( cdf_property_info_t * , realloc ( * info , * maxcount * sizeof ( * inp ) ) ) ; } else { * maxcount = sh . sh_properties ; inp = CAST ( cdf_property_info_t * , malloc ( * maxcount * sizeof ( * inp ) ) ) ; } if ( inp == NULL ) goto out ; * info = inp ; inp += * count ; * count += sh . sh_properties ; p = CAST ( const uint8_t * , ( const void * ) ( ( const char * ) ( const void * ) sst -> sst_tab + offs + sizeof ( sh ) ) ) ; e = CAST ( const uint8_t * , ( const void * ) ( ( ( const char * ) ( const void * ) shp ) + sh . sh_len ) ) ; if ( cdf_check_stream_offset ( sst , h , e , 0 , __LINE__ ) == - 1 ) goto out ; for ( i = 0 ; i < sh . sh_properties ; i ++ ) { size_t ofs , tail = ( i << 1 ) + 1 ; if ( cdf_check_stream_offset ( sst , h , p , tail * sizeof ( uint32_t ) , __LINE__ ) == - 1 ) goto out ; ofs = CDF_GETUINT32 ( p , tail ) ; q = ( const uint8_t * ) ( const void * ) ( ( const char * ) ( const void * ) p + ofs - 2 * sizeof ( uint32_t ) ) ; if ( q > e ) { DPRINTF ( ( ""Ranoftheend%p>%p\\n"" , q , e ) ) ; goto out ; } inp [ i ] . pi_id = CDF_GETUINT32 ( p , i << 1 ) ; inp [ i ] . pi_type = CDF_GETUINT32 ( q , 0 ) ; DPRINTF ( ( ""%"" SIZE_T_FORMAT ""u)id=%xtype=%xoffs=0x%tx,0x%x\\n"" , i , inp [ i ] . pi_id , inp [ i ] . pi_type , q - p , offs ) ) ; if ( inp [ i ] . pi_type & CDF_VECTOR ) { nelements = CDF_GETUINT32 ( q , 1 ) ; if ( nelements == 0 ) { DPRINTF ( ( ""CDF_VECTORwithnelements==0\\n"" ) ) ; goto out ; } o = 2 ; } else { nelements = 1 ; o = 1 ; } o4 = o * sizeof ( uint32_t ) ; if ( inp [ i ] . pi_type & ( CDF_ARRAY | CDF_BYREF | CDF_RESERVED ) ) goto unknown ; switch ( inp [ i ] . pi_type & CDF_TYPEMASK ) { case CDF_NULL : case CDF_EMPTY : break ; case CDF_SIGNED16 : if ( inp [ i ] . pi_type & CDF_VECTOR ) goto unknown ; ( void ) memcpy ( & s16 , & q [ o4 ] , sizeof ( s16 ) ) ; inp [ i ] . pi_s16 = CDF_TOLE2 ( s16 ) ; break ; case CDF_SIGNED32 : if ( inp [ i ] . pi_type & CDF_VECTOR ) goto unknown ; ( void ) memcpy ( & s32 , & q [ o4 ] , sizeof ( s32 ) ) ; inp [ i ] . pi_s32 = CDF_TOLE4 ( ( uint32_t ) s32 ) ; break ; case CDF_BOOL : case CDF_UNSIGNED32 : if ( inp [ i ] . pi_type & CDF_VECTOR ) goto unknown ; ( void ) memcpy ( & u32 , & q [ o4 ] , sizeof ( u32 ) ) ; inp [ i ] . pi_u32 = CDF_TOLE4 ( u32 ) ; break ; case CDF_SIGNED64 : if ( inp [ i ] . pi_type & CDF_VECTOR ) goto unknown ; ( void ) memcpy ( & s64 , & q [ o4 ] , sizeof ( s64 ) ) ; inp [ i ] . pi_s64 = CDF_TOLE8 ( ( uint64_t ) s64 ) ; break ; case CDF_UNSIGNED64 : if ( inp [ i ] . pi_type & CDF_VECTOR ) goto unknown ; ( void ) memcpy ( & u64 , & q [ o4 ] , sizeof ( u64 ) ) ; inp [ i ] . pi_u64 = CDF_TOLE8 ( ( uint64_t ) u64 ) ; break ; case CDF_FLOAT : if ( inp [ i ] . pi_type & CDF_VECTOR ) goto unknown ; ( void ) memcpy ( & u32 , & q [ o4 ] , sizeof ( u32 ) ) ; u32 = CDF_TOLE4 ( u32 ) ; memcpy ( & inp [ i ] . pi_f , & u32 , sizeof ( inp [ i ] . pi_f ) ) ; break ; case CDF_DOUBLE : if ( inp [ i ] . pi_type & CDF_VECTOR ) goto unknown ; ( void ) memcpy ( & u64 , & q [ o4 ] , sizeof ( u64 ) ) ; u64 = CDF_TOLE8 ( ( uint64_t ) u64 ) ; memcpy ( & inp [ i ] . pi_d , & u64 , sizeof ( inp [ i ] . pi_d ) ) ; break ; case CDF_LENGTH32_STRING : case CDF_LENGTH32_WSTRING : if ( nelements > 1 ) { size_t nelem = inp - * info ; if ( * maxcount > CDF_PROP_LIMIT || nelements > CDF_PROP_LIMIT ) goto out ; * maxcount += nelements ; inp = CAST ( cdf_property_info_t * , realloc ( * info , * maxcount * sizeof ( * inp ) ) ) ; if ( inp == NULL ) goto out ; * info = inp ; inp = * info + nelem ; } DPRINTF ( ( ""nelements=%"" SIZE_T_FORMAT ""u\\n"" , nelements ) ) ; for ( j = 0 ; j < nelements && i < sh . sh_properties ; j ++ , i ++ ) { uint32_t l = CDF_GETUINT32 ( q , o ) ; inp [ i ] . pi_str . s_len = l ; inp [ i ] . pi_str . s_buf = ( const char * ) ( const void * ) ( & q [ o4 + sizeof ( l ) ] ) ; DPRINTF ( ( ""l=%d,r=%"" SIZE_T_FORMAT ""u,s=%s\\n"" , l , CDF_ROUND ( l , sizeof ( l ) ) , inp [ i ] . pi_str . s_buf ) ) ; if ( l & 1 ) l ++ ; o += l >> 1 ; if ( q + o >= e ) goto out ; o4 = o * sizeof ( uint32_t ) ; } i -- ; break ; case CDF_FILETIME : if ( inp [ i ] . pi_type & CDF_VECTOR ) goto unknown ; ( void ) memcpy ( & tp , & q [ o4 ] , sizeof ( tp ) ) ; inp [ i ] . pi_tp = CDF_TOLE8 ( ( uint64_t ) tp ) ; break ; case CDF_CLIPBOARD : if ( inp [ i ] . pi_type & CDF_VECTOR ) goto unknown ; break ; default : unknown : DPRINTF ( ( ""Don\'tknowhowtodealwith%x\\n"" , inp [ i ] . pi_type ) ) ; break ; } } return 0 ; out : free ( * info ) ; return - 1 ; } "," if ( q < p || q ",file@file/7ba1409a1aee5925180de546057ddd84ff267947,CVE-2014-3587,https://github.com/file/file/commit/7ba1409a1aee5925180de546057ddd84ff267947,2014-08-23T01:55Z 191,CWE-20,"CWE-20 void init_util ( void ) { filegen_register ( statsdir , ""peerstats"" , & peerstats ) ; filegen_register ( statsdir , ""loopstats"" , & loopstats ) ; filegen_register ( statsdir , ""clockstats"" , & clockstats ) ; filegen_register ( statsdir , ""rawstats"" , & rawstats ) ; filegen_register ( statsdir , ""sysstats"" , & sysstats ) ; filegen_register ( statsdir , ""protostats"" , & protostats ) ; # ifdef AUTOKEY filegen_register ( statsdir , ""cryptostats"" , & cryptostats ) ; # endif # ifdef DEBUG_TIMING filegen_register ( statsdir , ""timingstats"" , & timingstats ) ; # endif step_callback = & ntpd_time_stepped ; # ifdef DEBUG atexit ( & uninit_util ) ; # endif } "," protostats ) ; filegen_register ( statsdir cryptostats ) ; filegen_register ( statsdir timingstats ) ; step_callback = & ",ntp-project@ntp/52e977d79a0c4ace997e5c74af429844da2f27be,CVE-2015-5195,https://github.com/ntp-project/ntp/commit/52e977d79a0c4ace997e5c74af429844da2f27be,2017-07-21T14:29Z 192,CWE-264,"CWE-264 static FILE * pw_tmpfile ( int lockfd ) { FILE * fd ; char * tmpname = NULL ; char * dir = ""/etc"" ; if ( ( fd = xfmkstemp ( & tmpname , dir ) ) == NULL ) { ulckpwdf ( ) ; err ( EXIT_FAILURE , _ ( ""can\'topentemporaryfile"" ) ) ; } copyfile ( lockfd , fileno ( fd ) ) ; tmp_file = tmpname ; return fd ; } "," = NULL ; if ( ( & tmpname , ""/etc"" , "".vipw"" ) ) == ",karelzak@util-linux/bde91c85bdc77975155058276f99d2e0f5eab5a9,CVE-2015-5224,https://github.com/karelzak/util-linux/commit/bde91c85bdc77975155058276f99d2e0f5eab5a9,2017-08-23T15:29Z 193,CWE-400,"CWE-400 static void commit_tree ( struct mount * mnt , struct mount * shadows ) { struct mount * parent = mnt -> mnt_parent ; struct mount * m ; LIST_HEAD ( head ) ; struct mnt_namespace * n = parent -> mnt_ns ; BUG_ON ( parent == mnt ) ; list_add_tail ( & head , & mnt -> mnt_list ) ; list_for_each_entry ( m , & head , mnt_list ) m -> mnt_ns = n ; list_splice ( & head , n -> list . prev ) ; attach_shadowed ( mnt , parent , shadows ) ; touch_mnt_namespace ( n ) ; } "," prev ) ; n -> mounts += n -> pending_mounts ; n -> pending_mounts = 0 ; ",torvalds@linux/d29216842a85c7970c536108e093963f02714498,CVE-2016-6213,https://github.com/torvalds/linux/commit/d29216842a85c7970c536108e093963f02714498,2016-12-28T07:59Z 194,CWE-200,"CWE-200 __visible __notrace_funcgraph struct task_struct * __switch_to ( struct task_struct * prev_p , struct task_struct * next_p ) { struct thread_struct * prev = & prev_p -> thread ; struct thread_struct * next = & next_p -> thread ; int cpu = smp_processor_id ( ) ; struct tss_struct * tss = & per_cpu ( init_tss , cpu ) ; unsigned fsindex , gsindex ; fpu_switch_t fpu ; fpu = switch_fpu_prepare ( prev_p , next_p , cpu ) ; load_sp0 ( tss , next ) ; savesegment ( es , prev -> es ) ; if ( unlikely ( next -> es | prev -> es ) ) loadsegment ( es , next -> es ) ; savesegment ( ds , prev -> ds ) ; if ( unlikely ( next -> ds | prev -> ds ) ) loadsegment ( ds , next -> ds ) ; savesegment ( fs , fsindex ) ; savesegment ( gs , gsindex ) ; load_TLS ( next , cpu ) ; arch_end_context_switch ( next_p ) ; if ( unlikely ( fsindex | next -> fsindex | prev -> fs ) ) { loadsegment ( fs , next -> fsindex ) ; if ( fsindex ) prev -> fs = 0 ; } if ( next -> fs ) wrmsrl ( MSR_FS_BASE , next -> fs ) ; prev -> fsindex = fsindex ; if ( unlikely ( gsindex | next -> gsindex | prev -> gs ) ) { load_gs_index ( next -> gsindex ) ; if ( gsindex ) prev -> gs = 0 ; } if ( next -> gs ) wrmsrl ( MSR_KERNEL_GS_BASE , next -> gs ) ; prev -> gsindex = gsindex ; switch_fpu_finish ( next_p , fpu ) ; prev -> usersp = this_cpu_read ( old_rsp ) ; this_cpu_write ( old_rsp , next -> usersp ) ; this_cpu_write ( current_task , next_p ) ; task_thread_info ( prev_p ) -> saved_preempt_count = this_cpu_read ( __preempt_count ) ; this_cpu_write ( __preempt_count , task_thread_info ( next_p ) -> saved_preempt_count ) ; this_cpu_write ( kernel_stack , ( unsigned long ) task_stack_page ( next_p ) + THREAD_SIZE - KERNEL_STACK_OFFSET ) ; if ( unlikely ( task_thread_info ( next_p ) -> flags & _TIF_WORK_CTXSW_NEXT || task_thread_info ( prev_p ) -> flags & _TIF_WORK_CTXSW_PREV ) ) __switch_to_xtra ( prev_p , next_p , tss ) ; return prev_p ; } "," ; savesegment ( fs , fsindex ) ; savesegment ( gs , gsindex ) ; load_TLS ( next , cpu ) ; arch_end_context_switch ( next_p ) ; savesegment ( next -> ds ) ; if ",torvalds@linux/f647d7c155f069c1a068030255c300663516420e,CVE-2014-9419,https://github.com/torvalds/linux/commit/f647d7c155f069c1a068030255c300663516420e,2014-12-26T00:59Z 195,CWE-200,"CWE-200 static void save_text_if_changed ( const char * name , const char * new_value ) { if ( ! g_hash_table_lookup ( g_loaded_texts , name ) ) return ; const char * old_value = g_cd ? problem_data_get_content_or_NULL ( g_cd , name ) : """" ; if ( ! old_value ) old_value = """" ; if ( strcmp ( new_value , old_value ) != 0 ) { struct dump_dir * dd = wizard_open_directory_for_writing ( g_dump_dir_name ) ; if ( dd ) dd_save_text ( dd , name , new_value ) ; dd_close ( dd ) ; problem_data_reload_from_dump_dir ( ) ; update_gui_state_from_problem_data ( 0 ) ; } } "," dd ) ; } } ",abrt@libreport/257578a23d1537a2d235aaa2b1488ee4f818e360,CVE-2015-5302,https://github.com/abrt/libreport/commit/257578a23d1537a2d235aaa2b1488ee4f818e360,2015-12-07T18:59Z 196,CWE-000,"CWE-000 IHEVCD_ERROR_T ihevcd_parse_pps ( codec_t * ps_codec ) { IHEVCD_ERROR_T ret = ( IHEVCD_ERROR_T ) IHEVCD_SUCCESS ; WORD32 value ; WORD32 pps_id ; pps_t * ps_pps ; sps_t * ps_sps ; bitstrm_t * ps_bitstrm = & ps_codec -> s_parse . s_bitstrm ; if ( 0 == ps_codec -> i4_sps_done ) return IHEVCD_INVALID_HEADER ; UEV_PARSE ( ""pic_parameter_set_id"" , value , ps_bitstrm ) ; pps_id = value ; if ( ( pps_id >= MAX_PPS_CNT ) || ( pps_id < 0 ) ) { if ( ps_codec -> i4_pps_done ) return IHEVCD_UNSUPPORTED_PPS_ID ; else pps_id = 0 ; } ps_pps = ( ps_codec -> s_parse . ps_pps_base + MAX_PPS_CNT - 1 ) ; ps_pps -> i1_pps_id = pps_id ; UEV_PARSE ( ""seq_parameter_set_id"" , value , ps_bitstrm ) ; ps_pps -> i1_sps_id = value ; ps_pps -> i1_sps_id = CLIP3 ( ps_pps -> i1_sps_id , 0 , MAX_SPS_CNT - 2 ) ; ps_sps = ( ps_codec -> s_parse . ps_sps_base + ps_pps -> i1_sps_id ) ; if ( 0 == ps_sps -> i1_sps_valid ) { return IHEVCD_INVALID_HEADER ; } BITS_PARSE ( ""dependent_slices_enabled_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_dependent_slice_enabled_flag = value ; BITS_PARSE ( ""output_flag_present_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_output_flag_present_flag = value ; BITS_PARSE ( ""num_extra_slice_header_bits"" , value , ps_bitstrm , 3 ) ; ps_pps -> i1_num_extra_slice_header_bits = value ; BITS_PARSE ( ""sign_data_hiding_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_sign_data_hiding_flag = value ; BITS_PARSE ( ""cabac_init_present_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_cabac_init_present_flag = value ; UEV_PARSE ( ""num_ref_idx_l0_default_active_minus1"" , value , ps_bitstrm ) ; ps_pps -> i1_num_ref_idx_l0_default_active = value + 1 ; UEV_PARSE ( ""num_ref_idx_l1_default_active_minus1"" , value , ps_bitstrm ) ; ps_pps -> i1_num_ref_idx_l1_default_active = value + 1 ; SEV_PARSE ( ""pic_init_qp_minus26"" , value , ps_bitstrm ) ; ps_pps -> i1_pic_init_qp = value + 26 ; BITS_PARSE ( ""constrained_intra_pred_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_constrained_intra_pred_flag = value ; BITS_PARSE ( ""transform_skip_enabled_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_transform_skip_enabled_flag = value ; BITS_PARSE ( ""cu_qp_delta_enabled_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_cu_qp_delta_enabled_flag = value ; if ( ps_pps -> i1_cu_qp_delta_enabled_flag ) { UEV_PARSE ( ""diff_cu_qp_delta_depth"" , value , ps_bitstrm ) ; ps_pps -> i1_diff_cu_qp_delta_depth = value ; } else { ps_pps -> i1_diff_cu_qp_delta_depth = 0 ; } ps_pps -> i1_log2_min_cu_qp_delta_size = ps_sps -> i1_log2_ctb_size - ps_pps -> i1_diff_cu_qp_delta_depth ; SEV_PARSE ( ""cb_qp_offset"" , value , ps_bitstrm ) ; ps_pps -> i1_pic_cb_qp_offset = value ; SEV_PARSE ( ""cr_qp_offset"" , value , ps_bitstrm ) ; ps_pps -> i1_pic_cr_qp_offset = value ; BITS_PARSE ( ""slicelevel_chroma_qp_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_pic_slice_level_chroma_qp_offsets_present_flag = value ; BITS_PARSE ( ""weighted_pred_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_weighted_pred_flag = value ; BITS_PARSE ( ""weighted_bipred_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_weighted_bipred_flag = value ; BITS_PARSE ( ""transquant_bypass_enable_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_transquant_bypass_enable_flag = value ; BITS_PARSE ( ""tiles_enabled_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_tiles_enabled_flag = value ; BITS_PARSE ( ""entropy_coding_sync_enabled_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_entropy_coding_sync_enabled_flag = value ; ps_pps -> i1_loop_filter_across_tiles_enabled_flag = 0 ; if ( ps_pps -> i1_tiles_enabled_flag ) { WORD32 wd = ALIGN64 ( ps_codec -> i4_wd ) ; WORD32 ht = ALIGN64 ( ps_codec -> i4_ht ) ; WORD32 max_tile_cols = ( wd + MIN_TILE_WD - 1 ) / MIN_TILE_WD ; WORD32 max_tile_rows = ( ht + MIN_TILE_HT - 1 ) / MIN_TILE_HT ; UEV_PARSE ( ""num_tile_columns_minus1"" , value , ps_bitstrm ) ; ps_pps -> i1_num_tile_columns = value + 1 ; UEV_PARSE ( ""num_tile_rows_minus1"" , value , ps_bitstrm ) ; ps_pps -> i1_num_tile_rows = value + 1 ; if ( ( ps_pps -> i1_num_tile_columns < 1 ) || ( ps_pps -> i1_num_tile_columns > max_tile_cols ) || ( ps_pps -> i1_num_tile_rows < 1 ) || ( ps_pps -> i1_num_tile_rows > max_tile_rows ) ) return IHEVCD_INVALID_HEADER ; BITS_PARSE ( ""uniform_spacing_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_uniform_spacing_flag = value ; { WORD32 start ; WORD32 i , j ; start = 0 ; for ( i = 0 ; i < ps_pps -> i1_num_tile_columns ; i ++ ) { tile_t * ps_tile ; if ( ! ps_pps -> i1_uniform_spacing_flag ) { if ( i < ( ps_pps -> i1_num_tile_columns - 1 ) ) { UEV_PARSE ( ""column_width_minus1[i]"" , value , ps_bitstrm ) ; value += 1 ; } else { value = ps_sps -> i2_pic_wd_in_ctb - start ; } } else { value = ( ( i + 1 ) * ps_sps -> i2_pic_wd_in_ctb ) / ps_pps -> i1_num_tile_columns - ( i * ps_sps -> i2_pic_wd_in_ctb ) / ps_pps -> i1_num_tile_columns ; } for ( j = 0 ; j < ps_pps -> i1_num_tile_rows ; j ++ ) { ps_tile = ps_pps -> ps_tile + j * ps_pps -> i1_num_tile_columns + i ; ps_tile -> u1_pos_x = start ; ps_tile -> u2_wd = value ; } start += value ; if ( ( start > ps_sps -> i2_pic_wd_in_ctb ) || ( value <= 0 ) ) return IHEVCD_INVALID_HEADER ; } start = 0 ; for ( i = 0 ; i < ( ps_pps -> i1_num_tile_rows ) ; i ++ ) { tile_t * ps_tile ; if ( ! ps_pps -> i1_uniform_spacing_flag ) { if ( i < ( ps_pps -> i1_num_tile_rows - 1 ) ) { UEV_PARSE ( ""row_height_minus1[i]"" , value , ps_bitstrm ) ; value += 1 ; } else { value = ps_sps -> i2_pic_ht_in_ctb - start ; } } else { value = ( ( i + 1 ) * ps_sps -> i2_pic_ht_in_ctb ) / ps_pps -> i1_num_tile_rows - ( i * ps_sps -> i2_pic_ht_in_ctb ) / ps_pps -> i1_num_tile_rows ; } for ( j = 0 ; j < ps_pps -> i1_num_tile_columns ; j ++ ) { ps_tile = ps_pps -> ps_tile + i * ps_pps -> i1_num_tile_columns + j ; ps_tile -> u1_pos_y = start ; ps_tile -> u2_ht = value ; } start += value ; if ( ( start > ps_sps -> i2_pic_ht_in_ctb ) || ( value <= 0 ) ) return IHEVCD_INVALID_HEADER ; } } BITS_PARSE ( ""loop_filter_across_tiles_enabled_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_loop_filter_across_tiles_enabled_flag = value ; } else { ps_pps -> i1_num_tile_columns = 1 ; ps_pps -> i1_num_tile_rows = 1 ; ps_pps -> i1_uniform_spacing_flag = 1 ; ps_pps -> ps_tile -> u1_pos_x = 0 ; ps_pps -> ps_tile -> u1_pos_y = 0 ; ps_pps -> ps_tile -> u2_wd = ps_sps -> i2_pic_wd_in_ctb ; ps_pps -> ps_tile -> u2_ht = ps_sps -> i2_pic_ht_in_ctb ; } BITS_PARSE ( ""loop_filter_across_slices_enabled_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_loop_filter_across_slices_enabled_flag = value ; BITS_PARSE ( ""deblocking_filter_control_present_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_deblocking_filter_control_present_flag = value ; ps_pps -> i1_pic_disable_deblocking_filter_flag = 0 ; ps_pps -> i1_deblocking_filter_override_enabled_flag = 0 ; ps_pps -> i1_beta_offset_div2 = 0 ; ps_pps -> i1_tc_offset_div2 = 0 ; if ( ps_pps -> i1_deblocking_filter_control_present_flag ) { BITS_PARSE ( ""deblocking_filter_override_enabled_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_deblocking_filter_override_enabled_flag = value ; BITS_PARSE ( ""pic_disable_deblocking_filter_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_pic_disable_deblocking_filter_flag = value ; if ( ! ps_pps -> i1_pic_disable_deblocking_filter_flag ) { SEV_PARSE ( ""pps_beta_offset_div2"" , value , ps_bitstrm ) ; ps_pps -> i1_beta_offset_div2 = value ; SEV_PARSE ( ""pps_tc_offset_div2"" , value , ps_bitstrm ) ; ps_pps -> i1_tc_offset_div2 = value ; } } BITS_PARSE ( ""pps_scaling_list_data_present_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_pps_scaling_list_data_present_flag = value ; if ( ps_pps -> i1_pps_scaling_list_data_present_flag ) { COPY_DEFAULT_SCALING_LIST ( ps_pps -> pi2_scaling_mat ) ; ihevcd_scaling_list_data ( ps_codec , ps_pps -> pi2_scaling_mat ) ; } BITS_PARSE ( ""lists_modification_present_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_lists_modification_present_flag = value ; UEV_PARSE ( ""log2_parallel_merge_level_minus2"" , value , ps_bitstrm ) ; ps_pps -> i1_log2_parallel_merge_level = value + 2 ; BITS_PARSE ( ""slice_header_extension_present_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_slice_header_extension_present_flag = value ; BITS_PARSE ( ""pps_extension_flag"" , value , ps_bitstrm , 1 ) ; if ( ( UWORD8 * ) ps_bitstrm -> pu4_buf > ps_bitstrm -> pu1_buf_max ) return IHEVCD_INVALID_PARAMETER ; ps_codec -> i4_pps_done = 1 ; return ret ; } "," = value ; if ( ( ps_pps -> i1_tiles_enabled_flag ) && ( ps_sps -> i1_log2_ctb_size == 4 ) && ( ( ps_sps -> i2_pic_width_in_luma_samples >= 4096 ) || ( ps_sps -> i2_pic_height_in_luma_samples >= 4096 ) ) ) { return IHEVCD_INVALID_HEADER ; } ",external@libhevc/25c0ffbe6a181b4a373c3c9b421ea449d457e6ed,CVE-2017-0811,https://android.googlesource.com/platform/external/libhevc/+/25c0ffbe6a181b4a373c3c9b421ea449d457e6ed,2017-10-04T01:29Z 197,CWE-399,"CWE-399 static void update_exception_bitmap ( struct kvm_vcpu * vcpu ) { u32 eb ; eb = ( 1u << PF_VECTOR ) | ( 1u << UD_VECTOR ) | ( 1u << MC_VECTOR ) | ( 1u << NM_VECTOR ) | ( 1u << DB_VECTOR ) ; if ( ( vcpu -> guest_debug & ( KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_USE_SW_BP ) ) == ( KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_USE_SW_BP ) ) eb |= 1u << BP_VECTOR ; if ( to_vmx ( vcpu ) -> rmode . vm86_active ) eb = ~ 0 ; if ( enable_ept ) eb &= ~ ( 1u << PF_VECTOR ) ; if ( vcpu -> fpu_active ) eb &= ~ ( 1u << NM_VECTOR ) ; if ( is_guest_mode ( vcpu ) ) eb |= get_vmcs12 ( vcpu ) -> exception_bitmap ; vmcs_write32 ( EXCEPTION_BITMAP , eb ) ; } "," 1u << DB_VECTOR ) | ( 1u << AC_VECTOR ",torvalds@linux/54a20552e1eae07aa240fa370a0293e006b5faed,CVE-2015-5307,https://github.com/torvalds/linux/commit/54a20552e1eae07aa240fa370a0293e006b5faed,2015-11-16T11:59Z 198,CWE-125,"CWE-125 static void nfs_printfh ( netdissect_options * ndo , register const uint32_t * dp , const u_int len ) { my_fsid fsid ; uint32_t ino ; const char * sfsname = NULL ; char * spacep ; if ( ndo -> ndo_uflag ) { u_int i ; char const * sep = """" ; ND_PRINT ( ( ndo , ""fh["" ) ) ; for ( i = 0 ; i < len ; i ++ ) { ND_PRINT ( ( ndo , ""%s%x"" , sep , dp [ i ] ) ) ; sep = "":"" ; } ND_PRINT ( ( ndo , ""]"" ) ) ; return ; } Parse_fh ( ( const u_char * ) dp , len , & fsid , & ino , NULL , & sfsname , 0 ) ; if ( sfsname ) { static char temp [ NFSX_V3FHMAX + 1 ] ; strncpy ( temp , sfsname , NFSX_V3FHMAX ) ; temp [ sizeof ( temp ) - 1 ] = '\\0' ; spacep = strchr ( temp , '' ) ; if ( spacep ) * spacep = '\\0' ; ND_PRINT ( ( ndo , ""fh%s/"" , temp ) ) ; } else { ND_PRINT ( ( ndo , ""fh%d,%d/"" , fsid . Fsid_dev . Major , fsid . Fsid_dev . Minor ) ) ; } if ( fsid . Fsid_dev . Minor == 257 ) ND_PRINT ( ( ndo , ""%s"" , fsid . Opaque_Handle ) ) ; else ND_PRINT ( ( ndo , ""%ld"" , ( long ) ino ) ) ; } "," sfsname ) { char temp [ 1 ] ; u_int stringlen ; stringlen = len ; if ( stringlen > NFSX_V3FHMAX ) stringlen = NFSX_V3FHMAX ; , sfsname , stringlen ) ; temp ; temp [ stringlen ] = '\\0' ",the-tcpdump-group@tcpdump/7a923447fd49a069a0fd3b6c3547438ab5ee2123,CVE-2017-13001,https://github.com/the-tcpdump-group/tcpdump/commit/7a923447fd49a069a0fd3b6c3547438ab5ee2123,2017-09-14T06:29Z 199,CWE-000,"CWE-000 static inline int ip6_ufo_append_data ( struct sock * sk , int getfrag ( void * from , char * to , int offset , int len , int odd , struct sk_buff * skb ) , void * from , int length , int hh_len , int fragheaderlen , int transhdrlen , int mtu , unsigned int flags ) { struct sk_buff * skb ; int err ; if ( ( skb = skb_peek_tail ( & sk -> sk_write_queue ) ) == NULL ) { skb = sock_alloc_send_skb ( sk , hh_len + fragheaderlen + transhdrlen + 20 , ( flags & MSG_DONTWAIT ) , & err ) ; if ( skb == NULL ) return - ENOMEM ; skb_reserve ( skb , hh_len ) ; skb_put ( skb , fragheaderlen + transhdrlen ) ; skb_reset_network_header ( skb ) ; skb -> transport_header = skb -> network_header + fragheaderlen ; skb -> ip_summed = CHECKSUM_PARTIAL ; skb -> csum = 0 ; } err = skb_append_datato_frags ( sk , skb , getfrag , from , ( length - transhdrlen ) ) ; if ( ! err ) { struct frag_hdr fhdr ; skb_shinfo ( skb ) -> gso_size = ( mtu - fragheaderlen - sizeof ( struct frag_hdr ) ) & ~ 7 ; skb_shinfo ( skb ) -> gso_type = SKB_GSO_UDP ; ipv6_select_ident ( & fhdr ) ; skb_shinfo ( skb ) -> ip6_frag_id = fhdr . identification ; __skb_queue_tail ( & sk -> sk_write_queue , skb ) ; return 0 ; } kfree_skb ( skb ) ; return err ; } "," unsigned int flags , struct rt6_info * rt ( & fhdr , rt ",torvalds@linux/87c48fa3b4630905f98268dde838ee43626a060c,CVE-2011-2699,https://github.com/torvalds/linux/commit/87c48fa3b4630905f98268dde838ee43626a060c,2012-05-24T23:55Z 200,CWE-772,"CWE-772 int hsr_dev_finalize ( struct net_device * hsr_dev , struct net_device * slave [ 2 ] , unsigned char multicast_spec , u8 protocol_version ) { struct hsr_priv * hsr ; struct hsr_port * port ; int res ; hsr = netdev_priv ( hsr_dev ) ; INIT_LIST_HEAD ( & hsr -> ports ) ; INIT_LIST_HEAD ( & hsr -> node_db ) ; INIT_LIST_HEAD ( & hsr -> self_node_db ) ; ether_addr_copy ( hsr_dev -> dev_addr , slave [ 0 ] -> dev_addr ) ; res = hsr_create_self_node ( & hsr -> self_node_db , hsr_dev -> dev_addr , slave [ 1 ] -> dev_addr ) ; if ( res < 0 ) return res ; spin_lock_init ( & hsr -> seqnr_lock ) ; hsr -> sequence_nr = HSR_SEQNR_START ; hsr -> sup_sequence_nr = HSR_SUP_SEQNR_START ; timer_setup ( & hsr -> announce_timer , hsr_announce , 0 ) ; timer_setup ( & hsr -> prune_timer , hsr_prune_nodes , 0 ) ; ether_addr_copy ( hsr -> sup_multicast_addr , def_multicast_addr ) ; hsr -> sup_multicast_addr [ ETH_ALEN - 1 ] = multicast_spec ; hsr -> protVersion = protocol_version ; netif_carrier_off ( hsr_dev ) ; res = hsr_add_port ( hsr , hsr_dev , HSR_PT_MASTER ) ; if ( res ) return res ; res = register_netdevice ( hsr_dev ) ; if ( res ) goto fail ; res = hsr_add_port ( hsr , slave [ 0 ] , HSR_PT_SLAVE_A ) ; if ( res ) goto fail ; res = hsr_add_port ( hsr , slave [ 1 ] , HSR_PT_SLAVE_B ) ; if ( res ) goto fail ; mod_timer ( & hsr -> prune_timer , jiffies + msecs_to_jiffies ( PRUNE_PERIOD ) ) ; return 0 ; fail : hsr_for_each_port ( hsr , port ) hsr_del_port ( port ) ; return res ; } "," ( res ) goto err_add_port ; res = port ) ; err_add_port : hsr_del_node ( & hsr -> self_node_db ) ; ",torvalds@linux/6caabe7f197d3466d238f70915d65301f1716626,CVE-2019-16995,https://github.com/torvalds/linux/commit/6caabe7f197d3466d238f70915d65301f1716626,2019-09-30T13:15Z 201,CWE-399,"CWE-399 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 ) { 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 # 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 , ""UNIXType:L8"" ) ; goto wayout ; # ifdef WITH_TLS } else if ( enforce_tls_auth > 0 && ! strcmp ( cmd , ""auth"" ) && ! strcasecmp ( arg , ""tls"" ) ) { addreply_noformat ( 234 , ""AUTHTLSOK."" ) ; doreply ( ) ; if ( tls_cnx == NULL ) { ( 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 , ""Fallbackto[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 ) { 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 , ""SITEIDLE:"" 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 , ""UTCOnly"" ) ; 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 } } "," NULL ) { flush_cmd ( ) ; ",jedisct1@pure-ftpd/65c4d4ad331e94661de763e9b5304d28698999c4,CVE-2011-1575,https://github.com/jedisct1/pure-ftpd/commit/65c4d4ad331e94661de763e9b5304d28698999c4,2011-05-23T22:55Z 202,CWE-119,"CWE-119 void vp9_setup_dst_planes ( MACROBLOCKD * xd , const YV12_BUFFER_CONFIG * src , int mi_row , int mi_col ) { uint8_t * const buffers [ 4 ] = { src -> y_buffer , src -> u_buffer , src -> v_buffer , src -> alpha_buffer } ; const int strides [ 4 ] = { src -> y_stride , src -> uv_stride , src -> uv_stride , src -> alpha_stride } ; int i ; for ( i = 0 ; i < MAX_MB_PLANE ; ++ i ) { struct macroblockd_plane * const pd = & xd -> plane [ i ] ; setup_pred_plane ( & pd -> dst , buffers [ i ] , strides [ i ] , mi_row , mi_col , NULL , pd -> subsampling_x , pd -> subsampling_y ) ; } } "," void vp9_setup_dst_planes ( struct macroblockd_plane planes [ MAX_MB_PLANE ] , const YV12_BUFFER_CONFIG const buffers [ MAX_MB_PLANE ] = { src -> v_buffer } ; const int strides [ MAX_MB_PLANE ] = { src -> uv_stride } ; int pd = & planes [ i ] ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 203,CWE-119,"CWE-119 int nfs3svc_decode_writeargs ( struct svc_rqst * rqstp , __be32 * p , struct nfsd3_writeargs * args ) { unsigned int len , v , hdr , dlen ; u32 max_blocksize = svc_max_payload ( rqstp ) ; struct kvec * head = rqstp -> rq_arg . head ; struct kvec * tail = rqstp -> rq_arg . tail ; p = decode_fh ( p , & args -> fh ) ; if ( ! p ) return 0 ; p = xdr_decode_hyper ( p , & args -> offset ) ; args -> count = ntohl ( * p ++ ) ; args -> stable = ntohl ( * p ++ ) ; len = args -> len = ntohl ( * p ++ ) ; if ( args -> count != args -> len ) return 0 ; hdr = ( void * ) p - head -> iov_base ; dlen = head -> iov_len + rqstp -> rq_arg . page_len + tail -> iov_len - hdr ; if ( dlen < XDR_QUADLEN ( len ) * 4 ) return 0 ; if ( args -> count > max_blocksize ) { args -> count = max_blocksize ; len = args -> len = max_blocksize ; } rqstp -> rq_vec [ 0 ] . iov_base = ( void * ) p ; rqstp -> rq_vec [ 0 ] . iov_len = head -> iov_len - hdr ; v = 0 ; while ( len > rqstp -> rq_vec [ v ] . iov_len ) { len -= rqstp -> rq_vec [ v ] . iov_len ; v ++ ; rqstp -> rq_vec [ v ] . iov_base = page_address ( rqstp -> rq_pages [ v ] ) ; rqstp -> rq_vec [ v ] . iov_len = PAGE_SIZE ; } rqstp -> rq_vec [ v ] . iov_len = len ; args -> vlen = v + 1 ; return 1 ; } "," p ++ ) ; if ( ( void * ) p > head -> iov_base + head -> iov_len ) return 0 ",torvalds@linux/13bf9fbff0e5e099e2b6f003a0ab8ae145436309,CVE-2017-7895,https://github.com/torvalds/linux/commit/13bf9fbff0e5e099e2b6f003a0ab8ae145436309,2017-04-28T10:59Z 204,CWE-000,"CWE-000 static inline void assign_eip_near ( struct x86_emulate_ctxt * ctxt , ulong dst ) { switch ( ctxt -> op_bytes ) { case 2 : ctxt -> _eip = ( u16 ) dst ; break ; case 4 : ctxt -> _eip = ( u32 ) dst ; break ; case 8 : ctxt -> _eip = dst ; break ; default : WARN ( 1 , ""unsupportedeipassignmentsize\\n"" ) ; } } "," static inline int assign_eip_near ( struct dst ) { return assign_eip_far ( ctxt , dst , ctxt -> mode == X86EMUL_MODE_PROT64 ) ; } ) ; } ",torvalds@linux/234f3ce485d54017f15cf5e0699cff4100121601,CVE-2014-3647,https://github.com/torvalds/linux/commit/234f3ce485d54017f15cf5e0699cff4100121601,2014-11-10T11:55Z 205,CWE-119,"CWE-119 static vpx_codec_err_t ctrl_set_invert_tile_order ( vpx_codec_alg_priv_t * ctx , int ctr_id , va_list args ) { ctx -> invert_tile_order = va_arg ( args , int ) ; return VPX_CODEC_OK ; } "," * ctx , va_list args ) ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 206,CWE-399,"CWE-399 static int dissect_spoolss_uint16uni ( tvbuff_t * tvb , int offset , packet_info * pinfo _U_ , proto_tree * tree , guint8 * drep _U_ , char * * data , int hf_name ) { gint len , remaining ; char * text ; if ( offset % 2 ) offset += 2 - ( offset % 2 ) ; remaining = tvb_captured_length_remaining ( tvb , offset ) ; if ( remaining <= 0 ) { if ( data ) * data = g_strdup ( """" ) ; return offset ; } text = tvb_get_string_enc ( NULL , tvb , offset , remaining , ENC_UTF_16 | ENC_LITTLE_ENDIAN ) ; len = ( int ) strlen ( text ) ; proto_tree_add_string ( tree , hf_name , tvb , offset , len * 2 , text ) ; if ( data ) * data = text ; else g_free ( text ) ; return offset + ( len + 1 ) * 2 ; } "," ; remaining = tvb_reported_length_remaining ( tvb , ",wireshark@wireshark/b4d16b4495b732888e12baf5b8a7e9bf2665e22b,CVE-2016-5350,https://github.com/wireshark/wireshark/commit/b4d16b4495b732888e12baf5b8a7e9bf2665e22b,2016-08-07T16:59Z 207,CWE-362,"CWE-362 static ssize_t ocfs2_direct_IO ( struct kiocb * iocb , struct iov_iter * iter ) { struct file * file = iocb -> ki_filp ; struct inode * inode = file -> f_mapping -> host ; struct ocfs2_super * osb = OCFS2_SB ( inode -> i_sb ) ; get_block_t * get_block ; if ( OCFS2_I ( inode ) -> ip_dyn_features & OCFS2_INLINE_DATA_FL ) return 0 ; if ( iocb -> ki_pos + iter -> count > i_size_read ( inode ) && ! ocfs2_supports_append_dio ( osb ) ) return 0 ; if ( iov_iter_rw ( iter ) == READ ) get_block = ocfs2_get_block ; else get_block = ocfs2_dio_get_block ; return __blockdev_direct_IO ( iocb , inode , inode -> i_sb -> s_bdev , iter , get_block , ocfs2_dio_end_io , NULL , 0 ) ; } "," ) get_block = ocfs2_lock_get_block ; else get_block else get_block = ocfs2_dio_wr_get_block ; return __blockdev_direct_IO ",torvalds@linux/3e4c56d41eef5595035872a2ec5a483f42e8917f,CVE-2017-18224,https://github.com/torvalds/linux/commit/3e4c56d41eef5595035872a2ec5a483f42e8917f,2018-03-12T03:29Z 208,CWE-20,"CWE-20 static int rawsock_recvmsg ( struct kiocb * iocb , struct socket * sock , struct msghdr * msg , size_t len , int flags ) { int noblock = flags & MSG_DONTWAIT ; struct sock * sk = sock -> sk ; struct sk_buff * skb ; int copied ; int rc ; pr_debug ( ""sock=%psk=%plen=%zuflags=%d\\n"" , sock , sk , len , flags ) ; skb = skb_recv_datagram ( sk , flags , noblock , & rc ) ; if ( ! skb ) return rc ; msg -> msg_namelen = 0 ; copied = skb -> len ; if ( len < copied ) { msg -> msg_flags |= MSG_TRUNC ; copied = len ; } rc = skb_copy_datagram_iovec ( skb , 0 , msg -> msg_iov , copied ) ; skb_free_datagram ( sk , skb ) ; return rc ? : copied ; } "," return rc ; copied = skb ",torvalds@linux/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,CVE-2013-7271,https://github.com/torvalds/linux/commit/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,2014-01-06T16:55Z 209,CWE-120,"CWE-120 void M_LoadDefaults ( void ) { int i ; int len ; FILE * f ; char def [ 80 ] ; char strparm [ 100 ] ; char * newstring ; int parm ; boolean isstring ; numdefaults = sizeof ( defaults ) / sizeof ( defaults [ 0 ] ) ; for ( i = 0 ; i < numdefaults ; i ++ ) * defaults [ i ] . location = defaults [ i ] . defaultvalue ; i = M_CheckParm ( ""-config"" ) ; if ( i && i < myargc - 1 ) { defaultfile = myargv [ i + 1 ] ; printf ( ""\tdefaultfile:%s\\n"" , defaultfile ) ; } else defaultfile = basedefault ; f = fopen ( defaultfile , ""r"" ) ; if ( f ) { while ( ! feof ( f ) ) { isstring = false ; if ( fscanf ( f , ""%79s%[^\\n]\\n"" , def , strparm ) == 2 ) { if ( strparm [ 0 ] == \'""\' ) { isstring = true ; len = strlen ( strparm ) ; newstring = ( char * ) malloc ( len ) ; strparm [ len - 1 ] = 0 ; strcpy ( newstring , strparm + 1 ) ; } else if ( strparm [ 0 ] == '0' && strparm [ 1 ] == 'x' ) sscanf ( strparm + 2 , ""%x"" , & parm ) ; else sscanf ( strparm , ""%i"" , & parm ) ; for ( i = 0 ; i < numdefaults ; i ++ ) if ( ! strcmp ( def , defaults [ i ] . name ) ) { if ( ! isstring ) * defaults [ i ] . location = parm ; else * defaults [ i ] . location = ( int ) newstring ; break ; } } } fclose ( f ) ; } for ( i = 0 ; i < numdefaults ; i ++ ) { if ( defaults [ i ] . scantranslate ) { parm = * defaults [ i ] . location ; defaults [ i ] . untranslated = parm ; * defaults [ i ] . location = scantokey [ parm ] ; } } } "," ( f , ""%79s%99[^\\n]\\n"" , def , ",AXDOOMER@doom-vanille/8a6d9a02fa991a91ff90ccdc73b5ceabaa6cb9ec,CVE-2020-15007,https://github.com/AXDOOMER/doom-vanille/commit/8a6d9a02fa991a91ff90ccdc73b5ceabaa6cb9ec,2020-06-24T11:15Z 210,CWE-189,"CWE-189 static void perf_event_interrupt ( struct pt_regs * regs ) { int i ; struct cpu_hw_events * cpuhw = & __get_cpu_var ( cpu_hw_events ) ; struct perf_event * event ; unsigned long val ; int found = 0 ; int nmi ; if ( cpuhw -> n_limited ) freeze_limited_counters ( cpuhw , mfspr ( SPRN_PMC5 ) , mfspr ( SPRN_PMC6 ) ) ; perf_read_regs ( regs ) ; nmi = perf_intr_is_nmi ( regs ) ; if ( nmi ) nmi_enter ( ) ; else irq_enter ( ) ; for ( i = 0 ; i < cpuhw -> n_events ; ++ i ) { event = cpuhw -> event [ i ] ; if ( ! event -> hw . idx || is_limited_pmc ( event -> hw . idx ) ) continue ; val = read_pmc ( event -> hw . idx ) ; if ( ( int ) val < 0 ) { found = 1 ; record_and_restart ( event , val , regs , nmi ) ; } } if ( ! found ) { for ( i = 0 ; i < ppmu -> n_counter ; ++ i ) { if ( is_limited_pmc ( i + 1 ) ) continue ; val = read_pmc ( i + 1 ) ; if ( ( int ) val < 0 ) write_pmc ( i + 1 , 0 ) ; } } write_mmcr0 ( cpuhw , cpuhw -> mmcr [ 0 ] ) ; if ( nmi ) nmi_exit ( ) ; else irq_exit ( ) ; } "," ; if ( pmc_overflow ( val ) ) write_pmc ( ",torvalds@linux/0837e3242c73566fc1c0196b4ec61779c25ffc93,CVE-2011-4611,https://github.com/torvalds/linux/commit/0837e3242c73566fc1c0196b4ec61779c25ffc93,2012-05-17T11:00Z 211,CWE-125,"CWE-125 static ssize_t next_line ( struct archive_read * a , const char * * b , ssize_t * avail , ssize_t * ravail , ssize_t * nl ) { ssize_t len ; int quit ; quit = 0 ; if ( * avail == 0 ) { * nl = 0 ; len = 0 ; } else len = get_line_size ( * b , * avail , nl ) ; while ( * nl == 0 && len == * avail && ! quit ) { ssize_t diff = * ravail - * avail ; size_t nbytes_req = ( * ravail + 1023 ) & ~ 1023U ; ssize_t tested ; if ( nbytes_req < ( size_t ) * ravail + 160 ) nbytes_req <<= 1 ; * b = __archive_read_ahead ( a , nbytes_req , avail ) ; if ( * b == NULL ) { if ( * ravail >= * avail ) return ( 0 ) ; * b = __archive_read_ahead ( a , * avail , avail ) ; quit = 1 ; } * ravail = * avail ; * b += diff ; * avail -= diff ; tested = len ; len = get_line_size ( * b , * avail , nl ) ; if ( len >= 0 ) len += tested ; } return ( len ) ; } "," ( * b + len , * avail - len , nl ) ",libarchive@libarchive/eec077f52bfa2d3f7103b4b74d52572ba8a15aca,CVE-2016-8688,https://github.com/libarchive/libarchive/commit/eec077f52bfa2d3f7103b4b74d52572ba8a15aca,2017-02-15T19:59Z 212,CWE-125,"CWE-125 static expr_ty fstring_compile_expr ( const char * expr_start , const char * expr_end , struct compiling * c , const node * n ) { int all_whitespace = 1 ; int kind ; void * data ; PyCompilerFlags cf ; mod_ty mod ; char * str ; PyObject * o , * fstring_name ; Py_ssize_t len ; Py_ssize_t i ; assert ( expr_end >= expr_start ) ; assert ( * ( expr_start - 1 ) == '{' ) ; assert ( * expr_end == '}' || * expr_end == '!' || * expr_end == ':' ) ; o = PyUnicode_DecodeUTF8 ( expr_start , expr_end - expr_start , NULL ) ; if ( o == NULL ) return NULL ; len = PyUnicode_GET_LENGTH ( o ) ; kind = PyUnicode_KIND ( o ) ; data = PyUnicode_DATA ( o ) ; for ( i = 0 ; i < len ; i ++ ) { if ( ! Py_UNICODE_ISSPACE ( PyUnicode_READ ( kind , data , i ) ) ) { all_whitespace = 0 ; break ; } } Py_DECREF ( o ) ; if ( all_whitespace ) { ast_error ( c , n , ""f-string:emptyexpressionnotallowed"" ) ; return NULL ; } len = expr_end - expr_start ; str = PyMem_RawMalloc ( len + 3 ) ; if ( str == NULL ) return NULL ; str [ 0 ] = '(' ; memcpy ( str + 1 , expr_start , len ) ; str [ len + 1 ] = ')' ; str [ len + 2 ] = 0 ; cf . cf_flags = PyCF_ONLY_AST ; fstring_name = PyUnicode_FromString ( """" ) ; mod = string_object_to_c_ast ( str , fstring_name , Py_eval_input , & cf , c -> c_feature_version , c -> c_arena ) ; Py_DECREF ( fstring_name ) ; PyMem_RawFree ( str ) ; if ( ! mod ) return NULL ; return mod -> v . Expression . body ; } "," n ) { PyCompilerFlags cf ; PyCompilerFlags cf ; node * mod_n ; * str ; Py_ssize_t len ; const char * s ; PyObject * fstring_name ; assert ( ':' ) ; for ( s = expr_start ; s != expr_end ; s ++ ) { char c = * s ; if ( ! ( c == '' || c == '\\t' || c == '\\n' || c == '\\f' ) ) { break ; } } if ( s == expr_end ) { ast_error ( c , n , ""f-string:emptyexpressionnotallowed"" ) ; return NULL ; } len = expr_end - expr_start expr_end - expr_start ; str = == NULL ) { PyErr_NoMemory ( ) ; return NULL ; } str [ 0 = PyCF_ONLY_AST ; mod_n = PyParser_SimpleParseStringFlagsFilename ( str , """" , Py_eval_input , 0 ) ; if ( ! mod_n ) { PyMem_RawFree ( str ) ; return NULL ; } str [ 0 ] = '{' ; str [ len + 1 ] = '}' ; fstring_fix_node_location ( n , mod_n , str ) ; PyMem_RawFree ( str ) ; Ta3Node_Free ( mod_n ",python@typed_ast/156afcb26c198e162504a57caddfe0acd9ed7dce,CVE-2019-19275,https://github.com/python/typed_ast/commit/156afcb26c198e162504a57caddfe0acd9ed7dce,2019-11-26T15:15Z 213,CWE-125,"CWE-125 void ntlm_print_message_fields ( NTLM_MESSAGE_FIELDS * fields , const char * name ) { WLog_DBG ( TAG , ""%s(Len:%"" PRIu16 ""MaxLen:%"" PRIu16 ""BufferOffset:%"" PRIu32 "")"" , name , fields -> Len , fields -> MaxLen , fields -> BufferOffset ) ; if ( fields -> Len > 0 ) winpr_HexDump ( TAG , WLOG_DEBUG , fields -> Buffer , fields -> Len ) ; } "," static ",FreeRDP@FreeRDP/2ee663f39dc8dac3d9988e847db19b2d7e3ac8c6,CVE-2018-8789,https://github.com/FreeRDP/FreeRDP/commit/2ee663f39dc8dac3d9988e847db19b2d7e3ac8c6,2018-11-29T18:29Z 214,CWE-119,"CWE-119 cJSON * cJSON_GetObjectItem ( cJSON * object , const char * string ) { cJSON * c = object -> child ; while ( c && cJSON_strcasecmp ( c -> string , string ) ) c = c -> next ; return c ; } "," c = object ? object -> child : 0 ; while ( ",esnet@iperf/91f2fa59e8ed80dfbf400add0164ee0e508e412a,CVE-2016-4303,https://github.com/esnet/iperf/commit/91f2fa59e8ed80dfbf400add0164ee0e508e412a,2016-09-26T14:59Z 215,CWE-20,"CWE-20 static inline key_ref_t __key_update ( key_ref_t key_ref , struct key_preparsed_payload * prep ) { struct key * key = key_ref_to_ptr ( key_ref ) ; int ret ; ret = key_permission ( key_ref , KEY_NEED_WRITE ) ; if ( ret < 0 ) goto error ; ret = - EEXIST ; if ( ! key -> type -> update ) goto error ; down_write ( & key -> sem ) ; ret = key -> type -> update ( key , prep ) ; if ( ret == 0 ) clear_bit ( KEY_FLAG_NEGATIVE , & key -> flags ) ; up_write ( & key -> sem ) ; if ( ret < 0 ) goto error ; out : return key_ref ; error : key_put ( key ) ; key_ref = ERR_PTR ( ret ) ; goto out ; } "," == 0 ) mark_key_instantiated ( key , 0 ) ; up_write ",torvalds@linux/363b02dab09b3226f3bd1420dad9c72b79a42a76,CVE-2017-15951,https://github.com/torvalds/linux/commit/363b02dab09b3226f3bd1420dad9c72b79a42a76,2017-10-28T02:29Z 216,CWE-20,"CWE-20 int net_get ( int s , void * arg , int * len ) { struct net_hdr nh ; int plen ; if ( net_read_exact ( s , & nh , sizeof ( nh ) ) == - 1 ) { return - 1 ; } plen = ntohl ( nh . nh_len ) ; if ( ! ( plen <= * len ) ) printf ( ""PLEN%dtype%dlen%d\\n"" , plen , nh . nh_type , * len ) ; assert ( plen <= * len ) ; * len = plen ; if ( ( * len ) && ( net_read_exact ( s , arg , * len ) == - 1 ) ) { return - 1 ; } return nh . nh_type ; } "," <= * len && plen > 0 ",aircrack-ng@aircrack-ng/88702a3ce4c28a973bf69023cd0312f412f6193e,CVE-2014-8324,https://github.com/aircrack-ng/aircrack-ng/commit/88702a3ce4c28a973bf69023cd0312f412f6193e,2017-10-17T14:29Z 217,CWE-19,"CWE-19 int xfs_attr3_leaf_list_int ( struct xfs_buf * bp , struct xfs_attr_list_context * context ) { struct attrlist_cursor_kern * cursor ; struct xfs_attr_leafblock * leaf ; struct xfs_attr3_icleaf_hdr ichdr ; struct xfs_attr_leaf_entry * entries ; struct xfs_attr_leaf_entry * entry ; int retval ; int i ; trace_xfs_attr_list_leaf ( context ) ; leaf = bp -> b_addr ; xfs_attr3_leaf_hdr_from_disk ( & ichdr , leaf ) ; entries = xfs_attr3_leaf_entryp ( leaf ) ; cursor = context -> cursor ; cursor -> initted = 1 ; if ( context -> resynch ) { entry = & entries [ 0 ] ; for ( i = 0 ; i < ichdr . count ; entry ++ , i ++ ) { if ( be32_to_cpu ( entry -> hashval ) == cursor -> hashval ) { if ( cursor -> offset == context -> dupcnt ) { context -> dupcnt = 0 ; break ; } context -> dupcnt ++ ; } else if ( be32_to_cpu ( entry -> hashval ) > cursor -> hashval ) { context -> dupcnt = 0 ; break ; } } if ( i == ichdr . count ) { trace_xfs_attr_list_notfound ( context ) ; return 0 ; } } else { entry = & entries [ 0 ] ; i = 0 ; } context -> resynch = 0 ; retval = 0 ; for ( ; i < ichdr . count ; entry ++ , i ++ ) { if ( be32_to_cpu ( entry -> hashval ) != cursor -> hashval ) { cursor -> hashval = be32_to_cpu ( entry -> hashval ) ; cursor -> offset = 0 ; } if ( entry -> flags & XFS_ATTR_INCOMPLETE ) continue ; if ( entry -> flags & XFS_ATTR_LOCAL ) { xfs_attr_leaf_name_local_t * name_loc = xfs_attr3_leaf_name_local ( leaf , i ) ; retval = context -> put_listent ( context , entry -> flags , name_loc -> nameval , ( int ) name_loc -> namelen , be16_to_cpu ( name_loc -> valuelen ) , & name_loc -> nameval [ name_loc -> namelen ] ) ; if ( retval ) return retval ; } else { xfs_attr_leaf_name_remote_t * name_rmt = xfs_attr3_leaf_name_remote ( leaf , i ) ; int valuelen = be32_to_cpu ( name_rmt -> valuelen ) ; if ( context -> put_value ) { xfs_da_args_t args ; memset ( ( char * ) & args , 0 , sizeof ( args ) ) ; args . dp = context -> dp ; args . whichfork = XFS_ATTR_FORK ; args . valuelen = valuelen ; args . value = kmem_alloc ( valuelen , KM_SLEEP | KM_NOFS ) ; args . rmtblkno = be32_to_cpu ( name_rmt -> valueblk ) ; args . rmtblkcnt = xfs_attr3_rmt_blocks ( args . dp -> i_mount , valuelen ) ; retval = xfs_attr_rmtval_get ( & args ) ; if ( retval ) return retval ; retval = context -> put_listent ( context , entry -> flags , name_rmt -> name , ( int ) name_rmt -> namelen , valuelen , args . value ) ; kmem_free ( args . value ) ; } else { retval = context -> put_listent ( context , entry -> flags , name_rmt -> name , ( int ) name_rmt -> namelen , valuelen , NULL ) ; } if ( retval ) return retval ; } if ( context -> seen_enough ) break ; cursor -> offset ++ ; } trace_xfs_attr_list_leaf_end ( context ) ; return retval ; } "," ; args . rmtvaluelen = valuelen ; args . ",torvalds@linux/8275cdd0e7ac550dcce2b3ef6d2fb3b808c1ae59,CVE-2015-0274,https://github.com/torvalds/linux/commit/8275cdd0e7ac550dcce2b3ef6d2fb3b808c1ae59,2015-03-16T10:59Z 218,CWE-20,"CWE-20 asmlinkage long compat_sys_recvmmsg ( int fd , struct compat_mmsghdr __user * mmsg , unsigned int vlen , unsigned int flags , struct compat_timespec __user * timeout ) { int datagrams ; struct timespec ktspec ; if ( flags & MSG_CMSG_COMPAT ) return - EINVAL ; if ( COMPAT_USE_64BIT_TIME ) return __sys_recvmmsg ( fd , ( struct mmsghdr __user * ) mmsg , vlen , flags | MSG_CMSG_COMPAT , ( struct timespec * ) timeout ) ; if ( timeout == NULL ) return __sys_recvmmsg ( fd , ( struct mmsghdr __user * ) mmsg , vlen , flags | MSG_CMSG_COMPAT , NULL ) ; if ( get_compat_timespec ( & ktspec , timeout ) ) return - EFAULT ; datagrams = __sys_recvmmsg ( fd , ( struct mmsghdr __user * ) mmsg , vlen , flags | MSG_CMSG_COMPAT , & ktspec ) ; if ( datagrams > 0 && put_compat_timespec ( & ktspec , timeout ) ) datagrams = - EFAULT ; return datagrams ; } "," ; if ( timeout == NULL ; if ( compat_get_timespec ( & ktspec > 0 && compat_put_timespec ( & ktspec ",torvalds@linux/2def2ef2ae5f3990aabdbe8a755911902707d268,CVE-2014-0038,https://github.com/torvalds/linux/commit/2def2ef2ae5f3990aabdbe8a755911902707d268,2014-02-06T22:55Z 219,CWE-119,"CWE-119 static Image * ReadSUNImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define RMT_EQUAL_RGB 1 # define RMT_NONE 0 # define RMT_RAW 2 # define RT_STANDARD 1 # define RT_ENCODED 2 # define RT_FORMAT_RGB 3 typedef struct _SUNInfo { unsigned int magic , width , height , depth , length , type , maptype , maplength ; } SUNInfo ; Image * image ; int bit ; MagickBooleanType status ; MagickSizeType number_pixels ; register Quantum * q ; register ssize_t i , x ; register unsigned char * p ; size_t bytes_per_line , extent , length ; ssize_t count , y ; SUNInfo sun_info ; unsigned char * sun_data , * sun_pixels ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } ( void ) ResetMagickMemory ( & sun_info , 0 , sizeof ( sun_info ) ) ; sun_info . magic = ReadBlobMSBLong ( image ) ; do { if ( sun_info . magic != 0x59a66a95 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; sun_info . width = ReadBlobMSBLong ( image ) ; sun_info . height = ReadBlobMSBLong ( image ) ; sun_info . depth = ReadBlobMSBLong ( image ) ; sun_info . length = ReadBlobMSBLong ( image ) ; sun_info . type = ReadBlobMSBLong ( image ) ; sun_info . maptype = ReadBlobMSBLong ( image ) ; sun_info . maplength = ReadBlobMSBLong ( image ) ; extent = sun_info . height * sun_info . width ; if ( ( sun_info . height != 0 ) && ( sun_info . width != extent / sun_info . height ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ( sun_info . type != RT_STANDARD ) && ( sun_info . type != RT_ENCODED ) && ( sun_info . type != RT_FORMAT_RGB ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ( sun_info . maptype == RMT_NONE ) && ( sun_info . maplength != 0 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ( sun_info . depth == 0 ) || ( sun_info . depth > 32 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ( sun_info . maptype != RMT_NONE ) && ( sun_info . maptype != RMT_EQUAL_RGB ) && ( sun_info . maptype != RMT_RAW ) ) ThrowReaderException ( CoderError , ""ColormapTypeNotSupported"" ) ; image -> columns = sun_info . width ; image -> rows = sun_info . height ; image -> depth = sun_info . depth <= 8 ? sun_info . depth : MAGICKCORE_QUANTUM_DEPTH ; if ( sun_info . depth < 24 ) { size_t one ; image -> storage_class = PseudoClass ; image -> colors = sun_info . maplength ; one = 1 ; if ( sun_info . maptype == RMT_NONE ) image -> colors = one << sun_info . depth ; if ( sun_info . maptype == RMT_EQUAL_RGB ) image -> colors = sun_info . maplength / 3 ; } switch ( sun_info . maptype ) { case RMT_NONE : { if ( sun_info . depth < 24 ) { if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; } break ; } case RMT_EQUAL_RGB : { unsigned char * sun_colormap ; if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; sun_colormap = ( unsigned char * ) AcquireQuantumMemory ( image -> colors , sizeof ( * sun_colormap ) ) ; if ( sun_colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; count = ReadBlob ( image , image -> colors , sun_colormap ) ; if ( count != ( ssize_t ) image -> colors ) ThrowReaderException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) image -> colormap [ i ] . red = ( MagickRealType ) ScaleCharToQuantum ( sun_colormap [ i ] ) ; count = ReadBlob ( image , image -> colors , sun_colormap ) ; if ( count != ( ssize_t ) image -> colors ) ThrowReaderException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) image -> colormap [ i ] . green = ( MagickRealType ) ScaleCharToQuantum ( sun_colormap [ i ] ) ; count = ReadBlob ( image , image -> colors , sun_colormap ) ; if ( count != ( ssize_t ) image -> colors ) ThrowReaderException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) image -> colormap [ i ] . blue = ( MagickRealType ) ScaleCharToQuantum ( sun_colormap [ i ] ) ; sun_colormap = ( unsigned char * ) RelinquishMagickMemory ( sun_colormap ) ; break ; } case RMT_RAW : { unsigned char * sun_colormap ; sun_colormap = ( unsigned char * ) AcquireQuantumMemory ( sun_info . maplength , sizeof ( * sun_colormap ) ) ; if ( sun_colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; count = ReadBlob ( image , sun_info . maplength , sun_colormap ) ; if ( count != ( ssize_t ) sun_info . maplength ) ThrowReaderException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; sun_colormap = ( unsigned char * ) RelinquishMagickMemory ( sun_colormap ) ; break ; } default : ThrowReaderException ( CoderError , ""ColormapTypeNotSupported"" ) ; } image -> alpha_trait = sun_info . depth == 32 ? BlendPixelTrait : UndefinedPixelTrait ; image -> columns = sun_info . width ; image -> rows = sun_info . height ; if ( image_info -> ping != MagickFalse ) { ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; if ( ( sun_info . length * sizeof ( * sun_data ) ) / sizeof ( * sun_data ) != sun_info . length || ! sun_info . length ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; number_pixels = ( MagickSizeType ) image -> columns * image -> rows ; if ( ( sun_info . type != RT_ENCODED ) && ( sun_info . depth >= 8 ) && ( ( number_pixels * ( ( sun_info . depth + 7 ) / 8 ) ) > sun_info . length ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; bytes_per_line = sun_info . width * sun_info . depth ; sun_data = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) MagickMax ( sun_info . length , bytes_per_line * sun_info . width ) , sizeof ( * sun_data ) ) ; if ( sun_data == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; count = ( ssize_t ) ReadBlob ( image , sun_info . length , sun_data ) ; if ( count != ( ssize_t ) sun_info . length ) ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; sun_pixels = sun_data ; bytes_per_line = 0 ; if ( sun_info . type == RT_ENCODED ) { size_t height ; height = sun_info . height ; if ( ( height == 0 ) || ( sun_info . width == 0 ) || ( sun_info . depth == 0 ) || ( ( bytes_per_line / sun_info . depth ) != sun_info . width ) ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; bytes_per_line += 15 ; bytes_per_line <<= 1 ; if ( ( bytes_per_line >> 1 ) != ( sun_info . width * sun_info . depth + 15 ) ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; bytes_per_line >>= 4 ; sun_pixels = ( unsigned char * ) AcquireQuantumMemory ( height , bytes_per_line * sizeof ( * sun_pixels ) ) ; if ( sun_pixels == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; ( void ) DecodeImage ( sun_data , sun_info . length , sun_pixels , bytes_per_line * height ) ; sun_data = ( unsigned char * ) RelinquishMagickMemory ( sun_data ) ; } p = sun_pixels ; if ( sun_info . depth == 1 ) for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ( ssize_t ) image -> columns - 7 ) ; x += 8 ) { for ( bit = 7 ; bit >= 0 ; bit -- ) { SetPixelIndex ( image , ( Quantum ) ( ( * p ) & ( 0x01 << bit ) ? 0x00 : 0x01 ) , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } if ( ( image -> columns % 8 ) != 0 ) { for ( bit = 7 ; bit >= ( int ) ( 8 - ( image -> columns % 8 ) ) ; bit -- ) { SetPixelIndex ( image , ( Quantum ) ( ( * p ) & ( 0x01 << bit ) ? 0x00 : 0x01 ) , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } if ( ( ( ( image -> columns / 8 ) + ( image -> columns % 8 ? 1 : 0 ) ) % 2 ) != 0 ) p ++ ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } else if ( image -> storage_class == PseudoClass ) { if ( bytes_per_line == 0 ) bytes_per_line = image -> columns ; length = image -> rows * ( image -> columns + image -> columns % 2 ) ; if ( ( ( sun_info . type == RT_ENCODED ) && ( length > ( bytes_per_line * image -> rows ) ) ) || ( ( sun_info . type != RT_ENCODED ) && ( length > sun_info . length ) ) ) ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelIndex ( image , * p ++ , q ) ; q += GetPixelChannels ( image ) ; } if ( ( image -> columns % 2 ) != 0 ) p ++ ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } else { size_t bytes_per_pixel ; bytes_per_pixel = 3 ; if ( image -> alpha_trait != UndefinedPixelTrait ) bytes_per_pixel ++ ; if ( bytes_per_line == 0 ) bytes_per_line = bytes_per_pixel * image -> columns ; length = image -> rows * ( bytes_per_line + image -> columns % 2 ) ; if ( ( ( sun_info . type == RT_ENCODED ) && ( length > ( bytes_per_line * image -> rows ) ) ) || ( ( sun_info . type != RT_ENCODED ) && ( length > sun_info . length ) ) ) ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { if ( image -> alpha_trait != UndefinedPixelTrait ) SetPixelAlpha ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; if ( sun_info . type == RT_STANDARD ) { SetPixelBlue ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelGreen ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelRed ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; } else { SetPixelRed ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelGreen ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelBlue ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; } if ( image -> colors != 0 ) { SetPixelRed ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) GetPixelRed ( image , q ) ] . red ) , q ) ; SetPixelGreen ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) GetPixelGreen ( image , q ) ] . green ) , q ) ; SetPixelBlue ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) GetPixelBlue ( image , q ) ] . blue ) , q ) ; } q += GetPixelChannels ( image ) ; } if ( ( ( bytes_per_pixel * image -> columns ) % 2 ) != 0 ) p ++ ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } if ( image -> storage_class == PseudoClass ) ( void ) SyncImage ( image , exception ) ; sun_pixels = ( unsigned char * ) RelinquishMagickMemory ( sun_pixels ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; sun_info . magic = ReadBlobMSBLong ( image ) ; if ( sun_info . magic == 0x59a66a95 ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( sun_info . magic == 0x59a66a95 ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," ; image -> colors = sun_info / 3 ; if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; maptype ) { case RMT_EQUAL_RGB : char * sun_colormap ; sun_colormap = ",ImageMagick@ImageMagick/bd96074b254c6607a0f7731e59f923ad19d5a46d,CVE-2015-8957,https://github.com/ImageMagick/ImageMagick/commit/bd96074b254c6607a0f7731e59f923ad19d5a46d,2017-04-20T18:59Z 220,CWE-416,"CWE-416 static netdev_tx_t hns_nic_net_xmit ( struct sk_buff * skb , struct net_device * ndev ) { struct hns_nic_priv * priv = netdev_priv ( ndev ) ; int ret ; assert ( skb -> queue_mapping < ndev -> ae_handle -> q_num ) ; ret = hns_nic_net_xmit_hw ( ndev , skb , & tx_ring_data ( priv , skb -> queue_mapping ) ) ; if ( ret == NETDEV_TX_OK ) { netif_trans_update ( ndev ) ; ndev -> stats . tx_bytes += skb -> len ; ndev -> stats . tx_packets ++ ; } return ( netdev_tx_t ) ret ; } "," ndev ) ; assert ( skb q_num ) ; return hns_nic_net_xmit_hw ( ndev ) ) ; } ",torvalds@linux/27463ad99f738ed93c7c8b3e2e5bc8c4853a2ff2,CVE-2017-18218,https://github.com/torvalds/linux/commit/27463ad99f738ed93c7c8b3e2e5bc8c4853a2ff2,2018-03-05T20:29Z 221,CWE-20,"CWE-20 static int hash_recvmsg ( struct kiocb * unused , struct socket * sock , struct msghdr * msg , size_t len , int flags ) { struct sock * sk = sock -> sk ; struct alg_sock * ask = alg_sk ( sk ) ; struct hash_ctx * ctx = ask -> private ; unsigned ds = crypto_ahash_digestsize ( crypto_ahash_reqtfm ( & ctx -> req ) ) ; int err ; if ( len > ds ) len = ds ; else if ( len < ds ) msg -> msg_flags |= MSG_TRUNC ; msg -> msg_namelen = 0 ; lock_sock ( sk ) ; if ( ctx -> more ) { ctx -> more = 0 ; ahash_request_set_crypt ( & ctx -> req , NULL , ctx -> result , 0 ) ; err = af_alg_wait_for_completion ( crypto_ahash_final ( & ctx -> req ) , & ctx -> completion ) ; if ( err ) goto unlock ; } err = memcpy_toiovec ( msg -> msg_iov , ctx -> result , len ) ; unlock : release_sock ( sk ) ; return err ? : len ; } "," |= MSG_TRUNC ; lock_sock ( sk ",torvalds@linux/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,CVE-2013-7271,https://github.com/torvalds/linux/commit/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,2014-01-06T16:55Z 222,CWE-400,"CWE-400 int main ( int argc , char * * argv ) { int c ; bool lock_memory = false ; bool do_daemonize = false ; bool preallocate = false ; int maxcore = 0 ; char * username = NULL ; char * pid_file = NULL ; struct passwd * pw ; struct rlimit rlim ; char * buf ; char unit = '\\0' ; int size_max = 0 ; int retval = EXIT_SUCCESS ; static int * l_socket = NULL ; static int * u_socket = NULL ; bool protocol_specified = false ; bool tcp_specified = false ; bool udp_specified = false ; bool start_lru_maintainer = true ; bool start_lru_crawler = true ; bool start_assoc_maint = true ; enum hashfunc_type hash_type = MURMUR3_HASH ; uint32_t tocrawl ; uint32_t slab_sizes [ MAX_NUMBER_OF_SLAB_CLASSES ] ; bool use_slab_sizes = false ; char * slab_sizes_unparsed = NULL ; bool slab_chunk_size_changed = false ; # ifdef EXTSTORE void * storage = NULL ; char * storage_file = NULL ; struct extstore_conf ext_cf ; # endif char * subopts , * subopts_orig ; char * subopts_value ; enum { MAXCONNS_FAST = 0 , HASHPOWER_INIT , NO_HASHEXPAND , SLAB_REASSIGN , SLAB_AUTOMOVE , SLAB_AUTOMOVE_RATIO , SLAB_AUTOMOVE_WINDOW , TAIL_REPAIR_TIME , HASH_ALGORITHM , LRU_CRAWLER , LRU_CRAWLER_SLEEP , LRU_CRAWLER_TOCRAWL , LRU_MAINTAINER , HOT_LRU_PCT , WARM_LRU_PCT , HOT_MAX_FACTOR , WARM_MAX_FACTOR , TEMPORARY_TTL , IDLE_TIMEOUT , WATCHER_LOGBUF_SIZE , WORKER_LOGBUF_SIZE , SLAB_SIZES , SLAB_CHUNK_MAX , TRACK_SIZES , NO_INLINE_ASCII_RESP , MODERN , NO_MODERN , NO_CHUNKED_ITEMS , NO_SLAB_REASSIGN , NO_SLAB_AUTOMOVE , NO_MAXCONNS_FAST , INLINE_ASCII_RESP , NO_LRU_CRAWLER , NO_LRU_MAINTAINER , NO_DROP_PRIVILEGES , # ifdef MEMCACHED_DEBUG RELAXED_PRIVILEGES , # endif # ifdef EXTSTORE EXT_PAGE_SIZE , EXT_PAGE_COUNT , EXT_WBUF_SIZE , EXT_THREADS , EXT_IO_DEPTH , EXT_PATH , EXT_ITEM_SIZE , EXT_ITEM_AGE , EXT_LOW_TTL , EXT_RECACHE_RATE , EXT_COMPACT_UNDER , EXT_DROP_UNDER , EXT_MAX_FRAG , EXT_DROP_UNREAD , SLAB_AUTOMOVE_FREERATIO , # endif } ; char * const subopts_tokens [ ] = { [ MAXCONNS_FAST ] = ""maxconns_fast"" , [ HASHPOWER_INIT ] = ""hashpower"" , [ NO_HASHEXPAND ] = ""no_hashexpand"" , [ SLAB_REASSIGN ] = ""slab_reassign"" , [ SLAB_AUTOMOVE ] = ""slab_automove"" , [ SLAB_AUTOMOVE_RATIO ] = ""slab_automove_ratio"" , [ SLAB_AUTOMOVE_WINDOW ] = ""slab_automove_window"" , [ TAIL_REPAIR_TIME ] = ""tail_repair_time"" , [ HASH_ALGORITHM ] = ""hash_algorithm"" , [ LRU_CRAWLER ] = ""lru_crawler"" , [ LRU_CRAWLER_SLEEP ] = ""lru_crawler_sleep"" , [ LRU_CRAWLER_TOCRAWL ] = ""lru_crawler_tocrawl"" , [ LRU_MAINTAINER ] = ""lru_maintainer"" , [ HOT_LRU_PCT ] = ""hot_lru_pct"" , [ WARM_LRU_PCT ] = ""warm_lru_pct"" , [ HOT_MAX_FACTOR ] = ""hot_max_factor"" , [ WARM_MAX_FACTOR ] = ""warm_max_factor"" , [ TEMPORARY_TTL ] = ""temporary_ttl"" , [ IDLE_TIMEOUT ] = ""idle_timeout"" , [ WATCHER_LOGBUF_SIZE ] = ""watcher_logbuf_size"" , [ WORKER_LOGBUF_SIZE ] = ""worker_logbuf_size"" , [ SLAB_SIZES ] = ""slab_sizes"" , [ SLAB_CHUNK_MAX ] = ""slab_chunk_max"" , [ TRACK_SIZES ] = ""track_sizes"" , [ NO_INLINE_ASCII_RESP ] = ""no_inline_ascii_resp"" , [ MODERN ] = ""modern"" , [ NO_MODERN ] = ""no_modern"" , [ NO_CHUNKED_ITEMS ] = ""no_chunked_items"" , [ NO_SLAB_REASSIGN ] = ""no_slab_reassign"" , [ NO_SLAB_AUTOMOVE ] = ""no_slab_automove"" , [ NO_MAXCONNS_FAST ] = ""no_maxconns_fast"" , [ INLINE_ASCII_RESP ] = ""inline_ascii_resp"" , [ NO_LRU_CRAWLER ] = ""no_lru_crawler"" , [ NO_LRU_MAINTAINER ] = ""no_lru_maintainer"" , [ NO_DROP_PRIVILEGES ] = ""no_drop_privileges"" , # ifdef MEMCACHED_DEBUG [ RELAXED_PRIVILEGES ] = ""relaxed_privileges"" , # endif # ifdef EXTSTORE [ EXT_PAGE_SIZE ] = ""ext_page_size"" , [ EXT_PAGE_COUNT ] = ""ext_page_count"" , [ EXT_WBUF_SIZE ] = ""ext_wbuf_size"" , [ EXT_THREADS ] = ""ext_threads"" , [ EXT_IO_DEPTH ] = ""ext_io_depth"" , [ EXT_PATH ] = ""ext_path"" , [ EXT_ITEM_SIZE ] = ""ext_item_size"" , [ EXT_ITEM_AGE ] = ""ext_item_age"" , [ EXT_LOW_TTL ] = ""ext_low_ttl"" , [ EXT_RECACHE_RATE ] = ""ext_recache_rate"" , [ EXT_COMPACT_UNDER ] = ""ext_compact_under"" , [ EXT_DROP_UNDER ] = ""ext_drop_under"" , [ EXT_MAX_FRAG ] = ""ext_max_frag"" , [ EXT_DROP_UNREAD ] = ""ext_drop_unread"" , [ SLAB_AUTOMOVE_FREERATIO ] = ""slab_automove_freeratio"" , # endif NULL } ; if ( ! sanitycheck ( ) ) { return EX_OSERR ; } signal ( SIGINT , sig_handler ) ; signal ( SIGTERM , sig_handler ) ; settings_init ( ) ; # ifdef EXTSTORE settings . ext_item_size = 512 ; settings . ext_item_age = UINT_MAX ; settings . ext_low_ttl = 0 ; settings . ext_recache_rate = 2000 ; settings . ext_max_frag = 0.8 ; settings . ext_drop_unread = false ; settings . ext_wbuf_size = 1024 * 1024 * 4 ; settings . ext_compact_under = 0 ; settings . ext_drop_under = 0 ; settings . slab_automove_freeratio = 0.01 ; ext_cf . page_size = 1024 * 1024 * 64 ; ext_cf . page_count = 64 ; ext_cf . wbuf_size = settings . ext_wbuf_size ; ext_cf . io_threadcount = 1 ; ext_cf . io_depth = 1 ; ext_cf . page_buckets = 4 ; ext_cf . wbuf_count = ext_cf . page_buckets ; # endif init_lru_maintainer ( ) ; setbuf ( stderr , NULL ) ; char * shortopts = ""a:"" ""A"" ""p:"" ""s:"" ""U:"" ""m:"" ""M"" ""c:"" ""k"" ""hiV"" ""r"" ""v"" ""d"" ""l:"" ""u:"" ""P:"" ""f:"" ""n:"" ""t:"" ""D:"" ""L"" ""R:"" ""C"" ""b:"" ""B:"" ""I:"" ""S"" ""F"" ""X"" ""o:"" ; # ifdef HAVE_GETOPT_LONG const struct option longopts [ ] = { { ""unix-mask"" , required_argument , 0 , 'a' } , { ""enable-shutdown"" , no_argument , 0 , 'A' } , { ""port"" , required_argument , 0 , 'p' } , { ""unix-socket"" , required_argument , 0 , 's' } , { ""udp-port"" , required_argument , 0 , 'U' } , { ""memory-limit"" , required_argument , 0 , 'm' } , { ""disable-evictions"" , no_argument , 0 , 'M' } , { ""conn-limit"" , required_argument , 0 , 'c' } , { ""lock-memory"" , no_argument , 0 , 'k' } , { ""help"" , no_argument , 0 , 'h' } , { ""license"" , no_argument , 0 , 'i' } , { ""version"" , no_argument , 0 , 'V' } , { ""enable-coredumps"" , no_argument , 0 , 'r' } , { ""verbose"" , optional_argument , 0 , 'v' } , { ""daemon"" , no_argument , 0 , 'd' } , { ""listen"" , required_argument , 0 , 'l' } , { ""user"" , required_argument , 0 , 'u' } , { ""pidfile"" , required_argument , 0 , 'P' } , { ""slab-growth-factor"" , required_argument , 0 , 'f' } , { ""slab-min-size"" , required_argument , 0 , 'n' } , { ""threads"" , required_argument , 0 , 't' } , { ""enable-largepages"" , no_argument , 0 , 'L' } , { ""max-reqs-per-event"" , required_argument , 0 , 'R' } , { ""disable-cas"" , no_argument , 0 , 'C' } , { ""listen-backlog"" , required_argument , 0 , 'b' } , { ""protocol"" , required_argument , 0 , 'B' } , { ""max-item-size"" , required_argument , 0 , 'I' } , { ""enable-sasl"" , no_argument , 0 , 'S' } , { ""disable-flush-all"" , no_argument , 0 , 'F' } , { ""disable-dumping"" , no_argument , 0 , 'X' } , { ""extended"" , required_argument , 0 , 'o' } , { 0 , 0 , 0 , 0 } } ; int optindex ; while ( - 1 != ( c = getopt_long ( argc , argv , shortopts , longopts , & optindex ) ) ) { # else while ( - 1 != ( c = getopt ( argc , argv , shortopts ) ) ) { # endif switch ( c ) { case 'A' : settings . shutdown_command = true ; break ; case 'a' : settings . access = strtol ( optarg , NULL , 8 ) ; break ; case 'U' : settings . udpport = atoi ( optarg ) ; udp_specified = true ; break ; case 'p' : settings . port = atoi ( optarg ) ; tcp_specified = true ; break ; case 's' : settings . socketpath = optarg ; break ; case 'm' : settings . maxbytes = ( ( size_t ) atoi ( optarg ) ) * 1024 * 1024 ; break ; case 'M' : settings . evict_to_free = 0 ; break ; case 'c' : settings . maxconns = atoi ( optarg ) ; if ( settings . maxconns <= 0 ) { fprintf ( stderr , ""Maximumconnectionsmustbegreaterthan0\\n"" ) ; return 1 ; } break ; case 'h' : usage ( ) ; exit ( EXIT_SUCCESS ) ; case 'i' : usage_license ( ) ; exit ( EXIT_SUCCESS ) ; case 'V' : printf ( PACKAGE """" VERSION ""\\n"" ) ; exit ( EXIT_SUCCESS ) ; case 'k' : lock_memory = true ; break ; case 'v' : settings . verbose ++ ; break ; case 'l' : if ( settings . inter != NULL ) { if ( strstr ( settings . inter , optarg ) != NULL ) { break ; } size_t len = strlen ( settings . inter ) + strlen ( optarg ) + 2 ; char * p = malloc ( len ) ; if ( p == NULL ) { fprintf ( stderr , ""Failedtoallocatememory\\n"" ) ; return 1 ; } snprintf ( p , len , ""%s,%s"" , settings . inter , optarg ) ; free ( settings . inter ) ; settings . inter = p ; } else { settings . inter = strdup ( optarg ) ; } break ; case 'd' : do_daemonize = true ; break ; case 'r' : maxcore = 1 ; break ; case 'R' : settings . reqs_per_event = atoi ( optarg ) ; if ( settings . reqs_per_event == 0 ) { fprintf ( stderr , ""Numberofrequestspereventmustbegreaterthan0\\n"" ) ; return 1 ; } break ; case 'u' : username = optarg ; break ; case 'P' : pid_file = optarg ; break ; case 'f' : settings . factor = atof ( optarg ) ; if ( settings . factor <= 1.0 ) { fprintf ( stderr , ""Factormustbegreaterthan1\\n"" ) ; return 1 ; } break ; case 'n' : settings . chunk_size = atoi ( optarg ) ; if ( settings . chunk_size == 0 ) { fprintf ( stderr , ""Chunksizemustbegreaterthan0\\n"" ) ; return 1 ; } break ; case 't' : settings . num_threads = atoi ( optarg ) ; if ( settings . num_threads <= 0 ) { fprintf ( stderr , ""Numberofthreadsmustbegreaterthan0\\n"" ) ; return 1 ; } if ( settings . num_threads > 64 ) { fprintf ( stderr , ""WARNING:Settingahighnumberofworker"" ""threadsisnotrecommended.\\n"" ""Setthisvaluetothenumberofcoresin"" ""yourmachineorless.\\n"" ) ; } break ; case 'D' : if ( ! optarg || ! optarg [ 0 ] ) { fprintf ( stderr , ""Nodelimiterspecified\\n"" ) ; return 1 ; } settings . prefix_delimiter = optarg [ 0 ] ; settings . detail_enabled = 1 ; break ; case 'L' : if ( enable_large_pages ( ) == 0 ) { preallocate = true ; } else { fprintf ( stderr , ""Cannotenablelargepagesonthissystem\\n"" ""(ThereisnoLinuxsupportasofthisversion)\\n"" ) ; return 1 ; } break ; case 'C' : settings . use_cas = false ; break ; case 'b' : settings . backlog = atoi ( optarg ) ; break ; case 'B' : protocol_specified = true ; if ( strcmp ( optarg , ""auto"" ) == 0 ) { settings . binding_protocol = negotiating_prot ; } else if ( strcmp ( optarg , ""binary"" ) == 0 ) { settings . binding_protocol = binary_prot ; } else if ( strcmp ( optarg , ""ascii"" ) == 0 ) { settings . binding_protocol = ascii_prot ; } else { fprintf ( stderr , ""Invalidvalueforbindingprotocol:%s\\n"" ""--shouldbeoneofauto,binary,orascii\\n"" , optarg ) ; exit ( EX_USAGE ) ; } break ; case 'I' : buf = strdup ( optarg ) ; unit = buf [ strlen ( buf ) - 1 ] ; if ( unit == 'k' || unit == 'm' || unit == 'K' || unit == 'M' ) { buf [ strlen ( buf ) - 1 ] = '\\0' ; size_max = atoi ( buf ) ; if ( unit == 'k' || unit == 'K' ) size_max *= 1024 ; if ( unit == 'm' || unit == 'M' ) size_max *= 1024 * 1024 ; settings . item_size_max = size_max ; } else { settings . item_size_max = atoi ( buf ) ; } free ( buf ) ; break ; case 'S' : # ifndef ENABLE_SASL fprintf ( stderr , ""ThisserverisnotbuiltwithSASLsupport.\\n"" ) ; exit ( EX_USAGE ) ; # endif settings . sasl = true ; break ; case 'F' : settings . flush_enabled = false ; break ; case 'X' : settings . dump_enabled = false ; break ; case 'o' : subopts_orig = subopts = strdup ( optarg ) ; while ( * subopts != '\\0' ) { switch ( getsubopt ( & subopts , subopts_tokens , & subopts_value ) ) { case MAXCONNS_FAST : settings . maxconns_fast = true ; break ; case HASHPOWER_INIT : if ( subopts_value == NULL ) { fprintf ( stderr , ""Missingnumericargumentforhashpower\\n"" ) ; return 1 ; } settings . hashpower_init = atoi ( subopts_value ) ; if ( settings . hashpower_init < 12 ) { fprintf ( stderr , ""Initialhashtablemultiplierof%distoolow\\n"" , settings . hashpower_init ) ; return 1 ; } else if ( settings . hashpower_init > 32 ) { fprintf ( stderr , ""Initialhashtablemultiplierof%distoohigh\\n"" ""Chooseavaluebasedon\\""STAThash_power_level\\""fromarunninginstance\\n"" , settings . hashpower_init ) ; return 1 ; } break ; case NO_HASHEXPAND : start_assoc_maint = false ; break ; case SLAB_REASSIGN : settings . slab_reassign = true ; break ; case SLAB_AUTOMOVE : if ( subopts_value == NULL ) { settings . slab_automove = 1 ; break ; } settings . slab_automove = atoi ( subopts_value ) ; if ( settings . slab_automove < 0 || settings . slab_automove > 2 ) { fprintf ( stderr , ""slab_automovemustbebetween0and2\\n"" ) ; return 1 ; } break ; case SLAB_AUTOMOVE_RATIO : if ( subopts_value == NULL ) { fprintf ( stderr , ""Missingslab_automove_ratioargument\\n"" ) ; return 1 ; } settings . slab_automove_ratio = atof ( subopts_value ) ; if ( settings . slab_automove_ratio <= 0 || settings . slab_automove_ratio > 1 ) { fprintf ( stderr , ""slab_automove_ratiomustbe>0and<1\\n"" ) ; return 1 ; } break ; case SLAB_AUTOMOVE_WINDOW : if ( subopts_value == NULL ) { fprintf ( stderr , ""Missingslab_automove_windowargument\\n"" ) ; return 1 ; } settings . slab_automove_window = atoi ( subopts_value ) ; if ( settings . slab_automove_window < 3 ) { fprintf ( stderr , ""slab_automove_windowmustbe>2\\n"" ) ; return 1 ; } break ; case TAIL_REPAIR_TIME : if ( subopts_value == NULL ) { fprintf ( stderr , ""Missingnumericargumentfortail_repair_time\\n"" ) ; return 1 ; } settings . tail_repair_time = atoi ( subopts_value ) ; if ( settings . tail_repair_time < 10 ) { fprintf ( stderr , ""Cannotsettail_repair_timetolessthan10seconds\\n"" ) ; return 1 ; } break ; case HASH_ALGORITHM : if ( subopts_value == NULL ) { fprintf ( stderr , ""Missinghash_algorithmargument\\n"" ) ; return 1 ; } ; if ( strcmp ( subopts_value , ""jenkins"" ) == 0 ) { hash_type = JENKINS_HASH ; } else if ( strcmp ( subopts_value , ""murmur3"" ) == 0 ) { hash_type = MURMUR3_HASH ; } else { fprintf ( stderr , ""Unknownhash_algorithmoption(jenkins,murmur3)\\n"" ) ; return 1 ; } break ; case LRU_CRAWLER : start_lru_crawler = true ; break ; case LRU_CRAWLER_SLEEP : if ( subopts_value == NULL ) { fprintf ( stderr , ""Missinglru_crawler_sleepvalue\\n"" ) ; return 1 ; } settings . lru_crawler_sleep = atoi ( subopts_value ) ; if ( settings . lru_crawler_sleep > 1000000 || settings . lru_crawler_sleep < 0 ) { fprintf ( stderr , ""LRUcrawlersleepmustbebetween0and1second\\n"" ) ; return 1 ; } break ; case LRU_CRAWLER_TOCRAWL : if ( subopts_value == NULL ) { fprintf ( stderr , ""Missinglru_crawler_tocrawlvalue\\n"" ) ; return 1 ; } if ( ! safe_strtoul ( subopts_value , & tocrawl ) ) { fprintf ( stderr , ""lru_crawler_tocrawltakesanumeric32bitvalue\\n"" ) ; return 1 ; } settings . lru_crawler_tocrawl = tocrawl ; break ; case LRU_MAINTAINER : start_lru_maintainer = true ; settings . lru_segmented = true ; break ; case HOT_LRU_PCT : if ( subopts_value == NULL ) { fprintf ( stderr , ""Missinghot_lru_pctargument\\n"" ) ; return 1 ; } settings . hot_lru_pct = atoi ( subopts_value ) ; if ( settings . hot_lru_pct < 1 || settings . hot_lru_pct >= 80 ) { fprintf ( stderr , ""hot_lru_pctmustbe>1and<80\\n"" ) ; return 1 ; } break ; case WARM_LRU_PCT : if ( subopts_value == NULL ) { fprintf ( stderr , ""Missingwarm_lru_pctargument\\n"" ) ; return 1 ; } settings . warm_lru_pct = atoi ( subopts_value ) ; if ( settings . warm_lru_pct < 1 || settings . warm_lru_pct >= 80 ) { fprintf ( stderr , ""warm_lru_pctmustbe>1and<80\\n"" ) ; return 1 ; } break ; case HOT_MAX_FACTOR : if ( subopts_value == NULL ) { fprintf ( stderr , ""Missinghot_max_factorargument\\n"" ) ; return 1 ; } settings . hot_max_factor = atof ( subopts_value ) ; if ( settings . hot_max_factor <= 0 ) { fprintf ( stderr , ""hot_max_factormustbe>0\\n"" ) ; return 1 ; } break ; case WARM_MAX_FACTOR : if ( subopts_value == NULL ) { fprintf ( stderr , ""Missingwarm_max_factorargument\\n"" ) ; return 1 ; } settings . warm_max_factor = atof ( subopts_value ) ; if ( settings . warm_max_factor <= 0 ) { fprintf ( stderr , ""warm_max_factormustbe>0\\n"" ) ; return 1 ; } break ; case TEMPORARY_TTL : if ( subopts_value == NULL ) { fprintf ( stderr , ""Missingtemporary_ttlargument\\n"" ) ; return 1 ; } settings . temp_lru = true ; settings . temporary_ttl = atoi ( subopts_value ) ; break ; case IDLE_TIMEOUT : if ( subopts_value == NULL ) { fprintf ( stderr , ""Missingnumericargumentforidle_timeout\\n"" ) ; return 1 ; } settings . idle_timeout = atoi ( subopts_value ) ; break ; case WATCHER_LOGBUF_SIZE : if ( subopts_value == NULL ) { fprintf ( stderr , ""Missingwatcher_logbuf_sizeargument\\n"" ) ; return 1 ; } if ( ! safe_strtoul ( subopts_value , & settings . logger_watcher_buf_size ) ) { fprintf ( stderr , ""couldnotparseargumenttowatcher_logbuf_size\\n"" ) ; return 1 ; } settings . logger_watcher_buf_size *= 1024 ; break ; case WORKER_LOGBUF_SIZE : if ( subopts_value == NULL ) { fprintf ( stderr , ""Missingworker_logbuf_sizeargument\\n"" ) ; return 1 ; } if ( ! safe_strtoul ( subopts_value , & settings . logger_buf_size ) ) { fprintf ( stderr , ""couldnotparseargumenttoworker_logbuf_size\\n"" ) ; return 1 ; } settings . logger_buf_size *= 1024 ; case SLAB_SIZES : slab_sizes_unparsed = subopts_value ; break ; case SLAB_CHUNK_MAX : if ( subopts_value == NULL ) { fprintf ( stderr , ""Missingslab_chunk_maxargument\\n"" ) ; } if ( ! safe_strtol ( subopts_value , & settings . slab_chunk_size_max ) ) { fprintf ( stderr , ""couldnotparseargumenttoslab_chunk_max\\n"" ) ; } slab_chunk_size_changed = true ; break ; case TRACK_SIZES : item_stats_sizes_init ( ) ; break ; case NO_INLINE_ASCII_RESP : settings . inline_ascii_response = false ; break ; case INLINE_ASCII_RESP : settings . inline_ascii_response = true ; break ; case NO_CHUNKED_ITEMS : settings . slab_chunk_size_max = settings . slab_page_size ; break ; case NO_SLAB_REASSIGN : settings . slab_reassign = false ; break ; case NO_SLAB_AUTOMOVE : settings . slab_automove = 0 ; break ; case NO_MAXCONNS_FAST : settings . maxconns_fast = false ; break ; case NO_LRU_CRAWLER : settings . lru_crawler = false ; start_lru_crawler = false ; break ; case NO_LRU_MAINTAINER : start_lru_maintainer = false ; settings . lru_segmented = false ; break ; # ifdef EXTSTORE case EXT_PAGE_SIZE : if ( subopts_value == NULL ) { fprintf ( stderr , ""Missingext_page_sizeargument\\n"" ) ; return 1 ; } if ( ! safe_strtoul ( subopts_value , & ext_cf . page_size ) ) { fprintf ( stderr , ""couldnotparseargumenttoext_page_size\\n"" ) ; return 1 ; } ext_cf . page_size *= 1024 * 1024 ; break ; case EXT_PAGE_COUNT : if ( subopts_value == NULL ) { fprintf ( stderr , ""Missingext_page_countargument\\n"" ) ; return 1 ; } if ( ! safe_strtoul ( subopts_value , & ext_cf . page_count ) ) { fprintf ( stderr , ""couldnotparseargumenttoext_page_count\\n"" ) ; return 1 ; } break ; case EXT_WBUF_SIZE : if ( subopts_value == NULL ) { fprintf ( stderr , ""Missingext_wbuf_sizeargument\\n"" ) ; return 1 ; } if ( ! safe_strtoul ( subopts_value , & ext_cf . wbuf_size ) ) { fprintf ( stderr , ""couldnotparseargumenttoext_wbuf_size\\n"" ) ; return 1 ; } ext_cf . wbuf_size *= 1024 * 1024 ; settings . ext_wbuf_size = ext_cf . wbuf_size ; break ; case EXT_THREADS : if ( subopts_value == NULL ) { fprintf ( stderr , ""Missingext_threadsargument\\n"" ) ; return 1 ; } if ( ! safe_strtoul ( subopts_value , & ext_cf . io_threadcount ) ) { fprintf ( stderr , ""couldnotparseargumenttoext_threads\\n"" ) ; return 1 ; } break ; case EXT_IO_DEPTH : if ( subopts_value == NULL ) { fprintf ( stderr , ""Missingext_io_depthargument\\n"" ) ; return 1 ; } if ( ! safe_strtoul ( subopts_value , & ext_cf . io_depth ) ) { fprintf ( stderr , ""couldnotparseargumenttoext_io_depth\\n"" ) ; return 1 ; } break ; case EXT_ITEM_SIZE : if ( subopts_value == NULL ) { fprintf ( stderr , ""Missingext_item_sizeargument\\n"" ) ; return 1 ; } if ( ! safe_strtoul ( subopts_value , & settings . ext_item_size ) ) { fprintf ( stderr , ""couldnotparseargumenttoext_item_size\\n"" ) ; return 1 ; } break ; case EXT_ITEM_AGE : if ( subopts_value == NULL ) { fprintf ( stderr , ""Missingext_item_ageargument\\n"" ) ; return 1 ; } if ( ! safe_strtoul ( subopts_value , & settings . ext_item_age ) ) { fprintf ( stderr , ""couldnotparseargumenttoext_item_age\\n"" ) ; return 1 ; } break ; case EXT_LOW_TTL : if ( subopts_value == NULL ) { fprintf ( stderr , ""Missingext_low_ttlargument\\n"" ) ; return 1 ; } if ( ! safe_strtoul ( subopts_value , & settings . ext_low_ttl ) ) { fprintf ( stderr , ""couldnotparseargumenttoext_low_ttl\\n"" ) ; return 1 ; } break ; case EXT_RECACHE_RATE : if ( subopts_value == NULL ) { fprintf ( stderr , ""Missingext_recache_rateargument\\n"" ) ; return 1 ; } if ( ! safe_strtoul ( subopts_value , & settings . ext_recache_rate ) ) { fprintf ( stderr , ""couldnotparseargumenttoext_recache_rate\\n"" ) ; return 1 ; } break ; case EXT_COMPACT_UNDER : if ( subopts_value == NULL ) { fprintf ( stderr , ""Missingext_compact_underargument\\n"" ) ; return 1 ; } if ( ! safe_strtoul ( subopts_value , & settings . ext_compact_under ) ) { fprintf ( stderr , ""couldnotparseargumenttoext_compact_under\\n"" ) ; return 1 ; } break ; case EXT_DROP_UNDER : if ( subopts_value == NULL ) { fprintf ( stderr , ""Missingext_drop_underargument\\n"" ) ; return 1 ; } if ( ! safe_strtoul ( subopts_value , & settings . ext_drop_under ) ) { fprintf ( stderr , ""couldnotparseargumenttoext_drop_under\\n"" ) ; return 1 ; } break ; case EXT_MAX_FRAG : if ( subopts_value == NULL ) { fprintf ( stderr , ""Missingext_max_fragargument\\n"" ) ; return 1 ; } if ( ! safe_strtod ( subopts_value , & settings . ext_max_frag ) ) { fprintf ( stderr , ""couldnotparseargumenttoext_max_frag\\n"" ) ; return 1 ; } break ; case SLAB_AUTOMOVE_FREERATIO : if ( subopts_value == NULL ) { fprintf ( stderr , ""Missingslab_automove_freeratioargument\\n"" ) ; return 1 ; } if ( ! safe_strtod ( subopts_value , & settings . slab_automove_freeratio ) ) { fprintf ( stderr , ""couldnotparseargumenttoslab_automove_freeratio\\n"" ) ; return 1 ; } break ; case EXT_DROP_UNREAD : settings . ext_drop_unread = true ; break ; case EXT_PATH : storage_file = strdup ( subopts_value ) ; break ; # endif case MODERN : break ; case NO_MODERN : if ( ! slab_chunk_size_changed ) { settings . slab_chunk_size_max = settings . slab_page_size ; } settings . slab_reassign = false ; settings . slab_automove = 0 ; settings . maxconns_fast = false ; settings . inline_ascii_response = true ; settings . lru_segmented = false ; hash_type = JENKINS_HASH ; start_lru_crawler = false ; start_lru_maintainer = false ; break ; case NO_DROP_PRIVILEGES : settings . drop_privileges = false ; break ; # ifdef MEMCACHED_DEBUG case RELAXED_PRIVILEGES : settings . relaxed_privileges = true ; break ; # endif default : printf ( ""Illegalsuboption\\""%s\\""\\n"" , subopts_value ) ; return 1 ; } } free ( subopts_orig ) ; break ; default : fprintf ( stderr , ""Illegalargument\\""%c\\""\\n"" , c ) ; return 1 ; } } if ( settings . item_size_max < 1024 ) { fprintf ( stderr , ""Itemmaxsizecannotbelessthan1024bytes.\\n"" ) ; exit ( EX_USAGE ) ; } if ( settings . item_size_max > ( settings . maxbytes / 2 ) ) { fprintf ( stderr , ""Cannotsetitemsizelimithigherthan1/2ofmemorymax.\\n"" ) ; exit ( EX_USAGE ) ; } if ( settings . item_size_max > ( 1024 * 1024 * 1024 ) ) { fprintf ( stderr , ""Cannotsetitemsizelimithigherthanagigabyte.\\n"" ) ; exit ( EX_USAGE ) ; } if ( settings . item_size_max > 1024 * 1024 ) { if ( ! slab_chunk_size_changed ) { settings . slab_chunk_size_max = settings . slab_page_size / 2 ; } } if ( settings . slab_chunk_size_max > settings . item_size_max ) { fprintf ( stderr , ""slab_chunk_max(bytes:%d)cannotbelargerthan-I(item_size_max%d)\\n"" , settings . slab_chunk_size_max , settings . item_size_max ) ; exit ( EX_USAGE ) ; } if ( settings . item_size_max % settings . slab_chunk_size_max != 0 ) { fprintf ( stderr , ""-I(item_size_max:%d)mustbeevenlydivisiblebyslab_chunk_max(bytes:%d)\\n"" , settings . item_size_max , settings . slab_chunk_size_max ) ; exit ( EX_USAGE ) ; } if ( settings . slab_page_size % settings . slab_chunk_size_max != 0 ) { fprintf ( stderr , ""slab_chunk_max(bytes:%d)mustdivideevenlyinto%d(slab_page_size)\\n"" , settings . slab_chunk_size_max , settings . slab_page_size ) ; exit ( EX_USAGE ) ; } # ifdef EXTSTORE if ( storage_file ) { if ( settings . item_size_max > ext_cf . wbuf_size ) { fprintf ( stderr , ""-I(item_size_max:%d)cannotbelargerthanext_wbuf_size:%d\\n"" , settings . item_size_max , ext_cf . wbuf_size ) ; exit ( EX_USAGE ) ; } if ( settings . inline_ascii_response ) { fprintf ( stderr , ""Cannotuseinline_ascii_responsewithextstoreenabled\\n"" ) ; exit ( EX_USAGE ) ; } if ( settings . udpport ) { fprintf ( stderr , ""CannotuseUDPwithextstoreenabled(-U0todisable)\\n"" ) ; exit ( EX_USAGE ) ; } } # endif if ( slab_sizes_unparsed != NULL ) { if ( _parse_slab_sizes ( slab_sizes_unparsed , slab_sizes ) ) { use_slab_sizes = true ; } else { exit ( EX_USAGE ) ; } } if ( settings . hot_lru_pct + settings . warm_lru_pct > 80 ) { fprintf ( stderr , ""hot_lru_pct+warm_lru_pctcannotbemorethan80%%combined\\n"" ) ; exit ( EX_USAGE ) ; } if ( settings . temp_lru && ! start_lru_maintainer ) { fprintf ( stderr , ""temporary_ttlrequireslru_maintainertobeenabled\\n"" ) ; exit ( EX_USAGE ) ; } if ( hash_init ( hash_type ) != 0 ) { fprintf ( stderr , ""Failedtoinitializehash_algorithm!\\n"" ) ; exit ( EX_USAGE ) ; } if ( settings . inter != NULL && strchr ( settings . inter , ',' ) ) { settings . num_threads_per_udp = 1 ; } else { settings . num_threads_per_udp = settings . num_threads ; } if ( settings . sasl ) { if ( ! protocol_specified ) { settings . binding_protocol = binary_prot ; } else { if ( settings . binding_protocol != binary_prot ) { fprintf ( stderr , ""ERROR:YoucannotallowtheASCIIprotocolwhileusingSASL.\\n"" ) ; exit ( EX_USAGE ) ; } } } if ( tcp_specified && settings . port != 0 && ! udp_specified ) { settings . udpport = settings . port ; } else if ( udp_specified && settings . udpport != 0 && ! tcp_specified ) { settings . port = settings . udpport ; } if ( maxcore != 0 ) { struct rlimit rlim_new ; if ( getrlimit ( RLIMIT_CORE , & rlim ) == 0 ) { rlim_new . rlim_cur = rlim_new . rlim_max = RLIM_INFINITY ; if ( setrlimit ( RLIMIT_CORE , & rlim_new ) != 0 ) { rlim_new . rlim_cur = rlim_new . rlim_max = rlim . rlim_max ; ( void ) setrlimit ( RLIMIT_CORE , & rlim_new ) ; } } if ( ( getrlimit ( RLIMIT_CORE , & rlim ) != 0 ) || rlim . rlim_cur == 0 ) { fprintf ( stderr , ""failedtoensurecorefilecreation\\n"" ) ; exit ( EX_OSERR ) ; } } if ( getrlimit ( RLIMIT_NOFILE , & rlim ) != 0 ) { fprintf ( stderr , ""failedtogetrlimitnumberoffiles\\n"" ) ; exit ( EX_OSERR ) ; } else { rlim . rlim_cur = settings . maxconns ; rlim . rlim_max = settings . maxconns ; if ( setrlimit ( RLIMIT_NOFILE , & rlim ) != 0 ) { fprintf ( stderr , ""failedtosetrlimitforopenfiles.Trystartingasrootorrequestingsmallermaxconnsvalue.\\n"" ) ; exit ( EX_OSERR ) ; } } if ( getuid ( ) == 0 || geteuid ( ) == 0 ) { if ( username == 0 || * username == '\\0' ) { fprintf ( stderr , ""can\'trunasrootwithoutthe-uswitch\\n"" ) ; exit ( EX_USAGE ) ; } if ( ( pw = getpwnam ( username ) ) == 0 ) { fprintf ( stderr , ""can\'tfindtheuser%stoswitchto\\n"" , username ) ; exit ( EX_NOUSER ) ; } if ( setgid ( pw -> pw_gid ) < 0 || setuid ( pw -> pw_uid ) < 0 ) { fprintf ( stderr , ""failedtoassumeidentityofuser%s\\n"" , username ) ; exit ( EX_OSERR ) ; } } if ( settings . sasl ) { init_sasl ( ) ; } if ( do_daemonize ) { if ( sigignore ( SIGHUP ) == - 1 ) { perror ( ""FailedtoignoreSIGHUP"" ) ; } if ( daemonize ( maxcore , settings . verbose ) == - 1 ) { fprintf ( stderr , ""failedtodaemon()inordertodaemonize\\n"" ) ; exit ( EXIT_FAILURE ) ; } } if ( lock_memory ) { # ifdef HAVE_MLOCKALL int res = mlockall ( MCL_CURRENT | MCL_FUTURE ) ; if ( res != 0 ) { fprintf ( stderr , ""warning:-kinvalid,mlockall()failed:%s\\n"" , strerror ( errno ) ) ; } # else fprintf ( stderr , ""warning:-kinvalid,mlockall()notsupportedonthisplatform.proceedingwithout.\\n"" ) ; # endif } # if defined ( LIBEVENT_VERSION_NUMBER ) && LIBEVENT_VERSION_NUMBER >= 0x02000101 struct event_config * ev_config ; ev_config = event_config_new ( ) ; event_config_set_flag ( ev_config , EVENT_BASE_FLAG_NOLOCK ) ; main_base = event_base_new_with_config ( ev_config ) ; event_config_free ( ev_config ) ; # else main_base = event_init ( ) ; # endif logger_init ( ) ; stats_init ( ) ; assoc_init ( settings . hashpower_init ) ; conn_init ( ) ; slabs_init ( settings . maxbytes , settings . factor , preallocate , use_slab_sizes ? slab_sizes : NULL ) ; # ifdef EXTSTORE if ( storage_file ) { enum extstore_res eres ; if ( settings . ext_compact_under == 0 ) { settings . ext_compact_under = ext_cf . page_count / 4 ; settings . ext_drop_under = ext_cf . page_count / 4 ; } crc32c_init ( ) ; for ( int x = 0 ; x < MAX_NUMBER_OF_SLAB_CLASSES ; x ++ ) { settings . ext_free_memchunks [ x ] = 0 ; } storage = extstore_init ( storage_file , & ext_cf , & eres ) ; if ( storage == NULL ) { fprintf ( stderr , ""Failedtoinitializeexternalstorage:%s\\n"" , extstore_err ( eres ) ) ; if ( eres == EXTSTORE_INIT_OPEN_FAIL ) { perror ( ""extstoreopen"" ) ; } exit ( EXIT_FAILURE ) ; } ext_storage = storage ; slabs_prefill_global ( ) ; } # endif if ( sigignore ( SIGPIPE ) == - 1 ) { perror ( ""failedtoignoreSIGPIPE;sigaction"" ) ; exit ( EX_OSERR ) ; } # ifdef EXTSTORE slabs_set_storage ( storage ) ; memcached_thread_init ( settings . num_threads , storage ) ; init_lru_crawler ( storage ) ; # else memcached_thread_init ( settings . num_threads , NULL ) ; init_lru_crawler ( NULL ) ; # endif if ( start_assoc_maint && start_assoc_maintenance_thread ( ) == - 1 ) { exit ( EXIT_FAILURE ) ; } if ( start_lru_crawler && start_item_crawler_thread ( ) != 0 ) { fprintf ( stderr , ""FailedtoenableLRUcrawlerthread\\n"" ) ; exit ( EXIT_FAILURE ) ; } # ifdef EXTSTORE if ( storage && start_storage_compact_thread ( storage ) != 0 ) { fprintf ( stderr , ""Failedtostartstoragecompactionthread\\n"" ) ; exit ( EXIT_FAILURE ) ; } if ( start_lru_maintainer && start_lru_maintainer_thread ( storage ) != 0 ) { # else if ( start_lru_maintainer && start_lru_maintainer_thread ( NULL ) != 0 ) { # endif fprintf ( stderr , ""FailedtoenableLRUmaintainerthread\\n"" ) ; return 1 ; } if ( settings . slab_reassign && start_slab_maintenance_thread ( ) == - 1 ) { exit ( EXIT_FAILURE ) ; } if ( settings . idle_timeout && start_conn_timeout_thread ( ) == - 1 ) { exit ( EXIT_FAILURE ) ; } clock_handler ( 0 , 0 , 0 ) ; if ( settings . socketpath != NULL ) { errno = 0 ; if ( server_socket_unix ( settings . socketpath , settings . access ) ) { vperror ( ""failedtolistenonUNIXsocket:%s"" , settings . socketpath ) ; exit ( EX_OSERR ) ; } } if ( settings . socketpath == NULL ) { const char * portnumber_filename = getenv ( ""MEMCACHED_PORT_FILENAME"" ) ; char * temp_portnumber_filename = NULL ; size_t len ; FILE * portnumber_file = NULL ; if ( portnumber_filename != NULL ) { len = strlen ( portnumber_filename ) + 4 + 1 ; temp_portnumber_filename = malloc ( len ) ; snprintf ( temp_portnumber_filename , len , ""%s.lck"" , portnumber_filename ) ; portnumber_file = fopen ( temp_portnumber_filename , ""a"" ) ; if ( portnumber_file == NULL ) { fprintf ( stderr , ""Failedtoopen\\""%s\\"":%s\\n"" , temp_portnumber_filename , strerror ( errno ) ) ; } } errno = 0 ; if ( settings . port && server_sockets ( settings . port , tcp_transport , portnumber_file ) ) { vperror ( ""failedtolistenonTCPport%d"" , settings . port ) ; exit ( EX_OSERR ) ; } errno = 0 ; if ( settings . udpport && server_sockets ( settings . udpport , udp_transport , portnumber_file ) ) { vperror ( ""failedtolistenonUDPport%d"" , settings . udpport ) ; exit ( EX_OSERR ) ; } if ( portnumber_file ) { fclose ( portnumber_file ) ; rename ( temp_portnumber_filename , portnumber_filename ) ; } if ( temp_portnumber_filename ) free ( temp_portnumber_filename ) ; } usleep ( 1000 ) ; if ( stats_state . curr_conns + stats_state . reserved_fds >= settings . maxconns - 1 ) { fprintf ( stderr , ""Maxconnssettingistoolow,use-ctoincrease.\\n"" ) ; exit ( EXIT_FAILURE ) ; } if ( pid_file != NULL ) { save_pid ( pid_file ) ; } if ( settings . drop_privileges ) { drop_privileges ( ) ; } uriencode_init ( ) ; if ( event_base_loop ( main_base , 0 ) != 0 ) { retval = EXIT_FAILURE ; } stop_assoc_maintenance_thread ( ) ; if ( do_daemonize ) remove_pidfile ( pid_file ) ; if ( settings . inter ) free ( settings . inter ) ; if ( l_socket ) free ( l_socket ) ; if ( u_socket ) free ( u_socket ) ; event_base_free ( main_base ) ; return retval ; } "," } if ( udp_specified && settings ",memcached@memcached/dbb7a8af90054bf4ef51f5814ef7ceb17d83d974,CVE-2018-1000115,https://github.com/memcached/memcached/commit/dbb7a8af90054bf4ef51f5814ef7ceb17d83d974,2018-03-05T14:29Z 223,CWE-125,"CWE-125 INST_HANDLER ( sbrx ) { int b = buf [ 0 ] & 0x7 ; int r = ( ( buf [ 0 ] >> 4 ) & 0xf ) | ( ( buf [ 1 ] & 0x01 ) << 4 ) ; RAnalOp next_op ; avr_op_analyze ( anal , & next_op , op -> addr + op -> size , buf + op -> size , len - op -> size , cpu ) ; r_strbuf_fini ( & next_op . esil ) ; op -> jump = op -> addr + next_op . size + 2 ; op -> cycles = 1 ; ESIL_A ( ""%d,1,<<,r%d,&,"" , b , r ) ; ESIL_A ( ( buf [ 1 ] & 0xe ) == 0xc ? ""!,"" : ""!,!,"" ) ; ESIL_A ( ""?{,%"" PFMT64d "",pc,=,},"" , op -> jump ) ; } "," ; RAnalOp next_op = { 0 } ",radare@radare2/25a3703ef2e015bbe1d1f16f6b2f63bb10dd34f4,CVE-2018-11377,https://github.com/radare/radare2/commit/25a3703ef2e015bbe1d1f16f6b2f63bb10dd34f4,2018-05-22T19:29Z 224,CWE-476,"CWE-476 static gboolean prplcb_xfer_new_send_cb ( gpointer data , gint fd , b_input_condition cond ) { PurpleXfer * xfer = data ; struct im_connection * ic = purple_ic_by_pa ( xfer -> account ) ; struct prpl_xfer_data * px = xfer -> ui_data ; PurpleBuddy * buddy ; const char * who ; buddy = purple_find_buddy ( xfer -> account , xfer -> who ) ; who = buddy ? purple_buddy_get_name ( buddy ) : xfer -> who ; px -> ft = imcb_file_send_start ( ic , ( char * ) who , xfer -> filename , xfer -> size ) ; px -> ft -> data = px ; px -> ft -> accept = prpl_xfer_accept ; px -> ft -> canceled = prpl_xfer_canceled ; px -> ft -> free = prpl_xfer_free ; px -> ft -> write_request = prpl_xfer_write_request ; return FALSE ; } "," size ) ; if ( ! px -> ft ) { return FALSE ; } ",bitlbee@bitlbee/30d598ce7cd3f136ee9d7097f39fa9818a272441,CVE-2017-5668,https://github.com/bitlbee/bitlbee/commit/30d598ce7cd3f136ee9d7097f39fa9818a272441,2017-03-14T14:59Z 225,CWE-000,"CWE-000 int perf_config ( config_fn_t fn , void * data ) { int ret = 0 , found = 0 ; char * repo_config = NULL ; const char * home = NULL ; if ( config_exclusive_filename ) return perf_config_from_file ( fn , config_exclusive_filename , data ) ; if ( perf_config_system ( ) && ! access ( perf_etc_perfconfig ( ) , R_OK ) ) { ret += perf_config_from_file ( fn , perf_etc_perfconfig ( ) , data ) ; found += 1 ; } home = getenv ( ""HOME"" ) ; if ( perf_config_global ( ) && home ) { char * user_config = strdup ( mkpath ( ""%s/.perfconfig"" , home ) ) ; if ( ! access ( user_config , R_OK ) ) { ret += perf_config_from_file ( fn , user_config , data ) ; found += 1 ; } free ( user_config ) ; } repo_config = perf_pathdup ( ""config"" ) ; if ( ! access ( repo_config , R_OK ) ) { ret += perf_config_from_file ( fn , repo_config , data ) ; found += 1 ; } free ( repo_config ) ; if ( found == 0 ) return - 1 ; return ret ; } "," found = 0 ; const char ) ; } if ( found ",torvalds@linux/aba8d056078e47350d85b06a9cabd5afcc4b72ea,CVE-2011-2905,https://github.com/torvalds/linux/commit/aba8d056078e47350d85b06a9cabd5afcc4b72ea,2013-03-01T12:37Z 226,CWE-264,"CWE-264 static int validate_event ( struct pmu_hw_events * hw_events , struct perf_event * event ) { struct arm_pmu * armpmu = to_arm_pmu ( event -> pmu ) ; struct hw_perf_event fake_event = event -> hw ; struct pmu * leader_pmu = event -> group_leader -> pmu ; if ( is_software_event ( event ) ) return 1 ; if ( event -> pmu != leader_pmu || event -> state < PERF_EVENT_STATE_OFF ) return 1 ; if ( event -> state == PERF_EVENT_STATE_OFF && ! event -> attr . enable_on_exec ) return 1 ; return armpmu -> get_event_idx ( hw_events , & fake_event ) >= 0 ; } "," int validate_event ( struct pmu * pmu , arm_pmu * armpmu ; struct hw_perf_event -> pmu != pmu ) return 0 ; if ( event -> pmu != return 1 ; armpmu = to_arm_pmu ( event -> pmu ) ; ",torvalds@linux/8fff105e13041e49b82f92eef034f363a6b1c071,CVE-2015-8955,https://github.com/torvalds/linux/commit/8fff105e13041e49b82f92eef034f363a6b1c071,2016-10-10T10:59Z 227,CWE-264,"CWE-264 static bool new_idmap_permitted ( struct user_namespace * ns , int cap_setid , struct uid_gid_map * new_map ) { if ( ( new_map -> nr_extents == 1 ) && ( new_map -> extent [ 0 ] . count == 1 ) ) { u32 id = new_map -> extent [ 0 ] . lower_first ; if ( cap_setid == CAP_SETUID ) { kuid_t uid = make_kuid ( ns -> parent , id ) ; if ( uid_eq ( uid , current_fsuid ( ) ) ) return true ; } else if ( cap_setid == CAP_SETGID ) { kgid_t gid = make_kgid ( ns -> parent , id ) ; if ( gid_eq ( gid , current_fsgid ( ) ) ) return true ; } } if ( ! cap_valid ( cap_setid ) ) return true ; if ( ns_capable ( ns -> parent , cap_setid ) ) return true ; return false ; } "," bool new_idmap_permitted ( const struct file * file , , cap_setid ) && file_ns_capable ( file , ns -> parent , cap_setid ) ",torvalds@linux/6708075f104c3c9b04b23336bb0366ca30c3931b,CVE-2013-1959,https://github.com/torvalds/linux/commit/6708075f104c3c9b04b23336bb0366ca30c3931b,2013-05-03T11:57Z 228,CWE-125,"CWE-125 static VarLenData * * get_html_data ( MAPI_Attr * a ) { VarLenData * * body = XCALLOC ( VarLenData * , a -> num_values + 1 ) ; int j ; for ( j = 0 ; j < a -> num_values ; j ++ ) { body [ j ] = XMALLOC ( VarLenData , 1 ) ; body [ j ] -> len = a -> values [ j ] . len ; body [ j ] -> data = CHECKED_XCALLOC ( unsigned char , a -> values [ j ] . len ) ; memmove ( body [ j ] -> data , a -> values [ j ] . data . buf , body [ j ] -> len ) ; } return body ; } "," j ++ ) { if ( a -> type == szMAPI_BINARY ) ) ; } } ",verdammelt@tnef/8dccf79857ceeb7a6d3e42c1e762e7b865d5344d,CVE-2017-6310,https://github.com/verdammelt/tnef/commit/8dccf79857ceeb7a6d3e42c1e762e7b865d5344d,2017-02-24T04:59Z 229,CWE-119,"CWE-119 int usb_cypress_load_firmware ( struct usb_device * udev , const struct firmware * fw , int type ) { struct hexline * hx ; u8 reset ; int ret , pos = 0 ; hx = kmalloc ( sizeof ( * hx ) , GFP_KERNEL ) ; if ( ! hx ) return - ENOMEM ; reset = 1 ; if ( ( ret = usb_cypress_writemem ( udev , cypress [ type ] . cpu_cs_register , & reset , 1 ) ) != 1 ) err ( ""couldnotstoptheUSBcontrollerCPU."" ) ; while ( ( ret = dvb_usb_get_hexline ( fw , hx , & pos ) ) > 0 ) { deb_fw ( ""writingtoaddress0x%04x(buffer:0x%02x%02x)\\n"" , hx -> addr , hx -> len , hx -> chk ) ; ret = usb_cypress_writemem ( udev , hx -> addr , hx -> data , hx -> len ) ; if ( ret != hx -> len ) { err ( ""errorwhiletransferringfirmware(transferredsize:%d,blocksize:%d)"" , ret , hx -> len ) ; ret = - EINVAL ; break ; } } if ( ret < 0 ) { err ( ""firmwaredownloadfailedat%dwith%d"" , pos , ret ) ; kfree ( hx ) ; return ret ; } if ( ret == 0 ) { reset = 0 ; if ( ret || usb_cypress_writemem ( udev , cypress [ type ] . cpu_cs_register , & reset , 1 ) != 1 ) { err ( ""couldnotrestarttheUSBcontrollerCPU."" ) ; ret = - EINVAL ; } } else ret = - EIO ; kfree ( hx ) ; return ret ; } "," hx ; u8 * buf ; int ret = 0 ; u16 cpu_cs_register = cypress [ type ] . cpu_cs_register ; buf = kmalloc ( sizeof ( * hx ) , GFP_KERNEL ) ; if ( ! buf ) return - ENOMEM ; hx = ( struct hexline * ) buf ; buf [ 0 ] = 1 ; if ( usb_cypress_writemem ( udev , cpu_cs_register , buf , 1 ) != 1 ; kfree ( buf ) ; return 0 ) { buf [ 0 ] = 0 ; if ( usb_cypress_writemem ( udev ( udev , cpu_cs_register , buf , 1 ) ; kfree ( buf ) ; return ",torvalds@linux/67b0503db9c29b04eadfeede6bebbfe5ddad94ef,CVE-2017-8061,https://github.com/torvalds/linux/commit/67b0503db9c29b04eadfeede6bebbfe5ddad94ef,2017-04-23T05:59Z 230,CWE-125,"CWE-125 static void l2tp_call_errors_print ( netdissect_options * ndo , const u_char * dat ) { const uint16_t * ptr = ( const uint16_t * ) dat ; uint16_t val_h , val_l ; ptr ++ ; val_h = EXTRACT_16BITS ( ptr ) ; ptr ++ ; val_l = EXTRACT_16BITS ( ptr ) ; ptr ++ ; ND_PRINT ( ( ndo , ""CRCErr=%u"" , ( val_h << 16 ) + val_l ) ) ; val_h = EXTRACT_16BITS ( ptr ) ; ptr ++ ; val_l = EXTRACT_16BITS ( ptr ) ; ptr ++ ; ND_PRINT ( ( ndo , ""FrameErr=%u"" , ( val_h << 16 ) + val_l ) ) ; val_h = EXTRACT_16BITS ( ptr ) ; ptr ++ ; val_l = EXTRACT_16BITS ( ptr ) ; ptr ++ ; ND_PRINT ( ( ndo , ""HardOver=%u"" , ( val_h << 16 ) + val_l ) ) ; val_h = EXTRACT_16BITS ( ptr ) ; ptr ++ ; val_l = EXTRACT_16BITS ( ptr ) ; ptr ++ ; ND_PRINT ( ( ndo , ""BufOver=%u"" , ( val_h << 16 ) + val_l ) ) ; val_h = EXTRACT_16BITS ( ptr ) ; ptr ++ ; val_l = EXTRACT_16BITS ( ptr ) ; ptr ++ ; ND_PRINT ( ( ndo , ""Timeout=%u"" , ( val_h << 16 ) + val_l ) ) ; val_h = EXTRACT_16BITS ( ptr ) ; ptr ++ ; val_l = EXTRACT_16BITS ( ptr ) ; ptr ++ ; ND_PRINT ( ( ndo , ""AlignErr=%u"" , ( val_h << 16 ) + val_l ) ) ; } "," u_char * dat , u_int length , val_l ; if ( length < 2 ) { ND_PRINT ( ( ndo , ""AVPtooshort"" ) ) ; return ; } ptr ++ ; length -= 2 ; if ( length < 4 ) { ND_PRINT ( ( ndo , ""AVPtooshort"" ) ) ; return ; } val_h = EXTRACT_16BITS ( ptr ) ; ptr ++ ; length -= 2 ; val_l = EXTRACT_16BITS ( ptr ) ; ptr ++ ; length -= 2 ; ND_PRINT ( ) ) ; if ( length < 4 ) { ND_PRINT ( ( ndo , ""AVPtooshort"" ) ) ; return ; } val_h = EXTRACT_16BITS ( ptr ) ; ptr ++ ; length -= 2 ; val_l = EXTRACT_16BITS ( ptr ) ; ptr ++ ; length -= 2 ; ND_PRINT ( ) ) ; if ( length < 4 ) { ND_PRINT ( ( ndo , ""AVPtooshort"" ) ) ; return ; } val_h = EXTRACT_16BITS ( ptr ) ; ptr ++ ; length -= 2 ; val_l = EXTRACT_16BITS ( ptr ) ; ptr ++ ; length -= 2 ; ND_PRINT ( ) ) ; if ( length < 4 ) { ND_PRINT ( ( ndo , ""AVPtooshort"" ) ) ; return ; } val_h = EXTRACT_16BITS ( ptr ) ; ptr ++ ; length -= 2 ; val_l = EXTRACT_16BITS ( ptr ) ; ptr ++ ; length -= 2 ; ND_PRINT ( ) ) ; if ( length < 4 ) { ND_PRINT ( ( ndo , ""AVPtooshort"" ) ) ; return ; } val_h = EXTRACT_16BITS ( ptr ) ; ptr ++ ; length -= 2 ; val_l = EXTRACT_16BITS ( ptr ) ; ptr ++ ; length -= 2 ; ND_PRINT ( ) ) ; if ( length < 4 ) { ND_PRINT ( ( ndo , ""AVPtooshort"" ) ) ; return ; } ",the-tcpdump-group@tcpdump/cc4a7391c616be7a64ed65742ef9ed3f106eb165,CVE-2017-13006,https://github.com/the-tcpdump-group/tcpdump/commit/cc4a7391c616be7a64ed65742ef9ed3f106eb165,2017-09-14T06:29Z 231,CWE-284,"CWE-284 static int check_rpcsec_auth ( struct svc_req * rqstp ) { gss_ctx_id_t ctx ; krb5_context kctx ; OM_uint32 maj_stat , min_stat ; gss_name_t name ; krb5_principal princ ; int ret , success ; krb5_data * c1 , * c2 , * realm ; gss_buffer_desc gss_str ; kadm5_server_handle_t handle ; size_t slen ; char * sdots ; success = 0 ; handle = ( kadm5_server_handle_t ) global_server_handle ; if ( rqstp -> rq_cred . oa_flavor != RPCSEC_GSS ) return 0 ; ctx = rqstp -> rq_svccred ; maj_stat = gss_inquire_context ( & min_stat , ctx , NULL , & name , NULL , NULL , NULL , NULL , NULL ) ; if ( maj_stat != GSS_S_COMPLETE ) { krb5_klog_syslog ( LOG_ERR , _ ( ""check_rpcsec_auth:failed"" ""inquire_context,stat=%u"" ) , maj_stat ) ; log_badauth ( maj_stat , min_stat , rqstp -> rq_xprt , NULL ) ; goto fail_name ; } kctx = handle -> context ; ret = gss_to_krb5_name_1 ( rqstp , kctx , name , & princ , & gss_str ) ; if ( ret == 0 ) goto fail_name ; slen = gss_str . length ; trunc_name ( & slen , & sdots ) ; if ( krb5_princ_size ( kctx , princ ) != 2 ) goto fail_princ ; c1 = krb5_princ_component ( kctx , princ , 0 ) ; c2 = krb5_princ_component ( kctx , princ , 1 ) ; realm = krb5_princ_realm ( kctx , princ ) ; if ( strncmp ( handle -> params . realm , realm -> data , realm -> length ) == 0 && strncmp ( ""kadmin"" , c1 -> data , c1 -> length ) == 0 ) { if ( strncmp ( ""history"" , c2 -> data , c2 -> length ) == 0 ) goto fail_princ ; else success = 1 ; } fail_princ : if ( ! success ) { krb5_klog_syslog ( LOG_ERR , _ ( ""badserviceprincipal%.*s%s"" ) , ( int ) slen , ( char * ) gss_str . value , sdots ) ; } gss_release_buffer ( & min_stat , & gss_str ) ; krb5_free_principal ( kctx , princ ) ; fail_name : gss_release_name ( & min_stat , & name ) ; return success ; } "," princ ) ; success = data_eq_string ( * realm , handle -> params params . realm ) && data_eq_string ( * c1 , ""kadmin"" ) && ! data_eq_string ( * c2 , ""history"" ) ; fail_princ : if ",krb5@krb5/6609658db0799053fbef0d7d0aa2f1fd68ef32d8,CVE-2014-9422,https://github.com/krb5/krb5/commit/6609658db0799053fbef0d7d0aa2f1fd68ef32d8,2015-02-19T11:59Z 232,CWE-190,"CWE-190 static int vc4_get_bcl ( struct drm_device * dev , struct vc4_exec_info * exec ) { struct drm_vc4_submit_cl * args = exec -> args ; void * temp = NULL ; void * bin ; int ret = 0 ; uint32_t bin_offset = 0 ; uint32_t shader_rec_offset = roundup ( bin_offset + args -> bin_cl_size , 16 ) ; uint32_t uniforms_offset = shader_rec_offset + args -> shader_rec_size ; uint32_t exec_size = uniforms_offset + args -> uniforms_size ; uint32_t temp_size = exec_size + ( sizeof ( struct vc4_shader_state ) * args -> shader_rec_count ) ; struct vc4_bo * bo ; if ( uniforms_offset < shader_rec_offset || exec_size < uniforms_offset || args -> shader_rec_count >= ( UINT_MAX / sizeof ( struct vc4_shader_state ) ) || temp_size < exec_size ) { DRM_ERROR ( ""overflowinexecarguments\\n"" ) ; goto fail ; } temp = drm_malloc_ab ( temp_size , 1 ) ; if ( ! temp ) { DRM_ERROR ( ""Failedtoallocatestorageforcopying"" ""inbin/renderCLs.\\n"" ) ; ret = - ENOMEM ; goto fail ; } bin = temp + bin_offset ; exec -> shader_rec_u = temp + shader_rec_offset ; exec -> uniforms_u = temp + uniforms_offset ; exec -> shader_state = temp + exec_size ; exec -> shader_state_size = args -> shader_rec_count ; if ( copy_from_user ( bin , ( void __user * ) ( uintptr_t ) args -> bin_cl , args -> bin_cl_size ) ) { ret = - EFAULT ; goto fail ; } if ( copy_from_user ( exec -> shader_rec_u , ( void __user * ) ( uintptr_t ) args -> shader_rec , args -> shader_rec_size ) ) { ret = - EFAULT ; goto fail ; } if ( copy_from_user ( exec -> uniforms_u , ( void __user * ) ( uintptr_t ) args -> uniforms , args -> uniforms_size ) ) { ret = - EFAULT ; goto fail ; } bo = vc4_bo_create ( dev , exec_size , true ) ; if ( IS_ERR ( bo ) ) { DRM_ERROR ( ""Couldn\'tallocateBOforbinning\\n"" ) ; ret = PTR_ERR ( bo ) ; goto fail ; } exec -> exec_bo = & bo -> base ; list_add_tail ( & to_vc4_bo ( & exec -> exec_bo -> base ) -> unref_head , & exec -> unref_list ) ; exec -> ct0ca = exec -> exec_bo -> paddr + bin_offset ; exec -> bin_u = bin ; exec -> shader_rec_v = exec -> exec_bo -> vaddr + shader_rec_offset ; exec -> shader_rec_p = exec -> exec_bo -> paddr + shader_rec_offset ; exec -> shader_rec_size = args -> shader_rec_size ; exec -> uniforms_v = exec -> exec_bo -> vaddr + uniforms_offset ; exec -> uniforms_p = exec -> exec_bo -> paddr + uniforms_offset ; exec -> uniforms_size = args -> uniforms_size ; ret = vc4_validate_bin_cl ( dev , exec -> exec_bo -> vaddr + bin_offset , bin , exec ) ; if ( ret ) goto fail ; ret = vc4_validate_shader_recs ( dev , exec ) ; if ( ret ) goto fail ; ret = vc4_wait_for_seqno ( dev , exec -> bin_dep_seqno , ~ 0ull , true ) ; fail : drm_free_large ( temp ) ; return ret ; } "," ; if ( shader_rec_offset < args -> bin_cl_size || ",torvalds@linux/0f2ff82e11c86c05d051cae32b58226392d33bbf,CVE-2017-5576,https://github.com/torvalds/linux/commit/0f2ff82e11c86c05d051cae32b58226392d33bbf,2017-02-06T06:59Z 233,CWE-401,"CWE-401 static int archive_read_format_zip_cleanup ( struct archive_read * a ) { struct zip * zip ; struct zip_entry * zip_entry , * next_zip_entry ; zip = ( struct zip * ) ( a -> format -> data ) ; # ifdef HAVE_ZLIB_H if ( zip -> stream_valid ) inflateEnd ( & zip -> stream ) ; # endif # if HAVA_LZMA_H && HAVE_LIBLZMA if ( zip -> zipx_lzma_valid ) { lzma_end ( & zip -> zipx_lzma_stream ) ; } # endif # ifdef HAVE_BZLIB_H if ( zip -> bzstream_valid ) { BZ2_bzDecompressEnd ( & zip -> bzstream ) ; } # endif free ( zip -> uncompressed_buffer ) ; if ( zip -> ppmd8_valid ) __archive_ppmd8_functions . Ppmd8_Free ( & zip -> ppmd8 ) ; if ( zip -> zip_entries ) { zip_entry = zip -> zip_entries ; while ( zip_entry != NULL ) { next_zip_entry = zip_entry -> next ; archive_string_free ( & zip_entry -> rsrcname ) ; free ( zip_entry ) ; zip_entry = next_zip_entry ; } } free ( zip -> decrypted_buffer ) ; if ( zip -> cctx_valid ) archive_decrypto_aes_ctr_release ( & zip -> cctx ) ; if ( zip -> hctx_valid ) archive_hmac_sha1_cleanup ( & zip -> hctx ) ; free ( zip -> iv ) ; free ( zip -> erd ) ; free ( zip -> v_data ) ; archive_string_free ( & zip -> format_name ) ; free ( zip ) ; ( a -> format -> data ) = NULL ; return ( ARCHIVE_OK ) ; } "," endif # if HAVE_LZMA_H && HAVE_LIBLZMA if ",libarchive@libarchive/ba641f73f3d758d9032b3f0e5597a9c6e593a505,CVE-2019-11463,https://github.com/libarchive/libarchive/commit/ba641f73f3d758d9032b3f0e5597a9c6e593a505,2019-04-23T03:29Z 234,CWE-362,"CWE-362 int ext4_page_mkwrite ( struct vm_area_struct * vma , struct vm_fault * vmf ) { struct page * page = vmf -> page ; loff_t size ; unsigned long len ; int ret ; struct file * file = vma -> vm_file ; struct inode * inode = file_inode ( file ) ; struct address_space * mapping = inode -> i_mapping ; handle_t * handle ; get_block_t * get_block ; int retries = 0 ; sb_start_pagefault ( inode -> i_sb ) ; file_update_time ( vma -> vm_file ) ; if ( test_opt ( inode -> i_sb , DELALLOC ) && ! ext4_should_journal_data ( inode ) && ! ext4_nonda_switch ( inode -> i_sb ) ) { do { ret = block_page_mkwrite ( vma , vmf , ext4_da_get_block_prep ) ; } while ( ret == - ENOSPC && ext4_should_retry_alloc ( inode -> i_sb , & retries ) ) ; goto out_ret ; } lock_page ( page ) ; size = i_size_read ( inode ) ; if ( page -> mapping != mapping || page_offset ( page ) > size ) { unlock_page ( page ) ; ret = VM_FAULT_NOPAGE ; goto out ; } if ( page -> index == size >> PAGE_CACHE_SHIFT ) len = size & ~ PAGE_CACHE_MASK ; else len = PAGE_CACHE_SIZE ; if ( page_has_buffers ( page ) ) { if ( ! ext4_walk_page_buffers ( NULL , page_buffers ( page ) , 0 , len , NULL , ext4_bh_unmapped ) ) { wait_for_stable_page ( page ) ; ret = VM_FAULT_LOCKED ; goto out ; } } unlock_page ( page ) ; if ( ext4_should_dioread_nolock ( inode ) ) get_block = ext4_get_block_write ; else get_block = ext4_get_block ; retry_alloc : handle = ext4_journal_start ( inode , EXT4_HT_WRITE_PAGE , ext4_writepage_trans_blocks ( inode ) ) ; if ( IS_ERR ( handle ) ) { ret = VM_FAULT_SIGBUS ; goto out ; } ret = block_page_mkwrite ( vma , vmf , get_block ) ; if ( ! ret && ext4_should_journal_data ( inode ) ) { if ( ext4_walk_page_buffers ( handle , page_buffers ( page ) , 0 , PAGE_CACHE_SIZE , NULL , do_journal_get_write_access ) ) { unlock_page ( page ) ; ret = VM_FAULT_SIGBUS ; ext4_journal_stop ( handle ) ; goto out ; } ext4_set_inode_state ( inode , EXT4_STATE_JDATA ) ; } ext4_journal_stop ( handle ) ; if ( ret == - ENOSPC && ext4_should_retry_alloc ( inode -> i_sb , & retries ) ) goto retry_alloc ; out_ret : ret = block_page_mkwrite_return ( ret ) ; out : sb_end_pagefault ( inode -> i_sb ) ; return ret ; } "," vma -> vm_file ) ; down_read ( & EXT4_I ( inode ) -> i_mmap_sem ; out : up_read ( & EXT4_I ( inode ) -> i_mmap_sem ) ; ",torvalds@linux/ea3d7209ca01da209cda6f0dea8be9cc4b7a933b,CVE-2015-8839,https://github.com/torvalds/linux/commit/ea3d7209ca01da209cda6f0dea8be9cc4b7a933b,2016-05-02T10:59Z 235,CWE-190,"CWE-190 static int jas_iccgetuint64 ( jas_stream_t * in , jas_iccuint64_t * val ) { ulonglong tmp ; if ( jas_iccgetuint ( in , 8 , & tmp ) ) return - 1 ; * val = tmp ; return 0 ; } "," val ) { jas_ulonglong tmp ; if ",mdadams@jasper/d42b2388f7f8e0332c846675133acea151fc557a,CVE-2016-9557,https://github.com/mdadams/jasper/commit/d42b2388f7f8e0332c846675133acea151fc557a,2017-03-23T18:59Z 236,CWE-78,"CWE-78 static char * __filterShell ( const char * arg ) { r_return_val_if_fail ( arg , NULL ) ; char * a = malloc ( strlen ( arg ) + 1 ) ; if ( ! a ) { return NULL ; } char * b = a ; while ( * arg ) { switch ( * arg ) { case '@' : case '`' : case '|' : case ';' : case '\\n' : break ; default : * b ++ = * arg ; break ; } arg ++ ; } * b = 0 ; return a ; } "," arg ) { char ch = * arg ; switch ( ch ) { case ';' : case '=' : case b ++ = ch ; break ; ",radareorg@radare2/5411543a310a470b1257fb93273cdd6e8dfcb3af,CVE-2019-16718,https://github.com/radareorg/radare2/commit/5411543a310a470b1257fb93273cdd6e8dfcb3af,2019-09-23T14:15Z 237,CWE-125,"CWE-125 static const u_char * ikev1_t_print ( netdissect_options * ndo , u_char tpay _U_ , const struct isakmp_gen * ext , u_int item_len , const u_char * ep , uint32_t phase _U_ , uint32_t doi _U_ , uint32_t proto , int depth _U_ ) { const struct ikev1_pl_t * p ; struct ikev1_pl_t t ; const u_char * cp ; const char * idstr ; const struct attrmap * map ; size_t nmap ; const u_char * ep2 ; ND_PRINT ( ( ndo , ""%s:"" , NPSTR ( ISAKMP_NPTYPE_T ) ) ) ; p = ( const struct ikev1_pl_t * ) ext ; ND_TCHECK ( * p ) ; UNALIGNED_MEMCPY ( & t , ext , sizeof ( t ) ) ; switch ( proto ) { case 1 : idstr = STR_OR_ID ( t . t_id , ikev1_p_map ) ; map = oakley_t_map ; nmap = sizeof ( oakley_t_map ) / sizeof ( oakley_t_map [ 0 ] ) ; break ; case 2 : idstr = STR_OR_ID ( t . t_id , ah_p_map ) ; map = ipsec_t_map ; nmap = sizeof ( ipsec_t_map ) / sizeof ( ipsec_t_map [ 0 ] ) ; break ; case 3 : idstr = STR_OR_ID ( t . t_id , esp_p_map ) ; map = ipsec_t_map ; nmap = sizeof ( ipsec_t_map ) / sizeof ( ipsec_t_map [ 0 ] ) ; break ; case 4 : idstr = STR_OR_ID ( t . t_id , ipcomp_p_map ) ; map = ipsec_t_map ; nmap = sizeof ( ipsec_t_map ) / sizeof ( ipsec_t_map [ 0 ] ) ; break ; default : idstr = NULL ; map = NULL ; nmap = 0 ; break ; } if ( idstr ) ND_PRINT ( ( ndo , ""#%did=%s"" , t . t_no , idstr ) ) ; else ND_PRINT ( ( ndo , ""#%did=%d"" , t . t_no , t . t_id ) ) ; cp = ( const u_char * ) ( p + 1 ) ; ep2 = ( const u_char * ) p + item_len ; while ( cp < ep && cp < ep2 ) { if ( map && nmap ) { cp = ikev1_attrmap_print ( ndo , cp , ( ep < ep2 ) ? ep : ep2 , map , nmap ) ; } else cp = ikev1_attr_print ( ndo , cp , ( ep < ep2 ) ? ep : ep2 ) ; } if ( ep < ep2 ) ND_PRINT ( ( ndo , ""..."" ) ) ; return cp ; trunc : ND_PRINT ( ( ndo , ""[|%s]"" , NPSTR ( ISAKMP_NPTYPE_T ) ) ) ; return NULL ; } "," && nmap ) cp = ikev1_attrmap_print , cp , ep2 , map , nmap ) ; else cp = ikev1_attr_print ( ndo , cp , ep2 ) ; if ( cp == NULL ) goto trunc ; } if < ep2 ) ND_PRINT ( ( ",the-tcpdump-group@tcpdump/e0a5a02b0fc1900a69d6c37ed0aab36fb8494e6d,CVE-2017-13039,https://github.com/the-tcpdump-group/tcpdump/commit/e0a5a02b0fc1900a69d6c37ed0aab36fb8494e6d,2017-09-14T06:29Z 238,CWE-835,"CWE-835 G_DEFINE_TYPE ( GsmXsmpServer , gsm_xsmp_server , G_TYPE_OBJECT ) typedef struct { GsmXsmpServer * server ; IceListenObj listener ; } GsmIceConnectionData ; static gboolean accept_ice_connection ( GIOChannel * source , GIOCondition condition , GsmIceConnectionData * data ) { IceListenObj listener ; IceConn ice_conn ; IceAcceptStatus status ; GsmClient * client ; GsmXsmpServer * server ; listener = data -> listener ; server = data -> server ; g_debug ( ""GsmXsmpServer:accept_ice_connection()"" ) ; ice_conn = IceAcceptConnection ( listener , & status ) ; if ( status != IceAcceptSuccess ) { g_debug ( ""GsmXsmpServer:IceAcceptConnectionreturned%d"" , status ) ; return TRUE ; } client = gsm_xsmp_client_new ( ice_conn ) ; ice_conn -> context = client ; gsm_store_add ( server -> priv -> client_store , gsm_client_peek_id ( client ) , G_OBJECT ( client ) ) ; g_object_unref ( client ) ; return TRUE ; } "," } GsmIceConnectionData ; typedef struct { guint watch_id ; guint protocol_timeout ; } GsmIceConnectionWatch ; static void disconnect_ice_connection ( IceConn ice_conn ) { IceSetShutdownNegotiation ( ice_conn , FALSE ) ; IceCloseConnection ( ice_conn ) ice_conn ) ; } ",GNOME@gnome-session/b0dc999e0b45355314616321dbb6cb71e729fc9d,CVE-2017-11171,https://github.com/GNOME/gnome-session/commit/b0dc999e0b45355314616321dbb6cb71e729fc9d,2017-07-11T20:29Z 239,CWE-399,"CWE-399 static struct sk_buff * udp6_ufo_fragment ( struct sk_buff * skb , u32 features ) { struct sk_buff * segs = ERR_PTR ( - EINVAL ) ; unsigned int mss ; unsigned int unfrag_ip6hlen , unfrag_len ; struct frag_hdr * fptr ; u8 * mac_start , * prevhdr ; u8 nexthdr ; u8 frag_hdr_sz = sizeof ( struct frag_hdr ) ; int offset ; __wsum csum ; mss = skb_shinfo ( skb ) -> gso_size ; if ( unlikely ( skb -> len <= mss ) ) goto out ; if ( skb_gso_ok ( skb , features | NETIF_F_GSO_ROBUST ) ) { int type = skb_shinfo ( skb ) -> gso_type ; if ( unlikely ( type & ~ ( SKB_GSO_UDP | SKB_GSO_DODGY ) || ! ( type & ( SKB_GSO_UDP ) ) ) ) goto out ; skb_shinfo ( skb ) -> gso_segs = DIV_ROUND_UP ( skb -> len , mss ) ; segs = NULL ; goto out ; } offset = skb -> csum_start - skb_headroom ( skb ) ; csum = skb_checksum ( skb , offset , skb -> len - offset , 0 ) ; offset += skb -> csum_offset ; * ( __sum16 * ) ( skb -> data + offset ) = csum_fold ( csum ) ; skb -> ip_summed = CHECKSUM_NONE ; if ( ( skb_headroom ( skb ) < frag_hdr_sz ) && pskb_expand_head ( skb , frag_hdr_sz , 0 , GFP_ATOMIC ) ) goto out ; unfrag_ip6hlen = ip6_find_1stfragopt ( skb , & prevhdr ) ; nexthdr = * prevhdr ; * prevhdr = NEXTHDR_FRAGMENT ; unfrag_len = skb_network_header ( skb ) - skb_mac_header ( skb ) + unfrag_ip6hlen ; mac_start = skb_mac_header ( skb ) ; memmove ( mac_start - frag_hdr_sz , mac_start , unfrag_len ) ; skb -> mac_header -= frag_hdr_sz ; skb -> network_header -= frag_hdr_sz ; fptr = ( struct frag_hdr * ) ( skb_network_header ( skb ) + unfrag_ip6hlen ) ; fptr -> nexthdr = nexthdr ; fptr -> reserved = 0 ; ipv6_select_ident ( fptr ) ; segs = skb_segment ( skb , features ) ; out : return segs ; } "," if ( ( skb_mac_header ( skb ) skb ) < skb -> head + ",torvalds@linux/a9cf73ea7ff78f52662c8658d93c226effbbedde,CVE-2011-4326,https://github.com/torvalds/linux/commit/a9cf73ea7ff78f52662c8658d93c226effbbedde,2012-05-17T11:00Z 240,CWE-20,"CWE-20 void test_checkout_nasty__git_tilde1 ( void ) { # ifdef GIT_WIN32 test_checkout_fails ( ""refs/heads/git_tilde1"" , "".git/foobar"" ) ; # endif } "," void ) { test_checkout_fails ( ""refs/heads/git_tilde1"" "".git/foobar"" ) ; test_checkout_fails ( ""refs/heads/git_tilde1"" , ""git~1/foobar"" ) ; } ",libgit2@libgit2/64c612cc3e25eff5fb02c59ef5a66ba7a14751e4,CVE-2020-12279,https://github.com/libgit2/libgit2/commit/64c612cc3e25eff5fb02c59ef5a66ba7a14751e4,2020-04-27T17:15Z 241,CWE-119,"CWE-119 int sock_getsockopt ( struct socket * sock , int level , int optname , char __user * optval , int __user * optlen ) { struct sock * sk = sock -> sk ; union { int val ; struct linger ling ; struct timeval tm ; } v ; int lv = sizeof ( int ) ; int len ; if ( get_user ( len , optlen ) ) return - EFAULT ; if ( len < 0 ) return - EINVAL ; memset ( & v , 0 , sizeof ( v ) ) ; switch ( optname ) { case SO_DEBUG : v . val = sock_flag ( sk , SOCK_DBG ) ; break ; case SO_DONTROUTE : v . val = sock_flag ( sk , SOCK_LOCALROUTE ) ; break ; case SO_BROADCAST : v . val = ! ! sock_flag ( sk , SOCK_BROADCAST ) ; break ; case SO_SNDBUF : v . val = sk -> sk_sndbuf ; break ; case SO_RCVBUF : v . val = sk -> sk_rcvbuf ; break ; case SO_REUSEADDR : v . val = sk -> sk_reuse ; break ; case SO_KEEPALIVE : v . val = ! ! sock_flag ( sk , SOCK_KEEPOPEN ) ; break ; case SO_TYPE : v . val = sk -> sk_type ; break ; case SO_PROTOCOL : v . val = sk -> sk_protocol ; break ; case SO_DOMAIN : v . val = sk -> sk_family ; break ; case SO_ERROR : v . val = - sock_error ( sk ) ; if ( v . val == 0 ) v . val = xchg ( & sk -> sk_err_soft , 0 ) ; break ; case SO_OOBINLINE : v . val = ! ! sock_flag ( sk , SOCK_URGINLINE ) ; break ; case SO_NO_CHECK : v . val = sk -> sk_no_check ; break ; case SO_PRIORITY : v . val = sk -> sk_priority ; break ; case SO_LINGER : lv = sizeof ( v . ling ) ; v . ling . l_onoff = ! ! sock_flag ( sk , SOCK_LINGER ) ; v . ling . l_linger = sk -> sk_lingertime / HZ ; break ; case SO_BSDCOMPAT : sock_warn_obsolete_bsdism ( ""getsockopt"" ) ; break ; case SO_TIMESTAMP : v . val = sock_flag ( sk , SOCK_RCVTSTAMP ) && ! sock_flag ( sk , SOCK_RCVTSTAMPNS ) ; break ; case SO_TIMESTAMPNS : v . val = sock_flag ( sk , SOCK_RCVTSTAMPNS ) ; break ; case SO_TIMESTAMPING : v . val = 0 ; if ( sock_flag ( sk , SOCK_TIMESTAMPING_TX_HARDWARE ) ) v . val |= SOF_TIMESTAMPING_TX_HARDWARE ; if ( sock_flag ( sk , SOCK_TIMESTAMPING_TX_SOFTWARE ) ) v . val |= SOF_TIMESTAMPING_TX_SOFTWARE ; if ( sock_flag ( sk , SOCK_TIMESTAMPING_RX_HARDWARE ) ) v . val |= SOF_TIMESTAMPING_RX_HARDWARE ; if ( sock_flag ( sk , SOCK_TIMESTAMPING_RX_SOFTWARE ) ) v . val |= SOF_TIMESTAMPING_RX_SOFTWARE ; if ( sock_flag ( sk , SOCK_TIMESTAMPING_SOFTWARE ) ) v . val |= SOF_TIMESTAMPING_SOFTWARE ; if ( sock_flag ( sk , SOCK_TIMESTAMPING_SYS_HARDWARE ) ) v . val |= SOF_TIMESTAMPING_SYS_HARDWARE ; if ( sock_flag ( sk , SOCK_TIMESTAMPING_RAW_HARDWARE ) ) v . val |= SOF_TIMESTAMPING_RAW_HARDWARE ; break ; case SO_RCVTIMEO : lv = sizeof ( struct timeval ) ; if ( sk -> sk_rcvtimeo == MAX_SCHEDULE_TIMEOUT ) { v . tm . tv_sec = 0 ; v . tm . tv_usec = 0 ; } else { v . tm . tv_sec = sk -> sk_rcvtimeo / HZ ; v . tm . tv_usec = ( ( sk -> sk_rcvtimeo % HZ ) * 1000000 ) / HZ ; } break ; case SO_SNDTIMEO : lv = sizeof ( struct timeval ) ; if ( sk -> sk_sndtimeo == MAX_SCHEDULE_TIMEOUT ) { v . tm . tv_sec = 0 ; v . tm . tv_usec = 0 ; } else { v . tm . tv_sec = sk -> sk_sndtimeo / HZ ; v . tm . tv_usec = ( ( sk -> sk_sndtimeo % HZ ) * 1000000 ) / HZ ; } break ; case SO_RCVLOWAT : v . val = sk -> sk_rcvlowat ; break ; case SO_SNDLOWAT : v . val = 1 ; break ; case SO_PASSCRED : v . val = test_bit ( SOCK_PASSCRED , & sock -> flags ) ? 1 : 0 ; break ; case SO_PEERCRED : { struct ucred peercred ; if ( len > sizeof ( peercred ) ) len = sizeof ( peercred ) ; cred_to_ucred ( sk -> sk_peer_pid , sk -> sk_peer_cred , & peercred ) ; if ( copy_to_user ( optval , & peercred , len ) ) return - EFAULT ; goto lenout ; } case SO_PEERNAME : { char address [ 128 ] ; if ( sock -> ops -> getname ( sock , ( struct sockaddr * ) address , & lv , 2 ) ) return - ENOTCONN ; if ( lv < len ) return - EINVAL ; if ( copy_to_user ( optval , address , len ) ) return - EFAULT ; goto lenout ; } case SO_ACCEPTCONN : v . val = sk -> sk_state == TCP_LISTEN ; break ; case SO_PASSSEC : v . val = test_bit ( SOCK_PASSSEC , & sock -> flags ) ? 1 : 0 ; break ; case SO_PEERSEC : return security_socket_getpeersec_stream ( sock , optval , optlen , len ) ; case SO_MARK : v . val = sk -> sk_mark ; break ; case SO_RXQ_OVFL : v . val = ! ! sock_flag ( sk , SOCK_RXQ_OVFL ) ; break ; case SO_WIFI_STATUS : v . val = ! ! sock_flag ( sk , SOCK_WIFI_STATUS ) ; break ; case SO_PEEK_OFF : if ( ! sock -> ops -> set_peek_off ) return - EOPNOTSUPP ; v . val = sk -> sk_peek_off ; break ; case SO_NOFCS : v . val = ! ! sock_flag ( sk , SOCK_NOFCS ) ; break ; default : return - ENOPROTOOPT ; } if ( len > lv ) len = lv ; if ( copy_to_user ( optval , & v , len ) ) return - EFAULT ; lenout : if ( put_user ( len , optlen ) ) return - EFAULT ; return 0 ; } "," . val = ! ! -> flags ) ; break ; . val = ! ! -> flags ) ; break ; ",torvalds@linux/82981930125abfd39d7c8378a9cfdf5e1be2002b,CVE-2012-6704,https://github.com/torvalds/linux/commit/82981930125abfd39d7c8378a9cfdf5e1be2002b,2016-12-28T07:59Z 242,CWE-20,"CWE-20 int bt_sock_recvmsg ( struct kiocb * iocb , struct socket * sock , struct msghdr * msg , size_t len , int flags ) { int noblock = flags & MSG_DONTWAIT ; struct sock * sk = sock -> sk ; struct sk_buff * skb ; size_t copied ; int err ; BT_DBG ( ""sock%psk%plen%zu"" , sock , sk , len ) ; if ( flags & ( MSG_OOB ) ) return - EOPNOTSUPP ; skb = skb_recv_datagram ( sk , flags , noblock , & err ) ; if ( ! skb ) { if ( sk -> sk_shutdown & RCV_SHUTDOWN ) { msg -> msg_namelen = 0 ; return 0 ; } return err ; } copied = skb -> len ; if ( len < copied ) { msg -> msg_flags |= MSG_TRUNC ; copied = len ; } skb_reset_transport_header ( skb ) ; err = skb_copy_datagram_iovec ( skb , 0 , msg -> msg_iov , copied ) ; if ( err == 0 ) { sock_recv_ts_and_drops ( msg , sk , skb ) ; if ( bt_sk ( sk ) -> skb_msg_name ) bt_sk ( sk ) -> skb_msg_name ( skb , msg -> msg_name , & msg -> msg_namelen ) ; else msg -> msg_namelen = 0 ; } skb_free_datagram ( sk , skb ) ; return err ? : copied ; } "," & RCV_SHUTDOWN ) return 0 ; return err ; msg_namelen ) ; } skb_free_datagram ( ",torvalds@linux/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,CVE-2013-7271,https://github.com/torvalds/linux/commit/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,2014-01-06T16:55Z 243,CWE-119,"CWE-119 SQLWCHAR * _multi_string_alloc_and_expand ( LPCSTR in ) { SQLWCHAR * chr ; int len = 0 ; if ( ! in ) { return in ; } while ( in [ len ] != 0 || in [ len + 1 ] != 0 ) { len ++ ; } chr = malloc ( sizeof ( SQLWCHAR ) * ( len + 2 ) ) ; len = 0 ; while ( in [ len ] != 0 || in [ len + 1 ] != 0 ) { chr [ len ] = in [ len ] ; len ++ ; } chr [ len ++ ] = 0 ; chr [ len ++ ] = 0 ; return chr ; } "," ) { return NULL ; } while ",lurcher@unixODBC/45ef78e037f578b15fc58938a3a3251655e71d6f,CVE-2018-7485,https://github.com/lurcher/unixODBC/commit/45ef78e037f578b15fc58938a3a3251655e71d6f,2018-02-26T14:29Z 244,CWE-119,"CWE-119 void vp9_setup_pre_planes ( MACROBLOCKD * xd , int idx , const YV12_BUFFER_CONFIG * src , int mi_row , int mi_col , const struct scale_factors * sf ) { if ( src != NULL ) { int i ; uint8_t * const buffers [ 4 ] = { src -> y_buffer , src -> u_buffer , src -> v_buffer , src -> alpha_buffer } ; const int strides [ 4 ] = { src -> y_stride , src -> uv_stride , src -> uv_stride , src -> alpha_stride } ; for ( i = 0 ; i < MAX_MB_PLANE ; ++ i ) { struct macroblockd_plane * const pd = & xd -> plane [ i ] ; setup_pred_plane ( & pd -> pre [ idx ] , buffers [ i ] , strides [ i ] , mi_row , mi_col , sf , pd -> subsampling_x , pd -> subsampling_y ) ; } } } "," const buffers [ MAX_MB_PLANE ] = { src -> v_buffer } ; const int strides [ MAX_MB_PLANE ] = { src -> uv_stride } ; for ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 245,CWE-119,"CWE-119 static krb5_error_code get_matching_data ( krb5_context context , pkinit_plg_crypto_context plg_cryptoctx , pkinit_req_crypto_context req_cryptoctx , X509 * cert , pkinit_cert_matching_data * * md_out ) { krb5_error_code ret = ENOMEM ; pkinit_cert_matching_data * md = NULL ; krb5_principal * pkinit_sans = NULL , * upn_sans = NULL ; size_t i , j ; char buf [ DN_BUF_LEN ] ; unsigned int bufsize = sizeof ( buf ) ; * md_out = NULL ; md = calloc ( 1 , sizeof ( * md ) ) ; if ( md == NULL ) goto cleanup ; X509_NAME_oneline_ex ( X509_get_subject_name ( cert ) , buf , & bufsize , XN_FLAG_SEP_COMMA_PLUS ) ; md -> subject_dn = strdup ( buf ) ; if ( md -> subject_dn == NULL ) { ret = ENOMEM ; goto cleanup ; } X509_NAME_oneline_ex ( X509_get_issuer_name ( cert ) , buf , & bufsize , XN_FLAG_SEP_COMMA_PLUS ) ; md -> issuer_dn = strdup ( buf ) ; if ( md -> issuer_dn == NULL ) { ret = ENOMEM ; goto cleanup ; } ret = crypto_retrieve_X509_sans ( context , plg_cryptoctx , req_cryptoctx , cert , & pkinit_sans , & upn_sans , NULL ) ; if ( ret ) goto cleanup ; j = 0 ; if ( pkinit_sans != NULL ) { for ( i = 0 ; pkinit_sans [ i ] != NULL ; i ++ ) j ++ ; } if ( upn_sans != NULL ) { for ( i = 0 ; upn_sans [ i ] != NULL ; i ++ ) j ++ ; } if ( j != 0 ) { md -> sans = calloc ( ( size_t ) j + 1 , sizeof ( * md -> sans ) ) ; if ( md -> sans == NULL ) { ret = ENOMEM ; goto cleanup ; } j = 0 ; if ( pkinit_sans != NULL ) { for ( i = 0 ; pkinit_sans [ i ] != NULL ; i ++ ) md -> sans [ j ++ ] = pkinit_sans [ i ] ; free ( pkinit_sans ) ; } if ( upn_sans != NULL ) { for ( i = 0 ; upn_sans [ i ] != NULL ; i ++ ) md -> sans [ j ++ ] = upn_sans [ i ] ; free ( upn_sans ) ; } md -> sans [ j ] = NULL ; } else md -> sans = NULL ; ret = crypto_retrieve_X509_key_usage ( context , plg_cryptoctx , req_cryptoctx , cert , & md -> ku_bits , & md -> eku_bits ) ; if ( ret ) goto cleanup ; * md_out = md ; md = NULL ; cleanup : crypto_cert_free_matching_data ( context , md ) ; return ret ; } "," , j ; * md_out = NULL ; md = calloc ( 1 , sizeof ( * md ) goto cleanup ; ret = rfc2253_name ( X509_get_subject_name ( cert ) , & md -> subject_dn md -> subject_dn ) ; if ( ret ) goto cleanup ; ret = rfc2253_name ( X509_get_issuer_name ( cert ) , & md -> issuer_dn md -> issuer_dn ) ; if ( ret ) goto cleanup ; ret = crypto_retrieve_X509_sans ",krb5@krb5/fbb687db1088ddd894d975996e5f6a4252b9a2b4,CVE-2017-15088,https://github.com/krb5/krb5/commit/fbb687db1088ddd894d975996e5f6a4252b9a2b4,2017-11-23T17:29Z 246,CWE-399,"CWE-399 int __kvm_set_memory_region ( struct kvm * kvm , struct kvm_userspace_memory_region * mem , int user_alloc ) { int r ; gfn_t base_gfn ; unsigned long npages ; unsigned long i ; struct kvm_memory_slot * memslot ; struct kvm_memory_slot old , new ; struct kvm_memslots * slots , * old_memslots ; r = check_memory_region_flags ( mem ) ; if ( r ) goto out ; r = - EINVAL ; if ( mem -> memory_size & ( PAGE_SIZE - 1 ) ) goto out ; if ( mem -> guest_phys_addr & ( PAGE_SIZE - 1 ) ) goto out ; if ( user_alloc && ( ( mem -> userspace_addr & ( PAGE_SIZE - 1 ) ) || ! access_ok ( VERIFY_WRITE , ( void __user * ) ( unsigned long ) mem -> userspace_addr , mem -> memory_size ) ) ) goto out ; if ( mem -> slot >= KVM_MEM_SLOTS_NUM ) goto out ; if ( mem -> guest_phys_addr + mem -> memory_size < mem -> guest_phys_addr ) goto out ; memslot = id_to_memslot ( kvm -> memslots , mem -> slot ) ; base_gfn = mem -> guest_phys_addr >> PAGE_SHIFT ; npages = mem -> memory_size >> PAGE_SHIFT ; r = - EINVAL ; if ( npages > KVM_MEM_MAX_NR_PAGES ) goto out ; if ( ! npages ) mem -> flags &= ~ KVM_MEM_LOG_DIRTY_PAGES ; new = old = * memslot ; new . id = mem -> slot ; new . base_gfn = base_gfn ; new . npages = npages ; new . flags = mem -> flags ; r = - EINVAL ; if ( npages && old . npages && npages != old . npages ) goto out_free ; r = - EEXIST ; for ( i = 0 ; i < KVM_MEMORY_SLOTS ; ++ i ) { struct kvm_memory_slot * s = & kvm -> memslots -> memslots [ i ] ; if ( s == memslot || ! s -> npages ) continue ; if ( ! ( ( base_gfn + npages <= s -> base_gfn ) || ( base_gfn >= s -> base_gfn + s -> npages ) ) ) goto out_free ; } if ( ! ( new . flags & KVM_MEM_LOG_DIRTY_PAGES ) ) new . dirty_bitmap = NULL ; r = - ENOMEM ; if ( npages && ! old . npages ) { new . user_alloc = user_alloc ; new . userspace_addr = mem -> userspace_addr ; if ( kvm_arch_create_memslot ( & new , npages ) ) goto out_free ; } if ( ( new . flags & KVM_MEM_LOG_DIRTY_PAGES ) && ! new . dirty_bitmap ) { if ( kvm_create_dirty_bitmap ( & new ) < 0 ) goto out_free ; } if ( ! npages ) { struct kvm_memory_slot * slot ; r = - ENOMEM ; slots = kmemdup ( kvm -> memslots , sizeof ( struct kvm_memslots ) , GFP_KERNEL ) ; if ( ! slots ) goto out_free ; slot = id_to_memslot ( slots , mem -> slot ) ; slot -> flags |= KVM_MEMSLOT_INVALID ; update_memslots ( slots , NULL ) ; old_memslots = kvm -> memslots ; rcu_assign_pointer ( kvm -> memslots , slots ) ; synchronize_srcu_expedited ( & kvm -> srcu ) ; kvm_arch_flush_shadow_memslot ( kvm , slot ) ; kfree ( old_memslots ) ; } r = kvm_arch_prepare_memory_region ( kvm , & new , old , mem , user_alloc ) ; if ( r ) goto out_free ; if ( npages ) { r = kvm_iommu_map_pages ( kvm , & new ) ; if ( r ) goto out_free ; } else kvm_iommu_unmap_pages ( kvm , & old ) ; r = - ENOMEM ; slots = kmemdup ( kvm -> memslots , sizeof ( struct kvm_memslots ) , GFP_KERNEL ) ; if ( ! slots ) goto out_free ; if ( ! npages ) { new . dirty_bitmap = NULL ; memset ( & new . arch , 0 , sizeof ( new . arch ) ) ; } update_memslots ( slots , & new ) ; old_memslots = kvm -> memslots ; rcu_assign_pointer ( kvm -> memslots , slots ) ; synchronize_srcu_expedited ( & kvm -> srcu ) ; kvm_arch_commit_memory_region ( kvm , mem , old , user_alloc ) ; if ( npages && old . base_gfn != mem -> guest_phys_addr >> PAGE_SHIFT ) kvm_arch_flush_shadow_all ( kvm ) ; kvm_free_physmem_slot ( & old , & new ) ; kfree ( old_memslots ) ; return 0 ; out_free : kvm_free_physmem_slot ( & new , & old ) ; out : return r ; } "," ( ! npages || base_gfn != old . base_gfn ",torvalds@linux/12d6e7538e2d418c08f082b1b44ffa5fb7270ed8,CVE-2013-4592,https://github.com/torvalds/linux/commit/12d6e7538e2d418c08f082b1b44ffa5fb7270ed8,2013-11-20T13:19Z 247,CWE-200,"CWE-200 SYSCALL_DEFINE5 ( waitid , int , which , pid_t , upid , struct siginfo __user * , infop , int , options , struct rusage __user * , ru ) { struct rusage r ; struct waitid_info info = { . status = 0 } ; long err = kernel_waitid ( which , upid , & info , options , ru ? & r : NULL ) ; int signo = 0 ; if ( err > 0 ) { signo = SIGCHLD ; err = 0 ; } if ( ! err ) { if ( ru && copy_to_user ( ru , & r , sizeof ( struct rusage ) ) ) return - EFAULT ; } if ( ! infop ) return err ; user_access_begin ( ) ; unsafe_put_user ( signo , & infop -> si_signo , Efault ) ; unsafe_put_user ( 0 , & infop -> si_errno , Efault ) ; unsafe_put_user ( info . cause , & infop -> si_code , Efault ) ; unsafe_put_user ( info . pid , & infop -> si_pid , Efault ) ; unsafe_put_user ( info . uid , & infop -> si_uid , Efault ) ; unsafe_put_user ( info . status , & infop -> si_status , Efault ) ; user_access_end ( ) ; return err ; Efault : user_access_end ( ) ; return - EFAULT ; } "," = 0 ; if ( ru ",torvalds@linux/6c85501f2fabcfc4fc6ed976543d252c4eaf4be9,CVE-2017-14954,https://github.com/torvalds/linux/commit/6c85501f2fabcfc4fc6ed976543d252c4eaf4be9,2017-10-02T01:29Z 248,CWE-20,"CWE-20 static int skcipher_recvmsg ( struct kiocb * unused , struct socket * sock , struct msghdr * msg , size_t ignored , int flags ) { struct sock * sk = sock -> sk ; struct alg_sock * ask = alg_sk ( sk ) ; struct skcipher_ctx * ctx = ask -> private ; unsigned bs = crypto_ablkcipher_blocksize ( crypto_ablkcipher_reqtfm ( & ctx -> req ) ) ; struct skcipher_sg_list * sgl ; struct scatterlist * sg ; unsigned long iovlen ; struct iovec * iov ; int err = - EAGAIN ; int used ; long copied = 0 ; lock_sock ( sk ) ; msg -> msg_namelen = 0 ; for ( iov = msg -> msg_iov , iovlen = msg -> msg_iovlen ; iovlen > 0 ; iovlen -- , iov ++ ) { unsigned long seglen = iov -> iov_len ; char __user * from = iov -> iov_base ; while ( seglen ) { sgl = list_first_entry ( & ctx -> tsgl , struct skcipher_sg_list , list ) ; sg = sgl -> sg ; while ( ! sg -> length ) sg ++ ; used = ctx -> used ; if ( ! used ) { err = skcipher_wait_for_data ( sk , flags ) ; if ( err ) goto unlock ; } used = min_t ( unsigned long , used , seglen ) ; used = af_alg_make_sg ( & ctx -> rsgl , from , used , 1 ) ; err = used ; if ( err < 0 ) goto unlock ; if ( ctx -> more || used < ctx -> used ) used -= used % bs ; err = - EINVAL ; if ( ! used ) goto free ; ablkcipher_request_set_crypt ( & ctx -> req , sg , ctx -> rsgl . sg , used , ctx -> iv ) ; err = af_alg_wait_for_completion ( ctx -> enc ? crypto_ablkcipher_encrypt ( & ctx -> req ) : crypto_ablkcipher_decrypt ( & ctx -> req ) , & ctx -> completion ) ; free : af_alg_free_sg ( & ctx -> rsgl ) ; if ( err ) goto unlock ; copied += used ; from += used ; seglen -= used ; skcipher_pull_sgl ( sk , used ) ; } } err = 0 ; unlock : skcipher_wmem_wakeup ( sk ) ; release_sock ( sk ) ; return copied ? : err ; } "," ( sk ) ; for ( ",torvalds@linux/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,CVE-2013-7271,https://github.com/torvalds/linux/commit/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,2014-01-06T16:55Z 249,CWE-125,"CWE-125 void ripng_print ( netdissect_options * ndo , const u_char * dat , unsigned int length ) { register const struct rip6 * rp = ( const struct rip6 * ) dat ; register const struct netinfo6 * ni ; register u_int amt ; register u_int i ; int j ; int trunc ; if ( ndo -> ndo_snapend < dat ) return ; amt = ndo -> ndo_snapend - dat ; i = min ( length , amt ) ; if ( i < ( sizeof ( struct rip6 ) - sizeof ( struct netinfo6 ) ) ) return ; i -= ( sizeof ( struct rip6 ) - sizeof ( struct netinfo6 ) ) ; switch ( rp -> rip6_cmd ) { case RIP6_REQUEST : j = length / sizeof ( * ni ) ; if ( j == 1 && rp -> rip6_nets -> rip6_metric == HOPCNT_INFINITY6 && IN6_IS_ADDR_UNSPECIFIED ( & rp -> rip6_nets -> rip6_dest ) ) { ND_PRINT ( ( ndo , ""ripng-reqdump"" ) ) ; break ; } if ( j * sizeof ( * ni ) != length - 4 ) ND_PRINT ( ( ndo , ""ripng-req%d[%u]:"" , j , length ) ) ; else ND_PRINT ( ( ndo , ""ripng-req%d:"" , j ) ) ; trunc = ( ( i / sizeof ( * ni ) ) * sizeof ( * ni ) != i ) ; for ( ni = rp -> rip6_nets ; i >= sizeof ( * ni ) ; i -= sizeof ( * ni ) , ++ ni ) { if ( ndo -> ndo_vflag > 1 ) ND_PRINT ( ( ndo , ""\\n\\t"" ) ) ; else ND_PRINT ( ( ndo , """" ) ) ; rip6_entry_print ( ndo , ni , 0 ) ; } break ; case RIP6_RESPONSE : j = length / sizeof ( * ni ) ; if ( j * sizeof ( * ni ) != length - 4 ) ND_PRINT ( ( ndo , ""ripng-resp%d[%u]:"" , j , length ) ) ; else ND_PRINT ( ( ndo , ""ripng-resp%d:"" , j ) ) ; trunc = ( ( i / sizeof ( * ni ) ) * sizeof ( * ni ) != i ) ; for ( ni = rp -> rip6_nets ; i >= sizeof ( * ni ) ; i -= sizeof ( * ni ) , ++ ni ) { if ( ndo -> ndo_vflag > 1 ) ND_PRINT ( ( ndo , ""\\n\\t"" ) ) ; else ND_PRINT ( ( ndo , """" ) ) ; rip6_entry_print ( ndo , ni , ni -> rip6_metric ) ; } if ( trunc ) ND_PRINT ( ( ndo , ""[|ripng]"" ) ) ; break ; default : ND_PRINT ( ( ndo , ""ripng-%d??%u"" , rp -> rip6_cmd , length ) ) ; break ; } if ( rp -> rip6_vers != RIP6_VERSION ) ND_PRINT ( ( ndo , ""[vers%d]"" , rp -> rip6_vers ) ) ; } "," * ni ; unsigned int length_left ; u_int j ; ND_TCHECK ( rp -> rip6_cmd ) ; switch case RIP6_REQUEST : length_left = length ; if ( length_left < ( sizeof ( struct rip6 ) - sizeof ( struct netinfo6 ) ) ) goto trunc ; length_left -= ( sizeof ( struct rip6 ) - sizeof ( struct netinfo6 ) ) ; j = length_left / sizeof ( j == 1 ) { ND_TCHECK ( rp -> rip6_nets ) ; if ( rp -> rip6_nets break ; } } ni ) != length_left ) ND_PRINT ( ( ndo , ""ripng-req%u[%u]:"" , j , length ) ) ; ( ndo , ""ripng-req%u:"" , j ) ) ; for -> rip6_nets ; length_left >= sizeof ( ni ) ; length_left -= sizeof ( ni ) { ND_TCHECK ( * ni ) ; ) ; } if ( length_left != 0 ) goto trunc ; case RIP6_RESPONSE : length_left = length ; if ( length_left < ( sizeof ( struct rip6 ) - sizeof ( struct netinfo6 ) ) ) goto trunc ; length_left -= ( sizeof ( struct rip6 ) - sizeof ( struct netinfo6 ) ) ; j = length_left / sizeof ( ni ) != length_left ) ND_PRINT ( ( ndo , ""ripng-resp%d[%u]:"" , j , length ) ) ; ) ) ; for ( ni -> rip6_nets ; length_left >= sizeof ( ni ) ; length_left -= sizeof ( ni ) { ND_TCHECK ( * ni ) ; } if ( length_left != 0 ) goto trunc ; break ; break ; } ND_TCHECK ( rp -> rip6_vers ) ; ) ) ; return ; trunc : ND_PRINT ( ( ndo , ""[|ripng]"" ) ) ; return ; ",the-tcpdump-group@tcpdump/e942fb84fbe3a73a98a00d2a279425872b5fb9d2,CVE-2017-12992,https://github.com/the-tcpdump-group/tcpdump/commit/e942fb84fbe3a73a98a00d2a279425872b5fb9d2,2017-09-14T06:29Z 250,CWE-404,"CWE-404 long keyctl_set_reqkey_keyring ( int reqkey_defl ) { struct cred * new ; int ret , old_setting ; old_setting = current_cred_xxx ( jit_keyring ) ; if ( reqkey_defl == KEY_REQKEY_DEFL_NO_CHANGE ) return old_setting ; new = prepare_creds ( ) ; if ( ! new ) return - ENOMEM ; switch ( reqkey_defl ) { case KEY_REQKEY_DEFL_THREAD_KEYRING : ret = install_thread_keyring_to_cred ( new ) ; if ( ret < 0 ) goto error ; goto set ; case KEY_REQKEY_DEFL_PROCESS_KEYRING : ret = install_process_keyring_to_cred ( new ) ; if ( ret < 0 ) { if ( ret != - EEXIST ) goto error ; ret = 0 ; } goto set ; case KEY_REQKEY_DEFL_DEFAULT : case KEY_REQKEY_DEFL_SESSION_KEYRING : case KEY_REQKEY_DEFL_USER_KEYRING : case KEY_REQKEY_DEFL_USER_SESSION_KEYRING : case KEY_REQKEY_DEFL_REQUESTOR_KEYRING : goto set ; case KEY_REQKEY_DEFL_NO_CHANGE : case KEY_REQKEY_DEFL_GROUP_KEYRING : default : ret = - EINVAL ; goto error ; } set : new -> jit_keyring = reqkey_defl ; commit_creds ( new ) ; return old_setting ; error : abort_creds ( new ) ; return ret ; } "," < 0 ) goto error ; goto set ; ",torvalds@linux/c9f838d104fed6f2f61d68164712e3204bf5271b,CVE-2017-7472,https://github.com/torvalds/linux/commit/c9f838d104fed6f2f61d68164712e3204bf5271b,2017-05-11T19:29Z 251,CWE-119,"CWE-119 static void calc_av_activity ( VP8_COMP * cpi , int64_t activity_sum ) { # if ACT_MEDIAN { unsigned int median ; unsigned int i , j ; unsigned int * sortlist ; unsigned int tmp ; CHECK_MEM_ERROR ( sortlist , vpx_calloc ( sizeof ( unsigned int ) , cpi -> common . MBs ) ) ; vpx_memcpy ( sortlist , cpi -> mb_activity_map , sizeof ( unsigned int ) * cpi -> common . MBs ) ; for ( i = 1 ; i < cpi -> common . MBs ; i ++ ) { for ( j = i ; j > 0 ; j -- ) { if ( sortlist [ j ] < sortlist [ j - 1 ] ) { tmp = sortlist [ j - 1 ] ; sortlist [ j - 1 ] = sortlist [ j ] ; sortlist [ j ] = tmp ; } else break ; } } median = ( 1 + sortlist [ cpi -> common . MBs >> 1 ] + sortlist [ ( cpi -> common . MBs >> 1 ) + 1 ] ) >> 1 ; cpi -> activity_avg = median ; vpx_free ( sortlist ) ; } # else cpi -> activity_avg = ( unsigned int ) ( activity_sum / cpi -> common . MBs ) ; # endif if ( cpi -> activity_avg < VP8_ACTIVITY_AVG_MIN ) cpi -> activity_avg = VP8_ACTIVITY_AVG_MIN ; if ( ALT_ACT_MEASURE ) cpi -> activity_avg = 100000 ; } "," ) ) ; memcpy ( sortlist , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 252,CWE-200,"CWE-200 static int load_misc_binary ( struct linux_binprm * bprm ) { Node * fmt ; struct file * interp_file = NULL ; char iname [ BINPRM_BUF_SIZE ] ; const char * iname_addr = iname ; int retval ; int fd_binary = - 1 ; retval = - ENOEXEC ; if ( ! enabled ) goto _ret ; read_lock ( & entries_lock ) ; fmt = check_file ( bprm ) ; if ( fmt ) strlcpy ( iname , fmt -> interpreter , BINPRM_BUF_SIZE ) ; read_unlock ( & entries_lock ) ; if ( ! fmt ) goto _ret ; if ( ! ( fmt -> flags & MISC_FMT_PRESERVE_ARGV0 ) ) { retval = remove_arg_zero ( bprm ) ; if ( retval ) goto _ret ; } if ( fmt -> flags & MISC_FMT_OPEN_BINARY ) { fd_binary = get_unused_fd ( ) ; if ( fd_binary < 0 ) { retval = fd_binary ; goto _ret ; } fd_install ( fd_binary , bprm -> file ) ; would_dump ( bprm , bprm -> file ) ; allow_write_access ( bprm -> file ) ; bprm -> file = NULL ; bprm -> interp_flags |= BINPRM_FLAGS_EXECFD ; bprm -> interp_data = fd_binary ; } else { allow_write_access ( bprm -> file ) ; fput ( bprm -> file ) ; bprm -> file = NULL ; } retval = copy_strings_kernel ( 1 , & bprm -> interp , bprm ) ; if ( retval < 0 ) goto _error ; bprm -> argc ++ ; retval = copy_strings_kernel ( 1 , & iname_addr , bprm ) ; if ( retval < 0 ) goto _error ; bprm -> argc ++ ; bprm -> interp = iname ; interp_file = open_exec ( iname ) ; retval = PTR_ERR ( interp_file ) ; if ( IS_ERR ( interp_file ) ) goto _error ; bprm -> file = interp_file ; if ( fmt -> flags & MISC_FMT_CREDENTIALS ) { memset ( bprm -> buf , 0 , BINPRM_BUF_SIZE ) ; retval = kernel_read ( bprm -> file , 0 , bprm -> buf , BINPRM_BUF_SIZE ) ; } else retval = prepare_binprm ( bprm ) ; if ( retval < 0 ) goto _error ; retval = search_binary_handler ( bprm ) ; if ( retval < 0 ) goto _error ; _ret : return retval ; _error : if ( fd_binary > 0 ) sys_close ( fd_binary ) ; bprm -> interp_flags = 0 ; bprm -> interp_data = 0 ; goto _ret ; } "," argc ++ ; retval = bprm_change_interp ( iname , bprm ) ; if ( retval < 0 ) goto _error ; interp_file = ",torvalds@linux/b66c5984017533316fd1951770302649baf1aa33,CVE-2012-4530,https://github.com/torvalds/linux/commit/b66c5984017533316fd1951770302649baf1aa33,2013-02-18T04:41Z 253,CWE-125,"CWE-125 static inline LineContribType * _gdContributionsCalc ( unsigned int line_size , unsigned int src_size , double scale_d , const interpolation_method pFilter ) { double width_d ; double scale_f_d = 1.0 ; const double filter_width_d = DEFAULT_BOX_RADIUS ; int windows_size ; unsigned int u ; LineContribType * res ; if ( scale_d < 1.0 ) { width_d = filter_width_d / scale_d ; scale_f_d = scale_d ; } else { width_d = filter_width_d ; } windows_size = 2 * ( int ) ceil ( width_d ) + 1 ; res = _gdContributionsAlloc ( line_size , windows_size ) ; for ( u = 0 ; u < line_size ; u ++ ) { const double dCenter = ( double ) u / scale_d ; register int iLeft = MAX ( 0 , ( int ) floor ( dCenter - width_d ) ) ; int iRight = MIN ( ( int ) ceil ( dCenter + width_d ) , ( int ) src_size - 1 ) ; double dTotalWeight = 0.0 ; int iSrc ; res -> ContribRow [ u ] . Left = iLeft ; res -> ContribRow [ u ] . Right = iRight ; if ( iRight - iLeft + 1 > windows_size ) { if ( iLeft < ( ( int ) src_size - 1 / 2 ) ) { iLeft ++ ; } else { iRight -- ; } } for ( iSrc = iLeft ; iSrc <= iRight ; iSrc ++ ) { dTotalWeight += ( res -> ContribRow [ u ] . Weights [ iSrc - iLeft ] = scale_f_d * ( * pFilter ) ( scale_f_d * ( dCenter - ( double ) iSrc ) ) ) ; } if ( dTotalWeight < 0.0 ) { _gdContributionsFree ( res ) ; return NULL ; } if ( dTotalWeight > 0.0 ) { for ( iSrc = iLeft ; iSrc <= iRight ; iSrc ++ ) { res -> ContribRow [ u ] . Weights [ iSrc - iLeft ] /= dTotalWeight ; } } } return res ; } "," ; int iSrc ; if ( ; } } res -> ContribRow u ] . Left = iLeft ; res -> ContribRow [ u ] . Right = iRight ; for ( iSrc = iLeft ; iSrc <= iRight ; iSrc ++ ) { dTotalWeight += ( res -> ContribRow [ u ] . ",libgd@libgd/4f65a3e4eedaffa1efcf9ee1eb08f0b504fbc31a,CVE-2013-7456,https://github.com/libgd/libgd/commit/4f65a3e4eedaffa1efcf9ee1eb08f0b504fbc31a,2016-08-07T10:59Z 254,CWE-416,"CWE-416 int ipmi_destroy_user ( struct ipmi_user * user ) { _ipmi_destroy_user ( user ) ; cleanup_srcu_struct ( & user -> release_barrier ) ; kref_put ( & user -> refcount , free_user ) ; return 0 ; } "," _ipmi_destroy_user ( user ) ; kref_put ",torvalds@linux/77f8269606bf95fcb232ee86f6da80886f1dfae8,CVE-2019-9003,https://github.com/torvalds/linux/commit/77f8269606bf95fcb232ee86f6da80886f1dfae8,2019-02-22T15:29Z 255,CWE-269,"CWE-269 void Com_WriteConfig_f ( void ) { char filename [ MAX_QPATH ] ; if ( Cmd_Argc ( ) != 2 ) { Com_Printf ( ""Usage:writeconfig\\n"" ) ; return ; } Q_strncpyz ( filename , Cmd_Argv ( 1 ) , sizeof ( filename ) ) ; COM_DefaultExtension ( filename , sizeof ( filename ) , "".cfg"" ) ; Com_Printf ( ""Writing%s.\\n"" , filename ) ; Com_WriteConfigToFile ( filename ) ; } "," Com_Printf ( ""Usage:writeconfig\\n"" ) ; return ; } if ( ! COM_CompareExtension ( filename , "".cfg"" ) ) { Com_Printf ( ""Com_WriteConfig_f:Onlythe\\"".cfg\\""extensionissupportedbythiscommand!\\n"" ",ioquake@ioq3/b173ac05993f634a42be3d3535e1b158de0c3372,CVE-2017-6903,https://github.com/ioquake/ioq3/commit/b173ac05993f634a42be3d3535e1b158de0c3372,2017-03-14T22:59Z 256,CWE-190,"CWE-190 static int mongo_cursor_get_more ( mongo_cursor * cursor ) { int res ; if ( cursor -> limit > 0 && cursor -> seen >= cursor -> limit ) { cursor -> err = MONGO_CURSOR_EXHAUSTED ; return MONGO_ERROR ; } else if ( ! cursor -> reply ) { cursor -> err = MONGO_CURSOR_INVALID ; return MONGO_ERROR ; } else if ( ! cursor -> reply -> fields . cursorID ) { cursor -> err = MONGO_CURSOR_EXHAUSTED ; return MONGO_ERROR ; } else { char * data ; int sl = strlen ( cursor -> ns ) + 1 ; int limit = 0 ; mongo_message * mm ; if ( cursor -> limit > 0 ) limit = cursor -> limit - cursor -> seen ; mm = mongo_message_create ( 16 + 4 + sl + 4 + 8 , 0 , 0 , MONGO_OP_GET_MORE ) ; data = & mm -> data ; data = mongo_data_append32 ( data , & ZERO ) ; data = mongo_data_append ( data , cursor -> ns , sl ) ; data = mongo_data_append32 ( data , & limit ) ; mongo_data_append64 ( data , & cursor -> reply -> fields . cursorID ) ; bson_free ( cursor -> reply ) ; res = mongo_message_send ( cursor -> conn , mm ) ; if ( res != MONGO_OK ) { mongo_cursor_destroy ( cursor ) ; return MONGO_ERROR ; } res = mongo_read_response ( cursor -> conn , & ( cursor -> reply ) ) ; if ( res != MONGO_OK ) { mongo_cursor_destroy ( cursor ) ; return MONGO_ERROR ; } cursor -> current . data = NULL ; cursor -> seen += cursor -> reply -> fields . num ; return MONGO_OK ; } } "," * data ; size_t sl = strlen ",10gen-archive@mongo-c-driver-legacy/1a1f5e26a4309480d88598913f9eebf9e9cba8ca,CVE-2020-12135,https://github.com/10gen-archive/mongo-c-driver-legacy/commit/1a1f5e26a4309480d88598913f9eebf9e9cba8ca,2020-04-24T01:15Z 257,CWE-189,"CWE-189 static struct mobj * alloc_ta_mem ( size_t size ) { # ifdef CFG_PAGED_USER_TA return mobj_paged_alloc ( size ) ; # else struct mobj * mobj = mobj_mm_alloc ( mobj_sec_ddr , size , & tee_mm_sec_ddr ) ; if ( mobj ) memset ( mobj_get_va ( mobj , 0 ) , 0 , size ) ; return mobj ; # endif } "," ( mobj ) { size_t granularity = BIT ( tee_mm_sec_ddr . shift ) ; , 0 , ROUNDUP ( size , granularity ) ) ; } return mobj ; ",OP-TEE@optee_os/7e768f8a473409215fe3fff8f6e31f8a3a0103c6,CVE-2019-1010294,https://github.com/OP-TEE/optee_os/commit/7e768f8a473409215fe3fff8f6e31f8a3a0103c6,2019-07-15T18:15Z 258,CWE-190,"CWE-190 static void bump_cpu_timer ( struct k_itimer * timer , u64 now ) { int i ; u64 delta , incr ; if ( timer -> it . cpu . incr == 0 ) return ; if ( now < timer -> it . cpu . expires ) return ; incr = timer -> it . cpu . incr ; delta = now + incr - timer -> it . cpu . expires ; for ( i = 0 ; incr < delta - incr ; i ++ ) incr = incr << 1 ; for ( ; i >= 0 ; incr >>= 1 , i -- ) { if ( delta < incr ) continue ; timer -> it . cpu . expires += incr ; timer -> it_overrun += 1 << i ; delta -= incr ; } } "," -> it_overrun += 1LL << i ; ",torvalds@linux/78c9c4dfbf8c04883941445a195276bb4bb92c76,CVE-2018-12896,https://github.com/torvalds/linux/commit/78c9c4dfbf8c04883941445a195276bb4bb92c76,2018-07-02T17:29Z 259,CWE-125,"CWE-125 static asdl_seq * ast_for_comprehension ( struct compiling * c , const node * n ) { int i , n_fors ; asdl_seq * comps ; n_fors = count_comp_fors ( c , n ) ; if ( n_fors == - 1 ) return NULL ; comps = _Ta3_asdl_seq_new ( n_fors , c -> c_arena ) ; if ( ! comps ) return NULL ; for ( i = 0 ; i < n_fors ; i ++ ) { comprehension_ty comp ; asdl_seq * t ; expr_ty expression , first ; node * for_ch ; int is_async = 0 ; REQ ( n , comp_for ) ; if ( TYPE ( CHILD ( n , 0 ) ) == ASYNC ) { is_async = 1 ; } if ( is_async && c -> c_feature_version < 6 ) { ast_error ( c , n , ""AsynccomprehensionsareonlysupportedinPython3.6andgreater"" ) ; return NULL ; } for_ch = CHILD ( n , 1 + is_async ) ; t = ast_for_exprlist ( c , for_ch , Store ) ; if ( ! t ) return NULL ; expression = ast_for_expr ( c , CHILD ( n , 3 + is_async ) ) ; if ( ! expression ) return NULL ; first = ( expr_ty ) asdl_seq_GET ( t , 0 ) ; if ( NCH ( for_ch ) == 1 ) comp = comprehension ( first , expression , NULL , is_async , c -> c_arena ) ; else comp = comprehension ( Tuple ( t , Store , first -> lineno , first -> col_offset , c -> c_arena ) , expression , NULL , is_async , c -> c_arena ) ; if ( ! comp ) return NULL ; if ( NCH ( n ) == ( 5 + is_async ) ) { int j , n_ifs ; asdl_seq * ifs ; n = CHILD ( n , 4 + is_async ) ; n_ifs = count_comp_ifs ( c , n ) ; if ( n_ifs == - 1 ) return NULL ; ifs = _Ta3_asdl_seq_new ( n_ifs , c -> c_arena ) ; if ( ! ifs ) return NULL ; for ( j = 0 ; j < n_ifs ; j ++ ) { REQ ( n , comp_iter ) ; n = CHILD ( n , 0 ) ; REQ ( n , comp_if ) ; expression = ast_for_expr ( c , CHILD ( n , 1 ) ) ; if ( ! expression ) return NULL ; asdl_seq_SET ( ifs , j , expression ) ; if ( NCH ( n ) == 3 ) n = CHILD ( n , 2 ) ; } if ( TYPE ( n ) == comp_iter ) n = CHILD ( n , 0 ) ; comp -> ifs = ifs ; } asdl_seq_SET ( comps , i , comp ) ; } return comps ; } "," * for_ch ; node * sync_n ; ; if ( NCH ( n ) == 2 ) { is_async = 1 ; REQ ( CHILD ( n , 0 ) , NAME ) ; assert ( strcmp ( STR ( CHILD ( n , 0 ) ) , ""async"" ) == 0 ) ; sync_n = CHILD ( n , 1 ) ; } else { sync_n = CHILD ( n , 0 ) ; } REQ ( sync_n , sync_comp_for ) ; if ( is_async = CHILD ( sync_n , 1 ) ; t , CHILD ( sync_n , 3 ) ) ; ( NCH ( sync_n ) == 5 ) { int = CHILD ( sync_n , 4 ) ; n_ifs ",python@typed_ast/156afcb26c198e162504a57caddfe0acd9ed7dce,CVE-2019-19275,https://github.com/python/typed_ast/commit/156afcb26c198e162504a57caddfe0acd9ed7dce,2019-11-26T15:15Z 260,CWE-189,"CWE-189 static int copy_verifier_state ( struct bpf_verifier_state * dst_state , const struct bpf_verifier_state * src ) { struct bpf_func_state * dst ; int i , err ; for ( i = src -> curframe + 1 ; i <= dst_state -> curframe ; i ++ ) { free_func_state ( dst_state -> frame [ i ] ) ; dst_state -> frame [ i ] = NULL ; } dst_state -> curframe = src -> curframe ; for ( i = 0 ; i <= src -> curframe ; i ++ ) { dst = dst_state -> frame [ i ] ; if ( ! dst ) { dst = kzalloc ( sizeof ( * dst ) , GFP_KERNEL ) ; if ( ! dst ) return - ENOMEM ; dst_state -> frame [ i ] = dst ; } err = copy_func_state ( dst , src -> frame [ i ] ) ; if ( err ) return err ; } return 0 ; } "," NULL ; } dst_state -> speculative = src -> speculative ; ",torvalds@linux/979d63d50c0c0f7bc537bf821e056cc9fe5abd38,CVE-2019-7308,https://github.com/torvalds/linux/commit/979d63d50c0c0f7bc537bf821e056cc9fe5abd38,2019-02-01T22:29Z 261,CWE-119,"CWE-119 static void write_mb_modes_kf ( const VP9_COMP * cpi , MODE_INFO * * mi_8x8 , vp9_writer * w ) { const VP9_COMMON * const cm = & cpi -> common ; const MACROBLOCKD * const xd = & cpi -> mb . e_mbd ; const struct segmentation * const seg = & cm -> seg ; const MODE_INFO * const mi = mi_8x8 [ 0 ] ; const MODE_INFO * const above_mi = mi_8x8 [ - xd -> mi_stride ] ; const MODE_INFO * const left_mi = xd -> left_available ? mi_8x8 [ - 1 ] : NULL ; const MB_MODE_INFO * const mbmi = & mi -> mbmi ; const BLOCK_SIZE bsize = mbmi -> sb_type ; if ( seg -> update_map ) write_segment_id ( w , seg , mbmi -> segment_id ) ; write_skip ( cpi , mbmi -> segment_id , mi , w ) ; if ( bsize >= BLOCK_8X8 && cm -> tx_mode == TX_MODE_SELECT ) write_selected_tx_size ( cpi , mbmi -> tx_size , bsize , w ) ; if ( bsize >= BLOCK_8X8 ) { write_intra_mode ( w , mbmi -> mode , get_y_mode_probs ( mi , above_mi , left_mi , 0 ) ) ; } else { const int num_4x4_w = num_4x4_blocks_wide_lookup [ bsize ] ; const int num_4x4_h = num_4x4_blocks_high_lookup [ bsize ] ; int idx , idy ; for ( idy = 0 ; idy < 2 ; idy += num_4x4_h ) { for ( idx = 0 ; idx < 2 ; idx += num_4x4_w ) { const int block = idy * 2 + idx ; write_intra_mode ( w , mi -> bmi [ block ] . as_mode , get_y_mode_probs ( mi , above_mi , left_mi , block ) ) ; } } } write_intra_mode ( w , mbmi -> uv_mode , vp9_kf_uv_mode_prob [ mbmi -> mode ] ) ; } "," write_mb_modes_kf ( const VP9_COMMON * cm , const MACROBLOCKD * xd , MODE_INFO * * * mi_8x8 , vpx_writer * w ) { const struct segmentation const above_mi = xd -> above_mi ; const MODE_INFO = xd -> left_mi ; const MB_MODE_INFO ; write_skip ( cm , xd , mbmi -> ) write_selected_tx_size ( cm , xd , w ) ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 262,CWE-284,"CWE-284 int socket_create ( uint16_t port ) { int sfd = - 1 ; int yes = 1 ; # ifdef WIN32 WSADATA wsa_data ; if ( ! wsa_init ) { if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsa_data ) != ERROR_SUCCESS ) { fprintf ( stderr , ""WSAStartupfailed!\\n"" ) ; ExitProcess ( - 1 ) ; } wsa_init = 1 ; } # endif struct sockaddr_in saddr ; if ( 0 > ( sfd = socket ( PF_INET , SOCK_STREAM , IPPROTO_TCP ) ) ) { perror ( ""socket()"" ) ; return - 1 ; } if ( setsockopt ( sfd , SOL_SOCKET , SO_REUSEADDR , ( void * ) & yes , sizeof ( int ) ) == - 1 ) { perror ( ""setsockopt()"" ) ; socket_close ( sfd ) ; return - 1 ; } memset ( ( void * ) & saddr , 0 , sizeof ( saddr ) ) ; saddr . sin_family = AF_INET ; saddr . sin_addr . s_addr = htonl ( INADDR_ANY ) ; saddr . sin_port = htons ( port ) ; if ( 0 > bind ( sfd , ( struct sockaddr * ) & saddr , sizeof ( saddr ) ) ) { perror ( ""bind()"" ) ; socket_close ( sfd ) ; return - 1 ; } if ( listen ( sfd , 1 ) == - 1 ) { perror ( ""listen()"" ) ; socket_close ( sfd ) ; return - 1 ; } return sfd ; } "," = htonl ( INADDR_LOOPBACK ) ; saddr ",libimobiledevice@libimobiledevice/df1f5c4d70d0c19ad40072f5246ca457e7f9849e,CVE-2016-5104,https://github.com/libimobiledevice/libimobiledevice/commit/df1f5c4d70d0c19ad40072f5246ca457e7f9849e,2016-06-13T14:59Z 263,CWE-119,"CWE-119 static void scsi_read_complete ( void * opaque , int ret ) { SCSIDiskReq * r = ( SCSIDiskReq * ) opaque ; SCSIDiskState * s = DO_UPCAST ( SCSIDiskState , qdev , r -> req . dev ) ; int n ; if ( r -> req . aiocb != NULL ) { r -> req . aiocb = NULL ; bdrv_acct_done ( s -> bs , & r -> acct ) ; } if ( ret ) { if ( scsi_handle_rw_error ( r , - ret , SCSI_REQ_STATUS_RETRY_READ ) ) { return ; } } DPRINTF ( ""Datareadytag=0x%xlen=%zd\\n"" , r -> req . tag , r -> iov . iov_len ) ; n = r -> iov . iov_len / 512 ; r -> sector += n ; r -> sector_count -= n ; scsi_req_data ( & r -> req , r -> iov . iov_len ) ; } "," , r -> qiov . size ) ; n = r -> qiov . size / 512 ; , r -> qiov . size ) ; } ",bonzini@qemu/103b40f51e4012b3b0ad20f615562a1806d7f49a,CVE-2011-3346,https://github.com/bonzini/qemu/commit/103b40f51e4012b3b0ad20f615562a1806d7f49a,2014-04-01T06:35Z 264,CWE-119,"CWE-119 static int cqspi_setup_flash ( struct cqspi_st * cqspi , struct device_node * np ) { struct platform_device * pdev = cqspi -> pdev ; struct device * dev = & pdev -> dev ; struct cqspi_flash_pdata * f_pdata ; struct spi_nor * nor ; struct mtd_info * mtd ; unsigned int cs ; int i , ret ; for_each_available_child_of_node ( dev -> of_node , np ) { if ( of_property_read_u32 ( np , ""reg"" , & cs ) ) { dev_err ( dev , ""Couldn\'tdeterminechipselect.\\n"" ) ; goto err ; } if ( cs > CQSPI_MAX_CHIPSELECT ) { dev_err ( dev , ""Chipselect%doutofrange.\\n"" , cs ) ; goto err ; } f_pdata = & cqspi -> f_pdata [ cs ] ; f_pdata -> cqspi = cqspi ; f_pdata -> cs = cs ; ret = cqspi_of_get_flash_pdata ( pdev , f_pdata , np ) ; if ( ret ) goto err ; nor = & f_pdata -> nor ; mtd = & nor -> mtd ; mtd -> priv = nor ; nor -> dev = dev ; spi_nor_set_flash_node ( nor , np ) ; nor -> priv = f_pdata ; nor -> read_reg = cqspi_read_reg ; nor -> write_reg = cqspi_write_reg ; nor -> read = cqspi_read ; nor -> write = cqspi_write ; nor -> erase = cqspi_erase ; nor -> prepare = cqspi_prep ; nor -> unprepare = cqspi_unprep ; mtd -> name = devm_kasprintf ( dev , GFP_KERNEL , ""%s.%d"" , dev_name ( dev ) , cs ) ; if ( ! mtd -> name ) { ret = - ENOMEM ; goto err ; } ret = spi_nor_scan ( nor , NULL , SPI_NOR_QUAD ) ; if ( ret ) goto err ; ret = mtd_device_register ( mtd , NULL , 0 ) ; if ( ret ) goto err ; f_pdata -> registered = true ; } return 0 ; err : for ( i = 0 ; i < CQSPI_MAX_CHIPSELECT ; i ++ ) if ( cqspi -> f_pdata [ i ] . registered ) mtd_device_unregister ( & cqspi -> f_pdata [ i ] . nor . mtd ) ; return ret ; } "," if ( cs >= CQSPI_MAX_CHIPSELECT ) { ",torvalds@linux/193e87143c290ec16838f5368adc0e0bc94eb931,CVE-2016-10764,https://github.com/torvalds/linux/commit/193e87143c290ec16838f5368adc0e0bc94eb931,2019-07-27T22:15Z 265,CWE-119,"CWE-119 int decompileAction ( int n , SWF_ACTION * actions , int maxn ) { if ( n > maxn ) SWF_error ( ""Actionoverflow!!"" ) ; # ifdef DEBUG fprintf ( stderr , ""%d:\\tACTION[%3.3d]:%s\\n"" , actions [ n ] . SWF_ACTIONRECORD . Offset , n , actionName ( actions [ n ] . SWF_ACTIONRECORD . ActionCode ) ) ; # endif switch ( actions [ n ] . SWF_ACTIONRECORD . ActionCode ) { case SWFACTION_END : return 0 ; case SWFACTION_CONSTANTPOOL : decompileCONSTANTPOOL ( & actions [ n ] ) ; return 0 ; case SWFACTION_GOTOLABEL : return decompileGOTOFRAME ( n , actions , maxn , 1 ) ; case SWFACTION_GOTOFRAME : return decompileGOTOFRAME ( n , actions , maxn , 0 ) ; case SWFACTION_GOTOFRAME2 : return decompileGOTOFRAME2 ( n , actions , maxn ) ; case SWFACTION_WAITFORFRAME : decompileWAITFORFRAME ( & actions [ n ] ) ; return 0 ; case SWFACTION_GETURL2 : decompileGETURL2 ( & actions [ n ] ) ; return 0 ; case SWFACTION_GETURL : decompileGETURL ( & actions [ n ] ) ; return 0 ; case SWFACTION_PUSH : decompilePUSH ( & actions [ n ] ) ; return 0 ; case SWFACTION_PUSHDUP : decompilePUSHDUP ( & actions [ n ] ) ; return 0 ; case SWFACTION_STACKSWAP : decompileSTACKSWAP ( & actions [ n ] ) ; return 0 ; case SWFACTION_SETPROPERTY : decompileSETPROPERTY ( n , actions , maxn ) ; return 0 ; case SWFACTION_GETPROPERTY : decompileGETPROPERTY ( n , actions , maxn ) ; return 0 ; case SWFACTION_GETTIME : return decompileGETTIME ( n , actions , maxn ) ; case SWFACTION_TRACE : decompileTRACE ( n , actions , maxn ) ; return 0 ; case SWFACTION_CALLFRAME : decompileCALLFRAME ( n , actions , maxn ) ; return 0 ; case SWFACTION_EXTENDS : decompileEXTENDS ( n , actions , maxn ) ; return 0 ; case SWFACTION_INITOBJECT : decompileINITOBJECT ( n , actions , maxn ) ; return 0 ; case SWFACTION_NEWOBJECT : decompileNEWOBJECT ( n , actions , maxn ) ; return 0 ; case SWFACTION_NEWMETHOD : decompileNEWMETHOD ( n , actions , maxn ) ; return 0 ; case SWFACTION_GETMEMBER : decompileGETMEMBER ( n , actions , maxn ) ; return 0 ; case SWFACTION_SETMEMBER : decompileSETMEMBER ( n , actions , maxn ) ; return 0 ; case SWFACTION_GETVARIABLE : decompileGETVARIABLE ( n , actions , maxn ) ; return 0 ; case SWFACTION_SETVARIABLE : decompileSETVARIABLE ( n , actions , maxn , 0 ) ; return 0 ; case SWFACTION_DEFINELOCAL : decompileSETVARIABLE ( n , actions , maxn , 1 ) ; return 0 ; case SWFACTION_DEFINELOCAL2 : decompileDEFINELOCAL2 ( n , actions , maxn ) ; return 0 ; case SWFACTION_DECREMENT : return decompileINCR_DECR ( n , actions , maxn , 0 ) ; case SWFACTION_INCREMENT : return decompileINCR_DECR ( n , actions , maxn , 1 ) ; case SWFACTION_STOREREGISTER : decompileSTOREREGISTER ( n , actions , maxn ) ; return 0 ; case SWFACTION_JUMP : return decompileJUMP ( n , actions , maxn ) ; case SWFACTION_RETURN : decompileRETURN ( n , actions , maxn ) ; return 0 ; case SWFACTION_LOGICALNOT : return decompileLogicalNot ( n , actions , maxn ) ; case SWFACTION_IF : return decompileIF ( n , actions , maxn ) ; case SWFACTION_WITH : decompileWITH ( n , actions , maxn ) ; return 0 ; case SWFACTION_ENUMERATE : return decompileENUMERATE ( n , actions , maxn , 0 ) ; case SWFACTION_ENUMERATE2 : return decompileENUMERATE ( n , actions , maxn , 1 ) ; case SWFACTION_INITARRAY : return decompileINITARRAY ( n , actions , maxn ) ; case SWFACTION_DEFINEFUNCTION : return decompileDEFINEFUNCTION ( n , actions , maxn , 0 ) ; case SWFACTION_DEFINEFUNCTION2 : return decompileDEFINEFUNCTION ( n , actions , maxn , 1 ) ; case SWFACTION_CALLFUNCTION : return decompileCALLFUNCTION ( n , actions , maxn ) ; case SWFACTION_CALLMETHOD : return decompileCALLMETHOD ( n , actions , maxn ) ; case SWFACTION_INSTANCEOF : case SWFACTION_SHIFTLEFT : case SWFACTION_SHIFTRIGHT : case SWFACTION_SHIFTRIGHT2 : case SWFACTION_ADD : case SWFACTION_ADD2 : case SWFACTION_SUBTRACT : case SWFACTION_MULTIPLY : case SWFACTION_DIVIDE : case SWFACTION_MODULO : case SWFACTION_BITWISEAND : case SWFACTION_BITWISEOR : case SWFACTION_BITWISEXOR : case SWFACTION_EQUAL : case SWFACTION_EQUALS2 : case SWFACTION_LESS2 : case SWFACTION_LOGICALAND : case SWFACTION_LOGICALOR : case SWFACTION_GREATER : case SWFACTION_LESSTHAN : case SWFACTION_STRINGEQ : case SWFACTION_STRINGCOMPARE : case SWFACTION_STRICTEQUALS : return decompileArithmeticOp ( n , actions , maxn ) ; case SWFACTION_POP : pop ( ) ; return 0 ; case SWFACTION_STARTDRAG : return decompileSTARTDRAG ( n , actions , maxn ) ; case SWFACTION_DELETE : return decompileDELETE ( n , actions , maxn , 0 ) ; case SWFACTION_DELETE2 : return decompileDELETE ( n , actions , maxn , 1 ) ; case SWFACTION_TARGETPATH : return decompileSingleArgBuiltInFunctionCall ( n , actions , maxn , ""targetPath"" ) ; case SWFACTION_TYPEOF : return decompileSingleArgBuiltInFunctionCall ( n , actions , maxn , ""typeof"" ) ; case SWFACTION_ORD : return decompileSingleArgBuiltInFunctionCall ( n , actions , maxn , ""ord"" ) ; case SWFACTION_CHR : return decompileSingleArgBuiltInFunctionCall ( n , actions , maxn , ""chr"" ) ; case SWFACTION_INT : return decompileSingleArgBuiltInFunctionCall ( n , actions , maxn , ""int"" ) ; case SWFACTION_TOSTRING : return decompileSingleArgBuiltInFunctionCall ( n , actions , maxn , ""String"" ) ; case SWFACTION_TONUMBER : return decompileSingleArgBuiltInFunctionCall ( n , actions , maxn , ""Number"" ) ; case SWFACTION_RANDOMNUMBER : return decompileSingleArgBuiltInFunctionCall ( n , actions , maxn , ""random"" ) ; case SWFACTION_STRINGLENGTH : return decompileSingleArgBuiltInFunctionCall ( n , actions , maxn , ""length"" ) ; case SWFACTION_PLAY : return decompile_Null_ArgBuiltInFunctionCall ( n , actions , maxn , ""play"" ) ; case SWFACTION_STOP : return decompile_Null_ArgBuiltInFunctionCall ( n , actions , maxn , ""stop"" ) ; case SWFACTION_NEXTFRAME : return decompile_Null_ArgBuiltInFunctionCall ( n , actions , maxn , ""nextFrame"" ) ; case SWFACTION_PREVFRAME : return decompile_Null_ArgBuiltInFunctionCall ( n , actions , maxn , ""prevFrame"" ) ; case SWFACTION_ENDDRAG : return decompile_Null_ArgBuiltInFunctionCall ( n , actions , maxn , ""stopDrag"" ) ; case SWFACTION_STOPSOUNDS : return decompile_Null_ArgBuiltInFunctionCall ( n , actions , maxn , ""stopAllSounds"" ) ; case SWFACTION_TOGGLEQUALITY : return decompile_Null_ArgBuiltInFunctionCall ( n , actions , maxn , ""toggleHighQuality"" ) ; case SWFACTION_MBSUBSTRING : case SWFACTION_SUBSTRING : return decompileSUBSTRING ( n , actions , maxn ) ; case SWFACTION_STRINGCONCAT : return decompileSTRINGCONCAT ( n , actions , maxn ) ; case SWFACTION_REMOVECLIP : return decompileREMOVECLIP ( n , actions , maxn ) ; case SWFACTION_DUPLICATECLIP : return decompileDUPLICATECLIP ( n , actions , maxn ) ; case SWFACTION_SETTARGET : return decompileSETTARGET ( n , actions , maxn , 0 ) ; case SWFACTION_SETTARGET2 : return decompileSETTARGET ( n , actions , maxn , 1 ) ; case SWFACTION_IMPLEMENTSOP : return decompileIMPLEMENTS ( n , actions , maxn ) ; case SWFACTION_CASTOP : return decompileCAST ( n , actions , maxn ) ; case SWFACTION_THROW : return decompileTHROW ( n , actions , maxn ) ; case SWFACTION_TRY : return decompileTRY ( n , actions , maxn ) ; default : outputSWF_ACTION ( n , & actions [ n ] ) ; return 0 ; } } "," maxn ) { # ifdef DEBUG endif switch ( OpCode ( actions , n , maxn ) ) { case ",libming@libming/da9d86eab55cbf608d5c916b8b690f5b76bca462,CVE-2019-12982,https://github.com/libming/libming/commit/da9d86eab55cbf608d5c916b8b690f5b76bca462,2019-06-26T18:15Z 266,CWE-119,"CWE-119 static enum fetch_step vbf_stp_error ( struct worker * wrk , struct busyobj * bo ) { ssize_t l , ll , o ; double now ; uint8_t * ptr ; struct vsb * synth_body ; CHECK_OBJ_NOTNULL ( wrk , WORKER_MAGIC ) ; CHECK_OBJ_NOTNULL ( bo , BUSYOBJ_MAGIC ) ; CHECK_OBJ_NOTNULL ( bo -> fetch_objcore , OBJCORE_MAGIC ) ; AN ( bo -> fetch_objcore -> flags & OC_F_BUSY ) ; assert ( bo -> director_state == DIR_S_NULL ) ; wrk -> stats -> fetch_failed ++ ; now = W_TIM_real ( wrk ) ; VSLb_ts_busyobj ( bo , ""Error"" , now ) ; if ( bo -> fetch_objcore -> stobj -> stevedore != NULL ) ObjFreeObj ( bo -> wrk , bo -> fetch_objcore ) ; HTTP_Setup ( bo -> beresp , bo -> ws , bo -> vsl , SLT_BerespMethod ) ; http_PutResponse ( bo -> beresp , ""HTTP/1.1"" , 503 , ""Backendfetchfailed"" ) ; http_TimeHeader ( bo -> beresp , ""Date:"" , now ) ; http_SetHeader ( bo -> beresp , ""Server:Varnish"" ) ; bo -> fetch_objcore -> t_origin = now ; if ( ! VTAILQ_EMPTY ( & bo -> fetch_objcore -> objhead -> waitinglist ) ) { bo -> fetch_objcore -> ttl = 1 ; bo -> fetch_objcore -> grace = 5 ; bo -> fetch_objcore -> keep = 5 ; } else { bo -> fetch_objcore -> ttl = 0 ; bo -> fetch_objcore -> grace = 0 ; bo -> fetch_objcore -> keep = 0 ; } synth_body = VSB_new_auto ( ) ; AN ( synth_body ) ; VCL_backend_error_method ( bo -> vcl , wrk , NULL , bo , synth_body ) ; AZ ( VSB_finish ( synth_body ) ) ; if ( wrk -> handling == VCL_RET_ABANDON || wrk -> handling == VCL_RET_FAIL ) { VSB_destroy ( & synth_body ) ; return ( F_STP_FAIL ) ; } if ( wrk -> handling == VCL_RET_RETRY ) { VSB_destroy ( & synth_body ) ; if ( bo -> retries ++ < cache_param -> max_retries ) return ( F_STP_RETRY ) ; VSLb ( bo -> vsl , SLT_VCL_Error , ""Toomanyretries,failing"" ) ; return ( F_STP_FAIL ) ; } assert ( wrk -> handling == VCL_RET_DELIVER ) ; bo -> vfc -> bo = bo ; bo -> vfc -> wrk = bo -> wrk ; bo -> vfc -> oc = bo -> fetch_objcore ; bo -> vfc -> http = bo -> beresp ; bo -> vfc -> esi_req = bo -> bereq ; if ( vbf_beresp2obj ( bo ) ) { ( void ) VFP_Error ( bo -> vfc , ""Couldnotgetstorage"" ) ; VSB_destroy ( & synth_body ) ; return ( F_STP_FAIL ) ; } ll = VSB_len ( synth_body ) ; o = 0 ; while ( ll > 0 ) { l = ll ; if ( VFP_GetStorage ( bo -> vfc , & l , & ptr ) != VFP_OK ) break ; memcpy ( ptr , VSB_data ( synth_body ) + o , l ) ; VFP_Extend ( bo -> vfc , l ) ; ll -= l ; o += l ; } AZ ( ObjSetU64 ( wrk , bo -> fetch_objcore , OA_LEN , o ) ) ; VSB_destroy ( & synth_body ) ; HSH_Unbusy ( wrk , bo -> fetch_objcore ) ; ObjSetState ( wrk , bo -> fetch_objcore , BOS_FINISHED ) ; return ( F_STP_DONE ) ; } "," ) break ; if ( l > ll ) l = ll ; ",varnishcache@varnish-cache/176f8a075a963ffbfa56f1c460c15f6a1a6af5a7,CVE-2017-8807,https://github.com/varnishcache/varnish-cache/commit/176f8a075a963ffbfa56f1c460c15f6a1a6af5a7,2017-11-16T02:29Z 267,CWE-119,"CWE-119 int mlx4_register_vlan ( struct mlx4_dev * dev , u8 port , u16 vlan , int * index ) { struct mlx4_vlan_table * table = & mlx4_priv ( dev ) -> port [ port ] . vlan_table ; int i , err = 0 ; int free = - 1 ; mutex_lock ( & table -> mutex ) ; for ( i = MLX4_VLAN_REGULAR ; i < MLX4_MAX_VLAN_NUM ; i ++ ) { if ( free < 0 && ( table -> refs [ i ] == 0 ) ) { free = i ; continue ; } if ( table -> refs [ i ] && ( vlan == ( MLX4_VLAN_MASK & be32_to_cpu ( table -> entries [ i ] ) ) ) ) { * index = i ; ++ table -> refs [ i ] ; goto out ; } } if ( table -> total == table -> max ) { err = - ENOSPC ; goto out ; } table -> refs [ free ] = 1 ; table -> entries [ free ] = cpu_to_be32 ( vlan | MLX4_VLAN_VALID ) ; err = mlx4_set_port_vlan_table ( dev , port , table -> entries ) ; if ( unlikely ( err ) ) { mlx4_warn ( dev , ""Failedaddingvlan:%u\\n"" , vlan ) ; table -> refs [ free ] = 0 ; table -> entries [ free ] = 0 ; goto out ; } * index = free ; ++ table -> total ; out : mutex_unlock ( & table -> mutex ) ; return err ; } "," out ; } } if ( free < 0 ) { err = - ENOMEM ; goto out ; ",torvalds@linux/0926f91083f34d047abc74f1ca4fa6a9c161f7db,CVE-2010-5332,https://github.com/torvalds/linux/commit/0926f91083f34d047abc74f1ca4fa6a9c161f7db,2019-07-27T22:15Z 268,CWE-125,"CWE-125 static int wb_prep ( netdissect_options * ndo , const struct pkt_prep * prep , u_int len ) { int n ; const struct pgstate * ps ; const u_char * ep = ndo -> ndo_snapend ; ND_PRINT ( ( ndo , ""wb-prep:"" ) ) ; if ( len < sizeof ( * prep ) ) { return ( - 1 ) ; } n = EXTRACT_32BITS ( & prep -> pp_n ) ; ps = ( const struct pgstate * ) ( prep + 1 ) ; while ( -- n >= 0 && ND_TTEST ( * ps ) ) { const struct id_off * io , * ie ; char c = '<' ; ND_PRINT ( ( ndo , ""%u/%s:%u"" , EXTRACT_32BITS ( & ps -> slot ) , ipaddr_string ( ndo , & ps -> page . p_sid ) , EXTRACT_32BITS ( & ps -> page . p_uid ) ) ) ; io = ( const struct id_off * ) ( ps + 1 ) ; for ( ie = io + ps -> nid ; io < ie && ND_TTEST ( * io ) ; ++ io ) { ND_PRINT ( ( ndo , ""%c%s:%u"" , c , ipaddr_string ( ndo , & io -> id ) , EXTRACT_32BITS ( & io -> off ) ) ) ; c = ',' ; } ND_PRINT ( ( ndo , "">"" ) ) ; ps = ( const struct pgstate * ) io ; } return ( ( const u_char * ) ps <= ep ? 0 : - 1 ) ; } "," * prep ) || ! ND_TTEST ( * prep ) ) return ( - 1 ) ; n = EXTRACT_32BITS ",the-tcpdump-group@tcpdump/cc356512f512e7fa423b3674db4bb31dbe40ffec,CVE-2017-13014,https://github.com/the-tcpdump-group/tcpdump/commit/cc356512f512e7fa423b3674db4bb31dbe40ffec,2017-09-14T06:29Z 269,CWE-835,"CWE-835 static void put_prev_task ( struct rq * rq , struct task_struct * prev ) { if ( prev -> se . on_rq ) update_rq_clock ( rq ) ; rq -> skip_clock_update = 0 ; prev -> sched_class -> put_prev_task ( rq , prev ) ; } "," rq ) ; prev -> sched_class ",torvalds@linux/f26f9aff6aaf67e9a430d16c266f91b13a5bff64,CVE-2011-4621,https://github.com/torvalds/linux/commit/f26f9aff6aaf67e9a430d16c266f91b13a5bff64,2012-05-17T11:00Z 270,CWE-119,"CWE-119 static int atusb_read_reg ( struct atusb * atusb , uint8_t reg ) { struct usb_device * usb_dev = atusb -> usb_dev ; int ret ; uint8_t value ; dev_dbg ( & usb_dev -> dev , ""atusb:reg=0x%x\\n"" , reg ) ; ret = atusb_control_msg ( atusb , usb_rcvctrlpipe ( usb_dev , 0 ) , ATUSB_REG_READ , ATUSB_REQ_FROM_DEV , 0 , reg , & value , 1 , 1000 ) ; return ret >= 0 ? value : ret ; } "," ret ; uint8_t * buffer ; uint8_t value ; buffer = kmalloc ( 1 , GFP_KERNEL ) ; if ( ! buffer ) return - ENOMEM ; dev_dbg ( , reg , buffer , 1 , 1000 ) ; if ( ret >= 0 ret >= 0 ) { value = buffer [ 0 ] ; kfree ( buffer ) ; return value ; } else { kfree ( buffer ) ; return ret ; } ret ; } } ",torvalds@linux/05a974efa4bdf6e2a150e3f27dc6fcf0a9ad5655,CVE-2017-5548,https://github.com/torvalds/linux/commit/05a974efa4bdf6e2a150e3f27dc6fcf0a9ad5655,2017-02-06T06:59Z 271,CWE-190,"CWE-190 static void addModuleArgument ( sqlite3 * db , Table * pTable , char * zArg ) { int nBytes = sizeof ( char * ) * ( 2 + pTable -> nModuleArg ) ; char * * azModuleArg ; azModuleArg = sqlite3DbRealloc ( db , pTable -> azModuleArg , nBytes ) ; if ( azModuleArg == 0 ) { sqlite3DbFree ( db , zArg ) ; } else { int i = pTable -> nModuleArg ++ ; azModuleArg [ i ] = zArg ; azModuleArg [ i + 1 ] = 0 ; pTable -> azModuleArg = azModuleArg ; } } "," void addModuleArgument ( Parse * pParse , Table * zArg ) { sqlite3_int64 nBytes = sizeof * azModuleArg ; sqlite3 * db = pParse -> db ; if ( pTable -> nModuleArg + 3 >= db -> aLimit [ SQLITE_LIMIT_COLUMN ] ) { sqlite3ErrorMsg ( pParse , ""toomanycolumnson%s"" , pTable -> zName ) ; } ",chromium@chromium/517ac71c9ee27f856f9becde8abea7d1604af9d4,CVE-2019-5827,https://github.com/chromium/chromium/commit/517ac71c9ee27f856f9becde8abea7d1604af9d4,2019-06-27T17:15Z 272,CWE-119,"CWE-119 void xmlrpc_char_encode ( char * outbuffer , const char * s1 ) { long unsigned int i ; unsigned char c ; char buf2 [ 15 ] ; mowgli_string_t * s = mowgli_string_create ( ) ; * buf2 = '\\0' ; * outbuffer = '\\0' ; if ( ( ! ( s1 ) || ( * ( s1 ) == '\\0' ) ) ) { return ; } for ( i = 0 ; s1 [ i ] != '\\0' ; i ++ ) { c = s1 [ i ] ; if ( c > 127 ) { snprintf ( buf2 , sizeof buf2 , ""&#%d;"" , c ) ; s -> append ( s , buf2 , strlen ( buf2 ) ) ; } else if ( c == '&' ) { s -> append ( s , ""&"" , 5 ) ; } else if ( c == '<' ) { s -> append ( s , ""<"" , 4 ) ; } else if ( c == '>' ) { s -> append ( s , "">"" , 4 ) ; } else if ( c == \'""\' ) { s -> append ( s , """"" , 6 ) ; } else { s -> append_char ( s , c ) ; } } memcpy ( outbuffer , s -> str , XMLRPC_BUFSIZE ) ; } "," ; } } s -> append_char ( s , 0 ) ; strncpy ( outbuffer , ",atheme@atheme/87580d767868360d2fed503980129504da84b63e,CVE-2016-4478,https://github.com/atheme/atheme/commit/87580d767868360d2fed503980129504da84b63e,2016-06-13T19:59Z 273,CWE-000,"CWE-000 static cmsPipeline * DefaultICCintents ( cmsContext ContextID , cmsUInt32Number nProfiles , cmsUInt32Number TheIntents [ ] , cmsHPROFILE hProfiles [ ] , cmsBool BPC [ ] , cmsFloat64Number AdaptationStates [ ] , cmsUInt32Number dwFlags ) { cmsPipeline * Lut = NULL ; cmsPipeline * Result ; cmsHPROFILE hProfile ; cmsMAT3 m ; cmsVEC3 off ; cmsColorSpaceSignature ColorSpaceIn , ColorSpaceOut , CurrentColorSpace ; cmsProfileClassSignature ClassSig ; cmsUInt32Number i , Intent ; if ( nProfiles == 0 ) return NULL ; Result = cmsPipelineAlloc ( ContextID , 0 , 0 ) ; if ( Result == NULL ) return NULL ; CurrentColorSpace = cmsGetColorSpace ( hProfiles [ 0 ] ) ; for ( i = 0 ; i < nProfiles ; i ++ ) { cmsBool lIsDeviceLink , lIsInput ; hProfile = hProfiles [ i ] ; ClassSig = cmsGetDeviceClass ( hProfile ) ; lIsDeviceLink = ( ClassSig == cmsSigLinkClass || ClassSig == cmsSigAbstractClass ) ; if ( ( i == 0 ) && ! lIsDeviceLink ) { lIsInput = TRUE ; } else { lIsInput = ( CurrentColorSpace != cmsSigXYZData ) && ( CurrentColorSpace != cmsSigLabData ) ; } Intent = TheIntents [ i ] ; if ( lIsInput || lIsDeviceLink ) { ColorSpaceIn = cmsGetColorSpace ( hProfile ) ; ColorSpaceOut = cmsGetPCS ( hProfile ) ; } else { ColorSpaceIn = cmsGetPCS ( hProfile ) ; ColorSpaceOut = cmsGetColorSpace ( hProfile ) ; } if ( ! ColorSpaceIsCompatible ( ColorSpaceIn , CurrentColorSpace ) ) { cmsSignalError ( ContextID , cmsERROR_COLORSPACE_CHECK , ""ColorSpacemismatch"" ) ; goto Error ; } if ( lIsDeviceLink || ( ( ClassSig == cmsSigNamedColorClass ) && ( nProfiles == 1 ) ) ) { Lut = _cmsReadDevicelinkLUT ( hProfile , Intent ) ; if ( Lut == NULL ) goto Error ; if ( ClassSig == cmsSigAbstractClass && i > 0 ) { if ( ! ComputeConversion ( i , hProfiles , Intent , BPC [ i ] , AdaptationStates [ i ] , & m , & off ) ) goto Error ; } else { _cmsMAT3identity ( & m ) ; _cmsVEC3init ( & off , 0 , 0 , 0 ) ; } if ( ! AddConversion ( Result , CurrentColorSpace , ColorSpaceIn , & m , & off ) ) goto Error ; } else { if ( lIsInput ) { Lut = _cmsReadInputLUT ( hProfile , Intent ) ; if ( Lut == NULL ) goto Error ; } else { Lut = _cmsReadOutputLUT ( hProfile , Intent ) ; if ( Lut == NULL ) goto Error ; if ( ! ComputeConversion ( i , hProfiles , Intent , BPC [ i ] , AdaptationStates [ i ] , & m , & off ) ) goto Error ; if ( ! AddConversion ( Result , CurrentColorSpace , ColorSpaceIn , & m , & off ) ) goto Error ; } } if ( ! cmsPipelineCat ( Result , Lut ) ) goto Error ; cmsPipelineFree ( Lut ) ; CurrentColorSpace = ColorSpaceOut ; } return Result ; Error : cmsPipelineFree ( Lut ) ; if ( Result != NULL ) cmsPipelineFree ( Result ) ; return NULL ; cmsUNUSED_PARAMETER ( dwFlags ) ; } "," Lut ) ; Lut = NULL ; ; Error : if ( Lut != NULL ) ",mm2@Little-CMS/fefaaa43c382eee632ea3ad0cfa915335140e1db,CVE-2013-7455,https://github.com/mm2/Little-CMS/commit/fefaaa43c382eee632ea3ad0cfa915335140e1db,2016-05-07T10:59Z 274,CWE-125,"CWE-125 static void process_constructors ( RBinFile * bf , RList * ret , int bits ) { RList * secs = sections ( bf ) ; RListIter * iter ; RBinSection * sec ; int i , type ; r_list_foreach ( secs , iter , sec ) { type = - 1 ; if ( ! strcmp ( sec -> name , "".fini_array"" ) ) { type = R_BIN_ENTRY_TYPE_FINI ; } else if ( ! strcmp ( sec -> name , "".init_array"" ) ) { type = R_BIN_ENTRY_TYPE_INIT ; } else if ( ! strcmp ( sec -> name , "".preinit_array"" ) ) { type = R_BIN_ENTRY_TYPE_PREINIT ; } if ( type != - 1 ) { ut8 * buf = calloc ( sec -> size , 1 ) ; if ( ! buf ) { continue ; } ( void ) r_buf_read_at ( bf -> buf , sec -> paddr , buf , sec -> size ) ; if ( bits == 32 ) { for ( i = 0 ; i < sec -> size ; i += 4 ) { ut32 addr32 = r_read_le32 ( buf + i ) ; if ( addr32 ) { RBinAddr * ba = newEntry ( sec -> paddr + i , ( ut64 ) addr32 , type , bits ) ; r_list_append ( ret , ba ) ; } } } else { for ( i = 0 ; i < sec -> size ; i += 8 ) { ut64 addr64 = r_read_le64 ( buf + i ) ; if ( addr64 ) { RBinAddr * ba = newEntry ( sec -> paddr + i , addr64 , type , bits ) ; r_list_append ( ret , ba ) ; } } } free ( buf ) ; } } r_list_free ( secs ) ; } "," = 0 ; ( i + 3 ) < sec -> = 0 ; ( i + 7 ) < sec -> ",radare@radare2/1f37c04f2a762500222dda2459e6a04646feeedf,CVE-2018-11376,https://github.com/radare/radare2/commit/1f37c04f2a762500222dda2459e6a04646feeedf,2018-05-22T19:29Z 275,CWE-125,"CWE-125 static int isis_print_is_reach_subtlv ( netdissect_options * ndo , const uint8_t * tptr , u_int subt , u_int subl , const char * ident ) { u_int te_class , priority_level , gmpls_switch_cap ; union { float f ; uint32_t i ; } bw ; ND_PRINT ( ( ndo , ""%s%ssubTLV#%u,length:%u"" , ident , tok2str ( isis_ext_is_reach_subtlv_values , ""unknown"" , subt ) , subt , subl ) ) ; ND_TCHECK2 ( * tptr , subl ) ; switch ( subt ) { case ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP : case ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID : case ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID : if ( subl >= 4 ) { ND_PRINT ( ( ndo , "",0x%08x"" , EXTRACT_32BITS ( tptr ) ) ) ; if ( subl == 8 ) ND_PRINT ( ( ndo , "",0x%08x"" , EXTRACT_32BITS ( tptr + 4 ) ) ) ; } break ; case ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR : case ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR : if ( subl >= sizeof ( struct in_addr ) ) ND_PRINT ( ( ndo , "",%s"" , ipaddr_string ( ndo , tptr ) ) ) ; break ; case ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW : case ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW : if ( subl >= 4 ) { bw . i = EXTRACT_32BITS ( tptr ) ; ND_PRINT ( ( ndo , "",%.3fMbps"" , bw . f * 8 / 1000000 ) ) ; } break ; case ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW : if ( subl >= 32 ) { for ( te_class = 0 ; te_class < 8 ; te_class ++ ) { bw . i = EXTRACT_32BITS ( tptr ) ; ND_PRINT ( ( ndo , ""%sTE-Class%u:%.3fMbps"" , ident , te_class , bw . f * 8 / 1000000 ) ) ; tptr += 4 ; } } break ; case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS : case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD : ND_PRINT ( ( ndo , ""%sBandwidthConstraintsModelID:%s(%u)"" , ident , tok2str ( diffserv_te_bc_values , ""unknown"" , * tptr ) , * tptr ) ) ; tptr ++ ; for ( te_class = 0 ; te_class < ( subl - 1 ) / 4 ; te_class ++ ) { ND_TCHECK2 ( * tptr , 4 ) ; bw . i = EXTRACT_32BITS ( tptr ) ; ND_PRINT ( ( ndo , ""%sBandwidthconstraintCT%u:%.3fMbps"" , ident , te_class , bw . f * 8 / 1000000 ) ) ; tptr += 4 ; } break ; case ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC : if ( subl >= 3 ) ND_PRINT ( ( ndo , "",%u"" , EXTRACT_24BITS ( tptr ) ) ) ; break ; case ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE : if ( subl == 2 ) { ND_PRINT ( ( ndo , "",[%s](0x%04x)"" , bittok2str ( isis_subtlv_link_attribute_values , ""Unknown"" , EXTRACT_16BITS ( tptr ) ) , EXTRACT_16BITS ( tptr ) ) ) ; } break ; case ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE : if ( subl >= 2 ) { ND_PRINT ( ( ndo , "",%s,Priority%u"" , bittok2str ( gmpls_link_prot_values , ""none"" , * tptr ) , * ( tptr + 1 ) ) ) ; } break ; case ISIS_SUBTLV_SPB_METRIC : if ( subl >= 6 ) { ND_PRINT ( ( ndo , "",LM:%u"" , EXTRACT_24BITS ( tptr ) ) ) ; tptr = tptr + 3 ; ND_PRINT ( ( ndo , "",P:%u"" , * ( tptr ) ) ) ; tptr ++ ; ND_PRINT ( ( ndo , "",P-ID:%u"" , EXTRACT_16BITS ( tptr ) ) ) ; } break ; case ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR : if ( subl >= 36 ) { gmpls_switch_cap = * tptr ; ND_PRINT ( ( ndo , ""%sInterfaceSwitchingCapability:%s"" , ident , tok2str ( gmpls_switch_cap_values , ""Unknown"" , gmpls_switch_cap ) ) ) ; ND_PRINT ( ( ndo , "",LSPEncoding:%s"" , tok2str ( gmpls_encoding_values , ""Unknown"" , * ( tptr + 1 ) ) ) ) ; tptr += 4 ; ND_PRINT ( ( ndo , ""%sMaxLSPBandwidth:"" , ident ) ) ; for ( priority_level = 0 ; priority_level < 8 ; priority_level ++ ) { bw . i = EXTRACT_32BITS ( tptr ) ; ND_PRINT ( ( ndo , ""%sprioritylevel%d:%.3fMbps"" , ident , priority_level , bw . f * 8 / 1000000 ) ) ; tptr += 4 ; } subl -= 36 ; switch ( gmpls_switch_cap ) { case GMPLS_PSC1 : case GMPLS_PSC2 : case GMPLS_PSC3 : case GMPLS_PSC4 : ND_TCHECK2 ( * tptr , 6 ) ; bw . i = EXTRACT_32BITS ( tptr ) ; ND_PRINT ( ( ndo , ""%sMinLSPBandwidth:%.3fMbps"" , ident , bw . f * 8 / 1000000 ) ) ; ND_PRINT ( ( ndo , ""%sInterfaceMTU:%u"" , ident , EXTRACT_16BITS ( tptr + 4 ) ) ) ; break ; case GMPLS_TSC : ND_TCHECK2 ( * tptr , 8 ) ; bw . i = EXTRACT_32BITS ( tptr ) ; ND_PRINT ( ( ndo , ""%sMinLSPBandwidth:%.3fMbps"" , ident , bw . f * 8 / 1000000 ) ) ; ND_PRINT ( ( ndo , ""%sIndication%s"" , ident , tok2str ( gmpls_switch_cap_tsc_indication_values , ""Unknown(%u)"" , * ( tptr + 4 ) ) ) ) ; break ; default : if ( subl > 0 ) { if ( ! print_unknown_data ( ndo , tptr , ""\\n\\t\\t"" , subl ) ) return ( 0 ) ; } } } break ; default : if ( ! print_unknown_data ( ndo , tptr , ""\\n\\t\\t"" , subl ) ) return ( 0 ) ; break ; } return ( 1 ) ; trunc : return ( 0 ) ; } "," case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD : if ( subl == 0 ) break ; ++ ) { bw . i ",the-tcpdump-group@tcpdump/5d0d76e88ee2d3236d7e032589d6f1d4ec5f7b1e,CVE-2017-13055,https://github.com/the-tcpdump-group/tcpdump/commit/5d0d76e88ee2d3236d7e032589d6f1d4ec5f7b1e,2017-09-14T06:29Z 276,CWE-787,"CWE-787 WORD32 ixheaacd_complex_anal_filt ( ia_esbr_hbe_txposer_struct * ptr_hbe_txposer ) { WORD32 idx ; WORD32 anal_size = 2 * ptr_hbe_txposer -> synth_size ; WORD32 N = ( 10 * anal_size ) ; for ( idx = 0 ; idx < ( ptr_hbe_txposer -> no_bins >> 1 ) ; idx ++ ) { WORD32 i , j , k , l ; FLOAT32 window_output [ 640 ] ; FLOAT32 u [ 128 ] , u_in [ 256 ] , u_out [ 256 ] ; FLOAT32 accu_r , accu_i ; const FLOAT32 * inp_signal ; FLOAT32 * anal_buf ; FLOAT32 * analy_cos_sin_tab = ptr_hbe_txposer -> analy_cos_sin_tab ; const FLOAT32 * interp_window_coeff = ptr_hbe_txposer -> analy_wind_coeff ; FLOAT32 * x = ptr_hbe_txposer -> analy_buf ; memset ( ptr_hbe_txposer -> qmf_in_buf [ idx + HBE_OPER_WIN_LEN - 1 ] , 0 , TWICE_QMF_SYNTH_CHANNELS_NUM * sizeof ( FLOAT32 ) ) ; inp_signal = ptr_hbe_txposer -> ptr_input_buf + idx * 2 * ptr_hbe_txposer -> synth_size + 1 ; anal_buf = & ptr_hbe_txposer -> qmf_in_buf [ idx + HBE_OPER_WIN_LEN - 1 ] [ 4 * ptr_hbe_txposer -> k_start ] ; for ( i = N - 1 ; i >= anal_size ; i -- ) { x [ i ] = x [ i - anal_size ] ; } for ( i = anal_size - 1 ; i >= 0 ; i -- ) { x [ i ] = inp_signal [ anal_size - 1 - i ] ; } for ( i = 0 ; i < N ; i ++ ) { window_output [ i ] = x [ i ] * interp_window_coeff [ i ] ; } for ( i = 0 ; i < 2 * anal_size ; i ++ ) { accu_r = 0.0 ; for ( j = 0 ; j < 5 ; j ++ ) { accu_r = accu_r + window_output [ i + j * 2 * anal_size ] ; } u [ i ] = accu_r ; } if ( anal_size == 40 ) { for ( i = 1 ; i < anal_size ; i ++ ) { FLOAT32 temp1 = u [ i ] + u [ 2 * anal_size - i ] ; FLOAT32 temp2 = u [ i ] - u [ 2 * anal_size - i ] ; u [ i ] = temp1 ; u [ 2 * anal_size - i ] = temp2 ; } for ( k = 0 ; k < anal_size ; k ++ ) { accu_r = u [ anal_size ] ; if ( k & 1 ) accu_i = u [ 0 ] ; else accu_i = - u [ 0 ] ; for ( l = 1 ; l < anal_size ; l ++ ) { accu_r = accu_r + u [ 0 + l ] * analy_cos_sin_tab [ 2 * l + 0 ] ; accu_i = accu_i + u [ 2 * anal_size - l ] * analy_cos_sin_tab [ 2 * l + 1 ] ; } analy_cos_sin_tab += ( 2 * anal_size ) ; * anal_buf ++ = ( FLOAT32 ) accu_r ; * anal_buf ++ = ( FLOAT32 ) accu_i ; } } else { FLOAT32 * ptr_u = u_in ; FLOAT32 * ptr_v = u_out ; for ( k = 0 ; k < anal_size * 2 ; k ++ ) { * ptr_u ++ = ( ( * analy_cos_sin_tab ++ ) * u [ k ] ) ; * ptr_u ++ = ( ( * analy_cos_sin_tab ++ ) * u [ k ] ) ; } if ( ixheaacd_cmplx_anal_fft != NULL ) ( * ixheaacd_cmplx_anal_fft ) ( u_in , u_out , anal_size * 2 ) ; else return - 1 ; for ( k = 0 ; k < anal_size / 2 ; k ++ ) { * ( anal_buf + 1 ) = - * ptr_v ++ ; * anal_buf = * ptr_v ++ ; anal_buf += 2 ; * ( anal_buf + 1 ) = * ptr_v ++ ; * anal_buf = - * ptr_v ++ ; anal_buf += 2 ; } } } return 0 ; } "," } if ( ptr_hbe_txposer -> ) ( * ( ptr_hbe_txposer -> ixheaacd_cmplx_anal_fft ) ) ( u_in , ",external@libxaac/04e8cd58f075bec5892e369c8deebca9c67e855c,CVE-2018-9496,https://android.googlesource.com/platform/external/libxaac/+/04e8cd58f075bec5892e369c8deebca9c67e855c,2018-10-02T19:29Z 277,CWE-125,"CWE-125 static int forward_search_range ( regex_t * reg , const UChar * str , const UChar * end , UChar * s , UChar * range , UChar * * low , UChar * * high , UChar * * low_prev ) { UChar * p , * pprev = ( UChar * ) NULL ; # ifdef ONIG_DEBUG_SEARCH fprintf ( stderr , ""forward_search_range:str:%d,end:%d,s:%d,range:%d\\n"" , ( int ) str , ( int ) end , ( int ) s , ( int ) range ) ; # endif p = s ; if ( reg -> dmin > 0 ) { if ( ONIGENC_IS_SINGLEBYTE ( reg -> enc ) ) { p += reg -> dmin ; } else { UChar * q = p + reg -> dmin ; while ( p < q ) p += enclen ( reg -> enc , p ) ; } } retry : switch ( reg -> optimize ) { case ONIG_OPTIMIZE_EXACT : p = slow_search ( reg -> enc , reg -> exact , reg -> exact_end , p , end , range ) ; break ; case ONIG_OPTIMIZE_EXACT_IC : p = slow_search_ic ( reg -> enc , reg -> case_fold_flag , reg -> exact , reg -> exact_end , p , end , range ) ; break ; case ONIG_OPTIMIZE_EXACT_BM : p = bm_search ( reg , reg -> exact , reg -> exact_end , p , end , range ) ; break ; case ONIG_OPTIMIZE_EXACT_BM_NOT_REV : p = bm_search_notrev ( reg , reg -> exact , reg -> exact_end , p , end , range ) ; break ; case ONIG_OPTIMIZE_MAP : p = map_search ( reg -> enc , reg -> map , p , range ) ; break ; } if ( p && p < range ) { if ( p - reg -> dmin < s ) { retry_gate : pprev = p ; p += enclen ( reg -> enc , p ) ; goto retry ; } if ( reg -> sub_anchor ) { UChar * prev ; switch ( reg -> sub_anchor ) { case ANCHOR_BEGIN_LINE : if ( ! ON_STR_BEGIN ( p ) ) { prev = onigenc_get_prev_char_head ( reg -> enc , ( pprev ? pprev : str ) , p ) ; if ( ! ONIGENC_IS_MBC_NEWLINE ( reg -> enc , prev , end ) ) goto retry_gate ; } break ; case ANCHOR_END_LINE : if ( ON_STR_END ( p ) ) { # ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE prev = ( UChar * ) onigenc_get_prev_char_head ( reg -> enc , ( pprev ? pprev : str ) , p ) ; if ( prev && ONIGENC_IS_MBC_NEWLINE ( reg -> enc , prev , end ) ) goto retry_gate ; # endif } else if ( ! ONIGENC_IS_MBC_NEWLINE ( reg -> enc , p , end ) # ifdef USE_CRNL_AS_LINE_TERMINATOR && ! ONIGENC_IS_MBC_CRNL ( reg -> enc , p , end ) # endif ) goto retry_gate ; break ; } } if ( reg -> dmax == 0 ) { * low = p ; if ( low_prev ) { if ( * low > s ) * low_prev = onigenc_get_prev_char_head ( reg -> enc , s , p ) ; else * low_prev = onigenc_get_prev_char_head ( reg -> enc , ( pprev ? pprev : str ) , p ) ; } } else { if ( reg -> dmax != ONIG_INFINITE_DISTANCE ) { * low = p - reg -> dmax ; if ( * low > s ) { * low = onigenc_get_right_adjust_char_head_with_prev ( reg -> enc , s , * low , ( const UChar * * ) low_prev ) ; if ( low_prev && IS_NULL ( * low_prev ) ) * low_prev = onigenc_get_prev_char_head ( reg -> enc , ( pprev ? pprev : s ) , * low ) ; } else { if ( low_prev ) * low_prev = onigenc_get_prev_char_head ( reg -> enc , ( pprev ? pprev : str ) , * low ) ; } } } * high = p - reg -> dmin ; # ifdef ONIG_DEBUG_SEARCH fprintf ( stderr , ""forward_search_rangesuccess:low:%d,high:%d,dmin:%d,dmax:%d\\n"" , ( int ) ( * low - str ) , ( int ) ( * high - str ) , reg -> dmin , reg -> dmax ) ; # endif return 1 ; } return 0 ; } "," -> dmin ; if ( q >= end ) return 0 ; ",kkos@oniguruma/9690d3ab1f9bcd2db8cbe1fe3ee4a5da606b8814,CVE-2017-9227,https://github.com/kkos/oniguruma/commit/9690d3ab1f9bcd2db8cbe1fe3ee4a5da606b8814,2017-05-24T15:29Z 278,CWE-416,"CWE-416 static void bfq_idle_slice_timer_body ( struct bfq_queue * bfqq ) { struct bfq_data * bfqd = bfqq -> bfqd ; enum bfqq_expiration reason ; unsigned long flags ; spin_lock_irqsave ( & bfqd -> lock , flags ) ; bfq_clear_bfqq_wait_request ( bfqq ) ; if ( bfqq != bfqd -> in_service_queue ) { spin_unlock_irqrestore ( & bfqd -> lock , flags ) ; return ; } if ( bfq_bfqq_budget_timeout ( bfqq ) ) reason = BFQQE_BUDGET_TIMEOUT ; else if ( bfqq -> queued [ 0 ] == 0 && bfqq -> queued [ 1 ] == 0 ) reason = BFQQE_TOO_IDLE ; else goto schedule_dispatch ; bfq_bfqq_expire ( bfqd , bfqq , true , reason ) ; schedule_dispatch : spin_unlock_irqrestore ( & bfqd -> lock , flags ) ; bfq_schedule_dispatch ( bfqd ) ; } "," void bfq_idle_slice_timer_body ( struct bfq_data * bfqd , bfqq ) { enum bfqq_expiration reason lock , flags ) ; if return ; } bfq_clear_bfqq_wait_request ( bfqq ) ; ",torvalds@linux/2f95fa5c955d0a9987ffdc3a095e2f4e62c5f2a9,CVE-2020-12657,https://github.com/torvalds/linux/commit/2f95fa5c955d0a9987ffdc3a095e2f4e62c5f2a9,2020-05-05T07:15Z 279,CWE-20,"CWE-20 void big_key_revoke ( struct key * key ) { struct path * path = ( struct path * ) & key -> payload . data [ big_key_path ] ; key_payload_reserve ( key , 0 ) ; if ( key_is_instantiated ( key ) && ( size_t ) key -> payload . data [ big_key_len ] > BIG_KEY_FILE_THRESHOLD ) vfs_truncate ( path , 0 ) ; } "," ; if ( key_is_positive ( key ) ",torvalds@linux/363b02dab09b3226f3bd1420dad9c72b79a42a76,CVE-2017-15951,https://github.com/torvalds/linux/commit/363b02dab09b3226f3bd1420dad9c72b79a42a76,2017-10-28T02:29Z 280,CWE-20,"CWE-20 static unsigned xen_netbk_tx_build_gops ( struct xen_netbk * netbk ) { struct gnttab_copy * gop = netbk -> tx_copy_ops , * request_gop ; struct sk_buff * skb ; int ret ; while ( ( ( nr_pending_reqs ( netbk ) + MAX_SKB_FRAGS ) < MAX_PENDING_REQS ) && ! list_empty ( & netbk -> net_schedule_list ) ) { struct xenvif * vif ; struct xen_netif_tx_request txreq ; struct xen_netif_tx_request txfrags [ MAX_SKB_FRAGS ] ; struct page * page ; struct xen_netif_extra_info extras [ XEN_NETIF_EXTRA_TYPE_MAX - 1 ] ; u16 pending_idx ; RING_IDX idx ; int work_to_do ; unsigned int data_len ; pending_ring_idx_t index ; vif = poll_net_schedule_list ( netbk ) ; if ( ! vif ) continue ; RING_FINAL_CHECK_FOR_REQUESTS ( & vif -> tx , work_to_do ) ; if ( ! work_to_do ) { xenvif_put ( vif ) ; continue ; } idx = vif -> tx . req_cons ; rmb ( ) ; memcpy ( & txreq , RING_GET_REQUEST ( & vif -> tx , idx ) , sizeof ( txreq ) ) ; if ( txreq . size > vif -> remaining_credit && tx_credit_exceeded ( vif , txreq . size ) ) { xenvif_put ( vif ) ; continue ; } vif -> remaining_credit -= txreq . size ; work_to_do -- ; vif -> tx . req_cons = ++ idx ; memset ( extras , 0 , sizeof ( extras ) ) ; if ( txreq . flags & XEN_NETTXF_extra_info ) { work_to_do = xen_netbk_get_extras ( vif , extras , work_to_do ) ; idx = vif -> tx . req_cons ; if ( unlikely ( work_to_do < 0 ) ) { netbk_tx_err ( vif , & txreq , idx ) ; continue ; } } ret = netbk_count_requests ( vif , & txreq , txfrags , work_to_do ) ; if ( unlikely ( ret < 0 ) ) { netbk_tx_err ( vif , & txreq , idx - ret ) ; continue ; } idx += ret ; if ( unlikely ( txreq . size < ETH_HLEN ) ) { netdev_dbg ( vif -> dev , ""Badpacketsize:%d\\n"" , txreq . size ) ; netbk_tx_err ( vif , & txreq , idx ) ; continue ; } if ( unlikely ( ( txreq . offset + txreq . size ) > PAGE_SIZE ) ) { netdev_dbg ( vif -> dev , ""txreq.offset:%x,size:%u,end:%lu\\n"" , txreq . offset , txreq . size , ( txreq . offset & ~ PAGE_MASK ) + txreq . size ) ; netbk_tx_err ( vif , & txreq , idx ) ; continue ; } index = pending_index ( netbk -> pending_cons ) ; pending_idx = netbk -> pending_ring [ index ] ; data_len = ( txreq . size > PKT_PROT_LEN && ret < MAX_SKB_FRAGS ) ? PKT_PROT_LEN : txreq . size ; skb = alloc_skb ( data_len + NET_SKB_PAD + NET_IP_ALIGN , GFP_ATOMIC | __GFP_NOWARN ) ; if ( unlikely ( skb == NULL ) ) { netdev_dbg ( vif -> dev , ""Can\'tallocateaskbinstart_xmit.\\n"" ) ; netbk_tx_err ( vif , & txreq , idx ) ; break ; } skb_reserve ( skb , NET_SKB_PAD + NET_IP_ALIGN ) ; if ( extras [ XEN_NETIF_EXTRA_TYPE_GSO - 1 ] . type ) { struct xen_netif_extra_info * gso ; gso = & extras [ XEN_NETIF_EXTRA_TYPE_GSO - 1 ] ; if ( netbk_set_skb_gso ( vif , skb , gso ) ) { kfree_skb ( skb ) ; netbk_tx_err ( vif , & txreq , idx ) ; continue ; } } page = xen_netbk_alloc_page ( netbk , skb , pending_idx ) ; if ( ! page ) { kfree_skb ( skb ) ; netbk_tx_err ( vif , & txreq , idx ) ; continue ; } gop -> source . u . ref = txreq . gref ; gop -> source . domid = vif -> domid ; gop -> source . offset = txreq . offset ; gop -> dest . u . gmfn = virt_to_mfn ( page_address ( page ) ) ; gop -> dest . domid = DOMID_SELF ; gop -> dest . offset = txreq . offset ; gop -> len = txreq . size ; gop -> flags = GNTCOPY_source_gref ; gop ++ ; memcpy ( & netbk -> pending_tx_info [ pending_idx ] . req , & txreq , sizeof ( txreq ) ) ; netbk -> pending_tx_info [ pending_idx ] . vif = vif ; * ( ( u16 * ) skb -> data ) = pending_idx ; __skb_put ( skb , data_len ) ; skb_shinfo ( skb ) -> nr_frags = ret ; if ( data_len < txreq . size ) { skb_shinfo ( skb ) -> nr_frags ++ ; frag_set_pending_idx ( & skb_shinfo ( skb ) -> frags [ 0 ] , pending_idx ) ; } else { frag_set_pending_idx ( & skb_shinfo ( skb ) -> frags [ 0 ] , INVALID_PENDING_IDX ) ; } netbk -> pending_cons ++ ; request_gop = xen_netbk_get_requests ( netbk , vif , skb , txfrags , gop ) ; if ( request_gop == NULL ) { kfree_skb ( skb ) ; netbk_tx_err ( vif , & txreq , idx ) ; continue ; } gop = request_gop ; __skb_queue_tail ( & netbk -> tx_queue , skb ) ; vif -> tx . req_cons = idx ; xen_netbk_check_rx_xenvif ( vif ) ; if ( ( gop - netbk -> tx_copy_ops ) >= ARRAY_SIZE ( netbk -> tx_copy_ops ) ) break ; } return gop - netbk -> tx_copy_ops ; } "," ) continue ; if ( vif -> tx . sring -> req_prod - vif -> tx . req_cons > XEN_NETIF_TX_RING_SIZE ) { netdev_err ( vif -> dev , ""Impossiblenumberofrequests."" ""req_prod%d,req_cons%d,size%ld\\n"" , vif -> tx . sring -> req_prod , vif -> tx . req_cons , XEN_NETIF_TX_RING_SIZE ) ; netbk_fatal_tx_err ( vif ) ; continue ; } 0 ) ) continue ; } ret = 0 ) ) continue ; idx += ret ) ) { netdev_err ( vif -> size ) ; netbk_fatal_tx_err ( vif ) ; continue skb ) ; continue ; } ",torvalds@linux/48856286b64e4b66ec62b94e504d0b29c1ade664,CVE-2013-0216,https://github.com/torvalds/linux/commit/48856286b64e4b66ec62b94e504d0b29c1ade664,2013-02-18T04:41Z 281,CWE-399,"CWE-399 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 ) { 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 # 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 , ""UNIXType:L8"" ) ; goto wayout ; # ifdef WITH_TLS } else if ( enforce_tls_auth > 0 && ! strcmp ( cmd , ""auth"" ) && ! strcasecmp ( arg , ""tls"" ) ) { addreply_noformat ( 234 , ""AUTHTLSOK."" ) ; doreply ( ) ; if ( tls_cnx == NULL ) { ( 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 , ""Fallbackto[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 ) { 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 , ""SITEIDLE:"" 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 , ""UTCOnly"" ) ; 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 } } "," NULL ) { flush_cmd ( ) ; ",jedisct1@pure-ftpd/65c4d4ad331e94661de763e9b5304d28698999c4,CVE-2011-1575,https://github.com/jedisct1/pure-ftpd/commit/65c4d4ad331e94661de763e9b5304d28698999c4,2011-05-23T22:55Z 282,CWE-416,"CWE-416 static int xfrm_dump_policy_done ( struct netlink_callback * cb ) { struct xfrm_policy_walk * walk = ( struct xfrm_policy_walk * ) & cb -> args [ 1 ] ; struct net * net = sock_net ( cb -> skb -> sk ) ; xfrm_policy_walk_done ( walk , net ) ; return 0 ; } "," xfrm_policy_walk * ) cb -> args cb -> args ; struct net ",torvalds@linux/1137b5e2529a8f5ca8ee709288ecba3e68044df2,CVE-2017-16939,https://github.com/torvalds/linux/commit/1137b5e2529a8f5ca8ee709288ecba3e68044df2,2017-11-24T10:29Z 283,CWE-000,"CWE-000 static void on_read ( h2o_socket_t * sock , int status ) { h2o_http2_conn_t * conn = sock -> data ; if ( status != 0 ) { h2o_socket_read_stop ( conn -> sock ) ; close_connection ( conn ) ; return ; } update_idle_timeout ( conn ) ; parse_input ( conn ) ; if ( h2o_timeout_is_linked ( & conn -> _write . timeout_entry ) ) { h2o_timeout_unlink ( & conn -> _write . timeout_entry ) ; do_emit_writereq ( conn ) ; } } "," conn ) ; if ( ( conn ) != 0 ) return ",h2o@h2o/1c0808d580da09fdec5a9a74ff09e103ea058dd4,CVE-2016-4817,https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4,2016-06-19T01:59Z 284,CWE-399,"CWE-399 static int xen_netbk_tx_check_gop ( struct xen_netbk * netbk , struct sk_buff * skb , struct gnttab_copy * * gopp ) { struct gnttab_copy * gop = * gopp ; u16 pending_idx = * ( ( u16 * ) skb -> data ) ; struct pending_tx_info * pending_tx_info = netbk -> pending_tx_info ; struct xenvif * vif = pending_tx_info [ pending_idx ] . vif ; struct xen_netif_tx_request * txp ; struct skb_shared_info * shinfo = skb_shinfo ( skb ) ; int nr_frags = shinfo -> nr_frags ; int i , err , start ; err = gop -> status ; if ( unlikely ( err ) ) { pending_ring_idx_t index ; index = pending_index ( netbk -> pending_prod ++ ) ; txp = & pending_tx_info [ pending_idx ] . req ; make_tx_response ( vif , txp , XEN_NETIF_RSP_ERROR ) ; netbk -> pending_ring [ index ] = pending_idx ; xenvif_put ( vif ) ; } start = ( frag_get_pending_idx ( & shinfo -> frags [ 0 ] ) == pending_idx ) ; for ( i = start ; i < nr_frags ; i ++ ) { int j , newerr ; pending_ring_idx_t index ; pending_idx = frag_get_pending_idx ( & shinfo -> frags [ i ] ) ; newerr = ( ++ gop ) -> status ; if ( likely ( ! newerr ) ) { if ( unlikely ( err ) ) xen_netbk_idx_release ( netbk , pending_idx ) ; continue ; } txp = & netbk -> pending_tx_info [ pending_idx ] . req ; make_tx_response ( vif , txp , XEN_NETIF_RSP_ERROR ) ; index = pending_index ( netbk -> pending_prod ++ ) ; netbk -> pending_ring [ index ] = pending_idx ; xenvif_put ( vif ) ; if ( err ) continue ; pending_idx = * ( ( u16 * ) skb -> data ) ; xen_netbk_idx_release ( netbk , pending_idx ) ; for ( j = start ; j < i ; j ++ ) { pending_idx = frag_get_pending_idx ( & shinfo -> frags [ j ] ) ; xen_netbk_idx_release ( netbk , pending_idx ) ; } err = newerr ; } * gopp = gop + 1 ; return err ; } "," ) ; struct skb_shared_info * shinfo err ) ) xen_netbk_idx_release ( netbk , pending_idx , XEN_NETIF_RSP_ERROR ) XEN_NETIF_RSP_ERROR ) ; start = ( , newerr ; pending_idx = frag_get_pending_idx netbk , pending_idx , XEN_NETIF_RSP_OKAY continue ; } xen_netbk_idx_release ( netbk , pending_idx , XEN_NETIF_RSP_ERROR ) XEN_NETIF_RSP_ERROR ) ; if ( err netbk , pending_idx , XEN_NETIF_RSP_OKAY netbk , pending_idx , XEN_NETIF_RSP_OKAY ",torvalds@linux/7d5145d8eb2b9791533ffe4dc003b129b9696c48,CVE-2013-0217,https://github.com/torvalds/linux/commit/7d5145d8eb2b9791533ffe4dc003b129b9696c48,2013-02-18T04:41Z 285,CWE-119,"CWE-119 void cJSON_AddItemReferenceToObject ( cJSON * object , const char * string , cJSON * item ) { cJSON_AddItemToObject ( object , string , create_reference ( item ) ) ; } "," ",esnet@iperf/91f2fa59e8ed80dfbf400add0164ee0e508e412a,CVE-2016-4303,https://github.com/esnet/iperf/commit/91f2fa59e8ed80dfbf400add0164ee0e508e412a,2016-09-26T14:59Z 286,CWE-772,"CWE-772 static Image * ReadYUVImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { Image * chroma_image , * image , * resize_image ; InterlaceType interlace ; MagickBooleanType status ; register const Quantum * chroma_pixels ; register ssize_t x ; register Quantum * q ; register unsigned char * p ; ssize_t count , horizontal_factor , vertical_factor , y ; size_t length , quantum ; unsigned char * scanline ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; if ( ( image -> columns == 0 ) || ( image -> rows == 0 ) ) ThrowReaderException ( OptionError , ""MustSpecifyImageSize"" ) ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; quantum = ( ssize_t ) ( image -> depth <= 8 ? 1 : 2 ) ; interlace = image_info -> interlace ; horizontal_factor = 2 ; vertical_factor = 2 ; if ( image_info -> sampling_factor != ( char * ) NULL ) { GeometryInfo geometry_info ; MagickStatusType flags ; flags = ParseGeometry ( image_info -> sampling_factor , & geometry_info ) ; horizontal_factor = ( ssize_t ) geometry_info . rho ; vertical_factor = ( ssize_t ) geometry_info . sigma ; if ( ( flags & SigmaValue ) == 0 ) vertical_factor = horizontal_factor ; if ( ( horizontal_factor != 1 ) && ( horizontal_factor != 2 ) && ( vertical_factor != 1 ) && ( vertical_factor != 2 ) ) ThrowReaderException ( CorruptImageError , ""UnexpectedSamplingFactor"" ) ; } if ( ( interlace == UndefinedInterlace ) || ( ( interlace == NoInterlace ) && ( vertical_factor == 2 ) ) ) { interlace = NoInterlace ; if ( vertical_factor == 2 ) interlace = PlaneInterlace ; } if ( interlace != PartitionInterlace ) { status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } if ( DiscardBlobBytes ( image , ( MagickSizeType ) image -> offset ) == MagickFalse ) ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; } if ( interlace == NoInterlace ) scanline = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) ( 2UL * image -> columns + 2UL ) , ( size_t ) quantum * sizeof ( * scanline ) ) ; else scanline = ( unsigned char * ) AcquireQuantumMemory ( image -> columns , ( size_t ) quantum * sizeof ( * scanline ) ) ; if ( scanline == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; status = MagickTrue ; do { chroma_image = CloneImage ( image , ( image -> columns + horizontal_factor - 1 ) / horizontal_factor , ( image -> rows + vertical_factor - 1 ) / vertical_factor , MagickTrue , exception ) ; if ( chroma_image == ( Image * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) break ; if ( interlace == PartitionInterlace ) { AppendImageFormat ( ""Y"" , image -> filename ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } } for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { register Quantum * chroma_pixels ; if ( interlace == NoInterlace ) { if ( ( y > 0 ) || ( GetPreviousImageInList ( image ) == ( Image * ) NULL ) ) { length = 2 * quantum * image -> columns ; count = ReadBlob ( image , length , scanline ) ; if ( count != ( ssize_t ) length ) { status = MagickFalse ; ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } } p = scanline ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; chroma_pixels = QueueAuthenticPixels ( chroma_image , 0 , y , chroma_image -> columns , 1 , exception ) ; if ( chroma_pixels == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x += 2 ) { SetPixelRed ( chroma_image , 0 , chroma_pixels ) ; if ( quantum == 1 ) SetPixelGreen ( chroma_image , ScaleCharToQuantum ( * p ++ ) , chroma_pixels ) ; else { SetPixelGreen ( chroma_image , ScaleShortToQuantum ( ( ( * p ) << 8 ) | * ( p + 1 ) ) , chroma_pixels ) ; p += 2 ; } if ( quantum == 1 ) SetPixelRed ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; else { SetPixelRed ( image , ScaleShortToQuantum ( ( ( * p ) << 8 ) | * ( p + 1 ) ) , q ) ; p += 2 ; } SetPixelGreen ( image , 0 , q ) ; SetPixelBlue ( image , 0 , q ) ; q += GetPixelChannels ( image ) ; SetPixelGreen ( image , 0 , q ) ; SetPixelBlue ( image , 0 , q ) ; if ( quantum == 1 ) SetPixelBlue ( chroma_image , ScaleCharToQuantum ( * p ++ ) , chroma_pixels ) ; else { SetPixelBlue ( chroma_image , ScaleShortToQuantum ( ( ( * p ) << 8 ) | * ( p + 1 ) ) , chroma_pixels ) ; p += 2 ; } if ( quantum == 1 ) SetPixelRed ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; else { SetPixelRed ( image , ScaleShortToQuantum ( ( ( * p ) << 8 ) | * ( p + 1 ) ) , q ) ; p += 2 ; } chroma_pixels += GetPixelChannels ( chroma_image ) ; q += GetPixelChannels ( image ) ; } } else { if ( ( y > 0 ) || ( GetPreviousImageInList ( image ) == ( Image * ) NULL ) ) { length = quantum * image -> columns ; count = ReadBlob ( image , length , scanline ) ; if ( count != ( ssize_t ) length ) { status = MagickFalse ; ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } } p = scanline ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { if ( quantum == 1 ) SetPixelRed ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; else { SetPixelRed ( image , ScaleShortToQuantum ( ( ( * p ) << 8 ) | * ( p + 1 ) ) , q ) ; p += 2 ; } SetPixelGreen ( image , 0 , q ) ; SetPixelBlue ( image , 0 , q ) ; q += GetPixelChannels ( image ) ; } } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( interlace == NoInterlace ) if ( SyncAuthenticPixels ( chroma_image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } if ( interlace == PartitionInterlace ) { ( void ) CloseBlob ( image ) ; AppendImageFormat ( ""U"" , image -> filename ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } } if ( interlace != NoInterlace ) { for ( y = 0 ; y < ( ssize_t ) chroma_image -> rows ; y ++ ) { length = quantum * chroma_image -> columns ; count = ReadBlob ( image , length , scanline ) ; if ( count != ( ssize_t ) length ) { status = MagickFalse ; ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } p = scanline ; q = QueueAuthenticPixels ( chroma_image , 0 , y , chroma_image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) chroma_image -> columns ; x ++ ) { SetPixelRed ( chroma_image , 0 , q ) ; if ( quantum == 1 ) SetPixelGreen ( chroma_image , ScaleCharToQuantum ( * p ++ ) , q ) ; else { SetPixelGreen ( chroma_image , ScaleShortToQuantum ( ( ( * p ) << 8 ) | * ( p + 1 ) ) , q ) ; p += 2 ; } SetPixelBlue ( chroma_image , 0 , q ) ; q += GetPixelChannels ( chroma_image ) ; } if ( SyncAuthenticPixels ( chroma_image , exception ) == MagickFalse ) break ; } if ( interlace == PartitionInterlace ) { ( void ) CloseBlob ( image ) ; AppendImageFormat ( ""V"" , image -> filename ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } } for ( y = 0 ; y < ( ssize_t ) chroma_image -> rows ; y ++ ) { length = quantum * chroma_image -> columns ; count = ReadBlob ( image , length , scanline ) ; if ( count != ( ssize_t ) length ) { status = MagickFalse ; ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } p = scanline ; q = GetAuthenticPixels ( chroma_image , 0 , y , chroma_image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) chroma_image -> columns ; x ++ ) { if ( quantum == 1 ) SetPixelBlue ( chroma_image , ScaleCharToQuantum ( * p ++ ) , q ) ; else { SetPixelBlue ( chroma_image , ScaleShortToQuantum ( ( ( * p ) << 8 ) | * ( p + 1 ) ) , q ) ; p += 2 ; } q += GetPixelChannels ( chroma_image ) ; } if ( SyncAuthenticPixels ( chroma_image , exception ) == MagickFalse ) break ; } } resize_image = ResizeImage ( chroma_image , image -> columns , image -> rows , TriangleFilter , exception ) ; chroma_image = DestroyImage ( chroma_image ) ; if ( resize_image == ( Image * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = GetAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; chroma_pixels = GetVirtualPixels ( resize_image , 0 , y , resize_image -> columns , 1 , exception ) ; if ( ( q == ( Quantum * ) NULL ) || ( chroma_pixels == ( const Quantum * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelGreen ( image , GetPixelGreen ( resize_image , chroma_pixels ) , q ) ; SetPixelBlue ( image , GetPixelBlue ( resize_image , chroma_pixels ) , q ) ; chroma_pixels += GetPixelChannels ( resize_image ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } resize_image = DestroyImage ( resize_image ) ; if ( SetImageColorspace ( image , YCbCrColorspace , exception ) == MagickFalse ) break ; if ( interlace == PartitionInterlace ) ( void ) CopyMagickString ( image -> filename , image_info -> filename , MagickPathExtent ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; if ( interlace == NoInterlace ) count = ReadBlob ( image , ( size_t ) ( 2 * quantum * image -> columns ) , scanline ) ; else count = ReadBlob ( image , ( size_t ) quantum * image -> columns , scanline ) ; if ( count != 0 ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( count != 0 ) ; scanline = ( unsigned char * ) RelinquishMagickMemory ( scanline ) ; ( void ) CloseBlob ( image ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; return ( GetFirstImageInList ( image ) ) ; } "," ) NULL ) { scanline = ( unsigned char * ) RelinquishMagickMemory ( scanline ) ; ""MemoryAllocationFailed"" ) ; } MagickFalse ) { scanline = ( unsigned char * ) RelinquishMagickMemory ( scanline ) ; MagickFalse ) { scanline = ( unsigned char * ) RelinquishMagickMemory ( scanline ) ; MagickFalse ) { scanline = ( unsigned char * ) RelinquishMagickMemory ( scanline ) ; ) NULL ) { scanline = ( unsigned char * ) RelinquishMagickMemory ( scanline ) ; ""MemoryAllocationFailed"" ) ; } NULL ) { scanline = ( unsigned char * ) RelinquishMagickMemory ( scanline ) ; ",ImageMagick@ImageMagick/ef8f40689ac452398026c07da41656a7c87e4683,CVE-2017-15033,https://github.com/ImageMagick/ImageMagick/commit/ef8f40689ac452398026c07da41656a7c87e4683,2017-10-05T07:29Z 287,CWE-000,"CWE-000 int main ( void ) { int fd , len , sock_opt ; int error ; struct cn_msg * message ; struct pollfd pfd ; struct nlmsghdr * incoming_msg ; struct cn_msg * incoming_cn_msg ; struct hv_kvp_msg * hv_msg ; char * p ; char * key_value ; char * key_name ; int op ; int pool ; char * if_name ; struct hv_kvp_ipaddr_value * kvp_ip_val ; daemon ( 1 , 0 ) ; openlog ( ""KVP"" , 0 , LOG_USER ) ; syslog ( LOG_INFO , ""KVPstarting;pidis:%d"" , getpid ( ) ) ; kvp_get_os_info ( ) ; if ( kvp_file_init ( ) ) { syslog ( LOG_ERR , ""Failedtoinitializethepools"" ) ; exit ( EXIT_FAILURE ) ; } fd = socket ( AF_NETLINK , SOCK_DGRAM , NETLINK_CONNECTOR ) ; if ( fd < 0 ) { syslog ( LOG_ERR , ""netlinksocketcreationfailed;error:%d"" , fd ) ; exit ( EXIT_FAILURE ) ; } addr . nl_family = AF_NETLINK ; addr . nl_pad = 0 ; addr . nl_pid = 0 ; addr . nl_groups = CN_KVP_IDX ; error = bind ( fd , ( struct sockaddr * ) & addr , sizeof ( addr ) ) ; if ( error < 0 ) { syslog ( LOG_ERR , ""bindfailed;error:%d"" , error ) ; close ( fd ) ; exit ( EXIT_FAILURE ) ; } sock_opt = addr . nl_groups ; setsockopt ( fd , 270 , 1 , & sock_opt , sizeof ( sock_opt ) ) ; message = ( struct cn_msg * ) kvp_send_buffer ; message -> id . idx = CN_KVP_IDX ; message -> id . val = CN_KVP_VAL ; hv_msg = ( struct hv_kvp_msg * ) message -> data ; hv_msg -> kvp_hdr . operation = KVP_OP_REGISTER1 ; message -> ack = 0 ; message -> len = sizeof ( struct hv_kvp_msg ) ; len = netlink_send ( fd , message ) ; if ( len < 0 ) { syslog ( LOG_ERR , ""netlink_sendfailed;error:%d"" , len ) ; close ( fd ) ; exit ( EXIT_FAILURE ) ; } pfd . fd = fd ; while ( 1 ) { struct sockaddr * addr_p = ( struct sockaddr * ) & addr ; socklen_t addr_l = sizeof ( addr ) ; pfd . events = POLLIN ; pfd . revents = 0 ; poll ( & pfd , 1 , - 1 ) ; len = recvfrom ( fd , kvp_recv_buffer , sizeof ( kvp_recv_buffer ) , 0 , addr_p , & addr_l ) ; if ( len < 0 || addr . nl_pid ) { syslog ( LOG_ERR , ""recvfromfailed;pid:%uerror:%d%s"" , addr . nl_pid , errno , strerror ( errno ) ) ; close ( fd ) ; return - 1 ; } incoming_msg = ( struct nlmsghdr * ) kvp_recv_buffer ; incoming_cn_msg = ( struct cn_msg * ) NLMSG_DATA ( incoming_msg ) ; hv_msg = ( struct hv_kvp_msg * ) incoming_cn_msg -> data ; op = hv_msg -> kvp_hdr . operation ; pool = hv_msg -> kvp_hdr . pool ; hv_msg -> error = HV_S_OK ; if ( ( in_hand_shake ) && ( op == KVP_OP_REGISTER1 ) ) { in_hand_shake = 0 ; p = ( char * ) hv_msg -> body . kvp_register . version ; lic_version = malloc ( strlen ( p ) + 1 ) ; if ( lic_version ) { strcpy ( lic_version , p ) ; syslog ( LOG_INFO , ""KVPLICVersion:%s"" , lic_version ) ; } else { syslog ( LOG_ERR , ""mallocfailed"" ) ; } continue ; } switch ( op ) { case KVP_OP_GET_IP_INFO : kvp_ip_val = & hv_msg -> body . kvp_ip_val ; if_name = kvp_mac_to_if_name ( ( char * ) kvp_ip_val -> adapter_id ) ; if ( if_name == NULL ) { hv_msg -> error = HV_E_FAIL ; break ; } error = kvp_get_ip_info ( 0 , if_name , KVP_OP_GET_IP_INFO , kvp_ip_val , ( MAX_IP_ADDR_SIZE * 2 ) ) ; if ( error ) hv_msg -> error = error ; free ( if_name ) ; break ; case KVP_OP_SET_IP_INFO : kvp_ip_val = & hv_msg -> body . kvp_ip_val ; if_name = kvp_get_if_name ( ( char * ) kvp_ip_val -> adapter_id ) ; if ( if_name == NULL ) { hv_msg -> error = HV_GUID_NOTFOUND ; break ; } error = kvp_set_ip_info ( if_name , kvp_ip_val ) ; if ( error ) hv_msg -> error = error ; free ( if_name ) ; break ; case KVP_OP_SET : if ( kvp_key_add_or_modify ( pool , hv_msg -> body . kvp_set . data . key , hv_msg -> body . kvp_set . data . key_size , hv_msg -> body . kvp_set . data . value , hv_msg -> body . kvp_set . data . value_size ) ) hv_msg -> error = HV_S_CONT ; break ; case KVP_OP_GET : if ( kvp_get_value ( pool , hv_msg -> body . kvp_set . data . key , hv_msg -> body . kvp_set . data . key_size , hv_msg -> body . kvp_set . data . value , hv_msg -> body . kvp_set . data . value_size ) ) hv_msg -> error = HV_S_CONT ; break ; case KVP_OP_DELETE : if ( kvp_key_delete ( pool , hv_msg -> body . kvp_delete . key , hv_msg -> body . kvp_delete . key_size ) ) hv_msg -> error = HV_S_CONT ; break ; default : break ; } if ( op != KVP_OP_ENUMERATE ) goto kvp_done ; if ( pool != KVP_POOL_AUTO ) { if ( kvp_pool_enumerate ( pool , hv_msg -> body . kvp_enum_data . index , hv_msg -> body . kvp_enum_data . data . key , HV_KVP_EXCHANGE_MAX_KEY_SIZE , hv_msg -> body . kvp_enum_data . data . value , HV_KVP_EXCHANGE_MAX_VALUE_SIZE ) ) hv_msg -> error = HV_S_CONT ; goto kvp_done ; } hv_msg = ( struct hv_kvp_msg * ) incoming_cn_msg -> data ; key_name = ( char * ) hv_msg -> body . kvp_enum_data . data . key ; key_value = ( char * ) hv_msg -> body . kvp_enum_data . data . value ; switch ( hv_msg -> body . kvp_enum_data . index ) { case FullyQualifiedDomainName : kvp_get_domain_name ( key_value , HV_KVP_EXCHANGE_MAX_VALUE_SIZE ) ; strcpy ( key_name , ""FullyQualifiedDomainName"" ) ; break ; case IntegrationServicesVersion : strcpy ( key_name , ""IntegrationServicesVersion"" ) ; strcpy ( key_value , lic_version ) ; break ; case NetworkAddressIPv4 : kvp_get_ip_info ( AF_INET , NULL , KVP_OP_ENUMERATE , key_value , HV_KVP_EXCHANGE_MAX_VALUE_SIZE ) ; strcpy ( key_name , ""NetworkAddressIPv4"" ) ; break ; case NetworkAddressIPv6 : kvp_get_ip_info ( AF_INET6 , NULL , KVP_OP_ENUMERATE , key_value , HV_KVP_EXCHANGE_MAX_VALUE_SIZE ) ; strcpy ( key_name , ""NetworkAddressIPv6"" ) ; break ; case OSBuildNumber : strcpy ( key_value , os_build ) ; strcpy ( key_name , ""OSBuildNumber"" ) ; break ; case OSName : strcpy ( key_value , os_name ) ; strcpy ( key_name , ""OSName"" ) ; break ; case OSMajorVersion : strcpy ( key_value , os_major ) ; strcpy ( key_name , ""OSMajorVersion"" ) ; break ; case OSMinorVersion : strcpy ( key_value , os_minor ) ; strcpy ( key_name , ""OSMinorVersion"" ) ; break ; case OSVersion : strcpy ( key_value , os_version ) ; strcpy ( key_name , ""OSVersion"" ) ; break ; case ProcessorArchitecture : strcpy ( key_value , processor_arch ) ; strcpy ( key_name , ""ProcessorArchitecture"" ) ; break ; default : hv_msg -> error = HV_S_CONT ; break ; } kvp_done : incoming_cn_msg -> id . idx = CN_KVP_IDX ; incoming_cn_msg -> id . val = CN_KVP_VAL ; incoming_cn_msg -> ack = 0 ; incoming_cn_msg -> len = sizeof ( struct hv_kvp_msg ) ; len = netlink_send ( fd , incoming_cn_msg ) ; if ( len < 0 ) { syslog ( LOG_ERR , ""net_linksendfailed;error:%d"" , len ) ; exit ( EXIT_FAILURE ) ; } } } "," len < 0 ) { syslog 1 ; } if ( addr . nl_pid ) { syslog ( LOG_WARNING , ""Receivedpacketfromuntrustedpid:%u"" , addr . nl_pid ) ; continue ; } ",torvalds@linux/95a69adab9acfc3981c504737a2b6578e4d846ef,CVE-2012-5532,https://github.com/torvalds/linux/commit/95a69adab9acfc3981c504737a2b6578e4d846ef,2012-12-27T11:47Z 288,CWE-400,"CWE-400 int handle_unaligned_access ( insn_size_t instruction , struct pt_regs * regs , struct mem_access * ma , int expected , unsigned long address ) { u_int rm ; int ret , index ; if ( instruction_size ( instruction ) != 2 ) return - EINVAL ; index = ( instruction >> 8 ) & 15 ; rm = regs -> regs [ index ] ; if ( ! expected ) { unaligned_fixups_notify ( current , instruction , regs ) ; perf_sw_event ( PERF_COUNT_SW_ALIGNMENT_FAULTS , 1 , 0 , regs , address ) ; } ret = - EFAULT ; switch ( instruction & 0xF000 ) { case 0x0000 : if ( instruction == 0x000B ) { ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) regs -> pc = regs -> pr ; } else if ( ( instruction & 0x00FF ) == 0x0023 ) { ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) regs -> pc += rm + 4 ; } else if ( ( instruction & 0x00FF ) == 0x0003 ) { ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) { regs -> pr = regs -> pc + 4 ; regs -> pc += rm + 4 ; } } else { goto simple ; } break ; case 0x1000 : goto simple ; case 0x2000 : goto simple ; case 0x4000 : if ( ( instruction & 0x00FF ) == 0x002B ) { ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) regs -> pc = rm ; } else if ( ( instruction & 0x00FF ) == 0x000B ) { ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) { regs -> pr = regs -> pc + 4 ; regs -> pc = rm ; } } else { goto simple ; } break ; case 0x5000 : goto simple ; case 0x6000 : goto simple ; case 0x8000 : switch ( instruction & 0x0F00 ) { case 0x0100 : goto simple ; case 0x0500 : goto simple ; case 0x0B00 : break ; case 0x0F00 : ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) { # if defined ( CONFIG_CPU_SH4 ) || defined ( CONFIG_SH7705_CACHE_32KB ) if ( ( regs -> sr & 0x00000001 ) != 0 ) regs -> pc += 4 ; else # endif regs -> pc += SH_PC_8BIT_OFFSET ( instruction ) ; } break ; case 0x0900 : break ; case 0x0D00 : ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) { # if defined ( CONFIG_CPU_SH4 ) || defined ( CONFIG_SH7705_CACHE_32KB ) if ( ( regs -> sr & 0x00000001 ) == 0 ) regs -> pc += 4 ; else # endif regs -> pc += SH_PC_8BIT_OFFSET ( instruction ) ; } break ; } break ; case 0xA000 : ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) regs -> pc += SH_PC_12BIT_OFFSET ( instruction ) ; break ; case 0xB000 : ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) { regs -> pr = regs -> pc + 4 ; regs -> pc += SH_PC_12BIT_OFFSET ( instruction ) ; } break ; } return ret ; simple : ret = handle_unaligned_ins ( instruction , regs , ma ) ; if ( ret == 0 ) regs -> pc += instruction_size ( instruction ) ; return ret ; } "," , 1 , regs , address ",torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,CVE-2011-2918,https://github.com/torvalds/linux/commit/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,2012-05-24T23:55Z 289,CWE-399,"CWE-399 gboolean cib_notify_client ( gpointer key , gpointer value , gpointer user_data ) { const char * type = NULL ; gboolean do_send = FALSE ; cib_client_t * client = value ; xmlNode * update_msg = user_data ; CRM_CHECK ( client != NULL , return TRUE ) ; CRM_CHECK ( update_msg != NULL , return TRUE ) ; if ( client -> ipc == NULL ) { crm_warn ( ""SkippingclientwithNULLchannel"" ) ; return FALSE ; } type = crm_element_value ( update_msg , F_SUBTYPE ) ; CRM_LOG_ASSERT ( type != NULL ) ; if ( client -> diffs && safe_str_eq ( type , T_CIB_DIFF_NOTIFY ) ) { do_send = TRUE ; } else if ( client -> replace && safe_str_eq ( type , T_CIB_REPLACE_NOTIFY ) ) { do_send = TRUE ; } else if ( client -> confirmations && safe_str_eq ( type , T_CIB_UPDATE_CONFIRM ) ) { do_send = TRUE ; } else if ( client -> pre_notify && safe_str_eq ( type , T_CIB_PRE_NOTIFY ) ) { do_send = TRUE ; } else if ( client -> post_notify && safe_str_eq ( type , T_CIB_POST_NOTIFY ) ) { do_send = TRUE ; } if ( do_send ) { if ( client -> ipc ) { if ( crm_ipcs_send ( client -> ipc , 0 , update_msg , TRUE ) == FALSE ) { crm_warn ( ""Notificationofclient%s/%sfailed"" , client -> name , client -> id ) ; } # ifdef HAVE_GNUTLS_GNUTLS_H } else if ( client -> session ) { crm_debug ( ""Sent%snotificationtoclient%s/%s"" , type , client -> name , client -> id ) ; crm_send_remote_msg ( client -> session , update_msg , client -> encrypted ) ; # endif } else { crm_err ( ""Unknowntransportfor%s"" , client -> name ) ; } } return FALSE ; } "," ipc == NULL && client -> session == NULL ",ClusterLabs@pacemaker/564f7cc2a51dcd2f28ab12a13394f31be5aa3c93,CVE-2013-0281,https://github.com/ClusterLabs/pacemaker/commit/564f7cc2a51dcd2f28ab12a13394f31be5aa3c93,2013-11-23T11:55Z 290,CWE-787,"CWE-787 static PyObject * patch ( PyObject * self , PyObject * args ) { char * origData , * newData , * diffBlock , * extraBlock , * diffPtr , * extraPtr ; Py_ssize_t origDataLength , newDataLength , diffBlockLength , extraBlockLength ; PyObject * controlTuples , * tuple , * results ; off_t oldpos , newpos , x , y , z ; int i , j , numTuples ; if ( ! PyArg_ParseTuple ( args , ""s#nO!s#s#"" , & origData , & origDataLength , & newDataLength , & PyList_Type , & controlTuples , & diffBlock , & diffBlockLength , & extraBlock , & extraBlockLength ) ) return NULL ; newData = PyMem_Malloc ( newDataLength + 1 ) ; if ( ! newData ) return PyErr_NoMemory ( ) ; oldpos = 0 ; newpos = 0 ; diffPtr = diffBlock ; extraPtr = extraBlock ; numTuples = PyList_GET_SIZE ( controlTuples ) ; for ( i = 0 ; i < numTuples ; i ++ ) { tuple = PyList_GET_ITEM ( controlTuples , i ) ; if ( ! PyTuple_Check ( tuple ) ) { PyMem_Free ( newData ) ; PyErr_SetString ( PyExc_TypeError , ""expectingtuple"" ) ; return NULL ; } if ( PyTuple_GET_SIZE ( tuple ) != 3 ) { PyMem_Free ( newData ) ; PyErr_SetString ( PyExc_TypeError , ""expectingtupleofsize3"" ) ; return NULL ; } x = PyLong_AsLong ( PyTuple_GET_ITEM ( tuple , 0 ) ) ; y = PyLong_AsLong ( PyTuple_GET_ITEM ( tuple , 1 ) ) ; z = PyLong_AsLong ( PyTuple_GET_ITEM ( tuple , 2 ) ) ; if ( newpos + x > newDataLength || diffPtr + x > diffBlock + diffBlockLength || extraPtr + y > extraBlock + extraBlockLength ) { PyMem_Free ( newData ) ; PyErr_SetString ( PyExc_ValueError , ""corruptpatch(overflow)"" ) ; return NULL ; } memcpy ( newData + newpos , diffPtr , x ) ; diffPtr += x ; for ( j = 0 ; j < x ; j ++ ) if ( ( oldpos + j >= 0 ) && ( oldpos + j < origDataLength ) ) newData [ newpos + j ] += origData [ oldpos + j ] ; newpos += x ; oldpos += x ; memcpy ( newData + newpos , extraPtr , y ) ; extraPtr += y ; newpos += y ; oldpos += z ; } if ( newpos != newDataLength || diffPtr != diffBlock + diffBlockLength || extraPtr != extraBlock + extraBlockLength ) { PyMem_Free ( newData ) ; PyErr_SetString ( PyExc_ValueError , ""corruptpatch(underflow)"" ) ; return NULL ; } results = PyBytes_FromStringAndSize ( newData , newDataLength ) ; PyMem_Free ( newData ) ; return results ; } "," diffBlock + diffBlockLength ) { PyMem_Free ( newData ) ; PyErr_SetString ( PyExc_ValueError , ""corruptpatch(overflow)"" ) ; return NULL ; } memcpy ( newData + newpos , diffPtr , x ) ; diffPtr += x ; for ( j = 0 ; j < x ; j ++ ) if ( ( oldpos + j >= 0 ) && ( oldpos + j < origDataLength ) ) newData [ newpos + j ] += origData [ oldpos + j ] ; newpos += x ; oldpos += x ; if ( newpos + y > newDataLength NULL ; } memcpy ( newData ",ilanschnell@bsdiff4/49a4cee2feef7deaf9d89e5e793a8824930284d7,CVE-2020-15904,https://github.com/ilanschnell/bsdiff4/commit/49a4cee2feef7deaf9d89e5e793a8824930284d7,2020-07-22T23:15Z 291,CWE-17,"CWE-17 static struct fileIdentDesc * udf_find_entry ( struct inode * dir , const struct qstr * child , struct udf_fileident_bh * fibh , struct fileIdentDesc * cfi ) { struct fileIdentDesc * fi = NULL ; loff_t f_pos ; int block , flen ; unsigned char * fname = NULL ; unsigned char * nameptr ; uint8_t lfi ; uint16_t liu ; loff_t size ; struct kernel_lb_addr eloc ; uint32_t elen ; sector_t offset ; struct extent_position epos = { } ; struct udf_inode_info * dinfo = UDF_I ( dir ) ; int isdotdot = child -> len == 2 && child -> name [ 0 ] == '.' && child -> name [ 1 ] == '.' ; size = udf_ext0_offset ( dir ) + dir -> i_size ; f_pos = udf_ext0_offset ( dir ) ; fibh -> sbh = fibh -> ebh = NULL ; fibh -> soffset = fibh -> eoffset = f_pos & ( dir -> i_sb -> s_blocksize - 1 ) ; if ( dinfo -> i_alloc_type != ICBTAG_FLAG_AD_IN_ICB ) { if ( inode_bmap ( dir , f_pos >> dir -> i_sb -> s_blocksize_bits , & epos , & eloc , & elen , & offset ) != ( EXT_RECORDED_ALLOCATED >> 30 ) ) goto out_err ; block = udf_get_lb_pblock ( dir -> i_sb , & eloc , offset ) ; if ( ( ++ offset << dir -> i_sb -> s_blocksize_bits ) < elen ) { if ( dinfo -> i_alloc_type == ICBTAG_FLAG_AD_SHORT ) epos . offset -= sizeof ( struct short_ad ) ; else if ( dinfo -> i_alloc_type == ICBTAG_FLAG_AD_LONG ) epos . offset -= sizeof ( struct long_ad ) ; } else offset = 0 ; fibh -> sbh = fibh -> ebh = udf_tread ( dir -> i_sb , block ) ; if ( ! fibh -> sbh ) goto out_err ; } fname = kmalloc ( UDF_NAME_LEN , GFP_NOFS ) ; if ( ! fname ) goto out_err ; while ( f_pos < size ) { fi = udf_fileident_read ( dir , & f_pos , fibh , cfi , & epos , & eloc , & elen , & offset ) ; if ( ! fi ) goto out_err ; liu = le16_to_cpu ( cfi -> lengthOfImpUse ) ; lfi = cfi -> lengthFileIdent ; if ( fibh -> sbh == fibh -> ebh ) { nameptr = fi -> fileIdent + liu ; } else { int poffset ; poffset = fibh -> soffset + sizeof ( struct fileIdentDesc ) + liu + lfi ; if ( poffset >= lfi ) nameptr = ( uint8_t * ) ( fibh -> ebh -> b_data + poffset - lfi ) ; else { nameptr = fname ; memcpy ( nameptr , fi -> fileIdent + liu , lfi - poffset ) ; memcpy ( nameptr + lfi - poffset , fibh -> ebh -> b_data , poffset ) ; } } if ( ( cfi -> fileCharacteristics & FID_FILE_CHAR_DELETED ) != 0 ) { if ( ! UDF_QUERY_FLAG ( dir -> i_sb , UDF_FLAG_UNDELETE ) ) continue ; } if ( ( cfi -> fileCharacteristics & FID_FILE_CHAR_HIDDEN ) != 0 ) { if ( ! UDF_QUERY_FLAG ( dir -> i_sb , UDF_FLAG_UNHIDE ) ) continue ; } if ( ( cfi -> fileCharacteristics & FID_FILE_CHAR_PARENT ) && isdotdot ) goto out_ok ; if ( ! lfi ) continue ; flen = udf_get_filename ( dir -> i_sb , nameptr , fname , lfi ) ; if ( flen && udf_match ( flen , fname , child -> len , child -> name ) ) goto out_ok ; } out_err : fi = NULL ; if ( fibh -> sbh != fibh -> ebh ) brelse ( fibh -> ebh ) ; brelse ( fibh -> sbh ) ; out_ok : brelse ( epos . bh ) ; kfree ( fname ) ; return fi ; } "," , nameptr , lfi , fname , UDF_NAME_LEN ) ; if ",torvalds@linux/0e5cc9a40ada6046e6bc3bdfcd0c0d7e4b706b14,CVE-2014-9731,https://github.com/torvalds/linux/commit/0e5cc9a40ada6046e6bc3bdfcd0c0d7e4b706b14,2015-08-31T10:59Z 292,CWE-200,"CWE-200 static int do_ip_vs_get_ctl ( struct sock * sk , int cmd , void __user * user , int * len ) { unsigned char arg [ 128 ] ; int ret = 0 ; unsigned int copylen ; struct net * net = sock_net ( sk ) ; struct netns_ipvs * ipvs = net_ipvs ( net ) ; BUG_ON ( ! net ) ; if ( ! capable ( CAP_NET_ADMIN ) ) return - EPERM ; if ( cmd < IP_VS_BASE_CTL || cmd > IP_VS_SO_GET_MAX ) return - EINVAL ; if ( * len < get_arglen [ GET_CMDID ( cmd ) ] ) { pr_err ( ""get_ctl:len%u<%u\\n"" , * len , get_arglen [ GET_CMDID ( cmd ) ] ) ; return - EINVAL ; } copylen = get_arglen [ GET_CMDID ( cmd ) ] ; if ( copylen > 128 ) return - EINVAL ; if ( copy_from_user ( arg , user , copylen ) != 0 ) return - EFAULT ; if ( cmd == IP_VS_SO_GET_DAEMON ) { struct ip_vs_daemon_user d [ 2 ] ; memset ( & d , 0 , sizeof ( d ) ) ; if ( mutex_lock_interruptible ( & ipvs -> sync_mutex ) ) return - ERESTARTSYS ; if ( ipvs -> sync_state & IP_VS_STATE_MASTER ) { d [ 0 ] . state = IP_VS_STATE_MASTER ; strlcpy ( d [ 0 ] . mcast_ifn , ipvs -> master_mcast_ifn , sizeof ( d [ 0 ] . mcast_ifn ) ) ; d [ 0 ] . syncid = ipvs -> master_syncid ; } if ( ipvs -> sync_state & IP_VS_STATE_BACKUP ) { d [ 1 ] . state = IP_VS_STATE_BACKUP ; strlcpy ( d [ 1 ] . mcast_ifn , ipvs -> backup_mcast_ifn , sizeof ( d [ 1 ] . mcast_ifn ) ) ; d [ 1 ] . syncid = ipvs -> backup_syncid ; } if ( copy_to_user ( user , & d , sizeof ( d ) ) != 0 ) ret = - EFAULT ; mutex_unlock ( & ipvs -> sync_mutex ) ; return ret ; } if ( mutex_lock_interruptible ( & __ip_vs_mutex ) ) return - ERESTARTSYS ; switch ( cmd ) { case IP_VS_SO_GET_VERSION : { char buf [ 64 ] ; sprintf ( buf , ""IPVirtualServerversion%d.%d.%d(size=%d)"" , NVERSION ( IP_VS_VERSION_CODE ) , ip_vs_conn_tab_size ) ; if ( copy_to_user ( user , buf , strlen ( buf ) + 1 ) != 0 ) { ret = - EFAULT ; goto out ; } * len = strlen ( buf ) + 1 ; } break ; case IP_VS_SO_GET_INFO : { struct ip_vs_getinfo info ; info . version = IP_VS_VERSION_CODE ; info . size = ip_vs_conn_tab_size ; info . num_services = ipvs -> num_services ; if ( copy_to_user ( user , & info , sizeof ( info ) ) != 0 ) ret = - EFAULT ; } break ; case IP_VS_SO_GET_SERVICES : { struct ip_vs_get_services * get ; int size ; get = ( struct ip_vs_get_services * ) arg ; size = sizeof ( * get ) + sizeof ( struct ip_vs_service_entry ) * get -> num_services ; if ( * len != size ) { pr_err ( ""length:%u!=%u\\n"" , * len , size ) ; ret = - EINVAL ; goto out ; } ret = __ip_vs_get_service_entries ( net , get , user ) ; } break ; case IP_VS_SO_GET_SERVICE : { struct ip_vs_service_entry * entry ; struct ip_vs_service * svc ; union nf_inet_addr addr ; entry = ( struct ip_vs_service_entry * ) arg ; addr . ip = entry -> addr ; if ( entry -> fwmark ) svc = __ip_vs_svc_fwm_find ( net , AF_INET , entry -> fwmark ) ; else svc = __ip_vs_service_find ( net , AF_INET , entry -> protocol , & addr , entry -> port ) ; if ( svc ) { ip_vs_copy_service ( entry , svc ) ; if ( copy_to_user ( user , entry , sizeof ( * entry ) ) != 0 ) ret = - EFAULT ; } else ret = - ESRCH ; } break ; case IP_VS_SO_GET_DESTS : { struct ip_vs_get_dests * get ; int size ; get = ( struct ip_vs_get_dests * ) arg ; size = sizeof ( * get ) + sizeof ( struct ip_vs_dest_entry ) * get -> num_dests ; if ( * len != size ) { pr_err ( ""length:%u!=%u\\n"" , * len , size ) ; ret = - EINVAL ; goto out ; } ret = __ip_vs_get_dest_entries ( net , get , user ) ; } break ; case IP_VS_SO_GET_TIMEOUT : { struct ip_vs_timeout_user t ; __ip_vs_get_timeouts ( net , & t ) ; if ( copy_to_user ( user , & t , sizeof ( t ) ) != 0 ) ret = - EFAULT ; } break ; default : ret = - EINVAL ; } out : mutex_unlock ( & __ip_vs_mutex ) ; return ret ; } "," ip_vs_timeout_user t ; memset ( & t , 0 , sizeof ( t ) ) ; ",torvalds@linux/2d8a041b7bfe1097af21441cb77d6af95f4f4680,CVE-2012-6540,https://github.com/torvalds/linux/commit/2d8a041b7bfe1097af21441cb77d6af95f4f4680,2013-03-15T20:55Z 293,CWE-264,"CWE-264 static int tcp_v6_send_synack ( const struct sock * sk , struct dst_entry * dst , struct flowi * fl , struct request_sock * req , struct tcp_fastopen_cookie * foc , bool attach_req ) { struct inet_request_sock * ireq = inet_rsk ( req ) ; struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct flowi6 * fl6 = & fl -> u . ip6 ; struct sk_buff * skb ; int err = - ENOMEM ; if ( ! dst && ( dst = inet6_csk_route_req ( sk , fl6 , req , IPPROTO_TCP ) ) == NULL ) goto done ; skb = tcp_make_synack ( sk , dst , req , foc , attach_req ) ; if ( skb ) { __tcp_v6_send_check ( skb , & ireq -> ir_v6_loc_addr , & ireq -> ir_v6_rmt_addr ) ; fl6 -> daddr = ireq -> ir_v6_rmt_addr ; if ( np -> repflow && ireq -> pktopts ) fl6 -> flowlabel = ip6_flowlabel ( ipv6_hdr ( ireq -> pktopts ) ) ; err = ip6_xmit ( sk , skb , fl6 , np -> opt , np -> tclass ) ; err = net_xmit_eval ( err ) ; } done : return err ; } "," , fl6 , rcu_dereference ( np -> opt ) , np -> tclass ",torvalds@linux/45f6fad84cc305103b28d73482b344d7f5b76f39,CVE-2016-3841,https://github.com/torvalds/linux/commit/45f6fad84cc305103b28d73482b344d7f5b76f39,2016-08-06T20:59Z 294,CWE-264,"CWE-264 static ssize_t ib_ucm_write ( struct file * filp , const char __user * buf , size_t len , loff_t * pos ) { struct ib_ucm_file * file = filp -> private_data ; struct ib_ucm_cmd_hdr hdr ; ssize_t result ; if ( len < sizeof ( hdr ) ) return - EINVAL ; if ( copy_from_user ( & hdr , buf , sizeof ( hdr ) ) ) return - EFAULT ; if ( hdr . cmd >= ARRAY_SIZE ( ucm_cmd_table ) ) return - EINVAL ; if ( hdr . in + sizeof ( hdr ) > len ) return - EINVAL ; result = ucm_cmd_table [ hdr . cmd ] ( file , buf + sizeof ( hdr ) , hdr . in , hdr . out ) ; if ( ! result ) result = len ; return result ; } "," ; ssize_t result ; if ( WARN_ON_ONCE ( ! ib_safe_file_access ( filp ) ) ) return - EACCES ",torvalds@linux/e6bd18f57aad1a2d1ef40e646d03ed0f2515c9e3,CVE-2016-4565,https://github.com/torvalds/linux/commit/e6bd18f57aad1a2d1ef40e646d03ed0f2515c9e3,2016-05-23T10:59Z 295,CWE-264,"CWE-264 int cg_mkdir ( const char * path , mode_t mode ) { struct fuse_context * fc = fuse_get_context ( ) ; char * fpath = NULL , * path1 , * cgdir = NULL , * controller ; const char * cgroup ; int ret ; if ( ! fc ) return - EIO ; controller = pick_controller_from_path ( fc , path ) ; if ( ! controller ) return - EINVAL ; cgroup = find_cgroup_in_path ( path ) ; if ( ! cgroup ) return - EINVAL ; get_cgdir_and_path ( cgroup , & cgdir , & fpath ) ; if ( ! fpath ) path1 = ""/"" ; else path1 = cgdir ; if ( ! fc_may_access ( fc , controller , path1 , NULL , O_RDWR ) ) { ret = - EACCES ; goto out ; } if ( ! caller_is_in_ancestor ( fc -> pid , controller , path1 , NULL ) ) { ret = - EACCES ; goto out ; } ret = cgfs_create ( controller , cgroup , fc -> uid , fc -> gid ) ; printf ( ""cgfs_createreturned%dfor%s%s\\n"" , ret , controller , cgroup ) ; out : free ( cgdir ) ; return ret ; } "," , * controller , * next = NULL if ( ! caller_is_in_ancestor ( fc -> pid , controller , path1 , & next ) ) { ) ) { if ( fpath && strcmp ( next , fpath ) == 0 ) ret = - EEXIST ; else ret = - ENOENT ; goto out if ( ! fc_may_access ( fc , controller , path1 , NULL , O_RDWR ) ) { ret = - EACCES ; goto out ; } if ( ! cgdir ) ; free ( next ) ; ",lxc@lxcfs/a8b6c3e0537e90fba3c55910fd1b7229d54a60a7,CVE-2015-1342,https://github.com/lxc/lxcfs/commit/a8b6c3e0537e90fba3c55910fd1b7229d54a60a7,2015-12-07T20:59Z 296,CWE-476,"CWE-476 static void pcd_init_units ( void ) { struct pcd_unit * cd ; int unit ; pcd_drive_count = 0 ; for ( unit = 0 , cd = pcd ; unit < PCD_UNITS ; unit ++ , cd ++ ) { struct gendisk * disk = alloc_disk ( 1 ) ; if ( ! disk ) continue ; disk -> queue = blk_mq_init_sq_queue ( & cd -> tag_set , & pcd_mq_ops , 1 , BLK_MQ_F_SHOULD_MERGE ) ; if ( IS_ERR ( disk -> queue ) ) { disk -> queue = NULL ; continue ; } INIT_LIST_HEAD ( & cd -> rq_list ) ; disk -> queue -> queuedata = cd ; blk_queue_bounce_limit ( disk -> queue , BLK_BOUNCE_HIGH ) ; cd -> disk = disk ; cd -> pi = & cd -> pia ; cd -> present = 0 ; cd -> last_sense = 0 ; cd -> changed = 1 ; cd -> drive = ( * drives [ unit ] ) [ D_SLV ] ; if ( ( * drives [ unit ] ) [ D_PRT ] ) pcd_drive_count ++ ; cd -> name = & cd -> info . name [ 0 ] ; snprintf ( cd -> name , sizeof ( cd -> info . name ) , ""%s%d"" , name , unit ) ; cd -> info . ops = & pcd_dops ; cd -> info . handle = cd ; cd -> info . speed = 0 ; cd -> info . capacity = 1 ; cd -> info . mask = 0 ; disk -> major = major ; disk -> first_minor = unit ; strcpy ( disk -> disk_name , cd -> name ) ; disk -> fops = & pcd_bdops ; disk -> flags = GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE ; } } "," ) ) { put_disk ( disk ) ; ",torvalds@linux/f0d1762554014ce0ae347b9f0d088f2c157c8c72,CVE-2019-15923,https://github.com/torvalds/linux/commit/f0d1762554014ce0ae347b9f0d088f2c157c8c72,2019-09-04T19:15Z 297,CWE-125,"CWE-125 void ntlm_write_message_header ( wStream * s , NTLM_MESSAGE_HEADER * header ) { Stream_Write ( s , header -> Signature , sizeof ( NTLM_SIGNATURE ) ) ; Stream_Write_UINT32 ( s , header -> MessageType ) ; } "," static ",FreeRDP@FreeRDP/2ee663f39dc8dac3d9988e847db19b2d7e3ac8c6,CVE-2018-8789,https://github.com/FreeRDP/FreeRDP/commit/2ee663f39dc8dac3d9988e847db19b2d7e3ac8c6,2018-11-29T18:29Z 298,CWE-120,"CWE-120 static Image * ReadVIFFImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define VFF_CM_genericRGB 15 # define VFF_CM_ntscRGB 1 # define VFF_CM_NONE 0 # define VFF_DEP_DECORDER 0x4 # define VFF_DEP_NSORDER 0x8 # define VFF_DES_RAW 0 # define VFF_LOC_IMPLICIT 1 # define VFF_MAPTYP_NONE 0 # define VFF_MAPTYP_1_BYTE 1 # define VFF_MAPTYP_2_BYTE 2 # define VFF_MAPTYP_4_BYTE 4 # define VFF_MAPTYP_FLOAT 5 # define VFF_MAPTYP_DOUBLE 7 # define VFF_MS_NONE 0 # define VFF_MS_ONEPERBAND 1 # define VFF_MS_SHARED 3 # define VFF_TYP_BIT 0 # define VFF_TYP_1_BYTE 1 # define VFF_TYP_2_BYTE 2 # define VFF_TYP_4_BYTE 4 # define VFF_TYP_FLOAT 5 # define VFF_TYP_DOUBLE 9 typedef struct _ViffInfo { unsigned char identifier , file_type , release , version , machine_dependency , reserve [ 3 ] ; char comment [ 512 ] ; unsigned int rows , columns , subrows ; int x_offset , y_offset ; float x_bits_per_pixel , y_bits_per_pixel ; unsigned int location_type , location_dimension , number_of_images , number_data_bands , data_storage_type , data_encode_scheme , map_scheme , map_storage_type , map_rows , map_columns , map_subrows , map_enable , maps_per_cycle , color_space_model ; } ViffInfo ; double min_value , scale_factor , value ; Image * image ; int bit ; MagickBooleanType status ; MagickSizeType number_pixels ; register ssize_t x ; register Quantum * q ; register ssize_t i ; register unsigned char * p ; size_t bytes_per_pixel , max_packets , quantum ; ssize_t count , y ; unsigned char * pixels ; unsigned long lsb_first ; ViffInfo viff_info ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } count = ReadBlob ( image , 1 , & viff_info . identifier ) ; do { if ( ( count != 1 ) || ( ( unsigned char ) viff_info . identifier != 0xab ) ) ThrowReaderException ( CorruptImageError , ""NotAVIFFImage"" ) ; ( void ) ReadBlob ( image , sizeof ( viff_info . file_type ) , & viff_info . file_type ) ; ( void ) ReadBlob ( image , sizeof ( viff_info . release ) , & viff_info . release ) ; ( void ) ReadBlob ( image , sizeof ( viff_info . version ) , & viff_info . version ) ; ( void ) ReadBlob ( image , sizeof ( viff_info . machine_dependency ) , & viff_info . machine_dependency ) ; ( void ) ReadBlob ( image , sizeof ( viff_info . reserve ) , viff_info . reserve ) ; count = ReadBlob ( image , 512 , ( unsigned char * ) viff_info . comment ) ; viff_info . comment [ 511 ] = '\\0' ; if ( strlen ( viff_info . comment ) > 4 ) ( void ) SetImageProperty ( image , ""comment"" , viff_info . comment , exception ) ; if ( ( viff_info . machine_dependency == VFF_DEP_DECORDER ) || ( viff_info . machine_dependency == VFF_DEP_NSORDER ) ) image -> endian = LSBEndian ; else image -> endian = MSBEndian ; viff_info . rows = ReadBlobLong ( image ) ; viff_info . columns = ReadBlobLong ( image ) ; viff_info . subrows = ReadBlobLong ( image ) ; viff_info . x_offset = ReadBlobSignedLong ( image ) ; viff_info . y_offset = ReadBlobSignedLong ( image ) ; viff_info . x_bits_per_pixel = ( float ) ReadBlobLong ( image ) ; viff_info . y_bits_per_pixel = ( float ) ReadBlobLong ( image ) ; viff_info . location_type = ReadBlobLong ( image ) ; viff_info . location_dimension = ReadBlobLong ( image ) ; viff_info . number_of_images = ReadBlobLong ( image ) ; viff_info . number_data_bands = ReadBlobLong ( image ) ; viff_info . data_storage_type = ReadBlobLong ( image ) ; viff_info . data_encode_scheme = ReadBlobLong ( image ) ; viff_info . map_scheme = ReadBlobLong ( image ) ; viff_info . map_storage_type = ReadBlobLong ( image ) ; viff_info . map_rows = ReadBlobLong ( image ) ; viff_info . map_columns = ReadBlobLong ( image ) ; viff_info . map_subrows = ReadBlobLong ( image ) ; viff_info . map_enable = ReadBlobLong ( image ) ; viff_info . maps_per_cycle = ReadBlobLong ( image ) ; viff_info . color_space_model = ReadBlobLong ( image ) ; for ( i = 0 ; i < 420 ; i ++ ) ( void ) ReadBlobByte ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowReaderException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; image -> columns = viff_info . rows ; image -> rows = viff_info . columns ; image -> depth = viff_info . x_bits_per_pixel <= 8 ? 8UL : MAGICKCORE_QUANTUM_DEPTH ; number_pixels = ( MagickSizeType ) viff_info . columns * viff_info . rows ; if ( number_pixels != ( size_t ) number_pixels ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; if ( number_pixels == 0 ) ThrowReaderException ( CoderError , ""ImageColumnOrRowSizeIsNotSupported"" ) ; if ( ( viff_info . number_data_bands < 1 ) || ( viff_info . number_data_bands > 4 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ( viff_info . data_storage_type != VFF_TYP_BIT ) && ( viff_info . data_storage_type != VFF_TYP_1_BYTE ) && ( viff_info . data_storage_type != VFF_TYP_2_BYTE ) && ( viff_info . data_storage_type != VFF_TYP_4_BYTE ) && ( viff_info . data_storage_type != VFF_TYP_FLOAT ) && ( viff_info . data_storage_type != VFF_TYP_DOUBLE ) ) ThrowReaderException ( CoderError , ""DataStorageTypeIsNotSupported"" ) ; if ( viff_info . data_encode_scheme != VFF_DES_RAW ) ThrowReaderException ( CoderError , ""DataEncodingSchemeIsNotSupported"" ) ; if ( ( viff_info . map_storage_type != VFF_MAPTYP_NONE ) && ( viff_info . map_storage_type != VFF_MAPTYP_1_BYTE ) && ( viff_info . map_storage_type != VFF_MAPTYP_2_BYTE ) && ( viff_info . map_storage_type != VFF_MAPTYP_4_BYTE ) && ( viff_info . map_storage_type != VFF_MAPTYP_FLOAT ) && ( viff_info . map_storage_type != VFF_MAPTYP_DOUBLE ) ) ThrowReaderException ( CoderError , ""MapStorageTypeIsNotSupported"" ) ; if ( ( viff_info . color_space_model != VFF_CM_NONE ) && ( viff_info . color_space_model != VFF_CM_ntscRGB ) && ( viff_info . color_space_model != VFF_CM_genericRGB ) ) ThrowReaderException ( CoderError , ""ColorspaceModelIsNotSupported"" ) ; if ( viff_info . location_type != VFF_LOC_IMPLICIT ) ThrowReaderException ( CoderError , ""LocationTypeIsNotSupported"" ) ; if ( viff_info . number_of_images != 1 ) ThrowReaderException ( CoderError , ""NumberOfImagesIsNotSupported"" ) ; if ( viff_info . map_rows == 0 ) viff_info . map_scheme = VFF_MS_NONE ; switch ( ( int ) viff_info . map_scheme ) { case VFF_MS_NONE : { if ( viff_info . number_data_bands < 3 ) { if ( viff_info . data_storage_type == VFF_TYP_BIT ) image -> colors = 2 ; else if ( viff_info . data_storage_type == VFF_MAPTYP_1_BYTE ) image -> colors = 256UL ; else image -> colors = image -> depth <= 8 ? 256UL : 65536UL ; status = AcquireImageColormap ( image , image -> colors , exception ) ; if ( status == MagickFalse ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; } break ; } case VFF_MS_ONEPERBAND : case VFF_MS_SHARED : { unsigned char * viff_colormap ; switch ( ( int ) viff_info . map_storage_type ) { case VFF_MAPTYP_1_BYTE : bytes_per_pixel = 1 ; break ; case VFF_MAPTYP_2_BYTE : bytes_per_pixel = 2 ; break ; case VFF_MAPTYP_4_BYTE : bytes_per_pixel = 4 ; break ; case VFF_MAPTYP_FLOAT : bytes_per_pixel = 4 ; break ; case VFF_MAPTYP_DOUBLE : bytes_per_pixel = 8 ; break ; default : bytes_per_pixel = 1 ; break ; } image -> colors = viff_info . map_columns ; if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; if ( viff_info . map_rows > ( viff_info . map_rows * bytes_per_pixel * sizeof ( * viff_colormap ) ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; viff_colormap = ( unsigned char * ) AcquireQuantumMemory ( image -> colors , viff_info . map_rows * bytes_per_pixel * sizeof ( * viff_colormap ) ) ; if ( viff_colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; count = ReadBlob ( image , bytes_per_pixel * image -> colors * viff_info . map_rows , viff_colormap ) ; lsb_first = 1 ; if ( * ( char * ) & lsb_first && ( ( viff_info . machine_dependency != VFF_DEP_DECORDER ) && ( viff_info . machine_dependency != VFF_DEP_NSORDER ) ) ) switch ( ( int ) viff_info . map_storage_type ) { case VFF_MAPTYP_2_BYTE : { MSBOrderShort ( viff_colormap , ( bytes_per_pixel * image -> colors * viff_info . map_rows ) ) ; break ; } case VFF_MAPTYP_4_BYTE : case VFF_MAPTYP_FLOAT : { MSBOrderLong ( viff_colormap , ( bytes_per_pixel * image -> colors * viff_info . map_rows ) ) ; break ; } default : break ; } for ( i = 0 ; i < ( ssize_t ) ( viff_info . map_rows * image -> colors ) ; i ++ ) { switch ( ( int ) viff_info . map_storage_type ) { case VFF_MAPTYP_2_BYTE : value = 1.0 * ( ( short * ) viff_colormap ) [ i ] ; break ; case VFF_MAPTYP_4_BYTE : value = 1.0 * ( ( int * ) viff_colormap ) [ i ] ; break ; case VFF_MAPTYP_FLOAT : value = ( ( float * ) viff_colormap ) [ i ] ; break ; case VFF_MAPTYP_DOUBLE : value = ( ( double * ) viff_colormap ) [ i ] ; break ; default : value = 1.0 * viff_colormap [ i ] ; break ; } if ( i < ( ssize_t ) image -> colors ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( ( unsigned char ) value ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( ( unsigned char ) value ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( ( unsigned char ) value ) ; } else if ( i < ( ssize_t ) ( 2 * image -> colors ) ) image -> colormap [ i % image -> colors ] . green = ScaleCharToQuantum ( ( unsigned char ) value ) ; else if ( i < ( ssize_t ) ( 3 * image -> colors ) ) image -> colormap [ i % image -> colors ] . blue = ScaleCharToQuantum ( ( unsigned char ) value ) ; } viff_colormap = ( unsigned char * ) RelinquishMagickMemory ( viff_colormap ) ; break ; } default : ThrowReaderException ( CoderError , ""ColormapTypeNotSupported"" ) ; } image -> alpha_trait = viff_info . number_data_bands == 4 ? BlendPixelTrait : UndefinedPixelTrait ; image -> storage_class = ( viff_info . number_data_bands < 3 ? PseudoClass : DirectClass ) ; image -> columns = viff_info . rows ; image -> rows = viff_info . columns ; if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; switch ( ( int ) viff_info . data_storage_type ) { case VFF_TYP_2_BYTE : bytes_per_pixel = 2 ; break ; case VFF_TYP_4_BYTE : bytes_per_pixel = 4 ; break ; case VFF_TYP_FLOAT : bytes_per_pixel = 4 ; break ; case VFF_TYP_DOUBLE : bytes_per_pixel = 8 ; break ; default : bytes_per_pixel = 1 ; break ; } if ( viff_info . data_storage_type == VFF_TYP_BIT ) { if ( CheckMemoryOverflow ( ( image -> columns + 7UL ) >> 3UL , image -> rows ) != MagickFalse ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; max_packets = ( ( image -> columns + 7UL ) >> 3UL ) * image -> rows ; } else { if ( CheckMemoryOverflow ( number_pixels , viff_info . number_data_bands ) != MagickFalse ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; max_packets = ( size_t ) ( number_pixels * viff_info . number_data_bands ) ; } pixels = ( unsigned char * ) AcquireQuantumMemory ( MagickMax ( number_pixels , max_packets ) , bytes_per_pixel * sizeof ( * pixels ) ) ; if ( pixels == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; count = ReadBlob ( image , bytes_per_pixel * max_packets , pixels ) ; lsb_first = 1 ; if ( * ( char * ) & lsb_first && ( ( viff_info . machine_dependency != VFF_DEP_DECORDER ) && ( viff_info . machine_dependency != VFF_DEP_NSORDER ) ) ) switch ( ( int ) viff_info . data_storage_type ) { case VFF_TYP_2_BYTE : { MSBOrderShort ( pixels , bytes_per_pixel * max_packets ) ; break ; } case VFF_TYP_4_BYTE : case VFF_TYP_FLOAT : { MSBOrderLong ( pixels , bytes_per_pixel * max_packets ) ; break ; } default : break ; } min_value = 0.0 ; scale_factor = 1.0 ; if ( ( viff_info . data_storage_type != VFF_TYP_1_BYTE ) && ( viff_info . map_scheme == VFF_MS_NONE ) ) { double max_value ; switch ( ( int ) viff_info . data_storage_type ) { case VFF_TYP_2_BYTE : value = 1.0 * ( ( short * ) pixels ) [ 0 ] ; break ; case VFF_TYP_4_BYTE : value = 1.0 * ( ( int * ) pixels ) [ 0 ] ; break ; case VFF_TYP_FLOAT : value = ( ( float * ) pixels ) [ 0 ] ; break ; case VFF_TYP_DOUBLE : value = ( ( double * ) pixels ) [ 0 ] ; break ; default : value = 1.0 * pixels [ 0 ] ; break ; } max_value = value ; min_value = value ; for ( i = 0 ; i < ( ssize_t ) max_packets ; i ++ ) { switch ( ( int ) viff_info . data_storage_type ) { case VFF_TYP_2_BYTE : value = 1.0 * ( ( short * ) pixels ) [ i ] ; break ; case VFF_TYP_4_BYTE : value = 1.0 * ( ( int * ) pixels ) [ i ] ; break ; case VFF_TYP_FLOAT : value = ( ( float * ) pixels ) [ i ] ; break ; case VFF_TYP_DOUBLE : value = ( ( double * ) pixels ) [ i ] ; break ; default : value = 1.0 * pixels [ i ] ; break ; } if ( value > max_value ) max_value = value ; else if ( value < min_value ) min_value = value ; } if ( ( min_value == 0 ) && ( max_value == 0 ) ) scale_factor = 0 ; else if ( min_value == max_value ) { scale_factor = ( double ) QuantumRange / min_value ; min_value = 0 ; } else scale_factor = ( double ) QuantumRange / ( max_value - min_value ) ; } p = ( unsigned char * ) pixels ; for ( i = 0 ; i < ( ssize_t ) max_packets ; i ++ ) { switch ( ( int ) viff_info . data_storage_type ) { case VFF_TYP_2_BYTE : value = 1.0 * ( ( short * ) pixels ) [ i ] ; break ; case VFF_TYP_4_BYTE : value = 1.0 * ( ( int * ) pixels ) [ i ] ; break ; case VFF_TYP_FLOAT : value = ( ( float * ) pixels ) [ i ] ; break ; case VFF_TYP_DOUBLE : value = ( ( double * ) pixels ) [ i ] ; break ; default : value = 1.0 * pixels [ i ] ; break ; } if ( viff_info . map_scheme == VFF_MS_NONE ) { value = ( value - min_value ) * scale_factor ; if ( value > QuantumRange ) value = QuantumRange ; else if ( value < 0 ) value = 0 ; } * p = ( unsigned char ) ( ( Quantum ) value ) ; p ++ ; } p = ( unsigned char * ) pixels ; if ( viff_info . data_storage_type == VFF_TYP_BIT ) { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) ( image -> columns - 7 ) ; x += 8 ) { for ( bit = 0 ; bit < 8 ; bit ++ ) { quantum = ( size_t ) ( ( * p ) & ( 0x01 << bit ) ? 0 : 1 ) ; SetPixelRed ( image , quantum == 0 ? 0 : QuantumRange , q ) ; SetPixelGreen ( image , quantum == 0 ? 0 : QuantumRange , q ) ; SetPixelBlue ( image , quantum == 0 ? 0 : QuantumRange , q ) ; if ( image -> storage_class == PseudoClass ) SetPixelIndex ( image , ( Quantum ) quantum , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } if ( ( image -> columns % 8 ) != 0 ) { for ( bit = 0 ; bit < ( int ) ( image -> columns % 8 ) ; bit ++ ) { quantum = ( size_t ) ( ( * p ) & ( 0x01 << bit ) ? 0 : 1 ) ; SetPixelRed ( image , quantum == 0 ? 0 : QuantumRange , q ) ; SetPixelGreen ( image , quantum == 0 ? 0 : QuantumRange , q ) ; SetPixelBlue ( image , quantum == 0 ? 0 : QuantumRange , q ) ; if ( image -> storage_class == PseudoClass ) SetPixelIndex ( image , ( Quantum ) quantum , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } else if ( image -> storage_class == PseudoClass ) for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelIndex ( image , * p ++ , q ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } else { number_pixels = ( MagickSizeType ) image -> columns * image -> rows ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( image , ScaleCharToQuantum ( * p ) , q ) ; SetPixelGreen ( image , ScaleCharToQuantum ( * ( p + number_pixels ) ) , q ) ; SetPixelBlue ( image , ScaleCharToQuantum ( * ( p + 2 * number_pixels ) ) , q ) ; if ( image -> colors != 0 ) { ssize_t index ; index = ( ssize_t ) GetPixelRed ( image , q ) ; SetPixelRed ( image , image -> colormap [ ConstrainColormapIndex ( image , index , exception ) ] . red , q ) ; index = ( ssize_t ) GetPixelGreen ( image , q ) ; SetPixelGreen ( image , image -> colormap [ ConstrainColormapIndex ( image , index , exception ) ] . green , q ) ; index = ( ssize_t ) GetPixelBlue ( image , q ) ; SetPixelBlue ( image , image -> colormap [ ConstrainColormapIndex ( image , index , exception ) ] . blue , q ) ; } SetPixelAlpha ( image , image -> alpha_trait != UndefinedPixelTrait ? ScaleCharToQuantum ( * ( p + number_pixels * 3 ) ) : OpaqueAlpha , q ) ; p ++ ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } pixels = ( unsigned char * ) RelinquishMagickMemory ( pixels ) ; if ( image -> storage_class == PseudoClass ) ( void ) SyncImage ( image , exception ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; count = ReadBlob ( image , 1 , & viff_info . identifier ) ; if ( ( count != 0 ) && ( viff_info . identifier == 0xab ) ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( ( count != 0 ) && ( viff_info . identifier == 0xab ) ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," { if ( HeapOverflowSanityCheck ( ( image { if ( HeapOverflowSanityCheck ( number_pixels , ",ImageMagick@ImageMagick/e45e48b881038487d0bc94d92a16c1537616cc0a,CVE-2016-10066,https://github.com/ImageMagick/ImageMagick/commit/e45e48b881038487d0bc94d92a16c1537616cc0a,2017-03-03T17:59Z 299,CWE-399,"CWE-399 static int asf_build_simple_index ( AVFormatContext * s , int stream_index ) { ff_asf_guid g ; ASFContext * asf = s -> priv_data ; int64_t current_pos = avio_tell ( s -> pb ) ; int64_t ret ; if ( ( ret = avio_seek ( s -> pb , asf -> data_object_offset + asf -> data_object_size , SEEK_SET ) ) < 0 ) { return ret ; } if ( ( ret = ff_get_guid ( s -> pb , & g ) ) < 0 ) goto end ; while ( ff_guidcmp ( & g , & ff_asf_simple_index_header ) ) { int64_t gsize = avio_rl64 ( s -> pb ) ; if ( gsize < 24 || avio_feof ( s -> pb ) ) { goto end ; } avio_skip ( s -> pb , gsize - 24 ) ; if ( ( ret = ff_get_guid ( s -> pb , & g ) ) < 0 ) goto end ; } { int64_t itime , last_pos = - 1 ; int pct , ict ; int i ; int64_t av_unused gsize = avio_rl64 ( s -> pb ) ; if ( ( ret = ff_get_guid ( s -> pb , & g ) ) < 0 ) goto end ; itime = avio_rl64 ( s -> pb ) ; pct = avio_rl32 ( s -> pb ) ; ict = avio_rl32 ( s -> pb ) ; av_log ( s , AV_LOG_DEBUG , ""itime:0x%"" PRIx64 "",pct:%d,ict:%d\\n"" , itime , pct , ict ) ; for ( i = 0 ; i < ict ; i ++ ) { int pktnum = avio_rl32 ( s -> pb ) ; int pktct = avio_rl16 ( s -> pb ) ; int64_t pos = s -> internal -> data_offset + s -> packet_size * ( int64_t ) pktnum ; int64_t index_pts = FFMAX ( av_rescale ( itime , i , 10000 ) - asf -> hdr . preroll , 0 ) ; if ( pos != last_pos ) { av_log ( s , AV_LOG_DEBUG , ""pktnum:%d,pktct:%dpts:%"" PRId64 ""\\n"" , pktnum , pktct , index_pts ) ; av_add_index_entry ( s -> streams [ stream_index ] , pos , index_pts , s -> packet_size , 0 , AVINDEX_KEYFRAME ) ; last_pos = pos ; } } asf -> index_read = ict > 1 ; } end : avio_seek ( s -> pb , current_pos , SEEK_SET ) ; return ret ; } "," 0 ) ; if ( avio_feof ( s -> pb ) ) { ret = AVERROR_INVALIDDATA ; goto end ; } ",FFmpeg@FFmpeg/afc9c683ed9db01edb357bc8c19edad4282b3a97,CVE-2017-14223,https://github.com/FFmpeg/FFmpeg/commit/afc9c683ed9db01edb357bc8c19edad4282b3a97,2017-09-09T01:29Z 300,CWE-200,"CWE-200 static long sg_ioctl ( struct file * filp , unsigned int cmd_in , unsigned long arg ) { void __user * p = ( void __user * ) arg ; int __user * ip = p ; int result , val , read_only ; Sg_device * sdp ; Sg_fd * sfp ; Sg_request * srp ; unsigned long iflags ; if ( ( ! ( sfp = ( Sg_fd * ) filp -> private_data ) ) || ( ! ( sdp = sfp -> parentdp ) ) ) return - ENXIO ; SCSI_LOG_TIMEOUT ( 3 , sg_printk ( KERN_INFO , sdp , ""sg_ioctl:cmd=0x%x\\n"" , ( int ) cmd_in ) ) ; read_only = ( O_RDWR != ( filp -> f_flags & O_ACCMODE ) ) ; switch ( cmd_in ) { case SG_IO : if ( atomic_read ( & sdp -> detaching ) ) return - ENODEV ; if ( ! scsi_block_when_processing_errors ( sdp -> device ) ) return - ENXIO ; if ( ! access_ok ( VERIFY_WRITE , p , SZ_SG_IO_HDR ) ) return - EFAULT ; result = sg_new_write ( sfp , filp , p , SZ_SG_IO_HDR , 1 , read_only , 1 , & srp ) ; if ( result < 0 ) return result ; result = wait_event_interruptible ( sfp -> read_wait , ( srp_done ( sfp , srp ) || atomic_read ( & sdp -> detaching ) ) ) ; if ( atomic_read ( & sdp -> detaching ) ) return - ENODEV ; write_lock_irq ( & sfp -> rq_list_lock ) ; if ( srp -> done ) { srp -> done = 2 ; write_unlock_irq ( & sfp -> rq_list_lock ) ; result = sg_new_read ( sfp , p , SZ_SG_IO_HDR , srp ) ; return ( result < 0 ) ? result : 0 ; } srp -> orphan = 1 ; write_unlock_irq ( & sfp -> rq_list_lock ) ; return result ; case SG_SET_TIMEOUT : result = get_user ( val , ip ) ; if ( result ) return result ; if ( val < 0 ) return - EIO ; if ( val >= mult_frac ( ( s64 ) INT_MAX , USER_HZ , HZ ) ) val = min_t ( s64 , mult_frac ( ( s64 ) INT_MAX , USER_HZ , HZ ) , INT_MAX ) ; sfp -> timeout_user = val ; sfp -> timeout = mult_frac ( val , HZ , USER_HZ ) ; return 0 ; case SG_GET_TIMEOUT : return sfp -> timeout_user ; case SG_SET_FORCE_LOW_DMA : return 0 ; case SG_GET_LOW_DMA : return put_user ( ( int ) sdp -> device -> host -> unchecked_isa_dma , ip ) ; case SG_GET_SCSI_ID : if ( ! access_ok ( VERIFY_WRITE , p , sizeof ( sg_scsi_id_t ) ) ) return - EFAULT ; else { sg_scsi_id_t __user * sg_idp = p ; if ( atomic_read ( & sdp -> detaching ) ) return - ENODEV ; __put_user ( ( int ) sdp -> device -> host -> host_no , & sg_idp -> host_no ) ; __put_user ( ( int ) sdp -> device -> channel , & sg_idp -> channel ) ; __put_user ( ( int ) sdp -> device -> id , & sg_idp -> scsi_id ) ; __put_user ( ( int ) sdp -> device -> lun , & sg_idp -> lun ) ; __put_user ( ( int ) sdp -> device -> type , & sg_idp -> scsi_type ) ; __put_user ( ( short ) sdp -> device -> host -> cmd_per_lun , & sg_idp -> h_cmd_per_lun ) ; __put_user ( ( short ) sdp -> device -> queue_depth , & sg_idp -> d_queue_depth ) ; __put_user ( 0 , & sg_idp -> unused [ 0 ] ) ; __put_user ( 0 , & sg_idp -> unused [ 1 ] ) ; return 0 ; } case SG_SET_FORCE_PACK_ID : result = get_user ( val , ip ) ; if ( result ) return result ; sfp -> force_packid = val ? 1 : 0 ; return 0 ; case SG_GET_PACK_ID : if ( ! access_ok ( VERIFY_WRITE , ip , sizeof ( int ) ) ) return - EFAULT ; read_lock_irqsave ( & sfp -> rq_list_lock , iflags ) ; list_for_each_entry ( srp , & sfp -> rq_list , entry ) { if ( ( 1 == srp -> done ) && ( ! srp -> sg_io_owned ) ) { read_unlock_irqrestore ( & sfp -> rq_list_lock , iflags ) ; __put_user ( srp -> header . pack_id , ip ) ; return 0 ; } } read_unlock_irqrestore ( & sfp -> rq_list_lock , iflags ) ; __put_user ( - 1 , ip ) ; return 0 ; case SG_GET_NUM_WAITING : read_lock_irqsave ( & sfp -> rq_list_lock , iflags ) ; val = 0 ; list_for_each_entry ( srp , & sfp -> rq_list , entry ) { if ( ( 1 == srp -> done ) && ( ! srp -> sg_io_owned ) ) ++ val ; } read_unlock_irqrestore ( & sfp -> rq_list_lock , iflags ) ; return put_user ( val , ip ) ; case SG_GET_SG_TABLESIZE : return put_user ( sdp -> sg_tablesize , ip ) ; case SG_SET_RESERVED_SIZE : result = get_user ( val , ip ) ; if ( result ) return result ; if ( val < 0 ) return - EINVAL ; val = min_t ( int , val , max_sectors_bytes ( sdp -> device -> request_queue ) ) ; mutex_lock ( & sfp -> f_mutex ) ; if ( val != sfp -> reserve . bufflen ) { if ( sfp -> mmap_called || sfp -> res_in_use ) { mutex_unlock ( & sfp -> f_mutex ) ; return - EBUSY ; } sg_remove_scat ( sfp , & sfp -> reserve ) ; sg_build_reserve ( sfp , val ) ; } mutex_unlock ( & sfp -> f_mutex ) ; return 0 ; case SG_GET_RESERVED_SIZE : val = min_t ( int , sfp -> reserve . bufflen , max_sectors_bytes ( sdp -> device -> request_queue ) ) ; return put_user ( val , ip ) ; case SG_SET_COMMAND_Q : result = get_user ( val , ip ) ; if ( result ) return result ; sfp -> cmd_q = val ? 1 : 0 ; return 0 ; case SG_GET_COMMAND_Q : return put_user ( ( int ) sfp -> cmd_q , ip ) ; case SG_SET_KEEP_ORPHAN : result = get_user ( val , ip ) ; if ( result ) return result ; sfp -> keep_orphan = val ; return 0 ; case SG_GET_KEEP_ORPHAN : return put_user ( ( int ) sfp -> keep_orphan , ip ) ; case SG_NEXT_CMD_LEN : result = get_user ( val , ip ) ; if ( result ) return result ; if ( val > SG_MAX_CDB_SIZE ) return - ENOMEM ; sfp -> next_cmd_len = ( val > 0 ) ? val : 0 ; return 0 ; case SG_GET_VERSION_NUM : return put_user ( sg_version_num , ip ) ; case SG_GET_ACCESS_COUNT : val = ( sdp -> device ? 1 : 0 ) ; return put_user ( val , ip ) ; case SG_GET_REQUEST_TABLE : if ( ! access_ok ( VERIFY_WRITE , p , SZ_SG_REQ_INFO * SG_MAX_QUEUE ) ) return - EFAULT ; else { sg_req_info_t * rinfo ; rinfo = kmalloc ( SZ_SG_REQ_INFO * SG_MAX_QUEUE , GFP_KERNEL ) ; if ( ! rinfo ) return - ENOMEM ; read_lock_irqsave ( & sfp -> rq_list_lock , iflags ) ; sg_fill_request_table ( sfp , rinfo ) ; read_unlock_irqrestore ( & sfp -> rq_list_lock , iflags ) ; result = __copy_to_user ( p , rinfo , SZ_SG_REQ_INFO * SG_MAX_QUEUE ) ; result = result ? - EFAULT : 0 ; kfree ( rinfo ) ; return result ; } case SG_EMULATED_HOST : if ( atomic_read ( & sdp -> detaching ) ) return - ENODEV ; return put_user ( sdp -> device -> host -> hostt -> emulated , ip ) ; case SCSI_IOCTL_SEND_COMMAND : if ( atomic_read ( & sdp -> detaching ) ) return - ENODEV ; if ( read_only ) { unsigned char opcode = WRITE_6 ; Scsi_Ioctl_Command __user * siocp = p ; if ( copy_from_user ( & opcode , siocp -> data , 1 ) ) return - EFAULT ; if ( sg_allow_access ( filp , & opcode ) ) return - EPERM ; } return sg_scsi_ioctl ( sdp -> device -> request_queue , NULL , filp -> f_mode , p ) ; case SG_SET_DEBUG : result = get_user ( val , ip ) ; if ( result ) return result ; sdp -> sgdebug = ( char ) val ; return 0 ; case BLKSECTGET : return put_user ( max_sectors_bytes ( sdp -> device -> request_queue ) , ip ) ; case BLKTRACESETUP : return blk_trace_setup ( sdp -> device -> request_queue , sdp -> disk -> disk_name , MKDEV ( SCSI_GENERIC_MAJOR , sdp -> index ) , NULL , p ) ; case BLKTRACESTART : return blk_trace_startstop ( sdp -> device -> request_queue , 1 ) ; case BLKTRACESTOP : return blk_trace_startstop ( sdp -> device -> request_queue , 0 ) ; case BLKTRACETEARDOWN : return blk_trace_remove ( sdp -> device -> request_queue ) ; case SCSI_IOCTL_GET_IDLUN : case SCSI_IOCTL_GET_BUS_NUMBER : case SCSI_IOCTL_PROBE_HOST : case SG_GET_TRANSFORM : case SG_SCSI_RESET : if ( atomic_read ( & sdp -> detaching ) ) return - ENODEV ; break ; default : if ( read_only ) return - EPERM ; break ; } result = scsi_ioctl_block_when_processing_errors ( sdp -> device , cmd_in , filp -> f_flags & O_NDELAY ) ; if ( result ) return result ; return scsi_ioctl ( sdp -> device , cmd_in , p ) ; } "," ; rinfo = kzalloc ( SZ_SG_REQ_INFO * ",torvalds@linux/3e0097499839e0fe3af380410eababe5a47c4cf9,CVE-2017-14991,https://github.com/torvalds/linux/commit/3e0097499839e0fe3af380410eababe5a47c4cf9,2017-10-04T01:29Z 301,CWE-200,"CWE-200 void init_global_keywords ( bool global_active ) { install_keyword_root ( ""linkbeat_use_polling"" , use_polling_handler , global_active ) ; # if HAVE_DECL_CLONE_NEWNET install_keyword_root ( ""net_namespace"" , & net_namespace_handler , global_active ) ; install_keyword_root ( ""namespace_with_ipsets"" , & namespace_ipsets_handler , global_active ) ; # endif install_keyword_root ( ""use_pid_dir"" , & use_pid_dir_handler , global_active ) ; install_keyword_root ( ""instance"" , & instance_handler , global_active ) ; install_keyword_root ( ""child_wait_time"" , & child_wait_handler , global_active ) ; install_keyword_root ( ""global_defs"" , NULL , global_active ) ; install_keyword ( ""router_id"" , & routerid_handler ) ; install_keyword ( ""notification_email_from"" , & emailfrom_handler ) ; install_keyword ( ""smtp_server"" , & smtpserver_handler ) ; install_keyword ( ""smtp_helo_name"" , & smtphelo_handler ) ; install_keyword ( ""smtp_connect_timeout"" , & smtpto_handler ) ; install_keyword ( ""notification_email"" , & email_handler ) ; install_keyword ( ""smtp_alert"" , & smtp_alert_handler ) ; # ifdef _WITH_VRRP_ install_keyword ( ""smtp_alert_vrrp"" , & smtp_alert_vrrp_handler ) ; # endif # ifdef _WITH_LVS_ install_keyword ( ""smtp_alert_checker"" , & smtp_alert_checker_handler ) ; # endif # ifdef _WITH_VRRP_ install_keyword ( ""dynamic_interfaces"" , & dynamic_interfaces_handler ) ; install_keyword ( ""no_email_faults"" , & no_email_faults_handler ) ; install_keyword ( ""default_interface"" , & default_interface_handler ) ; # endif # ifdef _WITH_LVS_ install_keyword ( ""lvs_timeouts"" , & lvs_timeouts ) ; install_keyword ( ""lvs_flush"" , & lvs_flush_handler ) ; # ifdef _WITH_VRRP_ install_keyword ( ""lvs_sync_daemon"" , & lvs_syncd_handler ) ; # endif # endif # ifdef _WITH_VRRP_ install_keyword ( ""vrrp_mcast_group4"" , & vrrp_mcast_group4_handler ) ; install_keyword ( ""vrrp_mcast_group6"" , & vrrp_mcast_group6_handler ) ; install_keyword ( ""vrrp_garp_master_delay"" , & vrrp_garp_delay_handler ) ; install_keyword ( ""vrrp_garp_master_repeat"" , & vrrp_garp_rep_handler ) ; install_keyword ( ""vrrp_garp_master_refresh"" , & vrrp_garp_refresh_handler ) ; install_keyword ( ""vrrp_garp_master_refresh_repeat"" , & vrrp_garp_refresh_rep_handler ) ; install_keyword ( ""vrrp_garp_lower_prio_delay"" , & vrrp_garp_lower_prio_delay_handler ) ; install_keyword ( ""vrrp_garp_lower_prio_repeat"" , & vrrp_garp_lower_prio_rep_handler ) ; install_keyword ( ""vrrp_garp_interval"" , & vrrp_garp_interval_handler ) ; install_keyword ( ""vrrp_gna_interval"" , & vrrp_gna_interval_handler ) ; install_keyword ( ""vrrp_lower_prio_no_advert"" , & vrrp_lower_prio_no_advert_handler ) ; install_keyword ( ""vrrp_higher_prio_send_advert"" , & vrrp_higher_prio_send_advert_handler ) ; install_keyword ( ""vrrp_version"" , & vrrp_version_handler ) ; install_keyword ( ""vrrp_iptables"" , & vrrp_iptables_handler ) ; # ifdef _HAVE_LIBIPSET_ install_keyword ( ""vrrp_ipsets"" , & vrrp_ipsets_handler ) ; # endif install_keyword ( ""vrrp_check_unicast_src"" , & vrrp_check_unicast_src_handler ) ; install_keyword ( ""vrrp_skip_check_adv_addr"" , & vrrp_check_adv_addr_handler ) ; install_keyword ( ""vrrp_strict"" , & vrrp_strict_handler ) ; install_keyword ( ""vrrp_priority"" , & vrrp_prio_handler ) ; install_keyword ( ""vrrp_no_swap"" , & vrrp_no_swap_handler ) ; # ifdef _HAVE_SCHED_RT_ install_keyword ( ""vrrp_rt_priority"" , & vrrp_rt_priority_handler ) ; # if HAVE_DECL_RLIMIT_RTTIME == 1 install_keyword ( ""vrrp_rlimit_rtime"" , & vrrp_rt_rlimit_handler ) ; # endif # endif # endif install_keyword ( ""notify_fifo"" , & global_notify_fifo ) ; install_keyword ( ""notify_fifo_script"" , & global_notify_fifo_script ) ; # ifdef _WITH_VRRP_ install_keyword ( ""vrrp_notify_fifo"" , & vrrp_notify_fifo ) ; install_keyword ( ""vrrp_notify_fifo_script"" , & vrrp_notify_fifo_script ) ; # endif # ifdef _WITH_LVS_ install_keyword ( ""lvs_notify_fifo"" , & lvs_notify_fifo ) ; install_keyword ( ""lvs_notify_fifo_script"" , & lvs_notify_fifo_script ) ; install_keyword ( ""checker_priority"" , & checker_prio_handler ) ; install_keyword ( ""checker_no_swap"" , & checker_no_swap_handler ) ; # ifdef _HAVE_SCHED_RT_ install_keyword ( ""checker_rt_priority"" , & checker_rt_priority_handler ) ; # if HAVE_DECL_RLIMIT_RTTIME == 1 install_keyword ( ""checker_rlimit_rtime"" , & checker_rt_rlimit_handler ) ; # endif # endif # endif # ifdef _WITH_BFD_ install_keyword ( ""bfd_priority"" , & bfd_prio_handler ) ; install_keyword ( ""bfd_no_swap"" , & bfd_no_swap_handler ) ; # ifdef _HAVE_SCHED_RT_ install_keyword ( ""bfd_rt_priority"" , & bfd_rt_priority_handler ) ; # if HAVE_DECL_RLIMIT_RTTIME == 1 install_keyword ( ""bfd_rlimit_rtime"" , & bfd_rt_rlimit_handler ) ; # endif # endif # endif # ifdef _WITH_SNMP_ install_keyword ( ""snmp_socket"" , & snmp_socket_handler ) ; install_keyword ( ""enable_traps"" , & trap_handler ) ; # ifdef _WITH_SNMP_VRRP_ install_keyword ( ""enable_snmp_vrrp"" , & snmp_vrrp_handler ) ; install_keyword ( ""enable_snmp_keepalived"" , & snmp_vrrp_handler ) ; # endif # ifdef _WITH_SNMP_RFC_ install_keyword ( ""enable_snmp_rfc"" , & snmp_rfc_handler ) ; # endif # ifdef _WITH_SNMP_RFCV2_ install_keyword ( ""enable_snmp_rfcv2"" , & snmp_rfcv2_handler ) ; # endif # ifdef _WITH_SNMP_RFCV3_ install_keyword ( ""enable_snmp_rfcv3"" , & snmp_rfcv3_handler ) ; # endif # ifdef _WITH_SNMP_CHECKER_ install_keyword ( ""enable_snmp_checker"" , & snmp_checker_handler ) ; # endif # endif # ifdef _WITH_DBUS_ install_keyword ( ""enable_dbus"" , & enable_dbus_handler ) ; install_keyword ( ""dbus_service_name"" , & dbus_service_name_handler ) ; # endif install_keyword ( ""script_user"" , & script_user_handler ) ; install_keyword ( ""enable_script_security"" , & script_security_handler ) ; # ifdef _WITH_VRRP_ install_keyword ( ""vrrp_netlink_cmd_rcv_bufs"" , & vrrp_netlink_cmd_rcv_bufs_handler ) ; install_keyword ( ""vrrp_netlink_cmd_rcv_bufs_force"" , & vrrp_netlink_cmd_rcv_bufs_force_handler ) ; install_keyword ( ""vrrp_netlink_monitor_rcv_bufs"" , & vrrp_netlink_monitor_rcv_bufs_handler ) ; install_keyword ( ""vrrp_netlink_monitor_rcv_bufs_force"" , & vrrp_netlink_monitor_rcv_bufs_force_handler ) ; # endif # ifdef _WITH_LVS_ install_keyword ( ""lvs_netlink_cmd_rcv_bufs"" , & lvs_netlink_cmd_rcv_bufs_handler ) ; install_keyword ( ""lvs_netlink_cmd_rcv_bufs_force"" , & lvs_netlink_cmd_rcv_bufs_force_handler ) ; install_keyword ( ""lvs_netlink_monitor_rcv_bufs"" , & lvs_netlink_monitor_rcv_bufs_handler ) ; install_keyword ( ""lvs_netlink_monitor_rcv_bufs_force"" , & lvs_netlink_monitor_rcv_bufs_force_handler ) ; # endif # ifdef _WITH_LVS_ install_keyword ( ""rs_init_notifies"" , & rs_init_notifies_handler ) ; install_keyword ( ""no_checker_emails"" , & no_checker_emails_handler ) ; # endif # ifdef _WITH_VRRP_ install_keyword ( ""vrrp_rx_bufs_policy"" , & vrrp_rx_bufs_policy_handler ) ; install_keyword ( ""vrrp_rx_bufs_multiplier"" , & vrrp_rx_bufs_multiplier_handler ) ; # endif } "," ; # endif install_keyword ( ""umask"" , & umask_handler ) ; ",acassen@keepalived/c6247a9ef2c7b33244ab1d3aa5d629ec49f0a067,CVE-2018-19045,https://github.com/acassen/keepalived/commit/c6247a9ef2c7b33244ab1d3aa5d629ec49f0a067,2018-11-08T20:29Z 302,CWE-119,"CWE-119 static vpx_codec_err_t encoder_init ( vpx_codec_ctx_t * ctx , vpx_codec_priv_enc_mr_cfg_t * data ) { return encoder_common_init ( ctx ) ; } "," data ) { vpx_codec_err_t res = VPX_CODEC_OK ; ( void ) data ; if ( ctx -> priv == NULL ) { vpx_codec_alg_priv_t * const priv = vpx_calloc ( 1 , sizeof ( * priv ) ) ; if ( priv == NULL ) return VPX_CODEC_MEM_ERROR ; ctx -> priv = ( vpx_codec_priv_t * ) priv ; ctx -> priv -> init_flags = ctx -> init_flags ; ctx -> priv -> enc . total_encoders = 1 ; priv -> buffer_pool = ( BufferPool * ) vpx_calloc ( 1 , sizeof ( BufferPool ) ) ; if ( priv -> buffer_pool == NULL ) return VPX_CODEC_MEM_ERROR ; # if CONFIG_MULTITHREAD if ( pthread_mutex_init ( & priv -> buffer_pool -> pool_mutex , NULL ) ) { return VPX_CODEC_MEM_ERROR ; } # endif if ( ctx -> config . enc ) { priv -> cfg = * ctx -> config . enc ; ctx -> config . enc = & priv -> cfg ; } priv -> extra_cfg = default_extra_cfg ; once ( vp9_initialize_enc ) ; res = validate_config ( priv , & priv -> cfg , & priv -> extra_cfg ) ; if ( res == VPX_CODEC_OK ) { set_encoder_config ( & priv -> oxcf , & priv -> cfg , & priv -> extra_cfg ) ; # if CONFIG_VP9_HIGHBITDEPTH priv -> oxcf . use_highbitdepth = ( ctx -> init_flags & VPX_CODEC_USE_HIGHBITDEPTH ) ? 1 : 0 ; # endif priv -> cpi = vp9_create_compressor ( & priv -> oxcf , priv -> buffer_pool ) ; if ( priv -> cpi == NULL ) res = VPX_CODEC_MEM_ERROR ; else priv -> cpi -> output_pkt_list = & priv -> pkt_list . head ; } } return res ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 303,CWE-119,"CWE-119 int iscsi_decode_text_input ( u8 phase , u8 sender , char * textbuf , u32 length , struct iscsi_conn * conn ) { struct iscsi_param_list * param_list = conn -> param_list ; char * tmpbuf , * start = NULL , * end = NULL ; tmpbuf = kzalloc ( length + 1 , GFP_KERNEL ) ; if ( ! tmpbuf ) { pr_err ( ""Unabletoallocatememoryfortmpbuf.\\n"" ) ; return - 1 ; } memcpy ( tmpbuf , textbuf , length ) ; tmpbuf [ length ] = '\\0' ; start = tmpbuf ; end = ( start + length ) ; while ( start < end ) { char * key , * value ; struct iscsi_param * param ; if ( iscsi_extract_key_value ( start , & key , & value ) < 0 ) { kfree ( tmpbuf ) ; return - 1 ; } pr_debug ( ""Gotkey:%s=%s\\n"" , key , value ) ; if ( phase & PHASE_SECURITY ) { if ( iscsi_check_for_auth_key ( key ) > 0 ) { char * tmpptr = key + strlen ( key ) ; * tmpptr = '=' ; kfree ( tmpbuf ) ; return 1 ; } } param = iscsi_check_key ( key , phase , sender , param_list ) ; if ( ! param ) { if ( iscsi_add_notunderstood_response ( key , value , param_list ) < 0 ) { kfree ( tmpbuf ) ; return - 1 ; } start += strlen ( key ) + strlen ( value ) + 2 ; continue ; } if ( iscsi_check_value ( param , value ) < 0 ) { kfree ( tmpbuf ) ; return - 1 ; } start += strlen ( key ) + strlen ( value ) + 2 ; if ( IS_PSTATE_PROPOSER ( param ) ) { if ( iscsi_check_proposer_state ( param , value ) < 0 ) { kfree ( tmpbuf ) ; return - 1 ; } SET_PSTATE_RESPONSE_GOT ( param ) ; } else { if ( iscsi_check_acceptor_state ( param , value , conn ) < 0 ) { kfree ( tmpbuf ) ; return - 1 ; } SET_PSTATE_ACCEPTOR ( param ) ; } } kfree ( tmpbuf ) ; return 0 ; } "," 0 ) { kfree ( tmpbuf ",torvalds@linux/cea4dcfdad926a27a18e188720efe0f2c9403456,CVE-2013-2850,https://github.com/torvalds/linux/commit/cea4dcfdad926a27a18e188720efe0f2c9403456,2013-06-07T14:03Z 304,CWE-264,"CWE-264 static int timer_start ( Unit * u ) { Timer * t = TIMER ( u ) ; TimerValue * v ; assert ( t ) ; assert ( t -> state == TIMER_DEAD || t -> state == TIMER_FAILED ) ; if ( UNIT_TRIGGER ( u ) -> load_state != UNIT_LOADED ) return - ENOENT ; t -> last_trigger = DUAL_TIMESTAMP_NULL ; LIST_FOREACH ( value , v , t -> values ) if ( v -> base == TIMER_ACTIVE ) v -> disabled = false ; if ( t -> stamp_path ) { struct stat st ; if ( stat ( t -> stamp_path , & st ) >= 0 ) t -> last_trigger . realtime = timespec_load ( & st . st_atim ) ; else if ( errno == ENOENT ) touch_file ( t -> stamp_path , true , USEC_INFINITY , UID_INVALID , GID_INVALID , 0 ) ; } t -> result = TIMER_SUCCESS ; timer_enter_waiting ( t , true ) ; return 1 ; } "," , GID_INVALID , MODE_INVALID ) ; } ",systemd@systemd/ee735086f8670be1591fa9593e80dd60163a7a2f,CVE-2016-10156,https://github.com/systemd/systemd/commit/ee735086f8670be1591fa9593e80dd60163a7a2f,2017-01-23T07:59Z 305,CWE-476,"CWE-476 jp2_box_t * jp2_box_get ( jas_stream_t * in ) { jp2_box_t * box ; jp2_boxinfo_t * boxinfo ; jas_stream_t * tmpstream ; uint_fast32_t len ; uint_fast64_t extlen ; bool dataflag ; box = 0 ; tmpstream = 0 ; if ( ! ( box = jas_malloc ( sizeof ( jp2_box_t ) ) ) ) { goto error ; } box -> ops = & jp2_boxinfo_unk . ops ; if ( jp2_getuint32 ( in , & len ) || jp2_getuint32 ( in , & box -> type ) ) { goto error ; } boxinfo = jp2_boxinfolookup ( box -> type ) ; box -> info = boxinfo ; box -> len = len ; JAS_DBGLOG ( 10 , ( ""preliminaryprocessingofJP2box:type=%c%s%c(0x%08x);length=%d\\n"" , \'""\' , boxinfo -> name , \'""\' , box -> type , box -> len ) ) ; if ( box -> len == 1 ) { if ( jp2_getuint64 ( in , & extlen ) ) { goto error ; } if ( extlen > 0xffffffffUL ) { jas_eprintf ( ""warning:cannothandlelarge64-bitboxlength\\n"" ) ; extlen = 0xffffffffUL ; } box -> len = extlen ; box -> datalen = extlen - JP2_BOX_HDRLEN ( true ) ; } else { box -> datalen = box -> len - JP2_BOX_HDRLEN ( false ) ; } if ( box -> len != 0 && box -> len < 8 ) { goto error ; } dataflag = ! ( box -> info -> flags & ( JP2_BOX_SUPER | JP2_BOX_NODATA ) ) ; if ( dataflag ) { if ( ! ( tmpstream = jas_stream_memopen ( 0 , 0 ) ) ) { goto error ; } if ( jas_stream_copy ( tmpstream , in , box -> datalen ) ) { jas_eprintf ( ""cannotcopyboxdata\\n"" ) ; goto error ; } jas_stream_rewind ( tmpstream ) ; box -> ops = & boxinfo -> ops ; if ( box -> ops -> getdata ) { if ( ( * box -> ops -> getdata ) ( box , tmpstream ) ) { jas_eprintf ( ""cannotparseboxdata\\n"" ) ; goto error ; } } jas_stream_close ( tmpstream ) ; } if ( jas_getdbglevel ( ) >= 1 ) { jp2_box_dump ( box , stderr ) ; } return box ; error : if ( box ) { jp2_box_destroy ( box ) ; } if ( tmpstream ) { jas_stream_close ( tmpstream ) ; } return 0 ; } "," ( box = jp2_box_create0 ( ) ) ) { goto error ; } if ( jp2_getuint32 10 , ( ""preliminaryprocessingofJP2box:"" ""type=%c%s%c(0x%08x);length=%"" PRIuFAST32 ""\\n"" , \'""\' , 1 ) { JAS_DBGLOG ( 10 , ( ""biglength\\n"" ) ) ; ",mdadams@jasper/e96fc4fdd525fa0ede28074a7e2b1caf94b58b0d,CVE-2017-6850,https://github.com/mdadams/jasper/commit/e96fc4fdd525fa0ede28074a7e2b1caf94b58b0d,2017-03-15T14:59Z 306,CWE-190,"CWE-190 static int _Unpickler_ResizeMemoList ( UnpicklerObject * self , Py_ssize_t new_size ) { Py_ssize_t i ; assert ( new_size > self -> memo_size ) ; PyObject * * memo_new = self -> memo ; PyMem_RESIZE ( memo_new , PyObject * , new_size ) ; if ( memo_new == NULL ) { PyErr_NoMemory ( ) ; return - 1 ; } self -> memo = memo_new ; for ( i = self -> memo_size ; i < new_size ; i ++ ) self -> memo [ i ] = NULL ; self -> memo_size = new_size ; return 0 ; } "," * self , size_t new_size ) { new_size ) { size_t i ; assert ",python@cpython/a4ae828ee416a66d8c7bf5ee71d653c2cc6a26dd,CVE-2018-20406,https://github.com/python/cpython/commit/a4ae828ee416a66d8c7bf5ee71d653c2cc6a26dd,2018-12-23T23:29Z 307,CWE-119,"CWE-119 static ssize_t macvtap_get_user ( struct macvtap_queue * q , struct msghdr * m , const struct iovec * iv , unsigned long total_len , size_t count , int noblock ) { struct sk_buff * skb ; struct macvlan_dev * vlan ; unsigned long len = total_len ; int err ; struct virtio_net_hdr vnet_hdr = { 0 } ; int vnet_hdr_len = 0 ; int copylen ; bool zerocopy = false ; if ( q -> flags & IFF_VNET_HDR ) { vnet_hdr_len = q -> vnet_hdr_sz ; err = - EINVAL ; if ( len < vnet_hdr_len ) goto err ; len -= vnet_hdr_len ; err = memcpy_fromiovecend ( ( void * ) & vnet_hdr , iv , 0 , sizeof ( vnet_hdr ) ) ; if ( err < 0 ) goto err ; if ( ( vnet_hdr . flags & VIRTIO_NET_HDR_F_NEEDS_CSUM ) && vnet_hdr . csum_start + vnet_hdr . csum_offset + 2 > vnet_hdr . hdr_len ) vnet_hdr . hdr_len = vnet_hdr . csum_start + vnet_hdr . csum_offset + 2 ; err = - EINVAL ; if ( vnet_hdr . hdr_len > len ) goto err ; } err = - EINVAL ; if ( unlikely ( len < ETH_HLEN ) ) goto err ; if ( m && m -> msg_control && sock_flag ( & q -> sk , SOCK_ZEROCOPY ) ) zerocopy = true ; if ( zerocopy ) { copylen = vnet_hdr . hdr_len ; if ( ! copylen ) copylen = GOODCOPY_LEN ; } else copylen = len ; skb = macvtap_alloc_skb ( & q -> sk , NET_IP_ALIGN , copylen , vnet_hdr . hdr_len , noblock , & err ) ; if ( ! skb ) goto err ; if ( zerocopy ) err = zerocopy_sg_from_iovec ( skb , iv , vnet_hdr_len , count ) ; else err = skb_copy_datagram_from_iovec ( skb , 0 , iv , vnet_hdr_len , len ) ; if ( err ) goto err_kfree ; skb_set_network_header ( skb , ETH_HLEN ) ; skb_reset_mac_header ( skb ) ; skb -> protocol = eth_hdr ( skb ) -> h_proto ; if ( vnet_hdr_len ) { err = macvtap_skb_from_vnet_hdr ( skb , & vnet_hdr ) ; if ( err ) goto err_kfree ; } rcu_read_lock_bh ( ) ; vlan = rcu_dereference_bh ( q -> vlan ) ; if ( zerocopy ) { skb_shinfo ( skb ) -> destructor_arg = m -> msg_control ; skb_shinfo ( skb ) -> tx_flags |= SKBTX_DEV_ZEROCOPY ; } if ( vlan ) macvlan_start_xmit ( skb , vlan -> dev ) ; else kfree_skb ( skb ) ; rcu_read_unlock_bh ( ) ; return total_len ; err_kfree : kfree_skb ( skb ) ; err : rcu_read_lock_bh ( ) ; vlan = rcu_dereference_bh ( q -> vlan ) ; if ( vlan ) vlan -> dev -> stats . tx_dropped ++ ; rcu_read_unlock_bh ( ) ; return err ; } "," ; int copylen = 0 goto err ; err = - EMSGSIZE ; if ( unlikely ( count > UIO_MAXIOV ) ) goto err ; zerocopy ) { if ( count > MAX_SKB_FRAGS ) { copylen = iov_length ( iv , count - MAX_SKB_FRAGS ) ; if ( copylen < vnet_hdr_len ) copylen = 0 ; else copylen -= vnet_hdr_len ; } if ( copylen < vnet_hdr . hdr_len ) ",torvalds@linux/b92946e2919134ebe2a4083e4302236295ea2a73,CVE-2012-2119,https://github.com/torvalds/linux/commit/b92946e2919134ebe2a4083e4302236295ea2a73,2013-01-22T23:55Z 308,CWE-125,"CWE-125 int ip6_find_1stfragopt ( struct sk_buff * skb , u8 * * nexthdr ) { u16 offset = sizeof ( struct ipv6hdr ) ; struct ipv6_opt_hdr * exthdr = ( struct ipv6_opt_hdr * ) ( ipv6_hdr ( skb ) + 1 ) ; unsigned int packet_len = skb_tail_pointer ( skb ) - skb_network_header ( skb ) ; int found_rhdr = 0 ; * nexthdr = & ipv6_hdr ( skb ) -> nexthdr ; while ( offset + 1 <= packet_len ) { switch ( * * nexthdr ) { case NEXTHDR_HOP : break ; case NEXTHDR_ROUTING : found_rhdr = 1 ; break ; case NEXTHDR_DEST : # if IS_ENABLED ( CONFIG_IPV6_MIP6 ) if ( ipv6_find_tlv ( skb , offset , IPV6_TLV_HAO ) >= 0 ) break ; # endif if ( found_rhdr ) return offset ; break ; default : return offset ; } offset += ipv6_optlen ( exthdr ) ; * nexthdr = & exthdr -> nexthdr ; exthdr = ( struct ipv6_opt_hdr * ) ( skb_network_header ( skb ) + offset ) ; } return offset ; } "," ( struct ipv6hdr ) ; unsigned while ( offset <= packet_len ) packet_len ) { struct ipv6_opt_hdr * exthdr ; offset ; } if ( offset + sizeof ( struct ipv6_opt_hdr ) > packet_len ) return - EINVAL ; exthdr = ( struct ipv6_opt_hdr * ) ( skb_network_header ( skb ) + offset ) ; -> nexthdr ; } return - EINVAL ; } ",torvalds@linux/2423496af35d94a87156b063ea5cedffc10a70a1,CVE-2017-9074,https://github.com/torvalds/linux/commit/2423496af35d94a87156b063ea5cedffc10a70a1,2017-05-19T07:29Z 309,CWE-119,"CWE-119 static void write_delta_q ( struct vp9_write_bit_buffer * wb , int delta_q ) { if ( delta_q != 0 ) { vp9_wb_write_bit ( wb , 1 ) ; vp9_wb_write_literal ( wb , abs ( delta_q ) , 4 ) ; vp9_wb_write_bit ( wb , delta_q < 0 ) ; } else { vp9_wb_write_bit ( wb , 0 ) ; } } "," write_delta_q ( struct vpx_write_bit_buffer * wb , 0 ) { vpx_wb_write_bit ( wb , 1 ) ; vpx_wb_write_literal ( wb , 4 ) ; vpx_wb_write_bit ( wb , } else { vpx_wb_write_bit ( wb , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 310,CWE-119,"CWE-119 void vp8_mv_pred ( VP8_COMP * cpi , MACROBLOCKD * xd , const MODE_INFO * here , int_mv * mvp , int refframe , int * ref_frame_sign_bias , int * sr , int near_sadidx [ ] ) { const MODE_INFO * above = here - xd -> mode_info_stride ; const MODE_INFO * left = here - 1 ; const MODE_INFO * aboveleft = above - 1 ; int_mv near_mvs [ 8 ] ; int near_ref [ 8 ] ; int_mv mv ; int vcnt = 0 ; int find = 0 ; int mb_offset ; int mvx [ 8 ] ; int mvy [ 8 ] ; int i ; mv . as_int = 0 ; if ( here -> mbmi . ref_frame != INTRA_FRAME ) { near_mvs [ 0 ] . as_int = near_mvs [ 1 ] . as_int = near_mvs [ 2 ] . as_int = near_mvs [ 3 ] . as_int = near_mvs [ 4 ] . as_int = near_mvs [ 5 ] . as_int = near_mvs [ 6 ] . as_int = near_mvs [ 7 ] . as_int = 0 ; near_ref [ 0 ] = near_ref [ 1 ] = near_ref [ 2 ] = near_ref [ 3 ] = near_ref [ 4 ] = near_ref [ 5 ] = near_ref [ 6 ] = near_ref [ 7 ] = 0 ; if ( above -> mbmi . ref_frame != INTRA_FRAME ) { near_mvs [ vcnt ] . as_int = above -> mbmi . mv . as_int ; mv_bias ( ref_frame_sign_bias [ above -> mbmi . ref_frame ] , refframe , & near_mvs [ vcnt ] , ref_frame_sign_bias ) ; near_ref [ vcnt ] = above -> mbmi . ref_frame ; } vcnt ++ ; if ( left -> mbmi . ref_frame != INTRA_FRAME ) { near_mvs [ vcnt ] . as_int = left -> mbmi . mv . as_int ; mv_bias ( ref_frame_sign_bias [ left -> mbmi . ref_frame ] , refframe , & near_mvs [ vcnt ] , ref_frame_sign_bias ) ; near_ref [ vcnt ] = left -> mbmi . ref_frame ; } vcnt ++ ; if ( aboveleft -> mbmi . ref_frame != INTRA_FRAME ) { near_mvs [ vcnt ] . as_int = aboveleft -> mbmi . mv . as_int ; mv_bias ( ref_frame_sign_bias [ aboveleft -> mbmi . ref_frame ] , refframe , & near_mvs [ vcnt ] , ref_frame_sign_bias ) ; near_ref [ vcnt ] = aboveleft -> mbmi . ref_frame ; } vcnt ++ ; if ( cpi -> common . last_frame_type != KEY_FRAME ) { mb_offset = ( - xd -> mb_to_top_edge / 128 + 1 ) * ( xd -> mode_info_stride + 1 ) + ( - xd -> mb_to_left_edge / 128 + 1 ) ; if ( cpi -> lf_ref_frame [ mb_offset ] != INTRA_FRAME ) { near_mvs [ vcnt ] . as_int = cpi -> lfmv [ mb_offset ] . as_int ; mv_bias ( cpi -> lf_ref_frame_sign_bias [ mb_offset ] , refframe , & near_mvs [ vcnt ] , ref_frame_sign_bias ) ; near_ref [ vcnt ] = cpi -> lf_ref_frame [ mb_offset ] ; } vcnt ++ ; if ( cpi -> lf_ref_frame [ mb_offset - xd -> mode_info_stride - 1 ] != INTRA_FRAME ) { near_mvs [ vcnt ] . as_int = cpi -> lfmv [ mb_offset - xd -> mode_info_stride - 1 ] . as_int ; mv_bias ( cpi -> lf_ref_frame_sign_bias [ mb_offset - xd -> mode_info_stride - 1 ] , refframe , & near_mvs [ vcnt ] , ref_frame_sign_bias ) ; near_ref [ vcnt ] = cpi -> lf_ref_frame [ mb_offset - xd -> mode_info_stride - 1 ] ; } vcnt ++ ; if ( cpi -> lf_ref_frame [ mb_offset - 1 ] != INTRA_FRAME ) { near_mvs [ vcnt ] . as_int = cpi -> lfmv [ mb_offset - 1 ] . as_int ; mv_bias ( cpi -> lf_ref_frame_sign_bias [ mb_offset - 1 ] , refframe , & near_mvs [ vcnt ] , ref_frame_sign_bias ) ; near_ref [ vcnt ] = cpi -> lf_ref_frame [ mb_offset - 1 ] ; } vcnt ++ ; if ( cpi -> lf_ref_frame [ mb_offset + 1 ] != INTRA_FRAME ) { near_mvs [ vcnt ] . as_int = cpi -> lfmv [ mb_offset + 1 ] . as_int ; mv_bias ( cpi -> lf_ref_frame_sign_bias [ mb_offset + 1 ] , refframe , & near_mvs [ vcnt ] , ref_frame_sign_bias ) ; near_ref [ vcnt ] = cpi -> lf_ref_frame [ mb_offset + 1 ] ; } vcnt ++ ; if ( cpi -> lf_ref_frame [ mb_offset + xd -> mode_info_stride + 1 ] != INTRA_FRAME ) { near_mvs [ vcnt ] . as_int = cpi -> lfmv [ mb_offset + xd -> mode_info_stride + 1 ] . as_int ; mv_bias ( cpi -> lf_ref_frame_sign_bias [ mb_offset + xd -> mode_info_stride + 1 ] , refframe , & near_mvs [ vcnt ] , ref_frame_sign_bias ) ; near_ref [ vcnt ] = cpi -> lf_ref_frame [ mb_offset + xd -> mode_info_stride + 1 ] ; } vcnt ++ ; } for ( i = 0 ; i < vcnt ; i ++ ) { if ( near_ref [ near_sadidx [ i ] ] != INTRA_FRAME ) { if ( here -> mbmi . ref_frame == near_ref [ near_sadidx [ i ] ] ) { mv . as_int = near_mvs [ near_sadidx [ i ] ] . as_int ; find = 1 ; if ( i < 3 ) * sr = 3 ; else * sr = 2 ; break ; } } } if ( ! find ) { for ( i = 0 ; i < vcnt ; i ++ ) { mvx [ i ] = near_mvs [ i ] . as_mv . row ; mvy [ i ] = near_mvs [ i ] . as_mv . col ; } insertsortmv ( mvx , vcnt ) ; insertsortmv ( mvy , vcnt ) ; mv . as_mv . row = mvx [ vcnt / 2 ] ; mv . as_mv . col = mvy [ vcnt / 2 ] ; find = 1 ; * sr = 0 ; } } mvp -> as_int = mv . as_int ; vp8_clamp_mv2 ( mvp , xd ) ; } "," 2 ] ; * sr = ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 311,CWE-264,"CWE-264 static int packet_recvmsg ( struct kiocb * iocb , struct socket * sock , struct msghdr * msg , size_t len , int flags ) { struct sock * sk = sock -> sk ; struct sk_buff * skb ; int copied , err ; struct sockaddr_ll * sll ; int vnet_hdr_len = 0 ; err = - EINVAL ; if ( flags & ~ ( MSG_PEEK | MSG_DONTWAIT | MSG_TRUNC | MSG_CMSG_COMPAT | MSG_ERRQUEUE ) ) goto out ; # if 0 if ( pkt_sk ( sk ) -> ifindex < 0 ) return - ENODEV ; # endif if ( flags & MSG_ERRQUEUE ) { err = packet_recv_error ( sk , msg , len ) ; goto out ; } skb = skb_recv_datagram ( sk , flags , flags & MSG_DONTWAIT , & err ) ; if ( skb == NULL ) goto out ; if ( pkt_sk ( sk ) -> has_vnet_hdr ) { struct virtio_net_hdr vnet_hdr = { 0 } ; err = - EINVAL ; vnet_hdr_len = sizeof ( vnet_hdr ) ; if ( len < vnet_hdr_len ) goto out_free ; len -= vnet_hdr_len ; if ( skb_is_gso ( skb ) ) { struct skb_shared_info * sinfo = skb_shinfo ( skb ) ; vnet_hdr . hdr_len = skb_headlen ( skb ) ; vnet_hdr . gso_size = sinfo -> gso_size ; if ( sinfo -> gso_type & SKB_GSO_TCPV4 ) vnet_hdr . gso_type = VIRTIO_NET_HDR_GSO_TCPV4 ; else if ( sinfo -> gso_type & SKB_GSO_TCPV6 ) vnet_hdr . gso_type = VIRTIO_NET_HDR_GSO_TCPV6 ; else if ( sinfo -> gso_type & SKB_GSO_UDP ) vnet_hdr . gso_type = VIRTIO_NET_HDR_GSO_UDP ; else if ( sinfo -> gso_type & SKB_GSO_FCOE ) goto out_free ; else BUG ( ) ; if ( sinfo -> gso_type & SKB_GSO_TCP_ECN ) vnet_hdr . gso_type |= VIRTIO_NET_HDR_GSO_ECN ; } else vnet_hdr . gso_type = VIRTIO_NET_HDR_GSO_NONE ; if ( skb -> ip_summed == CHECKSUM_PARTIAL ) { vnet_hdr . flags = VIRTIO_NET_HDR_F_NEEDS_CSUM ; vnet_hdr . csum_start = skb_checksum_start_offset ( skb ) ; vnet_hdr . csum_offset = skb -> csum_offset ; } err = memcpy_toiovec ( msg -> msg_iov , ( void * ) & vnet_hdr , vnet_hdr_len ) ; if ( err < 0 ) goto out_free ; } sll = & PACKET_SKB_CB ( skb ) -> sa . ll ; if ( sock -> type == SOCK_PACKET ) msg -> msg_namelen = sizeof ( struct sockaddr_pkt ) ; else msg -> msg_namelen = sll -> sll_halen + offsetof ( struct sockaddr_ll , sll_addr ) ; copied = skb -> len ; if ( copied > len ) { copied = len ; msg -> msg_flags |= MSG_TRUNC ; } err = skb_copy_datagram_iovec ( skb , 0 , msg -> msg_iov , copied ) ; if ( err ) goto out_free ; sock_recv_ts_and_drops ( msg , sk , skb ) ; if ( msg -> msg_name ) memcpy ( msg -> msg_name , & PACKET_SKB_CB ( skb ) -> sa , msg -> msg_namelen ) ; if ( pkt_sk ( sk ) -> auxdata ) { struct tpacket_auxdata aux ; aux . tp_status = TP_STATUS_USER ; if ( skb -> ip_summed == CHECKSUM_PARTIAL ) aux . tp_status |= TP_STATUS_CSUMNOTREADY ; aux . tp_len = PACKET_SKB_CB ( skb ) -> origlen ; aux . tp_snaplen = skb -> len ; aux . tp_mac = 0 ; aux . tp_net = skb_network_offset ( skb ) ; if ( vlan_tx_tag_present ( skb ) ) { aux . tp_vlan_tci = vlan_tx_tag_get ( skb ) ; aux . tp_status |= TP_STATUS_VLAN_VALID ; } else { aux . tp_vlan_tci = 0 ; } put_cmsg ( msg , SOL_PACKET , PACKET_AUXDATA , sizeof ( aux ) , & aux ) ; } err = vnet_hdr_len + ( ( flags & MSG_TRUNC ) ? skb -> len : copied ) ; out_free : skb_free_datagram ( sk , skb ) ; out : return err ; } "," 0 ; } aux . tp_padding = 0 ; ",torvalds@linux/13fcb7bd322164c67926ffe272846d4860196dc6,CVE-2011-2898,https://github.com/torvalds/linux/commit/13fcb7bd322164c67926ffe272846d4860196dc6,2012-05-24T23:55Z 312,CWE-119,"CWE-119 static void logi_dj_recv_add_djhid_device ( struct dj_receiver_dev * djrcv_dev , struct dj_report * dj_report ) { struct hid_device * djrcv_hdev = djrcv_dev -> hdev ; struct usb_interface * intf = to_usb_interface ( djrcv_hdev -> dev . parent ) ; struct usb_device * usbdev = interface_to_usbdev ( intf ) ; struct hid_device * dj_hiddev ; struct dj_device * dj_dev ; unsigned char tmpstr [ 3 ] ; if ( dj_report -> report_params [ DEVICE_PAIRED_PARAM_SPFUNCTION ] & SPFUNCTION_DEVICE_LIST_EMPTY ) { dbg_hid ( ""%s:devicelistisempty\\n"" , __func__ ) ; djrcv_dev -> querying_devices = false ; return ; } if ( ( dj_report -> device_index < DJ_DEVICE_INDEX_MIN ) || ( dj_report -> device_index > DJ_DEVICE_INDEX_MAX ) ) { dev_err ( & djrcv_hdev -> dev , ""%s:invaliddeviceindex:%d\\n"" , __func__ , dj_report -> device_index ) ; return ; } if ( djrcv_dev -> paired_dj_devices [ dj_report -> device_index ] ) { dbg_hid ( ""%s:deviceisalreadyknown\\n"" , __func__ ) ; return ; } dj_hiddev = hid_allocate_device ( ) ; if ( IS_ERR ( dj_hiddev ) ) { dev_err ( & djrcv_hdev -> dev , ""%s:hid_allocate_devicefailed\\n"" , __func__ ) ; return ; } dj_hiddev -> ll_driver = & logi_dj_ll_driver ; dj_hiddev -> dev . parent = & djrcv_hdev -> dev ; dj_hiddev -> bus = BUS_USB ; dj_hiddev -> vendor = le16_to_cpu ( usbdev -> descriptor . idVendor ) ; dj_hiddev -> product = le16_to_cpu ( usbdev -> descriptor . idProduct ) ; snprintf ( dj_hiddev -> name , sizeof ( dj_hiddev -> name ) , ""LogitechUnifyingDevice.WirelessPID:%02x%02x"" , dj_report -> report_params [ DEVICE_PAIRED_PARAM_EQUAD_ID_MSB ] , dj_report -> report_params [ DEVICE_PAIRED_PARAM_EQUAD_ID_LSB ] ) ; usb_make_path ( usbdev , dj_hiddev -> phys , sizeof ( dj_hiddev -> phys ) ) ; snprintf ( tmpstr , sizeof ( tmpstr ) , "":%d"" , dj_report -> device_index ) ; strlcat ( dj_hiddev -> phys , tmpstr , sizeof ( dj_hiddev -> phys ) ) ; dj_dev = kzalloc ( sizeof ( struct dj_device ) , GFP_KERNEL ) ; if ( ! dj_dev ) { dev_err ( & djrcv_hdev -> dev , ""%s:failedallocatingdj_device\\n"" , __func__ ) ; goto dj_device_allocate_fail ; } dj_dev -> reports_supported = get_unaligned_le32 ( dj_report -> report_params + DEVICE_PAIRED_RF_REPORT_TYPE ) ; dj_dev -> hdev = dj_hiddev ; dj_dev -> dj_receiver_dev = djrcv_dev ; dj_dev -> device_index = dj_report -> device_index ; dj_hiddev -> driver_data = dj_dev ; djrcv_dev -> paired_dj_devices [ dj_report -> device_index ] = dj_dev ; if ( hid_add_device ( dj_hiddev ) ) { dev_err ( & djrcv_hdev -> dev , ""%s:failedaddingdj_device\\n"" , __func__ ) ; goto hid_add_device_fail ; } return ; hid_add_device_fail : djrcv_dev -> paired_dj_devices [ dj_report -> device_index ] = NULL ; kfree ( dj_dev ) ; dj_device_allocate_fail : hid_destroy_device ( dj_hiddev ) ; } "," } if ( djrcv_dev -> paired_dj_devices ",torvalds@linux/ad3e14d7c5268c2e24477c6ef54bbdf88add5d36,CVE-2014-3182,https://github.com/torvalds/linux/commit/ad3e14d7c5268c2e24477c6ef54bbdf88add5d36,2014-09-28T10:55Z 313,CWE-119,"CWE-119 static inline int check_entry_size_and_hooks ( struct arpt_entry * e , struct xt_table_info * newinfo , const unsigned char * base , const unsigned char * limit , const unsigned int * hook_entries , const unsigned int * underflows , unsigned int valid_hooks ) { unsigned int h ; int err ; if ( ( unsigned long ) e % __alignof__ ( struct arpt_entry ) != 0 || ( unsigned char * ) e + sizeof ( struct arpt_entry ) >= limit || ( unsigned char * ) e + e -> next_offset > limit ) { duprintf ( ""Badoffset%p\\n"" , e ) ; return - EINVAL ; } if ( e -> next_offset < sizeof ( struct arpt_entry ) + sizeof ( struct xt_entry_target ) ) { duprintf ( ""checking:element%psize%u\\n"" , e , e -> next_offset ) ; return - EINVAL ; } err = check_entry ( e ) ; if ( err ) return err ; for ( h = 0 ; h < NF_ARP_NUMHOOKS ; h ++ ) { if ( ! ( valid_hooks & ( 1 << h ) ) ) continue ; if ( ( unsigned char * ) e - base == hook_entries [ h ] ) newinfo -> hook_entry [ h ] = hook_entries [ h ] ; if ( ( unsigned char * ) e - base == underflows [ h ] ) { if ( ! check_underflow ( e ) ) { pr_err ( ""Underflowsmustbeunconditionaland"" ""usetheSTANDARDtargetwith"" ""ACCEPT/DROP\\n"" ) ; return - EINVAL ; } newinfo -> underflow [ h ] = underflows [ h ] ; } } e -> counters = ( ( struct xt_counters ) { 0 , 0 } ) ; e -> comefrom = 0 ; return 0 ; } "," ) ) { pr_debug ( ""Underflowsmustbeunconditionaland"" ""usetheSTANDARDtargetwith"" ",torvalds@linux/54d83fc74aa9ec72794373cb47432c5f7fb1a309,CVE-2016-3134,https://github.com/torvalds/linux/commit/54d83fc74aa9ec72794373cb47432c5f7fb1a309,2016-04-27T17:59Z 314,CWE-190,"CWE-190 int bson_check_field_name ( bson * b , const char * string , const int length ) { return bson_validate_string ( b , ( const unsigned char * ) string , length , 1 , 1 , 1 ) ; } "," string , const size_t length ) { ",10gen-archive@mongo-c-driver-legacy/1a1f5e26a4309480d88598913f9eebf9e9cba8ca,CVE-2020-12135,https://github.com/10gen-archive/mongo-c-driver-legacy/commit/1a1f5e26a4309480d88598913f9eebf9e9cba8ca,2020-04-24T01:15Z 315,CWE-20,"CWE-20 struct sctp_chunk * sctp_process_asconf ( struct sctp_association * asoc , struct sctp_chunk * asconf ) { sctp_addiphdr_t * hdr ; union sctp_addr_param * addr_param ; sctp_addip_param_t * asconf_param ; struct sctp_chunk * asconf_ack ; __be16 err_code ; int length = 0 ; int chunk_len ; __u32 serial ; int all_param_pass = 1 ; chunk_len = ntohs ( asconf -> chunk_hdr -> length ) - sizeof ( sctp_chunkhdr_t ) ; hdr = ( sctp_addiphdr_t * ) asconf -> skb -> data ; serial = ntohl ( hdr -> serial ) ; length = sizeof ( sctp_addiphdr_t ) ; addr_param = ( union sctp_addr_param * ) ( asconf -> skb -> data + length ) ; chunk_len -= length ; length = ntohs ( addr_param -> p . length ) ; asconf_param = ( void * ) addr_param + length ; chunk_len -= length ; asconf_ack = sctp_make_asconf_ack ( asoc , serial , chunk_len * 4 ) ; if ( ! asconf_ack ) goto done ; while ( chunk_len > 0 ) { err_code = sctp_process_asconf_param ( asoc , asconf , asconf_param ) ; if ( SCTP_ERROR_NO_ERROR != err_code ) all_param_pass = 0 ; if ( ! all_param_pass ) sctp_add_asconf_response ( asconf_ack , asconf_param -> crr_id , err_code , asconf_param ) ; if ( SCTP_ERROR_RSRC_LOW == err_code ) goto done ; length = ntohs ( asconf_param -> param_hdr . length ) ; asconf_param = ( void * ) asconf_param + length ; chunk_len -= length ; } done : asoc -> peer . addip_serial ++ ; if ( asconf_ack ) { sctp_chunk_hold ( asconf_ack ) ; list_add_tail ( & asconf_ack -> transmitted_list , & asoc -> asconf_ack_list ) ; } return asconf_ack ; } "," asconf ) { sctp_addip_chunk_t * addip = ( sctp_addip_chunk_t * ) asconf -> chunk_hdr ; bool all_param_pass = true ; union sctp_params param ; __u32 serial ; chunk_len = ntohs goto done ; sctp_walk_params ( param , addip , addip_hdr . params ) { if ( param . p -> type == SCTP_PARAM_IPV4_ADDRESS || param . p -> type == SCTP_PARAM_IPV6_ADDRESS ) continue ; err_code = sctp_process_asconf_param , asconf , param . addip ) ; if ( err_code != SCTP_ERROR_NO_ERROR ) all_param_pass = ) all_param_pass = false ; if ( ( asconf_ack , param . addip -> crr_id , -> crr_id , err_code , param . addip ) ; if ( err_code == SCTP_ERROR_RSRC_LOW ) goto done goto done ; } done : ",torvalds@linux/9de7922bc709eee2f609cd01d98aaedc4cf5ea74,CVE-2014-3673,https://github.com/torvalds/linux/commit/9de7922bc709eee2f609cd01d98aaedc4cf5ea74,2014-11-10T11:55Z 316,CWE-190,"CWE-190 void * jas_realloc ( void * ptr , size_t size ) { void * result ; JAS_DBGLOG ( 101 , ( ""jas_realloccalledwith%x,%zu\\n"" , ptr , size ) ) ; result = realloc ( ptr , size ) ; JAS_DBGLOG ( 100 , ( ""jas_realloc(%p,%zu)->%p\\n"" , ptr , size , result ) ) ; return result ; } "," 101 , ( ""jas_realloc(%x,%zu)\\n"" , ptr , ",mdadams@jasper/988f8365f7d8ad8073b6786e433d34c553ecf568,CVE-2016-10249,https://github.com/mdadams/jasper/commit/988f8365f7d8ad8073b6786e433d34c553ecf568,2017-03-15T14:59Z 317,CWE-20,"CWE-20 static int recv_msg ( struct kiocb * iocb , struct socket * sock , struct msghdr * m , size_t buf_len , int flags ) { struct sock * sk = sock -> sk ; struct tipc_port * tport = tipc_sk_port ( sk ) ; struct sk_buff * buf ; struct tipc_msg * msg ; long timeout ; unsigned int sz ; u32 err ; int res ; if ( unlikely ( ! buf_len ) ) return - EINVAL ; lock_sock ( sk ) ; if ( unlikely ( sock -> state == SS_UNCONNECTED ) ) { res = - ENOTCONN ; goto exit ; } m -> msg_namelen = 0 ; timeout = sock_rcvtimeo ( sk , flags & MSG_DONTWAIT ) ; restart : while ( skb_queue_empty ( & sk -> sk_receive_queue ) ) { if ( sock -> state == SS_DISCONNECTING ) { res = - ENOTCONN ; goto exit ; } if ( timeout <= 0L ) { res = timeout ? timeout : - EWOULDBLOCK ; goto exit ; } release_sock ( sk ) ; timeout = wait_event_interruptible_timeout ( * sk_sleep ( sk ) , tipc_rx_ready ( sock ) , timeout ) ; lock_sock ( sk ) ; } buf = skb_peek ( & sk -> sk_receive_queue ) ; msg = buf_msg ( buf ) ; sz = msg_data_sz ( msg ) ; err = msg_errcode ( msg ) ; if ( ( ! sz ) && ( ! err ) ) { advance_rx_queue ( sk ) ; goto restart ; } set_orig_addr ( m , msg ) ; res = anc_data_recv ( m , msg , tport ) ; if ( res ) goto exit ; if ( ! err ) { if ( unlikely ( buf_len < sz ) ) { sz = buf_len ; m -> msg_flags |= MSG_TRUNC ; } res = skb_copy_datagram_iovec ( buf , msg_hdr_sz ( msg ) , m -> msg_iov , sz ) ; if ( res ) goto exit ; res = sz ; } else { if ( ( sock -> state == SS_READY ) || ( ( err == TIPC_CONN_SHUTDOWN ) || m -> msg_control ) ) res = 0 ; else res = - ECONNRESET ; } if ( likely ( ! ( flags & MSG_PEEK ) ) ) { if ( ( sock -> state != SS_READY ) && ( ++ tport -> conn_unacked >= TIPC_FLOW_CONTROL_WIN ) ) tipc_acknowledge ( tport -> ref , tport -> conn_unacked ) ; advance_rx_queue ( sk ) ; } exit : release_sock ( sk ) ; return res ; } "," exit ; } timeout = sock_rcvtimeo ",torvalds@linux/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,CVE-2013-7271,https://github.com/torvalds/linux/commit/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,2014-01-06T16:55Z 318,CWE-476,"CWE-476 int kvm_vm_ioctl_check_extension ( struct kvm * kvm , long ext ) { int r ; int hv_enabled = kvmppc_hv_ops ? 1 : 0 ; if ( kvm ) { hv_enabled = is_kvmppc_hv_enabled ( kvm ) ; } switch ( ext ) { # ifdef CONFIG_BOOKE case KVM_CAP_PPC_BOOKE_SREGS : case KVM_CAP_PPC_BOOKE_WATCHDOG : case KVM_CAP_PPC_EPR : # else case KVM_CAP_PPC_SEGSTATE : case KVM_CAP_PPC_HIOR : case KVM_CAP_PPC_PAPR : # endif case KVM_CAP_PPC_UNSET_IRQ : case KVM_CAP_PPC_IRQ_LEVEL : case KVM_CAP_ENABLE_CAP : case KVM_CAP_ENABLE_CAP_VM : case KVM_CAP_ONE_REG : case KVM_CAP_IOEVENTFD : case KVM_CAP_DEVICE_CTRL : case KVM_CAP_IMMEDIATE_EXIT : r = 1 ; break ; case KVM_CAP_PPC_PAIRED_SINGLES : case KVM_CAP_PPC_OSI : case KVM_CAP_PPC_GET_PVINFO : # if defined ( CONFIG_KVM_E500V2 ) || defined ( CONFIG_KVM_E500MC ) case KVM_CAP_SW_TLB : # endif r = ! hv_enabled ; break ; # ifdef CONFIG_KVM_MPIC case KVM_CAP_IRQ_MPIC : r = 1 ; break ; # endif # ifdef CONFIG_PPC_BOOK3S_64 case KVM_CAP_SPAPR_TCE : case KVM_CAP_SPAPR_TCE_64 : case KVM_CAP_SPAPR_TCE_VFIO : case KVM_CAP_PPC_RTAS : case KVM_CAP_PPC_FIXUP_HCALL : case KVM_CAP_PPC_ENABLE_HCALL : # ifdef CONFIG_KVM_XICS case KVM_CAP_IRQ_XICS : # endif r = 1 ; break ; case KVM_CAP_PPC_ALLOC_HTAB : r = hv_enabled ; break ; # endif # ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE case KVM_CAP_PPC_SMT : r = 0 ; if ( kvm ) { if ( kvm -> arch . emul_smt_mode > 1 ) r = kvm -> arch . emul_smt_mode ; else r = kvm -> arch . smt_mode ; } else if ( hv_enabled ) { if ( cpu_has_feature ( CPU_FTR_ARCH_300 ) ) r = 1 ; else r = threads_per_subcore ; } break ; case KVM_CAP_PPC_SMT_POSSIBLE : r = 1 ; if ( hv_enabled ) { if ( ! cpu_has_feature ( CPU_FTR_ARCH_300 ) ) r = ( ( threads_per_subcore << 1 ) - 1 ) ; else r = 8 | 4 | 2 | 1 ; } break ; case KVM_CAP_PPC_RMA : r = 0 ; break ; case KVM_CAP_PPC_HWRNG : r = kvmppc_hwrng_present ( ) ; break ; case KVM_CAP_PPC_MMU_RADIX : r = ! ! ( hv_enabled && radix_enabled ( ) ) ; break ; case KVM_CAP_PPC_MMU_HASH_V3 : r = ! ! ( hv_enabled && ! radix_enabled ( ) && cpu_has_feature ( CPU_FTR_ARCH_300 ) ) ; break ; # endif case KVM_CAP_SYNC_MMU : # ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE r = hv_enabled ; # elif defined ( KVM_ARCH_WANT_MMU_NOTIFIER ) r = 1 ; # else r = 0 ; # endif break ; # ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE case KVM_CAP_PPC_HTAB_FD : r = hv_enabled ; break ; # endif case KVM_CAP_NR_VCPUS : if ( hv_enabled ) r = num_present_cpus ( ) ; else r = num_online_cpus ( ) ; break ; case KVM_CAP_NR_MEMSLOTS : r = KVM_USER_MEM_SLOTS ; break ; case KVM_CAP_MAX_VCPUS : r = KVM_MAX_VCPUS ; break ; # ifdef CONFIG_PPC_BOOK3S_64 case KVM_CAP_PPC_GET_SMMU_INFO : r = 1 ; break ; case KVM_CAP_SPAPR_MULTITCE : r = 1 ; break ; case KVM_CAP_SPAPR_RESIZE_HPT : r = ! ! hv_enabled && ! cpu_has_feature ( CPU_FTR_ARCH_300 ) ; break ; # endif # ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE case KVM_CAP_PPC_FWNMI : r = hv_enabled ; break ; # endif case KVM_CAP_PPC_HTM : r = cpu_has_feature ( CPU_FTR_TM_COMP ) && is_kvmppc_hv_enabled ( kvm ) ; break ; default : r = 0 ; break ; } return r ; } "," CPU_FTR_TM_COMP ) && hv_enabled ; break ; ",torvalds@linux/ac64115a66c18c01745bbd3c47a36b124e5fd8c0,CVE-2017-15306,https://github.com/torvalds/linux/commit/ac64115a66c18c01745bbd3c47a36b124e5fd8c0,2017-11-06T18:29Z 319,CWE-617,"CWE-617 int pci_emul_add_msicap ( struct pci_vdev * dev , int msgnum ) { struct msicap msicap ; pci_populate_msicap ( & msicap , msgnum , 0 ) ; return pci_emul_add_capability ( dev , ( u_char * ) & msicap , sizeof ( msicap ) ) ; } "," msicap msicap ; return , 0 ) || pci_emul_add_capability ( dev ",projectacrn@acrn-hypervisor/2b3dedfb9ba13f15887f22b935d373f36c9a59fa,CVE-2019-18844,https://github.com/projectacrn/acrn-hypervisor/commit/2b3dedfb9ba13f15887f22b935d373f36c9a59fa,2019-11-13T20:15Z 320,CWE-119,"CWE-119 static void kvp_respond_to_host ( char * key , char * value , int error ) { struct hv_kvp_msg * kvp_msg ; struct hv_kvp_msg_enumerate * kvp_data ; char * key_name ; struct icmsg_hdr * icmsghdrp ; int keylen , valuelen ; u32 buf_len ; struct vmbus_channel * channel ; u64 req_id ; if ( ! kvp_transaction . active ) { pr_warn ( ""KVP:Transactionnotactive\\n"" ) ; return ; } buf_len = kvp_transaction . recv_len ; channel = kvp_transaction . recv_channel ; req_id = kvp_transaction . recv_req_id ; kvp_transaction . active = false ; if ( channel -> onchannel_callback == NULL ) return ; icmsghdrp = ( struct icmsg_hdr * ) & recv_buffer [ sizeof ( struct vmbuspipe_hdr ) ] ; kvp_msg = ( struct hv_kvp_msg * ) & recv_buffer [ sizeof ( struct vmbuspipe_hdr ) + sizeof ( struct icmsg_hdr ) ] ; kvp_data = & kvp_msg -> kvp_data ; key_name = key ; if ( error ) { icmsghdrp -> status = HV_E_FAIL ; goto response_done ; } keylen = utf8s_to_utf16s ( key_name , strlen ( key_name ) , ( wchar_t * ) kvp_data -> data . key ) ; kvp_data -> data . key_size = 2 * ( keylen + 1 ) ; valuelen = utf8s_to_utf16s ( value , strlen ( value ) , ( wchar_t * ) kvp_data -> data . value ) ; kvp_data -> data . value_size = 2 * ( valuelen + 1 ) ; kvp_data -> data . value_type = REG_SZ ; icmsghdrp -> status = HV_S_OK ; response_done : icmsghdrp -> icflags = ICMSGHDRFLAG_TRANSACTION | ICMSGHDRFLAG_RESPONSE ; vmbus_sendpacket ( channel , recv_buffer , buf_len , req_id , VM_PKT_DATA_INBAND , 0 ) ; } "," key_name ) , UTF16_HOST_ENDIAN , data . key , HV_KVP_EXCHANGE_MAX_KEY_SIZE / 2 value ) , UTF16_HOST_ENDIAN , data . value , HV_KVP_EXCHANGE_MAX_VALUE_SIZE / 2 ",torvalds@linux/0720a06a7518c9d0c0125bd5d1f3b6264c55c3dd,CVE-2013-1773,https://github.com/torvalds/linux/commit/0720a06a7518c9d0c0125bd5d1f3b6264c55c3dd,2013-02-28T19:55Z 321,CWE-399,"CWE-399 long vhost_dev_ioctl ( struct vhost_dev * d , unsigned int ioctl , void __user * argp ) { struct file * eventfp , * filep = NULL ; struct eventfd_ctx * ctx = NULL ; u64 p ; long r ; int i , fd ; if ( ioctl == VHOST_SET_OWNER ) { r = vhost_dev_set_owner ( d ) ; goto done ; } r = vhost_dev_check_owner ( d ) ; if ( r ) goto done ; switch ( ioctl ) { case VHOST_SET_MEM_TABLE : r = vhost_set_memory ( d , argp ) ; break ; case VHOST_SET_LOG_BASE : if ( copy_from_user ( & p , argp , sizeof p ) ) { r = - EFAULT ; break ; } if ( ( u64 ) ( unsigned long ) p != p ) { r = - EFAULT ; break ; } for ( i = 0 ; i < d -> nvqs ; ++ i ) { struct vhost_virtqueue * vq ; void __user * base = ( void __user * ) ( unsigned long ) p ; vq = d -> vqs [ i ] ; mutex_lock ( & vq -> mutex ) ; if ( vq -> private_data && ! vq_log_access_ok ( vq , base ) ) r = - EFAULT ; else vq -> log_base = base ; mutex_unlock ( & vq -> mutex ) ; } break ; case VHOST_SET_LOG_FD : r = get_user ( fd , ( int __user * ) argp ) ; if ( r < 0 ) break ; eventfp = fd == - 1 ? NULL : eventfd_fget ( fd ) ; if ( IS_ERR ( eventfp ) ) { r = PTR_ERR ( eventfp ) ; break ; } if ( eventfp != d -> log_file ) { filep = d -> log_file ; ctx = d -> log_ctx ; d -> log_ctx = eventfp ? eventfd_ctx_fileget ( eventfp ) : NULL ; } else filep = eventfp ; for ( i = 0 ; i < d -> nvqs ; ++ i ) { mutex_lock ( & d -> vqs [ i ] -> mutex ) ; d -> vqs [ i ] -> log_ctx = d -> log_ctx ; mutex_unlock ( & d -> vqs [ i ] -> mutex ) ; } if ( ctx ) eventfd_ctx_put ( ctx ) ; if ( filep ) fput ( filep ) ; break ; default : r = - ENOIOCTLCMD ; break ; } done : return r ; } "," -> log_file ; d -> log_file = eventfp ; ",torvalds@linux/7932c0bd7740f4cd2aa168d3ce0199e7af7d72d5,CVE-2015-6252,https://github.com/torvalds/linux/commit/7932c0bd7740f4cd2aa168d3ce0199e7af7d72d5,2015-10-19T10:59Z 322,CWE-125,"CWE-125 void color_sycc_to_rgb ( opj_image_t * img ) { if ( img -> numcomps < 3 ) { img -> color_space = OPJ_CLRSPC_GRAY ; return ; } if ( ( img -> comps [ 0 ] . dx == 1 ) && ( img -> comps [ 1 ] . dx == 2 ) && ( img -> comps [ 2 ] . dx == 2 ) && ( img -> comps [ 0 ] . dy == 1 ) && ( img -> comps [ 1 ] . dy == 2 ) && ( img -> comps [ 2 ] . dy == 2 ) ) { sycc420_to_rgb ( img ) ; } else if ( ( img -> comps [ 0 ] . dx == 1 ) && ( img -> comps [ 1 ] . dx == 2 ) && ( img -> comps [ 2 ] . dx == 2 ) && ( img -> comps [ 0 ] . dy == 1 ) && ( img -> comps [ 1 ] . dy == 1 ) && ( img -> comps [ 2 ] . dy == 1 ) ) { sycc422_to_rgb ( img ) ; } else if ( ( img -> comps [ 0 ] . dx == 1 ) && ( img -> comps [ 1 ] . dx == 1 ) && ( img -> comps [ 2 ] . dx == 1 ) && ( img -> comps [ 0 ] . dy == 1 ) && ( img -> comps [ 1 ] . dy == 1 ) && ( img -> comps [ 2 ] . dy == 1 ) ) { sycc444_to_rgb ( img ) ; } else { fprintf ( stderr , ""%s:%d:color_sycc_to_rgb\\n\\tCANNOTCONVERT\\n"" , __FILE__ , __LINE__ ) ; return ; } img -> color_space = OPJ_CLRSPC_SRGB ; } "," return ; } } ",uclouvain@openjpeg/15f081c89650dccee4aa4ae66f614c3fdb268767,CVE-2016-3183,https://github.com/uclouvain/openjpeg/commit/15f081c89650dccee4aa4ae66f614c3fdb268767,2017-02-03T16:59Z 323,CWE-399,"CWE-399 long video_usercopy ( struct file * file , unsigned int cmd , unsigned long arg , v4l2_kioctl func ) { char sbuf [ 128 ] ; void * mbuf = NULL ; void * parg = NULL ; long err = - EINVAL ; int is_ext_ctrl ; size_t ctrls_size = 0 ; void __user * user_ptr = NULL ; is_ext_ctrl = ( cmd == VIDIOC_S_EXT_CTRLS || cmd == VIDIOC_G_EXT_CTRLS || cmd == VIDIOC_TRY_EXT_CTRLS ) ; switch ( _IOC_DIR ( cmd ) ) { case _IOC_NONE : parg = NULL ; break ; case _IOC_READ : case _IOC_WRITE : case ( _IOC_WRITE | _IOC_READ ) : if ( _IOC_SIZE ( cmd ) <= sizeof ( sbuf ) ) { parg = sbuf ; } else { mbuf = kmalloc ( _IOC_SIZE ( cmd ) , GFP_KERNEL ) ; if ( NULL == mbuf ) return - ENOMEM ; parg = mbuf ; } err = - EFAULT ; if ( _IOC_DIR ( cmd ) & _IOC_WRITE ) if ( copy_from_user ( parg , ( void __user * ) arg , _IOC_SIZE ( cmd ) ) ) goto out ; break ; } if ( is_ext_ctrl ) { struct v4l2_ext_controls * p = parg ; p -> error_idx = p -> count ; user_ptr = ( void __user * ) p -> controls ; if ( p -> count ) { ctrls_size = sizeof ( struct v4l2_ext_control ) * p -> count ; mbuf = kmalloc ( ctrls_size , GFP_KERNEL ) ; err = - ENOMEM ; if ( NULL == mbuf ) goto out_ext_ctrl ; err = - EFAULT ; if ( copy_from_user ( mbuf , user_ptr , ctrls_size ) ) goto out_ext_ctrl ; p -> controls = mbuf ; } } err = func ( file , cmd , parg ) ; if ( err == - ENOIOCTLCMD ) err = - EINVAL ; if ( is_ext_ctrl ) { struct v4l2_ext_controls * p = parg ; p -> controls = ( void * ) user_ptr ; if ( p -> count && err == 0 && copy_to_user ( user_ptr , mbuf , ctrls_size ) ) err = - EFAULT ; goto out_ext_ctrl ; } if ( err < 0 ) goto out ; out_ext_ctrl : switch ( _IOC_DIR ( cmd ) ) { case _IOC_READ : case ( _IOC_WRITE | _IOC_READ ) : if ( copy_to_user ( ( void __user * ) arg , parg , _IOC_SIZE ( cmd ) ) ) err = - EFAULT ; break ; } out : kfree ( mbuf ) ; return err ; } "," * parg = ( void * ) arg ; long err = - EINVAL ; bool has_array_args ; size_t array_size = 0 ; void __user * user_ptr = NULL ; void * * kernel_ptr = NULL ; if ( _IOC_DIR ( cmd ) != _IOC_NONE ) { if ( _IOC_SIZE ( cmd ) <= sizeof ( sbuf ) ) { parg = sbuf ; } else { mbuf = kmalloc ( _IOC_SIZE ( cmd ) , GFP_KERNEL ) ; if ( NULL == mbuf ) return - ENOMEM ; parg = mbuf ; } err = - EFAULT ; if ( _IOC_DIR ( cmd ) & _IOC_WRITE ) { unsigned long n = cmd_input_size ( cmd ) ; if ( copy_from_user ( parg , ( void __user * ) arg , n ) ) goto out ; if ( n < _IOC_SIZE ( cmd ) ) memset ( ( u8 * ) parg + n , 0 , _IOC_SIZE ( cmd ) - n ) ; } else { memset ( parg , 0 , _IOC_SIZE ( cmd ) ) ; } } err = check_array_args ( cmd , parg , & array_size , & user_ptr , & kernel_ptr ) ; if ( err < 0 ) goto out ; has_array_args = err ; if ( has_array_args ) { mbuf = kmalloc ( array_size , GFP_KERNEL ) ; err = - ENOMEM ; if ( NULL == mbuf ) goto out_array_args ; err = - EFAULT ; if ( copy_from_user ( mbuf , user_ptr , array_size ) ) goto out_array_args ; * kernel_ptr = mbuf ; } err = func ( file , cmd , parg ) ; if ( err == - ENOIOCTLCMD ) err = - - EINVAL ; if ( has_array_args ) { * kernel_ptr = user_ptr ; if ( copy_to_user ( user_ptr , mbuf , array_size ) ) err = - EFAULT ; goto out_array_args ; } if ( err < 0 ) goto out ; out_array_args : switch ( _IOC_DIR ) ) { case _IOC_READ : _IOC_READ : case ( _IOC_WRITE | : if ( copy_to_user ( ( ",torvalds@linux/fc0a80798576f80ca10b3f6c9c7097f12fd1d64e,CVE-2010-5329,https://github.com/torvalds/linux/commit/fc0a80798576f80ca10b3f6c9c7097f12fd1d64e,2017-04-24T06:59Z 324,CWE-20,"CWE-20 int processCommand ( redisClient * c ) { struct redisCommand * cmd ; if ( ! strcasecmp ( c -> argv [ 0 ] -> ptr , ""quit"" ) ) { addReply ( c , shared . ok ) ; c -> flags |= REDIS_CLOSE_AFTER_REPLY ; return REDIS_ERR ; } cmd = lookupCommand ( c -> argv [ 0 ] -> ptr ) ; if ( ! cmd ) { addReplyErrorFormat ( c , ""unknowncommand\'%s\'"" , ( char * ) c -> argv [ 0 ] -> ptr ) ; return REDIS_OK ; } else if ( ( cmd -> arity > 0 && cmd -> arity != c -> argc ) || ( c -> argc < - cmd -> arity ) ) { addReplyErrorFormat ( c , ""wrongnumberofargumentsfor\'%s\'command"" , cmd -> name ) ; return REDIS_OK ; } if ( server . requirepass && ! c -> authenticated && cmd -> proc != authCommand ) { addReplyError ( c , ""operationnotpermitted"" ) ; return REDIS_OK ; } if ( server . maxmemory ) freeMemoryIfNeeded ( ) ; if ( server . maxmemory && ( cmd -> flags & REDIS_CMD_DENYOOM ) && zmalloc_used_memory ( ) > server . maxmemory ) { addReplyError ( c , ""commandnotallowedwhenusedmemory>\'maxmemory\'"" ) ; return REDIS_OK ; } if ( ( dictSize ( c -> pubsub_channels ) > 0 || listLength ( c -> pubsub_patterns ) > 0 ) && cmd -> proc != subscribeCommand && cmd -> proc != unsubscribeCommand && cmd -> proc != psubscribeCommand && cmd -> proc != punsubscribeCommand ) { addReplyError ( c , ""only(P)SUBSCRIBE/(P)UNSUBSCRIBE/QUITallowedinthiscontext"" ) ; return REDIS_OK ; } if ( server . masterhost && server . replstate != REDIS_REPL_CONNECTED && server . repl_serve_stale_data == 0 && cmd -> proc != infoCommand && cmd -> proc != slaveofCommand ) { addReplyError ( c , ""linkwithMASTERisdownandslave-serve-stale-dataissettono"" ) ; return REDIS_OK ; } if ( server . loading && cmd -> proc != infoCommand ) { addReply ( c , shared . loadingerr ) ; return REDIS_OK ; } if ( c -> flags & REDIS_MULTI && cmd -> proc != execCommand && cmd -> proc != discardCommand && cmd -> proc != multiCommand && cmd -> proc != watchCommand ) { queueMultiCommand ( c , cmd ) ; addReply ( c , shared . queued ) ; } else { if ( server . vm_enabled && server . vm_max_threads > 0 && blockClientOnSwappedKeys ( c , cmd ) ) return REDIS_ERR ; call ( c , cmd ) ; } return REDIS_OK ; } "," ( server . ds_enabled && blockClientOnSwappedKeys ( c ",antirez@redis/697af434fbeb2e3ba2ba9687cd283ed1a2734fa5,CVE-2013-0178,https://github.com/antirez/redis/commit/697af434fbeb2e3ba2ba9687cd283ed1a2734fa5,2019-11-01T19:15Z 325,CWE-119,"CWE-119 static int set_registers ( rtl8150_t * dev , u16 indx , u16 size , void * data ) { return usb_control_msg ( dev -> udev , usb_sndctrlpipe ( dev -> udev , 0 ) , RTL8150_REQ_SET_REGS , RTL8150_REQT_WRITE , indx , 0 , data , size , 500 ) ; } "," u16 size , const data ) { void * buf ; int ret ; buf = kmemdup ( data , size , GFP_NOIO ) ; if ( ! buf ) return - ENOMEM ; ret = usb_control_msg ( dev , 0 , buf , size , 500 ) ; kfree ( buf ) ; return ret ; ",torvalds@linux/7926aff5c57b577ab0f43364ff0c59d968f6a414,CVE-2017-8069,https://github.com/torvalds/linux/commit/7926aff5c57b577ab0f43364ff0c59d968f6a414,2017-04-23T05:59Z 326,CWE-000,"CWE-000 static int gtco_probe ( struct usb_interface * usbinterface , const struct usb_device_id * id ) { struct gtco * gtco ; struct input_dev * input_dev ; struct hid_descriptor * hid_desc ; char * report ; int result = 0 , retry ; int error ; struct usb_endpoint_descriptor * endpoint ; gtco = kzalloc ( sizeof ( struct gtco ) , GFP_KERNEL ) ; input_dev = input_allocate_device ( ) ; if ( ! gtco || ! input_dev ) { dev_err ( & usbinterface -> dev , ""Nomorememory\\n"" ) ; error = - ENOMEM ; goto err_free_devs ; } gtco -> inputdevice = input_dev ; gtco -> usbdev = interface_to_usbdev ( usbinterface ) ; gtco -> intf = usbinterface ; gtco -> buffer = usb_alloc_coherent ( gtco -> usbdev , REPORT_MAX_SIZE , GFP_KERNEL , & gtco -> buf_dma ) ; if ( ! gtco -> buffer ) { dev_err ( & usbinterface -> dev , ""Nomorememoryforusbuffers\\n"" ) ; error = - ENOMEM ; goto err_free_devs ; } gtco -> urbinfo = usb_alloc_urb ( 0 , GFP_KERNEL ) ; if ( ! gtco -> urbinfo ) { dev_err ( & usbinterface -> dev , ""FailedtoallocateURB\\n"" ) ; error = - ENOMEM ; goto err_free_buf ; } endpoint = & usbinterface -> altsetting [ 0 ] . endpoint [ 0 ] . desc ; dev_dbg ( & usbinterface -> dev , ""gtco#interfaces:%d\\n"" , usbinterface -> num_altsetting ) ; dev_dbg ( & usbinterface -> dev , ""numendpoints:%d\\n"" , usbinterface -> cur_altsetting -> desc . bNumEndpoints ) ; dev_dbg ( & usbinterface -> dev , ""interfaceclass:%d\\n"" , usbinterface -> cur_altsetting -> desc . bInterfaceClass ) ; dev_dbg ( & usbinterface -> dev , ""endpoint:attribute:0x%xtype:0x%x\\n"" , endpoint -> bmAttributes , endpoint -> bDescriptorType ) ; if ( usb_endpoint_xfer_int ( endpoint ) ) dev_dbg ( & usbinterface -> dev , ""endpoint:wehaveinterruptendpoint\\n"" ) ; dev_dbg ( & usbinterface -> dev , ""endpointextralen:%d\\n"" , usbinterface -> altsetting [ 0 ] . extralen ) ; if ( usb_get_extra_descriptor ( usbinterface -> cur_altsetting , HID_DEVICE_TYPE , & hid_desc ) != 0 ) { dev_err ( & usbinterface -> dev , ""Can\'tretrieveextaUSBdescriptortogethidreportdescriptorlength\\n"" ) ; error = - EIO ; goto err_free_urb ; } dev_dbg ( & usbinterface -> dev , ""Extradescriptorsuccess:type:%dlen:%d\\n"" , hid_desc -> bDescriptorType , hid_desc -> wDescriptorLength ) ; report = kzalloc ( le16_to_cpu ( hid_desc -> wDescriptorLength ) , GFP_KERNEL ) ; if ( ! report ) { dev_err ( & usbinterface -> dev , ""Nomorememoryforreport\\n"" ) ; error = - ENOMEM ; goto err_free_urb ; } for ( retry = 0 ; retry < 3 ; retry ++ ) { result = usb_control_msg ( gtco -> usbdev , usb_rcvctrlpipe ( gtco -> usbdev , 0 ) , USB_REQ_GET_DESCRIPTOR , USB_RECIP_INTERFACE | USB_DIR_IN , REPORT_DEVICE_TYPE << 8 , 0 , report , le16_to_cpu ( hid_desc -> wDescriptorLength ) , 5000 ) ; dev_dbg ( & usbinterface -> dev , ""usb_control_msgresult:%d\\n"" , result ) ; if ( result == le16_to_cpu ( hid_desc -> wDescriptorLength ) ) { parse_hid_report_descriptor ( gtco , report , result ) ; break ; } } kfree ( report ) ; if ( result != le16_to_cpu ( hid_desc -> wDescriptorLength ) ) { dev_err ( & usbinterface -> dev , ""FailedtogetHIDReportDescriptorofsize:%d\\n"" , hid_desc -> wDescriptorLength ) ; error = - EIO ; goto err_free_urb ; } usb_make_path ( gtco -> usbdev , gtco -> usbpath , sizeof ( gtco -> usbpath ) ) ; strlcat ( gtco -> usbpath , ""/input0"" , sizeof ( gtco -> usbpath ) ) ; input_dev -> open = gtco_input_open ; input_dev -> close = gtco_input_close ; input_dev -> name = ""GTCO_CalComp"" ; input_dev -> phys = gtco -> usbpath ; input_set_drvdata ( input_dev , gtco ) ; gtco_setup_caps ( input_dev ) ; usb_to_input_id ( gtco -> usbdev , & input_dev -> id ) ; input_dev -> dev . parent = & usbinterface -> dev ; endpoint = & usbinterface -> altsetting [ 0 ] . endpoint [ 0 ] . desc ; usb_fill_int_urb ( gtco -> urbinfo , gtco -> usbdev , usb_rcvintpipe ( gtco -> usbdev , endpoint -> bEndpointAddress ) , gtco -> buffer , REPORT_MAX_SIZE , gtco_urb_callback , gtco , endpoint -> bInterval ) ; gtco -> urbinfo -> transfer_dma = gtco -> buf_dma ; gtco -> urbinfo -> transfer_flags |= URB_NO_TRANSFER_DMA_MAP ; usb_set_intfdata ( usbinterface , gtco ) ; error = input_register_device ( input_dev ) ; if ( error ) goto err_free_urb ; return 0 ; err_free_urb : usb_free_urb ( gtco -> urbinfo ) ; err_free_buf : usb_free_coherent ( gtco -> usbdev , REPORT_MAX_SIZE , gtco -> buffer , gtco -> buf_dma ) ; err_free_devs : input_free_device ( input_dev ) ; kfree ( gtco ) ; return error ; } "," err_free_buf ; } if ( usbinterface -> altsetting [ 0 ] . desc . bNumEndpoints < 1 ) { dev_err ( & usbinterface -> dev , ""Invalidnumberofendpoints\\n"" ) ; error = - EINVAL ; goto err_free_urb ; } ",torvalds@linux/162f98dea487206d9ab79fc12ed64700667a894d,CVE-2016-2187,https://github.com/torvalds/linux/commit/162f98dea487206d9ab79fc12ed64700667a894d,2016-05-02T10:59Z 327,CWE-20,"CWE-20 static void untrusted_launcher_response_callback ( GtkDialog * dialog , int response_id , ActivateParametersDesktop * parameters ) { GdkScreen * screen ; char * uri ; GFile * file ; switch ( response_id ) { case RESPONSE_RUN : { screen = gtk_widget_get_screen ( GTK_WIDGET ( parameters -> parent_window ) ) ; uri = nautilus_file_get_uri ( parameters -> file ) ; DEBUG ( ""Launchinguntrustedlauncher%s"" , uri ) ; nautilus_launch_desktop_file ( screen , uri , NULL , parameters -> parent_window ) ; g_free ( uri ) ; } break ; case RESPONSE_MARK_TRUSTED : { file = nautilus_file_get_location ( parameters -> file ) ; nautilus_file_mark_desktop_file_trusted ( file , parameters -> parent_window , TRUE , NULL , NULL ) ; g_object_unref ( file ) ; } break ; default : { } break ; } gtk_widget_destroy ( GTK_WIDGET ( dialog ) ) ; activate_parameters_desktop_free ( parameters ) ; } "," ) { case GTK_RESPONSE_OK : { file = nautilus_file_get_location ( parameters -> file ) ; nautilus_file_set_metadata ( parameters -> file , NAUTILUS_METADATA_KEY_DESKTOP_FILE_TRUSTED , NULL , ""yes"" ) ; nautilus_file_mark_desktop_file_executable ( file , parameters -> parent_window , TRUE , NULL , NULL ) ; nautilus_file_invalidate_all_attributes ( parameters -> file ) ; screen = gtk_widget_get_screen uri ) ; g_object_unref ( file ",GNOME@nautilus/1630f53481f445ada0a455e9979236d31a8d3bb0,CVE-2017-14604,https://github.com/GNOME/nautilus/commit/1630f53481f445ada0a455e9979236d31a8d3bb0,2017-09-20T08:29Z 328,CWE-191,"CWE-191 static void edge_bulk_in_callback ( struct urb * urb ) { struct edgeport_port * edge_port = urb -> context ; struct device * dev = & edge_port -> port -> dev ; unsigned char * data = urb -> transfer_buffer ; int retval = 0 ; int port_number ; int status = urb -> status ; switch ( status ) { case 0 : break ; case - ECONNRESET : case - ENOENT : case - ESHUTDOWN : dev_dbg ( & urb -> dev -> dev , ""%s-urbshuttingdownwithstatus:%d\\n"" , __func__ , status ) ; return ; default : dev_err ( & urb -> dev -> dev , ""%s-nonzeroreadbulkstatusreceived:%d\\n"" , __func__ , status ) ; } if ( status == - EPIPE ) goto exit ; if ( status ) { dev_err ( & urb -> dev -> dev , ""%s-stoppingread!\\n"" , __func__ ) ; return ; } port_number = edge_port -> port -> port_number ; if ( edge_port -> lsr_event ) { edge_port -> lsr_event = 0 ; dev_dbg ( dev , ""%s=====Port%uLSRStatus=%02x,Data=%02x======\\n"" , __func__ , port_number , edge_port -> lsr_mask , * data ) ; handle_new_lsr ( edge_port , 1 , edge_port -> lsr_mask , * data ) ; -- urb -> actual_length ; ++ data ; } if ( urb -> actual_length ) { usb_serial_debug_data ( dev , __func__ , urb -> actual_length , data ) ; if ( edge_port -> close_pending ) dev_dbg ( dev , ""%s-closepending,droppingdataonthefloor\\n"" , __func__ ) ; else edge_tty_recv ( edge_port -> port , data , urb -> actual_length ) ; edge_port -> port -> icount . rx += urb -> actual_length ; } exit : spin_lock ( & edge_port -> ep_lock ) ; if ( edge_port -> ep_read_urb_state == EDGE_READ_URB_RUNNING ) retval = usb_submit_urb ( urb , GFP_ATOMIC ) ; else if ( edge_port -> ep_read_urb_state == EDGE_READ_URB_STOPPING ) edge_port -> ep_read_urb_state = EDGE_READ_URB_STOPPED ; spin_unlock ( & edge_port -> ep_lock ) ; if ( retval ) dev_err ( dev , ""%s-usb_submit_urbfailedwithresult%d\\n"" , __func__ , retval ) ; } "," ; if ( urb -> actual_length > 0 && ",torvalds@linux/654b404f2a222f918af9b0cd18ad469d0c941a8e,CVE-2017-8924,https://github.com/torvalds/linux/commit/654b404f2a222f918af9b0cd18ad469d0c941a8e,2017-05-12T21:29Z 329,CWE-264,"CWE-264 static struct cifsSesInfo * cifs_find_smb_ses ( struct TCP_Server_Info * server , char * username ) { struct list_head * tmp ; struct cifsSesInfo * ses ; write_lock ( & cifs_tcp_ses_lock ) ; list_for_each ( tmp , & server -> smb_ses_list ) { ses = list_entry ( tmp , struct cifsSesInfo , smb_ses_list ) ; if ( strncmp ( ses -> userName , username , MAX_USERNAME_SIZE ) ) continue ; ++ ses -> ses_count ; write_unlock ( & cifs_tcp_ses_lock ) ; return ses ; } write_unlock ( & cifs_tcp_ses_lock ) ; return NULL ; } "," * server , struct smb_vol * vol ) { struct cifsSesInfo * cifs_tcp_ses_lock ) ; list_for_each_entry ( ses , & server server -> smb_ses_list , smb_ses_list ) { switch ( server -> secType ) { case Kerberos : if ( vol -> linux_uid != ses -> linux_uid ) continue ; break ; default : if ( strncmp -> userName , vol -> ) continue ; if ( strlen ( vol -> username ) != 0 && strncmp ( ses -> password , vol -> password , MAX_PASSWORD_SIZE ) ) continue ; } ",torvalds@linux/4ff67b720c02c36e54d55b88c2931879b7db1cd2,CVE-2011-1585,https://github.com/torvalds/linux/commit/4ff67b720c02c36e54d55b88c2931879b7db1cd2,2013-06-08T13:05Z 330,CWE-119,"CWE-119 static vpx_codec_err_t vp8e_set_config ( vpx_codec_alg_priv_t * ctx , const vpx_codec_enc_cfg_t * cfg ) { vpx_codec_err_t res ; if ( ( ( cfg -> g_w != ctx -> cfg . g_w ) || ( cfg -> g_h != ctx -> cfg . g_h ) ) && ( cfg -> g_lag_in_frames > 1 || cfg -> g_pass != VPX_RC_ONE_PASS ) ) ERROR ( ""Cannotchangewidthorheightafterinitialization"" ) ; if ( ( cfg -> g_lag_in_frames > ctx -> cfg . g_lag_in_frames ) ) ERROR ( ""Cannotincreaselag_in_frames"" ) ; res = validate_config ( ctx , cfg , & ctx -> vp8_cfg , 0 ) ; if ( ! res ) { ctx -> cfg = * cfg ; set_vp8e_config ( & ctx -> oxcf , ctx -> cfg , ctx -> vp8_cfg , NULL ) ; vp8_change_config ( ctx -> cpi , & ctx -> oxcf ) ; } return res ; } "," ; if ( cfg -> g_w cfg . g_w || cfg -> g_h . g_h ) { if ( cfg -> != VPX_RC_ONE_PASS ) ERROR ( ""Cannotchangewidthorheightafterinitialization"" ""Cannotchangewidthorheightafterinitialization"" ) ; if ( ( ctx -> cpi -> initial_width && ( int ) cfg -> g_w > ctx -> cpi -> initial_width ) || ( ctx -> cpi -> initial_height && ( int ) cfg -> g_h > ctx -> cpi -> initial_height ) ) ERROR ( ""Cannotincreasewidthorheightlargerthantheirinitialvalues"" ) ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 331,CWE-119,"CWE-119 static int cmd_mount ( void * data , const char * _input ) { ut64 off = 0 ; char * input , * oinput , * ptr , * ptr2 ; RList * list ; RListIter * iter ; RFSFile * file ; RFSRoot * root ; RFSPlugin * plug ; RFSPartition * part ; RCore * core = ( RCore * ) data ; if ( ! strncmp ( ""kdir"" , _input , 4 ) ) { return cmd_mkdir ( data , _input ) ; } if ( ! strncmp ( ""v"" , _input , 1 ) ) { return cmd_mv ( data , _input ) ; } input = oinput = strdup ( _input ) ; switch ( * input ) { case '' : input ++ ; if ( input [ 0 ] == '' ) input ++ ; ptr = strchr ( input , '' ) ; if ( ptr ) { * ptr = 0 ; ptr ++ ; ptr2 = strchr ( ptr , '' ) ; if ( ptr2 ) { * ptr2 = 0 ; off = r_num_math ( core -> num , ptr2 + 1 ) ; } if ( ! r_fs_mount ( core -> fs , ptr , input , off ) ) eprintf ( ""Cannotmount%s\\n"" , input ) ; } else { if ( ! ( ptr = r_fs_name ( core -> fs , core -> offset ) ) ) eprintf ( ""Unknownfilesystemtype\\n"" ) ; else if ( ! r_fs_mount ( core -> fs , ptr , input , core -> offset ) ) eprintf ( ""Cannotmount%s\\n"" , input ) ; free ( ptr ) ; } break ; case '-' : r_fs_umount ( core -> fs , input + 1 ) ; break ; case '*' : eprintf ( ""Listcommandsinradareformat\\n"" ) ; r_list_foreach ( core -> fs -> roots , iter , root ) { r_cons_printf ( ""m%s%s0x%"" PFMT64x ""\\n"" , root -> path , root -> p -> name , root -> delta ) ; } break ; case '\\0' : r_list_foreach ( core -> fs -> roots , iter , root ) { r_cons_printf ( ""%s\\t0x%"" PFMT64x ""\\t%s\\n"" , root -> p -> name , root -> delta , root -> path ) ; } break ; case 'l' : r_list_foreach ( core -> fs -> plugins , iter , plug ) { r_cons_printf ( ""%10s%s\\n"" , plug -> name , plug -> desc ) ; } break ; case 'd' : input ++ ; if ( input [ 0 ] == '' ) input ++ ; list = r_fs_dir ( core -> fs , input ) ; if ( list ) { r_list_foreach ( list , iter , file ) { r_cons_printf ( ""%c%s\\n"" , file -> type , file -> name ) ; } r_list_free ( list ) ; } else eprintf ( ""Cannotopen\'%s\'directory\\n"" , input ) ; break ; case 'p' : input ++ ; if ( * input == '' ) input ++ ; ptr = strchr ( input , '' ) ; if ( ptr ) { * ptr = 0 ; off = r_num_math ( core -> num , ptr + 1 ) ; } list = r_fs_partitions ( core -> fs , input , off ) ; if ( list ) { r_list_foreach ( list , iter , part ) { r_cons_printf ( ""%d%02x0x%010"" PFMT64x ""0x%010"" PFMT64x ""\\n"" , part -> number , part -> type , part -> start , part -> start + part -> length ) ; } r_list_free ( list ) ; } else eprintf ( ""Cannotreadpartition\\n"" ) ; break ; case 'o' : input ++ ; if ( input [ 0 ] == '' ) input ++ ; file = r_fs_open ( core -> fs , input ) ; if ( file ) { r_fs_read ( core -> fs , file , 0 , file -> size ) ; r_cons_printf ( ""ffile%d0x%08"" PFMT64x ""\\n"" , file -> size , file -> off ) ; r_fs_close ( core -> fs , file ) ; } else eprintf ( ""Cannotopenfile\\n"" ) ; break ; case 'g' : input ++ ; if ( * input == '' ) input ++ ; ptr = strchr ( input , '' ) ; if ( ptr ) * ptr ++ = 0 ; else ptr = ""./"" ; file = r_fs_open ( core -> fs , input ) ; if ( file ) { r_fs_read ( core -> fs , file , 0 , file -> size ) ; write ( 1 , file -> data , file -> size ) ; r_fs_close ( core -> fs , file ) ; write ( 1 , ""\\n"" , 1 ) ; } else if ( ! r_fs_dir_dump ( core -> fs , input , ptr ) ) eprintf ( ""Cannotopenfile\\n"" ) ; break ; case 'f' : input ++ ; switch ( * input ) { case '?' : r_cons_printf ( ""Usage:mf[no][...]\\n"" ""mfn/foo*.c;searchfilesbynamein/foopath\\n"" ""mfo/foo0x5e91;searchfilesbyoffsetin/foopath\\n"" ) ; break ; case 'n' : input ++ ; if ( * input == '' ) input ++ ; ptr = strchr ( input , '' ) ; if ( ptr ) { * ptr ++ = 0 ; list = r_fs_find_name ( core -> fs , input , ptr ) ; r_list_foreach ( list , iter , ptr ) { r_str_chop_path ( ptr ) ; printf ( ""%s\\n"" , ptr ) ; } } else eprintf ( ""Unknownstorepath\\n"" ) ; break ; case 'o' : input ++ ; if ( * input == '' ) input ++ ; ptr = strchr ( input , '' ) ; if ( ptr ) { * ptr ++ = 0 ; ut64 off = r_num_math ( core -> num , ptr ) ; list = r_fs_find_off ( core -> fs , input , off ) ; r_list_foreach ( list , iter , ptr ) { r_str_chop_path ( ptr ) ; printf ( ""%s\\n"" , ptr ) ; } } else eprintf ( ""Unknownstorepath\\n"" ) ; break ; } break ; case 's' : if ( core -> http_up ) { free ( oinput ) ; return false ; } input ++ ; if ( input [ 0 ] == '' ) input ++ ; r_fs_prompt ( core -> fs , input ) ; break ; case 'y' : eprintf ( ""TODO\\n"" ) ; break ; case '?' : { const char * help_msg [ ] = { ""Usage:"" , ""m[-?*dgy][...]"" , ""Mountpointsmanagement"" , ""m"" , """" , ""Listallmountpointsinhumanreadableformat"" , ""m*"" , """" , ""Sameasabove,butinr2commands"" , ""ml"" , """" , ""Listfilesystemplugins"" , ""m"" , ""/mnt"" , ""Mountfsat/mntwithautodetectfsandcurrentoffset"" , ""m"" , ""/mntext20"" , ""Mountext2fsat/mntwithdelta0onIO"" , ""m-/"" , """" , ""Umountgivenpath(/)"" , ""my"" , """" , ""Yankcontentsoffileintoclipboard"" , ""mo"" , ""/foo"" , ""Getoffsetandsizeofgivenfile"" , ""mg"" , ""/foo"" , ""Getcontentsoffile/dirdumpedtodisk(XXX?)"" , ""mf"" , ""[?][o|n]"" , ""Searchfilesforgivenfilenameorforoffset"" , ""md"" , ""/"" , ""Listdirectorycontentsforpath"" , ""mp"" , """" , ""Listallsupportedpartitiontypes"" , ""mp"" , ""msdos0"" , ""Showpartitionsinmsdosformatatoffset0"" , ""ms"" , ""/mnt"" , ""Openfilesystempromptat/mnt"" , NULL } ; r_core_cmd_help ( core , help_msg ) ; } break ; } free ( oinput ) ; return 0 ; } "," == '' ) { input ++ ; } ptr = strchr off ) ) { ) ; } } ) ) ) { ""Unknownfilesystemtype\\n"" ) ; } offset ) ) { input ) ; } ",radare@radare2/65000a7fd9eea62359e6d6714f17b94a99a82edd,CVE-2017-9763,https://github.com/radare/radare2/commit/65000a7fd9eea62359e6d6714f17b94a99a82edd,2017-06-19T16:29Z 332,CWE-399,"CWE-399 int hugetlb_reserve_pages ( struct inode * inode , long from , long to , struct vm_area_struct * vma , vm_flags_t vm_flags ) { long ret , chg ; struct hstate * h = hstate_inode ( inode ) ; if ( vm_flags & VM_NORESERVE ) return 0 ; if ( ! vma || vma -> vm_flags & VM_MAYSHARE ) chg = region_chg ( & inode -> i_mapping -> private_list , from , to ) ; else { struct resv_map * resv_map = resv_map_alloc ( ) ; if ( ! resv_map ) return - ENOMEM ; chg = to - from ; set_vma_resv_map ( vma , resv_map ) ; set_vma_resv_flags ( vma , HPAGE_RESV_OWNER ) ; } if ( chg < 0 ) return chg ; if ( hugetlb_get_quota ( inode -> i_mapping , chg ) ) return - ENOSPC ; ret = hugetlb_acct_memory ( h , chg ) ; if ( ret < 0 ) { hugetlb_put_quota ( inode -> i_mapping , chg ) ; return ret ; } if ( ! vma || vma -> vm_flags & VM_MAYSHARE ) region_add ( & inode -> i_mapping -> private_list , from , to ) ; return 0 ; } "," inode ) ; struct hugepage_subpool * spool = subpool_inode ( inode ) ; ; if ( hugepage_subpool_get_pages ( spool , chg ) 0 ) { hugepage_subpool_put_pages ( spool , chg ) ",torvalds@linux/90481622d75715bfcb68501280a917dbfe516029,CVE-2012-2133,https://github.com/torvalds/linux/commit/90481622d75715bfcb68501280a917dbfe516029,2012-07-03T16:40Z 333,CWE-404,"CWE-404 int install_thread_keyring_to_cred ( struct cred * new ) { struct key * keyring ; keyring = keyring_alloc ( ""_tid"" , new -> uid , new -> gid , new , KEY_POS_ALL | KEY_USR_VIEW , KEY_ALLOC_QUOTA_OVERRUN , NULL , NULL ) ; if ( IS_ERR ( keyring ) ) return PTR_ERR ( keyring ) ; new -> thread_keyring = keyring ; return 0 ; } "," key * keyring ; if ( new -> thread_keyring ) return 0 ",torvalds@linux/c9f838d104fed6f2f61d68164712e3204bf5271b,CVE-2017-7472,https://github.com/torvalds/linux/commit/c9f838d104fed6f2f61d68164712e3204bf5271b,2017-05-11T19:29Z 334,CWE-399,"CWE-399 int sfgets ( void ) { struct pollfd pfd ; int pollret ; ssize_t readnb ; signed char seen_r = 0 ; static size_t scanned ; static size_t readnbd ; if ( scanned > ( size_t ) 0U ) { readnbd -= scanned ; memmove ( cmd , cmd + scanned , readnbd ) ; scanned = ( size_t ) 0U ; } pfd . fd = clientfd ; # ifdef __APPLE_CC__ pfd . events = POLLIN | POLLERR | POLLHUP ; # else pfd . events = POLLIN | POLLPRI | POLLERR | POLLHUP ; # endif while ( scanned < cmdsize ) { if ( scanned >= readnbd ) { pfd . revents = 0 ; while ( ( pollret = poll ( & pfd , 1U , idletime * 1000UL ) ) < 0 && errno == EINTR ) ; if ( pollret == 0 ) { return - 1 ; } if ( pollret <= 0 || ( pfd . revents & ( POLLERR | POLLHUP | POLLNVAL ) ) != 0 ) { return - 2 ; } if ( ( pfd . revents & ( POLLIN | POLLPRI ) ) == 0 ) { continue ; } if ( readnbd >= cmdsize ) { break ; } # ifdef WITH_TLS if ( tls_cnx != NULL ) { while ( ( readnb = SSL_read ( tls_cnx , cmd + readnbd , cmdsize - readnbd ) ) < ( ssize_t ) 0 && errno == EINTR ) ; } else # endif { while ( ( readnb = read ( clientfd , cmd + readnbd , cmdsize - readnbd ) ) < ( ssize_t ) 0 && errno == EINTR ) ; } if ( readnb <= ( ssize_t ) 0 ) { return - 2 ; } readnbd += readnb ; if ( readnbd > cmdsize ) { return - 2 ; } } # ifdef RFC_CONFORMANT_LINES if ( seen_r != 0 ) { # endif if ( cmd [ scanned ] == '\\n' ) { # ifndef RFC_CONFORMANT_LINES if ( seen_r != 0 ) { # endif cmd [ scanned - 1U ] = 0 ; # ifndef RFC_CONFORMANT_LINES } else { cmd [ scanned ] = 0 ; } # endif if ( ++ scanned >= readnbd ) { scanned = readnbd = ( size_t ) 0U ; } return 0 ; } seen_r = 0 ; # ifdef RFC_CONFORMANT_LINES } # endif if ( ISCTRLCODE ( cmd [ scanned ] ) ) { if ( cmd [ scanned ] == '\\r' ) { seen_r = 1 ; } # ifdef RFC_CONFORMANT_PARSER else if ( cmd [ scanned ] == 0 ) { cmd [ scanned ] = '\\n' ; } # else cmd [ scanned ] = '_' ; # endif } scanned ++ ; } die ( 421 , LOG_WARNING , MSG_LINE_TOO_LONG ) ; return 0 ; } "," = 0 ; if ( scanned ",jedisct1@pure-ftpd/65c4d4ad331e94661de763e9b5304d28698999c4,CVE-2011-1575,https://github.com/jedisct1/pure-ftpd/commit/65c4d4ad331e94661de763e9b5304d28698999c4,2011-05-23T22:55Z 335,CWE-416,"CWE-416 mrb_value mrb_io_initialize_copy ( mrb_state * mrb , mrb_value copy ) { mrb_value orig ; mrb_value buf ; struct mrb_io * fptr_copy ; struct mrb_io * fptr_orig ; mrb_bool failed = TRUE ; mrb_get_args ( mrb , ""o"" , & orig ) ; fptr_copy = ( struct mrb_io * ) DATA_PTR ( copy ) ; if ( fptr_copy != NULL ) { fptr_finalize ( mrb , fptr_copy , FALSE ) ; mrb_free ( mrb , fptr_copy ) ; } fptr_copy = ( struct mrb_io * ) mrb_io_alloc ( mrb ) ; fptr_orig = io_get_open_fptr ( mrb , orig ) ; DATA_TYPE ( copy ) = & mrb_io_type ; DATA_PTR ( copy ) = fptr_copy ; buf = mrb_iv_get ( mrb , orig , mrb_intern_cstr ( mrb , ""@buf"" ) ) ; mrb_iv_set ( mrb , copy , mrb_intern_cstr ( mrb , ""@buf"" ) , buf ) ; fptr_copy -> fd = mrb_dup ( mrb , fptr_orig -> fd , & failed ) ; if ( failed ) { mrb_sys_fail ( mrb , 0 ) ; } mrb_fd_cloexec ( mrb , fptr_copy -> fd ) ; if ( fptr_orig -> fd2 != - 1 ) { fptr_copy -> fd2 = mrb_dup ( mrb , fptr_orig -> fd2 , & failed ) ; if ( failed ) { close ( fptr_copy -> fd ) ; mrb_sys_fail ( mrb , 0 ) ; } mrb_fd_cloexec ( mrb , fptr_copy -> fd2 ) ; } fptr_copy -> pid = fptr_orig -> pid ; fptr_copy -> readable = fptr_orig -> readable ; fptr_copy -> writable = fptr_orig -> writable ; fptr_copy -> sync = fptr_orig -> sync ; fptr_copy -> is_socket = fptr_orig -> is_socket ; return copy ; } "," orig ) ; fptr_orig = io_get_open_fptr ( mrb , orig ) ; mrb_io_alloc ( mrb ) ; DATA_TYPE ",mruby@mruby/b51b21fc63c9805862322551387d9036f2b63433,CVE-2018-10199,https://github.com/mruby/mruby/commit/b51b21fc63c9805862322551387d9036f2b63433,2018-04-18T15:29Z 336,CWE-476,"CWE-476 struct key * key_get_instantiation_authkey ( key_serial_t target_id ) { char description [ 16 ] ; struct keyring_search_context ctx = { . index_key . type = & key_type_request_key_auth , . index_key . description = description , . cred = current_cred ( ) , . match_data . cmp = user_match , . match_data . raw_data = description , . match_data . lookup_type = KEYRING_SEARCH_LOOKUP_DIRECT , } ; struct key * authkey ; key_ref_t authkey_ref ; sprintf ( description , ""%x"" , target_id ) ; authkey_ref = search_process_keyrings ( & ctx ) ; if ( IS_ERR ( authkey_ref ) ) { authkey = ERR_CAST ( authkey_ref ) ; if ( authkey == ERR_PTR ( - EAGAIN ) ) authkey = ERR_PTR ( - ENOKEY ) ; goto error ; } authkey = key_ref_to_ptr ( authkey_ref ) ; if ( test_bit ( KEY_FLAG_REVOKED , & authkey -> flags ) ) { key_put ( authkey ) ; authkey = ERR_PTR ( - EKEYREVOKED ) ; } error : return authkey ; } "," . cmp = key_default_cmp , . match_data ",torvalds@linux/c06cfb08b88dfbe13be44a69ae2fdc3a7c902d81,CVE-2017-2647,https://github.com/torvalds/linux/commit/c06cfb08b88dfbe13be44a69ae2fdc3a7c902d81,2017-03-31T04:59Z 337,CWE-119,"CWE-119 void vp9_frame_init_quantizer ( VP9_COMP * cpi ) { cpi -> zbin_mode_boost = 0 ; vp9_init_plane_quantizers ( cpi , & cpi -> mb ) ; } "," cpi ) { vp9_init_plane_quantizers ( cpi & cpi -> td . ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 338,CWE-119,"CWE-119 static TEE_Result tee_svc_copy_param ( struct tee_ta_session * sess , struct tee_ta_session * called_sess , struct utee_params * callee_params , struct tee_ta_param * param , void * tmp_buf_va [ TEE_NUM_PARAMS ] , struct mobj * * mobj_tmp ) { size_t n ; TEE_Result res ; size_t req_mem = 0 ; size_t s ; uint8_t * dst = 0 ; bool ta_private_memref [ TEE_NUM_PARAMS ] ; struct user_ta_ctx * utc = to_user_ta_ctx ( sess -> ctx ) ; void * va ; size_t dst_offs ; if ( ! callee_params ) { memset ( param , 0 , sizeof ( * param ) ) ; } else { res = tee_mmu_check_access_rights ( utc , TEE_MEMORY_ACCESS_READ | TEE_MEMORY_ACCESS_ANY_OWNER , ( uaddr_t ) callee_params , sizeof ( struct utee_params ) ) ; if ( res != TEE_SUCCESS ) return res ; utee_param_to_param ( param , callee_params ) ; } if ( called_sess && is_pseudo_ta_ctx ( called_sess -> ctx ) ) { return TEE_SUCCESS ; } for ( n = 0 ; n < TEE_NUM_PARAMS ; n ++ ) { ta_private_memref [ n ] = false ; switch ( TEE_PARAM_TYPE_GET ( param -> types , n ) ) { case TEE_PARAM_TYPE_MEMREF_INPUT : case TEE_PARAM_TYPE_MEMREF_OUTPUT : case TEE_PARAM_TYPE_MEMREF_INOUT : va = ( void * ) param -> u [ n ] . mem . offs ; s = param -> u [ n ] . mem . size ; if ( ! va ) { if ( s ) return TEE_ERROR_BAD_PARAMETERS ; break ; } if ( tee_mmu_is_vbuf_inside_ta_private ( utc , va , s ) ) { s = ROUNDUP ( s , sizeof ( uint32_t ) ) ; if ( ADD_OVERFLOW ( req_mem , s , & req_mem ) ) return TEE_ERROR_BAD_PARAMETERS ; ta_private_memref [ n ] = true ; break ; } res = tee_mmu_vbuf_to_mobj_offs ( utc , va , s , & param -> u [ n ] . mem . mobj , & param -> u [ n ] . mem . offs ) ; if ( res != TEE_SUCCESS ) return res ; break ; default : break ; } } if ( req_mem == 0 ) return TEE_SUCCESS ; res = alloc_temp_sec_mem ( req_mem , mobj_tmp , & dst ) ; if ( res != TEE_SUCCESS ) return res ; dst_offs = 0 ; for ( n = 0 ; n < TEE_NUM_PARAMS ; n ++ ) { if ( ! ta_private_memref [ n ] ) continue ; s = ROUNDUP ( param -> u [ n ] . mem . size , sizeof ( uint32_t ) ) ; switch ( TEE_PARAM_TYPE_GET ( param -> types , n ) ) { case TEE_PARAM_TYPE_MEMREF_INPUT : case TEE_PARAM_TYPE_MEMREF_INOUT : va = ( void * ) param -> u [ n ] . mem . offs ; if ( va ) { res = tee_svc_copy_from_user ( dst , va , param -> u [ n ] . mem . size ) ; if ( res != TEE_SUCCESS ) return res ; param -> u [ n ] . mem . offs = dst_offs ; param -> u [ n ] . mem . mobj = * mobj_tmp ; tmp_buf_va [ n ] = dst ; dst += s ; dst_offs += s ; } break ; case TEE_PARAM_TYPE_MEMREF_OUTPUT : va = ( void * ) param -> u [ n ] . mem . offs ; if ( va ) { param -> u [ n ] . mem . offs = dst_offs ; param -> u [ n ] . mem . mobj = * mobj_tmp ; tmp_buf_va [ n ] = dst ; dst += s ; dst_offs += s ; } break ; default : continue ; } } return TEE_SUCCESS ; } "," return res ; res = utee_param_to_param ( utc , param , callee_params , callee_params ) ; if ( res != TEE_SUCCESS ) return res ",OP-TEE@optee_os/d5c5b0b77b2b589666024d219a8007b3f5b6faeb,CVE-2019-1010295,https://github.com/OP-TEE/optee_os/commit/d5c5b0b77b2b589666024d219a8007b3f5b6faeb,2019-07-15T18:15Z 339,CWE-000,"CWE-000 static int em_call_far ( struct x86_emulate_ctxt * ctxt ) { u16 sel , old_cs ; ulong old_eip ; int rc ; old_cs = get_segment_selector ( ctxt , VCPU_SREG_CS ) ; old_eip = ctxt -> _eip ; memcpy ( & sel , ctxt -> src . valptr + ctxt -> op_bytes , 2 ) ; if ( load_segment_descriptor ( ctxt , sel , VCPU_SREG_CS ) ) return X86EMUL_CONTINUE ; ctxt -> _eip = 0 ; memcpy ( & ctxt -> _eip , ctxt -> src . valptr , ctxt -> op_bytes ) ; ctxt -> src . val = old_cs ; rc = em_push ( ctxt ) ; if ( rc != X86EMUL_CONTINUE ) return rc ; ctxt -> src . val = old_eip ; return em_push ( ctxt ) ; } "," int rc ; struct desc_struct old_desc , new_desc ; const struct x86_emulate_ops * ops = ctxt -> ops ; int cpl = ctxt -> ops -> cpl ( ctxt ) ; old_eip = ctxt -> _eip ; ops -> get_segment ( ctxt , & old_cs , & old_desc , NULL , VCPU_SREG_CS ) , VCPU_SREG_CS ) ; memcpy ( 2 ) ; rc = __load_segment_descriptor ( ctxt , sel , VCPU_SREG_CS , cpl , false , & new_desc ) ; if ( rc != X86EMUL_CONTINUE ) return X86EMUL_CONTINUE return X86EMUL_CONTINUE ; rc = assign_eip_far ( ctxt , ctxt -> src . val , new_desc . l ) ; if ( rc != X86EMUL_CONTINUE ) goto fail ; ctxt -> src . val = old_cs ; rc = em_push ( ctxt ) ; if ( rc != X86EMUL_CONTINUE ) goto fail ; ctxt -> src . val = old_eip ; rc = em_push ( ctxt ) ; if ( rc != X86EMUL_CONTINUE ) goto fail ; return rc ; fail : ops -> set_segment ( ctxt , old_cs , & old_desc , 0 , VCPU_SREG_CS ) ; return rc ; } ",torvalds@linux/d1442d85cc30ea75f7d399474ca738e0bc96f715,CVE-2014-3647,https://github.com/torvalds/linux/commit/d1442d85cc30ea75f7d399474ca738e0bc96f715,2014-11-10T11:55Z 340,CWE-000,"CWE-000 int ff_jpeg2000_init_component ( Jpeg2000Component * comp , Jpeg2000CodingStyle * codsty , Jpeg2000QuantStyle * qntsty , int cbps , int dx , int dy , AVCodecContext * avctx ) { uint8_t log2_band_prec_width , log2_band_prec_height ; int reslevelno , bandno , gbandno = 0 , ret , i , j ; uint32_t csize ; if ( codsty -> nreslevels2decode <= 0 ) { av_log ( avctx , AV_LOG_ERROR , ""nreslevels2decode%dinvalidoruninitialized\\n"" , codsty -> nreslevels2decode ) ; return AVERROR_INVALIDDATA ; } if ( ret = ff_jpeg2000_dwt_init ( & comp -> dwt , comp -> coord , codsty -> nreslevels2decode - 1 , codsty -> transform ) ) return ret ; csize = ( comp -> coord [ 0 ] [ 1 ] - comp -> coord [ 0 ] [ 0 ] ) * ( comp -> coord [ 1 ] [ 1 ] - comp -> coord [ 1 ] [ 0 ] ) ; if ( codsty -> transform == FF_DWT97 ) { comp -> i_data = NULL ; comp -> f_data = av_malloc_array ( csize , sizeof ( * comp -> f_data ) ) ; if ( ! comp -> f_data ) return AVERROR ( ENOMEM ) ; } else { comp -> f_data = NULL ; comp -> i_data = av_malloc_array ( csize , sizeof ( * comp -> i_data ) ) ; if ( ! comp -> i_data ) return AVERROR ( ENOMEM ) ; } comp -> reslevel = av_malloc_array ( codsty -> nreslevels , sizeof ( * comp -> reslevel ) ) ; if ( ! comp -> reslevel ) return AVERROR ( ENOMEM ) ; for ( reslevelno = 0 ; reslevelno < codsty -> nreslevels ; reslevelno ++ ) { int declvl = codsty -> nreslevels - reslevelno ; Jpeg2000ResLevel * reslevel = comp -> reslevel + reslevelno ; for ( i = 0 ; i < 2 ; i ++ ) for ( j = 0 ; j < 2 ; j ++ ) reslevel -> coord [ i ] [ j ] = ff_jpeg2000_ceildivpow2 ( comp -> coord_o [ i ] [ j ] , declvl - 1 ) ; reslevel -> log2_prec_width = codsty -> log2_prec_widths [ reslevelno ] ; reslevel -> log2_prec_height = codsty -> log2_prec_heights [ reslevelno ] ; if ( reslevelno == 0 ) reslevel -> nbands = 1 ; else reslevel -> nbands = 3 ; if ( reslevel -> coord [ 0 ] [ 1 ] == reslevel -> coord [ 0 ] [ 0 ] ) reslevel -> num_precincts_x = 0 ; else reslevel -> num_precincts_x = ff_jpeg2000_ceildivpow2 ( reslevel -> coord [ 0 ] [ 1 ] , reslevel -> log2_prec_width ) - ( reslevel -> coord [ 0 ] [ 0 ] >> reslevel -> log2_prec_width ) ; if ( reslevel -> coord [ 1 ] [ 1 ] == reslevel -> coord [ 1 ] [ 0 ] ) reslevel -> num_precincts_y = 0 ; else reslevel -> num_precincts_y = ff_jpeg2000_ceildivpow2 ( reslevel -> coord [ 1 ] [ 1 ] , reslevel -> log2_prec_height ) - ( reslevel -> coord [ 1 ] [ 0 ] >> reslevel -> log2_prec_height ) ; reslevel -> band = av_malloc_array ( reslevel -> nbands , sizeof ( * reslevel -> band ) ) ; if ( ! reslevel -> band ) return AVERROR ( ENOMEM ) ; for ( bandno = 0 ; bandno < reslevel -> nbands ; bandno ++ , gbandno ++ ) { Jpeg2000Band * band = reslevel -> band + bandno ; int cblkno , precno ; int nb_precincts ; switch ( qntsty -> quantsty ) { uint8_t gain ; int numbps ; case JPEG2000_QSTY_NONE : band -> f_stepsize = 1 ; break ; case JPEG2000_QSTY_SI : numbps = cbps + lut_gain [ codsty -> transform == FF_DWT53 ] [ bandno + ( reslevelno > 0 ) ] ; band -> f_stepsize = SHL ( 2048 + qntsty -> mant [ gbandno ] , 2 + numbps - qntsty -> expn [ gbandno ] ) ; break ; case JPEG2000_QSTY_SE : gain = cbps ; band -> f_stepsize = pow ( 2.0 , gain - qntsty -> expn [ gbandno ] ) ; band -> f_stepsize *= qntsty -> mant [ gbandno ] / 2048.0 + 1.0 ; break ; default : band -> f_stepsize = 0 ; av_log ( avctx , AV_LOG_ERROR , ""Unknownquantizationformat\\n"" ) ; break ; } if ( ! av_codec_is_encoder ( avctx -> codec ) ) band -> f_stepsize *= 0.5 ; band -> i_stepsize = band -> f_stepsize * ( 1 << 15 ) ; if ( reslevelno == 0 ) { for ( i = 0 ; i < 2 ; i ++ ) for ( j = 0 ; j < 2 ; j ++ ) band -> coord [ i ] [ j ] = ff_jpeg2000_ceildivpow2 ( comp -> coord_o [ i ] [ j ] - comp -> coord_o [ i ] [ 0 ] , declvl - 1 ) ; log2_band_prec_width = reslevel -> log2_prec_width ; log2_band_prec_height = reslevel -> log2_prec_height ; band -> log2_cblk_width = FFMIN ( codsty -> log2_cblk_width , reslevel -> log2_prec_width ) ; band -> log2_cblk_height = FFMIN ( codsty -> log2_cblk_height , reslevel -> log2_prec_height ) ; } else { for ( i = 0 ; i < 2 ; i ++ ) for ( j = 0 ; j < 2 ; j ++ ) band -> coord [ i ] [ j ] = ff_jpeg2000_ceildivpow2 ( comp -> coord_o [ i ] [ j ] - comp -> coord_o [ i ] [ 0 ] - ( ( ( bandno + 1 >> i ) & 1 ) << declvl - 1 ) , declvl ) ; band -> log2_cblk_width = FFMIN ( codsty -> log2_cblk_width , reslevel -> log2_prec_width - 1 ) ; band -> log2_cblk_height = FFMIN ( codsty -> log2_cblk_height , reslevel -> log2_prec_height - 1 ) ; log2_band_prec_width = reslevel -> log2_prec_width - 1 ; log2_band_prec_height = reslevel -> log2_prec_height - 1 ; } for ( j = 0 ; j < 2 ; j ++ ) band -> coord [ 0 ] [ j ] = ff_jpeg2000_ceildiv ( band -> coord [ 0 ] [ j ] , dx ) ; for ( j = 0 ; j < 2 ; j ++ ) band -> coord [ 1 ] [ j ] = ff_jpeg2000_ceildiv ( band -> coord [ 1 ] [ j ] , dy ) ; band -> prec = av_malloc_array ( reslevel -> num_precincts_x * ( uint64_t ) reslevel -> num_precincts_y , sizeof ( * band -> prec ) ) ; if ( ! band -> prec ) return AVERROR ( ENOMEM ) ; nb_precincts = reslevel -> num_precincts_x * reslevel -> num_precincts_y ; for ( precno = 0 ; precno < nb_precincts ; precno ++ ) { Jpeg2000Prec * prec = band -> prec + precno ; prec -> coord [ 0 ] [ 0 ] = ( precno % reslevel -> num_precincts_x ) * ( 1 << log2_band_prec_width ) ; prec -> coord [ 0 ] [ 0 ] = FFMAX ( prec -> coord [ 0 ] [ 0 ] , band -> coord [ 0 ] [ 0 ] ) ; prec -> coord [ 1 ] [ 0 ] = ( precno / reslevel -> num_precincts_x ) * ( 1 << log2_band_prec_height ) ; prec -> coord [ 1 ] [ 0 ] = FFMAX ( prec -> coord [ 1 ] [ 0 ] , band -> coord [ 1 ] [ 0 ] ) ; prec -> coord [ 0 ] [ 1 ] = prec -> coord [ 0 ] [ 0 ] + ( 1 << log2_band_prec_width ) ; prec -> coord [ 0 ] [ 1 ] = FFMIN ( prec -> coord [ 0 ] [ 1 ] , band -> coord [ 0 ] [ 1 ] ) ; prec -> coord [ 1 ] [ 1 ] = prec -> coord [ 1 ] [ 0 ] + ( 1 << log2_band_prec_height ) ; prec -> coord [ 1 ] [ 1 ] = FFMIN ( prec -> coord [ 1 ] [ 1 ] , band -> coord [ 1 ] [ 1 ] ) ; prec -> nb_codeblocks_width = ff_jpeg2000_ceildivpow2 ( prec -> coord [ 0 ] [ 1 ] - prec -> coord [ 0 ] [ 0 ] , band -> log2_cblk_width ) ; prec -> nb_codeblocks_height = ff_jpeg2000_ceildivpow2 ( prec -> coord [ 1 ] [ 1 ] - prec -> coord [ 1 ] [ 0 ] , band -> log2_cblk_height ) ; prec -> cblkincl = ff_jpeg2000_tag_tree_init ( prec -> nb_codeblocks_width , prec -> nb_codeblocks_height ) ; if ( ! prec -> cblkincl ) return AVERROR ( ENOMEM ) ; prec -> zerobits = ff_jpeg2000_tag_tree_init ( prec -> nb_codeblocks_width , prec -> nb_codeblocks_height ) ; if ( ! prec -> zerobits ) return AVERROR ( ENOMEM ) ; prec -> cblk = av_mallocz_array ( prec -> nb_codeblocks_width * ( uint64_t ) prec -> nb_codeblocks_height , sizeof ( * prec -> cblk ) ) ; if ( ! prec -> cblk ) return AVERROR ( ENOMEM ) ; for ( cblkno = 0 ; cblkno < prec -> nb_codeblocks_width * prec -> nb_codeblocks_height ; cblkno ++ ) { Jpeg2000Cblk * cblk = prec -> cblk + cblkno ; uint16_t Cx0 , Cy0 ; Cx0 = ( prec -> coord [ 0 ] [ 0 ] >> band -> log2_cblk_width ) << band -> log2_cblk_width ; Cx0 = Cx0 + ( ( cblkno % prec -> nb_codeblocks_width ) << band -> log2_cblk_width ) ; cblk -> coord [ 0 ] [ 0 ] = FFMAX ( Cx0 , prec -> coord [ 0 ] [ 0 ] ) ; Cy0 = ( prec -> coord [ 1 ] [ 0 ] >> band -> log2_cblk_height ) << band -> log2_cblk_height ; Cy0 = Cy0 + ( ( cblkno / prec -> nb_codeblocks_width ) << band -> log2_cblk_height ) ; cblk -> coord [ 1 ] [ 0 ] = FFMAX ( Cy0 , prec -> coord [ 1 ] [ 0 ] ) ; cblk -> coord [ 0 ] [ 1 ] = FFMIN ( Cx0 + ( 1 << band -> log2_cblk_width ) , prec -> coord [ 0 ] [ 1 ] ) ; cblk -> coord [ 1 ] [ 1 ] = FFMIN ( Cy0 + ( 1 << band -> log2_cblk_height ) , prec -> coord [ 1 ] [ 1 ] ) ; if ( ( bandno + ! ! reslevelno ) & 1 ) { cblk -> coord [ 0 ] [ 0 ] += comp -> reslevel [ reslevelno - 1 ] . coord [ 0 ] [ 1 ] - comp -> reslevel [ reslevelno - 1 ] . coord [ 0 ] [ 0 ] ; cblk -> coord [ 0 ] [ 1 ] += comp -> reslevel [ reslevelno - 1 ] . coord [ 0 ] [ 1 ] - comp -> reslevel [ reslevelno - 1 ] . coord [ 0 ] [ 0 ] ; } if ( ( bandno + ! ! reslevelno ) & 2 ) { cblk -> coord [ 1 ] [ 0 ] += comp -> reslevel [ reslevelno - 1 ] . coord [ 1 ] [ 1 ] - comp -> reslevel [ reslevelno - 1 ] . coord [ 1 ] [ 0 ] ; cblk -> coord [ 1 ] [ 1 ] += comp -> reslevel [ reslevelno - 1 ] . coord [ 1 ] [ 1 ] - comp -> reslevel [ reslevelno - 1 ] . coord [ 1 ] [ 0 ] ; } cblk -> zero = 0 ; cblk -> lblock = 3 ; cblk -> length = 0 ; cblk -> lengthinc = 0 ; cblk -> npasses = 0 ; } } } } return 0 ; } "," -> band = av_calloc ( reslevel -> -> prec = av_calloc ( reslevel -> ",FFmpeg@FFmpeg/912ce9dd2080c5837285a471d750fa311e09b555,CVE-2013-7017,https://github.com/FFmpeg/FFmpeg/commit/912ce9dd2080c5837285a471d750fa311e09b555,2013-12-09T16:36Z 341,CWE-269,"CWE-269 void Con_Dump_f ( void ) { int l , x , i ; short * line ; fileHandle_t f ; int bufferlen ; char * buffer ; char filename [ MAX_QPATH ] ; if ( Cmd_Argc ( ) != 2 ) { Com_Printf ( ""usage:condump\\n"" ) ; return ; } Q_strncpyz ( filename , Cmd_Argv ( 1 ) , sizeof ( filename ) ) ; COM_DefaultExtension ( filename , sizeof ( filename ) , "".txt"" ) ; f = FS_FOpenFileWrite ( filename ) ; if ( ! f ) { Com_Printf ( ""ERROR:couldn\'topen%s.\\n"" , filename ) ; return ; } Com_Printf ( ""Dumpedconsoletextto%s.\\n"" , filename ) ; for ( l = con . current - con . totallines + 1 ; l <= con . current ; l ++ ) { line = con . text + ( l % con . totallines ) * con . linewidth ; for ( x = 0 ; x < con . linewidth ; x ++ ) if ( ( line [ x ] & 0xff ) != '' ) { break ; } if ( x != con . linewidth ) { break ; } } # ifdef _WIN32 bufferlen = con . linewidth + 3 * sizeof ( char ) ; # else bufferlen = con . linewidth + 2 * sizeof ( char ) ; # endif buffer = Hunk_AllocateTempMemory ( bufferlen ) ; buffer [ bufferlen - 1 ] = 0 ; for ( ; l <= con . current ; l ++ ) { line = con . text + ( l % con . totallines ) * con . linewidth ; for ( i = 0 ; i < con . linewidth ; i ++ ) buffer [ i ] = line [ i ] & 0xff ; for ( x = con . linewidth - 1 ; x >= 0 ; x -- ) { if ( buffer [ x ] == '' ) { buffer [ x ] = 0 ; } else { break ; } } # ifdef _WIN32 Q_strcat ( buffer , bufferlen , ""\\r\\n"" ) ; # else Q_strcat ( buffer , bufferlen , ""\\n"" ) ; # endif FS_Write ( buffer , strlen ( buffer ) , f ) ; } Hunk_FreeTempMemory ( buffer ) ; FS_FCloseFile ( f ) ; } "," "".txt"" ) ; if ( ! COM_CompareExtension ( filename , "".txt"" ) ) { Com_Printf ( ""Con_Dump_f:Onlythe\\"".txt\\""extensionissupportedbythiscommand!\\n"" ) ; return ; } ",iortcw@iortcw/11a83410153756ae350a82ed41b08d128ff7f998,CVE-2017-6903,https://github.com/iortcw/iortcw/commit/11a83410153756ae350a82ed41b08d128ff7f998,2017-03-14T22:59Z 342,CWE-119,"CWE-119 static RList * relocs ( RBinFile * arch ) { struct r_bin_bflt_obj * obj = ( struct r_bin_bflt_obj * ) arch -> o -> bin_obj ; RList * list = r_list_newf ( ( RListFree ) free ) ; int i , len , n_got , amount ; if ( ! list || ! obj ) { r_list_free ( list ) ; return NULL ; } if ( obj -> hdr -> flags & FLAT_FLAG_GOTPIC ) { n_got = get_ngot_entries ( obj ) ; if ( n_got ) { amount = n_got * sizeof ( ut32 ) ; if ( amount < n_got || amount > UT32_MAX ) { goto out_error ; } struct reloc_struct_t * got_table = calloc ( 1 , n_got * sizeof ( ut32 ) ) ; if ( got_table ) { ut32 offset = 0 ; for ( i = 0 ; i < n_got ; offset += 4 , i ++ ) { ut32 got_entry ; if ( obj -> hdr -> data_start + offset + 4 > obj -> size || obj -> hdr -> data_start + offset + 4 < offset ) { break ; } len = r_buf_read_at ( obj -> b , obj -> hdr -> data_start + offset , ( ut8 * ) & got_entry , sizeof ( ut32 ) ) ; if ( ! VALID_GOT_ENTRY ( got_entry ) || len != sizeof ( ut32 ) ) { break ; } got_table [ i ] . addr_to_patch = got_entry ; got_table [ i ] . data_offset = got_entry + BFLT_HDR_SIZE ; } obj -> n_got = n_got ; obj -> got_table = got_table ; } } } if ( obj -> hdr -> reloc_count > 0 ) { int n_reloc = obj -> hdr -> reloc_count ; amount = n_reloc * sizeof ( struct reloc_struct_t ) ; if ( amount < n_reloc || amount > UT32_MAX ) { goto out_error ; } struct reloc_struct_t * reloc_table = calloc ( 1 , amount + 1 ) ; if ( ! reloc_table ) { goto out_error ; } amount = n_reloc * sizeof ( ut32 ) ; if ( amount < n_reloc || amount > UT32_MAX ) { free ( reloc_table ) ; goto out_error ; } ut32 * reloc_pointer_table = calloc ( 1 , amount + 1 ) ; if ( ! reloc_pointer_table ) { free ( reloc_table ) ; goto out_error ; } if ( obj -> hdr -> reloc_start + amount > obj -> size || obj -> hdr -> reloc_start + amount < amount ) { free ( reloc_table ) ; free ( reloc_pointer_table ) ; goto out_error ; } len = r_buf_read_at ( obj -> b , obj -> hdr -> reloc_start , ( ut8 * ) reloc_pointer_table , amount ) ; if ( len != amount ) { free ( reloc_table ) ; free ( reloc_pointer_table ) ; goto out_error ; } for ( i = 0 ; i < obj -> hdr -> reloc_count ; i ++ ) { ut32 reloc_offset = r_swap_ut32 ( reloc_pointer_table [ i ] ) + BFLT_HDR_SIZE ; if ( reloc_offset < obj -> hdr -> bss_end && reloc_offset < obj -> size ) { ut32 reloc_fixed , reloc_data_offset ; if ( reloc_offset + sizeof ( ut32 ) > obj -> size || reloc_offset + sizeof ( ut32 ) < reloc_offset ) { free ( reloc_table ) ; free ( reloc_pointer_table ) ; goto out_error ; } len = r_buf_read_at ( obj -> b , reloc_offset , ( ut8 * ) & reloc_fixed , sizeof ( ut32 ) ) ; if ( len != sizeof ( ut32 ) ) { eprintf ( ""problemwhilereadingrelocationentries\\n"" ) ; free ( reloc_table ) ; free ( reloc_pointer_table ) ; goto out_error ; } reloc_data_offset = r_swap_ut32 ( reloc_fixed ) + BFLT_HDR_SIZE ; reloc_table [ i ] . addr_to_patch = reloc_offset ; reloc_table [ i ] . data_offset = reloc_data_offset ; RBinReloc * reloc = R_NEW0 ( RBinReloc ) ; if ( reloc ) { reloc -> type = R_BIN_RELOC_32 ; reloc -> paddr = reloc_table [ i ] . addr_to_patch ; reloc -> vaddr = reloc -> paddr ; r_list_append ( list , reloc ) ; } } } free ( reloc_pointer_table ) ; obj -> reloc_table = reloc_table ; } return list ; out_error : r_list_free ( list ) ; return NULL ; } "," * sizeof ( struct reloc_struct_t ) ) ; ",radare@radare2/72794dc3523bbd5bb370de3c5857cb736c387e18,CVE-2017-6194,https://github.com/radare/radare2/commit/72794dc3523bbd5bb370de3c5857cb736c387e18,2017-04-03T05:59Z 343,CWE-000,"CWE-000 long do_rt_tgsigqueueinfo ( pid_t tgid , pid_t pid , int sig , siginfo_t * info ) { if ( pid <= 0 || tgid <= 0 ) return - EINVAL ; if ( info -> si_code >= 0 ) return - EPERM ; info -> si_signo = sig ; return do_send_specific ( tgid , pid , sig , info ) ; } "," info -> si_code != SI_QUEUE ) { WARN_ON_ONCE ( info -> si_code < 0 ) ; return - EPERM - EPERM ; } ",torvalds@linux/da48524eb20662618854bb3df2db01fc65f3070c,CVE-2011-1182,https://github.com/torvalds/linux/commit/da48524eb20662618854bb3df2db01fc65f3070c,2013-03-01T12:37Z 344,CWE-190,"CWE-190 void opj_get_all_encoding_parameters ( const opj_image_t * p_image , const opj_cp_t * p_cp , OPJ_UINT32 tileno , OPJ_INT32 * p_tx0 , OPJ_INT32 * p_tx1 , OPJ_INT32 * p_ty0 , OPJ_INT32 * p_ty1 , OPJ_UINT32 * p_dx_min , OPJ_UINT32 * p_dy_min , OPJ_UINT32 * p_max_prec , OPJ_UINT32 * p_max_res , OPJ_UINT32 * * p_resolutions ) { OPJ_UINT32 compno , resno ; const opj_tcp_t * tcp = 00 ; const opj_tccp_t * l_tccp = 00 ; const opj_image_comp_t * l_img_comp = 00 ; OPJ_UINT32 * lResolutionPtr ; OPJ_UINT32 p , q ; assert ( p_cp != 00 ) ; assert ( p_image != 00 ) ; assert ( tileno < p_cp -> tw * p_cp -> th ) ; tcp = & p_cp -> tcps [ tileno ] ; l_tccp = tcp -> tccps ; l_img_comp = p_image -> comps ; p = tileno % p_cp -> tw ; q = tileno / p_cp -> tw ; * p_tx0 = opj_int_max ( ( OPJ_INT32 ) ( p_cp -> tx0 + p * p_cp -> tdx ) , ( OPJ_INT32 ) p_image -> x0 ) ; * p_tx1 = opj_int_min ( ( OPJ_INT32 ) ( p_cp -> tx0 + ( p + 1 ) * p_cp -> tdx ) , ( OPJ_INT32 ) p_image -> x1 ) ; * p_ty0 = opj_int_max ( ( OPJ_INT32 ) ( p_cp -> ty0 + q * p_cp -> tdy ) , ( OPJ_INT32 ) p_image -> y0 ) ; * p_ty1 = opj_int_min ( ( OPJ_INT32 ) ( p_cp -> ty0 + ( q + 1 ) * p_cp -> tdy ) , ( OPJ_INT32 ) p_image -> y1 ) ; * p_max_prec = 0 ; * p_max_res = 0 ; * p_dx_min = 0x7fffffff ; * p_dy_min = 0x7fffffff ; for ( compno = 0 ; compno < p_image -> numcomps ; ++ compno ) { OPJ_UINT32 l_level_no ; OPJ_INT32 l_rx0 , l_ry0 , l_rx1 , l_ry1 ; OPJ_INT32 l_px0 , l_py0 , l_px1 , py1 ; OPJ_UINT32 l_product ; OPJ_INT32 l_tcx0 , l_tcy0 , l_tcx1 , l_tcy1 ; OPJ_UINT32 l_pdx , l_pdy , l_pw , l_ph ; lResolutionPtr = p_resolutions [ compno ] ; l_tcx0 = opj_int_ceildiv ( * p_tx0 , ( OPJ_INT32 ) l_img_comp -> dx ) ; l_tcy0 = opj_int_ceildiv ( * p_ty0 , ( OPJ_INT32 ) l_img_comp -> dy ) ; l_tcx1 = opj_int_ceildiv ( * p_tx1 , ( OPJ_INT32 ) l_img_comp -> dx ) ; l_tcy1 = opj_int_ceildiv ( * p_ty1 , ( OPJ_INT32 ) l_img_comp -> dy ) ; if ( l_tccp -> numresolutions > * p_max_res ) { * p_max_res = l_tccp -> numresolutions ; } l_level_no = l_tccp -> numresolutions - 1 ; for ( resno = 0 ; resno < l_tccp -> numresolutions ; ++ resno ) { OPJ_UINT32 l_dx , l_dy ; l_pdx = l_tccp -> prcw [ resno ] ; l_pdy = l_tccp -> prch [ resno ] ; * lResolutionPtr ++ = l_pdx ; * lResolutionPtr ++ = l_pdy ; l_dx = l_img_comp -> dx * ( 1u << ( l_pdx + l_level_no ) ) ; l_dy = l_img_comp -> dy * ( 1u << ( l_pdy + l_level_no ) ) ; * p_dx_min = ( OPJ_UINT32 ) opj_int_min ( ( OPJ_INT32 ) * p_dx_min , ( OPJ_INT32 ) l_dx ) ; * p_dy_min = ( OPJ_UINT32 ) opj_int_min ( ( OPJ_INT32 ) * p_dy_min , ( OPJ_INT32 ) l_dy ) ; l_rx0 = opj_int_ceildivpow2 ( l_tcx0 , ( OPJ_INT32 ) l_level_no ) ; l_ry0 = opj_int_ceildivpow2 ( l_tcy0 , ( OPJ_INT32 ) l_level_no ) ; l_rx1 = opj_int_ceildivpow2 ( l_tcx1 , ( OPJ_INT32 ) l_level_no ) ; l_ry1 = opj_int_ceildivpow2 ( l_tcy1 , ( OPJ_INT32 ) l_level_no ) ; l_px0 = opj_int_floordivpow2 ( l_rx0 , ( OPJ_INT32 ) l_pdx ) << l_pdx ; l_py0 = opj_int_floordivpow2 ( l_ry0 , ( OPJ_INT32 ) l_pdy ) << l_pdy ; l_px1 = opj_int_ceildivpow2 ( l_rx1 , ( OPJ_INT32 ) l_pdx ) << l_pdx ; py1 = opj_int_ceildivpow2 ( l_ry1 , ( OPJ_INT32 ) l_pdy ) << l_pdy ; l_pw = ( l_rx0 == l_rx1 ) ? 0 : ( OPJ_UINT32 ) ( ( l_px1 - l_px0 ) >> l_pdx ) ; l_ph = ( l_ry0 == l_ry1 ) ? 0 : ( OPJ_UINT32 ) ( ( py1 - l_py0 ) >> l_pdy ) ; * lResolutionPtr ++ = l_pw ; * lResolutionPtr ++ = l_ph ; l_product = l_pw * l_ph ; if ( l_product > * p_max_prec ) { * p_max_prec = l_product ; } -- l_level_no ; } ++ l_tccp ; ++ l_img_comp ; } } "," * p_tx0 = ( OPJ_INT32 ) opj_uint_max ( p_cp -> p_cp -> tdx , p_image -> x0 * p_tx1 = ( OPJ_INT32 ) opj_uint_min ( p_cp -> p_cp -> tdx , p_image -> x1 * p_ty0 = ( OPJ_INT32 ) opj_uint_max ( p_cp -> p_cp -> tdy , p_image -> y0 * p_ty1 = ( OPJ_INT32 ) opj_uint_min ( p_cp -> p_cp -> tdy , p_image -> y1 ",uclouvain@openjpeg/5d00b719f4b93b1445e6fb4c766b9a9883c57949,CVE-2018-20847,https://github.com/uclouvain/openjpeg/commit/5d00b719f4b93b1445e6fb4c766b9a9883c57949,2019-06-26T18:15Z 345,CWE-22,"CWE-22 static char * create_output_name ( unsigned char * fname , unsigned char * dir , int lower , int isunix , int utf8 ) { unsigned char * p , * name , c , * fe , sep , slash ; unsigned int x ; sep = ( isunix ) ? '/' : '\\\\' ; slash = ( isunix ) ? '\\\\' : '/' ; x = strlen ( ( char * ) fname ) ; if ( utf8 ) x *= 3 ; if ( dir ) x += strlen ( ( char * ) dir ) ; if ( ! ( name = ( unsigned char * ) malloc ( x + 2 ) ) ) { fprintf ( stderr , ""outofmemory!\\n"" ) ; return NULL ; } * name = '\\0' ; if ( dir ) { strcpy ( ( char * ) name , ( char * ) dir ) ; strcat ( ( char * ) name , ""/"" ) ; } while ( * fname == sep ) fname ++ ; p = & name [ strlen ( ( char * ) name ) ] ; fe = & fname [ strlen ( ( char * ) fname ) ] ; if ( utf8 ) { do { if ( fname >= fe ) { free ( name ) ; return NULL ; } if ( ( c = * fname ++ ) < 0x80 ) x = c ; else { if ( ( c >= 0xC0 ) && ( c < 0xE0 ) ) { x = ( c & 0x1F ) << 6 ; x |= * fname ++ & 0x3F ; } else if ( ( c >= 0xE0 ) && ( c < 0xF0 ) ) { x = ( c & 0xF ) << 12 ; x |= ( * fname ++ & 0x3F ) << 6 ; x |= * fname ++ & 0x3F ; } else x = '?' ; } if ( x == sep ) x = '/' ; else if ( x == slash ) x = '\\\\' ; else if ( lower ) x = ( unsigned int ) tolower ( ( int ) x ) ; if ( x < 0x80 ) { * p ++ = ( unsigned char ) x ; } else if ( x < 0x800 ) { * p ++ = 0xC0 | ( x >> 6 ) ; * p ++ = 0x80 | ( x & 0x3F ) ; } else { * p ++ = 0xE0 | ( x >> 12 ) ; * p ++ = 0x80 | ( ( x >> 6 ) & 0x3F ) ; * p ++ = 0x80 | ( x & 0x3F ) ; } } while ( x ) ; } else { do { c = * fname ++ ; if ( c == sep ) c = '/' ; else if ( c == slash ) c = '\\\\' ; else if ( lower ) c = ( unsigned char ) tolower ( ( int ) c ) ; } while ( ( * p ++ = c ) ) ; } return ( char * ) name ; } "," char * create_output_name * create_output_name ( char * fname char * fname ) { char * out , * p ; if ( ; if ( ( out = malloc ( strlen ( fname ) + 1 ) ) ) ) ) { while ( * * fname == '/' || * fname == '\\\\' ) fname ++ fname ++ ; strcpy ( out , ( * fname ) ? fname : ""x"" ) ; for ( p = out ; * p ; p ++ ) { if ( { if ( p [ 0 ] == '.' && p [ 1 ] == '.' && ( p [ 2 ] == '/' || p [ 2 ] == '\\\\' ) ) { ) ) { p [ 0 ] = p [ 1 ] = 'x' ; } } ; } } } return out ; } ",kyz@libmspack/7cadd489698be117c47efcadd742651594429e6d,CVE-2018-18586,https://github.com/kyz/libmspack/commit/7cadd489698be117c47efcadd742651594429e6d,2018-10-23T02:29Z 346,CWE-416,"CWE-416 PHP_FUNCTION ( unserialize ) { char * buf = NULL ; size_t buf_len ; const unsigned char * p ; php_unserialize_data_t var_hash ; zval * options = NULL , * classes = NULL ; HashTable * class_hash = NULL ; if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , ""s|a"" , & buf , & buf_len , & options ) == FAILURE ) { RETURN_FALSE ; } if ( buf_len == 0 ) { RETURN_FALSE ; } p = ( const unsigned char * ) buf ; PHP_VAR_UNSERIALIZE_INIT ( var_hash ) ; if ( options != NULL ) { classes = zend_hash_str_find ( Z_ARRVAL_P ( options ) , ""allowed_classes"" , sizeof ( ""allowed_classes"" ) - 1 ) ; if ( classes && ( Z_TYPE_P ( classes ) == IS_ARRAY || ! zend_is_true ( classes ) ) ) { ALLOC_HASHTABLE ( class_hash ) ; zend_hash_init ( class_hash , ( Z_TYPE_P ( classes ) == IS_ARRAY ) ? zend_hash_num_elements ( Z_ARRVAL_P ( classes ) ) : 0 , NULL , NULL , 0 ) ; } if ( class_hash && Z_TYPE_P ( classes ) == IS_ARRAY ) { zval * entry ; zend_string * lcname ; ZEND_HASH_FOREACH_VAL ( Z_ARRVAL_P ( classes ) , entry ) { convert_to_string_ex ( entry ) ; lcname = zend_string_tolower ( Z_STR_P ( entry ) ) ; zend_hash_add_empty_element ( class_hash , lcname ) ; zend_string_release ( lcname ) ; } ZEND_HASH_FOREACH_END ( ) ; } } if ( ! php_var_unserialize_ex ( return_value , & p , p + buf_len , & var_hash , class_hash ) ) { PHP_VAR_UNSERIALIZE_DESTROY ( var_hash ) ; if ( class_hash ) { zend_hash_destroy ( class_hash ) ; FREE_HASHTABLE ( class_hash ) ; } zval_ptr_dtor ( return_value ) ; if ( ! EG ( exception ) ) { php_error_docref ( NULL , E_NOTICE , ""Erroratoffset"" ZEND_LONG_FMT ""of%zdbytes"" , ( zend_long ) ( ( char * ) p - buf ) , buf_len ) ; } RETURN_FALSE ; } var_push_dtor ( & var_hash , return_value ) ; PHP_VAR_UNSERIALIZE_DESTROY ( var_hash ) ; if ( class_hash ) { zend_hash_destroy ( class_hash ) ; FREE_HASHTABLE ( class_hash ) ; } } "," classes = NULL ; zval * retval ; } } retval = var_tmp_var ( & var_hash ) ; ! php_var_unserialize_ex ( retval , & p ) ; } if ( ! RETURN_FALSE ; } ZVAL_COPY ( return_value , retval ) ; PHP_VAR_UNSERIALIZE_DESTROY ",php@php-src/b2af4e8868726a040234de113436c6e4f6372d17,CVE-2016-9936,https://github.com/php/php-src/commit/b2af4e8868726a040234de113436c6e4f6372d17,2017-01-04T20:59Z 347,CWE-200,"CWE-200 static int snd_timer_user_tselect ( struct file * file , struct snd_timer_select __user * _tselect ) { struct snd_timer_user * tu ; struct snd_timer_select tselect ; char str [ 32 ] ; int err = 0 ; tu = file -> private_data ; if ( tu -> timeri ) { snd_timer_close ( tu -> timeri ) ; tu -> timeri = NULL ; } if ( copy_from_user ( & tselect , _tselect , sizeof ( tselect ) ) ) { err = - EFAULT ; goto __err ; } sprintf ( str , ""application%i"" , current -> pid ) ; if ( tselect . id . dev_class != SNDRV_TIMER_CLASS_SLAVE ) tselect . id . dev_sclass = SNDRV_TIMER_SCLASS_APPLICATION ; err = snd_timer_open ( & tu -> timeri , str , & tselect . id , current -> pid ) ; if ( err < 0 ) goto __err ; kfree ( tu -> queue ) ; tu -> queue = NULL ; kfree ( tu -> tqueue ) ; tu -> tqueue = NULL ; if ( tu -> tread ) { tu -> tqueue = kmalloc ( tu -> queue_size * sizeof ( struct snd_timer_tread ) , GFP_KERNEL ) ; if ( tu -> tqueue == NULL ) err = - ENOMEM ; } else { tu -> queue = kmalloc ( tu -> queue_size * sizeof ( struct snd_timer_read ) , GFP_KERNEL ) ; if ( tu -> queue == NULL ) err = - ENOMEM ; } if ( err < 0 ) { snd_timer_close ( tu -> timeri ) ; tu -> timeri = NULL ; } else { tu -> timeri -> flags |= SNDRV_TIMER_IFLG_FAST ; tu -> timeri -> callback = tu -> tread ? snd_timer_user_tinterrupt : snd_timer_user_interrupt ; tu -> timeri -> ccallback = snd_timer_user_ccallback ; tu -> timeri -> callback_data = ( void * ) tu ; tu -> timeri -> disconnect = snd_timer_user_disconnect ; } __err : return err ; } "," goto __err ; tu -> qhead = tu -> qtail = tu -> qused = 0 ; ",torvalds@linux/ba3021b2c79b2fa9114f92790a99deb27a65b728,CVE-2017-1000380,https://github.com/torvalds/linux/commit/ba3021b2c79b2fa9114f92790a99deb27a65b728,2017-06-17T18:29Z 348,CWE-125,"CWE-125 GF_Err abst_box_read ( GF_Box * s , GF_BitStream * bs ) { GF_AdobeBootstrapInfoBox * ptr = ( GF_AdobeBootstrapInfoBox * ) s ; int i ; u32 tmp_strsize ; char * tmp_str ; GF_Err e ; ISOM_DECREASE_SIZE ( ptr , 25 ) ptr -> bootstrapinfo_version = gf_bs_read_u32 ( bs ) ; ptr -> profile = gf_bs_read_int ( bs , 2 ) ; ptr -> live = gf_bs_read_int ( bs , 1 ) ; ptr -> update = gf_bs_read_int ( bs , 1 ) ; ptr -> reserved = gf_bs_read_int ( bs , 4 ) ; ptr -> time_scale = gf_bs_read_u32 ( bs ) ; ptr -> current_media_time = gf_bs_read_u64 ( bs ) ; ptr -> smpte_time_code_offset = gf_bs_read_u64 ( bs ) ; i = 0 ; if ( ptr -> size < 8 ) return GF_ISOM_INVALID_FILE ; tmp_strsize = ( u32 ) ptr -> size - 8 ; tmp_str = gf_malloc ( sizeof ( char ) * tmp_strsize ) ; if ( ! tmp_str ) return GF_OUT_OF_MEM ; memset ( tmp_str , 0 , sizeof ( char ) * tmp_strsize ) ; while ( tmp_strsize ) { ISOM_DECREASE_SIZE ( ptr , 1 ) tmp_str [ i ] = gf_bs_read_u8 ( bs ) ; tmp_strsize -- ; if ( ! tmp_str [ i ] ) break ; i ++ ; } if ( i ) { ptr -> movie_identifier = gf_strdup ( tmp_str ) ; } ISOM_DECREASE_SIZE ( ptr , 1 ) ptr -> server_entry_count = gf_bs_read_u8 ( bs ) ; for ( i = 0 ; i < ptr -> server_entry_count ; i ++ ) { int j = 0 ; tmp_strsize = ( u32 ) ptr -> size ; while ( tmp_strsize ) { ISOM_DECREASE_SIZE ( ptr , 1 ) tmp_str [ j ] = gf_bs_read_u8 ( bs ) ; tmp_strsize -- ; if ( ! tmp_str [ j ] ) break ; j ++ ; } if ( j ) { gf_list_insert ( ptr -> server_entry_table , gf_strdup ( tmp_str ) , i ) ; } } ISOM_DECREASE_SIZE ( ptr , 1 ) ptr -> quality_entry_count = gf_bs_read_u8 ( bs ) ; for ( i = 0 ; i < ptr -> quality_entry_count ; i ++ ) { int j = 0 ; tmp_strsize = ( u32 ) ptr -> size ; while ( tmp_strsize ) { ISOM_DECREASE_SIZE ( ptr , 1 ) tmp_str [ j ] = gf_bs_read_u8 ( bs ) ; tmp_strsize -- ; if ( ! tmp_str [ j ] ) break ; j ++ ; } if ( j ) { gf_list_insert ( ptr -> quality_entry_table , gf_strdup ( tmp_str ) , i ) ; } } i = 0 ; tmp_strsize = ( u32 ) ptr -> size ; while ( tmp_strsize ) { ISOM_DECREASE_SIZE ( ptr , 1 ) tmp_str [ i ] = gf_bs_read_u8 ( bs ) ; tmp_strsize -- ; if ( ! tmp_str [ i ] ) break ; i ++ ; } if ( i ) { ptr -> drm_data = gf_strdup ( tmp_str ) ; } i = 0 ; tmp_strsize = ( u32 ) ptr -> size ; while ( tmp_strsize ) { ISOM_DECREASE_SIZE ( ptr , 1 ) tmp_str [ i ] = gf_bs_read_u8 ( bs ) ; tmp_strsize -- ; if ( ! tmp_str [ i ] ) break ; i ++ ; } if ( i ) { ptr -> meta_data = gf_strdup ( tmp_str ) ; } ISOM_DECREASE_SIZE ( ptr , 1 ) ptr -> segment_run_table_count = gf_bs_read_u8 ( bs ) ; for ( i = 0 ; i < ptr -> segment_run_table_count ; i ++ ) { GF_AdobeSegmentRunTableBox * asrt = NULL ; e = gf_isom_box_parse ( ( GF_Box * * ) & asrt , bs ) ; if ( e ) { if ( asrt ) gf_isom_box_del ( ( GF_Box * ) asrt ) ; gf_free ( tmp_str ) ; return e ; } gf_list_add ( ptr -> segment_run_table_entries , asrt ) ; } ISOM_DECREASE_SIZE ( ptr , 1 ) ptr -> fragment_run_table_count = gf_bs_read_u8 ( bs ) ; for ( i = 0 ; i < ptr -> fragment_run_table_count ; i ++ ) { GF_AdobeFragmentRunTableBox * afrt = NULL ; e = gf_isom_box_parse ( ( GF_Box * * ) & afrt , bs ) ; if ( e ) { if ( afrt ) gf_isom_box_del ( ( GF_Box * ) afrt ) ; gf_free ( tmp_str ) ; return e ; } gf_list_add ( ptr -> fragment_run_table_entries , afrt ) ; } gf_free ( tmp_str ) ; return GF_OK ; } "," ptr -> size ; tmp_str = ",gpac@gpac/8e05648d6b4459facbc783025c5c42d301fef5c3,CVE-2020-23928,https://github.com/gpac/gpac/commit/8e05648d6b4459facbc783025c5c42d301fef5c3,2021-04-21T18:15Z 349,CWE-119,"CWE-119 vpx_fixed_buf_t * vpx_codec_get_global_headers ( vpx_codec_ctx_t * ctx ) { vpx_fixed_buf_t * buf = NULL ; if ( ctx ) { if ( ! ctx -> iface || ! ctx -> priv ) ctx -> err = VPX_CODEC_ERROR ; else if ( ! ( ctx -> iface -> caps & VPX_CODEC_CAP_ENCODER ) ) ctx -> err = VPX_CODEC_INCAPABLE ; else if ( ! ctx -> iface -> enc . get_glob_hdrs ) ctx -> err = VPX_CODEC_INCAPABLE ; else buf = ctx -> iface -> enc . get_glob_hdrs ( ctx -> priv -> alg_priv ) ; } return buf ; } "," . get_glob_hdrs ( get_alg_priv ( ctx ) ) ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 350,CWE-404,"CWE-404 int main ( int argc , char * * cargv ) { uschar * * argv = USS cargv ; int arg_receive_timeout = - 1 ; int arg_smtp_receive_timeout = - 1 ; int arg_error_handling = error_handling ; int filter_sfd = - 1 ; int filter_ufd = - 1 ; int group_count ; int i , rv ; int list_queue_option = 0 ; int msg_action = 0 ; int msg_action_arg = - 1 ; int namelen = ( argv [ 0 ] == NULL ) ? 0 : Ustrlen ( argv [ 0 ] ) ; int queue_only_reason = 0 ; # ifdef EXIM_PERL int perl_start_option = 0 ; # endif int recipients_arg = argc ; int sender_address_domain = 0 ; int test_retry_arg = - 1 ; int test_rewrite_arg = - 1 ; BOOL arg_queue_only = FALSE ; BOOL bi_option = FALSE ; BOOL checking = FALSE ; BOOL count_queue = FALSE ; BOOL expansion_test = FALSE ; BOOL extract_recipients = FALSE ; BOOL flag_G = FALSE ; BOOL flag_n = FALSE ; BOOL forced_delivery = FALSE ; BOOL f_end_dot = FALSE ; BOOL deliver_give_up = FALSE ; BOOL list_queue = FALSE ; BOOL list_options = FALSE ; BOOL list_config = FALSE ; BOOL local_queue_only ; BOOL more = TRUE ; BOOL one_msg_action = FALSE ; BOOL opt_D_used = FALSE ; BOOL queue_only_set = FALSE ; BOOL receiving_message = TRUE ; BOOL sender_ident_set = FALSE ; BOOL session_local_queue_only ; BOOL unprivileged ; BOOL removed_privilege = FALSE ; BOOL usage_wanted = FALSE ; BOOL verify_address_mode = FALSE ; BOOL verify_as_sender = FALSE ; BOOL version_printed = FALSE ; uschar * alias_arg = NULL ; uschar * called_as = US """" ; uschar * cmdline_syslog_name = NULL ; uschar * start_queue_run_id = NULL ; uschar * stop_queue_run_id = NULL ; uschar * expansion_test_message = NULL ; uschar * ftest_domain = NULL ; uschar * ftest_localpart = NULL ; uschar * ftest_prefix = NULL ; uschar * ftest_suffix = NULL ; uschar * log_oneline = NULL ; uschar * malware_test_file = NULL ; uschar * real_sender_address ; uschar * originator_home = US ""/"" ; size_t sz ; void * reset_point ; struct passwd * pw ; struct stat statbuf ; pid_t passed_qr_pid = ( pid_t ) 0 ; int passed_qr_pipe = - 1 ; gid_t group_list [ NGROUPS_MAX ] ; enum commandline_info info_flag = CMDINFO_NONE ; BOOL info_stdout = FALSE ; static uschar * rsopts [ ] = { US ""f"" , US ""ff"" , US ""r"" , US ""rf"" , US ""rff"" } ; extern char * * environ ; # ifdef EXIM_USERNAME if ( route_finduser ( US EXIM_USERNAME , & pw , & exim_uid ) ) { if ( exim_uid == 0 ) { fprintf ( stderr , ""exim:refusingtorunwithuid0for\\""%s\\""\\n"" , EXIM_USERNAME ) ; exit ( EXIT_FAILURE ) ; } if ( pw ) exim_gid = pw -> pw_gid ; # ifndef EXIM_GROUPNAME else { fprintf ( stderr , ""exim:ref:nameshouldspecifyausercode,notagroup.\\n"" ""exim:can\'tletyougetawaywithitunlessyoualsospecifyagroup.\\n"" ) ; exit ( EXIT_FAILURE ) ; } # endif } else { fprintf ( stderr , ""exim:failedtofinduidforusername\\""%s\\""\\n"" , EXIM_USERNAME ) ; exit ( EXIT_FAILURE ) ; } # endif # ifdef EXIM_GROUPNAME if ( ! route_findgroup ( US EXIM_GROUPNAME , & exim_gid ) ) { fprintf ( stderr , ""exim:failedtofindgidforgroupname\\""%s\\""\\n"" , EXIM_GROUPNAME ) ; exit ( EXIT_FAILURE ) ; } # endif # ifdef CONFIGURE_OWNERNAME if ( ! route_finduser ( US CONFIGURE_OWNERNAME , NULL , & config_uid ) ) { fprintf ( stderr , ""exim:failedtofinduidforusername\\""%s\\""\\n"" , CONFIGURE_OWNERNAME ) ; exit ( EXIT_FAILURE ) ; } # endif system_filter_uid = exim_uid ; # ifdef CONFIGURE_GROUPNAME if ( ! route_findgroup ( US CONFIGURE_GROUPNAME , & config_gid ) ) { fprintf ( stderr , ""exim:failedtofindgidforgroupname\\""%s\\""\\n"" , CONFIGURE_GROUPNAME ) ; exit ( EXIT_FAILURE ) ; } # endif # ifdef OS_INIT OS_INIT # endif running_in_test_harness = * running_status == '<' && Ustrcmp ( running_status , ""<<>>"" ) == 0 ; setlocale ( LC_ALL , ""C"" ) ; os_non_restarting_signal ( SIGALRM , sigalrm_handler ) ; if ( ! ( log_buffer = US malloc ( LOG_BUFFER_SIZE ) ) ) { fprintf ( stderr , ""exim:failedtogetstoreforlogbuffer\\n"" ) ; exit ( EXIT_FAILURE ) ; } bits_set ( log_selector , log_selector_size , log_default ) ; if ( fstat ( fileno ( stderr ) , & statbuf ) >= 0 ) log_stderr = stderr ; pcre_malloc = function_store_get ; pcre_free = function_dummy_free ; big_buffer = store_malloc ( big_buffer_size ) ; set_process_info ( ""initializing"" ) ; os_restarting_signal ( SIGUSR1 , usr1_handler ) ; signal ( SIGHUP , SIG_IGN ) ; signal ( SIGPIPE , SIG_IGN ) ; # ifdef SA_NOCLDWAIT { struct sigaction act ; act . sa_handler = SIG_DFL ; sigemptyset ( & ( act . sa_mask ) ) ; act . sa_flags = 0 ; sigaction ( SIGCHLD , & act , NULL ) ; } # else signal ( SIGCHLD , SIG_DFL ) ; # endif sighup_argv = argv ; version_init ( ) ; message_id_option [ 0 ] = '-' ; message_id_external = message_id_option + 1 ; message_id_external [ 0 ] = 'E' ; message_id = message_id_external + 1 ; message_id [ 0 ] = 0 ; ( void ) umask ( 0 ) ; regex_ismsgid = regex_must_compile ( US ""^(?:[^\\\\W_]{6}-){2}[^\\\\W_]{2}$"" , FALSE , TRUE ) ; regex_smtp_code = regex_must_compile ( US ""^\\\\d\\\\d\\\\d\\\\s(?:\\\\d\\\\.\\\\d\\\\d?\\\\d?\\\\.\\\\d\\\\d?\\\\d?\\\\s)?"" , FALSE , TRUE ) ; # ifdef WHITELIST_D_MACROS regex_whitelisted_macro = regex_must_compile ( US ""^[A-Za-z0-9_/.-]*$"" , FALSE , TRUE ) ; # endif for ( i = 0 ; i < REGEX_VARS ; i ++ ) regex_vars [ i ] = NULL ; if ( ( namelen == 5 && Ustrcmp ( argv [ 0 ] , ""mailq"" ) == 0 ) || ( namelen > 5 && Ustrncmp ( argv [ 0 ] + namelen - 6 , ""/mailq"" , 6 ) == 0 ) ) { list_queue = TRUE ; receiving_message = FALSE ; called_as = US ""-mailq"" ; } if ( ( namelen == 5 && Ustrcmp ( argv [ 0 ] , ""rmail"" ) == 0 ) || ( namelen > 5 && Ustrncmp ( argv [ 0 ] + namelen - 6 , ""/rmail"" , 6 ) == 0 ) ) { dot_ends = FALSE ; called_as = US ""-rmail"" ; errors_sender_rc = EXIT_SUCCESS ; } if ( ( namelen == 5 && Ustrcmp ( argv [ 0 ] , ""rsmtp"" ) == 0 ) || ( namelen > 5 && Ustrncmp ( argv [ 0 ] + namelen - 6 , ""/rsmtp"" , 6 ) == 0 ) ) { smtp_input = smtp_batched_input = TRUE ; called_as = US ""-rsmtp"" ; } if ( ( namelen == 4 && Ustrcmp ( argv [ 0 ] , ""runq"" ) == 0 ) || ( namelen > 4 && Ustrncmp ( argv [ 0 ] + namelen - 5 , ""/runq"" , 5 ) == 0 ) ) { queue_interval = 0 ; receiving_message = FALSE ; called_as = US ""-runq"" ; } if ( ( namelen == 10 && Ustrcmp ( argv [ 0 ] , ""newaliases"" ) == 0 ) || ( namelen > 10 && Ustrncmp ( argv [ 0 ] + namelen - 11 , ""/newaliases"" , 11 ) == 0 ) ) { bi_option = TRUE ; receiving_message = FALSE ; called_as = US ""-newaliases"" ; } original_euid = geteuid ( ) ; real_uid = getuid ( ) ; real_gid = getgid ( ) ; if ( real_uid == root_uid ) { rv = setgid ( real_gid ) ; if ( rv ) { fprintf ( stderr , ""exim:setgid(%ld)failed:%s\\n"" , ( long int ) real_gid , strerror ( errno ) ) ; exit ( EXIT_FAILURE ) ; } rv = setuid ( real_uid ) ; if ( rv ) { fprintf ( stderr , ""exim:setuid(%ld)failed:%s\\n"" , ( long int ) real_uid , strerror ( errno ) ) ; exit ( EXIT_FAILURE ) ; } } unprivileged = ( real_uid != root_uid && original_euid != root_uid ) ; for ( i = 1 ; i < argc ; i ++ ) { BOOL badarg = FALSE ; uschar * arg = argv [ i ] ; uschar * argrest ; int switchchar ; if ( arg [ 0 ] != '-' ) { recipients_arg = i ; break ; } if ( Ustrcmp ( arg , ""--"" ) == 0 ) { recipients_arg = i + 1 ; break ; } switchchar = arg [ 1 ] ; argrest = arg + 2 ; if ( Ustrncmp ( arg + 1 , ""oe"" , 2 ) == 0 || Ustrncmp ( arg + 1 , ""qR"" , 2 ) == 0 || Ustrncmp ( arg + 1 , ""qS"" , 2 ) == 0 ) { switchchar = arg [ 2 ] ; argrest ++ ; } else if ( Ustrncmp ( arg + 1 , ""qqR"" , 3 ) == 0 || Ustrncmp ( arg + 1 , ""qqS"" , 3 ) == 0 ) { switchchar = arg [ 3 ] ; argrest += 2 ; queue_2stage = TRUE ; } else if ( arg [ 1 ] == 'r' ) switchchar = 'f' ; else if ( Ustrcmp ( arg , ""-ov"" ) == 0 ) { switchchar = 'v' ; argrest ++ ; } else if ( switchchar == '-' ) { if ( Ustrcmp ( argrest , ""help"" ) == 0 ) { usage_wanted = TRUE ; break ; } else if ( Ustrcmp ( argrest , ""version"" ) == 0 ) { switchchar = 'b' ; argrest = US ""V"" ; } } switch ( switchchar ) { case 'A' : if ( * argrest == '\\0' ) { badarg = TRUE ; break ; } else { BOOL ignore = FALSE ; switch ( * argrest ) { case 'c' : case 'm' : if ( * ( argrest + 1 ) == '\\0' ) ignore = TRUE ; break ; } if ( ! ignore ) { badarg = TRUE ; break ; } } break ; case 'B' : if ( * argrest == 0 ) i ++ ; break ; case 'b' : receiving_message = FALSE ; if ( * argrest == 'd' ) { daemon_listen = TRUE ; if ( * ( ++ argrest ) == 'f' ) background_daemon = FALSE ; else if ( * argrest != 0 ) { badarg = TRUE ; break ; } } else if ( * argrest == 'e' ) { expansion_test = checking = TRUE ; if ( argrest [ 1 ] == 'm' ) { if ( ++ i >= argc ) { badarg = TRUE ; break ; } expansion_test_message = argv [ i ] ; argrest ++ ; } if ( argrest [ 1 ] != 0 ) { badarg = TRUE ; break ; } } else if ( * argrest == 'F' ) { filter_test |= checking = FTEST_SYSTEM ; if ( * ( ++ argrest ) != 0 ) { badarg = TRUE ; break ; } if ( ++ i < argc ) filter_test_sfile = argv [ i ] ; else { fprintf ( stderr , ""exim:filenameexpectedafter%s\\n"" , argv [ i - 1 ] ) ; exit ( EXIT_FAILURE ) ; } } else if ( * argrest == 'f' ) { if ( * ( ++ argrest ) == 0 ) { filter_test |= checking = FTEST_USER ; if ( ++ i < argc ) filter_test_ufile = argv [ i ] ; else { fprintf ( stderr , ""exim:filenameexpectedafter%s\\n"" , argv [ i - 1 ] ) ; exit ( EXIT_FAILURE ) ; } } else { if ( ++ i >= argc ) { fprintf ( stderr , ""exim:stringexpectedafter%s\\n"" , arg ) ; exit ( EXIT_FAILURE ) ; } if ( Ustrcmp ( argrest , ""d"" ) == 0 ) ftest_domain = argv [ i ] ; else if ( Ustrcmp ( argrest , ""l"" ) == 0 ) ftest_localpart = argv [ i ] ; else if ( Ustrcmp ( argrest , ""p"" ) == 0 ) ftest_prefix = argv [ i ] ; else if ( Ustrcmp ( argrest , ""s"" ) == 0 ) ftest_suffix = argv [ i ] ; else { badarg = TRUE ; break ; } } } else if ( Ustrcmp ( argrest , ""h"" ) == 0 || Ustrcmp ( argrest , ""hc"" ) == 0 ) { if ( ++ i >= argc ) { badarg = TRUE ; break ; } sender_host_address = argv [ i ] ; host_checking = checking = log_testing_mode = TRUE ; host_checking_callout = argrest [ 1 ] == 'c' ; message_logs = FALSE ; } else if ( Ustrcmp ( argrest , ""i"" ) == 0 ) bi_option = TRUE ; else if ( argrest [ 0 ] == 'I' && Ustrlen ( argrest ) >= 2 && argrest [ 1 ] == ':' ) { uschar * p = & argrest [ 2 ] ; info_flag = CMDINFO_HELP ; if ( Ustrlen ( p ) ) { if ( strcmpic ( p , CUS ""sieve"" ) == 0 ) { info_flag = CMDINFO_SIEVE ; info_stdout = TRUE ; } else if ( strcmpic ( p , CUS ""dscp"" ) == 0 ) { info_flag = CMDINFO_DSCP ; info_stdout = TRUE ; } else if ( strcmpic ( p , CUS ""help"" ) == 0 ) { info_stdout = TRUE ; } } } else if ( Ustrcmp ( argrest , ""m"" ) == 0 ) receiving_message = TRUE ; else if ( Ustrcmp ( argrest , ""malware"" ) == 0 ) { if ( ++ i >= argc ) { badarg = TRUE ; break ; } checking = TRUE ; malware_test_file = argv [ i ] ; } else if ( Ustrcmp ( argrest , ""nq"" ) == 0 ) { allow_unqualified_sender = FALSE ; allow_unqualified_recipient = FALSE ; } else if ( * argrest == 'p' ) { if ( * ( ++ argrest ) == 'c' ) { count_queue = TRUE ; if ( * ( ++ argrest ) != 0 ) badarg = TRUE ; break ; } if ( * argrest == 'r' ) { list_queue_option = 8 ; argrest ++ ; } else list_queue_option = 0 ; list_queue = TRUE ; if ( * argrest == 0 ) { } else if ( Ustrcmp ( argrest , ""u"" ) == 0 ) list_queue_option += 1 ; else if ( Ustrcmp ( argrest , ""a"" ) == 0 ) list_queue_option += 2 ; else { badarg = TRUE ; break ; } } else if ( Ustrcmp ( argrest , ""P"" ) == 0 ) { if ( argv [ i + 1 ] && Ustrcmp ( argv [ i + 1 ] , ""config"" ) == 0 ) { list_config = TRUE ; readconf_save_config ( version_string ) ; } else { list_options = TRUE ; debug_selector |= D_v ; debug_file = stderr ; } } else if ( Ustrcmp ( argrest , ""rt"" ) == 0 ) { checking = TRUE ; test_retry_arg = i + 1 ; goto END_ARG ; } else if ( Ustrcmp ( argrest , ""rw"" ) == 0 ) { checking = TRUE ; test_rewrite_arg = i + 1 ; goto END_ARG ; } else if ( Ustrcmp ( argrest , ""S"" ) == 0 ) smtp_input = smtp_batched_input = receiving_message = TRUE ; else if ( Ustrcmp ( argrest , ""s"" ) == 0 ) smtp_input = receiving_message = TRUE ; else if ( Ustrcmp ( argrest , ""t"" ) == 0 ) address_test_mode = checking = log_testing_mode = TRUE ; else if ( Ustrcmp ( argrest , ""v"" ) == 0 ) verify_address_mode = checking = log_testing_mode = TRUE ; else if ( Ustrcmp ( argrest , ""vs"" ) == 0 ) { verify_address_mode = checking = log_testing_mode = TRUE ; verify_as_sender = TRUE ; } else if ( Ustrcmp ( argrest , ""V"" ) == 0 ) { printf ( ""Eximversion%s#%sbuilt%s\\n"" , version_string , version_cnumber , version_date ) ; printf ( ""%s\\n"" , CS version_copyright ) ; version_printed = TRUE ; show_whats_supported ( stdout ) ; log_testing_mode = TRUE ; } else if ( * argrest == 'w' ) { inetd_wait_mode = TRUE ; background_daemon = FALSE ; daemon_listen = TRUE ; if ( * ( ++ argrest ) != '\\0' ) { inetd_wait_timeout = readconf_readtime ( argrest , 0 , FALSE ) ; if ( inetd_wait_timeout <= 0 ) { fprintf ( stderr , ""exim:badtimevalue%s:abandoned\\n"" , argv [ i ] ) ; exit ( EXIT_FAILURE ) ; } } } else badarg = TRUE ; break ; case 'C' : if ( * argrest == 0 ) { if ( ++ i < argc ) argrest = argv [ i ] ; else { badarg = TRUE ; break ; } } if ( Ustrcmp ( config_main_filelist , argrest ) != 0 ) { # ifdef ALT_CONFIG_PREFIX int sep = 0 ; int len = Ustrlen ( ALT_CONFIG_PREFIX ) ; const uschar * list = argrest ; uschar * filename ; while ( ( filename = string_nextinlist ( & list , & sep , big_buffer , big_buffer_size ) ) != NULL ) { if ( ( Ustrlen ( filename ) < len || Ustrncmp ( filename , ALT_CONFIG_PREFIX , len ) != 0 || Ustrstr ( filename , ""/../"" ) != NULL ) && ( Ustrcmp ( filename , ""/dev/null"" ) != 0 || real_uid != root_uid ) ) { fprintf ( stderr , ""-CPermissiondenied\\n"" ) ; exit ( EXIT_FAILURE ) ; } } # endif if ( real_uid != root_uid ) { # ifdef TRUSTED_CONFIG_LIST if ( real_uid != exim_uid # ifdef CONFIGURE_OWNER && real_uid != config_uid # endif ) trusted_config = FALSE ; else { FILE * trust_list = Ufopen ( TRUSTED_CONFIG_LIST , ""rb"" ) ; if ( trust_list ) { struct stat statbuf ; if ( fstat ( fileno ( trust_list ) , & statbuf ) != 0 || ( statbuf . st_uid != root_uid # ifdef CONFIGURE_OWNER && statbuf . st_uid != config_uid # endif ) || ( statbuf . st_gid != root_gid # ifdef CONFIGURE_GROUP && statbuf . st_gid != config_gid # endif && ( statbuf . st_mode & 020 ) != 0 ) || ( statbuf . st_mode & 2 ) != 0 ) { trusted_config = FALSE ; fclose ( trust_list ) ; } else { void * reset_point = store_get ( 0 ) ; uschar * trusted_configs [ 32 ] ; int nr_configs = 0 ; int i = 0 ; while ( Ufgets ( big_buffer , big_buffer_size , trust_list ) ) { uschar * start = big_buffer , * nl ; while ( * start && isspace ( * start ) ) start ++ ; if ( * start != '/' ) continue ; nl = Ustrchr ( start , '\\n' ) ; if ( nl ) * nl = 0 ; trusted_configs [ nr_configs ++ ] = string_copy ( start ) ; if ( nr_configs == 32 ) break ; } fclose ( trust_list ) ; if ( nr_configs ) { int sep = 0 ; const uschar * list = argrest ; uschar * filename ; while ( trusted_config && ( filename = string_nextinlist ( & list , & sep , big_buffer , big_buffer_size ) ) != NULL ) { for ( i = 0 ; i < nr_configs ; i ++ ) { if ( Ustrcmp ( filename , trusted_configs [ i ] ) == 0 ) break ; } if ( i == nr_configs ) { trusted_config = FALSE ; break ; } } store_reset ( reset_point ) ; } else { trusted_config = FALSE ; } } } else { trusted_config = FALSE ; } } # else trusted_config = FALSE ; # endif } config_main_filelist = argrest ; config_changed = TRUE ; } break ; case 'D' : # ifdef DISABLE_D_OPTION fprintf ( stderr , ""exim:-DisnotavailableinthisEximbinary\\n"" ) ; exit ( EXIT_FAILURE ) ; # else { int ptr = 0 ; macro_item * m ; uschar name [ 24 ] ; uschar * s = argrest ; opt_D_used = TRUE ; while ( isspace ( * s ) ) s ++ ; if ( * s < 'A' || * s > 'Z' ) { fprintf ( stderr , ""exim:macronamesetby-Dmuststartwith"" ""anuppercaseletter\\n"" ) ; exit ( EXIT_FAILURE ) ; } while ( isalnum ( * s ) || * s == '_' ) { if ( ptr < sizeof ( name ) - 1 ) name [ ptr ++ ] = * s ; s ++ ; } name [ ptr ] = 0 ; if ( ptr == 0 ) { badarg = TRUE ; break ; } while ( isspace ( * s ) ) s ++ ; if ( * s != 0 ) { if ( * s ++ != '=' ) { badarg = TRUE ; break ; } while ( isspace ( * s ) ) s ++ ; } for ( m = macros ; m ; m = m -> next ) if ( Ustrcmp ( m -> name , name ) == 0 ) { fprintf ( stderr , ""exim:duplicated-Dincommandline\\n"" ) ; exit ( EXIT_FAILURE ) ; } m = macro_create ( name , s , TRUE , FALSE ) ; if ( clmacro_count >= MAX_CLMACROS ) { fprintf ( stderr , ""exim:toomany-Doptionsoncommandline\\n"" ) ; exit ( EXIT_FAILURE ) ; } clmacros [ clmacro_count ++ ] = string_sprintf ( ""-D%s=%s"" , m -> name , m -> replacement ) ; } # endif break ; case 'd' : if ( Ustrcmp ( argrest , ""ropcr"" ) == 0 ) { } else { unsigned int selector = D_default ; debug_selector = 0 ; debug_file = NULL ; if ( * argrest == 'd' ) { debug_daemon = TRUE ; argrest ++ ; } if ( * argrest != 0 ) decode_bits ( & selector , 1 , debug_notall , argrest , debug_options , debug_options_count , US ""debug"" , 0 ) ; debug_selector = selector ; } break ; case 'E' : local_error_message = TRUE ; if ( mac_ismsgid ( argrest ) ) message_reference = argrest ; break ; case 'e' : if ( Ustrcmp ( argrest , ""e"" ) == 0 ) { arg_error_handling = ERRORS_SENDER ; errors_sender_rc = EXIT_SUCCESS ; } else if ( Ustrcmp ( argrest , ""m"" ) == 0 ) arg_error_handling = ERRORS_SENDER ; else if ( Ustrcmp ( argrest , ""p"" ) == 0 ) arg_error_handling = ERRORS_STDERR ; else if ( Ustrcmp ( argrest , ""q"" ) == 0 ) arg_error_handling = ERRORS_STDERR ; else if ( Ustrcmp ( argrest , ""w"" ) == 0 ) arg_error_handling = ERRORS_SENDER ; else badarg = TRUE ; break ; case 'F' : if ( * argrest == 0 ) { if ( ++ i < argc ) argrest = argv [ i ] ; else { badarg = TRUE ; break ; } } originator_name = argrest ; sender_name_forced = TRUE ; break ; case 'f' : { int dummy_start , dummy_end ; uschar * errmess ; if ( * argrest == 0 ) { if ( i + 1 < argc ) argrest = argv [ ++ i ] ; else { badarg = TRUE ; break ; } } if ( * argrest == 0 ) sender_address = string_sprintf ( """" ) ; else { uschar * temp = argrest + Ustrlen ( argrest ) - 1 ; while ( temp >= argrest && isspace ( * temp ) ) temp -- ; if ( temp >= argrest && * temp == '.' ) f_end_dot = TRUE ; allow_domain_literals = TRUE ; strip_trailing_dot = TRUE ; # ifdef SUPPORT_I18N allow_utf8_domains = TRUE ; # endif sender_address = parse_extract_address ( argrest , & errmess , & dummy_start , & dummy_end , & sender_address_domain , TRUE ) ; # ifdef SUPPORT_I18N message_smtputf8 = string_is_utf8 ( sender_address ) ; allow_utf8_domains = FALSE ; # endif allow_domain_literals = FALSE ; strip_trailing_dot = FALSE ; if ( sender_address == NULL ) { fprintf ( stderr , ""exim:bad-faddress\\""%s\\"":%s\\n"" , argrest , errmess ) ; return EXIT_FAILURE ; } } sender_address_forced = TRUE ; } break ; case 'G' : flag_G = TRUE ; break ; case 'h' : if ( * argrest == 0 ) { if ( ++ i < argc ) argrest = argv [ i ] ; else { badarg = TRUE ; break ; } } if ( ! isdigit ( * argrest ) ) badarg = TRUE ; break ; case 'i' : if ( * argrest == 0 ) dot_ends = FALSE ; else badarg = TRUE ; break ; case 'L' : if ( * argrest == '\\0' ) { if ( ++ i < argc ) argrest = argv [ i ] ; else { badarg = TRUE ; break ; } } sz = Ustrlen ( argrest ) ; if ( sz > 32 ) { fprintf ( stderr , ""exim:the-Lsyslognameistoolong:\\""%s\\""\\n"" , argrest ) ; return EXIT_FAILURE ; } if ( sz < 1 ) { fprintf ( stderr , ""exim:the-Lsyslognameistooshort\\n"" ) ; return EXIT_FAILURE ; } cmdline_syslog_name = argrest ; break ; case 'M' : receiving_message = FALSE ; if ( Ustrcmp ( argrest , ""C"" ) == 0 ) { union sockaddr_46 interface_sock ; EXIM_SOCKLEN_T size = sizeof ( interface_sock ) ; if ( argc != i + 6 ) { fprintf ( stderr , ""exim:toomanyortoofewargumentsafter-MC\\n"" ) ; return EXIT_FAILURE ; } if ( msg_action_arg >= 0 ) { fprintf ( stderr , ""exim:incompatiblearguments\\n"" ) ; return EXIT_FAILURE ; } continue_transport = argv [ ++ i ] ; continue_hostname = argv [ ++ i ] ; continue_host_address = argv [ ++ i ] ; continue_sequence = Uatoi ( argv [ ++ i ] ) ; msg_action = MSG_DELIVER ; msg_action_arg = ++ i ; forced_delivery = TRUE ; queue_run_pid = passed_qr_pid ; queue_run_pipe = passed_qr_pipe ; if ( ! mac_ismsgid ( argv [ i ] ) ) { fprintf ( stderr , ""exim:malformedmessageid%safter-MCoption\\n"" , argv [ i ] ) ; return EXIT_FAILURE ; } if ( ! continue_proxy_cipher ) if ( getsockname ( fileno ( stdin ) , ( struct sockaddr * ) ( & interface_sock ) , & size ) == 0 ) sending_ip_address = host_ntoa ( - 1 , & interface_sock , NULL , & sending_port ) ; else { fprintf ( stderr , ""exim:getsockname()failedafter-MCoption:%s\\n"" , strerror ( errno ) ) ; return EXIT_FAILURE ; } if ( running_in_test_harness ) millisleep ( 500 ) ; break ; } else if ( * argrest == 'C' && argrest [ 1 ] && ! argrest [ 2 ] ) { switch ( argrest [ 1 ] ) { case 'A' : smtp_authenticated = TRUE ; break ; case 'D' : smtp_peer_options |= PEER_OFFERED_DSN ; break ; case 'G' : if ( ++ i < argc ) queue_name = string_copy ( argv [ i ] ) ; else badarg = TRUE ; break ; case 'K' : smtp_peer_options |= PEER_OFFERED_CHUNKING ; break ; case 'P' : smtp_peer_options |= PEER_OFFERED_PIPE ; break ; case 'Q' : if ( ++ i < argc ) passed_qr_pid = ( pid_t ) ( Uatol ( argv [ i ] ) ) ; else badarg = TRUE ; if ( ++ i < argc ) passed_qr_pipe = ( int ) ( Uatol ( argv [ i ] ) ) ; else badarg = TRUE ; break ; case 'S' : smtp_peer_options |= PEER_OFFERED_SIZE ; break ; # ifdef SUPPORT_TLS case 't' : if ( ++ i < argc ) sending_ip_address = argv [ i ] ; else badarg = TRUE ; if ( ++ i < argc ) sending_port = ( int ) ( Uatol ( argv [ i ] ) ) ; else badarg = TRUE ; if ( ++ i < argc ) continue_proxy_cipher = argv [ i ] ; else badarg = TRUE ; case 'T' : smtp_peer_options |= PEER_OFFERED_TLS ; break ; # endif default : badarg = TRUE ; break ; } break ; } else if ( * argrest == 0 ) { msg_action = MSG_DELIVER ; forced_delivery = deliver_force_thaw = TRUE ; } else if ( Ustrcmp ( argrest , ""ar"" ) == 0 ) { msg_action = MSG_ADD_RECIPIENT ; one_msg_action = TRUE ; } else if ( Ustrcmp ( argrest , ""c"" ) == 0 ) msg_action = MSG_DELIVER ; else if ( Ustrcmp ( argrest , ""es"" ) == 0 ) { msg_action = MSG_EDIT_SENDER ; one_msg_action = TRUE ; } else if ( Ustrcmp ( argrest , ""f"" ) == 0 ) msg_action = MSG_FREEZE ; else if ( Ustrcmp ( argrest , ""g"" ) == 0 ) { msg_action = MSG_DELIVER ; deliver_give_up = TRUE ; } else if ( Ustrcmp ( argrest , ""mad"" ) == 0 ) { msg_action = MSG_MARK_ALL_DELIVERED ; } else if ( Ustrcmp ( argrest , ""md"" ) == 0 ) { msg_action = MSG_MARK_DELIVERED ; one_msg_action = TRUE ; } else if ( Ustrcmp ( argrest , ""rm"" ) == 0 ) msg_action = MSG_REMOVE ; else if ( Ustrcmp ( argrest , ""set"" ) == 0 ) { msg_action = MSG_LOAD ; one_msg_action = TRUE ; } else if ( Ustrcmp ( argrest , ""t"" ) == 0 ) msg_action = MSG_THAW ; else if ( Ustrcmp ( argrest , ""vb"" ) == 0 ) { msg_action = MSG_SHOW_BODY ; one_msg_action = TRUE ; } else if ( Ustrcmp ( argrest , ""vc"" ) == 0 ) { msg_action = MSG_SHOW_COPY ; one_msg_action = TRUE ; } else if ( Ustrcmp ( argrest , ""vh"" ) == 0 ) { msg_action = MSG_SHOW_HEADER ; one_msg_action = TRUE ; } else if ( Ustrcmp ( argrest , ""vl"" ) == 0 ) { msg_action = MSG_SHOW_LOG ; one_msg_action = TRUE ; } else { badarg = TRUE ; break ; } msg_action_arg = i + 1 ; if ( msg_action_arg >= argc ) { fprintf ( stderr , ""exim:nomessageidsgivenafter%soption\\n"" , arg ) ; return EXIT_FAILURE ; } if ( ! one_msg_action ) { int j ; for ( j = msg_action_arg ; j < argc ; j ++ ) if ( ! mac_ismsgid ( argv [ j ] ) ) { fprintf ( stderr , ""exim:malformedmessageid%safter%soption\\n"" , argv [ j ] , arg ) ; return EXIT_FAILURE ; } goto END_ARG ; } else { if ( ! mac_ismsgid ( argv [ msg_action_arg ] ) ) { fprintf ( stderr , ""exim:malformedmessageid%safter%soption\\n"" , argv [ msg_action_arg ] , arg ) ; return EXIT_FAILURE ; } i ++ ; } break ; case 'm' : if ( * argrest != 0 ) badarg = TRUE ; break ; case 'N' : if ( * argrest == 0 ) { dont_deliver = TRUE ; debug_selector |= D_v ; debug_file = stderr ; } else badarg = TRUE ; break ; case 'n' : flag_n = TRUE ; break ; case 'O' : if ( * argrest == 0 ) { if ( ++ i >= argc ) { fprintf ( stderr , ""exim:stringexpectedafter-O\\n"" ) ; exit ( EXIT_FAILURE ) ; } } break ; case 'o' : if ( * argrest == 'A' ) { alias_arg = argrest + 1 ; if ( alias_arg [ 0 ] == 0 ) { if ( i + 1 < argc ) alias_arg = argv [ ++ i ] ; else { fprintf ( stderr , ""exim:stringexpectedafter-oA\\n"" ) ; exit ( EXIT_FAILURE ) ; } } } else if ( * argrest == 'B' ) { uschar * p = argrest + 1 ; if ( p [ 0 ] == 0 ) { if ( i + 1 < argc && isdigit ( ( argv [ i + 1 ] [ 0 ] ) ) ) p = argv [ ++ i ] ; else { connection_max_messages = 1 ; p = NULL ; } } if ( p != NULL ) { if ( ! isdigit ( * p ) ) { fprintf ( stderr , ""exim:numberexpectedafter-oB\\n"" ) ; exit ( EXIT_FAILURE ) ; } connection_max_messages = Uatoi ( p ) ; } } else if ( Ustrcmp ( argrest , ""db"" ) == 0 ) { synchronous_delivery = FALSE ; arg_queue_only = FALSE ; queue_only_set = TRUE ; } else if ( Ustrcmp ( argrest , ""df"" ) == 0 || Ustrcmp ( argrest , ""di"" ) == 0 ) { synchronous_delivery = TRUE ; arg_queue_only = FALSE ; queue_only_set = TRUE ; } else if ( Ustrcmp ( argrest , ""dq"" ) == 0 ) { synchronous_delivery = FALSE ; arg_queue_only = TRUE ; queue_only_set = TRUE ; } else if ( Ustrcmp ( argrest , ""dqs"" ) == 0 ) { queue_smtp = TRUE ; arg_queue_only = FALSE ; queue_only_set = TRUE ; } else if ( Ustrcmp ( argrest , ""i"" ) == 0 || Ustrcmp ( argrest , ""itrue"" ) == 0 ) dot_ends = FALSE ; else if ( * argrest == 'M' ) { if ( i + 1 >= argc ) { fprintf ( stderr , ""exim:dataexpectedafter-o%s\\n"" , argrest ) ; exit ( EXIT_FAILURE ) ; } if ( Ustrcmp ( argrest , ""Ma"" ) == 0 ) sender_host_address = argv [ ++ i ] ; else if ( Ustrcmp ( argrest , ""Maa"" ) == 0 ) sender_host_authenticated = argv [ ++ i ] ; else if ( Ustrcmp ( argrest , ""Mas"" ) == 0 ) authenticated_sender = argv [ ++ i ] ; else if ( Ustrcmp ( argrest , ""Mai"" ) == 0 ) authenticated_id = argv [ ++ i ] ; else if ( Ustrcmp ( argrest , ""Mi"" ) == 0 ) interface_address = argv [ ++ i ] ; else if ( Ustrcmp ( argrest , ""Mm"" ) == 0 ) { if ( ! mac_ismsgid ( argv [ i + 1 ] ) ) { fprintf ( stderr , ""-oMmmustbeavalidmessageID\\n"" ) ; exit ( EXIT_FAILURE ) ; } if ( ! trusted_config ) { fprintf ( stderr , ""-oMmmustbecalledbyatrusteduser/config\\n"" ) ; exit ( EXIT_FAILURE ) ; } message_reference = argv [ ++ i ] ; } else if ( Ustrcmp ( argrest , ""Mr"" ) == 0 ) received_protocol = argv [ ++ i ] ; else if ( Ustrcmp ( argrest , ""Ms"" ) == 0 ) sender_host_name = argv [ ++ i ] ; else if ( Ustrcmp ( argrest , ""Mt"" ) == 0 ) { sender_ident_set = TRUE ; sender_ident = argv [ ++ i ] ; } else { badarg = TRUE ; break ; } } else if ( Ustrcmp ( argrest , ""m"" ) == 0 ) { } else if ( Ustrcmp ( argrest , ""o"" ) == 0 ) { } else if ( Ustrcmp ( argrest , ""P"" ) == 0 ) override_pid_file_path = argv [ ++ i ] ; else if ( * argrest == 'r' || * argrest == 's' ) { int * tp = ( * argrest == 'r' ) ? & arg_receive_timeout : & arg_smtp_receive_timeout ; if ( argrest [ 1 ] == 0 ) { if ( i + 1 < argc ) * tp = readconf_readtime ( argv [ ++ i ] , 0 , FALSE ) ; } else * tp = readconf_readtime ( argrest + 1 , 0 , FALSE ) ; if ( * tp < 0 ) { fprintf ( stderr , ""exim:badtimevalue%s:abandoned\\n"" , argv [ i ] ) ; exit ( EXIT_FAILURE ) ; } } else if ( Ustrcmp ( argrest , ""X"" ) == 0 ) override_local_interfaces = argv [ ++ i ] ; else badarg = TRUE ; break ; case 'p' : # ifdef EXIM_PERL if ( * argrest == 's' && argrest [ 1 ] == 0 ) { perl_start_option = 1 ; break ; } if ( * argrest == 'd' && argrest [ 1 ] == 0 ) { perl_start_option = - 1 ; break ; } # endif if ( * argrest == 0 ) { if ( i + 1 < argc ) argrest = argv [ ++ i ] ; else { badarg = TRUE ; break ; } } if ( * argrest != 0 ) { uschar * hn = Ustrchr ( argrest , ':' ) ; if ( hn == NULL ) { received_protocol = argrest ; } else { int old_pool = store_pool ; store_pool = POOL_PERM ; received_protocol = string_copyn ( argrest , hn - argrest ) ; store_pool = old_pool ; sender_host_name = hn + 1 ; } } break ; case 'q' : receiving_message = FALSE ; if ( queue_interval >= 0 ) { fprintf ( stderr , ""exim:-qspecifiedmorethanonce\\n"" ) ; exit ( EXIT_FAILURE ) ; } if ( * argrest == 'q' ) { queue_2stage = TRUE ; argrest ++ ; } if ( * argrest == 'i' ) { queue_run_first_delivery = TRUE ; argrest ++ ; } if ( * argrest == 'f' ) { queue_run_force = TRUE ; if ( * ++ argrest == 'f' ) { deliver_force_thaw = TRUE ; argrest ++ ; } } if ( * argrest == 'l' ) { queue_run_local = TRUE ; argrest ++ ; } if ( * argrest == 'G' ) { int i ; for ( argrest ++ , i = 0 ; argrest [ i ] && argrest [ i ] != '/' ; ) i ++ ; queue_name = string_copyn ( argrest , i ) ; argrest += i ; if ( * argrest == '/' ) argrest ++ ; } if ( * argrest == 0 && ( i + 1 >= argc || argv [ i + 1 ] [ 0 ] == '-' || mac_ismsgid ( argv [ i + 1 ] ) ) ) { queue_interval = 0 ; if ( i + 1 < argc && mac_ismsgid ( argv [ i + 1 ] ) ) start_queue_run_id = argv [ ++ i ] ; if ( i + 1 < argc && mac_ismsgid ( argv [ i + 1 ] ) ) stop_queue_run_id = argv [ ++ i ] ; } else if ( ( queue_interval = readconf_readtime ( * argrest ? argrest : argv [ ++ i ] , 0 , FALSE ) ) <= 0 ) { fprintf ( stderr , ""exim:badtimevalue%s:abandoned\\n"" , argv [ i ] ) ; exit ( EXIT_FAILURE ) ; } break ; case 'R' : receiving_message = FALSE ; if ( * argrest != 0 ) { int i ; for ( i = 0 ; i < nelem ( rsopts ) ; i ++ ) if ( Ustrcmp ( argrest , rsopts [ i ] ) == 0 ) { if ( i != 2 ) queue_run_force = TRUE ; if ( i >= 2 ) deliver_selectstring_regex = TRUE ; if ( i == 1 || i == 4 ) deliver_force_thaw = TRUE ; argrest += Ustrlen ( rsopts [ i ] ) ; } } if ( * argrest ) deliver_selectstring = argrest ; else if ( i + 1 < argc ) deliver_selectstring = argv [ ++ i ] ; else { fprintf ( stderr , ""exim:stringexpectedafter-R\\n"" ) ; exit ( EXIT_FAILURE ) ; } break ; case 'S' : receiving_message = FALSE ; if ( * argrest ) { int i ; for ( i = 0 ; i < nelem ( rsopts ) ; i ++ ) if ( Ustrcmp ( argrest , rsopts [ i ] ) == 0 ) { if ( i != 2 ) queue_run_force = TRUE ; if ( i >= 2 ) deliver_selectstring_sender_regex = TRUE ; if ( i == 1 || i == 4 ) deliver_force_thaw = TRUE ; argrest += Ustrlen ( rsopts [ i ] ) ; } } if ( * argrest ) deliver_selectstring_sender = argrest ; else if ( i + 1 < argc ) deliver_selectstring_sender = argv [ ++ i ] ; else { fprintf ( stderr , ""exim:stringexpectedafter-S\\n"" ) ; exit ( EXIT_FAILURE ) ; } break ; case 'T' : if ( running_in_test_harness && Ustrcmp ( argrest , ""qt"" ) == 0 ) fudged_queue_times = argv [ ++ i ] ; else badarg = TRUE ; break ; case 't' : if ( * argrest == 0 ) extract_recipients = TRUE ; else if ( Ustrcmp ( argrest , ""i"" ) == 0 ) { extract_recipients = TRUE ; dot_ends = FALSE ; } # ifdef SUPPORT_TLS else if ( Ustrcmp ( argrest , ""ls-on-connect"" ) == 0 ) tls_in . on_connect = TRUE ; # endif else badarg = TRUE ; break ; case 'U' : break ; case 'v' : if ( * argrest == 0 ) { debug_selector |= D_v ; debug_file = stderr ; } else badarg = TRUE ; break ; case 'x' : if ( * argrest != 0 ) badarg = TRUE ; break ; case 'X' : if ( * argrest == '\\0' ) if ( ++ i >= argc ) { fprintf ( stderr , ""exim:stringexpectedafter-X\\n"" ) ; exit ( EXIT_FAILURE ) ; } break ; case 'z' : if ( * argrest == '\\0' ) if ( ++ i < argc ) log_oneline = argv [ i ] ; else { fprintf ( stderr , ""exim:filenameexpectedafter%s\\n"" , argv [ i - 1 ] ) ; exit ( EXIT_FAILURE ) ; } break ; default : badarg = TRUE ; break ; } if ( badarg ) { fprintf ( stderr , ""eximabandoned:unknown,malformed,orincomplete"" ""option%s\\n"" , arg ) ; exit ( EXIT_FAILURE ) ; } } if ( ( deliver_selectstring || deliver_selectstring_sender ) && queue_interval < 0 ) queue_interval = 0 ; END_ARG : if ( usage_wanted ) exim_usage ( called_as ) ; if ( ( ( smtp_input || extract_recipients || recipients_arg < argc ) && ( daemon_listen || queue_interval >= 0 || bi_option || test_retry_arg >= 0 || test_rewrite_arg >= 0 || filter_test != FTEST_NONE || ( msg_action_arg > 0 && ! one_msg_action ) ) ) || ( msg_action_arg > 0 && ( daemon_listen || queue_interval > 0 || list_options || ( checking && msg_action != MSG_LOAD ) || bi_option || test_retry_arg >= 0 || test_rewrite_arg >= 0 ) ) || ( ( daemon_listen || queue_interval > 0 ) && ( sender_address != NULL || list_options || list_queue || checking || bi_option ) ) || ( daemon_listen && queue_interval == 0 ) || ( inetd_wait_mode && queue_interval >= 0 ) || ( list_options && ( checking || smtp_input || extract_recipients || filter_test != FTEST_NONE || bi_option ) ) || ( verify_address_mode && ( address_test_mode || smtp_input || extract_recipients || filter_test != FTEST_NONE || bi_option ) ) || ( address_test_mode && ( smtp_input || extract_recipients || filter_test != FTEST_NONE || bi_option ) ) || ( smtp_input && ( sender_address != NULL || filter_test != FTEST_NONE || extract_recipients ) ) || ( deliver_selectstring != NULL && queue_interval < 0 ) || ( msg_action == MSG_LOAD && ( ! expansion_test || expansion_test_message != NULL ) ) ) { fprintf ( stderr , ""exim:incompatiblecommand-lineoptionsorarguments\\n"" ) ; exit ( EXIT_FAILURE ) ; } if ( debug_selector != 0 ) { debug_file = stderr ; debug_fd = fileno ( debug_file ) ; background_daemon = FALSE ; if ( running_in_test_harness ) millisleep ( 100 ) ; if ( debug_selector != D_v ) { debug_printf ( ""Eximversion%suid=%ldgid=%ldpid=%dD=%x\\n"" , version_string , ( long int ) real_uid , ( long int ) real_gid , ( int ) getpid ( ) , debug_selector ) ; if ( ! version_printed ) show_whats_supported ( stderr ) ; } } if ( unprivileged ) { DEBUG ( D_any ) debug_print_ids ( US ""Eximhasnorootprivilege:"" ) ; } else { struct rlimit rlp ; # ifdef RLIMIT_NOFILE if ( getrlimit ( RLIMIT_NOFILE , & rlp ) < 0 ) { log_write ( 0 , LOG_MAIN | LOG_PANIC , ""getrlimit(RLIMIT_NOFILE)failed:%s"" , strerror ( errno ) ) ; rlp . rlim_cur = rlp . rlim_max = 0 ; } if ( rlp . rlim_cur < 1000 ) { rlp . rlim_cur = rlp . rlim_max = 1000 ; if ( setrlimit ( RLIMIT_NOFILE , & rlp ) < 0 ) { rlp . rlim_cur = rlp . rlim_max = 256 ; if ( setrlimit ( RLIMIT_NOFILE , & rlp ) < 0 ) log_write ( 0 , LOG_MAIN | LOG_PANIC , ""setrlimit(RLIMIT_NOFILE)failed:%s"" , strerror ( errno ) ) ; } } # endif # ifdef RLIMIT_NPROC if ( getrlimit ( RLIMIT_NPROC , & rlp ) < 0 ) { log_write ( 0 , LOG_MAIN | LOG_PANIC , ""getrlimit(RLIMIT_NPROC)failed:%s"" , strerror ( errno ) ) ; rlp . rlim_cur = rlp . rlim_max = 0 ; } # ifdef RLIM_INFINITY if ( rlp . rlim_cur != RLIM_INFINITY && rlp . rlim_cur < 1000 ) { rlp . rlim_cur = rlp . rlim_max = RLIM_INFINITY ; # else if ( rlp . rlim_cur < 1000 ) { rlp . rlim_cur = rlp . rlim_max = 1000 ; # endif if ( setrlimit ( RLIMIT_NPROC , & rlp ) < 0 ) log_write ( 0 , LOG_MAIN | LOG_PANIC , ""setrlimit(RLIMIT_NPROC)failed:%s"" , strerror ( errno ) ) ; } # endif } group_count = getgroups ( NGROUPS_MAX , group_list ) ; if ( group_count < 0 ) { fprintf ( stderr , ""exim:getgroups()failed:%s\\n"" , strerror ( errno ) ) ; exit ( EXIT_FAILURE ) ; } if ( setgroups ( 0 , NULL ) != 0 ) { if ( setgroups ( 1 , group_list ) != 0 && ! unprivileged ) { fprintf ( stderr , ""exim:setgroups()failed:%s\\n"" , strerror ( errno ) ) ; exit ( EXIT_FAILURE ) ; } } if ( ( ( ! trusted_config || ! macros_trusted ( opt_D_used ) ) && real_uid != root_uid && ! running_in_test_harness ) || expansion_test || filter_test != FTEST_NONE ) { setgroups ( group_count , group_list ) ; exim_setugid ( real_uid , real_gid , FALSE , US ""-C,-D,-beor-bfforcesrealuid"" ) ; removed_privilege = TRUE ; if ( ( log_stderr != NULL ) && ( real_uid != exim_uid ) ) really_exim = FALSE ; } else exim_setugid ( geteuid ( ) , getegid ( ) , FALSE , US ""forcingreal=effective"" ) ; if ( ( filter_test & FTEST_SYSTEM ) != 0 ) { filter_sfd = Uopen ( filter_test_sfile , O_RDONLY , 0 ) ; if ( filter_sfd < 0 ) { fprintf ( stderr , ""exim:failedtoopen%s:%s\\n"" , filter_test_sfile , strerror ( errno ) ) ; return EXIT_FAILURE ; } } if ( ( filter_test & FTEST_USER ) != 0 ) { filter_ufd = Uopen ( filter_test_ufile , O_RDONLY , 0 ) ; if ( filter_ufd < 0 ) { fprintf ( stderr , ""exim:failedtoopen%s:%s\\n"" , filter_test_ufile , strerror ( errno ) ) ; return EXIT_FAILURE ; } } init_lookup_list ( ) ; # ifdef SUPPORT_I18N if ( running_in_test_harness ) smtputf8_advertise_hosts = NULL ; # endif if ( ( initial_cwd = os_getcwd ( NULL , 0 ) ) == NULL ) { perror ( ""exim:can\'tgetthecurrentworkingdirectory"" ) ; exit ( EXIT_FAILURE ) ; } readconf_main ( checking || list_options ) ; if ( builtin_macros_create_trigger ) DEBUG ( D_any ) debug_printf ( ""Builtinmacroscreated(expensive)duetoconfigline\'%.*s\'\\n"" , Ustrlen ( builtin_macros_create_trigger ) - 1 , builtin_macros_create_trigger ) ; if ( cleanup_environment ( ) == FALSE ) log_write ( 0 , LOG_PANIC_DIE , ""Can\'tcleanupenvironment"" ) ; if ( real_uid == root_uid || real_uid == exim_uid || real_gid == exim_gid ) admin_user = TRUE ; else { int i , j ; for ( i = 0 ; i < group_count && ! admin_user ; i ++ ) if ( group_list [ i ] == exim_gid ) admin_user = TRUE ; else if ( admin_groups ) for ( j = 1 ; j <= ( int ) admin_groups [ 0 ] && ! admin_user ; j ++ ) if ( admin_groups [ j ] == group_list [ i ] ) admin_user = TRUE ; } if ( real_uid == root_uid || real_uid == exim_uid ) trusted_caller = TRUE ; else { int i , j ; if ( trusted_users ) for ( i = 1 ; i <= ( int ) trusted_users [ 0 ] && ! trusted_caller ; i ++ ) if ( trusted_users [ i ] == real_uid ) trusted_caller = TRUE ; if ( trusted_groups ) for ( i = 1 ; i <= ( int ) trusted_groups [ 0 ] && ! trusted_caller ; i ++ ) if ( trusted_groups [ i ] == real_gid ) trusted_caller = TRUE ; else for ( j = 0 ; j < group_count && ! trusted_caller ; j ++ ) if ( trusted_groups [ i ] == group_list [ j ] ) trusted_caller = TRUE ; } if ( checking && commandline_checks_require_admin && ! admin_user ) { fprintf ( stderr , ""exim:thosecommand-lineflagsaresettorequireadmin\\n"" ) ; exit ( EXIT_FAILURE ) ; } decode_bits ( log_selector , log_selector_size , log_notall , log_selector_string , log_options , log_options_count , US ""log"" , 0 ) ; DEBUG ( D_any ) { int i ; debug_printf ( ""configurationfileis%s\\n"" , config_main_filename ) ; debug_printf ( ""logselectors="" ) ; for ( i = 0 ; i < log_selector_size ; i ++ ) debug_printf ( ""%08x"" , log_selector [ i ] ) ; debug_printf ( ""\\n"" ) ; } if ( sender_address != NULL ) { if ( sender_address [ sender_address_domain ] == '[' && ! allow_domain_literals ) { fprintf ( stderr , ""exim:bad-faddress\\""%s\\"":domainliteralsnot"" ""allowed\\n"" , sender_address ) ; return EXIT_FAILURE ; } if ( f_end_dot && ! strip_trailing_dot ) { fprintf ( stderr , ""exim:bad-faddress\\""%s.\\"":domainismalformed"" ""(trailingdotnotallowed)\\n"" , sender_address ) ; return EXIT_FAILURE ; } } if ( cmdline_syslog_name != NULL ) { if ( admin_user ) { syslog_processname = cmdline_syslog_name ; log_file_path = string_copy ( CUS ""syslog"" ) ; } else { fprintf ( stderr , ""exim:youlacksufficientprivilegetospecifysyslogprocessname\\n"" ) ; return EXIT_FAILURE ; } } if ( Ustrlen ( log_file_path ) > 200 ) log_write ( 0 , LOG_MAIN | LOG_PANIC_DIE , ""log_file_pathislongerthan200chars:aborting"" ) ; if ( Ustrlen ( pid_file_path ) > 200 ) log_write ( 0 , LOG_MAIN | LOG_PANIC_DIE , ""pid_file_pathislongerthan200chars:aborting"" ) ; if ( Ustrlen ( spool_directory ) > 200 ) log_write ( 0 , LOG_MAIN | LOG_PANIC_DIE , ""spool_directoryislongerthan200chars:aborting"" ) ; if ( Ustrlen ( syslog_processname ) > 32 ) log_write ( 0 , LOG_MAIN | LOG_PANIC_DIE , ""syslog_processnameislongerthan32chars:aborting"" ) ; if ( log_oneline ) if ( admin_user ) { log_write ( 0 , LOG_MAIN , ""%s"" , log_oneline ) ; return EXIT_SUCCESS ; } else return EXIT_FAILURE ; # ifdef EXIM_TMPDIR { uschar * * p ; if ( environ ) for ( p = USS environ ; * p ; p ++ ) if ( Ustrncmp ( * p , ""TMPDIR="" , 7 ) == 0 && Ustrcmp ( * p + 7 , EXIM_TMPDIR ) != 0 ) { uschar * newp = store_malloc ( Ustrlen ( EXIM_TMPDIR ) + 8 ) ; sprintf ( CS newp , ""TMPDIR=%s"" , EXIM_TMPDIR ) ; * p = newp ; DEBUG ( D_any ) debug_printf ( ""resetTMPDIR=%sinenvironment\\n"" , EXIM_TMPDIR ) ; } } # endif if ( timezone_string && strcmpic ( timezone_string , US ""UTC"" ) == 0 ) timestamps_utc = TRUE ; else { uschar * envtz = US getenv ( ""TZ"" ) ; if ( envtz ? ! timezone_string || Ustrcmp ( timezone_string , envtz ) != 0 : timezone_string != NULL ) { uschar * * p = USS environ ; uschar * * new ; uschar * * newp ; int count = 0 ; if ( environ ) while ( * p ++ ) count ++ ; if ( ! envtz ) count ++ ; newp = new = store_malloc ( sizeof ( uschar * ) * ( count + 1 ) ) ; if ( environ ) for ( p = USS environ ; * p ; p ++ ) if ( Ustrncmp ( * p , ""TZ="" , 3 ) != 0 ) * newp ++ = * p ; if ( timezone_string ) { * newp = store_malloc ( Ustrlen ( timezone_string ) + 4 ) ; sprintf ( CS * newp ++ , ""TZ=%s"" , timezone_string ) ; } * newp = NULL ; environ = CSS new ; tzset ( ) ; DEBUG ( D_any ) debug_printf ( ""ResetTZto%s:timeis%s\\n"" , timezone_string , tod_stamp ( tod_log ) ) ; } } if ( removed_privilege && ( ! trusted_config || opt_D_used ) && real_uid == exim_uid ) if ( deliver_drop_privilege ) really_exim = TRUE ; else log_write ( 0 , LOG_MAIN | LOG_PANIC , ""eximuserlostprivilegeforusing%soption"" , trusted_config ? ""-D"" : ""-C"" ) ; # ifdef EXIM_PERL if ( perl_start_option != 0 ) opt_perl_at_start = ( perl_start_option > 0 ) ; if ( opt_perl_at_start && opt_perl_startup != NULL ) { uschar * errstr ; DEBUG ( D_any ) debug_printf ( ""StartingPerlinterpreter\\n"" ) ; errstr = init_perl ( opt_perl_startup ) ; if ( errstr != NULL ) { fprintf ( stderr , ""exim:errorinperl_startupcode:%s\\n"" , errstr ) ; return EXIT_FAILURE ; } opt_perl_started = TRUE ; } # endif if ( ( ( debug_selector & D_any ) != 0 || LOGGING ( arguments ) ) && really_exim && ! list_options && ! checking ) { int i ; uschar * p = big_buffer ; Ustrcpy ( p , ""cwd=(failed)"" ) ; Ustrncpy ( p + 4 , initial_cwd , big_buffer_size - 5 ) ; while ( * p ) p ++ ; ( void ) string_format ( p , big_buffer_size - ( p - big_buffer ) , ""%dargs:"" , argc ) ; while ( * p ) p ++ ; for ( i = 0 ; i < argc ; i ++ ) { int len = Ustrlen ( argv [ i ] ) ; const uschar * printing ; uschar * quote ; if ( p + len + 8 >= big_buffer + big_buffer_size ) { Ustrcpy ( p , ""..."" ) ; log_write ( 0 , LOG_MAIN , ""%s"" , big_buffer ) ; Ustrcpy ( big_buffer , ""..."" ) ; p = big_buffer + 3 ; } printing = string_printing ( argv [ i ] ) ; if ( printing [ 0 ] == 0 ) quote = US ""\\"""" ; else { const uschar * pp = printing ; quote = US """" ; while ( * pp != 0 ) if ( isspace ( * pp ++ ) ) { quote = US ""\\"""" ; break ; } } sprintf ( CS p , ""%s%.*s%s"" , quote , ( int ) ( big_buffer_size - ( p - big_buffer ) - 4 ) , printing , quote ) ; while ( * p ) p ++ ; } if ( LOGGING ( arguments ) ) log_write ( 0 , LOG_MAIN , ""%s"" , big_buffer ) ; else debug_printf ( ""%s\\n"" , big_buffer ) ; } if ( Uchdir ( spool_directory ) != 0 ) { int dummy ; ( void ) directory_make ( spool_directory , US """" , SPOOL_DIRECTORY_MODE , FALSE ) ; dummy = Uchdir ( spool_directory ) ; } if ( bi_option ) { ( void ) fclose ( config_file ) ; if ( bi_command != NULL ) { int i = 0 ; uschar * argv [ 3 ] ; argv [ i ++ ] = bi_command ; if ( alias_arg != NULL ) argv [ i ++ ] = alias_arg ; argv [ i ++ ] = NULL ; setgroups ( group_count , group_list ) ; exim_setugid ( real_uid , real_gid , FALSE , US ""runningbi_command"" ) ; DEBUG ( D_exec ) debug_printf ( ""exec%.256s%.256s\\n"" , argv [ 0 ] , ( argv [ 1 ] == NULL ) ? US """" : argv [ 1 ] ) ; execv ( CS argv [ 0 ] , ( char * const * ) argv ) ; fprintf ( stderr , ""exim:execfailed:%s\\n"" , strerror ( errno ) ) ; exit ( EXIT_FAILURE ) ; } else { DEBUG ( D_any ) debug_printf ( ""-biusedbutbi_commandnotset;exiting\\n"" ) ; exit ( EXIT_SUCCESS ) ; } } if ( trusted_caller ) DEBUG ( D_any ) debug_printf ( ""trusteduser\\n"" ) ; if ( admin_user ) DEBUG ( D_any ) debug_printf ( ""adminuser\\n"" ) ; if ( ! admin_user ) { BOOL debugset = ( debug_selector & ~ D_v ) != 0 ; if ( deliver_give_up || daemon_listen || malware_test_file || ( count_queue && queue_list_requires_admin ) || ( list_queue && queue_list_requires_admin ) || ( queue_interval >= 0 && prod_requires_admin ) || ( debugset && ! running_in_test_harness ) ) { fprintf ( stderr , ""exim:%spermissiondenied\\n"" , debugset ? ""debugging"" : """" ) ; exit ( EXIT_FAILURE ) ; } } if ( real_uid != root_uid && real_uid != exim_uid && ( continue_hostname != NULL || ( dont_deliver && ( queue_interval >= 0 || daemon_listen || msg_action_arg > 0 ) ) ) && ! running_in_test_harness ) { fprintf ( stderr , ""exim:Permissiondenied\\n"" ) ; return EXIT_FAILURE ; } if ( ! trusted_caller && ! checking ) { sender_host_name = sender_host_address = interface_address = sender_ident = received_protocol = NULL ; sender_host_port = interface_port = 0 ; sender_host_authenticated = authenticated_sender = authenticated_id = NULL ; } else { if ( sender_host_address != NULL ) sender_host_port = check_port ( sender_host_address ) ; if ( interface_address != NULL ) interface_port = check_port ( interface_address ) ; } if ( flag_G ) { if ( trusted_caller ) { suppress_local_fixups = suppress_local_fixups_default = TRUE ; DEBUG ( D_acl ) debug_printf ( ""suppress_local_fixupsforcedonby-G\\n"" ) ; } else { fprintf ( stderr , ""exim:permissiondenied(-Grequiresatrusteduser)\\n"" ) ; return EXIT_FAILURE ; } } if ( smtp_input ) { union sockaddr_46 inetd_sock ; EXIM_SOCKLEN_T size = sizeof ( inetd_sock ) ; if ( getpeername ( 0 , ( struct sockaddr * ) ( & inetd_sock ) , & size ) == 0 ) { int family = ( ( struct sockaddr * ) ( & inetd_sock ) ) -> sa_family ; if ( family == AF_INET || family == AF_INET6 ) { union sockaddr_46 interface_sock ; size = sizeof ( interface_sock ) ; if ( getsockname ( 0 , ( struct sockaddr * ) ( & interface_sock ) , & size ) == 0 ) interface_address = host_ntoa ( - 1 , & interface_sock , NULL , & interface_port ) ; if ( host_is_tls_on_connect_port ( interface_port ) ) tls_in . on_connect = TRUE ; if ( real_uid == root_uid || real_uid == exim_uid || interface_port < 1024 ) { is_inetd = TRUE ; sender_host_address = host_ntoa ( - 1 , ( struct sockaddr * ) ( & inetd_sock ) , NULL , & sender_host_port ) ; if ( mua_wrapper ) log_write ( 0 , LOG_MAIN | LOG_PANIC_DIE , ""Inputfrom"" ""inetdisnotsupportedwhenmua_wrapperisset"" ) ; } else { fprintf ( stderr , ""exim:Permissiondenied(unprivilegeduser,unprivilegedport)\\n"" ) ; return EXIT_FAILURE ; } } } } # ifdef LOAD_AVG_NEEDS_ROOT if ( receiving_message && ( queue_only_load >= 0 || ( is_inetd && smtp_load_reserve >= 0 ) ) ) { load_average = OS_GETLOADAVG ( ) ; } # endif if ( queue_only_set && ( queue_only_override || arg_queue_only ) ) queue_only = arg_queue_only ; if ( arg_receive_timeout >= 0 ) receive_timeout = arg_receive_timeout ; if ( arg_smtp_receive_timeout >= 0 ) smtp_receive_timeout = arg_smtp_receive_timeout ; if ( ! unprivileged && ! removed_privilege && ! daemon_listen && queue_interval <= 0 && ( deliver_drop_privilege || ( queue_interval < 0 && ( msg_action_arg < 0 || msg_action != MSG_DELIVER ) && ( ! checking || ! address_test_mode ) ) ) ) exim_setugid ( exim_uid , exim_gid , TRUE , US ""privilegenotneeded"" ) ; else { int rv ; rv = setgid ( exim_gid ) ; if ( rv == - 1 ) if ( ! ( unprivileged || removed_privilege ) ) { fprintf ( stderr , ""exim:changinggroupfailed:%s\\n"" , strerror ( errno ) ) ; exit ( EXIT_FAILURE ) ; } else DEBUG ( D_any ) debug_printf ( ""changinggroupto%ldfailed:%s\\n"" , ( long int ) exim_gid , strerror ( errno ) ) ; } if ( malware_test_file ) { # ifdef WITH_CONTENT_SCAN int result ; set_process_info ( ""scanningfileformalware"" ) ; result = malware_in_file ( malware_test_file ) ; if ( result == FAIL ) { printf ( ""Nomalwarefound.\\n"" ) ; exit ( EXIT_SUCCESS ) ; } if ( result != OK ) { printf ( ""Malwarelookupreturnednon-okay/fail:%d\\n"" , result ) ; exit ( EXIT_FAILURE ) ; } if ( malware_name ) printf ( ""Malwarefound:%s\\n"" , malware_name ) ; else printf ( ""Malwarescandetectedmalwareofunknownname.\\n"" ) ; # else printf ( ""Malwarescanningnotenabledatcompiletime.\\n"" ) ; # endif exit ( EXIT_FAILURE ) ; } if ( list_queue ) { set_process_info ( ""listingthequeue"" ) ; queue_list ( list_queue_option , argv + recipients_arg , argc - recipients_arg ) ; exit ( EXIT_SUCCESS ) ; } if ( count_queue ) { set_process_info ( ""countingthequeue"" ) ; queue_count ( ) ; exit ( EXIT_SUCCESS ) ; } if ( msg_action_arg > 0 && msg_action != MSG_DELIVER && msg_action != MSG_LOAD ) { int yield = EXIT_SUCCESS ; set_process_info ( ""actingonspecifiedmessages"" ) ; if ( ! one_msg_action ) { for ( i = msg_action_arg ; i < argc ; i ++ ) if ( ! queue_action ( argv [ i ] , msg_action , NULL , 0 , 0 ) ) yield = EXIT_FAILURE ; } else if ( ! queue_action ( argv [ msg_action_arg ] , msg_action , argv , argc , recipients_arg ) ) yield = EXIT_FAILURE ; exit ( yield ) ; } readconf_rest ( ) ; store_pool = POOL_MAIN ; if ( test_retry_arg >= 0 ) { retry_config * yield ; int basic_errno = 0 ; int more_errno = 0 ; uschar * s1 , * s2 ; if ( test_retry_arg >= argc ) { printf ( ""-brtneedsadomainoraddressargument\\n"" ) ; exim_exit ( EXIT_FAILURE ) ; } s1 = argv [ test_retry_arg ++ ] ; s2 = NULL ; if ( Ustrchr ( s1 , '@' ) == NULL && Ustrchr ( s1 , '.' ) == NULL ) { printf ( ""Warning:\\""%s\\""containsno\'@\'andno\'.\'characters.Itis"" ""being\\ntreatedasaone-componentdomain,notasalocalpart.\\n\\n"" , s1 ) ; } if ( test_retry_arg < argc && Ustrchr ( argv [ test_retry_arg ] , '.' ) != NULL ) s2 = argv [ test_retry_arg ++ ] ; if ( test_retry_arg < argc ) { uschar * ss = argv [ test_retry_arg ] ; uschar * error = readconf_retry_error ( ss , ss + Ustrlen ( ss ) , & basic_errno , & more_errno ) ; if ( error != NULL ) { printf ( ""%s\\n"" , CS error ) ; return EXIT_FAILURE ; } if ( basic_errno == ERRNO_MAIL4XX || basic_errno == ERRNO_RCPT4XX || basic_errno == ERRNO_DATA4XX ) { int code = ( more_errno >> 8 ) & 255 ; if ( code == 255 ) more_errno = ( more_errno & 0xffff00ff ) | ( 21 << 8 ) ; else if ( code > 100 ) more_errno = ( more_errno & 0xffff00ff ) | ( ( code - 96 ) << 8 ) ; } } yield = retry_find_config ( s1 , s2 , basic_errno , more_errno ) ; if ( yield == NULL ) printf ( ""Noretryinformationfound\\n"" ) ; else { retry_rule * r ; more_errno = yield -> more_errno ; printf ( ""Retryrule:%s"" , yield -> pattern ) ; if ( yield -> basic_errno == ERRNO_EXIMQUOTA ) { printf ( ""quota%s%s"" , ( more_errno > 0 ) ? ""_"" : """" , ( more_errno > 0 ) ? readconf_printtime ( more_errno ) : US """" ) ; } else if ( yield -> basic_errno == ECONNREFUSED ) { printf ( ""refused%s%s"" , ( more_errno > 0 ) ? ""_"" : """" , ( more_errno == 'M' ) ? ""MX"" : ( more_errno == 'A' ) ? ""A"" : """" ) ; } else if ( yield -> basic_errno == ETIMEDOUT ) { printf ( ""timeout"" ) ; if ( ( more_errno & RTEF_CTOUT ) != 0 ) printf ( ""_connect"" ) ; more_errno &= 255 ; if ( more_errno != 0 ) printf ( ""_%s"" , ( more_errno == 'M' ) ? ""MX"" : ""A"" ) ; printf ( """" ) ; } else if ( yield -> basic_errno == ERRNO_AUTHFAIL ) printf ( ""auth_failed"" ) ; else printf ( ""*"" ) ; for ( r = yield -> rules ; r != NULL ; r = r -> next ) { printf ( ""%c,%s"" , r -> rule , readconf_printtime ( r -> timeout ) ) ; printf ( "",%s"" , readconf_printtime ( r -> p1 ) ) ; if ( r -> rule == 'G' ) { int x = r -> p2 ; int f = x % 1000 ; int d = 100 ; printf ( "",%d."" , x / 1000 ) ; do { printf ( ""%d"" , f / d ) ; f %= d ; d /= 10 ; } while ( f != 0 ) ; } printf ( "";"" ) ; } printf ( ""\\n"" ) ; } exim_exit ( EXIT_SUCCESS ) ; } if ( list_options ) { set_process_info ( ""listingvariables"" ) ; if ( recipients_arg >= argc ) readconf_print ( US ""all"" , NULL , flag_n ) ; else for ( i = recipients_arg ; i < argc ; i ++ ) { if ( i < argc - 1 && ( Ustrcmp ( argv [ i ] , ""router"" ) == 0 || Ustrcmp ( argv [ i ] , ""transport"" ) == 0 || Ustrcmp ( argv [ i ] , ""authenticator"" ) == 0 || Ustrcmp ( argv [ i ] , ""macro"" ) == 0 || Ustrcmp ( argv [ i ] , ""environment"" ) == 0 ) ) { readconf_print ( argv [ i + 1 ] , argv [ i ] , flag_n ) ; i ++ ; } else readconf_print ( argv [ i ] , NULL , flag_n ) ; } exim_exit ( EXIT_SUCCESS ) ; } if ( list_config ) { set_process_info ( ""listingconfig"" ) ; readconf_print ( US ""config"" , NULL , flag_n ) ; exim_exit ( EXIT_SUCCESS ) ; } # ifndef DISABLE_DKIM dkim_exim_init ( ) ; # endif deliver_init ( ) ; if ( msg_action_arg > 0 && msg_action != MSG_LOAD ) { if ( prod_requires_admin && ! admin_user ) { fprintf ( stderr , ""exim:Permissiondenied\\n"" ) ; exim_exit ( EXIT_FAILURE ) ; } set_process_info ( ""deliveringspecifiedmessages"" ) ; if ( deliver_give_up ) forced_delivery = deliver_force_thaw = TRUE ; for ( i = msg_action_arg ; i < argc ; i ++ ) { int status ; pid_t pid ; if ( i == argc - 1 ) ( void ) deliver_message ( argv [ i ] , forced_delivery , deliver_give_up ) ; else if ( ( pid = fork ( ) ) == 0 ) { ( void ) deliver_message ( argv [ i ] , forced_delivery , deliver_give_up ) ; _exit ( EXIT_SUCCESS ) ; } else if ( pid < 0 ) { fprintf ( stderr , ""failedtoforkdeliveryprocessfor%s:%s\\n"" , argv [ i ] , strerror ( errno ) ) ; exim_exit ( EXIT_FAILURE ) ; } else wait ( & status ) ; } exim_exit ( EXIT_SUCCESS ) ; } if ( queue_interval == 0 && ! daemon_listen ) { DEBUG ( D_queue_run ) debug_printf ( ""Singlequeuerun%s%s%s%s\\n"" , ( start_queue_run_id == NULL ) ? US """" : US ""startingat"" , ( start_queue_run_id == NULL ) ? US """" : start_queue_run_id , ( stop_queue_run_id == NULL ) ? US """" : US ""stoppingat"" , ( stop_queue_run_id == NULL ) ? US """" : stop_queue_run_id ) ; if ( * queue_name ) set_process_info ( ""runningthe\'%s\'queue(singlequeuerun)"" , queue_name ) ; else set_process_info ( ""runningthequeue(singlequeuerun)"" ) ; queue_run ( start_queue_run_id , stop_queue_run_id , FALSE ) ; exim_exit ( EXIT_SUCCESS ) ; } for ( i = 0 ; ; ) { if ( ( pw = getpwuid ( real_uid ) ) != NULL ) { originator_login = string_copy ( US pw -> pw_name ) ; originator_home = string_copy ( US pw -> pw_dir ) ; if ( originator_name == NULL ) { if ( sender_address == NULL || ( ! trusted_caller && filter_test == FTEST_NONE ) ) { uschar * name = US pw -> pw_gecos ; uschar * amp = Ustrchr ( name , '&' ) ; uschar buffer [ 256 ] ; if ( amp != NULL ) { int loffset ; string_format ( buffer , sizeof ( buffer ) , ""%.*s%n%s%s"" , amp - name , name , & loffset , originator_login , amp + 1 ) ; buffer [ loffset ] = toupper ( buffer [ loffset ] ) ; name = buffer ; } if ( gecos_pattern != NULL && gecos_name != NULL ) { const pcre * re ; re = regex_must_compile ( gecos_pattern , FALSE , TRUE ) ; if ( regex_match_and_setup ( re , name , 0 , - 1 ) ) { uschar * new_name = expand_string ( gecos_name ) ; expand_nmax = - 1 ; if ( new_name != NULL ) { DEBUG ( D_receive ) debug_printf ( ""username\\""%s\\""extractedfrom"" ""gecosfield\\""%s\\""\\n"" , new_name , name ) ; name = new_name ; } else DEBUG ( D_receive ) debug_printf ( ""failedtoexpandgecos_namestring"" ""\\""%s\\"":%s\\n"" , gecos_name , expand_string_message ) ; } else DEBUG ( D_receive ) debug_printf ( ""gecos_pattern\\""%s\\""didnotmatch"" ""gecosfield\\""%s\\""\\n"" , gecos_pattern , name ) ; store_free ( ( void * ) re ) ; } originator_name = string_copy ( name ) ; } else originator_name = US """" ; } break ; } if ( ++ i > finduser_retries ) break ; sleep ( 1 ) ; } if ( originator_login == NULL || running_in_test_harness ) { if ( unknown_login != NULL ) { originator_login = expand_string ( unknown_login ) ; if ( originator_name == NULL && unknown_username != NULL ) originator_name = expand_string ( unknown_username ) ; if ( originator_name == NULL ) originator_name = US """" ; } if ( originator_login == NULL ) log_write ( 0 , LOG_MAIN | LOG_PANIC_DIE , ""Failedtogetusernameforuid%d"" , ( int ) real_uid ) ; } originator_name = string_copy ( parse_fix_phrase ( originator_name , Ustrlen ( originator_name ) , big_buffer , big_buffer_size ) ) ; originator_uid = real_uid ; originator_gid = real_gid ; DEBUG ( D_receive ) debug_printf ( ""originator:uid=%dgid=%dlogin=%sname=%s\\n"" , ( int ) originator_uid , ( int ) originator_gid , originator_login , originator_name ) ; if ( daemon_listen || inetd_wait_mode || queue_interval > 0 ) { if ( mua_wrapper ) { fprintf ( stderr , ""Daemoncannotberunwhenmua_wrapperisset\\n"" ) ; log_write ( 0 , LOG_MAIN | LOG_PANIC_DIE , ""Daemoncannotberunwhen"" ""mua_wrapperisset"" ) ; } daemon_go ( ) ; } if ( sender_ident == NULL ) sender_ident = originator_login ; else if ( sender_ident [ 0 ] == 0 ) sender_ident = NULL ; if ( test_rewrite_arg >= 0 ) { really_exim = FALSE ; if ( test_rewrite_arg >= argc ) { printf ( ""-brwneedsanaddressargument\\n"" ) ; exim_exit ( EXIT_FAILURE ) ; } rewrite_test ( argv [ test_rewrite_arg ] ) ; exim_exit ( EXIT_SUCCESS ) ; } if ( ( sender_address == NULL && ! smtp_input ) || ( ! trusted_caller && filter_test == FTEST_NONE ) ) { sender_local = TRUE ; if ( authenticated_sender == NULL && ! host_checking ) authenticated_sender = string_sprintf ( ""%s@%s"" , originator_login , qualify_domain_sender ) ; if ( authenticated_id == NULL && ! host_checking ) authenticated_id = originator_login ; } if ( ( ! smtp_input && sender_address == NULL ) || ! receive_check_set_sender ( sender_address ) ) { if ( sender_address == NULL || ( sender_address [ 0 ] != 0 && ! checking ) ) { sender_address = originator_login ; sender_address_forced = FALSE ; sender_address_domain = 0 ; } } sender_set_untrusted = sender_address != originator_login && ! trusted_caller ; if ( sender_address != NULL && sender_address [ 0 ] != 0 && sender_address_domain == 0 ) sender_address = string_sprintf ( ""%s@%s"" , local_part_quote ( sender_address ) , qualify_domain_sender ) ; DEBUG ( D_receive ) debug_printf ( ""senderaddress=%s\\n"" , sender_address ) ; if ( verify_address_mode || address_test_mode ) { int exit_value = 0 ; int flags = vopt_qualify ; if ( verify_address_mode ) { if ( ! verify_as_sender ) flags |= vopt_is_recipient ; DEBUG ( D_verify ) debug_print_ids ( US ""Verifying:"" ) ; } else { flags |= vopt_is_recipient ; debug_selector |= D_v ; debug_file = stderr ; debug_fd = fileno ( debug_file ) ; DEBUG ( D_verify ) debug_print_ids ( US ""Addresstesting:"" ) ; } if ( recipients_arg < argc ) { while ( recipients_arg < argc ) { uschar * s = argv [ recipients_arg ++ ] ; while ( * s != 0 ) { BOOL finished = FALSE ; uschar * ss = parse_find_address_end ( s , FALSE ) ; if ( * ss == ',' ) * ss = 0 ; else finished = TRUE ; test_address ( s , flags , & exit_value ) ; s = ss ; if ( ! finished ) while ( * ( ++ s ) != 0 && ( * s == ',' || isspace ( * s ) ) ) ; } } } else for ( ; ; ) { uschar * s = get_stdinput ( NULL , NULL ) ; if ( s == NULL ) break ; test_address ( s , flags , & exit_value ) ; } route_tidyup ( ) ; exim_exit ( exit_value ) ; } if ( expansion_test ) { dns_init ( FALSE , FALSE , FALSE ) ; if ( msg_action_arg > 0 && msg_action == MSG_LOAD ) { uschar spoolname [ 256 ] ; if ( ! admin_user ) { fprintf ( stderr , ""exim:permissiondenied\\n"" ) ; exit ( EXIT_FAILURE ) ; } message_id = argv [ msg_action_arg ] ; ( void ) string_format ( spoolname , sizeof ( spoolname ) , ""%s-H"" , message_id ) ; if ( ( deliver_datafile = spool_open_datafile ( message_id ) ) < 0 ) printf ( ""Failedtoloadmessagedatafile%s\\n"" , message_id ) ; if ( spool_read_header ( spoolname , TRUE , FALSE ) != spool_read_OK ) printf ( ""Failedtoloadmessage%s\\n"" , message_id ) ; } else if ( expansion_test_message != NULL ) { int save_stdin = dup ( 0 ) ; int fd = Uopen ( expansion_test_message , O_RDONLY , 0 ) ; if ( fd < 0 ) { fprintf ( stderr , ""exim:failedtoopen%s:%s\\n"" , expansion_test_message , strerror ( errno ) ) ; return EXIT_FAILURE ; } ( void ) dup2 ( fd , 0 ) ; filter_test = FTEST_USER ; message_ended = END_NOTENDED ; read_message_body ( receive_msg ( extract_recipients ) ) ; message_linecount += body_linecount ; ( void ) dup2 ( save_stdin , 0 ) ; ( void ) close ( save_stdin ) ; clearerr ( stdin ) ; } enable_dollar_recipients = TRUE ; if ( recipients_arg < argc ) { while ( recipients_arg < argc ) { uschar * s = argv [ recipients_arg ++ ] ; uschar * ss = expand_string ( s ) ; if ( ss == NULL ) printf ( ""Failed:%s\\n"" , expand_string_message ) ; else printf ( ""%s\\n"" , CS ss ) ; } } else { char * ( * fn_readline ) ( const char * ) = NULL ; void ( * fn_addhist ) ( const char * ) = NULL ; # ifdef USE_READLINE void * dlhandle = set_readline ( & fn_readline , & fn_addhist ) ; # endif for ( ; ; ) { uschar * ss ; uschar * source = get_stdinput ( fn_readline , fn_addhist ) ; if ( source == NULL ) break ; ss = expand_string ( source ) ; if ( ss == NULL ) printf ( ""Failed:%s\\n"" , expand_string_message ) ; else printf ( ""%s\\n"" , CS ss ) ; } # ifdef USE_READLINE if ( dlhandle != NULL ) dlclose ( dlhandle ) ; # endif } if ( deliver_datafile >= 0 ) { ( void ) close ( deliver_datafile ) ; deliver_datafile = - 1 ; } exim_exit ( EXIT_SUCCESS ) ; } smtp_active_hostname = primary_hostname ; if ( raw_active_hostname != NULL ) { uschar * nah = expand_string ( raw_active_hostname ) ; if ( nah == NULL ) { if ( ! expand_string_forcedfail ) log_write ( 0 , LOG_MAIN | LOG_PANIC_DIE , ""failedtoexpand\\""%s\\"""" ""(smtp_active_hostname):%s"" , raw_active_hostname , expand_string_message ) ; } else if ( nah [ 0 ] != 0 ) smtp_active_hostname = nah ; } if ( host_checking ) { int x [ 4 ] ; int size ; if ( ! sender_ident_set ) { sender_ident = NULL ; if ( running_in_test_harness && sender_host_port != 0 && interface_address != NULL && interface_port != 0 ) verify_get_ident ( 1413 ) ; } size = host_aton ( sender_host_address , x ) ; sender_host_address = store_get ( 48 ) ; ( void ) host_nmtoa ( size , x , - 1 , sender_host_address , ':' ) ; host_build_sender_fullhost ( ) ; smtp_input = TRUE ; smtp_in = stdin ; smtp_out = stdout ; sender_local = FALSE ; sender_host_notsocket = TRUE ; debug_file = stderr ; debug_fd = fileno ( debug_file ) ; fprintf ( stdout , ""\\n****SMTPtestingsessionasiffromhost%s\\n"" ""****butwithoutanyident(RFC1413)callback.\\n"" ""****Thisisnotforreal!\\n\\n"" , sender_host_address ) ; memset ( sender_host_cache , 0 , sizeof ( sender_host_cache ) ) ; if ( verify_check_host ( & hosts_connection_nolog ) == OK ) BIT_CLEAR ( log_selector , log_selector_size , Li_smtp_connection ) ; log_write ( L_smtp_connection , LOG_MAIN , ""%s"" , smtp_get_connection_info ( ) ) ; if ( smtp_start_session ( ) ) { for ( reset_point = store_get ( 0 ) ; ; store_reset ( reset_point ) ) { if ( smtp_setup_msg ( ) <= 0 ) break ; if ( ! receive_msg ( FALSE ) ) break ; return_path = sender_address = NULL ; dnslist_domain = dnslist_matched = NULL ; # ifndef DISABLE_DKIM dkim_cur_signer = NULL ; # endif acl_var_m = NULL ; deliver_localpart_orig = NULL ; deliver_domain_orig = NULL ; callout_address = sending_ip_address = NULL ; sender_rate = sender_rate_limit = sender_rate_period = NULL ; } smtp_log_no_mail ( ) ; } exim_exit ( EXIT_SUCCESS ) ; } if ( recipients_arg >= argc && ! extract_recipients && ! smtp_input ) { if ( version_printed ) { printf ( ""Configurationfileis%s\\n"" , config_main_filename ) ; return EXIT_SUCCESS ; } if ( info_flag != CMDINFO_NONE ) { show_exim_information ( info_flag , info_stdout ? stdout : stderr ) ; return info_stdout ? EXIT_SUCCESS : EXIT_FAILURE ; } if ( filter_test == FTEST_NONE ) exim_usage ( called_as ) ; } if ( mua_wrapper ) { synchronous_delivery = TRUE ; arg_error_handling = ERRORS_STDERR ; remote_max_parallel = 1 ; deliver_drop_privilege = TRUE ; queue_smtp = FALSE ; queue_smtp_domains = NULL ; # ifdef SUPPORT_I18N message_utf8_downconvert = - 1 ; # endif } if ( ! smtp_input ) error_handling = arg_error_handling ; else if ( is_inetd ) { ( void ) fclose ( stderr ) ; exim_nullstd ( ) ; verify_get_ident ( IDENT_PORT ) ; host_build_sender_fullhost ( ) ; set_process_info ( ""handlingincomingconnectionfrom%sviainetd"" , sender_fullhost ) ; } if ( sender_host_address != NULL && sender_fullhost == NULL ) { host_build_sender_fullhost ( ) ; set_process_info ( ""handlingincomingconnectionfrom%svia-oMa"" , sender_fullhost ) ; sender_host_notsocket = TRUE ; } else if ( ! is_inetd ) sender_host_unknown = TRUE ; if ( fstat ( 1 , & statbuf ) < 0 ) ( void ) dup2 ( 0 , 1 ) ; if ( smtp_input ) { if ( ! is_inetd ) set_process_info ( ""acceptingalocal%sSMTPmessagefrom<%s>"" , smtp_batched_input ? ""batched"" : """" , ( sender_address != NULL ) ? sender_address : originator_login ) ; } else { int old_pool = store_pool ; store_pool = POOL_PERM ; if ( ! received_protocol ) received_protocol = string_sprintf ( ""local%s"" , called_as ) ; store_pool = old_pool ; set_process_info ( ""acceptingalocalnon-SMTPmessagefrom<%s>"" , sender_address ) ; } queue_check_only ( ) ; session_local_queue_only = queue_only ; if ( ( ! smtp_input || smtp_batched_input ) && ! receive_check_fs ( 0 ) ) { fprintf ( stderr , ""exim:insufficientdiskspace\\n"" ) ; return EXIT_FAILURE ; } if ( smtp_input ) { smtp_in = stdin ; smtp_out = stdout ; memset ( sender_host_cache , 0 , sizeof ( sender_host_cache ) ) ; if ( verify_check_host ( & hosts_connection_nolog ) == OK ) BIT_CLEAR ( log_selector , log_selector_size , Li_smtp_connection ) ; log_write ( L_smtp_connection , LOG_MAIN , ""%s"" , smtp_get_connection_info ( ) ) ; if ( ! smtp_start_session ( ) ) { mac_smtp_fflush ( ) ; exim_exit ( EXIT_SUCCESS ) ; } } else { thismessage_size_limit = expand_string_integer ( message_size_limit , TRUE ) ; if ( expand_string_message ) if ( thismessage_size_limit == - 1 ) log_write ( 0 , LOG_MAIN | LOG_PANIC_DIE , ""failedtoexpand"" ""message_size_limit:%s"" , expand_string_message ) ; else log_write ( 0 , LOG_MAIN | LOG_PANIC_DIE , ""invalidvaluefor"" ""message_size_limit:%s"" , expand_string_message ) ; } if ( ! synchronous_delivery ) { # ifdef SA_NOCLDWAIT struct sigaction act ; act . sa_handler = SIG_IGN ; sigemptyset ( & ( act . sa_mask ) ) ; act . sa_flags = SA_NOCLDWAIT ; sigaction ( SIGCHLD , & act , NULL ) ; # else signal ( SIGCHLD , SIG_IGN ) ; # endif } reset_point = store_get ( 0 ) ; real_sender_address = sender_address ; while ( more ) { message_id [ 0 ] = 0 ; if ( smtp_input ) { int rc ; if ( ( rc = smtp_setup_msg ( ) ) > 0 ) { if ( real_sender_address != NULL && ! receive_check_set_sender ( sender_address ) ) { sender_address = raw_sender = real_sender_address ; sender_address_unrewritten = NULL ; } if ( smtp_batched_input && acl_not_smtp_start != NULL ) { uschar * user_msg , * log_msg ; enable_dollar_recipients = TRUE ; ( void ) acl_check ( ACL_WHERE_NOTSMTP_START , NULL , acl_not_smtp_start , & user_msg , & log_msg ) ; enable_dollar_recipients = FALSE ; } more = receive_msg ( extract_recipients ) ; if ( message_id [ 0 ] == 0 ) { cancel_cutthrough_connection ( TRUE , US ""receivedropped"" ) ; if ( more ) goto moreloop ; smtp_log_no_mail ( ) ; exim_exit ( EXIT_FAILURE ) ; } } else { cancel_cutthrough_connection ( TRUE , US ""messagesetupdropped"" ) ; smtp_log_no_mail ( ) ; exim_exit ( ( rc == 0 ) ? EXIT_SUCCESS : EXIT_FAILURE ) ; } } else { int i ; int rcount = 0 ; int count = argc - recipients_arg ; uschar * * list = argv + recipients_arg ; active_local_sender_retain = local_sender_retain ; active_local_from_check = local_from_check ; raw_sender = string_copy ( sender_address ) ; for ( i = 0 ; i < count ; i ++ ) { int start , end , domain ; uschar * errmess ; uschar * s = list [ i ] ; while ( * s != 0 ) { BOOL finished = FALSE ; uschar * recipient ; uschar * ss = parse_find_address_end ( s , FALSE ) ; if ( * ss == ',' ) * ss = 0 ; else finished = TRUE ; if ( recipients_max > 0 && ++ rcount > recipients_max && ! extract_recipients ) if ( error_handling == ERRORS_STDERR ) { fprintf ( stderr , ""exim:toomanyrecipients\\n"" ) ; exim_exit ( EXIT_FAILURE ) ; } else { return moan_to_sender ( ERRMESS_TOOMANYRECIP , NULL , NULL , stdin , TRUE ) ? errors_sender_rc : EXIT_FAILURE ; } # ifdef SUPPORT_I18N { BOOL b = allow_utf8_domains ; allow_utf8_domains = TRUE ; # endif recipient = parse_extract_address ( s , & errmess , & start , & end , & domain , FALSE ) ; # ifdef SUPPORT_I18N if ( string_is_utf8 ( recipient ) ) message_smtputf8 = TRUE ; else allow_utf8_domains = b ; } # endif if ( domain == 0 && ! allow_unqualified_recipient ) { recipient = NULL ; errmess = US ""unqualifiedrecipientaddressnotallowed"" ; } if ( recipient == NULL ) { if ( error_handling == ERRORS_STDERR ) { fprintf ( stderr , ""exim:badrecipientaddress\\""%s\\"":%s\\n"" , string_printing ( list [ i ] ) , errmess ) ; exim_exit ( EXIT_FAILURE ) ; } else { error_block eblock ; eblock . next = NULL ; eblock . text1 = string_printing ( list [ i ] ) ; eblock . text2 = errmess ; return moan_to_sender ( ERRMESS_BADARGADDRESS , & eblock , NULL , stdin , TRUE ) ? errors_sender_rc : EXIT_FAILURE ; } } receive_add_recipient ( recipient , - 1 ) ; s = ss ; if ( ! finished ) while ( * ( ++ s ) != 0 && ( * s == ',' || isspace ( * s ) ) ) ; } } DEBUG ( D_receive ) { int i ; if ( sender_address != NULL ) debug_printf ( ""Sender:%s\\n"" , sender_address ) ; if ( recipients_list != NULL ) { debug_printf ( ""Recipients:\\n"" ) ; for ( i = 0 ; i < recipients_count ; i ++ ) debug_printf ( ""%s\\n"" , recipients_list [ i ] . address ) ; } } if ( acl_not_smtp_start ) { uschar * user_msg , * log_msg ; enable_dollar_recipients = TRUE ; ( void ) acl_check ( ACL_WHERE_NOTSMTP_START , NULL , acl_not_smtp_start , & user_msg , & log_msg ) ; enable_dollar_recipients = FALSE ; } if ( ! receive_timeout ) { struct timeval t = { 30 * 60 , 0 } ; fd_set r ; FD_ZERO ( & r ) ; FD_SET ( 0 , & r ) ; if ( select ( 1 , & r , NULL , NULL , & t ) == 0 ) mainlog_close ( ) ; } message_ended = END_NOTENDED ; more = receive_msg ( extract_recipients ) ; if ( message_id [ 0 ] == 0 ) exim_exit ( EXIT_FAILURE ) ; } if ( filter_test != FTEST_NONE ) { deliver_domain = ( ftest_domain != NULL ) ? ftest_domain : qualify_domain_recipient ; deliver_domain_orig = deliver_domain ; deliver_localpart = ( ftest_localpart != NULL ) ? ftest_localpart : originator_login ; deliver_localpart_orig = deliver_localpart ; deliver_localpart_prefix = ftest_prefix ; deliver_localpart_suffix = ftest_suffix ; deliver_home = originator_home ; if ( return_path == NULL ) { printf ( ""Return-pathcopiedfromsender\\n"" ) ; return_path = string_copy ( sender_address ) ; } else printf ( ""Return-path=%s\\n"" , ( return_path [ 0 ] == 0 ) ? US ""<>"" : return_path ) ; printf ( ""Sender=%s\\n"" , ( sender_address [ 0 ] == 0 ) ? US ""<>"" : sender_address ) ; receive_add_recipient ( string_sprintf ( ""%s%s%s@%s"" , ( ftest_prefix == NULL ) ? US """" : ftest_prefix , deliver_localpart , ( ftest_suffix == NULL ) ? US """" : ftest_suffix , deliver_domain ) , - 1 ) ; printf ( ""Recipient=%s\\n"" , recipients_list [ 0 ] . address ) ; if ( ftest_prefix != NULL ) printf ( ""Prefix=%s\\n"" , ftest_prefix ) ; if ( ftest_suffix != NULL ) printf ( ""Suffix=%s\\n"" , ftest_suffix ) ; if ( chdir ( ""/"" ) ) { DEBUG ( D_receive ) debug_printf ( ""chdir(\\""/\\"")failed\\n"" ) ; exim_exit ( EXIT_FAILURE ) ; } if ( ( filter_test & FTEST_SYSTEM ) != 0 ) { if ( ! filter_runtest ( filter_sfd , filter_test_sfile , TRUE , more ) ) exim_exit ( EXIT_FAILURE ) ; } memcpy ( filter_sn , filter_n , sizeof ( filter_sn ) ) ; if ( ( filter_test & FTEST_USER ) != 0 ) { if ( ! filter_runtest ( filter_ufd , filter_test_ufile , FALSE , more ) ) exim_exit ( EXIT_FAILURE ) ; } exim_exit ( EXIT_SUCCESS ) ; } if ( ! session_local_queue_only && smtp_accept_queue_per_connection > 0 && receive_messagecount > smtp_accept_queue_per_connection ) { session_local_queue_only = TRUE ; queue_only_reason = 2 ; } local_queue_only = session_local_queue_only ; if ( ! local_queue_only && queue_only_load >= 0 ) { local_queue_only = ( load_average = OS_GETLOADAVG ( ) ) > queue_only_load ; if ( local_queue_only ) { queue_only_reason = 3 ; if ( queue_only_load_latch ) session_local_queue_only = TRUE ; } } if ( mua_wrapper ) local_queue_only = queue_only_policy = deliver_freeze = FALSE ; if ( local_queue_only ) { cancel_cutthrough_connection ( TRUE , US ""nodelivery;queueing"" ) ; switch ( queue_only_reason ) { case 2 : log_write ( L_delay_delivery , LOG_MAIN , ""noimmediatedelivery:morethan%dmessages"" ""receivedinoneconnection"" , smtp_accept_queue_per_connection ) ; break ; case 3 : log_write ( L_delay_delivery , LOG_MAIN , ""noimmediatedelivery:loadaverage%.2f"" , ( double ) load_average / 1000.0 ) ; break ; } } else if ( queue_only_policy || deliver_freeze ) cancel_cutthrough_connection ( TRUE , US ""nodelivery;queueing"" ) ; else { pid_t pid ; search_tidyup ( ) ; if ( ( pid = fork ( ) ) == 0 ) { int rc ; close_unwanted ( ) ; exim_nullstd ( ) ; if ( geteuid ( ) != root_uid && ! deliver_drop_privilege && ! unprivileged ) { delivery_re_exec ( CEE_EXEC_EXIT ) ; } rc = deliver_message ( message_id , FALSE , FALSE ) ; search_tidyup ( ) ; _exit ( ( ! mua_wrapper || rc == DELIVER_MUA_SUCCEEDED ) ? EXIT_SUCCESS : EXIT_FAILURE ) ; } if ( pid < 0 ) { cancel_cutthrough_connection ( TRUE , US ""deliveryforkfailed"" ) ; log_write ( 0 , LOG_MAIN | LOG_PANIC , ""failedtoforkautomaticdelivery"" ""process:%s"" , strerror ( errno ) ) ; } else { release_cutthrough_connection ( US ""msgpassedfordelivery"" ) ; if ( synchronous_delivery ) { int status ; while ( wait ( & status ) != pid ) ; if ( ( status & 0x00ff ) != 0 ) log_write ( 0 , LOG_MAIN | LOG_PANIC , ""process%dcrashedwithsignal%dwhiledelivering%s"" , ( int ) pid , status & 0x00ff , message_id ) ; if ( mua_wrapper && ( status & 0xffff ) != 0 ) exim_exit ( EXIT_FAILURE ) ; } } } # ifndef SIG_IGN_WORKS while ( waitpid ( - 1 , NULL , WNOHANG ) > 0 ) ; # endif moreloop : return_path = sender_address = NULL ; authenticated_sender = NULL ; deliver_localpart_orig = NULL ; deliver_domain_orig = NULL ; deliver_host = deliver_host_address = NULL ; dnslist_domain = dnslist_matched = NULL ; # ifdef WITH_CONTENT_SCAN malware_name = NULL ; # endif callout_address = NULL ; sending_ip_address = NULL ; acl_var_m = NULL ; { int i ; for ( i = 0 ; i < REGEX_VARS ; i ++ ) regex_vars [ i ] = NULL ; } store_reset ( reset_point ) ; } exim_exit ( EXIT_SUCCESS ) ; return 0 ; } "," == 0 ) if ( received_protocol ) { fprintf ( stderr , ""received_protocolissetalready\\n"" ) ; exit ( EXIT_FAILURE ) ; } else { uschar * hn ; if ( received_protocol ) { fprintf ( stderr , ""received_protocolissetalready\\n"" ) ; exit ( EXIT_FAILURE ) ; } ",Exim@exim/65e061b76867a9ea7aeeb535341b790b90ae6c21,CVE-2017-1000369,https://github.com/Exim/exim/commit/65e061b76867a9ea7aeeb535341b790b90ae6c21,2017-06-19T16:29Z 351,CWE-000,"CWE-000 long do_rt_tgsigqueueinfo ( pid_t tgid , pid_t pid , int sig , siginfo_t * info ) { if ( pid <= 0 || tgid <= 0 ) return - EINVAL ; if ( info -> si_code >= 0 ) return - EPERM ; info -> si_signo = sig ; return do_send_specific ( tgid , pid , sig , info ) ; } "," info -> si_code != SI_QUEUE ) { WARN_ON_ONCE ( info -> si_code < 0 ) ; return - EPERM - EPERM ; } ",torvalds@linux/da48524eb20662618854bb3df2db01fc65f3070c,CVE-2011-1182,https://github.com/torvalds/linux/commit/da48524eb20662618854bb3df2db01fc65f3070c,2013-03-01T12:37Z 352,CWE-119,"CWE-119 static void parse_content_range ( URLContext * h , const char * p ) { HTTPContext * s = h -> priv_data ; const char * slash ; if ( ! strncmp ( p , ""bytes"" , 6 ) ) { p += 6 ; s -> off = strtoll ( p , NULL , 10 ) ; if ( ( slash = strchr ( p , '/' ) ) && strlen ( slash ) > 0 ) s -> filesize = strtoll ( slash + 1 , NULL , 10 ) ; } if ( s -> seekable == - 1 && ( ! s -> is_akamai || s -> filesize != 2147483647 ) ) h -> is_streamed = 0 ; } "," -> off = strtoull ( p , -> filesize = strtoull ( slash + ",FFmpeg@FFmpeg/2a05c8f813de6f2278827734bf8102291e7484aa,CVE-2016-10190,https://github.com/FFmpeg/FFmpeg/commit/2a05c8f813de6f2278827734bf8102291e7484aa,2017-02-09T15:59Z 353,CWE-125,"CWE-125 static void sycc422_to_rgb ( opj_image_t * img ) { int * d0 , * d1 , * d2 , * r , * g , * b ; const int * y , * cb , * cr ; unsigned int maxw , maxh , max ; int offset , upb ; unsigned int i , j ; upb = ( int ) img -> comps [ 0 ] . prec ; offset = 1 << ( upb - 1 ) ; upb = ( 1 << upb ) - 1 ; maxw = ( unsigned int ) img -> comps [ 0 ] . w ; maxh = ( unsigned int ) img -> comps [ 0 ] . h ; max = maxw * maxh ; y = img -> comps [ 0 ] . data ; cb = img -> comps [ 1 ] . data ; cr = img -> comps [ 2 ] . data ; d0 = r = ( int * ) malloc ( sizeof ( int ) * ( size_t ) max ) ; d1 = g = ( int * ) malloc ( sizeof ( int ) * ( size_t ) max ) ; d2 = b = ( int * ) malloc ( sizeof ( int ) * ( size_t ) max ) ; if ( r == NULL || g == NULL || b == NULL ) goto fails ; for ( i = 0U ; i < maxh ; ++ i ) { for ( j = 0U ; j < ( maxw & ~ ( unsigned int ) 1U ) ; j += 2U ) { sycc_to_rgb ( offset , upb , * y , * cb , * cr , r , g , b ) ; ++ y ; ++ r ; ++ g ; ++ b ; sycc_to_rgb ( offset , upb , * y , * cb , * cr , r , g , b ) ; ++ y ; ++ r ; ++ g ; ++ b ; ++ cb ; ++ cr ; } if ( j < maxw ) { sycc_to_rgb ( offset , upb , * y , * cb , * cr , r , g , b ) ; ++ y ; ++ r ; ++ g ; ++ b ; ++ cb ; ++ cr ; } } free ( img -> comps [ 0 ] . data ) ; img -> comps [ 0 ] . data = d0 ; free ( img -> comps [ 1 ] . data ) ; img -> comps [ 1 ] . data = d1 ; free ( img -> comps [ 2 ] . data ) ; img -> comps [ 2 ] . data = d2 ; # if defined ( USE_JPWL ) || defined ( USE_MJ2 ) img -> comps [ 1 ] . w = maxw ; img -> comps [ 1 ] . h = maxh ; img -> comps [ 2 ] . w = maxw ; img -> comps [ 2 ] . h = maxh ; # else img -> comps [ 1 ] . w = ( OPJ_UINT32 ) maxw ; img -> comps [ 1 ] . h = ( OPJ_UINT32 ) maxh ; img -> comps [ 2 ] . w = ( OPJ_UINT32 ) maxw ; img -> comps [ 2 ] . h = ( OPJ_UINT32 ) maxh ; # endif img -> comps [ 1 ] . dx = img -> comps [ 0 ] . dx ; img -> comps [ 2 ] . dx = img -> comps [ 0 ] . dx ; img -> comps [ 1 ] . dy = img -> comps [ 0 ] . dy ; img -> comps [ 2 ] . dy = img -> comps [ 0 ] . dy ; return ; fails : if ( r ) free ( r ) ; if ( g ) free ( g ) ; if ( b ) free ( b ) ; } "," * cr ; size_t maxw , maxh maxh , max , offx , loopmaxw , upb ; size_t i ; upb = maxw = ( size_t ) img -> maxh = ( size_t ) img -> int ) * max ) ; int ) * max ) ; int ) * max ) ; goto fails ; offx = img -> x0 & 1U ; loopmaxw = maxw - offx ; i ) { size_t j ; if ( offx > 0U ) { sycc_to_rgb ( offset , upb , * y , 0 , 0 , r , g , b ) ; ++ y ; ++ r ; ++ g ; ++ b ; } j < ( loopmaxw & ~ ( & ~ ( size_t ) 1U ) ( j < loopmaxw ) { sycc_to_rgb = d2 ; img -> comps . w = img -> comps [ 2 ] . w = img -> comps [ 0 ] . w ; img -> comps . h = img -> comps 2 ] . h = img -> comps [ 0 ] . h ; img -> comps [ 1 ] . dx = img -> comps 2 ] . dx = img -> comps [ 0 ] . dx ; img -> comps [ 1 ] . dy = img -> comps 2 ] . dy = img ; img -> color_space = OPJ_CLRSPC_SRGB ; return ; ; fails : free ( r r ) ; free ( g g ) ; free ( b ",uclouvain@openjpeg/15f081c89650dccee4aa4ae66f614c3fdb268767,CVE-2016-3183,https://github.com/uclouvain/openjpeg/commit/15f081c89650dccee4aa4ae66f614c3fdb268767,2017-02-03T16:59Z 354,CWE-000,"CWE-000 void nfs4_state_set_mode_locked ( struct nfs4_state * state , mode_t mode ) { if ( state -> state == mode ) return ; if ( ( mode & FMODE_WRITE ) != ( state -> state & FMODE_WRITE ) ) { if ( mode & FMODE_WRITE ) list_move ( & state -> open_states , & state -> owner -> so_states ) ; else list_move_tail ( & state -> open_states , & state -> owner -> so_states ) ; } state -> state = mode ; } "," * state , fmode_t fmode ) { if -> state == fmode ) return ; if ( ( fmode & FMODE_WRITE ) { if ( fmode & FMODE_WRITE ) -> state = fmode ; } ",torvalds@linux/dc0b027dfadfcb8a5504f7d8052754bf8d501ab9,CVE-2011-4324,https://github.com/torvalds/linux/commit/dc0b027dfadfcb8a5504f7d8052754bf8d501ab9,2012-06-21T23:55Z 355,CWE-399,"CWE-399 int kex_input_kexinit ( int type , u_int32_t seq , void * ctxt ) { struct ssh * ssh = ctxt ; struct kex * kex = ssh -> kex ; const u_char * ptr ; u_int i ; size_t dlen ; int r ; debug ( ""SSH2_MSG_KEXINITreceived"" ) ; if ( kex == NULL ) return SSH_ERR_INVALID_ARGUMENT ; ptr = sshpkt_ptr ( ssh , & dlen ) ; if ( ( r = sshbuf_put ( kex -> peer , ptr , dlen ) ) != 0 ) return r ; for ( i = 0 ; i < KEX_COOKIE_LEN ; i ++ ) if ( ( r = sshpkt_get_u8 ( ssh , NULL ) ) != 0 ) return r ; for ( i = 0 ; i < PROPOSAL_MAX ; i ++ ) if ( ( r = sshpkt_get_string ( ssh , NULL , NULL ) ) != 0 ) return r ; if ( ( r = sshpkt_get_u8 ( ssh , NULL ) ) != 0 || ( r = sshpkt_get_u32 ( ssh , NULL ) ) != 0 || ( r = sshpkt_get_end ( ssh ) ) != 0 ) return r ; if ( ! ( kex -> flags & KEX_INIT_SENT ) ) if ( ( r = kex_send_kexinit ( ssh ) ) != 0 ) return r ; if ( ( r = kex_choose_conf ( ssh ) ) != 0 ) return r ; if ( kex -> kex_type < KEX_MAX && kex -> kex [ kex -> kex_type ] != NULL ) return ( kex -> kex [ kex -> kex_type ] ) ( ssh ) ; return SSH_ERR_INTERNAL_ERROR ; } "," return SSH_ERR_INVALID_ARGUMENT ; ssh_dispatch_set ( ssh , SSH2_MSG_KEXINIT , NULL ) ; ",openssh@openssh-portable/ec165c392ca54317dbe3064a8c200de6531e89ad,CVE-2016-8858,https://github.com/openssh/openssh-portable/commit/ec165c392ca54317dbe3064a8c200de6531e89ad,2016-12-09T11:59Z 356,CWE-119,"CWE-119 static void test_modules ( ) { assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.constants.one+1==tests.constants.two\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.constants.foo==\\""foo\\""\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.constants.empty==\\""\\""\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.empty()==\\""\\""\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.struct_array[1].i==1\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.struct_array[0].i==1ortrue\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.integer_array[0]==0\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.integer_array[1]==1\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.string_array[0]==\\""foo\\""\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.string_array[2]==\\""baz\\""\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.string_dict[\\""foo\\""]==\\""foo\\""\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.string_dict[\\""bar\\""]==\\""bar\\""\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.isum(1,2)==3\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.isum(1,2,3)==6\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.fsum(1.0,2.0)==3.0\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.fsum(1.0,2.0,3.0)==6.0\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.foobar(1)==tests.foobar(1)\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.foobar(1)!=tests.foobar(2)\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.length(\\""dummy\\"")==5\\\n}"" , NULL ) ; assert_false_rule ( ""import\\""tests\\""\\\nruletest{condition:tests.struct_array[0].i==1\\\n}"" , NULL ) ; assert_false_rule ( ""import\\""tests\\""\\\nruletest{condition:tests.isum(1,1)==3\\\n}"" , NULL ) ; assert_false_rule ( ""import\\""tests\\""\\\nruletest{condition:tests.fsum(1.0,1.0)==3.0\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{condition:tests.match(/foo/,\\""foo\\"")==3\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{condition:tests.match(/foo/,\\""bar\\"")==-1\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{condition:tests.match(/foo.bar/i,\\""FOO\\\\nBAR\\"")==-1\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{condition:tests.match(/foo.bar/is,\\""FOO\\\\nBAR\\"")==7\\\n}"" , NULL ) ; assert_error ( ""import\\""\\\\x00\\"""" , ERROR_INVALID_MODULE_NAME ) ; assert_error ( ""import\\""\\"""" , ERROR_INVALID_MODULE_NAME ) ; } "," { assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.constants.one+1==tests.constants.two\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.constants.foo==\\""foo\\""\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.constants.empty==\\""\\""\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.empty()==\\""\\""\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.struct_array[1].i==1\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.struct_array[0].i==1ortrue\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.integer_array[0]==0\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.integer_array[1]==1\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.integer_array[256]==256\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.string_array[0]==\\""foo\\""\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.string_array[2]==\\""baz\\""\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.string_dict[\\""foo\\""]==\\""foo\\""\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.string_dict[\\""bar\\""]==\\""bar\\""\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.isum(1,2)==3\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.isum(1,2,3)==6\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.fsum(1.0,2.0)==3.0\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.fsum(1.0,2.0,3.0)==6.0\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.foobar(1)==tests.foobar(1)\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.foobar(1)!=tests.foobar(2)\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{\\\ncondition:tests.length(\\""dummy\\"")==5\\\n}"" , NULL ) ; assert_false_rule ( ""import\\""tests\\""\\\nruletest{condition:tests.struct_array[0].i==1\\\n}"" , NULL ) ; assert_false_rule ( ""import\\""tests\\""\\\nruletest{condition:tests.isum(1,1)==3\\\n}"" , NULL ) ; assert_false_rule ( ""import\\""tests\\""\\\nruletest{condition:tests.fsum(1.0,1.0)==3.0\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{condition:tests.match(/foo/,\\""foo\\"")==3\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{condition:tests.match(/foo/,\\""bar\\"")==-1\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{condition:tests.match(/foo.bar/i,\\""FOO\\\\nBAR\\"")==-1\\\n}"" , NULL ) ; assert_true_rule ( ""import\\""tests\\""\\\nruletest{condition:tests.match(/foo.bar/is,\\""FOO\\\\nBAR\\"")==7\\\n}"" , NULL ) ",VirusTotal@yara/4a342f01e5439b9bb901aff1c6c23c536baeeb3f,CVE-2017-11328,https://github.com/VirusTotal/yara/commit/4a342f01e5439b9bb901aff1c6c23c536baeeb3f,2017-07-17T13:18Z 357,CWE-416,"CWE-416 static Image * ReadPWPImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { FILE * file ; Image * image , * next_image , * pwp_image ; ImageInfo * read_info ; int c , unique_file ; MagickBooleanType status ; register Image * p ; register ssize_t i ; size_t filesize , length ; ssize_t count ; unsigned char magick [ MaxTextExtent ] ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; pwp_image = AcquireImage ( image_info ) ; image = pwp_image ; status = OpenBlob ( image_info , pwp_image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) return ( ( Image * ) NULL ) ; count = ReadBlob ( pwp_image , 5 , magick ) ; if ( ( count != 5 ) || ( LocaleNCompare ( ( char * ) magick , ""SFW95"" , 5 ) != 0 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; read_info = CloneImageInfo ( image_info ) ; ( void ) SetImageInfoProgressMonitor ( read_info , ( MagickProgressMonitor ) NULL , ( void * ) NULL ) ; SetImageInfoBlob ( read_info , ( void * ) NULL , 0 ) ; unique_file = AcquireUniqueFileResource ( read_info -> filename ) ; for ( ; ; ) { for ( c = ReadBlobByte ( pwp_image ) ; c != EOF ; c = ReadBlobByte ( pwp_image ) ) { for ( i = 0 ; i < 17 ; i ++ ) magick [ i ] = magick [ i + 1 ] ; magick [ 17 ] = ( unsigned char ) c ; if ( LocaleNCompare ( ( char * ) ( magick + 12 ) , ""SFW94A"" , 6 ) == 0 ) break ; } if ( c == EOF ) break ; if ( LocaleNCompare ( ( char * ) ( magick + 12 ) , ""SFW94A"" , 6 ) != 0 ) { ( void ) RelinquishUniqueFileResource ( read_info -> filename ) ; ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; } file = ( FILE * ) NULL ; if ( unique_file != - 1 ) file = fdopen ( unique_file , ""wb"" ) ; if ( ( unique_file == - 1 ) || ( file == ( FILE * ) NULL ) ) { ( void ) RelinquishUniqueFileResource ( read_info -> filename ) ; ThrowFileException ( exception , FileOpenError , ""UnableToWriteFile"" , image -> filename ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } length = fwrite ( ""SFW94A"" , 1 , 6 , file ) ; ( void ) length ; filesize = 65535UL * magick [ 2 ] + 256L * magick [ 1 ] + magick [ 0 ] ; for ( i = 0 ; i < ( ssize_t ) filesize ; i ++ ) { c = ReadBlobByte ( pwp_image ) ; ( void ) fputc ( c , file ) ; } ( void ) fclose ( file ) ; next_image = ReadImage ( read_info , exception ) ; if ( next_image == ( Image * ) NULL ) break ; ( void ) FormatLocaleString ( next_image -> filename , MaxTextExtent , ""slide_%02ld.sfw"" , ( long ) next_image -> scene ) ; if ( image == ( Image * ) NULL ) image = next_image ; else { for ( p = image ; p -> next != ( Image * ) NULL ; p = GetNextImageInList ( p ) ) ; next_image -> previous = p ; next_image -> scene = p -> scene + 1 ; p -> next = next_image ; } if ( image_info -> number_scenes != 0 ) if ( next_image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( pwp_image ) , GetBlobSize ( pwp_image ) ) ; if ( status == MagickFalse ) break ; } if ( unique_file != - 1 ) ( void ) close ( unique_file ) ; ( void ) RelinquishUniqueFileResource ( read_info -> filename ) ; read_info = DestroyImageInfo ( read_info ) ; ( void ) CloseBlob ( pwp_image ) ; pwp_image = DestroyImage ( pwp_image ) ; if ( EOFBlob ( image ) != MagickFalse ) { char * message ; message = GetExceptionMessage ( errno ) ; ( void ) ThrowMagickException ( exception , GetMagickModule ( ) , CorruptImageError , ""UnexpectedEndOfFile"" , ""`%s\':%s"" , image -> filename , message ) ; message = DestroyString ( message ) ; } ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," read_info ) ; if ( EOFBlob ",ImageMagick@ImageMagick/ecc03a2518c2b7dd375fde3a040fdae0bdf6a521,CVE-2016-10051,https://github.com/ImageMagick/ImageMagick/commit/ecc03a2518c2b7dd375fde3a040fdae0bdf6a521,2017-03-23T17:59Z 358,CWE-119,"CWE-119 int main ( int argc , char * * argv ) { test_cmp_parameters inParam ; FILE * fbase = NULL , * ftest = NULL ; int same = 0 ; char lbase [ 256 ] ; char strbase [ 256 ] ; char ltest [ 256 ] ; char strtest [ 256 ] ; if ( parse_cmdline_cmp ( argc , argv , & inParam ) == 1 ) { compare_dump_files_help_display ( ) ; goto cleanup ; } printf ( ""******Parameters*********\\n"" ) ; printf ( ""base_filename=%s\\n"" ""test_filename=%s\\n"" , inParam . base_filename , inParam . test_filename ) ; printf ( ""*************************\\n"" ) ; printf ( ""Trytoopen:%sforreading..."" , inParam . base_filename ) ; if ( ( fbase = fopen ( inParam . base_filename , ""rb"" ) ) == NULL ) { goto cleanup ; } printf ( ""Ok.\\n"" ) ; printf ( ""Trytoopen:%sforreading..."" , inParam . test_filename ) ; if ( ( ftest = fopen ( inParam . test_filename , ""rb"" ) ) == NULL ) { goto cleanup ; } printf ( ""Ok.\\n"" ) ; while ( fgets ( lbase , sizeof ( lbase ) , fbase ) && fgets ( ltest , sizeof ( ltest ) , ftest ) ) { int nbase = sscanf ( lbase , ""%255[^\\r\\n]"" , strbase ) ; int ntest = sscanf ( ltest , ""%255[^\\r\\n]"" , strtest ) ; assert ( nbase != 255 && ntest != 255 ) ; if ( nbase != 1 || ntest != 1 ) { fprintf ( stderr , ""couldnotparselinefromfiles\\n"" ) ; goto cleanup ; } if ( strcmp ( strbase , strtest ) != 0 ) { fprintf ( stderr , ""<%s>vs.<%s>\\n"" , strbase , strtest ) ; goto cleanup ; } } same = 1 ; printf ( ""\\n*****TESTSUCCEED:Filesarethesame.*****\\n"" ) ; cleanup : if ( fbase ) fclose ( fbase ) ; if ( ftest ) fclose ( ftest ) ; free ( inParam . base_filename ) ; free ( inParam . test_filename ) ; return same ? EXIT_SUCCESS : EXIT_FAILURE ; } "," char lbase [ 512 ] ; char char strbase [ 512 ] ; char char ltest [ 512 ] ; char char strtest [ 512 ] ; if ( lbase , ""%511[^\\r\\n]"" , strbase ) ( ltest , ""%511[^\\r\\n]"" , strtest ) ( nbase != 511 && ntest != && ntest != 511 ) ; if ",uclouvain@openjpeg/e078172b1c3f98d2219c37076b238fb759c751ea,CVE-2016-5157,https://github.com/uclouvain/openjpeg/commit/e078172b1c3f98d2219c37076b238fb759c751ea,2016-09-11T10:59Z 359,CWE-000,"CWE-000 static int cdc_ncm_bind ( struct usbnet * dev , struct usb_interface * intf ) { int ret ; if ( cdc_ncm_select_altsetting ( intf ) != CDC_NCM_COMM_ALTSETTING_NCM ) return - ENODEV ; ret = cdc_ncm_bind_common ( dev , intf , CDC_NCM_DATA_ALTSETTING_NCM , 0 ) ; usbnet_link_change ( dev , 0 , 0 ) ; return ret ; } "," intf ) { if ( cdc_ncm_select_altsetting - ENODEV ; return cdc_ncm_bind_common ( dev 0 ) ; } ",torvalds@linux/4d06dd537f95683aba3651098ae288b7cbff8274,CVE-2016-3951,https://github.com/torvalds/linux/commit/4d06dd537f95683aba3651098ae288b7cbff8274,2016-05-02T10:59Z 360,CWE-120,"CWE-120 static size_t send_control_msg ( VirtIOSerial * vser , void * buf , size_t len ) { VirtQueueElement elem ; VirtQueue * vq ; vq = vser -> c_ivq ; if ( ! virtio_queue_ready ( vq ) ) { return 0 ; } if ( ! virtqueue_pop ( vq , & elem ) ) { return 0 ; } memcpy ( elem . in_sg [ 0 ] . iov_base , buf , len ) ; virtqueue_push ( vq , & elem , len ) ; virtio_notify ( VIRTIO_DEVICE ( vser ) , vq ) ; return len ; } "," 0 ; } iov_from_buf ( elem . elem . in_sg , elem . in_num , 0 , buf , ",qemu@qemu/7882080388be5088e72c425b02223c02e6cb4295,CVE-2015-5745,https://github.com/qemu/qemu/commit/7882080388be5088e72c425b02223c02e6cb4295,2020-01-23T20:15Z 361,CWE-000,"CWE-000 static int jpc_qcd_dumpparms ( jpc_ms_t * ms , FILE * out ) { jpc_qcd_t * qcd = & ms -> parms . qcd ; int i ; fprintf ( out , ""qntsty=%d;numguard=%d;numstepsizes=%d\\n"" , ( int ) qcd -> compparms . qntsty , qcd -> compparms . numguard , qcd -> compparms . numstepsizes ) ; for ( i = 0 ; i < qcd -> compparms . numstepsizes ; ++ i ) { fprintf ( out , ""expn[%d]=0x%04x;mant[%d]=0x%04x;\\n"" , i , ( unsigned ) JPC_QCX_GETEXPN ( qcd -> compparms . stepsizes [ i ] ) , i , ( unsigned ) JPC_QCX_GETMANT ( qcd -> compparms . stepsizes [ i ] ) ) ; } return 0 ; } "," , i , JAS_CAST ( unsigned , JPC_QCX_GETEXPN ( qcd i ] ) ) , i , JAS_CAST ( unsigned , JPC_QCX_GETMANT ( qcd ] ) ) ) ",mdadams@jasper/1e84674d95353c64e5c4c0e7232ae86fd6ea813b,CVE-2016-9391,https://github.com/mdadams/jasper/commit/1e84674d95353c64e5c4c0e7232ae86fd6ea813b,2017-03-23T18:59Z 362,CWE-264,"CWE-264 static int check_entry_size_and_hooks ( struct ip6t_entry * e , struct xt_table_info * newinfo , const unsigned char * base , const unsigned char * limit , const unsigned int * hook_entries , const unsigned int * underflows , unsigned int valid_hooks ) { unsigned int h ; int err ; if ( ( unsigned long ) e % __alignof__ ( struct ip6t_entry ) != 0 || ( unsigned char * ) e + sizeof ( struct ip6t_entry ) >= limit || ( unsigned char * ) e + e -> next_offset > limit ) { duprintf ( ""Badoffset%p\\n"" , e ) ; return - EINVAL ; } if ( e -> next_offset < sizeof ( struct ip6t_entry ) + sizeof ( struct xt_entry_target ) ) { duprintf ( ""checking:element%psize%u\\n"" , e , e -> next_offset ) ; return - EINVAL ; } if ( ! ip6_checkentry ( & e -> ipv6 ) ) return - EINVAL ; err = xt_check_entry_offsets ( e , e -> target_offset , e -> next_offset ) ; if ( err ) return err ; for ( h = 0 ; h < NF_INET_NUMHOOKS ; h ++ ) { if ( ! ( valid_hooks & ( 1 << h ) ) ) continue ; if ( ( unsigned char * ) e - base == hook_entries [ h ] ) newinfo -> hook_entry [ h ] = hook_entries [ h ] ; if ( ( unsigned char * ) e - base == underflows [ h ] ) { if ( ! check_underflow ( e ) ) { pr_debug ( ""Underflowsmustbeunconditionaland"" ""usetheSTANDARDtargetwith"" ""ACCEPT/DROP\\n"" ) ; return - EINVAL ; } newinfo -> underflow [ h ] = underflows [ h ] ; } } e -> counters = ( ( struct xt_counters ) { 0 , 0 } ) ; e -> comefrom = 0 ; return 0 ; } "," , e -> elems , e -> ",torvalds@linux/ce683e5f9d045e5d67d1312a42b359cb2ab2a13c,CVE-2016-4997,https://github.com/torvalds/linux/commit/ce683e5f9d045e5d67d1312a42b359cb2ab2a13c,2016-07-03T21:59Z 363,CWE-119,"CWE-119 static int cdxl_decode_frame ( AVCodecContext * avctx , void * data , int * got_frame , AVPacket * pkt ) { CDXLVideoContext * c = avctx -> priv_data ; AVFrame * const p = data ; int ret , w , h , encoding , aligned_width , buf_size = pkt -> size ; const uint8_t * buf = pkt -> data ; if ( buf_size < 32 ) return AVERROR_INVALIDDATA ; encoding = buf [ 1 ] & 7 ; c -> format = buf [ 1 ] & 0xE0 ; w = AV_RB16 ( & buf [ 14 ] ) ; h = AV_RB16 ( & buf [ 16 ] ) ; c -> bpp = buf [ 19 ] ; c -> palette_size = AV_RB16 ( & buf [ 20 ] ) ; c -> palette = buf + 32 ; c -> video = c -> palette + c -> palette_size ; c -> video_size = buf_size - c -> palette_size - 32 ; if ( c -> palette_size > 512 ) return AVERROR_INVALIDDATA ; if ( buf_size < c -> palette_size + 32 ) return AVERROR_INVALIDDATA ; if ( c -> bpp < 1 ) return AVERROR_INVALIDDATA ; if ( c -> format != BIT_PLANAR && c -> format != BIT_LINE && c -> format != CHUNKY ) { avpriv_request_sample ( avctx , ""Pixelformat0x%0x"" , c -> format ) ; return AVERROR_PATCHWELCOME ; } if ( ( ret = ff_set_dimensions ( avctx , w , h ) ) < 0 ) return ret ; if ( c -> format == CHUNKY ) aligned_width = avctx -> width ; else aligned_width = FFALIGN ( c -> avctx -> width , 16 ) ; c -> padded_bits = aligned_width - c -> avctx -> width ; if ( c -> video_size < aligned_width * avctx -> height * ( int64_t ) c -> bpp / 8 ) return AVERROR_INVALIDDATA ; if ( ! encoding && c -> palette_size && c -> bpp <= 8 && c -> format != CHUNKY ) { avctx -> pix_fmt = AV_PIX_FMT_PAL8 ; } else if ( encoding == 1 && ( c -> bpp == 6 || c -> bpp == 8 ) ) { if ( c -> palette_size != ( 1 << ( c -> bpp - 1 ) ) ) return AVERROR_INVALIDDATA ; avctx -> pix_fmt = AV_PIX_FMT_BGR24 ; } else if ( ! encoding && c -> bpp == 24 && c -> format == CHUNKY && ! c -> palette_size ) { avctx -> pix_fmt = AV_PIX_FMT_RGB24 ; } else { avpriv_request_sample ( avctx , ""Encoding%d,bpp%dandformat0x%x"" , encoding , c -> bpp , c -> format ) ; return AVERROR_PATCHWELCOME ; } if ( ( ret = ff_get_buffer ( avctx , p , 0 ) ) < 0 ) return ret ; p -> pict_type = AV_PICTURE_TYPE_I ; if ( encoding ) { av_fast_padded_malloc ( & c -> new_video , & c -> new_video_size , h * w + AV_INPUT_BUFFER_PADDING_SIZE ) ; if ( ! c -> new_video ) return AVERROR ( ENOMEM ) ; if ( c -> bpp == 8 ) cdxl_decode_ham8 ( c , p ) ; else cdxl_decode_ham6 ( c , p ) ; } else if ( avctx -> pix_fmt == AV_PIX_FMT_PAL8 ) { cdxl_decode_rgb ( c , p ) ; } else { cdxl_decode_raw ( c , p ) ; } * got_frame = 1 ; return buf_size ; } "," == 8 ) && c -> format != CHUNKY ",FFmpeg@FFmpeg/1e42736b95065c69a7481d0cf55247024f54b660,CVE-2017-9996,https://github.com/FFmpeg/FFmpeg/commit/1e42736b95065c69a7481d0cf55247024f54b660,2017-06-28T06:29Z 364,CWE-125,"CWE-125 int ethertype_print ( netdissect_options * ndo , u_short ether_type , const u_char * p , u_int length , u_int caplen , const struct lladdr_info * src , const struct lladdr_info * dst ) { switch ( ether_type ) { case ETHERTYPE_IP : ip_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_IPV6 : ip6_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_ARP : case ETHERTYPE_REVARP : arp_print ( ndo , p , length , caplen ) ; return ( 1 ) ; case ETHERTYPE_DN : decnet_print ( ndo , p , length , caplen ) ; return ( 1 ) ; case ETHERTYPE_ATALK : if ( ndo -> ndo_vflag ) ND_PRINT ( ( ndo , ""et1"" ) ) ; atalk_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_AARP : aarp_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_IPX : ND_PRINT ( ( ndo , ""(NOV-ETHII)"" ) ) ; ipx_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_ISO : if ( length == 0 || caplen == 0 ) { ND_PRINT ( ( ndo , ""[|osi]"" ) ) ; return ( 1 ) ; } isoclns_print ( ndo , p + 1 , length - 1 , caplen - 1 ) ; return ( 1 ) ; case ETHERTYPE_PPPOED : case ETHERTYPE_PPPOES : case ETHERTYPE_PPPOED2 : case ETHERTYPE_PPPOES2 : pppoe_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_EAPOL : eap_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_RRCP : rrcp_print ( ndo , p , length , src , dst ) ; return ( 1 ) ; case ETHERTYPE_PPP : if ( length ) { ND_PRINT ( ( ndo , "":"" ) ) ; ppp_print ( ndo , p , length ) ; } return ( 1 ) ; case ETHERTYPE_MPCP : mpcp_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_SLOW : slow_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_CFM : case ETHERTYPE_CFM_OLD : cfm_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_LLDP : lldp_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_NSH : nsh_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_LOOPBACK : loopback_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_MPLS : case ETHERTYPE_MPLS_MULTI : mpls_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_TIPC : tipc_print ( ndo , p , length , caplen ) ; return ( 1 ) ; case ETHERTYPE_MS_NLB_HB : msnlb_print ( ndo , p ) ; return ( 1 ) ; case ETHERTYPE_GEONET_OLD : case ETHERTYPE_GEONET : geonet_print ( ndo , p , length , src ) ; return ( 1 ) ; case ETHERTYPE_CALM_FAST : calm_fast_print ( ndo , p , length , src ) ; return ( 1 ) ; case ETHERTYPE_AOE : aoe_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_MEDSA : medsa_print ( ndo , p , length , caplen , src , dst ) ; return ( 1 ) ; case ETHERTYPE_LAT : case ETHERTYPE_SCA : case ETHERTYPE_MOPRC : case ETHERTYPE_MOPDL : case ETHERTYPE_IEEE1905_1 : default : return ( 0 ) ; } } "," length - 1 ) ; return ",the-tcpdump-group@tcpdump/1dcd10aceabbc03bf571ea32b892c522cbe923de,CVE-2017-12897,https://github.com/the-tcpdump-group/tcpdump/commit/1dcd10aceabbc03bf571ea32b892c522cbe923de,2017-09-14T06:29Z 365,CWE-362,"CWE-362 static void queue_delete ( struct snd_seq_queue * q ) { snd_seq_timer_stop ( q -> timer ) ; snd_seq_timer_close ( q ) ; snd_use_lock_sync ( & q -> use_lock ) ; snd_seq_prioq_delete ( & q -> tickq ) ; snd_seq_prioq_delete ( & q -> timeq ) ; snd_seq_timer_delete ( & q -> timer ) ; kfree ( q ) ; } "," q ) { mutex_lock ( & q -> timer_mutex ) ; snd_seq_timer_close ( q ) ; mutex_unlock ( & q -> timer_mutex ",torvalds@linux/3567eb6af614dac436c4b16a8d426f9faed639b3,CVE-2016-2544,https://github.com/torvalds/linux/commit/3567eb6af614dac436c4b16a8d426f9faed639b3,2016-04-27T17:59Z 366,CWE-119,"CWE-119 static int fallocate_chunk ( struct inode * inode , loff_t offset , loff_t len , int mode ) { struct gfs2_inode * ip = GFS2_I ( inode ) ; struct buffer_head * dibh ; int error ; u64 start = offset >> PAGE_CACHE_SHIFT ; unsigned int start_offset = offset & ~ PAGE_CACHE_MASK ; u64 end = ( offset + len - 1 ) >> PAGE_CACHE_SHIFT ; pgoff_t curr ; struct page * page ; unsigned int end_offset = ( offset + len ) & ~ PAGE_CACHE_MASK ; unsigned int from , to ; if ( ! end_offset ) end_offset = PAGE_CACHE_SIZE ; error = gfs2_meta_inode_buffer ( ip , & dibh ) ; if ( unlikely ( error ) ) goto out ; gfs2_trans_add_bh ( ip -> i_gl , dibh , 1 ) ; if ( gfs2_is_stuffed ( ip ) ) { error = gfs2_unstuff_dinode ( ip , NULL ) ; if ( unlikely ( error ) ) goto out ; } curr = start ; offset = start << PAGE_CACHE_SHIFT ; from = start_offset ; to = PAGE_CACHE_SIZE ; while ( curr <= end ) { page = grab_cache_page_write_begin ( inode -> i_mapping , curr , AOP_FLAG_NOFS ) ; if ( unlikely ( ! page ) ) { error = - ENOMEM ; goto out ; } if ( curr == end ) to = end_offset ; error = write_empty_blocks ( page , from , to , mode ) ; if ( ! error && offset + to > inode -> i_size && ! ( mode & FALLOC_FL_KEEP_SIZE ) ) { i_size_write ( inode , offset + to ) ; } unlock_page ( page ) ; page_cache_release ( page ) ; if ( error ) goto out ; curr ++ ; offset += PAGE_CACHE_SIZE ; from = 0 ; } mark_inode_dirty ( inode ) ; brelse ( dibh ) ; out : return error ; } "," int error ; unsigned int nr_blks ; sector_t lblock = offset >> = offset >> inode -> i_blkbits ; error = gfs2_meta_inode_buffer ( ip , & dibh ) ; if ( unlikely ( error ) ) return error ; gfs2_trans_add_bh ( ip -> i_gl , dibh , 1 ) ; if ( gfs2_is_stuffed ( ip ) ) { error = gfs2_unstuff_dinode ( ip , NULL ) ; if ( unlikely ( error ) ) goto out ; } while ( len ) { struct buffer_head bh_map = { . b_state = 0 , . b_blocknr = 0 } ; bh_map . b_size = len ; set_buffer_zeronew ( & bh_map ) ; error = gfs2_block_map ( inode , lblock , & bh_map , 1 ) ; if ( unlikely ( error ) ) goto out ; len -= bh_map . b_size ; nr_blks = bh_map . b_size >> inode -> i_blkbits ; lblock += nr_blks ; if ( ! buffer_new ( & bh_map ) ) continue ; if ( unlikely ( ! buffer_zeronew ( & bh_map ) ) ) { error = - EIO ; goto out ; } } if ( offset + offset + len > inode -> FALLOC_FL_KEEP_SIZE ) ) i_size_write ( inode , offset + len ) ; mark_inode_dirty ( inode mark_inode_dirty ( inode ) ; out ; out : brelse ( dibh ) ; ",torvalds@linux/64dd153c83743af81f20924c6343652d731eeecb,CVE-2011-4098,https://github.com/torvalds/linux/commit/64dd153c83743af81f20924c6343652d731eeecb,2013-06-08T13:05Z 367,CWE-362,"CWE-362 static void * vips_foreign_load_start ( VipsImage * out , void * a , void * b ) { VipsForeignLoad * load = VIPS_FOREIGN_LOAD ( b ) ; VipsForeignLoadClass * class = VIPS_FOREIGN_LOAD_GET_CLASS ( load ) ; if ( ! load -> real ) { if ( ! ( load -> real = vips_foreign_load_temp ( load ) ) ) return ( NULL ) ; # ifdef DEBUG printf ( ""vips_foreign_load_start:triggering->load()\\n"" ) ; # endif load -> real -> progress_signal = load -> out ; g_object_set_qdata ( G_OBJECT ( load -> real ) , vips__foreign_load_operation , load ) ; if ( class -> load ( load ) || vips_image_pio_input ( load -> real ) ) return ( NULL ) ; if ( ! vips_foreign_load_iscompat ( load -> real , out ) ) return ( NULL ) ; vips_image_pipelinev ( load -> out , load -> out -> dhint , load -> real , NULL ) ; } return ( vips_region_new ( load -> real ) ) ; } "," VIPS_FOREIGN_LOAD_GET_CLASS ( load ) ; if ( load -> error ) return ( NULL -> real ) || vips_foreign_load_iscompat ( load out ) ) { vips_operation_invalidate ( VIPS_OPERATION ( load ) ) ; load -> error = TRUE ; return ( NULL ) ; } vips_image_pipelinev ( load ",jcupitt@libvips/20d840e6da15c1574b3ed998bc92f91d1e36c2a5,CVE-2018-7998,https://github.com/jcupitt/libvips/commit/20d840e6da15c1574b3ed998bc92f91d1e36c2a5,2018-03-09T19:29Z 368,CWE-000,"CWE-000 static int fit_image_verify_sig ( const void * fit , int image_noffset , const char * data , size_t size , const void * sig_blob , int sig_offset ) { int noffset ; char * err_msg = """" ; int verified = 0 ; int ret ; fdt_for_each_subnode ( noffset , fit , image_noffset ) { const char * name = fit_get_name ( fit , noffset , NULL ) ; if ( ! strncmp ( name , FIT_SIG_NODENAME , strlen ( FIT_SIG_NODENAME ) ) ) { ret = fit_image_check_sig ( fit , noffset , data , size , - 1 , & err_msg ) ; if ( ret ) { puts ( ""-"" ) ; } else { puts ( ""+"" ) ; verified = 1 ; break ; } } } if ( noffset == - FDT_ERR_TRUNCATED || noffset == - FDT_ERR_BADSTRUCTURE ) { err_msg = ""Corruptedortruncatedtree"" ; goto error ; } return verified ? 0 : - EPERM ; error : printf ( ""error!\\n%sfor\'%s\'hashnodein\'%s\'imagenode\\n"" , err_msg , fit_get_name ( fit , noffset , NULL ) , fit_get_name ( fit , image_noffset , NULL ) ) ; return - 1 ; } "," NULL ) ; if ( strchr ( name , '@' ) ) { err_msg = ""Nodenamecontains@"" ; goto error ; } ",u-boot@u-boot/79af75f7776fc20b0d7eb6afe1e27c00fdb4b9b4,CVE-2021-27138,https://github.com/u-boot/u-boot/commit/79af75f7776fc20b0d7eb6afe1e27c00fdb4b9b4,2021-02-17T23:15Z 369,CWE-400,"CWE-400 int xfs_attr3_leaf_list_int ( struct xfs_buf * bp , struct xfs_attr_list_context * context ) { struct attrlist_cursor_kern * cursor ; struct xfs_attr_leafblock * leaf ; struct xfs_attr3_icleaf_hdr ichdr ; struct xfs_attr_leaf_entry * entries ; struct xfs_attr_leaf_entry * entry ; int retval ; int i ; struct xfs_mount * mp = context -> dp -> i_mount ; trace_xfs_attr_list_leaf ( context ) ; leaf = bp -> b_addr ; xfs_attr3_leaf_hdr_from_disk ( mp -> m_attr_geo , & ichdr , leaf ) ; entries = xfs_attr3_leaf_entryp ( leaf ) ; cursor = context -> cursor ; cursor -> initted = 1 ; if ( context -> resynch ) { entry = & entries [ 0 ] ; for ( i = 0 ; i < ichdr . count ; entry ++ , i ++ ) { if ( be32_to_cpu ( entry -> hashval ) == cursor -> hashval ) { if ( cursor -> offset == context -> dupcnt ) { context -> dupcnt = 0 ; break ; } context -> dupcnt ++ ; } else if ( be32_to_cpu ( entry -> hashval ) > cursor -> hashval ) { context -> dupcnt = 0 ; break ; } } if ( i == ichdr . count ) { trace_xfs_attr_list_notfound ( context ) ; return 0 ; } } else { entry = & entries [ 0 ] ; i = 0 ; } context -> resynch = 0 ; retval = 0 ; for ( ; i < ichdr . count ; entry ++ , i ++ ) { if ( be32_to_cpu ( entry -> hashval ) != cursor -> hashval ) { cursor -> hashval = be32_to_cpu ( entry -> hashval ) ; cursor -> offset = 0 ; } if ( entry -> flags & XFS_ATTR_INCOMPLETE ) continue ; if ( entry -> flags & XFS_ATTR_LOCAL ) { xfs_attr_leaf_name_local_t * name_loc = xfs_attr3_leaf_name_local ( leaf , i ) ; retval = context -> put_listent ( context , entry -> flags , name_loc -> nameval , ( int ) name_loc -> namelen , be16_to_cpu ( name_loc -> valuelen ) , & name_loc -> nameval [ name_loc -> namelen ] ) ; if ( retval ) return retval ; } else { xfs_attr_leaf_name_remote_t * name_rmt = xfs_attr3_leaf_name_remote ( leaf , i ) ; int valuelen = be32_to_cpu ( name_rmt -> valuelen ) ; if ( context -> put_value ) { xfs_da_args_t args ; memset ( ( char * ) & args , 0 , sizeof ( args ) ) ; args . geo = context -> dp -> i_mount -> m_attr_geo ; args . dp = context -> dp ; args . whichfork = XFS_ATTR_FORK ; args . valuelen = valuelen ; args . rmtvaluelen = valuelen ; args . value = kmem_alloc ( valuelen , KM_SLEEP | KM_NOFS ) ; args . rmtblkno = be32_to_cpu ( name_rmt -> valueblk ) ; args . rmtblkcnt = xfs_attr3_rmt_blocks ( args . dp -> i_mount , valuelen ) ; retval = xfs_attr_rmtval_get ( & args ) ; if ( retval ) return retval ; retval = context -> put_listent ( context , entry -> flags , name_rmt -> name , ( int ) name_rmt -> namelen , valuelen , args . value ) ; kmem_free ( args . value ) ; } else { retval = context -> put_listent ( context , entry -> flags , name_rmt -> name , ( int ) name_rmt -> namelen , valuelen , NULL ) ; } if ( retval ) return retval ; } if ( context -> seen_enough ) break ; cursor -> offset ++ ; } trace_xfs_attr_list_leaf_end ( context ) ; return retval ; } "," ; if ( ! retval ) retval = context ",torvalds@linux/2e83b79b2d6c78bf1b4aa227938a214dcbddc83f,CVE-2016-9685,https://github.com/torvalds/linux/commit/2e83b79b2d6c78bf1b4aa227938a214dcbddc83f,2016-12-28T07:59Z 370,CWE-401,"CWE-401 int cx23888_ir_probe ( struct cx23885_dev * dev ) { struct cx23888_ir_state * state ; struct v4l2_subdev * sd ; struct v4l2_subdev_ir_parameters default_params ; int ret ; state = kzalloc ( sizeof ( struct cx23888_ir_state ) , GFP_KERNEL ) ; if ( state == NULL ) return - ENOMEM ; spin_lock_init ( & state -> rx_kfifo_lock ) ; if ( kfifo_alloc ( & state -> rx_kfifo , CX23888_IR_RX_KFIFO_SIZE , GFP_KERNEL ) ) return - ENOMEM ; state -> dev = dev ; sd = & state -> sd ; v4l2_subdev_init ( sd , & cx23888_ir_controller_ops ) ; v4l2_set_subdevdata ( sd , state ) ; snprintf ( sd -> name , sizeof ( sd -> name ) , ""%s/888-ir"" , dev -> name ) ; sd -> grp_id = CX23885_HW_888_IR ; ret = v4l2_device_register_subdev ( & dev -> v4l2_dev , sd ) ; if ( ret == 0 ) { cx23888_ir_write4 ( dev , CX23888_IR_IRQEN_REG , 0 ) ; mutex_init ( & state -> rx_params_lock ) ; default_params = default_rx_params ; v4l2_subdev_call ( sd , ir , rx_s_parameters , & default_params ) ; mutex_init ( & state -> tx_params_lock ) ; default_params = default_tx_params ; v4l2_subdev_call ( sd , ir , tx_s_parameters , & default_params ) ; } else { kfifo_free ( & state -> rx_kfifo ) ; } return ret ; } "," GFP_KERNEL ) ) { kfree ( state ) ; - ENOMEM ; } ",torvalds@linux/a7b2df76b42bdd026e3106cf2ba97db41345a177,CVE-2019-19054,https://github.com/torvalds/linux/commit/a7b2df76b42bdd026e3106cf2ba97db41345a177,2019-11-18T06:15Z 371,CWE-476,"CWE-476 int nfc_llcp_send_connect ( struct nfc_llcp_sock * sock ) { struct nfc_llcp_local * local ; struct sk_buff * skb ; u8 * service_name_tlv = NULL , service_name_tlv_length ; u8 * miux_tlv = NULL , miux_tlv_length ; u8 * rw_tlv = NULL , rw_tlv_length , rw ; int err ; u16 size = 0 ; __be16 miux ; pr_debug ( ""SendingCONNECT\\n"" ) ; local = sock -> local ; if ( local == NULL ) return - ENODEV ; if ( sock -> service_name != NULL ) { service_name_tlv = nfc_llcp_build_tlv ( LLCP_TLV_SN , sock -> service_name , sock -> service_name_len , & service_name_tlv_length ) ; size += service_name_tlv_length ; } miux = be16_to_cpu ( sock -> miux ) > LLCP_MAX_MIUX ? local -> miux : sock -> miux ; rw = sock -> rw > LLCP_MAX_RW ? local -> rw : sock -> rw ; miux_tlv = nfc_llcp_build_tlv ( LLCP_TLV_MIUX , ( u8 * ) & miux , 0 , & miux_tlv_length ) ; size += miux_tlv_length ; rw_tlv = nfc_llcp_build_tlv ( LLCP_TLV_RW , & rw , 0 , & rw_tlv_length ) ; size += rw_tlv_length ; pr_debug ( ""SKBsize%dSNlength%zu\\n"" , size , sock -> service_name_len ) ; skb = llcp_allocate_pdu ( sock , LLCP_PDU_CONNECT , size ) ; if ( skb == NULL ) { err = - ENOMEM ; goto error_tlv ; } llcp_add_tlv ( skb , service_name_tlv , service_name_tlv_length ) ; llcp_add_tlv ( skb , miux_tlv , miux_tlv_length ) ; llcp_add_tlv ( skb , rw_tlv , rw_tlv_length ) ; skb_queue_tail ( & local -> tx_queue , skb ) ; err = 0 ; error_tlv : if ( err ) pr_err ( ""error%d\\n"" , err ) ; kfree ( service_name_tlv ) ; kfree ( miux_tlv ) ; kfree ( rw_tlv ) ; return err ; } "," service_name_tlv_length ) ; if ( ! service_name_tlv ) { err = - ENOMEM ; goto error_tlv ; } miux_tlv_length ) ; if ( ! miux_tlv ) { err = - ENOMEM ; goto error_tlv ; } rw_tlv_length ) ; if ( ! rw_tlv ) { err = - ENOMEM ; goto error_tlv ; } ",torvalds@linux/58bdd544e2933a21a51eecf17c3f5f94038261b5,CVE-2019-12818,https://github.com/torvalds/linux/commit/58bdd544e2933a21a51eecf17c3f5f94038261b5,2019-06-14T02:29Z 372,CWE-119,"CWE-119 struct monitor * monitor_init ( void ) { struct ssh * ssh = active_state ; struct monitor * mon ; mon = xcalloc ( 1 , sizeof ( * mon ) ) ; monitor_openfds ( mon , 1 ) ; if ( options . compression ) { mon -> m_zback = mm_create ( NULL , MM_MEMSIZE ) ; mon -> m_zlib = mm_create ( mon -> m_zback , 20 * MM_MEMSIZE ) ; ssh_packet_set_compress_hooks ( ssh , mon -> m_zlib , ( ssh_packet_comp_alloc_func * ) mm_zalloc , ( ssh_packet_comp_free_func * ) mm_zfree ) ; } return mon ; } "," void ) { struct monitor * 1 ) ; return mon ; ",openbsd@src/3095060f479b86288e31c79ecbc5131a66bcd2f9,CVE-2016-10012,https://github.com/openbsd/src/commit/3095060f479b86288e31c79ecbc5131a66bcd2f9,2017-01-05T02:59Z 373,CWE-119,"CWE-119 vpx_codec_err_t vpx_codec_dec_init_ver ( vpx_codec_ctx_t * ctx , vpx_codec_iface_t * iface , vpx_codec_dec_cfg_t * cfg , vpx_codec_flags_t flags , int ver ) { vpx_codec_err_t res ; if ( ver != VPX_DECODER_ABI_VERSION ) res = VPX_CODEC_ABI_MISMATCH ; else if ( ! ctx || ! iface ) res = VPX_CODEC_INVALID_PARAM ; else if ( iface -> abi_version != VPX_CODEC_INTERNAL_ABI_VERSION ) res = VPX_CODEC_ABI_MISMATCH ; else if ( ( flags & VPX_CODEC_USE_XMA ) && ! ( iface -> caps & VPX_CODEC_CAP_XMA ) ) res = VPX_CODEC_INCAPABLE ; else if ( ( flags & VPX_CODEC_USE_POSTPROC ) && ! ( iface -> caps & VPX_CODEC_CAP_POSTPROC ) ) res = VPX_CODEC_INCAPABLE ; else if ( ( flags & VPX_CODEC_USE_ERROR_CONCEALMENT ) && ! ( iface -> caps & VPX_CODEC_CAP_ERROR_CONCEALMENT ) ) res = VPX_CODEC_INCAPABLE ; else if ( ( flags & VPX_CODEC_USE_INPUT_FRAGMENTS ) && ! ( iface -> caps & VPX_CODEC_CAP_INPUT_FRAGMENTS ) ) res = VPX_CODEC_INCAPABLE ; else if ( ! ( iface -> caps & VPX_CODEC_CAP_DECODER ) ) res = VPX_CODEC_INCAPABLE ; else { memset ( ctx , 0 , sizeof ( * ctx ) ) ; ctx -> iface = iface ; ctx -> name = iface -> name ; ctx -> priv = NULL ; ctx -> init_flags = flags ; ctx -> config . dec = cfg ; res = VPX_CODEC_OK ; if ( ! ( flags & VPX_CODEC_USE_XMA ) ) { res = ctx -> iface -> init ( ctx , NULL ) ; if ( res ) { ctx -> err_detail = ctx -> priv ? ctx -> priv -> err_detail : NULL ; vpx_codec_destroy ( ctx ) ; } if ( ctx -> priv ) ctx -> priv -> iface = ctx -> iface ; } } return SAVE_STATUS ( ctx , res ) ; } "," * iface , const ( flags & VPX_CODEC_USE_POSTPROC ) && ; res = ctx -> iface ) ; } } return SAVE_STATUS ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 374,CWE-476,"CWE-476 static int jp2_cdef_getdata ( jp2_box_t * box , jas_stream_t * in ) { jp2_cdef_t * cdef = & box -> data . cdef ; jp2_cdefchan_t * chan ; unsigned int channo ; if ( jp2_getuint16 ( in , & cdef -> numchans ) ) { return - 1 ; } if ( ! ( cdef -> ents = jas_alloc2 ( cdef -> numchans , sizeof ( jp2_cdefchan_t ) ) ) ) { return - 1 ; } for ( channo = 0 ; channo < cdef -> numchans ; ++ channo ) { chan = & cdef -> ents [ channo ] ; if ( jp2_getuint16 ( in , & chan -> channo ) || jp2_getuint16 ( in , & chan -> type ) || jp2_getuint16 ( in , & chan -> assoc ) ) { return - 1 ; } } return 0 ; } "," unsigned int channo ; cdef -> ents = 0 ",mdadams@jasper/e96fc4fdd525fa0ede28074a7e2b1caf94b58b0d,CVE-2017-6850,https://github.com/mdadams/jasper/commit/e96fc4fdd525fa0ede28074a7e2b1caf94b58b0d,2017-03-15T14:59Z 375,CWE-20,"CWE-20 error_t tja1100Init ( NetInterface * interface ) { uint16_t value ; TRACE_INFO ( ""InitializingTJA1100...\\r\\n"" ) ; if ( interface -> phyAddr >= 32 ) { interface -> phyAddr = TJA1100_PHY_ADDR ; } if ( interface -> smiDriver != NULL ) { interface -> smiDriver -> init ( ) ; } if ( interface -> extIntDriver != NULL ) { interface -> extIntDriver -> init ( ) ; } tja1100WritePhyReg ( interface , TJA1100_BASIC_CTRL , TJA1100_BASIC_CTRL_RESET ) ; while ( tja1100ReadPhyReg ( interface , TJA1100_BASIC_CTRL ) & TJA1100_BASIC_CTRL_RESET ) { } tja1100DumpPhyReg ( interface ) ; value = tja1100ReadPhyReg ( interface , TJA1100_EXTENDED_CTRL ) ; value |= TJA1100_EXTENDED_CTRL_CONFIG_EN ; tja1100WritePhyReg ( interface , TJA1100_EXTENDED_CTRL , value ) ; value = tja1100ReadPhyReg ( interface , TJA1100_CONFIG1 ) ; value &= ~ TJA1100_CONFIG1_MII_MODE ; value |= TJA1100_CONFIG1_MII_MODE_RMII_25MHZ ; tja1100WritePhyReg ( interface , TJA1100_CONFIG1 , value ) ; value = tja1100ReadPhyReg ( interface , TJA1100_CONFIG1 ) ; value |= TJA1100_CONFIG1_AUTO_OP ; tja1100WritePhyReg ( interface , TJA1100_CONFIG1 , value ) ; interface -> phyEvent = TRUE ; osSetEvent ( & netEvent ) ; return NO_ERROR ; } "," ; value |= TJA1100_CONFIG1_MII_MODE_RMII_25MHZ_XTAL ; tja1100WritePhyReg ( ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 376,CWE-362,"CWE-362 void icmp_send ( struct sk_buff * skb_in , int type , int code , __be32 info ) { struct iphdr * iph ; int room ; struct icmp_bxm icmp_param ; struct rtable * rt = skb_rtable ( skb_in ) ; struct ipcm_cookie ipc ; __be32 saddr ; u8 tos ; struct net * net ; struct sock * sk ; if ( ! rt ) goto out ; net = dev_net ( rt -> dst . dev ) ; iph = ip_hdr ( skb_in ) ; if ( ( u8 * ) iph < skb_in -> head || ( skb_in -> network_header + sizeof ( * iph ) ) > skb_in -> tail ) goto out ; if ( skb_in -> pkt_type != PACKET_HOST ) goto out ; if ( rt -> rt_flags & ( RTCF_BROADCAST | RTCF_MULTICAST ) ) goto out ; if ( iph -> frag_off & htons ( IP_OFFSET ) ) goto out ; if ( icmp_pointers [ type ] . error ) { if ( iph -> protocol == IPPROTO_ICMP ) { u8 _inner_type , * itp ; itp = skb_header_pointer ( skb_in , skb_network_header ( skb_in ) + ( iph -> ihl << 2 ) + offsetof ( struct icmphdr , type ) - skb_in -> data , sizeof ( _inner_type ) , & _inner_type ) ; if ( itp == NULL ) goto out ; if ( * itp > NR_ICMP_TYPES || icmp_pointers [ * itp ] . error ) goto out ; } } sk = icmp_xmit_lock ( net ) ; if ( sk == NULL ) return ; saddr = iph -> daddr ; if ( ! ( rt -> rt_flags & RTCF_LOCAL ) ) { struct net_device * dev = NULL ; rcu_read_lock ( ) ; if ( rt_is_input_route ( rt ) && net -> ipv4 . sysctl_icmp_errors_use_inbound_ifaddr ) dev = dev_get_by_index_rcu ( net , rt -> rt_iif ) ; if ( dev ) saddr = inet_select_addr ( dev , 0 , RT_SCOPE_LINK ) ; else saddr = 0 ; rcu_read_unlock ( ) ; } tos = icmp_pointers [ type ] . error ? ( ( iph -> tos & IPTOS_TOS_MASK ) | IPTOS_PREC_INTERNETCONTROL ) : iph -> tos ; if ( ip_options_echo ( & icmp_param . replyopts , skb_in ) ) goto out_unlock ; icmp_param . data . icmph . type = type ; icmp_param . data . icmph . code = code ; icmp_param . data . icmph . un . gateway = info ; icmp_param . data . icmph . checksum = 0 ; icmp_param . skb = skb_in ; icmp_param . offset = skb_network_offset ( skb_in ) ; inet_sk ( sk ) -> tos = tos ; ipc . addr = iph -> saddr ; ipc . opt = & icmp_param . replyopts ; ipc . tx_flags = 0 ; rt = icmp_route_lookup ( net , skb_in , iph , saddr , tos , type , code , & icmp_param ) ; if ( IS_ERR ( rt ) ) goto out_unlock ; if ( ! icmpv4_xrlim_allow ( net , rt , type , code ) ) goto ende ; room = dst_mtu ( & rt -> dst ) ; if ( room > 576 ) room = 576 ; room -= sizeof ( struct iphdr ) + icmp_param . replyopts . optlen ; room -= sizeof ( struct icmphdr ) ; icmp_param . data_len = skb_in -> len - icmp_param . offset ; if ( icmp_param . data_len > room ) icmp_param . data_len = room ; icmp_param . head_len = sizeof ( struct icmphdr ) ; icmp_push_reply ( & icmp_param , & ipc , & rt ) ; ende : ip_rt_put ( rt ) ; out_unlock : icmp_xmit_unlock ( sk ) ; out : ; } "," icmp_param . replyopts . opt . opt icmp_param . replyopts . opt . replyopts . opt . opt . ",torvalds@linux/f6d8bd051c391c1c0458a30b2a7abcd939329259,CVE-2012-3552,https://github.com/torvalds/linux/commit/f6d8bd051c391c1c0458a30b2a7abcd939329259,2012-10-03T11:02Z 377,CWE-125,"CWE-125 static int print_bacp_config_options ( netdissect_options * ndo , const u_char * p , int length ) { int len , opt ; if ( length < 2 ) return 0 ; ND_TCHECK2 ( * p , 2 ) ; len = p [ 1 ] ; opt = p [ 0 ] ; if ( length < len ) return 0 ; if ( len < 2 ) { ND_PRINT ( ( ndo , ""\\n\\t%sOption(0x%02x),length%u(lengthbogus,shouldbe>=2)"" , tok2str ( bacconfopts_values , ""Unknown"" , opt ) , opt , len ) ) ; return 0 ; } ND_PRINT ( ( ndo , ""\\n\\t%sOption(0x%02x),length%u"" , tok2str ( bacconfopts_values , ""Unknown"" , opt ) , opt , len ) ) ; switch ( opt ) { case BACPOPT_FPEER : if ( len != 6 ) { ND_PRINT ( ( ndo , ""(lengthbogus,shouldbe=6)"" ) ) ; return len ; } ND_TCHECK2 ( * ( p + 2 ) , 4 ) ; ND_PRINT ( ( ndo , "":Magic-Num0x%08x"" , EXTRACT_32BITS ( p + 2 ) ) ) ; break ; default : if ( ndo -> ndo_vflag < 2 ) print_unknown_data ( ndo , & p [ 2 ] , ""\\n\\t"" , len - 2 ) ; break ; } if ( ndo -> ndo_vflag > 1 ) print_unknown_data ( ndo , & p [ 2 ] , ""\\n\\t"" , len - 2 ) ; return len ; trunc : ND_PRINT ( ( ndo , ""[|bacp]"" ) ) ; return 0 ; } "," len ; } ND_TCHECK_32BITS ( p + p + 2 ) ; ND_PRINT ",the-tcpdump-group@tcpdump/7029d15f148ef24bb7c6668bc640f5470d085e5a,CVE-2017-13029,https://github.com/the-tcpdump-group/tcpdump/commit/7029d15f148ef24bb7c6668bc640f5470d085e5a,2017-09-14T06:29Z 378,CWE-476,"CWE-476 void ipv4_pktinfo_prepare ( const struct sock * sk , struct sk_buff * skb ) { struct in_pktinfo * pktinfo = PKTINFO_SKB_CB ( skb ) ; bool prepare = ( inet_sk ( sk ) -> cmsg_flags & IP_CMSG_PKTINFO ) || ipv6_sk_rxinfo ( sk ) ; if ( prepare && skb_rtable ( skb ) ) { if ( pktinfo -> ipi_ifindex == LOOPBACK_IFINDEX ) pktinfo -> ipi_ifindex = inet_iif ( skb ) ; pktinfo -> ipi_spec_dst . s_addr = fib_compute_spec_dst ( skb ) ; } else { pktinfo -> ipi_ifindex = 0 ; pktinfo -> ipi_spec_dst . s_addr = 0 ; } skb_dst_drop ( skb ) ; } "," 0 ; } if ( unlikely ( IPCB ( skb ) -> opt . optlen ) ) skb_dst_force ( skb ) ; else ",torvalds@linux/34b2cef20f19c87999fff3da4071e66937db9644,CVE-2017-5970,https://github.com/torvalds/linux/commit/34b2cef20f19c87999fff3da4071e66937db9644,2017-02-14T06:59Z 379,CWE-476,"CWE-476 static void skcipher_release ( void * private ) { crypto_free_skcipher ( private ) ; } "," private ) { struct skcipher_tfm * tfm = private ; crypto_free_skcipher ( tfm -> skcipher ) ; kfree ( tfm ) ; } ",torvalds@linux/dd504589577d8e8e70f51f997ad487a4cb6c026f,CVE-2015-8970,https://github.com/torvalds/linux/commit/dd504589577d8e8e70f51f997ad487a4cb6c026f,2016-11-28T03:59Z 380,CWE-362,"CWE-362 int prepare_binprm ( struct linux_binprm * bprm ) { struct inode * inode = file_inode ( bprm -> file ) ; umode_t mode = inode -> i_mode ; int retval ; bprm -> cred -> euid = current_euid ( ) ; bprm -> cred -> egid = current_egid ( ) ; if ( ! ( bprm -> file -> f_path . mnt -> mnt_flags & MNT_NOSUID ) && ! task_no_new_privs ( current ) && kuid_has_mapping ( bprm -> cred -> user_ns , inode -> i_uid ) && kgid_has_mapping ( bprm -> cred -> user_ns , inode -> i_gid ) ) { if ( mode & S_ISUID ) { bprm -> per_clear |= PER_CLEAR_ON_SETID ; bprm -> cred -> euid = inode -> i_uid ; } if ( ( mode & ( S_ISGID | S_IXGRP ) ) == ( S_ISGID | S_IXGRP ) ) { bprm -> per_clear |= PER_CLEAR_ON_SETID ; bprm -> cred -> egid = inode -> i_gid ; } } retval = security_bprm_set_creds ( bprm ) ; if ( retval ) return retval ; bprm -> cred_prepared = 1 ; memset ( bprm -> buf , 0 , BINPRM_BUF_SIZE ) ; return kernel_read ( bprm -> file , 0 , bprm -> buf , BINPRM_BUF_SIZE ) ; } "," bprm ) { int retval ; int retval ; bprm_fill_uid ( bprm ) ; retval = security_bprm_set_creds ",torvalds@linux/8b01fc86b9f425899f8a3a8fc1c47d73c2c20543,CVE-2015-3339,https://github.com/torvalds/linux/commit/8b01fc86b9f425899f8a3a8fc1c47d73c2c20543,2015-05-27T10:59Z 381,CWE-20,"CWE-20 static int get_rx_bufs ( struct vhost_virtqueue * vq , struct vring_used_elem * heads , int datalen , unsigned * iovcount , struct vhost_log * log , unsigned * log_num , unsigned int quota ) { unsigned int out , in ; int seg = 0 ; int headcount = 0 ; unsigned d ; int r , nlogs = 0 ; while ( datalen > 0 && headcount < quota ) { if ( unlikely ( seg >= UIO_MAXIOV ) ) { r = - ENOBUFS ; goto err ; } d = vhost_get_vq_desc ( vq -> dev , vq , vq -> iov + seg , ARRAY_SIZE ( vq -> iov ) - seg , & out , & in , log , log_num ) ; if ( d == vq -> num ) { r = 0 ; goto err ; } if ( unlikely ( out || in <= 0 ) ) { vq_err ( vq , ""unexpecteddescriptorformatforRX:"" ""out%d,in%d\\n"" , out , in ) ; r = - EINVAL ; goto err ; } if ( unlikely ( log ) ) { nlogs += * log_num ; log += * log_num ; } heads [ headcount ] . id = d ; heads [ headcount ] . len = iov_length ( vq -> iov + seg , in ) ; datalen -= heads [ headcount ] . len ; ++ headcount ; seg += in ; } heads [ headcount - 1 ] . len += datalen ; * iovcount = seg ; if ( unlikely ( log ) ) * log_num = nlogs ; return headcount ; err : vhost_discard_vq_desc ( vq , headcount ) ; return r ; } "," = nlogs ; if ( unlikely ( datalen > 0 ) ) { r = UIO_MAXIOV + 1 ; goto err ; } ",torvalds@linux/d8316f3991d207fe32881a9ac20241be8fa2bad0,CVE-2014-0077,https://github.com/torvalds/linux/commit/d8316f3991d207fe32881a9ac20241be8fa2bad0,2014-04-14T23:55Z 382,CWE-191,"CWE-191 void imap_quote_string ( char * dest , size_t dlen , const char * src , bool quote_backtick ) { const char * quote = ""`\\""\\\\"" ; if ( ! quote_backtick ) quote ++ ; char * pt = dest ; const char * s = src ; * pt ++ = \'""\' ; dlen -= 2 ; for ( ; * s && dlen ; s ++ ) { if ( strchr ( quote , * s ) ) { dlen -= 2 ; if ( dlen == 0 ) break ; * pt ++ = '\\\\' ; * pt ++ = * s ; } else { * pt ++ = * s ; dlen -- ; } } * pt ++ = \'""\' ; * pt = '\\0' ; } "," ) ) { if ( dlen < 2 ) break ; dlen -= 2 ; * pt ",neomutt@neomutt/65d64a5b60a4a3883f2cd799d92c6091d8854f23,CVE-2018-14353,https://github.com/neomutt/neomutt/commit/65d64a5b60a4a3883f2cd799d92c6091d8854f23,2018-07-17T17:29Z 383,CWE-362,"CWE-362 static void bt_tags_for_each ( struct blk_mq_tags * tags , struct blk_mq_bitmap_tags * bt , unsigned int off , busy_tag_iter_fn * fn , void * data , bool reserved ) { struct request * rq ; int bit , i ; if ( ! tags -> rqs ) return ; for ( i = 0 ; i < bt -> map_nr ; i ++ ) { struct blk_align_bitmap * bm = & bt -> map [ i ] ; for ( bit = find_first_bit ( & bm -> word , bm -> depth ) ; bit < bm -> depth ; bit = find_next_bit ( & bm -> word , bm -> depth , bit + 1 ) ) { rq = blk_mq_tag_to_rq ( tags , off + bit ) ; fn ( rq , data , reserved ) ; } off += ( 1 << bt -> bits_per_word ) ; } } "," { rq = tags -> rqs [ off + bit off + bit ] ; fn ( ",torvalds@linux/0048b4837affd153897ed1222283492070027aa9,CVE-2015-9016,https://github.com/torvalds/linux/commit/0048b4837affd153897ed1222283492070027aa9,2018-04-05T18:29Z 384,CWE-119,"CWE-119 vpx_codec_err_t vpx_codec_enc_init_multi_ver ( vpx_codec_ctx_t * ctx , vpx_codec_iface_t * iface , vpx_codec_enc_cfg_t * cfg , int num_enc , vpx_codec_flags_t flags , vpx_rational_t * dsf , int ver ) { vpx_codec_err_t res = VPX_CODEC_OK ; if ( ver != VPX_ENCODER_ABI_VERSION ) res = VPX_CODEC_ABI_MISMATCH ; else if ( ! ctx || ! iface || ! cfg || ( num_enc > 16 || num_enc < 1 ) ) res = VPX_CODEC_INVALID_PARAM ; else if ( iface -> abi_version != VPX_CODEC_INTERNAL_ABI_VERSION ) res = VPX_CODEC_ABI_MISMATCH ; else if ( ! ( iface -> caps & VPX_CODEC_CAP_ENCODER ) ) res = VPX_CODEC_INCAPABLE ; else if ( ( flags & VPX_CODEC_USE_XMA ) && ! ( iface -> caps & VPX_CODEC_CAP_XMA ) ) res = VPX_CODEC_INCAPABLE ; else if ( ( flags & VPX_CODEC_USE_PSNR ) && ! ( iface -> caps & VPX_CODEC_CAP_PSNR ) ) res = VPX_CODEC_INCAPABLE ; else if ( ( flags & VPX_CODEC_USE_OUTPUT_PARTITION ) && ! ( iface -> caps & VPX_CODEC_CAP_OUTPUT_PARTITION ) ) res = VPX_CODEC_INCAPABLE ; else { int i ; void * mem_loc = NULL ; if ( ! ( res = iface -> enc . mr_get_mem_loc ( cfg , & mem_loc ) ) ) { for ( i = 0 ; i < num_enc ; i ++ ) { vpx_codec_priv_enc_mr_cfg_t mr_cfg ; if ( dsf -> num < 1 || dsf -> num > 4096 || dsf -> den < 1 || dsf -> den > dsf -> num ) { res = VPX_CODEC_INVALID_PARAM ; break ; } mr_cfg . mr_low_res_mode_info = mem_loc ; mr_cfg . mr_total_resolutions = num_enc ; mr_cfg . mr_encoder_id = num_enc - 1 - i ; mr_cfg . mr_down_sampling_factor . num = dsf -> num ; mr_cfg . mr_down_sampling_factor . den = dsf -> den ; if ( mr_cfg . mr_encoder_id ) cfg -> kf_mode = VPX_KF_DISABLED ; ctx -> iface = iface ; ctx -> name = iface -> name ; ctx -> priv = NULL ; ctx -> init_flags = flags ; ctx -> config . enc = cfg ; res = ctx -> iface -> init ( ctx , & mr_cfg ) ; if ( res ) { const char * error_detail = ctx -> priv ? ctx -> priv -> err_detail : NULL ; ctx -> err_detail = error_detail ; vpx_codec_destroy ( ctx ) ; while ( i ) { ctx -- ; ctx -> err_detail = error_detail ; vpx_codec_destroy ( ctx ) ; i -- ; } } if ( ctx -> priv ) ctx -> priv -> iface = ctx -> iface ; if ( res ) break ; ctx ++ ; cfg ++ ; dsf ++ ; } ctx -- ; } } return SAVE_STATUS ( ctx , res ) ; } "," ( flags & VPX_CODEC_USE_PSNR ) && } if ( res ) break ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 385,CWE-20,"CWE-20 static int vmci_transport_dgram_dequeue ( struct kiocb * kiocb , struct vsock_sock * vsk , struct msghdr * msg , size_t len , int flags ) { int err ; int noblock ; struct vmci_datagram * dg ; size_t payload_len ; struct sk_buff * skb ; noblock = flags & MSG_DONTWAIT ; if ( flags & MSG_OOB || flags & MSG_ERRQUEUE ) return - EOPNOTSUPP ; msg -> msg_namelen = 0 ; err = 0 ; skb = skb_recv_datagram ( & vsk -> sk , flags , noblock , & err ) ; if ( err ) return err ; if ( ! skb ) return - EAGAIN ; dg = ( struct vmci_datagram * ) skb -> data ; if ( ! dg ) goto out ; payload_len = dg -> payload_size ; if ( payload_len != skb -> len - sizeof ( * dg ) ) { err = - EINVAL ; goto out ; } if ( payload_len > len ) { payload_len = len ; msg -> msg_flags |= MSG_TRUNC ; } err = skb_copy_datagram_iovec ( skb , sizeof ( * dg ) , msg -> msg_iov , payload_len ) ; if ( err ) goto out ; if ( msg -> msg_name ) { struct sockaddr_vm * vm_addr ; vm_addr = ( struct sockaddr_vm * ) msg -> msg_name ; vsock_addr_init ( vm_addr , dg -> src . context , dg -> src . resource ) ; msg -> msg_namelen = sizeof ( * vm_addr ) ; } err = payload_len ; out : skb_free_datagram ( & vsk -> sk , skb ) ; return err ; } "," - EOPNOTSUPP ; err = 0 ",torvalds@linux/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,CVE-2013-7271,https://github.com/torvalds/linux/commit/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,2014-01-06T16:55Z 386,CWE-189,"CWE-189 static u64 __skb_get_nlattr ( u64 ctx , u64 A , u64 X , u64 r4 , u64 r5 ) { struct sk_buff * skb = ( struct sk_buff * ) ( long ) ctx ; struct nlattr * nla ; if ( skb_is_nonlinear ( skb ) ) return 0 ; if ( A > skb -> len - sizeof ( struct nlattr ) ) return 0 ; nla = nla_find ( ( struct nlattr * ) & skb -> data [ A ] , skb -> len - A , X ) ; if ( nla ) return ( void * ) nla - ( void * ) skb -> data ; return 0 ; } "," skb_is_nonlinear ( skb ) ) return 0 ; if ( skb -> len < sizeof ( struct nlattr ",torvalds@linux/05ab8f2647e4221cbdb3856dd7d32bd5407316b3,CVE-2014-3145,https://github.com/torvalds/linux/commit/05ab8f2647e4221cbdb3856dd7d32bd5407316b3,2014-05-11T21:55Z 387,CWE-000,"CWE-000 static inline void encode_openhdr ( struct xdr_stream * xdr , const struct nfs_openargs * arg ) { __be32 * p ; RESERVE_SPACE ( 8 ) ; WRITE32 ( OP_OPEN ) ; WRITE32 ( arg -> seqid -> sequence -> counter ) ; encode_share_access ( xdr , arg -> open_flags ) ; RESERVE_SPACE ( 28 ) ; WRITE64 ( arg -> clientid ) ; WRITE32 ( 16 ) ; WRITEMEM ( ""openid:"" , 8 ) ; WRITE64 ( arg -> id ) ; } "," , arg -> fmode ) ; RESERVE_SPACE ",torvalds@linux/dc0b027dfadfcb8a5504f7d8052754bf8d501ab9,CVE-2011-4324,https://github.com/torvalds/linux/commit/dc0b027dfadfcb8a5504f7d8052754bf8d501ab9,2012-06-21T23:55Z 388,CWE-125,"CWE-125 static void gre_print_0 ( netdissect_options * ndo , const u_char * bp , u_int length ) { u_int len = length ; uint16_t flags , prot ; flags = EXTRACT_16BITS ( bp ) ; if ( ndo -> ndo_vflag ) ND_PRINT ( ( ndo , "",Flags[%s]"" , bittok2str ( gre_flag_values , ""none"" , flags ) ) ) ; len -= 2 ; bp += 2 ; ND_TCHECK2 ( * bp , 2 ) ; if ( len < 2 ) goto trunc ; prot = EXTRACT_16BITS ( bp ) ; len -= 2 ; bp += 2 ; if ( ( flags & GRE_CP ) | ( flags & GRE_RP ) ) { ND_TCHECK2 ( * bp , 2 ) ; if ( len < 2 ) goto trunc ; if ( ndo -> ndo_vflag ) ND_PRINT ( ( ndo , "",sum0x%x"" , EXTRACT_16BITS ( bp ) ) ) ; bp += 2 ; len -= 2 ; ND_TCHECK2 ( * bp , 2 ) ; if ( len < 2 ) goto trunc ; ND_PRINT ( ( ndo , "",off0x%x"" , EXTRACT_16BITS ( bp ) ) ) ; bp += 2 ; len -= 2 ; } if ( flags & GRE_KP ) { ND_TCHECK2 ( * bp , 4 ) ; if ( len < 4 ) goto trunc ; ND_PRINT ( ( ndo , "",key=0x%x"" , EXTRACT_32BITS ( bp ) ) ) ; bp += 4 ; len -= 4 ; } if ( flags & GRE_SP ) { ND_TCHECK2 ( * bp , 4 ) ; if ( len < 4 ) goto trunc ; ND_PRINT ( ( ndo , "",seq%u"" , EXTRACT_32BITS ( bp ) ) ) ; bp += 4 ; len -= 4 ; } if ( flags & GRE_RP ) { for ( ; ; ) { uint16_t af ; uint8_t sreoff ; uint8_t srelen ; ND_TCHECK2 ( * bp , 4 ) ; if ( len < 4 ) goto trunc ; af = EXTRACT_16BITS ( bp ) ; sreoff = * ( bp + 2 ) ; srelen = * ( bp + 3 ) ; bp += 4 ; len -= 4 ; if ( af == 0 && srelen == 0 ) break ; if ( ! gre_sre_print ( ndo , af , sreoff , srelen , bp , len ) ) goto trunc ; if ( len < srelen ) goto trunc ; bp += srelen ; len -= srelen ; } } if ( ndo -> ndo_eflag ) ND_PRINT ( ( ndo , "",proto%s(0x%04x)"" , tok2str ( ethertype_values , ""unknown"" , prot ) , prot ) ) ; ND_PRINT ( ( ndo , "",length%u"" , length ) ) ; if ( ndo -> ndo_vflag < 1 ) ND_PRINT ( ( ndo , "":"" ) ) ; else ND_PRINT ( ( ndo , ""\\n\\t"" ) ) ; switch ( prot ) { case ETHERTYPE_IP : ip_print ( ndo , bp , len ) ; break ; case ETHERTYPE_IPV6 : ip6_print ( ndo , bp , len ) ; break ; case ETHERTYPE_MPLS : mpls_print ( ndo , bp , len ) ; break ; case ETHERTYPE_IPX : ipx_print ( ndo , bp , len ) ; break ; case ETHERTYPE_ATALK : atalk_print ( ndo , bp , len ) ; break ; case ETHERTYPE_GRE_ISO : isoclns_print ( ndo , bp , len , ndo -> ndo_snapend - bp ) ; break ; case ETHERTYPE_TEB : ether_print ( ndo , bp , len , ndo -> ndo_snapend - bp , NULL , NULL ) ; break ; default : ND_PRINT ( ( ndo , ""gre-proto-0x%x"" , prot ) ) ; } return ; trunc : ND_PRINT ( ( ndo , ""%s"" , tstr ) ) ; } "," bp , len ) ; break ; case ETHERTYPE_TEB : ether_print ( ndo , bp , len ndo_snapend - bp , NULL , ",the-tcpdump-group@tcpdump/1dcd10aceabbc03bf571ea32b892c522cbe923de,CVE-2017-12897,https://github.com/the-tcpdump-group/tcpdump/commit/1dcd10aceabbc03bf571ea32b892c522cbe923de,2017-09-14T06:29Z 389,CWE-119,"CWE-119 static int readContigTilesIntoBuffer ( TIFF * in , uint8 * buf , uint32 imagelength , uint32 imagewidth , uint32 tw , uint32 tl , tsample_t spp , uint16 bps ) { int status = 1 ; tsample_t sample = 0 ; tsample_t count = spp ; uint32 row , col , trow ; uint32 nrow , ncol ; uint32 dst_rowsize , shift_width ; uint32 bytes_per_sample , bytes_per_pixel ; uint32 trailing_bits , prev_trailing_bits ; uint32 tile_rowsize = TIFFTileRowSize ( in ) ; uint32 src_offset , dst_offset ; uint32 row_offset , col_offset ; uint8 * bufp = ( uint8 * ) buf ; unsigned char * src = NULL ; unsigned char * dst = NULL ; tsize_t tbytes = 0 , tile_buffsize = 0 ; tsize_t tilesize = TIFFTileSize ( in ) ; unsigned char * tilebuf = NULL ; bytes_per_sample = ( bps + 7 ) / 8 ; bytes_per_pixel = ( ( bps * spp ) + 7 ) / 8 ; if ( ( bps % 8 ) == 0 ) shift_width = 0 ; else { if ( bytes_per_pixel < ( bytes_per_sample + 1 ) ) shift_width = bytes_per_pixel ; else shift_width = bytes_per_sample + 1 ; } tile_buffsize = tilesize ; if ( tilesize == 0 || tile_rowsize == 0 ) { TIFFError ( ""readContigTilesIntoBuffer"" , ""Tilesizeortilerowsizeiszero"" ) ; exit ( - 1 ) ; } if ( tilesize < ( tsize_t ) ( tl * tile_rowsize ) ) { # ifdef DEBUG2 TIFFError ( ""readContigTilesIntoBuffer"" , ""Tilesize%luistoosmall,usingalternatecalculation%u"" , tilesize , tl * tile_rowsize ) ; # endif tile_buffsize = tl * tile_rowsize ; if ( tl != ( tile_buffsize / tile_rowsize ) ) { TIFFError ( ""readContigTilesIntoBuffer"" , ""Integeroverflowwhencalculatingbuffersize."" ) ; exit ( - 1 ) ; } } tilebuf = _TIFFmalloc ( tile_buffsize ) ; if ( tilebuf == 0 ) return 0 ; dst_rowsize = ( ( imagewidth * bps * spp ) + 7 ) / 8 ; for ( row = 0 ; row < imagelength ; row += tl ) { nrow = ( row + tl > imagelength ) ? imagelength - row : tl ; for ( col = 0 ; col < imagewidth ; col += tw ) { tbytes = TIFFReadTile ( in , tilebuf , col , row , 0 , 0 ) ; if ( tbytes < tilesize && ! ignore ) { TIFFError ( TIFFFileName ( in ) , ""Error,can\'treadtileatrow%lucol%lu,Read%lubytesof%lu"" , ( unsigned long ) col , ( unsigned long ) row , ( unsigned long ) tbytes , ( unsigned long ) tilesize ) ; status = 0 ; _TIFFfree ( tilebuf ) ; return status ; } row_offset = row * dst_rowsize ; col_offset = ( ( col * bps * spp ) + 7 ) / 8 ; bufp = buf + row_offset + col_offset ; if ( col + tw > imagewidth ) ncol = imagewidth - col ; else ncol = tw ; if ( ( ( bps % 8 ) == 0 ) && ( count == spp ) ) { for ( trow = 0 ; trow < nrow ; trow ++ ) { src_offset = trow * tile_rowsize ; _TIFFmemcpy ( bufp , tilebuf + src_offset , ( ncol * spp * bps ) / 8 ) ; bufp += ( imagewidth * bps * spp ) / 8 ; } } else { prev_trailing_bits = trailing_bits = 0 ; trailing_bits = ( ncol * bps * spp ) % 8 ; for ( trow = 0 ; trow < nrow ; trow ++ ) { src_offset = trow * tile_rowsize ; src = tilebuf + src_offset ; dst_offset = ( row + trow ) * dst_rowsize ; dst = buf + dst_offset + col_offset ; switch ( shift_width ) { case 0 : if ( extractContigSamplesBytes ( src , dst , ncol , sample , spp , bps , count , 0 , ncol ) ) { TIFFError ( ""readContigTilesIntoBuffer"" , ""Unabletoextractrow%dfromtile%lu"" , row , ( unsigned long ) TIFFCurrentTile ( in ) ) ; return 1 ; } break ; case 1 : if ( bps == 1 ) { if ( extractContigSamplesShifted8bits ( src , dst , ncol , sample , spp , bps , count , 0 , ncol , prev_trailing_bits ) ) { TIFFError ( ""readContigTilesIntoBuffer"" , ""Unabletoextractrow%dfromtile%lu"" , row , ( unsigned long ) TIFFCurrentTile ( in ) ) ; return 1 ; } break ; } else if ( extractContigSamplesShifted16bits ( src , dst , ncol , sample , spp , bps , count , 0 , ncol , prev_trailing_bits ) ) { TIFFError ( ""readContigTilesIntoBuffer"" , ""Unabletoextractrow%dfromtile%lu"" , row , ( unsigned long ) TIFFCurrentTile ( in ) ) ; return 1 ; } break ; case 2 : if ( extractContigSamplesShifted24bits ( src , dst , ncol , sample , spp , bps , count , 0 , ncol , prev_trailing_bits ) ) { TIFFError ( ""readContigTilesIntoBuffer"" , ""Unabletoextractrow%dfromtile%lu"" , row , ( unsigned long ) TIFFCurrentTile ( in ) ) ; return 1 ; } break ; case 3 : case 4 : case 5 : if ( extractContigSamplesShifted32bits ( src , dst , ncol , sample , spp , bps , count , 0 , ncol , prev_trailing_bits ) ) { TIFFError ( ""readContigTilesIntoBuffer"" , ""Unabletoextractrow%dfromtile%lu"" , row , ( unsigned long ) TIFFCurrentTile ( in ) ) ; return 1 ; } break ; default : TIFFError ( ""readContigTilesIntoBuffer"" , ""Unsupportedbitdepth%d"" , bps ) ; return 1 ; } } prev_trailing_bits += trailing_bits ; } } } _TIFFfree ( tilebuf ) ; return status ; } "," ; } } if ( tile_buffsize > 0xFFFFFFFFU - 3 ) { TIFFError ( ""readContigTilesIntoBuffer"" , ""Integeroverflowwhencalculatingbuffersize."" ) ; exit ( - 1 ) ; } _TIFFmalloc ( tile_buffsize + 3 0 ) return 0 ; tilebuf [ tile_buffsize ] = 0 ; tilebuf [ tile_buffsize + 1 ] = 0 ; tilebuf [ tile_buffsize + 2 ] = ",vadz@libtiff/ae9365db1b271b62b35ce018eac8799b1d5e8a53,CVE-2016-9539,https://github.com/vadz/libtiff/commit/ae9365db1b271b62b35ce018eac8799b1d5e8a53,2016-11-22T19:59Z 390,CWE-59,"CWE-59 static bool parse_cmdline ( int argc , char * * argv ) { int c ; bool reopen_log = false ; int signum ; struct utsname uname_buf ; int longindex ; int curind ; bool bad_option = false ; unsigned facility ; mode_t new_umask_val ; struct option long_options [ ] = { { ""use-file"" , required_argument , NULL , 'f' } , # if defined _WITH_VRRP_ && defined _WITH_LVS_ { ""vrrp"" , no_argument , NULL , 'P' } , { ""check"" , no_argument , NULL , 'C' } , # endif # ifdef _WITH_BFD_ { ""no_bfd"" , no_argument , NULL , 'B' } , # endif { ""all"" , no_argument , NULL , 3 } , { ""log-console"" , no_argument , NULL , 'l' } , { ""log-detail"" , no_argument , NULL , 'D' } , { ""log-facility"" , required_argument , NULL , 'S' } , { ""log-file"" , optional_argument , NULL , 'g' } , { ""flush-log-file"" , no_argument , NULL , 2 } , { ""no-syslog"" , no_argument , NULL , 'G' } , { ""umask"" , required_argument , NULL , 'u' } , # ifdef _WITH_VRRP_ { ""release-vips"" , no_argument , NULL , 'X' } , { ""dont-release-vrrp"" , no_argument , NULL , 'V' } , # endif # ifdef _WITH_LVS_ { ""dont-release-ipvs"" , no_argument , NULL , 'I' } , # endif { ""dont-respawn"" , no_argument , NULL , 'R' } , { ""dont-fork"" , no_argument , NULL , 'n' } , { ""dump-conf"" , no_argument , NULL , 'd' } , { ""pid"" , required_argument , NULL , 'p' } , # ifdef _WITH_VRRP_ { ""vrrp_pid"" , required_argument , NULL , 'r' } , # endif # ifdef _WITH_LVS_ { ""checkers_pid"" , required_argument , NULL , 'c' } , { ""address-monitoring"" , no_argument , NULL , 'a' } , # endif # ifdef _WITH_BFD_ { ""bfd_pid"" , required_argument , NULL , 'b' } , # endif # ifdef _WITH_SNMP_ { ""snmp"" , no_argument , NULL , 'x' } , { ""snmp-agent-socket"" , required_argument , NULL , 'A' } , # endif { ""core-dump"" , no_argument , NULL , 'm' } , { ""core-dump-pattern"" , optional_argument , NULL , 'M' } , # ifdef _MEM_CHECK_LOG_ { ""mem-check-log"" , no_argument , NULL , 'L' } , # endif # if HAVE_DECL_CLONE_NEWNET { ""namespace"" , required_argument , NULL , 's' } , # endif { ""config-id"" , required_argument , NULL , 'i' } , { ""signum"" , required_argument , NULL , 4 } , { ""config-test"" , optional_argument , NULL , 't' } , # ifdef _WITH_PERF_ { ""perf"" , optional_argument , NULL , 5 } , # endif # ifdef WITH_DEBUG_OPTIONS { ""debug"" , optional_argument , NULL , 6 } , # endif { ""version"" , no_argument , NULL , 'v' } , { ""help"" , no_argument , NULL , 'h' } , { NULL , 0 , NULL , 0 } } ; curind = optind ; while ( longindex = - 1 , ( c = getopt_long ( argc , argv , "":vhlndu:DRS:f:p:i:mM::g::Gt::"" # if defined _WITH_VRRP_ && defined _WITH_LVS_ ""PC"" # endif # ifdef _WITH_VRRP_ ""r:VX"" # endif # ifdef _WITH_LVS_ ""ac:I"" # endif # ifdef _WITH_BFD_ ""Bb:"" # endif # ifdef _WITH_SNMP_ ""xA:"" # endif # ifdef _MEM_CHECK_LOG_ ""L"" # endif # if HAVE_DECL_CLONE_NEWNET ""s:"" # endif , long_options , & longindex ) ) != - 1 ) { if ( longindex >= 0 && long_options [ longindex ] . has_arg == required_argument && optarg && ! optarg [ 0 ] ) { c = ':' ; optarg = NULL ; } switch ( c ) { case 'v' : fprintf ( stderr , ""%s"" , version_string ) ; # ifdef GIT_COMMIT fprintf ( stderr , "",gitcommit%s"" , GIT_COMMIT ) ; # endif fprintf ( stderr , ""\\n\\n%s\\n\\n"" , COPYRIGHT_STRING ) ; fprintf ( stderr , ""BuiltwithkernelheadersforLinux%d.%d.%d\\n"" , ( LINUX_VERSION_CODE >> 16 ) & 0xff , ( LINUX_VERSION_CODE >> 8 ) & 0xff , ( LINUX_VERSION_CODE ) & 0xff ) ; uname ( & uname_buf ) ; fprintf ( stderr , ""Runningon%s%s%s\\n\\n"" , uname_buf . sysname , uname_buf . release , uname_buf . version ) ; fprintf ( stderr , ""configureoptions:%s\\n\\n"" , KEEPALIVED_CONFIGURE_OPTIONS ) ; fprintf ( stderr , ""Configoptions:%s\\n\\n"" , CONFIGURATION_OPTIONS ) ; fprintf ( stderr , ""Systemoptions:%s\\n"" , SYSTEM_OPTIONS ) ; exit ( 0 ) ; break ; case 'h' : usage ( argv [ 0 ] ) ; exit ( 0 ) ; break ; case 'l' : __set_bit ( LOG_CONSOLE_BIT , & debug ) ; reopen_log = true ; break ; case 'n' : __set_bit ( DONT_FORK_BIT , & debug ) ; break ; case 'd' : __set_bit ( DUMP_CONF_BIT , & debug ) ; break ; # ifdef _WITH_VRRP_ case 'V' : __set_bit ( DONT_RELEASE_VRRP_BIT , & debug ) ; break ; # endif # ifdef _WITH_LVS_ case 'I' : __set_bit ( DONT_RELEASE_IPVS_BIT , & debug ) ; break ; # endif case 'D' : if ( __test_bit ( LOG_DETAIL_BIT , & debug ) ) __set_bit ( LOG_EXTRA_DETAIL_BIT , & debug ) ; else __set_bit ( LOG_DETAIL_BIT , & debug ) ; break ; case 'R' : __set_bit ( DONT_RESPAWN_BIT , & debug ) ; break ; # ifdef _WITH_VRRP_ case 'X' : __set_bit ( RELEASE_VIPS_BIT , & debug ) ; break ; # endif case 'S' : if ( ! read_unsigned ( optarg , & facility , 0 , LOG_FACILITY_MAX , false ) ) fprintf ( stderr , ""Invalidlogfacility\'%s\'\\n"" , optarg ) ; else { log_facility = LOG_FACILITY [ facility ] . facility ; reopen_log = true ; } break ; case 'g' : if ( optarg && optarg [ 0 ] ) log_file_name = optarg ; else log_file_name = ""/tmp/keepalived.log"" ; open_log_file ( log_file_name , NULL , NULL , NULL ) ; break ; case 'G' : __set_bit ( NO_SYSLOG_BIT , & debug ) ; reopen_log = true ; break ; case 'u' : new_umask_val = set_umask ( optarg ) ; if ( umask_cmdline ) umask_val = new_umask_val ; break ; case 't' : __set_bit ( CONFIG_TEST_BIT , & debug ) ; __set_bit ( DONT_RESPAWN_BIT , & debug ) ; __set_bit ( DONT_FORK_BIT , & debug ) ; __set_bit ( NO_SYSLOG_BIT , & debug ) ; if ( optarg && optarg [ 0 ] ) { int fd = open ( optarg , O_WRONLY | O_APPEND | O_CREAT , S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH ) ; if ( fd == - 1 ) { fprintf ( stderr , ""Unabletoopenconfig-testlogfile%s\\n"" , optarg ) ; exit ( EXIT_FAILURE ) ; } dup2 ( fd , STDERR_FILENO ) ; close ( fd ) ; } break ; case 'f' : conf_file = optarg ; break ; case 2 : set_flush_log_file ( ) ; break ; # if defined _WITH_VRRP_ && defined _WITH_LVS_ case 'P' : __clear_bit ( DAEMON_CHECKERS , & daemon_mode ) ; break ; case 'C' : __clear_bit ( DAEMON_VRRP , & daemon_mode ) ; break ; # endif # ifdef _WITH_BFD_ case 'B' : __clear_bit ( DAEMON_BFD , & daemon_mode ) ; break ; # endif case 'p' : main_pidfile = optarg ; break ; # ifdef _WITH_LVS_ case 'c' : checkers_pidfile = optarg ; break ; case 'a' : __set_bit ( LOG_ADDRESS_CHANGES , & debug ) ; break ; # endif # ifdef _WITH_VRRP_ case 'r' : vrrp_pidfile = optarg ; break ; # endif # ifdef _WITH_BFD_ case 'b' : bfd_pidfile = optarg ; break ; # endif # ifdef _WITH_SNMP_ case 'x' : snmp = 1 ; break ; case 'A' : snmp_socket = optarg ; break ; # endif case 'M' : set_core_dump_pattern = true ; if ( optarg && optarg [ 0 ] ) core_dump_pattern = optarg ; case 'm' : create_core_dump = true ; break ; # ifdef _MEM_CHECK_LOG_ case 'L' : __set_bit ( MEM_CHECK_LOG_BIT , & debug ) ; break ; # endif # if HAVE_DECL_CLONE_NEWNET case 's' : override_namespace = MALLOC ( strlen ( optarg ) + 1 ) ; strcpy ( override_namespace , optarg ) ; break ; # endif case 'i' : FREE_PTR ( config_id ) ; config_id = MALLOC ( strlen ( optarg ) + 1 ) ; strcpy ( config_id , optarg ) ; break ; case 4 : signum = get_signum ( optarg ) ; if ( signum == - 1 ) { fprintf ( stderr , ""Unknownsigfunc%s\\n"" , optarg ) ; exit ( 1 ) ; } printf ( ""%d\\n"" , signum ) ; exit ( 0 ) ; break ; case 3 : __set_bit ( RUN_ALL_CHILDREN , & daemon_mode ) ; # ifdef _WITH_VRRP_ __set_bit ( DAEMON_VRRP , & daemon_mode ) ; # endif # ifdef _WITH_LVS_ __set_bit ( DAEMON_CHECKERS , & daemon_mode ) ; # endif # ifdef _WITH_BFD_ __set_bit ( DAEMON_BFD , & daemon_mode ) ; # endif break ; # ifdef _WITH_PERF_ case 5 : if ( optarg && optarg [ 0 ] ) { if ( ! strcmp ( optarg , ""run"" ) ) perf_run = PERF_RUN ; else if ( ! strcmp ( optarg , ""all"" ) ) perf_run = PERF_ALL ; else if ( ! strcmp ( optarg , ""end"" ) ) perf_run = PERF_END ; else log_message ( LOG_INFO , ""Unknownperfstartpoint%s"" , optarg ) ; } else perf_run = PERF_RUN ; break ; # endif # ifdef WITH_DEBUG_OPTIONS case 6 : set_debug_options ( optarg && optarg [ 0 ] ? optarg : NULL ) ; break ; # endif case '?' : if ( optopt && argv [ curind ] [ 1 ] != '-' ) fprintf ( stderr , ""Unknownoption-%c\\n"" , optopt ) ; else fprintf ( stderr , ""Unknownoption%s\\n"" , argv [ curind ] ) ; bad_option = true ; break ; case ':' : if ( optopt && argv [ curind ] [ 1 ] != '-' ) fprintf ( stderr , ""Missingparameterforoption-%c\\n"" , optopt ) ; else fprintf ( stderr , ""Missingparameterforoption--%s\\n"" , long_options [ longindex ] . name ) ; bad_option = true ; break ; default : exit ( 1 ) ; break ; } curind = optind ; } if ( optind < argc ) { printf ( ""Unexpectedargument(s):"" ) ; while ( optind < argc ) printf ( ""%s"" , argv [ optind ++ ] ) ; printf ( ""\\n"" ) ; } if ( bad_option ) exit ( 1 ) ; return reopen_log ; } "," O_APPEND | O_CREAT | O_NOFOLLOW ",acassen@keepalived/04f2d32871bb3b11d7dc024039952f2fe2750306,CVE-2018-19044,https://github.com/acassen/keepalived/commit/04f2d32871bb3b11d7dc024039952f2fe2750306,2018-11-08T20:29Z 391,CWE-617,"CWE-617 static void modify_bar_registration ( struct pci_vdev * dev , int idx , int registration ) { int error ; struct inout_port iop ; struct mem_range mr ; if ( is_pci_gvt ( dev ) ) { printf ( ""modify_bar_registration:bypassforpci-gvt\\n"" ) ; return ; } switch ( dev -> bar [ idx ] . type ) { case PCIBAR_IO : bzero ( & iop , sizeof ( struct inout_port ) ) ; iop . name = dev -> name ; iop . port = dev -> bar [ idx ] . addr ; iop . size = dev -> bar [ idx ] . size ; if ( registration ) { iop . flags = IOPORT_F_INOUT ; iop . handler = pci_emul_io_handler ; iop . arg = dev ; error = register_inout ( & iop ) ; } else error = unregister_inout ( & iop ) ; break ; case PCIBAR_MEM32 : case PCIBAR_MEM64 : bzero ( & mr , sizeof ( struct mem_range ) ) ; mr . name = dev -> name ; mr . base = dev -> bar [ idx ] . addr ; mr . size = dev -> bar [ idx ] . size ; if ( registration ) { mr . flags = MEM_F_RW ; mr . handler = pci_emul_mem_handler ; mr . arg1 = dev ; mr . arg2 = idx ; error = register_mem ( & mr ) ; } else error = unregister_mem ( & mr ) ; break ; default : error = EINVAL ; break ; } assert ( error == 0 ) ; } "," static int modify_bar_registration ( struct ) ; return 0 break ; } return error ; } ",projectacrn@acrn-hypervisor/2b3dedfb9ba13f15887f22b935d373f36c9a59fa,CVE-2019-18844,https://github.com/projectacrn/acrn-hypervisor/commit/2b3dedfb9ba13f15887f22b935d373f36c9a59fa,2019-11-13T20:15Z 392,CWE-476,"CWE-476 static ssize_t o2nm_node_local_store ( struct config_item * item , const char * page , size_t count ) { struct o2nm_node * node = to_o2nm_node ( item ) ; struct o2nm_cluster * cluster = to_o2nm_cluster_from_node ( node ) ; unsigned long tmp ; char * p = ( char * ) page ; ssize_t ret ; tmp = simple_strtoul ( p , & p , 0 ) ; if ( ! p || ( * p && ( * p != '\\n' ) ) ) return - EINVAL ; tmp = ! ! tmp ; if ( ! test_bit ( O2NM_NODE_ATTR_ADDRESS , & node -> nd_set_attributes ) || ! test_bit ( O2NM_NODE_ATTR_NUM , & node -> nd_set_attributes ) || ! test_bit ( O2NM_NODE_ATTR_PORT , & node -> nd_set_attributes ) ) return - EINVAL ; if ( tmp && tmp == cluster -> cl_has_local && cluster -> cl_local_node != node -> nd_num ) return - EBUSY ; if ( tmp && ! cluster -> cl_has_local ) { ret = o2net_start_listening ( node ) ; if ( ret ) return ret ; } if ( ! tmp && cluster -> cl_has_local && cluster -> cl_local_node == node -> nd_num ) { o2net_stop_listening ( node ) ; cluster -> cl_local_node = O2NM_INVALID_NODE_NUM ; } node -> nd_local = tmp ; if ( node -> nd_local ) { cluster -> cl_has_local = tmp ; cluster -> cl_local_node = node -> nd_num ; } return count ; } "," o2nm_cluster * cluster ; unsigned long - EINVAL ; o2nm_lock_subsystem ( ) ; cluster = to_o2nm_cluster_from_node ( node ) ; if ( ! cluster ) { ret = - EINVAL ; goto out ; } -> nd_num ) { ret = - EBUSY ; - EBUSY ; goto out ; } ( ret ) goto out ; } if nd_num ; } ret = count ; out : o2nm_unlock_subsystem ( ) ; return ret ; } ",torvalds@linux/853bc26a7ea39e354b9f8889ae7ad1492ffa28d2,CVE-2017-18216,https://github.com/torvalds/linux/commit/853bc26a7ea39e354b9f8889ae7ad1492ffa28d2,2018-03-05T18:29Z 393,CWE-119,"CWE-119 PTA * ptaReadStream ( FILE * fp ) { char typestr [ 128 ] ; l_int32 i , n , ix , iy , type , version ; l_float32 x , y ; PTA * pta ; PROCNAME ( ""ptaReadStream"" ) ; if ( ! fp ) return ( PTA * ) ERROR_PTR ( ""streamnotdefined"" , procName , NULL ) ; if ( fscanf ( fp , ""\\nPtaVersion%d\\n"" , & version ) != 1 ) return ( PTA * ) ERROR_PTR ( ""notaptafile"" , procName , NULL ) ; if ( version != PTA_VERSION_NUMBER ) return ( PTA * ) ERROR_PTR ( ""invalidptaversion"" , procName , NULL ) ; if ( fscanf ( fp , ""Numberofpts=%d;format=%s\\n"" , & n , typestr ) != 2 ) return ( PTA * ) ERROR_PTR ( ""notaptafile"" , procName , NULL ) ; if ( ! strcmp ( typestr , ""float"" ) ) type = 0 ; else type = 1 ; if ( ( pta = ptaCreate ( n ) ) == NULL ) return ( PTA * ) ERROR_PTR ( ""ptanotmade"" , procName , NULL ) ; for ( i = 0 ; i < n ; i ++ ) { if ( type == 0 ) { if ( fscanf ( fp , ""(%f,%f)\\n"" , & x , & y ) != 2 ) { ptaDestroy ( & pta ) ; return ( PTA * ) ERROR_PTR ( ""errorreadingfloats"" , procName , NULL ) ; } ptaAddPt ( pta , x , y ) ; } else { if ( fscanf ( fp , ""(%d,%d)\\n"" , & ix , & iy ) != 2 ) { ptaDestroy ( & pta ) ; return ( PTA * ) ERROR_PTR ( ""errorreadingints"" , procName , NULL ) ; } ptaAddPt ( pta , ix , iy ) ; } } return pta ; } "," ( fp , ""Numberofpts=%d;format=%127s\\n"" , & n ",DanBloomberg@leptonica/ee301cb2029db8a6289c5295daa42bba7715e99a,CVE-2018-7186,https://github.com/DanBloomberg/leptonica/commit/ee301cb2029db8a6289c5295daa42bba7715e99a,2018-02-16T16:29Z 394,CWE-125,"CWE-125 static int _6502_op ( RAnal * anal , RAnalOp * op , ut64 addr , const ut8 * data , int len ) { char addrbuf [ 64 ] ; const int buffsize = sizeof ( addrbuf ) - 1 ; memset ( op , '\\0' , sizeof ( RAnalOp ) ) ; op -> size = snes_op_get_size ( 1 , 1 , & snes_op [ data [ 0 ] ] ) ; op -> addr = addr ; op -> type = R_ANAL_OP_TYPE_UNK ; op -> id = data [ 0 ] ; r_strbuf_init ( & op -> esil ) ; switch ( data [ 0 ] ) { case 0x02 : case 0x03 : case 0x04 : case 0x07 : case 0x0b : case 0x0c : case 0x0f : case 0x12 : case 0x13 : case 0x14 : case 0x17 : case 0x1a : case 0x1b : case 0x1c : case 0x1f : case 0x22 : case 0x23 : case 0x27 : case 0x2b : case 0x2f : case 0x32 : case 0x33 : case 0x34 : case 0x37 : case 0x3a : case 0x3b : case 0x3c : case 0x3f : case 0x42 : case 0x43 : case 0x44 : case 0x47 : case 0x4b : case 0x4f : case 0x52 : case 0x53 : case 0x54 : case 0x57 : case 0x5a : case 0x5b : case 0x5c : case 0x5f : case 0x62 : case 0x63 : case 0x64 : case 0x67 : case 0x6b : case 0x6f : case 0x72 : case 0x73 : case 0x74 : case 0x77 : case 0x7a : case 0x7b : case 0x7c : case 0x7f : case 0x80 : case 0x82 : case 0x83 : case 0x87 : case 0x89 : case 0x8b : case 0x8f : case 0x92 : case 0x93 : case 0x97 : case 0x9b : case 0x9c : case 0x9e : case 0x9f : case 0xa3 : case 0xa7 : case 0xab : case 0xaf : case 0xb2 : case 0xb3 : case 0xb7 : case 0xbb : case 0xbf : case 0xc2 : case 0xc3 : case 0xc7 : case 0xcb : case 0xcf : case 0xd2 : case 0xd3 : case 0xd4 : case 0xd7 : case 0xda : case 0xdb : case 0xdc : case 0xdf : case 0xe2 : case 0xe3 : case 0xe7 : case 0xeb : case 0xef : case 0xf2 : case 0xf3 : case 0xf4 : case 0xf7 : case 0xfa : case 0xfb : case 0xfc : case 0xff : op -> size = 1 ; op -> type = R_ANAL_OP_TYPE_ILL ; break ; case 0x00 : op -> cycles = 7 ; op -> type = R_ANAL_OP_TYPE_SWI ; op -> size = 1 ; r_strbuf_set ( & op -> esil , "",1,I,=,0,D,=,flags,0x10,|,0x100,sp,+,=[1],pc,1,+,0xfe,sp,+,=[2],3,sp,-=,0xfffe,[2],pc,="" ) ; break ; case 0x78 : case 0x58 : case 0x38 : case 0x18 : case 0xf8 : case 0xd8 : case 0xb8 : op -> cycles = 2 ; op -> type = R_ANAL_OP_TYPE_NOP ; _6502_anal_esil_flags ( op , data [ 0 ] ) ; break ; case 0x24 : case 0x2c : op -> type = R_ANAL_OP_TYPE_MOV ; _6502_anal_esil_get_addr_pattern3 ( op , data , addrbuf , buffsize , 0 ) ; r_strbuf_setf ( & op -> esil , ""a,%s,[1],&,0x80,&,!,!,N,=,a,%s,[1],&,0x40,&,!,!,V,=,a,%s,[1],&,0xff,&,!,Z,="" , addrbuf , addrbuf , addrbuf ) ; break ; case 0x69 : case 0x65 : case 0x75 : case 0x6d : case 0x7d : case 0x79 : case 0x61 : case 0x71 : op -> type = R_ANAL_OP_TYPE_ADD ; _6502_anal_esil_get_addr_pattern1 ( op , data , addrbuf , buffsize ) ; if ( data [ 0 ] == 0x69 ) r_strbuf_setf ( & op -> esil , ""%s,a,+=,C,NUM,$c7,C,=,a,+=,$c7,C,|="" , addrbuf ) ; else r_strbuf_setf ( & op -> esil , ""%s,[1],a,+=,C,NUM,$c7,C,=,a,+=,$c7,C,|="" , addrbuf ) ; _6502_anal_update_flags ( op , _6502_FLAGS_NZ ) ; r_strbuf_append ( & op -> esil , "",a,a,=,$z,Z,="" ) ; break ; case 0xe9 : case 0xe5 : case 0xf5 : case 0xed : case 0xfd : case 0xf9 : case 0xe1 : case 0xf1 : op -> type = R_ANAL_OP_TYPE_SUB ; _6502_anal_esil_get_addr_pattern1 ( op , data , addrbuf , buffsize ) ; if ( data [ 0 ] == 0xe9 ) r_strbuf_setf ( & op -> esil , ""C,!,%s,+,a,-="" , addrbuf ) ; else r_strbuf_setf ( & op -> esil , ""C,!,%s,[1],+,a,-="" , addrbuf ) ; _6502_anal_update_flags ( op , _6502_FLAGS_BNZ ) ; r_strbuf_append ( & op -> esil , "",a,a,=,$z,Z,=,C,!="" ) ; break ; case 0x09 : case 0x05 : case 0x15 : case 0x0d : case 0x1d : case 0x19 : case 0x01 : case 0x11 : op -> type = R_ANAL_OP_TYPE_OR ; _6502_anal_esil_get_addr_pattern1 ( op , data , addrbuf , buffsize ) ; if ( data [ 0 ] == 0x09 ) r_strbuf_setf ( & op -> esil , ""%s,a,|="" , addrbuf ) ; else r_strbuf_setf ( & op -> esil , ""%s,[1],a,|="" , addrbuf ) ; _6502_anal_update_flags ( op , _6502_FLAGS_NZ ) ; break ; case 0x29 : case 0x25 : case 0x35 : case 0x2d : case 0x3d : case 0x39 : case 0x21 : case 0x31 : op -> type = R_ANAL_OP_TYPE_AND ; _6502_anal_esil_get_addr_pattern1 ( op , data , addrbuf , buffsize ) ; if ( data [ 0 ] == 0x29 ) r_strbuf_setf ( & op -> esil , ""%s,a,&="" , addrbuf ) ; else r_strbuf_setf ( & op -> esil , ""%s,[1],a,&="" , addrbuf ) ; _6502_anal_update_flags ( op , _6502_FLAGS_NZ ) ; break ; case 0x49 : case 0x45 : case 0x55 : case 0x4d : case 0x5d : case 0x59 : case 0x41 : case 0x51 : op -> type = R_ANAL_OP_TYPE_XOR ; _6502_anal_esil_get_addr_pattern1 ( op , data , addrbuf , buffsize ) ; if ( data [ 0 ] == 0x49 ) r_strbuf_setf ( & op -> esil , ""%s,a,^="" , addrbuf ) ; else r_strbuf_setf ( & op -> esil , ""%s,[1],a,^="" , addrbuf ) ; _6502_anal_update_flags ( op , _6502_FLAGS_NZ ) ; break ; case 0x0a : case 0x06 : case 0x16 : case 0x0e : case 0x1e : op -> type = R_ANAL_OP_TYPE_SHL ; if ( data [ 0 ] == 0x0a ) { r_strbuf_set ( & op -> esil , ""1,a,<<=,$c7,C,=,a,a,="" ) ; } else { _6502_anal_esil_get_addr_pattern2 ( op , data , addrbuf , buffsize , 'x' ) ; r_strbuf_setf ( & op -> esil , ""1,%s,[1],<<,%s,=[1],$c7,C,="" , addrbuf , addrbuf ) ; } _6502_anal_update_flags ( op , _6502_FLAGS_NZ ) ; break ; case 0x4a : case 0x46 : case 0x56 : case 0x4e : case 0x5e : op -> type = R_ANAL_OP_TYPE_SHR ; if ( data [ 0 ] == 0x4a ) { r_strbuf_set ( & op -> esil , ""1,a,&,C,=,1,a,>>="" ) ; } else { _6502_anal_esil_get_addr_pattern2 ( op , data , addrbuf , buffsize , 'x' ) ; r_strbuf_setf ( & op -> esil , ""1,%s,[1],&,C,=,1,%s,[1],>>,%s,=[1]"" , addrbuf , addrbuf , addrbuf ) ; } _6502_anal_update_flags ( op , _6502_FLAGS_NZ ) ; break ; case 0x2a : case 0x26 : case 0x36 : case 0x2e : case 0x3e : op -> type = R_ANAL_OP_TYPE_ROL ; if ( data [ 0 ] == 0x2a ) { r_strbuf_set ( & op -> esil , ""1,a,<<,C,|,a,=,$c7,C,=,a,a,="" ) ; } else { _6502_anal_esil_get_addr_pattern2 ( op , data , addrbuf , buffsize , 'x' ) ; r_strbuf_setf ( & op -> esil , ""1,%s,[1],<<,C,|,%s,=[1],$c7,C,="" , addrbuf , addrbuf ) ; } _6502_anal_update_flags ( op , _6502_FLAGS_NZ ) ; break ; case 0x6a : case 0x66 : case 0x76 : case 0x6e : case 0x7e : op -> type = R_ANAL_OP_TYPE_ROR ; if ( data [ 0 ] == 0x6a ) { r_strbuf_set ( & op -> esil , ""C,N,=,1,a,&,C,=,1,a,>>,7,N,<<,|,a,="" ) ; } else { _6502_anal_esil_get_addr_pattern2 ( op , data , addrbuf , buffsize , 'x' ) ; r_strbuf_setf ( & op -> esil , ""C,N,=,1,%s,[1],&,C,=,1,%s,[1],>>,7,N,<<,|,%s,=[1]"" , addrbuf , addrbuf , addrbuf ) ; } _6502_anal_update_flags ( op , _6502_FLAGS_NZ ) ; break ; case 0xe6 : case 0xf6 : case 0xee : case 0xfe : op -> type = R_ANAL_OP_TYPE_STORE ; _6502_anal_esil_get_addr_pattern2 ( op , data , addrbuf , buffsize , 'x' ) ; r_strbuf_setf ( & op -> esil , ""%s,++=[1]"" , addrbuf ) ; _6502_anal_update_flags ( op , _6502_FLAGS_NZ ) ; break ; case 0xc6 : case 0xd6 : case 0xce : case 0xde : op -> type = R_ANAL_OP_TYPE_STORE ; _6502_anal_esil_get_addr_pattern2 ( op , data , addrbuf , buffsize , 'x' ) ; r_strbuf_setf ( & op -> esil , ""%s,--=[1]"" , addrbuf ) ; _6502_anal_update_flags ( op , _6502_FLAGS_NZ ) ; break ; case 0xe8 : case 0xc8 : op -> cycles = 2 ; op -> type = R_ANAL_OP_TYPE_STORE ; _6502_anal_esil_inc_reg ( op , data [ 0 ] , ""+"" ) ; break ; case 0xca : case 0x88 : op -> cycles = 2 ; op -> type = R_ANAL_OP_TYPE_STORE ; _6502_anal_esil_inc_reg ( op , data [ 0 ] , ""-"" ) ; break ; case 0xc9 : case 0xc5 : case 0xd5 : case 0xcd : case 0xdd : case 0xd9 : case 0xc1 : case 0xd1 : op -> type = R_ANAL_OP_TYPE_CMP ; _6502_anal_esil_get_addr_pattern1 ( op , data , addrbuf , buffsize ) ; if ( data [ 0 ] == 0xc9 ) r_strbuf_setf ( & op -> esil , ""%s,a,=="" , addrbuf ) ; else r_strbuf_setf ( & op -> esil , ""%s,[1],a,=="" , addrbuf ) ; _6502_anal_update_flags ( op , _6502_FLAGS_BNZ ) ; r_strbuf_append ( & op -> esil , "",C,!,C,="" ) ; break ; case 0xe0 : case 0xe4 : case 0xec : op -> type = R_ANAL_OP_TYPE_CMP ; _6502_anal_esil_get_addr_pattern3 ( op , data , addrbuf , buffsize , 0 ) ; if ( data [ 0 ] == 0xe0 ) r_strbuf_setf ( & op -> esil , ""%s,x,=="" , addrbuf ) ; else r_strbuf_setf ( & op -> esil , ""%s,[1],x,=="" , addrbuf ) ; _6502_anal_update_flags ( op , _6502_FLAGS_BNZ ) ; r_strbuf_append ( & op -> esil , "",C,!,C,="" ) ; break ; case 0xc0 : case 0xc4 : case 0xcc : op -> type = R_ANAL_OP_TYPE_CMP ; _6502_anal_esil_get_addr_pattern3 ( op , data , addrbuf , buffsize , 0 ) ; if ( data [ 0 ] == 0xc0 ) r_strbuf_setf ( & op -> esil , ""%s,y,=="" , addrbuf ) ; else r_strbuf_setf ( & op -> esil , ""%s,[1],y,=="" , addrbuf ) ; _6502_anal_update_flags ( op , _6502_FLAGS_BNZ ) ; r_strbuf_append ( & op -> esil , "",C,!,C,="" ) ; break ; case 0x10 : case 0x30 : case 0x50 : case 0x70 : case 0x90 : case 0xb0 : case 0xd0 : case 0xf0 : op -> cycles = 2 ; op -> failcycles = 3 ; op -> type = R_ANAL_OP_TYPE_CJMP ; if ( data [ 1 ] <= 127 ) op -> jump = addr + data [ 1 ] + op -> size ; else op -> jump = addr - ( 256 - data [ 1 ] ) + op -> size ; op -> fail = addr + op -> size ; _6502_anal_esil_ccall ( op , data [ 0 ] ) ; break ; case 0x20 : op -> cycles = 6 ; op -> type = R_ANAL_OP_TYPE_CALL ; op -> jump = data [ 1 ] | data [ 2 ] << 8 ; op -> stackop = R_ANAL_STACK_INC ; op -> stackptr = 2 ; r_strbuf_setf ( & op -> esil , ""1,pc,-,0xff,sp,+,=[2],0x%04x,pc,=,2,sp,-="" , op -> jump ) ; break ; case 0x4c : op -> cycles = 3 ; op -> type = R_ANAL_OP_TYPE_JMP ; op -> jump = data [ 1 ] | data [ 2 ] << 8 ; r_strbuf_setf ( & op -> esil , ""0x%04x,pc,="" , op -> jump ) ; break ; case 0x6c : op -> cycles = 5 ; op -> type = R_ANAL_OP_TYPE_UJMP ; r_strbuf_setf ( & op -> esil , ""0x%04x,[2],pc,="" , data [ 1 ] | data [ 2 ] << 8 ) ; break ; case 0x60 : op -> eob = true ; op -> type = R_ANAL_OP_TYPE_RET ; op -> cycles = 6 ; op -> stackop = R_ANAL_STACK_INC ; op -> stackptr = - 2 ; r_strbuf_set ( & op -> esil , ""0x101,sp,+,[2],pc,=,pc,++=,2,sp,+="" ) ; break ; case 0x40 : op -> eob = true ; op -> type = R_ANAL_OP_TYPE_RET ; op -> cycles = 6 ; op -> stackop = R_ANAL_STACK_INC ; op -> stackptr = - 3 ; r_strbuf_set ( & op -> esil , ""0x101,sp,+,[1],flags,=,0x102,sp,+,[2],pc,=,3,sp,+="" ) ; break ; case 0xea : op -> type = R_ANAL_OP_TYPE_NOP ; op -> cycles = 2 ; break ; case 0xa9 : case 0xa5 : case 0xb5 : case 0xad : case 0xbd : case 0xb9 : case 0xa1 : case 0xb1 : op -> type = R_ANAL_OP_TYPE_LOAD ; _6502_anal_esil_get_addr_pattern1 ( op , data , addrbuf , buffsize ) ; if ( data [ 0 ] == 0xa9 ) r_strbuf_setf ( & op -> esil , ""%s,a,="" , addrbuf ) ; else r_strbuf_setf ( & op -> esil , ""%s,[1],a,="" , addrbuf ) ; _6502_anal_update_flags ( op , _6502_FLAGS_NZ ) ; break ; case 0xa2 : case 0xa6 : case 0xb6 : case 0xae : case 0xbe : op -> type = R_ANAL_OP_TYPE_LOAD ; _6502_anal_esil_get_addr_pattern2 ( op , data , addrbuf , buffsize , 'y' ) ; if ( data [ 0 ] == 0xa2 ) r_strbuf_setf ( & op -> esil , ""%s,x,="" , addrbuf ) ; else r_strbuf_setf ( & op -> esil , ""%s,[1],x,="" , addrbuf ) ; _6502_anal_update_flags ( op , _6502_FLAGS_NZ ) ; break ; case 0xa0 : case 0xa4 : case 0xb4 : case 0xac : case 0xbc : op -> type = R_ANAL_OP_TYPE_LOAD ; _6502_anal_esil_get_addr_pattern3 ( op , data , addrbuf , buffsize , 'x' ) ; if ( data [ 0 ] == 0xa0 ) r_strbuf_setf ( & op -> esil , ""%s,y,="" , addrbuf ) ; else r_strbuf_setf ( & op -> esil , ""%s,[1],y,="" , addrbuf ) ; _6502_anal_update_flags ( op , _6502_FLAGS_NZ ) ; break ; case 0x85 : case 0x95 : case 0x8d : case 0x9d : case 0x99 : case 0x81 : case 0x91 : op -> type = R_ANAL_OP_TYPE_STORE ; _6502_anal_esil_get_addr_pattern1 ( op , data , addrbuf , buffsize ) ; r_strbuf_setf ( & op -> esil , ""a,%s,=[1]"" , addrbuf ) ; break ; case 0x86 : case 0x96 : case 0x8e : op -> type = R_ANAL_OP_TYPE_STORE ; _6502_anal_esil_get_addr_pattern2 ( op , data , addrbuf , buffsize , 'y' ) ; r_strbuf_setf ( & op -> esil , ""x,%s,=[1]"" , addrbuf ) ; break ; case 0x84 : case 0x94 : case 0x8c : op -> type = R_ANAL_OP_TYPE_STORE ; _6502_anal_esil_get_addr_pattern3 ( op , data , addrbuf , buffsize , 'x' ) ; r_strbuf_setf ( & op -> esil , ""y,%s,=[1]"" , addrbuf ) ; break ; case 0x08 : case 0x48 : op -> type = R_ANAL_OP_TYPE_PUSH ; op -> cycles = 3 ; op -> stackop = R_ANAL_STACK_INC ; op -> stackptr = 1 ; _6502_anal_esil_push ( op , data [ 0 ] ) ; break ; case 0x28 : case 0x68 : op -> type = R_ANAL_OP_TYPE_POP ; op -> cycles = 4 ; op -> stackop = R_ANAL_STACK_INC ; op -> stackptr = - 1 ; _6502_anal_esil_pop ( op , data [ 0 ] ) ; break ; case 0xaa : case 0x8a : case 0xa8 : case 0x98 : op -> type = R_ANAL_OP_TYPE_MOV ; op -> cycles = 2 ; _6502_anal_esil_mov ( op , data [ 0 ] ) ; break ; case 0x9a : op -> type = R_ANAL_OP_TYPE_MOV ; op -> cycles = 2 ; op -> stackop = R_ANAL_STACK_SET ; _6502_anal_esil_mov ( op , data [ 0 ] ) ; break ; case 0xba : op -> type = R_ANAL_OP_TYPE_MOV ; op -> cycles = 2 ; op -> stackop = R_ANAL_STACK_GET ; _6502_anal_esil_mov ( op , data [ 0 ] ) ; break ; } return op -> size ; } "," ; if ( len > 1 ) { if ( <= 127 ) { -> size ; } else { op -> jump -> size ; } } else { op -> jump = addr ; } ",radare@radare2/bbb4af56003c1afdad67af0c4339267ca38b1017,CVE-2018-12322,https://github.com/radare/radare2/commit/bbb4af56003c1afdad67af0c4339267ca38b1017,2018-06-13T16:29Z 395,CWE-362,"CWE-362 void sctp_generate_t3_rtx_event ( unsigned long peer ) { int error ; struct sctp_transport * transport = ( struct sctp_transport * ) peer ; struct sctp_association * asoc = transport -> asoc ; struct net * net = sock_net ( asoc -> base . sk ) ; bh_lock_sock ( asoc -> base . sk ) ; if ( sock_owned_by_user ( asoc -> base . sk ) ) { pr_debug ( ""%s:sockisbusy\\n"" , __func__ ) ; if ( ! mod_timer ( & transport -> T3_rtx_timer , jiffies + ( HZ / 20 ) ) ) sctp_transport_hold ( transport ) ; goto out_unlock ; } if ( transport -> dead ) goto out_unlock ; error = sctp_do_sm ( net , SCTP_EVENT_T_TIMEOUT , SCTP_ST_TIMEOUT ( SCTP_EVENT_TIMEOUT_T3_RTX ) , asoc -> state , asoc -> ep , asoc , transport , GFP_ATOMIC ) ; if ( error ) asoc -> base . sk -> sk_err = - error ; out_unlock : bh_unlock_sock ( asoc -> base . sk ) ; sctp_transport_put ( transport ) ; } "," asoc ; struct sock * sk = asoc -> base . sk ; struct = sock_net ( sk ) ; ; bh_lock_sock ( sk ) ; ( sock_owned_by_user ( sk ) ) ( error ) sk -> sk_err : bh_unlock_sock ( sk ) ; ",torvalds@linux/635682a14427d241bab7bbdeebb48a7d7b91638e,CVE-2015-8767,https://github.com/torvalds/linux/commit/635682a14427d241bab7bbdeebb48a7d7b91638e,2016-02-08T03:59Z 396,CWE-20,"CWE-20 error_t httpParseRequestLine ( HttpConnection * connection , char_t * requestLine ) { error_t error ; char_t * token ; char_t * p ; char_t * s ; token = osStrtok_r ( requestLine , ""\\r\\n"" , & p ) ; if ( token == NULL ) return ERROR_INVALID_REQUEST ; error = strSafeCopy ( connection -> request . method , token , HTTP_SERVER_METHOD_MAX_LEN ) ; if ( error ) return ERROR_INVALID_REQUEST ; token = osStrtok_r ( NULL , ""\\r\\n"" , & p ) ; if ( token == NULL ) return ERROR_INVALID_REQUEST ; s = strchr ( token , '?' ) ; if ( s != NULL ) { * s = '\\0' ; error = httpDecodePercentEncodedString ( token , connection -> request . uri , HTTP_SERVER_URI_MAX_LEN ) ; if ( error ) return ERROR_INVALID_REQUEST ; if ( osStrlen ( s + 1 ) > HTTP_SERVER_QUERY_STRING_MAX_LEN ) return ERROR_INVALID_REQUEST ; osStrcpy ( connection -> request . queryString , s + 1 ) ; } else { error = httpDecodePercentEncodedString ( token , connection -> request . uri , HTTP_SERVER_URI_MAX_LEN ) ; if ( error ) return ERROR_INVALID_REQUEST ; connection -> request . queryString [ 0 ] = '\\0' ; } if ( ! osStrcasecmp ( connection -> request . uri , ""/"" ) ) osStrcpy ( connection -> request . uri , connection -> settings -> defaultDocument ) ; pathCanonicalize ( connection -> request . uri ) ; token = osStrtok_r ( NULL , ""\\r\\n"" , & p ) ; if ( token == NULL ) { connection -> request . version = HTTP_VERSION_0_9 ; connection -> request . keepAlive = FALSE ; } else if ( ! osStrcasecmp ( token , ""HTTP/1.0"" ) ) { connection -> request . version = HTTP_VERSION_1_0 ; connection -> request . keepAlive = FALSE ; } else if ( ! osStrcasecmp ( token , ""HTTP/1.1"" ) ) { connection -> request . version = HTTP_VERSION_1_1 ; connection -> request . keepAlive = TRUE ; } else { return ERROR_INVALID_REQUEST ; } return NO_ERROR ; } "," ; s = osStrchr ( token , ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 397,CWE-125,"CWE-125 int write_output ( void ) { int fd ; struct filter_op * fop ; struct filter_header fh ; size_t ninst , i ; u_char * data ; ninst = compile_tree ( & fop ) ; if ( fop == NULL ) return - E_NOTHANDLED ; fd = open ( EF_GBL_OPTIONS -> output_file , O_CREAT | O_RDWR | O_TRUNC | O_BINARY , 0644 ) ; ON_ERROR ( fd , - 1 , ""Can\'tcreatefile%s"" , EF_GBL_OPTIONS -> output_file ) ; fprintf ( stdout , ""Writingoutputto\\\'%s\\\'"" , EF_GBL_OPTIONS -> output_file ) ; fflush ( stdout ) ; fh . magic = htons ( EC_FILTER_MAGIC ) ; strncpy ( fh . version , EC_VERSION , sizeof ( fh . version ) ) ; fh . data = sizeof ( fh ) ; data = create_data_segment ( & fh , fop , ninst ) ; write ( fd , & fh , sizeof ( struct filter_header ) ) ; write ( fd , data , fh . code - fh . data ) ; for ( i = 0 ; i <= ninst ; i ++ ) { print_progress_bar ( & fop [ i ] ) ; write ( fd , & fop [ i ] , sizeof ( struct filter_op ) ) ; } close ( fd ) ; fprintf ( stdout , ""done.\\n\\n"" ) ; fprintf ( stdout , ""->Scriptencodedinto%dinstructions.\\n\\n"" , ( int ) ( i - 1 ) ) ; return E_SUCCESS ; } "," return - E_NOTHANDLED ; if ( ninst == 0 ) return - E_INVALID ",LocutusOfBorg@ettercap/626dc56686f15f2dda13c48f78c2a666cb6d8506,CVE-2017-6430,https://github.com/LocutusOfBorg/ettercap/commit/626dc56686f15f2dda13c48f78c2a666cb6d8506,2017-03-15T15:59Z 398,CWE-125,"CWE-125 static int ospf6_print_lshdr ( netdissect_options * ndo , register const struct lsa6_hdr * lshp , const u_char * dataend ) { if ( ( const u_char * ) ( lshp + 1 ) > dataend ) goto trunc ; ND_TCHECK ( lshp -> ls_type ) ; ND_TCHECK ( lshp -> ls_seq ) ; ND_PRINT ( ( ndo , ""\\n\\tAdvertisingRouter%s,seq0x%08x,age%us,length%u"" , ipaddr_string ( ndo , & lshp -> ls_router ) , EXTRACT_32BITS ( & lshp -> ls_seq ) , EXTRACT_16BITS ( & lshp -> ls_age ) , EXTRACT_16BITS ( & lshp -> ls_length ) - ( u_int ) sizeof ( struct lsa6_hdr ) ) ) ; ospf6_print_ls_type ( ndo , EXTRACT_16BITS ( & lshp -> ls_type ) , & lshp -> ls_stateid ) ; return ( 0 ) ; trunc : return ( 1 ) ; } "," ( lshp -> ls_length ) ; ND_PRINT ",the-tcpdump-group@tcpdump/e01c9bf76740802025c9328901b55ee4a0c49ed6,CVE-2018-14880,https://github.com/the-tcpdump-group/tcpdump/commit/e01c9bf76740802025c9328901b55ee4a0c49ed6,2019-10-03T16:15Z 399,CWE-190,"CWE-190 static int jas_iccputuint ( jas_stream_t * out , int n , ulonglong val ) { int i ; int c ; for ( i = n ; i > 0 ; -- i ) { c = ( val >> ( 8 * ( i - 1 ) ) ) & 0xff ; if ( jas_stream_putc ( out , c ) == EOF ) return - 1 ; } return 0 ; } "," int n , jas_ulonglong val ) { ",mdadams@jasper/d42b2388f7f8e0332c846675133acea151fc557a,CVE-2016-9557,https://github.com/mdadams/jasper/commit/d42b2388f7f8e0332c846675133acea151fc557a,2017-03-23T18:59Z 400,CWE-125,"CWE-125 static int parse_elements ( netdissect_options * ndo , struct mgmt_body_t * pbody , const u_char * p , int offset , u_int length ) { u_int elementlen ; struct ssid_t ssid ; struct challenge_t challenge ; struct rates_t rates ; struct ds_t ds ; struct cf_t cf ; struct tim_t tim ; pbody -> challenge_present = 0 ; pbody -> ssid_present = 0 ; pbody -> rates_present = 0 ; pbody -> ds_present = 0 ; pbody -> cf_present = 0 ; pbody -> tim_present = 0 ; while ( length != 0 ) { if ( ! ND_TTEST2 ( * ( p + offset ) , 2 ) ) return 0 ; if ( length < 2 ) return 0 ; elementlen = * ( p + offset + 1 ) ; if ( ! ND_TTEST2 ( * ( p + offset + 2 ) , elementlen ) ) return 0 ; if ( length < elementlen + 2 ) return 0 ; switch ( * ( p + offset ) ) { case E_SSID : memcpy ( & ssid , p + offset , 2 ) ; offset += 2 ; length -= 2 ; if ( ssid . length != 0 ) { if ( ssid . length > sizeof ( ssid . ssid ) - 1 ) return 0 ; if ( ! ND_TTEST2 ( * ( p + offset ) , ssid . length ) ) return 0 ; if ( length < ssid . length ) return 0 ; memcpy ( & ssid . ssid , p + offset , ssid . length ) ; offset += ssid . length ; length -= ssid . length ; } ssid . ssid [ ssid . length ] = '\\0' ; if ( ! pbody -> ssid_present ) { pbody -> ssid = ssid ; pbody -> ssid_present = 1 ; } break ; case E_CHALLENGE : memcpy ( & challenge , p + offset , 2 ) ; offset += 2 ; length -= 2 ; if ( challenge . length != 0 ) { if ( challenge . length > sizeof ( challenge . text ) - 1 ) return 0 ; if ( ! ND_TTEST2 ( * ( p + offset ) , challenge . length ) ) return 0 ; if ( length < challenge . length ) return 0 ; memcpy ( & challenge . text , p + offset , challenge . length ) ; offset += challenge . length ; length -= challenge . length ; } challenge . text [ challenge . length ] = '\\0' ; if ( ! pbody -> challenge_present ) { pbody -> challenge = challenge ; pbody -> challenge_present = 1 ; } break ; case E_RATES : memcpy ( & rates , p + offset , 2 ) ; offset += 2 ; length -= 2 ; if ( rates . length != 0 ) { if ( rates . length > sizeof rates . rate ) return 0 ; if ( ! ND_TTEST2 ( * ( p + offset ) , rates . length ) ) return 0 ; if ( length < rates . length ) return 0 ; memcpy ( & rates . rate , p + offset , rates . length ) ; offset += rates . length ; length -= rates . length ; } if ( ! pbody -> rates_present && rates . length != 0 ) { pbody -> rates = rates ; pbody -> rates_present = 1 ; } break ; case E_DS : memcpy ( & ds , p + offset , 2 ) ; offset += 2 ; length -= 2 ; if ( ds . length != 1 ) { offset += ds . length ; length -= ds . length ; break ; } ds . channel = * ( p + offset ) ; offset += 1 ; length -= 1 ; if ( ! pbody -> ds_present ) { pbody -> ds = ds ; pbody -> ds_present = 1 ; } break ; case E_CF : memcpy ( & cf , p + offset , 2 ) ; offset += 2 ; length -= 2 ; if ( cf . length != 6 ) { offset += cf . length ; length -= cf . length ; break ; } memcpy ( & cf . count , p + offset , 6 ) ; offset += 6 ; length -= 6 ; if ( ! pbody -> cf_present ) { pbody -> cf = cf ; pbody -> cf_present = 1 ; } break ; case E_TIM : memcpy ( & tim , p + offset , 2 ) ; offset += 2 ; length -= 2 ; if ( tim . length <= 3 ) { offset += tim . length ; length -= tim . length ; break ; } if ( tim . length - 3 > ( int ) sizeof tim . bitmap ) return 0 ; memcpy ( & tim . count , p + offset , 3 ) ; offset += 3 ; length -= 3 ; memcpy ( tim . bitmap , p + ( tim . length - 3 ) , ( tim . length - 3 ) ) ; offset += tim . length - 3 ; length -= tim . length - 3 ; if ( ! pbody -> tim_present ) { pbody -> tim = tim ; pbody -> tim_present = 1 ; } break ; default : # if 0 ND_PRINT ( ( ndo , ""(1)unhandledelement_id(%d)"" , * ( p + offset ) ) ) ; # endif offset += 2 + elementlen ; length -= 2 + elementlen ; break ; } } return 1 ; } "," , p + offset + 3 , tim . length - 3 ) ; offset += tim . length length - 3 ; length -= tim . length - 3 ; if ( ! ",the-tcpdump-group@tcpdump/99798bd9a41bd3d03fdc1e949810a38967f20ed3,CVE-2017-12987,https://github.com/the-tcpdump-group/tcpdump/commit/99798bd9a41bd3d03fdc1e949810a38967f20ed3,2017-09-14T06:29Z 401,CWE-416,"CWE-416 static int splice_pipe_to_pipe ( struct pipe_inode_info * ipipe , struct pipe_inode_info * opipe , size_t len , unsigned int flags ) { struct pipe_buffer * ibuf , * obuf ; int ret = 0 , nbuf ; bool input_wakeup = false ; retry : ret = ipipe_prep ( ipipe , flags ) ; if ( ret ) return ret ; ret = opipe_prep ( opipe , flags ) ; if ( ret ) return ret ; pipe_double_lock ( ipipe , opipe ) ; do { if ( ! opipe -> readers ) { send_sig ( SIGPIPE , current , 0 ) ; if ( ! ret ) ret = - EPIPE ; break ; } if ( ! ipipe -> nrbufs && ! ipipe -> writers ) break ; if ( ! ipipe -> nrbufs || opipe -> nrbufs >= opipe -> buffers ) { if ( ret ) break ; if ( flags & SPLICE_F_NONBLOCK ) { ret = - EAGAIN ; break ; } pipe_unlock ( ipipe ) ; pipe_unlock ( opipe ) ; goto retry ; } ibuf = ipipe -> bufs + ipipe -> curbuf ; nbuf = ( opipe -> curbuf + opipe -> nrbufs ) & ( opipe -> buffers - 1 ) ; obuf = opipe -> bufs + nbuf ; if ( len >= ibuf -> len ) { * obuf = * ibuf ; ibuf -> ops = NULL ; opipe -> nrbufs ++ ; ipipe -> curbuf = ( ipipe -> curbuf + 1 ) & ( ipipe -> buffers - 1 ) ; ipipe -> nrbufs -- ; input_wakeup = true ; } else { pipe_buf_get ( ipipe , ibuf ) ; * obuf = * ibuf ; obuf -> flags &= ~ PIPE_BUF_FLAG_GIFT ; pipe_buf_mark_unmergeable ( obuf ) ; obuf -> len = len ; opipe -> nrbufs ++ ; ibuf -> offset += obuf -> len ; ibuf -> len -= obuf -> len ; } ret += obuf -> len ; len -= obuf -> len ; } while ( len ) ; pipe_unlock ( ipipe ) ; pipe_unlock ( opipe ) ; if ( ret > 0 ) wakeup_pipe_readers ( opipe ) ; if ( input_wakeup ) wakeup_pipe_writers ( ipipe ) ; return ret ; } "," } else { if ( ! , ibuf ) ) { if ( ret == 0 ) ret = - EFAULT ; break ; } * obuf = ",torvalds@linux/6b3a707736301c2128ca85ce85fb13f60b5e350a,CVE-2019-11487,https://github.com/torvalds/linux/commit/6b3a707736301c2128ca85ce85fb13f60b5e350a,2019-04-23T22:29Z 402,CWE-119,"CWE-119 static void * load_bytes ( RBinFile * arch , const ut8 * buf , ut64 sz , ut64 loaddr , Sdb * sdb ) { if ( ! buf || ! sz || sz == UT64_MAX ) { return NULL ; } RBuffer * tbuf = r_buf_new ( ) ; r_buf_set_bytes ( tbuf , buf , sz ) ; struct r_bin_bflt_obj * res = r_bin_bflt_new_buf ( tbuf ) ; r_buf_free ( tbuf ) ; return res ? res : NULL ; } "," ( ) ; if ( ! tbuf ) { return NULL ; } ",radare@radare2/72794dc3523bbd5bb370de3c5857cb736c387e18,CVE-2017-6194,https://github.com/radare/radare2/commit/72794dc3523bbd5bb370de3c5857cb736c387e18,2017-04-03T05:59Z 403,CWE-264,"CWE-264 SYSCALL_DEFINE4 ( osf_wait4 , pid_t , pid , int __user * , ustatus , int , options , struct rusage32 __user * , ur ) { struct rusage r ; long ret , err ; mm_segment_t old_fs ; if ( ! ur ) return sys_wait4 ( pid , ustatus , options , NULL ) ; old_fs = get_fs ( ) ; set_fs ( KERNEL_DS ) ; ret = sys_wait4 ( pid , ustatus , options , ( struct rusage __user * ) & r ) ; set_fs ( old_fs ) ; if ( ! access_ok ( VERIFY_WRITE , ur , sizeof ( * ur ) ) ) return - EFAULT ; err = 0 ; err |= __put_user ( r . ru_utime . tv_sec , & ur -> ru_utime . tv_sec ) ; err |= __put_user ( r . ru_utime . tv_usec , & ur -> ru_utime . tv_usec ) ; err |= __put_user ( r . ru_stime . tv_sec , & ur -> ru_stime . tv_sec ) ; err |= __put_user ( r . ru_stime . tv_usec , & ur -> ru_stime . tv_usec ) ; err |= __put_user ( r . ru_maxrss , & ur -> ru_maxrss ) ; err |= __put_user ( r . ru_ixrss , & ur -> ru_ixrss ) ; err |= __put_user ( r . ru_idrss , & ur -> ru_idrss ) ; err |= __put_user ( r . ru_isrss , & ur -> ru_isrss ) ; err |= __put_user ( r . ru_minflt , & ur -> ru_minflt ) ; err |= __put_user ( r . ru_majflt , & ur -> ru_majflt ) ; err |= __put_user ( r . ru_nswap , & ur -> ru_nswap ) ; err |= __put_user ( r . ru_inblock , & ur -> ru_inblock ) ; err |= __put_user ( r . ru_oublock , & ur -> ru_oublock ) ; err |= __put_user ( r . ru_msgsnd , & ur -> ru_msgsnd ) ; err |= __put_user ( r . ru_msgrcv , & ur -> ru_msgrcv ) ; err |= __put_user ( r . ru_nsignals , & ur -> ru_nsignals ) ; err |= __put_user ( r . ru_nvcsw , & ur -> ru_nvcsw ) ; err |= __put_user ( r . ru_nivcsw , & ur -> ru_nivcsw ) ; return err ? err : ret ; } "," , err ; unsigned int status = 0 ; ( pid , ( unsigned int __user * ) & status , options , ; err |= put_user ( status , ustatus ) ; err |= ",torvalds@linux/21c5977a836e399fc710ff2c5367845ed5c2527f,CVE-2011-2211,https://github.com/torvalds/linux/commit/21c5977a836e399fc710ff2c5367845ed5c2527f,2012-06-13T10:24Z 404,CWE-59,"CWE-59 static int lxc_mount_auto_mounts ( struct lxc_conf * conf , int flags , struct lxc_handler * handler ) { int r ; size_t i ; static struct { int match_mask ; int match_flag ; const char * source ; const char * destination ; const char * fstype ; unsigned long flags ; const char * options ; } default_mounts [ ] = { { LXC_AUTO_PROC_MASK , LXC_AUTO_PROC_MIXED , ""proc"" , ""%r/proc"" , ""proc"" , MS_NODEV | MS_NOEXEC | MS_NOSUID , NULL } , { LXC_AUTO_PROC_MASK , LXC_AUTO_PROC_MIXED , ""%r/proc/sys/net"" , ""%r/proc/net"" , NULL , MS_BIND , NULL } , { LXC_AUTO_PROC_MASK , LXC_AUTO_PROC_MIXED , ""%r/proc/sys"" , ""%r/proc/sys"" , NULL , MS_BIND , NULL } , { LXC_AUTO_PROC_MASK , LXC_AUTO_PROC_MIXED , NULL , ""%r/proc/sys"" , NULL , MS_REMOUNT | MS_BIND | MS_RDONLY , NULL } , { LXC_AUTO_PROC_MASK , LXC_AUTO_PROC_MIXED , ""%r/proc/net"" , ""%r/proc/sys/net"" , NULL , MS_MOVE , NULL } , { LXC_AUTO_PROC_MASK , LXC_AUTO_PROC_MIXED , ""%r/proc/sysrq-trigger"" , ""%r/proc/sysrq-trigger"" , NULL , MS_BIND , NULL } , { LXC_AUTO_PROC_MASK , LXC_AUTO_PROC_MIXED , NULL , ""%r/proc/sysrq-trigger"" , NULL , MS_REMOUNT | MS_BIND | MS_RDONLY , NULL } , { LXC_AUTO_PROC_MASK , LXC_AUTO_PROC_RW , ""proc"" , ""%r/proc"" , ""proc"" , MS_NODEV | MS_NOEXEC | MS_NOSUID , NULL } , { LXC_AUTO_SYS_MASK , LXC_AUTO_SYS_RW , ""sysfs"" , ""%r/sys"" , ""sysfs"" , 0 , NULL } , { LXC_AUTO_SYS_MASK , LXC_AUTO_SYS_RO , ""sysfs"" , ""%r/sys"" , ""sysfs"" , MS_RDONLY , NULL } , { LXC_AUTO_SYS_MASK , LXC_AUTO_SYS_MIXED , ""sysfs"" , ""%r/sys"" , ""sysfs"" , MS_NODEV | MS_NOEXEC | MS_NOSUID , NULL } , { LXC_AUTO_SYS_MASK , LXC_AUTO_SYS_MIXED , ""%r/sys"" , ""%r/sys"" , NULL , MS_BIND , NULL } , { LXC_AUTO_SYS_MASK , LXC_AUTO_SYS_MIXED , NULL , ""%r/sys"" , NULL , MS_REMOUNT | MS_BIND | MS_RDONLY , NULL } , { LXC_AUTO_SYS_MASK , LXC_AUTO_SYS_MIXED , ""sysfs"" , ""%r/sys/devices/virtual/net"" , ""sysfs"" , 0 , NULL } , { LXC_AUTO_SYS_MASK , LXC_AUTO_SYS_MIXED , ""%r/sys/devices/virtual/net/devices/virtual/net"" , ""%r/sys/devices/virtual/net"" , NULL , MS_BIND , NULL } , { LXC_AUTO_SYS_MASK , LXC_AUTO_SYS_MIXED , NULL , ""%r/sys/devices/virtual/net"" , NULL , MS_REMOUNT | MS_BIND | MS_NOSUID | MS_NODEV | MS_NOEXEC , NULL } , { 0 , 0 , NULL , NULL , NULL , 0 , NULL } } ; for ( i = 0 ; default_mounts [ i ] . match_mask ; i ++ ) { if ( ( flags & default_mounts [ i ] . match_mask ) == default_mounts [ i ] . match_flag ) { char * source = NULL ; char * destination = NULL ; int saved_errno ; unsigned long mflags ; if ( default_mounts [ i ] . source ) { source = lxc_string_replace ( ""%r"" , conf -> rootfs . path ? conf -> rootfs . mount : """" , default_mounts [ i ] . source ) ; if ( ! source ) { SYSERROR ( ""memoryallocationerror"" ) ; return - 1 ; } } if ( default_mounts [ i ] . destination ) { destination = lxc_string_replace ( ""%r"" , conf -> rootfs . path ? conf -> rootfs . mount : """" , default_mounts [ i ] . destination ) ; if ( ! destination ) { saved_errno = errno ; SYSERROR ( ""memoryallocationerror"" ) ; free ( source ) ; errno = saved_errno ; return - 1 ; } } mflags = add_required_remount_flags ( source , destination , default_mounts [ i ] . flags ) ; r = mount ( source , destination , default_mounts [ i ] . fstype , mflags , default_mounts [ i ] . options ) ; saved_errno = errno ; if ( r < 0 && errno == ENOENT ) { INFO ( ""Mountsourceortargetfor%son%sdoesn\'texist.Skipping."" , source , destination ) ; r = 0 ; } else if ( r < 0 ) SYSERROR ( ""errormounting%son%sflags%lu"" , source , destination , mflags ) ; free ( source ) ; free ( destination ) ; if ( r < 0 ) { errno = saved_errno ; return - 1 ; } } } if ( flags & LXC_AUTO_CGROUP_MASK ) { int cg_flags ; cg_flags = flags & LXC_AUTO_CGROUP_MASK ; if ( cg_flags == LXC_AUTO_CGROUP_NOSPEC || cg_flags == LXC_AUTO_CGROUP_FULL_NOSPEC ) { int has_sys_admin = 0 ; if ( ! lxc_list_empty ( & conf -> keepcaps ) ) { has_sys_admin = in_caplist ( CAP_SYS_ADMIN , & conf -> keepcaps ) ; } else { has_sys_admin = ! in_caplist ( CAP_SYS_ADMIN , & conf -> caps ) ; } if ( cg_flags == LXC_AUTO_CGROUP_NOSPEC ) { cg_flags = has_sys_admin ? LXC_AUTO_CGROUP_RW : LXC_AUTO_CGROUP_MIXED ; } else { cg_flags = has_sys_admin ? LXC_AUTO_CGROUP_FULL_RW : LXC_AUTO_CGROUP_FULL_MIXED ; } } if ( ! cgroup_mount ( conf -> rootfs . path ? conf -> rootfs . mount : """" , handler , cg_flags ) ) { SYSERROR ( ""errormounting/sys/fs/cgroup"" ) ; return - 1 ; } } return 0 ; } "," , ""%r/proc/sys/net"" , ""%r/proc/tty"" , NULL , , LXC_AUTO_PROC_MIXED , ""%r/proc/tty"" , ""%r/proc/sys/net"" , ; r = safe_mount ( source , destination , default_mounts [ i ] . fstype , mflags , default_mounts [ i ] . options , conf -> rootfs . path ? conf -> rootfs . mount : NULL ) ; saved_errno ",lxc@lxc/592fd47a6245508b79fe6ac819fe6d3b2c1289be,CVE-2015-1335,https://github.com/lxc/lxc/commit/592fd47a6245508b79fe6ac819fe6d3b2c1289be,2015-10-01T20:59Z 405,CWE-20,"CWE-20 stf_status ikev2parent_inI1outR1 ( struct msg_digest * md ) { struct state * st = md -> st ; lset_t policy = POLICY_IKEV2_ALLOW ; struct connection * c = find_host_connection ( & md -> iface -> ip_addr , md -> iface -> port , & md -> sender , md -> sender_port , POLICY_IKEV2_ALLOW ) ; # if 0 if ( c == NULL ) { pb_stream pre_sa_pbs = sa_pd -> pbs ; policy = preparse_isakmp_sa_body ( & pre_sa_pbs ) ; c = find_host_connection ( & md -> iface -> ip_addr , pluto_port , ( ip_address * ) NULL , md -> sender_port , policy ) ; } # endif if ( c == NULL ) { { struct connection * d ; d = find_host_connection ( & md -> iface -> ip_addr , pluto_port , ( ip_address * ) NULL , md -> sender_port , policy ) ; for ( ; d != NULL ; d = d -> hp_next ) { if ( d -> kind == CK_GROUP ) { } else { if ( d -> kind == CK_TEMPLATE && ! ( d -> policy & POLICY_OPPO ) ) { c = d ; break ; } if ( addrinsubnet ( & md -> sender , & d -> spd . that . client ) && ( c == NULL || ! subnetinsubnet ( & c -> spd . that . client , & d -> spd . that . client ) ) ) c = d ; } } } if ( c == NULL ) { loglog ( RC_LOG_SERIOUS , ""initialparentSAmessagereceivedon%s:%u"" ""butnoconnectionhasbeenauthorized%s%s"" , ip_str ( & md -> iface -> ip_addr ) , ntohs ( portof ( & md -> iface -> ip_addr ) ) , ( policy != LEMPTY ) ? ""withpolicy="" : """" , ( policy != LEMPTY ) ? bitnamesof ( sa_policy_bit_names , policy ) : """" ) ; return STF_FAIL + v2N_NO_PROPOSAL_CHOSEN ; } if ( c -> kind != CK_TEMPLATE ) { loglog ( RC_LOG_SERIOUS , ""initialparentSAmessagereceivedon%s:%u"" ""but\\""%s\\""forbidsconnection"" , ip_str ( & md -> iface -> ip_addr ) , pluto_port , c -> name ) ; return STF_FAIL + v2N_NO_PROPOSAL_CHOSEN ; } c = rw_instantiate ( c , & md -> sender , NULL , NULL ) ; } else { if ( ( c -> kind == CK_TEMPLATE ) && c -> spd . that . virt ) { DBG ( DBG_CONTROL , DBG_log ( ""localendpointhasvirt(vnet/vhost)setwithoutwildcards-needsinstantiation"" ) ) ; c = rw_instantiate ( c , & md -> sender , NULL , NULL ) ; } else if ( ( c -> kind == CK_TEMPLATE ) && ( c -> policy & POLICY_IKEV2_ALLOW_NARROWING ) ) { DBG ( DBG_CONTROL , DBG_log ( ""localendpointhasnarrowing=yes-needsinstantiation"" ) ) ; c = rw_instantiate ( c , & md -> sender , NULL , NULL ) ; } } DBG_log ( ""foundconnection:%s\\n"" , c ? c -> name : """" ) ; if ( ! st ) { st = new_state ( ) ; memcpy ( st -> st_icookie , md -> hdr . isa_icookie , COOKIE_SIZE ) ; get_cookie ( FALSE , st -> st_rcookie , COOKIE_SIZE , & md -> sender ) ; initialize_new_state ( st , c , policy , 0 , NULL_FD , pcim_stranger_crypto ) ; st -> st_ikev2 = TRUE ; change_state ( st , STATE_PARENT_R1 ) ; st -> st_msgid_lastack = INVALID_MSGID ; st -> st_msgid_nextuse = 0 ; md -> st = st ; md -> from_state = STATE_IKEv2_BASE ; } if ( force_busy == TRUE ) { u_char dcookie [ SHA1_DIGEST_SIZE ] ; chunk_t dc ; ikev2_get_dcookie ( dcookie , st -> st_ni , & md -> sender , st -> st_icookie ) ; dc . ptr = dcookie ; dc . len = SHA1_DIGEST_SIZE ; if ( md -> chain [ ISAKMP_NEXT_v2KE ] && md -> chain [ ISAKMP_NEXT_v2N ] && ( md -> chain [ ISAKMP_NEXT_v2N ] -> payload . v2n . isan_type == v2N_COOKIE ) ) { u_int8_t spisize ; const pb_stream * dc_pbs ; chunk_t blob ; DBG ( DBG_CONTROLMORE , DBG_log ( ""receivedaDOScookieinI1verifyit"" ) ) ; spisize = md -> chain [ ISAKMP_NEXT_v2N ] -> payload . v2n . isan_spisize ; dc_pbs = & md -> chain [ ISAKMP_NEXT_v2N ] -> pbs ; blob . ptr = dc_pbs -> cur + spisize ; blob . len = pbs_left ( dc_pbs ) - spisize ; DBG ( DBG_CONTROLMORE , DBG_dump_chunk ( ""dcookiereceivedinI1Packet"" , blob ) ; DBG_dump ( ""dcookiecomputed"" , dcookie , SHA1_DIGEST_SIZE ) ) ; if ( memcmp ( blob . ptr , dcookie , SHA1_DIGEST_SIZE ) != 0 ) { libreswan_log ( ""mismatchinDOSv2N_COOKIE,sendanewone"" ) ; SEND_NOTIFICATION_AA ( v2N_COOKIE , & dc ) ; return STF_FAIL + v2N_INVALID_IKE_SPI ; } DBG ( DBG_CONTROLMORE , DBG_log ( ""dcookiereceivedmatchwithcomputedone"" ) ) ; } else { DBG ( DBG_CONTROLMORE , DBG_log ( ""busymodeon.receievedI1withoutavaliddcookie"" ) ; DBG_log ( ""sendadcookieandforgetthisstate"" ) ) ; SEND_NOTIFICATION_AA ( v2N_COOKIE , & dc ) ; return STF_FAIL ; } } else { DBG ( DBG_CONTROLMORE , DBG_log ( ""willnotsend/processadcookie"" ) ) ; } { struct ikev2_ke * ke ; ke = & md -> chain [ ISAKMP_NEXT_v2KE ] -> payload . v2ke ; st -> st_oakley . group = lookup_group ( ke -> isak_group ) ; if ( st -> st_oakley . group == NULL ) { char fromname [ ADDRTOT_BUF ] ; addrtot ( & md -> sender , 0 , fromname , ADDRTOT_BUF ) ; libreswan_log ( ""rejectingI1from%s:%u,invalidDHgroup=%u"" , fromname , md -> sender_port , ke -> isak_group ) ; return v2N_INVALID_KE_PAYLOAD ; } } { struct ke_continuation * ke = alloc_thing ( struct ke_continuation , ""ikev2_inI1outR1KE"" ) ; stf_status e ; ke -> md = md ; set_suspended ( st , ke -> md ) ; if ( ! st -> st_sec_in_use ) { pcrc_init ( & ke -> ke_pcrc ) ; ke -> ke_pcrc . pcrc_func = ikev2_parent_inI1outR1_continue ; e = build_ke ( & ke -> ke_pcrc , st , st -> st_oakley . group , pcim_stranger_crypto ) ; if ( e != STF_SUSPEND && e != STF_INLINE ) { loglog ( RC_CRYPTOFAILED , ""systemtoobusy"" ) ; delete_state ( st ) ; } } else { e = ikev2_parent_inI1outR1_tail ( ( struct pluto_crypto_req_cont * ) ke , NULL ) ; } reset_globals ( ) ; return e ; } } "," * ke ; char fromname [ ADDRTOT_BUF ) ; if ( ! md -> chain [ ISAKMP_NEXT_v2KE ] ) { if ( md -> chain [ ISAKMP_NEXT_v2N ] ) { libreswan_log ( ""ReceivedNotify(%d):%s"" , md -> chain [ ISAKMP_NEXT_v2N ] -> payload . v2n . isan_type , enum_name ( & ikev2_notify_names , md -> chain [ ISAKMP_NEXT_v2N ] -> payload . v2n . isan_type ) ) ; } libreswan_log ( ""rejectingI1from%s:%u,noKEpayloadpresent"" , fromname , md -> sender_port ) ; return STF_FAIL + v2N_INVALID_KE_PAYLOAD ; } ke = & md -> chain [ ISAKMP_NEXT_v2KE ] -> payload . v2ke ; st -> st_oakley . group = lookup_group ( ke -> isak_group ) ; if ( st -> st_oakley . group == NULL ) { libreswan_log ( ""rejectingI1from%s:%u,invalidDHgroup=%u"" , fromname ) ; return STF_FAIL + ",libreswan@libreswan/2899351224fe2940aec37d7656e1e392c0fe07f0,CVE-2013-7294,https://github.com/libreswan/libreswan/commit/2899351224fe2940aec37d7656e1e392c0fe07f0,2014-01-16T05:05Z 406,CWE-787,"CWE-787 void nsc_encode ( NSC_CONTEXT * context , const BYTE * bmpdata , UINT32 rowstride ) { nsc_encode_argb_to_aycocg ( context , bmpdata , rowstride ) ; if ( context -> ChromaSubsamplingLevel ) { nsc_encode_subsampling ( context ) ; } } "," BOOL nsc_encode ( NSC_CONTEXT rowstride ) { if ( ! context || ! bmpdata || ( rowstride == 0 ) ) return FALSE ; if ( ! , rowstride ) ) return FALSE ChromaSubsamplingLevel ) { if ( ! ( context ) ) return FALSE ; } return TRUE ; } ",FreeRDP@FreeRDP/d1112c279bd1a327e8e4d0b5f371458bf2579659,CVE-2018-8788,https://github.com/FreeRDP/FreeRDP/commit/d1112c279bd1a327e8e4d0b5f371458bf2579659,2018-11-29T18:29Z 407,CWE-119,"CWE-119 void vp9_tree_probs_from_distribution ( vp9_tree tree , unsigned int branch_ct [ ] [ 2 ] , const unsigned int num_events [ ] ) { convert_distribution ( 0 , tree , branch_ct , num_events ) ; } "," void vp9_tree_probs_from_distribution ( vpx_tree tree , unsigned ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 408,CWE-119,"CWE-119 static int hns_xgmac_get_sset_count ( int stringset ) { if ( stringset == ETH_SS_STATS ) return ARRAY_SIZE ( g_xgmac_stats_string ) ; return 0 ; } "," stringset == ETH_SS_STATS || stringset == ETH_SS_PRIV_FLAGS ",torvalds@linux/412b65d15a7f8a93794653968308fc100f2aa87c,CVE-2017-18222,https://github.com/torvalds/linux/commit/412b65d15a7f8a93794653968308fc100f2aa87c,2018-03-08T14:29Z 409,CWE-125,"CWE-125 static inline size_t GetPSDRowSize ( Image * image ) { if ( image -> depth == 1 ) return ( ( image -> columns + 7 ) / 8 ) ; else return ( image -> columns * GetPSDPacketSize ( image ) ) ; } "," return ( ( ( ) / 8 ) * GetPSDPacketSize ( image ) ",ImageMagick@ImageMagick/5f16640725b1225e6337c62526e6577f0f88edb8,CVE-2016-7525,https://github.com/ImageMagick/ImageMagick/commit/5f16640725b1225e6337c62526e6577f0f88edb8,2017-04-20T18:59Z 410,CWE-284,"CWE-284 void bta_hh_co_open ( UINT8 dev_handle , UINT8 sub_class , tBTA_HH_ATTR_MASK attr_mask , UINT8 app_id ) { UINT32 i ; btif_hh_device_t * p_dev = NULL ; if ( dev_handle == BTA_HH_INVALID_HANDLE ) { APPL_TRACE_WARNING ( ""%s:Oops,dev_handle(%d)isinvalid..."" , __FUNCTION__ , dev_handle ) ; return ; } for ( i = 0 ; i < BTIF_HH_MAX_HID ; i ++ ) { p_dev = & btif_hh_cb . devices [ i ] ; if ( p_dev -> dev_status != BTHH_CONN_STATE_UNKNOWN && p_dev -> dev_handle == dev_handle ) { APPL_TRACE_WARNING ( ""%s:Foundanexistingdevicewiththesamehandle"" ""dev_status=%d"" , __FUNCTION__ , p_dev -> dev_status ) ; APPL_TRACE_WARNING ( ""%s:bd_addr=[%02X:%02X:%02X:%02X:%02X:]"" , __FUNCTION__ , p_dev -> bd_addr . address [ 0 ] , p_dev -> bd_addr . address [ 1 ] , p_dev -> bd_addr . address [ 2 ] , p_dev -> bd_addr . address [ 3 ] , p_dev -> bd_addr . address [ 4 ] ) ; APPL_TRACE_WARNING ( ""%s:attr_mask=0x%04x,sub_class=0x%02x,app_id=%d"" , __FUNCTION__ , p_dev -> attr_mask , p_dev -> sub_class , p_dev -> app_id ) ; if ( p_dev -> fd < 0 ) { p_dev -> fd = open ( dev_path , O_RDWR | O_CLOEXEC ) ; if ( p_dev -> fd < 0 ) { APPL_TRACE_ERROR ( ""%s:Error:failedtoopenuhid,err:%s"" , __FUNCTION__ , strerror ( errno ) ) ; return ; } else APPL_TRACE_DEBUG ( ""%s:uhidfd=%d"" , __FUNCTION__ , p_dev -> fd ) ; } p_dev -> hh_keep_polling = 1 ; p_dev -> hh_poll_thread_id = create_thread ( btif_hh_poll_event_thread , p_dev ) ; break ; } p_dev = NULL ; } if ( p_dev == NULL ) { for ( i = 0 ; i < BTIF_HH_MAX_HID ; i ++ ) { if ( btif_hh_cb . devices [ i ] . dev_status == BTHH_CONN_STATE_UNKNOWN ) { p_dev = & btif_hh_cb . devices [ i ] ; p_dev -> dev_handle = dev_handle ; p_dev -> attr_mask = attr_mask ; p_dev -> sub_class = sub_class ; p_dev -> app_id = app_id ; p_dev -> local_vup = FALSE ; btif_hh_cb . device_num ++ ; p_dev -> fd = open ( dev_path , O_RDWR | O_CLOEXEC ) ; if ( p_dev -> fd < 0 ) { APPL_TRACE_ERROR ( ""%s:Error:failedtoopenuhid,err:%s"" , __FUNCTION__ , strerror ( errno ) ) ; return ; } else { APPL_TRACE_DEBUG ( ""%s:uhidfd=%d"" , __FUNCTION__ , p_dev -> fd ) ; p_dev -> hh_keep_polling = 1 ; p_dev -> hh_poll_thread_id = create_thread ( btif_hh_poll_event_thread , p_dev ) ; } break ; } } } if ( p_dev == NULL ) { APPL_TRACE_ERROR ( ""%s:Error:toomanyHIDdevicesareconnected"" , __FUNCTION__ ) ; return ; } p_dev -> dev_status = BTHH_CONN_STATE_CONNECTED ; APPL_TRACE_DEBUG ( ""%s:Returndevicestatus%d"" , __FUNCTION__ , p_dev -> dev_status ) ; } "," -> fd = TEMP_FAILURE_RETRY ( | O_CLOEXEC ) ) -> fd = TEMP_FAILURE_RETRY ( | O_CLOEXEC ) ) ",system@bt/472271b153c5dc53c28beac55480a8d8434b2d5c,CVE-2016-3839,https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c,2016-08-05T20:59Z 411,CWE-000,"CWE-000 static int ims_pcu_parse_cdc_data ( struct usb_interface * intf , struct ims_pcu * pcu ) { const struct usb_cdc_union_desc * union_desc ; struct usb_host_interface * alt ; union_desc = ims_pcu_get_cdc_union_desc ( intf ) ; if ( ! union_desc ) return - EINVAL ; pcu -> ctrl_intf = usb_ifnum_to_if ( pcu -> udev , union_desc -> bMasterInterface0 ) ; alt = pcu -> ctrl_intf -> cur_altsetting ; pcu -> ep_ctrl = & alt -> endpoint [ 0 ] . desc ; pcu -> max_ctrl_size = usb_endpoint_maxp ( pcu -> ep_ctrl ) ; pcu -> data_intf = usb_ifnum_to_if ( pcu -> udev , union_desc -> bSlaveInterface0 ) ; alt = pcu -> data_intf -> cur_altsetting ; if ( alt -> desc . bNumEndpoints != 2 ) { dev_err ( pcu -> dev , ""Incorrectnumberofendpointsondatainterface(%d)\\n"" , alt -> desc . bNumEndpoints ) ; return - EINVAL ; } pcu -> ep_out = & alt -> endpoint [ 0 ] . desc ; if ( ! usb_endpoint_is_bulk_out ( pcu -> ep_out ) ) { dev_err ( pcu -> dev , ""FirstendpointondatainterfaceisnotBULKOUT\\n"" ) ; return - EINVAL ; } pcu -> max_out_size = usb_endpoint_maxp ( pcu -> ep_out ) ; if ( pcu -> max_out_size < 8 ) { dev_err ( pcu -> dev , ""MaxOUTpacketsizeistoosmall(%zd)\\n"" , pcu -> max_out_size ) ; return - EINVAL ; } pcu -> ep_in = & alt -> endpoint [ 1 ] . desc ; if ( ! usb_endpoint_is_bulk_in ( pcu -> ep_in ) ) { dev_err ( pcu -> dev , ""SecondendpointondatainterfaceisnotBULKIN\\n"" ) ; return - EINVAL ; } pcu -> max_in_size = usb_endpoint_maxp ( pcu -> ep_in ) ; if ( pcu -> max_in_size < 8 ) { dev_err ( pcu -> dev , ""MaxINpacketsizeistoosmall(%zd)\\n"" , pcu -> max_in_size ) ; return - EINVAL ; } return 0 ; } "," bMasterInterface0 ) ; if ( ! pcu -> ctrl_intf ) return - EINVAL ; bSlaveInterface0 ) ; if ( ! pcu -> data_intf ) return - EINVAL ; ",torvalds@linux/a0ad220c96692eda76b2e3fd7279f3dcd1d8a8ff,CVE-2016-3689,https://github.com/torvalds/linux/commit/a0ad220c96692eda76b2e3fd7279f3dcd1d8a8ff,2016-05-02T10:59Z 412,CWE-119,"CWE-119 void dvb_usbv2_disconnect ( struct usb_interface * intf ) { struct dvb_usb_device * d = usb_get_intfdata ( intf ) ; const char * name = d -> name ; struct device dev = d -> udev -> dev ; dev_dbg ( & d -> udev -> dev , ""%s:bInterfaceNumber=%d\\n"" , __func__ , intf -> cur_altsetting -> desc . bInterfaceNumber ) ; if ( d -> props -> exit ) d -> props -> exit ( d ) ; dvb_usbv2_exit ( d ) ; dev_info ( & dev , ""%s:\'%s\'successfullydeinitializedanddisconnected\\n"" , KBUILD_MODNAME , name ) ; } "," const char * devname = kstrdup ( dev_name ( & d -> udev udev -> dev ) , GFP_KERNEL ) ; const char * drvname = d -> name d ) ; pr_info ( ""%s:\'%s:%s\'successfullydeinitializedanddisconnected\\n"" , KBUILD_MODNAME , , KBUILD_MODNAME , drvname , devname ) ; kfree ( devname ) ; } ",torvalds@linux/005145378c9ad7575a01b6ce1ba118fb427f583a,CVE-2017-8064,https://github.com/torvalds/linux/commit/005145378c9ad7575a01b6ce1ba118fb427f583a,2017-04-23T05:59Z 413,CWE-125,"CWE-125 static int jpc_pi_nextpcrl ( register jpc_pi_t * pi ) { int rlvlno ; jpc_pirlvl_t * pirlvl ; jpc_pchg_t * pchg ; int prchind ; int prcvind ; int * prclyrno ; int compno ; jpc_picomp_t * picomp ; int xstep ; int ystep ; uint_fast32_t trx0 ; uint_fast32_t try0 ; uint_fast32_t r ; uint_fast32_t rpx ; uint_fast32_t rpy ; pchg = pi -> pchg ; if ( ! pi -> prgvolfirst ) { goto skip ; } else { pi -> xstep = 0 ; pi -> ystep = 0 ; for ( compno = 0 , picomp = pi -> picomps ; compno < pi -> numcomps ; ++ compno , ++ picomp ) { for ( rlvlno = 0 , pirlvl = picomp -> pirlvls ; rlvlno < picomp -> numrlvls ; ++ rlvlno , ++ pirlvl ) { xstep = picomp -> hsamp * ( 1 << ( pirlvl -> prcwidthexpn + picomp -> numrlvls - rlvlno - 1 ) ) ; ystep = picomp -> vsamp * ( 1 << ( pirlvl -> prcheightexpn + picomp -> numrlvls - rlvlno - 1 ) ) ; pi -> xstep = ( ! pi -> xstep ) ? xstep : JAS_MIN ( pi -> xstep , xstep ) ; pi -> ystep = ( ! pi -> ystep ) ? ystep : JAS_MIN ( pi -> ystep , ystep ) ; } } pi -> prgvolfirst = 0 ; } for ( pi -> y = pi -> ystart ; pi -> y < pi -> yend ; pi -> y += pi -> ystep - ( pi -> y % pi -> ystep ) ) { for ( pi -> x = pi -> xstart ; pi -> x < pi -> xend ; pi -> x += pi -> xstep - ( pi -> x % pi -> xstep ) ) { for ( pi -> compno = pchg -> compnostart , pi -> picomp = & pi -> picomps [ pi -> compno ] ; pi -> compno < pi -> numcomps && pi -> compno < JAS_CAST ( int , pchg -> compnoend ) ; ++ pi -> compno , ++ pi -> picomp ) { for ( pi -> rlvlno = pchg -> rlvlnostart , pi -> pirlvl = & pi -> picomp -> pirlvls [ pi -> rlvlno ] ; pi -> rlvlno < pi -> picomp -> numrlvls && pi -> rlvlno < pchg -> rlvlnoend ; ++ pi -> rlvlno , ++ pi -> pirlvl ) { if ( pi -> pirlvl -> numprcs == 0 ) { continue ; } r = pi -> picomp -> numrlvls - 1 - pi -> rlvlno ; trx0 = JPC_CEILDIV ( pi -> xstart , pi -> picomp -> hsamp << r ) ; try0 = JPC_CEILDIV ( pi -> ystart , pi -> picomp -> vsamp << r ) ; rpx = r + pi -> pirlvl -> prcwidthexpn ; rpy = r + pi -> pirlvl -> prcheightexpn ; if ( ( ( pi -> x == pi -> xstart && ( ( trx0 << r ) % ( 1 << rpx ) ) ) || ! ( pi -> x % ( pi -> picomp -> hsamp << rpx ) ) ) && ( ( pi -> y == pi -> ystart && ( ( try0 << r ) % ( 1 << rpy ) ) ) || ! ( pi -> y % ( pi -> picomp -> vsamp << rpy ) ) ) ) { prchind = JPC_FLOORDIVPOW2 ( JPC_CEILDIV ( pi -> x , pi -> picomp -> hsamp << r ) , pi -> pirlvl -> prcwidthexpn ) - JPC_FLOORDIVPOW2 ( trx0 , pi -> pirlvl -> prcwidthexpn ) ; prcvind = JPC_FLOORDIVPOW2 ( JPC_CEILDIV ( pi -> y , pi -> picomp -> vsamp << r ) , pi -> pirlvl -> prcheightexpn ) - JPC_FLOORDIVPOW2 ( try0 , pi -> pirlvl -> prcheightexpn ) ; pi -> prcno = prcvind * pi -> pirlvl -> numhprcs + prchind ; assert ( pi -> prcno < pi -> pirlvl -> numprcs ) ; for ( pi -> lyrno = 0 ; pi -> lyrno < pi -> numlyrs && pi -> lyrno < JAS_CAST ( int , pchg -> lyrnoend ) ; ++ pi -> lyrno ) { prclyrno = & pi -> pirlvl -> prclyrnos [ pi -> prcno ] ; if ( pi -> lyrno >= * prclyrno ) { ++ ( * prclyrno ) ; return 0 ; } skip : ; } } } } } } return 1 ; } "," pirlvl ) { if ( pirlvl -> prcwidthexpn + pi -> picomp -> numrlvls > JAS_UINTFAST32_NUMBITS - 2 || pirlvl -> prcheightexpn + pi -> picomp -> numrlvls > JAS_UINTFAST32_NUMBITS - 2 ) { return - 1 ; } hsamp * ( JAS_CAST ( uint_fast32_t , 1 ) << ( pirlvl vsamp * ( JAS_CAST ( uint_fast32_t , 1 ) << ( pirlvl ) % ( JAS_CAST ( uint_fast32_t , 1 ) << rpx ) ) % ( JAS_CAST ( uint_fast32_t , 1 ) << rpy ) ",mdadams@jasper/aa0b0f79ade5eef8b0e7a214c03f5af54b36ba7d,CVE-2016-9583,https://github.com/mdadams/jasper/commit/aa0b0f79ade5eef8b0e7a214c03f5af54b36ba7d,2018-08-01T17:29Z 414,CWE-416,"CWE-416 extern int onig_new_deluxe ( regex_t * * reg , const UChar * pattern , const UChar * pattern_end , OnigCompileInfo * ci , OnigErrorInfo * einfo ) { int r ; UChar * cpat , * cpat_end ; if ( IS_NOT_NULL ( einfo ) ) einfo -> par = ( UChar * ) NULL ; if ( ci -> pattern_enc != ci -> target_enc ) { r = conv_encoding ( ci -> pattern_enc , ci -> target_enc , pattern , pattern_end , & cpat , & cpat_end ) ; if ( r != 0 ) return r ; } else { cpat = ( UChar * ) pattern ; cpat_end = ( UChar * ) pattern_end ; } * reg = ( regex_t * ) xmalloc ( sizeof ( regex_t ) ) ; if ( IS_NULL ( * reg ) ) { r = ONIGERR_MEMORY ; goto err2 ; } r = onig_reg_init ( * reg , ci -> option , ci -> case_fold_flag , ci -> target_enc , ci -> syntax ) ; if ( r != 0 ) goto err ; r = onig_compile ( * reg , cpat , cpat_end , einfo ) ; if ( r != 0 ) { err : onig_free ( * reg ) ; * reg = NULL ; } err2 : if ( cpat != pattern ) xfree ( cpat ) ; return r ; } "," target_enc ) { return ONIGERR_NOT_SUPPORTED_ENCODING_COMBINATION ; } else ",kkos@oniguruma/0f7f61ed1b7b697e283e37bd2d731d0bd57adb55,CVE-2019-13224,https://github.com/kkos/oniguruma/commit/0f7f61ed1b7b697e283e37bd2d731d0bd57adb55,2019-07-10T14:15Z 415,CWE-787,"CWE-787 static void InsertRow ( Image * image , ssize_t depth , unsigned char * p , ssize_t y , ExceptionInfo * exception ) { size_t bit ; ssize_t x ; register Quantum * q ; Quantum index ; index = 0 ; switch ( depth ) { case 1 : { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ( ssize_t ) image -> columns - 7 ) ; x += 8 ) { for ( bit = 0 ; bit < 8 ; bit ++ ) { index = ( Quantum ) ( ( ( ( * p ) & ( 0x80 >> bit ) ) != 0 ) ? 0x01 : 0x00 ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } if ( ( image -> columns % 8 ) != 0 ) { for ( bit = 0 ; bit < ( image -> columns % 8 ) ; bit ++ ) { index = ( Quantum ) ( ( ( ( * p ) & ( 0x80 >> bit ) ) != 0 ) ? 0x01 : 0x00 ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } ( void ) SyncAuthenticPixels ( image , exception ) ; break ; } case 2 : { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ( ssize_t ) image -> columns - 1 ) ; x += 2 ) { index = ConstrainColormapIndex ( image , ( * p >> 6 ) & 0x3 , exception ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; index = ConstrainColormapIndex ( image , ( * p >> 4 ) & 0x3 , exception ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; index = ConstrainColormapIndex ( image , ( * p >> 2 ) & 0x3 , exception ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; index = ConstrainColormapIndex ( image , ( * p ) & 0x3 , exception ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; p ++ ; } if ( ( image -> columns % 4 ) != 0 ) { index = ConstrainColormapIndex ( image , ( * p >> 6 ) & 0x3 , exception ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; if ( ( image -> columns % 4 ) >= 1 ) { index = ConstrainColormapIndex ( image , ( * p >> 4 ) & 0x3 , exception ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; if ( ( image -> columns % 4 ) >= 2 ) { index = ConstrainColormapIndex ( image , ( * p >> 2 ) & 0x3 , exception ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; } } p ++ ; } ( void ) SyncAuthenticPixels ( image , exception ) ; break ; } case 4 : { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ( ssize_t ) image -> columns - 1 ) ; x += 2 ) { index = ConstrainColormapIndex ( image , ( * p >> 4 ) & 0xf , exception ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; index = ConstrainColormapIndex ( image , ( * p ) & 0xf , exception ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; p ++ ; } if ( ( image -> columns % 2 ) != 0 ) { index = ConstrainColormapIndex ( image , ( * p >> 4 ) & 0xf , exception ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; p ++ ; } ( void ) SyncAuthenticPixels ( image , exception ) ; break ; } case 8 : { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { index = ConstrainColormapIndex ( image , * p , exception ) ; SetPixelIndex ( image , index , q ) ; p ++ ; q += GetPixelChannels ( image ) ; } ( void ) SyncAuthenticPixels ( image , exception ) ; break ; } } } "," static MagickBooleanType InsertRow ( Image image , ssize_t bpp , unsigned char exception ) { int bit ; Quantum index ; register Quantum ; register Quantum * q ; ssize_t x ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) return ( MagickFalse ) ; switch ( ; switch ( bpp ) { case 1 : { for ( x index = ( ( * p 0x80 >> bit ) ? 0x01 q ) ; if ( index < image -> colors ) SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) index , q ) ; bit < ( ssize_t ) ( index = ( ( * p 0x80 >> bit ) ? 0x01 q ) ; if ( index < image -> colors ) SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) index , q ) ; SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) index , q ) ; ++ ; } break ; } 2 : { for ( x = 0 ; x < ( ( ssize_t ) image -> columns image -> columns - 3 ) ; x += 4 ) { index = ConstrainColormapIndex ( image , ( * p >> 6 ) & 0x3 , exception ) ; SetPixelIndex ( image , index , q ) ; if ( index < image -> colors ) SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) index , q ) ; q += GetPixelChannels ( image ) ; index = ConstrainColormapIndex ( image , ( * p >> 4 ) & 0x3 , exception ) ; SetPixelIndex ( image , index , q ) ; if ( index < image -> colors ) SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) index , q ) ; q += GetPixelChannels ( image ) ; index = ConstrainColormapIndex ( image , ( * p >> 2 ) & 0x3 , exception ) ; SetPixelIndex ( image , index , q ) ; if ( index < image -> colors ) SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) index , q ) ; q += GetPixelChannels ( image ) ; index = ConstrainColormapIndex ( image , ( * p ) & 0x3 , exception ) ; SetPixelIndex ( image , index , q ) ; if ( index < image -> colors ) SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) index , q ) ; q += GetPixelChannels ( image ) ; p ++ ; } if ( ( image -> columns % 4 ) != 0 ) { index = ConstrainColormapIndex ( image , ( * p >> 6 ) & 0x3 , exception ) ; SetPixelIndex ( image , index , q ) ; if ( index < image -> colors ) SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) index , q ) ; q += GetPixelChannels ( image ) ; if ( ( image -> columns % 4 ) > 1 ) { index = ConstrainColormapIndex ( image , ( * p >> 4 ) & 0x3 , exception ) exception ) ; SetPixelIndex ( image , index , q ) ; if ( index < image -> colors ) SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) index , q ) ; q += GetPixelChannels ( image ) ; if ( ( image -> columns % 4 ) > 2 ) { index = ConstrainColormapIndex ( image , ( * p >> 2 ) & 0x3 , exception ) ; SetPixelIndex ( image , index , q ) ; if ( index < image -> colors ) SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) index , q ) ; q += GetPixelChannels ( image ) ; } } p ++ ; } break ; } case 4 : { for ( x * p >> 4 ) & 0x0f , exception ) q ) ; if ( index < image -> colors ) SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) index , q ) ; ( * p ) & 0x0f , exception ) q ) ; if ( index < image -> colors ) SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) index , q ) ; p ++ ; ( image ) ; } if 4 ) & 0x0f , exception ) q ) ; if ( index < image -> colors ) SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) index , q ) ; p ++ ; image ) ; } break ; } 8 : { for ( x = 0 ; x < ( ssize_t ) image -> columns image -> columns ; x ++ ) { index = ConstrainColormapIndex ( image , * p , exception ) exception ) ; SetPixelIndex ( image , index , q ) ; if ( index < image -> colors ) SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) index , q ) ; p ++ ; q += GetPixelChannels ( image ) ; } } break ; case 24 : for ( x ++ ) { SetPixelRed ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelGreen ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelBlue ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; q += GetPixelChannels ( image ) ; } break ; } if ( ! SyncAuthenticPixels ( image , exception ) , exception ) ) return ( MagickFalse ) ; return ( MagickTrue ) ; } ",ImageMagick@ImageMagick/cc4ac341f29fa368da6ef01c207deaf8c61f6a2e,CVE-2018-16642,https://github.com/ImageMagick/ImageMagick/commit/cc4ac341f29fa368da6ef01c207deaf8c61f6a2e,2018-09-06T22:29Z 416,CWE-125,"CWE-125 static int cfm_network_addr_print ( netdissect_options * ndo , register const u_char * tptr ) { u_int network_addr_type ; u_int hexdump = FALSE ; network_addr_type = * tptr ; ND_PRINT ( ( ndo , ""\\n\\tNetworkAddressType%s(%u)"" , tok2str ( af_values , ""Unknown"" , network_addr_type ) , network_addr_type ) ) ; switch ( network_addr_type ) { case AFNUM_INET : ND_PRINT ( ( ndo , "",%s"" , ipaddr_string ( ndo , tptr + 1 ) ) ) ; break ; case AFNUM_INET6 : ND_PRINT ( ( ndo , "",%s"" , ip6addr_string ( ndo , tptr + 1 ) ) ) ; break ; default : hexdump = TRUE ; break ; } return hexdump ; } "," u_char * tptr , const u_int length ) { u_int network_addr_type ; u_int hexdump = FALSE = FALSE ; if ( length < 1 ) { ND_PRINT ( ( ndo , ""\\n\\tNetworkAddressType(invalid,nodata"" ) ) ; return hexdump ; } case AFNUM_INET : if ( length != 1 + 4 ) { ND_PRINT ( ( ndo , ""(invalidIPv4addresslength%u)"" , length - 1 ) ) ; hexdump = TRUE ; break ; } case AFNUM_INET6 : if ( length != 1 + 16 ) { ND_PRINT ( ( ndo , ""(invalidIPv6addresslength%u)"" , length - 1 ) ) ; hexdump = TRUE ; break ; } ",the-tcpdump-group@tcpdump/5d340a5ca6e420a70297cdbdf777333f18bfdab7,CVE-2017-13052,https://github.com/the-tcpdump-group/tcpdump/commit/5d340a5ca6e420a70297cdbdf777333f18bfdab7,2017-09-14T06:29Z 417,CWE-264,"CWE-264 static int em_sysexit ( struct x86_emulate_ctxt * ctxt ) { const struct x86_emulate_ops * ops = ctxt -> ops ; struct desc_struct cs , ss ; u64 msr_data ; int usermode ; u16 cs_sel = 0 , ss_sel = 0 ; if ( ctxt -> mode == X86EMUL_MODE_REAL || ctxt -> mode == X86EMUL_MODE_VM86 ) return emulate_gp ( ctxt , 0 ) ; setup_syscalls_segments ( ctxt , & cs , & ss ) ; if ( ( ctxt -> rex_prefix & 0x8 ) != 0x0 ) usermode = X86EMUL_MODE_PROT64 ; else usermode = X86EMUL_MODE_PROT32 ; cs . dpl = 3 ; ss . dpl = 3 ; ops -> get_msr ( ctxt , MSR_IA32_SYSENTER_CS , & msr_data ) ; switch ( usermode ) { case X86EMUL_MODE_PROT32 : cs_sel = ( u16 ) ( msr_data + 16 ) ; if ( ( msr_data & 0xfffc ) == 0x0 ) return emulate_gp ( ctxt , 0 ) ; ss_sel = ( u16 ) ( msr_data + 24 ) ; break ; case X86EMUL_MODE_PROT64 : cs_sel = ( u16 ) ( msr_data + 32 ) ; if ( msr_data == 0x0 ) return emulate_gp ( ctxt , 0 ) ; ss_sel = cs_sel + 8 ; cs . d = 0 ; cs . l = 1 ; break ; } cs_sel |= SELECTOR_RPL_MASK ; ss_sel |= SELECTOR_RPL_MASK ; ops -> set_segment ( ctxt , cs_sel , & cs , 0 , VCPU_SREG_CS ) ; ops -> set_segment ( ctxt , ss_sel , & ss , 0 , VCPU_SREG_SS ) ; ctxt -> _eip = reg_read ( ctxt , VCPU_REGS_RDX ) ; * reg_write ( ctxt , VCPU_REGS_RSP ) = reg_read ( ctxt , VCPU_REGS_RCX ) ; return X86EMUL_CONTINUE ; } "," ; u64 msr_data , rcx , rdx = X86EMUL_MODE_PROT32 ; rcx = reg_read ( ctxt , VCPU_REGS_RCX ) ; rdx = reg_read ( ctxt , VCPU_REGS_RDX ) ; = 1 ; if ( is_noncanonical_address ( rcx ) || is_noncanonical_address ( rdx ) ) return emulate_gp ( ctxt , 0 ) ; -> _eip = rdx ; * reg_write VCPU_REGS_RSP ) = rcx ; return X86EMUL_CONTINUE ",torvalds@linux/234f3ce485d54017f15cf5e0699cff4100121601,CVE-2014-3647,https://github.com/torvalds/linux/commit/234f3ce485d54017f15cf5e0699cff4100121601,2014-11-10T11:55Z 418,CWE-362,"CWE-362 static ssize_t driver_override_show ( struct device * dev , struct device_attribute * attr , char * buf ) { struct platform_device * pdev = to_platform_device ( dev ) ; return sprintf ( buf , ""%s\\n"" , pdev -> driver_override ) ; } "," dev ) ; ssize_t len ; device_lock ( dev ) ; len = sprintf ( buf driver_override ) ; device_unlock ( dev ) ; return len ; ",torvalds@linux/6265539776a0810b7ce6398c27866ddb9c6bd154,CVE-2017-12146,https://github.com/torvalds/linux/commit/6265539776a0810b7ce6398c27866ddb9c6bd154,2017-09-08T19:29Z 419,CWE-399,"CWE-399 static int cms_copy_content ( BIO * out , BIO * in , unsigned int flags ) { unsigned char buf [ 4096 ] ; int r = 0 , i ; BIO * tmpout = NULL ; if ( out == NULL ) tmpout = BIO_new ( BIO_s_null ( ) ) ; else if ( flags & CMS_TEXT ) { tmpout = BIO_new ( BIO_s_mem ( ) ) ; BIO_set_mem_eof_return ( tmpout , 0 ) ; } else tmpout = out ; if ( ! tmpout ) { CMSerr ( CMS_F_CMS_COPY_CONTENT , ERR_R_MALLOC_FAILURE ) ; goto err ; } for ( ; ; ) { i = BIO_read ( in , buf , sizeof ( buf ) ) ; if ( i <= 0 ) { if ( BIO_method_type ( in ) == BIO_TYPE_CIPHER ) { if ( ! BIO_get_cipher_status ( in ) ) goto err ; } if ( i < 0 ) goto err ; break ; } if ( tmpout && ( BIO_write ( tmpout , buf , i ) != i ) ) goto err ; } if ( flags & CMS_TEXT ) { if ( ! SMIME_text ( tmpout , out ) ) { CMSerr ( CMS_F_CMS_COPY_CONTENT , CMS_R_SMIME_TEXT_ERROR ) ; goto err ; } } r = 1 ; err : if ( tmpout && ( tmpout != out ) ) BIO_free ( tmpout ) ; return r ; } "," BIO * tmpout ; tmpout = cms_get_text_bio ( out , flags ) ; if ( ! tmpout ) { CMSerr ( CMS_F_CMS_COPY_CONTENT , ERR_R_MALLOC_FAILURE ) ; goto err ; } for ( ; ; ) { i = BIO_read ( in , buf , sizeof ( buf ) ) ; if ( i <= 0 ) { if ( BIO_method_type ( in ) == BIO_TYPE_CIPHER ) { if ( ! BIO_get_cipher_status ( in ) ) goto err ; } if ( i < 0 ) goto err ; break ; } if ( tmpout && ( BIO_write ( tmpout , buf , i ) != i ) ) goto err ; } if ( flags CMS_TEXT ) { if ( ! ",openssl@openssl/cd30f03ac5bf2962f44bd02ae8d88245dff2f12c,CVE-2015-1792,https://github.com/openssl/openssl/commit/cd30f03ac5bf2962f44bd02ae8d88245dff2f12c,2015-06-12T19:59Z 420,CWE-264,"CWE-264 static void on_response ( void * data , krb5_error_code retval , otp_response response ) { struct request_state rs = * ( struct request_state * ) data ; free ( data ) ; if ( retval == 0 && response != otp_response_success ) retval = KRB5_PREAUTH_FAILED ; rs . respond ( rs . arg , retval , NULL , NULL , NULL ) ; } "," = KRB5_PREAUTH_FAILED ; if ( retval == 0 ) rs . enc_tkt_reply -> flags |= TKT_FLG_PRE_AUTH ; ",krb5@krb5/e3b5a5e5267818c97750b266df50b6a3d4649604,CVE-2015-2694,https://github.com/krb5/krb5/commit/e3b5a5e5267818c97750b266df50b6a3d4649604,2015-05-25T19:59Z 421,CWE-119,"CWE-119 static void cost ( int * costs , vp9_tree tree , const vp9_prob * probs , int i , int c ) { const vp9_prob prob = probs [ i / 2 ] ; int b ; for ( b = 0 ; b <= 1 ; ++ b ) { const int cc = c + vp9_cost_bit ( prob , b ) ; const vp9_tree_index ii = tree [ i + b ] ; if ( ii <= 0 ) costs [ - ii ] = cc ; else cost ( costs , tree , probs , ii , cc ) ; } } "," * costs , vpx_tree tree , const tree , const vpx_prob * probs , ) { const vpx_prob prob = probs ) ; const vpx_tree_index ii = tree ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 422,CWE-59,"CWE-59 void init_rc ( void ) { int i ; struct stat st ; FILE * f ; if ( rc_dir != NULL ) goto open_rc ; rc_dir = expandPath ( RC_DIR ) ; i = strlen ( rc_dir ) ; if ( i > 1 && rc_dir [ i - 1 ] == '/' ) rc_dir [ i - 1 ] = '\\0' ; # ifdef USE_M17N display_charset_str = wc_get_ces_list ( ) ; document_charset_str = display_charset_str ; system_charset_str = display_charset_str ; # endif if ( stat ( rc_dir , & st ) < 0 ) { if ( errno == ENOENT ) { if ( do_mkdir ( rc_dir , 0700 ) < 0 ) { goto rc_dir_err ; } else { stat ( rc_dir , & st ) ; } } else { goto rc_dir_err ; } } if ( ! S_ISDIR ( st . st_mode ) ) { goto rc_dir_err ; } if ( ! ( st . st_mode & S_IWUSR ) ) { goto rc_dir_err ; } no_rc_dir = FALSE ; tmp_dir = rc_dir ; if ( config_file == NULL ) config_file = rcFile ( CONFIG_FILE ) ; create_option_search_table ( ) ; open_rc : if ( ( f = fopen ( etcFile ( W3MCONFIG ) , ""rt"" ) ) != NULL ) { interpret_rc ( f ) ; fclose ( f ) ; } if ( ( f = fopen ( confFile ( CONFIG_FILE ) , ""rt"" ) ) != NULL ) { interpret_rc ( f ) ; fclose ( f ) ; } if ( config_file && ( f = fopen ( config_file , ""rt"" ) ) != NULL ) { interpret_rc ( f ) ; fclose ( f ) ; } return ; rc_dir_err : no_rc_dir = TRUE ; if ( ( ( tmp_dir = getenv ( ""TMPDIR"" ) ) == NULL || * tmp_dir == '\\0' ) && ( ( tmp_dir = getenv ( ""TMP"" ) ) == NULL || * tmp_dir == '\\0' ) && ( ( tmp_dir = getenv ( ""TEMP"" ) ) == NULL || * tmp_dir == '\\0' ) ) tmp_dir = ""/tmp"" ; create_option_search_table ( ) ; goto open_rc ; } "," = ""/tmp"" ; # ifdef HAVE_MKDTEMP tmp_dir = mkdtemp ( Strnew_m_charp ( tmp_dir , ""/w3m-XXXXXX"" , NULL ) -> ptr ) ; if ( tmp_dir == NULL ) tmp_dir = rc_dir ; # endif ",tats@w3m/18dcbadf2771cdb0c18509b14e4e73505b242753,CVE-2018-6198,https://github.com/tats/w3m/commit/18dcbadf2771cdb0c18509b14e4e73505b242753,2018-01-25T03:29Z 423,CWE-125,"CWE-125 static inline void get_conn_text ( const conn * c , const int af , char * addr , struct sockaddr * sock_addr ) { char addr_text [ MAXPATHLEN ] ; addr_text [ 0 ] = '\\0' ; const char * protoname = ""?"" ; unsigned short port = 0 ; switch ( af ) { case AF_INET : ( void ) inet_ntop ( af , & ( ( struct sockaddr_in * ) sock_addr ) -> sin_addr , addr_text , sizeof ( addr_text ) - 1 ) ; port = ntohs ( ( ( struct sockaddr_in * ) sock_addr ) -> sin_port ) ; protoname = IS_UDP ( c -> transport ) ? ""udp"" : ""tcp"" ; break ; case AF_INET6 : addr_text [ 0 ] = '[' ; addr_text [ 1 ] = '\\0' ; if ( inet_ntop ( af , & ( ( struct sockaddr_in6 * ) sock_addr ) -> sin6_addr , addr_text + 1 , sizeof ( addr_text ) - 2 ) ) { strcat ( addr_text , ""]"" ) ; } port = ntohs ( ( ( struct sockaddr_in6 * ) sock_addr ) -> sin6_port ) ; protoname = IS_UDP ( c -> transport ) ? ""udp6"" : ""tcp6"" ; break ; case AF_UNIX : strncpy ( addr_text , ( ( struct sockaddr_un * ) sock_addr ) -> sun_path , sizeof ( addr_text ) - 1 ) ; addr_text [ sizeof ( addr_text ) - 1 ] = '\\0' ; protoname = ""unix"" ; break ; } if ( strlen ( addr_text ) < 2 ) { sprintf ( addr_text , ""%d>"" , af ) ; } if ( port ) { sprintf ( addr , ""%s:%s:%u"" , protoname , addr_text , port ) ; } else { sprintf ( addr , ""%s:%s"" , protoname , addr_text ) ; } } "," = 0 ; size_t pathlen = 0 ; case AF_UNIX : pathlen = sizeof ( ( ( struct ) -> sun_path ) ; if ( MAXPATHLEN <= pathlen ) { pathlen = MAXPATHLEN - 1 ; } strncpy ( addr_text , ( ( struct sockaddr_un * ) sock_addr ) -> sun_path , pathlen ) ; addr_text [ pathlen ] = '\\0' ",memcached@memcached/554b56687a19300a75ec24184746b5512580c819,CVE-2019-15026,https://github.com/memcached/memcached/commit/554b56687a19300a75ec24184746b5512580c819,2019-08-30T15:15Z 424,CWE-119,"CWE-119 static INLINE void write_buffer_16x16 ( int16_t * output , __m128i * in0 , __m128i * in1 , int stride ) { write_buffer_8x8 ( output , in0 , stride ) ; write_buffer_8x8 ( output + 8 * stride , in0 + 8 , stride ) ; output += 8 ; write_buffer_8x8 ( output , in1 , stride ) ; write_buffer_8x8 ( output + 8 * stride , in1 + 8 , stride ) ; } "," void write_buffer_16x16 ( tran_low_t * output , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 425,CWE-189,"CWE-189 int sequencer_write ( int dev , struct file * file , const char __user * buf , int count ) { unsigned char event_rec [ EV_SZ ] , ev_code ; int p = 0 , c , ev_size ; int mode = translate_mode ( file ) ; dev = dev >> 4 ; DEB ( printk ( ""sequencer_write(dev=%d,count=%d)\\n"" , dev , count ) ) ; if ( mode == OPEN_READ ) return - EIO ; c = count ; while ( c >= 4 ) { if ( copy_from_user ( ( char * ) event_rec , & ( buf ) [ p ] , 4 ) ) goto out ; ev_code = event_rec [ 0 ] ; if ( ev_code == SEQ_FULLSIZE ) { int err , fmt ; dev = * ( unsigned short * ) & event_rec [ 2 ] ; if ( dev < 0 || dev >= max_synthdev || synth_devs [ dev ] == NULL ) return - ENXIO ; if ( ! ( synth_open_mask & ( 1 << dev ) ) ) return - ENXIO ; fmt = ( * ( short * ) & event_rec [ 0 ] ) & 0xffff ; err = synth_devs [ dev ] -> load_patch ( dev , fmt , buf , p + 4 , c , 0 ) ; if ( err < 0 ) return err ; return err ; } if ( ev_code >= 128 ) { if ( seq_mode == SEQ_2 && ev_code == SEQ_EXTENDED ) { printk ( KERN_WARNING ""Sequencer:Invalidlevel2event%x\\n"" , ev_code ) ; return - EINVAL ; } ev_size = 8 ; if ( c < ev_size ) { if ( ! seq_playing ) seq_startplay ( ) ; return count - c ; } if ( copy_from_user ( ( char * ) & event_rec [ 4 ] , & ( buf ) [ p + 4 ] , 4 ) ) goto out ; } else { if ( seq_mode == SEQ_2 ) { printk ( KERN_WARNING ""Sequencer:4byteeventinlevel2mode\\n"" ) ; return - EINVAL ; } ev_size = 4 ; if ( event_rec [ 0 ] != SEQ_MIDIPUTC ) obsolete_api_used = 1 ; } if ( event_rec [ 0 ] == SEQ_MIDIPUTC ) { if ( ! midi_opened [ event_rec [ 2 ] ] ) { int err , mode ; int dev = event_rec [ 2 ] ; if ( dev >= max_mididev || midi_devs [ dev ] == NULL ) { return - ENXIO ; } mode = translate_mode ( file ) ; if ( ( err = midi_devs [ dev ] -> open ( dev , mode , sequencer_midi_input , sequencer_midi_output ) ) < 0 ) { seq_reset ( ) ; printk ( KERN_WARNING ""SequencerError:UnabletoopenMidi#%d\\n"" , dev ) ; return err ; } midi_opened [ dev ] = 1 ; } } if ( ! seq_queue ( event_rec , ( file -> f_flags & ( O_NONBLOCK ) ? 1 : 0 ) ) ) { int processed = count - c ; if ( ! seq_playing ) seq_startplay ( ) ; if ( ! processed && ( file -> f_flags & O_NONBLOCK ) ) return - EAGAIN ; else return processed ; } p += ev_size ; c -= ev_size ; } if ( ! seq_playing ) seq_startplay ( ) ; out : return count ; } "," fmt , buf + p , c , ",torvalds@linux/b769f49463711205d57286e64cf535ed4daf59e9,CVE-2011-1476,https://github.com/torvalds/linux/commit/b769f49463711205d57286e64cf535ed4daf59e9,2012-06-21T23:55Z 426,CWE-399,"CWE-399 static struct page * alloc_huge_page ( struct vm_area_struct * vma , unsigned long addr , int avoid_reserve ) { struct hstate * h = hstate_vma ( vma ) ; struct page * page ; struct address_space * mapping = vma -> vm_file -> f_mapping ; struct inode * inode = mapping -> host ; long chg ; chg = vma_needs_reservation ( h , vma , addr ) ; if ( chg < 0 ) return ERR_PTR ( - VM_FAULT_OOM ) ; if ( chg ) if ( hugetlb_get_quota ( inode -> i_mapping , chg ) ) return ERR_PTR ( - VM_FAULT_SIGBUS ) ; spin_lock ( & hugetlb_lock ) ; page = dequeue_huge_page_vma ( h , vma , addr , avoid_reserve ) ; spin_unlock ( & hugetlb_lock ) ; if ( ! page ) { page = alloc_buddy_huge_page ( h , NUMA_NO_NODE ) ; if ( ! page ) { hugetlb_put_quota ( inode -> i_mapping , chg ) ; return ERR_PTR ( - VM_FAULT_SIGBUS ) ; } } set_page_private ( page , ( unsigned long ) mapping ) ; vma_commit_reservation ( h , vma , addr ) ; return page ; } "," ) { struct hugepage_subpool * spool = subpool_vma ( vma ) ; struct page * page ; long chg ) if ( hugepage_subpool_get_pages ( spool , chg ) page ) { hugepage_subpool_put_pages ( spool , chg ) unsigned long ) spool ) ; vma_commit_reservation ",torvalds@linux/90481622d75715bfcb68501280a917dbfe516029,CVE-2012-2133,https://github.com/torvalds/linux/commit/90481622d75715bfcb68501280a917dbfe516029,2012-07-03T16:40Z 427,CWE-20,"CWE-20 static void config_monitor ( config_tree * ptree ) { int_node * pfilegen_token ; const char * filegen_string ; const char * filegen_file ; FILEGEN * filegen ; filegen_node * my_node ; attr_val * my_opts ; int filegen_type ; int filegen_flag ; if ( ptree -> stats_dir ) stats_config ( STATS_STATSDIR , ptree -> stats_dir ) ; pfilegen_token = HEAD_PFIFO ( ptree -> stats_list ) ; for ( ; pfilegen_token != NULL ; pfilegen_token = pfilegen_token -> link ) { filegen_string = keyword ( pfilegen_token -> i ) ; filegen = filegen_get ( filegen_string ) ; DPRINTF ( 4 , ( ""enablingfilegenfor%sstatistics\'%s%s\'\\n"" , filegen_string , filegen -> prefix , filegen -> basename ) ) ; filegen -> flag |= FGEN_FLAG_ENABLED ; } my_node = HEAD_PFIFO ( ptree -> filegen_opts ) ; for ( ; my_node != NULL ; my_node = my_node -> link ) { filegen_file = keyword ( my_node -> filegen_token ) ; filegen = filegen_get ( filegen_file ) ; filegen_flag = filegen -> flag ; filegen_type = filegen -> type ; filegen_flag |= FGEN_FLAG_ENABLED ; my_opts = HEAD_PFIFO ( my_node -> options ) ; for ( ; my_opts != NULL ; my_opts = my_opts -> link ) { switch ( my_opts -> attr ) { case T_File : filegen_file = my_opts -> value . s ; break ; case T_Type : switch ( my_opts -> value . i ) { default : NTP_INSIST ( 0 ) ; break ; case T_None : filegen_type = FILEGEN_NONE ; break ; case T_Pid : filegen_type = FILEGEN_PID ; break ; case T_Day : filegen_type = FILEGEN_DAY ; break ; case T_Week : filegen_type = FILEGEN_WEEK ; break ; case T_Month : filegen_type = FILEGEN_MONTH ; break ; case T_Year : filegen_type = FILEGEN_YEAR ; break ; case T_Age : filegen_type = FILEGEN_AGE ; break ; } break ; case T_Flag : switch ( my_opts -> value . i ) { case T_Link : filegen_flag |= FGEN_FLAG_LINK ; break ; case T_Nolink : filegen_flag &= ~ FGEN_FLAG_LINK ; break ; case T_Enable : filegen_flag |= FGEN_FLAG_ENABLED ; break ; case T_Disable : filegen_flag &= ~ FGEN_FLAG_ENABLED ; break ; default : msyslog ( LOG_ERR , ""Unknownfilegenflagtoken%d"" , my_opts -> value . i ) ; exit ( 1 ) ; } break ; default : msyslog ( LOG_ERR , ""Unknownfilegenoptiontoken%d"" , my_opts -> attr ) ; exit ( 1 ) ; } } filegen_config ( filegen , filegen_file , filegen_type , filegen_flag ) ; } } "," filegen_string ) ; if ( NULL == filegen ) { msyslog ( LOG_ERR , ""stats%sunrecognized"" , filegen_string ) ; continue ; } filegen_file ) ; if ( NULL == filegen ) { msyslog ( LOG_ERR , ""filegencategory\'%s\'unrecognized"" , filegen_file ) ; continue ; } ",ntp-project@ntp/52e977d79a0c4ace997e5c74af429844da2f27be,CVE-2015-5195,https://github.com/ntp-project/ntp/commit/52e977d79a0c4ace997e5c74af429844da2f27be,2017-07-21T14:29Z 428,CWE-264,"CWE-264 static void timer_enter_running ( Timer * t ) { _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL ; int r ; assert ( t ) ; if ( unit_stop_pending ( UNIT ( t ) ) ) return ; r = manager_add_job ( UNIT ( t ) -> manager , JOB_START , UNIT_TRIGGER ( UNIT ( t ) ) , JOB_REPLACE , true , & error , NULL ) ; if ( r < 0 ) goto fail ; dual_timestamp_get ( & t -> last_trigger ) ; if ( t -> stamp_path ) touch_file ( t -> stamp_path , true , t -> last_trigger . realtime , UID_INVALID , GID_INVALID , 0 ) ; timer_set_state ( t , TIMER_RUNNING ) ; return ; fail : log_unit_warning ( UNIT ( t ) , ""Failedtoqueueunitstartupjob:%s"" , bus_error_message ( & error , r ) ) ; timer_enter_dead ( t , TIMER_FAILURE_RESOURCES ) ; } "," , GID_INVALID , MODE_INVALID ) ; timer_set_state ",systemd@systemd/ee735086f8670be1591fa9593e80dd60163a7a2f,CVE-2016-10156,https://github.com/systemd/systemd/commit/ee735086f8670be1591fa9593e80dd60163a7a2f,2017-01-23T07:59Z 429,CWE-119,"CWE-119 static void fadst16 ( const int16_t * input , int16_t * output ) { int s0 , s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 , s10 , s11 , s12 , s13 , s14 , s15 ; int x0 = input [ 15 ] ; int x1 = input [ 0 ] ; int x2 = input [ 13 ] ; int x3 = input [ 2 ] ; int x4 = input [ 11 ] ; int x5 = input [ 4 ] ; int x6 = input [ 9 ] ; int x7 = input [ 6 ] ; int x8 = input [ 7 ] ; int x9 = input [ 8 ] ; int x10 = input [ 5 ] ; int x11 = input [ 10 ] ; int x12 = input [ 3 ] ; int x13 = input [ 12 ] ; int x14 = input [ 1 ] ; int x15 = input [ 14 ] ; s0 = x0 * cospi_1_64 + x1 * cospi_31_64 ; s1 = x0 * cospi_31_64 - x1 * cospi_1_64 ; s2 = x2 * cospi_5_64 + x3 * cospi_27_64 ; s3 = x2 * cospi_27_64 - x3 * cospi_5_64 ; s4 = x4 * cospi_9_64 + x5 * cospi_23_64 ; s5 = x4 * cospi_23_64 - x5 * cospi_9_64 ; s6 = x6 * cospi_13_64 + x7 * cospi_19_64 ; s7 = x6 * cospi_19_64 - x7 * cospi_13_64 ; s8 = x8 * cospi_17_64 + x9 * cospi_15_64 ; s9 = x8 * cospi_15_64 - x9 * cospi_17_64 ; s10 = x10 * cospi_21_64 + x11 * cospi_11_64 ; s11 = x10 * cospi_11_64 - x11 * cospi_21_64 ; s12 = x12 * cospi_25_64 + x13 * cospi_7_64 ; s13 = x12 * cospi_7_64 - x13 * cospi_25_64 ; s14 = x14 * cospi_29_64 + x15 * cospi_3_64 ; s15 = x14 * cospi_3_64 - x15 * cospi_29_64 ; x0 = fdct_round_shift ( s0 + s8 ) ; x1 = fdct_round_shift ( s1 + s9 ) ; x2 = fdct_round_shift ( s2 + s10 ) ; x3 = fdct_round_shift ( s3 + s11 ) ; x4 = fdct_round_shift ( s4 + s12 ) ; x5 = fdct_round_shift ( s5 + s13 ) ; x6 = fdct_round_shift ( s6 + s14 ) ; x7 = fdct_round_shift ( s7 + s15 ) ; x8 = fdct_round_shift ( s0 - s8 ) ; x9 = fdct_round_shift ( s1 - s9 ) ; x10 = fdct_round_shift ( s2 - s10 ) ; x11 = fdct_round_shift ( s3 - s11 ) ; x12 = fdct_round_shift ( s4 - s12 ) ; x13 = fdct_round_shift ( s5 - s13 ) ; x14 = fdct_round_shift ( s6 - s14 ) ; x15 = fdct_round_shift ( s7 - s15 ) ; s0 = x0 ; s1 = x1 ; s2 = x2 ; s3 = x3 ; s4 = x4 ; s5 = x5 ; s6 = x6 ; s7 = x7 ; s8 = x8 * cospi_4_64 + x9 * cospi_28_64 ; s9 = x8 * cospi_28_64 - x9 * cospi_4_64 ; s10 = x10 * cospi_20_64 + x11 * cospi_12_64 ; s11 = x10 * cospi_12_64 - x11 * cospi_20_64 ; s12 = - x12 * cospi_28_64 + x13 * cospi_4_64 ; s13 = x12 * cospi_4_64 + x13 * cospi_28_64 ; s14 = - x14 * cospi_12_64 + x15 * cospi_20_64 ; s15 = x14 * cospi_20_64 + x15 * cospi_12_64 ; x0 = s0 + s4 ; x1 = s1 + s5 ; x2 = s2 + s6 ; x3 = s3 + s7 ; x4 = s0 - s4 ; x5 = s1 - s5 ; x6 = s2 - s6 ; x7 = s3 - s7 ; x8 = fdct_round_shift ( s8 + s12 ) ; x9 = fdct_round_shift ( s9 + s13 ) ; x10 = fdct_round_shift ( s10 + s14 ) ; x11 = fdct_round_shift ( s11 + s15 ) ; x12 = fdct_round_shift ( s8 - s12 ) ; x13 = fdct_round_shift ( s9 - s13 ) ; x14 = fdct_round_shift ( s10 - s14 ) ; x15 = fdct_round_shift ( s11 - s15 ) ; s0 = x0 ; s1 = x1 ; s2 = x2 ; s3 = x3 ; s4 = x4 * cospi_8_64 + x5 * cospi_24_64 ; s5 = x4 * cospi_24_64 - x5 * cospi_8_64 ; s6 = - x6 * cospi_24_64 + x7 * cospi_8_64 ; s7 = x6 * cospi_8_64 + x7 * cospi_24_64 ; s8 = x8 ; s9 = x9 ; s10 = x10 ; s11 = x11 ; s12 = x12 * cospi_8_64 + x13 * cospi_24_64 ; s13 = x12 * cospi_24_64 - x13 * cospi_8_64 ; s14 = - x14 * cospi_24_64 + x15 * cospi_8_64 ; s15 = x14 * cospi_8_64 + x15 * cospi_24_64 ; x0 = s0 + s2 ; x1 = s1 + s3 ; x2 = s0 - s2 ; x3 = s1 - s3 ; x4 = fdct_round_shift ( s4 + s6 ) ; x5 = fdct_round_shift ( s5 + s7 ) ; x6 = fdct_round_shift ( s4 - s6 ) ; x7 = fdct_round_shift ( s5 - s7 ) ; x8 = s8 + s10 ; x9 = s9 + s11 ; x10 = s8 - s10 ; x11 = s9 - s11 ; x12 = fdct_round_shift ( s12 + s14 ) ; x13 = fdct_round_shift ( s13 + s15 ) ; x14 = fdct_round_shift ( s12 - s14 ) ; x15 = fdct_round_shift ( s13 - s15 ) ; s2 = ( - cospi_16_64 ) * ( x2 + x3 ) ; s3 = cospi_16_64 * ( x2 - x3 ) ; s6 = cospi_16_64 * ( x6 + x7 ) ; s7 = cospi_16_64 * ( - x6 + x7 ) ; s10 = cospi_16_64 * ( x10 + x11 ) ; s11 = cospi_16_64 * ( - x10 + x11 ) ; s14 = ( - cospi_16_64 ) * ( x14 + x15 ) ; s15 = cospi_16_64 * ( x14 - x15 ) ; x2 = fdct_round_shift ( s2 ) ; x3 = fdct_round_shift ( s3 ) ; x6 = fdct_round_shift ( s6 ) ; x7 = fdct_round_shift ( s7 ) ; x10 = fdct_round_shift ( s10 ) ; x11 = fdct_round_shift ( s11 ) ; x14 = fdct_round_shift ( s14 ) ; x15 = fdct_round_shift ( s15 ) ; output [ 0 ] = x0 ; output [ 1 ] = - x8 ; output [ 2 ] = x12 ; output [ 3 ] = - x4 ; output [ 4 ] = x6 ; output [ 5 ] = x14 ; output [ 6 ] = x10 ; output [ 7 ] = x2 ; output [ 8 ] = x3 ; output [ 9 ] = x11 ; output [ 10 ] = x15 ; output [ 11 ] = x7 ; output [ 12 ] = x5 ; output [ 13 ] = - x13 ; output [ 14 ] = x9 ; output [ 15 ] = - x1 ; } "," fadst16 ( const tran_low_t * input , * input , tran_low_t * output ) output ) { tran_high_t s0 , s1 s7 , s8 ; tran_high_t s9 , s10 , s15 ; tran_high_t x0 = input 15 ] ; tran_high_t x1 = input 0 ] ; tran_high_t x2 = input 13 ] ; tran_high_t x3 = input 2 ] ; tran_high_t x4 = input 11 ] ; tran_high_t x5 = input 4 ] ; tran_high_t x6 = input 9 ] ; tran_high_t x7 = input 6 ] ; tran_high_t x8 = input 7 ] ; tran_high_t x9 = input 8 ] ; tran_high_t x10 = input 5 ] ; tran_high_t x11 = input 10 ] ; tran_high_t x12 = input 3 ] ; tran_high_t x13 = input 12 ] ; tran_high_t x14 = input 1 ] ; tran_high_t x15 = input 0 ] = ( tran_low_t ) 1 ] = ( tran_low_t ) 2 ] = ( tran_low_t ) 3 ] = ( tran_low_t ) 4 ] = ( tran_low_t ) 5 ] = ( tran_low_t ) 6 ] = ( tran_low_t ) 7 ] = ( tran_low_t ) 8 ] = ( tran_low_t ) 9 ] = ( tran_low_t ) 10 ] = ( tran_low_t ) 11 ] = ( tran_low_t ) 12 ] = ( tran_low_t ) 13 ] = ( tran_low_t ) 14 ] = ( tran_low_t ) 15 ] = ( tran_low_t ) ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 430,CWE-119,"CWE-119 int arm_cpu_caps ( void ) { int flags ; int mask ; if ( ! arm_cpu_env_flags ( & flags ) ) { return flags ; } mask = arm_cpu_env_mask ( ) ; # if HAVE_EDSP flags |= HAS_EDSP ; # endif # if HAVE_MEDIA flags |= HAS_MEDIA ; # endif # if HAVE_NEON flags |= HAS_NEON ; # endif return flags & mask ; } "," ; # if HAVE_MEDIA flags |= # if HAVE_NEON || HAVE_NEON_ASM ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 431,CWE-119,"CWE-119 MB_PREDICTION_MODE vp9_left_block_mode ( const MODE_INFO * cur_mi , const MODE_INFO * left_mi , int b ) { if ( b == 0 || b == 2 ) { if ( ! left_mi || is_inter_block ( & left_mi -> mbmi ) ) return DC_PRED ; return get_y_mode ( left_mi , b + 1 ) ; } else { assert ( b == 1 || b == 3 ) ; return cur_mi -> bmi [ b - 1 ] . as_mode ; } } "," PREDICTION_MODE vp9_left_block_mode ( const ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 432,CWE-119,"CWE-119 static void swabHorAcc16 ( TIFF * tif , uint8 * cp0 , tmsize_t cc ) { uint16 * wp = ( uint16 * ) cp0 ; tmsize_t wc = cc / 2 ; TIFFSwabArrayOfShort ( wp , wc ) ; horAcc16 ( tif , cp0 , cc ) ; } "," static int swabHorAcc16 ( TIFF wc ) ; return ",vadz@libtiff/3ca657a8793dd011bf869695d72ad31c779c3cc1,CVE-2016-9535,https://github.com/vadz/libtiff/commit/3ca657a8793dd011bf869695d72ad31c779c3cc1,2016-11-22T19:59Z 433,CWE-416,"CWE-416 struct ipv6_txoptions * ipv6_renew_options ( struct sock * sk , struct ipv6_txoptions * opt , int newtype , struct ipv6_opt_hdr __user * newopt , int newoptlen ) { int tot_len = 0 ; char * p ; struct ipv6_txoptions * opt2 ; int err ; if ( opt ) { if ( newtype != IPV6_HOPOPTS && opt -> hopopt ) tot_len += CMSG_ALIGN ( ipv6_optlen ( opt -> hopopt ) ) ; if ( newtype != IPV6_RTHDRDSTOPTS && opt -> dst0opt ) tot_len += CMSG_ALIGN ( ipv6_optlen ( opt -> dst0opt ) ) ; if ( newtype != IPV6_RTHDR && opt -> srcrt ) tot_len += CMSG_ALIGN ( ipv6_optlen ( opt -> srcrt ) ) ; if ( newtype != IPV6_DSTOPTS && opt -> dst1opt ) tot_len += CMSG_ALIGN ( ipv6_optlen ( opt -> dst1opt ) ) ; } if ( newopt && newoptlen ) tot_len += CMSG_ALIGN ( newoptlen ) ; if ( ! tot_len ) return NULL ; tot_len += sizeof ( * opt2 ) ; opt2 = sock_kmalloc ( sk , tot_len , GFP_ATOMIC ) ; if ( ! opt2 ) return ERR_PTR ( - ENOBUFS ) ; memset ( opt2 , 0 , tot_len ) ; opt2 -> tot_len = tot_len ; p = ( char * ) ( opt2 + 1 ) ; err = ipv6_renew_option ( opt ? opt -> hopopt : NULL , newopt , newoptlen , newtype != IPV6_HOPOPTS , & opt2 -> hopopt , & p ) ; if ( err ) goto out ; err = ipv6_renew_option ( opt ? opt -> dst0opt : NULL , newopt , newoptlen , newtype != IPV6_RTHDRDSTOPTS , & opt2 -> dst0opt , & p ) ; if ( err ) goto out ; err = ipv6_renew_option ( opt ? opt -> srcrt : NULL , newopt , newoptlen , newtype != IPV6_RTHDR , ( struct ipv6_opt_hdr * * ) & opt2 -> srcrt , & p ) ; if ( err ) goto out ; err = ipv6_renew_option ( opt ? opt -> dst1opt : NULL , newopt , newoptlen , newtype != IPV6_DSTOPTS , & opt2 -> dst1opt , & p ) ; if ( err ) goto out ; opt2 -> opt_nflen = ( opt2 -> hopopt ? ipv6_optlen ( opt2 -> hopopt ) : 0 ) + ( opt2 -> dst0opt ? ipv6_optlen ( opt2 -> dst0opt ) : 0 ) + ( opt2 -> srcrt ? ipv6_optlen ( opt2 -> srcrt ) : 0 ) ; opt2 -> opt_flen = ( opt2 -> dst1opt ? ipv6_optlen ( opt2 -> dst1opt ) : 0 ) ; return opt2 ; out : sock_kfree_s ( sk , opt2 , opt2 -> tot_len ) ; return ERR_PTR ( err ) ; } "," tot_len ) ; atomic_set ( & opt2 -> refcnt , 1 ) ; ",torvalds@linux/45f6fad84cc305103b28d73482b344d7f5b76f39,CVE-2016-3841,https://github.com/torvalds/linux/commit/45f6fad84cc305103b28d73482b344d7f5b76f39,2016-08-06T20:59Z 434,CWE-834,"CWE-834 static int cine_read_header ( AVFormatContext * avctx ) { AVIOContext * pb = avctx -> pb ; AVStream * st ; unsigned int version , compression , offImageHeader , offSetup , offImageOffsets , biBitCount , length , CFA ; int vflip ; char * description ; uint64_t i ; st = avformat_new_stream ( avctx , NULL ) ; if ( ! st ) return AVERROR ( ENOMEM ) ; st -> codecpar -> codec_type = AVMEDIA_TYPE_VIDEO ; st -> codecpar -> codec_id = AV_CODEC_ID_RAWVIDEO ; st -> codecpar -> codec_tag = 0 ; avio_skip ( pb , 4 ) ; compression = avio_rl16 ( pb ) ; version = avio_rl16 ( pb ) ; if ( version != 1 ) { avpriv_request_sample ( avctx , ""unknownversion%i"" , version ) ; return AVERROR_INVALIDDATA ; } avio_skip ( pb , 12 ) ; st -> duration = avio_rl32 ( pb ) ; offImageHeader = avio_rl32 ( pb ) ; offSetup = avio_rl32 ( pb ) ; offImageOffsets = avio_rl32 ( pb ) ; avio_skip ( pb , 8 ) ; avio_seek ( pb , offImageHeader , SEEK_SET ) ; avio_skip ( pb , 4 ) ; st -> codecpar -> width = avio_rl32 ( pb ) ; st -> codecpar -> height = avio_rl32 ( pb ) ; if ( avio_rl16 ( pb ) != 1 ) return AVERROR_INVALIDDATA ; biBitCount = avio_rl16 ( pb ) ; if ( biBitCount != 8 && biBitCount != 16 && biBitCount != 24 && biBitCount != 48 ) { avpriv_request_sample ( avctx , ""unsupportedbiBitCount%i"" , biBitCount ) ; return AVERROR_INVALIDDATA ; } switch ( avio_rl32 ( pb ) ) { case BMP_RGB : vflip = 0 ; break ; case 0x100 : st -> codecpar -> codec_tag = MKTAG ( 'B' , 'I' , 'T' , 0 ) ; vflip = 1 ; break ; default : avpriv_request_sample ( avctx , ""unknownbitmapcompression"" ) ; return AVERROR_INVALIDDATA ; } avio_skip ( pb , 4 ) ; avio_seek ( pb , offSetup , SEEK_SET ) ; avio_skip ( pb , 140 ) ; if ( avio_rl16 ( pb ) != 0x5453 ) return AVERROR_INVALIDDATA ; length = avio_rl16 ( pb ) ; if ( length < 0x163C ) { avpriv_request_sample ( avctx , ""shortSETUPheader"" ) ; return AVERROR_INVALIDDATA ; } avio_skip ( pb , 616 ) ; if ( ! avio_rl32 ( pb ) ^ vflip ) { st -> codecpar -> extradata = av_strdup ( ""BottomUp"" ) ; st -> codecpar -> extradata_size = 9 ; } avio_skip ( pb , 4 ) ; avpriv_set_pts_info ( st , 64 , 1 , avio_rl32 ( pb ) ) ; avio_skip ( pb , 20 ) ; set_metadata_int ( & st -> metadata , ""camera_version"" , avio_rl32 ( pb ) , 0 ) ; set_metadata_int ( & st -> metadata , ""firmware_version"" , avio_rl32 ( pb ) , 0 ) ; set_metadata_int ( & st -> metadata , ""software_version"" , avio_rl32 ( pb ) , 0 ) ; set_metadata_int ( & st -> metadata , ""recording_timezone"" , avio_rl32 ( pb ) , 0 ) ; CFA = avio_rl32 ( pb ) ; set_metadata_int ( & st -> metadata , ""brightness"" , avio_rl32 ( pb ) , 1 ) ; set_metadata_int ( & st -> metadata , ""contrast"" , avio_rl32 ( pb ) , 1 ) ; set_metadata_int ( & st -> metadata , ""gamma"" , avio_rl32 ( pb ) , 1 ) ; avio_skip ( pb , 12 + 16 ) ; set_metadata_float ( & st -> metadata , ""wbgain[0].r"" , av_int2float ( avio_rl32 ( pb ) ) , 1 ) ; set_metadata_float ( & st -> metadata , ""wbgain[0].b"" , av_int2float ( avio_rl32 ( pb ) ) , 1 ) ; avio_skip ( pb , 36 ) ; st -> codecpar -> bits_per_coded_sample = avio_rl32 ( pb ) ; if ( compression == CC_RGB ) { if ( biBitCount == 8 ) { st -> codecpar -> format = AV_PIX_FMT_GRAY8 ; } else if ( biBitCount == 16 ) { st -> codecpar -> format = AV_PIX_FMT_GRAY16LE ; } else if ( biBitCount == 24 ) { st -> codecpar -> format = AV_PIX_FMT_BGR24 ; } else if ( biBitCount == 48 ) { st -> codecpar -> format = AV_PIX_FMT_BGR48LE ; } else { avpriv_request_sample ( avctx , ""unsupportedbiBitCount%i"" , biBitCount ) ; return AVERROR_INVALIDDATA ; } } else if ( compression == CC_UNINT ) { switch ( CFA & 0xFFFFFF ) { case CFA_BAYER : if ( biBitCount == 8 ) { st -> codecpar -> format = AV_PIX_FMT_BAYER_GBRG8 ; } else if ( biBitCount == 16 ) { st -> codecpar -> format = AV_PIX_FMT_BAYER_GBRG16LE ; } else { avpriv_request_sample ( avctx , ""unsupportedbiBitCount%i"" , biBitCount ) ; return AVERROR_INVALIDDATA ; } break ; case CFA_BAYERFLIP : if ( biBitCount == 8 ) { st -> codecpar -> format = AV_PIX_FMT_BAYER_RGGB8 ; } else if ( biBitCount == 16 ) { st -> codecpar -> format = AV_PIX_FMT_BAYER_RGGB16LE ; } else { avpriv_request_sample ( avctx , ""unsupportedbiBitCount%i"" , biBitCount ) ; return AVERROR_INVALIDDATA ; } break ; default : avpriv_request_sample ( avctx , ""unsupportedColorFieldArray(CFA)%i"" , CFA & 0xFFFFFF ) ; return AVERROR_INVALIDDATA ; } } else { avpriv_request_sample ( avctx , ""unsupportedcompression%i"" , compression ) ; return AVERROR_INVALIDDATA ; } avio_skip ( pb , 668 ) ; set_metadata_int ( & st -> metadata , ""shutter_ns"" , avio_rl32 ( pb ) , 0 ) ; avio_skip ( pb , 24 ) ; # define DESCRIPTION_SIZE 4096 description = av_malloc ( DESCRIPTION_SIZE + 1 ) ; if ( ! description ) return AVERROR ( ENOMEM ) ; i = avio_get_str ( pb , DESCRIPTION_SIZE , description , DESCRIPTION_SIZE + 1 ) ; if ( i < DESCRIPTION_SIZE ) avio_skip ( pb , DESCRIPTION_SIZE - i ) ; if ( description [ 0 ] ) av_dict_set ( & st -> metadata , ""description"" , description , AV_DICT_DONT_STRDUP_VAL ) ; else av_free ( description ) ; avio_skip ( pb , 1176 ) ; set_metadata_int ( & st -> metadata , ""enable_crop"" , avio_rl32 ( pb ) , 1 ) ; set_metadata_int ( & st -> metadata , ""crop_left"" , avio_rl32 ( pb ) , 1 ) ; set_metadata_int ( & st -> metadata , ""crop_top"" , avio_rl32 ( pb ) , 1 ) ; set_metadata_int ( & st -> metadata , ""crop_right"" , avio_rl32 ( pb ) , 1 ) ; set_metadata_int ( & st -> metadata , ""crop_bottom"" , avio_rl32 ( pb ) , 1 ) ; avio_seek ( pb , offImageOffsets , SEEK_SET ) ; for ( i = 0 ; i < st -> duration ; i ++ ) av_add_index_entry ( st , avio_rl64 ( pb ) , i , 0 , 0 , AVINDEX_KEYFRAME ) ; return 0 ; } "," i ++ ) { if ( avio_feof ( pb ) ) return AVERROR_INVALIDDATA ; AVINDEX_KEYFRAME ) ; } ",FFmpeg@FFmpeg/7e80b63ecd259d69d383623e75b318bf2bd491f6,CVE-2017-14059,https://github.com/FFmpeg/FFmpeg/commit/7e80b63ecd259d69d383623e75b318bf2bd491f6,2017-08-31T15:29Z 435,CWE-310,"CWE-310 int asn1_ber_decoder ( const struct asn1_decoder * decoder , void * context , const unsigned char * data , size_t datalen ) { const unsigned char * machine = decoder -> machine ; const asn1_action_t * actions = decoder -> actions ; size_t machlen = decoder -> machlen ; enum asn1_opcode op ; unsigned char tag = 0 , csp = 0 , jsp = 0 , optag = 0 , hdr = 0 ; const char * errmsg ; size_t pc = 0 , dp = 0 , tdp = 0 , len = 0 ; int ret ; unsigned char flags = 0 ; # define FLAG_INDEFINITE_LENGTH 0x01 # define FLAG_MATCHED 0x02 # define FLAG_LAST_MATCHED 0x04 # define FLAG_CONS 0x20 # define NR_CONS_STACK 10 unsigned short cons_dp_stack [ NR_CONS_STACK ] ; unsigned short cons_datalen_stack [ NR_CONS_STACK ] ; unsigned char cons_hdrlen_stack [ NR_CONS_STACK ] ; # define NR_JUMP_STACK 10 unsigned char jump_stack [ NR_JUMP_STACK ] ; if ( datalen > 65535 ) return - EMSGSIZE ; next_op : pr_debug ( ""next_op:pc=\\e[32m%zu\\e[m/%zudp=\\e[33m%zu\\e[m/%zuC=%dJ=%d\\n"" , pc , machlen , dp , datalen , csp , jsp ) ; if ( unlikely ( pc >= machlen ) ) goto machine_overrun_error ; op = machine [ pc ] ; if ( unlikely ( pc + asn1_op_lengths [ op ] > machlen ) ) goto machine_overrun_error ; if ( op <= ASN1_OP__MATCHES_TAG ) { unsigned char tmp ; if ( ( op & ASN1_OP_MATCH__COND && flags & FLAG_MATCHED ) || dp == datalen ) { flags &= ~ FLAG_LAST_MATCHED ; pc += asn1_op_lengths [ op ] ; goto next_op ; } flags = 0 ; hdr = 2 ; if ( unlikely ( dp >= datalen - 1 ) ) goto data_overrun_error ; tag = data [ dp ++ ] ; if ( unlikely ( ( tag & 0x1f ) == ASN1_LONG_TAG ) ) goto long_tag_not_supported ; if ( op & ASN1_OP_MATCH__ANY ) { pr_debug ( ""-any%02x\\n"" , tag ) ; } else { optag = machine [ pc + 1 ] ; flags |= optag & FLAG_CONS ; tmp = optag ^ tag ; tmp &= ~ ( optag & ASN1_CONS_BIT ) ; pr_debug ( ""-match?%02x%02x%02x\\n"" , tag , optag , tmp ) ; if ( tmp != 0 ) { if ( op & ASN1_OP_MATCH__SKIP ) { pc += asn1_op_lengths [ op ] ; dp -- ; goto next_op ; } goto tag_mismatch ; } } flags |= FLAG_MATCHED ; len = data [ dp ++ ] ; if ( len > 0x7f ) { if ( unlikely ( len == ASN1_INDEFINITE_LENGTH ) ) { if ( unlikely ( ! ( tag & ASN1_CONS_BIT ) ) ) goto indefinite_len_primitive ; flags |= FLAG_INDEFINITE_LENGTH ; if ( unlikely ( 2 > datalen - dp ) ) goto data_overrun_error ; } else { int n = len - 0x80 ; if ( unlikely ( n > 2 ) ) goto length_too_long ; if ( unlikely ( dp >= datalen - n ) ) goto data_overrun_error ; hdr += n ; for ( len = 0 ; n > 0 ; n -- ) { len <<= 8 ; len |= data [ dp ++ ] ; } if ( unlikely ( len > datalen - dp ) ) goto data_overrun_error ; } } if ( flags & FLAG_CONS ) { if ( unlikely ( csp >= NR_CONS_STACK ) ) goto cons_stack_overflow ; cons_dp_stack [ csp ] = dp ; cons_hdrlen_stack [ csp ] = hdr ; if ( ! ( flags & FLAG_INDEFINITE_LENGTH ) ) { cons_datalen_stack [ csp ] = datalen ; datalen = dp + len ; } else { cons_datalen_stack [ csp ] = 0 ; } csp ++ ; } pr_debug ( ""-TAG:%02x%zu%s\\n"" , tag , len , flags & FLAG_CONS ? ""CONS"" : """" ) ; tdp = dp ; } switch ( op ) { case ASN1_OP_MATCH_ANY_ACT : case ASN1_OP_COND_MATCH_ANY_ACT : ret = actions [ machine [ pc + 1 ] ] ( context , hdr , tag , data + dp , len ) ; if ( ret < 0 ) return ret ; goto skip_data ; case ASN1_OP_MATCH_ACT : case ASN1_OP_MATCH_ACT_OR_SKIP : case ASN1_OP_COND_MATCH_ACT_OR_SKIP : ret = actions [ machine [ pc + 2 ] ] ( context , hdr , tag , data + dp , len ) ; if ( ret < 0 ) return ret ; goto skip_data ; case ASN1_OP_MATCH : case ASN1_OP_MATCH_OR_SKIP : case ASN1_OP_MATCH_ANY : case ASN1_OP_COND_MATCH_OR_SKIP : case ASN1_OP_COND_MATCH_ANY : skip_data : if ( ! ( flags & FLAG_CONS ) ) { if ( flags & FLAG_INDEFINITE_LENGTH ) { ret = asn1_find_indefinite_length ( data , datalen , & dp , & len , & errmsg ) ; if ( ret < 0 ) goto error ; } else { dp += len ; } pr_debug ( ""-LEAF:%zu\\n"" , len ) ; } pc += asn1_op_lengths [ op ] ; goto next_op ; case ASN1_OP_MATCH_JUMP : case ASN1_OP_MATCH_JUMP_OR_SKIP : case ASN1_OP_COND_MATCH_JUMP_OR_SKIP : pr_debug ( ""-MATCH_JUMP\\n"" ) ; if ( unlikely ( jsp == NR_JUMP_STACK ) ) goto jump_stack_overflow ; jump_stack [ jsp ++ ] = pc + asn1_op_lengths [ op ] ; pc = machine [ pc + 2 ] ; goto next_op ; case ASN1_OP_COND_FAIL : if ( unlikely ( ! ( flags & FLAG_MATCHED ) ) ) goto tag_mismatch ; pc += asn1_op_lengths [ op ] ; goto next_op ; case ASN1_OP_COMPLETE : if ( unlikely ( jsp != 0 || csp != 0 ) ) { pr_err ( ""ASN.1decodererror:Stacksnotemptyatcompletion(%u,%u)\\n"" , jsp , csp ) ; return - EBADMSG ; } return 0 ; case ASN1_OP_END_SET : case ASN1_OP_END_SET_ACT : if ( unlikely ( ! ( flags & FLAG_MATCHED ) ) ) goto tag_mismatch ; case ASN1_OP_END_SEQ : case ASN1_OP_END_SET_OF : case ASN1_OP_END_SEQ_OF : case ASN1_OP_END_SEQ_ACT : case ASN1_OP_END_SET_OF_ACT : case ASN1_OP_END_SEQ_OF_ACT : if ( unlikely ( csp <= 0 ) ) goto cons_stack_underflow ; csp -- ; tdp = cons_dp_stack [ csp ] ; hdr = cons_hdrlen_stack [ csp ] ; len = datalen ; datalen = cons_datalen_stack [ csp ] ; pr_debug ( ""-endconst=%zudp=%zul=%zu/%zu\\n"" , tdp , dp , len , datalen ) ; if ( datalen == 0 ) { datalen = len ; if ( unlikely ( datalen - dp < 2 ) ) goto data_overrun_error ; if ( data [ dp ++ ] != 0 ) { if ( op & ASN1_OP_END__OF ) { dp -- ; csp ++ ; pc = machine [ pc + 1 ] ; pr_debug ( ""-continue\\n"" ) ; goto next_op ; } goto missing_eoc ; } if ( data [ dp ++ ] != 0 ) goto invalid_eoc ; len = dp - tdp - 2 ; } else { if ( dp < len && ( op & ASN1_OP_END__OF ) ) { datalen = len ; csp ++ ; pc = machine [ pc + 1 ] ; pr_debug ( ""-continue\\n"" ) ; goto next_op ; } if ( dp != len ) goto cons_length_error ; len -= tdp ; pr_debug ( ""-conslenl=%zud=%zu\\n"" , len , dp - tdp ) ; } if ( op & ASN1_OP_END__ACT ) { unsigned char act ; if ( op & ASN1_OP_END__OF ) act = machine [ pc + 2 ] ; else act = machine [ pc + 1 ] ; ret = actions [ act ] ( context , hdr , 0 , data + tdp , len ) ; } pc += asn1_op_lengths [ op ] ; goto next_op ; case ASN1_OP_MAYBE_ACT : if ( ! ( flags & FLAG_LAST_MATCHED ) ) { pc += asn1_op_lengths [ op ] ; goto next_op ; } case ASN1_OP_ACT : ret = actions [ machine [ pc + 1 ] ] ( context , hdr , tag , data + tdp , len ) ; if ( ret < 0 ) return ret ; pc += asn1_op_lengths [ op ] ; goto next_op ; case ASN1_OP_RETURN : if ( unlikely ( jsp <= 0 ) ) goto jump_stack_underflow ; pc = jump_stack [ -- jsp ] ; flags |= FLAG_MATCHED | FLAG_LAST_MATCHED ; goto next_op ; default : break ; } pr_err ( ""ASN.1decodererror:Foundreservedopcode(%u)pc=%zu\\n"" , op , pc ) ; return - EBADMSG ; data_overrun_error : errmsg = ""Dataoverrunerror"" ; goto error ; machine_overrun_error : errmsg = ""Machineoverrunerror"" ; goto error ; jump_stack_underflow : errmsg = ""Jumpstackunderflow"" ; goto error ; jump_stack_overflow : errmsg = ""Jumpstackoverflow"" ; goto error ; cons_stack_underflow : errmsg = ""Consstackunderflow"" ; goto error ; cons_stack_overflow : errmsg = ""Consstackoverflow"" ; goto error ; cons_length_error : errmsg = ""Conslengtherror"" ; goto error ; missing_eoc : errmsg = ""MissingEOCinindefinitelencons"" ; goto error ; invalid_eoc : errmsg = ""InvalidlengthEOC"" ; goto error ; length_too_long : errmsg = ""Unsupportedlength"" ; goto error ; indefinite_len_primitive : errmsg = ""Indefinitelenprimitivenotpermitted"" ; goto error ; tag_mismatch : errmsg = ""Unexpectedtag"" ; goto error ; long_tag_not_supported : errmsg = ""Longtagnotsupported"" ; error : pr_debug ( ""\\nASN1:%s[m=%zud=%zuot=%02xt=%02xl=%zu]\\n"" , errmsg , pc , dp , optag , tag , len ) ; return - EBADMSG ; } "," FLAG_MATCHED ) || ( op & ASN1_OP_MATCH__SKIP && dp == datalen ) ",torvalds@linux/0d62e9dd6da45bbf0f33a8617afc5fe774c8f45f,CVE-2016-2053,https://github.com/torvalds/linux/commit/0d62e9dd6da45bbf0f33a8617afc5fe774c8f45f,2016-05-02T10:59Z 436,CWE-264,"CWE-264 static int cg_rmdir ( const char * path ) { struct fuse_context * fc = fuse_get_context ( ) ; char * fpath = NULL , * cgdir = NULL , * controller ; const char * cgroup ; int ret ; if ( ! fc ) return - EIO ; controller = pick_controller_from_path ( fc , path ) ; if ( ! controller ) return - EINVAL ; cgroup = find_cgroup_in_path ( path ) ; if ( ! cgroup ) return - EINVAL ; get_cgdir_and_path ( cgroup , & cgdir , & fpath ) ; if ( ! fpath ) { ret = - EINVAL ; goto out ; } fprintf ( stderr , ""rmdir:verifyingaccessto%s:%s(reqpath%s)\\n"" , controller , cgdir , path ) ; if ( ! fc_may_access ( fc , controller , cgdir , NULL , O_WRONLY ) ) { ret = - EACCES ; goto out ; } if ( ! caller_is_in_ancestor ( fc -> pid , controller , cgroup , NULL ) ) { ret = - EACCES ; goto out ; } if ( ! cgfs_remove ( controller , cgroup ) ) { ret = - EINVAL ; goto out ; } ret = 0 ; out : free ( cgdir ) ; return ret ; } "," , * controller , * next = NULL out ; } if ( ! , cgroup , & next ) ) { if ( ! fpath || strcmp ( next , fpath ) == 0 ) ret = - EBUSY ; else ret = - ENOENT ; goto out ; } if ( ! fc_may_access ( fc , controller , cgdir , NULL , O_WRONLY ) ) { if ( ! caller_is_in_ancestor ( fc -> pid , controller , cgroup , NULL ) ) { ret = - EACCES ; goto out ; } if ( ! cgdir ) ; free ( next ) ; ",lxc@lxcfs/a8b6c3e0537e90fba3c55910fd1b7229d54a60a7,CVE-2015-1342,https://github.com/lxc/lxcfs/commit/a8b6c3e0537e90fba3c55910fd1b7229d54a60a7,2015-12-07T20:59Z 437,CWE-269,"CWE-269 static struct mount * clone_mnt ( struct mount * old , struct dentry * root , int flag ) { struct super_block * sb = old -> mnt . mnt_sb ; struct mount * mnt ; int err ; mnt = alloc_vfsmnt ( old -> mnt_devname ) ; if ( ! mnt ) return ERR_PTR ( - ENOMEM ) ; if ( flag & ( CL_SLAVE | CL_PRIVATE | CL_SHARED_TO_SLAVE ) ) mnt -> mnt_group_id = 0 ; else mnt -> mnt_group_id = old -> mnt_group_id ; if ( ( flag & CL_MAKE_SHARED ) && ! mnt -> mnt_group_id ) { err = mnt_alloc_group_id ( mnt ) ; if ( err ) goto out_free ; } mnt -> mnt . mnt_flags = old -> mnt . mnt_flags & ~ ( MNT_WRITE_HOLD | MNT_MARKED ) ; if ( ( flag & CL_UNPRIVILEGED ) && ( mnt -> mnt . mnt_flags & MNT_READONLY ) ) mnt -> mnt . mnt_flags |= MNT_LOCK_READONLY ; if ( ( flag & CL_UNPRIVILEGED ) && list_empty ( & old -> mnt_expire ) ) mnt -> mnt . mnt_flags |= MNT_LOCKED ; atomic_inc ( & sb -> s_active ) ; mnt -> mnt . mnt_sb = sb ; mnt -> mnt . mnt_root = dget ( root ) ; mnt -> mnt_mountpoint = mnt -> mnt . mnt_root ; mnt -> mnt_parent = mnt ; lock_mount_hash ( ) ; list_add_tail ( & mnt -> mnt_instance , & sb -> s_mounts ) ; unlock_mount_hash ( ) ; if ( ( flag & CL_SLAVE ) || ( ( flag & CL_SHARED_TO_SLAVE ) && IS_MNT_SHARED ( old ) ) ) { list_add ( & mnt -> mnt_slave , & old -> mnt_slave_list ) ; mnt -> mnt_master = old ; CLEAR_MNT_SHARED ( mnt ) ; } else if ( ! ( flag & CL_PRIVATE ) ) { if ( ( flag & CL_MAKE_SHARED ) || IS_MNT_SHARED ( old ) ) list_add ( & mnt -> mnt_share , & old -> mnt_share ) ; if ( IS_MNT_SLAVE ( old ) ) list_add ( & mnt -> mnt_slave , & old -> mnt_slave ) ; mnt -> mnt_master = old -> mnt_master ; } if ( flag & CL_MAKE_SHARED ) set_mnt_shared ( mnt ) ; if ( flag & CL_EXPIRE ) { if ( ! list_empty ( & old -> mnt_expire ) ) list_add ( & mnt -> mnt_expire , & old -> mnt_expire ) ; } return mnt ; out_free : mnt_free_id ( mnt ) ; free_vfsmnt ( mnt ) ; return ERR_PTR ( err ) ; } "," ; if ( flag & CL_UNPRIVILEGED & CL_UNPRIVILEGED ) { mnt -> mnt . mnt_flags |= MNT_LOCK_ATIME ; if ( mnt -> mnt_flags & MNT_READONLY ) mnt -> ; if ( mnt -> mnt . mnt_flags & MNT_NODEV ) mnt -> mnt . mnt_flags |= MNT_LOCK_NODEV ; if ( mnt -> mnt . mnt_flags & MNT_NOSUID ) mnt -> mnt . mnt_flags |= MNT_LOCK_NOSUID ; if ( mnt -> mnt . mnt_flags & MNT_NOEXEC ) mnt -> mnt . mnt_flags |= MNT_LOCK_NOEXEC ; } if ( ",torvalds@linux/9566d6742852c527bf5af38af5cbb878dad75705,CVE-2014-5207,https://github.com/torvalds/linux/commit/9566d6742852c527bf5af38af5cbb878dad75705,2014-08-18T11:15Z 438,CWE-362,"CWE-362 static struct rds_connection * __rds_conn_create ( struct net * net , __be32 laddr , __be32 faddr , struct rds_transport * trans , gfp_t gfp , int is_outgoing ) { struct rds_connection * conn , * parent = NULL ; struct hlist_head * head = rds_conn_bucket ( laddr , faddr ) ; struct rds_transport * loop_trans ; unsigned long flags ; int ret ; rcu_read_lock ( ) ; conn = rds_conn_lookup ( net , head , laddr , faddr , trans ) ; if ( conn && conn -> c_loopback && conn -> c_trans != & rds_loop_transport && laddr == faddr && ! is_outgoing ) { parent = conn ; conn = parent -> c_passive ; } rcu_read_unlock ( ) ; if ( conn ) goto out ; conn = kmem_cache_zalloc ( rds_conn_slab , gfp ) ; if ( ! conn ) { conn = ERR_PTR ( - ENOMEM ) ; goto out ; } INIT_HLIST_NODE ( & conn -> c_hash_node ) ; conn -> c_laddr = laddr ; conn -> c_faddr = faddr ; spin_lock_init ( & conn -> c_lock ) ; conn -> c_next_tx_seq = 1 ; rds_conn_net_set ( conn , net ) ; init_waitqueue_head ( & conn -> c_waitq ) ; INIT_LIST_HEAD ( & conn -> c_send_queue ) ; INIT_LIST_HEAD ( & conn -> c_retrans ) ; ret = rds_cong_get_maps ( conn ) ; if ( ret ) { kmem_cache_free ( rds_conn_slab , conn ) ; conn = ERR_PTR ( ret ) ; goto out ; } loop_trans = rds_trans_get_preferred ( net , faddr ) ; if ( loop_trans ) { rds_trans_put ( loop_trans ) ; conn -> c_loopback = 1 ; if ( is_outgoing && trans -> t_prefer_loopback ) { trans = & rds_loop_transport ; } } if ( trans == NULL ) { kmem_cache_free ( rds_conn_slab , conn ) ; conn = ERR_PTR ( - ENODEV ) ; goto out ; } conn -> c_trans = trans ; ret = trans -> conn_alloc ( conn , gfp ) ; if ( ret ) { kmem_cache_free ( rds_conn_slab , conn ) ; conn = ERR_PTR ( ret ) ; goto out ; } atomic_set ( & conn -> c_state , RDS_CONN_DOWN ) ; conn -> c_send_gen = 0 ; conn -> c_outgoing = ( is_outgoing ? 1 : 0 ) ; conn -> c_reconnect_jiffies = 0 ; INIT_DELAYED_WORK ( & conn -> c_send_w , rds_send_worker ) ; INIT_DELAYED_WORK ( & conn -> c_recv_w , rds_recv_worker ) ; INIT_DELAYED_WORK ( & conn -> c_conn_w , rds_connect_worker ) ; INIT_WORK ( & conn -> c_down_w , rds_shutdown_worker ) ; mutex_init ( & conn -> c_cm_lock ) ; conn -> c_flags = 0 ; rdsdebug ( ""allocatedconn%pfor%pI4->%pI4over%s%s\\n"" , conn , & laddr , & faddr , trans -> t_name ? trans -> t_name : ""[unknown]"" , is_outgoing ? ""(outgoing)"" : """" ) ; spin_lock_irqsave ( & rds_conn_lock , flags ) ; if ( parent ) { if ( parent -> c_passive ) { trans -> conn_free ( conn -> c_transport_data ) ; kmem_cache_free ( rds_conn_slab , conn ) ; conn = parent -> c_passive ; } else { parent -> c_passive = conn ; rds_cong_add_conn ( conn ) ; rds_conn_count ++ ; } } else { struct rds_connection * found ; found = rds_conn_lookup ( net , head , laddr , faddr , trans ) ; if ( found ) { trans -> conn_free ( conn -> c_transport_data ) ; kmem_cache_free ( rds_conn_slab , conn ) ; conn = found ; } else { hlist_add_head_rcu ( & conn -> c_hash_node , head ) ; rds_cong_add_conn ( conn ) ; rds_conn_count ++ ; } } spin_unlock_irqrestore ( & rds_conn_lock , flags ) ; out : return conn ; } "," rds_loop_transport ; } } conn -> ",torvalds@linux/8c7188b23474cca017b3ef354c4a58456f68303a,CVE-2015-7990,https://github.com/torvalds/linux/commit/8c7188b23474cca017b3ef354c4a58456f68303a,2015-12-28T11:59Z 439,CWE-119,"CWE-119 static __u8 * sp_report_fixup ( struct hid_device * hdev , __u8 * rdesc , unsigned int * rsize ) { if ( * rsize >= 107 && rdesc [ 104 ] == 0x26 && rdesc [ 105 ] == 0x80 && rdesc [ 106 ] == 0x03 ) { hid_info ( hdev , ""fixingupSunplusWirelessDesktopreportdescriptor\\n"" ) ; rdesc [ 105 ] = rdesc [ 110 ] = 0x03 ; rdesc [ 106 ] = rdesc [ 111 ] = 0x21 ; } return rdesc ; } "," * rsize >= 112 && rdesc [ ",torvalds@linux/4ab25786c87eb20857bbb715c3ae34ec8fd6a214,CVE-2014-3184,https://github.com/torvalds/linux/commit/4ab25786c87eb20857bbb715c3ae34ec8fd6a214,2014-09-28T10:55Z 440,CWE-20,"CWE-20 static INT AirPDcapScanForKeys ( PAIRPDCAP_CONTEXT ctx , const guint8 * data , const guint mac_header_len , const guint tot_len , AIRPDCAP_SEC_ASSOCIATION_ID id ) { const UCHAR * addr ; guint bodyLength ; PAIRPDCAP_SEC_ASSOCIATION sta_sa ; PAIRPDCAP_SEC_ASSOCIATION sa ; guint offset = 0 ; const guint8 dot1x_header [ ] = { 0xAA , 0xAA , 0x03 , 0x00 , 0x00 , 0x00 , 0x88 , 0x8E } ; const guint8 bt_dot1x_header [ ] = { 0xAA , 0xAA , 0x03 , 0x00 , 0x19 , 0x58 , 0x00 , 0x03 } ; const guint8 tdls_header [ ] = { 0xAA , 0xAA , 0x03 , 0x00 , 0x00 , 0x00 , 0x89 , 0x0D , 0x02 , 0X0C } ; const EAPOL_RSN_KEY * pEAPKey ; # ifdef _DEBUG # define MSGBUF_LEN 255 CHAR msgbuf [ MSGBUF_LEN ] ; # endif AIRPDCAP_DEBUG_TRACE_START ( ""AirPDcapScanForKeys"" ) ; offset = mac_header_len ; if ( memcmp ( data + offset , dot1x_header , 8 ) == 0 || memcmp ( data + offset , bt_dot1x_header , 8 ) == 0 ) { AIRPDCAP_DEBUG_PRINT_LINE ( ""AirPDcapScanForKeys"" , ""Authentication:EAPOLpacket"" , AIRPDCAP_DEBUG_LEVEL_3 ) ; offset += 8 ; if ( data [ offset + 1 ] != 3 ) { AIRPDCAP_DEBUG_PRINT_LINE ( ""AirPDcapScanForKeys"" , ""NotEAPOL-Key"" , AIRPDCAP_DEBUG_LEVEL_3 ) ; return AIRPDCAP_RET_NO_VALID_HANDSHAKE ; } bodyLength = pntoh16 ( data + offset + 2 ) ; if ( ( tot_len - offset - 4 ) < bodyLength ) { AIRPDCAP_DEBUG_PRINT_LINE ( ""AirPDcapScanForKeys"" , ""EAPOLbodytooshort"" , AIRPDCAP_DEBUG_LEVEL_3 ) ; return AIRPDCAP_RET_NO_VALID_HANDSHAKE ; } offset += 4 ; pEAPKey = ( const EAPOL_RSN_KEY * ) ( data + offset ) ; if ( pEAPKey -> type != AIRPDCAP_RSN_WPA2_KEY_DESCRIPTOR && pEAPKey -> type != AIRPDCAP_RSN_WPA_KEY_DESCRIPTOR ) { AIRPDCAP_DEBUG_PRINT_LINE ( ""AirPDcapScanForKeys"" , ""Notvalidkeydescriptortype"" , AIRPDCAP_DEBUG_LEVEL_3 ) ; return AIRPDCAP_RET_NO_VALID_HANDSHAKE ; } offset += 1 ; sa = AirPDcapGetSaPtr ( ctx , & id ) ; if ( sa == NULL ) { AIRPDCAP_DEBUG_PRINT_LINE ( ""AirPDcapScanForKeys"" , ""NoSAforBSSIDfound"" , AIRPDCAP_DEBUG_LEVEL_3 ) ; return AIRPDCAP_RET_REQ_DATA ; } if ( AirPDcapRsna4WHandshake ( ctx , data , sa , offset , tot_len ) == AIRPDCAP_RET_SUCCESS_HANDSHAKE ) return AIRPDCAP_RET_SUCCESS_HANDSHAKE ; if ( mac_header_len + GROUP_KEY_PAYLOAD_LEN_MIN > tot_len ) { AIRPDCAP_DEBUG_PRINT_LINE ( ""AirPDcapScanForKeys"" , ""MessagetooshortforGroupKey"" , AIRPDCAP_DEBUG_LEVEL_3 ) ; return AIRPDCAP_RET_NO_VALID_HANDSHAKE ; } if ( AIRPDCAP_EAP_KEY ( data [ offset + 1 ] ) != 0 || AIRPDCAP_EAP_ACK ( data [ offset + 1 ] ) != 1 || AIRPDCAP_EAP_MIC ( data [ offset ] ) != 1 || AIRPDCAP_EAP_SEC ( data [ offset ] ) != 1 ) { AIRPDCAP_DEBUG_PRINT_LINE ( ""AirPDcapScanForKeys"" , ""KeybitfieldsnotcorrectforGroupKey"" , AIRPDCAP_DEBUG_LEVEL_3 ) ; return AIRPDCAP_RET_NO_VALID_HANDSHAKE ; } memcpy ( id . sta , broadcast_mac , AIRPDCAP_MAC_LEN ) ; sa = AirPDcapGetSaPtr ( ctx , & id ) ; if ( sa == NULL ) { return AIRPDCAP_RET_REQ_DATA ; } if ( ( addr = AirPDcapGetStaAddress ( ( const AIRPDCAP_MAC_FRAME_ADDR4 * ) ( data ) ) ) != NULL ) { memcpy ( id . sta , addr , AIRPDCAP_MAC_LEN ) ; # ifdef _DEBUG g_snprintf ( msgbuf , MSGBUF_LEN , ""ST_MAC:%2X.%2X.%2X.%2X.%2X.%2X\\t"" , id . sta [ 0 ] , id . sta [ 1 ] , id . sta [ 2 ] , id . sta [ 3 ] , id . sta [ 4 ] , id . sta [ 5 ] ) ; # endif AIRPDCAP_DEBUG_PRINT_LINE ( ""AirPDcapScanForKeys"" , msgbuf , AIRPDCAP_DEBUG_LEVEL_3 ) ; } else { AIRPDCAP_DEBUG_PRINT_LINE ( ""AirPDcapScanForKeys"" , ""SAnotfound"" , AIRPDCAP_DEBUG_LEVEL_5 ) ; return AIRPDCAP_RET_REQ_DATA ; } sta_sa = AirPDcapGetSaPtr ( ctx , & id ) ; if ( sta_sa == NULL ) { return AIRPDCAP_RET_REQ_DATA ; } return ( AirPDcapDecryptWPABroadcastKey ( pEAPKey , sta_sa -> wpa . ptk + 16 , sa , tot_len - offset + 1 ) ) ; } else if ( memcmp ( data + offset , tdls_header , 10 ) == 0 ) { const guint8 * initiator , * responder ; guint8 action ; guint status , offset_rsne = 0 , offset_fte = 0 , offset_link = 0 , offset_timeout = 0 ; AIRPDCAP_DEBUG_PRINT_LINE ( ""AirPDcapScanForKeys"" , ""Authentication:TDLSActionFrame"" , AIRPDCAP_DEBUG_LEVEL_3 ) ; offset += 10 ; action = data [ offset ] ; if ( action != 1 && action != 2 ) { AIRPDCAP_DEBUG_PRINT_LINE ( ""AirPDcapScanForKeys"" , ""NotResponsenorconfirm"" , AIRPDCAP_DEBUG_LEVEL_3 ) ; return AIRPDCAP_RET_NO_VALID_HANDSHAKE ; } offset ++ ; status = pntoh16 ( data + offset ) ; if ( status != 0 ) { AIRPDCAP_DEBUG_PRINT_LINE ( ""AirPDcapScanForKeys"" , ""TDLSsetupnotsuccessfull"" , AIRPDCAP_DEBUG_LEVEL_3 ) ; return AIRPDCAP_RET_NO_VALID_HANDSHAKE ; } offset += 5 ; while ( offset < ( tot_len - 2 ) ) { if ( data [ offset ] == 48 ) { offset_rsne = offset ; } else if ( data [ offset ] == 55 ) { offset_fte = offset ; } else if ( data [ offset ] == 56 ) { offset_timeout = offset ; } else if ( data [ offset ] == 101 ) { offset_link = offset ; } if ( tot_len < offset + data [ offset + 1 ] + 2 ) { return AIRPDCAP_RET_NO_VALID_HANDSHAKE ; } offset += data [ offset + 1 ] + 2 ; } if ( offset_rsne == 0 || offset_fte == 0 || offset_timeout == 0 || offset_link == 0 ) { AIRPDCAP_DEBUG_PRINT_LINE ( ""AirPDcapScanForKeys"" , ""CannotFindallnecessaryIEs"" , AIRPDCAP_DEBUG_LEVEL_3 ) ; return AIRPDCAP_RET_NO_VALID_HANDSHAKE ; } AIRPDCAP_DEBUG_PRINT_LINE ( ""AirPDcapScanForKeys"" , ""FoundRSNE/FastBSS/TimeoutInterval/LinkIEs"" , AIRPDCAP_DEBUG_LEVEL_3 ) ; initiator = & data [ offset_link + 8 ] ; responder = & data [ offset_link + 14 ] ; if ( memcmp ( initiator , responder , AIRPDCAP_MAC_LEN ) < 0 ) { memcpy ( id . sta , initiator , AIRPDCAP_MAC_LEN ) ; memcpy ( id . bssid , responder , AIRPDCAP_MAC_LEN ) ; } else { memcpy ( id . sta , responder , AIRPDCAP_MAC_LEN ) ; memcpy ( id . bssid , initiator , AIRPDCAP_MAC_LEN ) ; } sa = AirPDcapGetSaPtr ( ctx , & id ) ; if ( sa == NULL ) { return AIRPDCAP_RET_REQ_DATA ; } if ( sa -> validKey ) { if ( memcmp ( sa -> wpa . nonce , data + offset_fte + 52 , AIRPDCAP_WPA_NONCE_LEN ) == 0 ) { return AIRPDCAP_RET_SUCCESS_HANDSHAKE ; } else { AIRPDCAP_SEC_ASSOCIATION * tmp_sa = g_new ( AIRPDCAP_SEC_ASSOCIATION , 1 ) ; memcpy ( tmp_sa , sa , sizeof ( AIRPDCAP_SEC_ASSOCIATION ) ) ; sa -> next = tmp_sa ; sa -> validKey = FALSE ; } } if ( AirPDcapTDLSDeriveKey ( sa , data , offset_rsne , offset_fte , offset_timeout , offset_link , action ) == AIRPDCAP_RET_SUCCESS ) { AIRPDCAP_DEBUG_TRACE_END ( ""AirPDcapScanForKeys"" ) ; return AIRPDCAP_RET_SUCCESS_HANDSHAKE ; } } else { AIRPDCAP_DEBUG_PRINT_LINE ( ""AirPDcapScanForKeys"" , ""Skipping:notanEAPOLpacket"" , AIRPDCAP_DEBUG_LEVEL_3 ) ; } AIRPDCAP_DEBUG_TRACE_END ( ""AirPDcapScanForKeys"" ) ; return AIRPDCAP_RET_NO_VALID_HANDSHAKE ; } "," if ( ( ( ) < bodyLength ) || ( bodyLength < sizeof ( EAPOL_RSN_KEY ) ) ",wireshark@wireshark/9b0b20b8d5f8c9f7839d58ff6c5900f7e19283b4,CVE-2016-5351,https://github.com/wireshark/wireshark/commit/9b0b20b8d5f8c9f7839d58ff6c5900f7e19283b4,2016-08-07T16:59Z 441,CWE-476,"CWE-476 static irqreturn_t i8042_interrupt ( int irq , void * dev_id ) { struct i8042_port * port ; struct serio * serio ; unsigned long flags ; unsigned char str , data ; unsigned int dfl ; unsigned int port_no ; bool filtered ; int ret = 1 ; spin_lock_irqsave ( & i8042_lock , flags ) ; str = i8042_read_status ( ) ; if ( unlikely ( ~ str & I8042_STR_OBF ) ) { spin_unlock_irqrestore ( & i8042_lock , flags ) ; if ( irq ) dbg ( ""Interrupt%d,withoutanydata\\n"" , irq ) ; ret = 0 ; goto out ; } data = i8042_read_data ( ) ; if ( i8042_mux_present && ( str & I8042_STR_AUXDATA ) ) { static unsigned long last_transmit ; static unsigned char last_str ; dfl = 0 ; if ( str & I8042_STR_MUXERR ) { dbg ( ""MUXerror,statusis%02x,datais%02x\\n"" , str , data ) ; switch ( data ) { default : if ( time_before ( jiffies , last_transmit + HZ / 10 ) ) { str = last_str ; break ; } case 0xfc : case 0xfd : case 0xfe : dfl = SERIO_TIMEOUT ; data = 0xfe ; break ; case 0xff : dfl = SERIO_PARITY ; data = 0xfe ; break ; } } port_no = I8042_MUX_PORT_NO + ( ( str >> 6 ) & 3 ) ; last_str = str ; last_transmit = jiffies ; } else { dfl = ( ( str & I8042_STR_PARITY ) ? SERIO_PARITY : 0 ) | ( ( str & I8042_STR_TIMEOUT && ! i8042_notimeout ) ? SERIO_TIMEOUT : 0 ) ; port_no = ( str & I8042_STR_AUXDATA ) ? I8042_AUX_PORT_NO : I8042_KBD_PORT_NO ; } port = & i8042_ports [ port_no ] ; serio = port -> exists ? port -> serio : NULL ; filter_dbg ( port -> driver_bound , data , ""<-i8042(interrupt,%d,%d%s%s)\\n"" , port_no , irq , dfl & SERIO_PARITY ? "",badparity"" : """" , dfl & SERIO_TIMEOUT ? "",timeout"" : """" ) ; filtered = i8042_filter ( data , str , serio ) ; spin_unlock_irqrestore ( & i8042_lock , flags ) ; if ( likely ( port -> exists && ! filtered ) ) serio_interrupt ( serio , data , dfl ) ; out : return IRQ_RETVAL ( ret ) ; } "," ( likely ( serio && ! filtered ",torvalds@linux/340d394a789518018f834ff70f7534fc463d3226,CVE-2017-18079,https://github.com/torvalds/linux/commit/340d394a789518018f834ff70f7534fc463d3226,2018-01-29T05:29Z 442,CWE-125,"CWE-125 static void interp_reply ( netdissect_options * ndo , const struct sunrpc_msg * rp , uint32_t proc , uint32_t vers , int length ) { register const uint32_t * dp ; register int v3 ; int er ; v3 = ( vers == NFS_VER3 ) ; if ( ! v3 && proc < NFS_NPROCS ) proc = nfsv3_procid [ proc ] ; ND_PRINT ( ( ndo , ""%s"" , tok2str ( nfsproc_str , ""proc-%u"" , proc ) ) ) ; switch ( proc ) { case NFSPROC_GETATTR : dp = parserep ( ndo , rp , length ) ; if ( dp != NULL && parseattrstat ( ndo , dp , ! ndo -> ndo_qflag , v3 ) != 0 ) return ; break ; case NFSPROC_SETATTR : if ( ! ( dp = parserep ( ndo , rp , length ) ) ) return ; if ( v3 ) { if ( parsewccres ( ndo , dp , ndo -> ndo_vflag ) ) return ; } else { if ( parseattrstat ( ndo , dp , ! ndo -> ndo_qflag , 0 ) != 0 ) return ; } break ; case NFSPROC_LOOKUP : if ( ! ( dp = parserep ( ndo , rp , length ) ) ) break ; if ( v3 ) { if ( ! ( dp = parsestatus ( ndo , dp , & er ) ) ) break ; if ( er ) { if ( ndo -> ndo_vflag > 1 ) { ND_PRINT ( ( ndo , ""postdattr:"" ) ) ; dp = parse_post_op_attr ( ndo , dp , ndo -> ndo_vflag ) ; } } else { if ( ! ( dp = parsefh ( ndo , dp , v3 ) ) ) break ; if ( ( dp = parse_post_op_attr ( ndo , dp , ndo -> ndo_vflag ) ) && ndo -> ndo_vflag > 1 ) { ND_PRINT ( ( ndo , ""postdattr:"" ) ) ; dp = parse_post_op_attr ( ndo , dp , ndo -> ndo_vflag ) ; } } if ( dp ) return ; } else { if ( parsediropres ( ndo , dp ) != 0 ) return ; } break ; case NFSPROC_ACCESS : if ( ! ( dp = parserep ( ndo , rp , length ) ) ) break ; if ( ! ( dp = parsestatus ( ndo , dp , & er ) ) ) break ; if ( ndo -> ndo_vflag ) ND_PRINT ( ( ndo , ""attr:"" ) ) ; if ( ! ( dp = parse_post_op_attr ( ndo , dp , ndo -> ndo_vflag ) ) ) break ; if ( ! er ) ND_PRINT ( ( ndo , ""c%04x"" , EXTRACT_32BITS ( & dp [ 0 ] ) ) ) ; return ; case NFSPROC_READLINK : dp = parserep ( ndo , rp , length ) ; if ( dp != NULL && parselinkres ( ndo , dp , v3 ) != 0 ) return ; break ; case NFSPROC_READ : if ( ! ( dp = parserep ( ndo , rp , length ) ) ) break ; if ( v3 ) { if ( ! ( dp = parsestatus ( ndo , dp , & er ) ) ) break ; if ( ! ( dp = parse_post_op_attr ( ndo , dp , ndo -> ndo_vflag ) ) ) break ; if ( er ) return ; if ( ndo -> ndo_vflag ) { ND_TCHECK ( dp [ 1 ] ) ; ND_PRINT ( ( ndo , ""%ubytes"" , EXTRACT_32BITS ( & dp [ 0 ] ) ) ) ; if ( EXTRACT_32BITS ( & dp [ 1 ] ) ) ND_PRINT ( ( ndo , ""EOF"" ) ) ; } return ; } else { if ( parseattrstat ( ndo , dp , ndo -> ndo_vflag , 0 ) != 0 ) return ; } break ; case NFSPROC_WRITE : if ( ! ( dp = parserep ( ndo , rp , length ) ) ) break ; if ( v3 ) { if ( ! ( dp = parsestatus ( ndo , dp , & er ) ) ) break ; if ( ! ( dp = parse_wcc_data ( ndo , dp , ndo -> ndo_vflag ) ) ) break ; if ( er ) return ; if ( ndo -> ndo_vflag ) { ND_TCHECK ( dp [ 0 ] ) ; ND_PRINT ( ( ndo , ""%ubytes"" , EXTRACT_32BITS ( & dp [ 0 ] ) ) ) ; if ( ndo -> ndo_vflag > 1 ) { ND_TCHECK ( dp [ 1 ] ) ; ND_PRINT ( ( ndo , ""<%s>"" , tok2str ( nfsv3_writemodes , NULL , EXTRACT_32BITS ( & dp [ 1 ] ) ) ) ) ; } return ; } } else { if ( parseattrstat ( ndo , dp , ndo -> ndo_vflag , v3 ) != 0 ) return ; } break ; case NFSPROC_CREATE : case NFSPROC_MKDIR : if ( ! ( dp = parserep ( ndo , rp , length ) ) ) break ; if ( v3 ) { if ( parsecreateopres ( ndo , dp , ndo -> ndo_vflag ) != NULL ) return ; } else { if ( parsediropres ( ndo , dp ) != 0 ) return ; } break ; case NFSPROC_SYMLINK : if ( ! ( dp = parserep ( ndo , rp , length ) ) ) break ; if ( v3 ) { if ( parsecreateopres ( ndo , dp , ndo -> ndo_vflag ) != NULL ) return ; } else { if ( parsestatus ( ndo , dp , & er ) != NULL ) return ; } break ; case NFSPROC_MKNOD : if ( ! ( dp = parserep ( ndo , rp , length ) ) ) break ; if ( parsecreateopres ( ndo , dp , ndo -> ndo_vflag ) != NULL ) return ; break ; case NFSPROC_REMOVE : case NFSPROC_RMDIR : if ( ! ( dp = parserep ( ndo , rp , length ) ) ) break ; if ( v3 ) { if ( parsewccres ( ndo , dp , ndo -> ndo_vflag ) ) return ; } else { if ( parsestatus ( ndo , dp , & er ) != NULL ) return ; } break ; case NFSPROC_RENAME : if ( ! ( dp = parserep ( ndo , rp , length ) ) ) break ; if ( v3 ) { if ( ! ( dp = parsestatus ( ndo , dp , & er ) ) ) break ; if ( ndo -> ndo_vflag ) { ND_PRINT ( ( ndo , ""from:"" ) ) ; if ( ! ( dp = parse_wcc_data ( ndo , dp , ndo -> ndo_vflag ) ) ) break ; ND_PRINT ( ( ndo , ""to:"" ) ) ; if ( ! ( dp = parse_wcc_data ( ndo , dp , ndo -> ndo_vflag ) ) ) break ; } return ; } else { if ( parsestatus ( ndo , dp , & er ) != NULL ) return ; } break ; case NFSPROC_LINK : if ( ! ( dp = parserep ( ndo , rp , length ) ) ) break ; if ( v3 ) { if ( ! ( dp = parsestatus ( ndo , dp , & er ) ) ) break ; if ( ndo -> ndo_vflag ) { ND_PRINT ( ( ndo , ""filePOST:"" ) ) ; if ( ! ( dp = parse_post_op_attr ( ndo , dp , ndo -> ndo_vflag ) ) ) break ; ND_PRINT ( ( ndo , ""dir:"" ) ) ; if ( ! ( dp = parse_wcc_data ( ndo , dp , ndo -> ndo_vflag ) ) ) break ; return ; } } else { if ( parsestatus ( ndo , dp , & er ) != NULL ) return ; } break ; case NFSPROC_READDIR : if ( ! ( dp = parserep ( ndo , rp , length ) ) ) break ; if ( v3 ) { if ( parsev3rddirres ( ndo , dp , ndo -> ndo_vflag ) ) return ; } else { if ( parserddires ( ndo , dp ) != 0 ) return ; } break ; case NFSPROC_READDIRPLUS : if ( ! ( dp = parserep ( ndo , rp , length ) ) ) break ; if ( parsev3rddirres ( ndo , dp , ndo -> ndo_vflag ) ) return ; break ; case NFSPROC_FSSTAT : dp = parserep ( ndo , rp , length ) ; if ( dp != NULL && parsestatfs ( ndo , dp , v3 ) != 0 ) return ; break ; case NFSPROC_FSINFO : dp = parserep ( ndo , rp , length ) ; if ( dp != NULL && parsefsinfo ( ndo , dp ) != 0 ) return ; break ; case NFSPROC_PATHCONF : dp = parserep ( ndo , rp , length ) ; if ( dp != NULL && parsepathconf ( ndo , dp ) != 0 ) return ; break ; case NFSPROC_COMMIT : dp = parserep ( ndo , rp , length ) ; if ( dp != NULL && parsewccres ( ndo , dp , ndo -> ndo_vflag ) != 0 ) return ; break ; default : return ; } trunc : if ( ! nfserr ) ND_PRINT ( ( ndo , ""%s"" , tstr ) ) ; } "," ! er ) { ND_TCHECK ( dp [ 0 0 ] ) ; ND_PRINT ( ( ndo , ""c%04x"" , EXTRACT_32BITS ( & dp [ 0 ] ) ) ) ; } return ; case ",the-tcpdump-group@tcpdump/19d25dd8781620cd41bf178a5e2e27fc1cf242d0,CVE-2017-12898,https://github.com/the-tcpdump-group/tcpdump/commit/19d25dd8781620cd41bf178a5e2e27fc1cf242d0,2017-09-14T06:29Z 443,CWE-17,"CWE-17 static int udf_translate_to_linux ( uint8_t * newName , uint8_t * udfName , int udfLen , uint8_t * fidName , int fidNameLen ) { int index , newIndex = 0 , needsCRC = 0 ; int extIndex = 0 , newExtIndex = 0 , hasExt = 0 ; unsigned short valueCRC ; uint8_t curr ; if ( udfName [ 0 ] == '.' && ( udfLen == 1 || ( udfLen == 2 && udfName [ 1 ] == '.' ) ) ) { needsCRC = 1 ; newIndex = udfLen ; memcpy ( newName , udfName , udfLen ) ; } else { for ( index = 0 ; index < udfLen ; index ++ ) { curr = udfName [ index ] ; if ( curr == '/' || curr == 0 ) { needsCRC = 1 ; curr = ILLEGAL_CHAR_MARK ; while ( index + 1 < udfLen && ( udfName [ index + 1 ] == '/' || udfName [ index + 1 ] == 0 ) ) index ++ ; } if ( curr == EXT_MARK && ( udfLen - index - 1 ) <= EXT_SIZE ) { if ( udfLen == index + 1 ) hasExt = 0 ; else { hasExt = 1 ; extIndex = index ; newExtIndex = newIndex ; } } if ( newIndex < 256 ) newName [ newIndex ++ ] = curr ; else needsCRC = 1 ; } } if ( needsCRC ) { uint8_t ext [ EXT_SIZE ] ; int localExtIndex = 0 ; if ( hasExt ) { int maxFilenameLen ; for ( index = 0 ; index < EXT_SIZE && extIndex + index + 1 < udfLen ; index ++ ) { curr = udfName [ extIndex + index + 1 ] ; if ( curr == '/' || curr == 0 ) { needsCRC = 1 ; curr = ILLEGAL_CHAR_MARK ; while ( extIndex + index + 2 < udfLen && ( index + 1 < EXT_SIZE && ( udfName [ extIndex + index + 2 ] == '/' || udfName [ extIndex + index + 2 ] == 0 ) ) ) index ++ ; } ext [ localExtIndex ++ ] = curr ; } maxFilenameLen = 250 - localExtIndex ; if ( newIndex > maxFilenameLen ) newIndex = maxFilenameLen ; else newIndex = newExtIndex ; } else if ( newIndex > 250 ) newIndex = 250 ; newName [ newIndex ++ ] = CRC_MARK ; valueCRC = crc_itu_t ( 0 , fidName , fidNameLen ) ; newName [ newIndex ++ ] = hex_asc_upper_hi ( valueCRC >> 8 ) ; newName [ newIndex ++ ] = hex_asc_upper_lo ( valueCRC >> 8 ) ; newName [ newIndex ++ ] = hex_asc_upper_hi ( valueCRC ) ; newName [ newIndex ++ ] = hex_asc_upper_lo ( valueCRC ) ; if ( hasExt ) { newName [ newIndex ++ ] = EXT_MARK ; for ( index = 0 ; index < localExtIndex ; index ++ ) newName [ newIndex ++ ] = ext [ index ] ; } } return newIndex ; } "," * newName , int newLen , * udfName , int udfLen , uint8_t * fidName ( newIndex < newLen ) newName [ } maxFilenameLen = newLen - CRC_LEN - localExtIndex ; ( newIndex > newLen - CRC_LEN ) newIndex = newLen - CRC_LEN ; newName [ ",torvalds@linux/0e5cc9a40ada6046e6bc3bdfcd0c0d7e4b706b14,CVE-2014-9731,https://github.com/torvalds/linux/commit/0e5cc9a40ada6046e6bc3bdfcd0c0d7e4b706b14,2015-08-31T10:59Z 444,CWE-119,"CWE-119 static void count_segs_sb ( VP9_COMP * cpi , const TileInfo * const tile , MODE_INFO * * mi_8x8 , int * no_pred_segcounts , int ( * temporal_predictor_count ) [ 2 ] , int * t_unpred_seg_counts , int mi_row , int mi_col , BLOCK_SIZE bsize ) { const VP9_COMMON * const cm = & cpi -> common ; const int mis = cm -> mi_stride ; int bw , bh ; const int bs = num_8x8_blocks_wide_lookup [ bsize ] , hbs = bs / 2 ; if ( mi_row >= cm -> mi_rows || mi_col >= cm -> mi_cols ) return ; bw = num_8x8_blocks_wide_lookup [ mi_8x8 [ 0 ] -> mbmi . sb_type ] ; bh = num_8x8_blocks_high_lookup [ mi_8x8 [ 0 ] -> mbmi . sb_type ] ; if ( bw == bs && bh == bs ) { count_segs ( cpi , tile , mi_8x8 , no_pred_segcounts , temporal_predictor_count , t_unpred_seg_counts , bs , bs , mi_row , mi_col ) ; } else if ( bw == bs && bh < bs ) { count_segs ( cpi , tile , mi_8x8 , no_pred_segcounts , temporal_predictor_count , t_unpred_seg_counts , bs , hbs , mi_row , mi_col ) ; count_segs ( cpi , tile , mi_8x8 + hbs * mis , no_pred_segcounts , temporal_predictor_count , t_unpred_seg_counts , bs , hbs , mi_row + hbs , mi_col ) ; } else if ( bw < bs && bh == bs ) { count_segs ( cpi , tile , mi_8x8 , no_pred_segcounts , temporal_predictor_count , t_unpred_seg_counts , hbs , bs , mi_row , mi_col ) ; count_segs ( cpi , tile , mi_8x8 + hbs , no_pred_segcounts , temporal_predictor_count , t_unpred_seg_counts , hbs , bs , mi_row , mi_col + hbs ) ; } else { const BLOCK_SIZE subsize = subsize_lookup [ PARTITION_SPLIT ] [ bsize ] ; int n ; assert ( bw < bs && bh < bs ) ; for ( n = 0 ; n < 4 ; n ++ ) { const int mi_dc = hbs * ( n & 1 ) ; const int mi_dr = hbs * ( n >> 1 ) ; count_segs_sb ( cpi , tile , & mi_8x8 [ mi_dr * mis + mi_dc ] , no_pred_segcounts , temporal_predictor_count , t_unpred_seg_counts , mi_row + mi_dr , mi_col + mi_dc , subsize ) ; } } } "," void count_segs_sb ( const VP9_COMMON * cm , MACROBLOCKD * xd , const TileInfo * const TileInfo * tile , MODE_INFO * * MODE_INFO * * mi , int * bsize ) { const int mis = num_8x8_blocks_wide_lookup [ mi [ 0 ] = num_8x8_blocks_high_lookup [ mi [ 0 ] { count_segs ( cm , xd , tile , mi , no_pred_segcounts , { count_segs ( cm , xd , tile , mi , no_pred_segcounts , ; count_segs ( cm , xd , tile , mi + hbs * { count_segs ( cm , xd , tile , mi , no_pred_segcounts , ; count_segs ( cm , xd , tile , mi + hbs , ; count_segs_sb ( cm , xd , tile , tile , & mi [ mi_dr * ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 445,CWE-254,"CWE-254 void processInputBuffer ( client * c ) { server . current_client = c ; while ( sdslen ( c -> querybuf ) ) { if ( ! ( c -> flags & CLIENT_SLAVE ) && clientsArePaused ( ) ) break ; if ( c -> flags & CLIENT_BLOCKED ) break ; if ( c -> flags & CLIENT_CLOSE_AFTER_REPLY ) break ; if ( ! c -> reqtype ) { if ( c -> querybuf [ 0 ] == '*' ) { c -> reqtype = PROTO_REQ_MULTIBULK ; } else { c -> reqtype = PROTO_REQ_INLINE ; } } if ( c -> reqtype == PROTO_REQ_INLINE ) { if ( processInlineBuffer ( c ) != C_OK ) break ; } else if ( c -> reqtype == PROTO_REQ_MULTIBULK ) { if ( processMultibulkBuffer ( c ) != C_OK ) break ; } else { serverPanic ( ""Unknownrequesttype"" ) ; } if ( c -> argc == 0 ) { resetClient ( c ) ; } else { if ( processCommand ( c ) == C_OK ) resetClient ( c ) ; if ( server . current_client == NULL ) break ; } } server . current_client = NULL ; } "," -> flags & ( CLIENT_CLOSE_AFTER_REPLY | CLIENT_CLOSE_ASAP ) ) break ; ",antirez@redis/874804da0c014a7d704b3d285aa500098a931f50,CVE-2016-10517,https://github.com/antirez/redis/commit/874804da0c014a7d704b3d285aa500098a931f50,2017-10-24T18:29Z 446,CWE-000,"CWE-000 static int mpage_da_map_blocks ( struct mpage_da_data * mpd ) { int err , blks , get_blocks_flags ; struct buffer_head new ; sector_t next = mpd -> b_blocknr ; unsigned max_blocks = mpd -> b_size >> mpd -> inode -> i_blkbits ; loff_t disksize = EXT4_I ( mpd -> inode ) -> i_disksize ; handle_t * handle = NULL ; if ( ( mpd -> b_state & ( 1 << BH_Mapped ) ) && ! ( mpd -> b_state & ( 1 << BH_Delay ) ) && ! ( mpd -> b_state & ( 1 << BH_Unwritten ) ) ) return 0 ; if ( ! mpd -> b_size ) return 0 ; handle = ext4_journal_current_handle ( ) ; BUG_ON ( ! handle ) ; new . b_state = 0 ; get_blocks_flags = EXT4_GET_BLOCKS_CREATE ; if ( mpd -> b_state & ( 1 << BH_Delay ) ) get_blocks_flags |= EXT4_GET_BLOCKS_DELALLOC_RESERVE ; blks = ext4_get_blocks ( handle , mpd -> inode , next , max_blocks , & new , get_blocks_flags ) ; if ( blks < 0 ) { err = blks ; if ( err == - EAGAIN ) return 0 ; if ( err == - ENOSPC && ext4_count_free_blocks ( mpd -> inode -> i_sb ) ) { mpd -> retval = err ; return 0 ; } ext4_msg ( mpd -> inode -> i_sb , KERN_CRIT , ""delayedblockallocationfailedforinode%luat"" ""logicaloffset%lluwithmaxblocks%zdwith"" ""error%d\\n"" , mpd -> inode -> i_ino , ( unsigned long long ) next , mpd -> b_size >> mpd -> inode -> i_blkbits , err ) ; printk ( KERN_CRIT ""Thisshouldnothappen!!"" ""Datawillbelost\\n"" ) ; if ( err == - ENOSPC ) { ext4_print_free_blocks ( mpd -> inode ) ; } ext4_da_block_invalidatepages ( mpd , next , mpd -> b_size >> mpd -> inode -> i_blkbits ) ; return err ; } BUG_ON ( blks == 0 ) ; new . b_size = ( blks << mpd -> inode -> i_blkbits ) ; if ( buffer_new ( & new ) ) __unmap_underlying_blocks ( mpd -> inode , & new ) ; if ( ( mpd -> b_state & ( 1 << BH_Delay ) ) || ( mpd -> b_state & ( 1 << BH_Unwritten ) ) ) mpage_put_bnr_to_bhs ( mpd , next , & new ) ; if ( ext4_should_order_data ( mpd -> inode ) ) { err = ext4_jbd2_file_inode ( handle , mpd -> inode ) ; if ( err ) return err ; } disksize = ( ( loff_t ) next + blks ) << mpd -> inode -> i_blkbits ; if ( disksize > i_size_read ( mpd -> inode ) ) disksize = i_size_read ( mpd -> inode ) ; if ( disksize > EXT4_I ( mpd -> inode ) -> i_disksize ) { ext4_update_i_disksize ( mpd -> inode , disksize ) ; return ext4_mark_inode_dirty ( handle , mpd -> inode ) ; } return 0 ; } "," get_blocks_flags = EXT4_GET_BLOCKS_CREATE ; if ( ext4_should_dioread_nolock ( mpd -> inode ) ) get_blocks_flags |= EXT4_GET_BLOCKS_IO_CREATE_EXT ",torvalds@linux/744692dc059845b2a3022119871846e74d4f6e11,CVE-2015-8324,https://github.com/torvalds/linux/commit/744692dc059845b2a3022119871846e74d4f6e11,2016-05-02T10:59Z 447,CWE-310,"CWE-310 int DSA_verify ( int type , const unsigned char * dgst , int dgst_len , const unsigned char * sigbuf , int siglen , DSA * dsa ) { DSA_SIG * s ; int ret = - 1 ; s = DSA_SIG_new ( ) ; if ( s == NULL ) return ( ret ) ; if ( d2i_DSA_SIG ( & s , & sigbuf , siglen ) == NULL ) goto err ; ret = DSA_do_verify ( dgst , dgst_len , s , dsa ) ; err : DSA_SIG_free ( s ) ; return ( ret ) ; } "," * s ; const unsigned char * p = sigbuf ; unsigned char * der = NULL ; int derlen = - 1 ; s , & p , siglen ) == NULL ) goto err ; derlen = i2d_DSA_SIG ( s , & der ) ; if ( derlen != siglen || memcmp ( sigbuf , der , derlen ) ) ; err : if ( derlen > 0 ) { OPENSSL_cleanse ( der , derlen ) ; OPENSSL_free ( der ) ; } ",openssl@openssl/684400ce192dac51df3d3e92b61830a6ef90be3e,CVE-2014-8275,https://github.com/openssl/openssl/commit/684400ce192dac51df3d3e92b61830a6ef90be3e,2015-01-09T02:59Z 448,CWE-415,"CWE-415 void * gdImageGifPtr ( gdImagePtr im , int * size ) { void * rv ; gdIOCtx * out = gdNewDynamicCtx ( 2048 , NULL ) ; gdImageGifCtx ( im , out ) ; rv = gdDPExtractData ( out , size ) ; out -> gd_free ( out ) ; return rv ; } "," NULL ) ; if ( ! _gdImageGifCtx ( im , , out ) ) { rv = gdDPExtractData size ) ; } else { rv = NULL ; } ",php@php-src/089f7c0bc28d399b0420aa6ef058e4c1c120b2ae,CVE-2019-6978,https://github.com/php/php-src/commit/089f7c0bc28d399b0420aa6ef058e4c1c120b2ae,2019-01-28T08:29Z 449,CWE-200,"CWE-200 void free_bprm ( struct linux_binprm * bprm ) { free_arg_pages ( bprm ) ; if ( bprm -> cred ) { mutex_unlock ( & current -> signal -> cred_guard_mutex ) ; abort_creds ( bprm -> cred ) ; } kfree ( bprm ) ; } "," ) ; } if ( bprm -> interp != bprm -> filename ) kfree ( bprm -> interp ) ; ",torvalds@linux/b66c5984017533316fd1951770302649baf1aa33,CVE-2012-4530,https://github.com/torvalds/linux/commit/b66c5984017533316fd1951770302649baf1aa33,2013-02-18T04:41Z 450,CWE-552,"CWE-552 static int _hostresolver_getaddrinfo ( oe_resolver_t * resolver , const char * node , const char * service , const struct oe_addrinfo * hints , struct oe_addrinfo * * res ) { int ret = OE_EAI_FAIL ; uint64_t handle = 0 ; struct oe_addrinfo * head = NULL ; struct oe_addrinfo * tail = NULL ; struct oe_addrinfo * p = NULL ; OE_UNUSED ( resolver ) ; if ( res ) * res = NULL ; if ( ! res ) { ret = OE_EAI_SYSTEM ; OE_RAISE_ERRNO ( OE_EINVAL ) ; } { int retval = OE_EAI_FAIL ; if ( oe_syscall_getaddrinfo_open_ocall ( & retval , node , service , hints , & handle ) != OE_OK ) { ret = OE_EAI_SYSTEM ; OE_RAISE_ERRNO ( OE_EINVAL ) ; } if ( ! handle ) { ret = retval ; goto done ; } } for ( ; ; ) { int retval = 0 ; size_t canonnamelen = 0 ; if ( ! ( p = oe_calloc ( 1 , sizeof ( struct oe_addrinfo ) ) ) ) { ret = OE_EAI_MEMORY ; goto done ; } if ( oe_syscall_getaddrinfo_read_ocall ( & retval , handle , & p -> ai_flags , & p -> ai_family , & p -> ai_socktype , & p -> ai_protocol , p -> ai_addrlen , & p -> ai_addrlen , NULL , canonnamelen , & canonnamelen , NULL ) != OE_OK ) { ret = OE_EAI_SYSTEM ; OE_RAISE_ERRNO ( OE_EINVAL ) ; } if ( retval == 1 ) break ; if ( retval != - 1 || oe_errno != OE_ENAMETOOLONG ) { ret = OE_EAI_SYSTEM ; OE_RAISE_ERRNO ( oe_errno ) ; } if ( p -> ai_addrlen && ! ( p -> ai_addr = oe_calloc ( 1 , p -> ai_addrlen ) ) ) { ret = OE_EAI_MEMORY ; goto done ; } if ( canonnamelen && ! ( p -> ai_canonname = oe_calloc ( 1 , canonnamelen ) ) ) { ret = OE_EAI_MEMORY ; goto done ; } if ( oe_syscall_getaddrinfo_read_ocall ( & retval , handle , & p -> ai_flags , & p -> ai_family , & p -> ai_socktype , & p -> ai_protocol , p -> ai_addrlen , & p -> ai_addrlen , p -> ai_addr , canonnamelen , & canonnamelen , p -> ai_canonname ) != OE_OK ) { ret = OE_EAI_SYSTEM ; OE_RAISE_ERRNO ( OE_EINVAL ) ; } if ( tail ) { tail -> ai_next = p ; tail = p ; } else { head = p ; tail = p ; } p = NULL ; } if ( handle ) { int retval = - 1 ; if ( oe_syscall_getaddrinfo_close_ocall ( & retval , handle ) != OE_OK ) { ret = OE_EAI_SYSTEM ; OE_RAISE_ERRNO ( OE_EINVAL ) ; } handle = 0 ; if ( retval != 0 ) { ret = OE_EAI_SYSTEM ; OE_RAISE_ERRNO ( oe_errno ) ; } } if ( ! head ) { ret = OE_EAI_SYSTEM ; OE_RAISE_ERRNO ( OE_EINVAL ) ; } * res = head ; head = NULL ; tail = NULL ; ret = 0 ; done : if ( handle ) { int retval ; oe_syscall_getaddrinfo_close_ocall ( & retval , handle ) ; } if ( head ) oe_freeaddrinfo ( head ) ; if ( p ) oe_freeaddrinfo ( p ) ; return ret ; } "," 0 ; size_t canonnamelen_in = 0 ; = 0 ; size_t canonnamelen_out = 0 ; struct oe_addrinfo p_out ; memset ( & p_out , 0 , sizeof ( struct oe_addrinfo ) ) ; if ( oe_syscall_getaddrinfo_read_ocall handle , & p_out . ai_flags , & ai_flags , & p_out . ai_family , & ai_family , & p_out . ai_socktype , & ai_socktype , & p_out . ai_protocol , p_out . ai_addrlen , & ai_addrlen , & p_out . ai_addrlen , NULL , NULL , canonnamelen_in , & canonnamelen_out , NULL ) ) ; } switch ( p_out . ai_family ) { case OE_AF_INET : if ( p_out . ai_addrlen != sizeof ( struct oe_sockaddr ) ) { ret = OE_EAI_FAIL ; goto done ; } break ; case OE_AF_INET6 : case OE_AF_INET6_WIN : case OE_AF_UNSPEC : if ( p_out . ai_addrlen != sizeof ( struct oe_sockaddr_in6 ) ) { ret = OE_EAI_FAIL ; goto done ; } break ; default : ret = OE_EAI_FAIL ; goto done ; } if ( ! ( p = oe_calloc ( 1 , sizeof ( struct oe_addrinfo ) ) ) ) { ret = OE_EAI_MEMORY ; goto done ; } if ( p_out . ai_addrlen && ! ( 1 , p_out . ai_addrlen ) ) } if ( canonnamelen_out && ! ( ( 1 , canonnamelen_out ) ) ) done ; } canonnamelen_in = canonnamelen_out ; -> ai_protocol , p_out . ai_addrlen , & -> ai_addr , canonnamelen_in , & canonnamelen_out , p -> } if ( ( p -> ai_flags != p_out . ai_flags ) || ( p -> ai_family != p_out . ai_family ) || ( p -> ai_socktype != p_out . ai_socktype ) || ( p -> ai_protocol != p_out . ai_protocol ) || ( p -> ai_addrlen != p_out . ai_addrlen ) || ( canonnamelen_out != canonnamelen_in ) || ( canonnamelen_out && p -> ai_canonname [ canonnamelen_out - 1 ] != '\\0' ) ) { ret = OE_EAI_FAIL ; goto done ; } if ( tail ) { tail -> ai_next = p ; tail = p ; } else { head = p ; tail = p ; } p = NULL ; } if ( handle ) { int retval = - 1 ; if ( ",openenclave@openenclave/bcac8e7acb514429fee9e0b5d0c7a0308fd4d76b,CVE-2020-15224,https://github.com/openenclave/openenclave/commit/bcac8e7acb514429fee9e0b5d0c7a0308fd4d76b,2020-10-14T19:15Z 451,CWE-20,"CWE-20 void httpParseAuthorizationField ( HttpConnection * connection , char_t * value ) { char_t * p ; char_t * token ; token = osStrtok_r ( value , ""\\t"" , & p ) ; if ( token == NULL ) { return ; } # if ( HTTP_SERVER_BASIC_AUTH_SUPPORT == ENABLED ) else if ( ! osStrcasecmp ( token , ""Basic"" ) ) { error_t error ; size_t n ; char_t * separator ; connection -> request . auth . mode = HTTP_AUTH_MODE_BASIC ; token = osStrtok_r ( NULL , ""\\t"" , & p ) ; if ( token != NULL ) { error = base64Decode ( token , osStrlen ( token ) , token , & n ) ; if ( ! error ) { token [ n ] = '\\0' ; separator = strchr ( token , ':' ) ; if ( separator != NULL ) { * separator = '\\0' ; strSafeCopy ( connection -> request . auth . user , token , HTTP_SERVER_USERNAME_MAX_LEN ) ; token = separator + 1 ; connection -> request . auth . password = token ; } } } TRACE_DEBUG ( ""Authorizationheader:\\r\\n"" ) ; TRACE_DEBUG ( ""username:%s\\r\\n"" , connection -> request . auth . user ) ; TRACE_DEBUG ( ""password:%s\\r\\n"" , connection -> request . auth . password ) ; } # endif # if ( HTTP_SERVER_DIGEST_AUTH_SUPPORT == ENABLED ) else if ( ! osStrcasecmp ( token , ""Digest"" ) ) { size_t n ; char_t * separator ; char_t * name ; connection -> request . auth . mode = HTTP_AUTH_MODE_DIGEST ; token = osStrtok_r ( NULL , "","" , & p ) ; while ( token != NULL ) { separator = strchr ( token , '=' ) ; if ( separator != NULL ) { * separator = '\\0' ; name = strTrimWhitespace ( token ) ; value = strTrimWhitespace ( separator + 1 ) ; n = osStrlen ( value ) ; if ( n > 0 && value [ n - 1 ] == \'\\""\' ) value [ n - 1 ] = '\\0' ; if ( value [ 0 ] == \'\\""\' ) value ++ ; if ( ! osStrcasecmp ( name , ""username"" ) ) { strSafeCopy ( connection -> request . auth . user , value , HTTP_SERVER_USERNAME_MAX_LEN ) ; } else if ( ! osStrcasecmp ( name , ""realm"" ) ) { connection -> request . auth . realm = value ; } else if ( ! osStrcasecmp ( name , ""nonce"" ) ) { connection -> request . auth . nonce = value ; } else if ( ! osStrcasecmp ( name , ""uri"" ) ) { connection -> request . auth . uri = value ; } else if ( ! osStrcasecmp ( name , ""qop"" ) ) { connection -> request . auth . qop = value ; } else if ( ! osStrcasecmp ( name , ""nc"" ) ) { connection -> request . auth . nc = value ; } else if ( ! osStrcasecmp ( name , ""cnonce"" ) ) { connection -> request . auth . cnonce = value ; } else if ( ! osStrcasecmp ( name , ""response"" ) ) { connection -> request . auth . response = value ; } else if ( ! osStrcasecmp ( name , ""opaque"" ) ) { connection -> request . auth . opaque = value ; } token = osStrtok_r ( NULL , "","" , & p ) ; } } TRACE_DEBUG ( ""Authorizationheader:\\r\\n"" ) ; TRACE_DEBUG ( ""username:%s\\r\\n"" , connection -> request . auth . user ) ; TRACE_DEBUG ( ""realm:%s\\r\\n"" , connection -> request . auth . realm ) ; TRACE_DEBUG ( ""nonce:%s\\r\\n"" , connection -> request . auth . nonce ) ; TRACE_DEBUG ( ""uri:%s\\r\\n"" , connection -> request . auth . uri ) ; TRACE_DEBUG ( ""qop:%s\\r\\n"" , connection -> request . auth . qop ) ; TRACE_DEBUG ( ""nc:%s\\r\\n"" , connection -> request . auth . nc ) ; TRACE_DEBUG ( ""cnonce:%s\\r\\n"" , connection -> request . auth . cnonce ) ; TRACE_DEBUG ( ""response:%s\\r\\n"" , connection -> request . auth . response ) ; TRACE_DEBUG ( ""opaque:%s\\r\\n"" , connection -> request . auth . opaque ) ; } # endif else { return ; } # if ( HTTP_SERVER_BASIC_AUTH_SUPPORT == ENABLED || HTTP_SERVER_DIGEST_AUTH_SUPPORT == ENABLED ) connection -> request . auth . found = TRUE ; if ( connection -> settings -> authCallback != NULL ) { connection -> status = connection -> settings -> authCallback ( connection , connection -> request . auth . user , connection -> request . uri ) ; } else { connection -> status = HTTP_ACCESS_ALLOWED ; } # endif } "," ; separator = osStrchr ( token , { separator = osStrchr ( token , ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 452,CWE-369,"CWE-369 static int iwgif_read_image ( struct iwgifrcontext * rctx ) { int retval = 0 ; struct lzwdeccontext d ; size_t subblocksize ; int has_local_ct ; int local_ct_size ; unsigned int root_codesize ; if ( ! iwgif_read ( rctx , rctx -> rbuf , 9 ) ) goto done ; rctx -> image_left = ( int ) iw_get_ui16le ( & rctx -> rbuf [ 0 ] ) ; rctx -> image_top = ( int ) iw_get_ui16le ( & rctx -> rbuf [ 2 ] ) ; rctx -> image_width = ( int ) iw_get_ui16le ( & rctx -> rbuf [ 4 ] ) ; rctx -> image_height = ( int ) iw_get_ui16le ( & rctx -> rbuf [ 6 ] ) ; rctx -> interlaced = ( int ) ( ( rctx -> rbuf [ 8 ] >> 6 ) & 0x01 ) ; has_local_ct = ( int ) ( ( rctx -> rbuf [ 8 ] >> 7 ) & 0x01 ) ; if ( has_local_ct ) { local_ct_size = ( int ) ( rctx -> rbuf [ 8 ] & 0x07 ) ; rctx -> colortable . num_entries = 1 << ( 1 + local_ct_size ) ; } if ( has_local_ct ) { if ( ! iwgif_read_color_table ( rctx , & rctx -> colortable ) ) goto done ; } if ( rctx -> has_transparency ) { rctx -> colortable . entry [ rctx -> trans_color_index ] . a = 0 ; } if ( ! iwgif_read ( rctx , rctx -> rbuf , 1 ) ) goto done ; root_codesize = ( unsigned int ) rctx -> rbuf [ 0 ] ; if ( root_codesize < 2 || root_codesize > 11 ) { iw_set_error ( rctx -> ctx , ""InvalidLZWminimumcodesize"" ) ; goto done ; } if ( ! iwgif_init_screen ( rctx ) ) goto done ; rctx -> total_npixels = ( size_t ) rctx -> image_width * ( size_t ) rctx -> image_height ; if ( ! iwgif_make_row_pointers ( rctx ) ) goto done ; lzw_init ( & d , root_codesize ) ; lzw_clear ( & d ) ; while ( 1 ) { if ( ! iwgif_read ( rctx , rctx -> rbuf , 1 ) ) goto done ; subblocksize = ( size_t ) rctx -> rbuf [ 0 ] ; if ( subblocksize == 0 ) break ; if ( ! iwgif_read ( rctx , rctx -> rbuf , subblocksize ) ) goto done ; if ( ! lzw_process_bytes ( rctx , & d , rctx -> rbuf , subblocksize ) ) goto done ; if ( d . eoi_flag ) break ; if ( rctx -> pixels_set >= rctx -> total_npixels ) break ; } retval = 1 ; done : return retval ; } "," ] ) ; if ( rctx -> image_width < 1 || rctx -> image_height < 1 ) { iw_set_error ( rctx -> ctx , ""Invalidimagedimensions"" ) ; goto done ; } ",jsummers@imageworsener/ca3356eb49fee03e2eaf6b6aff826988c1122d93,CVE-2017-7962,https://github.com/jsummers/imageworsener/commit/ca3356eb49fee03e2eaf6b6aff826988c1122d93,2017-04-19T15:59Z 453,CWE-119,"CWE-119 void vp8_default_coef_probs ( VP8_COMMON * pc ) { vpx_memcpy ( pc -> fc . coef_probs , default_coef_probs , sizeof ( default_coef_probs ) ) ; } "," pc ) { memcpy ( pc -> ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 454,CWE-119,"CWE-119 static int set_registers ( pegasus_t * pegasus , __u16 indx , __u16 size , void * data ) { int ret ; ret = usb_control_msg ( pegasus -> usb , usb_sndctrlpipe ( pegasus -> usb , 0 ) , PEGASUS_REQ_SET_REGS , PEGASUS_REQT_WRITE , 0 , indx , data , size , 100 ) ; if ( ret < 0 ) netif_dbg ( pegasus , drv , pegasus -> net , ""%sreturned%d\\n"" , __func__ , ret ) ; return ret ; } "," __u16 size , const data ) { u8 * buf ; int ret ; buf = kmemdup ( data , size , GFP_NOIO ) ; if ( ! buf ) return - ENOMEM ; ret = , indx , buf , size , ret ) ; kfree ( buf ) ; ",torvalds@linux/5593523f968bc86d42a035c6df47d5e0979b5ace,CVE-2017-8068,https://github.com/torvalds/linux/commit/5593523f968bc86d42a035c6df47d5e0979b5ace,2017-04-23T05:59Z 455,CWE-125,"CWE-125 mod_ty Module ( asdl_seq * body , PyArena * arena ) { mod_ty p ; p = ( mod_ty ) PyArena_Malloc ( arena , sizeof ( * p ) ) ; if ( ! p ) return NULL ; p -> kind = Module_kind ; p -> v . Module . body = body ; return p ; } "," asdl_seq * body , asdl_seq * type_ignores = body ; p -> v . Module . type_ignores = type_ignores ; ",python@typed_ast/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,CVE-2019-19275,https://github.com/python/typed_ast/commit/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,2019-11-26T15:15Z 456,CWE-000,"CWE-000 void sas_unregister_dev ( struct asd_sas_port * port , struct domain_device * dev ) { if ( ! test_bit ( SAS_DEV_DESTROY , & dev -> state ) && ! list_empty ( & dev -> disco_list_node ) ) { list_del_init ( & dev -> disco_list_node ) ; sas_rphy_free ( dev -> rphy ) ; sas_unregister_common_dev ( port , dev ) ; return ; } if ( ! test_and_set_bit ( SAS_DEV_DESTROY , & dev -> state ) ) { sas_rphy_unlink ( dev -> rphy ) ; list_move_tail ( & dev -> disco_list_node , & port -> destroy_list ) ; sas_discover_event ( dev -> port , DISCE_DESTRUCT ) ; } } "," destroy_list ) ; } } ",torvalds@linux/0558f33c06bb910e2879e355192227a8e8f0219d,CVE-2017-18232,https://github.com/torvalds/linux/commit/0558f33c06bb910e2879e355192227a8e8f0219d,2018-03-15T04:29Z 457,CWE-119,"CWE-119 int vp9_lookahead_push ( struct lookahead_ctx * ctx , YV12_BUFFER_CONFIG * src , int64_t ts_start , int64_t ts_end , unsigned int flags ) { struct lookahead_entry * buf ; # if USE_PARTIAL_COPY int row , col , active_end ; int mb_rows = ( src -> y_height + 15 ) >> 4 ; int mb_cols = ( src -> y_width + 15 ) >> 4 ; # endif if ( ctx -> sz + 1 + MAX_PRE_FRAMES > ctx -> max_sz ) return 1 ; ctx -> sz ++ ; buf = pop ( ctx , & ctx -> write_idx ) ; # if USE_PARTIAL_COPY if ( ctx -> max_sz == 1 && active_map && ! flags ) { for ( row = 0 ; row < mb_rows ; ++ row ) { col = 0 ; while ( 1 ) { for ( ; col < mb_cols ; ++ col ) { if ( active_map [ col ] ) break ; } if ( col == mb_cols ) break ; active_end = col ; for ( ; active_end < mb_cols ; ++ active_end ) { if ( ! active_map [ active_end ] ) break ; } vp9_copy_and_extend_frame_with_rect ( src , & buf -> img , row << 4 , col << 4 , 16 , ( active_end - col ) << 4 ) ; col = active_end ; } active_map += mb_cols ; } } else { vp9_copy_and_extend_frame ( src , & buf -> img ) ; } # else vp9_copy_and_extend_frame ( src , & buf -> img ) ; # endif buf -> ts_start = ts_start ; buf -> ts_end = ts_end ; buf -> flags = flags ; return 0 ; } "," int64_t ts_end , # if CONFIG_VP9_HIGHBITDEPTH int use_highbitdepth , # endif ; # endif int width = src -> y_crop_width ; int height = src -> y_crop_height ; int uv_width = src -> uv_crop_width ; int uv_height = src -> uv_crop_height ; int subsampling_x = src -> subsampling_x ; int subsampling_y = src -> subsampling_y ; int larger_dimensions , new_dimensions ; write_idx ) ; new_dimensions = width != buf -> img . y_crop_width || height != buf -> img . y_crop_height || uv_width != buf -> img . uv_crop_width || uv_height != buf -> img . uv_crop_height ; larger_dimensions = width > buf -> img . y_width || height > buf -> img . y_height || uv_width > buf -> img . uv_width || uv_height > buf -> img . uv_height ; assert ( ! larger_dimensions || new_dimensions ) ; USE_PARTIAL_COPY if ( ! new_dimensions && } else { # endif if ( larger_dimensions ) { YV12_BUFFER_CONFIG new_img ; memset ( & new_img , 0 , sizeof ( new_img ) ) ; if ( vpx_alloc_frame_buffer ( & new_img , width , height , subsampling_x , subsampling_y , # if CONFIG_VP9_HIGHBITDEPTH use_highbitdepth , # endif VP9_ENC_BORDER_IN_PIXELS , 0 ) ) return 1 ; vpx_free_frame_buffer ( & buf -> img ) ; buf -> img = new_img ; } else if ( new_dimensions ) { buf -> img . y_crop_width = src -> y_crop_width ; buf -> img . y_crop_height = src -> y_crop_height ; buf -> img . uv_crop_width = src -> uv_crop_width ; buf -> img . uv_crop_height = src -> uv_crop_height ; buf -> img . subsampling_x = src -> subsampling_x ; buf -> img . subsampling_y = src -> subsampling_y ; } img ) ; # if USE_PARTIAL_COPY } # endif buf ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 458,CWE-399,"CWE-399 static int cuse_channel_release ( struct inode * inode , struct file * file ) { struct fuse_dev * fud = file -> private_data ; struct cuse_conn * cc = fc_to_cc ( fud -> fc ) ; int rc ; mutex_lock ( & cuse_lock ) ; list_del_init ( & cc -> list ) ; mutex_unlock ( & cuse_lock ) ; if ( cc -> dev ) device_unregister ( cc -> dev ) ; if ( cc -> cdev ) { unregister_chrdev_region ( cc -> cdev -> dev , 1 ) ; cdev_del ( cc -> cdev ) ; } rc = fuse_dev_release ( inode , file ) ; return rc ; } "," ) ; } fuse_conn_put ( & cc -> fc ) ; ",torvalds@linux/2c5816b4beccc8ba709144539f6fdd764f8fa49c,CVE-2015-1339,https://github.com/torvalds/linux/commit/2c5816b4beccc8ba709144539f6fdd764f8fa49c,2016-04-27T17:59Z 459,CWE-617,"CWE-617 static krb5_error_code kdc_process_s4u_x509_user ( krb5_context context , krb5_kdc_req * request , krb5_pa_data * pa_data , krb5_keyblock * tgs_subkey , krb5_keyblock * tgs_session , krb5_pa_s4u_x509_user * * s4u_x509_user , const char * * status ) { krb5_error_code code ; krb5_data req_data ; req_data . length = pa_data -> length ; req_data . data = ( char * ) pa_data -> contents ; code = decode_krb5_pa_s4u_x509_user ( & req_data , s4u_x509_user ) ; if ( code ) return code ; code = verify_s4u_x509_user_checksum ( context , tgs_subkey ? tgs_subkey : tgs_session , & req_data , request -> nonce , * s4u_x509_user ) ; if ( code ) { * status = ""INVALID_S4U2SELF_CHECKSUM"" ; krb5_free_pa_s4u_x509_user ( context , * s4u_x509_user ) ; * s4u_x509_user = NULL ; return code ; } if ( krb5_princ_size ( context , ( * s4u_x509_user ) -> user_id . user ) == 0 || ( * s4u_x509_user ) -> user_id . subject_cert . length != 0 ) { * status = ""INVALID_S4U2SELF_REQUEST"" ; krb5_free_pa_s4u_x509_user ( context , * s4u_x509_user ) ; * s4u_x509_user = NULL ; return KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN ; } return 0 ; } "," ( code ) { * status = ""DECODE_PA_S4U_X509_USER"" ; return code ; } code = verify_s4u_x509_user_checksum ",krb5@krb5/ffb35baac6981f9e8914f8f3bffd37f284b85970,CVE-2017-11368,https://github.com/krb5/krb5/commit/ffb35baac6981f9e8914f8f3bffd37f284b85970,2017-08-09T18:29Z 460,CWE-119,"CWE-119 static int scsi_disk_emulate_command ( SCSIDiskReq * r , uint8_t * outbuf ) { SCSIRequest * req = & r -> req ; SCSIDiskState * s = DO_UPCAST ( SCSIDiskState , qdev , req -> dev ) ; uint64_t nb_sectors ; int buflen = 0 ; switch ( req -> cmd . buf [ 0 ] ) { case TEST_UNIT_READY : if ( s -> tray_open || ! bdrv_is_inserted ( s -> bs ) ) goto not_ready ; break ; case INQUIRY : buflen = scsi_disk_emulate_inquiry ( req , outbuf ) ; if ( buflen < 0 ) goto illegal_request ; break ; case MODE_SENSE : case MODE_SENSE_10 : buflen = scsi_disk_emulate_mode_sense ( r , outbuf ) ; if ( buflen < 0 ) goto illegal_request ; break ; case READ_TOC : buflen = scsi_disk_emulate_read_toc ( req , outbuf ) ; if ( buflen < 0 ) goto illegal_request ; break ; case RESERVE : if ( req -> cmd . buf [ 1 ] & 1 ) goto illegal_request ; break ; case RESERVE_10 : if ( req -> cmd . buf [ 1 ] & 3 ) goto illegal_request ; break ; case RELEASE : if ( req -> cmd . buf [ 1 ] & 1 ) goto illegal_request ; break ; case RELEASE_10 : if ( req -> cmd . buf [ 1 ] & 3 ) goto illegal_request ; break ; case START_STOP : if ( scsi_disk_emulate_start_stop ( r ) < 0 ) { return - 1 ; } break ; case ALLOW_MEDIUM_REMOVAL : s -> tray_locked = req -> cmd . buf [ 4 ] & 1 ; bdrv_lock_medium ( s -> bs , req -> cmd . buf [ 4 ] & 1 ) ; break ; case READ_CAPACITY_10 : memset ( outbuf , 0 , 8 ) ; bdrv_get_geometry ( s -> bs , & nb_sectors ) ; if ( ! nb_sectors ) goto not_ready ; nb_sectors /= s -> cluster_size ; nb_sectors -- ; s -> max_lba = nb_sectors ; if ( nb_sectors > UINT32_MAX ) nb_sectors = UINT32_MAX ; outbuf [ 0 ] = ( nb_sectors >> 24 ) & 0xff ; outbuf [ 1 ] = ( nb_sectors >> 16 ) & 0xff ; outbuf [ 2 ] = ( nb_sectors >> 8 ) & 0xff ; outbuf [ 3 ] = nb_sectors & 0xff ; outbuf [ 4 ] = 0 ; outbuf [ 5 ] = 0 ; outbuf [ 6 ] = s -> cluster_size * 2 ; outbuf [ 7 ] = 0 ; buflen = 8 ; break ; case GET_CONFIGURATION : memset ( outbuf , 0 , 8 ) ; outbuf [ 7 ] = 8 ; buflen = 8 ; break ; case SERVICE_ACTION_IN_16 : if ( ( req -> cmd . buf [ 1 ] & 31 ) == SAI_READ_CAPACITY_16 ) { DPRINTF ( ""SAIREADCAPACITY(16)\\n"" ) ; memset ( outbuf , 0 , req -> cmd . xfer ) ; bdrv_get_geometry ( s -> bs , & nb_sectors ) ; if ( ! nb_sectors ) goto not_ready ; nb_sectors /= s -> cluster_size ; nb_sectors -- ; s -> max_lba = nb_sectors ; outbuf [ 0 ] = ( nb_sectors >> 56 ) & 0xff ; outbuf [ 1 ] = ( nb_sectors >> 48 ) & 0xff ; outbuf [ 2 ] = ( nb_sectors >> 40 ) & 0xff ; outbuf [ 3 ] = ( nb_sectors >> 32 ) & 0xff ; outbuf [ 4 ] = ( nb_sectors >> 24 ) & 0xff ; outbuf [ 5 ] = ( nb_sectors >> 16 ) & 0xff ; outbuf [ 6 ] = ( nb_sectors >> 8 ) & 0xff ; outbuf [ 7 ] = nb_sectors & 0xff ; outbuf [ 8 ] = 0 ; outbuf [ 9 ] = 0 ; outbuf [ 10 ] = s -> cluster_size * 2 ; outbuf [ 11 ] = 0 ; outbuf [ 12 ] = 0 ; outbuf [ 13 ] = get_physical_block_exp ( & s -> qdev . conf ) ; if ( s -> qdev . conf . discard_granularity ) { outbuf [ 14 ] = 0x80 ; } buflen = req -> cmd . xfer ; break ; } DPRINTF ( ""UnsupportedServiceActionIn\\n"" ) ; goto illegal_request ; case VERIFY_10 : break ; default : scsi_check_condition ( r , SENSE_CODE ( INVALID_OPCODE ) ) ; return - 1 ; } return buflen ; not_ready : if ( s -> tray_open || ! bdrv_is_inserted ( s -> bs ) ) { scsi_check_condition ( r , SENSE_CODE ( NO_MEDIUM ) ) ; } else { scsi_check_condition ( r , SENSE_CODE ( LUN_NOT_READY ) ) ; } return - 1 ; illegal_request : if ( r -> req . status == - 1 ) { scsi_check_condition ( r , SENSE_CODE ( INVALID_FIELD ) ) ; } return - 1 ; } "," SCSIDiskReq * r ) { SCSIRequest * req = & r -> req ; SCSIDiskState * s = DO_UPCAST ( SCSIDiskState , qdev , req -> dev ) ; uint64_t nb_sectors ; uint8_t * outbuf uint8_t * outbuf ; int buflen = 0 ; if ( ! r -> iov . iov_base ) { if ( req -> cmd . xfer > 65536 ) { goto illegal_request ; } r -> buflen = MAX ( 4096 , req -> cmd . xfer ) ; r -> iov . iov_base = qemu_blockalign ( s -> bs , r -> buflen ) ; } outbuf = r -> iov . iov_base ; switch ( ",bonzini@qemu/7285477ab11831b1cf56e45878a89170dd06d9b9,CVE-2011-3346,https://github.com/bonzini/qemu/commit/7285477ab11831b1cf56e45878a89170dd06d9b9,2014-04-01T06:35Z 461,CWE-617,"CWE-617 static int er_supported ( ERContext * s ) { if ( s -> avctx -> hwaccel && s -> avctx -> hwaccel -> decode_slice || ! s -> cur_pic . f || s -> cur_pic . field_picture || s -> avctx -> profile == FF_PROFILE_MPEG4_SIMPLE_STUDIO ) return 0 ; return 1 ; } "," cur_pic . field_picture ) return 0 ",FFmpeg@FFmpeg/bd27a9364ca274ca97f1df6d984e88a0700fb235,CVE-2018-13304,https://github.com/FFmpeg/FFmpeg/commit/bd27a9364ca274ca97f1df6d984e88a0700fb235,2018-07-05T17:29Z 462,CWE-000,"CWE-000 static int rds_loop_xmit ( struct rds_connection * conn , struct rds_message * rm , unsigned int hdr_off , unsigned int sg , unsigned int off ) { if ( rm -> m_inc . i_hdr . h_flags & RDS_FLAG_CONG_BITMAP ) { rds_cong_map_updated ( conn -> c_fcong , ~ ( u64 ) 0 ) ; return sizeof ( struct rds_header ) + RDS_CONG_MAP_BYTES ; } BUG_ON ( hdr_off || sg || off ) ; rds_inc_init ( & rm -> m_inc , conn , conn -> c_laddr ) ; rds_message_addref ( rm ) ; rds_recv_incoming ( conn , conn -> c_laddr , conn -> c_faddr , & rm -> m_inc , GFP_KERNEL , KM_USER0 ) ; rds_send_drop_acked ( conn , be64_to_cpu ( rm -> m_inc . i_hdr . h_sequence ) , NULL ) ; rds_inc_put ( & rm -> m_inc ) ; return sizeof ( struct rds_header ) + be32_to_cpu ( rm -> m_inc . i_hdr . h_len ) ; } "," off ) { struct scatterlist * sgp = & rm -> data . op_sg [ sg ] ; int ret = sizeof ( struct rds_header ) + be32_to_cpu ( rm -> m_inc . i_hdr . h_len ) ; 0 ) ; ret = min_t ( int , ret , sgp -> length - conn -> c_xmit_data_off ) ; goto out ; } BUG_ON m_inc ) ; out : return ret ; } ",torvalds@linux/6094628bfd94323fc1cea05ec2c6affd98c18f7f,CVE-2011-1023,https://github.com/torvalds/linux/commit/6094628bfd94323fc1cea05ec2c6affd98c18f7f,2012-06-21T23:55Z 463,CWE-119,"CWE-119 static struct grub_ext4_extent_header * grub_ext4_find_leaf ( struct grub_ext2_data * data , char * buf , struct grub_ext4_extent_header * ext_block , grub_uint32_t fileblock ) { struct grub_ext4_extent_idx * index ; while ( 1 ) { int i ; grub_disk_addr_t block ; index = ( struct grub_ext4_extent_idx * ) ( ext_block + 1 ) ; if ( grub_le_to_cpu16 ( ext_block -> magic ) != EXT4_EXT_MAGIC ) return 0 ; if ( ext_block -> depth == 0 ) return ext_block ; for ( i = 0 ; i < grub_le_to_cpu16 ( ext_block -> entries ) ; i ++ ) { if ( fileblock < grub_le_to_cpu32 ( index [ i ] . block ) ) break ; } if ( -- i < 0 ) return 0 ; block = grub_le_to_cpu16 ( index [ i ] . leaf_hi ) ; block = ( block << 32 ) + grub_le_to_cpu32 ( index [ i ] . leaf ) ; if ( grub_disk_read ( data -> disk , block << LOG2_EXT2_BLOCK_SIZE ( data ) , 0 , EXT2_BLOCK_SIZE ( data ) , buf ) ) return 0 ; ext_block = ( struct grub_ext4_extent_header * ) buf ; } } "," buf ) ) { return 0 ; } ext_block = ( ",radare@radare2/65000a7fd9eea62359e6d6714f17b94a99a82edd,CVE-2017-9763,https://github.com/radare/radare2/commit/65000a7fd9eea62359e6d6714f17b94a99a82edd,2017-06-19T16:29Z 464,CWE-20,"CWE-20 long keyctl_read_key ( key_serial_t keyid , char __user * buffer , size_t buflen ) { struct key * key ; key_ref_t key_ref ; long ret ; key_ref = lookup_user_key ( keyid , 0 , 0 ) ; if ( IS_ERR ( key_ref ) ) { ret = - ENOKEY ; goto error ; } key = key_ref_to_ptr ( key_ref ) ; if ( test_bit ( KEY_FLAG_NEGATIVE , & key -> flags ) ) { ret = - ENOKEY ; goto error2 ; } ret = key_permission ( key_ref , KEY_NEED_READ ) ; if ( ret == 0 ) goto can_read_key ; if ( ret != - EACCES ) goto error2 ; if ( ! is_key_possessed ( key_ref ) ) { ret = - EACCES ; goto error2 ; } can_read_key : ret = - EOPNOTSUPP ; if ( key -> type -> read ) { down_read ( & key -> sem ) ; ret = key_validate ( key ) ; if ( ret == 0 ) ret = key -> type -> read ( key , buffer , buflen ) ; up_read ( & key -> sem ) ; } error2 : key_put ( key ) ; error : return ret ; } "," key_ref ) ; ret = key_read_state ( key ) ; if ( ret < 0 ) goto error2 ; ret = key_permission ",torvalds@linux/363b02dab09b3226f3bd1420dad9c72b79a42a76,CVE-2017-15951,https://github.com/torvalds/linux/commit/363b02dab09b3226f3bd1420dad9c72b79a42a76,2017-10-28T02:29Z 465,CWE-125,"CWE-125 int mobility_print ( netdissect_options * ndo , const u_char * bp , const u_char * bp2 _U_ ) { const struct ip6_mobility * mh ; const u_char * ep ; unsigned mhlen , hlen ; uint8_t type ; mh = ( const struct ip6_mobility * ) bp ; ep = ndo -> ndo_snapend ; if ( ! ND_TTEST ( mh -> ip6m_len ) ) { mhlen = ep - bp ; goto trunc ; } mhlen = ( mh -> ip6m_len + 1 ) << 3 ; ND_TCHECK ( mh -> ip6m_type ) ; type = mh -> ip6m_type ; if ( type <= IP6M_MAX && mhlen < ip6m_hdrlen [ type ] ) { ND_PRINT ( ( ndo , ""(headerlength%uistoosmallfortype%u)"" , mhlen , type ) ) ; goto trunc ; } ND_PRINT ( ( ndo , ""mobility:%s"" , tok2str ( ip6m_str , ""type-#%u"" , type ) ) ) ; switch ( type ) { case IP6M_BINDING_REQUEST : hlen = IP6M_MINLEN ; break ; case IP6M_HOME_TEST_INIT : case IP6M_CAREOF_TEST_INIT : hlen = IP6M_MINLEN ; if ( ndo -> ndo_vflag ) { ND_TCHECK2 ( * mh , hlen + 8 ) ; ND_PRINT ( ( ndo , ""%sInitCookie=%08x:%08x"" , type == IP6M_HOME_TEST_INIT ? ""Home"" : ""Care-of"" , EXTRACT_32BITS ( & bp [ hlen ] ) , EXTRACT_32BITS ( & bp [ hlen + 4 ] ) ) ) ; } hlen += 8 ; break ; case IP6M_HOME_TEST : case IP6M_CAREOF_TEST : ND_TCHECK ( mh -> ip6m_data16 [ 0 ] ) ; ND_PRINT ( ( ndo , ""nonceid=0x%x"" , EXTRACT_16BITS ( & mh -> ip6m_data16 [ 0 ] ) ) ) ; hlen = IP6M_MINLEN ; if ( ndo -> ndo_vflag ) { ND_TCHECK2 ( * mh , hlen + 8 ) ; ND_PRINT ( ( ndo , ""%sInitCookie=%08x:%08x"" , type == IP6M_HOME_TEST ? ""Home"" : ""Care-of"" , EXTRACT_32BITS ( & bp [ hlen ] ) , EXTRACT_32BITS ( & bp [ hlen + 4 ] ) ) ) ; } hlen += 8 ; if ( ndo -> ndo_vflag ) { ND_TCHECK2 ( * mh , hlen + 8 ) ; ND_PRINT ( ( ndo , ""%sKeygenToken=%08x:%08x"" , type == IP6M_HOME_TEST ? ""Home"" : ""Care-of"" , EXTRACT_32BITS ( & bp [ hlen ] ) , EXTRACT_32BITS ( & bp [ hlen + 4 ] ) ) ) ; } hlen += 8 ; break ; case IP6M_BINDING_UPDATE : ND_TCHECK ( mh -> ip6m_data16 [ 0 ] ) ; ND_PRINT ( ( ndo , ""seq#=%u"" , EXTRACT_16BITS ( & mh -> ip6m_data16 [ 0 ] ) ) ) ; hlen = IP6M_MINLEN ; ND_TCHECK2 ( * mh , hlen + 1 ) ; if ( bp [ hlen ] & 0xf0 ) ND_PRINT ( ( ndo , """" ) ) ; if ( bp [ hlen ] & 0x80 ) ND_PRINT ( ( ndo , ""A"" ) ) ; if ( bp [ hlen ] & 0x40 ) ND_PRINT ( ( ndo , ""H"" ) ) ; if ( bp [ hlen ] & 0x20 ) ND_PRINT ( ( ndo , ""L"" ) ) ; if ( bp [ hlen ] & 0x10 ) ND_PRINT ( ( ndo , ""K"" ) ) ; hlen += 1 ; hlen += 1 ; ND_TCHECK2 ( * mh , hlen + 2 ) ; ND_PRINT ( ( ndo , ""lifetime=%u"" , EXTRACT_16BITS ( & bp [ hlen ] ) << 2 ) ) ; hlen += 2 ; break ; case IP6M_BINDING_ACK : ND_TCHECK ( mh -> ip6m_data8 [ 0 ] ) ; ND_PRINT ( ( ndo , ""status=%u"" , mh -> ip6m_data8 [ 0 ] ) ) ; if ( mh -> ip6m_data8 [ 1 ] & 0x80 ) ND_PRINT ( ( ndo , ""K"" ) ) ; hlen = IP6M_MINLEN ; ND_TCHECK2 ( * mh , hlen + 2 ) ; ND_PRINT ( ( ndo , ""seq#=%u"" , EXTRACT_16BITS ( & bp [ hlen ] ) ) ) ; hlen += 2 ; ND_TCHECK2 ( * mh , hlen + 2 ) ; ND_PRINT ( ( ndo , ""lifetime=%u"" , EXTRACT_16BITS ( & bp [ hlen ] ) << 2 ) ) ; hlen += 2 ; break ; case IP6M_BINDING_ERROR : ND_TCHECK ( mh -> ip6m_data8 [ 0 ] ) ; ND_PRINT ( ( ndo , ""status=%u"" , mh -> ip6m_data8 [ 0 ] ) ) ; hlen = IP6M_MINLEN ; ND_TCHECK2 ( * mh , hlen + 16 ) ; ND_PRINT ( ( ndo , ""homeaddr%s"" , ip6addr_string ( ndo , & bp [ hlen ] ) ) ) ; hlen += 16 ; break ; default : ND_PRINT ( ( ndo , ""len=%u"" , mh -> ip6m_len ) ) ; return ( mhlen ) ; break ; } if ( ndo -> ndo_vflag ) if ( mobility_opt_print ( ndo , & bp [ hlen ] , mhlen - hlen ) ) goto trunc ; return ( mhlen ) ; trunc : ND_PRINT ( ( ndo , ""%s"" , tstr ) ) ; return ( - 1 ) ; } "," ndo_vflag ) { ND_TCHECK_32BITS ( & bp [ hlen + 4 ] ) ; ND_PRINT ndo_vflag ) { ND_TCHECK_32BITS ( & bp [ hlen + 4 ] ) ; ND_PRINT ndo_vflag ) { ND_TCHECK_32BITS ( & bp [ hlen + 4 ] ) ; ND_PRINT = IP6M_MINLEN ; ND_TCHECK_16BITS ( & bp [ hlen ] ) ; if & 0xf0 ) { ) ) ; } += 1 ; ND_TCHECK_16BITS ( & bp [ hlen ] ) ; ND_PRINT ) ) ; ND_TCHECK ( mh -> [ 1 ] ) ; if ( mh -> ip6m_data8 [ 1 ] = IP6M_MINLEN ; ND_TCHECK_16BITS ( & bp [ hlen ] ) ; ND_PRINT += 2 ; ND_TCHECK_16BITS ( & bp [ hlen ] ) ; ND_PRINT ; ND_TCHECK2 ( bp [ hlen ] , 16 ) ; ",the-tcpdump-group@tcpdump/db8c799f6dfc68765c9451fcbfca06e662f5bd5f,CVE-2017-13009,https://github.com/the-tcpdump-group/tcpdump/commit/db8c799f6dfc68765c9451fcbfca06e662f5bd5f,2017-09-14T06:29Z 466,CWE-000,"CWE-000 static void ieee80211_if_setup ( struct net_device * dev ) { ether_setup ( dev ) ; dev -> netdev_ops = & ieee80211_dataif_ops ; dev -> destructor = free_netdev ; } "," ; dev -> priv_flags &= ~ IFF_TX_SKB_SHARING ; dev -> ",torvalds@linux/550fd08c2cebad61c548def135f67aba284c6162,CVE-2011-4112,https://github.com/torvalds/linux/commit/550fd08c2cebad61c548def135f67aba284c6162,2012-05-17T11:00Z 467,CWE-125,"CWE-125 struct _mdi * _WM_ParseNewHmi ( uint8_t * hmi_data , uint32_t hmi_size ) { uint32_t hmi_tmp = 0 ; uint8_t * hmi_base = hmi_data ; uint16_t hmi_bpm = 0 ; uint16_t hmi_division = 0 ; uint32_t hmi_track_cnt = 0 ; uint32_t * hmi_track_offset = NULL ; uint32_t i = 0 ; uint32_t j = 0 ; uint8_t * hmi_addr = NULL ; uint32_t * hmi_track_header_length = NULL ; struct _mdi * hmi_mdi = NULL ; uint32_t tempo_f = 5000000.0 ; uint32_t * hmi_track_end = NULL ; uint8_t hmi_tracks_ended = 0 ; uint8_t * hmi_running_event = NULL ; uint32_t setup_ret = 0 ; uint32_t * hmi_delta = NULL ; uint32_t smallest_delta = 0 ; uint32_t subtract_delta = 0 ; uint32_t sample_count = 0 ; float sample_count_f = 0 ; float sample_remainder = 0 ; float samples_per_delta_f = 0.0 ; struct _note { uint32_t length ; uint8_t channel ; } * note ; UNUSED ( hmi_size ) ; if ( memcmp ( hmi_data , ""HMI-MIDISONG061595"" , 18 ) ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_NOT_HMI , NULL , 0 ) ; return NULL ; } hmi_bpm = hmi_data [ 212 ] ; hmi_division = 60 ; hmi_track_cnt = hmi_data [ 228 ] ; hmi_mdi = _WM_initMDI ( ) ; _WM_midi_setup_divisions ( hmi_mdi , hmi_division ) ; if ( ( _WM_MixerOptions & WM_MO_ROUNDTEMPO ) ) { tempo_f = ( float ) ( 60000000 / hmi_bpm ) + 0.5f ; } else { tempo_f = ( float ) ( 60000000 / hmi_bpm ) ; } samples_per_delta_f = _WM_GetSamplesPerTick ( hmi_division , ( uint32_t ) tempo_f ) ; _WM_midi_setup_tempo ( hmi_mdi , ( uint32_t ) tempo_f ) ; hmi_track_offset = ( uint32_t * ) malloc ( sizeof ( uint32_t ) * hmi_track_cnt ) ; hmi_track_header_length = malloc ( sizeof ( uint32_t ) * hmi_track_cnt ) ; hmi_track_end = malloc ( sizeof ( uint32_t ) * hmi_track_cnt ) ; hmi_delta = malloc ( sizeof ( uint32_t ) * hmi_track_cnt ) ; note = malloc ( sizeof ( struct _note ) * 128 * hmi_track_cnt ) ; hmi_running_event = malloc ( sizeof ( uint8_t ) * 128 * hmi_track_cnt ) ; hmi_data += 370 ; smallest_delta = 0xffffffff ; if ( hmi_size < ( 370 + ( hmi_track_cnt * 17 ) ) ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_NOT_HMI , ""filetooshort"" , 0 ) ; goto _hmi_end ; } hmi_track_offset [ 0 ] = * hmi_data ; for ( i = 0 ; i < hmi_track_cnt ; i ++ ) { hmi_track_offset [ i ] = * hmi_data ++ ; hmi_track_offset [ i ] += ( * hmi_data ++ << 8 ) ; hmi_track_offset [ i ] += ( * hmi_data ++ << 16 ) ; hmi_track_offset [ i ] += ( * hmi_data ++ << 24 ) ; if ( hmi_size < ( hmi_track_offset [ i ] + 0x5a + 4 ) ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_NOT_HMI , ""filetooshort"" , 0 ) ; goto _hmi_end ; } hmi_addr = hmi_base + hmi_track_offset [ i ] ; if ( memcmp ( hmi_addr , ""HMI-MIDITRACK"" , 13 ) ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_NOT_HMI , NULL , 0 ) ; goto _hmi_end ; } hmi_track_header_length [ i ] = hmi_addr [ 0x57 ] ; hmi_track_header_length [ i ] += ( hmi_addr [ 0x58 ] << 8 ) ; hmi_track_header_length [ i ] += ( hmi_addr [ 0x59 ] << 16 ) ; hmi_track_header_length [ i ] += ( hmi_addr [ 0x5a ] << 24 ) ; hmi_addr += hmi_track_header_length [ i ] ; hmi_track_offset [ i ] += hmi_track_header_length [ i ] ; hmi_delta [ i ] = 0 ; if ( * hmi_addr > 0x7f ) { do { hmi_delta [ i ] = ( hmi_delta [ i ] << 7 ) + ( * hmi_addr & 0x7f ) ; hmi_addr ++ ; hmi_track_offset [ i ] ++ ; } while ( * hmi_addr > 0x7f ) ; } hmi_delta [ i ] = ( hmi_delta [ i ] << 7 ) + ( * hmi_addr & 0x7f ) ; hmi_track_offset [ i ] ++ ; hmi_addr ++ ; if ( hmi_delta [ i ] < smallest_delta ) { smallest_delta = hmi_delta [ i ] ; } hmi_track_end [ i ] = 0 ; hmi_running_event [ i ] = 0 ; for ( j = 0 ; j < 128 ; j ++ ) { hmi_tmp = ( 128 * i ) + j ; note [ hmi_tmp ] . length = 0 ; note [ hmi_tmp ] . channel = 0 ; } } subtract_delta = smallest_delta ; sample_count_f = ( ( ( float ) smallest_delta * samples_per_delta_f ) + sample_remainder ) ; sample_count = ( uint32_t ) sample_count_f ; sample_remainder = sample_count_f - ( float ) sample_count ; hmi_mdi -> events [ hmi_mdi -> event_count - 1 ] . samples_to_next += sample_count ; hmi_mdi -> extra_info . approx_total_samples += sample_count ; while ( hmi_tracks_ended < hmi_track_cnt ) { smallest_delta = 0 ; for ( i = 0 ; i < hmi_track_cnt ; i ++ ) { if ( hmi_track_end [ i ] ) continue ; for ( j = 0 ; j < 128 ; j ++ ) { hmi_tmp = ( 128 * i ) + j ; if ( note [ hmi_tmp ] . length ) { note [ hmi_tmp ] . length -= subtract_delta ; if ( note [ hmi_tmp ] . length ) { if ( ( ! smallest_delta ) || ( smallest_delta > note [ hmi_tmp ] . length ) ) { smallest_delta = note [ hmi_tmp ] . length ; } } else { _WM_midi_setup_noteoff ( hmi_mdi , note [ hmi_tmp ] . channel , j , 0 ) ; } } } if ( hmi_delta [ i ] ) { hmi_delta [ i ] -= subtract_delta ; if ( hmi_delta [ i ] ) { if ( ( ! smallest_delta ) || ( smallest_delta > hmi_delta [ i ] ) ) { smallest_delta = hmi_delta [ i ] ; } continue ; } } do { hmi_data = hmi_base + hmi_track_offset [ i ] ; hmi_delta [ i ] = 0 ; if ( hmi_data [ 0 ] == 0xfe ) { if ( hmi_data [ 1 ] == 0x10 ) { hmi_tmp = ( hmi_data [ 4 ] + 5 ) ; hmi_data += hmi_tmp ; hmi_track_offset [ i ] += hmi_tmp ; } else if ( hmi_data [ 1 ] == 0x15 ) { hmi_data += 4 ; hmi_track_offset [ i ] += 4 ; } hmi_data += 4 ; hmi_track_offset [ i ] += 4 ; } else { if ( ( setup_ret = _WM_SetupMidiEvent ( hmi_mdi , hmi_data , hmi_running_event [ i ] ) ) == 0 ) { goto _hmi_end ; } if ( ( hmi_data [ 0 ] == 0xff ) && ( hmi_data [ 1 ] == 0x2f ) && ( hmi_data [ 2 ] == 0x00 ) ) { hmi_track_end [ i ] = 1 ; hmi_tracks_ended ++ ; for ( j = 0 ; j < 128 ; j ++ ) { hmi_tmp = ( 128 * i ) + j ; if ( note [ hmi_tmp ] . length ) { _WM_midi_setup_noteoff ( hmi_mdi , note [ hmi_tmp ] . channel , j , 0 ) ; note [ hmi_tmp ] . length = 0 ; } } goto _hmi_next_track ; } if ( ( * hmi_data == 0xF0 ) || ( * hmi_data == 0xF7 ) ) { hmi_running_event [ i ] = 0 ; } else if ( * hmi_data < 0xF0 ) { if ( * hmi_data >= 0x80 ) { hmi_running_event [ i ] = * hmi_data ; } } if ( ( hmi_running_event [ i ] & 0xf0 ) == 0x90 ) { if ( * hmi_data > 127 ) { hmi_tmp = hmi_data [ 1 ] ; } else { hmi_tmp = * hmi_data ; } hmi_tmp += ( i * 128 ) ; note [ hmi_tmp ] . channel = hmi_running_event [ i ] & 0xf ; hmi_data += setup_ret ; hmi_track_offset [ i ] += setup_ret ; note [ hmi_tmp ] . length = 0 ; if ( * hmi_data > 0x7f ) { do { note [ hmi_tmp ] . length = ( note [ hmi_tmp ] . length << 7 ) | ( * hmi_data & 0x7F ) ; hmi_data ++ ; hmi_track_offset [ i ] ++ ; } while ( * hmi_data > 0x7F ) ; } note [ hmi_tmp ] . length = ( note [ hmi_tmp ] . length << 7 ) | ( * hmi_data & 0x7F ) ; hmi_data ++ ; hmi_track_offset [ i ] ++ ; if ( note [ hmi_tmp ] . length ) { if ( ( ! smallest_delta ) || ( smallest_delta > note [ hmi_tmp ] . length ) ) { smallest_delta = note [ hmi_tmp ] . length ; } } else { _WM_midi_setup_noteoff ( hmi_mdi , note [ hmi_tmp ] . channel , j , 0 ) ; } } else { hmi_data += setup_ret ; hmi_track_offset [ i ] += setup_ret ; } } if ( * hmi_data > 0x7f ) { do { hmi_delta [ i ] = ( hmi_delta [ i ] << 7 ) | ( * hmi_data & 0x7F ) ; hmi_data ++ ; hmi_track_offset [ i ] ++ ; } while ( * hmi_data > 0x7F ) ; } hmi_delta [ i ] = ( hmi_delta [ i ] << 7 ) | ( * hmi_data & 0x7F ) ; hmi_data ++ ; hmi_track_offset [ i ] ++ ; } while ( ! hmi_delta [ i ] ) ; if ( ( ! smallest_delta ) || ( smallest_delta > hmi_delta [ i ] ) ) { smallest_delta = hmi_delta [ i ] ; } _hmi_next_track : hmi_tmp = 0 ; UNUSED ( hmi_tmp ) ; } subtract_delta = smallest_delta ; sample_count_f = ( ( ( float ) smallest_delta * samples_per_delta_f ) + sample_remainder ) ; sample_count = ( uint32_t ) sample_count_f ; sample_remainder = sample_count_f - ( float ) sample_count ; hmi_mdi -> events [ hmi_mdi -> event_count - 1 ] . samples_to_next += sample_count ; hmi_mdi -> extra_info . approx_total_samples += sample_count ; } if ( ( hmi_mdi -> reverb = _WM_init_reverb ( _WM_SampleRate , _WM_reverb_room_width , _WM_reverb_room_length , _WM_reverb_listen_posx , _WM_reverb_listen_posy ) ) == NULL ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_MEM , ""toinitreverb"" , 0 ) ; goto _hmi_end ; } hmi_mdi -> extra_info . current_sample = 0 ; hmi_mdi -> current_event = & hmi_mdi -> events [ 0 ] ; hmi_mdi -> samples_to_mix = 0 ; hmi_mdi -> note = NULL ; _WM_ResetToStart ( hmi_mdi ) ; _hmi_end : free ( hmi_track_offset ) ; free ( hmi_track_header_length ) ; free ( hmi_track_end ) ; free ( hmi_delta ) ; free ( note ) ; free ( hmi_running_event ) ; if ( hmi_mdi -> reverb ) return ( hmi_mdi ) ; _WM_freeMDI ( hmi_mdi ) ; return 0 ; } "," = hmi_data ; uint32_t data_siz ; } * note ; if ( ; if ( hmi_track_offset [ i ] >= hmi_size ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_NOT_HMI , ""filetooshort"" , 0 ) ; goto _hmi_end ; } data_siz = hmi_size - hmi_track_offset [ i ] ; if ( += hmi_tmp ; hmi_tmp += 4 ; += 4 ; hmi_tmp = 8 ; } else { hmi_tmp = 4 ; } hmi_data += 4 ; += 4 ; hmi_track_offset [ i ] += 4 ; if ( hmi_tmp > data_siz ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_NOT_HMI , ""filetooshort"" , 0 ) ; goto _hmi_end ; } data_siz -= hmi_tmp ; hmi_mdi , hmi_data , data_siz += setup_ret ; data_siz -= setup_ret ; ; if ( data_siz && { do { if ( ! data_siz ) break ; hmi_data ++ ; data_siz -- ; > 0x7F ) ; } if ( ! data_siz ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_NOT_HMI , ""filetooshort"" , 0 ) ; goto _hmi_end hmi_data ++ ; data_siz -- ; += setup_ret ; data_siz -= setup_ret ; } } if ( data_siz && * hmi_data > { do { if ( ! data_siz ) break ; hmi_data ++ ; data_siz -- ; ) ; } if ( ! data_siz ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_NOT_HMI , ""filetooshort"" , 0 ) ; goto _hmi_end ; } ; hmi_data ++ ; data_siz -- ",Mindwerks@wildmidi/ad6d7cf88d6673167ca1f517248af9409a9f1be1,CVE-2017-11664,https://github.com/Mindwerks/wildmidi/commit/ad6d7cf88d6673167ca1f517248af9409a9f1be1,2017-08-17T16:29Z 468,CWE-200,"CWE-200 static int hci_sock_getname ( struct socket * sock , struct sockaddr * addr , int * addr_len , int peer ) { struct sockaddr_hci * haddr = ( struct sockaddr_hci * ) addr ; struct sock * sk = sock -> sk ; struct hci_dev * hdev = hci_pi ( sk ) -> hdev ; BT_DBG ( ""sock%psk%p"" , sock , sk ) ; if ( ! hdev ) return - EBADFD ; lock_sock ( sk ) ; * addr_len = sizeof ( * haddr ) ; haddr -> hci_family = AF_BLUETOOTH ; haddr -> hci_dev = hdev -> id ; release_sock ( sk ) ; return 0 ; } "," -> id ; haddr -> hci_channel = 0 ; ",torvalds@linux/3f68ba07b1da811bf383b4b701b129bfcb2e4988,CVE-2012-6544,https://github.com/torvalds/linux/commit/3f68ba07b1da811bf383b4b701b129bfcb2e4988,2013-03-15T20:55Z 469,CWE-200,"CWE-200 static int isofs_export_encode_fh ( struct inode * inode , __u32 * fh32 , int * max_len , struct inode * parent ) { struct iso_inode_info * ei = ISOFS_I ( inode ) ; int len = * max_len ; int type = 1 ; __u16 * fh16 = ( __u16 * ) fh32 ; if ( parent && ( len < 5 ) ) { * max_len = 5 ; return 255 ; } else if ( len < 3 ) { * max_len = 3 ; return 255 ; } len = 3 ; fh32 [ 0 ] = ei -> i_iget5_block ; fh16 [ 2 ] = ( __u16 ) ei -> i_iget5_offset ; fh32 [ 2 ] = inode -> i_generation ; if ( parent ) { struct iso_inode_info * eparent ; eparent = ISOFS_I ( parent ) ; fh32 [ 3 ] = eparent -> i_iget5_block ; fh16 [ 3 ] = ( __u16 ) eparent -> i_iget5_offset ; fh32 [ 4 ] = parent -> i_generation ; len = 5 ; type = 2 ; } * max_len = len ; return type ; } "," -> i_iget5_offset ; fh16 [ 3 ] = 0 ; ",torvalds@linux/fe685aabf7c8c9f138e5ea900954d295bf229175,CVE-2012-6549,https://github.com/torvalds/linux/commit/fe685aabf7c8c9f138e5ea900954d295bf229175,2013-03-15T20:55Z 470,CWE-476,"CWE-476 int validate_as_request ( kdc_realm_t * kdc_active_realm , register krb5_kdc_req * request , krb5_db_entry client , krb5_db_entry server , krb5_timestamp kdc_time , const char * * status , krb5_pa_data * * * e_data ) { int errcode ; krb5_error_code ret ; if ( request -> kdc_options & AS_INVALID_OPTIONS ) { * status = ""INVALIDASOPTIONS"" ; return KDC_ERR_BADOPTION ; } if ( client . expiration && client . expiration < kdc_time ) { * status = ""CLIENTEXPIRED"" ; if ( vague_errors ) return ( KRB_ERR_GENERIC ) ; else return ( KDC_ERR_NAME_EXP ) ; } if ( client . pw_expiration && client . pw_expiration < kdc_time && ! isflagset ( server . attributes , KRB5_KDB_PWCHANGE_SERVICE ) ) { * status = ""CLIENTKEYEXPIRED"" ; if ( vague_errors ) return ( KRB_ERR_GENERIC ) ; else return ( KDC_ERR_KEY_EXP ) ; } if ( server . expiration && server . expiration < kdc_time ) { * status = ""SERVICEEXPIRED"" ; return ( KDC_ERR_SERVICE_EXP ) ; } if ( isflagset ( client . attributes , KRB5_KDB_REQUIRES_PWCHANGE ) && ! isflagset ( server . attributes , KRB5_KDB_PWCHANGE_SERVICE ) ) { * status = ""REQUIREDPWCHANGE"" ; return ( KDC_ERR_KEY_EXP ) ; } if ( ( isflagset ( request -> kdc_options , KDC_OPT_ALLOW_POSTDATE ) || isflagset ( request -> kdc_options , KDC_OPT_POSTDATED ) ) && ( isflagset ( client . attributes , KRB5_KDB_DISALLOW_POSTDATED ) || isflagset ( server . attributes , KRB5_KDB_DISALLOW_POSTDATED ) ) ) { * status = ""POSTDATENOTALLOWED"" ; return ( KDC_ERR_CANNOT_POSTDATE ) ; } if ( isflagset ( request -> kdc_options , KDC_OPT_PROXIABLE ) && ( isflagset ( client . attributes , KRB5_KDB_DISALLOW_PROXIABLE ) || isflagset ( server . attributes , KRB5_KDB_DISALLOW_PROXIABLE ) ) ) { * status = ""PROXIABLENOTALLOWED"" ; return ( KDC_ERR_POLICY ) ; } if ( isflagset ( client . attributes , KRB5_KDB_DISALLOW_ALL_TIX ) ) { * status = ""CLIENTLOCKEDOUT"" ; return ( KDC_ERR_CLIENT_REVOKED ) ; } if ( isflagset ( server . attributes , KRB5_KDB_DISALLOW_ALL_TIX ) ) { * status = ""SERVICELOCKEDOUT"" ; return ( KDC_ERR_S_PRINCIPAL_UNKNOWN ) ; } if ( isflagset ( server . attributes , KRB5_KDB_DISALLOW_SVR ) ) { * status = ""SERVICENOTALLOWED"" ; return ( KDC_ERR_MUST_USE_USER2USER ) ; } if ( check_anon ( kdc_active_realm , request -> client , request -> server ) != 0 ) { * status = ""ANONYMOUSNOTALLOWED"" ; return ( KDC_ERR_POLICY ) ; } ret = krb5_db_check_policy_as ( kdc_context , request , & client , & server , kdc_time , status , e_data ) ; if ( ret && ret != KRB5_PLUGIN_OP_NOTSUPP ) return errcode_to_protocol ( ret ) ; errcode = against_local_policy_as ( request , client , server , kdc_time , status , e_data ) ; if ( errcode ) return errcode ; return 0 ; } "," ( kdc_active_realm , client . princ , request -> ",krb5@krb5/93b4a6306a0026cf1cc31ac4bd8a49ba5d034ba7,CVE-2016-3120,https://github.com/krb5/krb5/commit/93b4a6306a0026cf1cc31ac4bd8a49ba5d034ba7,2016-08-01T02:59Z 471,CWE-119,"CWE-119 static int adjust_scalar_min_max_vals ( struct bpf_verifier_env * env , struct bpf_insn * insn , struct bpf_reg_state * dst_reg , struct bpf_reg_state src_reg ) { struct bpf_reg_state * regs = cur_regs ( env ) ; u8 opcode = BPF_OP ( insn -> code ) ; bool src_known , dst_known ; s64 smin_val , smax_val ; u64 umin_val , umax_val ; if ( BPF_CLASS ( insn -> code ) != BPF_ALU64 ) { coerce_reg_to_32 ( dst_reg ) ; coerce_reg_to_32 ( & src_reg ) ; } smin_val = src_reg . smin_value ; smax_val = src_reg . smax_value ; umin_val = src_reg . umin_value ; umax_val = src_reg . umax_value ; src_known = tnum_is_const ( src_reg . var_off ) ; dst_known = tnum_is_const ( dst_reg -> var_off ) ; switch ( opcode ) { case BPF_ADD : if ( signed_add_overflows ( dst_reg -> smin_value , smin_val ) || signed_add_overflows ( dst_reg -> smax_value , smax_val ) ) { dst_reg -> smin_value = S64_MIN ; dst_reg -> smax_value = S64_MAX ; } else { dst_reg -> smin_value += smin_val ; dst_reg -> smax_value += smax_val ; } if ( dst_reg -> umin_value + umin_val < umin_val || dst_reg -> umax_value + umax_val < umax_val ) { dst_reg -> umin_value = 0 ; dst_reg -> umax_value = U64_MAX ; } else { dst_reg -> umin_value += umin_val ; dst_reg -> umax_value += umax_val ; } dst_reg -> var_off = tnum_add ( dst_reg -> var_off , src_reg . var_off ) ; break ; case BPF_SUB : if ( signed_sub_overflows ( dst_reg -> smin_value , smax_val ) || signed_sub_overflows ( dst_reg -> smax_value , smin_val ) ) { dst_reg -> smin_value = S64_MIN ; dst_reg -> smax_value = S64_MAX ; } else { dst_reg -> smin_value -= smax_val ; dst_reg -> smax_value -= smin_val ; } if ( dst_reg -> umin_value < umax_val ) { dst_reg -> umin_value = 0 ; dst_reg -> umax_value = U64_MAX ; } else { dst_reg -> umin_value -= umax_val ; dst_reg -> umax_value -= umin_val ; } dst_reg -> var_off = tnum_sub ( dst_reg -> var_off , src_reg . var_off ) ; break ; case BPF_MUL : dst_reg -> var_off = tnum_mul ( dst_reg -> var_off , src_reg . var_off ) ; if ( smin_val < 0 || dst_reg -> smin_value < 0 ) { __mark_reg_unbounded ( dst_reg ) ; __update_reg_bounds ( dst_reg ) ; break ; } if ( umax_val > U32_MAX || dst_reg -> umax_value > U32_MAX ) { __mark_reg_unbounded ( dst_reg ) ; __update_reg_bounds ( dst_reg ) ; break ; } dst_reg -> umin_value *= umin_val ; dst_reg -> umax_value *= umax_val ; if ( dst_reg -> umax_value > S64_MAX ) { dst_reg -> smin_value = S64_MIN ; dst_reg -> smax_value = S64_MAX ; } else { dst_reg -> smin_value = dst_reg -> umin_value ; dst_reg -> smax_value = dst_reg -> umax_value ; } break ; case BPF_AND : if ( src_known && dst_known ) { __mark_reg_known ( dst_reg , dst_reg -> var_off . value & src_reg . var_off . value ) ; break ; } dst_reg -> var_off = tnum_and ( dst_reg -> var_off , src_reg . var_off ) ; dst_reg -> umin_value = dst_reg -> var_off . value ; dst_reg -> umax_value = min ( dst_reg -> umax_value , umax_val ) ; if ( dst_reg -> smin_value < 0 || smin_val < 0 ) { dst_reg -> smin_value = S64_MIN ; dst_reg -> smax_value = S64_MAX ; } else { dst_reg -> smin_value = dst_reg -> umin_value ; dst_reg -> smax_value = dst_reg -> umax_value ; } __update_reg_bounds ( dst_reg ) ; break ; case BPF_OR : if ( src_known && dst_known ) { __mark_reg_known ( dst_reg , dst_reg -> var_off . value | src_reg . var_off . value ) ; break ; } dst_reg -> var_off = tnum_or ( dst_reg -> var_off , src_reg . var_off ) ; dst_reg -> umin_value = max ( dst_reg -> umin_value , umin_val ) ; dst_reg -> umax_value = dst_reg -> var_off . value | dst_reg -> var_off . mask ; if ( dst_reg -> smin_value < 0 || smin_val < 0 ) { dst_reg -> smin_value = S64_MIN ; dst_reg -> smax_value = S64_MAX ; } else { dst_reg -> smin_value = dst_reg -> umin_value ; dst_reg -> smax_value = dst_reg -> umax_value ; } __update_reg_bounds ( dst_reg ) ; break ; case BPF_LSH : if ( umax_val > 63 ) { mark_reg_unknown ( env , regs , insn -> dst_reg ) ; break ; } dst_reg -> smin_value = S64_MIN ; dst_reg -> smax_value = S64_MAX ; if ( dst_reg -> umax_value > 1ULL << ( 63 - umax_val ) ) { dst_reg -> umin_value = 0 ; dst_reg -> umax_value = U64_MAX ; } else { dst_reg -> umin_value <<= umin_val ; dst_reg -> umax_value <<= umax_val ; } if ( src_known ) dst_reg -> var_off = tnum_lshift ( dst_reg -> var_off , umin_val ) ; else dst_reg -> var_off = tnum_lshift ( tnum_unknown , umin_val ) ; __update_reg_bounds ( dst_reg ) ; break ; case BPF_RSH : if ( umax_val > 63 ) { mark_reg_unknown ( env , regs , insn -> dst_reg ) ; break ; } if ( dst_reg -> smin_value < 0 ) { if ( umin_val ) { dst_reg -> smin_value = 0 ; } else { dst_reg -> smin_value = S64_MIN ; dst_reg -> smax_value = S64_MAX ; } } else { dst_reg -> smin_value = ( u64 ) ( dst_reg -> smin_value ) >> umax_val ; } if ( src_known ) dst_reg -> var_off = tnum_rshift ( dst_reg -> var_off , umin_val ) ; else dst_reg -> var_off = tnum_rshift ( tnum_unknown , umin_val ) ; dst_reg -> umin_value >>= umax_val ; dst_reg -> umax_value >>= umin_val ; __update_reg_bounds ( dst_reg ) ; break ; default : mark_reg_unknown ( env , regs , insn -> dst_reg ) ; break ; } __reg_deduce_bounds ( dst_reg ) ; __reg_bound_offset ( dst_reg ) ; return 0 ; } "," break ; } dst_reg -> smin_value = S64_MAX ; if ( src_known ",torvalds@linux/4374f256ce8182019353c0c639bb8d0695b4c941,CVE-2017-17853,https://github.com/torvalds/linux/commit/4374f256ce8182019353c0c639bb8d0695b4c941,2017-12-27T17:08Z 472,CWE-119,"CWE-119 void vp9_pick_filter_level ( const YV12_BUFFER_CONFIG * sd , VP9_COMP * cpi , LPF_PICK_METHOD method ) { VP9_COMMON * const cm = & cpi -> common ; struct loopfilter * const lf = & cm -> lf ; lf -> sharpness_level = cm -> frame_type == KEY_FRAME ? 0 : cpi -> oxcf . sharpness ; if ( method == LPF_PICK_FROM_Q ) { const int min_filter_level = 0 ; const int max_filter_level = get_max_filter_level ( cpi ) ; const int q = vp9_ac_quant ( cm -> base_qindex , 0 ) ; int filt_guess = ROUND_POWER_OF_TWO ( q * 20723 + 1015158 , 18 ) ; if ( cm -> frame_type == KEY_FRAME ) filt_guess -= 4 ; lf -> filter_level = clamp ( filt_guess , min_filter_level , max_filter_level ) ; } else { search_filter_level ( sd , cpi , method == LPF_PICK_FROM_SUBIMAGE ) ; } } "," ( method == LPF_PICK_MINIMAL_LPF && lf -> filter_level ) { lf -> filter_level = 0 ; } else if ( method >= base_qindex , 0 , cm -> bit_depth ) ; # if CONFIG_VP9_HIGHBITDEPTH int filt_guess ; switch ( cm -> bit_depth ) { case VPX_BITS_8 : filt_guess = ROUND_POWER_OF_TWO 18 ) ; break ; case VPX_BITS_10 : filt_guess = ROUND_POWER_OF_TWO ( q * 20723 + 4060632 , 20 ) ; break ; case VPX_BITS_12 : filt_guess = ROUND_POWER_OF_TWO ( q * 20723 + 16242526 , 22 ) ; break ; default : assert ( 0 && ""bit_depthshouldbeVPX_BITS_8,VPX_BITS_10"" ""orVPX_BITS_12"" ) ; return ; } # else int filt_guess = ROUND_POWER_OF_TWO ( q * 20723 + 1015158 , 18 ) ; # endif } else { lf -> filter_level = ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 473,CWE-284,"CWE-284 static void btif_dm_upstreams_evt ( UINT16 event , char * p_param ) { tBTA_DM_SEC * p_data = ( tBTA_DM_SEC * ) p_param ; tBTA_SERVICE_MASK service_mask ; uint32_t i ; bt_bdaddr_t bd_addr ; BTIF_TRACE_EVENT ( ""btif_dm_upstreams_cbackev:%s"" , dump_dm_event ( event ) ) ; switch ( event ) { case BTA_DM_ENABLE_EVT : { BD_NAME bdname ; bt_status_t status ; bt_property_t prop ; prop . type = BT_PROPERTY_BDNAME ; prop . len = BD_NAME_LEN ; prop . val = ( void * ) bdname ; status = btif_storage_get_adapter_property ( & prop ) ; if ( status == BT_STATUS_SUCCESS ) { BTA_DmSetDeviceName ( ( char * ) prop . val ) ; } else { BTA_DmSetDeviceName ( btif_get_default_local_name ( ) ) ; } # if ( defined ( BLE_INCLUDED ) && ( BLE_INCLUDED == TRUE ) ) BTA_DmBleConfigLocalPrivacy ( BLE_LOCAL_PRIVACY_ENABLED ) ; # endif service_mask = btif_get_enabled_services_mask ( ) ; for ( i = 0 ; i <= BTA_MAX_SERVICE_ID ; i ++ ) { if ( service_mask & ( tBTA_SERVICE_MASK ) ( BTA_SERVICE_ID_TO_SERVICE_MASK ( i ) ) ) { btif_in_execute_service_request ( i , TRUE ) ; } } memset ( & pairing_cb , 0 , sizeof ( btif_dm_pairing_cb_t ) ) ; pairing_cb . bond_type = BOND_TYPE_PERSISTENT ; btif_storage_load_bonded_devices ( ) ; btif_storage_load_autopair_device_list ( ) ; btif_enable_bluetooth_evt ( p_data -> enable . status ) ; } break ; case BTA_DM_DISABLE_EVT : service_mask = btif_get_enabled_services_mask ( ) ; for ( i = 0 ; i <= BTA_MAX_SERVICE_ID ; i ++ ) { if ( service_mask & ( tBTA_SERVICE_MASK ) ( BTA_SERVICE_ID_TO_SERVICE_MASK ( i ) ) ) { btif_in_execute_service_request ( i , FALSE ) ; } } btif_disable_bluetooth_evt ( ) ; break ; case BTA_DM_PIN_REQ_EVT : btif_dm_pin_req_evt ( & p_data -> pin_req ) ; break ; case BTA_DM_AUTH_CMPL_EVT : btif_dm_auth_cmpl_evt ( & p_data -> auth_cmpl ) ; break ; case BTA_DM_BOND_CANCEL_CMPL_EVT : if ( pairing_cb . state == BT_BOND_STATE_BONDING ) { bdcpy ( bd_addr . address , pairing_cb . bd_addr ) ; btm_set_bond_type_dev ( pairing_cb . bd_addr , BOND_TYPE_UNKNOWN ) ; bond_state_changed ( p_data -> bond_cancel_cmpl . result , & bd_addr , BT_BOND_STATE_NONE ) ; } break ; case BTA_DM_SP_CFM_REQ_EVT : btif_dm_ssp_cfm_req_evt ( & p_data -> cfm_req ) ; break ; case BTA_DM_SP_KEY_NOTIF_EVT : btif_dm_ssp_key_notif_evt ( & p_data -> key_notif ) ; break ; case BTA_DM_DEV_UNPAIRED_EVT : bdcpy ( bd_addr . address , p_data -> link_down . bd_addr ) ; btm_set_bond_type_dev ( p_data -> link_down . bd_addr , BOND_TYPE_UNKNOWN ) ; # if ( defined ( BTA_HH_INCLUDED ) && ( BTA_HH_INCLUDED == TRUE ) ) btif_hh_remove_device ( bd_addr ) ; # endif btif_storage_remove_bonded_device ( & bd_addr ) ; bond_state_changed ( BT_STATUS_SUCCESS , & bd_addr , BT_BOND_STATE_NONE ) ; break ; case BTA_DM_BUSY_LEVEL_EVT : { if ( p_data -> busy_level . level_flags & BTM_BL_INQUIRY_PAGING_MASK ) { if ( p_data -> busy_level . level_flags == BTM_BL_INQUIRY_STARTED ) { HAL_CBACK ( bt_hal_cbacks , discovery_state_changed_cb , BT_DISCOVERY_STARTED ) ; btif_dm_inquiry_in_progress = TRUE ; } else if ( p_data -> busy_level . level_flags == BTM_BL_INQUIRY_CANCELLED ) { HAL_CBACK ( bt_hal_cbacks , discovery_state_changed_cb , BT_DISCOVERY_STOPPED ) ; btif_dm_inquiry_in_progress = FALSE ; } else if ( p_data -> busy_level . level_flags == BTM_BL_INQUIRY_COMPLETE ) { btif_dm_inquiry_in_progress = FALSE ; } } } break ; case BTA_DM_LINK_UP_EVT : bdcpy ( bd_addr . address , p_data -> link_up . bd_addr ) ; BTIF_TRACE_DEBUG ( ""BTA_DM_LINK_UP_EVT.SendingBT_ACL_STATE_CONNECTED"" ) ; btif_update_remote_version_property ( & bd_addr ) ; HAL_CBACK ( bt_hal_cbacks , acl_state_changed_cb , BT_STATUS_SUCCESS , & bd_addr , BT_ACL_STATE_CONNECTED ) ; break ; case BTA_DM_LINK_DOWN_EVT : bdcpy ( bd_addr . address , p_data -> link_down . bd_addr ) ; btm_set_bond_type_dev ( p_data -> link_down . bd_addr , BOND_TYPE_UNKNOWN ) ; BTIF_TRACE_DEBUG ( ""BTA_DM_LINK_DOWN_EVT.SendingBT_ACL_STATE_DISCONNECTED"" ) ; HAL_CBACK ( bt_hal_cbacks , acl_state_changed_cb , BT_STATUS_SUCCESS , & bd_addr , BT_ACL_STATE_DISCONNECTED ) ; break ; case BTA_DM_HW_ERROR_EVT : BTIF_TRACE_ERROR ( ""ReceivedH/WError."" ) ; btif_config_flush ( ) ; usleep ( 100000 ) ; kill ( getpid ( ) , SIGKILL ) ; break ; # if ( defined ( BLE_INCLUDED ) && ( BLE_INCLUDED == TRUE ) ) case BTA_DM_BLE_KEY_EVT : BTIF_TRACE_DEBUG ( ""BTA_DM_BLE_KEY_EVTkey_type=0x%02x"" , p_data -> ble_key . key_type ) ; if ( pairing_cb . state != BT_BOND_STATE_BONDING ) { BTIF_TRACE_DEBUG ( ""BondstatenotsenttoAppsofar.Notifytheappnow"" ) ; bond_state_changed ( BT_STATUS_SUCCESS , ( bt_bdaddr_t * ) p_data -> ble_key . bd_addr , BT_BOND_STATE_BONDING ) ; } else if ( memcmp ( pairing_cb . bd_addr , p_data -> ble_key . bd_addr , BD_ADDR_LEN ) != 0 ) { BTIF_TRACE_ERROR ( ""BDmismatchdiscardBLEkey_type=%d"" , p_data -> ble_key . key_type ) ; break ; } switch ( p_data -> ble_key . key_type ) { case BTA_LE_KEY_PENC : BTIF_TRACE_DEBUG ( ""RcvBTA_LE_KEY_PENC"" ) ; pairing_cb . ble . is_penc_key_rcvd = TRUE ; pairing_cb . ble . penc_key = p_data -> ble_key . p_key_value -> penc_key ; break ; case BTA_LE_KEY_PID : BTIF_TRACE_DEBUG ( ""RcvBTA_LE_KEY_PID"" ) ; pairing_cb . ble . is_pid_key_rcvd = TRUE ; pairing_cb . ble . pid_key = p_data -> ble_key . p_key_value -> pid_key ; break ; case BTA_LE_KEY_PCSRK : BTIF_TRACE_DEBUG ( ""RcvBTA_LE_KEY_PCSRK"" ) ; pairing_cb . ble . is_pcsrk_key_rcvd = TRUE ; pairing_cb . ble . pcsrk_key = p_data -> ble_key . p_key_value -> pcsrk_key ; break ; case BTA_LE_KEY_LENC : BTIF_TRACE_DEBUG ( ""RcvBTA_LE_KEY_LENC"" ) ; pairing_cb . ble . is_lenc_key_rcvd = TRUE ; pairing_cb . ble . lenc_key = p_data -> ble_key . p_key_value -> lenc_key ; break ; case BTA_LE_KEY_LCSRK : BTIF_TRACE_DEBUG ( ""RcvBTA_LE_KEY_LCSRK"" ) ; pairing_cb . ble . is_lcsrk_key_rcvd = TRUE ; pairing_cb . ble . lcsrk_key = p_data -> ble_key . p_key_value -> lcsrk_key ; break ; case BTA_LE_KEY_LID : BTIF_TRACE_DEBUG ( ""RcvBTA_LE_KEY_LID"" ) ; pairing_cb . ble . is_lidk_key_rcvd = TRUE ; break ; default : BTIF_TRACE_ERROR ( ""unknownBLEkeytype(0x%02x)"" , p_data -> ble_key . key_type ) ; break ; } break ; case BTA_DM_BLE_SEC_REQ_EVT : BTIF_TRACE_DEBUG ( ""BTA_DM_BLE_SEC_REQ_EVT."" ) ; btif_dm_ble_sec_req_evt ( & p_data -> ble_req ) ; break ; case BTA_DM_BLE_PASSKEY_NOTIF_EVT : BTIF_TRACE_DEBUG ( ""BTA_DM_BLE_PASSKEY_NOTIF_EVT."" ) ; btif_dm_ble_key_notif_evt ( & p_data -> key_notif ) ; break ; case BTA_DM_BLE_PASSKEY_REQ_EVT : BTIF_TRACE_DEBUG ( ""BTA_DM_BLE_PASSKEY_REQ_EVT."" ) ; btif_dm_ble_passkey_req_evt ( & p_data -> pin_req ) ; break ; case BTA_DM_BLE_NC_REQ_EVT : BTIF_TRACE_DEBUG ( ""BTA_DM_BLE_PASSKEY_REQ_EVT."" ) ; btif_dm_ble_key_nc_req_evt ( & p_data -> key_notif ) ; break ; case BTA_DM_BLE_OOB_REQ_EVT : BTIF_TRACE_DEBUG ( ""BTA_DM_BLE_OOB_REQ_EVT."" ) ; break ; case BTA_DM_BLE_LOCAL_IR_EVT : BTIF_TRACE_DEBUG ( ""BTA_DM_BLE_LOCAL_IR_EVT."" ) ; ble_local_key_cb . is_id_keys_rcvd = TRUE ; memcpy ( & ble_local_key_cb . id_keys . irk [ 0 ] , & p_data -> ble_id_keys . irk [ 0 ] , sizeof ( BT_OCTET16 ) ) ; memcpy ( & ble_local_key_cb . id_keys . ir [ 0 ] , & p_data -> ble_id_keys . ir [ 0 ] , sizeof ( BT_OCTET16 ) ) ; memcpy ( & ble_local_key_cb . id_keys . dhk [ 0 ] , & p_data -> ble_id_keys . dhk [ 0 ] , sizeof ( BT_OCTET16 ) ) ; btif_storage_add_ble_local_key ( ( char * ) & ble_local_key_cb . id_keys . irk [ 0 ] , BTIF_DM_LE_LOCAL_KEY_IRK , BT_OCTET16_LEN ) ; btif_storage_add_ble_local_key ( ( char * ) & ble_local_key_cb . id_keys . ir [ 0 ] , BTIF_DM_LE_LOCAL_KEY_IR , BT_OCTET16_LEN ) ; btif_storage_add_ble_local_key ( ( char * ) & ble_local_key_cb . id_keys . dhk [ 0 ] , BTIF_DM_LE_LOCAL_KEY_DHK , BT_OCTET16_LEN ) ; break ; case BTA_DM_BLE_LOCAL_ER_EVT : BTIF_TRACE_DEBUG ( ""BTA_DM_BLE_LOCAL_ER_EVT."" ) ; ble_local_key_cb . is_er_rcvd = TRUE ; memcpy ( & ble_local_key_cb . er [ 0 ] , & p_data -> ble_er [ 0 ] , sizeof ( BT_OCTET16 ) ) ; btif_storage_add_ble_local_key ( ( char * ) & ble_local_key_cb . er [ 0 ] , BTIF_DM_LE_LOCAL_KEY_ER , BT_OCTET16_LEN ) ; break ; case BTA_DM_BLE_AUTH_CMPL_EVT : BTIF_TRACE_DEBUG ( ""BTA_DM_BLE_AUTH_CMPL_EVT."" ) ; btif_dm_ble_auth_cmpl_evt ( & p_data -> auth_cmpl ) ; break ; case BTA_DM_LE_FEATURES_READ : { tBTM_BLE_VSC_CB cmn_vsc_cb ; bt_local_le_features_t local_le_features ; char buf [ 512 ] ; bt_property_t prop ; prop . type = BT_PROPERTY_LOCAL_LE_FEATURES ; prop . val = ( void * ) buf ; prop . len = sizeof ( buf ) ; BTM_BleGetVendorCapabilities ( & cmn_vsc_cb ) ; local_le_features . local_privacy_enabled = BTM_BleLocalPrivacyEnabled ( ) ; prop . len = sizeof ( bt_local_le_features_t ) ; if ( cmn_vsc_cb . filter_support == 1 ) local_le_features . max_adv_filter_supported = cmn_vsc_cb . max_filter ; else local_le_features . max_adv_filter_supported = 0 ; local_le_features . max_adv_instance = cmn_vsc_cb . adv_inst_max ; local_le_features . max_irk_list_size = cmn_vsc_cb . max_irk_list_sz ; local_le_features . rpa_offload_supported = cmn_vsc_cb . rpa_offloading ; local_le_features . activity_energy_info_supported = cmn_vsc_cb . energy_support ; local_le_features . scan_result_storage_size = cmn_vsc_cb . tot_scan_results_strg ; local_le_features . version_supported = cmn_vsc_cb . version_supported ; local_le_features . total_trackable_advertisers = cmn_vsc_cb . total_trackable_advertisers ; local_le_features . extended_scan_support = cmn_vsc_cb . extended_scan_support > 0 ; local_le_features . debug_logging_supported = cmn_vsc_cb . debug_logging_supported > 0 ; memcpy ( prop . val , & local_le_features , prop . len ) ; HAL_CBACK ( bt_hal_cbacks , adapter_properties_cb , BT_STATUS_SUCCESS , 1 , & prop ) ; break ; } case BTA_DM_ENER_INFO_READ : { btif_activity_energy_info_cb_t * p_ener_data = ( btif_activity_energy_info_cb_t * ) p_param ; bt_activity_energy_info energy_info ; energy_info . status = p_ener_data -> status ; energy_info . ctrl_state = p_ener_data -> ctrl_state ; energy_info . rx_time = p_ener_data -> rx_time ; energy_info . tx_time = p_ener_data -> tx_time ; energy_info . idle_time = p_ener_data -> idle_time ; energy_info . energy_used = p_ener_data -> energy_used ; HAL_CBACK ( bt_hal_cbacks , energy_info_cb , & energy_info ) ; break ; } # endif case BTA_DM_AUTHORIZE_EVT : case BTA_DM_SIG_STRENGTH_EVT : case BTA_DM_SP_RMT_OOB_EVT : case BTA_DM_SP_KEYPRESS_EVT : case BTA_DM_ROLE_CHG_EVT : default : BTIF_TRACE_WARNING ( ""btif_dm_cback:unhandledevent(%d)"" , event ) ; break ; } btif_dm_data_free ( event , p_data ) ; } "," ( ) ; TEMP_FAILURE_RETRY ( usleep ( 100000 ) ",system@bt/472271b153c5dc53c28beac55480a8d8434b2d5c,CVE-2016-3839,https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c,2016-08-05T20:59Z 474,CWE-772,"CWE-772 static Image * ReadYCBCRImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { const unsigned char * pixels ; Image * canvas_image , * image ; MagickBooleanType status ; MagickOffsetType scene ; QuantumInfo * quantum_info ; QuantumType quantum_type ; register const Quantum * p ; register ssize_t i , x ; register Quantum * q ; size_t length ; ssize_t count , y ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; if ( ( image -> columns == 0 ) || ( image -> rows == 0 ) ) ThrowReaderException ( OptionError , ""MustSpecifyImageSize"" ) ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; SetImageColorspace ( image , YCbCrColorspace , exception ) ; if ( image_info -> interlace != PartitionInterlace ) { status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } if ( DiscardBlobBytes ( image , image -> offset ) == MagickFalse ) ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; } canvas_image = CloneImage ( image , image -> extract_info . width , 1 , MagickFalse , exception ) ; ( void ) SetImageVirtualPixelMethod ( canvas_image , BlackVirtualPixelMethod , exception ) ; quantum_info = AcquireQuantumInfo ( image_info , canvas_image ) ; if ( quantum_info == ( QuantumInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; quantum_type = RGBQuantum ; if ( LocaleCompare ( image_info -> magick , ""YCbCrA"" ) == 0 ) { quantum_type = RGBAQuantum ; image -> alpha_trait = BlendPixelTrait ; } pixels = ( const unsigned char * ) NULL ; if ( image_info -> number_scenes != 0 ) while ( image -> scene < image_info -> scene ) { image -> scene ++ ; length = GetQuantumExtent ( canvas_image , quantum_info , quantum_type ) ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { pixels = ( const unsigned char * ) ReadBlobStream ( image , length , GetQuantumPixels ( quantum_info ) , & count ) ; if ( count != ( ssize_t ) length ) break ; } } count = 0 ; length = 0 ; scene = 0 ; do { if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) { quantum_info = DestroyQuantumInfo ( quantum_info ) ; return ( DestroyImageList ( image ) ) ; } SetImageColorspace ( image , YCbCrColorspace , exception ) ; switch ( image_info -> interlace ) { case NoInterlace : default : { if ( scene == 0 ) { length = GetQuantumExtent ( canvas_image , quantum_info , quantum_type ) ; pixels = ( const unsigned char * ) ReadBlobStream ( image , length , GetQuantumPixels ( quantum_info ) , & count ) ; } for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , quantum_type , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = QueueAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const Quantum * ) NULL ) || ( q == ( Quantum * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( image , GetPixelRed ( canvas_image , p ) , q ) ; SetPixelGreen ( image , GetPixelGreen ( canvas_image , p ) , q ) ; SetPixelBlue ( image , GetPixelBlue ( canvas_image , p ) , q ) ; if ( image -> alpha_trait != UndefinedPixelTrait ) SetPixelAlpha ( image , GetPixelAlpha ( canvas_image , p ) , q ) ; p += GetPixelChannels ( canvas_image ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } pixels = ( const unsigned char * ) ReadBlobStream ( image , length , GetQuantumPixels ( quantum_info ) , & count ) ; } break ; } case LineInterlace : { static QuantumType quantum_types [ 4 ] = { RedQuantum , GreenQuantum , BlueQuantum , OpacityQuantum } ; if ( scene == 0 ) { length = GetQuantumExtent ( canvas_image , quantum_info , RedQuantum ) ; pixels = ( const unsigned char * ) ReadBlobStream ( image , length , GetQuantumPixels ( quantum_info ) , & count ) ; } for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { for ( i = 0 ; i < ( image -> alpha_trait != UndefinedPixelTrait ? 4 : 3 ) ; i ++ ) { if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } quantum_type = quantum_types [ i ] ; q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , quantum_type , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const Quantum * ) NULL ) || ( q == ( Quantum * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { switch ( quantum_type ) { case RedQuantum : { SetPixelRed ( image , GetPixelRed ( canvas_image , p ) , q ) ; break ; } case GreenQuantum : { SetPixelGreen ( image , GetPixelGreen ( canvas_image , p ) , q ) ; break ; } case BlueQuantum : { SetPixelBlue ( image , GetPixelBlue ( canvas_image , p ) , q ) ; break ; } case OpacityQuantum : { SetPixelAlpha ( image , GetPixelAlpha ( canvas_image , p ) , q ) ; break ; } default : break ; } p += GetPixelChannels ( canvas_image ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } pixels = ( const unsigned char * ) ReadBlobStream ( image , length , GetQuantumPixels ( quantum_info ) , & count ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } break ; } case PlaneInterlace : { if ( scene == 0 ) { length = GetQuantumExtent ( canvas_image , quantum_info , RedQuantum ) ; pixels = ( const unsigned char * ) ReadBlobStream ( image , length , GetQuantumPixels ( quantum_info ) , & count ) ; } for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , RedQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const Quantum * ) NULL ) || ( q == ( Quantum * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( image , GetPixelRed ( canvas_image , p ) , q ) ; p += GetPixelChannels ( canvas_image ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } pixels = ( const unsigned char * ) ReadBlobStream ( image , length , GetQuantumPixels ( quantum_info ) , & count ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 1 , 5 ) ; if ( status == MagickFalse ) break ; } for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , GreenQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const Quantum * ) NULL ) || ( q == ( Quantum * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelGreen ( image , GetPixelGreen ( canvas_image , p ) , q ) ; p += GetPixelChannels ( canvas_image ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } pixels = ( const unsigned char * ) ReadBlobStream ( image , length , GetQuantumPixels ( quantum_info ) , & count ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 2 , 5 ) ; if ( status == MagickFalse ) break ; } for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , BlueQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const Quantum * ) NULL ) || ( q == ( Quantum * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelBlue ( image , GetPixelBlue ( canvas_image , p ) , q ) ; p += GetPixelChannels ( canvas_image ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } pixels = ( const unsigned char * ) ReadBlobStream ( image , length , GetQuantumPixels ( quantum_info ) , & count ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 3 , 5 ) ; if ( status == MagickFalse ) break ; } if ( image -> alpha_trait != UndefinedPixelTrait ) { for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , AlphaQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const Quantum * ) NULL ) || ( q == ( Quantum * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelAlpha ( image , GetPixelAlpha ( canvas_image , p ) , q ) ; p += GetPixelChannels ( canvas_image ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } pixels = ( const unsigned char * ) ReadBlobStream ( image , length , GetQuantumPixels ( quantum_info ) , & count ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 4 , 5 ) ; if ( status == MagickFalse ) break ; } } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 5 , 5 ) ; if ( status == MagickFalse ) break ; } break ; } case PartitionInterlace : { AppendImageFormat ( ""Y"" , image -> filename ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { canvas_image = DestroyImageList ( canvas_image ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } if ( DiscardBlobBytes ( image , image -> offset ) == MagickFalse ) ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; length = GetQuantumExtent ( canvas_image , quantum_info , RedQuantum ) ; for ( i = 0 ; i < ( ssize_t ) scene ; i ++ ) for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { pixels = ( const unsigned char * ) ReadBlobStream ( image , length , GetQuantumPixels ( quantum_info ) , & count ) ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } } pixels = ( const unsigned char * ) ReadBlobStream ( image , length , GetQuantumPixels ( quantum_info ) , & count ) ; for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , RedQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const Quantum * ) NULL ) || ( q == ( Quantum * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( image , GetPixelRed ( canvas_image , p ) , q ) ; p += GetPixelChannels ( canvas_image ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } pixels = ( const unsigned char * ) ReadBlobStream ( image , length , GetQuantumPixels ( quantum_info ) , & count ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 1 , 5 ) ; if ( status == MagickFalse ) break ; } ( void ) CloseBlob ( image ) ; AppendImageFormat ( ""Cb"" , image -> filename ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { canvas_image = DestroyImageList ( canvas_image ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } length = GetQuantumExtent ( canvas_image , quantum_info , GreenQuantum ) ; for ( i = 0 ; i < ( ssize_t ) scene ; i ++ ) for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { pixels = ( const unsigned char * ) ReadBlobStream ( image , length , GetQuantumPixels ( quantum_info ) , & count ) ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } } pixels = ( const unsigned char * ) ReadBlobStream ( image , length , GetQuantumPixels ( quantum_info ) , & count ) ; for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , GreenQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const Quantum * ) NULL ) || ( q == ( Quantum * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelGreen ( image , GetPixelGreen ( canvas_image , p ) , q ) ; p += GetPixelChannels ( canvas_image ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } pixels = ( const unsigned char * ) ReadBlobStream ( image , length , GetQuantumPixels ( quantum_info ) , & count ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 2 , 5 ) ; if ( status == MagickFalse ) break ; } ( void ) CloseBlob ( image ) ; AppendImageFormat ( ""Cr"" , image -> filename ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { canvas_image = DestroyImageList ( canvas_image ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } length = GetQuantumExtent ( canvas_image , quantum_info , BlueQuantum ) ; for ( i = 0 ; i < ( ssize_t ) scene ; i ++ ) for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { pixels = ( const unsigned char * ) ReadBlobStream ( image , length , GetQuantumPixels ( quantum_info ) , & count ) ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } } pixels = ( const unsigned char * ) ReadBlobStream ( image , length , GetQuantumPixels ( quantum_info ) , & count ) ; for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , BlueQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const Quantum * ) NULL ) || ( q == ( Quantum * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelBlue ( image , GetPixelBlue ( canvas_image , p ) , q ) ; p += GetPixelChannels ( canvas_image ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } pixels = ( const unsigned char * ) ReadBlobStream ( image , length , GetQuantumPixels ( quantum_info ) , & count ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 3 , 5 ) ; if ( status == MagickFalse ) break ; } if ( image -> alpha_trait != UndefinedPixelTrait ) { ( void ) CloseBlob ( image ) ; AppendImageFormat ( ""A"" , image -> filename ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { canvas_image = DestroyImageList ( canvas_image ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } length = GetQuantumExtent ( canvas_image , quantum_info , AlphaQuantum ) ; for ( i = 0 ; i < ( ssize_t ) scene ; i ++ ) for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { pixels = ( const unsigned char * ) ReadBlobStream ( image , length , GetQuantumPixels ( quantum_info ) , & count ) ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } } pixels = ( const unsigned char * ) ReadBlobStream ( image , length , GetQuantumPixels ( quantum_info ) , & count ) ; for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , BlueQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const Quantum * ) NULL ) || ( q == ( Quantum * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelAlpha ( image , GetPixelAlpha ( canvas_image , p ) , q ) ; p += GetPixelChannels ( canvas_image ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } pixels = ( const unsigned char * ) ReadBlobStream ( image , length , GetQuantumPixels ( quantum_info ) , & count ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 4 , 5 ) ; if ( status == MagickFalse ) break ; } } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 5 , 5 ) ; if ( status == MagickFalse ) break ; } break ; } } SetQuantumImageType ( image , quantum_type ) ; if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; if ( count == ( ssize_t ) length ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } scene ++ ; } while ( count == ( ssize_t ) length ) ; quantum_info = DestroyQuantumInfo ( quantum_info ) ; canvas_image = DestroyImage ( canvas_image ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," DestroyQuantumInfo ( quantum_info ) ; canvas_image = DestroyImage ( canvas_image ",ImageMagick@ImageMagick/241988ca28139ad970c1d9717c419f41e360ddb0,CVE-2017-15032,https://github.com/ImageMagick/ImageMagick/commit/241988ca28139ad970c1d9717c419f41e360ddb0,2017-10-05T07:29Z 475,CWE-190,"CWE-190 static void controloptions ( lua_State * L , int opt , const char * * fmt , Header * h ) { switch ( opt ) { case '' : return ; case '>' : h -> endian = BIG ; return ; case '<' : h -> endian = LITTLE ; return ; case '!' : { int a = getnum ( fmt , MAXALIGN ) ; if ( ! isp2 ( a ) ) luaL_error ( L , ""alignment%disnotapowerof2"" , a ) ; h -> align = a ; return ; } default : { const char * msg = lua_pushfstring ( L , ""invalidformatoption\'%c\'"" , opt ) ; luaL_argerror ( L , 1 , msg ) ; } } } "," = getnum ( L , ",antirez@redis/ef764dde1cca2f25d00686673d1bc89448819571,CVE-2020-14147,https://github.com/antirez/redis/commit/ef764dde1cca2f25d00686673d1bc89448819571,2020-06-15T18:15Z 476,CWE-119,"CWE-119 void usage_exit ( ) { fprintf ( stderr , ""Usage:%s\\n"" , exec_name ) ; exit ( EXIT_FAILURE ) ; } "," void usage_exit ( void ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 477,CWE-119,"CWE-119 void edge_sparse_csr_reader_double ( const char * i_csr_file_in , unsigned int * * o_row_idx , unsigned int * * o_column_idx , double * * o_values , unsigned int * o_row_count , unsigned int * o_column_count , unsigned int * o_element_count ) { FILE * l_csr_file_handle ; const unsigned int l_line_length = 512 ; char l_line [ 512 + 1 ] ; unsigned int l_header_read = 0 ; unsigned int * l_row_idx_id = NULL ; unsigned int l_i = 0 ; l_csr_file_handle = fopen ( i_csr_file_in , ""r"" ) ; if ( l_csr_file_handle == NULL ) { fprintf ( stderr , ""cannotopenCSRfile!\\n"" ) ; return ; } while ( fgets ( l_line , l_line_length , l_csr_file_handle ) != NULL ) { if ( strlen ( l_line ) == l_line_length ) { fprintf ( stderr , ""couldnotreadfilelength!\\n"" ) ; return ; } if ( l_line [ 0 ] == '%' ) { continue ; } else { if ( l_header_read == 0 ) { if ( sscanf ( l_line , ""%u%u%u"" , o_row_count , o_column_count , o_element_count ) == 3 ) { * o_column_idx = ( unsigned int * ) malloc ( sizeof ( unsigned int ) * ( * o_element_count ) ) ; * o_row_idx = ( unsigned int * ) malloc ( sizeof ( unsigned int ) * ( * o_row_count + 1 ) ) ; * o_values = ( double * ) malloc ( sizeof ( double ) * ( * o_element_count ) ) ; l_row_idx_id = ( unsigned int * ) malloc ( sizeof ( unsigned int ) * ( * o_row_count ) ) ; if ( ( * o_row_idx == NULL ) || ( * o_column_idx == NULL ) || ( * o_values == NULL ) || ( l_row_idx_id == NULL ) ) { fprintf ( stderr , ""couldnotallocatespdata!\\n"" ) ; return ; } memset ( * o_row_idx , 0 , sizeof ( unsigned int ) * ( * o_row_count + 1 ) ) ; memset ( * o_column_idx , 0 , sizeof ( unsigned int ) * ( * o_element_count ) ) ; memset ( * o_values , 0 , sizeof ( double ) * ( * o_element_count ) ) ; memset ( l_row_idx_id , 0 , sizeof ( unsigned int ) * ( * o_row_count ) ) ; for ( l_i = 0 ; l_i < ( * o_row_count + 1 ) ; l_i ++ ) ( * o_row_idx ) [ l_i ] = ( * o_element_count ) ; ( * o_row_idx ) [ 0 ] = 0 ; l_i = 0 ; l_header_read = 1 ; } else { fprintf ( stderr , ""couldnotcsrdescription!\\n"" ) ; return ; } } else { unsigned int l_row , l_column ; double l_value ; if ( sscanf ( l_line , ""%u%u%lf"" , & l_row , & l_column , & l_value ) != 3 ) { fprintf ( stderr , ""couldnotreadelement!\\n"" ) ; return ; } l_row -- ; l_column -- ; ( * o_column_idx ) [ l_i ] = l_column ; ( * o_values ) [ l_i ] = l_value ; l_i ++ ; l_row_idx_id [ l_row ] = 1 ; ( * o_row_idx ) [ l_row + 1 ] = l_i ; } } } fclose ( l_csr_file_handle ) ; if ( l_i != ( * o_element_count ) ) { fprintf ( stderr , ""wewerenotabletoreadallelements!\\n"" ) ; return ; } for ( l_i = 0 ; l_i < ( * o_row_count ) ; l_i ++ ) { if ( l_row_idx_id [ l_i ] == 0 ) { ( * o_row_idx ) [ l_i + 1 ] = ( * o_row_idx ) [ l_i ] ; } } if ( l_row_idx_id != NULL ) { free ( l_row_idx_id ) ; } } "," { if ( 3 == , o_element_count ) && 0 != * o_row_count && 0 != * o_column_count && 0 != * o_element_count ) { * o_column_idx ",hfp@libxsmm/151481489192e6d1997f8bde52c5c425ea41741d,CVE-2018-20542,https://github.com/hfp/libxsmm/commit/151481489192e6d1997f8bde52c5c425ea41741d,2018-12-28T16:29Z 478,CWE-119,"CWE-119 static Image * ReadCMYKImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { Image * canvas_image , * image ; MagickBooleanType status ; MagickOffsetType scene ; QuantumInfo * quantum_info ; QuantumType quantum_type ; register ssize_t i ; size_t length ; ssize_t count , y ; unsigned char * pixels ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; if ( ( image -> columns == 0 ) || ( image -> rows == 0 ) ) ThrowReaderException ( OptionError , ""MustSpecifyImageSize"" ) ; SetImageColorspace ( image , CMYKColorspace ) ; if ( image_info -> interlace != PartitionInterlace ) { status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } if ( DiscardBlobBytes ( image , image -> offset ) == MagickFalse ) ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; } canvas_image = CloneImage ( image , image -> extract_info . width , 1 , MagickFalse , exception ) ; ( void ) SetImageVirtualPixelMethod ( canvas_image , BlackVirtualPixelMethod ) ; quantum_info = AcquireQuantumInfo ( image_info , canvas_image ) ; if ( quantum_info == ( QuantumInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; pixels = GetQuantumPixels ( quantum_info ) ; quantum_type = CMYKQuantum ; if ( LocaleCompare ( image_info -> magick , ""CMYKA"" ) == 0 ) { quantum_type = CMYKAQuantum ; image -> matte = MagickTrue ; } if ( image_info -> number_scenes != 0 ) while ( image -> scene < image_info -> scene ) { image -> scene ++ ; length = GetQuantumExtent ( canvas_image , quantum_info , quantum_type ) ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { count = ReadBlob ( image , length , pixels ) ; if ( count != ( ssize_t ) length ) break ; } } count = 0 ; length = 0 ; scene = 0 ; do { if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; SetImageColorspace ( image , CMYKColorspace ) ; switch ( image_info -> interlace ) { case NoInterlace : default : { if ( scene == 0 ) { length = GetQuantumExtent ( canvas_image , quantum_info , quantum_type ) ; count = ReadBlob ( image , length , pixels ) ; } for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const IndexPacket * restrict canvas_indexes ; register const PixelPacket * restrict p ; register IndexPacket * restrict indexes ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , quantum_type , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = QueueAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; canvas_indexes = GetVirtualIndexQueue ( canvas_image ) ; indexes = GetAuthenticIndexQueue ( image ) ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( q , GetPixelRed ( p ) ) ; SetPixelGreen ( q , GetPixelGreen ( p ) ) ; SetPixelBlue ( q , GetPixelBlue ( p ) ) ; SetPixelBlack ( indexes + x , GetPixelBlack ( canvas_indexes + image -> extract_info . x + x ) ) ; SetPixelOpacity ( q , OpaqueOpacity ) ; if ( image -> matte != MagickFalse ) SetPixelOpacity ( q , GetPixelOpacity ( p ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } break ; } case LineInterlace : { static QuantumType quantum_types [ 5 ] = { CyanQuantum , MagentaQuantum , YellowQuantum , BlackQuantum , OpacityQuantum } ; if ( scene == 0 ) { length = GetQuantumExtent ( canvas_image , quantum_info , CyanQuantum ) ; count = ReadBlob ( image , length , pixels ) ; } for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const IndexPacket * restrict canvas_indexes ; register const PixelPacket * restrict p ; register IndexPacket * restrict indexes ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } for ( i = 0 ; i < ( image -> matte != MagickFalse ? 5 : 4 ) ; i ++ ) { quantum_type = quantum_types [ i ] ; q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , quantum_type , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; canvas_indexes = GetVirtualIndexQueue ( canvas_image ) ; indexes = GetAuthenticIndexQueue ( image ) ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { switch ( quantum_type ) { case CyanQuantum : { SetPixelCyan ( q , GetPixelCyan ( p ) ) ; break ; } case MagentaQuantum : { SetPixelMagenta ( q , GetPixelMagenta ( p ) ) ; break ; } case YellowQuantum : { SetPixelYellow ( q , GetPixelYellow ( p ) ) ; break ; } case BlackQuantum : { SetPixelIndex ( indexes + x , GetPixelIndex ( canvas_indexes + image -> extract_info . x + x ) ) ; break ; } case OpacityQuantum : { SetPixelOpacity ( q , GetPixelOpacity ( p ) ) ; break ; } default : break ; } p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } break ; } case PlaneInterlace : { if ( scene == 0 ) { length = GetQuantumExtent ( canvas_image , quantum_info , CyanQuantum ) ; count = ReadBlob ( image , length , pixels ) ; } for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const PixelPacket * restrict p ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , CyanQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( q , GetPixelRed ( p ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 1 , 6 ) ; if ( status == MagickFalse ) break ; } for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const PixelPacket * restrict p ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , MagentaQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelGreen ( q , GetPixelGreen ( p ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 2 , 6 ) ; if ( status == MagickFalse ) break ; } for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const PixelPacket * restrict p ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , YellowQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelBlue ( q , GetPixelBlue ( p ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 3 , 6 ) ; if ( status == MagickFalse ) break ; } for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const IndexPacket * restrict canvas_indexes ; register const PixelPacket * restrict p ; register IndexPacket * restrict indexes ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , BlackQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; canvas_indexes = GetVirtualIndexQueue ( canvas_image ) ; indexes = GetAuthenticIndexQueue ( image ) ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelIndex ( indexes + x , GetPixelIndex ( canvas_indexes + image -> extract_info . x + x ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 4 , 6 ) ; if ( status == MagickFalse ) break ; } if ( image -> matte != MagickFalse ) { for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const PixelPacket * restrict p ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , AlphaQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelOpacity ( q , GetPixelOpacity ( p ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 5 , 6 ) ; if ( status == MagickFalse ) break ; } } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 6 , 6 ) ; if ( status == MagickFalse ) break ; } break ; } case PartitionInterlace : { AppendImageFormat ( ""C"" , image -> filename ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { canvas_image = DestroyImageList ( canvas_image ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } if ( DiscardBlobBytes ( image , image -> offset ) == MagickFalse ) ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; length = GetQuantumExtent ( canvas_image , quantum_info , CyanQuantum ) ; for ( i = 0 ; i < ( ssize_t ) scene ; i ++ ) for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) if ( ReadBlob ( image , length , pixels ) != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } count = ReadBlob ( image , length , pixels ) ; for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const PixelPacket * restrict p ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , CyanQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( q , GetPixelRed ( p ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 1 , 5 ) ; if ( status == MagickFalse ) break ; } ( void ) CloseBlob ( image ) ; AppendImageFormat ( ""M"" , image -> filename ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { canvas_image = DestroyImageList ( canvas_image ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } length = GetQuantumExtent ( canvas_image , quantum_info , MagentaQuantum ) ; for ( i = 0 ; i < ( ssize_t ) scene ; i ++ ) for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) if ( ReadBlob ( image , length , pixels ) != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } count = ReadBlob ( image , length , pixels ) ; for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const PixelPacket * restrict p ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , MagentaQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelGreen ( q , GetPixelGreen ( p ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 2 , 5 ) ; if ( status == MagickFalse ) break ; } ( void ) CloseBlob ( image ) ; AppendImageFormat ( ""Y"" , image -> filename ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { canvas_image = DestroyImageList ( canvas_image ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } length = GetQuantumExtent ( canvas_image , quantum_info , YellowQuantum ) ; for ( i = 0 ; i < ( ssize_t ) scene ; i ++ ) for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) if ( ReadBlob ( image , length , pixels ) != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } count = ReadBlob ( image , length , pixels ) ; for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const PixelPacket * restrict p ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , YellowQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelBlue ( q , GetPixelBlue ( p ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 3 , 5 ) ; if ( status == MagickFalse ) break ; } ( void ) CloseBlob ( image ) ; AppendImageFormat ( ""K"" , image -> filename ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { canvas_image = DestroyImageList ( canvas_image ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } length = GetQuantumExtent ( canvas_image , quantum_info , BlackQuantum ) ; for ( i = 0 ; i < ( ssize_t ) scene ; i ++ ) for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) if ( ReadBlob ( image , length , pixels ) != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } count = ReadBlob ( image , length , pixels ) ; for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const IndexPacket * restrict canvas_indexes ; register const PixelPacket * restrict p ; register IndexPacket * restrict indexes ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , BlackQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; canvas_indexes = GetVirtualIndexQueue ( canvas_image ) ; indexes = GetAuthenticIndexQueue ( image ) ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelIndex ( indexes + x , GetPixelIndex ( canvas_indexes + image -> extract_info . x + x ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 3 , 5 ) ; if ( status == MagickFalse ) break ; } if ( image -> matte != MagickFalse ) { ( void ) CloseBlob ( image ) ; AppendImageFormat ( ""A"" , image -> filename ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { canvas_image = DestroyImageList ( canvas_image ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } length = GetQuantumExtent ( canvas_image , quantum_info , AlphaQuantum ) ; for ( i = 0 ; i < ( ssize_t ) scene ; i ++ ) for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) if ( ReadBlob ( image , length , pixels ) != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } count = ReadBlob ( image , length , pixels ) ; for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const PixelPacket * restrict p ; register PixelPacket * restrict q ; register ssize_t x ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , YellowQuantum , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , canvas_image -> columns , 1 , exception ) ; q = GetAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelOpacity ( q , GetPixelOpacity ( p ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } count = ReadBlob ( image , length , pixels ) ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 4 , 5 ) ; if ( status == MagickFalse ) break ; } } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , 5 , 5 ) ; if ( status == MagickFalse ) break ; } break ; } } SetQuantumImageType ( image , quantum_type ) ; if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; if ( count == ( ssize_t ) length ) { AcquireNextImage ( image_info , image ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } scene ++ ; } while ( count == ( ssize_t ) length ) ; quantum_info = DestroyQuantumInfo ( quantum_info ) ; InheritException ( & image -> exception , & canvas_image -> exception ) ; canvas_image = DestroyImage ( canvas_image ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," ) break ; status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; } ",ImageMagick@ImageMagick/f6e9d0d9955e85bdd7540b251cd50d598dacc5e6,CVE-2016-10066,https://github.com/ImageMagick/ImageMagick/commit/f6e9d0d9955e85bdd7540b251cd50d598dacc5e6,2017-03-03T17:59Z 479,CWE-189,"CWE-189 static inline void jiffies_to_compat_timeval ( unsigned long jiffies , struct compat_timeval * value ) { u64 nsec = ( u64 ) jiffies * TICK_NSEC ; long rem ; value -> tv_sec = div_long_long_rem ( nsec , NSEC_PER_SEC , & rem ) ; value -> tv_usec = rem / NSEC_PER_USEC ; } "," * TICK_NSEC ; u32 rem ; value -> tv_sec = div_u64_rem ( nsec , ",torvalds@linux/f8bd2258e2d520dff28c855658bd24bdafb5102d,CVE-2011-3209,https://github.com/torvalds/linux/commit/f8bd2258e2d520dff28c855658bd24bdafb5102d,2012-10-03T11:02Z 480,CWE-119,"CWE-119 vpx_codec_err_t vpx_codec_decode ( vpx_codec_ctx_t * ctx , const uint8_t * data , unsigned int data_sz , void * user_priv , long deadline ) { vpx_codec_err_t res ; if ( ! ctx || ( ! data && data_sz ) ) res = VPX_CODEC_INVALID_PARAM ; else if ( ! ctx -> iface || ! ctx -> priv ) res = VPX_CODEC_ERROR ; else { res = ctx -> iface -> dec . decode ( ctx -> priv -> alg_priv , data , data_sz , user_priv , deadline ) ; } return SAVE_STATUS ( ctx , res ) ; } "," && data_sz ) || ( data && ! data_sz ) . decode ( get_alg_priv ( ctx ) , data , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 481,CWE-119,"CWE-119 static int sdp_parse_fmtp_config_h264 ( AVFormatContext * s , AVStream * stream , PayloadContext * h264_data , const char * attr , const char * value ) { AVCodecParameters * par = stream -> codecpar ; if ( ! strcmp ( attr , ""packetization-mode"" ) ) { av_log ( s , AV_LOG_DEBUG , ""RTPPacketizationMode:%d\\n"" , atoi ( value ) ) ; h264_data -> packetization_mode = atoi ( value ) ; if ( h264_data -> packetization_mode > 1 ) av_log ( s , AV_LOG_ERROR , ""InterleavedRTPmodeisnotsupportedyet.\\n"" ) ; } else if ( ! strcmp ( attr , ""profile-level-id"" ) ) { if ( strlen ( value ) == 6 ) parse_profile_level_id ( s , h264_data , value ) ; } else if ( ! strcmp ( attr , ""sprop-parameter-sets"" ) ) { int ret ; if ( value [ strlen ( value ) - 1 ] == ',' ) { av_log ( s , AV_LOG_WARNING , ""MissingPPSinsprop-parameter-sets,ignoring\\n"" ) ; return 0 ; } par -> extradata_size = 0 ; av_freep ( & par -> extradata ) ; ret = ff_h264_parse_sprop_parameter_sets ( s , & par -> extradata , & par -> extradata_size , value ) ; av_log ( s , AV_LOG_DEBUG , ""Extradatasetto%p(size:%d)\\n"" , par -> extradata , par -> extradata_size ) ; return ret ; } return 0 ; } "," ; if ( * value == 0 || ",FFmpeg@FFmpeg/c42a1388a6d1bfd8001bf6a4241d8ca27e49326d,CVE-2017-14767,https://github.com/FFmpeg/FFmpeg/commit/c42a1388a6d1bfd8001bf6a4241d8ca27e49326d,2017-09-27T08:29Z 482,CWE-20,"CWE-20 static int isofs_read_inode ( struct inode * inode ) { struct super_block * sb = inode -> i_sb ; struct isofs_sb_info * sbi = ISOFS_SB ( sb ) ; unsigned long bufsize = ISOFS_BUFFER_SIZE ( inode ) ; unsigned long block ; int high_sierra = sbi -> s_high_sierra ; struct buffer_head * bh = NULL ; struct iso_directory_record * de ; struct iso_directory_record * tmpde = NULL ; unsigned int de_len ; unsigned long offset ; struct iso_inode_info * ei = ISOFS_I ( inode ) ; int ret = - EIO ; block = ei -> i_iget5_block ; bh = sb_bread ( inode -> i_sb , block ) ; if ( ! bh ) goto out_badread ; offset = ei -> i_iget5_offset ; de = ( struct iso_directory_record * ) ( bh -> b_data + offset ) ; de_len = * ( unsigned char * ) de ; if ( offset + de_len > bufsize ) { int frag1 = bufsize - offset ; tmpde = kmalloc ( de_len , GFP_KERNEL ) ; if ( tmpde == NULL ) { printk ( KERN_INFO ""%s:outofmemory\\n"" , __func__ ) ; ret = - ENOMEM ; goto fail ; } memcpy ( tmpde , bh -> b_data + offset , frag1 ) ; brelse ( bh ) ; bh = sb_bread ( inode -> i_sb , ++ block ) ; if ( ! bh ) goto out_badread ; memcpy ( ( char * ) tmpde + frag1 , bh -> b_data , de_len - frag1 ) ; de = tmpde ; } inode -> i_ino = isofs_get_ino ( ei -> i_iget5_block , ei -> i_iget5_offset , ISOFS_BUFFER_BITS ( inode ) ) ; ei -> i_file_format = isofs_file_normal ; if ( de -> flags [ - high_sierra ] & 2 ) { if ( sbi -> s_dmode != ISOFS_INVALID_MODE ) inode -> i_mode = S_IFDIR | sbi -> s_dmode ; else inode -> i_mode = S_IFDIR | S_IRUGO | S_IXUGO ; set_nlink ( inode , 1 ) ; } else { if ( sbi -> s_fmode != ISOFS_INVALID_MODE ) { inode -> i_mode = S_IFREG | sbi -> s_fmode ; } else { inode -> i_mode = S_IFREG | S_IRUGO | S_IXUGO ; } set_nlink ( inode , 1 ) ; } inode -> i_uid = sbi -> s_uid ; inode -> i_gid = sbi -> s_gid ; inode -> i_blocks = 0 ; ei -> i_format_parm [ 0 ] = 0 ; ei -> i_format_parm [ 1 ] = 0 ; ei -> i_format_parm [ 2 ] = 0 ; ei -> i_section_size = isonum_733 ( de -> size ) ; if ( de -> flags [ - high_sierra ] & 0x80 ) { ret = isofs_read_level3_size ( inode ) ; if ( ret < 0 ) goto fail ; ret = - EIO ; } else { ei -> i_next_section_block = 0 ; ei -> i_next_section_offset = 0 ; inode -> i_size = isonum_733 ( de -> size ) ; } if ( sbi -> s_cruft ) inode -> i_size &= 0x00ffffff ; if ( de -> interleave [ 0 ] ) { printk ( KERN_DEBUG ""ISOFS:Interleavedfilesnot(yet)supported.\\n"" ) ; inode -> i_size = 0 ; } if ( de -> file_unit_size [ 0 ] != 0 ) { printk ( KERN_DEBUG ""ISOFS:Fileunitsize!=0forISOfile(%ld).\\n"" , inode -> i_ino ) ; } # ifdef DEBUG if ( ( de -> flags [ - high_sierra ] & ~ 2 ) != 0 ) { printk ( KERN_DEBUG ""ISOFS:UnusualflagsettingsforISOfile"" ""(%ld%x).\\n"" , inode -> i_ino , de -> flags [ - high_sierra ] ) ; } # endif inode -> i_mtime . tv_sec = inode -> i_atime . tv_sec = inode -> i_ctime . tv_sec = iso_date ( de -> date , high_sierra ) ; inode -> i_mtime . tv_nsec = inode -> i_atime . tv_nsec = inode -> i_ctime . tv_nsec = 0 ; ei -> i_first_extent = ( isonum_733 ( de -> extent ) + isonum_711 ( de -> ext_attr_length ) ) ; inode -> i_blocks = ( inode -> i_size + 511 ) >> 9 ; if ( ! high_sierra ) { parse_rock_ridge_inode ( de , inode ) ; if ( sbi -> s_uid_set ) inode -> i_uid = sbi -> s_uid ; if ( sbi -> s_gid_set ) inode -> i_gid = sbi -> s_gid ; } if ( S_ISDIR ( inode -> i_mode ) && sbi -> s_overriderockperm && sbi -> s_dmode != ISOFS_INVALID_MODE ) inode -> i_mode = S_IFDIR | sbi -> s_dmode ; if ( S_ISREG ( inode -> i_mode ) && sbi -> s_overriderockperm && sbi -> s_fmode != ISOFS_INVALID_MODE ) inode -> i_mode = S_IFREG | sbi -> s_fmode ; if ( S_ISREG ( inode -> i_mode ) ) { inode -> i_fop = & generic_ro_fops ; switch ( ei -> i_file_format ) { # ifdef CONFIG_ZISOFS case isofs_file_compressed : inode -> i_data . a_ops = & zisofs_aops ; break ; # endif default : inode -> i_data . a_ops = & isofs_aops ; break ; } } else if ( S_ISDIR ( inode -> i_mode ) ) { inode -> i_op = & isofs_dir_inode_operations ; inode -> i_fop = & isofs_dir_operations ; } else if ( S_ISLNK ( inode -> i_mode ) ) { inode -> i_op = & page_symlink_inode_operations ; inode -> i_data . a_ops = & isofs_symlink_aops ; } else init_special_inode ( inode , inode -> i_mode , inode -> i_rdev ) ; ret = 0 ; out : kfree ( tmpde ) ; if ( bh ) brelse ( bh ) ; return ret ; out_badread : printk ( KERN_WARNING ""ISOFS:unabletoreadi-nodeblock\\n"" ) ; fail : goto out ; } "," inode * inode , int relocated de , inode , relocated ",torvalds@linux/410dd3cf4c9b36f27ed4542ee18b1af5e68645a4,CVE-2014-5472,https://github.com/torvalds/linux/commit/410dd3cf4c9b36f27ed4542ee18b1af5e68645a4,2014-09-01T01:55Z 483,CWE-000,"CWE-000 void Con_Dump_f ( void ) { int l , x , i ; short * line ; fileHandle_t f ; int bufferlen ; char * buffer ; char filename [ MAX_QPATH ] ; if ( Cmd_Argc ( ) != 2 ) { Com_Printf ( ""usage:condump\\n"" ) ; return ; } Q_strncpyz ( filename , Cmd_Argv ( 1 ) , sizeof ( filename ) ) ; COM_DefaultExtension ( filename , sizeof ( filename ) , "".txt"" ) ; f = FS_FOpenFileWrite ( filename ) ; if ( ! f ) { Com_Printf ( ""ERROR:couldn\'topen%s.\\n"" , filename ) ; return ; } Com_Printf ( ""Dumpedconsoletextto%s.\\n"" , filename ) ; for ( l = con . current - con . totallines + 1 ; l <= con . current ; l ++ ) { line = con . text + ( l % con . totallines ) * con . linewidth ; for ( x = 0 ; x < con . linewidth ; x ++ ) if ( ( line [ x ] & 0xff ) != '' ) { break ; } if ( x != con . linewidth ) { break ; } } # ifdef _WIN32 bufferlen = con . linewidth + 3 * sizeof ( char ) ; # else bufferlen = con . linewidth + 2 * sizeof ( char ) ; # endif buffer = Hunk_AllocateTempMemory ( bufferlen ) ; buffer [ bufferlen - 1 ] = 0 ; for ( ; l <= con . current ; l ++ ) { line = con . text + ( l % con . totallines ) * con . linewidth ; for ( i = 0 ; i < con . linewidth ; i ++ ) buffer [ i ] = line [ i ] & 0xff ; for ( x = con . linewidth - 1 ; x >= 0 ; x -- ) { if ( buffer [ x ] == '' ) { buffer [ x ] = 0 ; } else { break ; } } # ifdef _WIN32 Q_strcat ( buffer , bufferlen , ""\\r\\n"" ) ; # else Q_strcat ( buffer , bufferlen , ""\\n"" ) ; # endif FS_Write ( buffer , strlen ( buffer ) , f ) ; } Hunk_FreeTempMemory ( buffer ) ; FS_FCloseFile ( f ) ; } "," "".txt"" ) ; if ( ! COM_CompareExtension ( filename , "".txt"" ) ) { Com_Printf ( ""Con_Dump_f:Onlythe\\"".txt\\""extensionissupportedbythiscommand!\\n"" ) ; return ; } ",JACoders@OpenJK/11a83410153756ae350a82ed41b08d128ff7f998,CVE-2017-6903,https://github.com/JACoders/OpenJK/commit/11a83410153756ae350a82ed41b08d128ff7f998,2017-03-14T22:59Z 484,CWE-125,"CWE-125 static void esis_print ( netdissect_options * ndo , const uint8_t * pptr , u_int length ) { const uint8_t * optr ; u_int li , esis_pdu_type , source_address_length , source_address_number ; const struct esis_header_t * esis_header ; if ( ! ndo -> ndo_eflag ) ND_PRINT ( ( ndo , ""ES-IS"" ) ) ; if ( length <= 2 ) { ND_PRINT ( ( ndo , ndo -> ndo_qflag ? ""badpkt!"" : ""noheaderatall!"" ) ) ; return ; } esis_header = ( const struct esis_header_t * ) pptr ; ND_TCHECK ( * esis_header ) ; li = esis_header -> length_indicator ; optr = pptr ; if ( esis_header -> nlpid != NLPID_ESIS ) { ND_PRINT ( ( ndo , ""nlpid0x%02xpacketnotsupported"" , esis_header -> nlpid ) ) ; return ; } if ( esis_header -> version != ESIS_VERSION ) { ND_PRINT ( ( ndo , ""version%dpacketnotsupported"" , esis_header -> version ) ) ; return ; } if ( li > length ) { ND_PRINT ( ( ndo , ""lengthindicator(%u)>PDUsize(%u)!"" , li , length ) ) ; return ; } if ( li < sizeof ( struct esis_header_t ) + 2 ) { ND_PRINT ( ( ndo , ""lengthindicator%u<minPDUsize:"" , li ) ) ; while ( pptr < ndo -> ndo_snapend ) ND_PRINT ( ( ndo , ""%02X"" , * pptr ++ ) ) ; return ; } esis_pdu_type = esis_header -> type & ESIS_PDU_TYPE_MASK ; if ( ndo -> ndo_vflag < 1 ) { ND_PRINT ( ( ndo , ""%s%s,length%u"" , ndo -> ndo_eflag ? """" : "","" , tok2str ( esis_pdu_values , ""unknowntype(%u)"" , esis_pdu_type ) , length ) ) ; return ; } else ND_PRINT ( ( ndo , ""%slength%u\\n\\t%s(%u)"" , ndo -> ndo_eflag ? """" : "","" , length , tok2str ( esis_pdu_values , ""unknowntype:%u"" , esis_pdu_type ) , esis_pdu_type ) ) ; ND_PRINT ( ( ndo , "",v:%u%s"" , esis_header -> version , esis_header -> version == ESIS_VERSION ? """" : ""unsupported"" ) ) ; ND_PRINT ( ( ndo , "",checksum:0x%04x"" , EXTRACT_16BITS ( esis_header -> cksum ) ) ) ; osi_print_cksum ( ndo , pptr , EXTRACT_16BITS ( esis_header -> cksum ) , 7 , li ) ; ND_PRINT ( ( ndo , "",holdingtime:%us,lengthindicator:%u"" , EXTRACT_16BITS ( esis_header -> holdtime ) , li ) ) ; if ( ndo -> ndo_vflag > 1 ) print_unknown_data ( ndo , optr , ""\\n\\t"" , sizeof ( struct esis_header_t ) ) ; pptr += sizeof ( struct esis_header_t ) ; li -= sizeof ( struct esis_header_t ) ; switch ( esis_pdu_type ) { case ESIS_PDU_REDIRECT : { const uint8_t * dst , * snpa , * neta ; u_int dstl , snpal , netal ; ND_TCHECK ( * pptr ) ; if ( li < 1 ) { ND_PRINT ( ( ndo , "",badredirect/li"" ) ) ; return ; } dstl = * pptr ; pptr ++ ; li -- ; ND_TCHECK2 ( * pptr , dstl ) ; if ( li < dstl ) { ND_PRINT ( ( ndo , "",badredirect/li"" ) ) ; return ; } dst = pptr ; pptr += dstl ; li -= dstl ; ND_PRINT ( ( ndo , ""\\n\\t%s"" , isonsap_string ( ndo , dst , dstl ) ) ) ; ND_TCHECK ( * pptr ) ; if ( li < 1 ) { ND_PRINT ( ( ndo , "",badredirect/li"" ) ) ; return ; } snpal = * pptr ; pptr ++ ; li -- ; ND_TCHECK2 ( * pptr , snpal ) ; if ( li < snpal ) { ND_PRINT ( ( ndo , "",badredirect/li"" ) ) ; return ; } snpa = pptr ; pptr += snpal ; li -= snpal ; ND_TCHECK ( * pptr ) ; if ( li < 1 ) { ND_PRINT ( ( ndo , "",badredirect/li"" ) ) ; return ; } netal = * pptr ; pptr ++ ; ND_TCHECK2 ( * pptr , netal ) ; if ( li < netal ) { ND_PRINT ( ( ndo , "",badredirect/li"" ) ) ; return ; } neta = pptr ; pptr += netal ; li -= netal ; if ( netal == 0 ) ND_PRINT ( ( ndo , ""\\n\\t%s"" , etheraddr_string ( ndo , snpa ) ) ) ; else ND_PRINT ( ( ndo , ""\\n\\t%s"" , isonsap_string ( ndo , neta , netal ) ) ) ; break ; } case ESIS_PDU_ESH : ND_TCHECK ( * pptr ) ; if ( li < 1 ) { ND_PRINT ( ( ndo , "",badesh/li"" ) ) ; return ; } source_address_number = * pptr ; pptr ++ ; li -- ; ND_PRINT ( ( ndo , ""\\n\\tNumberofSourceAddresses:%u"" , source_address_number ) ) ; while ( source_address_number > 0 ) { ND_TCHECK ( * pptr ) ; if ( li < 1 ) { ND_PRINT ( ( ndo , "",badesh/li"" ) ) ; return ; } source_address_length = * pptr ; pptr ++ ; li -- ; ND_TCHECK2 ( * pptr , source_address_length ) ; if ( li < source_address_length ) { ND_PRINT ( ( ndo , "",badesh/li"" ) ) ; return ; } ND_PRINT ( ( ndo , ""\\n\\tNET(length:%u):%s"" , source_address_length , isonsap_string ( ndo , pptr , source_address_length ) ) ) ; pptr += source_address_length ; li -= source_address_length ; source_address_number -- ; } break ; case ESIS_PDU_ISH : { ND_TCHECK ( * pptr ) ; if ( li < 1 ) { ND_PRINT ( ( ndo , "",badish/li"" ) ) ; return ; } source_address_length = * pptr ; pptr ++ ; li -- ; ND_TCHECK2 ( * pptr , source_address_length ) ; if ( li < source_address_length ) { ND_PRINT ( ( ndo , "",badish/li"" ) ) ; return ; } ND_PRINT ( ( ndo , ""\\n\\tNET(length:%u):%s"" , source_address_length , isonsap_string ( ndo , pptr , source_address_length ) ) ) ; pptr += source_address_length ; li -= source_address_length ; break ; } default : if ( ndo -> ndo_vflag <= 1 ) { if ( pptr < ndo -> ndo_snapend ) print_unknown_data ( ndo , pptr , ""\\n\\t"" , ndo -> ndo_snapend - pptr ) ; } return ; } while ( li != 0 ) { u_int op , opli ; const uint8_t * tptr ; if ( li < 2 ) { ND_PRINT ( ( ndo , "",badopts/li"" ) ) ; return ; } ND_TCHECK2 ( * pptr , 2 ) ; op = * pptr ++ ; opli = * pptr ++ ; li -= 2 ; if ( opli > li ) { ND_PRINT ( ( ndo , "",opt(%d)toolong"" , op ) ) ; return ; } li -= opli ; tptr = pptr ; ND_PRINT ( ( ndo , ""\\n\\t%sOption#%u,length%u,value:"" , tok2str ( esis_option_values , ""Unknown"" , op ) , op , opli ) ) ; switch ( op ) { case ESIS_OPTION_ES_CONF_TIME : if ( opli == 2 ) { ND_TCHECK2 ( * pptr , 2 ) ; ND_PRINT ( ( ndo , ""%us"" , EXTRACT_16BITS ( tptr ) ) ) ; } else ND_PRINT ( ( ndo , ""(badlength)"" ) ) ; break ; case ESIS_OPTION_PROTOCOLS : while ( opli > 0 ) { ND_TCHECK ( * pptr ) ; ND_PRINT ( ( ndo , ""%s(0x%02x)"" , tok2str ( nlpid_values , ""unknown"" , * tptr ) , * tptr ) ) ; if ( opli > 1 ) ND_PRINT ( ( ndo , "","" ) ) ; tptr ++ ; opli -- ; } break ; case ESIS_OPTION_QOS_MAINTENANCE : case ESIS_OPTION_SECURITY : case ESIS_OPTION_PRIORITY : case ESIS_OPTION_ADDRESS_MASK : case ESIS_OPTION_SNPA_MASK : default : print_unknown_data ( ndo , tptr , ""\\n\\t"" , opli ) ; break ; } if ( ndo -> ndo_vflag > 1 ) print_unknown_data ( ndo , pptr , ""\\n\\t"" , opli ) ; pptr += opli ; } trunc : return ; } "," ; if ( snpal == 6 ) ND_PRINT ( ( ndo , ""\\n\\tSNPA(length:%u):%s"" , snpal , etheraddr_string ( ndo , snpa ) ) ) ; else ND_PRINT ( ( ndo , ""\\n\\tSNPA(length:%u):%s"" , snpal , linkaddr_string ( ndo , snpa , LINKADDR_OTHER , snpal ) ) ) ; if ( netal != 0 ) ND_PRINT ( ndo , ""\\n\\tNET(length:%u)%s"" , netal , isonsap_string ( ndo ",the-tcpdump-group@tcpdump/c177cb3800a9a68d79b2812f0ffcb9479abd6eb8,CVE-2017-13016,https://github.com/the-tcpdump-group/tcpdump/commit/c177cb3800a9a68d79b2812f0ffcb9479abd6eb8,2017-09-14T06:29Z 485,CWE-20,"CWE-20 void SetColor ( double c , double m , double y , double k , int par ) { if ( par == STROKING ) { outpos += sprintf ( outpos , ""%12.3f%12.3f%12.3f%12.3fK"" , c , m , y , k ) ; } else { outpos += sprintf ( outpos , ""%12.3f%12.3f%12.3f%12.3fk"" , c , m , y , k ) ; } } "," STROKING ) { sprintf ( outputbuffer , ""%12.3f%12.3f%12.3f%12.3fK"" , } else { sprintf ( outputbuffer , ""%12.3f%12.3f%12.3f%12.3fk"" , ) ; } sendClean ( outputbuffer ) ; ",TeX-Live@texlive-source/9216833a3888a4105a18e8c349f65b045ddb1079,CVE-2019-18604,https://github.com/TeX-Live/texlive-source/commit/9216833a3888a4105a18e8c349f65b045ddb1079,2019-10-29T19:15Z 486,CWE-617,"CWE-617 static bool access_pmu_evcntr ( struct kvm_vcpu * vcpu , struct sys_reg_params * p , const struct sys_reg_desc * r ) { u64 idx ; if ( ! kvm_arm_pmu_v3_ready ( vcpu ) ) return trap_raz_wi ( vcpu , p , r ) ; if ( r -> CRn == 9 && r -> CRm == 13 ) { if ( r -> Op2 == 2 ) { if ( pmu_access_event_counter_el0_disabled ( vcpu ) ) return false ; idx = vcpu_sys_reg ( vcpu , PMSELR_EL0 ) & ARMV8_PMU_COUNTER_MASK ; } else if ( r -> Op2 == 0 ) { if ( pmu_access_cycle_counter_el0_disabled ( vcpu ) ) return false ; idx = ARMV8_PMU_CYCLE_IDX ; } else { BUG ( ) ; } } else if ( r -> CRn == 14 && ( r -> CRm & 12 ) == 8 ) { if ( pmu_access_event_counter_el0_disabled ( vcpu ) ) return false ; idx = ( ( r -> CRm & 3 ) << 3 ) | ( r -> Op2 & 7 ) ; } else { BUG ( ) ; } if ( ! pmu_counter_idx_valid ( vcpu , idx ) ) return false ; if ( p -> is_write ) { if ( pmu_access_el0_disabled ( vcpu ) ) return false ; kvm_pmu_set_counter_value ( vcpu , idx , p -> regval ) ; } else { p -> regval = kvm_pmu_get_counter_value ( vcpu , idx ) ; } return true ; } "," } else { return false ; } } else if ( r -> CRn == 0 && r -> CRm == 9 ) { if ( pmu_access_event_counter_el0_disabled ( vcpu ) ) return false ; idx = ARMV8_PMU_CYCLE_IDX ; } else if } else { return false ; } if ",torvalds@linux/9e3f7a29694049edd728e2400ab57ad7553e5aa9,CVE-2017-12168,https://github.com/torvalds/linux/commit/9e3f7a29694049edd728e2400ab57ad7553e5aa9,2017-09-20T08:29Z 487,CWE-189,"CWE-189 PHP_FUNCTION ( imageaffine ) { zval * IM ; gdImagePtr src ; gdImagePtr dst ; gdRect rect ; gdRectPtr pRect = NULL ; zval * z_rect = NULL ; zval * z_affine ; zval * * tmp ; double affine [ 6 ] ; int i , nelems ; zval * * zval_affine_elem = NULL ; if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) TSRMLS_CC , ""ra|a"" , & IM , & z_affine , & z_rect ) == FAILURE ) { return ; } ZEND_FETCH_RESOURCE ( src , gdImagePtr , & IM , - 1 , ""Image"" , le_gd ) ; if ( ( nelems = zend_hash_num_elements ( Z_ARRVAL_P ( z_affine ) ) ) != 6 ) { php_error_docref ( NULL TSRMLS_CC , E_WARNING , ""Affinearraymusthavesixelements"" ) ; RETURN_FALSE ; } for ( i = 0 ; i < nelems ; i ++ ) { if ( zend_hash_index_find ( Z_ARRVAL_P ( z_affine ) , i , ( void * * ) & zval_affine_elem ) == SUCCESS ) { switch ( Z_TYPE_PP ( zval_affine_elem ) ) { case IS_LONG : affine [ i ] = Z_LVAL_PP ( zval_affine_elem ) ; break ; case IS_DOUBLE : affine [ i ] = Z_DVAL_PP ( zval_affine_elem ) ; break ; case IS_STRING : convert_to_double_ex ( zval_affine_elem ) ; affine [ i ] = Z_DVAL_PP ( zval_affine_elem ) ; break ; default : php_error_docref ( NULL TSRMLS_CC , E_WARNING , ""Invalidtypeforelement%i"" , i ) ; RETURN_FALSE ; } } } if ( z_rect != NULL ) { if ( zend_hash_find ( HASH_OF ( z_rect ) , ""x"" , sizeof ( ""x"" ) , ( void * * ) & tmp ) != FAILURE ) { convert_to_long_ex ( tmp ) ; rect . x = Z_LVAL_PP ( tmp ) ; } else { php_error_docref ( NULL TSRMLS_CC , E_WARNING , ""Missingxposition"" ) ; RETURN_FALSE ; } if ( zend_hash_find ( HASH_OF ( z_rect ) , ""y"" , sizeof ( ""x"" ) , ( void * * ) & tmp ) != FAILURE ) { convert_to_long_ex ( tmp ) ; rect . y = Z_LVAL_PP ( tmp ) ; } else { php_error_docref ( NULL TSRMLS_CC , E_WARNING , ""Missingyposition"" ) ; RETURN_FALSE ; } if ( zend_hash_find ( HASH_OF ( z_rect ) , ""width"" , sizeof ( ""width"" ) , ( void * * ) & tmp ) != FAILURE ) { convert_to_long_ex ( tmp ) ; rect . width = Z_LVAL_PP ( tmp ) ; } else { php_error_docref ( NULL TSRMLS_CC , E_WARNING , ""Missingwidth"" ) ; RETURN_FALSE ; } if ( zend_hash_find ( HASH_OF ( z_rect ) , ""height"" , sizeof ( ""height"" ) , ( void * * ) & tmp ) != FAILURE ) { convert_to_long_ex ( tmp ) ; rect . height = Z_LVAL_PP ( tmp ) ; } else { php_error_docref ( NULL TSRMLS_CC , E_WARNING , ""Missingheight"" ) ; RETURN_FALSE ; } pRect = & rect ; } else { rect . x = - 1 ; rect . y = - 1 ; rect . width = gdImageSX ( src ) ; rect . height = gdImageSY ( src ) ; pRect = NULL ; } if ( gdTransformAffineGetImage ( & dst , src , pRect , affine ) != GD_TRUE ) { RETURN_FALSE ; } if ( dst == NULL ) { RETURN_FALSE ; } else { ZEND_REGISTER_RESOURCE ( return_value , dst , le_gd ) ; } } "," case IS_STRING : { zval dval ; dval = * * zval_affine_elem ; zval_copy_ctor ( & dval ) ; convert_to_double ( & dval ) ; affine i ] = Z_DVAL ( dval ) ; } break ; default FAILURE ) { if ( Z_TYPE_PP ( tmp ) != IS_LONG ) { zval lval ; lval = * * tmp ; zval_copy_ctor ( & lval ) ; convert_to_long ( & lval ) ; rect . x = Z_LVAL ( lval ) ; } else { rect . x = ) ; } } FAILURE ) { if ( Z_TYPE_PP ( tmp ) != IS_LONG ) { zval lval ; lval = * * tmp ; zval_copy_ctor ( & lval ) ; convert_to_long ( & lval ) ; rect . y = Z_LVAL ( lval ) ; } else { rect . y = ) ; } } FAILURE ) { if ( Z_TYPE_PP ( tmp ) != IS_LONG ) { zval lval ; lval = * * tmp ; zval_copy_ctor ( & lval ) ; convert_to_long ( & lval ) ; rect . width = Z_LVAL ( lval ) ; } else { rect . width = ) ; } } FAILURE ) { if ( Z_TYPE_PP ( tmp ) != IS_LONG ) { zval lval ; lval = * * tmp ; zval_copy_ctor ( & lval ) ; convert_to_long ( & lval ) ; rect . height = Z_LVAL ( lval ) ; } else { rect . height = tmp ) ; } ",php@php-src/2938329ce19cb8c4197dec146c3ec887c6f61d01,CVE-2014-2020,https://github.com/php/php-src/commit/2938329ce19cb8c4197dec146c3ec887c6f61d01,2014-02-18T11:55Z 488,CWE-125,"CWE-125 static void ast_dealloc ( AST_object * self ) { Py_CLEAR ( self -> dict ) ; Py_TYPE ( self ) -> tp_free ( self ) ; } "," self ) { PyObject_GC_UnTrack ( self ) ; ",python@typed_ast/156afcb26c198e162504a57caddfe0acd9ed7dce,CVE-2019-19275,https://github.com/python/typed_ast/commit/156afcb26c198e162504a57caddfe0acd9ed7dce,2019-11-26T15:15Z 489,CWE-119,"CWE-119 static int ExecuteSQL ( SQLHDBC hDbc , char * szSQL , char cDelimiter , int bColumnNames , int bHTMLTable ) { SQLHSTMT hStmt ; SQLTCHAR szSepLine [ 32001 ] ; SQLTCHAR szUcSQL [ 32001 ] ; SQLSMALLINT cols ; SQLINTEGER ret ; SQLLEN nRows = 0 ; szSepLine [ 0 ] = 0 ; ansi_to_unicode ( szSQL , szUcSQL ) ; if ( SQLAllocStmt ( hDbc , & hStmt ) != SQL_SUCCESS ) { if ( bVerbose ) DumpODBCLog ( hEnv , hDbc , 0 ) ; fprintf ( stderr , ""[ISQL]ERROR:CouldnotSQLAllocStmt\\n"" ) ; return 0 ; } if ( buseED ) { ret = SQLExecDirect ( hStmt , szUcSQL , SQL_NTS ) ; if ( ret == SQL_NO_DATA ) { fprintf ( stderr , ""[ISQL]INFO:SQLExecDirectreturnedSQL_NO_DATA\\n"" ) ; } else if ( ret == SQL_SUCCESS_WITH_INFO ) { if ( bVerbose ) DumpODBCLog ( hEnv , hDbc , hStmt ) ; fprintf ( stderr , ""[ISQL]INFO:SQLExecDirectreturnedSQL_SUCCESS_WITH_INFO\\n"" ) ; } else if ( ret != SQL_SUCCESS ) { if ( bVerbose ) DumpODBCLog ( hEnv , hDbc , hStmt ) ; fprintf ( stderr , ""[ISQL]ERROR:CouldnotSQLExecDirect\\n"" ) ; SQLFreeStmt ( hStmt , SQL_DROP ) ; free ( szSepLine ) ; return 0 ; } } else { if ( SQLPrepare ( hStmt , szUcSQL , SQL_NTS ) != SQL_SUCCESS ) { if ( bVerbose ) DumpODBCLog ( hEnv , hDbc , hStmt ) ; fprintf ( stderr , ""[ISQL]ERROR:CouldnotSQLPrepare\\n"" ) ; SQLFreeStmt ( hStmt , SQL_DROP ) ; return 0 ; } ret = SQLExecute ( hStmt ) ; if ( ret == SQL_NO_DATA ) { fprintf ( stderr , ""[ISQL]INFO:SQLExecutereturnedSQL_NO_DATA\\n"" ) ; } else if ( ret == SQL_SUCCESS_WITH_INFO ) { if ( bVerbose ) DumpODBCLog ( hEnv , hDbc , hStmt ) ; fprintf ( stderr , ""[ISQL]INFO:SQLExecutereturnedSQL_SUCCESS_WITH_INFO\\n"" ) ; } else if ( ret != SQL_SUCCESS ) { if ( bVerbose ) DumpODBCLog ( hEnv , hDbc , hStmt ) ; fprintf ( stderr , ""[ISQL]ERROR:CouldnotSQLExecute\\n"" ) ; SQLFreeStmt ( hStmt , SQL_DROP ) ; return 0 ; } } do { if ( SQLNumResultCols ( hStmt , & cols ) != SQL_SUCCESS ) { if ( bVerbose ) DumpODBCLog ( hEnv , hDbc , hStmt ) ; fprintf ( stderr , ""[ISQL]ERROR:CouldnotSQLNumResultCols\\n"" ) ; SQLFreeStmt ( hStmt , SQL_DROP ) ; return 0 ; } if ( cols > 0 ) { if ( bHTMLTable ) WriteHeaderHTMLTable ( hStmt ) ; else if ( cDelimiter == 0 ) UWriteHeaderNormal ( hStmt , szSepLine ) ; else if ( cDelimiter && bColumnNames ) WriteHeaderDelimited ( hStmt , cDelimiter ) ; if ( bHTMLTable ) WriteBodyHTMLTable ( hStmt ) ; else if ( cDelimiter == 0 ) nRows = WriteBodyNormal ( hStmt ) ; else WriteBodyDelimited ( hStmt , cDelimiter ) ; } if ( bHTMLTable ) WriteFooterHTMLTable ( hStmt ) ; else if ( cDelimiter == 0 ) UWriteFooterNormal ( hStmt , szSepLine , nRows ) ; } while ( SQL_SUCCEEDED ( SQLMoreResults ( hStmt ) ) ) ; SQLFreeStmt ( hStmt , SQL_DROP ) ; return 1 ; } "," SQL_DROP ) ; return 0 ; ",lurcher@unixODBC/45ef78e037f578b15fc58938a3a3251655e71d6f,CVE-2018-7485,https://github.com/lurcher/unixODBC/commit/45ef78e037f578b15fc58938a3a3251655e71d6f#diff-d52750c7ba4e594410438569d8e2963aL24,2018-02-26T14:29Z 490,CWE-20,"CWE-20 int kvm_read_guest_page ( struct kvm * kvm , gfn_t gfn , void * data , int offset , int len ) { int r ; unsigned long addr ; addr = gfn_to_hva ( kvm , gfn ) ; if ( kvm_is_error_hva ( addr ) ) return - EFAULT ; r = copy_from_user ( data , ( void __user * ) addr + offset , len ) ; if ( r ) return - EFAULT ; return 0 ; } "," ; r = __copy_from_user ( data , ",torvalds@linux/fa3d315a4ce2c0891cdde262562e710d95fba19e,CVE-2013-1943,https://github.com/torvalds/linux/commit/fa3d315a4ce2c0891cdde262562e710d95fba19e,2013-07-16T14:08Z 491,CWE-119,"CWE-119 int main ( int argc , char * argv [ ] ) { char * p , * q , * r ; Clp_Parser * clp = Clp_NewParser ( argc , ( const char * const * ) argv , sizeof ( options ) / sizeof ( options [ 0 ] ) , options ) ; program_name = Clp_ProgramName ( clp ) ; while ( 1 ) { int opt = Clp_Next ( clp ) ; switch ( opt ) { case BLOCK_LEN_OPT : blocklen = clp -> val . i ; break ; output_file : case OUTPUT_OPT : if ( ofp ) fatal_error ( ""outputfilealreadyspecified"" ) ; if ( strcmp ( clp -> vstr , ""-"" ) == 0 ) ofp = stdout ; else if ( ! ( ofp = fopen ( clp -> vstr , ""w"" ) ) ) fatal_error ( ""%s:%s"" , clp -> vstr , strerror ( errno ) ) ; break ; case PFB_OPT : pfb = 1 ; break ; case PFA_OPT : pfb = 0 ; break ; case HELP_OPT : usage ( ) ; exit ( 0 ) ; break ; case VERSION_OPT : printf ( ""t1asm(LCDFt1utils)%s\\n"" , VERSION ) ; printf ( ""Copyright(C)1992-2010I.LeeHetherington,EddieKohleretal.\\n\\\nThisisfreesoftware;seethesourceforcopyingconditions.\\n\\\nThereisNOwarranty,notevenformerchantabilityorfitnessfora\\n\\\nparticularpurpose.\\n"" ) ; exit ( 0 ) ; break ; case Clp_NotOption : if ( ifp && ofp ) fatal_error ( ""toomanyarguments"" ) ; else if ( ifp ) goto output_file ; if ( strcmp ( clp -> vstr , ""-"" ) == 0 ) ifp = stdin ; else if ( ! ( ifp = fopen ( clp -> vstr , ""r"" ) ) ) fatal_error ( ""%s:%s"" , clp -> vstr , strerror ( errno ) ) ; break ; case Clp_Done : goto done ; case Clp_BadOption : short_usage ( ) ; exit ( 1 ) ; break ; } } done : if ( ! pfb ) { if ( blocklen == - 1 ) blocklen = 64 ; else if ( blocklen < 8 ) { blocklen = 8 ; error ( ""warning:linelengthraisedto%d"" , blocklen ) ; } else if ( blocklen > 1024 ) { blocklen = 1024 ; error ( ""warning:linelengthloweredto%d"" , blocklen ) ; } } if ( ! ifp ) ifp = stdin ; if ( ! ofp ) ofp = stdout ; if ( pfb ) init_pfb_writer ( & w , blocklen , ofp ) ; # if defined ( _MSDOS ) || defined ( _WIN32 ) if ( pfb ) _setmode ( _fileno ( ofp ) , _O_BINARY ) ; # endif while ( ! feof ( ifp ) && ! ferror ( ifp ) ) { t1utils_getline ( ) ; if ( ! ever_active ) { if ( strncmp ( line , ""currentfileeexec"" , 17 ) == 0 && isspace ( line [ 17 ] ) ) { for ( p = line + 18 ; isspace ( * p ) ; p ++ ) ; eexec_start ( p ) ; continue ; } else if ( strncmp ( line , ""/lenIV"" , 6 ) == 0 ) { lenIV = atoi ( line + 6 ) ; } else if ( ( p = strstr ( line , ""stringcurrentfile"" ) ) && strstr ( line , ""readstring"" ) ) { * p = '\\0' ; q = strrchr ( line , '/' ) ; if ( q ) { r = cs_start ; ++ q ; while ( ! isspace ( * q ) && * q != '{' ) * r ++ = * q ++ ; * r = '\\0' ; } * p = 's' ; } } if ( ! active ) { if ( ( p = strstr ( line , ""/Subrs"" ) ) && isdigit ( p [ 7 ] ) ) ever_active = active = 1 ; else if ( ( p = strstr ( line , ""/CharStrings"" ) ) && isdigit ( p [ 13 ] ) ) ever_active = active = 1 ; } if ( ( p = strstr ( line , ""currentfileclosefile"" ) ) ) { p += sizeof ( ""currentfileclosefile"" ) - 1 ; for ( q = p ; isspace ( * q ) && * q != '\\n' ; q ++ ) ; if ( q == p && ! * q ) error ( ""warning:`currentfileclosefile\'linetoolong"" ) ; else if ( q != p ) { if ( * q != '\\n' ) error ( ""textafter`currentfileclosefile\'ignored"" ) ; * p ++ = '\\n' ; * p ++ = '\\0' ; } eexec_string ( line ) ; break ; } eexec_string ( line ) ; if ( start_charstring ) { if ( ! cs_start [ 0 ] ) fatal_error ( ""couldn\'tfindcharstringstartcommand"" ) ; parse_charstring ( ) ; } } if ( in_eexec ) eexec_end ( ) ; while ( ! feof ( ifp ) && ! ferror ( ifp ) ) { t1utils_getline ( ) ; eexec_string ( line ) ; } if ( pfb ) pfb_writer_end ( & w ) ; if ( ! ever_active ) error ( ""warning:nocharstringsfoundininputfile"" ) ; fclose ( ifp ) ; fclose ( ofp ) ; return 0 ; } "," , * q ; Clp_Parser * ; printf ( ""Copyright(C)1992-2010I.LeeHetherington,EddieKohleretal.\\n\\\nThisisfreesoftware;seethesourceforcopyingconditions.\\n\\\nThereisNOwarranty,notevenformerchantabilityorfitnessfora\\n\\\nparticularpurpose.\\n"" ) ; exit && isspace ( ( unsigned char ) ; isspace ( ( unsigned char ) 0 ) { set_lenIV ( line ) ; } ""stringcurrentfile"" ) ) ) { set_cs_start ( line ) ; } } && isdigit ( ( unsigned char ) && isdigit ( ( unsigned char ) ; isspace ( ( unsigned char ) ",kohler@t1utils/6b9d1aafcb61a3663c883663eb19ccdbfcde8d33,CVE-2015-3905,https://github.com/kohler/t1utils/commit/6b9d1aafcb61a3663c883663eb19ccdbfcde8d33,2015-06-08T14:59Z 492,CWE-416,"CWE-416 static int usb_console_setup ( struct console * co , char * options ) { struct usbcons_info * info = & usbcons_info ; int baud = 9600 ; int bits = 8 ; int parity = 'n' ; int doflow = 0 ; int cflag = CREAD | HUPCL | CLOCAL ; char * s ; struct usb_serial * serial ; struct usb_serial_port * port ; int retval ; struct tty_struct * tty = NULL ; struct ktermios dummy ; if ( options ) { baud = simple_strtoul ( options , NULL , 10 ) ; s = options ; while ( * s >= '0' && * s <= '9' ) s ++ ; if ( * s ) parity = * s ++ ; if ( * s ) bits = * s ++ - '0' ; if ( * s ) doflow = ( * s ++ == 'r' ) ; } if ( baud == 0 ) baud = 9600 ; switch ( bits ) { case 7 : cflag |= CS7 ; break ; default : case 8 : cflag |= CS8 ; break ; } switch ( parity ) { case 'o' : case 'O' : cflag |= PARODD ; break ; case 'e' : case 'E' : cflag |= PARENB ; break ; } co -> cflag = cflag ; port = usb_serial_port_get_by_minor ( co -> index ) ; if ( port == NULL ) { pr_err ( ""NoUSBdeviceconnectedtottyUSB%i\\n"" , co -> index ) ; return - ENODEV ; } serial = port -> serial ; retval = usb_autopm_get_interface ( serial -> interface ) ; if ( retval ) goto error_get_interface ; tty_port_tty_set ( & port -> port , NULL ) ; info -> port = port ; ++ port -> port . count ; if ( ! tty_port_initialized ( & port -> port ) ) { if ( serial -> type -> set_termios ) { tty = kzalloc ( sizeof ( * tty ) , GFP_KERNEL ) ; if ( ! tty ) { retval = - ENOMEM ; goto reset_open_count ; } kref_init ( & tty -> kref ) ; tty -> driver = usb_serial_tty_driver ; tty -> index = co -> index ; init_ldsem ( & tty -> ldisc_sem ) ; spin_lock_init ( & tty -> files_lock ) ; INIT_LIST_HEAD ( & tty -> tty_files ) ; kref_get ( & tty -> driver -> kref ) ; __module_get ( tty -> driver -> owner ) ; tty -> ops = & usb_console_fake_tty_ops ; tty_init_termios ( tty ) ; tty_port_tty_set ( & port -> port , tty ) ; } retval = serial -> type -> open ( NULL , port ) ; if ( retval ) { dev_err ( & port -> dev , ""couldnotopenUSBconsoleport\\n"" ) ; goto fail ; } if ( serial -> type -> set_termios ) { tty -> termios . c_cflag = cflag ; tty_termios_encode_baud_rate ( & tty -> termios , baud , baud ) ; memset ( & dummy , 0 , sizeof ( struct ktermios ) ) ; serial -> type -> set_termios ( tty , port , & dummy ) ; tty_port_tty_set ( & port -> port , NULL ) ; tty_kref_put ( tty ) ; } tty_port_set_initialized ( & port -> port , 1 ) ; } -- port -> port . count ; port -> port . console = 1 ; mutex_unlock ( & serial -> disc_mutex ) ; return retval ; fail : tty_port_tty_set ( & port -> port , NULL ) ; tty_kref_put ( tty ) ; reset_open_count : port -> port . count = 0 ; usb_autopm_put_interface ( serial -> interface ) ; error_get_interface : usb_serial_put ( serial ) ; mutex_unlock ( & serial -> disc_mutex ) ; return retval ; } "," = 0 ; info -> port = NULL ; ",torvalds@linux/299d7572e46f98534033a9e65973f13ad1ce9047,CVE-2017-16525,https://github.com/torvalds/linux/commit/299d7572e46f98534033a9e65973f13ad1ce9047,2017-11-04T01:29Z 493,CWE-264,"CWE-264 int perf_pmu_register ( struct pmu * pmu , const char * name , int type ) { int cpu , ret ; mutex_lock ( & pmus_lock ) ; ret = - ENOMEM ; pmu -> pmu_disable_count = alloc_percpu ( int ) ; if ( ! pmu -> pmu_disable_count ) goto unlock ; pmu -> type = - 1 ; if ( ! name ) goto skip_type ; pmu -> name = name ; if ( type < 0 ) { type = idr_alloc ( & pmu_idr , pmu , PERF_TYPE_MAX , 0 , GFP_KERNEL ) ; if ( type < 0 ) { ret = type ; goto free_pdc ; } } pmu -> type = type ; if ( pmu_bus_running ) { ret = pmu_dev_alloc ( pmu ) ; if ( ret ) goto free_idr ; } skip_type : pmu -> pmu_cpu_context = find_pmu_context ( pmu -> task_ctx_nr ) ; if ( pmu -> pmu_cpu_context ) goto got_cpu_context ; ret = - ENOMEM ; pmu -> pmu_cpu_context = alloc_percpu ( struct perf_cpu_context ) ; if ( ! pmu -> pmu_cpu_context ) goto free_dev ; for_each_possible_cpu ( cpu ) { struct perf_cpu_context * cpuctx ; cpuctx = per_cpu_ptr ( pmu -> pmu_cpu_context , cpu ) ; __perf_event_init_context ( & cpuctx -> ctx ) ; lockdep_set_class ( & cpuctx -> ctx . mutex , & cpuctx_mutex ) ; lockdep_set_class ( & cpuctx -> ctx . lock , & cpuctx_lock ) ; cpuctx -> ctx . type = cpu_context ; cpuctx -> ctx . pmu = pmu ; __perf_cpu_hrtimer_init ( cpuctx , cpu ) ; INIT_LIST_HEAD ( & cpuctx -> rotation_list ) ; cpuctx -> unique_pmu = pmu ; } got_cpu_context : if ( ! pmu -> start_txn ) { if ( pmu -> pmu_enable ) { pmu -> start_txn = perf_pmu_start_txn ; pmu -> commit_txn = perf_pmu_commit_txn ; pmu -> cancel_txn = perf_pmu_cancel_txn ; } else { pmu -> start_txn = perf_pmu_nop_void ; pmu -> commit_txn = perf_pmu_nop_int ; pmu -> cancel_txn = perf_pmu_nop_void ; } } if ( ! pmu -> pmu_enable ) { pmu -> pmu_enable = perf_pmu_nop_void ; pmu -> pmu_disable = perf_pmu_nop_void ; } if ( ! pmu -> event_idx ) pmu -> event_idx = perf_event_idx_default ; list_add_rcu ( & pmu -> entry , & pmus ) ; ret = 0 ; unlock : mutex_unlock ( & pmus_lock ) ; return ret ; free_dev : device_del ( pmu -> dev ) ; put_device ( pmu -> dev ) ; free_idr : if ( pmu -> type >= PERF_TYPE_MAX ) idr_remove ( & pmu_idr , pmu -> type ) ; free_pdc : free_percpu ( pmu -> pmu_disable_count ) ; goto unlock ; } "," -> ctx . pmu = pmu ",torvalds@linux/c3c87e770458aa004bd7ed3f29945ff436fd6511,CVE-2015-9004,https://github.com/torvalds/linux/commit/c3c87e770458aa004bd7ed3f29945ff436fd6511,2017-05-02T21:59Z 494,CWE-000,"CWE-000 static ssize_t aio_setup_single_vector ( struct kiocb * kiocb , int rw , char __user * buf , unsigned long * nr_segs , size_t len , struct iovec * iovec ) { if ( unlikely ( ! access_ok ( ! rw , buf , len ) ) ) return - EFAULT ; iovec -> iov_base = buf ; iovec -> iov_len = len ; * nr_segs = 1 ; return 0 ; } "," iovec * iovec , struct iov_iter * iter ) { if ( len > MAX_RW_COUNT ) len = MAX_RW_COUNT ; if ( unlikely = 1 ; iov_iter_init ( iter , rw , iovec , * nr_segs , len ) ; ",torvalds@linux/4c185ce06dca14f5cea192f5a2c981ef50663f2b,CVE-2015-8830,https://github.com/torvalds/linux/commit/4c185ce06dca14f5cea192f5a2c981ef50663f2b,2016-05-02T10:59Z 495,CWE-189,"CWE-189 static int ext4_fill_flex_info ( struct super_block * sb ) { struct ext4_sb_info * sbi = EXT4_SB ( sb ) ; struct ext4_group_desc * gdp = NULL ; ext4_group_t flex_group_count ; ext4_group_t flex_group ; int groups_per_flex = 0 ; size_t size ; int i ; sbi -> s_log_groups_per_flex = sbi -> s_es -> s_log_groups_per_flex ; groups_per_flex = 1 << sbi -> s_log_groups_per_flex ; if ( groups_per_flex < 2 ) { sbi -> s_log_groups_per_flex = 0 ; return 1 ; } flex_group_count = ( ( sbi -> s_groups_count + groups_per_flex - 1 ) + ( ( le16_to_cpu ( sbi -> s_es -> s_reserved_gdt_blocks ) + 1 ) << EXT4_DESC_PER_BLOCK_BITS ( sb ) ) ) / groups_per_flex ; size = flex_group_count * sizeof ( struct flex_groups ) ; sbi -> s_flex_groups = ext4_kvzalloc ( size , GFP_KERNEL ) ; if ( sbi -> s_flex_groups == NULL ) { ext4_msg ( sb , KERN_ERR , ""notenoughmemoryfor%uflexgroups"" , flex_group_count ) ; goto failed ; } for ( i = 0 ; i < sbi -> s_groups_count ; i ++ ) { gdp = ext4_get_group_desc ( sb , i , NULL ) ; flex_group = ext4_flex_group ( sbi , i ) ; atomic_add ( ext4_free_inodes_count ( sb , gdp ) , & sbi -> s_flex_groups [ flex_group ] . free_inodes ) ; atomic_add ( ext4_free_group_clusters ( sb , gdp ) , & sbi -> s_flex_groups [ flex_group ] . free_clusters ) ; atomic_add ( ext4_used_dirs_count ( sb , gdp ) , & sbi -> s_flex_groups [ flex_group ] . used_dirs ) ; } return 1 ; failed : return 0 ; } "," ext4_group_t flex_group ; unsigned -> s_log_groups_per_flex ; if ( sbi -> s_log_groups_per_flex < 1 || sbi -> s_log_groups_per_flex > 31 ) { sbi -> s_log_groups_per_flex = 0 ; return 1 ; } -> s_log_groups_per_flex ; flex_group_count = ( ",torvalds@linux/d50f2ab6f050311dbf7b8f5501b25f0bf64a439b,CVE-2012-2100,https://github.com/torvalds/linux/commit/d50f2ab6f050311dbf7b8f5501b25f0bf64a439b,2012-07-03T16:40Z 496,CWE-399,"CWE-399 static inline int sctp_chunk_length_valid ( struct sctp_chunk * chunk , __u16 required_length ) { __u16 chunk_length = ntohs ( chunk -> chunk_hdr -> length ) ; if ( unlikely ( chunk_length < required_length ) ) return 0 ; return 1 ; } "," ( unlikely ( chunk -> pdiscard ) ) return 0 ; if ( unlikely ( ",torvalds@linux/26b87c7881006311828bb0ab271a551a62dcceb4,CVE-2014-3688,https://github.com/torvalds/linux/commit/26b87c7881006311828bb0ab271a551a62dcceb4,2014-11-30T01:59Z 497,CWE-119,"CWE-119 cJSON * cJSON_CreateStringArray ( const char * * strings , int count ) { int i ; cJSON * n = 0 , * p = 0 , * a = cJSON_CreateArray ( ) ; for ( i = 0 ; a && i < count ; ++ i ) { n = cJSON_CreateString ( strings [ i ] ) ; if ( ! i ) a -> child = n ; else suffix_object ( p , n ) ; p = n ; } return a ; } "," < count ; i ++ ) { n ] ) ; if ( ! n ) { cJSON_Delete ( a ) ; return 0 ; } ",esnet@iperf/91f2fa59e8ed80dfbf400add0164ee0e508e412a,CVE-2016-4303,https://github.com/esnet/iperf/commit/91f2fa59e8ed80dfbf400add0164ee0e508e412a,2016-09-26T14:59Z 498,CWE-287,"CWE-287 int m_authenticate ( struct Client * cptr , struct Client * sptr , int parc , char * parv [ ] ) { struct Client * acptr ; int first = 0 ; char realhost [ HOSTLEN + 3 ] ; char * hoststr = ( cli_sockhost ( cptr ) ? cli_sockhost ( cptr ) : cli_sock_ip ( cptr ) ) ; if ( ! CapActive ( cptr , CAP_SASL ) ) return 0 ; if ( parc < 2 ) return need_more_params ( cptr , ""AUTHENTICATE"" ) ; if ( strlen ( parv [ 1 ] ) > 400 ) return send_reply ( cptr , ERR_SASLTOOLONG ) ; if ( IsSASLComplete ( cptr ) ) return send_reply ( cptr , ERR_SASLALREADY ) ; if ( ! ( acptr = cli_saslagent ( cptr ) ) ) { if ( strcmp ( feature_str ( FEAT_SASL_SERVER ) , ""*"" ) ) acptr = find_match_server ( ( char * ) feature_str ( FEAT_SASL_SERVER ) ) ; else acptr = NULL ; } if ( ! acptr && strcmp ( feature_str ( FEAT_SASL_SERVER ) , ""*"" ) ) return send_reply ( cptr , ERR_SASLFAIL , "":serviceunavailable"" ) ; if ( acptr && IsMe ( acptr ) ) return 0 ; if ( ! cli_saslcookie ( cptr ) ) { do { cli_saslcookie ( cptr ) = ircrandom ( ) & 0x7fffffff ; } while ( ! cli_saslcookie ( cptr ) ) ; first = 1 ; } if ( strchr ( hoststr , ':' ) != NULL ) ircd_snprintf ( 0 , realhost , sizeof ( realhost ) , ""[%s]"" , hoststr ) ; else ircd_strncpy ( realhost , hoststr , sizeof ( realhost ) ) ; if ( acptr ) { if ( first ) { if ( ! EmptyString ( cli_sslclifp ( cptr ) ) ) sendcmdto_one ( & me , CMD_SASL , acptr , ""%C%C!%u.%uS%s:%s"" , acptr , & me , cli_fd ( cptr ) , cli_saslcookie ( cptr ) , parv [ 1 ] , cli_sslclifp ( cptr ) ) ; else sendcmdto_one ( & me , CMD_SASL , acptr , ""%C%C!%u.%uS:%s"" , acptr , & me , cli_fd ( cptr ) , cli_saslcookie ( cptr ) , parv [ 1 ] ) ; if ( feature_bool ( FEAT_SASL_SENDHOST ) ) sendcmdto_one ( & me , CMD_SASL , acptr , ""%C%C!%u.%uH:%s@%s:%s"" , acptr , & me , cli_fd ( cptr ) , cli_saslcookie ( cptr ) , cli_username ( cptr ) , realhost , cli_sock_ip ( cptr ) ) ; } else { sendcmdto_one ( & me , CMD_SASL , acptr , ""%C%C!%u.%uC:%s"" , acptr , & me , cli_fd ( cptr ) , cli_saslcookie ( cptr ) , parv [ 1 ] ) ; } } else { if ( first ) { if ( ! EmptyString ( cli_sslclifp ( cptr ) ) ) sendcmdto_serv_butone ( & me , CMD_SASL , cptr , ""*%C!%u.%uS%s:%s"" , & me , cli_fd ( cptr ) , cli_saslcookie ( cptr ) , parv [ 1 ] , cli_sslclifp ( cptr ) ) ; else sendcmdto_serv_butone ( & me , CMD_SASL , cptr , ""*%C!%u.%uS:%s"" , & me , cli_fd ( cptr ) , cli_saslcookie ( cptr ) , parv [ 1 ] ) ; if ( feature_bool ( FEAT_SASL_SENDHOST ) ) sendcmdto_serv_butone ( & me , CMD_SASL , cptr , ""*%C!%u.%uH:%s@%s:%s"" , & me , cli_fd ( cptr ) , cli_saslcookie ( cptr ) , cli_username ( cptr ) , realhost , cli_sock_ip ( cptr ) ) ; } else { sendcmdto_serv_butone ( & me , CMD_SASL , cptr , ""*%C!%u.%uC:%s"" , & me , cli_fd ( cptr ) , cli_saslcookie ( cptr ) , parv [ 1 ] ) ; } } if ( ! t_active ( & cli_sasltimeout ( cptr ) ) ) timer_add ( timer_init ( & cli_sasltimeout ( cptr ) ) , sasl_timeout_callback , ( void * ) cptr , TT_RELATIVE , feature_int ( FEAT_SASL_TIMEOUT ) ) ; return 0 ; } "," { if ( * parv [ 1 ] == ':' || strchr ( parv [ 1 ] , '' ) ) return exit_client ( cptr , sptr , sptr , ""MalformedAUTHENTICATE"" ) ; if ( { if ( * parv [ 1 ] == ':' || strchr ( parv [ 1 ] , '' ) ) return exit_client ( cptr , sptr , sptr , ""MalformedAUTHENTICATE"" ) ; if ( ",evilnet@nefarious2/f50a84bad996d438e7b31b9e74c32a41e43f8be5,CVE-2016-7145,https://github.com/evilnet/nefarious2/commit/f50a84bad996d438e7b31b9e74c32a41e43f8be5,2017-03-07T15:59Z 499,CWE-189,"CWE-189 static void diff_bytes_c ( uint8_t * dst , const uint8_t * src1 , const uint8_t * src2 , int w ) { long i ; # if ! HAVE_FAST_UNALIGNED if ( ( long ) src2 & ( sizeof ( long ) - 1 ) ) { for ( i = 0 ; i + 7 < w ; i += 8 ) { dst [ i + 0 ] = src1 [ i + 0 ] - src2 [ i + 0 ] ; dst [ i + 1 ] = src1 [ i + 1 ] - src2 [ i + 1 ] ; dst [ i + 2 ] = src1 [ i + 2 ] - src2 [ i + 2 ] ; dst [ i + 3 ] = src1 [ i + 3 ] - src2 [ i + 3 ] ; dst [ i + 4 ] = src1 [ i + 4 ] - src2 [ i + 4 ] ; dst [ i + 5 ] = src1 [ i + 5 ] - src2 [ i + 5 ] ; dst [ i + 6 ] = src1 [ i + 6 ] - src2 [ i + 6 ] ; dst [ i + 7 ] = src1 [ i + 7 ] - src2 [ i + 7 ] ; } } else # endif for ( i = 0 ; i <= w - sizeof ( long ) ; i += sizeof ( long ) ) { long a = * ( long * ) ( src1 + i ) ; long b = * ( long * ) ( src2 + i ) ; * ( long * ) ( dst + i ) = ( ( a | pb_80 ) - ( b & pb_7f ) ) ^ ( ( a ^ b ^ pb_80 ) & pb_80 ) ; } for ( ; i < w ; i ++ ) dst [ i + 0 ] = src1 [ i + 0 ] - src2 [ i + 0 ] ; } "," <= w - ( int ) ",FFmpeg@FFmpeg/454a11a1c9c686c78aa97954306fb63453299760,CVE-2013-7010,https://github.com/FFmpeg/FFmpeg/commit/454a11a1c9c686c78aa97954306fb63453299760,2013-12-09T16:36Z 500,CWE-125,"CWE-125 int _yr_scan_match_callback ( uint8_t * match_data , int32_t match_length , int flags , void * args ) { CALLBACK_ARGS * callback_args = ( CALLBACK_ARGS * ) args ; YR_STRING * string = callback_args -> string ; YR_MATCH * new_match ; int result = ERROR_SUCCESS ; int tidx = callback_args -> context -> tidx ; size_t match_offset = match_data - callback_args -> data ; match_length += callback_args -> forward_matches ; if ( callback_args -> full_word ) { if ( flags & RE_FLAGS_WIDE ) { if ( match_offset >= 2 && * ( match_data - 1 ) == 0 && isalnum ( * ( match_data - 2 ) ) ) return ERROR_SUCCESS ; if ( match_offset + match_length + 1 < callback_args -> data_size && * ( match_data + match_length + 1 ) == 0 && isalnum ( * ( match_data + match_length ) ) ) return ERROR_SUCCESS ; } else { if ( match_offset >= 1 && isalnum ( * ( match_data - 1 ) ) ) return ERROR_SUCCESS ; if ( match_offset + match_length < callback_args -> data_size && isalnum ( * ( match_data + match_length ) ) ) return ERROR_SUCCESS ; } } if ( STRING_IS_CHAIN_PART ( string ) ) { result = _yr_scan_verify_chained_string_match ( string , callback_args -> context , match_data , callback_args -> data_base , match_offset , match_length ) ; } else { if ( string -> matches [ tidx ] . count == 0 ) { FAIL_ON_ERROR ( yr_arena_write_data ( callback_args -> context -> matching_strings_arena , & string , sizeof ( string ) , NULL ) ) ; } FAIL_ON_ERROR ( yr_arena_allocate_memory ( callback_args -> context -> matches_arena , sizeof ( YR_MATCH ) , ( void * * ) & new_match ) ) ; new_match -> data_length = yr_min ( match_length , MAX_MATCH_DATA ) ; FAIL_ON_ERROR ( yr_arena_write_data ( callback_args -> context -> matches_arena , match_data , new_match -> data_length , ( void * * ) & new_match -> data ) ) ; if ( result == ERROR_SUCCESS ) { new_match -> base = callback_args -> data_base ; new_match -> offset = match_offset ; new_match -> match_length = match_length ; new_match -> prev = NULL ; new_match -> next = NULL ; FAIL_ON_ERROR ( _yr_scan_add_match_to_list ( new_match , & string -> matches [ tidx ] , STRING_IS_GREEDY_REGEXP ( string ) ) ) ; } } return result ; } "," callback_args -> forward_matches ; assert ( match_offset + match_length <= callback_args -> data_size ) ",VirusTotal@yara/992480c30f75943e9cd6245bb2015c7737f9b661,CVE-2017-9465,https://github.com/VirusTotal/yara/commit/992480c30f75943e9cd6245bb2015c7737f9b661,2017-06-06T21:29Z 501,CWE-264,"CWE-264 static Channel * server_request_direct_streamlocal ( void ) { Channel * c = NULL ; char * target , * originator ; u_short originator_port ; target = packet_get_string ( NULL ) ; originator = packet_get_string ( NULL ) ; originator_port = packet_get_int ( ) ; packet_check_eom ( ) ; debug ( ""server_request_direct_streamlocal:originator%sport%d,target%s"" , originator , originator_port , target ) ; if ( ( options . allow_streamlocal_forwarding & FORWARD_LOCAL ) != 0 && ! no_port_forwarding_flag && ! options . disable_forwarding ) { c = channel_connect_to_path ( target , ""direct-streamlocal@openssh.com"" , ""direct-streamlocal"" ) ; } else { logit ( ""refusedstreamlocalportforward:"" ""originator%sport%d,target%s"" , originator , originator_port , target ) ; } free ( originator ) ; free ( target ) ; return c ; } "," options . disable_forwarding && use_privsep ",openbsd@src/c76fac666ea038753294f2ac94d310f8adece9ce,CVE-2016-10010,https://github.com/openbsd/src/commit/c76fac666ea038753294f2ac94d310f8adece9ce,2017-01-05T02:59Z 502,CWE-119,"CWE-119 static int smacker_decode_tree ( BitstreamContext * bc , HuffContext * hc , uint32_t prefix , int length ) { if ( ! bitstream_read_bit ( bc ) ) { if ( hc -> current >= 256 ) { av_log ( NULL , AV_LOG_ERROR , ""Treesizeexceeded!\\n"" ) ; return AVERROR_INVALIDDATA ; } if ( length ) { hc -> bits [ hc -> current ] = prefix ; hc -> lengths [ hc -> current ] = length ; } else { hc -> bits [ hc -> current ] = 0 ; hc -> lengths [ hc -> current ] = 0 ; } hc -> values [ hc -> current ] = bitstream_read ( bc , 8 ) ; hc -> current ++ ; if ( hc -> maxlength < length ) hc -> maxlength = length ; return 0 ; } else { int r ; length ++ ; r = smacker_decode_tree ( bc , hc , prefix , length ) ; if ( r ) return r ; return smacker_decode_tree ( bc , hc , prefix | ( 1 << ( length - 1 ) ) , length ) ; } } "," { if ( length > SMKTREE_DECODE_MAX_RECURSION ) { av_log ( NULL , AV_LOG_ERROR , ""Maximumtreerecursionlevelexceeded.\\n"" ) ; return AVERROR_INVALIDDATA ; } if ( ",libav@libav/cd4663dc80323ba64989d0c103d51ad3ee0e9c2f,CVE-2017-16803,https://github.com/libav/libav/commit/cd4663dc80323ba64989d0c103d51ad3ee0e9c2f,2017-11-13T17:29Z 503,CWE-20,"CWE-20 int verify_iovec ( struct msghdr * m , struct iovec * iov , struct sockaddr_storage * address , int mode ) { int size , ct , err ; if ( m -> msg_namelen ) { if ( mode == VERIFY_READ ) { void __user * namep ; namep = ( void __user __force * ) m -> msg_name ; err = move_addr_to_kernel ( namep , m -> msg_namelen , address ) ; if ( err < 0 ) return err ; } m -> msg_name = address ; } else { m -> msg_name = NULL ; } size = m -> msg_iovlen * sizeof ( struct iovec ) ; if ( copy_from_user ( iov , ( void __user __force * ) m -> msg_iov , size ) ) return - EFAULT ; m -> msg_iov = iov ; err = 0 ; for ( ct = 0 ; ct < m -> msg_iovlen ; ct ++ ) { size_t len = iov [ ct ] . iov_len ; if ( len > INT_MAX - err ) { len = INT_MAX - err ; iov [ ct ] . iov_len = len ; } err += len ; } return err ; } "," err ; } if ( m -> msg_name ) ",torvalds@linux/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,CVE-2013-7271,https://github.com/torvalds/linux/commit/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,2014-01-06T16:55Z 504,CWE-125,"CWE-125 int obj2ast_mod ( PyObject * obj , mod_ty * out , PyArena * arena ) { int isinstance ; PyObject * tmp = NULL ; if ( obj == Py_None ) { * out = NULL ; return 0 ; } isinstance = PyObject_IsInstance ( obj , ( PyObject * ) Module_type ) ; if ( isinstance == - 1 ) { return 1 ; } if ( isinstance ) { asdl_seq * body ; asdl_seq * type_ignores ; if ( _PyObject_HasAttrId ( obj , & PyId_body ) ) { int res ; Py_ssize_t len ; Py_ssize_t i ; tmp = _PyObject_GetAttrId ( obj , & PyId_body ) ; if ( tmp == NULL ) goto failed ; if ( ! PyList_Check ( tmp ) ) { PyErr_Format ( PyExc_TypeError , ""Modulefield\\""body\\""mustbealist,nota%.200s"" , tmp -> ob_type -> tp_name ) ; goto failed ; } len = PyList_GET_SIZE ( tmp ) ; body = _Ta3_asdl_seq_new ( len , arena ) ; if ( body == NULL ) goto failed ; for ( i = 0 ; i < len ; i ++ ) { stmt_ty value ; res = obj2ast_stmt ( PyList_GET_ITEM ( tmp , i ) , & value , arena ) ; if ( res != 0 ) goto failed ; if ( len != PyList_GET_SIZE ( tmp ) ) { PyErr_SetString ( PyExc_RuntimeError , ""Modulefield\\""body\\""changedsizeduringiteration"" ) ; goto failed ; } asdl_seq_SET ( body , i , value ) ; } Py_CLEAR ( tmp ) ; } else { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""body\\""missingfromModule"" ) ; return 1 ; } if ( _PyObject_HasAttrId ( obj , & PyId_type_ignores ) ) { int res ; Py_ssize_t len ; Py_ssize_t i ; tmp = _PyObject_GetAttrId ( obj , & PyId_type_ignores ) ; if ( tmp == NULL ) goto failed ; if ( ! PyList_Check ( tmp ) ) { PyErr_Format ( PyExc_TypeError , ""Modulefield\\""type_ignores\\""mustbealist,nota%.200s"" , tmp -> ob_type -> tp_name ) ; goto failed ; } len = PyList_GET_SIZE ( tmp ) ; type_ignores = _Ta3_asdl_seq_new ( len , arena ) ; if ( type_ignores == NULL ) goto failed ; for ( i = 0 ; i < len ; i ++ ) { type_ignore_ty value ; res = obj2ast_type_ignore ( PyList_GET_ITEM ( tmp , i ) , & value , arena ) ; if ( res != 0 ) goto failed ; if ( len != PyList_GET_SIZE ( tmp ) ) { PyErr_SetString ( PyExc_RuntimeError , ""Modulefield\\""type_ignores\\""changedsizeduringiteration"" ) ; goto failed ; } asdl_seq_SET ( type_ignores , i , value ) ; } Py_CLEAR ( tmp ) ; } else { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""type_ignores\\""missingfromModule"" ) ; return 1 ; } * out = Module ( body , type_ignores , arena ) ; if ( * out == NULL ) goto failed ; return 0 ; } isinstance = PyObject_IsInstance ( obj , ( PyObject * ) Interactive_type ) ; if ( isinstance == - 1 ) { return 1 ; } if ( isinstance ) { asdl_seq * body ; if ( _PyObject_HasAttrId ( obj , & PyId_body ) ) { int res ; Py_ssize_t len ; Py_ssize_t i ; tmp = _PyObject_GetAttrId ( obj , & PyId_body ) ; if ( tmp == NULL ) goto failed ; if ( ! PyList_Check ( tmp ) ) { PyErr_Format ( PyExc_TypeError , ""Interactivefield\\""body\\""mustbealist,nota%.200s"" , tmp -> ob_type -> tp_name ) ; goto failed ; } len = PyList_GET_SIZE ( tmp ) ; body = _Ta3_asdl_seq_new ( len , arena ) ; if ( body == NULL ) goto failed ; for ( i = 0 ; i < len ; i ++ ) { stmt_ty value ; res = obj2ast_stmt ( PyList_GET_ITEM ( tmp , i ) , & value , arena ) ; if ( res != 0 ) goto failed ; if ( len != PyList_GET_SIZE ( tmp ) ) { PyErr_SetString ( PyExc_RuntimeError , ""Interactivefield\\""body\\""changedsizeduringiteration"" ) ; goto failed ; } asdl_seq_SET ( body , i , value ) ; } Py_CLEAR ( tmp ) ; } else { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""body\\""missingfromInteractive"" ) ; return 1 ; } * out = Interactive ( body , arena ) ; if ( * out == NULL ) goto failed ; return 0 ; } isinstance = PyObject_IsInstance ( obj , ( PyObject * ) Expression_type ) ; if ( isinstance == - 1 ) { return 1 ; } if ( isinstance ) { expr_ty body ; if ( _PyObject_HasAttrId ( obj , & PyId_body ) ) { int res ; tmp = _PyObject_GetAttrId ( obj , & PyId_body ) ; if ( tmp == NULL ) goto failed ; res = obj2ast_expr ( tmp , & body , arena ) ; if ( res != 0 ) goto failed ; Py_CLEAR ( tmp ) ; } else { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""body\\""missingfromExpression"" ) ; return 1 ; } * out = Expression ( body , arena ) ; if ( * out == NULL ) goto failed ; return 0 ; } isinstance = PyObject_IsInstance ( obj , ( PyObject * ) FunctionType_type ) ; if ( isinstance == - 1 ) { return 1 ; } if ( isinstance ) { asdl_seq * argtypes ; expr_ty returns ; if ( _PyObject_HasAttrId ( obj , & PyId_argtypes ) ) { int res ; Py_ssize_t len ; Py_ssize_t i ; tmp = _PyObject_GetAttrId ( obj , & PyId_argtypes ) ; if ( tmp == NULL ) goto failed ; if ( ! PyList_Check ( tmp ) ) { PyErr_Format ( PyExc_TypeError , ""FunctionTypefield\\""argtypes\\""mustbealist,nota%.200s"" , tmp -> ob_type -> tp_name ) ; goto failed ; } len = PyList_GET_SIZE ( tmp ) ; argtypes = _Ta3_asdl_seq_new ( len , arena ) ; if ( argtypes == NULL ) goto failed ; for ( i = 0 ; i < len ; i ++ ) { expr_ty value ; res = obj2ast_expr ( PyList_GET_ITEM ( tmp , i ) , & value , arena ) ; if ( res != 0 ) goto failed ; if ( len != PyList_GET_SIZE ( tmp ) ) { PyErr_SetString ( PyExc_RuntimeError , ""FunctionTypefield\\""argtypes\\""changedsizeduringiteration"" ) ; goto failed ; } asdl_seq_SET ( argtypes , i , value ) ; } Py_CLEAR ( tmp ) ; } else { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""argtypes\\""missingfromFunctionType"" ) ; return 1 ; } if ( _PyObject_HasAttrId ( obj , & PyId_returns ) ) { int res ; tmp = _PyObject_GetAttrId ( obj , & PyId_returns ) ; if ( tmp == NULL ) goto failed ; res = obj2ast_expr ( tmp , & returns , arena ) ; if ( res != 0 ) goto failed ; Py_CLEAR ( tmp ) ; } else { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""returns\\""missingfromFunctionType"" ) ; return 1 ; } * out = FunctionType ( argtypes , returns , arena ) ; if ( * out == NULL ) goto failed ; return 0 ; } isinstance = PyObject_IsInstance ( obj , ( PyObject * ) Suite_type ) ; if ( isinstance == - 1 ) { return 1 ; } if ( isinstance ) { asdl_seq * body ; if ( _PyObject_HasAttrId ( obj , & PyId_body ) ) { int res ; Py_ssize_t len ; Py_ssize_t i ; tmp = _PyObject_GetAttrId ( obj , & PyId_body ) ; if ( tmp == NULL ) goto failed ; if ( ! PyList_Check ( tmp ) ) { PyErr_Format ( PyExc_TypeError , ""Suitefield\\""body\\""mustbealist,nota%.200s"" , tmp -> ob_type -> tp_name ) ; goto failed ; } len = PyList_GET_SIZE ( tmp ) ; body = _Ta3_asdl_seq_new ( len , arena ) ; if ( body == NULL ) goto failed ; for ( i = 0 ; i < len ; i ++ ) { stmt_ty value ; res = obj2ast_stmt ( PyList_GET_ITEM ( tmp , i ) , & value , arena ) ; if ( res != 0 ) goto failed ; if ( len != PyList_GET_SIZE ( tmp ) ) { PyErr_SetString ( PyExc_RuntimeError , ""Suitefield\\""body\\""changedsizeduringiteration"" ) ; goto failed ; } asdl_seq_SET ( body , i , value ) ; } Py_CLEAR ( tmp ) ; } else { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""body\\""missingfromSuite"" ) ; return 1 ; } * out = Suite ( body , arena ) ; if ( * out == NULL ) goto failed ; return 0 ; } PyErr_Format ( PyExc_TypeError , ""expectedsomesortofmod,butgot%R"" , obj ) ; failed : Py_XDECREF ( tmp ) ; return 1 ; } "," ; if ( lookup_attr_id ( obj , , & PyId_body , & tmp ) < 0 ) { return 1 ; } if ( tmp == NULL ) { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""body\\""missingfromModule"" ) ; return 1 ; } else { int res ; Py_ssize_t i ; if ( ) { stmt_ty val ; res = ) , & val , arena ) , i , val ) ; } ) ; } if ( lookup_attr_id ( obj , & PyId_type_ignores , & tmp ) < 0 ) { return 1 ; } if ( tmp == NULL ) { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""type_ignores\\""missingfromModule"" ) ; return 1 ; } else { int res ; ; Py_ssize_t i ; if ( ) { type_ignore_ty val ; res = ) , & val , arena ) , i , val ) ; } ) ; } * out = Module ( body , type_ignores , arena ) ; if ( * out == NULL ) goto failed ; return 0 ; } isinstance = PyObject_IsInstance ( obj , ( PyObject * ) Interactive_type ) ; if ( isinstance == - 1 ) { return 1 ; } if ( isinstance ) { asdl_seq * body ; if ( lookup_attr_id ( obj , & PyId_body , & tmp ) < 0 ) { return 1 ; } if ( tmp == NULL ) { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""body\\""missingfromInteractive"" ) ; return 1 ; } else { int res ; ; Py_ssize_t i ; if ( ) { stmt_ty val ; res = ) , & val , arena ) , i , val ) ; } ) ; } * out = Interactive ( body , arena ) ; if ( * out == NULL ) goto failed ; return 0 ; } isinstance = PyObject_IsInstance ( obj , ( PyObject * ) Expression_type ) ; if ( isinstance == - 1 ) { return 1 ; } if ( isinstance ) { expr_ty body ; if ( lookup_attr_id ( obj , & PyId_body , & tmp ) < 0 ) { return 1 ; } if ( tmp == NULL ) { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""body\\""missingfromExpression"" ) ; return 1 ; } else { int res ; int res ; res = obj2ast_expr ( tmp ) ; } * ; if ( lookup_attr_id ( obj , , & PyId_argtypes , & tmp ) < 0 ) { return 1 ; } if ( tmp == NULL ) { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""argtypes\\""missingfromFunctionType"" ) ; return 1 ; } else { int res ; Py_ssize_t i ; if ( ) { expr_ty val ; res = ) , & val , arena ) , i , val ) ; } ) ; } if ( lookup_attr_id ( obj , & PyId_returns , & tmp ) < 0 ) { return 1 ; } if ( tmp == NULL ) { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""returns\\""missingfromFunctionType"" ) ; return 1 ; } else { int res ; res = obj2ast_expr ( tmp , & returns , arena ) ; if ( res != 0 ) goto failed ; Py_CLEAR ( tmp ) ; } * out = FunctionType ( argtypes , returns , arena ) ; if ( * out == NULL ) goto failed ; return 0 ; } isinstance = PyObject_IsInstance ( obj , ( PyObject * ) Suite_type ) ; if ( isinstance == - 1 ) { return 1 ; } if ( isinstance ) { asdl_seq * body ; if ( lookup_attr_id ( obj , & PyId_body , & tmp ) < 0 ) { return 1 ; } if ( tmp == NULL ) { PyErr_SetString ( PyExc_TypeError ( PyExc_TypeError , ""requiredfield\\""body\\""missingfromSuite"" ) ; return 1 ; } else { int res int res ; Py_ssize_t len ; ; Py_ssize_t i ; if ( ) { stmt_ty val ; res = ) , & val , arena ) , i , val ) ; } ) ; } * out = Suite ( body , arena ) ; if ( * out == NULL ) goto failed ; return 0 ; } PyErr_Format ( PyExc_TypeError , ( PyExc_TypeError , ""expectedsomesortofmod,butgot%R"" , obj ",python@typed_ast/156afcb26c198e162504a57caddfe0acd9ed7dce,CVE-2019-19275,https://github.com/python/typed_ast/commit/156afcb26c198e162504a57caddfe0acd9ed7dce,2019-11-26T15:15Z 505,CWE-119,"CWE-119 void jpc_qmfb_split_col ( jpc_fix_t * a , int numrows , int stride , int parity ) { int bufsize = JPC_CEILDIVPOW2 ( numrows , 1 ) ; jpc_fix_t splitbuf [ QMFB_SPLITBUFSIZE ] ; jpc_fix_t * buf = splitbuf ; register jpc_fix_t * srcptr ; register jpc_fix_t * dstptr ; register int n ; register int m ; int hstartcol ; if ( bufsize > QMFB_SPLITBUFSIZE ) { if ( ! ( buf = jas_alloc2 ( bufsize , sizeof ( jpc_fix_t ) ) ) ) { abort ( ) ; } } if ( numrows >= 2 ) { hstartcol = ( numrows + 1 - parity ) >> 1 ; m = numrows - hstartcol ; n = m ; dstptr = buf ; srcptr = & a [ ( 1 - parity ) * stride ] ; while ( n -- > 0 ) { * dstptr = * srcptr ; ++ dstptr ; srcptr += stride << 1 ; } dstptr = & a [ ( 1 - parity ) * stride ] ; srcptr = & a [ ( 2 - parity ) * stride ] ; n = numrows - m - ( ! parity ) ; while ( n -- > 0 ) { * dstptr = * srcptr ; dstptr += stride ; srcptr += stride << 1 ; } dstptr = & a [ hstartcol * stride ] ; srcptr = buf ; n = m ; while ( n -- > 0 ) { * dstptr = * srcptr ; dstptr += stride ; ++ srcptr ; } } if ( buf != splitbuf ) { jas_free ( buf ) ; } } "," m ; int hstartrow ; if ( 2 ) { hstartrow = ( numrows = numrows - hstartrow ; n = & a [ hstartrow * stride ] ",mdadams@jasper/4a59cfaf9ab3d48fca4a15c0d2674bf7138e3d1a,CVE-2016-8654,https://github.com/mdadams/jasper/commit/4a59cfaf9ab3d48fca4a15c0d2674bf7138e3d1a,2018-08-01T16:29Z 506,CWE-119,"CWE-119 static int iwl_process_add_sta_resp ( struct iwl_priv * priv , struct iwl_addsta_cmd * addsta , struct iwl_rx_packet * pkt ) { u8 sta_id = addsta -> sta . sta_id ; unsigned long flags ; int ret = - EIO ; if ( pkt -> hdr . flags & IWL_CMD_FAILED_MSK ) { IWL_ERR ( priv , ""BadreturnfromREPLY_ADD_STA(0x%08X)\\n"" , pkt -> hdr . flags ) ; return ret ; } IWL_DEBUG_INFO ( priv , ""Processingresponseforaddingstation%u\\n"" , sta_id ) ; spin_lock_irqsave ( & priv -> shrd -> sta_lock , flags ) ; switch ( pkt -> u . add_sta . status ) { case ADD_STA_SUCCESS_MSK : IWL_DEBUG_INFO ( priv , ""REPLY_ADD_STAPASSED\\n"" ) ; iwl_sta_ucode_activate ( priv , sta_id ) ; ret = 0 ; break ; case ADD_STA_NO_ROOM_IN_TABLE : IWL_ERR ( priv , ""Addingstation%dfailed,noroomintable.\\n"" , sta_id ) ; break ; case ADD_STA_NO_BLOCK_ACK_RESOURCE : IWL_ERR ( priv , ""Addingstation%dfailed,noblockack"" ""resource.\\n"" , sta_id ) ; break ; case ADD_STA_MODIFY_NON_EXIST_STA : IWL_ERR ( priv , ""Attemptingtomodifynon-existingstation%d\\n"" , sta_id ) ; break ; default : IWL_DEBUG_ASSOC ( priv , ""ReceivedREPLY_ADD_STA:(0x%08X)\\n"" , pkt -> u . add_sta . status ) ; break ; } IWL_DEBUG_INFO ( priv , ""%sstationid%uaddr%pM\\n"" , priv -> stations [ sta_id ] . sta . mode == STA_CONTROL_MODIFY_MSK ? ""Modified"" : ""Added"" , sta_id , priv -> stations [ sta_id ] . sta . sta . addr ) ; IWL_DEBUG_INFO ( priv , ""%sstationaccordingtocmdbuffer%pM\\n"" , priv -> stations [ sta_id ] . sta . mode == STA_CONTROL_MODIFY_MSK ? ""Modified"" : ""Added"" , addsta -> sta . addr ) ; spin_unlock_irqrestore ( & priv -> shrd -> sta_lock , flags ) ; return ret ; } "," ""REPLY_ADD_STAPASSED\\n"" ) ; ret = iwl_sta_ucode_activate ( priv , sta_id ) ; break ; ",torvalds@linux/2da424b0773cea3db47e1e81db71eeebde8269d4,CVE-2012-6712,https://github.com/torvalds/linux/commit/2da424b0773cea3db47e1e81db71eeebde8269d4,2019-07-27T22:15Z 507,CWE-59,"CWE-59 void open_log_file ( const char * name , const char * prog , const char * namespace , const char * instance ) { char * file_name ; if ( log_file ) { fclose ( log_file ) ; log_file = NULL ; } if ( ! name ) return ; file_name = make_file_name ( name , prog , namespace , instance ) ; log_file = fopen ( file_name , ""a"" ) ; if ( log_file ) { int n = fileno ( log_file ) ; fcntl ( n , F_SETFD , FD_CLOEXEC | fcntl ( n , F_GETFD ) ) ; fcntl ( n , F_SETFL , O_NONBLOCK | fcntl ( n , F_GETFL ) ) ; } FREE ( file_name ) ; } "," ; log_file = fopen_safe ( file_name , ",acassen@keepalived/04f2d32871bb3b11d7dc024039952f2fe2750306,CVE-2018-19044,https://github.com/acassen/keepalived/commit/04f2d32871bb3b11d7dc024039952f2fe2750306,2018-11-08T20:29Z 508,CWE-476,"CWE-476 void test_re ( ) { assert_true_rule ( ""ruletest{strings:$a=/ssi/condition:$a}"" , ""mississippi\\tmississippi.mississippi\\nmississippi"" ) ; assert_true_rule ( ""ruletest{strings:$a=/ssi(s|p)/condition:$a}"" , ""mississippi\\tmississippi.mississippi\\nmississippi"" ) ; assert_true_rule ( ""ruletest{strings:$a=/ssim*/condition:$a}"" , ""mississippi\\tmississippi.mississippi\\nmississippi"" ) ; assert_true_rule ( ""ruletest{strings:$a=/ssa?/condition:$a}"" , ""mississippi\\tmississippi.mississippi\\nmississippi"" ) ; assert_true_rule ( ""ruletest{strings:$a=/Miss/nocasecondition:$a}"" , ""mississippi\\tmississippi.mississippi\\nmississippi"" ) ; assert_true_rule ( ""ruletest{strings:$a=/(M|N)iss/nocasecondition:$a}"" , ""mississippi\\tmississippi.mississippi\\nmississippi"" ) ; assert_true_rule ( ""ruletest{strings:$a=/[M-N]iss/nocasecondition:$a}"" , ""mississippi\\tmississippi.mississippi\\nmississippi"" ) ; assert_true_rule ( ""ruletest{strings:$a=/(Mi|ssi)ssippi/nocasecondition:$a}"" , ""mississippi\\tmississippi.mississippi\\nmississippi"" ) ; assert_true_rule ( ""ruletest{strings:$a=/ppi\\\\tmi/condition:$a}"" , ""mississippi\\tmississippi.mississippi\\nmississippi"" ) ; assert_true_rule ( ""ruletest{strings:$a=/ppi\\\\.mi/condition:$a}"" , ""mississippi\\tmississippi.mississippi\\nmississippi"" ) ; assert_true_rule ( ""ruletest{strings:$a=/^mississippi/fullwordcondition:$a}"" , ""mississippi\\tmississippi.mississippi\\nmississippi"" ) ; assert_true_rule ( ""ruletest{strings:$a=/mississippi.*mississippi$/scondition:$a}"" , ""mississippi\\tmississippi.mississippi\\nmississippi"" ) ; assert_false_rule ( ""ruletest{strings:$a=/^ssi/condition:$a}"" , ""mississippi"" ) ; assert_false_rule ( ""ruletest{strings:$a=/ssi$/condition:$a}"" , ""mississippi"" ) ; assert_false_rule ( ""ruletest{strings:$a=/ssissi/fullwordcondition:$a}"" , ""mississippi"" ) ; assert_false_rule ( ""ruletest{strings:$a=/^[isp]+/condition:$a}"" , ""mississippi"" ) ; assert_regexp_syntax_error ( "")"" ) ; assert_true_regexp ( ""abc"" , ""abc"" , ""abc"" ) ; assert_false_regexp ( ""abc"" , ""xbc"" ) ; assert_false_regexp ( ""abc"" , ""axc"" ) ; assert_false_regexp ( ""abc"" , ""abx"" ) ; assert_true_regexp ( ""abc"" , ""xabcx"" , ""abc"" ) ; assert_true_regexp ( ""abc"" , ""ababc"" , ""abc"" ) ; assert_true_regexp ( ""a.c"" , ""abc"" , ""abc"" ) ; assert_false_regexp ( ""a.b"" , ""a\\nb"" ) ; assert_false_regexp ( ""a.*b"" , ""acc\\nccb"" ) ; assert_false_regexp ( ""a.{4,5}b"" , ""acc\\nccb"" ) ; assert_true_regexp ( ""a.b"" , ""a\\rb"" , ""a\\rb"" ) ; assert_true_regexp ( ""ab*c"" , ""abc"" , ""abc"" ) ; assert_true_regexp ( ""ab*c"" , ""ac"" , ""ac"" ) ; assert_true_regexp ( ""ab*bc"" , ""abc"" , ""abc"" ) ; assert_true_regexp ( ""ab*bc"" , ""abbc"" , ""abbc"" ) ; assert_true_regexp ( ""a.*bb"" , ""abbbb"" , ""abbbb"" ) ; assert_true_regexp ( ""a.*?bbb"" , ""abbbbbb"" , ""abbb"" ) ; assert_true_regexp ( ""a.*c"" , ""ac"" , ""ac"" ) ; assert_true_regexp ( ""a.*c"" , ""axyzc"" , ""axyzc"" ) ; assert_true_regexp ( ""ab+c"" , ""abbc"" , ""abbc"" ) ; assert_false_regexp ( ""ab+c"" , ""ac"" ) ; assert_true_regexp ( ""ab+"" , ""abbbb"" , ""abbbb"" ) ; assert_true_regexp ( ""ab+?"" , ""abbbb"" , ""ab"" ) ; assert_false_regexp ( ""ab+bc"" , ""abc"" ) ; assert_false_regexp ( ""ab+bc"" , ""abq"" ) ; assert_true_regexp ( ""a+b+c"" , ""aabbabc"" , ""abc"" ) ; assert_false_regexp ( ""ab?bc"" , ""abbbbc"" ) ; assert_true_regexp ( ""ab?c"" , ""abc"" , ""abc"" ) ; assert_true_regexp ( ""ab*?"" , ""abbb"" , ""a"" ) ; assert_true_regexp ( ""ab?c"" , ""abc"" , ""abc"" ) ; assert_true_regexp ( ""ab??"" , ""ab"" , ""a"" ) ; assert_true_regexp ( ""a(b|x)c"" , ""abc"" , ""abc"" ) ; assert_true_regexp ( ""a(b|x)c"" , ""axc"" , ""axc"" ) ; assert_true_regexp ( ""a(b|.)c"" , ""axc"" , ""axc"" ) ; assert_true_regexp ( ""a(b|x|y)c"" , ""ayc"" , ""ayc"" ) ; assert_true_regexp ( ""(a+|b)*"" , ""ab"" , ""ab"" ) ; assert_true_regexp ( ""a|b|c|d|e"" , ""e"" , ""e"" ) ; assert_true_regexp ( ""(a|b|c|d|e)f"" , ""ef"" , ""ef"" ) ; assert_true_regexp ( "".b{2}"" , ""abb"" , ""abb"" ) ; assert_true_regexp ( ""ab{1}c"" , ""abc"" , ""abc"" ) ; assert_true_regexp ( ""ab{1,2}c"" , ""abbc"" , ""abbc"" ) ; assert_true_regexp ( ""ab{1,}c"" , ""abbbc"" , ""abbbc"" ) ; assert_false_regexp ( ""ab{1,}b"" , ""ab"" ) ; assert_false_regexp ( ""ab{1}c"" , ""abbc"" ) ; assert_true_regexp ( ""ab{0,}c"" , ""ac"" , ""ac"" ) ; assert_true_regexp ( ""ab{0,}c"" , ""abbbc"" , ""abbbc"" ) ; assert_true_regexp ( ""ab{,3}c"" , ""abbbc"" , ""abbbc"" ) ; assert_false_regexp ( ""ab{,2}c"" , ""abbbc"" ) ; assert_false_regexp ( ""ab{4,5}bc"" , ""abbbbc"" ) ; assert_true_regexp ( ""ab{2,3}?"" , ""abbbbb"" , ""abb"" ) ; assert_true_regexp ( ""ab{.*}"" , ""ab{c}"" , ""ab{c}"" ) ; assert_true_regexp ( "".(aa){1,2}"" , ""aaaaaaaaaa"" , ""aaaaa"" ) ; assert_true_regexp ( ""a.(bc.){2}"" , ""aabcabca"" , ""aabcabca"" ) ; assert_true_regexp ( ""(ab{1,2}c){1,3}"" , ""abbcabc"" , ""abbcabc"" ) ; assert_true_regexp ( ""ab(c|cc){1,3}d"" , ""abccccccd"" , ""abccccccd"" ) ; assert_true_regexp ( ""a[bx]c"" , ""abc"" , ""abc"" ) ; assert_true_regexp ( ""a[bx]c"" , ""axc"" , ""axc"" ) ; assert_true_regexp ( ""a[0-9]*b"" , ""ab"" , ""ab"" ) ; assert_true_regexp ( ""a[0-9]*b"" , ""a0123456789b"" , ""a0123456789b"" ) ; assert_true_regexp ( ""[0-9a-f]+"" , ""0123456789abcdef"" , ""0123456789abcdef"" ) ; assert_true_regexp ( ""[0-9a-f]+"" , ""xyz0123456789xyz"" , ""0123456789"" ) ; assert_true_regexp ( ""a[\\\\s\\\\S]b"" , ""ab"" , ""ab"" ) ; assert_true_regexp ( ""a[\\\\d\\\\D]b"" , ""a1b"" , ""a1b"" ) ; assert_false_regexp ( ""[x-z]+"" , ""abc"" ) ; assert_true_regexp ( ""a[-]?c"" , ""ac"" , ""ac"" ) ; assert_true_regexp ( ""a[-b]"" , ""a-"" , ""a-"" ) ; assert_true_regexp ( ""a[-b]"" , ""ab"" , ""ab"" ) ; assert_true_regexp ( ""a[b-]"" , ""a-"" , ""a-"" ) ; assert_true_regexp ( ""a[b-]"" , ""ab"" , ""ab"" ) ; assert_true_regexp ( ""[a-c-e]"" , ""b"" , ""b"" ) ; assert_true_regexp ( ""[a-c-e]"" , ""-"" , ""-"" ) ; assert_false_regexp ( ""[a-c-e]"" , ""d"" ) ; assert_regexp_syntax_error ( ""[b-a]"" ) ; assert_regexp_syntax_error ( ""(abc"" ) ; assert_regexp_syntax_error ( ""abc)"" ) ; assert_regexp_syntax_error ( ""a[]b"" ) ; assert_regexp_syntax_error ( ""a\\\\"" ) ; assert_true_regexp ( ""a[\\\\-b]"" , ""a-"" , ""a-"" ) ; assert_true_regexp ( ""a[\\\\-b]"" , ""ab"" , ""ab"" ) ; assert_regexp_syntax_error ( ""a[\\\\"" ) ; assert_true_regexp ( ""a]"" , ""a]"" , ""a]"" ) ; assert_true_regexp ( ""a[]]b"" , ""a]b"" , ""a]b"" ) ; assert_true_regexp ( ""a[\\\\]]b"" , ""a]b"" , ""a]b"" ) ; assert_true_regexp ( ""a[^bc]d"" , ""aed"" , ""aed"" ) ; assert_false_regexp ( ""a[^bc]d"" , ""abd"" ) ; assert_true_regexp ( ""a[^-b]c"" , ""adc"" , ""adc"" ) ; assert_false_regexp ( ""a[^-b]c"" , ""a-c"" ) ; assert_false_regexp ( ""a[^]b]c"" , ""a]c"" ) ; assert_true_regexp ( ""a[^]b]c"" , ""adc"" , ""adc"" ) ; assert_true_regexp ( ""[^ab]*"" , ""cde"" , ""cde"" ) ; assert_regexp_syntax_error ( "")("" ) ; assert_true_regexp ( ""a\\\\sb"" , ""ab"" , ""ab"" ) ; assert_true_regexp ( ""a\\\\sb"" , ""a\\tb"" , ""a\\tb"" ) ; assert_true_regexp ( ""a\\\\sb"" , ""a\\rb"" , ""a\\rb"" ) ; assert_true_regexp ( ""a\\\\sb"" , ""a\\nb"" , ""a\\nb"" ) ; assert_true_regexp ( ""a\\\\sb"" , ""a\\vb"" , ""a\\vb"" ) ; assert_true_regexp ( ""a\\\\sb"" , ""a\\fb"" , ""a\\fb"" ) ; assert_false_regexp ( ""a\\\\Sb"" , ""ab"" ) ; assert_false_regexp ( ""a\\\\Sb"" , ""a\\tb"" ) ; assert_false_regexp ( ""a\\\\Sb"" , ""a\\rb"" ) ; assert_false_regexp ( ""a\\\\Sb"" , ""a\\nb"" ) ; assert_false_regexp ( ""a\\\\Sb"" , ""a\\vb"" ) ; assert_false_regexp ( ""a\\\\Sb"" , ""a\\fb"" ) ; assert_true_regexp ( ""\\\\n\\\\r\\\\t\\\\f\\\\a"" , ""\\n\\r\\t\\f\\a"" , ""\\n\\r\\t\\f\\a"" ) ; assert_true_regexp ( ""[\\\\n][\\\\r][\\\\t][\\\\f][\\\\a]"" , ""\\n\\r\\t\\f\\a"" , ""\\n\\r\\t\\f\\a"" ) ; assert_true_regexp ( ""\\\\x01\\\\x02\\\\x03"" , ""\\x01\\x02\\x03"" , ""\\x01\\x02\\x03"" ) ; assert_true_regexp ( ""[\\\\x01-\\\\x03]+"" , ""\\x01\\x02\\x03"" , ""\\x01\\x02\\x03"" ) ; assert_false_regexp ( ""[\\\\x00-\\\\x02]+"" , ""\\x03\\x04\\x05"" ) ; assert_true_regexp ( ""[\\\\x5D]"" , ""]"" , ""]"" ) ; assert_true_regexp ( ""[\\\\0x5A-\\\\x5D]"" , ""\\x5B"" , ""\\x5B"" ) ; assert_true_regexp ( ""[\\\\x5D-\\\\x5F]"" , ""\\x5E"" , ""\\x5E"" ) ; assert_true_regexp ( ""[\\\\x5C-\\\\x5F]"" , ""\\x5E"" , ""\\x5E"" ) ; assert_true_regexp ( ""[\\\\x5D-\\\\x5F]"" , ""\\x5E"" , ""\\x5E"" ) ; assert_true_regexp ( ""a\\\\wc"" , ""abc"" , ""abc"" ) ; assert_true_regexp ( ""a\\\\wc"" , ""a_c"" , ""a_c"" ) ; assert_true_regexp ( ""a\\\\wc"" , ""a0c"" , ""a0c"" ) ; assert_false_regexp ( ""a\\\\wc"" , ""a*c"" ) ; assert_true_regexp ( ""\\\\w+"" , ""--ab_cd0123--"" , ""ab_cd0123"" ) ; assert_true_regexp ( ""[\\\\w]+"" , ""--ab_cd0123--"" , ""ab_cd0123"" ) ; assert_true_regexp ( ""\\\\D+"" , ""1234abc5678"" , ""abc"" ) ; assert_true_regexp ( ""[\\\\d]+"" , ""0123456789"" , ""0123456789"" ) ; assert_true_regexp ( ""[\\\\D]+"" , ""1234abc5678"" , ""abc"" ) ; assert_true_regexp ( ""[\\\\da-fA-F]+"" , ""123abc"" , ""123abc"" ) ; assert_false_regexp ( ""^(ab|cd)e"" , ""abcde"" ) ; assert_true_regexp ( ""(abc|)ef"" , ""abcdef"" , ""ef"" ) ; assert_true_regexp ( ""(abc|)ef"" , ""abcef"" , ""abcef"" ) ; assert_true_regexp ( ""\\\\babc"" , ""abc"" , ""abc"" ) ; assert_true_regexp ( ""abc\\\\b"" , ""abc"" , ""abc"" ) ; assert_false_regexp ( ""\\\\babc"" , ""1abc"" ) ; assert_false_regexp ( ""abc\\\\b"" , ""abc1"" ) ; assert_true_regexp ( ""abc\\\\s\\\\b"" , ""abcx"" , ""abc"" ) ; assert_false_regexp ( ""abc\\\\s\\\\b"" , ""abc"" ) ; assert_true_regexp ( ""\\\\babc\\\\b"" , ""abc"" , ""abc"" ) ; assert_true_regexp ( ""\\\\b\\\\w\\\\w\\\\w\\\\b"" , ""abc"" , ""abc"" ) ; assert_true_regexp ( ""\\\\w\\\\w\\\\w\\\\b"" , ""abcd"" , ""bcd"" ) ; assert_true_regexp ( ""\\\\b\\\\w\\\\w\\\\w"" , ""abcd"" , ""abc"" ) ; assert_false_regexp ( ""\\\\b\\\\w\\\\w\\\\w\\\\b"" , ""abcd"" ) ; assert_false_regexp ( ""\\\\Babc"" , ""abc"" ) ; assert_false_regexp ( ""abc\\\\B"" , ""abc"" ) ; assert_true_regexp ( ""\\\\Babc"" , ""1abc"" , ""abc"" ) ; assert_true_regexp ( ""abc\\\\B"" , ""abc1"" , ""abc"" ) ; assert_false_regexp ( ""abc\\\\s\\\\B"" , ""abcx"" ) ; assert_true_regexp ( ""abc\\\\s\\\\B"" , ""abc"" , ""abc"" ) ; assert_true_regexp ( ""\\\\w\\\\w\\\\w\\\\B"" , ""abcd"" , ""abc"" ) ; assert_true_regexp ( ""\\\\B\\\\w\\\\w\\\\w"" , ""abcd"" , ""bcd"" ) ; assert_false_regexp ( ""\\\\B\\\\w\\\\w\\\\w\\\\B"" , ""abcd"" ) ; assert_regexp_syntax_error ( ""(|abc)ef"" ) ; assert_true_regexp ( ""((a)(b)c)(d)"" , ""abcd"" , ""abcd"" ) ; assert_true_regexp ( ""(a|b)c*d"" , ""abcd"" , ""bcd"" ) ; assert_true_regexp ( ""(ab|ab*)bc"" , ""abc"" , ""abc"" ) ; assert_true_regexp ( ""a([bc]*)c*"" , ""abc"" , ""abc"" ) ; assert_true_regexp ( ""a([bc]*)c*"" , ""ac"" , ""ac"" ) ; assert_true_regexp ( ""a([bc]*)c*"" , ""a"" , ""a"" ) ; assert_true_regexp ( ""a([bc]*)(c*d)"" , ""abcd"" , ""abcd"" ) ; assert_true_regexp ( ""a([bc]+)(c*d)"" , ""abcd"" , ""abcd"" ) ; assert_true_regexp ( ""a([bc]*)(c+d)"" , ""abcd"" , ""abcd"" ) ; assert_true_regexp ( ""a[bcd]*dcdcde"" , ""adcdcde"" , ""adcdcde"" ) ; assert_false_regexp ( ""a[bcd]+dcdcde"" , ""adcdcde"" ) ; assert_true_regexp ( ""\\\\((.*),(.*)\\\\)"" , ""(a,b)"" , ""(a,b)"" ) ; assert_true_regexp ( ""abc|123$"" , ""abcx"" , ""abc"" ) ; assert_false_regexp ( ""abc|123$"" , ""123x"" ) ; assert_true_regexp ( ""abc|^123"" , ""123"" , ""123"" ) ; assert_false_regexp ( ""abc|^123"" , ""x123"" ) ; assert_true_regexp ( ""^abc$"" , ""abc"" , ""abc"" ) ; assert_false_regexp ( ""^abc$"" , ""abcc"" ) ; assert_true_regexp ( ""^abc"" , ""abcc"" , ""abc"" ) ; assert_false_regexp ( ""^abc$"" , ""aabc"" ) ; assert_true_regexp ( ""abc$"" , ""aabc"" , ""abc"" ) ; assert_true_regexp ( ""^a(bc+|b[eh])g|.h$"" , ""abhg"" , ""abhg"" ) ; assert_true_regexp ( ""(bc+d$|ef*g.|h?i(j|k))"" , ""effgz"" , ""effgz"" ) ; assert_true_regexp ( ""(bc+d$|ef*g.|h?i(j|k))"" , ""ij"" , ""ij"" ) ; assert_false_regexp ( ""(bc+d$|ef*g.|h?i(j|k))"" , ""effg"" ) ; assert_false_regexp ( ""(bc+d$|ef*g.|h?i(j|k))"" , ""bcdd"" ) ; assert_true_regexp ( ""(bc+d$|ef*g.|h?i(j|k))"" , ""reffgz"" , ""effgz"" ) ; assert_true_regexp ( ""whatever|x.x"" , ""xyx"" , ""xyx"" ) ; } "," ""xyx"" ) ; assert_regexp_syntax_error ( ""\\\\x0"" ) ; assert_regexp_syntax_error ( ""\\\\x"" ) ; assert_regexp_syntax_error ( ""\\\\xxy"" ) ; ",VirusTotal@yara/3119b232c9c453c98d8fa8b6ae4e37ba18117cd4,CVE-2016-10210,https://github.com/VirusTotal/yara/commit/3119b232c9c453c98d8fa8b6ae4e37ba18117cd4,2017-04-03T05:59Z 509,CWE-000,"CWE-000 int hashbin_delete ( hashbin_t * hashbin , FREE_FUNC free_func ) { irda_queue_t * queue ; unsigned long flags = 0 ; int i ; IRDA_ASSERT ( hashbin != NULL , return - 1 ; ) ; IRDA_ASSERT ( hashbin -> magic == HB_MAGIC , return - 1 ; ) ; if ( hashbin -> hb_type & HB_LOCK ) { spin_lock_irqsave_nested ( & hashbin -> hb_spinlock , flags , hashbin_lock_depth ++ ) ; } for ( i = 0 ; i < HASHBIN_SIZE ; i ++ ) { queue = dequeue_first ( ( irda_queue_t * * ) & hashbin -> hb_queue [ i ] ) ; while ( queue ) { if ( free_func ) ( * free_func ) ( queue ) ; queue = dequeue_first ( ( irda_queue_t * * ) & hashbin -> hb_queue [ i ] ) ; } } hashbin -> hb_current = NULL ; hashbin -> magic = ~ HB_MAGIC ; if ( hashbin -> hb_type & HB_LOCK ) { spin_unlock_irqrestore ( & hashbin -> hb_spinlock , flags ) ; # ifdef CONFIG_LOCKDEP hashbin_lock_depth -- ; # endif } kfree ( hashbin ) ; return 0 ; } "," & HB_LOCK ) spin_lock_irqsave ( & hashbin -> hb_spinlock , flags ) ; for ( i ++ ) { while ( 1 ) { ] ) ; if ( ! queue ) break ; if ( free_func ( free_func ) { if ( hashbin -> hb_type & HB_LOCK ) spin_unlock_irqrestore ( & hashbin -> hb_spinlock , flags ) ; free_func ( queue ) ; if ( hashbin -> hb_type & HB_LOCK ) spin_lock_irqsave ( & hashbin -> hb_spinlock , flags ) ; } } } hashbin & HB_LOCK ) spin_unlock_irqrestore ( & flags ) ; kfree ( hashbin ",torvalds@linux/4c03b862b12f980456f9de92db6d508a4999b788,CVE-2017-6348,https://github.com/torvalds/linux/commit/4c03b862b12f980456f9de92db6d508a4999b788,2017-03-01T20:59Z 510,CWE-269,"CWE-269 static int do_remount ( struct path * path , int flags , int mnt_flags , void * data ) { int err ; struct super_block * sb = path -> mnt -> mnt_sb ; struct mount * mnt = real_mount ( path -> mnt ) ; if ( ! check_mnt ( mnt ) ) return - EINVAL ; if ( path -> dentry != path -> mnt -> mnt_root ) return - EINVAL ; if ( ( mnt -> mnt . mnt_flags & MNT_LOCK_READONLY ) && ! ( mnt_flags & MNT_READONLY ) ) { return - EPERM ; } err = security_sb_remount ( sb , data ) ; if ( err ) return err ; down_write ( & sb -> s_umount ) ; if ( flags & MS_BIND ) err = change_mount_flags ( path -> mnt , flags ) ; else if ( ! capable ( CAP_SYS_ADMIN ) ) err = - EPERM ; else err = do_remount_sb ( sb , flags , data , 0 ) ; if ( ! err ) { lock_mount_hash ( ) ; mnt_flags |= mnt -> mnt . mnt_flags & ~ MNT_USER_SETTABLE_MASK ; mnt -> mnt . mnt_flags = mnt_flags ; touch_mnt_namespace ( mnt -> mnt_ns ) ; unlock_mount_hash ( ) ; } up_write ( & sb -> s_umount ) ; return err ; } "," EPERM ; } if ( ( mnt -> mnt . mnt_flags & MNT_LOCK_NODEV ) && ! ( mnt_flags & MNT_NODEV ) ) { return - EPERM ; } if ( ( mnt -> mnt . mnt_flags & MNT_LOCK_NOSUID ) && ! ( mnt_flags & MNT_NOSUID ) ) { return - EPERM ; } if ( ( mnt -> mnt . mnt_flags & MNT_LOCK_NOEXEC ) && ! ( mnt_flags & MNT_NOEXEC ) ) { return - EPERM ; } if ( ( mnt -> mnt . mnt_flags & MNT_LOCK_ATIME ) && ( ( mnt -> mnt . mnt_flags & MNT_ATIME_MASK ) != ( mnt_flags & MNT_ATIME_MASK ) ) ) { return - EPERM ; } ",torvalds@linux/9566d6742852c527bf5af38af5cbb878dad75705,CVE-2014-5207,https://github.com/torvalds/linux/commit/9566d6742852c527bf5af38af5cbb878dad75705,2014-08-18T11:15Z 511,CWE-20,"CWE-20 static int packet_recvmsg ( struct kiocb * iocb , struct socket * sock , struct msghdr * msg , size_t len , int flags ) { struct sock * sk = sock -> sk ; struct sk_buff * skb ; int copied , err ; struct sockaddr_ll * sll ; int vnet_hdr_len = 0 ; err = - EINVAL ; if ( flags & ~ ( MSG_PEEK | MSG_DONTWAIT | MSG_TRUNC | MSG_CMSG_COMPAT | MSG_ERRQUEUE ) ) goto out ; # if 0 if ( pkt_sk ( sk ) -> ifindex < 0 ) return - ENODEV ; # endif if ( flags & MSG_ERRQUEUE ) { err = sock_recv_errqueue ( sk , msg , len , SOL_PACKET , PACKET_TX_TIMESTAMP ) ; goto out ; } skb = skb_recv_datagram ( sk , flags , flags & MSG_DONTWAIT , & err ) ; if ( skb == NULL ) goto out ; if ( pkt_sk ( sk ) -> has_vnet_hdr ) { struct virtio_net_hdr vnet_hdr = { 0 } ; err = - EINVAL ; vnet_hdr_len = sizeof ( vnet_hdr ) ; if ( len < vnet_hdr_len ) goto out_free ; len -= vnet_hdr_len ; if ( skb_is_gso ( skb ) ) { struct skb_shared_info * sinfo = skb_shinfo ( skb ) ; vnet_hdr . hdr_len = skb_headlen ( skb ) ; vnet_hdr . gso_size = sinfo -> gso_size ; if ( sinfo -> gso_type & SKB_GSO_TCPV4 ) vnet_hdr . gso_type = VIRTIO_NET_HDR_GSO_TCPV4 ; else if ( sinfo -> gso_type & SKB_GSO_TCPV6 ) vnet_hdr . gso_type = VIRTIO_NET_HDR_GSO_TCPV6 ; else if ( sinfo -> gso_type & SKB_GSO_UDP ) vnet_hdr . gso_type = VIRTIO_NET_HDR_GSO_UDP ; else if ( sinfo -> gso_type & SKB_GSO_FCOE ) goto out_free ; else BUG ( ) ; if ( sinfo -> gso_type & SKB_GSO_TCP_ECN ) vnet_hdr . gso_type |= VIRTIO_NET_HDR_GSO_ECN ; } else vnet_hdr . gso_type = VIRTIO_NET_HDR_GSO_NONE ; if ( skb -> ip_summed == CHECKSUM_PARTIAL ) { vnet_hdr . flags = VIRTIO_NET_HDR_F_NEEDS_CSUM ; vnet_hdr . csum_start = skb_checksum_start_offset ( skb ) ; vnet_hdr . csum_offset = skb -> csum_offset ; } else if ( skb -> ip_summed == CHECKSUM_UNNECESSARY ) { vnet_hdr . flags = VIRTIO_NET_HDR_F_DATA_VALID ; } err = memcpy_toiovec ( msg -> msg_iov , ( void * ) & vnet_hdr , vnet_hdr_len ) ; if ( err < 0 ) goto out_free ; } sll = & PACKET_SKB_CB ( skb ) -> sa . ll ; if ( sock -> type == SOCK_PACKET ) msg -> msg_namelen = sizeof ( struct sockaddr_pkt ) ; else msg -> msg_namelen = sll -> sll_halen + offsetof ( struct sockaddr_ll , sll_addr ) ; copied = skb -> len ; if ( copied > len ) { copied = len ; msg -> msg_flags |= MSG_TRUNC ; } err = skb_copy_datagram_iovec ( skb , 0 , msg -> msg_iov , copied ) ; if ( err ) goto out_free ; sock_recv_ts_and_drops ( msg , sk , skb ) ; if ( msg -> msg_name ) memcpy ( msg -> msg_name , & PACKET_SKB_CB ( skb ) -> sa , msg -> msg_namelen ) ; if ( pkt_sk ( sk ) -> auxdata ) { struct tpacket_auxdata aux ; aux . tp_status = TP_STATUS_USER ; if ( skb -> ip_summed == CHECKSUM_PARTIAL ) aux . tp_status |= TP_STATUS_CSUMNOTREADY ; aux . tp_len = PACKET_SKB_CB ( skb ) -> origlen ; aux . tp_snaplen = skb -> len ; aux . tp_mac = 0 ; aux . tp_net = skb_network_offset ( skb ) ; if ( vlan_tx_tag_present ( skb ) ) { aux . tp_vlan_tci = vlan_tx_tag_get ( skb ) ; aux . tp_status |= TP_STATUS_VLAN_VALID ; } else { aux . tp_vlan_tci = 0 ; } aux . tp_padding = 0 ; put_cmsg ( msg , SOL_PACKET , PACKET_AUXDATA , sizeof ( aux ) , & aux ) ; } err = vnet_hdr_len + ( ( flags & MSG_TRUNC ) ? skb -> len : copied ) ; out_free : skb_free_datagram ( sk , skb ) ; out : return err ; } "," copied , err ; int vnet_hdr_len out_free ; } copied = skb -> len ; if ( copied > len ) { copied = len ; msg -> msg_flags |= MSG_TRUNC ; } err = skb_copy_datagram_iovec ( skb , 0 , msg -> msg_iov , copied ) ; if ( err ) goto out_free ; sock_recv_ts_and_drops ( msg , sk , skb ) ; if ( msg -> msg_name ) { if ( sock == SOCK_PACKET ) { sockaddr_pkt ) ; } else { struct sockaddr_ll * sll = & PACKET_SKB_CB ( skb ) -> sa . ll ; msg -> msg_namelen sll_addr ) ; } memcpy ( msg -> msg -> msg_name , & PACKET_SKB_CB msg_namelen ) ; } ",torvalds@linux/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,CVE-2013-7271,https://github.com/torvalds/linux/commit/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,2014-01-06T16:55Z 512,CWE-190,"CWE-190 int ras_validate ( jas_stream_t * in ) { uchar buf [ RAS_MAGICLEN ] ; int i ; int n ; uint_fast32_t magic ; assert ( JAS_STREAM_MAXPUTBACK >= RAS_MAGICLEN ) ; if ( ( n = jas_stream_read ( in , buf , RAS_MAGICLEN ) ) < 0 ) { return - 1 ; } for ( i = n - 1 ; i >= 0 ; -- i ) { if ( jas_stream_ungetc ( in , buf [ i ] ) == EOF ) { return - 1 ; } } if ( n < RAS_MAGICLEN ) { return - 1 ; } magic = ( JAS_CAST ( uint_fast32_t , buf [ 0 ] ) << 24 ) | ( JAS_CAST ( uint_fast32_t , buf [ 1 ] ) << 16 ) | ( JAS_CAST ( uint_fast32_t , buf [ 2 ] ) << 8 ) | buf [ 3 ] ; if ( magic != RAS_MAGIC ) { return - 1 ; } return 0 ; } "," in ) { jas_uchar buf [ RAS_MAGICLEN ",mdadams@jasper/d42b2388f7f8e0332c846675133acea151fc557a,CVE-2016-9557,https://github.com/mdadams/jasper/commit/d42b2388f7f8e0332c846675133acea151fc557a,2017-03-23T18:59Z 513,CWE-000,"CWE-000 static int clie_5_attach ( struct usb_serial * serial ) { struct usb_serial_port * port ; unsigned int pipe ; int j ; if ( serial -> num_ports < 2 ) return - 1 ; port = serial -> port [ 0 ] ; port -> bulk_out_endpointAddress = serial -> port [ 1 ] -> bulk_out_endpointAddress ; pipe = usb_sndbulkpipe ( serial -> dev , port -> bulk_out_endpointAddress ) ; for ( j = 0 ; j < ARRAY_SIZE ( port -> write_urbs ) ; ++ j ) port -> write_urbs [ j ] -> pipe = pipe ; return 0 ; } "," ( serial -> num_bulk_out < 2 ) < 2 ) { dev_err ( & serial -> interface -> dev , ""missingbulkoutendpoints\\n"" ) ; return - ENODEV ; } port = serial ",torvalds@linux/cb3232138e37129e88240a98a1d2aba2187ff57c,CVE-2015-7566,https://github.com/torvalds/linux/commit/cb3232138e37129e88240a98a1d2aba2187ff57c,2016-02-08T03:59Z 514,CWE-119,"CWE-119 int WriteRiffHeader ( FILE * outfile , WavpackContext * wpc , int64_t total_samples , int qmode ) { int do_rf64 = 0 , write_junk = 1 ; ChunkHeader ds64hdr , datahdr , fmthdr ; RiffChunkHeader riffhdr ; DS64Chunk ds64_chunk ; JunkChunk junkchunk ; WaveHeader wavhdr ; uint32_t bcount ; int64_t total_data_bytes , total_riff_bytes ; int num_channels = WavpackGetNumChannels ( wpc ) ; int32_t channel_mask = WavpackGetChannelMask ( wpc ) ; int32_t sample_rate = WavpackGetSampleRate ( wpc ) ; int bytes_per_sample = WavpackGetBytesPerSample ( wpc ) ; int bits_per_sample = WavpackGetBitsPerSample ( wpc ) ; int format = WavpackGetFloatNormExp ( wpc ) ? 3 : 1 ; int wavhdrsize = 16 ; if ( format == 3 && WavpackGetFloatNormExp ( wpc ) != 127 ) { error_line ( ""can\'tcreatevalidRIFFwavheaderfornon-normalizedfloatingdata!"" ) ; return FALSE ; } if ( total_samples == - 1 ) total_samples = 0x7ffff000 / ( bytes_per_sample * num_channels ) ; total_data_bytes = total_samples * bytes_per_sample * num_channels ; if ( total_data_bytes > 0xff000000 ) { if ( debug_logging_mode ) error_line ( ""total_data_bytes=%lld,sorf64"" , total_data_bytes ) ; write_junk = 0 ; do_rf64 = 1 ; } else if ( debug_logging_mode ) error_line ( ""total_data_bytes=%lld,soriff"" , total_data_bytes ) ; CLEAR ( wavhdr ) ; wavhdr . FormatTag = format ; wavhdr . NumChannels = num_channels ; wavhdr . SampleRate = sample_rate ; wavhdr . BytesPerSecond = sample_rate * num_channels * bytes_per_sample ; wavhdr . BlockAlign = bytes_per_sample * num_channels ; wavhdr . BitsPerSample = bits_per_sample ; if ( num_channels > 2 || channel_mask != 0x5 - num_channels ) { wavhdrsize = sizeof ( wavhdr ) ; wavhdr . cbSize = 22 ; wavhdr . ValidBitsPerSample = bits_per_sample ; wavhdr . SubFormat = format ; wavhdr . ChannelMask = channel_mask ; wavhdr . FormatTag = 0xfffe ; wavhdr . BitsPerSample = bytes_per_sample * 8 ; wavhdr . GUID [ 4 ] = 0x10 ; wavhdr . GUID [ 6 ] = 0x80 ; wavhdr . GUID [ 9 ] = 0xaa ; wavhdr . GUID [ 11 ] = 0x38 ; wavhdr . GUID [ 12 ] = 0x9b ; wavhdr . GUID [ 13 ] = 0x71 ; } strncpy ( riffhdr . ckID , do_rf64 ? ""RF64"" : ""RIFF"" , sizeof ( riffhdr . ckID ) ) ; strncpy ( riffhdr . formType , ""WAVE"" , sizeof ( riffhdr . formType ) ) ; total_riff_bytes = sizeof ( riffhdr ) + wavhdrsize + sizeof ( datahdr ) + ( ( total_data_bytes + 1 ) & ~ ( int64_t ) 1 ) ; if ( do_rf64 ) total_riff_bytes += sizeof ( ds64hdr ) + sizeof ( ds64_chunk ) ; if ( write_junk ) total_riff_bytes += sizeof ( junkchunk ) ; strncpy ( fmthdr . ckID , ""fmt"" , sizeof ( fmthdr . ckID ) ) ; strncpy ( datahdr . ckID , ""data"" , sizeof ( datahdr . ckID ) ) ; fmthdr . ckSize = wavhdrsize ; if ( write_junk ) { CLEAR ( junkchunk ) ; strncpy ( junkchunk . ckID , ""junk"" , sizeof ( junkchunk . ckID ) ) ; junkchunk . ckSize = sizeof ( junkchunk ) - 8 ; WavpackNativeToLittleEndian ( & junkchunk , ChunkHeaderFormat ) ; } if ( do_rf64 ) { strncpy ( ds64hdr . ckID , ""ds64"" , sizeof ( ds64hdr . ckID ) ) ; ds64hdr . ckSize = sizeof ( ds64_chunk ) ; CLEAR ( ds64_chunk ) ; ds64_chunk . riffSize64 = total_riff_bytes ; ds64_chunk . dataSize64 = total_data_bytes ; ds64_chunk . sampleCount64 = total_samples ; riffhdr . ckSize = ( uint32_t ) - 1 ; datahdr . ckSize = ( uint32_t ) - 1 ; WavpackNativeToLittleEndian ( & ds64hdr , ChunkHeaderFormat ) ; WavpackNativeToLittleEndian ( & ds64_chunk , DS64ChunkFormat ) ; } else { riffhdr . ckSize = ( uint32_t ) total_riff_bytes ; datahdr . ckSize = ( uint32_t ) total_data_bytes ; } WavpackNativeToLittleEndian ( & riffhdr , ChunkHeaderFormat ) ; WavpackNativeToLittleEndian ( & fmthdr , ChunkHeaderFormat ) ; WavpackNativeToLittleEndian ( & wavhdr , WaveHeaderFormat ) ; WavpackNativeToLittleEndian ( & datahdr , ChunkHeaderFormat ) ; if ( ! DoWriteFile ( outfile , & riffhdr , sizeof ( riffhdr ) , & bcount ) || bcount != sizeof ( riffhdr ) || ( do_rf64 && ( ! DoWriteFile ( outfile , & ds64hdr , sizeof ( ds64hdr ) , & bcount ) || bcount != sizeof ( ds64hdr ) ) ) || ( do_rf64 && ( ! DoWriteFile ( outfile , & ds64_chunk , sizeof ( ds64_chunk ) , & bcount ) || bcount != sizeof ( ds64_chunk ) ) ) || ( write_junk && ( ! DoWriteFile ( outfile , & junkchunk , sizeof ( junkchunk ) , & bcount ) || bcount != sizeof ( junkchunk ) ) ) || ! DoWriteFile ( outfile , & fmthdr , sizeof ( fmthdr ) , & bcount ) || bcount != sizeof ( fmthdr ) || ! DoWriteFile ( outfile , & wavhdr , wavhdrsize , & bcount ) || bcount != wavhdrsize || ! DoWriteFile ( outfile , & datahdr , sizeof ( datahdr ) , & bcount ) || bcount != sizeof ( datahdr ) ) { error_line ( ""can\'twrite.WAVdata,diskprobablyfull!"" ) ; return FALSE ; } return TRUE ; } "," write_junk = 1 , table_length = 0 ; DS64Chunk ds64_chunk ; CS64Chunk cs64_chunk ds64_chunk ) ; total_riff_bytes += table_length * sizeof ( CS64Chunk ) ; if ( write_junk ) total_riff_bytes += sizeof ( junkchunk ( ds64_chunk ) + ( table_length * sizeof ( CS64Chunk ) ) sampleCount64 = total_samples ; ds64_chunk . tableLength = table_length total_data_bytes ; } if ( table_length ) { strncpy ( cs64_chunk . ckID , ""dmmy"" , sizeof ( cs64_chunk . ckID ) ) ; cs64_chunk . chunkSize64 = 12345678 ; WavpackNativeToLittleEndian ( & cs64_chunk , CS64ChunkFormat ) ; } ) ) ) ) { error_line ( ""can\'twrite.WAVdata,diskprobablyfull!"" ) ; return FALSE ; } while ( table_length -- ) if ( ! DoWriteFile ( outfile , & cs64_chunk , sizeof ( cs64_chunk ) , & bcount ) || bcount != sizeof ( cs64_chunk ) ) { error_line ( ""can\'twrite.WAVdata,diskprobablyfull!"" ) ; return FALSE ; } if ( ( write_junk && ",dbry@WavPack/d5bf76b5a88d044a1be1d5656698e3ba737167e5,CVE-2018-6767,https://github.com/dbry/WavPack/commit/d5bf76b5a88d044a1be1d5656698e3ba737167e5,2018-02-06T22:29Z 515,CWE-20,"CWE-20 static int ___sys_recvmsg ( struct socket * sock , struct msghdr __user * msg , struct msghdr * msg_sys , unsigned int flags , int nosec ) { struct compat_msghdr __user * msg_compat = ( struct compat_msghdr __user * ) msg ; struct iovec iovstack [ UIO_FASTIOV ] ; struct iovec * iov = iovstack ; unsigned long cmsg_ptr ; int err , total_len , len ; struct sockaddr_storage addr ; struct sockaddr __user * uaddr ; int __user * uaddr_len ; if ( MSG_CMSG_COMPAT & flags ) { if ( get_compat_msghdr ( msg_sys , msg_compat ) ) return - EFAULT ; } else { err = copy_msghdr_from_user ( msg_sys , msg ) ; if ( err ) return err ; } if ( msg_sys -> msg_iovlen > UIO_FASTIOV ) { err = - EMSGSIZE ; if ( msg_sys -> msg_iovlen > UIO_MAXIOV ) goto out ; err = - ENOMEM ; iov = kmalloc ( msg_sys -> msg_iovlen * sizeof ( struct iovec ) , GFP_KERNEL ) ; if ( ! iov ) goto out ; } uaddr = ( __force void __user * ) msg_sys -> msg_name ; uaddr_len = COMPAT_NAMELEN ( msg ) ; if ( MSG_CMSG_COMPAT & flags ) { err = verify_compat_iovec ( msg_sys , iov , & addr , VERIFY_WRITE ) ; } else err = verify_iovec ( msg_sys , iov , & addr , VERIFY_WRITE ) ; if ( err < 0 ) goto out_freeiov ; total_len = err ; cmsg_ptr = ( unsigned long ) msg_sys -> msg_control ; msg_sys -> msg_flags = flags & ( MSG_CMSG_CLOEXEC | MSG_CMSG_COMPAT ) ; if ( sock -> file -> f_flags & O_NONBLOCK ) flags |= MSG_DONTWAIT ; err = ( nosec ? sock_recvmsg_nosec : sock_recvmsg ) ( sock , msg_sys , total_len , flags ) ; if ( err < 0 ) goto out_freeiov ; len = err ; if ( uaddr != NULL ) { err = move_addr_to_user ( & addr , msg_sys -> msg_namelen , uaddr , uaddr_len ) ; if ( err < 0 ) goto out_freeiov ; } err = __put_user ( ( msg_sys -> msg_flags & ~ MSG_CMSG_COMPAT ) , COMPAT_FLAGS ( msg ) ) ; if ( err ) goto out_freeiov ; if ( MSG_CMSG_COMPAT & flags ) err = __put_user ( ( unsigned long ) msg_sys -> msg_control - cmsg_ptr , & msg_compat -> msg_controllen ) ; else err = __put_user ( ( unsigned long ) msg_sys -> msg_control - cmsg_ptr , & msg -> msg_controllen ) ; if ( err ) goto out_freeiov ; err = len ; out_freeiov : if ( iov != iovstack ) kfree ( iov ) ; out : return err ; } "," & flags ) err = verify_compat_iovec VERIFY_WRITE ) ; else err = | MSG_CMSG_COMPAT ) ; msg_sys -> msg_namelen = 0 ",torvalds@linux/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,CVE-2013-7271,https://github.com/torvalds/linux/commit/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,2014-01-06T16:55Z 516,CWE-119,"CWE-119 static int gfs2_bmap_alloc ( struct inode * inode , const sector_t lblock , struct buffer_head * bh_map , struct metapath * mp , const unsigned int sheight , const unsigned int height , const unsigned int maxlen ) { struct gfs2_inode * ip = GFS2_I ( inode ) ; struct gfs2_sbd * sdp = GFS2_SB ( inode ) ; struct buffer_head * dibh = mp -> mp_bh [ 0 ] ; u64 bn , dblock = 0 ; unsigned n , i , blks , alloced = 0 , iblks = 0 , branch_start = 0 ; unsigned dblks = 0 ; unsigned ptrs_per_blk ; const unsigned end_of_metadata = height - 1 ; int eob = 0 ; enum alloc_state state ; __be64 * ptr ; __be64 zero_bn = 0 ; BUG_ON ( sheight < 1 ) ; BUG_ON ( dibh == NULL ) ; gfs2_trans_add_bh ( ip -> i_gl , dibh , 1 ) ; if ( height == sheight ) { struct buffer_head * bh ; ptr = metapointer ( end_of_metadata , mp ) ; bh = mp -> mp_bh [ end_of_metadata ] ; dblks = gfs2_extent_length ( bh -> b_data , bh -> b_size , ptr , maxlen , & eob ) ; BUG_ON ( dblks < 1 ) ; state = ALLOC_DATA ; } else { ptrs_per_blk = height > 1 ? sdp -> sd_inptrs : sdp -> sd_diptrs ; dblks = min ( maxlen , ptrs_per_blk - mp -> mp_list [ end_of_metadata ] ) ; if ( height == ip -> i_height ) { iblks = height - sheight ; state = ALLOC_GROW_DEPTH ; } else { state = ALLOC_GROW_HEIGHT ; iblks = height - ip -> i_height ; branch_start = metapath_branch_start ( mp ) ; iblks += ( height - branch_start ) ; } } blks = dblks + iblks ; i = sheight ; do { int error ; n = blks - alloced ; error = gfs2_alloc_block ( ip , & bn , & n ) ; if ( error ) return error ; alloced += n ; if ( state != ALLOC_DATA || gfs2_is_jdata ( ip ) ) gfs2_trans_add_unrevoke ( sdp , bn , n ) ; switch ( state ) { case ALLOC_GROW_HEIGHT : if ( i == 1 ) { ptr = ( __be64 * ) ( dibh -> b_data + sizeof ( struct gfs2_dinode ) ) ; zero_bn = * ptr ; } for ( ; i - 1 < height - ip -> i_height && n > 0 ; i ++ , n -- ) gfs2_indirect_init ( mp , ip -> i_gl , i , 0 , bn ++ ) ; if ( i - 1 == height - ip -> i_height ) { i -- ; gfs2_buffer_copy_tail ( mp -> mp_bh [ i ] , sizeof ( struct gfs2_meta_header ) , dibh , sizeof ( struct gfs2_dinode ) ) ; gfs2_buffer_clear_tail ( dibh , sizeof ( struct gfs2_dinode ) + sizeof ( __be64 ) ) ; ptr = ( __be64 * ) ( mp -> mp_bh [ i ] -> b_data + sizeof ( struct gfs2_meta_header ) ) ; * ptr = zero_bn ; state = ALLOC_GROW_DEPTH ; for ( i = branch_start ; i < height ; i ++ ) { if ( mp -> mp_bh [ i ] == NULL ) break ; brelse ( mp -> mp_bh [ i ] ) ; mp -> mp_bh [ i ] = NULL ; } i = branch_start ; } if ( n == 0 ) break ; case ALLOC_GROW_DEPTH : if ( i > 1 && i < height ) gfs2_trans_add_bh ( ip -> i_gl , mp -> mp_bh [ i - 1 ] , 1 ) ; for ( ; i < height && n > 0 ; i ++ , n -- ) gfs2_indirect_init ( mp , ip -> i_gl , i , mp -> mp_list [ i - 1 ] , bn ++ ) ; if ( i == height ) state = ALLOC_DATA ; if ( n == 0 ) break ; case ALLOC_DATA : BUG_ON ( n > dblks ) ; BUG_ON ( mp -> mp_bh [ end_of_metadata ] == NULL ) ; gfs2_trans_add_bh ( ip -> i_gl , mp -> mp_bh [ end_of_metadata ] , 1 ) ; dblks = n ; ptr = metapointer ( end_of_metadata , mp ) ; dblock = bn ; while ( n -- > 0 ) * ptr ++ = cpu_to_be64 ( bn ++ ) ; break ; } } while ( ( state != ALLOC_DATA ) || ! dblock ) ; ip -> i_height = height ; gfs2_add_inode_blocks ( & ip -> i_inode , alloced ) ; gfs2_dinode_out ( ip , mp -> mp_bh [ 0 ] -> b_data ) ; map_bh ( bh_map , inode -> i_sb , dblock ) ; bh_map -> b_size = dblks << inode -> i_blkbits ; set_buffer_new ( bh_map ) ; return 0 ; } "," ) ; struct super_block * sb = sdp -> sd_vfs ; struct height - 1 ; int ret ++ ) ; if ( buffer_zeronew ( bh_map ) ) { ret = sb_issue_zeroout ( sb , dblock , dblks , GFP_NOFS ) ; if ( ret ) { fs_err ( sdp , ""Failedtozerodatabuffers\\n"" ) ; clear_buffer_zeronew ( bh_map ) ; } } ",torvalds@linux/64dd153c83743af81f20924c6343652d731eeecb,CVE-2011-4098,https://github.com/torvalds/linux/commit/64dd153c83743af81f20924c6343652d731eeecb,2013-06-08T13:05Z 517,CWE-119,"CWE-119 static void show_stream_config ( struct stream_state * stream , struct VpxEncoderConfig * global , struct VpxInputContext * input ) { # define SHOW ( field ) fprintf ( stderr , ""%-28s=%d\\n"" , # field , stream -> config . cfg . field ) if ( stream -> index == 0 ) { fprintf ( stderr , ""Codec:%s\\n"" , vpx_codec_iface_name ( global -> codec -> interface ( ) ) ) ; fprintf ( stderr , ""Sourcefile:%sFormat:%s\\n"" , input -> filename , input -> use_i420 ? ""I420"" : ""YV12"" ) ; } if ( stream -> next || stream -> index ) fprintf ( stderr , ""\\nStreamIndex:%d\\n"" , stream -> index ) ; fprintf ( stderr , ""Destinationfile:%s\\n"" , stream -> config . out_fn ) ; fprintf ( stderr , ""Encoderparameters:\\n"" ) ; SHOW ( g_usage ) ; SHOW ( g_threads ) ; SHOW ( g_profile ) ; SHOW ( g_w ) ; SHOW ( g_h ) ; SHOW ( g_timebase . num ) ; SHOW ( g_timebase . den ) ; SHOW ( g_error_resilient ) ; SHOW ( g_pass ) ; SHOW ( g_lag_in_frames ) ; SHOW ( rc_dropframe_thresh ) ; SHOW ( rc_resize_allowed ) ; SHOW ( rc_resize_up_thresh ) ; SHOW ( rc_resize_down_thresh ) ; SHOW ( rc_end_usage ) ; SHOW ( rc_target_bitrate ) ; SHOW ( rc_min_quantizer ) ; SHOW ( rc_max_quantizer ) ; SHOW ( rc_undershoot_pct ) ; SHOW ( rc_overshoot_pct ) ; SHOW ( rc_buf_sz ) ; SHOW ( rc_buf_initial_sz ) ; SHOW ( rc_buf_optimal_sz ) ; SHOW ( rc_2pass_vbr_bias_pct ) ; SHOW ( rc_2pass_vbr_minsection_pct ) ; SHOW ( rc_2pass_vbr_maxsection_pct ) ; SHOW ( kf_mode ) ; SHOW ( kf_min_dist ) ; SHOW ( kf_max_dist ) ; } "," -> codec -> codec_interface ( ) ) ) ; fprintf ( stderr , ""Sourcefile:%sFileType:%sFormat:%s\\n"" , input -> filename -> filename , file_type_to_string ( input -> file_type ) , image_format_to_string ( input -> fmt ) ) ; } ; SHOW ( g_bit_depth ) ; SHOW ( g_input_bit_depth ) ; SHOW ( SHOW ( rc_resize_allowed ) ; SHOW ( rc_scaled_width ) ; SHOW ( rc_scaled_height ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 518,CWE-787,"CWE-787 BOOL nsc_process_message ( NSC_CONTEXT * context , UINT16 bpp , UINT32 width , UINT32 height , const BYTE * data , UINT32 length , BYTE * pDstData , UINT32 DstFormat , UINT32 nDstStride , UINT32 nXDst , UINT32 nYDst , UINT32 nWidth , UINT32 nHeight , UINT32 flip ) { wStream * s ; BOOL ret ; s = Stream_New ( ( BYTE * ) data , length ) ; if ( ! s ) return FALSE ; if ( nDstStride == 0 ) nDstStride = nWidth * GetBytesPerPixel ( DstFormat ) ; switch ( bpp ) { case 32 : context -> format = PIXEL_FORMAT_BGRA32 ; break ; case 24 : context -> format = PIXEL_FORMAT_BGR24 ; break ; case 16 : context -> format = PIXEL_FORMAT_BGR16 ; break ; case 8 : context -> format = PIXEL_FORMAT_RGB8 ; break ; case 4 : context -> format = PIXEL_FORMAT_A4 ; break ; default : Stream_Free ( s , TRUE ) ; return FALSE ; } context -> width = width ; context -> height = height ; ret = nsc_context_initialize ( context , s ) ; Stream_Free ( s , FALSE ) ; if ( ! ret ) return FALSE ; PROFILER_ENTER ( context -> priv -> prof_nsc_rle_decompress_data ) nsc_rle_decompress_data ( context ) ; PROFILER_EXIT ( context -> priv -> prof_nsc_rle_decompress_data ) PROFILER_ENTER ( context -> priv -> prof_nsc_decode ) context -> decode ( context ) ; PROFILER_EXIT ( context -> priv -> prof_nsc_decode ) if ( ! freerdp_image_copy ( pDstData , DstFormat , nDstStride , nXDst , nYDst , width , height , context -> BitmapData , PIXEL_FORMAT_BGRA32 , 0 , 0 , 0 , NULL , flip ) ) return FALSE ; return TRUE ; } "," return FALSE ; { BOOL rc ; -> prof_nsc_rle_decompress_data ) rc = -> prof_nsc_rle_decompress_data ) if ( ! rc ) return FALSE ; } { BOOL rc ; -> prof_nsc_decode ) rc = -> prof_nsc_decode ) if ( ! rc ) return FALSE ; } ",FreeRDP@FreeRDP/d1112c279bd1a327e8e4d0b5f371458bf2579659,CVE-2018-8788,https://github.com/FreeRDP/FreeRDP/commit/d1112c279bd1a327e8e4d0b5f371458bf2579659,2018-11-29T18:29Z 519,CWE-399,"CWE-399 xmlAttrPtr xsltAttrListTemplateProcess ( xsltTransformContextPtr ctxt , xmlNodePtr target , xmlAttrPtr attrs ) { xmlAttrPtr attr , copy , last ; xmlNodePtr oldInsert , text ; xmlNsPtr origNs = NULL , copyNs = NULL ; const xmlChar * value ; xmlChar * valueAVT ; if ( ( ctxt == NULL ) || ( target == NULL ) || ( attrs == NULL ) ) return ( NULL ) ; oldInsert = ctxt -> insert ; ctxt -> insert = target ; if ( target -> properties ) { last = target -> properties ; while ( last -> next != NULL ) last = last -> next ; } else { last = NULL ; } attr = attrs ; do { # ifdef XSLT_REFACTORED if ( attr -> psvi == xsltXSLTAttrMarker ) { goto next_attribute ; } # else if ( ( attr -> ns != NULL ) && xmlStrEqual ( attr -> ns -> href , XSLT_NAMESPACE ) ) { goto next_attribute ; } # endif if ( attr -> children != NULL ) { if ( ( attr -> children -> type != XML_TEXT_NODE ) || ( attr -> children -> next != NULL ) ) { xsltTransformError ( ctxt , NULL , attr -> parent , ""Internalerror:Thechildrenofanattributenodeofa"" ""literalresultelementarenotintheexpectedform.\\n"" ) ; goto error ; } value = attr -> children -> content ; if ( value == NULL ) value = xmlDictLookup ( ctxt -> dict , BAD_CAST """" , 0 ) ; } else value = xmlDictLookup ( ctxt -> dict , BAD_CAST """" , 0 ) ; copy = xmlNewDocProp ( target -> doc , attr -> name , NULL ) ; if ( copy == NULL ) { if ( attr -> ns ) { xsltTransformError ( ctxt , NULL , attr -> parent , ""Internalerror:Failedtocreateattribute\'{%s}%s\'.\\n"" , attr -> ns -> href , attr -> name ) ; } else { xsltTransformError ( ctxt , NULL , attr -> parent , ""Internalerror:Failedtocreateattribute\'%s\'.\\n"" , attr -> name ) ; } goto error ; } copy -> parent = target ; if ( last == NULL ) { target -> properties = copy ; last = copy ; } else { last -> next = copy ; copy -> prev = last ; last = copy ; } if ( attr -> ns != origNs ) { origNs = attr -> ns ; if ( attr -> ns != NULL ) { # ifdef XSLT_REFACTORED copyNs = xsltGetSpecialNamespace ( ctxt , attr -> parent , attr -> ns -> href , attr -> ns -> prefix , target ) ; # else copyNs = xsltGetNamespace ( ctxt , attr -> parent , attr -> ns , target ) ; # endif if ( copyNs == NULL ) goto error ; } else copyNs = NULL ; } copy -> ns = copyNs ; text = xmlNewText ( NULL ) ; if ( text != NULL ) { copy -> last = copy -> children = text ; text -> parent = ( xmlNodePtr ) copy ; text -> doc = copy -> doc ; if ( attr -> psvi != NULL ) { valueAVT = xsltEvalAVT ( ctxt , attr -> psvi , attr -> parent ) ; if ( valueAVT == NULL ) { if ( attr -> ns ) { xsltTransformError ( ctxt , NULL , attr -> parent , ""Internalerror:FailedtoevaluatetheAVT"" ""ofattribute\'{%s}%s\'.\\n"" , attr -> ns -> href , attr -> name ) ; } else { xsltTransformError ( ctxt , NULL , attr -> parent , ""Internalerror:FailedtoevaluatetheAVT"" ""ofattribute\'%s\'.\\n"" , attr -> name ) ; } text -> content = xmlStrdup ( BAD_CAST """" ) ; goto error ; } else { text -> content = valueAVT ; } } else if ( ( ctxt -> internalized ) && ( target -> doc != NULL ) && ( target -> doc -> dict == ctxt -> dict ) ) { text -> content = ( xmlChar * ) value ; } else { text -> content = xmlStrdup ( value ) ; } if ( ( copy != NULL ) && ( text != NULL ) && ( xmlIsID ( copy -> doc , copy -> parent , copy ) ) ) xmlAddID ( NULL , copy -> doc , text -> content , copy ) ; } next_attribute : attr = attr -> next ; } while ( attr != NULL ) ; attr = attrs ; do { # ifdef XSLT_REFACTORED if ( ( attr -> psvi == xsltXSLTAttrMarker ) && xmlStrEqual ( attr -> name , ( const xmlChar * ) ""use-attribute-sets"" ) ) { xsltApplyAttributeSet ( ctxt , ctxt -> node , ( xmlNodePtr ) attr , NULL ) ; } # else if ( ( attr -> ns != NULL ) && xmlStrEqual ( attr -> name , ( const xmlChar * ) ""use-attribute-sets"" ) && xmlStrEqual ( attr -> ns -> href , XSLT_NAMESPACE ) ) { xsltApplyAttributeSet ( ctxt , ctxt -> node , ( xmlNodePtr ) attr , NULL ) ; } # endif attr = attr -> next ; } while ( attr != NULL ) ; ctxt -> insert = oldInsert ; return ( target -> properties ) ; error : ctxt -> insert = oldInsert ; return ( NULL ) ; } "," -> dict ) && xmlDictOwns ( ctxt -> dict , value ) ",chromium@chromium/2de493f4a1d48952e09230a0c32ccbd45db973b2,CVE-2012-2893,https://github.com/chromium/chromium/commit/2de493f4a1d48952e09230a0c32ccbd45db973b2,2012-09-26T10:56Z 520,CWE-269,"CWE-269 static void skel ( const char * homedir , uid_t u , gid_t g ) { char * fname ; if ( ! arg_shell_none && ( strcmp ( cfg . shell , ""/usr/bin/zsh"" ) == 0 || strcmp ( cfg . shell , ""/bin/zsh"" ) == 0 ) ) { if ( asprintf ( & fname , ""%s/.zshrc"" , homedir ) == - 1 ) errExit ( ""asprintf"" ) ; struct stat s ; if ( stat ( fname , & s ) == 0 ) return ; if ( stat ( ""/etc/skel/.zshrc"" , & s ) == 0 ) { if ( copy_file ( ""/etc/skel/.zshrc"" , fname , u , g , 0644 ) == 0 ) { fs_logger ( ""clone/etc/skel/.zshrc"" ) ; } } else { FILE * fp = fopen ( fname , ""w"" ) ; if ( fp ) { fprintf ( fp , ""\\n"" ) ; SET_PERMS_STREAM ( fp , u , g , S_IRUSR | S_IWUSR ) ; fclose ( fp ) ; fs_logger2 ( ""touch"" , fname ) ; } } free ( fname ) ; } else if ( ! arg_shell_none && strcmp ( cfg . shell , ""/bin/csh"" ) == 0 ) { if ( asprintf ( & fname , ""%s/.cshrc"" , homedir ) == - 1 ) errExit ( ""asprintf"" ) ; struct stat s ; if ( stat ( fname , & s ) == 0 ) return ; if ( stat ( ""/etc/skel/.cshrc"" , & s ) == 0 ) { if ( copy_file ( ""/etc/skel/.cshrc"" , fname , u , g , 0644 ) == 0 ) { fs_logger ( ""clone/etc/skel/.cshrc"" ) ; } } else { FILE * fp = fopen ( fname , ""w"" ) ; if ( fp ) { fprintf ( fp , ""\\n"" ) ; SET_PERMS_STREAM ( fp , u , g , S_IRUSR | S_IWUSR ) ; fclose ( fp ) ; fs_logger2 ( ""touch"" , fname ) ; } } free ( fname ) ; } else { if ( asprintf ( & fname , ""%s/.bashrc"" , homedir ) == - 1 ) errExit ( ""asprintf"" ) ; struct stat s ; if ( stat ( fname , & s ) == 0 ) return ; if ( stat ( ""/etc/skel/.bashrc"" , & s ) == 0 ) { if ( copy_file ( ""/etc/skel/.bashrc"" , fname , u , g , 0644 ) == 0 ) { fs_logger ( ""clone/etc/skel/.bashrc"" ) ; } } free ( fname ) ; } } "," 0 ) { copy_file ( ""/etc/skel/.zshrc"" , 0644 ) ; fs_logger ( ""clone/etc/skel/.zshrc"" ) ; } else { touch_file_as_user ( fname , u , g , 0644 ) ; fs_logger2 fname ) ; } free ( 0 ) { copy_file ( ""/etc/skel/.cshrc"" , 0644 ) ; fs_logger ( ""clone/etc/skel/.cshrc"" ) ; } else { touch_file_as_user ( fname , u , g , 0644 ) ; fs_logger2 fname ) ; } free ( 0 ) { copy_file ( ""/etc/skel/.bashrc"" , 0644 ) ; fs_logger ( ""clone/etc/skel/.bashrc"" ) ; } free ( fname ",netblue30@firejail/b8a4ff9775318ca5e679183884a6a63f3da8f863,CVE-2017-5940,https://github.com/netblue30/firejail/commit/b8a4ff9775318ca5e679183884a6a63f3da8f863,2017-02-09T18:59Z 521,CWE-189,"CWE-189 static int decode_getacl ( struct xdr_stream * xdr , struct rpc_rqst * req , size_t * acl_len ) { __be32 * savep ; uint32_t attrlen , bitmap [ 3 ] = { 0 } ; struct kvec * iov = req -> rq_rcv_buf . head ; int status ; * acl_len = 0 ; if ( ( status = decode_op_hdr ( xdr , OP_GETATTR ) ) != 0 ) goto out ; if ( ( status = decode_attr_bitmap ( xdr , bitmap ) ) != 0 ) goto out ; if ( ( status = decode_attr_length ( xdr , & attrlen , & savep ) ) != 0 ) goto out ; if ( unlikely ( bitmap [ 0 ] & ( FATTR4_WORD0_ACL - 1U ) ) ) return - EIO ; if ( likely ( bitmap [ 0 ] & FATTR4_WORD0_ACL ) ) { size_t hdrlen ; u32 recvd ; hdrlen = ( u8 * ) xdr -> p - ( u8 * ) iov -> iov_base ; recvd = req -> rq_rcv_buf . len - hdrlen ; if ( attrlen > recvd ) { dprintk ( ""NFS:servercheatingingetattr"" ""aclreply:attrlen%u>recvd%u\\n"" , attrlen , recvd ) ; return - EINVAL ; } xdr_read_pages ( xdr , attrlen ) ; * acl_len = attrlen ; } else status = - EOPNOTSUPP ; out : return status ; } "," * req , struct nfs_getaclres * res ) { __be32 __be32 * savep , * bm_p int status ; res -> acl_len = 0 ) goto out ; bm_p = xdr -> p u32 recvd ; xdr -> p = bm_p ; res -> acl_data_offset = be32_to_cpup ( bm_p ) + 2 ; res -> acl_data_offset <<= 2 ; iov -> iov_base ; attrlen += res -> acl_data_offset recvd ) { if ( res -> acl_flags & NFS4_ACL_LEN_REQUEST ) { res -> acl_len = attrlen ; goto out ; } dprintk ( ""NFS:aclreply:attrlen%u>recvd%u\\n"" , attrlen , attrlen ) ; res -> acl_len = attrlen ",torvalds@linux/bf118a342f10dafe44b14451a1392c3254629a1f,CVE-2011-4131,https://github.com/torvalds/linux/commit/bf118a342f10dafe44b14451a1392c3254629a1f,2012-05-17T11:00Z 522,CWE-119,"CWE-119 static int _FVMenuClose ( FontView * fv ) { int i ; SplineFont * sf = fv -> b . cidmaster ? fv -> b . cidmaster : fv -> b . sf ; if ( ! SFCloseAllInstrs ( fv -> b . sf ) ) return ( false ) ; if ( fv -> b . nextsame != NULL || fv -> b . sf -> fv != & fv -> b ) { } else if ( SFAnyChanged ( sf ) ) { i = AskChanged ( fv -> b . sf ) ; if ( i == 2 ) return ( false ) ; if ( i == 0 && ! _FVMenuSave ( fv ) ) return ( false ) ; else SFClearAutoSave ( sf ) ; } _FVCloseWindows ( fv ) ; if ( sf -> filename != NULL ) RecentFilesRemember ( sf -> filename ) ; else if ( sf -> origname != NULL ) RecentFilesRemember ( sf -> origname ) ; GDrawDestroyWindow ( fv -> gw ) ; return ( true ) ; } "," b ) { } else if ( warn_script_unsaved && fv -> script_unsaved && AskScriptChanged ( ) == 2 ) { return false ; ",fontforge@fontforge/626f751752875a0ddd74b9e217b6f4828713573c,CVE-2019-15785,https://github.com/fontforge/fontforge/commit/626f751752875a0ddd74b9e217b6f4828713573c,2019-08-29T13:15Z 523,CWE-617,"CWE-617 static void pci_populate_msixcap ( struct msixcap * msixcap , int msgnum , int barnum , uint32_t msix_tab_size ) { assert ( msix_tab_size % 4096 == 0 ) ; bzero ( msixcap , sizeof ( struct msixcap ) ) ; msixcap -> capid = PCIY_MSIX ; msixcap -> msgctrl = msgnum - 1 ; msixcap -> table_info = barnum & PCIM_MSIX_BIR_MASK ; msixcap -> pba_info = msix_tab_size | ( barnum & PCIM_MSIX_BIR_MASK ) ; } "," msix_tab_size ) { bzero ( msixcap ",projectacrn@acrn-hypervisor/2b3dedfb9ba13f15887f22b935d373f36c9a59fa,CVE-2019-18844,https://github.com/projectacrn/acrn-hypervisor/commit/2b3dedfb9ba13f15887f22b935d373f36c9a59fa,2019-11-13T20:15Z 524,CWE-189,"CWE-189 static int sgi_timer_set ( struct k_itimer * timr , int flags , struct itimerspec * new_setting , struct itimerspec * old_setting ) { unsigned long when , period , irqflags ; int err = 0 ; cnodeid_t nodeid ; struct mmtimer * base ; struct rb_node * n ; if ( old_setting ) sgi_timer_get ( timr , old_setting ) ; sgi_timer_del ( timr ) ; when = timespec_to_ns ( new_setting -> it_value ) ; period = timespec_to_ns ( new_setting -> it_interval ) ; if ( when == 0 ) return 0 ; base = kmalloc ( sizeof ( struct mmtimer ) , GFP_KERNEL ) ; if ( base == NULL ) return - ENOMEM ; if ( flags & TIMER_ABSTIME ) { struct timespec n ; unsigned long now ; getnstimeofday ( & n ) ; now = timespec_to_ns ( n ) ; if ( when > now ) when -= now ; else when = 0 ; } when = ( when + sgi_clock_period - 1 ) / sgi_clock_period + rtc_time ( ) ; period = ( period + sgi_clock_period - 1 ) / sgi_clock_period ; preempt_disable ( ) ; nodeid = cpu_to_node ( smp_processor_id ( ) ) ; spin_lock_irqsave ( & timers [ nodeid ] . lock , irqflags ) ; base -> timer = timr ; base -> cpu = smp_processor_id ( ) ; timr -> it . mmtimer . clock = TIMER_SET ; timr -> it . mmtimer . node = nodeid ; timr -> it . mmtimer . incr = period ; timr -> it . mmtimer . expires = when ; n = timers [ nodeid ] . next ; mmtimer_add_list ( base ) ; if ( timers [ nodeid ] . next == n ) { spin_unlock_irqrestore ( & timers [ nodeid ] . lock , irqflags ) ; preempt_enable ( ) ; return err ; } if ( n ) mmtimer_disable_int ( cnodeid_to_nasid ( nodeid ) , COMPARATOR ) ; mmtimer_set_next_timer ( nodeid ) ; spin_unlock_irqrestore ( & timers [ nodeid ] . lock , irqflags ) ; preempt_enable ( ) ; return err ; } "," = timespec_to_ns ( & = timespec_to_ns ( & = timespec_to_ns ( & ",torvalds@linux/f8bd2258e2d520dff28c855658bd24bdafb5102d,CVE-2011-3209,https://github.com/torvalds/linux/commit/f8bd2258e2d520dff28c855658bd24bdafb5102d,2012-10-03T11:02Z 525,CWE-674,"CWE-674 static void Sp_search ( js_State * J ) { js_Regexp * re ; const char * text ; Resub m ; text = checkstring ( J , 0 ) ; if ( js_isregexp ( J , 1 ) ) js_copy ( J , 1 ) ; else if ( js_isundefined ( J , 1 ) ) js_newregexp ( J , """" , 0 ) ; else js_newregexp ( J , js_tostring ( J , 1 ) , 0 ) ; re = js_toregexp ( J , - 1 ) ; if ( ! js_regexec ( re -> prog , text , & m , 0 ) ) js_pushnumber ( J , js_utfptrtoidx ( text , m . sub [ 0 ] . sp ) ) ; else js_pushnumber ( J , - 1 ) ; } "," if ( ! js_doregexec ( J , re -> prog ",ccxvii@mujs/00d4606c3baf813b7b1c176823b2729bf51002a2,CVE-2019-11413,https://github.com/ccxvii/mujs/commit/00d4606c3baf813b7b1c176823b2729bf51002a2,2019-04-22T11:29Z 526,CWE-119,"CWE-119 static void intern_rec ( value * dest ) { unsigned int code ; tag_t tag ; mlsize_t size , len , ofs_ind ; value v ; asize_t ofs ; header_t header ; unsigned char digest [ 16 ] ; struct custom_operations * ops ; char * codeptr ; struct intern_item * sp ; sp = intern_stack ; ReadItems ( dest , 1 ) ; while ( sp != intern_stack ) { dest = sp -> dest ; switch ( sp -> op ) { case OFreshOID : if ( Int_val ( Field ( ( value ) dest , 1 ) ) >= 0 ) caml_set_oo_id ( ( value ) dest ) ; sp -- ; break ; case OShift : * dest += sp -> arg ; sp -- ; break ; case OReadItems : sp -> dest ++ ; if ( -- ( sp -> arg ) == 0 ) sp -- ; code = read8u ( ) ; if ( code >= PREFIX_SMALL_INT ) { if ( code >= PREFIX_SMALL_BLOCK ) { tag = code & 0xF ; size = ( code >> 4 ) & 0x7 ; read_block : if ( size == 0 ) { v = Atom ( tag ) ; } else { v = Val_hp ( intern_dest ) ; if ( intern_obj_table != NULL ) intern_obj_table [ obj_counter ++ ] = v ; * intern_dest = Make_header ( size , tag , intern_color ) ; intern_dest += 1 + size ; if ( tag == Object_tag ) { Assert ( size >= 2 ) ; ReadItems ( & Field ( v , 2 ) , size - 2 ) ; PushItem ( ) ; sp -> op = OFreshOID ; sp -> dest = ( value * ) v ; sp -> arg = 1 ; ReadItems ( & Field ( v , 0 ) , 2 ) ; } else ReadItems ( & Field ( v , 0 ) , size ) ; } } else { v = Val_int ( code & 0x3F ) ; } } else { if ( code >= PREFIX_SMALL_STRING ) { len = ( code & 0x1F ) ; read_string : size = ( len + sizeof ( value ) ) / sizeof ( value ) ; v = Val_hp ( intern_dest ) ; if ( intern_obj_table != NULL ) intern_obj_table [ obj_counter ++ ] = v ; * intern_dest = Make_header ( size , String_tag , intern_color ) ; intern_dest += 1 + size ; Field ( v , size - 1 ) = 0 ; ofs_ind = Bsize_wsize ( size ) - 1 ; Byte ( v , ofs_ind ) = ofs_ind - len ; readblock ( String_val ( v ) , len ) ; } else { switch ( code ) { case CODE_INT8 : v = Val_long ( read8s ( ) ) ; break ; case CODE_INT16 : v = Val_long ( read16s ( ) ) ; break ; case CODE_INT32 : v = Val_long ( read32s ( ) ) ; break ; case CODE_INT64 : # ifdef ARCH_SIXTYFOUR v = Val_long ( read64s ( ) ) ; break ; # else intern_cleanup ( ) ; caml_failwith ( ""input_value:integertoolarge"" ) ; break ; # endif case CODE_SHARED8 : ofs = read8u ( ) ; read_shared : Assert ( ofs > 0 ) ; Assert ( ofs <= obj_counter ) ; Assert ( intern_obj_table != NULL ) ; v = intern_obj_table [ obj_counter - ofs ] ; break ; case CODE_SHARED16 : ofs = read16u ( ) ; goto read_shared ; case CODE_SHARED32 : ofs = read32u ( ) ; goto read_shared ; case CODE_BLOCK32 : header = ( header_t ) read32u ( ) ; tag = Tag_hd ( header ) ; size = Wosize_hd ( header ) ; goto read_block ; case CODE_BLOCK64 : # ifdef ARCH_SIXTYFOUR header = ( header_t ) read64s ( ) ; tag = Tag_hd ( header ) ; size = Wosize_hd ( header ) ; goto read_block ; # else intern_cleanup ( ) ; caml_failwith ( ""input_value:datablocktoolarge"" ) ; break ; # endif case CODE_STRING8 : len = read8u ( ) ; goto read_string ; case CODE_STRING32 : len = read32u ( ) ; goto read_string ; case CODE_DOUBLE_LITTLE : case CODE_DOUBLE_BIG : v = Val_hp ( intern_dest ) ; if ( intern_obj_table != NULL ) intern_obj_table [ obj_counter ++ ] = v ; * intern_dest = Make_header ( Double_wosize , Double_tag , intern_color ) ; intern_dest += 1 + Double_wosize ; readfloat ( ( double * ) v , code ) ; break ; case CODE_DOUBLE_ARRAY8_LITTLE : case CODE_DOUBLE_ARRAY8_BIG : len = read8u ( ) ; read_double_array : size = len * Double_wosize ; v = Val_hp ( intern_dest ) ; if ( intern_obj_table != NULL ) intern_obj_table [ obj_counter ++ ] = v ; * intern_dest = Make_header ( size , Double_array_tag , intern_color ) ; intern_dest += 1 + size ; readfloats ( ( double * ) v , len , code ) ; break ; case CODE_DOUBLE_ARRAY32_LITTLE : case CODE_DOUBLE_ARRAY32_BIG : len = read32u ( ) ; goto read_double_array ; case CODE_CODEPOINTER : ofs = read32u ( ) ; readblock ( digest , 16 ) ; codeptr = intern_resolve_code_pointer ( digest , ofs ) ; if ( codeptr != NULL ) { v = ( value ) codeptr ; } else { value * function_placeholder = caml_named_value ( ""Debugger.function_placeholder"" ) ; if ( function_placeholder != NULL ) { v = * function_placeholder ; } else { intern_cleanup ( ) ; intern_bad_code_pointer ( digest ) ; } } break ; case CODE_INFIXPOINTER : ofs = read32u ( ) ; PushItem ( ) ; sp -> dest = dest ; sp -> op = OShift ; sp -> arg = ofs ; ReadItems ( dest , 1 ) ; continue ; case CODE_CUSTOM : ops = caml_find_custom_operations ( ( char * ) intern_src ) ; if ( ops == NULL ) { intern_cleanup ( ) ; caml_failwith ( ""input_value:unknowncustomblockidentifier"" ) ; } while ( * intern_src ++ != 0 ) ; size = ops -> deserialize ( ( void * ) ( intern_dest + 2 ) ) ; size = 1 + ( size + sizeof ( value ) - 1 ) / sizeof ( value ) ; v = Val_hp ( intern_dest ) ; if ( intern_obj_table != NULL ) intern_obj_table [ obj_counter ++ ] = v ; * intern_dest = Make_header ( size , Custom_tag , intern_color ) ; Custom_ops_val ( v ) = ops ; if ( ops -> finalize != NULL && Is_young ( v ) ) { if ( caml_finalize_table . ptr >= caml_finalize_table . limit ) { CAMLassert ( caml_finalize_table . ptr == caml_finalize_table . limit ) ; caml_realloc_ref_table ( & caml_finalize_table ) ; } * caml_finalize_table . ptr ++ = ( value * ) v ; } intern_dest += 1 + size ; break ; default : intern_cleanup ( ) ; caml_failwith ( ""input_value:ill-formedmessage"" ) ; } } } * dest = v ; break ; default : Assert ( 0 ) ; } } intern_free_stack ( ) ; } "," : if ( Long_val ( Field ( ",ocaml@ocaml/659615c7b100a89eafe6253e7a5b9d84d0e8df74,CVE-2015-8869,https://github.com/ocaml/ocaml/commit/659615c7b100a89eafe6253e7a5b9d84d0e8df74,2016-06-13T19:59Z 527,CWE-770,"CWE-770 int server_partial_file_request ( struct httpd * env , struct client * clt , char * path , struct stat * st , char * range_str ) { struct server_config * srv_conf = clt -> clt_srv_conf ; struct http_descriptor * resp = clt -> clt_descresp ; struct http_descriptor * desc = clt -> clt_descreq ; struct media_type * media , multipart_media ; struct range * range ; struct evbuffer * evb = NULL ; size_t content_length ; int code = 500 , fd = - 1 , i , nranges , ret ; uint32_t boundary ; char content_range [ 64 ] ; const char * errstr = NULL ; if ( desc -> http_method != HTTP_METHOD_GET ) return server_file_request ( env , clt , path , st ) ; if ( ( range = parse_range ( range_str , st -> st_size , & nranges ) ) == NULL ) { code = 416 ; ( void ) snprintf ( content_range , sizeof ( content_range ) , ""bytes*/%lld"" , st -> st_size ) ; errstr = content_range ; goto abort ; } if ( ( fd = open ( path , O_RDONLY ) ) == - 1 ) goto abort ; media = media_find_config ( env , srv_conf , path ) ; if ( ( evb = evbuffer_new ( ) ) == NULL ) { errstr = ""failedtoallocatefilebuffer"" ; goto abort ; } if ( nranges == 1 ) { ( void ) snprintf ( content_range , sizeof ( content_range ) , ""bytes%lld-%lld/%lld"" , range -> start , range -> end , st -> st_size ) ; if ( kv_add ( & resp -> http_headers , ""Content-Range"" , content_range ) == NULL ) goto abort ; content_length = range -> end - range -> start + 1 ; if ( buffer_add_range ( fd , evb , range ) == 0 ) goto abort ; } else { content_length = 0 ; boundary = arc4random ( ) ; while ( nranges -- ) { if ( ( i = evbuffer_add_printf ( evb , ""\\r\\n--%ud\\r\\n"" , boundary ) ) == - 1 ) goto abort ; content_length += i ; if ( ( i = evbuffer_add_printf ( evb , ""Content-Type:%s/%s\\r\\n"" , media -> media_type , media -> media_subtype ) ) == - 1 ) goto abort ; content_length += i ; if ( ( i = evbuffer_add_printf ( evb , ""Content-Range:bytes%lld-%lld/%lld\\r\\n\\r\\n"" , range -> start , range -> end , st -> st_size ) ) == - 1 ) goto abort ; content_length += i ; if ( buffer_add_range ( fd , evb , range ) == 0 ) goto abort ; content_length += range -> end - range -> start + 1 ; range ++ ; } if ( ( i = evbuffer_add_printf ( evb , ""\\r\\n--%ud--\\r\\n"" , boundary ) ) == - 1 ) goto abort ; content_length += i ; ( void ) strlcpy ( multipart_media . media_type , ""multipart"" , sizeof ( multipart_media . media_type ) ) ; ( void ) snprintf ( multipart_media . media_subtype , sizeof ( multipart_media . media_subtype ) , ""byteranges;boundary=%ud"" , boundary ) ; media = & multipart_media ; } close ( fd ) ; fd = - 1 ; ret = server_response_http ( clt , 206 , media , content_length , MINIMUM ( time ( NULL ) , st -> st_mtim . tv_sec ) ) ; switch ( ret ) { case - 1 : goto fail ; case 0 : goto done ; default : break ; } if ( server_bufferevent_write_buffer ( clt , evb ) == - 1 ) goto fail ; bufferevent_enable ( clt -> clt_bev , EV_READ | EV_WRITE ) ; if ( clt -> clt_persist ) clt -> clt_toread = TOREAD_HTTP_HEADER ; else clt -> clt_toread = TOREAD_HTTP_NONE ; clt -> clt_done = 0 ; done : evbuffer_free ( evb ) ; server_reset_http ( clt ) ; return ( 0 ) ; fail : bufferevent_disable ( clt -> clt_bev , EV_READ | EV_WRITE ) ; bufferevent_free ( clt -> clt_bev ) ; clt -> clt_bev = NULL ; abort : if ( evb != NULL ) evbuffer_free ( evb ) ; if ( fd != - 1 ) close ( fd ) ; if ( errstr == NULL ) errstr = strerror ( errno ) ; server_abort_http ( clt , code , errstr ) ; return ( - 1 ) ; } "," multipart_media ; struct range_data * r = & clt -> clt_ranges ; struct range * range ; size_t content_length ; size_t content_length = 0 nranges , ret ; char content_range if ( ( nranges = parse_ranges ( clt , range_str , st st -> st_size ) ) < 1 ) { code path ) ; r -> range_media = media ; if ( nranges 1 ) { range = & r -> range [ 0 ] ; goto abort ; range = & r -> range [ 0 ] ; content_length += range -> end + 1 ; } else { } else { arc4random_buf ( & clt -> clt_boundary , sizeof ( clt -> clt_boundary ) ) ; for ( i = 0 ; i < nranges ; i ++ ) { range = & r -> range [ i ] ; if ( ( ret = snprintf ( NULL , 0 , ""\\r\\n--%llu\\r\\n"" ""Content-Type:%s/%s\\r\\n"" ""Content-Range:bytes%lld-%lld/%lld\\r\\n\\r\\n"" , clt -> clt_boundary , media -> media_type , media -> media_subtype , range -> start , range -> end , st -> st_size ) ) < 0 ) goto abort ; content_length += ret + range -> end + 1 ; } if ( if ( ( ret = snprintf ( NULL , 0 , ""\\r\\n--%llu--\\r\\n"" , clt -> clt_boundary ) ) < 0 ) goto abort ; content_length += ret ; ( void media_subtype ) , ""byteranges;boundary=%llu"" , clt -> clt_boundary ) ; media multipart_media ; } r -> range_toread = TOREAD_HTTP_RANGE ; ret = case 0 : close ( fd ) ; break ; } clt -> clt_fd = fd ; if ( clt -> clt_srvbev != NULL ) bufferevent_free ( clt -> clt_srvbev ) ; clt -> clt_srvbev_throttled = 0 ; clt -> clt_srvbev = bufferevent_new ( clt -> clt_fd , server_read_httprange , server_write , server_file_error , clt ) ; if ( clt -> clt_srvbev == NULL ) { errstr = ""failedtoallocatefilebufferevent"" ; goto fail ; goto fail ; } bufferevent_setwatermark ( clt -> clt_srvbev , EV_READ , 0 , clt -> clt_sndbufsiz ) ; bufferevent_settimeout ( clt -> clt_srvbev , srv_conf -> timeout . tv_sec , srv_conf -> timeout . tv_sec ) ; bufferevent_enable ( clt -> clt_srvbev , EV_READ ) ; bufferevent_disable ( clt -> clt_bev , EV_READ ) ; done : server_reset_http ( clt ) ; return ( 0 ) ; fail : bufferevent_disable ( clt -> EV_WRITE ) ; bufferevent_free ( clt ; abort : if ( fd ",openbsd@src/142cfc82b932bc211218fbd7bdda8c7ce83f19df,CVE-2017-5850,https://github.com/openbsd/src/commit/142cfc82b932bc211218fbd7bdda8c7ce83f19df,2017-03-27T15:59Z 528,CWE-20,"CWE-20 bool_t ksz8851IrqHandler ( NetInterface * interface ) { bool_t flag ; size_t n ; uint16_t ier ; uint16_t isr ; flag = FALSE ; ier = ksz8851ReadReg ( interface , KSZ8851_REG_IER ) ; ksz8851WriteReg ( interface , KSZ8851_REG_IER , 0 ) ; isr = ksz8851ReadReg ( interface , KSZ8851_REG_ISR ) ; if ( ( isr & ISR_LCIS ) != 0 ) { ier &= ~ IER_LCIE ; interface -> nicEvent = TRUE ; flag |= osSetEventFromIsr ( & netEvent ) ; } if ( ( isr & ISR_TXIS ) != 0 ) { ksz8851WriteReg ( interface , KSZ8851_REG_ISR , ISR_TXIS ) ; n = ksz8851ReadReg ( interface , KSZ8851_REG_TXMIR ) & TXMIR_TXMA_MASK ; if ( n >= ( ETH_MAX_FRAME_SIZE + 8 ) ) { flag |= osSetEventFromIsr ( & interface -> nicTxEvent ) ; } } if ( ( isr & ISR_RXIS ) != 0 ) { ier &= ~ IER_RXIE ; interface -> nicEvent = TRUE ; flag |= osSetEventFromIsr ( & netEvent ) ; } ksz8851WriteReg ( interface , KSZ8851_REG_IER , ier ) ; return flag ; } "," ( interface , KSZ8851_IER ) ; ksz8851WriteReg ( interface , KSZ8851_IER , 0 ) ( interface , KSZ8851_ISR ) ; if ( ( isr & KSZ8851_ISR_LCIS ) != 0 ier &= ~ KSZ8851_IER_LCIE ; interface -> ( isr & KSZ8851_ISR_TXIS ) != 0 ( interface , KSZ8851_ISR , KSZ8851_ISR_TXIS ) ; n ( interface , KSZ8851_TXMIR ) & KSZ8851_TXMIR_TXMA ; if ( ( isr & KSZ8851_ISR_RXIS ) != 0 ier &= ~ KSZ8851_IER_RXIE ; interface -> ( interface , KSZ8851_IER , ier ) ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 529,CWE-119,"CWE-119 static void encode_quantization ( VP9_COMMON * cm , struct vp9_write_bit_buffer * wb ) { vp9_wb_write_literal ( wb , cm -> base_qindex , QINDEX_BITS ) ; write_delta_q ( wb , cm -> y_dc_delta_q ) ; write_delta_q ( wb , cm -> uv_dc_delta_q ) ; write_delta_q ( wb , cm -> uv_ac_delta_q ) ; } "," void encode_quantization ( const VP9_COMMON * const cm , struct cm , struct vpx_write_bit_buffer * wb ) wb ) { vpx_wb_write_literal ( wb , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 530,CWE-119,"CWE-119 static int cdxl_decode_frame ( AVCodecContext * avctx , void * data , int * got_frame , AVPacket * pkt ) { CDXLVideoContext * c = avctx -> priv_data ; AVFrame * const p = data ; int ret , w , h , encoding , aligned_width , buf_size = pkt -> size ; const uint8_t * buf = pkt -> data ; if ( buf_size < 32 ) return AVERROR_INVALIDDATA ; encoding = buf [ 1 ] & 7 ; c -> format = buf [ 1 ] & 0xE0 ; w = AV_RB16 ( & buf [ 14 ] ) ; h = AV_RB16 ( & buf [ 16 ] ) ; c -> bpp = buf [ 19 ] ; c -> palette_size = AV_RB16 ( & buf [ 20 ] ) ; c -> palette = buf + 32 ; c -> video = c -> palette + c -> palette_size ; c -> video_size = buf_size - c -> palette_size - 32 ; if ( c -> palette_size > 512 ) return AVERROR_INVALIDDATA ; if ( buf_size < c -> palette_size + 32 ) return AVERROR_INVALIDDATA ; if ( c -> bpp < 1 ) return AVERROR_INVALIDDATA ; if ( c -> format != BIT_PLANAR && c -> format != BIT_LINE && c -> format != CHUNKY ) { avpriv_request_sample ( avctx , ""Pixelformat0x%0x"" , c -> format ) ; return AVERROR_PATCHWELCOME ; } if ( ( ret = ff_set_dimensions ( avctx , w , h ) ) < 0 ) return ret ; if ( c -> format == CHUNKY ) aligned_width = avctx -> width ; else aligned_width = FFALIGN ( c -> avctx -> width , 16 ) ; c -> padded_bits = aligned_width - c -> avctx -> width ; if ( c -> video_size < aligned_width * avctx -> height * ( int64_t ) c -> bpp / 8 ) return AVERROR_INVALIDDATA ; if ( ! encoding && c -> palette_size && c -> bpp <= 8 && c -> format != CHUNKY ) { avctx -> pix_fmt = AV_PIX_FMT_PAL8 ; } else if ( encoding == 1 && ( c -> bpp == 6 || c -> bpp == 8 ) ) { if ( c -> palette_size != ( 1 << ( c -> bpp - 1 ) ) ) return AVERROR_INVALIDDATA ; avctx -> pix_fmt = AV_PIX_FMT_BGR24 ; } else if ( ! encoding && c -> bpp == 24 && c -> format == CHUNKY && ! c -> palette_size ) { avctx -> pix_fmt = AV_PIX_FMT_RGB24 ; } else { avpriv_request_sample ( avctx , ""Encoding%d,bpp%dandformat0x%x"" , encoding , c -> bpp , c -> format ) ; return AVERROR_PATCHWELCOME ; } if ( ( ret = ff_get_buffer ( avctx , p , 0 ) ) < 0 ) return ret ; p -> pict_type = AV_PICTURE_TYPE_I ; if ( encoding ) { av_fast_padded_malloc ( & c -> new_video , & c -> new_video_size , h * w + AV_INPUT_BUFFER_PADDING_SIZE ) ; if ( ! c -> new_video ) return AVERROR ( ENOMEM ) ; if ( c -> bpp == 8 ) cdxl_decode_ham8 ( c , p ) ; else cdxl_decode_ham6 ( c , p ) ; } else if ( avctx -> pix_fmt == AV_PIX_FMT_PAL8 ) { cdxl_decode_rgb ( c , p ) ; } else { cdxl_decode_raw ( c , p ) ; } * got_frame = 1 ; return buf_size ; } "," == 8 ) && c -> format != CHUNKY ",FFmpeg@FFmpeg/1e42736b95065c69a7481d0cf55247024f54b660,CVE-2017-9996,https://github.com/FFmpeg/FFmpeg/commit/1e42736b95065c69a7481d0cf55247024f54b660,2017-06-28T06:29Z 531,CWE-284,"CWE-284 BOOLEAN UIPC_Send ( tUIPC_CH_ID ch_id , UINT16 msg_evt , UINT8 * p_buf , UINT16 msglen ) { UNUSED ( msg_evt ) ; BTIF_TRACE_DEBUG ( ""UIPC_Send:ch_id:%d%dbytes"" , ch_id , msglen ) ; UIPC_LOCK ( ) ; if ( write ( uipc_main . ch [ ch_id ] . fd , p_buf , msglen ) < 0 ) { BTIF_TRACE_ERROR ( ""failedtowrite(%s)"" , strerror ( errno ) ) ; } UIPC_UNLOCK ( ) ; return FALSE ; } "," ; if ( TEMP_FAILURE_RETRY ( p_buf , msglen ) ",system@bt/472271b153c5dc53c28beac55480a8d8434b2d5c,CVE-2016-3839,https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c,2016-08-05T20:59Z 532,CWE-119,"CWE-119 static const char * parse_scheme ( struct parse_state * state ) { size_t mb ; const char * tmp = state -> ptr ; do { switch ( * state -> ptr ) { case ':' : state -> url . scheme = & state -> buffer [ 0 ] ; state -> buffer [ state -> offset ++ ] = 0 ; return ++ state -> ptr ; case '0' : case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : case '+' : case '-' : case '.' : if ( state -> ptr == tmp ) { return tmp ; } case 'A' : case 'B' : case 'C' : case 'D' : case 'E' : case 'F' : case 'G' : case 'H' : case 'I' : case 'J' : case 'K' : case 'L' : case 'M' : case 'N' : case 'O' : case 'P' : case 'Q' : case 'R' : case 'S' : case 'T' : case 'U' : case 'V' : case 'W' : case 'X' : case 'Y' : case 'Z' : case 'a' : case 'b' : case 'c' : case 'd' : case 'e' : case 'f' : case 'g' : case 'h' : case 'i' : case 'j' : case 'k' : case 'l' : case 'm' : case 'n' : case 'o' : case 'p' : case 'q' : case 'r' : case 's' : case 't' : case 'u' : case 'v' : case 'w' : case 'x' : case 'y' : case 'z' : state -> buffer [ state -> offset ++ ] = * state -> ptr ; break ; default : if ( ! ( mb = parse_mb ( state , PARSE_SCHEME , state -> ptr , state -> end , tmp , 1 ) ) ) { return tmp ; } state -> ptr += mb - 1 ; } } while ( ++ state -> ptr != state -> end ) ; return state -> ptr = tmp ; } "," tmp ) { goto softfail ; } case ) ) { goto softfail ; } state end ) ; softfail : state -> offset = 0 ; ",m6w6@ext-http/3724cd76a28be1d6049b5537232e97ac567ae1f5,CVE-2016-5873,https://github.com/m6w6/ext-http/commit/3724cd76a28be1d6049b5537232e97ac567ae1f5,2017-01-23T21:59Z 533,CWE-200,"CWE-200 static int vivid_fb_ioctl ( struct fb_info * info , unsigned cmd , unsigned long arg ) { struct vivid_dev * dev = ( struct vivid_dev * ) info -> par ; switch ( cmd ) { case FBIOGET_VBLANK : { struct fb_vblank vblank ; vblank . flags = FB_VBLANK_HAVE_COUNT | FB_VBLANK_HAVE_VCOUNT | FB_VBLANK_HAVE_VSYNC ; vblank . count = 0 ; vblank . vcount = 0 ; vblank . hcount = 0 ; if ( copy_to_user ( ( void __user * ) arg , & vblank , sizeof ( vblank ) ) ) return - EFAULT ; return 0 ; } default : dprintk ( dev , 1 , ""Unknownioctl%08x\\n"" , cmd ) ; return - EINVAL ; } return 0 ; } "," struct fb_vblank vblank ; memset ( & vblank , 0 , sizeof ( vblank ) ) ",torvalds@linux/eda98796aff0d9bf41094b06811f5def3b4c333c,CVE-2015-7884,https://github.com/torvalds/linux/commit/eda98796aff0d9bf41094b06811f5def3b4c333c,2015-12-28T11:59Z 534,CWE-416,"CWE-416 static void timerfd_setup_cancel ( struct timerfd_ctx * ctx , int flags ) { if ( ( ctx -> clockid == CLOCK_REALTIME || ctx -> clockid == CLOCK_REALTIME_ALARM ) && ( flags & TFD_TIMER_ABSTIME ) && ( flags & TFD_TIMER_CANCEL_ON_SET ) ) { if ( ! ctx -> might_cancel ) { ctx -> might_cancel = true ; spin_lock ( & cancel_lock ) ; list_add_rcu ( & ctx -> clist , & cancel_list ) ; spin_unlock ( & cancel_lock ) ; } } else if ( ctx -> might_cancel ) { timerfd_remove_cancel ( ctx ) ; } } "," flags ) { spin_lock ( & ctx -> cancel_lock ) ; } } else { __timerfd_remove_cancel ( ctx ) ) ; } spin_unlock ( & ctx -> cancel_lock ) ; ",torvalds@linux/1e38da300e1e395a15048b0af1e5305bd91402f6,CVE-2017-10661,https://github.com/torvalds/linux/commit/1e38da300e1e395a15048b0af1e5305bd91402f6,2017-08-19T18:29Z 535,CWE-000,"CWE-000 static Curves16Data * CurvesAlloc ( cmsContext ContextID , int nCurves , int nElements , cmsToneCurve * * G ) { int i , j ; Curves16Data * c16 ; c16 = _cmsMallocZero ( ContextID , sizeof ( Curves16Data ) ) ; if ( c16 == NULL ) return NULL ; c16 -> nCurves = nCurves ; c16 -> nElements = nElements ; c16 -> Curves = _cmsCalloc ( ContextID , nCurves , sizeof ( cmsUInt16Number * ) ) ; if ( c16 -> Curves == NULL ) return NULL ; for ( i = 0 ; i < nCurves ; i ++ ) { c16 -> Curves [ i ] = _cmsCalloc ( ContextID , nElements , sizeof ( cmsUInt16Number ) ) ; if ( nElements == 256 ) { for ( j = 0 ; j < nElements ; j ++ ) { c16 -> Curves [ i ] [ j ] = cmsEvalToneCurve16 ( G [ i ] , FROM_8_TO_16 ( j ) ) ; } } else { for ( j = 0 ; j < nElements ; j ++ ) { c16 -> Curves [ i ] [ j ] = cmsEvalToneCurve16 ( G [ i ] , ( cmsUInt16Number ) j ) ; } } } return c16 ; } "," ) ) ; if ( c16 -> Curves [ i ] == NULL ) { for ( j = 0 ; j < i ; j ++ ) { _cmsFree ( ContextID , c16 -> Curves [ j ] ) ; } _cmsFree ( ContextID , c16 -> Curves ) ; _cmsFree ( ContextID , c16 ) ; return NULL ; } ",mm2@Little-CMS/91c2db7f2559be504211b283bc3a2c631d6f06d9,CVE-2013-4160,https://github.com/mm2/Little-CMS/commit/91c2db7f2559be504211b283bc3a2c631d6f06d9,2014-01-21T18:55Z 536,CWE-20,"CWE-20 static int tomoyo_mount_acl ( struct tomoyo_request_info * r , char * dev_name , struct path * dir , char * type , unsigned long flags ) { struct path path ; struct file_system_type * fstype = NULL ; const char * requested_type = NULL ; const char * requested_dir_name = NULL ; const char * requested_dev_name = NULL ; struct tomoyo_path_info rtype ; struct tomoyo_path_info rdev ; struct tomoyo_path_info rdir ; int need_dev = 0 ; int error = - ENOMEM ; requested_type = tomoyo_encode ( type ) ; if ( ! requested_type ) goto out ; rtype . name = requested_type ; tomoyo_fill_path_info ( & rtype ) ; requested_dir_name = tomoyo_realpath_from_path ( dir ) ; if ( ! requested_dir_name ) { error = - ENOMEM ; goto out ; } rdir . name = requested_dir_name ; tomoyo_fill_path_info ( & rdir ) ; if ( ! strcmp ( type , TOMOYO_MOUNT_REMOUNT_KEYWORD ) ) { } else if ( ! strcmp ( type , TOMOYO_MOUNT_MAKE_UNBINDABLE_KEYWORD ) || ! strcmp ( type , TOMOYO_MOUNT_MAKE_PRIVATE_KEYWORD ) || ! strcmp ( type , TOMOYO_MOUNT_MAKE_SLAVE_KEYWORD ) || ! strcmp ( type , TOMOYO_MOUNT_MAKE_SHARED_KEYWORD ) ) { } else if ( ! strcmp ( type , TOMOYO_MOUNT_BIND_KEYWORD ) || ! strcmp ( type , TOMOYO_MOUNT_MOVE_KEYWORD ) ) { need_dev = - 1 ; } else { fstype = get_fs_type ( type ) ; if ( ! fstype ) { error = - ENODEV ; goto out ; } if ( fstype -> fs_flags & FS_REQUIRES_DEV ) need_dev = 1 ; } if ( need_dev ) { if ( kern_path ( dev_name , LOOKUP_FOLLOW , & path ) ) { error = - ENOENT ; goto out ; } requested_dev_name = tomoyo_realpath_from_path ( & path ) ; path_put ( & path ) ; if ( ! requested_dev_name ) { error = - ENOENT ; goto out ; } } else { if ( ! dev_name ) dev_name = """" ; requested_dev_name = tomoyo_encode ( dev_name ) ; if ( ! requested_dev_name ) { error = - ENOMEM ; goto out ; } } rdev . name = requested_dev_name ; tomoyo_fill_path_info ( & rdev ) ; r -> param_type = TOMOYO_TYPE_MOUNT_ACL ; r -> param . mount . need_dev = need_dev ; r -> param . mount . dev = & rdev ; r -> param . mount . dir = & rdir ; r -> param . mount . type = & rtype ; r -> param . mount . flags = flags ; do { tomoyo_check_acl ( r , tomoyo_check_mount_acl ) ; error = tomoyo_audit_mount_log ( r ) ; } while ( error == TOMOYO_RETRY_REQUEST ) ; out : kfree ( requested_dev_name ) ; kfree ( requested_dir_name ) ; if ( fstype ) put_filesystem ( fstype ) ; kfree ( requested_type ) ; return error ; } "," { if ( ! dev_name || ",torvalds@linux/4e78c724d47e2342aa8fde61f6b8536f662f795f,CVE-2011-2518,https://github.com/torvalds/linux/commit/4e78c724d47e2342aa8fde61f6b8536f662f795f,2012-05-24T23:55Z 537,CWE-125,"CWE-125 int ethertype_print ( netdissect_options * ndo , u_short ether_type , const u_char * p , u_int length , u_int caplen , const struct lladdr_info * src , const struct lladdr_info * dst ) { switch ( ether_type ) { case ETHERTYPE_IP : ip_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_IPV6 : ip6_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_ARP : case ETHERTYPE_REVARP : arp_print ( ndo , p , length , caplen ) ; return ( 1 ) ; case ETHERTYPE_DN : decnet_print ( ndo , p , length , caplen ) ; return ( 1 ) ; case ETHERTYPE_ATALK : if ( ndo -> ndo_vflag ) ND_PRINT ( ( ndo , ""et1"" ) ) ; atalk_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_AARP : aarp_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_IPX : ND_PRINT ( ( ndo , ""(NOV-ETHII)"" ) ) ; ipx_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_ISO : if ( length == 0 || caplen == 0 ) { ND_PRINT ( ( ndo , ""[|osi]"" ) ) ; return ( 1 ) ; } isoclns_print ( ndo , p + 1 , length - 1 , caplen - 1 ) ; return ( 1 ) ; case ETHERTYPE_PPPOED : case ETHERTYPE_PPPOES : case ETHERTYPE_PPPOED2 : case ETHERTYPE_PPPOES2 : pppoe_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_EAPOL : eap_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_RRCP : rrcp_print ( ndo , p , length , src , dst ) ; return ( 1 ) ; case ETHERTYPE_PPP : if ( length ) { ND_PRINT ( ( ndo , "":"" ) ) ; ppp_print ( ndo , p , length ) ; } return ( 1 ) ; case ETHERTYPE_MPCP : mpcp_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_SLOW : slow_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_CFM : case ETHERTYPE_CFM_OLD : cfm_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_LLDP : lldp_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_NSH : nsh_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_LOOPBACK : loopback_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_MPLS : case ETHERTYPE_MPLS_MULTI : mpls_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_TIPC : tipc_print ( ndo , p , length , caplen ) ; return ( 1 ) ; case ETHERTYPE_MS_NLB_HB : msnlb_print ( ndo , p ) ; return ( 1 ) ; case ETHERTYPE_GEONET_OLD : case ETHERTYPE_GEONET : geonet_print ( ndo , p , length , src ) ; return ( 1 ) ; case ETHERTYPE_CALM_FAST : calm_fast_print ( ndo , p , length , src ) ; return ( 1 ) ; case ETHERTYPE_AOE : aoe_print ( ndo , p , length ) ; return ( 1 ) ; case ETHERTYPE_MEDSA : medsa_print ( ndo , p , length , caplen , src , dst ) ; return ( 1 ) ; case ETHERTYPE_LAT : case ETHERTYPE_SCA : case ETHERTYPE_MOPRC : case ETHERTYPE_MOPDL : case ETHERTYPE_IEEE1905_1 : default : return ( 0 ) ; } } "," length - 1 ) ; return ",the-tcpdump-group@tcpdump/1dcd10aceabbc03bf571ea32b892c522cbe923de,CVE-2017-12897,https://github.com/the-tcpdump-group/tcpdump/commit/1dcd10aceabbc03bf571ea32b892c522cbe923de,2017-09-14T06:29Z 538,CWE-125,"CWE-125 int saa7164_bus_get ( struct saa7164_dev * dev , struct tmComResInfo * msg , void * buf , int peekonly ) { struct tmComResBusInfo * bus = & dev -> bus ; u32 bytes_to_read , write_distance , curr_grp , curr_gwp , new_grp , buf_size , space_rem ; struct tmComResInfo msg_tmp ; int ret = SAA_ERR_BAD_PARAMETER ; saa7164_bus_verify ( dev ) ; if ( msg == NULL ) return ret ; if ( msg -> size > dev -> bus . m_wMaxReqSize ) { printk ( KERN_ERR ""%s()Exceededdev->bus.m_wMaxReqSize\\n"" , __func__ ) ; return ret ; } if ( ( peekonly == 0 ) && ( msg -> size > 0 ) && ( buf == NULL ) ) { printk ( KERN_ERR ""%s()Missingmsgbuf,sizeshouldbe%dbytes\\n"" , __func__ , msg -> size ) ; return ret ; } mutex_lock ( & bus -> lock ) ; curr_gwp = saa7164_readl ( bus -> m_dwGetWritePos ) ; curr_grp = saa7164_readl ( bus -> m_dwGetReadPos ) ; if ( curr_gwp == curr_grp ) { ret = SAA_ERR_EMPTY ; goto out ; } bytes_to_read = sizeof ( * msg ) ; write_distance = 0 ; if ( curr_gwp >= curr_grp ) write_distance = curr_gwp - curr_grp ; else write_distance = curr_gwp + bus -> m_dwSizeGetRing - curr_grp ; if ( bytes_to_read > write_distance ) { printk ( KERN_ERR ""%s()Nomessage/responsefound\\n"" , __func__ ) ; ret = SAA_ERR_INVALID_COMMAND ; goto out ; } new_grp = curr_grp + bytes_to_read ; if ( new_grp > bus -> m_dwSizeGetRing ) { new_grp -= bus -> m_dwSizeGetRing ; space_rem = bus -> m_dwSizeGetRing - curr_grp ; memcpy_fromio ( & msg_tmp , bus -> m_pdwGetRing + curr_grp , space_rem ) ; memcpy_fromio ( ( u8 * ) & msg_tmp + space_rem , bus -> m_pdwGetRing , bytes_to_read - space_rem ) ; } else { memcpy_fromio ( & msg_tmp , bus -> m_pdwGetRing + curr_grp , bytes_to_read ) ; } msg_tmp . size = le16_to_cpu ( ( __force __le16 ) msg_tmp . size ) ; msg_tmp . command = le32_to_cpu ( ( __force __le32 ) msg_tmp . command ) ; msg_tmp . controlselector = le16_to_cpu ( ( __force __le16 ) msg_tmp . controlselector ) ; if ( peekonly ) { memcpy ( msg , & msg_tmp , sizeof ( * msg ) ) ; goto peekout ; } if ( ( msg_tmp . id != msg -> id ) || ( msg_tmp . command != msg -> command ) || ( msg_tmp . controlselector != msg -> controlselector ) || ( msg_tmp . seqno != msg -> seqno ) || ( msg_tmp . size != msg -> size ) ) { printk ( KERN_ERR ""%s()Unexpectedmsgmiss-match\\n"" , __func__ ) ; saa7164_bus_dumpmsg ( dev , msg , buf ) ; saa7164_bus_dumpmsg ( dev , & msg_tmp , NULL ) ; ret = SAA_ERR_INVALID_COMMAND ; goto out ; } buf_size = msg -> size ; bytes_to_read = sizeof ( * msg ) + msg -> size ; write_distance = 0 ; if ( curr_gwp >= curr_grp ) write_distance = curr_gwp - curr_grp ; else write_distance = curr_gwp + bus -> m_dwSizeGetRing - curr_grp ; if ( bytes_to_read > write_distance ) { printk ( KERN_ERR ""%s()Invalidbusstate,missingmsgormangledring,faultyH/W/badcode?\\n"" , __func__ ) ; ret = SAA_ERR_INVALID_COMMAND ; goto out ; } new_grp = curr_grp + bytes_to_read ; if ( new_grp > bus -> m_dwSizeGetRing ) { new_grp -= bus -> m_dwSizeGetRing ; space_rem = bus -> m_dwSizeGetRing - curr_grp ; if ( space_rem < sizeof ( * msg ) ) { memcpy_fromio ( msg , bus -> m_pdwGetRing + curr_grp , space_rem ) ; memcpy_fromio ( ( u8 * ) msg + space_rem , bus -> m_pdwGetRing , sizeof ( * msg ) - space_rem ) ; if ( buf ) memcpy_fromio ( buf , bus -> m_pdwGetRing + sizeof ( * msg ) - space_rem , buf_size ) ; } else if ( space_rem == sizeof ( * msg ) ) { memcpy_fromio ( msg , bus -> m_pdwGetRing + curr_grp , sizeof ( * msg ) ) ; if ( buf ) memcpy_fromio ( buf , bus -> m_pdwGetRing , buf_size ) ; } else { memcpy_fromio ( msg , bus -> m_pdwGetRing + curr_grp , sizeof ( * msg ) ) ; if ( buf ) { memcpy_fromio ( buf , bus -> m_pdwGetRing + curr_grp + sizeof ( * msg ) , space_rem - sizeof ( * msg ) ) ; memcpy_fromio ( buf + space_rem - sizeof ( * msg ) , bus -> m_pdwGetRing , bytes_to_read - space_rem ) ; } } } else { memcpy_fromio ( msg , bus -> m_pdwGetRing + curr_grp , sizeof ( * msg ) ) ; if ( buf ) memcpy_fromio ( buf , bus -> m_pdwGetRing + curr_grp + sizeof ( * msg ) , buf_size ) ; } msg -> size = le16_to_cpu ( ( __force __le16 ) msg -> size ) ; msg -> command = le32_to_cpu ( ( __force __le32 ) msg -> command ) ; msg -> controlselector = le16_to_cpu ( ( __force __le16 ) msg -> controlselector ) ; saa7164_writel ( bus -> m_dwGetReadPos , new_grp ) ; peekout : ret = SAA_OK ; out : mutex_unlock ( & bus -> lock ) ; saa7164_bus_verify ( dev ) ; return ret ; } "," controlselector ) ; memcpy ( msg , & msg_tmp , sizeof ( * msg ) ) ; peekonly ) { goto peekout ; ) ) { if ( buf ) memcpy_fromio ( buf , bus -> -> m_pdwGetRing + sizeof ( * msg ) - space_rem , buf_size ) ; } else if ( space_rem == sizeof ( * msg ) ) { if ( buf ) memcpy_fromio ( buf , bus -> -> m_pdwGetRing , buf_size ) ; } else { if ( buf ) { memcpy_fromio ( buf -> m_pdwGetRing + curr_grp + sizeof ( * msg ) , space_rem - sizeof ( * msg ) ) ; memcpy_fromio ( buf + space_rem - sizeof ( * msg ) , bus -> m_pdwGetRing , bytes_to_read - space_rem ) ; } } } else { if ( buf ) memcpy_fromio ( buf , bus -> m_pdwGetRing + curr_grp + sizeof ( * msg ) , buf_size ) ; ) ; } saa7164_writel ( bus ",stoth68000@media-tree/354dd3924a2e43806774953de536257548b5002c,CVE-2017-8831,https://github.com/stoth68000/media-tree/commit/354dd3924a2e43806774953de536257548b5002c,2017-05-08T06:29Z 539,CWE-190,"CWE-190 static void php_html_entities ( INTERNAL_FUNCTION_PARAMETERS , int all ) { char * str , * hint_charset = NULL ; int str_len , hint_charset_len = 0 ; size_t new_len ; long flags = ENT_COMPAT ; char * replaced ; zend_bool double_encode = 1 ; if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) TSRMLS_CC , ""s|ls!b"" , & str , & str_len , & flags , & hint_charset , & hint_charset_len , & double_encode ) == FAILURE ) { return ; } replaced = php_escape_html_entities_ex ( str , str_len , & new_len , all , ( int ) flags , hint_charset , double_encode TSRMLS_CC ) ; RETVAL_STRINGL ( replaced , ( int ) new_len , 0 ) ; } "," TSRMLS_CC ) ; if ( new_len > INT_MAX ) { efree ( replaced ) ; RETURN_FALSE ; } ",php@php-src/0da8b8b801f9276359262f1ef8274c7812d3dfda,CVE-2016-5094,https://github.com/php/php-src/commit/0da8b8b801f9276359262f1ef8274c7812d3dfda?w=1,2016-08-07T10:59Z 540,CWE-639,"CWE-639 int ca_validate_pubkey ( struct iked * env , struct iked_static_id * id , void * data , size_t len , struct iked_id * out ) { BIO * rawcert = NULL ; RSA * peerrsa = NULL , * localrsa = NULL ; EC_KEY * peerec = NULL ; EVP_PKEY * peerkey = NULL , * localkey = NULL ; int ret = - 1 ; FILE * fp = NULL ; char idstr [ IKED_ID_SIZE ] ; char file [ PATH_MAX ] ; struct iked_id idp ; switch ( id -> id_type ) { case IKEV2_ID_IPV4 : case IKEV2_ID_FQDN : case IKEV2_ID_UFQDN : case IKEV2_ID_IPV6 : break ; default : log_debug ( ""%s:unsupportedpublickeytype%s"" , __func__ , print_map ( id -> id_type , ikev2_id_map ) ) ; return ( - 1 ) ; } bzero ( & idp , sizeof ( idp ) ) ; if ( ( idp . id_buf = ibuf_new ( id -> id_data , id -> id_length ) ) == NULL ) goto done ; idp . id_type = id -> id_type ; idp . id_offset = id -> id_offset ; if ( ikev2_print_id ( & idp , idstr , sizeof ( idstr ) ) == - 1 ) goto done ; if ( len == 0 && data ) { peerkey = ( EVP_PKEY * ) data ; } if ( len > 0 ) { if ( ( rawcert = BIO_new_mem_buf ( data , len ) ) == NULL ) goto done ; if ( ( peerkey = EVP_PKEY_new ( ) ) == NULL ) goto sslerr ; if ( ( peerrsa = d2i_RSAPublicKey_bio ( rawcert , NULL ) ) ) { if ( ! EVP_PKEY_set1_RSA ( peerkey , peerrsa ) ) { goto sslerr ; } } else if ( BIO_reset ( rawcert ) == 1 && ( peerec = d2i_EC_PUBKEY_bio ( rawcert , NULL ) ) ) { if ( ! EVP_PKEY_set1_EC_KEY ( peerkey , peerec ) ) { goto sslerr ; } } else { log_debug ( ""%s:unknownkeytypereceived"" , __func__ ) ; goto sslerr ; } } lc_idtype ( idstr ) ; if ( strlcpy ( file , IKED_PUBKEY_DIR , sizeof ( file ) ) >= sizeof ( file ) || strlcat ( file , idstr , sizeof ( file ) ) >= sizeof ( file ) ) { log_debug ( ""%s:publickeyidtoolong%s"" , __func__ , idstr ) ; goto done ; } if ( ( fp = fopen ( file , ""r"" ) ) == NULL ) { logit ( len == 0 ? LOG_DEBUG : LOG_INFO , ""%s:couldnotopenpublickey%s"" , __func__ , file ) ; goto done ; } localkey = PEM_read_PUBKEY ( fp , NULL , NULL , NULL ) ; if ( localkey == NULL ) { rewind ( fp ) ; localrsa = PEM_read_RSAPublicKey ( fp , NULL , NULL , NULL ) ; fclose ( fp ) ; if ( localrsa == NULL ) goto sslerr ; if ( ( localkey = EVP_PKEY_new ( ) ) == NULL ) goto sslerr ; if ( ! EVP_PKEY_set1_RSA ( localkey , localrsa ) ) goto sslerr ; } else { fclose ( fp ) ; } if ( localkey == NULL ) goto sslerr ; if ( peerkey && ! EVP_PKEY_cmp ( peerkey , localkey ) ) { log_debug ( ""%s:publickeydoesnotmatch%s"" , __func__ , file ) ; goto done ; } log_debug ( ""%s:validpublickeyinfile%s"" , __func__ , file ) ; if ( out && ca_pubkey_serialize ( localkey , out ) ) goto done ; ret = 0 ; sslerr : if ( ret != 0 ) ca_sslerror ( __func__ ) ; done : ibuf_release ( idp . id_buf ) ; if ( localkey != NULL ) EVP_PKEY_free ( localkey ) ; if ( peerrsa != NULL ) RSA_free ( peerrsa ) ; if ( peerec != NULL ) EC_KEY_free ( peerec ) ; if ( localrsa != NULL ) RSA_free ( localrsa ) ; if ( rawcert != NULL ) { BIO_free ( rawcert ) ; if ( peerkey != NULL ) EVP_PKEY_free ( peerkey ) ; } return ( ret ) ; } "," ( peerkey && EVP_PKEY_cmp ( peerkey , localkey ) != 1 ",openbsd@src/7afb2d41c6d373cf965285840b85c45011357115,CVE-2020-16088,https://github.com/openbsd/src/commit/7afb2d41c6d373cf965285840b85c45011357115,2020-07-28T12:15Z 541,CWE-119,"CWE-119 static void t1_check_unusual_charstring ( void ) { char * p = strstr ( t1_line_array , charstringname ) + strlen ( charstringname ) ; int i ; if ( sscanf ( p , ""%i"" , & i ) != 1 ) { strcpy ( t1_buf_array , t1_line_array ) ; t1_getline ( ) ; strcat ( t1_buf_array , t1_line_array ) ; strcpy ( t1_line_array , t1_buf_array ) ; t1_line_ptr = eol ( t1_line_array ) ; } } "," ( ) ; alloc_array ( t1_buf , strlen ( t1_line_array ) + strlen ( t1_buf_array ) + 1 , T1_BUF_SIZE ) ; t1_buf_array , t1_line_array ) ; alloc_array ( t1_line , strlen ( t1_buf_array ) + 1 , T1_BUF_SIZE ",TeX-Live@texlive-source/6ed0077520e2b0da1fd060c7f88db7b2e6068e4c,CVE-2018-17407,https://github.com/TeX-Live/texlive-source/commit/6ed0077520e2b0da1fd060c7f88db7b2e6068e4c,2018-09-23T21:29Z 542,CWE-119,"CWE-119 static void fill_mode_info_sb ( VP9_COMMON * cm , MACROBLOCK * x , int mi_row , int mi_col , BLOCK_SIZE bsize , BLOCK_SIZE subsize ) { MACROBLOCKD * xd = & x -> e_mbd ; int bsl = b_width_log2 ( bsize ) , hbs = ( 1 << bsl ) / 4 ; PARTITION_TYPE partition = partition_lookup [ bsl ] [ subsize ] ; assert ( bsize >= BLOCK_8X8 ) ; if ( mi_row >= cm -> mi_rows || mi_col >= cm -> mi_cols ) return ; switch ( partition ) { case PARTITION_NONE : set_modeinfo_offsets ( cm , xd , mi_row , mi_col ) ; * ( xd -> mi [ 0 ] ) = get_block_context ( x , subsize ) -> mic ; duplicate_mode_info_in_sb ( cm , xd , mi_row , mi_col , bsize ) ; break ; case PARTITION_VERT : * get_sb_index ( x , subsize ) = 0 ; set_modeinfo_offsets ( cm , xd , mi_row , mi_col ) ; * ( xd -> mi [ 0 ] ) = get_block_context ( x , subsize ) -> mic ; duplicate_mode_info_in_sb ( cm , xd , mi_row , mi_col , bsize ) ; if ( mi_col + hbs < cm -> mi_cols ) { * get_sb_index ( x , subsize ) = 1 ; set_modeinfo_offsets ( cm , xd , mi_row , mi_col + hbs ) ; * ( xd -> mi [ 0 ] ) = get_block_context ( x , subsize ) -> mic ; duplicate_mode_info_in_sb ( cm , xd , mi_row , mi_col + hbs , bsize ) ; } break ; case PARTITION_HORZ : * get_sb_index ( x , subsize ) = 0 ; set_modeinfo_offsets ( cm , xd , mi_row , mi_col ) ; * ( xd -> mi [ 0 ] ) = get_block_context ( x , subsize ) -> mic ; duplicate_mode_info_in_sb ( cm , xd , mi_row , mi_col , bsize ) ; if ( mi_row + hbs < cm -> mi_rows ) { * get_sb_index ( x , subsize ) = 1 ; set_modeinfo_offsets ( cm , xd , mi_row + hbs , mi_col ) ; * ( xd -> mi [ 0 ] ) = get_block_context ( x , subsize ) -> mic ; duplicate_mode_info_in_sb ( cm , xd , mi_row + hbs , mi_col , bsize ) ; } break ; case PARTITION_SPLIT : * get_sb_index ( x , subsize ) = 0 ; fill_mode_info_sb ( cm , x , mi_row , mi_col , subsize , * ( get_sb_partitioning ( x , subsize ) ) ) ; * get_sb_index ( x , subsize ) = 1 ; fill_mode_info_sb ( cm , x , mi_row , mi_col + hbs , subsize , * ( get_sb_partitioning ( x , subsize ) ) ) ; * get_sb_index ( x , subsize ) = 2 ; fill_mode_info_sb ( cm , x , mi_row + hbs , mi_col , subsize , * ( get_sb_partitioning ( x , subsize ) ) ) ; * get_sb_index ( x , subsize ) = 3 ; fill_mode_info_sb ( cm , x , mi_row + hbs , mi_col + hbs , subsize , * ( get_sb_partitioning ( x , subsize ) ) ) ; break ; default : break ; } } "," BLOCK_SIZE bsize , PC_TREE * pc_tree ) { MACROBLOCKD int bsl = b_width_log2_lookup [ bsize ] , hbs = PARTITION_TYPE partition = pc_tree -> partitioning ; BLOCK_SIZE subsize = get_subsize ( bsize , partition ) ; assert ( case PARTITION_NONE : set_mode_info_offsets ( cm , x , xd , ] ) = pc_tree -> none . mic ; * ( x -> mbmi_ext ) = pc_tree -> none . mbmi_ext ; duplicate_mode_info_in_sb ( case PARTITION_VERT : set_mode_info_offsets ( cm , x , xd , ] ) = pc_tree -> vertical [ 0 ] . mic ; * ( x -> mbmi_ext ) = pc_tree -> vertical [ 0 ] . mbmi_ext ; duplicate_mode_info_in_sb ( cm , mi_col , subsize ) ; if mi_cols ) { set_mode_info_offsets ( cm , x , xd , mi_row , mi_col + hbs ) ; * ( xd -> mi [ 0 ] ) = pc_tree -> vertical [ 1 ] . mic ; * ( x -> mbmi_ext ) = pc_tree -> vertical [ 1 ] . mbmi_ext ; duplicate_mode_info_in_sb ( cm + hbs , subsize ) ; } case PARTITION_HORZ : set_mode_info_offsets ( cm , x , xd , ] ) = pc_tree -> horizontal [ 0 ] . mic ; * ( x -> mbmi_ext ) = pc_tree -> horizontal [ 0 ] . mbmi_ext ; duplicate_mode_info_in_sb ( cm , mi_col , subsize ) ; if mi_rows ) { set_mode_info_offsets ( cm , x , xd , mi_row + hbs , mi_col ) ; * ( xd -> mi [ 0 ] ) = pc_tree -> horizontal [ 1 ] . mic ; * ( x -> mbmi_ext ) = pc_tree -> horizontal [ 1 ] . mbmi_ext ; duplicate_mode_info_in_sb ( cm , mi_col , subsize ) ; } case PARTITION_SPLIT : { fill_mode_info_sb ( cm , subsize , pc_tree -> split [ 0 ] ) ; fill_mode_info_sb ( cm , x , mi_row , mi_col + hbs , subsize , pc_tree -> split [ 1 ] ) ; fill_mode_info_sb ( x , mi_row + hbs , mi_col , subsize , pc_tree -> split [ 2 ] ) ; fill_mode_info_sb ( hbs , mi_col + hbs , subsize , pc_tree -> split [ 3 ] ) ; break ; break ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 543,CWE-20,"CWE-20 static int fsck_gitmodules_fn ( const char * var , const char * value , void * vdata ) { struct fsck_gitmodules_data * data = vdata ; const char * subsection , * key ; int subsection_len ; char * name ; if ( parse_config_key ( var , ""submodule"" , & subsection , & subsection_len , & key ) < 0 || ! subsection ) return 0 ; name = xmemdupz ( subsection , subsection_len ) ; if ( check_submodule_name ( name ) < 0 ) data -> ret |= report ( data -> options , data -> obj , FSCK_MSG_GITMODULES_NAME , ""disallowedsubmodulename:%s"" , name ) ; free ( name ) ; return 0 ; } "," name ) ; if ( ! strcmp ( key , ""url"" ) && value && looks_like_command_line_option ( value ) ) data -> ret |= report ( data -> options , data -> obj , FSCK_MSG_GITMODULES_URL , ""disallowedsubmoduleurl:%s"" , value ) ; ",git@git/a124133e1e6ab5c7a9fef6d0e6bcb084e3455b46,CVE-2018-17456,https://github.com/git/git/commit/a124133e1e6ab5c7a9fef6d0e6bcb084e3455b46,2018-10-06T14:29Z 544,CWE-119,"CWE-119 static void rpza_decode_stream ( RpzaContext * s ) { int width = s -> avctx -> width ; int stride = s -> frame . linesize [ 0 ] / 2 ; int row_inc = stride - 4 ; int stream_ptr = 0 ; int chunk_size ; unsigned char opcode ; int n_blocks ; unsigned short colorA = 0 , colorB ; unsigned short color4 [ 4 ] ; unsigned char index , idx ; unsigned short ta , tb ; unsigned short * pixels = ( unsigned short * ) s -> frame . data [ 0 ] ; int row_ptr = 0 ; int pixel_ptr = 0 ; int block_ptr ; int pixel_x , pixel_y ; int total_blocks ; if ( s -> buf [ stream_ptr ] != 0xe1 ) av_log ( s -> avctx , AV_LOG_ERROR , ""Firstchunkbyteis0x%02xinsteadof0xe1\\n"" , s -> buf [ stream_ptr ] ) ; chunk_size = AV_RB32 ( & s -> buf [ stream_ptr ] ) & 0x00FFFFFF ; stream_ptr += 4 ; if ( chunk_size != s -> size ) av_log ( s -> avctx , AV_LOG_ERROR , ""MOVchunksize!=encodedchunksize;usingMOVchunksize\\n"" ) ; chunk_size = s -> size ; total_blocks = ( ( s -> avctx -> width + 3 ) / 4 ) * ( ( s -> avctx -> height + 3 ) / 4 ) ; while ( stream_ptr < chunk_size ) { opcode = s -> buf [ stream_ptr ++ ] ; n_blocks = ( opcode & 0x1f ) + 1 ; if ( ( opcode & 0x80 ) == 0 ) { colorA = ( opcode << 8 ) | ( s -> buf [ stream_ptr ++ ] ) ; opcode = 0 ; if ( ( s -> buf [ stream_ptr ] & 0x80 ) != 0 ) { opcode = 0x20 ; n_blocks = 1 ; } } switch ( opcode & 0xe0 ) { case 0x80 : while ( n_blocks -- ) { ADVANCE_BLOCK ( ) ; } break ; case 0xa0 : colorA = AV_RB16 ( & s -> buf [ stream_ptr ] ) ; stream_ptr += 2 ; while ( n_blocks -- ) { block_ptr = row_ptr + pixel_ptr ; for ( pixel_y = 0 ; pixel_y < 4 ; pixel_y ++ ) { for ( pixel_x = 0 ; pixel_x < 4 ; pixel_x ++ ) { pixels [ block_ptr ] = colorA ; block_ptr ++ ; } block_ptr += row_inc ; } ADVANCE_BLOCK ( ) ; } break ; case 0xc0 : colorA = AV_RB16 ( & s -> buf [ stream_ptr ] ) ; stream_ptr += 2 ; case 0x20 : colorB = AV_RB16 ( & s -> buf [ stream_ptr ] ) ; stream_ptr += 2 ; color4 [ 0 ] = colorB ; color4 [ 1 ] = 0 ; color4 [ 2 ] = 0 ; color4 [ 3 ] = colorA ; ta = ( colorA >> 10 ) & 0x1F ; tb = ( colorB >> 10 ) & 0x1F ; color4 [ 1 ] |= ( ( 11 * ta + 21 * tb ) >> 5 ) << 10 ; color4 [ 2 ] |= ( ( 21 * ta + 11 * tb ) >> 5 ) << 10 ; ta = ( colorA >> 5 ) & 0x1F ; tb = ( colorB >> 5 ) & 0x1F ; color4 [ 1 ] |= ( ( 11 * ta + 21 * tb ) >> 5 ) << 5 ; color4 [ 2 ] |= ( ( 21 * ta + 11 * tb ) >> 5 ) << 5 ; ta = colorA & 0x1F ; tb = colorB & 0x1F ; color4 [ 1 ] |= ( ( 11 * ta + 21 * tb ) >> 5 ) ; color4 [ 2 ] |= ( ( 21 * ta + 11 * tb ) >> 5 ) ; if ( s -> size - stream_ptr < n_blocks * 4 ) return ; while ( n_blocks -- ) { block_ptr = row_ptr + pixel_ptr ; for ( pixel_y = 0 ; pixel_y < 4 ; pixel_y ++ ) { index = s -> buf [ stream_ptr ++ ] ; for ( pixel_x = 0 ; pixel_x < 4 ; pixel_x ++ ) { idx = ( index >> ( 2 * ( 3 - pixel_x ) ) ) & 0x03 ; pixels [ block_ptr ] = color4 [ idx ] ; block_ptr ++ ; } block_ptr += row_inc ; } ADVANCE_BLOCK ( ) ; } break ; case 0x00 : if ( s -> size - stream_ptr < 16 ) return ; block_ptr = row_ptr + pixel_ptr ; for ( pixel_y = 0 ; pixel_y < 4 ; pixel_y ++ ) { for ( pixel_x = 0 ; pixel_x < 4 ; pixel_x ++ ) { if ( ( pixel_y != 0 ) || ( pixel_x != 0 ) ) { colorA = AV_RB16 ( & s -> buf [ stream_ptr ] ) ; stream_ptr += 2 ; } pixels [ block_ptr ] = colorA ; block_ptr ++ ; } block_ptr += row_inc ; } ADVANCE_BLOCK ( ) ; break ; default : av_log ( s -> avctx , AV_LOG_ERROR , ""Unknownopcode%dinrpzachunk."" ""Skipremaining%dbytesofchunkdata.\\n"" , opcode , chunk_size - stream_ptr ) ; return ; } } } "," int pixel_ptr = - 4 ; int block_ptr -- ) { ADVANCE_BLOCK ( ) row_inc ; } } break ; -- ) { ADVANCE_BLOCK ( ) ; row_inc ; } } break ; ) return ; ADVANCE_BLOCK ( ) ; row_inc ; } break ; default ",FFmpeg@FFmpeg/3819db745da2ac7fb3faacb116788c32f4753f34,CVE-2013-7009,https://github.com/FFmpeg/FFmpeg/commit/3819db745da2ac7fb3faacb116788c32f4753f34,2013-12-09T16:36Z 545,CWE-190,"CWE-190 static int mem_read ( jas_stream_obj_t * obj , char * buf , int cnt ) { int n ; assert ( cnt >= 0 ) ; assert ( buf ) ; JAS_DBGLOG ( 100 , ( ""mem_read(%p,%p,%d)\\n"" , obj , buf , cnt ) ) ; jas_stream_memobj_t * m = ( jas_stream_memobj_t * ) obj ; n = m -> len_ - m -> pos_ ; cnt = JAS_MIN ( n , cnt ) ; memcpy ( buf , & m -> buf_ [ m -> pos_ ] , cnt ) ; m -> pos_ += cnt ; return cnt ; } "," cnt ) { ssize_t n ; assert ",mdadams@jasper/634ce8e8a5accc0fa05dd2c20d42b4749d4b2735,CVE-2016-9262,https://github.com/mdadams/jasper/commit/634ce8e8a5accc0fa05dd2c20d42b4749d4b2735,2017-03-23T18:59Z 546,CWE-400,"CWE-400 static struct sk_buff * * gre_gro_receive ( struct sk_buff * * head , struct sk_buff * skb ) { struct sk_buff * * pp = NULL ; struct sk_buff * p ; const struct gre_base_hdr * greh ; unsigned int hlen , grehlen ; unsigned int off ; int flush = 1 ; struct packet_offload * ptype ; __be16 type ; off = skb_gro_offset ( skb ) ; hlen = off + sizeof ( * greh ) ; greh = skb_gro_header_fast ( skb , off ) ; if ( skb_gro_header_hard ( skb , hlen ) ) { greh = skb_gro_header_slow ( skb , hlen , off ) ; if ( unlikely ( ! greh ) ) goto out ; } if ( ( greh -> flags & ~ ( GRE_KEY | GRE_CSUM ) ) != 0 ) goto out ; type = greh -> protocol ; rcu_read_lock ( ) ; ptype = gro_find_receive_by_type ( type ) ; if ( ! ptype ) goto out_unlock ; grehlen = GRE_HEADER_SECTION ; if ( greh -> flags & GRE_KEY ) grehlen += GRE_HEADER_SECTION ; if ( greh -> flags & GRE_CSUM ) grehlen += GRE_HEADER_SECTION ; hlen = off + grehlen ; if ( skb_gro_header_hard ( skb , hlen ) ) { greh = skb_gro_header_slow ( skb , hlen , off ) ; if ( unlikely ( ! greh ) ) goto out_unlock ; } if ( ( greh -> flags & GRE_CSUM ) && ! NAPI_GRO_CB ( skb ) -> flush ) { if ( skb_gro_checksum_simple_validate ( skb ) ) goto out_unlock ; skb_gro_checksum_try_convert ( skb , IPPROTO_GRE , 0 , null_compute_pseudo ) ; } for ( p = * head ; p ; p = p -> next ) { const struct gre_base_hdr * greh2 ; if ( ! NAPI_GRO_CB ( p ) -> same_flow ) continue ; greh2 = ( struct gre_base_hdr * ) ( p -> data + off ) ; if ( greh2 -> flags != greh -> flags || greh2 -> protocol != greh -> protocol ) { NAPI_GRO_CB ( p ) -> same_flow = 0 ; continue ; } if ( greh -> flags & GRE_KEY ) { if ( * ( __be32 * ) ( greh2 + 1 ) != * ( __be32 * ) ( greh + 1 ) ) { NAPI_GRO_CB ( p ) -> same_flow = 0 ; continue ; } } } skb_gro_pull ( skb , grehlen ) ; skb_gro_postpull_rcsum ( skb , greh , grehlen ) ; pp = ptype -> callbacks . gro_receive ( head , skb ) ; flush = 0 ; out_unlock : rcu_read_unlock ( ) ; out : NAPI_GRO_CB ( skb ) -> flush |= flush ; return pp ; } "," ; __be16 type ; if ( NAPI_GRO_CB ( skb ) -> encap_mark ) goto out ; NAPI_GRO_CB ( skb ) -> encap_mark = 1 ",torvalds@linux/fac8e0f579695a3ecbc4d3cac369139d7f819971,CVE-2016-8666,https://github.com/torvalds/linux/commit/fac8e0f579695a3ecbc4d3cac369139d7f819971,2016-10-16T21:59Z 547,CWE-476,"CWE-476 jas_matrix_t * jas_matrix_create ( int numrows , int numcols ) { jas_matrix_t * matrix ; int i ; if ( ! ( matrix = jas_malloc ( sizeof ( jas_matrix_t ) ) ) ) { return 0 ; } matrix -> flags_ = 0 ; matrix -> numrows_ = numrows ; matrix -> numcols_ = numcols ; matrix -> rows_ = 0 ; matrix -> maxrows_ = numrows ; matrix -> data_ = 0 ; matrix -> datasize_ = numrows * numcols ; if ( matrix -> maxrows_ > 0 ) { if ( ! ( matrix -> rows_ = jas_alloc2 ( matrix -> maxrows_ , sizeof ( jas_seqent_t * ) ) ) ) { jas_matrix_destroy ( matrix ) ; return 0 ; } } if ( matrix -> datasize_ > 0 ) { if ( ! ( matrix -> data_ = jas_alloc2 ( matrix -> datasize_ , sizeof ( jas_seqent_t ) ) ) ) { jas_matrix_destroy ( matrix ) ; return 0 ; } } for ( i = 0 ; i < numrows ; ++ i ) { matrix -> rows_ [ i ] = & matrix -> data_ [ i * matrix -> numcols_ ] ; } for ( i = 0 ; i < matrix -> datasize_ ; ++ i ) { matrix -> data_ [ i ] = 0 ; } matrix -> xstart_ = 0 ; matrix -> ystart_ = 0 ; matrix -> xend_ = matrix -> numcols_ ; matrix -> yend_ = matrix -> numrows_ ; return matrix ; } "," ; if ( numrows < 0 || numcols < 0 ) { return 0 ; } if ( ",mdadams@jasper/5d66894d2313e3f3469f19066e149e08ff076698,CVE-2016-8884,https://github.com/mdadams/jasper/commit/5d66894d2313e3f3469f19066e149e08ff076698,2017-03-28T14:59Z 548,CWE-522,"CWE-522 static TPM_RC StartAuthSession ( TSS2_SYS_CONTEXT * sapi_context , SESSION * session ) { TPM_RC rval ; TPM2B_ENCRYPTED_SECRET key ; char label [ ] = ""ATH"" ; UINT16 bytes ; int i ; key . t . size = 0 ; if ( session -> nonceOlder . t . size == 0 ) { session -> nonceOlder . t . size = GetDigestSize ( TPM_ALG_SHA1 ) ; for ( i = 0 ; i < session -> nonceOlder . t . size ; i ++ ) session -> nonceOlder . t . buffer [ i ] = 0 ; } session -> nonceNewer . t . size = session -> nonceOlder . t . size ; rval = Tss2_Sys_StartAuthSession ( sapi_context , session -> tpmKey , session -> bind , 0 , & ( session -> nonceOlder ) , & ( session -> encryptedSalt ) , session -> sessionType , & ( session -> symmetric ) , session -> authHash , & ( session -> sessionHandle ) , & ( session -> nonceNewer ) , 0 ) ; if ( rval == TPM_RC_SUCCESS ) { if ( session -> tpmKey == TPM_RH_NULL ) session -> salt . t . size = 0 ; if ( session -> bind == TPM_RH_NULL ) session -> authValueBind . t . size = 0 ; if ( session -> tpmKey == TPM_RH_NULL && session -> bind == TPM_RH_NULL ) { session -> sessionKey . b . size = 0 ; } else { bool result = string_bytes_concat_buffer ( ( TPM2B_MAX_BUFFER * ) & key , & ( session -> authValueBind . b ) ) ; if ( ! result ) { return TSS2_SYS_RC_BAD_VALUE ; } result = string_bytes_concat_buffer ( ( TPM2B_MAX_BUFFER * ) & key , & ( session -> salt . b ) ) ; if ( ! result ) { return TSS2_SYS_RC_BAD_VALUE ; } bytes = GetDigestSize ( session -> authHash ) ; if ( key . t . size == 0 ) { session -> sessionKey . t . size = 0 ; } else { rval = tpm_kdfa ( sapi_context , session -> authHash , & ( key . b ) , label , & ( session -> nonceNewer . b ) , & ( session -> nonceOlder . b ) , bytes * 8 , ( TPM2B_MAX_BUFFER * ) & ( session -> sessionKey ) ) ; } if ( rval != TPM_RC_SUCCESS ) { return ( TSS2_APP_RC_CREATE_SESSION_KEY_FAILED ) ; } } session -> nonceTpmDecrypt . b . size = 0 ; session -> nonceTpmEncrypt . b . size = 0 ; session -> nvNameChanged = 0 ; } return rval ; } "," = tpm_kdfa ( session -> authHash ",01org@tpm2.0-tools/c5d72beaab1cbbbe68271f4bc4b6670d69985157,CVE-2017-7524,https://github.com/01org/tpm2.0-tools/commit/c5d72beaab1cbbbe68271f4bc4b6670d69985157,2017-06-27T14:29Z 549,CWE-476,"CWE-476 long keyctl_read_key ( key_serial_t keyid , char __user * buffer , size_t buflen ) { struct key * key ; key_ref_t key_ref ; long ret ; key_ref = lookup_user_key ( keyid , 0 , 0 ) ; if ( IS_ERR ( key_ref ) ) { ret = - ENOKEY ; goto error ; } key = key_ref_to_ptr ( key_ref ) ; ret = key_permission ( key_ref , KEY_NEED_READ ) ; if ( ret == 0 ) goto can_read_key ; if ( ret != - EACCES ) goto error2 ; if ( ! is_key_possessed ( key_ref ) ) { ret = - EACCES ; goto error2 ; } can_read_key : ret = - EOPNOTSUPP ; if ( key -> type -> read ) { down_read ( & key -> sem ) ; ret = key_validate ( key ) ; if ( ret == 0 ) ret = key -> type -> read ( key , buffer , buflen ) ; up_read ( & key -> sem ) ; } error2 : key_put ( key ) ; error : return ret ; } "," key_ref ) ; if ( test_bit ( KEY_FLAG_NEGATIVE , & key -> flags ) ) { ret = - ENOKEY ; goto error2 ; } ",torvalds@linux/37863c43b2c6464f252862bf2e9768264e961678,CVE-2017-12192,https://github.com/torvalds/linux/commit/37863c43b2c6464f252862bf2e9768264e961678,2017-10-12T00:29Z 550,CWE-172,"CWE-172 WORD32 ih264d_video_decode ( iv_obj_t * dec_hdl , void * pv_api_ip , void * pv_api_op ) { dec_struct_t * ps_dec = ( dec_struct_t * ) ( dec_hdl -> pv_codec_handle ) ; WORD32 i4_err_status = 0 ; UWORD8 * pu1_buf = NULL ; WORD32 buflen ; UWORD32 u4_max_ofst , u4_length_of_start_code = 0 ; UWORD32 bytes_consumed = 0 ; UWORD32 cur_slice_is_nonref = 0 ; UWORD32 u4_next_is_aud ; UWORD32 u4_first_start_code_found = 0 ; WORD32 ret = 0 , api_ret_value = IV_SUCCESS ; WORD32 header_data_left = 0 , frame_data_left = 0 ; UWORD8 * pu1_bitstrm_buf ; ivd_video_decode_ip_t * ps_dec_ip ; ivd_video_decode_op_t * ps_dec_op ; ithread_set_name ( ( void * ) ""Parse_thread"" ) ; ps_dec_ip = ( ivd_video_decode_ip_t * ) pv_api_ip ; ps_dec_op = ( ivd_video_decode_op_t * ) pv_api_op ; { UWORD32 u4_size ; u4_size = ps_dec_op -> u4_size ; memset ( ps_dec_op , 0 , sizeof ( ivd_video_decode_op_t ) ) ; ps_dec_op -> u4_size = u4_size ; } ps_dec -> pv_dec_out = ps_dec_op ; if ( ps_dec -> init_done != 1 ) { return IV_FAIL ; } DATA_SYNC ( ) ; if ( 0 == ps_dec -> u1_flushfrm ) { if ( ps_dec_ip -> pv_stream_buffer == NULL ) { ps_dec_op -> u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM ; ps_dec_op -> u4_error_code |= IVD_DEC_FRM_BS_BUF_NULL ; return IV_FAIL ; } if ( ps_dec_ip -> u4_num_Bytes <= 0 ) { ps_dec_op -> u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM ; ps_dec_op -> u4_error_code |= IVD_DEC_NUMBYTES_INV ; return IV_FAIL ; } } ps_dec -> u1_pic_decode_done = 0 ; ps_dec_op -> u4_num_bytes_consumed = 0 ; ps_dec -> ps_out_buffer = NULL ; if ( ps_dec_ip -> u4_size >= offsetof ( ivd_video_decode_ip_t , s_out_buffer ) ) ps_dec -> ps_out_buffer = & ps_dec_ip -> s_out_buffer ; ps_dec -> u4_fmt_conv_cur_row = 0 ; ps_dec -> u4_output_present = 0 ; ps_dec -> s_disp_op . u4_error_code = 1 ; ps_dec -> u4_fmt_conv_num_rows = FMT_CONV_NUM_ROWS ; if ( 0 == ps_dec -> u4_share_disp_buf && ps_dec -> i4_decode_header == 0 ) { UWORD32 i ; if ( ps_dec -> ps_out_buffer -> u4_num_bufs == 0 ) { ps_dec_op -> u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM ; ps_dec_op -> u4_error_code |= IVD_DISP_FRM_ZERO_OP_BUFS ; return IV_FAIL ; } for ( i = 0 ; i < ps_dec -> ps_out_buffer -> u4_num_bufs ; i ++ ) { if ( ps_dec -> ps_out_buffer -> pu1_bufs [ i ] == NULL ) { ps_dec_op -> u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM ; ps_dec_op -> u4_error_code |= IVD_DISP_FRM_OP_BUF_NULL ; return IV_FAIL ; } if ( ps_dec -> ps_out_buffer -> u4_min_out_buf_size [ i ] == 0 ) { ps_dec_op -> u4_error_code |= 1 << IVD_UNSUPPORTEDPARAM ; ps_dec_op -> u4_error_code |= IVD_DISP_FRM_ZERO_OP_BUF_SIZE ; return IV_FAIL ; } } } if ( ps_dec -> u4_total_frames_decoded >= NUM_FRAMES_LIMIT ) { ps_dec_op -> u4_error_code = ERROR_FRAME_LIMIT_OVER ; return IV_FAIL ; } ps_dec -> u4_ts = ps_dec_ip -> u4_ts ; ps_dec_op -> u4_error_code = 0 ; ps_dec_op -> e_pic_type = - 1 ; ps_dec_op -> u4_output_present = 0 ; ps_dec_op -> u4_frame_decoded_flag = 0 ; ps_dec -> i4_frametype = - 1 ; ps_dec -> i4_content_type = - 1 ; { if ( ( TOP_FIELD_ONLY | BOT_FIELD_ONLY ) == ps_dec -> u1_top_bottom_decoded ) { ps_dec -> u1_top_bottom_decoded = 0 ; } } ps_dec -> u4_slice_start_code_found = 0 ; if ( ps_dec -> u1_init_dec_flag == 1 && ps_dec -> u4_share_disp_buf == 1 && ps_dec -> u1_flushfrm == 0 ) { UWORD32 i ; WORD32 disp_avail = 0 , free_id ; for ( i = 0 ; i < ps_dec -> u1_pic_bufs ; i ++ ) { if ( 0 == ps_dec -> u4_disp_buf_mapping [ i ] || 1 == ps_dec -> u4_disp_buf_to_be_freed [ i ] ) { disp_avail = 1 ; break ; } } if ( 0 == disp_avail ) { ps_dec_op -> u4_error_code = IVD_DEC_REF_BUF_NULL ; ps_dec_op -> u4_error_code |= ( 1 << IVD_UNSUPPORTEDPARAM ) ; return ( IV_FAIL ) ; } while ( 1 ) { pic_buffer_t * ps_pic_buf ; ps_pic_buf = ( pic_buffer_t * ) ih264_buf_mgr_get_next_free ( ( buf_mgr_t * ) ps_dec -> pv_pic_buf_mgr , & free_id ) ; if ( ps_pic_buf == NULL ) { UWORD32 i , display_queued = 0 ; for ( i = 0 ; i < ( MAX_DISP_BUFS_NEW ) ; i ++ ) { if ( 0 != ps_dec -> u4_disp_buf_mapping [ i ] ) { display_queued = 1 ; break ; } } if ( 1 == display_queued ) { ps_dec_op -> u4_error_code = IVD_DEC_REF_BUF_NULL ; ps_dec_op -> u4_error_code |= ( 1 << IVD_UNSUPPORTEDPARAM ) ; return ( IV_FAIL ) ; } } else { if ( 1 == ps_dec -> u4_disp_buf_mapping [ free_id ] ) { ih264_buf_mgr_set_status ( ( buf_mgr_t * ) ps_dec -> pv_pic_buf_mgr , free_id , BUF_MGR_IO ) ; } else { ih264_buf_mgr_release ( ( buf_mgr_t * ) ps_dec -> pv_pic_buf_mgr , free_id , BUF_MGR_IO ) ; break ; } } } } if ( ps_dec -> u1_flushfrm && ps_dec -> u1_init_dec_flag ) { ih264d_get_next_display_field ( ps_dec , ps_dec -> ps_out_buffer , & ( ps_dec -> s_disp_op ) ) ; if ( 0 == ps_dec -> s_disp_op . u4_error_code ) { ps_dec -> u4_fmt_conv_cur_row = 0 ; ps_dec -> u4_fmt_conv_num_rows = ps_dec -> s_disp_frame_info . u4_y_ht ; ih264d_format_convert ( ps_dec , & ( ps_dec -> s_disp_op ) , ps_dec -> u4_fmt_conv_cur_row , ps_dec -> u4_fmt_conv_num_rows ) ; ps_dec -> u4_fmt_conv_cur_row += ps_dec -> u4_fmt_conv_num_rows ; ps_dec -> u4_output_present = 1 ; } ih264d_release_display_field ( ps_dec , & ( ps_dec -> s_disp_op ) ) ; ps_dec_op -> u4_pic_wd = ( UWORD32 ) ps_dec -> u2_disp_width ; ps_dec_op -> u4_pic_ht = ( UWORD32 ) ps_dec -> u2_disp_height ; ps_dec_op -> u4_new_seq = 0 ; ps_dec_op -> u4_output_present = ps_dec -> u4_output_present ; ps_dec_op -> u4_progressive_frame_flag = ps_dec -> s_disp_op . u4_progressive_frame_flag ; ps_dec_op -> e_output_format = ps_dec -> s_disp_op . e_output_format ; ps_dec_op -> s_disp_frm_buf = ps_dec -> s_disp_op . s_disp_frm_buf ; ps_dec_op -> e4_fld_type = ps_dec -> s_disp_op . e4_fld_type ; ps_dec_op -> u4_ts = ps_dec -> s_disp_op . u4_ts ; ps_dec_op -> u4_disp_buf_id = ps_dec -> s_disp_op . u4_disp_buf_id ; ps_dec_op -> u4_is_ref_flag = - 1 ; ps_dec_op -> e_pic_type = IV_NA_FRAME ; ps_dec_op -> u4_frame_decoded_flag = 0 ; if ( 0 == ps_dec -> s_disp_op . u4_error_code ) { return ( IV_SUCCESS ) ; } else return ( IV_FAIL ) ; } if ( ps_dec -> u1_res_changed == 1 ) { ih264d_init_decoder ( ps_dec ) ; } ps_dec -> u4_prev_nal_skipped = 0 ; ps_dec -> u2_cur_mb_addr = 0 ; ps_dec -> u2_total_mbs_coded = 0 ; ps_dec -> u2_cur_slice_num = 0 ; ps_dec -> cur_dec_mb_num = 0 ; ps_dec -> cur_recon_mb_num = 0 ; ps_dec -> u4_first_slice_in_pic = 2 ; ps_dec -> u1_slice_header_done = 0 ; ps_dec -> u1_dangling_field = 0 ; ps_dec -> u4_dec_thread_created = 0 ; ps_dec -> u4_bs_deblk_thread_created = 0 ; ps_dec -> u4_cur_bs_mb_num = 0 ; ps_dec -> u4_start_recon_deblk = 0 ; DEBUG_THREADS_PRINTF ( ""Startingprocesscall\\n"" ) ; ps_dec -> u4_pic_buf_got = 0 ; do { WORD32 buf_size ; pu1_buf = ( UWORD8 * ) ps_dec_ip -> pv_stream_buffer + ps_dec_op -> u4_num_bytes_consumed ; u4_max_ofst = ps_dec_ip -> u4_num_Bytes - ps_dec_op -> u4_num_bytes_consumed ; if ( ( NULL == ps_dec -> pu1_bits_buf_dynamic ) && ( ps_dec -> i4_header_decoded & 1 ) ) { WORD32 size ; void * pv_buf ; void * pv_mem_ctxt = ps_dec -> pv_mem_ctxt ; size = MAX ( 256000 , ps_dec -> u2_pic_wd * ps_dec -> u2_pic_ht * 3 / 2 ) ; pv_buf = ps_dec -> pf_aligned_alloc ( pv_mem_ctxt , 128 , size ) ; RETURN_IF ( ( NULL == pv_buf ) , IV_FAIL ) ; ps_dec -> pu1_bits_buf_dynamic = pv_buf ; ps_dec -> u4_dynamic_bits_buf_size = size ; } if ( ps_dec -> pu1_bits_buf_dynamic ) { pu1_bitstrm_buf = ps_dec -> pu1_bits_buf_dynamic ; buf_size = ps_dec -> u4_dynamic_bits_buf_size ; } else { pu1_bitstrm_buf = ps_dec -> pu1_bits_buf_static ; buf_size = ps_dec -> u4_static_bits_buf_size ; } u4_next_is_aud = 0 ; buflen = ih264d_find_start_code ( pu1_buf , 0 , u4_max_ofst , & u4_length_of_start_code , & u4_next_is_aud ) ; if ( buflen == - 1 ) buflen = 0 ; buflen = MIN ( buflen , buf_size ) ; bytes_consumed = buflen + u4_length_of_start_code ; ps_dec_op -> u4_num_bytes_consumed += bytes_consumed ; { UWORD8 u1_firstbyte , u1_nal_ref_idc ; if ( ps_dec -> i4_app_skip_mode == IVD_SKIP_B ) { u1_firstbyte = * ( pu1_buf + u4_length_of_start_code ) ; u1_nal_ref_idc = ( UWORD8 ) ( NAL_REF_IDC ( u1_firstbyte ) ) ; if ( u1_nal_ref_idc == 0 ) { cur_slice_is_nonref = 1 ; continue ; } else { if ( 1 == cur_slice_is_nonref ) { ps_dec_op -> u4_num_bytes_consumed -= bytes_consumed ; ps_dec_op -> e_pic_type = IV_B_FRAME ; ps_dec_op -> u4_error_code = IVD_DEC_FRM_SKIPPED ; ps_dec_op -> u4_error_code |= ( 1 << IVD_UNSUPPORTEDPARAM ) ; ps_dec_op -> u4_frame_decoded_flag = 0 ; ps_dec_op -> u4_size = sizeof ( ivd_video_decode_op_t ) ; ih264d_signal_decode_thread ( ps_dec ) ; if ( ps_dec -> u4_num_cores == 3 ) { ih264d_signal_bs_deblk_thread ( ps_dec ) ; } return ( IV_FAIL ) ; } } } } if ( buflen ) { memcpy ( pu1_bitstrm_buf , pu1_buf + u4_length_of_start_code , buflen ) ; if ( ( buflen + 8 ) < buf_size ) { memset ( pu1_bitstrm_buf + buflen , 0 , 8 ) ; } u4_first_start_code_found = 1 ; } else { if ( u4_first_start_code_found == 0 ) { ps_dec -> i4_error_code = ERROR_START_CODE_NOT_FOUND ; ps_dec_op -> u4_error_code |= 1 << IVD_INSUFFICIENTDATA ; if ( ps_dec -> u4_pic_buf_got == 0 ) { ih264d_fill_output_struct_from_context ( ps_dec , ps_dec_op ) ; ps_dec_op -> u4_error_code = ps_dec -> i4_error_code ; ps_dec_op -> u4_frame_decoded_flag = 0 ; return ( IV_FAIL ) ; } else { ps_dec -> u1_pic_decode_done = 1 ; continue ; } } else { frame_data_left = 0 ; continue ; } } ps_dec -> u4_return_to_app = 0 ; ret = ih264d_parse_nal_unit ( dec_hdl , ps_dec_op , pu1_bitstrm_buf , buflen ) ; if ( ret != OK ) { UWORD32 error = ih264d_map_error ( ret ) ; ps_dec_op -> u4_error_code = error | ret ; api_ret_value = IV_FAIL ; if ( ( ret == IVD_RES_CHANGED ) || ( ret == IVD_MEM_ALLOC_FAILED ) || ( ret == ERROR_UNAVAIL_PICBUF_T ) || ( ret == ERROR_UNAVAIL_MVBUF_T ) ) { break ; } if ( ( ret == ERROR_INCOMPLETE_FRAME ) || ( ret == ERROR_DANGLING_FIELD_IN_PIC ) ) { ps_dec_op -> u4_num_bytes_consumed -= bytes_consumed ; api_ret_value = IV_FAIL ; break ; } if ( ret == ERROR_IN_LAST_SLICE_OF_PIC ) { api_ret_value = IV_FAIL ; break ; } } if ( ps_dec -> u4_return_to_app ) { ps_dec_op -> u4_num_bytes_consumed -= bytes_consumed ; ps_dec_op -> u4_error_code = IVD_DEC_FRM_SKIPPED ; ps_dec_op -> u4_error_code |= ( 1 << IVD_UNSUPPORTEDPARAM ) ; ps_dec_op -> u4_frame_decoded_flag = 0 ; ps_dec_op -> u4_size = sizeof ( ivd_video_decode_op_t ) ; ih264d_signal_decode_thread ( ps_dec ) ; if ( ps_dec -> u4_num_cores == 3 ) { ih264d_signal_bs_deblk_thread ( ps_dec ) ; } return ( IV_FAIL ) ; } header_data_left = ( ( ps_dec -> i4_decode_header == 1 ) && ( ps_dec -> i4_header_decoded != 3 ) && ( ps_dec_op -> u4_num_bytes_consumed < ps_dec_ip -> u4_num_Bytes ) ) ; frame_data_left = ( ( ( ps_dec -> i4_decode_header == 0 ) && ( ( ps_dec -> u1_pic_decode_done == 0 ) || ( u4_next_is_aud == 1 ) ) ) && ( ps_dec_op -> u4_num_bytes_consumed < ps_dec_ip -> u4_num_Bytes ) ) ; } while ( ( header_data_left == 1 ) || ( frame_data_left == 1 ) ) ; if ( ( ps_dec -> u4_slice_start_code_found == 1 ) && ( ret != IVD_MEM_ALLOC_FAILED ) && ps_dec -> u2_total_mbs_coded < ps_dec -> u2_frm_ht_in_mbs * ps_dec -> u2_frm_wd_in_mbs ) { WORD32 num_mb_skipped ; WORD32 prev_slice_err ; pocstruct_t temp_poc ; WORD32 ret1 ; num_mb_skipped = ( ps_dec -> u2_frm_ht_in_mbs * ps_dec -> u2_frm_wd_in_mbs ) - ps_dec -> u2_total_mbs_coded ; if ( ps_dec -> u4_first_slice_in_pic && ( ps_dec -> u4_pic_buf_got == 0 ) ) prev_slice_err = 1 ; else prev_slice_err = 2 ; ret1 = ih264d_mark_err_slice_skip ( ps_dec , num_mb_skipped , ps_dec -> u1_nal_unit_type == IDR_SLICE_NAL , ps_dec -> ps_cur_slice -> u2_frame_num , & temp_poc , prev_slice_err ) ; if ( ( ret1 == ERROR_UNAVAIL_PICBUF_T ) || ( ret1 == ERROR_UNAVAIL_MVBUF_T ) ) { return IV_FAIL ; } } if ( ( ret == IVD_RES_CHANGED ) || ( ret == IVD_MEM_ALLOC_FAILED ) || ( ret == ERROR_UNAVAIL_PICBUF_T ) || ( ret == ERROR_UNAVAIL_MVBUF_T ) ) { ih264d_signal_decode_thread ( ps_dec ) ; if ( ps_dec -> u4_num_cores == 3 ) { ih264d_signal_bs_deblk_thread ( ps_dec ) ; } if ( ret == IVD_RES_CHANGED ) { ps_dec_op -> u4_num_bytes_consumed -= bytes_consumed ; } return IV_FAIL ; } if ( ps_dec -> u1_separate_parse ) { if ( ps_dec -> u4_num_cores == 2 ) { if ( ( ps_dec -> u4_nmb_deblk == 0 ) && ( ps_dec -> u4_start_recon_deblk == 1 ) && ( ps_dec -> ps_cur_sps -> u1_mb_aff_flag == 0 ) ) { UWORD32 u4_num_mbs , u4_max_addr ; tfr_ctxt_t s_tfr_ctxt ; tfr_ctxt_t * ps_tfr_cxt = & s_tfr_ctxt ; pad_mgr_t * ps_pad_mgr = & ps_dec -> s_pad_mgr ; u4_max_addr = ( ps_dec -> u2_frm_wd_in_mbs * ps_dec -> u2_frm_ht_in_mbs ) - 1 ; ps_dec -> u4_cur_bs_mb_num = u4_max_addr + 1 ; ih264d_init_deblk_tfr_ctxt ( ps_dec , ps_pad_mgr , ps_tfr_cxt , ps_dec -> u2_frm_wd_in_mbs , 0 ) ; u4_num_mbs = u4_max_addr - ps_dec -> u4_cur_deblk_mb_num + 1 ; DEBUG_PERF_PRINTF ( ""mbsleftfordeblocking=%d\\n"" , u4_num_mbs ) ; if ( u4_num_mbs != 0 ) ih264d_check_mb_map_deblk ( ps_dec , u4_num_mbs , ps_tfr_cxt , 1 ) ; ps_dec -> u4_start_recon_deblk = 0 ; } } ih264d_signal_decode_thread ( ps_dec ) ; if ( ps_dec -> u4_num_cores == 3 ) { ih264d_signal_bs_deblk_thread ( ps_dec ) ; } } DATA_SYNC ( ) ; if ( ( ps_dec_op -> u4_error_code & 0xff ) != ERROR_DYNAMIC_RESOLUTION_NOT_SUPPORTED ) { ps_dec_op -> u4_pic_wd = ( UWORD32 ) ps_dec -> u2_disp_width ; ps_dec_op -> u4_pic_ht = ( UWORD32 ) ps_dec -> u2_disp_height ; } if ( ps_dec -> i4_header_decoded != 3 ) { ps_dec_op -> u4_error_code |= ( 1 << IVD_INSUFFICIENTDATA ) ; } if ( ps_dec -> i4_decode_header == 1 && ps_dec -> i4_header_decoded != 3 ) { ps_dec_op -> u4_error_code |= ( 1 << IVD_INSUFFICIENTDATA ) ; } if ( ps_dec -> u4_prev_nal_skipped ) { ps_dec_op -> u4_error_code = IVD_DEC_FRM_SKIPPED ; ps_dec_op -> u4_error_code |= ( 1 << IVD_UNSUPPORTEDPARAM ) ; ps_dec_op -> u4_frame_decoded_flag = 0 ; ps_dec_op -> u4_size = sizeof ( ivd_video_decode_op_t ) ; if ( ps_dec -> u4_num_cores == 3 ) { ih264d_signal_bs_deblk_thread ( ps_dec ) ; } return ( IV_FAIL ) ; } if ( ( ps_dec -> u4_slice_start_code_found == 1 ) && ( ERROR_DANGLING_FIELD_IN_PIC != i4_err_status ) ) { if ( ps_dec -> ps_cur_slice -> u1_field_pic_flag ) { if ( 1 == ps_dec -> ps_cur_slice -> u1_bottom_field_flag ) { ps_dec -> u1_top_bottom_decoded |= BOT_FIELD_ONLY ; } else { ps_dec -> u1_top_bottom_decoded |= TOP_FIELD_ONLY ; } } if ( ( ps_dec -> ps_dec_err_status -> u1_err_flag & REJECT_CUR_PIC ) == 0 ) { ret = ih264d_deblock_display ( ps_dec ) ; if ( ret != 0 ) { return IV_FAIL ; } } if ( ps_dec -> i4_header_decoded == 3 ) { ps_dec -> u2_total_mbs_coded = ps_dec -> ps_cur_sps -> u2_max_mb_addr + 1 ; } if ( ps_dec -> ps_cur_slice -> u1_nal_unit_type == IDR_SLICE_NAL ) { ps_dec -> i4_frametype = IV_IDR_FRAME ; } else if ( ps_dec -> i4_pic_type == B_SLICE ) { ps_dec -> i4_frametype = IV_B_FRAME ; } else if ( ps_dec -> i4_pic_type == P_SLICE ) { ps_dec -> i4_frametype = IV_P_FRAME ; } else if ( ps_dec -> i4_pic_type == I_SLICE ) { ps_dec -> i4_frametype = IV_I_FRAME ; } else { H264_DEC_DEBUG_PRINT ( ""Shouldn\'tcomehere\\n"" ) ; } ps_dec -> i4_content_type = ps_dec -> ps_cur_slice -> u1_field_pic_flag ; ps_dec -> u4_total_frames_decoded = ps_dec -> u4_total_frames_decoded + 2 ; ps_dec -> u4_total_frames_decoded = ps_dec -> u4_total_frames_decoded - ps_dec -> ps_cur_slice -> u1_field_pic_flag ; } if ( ps_dec -> u4_num_cores == 3 ) { ih264d_signal_bs_deblk_thread ( ps_dec ) ; } { if ( ( IVD_DECODE_FRAME_OUT == ps_dec -> e_frm_out_mode ) && ps_dec -> u1_init_dec_flag ) { ih264d_get_next_display_field ( ps_dec , ps_dec -> ps_out_buffer , & ( ps_dec -> s_disp_op ) ) ; if ( 0 == ps_dec -> s_disp_op . u4_error_code ) { ps_dec -> u4_fmt_conv_cur_row = 0 ; ps_dec -> u4_output_present = 1 ; } } ih264d_fill_output_struct_from_context ( ps_dec , ps_dec_op ) ; if ( ps_dec -> u4_output_present && ( ps_dec -> u4_fmt_conv_cur_row < ps_dec -> s_disp_frame_info . u4_y_ht ) ) { ps_dec -> u4_fmt_conv_num_rows = ps_dec -> s_disp_frame_info . u4_y_ht - ps_dec -> u4_fmt_conv_cur_row ; ih264d_format_convert ( ps_dec , & ( ps_dec -> s_disp_op ) , ps_dec -> u4_fmt_conv_cur_row , ps_dec -> u4_fmt_conv_num_rows ) ; ps_dec -> u4_fmt_conv_cur_row += ps_dec -> u4_fmt_conv_num_rows ; } ih264d_release_display_field ( ps_dec , & ( ps_dec -> s_disp_op ) ) ; } if ( ps_dec -> i4_decode_header == 1 && ( ps_dec -> i4_header_decoded & 1 ) == 1 ) { ps_dec_op -> u4_progressive_frame_flag = 1 ; if ( ( NULL != ps_dec -> ps_cur_sps ) && ( 1 == ( ps_dec -> ps_cur_sps -> u1_is_valid ) ) ) { if ( ( 0 == ps_dec -> ps_sps -> u1_frame_mbs_only_flag ) && ( 0 == ps_dec -> ps_sps -> u1_mb_aff_flag ) ) ps_dec_op -> u4_progressive_frame_flag = 0 ; } } DATA_SYNC ( ) ; H264_DEC_DEBUG_PRINT ( ""Thenumbytesconsumed:%d\\n"" , ps_dec_op -> u4_num_bytes_consumed ) ; return api_ret_value ; } "," == ERROR_UNAVAIL_MVBUF_T ) || ( ret == ERROR_INV_SPS_PPS_T ) ) { ps_dec -> u4_slice_start_code_found = 0 ; break ; } == ERROR_UNAVAIL_MVBUF_T ) || ( ret == ERROR_INV_SPS_PPS_T ) ",external@libavc/7554755536019e439433c515eeb44e701fb3bfb2,CVE-2016-3828,https://android.googlesource.com/platform/external/libavc/+/7554755536019e439433c515eeb44e701fb3bfb2,2016-08-05T20:59Z 551,CWE-190,"CWE-190 static int adjust_scalar_min_max_vals ( struct bpf_verifier_env * env , struct bpf_insn * insn , struct bpf_reg_state * dst_reg , struct bpf_reg_state src_reg ) { struct bpf_reg_state * regs = cur_regs ( env ) ; u8 opcode = BPF_OP ( insn -> code ) ; bool src_known , dst_known ; s64 smin_val , smax_val ; u64 umin_val , umax_val ; u64 insn_bitness = ( BPF_CLASS ( insn -> code ) == BPF_ALU64 ) ? 64 : 32 ; smin_val = src_reg . smin_value ; smax_val = src_reg . smax_value ; umin_val = src_reg . umin_value ; umax_val = src_reg . umax_value ; src_known = tnum_is_const ( src_reg . var_off ) ; dst_known = tnum_is_const ( dst_reg -> var_off ) ; switch ( opcode ) { case BPF_ADD : if ( signed_add_overflows ( dst_reg -> smin_value , smin_val ) || signed_add_overflows ( dst_reg -> smax_value , smax_val ) ) { dst_reg -> smin_value = S64_MIN ; dst_reg -> smax_value = S64_MAX ; } else { dst_reg -> smin_value += smin_val ; dst_reg -> smax_value += smax_val ; } if ( dst_reg -> umin_value + umin_val < umin_val || dst_reg -> umax_value + umax_val < umax_val ) { dst_reg -> umin_value = 0 ; dst_reg -> umax_value = U64_MAX ; } else { dst_reg -> umin_value += umin_val ; dst_reg -> umax_value += umax_val ; } dst_reg -> var_off = tnum_add ( dst_reg -> var_off , src_reg . var_off ) ; break ; case BPF_SUB : if ( signed_sub_overflows ( dst_reg -> smin_value , smax_val ) || signed_sub_overflows ( dst_reg -> smax_value , smin_val ) ) { dst_reg -> smin_value = S64_MIN ; dst_reg -> smax_value = S64_MAX ; } else { dst_reg -> smin_value -= smax_val ; dst_reg -> smax_value -= smin_val ; } if ( dst_reg -> umin_value < umax_val ) { dst_reg -> umin_value = 0 ; dst_reg -> umax_value = U64_MAX ; } else { dst_reg -> umin_value -= umax_val ; dst_reg -> umax_value -= umin_val ; } dst_reg -> var_off = tnum_sub ( dst_reg -> var_off , src_reg . var_off ) ; break ; case BPF_MUL : dst_reg -> var_off = tnum_mul ( dst_reg -> var_off , src_reg . var_off ) ; if ( smin_val < 0 || dst_reg -> smin_value < 0 ) { __mark_reg_unbounded ( dst_reg ) ; __update_reg_bounds ( dst_reg ) ; break ; } if ( umax_val > U32_MAX || dst_reg -> umax_value > U32_MAX ) { __mark_reg_unbounded ( dst_reg ) ; __update_reg_bounds ( dst_reg ) ; break ; } dst_reg -> umin_value *= umin_val ; dst_reg -> umax_value *= umax_val ; if ( dst_reg -> umax_value > S64_MAX ) { dst_reg -> smin_value = S64_MIN ; dst_reg -> smax_value = S64_MAX ; } else { dst_reg -> smin_value = dst_reg -> umin_value ; dst_reg -> smax_value = dst_reg -> umax_value ; } break ; case BPF_AND : if ( src_known && dst_known ) { __mark_reg_known ( dst_reg , dst_reg -> var_off . value & src_reg . var_off . value ) ; break ; } dst_reg -> var_off = tnum_and ( dst_reg -> var_off , src_reg . var_off ) ; dst_reg -> umin_value = dst_reg -> var_off . value ; dst_reg -> umax_value = min ( dst_reg -> umax_value , umax_val ) ; if ( dst_reg -> smin_value < 0 || smin_val < 0 ) { dst_reg -> smin_value = S64_MIN ; dst_reg -> smax_value = S64_MAX ; } else { dst_reg -> smin_value = dst_reg -> umin_value ; dst_reg -> smax_value = dst_reg -> umax_value ; } __update_reg_bounds ( dst_reg ) ; break ; case BPF_OR : if ( src_known && dst_known ) { __mark_reg_known ( dst_reg , dst_reg -> var_off . value | src_reg . var_off . value ) ; break ; } dst_reg -> var_off = tnum_or ( dst_reg -> var_off , src_reg . var_off ) ; dst_reg -> umin_value = max ( dst_reg -> umin_value , umin_val ) ; dst_reg -> umax_value = dst_reg -> var_off . value | dst_reg -> var_off . mask ; if ( dst_reg -> smin_value < 0 || smin_val < 0 ) { dst_reg -> smin_value = S64_MIN ; dst_reg -> smax_value = S64_MAX ; } else { dst_reg -> smin_value = dst_reg -> umin_value ; dst_reg -> smax_value = dst_reg -> umax_value ; } __update_reg_bounds ( dst_reg ) ; break ; case BPF_LSH : if ( umax_val >= insn_bitness ) { mark_reg_unknown ( env , regs , insn -> dst_reg ) ; break ; } dst_reg -> smin_value = S64_MIN ; dst_reg -> smax_value = S64_MAX ; if ( dst_reg -> umax_value > 1ULL << ( 63 - umax_val ) ) { dst_reg -> umin_value = 0 ; dst_reg -> umax_value = U64_MAX ; } else { dst_reg -> umin_value <<= umin_val ; dst_reg -> umax_value <<= umax_val ; } if ( src_known ) dst_reg -> var_off = tnum_lshift ( dst_reg -> var_off , umin_val ) ; else dst_reg -> var_off = tnum_lshift ( tnum_unknown , umin_val ) ; __update_reg_bounds ( dst_reg ) ; break ; case BPF_RSH : if ( umax_val >= insn_bitness ) { mark_reg_unknown ( env , regs , insn -> dst_reg ) ; break ; } dst_reg -> smin_value = S64_MIN ; dst_reg -> smax_value = S64_MAX ; if ( src_known ) dst_reg -> var_off = tnum_rshift ( dst_reg -> var_off , umin_val ) ; else dst_reg -> var_off = tnum_rshift ( tnum_unknown , umin_val ) ; dst_reg -> umin_value >>= umax_val ; dst_reg -> umax_value >>= umin_val ; __update_reg_bounds ( dst_reg ) ; break ; default : mark_reg_unknown ( env , regs , insn -> dst_reg ) ; break ; } if ( BPF_CLASS ( insn -> code ) != BPF_ALU64 ) { coerce_reg_to_size ( dst_reg , 4 ) ; coerce_reg_to_size ( & src_reg , 4 ) ; } __reg_deduce_bounds ( dst_reg ) ; __reg_bound_offset ( dst_reg ) ; return 0 ; } "," var_off ) ; if ( ! src_known && opcode != BPF_ADD && opcode != BPF_SUB && opcode != BPF_AND ) { __mark_reg_unknown ( dst_reg ) ; return 0 ; } ",torvalds@linux/bb7f0f989ca7de1153bd128a40a71709e339fa03,CVE-2017-17854,https://github.com/torvalds/linux/commit/bb7f0f989ca7de1153bd128a40a71709e339fa03,2017-12-27T17:08Z 552,CWE-264,"CWE-264 struct dentry * cifs_lookup ( struct inode * parent_dir_inode , struct dentry * direntry , struct nameidata * nd ) { int xid ; int rc = 0 ; __u32 oplock = enable_oplocks ? REQ_OPLOCK : 0 ; __u16 fileHandle = 0 ; bool posix_open = false ; struct cifs_sb_info * cifs_sb ; struct tcon_link * tlink ; struct cifs_tcon * pTcon ; struct cifsFileInfo * cfile ; struct inode * newInode = NULL ; char * full_path = NULL ; struct file * filp ; xid = GetXid ( ) ; cFYI ( 1 , ""parentinode=0x%pnameis:%sanddentry=0x%p"" , parent_dir_inode , direntry -> d_name . name , direntry ) ; cifs_sb = CIFS_SB ( parent_dir_inode -> i_sb ) ; tlink = cifs_sb_tlink ( cifs_sb ) ; if ( IS_ERR ( tlink ) ) { FreeXid ( xid ) ; return ( struct dentry * ) tlink ; } pTcon = tlink_tcon ( tlink ) ; if ( ! ( cifs_sb -> mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS ) ) { int i ; for ( i = 0 ; i < direntry -> d_name . len ; i ++ ) if ( direntry -> d_name . name [ i ] == '\\\\' ) { cFYI ( 1 , ""Invalidfilename"" ) ; rc = - EINVAL ; goto lookup_out ; } } if ( nd && ( nd -> flags & LOOKUP_EXCL ) ) { d_instantiate ( direntry , NULL ) ; rc = 0 ; goto lookup_out ; } full_path = build_path_from_dentry ( direntry ) ; if ( full_path == NULL ) { rc = - ENOMEM ; goto lookup_out ; } if ( direntry -> d_inode != NULL ) { cFYI ( 1 , ""non-NULLinodeinlookup"" ) ; } else { cFYI ( 1 , ""NULLinodeinlookup"" ) ; } cFYI ( 1 , ""Fullpath:%sinode=0x%p"" , full_path , direntry -> d_inode ) ; if ( pTcon -> unix_ext ) { if ( nd && ! ( nd -> flags & LOOKUP_DIRECTORY ) && ( nd -> flags & LOOKUP_OPEN ) && ! pTcon -> broken_posix_open && ( nd -> intent . open . file -> f_flags & O_CREAT ) ) { rc = cifs_posix_open ( full_path , & newInode , parent_dir_inode -> i_sb , nd -> intent . open . create_mode , nd -> intent . open . file -> f_flags , & oplock , & fileHandle , xid ) ; if ( ( rc == 0 ) || ( rc == - ENOENT ) ) posix_open = true ; else if ( ( rc == - EINVAL ) || ( rc != - EOPNOTSUPP ) ) pTcon -> broken_posix_open = true ; } if ( ! posix_open ) rc = cifs_get_inode_info_unix ( & newInode , full_path , parent_dir_inode -> i_sb , xid ) ; } else rc = cifs_get_inode_info ( & newInode , full_path , NULL , parent_dir_inode -> i_sb , xid , NULL ) ; if ( ( rc == 0 ) && ( newInode != NULL ) ) { d_add ( direntry , newInode ) ; if ( posix_open ) { filp = lookup_instantiate_filp ( nd , direntry , generic_file_open ) ; if ( IS_ERR ( filp ) ) { rc = PTR_ERR ( filp ) ; CIFSSMBClose ( xid , pTcon , fileHandle ) ; goto lookup_out ; } cfile = cifs_new_fileinfo ( fileHandle , filp , tlink , oplock ) ; if ( cfile == NULL ) { fput ( filp ) ; CIFSSMBClose ( xid , pTcon , fileHandle ) ; rc = - ENOMEM ; goto lookup_out ; } } renew_parental_timestamps ( direntry ) ; } else if ( rc == - ENOENT ) { rc = 0 ; direntry -> d_time = jiffies ; d_add ( direntry , NULL ) ; } else if ( rc != - EACCES ) { cERROR ( 1 , ""Unexpectedlookuperror%d"" , rc ) ; } lookup_out : kfree ( full_path ) ; cifs_put_tlink ( tlink ) ; FreeXid ( xid ) ; return ERR_PTR ( rc ) ; } "," xid ) ; switch ( rc ) { case 0 : if ( newInode && ! S_ISREG ( newInode -> i_mode ) ) { CIFSSMBClose ( xid , pTcon , fileHandle ) ; break ; } case - ENOENT : posix_open = true ; case - EOPNOTSUPP : break ; default : pTcon -> broken_posix_open = true ; } } if ( ! posix_open ) rc = cifs_get_inode_info_unix ( & newInode , full_path , parent_dir_inode -> i_sb , xid ) ; } else rc = cifs_get_inode_info ( & newInode , full_path , NULL , parent_dir_inode -> i_sb , xid , NULL ) ; == 0 ) && ( newInode != NULL ) ) { d_add ( direntry , newInode ) ; if ( posix_open ) { filp = lookup_instantiate_filp ( nd , direntry , generic_file_open ) ; if ( IS_ERR ( filp ) ) { rc = PTR_ERR ( filp ) ; CIFSSMBClose ( xid , pTcon , fileHandle ) ; goto lookup_out ; } cfile = cifs_new_fileinfo ( fileHandle , filp , tlink , oplock ) ; if ( cfile == NULL ) { fput ( filp ) ; CIFSSMBClose ( xid , pTcon , fileHandle ) ; rc = - ENOMEM ; goto lookup_out ; } } renew_parental_timestamps ( direntry ) ; } else if ( rc == - ENOENT ) { rc = ",torvalds@linux/88d7d4e4a439f32acc56a6d860e415ee71d3df08,CVE-2012-1090,https://github.com/torvalds/linux/commit/88d7d4e4a439f32acc56a6d860e415ee71d3df08,2012-05-17T11:00Z 553,CWE-190,"CWE-190 static long vfio_pci_ioctl ( void * device_data , unsigned int cmd , unsigned long arg ) { struct vfio_pci_device * vdev = device_data ; unsigned long minsz ; if ( cmd == VFIO_DEVICE_GET_INFO ) { struct vfio_device_info info ; minsz = offsetofend ( struct vfio_device_info , num_irqs ) ; if ( copy_from_user ( & info , ( void __user * ) arg , minsz ) ) return - EFAULT ; if ( info . argsz < minsz ) return - EINVAL ; info . flags = VFIO_DEVICE_FLAGS_PCI ; if ( vdev -> reset_works ) info . flags |= VFIO_DEVICE_FLAGS_RESET ; info . num_regions = VFIO_PCI_NUM_REGIONS + vdev -> num_regions ; info . num_irqs = VFIO_PCI_NUM_IRQS ; return copy_to_user ( ( void __user * ) arg , & info , minsz ) ? - EFAULT : 0 ; } else if ( cmd == VFIO_DEVICE_GET_REGION_INFO ) { struct pci_dev * pdev = vdev -> pdev ; struct vfio_region_info info ; struct vfio_info_cap caps = { . buf = NULL , . size = 0 } ; int i , ret ; minsz = offsetofend ( struct vfio_region_info , offset ) ; if ( copy_from_user ( & info , ( void __user * ) arg , minsz ) ) return - EFAULT ; if ( info . argsz < minsz ) return - EINVAL ; switch ( info . index ) { case VFIO_PCI_CONFIG_REGION_INDEX : info . offset = VFIO_PCI_INDEX_TO_OFFSET ( info . index ) ; info . size = pdev -> cfg_size ; info . flags = VFIO_REGION_INFO_FLAG_READ | VFIO_REGION_INFO_FLAG_WRITE ; break ; case VFIO_PCI_BAR0_REGION_INDEX ... VFIO_PCI_BAR5_REGION_INDEX : info . offset = VFIO_PCI_INDEX_TO_OFFSET ( info . index ) ; info . size = pci_resource_len ( pdev , info . index ) ; if ( ! info . size ) { info . flags = 0 ; break ; } info . flags = VFIO_REGION_INFO_FLAG_READ | VFIO_REGION_INFO_FLAG_WRITE ; if ( vdev -> bar_mmap_supported [ info . index ] ) { info . flags |= VFIO_REGION_INFO_FLAG_MMAP ; if ( info . index == vdev -> msix_bar ) { ret = msix_sparse_mmap_cap ( vdev , & caps ) ; if ( ret ) return ret ; } } break ; case VFIO_PCI_ROM_REGION_INDEX : { void __iomem * io ; size_t size ; info . offset = VFIO_PCI_INDEX_TO_OFFSET ( info . index ) ; info . flags = 0 ; info . size = pci_resource_len ( pdev , info . index ) ; if ( ! info . size ) { if ( pdev -> resource [ PCI_ROM_RESOURCE ] . flags & IORESOURCE_ROM_SHADOW ) info . size = 0x20000 ; else break ; } io = pci_map_rom ( pdev , & size ) ; if ( ! io || ! size ) { info . size = 0 ; break ; } pci_unmap_rom ( pdev , io ) ; info . flags = VFIO_REGION_INFO_FLAG_READ ; break ; } case VFIO_PCI_VGA_REGION_INDEX : if ( ! vdev -> has_vga ) return - EINVAL ; info . offset = VFIO_PCI_INDEX_TO_OFFSET ( info . index ) ; info . size = 0xc0000 ; info . flags = VFIO_REGION_INFO_FLAG_READ | VFIO_REGION_INFO_FLAG_WRITE ; break ; default : if ( info . index >= VFIO_PCI_NUM_REGIONS + vdev -> num_regions ) return - EINVAL ; i = info . index - VFIO_PCI_NUM_REGIONS ; info . offset = VFIO_PCI_INDEX_TO_OFFSET ( info . index ) ; info . size = vdev -> region [ i ] . size ; info . flags = vdev -> region [ i ] . flags ; ret = region_type_cap ( vdev , & caps , vdev -> region [ i ] . type , vdev -> region [ i ] . subtype ) ; if ( ret ) return ret ; } if ( caps . size ) { info . flags |= VFIO_REGION_INFO_FLAG_CAPS ; if ( info . argsz < sizeof ( info ) + caps . size ) { info . argsz = sizeof ( info ) + caps . size ; info . cap_offset = 0 ; } else { vfio_info_cap_shift ( & caps , sizeof ( info ) ) ; if ( copy_to_user ( ( void __user * ) arg + sizeof ( info ) , caps . buf , caps . size ) ) { kfree ( caps . buf ) ; return - EFAULT ; } info . cap_offset = sizeof ( info ) ; } kfree ( caps . buf ) ; } return copy_to_user ( ( void __user * ) arg , & info , minsz ) ? - EFAULT : 0 ; } else if ( cmd == VFIO_DEVICE_GET_IRQ_INFO ) { struct vfio_irq_info info ; minsz = offsetofend ( struct vfio_irq_info , count ) ; if ( copy_from_user ( & info , ( void __user * ) arg , minsz ) ) return - EFAULT ; if ( info . argsz < minsz || info . index >= VFIO_PCI_NUM_IRQS ) return - EINVAL ; switch ( info . index ) { case VFIO_PCI_INTX_IRQ_INDEX ... VFIO_PCI_MSIX_IRQ_INDEX : case VFIO_PCI_REQ_IRQ_INDEX : break ; case VFIO_PCI_ERR_IRQ_INDEX : if ( pci_is_pcie ( vdev -> pdev ) ) break ; default : return - EINVAL ; } info . flags = VFIO_IRQ_INFO_EVENTFD ; info . count = vfio_pci_get_irq_count ( vdev , info . index ) ; if ( info . index == VFIO_PCI_INTX_IRQ_INDEX ) info . flags |= ( VFIO_IRQ_INFO_MASKABLE | VFIO_IRQ_INFO_AUTOMASKED ) ; else info . flags |= VFIO_IRQ_INFO_NORESIZE ; return copy_to_user ( ( void __user * ) arg , & info , minsz ) ? - EFAULT : 0 ; } else if ( cmd == VFIO_DEVICE_SET_IRQS ) { struct vfio_irq_set hdr ; u8 * data = NULL ; int ret = 0 ; minsz = offsetofend ( struct vfio_irq_set , count ) ; if ( copy_from_user ( & hdr , ( void __user * ) arg , minsz ) ) return - EFAULT ; if ( hdr . argsz < minsz || hdr . index >= VFIO_PCI_NUM_IRQS || hdr . flags & ~ ( VFIO_IRQ_SET_DATA_TYPE_MASK | VFIO_IRQ_SET_ACTION_TYPE_MASK ) ) return - EINVAL ; if ( ! ( hdr . flags & VFIO_IRQ_SET_DATA_NONE ) ) { size_t size ; int max = vfio_pci_get_irq_count ( vdev , hdr . index ) ; if ( hdr . flags & VFIO_IRQ_SET_DATA_BOOL ) size = sizeof ( uint8_t ) ; else if ( hdr . flags & VFIO_IRQ_SET_DATA_EVENTFD ) size = sizeof ( int32_t ) ; else return - EINVAL ; if ( hdr . argsz - minsz < hdr . count * size || hdr . start >= max || hdr . start + hdr . count > max ) return - EINVAL ; data = memdup_user ( ( void __user * ) ( arg + minsz ) , hdr . count * size ) ; if ( IS_ERR ( data ) ) return PTR_ERR ( data ) ; } mutex_lock ( & vdev -> igate ) ; ret = vfio_pci_set_irqs_ioctl ( vdev , hdr . flags , hdr . index , hdr . start , hdr . count , data ) ; mutex_unlock ( & vdev -> igate ) ; kfree ( data ) ; return ret ; } else if ( cmd == VFIO_DEVICE_RESET ) { return vdev -> reset_works ? pci_try_reset_function ( vdev -> pdev ) : - EINVAL ; } else if ( cmd == VFIO_DEVICE_GET_PCI_HOT_RESET_INFO ) { struct vfio_pci_hot_reset_info hdr ; struct vfio_pci_fill_info fill = { 0 } ; struct vfio_pci_dependent_device * devices = NULL ; bool slot = false ; int ret = 0 ; minsz = offsetofend ( struct vfio_pci_hot_reset_info , count ) ; if ( copy_from_user ( & hdr , ( void __user * ) arg , minsz ) ) return - EFAULT ; if ( hdr . argsz < minsz ) return - EINVAL ; hdr . flags = 0 ; if ( ! pci_probe_reset_slot ( vdev -> pdev -> slot ) ) slot = true ; else if ( pci_probe_reset_bus ( vdev -> pdev -> bus ) ) return - ENODEV ; ret = vfio_pci_for_each_slot_or_bus ( vdev -> pdev , vfio_pci_count_devs , & fill . max , slot ) ; if ( ret ) return ret ; WARN_ON ( ! fill . max ) ; if ( hdr . argsz < sizeof ( hdr ) + ( fill . max * sizeof ( * devices ) ) ) { ret = - ENOSPC ; hdr . count = fill . max ; goto reset_info_exit ; } devices = kcalloc ( fill . max , sizeof ( * devices ) , GFP_KERNEL ) ; if ( ! devices ) return - ENOMEM ; fill . devices = devices ; ret = vfio_pci_for_each_slot_or_bus ( vdev -> pdev , vfio_pci_fill_devs , & fill , slot ) ; if ( ! ret ) hdr . count = fill . cur ; reset_info_exit : if ( copy_to_user ( ( void __user * ) arg , & hdr , minsz ) ) ret = - EFAULT ; if ( ! ret ) { if ( copy_to_user ( ( void __user * ) ( arg + minsz ) , devices , hdr . count * sizeof ( * devices ) ) ) ret = - EFAULT ; } kfree ( devices ) ; return ret ; } else if ( cmd == VFIO_DEVICE_PCI_HOT_RESET ) { struct vfio_pci_hot_reset hdr ; int32_t * group_fds ; struct vfio_pci_group_entry * groups ; struct vfio_pci_group_info info ; bool slot = false ; int i , count = 0 , ret = 0 ; minsz = offsetofend ( struct vfio_pci_hot_reset , count ) ; if ( copy_from_user ( & hdr , ( void __user * ) arg , minsz ) ) return - EFAULT ; if ( hdr . argsz < minsz || hdr . flags ) return - EINVAL ; if ( ! pci_probe_reset_slot ( vdev -> pdev -> slot ) ) slot = true ; else if ( pci_probe_reset_bus ( vdev -> pdev -> bus ) ) return - ENODEV ; ret = vfio_pci_for_each_slot_or_bus ( vdev -> pdev , vfio_pci_count_devs , & count , slot ) ; if ( ret ) return ret ; if ( ! hdr . count || hdr . count > count ) return - EINVAL ; group_fds = kcalloc ( hdr . count , sizeof ( * group_fds ) , GFP_KERNEL ) ; groups = kcalloc ( hdr . count , sizeof ( * groups ) , GFP_KERNEL ) ; if ( ! group_fds || ! groups ) { kfree ( group_fds ) ; kfree ( groups ) ; return - ENOMEM ; } if ( copy_from_user ( group_fds , ( void __user * ) ( arg + minsz ) , hdr . count * sizeof ( * group_fds ) ) ) { kfree ( group_fds ) ; kfree ( groups ) ; return - EFAULT ; } for ( i = 0 ; i < hdr . count ; i ++ ) { struct vfio_group * group ; struct fd f = fdget ( group_fds [ i ] ) ; if ( ! f . file ) { ret = - EBADF ; break ; } group = vfio_group_get_external_user ( f . file ) ; fdput ( f ) ; if ( IS_ERR ( group ) ) { ret = PTR_ERR ( group ) ; break ; } groups [ i ] . group = group ; groups [ i ] . id = vfio_external_user_iommu_id ( group ) ; } kfree ( group_fds ) ; if ( ret ) goto hot_reset_release ; info . count = hdr . count ; info . groups = groups ; ret = vfio_pci_for_each_slot_or_bus ( vdev -> pdev , vfio_pci_validate_devs , & info , slot ) ; if ( ! ret ) ret = slot ? pci_try_reset_slot ( vdev -> pdev -> slot ) : pci_try_reset_bus ( vdev -> pdev -> bus ) ; hot_reset_release : for ( i -- ; i >= 0 ; i -- ) vfio_group_put_external_user ( groups [ i ] . group ) ; kfree ( groups ) ; return ret ; } return - ENOTTY ; } "," vfio_irq_set hdr ; size_t size ; NULL ; int max , || hdr . count >= ( U32_MAX - hdr . start ) || hdr . - EINVAL ; max = vfio_pci_get_irq_count ; if ( hdr . start count > max ) return - EINVAL ; switch ( hdr . flags & VFIO_IRQ_SET_DATA_TYPE_MASK ) { case VFIO_IRQ_SET_DATA_NONE : size = 0 ; break ; case VFIO_IRQ_SET_DATA_BOOL : size = sizeof ( uint8_t ) ; break ; case VFIO_IRQ_SET_DATA_EVENTFD : size = sizeof ( int32_t ) ; break ; default : return - EINVAL ; } if ( size ) { if ( hdr . argsz - minsz < hdr . count * size ",torvalds@linux/05692d7005a364add85c6e25a6c4447ce08f913a,CVE-2016-9084,https://github.com/torvalds/linux/commit/05692d7005a364add85c6e25a6c4447ce08f913a,2016-11-28T03:59Z 554,CWE-200,"CWE-200 static int ext4_write_end ( struct file * file , struct address_space * mapping , loff_t pos , unsigned len , unsigned copied , struct page * page , void * fsdata ) { handle_t * handle = ext4_journal_current_handle ( ) ; struct inode * inode = mapping -> host ; loff_t old_size = inode -> i_size ; int ret = 0 , ret2 ; int i_size_changed = 0 ; trace_ext4_write_end ( inode , pos , len , copied ) ; if ( ext4_test_inode_state ( inode , EXT4_STATE_ORDERED_MODE ) ) { ret = ext4_jbd2_file_inode ( handle , inode ) ; if ( ret ) { unlock_page ( page ) ; put_page ( page ) ; goto errout ; } } if ( ext4_has_inline_data ( inode ) ) { ret = ext4_write_inline_data_end ( inode , pos , len , copied , page ) ; if ( ret < 0 ) goto errout ; copied = ret ; } else copied = block_write_end ( file , mapping , pos , len , copied , page , fsdata ) ; i_size_changed = ext4_update_inode_size ( inode , pos + copied ) ; unlock_page ( page ) ; put_page ( page ) ; if ( old_size < pos ) pagecache_isize_extended ( inode , old_size , pos ) ; if ( i_size_changed ) ext4_mark_inode_dirty ( handle , inode ) ; if ( pos + len > inode -> i_size && ext4_can_truncate ( inode ) ) ext4_orphan_add ( handle , inode ) ; errout : ret2 = ext4_journal_stop ( handle ) ; if ( ! ret ) ret = ret2 ; if ( pos + len > inode -> i_size ) { ext4_truncate_failed_write ( inode ) ; if ( inode -> i_nlink ) ext4_orphan_del ( NULL , inode ) ; } return ret ? ret : copied ; } "," ; if ( ext4_has_inline_data ( inode ",torvalds@linux/06bd3c36a733ac27962fea7d6f47168841376824,CVE-2017-7495,https://github.com/torvalds/linux/commit/06bd3c36a733ac27962fea7d6f47168841376824,2017-05-15T18:29Z 555,CWE-119,"CWE-119 static int http_open ( URLContext * h , const char * uri , int flags , AVDictionary * * options ) { HTTPContext * s = h -> priv_data ; int ret ; if ( s -> seekable == 1 ) h -> is_streamed = 0 ; else h -> is_streamed = 1 ; s -> filesize = - 1 ; s -> location = av_strdup ( uri ) ; if ( ! s -> location ) return AVERROR ( ENOMEM ) ; if ( options ) av_dict_copy ( & s -> chained_options , * options , 0 ) ; if ( s -> headers ) { int len = strlen ( s -> headers ) ; if ( len < 2 || strcmp ( ""\\r\\n"" , s -> headers + len - 2 ) ) { av_log ( h , AV_LOG_WARNING , ""NotrailingCRLFfoundinHTTPheader.\\n"" ) ; ret = av_reallocp ( & s -> headers , len + 3 ) ; if ( ret < 0 ) return ret ; s -> headers [ len ] = '\\r' ; s -> headers [ len + 1 ] = '\\n' ; s -> headers [ len + 2 ] = '\\0' ; } } if ( s -> listen ) { return http_listen ( h , uri , flags , options ) ; } ret = http_open_cnx ( h , options ) ; if ( ret < 0 ) av_dict_free ( & s -> chained_options ) ; return ret ; } "," -> filesize = UINT64_MAX ; s -> ",FFmpeg@FFmpeg/2a05c8f813de6f2278827734bf8102291e7484aa,CVE-2016-10190,https://github.com/FFmpeg/FFmpeg/commit/2a05c8f813de6f2278827734bf8102291e7484aa,2017-02-09T15:59Z 556,CWE-362,"CWE-362 struct sock * cookie_v4_check ( struct sock * sk , struct sk_buff * skb , struct ip_options * opt ) { struct tcp_options_received tcp_opt ; u8 * hash_location ; struct inet_request_sock * ireq ; struct tcp_request_sock * treq ; struct tcp_sock * tp = tcp_sk ( sk ) ; const struct tcphdr * th = tcp_hdr ( skb ) ; __u32 cookie = ntohl ( th -> ack_seq ) - 1 ; struct sock * ret = sk ; struct request_sock * req ; int mss ; struct rtable * rt ; __u8 rcv_wscale ; bool ecn_ok ; if ( ! sysctl_tcp_syncookies || ! th -> ack || th -> rst ) goto out ; if ( tcp_synq_no_recent_overflow ( sk ) || ( mss = cookie_check ( skb , cookie ) ) == 0 ) { NET_INC_STATS_BH ( sock_net ( sk ) , LINUX_MIB_SYNCOOKIESFAILED ) ; goto out ; } NET_INC_STATS_BH ( sock_net ( sk ) , LINUX_MIB_SYNCOOKIESRECV ) ; memset ( & tcp_opt , 0 , sizeof ( tcp_opt ) ) ; tcp_parse_options ( skb , & tcp_opt , & hash_location , 0 ) ; if ( ! cookie_check_timestamp ( & tcp_opt , & ecn_ok ) ) goto out ; ret = NULL ; req = inet_reqsk_alloc ( & tcp_request_sock_ops ) ; if ( ! req ) goto out ; ireq = inet_rsk ( req ) ; treq = tcp_rsk ( req ) ; treq -> rcv_isn = ntohl ( th -> seq ) - 1 ; treq -> snt_isn = cookie ; req -> mss = mss ; ireq -> loc_port = th -> dest ; ireq -> rmt_port = th -> source ; ireq -> loc_addr = ip_hdr ( skb ) -> daddr ; ireq -> rmt_addr = ip_hdr ( skb ) -> saddr ; ireq -> ecn_ok = ecn_ok ; ireq -> snd_wscale = tcp_opt . snd_wscale ; ireq -> sack_ok = tcp_opt . sack_ok ; ireq -> wscale_ok = tcp_opt . wscale_ok ; ireq -> tstamp_ok = tcp_opt . saw_tstamp ; req -> ts_recent = tcp_opt . saw_tstamp ? tcp_opt . rcv_tsval : 0 ; if ( opt && opt -> optlen ) { int opt_size = sizeof ( struct ip_options ) + opt -> optlen ; ireq -> opt = kmalloc ( opt_size , GFP_ATOMIC ) ; if ( ireq -> opt != NULL && ip_options_echo ( ireq -> opt , skb ) ) { kfree ( ireq -> opt ) ; ireq -> opt = NULL ; } } if ( security_inet_conn_request ( sk , skb , req ) ) { reqsk_free ( req ) ; goto out ; } req -> expires = 0UL ; req -> retrans = 0 ; { struct flowi4 fl4 ; flowi4_init_output ( & fl4 , 0 , sk -> sk_mark , RT_CONN_FLAGS ( sk ) , RT_SCOPE_UNIVERSE , IPPROTO_TCP , inet_sk_flowi_flags ( sk ) , ( opt && opt -> srr ) ? opt -> faddr : ireq -> rmt_addr , ireq -> loc_addr , th -> source , th -> dest ) ; security_req_classify_flow ( req , flowi4_to_flowi ( & fl4 ) ) ; rt = ip_route_output_key ( sock_net ( sk ) , & fl4 ) ; if ( IS_ERR ( rt ) ) { reqsk_free ( req ) ; goto out ; } } req -> window_clamp = tp -> window_clamp ? : dst_metric ( & rt -> dst , RTAX_WINDOW ) ; tcp_select_initial_window ( tcp_full_space ( sk ) , req -> mss , & req -> rcv_wnd , & req -> window_clamp , ireq -> wscale_ok , & rcv_wscale , dst_metric ( & rt -> dst , RTAX_INITRWND ) ) ; ireq -> rcv_wscale = rcv_wscale ; ret = get_cookie_sock ( sk , skb , req , & rt -> dst ) ; out : return ret ; } "," sizeof ( struct ip_options_rcu ) + opt && ip_options_echo ( & ireq -> opt -> opt , ",torvalds@linux/f6d8bd051c391c1c0458a30b2a7abcd939329259,CVE-2012-3552,https://github.com/torvalds/linux/commit/f6d8bd051c391c1c0458a30b2a7abcd939329259,2012-10-03T11:02Z 557,CWE-119,"CWE-119 int mutt_b64_decode ( char * out , const char * in ) { int len = 0 ; unsigned char digit4 ; do { const unsigned char digit1 = in [ 0 ] ; if ( ( digit1 > 127 ) || ( base64val ( digit1 ) == BAD ) ) return - 1 ; const unsigned char digit2 = in [ 1 ] ; if ( ( digit2 > 127 ) || ( base64val ( digit2 ) == BAD ) ) return - 1 ; const unsigned char digit3 = in [ 2 ] ; if ( ( digit3 > 127 ) || ( ( digit3 != '=' ) && ( base64val ( digit3 ) == BAD ) ) ) return - 1 ; digit4 = in [ 3 ] ; if ( ( digit4 > 127 ) || ( ( digit4 != '=' ) && ( base64val ( digit4 ) == BAD ) ) ) return - 1 ; in += 4 ; * out ++ = ( base64val ( digit1 ) << 2 ) | ( base64val ( digit2 ) >> 4 ) ; len ++ ; if ( digit3 != '=' ) { * out ++ = ( ( base64val ( digit2 ) << 4 ) & 0xf0 ) | ( base64val ( digit3 ) >> 2 ) ; len ++ ; if ( digit4 != '=' ) { * out ++ = ( ( base64val ( digit3 ) << 6 ) & 0xc0 ) | base64val ( digit4 ) ; len ++ ; } } } while ( * in && digit4 != '=' ) ; return len ; } "," char * in , size_t olen += 4 ; if ( len == olen ) return len ; '=' ) { if ( len == olen ) return len ; '=' ) { if ( len == olen ) return len ; ",neomutt@neomutt/6f163e07ae68654d7ac5268cbb7565f6df79ad85,CVE-2018-14359,https://github.com/neomutt/neomutt/commit/6f163e07ae68654d7ac5268cbb7565f6df79ad85,2018-07-17T17:29Z 558,CWE-415,"CWE-415 static int amd_gpio_remove ( struct platform_device * pdev ) { struct amd_gpio * gpio_dev ; gpio_dev = platform_get_drvdata ( pdev ) ; gpiochip_remove ( & gpio_dev -> gc ) ; pinctrl_unregister ( gpio_dev -> pctrl ) ; return 0 ; } "," gc ) ; return 0 ; ",torvalds@linux/8dca4a41f1ad65043a78c2338d9725f859c8d2c3,CVE-2017-18174,https://github.com/torvalds/linux/commit/8dca4a41f1ad65043a78c2338d9725f859c8d2c3,2018-02-11T18:29Z 559,CWE-119,"CWE-119 static ssize_t cifs_iovec_write ( struct file * file , const struct iovec * iov , unsigned long nr_segs , loff_t * poffset ) { unsigned long nr_pages , i ; size_t copied , len , cur_len ; ssize_t total_written = 0 ; loff_t offset ; struct iov_iter it ; struct cifsFileInfo * open_file ; struct cifs_tcon * tcon ; struct cifs_sb_info * cifs_sb ; struct cifs_writedata * wdata , * tmp ; struct list_head wdata_list ; int rc ; pid_t pid ; len = iov_length ( iov , nr_segs ) ; if ( ! len ) return 0 ; rc = generic_write_checks ( file , poffset , & len , 0 ) ; if ( rc ) return rc ; INIT_LIST_HEAD ( & wdata_list ) ; cifs_sb = CIFS_SB ( file -> f_path . dentry -> d_sb ) ; open_file = file -> private_data ; tcon = tlink_tcon ( open_file -> tlink ) ; if ( ! tcon -> ses -> server -> ops -> async_writev ) return - ENOSYS ; offset = * poffset ; if ( cifs_sb -> mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD ) pid = open_file -> pid ; else pid = current -> tgid ; iov_iter_init ( & it , iov , nr_segs , len , 0 ) ; do { size_t save_len ; nr_pages = get_numpages ( cifs_sb -> wsize , len , & cur_len ) ; wdata = cifs_writedata_alloc ( nr_pages , cifs_uncached_writev_complete ) ; if ( ! wdata ) { rc = - ENOMEM ; break ; } rc = cifs_write_allocate_pages ( wdata -> pages , nr_pages ) ; if ( rc ) { kfree ( wdata ) ; break ; } save_len = cur_len ; for ( i = 0 ; i < nr_pages ; i ++ ) { copied = min_t ( const size_t , cur_len , PAGE_SIZE ) ; copied = iov_iter_copy_from_user ( wdata -> pages [ i ] , & it , 0 , copied ) ; cur_len -= copied ; iov_iter_advance ( & it , copied ) ; } cur_len = save_len - cur_len ; wdata -> sync_mode = WB_SYNC_ALL ; wdata -> nr_pages = nr_pages ; wdata -> offset = ( __u64 ) offset ; wdata -> cfile = cifsFileInfo_get ( open_file ) ; wdata -> pid = pid ; wdata -> bytes = cur_len ; wdata -> pagesz = PAGE_SIZE ; wdata -> tailsz = cur_len - ( ( nr_pages - 1 ) * PAGE_SIZE ) ; rc = cifs_uncached_retry_writev ( wdata ) ; if ( rc ) { kref_put ( & wdata -> refcount , cifs_uncached_writedata_release ) ; break ; } list_add_tail ( & wdata -> list , & wdata_list ) ; offset += cur_len ; len -= cur_len ; } while ( len > 0 ) ; if ( ! list_empty ( & wdata_list ) ) rc = 0 ; restart_loop : list_for_each_entry_safe ( wdata , tmp , & wdata_list , list ) { if ( ! rc ) { rc = wait_for_completion_killable ( & wdata -> done ) ; if ( rc ) rc = - EINTR ; else if ( wdata -> result ) rc = wdata -> result ; else total_written += wdata -> bytes ; if ( rc == - EAGAIN ) { rc = cifs_uncached_retry_writev ( wdata ) ; goto restart_loop ; } } list_del_init ( & wdata -> list ) ; kref_put ( & wdata -> refcount , cifs_uncached_writedata_release ) ; } if ( total_written > 0 ) * poffset += total_written ; cifs_stats_bytes_written ( tcon , total_written ) ; return total_written ? total_written : ( ssize_t ) rc ; } "," i ; size_t bytes , ++ ) { bytes = min_t ( , 0 , bytes ) ; cur_len copied ) ; if ( copied < bytes ) break ; save_len - cur_len ; if ( ! cur_len ) { for ( i = 0 ; i < nr_pages ; i ++ ) put_page ( wdata -> pages [ i ] ) ; kfree ( wdata ) ; rc = - EFAULT ; break ; } for ( ; nr_pages > i + 1 ; nr_pages -- ) put_page ( wdata -> pages [ nr_pages - 1 ] ) ",torvalds@linux/5d81de8e8667da7135d3a32a964087c0faf5483f,CVE-2014-0069,https://github.com/torvalds/linux/commit/5d81de8e8667da7135d3a32a964087c0faf5483f,2014-02-28T06:18Z 560,CWE-000,"CWE-000 static __u8 * cp_report_fixup ( struct hid_device * hdev , __u8 * rdesc , unsigned int * rsize ) { unsigned long quirks = ( unsigned long ) hid_get_drvdata ( hdev ) ; unsigned int i ; if ( ! ( quirks & CP_RDESC_SWAPPED_MIN_MAX ) ) return rdesc ; for ( i = 0 ; i < * rsize - 4 ; i ++ ) if ( rdesc [ i ] == 0x29 && rdesc [ i + 2 ] == 0x19 ) { rdesc [ i ] = 0x19 ; rdesc [ i + 2 ] = 0x29 ; swap ( rdesc [ i + 3 ] , rdesc [ i + 1 ] ) ; } return rdesc ; } "," & CP_RDESC_SWAPPED_MIN_MAX ) ) return rdesc ; if ( * rsize < 4 ",torvalds@linux/1ebb71143758f45dc0fa76e2f48429e13b16d110,CVE-2017-7273,https://github.com/torvalds/linux/commit/1ebb71143758f45dc0fa76e2f48429e13b16d110,2017-03-27T17:59Z 561,CWE-119,"CWE-119 const char * vpx_svc_dump_statistics ( SvcContext * svc_ctx ) { int number_of_frames , number_of_keyframes , encode_frame_count ; int i , j ; uint32_t bytes_total = 0 ; double scale [ COMPONENTS ] ; double psnr [ COMPONENTS ] ; double mse [ COMPONENTS ] ; double y_scale ; SvcInternal * const si = get_svc_internal ( svc_ctx ) ; if ( svc_ctx == NULL || si == NULL ) return NULL ; svc_log_reset ( svc_ctx ) ; encode_frame_count = si -> encode_frame_count ; if ( si -> encode_frame_count <= 0 ) return vpx_svc_get_message ( svc_ctx ) ; svc_log ( svc_ctx , SVC_LOG_INFO , ""\\n"" ) ; number_of_keyframes = encode_frame_count / si -> kf_dist + 1 ; for ( i = 0 ; i < si -> layers ; ++ i ) { number_of_frames = encode_frame_count ; if ( svc_ctx -> encoding_mode == ALT_INTER_LAYER_PREDICTION_IP && ( i == 1 || i == 3 ) ) { number_of_frames -= number_of_keyframes ; } svc_log ( svc_ctx , SVC_LOG_INFO , ""Layer%dAveragePSNR=[%2.3f,%2.3f,%2.3f,%2.3f],Bytes=[%u]\\n"" , i , ( double ) si -> psnr_sum [ i ] [ 0 ] / number_of_frames , ( double ) si -> psnr_sum [ i ] [ 1 ] / number_of_frames , ( double ) si -> psnr_sum [ i ] [ 2 ] / number_of_frames , ( double ) si -> psnr_sum [ i ] [ 3 ] / number_of_frames , si -> bytes_sum [ i ] ) ; y_scale = si -> width * si -> height * 255.0 * 255.0 * number_of_frames ; scale [ 1 ] = y_scale ; scale [ 2 ] = scale [ 3 ] = y_scale / 4 ; scale [ 0 ] = y_scale * 1.5 ; for ( j = 0 ; j < COMPONENTS ; j ++ ) { psnr [ j ] = calc_psnr ( si -> sse_sum [ i ] [ j ] / scale [ j ] ) ; mse [ j ] = si -> sse_sum [ i ] [ j ] * 255.0 * 255.0 / scale [ j ] ; } svc_log ( svc_ctx , SVC_LOG_INFO , ""Layer%dOverallPSNR=[%2.3f,%2.3f,%2.3f,%2.3f]\\n"" , i , psnr [ 0 ] , psnr [ 1 ] , psnr [ 2 ] , psnr [ 3 ] ) ; svc_log ( svc_ctx , SVC_LOG_INFO , ""Layer%dOverallMSE=[%2.3f,%2.3f,%2.3f,%2.3f]\\n"" , i , mse [ 0 ] , mse [ 1 ] , mse [ 2 ] , mse [ 3 ] ) ; bytes_total += si -> bytes_sum [ i ] ; si -> bytes_sum [ i ] = 0 ; for ( j = 0 ; j < COMPONENTS ; ++ j ) { si -> psnr_sum [ i ] [ j ] = 0 ; si -> sse_sum [ i ] [ j ] = 0 ; } } si -> encode_frame_count = 0 ; svc_log ( svc_ctx , SVC_LOG_INFO , ""TotalBytes=[%u]\\n"" , bytes_total ) ; return vpx_svc_get_message ( svc_ctx ) ; } "," { int number_of_frames ; int i double y_scale ; SvcInternal_t * const si svc_ctx ) ; number_of_frames = si -> psnr_pkt_received ; if ( ; if ( number_of_frames <= 0 ) ""\\n"" ) ; for ( i ; i < svc_ctx -> spatial_layers ; ++ i i ) { svc_log ( svc_ctx } si -> psnr_pkt_received = 0 ; ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 562,CWE-787,"CWE-787 static void nsc_rle_decode ( BYTE * in , BYTE * out , UINT32 originalSize ) { UINT32 len ; UINT32 left ; BYTE value ; left = originalSize ; while ( left > 4 ) { value = * in ++ ; if ( left == 5 ) { * out ++ = value ; left -- ; } else if ( value == * in ) { in ++ ; if ( * in < 0xFF ) { len = ( UINT32 ) * in ++ ; len += 2 ; } else { in ++ ; len = * ( ( UINT32 * ) in ) ; in += 4 ; } FillMemory ( out , len , value ) ; out += len ; left -= len ; } else { * out ++ = value ; left -- ; } } * ( ( UINT32 * ) out ) = * ( ( UINT32 * ) in ) ; } "," static BOOL nsc_rle_decode ( BYTE BYTE * out , UINT32 outSize 5 ) { if ( outSize < 1 ) return FALSE ; outSize -- ; 4 ; } if ( outSize < len ) return FALSE ; outSize -= len ; } else { if ( outSize < 1 ) return FALSE ; outSize -- ; * out ++ = value ; left -- ; } } if ( ( outSize < 4 ) || ( left < 4 ) ) return FALSE ; memcpy ( out , in , 4 ) ; return TRUE ; } ",FreeRDP@FreeRDP/d1112c279bd1a327e8e4d0b5f371458bf2579659,CVE-2018-8788,https://github.com/FreeRDP/FreeRDP/commit/d1112c279bd1a327e8e4d0b5f371458bf2579659,2018-11-29T18:29Z 563,CWE-476,"CWE-476 static int resize ( int new_rows , int new_cols , VTermPos * delta , void * user ) { VTermScreen * screen = user ; int is_altscreen = ( screen -> buffers [ 1 ] && screen -> buffer == screen -> buffers [ 1 ] ) ; int old_rows = screen -> rows ; int old_cols = screen -> cols ; int first_blank_row ; if ( ! is_altscreen && new_rows < old_rows ) { VTermPos pos = { 0 , 0 } ; VTermPos cursor = screen -> state -> pos ; for ( pos . row = old_rows - 1 ; pos . row >= new_rows ; pos . row -- ) if ( ! vterm_screen_is_eol ( screen , pos ) || cursor . row == pos . row ) break ; first_blank_row = pos . row + 1 ; if ( first_blank_row > new_rows ) { VTermRect rect = { 0 , 0 , 0 , 0 } ; rect . end_row = old_rows ; rect . end_col = old_cols ; scrollrect ( rect , first_blank_row - new_rows , 0 , user ) ; vterm_screen_flush_damage ( screen ) ; delta -> row -= first_blank_row - new_rows ; } } screen -> buffers [ 0 ] = realloc_buffer ( screen , screen -> buffers [ 0 ] , new_rows , new_cols ) ; if ( screen -> buffers [ 1 ] ) screen -> buffers [ 1 ] = realloc_buffer ( screen , screen -> buffers [ 1 ] , new_rows , new_cols ) ; screen -> buffer = is_altscreen ? screen -> buffers [ 1 ] : screen -> buffers [ 0 ] ; screen -> rows = new_rows ; screen -> cols = new_cols ; if ( screen -> sb_buffer ) vterm_allocator_free ( screen -> vt , screen -> sb_buffer ) ; screen -> sb_buffer = vterm_allocator_malloc ( screen -> vt , sizeof ( VTermScreenCell ) * new_cols ) ; if ( new_cols > old_cols ) { VTermRect rect ; rect . start_row = 0 ; rect . end_row = old_rows ; rect . start_col = old_cols ; rect . end_col = new_cols ; damagerect ( screen , rect ) ; } if ( new_rows > old_rows ) { if ( ! is_altscreen && screen -> callbacks && screen -> callbacks -> sb_popline ) { int rows = new_rows - old_rows ; while ( rows ) { VTermRect rect = { 0 , 0 , 0 , 0 } ; VTermPos pos = { 0 , 0 } ; if ( ! ( screen -> callbacks -> sb_popline ( screen -> cols , screen -> sb_buffer , screen -> cbdata ) ) ) break ; rect . end_row = screen -> rows ; rect . end_col = screen -> cols ; scrollrect ( rect , - 1 , 0 , user ) ; for ( pos . col = 0 ; pos . col < screen -> cols ; pos . col += screen -> sb_buffer [ pos . col ] . width ) vterm_screen_set_cell ( screen , pos , screen -> sb_buffer + pos . col ) ; rect . end_row = 1 ; damagerect ( screen , rect ) ; vterm_screen_flush_damage ( screen ) ; rows -- ; delta -> row ++ ; } } { VTermRect rect ; rect . start_row = old_rows ; rect . end_row = new_rows ; rect . start_col = 0 ; rect . end_col = new_cols ; damagerect ( screen , rect ) ; } } if ( screen -> callbacks && screen -> callbacks -> resize ) return ( * screen -> callbacks -> resize ) ( new_rows , new_cols , screen -> cbdata ) ; return 1 ; } "," = new_cols ; vterm_allocator_free ( screen ",vim@vim/cd929f7ba8cc5b6d6dcf35c8b34124e969fed6b8,CVE-2018-20786,https://github.com/vim/vim/commit/cd929f7ba8cc5b6d6dcf35c8b34124e969fed6b8,2019-02-24T14:29Z 564,CWE-125,"CWE-125 static int fstring_find_literal ( const char * * str , const char * end , int raw , PyObject * * literal , int recurse_lvl , struct compiling * c , const node * n ) { const char * literal_start = * str ; const char * literal_end ; int in_named_escape = 0 ; int result = 0 ; assert ( * literal == NULL ) ; for ( ; * str < end ; ( * str ) ++ ) { char ch = * * str ; if ( ! in_named_escape && ch == '{' && ( * str ) - literal_start >= 2 && * ( * str - 2 ) == '\\\\' && * ( * str - 1 ) == 'N' ) { in_named_escape = 1 ; } else if ( in_named_escape && ch == '}' ) { in_named_escape = 0 ; } else if ( ch == '{' || ch == '}' ) { if ( recurse_lvl == 0 ) { if ( * str + 1 < end && * ( * str + 1 ) == ch ) { literal_end = * str + 1 ; * str += 2 ; result = 1 ; goto done ; } if ( ch == '}' ) { ast_error ( c , n , ""f-string:single\'}\'isnotallowed"" ) ; return - 1 ; } } break ; } } literal_end = * str ; assert ( * str <= end ) ; assert ( * str == end || * * str == '{' || * * str == '}' ) ; done : if ( literal_start != literal_end ) { if ( raw ) * literal = PyUnicode_DecodeUTF8Stateful ( literal_start , literal_end - literal_start , NULL , NULL ) ; else * literal = decode_unicode_with_escapes ( c , n , literal_start , literal_end - literal_start ) ; if ( ! * literal ) return - 1 ; } return result ; } "," const char * s = * str ; const char * literal_start = s ; int result NULL ) ; while ( s < end ) { char ch = * s ++ ; if ( if ( ! raw && ch == '\\\\' && s < end ) { ch = * s ++ ; if ( ch == 'N' ) { if ( s < end && * s ++ == '{' ) { while ( s < end && * s ++ != '}' ) { '}' ) { } continue ; } break ; } if ( ch == '{' && warn_invalid_escape_sequence ( c , n , ch ) < 0 ) { return - 1 ; } } if ( ch { if ( s < end && * s == ch ) { * str = s + 1 ; result = '}' ) { * str = s - 1 ; ; } } s -- ; ; } } * str = s ; assert ( ; assert ( s <= end ) ; assert ( s == end || end || * s == '{' || '{' || * s == '}' ) ( literal_start != s ) { if ( literal_start , s - literal_start , , literal_start , s - literal_start ) ",python@typed_ast/156afcb26c198e162504a57caddfe0acd9ed7dce,CVE-2019-19275,https://github.com/python/typed_ast/commit/156afcb26c198e162504a57caddfe0acd9ed7dce,2019-11-26T15:15Z 565,CWE-190,"CWE-190 static int mem_resize ( jas_stream_memobj_t * m , int bufsize ) { unsigned char * buf ; assert ( bufsize >= 0 ) ; JAS_DBGLOG ( 100 , ( ""mem_resize(%p,%d)\\n"" , m , bufsize ) ) ; if ( ! ( buf = jas_realloc2 ( m -> buf_ , bufsize , sizeof ( unsigned char ) ) ) && bufsize ) { JAS_DBGLOG ( 100 , ( ""mem_resizereallocfailed\\n"" ) ) ; return - 1 ; } JAS_DBGLOG ( 100 , ( ""mem_resizereallocsucceeded\\n"" ) ) ; m -> buf_ = buf ; m -> bufsize_ = bufsize ; return 0 ; } "," * m , size_t bufsize ) { * buf ; JAS_DBGLOG ( 100 100 , ( ""mem_resize(%p,%zu)\\n"" , m , ) ) ; if ( ! bufsize ) { jas_eprintf ( ""mem_resizewasnotreallydesignedtohandleabufferofsize0\\n"" ""Thismaynotwork.\\n"" ) ; } ",mdadams@jasper/634ce8e8a5accc0fa05dd2c20d42b4749d4b2735,CVE-2016-9262,https://github.com/mdadams/jasper/commit/634ce8e8a5accc0fa05dd2c20d42b4749d4b2735,2017-03-23T18:59Z 566,CWE-200,"CWE-200 char * problem_data_save ( problem_data_t * pd ) { load_abrt_conf ( ) ; struct dump_dir * dd = create_dump_dir_from_problem_data ( pd , g_settings_dump_location ) ; char * problem_id = NULL ; if ( dd ) { problem_id = xstrdup ( dd -> dd_dirname ) ; dd_close ( dd ) ; } log_info ( ""problemid:\'%s\'"" , problem_id ) ; return problem_id ; } "," struct dump_dir * dd = NULL ; if ( g_settings_privatereports ) dd = create_dump_dir_from_problem_data_ext ( pd , g_settings_dump_location , 0 ) ; else ",abrt@abrt/8939398b82006ba1fec4ed491339fc075f43fc7c,CVE-2015-1870,https://github.com/abrt/abrt/commit/8939398b82006ba1fec4ed491339fc075f43fc7c,2017-06-26T15:29Z 567,CWE-476,"CWE-476 static bool ResolveStateAndPredicate ( ExprDef * expr , enum xkb_match_operation * pred_rtrn , xkb_mod_mask_t * mods_rtrn , CompatInfo * info ) { if ( expr == NULL ) { * pred_rtrn = MATCH_ANY_OR_NONE ; * mods_rtrn = MOD_REAL_MASK_ALL ; return true ; } * pred_rtrn = MATCH_EXACTLY ; if ( expr -> expr . op == EXPR_ACTION_DECL ) { const char * pred_txt = xkb_atom_text ( info -> ctx , expr -> action . name ) ; if ( ! LookupString ( symInterpretMatchMaskNames , pred_txt , pred_rtrn ) ) { log_err ( info -> ctx , ""Illegalmodifierpredicate\\""%s\\"";Ignored\\n"" , pred_txt ) ; return false ; } expr = expr -> action . args ; } else if ( expr -> expr . op == EXPR_IDENT ) { const char * pred_txt = xkb_atom_text ( info -> ctx , expr -> ident . ident ) ; if ( pred_txt && istreq ( pred_txt , ""any"" ) ) { * pred_rtrn = MATCH_ANY ; * mods_rtrn = MOD_REAL_MASK_ALL ; return true ; } } return ExprResolveModMask ( info -> ctx , expr , MOD_REAL , & info -> mods , mods_rtrn ) ; } "," , pred_rtrn ) || ! expr -> action . args ",xkbcommon@libxkbcommon/96df3106d49438e442510c59acad306e94f3db4d,CVE-2018-15863,https://github.com/xkbcommon/libxkbcommon/commit/96df3106d49438e442510c59acad306e94f3db4d,2018-08-25T21:29Z 568,CWE-763,"CWE-763 static void pcrypt_free ( struct crypto_instance * inst ) { struct pcrypt_instance_ctx * ctx = crypto_instance_ctx ( inst ) ; crypto_drop_aead ( & ctx -> spawn ) ; kfree ( inst ) ; } "," pcrypt_free ( struct aead_instance * inst ) * ctx = aead_instance_ctx ( inst ) ",torvalds@linux/d76c68109f37cb85b243a1cf0f40313afd2bae68,CVE-2017-18075,https://github.com/torvalds/linux/commit/d76c68109f37cb85b243a1cf0f40313afd2bae68,2018-01-24T10:29Z 569,CWE-190,"CWE-190 void rfbScaledScreenUpdateRect ( rfbScreenInfoPtr screen , rfbScreenInfoPtr ptr , int x0 , int y0 , int w0 , int h0 ) { int x , y , w , v , z ; int x1 , y1 , w1 , h1 ; int bitsPerPixel , bytesPerPixel , bytesPerLine , areaX , areaY , area2 ; unsigned char * srcptr , * dstptr ; if ( screen == ptr ) return ; x1 = x0 ; y1 = y0 ; w1 = w0 ; h1 = h0 ; rfbScaledCorrection ( screen , ptr , & x1 , & y1 , & w1 , & h1 , ""rfbScaledScreenUpdateRect"" ) ; x0 = ScaleX ( ptr , screen , x1 ) ; y0 = ScaleY ( ptr , screen , y1 ) ; w0 = ScaleX ( ptr , screen , w1 ) ; h0 = ScaleY ( ptr , screen , h1 ) ; bitsPerPixel = screen -> bitsPerPixel ; bytesPerPixel = bitsPerPixel / 8 ; bytesPerLine = w1 * bytesPerPixel ; srcptr = ( unsigned char * ) ( screen -> frameBuffer + ( y0 * screen -> paddedWidthInBytes + x0 * bytesPerPixel ) ) ; dstptr = ( unsigned char * ) ( ptr -> frameBuffer + ( y1 * ptr -> paddedWidthInBytes + x1 * bytesPerPixel ) ) ; areaX = ScaleX ( ptr , screen , 1 ) ; areaY = ScaleY ( ptr , screen , 1 ) ; area2 = areaX * areaY ; if ( ( x1 + w1 ) > ( ptr -> width ) ) { if ( x1 == 0 ) w1 = ptr -> width ; else x1 = ptr -> width - w1 ; } if ( ( y1 + h1 ) > ( ptr -> height ) ) { if ( y1 == 0 ) h1 = ptr -> height ; else y1 = ptr -> height - h1 ; } if ( screen -> serverFormat . trueColour ) { unsigned char * srcptr2 ; unsigned long pixel_value , red , green , blue ; unsigned int redShift = screen -> serverFormat . redShift ; unsigned int greenShift = screen -> serverFormat . greenShift ; unsigned int blueShift = screen -> serverFormat . blueShift ; unsigned long redMax = screen -> serverFormat . redMax ; unsigned long greenMax = screen -> serverFormat . greenMax ; unsigned long blueMax = screen -> serverFormat . blueMax ; for ( y = 0 ; y < h1 ; y ++ ) { for ( x = 0 ; x < w1 ; x ++ ) { red = green = blue = 0 ; for ( w = 0 ; w < areaX ; w ++ ) { for ( v = 0 ; v < areaY ; v ++ ) { srcptr2 = & srcptr [ ( ( ( x * areaX ) + w ) * bytesPerPixel ) + ( v * screen -> paddedWidthInBytes ) ] ; pixel_value = 0 ; switch ( bytesPerPixel ) { case 4 : pixel_value = * ( ( unsigned int * ) srcptr2 ) ; break ; case 2 : pixel_value = * ( ( unsigned short * ) srcptr2 ) ; break ; case 1 : pixel_value = * ( ( unsigned char * ) srcptr2 ) ; break ; default : for ( z = 0 ; z < bytesPerPixel ; z ++ ) pixel_value += ( srcptr2 [ z ] << ( 8 * z ) ) ; break ; } red += ( ( pixel_value >> redShift ) & redMax ) ; green += ( ( pixel_value >> greenShift ) & greenMax ) ; blue += ( ( pixel_value >> blueShift ) & blueMax ) ; } } red /= area2 ; green /= area2 ; blue /= area2 ; pixel_value = ( ( red & redMax ) << redShift ) | ( ( green & greenMax ) << greenShift ) | ( ( blue & blueMax ) << blueShift ) ; switch ( bytesPerPixel ) { case 4 : * ( ( unsigned int * ) dstptr ) = ( unsigned int ) pixel_value ; break ; case 2 : * ( ( unsigned short * ) dstptr ) = ( unsigned short ) pixel_value ; break ; case 1 : * ( ( unsigned char * ) dstptr ) = ( unsigned char ) pixel_value ; break ; default : for ( z = 0 ; z < bytesPerPixel ; z ++ ) dstptr [ z ] = ( pixel_value >> ( 8 * z ) ) & 0xff ; break ; } dstptr += bytesPerPixel ; } srcptr += ( screen -> paddedWidthInBytes * areaY ) ; dstptr += ( ptr -> paddedWidthInBytes - bytesPerLine ) ; } } else { for ( y = y1 ; y < ( y1 + h1 ) ; y ++ ) { for ( x = x1 ; x < ( x1 + w1 ) ; x ++ ) memcpy ( & ptr -> frameBuffer [ ( y * ptr -> paddedWidthInBytes ) + ( x * bytesPerPixel ) ] , & screen -> frameBuffer [ ( y * areaY * screen -> paddedWidthInBytes ) + ( x * areaX * bytesPerPixel ) ] , bytesPerPixel ) ; } } } "," pixel_value += ( ( unsigned long ) ",LibVNC@libvncserver/a6788d1da719ae006605b78d22f5a9f170b423af,CVE-2020-14401,https://github.com/LibVNC/libvncserver/commit/a6788d1da719ae006605b78d22f5a9f170b423af,2020-06-17T16:15Z 570,CWE-125,"CWE-125 static Image * ReadSGIImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { Image * image ; MagickBooleanType status ; MagickSizeType number_pixels ; MemoryInfo * pixel_info ; register Quantum * q ; register ssize_t i , x ; register unsigned char * p ; SGIInfo iris_info ; size_t bytes_per_pixel , quantum ; ssize_t count , y , z ; unsigned char * pixels ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } iris_info . magic = ReadBlobMSBShort ( image ) ; do { if ( iris_info . magic != 0x01DA ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; iris_info . storage = ( unsigned char ) ReadBlobByte ( image ) ; switch ( iris_info . storage ) { case 0x00 : image -> compression = NoCompression ; break ; case 0x01 : image -> compression = RLECompression ; break ; default : ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; } iris_info . bytes_per_pixel = ( unsigned char ) ReadBlobByte ( image ) ; if ( ( iris_info . bytes_per_pixel == 0 ) || ( iris_info . bytes_per_pixel > 2 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; iris_info . dimension = ReadBlobMSBShort ( image ) ; iris_info . columns = ReadBlobMSBShort ( image ) ; iris_info . rows = ReadBlobMSBShort ( image ) ; iris_info . depth = ReadBlobMSBShort ( image ) ; if ( ( iris_info . depth == 0 ) || ( iris_info . depth > 4 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; iris_info . minimum_value = ReadBlobMSBLong ( image ) ; iris_info . maximum_value = ReadBlobMSBLong ( image ) ; iris_info . sans = ReadBlobMSBLong ( image ) ; ( void ) ReadBlob ( image , sizeof ( iris_info . name ) , ( unsigned char * ) iris_info . name ) ; iris_info . name [ sizeof ( iris_info . name ) - 1 ] = '\\0' ; if ( * iris_info . name != '\\0' ) ( void ) SetImageProperty ( image , ""label"" , iris_info . name , exception ) ; iris_info . pixel_format = ReadBlobMSBLong ( image ) ; if ( iris_info . pixel_format != 0 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; count = ReadBlob ( image , sizeof ( iris_info . filler ) , iris_info . filler ) ; ( void ) count ; image -> columns = iris_info . columns ; image -> rows = iris_info . rows ; image -> depth = ( size_t ) MagickMin ( iris_info . depth , MAGICKCORE_QUANTUM_DEPTH ) ; if ( iris_info . pixel_format == 0 ) image -> depth = ( size_t ) MagickMin ( ( size_t ) 8 * iris_info . bytes_per_pixel , MAGICKCORE_QUANTUM_DEPTH ) ; if ( iris_info . depth < 3 ) { image -> storage_class = PseudoClass ; image -> colors = iris_info . bytes_per_pixel > 1 ? 65535 : 256 ; } if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; bytes_per_pixel = ( size_t ) iris_info . bytes_per_pixel ; number_pixels = ( MagickSizeType ) iris_info . columns * iris_info . rows ; if ( ( 4 * bytes_per_pixel * number_pixels ) != ( ( MagickSizeType ) ( size_t ) ( 4 * bytes_per_pixel * number_pixels ) ) ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; pixel_info = AcquireVirtualMemory ( iris_info . columns , iris_info . rows * 4 * bytes_per_pixel * sizeof ( * pixels ) ) ; if ( pixel_info == ( MemoryInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; pixels = ( unsigned char * ) GetVirtualMemoryBlob ( pixel_info ) ; if ( ( int ) iris_info . storage != 0x01 ) { unsigned char * scanline ; scanline = ( unsigned char * ) AcquireQuantumMemory ( iris_info . columns , bytes_per_pixel * sizeof ( * scanline ) ) ; if ( scanline == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; for ( z = 0 ; z < ( ssize_t ) iris_info . depth ; z ++ ) { p = pixels + bytes_per_pixel * z ; for ( y = 0 ; y < ( ssize_t ) iris_info . rows ; y ++ ) { count = ReadBlob ( image , bytes_per_pixel * iris_info . columns , scanline ) ; if ( EOFBlob ( image ) != MagickFalse ) break ; if ( bytes_per_pixel == 2 ) for ( x = 0 ; x < ( ssize_t ) iris_info . columns ; x ++ ) { * p = scanline [ 2 * x ] ; * ( p + 1 ) = scanline [ 2 * x + 1 ] ; p += 8 ; } else for ( x = 0 ; x < ( ssize_t ) iris_info . columns ; x ++ ) { * p = scanline [ x ] ; p += 4 ; } } } scanline = ( unsigned char * ) RelinquishMagickMemory ( scanline ) ; } else { MemoryInfo * packet_info ; size_t * runlength ; ssize_t offset , * offsets ; unsigned char * packets ; unsigned int data_order ; offsets = ( ssize_t * ) AcquireQuantumMemory ( ( size_t ) iris_info . rows , iris_info . depth * sizeof ( * offsets ) ) ; runlength = ( size_t * ) AcquireQuantumMemory ( iris_info . rows , iris_info . depth * sizeof ( * runlength ) ) ; packet_info = AcquireVirtualMemory ( ( size_t ) iris_info . columns + 10UL , 4UL * sizeof ( * packets ) ) ; if ( ( offsets == ( ssize_t * ) NULL ) || ( runlength == ( size_t * ) NULL ) || ( packet_info == ( MemoryInfo * ) NULL ) ) { if ( offsets == ( ssize_t * ) NULL ) offsets = ( ssize_t * ) RelinquishMagickMemory ( offsets ) ; if ( runlength == ( size_t * ) NULL ) runlength = ( size_t * ) RelinquishMagickMemory ( runlength ) ; if ( packet_info == ( MemoryInfo * ) NULL ) packet_info = RelinquishVirtualMemory ( packet_info ) ; ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; } packets = ( unsigned char * ) GetVirtualMemoryBlob ( packet_info ) ; for ( i = 0 ; i < ( ssize_t ) ( iris_info . rows * iris_info . depth ) ; i ++ ) offsets [ i ] = ReadBlobMSBSignedLong ( image ) ; for ( i = 0 ; i < ( ssize_t ) ( iris_info . rows * iris_info . depth ) ; i ++ ) { runlength [ i ] = ReadBlobMSBLong ( image ) ; if ( runlength [ i ] > ( 4 * ( size_t ) iris_info . columns + 10 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; } offset = 0 ; data_order = 0 ; for ( y = 0 ; ( ( y < ( ssize_t ) iris_info . rows ) && ( data_order == 0 ) ) ; y ++ ) for ( z = 0 ; ( ( z < ( ssize_t ) iris_info . depth ) && ( data_order == 0 ) ) ; z ++ ) { if ( offsets [ y + z * iris_info . rows ] < offset ) data_order = 1 ; offset = offsets [ y + z * iris_info . rows ] ; } offset = ( ssize_t ) TellBlob ( image ) ; if ( data_order == 1 ) { for ( z = 0 ; z < ( ssize_t ) iris_info . depth ; z ++ ) { p = pixels ; for ( y = 0 ; y < ( ssize_t ) iris_info . rows ; y ++ ) { if ( offset != offsets [ y + z * iris_info . rows ] ) { offset = offsets [ y + z * iris_info . rows ] ; offset = ( ssize_t ) SeekBlob ( image , ( ssize_t ) offset , SEEK_SET ) ; } count = ReadBlob ( image , ( size_t ) runlength [ y + z * iris_info . rows ] , packets ) ; if ( EOFBlob ( image ) != MagickFalse ) break ; offset += ( ssize_t ) runlength [ y + z * iris_info . rows ] ; status = SGIDecode ( bytes_per_pixel , ( ssize_t ) ( runlength [ y + z * iris_info . rows ] / bytes_per_pixel ) , packets , 1L * iris_info . columns , p + bytes_per_pixel * z ) ; if ( status == MagickFalse ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; p += ( iris_info . columns * 4 * bytes_per_pixel ) ; } } } else { MagickOffsetType position ; position = TellBlob ( image ) ; p = pixels ; for ( y = 0 ; y < ( ssize_t ) iris_info . rows ; y ++ ) { for ( z = 0 ; z < ( ssize_t ) iris_info . depth ; z ++ ) { if ( offset != offsets [ y + z * iris_info . rows ] ) { offset = offsets [ y + z * iris_info . rows ] ; offset = ( ssize_t ) SeekBlob ( image , ( ssize_t ) offset , SEEK_SET ) ; } count = ReadBlob ( image , ( size_t ) runlength [ y + z * iris_info . rows ] , packets ) ; if ( EOFBlob ( image ) != MagickFalse ) break ; offset += ( ssize_t ) runlength [ y + z * iris_info . rows ] ; status = SGIDecode ( bytes_per_pixel , ( ssize_t ) ( runlength [ y + z * iris_info . rows ] / bytes_per_pixel ) , packets , 1L * iris_info . columns , p + bytes_per_pixel * z ) ; if ( status == MagickFalse ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; } p += ( iris_info . columns * 4 * bytes_per_pixel ) ; } offset = ( ssize_t ) SeekBlob ( image , position , SEEK_SET ) ; } packet_info = RelinquishVirtualMemory ( packet_info ) ; runlength = ( size_t * ) RelinquishMagickMemory ( runlength ) ; offsets = ( ssize_t * ) RelinquishMagickMemory ( offsets ) ; } image -> alpha_trait = iris_info . depth == 4 ? BlendPixelTrait : UndefinedPixelTrait ; image -> columns = iris_info . columns ; image -> rows = iris_info . rows ; if ( image -> storage_class == DirectClass ) { if ( bytes_per_pixel == 2 ) { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { p = pixels + ( image -> rows - y - 1 ) * 8 * image -> columns ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( image , ScaleShortToQuantum ( ( unsigned short ) ( ( * ( p + 0 ) << 8 ) | ( * ( p + 1 ) ) ) ) , q ) ; SetPixelGreen ( image , ScaleShortToQuantum ( ( unsigned short ) ( ( * ( p + 2 ) << 8 ) | ( * ( p + 3 ) ) ) ) , q ) ; SetPixelBlue ( image , ScaleShortToQuantum ( ( unsigned short ) ( ( * ( p + 4 ) << 8 ) | ( * ( p + 5 ) ) ) ) , q ) ; SetPixelAlpha ( image , OpaqueAlpha , q ) ; if ( image -> alpha_trait != UndefinedPixelTrait ) SetPixelAlpha ( image , ScaleShortToQuantum ( ( unsigned short ) ( ( * ( p + 6 ) << 8 ) | ( * ( p + 7 ) ) ) ) , q ) ; p += 8 ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } else for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { p = pixels + ( image -> rows - y - 1 ) * 4 * image -> columns ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( image , ScaleCharToQuantum ( * p ) , q ) ; SetPixelGreen ( image , ScaleCharToQuantum ( * ( p + 1 ) ) , q ) ; SetPixelBlue ( image , ScaleCharToQuantum ( * ( p + 2 ) ) , q ) ; SetPixelAlpha ( image , OpaqueAlpha , q ) ; if ( image -> alpha_trait != UndefinedPixelTrait ) SetPixelAlpha ( image , ScaleCharToQuantum ( * ( p + 3 ) ) , q ) ; p += 4 ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } else { if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; if ( bytes_per_pixel == 2 ) { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { p = pixels + ( image -> rows - y - 1 ) * 8 * image -> columns ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { quantum = ( * p << 8 ) ; quantum |= ( * ( p + 1 ) ) ; SetPixelIndex ( image , ( Quantum ) quantum , q ) ; p += 8 ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } else for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { p = pixels + ( image -> rows - y - 1 ) * 4 * image -> columns ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelIndex ( image , * p , q ) ; p += 4 ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } ( void ) SyncImage ( image , exception ) ; } pixel_info = RelinquishVirtualMemory ( pixel_info ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; iris_info . magic = ReadBlobMSBShort ( image ) ; if ( iris_info . magic == 0x01DA ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( iris_info . magic == 0x01DA ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," } if ( EOFBlob ( image ) != MagickFalse ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ",ImageMagick@ImageMagick/7afcf9f71043df15508e46f079387bd4689a738d,CVE-2016-7101,https://github.com/ImageMagick/ImageMagick/commit/7afcf9f71043df15508e46f079387bd4689a738d,2017-01-18T17:59Z 571,CWE-17,"CWE-17 static void ndisc_router_discovery ( struct sk_buff * skb ) { struct ra_msg * ra_msg = ( struct ra_msg * ) skb_transport_header ( skb ) ; struct neighbour * neigh = NULL ; struct inet6_dev * in6_dev ; struct rt6_info * rt = NULL ; int lifetime ; struct ndisc_options ndopts ; int optlen ; unsigned int pref = 0 ; __u8 * opt = ( __u8 * ) ( ra_msg + 1 ) ; optlen = ( skb_tail_pointer ( skb ) - skb_transport_header ( skb ) ) - sizeof ( struct ra_msg ) ; ND_PRINTK ( 2 , info , ""RA:%s,dev:%s\\n"" , __func__ , skb -> dev -> name ) ; if ( ! ( ipv6_addr_type ( & ipv6_hdr ( skb ) -> saddr ) & IPV6_ADDR_LINKLOCAL ) ) { ND_PRINTK ( 2 , warn , ""RA:sourceaddressisnotlink-local\\n"" ) ; return ; } if ( optlen < 0 ) { ND_PRINTK ( 2 , warn , ""RA:packettooshort\\n"" ) ; return ; } # ifdef CONFIG_IPV6_NDISC_NODETYPE if ( skb -> ndisc_nodetype == NDISC_NODETYPE_HOST ) { ND_PRINTK ( 2 , warn , ""RA:fromhostorunauthorizedrouter\\n"" ) ; return ; } # endif in6_dev = __in6_dev_get ( skb -> dev ) ; if ( in6_dev == NULL ) { ND_PRINTK ( 0 , err , ""RA:can\'tfindinet6devicefor%s\\n"" , skb -> dev -> name ) ; return ; } if ( ! ndisc_parse_options ( opt , optlen , & ndopts ) ) { ND_PRINTK ( 2 , warn , ""RA:invalidNDoptions\\n"" ) ; return ; } if ( ! ipv6_accept_ra ( in6_dev ) ) { ND_PRINTK ( 2 , info , ""RA:%s,didnotacceptrafordev:%s\\n"" , __func__ , skb -> dev -> name ) ; goto skip_linkparms ; } # ifdef CONFIG_IPV6_NDISC_NODETYPE if ( skb -> ndisc_nodetype == NDISC_NODETYPE_NODEFAULT ) { ND_PRINTK ( 2 , info , ""RA:%s,nodetypeisNODEFAULT,dev:%s\\n"" , __func__ , skb -> dev -> name ) ; goto skip_linkparms ; } # endif if ( in6_dev -> if_flags & IF_RS_SENT ) { in6_dev -> if_flags |= IF_RA_RCVD ; } in6_dev -> if_flags = ( in6_dev -> if_flags & ~ ( IF_RA_MANAGED | IF_RA_OTHERCONF ) ) | ( ra_msg -> icmph . icmp6_addrconf_managed ? IF_RA_MANAGED : 0 ) | ( ra_msg -> icmph . icmp6_addrconf_other ? IF_RA_OTHERCONF : 0 ) ; if ( ! in6_dev -> cnf . accept_ra_defrtr ) { ND_PRINTK ( 2 , info , ""RA:%s,defrtrisfalsefordev:%s\\n"" , __func__ , skb -> dev -> name ) ; goto skip_defrtr ; } if ( ! in6_dev -> cnf . accept_ra_from_local && ipv6_chk_addr ( dev_net ( in6_dev -> dev ) , & ipv6_hdr ( skb ) -> saddr , NULL , 0 ) ) { ND_PRINTK ( 2 , info , ""RAfromlocaladdressdetectedondev:%s:defaultrouterignored\\n"" , skb -> dev -> name ) ; goto skip_defrtr ; } lifetime = ntohs ( ra_msg -> icmph . icmp6_rt_lifetime ) ; # ifdef CONFIG_IPV6_ROUTER_PREF pref = ra_msg -> icmph . icmp6_router_pref ; if ( pref == ICMPV6_ROUTER_PREF_INVALID || ! in6_dev -> cnf . accept_ra_rtr_pref ) pref = ICMPV6_ROUTER_PREF_MEDIUM ; # endif rt = rt6_get_dflt_router ( & ipv6_hdr ( skb ) -> saddr , skb -> dev ) ; if ( rt ) { neigh = dst_neigh_lookup ( & rt -> dst , & ipv6_hdr ( skb ) -> saddr ) ; if ( ! neigh ) { ND_PRINTK ( 0 , err , ""RA:%sgotdefaultrouterwithoutneighbour\\n"" , __func__ ) ; ip6_rt_put ( rt ) ; return ; } } if ( rt && lifetime == 0 ) { ip6_del_rt ( rt ) ; rt = NULL ; } ND_PRINTK ( 3 , info , ""RA:rt:%plifetime:%d,fordev:%s\\n"" , rt , lifetime , skb -> dev -> name ) ; if ( rt == NULL && lifetime ) { ND_PRINTK ( 3 , info , ""RA:addingdefaultrouter\\n"" ) ; rt = rt6_add_dflt_router ( & ipv6_hdr ( skb ) -> saddr , skb -> dev , pref ) ; if ( rt == NULL ) { ND_PRINTK ( 0 , err , ""RA:%sfailedtoadddefaultroute\\n"" , __func__ ) ; return ; } neigh = dst_neigh_lookup ( & rt -> dst , & ipv6_hdr ( skb ) -> saddr ) ; if ( neigh == NULL ) { ND_PRINTK ( 0 , err , ""RA:%sgotdefaultrouterwithoutneighbour\\n"" , __func__ ) ; ip6_rt_put ( rt ) ; return ; } neigh -> flags |= NTF_ROUTER ; } else if ( rt ) { rt -> rt6i_flags = ( rt -> rt6i_flags & ~ RTF_PREF_MASK ) | RTF_PREF ( pref ) ; } if ( rt ) rt6_set_expires ( rt , jiffies + ( HZ * lifetime ) ) ; if ( ra_msg -> icmph . icmp6_hop_limit ) { in6_dev -> cnf . hop_limit = ra_msg -> icmph . icmp6_hop_limit ; if ( rt ) dst_metric_set ( & rt -> dst , RTAX_HOPLIMIT , ra_msg -> icmph . icmp6_hop_limit ) ; } skip_defrtr : if ( in6_dev -> nd_parms ) { unsigned long rtime = ntohl ( ra_msg -> retrans_timer ) ; if ( rtime && rtime / 1000 < MAX_SCHEDULE_TIMEOUT / HZ ) { rtime = ( rtime * HZ ) / 1000 ; if ( rtime < HZ / 10 ) rtime = HZ / 10 ; NEIGH_VAR_SET ( in6_dev -> nd_parms , RETRANS_TIME , rtime ) ; in6_dev -> tstamp = jiffies ; inet6_ifinfo_notify ( RTM_NEWLINK , in6_dev ) ; } rtime = ntohl ( ra_msg -> reachable_time ) ; if ( rtime && rtime / 1000 < MAX_SCHEDULE_TIMEOUT / ( 3 * HZ ) ) { rtime = ( rtime * HZ ) / 1000 ; if ( rtime < HZ / 10 ) rtime = HZ / 10 ; if ( rtime != NEIGH_VAR ( in6_dev -> nd_parms , BASE_REACHABLE_TIME ) ) { NEIGH_VAR_SET ( in6_dev -> nd_parms , BASE_REACHABLE_TIME , rtime ) ; NEIGH_VAR_SET ( in6_dev -> nd_parms , GC_STALETIME , 3 * rtime ) ; in6_dev -> nd_parms -> reachable_time = neigh_rand_reach_time ( rtime ) ; in6_dev -> tstamp = jiffies ; inet6_ifinfo_notify ( RTM_NEWLINK , in6_dev ) ; } } } skip_linkparms : if ( ! neigh ) neigh = __neigh_lookup ( & nd_tbl , & ipv6_hdr ( skb ) -> saddr , skb -> dev , 1 ) ; if ( neigh ) { u8 * lladdr = NULL ; if ( ndopts . nd_opts_src_lladdr ) { lladdr = ndisc_opt_addr_data ( ndopts . nd_opts_src_lladdr , skb -> dev ) ; if ( ! lladdr ) { ND_PRINTK ( 2 , warn , ""RA:invalidlink-layeraddresslength\\n"" ) ; goto out ; } } neigh_update ( neigh , lladdr , NUD_STALE , NEIGH_UPDATE_F_WEAK_OVERRIDE | NEIGH_UPDATE_F_OVERRIDE | NEIGH_UPDATE_F_OVERRIDE_ISROUTER | NEIGH_UPDATE_F_ISROUTER ) ; } if ( ! ipv6_accept_ra ( in6_dev ) ) { ND_PRINTK ( 2 , info , ""RA:%s,accept_raisfalsefordev:%s\\n"" , __func__ , skb -> dev -> name ) ; goto out ; } # ifdef CONFIG_IPV6_ROUTE_INFO if ( ! in6_dev -> cnf . accept_ra_from_local && ipv6_chk_addr ( dev_net ( in6_dev -> dev ) , & ipv6_hdr ( skb ) -> saddr , NULL , 0 ) ) { ND_PRINTK ( 2 , info , ""RAfromlocaladdressdetectedondev:%s:routerinfoignored.\\n"" , skb -> dev -> name ) ; goto skip_routeinfo ; } if ( in6_dev -> cnf . accept_ra_rtr_pref && ndopts . nd_opts_ri ) { struct nd_opt_hdr * p ; for ( p = ndopts . nd_opts_ri ; p ; p = ndisc_next_option ( p , ndopts . nd_opts_ri_end ) ) { struct route_info * ri = ( struct route_info * ) p ; # ifdef CONFIG_IPV6_NDISC_NODETYPE if ( skb -> ndisc_nodetype == NDISC_NODETYPE_NODEFAULT && ri -> prefix_len == 0 ) continue ; # endif if ( ri -> prefix_len == 0 && ! in6_dev -> cnf . accept_ra_defrtr ) continue ; if ( ri -> prefix_len > in6_dev -> cnf . accept_ra_rt_info_max_plen ) continue ; rt6_route_rcv ( skb -> dev , ( u8 * ) p , ( p -> nd_opt_len ) << 3 , & ipv6_hdr ( skb ) -> saddr ) ; } } skip_routeinfo : # endif # ifdef CONFIG_IPV6_NDISC_NODETYPE if ( skb -> ndisc_nodetype == NDISC_NODETYPE_NODEFAULT ) { ND_PRINTK ( 2 , info , ""RA:%s,nodetypeisNODEFAULT(interiorroutes),dev:%s\\n"" , __func__ , skb -> dev -> name ) ; goto out ; } # endif if ( in6_dev -> cnf . accept_ra_pinfo && ndopts . nd_opts_pi ) { struct nd_opt_hdr * p ; for ( p = ndopts . nd_opts_pi ; p ; p = ndisc_next_option ( p , ndopts . nd_opts_pi_end ) ) { addrconf_prefix_rcv ( skb -> dev , ( u8 * ) p , ( p -> nd_opt_len ) << 3 , ndopts . nd_opts_src_lladdr != NULL ) ; } } if ( ndopts . nd_opts_mtu && in6_dev -> cnf . accept_ra_mtu ) { __be32 n ; u32 mtu ; memcpy ( & n , ( ( u8 * ) ( ndopts . nd_opts_mtu + 1 ) ) + 2 , sizeof ( mtu ) ) ; mtu = ntohl ( n ) ; if ( mtu < IPV6_MIN_MTU || mtu > skb -> dev -> mtu ) { ND_PRINTK ( 2 , warn , ""RA:invalidmtu:%d\\n"" , mtu ) ; } else if ( in6_dev -> cnf . mtu6 != mtu ) { in6_dev -> cnf . mtu6 = mtu ; if ( rt ) dst_metric_set ( & rt -> dst , RTAX_MTU , mtu ) ; rt6_mtu_change ( skb -> dev , mtu ) ; } } if ( ndopts . nd_useropts ) { struct nd_opt_hdr * p ; for ( p = ndopts . nd_useropts ; p ; p = ndisc_next_useropt ( p , ndopts . nd_useropts_end ) ) { ndisc_ra_useropt ( skb , p ) ; } } if ( ndopts . nd_opts_tgt_lladdr || ndopts . nd_opts_rh ) { ND_PRINTK ( 2 , warn , ""RA:invalidRAoptions\\n"" ) ; } out : ip6_rt_put ( rt ) ; if ( neigh ) neigh_release ( neigh ) ; } "," icmp6_hop_limit ) { if ( cnf . hop_limit < ra_msg -> icmph icmph . icmp6_hop_limit ) { in6_dev -> cnf . hop_limit = ra_msg -> icmph . icmp6_hop_limit ; } else { ND_PRINTK ( 2 , warn , ""RA:Gotrouteadvertisementwithlowerhop_limitthancurrent\\n"" ) ; } if ( rt ",torvalds@linux/6fd99094de2b83d1d4c8457f2c83483b2828e75a,CVE-2015-2922,https://github.com/torvalds/linux/commit/6fd99094de2b83d1d4c8457f2c83483b2828e75a,2015-05-27T10:59Z 572,CWE-125,"CWE-125 static void l2tp_proxy_auth_id_print ( netdissect_options * ndo , const u_char * dat ) { const uint16_t * ptr = ( const uint16_t * ) dat ; ND_PRINT ( ( ndo , ""%u"" , EXTRACT_16BITS ( ptr ) & L2TP_PROXY_AUTH_ID_MASK ) ) ; } "," u_char * dat , u_int length ) dat ; if ( length < 2 ) { ND_PRINT ( ( ndo , ""AVPtooshort"" ) ) ; return ; } ",the-tcpdump-group@tcpdump/cc4a7391c616be7a64ed65742ef9ed3f106eb165,CVE-2017-13006,https://github.com/the-tcpdump-group/tcpdump/commit/cc4a7391c616be7a64ed65742ef9ed3f106eb165,2017-09-14T06:29Z 573,CWE-200,"CWE-200 static inline int xfrm_replay_verify_len ( struct xfrm_replay_state_esn * replay_esn , struct nlattr * rp ) { struct xfrm_replay_state_esn * up ; if ( ! replay_esn || ! rp ) return 0 ; up = nla_data ( rp ) ; if ( xfrm_replay_state_esn_len ( replay_esn ) != xfrm_replay_state_esn_len ( up ) ) return - EINVAL ; return 0 ; } "," * up ; int ulen ; rp ) ; ulen = xfrm_replay_state_esn_len ( up ) ; if ( nla_len ( rp ) < ulen || xfrm_replay_state_esn_len ( replay_esn replay_esn ) != ulen ) return - ",torvalds@linux/ecd7918745234e423dd87fcc0c077da557909720,CVE-2012-6536,https://github.com/torvalds/linux/commit/ecd7918745234e423dd87fcc0c077da557909720,2013-03-15T20:55Z 574,CWE-190,"CWE-190 int perf_cpu_time_max_percent_handler ( struct ctl_table * table , int write , void __user * buffer , size_t * lenp , loff_t * ppos ) { int ret = proc_dointvec ( table , write , buffer , lenp , ppos ) ; if ( ret || ! write ) return ret ; if ( sysctl_perf_cpu_time_max_percent == 100 || sysctl_perf_cpu_time_max_percent == 0 ) { printk ( KERN_WARNING ""perf:Dynamicinterruptthrottlingdisabled,canhangyoursystem!\\n"" ) ; WRITE_ONCE ( perf_sample_allowed_ns , 0 ) ; } else { update_perf_cpu_limits ( ) ; } return 0 ; } "," int ret = proc_dointvec_minmax ( table , ",torvalds@linux/1572e45a924f254d9570093abde46430c3172e3d,CVE-2017-18255,https://github.com/torvalds/linux/commit/1572e45a924f254d9570093abde46430c3172e3d,2018-03-31T17:29Z 575,CWE-119,"CWE-119 int vp8_full_search_sadx3 ( MACROBLOCK * x , BLOCK * b , BLOCKD * d , int_mv * ref_mv , int sad_per_bit , int distance , vp8_variance_fn_ptr_t * fn_ptr , int * mvcost [ 2 ] , int_mv * center_mv ) { unsigned char * what = ( * ( b -> base_src ) + b -> src ) ; int what_stride = b -> src_stride ; unsigned char * in_what ; int pre_stride = x -> e_mbd . pre . y_stride ; unsigned char * base_pre = x -> e_mbd . pre . y_buffer ; int in_what_stride = pre_stride ; int mv_stride = pre_stride ; unsigned char * bestaddress ; int_mv * best_mv = & d -> bmi . mv ; int_mv this_mv ; unsigned int bestsad ; unsigned int thissad ; int r , c ; unsigned char * check_here ; int ref_row = ref_mv -> as_mv . row ; int ref_col = ref_mv -> as_mv . col ; int row_min = ref_row - distance ; int row_max = ref_row + distance ; int col_min = ref_col - distance ; int col_max = ref_col + distance ; unsigned int sad_array [ 3 ] ; int * mvsadcost [ 2 ] ; int_mv fcenter_mv ; mvsadcost [ 0 ] = x -> mvsadcost [ 0 ] ; mvsadcost [ 1 ] = x -> mvsadcost [ 1 ] ; fcenter_mv . as_mv . row = center_mv -> as_mv . row >> 3 ; fcenter_mv . as_mv . col = center_mv -> as_mv . col >> 3 ; in_what = base_pre + d -> offset ; bestaddress = in_what + ( ref_row * pre_stride ) + ref_col ; best_mv -> as_mv . row = ref_row ; best_mv -> as_mv . col = ref_col ; bestsad = fn_ptr -> sdf ( what , what_stride , bestaddress , in_what_stride , UINT_MAX ) + mvsad_err_cost ( best_mv , & fcenter_mv , mvsadcost , sad_per_bit ) ; if ( col_min < x -> mv_col_min ) col_min = x -> mv_col_min ; if ( col_max > x -> mv_col_max ) col_max = x -> mv_col_max ; if ( row_min < x -> mv_row_min ) row_min = x -> mv_row_min ; if ( row_max > x -> mv_row_max ) row_max = x -> mv_row_max ; for ( r = row_min ; r < row_max ; r ++ ) { this_mv . as_mv . row = r ; check_here = r * mv_stride + in_what + col_min ; c = col_min ; while ( ( c + 2 ) < col_max ) { int i ; fn_ptr -> sdx3f ( what , what_stride , check_here , in_what_stride , sad_array ) ; for ( i = 0 ; i < 3 ; i ++ ) { thissad = sad_array [ i ] ; if ( thissad < bestsad ) { this_mv . as_mv . col = c ; thissad += mvsad_err_cost ( & this_mv , & fcenter_mv , mvsadcost , sad_per_bit ) ; if ( thissad < bestsad ) { bestsad = thissad ; best_mv -> as_mv . row = r ; best_mv -> as_mv . col = c ; bestaddress = check_here ; } } check_here ++ ; c ++ ; } } while ( c < col_max ) { thissad = fn_ptr -> sdf ( what , what_stride , check_here , in_what_stride , bestsad ) ; if ( thissad < bestsad ) { this_mv . as_mv . col = c ; thissad += mvsad_err_cost ( & this_mv , & fcenter_mv , mvsadcost , sad_per_bit ) ; if ( thissad < bestsad ) { bestsad = thissad ; best_mv -> as_mv . row = r ; best_mv -> as_mv . col = c ; bestaddress = check_here ; } } check_here ++ ; c ++ ; } } this_mv . as_mv . row = best_mv -> as_mv . row << 3 ; this_mv . as_mv . col = best_mv -> as_mv . col << 3 ; return fn_ptr -> vf ( what , what_stride , bestaddress , in_what_stride , & thissad ) + mv_err_cost ( & this_mv , center_mv , mvcost , x -> errorperbit ) ; } "," bestaddress , in_what_stride ) + mvsad_err_cost check_here , in_what_stride ) ; if ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 576,CWE-125,"CWE-125 opj_pi_iterator_t * opj_pi_create_decode ( opj_image_t * p_image , opj_cp_t * p_cp , OPJ_UINT32 p_tile_no ) { OPJ_UINT32 pino ; OPJ_UINT32 compno , resno ; OPJ_UINT32 * l_tmp_data ; OPJ_UINT32 * * l_tmp_ptr ; OPJ_UINT32 l_max_res ; OPJ_UINT32 l_max_prec ; OPJ_INT32 l_tx0 , l_tx1 , l_ty0 , l_ty1 ; OPJ_UINT32 l_dx_min , l_dy_min ; OPJ_UINT32 l_bound ; OPJ_UINT32 l_step_p , l_step_c , l_step_r , l_step_l ; OPJ_UINT32 l_data_stride ; opj_pi_iterator_t * l_pi = 00 ; opj_tcp_t * l_tcp = 00 ; const opj_tccp_t * l_tccp = 00 ; opj_pi_comp_t * l_current_comp = 00 ; opj_image_comp_t * l_img_comp = 00 ; opj_pi_iterator_t * l_current_pi = 00 ; OPJ_UINT32 * l_encoding_value_ptr = 00 ; assert ( p_cp != 00 ) ; assert ( p_image != 00 ) ; assert ( p_tile_no < p_cp -> tw * p_cp -> th ) ; l_tcp = & p_cp -> tcps [ p_tile_no ] ; l_bound = l_tcp -> numpocs + 1 ; l_data_stride = 4 * OPJ_J2K_MAXRLVLS ; l_tmp_data = ( OPJ_UINT32 * ) opj_malloc ( l_data_stride * p_image -> numcomps * sizeof ( OPJ_UINT32 ) ) ; if ( ! l_tmp_data ) { return 00 ; } l_tmp_ptr = ( OPJ_UINT32 * * ) opj_malloc ( p_image -> numcomps * sizeof ( OPJ_UINT32 * ) ) ; if ( ! l_tmp_ptr ) { opj_free ( l_tmp_data ) ; return 00 ; } l_pi = opj_pi_create ( p_image , p_cp , p_tile_no ) ; if ( ! l_pi ) { opj_free ( l_tmp_data ) ; opj_free ( l_tmp_ptr ) ; return 00 ; } l_encoding_value_ptr = l_tmp_data ; for ( compno = 0 ; compno < p_image -> numcomps ; ++ compno ) { l_tmp_ptr [ compno ] = l_encoding_value_ptr ; l_encoding_value_ptr += l_data_stride ; } opj_get_all_encoding_parameters ( p_image , p_cp , p_tile_no , & l_tx0 , & l_tx1 , & l_ty0 , & l_ty1 , & l_dx_min , & l_dy_min , & l_max_prec , & l_max_res , l_tmp_ptr ) ; l_step_p = 1 ; l_step_c = l_max_prec * l_step_p ; l_step_r = p_image -> numcomps * l_step_c ; l_step_l = l_max_res * l_step_r ; l_current_pi = l_pi ; l_current_pi -> include = ( OPJ_INT16 * ) opj_calloc ( ( l_tcp -> numlayers + 1 ) * l_step_l , sizeof ( OPJ_INT16 ) ) ; if ( ! l_current_pi -> include ) { opj_free ( l_tmp_data ) ; opj_free ( l_tmp_ptr ) ; opj_pi_destroy ( l_pi , l_bound ) ; return 00 ; } l_current_comp = l_current_pi -> comps ; l_img_comp = p_image -> comps ; l_tccp = l_tcp -> tccps ; l_current_pi -> tx0 = l_tx0 ; l_current_pi -> ty0 = l_ty0 ; l_current_pi -> tx1 = l_tx1 ; l_current_pi -> ty1 = l_ty1 ; l_current_pi -> step_p = l_step_p ; l_current_pi -> step_c = l_step_c ; l_current_pi -> step_r = l_step_r ; l_current_pi -> step_l = l_step_l ; for ( compno = 0 ; compno < l_current_pi -> numcomps ; ++ compno ) { opj_pi_resolution_t * l_res = l_current_comp -> resolutions ; l_encoding_value_ptr = l_tmp_ptr [ compno ] ; l_current_comp -> dx = l_img_comp -> dx ; l_current_comp -> dy = l_img_comp -> dy ; for ( resno = 0 ; resno < l_current_comp -> numresolutions ; resno ++ ) { l_res -> pdx = * ( l_encoding_value_ptr ++ ) ; l_res -> pdy = * ( l_encoding_value_ptr ++ ) ; l_res -> pw = * ( l_encoding_value_ptr ++ ) ; l_res -> ph = * ( l_encoding_value_ptr ++ ) ; ++ l_res ; } ++ l_current_comp ; ++ l_img_comp ; ++ l_tccp ; } ++ l_current_pi ; for ( pino = 1 ; pino < l_bound ; ++ pino ) { l_current_comp = l_current_pi -> comps ; l_img_comp = p_image -> comps ; l_tccp = l_tcp -> tccps ; l_current_pi -> tx0 = l_tx0 ; l_current_pi -> ty0 = l_ty0 ; l_current_pi -> tx1 = l_tx1 ; l_current_pi -> ty1 = l_ty1 ; l_current_pi -> step_p = l_step_p ; l_current_pi -> step_c = l_step_c ; l_current_pi -> step_r = l_step_r ; l_current_pi -> step_l = l_step_l ; for ( compno = 0 ; compno < l_current_pi -> numcomps ; ++ compno ) { opj_pi_resolution_t * l_res = l_current_comp -> resolutions ; l_encoding_value_ptr = l_tmp_ptr [ compno ] ; l_current_comp -> dx = l_img_comp -> dx ; l_current_comp -> dy = l_img_comp -> dy ; for ( resno = 0 ; resno < l_current_comp -> numresolutions ; resno ++ ) { l_res -> pdx = * ( l_encoding_value_ptr ++ ) ; l_res -> pdy = * ( l_encoding_value_ptr ++ ) ; l_res -> pw = * ( l_encoding_value_ptr ++ ) ; l_res -> ph = * ( l_encoding_value_ptr ++ ) ; ++ l_res ; } ++ l_current_comp ; ++ l_img_comp ; ++ l_tccp ; } l_current_pi -> include = ( l_current_pi - 1 ) -> include ; ++ l_current_pi ; } opj_free ( l_tmp_data ) ; l_tmp_data = 00 ; opj_free ( l_tmp_ptr ) ; l_tmp_ptr = 00 ; if ( l_tcp -> POC ) { opj_pi_update_decode_poc ( l_pi , l_tcp , l_max_prec , l_max_res ) ; } else { opj_pi_update_decode_not_poc ( l_pi , l_tcp , l_max_prec , l_max_res ) ; } return l_pi ; } "," -> include = 00 ; if ( l_step_l <= ( SIZE_MAX / ( l_tcp -> numlayers + 1U ) ) ) { l_current_pi -> include = ) ) ; } ",uclouvain@openjpeg/c16bc057ba3f125051c9966cf1f5b68a05681de4,CVE-2016-7163,https://github.com/uclouvain/openjpeg/commit/c16bc057ba3f125051c9966cf1f5b68a05681de4,2016-09-21T14:25Z 577,CWE-269,"CWE-269 struct crypto_template * crypto_lookup_template ( const char * name ) { return try_then_request_module ( __crypto_lookup_template ( name ) , ""%s"" , name ) ; } "," name ) , ""crypto-%s"" , name ) ",torvalds@linux/4943ba16bbc2db05115707b3ff7b4874e9e3c560,CVE-2014-9644,https://github.com/torvalds/linux/commit/4943ba16bbc2db05115707b3ff7b4874e9e3c560,2015-03-02T11:59Z 578,CWE-000,"CWE-000 static int kvm_vm_ioctl_set_pit2 ( struct kvm * kvm , struct kvm_pit_state2 * ps ) { int start = 0 ; u32 prev_legacy , cur_legacy ; mutex_lock ( & kvm -> arch . vpit -> pit_state . lock ) ; prev_legacy = kvm -> arch . vpit -> pit_state . flags & KVM_PIT_FLAGS_HPET_LEGACY ; cur_legacy = ps -> flags & KVM_PIT_FLAGS_HPET_LEGACY ; if ( ! prev_legacy && cur_legacy ) start = 1 ; memcpy ( & kvm -> arch . vpit -> pit_state . channels , & ps -> channels , sizeof ( kvm -> arch . vpit -> pit_state . channels ) ) ; kvm -> arch . vpit -> pit_state . flags = ps -> flags ; kvm_pit_load_count ( kvm , 0 , kvm -> arch . vpit -> pit_state . channels [ 0 ] . count , start ) ; mutex_unlock ( & kvm -> arch . vpit -> pit_state . lock ) ; return 0 ; } "," start = 0 ; int i -> flags ; for ( i = 0 ; i < 3 ; i ++ ) ( kvm , i , kvm -> . channels [ i ] . count ",torvalds@linux/0185604c2d82c560dab2f2933a18f797e74ab5a8,CVE-2015-7513,https://github.com/torvalds/linux/commit/0185604c2d82c560dab2f2933a18f797e74ab5a8,2016-02-08T03:59Z 579,CWE-119,"CWE-119 static void encode_nonrd_sb_row ( VP9_COMP * cpi , const TileInfo * const tile , int mi_row , TOKENEXTRA * * tp ) { VP9_COMMON * cm = & cpi -> common ; MACROBLOCKD * xd = & cpi -> mb . e_mbd ; int mi_col ; vpx_memset ( & xd -> left_context , 0 , sizeof ( xd -> left_context ) ) ; vpx_memset ( xd -> left_seg_context , 0 , sizeof ( xd -> left_seg_context ) ) ; for ( mi_col = tile -> mi_col_start ; mi_col < tile -> mi_col_end ; mi_col += MI_BLOCK_SIZE ) { int dummy_rate = 0 ; int64_t dummy_dist = 0 ; const int idx_str = cm -> mi_stride * mi_row + mi_col ; MODE_INFO * * mi_8x8 = cm -> mi_grid_visible + idx_str ; MODE_INFO * * prev_mi_8x8 = cm -> prev_mi_grid_visible + idx_str ; BLOCK_SIZE bsize ; cpi -> mb . source_variance = UINT_MAX ; vp9_zero ( cpi -> mb . pred_mv ) ; switch ( cpi -> sf . partition_search_type ) { case VAR_BASED_PARTITION : choose_partitioning ( cpi , tile , mi_row , mi_col ) ; nonrd_use_partition ( cpi , tile , mi_8x8 , tp , mi_row , mi_col , BLOCK_64X64 , 1 , & dummy_rate , & dummy_dist ) ; break ; case SOURCE_VAR_BASED_PARTITION : set_offsets ( cpi , tile , mi_row , mi_col , BLOCK_64X64 ) ; set_source_var_based_partition ( cpi , tile , mi_8x8 , mi_row , mi_col ) ; nonrd_use_partition ( cpi , tile , mi_8x8 , tp , mi_row , mi_col , BLOCK_64X64 , 1 , & dummy_rate , & dummy_dist ) ; break ; case VAR_BASED_FIXED_PARTITION : case FIXED_PARTITION : bsize = cpi -> sf . partition_search_type == FIXED_PARTITION ? cpi -> sf . always_this_block_size : get_nonrd_var_based_fixed_partition ( cpi , mi_row , mi_col ) ; set_fixed_partitioning ( cpi , tile , mi_8x8 , mi_row , mi_col , bsize ) ; nonrd_use_partition ( cpi , tile , mi_8x8 , tp , mi_row , mi_col , BLOCK_64X64 , 1 , & dummy_rate , & dummy_dist ) ; break ; case REFERENCE_PARTITION : if ( cpi -> sf . partition_check || sb_has_motion ( cm , prev_mi_8x8 ) ) { nonrd_pick_partition ( cpi , tile , tp , mi_row , mi_col , BLOCK_64X64 , & dummy_rate , & dummy_dist , 1 , INT64_MAX ) ; } else { copy_partitioning ( cm , mi_8x8 , prev_mi_8x8 ) ; nonrd_use_partition ( cpi , tile , mi_8x8 , tp , mi_row , mi_col , BLOCK_64X64 , 1 , & dummy_rate , & dummy_dist ) ; } break ; default : assert ( 0 ) ; } } } "," * cpi , ThreadData * td , TileDataEnc * tile_data , int mi_row , TOKENEXTRA * * tp ) { SPEED_FEATURES * const sf = & cpi -> sf ; VP9_COMMON * const cm = & cpi -> common ; TileInfo * const TileInfo * const tile_info = & tile_data -> tile_info ; MACROBLOCK * const x = & td -> mb ; MACROBLOCKD * const xd = & x -> e_mbd ; int mi_col ; memset ( & xd -> left_context , 0 , sizeof ( xd -> left_context xd -> left_context ) ) ; memset ( xd -> left_seg_context ( xd -> left_seg_context ) ) ; ( mi_col = tile_info -> mi_col_start ; ; mi_col < tile_info -> mi_col_end ; MI_BLOCK_SIZE ) { const struct segmentation * const seg = & cm -> seg ; RD_COST dummy_rdc ; const int MODE_INFO * * mi = cm -> + idx_str ; PARTITION_SEARCH_TYPE partition_search_type = sf -> partition_search_type ; BLOCK_SIZE bsize ; BLOCK_SIZE bsize = BLOCK_64X64 ; int seg_skip = 0 ; x -> source_variance = UINT_MAX ; vp9_zero ( x -> pred_mv ) ; pred_mv ) ; vp9_rd_cost_init ( & dummy_rdc ) ; x -> color_sensitivity [ 0 ] = 0 ; x -> color_sensitivity [ 1 ] = 0 ; if ( seg -> enabled ) { const uint8_t * const map = seg -> update_map ? cpi -> segmentation_map : cm -> last_frame_seg_map ; int segment_id = get_segment_id ( cm , map , BLOCK_64X64 , mi_row , mi_col ) ; seg_skip = segfeature_active ( seg , segment_id , SEG_LVL_SKIP ) ; if ( seg_skip ) { partition_search_type = FIXED_PARTITION ; } } switch ( partition_search_type ) { ( cpi , tile_info , x , mi_row , ( cpi , td , tile_data , mi , tp , , mi_col , BLOCK_64X64 , 1 , & 1 , & dummy_rdc , td -> pc_root ) ; break case SOURCE_VAR_BASED_PARTITION : set_source_var_based_partition ( cpi ( cpi , tile_info , x , mi , mi_row , ( cpi , td , tile_data , mi , tp , , mi_col , BLOCK_64X64 , 1 , & 1 , & dummy_rdc , td -> pc_root ) ; break ; break ; case FIXED_PARTITION : case FIXED_PARTITION : if ( ! seg_skip ) bsize = sf -> always_this_block_size ; set_fixed_partitioning ( ( cpi , tile_info , mi , mi_row , ( cpi , td , tile_data , mi , tp , , mi_col , BLOCK_64X64 , 1 , & 1 , & dummy_rdc , td -> pc_root ) ; break case REFERENCE_PARTITION : set_offsets ( cpi , tile_info , x , mi_row , mi_col , BLOCK_64X64 ) ; ( cpi -> oxcf . aq_mode == CYCLIC_REFRESH_AQ && cm -> seg . enabled && xd -> mi [ 0 ] -> mbmi . segment_id ) { if ( cm -> width <= 352 && cm -> height <= 288 ) x -> max_partition_size = BLOCK_32X32 ; else x -> max_partition_size = BLOCK_64X64 ; x -> min_partition_size = BLOCK_8X8 ; nonrd_pick_partition ( cpi ( cpi , td , tile_data , tp , , mi_col , BLOCK_64X64 , & dummy_rdc , 1 , 1 , INT64_MAX , td -> pc_root } else { choose_partitioning ( cpi , tile_info , x , mi_row , mi_col ) ; if ( cm -> frame_type == KEY_FRAME ) nonrd_use_partition ( cpi ( cpi , td , tile_data , mi , tp , 1 , & dummy_rdc , td -> pc_root ) ; else nonrd_select_partition ( cpi , td , tile_data , mi , tp , mi_row , mi_col , BLOCK_64X64 , 1 , & dummy_rdc , td -> pc_root ) ; } 0 ) ; break ; ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 580,CWE-416,"CWE-416 static int link_pipe ( struct pipe_inode_info * ipipe , struct pipe_inode_info * opipe , size_t len , unsigned int flags ) { struct pipe_buffer * ibuf , * obuf ; int ret = 0 , i = 0 , nbuf ; pipe_double_lock ( ipipe , opipe ) ; do { if ( ! opipe -> readers ) { send_sig ( SIGPIPE , current , 0 ) ; if ( ! ret ) ret = - EPIPE ; break ; } if ( i >= ipipe -> nrbufs || opipe -> nrbufs >= opipe -> buffers ) break ; ibuf = ipipe -> bufs + ( ( ipipe -> curbuf + i ) & ( ipipe -> buffers - 1 ) ) ; nbuf = ( opipe -> curbuf + opipe -> nrbufs ) & ( opipe -> buffers - 1 ) ; pipe_buf_get ( ipipe , ibuf ) ; obuf = opipe -> bufs + nbuf ; * obuf = * ibuf ; obuf -> flags &= ~ PIPE_BUF_FLAG_GIFT ; if ( obuf -> len > len ) obuf -> len = len ; opipe -> nrbufs ++ ; ret += obuf -> len ; len -= obuf -> len ; i ++ ; } while ( len ) ; if ( ! ret && ipipe -> waiting_writers && ( flags & SPLICE_F_NONBLOCK ) ) ret = - EAGAIN ; pipe_unlock ( ipipe ) ; pipe_unlock ( opipe ) ; if ( ret > 0 ) wakeup_pipe_readers ( opipe ) ; return ret ; } "," 1 ) ; if ( ! , ibuf ) ) { if ( ret == 0 ) ret = - EFAULT ; break ; } obuf = opipe ",torvalds@linux/15fab63e1e57be9fdb5eec1bbc5916e9825e9acb,CVE-2019-11487,https://github.com/torvalds/linux/commit/15fab63e1e57be9fdb5eec1bbc5916e9825e9acb,2019-04-23T22:29Z 581,CWE-20,"CWE-20 static bool dccp_new ( struct nf_conn * ct , const struct sk_buff * skb , unsigned int dataoff , unsigned int * timeouts ) { struct net * net = nf_ct_net ( ct ) ; struct dccp_net * dn ; struct dccp_hdr _dh , * dh ; const char * msg ; u_int8_t state ; dh = skb_header_pointer ( skb , dataoff , sizeof ( _dh ) , & dh ) ; BUG_ON ( dh == NULL ) ; state = dccp_state_table [ CT_DCCP_ROLE_CLIENT ] [ dh -> dccph_type ] [ CT_DCCP_NONE ] ; switch ( state ) { default : dn = dccp_pernet ( net ) ; if ( dn -> dccp_loose == 0 ) { msg = ""nf_ct_dccp:notpickingupexistingconnection"" ; goto out_invalid ; } case CT_DCCP_REQUEST : break ; case CT_DCCP_INVALID : msg = ""nf_ct_dccp:invalidstatetransition"" ; goto out_invalid ; } ct -> proto . dccp . role [ IP_CT_DIR_ORIGINAL ] = CT_DCCP_ROLE_CLIENT ; ct -> proto . dccp . role [ IP_CT_DIR_REPLY ] = CT_DCCP_ROLE_SERVER ; ct -> proto . dccp . state = CT_DCCP_NONE ; ct -> proto . dccp . last_pkt = DCCP_PKT_REQUEST ; ct -> proto . dccp . last_dir = IP_CT_DIR_ORIGINAL ; ct -> proto . dccp . handshake_seq = 0 ; return true ; out_invalid : if ( LOG_INVALID ( net , IPPROTO_DCCP ) ) nf_log_packet ( net , nf_ct_l3num ( ct ) , 0 , skb , NULL , NULL , NULL , ""%s"" , msg ) ; return false ; } "," ) , & _dh ) ; BUG_ON ",torvalds@linux/b22f5126a24b3b2f15448c3f2a254fc10cbc2b92,CVE-2014-2523,https://github.com/torvalds/linux/commit/b22f5126a24b3b2f15448c3f2a254fc10cbc2b92,2014-03-24T16:40Z 582,CWE-284,"CWE-284 static int http_RecvPostMessage ( http_parser_t * parser , SOCKINFO * info , char * filename , struct SendInstruction * Instr ) { size_t Data_Buf_Size = 1024 ; char Buf [ 1024 ] ; int Timeout = - 1 ; FILE * Fp ; parse_status_t status = PARSE_OK ; int ok_on_close = FALSE ; size_t entity_offset = 0 ; int num_read = 0 ; int ret_code = HTTP_OK ; if ( Instr && Instr -> IsVirtualFile ) { Fp = ( virtualDirCallback . open ) ( filename , UPNP_WRITE ) ; if ( Fp == NULL ) return HTTP_INTERNAL_SERVER_ERROR ; } else { Fp = fopen ( filename , ""wb"" ) ; if ( Fp == NULL ) return HTTP_UNAUTHORIZED ; } parser -> position = POS_ENTITY ; do { if ( parser -> position != POS_COMPLETE ) status = parser_parse_entity ( parser ) ; if ( status == PARSE_INCOMPLETE_ENTITY ) { ok_on_close = TRUE ; } else if ( ( status != PARSE_SUCCESS ) && ( status != PARSE_CONTINUE_1 ) && ( status != PARSE_INCOMPLETE ) ) { ret_code = HTTP_BAD_REQUEST ; goto ExitFunction ; } while ( entity_offset + Data_Buf_Size > parser -> msg . entity . length && parser -> position != POS_COMPLETE ) { num_read = sock_read ( info , Buf , sizeof ( Buf ) , & Timeout ) ; if ( num_read > 0 ) { if ( membuffer_append ( & parser -> msg . msg , Buf , ( size_t ) num_read ) != 0 ) { parser -> http_error_code = HTTP_INTERNAL_SERVER_ERROR ; ret_code = HTTP_INTERNAL_SERVER_ERROR ; goto ExitFunction ; } status = parser_parse_entity ( parser ) ; if ( status == PARSE_INCOMPLETE_ENTITY ) { ok_on_close = TRUE ; } else if ( ( status != PARSE_SUCCESS ) && ( status != PARSE_CONTINUE_1 ) && ( status != PARSE_INCOMPLETE ) ) { ret_code = HTTP_BAD_REQUEST ; goto ExitFunction ; } } else if ( num_read == 0 ) { if ( ok_on_close ) { UpnpPrintf ( UPNP_INFO , HTTP , __FILE__ , __LINE__ , ""<<<(RECVD)<<<\\n%s\\n-----------------\\n"" , parser -> msg . msg . buf ) ; print_http_headers ( & parser -> msg ) ; parser -> position = POS_COMPLETE ; } else { parser -> http_error_code = HTTP_BAD_REQUEST ; ret_code = HTTP_BAD_REQUEST ; goto ExitFunction ; } } else { ret_code = HTTP_SERVICE_UNAVAILABLE ; goto ExitFunction ; } } if ( ( entity_offset + Data_Buf_Size ) > parser -> msg . entity . length ) { Data_Buf_Size = parser -> msg . entity . length - entity_offset ; } memcpy ( Buf , & parser -> msg . msg . buf [ parser -> entity_start_position + entity_offset ] , Data_Buf_Size ) ; entity_offset += Data_Buf_Size ; if ( Instr && Instr -> IsVirtualFile ) { int n = virtualDirCallback . write ( Fp , Buf , Data_Buf_Size ) ; if ( n < 0 ) { ret_code = HTTP_INTERNAL_SERVER_ERROR ; goto ExitFunction ; } } else { size_t n = fwrite ( Buf , 1 , Data_Buf_Size , Fp ) ; if ( n != Data_Buf_Size ) { ret_code = HTTP_INTERNAL_SERVER_ERROR ; goto ExitFunction ; } } } while ( parser -> position != POS_COMPLETE || entity_offset != parser -> msg . entity . length ) ; ExitFunction : if ( Instr && Instr -> IsVirtualFile ) { virtualDirCallback . close ( Fp ) ; } else { fclose ( Fp ) ; } return ret_code ; } "," } else { # ifdef UPNP_ENABLE_POST_WRITE return HTTP_UNAUTHORIZED ; # else return HTTP_NOT_FOUND ; # endif ",mjg59@pupnp-code/be0a01bdb83395d9f3a5ea09c1308a4f1a972cbd,CVE-2016-6255,https://github.com/mjg59/pupnp-code/commit/be0a01bdb83395d9f3a5ea09c1308a4f1a972cbd,2017-03-07T16:59Z 583,CWE-000,"CWE-000 static FILE * pw_tmpfile ( int lockfd ) { FILE * fd ; char * tmpname = NULL ; char * dir = ""/etc"" ; if ( ( fd = xfmkstemp ( & tmpname , dir ) ) == NULL ) { ulckpwdf ( ) ; err ( EXIT_FAILURE , _ ( ""can\'topentemporaryfile"" ) ) ; } copyfile ( lockfd , fileno ( fd ) ) ; tmp_file = tmpname ; return fd ; } "," = NULL ; if ( ( & tmpname , ""/etc"" , "".vipw"" ) ) == ",karelzak@util-linux/bde91c85bdc77975155058276f99d2e0f5eab5a9,CVE-2015-5224,https://github.com/karelzak/util-linux/commit/bde91c85bdc77975155058276f99d2e0f5eab5a9,2017-08-23T15:29Z 584,CWE-415,"CWE-415 int blkcg_init_queue ( struct request_queue * q ) { struct blkcg_gq * new_blkg , * blkg ; bool preloaded ; int ret ; new_blkg = blkg_alloc ( & blkcg_root , q , GFP_KERNEL ) ; if ( ! new_blkg ) return - ENOMEM ; preloaded = ! radix_tree_preload ( GFP_KERNEL ) ; rcu_read_lock ( ) ; spin_lock_irq ( q -> queue_lock ) ; blkg = blkg_create ( & blkcg_root , q , new_blkg ) ; spin_unlock_irq ( q -> queue_lock ) ; rcu_read_unlock ( ) ; if ( preloaded ) radix_tree_preload_end ( ) ; if ( IS_ERR ( blkg ) ) { blkg_free ( new_blkg ) ; return PTR_ERR ( blkg ) ; } q -> root_blkg = blkg ; q -> root_rl . blkg = blkg ; ret = blk_throtl_init ( q ) ; if ( ret ) { spin_lock_irq ( q -> queue_lock ) ; blkg_destroy_all ( q ) ; spin_unlock_irq ( q -> queue_lock ) ; } return ret ; } "," blkg ) ) return PTR_ERR ( blkg ) ; q -> root_blkg ",torvalds@linux/9b54d816e00425c3a517514e0d677bb3cec49258,CVE-2018-7480,https://github.com/torvalds/linux/commit/9b54d816e00425c3a517514e0d677bb3cec49258,2018-02-25T20:29Z 585,CWE-119,"CWE-119 static int xwd_decode_frame ( AVCodecContext * avctx , void * data , int * got_frame , AVPacket * avpkt ) { AVFrame * p = data ; const uint8_t * buf = avpkt -> data ; int i , ret , buf_size = avpkt -> size ; uint32_t version , header_size , vclass , ncolors ; uint32_t xoffset , be , bpp , lsize , rsize ; uint32_t pixformat , pixdepth , bunit , bitorder , bpad ; uint32_t rgb [ 3 ] ; uint8_t * ptr ; GetByteContext gb ; if ( buf_size < XWD_HEADER_SIZE ) return AVERROR_INVALIDDATA ; bytestream2_init ( & gb , buf , buf_size ) ; header_size = bytestream2_get_be32u ( & gb ) ; version = bytestream2_get_be32u ( & gb ) ; if ( version != XWD_VERSION ) { av_log ( avctx , AV_LOG_ERROR , ""unsupportedversion\\n"" ) ; return AVERROR_INVALIDDATA ; } if ( buf_size < header_size || header_size < XWD_HEADER_SIZE ) { av_log ( avctx , AV_LOG_ERROR , ""invalidheadersize\\n"" ) ; return AVERROR_INVALIDDATA ; } pixformat = bytestream2_get_be32u ( & gb ) ; pixdepth = bytestream2_get_be32u ( & gb ) ; avctx -> width = bytestream2_get_be32u ( & gb ) ; avctx -> height = bytestream2_get_be32u ( & gb ) ; xoffset = bytestream2_get_be32u ( & gb ) ; be = bytestream2_get_be32u ( & gb ) ; bunit = bytestream2_get_be32u ( & gb ) ; bitorder = bytestream2_get_be32u ( & gb ) ; bpad = bytestream2_get_be32u ( & gb ) ; bpp = bytestream2_get_be32u ( & gb ) ; lsize = bytestream2_get_be32u ( & gb ) ; vclass = bytestream2_get_be32u ( & gb ) ; rgb [ 0 ] = bytestream2_get_be32u ( & gb ) ; rgb [ 1 ] = bytestream2_get_be32u ( & gb ) ; rgb [ 2 ] = bytestream2_get_be32u ( & gb ) ; bytestream2_skipu ( & gb , 8 ) ; ncolors = bytestream2_get_be32u ( & gb ) ; bytestream2_skipu ( & gb , header_size - ( XWD_HEADER_SIZE - 20 ) ) ; av_log ( avctx , AV_LOG_DEBUG , ""pixformat%"" PRIu32 "",pixdepth%"" PRIu32 "",bunit%"" PRIu32 "",bitorder%"" PRIu32 "",bpad%"" PRIu32 ""\\n"" , pixformat , pixdepth , bunit , bitorder , bpad ) ; av_log ( avctx , AV_LOG_DEBUG , ""vclass%"" PRIu32 "",ncolors%"" PRIu32 "",bpp%"" PRIu32 "",be%"" PRIu32 "",lsize%"" PRIu32 "",xoffset%"" PRIu32 ""\\n"" , vclass , ncolors , bpp , be , lsize , xoffset ) ; av_log ( avctx , AV_LOG_DEBUG , ""red%0"" PRIx32 "",green%0"" PRIx32 "",blue%0"" PRIx32 ""\\n"" , rgb [ 0 ] , rgb [ 1 ] , rgb [ 2 ] ) ; if ( pixformat > XWD_Z_PIXMAP ) { av_log ( avctx , AV_LOG_ERROR , ""invalidpixmapformat\\n"" ) ; return AVERROR_INVALIDDATA ; } if ( pixdepth == 0 || pixdepth > 32 ) { av_log ( avctx , AV_LOG_ERROR , ""invalidpixmapdepth\\n"" ) ; return AVERROR_INVALIDDATA ; } if ( xoffset ) { avpriv_request_sample ( avctx , ""xoffset%"" PRIu32 """" , xoffset ) ; return AVERROR_PATCHWELCOME ; } if ( be > 1 ) { av_log ( avctx , AV_LOG_ERROR , ""invalidbyteorder\\n"" ) ; return AVERROR_INVALIDDATA ; } if ( bitorder > 1 ) { av_log ( avctx , AV_LOG_ERROR , ""invalidbitmapbitorder\\n"" ) ; return AVERROR_INVALIDDATA ; } if ( bunit != 8 && bunit != 16 && bunit != 32 ) { av_log ( avctx , AV_LOG_ERROR , ""invalidbitmapunit\\n"" ) ; return AVERROR_INVALIDDATA ; } if ( bpad != 8 && bpad != 16 && bpad != 32 ) { av_log ( avctx , AV_LOG_ERROR , ""invalidbitmapscan-linepad\\n"" ) ; return AVERROR_INVALIDDATA ; } if ( bpp == 0 || bpp > 32 ) { av_log ( avctx , AV_LOG_ERROR , ""invalidbitsperpixel\\n"" ) ; return AVERROR_INVALIDDATA ; } if ( ncolors > 256 ) { av_log ( avctx , AV_LOG_ERROR , ""invalidnumberofentriesincolormap\\n"" ) ; return AVERROR_INVALIDDATA ; } if ( ( ret = av_image_check_size ( avctx -> width , avctx -> height , 0 , NULL ) ) < 0 ) return ret ; rsize = FFALIGN ( avctx -> width * bpp , bpad ) / 8 ; if ( lsize < rsize ) { av_log ( avctx , AV_LOG_ERROR , ""invalidbytesperscan-line\\n"" ) ; return AVERROR_INVALIDDATA ; } if ( bytestream2_get_bytes_left ( & gb ) < ncolors * XWD_CMAP_SIZE + ( uint64_t ) avctx -> height * lsize ) { av_log ( avctx , AV_LOG_ERROR , ""inputbuffertoosmall\\n"" ) ; return AVERROR_INVALIDDATA ; } if ( pixformat != XWD_Z_PIXMAP ) { avpriv_report_missing_feature ( avctx , ""Pixmapformat%"" PRIu32 , pixformat ) ; return AVERROR_PATCHWELCOME ; } avctx -> pix_fmt = AV_PIX_FMT_NONE ; switch ( vclass ) { case XWD_STATIC_GRAY : case XWD_GRAY_SCALE : if ( bpp != 1 && bpp != 8 ) return AVERROR_INVALIDDATA ; if ( pixdepth == 1 ) { avctx -> pix_fmt = AV_PIX_FMT_MONOWHITE ; } else if ( pixdepth == 8 ) { avctx -> pix_fmt = AV_PIX_FMT_GRAY8 ; } break ; case XWD_STATIC_COLOR : case XWD_PSEUDO_COLOR : if ( bpp == 8 ) avctx -> pix_fmt = AV_PIX_FMT_PAL8 ; break ; case XWD_TRUE_COLOR : case XWD_DIRECT_COLOR : if ( bpp != 16 && bpp != 24 && bpp != 32 ) return AVERROR_INVALIDDATA ; if ( bpp == 16 && pixdepth == 15 ) { if ( rgb [ 0 ] == 0x7C00 && rgb [ 1 ] == 0x3E0 && rgb [ 2 ] == 0x1F ) avctx -> pix_fmt = be ? AV_PIX_FMT_RGB555BE : AV_PIX_FMT_RGB555LE ; else if ( rgb [ 0 ] == 0x1F && rgb [ 1 ] == 0x3E0 && rgb [ 2 ] == 0x7C00 ) avctx -> pix_fmt = be ? AV_PIX_FMT_BGR555BE : AV_PIX_FMT_BGR555LE ; } else if ( bpp == 16 && pixdepth == 16 ) { if ( rgb [ 0 ] == 0xF800 && rgb [ 1 ] == 0x7E0 && rgb [ 2 ] == 0x1F ) avctx -> pix_fmt = be ? AV_PIX_FMT_RGB565BE : AV_PIX_FMT_RGB565LE ; else if ( rgb [ 0 ] == 0x1F && rgb [ 1 ] == 0x7E0 && rgb [ 2 ] == 0xF800 ) avctx -> pix_fmt = be ? AV_PIX_FMT_BGR565BE : AV_PIX_FMT_BGR565LE ; } else if ( bpp == 24 ) { if ( rgb [ 0 ] == 0xFF0000 && rgb [ 1 ] == 0xFF00 && rgb [ 2 ] == 0xFF ) avctx -> pix_fmt = be ? AV_PIX_FMT_RGB24 : AV_PIX_FMT_BGR24 ; else if ( rgb [ 0 ] == 0xFF && rgb [ 1 ] == 0xFF00 && rgb [ 2 ] == 0xFF0000 ) avctx -> pix_fmt = be ? AV_PIX_FMT_BGR24 : AV_PIX_FMT_RGB24 ; } else if ( bpp == 32 ) { if ( rgb [ 0 ] == 0xFF0000 && rgb [ 1 ] == 0xFF00 && rgb [ 2 ] == 0xFF ) avctx -> pix_fmt = be ? AV_PIX_FMT_ARGB : AV_PIX_FMT_BGRA ; else if ( rgb [ 0 ] == 0xFF && rgb [ 1 ] == 0xFF00 && rgb [ 2 ] == 0xFF0000 ) avctx -> pix_fmt = be ? AV_PIX_FMT_ABGR : AV_PIX_FMT_RGBA ; } bytestream2_skipu ( & gb , ncolors * XWD_CMAP_SIZE ) ; break ; default : av_log ( avctx , AV_LOG_ERROR , ""invalidvisualclass\\n"" ) ; return AVERROR_INVALIDDATA ; } if ( avctx -> pix_fmt == AV_PIX_FMT_NONE ) { avpriv_request_sample ( avctx , ""Unknownfile:bpp%"" PRIu32 "",pixdepth%"" PRIu32 "",vclass%"" PRIu32 """" , bpp , pixdepth , vclass ) ; return AVERROR_PATCHWELCOME ; } if ( ( ret = ff_get_buffer ( avctx , p , 0 ) ) < 0 ) return ret ; p -> key_frame = 1 ; p -> pict_type = AV_PICTURE_TYPE_I ; if ( avctx -> pix_fmt == AV_PIX_FMT_PAL8 ) { uint32_t * dst = ( uint32_t * ) p -> data [ 1 ] ; uint8_t red , green , blue ; for ( i = 0 ; i < ncolors ; i ++ ) { bytestream2_skipu ( & gb , 4 ) ; red = bytestream2_get_byteu ( & gb ) ; bytestream2_skipu ( & gb , 1 ) ; green = bytestream2_get_byteu ( & gb ) ; bytestream2_skipu ( & gb , 1 ) ; blue = bytestream2_get_byteu ( & gb ) ; bytestream2_skipu ( & gb , 3 ) ; dst [ i ] = red << 16 | green << 8 | blue ; } } ptr = p -> data [ 0 ] ; for ( i = 0 ; i < avctx -> height ; i ++ ) { bytestream2_get_bufferu ( & gb , ptr , rsize ) ; bytestream2_skipu ( & gb , lsize - rsize ) ; ptr += p -> linesize [ 0 ] ; } * got_frame = 1 ; return buf_size ; } "," ; if ( bpp == 1 && else if ( bpp == 8 && ",FFmpeg@FFmpeg/441026fcb13ac23aa10edc312bdacb6445a0ad06,CVE-2017-9991,https://github.com/FFmpeg/FFmpeg/commit/441026fcb13ac23aa10edc312bdacb6445a0ad06,2017-06-28T06:29Z 586,CWE-295,"CWE-295 static krb5_error_code tgs_build_reply ( krb5_context context , krb5_kdc_configuration * config , KDC_REQ * req , KDC_REQ_BODY * b , hdb_entry_ex * krbtgt , krb5_enctype krbtgt_etype , const krb5_keyblock * replykey , int rk_is_subkey , krb5_ticket * ticket , krb5_data * reply , const char * from , const char * * e_text , AuthorizationData * * auth_data , const struct sockaddr * from_addr ) { krb5_error_code ret ; krb5_principal cp = NULL , sp = NULL , rsp = NULL , tp = NULL , dp = NULL ; krb5_principal krbtgt_out_principal = NULL ; char * spn = NULL , * cpn = NULL , * tpn = NULL , * dpn = NULL , * krbtgt_out_n = NULL ; hdb_entry_ex * server = NULL , * client = NULL , * s4u2self_impersonated_client = NULL ; HDB * clientdb , * s4u2self_impersonated_clientdb ; krb5_realm ref_realm = NULL ; EncTicketPart * tgt = & ticket -> ticket ; krb5_principals spp = NULL ; const EncryptionKey * ekey ; krb5_keyblock sessionkey ; krb5_kvno kvno ; krb5_data rspac ; const char * our_realm = krb5_principal_get_comp_string ( context , krbtgt -> entry . principal , 1 ) ; char * * capath = NULL ; size_t num_capath = 0 ; hdb_entry_ex * krbtgt_out = NULL ; METHOD_DATA enc_pa_data ; PrincipalName * s ; Realm r ; EncTicketPart adtkt ; char opt_str [ 128 ] ; int signedpath = 0 ; Key * tkey_check ; Key * tkey_sign ; int flags = HDB_F_FOR_TGS_REQ ; memset ( & sessionkey , 0 , sizeof ( sessionkey ) ) ; memset ( & adtkt , 0 , sizeof ( adtkt ) ) ; krb5_data_zero ( & rspac ) ; memset ( & enc_pa_data , 0 , sizeof ( enc_pa_data ) ) ; s = b -> sname ; r = b -> realm ; flags |= HDB_F_CANON ; if ( b -> kdc_options . enc_tkt_in_skey ) { Ticket * t ; hdb_entry_ex * uu ; krb5_principal p ; Key * uukey ; krb5uint32 second_kvno = 0 ; krb5uint32 * kvno_ptr = NULL ; if ( b -> additional_tickets == NULL || b -> additional_tickets -> len == 0 ) { ret = KRB5KDC_ERR_BADOPTION ; kdc_log ( context , config , 0 , ""Nosecondticketpresentinrequest"" ) ; goto out ; } t = & b -> additional_tickets -> val [ 0 ] ; if ( ! get_krbtgt_realm ( & t -> sname ) ) { kdc_log ( context , config , 0 , ""Additionalticketisnotaticket-grantingticket"" ) ; ret = KRB5KDC_ERR_POLICY ; goto out ; } _krb5_principalname2krb5_principal ( context , & p , t -> sname , t -> realm ) ; if ( t -> enc_part . kvno ) { second_kvno = * t -> enc_part . kvno ; kvno_ptr = & second_kvno ; } ret = _kdc_db_fetch ( context , config , p , HDB_F_GET_KRBTGT , kvno_ptr , NULL , & uu ) ; krb5_free_principal ( context , p ) ; if ( ret ) { if ( ret == HDB_ERR_NOENTRY ) ret = KRB5KDC_ERR_S_PRINCIPAL_UNKNOWN ; goto out ; } ret = hdb_enctype2key ( context , & uu -> entry , NULL , t -> enc_part . etype , & uukey ) ; if ( ret ) { _kdc_free_ent ( context , uu ) ; ret = KRB5KDC_ERR_ETYPE_NOSUPP ; goto out ; } ret = krb5_decrypt_ticket ( context , t , & uukey -> key , & adtkt , 0 ) ; _kdc_free_ent ( context , uu ) ; if ( ret ) goto out ; ret = verify_flags ( context , config , & adtkt , spn ) ; if ( ret ) goto out ; s = & adtkt . cname ; r = adtkt . crealm ; } _krb5_principalname2krb5_principal ( context , & sp , * s , r ) ; ret = krb5_unparse_name ( context , sp , & spn ) ; if ( ret ) goto out ; _krb5_principalname2krb5_principal ( context , & cp , tgt -> cname , tgt -> crealm ) ; ret = krb5_unparse_name ( context , cp , & cpn ) ; if ( ret ) goto out ; unparse_flags ( KDCOptions2int ( b -> kdc_options ) , asn1_KDCOptions_units ( ) , opt_str , sizeof ( opt_str ) ) ; if ( * opt_str ) kdc_log ( context , config , 0 , ""TGS-REQ%sfrom%sfor%s[%s]"" , cpn , from , spn , opt_str ) ; else kdc_log ( context , config , 0 , ""TGS-REQ%sfrom%sfor%s"" , cpn , from , spn ) ; server_lookup : ret = _kdc_db_fetch ( context , config , sp , HDB_F_GET_SERVER | flags , NULL , NULL , & server ) ; if ( ret == HDB_ERR_NOT_FOUND_HERE ) { kdc_log ( context , config , 5 , ""target%sdoesnothavesecretsatthisKDC,needtoproxy"" , sp ) ; goto out ; } else if ( ret == HDB_ERR_WRONG_REALM ) { free ( ref_realm ) ; ref_realm = strdup ( server -> entry . principal -> realm ) ; if ( ref_realm == NULL ) { ret = krb5_enomem ( context ) ; goto out ; } kdc_log ( context , config , 5 , ""Returningareferraltorealm%sfor"" ""server%s."" , ref_realm , spn ) ; krb5_free_principal ( context , sp ) ; sp = NULL ; ret = krb5_make_principal ( context , & sp , r , KRB5_TGS_NAME , ref_realm , NULL ) ; if ( ret ) goto out ; free ( spn ) ; spn = NULL ; ret = krb5_unparse_name ( context , sp , & spn ) ; if ( ret ) goto out ; goto server_lookup ; } else if ( ret ) { const char * new_rlm , * msg ; Realm req_rlm ; krb5_realm * realms ; if ( ( req_rlm = get_krbtgt_realm ( & sp -> name ) ) != NULL ) { if ( capath == NULL ) { ret = _krb5_find_capath ( context , tgt -> crealm , our_realm , req_rlm , TRUE , & capath , & num_capath ) ; if ( ret ) goto out ; } new_rlm = num_capath > 0 ? capath [ -- num_capath ] : NULL ; if ( new_rlm ) { kdc_log ( context , config , 5 , ""krbtgtfrom%svia%sfor"" ""realm%snotfound,trying%s"" , tgt -> crealm , our_realm , req_rlm , new_rlm ) ; free ( ref_realm ) ; ref_realm = strdup ( new_rlm ) ; if ( ref_realm == NULL ) { ret = krb5_enomem ( context ) ; goto out ; } krb5_free_principal ( context , sp ) ; sp = NULL ; krb5_make_principal ( context , & sp , r , KRB5_TGS_NAME , ref_realm , NULL ) ; free ( spn ) ; spn = NULL ; ret = krb5_unparse_name ( context , sp , & spn ) ; if ( ret ) goto out ; goto server_lookup ; } } else if ( need_referral ( context , config , & b -> kdc_options , sp , & realms ) ) { if ( strcmp ( realms [ 0 ] , sp -> realm ) != 0 ) { kdc_log ( context , config , 5 , ""Returningareferraltorealm%sfor"" ""server%sthatwasnotfound"" , realms [ 0 ] , spn ) ; krb5_free_principal ( context , sp ) ; sp = NULL ; krb5_make_principal ( context , & sp , r , KRB5_TGS_NAME , realms [ 0 ] , NULL ) ; free ( spn ) ; spn = NULL ; ret = krb5_unparse_name ( context , sp , & spn ) ; if ( ret ) { krb5_free_host_realm ( context , realms ) ; goto out ; } free ( ref_realm ) ; ref_realm = strdup ( realms [ 0 ] ) ; krb5_free_host_realm ( context , realms ) ; goto server_lookup ; } krb5_free_host_realm ( context , realms ) ; } msg = krb5_get_error_message ( context , ret ) ; kdc_log ( context , config , 0 , ""Servernotfoundindatabase:%s:%s"" , spn , msg ) ; krb5_free_error_message ( context , msg ) ; if ( ret == HDB_ERR_NOENTRY ) ret = KRB5KDC_ERR_S_PRINCIPAL_UNKNOWN ; goto out ; } if ( b -> kdc_options . canonicalize ) rsp = server -> entry . principal ; else rsp = sp ; { krb5_enctype etype ; if ( b -> kdc_options . enc_tkt_in_skey ) { size_t i ; ekey = & adtkt . key ; for ( i = 0 ; i < b -> etype . len ; i ++ ) if ( b -> etype . val [ i ] == adtkt . key . keytype ) break ; if ( i == b -> etype . len ) { kdc_log ( context , config , 0 , ""Additiontickethavenotmatchingetypes"" ) ; krb5_clear_error_message ( context ) ; ret = KRB5KDC_ERR_ETYPE_NOSUPP ; goto out ; } etype = b -> etype . val [ i ] ; kvno = 0 ; } else { Key * skey ; ret = _kdc_find_etype ( context , krb5_principal_is_krbtgt ( context , sp ) ? config -> tgt_use_strongest_session_key : config -> svc_use_strongest_session_key , FALSE , server , b -> etype . val , b -> etype . len , & etype , NULL ) ; if ( ret ) { kdc_log ( context , config , 0 , ""Server(%s)hasnosupportforetypes"" , spn ) ; goto out ; } ret = _kdc_get_preferred_key ( context , config , server , spn , NULL , & skey ) ; if ( ret ) { kdc_log ( context , config , 0 , ""Server(%s)hasnosupportedetypes"" , spn ) ; goto out ; } ekey = & skey -> key ; kvno = server -> entry . kvno ; } ret = krb5_generate_random_keyblock ( context , etype , & sessionkey ) ; if ( ret ) goto out ; } ret = hdb_enctype2key ( context , & krbtgt -> entry , NULL , krbtgt_etype , & tkey_check ) ; if ( ret ) { kdc_log ( context , config , 0 , ""FailedtofindkeyforkrbtgtPACcheck"" ) ; goto out ; } ret = krb5_make_principal ( context , & krbtgt_out_principal , our_realm , KRB5_TGS_NAME , our_realm , NULL ) ; if ( ret ) { kdc_log ( context , config , 0 , ""Failedtomakekrbtgtprincipalnameobjectfor"" ""authz-datasignatures"" ) ; goto out ; } ret = krb5_unparse_name ( context , krbtgt_out_principal , & krbtgt_out_n ) ; if ( ret ) { kdc_log ( context , config , 0 , ""Failedtomakekrbtgtprincipalnameobjectfor"" ""authz-datasignatures"" ) ; goto out ; } ret = _kdc_db_fetch ( context , config , krbtgt_out_principal , HDB_F_GET_KRBTGT , NULL , NULL , & krbtgt_out ) ; if ( ret ) { char * ktpn = NULL ; ret = krb5_unparse_name ( context , krbtgt -> entry . principal , & ktpn ) ; kdc_log ( context , config , 0 , ""Nosuchprincipal%s(neededforauthz-datasignaturekeys)"" ""whileprocessingTGS-REQforservice%swithkrbtg%s"" , krbtgt_out_n , spn , ( ret == 0 ) ? ktpn : """" ) ; free ( ktpn ) ; ret = KRB5KRB_AP_ERR_NOT_US ; goto out ; } if ( strcmp ( krb5_principal_get_realm ( context , server -> entry . principal ) , krb5_principal_get_realm ( context , krbtgt_out -> entry . principal ) ) != 0 ) { char * ktpn ; ret = krb5_unparse_name ( context , krbtgt_out -> entry . principal , & ktpn ) ; kdc_log ( context , config , 0 , ""Requestwithwrongkrbtgt:%s"" , ( ret == 0 ) ? ktpn : """" ) ; if ( ret == 0 ) free ( ktpn ) ; ret = KRB5KRB_AP_ERR_NOT_US ; goto out ; } ret = _kdc_get_preferred_key ( context , config , krbtgt_out , krbtgt_out_n , NULL , & tkey_sign ) ; if ( ret ) { kdc_log ( context , config , 0 , ""FailedtofindkeyforkrbtgtPACsignature"" ) ; goto out ; } ret = hdb_enctype2key ( context , & krbtgt_out -> entry , NULL , tkey_sign -> key . keytype , & tkey_sign ) ; if ( ret ) { kdc_log ( context , config , 0 , ""FailedtofindkeyforkrbtgtPACsignature"" ) ; goto out ; } ret = _kdc_db_fetch ( context , config , cp , HDB_F_GET_CLIENT | flags , NULL , & clientdb , & client ) ; if ( ret == HDB_ERR_NOT_FOUND_HERE ) { } else if ( ret ) { const char * krbtgt_realm , * msg ; krbtgt_realm = krb5_principal_get_realm ( context , krbtgt_out -> entry . principal ) ; if ( strcmp ( krb5_principal_get_realm ( context , cp ) , krbtgt_realm ) == 0 ) { if ( ret == HDB_ERR_NOENTRY ) ret = KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN ; kdc_log ( context , config , 1 , ""Clientnolongerindatabase:%s"" , cpn ) ; goto out ; } msg = krb5_get_error_message ( context , ret ) ; kdc_log ( context , config , 1 , ""Clientnotfoundindatabase:%s"" , msg ) ; krb5_free_error_message ( context , msg ) ; } ret = check_PAC ( context , config , cp , NULL , client , server , krbtgt , & tkey_check -> key , ekey , & tkey_sign -> key , tgt , & rspac , & signedpath ) ; if ( ret ) { const char * msg = krb5_get_error_message ( context , ret ) ; kdc_log ( context , config , 0 , ""VerifyPACfailedfor%s(%s)from%swith%s"" , spn , cpn , from , msg ) ; krb5_free_error_message ( context , msg ) ; goto out ; } ret = check_KRB5SignedPath ( context , config , krbtgt , cp , tgt , & spp , & signedpath ) ; if ( ret ) { const char * msg = krb5_get_error_message ( context , ret ) ; kdc_log ( context , config , 0 , ""KRB5SignedPathcheckfailedfor%s(%s)from%swith%s"" , spn , cpn , from , msg ) ; krb5_free_error_message ( context , msg ) ; goto out ; } tp = cp ; tpn = cpn ; if ( client ) { const PA_DATA * sdata ; int i = 0 ; sdata = _kdc_find_padata ( req , & i , KRB5_PADATA_FOR_USER ) ; if ( sdata ) { krb5_crypto crypto ; krb5_data datack ; PA_S4U2Self self ; const char * str ; ret = decode_PA_S4U2Self ( sdata -> padata_value . data , sdata -> padata_value . length , & self , NULL ) ; if ( ret ) { kdc_log ( context , config , 0 , ""FailedtodecodePA-S4U2Self"" ) ; goto out ; } ret = _krb5_s4u2self_to_checksumdata ( context , & self , & datack ) ; if ( ret ) goto out ; ret = krb5_crypto_init ( context , & tgt -> key , 0 , & crypto ) ; if ( ret ) { const char * msg = krb5_get_error_message ( context , ret ) ; free_PA_S4U2Self ( & self ) ; krb5_data_free ( & datack ) ; kdc_log ( context , config , 0 , ""krb5_crypto_initfailed:%s"" , msg ) ; krb5_free_error_message ( context , msg ) ; goto out ; } ret = krb5_verify_checksum ( context , crypto , KRB5_KU_OTHER_CKSUM , datack . data , datack . length , & self . cksum ) ; krb5_data_free ( & datack ) ; krb5_crypto_destroy ( context , crypto ) ; if ( ret ) { const char * msg = krb5_get_error_message ( context , ret ) ; free_PA_S4U2Self ( & self ) ; kdc_log ( context , config , 0 , ""krb5_verify_checksumfailedforS4U2Self:%s"" , msg ) ; krb5_free_error_message ( context , msg ) ; goto out ; } ret = _krb5_principalname2krb5_principal ( context , & tp , self . name , self . realm ) ; free_PA_S4U2Self ( & self ) ; if ( ret ) goto out ; ret = krb5_unparse_name ( context , tp , & tpn ) ; if ( ret ) goto out ; if ( rspac . data ) { krb5_pac p = NULL ; krb5_data_free ( & rspac ) ; ret = _kdc_db_fetch ( context , config , tp , HDB_F_GET_CLIENT | flags , NULL , & s4u2self_impersonated_clientdb , & s4u2self_impersonated_client ) ; if ( ret ) { const char * msg ; if ( ret == HDB_ERR_NOENTRY ) ret = KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN ; msg = krb5_get_error_message ( context , ret ) ; kdc_log ( context , config , 1 , ""S2U4Selfprincipaltoimpersonate%snotfoundindatabase:%s"" , tpn , msg ) ; krb5_free_error_message ( context , msg ) ; goto out ; } ret = _kdc_pac_generate ( context , s4u2self_impersonated_client , & p ) ; if ( ret ) { kdc_log ( context , config , 0 , ""PACgenerationfailedfor--%s"" , tpn ) ; goto out ; } if ( p != NULL ) { ret = _krb5_pac_sign ( context , p , ticket -> ticket . authtime , s4u2self_impersonated_client -> entry . principal , ekey , & tkey_sign -> key , & rspac ) ; krb5_pac_free ( context , p ) ; if ( ret ) { kdc_log ( context , config , 0 , ""PACsigningfailedfor--%s"" , tpn ) ; goto out ; } } } ret = check_s4u2self ( context , config , clientdb , client , sp ) ; if ( ret ) { kdc_log ( context , config , 0 , ""S4U2Self:%sisnotallowed"" ""toimpersonatetoservice"" ""(triedforuser%stoservice%s)"" , cpn , tpn , spn ) ; goto out ; } if ( client -> entry . flags . trusted_for_delegation ) { str = ""[forwardable]"" ; } else { b -> kdc_options . forwardable = 0 ; str = """" ; } kdc_log ( context , config , 0 , ""s4u2self%simpersonating%sto"" ""service%s%s"" , cpn , tpn , spn , str ) ; } } if ( client != NULL && b -> additional_tickets != NULL && b -> additional_tickets -> len != 0 && b -> kdc_options . enc_tkt_in_skey == 0 ) { int ad_signedpath = 0 ; Key * clientkey ; Ticket * t ; if ( ! signedpath ) { ret = KRB5KDC_ERR_BADOPTION ; kdc_log ( context , config , 0 , ""Constraineddelegationdoneonserviceticket%s/%s"" , cpn , spn ) ; goto out ; } t = & b -> additional_tickets -> val [ 0 ] ; ret = hdb_enctype2key ( context , & client -> entry , hdb_kvno2keys ( context , & client -> entry , t -> enc_part . kvno ? * t -> enc_part . kvno : 0 ) , t -> enc_part . etype , & clientkey ) ; if ( ret ) { ret = KRB5KDC_ERR_ETYPE_NOSUPP ; goto out ; } ret = krb5_decrypt_ticket ( context , t , & clientkey -> key , & adtkt , 0 ) ; if ( ret ) { kdc_log ( context , config , 0 , ""failedtodecryptticketfor"" ""constraineddelegationfrom%sto%s"" , cpn , spn ) ; goto out ; } ret = _krb5_principalname2krb5_principal ( context , & tp , adtkt . cname , adtkt . crealm ) ; if ( ret ) goto out ; ret = krb5_unparse_name ( context , tp , & tpn ) ; if ( ret ) goto out ; ret = _krb5_principalname2krb5_principal ( context , & dp , t -> sname , t -> realm ) ; if ( ret ) goto out ; ret = krb5_unparse_name ( context , dp , & dpn ) ; if ( ret ) goto out ; if ( adtkt . flags . forwardable == 0 ) { kdc_log ( context , config , 0 , ""Missingforwardableflagonticketfor"" ""constraineddelegationfrom%s(%s)as%sto%s"" , cpn , dpn , tpn , spn ) ; ret = KRB5KDC_ERR_BADOPTION ; goto out ; } ret = check_constrained_delegation ( context , config , clientdb , client , server , sp ) ; if ( ret ) { kdc_log ( context , config , 0 , ""constraineddelegationfrom%s(%s)as%sto%snotallowed"" , cpn , dpn , tpn , spn ) ; goto out ; } ret = verify_flags ( context , config , & adtkt , tpn ) ; if ( ret ) { goto out ; } krb5_data_free ( & rspac ) ; ret = check_PAC ( context , config , tp , dp , client , server , krbtgt , & clientkey -> key , ekey , & tkey_sign -> key , & adtkt , & rspac , & ad_signedpath ) ; if ( ret ) { const char * msg = krb5_get_error_message ( context , ret ) ; kdc_log ( context , config , 0 , ""VerifydelegatedPACfailedto%sforclient"" ""%s(%s)as%sfrom%swith%s"" , spn , cpn , dpn , tpn , from , msg ) ; krb5_free_error_message ( context , msg ) ; goto out ; } ret = check_KRB5SignedPath ( context , config , krbtgt , cp , & adtkt , NULL , & ad_signedpath ) ; if ( ret ) { const char * msg = krb5_get_error_message ( context , ret ) ; kdc_log ( context , config , 0 , ""KRB5SignedPathcheckfromservice%sfailed"" ""fordelegationto%sforclient%s(%s)"" ""from%sfailedwith%s"" , spn , tpn , dpn , cpn , from , msg ) ; krb5_free_error_message ( context , msg ) ; goto out ; } if ( ! ad_signedpath ) { ret = KRB5KDC_ERR_BADOPTION ; kdc_log ( context , config , 0 , ""TicketnotsignedwithPACnorSignedPathservice%sfailed"" ""fordelegationto%sforclient%s(%s)"" ""from%s"" , spn , tpn , dpn , cpn , from ) ; goto out ; } kdc_log ( context , config , 0 , ""constraineddelegationfor%s"" ""from%s(%s)to%s"" , tpn , cpn , dpn , spn ) ; } ret = kdc_check_flags ( context , config , client , cpn , server , spn , FALSE ) ; if ( ret ) goto out ; if ( ( b -> kdc_options . validate || b -> kdc_options . renew ) && ! krb5_principal_compare ( context , krbtgt -> entry . principal , server -> entry . principal ) ) { kdc_log ( context , config , 0 , ""Inconsistentrequest."" ) ; ret = KRB5KDC_ERR_SERVER_NOMATCH ; goto out ; } if ( ! _kdc_check_addresses ( context , config , tgt -> caddr , from_addr ) ) { ret = KRB5KRB_AP_ERR_BADADDR ; kdc_log ( context , config , 0 , ""Requestfromwrongaddress"" ) ; goto out ; } if ( ref_realm ) { PA_DATA pa ; krb5_crypto crypto ; kdc_log ( context , config , 0 , ""Addingserverreferralto%s"" , ref_realm ) ; ret = krb5_crypto_init ( context , & sessionkey , 0 , & crypto ) ; if ( ret ) goto out ; ret = build_server_referral ( context , config , crypto , ref_realm , NULL , s , & pa . padata_value ) ; krb5_crypto_destroy ( context , crypto ) ; if ( ret ) { kdc_log ( context , config , 0 , ""Failedbuildingserverreferral"" ) ; goto out ; } pa . padata_type = KRB5_PADATA_SERVER_REFERRAL ; ret = add_METHOD_DATA ( & enc_pa_data , & pa ) ; krb5_data_free ( & pa . padata_value ) ; if ( ret ) { kdc_log ( context , config , 0 , ""AddserverreferralMETHOD-DATAfailed"" ) ; goto out ; } } ret = tgs_make_reply ( context , config , b , tp , tgt , replykey , rk_is_subkey , ekey , & sessionkey , kvno , * auth_data , server , rsp , spn , client , cp , krbtgt_out , tkey_sign -> key . keytype , spp , & rspac , & enc_pa_data , e_text , reply ) ; out : if ( tpn != cpn ) free ( tpn ) ; free ( spn ) ; free ( cpn ) ; free ( dpn ) ; free ( krbtgt_out_n ) ; _krb5_free_capath ( context , capath ) ; krb5_data_free ( & rspac ) ; krb5_free_keyblock_contents ( context , & sessionkey ) ; if ( krbtgt_out ) _kdc_free_ent ( context , krbtgt_out ) ; if ( server ) _kdc_free_ent ( context , server ) ; if ( client ) _kdc_free_ent ( context , client ) ; if ( s4u2self_impersonated_client ) _kdc_free_ent ( context , s4u2self_impersonated_client ) ; if ( tp && tp != cp ) krb5_free_principal ( context , tp ) ; krb5_free_principal ( context , cp ) ; krb5_free_principal ( context , dp ) ; krb5_free_principal ( context , sp ) ; krb5_free_principal ( context , krbtgt_out_principal ) ; free ( ref_realm ) ; free_METHOD_DATA ( & enc_pa_data ) ; free_EncTicketPart ( & adtkt ) ; return ret ; } "," ; krb5_data rspac ; const char * tgt_realm = krb5_principal_get_realm ( context , krbtgt -> entry . principal ) , cp , tgt_realm , ",heimdal@heimdal/b1e699103f08d6a0ca46a122193c9da65f6cf837,CVE-2017-6594,https://github.com/heimdal/heimdal/commit/b1e699103f08d6a0ca46a122193c9da65f6cf837,2017-08-28T19:29Z 587,CWE-20,"CWE-20 static __always_inline int __do_follow_link ( struct path * path , struct nameidata * nd ) { int error ; void * cookie ; struct dentry * dentry = path -> dentry ; touch_atime ( path -> mnt , dentry ) ; nd_set_link ( nd , NULL ) ; if ( path -> mnt != nd -> path . mnt ) { path_to_nameidata ( path , nd ) ; dget ( dentry ) ; } mntget ( path -> mnt ) ; cookie = dentry -> d_inode -> i_op -> follow_link ( dentry , nd ) ; error = PTR_ERR ( cookie ) ; if ( ! IS_ERR ( cookie ) ) { char * s = nd_get_link ( nd ) ; error = 0 ; if ( s ) error = __vfs_follow_link ( nd , s ) ; else if ( nd -> last_type == LAST_BIND ) { error = force_reval_path ( & nd -> path , nd ) ; if ( error ) path_put ( & nd -> path ) ; } if ( dentry -> d_inode -> i_op -> put_link ) dentry -> d_inode -> i_op -> put_link ( dentry , nd , cookie ) ; } return error ; } "," mnt ) ; nd -> last_type = LAST_BIND ; ",torvalds@linux/86acdca1b63e6890540fa19495cfc708beff3d8b,CVE-2014-0203,https://github.com/torvalds/linux/commit/86acdca1b63e6890540fa19495cfc708beff3d8b,2014-06-23T11:21Z 588,CWE-200,"CWE-200 static int proc_connectinfo ( struct usb_dev_state * ps , void __user * arg ) { struct usbdevfs_connectinfo ci = { . devnum = ps -> dev -> devnum , . slow = ps -> dev -> speed == USB_SPEED_LOW } ; if ( copy_to_user ( arg , & ci , sizeof ( ci ) ) ) return - EFAULT ; return 0 ; } "," struct usbdevfs_connectinfo ci ; memset ( & ci , 0 , sizeof ( ci ) ) ; ci . devnum = dev -> devnum ; ci . slow = speed == USB_SPEED_LOW ; if ( ",torvalds@linux/681fef8380eb818c0b845fca5d2ab1dcbab114ee,CVE-2016-4482,https://github.com/torvalds/linux/commit/681fef8380eb818c0b845fca5d2ab1dcbab114ee,2016-05-23T10:59Z 589,CWE-362,"CWE-362 static int ip_options_get_finish ( struct net * net , struct ip_options * * optp , struct ip_options * opt , int optlen ) { while ( optlen & 3 ) opt -> __data [ optlen ++ ] = IPOPT_END ; opt -> optlen = optlen ; if ( optlen && ip_options_compile ( net , opt , NULL ) ) { kfree ( opt ) ; return - EINVAL ; } kfree ( * optp ) ; * optp = opt ; return 0 ; } "," net , struct ip_options_rcu * * optp optp , struct ip_options_rcu * opt , ) opt -> opt . ; opt -> opt . ( net , & opt -> ",torvalds@linux/f6d8bd051c391c1c0458a30b2a7abcd939329259,CVE-2012-3552,https://github.com/torvalds/linux/commit/f6d8bd051c391c1c0458a30b2a7abcd939329259,2012-10-03T11:02Z 590,CWE-19,"CWE-19 STATIC int xfs_attr_leaf_addname ( xfs_da_args_t * args ) { xfs_inode_t * dp ; struct xfs_buf * bp ; int retval , error , committed , forkoff ; trace_xfs_attr_leaf_addname ( args ) ; dp = args -> dp ; args -> blkno = 0 ; error = xfs_attr3_leaf_read ( args -> trans , args -> dp , args -> blkno , - 1 , & bp ) ; if ( error ) return error ; retval = xfs_attr3_leaf_lookup_int ( bp , args ) ; if ( ( args -> flags & ATTR_REPLACE ) && ( retval == ENOATTR ) ) { xfs_trans_brelse ( args -> trans , bp ) ; return retval ; } else if ( retval == EEXIST ) { if ( args -> flags & ATTR_CREATE ) { xfs_trans_brelse ( args -> trans , bp ) ; return retval ; } trace_xfs_attr_leaf_replace ( args ) ; args -> op_flags |= XFS_DA_OP_RENAME ; args -> blkno2 = args -> blkno ; args -> index2 = args -> index ; args -> rmtblkno2 = args -> rmtblkno ; args -> rmtblkcnt2 = args -> rmtblkcnt ; } retval = xfs_attr3_leaf_add ( bp , args ) ; if ( retval == ENOSPC ) { xfs_bmap_init ( args -> flist , args -> firstblock ) ; error = xfs_attr3_leaf_to_node ( args ) ; if ( ! error ) { error = xfs_bmap_finish ( & args -> trans , args -> flist , & committed ) ; } if ( error ) { ASSERT ( committed ) ; args -> trans = NULL ; xfs_bmap_cancel ( args -> flist ) ; return ( error ) ; } if ( committed ) xfs_trans_ijoin ( args -> trans , dp , 0 ) ; error = xfs_trans_roll ( & args -> trans , dp ) ; if ( error ) return ( error ) ; error = xfs_attr_node_addname ( args ) ; return ( error ) ; } error = xfs_trans_roll ( & args -> trans , dp ) ; if ( error ) return ( error ) ; if ( args -> rmtblkno > 0 ) { error = xfs_attr_rmtval_set ( args ) ; if ( error ) return ( error ) ; } if ( args -> op_flags & XFS_DA_OP_RENAME ) { error = xfs_attr3_leaf_flipflags ( args ) ; if ( error ) return ( error ) ; args -> index = args -> index2 ; args -> blkno = args -> blkno2 ; args -> rmtblkno = args -> rmtblkno2 ; args -> rmtblkcnt = args -> rmtblkcnt2 ; if ( args -> rmtblkno ) { error = xfs_attr_rmtval_remove ( args ) ; if ( error ) return ( error ) ; } error = xfs_attr3_leaf_read ( args -> trans , args -> dp , args -> blkno , - 1 , & bp ) ; if ( error ) return error ; xfs_attr3_leaf_remove ( bp , args ) ; if ( ( forkoff = xfs_attr_shortform_allfit ( bp , dp ) ) ) { xfs_bmap_init ( args -> flist , args -> firstblock ) ; error = xfs_attr3_leaf_to_shortform ( bp , args , forkoff ) ; if ( ! error ) { error = xfs_bmap_finish ( & args -> trans , args -> flist , & committed ) ; } if ( error ) { ASSERT ( committed ) ; args -> trans = NULL ; xfs_bmap_cancel ( args -> flist ) ; return ( error ) ; } if ( committed ) xfs_trans_ijoin ( args -> trans , dp , 0 ) ; } error = xfs_trans_roll ( & args -> trans , dp ) ; } else if ( args -> rmtblkno > 0 ) { error = xfs_attr3_leaf_clearflag ( args ) ; } return error ; } "," -> rmtblkcnt ; args -> rmtvaluelen2 = args -> rmtvaluelen ; args -> rmtblkno = 0 ; args -> rmtblkcnt = 0 ; args -> rmtvaluelen = 0 ; -> rmtblkcnt2 ; args -> rmtvaluelen = args -> rmtvaluelen2 ; ",torvalds@linux/8275cdd0e7ac550dcce2b3ef6d2fb3b808c1ae59,CVE-2015-0274,https://github.com/torvalds/linux/commit/8275cdd0e7ac550dcce2b3ef6d2fb3b808c1ae59,2015-03-16T10:59Z 591,CWE-119,"CWE-119 NTSTATUS ProcessMainDeviceControlIrp ( PDEVICE_OBJECT DeviceObject , PEXTENSION Extension , PIRP Irp ) { PIO_STACK_LOCATION irpSp = IoGetCurrentIrpStackLocation ( Irp ) ; NTSTATUS ntStatus ; switch ( irpSp -> Parameters . DeviceIoControl . IoControlCode ) { case TC_IOCTL_GET_DRIVER_VERSION : case TC_IOCTL_LEGACY_GET_DRIVER_VERSION : if ( ValidateIOBufferSize ( Irp , sizeof ( LONG ) , ValidateOutput ) ) { LONG tmp = VERSION_NUM ; memcpy ( Irp -> AssociatedIrp . SystemBuffer , & tmp , 4 ) ; Irp -> IoStatus . Information = sizeof ( LONG ) ; Irp -> IoStatus . Status = STATUS_SUCCESS ; } break ; case TC_IOCTL_GET_DEVICE_REFCOUNT : if ( ValidateIOBufferSize ( Irp , sizeof ( int ) , ValidateOutput ) ) { * ( int * ) Irp -> AssociatedIrp . SystemBuffer = DeviceObject -> ReferenceCount ; Irp -> IoStatus . Information = sizeof ( int ) ; Irp -> IoStatus . Status = STATUS_SUCCESS ; } break ; case TC_IOCTL_IS_DRIVER_UNLOAD_DISABLED : if ( ValidateIOBufferSize ( Irp , sizeof ( int ) , ValidateOutput ) ) { LONG deviceObjectCount = 0 ; * ( int * ) Irp -> AssociatedIrp . SystemBuffer = DriverUnloadDisabled ; if ( IoEnumerateDeviceObjectList ( TCDriverObject , NULL , 0 , & deviceObjectCount ) == STATUS_BUFFER_TOO_SMALL && deviceObjectCount > 1 ) * ( int * ) Irp -> AssociatedIrp . SystemBuffer = TRUE ; Irp -> IoStatus . Information = sizeof ( int ) ; Irp -> IoStatus . Status = STATUS_SUCCESS ; } break ; case TC_IOCTL_IS_ANY_VOLUME_MOUNTED : if ( ValidateIOBufferSize ( Irp , sizeof ( int ) , ValidateOutput ) ) { int drive ; * ( int * ) Irp -> AssociatedIrp . SystemBuffer = 0 ; for ( drive = MIN_MOUNTED_VOLUME_DRIVE_NUMBER ; drive <= MAX_MOUNTED_VOLUME_DRIVE_NUMBER ; ++ drive ) { if ( GetVirtualVolumeDeviceObject ( drive ) ) { * ( int * ) Irp -> AssociatedIrp . SystemBuffer = 1 ; break ; } } if ( IsBootDriveMounted ( ) ) * ( int * ) Irp -> AssociatedIrp . SystemBuffer = 1 ; Irp -> IoStatus . Information = sizeof ( int ) ; Irp -> IoStatus . Status = STATUS_SUCCESS ; } break ; case TC_IOCTL_OPEN_TEST : { OPEN_TEST_STRUCT * opentest = ( OPEN_TEST_STRUCT * ) Irp -> AssociatedIrp . SystemBuffer ; OBJECT_ATTRIBUTES ObjectAttributes ; HANDLE NtFileHandle ; UNICODE_STRING FullFileName ; IO_STATUS_BLOCK IoStatus ; LARGE_INTEGER offset ; ACCESS_MASK access = FILE_READ_ATTRIBUTES ; if ( ! ValidateIOBufferSize ( Irp , sizeof ( OPEN_TEST_STRUCT ) , ValidateInputOutput ) ) break ; EnsureNullTerminatedString ( opentest -> wszFileName , sizeof ( opentest -> wszFileName ) ) ; RtlInitUnicodeString ( & FullFileName , opentest -> wszFileName ) ; InitializeObjectAttributes ( & ObjectAttributes , & FullFileName , OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE , NULL , NULL ) ; if ( opentest -> bDetectTCBootLoader || opentest -> DetectFilesystem || opentest -> bComputeVolumeIDs ) access |= FILE_READ_DATA ; ntStatus = ZwCreateFile ( & NtFileHandle , SYNCHRONIZE | access , & ObjectAttributes , & IoStatus , NULL , 0 , FILE_SHARE_READ | FILE_SHARE_WRITE , FILE_OPEN , FILE_SYNCHRONOUS_IO_NONALERT , NULL , 0 ) ; if ( NT_SUCCESS ( ntStatus ) ) { opentest -> TCBootLoaderDetected = FALSE ; opentest -> FilesystemDetected = FALSE ; memset ( opentest -> VolumeIDComputed , 0 , sizeof ( opentest -> VolumeIDComputed ) ) ; memset ( opentest -> volumeIDs , 0 , sizeof ( opentest -> volumeIDs ) ) ; if ( opentest -> bDetectTCBootLoader || opentest -> DetectFilesystem || opentest -> bComputeVolumeIDs ) { byte * readBuffer = TCalloc ( TC_MAX_VOLUME_SECTOR_SIZE ) ; if ( ! readBuffer ) { ntStatus = STATUS_INSUFFICIENT_RESOURCES ; } else { if ( opentest -> bDetectTCBootLoader || opentest -> DetectFilesystem ) { offset . QuadPart = 0 ; ntStatus = ZwReadFile ( NtFileHandle , NULL , NULL , NULL , & IoStatus , readBuffer , TC_MAX_VOLUME_SECTOR_SIZE , & offset , NULL ) ; if ( NT_SUCCESS ( ntStatus ) ) { size_t i ; if ( opentest -> bDetectTCBootLoader && IoStatus . Information >= TC_SECTOR_SIZE_BIOS ) { for ( i = 0 ; i < TC_SECTOR_SIZE_BIOS - strlen ( TC_APP_NAME ) ; ++ i ) { if ( memcmp ( readBuffer + i , TC_APP_NAME , strlen ( TC_APP_NAME ) ) == 0 ) { opentest -> TCBootLoaderDetected = TRUE ; break ; } } } if ( opentest -> DetectFilesystem && IoStatus . Information >= sizeof ( int64 ) ) { switch ( BE64 ( * ( uint64 * ) readBuffer ) ) { case 0xEB52904E54465320ULL : case 0xEB3C904D53444F53ULL : case 0xEB58904D53444F53ULL : case 0xEB76904558464154ULL : case 0x0000005265465300ULL : case 0xEB58906D6B66732EULL : case 0xEB58906D6B646F73ULL : case 0xEB3C906D6B66732EULL : case 0xEB3C906D6B646F73ULL : opentest -> FilesystemDetected = TRUE ; break ; case 0x0000000000000000ULL : if ( IsAllZeroes ( readBuffer + 8 , TC_VOLUME_HEADER_EFFECTIVE_SIZE - 8 ) ) opentest -> FilesystemDetected = TRUE ; break ; } } } } if ( opentest -> bComputeVolumeIDs && ( ! opentest -> DetectFilesystem || ! opentest -> FilesystemDetected ) ) { int volumeType ; for ( volumeType = TC_VOLUME_TYPE_NORMAL ; volumeType < TC_VOLUME_TYPE_COUNT ; volumeType ++ ) { switch ( volumeType ) { case TC_VOLUME_TYPE_NORMAL : offset . QuadPart = TC_VOLUME_HEADER_OFFSET ; break ; case TC_VOLUME_TYPE_HIDDEN : offset . QuadPart = TC_HIDDEN_VOLUME_HEADER_OFFSET ; break ; } ntStatus = ZwReadFile ( NtFileHandle , NULL , NULL , NULL , & IoStatus , readBuffer , TC_MAX_VOLUME_SECTOR_SIZE , & offset , NULL ) ; if ( NT_SUCCESS ( ntStatus ) ) { sha256 ( opentest -> volumeIDs [ volumeType ] , readBuffer , TC_VOLUME_HEADER_EFFECTIVE_SIZE ) ; opentest -> VolumeIDComputed [ volumeType ] = TRUE ; } } } TCfree ( readBuffer ) ; } } ZwClose ( NtFileHandle ) ; Dump ( ""Opentestonfile%lssuccess.\\n"" , opentest -> wszFileName ) ; } else { # if 0 Dump ( ""Opentestonfile%lsfailedNTSTATUS0x%08x\\n"" , opentest -> wszFileName , ntStatus ) ; # endif } Irp -> IoStatus . Information = NT_SUCCESS ( ntStatus ) ? sizeof ( OPEN_TEST_STRUCT ) : 0 ; Irp -> IoStatus . Status = ntStatus ; } break ; case TC_IOCTL_GET_SYSTEM_DRIVE_CONFIG : { GetSystemDriveConfigurationRequest * request = ( GetSystemDriveConfigurationRequest * ) Irp -> AssociatedIrp . SystemBuffer ; OBJECT_ATTRIBUTES ObjectAttributes ; HANDLE NtFileHandle ; UNICODE_STRING FullFileName ; IO_STATUS_BLOCK IoStatus ; LARGE_INTEGER offset ; byte readBuffer [ TC_SECTOR_SIZE_BIOS ] ; if ( ! ValidateIOBufferSize ( Irp , sizeof ( GetSystemDriveConfigurationRequest ) , ValidateInputOutput ) ) break ; EnsureNullTerminatedString ( request -> DevicePath , sizeof ( request -> DevicePath ) ) ; RtlInitUnicodeString ( & FullFileName , request -> DevicePath ) ; InitializeObjectAttributes ( & ObjectAttributes , & FullFileName , OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE , NULL , NULL ) ; ntStatus = ZwCreateFile ( & NtFileHandle , SYNCHRONIZE | GENERIC_READ , & ObjectAttributes , & IoStatus , NULL , FILE_ATTRIBUTE_NORMAL , FILE_SHARE_READ | FILE_SHARE_WRITE , FILE_OPEN , FILE_SYNCHRONOUS_IO_NONALERT | FILE_RANDOM_ACCESS , NULL , 0 ) ; if ( NT_SUCCESS ( ntStatus ) ) { offset . QuadPart = 0 ; ntStatus = ZwReadFile ( NtFileHandle , NULL , NULL , NULL , & IoStatus , readBuffer , sizeof ( readBuffer ) , & offset , NULL ) ; if ( NT_SUCCESS ( ntStatus ) ) { size_t i ; request -> DriveIsDynamic = FALSE ; if ( readBuffer [ 510 ] == 0x55 && readBuffer [ 511 ] == 0xaa ) { int i ; for ( i = 0 ; i < 4 ; ++ i ) { if ( readBuffer [ 446 + i * 16 + 4 ] == PARTITION_LDM ) { request -> DriveIsDynamic = TRUE ; break ; } } } request -> BootLoaderVersion = 0 ; request -> Configuration = 0 ; request -> UserConfiguration = 0 ; request -> CustomUserMessage [ 0 ] = 0 ; for ( i = 0 ; i < sizeof ( readBuffer ) - strlen ( TC_APP_NAME ) ; ++ i ) { if ( memcmp ( readBuffer + i , TC_APP_NAME , strlen ( TC_APP_NAME ) ) == 0 ) { request -> BootLoaderVersion = BE16 ( * ( uint16 * ) ( readBuffer + TC_BOOT_SECTOR_VERSION_OFFSET ) ) ; request -> Configuration = readBuffer [ TC_BOOT_SECTOR_CONFIG_OFFSET ] ; if ( request -> BootLoaderVersion != 0 && request -> BootLoaderVersion <= VERSION_NUM ) { request -> UserConfiguration = readBuffer [ TC_BOOT_SECTOR_USER_CONFIG_OFFSET ] ; memcpy ( request -> CustomUserMessage , readBuffer + TC_BOOT_SECTOR_USER_MESSAGE_OFFSET , TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH ) ; } break ; } } Irp -> IoStatus . Status = STATUS_SUCCESS ; Irp -> IoStatus . Information = sizeof ( * request ) ; } else { Irp -> IoStatus . Status = ntStatus ; Irp -> IoStatus . Information = 0 ; } ZwClose ( NtFileHandle ) ; } else { Irp -> IoStatus . Status = ntStatus ; Irp -> IoStatus . Information = 0 ; } } break ; case TC_IOCTL_WIPE_PASSWORD_CACHE : WipeCache ( ) ; Irp -> IoStatus . Status = STATUS_SUCCESS ; Irp -> IoStatus . Information = 0 ; break ; case TC_IOCTL_GET_PASSWORD_CACHE_STATUS : Irp -> IoStatus . Status = cacheEmpty ? STATUS_PIPE_EMPTY : STATUS_SUCCESS ; Irp -> IoStatus . Information = 0 ; break ; case TC_IOCTL_SET_PORTABLE_MODE_STATUS : if ( ! UserCanAccessDriveDevice ( ) ) { Irp -> IoStatus . Status = STATUS_ACCESS_DENIED ; Irp -> IoStatus . Information = 0 ; } else { PortableMode = TRUE ; Dump ( ""Settingportablemode\\n"" ) ; } break ; case TC_IOCTL_GET_PORTABLE_MODE_STATUS : Irp -> IoStatus . Status = PortableMode ? STATUS_SUCCESS : STATUS_PIPE_EMPTY ; Irp -> IoStatus . Information = 0 ; break ; case TC_IOCTL_GET_MOUNTED_VOLUMES : if ( ValidateIOBufferSize ( Irp , sizeof ( MOUNT_LIST_STRUCT ) , ValidateOutput ) ) { MOUNT_LIST_STRUCT * list = ( MOUNT_LIST_STRUCT * ) Irp -> AssociatedIrp . SystemBuffer ; PDEVICE_OBJECT ListDevice ; int drive ; list -> ulMountedDrives = 0 ; for ( drive = MIN_MOUNTED_VOLUME_DRIVE_NUMBER ; drive <= MAX_MOUNTED_VOLUME_DRIVE_NUMBER ; ++ drive ) { PEXTENSION ListExtension ; ListDevice = GetVirtualVolumeDeviceObject ( drive ) ; if ( ! ListDevice ) continue ; ListExtension = ( PEXTENSION ) ListDevice -> DeviceExtension ; if ( IsVolumeAccessibleByCurrentUser ( ListExtension ) ) { list -> ulMountedDrives |= ( 1 << ListExtension -> nDosDriveNo ) ; RtlStringCbCopyW ( list -> wszVolume [ ListExtension -> nDosDriveNo ] , sizeof ( list -> wszVolume [ ListExtension -> nDosDriveNo ] ) , ListExtension -> wszVolume ) ; RtlStringCbCopyW ( list -> wszLabel [ ListExtension -> nDosDriveNo ] , sizeof ( list -> wszLabel [ ListExtension -> nDosDriveNo ] ) , ListExtension -> wszLabel ) ; memcpy ( list -> volumeID [ ListExtension -> nDosDriveNo ] , ListExtension -> volumeID , VOLUME_ID_SIZE ) ; list -> diskLength [ ListExtension -> nDosDriveNo ] = ListExtension -> DiskLength ; list -> ea [ ListExtension -> nDosDriveNo ] = ListExtension -> cryptoInfo -> ea ; if ( ListExtension -> cryptoInfo -> hiddenVolume ) list -> volumeType [ ListExtension -> nDosDriveNo ] = PROP_VOL_TYPE_HIDDEN ; else if ( ListExtension -> cryptoInfo -> bHiddenVolProtectionAction ) list -> volumeType [ ListExtension -> nDosDriveNo ] = PROP_VOL_TYPE_OUTER_VOL_WRITE_PREVENTED ; else if ( ListExtension -> cryptoInfo -> bProtectHiddenVolume ) list -> volumeType [ ListExtension -> nDosDriveNo ] = PROP_VOL_TYPE_OUTER ; else list -> volumeType [ ListExtension -> nDosDriveNo ] = PROP_VOL_TYPE_NORMAL ; list -> truecryptMode [ ListExtension -> nDosDriveNo ] = ListExtension -> cryptoInfo -> bTrueCryptMode ; } } Irp -> IoStatus . Status = STATUS_SUCCESS ; Irp -> IoStatus . Information = sizeof ( MOUNT_LIST_STRUCT ) ; } break ; case TC_IOCTL_LEGACY_GET_MOUNTED_VOLUMES : if ( ValidateIOBufferSize ( Irp , sizeof ( uint32 ) , ValidateOutput ) ) { memset ( Irp -> AssociatedIrp . SystemBuffer , 0 , irpSp -> Parameters . DeviceIoControl . OutputBufferLength ) ; * ( uint32 * ) Irp -> AssociatedIrp . SystemBuffer = 0xffffFFFF ; Irp -> IoStatus . Status = STATUS_SUCCESS ; Irp -> IoStatus . Information = irpSp -> Parameters . DeviceIoControl . OutputBufferLength ; } break ; case TC_IOCTL_GET_VOLUME_PROPERTIES : if ( ValidateIOBufferSize ( Irp , sizeof ( VOLUME_PROPERTIES_STRUCT ) , ValidateInputOutput ) ) { VOLUME_PROPERTIES_STRUCT * prop = ( VOLUME_PROPERTIES_STRUCT * ) Irp -> AssociatedIrp . SystemBuffer ; PDEVICE_OBJECT ListDevice = GetVirtualVolumeDeviceObject ( prop -> driveNo ) ; Irp -> IoStatus . Status = STATUS_INVALID_PARAMETER ; Irp -> IoStatus . Information = 0 ; if ( ListDevice ) { PEXTENSION ListExtension = ( PEXTENSION ) ListDevice -> DeviceExtension ; if ( IsVolumeAccessibleByCurrentUser ( ListExtension ) ) { prop -> uniqueId = ListExtension -> UniqueVolumeId ; RtlStringCbCopyW ( prop -> wszVolume , sizeof ( prop -> wszVolume ) , ListExtension -> wszVolume ) ; RtlStringCbCopyW ( prop -> wszLabel , sizeof ( prop -> wszLabel ) , ListExtension -> wszLabel ) ; memcpy ( prop -> volumeID , ListExtension -> volumeID , VOLUME_ID_SIZE ) ; prop -> bDriverSetLabel = ListExtension -> bDriverSetLabel ; prop -> diskLength = ListExtension -> DiskLength ; prop -> ea = ListExtension -> cryptoInfo -> ea ; prop -> mode = ListExtension -> cryptoInfo -> mode ; prop -> pkcs5 = ListExtension -> cryptoInfo -> pkcs5 ; prop -> pkcs5Iterations = ListExtension -> cryptoInfo -> noIterations ; prop -> volumePim = ListExtension -> cryptoInfo -> volumePim ; # if 0 prop -> volumeCreationTime = ListExtension -> cryptoInfo -> volume_creation_time ; prop -> headerCreationTime = ListExtension -> cryptoInfo -> header_creation_time ; # endif prop -> volumeHeaderFlags = ListExtension -> cryptoInfo -> HeaderFlags ; prop -> readOnly = ListExtension -> bReadOnly ; prop -> removable = ListExtension -> bRemovable ; prop -> partitionInInactiveSysEncScope = ListExtension -> PartitionInInactiveSysEncScope ; prop -> hiddenVolume = ListExtension -> cryptoInfo -> hiddenVolume ; if ( ListExtension -> cryptoInfo -> bProtectHiddenVolume ) prop -> hiddenVolProtection = ListExtension -> cryptoInfo -> bHiddenVolProtectionAction ? HIDVOL_PROT_STATUS_ACTION_TAKEN : HIDVOL_PROT_STATUS_ACTIVE ; else prop -> hiddenVolProtection = HIDVOL_PROT_STATUS_NONE ; prop -> totalBytesRead = ListExtension -> Queue . TotalBytesRead ; prop -> totalBytesWritten = ListExtension -> Queue . TotalBytesWritten ; prop -> volFormatVersion = ListExtension -> cryptoInfo -> LegacyVolume ? TC_VOLUME_FORMAT_VERSION_PRE_6_0 : TC_VOLUME_FORMAT_VERSION ; Irp -> IoStatus . Status = STATUS_SUCCESS ; Irp -> IoStatus . Information = sizeof ( VOLUME_PROPERTIES_STRUCT ) ; } } } break ; case TC_IOCTL_GET_RESOLVED_SYMLINK : if ( ValidateIOBufferSize ( Irp , sizeof ( RESOLVE_SYMLINK_STRUCT ) , ValidateInputOutput ) ) { RESOLVE_SYMLINK_STRUCT * resolve = ( RESOLVE_SYMLINK_STRUCT * ) Irp -> AssociatedIrp . SystemBuffer ; { NTSTATUS ntStatus ; EnsureNullTerminatedString ( resolve -> symLinkName , sizeof ( resolve -> symLinkName ) ) ; ntStatus = SymbolicLinkToTarget ( resolve -> symLinkName , resolve -> targetName , sizeof ( resolve -> targetName ) ) ; Irp -> IoStatus . Information = sizeof ( RESOLVE_SYMLINK_STRUCT ) ; Irp -> IoStatus . Status = ntStatus ; } } break ; case TC_IOCTL_GET_DRIVE_PARTITION_INFO : if ( ValidateIOBufferSize ( Irp , sizeof ( DISK_PARTITION_INFO_STRUCT ) , ValidateInputOutput ) ) { DISK_PARTITION_INFO_STRUCT * info = ( DISK_PARTITION_INFO_STRUCT * ) Irp -> AssociatedIrp . SystemBuffer ; { PARTITION_INFORMATION_EX pi ; NTSTATUS ntStatus ; EnsureNullTerminatedString ( info -> deviceName , sizeof ( info -> deviceName ) ) ; ntStatus = TCDeviceIoControl ( info -> deviceName , IOCTL_DISK_GET_PARTITION_INFO_EX , NULL , 0 , & pi , sizeof ( pi ) ) ; if ( NT_SUCCESS ( ntStatus ) ) { memset ( & info -> partInfo , 0 , sizeof ( info -> partInfo ) ) ; info -> partInfo . PartitionLength = pi . PartitionLength ; info -> partInfo . PartitionNumber = pi . PartitionNumber ; info -> partInfo . StartingOffset = pi . StartingOffset ; if ( pi . PartitionStyle == PARTITION_STYLE_MBR ) { info -> partInfo . PartitionType = pi . Mbr . PartitionType ; info -> partInfo . BootIndicator = pi . Mbr . BootIndicator ; } info -> IsGPT = pi . PartitionStyle == PARTITION_STYLE_GPT ; } else { ntStatus = TCDeviceIoControl ( info -> deviceName , IOCTL_DISK_GET_PARTITION_INFO , NULL , 0 , & info -> partInfo , sizeof ( info -> partInfo ) ) ; info -> IsGPT = FALSE ; } if ( ! NT_SUCCESS ( ntStatus ) ) { GET_LENGTH_INFORMATION lengthInfo ; ntStatus = TCDeviceIoControl ( info -> deviceName , IOCTL_DISK_GET_LENGTH_INFO , NULL , 0 , & lengthInfo , sizeof ( lengthInfo ) ) ; if ( NT_SUCCESS ( ntStatus ) ) { memset ( & info -> partInfo , 0 , sizeof ( info -> partInfo ) ) ; info -> partInfo . PartitionLength = lengthInfo . Length ; } } info -> IsDynamic = FALSE ; if ( NT_SUCCESS ( ntStatus ) && OsMajorVersion >= 6 ) { # define IOCTL_VOLUME_IS_DYNAMIC CTL_CODE ( IOCTL_VOLUME_BASE , 18 , METHOD_BUFFERED , FILE_ANY_ACCESS ) if ( ! NT_SUCCESS ( TCDeviceIoControl ( info -> deviceName , IOCTL_VOLUME_IS_DYNAMIC , NULL , 0 , & info -> IsDynamic , sizeof ( info -> IsDynamic ) ) ) ) info -> IsDynamic = FALSE ; } Irp -> IoStatus . Information = sizeof ( DISK_PARTITION_INFO_STRUCT ) ; Irp -> IoStatus . Status = ntStatus ; } } break ; case TC_IOCTL_GET_DRIVE_GEOMETRY : if ( ValidateIOBufferSize ( Irp , sizeof ( DISK_GEOMETRY_STRUCT ) , ValidateInputOutput ) ) { DISK_GEOMETRY_STRUCT * g = ( DISK_GEOMETRY_STRUCT * ) Irp -> AssociatedIrp . SystemBuffer ; { NTSTATUS ntStatus ; EnsureNullTerminatedString ( g -> deviceName , sizeof ( g -> deviceName ) ) ; Dump ( ""CallingIOCTL_DISK_GET_DRIVE_GEOMETRYon%ls\\n"" , g -> deviceName ) ; ntStatus = TCDeviceIoControl ( g -> deviceName , IOCTL_DISK_GET_DRIVE_GEOMETRY , NULL , 0 , & g -> diskGeometry , sizeof ( g -> diskGeometry ) ) ; Irp -> IoStatus . Information = sizeof ( DISK_GEOMETRY_STRUCT ) ; Irp -> IoStatus . Status = ntStatus ; } } break ; case VC_IOCTL_GET_DRIVE_GEOMETRY_EX : if ( ValidateIOBufferSize ( Irp , sizeof ( DISK_GEOMETRY_EX_STRUCT ) , ValidateInputOutput ) ) { DISK_GEOMETRY_EX_STRUCT * g = ( DISK_GEOMETRY_EX_STRUCT * ) Irp -> AssociatedIrp . SystemBuffer ; { NTSTATUS ntStatus ; PVOID buffer = TCalloc ( 256 ) ; if ( buffer ) { EnsureNullTerminatedString ( g -> deviceName , sizeof ( g -> deviceName ) ) ; Dump ( ""CallingIOCTL_DISK_GET_DRIVE_GEOMETRY_EXon%ls\\n"" , g -> deviceName ) ; ntStatus = TCDeviceIoControl ( g -> deviceName , IOCTL_DISK_GET_DRIVE_GEOMETRY_EX , NULL , 0 , buffer , 256 ) ; if ( NT_SUCCESS ( ntStatus ) ) { PDISK_GEOMETRY_EX pGeo = ( PDISK_GEOMETRY_EX ) buffer ; memcpy ( & g -> diskGeometry , & pGeo -> Geometry , sizeof ( DISK_GEOMETRY ) ) ; g -> DiskSize . QuadPart = pGeo -> DiskSize . QuadPart ; } else { DISK_GEOMETRY dg = { 0 } ; Dump ( ""Failed.CallingIOCTL_DISK_GET_DRIVE_GEOMETRYon%ls\\n"" , g -> deviceName ) ; ntStatus = TCDeviceIoControl ( g -> deviceName , IOCTL_DISK_GET_DRIVE_GEOMETRY , NULL , 0 , & dg , sizeof ( dg ) ) ; if ( NT_SUCCESS ( ntStatus ) ) { memcpy ( & g -> diskGeometry , & dg , sizeof ( DISK_GEOMETRY ) ) ; g -> DiskSize . QuadPart = dg . Cylinders . QuadPart * dg . SectorsPerTrack * dg . TracksPerCylinder * dg . BytesPerSector ; if ( OsMajorVersion >= 6 ) { STORAGE_READ_CAPACITY storage = { 0 } ; NTSTATUS lStatus ; storage . Version = sizeof ( STORAGE_READ_CAPACITY ) ; Dump ( ""CallingIOCTL_STORAGE_READ_CAPACITYon%ls\\n"" , g -> deviceName ) ; lStatus = TCDeviceIoControl ( g -> deviceName , IOCTL_STORAGE_READ_CAPACITY , NULL , 0 , & storage , sizeof ( STORAGE_READ_CAPACITY ) ) ; if ( NT_SUCCESS ( lStatus ) && ( storage . Size == sizeof ( STORAGE_READ_CAPACITY ) ) ) { g -> DiskSize . QuadPart = storage . DiskLength . QuadPart ; } } } } TCfree ( buffer ) ; Irp -> IoStatus . Information = sizeof ( DISK_GEOMETRY_EX_STRUCT ) ; Irp -> IoStatus . Status = ntStatus ; } else { Irp -> IoStatus . Status = STATUS_INSUFFICIENT_RESOURCES ; Irp -> IoStatus . Information = 0 ; } } } break ; case TC_IOCTL_PROBE_REAL_DRIVE_SIZE : if ( ValidateIOBufferSize ( Irp , sizeof ( ProbeRealDriveSizeRequest ) , ValidateInputOutput ) ) { ProbeRealDriveSizeRequest * request = ( ProbeRealDriveSizeRequest * ) Irp -> AssociatedIrp . SystemBuffer ; NTSTATUS status ; UNICODE_STRING name ; PFILE_OBJECT fileObject ; PDEVICE_OBJECT deviceObject ; EnsureNullTerminatedString ( request -> DeviceName , sizeof ( request -> DeviceName ) ) ; RtlInitUnicodeString ( & name , request -> DeviceName ) ; status = IoGetDeviceObjectPointer ( & name , FILE_READ_ATTRIBUTES , & fileObject , & deviceObject ) ; if ( ! NT_SUCCESS ( status ) ) { Irp -> IoStatus . Information = 0 ; Irp -> IoStatus . Status = status ; break ; } status = ProbeRealDriveSize ( deviceObject , & request -> RealDriveSize ) ; ObDereferenceObject ( fileObject ) ; if ( status == STATUS_TIMEOUT ) { request -> TimeOut = TRUE ; Irp -> IoStatus . Information = sizeof ( ProbeRealDriveSizeRequest ) ; Irp -> IoStatus . Status = STATUS_SUCCESS ; } else if ( ! NT_SUCCESS ( status ) ) { Irp -> IoStatus . Information = 0 ; Irp -> IoStatus . Status = status ; } else { request -> TimeOut = FALSE ; Irp -> IoStatus . Information = sizeof ( ProbeRealDriveSizeRequest ) ; Irp -> IoStatus . Status = status ; } } break ; case TC_IOCTL_MOUNT_VOLUME : if ( ValidateIOBufferSize ( Irp , sizeof ( MOUNT_STRUCT ) , ValidateInputOutput ) ) { MOUNT_STRUCT * mount = ( MOUNT_STRUCT * ) Irp -> AssociatedIrp . SystemBuffer ; if ( mount -> VolumePassword . Length > MAX_PASSWORD || mount -> ProtectedHidVolPassword . Length > MAX_PASSWORD || mount -> pkcs5_prf < 0 || mount -> pkcs5_prf > LAST_PRF_ID || mount -> VolumePim < - 1 || mount -> VolumePim == INT_MAX || mount -> ProtectedHidVolPkcs5Prf < 0 || mount -> ProtectedHidVolPkcs5Prf > LAST_PRF_ID || ( mount -> bTrueCryptMode != FALSE && mount -> bTrueCryptMode != TRUE ) ) { Irp -> IoStatus . Status = STATUS_INVALID_PARAMETER ; Irp -> IoStatus . Information = 0 ; break ; } EnsureNullTerminatedString ( mount -> wszVolume , sizeof ( mount -> wszVolume ) ) ; EnsureNullTerminatedString ( mount -> wszLabel , sizeof ( mount -> wszLabel ) ) ; Irp -> IoStatus . Information = sizeof ( MOUNT_STRUCT ) ; Irp -> IoStatus . Status = MountDevice ( DeviceObject , mount ) ; burn ( & mount -> VolumePassword , sizeof ( mount -> VolumePassword ) ) ; burn ( & mount -> ProtectedHidVolPassword , sizeof ( mount -> ProtectedHidVolPassword ) ) ; burn ( & mount -> pkcs5_prf , sizeof ( mount -> pkcs5_prf ) ) ; burn ( & mount -> VolumePim , sizeof ( mount -> VolumePim ) ) ; burn ( & mount -> bTrueCryptMode , sizeof ( mount -> bTrueCryptMode ) ) ; burn ( & mount -> ProtectedHidVolPkcs5Prf , sizeof ( mount -> ProtectedHidVolPkcs5Prf ) ) ; burn ( & mount -> ProtectedHidVolPim , sizeof ( mount -> ProtectedHidVolPim ) ) ; } break ; case TC_IOCTL_DISMOUNT_VOLUME : if ( ValidateIOBufferSize ( Irp , sizeof ( UNMOUNT_STRUCT ) , ValidateInputOutput ) ) { UNMOUNT_STRUCT * unmount = ( UNMOUNT_STRUCT * ) Irp -> AssociatedIrp . SystemBuffer ; PDEVICE_OBJECT ListDevice = GetVirtualVolumeDeviceObject ( unmount -> nDosDriveNo ) ; unmount -> nReturnCode = ERR_DRIVE_NOT_FOUND ; if ( ListDevice ) { PEXTENSION ListExtension = ( PEXTENSION ) ListDevice -> DeviceExtension ; if ( IsVolumeAccessibleByCurrentUser ( ListExtension ) ) unmount -> nReturnCode = UnmountDevice ( unmount , ListDevice , unmount -> ignoreOpenFiles ) ; } Irp -> IoStatus . Information = sizeof ( UNMOUNT_STRUCT ) ; Irp -> IoStatus . Status = STATUS_SUCCESS ; } break ; case TC_IOCTL_DISMOUNT_ALL_VOLUMES : if ( ValidateIOBufferSize ( Irp , sizeof ( UNMOUNT_STRUCT ) , ValidateInputOutput ) ) { UNMOUNT_STRUCT * unmount = ( UNMOUNT_STRUCT * ) Irp -> AssociatedIrp . SystemBuffer ; unmount -> nReturnCode = UnmountAllDevices ( unmount , unmount -> ignoreOpenFiles ) ; Irp -> IoStatus . Information = sizeof ( UNMOUNT_STRUCT ) ; Irp -> IoStatus . Status = STATUS_SUCCESS ; } break ; case TC_IOCTL_BOOT_ENCRYPTION_SETUP : Irp -> IoStatus . Status = StartBootEncryptionSetup ( DeviceObject , Irp , irpSp ) ; Irp -> IoStatus . Information = 0 ; break ; case TC_IOCTL_ABORT_BOOT_ENCRYPTION_SETUP : Irp -> IoStatus . Status = AbortBootEncryptionSetup ( ) ; Irp -> IoStatus . Information = 0 ; break ; case TC_IOCTL_GET_BOOT_ENCRYPTION_STATUS : GetBootEncryptionStatus ( Irp , irpSp ) ; break ; case TC_IOCTL_GET_BOOT_ENCRYPTION_SETUP_RESULT : Irp -> IoStatus . Information = 0 ; Irp -> IoStatus . Status = GetSetupResult ( ) ; break ; case TC_IOCTL_GET_BOOT_DRIVE_VOLUME_PROPERTIES : GetBootDriveVolumeProperties ( Irp , irpSp ) ; break ; case TC_IOCTL_GET_BOOT_LOADER_VERSION : GetBootLoaderVersion ( Irp , irpSp ) ; break ; case TC_IOCTL_REOPEN_BOOT_VOLUME_HEADER : ReopenBootVolumeHeader ( Irp , irpSp ) ; break ; case VC_IOCTL_GET_BOOT_LOADER_FINGERPRINT : GetBootLoaderFingerprint ( Irp , irpSp ) ; break ; case TC_IOCTL_GET_BOOT_ENCRYPTION_ALGORITHM_NAME : GetBootEncryptionAlgorithmName ( Irp , irpSp ) ; break ; case TC_IOCTL_IS_HIDDEN_SYSTEM_RUNNING : if ( ValidateIOBufferSize ( Irp , sizeof ( int ) , ValidateOutput ) ) { * ( int * ) Irp -> AssociatedIrp . SystemBuffer = IsHiddenSystemRunning ( ) ? 1 : 0 ; Irp -> IoStatus . Information = sizeof ( int ) ; Irp -> IoStatus . Status = STATUS_SUCCESS ; } break ; case TC_IOCTL_START_DECOY_SYSTEM_WIPE : Irp -> IoStatus . Status = StartDecoySystemWipe ( DeviceObject , Irp , irpSp ) ; Irp -> IoStatus . Information = 0 ; break ; case TC_IOCTL_ABORT_DECOY_SYSTEM_WIPE : Irp -> IoStatus . Status = AbortDecoySystemWipe ( ) ; Irp -> IoStatus . Information = 0 ; break ; case TC_IOCTL_GET_DECOY_SYSTEM_WIPE_RESULT : Irp -> IoStatus . Status = GetDecoySystemWipeResult ( ) ; Irp -> IoStatus . Information = 0 ; break ; case TC_IOCTL_GET_DECOY_SYSTEM_WIPE_STATUS : GetDecoySystemWipeStatus ( Irp , irpSp ) ; break ; case TC_IOCTL_WRITE_BOOT_DRIVE_SECTOR : Irp -> IoStatus . Status = WriteBootDriveSector ( Irp , irpSp ) ; Irp -> IoStatus . Information = 0 ; break ; case TC_IOCTL_GET_WARNING_FLAGS : if ( ValidateIOBufferSize ( Irp , sizeof ( GetWarningFlagsRequest ) , ValidateOutput ) ) { GetWarningFlagsRequest * flags = ( GetWarningFlagsRequest * ) Irp -> AssociatedIrp . SystemBuffer ; flags -> PagingFileCreationPrevented = PagingFileCreationPrevented ; PagingFileCreationPrevented = FALSE ; flags -> SystemFavoriteVolumeDirty = SystemFavoriteVolumeDirty ; SystemFavoriteVolumeDirty = FALSE ; Irp -> IoStatus . Information = sizeof ( GetWarningFlagsRequest ) ; Irp -> IoStatus . Status = STATUS_SUCCESS ; } break ; case TC_IOCTL_SET_SYSTEM_FAVORITE_VOLUME_DIRTY : if ( UserCanAccessDriveDevice ( ) ) { SystemFavoriteVolumeDirty = TRUE ; Irp -> IoStatus . Status = STATUS_SUCCESS ; } else Irp -> IoStatus . Status = STATUS_ACCESS_DENIED ; Irp -> IoStatus . Information = 0 ; break ; case TC_IOCTL_REREAD_DRIVER_CONFIG : Irp -> IoStatus . Status = ReadRegistryConfigFlags ( FALSE ) ; Irp -> IoStatus . Information = 0 ; break ; case TC_IOCTL_GET_SYSTEM_DRIVE_DUMP_CONFIG : if ( ( ValidateIOBufferSize ( Irp , sizeof ( GetSystemDriveDumpConfigRequest ) , ValidateOutput ) ) && ( Irp -> RequestorMode == KernelMode ) ) { GetSystemDriveDumpConfigRequest * request = ( GetSystemDriveDumpConfigRequest * ) Irp -> AssociatedIrp . SystemBuffer ; request -> BootDriveFilterExtension = GetBootDriveFilterExtension ( ) ; if ( IsBootDriveMounted ( ) && request -> BootDriveFilterExtension ) { request -> HwEncryptionEnabled = IsHwEncryptionEnabled ( ) ; Irp -> IoStatus . Status = STATUS_SUCCESS ; Irp -> IoStatus . Information = sizeof ( * request ) ; } else { Irp -> IoStatus . Status = STATUS_INVALID_PARAMETER ; Irp -> IoStatus . Information = 0 ; } } break ; default : return TCCompleteIrp ( Irp , STATUS_INVALID_DEVICE_REQUEST , 0 ) ; } # if defined ( DEBUG ) || defined ( DEBUG_TRACE ) if ( ! NT_SUCCESS ( Irp -> IoStatus . Status ) ) { switch ( irpSp -> Parameters . DeviceIoControl . IoControlCode ) { case TC_IOCTL_GET_MOUNTED_VOLUMES : case TC_IOCTL_GET_PASSWORD_CACHE_STATUS : case TC_IOCTL_GET_PORTABLE_MODE_STATUS : case TC_IOCTL_SET_PORTABLE_MODE_STATUS : case TC_IOCTL_OPEN_TEST : case TC_IOCTL_GET_RESOLVED_SYMLINK : case TC_IOCTL_GET_DRIVE_PARTITION_INFO : case TC_IOCTL_GET_BOOT_DRIVE_VOLUME_PROPERTIES : case TC_IOCTL_GET_BOOT_ENCRYPTION_STATUS : case TC_IOCTL_IS_HIDDEN_SYSTEM_RUNNING : break ; default : Dump ( ""IOCTLerror0x%08x\\n"" , Irp -> IoStatus . Status ) ; } } # endif return TCCompleteIrp ( Irp , Irp -> IoStatus . Status , Irp -> IoStatus . Information ) ; } "," LARGE_INTEGER offset ; size_t devicePathLen = 0 ; if ( ) break ; if ( ! NT_SUCCESS ( RtlUnalignedStringCchLengthW ( request -> DevicePath , TC_MAX_PATH , & devicePathLen ) ) || ( devicePathLen < 28 ) || ( devicePathLen > 30 ) || ( memcmp ( request -> DevicePath , L""\\\\Device\\\\Harddisk"" , 16 * sizeof ( WCHAR ) ) ) || ( memcmp ( & request -> DevicePath [ devicePathLen - 11 ] , L""\\\\Partition0"" , 11 * sizeof ( WCHAR ) ) ) ) { Irp -> IoStatus . Status = STATUS_INVALID_PARAMETER ; Irp -> IoStatus . Information = 0 ; break ; } ) ) { byte * readBuffer = TCalloc ( TC_MAX_VOLUME_SECTOR_SIZE ) ; if ( ! readBuffer ) { Irp -> IoStatus . Status = STATUS_INSUFFICIENT_RESOURCES ; Irp -> IoStatus . Information = 0 ; } else { , readBuffer , TC_MAX_VOLUME_SECTOR_SIZE , & offset ( ntStatus ) ) { if ( IoStatus . Information >= TC_SECTOR_SIZE_BIOS . Status = STATUS_INVALID_PARAMETER ; Irp -> IoStatus . Information = 0 ; } } else { Irp -> IoStatus . Status = Information = 0 ; } TCfree ( readBuffer ) ",veracrypt@VeraCrypt/f30f9339c9a0b9bbcc6f5ad38804af39db1f479e,CVE-2019-1010208,https://github.com/veracrypt/VeraCrypt/commit/f30f9339c9a0b9bbcc6f5ad38804af39db1f479e,2019-07-23T14:15Z 592,CWE-190,"CWE-190 static int on_http_message_complete ( http_parser * parser ) { struct clt_info * info = parser -> data ; ws_svr * svr = ws_svr_from_ses ( info -> ses ) ; info -> request -> version_major = parser -> http_major ; info -> request -> version_minor = parser -> http_minor ; info -> request -> method = parser -> method ; dict_entry * entry ; dict_iterator * iter = dict_get_iterator ( info -> request -> headers ) ; while ( ( entry = dict_next ( iter ) ) != NULL ) { log_trace ( ""Header:%s:%s"" , ( char * ) entry -> key , ( char * ) entry -> val ) ; } dict_release_iterator ( iter ) ; if ( info -> request -> method != HTTP_GET ) goto error ; if ( http_request_get_header ( info -> request , ""Host"" ) == NULL ) goto error ; double version = info -> request -> version_major + info -> request -> version_minor * 0.1 ; if ( version < 1.1 ) goto error ; const char * upgrade = http_request_get_header ( info -> request , ""Upgrade"" ) ; if ( upgrade == NULL || strcasecmp ( upgrade , ""websocket"" ) != 0 ) goto error ; const char * connection = http_request_get_header ( info -> request , ""Connection"" ) ; if ( connection == NULL ) goto error ; else { bool found_upgrade = false ; int count ; sds * tokens = sdssplitlen ( connection , strlen ( connection ) , "","" , 1 , & count ) ; if ( tokens == NULL ) goto error ; for ( int i = 0 ; i < count ; i ++ ) { sds token = tokens [ i ] ; sdstrim ( token , """" ) ; if ( strcasecmp ( token , ""Upgrade"" ) == 0 ) { found_upgrade = true ; break ; } } sdsfreesplitres ( tokens , count ) ; if ( ! found_upgrade ) goto error ; } const char * ws_version = http_request_get_header ( info -> request , ""Sec-WebSocket-Version"" ) ; if ( ws_version == NULL || strcmp ( ws_version , ""13"" ) != 0 ) goto error ; const char * ws_key = http_request_get_header ( info -> request , ""Sec-WebSocket-Key"" ) ; if ( ws_key == NULL ) goto error ; const char * protocol_list = http_request_get_header ( info -> request , ""Sec-WebSocket-Protocol"" ) ; if ( protocol_list && ! is_good_protocol ( protocol_list , svr -> protocol ) ) goto error ; if ( strlen ( svr -> origin ) > 0 ) { const char * origin = http_request_get_header ( info -> request , ""Origin"" ) ; if ( origin == NULL || ! is_good_origin ( origin , svr -> origin ) ) goto error ; } if ( svr -> type . on_privdata_alloc ) { info -> privdata = svr -> type . on_privdata_alloc ( svr ) ; if ( info -> privdata == NULL ) goto error ; } info -> upgrade = true ; info -> remote = sdsnew ( http_get_remote_ip ( info -> ses , info -> request ) ) ; info -> url = sdsnew ( info -> request -> url ) ; if ( svr -> type . on_upgrade ) { svr -> type . on_upgrade ( info -> ses , info -> remote ) ; } if ( protocol_list ) { send_hand_shake_reply ( info -> ses , svr -> protocol , ws_key ) ; } else { send_hand_shake_reply ( info -> ses , NULL , ws_key ) ; } return 0 ; error : ws_svr_close_clt ( ws_svr_from_ses ( info -> ses ) , info -> ses ) ; return - 1 ; } "," connection == NULL || strlen ( connection ) > UT_WS_SVR_MAX_HEADER_SIZE ",viabtc@viabtc_exchange_server/4a7c27bfe98f409623d4d857894d017ff0672cc9,CVE-2018-17568,https://github.com/viabtc/viabtc_exchange_server/commit/4a7c27bfe98f409623d4d857894d017ff0672cc9#diff-0c23effa84a7b85053bac7981a8580c8,2018-09-26T22:29Z 593,CWE-20,"CWE-20 static int daemon_msg_findallif_req ( uint8 ver , struct daemon_slpars * pars , uint32 plen ) { char errbuf [ PCAP_ERRBUF_SIZE ] ; char errmsgbuf [ PCAP_ERRBUF_SIZE ] ; char sendbuf [ RPCAP_NETBUF_SIZE ] ; int sendbufidx = 0 ; pcap_if_t * alldevs = NULL ; pcap_if_t * d ; struct pcap_addr * address ; struct rpcap_findalldevs_if * findalldevs_if ; uint16 nif = 0 ; if ( rpcapd_discard ( pars -> sockctrl , plen ) == - 1 ) { return - 1 ; } if ( pcap_findalldevs ( & alldevs , errmsgbuf ) == - 1 ) goto error ; if ( alldevs == NULL ) { if ( rpcap_senderror ( pars -> sockctrl , ver , PCAP_ERR_NOREMOTEIF , ""Nointerfacesfound!Makesurelibpcap/WinPcapisproperlyinstalled"" ""andyouhavetherighttoaccesstotheremotedevice."" , errbuf ) == - 1 ) { rpcapd_log ( LOGPRIO_ERROR , ""Sendtoclientfailed:%s"" , errbuf ) ; return - 1 ; } return 0 ; } for ( d = alldevs ; d != NULL ; d = d -> next ) { nif ++ ; if ( d -> description ) plen += strlen ( d -> description ) ; if ( d -> name ) plen += strlen ( d -> name ) ; plen += sizeof ( struct rpcap_findalldevs_if ) ; for ( address = d -> addresses ; address != NULL ; address = address -> next ) { switch ( address -> addr -> sa_family ) { case AF_INET : # ifdef AF_INET6 case AF_INET6 : # endif plen += ( sizeof ( struct rpcap_sockaddr ) * 4 ) ; break ; default : break ; } } } if ( sock_bufferize ( NULL , sizeof ( struct rpcap_header ) , NULL , & sendbufidx , RPCAP_NETBUF_SIZE , SOCKBUF_CHECKONLY , errmsgbuf , PCAP_ERRBUF_SIZE ) == - 1 ) goto error ; rpcap_createhdr ( ( struct rpcap_header * ) sendbuf , ver , RPCAP_MSG_FINDALLIF_REPLY , nif , plen ) ; for ( d = alldevs ; d != NULL ; d = d -> next ) { uint16 lname , ldescr ; findalldevs_if = ( struct rpcap_findalldevs_if * ) & sendbuf [ sendbufidx ] ; if ( sock_bufferize ( NULL , sizeof ( struct rpcap_findalldevs_if ) , NULL , & sendbufidx , RPCAP_NETBUF_SIZE , SOCKBUF_CHECKONLY , errmsgbuf , PCAP_ERRBUF_SIZE ) == - 1 ) goto error ; memset ( findalldevs_if , 0 , sizeof ( struct rpcap_findalldevs_if ) ) ; if ( d -> description ) ldescr = ( short ) strlen ( d -> description ) ; else ldescr = 0 ; if ( d -> name ) lname = ( short ) strlen ( d -> name ) ; else lname = 0 ; findalldevs_if -> desclen = htons ( ldescr ) ; findalldevs_if -> namelen = htons ( lname ) ; findalldevs_if -> flags = htonl ( d -> flags ) ; for ( address = d -> addresses ; address != NULL ; address = address -> next ) { switch ( address -> addr -> sa_family ) { case AF_INET : # ifdef AF_INET6 case AF_INET6 : # endif findalldevs_if -> naddr ++ ; break ; default : break ; } } findalldevs_if -> naddr = htons ( findalldevs_if -> naddr ) ; if ( sock_bufferize ( d -> name , lname , sendbuf , & sendbufidx , RPCAP_NETBUF_SIZE , SOCKBUF_BUFFERIZE , errmsgbuf , PCAP_ERRBUF_SIZE ) == - 1 ) goto error ; if ( sock_bufferize ( d -> description , ldescr , sendbuf , & sendbufidx , RPCAP_NETBUF_SIZE , SOCKBUF_BUFFERIZE , errmsgbuf , PCAP_ERRBUF_SIZE ) == - 1 ) goto error ; for ( address = d -> addresses ; address != NULL ; address = address -> next ) { struct rpcap_sockaddr * sockaddr ; switch ( address -> addr -> sa_family ) { case AF_INET : # ifdef AF_INET6 case AF_INET6 : # endif sockaddr = ( struct rpcap_sockaddr * ) & sendbuf [ sendbufidx ] ; if ( sock_bufferize ( NULL , sizeof ( struct rpcap_sockaddr ) , NULL , & sendbufidx , RPCAP_NETBUF_SIZE , SOCKBUF_CHECKONLY , errmsgbuf , PCAP_ERRBUF_SIZE ) == - 1 ) goto error ; daemon_seraddr ( ( struct sockaddr_storage * ) address -> addr , sockaddr ) ; sockaddr = ( struct rpcap_sockaddr * ) & sendbuf [ sendbufidx ] ; if ( sock_bufferize ( NULL , sizeof ( struct rpcap_sockaddr ) , NULL , & sendbufidx , RPCAP_NETBUF_SIZE , SOCKBUF_CHECKONLY , errmsgbuf , PCAP_ERRBUF_SIZE ) == - 1 ) goto error ; daemon_seraddr ( ( struct sockaddr_storage * ) address -> netmask , sockaddr ) ; sockaddr = ( struct rpcap_sockaddr * ) & sendbuf [ sendbufidx ] ; if ( sock_bufferize ( NULL , sizeof ( struct rpcap_sockaddr ) , NULL , & sendbufidx , RPCAP_NETBUF_SIZE , SOCKBUF_CHECKONLY , errmsgbuf , PCAP_ERRBUF_SIZE ) == - 1 ) goto error ; daemon_seraddr ( ( struct sockaddr_storage * ) address -> broadaddr , sockaddr ) ; sockaddr = ( struct rpcap_sockaddr * ) & sendbuf [ sendbufidx ] ; if ( sock_bufferize ( NULL , sizeof ( struct rpcap_sockaddr ) , NULL , & sendbufidx , RPCAP_NETBUF_SIZE , SOCKBUF_CHECKONLY , errmsgbuf , PCAP_ERRBUF_SIZE ) == - 1 ) goto error ; daemon_seraddr ( ( struct sockaddr_storage * ) address -> dstaddr , sockaddr ) ; break ; default : break ; } } } pcap_freealldevs ( alldevs ) ; if ( sock_send ( pars -> sockctrl , sendbuf , sendbufidx , errbuf , PCAP_ERRBUF_SIZE ) == - 1 ) { rpcapd_log ( LOGPRIO_ERROR , ""Sendtoclientfailed:%s"" , errbuf ) ; return - 1 ; } return 0 ; error : if ( alldevs ) pcap_freealldevs ( alldevs ) ; if ( rpcap_senderror ( pars -> sockctrl , ver , PCAP_ERR_FINDALLIF , errmsgbuf , errbuf ) == - 1 ) { rpcapd_log ( LOGPRIO_ERROR , ""Sendtoclientfailed:%s"" , errbuf ) ; return - 1 ; } return 0 ; } "," * findalldevs_if ; uint32 replylen ; 0 ; } replylen = 0 ; -> description ) replylen += strlen ( -> name ) replylen += strlen ( name ) ; replylen += sizeof ( : # endif replylen += ( sizeof , nif , replylen ) ; for ",the-tcpdump-group@libpcap/617b12c0339db4891d117b661982126c495439ea,CVE-2019-15161,https://github.com/the-tcpdump-group/libpcap/commit/617b12c0339db4891d117b661982126c495439ea,2019-10-03T19:15Z 594,CWE-200,"CWE-200 static int create_problem_dir ( GHashTable * problem_info , unsigned pid ) { if ( g_settings_nMaxCrashReportsSize > 0 ) { if ( low_free_space ( g_settings_nMaxCrashReportsSize , g_settings_dump_location ) ) exit ( 1 ) ; } gchar * dir_basename = g_hash_table_lookup ( problem_info , ""basename"" ) ; if ( ! dir_basename ) dir_basename = g_hash_table_lookup ( problem_info , FILENAME_TYPE ) ; char * path = xasprintf ( ""%s/%s-%s-%u.new"" , g_settings_dump_location , dir_basename , iso_date_string ( NULL ) , pid ) ; g_hash_table_remove ( problem_info , ""basename"" ) ; struct dump_dir * dd = dd_create ( path , client_uid , DEFAULT_DUMP_DIR_MODE ) ; if ( ! dd ) { error_msg_and_die ( ""Errorcreatingproblemdirectory\'%s\'"" , path ) ; } dd_create_basic_files ( dd , client_uid , NULL ) ; dd_save_text ( dd , FILENAME_ABRT_VERSION , VERSION ) ; gpointer gpkey = g_hash_table_lookup ( problem_info , FILENAME_CMDLINE ) ; if ( ! gpkey ) { char * cmdline = get_cmdline ( pid ) ; if ( cmdline ) { dd_save_text ( dd , FILENAME_CMDLINE , cmdline ) ; free ( cmdline ) ; } } char uid_str [ sizeof ( long ) * 3 + 2 ] ; sprintf ( uid_str , ""%lu"" , ( long ) client_uid ) ; dd_save_text ( dd , FILENAME_UID , uid_str ) ; GHashTableIter iter ; gpointer gpvalue ; g_hash_table_iter_init ( & iter , problem_info ) ; while ( g_hash_table_iter_next ( & iter , & gpkey , & gpvalue ) ) { dd_save_text ( dd , ( gchar * ) gpkey , ( gchar * ) gpvalue ) ; } dd_close ( dd ) ; g_hash_table_destroy ( problem_info ) ; char * newpath = xstrndup ( path , strlen ( path ) - strlen ( "".new"" ) ) ; if ( rename ( path , newpath ) == 0 ) strcpy ( path , newpath ) ; free ( newpath ) ; log_notice ( ""Savedproblemdirectoryofpid%uto\'%s\'"" , pid , path ) ; printf ( ""HTTP/1.1201Created\\r\\n\\r\\n"" ) ; fflush ( NULL ) ; close ( STDOUT_FILENO ) ; xdup2 ( STDERR_FILENO , STDOUT_FILENO ) ; if ( g_settings_nMaxCrashReportsSize > 0 ) { trim_problem_dirs ( g_settings_dump_location , g_settings_nMaxCrashReportsSize * ( double ) ( 1024 * 1024 ) , path ) ; } run_post_create ( path ) ; exit ( 0 ) ; } "," ( path , g_settings_privatereports ? 0 : ",abrt@abrt/8939398b82006ba1fec4ed491339fc075f43fc7c,CVE-2015-1870,https://github.com/abrt/abrt/commit/8939398b82006ba1fec4ed491339fc075f43fc7c,2017-06-26T15:29Z 595,CWE-787,"CWE-787 static void InsertRow ( unsigned char * p , ssize_t y , Image * image , int bpp ) { ExceptionInfo * exception ; int bit ; ssize_t x ; register PixelPacket * q ; IndexPacket index ; register IndexPacket * indexes ; exception = ( & image -> exception ) ; switch ( bpp ) { case 1 : { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; indexes = GetAuthenticIndexQueue ( image ) ; for ( x = 0 ; x < ( ( ssize_t ) image -> columns - 7 ) ; x += 8 ) { for ( bit = 0 ; bit < 8 ; bit ++ ) { index = ( ( * p ) & ( 0x80 >> bit ) ? 0x01 : 0x00 ) ; SetPixelIndex ( indexes + x + bit , index ) ; SetPixelRGBO ( q , image -> colormap + ( ssize_t ) index ) ; q ++ ; } p ++ ; } if ( ( image -> columns % 8 ) != 0 ) { for ( bit = 0 ; bit < ( ssize_t ) ( image -> columns % 8 ) ; bit ++ ) { index = ( ( * p ) & ( 0x80 >> bit ) ? 0x01 : 0x00 ) ; SetPixelIndex ( indexes + x + bit , index ) ; SetPixelRGBO ( q , image -> colormap + ( ssize_t ) index ) ; q ++ ; } p ++ ; } if ( ! SyncAuthenticPixels ( image , exception ) ) break ; break ; } case 2 : { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; indexes = GetAuthenticIndexQueue ( image ) ; for ( x = 0 ; x < ( ( ssize_t ) image -> columns - 1 ) ; x += 2 ) { index = ConstrainColormapIndex ( image , ( * p >> 6 ) & 0x3 ) ; SetPixelIndex ( indexes + x , index ) ; SetPixelRGBO ( q , image -> colormap + ( ssize_t ) index ) ; q ++ ; index = ConstrainColormapIndex ( image , ( * p >> 4 ) & 0x3 ) ; SetPixelIndex ( indexes + x , index ) ; SetPixelRGBO ( q , image -> colormap + ( ssize_t ) index ) ; q ++ ; index = ConstrainColormapIndex ( image , ( * p >> 2 ) & 0x3 ) ; SetPixelIndex ( indexes + x , index ) ; SetPixelRGBO ( q , image -> colormap + ( ssize_t ) index ) ; q ++ ; index = ConstrainColormapIndex ( image , ( * p ) & 0x3 ) ; SetPixelIndex ( indexes + x + 1 , index ) ; SetPixelRGBO ( q , image -> colormap + ( ssize_t ) index ) ; p ++ ; q ++ ; } if ( ( image -> columns % 4 ) != 0 ) { index = ConstrainColormapIndex ( image , ( * p >> 6 ) & 0x3 ) ; SetPixelIndex ( indexes + x , index ) ; SetPixelRGBO ( q , image -> colormap + ( ssize_t ) index ) ; q ++ ; if ( ( image -> columns % 4 ) >= 1 ) { index = ConstrainColormapIndex ( image , ( * p >> 4 ) & 0x3 ) ; SetPixelIndex ( indexes + x , index ) ; SetPixelRGBO ( q , image -> colormap + ( ssize_t ) index ) ; q ++ ; if ( ( image -> columns % 4 ) >= 2 ) { index = ConstrainColormapIndex ( image , ( * p >> 2 ) & 0x3 ) ; SetPixelIndex ( indexes + x , index ) ; SetPixelRGBO ( q , image -> colormap + ( ssize_t ) index ) ; q ++ ; } } p ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; break ; } case 4 : { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; indexes = GetAuthenticIndexQueue ( image ) ; for ( x = 0 ; x < ( ( ssize_t ) image -> columns - 1 ) ; x += 2 ) { index = ConstrainColormapIndex ( image , ( * p >> 4 ) & 0x0f ) ; SetPixelIndex ( indexes + x , index ) ; SetPixelRGBO ( q , image -> colormap + ( ssize_t ) index ) ; q ++ ; index = ConstrainColormapIndex ( image , ( * p ) & 0x0f ) ; SetPixelIndex ( indexes + x + 1 , index ) ; SetPixelRGBO ( q , image -> colormap + ( ssize_t ) index ) ; p ++ ; q ++ ; } if ( ( image -> columns % 2 ) != 0 ) { index = ConstrainColormapIndex ( image , ( * p >> 4 ) & 0x0f ) ; SetPixelIndex ( indexes + x , index ) ; SetPixelRGBO ( q , image -> colormap + ( ssize_t ) index ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; break ; } case 8 : { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; indexes = GetAuthenticIndexQueue ( image ) ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { index = ConstrainColormapIndex ( image , * p ) ; SetPixelIndex ( indexes + x , index ) ; SetPixelRGBO ( q , image -> colormap + ( ssize_t ) index ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } break ; case 24 : q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( q , ScaleCharToQuantum ( * p ++ ) ) ; SetPixelGreen ( q , ScaleCharToQuantum ( * p ++ ) ) ; SetPixelBlue ( q , ScaleCharToQuantum ( * p ++ ) ) ; q ++ ; } if ( ! SyncAuthenticPixels ( image , exception ) ) break ; break ; } } "," ; x += 4 ) { index ",ImageMagick@ImageMagick/b6ae2f9e0ab13343c0281732d479757a8e8979c7,CVE-2016-7526,https://github.com/ImageMagick/ImageMagick/commit/b6ae2f9e0ab13343c0281732d479757a8e8979c7,2017-04-20T18:59Z 596,CWE-310,"CWE-310 void bn_sqr_comba8 ( BN_ULONG * r , const BN_ULONG * a ) { BN_ULONG t1 , t2 ; BN_ULONG c1 , c2 , c3 ; c1 = 0 ; c2 = 0 ; c3 = 0 ; sqr_add_c ( a , 0 , c1 , c2 , c3 ) ; r [ 0 ] = c1 ; c1 = 0 ; sqr_add_c2 ( a , 1 , 0 , c2 , c3 , c1 ) ; r [ 1 ] = c2 ; c2 = 0 ; sqr_add_c ( a , 1 , c3 , c1 , c2 ) ; sqr_add_c2 ( a , 2 , 0 , c3 , c1 , c2 ) ; r [ 2 ] = c3 ; c3 = 0 ; sqr_add_c2 ( a , 3 , 0 , c1 , c2 , c3 ) ; sqr_add_c2 ( a , 2 , 1 , c1 , c2 , c3 ) ; r [ 3 ] = c1 ; c1 = 0 ; sqr_add_c ( a , 2 , c2 , c3 , c1 ) ; sqr_add_c2 ( a , 3 , 1 , c2 , c3 , c1 ) ; sqr_add_c2 ( a , 4 , 0 , c2 , c3 , c1 ) ; r [ 4 ] = c2 ; c2 = 0 ; sqr_add_c2 ( a , 5 , 0 , c3 , c1 , c2 ) ; sqr_add_c2 ( a , 4 , 1 , c3 , c1 , c2 ) ; sqr_add_c2 ( a , 3 , 2 , c3 , c1 , c2 ) ; r [ 5 ] = c3 ; c3 = 0 ; sqr_add_c ( a , 3 , c1 , c2 , c3 ) ; sqr_add_c2 ( a , 4 , 2 , c1 , c2 , c3 ) ; sqr_add_c2 ( a , 5 , 1 , c1 , c2 , c3 ) ; sqr_add_c2 ( a , 6 , 0 , c1 , c2 , c3 ) ; r [ 6 ] = c1 ; c1 = 0 ; sqr_add_c2 ( a , 7 , 0 , c2 , c3 , c1 ) ; sqr_add_c2 ( a , 6 , 1 , c2 , c3 , c1 ) ; sqr_add_c2 ( a , 5 , 2 , c2 , c3 , c1 ) ; sqr_add_c2 ( a , 4 , 3 , c2 , c3 , c1 ) ; r [ 7 ] = c2 ; c2 = 0 ; sqr_add_c ( a , 4 , c3 , c1 , c2 ) ; sqr_add_c2 ( a , 5 , 3 , c3 , c1 , c2 ) ; sqr_add_c2 ( a , 6 , 2 , c3 , c1 , c2 ) ; sqr_add_c2 ( a , 7 , 1 , c3 , c1 , c2 ) ; r [ 8 ] = c3 ; c3 = 0 ; sqr_add_c2 ( a , 7 , 2 , c1 , c2 , c3 ) ; sqr_add_c2 ( a , 6 , 3 , c1 , c2 , c3 ) ; sqr_add_c2 ( a , 5 , 4 , c1 , c2 , c3 ) ; r [ 9 ] = c1 ; c1 = 0 ; sqr_add_c ( a , 5 , c2 , c3 , c1 ) ; sqr_add_c2 ( a , 6 , 4 , c2 , c3 , c1 ) ; sqr_add_c2 ( a , 7 , 3 , c2 , c3 , c1 ) ; r [ 10 ] = c2 ; c2 = 0 ; sqr_add_c2 ( a , 7 , 4 , c3 , c1 , c2 ) ; sqr_add_c2 ( a , 6 , 5 , c3 , c1 , c2 ) ; r [ 11 ] = c3 ; c3 = 0 ; sqr_add_c ( a , 6 , c1 , c2 , c3 ) ; sqr_add_c2 ( a , 7 , 5 , c1 , c2 , c3 ) ; r [ 12 ] = c1 ; c1 = 0 ; sqr_add_c2 ( a , 7 , 6 , c2 , c3 , c1 ) ; r [ 13 ] = c2 ; c2 = 0 ; sqr_add_c ( a , 7 , c3 , c1 , c2 ) ; r [ 14 ] = c3 ; r [ 15 ] = c1 ; } "," ) { BN_ULONG c1 , c2 ",openssl@openssl/a7a44ba55cb4f884c6bc9ceac90072dea38e66d0,CVE-2014-3570,https://github.com/openssl/openssl/commit/a7a44ba55cb4f884c6bc9ceac90072dea38e66d0,2015-01-09T02:59Z 597,CWE-125,"CWE-125 static void __skb_complete_tx_timestamp ( struct sk_buff * skb , struct sock * sk , int tstype ) { struct sock_exterr_skb * serr ; int err ; serr = SKB_EXT_ERR ( skb ) ; memset ( serr , 0 , sizeof ( * serr ) ) ; serr -> ee . ee_errno = ENOMSG ; serr -> ee . ee_origin = SO_EE_ORIGIN_TIMESTAMPING ; serr -> ee . ee_info = tstype ; if ( sk -> sk_tsflags & SOF_TIMESTAMPING_OPT_ID ) { serr -> ee . ee_data = skb_shinfo ( skb ) -> tskey ; if ( sk -> sk_protocol == IPPROTO_TCP && sk -> sk_type == SOCK_STREAM ) serr -> ee . ee_data -= sk -> sk_tskey ; } err = sock_queue_err_skb ( sk , skb ) ; if ( err ) kfree_skb ( skb ) ; } "," , int tstype , bool opt_stats ; int err ; BUILD_BUG_ON ( sizeof ( struct sock_exterr_skb ) > sizeof ( skb -> cb ) ) ee_info = tstype ; serr -> opt_stats = opt_stats ",torvalds@linux/4ef1b2869447411ad3ef91ad7d4891a83c1a509a,CVE-2017-7277,https://github.com/torvalds/linux/commit/4ef1b2869447411ad3ef91ad7d4891a83c1a509a,2017-03-28T06:59Z 598,CWE-119,"CWE-119 static Image * ReadDDSImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { Image * image ; MagickBooleanType status , cubemap = MagickFalse , volume = MagickFalse , matte ; CompressionType compression ; DDSInfo dds_info ; DDSDecoder * decoder ; size_t n , num_images ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } if ( ReadDDSInfo ( image , & dds_info ) != MagickTrue ) { ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; } if ( dds_info . ddscaps2 & DDSCAPS2_CUBEMAP ) cubemap = MagickTrue ; if ( dds_info . ddscaps2 & DDSCAPS2_VOLUME && dds_info . depth > 0 ) volume = MagickTrue ; ( void ) SeekBlob ( image , 128 , SEEK_SET ) ; if ( dds_info . pixelformat . flags & DDPF_RGB ) { compression = NoCompression ; if ( dds_info . pixelformat . flags & DDPF_ALPHAPIXELS ) { matte = MagickTrue ; decoder = ReadUncompressedRGBA ; } else { matte = MagickTrue ; decoder = ReadUncompressedRGB ; } } else if ( dds_info . pixelformat . flags & DDPF_LUMINANCE ) { compression = NoCompression ; if ( dds_info . pixelformat . flags & DDPF_ALPHAPIXELS ) { ThrowReaderException ( CorruptImageError , ""ImageTypeNotSupported"" ) ; } else { matte = MagickFalse ; decoder = ReadUncompressedRGB ; } } else if ( dds_info . pixelformat . flags & DDPF_FOURCC ) { switch ( dds_info . pixelformat . fourcc ) { case FOURCC_DXT1 : { matte = MagickFalse ; compression = DXT1Compression ; decoder = ReadDXT1 ; break ; } case FOURCC_DXT3 : { matte = MagickTrue ; compression = DXT3Compression ; decoder = ReadDXT3 ; break ; } case FOURCC_DXT5 : { matte = MagickTrue ; compression = DXT5Compression ; decoder = ReadDXT5 ; break ; } default : { ThrowReaderException ( CorruptImageError , ""ImageTypeNotSupported"" ) ; } } } else { ThrowReaderException ( CorruptImageError , ""ImageTypeNotSupported"" ) ; } num_images = 1 ; if ( cubemap ) { num_images = 0 ; if ( dds_info . ddscaps2 & DDSCAPS2_CUBEMAP_POSITIVEX ) num_images ++ ; if ( dds_info . ddscaps2 & DDSCAPS2_CUBEMAP_NEGATIVEX ) num_images ++ ; if ( dds_info . ddscaps2 & DDSCAPS2_CUBEMAP_POSITIVEY ) num_images ++ ; if ( dds_info . ddscaps2 & DDSCAPS2_CUBEMAP_NEGATIVEY ) num_images ++ ; if ( dds_info . ddscaps2 & DDSCAPS2_CUBEMAP_POSITIVEZ ) num_images ++ ; if ( dds_info . ddscaps2 & DDSCAPS2_CUBEMAP_NEGATIVEZ ) num_images ++ ; } if ( volume ) num_images = dds_info . depth ; for ( n = 0 ; n < num_images ; n ++ ) { if ( n != 0 ) { AcquireNextImage ( image_info , image ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) return ( DestroyImageList ( image ) ) ; image = SyncNextImageInList ( image ) ; } image -> matte = matte ; image -> compression = compression ; image -> columns = dds_info . width ; image -> rows = dds_info . height ; image -> storage_class = DirectClass ; image -> endian = LSBEndian ; image -> depth = 8 ; if ( image_info -> ping != MagickFalse ) { ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } if ( ( decoder ) ( image , & dds_info , exception ) != MagickTrue ) { ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } } if ( EOFBlob ( image ) != MagickFalse ) ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," ) ; } status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; } ",ImageMagick@ImageMagick/f6e9d0d9955e85bdd7540b251cd50d598dacc5e6,CVE-2016-10066,https://github.com/ImageMagick/ImageMagick/commit/f6e9d0d9955e85bdd7540b251cd50d598dacc5e6,2017-03-03T17:59Z 599,CWE-125,"CWE-125 void vrrp_print ( netdissect_options * ndo , register const u_char * bp , register u_int len , register const u_char * bp2 , int ttl ) { int version , type , auth_type = VRRP_AUTH_NONE ; const char * type_s ; ND_TCHECK ( bp [ 0 ] ) ; version = ( bp [ 0 ] & 0xf0 ) >> 4 ; type = bp [ 0 ] & 0x0f ; type_s = tok2str ( type2str , ""unknowntype(%u)"" , type ) ; ND_PRINT ( ( ndo , ""VRRPv%u,%s"" , version , type_s ) ) ; if ( ttl != 255 ) ND_PRINT ( ( ndo , "",(ttl%u)"" , ttl ) ) ; if ( version < 2 || version > 3 || type != VRRP_TYPE_ADVERTISEMENT ) return ; ND_TCHECK ( bp [ 2 ] ) ; ND_PRINT ( ( ndo , "",vrid%u,prio%u"" , bp [ 1 ] , bp [ 2 ] ) ) ; ND_TCHECK ( bp [ 5 ] ) ; if ( version == 2 ) { auth_type = bp [ 4 ] ; ND_PRINT ( ( ndo , "",authtype%s"" , tok2str ( auth2str , NULL , auth_type ) ) ) ; ND_PRINT ( ( ndo , "",intvl%us,length%u"" , bp [ 5 ] , len ) ) ; } else { uint16_t intvl = ( bp [ 4 ] & 0x0f ) << 8 | bp [ 5 ] ; ND_PRINT ( ( ndo , "",intvl%ucs,length%u"" , intvl , len ) ) ; } if ( ndo -> ndo_vflag ) { int naddrs = bp [ 3 ] ; int i ; char c ; if ( version == 2 && ND_TTEST2 ( bp [ 0 ] , len ) ) { struct cksum_vec vec [ 1 ] ; vec [ 0 ] . ptr = bp ; vec [ 0 ] . len = len ; if ( in_cksum ( vec , 1 ) ) ND_PRINT ( ( ndo , "",(badvrrpcksum%x)"" , EXTRACT_16BITS ( & bp [ 6 ] ) ) ) ; } if ( version == 3 && ND_TTEST2 ( bp [ 0 ] , len ) ) { uint16_t cksum = nextproto4_cksum ( ndo , ( const struct ip * ) bp2 , bp , len , len , IPPROTO_VRRP ) ; if ( cksum ) ND_PRINT ( ( ndo , "",(badvrrpcksum%x)"" , EXTRACT_16BITS ( & bp [ 6 ] ) ) ) ; } ND_PRINT ( ( ndo , "",addrs"" ) ) ; if ( naddrs > 1 ) ND_PRINT ( ( ndo , ""(%d)"" , naddrs ) ) ; ND_PRINT ( ( ndo , "":"" ) ) ; c = '' ; bp += 8 ; for ( i = 0 ; i < naddrs ; i ++ ) { ND_TCHECK ( bp [ 3 ] ) ; ND_PRINT ( ( ndo , ""%c%s"" , c , ipaddr_string ( ndo , bp ) ) ) ; c = ',' ; bp += 4 ; } if ( version == 2 && auth_type == VRRP_AUTH_SIMPLE ) { ND_TCHECK ( bp [ 7 ] ) ; ND_PRINT ( ( ndo , ""auth\\"""" ) ) ; if ( fn_printn ( ndo , bp , 8 , ndo -> ndo_snapend ) ) { ND_PRINT ( ( ndo , ""\\"""" ) ) ; goto trunc ; } ND_PRINT ( ( ndo , ""\\"""" ) ) ; } } return ; trunc : ND_PRINT ( ( ndo , ""[|vrrp]"" ) ) ; } "," 1 ) ) { ND_TCHECK_16BITS ( & bp [ 6 ] ) ; ) ) ; } ",the-tcpdump-group@tcpdump/3de07c772166b7e8e8bb4b9d1d078f1d901b570b,CVE-2018-14463,https://github.com/the-tcpdump-group/tcpdump/commit/3de07c772166b7e8e8bb4b9d1d078f1d901b570b,2019-10-03T16:15Z 600,CWE-190,"CWE-190 static void test_burl_normalize ( void ) { buffer * psrc = buffer_init ( ) ; buffer * ptmp = buffer_init ( ) ; int flags ; flags = HTTP_PARSEOPT_URL_NORMALIZE_UNRESERVED ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""no-slash"" ) , CONST_STR_LEN ( ""no-slash"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/"" ) , CONST_STR_LEN ( ""/"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/abc"" ) , CONST_STR_LEN ( ""/abc"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/abc/"" ) , CONST_STR_LEN ( ""/abc/"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/abc/def"" ) , CONST_STR_LEN ( ""/abc/def"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/abc?"" ) , CONST_STR_LEN ( ""/abc?"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/abc?d"" ) , CONST_STR_LEN ( ""/abc?d"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/abc?d="" ) , CONST_STR_LEN ( ""/abc?d="" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/abc?d=e"" ) , CONST_STR_LEN ( ""/abc?d=e"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/abc?d=e&"" ) , CONST_STR_LEN ( ""/abc?d=e&"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/abc?d=e&f"" ) , CONST_STR_LEN ( ""/abc?d=e&f"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/abc?d=e&f=g"" ) , CONST_STR_LEN ( ""/abc?d=e&f=g"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/abc?d=e&f=g#"" ) , CONST_STR_LEN ( ""/abc?d=e&f=g"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/abc?d=e&f=g#any"" ) , CONST_STR_LEN ( ""/abc?d=e&f=g"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/%2F"" ) , CONST_STR_LEN ( ""/%2F"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/%2f"" ) , CONST_STR_LEN ( ""/%2F"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/%20"" ) , CONST_STR_LEN ( ""/%20"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/%2b"" ) , CONST_STR_LEN ( ""/%2B"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/%2B"" ) , CONST_STR_LEN ( ""/%2B"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/%3a"" ) , CONST_STR_LEN ( ""/%3A"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/%3A"" ) , CONST_STR_LEN ( ""/%3A"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/~test%20ä_"" ) , CONST_STR_LEN ( ""/~test%20%C3%A4_"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/\\375"" ) , """" , ( size_t ) - 2 ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/\\376"" ) , """" , ( size_t ) - 2 ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/\\377"" ) , """" , ( size_t ) - 2 ) ; flags = HTTP_PARSEOPT_URL_NORMALIZE_REQUIRED ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/"" ) , CONST_STR_LEN ( ""/"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/abc"" ) , CONST_STR_LEN ( ""/abc"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/abc/"" ) , CONST_STR_LEN ( ""/abc/"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/abc/def"" ) , CONST_STR_LEN ( ""/abc/def"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/abc?"" ) , CONST_STR_LEN ( ""/abc?"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/abc?d"" ) , CONST_STR_LEN ( ""/abc?d"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/abc?d="" ) , CONST_STR_LEN ( ""/abc?d="" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/abc?d=e"" ) , CONST_STR_LEN ( ""/abc?d=e"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/abc?d=e&"" ) , CONST_STR_LEN ( ""/abc?d=e&"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/abc?d=e&f"" ) , CONST_STR_LEN ( ""/abc?d=e&f"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/abc?d=e&f=g"" ) , CONST_STR_LEN ( ""/abc?d=e&f=g"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/abc?d=e&f=g#"" ) , CONST_STR_LEN ( ""/abc?d=e&f=g"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/abc?d=e&f=g#any"" ) , CONST_STR_LEN ( ""/abc?d=e&f=g"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/%2F"" ) , CONST_STR_LEN ( ""/%2F"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/%2f"" ) , CONST_STR_LEN ( ""/%2F"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/%20"" ) , CONST_STR_LEN ( ""/%20"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/%2b"" ) , CONST_STR_LEN ( ""/+"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/%2B"" ) , CONST_STR_LEN ( ""/+"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/%3a"" ) , CONST_STR_LEN ( ""/:"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/%3A"" ) , CONST_STR_LEN ( ""/:"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/~test%20ä_"" ) , CONST_STR_LEN ( ""/~test%20%C3%A4_"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/\\375"" ) , """" , ( size_t ) - 2 ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/\\376"" ) , """" , ( size_t ) - 2 ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/\\377"" ) , """" , ( size_t ) - 2 ) ; flags |= HTTP_PARSEOPT_URL_NORMALIZE_CTRLS_REJECT ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/\\a"" ) , """" , ( size_t ) - 2 ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/\\t"" ) , """" , ( size_t ) - 2 ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/\\r"" ) , """" , ( size_t ) - 2 ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/\\177"" ) , """" , ( size_t ) - 2 ) ; # if defined ( __WIN32 ) || defined ( __CYGWIN__ ) flags |= HTTP_PARSEOPT_URL_NORMALIZE_PATH_BACKSLASH_TRANS ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/a\\\\b"" ) , CONST_STR_LEN ( ""/a/b"" ) ) ; # endif flags |= HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_DECODE ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/a/b?c=/"" ) , CONST_STR_LEN ( ""/a/b?c=/"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/a/b?c=%2f"" ) , CONST_STR_LEN ( ""/a/b?c=/"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/a%2fb"" ) , CONST_STR_LEN ( ""/a/b"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/a%2Fb"" ) , CONST_STR_LEN ( ""/a/b"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/a%2fb?c=/"" ) , CONST_STR_LEN ( ""/a/b?c=/"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/a%2fb?c=%2f"" ) , CONST_STR_LEN ( ""/a/b?c=/"" ) ) ; flags &= ~ HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_DECODE ; flags |= HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_REJECT ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/a%2fb"" ) , """" , ( size_t ) - 2 ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/a%2Fb"" ) , """" , ( size_t ) - 2 ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/a/b?c=%2f"" ) , CONST_STR_LEN ( ""/a/b?c=/"" ) ) ; flags &= ~ HTTP_PARSEOPT_URL_NORMALIZE_PATH_2F_REJECT ; flags |= HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REMOVE ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""./a/b"" ) , CONST_STR_LEN ( ""/a/b"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""../a/b"" ) , CONST_STR_LEN ( ""/a/b"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/a/./b"" ) , CONST_STR_LEN ( ""/a/b"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/a/../b"" ) , CONST_STR_LEN ( ""/b"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/a/b/."" ) , CONST_STR_LEN ( ""/a/b/"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/a/b/.."" ) , CONST_STR_LEN ( ""/a/"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/a/../b/.."" ) , CONST_STR_LEN ( ""/"" ) ) ; flags &= ~ HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REMOVE ; flags |= HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REJECT ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""./a/b"" ) , """" , ( size_t ) - 2 ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""../a/b"" ) , """" , ( size_t ) - 2 ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/a/./b"" ) , """" , ( size_t ) - 2 ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/a/../b"" ) , """" , ( size_t ) - 2 ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/a/b/."" ) , """" , ( size_t ) - 2 ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/a/b/.."" ) , """" , ( size_t ) - 2 ) ; flags &= ~ HTTP_PARSEOPT_URL_NORMALIZE_PATH_DOTSEG_REJECT ; flags |= HTTP_PARSEOPT_URL_NORMALIZE_QUERY_20_PLUS ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/a/b?c=d+e"" ) , CONST_STR_LEN ( ""/a/b?c=d+e"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/a/b?c=d%20e"" ) , CONST_STR_LEN ( ""/a/b?c=d+e"" ) ) ; flags &= ~ HTTP_PARSEOPT_URL_NORMALIZE_QUERY_20_PLUS ; buffer_free ( psrc ) ; buffer_free ( ptmp ) ; } "," , CONST_STR_LEN ( ""%2f?"" ) , CONST_STR_LEN ( ""/?"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ""/%2f?"" ) , CONST_STR_LEN ( ""//?"" ) ) ; run_burl_normalize ( psrc , ptmp , flags , __LINE__ , CONST_STR_LEN ( ",lighttpd@lighttpd1.4/32120d5b8b3203fc21ccb9eafb0eaf824bb59354,CVE-2019-11072,https://github.com/lighttpd/lighttpd1.4/commit/32120d5b8b3203fc21ccb9eafb0eaf824bb59354,2019-04-10T22:29Z 601,CWE-264,"CWE-264 static int __ptrace_may_access ( struct task_struct * task , unsigned int mode ) { const struct cred * cred = current_cred ( ) , * tcred ; int dumpable = 0 ; if ( same_thread_group ( task , current ) ) return 0 ; rcu_read_lock ( ) ; tcred = __task_cred ( task ) ; if ( uid_eq ( cred -> uid , tcred -> euid ) && uid_eq ( cred -> uid , tcred -> suid ) && uid_eq ( cred -> uid , tcred -> uid ) && gid_eq ( cred -> gid , tcred -> egid ) && gid_eq ( cred -> gid , tcred -> sgid ) && gid_eq ( cred -> gid , tcred -> gid ) ) goto ok ; if ( ptrace_has_cap ( tcred -> user_ns , mode ) ) goto ok ; rcu_read_unlock ( ) ; return - EPERM ; ok : rcu_read_unlock ( ) ; smp_rmb ( ) ; if ( task -> mm ) dumpable = get_dumpable ( task -> mm ) ; rcu_read_lock ( ) ; if ( ! dumpable && ! ptrace_has_cap ( __task_cred ( task ) -> user_ns , mode ) ) { rcu_read_unlock ( ) ; return - EPERM ; } rcu_read_unlock ( ) ; return security_ptrace_access_check ( task , mode ) ; } "," ; if ( dumpable != SUID_DUMP_USER && ! ptrace_has_cap ( ",torvalds@linux/d049f74f2dbe71354d43d393ac3a188947811348,CVE-2013-2929,https://github.com/torvalds/linux/commit/d049f74f2dbe71354d43d393ac3a188947811348,2013-12-09T18:55Z 602,CWE-189,"CWE-189 static void add_bytes_l2_c ( uint8_t * dst , uint8_t * src1 , uint8_t * src2 , int w ) { long i ; for ( i = 0 ; i <= w - sizeof ( long ) ; i += sizeof ( long ) ) { long a = * ( long * ) ( src1 + i ) ; long b = * ( long * ) ( src2 + i ) ; * ( long * ) ( dst + i ) = ( ( a & pb_7f ) + ( b & pb_7f ) ) ^ ( ( a ^ b ) & pb_80 ) ; } for ( ; i < w ; i ++ ) dst [ i ] = src1 [ i ] + src2 [ i ] ; } "," <= w - ( int ) ",FFmpeg@FFmpeg/86736f59d6a527d8bc807d09b93f971c0fe0bb07,CVE-2013-7014,https://github.com/FFmpeg/FFmpeg/commit/86736f59d6a527d8bc807d09b93f971c0fe0bb07,2013-12-09T16:36Z 603,CWE-200,"CWE-200 static void * __dma_alloc_coherent ( struct device * dev , size_t size , dma_addr_t * dma_handle , gfp_t flags , struct dma_attrs * attrs ) { if ( dev == NULL ) { WARN_ONCE ( 1 , ""UseanactualdevicestructureforDMAallocation\\n"" ) ; return NULL ; } if ( IS_ENABLED ( CONFIG_ZONE_DMA ) && dev -> coherent_dma_mask <= DMA_BIT_MASK ( 32 ) ) flags |= GFP_DMA ; if ( IS_ENABLED ( CONFIG_DMA_CMA ) && ( flags & __GFP_WAIT ) ) { struct page * page ; void * addr ; size = PAGE_ALIGN ( size ) ; page = dma_alloc_from_contiguous ( dev , size >> PAGE_SHIFT , get_order ( size ) ) ; if ( ! page ) return NULL ; * dma_handle = phys_to_dma ( dev , page_to_phys ( page ) ) ; addr = page_address ( page ) ; if ( flags & __GFP_ZERO ) memset ( addr , 0 , size ) ; return addr ; } else { return swiotlb_alloc_coherent ( dev , size , dma_handle , flags ) ; } } "," page ) ; memset ( addr ",torvalds@linux/6829e274a623187c24f7cfc0e3d35f25d087fcc5,CVE-2015-8950,https://github.com/torvalds/linux/commit/6829e274a623187c24f7cfc0e3d35f25d087fcc5,2016-10-10T10:59Z 604,CWE-190,"CWE-190 void jas_matrix_clip ( jas_matrix_t * matrix , jas_seqent_t minval , jas_seqent_t maxval ) { int i ; int j ; jas_seqent_t v ; jas_seqent_t * rowstart ; jas_seqent_t * data ; int rowstep ; if ( jas_matrix_numrows ( matrix ) > 0 && jas_matrix_numcols ( matrix ) > 0 ) { assert ( matrix -> rows_ ) ; rowstep = jas_matrix_rowstep ( matrix ) ; for ( i = matrix -> numrows_ , rowstart = matrix -> rows_ [ 0 ] ; i > 0 ; -- i , rowstart += rowstep ) { data = rowstart ; for ( j = matrix -> numcols_ , data = rowstart ; j > 0 ; -- j , ++ data ) { v = * data ; if ( v < minval ) { * data = minval ; } else if ( v > maxval ) { * data = maxval ; } } } } } "," maxval ) { jas_matind_t i ; jas_matind_t j ; jas_seqent_t * data ; jas_matind_t rowstep ; if ",mdadams@jasper/d42b2388f7f8e0332c846675133acea151fc557a,CVE-2016-9557,https://github.com/mdadams/jasper/commit/d42b2388f7f8e0332c846675133acea151fc557a,2017-03-23T18:59Z 605,CWE-190,"CWE-190 void ihevcd_parse_sei_payload ( codec_t * ps_codec , UWORD32 u4_payload_type , UWORD32 u4_payload_size , WORD8 i1_nal_type ) { parse_ctxt_t * ps_parse = & ps_codec -> s_parse ; bitstrm_t * ps_bitstrm = & ps_parse -> s_bitstrm ; WORD32 payload_bits_remaining = 0 ; sps_t * ps_sps ; UWORD32 i ; for ( i = 0 ; i < MAX_SPS_CNT ; i ++ ) { ps_sps = ps_codec -> ps_sps_base + i ; if ( ps_sps -> i1_sps_valid ) { break ; } } if ( NULL == ps_sps ) { return ; } if ( NAL_PREFIX_SEI == i1_nal_type ) { switch ( u4_payload_type ) { case SEI_BUFFERING_PERIOD : ps_parse -> s_sei_params . i1_sei_parameters_present_flag = 1 ; ihevcd_parse_buffering_period_sei ( ps_codec , ps_sps ) ; break ; case SEI_PICTURE_TIMING : ps_parse -> s_sei_params . i1_sei_parameters_present_flag = 1 ; ihevcd_parse_pic_timing_sei ( ps_codec , ps_sps ) ; break ; case SEI_TIME_CODE : ps_parse -> s_sei_params . i1_sei_parameters_present_flag = 1 ; ihevcd_parse_time_code_sei ( ps_codec ) ; break ; case SEI_MASTERING_DISPLAY_COLOUR_VOLUME : ps_parse -> s_sei_params . i4_sei_mastering_disp_colour_vol_params_present_flags = 1 ; ihevcd_parse_mastering_disp_params_sei ( ps_codec ) ; break ; case SEI_USER_DATA_REGISTERED_ITU_T_T35 : ps_parse -> s_sei_params . i1_sei_parameters_present_flag = 1 ; ihevcd_parse_user_data_registered_itu_t_t35 ( ps_codec , u4_payload_size ) ; break ; default : for ( i = 0 ; i < u4_payload_size ; i ++ ) { ihevcd_bits_flush ( ps_bitstrm , 8 ) ; } break ; } } else { switch ( u4_payload_type ) { case SEI_USER_DATA_REGISTERED_ITU_T_T35 : ps_parse -> s_sei_params . i1_sei_parameters_present_flag = 1 ; ihevcd_parse_user_data_registered_itu_t_t35 ( ps_codec , u4_payload_size ) ; break ; default : for ( i = 0 ; i < u4_payload_size ; i ++ ) { ihevcd_bits_flush ( ps_bitstrm , 8 ) ; } break ; } } payload_bits_remaining = ihevcd_bits_num_bits_remaining ( ps_bitstrm ) ; if ( payload_bits_remaining ) { WORD32 final_bits ; WORD32 final_payload_bits = 0 ; WORD32 mask = 0xFF ; UWORD32 u4_dummy ; UWORD32 u4_reserved_payload_extension_data ; UNUSED ( u4_dummy ) ; UNUSED ( u4_reserved_payload_extension_data ) ; while ( payload_bits_remaining > 9 ) { BITS_PARSE ( ""reserved_payload_extension_data"" , u4_reserved_payload_extension_data , ps_bitstrm , 1 ) ; payload_bits_remaining -- ; } final_bits = ihevcd_bits_nxt ( ps_bitstrm , payload_bits_remaining ) ; while ( final_bits & ( mask >> final_payload_bits ) ) { final_payload_bits ++ ; continue ; } while ( payload_bits_remaining > ( 9 - final_payload_bits ) ) { BITS_PARSE ( ""reserved_payload_extension_data"" , u4_reserved_payload_extension_data , ps_bitstrm , 1 ) ; payload_bits_remaining -- ; } BITS_PARSE ( ""payload_bit_equal_to_one"" , u4_dummy , ps_bitstrm , 1 ) ; payload_bits_remaining -- ; while ( payload_bits_remaining ) { BITS_PARSE ( ""payload_bit_equal_to_zero"" , u4_dummy , ps_bitstrm , 1 ) ; payload_bits_remaining -- ; } } return ; } "," = 1 ; if ( ps_parse -> s_sei_params . i4_sei_user_data_cnt >= USER_DATA_MAX ) { for ( i = 0 ; i < u4_payload_size / 4 ; i ++ ) { ihevcd_bits_flush ( ps_bitstrm , 4 * 8 ) ; } ihevcd_bits_flush ( ps_bitstrm , ( u4_payload_size - i * 4 ) * 8 ) ; } else { u4_payload_size ) ; } = 1 ; if ( ps_parse -> s_sei_params . i4_sei_user_data_cnt >= USER_DATA_MAX ) { for ( i = 0 ; i < u4_payload_size / 4 ; i ++ ) { ihevcd_bits_flush ( ps_bitstrm , 4 * 8 ) ; } ihevcd_bits_flush ( ps_bitstrm , ( u4_payload_size - i * 4 ) * 8 ) ; } else { u4_payload_size ) ; } ",external@libhevc/9f0fb67540d2259e4930d9bd5f1a1a6fb95af862,CVE-2018-9473,https://android.googlesource.com/platform/external/libhevc/+/9f0fb67540d2259e4930d9bd5f1a1a6fb95af862,2018-10-02T19:29Z 606,CWE-000,"CWE-000 static int cypress_generic_port_probe ( struct usb_serial_port * port ) { struct usb_serial * serial = port -> serial ; struct cypress_private * priv ; priv = kzalloc ( sizeof ( struct cypress_private ) , GFP_KERNEL ) ; if ( ! priv ) return - ENOMEM ; priv -> comm_is_ok = ! 0 ; spin_lock_init ( & priv -> lock ) ; if ( kfifo_alloc ( & priv -> write_fifo , CYPRESS_BUF_SIZE , GFP_KERNEL ) ) { kfree ( priv ) ; return - ENOMEM ; } if ( ! is_frwd ( serial -> dev ) ) usb_reset_configuration ( serial -> dev ) ; priv -> cmd_ctrl = 0 ; priv -> line_control = 0 ; priv -> termios_initialized = 0 ; priv -> rx_flags = 0 ; if ( port -> interrupt_out_size > 9 ) priv -> pkt_fmt = packet_format_1 ; else priv -> pkt_fmt = packet_format_2 ; if ( interval > 0 ) { priv -> write_urb_interval = interval ; priv -> read_urb_interval = interval ; dev_dbg ( & port -> dev , ""%s-read&writeintervalsforcedto%d\\n"" , __func__ , interval ) ; } else { priv -> write_urb_interval = port -> interrupt_out_urb -> interval ; priv -> read_urb_interval = port -> interrupt_in_urb -> interval ; dev_dbg ( & port -> dev , ""%s-intervals:read=%dwrite=%d\\n"" , __func__ , priv -> read_urb_interval , priv -> write_urb_interval ) ; } usb_set_serial_port_data ( port , priv ) ; port -> port . drain_delay = 256 ; return 0 ; } "," * priv ; if ( ! port -> interrupt_out_urb || ! port -> interrupt_in_urb ) { dev_err ( & port -> dev , ""requiredendpointismissing\\n"" ) ; return - ENODEV ; } ",torvalds@linux/c55aee1bf0e6b6feec8b2927b43f7a09a6d5f754,CVE-2016-3137,https://github.com/torvalds/linux/commit/c55aee1bf0e6b6feec8b2927b43f7a09a6d5f754,2016-05-02T10:59Z 607,CWE-401,"CWE-401 int sdma_init ( struct hfi1_devdata * dd , u8 port ) { unsigned this_idx ; struct sdma_engine * sde ; struct rhashtable * tmp_sdma_rht ; u16 descq_cnt ; void * curr_head ; struct hfi1_pportdata * ppd = dd -> pport + port ; u32 per_sdma_credits ; uint idle_cnt = sdma_idle_cnt ; size_t num_engines = chip_sdma_engines ( dd ) ; int ret = - ENOMEM ; if ( ! HFI1_CAP_IS_KSET ( SDMA ) ) { HFI1_CAP_CLEAR ( SDMA_AHG ) ; return 0 ; } if ( mod_num_sdma && mod_num_sdma <= chip_sdma_engines ( dd ) && mod_num_sdma >= num_vls ) num_engines = mod_num_sdma ; dd_dev_info ( dd , ""SDMAmod_num_sdma:%u\\n"" , mod_num_sdma ) ; dd_dev_info ( dd , ""SDMAchip_sdma_engines:%u\\n"" , chip_sdma_engines ( dd ) ) ; dd_dev_info ( dd , ""SDMAchip_sdma_mem_size:%u\\n"" , chip_sdma_mem_size ( dd ) ) ; per_sdma_credits = chip_sdma_mem_size ( dd ) / ( num_engines * SDMA_BLOCK_SIZE ) ; init_waitqueue_head ( & dd -> sdma_unfreeze_wq ) ; atomic_set ( & dd -> sdma_unfreeze_count , 0 ) ; descq_cnt = sdma_get_descq_cnt ( ) ; dd_dev_info ( dd , ""SDMAengines%zudescq_cnt%u\\n"" , num_engines , descq_cnt ) ; dd -> per_sdma = kcalloc_node ( num_engines , sizeof ( * dd -> per_sdma ) , GFP_KERNEL , dd -> node ) ; if ( ! dd -> per_sdma ) return ret ; idle_cnt = ns_to_cclock ( dd , idle_cnt ) ; if ( idle_cnt ) dd -> default_desc1 = SDMA_DESC1_HEAD_TO_HOST_FLAG ; else dd -> default_desc1 = SDMA_DESC1_INT_REQ_FLAG ; if ( ! sdma_desct_intr ) sdma_desct_intr = SDMA_DESC_INTR ; for ( this_idx = 0 ; this_idx < num_engines ; ++ this_idx ) { sde = & dd -> per_sdma [ this_idx ] ; sde -> dd = dd ; sde -> ppd = ppd ; sde -> this_idx = this_idx ; sde -> descq_cnt = descq_cnt ; sde -> desc_avail = sdma_descq_freecnt ( sde ) ; sde -> sdma_shift = ilog2 ( descq_cnt ) ; sde -> sdma_mask = ( 1 << sde -> sdma_shift ) - 1 ; sde -> int_mask = ( u64 ) 1 << ( 0 * TXE_NUM_SDMA_ENGINES + this_idx ) ; sde -> progress_mask = ( u64 ) 1 << ( 1 * TXE_NUM_SDMA_ENGINES + this_idx ) ; sde -> idle_mask = ( u64 ) 1 << ( 2 * TXE_NUM_SDMA_ENGINES + this_idx ) ; sde -> imask = sde -> int_mask | sde -> progress_mask | sde -> idle_mask ; spin_lock_init ( & sde -> tail_lock ) ; seqlock_init ( & sde -> head_lock ) ; spin_lock_init ( & sde -> senddmactrl_lock ) ; spin_lock_init ( & sde -> flushlist_lock ) ; seqlock_init ( & sde -> waitlock ) ; sde -> ahg_bits = 0xfffffffe00000000ULL ; sdma_set_state ( sde , sdma_state_s00_hw_down ) ; kref_init ( & sde -> state . kref ) ; init_completion ( & sde -> state . comp ) ; INIT_LIST_HEAD ( & sde -> flushlist ) ; INIT_LIST_HEAD ( & sde -> dmawait ) ; sde -> tail_csr = get_kctxt_csr_addr ( dd , this_idx , SD ( TAIL ) ) ; tasklet_init ( & sde -> sdma_hw_clean_up_task , sdma_hw_clean_up_task , ( unsigned long ) sde ) ; tasklet_init ( & sde -> sdma_sw_clean_up_task , sdma_sw_clean_up_task , ( unsigned long ) sde ) ; INIT_WORK ( & sde -> err_halt_worker , sdma_err_halt_wait ) ; INIT_WORK ( & sde -> flush_worker , sdma_field_flush ) ; sde -> progress_check_head = 0 ; timer_setup ( & sde -> err_progress_check_timer , sdma_err_progress_check , 0 ) ; sde -> descq = dma_alloc_coherent ( & dd -> pcidev -> dev , descq_cnt * sizeof ( u64 [ 2 ] ) , & sde -> descq_phys , GFP_KERNEL ) ; if ( ! sde -> descq ) goto bail ; sde -> tx_ring = kvzalloc_node ( array_size ( descq_cnt , sizeof ( struct sdma_txreq * ) ) , GFP_KERNEL , dd -> node ) ; if ( ! sde -> tx_ring ) goto bail ; } dd -> sdma_heads_size = L1_CACHE_BYTES * num_engines ; dd -> sdma_heads_dma = dma_alloc_coherent ( & dd -> pcidev -> dev , dd -> sdma_heads_size , & dd -> sdma_heads_phys , GFP_KERNEL ) ; if ( ! dd -> sdma_heads_dma ) { dd_dev_err ( dd , ""failedtoallocateSendDMAheadmemory\\n"" ) ; goto bail ; } dd -> sdma_pad_dma = dma_alloc_coherent ( & dd -> pcidev -> dev , sizeof ( u32 ) , & dd -> sdma_pad_phys , GFP_KERNEL ) ; if ( ! dd -> sdma_pad_dma ) { dd_dev_err ( dd , ""failedtoallocateSendDMApadmemory\\n"" ) ; goto bail ; } curr_head = ( void * ) dd -> sdma_heads_dma ; for ( this_idx = 0 ; this_idx < num_engines ; ++ this_idx ) { unsigned long phys_offset ; sde = & dd -> per_sdma [ this_idx ] ; sde -> head_dma = curr_head ; curr_head += L1_CACHE_BYTES ; phys_offset = ( unsigned long ) sde -> head_dma - ( unsigned long ) dd -> sdma_heads_dma ; sde -> head_phys = dd -> sdma_heads_phys + phys_offset ; init_sdma_regs ( sde , per_sdma_credits , idle_cnt ) ; } dd -> flags |= HFI1_HAS_SEND_DMA ; dd -> flags |= idle_cnt ? HFI1_HAS_SDMA_TIMEOUT : 0 ; dd -> num_sdma = num_engines ; ret = sdma_map_init ( dd , port , ppd -> vls_operational , NULL ) ; if ( ret < 0 ) goto bail ; tmp_sdma_rht = kzalloc ( sizeof ( * tmp_sdma_rht ) , GFP_KERNEL ) ; if ( ! tmp_sdma_rht ) { ret = - ENOMEM ; goto bail ; } ret = rhashtable_init ( tmp_sdma_rht , & sdma_rht_params ) ; if ( ret < 0 ) goto bail ; dd -> sdma_rht = tmp_sdma_rht ; dd_dev_info ( dd , ""SDMAnum_sdma:%u\\n"" , dd -> num_sdma ) ; return 0 ; bail : sdma_clean ( dd , num_engines ) ; return ret ; } "," < 0 ) { kfree ( tmp_sdma_rht ) ; goto bail ; } ",torvalds@linux/34b3be18a04ecdc610aae4c48e5d1b799d8689f6,CVE-2019-19065,https://github.com/torvalds/linux/commit/34b3be18a04ecdc610aae4c48e5d1b799d8689f6,2019-11-18T06:15Z 608,CWE-416,"CWE-416 static int snd_seq_device_dev_free ( struct snd_device * device ) { struct snd_seq_device * dev = device -> device_data ; put_device ( & dev -> dev ) ; return 0 ; } "," -> device_data ; cancel_autoload_drivers ( ) ; ",torvalds@linux/fc27fe7e8deef2f37cba3f2be2d52b6ca5eb9d57,CVE-2017-16528,https://github.com/torvalds/linux/commit/fc27fe7e8deef2f37cba3f2be2d52b6ca5eb9d57,2017-11-04T01:29Z 609,CWE-362,"CWE-362 int mi_repair_parallel ( MI_CHECK * param , register MI_INFO * info , const char * name , int rep_quick ) { int got_error ; uint i , key , total_key_length , istep ; ulong rec_length ; ha_rows start_records ; my_off_t new_header_length , del ; File new_file ; MI_SORT_PARAM * sort_param = 0 ; MYISAM_SHARE * share = info -> s ; ulong * rec_per_key_part ; HA_KEYSEG * keyseg ; char llbuff [ 22 ] ; IO_CACHE new_data_cache ; IO_CACHE_SHARE io_share ; SORT_INFO sort_info ; ulonglong UNINIT_VAR ( key_map ) ; pthread_attr_t thr_attr ; ulong max_pack_reclength ; int error ; DBUG_ENTER ( ""mi_repair_parallel"" ) ; start_records = info -> state -> records ; got_error = 1 ; new_file = - 1 ; new_header_length = ( param -> testflag & T_UNPACK ) ? 0 : share -> pack . header_length ; if ( ! ( param -> testflag & T_SILENT ) ) { printf ( ""-parallelrecovering(withsort)MyISAM-table\'%s\'\\n"" , name ) ; printf ( ""Datarecords:%s\\n"" , llstr ( start_records , llbuff ) ) ; } param -> testflag |= T_REP ; if ( info -> s -> options & ( HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD ) ) param -> testflag |= T_CALC_CHECKSUM ; DBUG_PRINT ( ""info"" , ( ""isquickrepair:%d"" , rep_quick ) ) ; bzero ( ( char * ) & sort_info , sizeof ( sort_info ) ) ; mysql_mutex_init ( mi_key_mutex_MI_SORT_INFO_mutex , & sort_info . mutex , MY_MUTEX_INIT_FAST ) ; mysql_cond_init ( mi_key_cond_MI_SORT_INFO_cond , & sort_info . cond , 0 ) ; mysql_mutex_init ( mi_key_mutex_MI_CHECK_print_msg , & param -> print_msg_mutex , MY_MUTEX_INIT_FAST ) ; param -> need_print_msg_lock = 1 ; if ( ! ( sort_info . key_block = alloc_key_blocks ( param , ( uint ) param -> sort_key_blocks , share -> base . max_key_block_length ) ) || init_io_cache ( & param -> read_cache , info -> dfile , ( uint ) param -> read_buffer_length , READ_CACHE , share -> pack . header_length , 1 , MYF ( MY_WME ) ) || ( ! rep_quick && ( init_io_cache ( & info -> rec_cache , info -> dfile , ( uint ) param -> write_buffer_length , WRITE_CACHE , new_header_length , 1 , MYF ( MY_WME | MY_WAIT_IF_FULL ) & param -> myf_rw ) || init_io_cache ( & new_data_cache , - 1 , ( uint ) param -> write_buffer_length , READ_CACHE , new_header_length , 1 , MYF ( MY_WME | MY_DONT_CHECK_FILESIZE ) ) ) ) ) goto err ; sort_info . key_block_end = sort_info . key_block + param -> sort_key_blocks ; info -> opt_flag |= WRITE_CACHE_USED ; info -> rec_cache . file = info -> dfile ; if ( ! rep_quick ) { if ( ( new_file = mysql_file_create ( mi_key_file_datatmp , fn_format ( param -> temp_filename , share -> data_file_name , """" , DATA_TMP_EXT , 2 + 4 ) , 0 , param -> tmpfile_createflag , MYF ( 0 ) ) ) < 0 ) { mi_check_print_error ( param , ""Can\'tcreatenewtempfile:\'%s\'"" , param -> temp_filename ) ; goto err ; } if ( new_header_length && filecopy ( param , new_file , info -> dfile , 0L , new_header_length , ""datafile-header"" ) ) goto err ; if ( param -> testflag & T_UNPACK ) { share -> options &= ~ HA_OPTION_COMPRESS_RECORD ; mi_int2store ( share -> state . header . options , share -> options ) ; } share -> state . dellink = HA_OFFSET_ERROR ; info -> rec_cache . file = new_file ; } info -> update = ( short ) ( HA_STATE_CHANGED | HA_STATE_ROW_CHANGED ) ; mi_drop_all_indexes ( param , info , FALSE ) ; key_map = share -> state . key_map ; if ( param -> testflag & T_CREATE_MISSING_KEYS ) { key_map = ~ key_map ; } sort_info . info = info ; sort_info . param = param ; set_data_file_type ( & sort_info , share ) ; sort_info . dupp = 0 ; sort_info . buff = 0 ; param -> read_cache . end_of_file = sort_info . filelength = mysql_file_seek ( param -> read_cache . file , 0L , MY_SEEK_END , MYF ( 0 ) ) ; if ( share -> data_file_type == DYNAMIC_RECORD ) rec_length = max ( share -> base . min_pack_length + 1 , share -> base . min_block_length ) ; else if ( share -> data_file_type == COMPRESSED_RECORD ) rec_length = share -> base . min_block_length ; else rec_length = share -> base . pack_reclength ; sort_info . max_records = ( ( param -> testflag & T_CREATE_MISSING_KEYS ) ? info -> state -> records + 1 : ( ha_rows ) ( sort_info . filelength / rec_length + 1 ) ) ; del = info -> state -> del ; param -> glob_crc = 0 ; max_pack_reclength = share -> base . pack_reclength ; if ( share -> options & HA_OPTION_COMPRESS_RECORD ) set_if_bigger ( max_pack_reclength , share -> max_pack_length ) ; if ( ! ( sort_param = ( MI_SORT_PARAM * ) my_malloc ( ( uint ) share -> base . keys * ( sizeof ( MI_SORT_PARAM ) + max_pack_reclength ) , MYF ( MY_ZEROFILL ) ) ) ) { mi_check_print_error ( param , ""Notenoughmemoryforkey!"" ) ; goto err ; } total_key_length = 0 ; rec_per_key_part = param -> rec_per_key_part ; info -> state -> records = info -> state -> del = share -> state . split = 0 ; info -> state -> empty = 0 ; for ( i = key = 0 , istep = 1 ; key < share -> base . keys ; rec_per_key_part += sort_param [ i ] . keyinfo -> keysegs , i += istep , key ++ ) { sort_param [ i ] . key = key ; sort_param [ i ] . keyinfo = share -> keyinfo + key ; sort_param [ i ] . seg = sort_param [ i ] . keyinfo -> seg ; if ( ! mi_is_key_active ( key_map , key ) ) { memcpy ( ( char * ) rec_per_key_part , ( char * ) ( share -> state . rec_per_key_part + ( uint ) ( rec_per_key_part - param -> rec_per_key_part ) ) , sort_param [ i ] . keyinfo -> keysegs * sizeof ( * rec_per_key_part ) ) ; istep = 0 ; continue ; } istep = 1 ; if ( ( ! ( param -> testflag & T_SILENT ) ) ) printf ( ""-Fixingindex%d\\n"" , key + 1 ) ; if ( sort_param [ i ] . keyinfo -> flag & HA_FULLTEXT ) { sort_param [ i ] . key_read = sort_ft_key_read ; sort_param [ i ] . key_write = sort_ft_key_write ; } else { sort_param [ i ] . key_read = sort_key_read ; sort_param [ i ] . key_write = sort_key_write ; } sort_param [ i ] . key_cmp = sort_key_cmp ; sort_param [ i ] . lock_in_memory = lock_memory ; sort_param [ i ] . tmpdir = param -> tmpdir ; sort_param [ i ] . sort_info = & sort_info ; sort_param [ i ] . master = 0 ; sort_param [ i ] . fix_datafile = 0 ; sort_param [ i ] . calc_checksum = 0 ; sort_param [ i ] . filepos = new_header_length ; sort_param [ i ] . max_pos = sort_param [ i ] . pos = share -> pack . header_length ; sort_param [ i ] . record = ( ( ( uchar * ) ( sort_param + share -> base . keys ) ) + ( max_pack_reclength * i ) ) ; if ( ! mi_alloc_rec_buff ( info , - 1 , & sort_param [ i ] . rec_buff ) ) { mi_check_print_error ( param , ""Notenoughmemory!"" ) ; goto err ; } sort_param [ i ] . key_length = share -> rec_reflength ; for ( keyseg = sort_param [ i ] . seg ; keyseg -> type != HA_KEYTYPE_END ; keyseg ++ ) { sort_param [ i ] . key_length += keyseg -> length ; if ( keyseg -> flag & HA_SPACE_PACK ) sort_param [ i ] . key_length += get_pack_length ( keyseg -> length ) ; if ( keyseg -> flag & ( HA_BLOB_PART | HA_VAR_LENGTH_PART ) ) sort_param [ i ] . key_length += 2 + test ( keyseg -> length >= 127 ) ; if ( keyseg -> flag & HA_NULL_PART ) sort_param [ i ] . key_length ++ ; } total_key_length += sort_param [ i ] . key_length ; if ( sort_param [ i ] . keyinfo -> flag & HA_FULLTEXT ) { uint ft_max_word_len_for_sort = FT_MAX_WORD_LEN_FOR_SORT * sort_param [ i ] . keyinfo -> seg -> charset -> mbmaxlen ; sort_param [ i ] . key_length += ft_max_word_len_for_sort - HA_FT_MAXBYTELEN ; init_alloc_root ( & sort_param [ i ] . wordroot , FTPARSER_MEMROOT_ALLOC_SIZE , 0 ) ; } } sort_info . total_keys = i ; sort_param [ 0 ] . master = 1 ; sort_param [ 0 ] . fix_datafile = ( my_bool ) ( ! rep_quick ) ; sort_param [ 0 ] . calc_checksum = test ( param -> testflag & T_CALC_CHECKSUM ) ; if ( ! ftparser_alloc_param ( info ) ) goto err ; sort_info . got_error = 0 ; mysql_mutex_lock ( & sort_info . mutex ) ; if ( i > 1 ) { if ( rep_quick ) init_io_cache_share ( & param -> read_cache , & io_share , NULL , i ) ; else init_io_cache_share ( & new_data_cache , & io_share , & info -> rec_cache , i ) ; } else io_share . total_threads = 0 ; ( void ) pthread_attr_init ( & thr_attr ) ; ( void ) pthread_attr_setdetachstate ( & thr_attr , PTHREAD_CREATE_DETACHED ) ; for ( i = 0 ; i < sort_info . total_keys ; i ++ ) { sort_param [ i ] . read_cache = ( ( rep_quick || ! i ) ? param -> read_cache : new_data_cache ) ; DBUG_PRINT ( ""io_cache_share"" , ( ""thread:%uread_cache:0x%lx"" , i , ( long ) & sort_param [ i ] . read_cache ) ) ; sort_param [ i ] . sortbuff_size = # ifndef USING_SECOND_APPROACH param -> sort_buffer_length / sort_info . total_keys ; # else param -> sort_buffer_length * sort_param [ i ] . key_length / total_key_length ; # endif if ( ( error = mysql_thread_create ( mi_key_thread_find_all_keys , & sort_param [ i ] . thr , & thr_attr , thr_find_all_keys , ( void * ) ( sort_param + i ) ) ) ) { mi_check_print_error ( param , ""Cannotstartarepairthread(errno=%d)"" , error ) ; if ( io_share . total_threads ) remove_io_thread ( & sort_param [ i ] . read_cache ) ; DBUG_PRINT ( ""error"" , ( ""Cannotstartarepairthread"" ) ) ; sort_info . got_error = 1 ; } else sort_info . threads_running ++ ; } ( void ) pthread_attr_destroy ( & thr_attr ) ; while ( sort_info . threads_running ) mysql_cond_wait ( & sort_info . cond , & sort_info . mutex ) ; mysql_mutex_unlock ( & sort_info . mutex ) ; if ( ( got_error = thr_write_keys ( sort_param ) ) ) { param -> retry_repair = 1 ; goto err ; } got_error = 1 ; if ( sort_param [ 0 ] . fix_datafile ) { if ( write_data_suffix ( & sort_info , 1 ) || end_io_cache ( & info -> rec_cache ) ) goto err ; if ( param -> testflag & T_SAFE_REPAIR ) { if ( info -> state -> records + 1 < start_records ) { info -> state -> records = start_records ; goto err ; } } share -> state . state . data_file_length = info -> state -> data_file_length = sort_param -> filepos ; share -> state . version = ( ulong ) time ( ( time_t * ) 0 ) ; mysql_file_close ( info -> dfile , MYF ( 0 ) ) ; info -> dfile = new_file ; share -> data_file_type = sort_info . new_data_file_type ; share -> pack . header_length = ( ulong ) new_header_length ; } else info -> state -> data_file_length = sort_param -> max_pos ; if ( rep_quick && del + sort_info . dupp != info -> state -> del ) { mi_check_print_error ( param , ""Couldn\'tfixtablewithquickrecovery:Foundwrongnumberofdeletedrecords"" ) ; mi_check_print_error ( param , ""Runrecoveryagainwithout-q"" ) ; param -> retry_repair = 1 ; param -> testflag |= T_RETRY_WITHOUT_QUICK ; goto err ; } if ( rep_quick & T_FORCE_UNIQUENESS ) { my_off_t skr = info -> state -> data_file_length + ( share -> options & HA_OPTION_COMPRESS_RECORD ? MEMMAP_EXTRA_MARGIN : 0 ) ; # ifdef USE_RELOC if ( share -> data_file_type == STATIC_RECORD && skr < share -> base . reloc * share -> base . min_pack_length ) skr = share -> base . reloc * share -> base . min_pack_length ; # endif if ( skr != sort_info . filelength ) if ( mysql_file_chsize ( info -> dfile , skr , 0 , MYF ( 0 ) ) ) mi_check_print_warning ( param , ""Can\'tchangesizeofdatafile,error:%d"" , my_errno ) ; } if ( param -> testflag & T_CALC_CHECKSUM ) info -> state -> checksum = param -> glob_crc ; if ( mysql_file_chsize ( share -> kfile , info -> state -> key_file_length , 0 , MYF ( 0 ) ) ) mi_check_print_warning ( param , ""Can\'tchangesizeofindexfile,error:%d"" , my_errno ) ; if ( ! ( param -> testflag & T_SILENT ) ) { if ( start_records != info -> state -> records ) printf ( ""Datarecords:%s\\n"" , llstr ( info -> state -> records , llbuff ) ) ; if ( sort_info . dupp ) mi_check_print_warning ( param , ""%srecordshavebeenremoved"" , llstr ( sort_info . dupp , llbuff ) ) ; } got_error = 0 ; if ( & share -> state . state != info -> state ) memcpy ( & share -> state . state , info -> state , sizeof ( * info -> state ) ) ; err : got_error |= flush_blocks ( param , share -> key_cache , share -> kfile ) ; ( void ) end_io_cache ( & info -> rec_cache ) ; if ( ! rep_quick ) ( void ) end_io_cache ( & new_data_cache ) ; if ( ! got_error ) { if ( new_file >= 0 ) { mysql_file_close ( new_file , MYF ( 0 ) ) ; info -> dfile = new_file = - 1 ; if ( change_to_newfile ( share -> data_file_name , MI_NAME_DEXT , DATA_TMP_EXT , ( param -> testflag & T_BACKUP_DATA ? MYF ( MY_REDEL_MAKE_BACKUP ) : MYF ( 0 ) ) ) || mi_open_datafile ( info , share , name , - 1 ) ) got_error = 1 ; } } if ( got_error ) { if ( ! param -> error_printed ) mi_check_print_error ( param , ""%dwhenfixingtable"" , my_errno ) ; if ( new_file >= 0 ) { ( void ) mysql_file_close ( new_file , MYF ( 0 ) ) ; ( void ) mysql_file_delete ( mi_key_file_datatmp , param -> temp_filename , MYF ( MY_WME ) ) ; if ( info -> dfile == new_file ) if ( unlikely ( mi_open_datafile ( info , share , name , - 1 ) ) ) param -> retry_repair = 0 ; } mi_mark_crashed_on_repair ( info ) ; } else if ( key_map == share -> state . key_map ) share -> state . changed &= ~ STATE_NOT_OPTIMIZED_KEYS ; share -> state . changed |= STATE_NOT_SORTED_PAGES ; mysql_cond_destroy ( & sort_info . cond ) ; mysql_mutex_destroy ( & sort_info . mutex ) ; mysql_mutex_destroy ( & param -> print_msg_mutex ) ; param -> need_print_msg_lock = 0 ; my_free ( sort_info . ft_buf ) ; my_free ( sort_info . key_block ) ; my_free ( sort_param ) ; my_free ( sort_info . buff ) ; ( void ) end_io_cache ( & param -> read_cache ) ; info -> opt_flag &= ~ ( READ_CACHE_USED | WRITE_CACHE_USED ) ; if ( ! got_error && ( param -> testflag & T_UNPACK ) ) { share -> state . header . options [ 0 ] &= ( uchar ) ~ HA_OPTION_COMPRESS_RECORD ; share -> pack . header_length = 0 ; } DBUG_RETURN ( got_error ) ; } "," , int rep_quick , my_bool no_copy_stat 0 ) { myf flags = 0 ; if ( param -> testflag & T_BACKUP_DATA ) flags |= MY_REDEL_MAKE_BACKUP ; if ( no_copy_stat ) flags |= MY_REDEL_NO_COPY_STAT ; , DATA_TMP_EXT , flags ) || mi_open_datafile ",MariaDB@server/4e5473862e6852b0f3802b0cd0c6fa10b5253291,CVE-2016-6663,https://github.com/MariaDB/server/commit/4e5473862e6852b0f3802b0cd0c6fa10b5253291,2016-12-13T21:59Z 610,CWE-000,"CWE-000 Image * AutoResizeImage ( const Image * image , const char * option , MagickOffsetType * count , ExceptionInfo * exception ) { # define MAX_SIZES 16 char * q ; const char * p ; Image * resized , * images ; register ssize_t i ; size_t sizes [ MAX_SIZES ] = { 256 , 192 , 128 , 96 , 64 , 48 , 40 , 32 , 24 , 16 } ; images = NULL ; * count = 0 ; i = 0 ; p = option ; while ( * p != '\\0' && i < MAX_SIZES ) { size_t size ; while ( ( isspace ( ( int ) ( ( unsigned char ) * p ) ) != 0 ) ) p ++ ; size = ( size_t ) strtol ( p , & q , 10 ) ; if ( p == q || size < 16 || size > 256 ) return ( ( Image * ) NULL ) ; p = q ; sizes [ i ++ ] = size ; while ( ( isspace ( ( int ) ( ( unsigned char ) * p ) ) != 0 ) || ( * p == ',' ) ) p ++ ; } if ( i == 0 ) i = 10 ; * count = i ; for ( i = 0 ; i < * count ; i ++ ) { resized = ResizeImage ( image , sizes [ i ] , sizes [ i ] , image -> filter , exception ) ; if ( resized == ( Image * ) NULL ) return ( DestroyImageList ( images ) ) ; if ( images == ( Image * ) NULL ) images = resized ; else AppendImageToList ( & images , resized ) ; } return ( images ) ; } "," ; if ( ( p == q ) || ( size < 16 size < 16 ) || ( size > 256 size > 256 ) ",ImageMagick@ImageMagick/0f6fc2d5bf8f500820c3dbcf0d23ee14f2d9f734,CVE-2015-8896,https://github.com/ImageMagick/ImageMagick/commit/0f6fc2d5bf8f500820c3dbcf0d23ee14f2d9f734,2017-03-15T19:59Z 611,CWE-19,"CWE-19 STATIC int xfs_attr_calc_size ( struct xfs_inode * ip , int namelen , int valuelen , int * local ) { struct xfs_mount * mp = ip -> i_mount ; int size ; int nblks ; size = xfs_attr_leaf_newentsize ( namelen , valuelen , mp -> m_sb . sb_blocksize , local ) ; nblks = XFS_DAENTER_SPACE_RES ( mp , XFS_ATTR_FORK ) ; if ( * local ) { if ( size > ( mp -> m_sb . sb_blocksize >> 1 ) ) { nblks *= 2 ; } } else { uint dblocks = XFS_B_TO_FSB ( mp , valuelen ) ; nblks += dblocks ; nblks += XFS_NEXTENTADD_SPACE_RES ( mp , dblocks , XFS_ATTR_FORK ) ; } return nblks ; } "," uint dblocks = xfs_attr3_rmt_blocks ( mp , ",torvalds@linux/8275cdd0e7ac550dcce2b3ef6d2fb3b808c1ae59,CVE-2015-0274,https://github.com/torvalds/linux/commit/8275cdd0e7ac550dcce2b3ef6d2fb3b808c1ae59,2015-03-16T10:59Z 612,CWE-189,"CWE-189 Datum hstore_recv ( PG_FUNCTION_ARGS ) { int32 buflen ; HStore * out ; Pairs * pairs ; int32 i ; int32 pcount ; StringInfo buf = ( StringInfo ) PG_GETARG_POINTER ( 0 ) ; pcount = pq_getmsgint ( buf , 4 ) ; if ( pcount == 0 ) { out = hstorePairs ( NULL , 0 , 0 ) ; PG_RETURN_POINTER ( out ) ; } pairs = palloc ( pcount * sizeof ( Pairs ) ) ; for ( i = 0 ; i < pcount ; ++ i ) { int rawlen = pq_getmsgint ( buf , 4 ) ; int len ; if ( rawlen < 0 ) ereport ( ERROR , ( errcode ( ERRCODE_NULL_VALUE_NOT_ALLOWED ) , errmsg ( ""nullvaluenotallowedforhstorekey"" ) ) ) ; pairs [ i ] . key = pq_getmsgtext ( buf , rawlen , & len ) ; pairs [ i ] . keylen = hstoreCheckKeyLen ( len ) ; pairs [ i ] . needfree = true ; rawlen = pq_getmsgint ( buf , 4 ) ; if ( rawlen < 0 ) { pairs [ i ] . val = NULL ; pairs [ i ] . vallen = 0 ; pairs [ i ] . isnull = true ; } else { pairs [ i ] . val = pq_getmsgtext ( buf , rawlen , & len ) ; pairs [ i ] . vallen = hstoreCheckValLen ( len ) ; pairs [ i ] . isnull = false ; } } pcount = hstoreUniquePairs ( pairs , pcount , & buflen ) ; out = hstorePairs ( pairs , pcount , buflen ) ; PG_RETURN_POINTER ( out ) ; } "," ) ; } if ( pcount < 0 || pcount > MaxAllocSize / sizeof ( Pairs ) ) ereport ( ERROR , ( errcode ( ERRCODE_PROGRAM_LIMIT_EXCEEDED ) , errmsg ( ""numberofpairs(%d)exceedsthemaximumallowed(%d)"" , pcount , ( int ) ( MaxAllocSize / sizeof ( Pairs ) ) ) ) ) ; ",postgres@postgres/31400a673325147e1205326008e32135a78b4d8a,CVE-2014-2669,https://github.com/postgres/postgres/commit/31400a673325147e1205326008e32135a78b4d8a,2014-03-31T14:58Z 613,CWE-476,"CWE-476 static void parserule ( struct scanner * s , struct environment * env ) { struct rule * r ; char * var ; struct evalstring * val ; bool hascommand = false , hasrspfile = false , hasrspcontent = false ; r = mkrule ( scanname ( s ) ) ; scannewline ( s ) ; while ( scanindent ( s ) ) { var = scanname ( s ) ; parselet ( s , & val ) ; ruleaddvar ( r , var , val ) ; if ( strcmp ( var , ""command"" ) == 0 ) hascommand = true ; else if ( strcmp ( var , ""rspfile"" ) == 0 ) hasrspfile = true ; else if ( strcmp ( var , ""rspfile_content"" ) == 0 ) hasrspcontent = true ; } if ( ! hascommand ) fatal ( ""rule\'%s\'hasnocommand"" , r -> name ) ; if ( hasrspfile != hasrspcontent ) fatal ( ""rule\'%s\'hasrspfileandnorspfile_contentorviceversa"" , r -> name ) ; envaddrule ( env , r ) ; } "," , val ) ; if ( ! val ) continue ",michaelforney@samurai/d2af3bc375e2a77139c3a28d6128c60cd8d08655,CVE-2021-30219,https://github.com/michaelforney/samurai/commit/d2af3bc375e2a77139c3a28d6128c60cd8d08655,2021-04-29T15:15Z 614,CWE-476,"CWE-476 int read_escaped_char ( yyscan_t yyscanner , uint8_t * escaped_char ) { char text [ 4 ] = { 0 , 0 , 0 , 0 } ; text [ 0 ] = '\\\\' ; text [ 1 ] = RE_YY_INPUT ( yyscanner ) ; if ( text [ 1 ] == EOF ) return 0 ; if ( text [ 1 ] == 'x' ) { text [ 2 ] = RE_YY_INPUT ( yyscanner ) ; if ( text [ 2 ] == EOF ) return 0 ; text [ 3 ] = RE_YY_INPUT ( yyscanner ) ; if ( text [ 3 ] == EOF ) return 0 ; } * escaped_char = escaped_char_value ( text ) ; return 1 ; } "," ] == EOF || text [ 1 ] == 0 ; if ( ! isxdigit ( [ 2 ] ) ) return 0 ; if ( ! isxdigit ( [ 3 ] ) ) return 0 ",VirusTotal@yara/3119b232c9c453c98d8fa8b6ae4e37ba18117cd4,CVE-2016-10210,https://github.com/VirusTotal/yara/commit/3119b232c9c453c98d8fa8b6ae4e37ba18117cd4,2017-04-03T05:59Z 615,CWE-444,"CWE-444 static HeadReturn con_header_read ( agooCon c , size_t * mlenp ) { char * hend = strstr ( c -> buf , ""\\r\\n\\r\\n"" ) ; agooMethod method ; struct _agooSeg path ; char * query = NULL ; char * qend ; char * b ; size_t clen = 0 ; long mlen ; agooHook hook = NULL ; agooPage p ; struct _agooErr err = AGOO_ERR_INIT ; if ( NULL == hend ) { if ( sizeof ( c -> buf ) - 1 <= c -> bcnt ) { return bad_request ( c , 431 , __LINE__ ) ; } return HEAD_AGAIN ; } if ( agoo_req_cat . on ) { * hend = '\\0' ; agoo_log_cat ( & agoo_req_cat , ""%s%llu:%s"" , agoo_con_kind_str ( c -> bind -> kind ) , ( unsigned long long ) c -> id , c -> buf ) ; * hend = '\\r' ; } for ( b = c -> buf ; '' != * b ; b ++ ) { if ( '\\0' == * b ) { return bad_request ( c , 400 , __LINE__ ) ; } } switch ( toupper ( * c -> buf ) ) { case 'G' : if ( 3 != b - c -> buf || 0 != strncmp ( ""GET"" , c -> buf , 3 ) ) { return bad_request ( c , 400 , __LINE__ ) ; } method = AGOO_GET ; break ; case 'P' : { const char * v ; int vlen = 0 ; char * vend ; if ( 3 == b - c -> buf && 0 == strncmp ( ""PUT"" , c -> buf , 3 ) ) { method = AGOO_PUT ; } else if ( 4 == b - c -> buf && 0 == strncmp ( ""POST"" , c -> buf , 4 ) ) { method = AGOO_POST ; } else { return bad_request ( c , 400 , __LINE__ ) ; } if ( NULL == ( v = agoo_con_header_value ( c -> buf , ( int ) ( hend - c -> buf ) , ""Content-Length"" , & vlen ) ) ) { return bad_request ( c , 411 , __LINE__ ) ; } clen = ( size_t ) strtoul ( v , & vend , 10 ) ; if ( vend != v + vlen ) { return bad_request ( c , 411 , __LINE__ ) ; } break ; } case 'D' : if ( 6 != b - c -> buf || 0 != strncmp ( ""DELETE"" , c -> buf , 6 ) ) { return bad_request ( c , 400 , __LINE__ ) ; } method = AGOO_DELETE ; break ; case 'H' : if ( 4 != b - c -> buf || 0 != strncmp ( ""HEAD"" , c -> buf , 4 ) ) { return bad_request ( c , 400 , __LINE__ ) ; } method = AGOO_HEAD ; break ; case 'O' : if ( 7 != b - c -> buf || 0 != strncmp ( ""OPTIONS"" , c -> buf , 7 ) ) { return bad_request ( c , 400 , __LINE__ ) ; } method = AGOO_OPTIONS ; break ; case 'C' : if ( 7 != b - c -> buf || 0 != strncmp ( ""CONNECT"" , c -> buf , 7 ) ) { return bad_request ( c , 400 , __LINE__ ) ; } method = AGOO_CONNECT ; break ; default : return bad_request ( c , 400 , __LINE__ ) ; } for ( ; '' == * b ; b ++ ) { if ( '\\0' == * b ) { return bad_request ( c , 400 , __LINE__ ) ; } } path . start = b ; for ( ; '' != * b ; b ++ ) { switch ( * b ) { case '?' : path . end = b ; query = b + 1 ; break ; case '\\0' : return bad_request ( c , 400 , __LINE__ ) ; default : break ; } } if ( NULL == query ) { path . end = b ; query = b ; qend = b ; } else { qend = b ; } mlen = hend - c -> buf + 4 + clen ; * mlenp = mlen ; if ( AGOO_GET == method ) { char root_buf [ 20148 ] ; const char * root = NULL ; if ( NULL != ( p = agoo_group_get ( & err , path . start , ( int ) ( path . end - path . start ) ) ) ) { if ( page_response ( c , p , hend ) ) { return bad_request ( c , 500 , __LINE__ ) ; } return HEAD_HANDLED ; } if ( agoo_domain_use ( ) ) { const char * host ; int vlen = 0 ; if ( NULL == ( host = agoo_con_header_value ( c -> buf , ( int ) ( hend - c -> buf ) , ""Host"" , & vlen ) ) ) { return bad_request ( c , 411 , __LINE__ ) ; } ( ( char * ) host ) [ vlen ] = '\\0' ; root = agoo_domain_resolve ( host , root_buf , sizeof ( root_buf ) ) ; ( ( char * ) host ) [ vlen ] = '\\r' ; } if ( agoo_server . root_first && NULL != ( p = agoo_page_get ( & err , path . start , ( int ) ( path . end - path . start ) , root ) ) ) { if ( page_response ( c , p , hend ) ) { return bad_request ( c , 500 , __LINE__ ) ; } return HEAD_HANDLED ; } if ( NULL == ( hook = agoo_hook_find ( agoo_server . hooks , method , & path ) ) ) { if ( NULL != ( p = agoo_page_get ( & err , path . start , ( int ) ( path . end - path . start ) , root ) ) ) { if ( page_response ( c , p , hend ) ) { return bad_request ( c , 500 , __LINE__ ) ; } return HEAD_HANDLED ; } if ( NULL == agoo_server . hook404 ) { return bad_request ( c , 404 , __LINE__ ) ; } hook = agoo_server . hook404 ; } } else if ( NULL == ( hook = agoo_hook_find ( agoo_server . hooks , method , & path ) ) ) { return bad_request ( c , 404 , __LINE__ ) ; } if ( NULL == ( c -> req = agoo_req_create ( mlen ) ) ) { return bad_request ( c , 413 , __LINE__ ) ; } if ( ( long ) c -> bcnt <= mlen ) { memcpy ( c -> req -> msg , c -> buf , c -> bcnt ) ; if ( ( long ) c -> bcnt < mlen ) { memset ( c -> req -> msg + c -> bcnt , 0 , mlen - c -> bcnt ) ; } } else { memcpy ( c -> req -> msg , c -> buf , mlen ) ; } c -> req -> msg [ mlen ] = '\\0' ; c -> req -> method = method ; c -> req -> upgrade = AGOO_UP_NONE ; c -> req -> up = NULL ; c -> req -> path . start = c -> req -> msg + ( path . start - c -> buf ) ; c -> req -> path . len = ( int ) ( path . end - path . start ) ; c -> req -> query . start = c -> req -> msg + ( query - c -> buf ) ; c -> req -> query . len = ( int ) ( qend - query ) ; c -> req -> query . start [ c -> req -> query . len ] = '\\0' ; c -> req -> body . start = c -> req -> msg + ( hend - c -> buf + 4 ) ; c -> req -> body . len = ( unsigned int ) clen ; b = strstr ( b , ""\\r\\n"" ) ; c -> req -> header . start = c -> req -> msg + ( b + 2 - c -> buf ) ; if ( b < hend ) { c -> req -> header . len = ( unsigned int ) ( hend - b - 2 ) ; } else { c -> req -> header . len = 0 ; } c -> req -> res = NULL ; c -> req -> hook = hook ; return HEAD_OK ; } "," = NULL ; memcpy ( c -> req -> remote , c -> remote , sizeof ( c -> remote ) ) ; ",ohler55@agoo/23d03535cf7b50d679a60a953a0cae9519a4a130,CVE-2020-7670,https://github.com/ohler55/agoo/commit/23d03535cf7b50d679a60a953a0cae9519a4a130,2020-06-10T16:15Z 616,CWE-119,"CWE-119 void vp9_fht16x16_c ( const int16_t * input , int16_t * output , int stride , int tx_type ) { if ( tx_type == DCT_DCT ) { vp9_fdct16x16_c ( input , output , stride ) ; } else { int16_t out [ 256 ] ; int16_t * outptr = & out [ 0 ] ; int i , j ; int16_t temp_in [ 16 ] , temp_out [ 16 ] ; const transform_2d ht = FHT_16 [ tx_type ] ; for ( i = 0 ; i < 16 ; ++ i ) { for ( j = 0 ; j < 16 ; ++ j ) temp_in [ j ] = input [ j * stride + i ] * 4 ; ht . cols ( temp_in , temp_out ) ; for ( j = 0 ; j < 16 ; ++ j ) outptr [ j * 16 + i ] = ( temp_out [ j ] + 1 + ( temp_out [ j ] < 0 ) ) >> 2 ; } for ( i = 0 ; i < 16 ; ++ i ) { for ( j = 0 ; j < 16 ; ++ j ) temp_in [ j ] = out [ j + i * 16 ] ; ht . rows ( temp_in , temp_out ) ; for ( j = 0 ; j < 16 ; ++ j ) output [ j + i * 16 ] = temp_out [ j ] ; } } } "," * input , tran_low_t * output , DCT_DCT ) { vpx_fdct16x16_c ( input , } else { tran_low_t out [ 256 256 ] ; int i , , j ; tran_low_t temp_in [ 16 ++ j ) out [ j * ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 617,CWE-74,"CWE-74 static gboolean export_desktop_file ( const char * app , const char * branch , const char * arch , GKeyFile * metadata , const char * const * previous_ids , int parent_fd , const char * name , struct stat * stat_buf , char * * target , GCancellable * cancellable , GError * * error ) { gboolean ret = FALSE ; glnx_autofd int desktop_fd = - 1 ; g_autofree char * tmpfile_name = g_strdup_printf ( ""export-desktop-XXXXXX"" ) ; g_autoptr ( GOutputStream ) out_stream = NULL ; g_autofree gchar * data = NULL ; gsize data_len ; g_autofree gchar * new_data = NULL ; gsize new_data_len ; g_autoptr ( GKeyFile ) keyfile = NULL ; g_autofree gchar * old_exec = NULL ; gint old_argc ; g_auto ( GStrv ) old_argv = NULL ; g_auto ( GStrv ) groups = NULL ; GString * new_exec = NULL ; g_autofree char * escaped_app = maybe_quote ( app ) ; g_autofree char * escaped_branch = maybe_quote ( branch ) ; g_autofree char * escaped_arch = maybe_quote ( arch ) ; int i ; if ( ! flatpak_openat_noatime ( parent_fd , name , & desktop_fd , cancellable , error ) ) goto out ; if ( ! read_fd ( desktop_fd , stat_buf , & data , & data_len , error ) ) goto out ; keyfile = g_key_file_new ( ) ; if ( ! g_key_file_load_from_data ( keyfile , data , data_len , G_KEY_FILE_KEEP_TRANSLATIONS , error ) ) goto out ; if ( g_str_has_suffix ( name , "".service"" ) ) { g_autofree gchar * dbus_name = NULL ; g_autofree gchar * expected_dbus_name = g_strndup ( name , strlen ( name ) - strlen ( "".service"" ) ) ; dbus_name = g_key_file_get_string ( keyfile , ""D-BUSService"" , ""Name"" , NULL ) ; if ( dbus_name == NULL || strcmp ( dbus_name , expected_dbus_name ) != 0 ) { return flatpak_fail_error ( error , FLATPAK_ERROR_EXPORT_FAILED , _ ( ""D-Busservicefile\'%s\'haswrongname"" ) , name ) ; } } if ( g_str_has_suffix ( name , "".desktop"" ) ) { gsize length ; g_auto ( GStrv ) tags = g_key_file_get_string_list ( metadata , ""Application"" , ""tags"" , & length , NULL ) ; if ( tags != NULL ) { g_key_file_set_string_list ( keyfile , G_KEY_FILE_DESKTOP_GROUP , ""X-Flatpak-Tags"" , ( const char * const * ) tags , length ) ; } g_key_file_set_string ( keyfile , G_KEY_FILE_DESKTOP_GROUP , ""X-Flatpak"" , app ) ; if ( previous_ids != NULL ) { const char * X_FLATPAK_RENAMED_FROM = ""X-Flatpak-RenamedFrom"" ; g_auto ( GStrv ) renamed_from = g_key_file_get_string_list ( keyfile , G_KEY_FILE_DESKTOP_GROUP , X_FLATPAK_RENAMED_FROM , NULL , NULL ) ; g_autoptr ( GPtrArray ) merged = g_ptr_array_new_with_free_func ( g_free ) ; g_autoptr ( GHashTable ) seen = g_hash_table_new ( g_str_hash , g_str_equal ) ; const char * new_suffix ; for ( i = 0 ; renamed_from != NULL && renamed_from [ i ] != NULL ; i ++ ) { if ( ! g_hash_table_contains ( seen , renamed_from [ i ] ) ) { gchar * copy = g_strdup ( renamed_from [ i ] ) ; g_hash_table_insert ( seen , copy , copy ) ; g_ptr_array_add ( merged , g_steal_pointer ( & copy ) ) ; } } g_assert ( g_str_has_prefix ( name , app ) ) ; new_suffix = name + strlen ( app ) ; for ( i = 0 ; previous_ids [ i ] != NULL ; i ++ ) { g_autofree gchar * previous_desktop = g_strconcat ( previous_ids [ i ] , new_suffix , NULL ) ; if ( ! g_hash_table_contains ( seen , previous_desktop ) ) { g_hash_table_insert ( seen , previous_desktop , previous_desktop ) ; g_ptr_array_add ( merged , g_steal_pointer ( & previous_desktop ) ) ; } } if ( merged -> len > 0 ) { g_ptr_array_add ( merged , NULL ) ; g_key_file_set_string_list ( keyfile , G_KEY_FILE_DESKTOP_GROUP , X_FLATPAK_RENAMED_FROM , ( const char * const * ) merged -> pdata , merged -> len - 1 ) ; } } } groups = g_key_file_get_groups ( keyfile , NULL ) ; for ( i = 0 ; groups [ i ] != NULL ; i ++ ) { g_auto ( GStrv ) flatpak_run_opts = g_key_file_get_string_list ( keyfile , groups [ i ] , ""X-Flatpak-RunOptions"" , NULL , NULL ) ; g_autofree char * flatpak_run_args = format_flatpak_run_args_from_run_opts ( flatpak_run_opts ) ; g_key_file_remove_key ( keyfile , groups [ i ] , ""X-Flatpak-RunOptions"" , NULL ) ; g_key_file_remove_key ( keyfile , groups [ i ] , ""TryExec"" , NULL ) ; g_key_file_remove_key ( keyfile , groups [ i ] , ""X-GNOME-Bugzilla-ExtraInfoScript"" , NULL ) ; new_exec = g_string_new ( """" ) ; g_string_append_printf ( new_exec , FLATPAK_BINDIR ""/flatpakrun--branch=%s--arch=%s"" , escaped_branch , escaped_arch ) ; if ( flatpak_run_args != NULL ) g_string_append_printf ( new_exec , ""%s"" , flatpak_run_args ) ; old_exec = g_key_file_get_string ( keyfile , groups [ i ] , ""Exec"" , NULL ) ; if ( old_exec && g_shell_parse_argv ( old_exec , & old_argc , & old_argv , NULL ) && old_argc >= 1 ) { int j ; g_autofree char * command = maybe_quote ( old_argv [ 0 ] ) ; g_string_append_printf ( new_exec , ""--command=%s"" , command ) ; for ( j = 1 ; j < old_argc ; j ++ ) { if ( strcasecmp ( old_argv [ j ] , ""%f"" ) == 0 || strcasecmp ( old_argv [ j ] , ""%u"" ) == 0 ) { g_string_append ( new_exec , ""--file-forwarding"" ) ; break ; } } g_string_append ( new_exec , """" ) ; g_string_append ( new_exec , escaped_app ) ; for ( j = 1 ; j < old_argc ; j ++ ) { g_autofree char * arg = maybe_quote ( old_argv [ j ] ) ; if ( strcasecmp ( arg , ""%f"" ) == 0 ) g_string_append_printf ( new_exec , ""@@%s@@"" , arg ) ; else if ( strcasecmp ( arg , ""%u"" ) == 0 ) g_string_append_printf ( new_exec , ""@@u%s@@"" , arg ) ; else if ( g_str_has_prefix ( arg , ""@@"" ) ) g_print ( _ ( ""SkippinginvalidExecargument%s\\n"" ) , arg ) ; else g_string_append_printf ( new_exec , ""%s"" , arg ) ; } } else { g_string_append ( new_exec , """" ) ; g_string_append ( new_exec , escaped_app ) ; } g_key_file_set_string ( keyfile , groups [ i ] , G_KEY_FILE_DESKTOP_KEY_EXEC , new_exec -> str ) ; } new_data = g_key_file_to_data ( keyfile , & new_data_len , error ) ; if ( new_data == NULL ) goto out ; if ( ! flatpak_open_in_tmpdir_at ( parent_fd , 0755 , tmpfile_name , & out_stream , cancellable , error ) ) goto out ; if ( ! g_output_stream_write_all ( out_stream , new_data , new_data_len , NULL , cancellable , error ) ) goto out ; if ( ! g_output_stream_close ( out_stream , cancellable , error ) ) goto out ; if ( target ) * target = g_steal_pointer ( & tmpfile_name ) ; ret = TRUE ; out : if ( new_exec != NULL ) g_string_free ( new_exec , TRUE ) ; return ret ; } "," ""@@"" ) ) { flatpak_fail_error ( error , FLATPAK_ERROR_EXPORT_FAILED , _ ( ""InvalidExecargument%s"" ) , arg arg ) ; goto out ; } ",flatpak@flatpak/a7401e638bf0c03102039e216ab1081922f140ae,CVE-2021-21381,https://github.com/flatpak/flatpak/commit/a7401e638bf0c03102039e216ab1081922f140ae,2021-03-11T17:15Z 618,CWE-284,"CWE-284 static __be32 nfsd3_proc_setacl ( struct svc_rqst * rqstp , struct nfsd3_setaclargs * argp , struct nfsd3_attrstat * resp ) { struct inode * inode ; svc_fh * fh ; __be32 nfserr = 0 ; int error ; fh = fh_copy ( & resp -> fh , & argp -> fh ) ; nfserr = fh_verify ( rqstp , & resp -> fh , 0 , NFSD_MAY_SATTR ) ; if ( nfserr ) goto out ; inode = d_inode ( fh -> fh_dentry ) ; if ( ! IS_POSIXACL ( inode ) || ! inode -> i_op -> set_acl ) { error = - EOPNOTSUPP ; goto out_errno ; } error = fh_want_write ( fh ) ; if ( error ) goto out_errno ; error = inode -> i_op -> set_acl ( inode , argp -> acl_access , ACL_TYPE_ACCESS ) ; if ( error ) goto out_drop_write ; error = inode -> i_op -> set_acl ( inode , argp -> acl_default , ACL_TYPE_DEFAULT ) ; out_drop_write : fh_drop_write ( fh ) ; out_errno : nfserr = nfserrno ( error ) ; out : posix_acl_release ( argp -> acl_access ) ; posix_acl_release ( argp -> acl_default ) ; RETURN_STATUS ( nfserr ) ; } "," fh_dentry ) ; error = fh_want_write ( fh ) ; if ( error ) goto out_errno ; goto out_errno ; fh_lock ( fh ) ; error = set_posix_acl ( inode , ACL_TYPE_ACCESS , argp -> acl_access ) ; if error ) goto out_drop_lock ; error = set_posix_acl ( inode , ACL_TYPE_DEFAULT , argp -> argp -> acl_default ) ; out_drop_lock : fh_unlock ( fh ) ; fh_drop_write ( fh ",torvalds@linux/999653786df6954a31044528ac3f7a5dadca08f4,CVE-2016-1237,https://github.com/torvalds/linux/commit/999653786df6954a31044528ac3f7a5dadca08f4,2016-06-29T14:10Z 619,CWE-125,"CWE-125 size_t compile_tree ( struct filter_op * * fop ) { int i = 1 ; struct filter_op * array = NULL ; struct unfold_elm * ue ; BUG_IF ( tree_root == NULL ) ; fprintf ( stdout , ""Unfoldingthemeta-tree"" ) ; fflush ( stdout ) ; unfold_blk ( & tree_root ) ; fprintf ( stdout , ""done.\\n\\n"" ) ; labels_to_offsets ( ) ; TAILQ_FOREACH ( ue , & unfolded_tree , next ) { if ( ue -> label == 0 ) { SAFE_REALLOC ( array , i * sizeof ( struct filter_op ) ) ; memcpy ( & array [ i - 1 ] , & ue -> fop , sizeof ( struct filter_op ) ) ; i ++ ; } } SAFE_REALLOC ( array , i * sizeof ( struct filter_op ) ) ; array [ i - 1 ] . opcode = FOP_EXIT ; * fop = array ; return ( i ) ; } "," * ue ; if ( tree_root == == NULL ) return 0 ",LocutusOfBorg@ettercap/626dc56686f15f2dda13c48f78c2a666cb6d8506,CVE-2017-6430,https://github.com/LocutusOfBorg/ettercap/commit/626dc56686f15f2dda13c48f78c2a666cb6d8506,2017-03-15T15:59Z 620,CWE-284,"CWE-284 bool config_save ( const config_t * config , const char * filename ) { assert ( config != NULL ) ; assert ( filename != NULL ) ; assert ( * filename != '\\0' ) ; char * temp_filename = osi_calloc ( strlen ( filename ) + 5 ) ; if ( ! temp_filename ) { LOG_ERROR ( ""%sunabletoallocatememoryforfilename."" , __func__ ) ; return false ; } strcpy ( temp_filename , filename ) ; strcat ( temp_filename , "".new"" ) ; FILE * fp = fopen ( temp_filename , ""wt"" ) ; if ( ! fp ) { LOG_ERROR ( ""%sunabletowritefile\'%s\':%s"" , __func__ , temp_filename , strerror ( errno ) ) ; goto error ; } for ( const list_node_t * node = list_begin ( config -> sections ) ; node != list_end ( config -> sections ) ; node = list_next ( node ) ) { const section_t * section = ( const section_t * ) list_node ( node ) ; fprintf ( fp , ""[%s]\\n"" , section -> name ) ; for ( const list_node_t * enode = list_begin ( section -> entries ) ; enode != list_end ( section -> entries ) ; enode = list_next ( enode ) ) { const entry_t * entry = ( const entry_t * ) list_node ( enode ) ; fprintf ( fp , ""%s=%s\\n"" , entry -> key , entry -> value ) ; } if ( list_next ( node ) != list_end ( config -> sections ) ) fputc ( '\\n' , fp ) ; } fflush ( fp ) ; fclose ( fp ) ; if ( chmod ( temp_filename , S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP ) == - 1 ) { LOG_ERROR ( ""%sunabletochangefilepermissions\'%s\':%s"" , __func__ , filename , strerror ( errno ) ) ; goto error ; } if ( rename ( temp_filename , filename ) == - 1 ) { LOG_ERROR ( ""%sunabletocommitfile\'%s\':%s"" , __func__ , filename , strerror ( errno ) ) ; goto error ; } osi_free ( temp_filename ) ; return true ; error : ; unlink ( temp_filename ) ; osi_free ( temp_filename ) ; return false ; } "," '\\0' ) ; int dir_fd = - 1 ; FILE * fp = NULL ; static const char * temp_file_ext = "".new"" ; const int filename_len = strlen ( filename ) ; const int temp_filename_len = filename_len + strlen ( temp_file_ext ) + 1 ; char * temp_filename = osi_calloc = osi_calloc ( temp_filename_len ) ; snprintf ( temp_filename , temp_filename_len , ""%s%s"" , filename , temp_file_ext ) ; char * temp_dirname = osi_strdup ( filename ) ; const char * directoryname = dirname ( temp_dirname ) ; if if ( ! directoryname ) { LOG_ERROR ( ""%serrorextractingdirectoryfrom\'%s\':%s"" , __func__ , filename , strerror ( errno ) ) ; goto error ; } dir_fd = TEMP_FAILURE_RETRY ( open ( directoryname , O_RDONLY ) ) ; if ( dir_fd < 0 ) { LOG_ERROR ( ""%sunabletoopendir\'%s\':%s"" , __func__ , directoryname , strerror ( errno ) ) ; goto error ; } fp = fopen node ) ; if ( -> name ) < 0 ) { LOG_ERROR ( ""%sunabletowritetofile\'%s\':%s"" , __func__ , temp_filename , strerror ( errno ) ) ; goto error ; } for ( const enode ) ; if ( -> value ) < 0 ) { LOG_ERROR ( ""%sunabletowritetofile\'%s\':%s"" , __func__ , temp_filename , strerror ( errno ) ) ; goto error ; } } if ( sections ) ) { if ( , fp ) == EOF ) { LOG_ERROR ( ""%sunabletowritetofile\'%s\':%s"" , __func__ , temp_filename , strerror ( errno ) ) ; goto error ; } } } if ( fsync ( fileno ( fp ) ) < 0 ) { LOG_WARN ( ""%sunabletofsyncfile\'%s\':%s"" , __func__ , temp_filename , strerror ( errno ) ) ; } if ( fclose ( fp ( fp ) == EOF ) { LOG_ERROR ( ""%sunabletoclosefile\'%s\':%s"" , __func__ , temp_filename , strerror ( errno ) ) ; goto error ; } fp = NULL error ; } if ( fsync ( dir_fd ) < 0 ) { LOG_WARN ( ""%sunabletofsyncdir\'%s\':%s"" , __func__ , directoryname , strerror ( errno ) ) ; } if ( close ( dir_fd ) < 0 ) { LOG_ERROR ( ""%sunabletoclosedir\'%s\':%s"" , __func__ , directoryname , strerror ( errno ) ) ; goto error ; } osi_free ( temp_filename ) ; osi_free ( temp_dirname ; error : unlink ( temp_filename temp_filename ) ; if ( fp ) fclose ( fp ) ; if ( dir_fd != - 1 ) close ( dir_fd ) ; osi_free ( temp_filename ) ; osi_free ( temp_dirname ",system@bt/472271b153c5dc53c28beac55480a8d8434b2d5c,CVE-2016-3839,https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c,2016-08-05T20:59Z 621,CWE-000,"CWE-000 static int udf_pc_to_char ( struct super_block * sb , unsigned char * from , int fromlen , unsigned char * to , int tolen ) { struct pathComponent * pc ; int elen = 0 ; int comp_len ; unsigned char * p = to ; tolen -- ; while ( elen < fromlen ) { pc = ( struct pathComponent * ) ( from + elen ) ; switch ( pc -> componentType ) { case 1 : if ( pc -> lengthComponentIdent > 0 ) break ; case 2 : if ( tolen == 0 ) return - ENAMETOOLONG ; p = to ; * p ++ = '/' ; tolen -- ; break ; case 3 : if ( tolen < 3 ) return - ENAMETOOLONG ; memcpy ( p , ""../"" , 3 ) ; p += 3 ; tolen -= 3 ; break ; case 4 : if ( tolen < 2 ) return - ENAMETOOLONG ; memcpy ( p , ""./"" , 2 ) ; p += 2 ; tolen -= 2 ; break ; case 5 : comp_len = udf_get_filename ( sb , pc -> componentIdent , pc -> lengthComponentIdent , p , tolen ) ; p += comp_len ; tolen -= comp_len ; if ( tolen == 0 ) return - ENAMETOOLONG ; * p ++ = '/' ; tolen -- ; break ; } elen += sizeof ( struct pathComponent ) + pc -> lengthComponentIdent ; } if ( p > to + 1 ) p [ - 1 ] = '\\0' ; else p [ 0 ] = '\\0' ; return 0 ; } "," elen ) ; elen += sizeof ( struct pathComponent ) ; > 0 ) { elen += pc -> lengthComponentIdent ; break ; } case 2 : case 5 : elen += pc -> lengthComponentIdent ; if ( elen > fromlen ) return - EIO ; break ; } } if ( ",torvalds@linux/e237ec37ec154564f8690c5bd1795339955eeef9,CVE-2014-9730,https://github.com/torvalds/linux/commit/e237ec37ec154564f8690c5bd1795339955eeef9,2015-08-31T10:59Z 622,CWE-125,"CWE-125 void nfsreq_print_noaddr ( netdissect_options * ndo , register const u_char * bp , u_int length , register const u_char * bp2 ) { register const struct sunrpc_msg * rp ; register const uint32_t * dp ; nfs_type type ; int v3 ; uint32_t proc ; uint32_t access_flags ; struct nfsv3_sattr sa3 ; ND_PRINT ( ( ndo , ""%d"" , length ) ) ; nfserr = 0 ; rp = ( const struct sunrpc_msg * ) bp ; if ( ! xid_map_enter ( ndo , rp , bp2 ) ) goto trunc ; v3 = ( EXTRACT_32BITS ( & rp -> rm_call . cb_vers ) == NFS_VER3 ) ; proc = EXTRACT_32BITS ( & rp -> rm_call . cb_proc ) ; if ( ! v3 && proc < NFS_NPROCS ) proc = nfsv3_procid [ proc ] ; ND_PRINT ( ( ndo , ""%s"" , tok2str ( nfsproc_str , ""proc-%u"" , proc ) ) ) ; switch ( proc ) { case NFSPROC_GETATTR : case NFSPROC_SETATTR : case NFSPROC_READLINK : case NFSPROC_FSSTAT : case NFSPROC_FSINFO : case NFSPROC_PATHCONF : if ( ( dp = parsereq ( ndo , rp , length ) ) != NULL && parsefh ( ndo , dp , v3 ) != NULL ) return ; break ; case NFSPROC_LOOKUP : case NFSPROC_CREATE : case NFSPROC_MKDIR : case NFSPROC_REMOVE : case NFSPROC_RMDIR : if ( ( dp = parsereq ( ndo , rp , length ) ) != NULL && parsefhn ( ndo , dp , v3 ) != NULL ) return ; break ; case NFSPROC_ACCESS : if ( ( dp = parsereq ( ndo , rp , length ) ) != NULL && ( dp = parsefh ( ndo , dp , v3 ) ) != NULL ) { ND_TCHECK ( dp [ 0 ] ) ; access_flags = EXTRACT_32BITS ( & dp [ 0 ] ) ; if ( access_flags & ~ NFSV3ACCESS_FULL ) { ND_PRINT ( ( ndo , ""%04x"" , access_flags ) ) ; } else if ( ( access_flags & NFSV3ACCESS_FULL ) == NFSV3ACCESS_FULL ) { ND_PRINT ( ( ndo , ""NFS_ACCESS_FULL"" ) ) ; } else { char separator = '' ; if ( access_flags & NFSV3ACCESS_READ ) { ND_PRINT ( ( ndo , ""NFS_ACCESS_READ"" ) ) ; separator = '|' ; } if ( access_flags & NFSV3ACCESS_LOOKUP ) { ND_PRINT ( ( ndo , ""%cNFS_ACCESS_LOOKUP"" , separator ) ) ; separator = '|' ; } if ( access_flags & NFSV3ACCESS_MODIFY ) { ND_PRINT ( ( ndo , ""%cNFS_ACCESS_MODIFY"" , separator ) ) ; separator = '|' ; } if ( access_flags & NFSV3ACCESS_EXTEND ) { ND_PRINT ( ( ndo , ""%cNFS_ACCESS_EXTEND"" , separator ) ) ; separator = '|' ; } if ( access_flags & NFSV3ACCESS_DELETE ) { ND_PRINT ( ( ndo , ""%cNFS_ACCESS_DELETE"" , separator ) ) ; separator = '|' ; } if ( access_flags & NFSV3ACCESS_EXECUTE ) ND_PRINT ( ( ndo , ""%cNFS_ACCESS_EXECUTE"" , separator ) ) ; } return ; } break ; case NFSPROC_READ : if ( ( dp = parsereq ( ndo , rp , length ) ) != NULL && ( dp = parsefh ( ndo , dp , v3 ) ) != NULL ) { if ( v3 ) { ND_TCHECK ( dp [ 2 ] ) ; ND_PRINT ( ( ndo , ""%ubytes@%"" PRIu64 , EXTRACT_32BITS ( & dp [ 2 ] ) , EXTRACT_64BITS ( & dp [ 0 ] ) ) ) ; } else { ND_TCHECK ( dp [ 1 ] ) ; ND_PRINT ( ( ndo , ""%ubytes@%u"" , EXTRACT_32BITS ( & dp [ 1 ] ) , EXTRACT_32BITS ( & dp [ 0 ] ) ) ) ; } return ; } break ; case NFSPROC_WRITE : if ( ( dp = parsereq ( ndo , rp , length ) ) != NULL && ( dp = parsefh ( ndo , dp , v3 ) ) != NULL ) { if ( v3 ) { ND_TCHECK ( dp [ 2 ] ) ; ND_PRINT ( ( ndo , ""%u(%u)bytes@%"" PRIu64 , EXTRACT_32BITS ( & dp [ 4 ] ) , EXTRACT_32BITS ( & dp [ 2 ] ) , EXTRACT_64BITS ( & dp [ 0 ] ) ) ) ; if ( ndo -> ndo_vflag ) { dp += 3 ; ND_TCHECK ( dp [ 0 ] ) ; ND_PRINT ( ( ndo , ""<%s>"" , tok2str ( nfsv3_writemodes , NULL , EXTRACT_32BITS ( dp ) ) ) ) ; } } else { ND_TCHECK ( dp [ 3 ] ) ; ND_PRINT ( ( ndo , ""%u(%u)bytes@%u(%u)"" , EXTRACT_32BITS ( & dp [ 3 ] ) , EXTRACT_32BITS ( & dp [ 2 ] ) , EXTRACT_32BITS ( & dp [ 1 ] ) , EXTRACT_32BITS ( & dp [ 0 ] ) ) ) ; } return ; } break ; case NFSPROC_SYMLINK : if ( ( dp = parsereq ( ndo , rp , length ) ) != NULL && ( dp = parsefhn ( ndo , dp , v3 ) ) != NULL ) { ND_PRINT ( ( ndo , ""->"" ) ) ; if ( v3 && ( dp = parse_sattr3 ( ndo , dp , & sa3 ) ) == NULL ) break ; if ( parsefn ( ndo , dp ) == NULL ) break ; if ( v3 && ndo -> ndo_vflag ) print_sattr3 ( ndo , & sa3 , ndo -> ndo_vflag ) ; return ; } break ; case NFSPROC_MKNOD : if ( ( dp = parsereq ( ndo , rp , length ) ) != NULL && ( dp = parsefhn ( ndo , dp , v3 ) ) != NULL ) { ND_TCHECK ( * dp ) ; type = ( nfs_type ) EXTRACT_32BITS ( dp ) ; dp ++ ; if ( ( dp = parse_sattr3 ( ndo , dp , & sa3 ) ) == NULL ) break ; ND_PRINT ( ( ndo , ""%s"" , tok2str ( type2str , ""unk-ft%d"" , type ) ) ) ; if ( ndo -> ndo_vflag && ( type == NFCHR || type == NFBLK ) ) { ND_TCHECK ( dp [ 1 ] ) ; ND_PRINT ( ( ndo , ""%u/%u"" , EXTRACT_32BITS ( & dp [ 0 ] ) , EXTRACT_32BITS ( & dp [ 1 ] ) ) ) ; dp += 2 ; } if ( ndo -> ndo_vflag ) print_sattr3 ( ndo , & sa3 , ndo -> ndo_vflag ) ; return ; } break ; case NFSPROC_RENAME : if ( ( dp = parsereq ( ndo , rp , length ) ) != NULL && ( dp = parsefhn ( ndo , dp , v3 ) ) != NULL ) { ND_PRINT ( ( ndo , ""->"" ) ) ; if ( parsefhn ( ndo , dp , v3 ) != NULL ) return ; } break ; case NFSPROC_LINK : if ( ( dp = parsereq ( ndo , rp , length ) ) != NULL && ( dp = parsefh ( ndo , dp , v3 ) ) != NULL ) { ND_PRINT ( ( ndo , ""->"" ) ) ; if ( parsefhn ( ndo , dp , v3 ) != NULL ) return ; } break ; case NFSPROC_READDIR : if ( ( dp = parsereq ( ndo , rp , length ) ) != NULL && ( dp = parsefh ( ndo , dp , v3 ) ) != NULL ) { if ( v3 ) { ND_TCHECK ( dp [ 4 ] ) ; ND_PRINT ( ( ndo , ""%ubytes@%"" PRId64 , EXTRACT_32BITS ( & dp [ 4 ] ) , EXTRACT_64BITS ( & dp [ 0 ] ) ) ) ; if ( ndo -> ndo_vflag ) ND_PRINT ( ( ndo , ""verf%08x%08x"" , dp [ 2 ] , dp [ 3 ] ) ) ; } else { ND_TCHECK ( dp [ 1 ] ) ; ND_PRINT ( ( ndo , ""%ubytes@%d"" , EXTRACT_32BITS ( & dp [ 1 ] ) , EXTRACT_32BITS ( & dp [ 0 ] ) ) ) ; } return ; } break ; case NFSPROC_READDIRPLUS : if ( ( dp = parsereq ( ndo , rp , length ) ) != NULL && ( dp = parsefh ( ndo , dp , v3 ) ) != NULL ) { ND_TCHECK ( dp [ 4 ] ) ; ND_PRINT ( ( ndo , ""%ubytes@%"" PRId64 , EXTRACT_32BITS ( & dp [ 4 ] ) , EXTRACT_64BITS ( & dp [ 0 ] ) ) ) ; if ( ndo -> ndo_vflag ) { ND_TCHECK ( dp [ 5 ] ) ; ND_PRINT ( ( ndo , ""max%uverf%08x%08x"" , EXTRACT_32BITS ( & dp [ 5 ] ) , dp [ 2 ] , dp [ 3 ] ) ) ; } return ; } break ; case NFSPROC_COMMIT : if ( ( dp = parsereq ( ndo , rp , length ) ) != NULL && ( dp = parsefh ( ndo , dp , v3 ) ) != NULL ) { ND_TCHECK ( dp [ 2 ] ) ; ND_PRINT ( ( ndo , ""%ubytes@%"" PRIu64 , EXTRACT_32BITS ( & dp [ 2 ] ) , EXTRACT_64BITS ( & dp [ 0 ] ) ) ) ; return ; } break ; default : return ; } trunc : if ( ! nfserr ) ND_PRINT ( ( ndo , ""%s"" , tstr ) ) ; } "," ( dp [ 4 ] ) ; ndo_vflag ) { ND_PRINT ( ( ndo , ""<%s>"" , tok2str ( nfsv3_writemodes , NULL , EXTRACT_32BITS ( & dp [ 3 ] ) ) ) ",the-tcpdump-group@tcpdump/19d25dd8781620cd41bf178a5e2e27fc1cf242d0,CVE-2017-12898,https://github.com/the-tcpdump-group/tcpdump/commit/19d25dd8781620cd41bf178a5e2e27fc1cf242d0,2017-09-14T06:29Z 623,CWE-125,"CWE-125 void vtp_print ( netdissect_options * ndo , const u_char * pptr , u_int length ) { int type , len , tlv_len , tlv_value , mgmtd_len ; const u_char * tptr ; const struct vtp_vlan_ * vtp_vlan ; if ( length < VTP_HEADER_LEN ) goto trunc ; tptr = pptr ; ND_TCHECK2 ( * tptr , VTP_HEADER_LEN ) ; type = * ( tptr + 1 ) ; ND_PRINT ( ( ndo , ""VTPv%u,Message%s(0x%02x),length%u"" , * tptr , tok2str ( vtp_message_type_values , ""Unknownmessagetype"" , type ) , type , length ) ) ; if ( ndo -> ndo_vflag < 1 ) { return ; } ND_PRINT ( ( ndo , ""\\n\\tDomainname:"" ) ) ; mgmtd_len = * ( tptr + 3 ) ; if ( mgmtd_len < 1 || mgmtd_len > 32 ) { ND_PRINT ( ( ndo , ""[invalidMgmtDLen%d]"" , mgmtd_len ) ) ; return ; } fn_printzp ( ndo , tptr + 4 , mgmtd_len , NULL ) ; ND_PRINT ( ( ndo , "",%s:%u"" , tok2str ( vtp_header_values , ""Unknown"" , type ) , * ( tptr + 2 ) ) ) ; tptr += VTP_HEADER_LEN ; switch ( type ) { case VTP_SUMMARY_ADV : ND_TCHECK2 ( * tptr , 8 ) ; ND_PRINT ( ( ndo , ""\\n\\tConfigRev%x,Updater%s"" , EXTRACT_32BITS ( tptr ) , ipaddr_string ( ndo , tptr + 4 ) ) ) ; tptr += 8 ; ND_TCHECK2 ( * tptr , VTP_UPDATE_TIMESTAMP_LEN ) ; ND_PRINT ( ( ndo , "",Timestamp0x%08x0x%08x0x%08x"" , EXTRACT_32BITS ( tptr ) , EXTRACT_32BITS ( tptr + 4 ) , EXTRACT_32BITS ( tptr + 8 ) ) ) ; tptr += VTP_UPDATE_TIMESTAMP_LEN ; ND_TCHECK2 ( * tptr , VTP_MD5_DIGEST_LEN ) ; ND_PRINT ( ( ndo , "",MD5digest:%08x%08x%08x%08x"" , EXTRACT_32BITS ( tptr ) , EXTRACT_32BITS ( tptr + 4 ) , EXTRACT_32BITS ( tptr + 8 ) , EXTRACT_32BITS ( tptr + 12 ) ) ) ; tptr += VTP_MD5_DIGEST_LEN ; break ; case VTP_SUBSET_ADV : ND_TCHECK_32BITS ( tptr ) ; ND_PRINT ( ( ndo , "",ConfigRev%x"" , EXTRACT_32BITS ( tptr ) ) ) ; tptr += 4 ; while ( tptr < ( pptr + length ) ) { ND_TCHECK_8BITS ( tptr ) ; len = * tptr ; if ( len == 0 ) break ; ND_TCHECK2 ( * tptr , len ) ; vtp_vlan = ( const struct vtp_vlan_ * ) tptr ; ND_TCHECK ( * vtp_vlan ) ; ND_PRINT ( ( ndo , ""\\n\\tVLANinfostatus%s,type%s,VLAN-id%u,MTU%u,SAID0x%08x,Name"" , tok2str ( vtp_vlan_status , ""Unknown"" , vtp_vlan -> status ) , tok2str ( vtp_vlan_type_values , ""Unknown"" , vtp_vlan -> type ) , EXTRACT_16BITS ( & vtp_vlan -> vlanid ) , EXTRACT_16BITS ( & vtp_vlan -> mtu ) , EXTRACT_32BITS ( & vtp_vlan -> index ) ) ) ; fn_printzp ( ndo , tptr + VTP_VLAN_INFO_OFFSET , vtp_vlan -> name_len , NULL ) ; len -= VTP_VLAN_INFO_OFFSET + 4 * ( ( vtp_vlan -> name_len + 3 ) / 4 ) ; tptr += VTP_VLAN_INFO_OFFSET + 4 * ( ( vtp_vlan -> name_len + 3 ) / 4 ) ; while ( len > 0 ) { type = * tptr ; tlv_len = * ( tptr + 1 ) ; ND_PRINT ( ( ndo , ""\\n\\t\\t%s(0x%04x)TLV"" , tok2str ( vtp_vlan_tlv_values , ""Unknown"" , type ) , type ) ) ; if ( type == 0 || tlv_len == 0 ) { return ; } ND_TCHECK2 ( * tptr , tlv_len * 2 + 2 ) ; tlv_value = EXTRACT_16BITS ( tptr + 2 ) ; switch ( type ) { case VTP_VLAN_STE_HOP_COUNT : ND_PRINT ( ( ndo , "",%u"" , tlv_value ) ) ; break ; case VTP_VLAN_PRUNING : ND_PRINT ( ( ndo , "",%s(%u)"" , tlv_value == 1 ? ""Enabled"" : ""Disabled"" , tlv_value ) ) ; break ; case VTP_VLAN_STP_TYPE : ND_PRINT ( ( ndo , "",%s(%u)"" , tok2str ( vtp_stp_type_values , ""Unknown"" , tlv_value ) , tlv_value ) ) ; break ; case VTP_VLAN_BRIDGE_TYPE : ND_PRINT ( ( ndo , "",%s(%u)"" , tlv_value == 1 ? ""SRB"" : ""SRT"" , tlv_value ) ) ; break ; case VTP_VLAN_BACKUP_CRF_MODE : ND_PRINT ( ( ndo , "",%s(%u)"" , tlv_value == 1 ? ""Backup"" : ""Notbackup"" , tlv_value ) ) ; break ; case VTP_VLAN_SOURCE_ROUTING_RING_NUMBER : case VTP_VLAN_SOURCE_ROUTING_BRIDGE_NUMBER : case VTP_VLAN_PARENT_VLAN : case VTP_VLAN_TRANS_BRIDGED_VLAN : case VTP_VLAN_ARP_HOP_COUNT : default : print_unknown_data ( ndo , tptr , ""\\n\\t\\t"" , 2 + tlv_len * 2 ) ; break ; } len -= 2 + tlv_len * 2 ; tptr += 2 + tlv_len * 2 ; } } break ; case VTP_ADV_REQUEST : ND_TCHECK2 ( * tptr , 4 ) ; ND_PRINT ( ( ndo , ""\\n\\tStartvalue:%u"" , EXTRACT_32BITS ( tptr ) ) ) ; break ; case VTP_JOIN_MESSAGE : break ; default : break ; } return ; trunc : ND_PRINT ( ( ndo , ""[|vtp]"" ) ) ; } "," ) tptr ; if ( len < VTP_VLAN_INFO_FIXED_PART_LEN ) goto trunc ; ) ) ; len -= VTP_VLAN_INFO_FIXED_PART_LEN ; tptr += VTP_VLAN_INFO_FIXED_PART_LEN ; if ( len < 4 * ( ( vtp_vlan -> name_len vtp_vlan -> name_len + 3 ) / 4 ) ) goto trunc ; ND_TCHECK2 ( * tptr , vtp_vlan -> name_len vtp_vlan -> name_len ) ; fn_printzp ( ndo , tptr , vtp_vlan -> name_len vtp_vlan -> name_len , NULL ) ; len -= 4 * ( ( vtp_vlan -> name_len + 3 ) / 4 ) ; tptr += 4 * ( ( vtp_vlan -> name_len 0 ) { if ( len < 2 ) goto trunc ; ND_TCHECK2 ( * tptr , 2 ) ; ; if ( len < tlv_len * 2 + 2 ) { ND_PRINT ( ( ndo , ""(TLVgoespasttheendofthepacket)"" ) ) ; return ; } 2 ) ; if ( tlv_len != 1 ) { ND_PRINT ( ( ndo , ""(invalidTLVlength%u!=1)"" , tlv_len ) ) ; return ; } else { break ; } } ",the-tcpdump-group@tcpdump/ae83295915d08a854de27a88efac5dd7353e6d3f,CVE-2017-13033,https://github.com/the-tcpdump-group/tcpdump/commit/ae83295915d08a854de27a88efac5dd7353e6d3f,2017-09-14T06:29Z 624,CWE-000,"CWE-000 void xmlParsePI ( xmlParserCtxtPtr ctxt ) { xmlChar * buf = NULL ; int len = 0 ; int size = XML_PARSER_BUFFER_SIZE ; int cur , l ; const xmlChar * target ; xmlParserInputState state ; int count = 0 ; if ( ( RAW == '<' ) && ( NXT ( 1 ) == '?' ) ) { xmlParserInputPtr input = ctxt -> input ; state = ctxt -> instate ; ctxt -> instate = XML_PARSER_PI ; SKIP ( 2 ) ; SHRINK ; target = xmlParsePITarget ( ctxt ) ; if ( target != NULL ) { if ( ( RAW == '?' ) && ( NXT ( 1 ) == '>' ) ) { if ( input != ctxt -> input ) { xmlFatalErrMsg ( ctxt , XML_ERR_ENTITY_BOUNDARY , ""PIdeclarationdoesn\'tstartandstopinthesameentity\\n"" ) ; } SKIP ( 2 ) ; if ( ( ctxt -> sax ) && ( ! ctxt -> disableSAX ) && ( ctxt -> sax -> processingInstruction != NULL ) ) ctxt -> sax -> processingInstruction ( ctxt -> userData , target , NULL ) ; ctxt -> instate = state ; return ; } buf = ( xmlChar * ) xmlMallocAtomic ( size * sizeof ( xmlChar ) ) ; if ( buf == NULL ) { xmlErrMemory ( ctxt , NULL ) ; ctxt -> instate = state ; return ; } cur = CUR ; if ( ! IS_BLANK ( cur ) ) { xmlFatalErrMsgStr ( ctxt , XML_ERR_SPACE_REQUIRED , ""ParsePI:PI%sspaceexpected\\n"" , target ) ; } SKIP_BLANKS ; cur = CUR_CHAR ( l ) ; while ( IS_CHAR ( cur ) && ( ( cur != '?' ) || ( NXT ( 1 ) != '>' ) ) ) { if ( len + 5 >= size ) { xmlChar * tmp ; size *= 2 ; tmp = ( xmlChar * ) xmlRealloc ( buf , size * sizeof ( xmlChar ) ) ; if ( tmp == NULL ) { xmlErrMemory ( ctxt , NULL ) ; xmlFree ( buf ) ; ctxt -> instate = state ; return ; } buf = tmp ; } count ++ ; if ( count > 50 ) { GROW ; count = 0 ; } COPY_BUF ( l , buf , len , cur ) ; NEXTL ( l ) ; cur = CUR_CHAR ( l ) ; if ( cur == 0 ) { SHRINK ; GROW ; cur = CUR_CHAR ( l ) ; } } buf [ len ] = 0 ; if ( cur != '?' ) { xmlFatalErrMsgStr ( ctxt , XML_ERR_PI_NOT_FINISHED , ""ParsePI:PI%sneverend...\\n"" , target ) ; } else { if ( input != ctxt -> input ) { xmlFatalErrMsg ( ctxt , XML_ERR_SPACE_REQUIRED , ""PIdeclarationdoesn\'tstartandstopinthesameentity\\n"" ) ; } SKIP ( 2 ) ; # ifdef LIBXML_CATALOG_ENABLED if ( ( ( state == XML_PARSER_MISC ) || ( state == XML_PARSER_START ) ) && ( xmlStrEqual ( target , XML_CATALOG_PI ) ) ) { xmlCatalogAllow allow = xmlCatalogGetDefaults ( ) ; if ( ( allow == XML_CATA_ALLOW_DOCUMENT ) || ( allow == XML_CATA_ALLOW_ALL ) ) xmlParseCatalogPI ( ctxt , buf ) ; } # endif if ( ( ctxt -> sax ) && ( ! ctxt -> disableSAX ) && ( ctxt -> sax -> processingInstruction != NULL ) ) ctxt -> sax -> processingInstruction ( ctxt -> userData , target , buf ) ; } xmlFree ( buf ) ; } else { xmlFatalErr ( ctxt , XML_ERR_PI_NOT_STARTED , NULL ) ; } ctxt -> instate = state ; } } "," NULL ) ; if ( ctxt -> instate != XML_PARSER_EOF ) ) ; } if ( ctxt -> instate != XML_PARSER_EOF ) ctxt -> instate ",chromium@chromium/44a637b47793512bfb1d2589d43b8dc492a97629,,https://github.com/chromium/chromium/commit/44a637b47793512bfb1d2589d43b8dc492a97629, 625,CWE-200,"CWE-200 int udp_recvmsg ( struct kiocb * iocb , struct sock * sk , struct msghdr * msg , size_t len , int noblock , int flags , int * addr_len ) { struct inet_sock * inet = inet_sk ( sk ) ; struct sockaddr_in * sin = ( struct sockaddr_in * ) msg -> msg_name ; struct sk_buff * skb ; unsigned int ulen , copied ; int peeked , off = 0 ; int err ; int is_udplite = IS_UDPLITE ( sk ) ; bool slow ; if ( addr_len ) * addr_len = sizeof ( * sin ) ; if ( flags & MSG_ERRQUEUE ) return ip_recv_error ( sk , msg , len ) ; try_again : skb = __skb_recv_datagram ( sk , flags | ( noblock ? MSG_DONTWAIT : 0 ) , & peeked , & off , & err ) ; if ( ! skb ) goto out ; ulen = skb -> len - sizeof ( struct udphdr ) ; copied = len ; if ( copied > ulen ) copied = ulen ; else if ( copied < ulen ) msg -> msg_flags |= MSG_TRUNC ; if ( copied < ulen || UDP_SKB_CB ( skb ) -> partial_cov ) { if ( udp_lib_checksum_complete ( skb ) ) goto csum_copy_err ; } if ( skb_csum_unnecessary ( skb ) ) err = skb_copy_datagram_iovec ( skb , sizeof ( struct udphdr ) , msg -> msg_iov , copied ) ; else { err = skb_copy_and_csum_datagram_iovec ( skb , sizeof ( struct udphdr ) , msg -> msg_iov ) ; if ( err == - EINVAL ) goto csum_copy_err ; } if ( unlikely ( err ) ) { trace_kfree_skb ( skb , udp_recvmsg ) ; if ( ! peeked ) { atomic_inc ( & sk -> sk_drops ) ; UDP_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INERRORS , is_udplite ) ; } goto out_free ; } if ( ! peeked ) UDP_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INDATAGRAMS , is_udplite ) ; sock_recv_ts_and_drops ( msg , sk , skb ) ; if ( sin ) { sin -> sin_family = AF_INET ; sin -> sin_port = udp_hdr ( skb ) -> source ; sin -> sin_addr . s_addr = ip_hdr ( skb ) -> saddr ; memset ( sin -> sin_zero , 0 , sizeof ( sin -> sin_zero ) ) ; } if ( inet -> cmsg_flags ) ip_cmsg_recv ( msg , skb ) ; err = copied ; if ( flags & MSG_TRUNC ) err = ulen ; out_free : skb_free_datagram_locked ( sk , skb ) ; out : return err ; csum_copy_err : slow = lock_sock_fast ( sk ) ; if ( ! skb_kill_datagram ( sk , skb , flags ) ) { UDP_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_CSUMERRORS , is_udplite ) ; UDP_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INERRORS , is_udplite ) ; } unlock_sock_fast ( sk , slow ) ; if ( noblock ) return - EAGAIN ; msg -> msg_flags &= ~ MSG_TRUNC ; goto try_again ; } "," ; bool slow ; if ( ) ) ; * addr_len = sizeof ( * sin ) ; ",torvalds@linux/bceaa90240b6019ed73b49965eac7d167610be69,CVE-2013-7281,https://github.com/torvalds/linux/commit/bceaa90240b6019ed73b49965eac7d167610be69,2014-01-08T16:55Z 626,CWE-125,"CWE-125 void rpki_rtr_print ( netdissect_options * ndo , register const u_char * pptr , register u_int len ) { u_int tlen , pdu_type , pdu_len ; const u_char * tptr ; const rpki_rtr_pdu * pdu_header ; tptr = pptr ; tlen = len ; if ( ! ndo -> ndo_vflag ) { ND_PRINT ( ( ndo , "",RPKI-RTR"" ) ) ; return ; } while ( tlen >= sizeof ( rpki_rtr_pdu ) ) { ND_TCHECK2 ( * tptr , sizeof ( rpki_rtr_pdu ) ) ; pdu_header = ( const rpki_rtr_pdu * ) tptr ; pdu_type = pdu_header -> pdu_type ; pdu_len = EXTRACT_32BITS ( pdu_header -> length ) ; ND_TCHECK2 ( * tptr , pdu_len ) ; if ( ! pdu_type || ! pdu_len ) { break ; } if ( tlen < pdu_len ) { goto trunc ; } if ( rpki_rtr_pdu_print ( ndo , tptr , 8 ) ) goto trunc ; tlen -= pdu_len ; tptr += pdu_len ; } return ; trunc : ND_PRINT ( ( ndo , ""\\n\\t%s"" , tstr ) ) ; } "," len ) { if ( ! } while ( len ) { u_int pdu_len = rpki_rtr_pdu_print ( ndo ( ndo , pptr , len , 1 , 8 ) , 8 ) ; len -= pdu_len ; -= pdu_len ; pptr += pdu_len ; pdu_len ; } } ",the-tcpdump-group@tcpdump/83c64fce3a5226b080e535f5131a8a318f30e79b,CVE-2017-13050,https://github.com/the-tcpdump-group/tcpdump/commit/83c64fce3a5226b080e535f5131a8a318f30e79b,2017-09-14T06:29Z 627,CWE-119,"CWE-119 RD_BOOL cssp_read_tsrequest ( STREAM token , STREAM pubkey ) { STREAM s ; int length ; int tagval ; s = tcp_recv ( NULL , 4 ) ; if ( s == NULL ) return False ; if ( s -> p [ 0 ] != ( BER_TAG_SEQUENCE | BER_TAG_CONSTRUCTED ) ) { logger ( Protocol , Error , ""cssp_read_tsrequest(),expectedBER_TAG_SEQUENCE|BER_TAG_CONSTRUCTED,got%x"" , s -> p [ 0 ] ) ; return False ; } if ( s -> p [ 1 ] < 0x80 ) length = s -> p [ 1 ] - 2 ; else if ( s -> p [ 1 ] == 0x81 ) length = s -> p [ 2 ] - 1 ; else if ( s -> p [ 1 ] == 0x82 ) length = ( s -> p [ 2 ] << 8 ) | s -> p [ 3 ] ; else return False ; s = tcp_recv ( s , length ) ; if ( ! ber_in_header ( s , & tagval , & length ) || tagval != ( BER_TAG_SEQUENCE | BER_TAG_CONSTRUCTED ) ) return False ; if ( ! ber_in_header ( s , & tagval , & length ) || tagval != ( BER_TAG_CTXT_SPECIFIC | BER_TAG_CONSTRUCTED | 0 ) ) return False ; in_uint8s ( s , length ) ; if ( token ) { if ( ! ber_in_header ( s , & tagval , & length ) || tagval != ( BER_TAG_CTXT_SPECIFIC | BER_TAG_CONSTRUCTED | 1 ) ) return False ; if ( ! ber_in_header ( s , & tagval , & length ) || tagval != ( BER_TAG_SEQUENCE | BER_TAG_CONSTRUCTED ) ) return False ; if ( ! ber_in_header ( s , & tagval , & length ) || tagval != ( BER_TAG_SEQUENCE | BER_TAG_CONSTRUCTED ) ) return False ; if ( ! ber_in_header ( s , & tagval , & length ) || tagval != ( BER_TAG_CTXT_SPECIFIC | BER_TAG_CONSTRUCTED | 0 ) ) return False ; if ( ! ber_in_header ( s , & tagval , & length ) || tagval != BER_TAG_OCTET_STRING ) return False ; token -> end = token -> p = token -> data ; out_uint8p ( token , s -> p , length ) ; s_mark_end ( token ) ; } if ( pubkey ) { if ( ! ber_in_header ( s , & tagval , & length ) || tagval != ( BER_TAG_CTXT_SPECIFIC | BER_TAG_CONSTRUCTED | 3 ) ) return False ; if ( ! ber_in_header ( s , & tagval , & length ) || tagval != BER_TAG_OCTET_STRING ) return False ; pubkey -> data = pubkey -> p = s -> p ; pubkey -> end = pubkey -> data + length ; pubkey -> size = length ; } return True ; } "," int tagval ; struct stream packet ; length ) ; packet = * s ; return False ; if ( ! s_check_rem ( s , length ) ) { rdp_protocol_error ( ""cssp_read_tsrequest(),consumeofversionfromstreamwouldoverrun"" , & packet ) ; } return False ; if ( ! s_check_rem ( s , length ) ) { rdp_protocol_error ( ""cssp_read_tsrequest(),consumeoftokenfromstreamwouldoverrun"" , & packet ) ; } s_realloc ( token , length ) ; s_reset ( token ) ; out_uint8p ( ",rdesktop@rdesktop/4dca546d04321a610c1835010b5dad85163b65e1,CVE-2018-20182,https://github.com/rdesktop/rdesktop/commit/4dca546d04321a610c1835010b5dad85163b65e1,2019-03-15T18:29Z 628,CWE-835,"CWE-835 const u_char * ns_nprint ( netdissect_options * ndo , register const u_char * cp , register const u_char * bp ) { register u_int i , l ; register const u_char * rp = NULL ; register int compress = 0 ; int chars_processed ; int elt ; int data_size = ndo -> ndo_snapend - bp ; if ( ( l = labellen ( ndo , cp ) ) == ( u_int ) - 1 ) return ( NULL ) ; if ( ! ND_TTEST2 ( * cp , 1 ) ) return ( NULL ) ; chars_processed = 1 ; if ( ( ( i = * cp ++ ) & INDIR_MASK ) != INDIR_MASK ) { compress = 0 ; rp = cp + l ; } if ( i != 0 ) while ( i && cp < ndo -> ndo_snapend ) { if ( ( i & INDIR_MASK ) == INDIR_MASK ) { if ( ! compress ) { rp = cp + 1 ; compress = 1 ; } if ( ! ND_TTEST2 ( * cp , 1 ) ) return ( NULL ) ; cp = bp + ( ( ( i << 8 ) | * cp ) & 0x3fff ) ; if ( ( l = labellen ( ndo , cp ) ) == ( u_int ) - 1 ) return ( NULL ) ; if ( ! ND_TTEST2 ( * cp , 1 ) ) return ( NULL ) ; i = * cp ++ ; chars_processed ++ ; if ( chars_processed >= data_size ) { ND_PRINT ( ( ndo , """" ) ) ; return ( NULL ) ; } continue ; } if ( ( i & INDIR_MASK ) == EDNS0_MASK ) { elt = ( i & ~ INDIR_MASK ) ; switch ( elt ) { case EDNS0_ELT_BITLABEL : if ( blabel_print ( ndo , cp ) == NULL ) return ( NULL ) ; break ; default : ND_PRINT ( ( ndo , ""%d>"" , elt ) ) ; return ( NULL ) ; } } else { if ( fn_printn ( ndo , cp , l , ndo -> ndo_snapend ) ) return ( NULL ) ; } cp += l ; chars_processed += l ; ND_PRINT ( ( ndo , ""."" ) ) ; if ( ( l = labellen ( ndo , cp ) ) == ( u_int ) - 1 ) return ( NULL ) ; if ( ! ND_TTEST2 ( * cp , 1 ) ) return ( NULL ) ; i = * cp ++ ; chars_processed ++ ; if ( ! compress ) rp += l + 1 ; } else ND_PRINT ( ( ndo , ""."" ) ) ; return ( rp ) ; } "," 0 ; int elt ; u_int offset , max_offset ; if ( ( l = labellen ( ndo , cp ) ) == ( u_int ) - 1 ) return ( NULL ) ; if ( ! ND_TTEST2 ( * cp , 1 ) ) return ( NULL ) ; max_offset = ( u_int ) ( cp - bp ) ; if ( ( ( i = * cp ++ ) & INDIR_MASK ) != INDIR_MASK ) { compress = 0 ; rp = cp + l ; } if ( i != 0 ) while ( i && cp < ndo -> ndo_snapend ndo -> ndo_snapend ) { if ( ( i & INDIR_MASK ) == INDIR_MASK ) { if ( ! compress ) { rp = cp + 1 ; compress = 1 ; } if ( ! NULL ) ; offset = ( ( ( i << 8 ) | * cp ) & 0x3fff ) ; if ( offset >= max_offset ) { ND_PRINT ( ( ndo , ""PTR>"" ) ) ; return ( NULL ) ; } max_offset = offset ; cp = bp + offset ; if ( ( l = labellen ( ndo , cp ) ) == ( u_int ) - 1 ) return ( NULL ) ; if ( ! NULL ) ; i = * cp ++ ; continue ; } += l ; ND_PRINT ( ( cp ++ ; if ( ! ",the-tcpdump-group@tcpdump/3a76fd7c95fced2c2f8c8148a9055c3a542eff29,CVE-2017-12995,https://github.com/the-tcpdump-group/tcpdump/commit/3a76fd7c95fced2c2f8c8148a9055c3a542eff29,2017-09-14T06:29Z 629,CWE-19,"CWE-19 int xfs_attr_rmtval_set ( struct xfs_da_args * args ) { struct xfs_inode * dp = args -> dp ; struct xfs_mount * mp = dp -> i_mount ; struct xfs_bmbt_irec map ; xfs_dablk_t lblkno ; xfs_fileoff_t lfileoff = 0 ; __uint8_t * src = args -> value ; int blkcnt ; int valuelen ; int nmap ; int error ; int offset = 0 ; trace_xfs_attr_rmtval_set ( args ) ; blkcnt = xfs_attr3_rmt_blocks ( mp , args -> valuelen ) ; error = xfs_bmap_first_unused ( args -> trans , args -> dp , blkcnt , & lfileoff , XFS_ATTR_FORK ) ; if ( error ) return error ; args -> rmtblkno = lblkno = ( xfs_dablk_t ) lfileoff ; args -> rmtblkcnt = blkcnt ; while ( blkcnt > 0 ) { int committed ; xfs_bmap_init ( args -> flist , args -> firstblock ) ; nmap = 1 ; error = xfs_bmapi_write ( args -> trans , dp , ( xfs_fileoff_t ) lblkno , blkcnt , XFS_BMAPI_ATTRFORK | XFS_BMAPI_METADATA , args -> firstblock , args -> total , & map , & nmap , args -> flist ) ; if ( ! error ) { error = xfs_bmap_finish ( & args -> trans , args -> flist , & committed ) ; } if ( error ) { ASSERT ( committed ) ; args -> trans = NULL ; xfs_bmap_cancel ( args -> flist ) ; return ( error ) ; } if ( committed ) xfs_trans_ijoin ( args -> trans , dp , 0 ) ; ASSERT ( nmap == 1 ) ; ASSERT ( ( map . br_startblock != DELAYSTARTBLOCK ) && ( map . br_startblock != HOLESTARTBLOCK ) ) ; lblkno += map . br_blockcount ; blkcnt -= map . br_blockcount ; error = xfs_trans_roll ( & args -> trans , dp ) ; if ( error ) return ( error ) ; } lblkno = args -> rmtblkno ; blkcnt = args -> rmtblkcnt ; valuelen = args -> valuelen ; while ( valuelen > 0 ) { struct xfs_buf * bp ; xfs_daddr_t dblkno ; int dblkcnt ; ASSERT ( blkcnt > 0 ) ; xfs_bmap_init ( args -> flist , args -> firstblock ) ; nmap = 1 ; error = xfs_bmapi_read ( dp , ( xfs_fileoff_t ) lblkno , blkcnt , & map , & nmap , XFS_BMAPI_ATTRFORK ) ; if ( error ) return ( error ) ; ASSERT ( nmap == 1 ) ; ASSERT ( ( map . br_startblock != DELAYSTARTBLOCK ) && ( map . br_startblock != HOLESTARTBLOCK ) ) ; dblkno = XFS_FSB_TO_DADDR ( mp , map . br_startblock ) , dblkcnt = XFS_FSB_TO_BB ( mp , map . br_blockcount ) ; bp = xfs_buf_get ( mp -> m_ddev_targp , dblkno , dblkcnt , 0 ) ; if ( ! bp ) return ENOMEM ; bp -> b_ops = & xfs_attr3_rmt_buf_ops ; xfs_attr_rmtval_copyin ( mp , bp , args -> dp -> i_ino , & offset , & valuelen , & src ) ; error = xfs_bwrite ( bp ) ; xfs_buf_relse ( bp ) ; if ( error ) return error ; lblkno += map . br_blockcount ; blkcnt -= map . br_blockcount ; } ASSERT ( valuelen == 0 ) ; return 0 ; } "," , args -> rmtvaluelen ) ; error = args -> rmtvaluelen ; while ( ",torvalds@linux/8275cdd0e7ac550dcce2b3ef6d2fb3b808c1ae59,CVE-2015-0274,https://github.com/torvalds/linux/commit/8275cdd0e7ac550dcce2b3ef6d2fb3b808c1ae59,2015-03-16T10:59Z 630,CWE-352,"CWE-352 static void _send ( Socket_T S , const char * request , StringBuffer_T data ) { _argument ( data , ""format"" , ""text"" ) ; char * _auth = _getBasicAuthHeader ( ) ; int rv = Socket_print ( S , ""POST%sHTTP/1.0\\r\\n"" ""Content-Type:application/x-www-form-urlencoded\\r\\n"" ""Content-Length:%d\\r\\n"" ""%s"" ""\\r\\n"" ""%s"" , request , StringBuffer_length ( data ) , _auth ? _auth : """" , StringBuffer_toString ( data ) ) ; FREE ( _auth ) ; if ( rv < 0 ) THROW ( IOException , ""Monit:cannotsendcommandtothemonitdaemon--%s"" , STRERROR ) ; } "," ( ) ; MD_T token ; StringBuffer_append ( data , ""%ssecuritytoken=%s"" , StringBuffer_length ( data ) > 0 ? ""&"" : """" , Util_getToken ( token ) ) ; , ""POST%sHTTP/1.0\\r\\n"" ""Content-Type:application/x-www-form-urlencoded\\r\\n"" ""Cookie:securitytoken=%s\\r\\n"" ""%s"" , request , token ",tildeslash@monit/c6ec3820e627f85417053e6336de2987f2d863e3,CVE-2016-7067,https://bitbucket.org/tildeslash/monit/commit/c6ec3820e627f85417053e6336de2987f2d863e3,2018-09-10T14:29Z 631,CWE-269,"CWE-269 static void copy_asoundrc ( void ) { char * src = RUN_ASOUNDRC_FILE ; char * dest ; if ( asprintf ( & dest , ""%s/.asoundrc"" , cfg . homedir ) == - 1 ) errExit ( ""asprintf"" ) ; if ( is_link ( dest ) ) { fprintf ( stderr , ""Error:%sisasymboliclink\\n"" , dest ) ; exit ( 1 ) ; } pid_t child = fork ( ) ; if ( child < 0 ) errExit ( ""fork"" ) ; if ( child == 0 ) { drop_privs ( 0 ) ; int rv = copy_file ( src , dest ) ; if ( rv ) fprintf ( stderr , ""Warning:cannottransfer.asoundrcinprivatehomedirectory\\n"" ) ; else { fs_logger2 ( ""clone"" , dest ) ; } _exit ( 0 ) ; } waitpid ( child , NULL , 0 ) ; if ( chown ( dest , getuid ( ) , getgid ( ) ) < 0 ) errExit ( ""chown"" ) ; if ( chmod ( dest , S_IRUSR | S_IWUSR ) < 0 ) errExit ( ""chmod"" ) ; unlink ( src ) ; } "," ) ; } copy_file_as_user ( src , ( src , dest , getuid getgid ( ) , S_IRUSR | | S_IWUSR ) ; fs_logger2 ( ""clone"" , dest ) ; unlink ",netblue30@firejail/903fd8a0789ca3cc3c21d84cd0282481515592ef,CVE-2017-5940,https://github.com/netblue30/firejail/commit/903fd8a0789ca3cc3c21d84cd0282481515592ef,2017-02-09T18:59Z 632,CWE-401,"CWE-401 static struct fc_host_statistics * bfad_im_get_stats ( struct Scsi_Host * shost ) { struct bfad_im_port_s * im_port = ( struct bfad_im_port_s * ) shost -> hostdata [ 0 ] ; struct bfad_s * bfad = im_port -> bfad ; struct bfad_hal_comp fcomp ; union bfa_port_stats_u * fcstats ; struct fc_host_statistics * hstats ; bfa_status_t rc ; unsigned long flags ; fcstats = kzalloc ( sizeof ( union bfa_port_stats_u ) , GFP_KERNEL ) ; if ( fcstats == NULL ) return NULL ; hstats = & bfad -> link_stats ; init_completion ( & fcomp . comp ) ; spin_lock_irqsave ( & bfad -> bfad_lock , flags ) ; memset ( hstats , 0 , sizeof ( struct fc_host_statistics ) ) ; rc = bfa_port_get_stats ( BFA_FCPORT ( & bfad -> bfa ) , fcstats , bfad_hcb_comp , & fcomp ) ; spin_unlock_irqrestore ( & bfad -> bfad_lock , flags ) ; if ( rc != BFA_STATUS_OK ) return NULL ; wait_for_completion ( & fcomp . comp ) ; hstats -> seconds_since_last_reset = fcstats -> fc . secs_reset ; hstats -> tx_frames = fcstats -> fc . tx_frames ; hstats -> tx_words = fcstats -> fc . tx_words ; hstats -> rx_frames = fcstats -> fc . rx_frames ; hstats -> rx_words = fcstats -> fc . rx_words ; hstats -> lip_count = fcstats -> fc . lip_count ; hstats -> nos_count = fcstats -> fc . nos_count ; hstats -> error_frames = fcstats -> fc . error_frames ; hstats -> dumped_frames = fcstats -> fc . dropped_frames ; hstats -> link_failure_count = fcstats -> fc . link_failures ; hstats -> loss_of_sync_count = fcstats -> fc . loss_of_syncs ; hstats -> loss_of_signal_count = fcstats -> fc . loss_of_signals ; hstats -> prim_seq_protocol_err_count = fcstats -> fc . primseq_errs ; hstats -> invalid_crc_count = fcstats -> fc . invalid_crcs ; kfree ( fcstats ) ; return hstats ; } "," != BFA_STATUS_OK ) { kfree ( fcstats ) ; return NULL ; } ",torvalds@linux/0e62395da2bd5166d7c9e14cbc7503b256a34cb0,CVE-2019-19066,https://github.com/torvalds/linux/commit/0e62395da2bd5166d7c9e14cbc7503b256a34cb0,2019-11-18T06:15Z 633,CWE-20,"CWE-20 static inline void VectorClamp3 ( DDSVector3 * value ) { value -> x = MinF ( 1.0f , MaxF ( 0.0f , value -> x ) ) ; value -> y = MinF ( 1.0f , MaxF ( 0.0f , value -> y ) ) ; value -> z = MinF ( 1.0f , MaxF ( 0.0f , value -> z ) ) ; } "," -> x = MagickMin ( 1.0f , ( 1.0f , MagickMax ( 0.0f , -> y = MagickMin ( 1.0f , ( 1.0f , MagickMax ( 0.0f , -> z = MagickMin ( 1.0f , ( 1.0f , MagickMax ( 0.0f , ",ImageMagick@ImageMagick/d7325bac173492b358417a0ad49fabad44447d52,CVE-2014-9907,https://github.com/ImageMagick/ImageMagick/commit/d7325bac173492b358417a0ad49fabad44447d52,2017-04-19T14:59Z 634,CWE-476,"CWE-476 int git_pkt_parse_line ( git_pkt * * head , const char * line , const char * * out , size_t bufflen ) { int ret ; int32_t len ; if ( bufflen > 0 && bufflen < PKT_LEN_SIZE ) return GIT_EBUFS ; len = parse_len ( line ) ; if ( len < 0 ) { if ( bufflen >= 4 && ! git__prefixcmp ( line , ""PACK"" ) ) { giterr_clear ( ) ; * out = line ; return pack_pkt ( head ) ; } return ( int ) len ; } if ( bufflen > 0 && bufflen < ( size_t ) len ) return GIT_EBUFS ; if ( len != 0 && len < PKT_LEN_SIZE ) return GIT_ERROR ; line += PKT_LEN_SIZE ; if ( len == PKT_LEN_SIZE ) { * head = NULL ; * out = line ; return 0 ; } if ( len == 0 ) { * out = line ; return flush_pkt ( head ) ; } len -= PKT_LEN_SIZE ; if ( * line == GIT_SIDE_BAND_DATA ) ret = data_pkt ( head , line , len ) ; else if ( * line == GIT_SIDE_BAND_PROGRESS ) ret = sideband_progress_pkt ( head , line , len ) ; else if ( * line == GIT_SIDE_BAND_ERROR ) ret = sideband_error_pkt ( head , line , len ) ; else if ( ! git__prefixcmp ( line , ""ACK"" ) ) ret = ack_pkt ( head , line , len ) ; else if ( ! git__prefixcmp ( line , ""NAK"" ) ) ret = nak_pkt ( head ) ; else if ( ! git__prefixcmp ( line , ""ERR"" ) ) ret = err_pkt ( head , line , len ) ; else if ( * line == '#' ) ret = comment_pkt ( head , line , len ) ; else if ( ! git__prefixcmp ( line , ""ok"" ) ) ret = ok_pkt ( head , line , len ) ; else if ( ! git__prefixcmp ( line , ""ng"" ) ) ret = ng_pkt ( head , line , len ) ; else if ( ! git__prefixcmp ( line , ""unpack"" ) ) ret = unpack_pkt ( head , line , len ) ; else ret = ref_pkt ( head , line , len ) ; * out = line + len ; return ret ; } "," PKT_LEN_SIZE ) { giterr_set_str ( GITERR_NET , ""Invalidemptypacket"" ) ; return GIT_ERROR ; } if ",libgit2@libgit2/84d30d569ada986f3eef527cbdb932643c2dd037,CVE-2016-10129,https://github.com/libgit2/libgit2/commit/84d30d569ada986f3eef527cbdb932643c2dd037,2017-03-24T15:59Z 635,CWE-20,"CWE-20 static int do_anonymous_page ( struct mm_struct * mm , struct vm_area_struct * vma , unsigned long address , pte_t * page_table , pmd_t * pmd , unsigned int flags ) { struct mem_cgroup * memcg ; struct page * page ; spinlock_t * ptl ; pte_t entry ; pte_unmap ( page_table ) ; if ( check_stack_guard_page ( vma , address ) < 0 ) return VM_FAULT_SIGSEGV ; if ( ! ( flags & FAULT_FLAG_WRITE ) && ! mm_forbids_zeropage ( mm ) ) { entry = pte_mkspecial ( pfn_pte ( my_zero_pfn ( address ) , vma -> vm_page_prot ) ) ; page_table = pte_offset_map_lock ( mm , pmd , address , & ptl ) ; if ( ! pte_none ( * page_table ) ) goto unlock ; goto setpte ; } if ( unlikely ( anon_vma_prepare ( vma ) ) ) goto oom ; page = alloc_zeroed_user_highpage_movable ( vma , address ) ; if ( ! page ) goto oom ; if ( mem_cgroup_try_charge ( page , mm , GFP_KERNEL , & memcg ) ) goto oom_free_page ; __SetPageUptodate ( page ) ; entry = mk_pte ( page , vma -> vm_page_prot ) ; if ( vma -> vm_flags & VM_WRITE ) entry = pte_mkwrite ( pte_mkdirty ( entry ) ) ; page_table = pte_offset_map_lock ( mm , pmd , address , & ptl ) ; if ( ! pte_none ( * page_table ) ) goto release ; inc_mm_counter_fast ( mm , MM_ANONPAGES ) ; page_add_new_anon_rmap ( page , vma , address ) ; mem_cgroup_commit_charge ( page , memcg , false ) ; lru_cache_add_active_or_unevictable ( page , vma ) ; setpte : set_pte_at ( mm , address , page_table , entry ) ; update_mmu_cache ( vma , address , page_table ) ; unlock : pte_unmap_unlock ( page_table , ptl ) ; return 0 ; release : mem_cgroup_cancel_charge ( page , memcg ) ; page_cache_release ( page ) ; goto unlock ; oom_free_page : page_cache_release ( page ) ; oom : return VM_FAULT_OOM ; } "," ; if ( vma -> vm_flags & VM_SHARED ) return VM_FAULT_SIGBUS ; if ( ",torvalds@linux/6b7339f4c31ad69c8e9c0b2859276e22cf72176d,CVE-2015-3288,https://github.com/torvalds/linux/commit/6b7339f4c31ad69c8e9c0b2859276e22cf72176d,2016-10-16T21:59Z 636,CWE-416,"CWE-416 static void sig_server_connect_copy ( SERVER_CONNECT_REC * * dest , IRC_SERVER_CONNECT_REC * src ) { IRC_SERVER_CONNECT_REC * rec ; g_return_if_fail ( dest != NULL ) ; if ( ! IS_IRC_SERVER_CONNECT ( src ) ) return ; rec = g_new0 ( IRC_SERVER_CONNECT_REC , 1 ) ; rec -> chat_type = IRC_PROTOCOL ; rec -> max_cmds_at_once = src -> max_cmds_at_once ; rec -> cmd_queue_speed = src -> cmd_queue_speed ; rec -> max_query_chans = src -> max_query_chans ; rec -> max_kicks = src -> max_kicks ; rec -> max_modes = src -> max_modes ; rec -> max_msgs = src -> max_msgs ; rec -> max_whois = src -> max_whois ; rec -> usermode = g_strdup ( src -> usermode ) ; rec -> alternate_nick = g_strdup ( src -> alternate_nick ) ; rec -> sasl_mechanism = src -> sasl_mechanism ; rec -> sasl_username = src -> sasl_username ; rec -> sasl_password = src -> sasl_password ; * dest = ( SERVER_CONNECT_REC * ) rec ; } "," -> sasl_username = g_strdup ( src -> sasl_username ) -> sasl_password = g_strdup ( src -> sasl_password ) ",irssi@irssi/d23b0d22cc611e43c88d99192a59f413f951a955,CVE-2019-13045,https://github.com/irssi/irssi/commit/d23b0d22cc611e43c88d99192a59f413f951a955,2019-06-29T14:15Z 637,CWE-20,"CWE-20 static int adjust_insn_aux_data ( struct bpf_verifier_env * env , u32 prog_len , u32 off , u32 cnt ) { struct bpf_insn_aux_data * new_data , * old_data = env -> insn_aux_data ; if ( cnt == 1 ) return 0 ; new_data = vzalloc ( sizeof ( struct bpf_insn_aux_data ) * prog_len ) ; if ( ! new_data ) return - ENOMEM ; memcpy ( new_data , old_data , sizeof ( struct bpf_insn_aux_data ) * off ) ; memcpy ( new_data + off + cnt - 1 , old_data + off , sizeof ( struct bpf_insn_aux_data ) * ( prog_len - off - cnt + 1 ) ) ; env -> insn_aux_data = new_data ; vfree ( old_data ) ; return 0 ; } "," env -> insn_aux_data ; int i ) ) ; for ( i = off ; i < off + cnt - 1 ; i ++ ) new_data [ i ] . seen = true ; ",torvalds@linux/c131187db2d3fa2f8bf32fdf4e9a4ef805168467,CVE-2017-17862,https://github.com/torvalds/linux/commit/c131187db2d3fa2f8bf32fdf4e9a4ef805168467,2017-12-27T17:08Z 638,CWE-125,"CWE-125 int frag6_print ( netdissect_options * ndo , register const u_char * bp , register const u_char * bp2 ) { register const struct ip6_frag * dp ; register const struct ip6_hdr * ip6 ; dp = ( const struct ip6_frag * ) bp ; ip6 = ( const struct ip6_hdr * ) bp2 ; ND_TCHECK ( dp -> ip6f_offlg ) ; if ( ndo -> ndo_vflag ) { ND_PRINT ( ( ndo , ""frag(0x%08x:%d|%ld)"" , EXTRACT_32BITS ( & dp -> ip6f_ident ) , EXTRACT_16BITS ( & dp -> ip6f_offlg ) & IP6F_OFF_MASK , sizeof ( struct ip6_hdr ) + EXTRACT_16BITS ( & ip6 -> ip6_plen ) - ( long ) ( bp - bp2 ) - sizeof ( struct ip6_frag ) ) ) ; } else { ND_PRINT ( ( ndo , ""frag(%d|%ld)"" , EXTRACT_16BITS ( & dp -> ip6f_offlg ) & IP6F_OFF_MASK , sizeof ( struct ip6_hdr ) + EXTRACT_16BITS ( & ip6 -> ip6_plen ) - ( long ) ( bp - bp2 ) - sizeof ( struct ip6_frag ) ) ) ; } if ( ( EXTRACT_16BITS ( & dp -> ip6f_offlg ) & IP6F_OFF_MASK ) != 0 ) return - 1 ; else { ND_PRINT ( ( ndo , """" ) ) ; return sizeof ( struct ip6_frag ) ; } trunc : ND_PRINT ( ( ndo , ""[|frag]"" ) ) ; return - 1 ; } "," ; ND_TCHECK ( * dp ) ; if ",the-tcpdump-group@tcpdump/2d669862df7cd17f539129049f6fb70d17174125,CVE-2017-13031,https://github.com/the-tcpdump-group/tcpdump/commit/2d669862df7cd17f539129049f6fb70d17174125,2017-09-14T06:29Z 639,CWE-125,"CWE-125 static int mobility_opt_print ( netdissect_options * ndo , const u_char * bp , const unsigned len ) { unsigned i , optlen ; for ( i = 0 ; i < len ; i += optlen ) { ND_TCHECK ( bp [ i ] ) ; if ( bp [ i ] == IP6MOPT_PAD1 ) optlen = 1 ; else { if ( i + 1 < len ) { ND_TCHECK ( bp [ i + 1 ] ) ; optlen = bp [ i + 1 ] + 2 ; } else goto trunc ; } if ( i + optlen > len ) goto trunc ; ND_TCHECK ( bp [ i + optlen ] ) ; switch ( bp [ i ] ) { case IP6MOPT_PAD1 : ND_PRINT ( ( ndo , ""(pad1)"" ) ) ; break ; case IP6MOPT_PADN : if ( len - i < IP6MOPT_MINLEN ) { ND_PRINT ( ( ndo , ""(padn:trunc)"" ) ) ; goto trunc ; } ND_PRINT ( ( ndo , ""(padn)"" ) ) ; break ; case IP6MOPT_REFRESH : if ( len - i < IP6MOPT_REFRESH_MINLEN ) { ND_PRINT ( ( ndo , ""(refresh:trunc)"" ) ) ; goto trunc ; } ND_PRINT ( ( ndo , ""(refresh:%u)"" , EXTRACT_16BITS ( & bp [ i + 2 ] ) << 2 ) ) ; break ; case IP6MOPT_ALTCOA : if ( len - i < IP6MOPT_ALTCOA_MINLEN ) { ND_PRINT ( ( ndo , ""(altcoa:trunc)"" ) ) ; goto trunc ; } ND_PRINT ( ( ndo , ""(alt-CoA:%s)"" , ip6addr_string ( ndo , & bp [ i + 2 ] ) ) ) ; break ; case IP6MOPT_NONCEID : if ( len - i < IP6MOPT_NONCEID_MINLEN ) { ND_PRINT ( ( ndo , ""(ni:trunc)"" ) ) ; goto trunc ; } ND_PRINT ( ( ndo , ""(ni:ho=0x%04xco=0x%04x)"" , EXTRACT_16BITS ( & bp [ i + 2 ] ) , EXTRACT_16BITS ( & bp [ i + 4 ] ) ) ) ; break ; case IP6MOPT_AUTH : if ( len - i < IP6MOPT_AUTH_MINLEN ) { ND_PRINT ( ( ndo , ""(auth:trunc)"" ) ) ; goto trunc ; } ND_PRINT ( ( ndo , ""(auth)"" ) ) ; break ; default : if ( len - i < IP6MOPT_MINLEN ) { ND_PRINT ( ( ndo , ""(sopt_type%u:trunc)"" , bp [ i ] ) ) ; goto trunc ; } ND_PRINT ( ( ndo , ""(type-0x%02x:len=%u)"" , bp [ i ] , bp [ i + 1 ] ) ) ; break ; } } return 0 ; trunc : return 1 ; } "," trunc ; } ND_TCHECK_16BITS ( & bp [ i + 2 ] ) ; ",the-tcpdump-group@tcpdump/b8e559afaeb8fe0604a1f8e3ad4dc1445de07a00,CVE-2017-13023,https://github.com/the-tcpdump-group/tcpdump/commit/b8e559afaeb8fe0604a1f8e3ad4dc1445de07a00,2017-09-14T06:29Z 640,CWE-119,"CWE-119 static void update_alt_ref_frame_stats ( VP8_COMP * cpi ) { VP8_COMMON * cm = & cpi -> common ; if ( ! cpi -> auto_gold ) cpi -> frames_till_gf_update_due = DEFAULT_GF_INTERVAL ; if ( ( cpi -> pass != 2 ) && cpi -> frames_till_gf_update_due ) { cpi -> current_gf_interval = cpi -> frames_till_gf_update_due ; cpi -> gf_overspend_bits += cpi -> projected_frame_size ; cpi -> non_gf_bitrate_adjustment = cpi -> gf_overspend_bits / cpi -> frames_till_gf_update_due ; } vpx_memset ( cpi -> gf_active_flags , 1 , ( cm -> mb_rows * cm -> mb_cols ) ) ; cpi -> gf_active_count = cm -> mb_rows * cm -> mb_cols ; cpi -> frames_since_golden = 0 ; cpi -> source_alt_ref_pending = 0 ; cpi -> source_alt_ref_active = 1 ; } "," frames_till_gf_update_due ; } memset ( cpi -> ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 641,CWE-119,"CWE-119 static int PredictorDecodeTile ( TIFF * tif , uint8 * op0 , tmsize_t occ0 , uint16 s ) { TIFFPredictorState * sp = PredictorState ( tif ) ; assert ( sp != NULL ) ; assert ( sp -> decodetile != NULL ) ; if ( ( * sp -> decodetile ) ( tif , op0 , occ0 , s ) ) { tmsize_t rowsize = sp -> rowsize ; assert ( rowsize > 0 ) ; assert ( ( occ0 % rowsize ) == 0 ) ; assert ( sp -> decodepfunc != NULL ) ; while ( occ0 > 0 ) { ( * sp -> decodepfunc ) ( tif , op0 , rowsize ) ; occ0 -= rowsize ; op0 += rowsize ; } return 1 ; } else return 0 ; } "," 0 ) ; if ( ( occ0 % rowsize ) != 0 ) { TIFFErrorExt ( tif -> tif_clientdata , ""PredictorDecodeTile"" , ""%s"" , ""occ0%rowsize!=0"" ) ; return 0 ; } assert ( sp 0 ) { if ( ! , rowsize ) ) return 0 ",vadz@libtiff/3ca657a8793dd011bf869695d72ad31c779c3cc1,CVE-2016-9535,https://github.com/vadz/libtiff/commit/3ca657a8793dd011bf869695d72ad31c779c3cc1,2016-11-22T19:59Z 642,CWE-400,"CWE-400 static void exif_mnote_data_canon_load ( ExifMnoteData * ne , const unsigned char * buf , unsigned int buf_size ) { ExifMnoteDataCanon * n = ( ExifMnoteDataCanon * ) ne ; ExifShort c ; size_t i , tcount , o , datao ; if ( ! n || ! buf || ! buf_size ) { exif_log ( ne -> log , EXIF_LOG_CODE_CORRUPT_DATA , ""ExifMnoteCanon"" , ""ShortMakerNote"" ) ; return ; } datao = 6 + n -> offset ; if ( CHECKOVERFLOW ( datao , buf_size , 2 ) ) { exif_log ( ne -> log , EXIF_LOG_CODE_CORRUPT_DATA , ""ExifMnoteCanon"" , ""ShortMakerNote"" ) ; return ; } c = exif_get_short ( buf + datao , n -> order ) ; datao += 2 ; exif_mnote_data_canon_clear ( n ) ; n -> entries = exif_mem_alloc ( ne -> mem , sizeof ( MnoteCanonEntry ) * c ) ; if ( ! n -> entries ) { EXIF_LOG_NO_MEMORY ( ne -> log , ""ExifMnoteCanon"" , sizeof ( MnoteCanonEntry ) * c ) ; return ; } tcount = 0 ; for ( i = c , o = datao ; i ; -- i , o += 12 ) { size_t s ; memset ( & n -> entries [ tcount ] , 0 , sizeof ( MnoteCanonEntry ) ) ; if ( CHECKOVERFLOW ( o , buf_size , 12 ) ) { exif_log ( ne -> log , EXIF_LOG_CODE_CORRUPT_DATA , ""ExifMnoteCanon"" , ""ShortMakerNote"" ) ; break ; } n -> entries [ tcount ] . tag = exif_get_short ( buf + o , n -> order ) ; n -> entries [ tcount ] . format = exif_get_short ( buf + o + 2 , n -> order ) ; n -> entries [ tcount ] . components = exif_get_long ( buf + o + 4 , n -> order ) ; n -> entries [ tcount ] . order = n -> order ; exif_log ( ne -> log , EXIF_LOG_CODE_DEBUG , ""ExifMnoteCanon"" , ""Loadingentry0x%x(\'%s\')..."" , n -> entries [ tcount ] . tag , mnote_canon_tag_get_name ( n -> entries [ tcount ] . tag ) ) ; if ( exif_format_get_size ( n -> entries [ tcount ] . format ) && buf_size / exif_format_get_size ( n -> entries [ tcount ] . format ) < n -> entries [ tcount ] . components ) { exif_log ( ne -> log , EXIF_LOG_CODE_CORRUPT_DATA , ""ExifMnoteCanon"" , ""Tagsizeoverflowdetected(%u*%lu)"" , exif_format_get_size ( n -> entries [ tcount ] . format ) , n -> entries [ tcount ] . components ) ; continue ; } s = exif_format_get_size ( n -> entries [ tcount ] . format ) * n -> entries [ tcount ] . components ; n -> entries [ tcount ] . size = s ; if ( ! s ) { exif_log ( ne -> log , EXIF_LOG_CODE_CORRUPT_DATA , ""ExifMnoteCanon"" , ""Invalidzero-lengthtagsize"" ) ; continue ; } else { size_t dataofs = o + 8 ; if ( s > 4 ) dataofs = exif_get_long ( buf + dataofs , n -> order ) + 6 ; if ( CHECKOVERFLOW ( dataofs , buf_size , s ) ) { exif_log ( ne -> log , EXIF_LOG_CODE_DEBUG , ""ExifMnoteCanon"" , ""Tagdatapastendofbuffer(%u>%u)"" , ( unsigned ) ( dataofs + s ) , buf_size ) ; continue ; } n -> entries [ tcount ] . data = exif_mem_alloc ( ne -> mem , s ) ; if ( ! n -> entries [ tcount ] . data ) { EXIF_LOG_NO_MEMORY ( ne -> log , ""ExifMnoteCanon"" , s ) ; continue ; } memcpy ( n -> entries [ tcount ] . data , buf + dataofs , s ) ; } ++ tcount ; } n -> count = tcount ; } "," o , datao ; long failsafe_size = 0 ) ; } failsafe_size += mnote_canon_entry_count_values ( & n -> entries [ tcount ] ) ; if ( failsafe_size > FAILSAFE_SIZE_MAX ) { exif_mem_free ( ne -> mem , n -> entries [ tcount ] . data ) ; exif_log ( ne -> log , EXIF_LOG_CODE_CORRUPT_DATA , ""ExifMnoteCanon"" , ""Failsafetagsizeoverflow(%lu>%ld)"" , failsafe_size , FAILSAFE_SIZE_MAX ) ; break ; } ",libexif@libexif/e6a38a1a23ba94d139b1fa2cd4519fdcfe3c9bab,CVE-2020-13114,https://github.com/libexif/libexif/commit/e6a38a1a23ba94d139b1fa2cd4519fdcfe3c9bab,2020-05-21T16:15Z 643,CWE-000,"CWE-000 OM_uint32 kg_unseal_iov ( OM_uint32 * minor_status , gss_ctx_id_t context_handle , int * conf_state , gss_qop_t * qop_state , gss_iov_buffer_desc * iov , int iov_count , int toktype ) { krb5_gss_ctx_id_rec * ctx ; OM_uint32 code ; ctx = ( krb5_gss_ctx_id_rec * ) context_handle ; if ( ! ctx -> established ) { * minor_status = KG_CTX_INCOMPLETE ; return GSS_S_NO_CONTEXT ; } if ( kg_locate_iov ( iov , iov_count , GSS_IOV_BUFFER_TYPE_STREAM ) != NULL ) { code = kg_unseal_stream_iov ( minor_status , ctx , conf_state , qop_state , iov , iov_count , toktype ) ; } else { code = kg_unseal_iov_token ( minor_status , ctx , conf_state , qop_state , iov , iov_count , toktype ) ; } return code ; } "," ; if ( ctx -> terminated || ",krb5@krb5/82dc33da50338ac84c7b4102dc6513d897d0506a,CVE-2014-5352,https://github.com/krb5/krb5/commit/82dc33da50338ac84c7b4102dc6513d897d0506a,2015-02-19T11:59Z 644,CWE-399,"CWE-399 static void hugetlbfs_put_super ( struct super_block * sb ) { struct hugetlbfs_sb_info * sbi = HUGETLBFS_SB ( sb ) ; if ( sbi ) { sb -> s_fs_info = NULL ; kfree ( sbi ) ; } } "," = NULL ; if ( sbi -> spool ) hugepage_put_subpool ( sbi -> spool ) ; ",torvalds@linux/90481622d75715bfcb68501280a917dbfe516029,CVE-2012-2133,https://github.com/torvalds/linux/commit/90481622d75715bfcb68501280a917dbfe516029,2012-07-03T16:40Z 645,CWE-362,"CWE-362 static int myisamchk ( MI_CHECK * param , char * filename ) { int error , lock_type , recreate ; int rep_quick = param -> testflag & ( T_QUICK | T_FORCE_UNIQUENESS ) ; MI_INFO * info ; File datafile ; char llbuff [ 22 ] , llbuff2 [ 22 ] ; my_bool state_updated = 0 ; MYISAM_SHARE * share ; DBUG_ENTER ( ""myisamchk"" ) ; param -> out_flag = error = param -> warning_printed = param -> error_printed = recreate = 0 ; datafile = 0 ; param -> isam_file_name = filename ; if ( ! ( info = mi_open ( filename , ( param -> testflag & ( T_DESCRIPT | T_READONLY ) ) ? O_RDONLY : O_RDWR , HA_OPEN_FOR_REPAIR | ( ( param -> testflag & T_WAIT_FOREVER ) ? HA_OPEN_WAIT_IF_LOCKED : ( param -> testflag & T_DESCRIPT ) ? HA_OPEN_IGNORE_IF_LOCKED : HA_OPEN_ABORT_IF_LOCKED ) ) ) ) { param -> error_printed = 1 ; switch ( my_errno ) { case HA_ERR_CRASHED : mi_check_print_error ( param , ""\'%s\'doesn\'thaveacorrectindexdefinition.Youneedtorecreateitbeforeyoucandoarepair"" , filename ) ; break ; case HA_ERR_NOT_A_TABLE : mi_check_print_error ( param , ""\'%s\'isnotaMyISAM-table"" , filename ) ; break ; case HA_ERR_CRASHED_ON_USAGE : mi_check_print_error ( param , ""\'%s\'ismarkedascrashed"" , filename ) ; break ; case HA_ERR_CRASHED_ON_REPAIR : mi_check_print_error ( param , ""\'%s\'ismarkedascrashedafterlastrepair"" , filename ) ; break ; case HA_ERR_OLD_FILE : mi_check_print_error ( param , ""\'%s\'isanoldtypeofMyISAM-table"" , filename ) ; break ; case HA_ERR_END_OF_FILE : mi_check_print_error ( param , ""Couldn\'treadcompleteheaderfrom\'%s\'"" , filename ) ; break ; case EAGAIN : mi_check_print_error ( param , ""\'%s\'islocked.Use-wtowaituntilunlocked"" , filename ) ; break ; case ENOENT : mi_check_print_error ( param , ""File\'%s\'doesn\'texist"" , filename ) ; break ; case EACCES : mi_check_print_error ( param , ""Youdon\'thavepermissiontouse\'%s\'"" , filename ) ; break ; default : mi_check_print_error ( param , ""%dwhenopeningMyISAM-table\'%s\'"" , my_errno , filename ) ; break ; } DBUG_RETURN ( 1 ) ; } share = info -> s ; share -> options &= ~ HA_OPTION_READ_ONLY_DATA ; share -> tot_locks -= share -> r_locks ; share -> r_locks = 0 ; if ( param -> testflag & ( T_FAST | T_CHECK_ONLY_CHANGED ) ) { my_bool need_to_check = mi_is_crashed ( info ) || share -> state . open_count != 0 ; if ( ( param -> testflag & ( T_REP_ANY | T_SORT_RECORDS ) ) && ( ( share -> state . changed & ( STATE_CHANGED | STATE_CRASHED | STATE_CRASHED_ON_REPAIR ) || ! ( param -> testflag & T_CHECK_ONLY_CHANGED ) ) ) ) need_to_check = 1 ; if ( info -> s -> base . keys && info -> state -> records ) { if ( ( param -> testflag & T_STATISTICS ) && ( share -> state . changed & STATE_NOT_ANALYZED ) ) need_to_check = 1 ; if ( ( param -> testflag & T_SORT_INDEX ) && ( share -> state . changed & STATE_NOT_SORTED_PAGES ) ) need_to_check = 1 ; if ( ( param -> testflag & T_REP_BY_SORT ) && ( share -> state . changed & STATE_NOT_OPTIMIZED_KEYS ) ) need_to_check = 1 ; } if ( ( param -> testflag & T_CHECK_ONLY_CHANGED ) && ( share -> state . changed & ( STATE_CHANGED | STATE_CRASHED | STATE_CRASHED_ON_REPAIR ) ) ) need_to_check = 1 ; if ( ! need_to_check ) { if ( ! ( param -> testflag & T_SILENT ) || param -> testflag & T_INFO ) printf ( ""MyISAMfile:%sisalreadychecked\\n"" , filename ) ; if ( mi_close ( info ) ) { mi_check_print_error ( param , ""%dwhenclosingMyISAM-table\'%s\'"" , my_errno , filename ) ; DBUG_RETURN ( 1 ) ; } DBUG_RETURN ( 0 ) ; } } if ( ( param -> testflag & ( T_REP_ANY | T_STATISTICS | T_SORT_RECORDS | T_SORT_INDEX ) ) && ( ( ( param -> testflag & T_UNPACK ) && share -> data_file_type == COMPRESSED_RECORD ) || mi_uint2korr ( share -> state . header . state_info_length ) != MI_STATE_INFO_SIZE || mi_uint2korr ( share -> state . header . base_info_length ) != MI_BASE_INFO_SIZE || mi_is_any_intersect_keys_active ( param -> keys_in_use , share -> base . keys , ~ share -> state . key_map ) || test_if_almost_full ( info ) || info -> s -> state . header . file_version [ 3 ] != myisam_file_magic [ 3 ] || ( set_collation && set_collation -> number != share -> state . header . language ) || myisam_block_size != MI_KEY_BLOCK_LENGTH ) ) { if ( set_collation ) param -> language = set_collation -> number ; if ( recreate_table ( param , & info , filename ) ) { ( void ) fprintf ( stderr , ""MyISAM-table\'%s\'isnotfixedbecauseoferrors\\n"" , filename ) ; return ( - 1 ) ; } recreate = 1 ; if ( ! ( param -> testflag & T_REP_ANY ) ) { param -> testflag |= T_REP_BY_SORT ; if ( ! ( param -> testflag & T_SILENT ) ) printf ( ""-\'%s\'hasoldtable-format.Recreatingindex\\n"" , filename ) ; rep_quick |= T_QUICK ; } share = info -> s ; share -> tot_locks -= share -> r_locks ; share -> r_locks = 0 ; } if ( param -> testflag & T_DESCRIPT ) { param -> total_files ++ ; param -> total_records += info -> state -> records ; param -> total_deleted += info -> state -> del ; descript ( param , info , filename ) ; } else { if ( ! stopwords_inited ++ ) ft_init_stopwords ( ) ; if ( ! ( param -> testflag & T_READONLY ) ) lock_type = F_WRLCK ; else lock_type = F_RDLCK ; if ( info -> lock_type == F_RDLCK ) info -> lock_type = F_UNLCK ; if ( _mi_readinfo ( info , lock_type , 0 ) ) { mi_check_print_error ( param , ""Can\'tlockindexfileof\'%s\',error:%d"" , filename , my_errno ) ; param -> error_printed = 0 ; goto end2 ; } mi_lock_database ( info , F_EXTRA_LCK ) ; datafile = info -> dfile ; if ( param -> testflag & ( T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX ) ) { if ( param -> testflag & T_REP_ANY ) { ulonglong tmp = share -> state . key_map ; mi_copy_keys_active ( share -> state . key_map , share -> base . keys , param -> keys_in_use ) ; if ( tmp != share -> state . key_map ) info -> update |= HA_STATE_CHANGED ; } if ( rep_quick && chk_del ( param , info , param -> testflag & ~ T_VERBOSE ) ) { if ( param -> testflag & T_FORCE_CREATE ) { rep_quick = 0 ; mi_check_print_info ( param , ""Creatingnewdatafile\\n"" ) ; } else { error = 1 ; mi_check_print_error ( param , ""Quick-recoveraborted;Runrecoverywithoutswitch\'q\'"" ) ; } } if ( ! error ) { if ( ( param -> testflag & ( T_REP_BY_SORT | T_REP_PARALLEL ) ) && ( mi_is_any_key_active ( share -> state . key_map ) || ( rep_quick && ! param -> keys_in_use && ! recreate ) ) && mi_test_if_sort_rep ( info , info -> state -> records , info -> s -> state . key_map , param -> force_sort ) ) { if ( param -> testflag & T_REP_BY_SORT ) error = mi_repair_by_sort ( param , info , filename , rep_quick ) ; else error = mi_repair_parallel ( param , info , filename , rep_quick ) ; state_updated = 1 ; } else if ( param -> testflag & T_REP_ANY ) error = mi_repair ( param , info , filename , rep_quick ) ; } if ( ! error && param -> testflag & T_SORT_RECORDS ) { # ifndef TO_BE_REMOVED if ( param -> out_flag & O_NEW_DATA ) { ( void ) my_close ( info -> dfile , MYF ( MY_WME ) ) ; error |= change_to_newfile ( filename , MI_NAME_DEXT , DATA_TMP_EXT , MYF ( 0 ) ) ; if ( mi_open_datafile ( info , info -> s , NULL , - 1 ) ) error = 1 ; param -> out_flag &= ~ O_NEW_DATA ; param -> read_cache . file = info -> dfile ; } # endif if ( ! error ) { uint key ; my_bool update_index = 1 ; for ( key = 0 ; key < share -> base . keys ; key ++ ) if ( share -> keyinfo [ key ] . flag & ( HA_BINARY_PACK_KEY | HA_FULLTEXT ) ) update_index = 0 ; error = mi_sort_records ( param , info , filename , param -> opt_sort_key , ( my_bool ) ! ( param -> testflag & T_REP ) , update_index ) ; datafile = info -> dfile ; if ( ! error && ! update_index ) { if ( param -> verbose ) puts ( ""Tablehadacompressedindex;Wemustnowrecreatetheindex"" ) ; error = mi_repair_by_sort ( param , info , filename , 1 ) ; } } } if ( ! error && param -> testflag & T_SORT_INDEX ) error = mi_sort_index ( param , info , filename ) ; if ( ! error ) share -> state . changed &= ~ ( STATE_CHANGED | STATE_CRASHED | STATE_CRASHED_ON_REPAIR ) ; else mi_mark_crashed ( info ) ; } else if ( ( param -> testflag & T_CHECK ) || ! ( param -> testflag & T_AUTO_INC ) ) { if ( ! ( param -> testflag & T_SILENT ) || param -> testflag & T_INFO ) printf ( ""CheckingMyISAMfile:%s\\n"" , filename ) ; if ( ! ( param -> testflag & T_SILENT ) ) printf ( ""Datarecords:%7sDeletedblocks:%7s\\n"" , llstr ( info -> state -> records , llbuff ) , llstr ( info -> state -> del , llbuff2 ) ) ; error = chk_status ( param , info ) ; mi_intersect_keys_active ( share -> state . key_map , param -> keys_in_use ) ; error = chk_size ( param , info ) ; if ( ! error || ! ( param -> testflag & ( T_FAST | T_FORCE_CREATE ) ) ) error |= chk_del ( param , info , param -> testflag ) ; if ( ( ! error || ( ! ( param -> testflag & ( T_FAST | T_FORCE_CREATE ) ) && ! param -> start_check_pos ) ) ) { error |= chk_key ( param , info ) ; if ( ! error && ( param -> testflag & ( T_STATISTICS | T_AUTO_INC ) ) ) error = update_state_info ( param , info , ( ( param -> testflag & T_STATISTICS ) ? UPDATE_STAT : 0 ) | ( ( param -> testflag & T_AUTO_INC ) ? UPDATE_AUTO_INC : 0 ) ) ; } if ( ( ! rep_quick && ! error ) || ! ( param -> testflag & ( T_FAST | T_FORCE_CREATE ) ) ) { if ( param -> testflag & ( T_EXTEND | T_MEDIUM ) ) ( void ) init_key_cache ( dflt_key_cache , opt_key_cache_block_size , param -> use_buffers , 0 , 0 ) ; ( void ) init_io_cache ( & param -> read_cache , datafile , ( uint ) param -> read_buffer_length , READ_CACHE , ( param -> start_check_pos ? param -> start_check_pos : share -> pack . header_length ) , 1 , MYF ( MY_WME ) ) ; lock_memory ( param ) ; if ( ( info -> s -> options & ( HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD ) ) || ( param -> testflag & ( T_EXTEND | T_MEDIUM ) ) ) error |= chk_data_link ( param , info , param -> testflag & T_EXTEND ) ; error |= flush_blocks ( param , share -> key_cache , share -> kfile ) ; ( void ) end_io_cache ( & param -> read_cache ) ; } if ( ! error ) { if ( ( share -> state . changed & STATE_CHANGED ) && ( param -> testflag & T_UPDATE_STATE ) ) info -> update |= HA_STATE_CHANGED | HA_STATE_ROW_CHANGED ; share -> state . changed &= ~ ( STATE_CHANGED | STATE_CRASHED | STATE_CRASHED_ON_REPAIR ) ; } else if ( ! mi_is_crashed ( info ) && ( param -> testflag & T_UPDATE_STATE ) ) { mi_mark_crashed ( info ) ; info -> update |= HA_STATE_CHANGED | HA_STATE_ROW_CHANGED ; } } } if ( ( param -> testflag & T_AUTO_INC ) || ( ( param -> testflag & T_REP_ANY ) && info -> s -> base . auto_key ) ) update_auto_increment_key ( param , info , ( my_bool ) ! test ( param -> testflag & T_AUTO_INC ) ) ; if ( ! ( param -> testflag & T_DESCRIPT ) ) { if ( info -> update & HA_STATE_CHANGED && ! ( param -> testflag & T_READONLY ) ) error |= update_state_info ( param , info , UPDATE_OPEN_COUNT | ( ( ( param -> testflag & T_REP_ANY ) ? UPDATE_TIME : 0 ) | ( state_updated ? UPDATE_STAT : 0 ) | ( ( param -> testflag & T_SORT_RECORDS ) ? UPDATE_SORT : 0 ) ) ) ; ( void ) lock_file ( param , share -> kfile , 0L , F_UNLCK , ""indexfile"" , filename ) ; info -> update &= ~ HA_STATE_CHANGED ; } mi_lock_database ( info , F_UNLCK ) ; end2 : if ( mi_close ( info ) ) { mi_check_print_error ( param , ""%dwhenclosingMyISAM-table\'%s\'"" , my_errno , filename ) ; DBUG_RETURN ( 1 ) ; } if ( error == 0 ) { if ( param -> out_flag & O_NEW_DATA ) error |= change_to_newfile ( filename , MI_NAME_DEXT , DATA_TMP_EXT , ( ( param -> testflag & T_BACKUP_DATA ) ? MYF ( MY_REDEL_MAKE_BACKUP ) : MYF ( 0 ) ) ) ; if ( param -> out_flag & O_NEW_INDEX ) error |= change_to_newfile ( filename , MI_NAME_IEXT , INDEX_TMP_EXT , MYF ( 0 ) ) ; } ( void ) fflush ( stdout ) ; ( void ) fflush ( stderr ) ; if ( param -> error_printed ) { if ( param -> testflag & ( T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX ) ) { ( void ) fprintf ( stderr , ""MyISAM-table\'%s\'isnotfixedbecauseoferrors\\n"" , filename ) ; if ( param -> testflag & T_REP_ANY ) ( void ) fprintf ( stderr , ""Tryfixingitbyusingthe--safe-recover(-o),the--force(-f)optionorbynotusingthe--quick(-q)flag\\n"" ) ; } else if ( ! ( param -> error_printed & 2 ) && ! ( param -> testflag & T_FORCE_CREATE ) ) ( void ) fprintf ( stderr , ""MyISAM-table\'%s\'iscorrupted\\nFixitusingswitch\\""-r\\""or\\""-o\\""\\n"" , filename ) ; } else if ( param -> warning_printed && ! ( param -> testflag & ( T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX | T_FORCE_CREATE ) ) ) ( void ) fprintf ( stderr , ""MyISAM-table\'%s\'isusablebutshouldbefixed\\n"" , filename ) ; ( void ) fflush ( stderr ) ; DBUG_RETURN ( error ) ; } "," filename , rep_quick , FALSE filename , rep_quick , FALSE filename , rep_quick , FALSE filename , 1 , FALSE info , filename , FALSE ",MariaDB@server/4e5473862e6852b0f3802b0cd0c6fa10b5253291,CVE-2016-6663,https://github.com/MariaDB/server/commit/4e5473862e6852b0f3802b0cd0c6fa10b5253291,2016-12-13T21:59Z 646,CWE-89,"CWE-89 char * curl_easy_unescape ( CURL * handle , const char * string , int length , int * olen ) { int alloc = ( length ? length : ( int ) strlen ( string ) ) + 1 ; char * ns = malloc ( alloc ) ; unsigned char in ; int strindex = 0 ; unsigned long hex ; CURLcode res ; if ( ! ns ) return NULL ; while ( -- alloc > 0 ) { in = * string ; if ( ( '%' == in ) && ISXDIGIT ( string [ 1 ] ) && ISXDIGIT ( string [ 2 ] ) ) { char hexstr [ 3 ] ; char * ptr ; hexstr [ 0 ] = string [ 1 ] ; hexstr [ 1 ] = string [ 2 ] ; hexstr [ 2 ] = 0 ; hex = strtoul ( hexstr , & ptr , 16 ) ; in = curlx_ultouc ( hex ) ; res = Curl_convert_from_network ( handle , & in , 1 ) ; if ( res ) { free ( ns ) ; return NULL ; } string += 2 ; alloc -= 2 ; } ns [ strindex ++ ] = in ; string ++ ; } ns [ strindex ] = 0 ; if ( olen ) * olen = strindex ; return ns ; } "," olen ) { char * str = NULL ; size_t inputlen = length ; size_t outputlen ; CURLcode res ; CURLcode res = Curl_urldecode ( handle , ( handle , string , inputlen , & str , & outputlen , FALSE ) ; if ( res ) return NULL ; if ( * olen = curlx_uztosi ( outputlen ) ; return str ; } ",bagder@curl/75ca568fa1c19de4c5358fed246686de8467c238,CVE-2012-0036,https://github.com/bagder/curl/commit/75ca568fa1c19de4c5358fed246686de8467c238,2012-04-13T20:55Z 647,CWE-416,"CWE-416 INST_HANDLER ( cpse ) { int r = ( buf [ 0 ] & 0xf ) | ( ( buf [ 1 ] & 0x2 ) << 3 ) ; int d = ( ( buf [ 0 ] >> 4 ) & 0xf ) | ( ( buf [ 1 ] & 0x1 ) << 4 ) ; RAnalOp next_op ; avr_op_analyze ( anal , & next_op , op -> addr + op -> size , buf + op -> size , len - op -> size , cpu ) ; r_strbuf_fini ( & next_op . esil ) ; op -> jump = op -> addr + next_op . size + 2 ; op -> cycles = 1 ; ESIL_A ( ""r%d,r%d,^,!,"" , r , d ) ; ESIL_A ( ""?{,%"" PFMT64d "",pc,=,},"" , op -> jump ) ; } "," ; RAnalOp next_op = { 0 } ",radare@radare2/9d348bcc2c4bbd3805e7eec97b594be9febbdf9a,CVE-2018-11383,https://github.com/radare/radare2/commit/9d348bcc2c4bbd3805e7eec97b594be9febbdf9a,2018-05-22T19:29Z 648,CWE-20,"CWE-20 static ssize_t generic_perform_write ( struct file * file , struct iov_iter * i , loff_t pos ) { struct address_space * mapping = file -> f_mapping ; const struct address_space_operations * a_ops = mapping -> a_ops ; long status = 0 ; ssize_t written = 0 ; unsigned int flags = 0 ; if ( segment_eq ( get_fs ( ) , KERNEL_DS ) ) flags |= AOP_FLAG_UNINTERRUPTIBLE ; do { struct page * page ; pgoff_t index ; unsigned long offset ; unsigned long bytes ; size_t copied ; void * fsdata ; offset = ( pos & ( PAGE_CACHE_SIZE - 1 ) ) ; index = pos >> PAGE_CACHE_SHIFT ; bytes = min_t ( unsigned long , PAGE_CACHE_SIZE - offset , iov_iter_count ( i ) ) ; again : if ( unlikely ( iov_iter_fault_in_readable ( i , bytes ) ) ) { status = - EFAULT ; break ; } status = a_ops -> write_begin ( file , mapping , pos , bytes , flags , & page , & fsdata ) ; if ( unlikely ( status ) ) break ; pagefault_disable ( ) ; copied = iov_iter_copy_from_user_atomic ( page , i , offset , bytes ) ; pagefault_enable ( ) ; flush_dcache_page ( page ) ; status = a_ops -> write_end ( file , mapping , pos , bytes , copied , page , fsdata ) ; if ( unlikely ( status < 0 ) ) break ; copied = status ; cond_resched ( ) ; if ( unlikely ( copied == 0 ) ) { bytes = min_t ( unsigned long , PAGE_CACHE_SIZE - offset , iov_iter_single_seg_count ( i ) ) ; goto again ; } iov_iter_advance ( i , copied ) ; pos += copied ; written += copied ; balance_dirty_pages_ratelimited ( mapping ) ; } while ( iov_iter_count ( i ) ) ; return written ? written : status ; } "," ( ) ; iov_iter_advance ( i , copied ) ; again ; } pos += copied ",torvalds@linux/124d3b7041f9a0ca7c43a6293e1cae4576c32fd5,CVE-2008-7316,https://github.com/torvalds/linux/commit/124d3b7041f9a0ca7c43a6293e1cae4576c32fd5,2016-05-02T10:59Z 649,CWE-119,"CWE-119 static void dma_rx ( struct b43_dmaring * ring , int * slot ) { const struct b43_dma_ops * ops = ring -> ops ; struct b43_dmadesc_generic * desc ; struct b43_dmadesc_meta * meta ; struct b43_rxhdr_fw4 * rxhdr ; struct sk_buff * skb ; u16 len ; int err ; dma_addr_t dmaaddr ; desc = ops -> idx2desc ( ring , * slot , & meta ) ; sync_descbuffer_for_cpu ( ring , meta -> dmaaddr , ring -> rx_buffersize ) ; skb = meta -> skb ; rxhdr = ( struct b43_rxhdr_fw4 * ) skb -> data ; len = le16_to_cpu ( rxhdr -> frame_len ) ; if ( len == 0 ) { int i = 0 ; do { udelay ( 2 ) ; barrier ( ) ; len = le16_to_cpu ( rxhdr -> frame_len ) ; } while ( len == 0 && i ++ < 5 ) ; if ( unlikely ( len == 0 ) ) { dmaaddr = meta -> dmaaddr ; goto drop_recycle_buffer ; } } if ( unlikely ( b43_rx_buffer_is_poisoned ( ring , skb ) ) ) { b43dbg ( ring -> dev -> wl , ""DMARX:Droppingpoisonedbuffer.\\n"" ) ; dmaaddr = meta -> dmaaddr ; goto drop_recycle_buffer ; } if ( unlikely ( len > ring -> rx_buffersize ) ) { int cnt = 0 ; s32 tmp = len ; while ( 1 ) { desc = ops -> idx2desc ( ring , * slot , & meta ) ; b43_poison_rx_buffer ( ring , meta -> skb ) ; sync_descbuffer_for_device ( ring , meta -> dmaaddr , ring -> rx_buffersize ) ; * slot = next_slot ( ring , * slot ) ; cnt ++ ; tmp -= ring -> rx_buffersize ; if ( tmp <= 0 ) break ; } b43err ( ring -> dev -> wl , ""DMARXbuffertoosmall"" ""(len:%u,buffer:%u,nr-dropped:%d)\\n"" , len , ring -> rx_buffersize , cnt ) ; goto drop ; } dmaaddr = meta -> dmaaddr ; err = setup_rx_descbuffer ( ring , desc , meta , GFP_ATOMIC ) ; if ( unlikely ( err ) ) { b43dbg ( ring -> dev -> wl , ""DMARX:setup_rx_descbuffer()failed\\n"" ) ; goto drop_recycle_buffer ; } unmap_descbuffer ( ring , dmaaddr , ring -> rx_buffersize , 0 ) ; skb_put ( skb , len + ring -> frameoffset ) ; skb_pull ( skb , ring -> frameoffset ) ; b43_rx ( ring -> dev , skb , rxhdr ) ; drop : return ; drop_recycle_buffer : b43_poison_rx_buffer ( ring , skb ) ; sync_descbuffer_for_device ( ring , dmaaddr , ring -> rx_buffersize ) ; } "," unlikely ( len + ring -> frameoffset ",torvalds@linux/c85ce65ecac078ab1a1835c87c4a6319cf74660a,CVE-2011-3359,https://github.com/torvalds/linux/commit/c85ce65ecac078ab1a1835c87c4a6319cf74660a,2012-05-24T23:55Z 650,CWE-415,"CWE-415 void init_usm ( void ) { struct snmp_secmod_def * def ; char * type ; DEBUGMSGTL ( ( ""init_usm"" , ""unit_usm:%"" NETSNMP_PRIo ""u%"" NETSNMP_PRIo ""u\\n"" , usmNoPrivProtocol [ 0 ] , usmNoPrivProtocol [ 1 ] ) ) ; sc_init ( ) ; def = SNMP_MALLOC_STRUCT ( snmp_secmod_def ) ; if ( def == NULL ) return ; def -> encode_reverse = usm_secmod_rgenerate_out_msg ; def -> encode_forward = usm_secmod_generate_out_msg ; def -> decode = usm_secmod_process_in_msg ; def -> pdu_free_state_ref = usm_free_usmStateReference ; def -> session_setup = usm_session_init ; def -> handle_report = usm_handle_report ; def -> probe_engineid = usm_discover_engineid ; def -> post_probe_engineid = usm_create_user_from_session_hook ; if ( register_sec_mod ( USM_SEC_MODEL_NUMBER , ""usm"" , def ) != SNMPERR_SUCCESS ) { SNMP_FREE ( def ) ; snmp_log ( LOG_ERR , ""couldnotregisterusmsecmod\\n"" ) ; return ; } snmp_register_callback ( SNMP_CALLBACK_LIBRARY , SNMP_CALLBACK_POST_PREMIB_READ_CONFIG , init_usm_post_config , NULL ) ; snmp_register_callback ( SNMP_CALLBACK_LIBRARY , SNMP_CALLBACK_SHUTDOWN , deinit_usm_post_config , NULL ) ; snmp_register_callback ( SNMP_CALLBACK_LIBRARY , SNMP_CALLBACK_SHUTDOWN , free_engineID , NULL ) ; register_config_handler ( ""snmp"" , ""defAuthType"" , snmpv3_authtype_conf , NULL , ""MD5|SHA|SHA-512|SHA-384|SHA-256|SHA-224"" ) ; register_config_handler ( ""snmp"" , ""defPrivType"" , snmpv3_privtype_conf , NULL , ""DES"" # ifdef HAVE_AES ""|AES|AES-128"" # ifdef NETSNMP_DRAFT_BLUMENTHAL_AES_04 ""|AES-192|AES-256"" # endif # else ""(AESsupportnotavailable)"" # endif ) ; snmp_register_callback ( SNMP_CALLBACK_LIBRARY , SNMP_CALLBACK_SHUTDOWN , free_enginetime_on_shutdown , NULL ) ; type = netsnmp_ds_get_string ( NETSNMP_DS_LIBRARY_ID , NETSNMP_DS_LIB_APPTYPE ) ; register_config_handler ( type , ""userSetAuthPass"" , usm_set_password , NULL , NULL ) ; register_config_handler ( type , ""userSetPrivPass"" , usm_set_password , NULL , NULL ) ; register_config_handler ( type , ""userSetAuthKey"" , usm_set_password , NULL , NULL ) ; register_config_handler ( type , ""userSetPrivKey"" , usm_set_password , NULL , NULL ) ; register_config_handler ( type , ""userSetAuthLocalKey"" , usm_set_password , NULL , NULL ) ; register_config_handler ( type , ""userSetPrivLocalKey"" , usm_set_password , NULL , NULL ) ; } "," ; def -> pdu_clone = usm_clone ; def -> ",net-snmp@net-snmp/5f881d3bf24599b90d67a45cae7a3eb099cd71c9,CVE-2019-20892,https://github.com/net-snmp/net-snmp/commit/5f881d3bf24599b90d67a45cae7a3eb099cd71c9,2020-06-25T10:15Z 651,CWE-119,"CWE-119 void traverse_commit_list ( struct rev_info * revs , show_commit_fn show_commit , show_object_fn show_object , void * data ) { int i ; struct commit * commit ; struct strbuf base ; strbuf_init ( & base , PATH_MAX ) ; while ( ( commit = get_revision ( revs ) ) != NULL ) { if ( commit -> tree ) add_pending_tree ( revs , commit -> tree ) ; show_commit ( commit , data ) ; } for ( i = 0 ; i < revs -> pending . nr ; i ++ ) { struct object_array_entry * pending = revs -> pending . objects + i ; struct object * obj = pending -> item ; const char * name = pending -> name ; const char * path = pending -> path ; if ( obj -> flags & ( UNINTERESTING | SEEN ) ) continue ; if ( obj -> type == OBJ_TAG ) { obj -> flags |= SEEN ; show_object ( obj , NULL , name , data ) ; continue ; } if ( ! path ) path = """" ; if ( obj -> type == OBJ_TREE ) { process_tree ( revs , ( struct tree * ) obj , show_object , & base , path , data ) ; continue ; } if ( obj -> type == OBJ_BLOB ) { process_blob ( revs , ( struct blob * ) obj , show_object , NULL , path , data ) ; continue ; } die ( ""unknownpendingobject%s(%s)"" , oid_to_hex ( & obj -> oid ) , name ) ; } object_array_clear ( & revs -> pending ) ; strbuf_release ( & base ) ; } "," ( obj , name , data , show_object , & base , path , ",git@git/de1e67d0703894cb6ea782e36abb63976ab07e60,CVE-2016-2324,https://github.com/git/git/commit/de1e67d0703894cb6ea782e36abb63976ab07e60,2016-04-08T14:59Z 652,CWE-674,"CWE-674 int regexec ( Reprog * prog , const char * sp , Resub * sub , int eflags ) { Resub scratch ; int i ; if ( ! sub ) sub = & scratch ; sub -> nsub = prog -> nsub ; for ( i = 0 ; i < MAXSUB ; ++ i ) sub -> sub [ i ] . sp = sub -> sub [ i ] . ep = NULL ; return ! match ( prog -> start , sp , sp , prog -> flags | eflags , sub ) ; } "," NULL ; return match ( prog eflags , sub , 0 ",ccxvii@mujs/00d4606c3baf813b7b1c176823b2729bf51002a2,CVE-2019-11413,https://github.com/ccxvii/mujs/commit/00d4606c3baf813b7b1c176823b2729bf51002a2,2019-04-22T11:29Z 653,CWE-119,"CWE-119 static int kempf_decode_tile ( G2MContext * c , int tile_x , int tile_y , const uint8_t * src , int src_size ) { int width , height ; int hdr , zsize , npal , tidx = - 1 , ret ; int i , j ; const uint8_t * src_end = src + src_size ; uint8_t pal [ 768 ] , transp [ 3 ] ; uLongf dlen = ( c -> tile_width + 1 ) * c -> tile_height ; int sub_type ; int nblocks , cblocks , bstride ; int bits , bitbuf , coded ; uint8_t * dst = c -> framebuf + tile_x * c -> tile_width * 3 + tile_y * c -> tile_height * c -> framebuf_stride ; if ( src_size < 2 ) return AVERROR_INVALIDDATA ; width = FFMIN ( c -> width - tile_x * c -> tile_width , c -> tile_width ) ; height = FFMIN ( c -> height - tile_y * c -> tile_height , c -> tile_height ) ; hdr = * src ++ ; sub_type = hdr >> 5 ; if ( sub_type == 0 ) { int j ; memcpy ( transp , src , 3 ) ; src += 3 ; for ( j = 0 ; j < height ; j ++ , dst += c -> framebuf_stride ) for ( i = 0 ; i < width ; i ++ ) memcpy ( dst + i * 3 , transp , 3 ) ; return 0 ; } else if ( sub_type == 1 ) { return jpg_decode_data ( & c -> jc , width , height , src , src_end - src , dst , c -> framebuf_stride , NULL , 0 , 0 , 0 ) ; } if ( sub_type != 2 ) { memcpy ( transp , src , 3 ) ; src += 3 ; } npal = * src ++ + 1 ; memcpy ( pal , src , npal * 3 ) ; src += npal * 3 ; if ( sub_type != 2 ) { for ( i = 0 ; i < npal ; i ++ ) { if ( ! memcmp ( pal + i * 3 , transp , 3 ) ) { tidx = i ; break ; } } } if ( src_end - src < 2 ) return 0 ; zsize = ( src [ 0 ] << 8 ) | src [ 1 ] ; src += 2 ; if ( src_end - src < zsize ) return AVERROR_INVALIDDATA ; ret = uncompress ( c -> kempf_buf , & dlen , src , zsize ) ; if ( ret ) return AVERROR_INVALIDDATA ; src += zsize ; if ( sub_type == 2 ) { kempf_restore_buf ( c -> kempf_buf , dlen , dst , c -> framebuf_stride , NULL , 0 , width , height , pal , npal , tidx ) ; return 0 ; } nblocks = * src ++ + 1 ; cblocks = 0 ; bstride = FFALIGN ( width , 16 ) >> 4 ; bits = 0 ; for ( i = 0 ; i < ( FFALIGN ( height , 16 ) >> 4 ) ; i ++ ) { for ( j = 0 ; j < ( FFALIGN ( width , 16 ) >> 4 ) ; j ++ ) { if ( ! bits ) { bitbuf = * src ++ ; bits = 8 ; } coded = bitbuf & 1 ; bits -- ; bitbuf >>= 1 ; cblocks += coded ; if ( cblocks > nblocks ) return AVERROR_INVALIDDATA ; c -> kempf_flags [ j + i * bstride ] = coded ; } } memset ( c -> jpeg_tile , 0 , c -> tile_stride * height ) ; jpg_decode_data ( & c -> jc , width , height , src , src_end - src , c -> jpeg_tile , c -> tile_stride , c -> kempf_flags , bstride , nblocks , 0 ) ; kempf_restore_buf ( c -> kempf_buf , dlen , dst , c -> framebuf_stride , c -> jpeg_tile , c -> tile_stride , width , height , pal , npal , tidx ) ; return 0 ; } "," src < zsize + ( sub_type != 2 ) bits ) { if ( src >= src_end ) return AVERROR_INVALIDDATA ; ",FFmpeg@FFmpeg/2960576378d17d71cc8dccc926352ce568b5eec1,CVE-2013-4264,https://github.com/FFmpeg/FFmpeg/commit/2960576378d17d71cc8dccc926352ce568b5eec1,2013-11-23T17:55Z 654,CWE-119,"CWE-119 static void unqueue_me_pi ( struct futex_q * q ) { WARN_ON ( plist_node_empty ( & q -> list ) ) ; plist_del ( & q -> list , & q -> list . plist ) ; BUG_ON ( ! q -> pi_state ) ; free_pi_state ( q -> pi_state ) ; q -> pi_state = NULL ; spin_unlock ( q -> lock_ptr ) ; drop_futex_key_refs ( & q -> key ) ; } "," lock_ptr ) ; } ",torvalds@linux/7ada876a8703f23befbb20a7465a702ee39b1704,CVE-2014-0205,https://github.com/torvalds/linux/commit/7ada876a8703f23befbb20a7465a702ee39b1704,2014-09-28T19:55Z 655,CWE-269,"CWE-269 int fixExec2Error ( int action , u_char * var_val , u_char var_val_type , size_t var_val_len , u_char * statP , oid * name , size_t name_len ) { netsnmp_old_extend * exten = NULL ; unsigned int idx ; idx = name [ name_len - 1 ] - 1 ; exten = & compatability_entries [ idx ] ; # ifndef NETSNMP_NO_WRITE_SUPPORT switch ( action ) { case MODE_SET_RESERVE1 : if ( var_val_type != ASN_INTEGER ) { snmp_log ( LOG_ERR , ""Wrongtype!=int\\n"" ) ; return SNMP_ERR_WRONGTYPE ; } idx = * ( ( long * ) var_val ) ; if ( idx != 1 ) { snmp_log ( LOG_ERR , ""Wrongvalue!=1\\n"" ) ; return SNMP_ERR_WRONGVALUE ; } if ( ! exten || ! exten -> efix_entry ) { snmp_log ( LOG_ERR , ""Nocommandtorun\\n"" ) ; return SNMP_ERR_GENERR ; } return SNMP_ERR_NOERROR ; case MODE_SET_COMMIT : netsnmp_cache_check_and_reload ( exten -> efix_entry -> cache ) ; } # endif return SNMP_ERR_NOERROR ; } "," ] ; # if ! defined ( NETSNMP_NO_WRITE_SUPPORT ) && ENABLE_EXTEND_WRITE_ACCESS switch ( action ",net-snmp@net-snmp/77f6c60f57dba0aaea5d8ef1dd94bcd0c8e6d205,CVE-2020-15862,https://github.com/net-snmp/net-snmp/commit/77f6c60f57dba0aaea5d8ef1dd94bcd0c8e6d205,2020-08-20T01:17Z 656,CWE-125,"CWE-125 static ssize_t DecodePSDPixels ( const size_t number_compact_pixels , const unsigned char * compact_pixels , const ssize_t depth , const size_t number_pixels , unsigned char * pixels ) { # define CheckNumberCompactPixels if ( packets == 0 ) return ( i ) ; packets -- # define CheckNumberPixels ( count ) if ( ( ( ssize_t ) i + count ) > ( ssize_t ) number_pixels ) return ( i ) ; i += count int pixel ; register ssize_t i , j ; size_t length ; ssize_t packets ; packets = ( ssize_t ) number_compact_pixels ; for ( i = 0 ; ( packets > 1 ) && ( i < ( ssize_t ) number_pixels ) ; ) { packets -- ; length = ( size_t ) ( * compact_pixels ++ ) ; if ( length == 128 ) continue ; if ( length > 128 ) { length = 256 - length + 1 ; CheckNumberCompactPixels ; pixel = ( * compact_pixels ++ ) ; for ( j = 0 ; j < ( ssize_t ) length ; j ++ ) { switch ( depth ) { case 1 : { CheckNumberPixels ( 8 ) ; * pixels ++ = ( pixel >> 7 ) & 0x01 ? 0U : 255U ; * pixels ++ = ( pixel >> 6 ) & 0x01 ? 0U : 255U ; * pixels ++ = ( pixel >> 5 ) & 0x01 ? 0U : 255U ; * pixels ++ = ( pixel >> 4 ) & 0x01 ? 0U : 255U ; * pixels ++ = ( pixel >> 3 ) & 0x01 ? 0U : 255U ; * pixels ++ = ( pixel >> 2 ) & 0x01 ? 0U : 255U ; * pixels ++ = ( pixel >> 1 ) & 0x01 ? 0U : 255U ; * pixels ++ = ( pixel >> 0 ) & 0x01 ? 0U : 255U ; break ; } case 2 : { CheckNumberPixels ( 4 ) ; * pixels ++ = ( unsigned char ) ( ( pixel >> 6 ) & 0x03 ) ; * pixels ++ = ( unsigned char ) ( ( pixel >> 4 ) & 0x03 ) ; * pixels ++ = ( unsigned char ) ( ( pixel >> 2 ) & 0x03 ) ; * pixels ++ = ( unsigned char ) ( ( pixel & 0x03 ) & 0x03 ) ; break ; } case 4 : { CheckNumberPixels ( 2 ) ; * pixels ++ = ( unsigned char ) ( ( pixel >> 4 ) & 0xff ) ; * pixels ++ = ( unsigned char ) ( ( pixel & 0x0f ) & 0xff ) ; break ; } default : { CheckNumberPixels ( 1 ) ; * pixels ++ = ( unsigned char ) pixel ; break ; } } } continue ; } length ++ ; for ( j = 0 ; j < ( ssize_t ) length ; j ++ ) { switch ( depth ) { case 1 : { CheckNumberPixels ( 8 ) ; * pixels ++ = ( * compact_pixels >> 7 ) & 0x01 ? 0U : 255U ; * pixels ++ = ( * compact_pixels >> 6 ) & 0x01 ? 0U : 255U ; * pixels ++ = ( * compact_pixels >> 5 ) & 0x01 ? 0U : 255U ; * pixels ++ = ( * compact_pixels >> 4 ) & 0x01 ? 0U : 255U ; * pixels ++ = ( * compact_pixels >> 3 ) & 0x01 ? 0U : 255U ; * pixels ++ = ( * compact_pixels >> 2 ) & 0x01 ? 0U : 255U ; * pixels ++ = ( * compact_pixels >> 1 ) & 0x01 ? 0U : 255U ; * pixels ++ = ( * compact_pixels >> 0 ) & 0x01 ? 0U : 255U ; break ; } case 2 : { CheckNumberPixels ( 4 ) ; * pixels ++ = ( * compact_pixels >> 6 ) & 0x03 ; * pixels ++ = ( * compact_pixels >> 4 ) & 0x03 ; * pixels ++ = ( * compact_pixels >> 2 ) & 0x03 ; * pixels ++ = ( * compact_pixels & 0x03 ) & 0x03 ; break ; } case 4 : { CheckNumberPixels ( 2 ) ; * pixels ++ = ( * compact_pixels >> 4 ) & 0xff ; * pixels ++ = ( * compact_pixels & 0x0f ) & 0xff ; break ; } default : { CheckNumberPixels ( 1 ) ; * pixels ++ = ( * compact_pixels ) ; break ; } } CheckNumberCompactPixels ; compact_pixels ++ ; } } return ( i ) ; } "," ++ ) { CheckNumberCompactPixels ; ; } } compact_pixels ++ ; ",ImageMagick@ImageMagick/30eec879c8b446b0ea9a3bb0da1a441cc8482bc4,CVE-2016-7521,https://github.com/ImageMagick/ImageMagick/commit/30eec879c8b446b0ea9a3bb0da1a441cc8482bc4,2017-04-20T18:59Z 657,CWE-20,"CWE-20 int snd_timer_close ( struct snd_timer_instance * timeri ) { struct snd_timer * timer = NULL ; struct snd_timer_instance * slave , * tmp ; if ( snd_BUG_ON ( ! timeri ) ) return - ENXIO ; snd_timer_stop ( timeri ) ; if ( timeri -> flags & SNDRV_TIMER_IFLG_SLAVE ) { spin_lock_irq ( & slave_active_lock ) ; while ( timeri -> flags & SNDRV_TIMER_IFLG_CALLBACK ) { spin_unlock_irq ( & slave_active_lock ) ; udelay ( 10 ) ; spin_lock_irq ( & slave_active_lock ) ; } spin_unlock_irq ( & slave_active_lock ) ; mutex_lock ( & register_mutex ) ; list_del ( & timeri -> open_list ) ; mutex_unlock ( & register_mutex ) ; } else { timer = timeri -> timer ; if ( snd_BUG_ON ( ! timer ) ) goto out ; spin_lock_irq ( & timer -> lock ) ; while ( timeri -> flags & SNDRV_TIMER_IFLG_CALLBACK ) { spin_unlock_irq ( & timer -> lock ) ; udelay ( 10 ) ; spin_lock_irq ( & timer -> lock ) ; } spin_unlock_irq ( & timer -> lock ) ; mutex_lock ( & register_mutex ) ; list_del ( & timeri -> open_list ) ; if ( timer && list_empty ( & timer -> open_list_head ) && timer -> hw . close ) timer -> hw . close ( timer ) ; list_for_each_entry_safe ( slave , tmp , & timeri -> slave_list_head , open_list ) { spin_lock_irq ( & slave_active_lock ) ; _snd_timer_stop ( slave , 1 , SNDRV_TIMER_EVENT_RESOLUTION ) ; list_move_tail ( & slave -> open_list , & snd_timer_slave_list ) ; slave -> master = NULL ; slave -> timer = NULL ; spin_unlock_irq ( & slave_active_lock ) ; } mutex_unlock ( & register_mutex ) ; } out : if ( timeri -> private_free ) timeri -> private_free ( timeri ) ; kfree ( timeri -> owner ) ; kfree ( timeri ) ; if ( timer ) module_put ( timer -> module ) ; return 0 ; } "," timer ) ; spin_lock_irq ( & slave_active_lock ) ; spin_lock ( & timer -> lock ) ; open_list ) { list_move_tail ( & = NULL ; list_del_init ( & slave -> ack_list ) ; list_del_init ( & slave -> active_list ) ; } spin_unlock ( & timer -> lock ) ; slave_active_lock ) ; mutex_unlock ( & ",torvalds@linux/b5a663aa426f4884c71cd8580adae73f33570f0d,CVE-2016-2548,https://github.com/torvalds/linux/commit/b5a663aa426f4884c71cd8580adae73f33570f0d,2016-04-27T17:59Z 658,CWE-125,"CWE-125 static int print_ccp_config_options ( netdissect_options * ndo , const u_char * p , int length ) { int len , opt ; if ( length < 2 ) return 0 ; ND_TCHECK2 ( * p , 2 ) ; len = p [ 1 ] ; opt = p [ 0 ] ; if ( length < len ) return 0 ; if ( len < 2 ) { ND_PRINT ( ( ndo , ""\\n\\t%sOption(0x%02x),length%u(lengthbogus,shouldbe>=2)"" , tok2str ( ccpconfopts_values , ""Unknown"" , opt ) , opt , len ) ) ; return 0 ; } ND_PRINT ( ( ndo , ""\\n\\t%sOption(0x%02x),length%u"" , tok2str ( ccpconfopts_values , ""Unknown"" , opt ) , opt , len ) ) ; switch ( opt ) { case CCPOPT_BSDCOMP : if ( len < 3 ) { ND_PRINT ( ( ndo , ""(lengthbogus,shouldbe>=3)"" ) ) ; return len ; } ND_TCHECK2 ( * ( p + 2 ) , 1 ) ; ND_PRINT ( ( ndo , "":Version:%u,DictionaryBits:%u"" , p [ 2 ] >> 5 , p [ 2 ] & 0x1f ) ) ; break ; case CCPOPT_MVRCA : if ( len < 4 ) { ND_PRINT ( ( ndo , ""(lengthbogus,shouldbe>=4)"" ) ) ; return len ; } ND_TCHECK2 ( * ( p + 2 ) , 1 ) ; ND_PRINT ( ( ndo , "":Features:%u,PxP:%s,History:%u,#CTX-ID:%u"" , ( p [ 2 ] & 0xc0 ) >> 6 , ( p [ 2 ] & 0x20 ) ? ""Enabled"" : ""Disabled"" , p [ 2 ] & 0x1f , p [ 3 ] ) ) ; break ; case CCPOPT_DEFLATE : if ( len < 4 ) { ND_PRINT ( ( ndo , ""(lengthbogus,shouldbe>=4)"" ) ) ; return len ; } ND_TCHECK2 ( * ( p + 2 ) , 1 ) ; ND_PRINT ( ( ndo , "":Window:%uK,Method:%s(0x%x),MBZ:%u,CHK:%u"" , ( p [ 2 ] & 0xf0 ) >> 4 , ( ( p [ 2 ] & 0x0f ) == 8 ) ? ""zlib"" : ""unknown"" , p [ 2 ] & 0x0f , ( p [ 3 ] & 0xfc ) >> 2 , p [ 3 ] & 0x03 ) ) ; break ; # if 0 case CCPOPT_OUI : case CCPOPT_PRED1 : case CCPOPT_PRED2 : case CCPOPT_PJUMP : case CCPOPT_HPPPC : case CCPOPT_STACLZS : case CCPOPT_MPPC : case CCPOPT_GFZA : case CCPOPT_V42BIS : case CCPOPT_LZSDCP : case CCPOPT_DEC : case CCPOPT_RESV : break ; # endif default : if ( ndo -> ndo_vflag < 2 ) print_unknown_data ( ndo , & p [ 2 ] , ""\\n\\t"" , len - 2 ) ; break ; } if ( ndo -> ndo_vflag > 1 ) print_unknown_data ( ndo , & p [ 2 ] , ""\\n\\t"" , len - 2 ) ; return len ; trunc : ND_PRINT ( ( ndo , ""[|ccp]"" ) ) ; return 0 ; } "," len ; } ND_TCHECK ( p [ 2 ] ) ; ND_PRINT len ; } ND_TCHECK ( p [ 3 ] ) ; ND_PRINT len ; } ND_TCHECK ( p [ 3 ] ) ; ND_PRINT ",the-tcpdump-group@tcpdump/7029d15f148ef24bb7c6668bc640f5470d085e5a,CVE-2017-13029,https://github.com/the-tcpdump-group/tcpdump/commit/7029d15f148ef24bb7c6668bc640f5470d085e5a,2017-09-14T06:29Z 659,CWE-416,"CWE-416 R_API int r_core_bin_set_env ( RCore * r , RBinFile * binfile ) { RBinObject * binobj = binfile ? binfile -> o : NULL ; RBinInfo * info = binobj ? binobj -> info : NULL ; if ( info ) { int va = info -> has_va ; const char * arch = info -> arch ; ut16 bits = info -> bits ; ut64 baseaddr = r_bin_get_baddr ( r -> bin ) ; r_config_set_i ( r -> config , ""io.va"" , ( binobj -> info ) ? binobj -> info -> has_va : 0 ) ; r_config_set_i ( r -> config , ""bin.baddr"" , baseaddr ) ; r_config_set ( r -> config , ""asm.arch"" , arch ) ; r_config_set_i ( r -> config , ""asm.bits"" , bits ) ; r_config_set ( r -> config , ""anal.arch"" , arch ) ; if ( info -> cpu && * info -> cpu ) { r_config_set ( r -> config , ""anal.cpu"" , info -> cpu ) ; } else { r_config_set ( r -> config , ""anal.cpu"" , arch ) ; } r_asm_use ( r -> assembler , arch ) ; r_core_bin_info ( r , R_CORE_BIN_ACC_ALL , R_CORE_BIN_SET , va , NULL , NULL ) ; r_core_bin_set_cur ( r , binfile ) ; return true ; } return false ; } "," -> has_va ; char * arch * arch = strdup ( info -> arch ) ; char * cpu = info -> cpu ? strdup ( info -> cpu ) : NULL ; ut16 bits ; if ( cpu && * cpu && * cpu ) { , ""anal.cpu"" , cpu ) ; r , binfile ) ; free ( cpu ) ; free ( arch ",radare@radare2/f85bc674b2a2256a364fe796351bc1971e106005,CVE-2017-9520,https://github.com/radare/radare2/commit/f85bc674b2a2256a364fe796351bc1971e106005,2017-06-08T14:29Z 660,CWE-000,"CWE-000 static void sas_probe_devices ( struct work_struct * work ) { struct domain_device * dev , * n ; struct sas_discovery_event * ev = to_sas_discovery_event ( work ) ; struct asd_sas_port * port = ev -> port ; clear_bit ( DISCE_PROBE , & port -> disc . pending ) ; list_for_each_entry ( dev , & port -> disco_list , disco_list_node ) { spin_lock_irq ( & port -> dev_list_lock ) ; list_add_tail ( & dev -> dev_list_node , & port -> dev_list ) ; spin_unlock_irq ( & port -> dev_list_lock ) ; } sas_probe_sata ( port ) ; list_for_each_entry_safe ( dev , n , & port -> disco_list , disco_list_node ) { int err ; err = sas_rphy_add ( dev -> rphy ) ; if ( err ) sas_fail_probe ( dev , __func__ , err ) ; else list_del_init ( & dev -> disco_list_node ) ; } } "," sas_probe_devices ( struct asd_sas_port * port ) { struct , * n ; list_for_each_entry ( ",torvalds@linux/0558f33c06bb910e2879e355192227a8e8f0219d,CVE-2017-18232,https://github.com/torvalds/linux/commit/0558f33c06bb910e2879e355192227a8e8f0219d,2018-03-15T04:29Z 661,CWE-119,"CWE-119 WORD32 ih264d_parse_islice ( dec_struct_t * ps_dec , UWORD16 u2_first_mb_in_slice ) { dec_pic_params_t * ps_pps = ps_dec -> ps_cur_pps ; dec_slice_params_t * ps_slice = ps_dec -> ps_cur_slice ; UWORD32 * pu4_bitstrm_buf = ps_dec -> ps_bitstrm -> pu4_buffer ; UWORD32 * pu4_bitstrm_ofst = & ps_dec -> ps_bitstrm -> u4_ofst ; UWORD32 u4_temp ; WORD32 i_temp ; WORD32 ret ; if ( ps_slice -> u1_nal_ref_idc != 0 ) { if ( ! ps_dec -> ps_dpb_cmds -> u1_dpb_commands_read ) ps_dec -> u4_bitoffset = ih264d_read_mmco_commands ( ps_dec ) ; else ps_dec -> ps_bitstrm -> u4_ofst += ps_dec -> u4_bitoffset ; } i_temp = ps_pps -> u1_pic_init_qp + ih264d_sev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; if ( ( i_temp < 0 ) || ( i_temp > 51 ) ) return ERROR_INV_RANGE_QP_T ; ps_slice -> u1_slice_qp = i_temp ; COPYTHECONTEXT ( ""SH:slice_qp_delta"" , ps_slice -> u1_slice_qp - ps_pps -> u1_pic_init_qp ) ; if ( ps_pps -> u1_deblocking_filter_parameters_present_flag == 1 ) { u4_temp = ih264d_uev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; COPYTHECONTEXT ( ""SH:disable_deblocking_filter_idc"" , u4_temp ) ; if ( u4_temp > SLICE_BOUNDARY_DBLK_DISABLED ) { return ERROR_INV_SLICE_HDR_T ; } ps_slice -> u1_disable_dblk_filter_idc = u4_temp ; if ( u4_temp != 1 ) { i_temp = ih264d_sev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) << 1 ; if ( ( MIN_DBLK_FIL_OFF > i_temp ) || ( i_temp > MAX_DBLK_FIL_OFF ) ) { return ERROR_INV_SLICE_HDR_T ; } ps_slice -> i1_slice_alpha_c0_offset = i_temp ; COPYTHECONTEXT ( ""SH:slice_alpha_c0_offset_div2"" , ps_slice -> i1_slice_alpha_c0_offset >> 1 ) ; i_temp = ih264d_sev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) << 1 ; if ( ( MIN_DBLK_FIL_OFF > i_temp ) || ( i_temp > MAX_DBLK_FIL_OFF ) ) { return ERROR_INV_SLICE_HDR_T ; } ps_slice -> i1_slice_beta_offset = i_temp ; COPYTHECONTEXT ( ""SH:slice_beta_offset_div2"" , ps_slice -> i1_slice_beta_offset >> 1 ) ; } else { ps_slice -> i1_slice_alpha_c0_offset = 0 ; ps_slice -> i1_slice_beta_offset = 0 ; } } else { ps_slice -> u1_disable_dblk_filter_idc = 0 ; ps_slice -> i1_slice_alpha_c0_offset = 0 ; ps_slice -> i1_slice_beta_offset = 0 ; } ps_dec -> u2_mv_2mb [ 0 ] = 0 ; ps_dec -> u2_mv_2mb [ 1 ] = 0 ; ps_dec -> u1_slice_header_done = 2 ; if ( ps_pps -> u1_entropy_coding_mode ) { SWITCHOFFTRACE ; SWITCHONTRACECABAC ; if ( ps_dec -> ps_cur_slice -> u1_mbaff_frame_flag ) { ps_dec -> pf_get_mb_info = ih264d_get_mb_info_cabac_mbaff ; } else ps_dec -> pf_get_mb_info = ih264d_get_mb_info_cabac_nonmbaff ; ret = ih264d_parse_islice_data_cabac ( ps_dec , ps_slice , u2_first_mb_in_slice ) ; if ( ret != OK ) return ret ; SWITCHONTRACE ; SWITCHOFFTRACECABAC ; } else { if ( ps_dec -> ps_cur_slice -> u1_mbaff_frame_flag ) { ps_dec -> pf_get_mb_info = ih264d_get_mb_info_cavlc_mbaff ; } else ps_dec -> pf_get_mb_info = ih264d_get_mb_info_cavlc_nonmbaff ; ret = ih264d_parse_islice_data_cavlc ( ps_dec , ps_slice , u2_first_mb_in_slice ) ; if ( ret != OK ) return ret ; } return OK ; } "," -> u1_dpb_commands_read ) { i_temp = ih264d_read_mmco_commands ( ps_dec ) ; if ( i_temp < 0 ) { return ERROR_DBP_MANAGER_T ; } -> u4_bitoffset = i_temp ; } else ps_dec -> ",external@libavc/943323f1d9d3dd5c2634deb26cbe72343ca6b3db,CVE-2016-0842,https://android.googlesource.com/platform/external/libavc/+/943323f1d9d3dd5c2634deb26cbe72343ca6b3db,2016-04-18T00:59Z 662,CWE-20,"CWE-20 static gboolean netscreen_read ( wtap * wth , int * err , gchar * * err_info , gint64 * data_offset ) { gint64 offset ; int pkt_len ; char line [ NETSCREEN_LINE_LENGTH ] ; char cap_int [ NETSCREEN_MAX_INT_NAME_LENGTH ] ; gboolean cap_dir ; char cap_dst [ 13 ] ; offset = netscreen_seek_next_packet ( wth , err , err_info , line ) ; if ( offset < 0 ) return FALSE ; pkt_len = parse_netscreen_rec_hdr ( & wth -> phdr , line , cap_int , & cap_dir , cap_dst , err , err_info ) ; if ( pkt_len == - 1 ) return FALSE ; if ( ! parse_netscreen_hex_dump ( wth -> fh , pkt_len , cap_int , cap_dst , & wth -> phdr , wth -> frame_buffer , err , err_info ) ) return FALSE ; if ( wth -> file_encap == WTAP_ENCAP_UNKNOWN ) wth -> file_encap = wth -> phdr . pkt_encap ; else { if ( wth -> file_encap != wth -> phdr . pkt_encap ) wth -> file_encap = WTAP_ENCAP_PER_PACKET ; } * data_offset = offset ; return TRUE ; } "," gint64 offset ; char line [ line [ NETSCREEN_LINE_LENGTH ] ; offset return FALSE ; if ( ! if ( ! parse_netscreen_packet ( wth -> wth -> fh , & wth wth -> frame_buffer , line ",wireshark@wireshark/6a140eca7b78b230f1f90a739a32257476513c78,CVE-2016-5357,https://github.com/wireshark/wireshark/commit/6a140eca7b78b230f1f90a739a32257476513c78,2016-08-07T16:59Z 663,CWE-119,"CWE-119 static int dtls1_process_buffered_records ( SSL * s ) { pitem * item ; item = pqueue_peek ( s -> d1 -> unprocessed_rcds . q ) ; if ( item ) { if ( s -> d1 -> unprocessed_rcds . epoch != s -> d1 -> r_epoch ) return ( 1 ) ; while ( pqueue_peek ( s -> d1 -> unprocessed_rcds . q ) ) { dtls1_get_unprocessed_record ( s ) ; if ( ! dtls1_process_record ( s ) ) return ( 0 ) ; dtls1_buffer_record ( s , & ( s -> d1 -> processed_rcds ) , s -> s3 -> rrec . seq_num ) ; } } s -> d1 -> processed_rcds . epoch = s -> d1 -> r_epoch ; s -> d1 -> unprocessed_rcds . epoch = s -> d1 -> r_epoch + 1 ; return ( 1 ) ; } "," 0 ) ; if ( . seq_num ) < 0 ) return - 1 ",openssl@openssl/103b171d8fc282ef435f8de9afbf7782e312961f,CVE-2015-0206,https://github.com/openssl/openssl/commit/103b171d8fc282ef435f8de9afbf7782e312961f,2015-01-09T02:59Z 664,CWE-415,"CWE-415 void DDGifSlurp ( GifInfo * info , bool decode , bool exitAfterFrame ) { GifRecordType RecordType ; GifByteType * ExtData ; int ExtFunction ; GifFileType * gifFilePtr ; gifFilePtr = info -> gifFilePtr ; uint_fast32_t lastAllocatedGCBIndex = 0 ; do { if ( DGifGetRecordType ( gifFilePtr , & RecordType ) == GIF_ERROR ) { break ; } bool isInitialPass = ! decode && ! exitAfterFrame ; switch ( RecordType ) { case IMAGE_DESC_RECORD_TYPE : if ( DGifGetImageDesc ( gifFilePtr , isInitialPass ) == GIF_ERROR ) { break ; } if ( isInitialPass ) { int_fast32_t widthOverflow = gifFilePtr -> Image . Width - gifFilePtr -> SWidth ; int_fast32_t heightOverflow = gifFilePtr -> Image . Height - gifFilePtr -> SHeight ; if ( widthOverflow > 0 || heightOverflow > 0 ) { gifFilePtr -> SWidth += widthOverflow ; gifFilePtr -> SHeight += heightOverflow ; } SavedImage * sp = & gifFilePtr -> SavedImages [ gifFilePtr -> ImageCount - 1 ] ; int_fast32_t topOverflow = gifFilePtr -> Image . Top + gifFilePtr -> Image . Height - gifFilePtr -> SHeight ; if ( topOverflow > 0 ) { sp -> ImageDesc . Top -= topOverflow ; } int_fast32_t leftOverflow = gifFilePtr -> Image . Left + gifFilePtr -> Image . Width - gifFilePtr -> SWidth ; if ( leftOverflow > 0 ) { sp -> ImageDesc . Left -= leftOverflow ; } if ( ! updateGCB ( info , & lastAllocatedGCBIndex ) ) { break ; } } if ( decode ) { int_fast32_t widthOverflow = gifFilePtr -> Image . Width - info -> originalWidth ; int_fast32_t heightOverflow = gifFilePtr -> Image . Height - info -> originalHeight ; const uint_fast32_t newRasterSize = gifFilePtr -> Image . Width * gifFilePtr -> Image . Height ; if ( newRasterSize > info -> rasterSize || widthOverflow > 0 || heightOverflow > 0 ) { void * tmpRasterBits = reallocarray ( info -> rasterBits , newRasterSize , sizeof ( GifPixelType ) ) ; if ( tmpRasterBits == NULL ) { gifFilePtr -> Error = D_GIF_ERR_NOT_ENOUGH_MEM ; break ; } info -> rasterBits = tmpRasterBits ; info -> rasterSize = newRasterSize ; } if ( gifFilePtr -> Image . Interlace ) { uint_fast16_t i , j ; uint_fast8_t InterlacedOffset [ ] = { 0 , 4 , 2 , 1 } ; uint_fast8_t InterlacedJumps [ ] = { 8 , 8 , 4 , 2 } ; for ( i = 0 ; i < 4 ; i ++ ) for ( j = InterlacedOffset [ i ] ; j < gifFilePtr -> Image . Height ; j += InterlacedJumps [ i ] ) { if ( DGifGetLine ( gifFilePtr , info -> rasterBits + j * gifFilePtr -> Image . Width , gifFilePtr -> Image . Width ) == GIF_ERROR ) break ; } } else { if ( DGifGetLine ( gifFilePtr , info -> rasterBits , gifFilePtr -> Image . Width * gifFilePtr -> Image . Height ) == GIF_ERROR ) { break ; } } if ( info -> sampleSize > 1 ) { unsigned char * dst = info -> rasterBits ; unsigned char * src = info -> rasterBits ; unsigned char * const srcEndImage = info -> rasterBits + gifFilePtr -> Image . Width * gifFilePtr -> Image . Height ; do { unsigned char * srcNextLineStart = src + gifFilePtr -> Image . Width * info -> sampleSize ; unsigned char * const srcEndLine = src + gifFilePtr -> Image . Width ; unsigned char * dstEndLine = dst + gifFilePtr -> Image . Width / info -> sampleSize ; do { * dst = * src ; dst ++ ; src += info -> sampleSize ; } while ( src < srcEndLine ) ; dst = dstEndLine ; src = srcNextLineStart ; } while ( src < srcEndImage ) ; } return ; } else { do { if ( DGifGetCodeNext ( gifFilePtr , & ExtData ) == GIF_ERROR ) { break ; } } while ( ExtData != NULL ) ; if ( exitAfterFrame ) { return ; } } break ; case EXTENSION_RECORD_TYPE : if ( DGifGetExtension ( gifFilePtr , & ExtFunction , & ExtData ) == GIF_ERROR ) { break ; } if ( isInitialPass ) { updateGCB ( info , & lastAllocatedGCBIndex ) ; if ( readExtensions ( ExtFunction , ExtData , info ) == GIF_ERROR ) { break ; } } while ( ExtData != NULL ) { if ( DGifGetExtensionNext ( gifFilePtr , & ExtData ) == GIF_ERROR ) { break ; } if ( isInitialPass && readExtensions ( ExtFunction , ExtData , info ) == GIF_ERROR ) { break ; } } break ; case TERMINATE_RECORD_TYPE : break ; default : break ; } } while ( RecordType != TERMINATE_RECORD_TYPE ) ; info -> rewindFunction ( info ) ; } "," decode ) { const uint_fast32_t newRasterSize Image . Height ; if ( newRasterSize == 0 ) { free ( info -> rasterBits ) ; info -> rasterBits = NULL ; info -> rasterSize = newRasterSize ; return ; } const int_fast32_t widthOverflow = gifFilePtr -> Image . Width - info -> originalWidth ; const int_fast32_t heightOverflow = gifFilePtr -> Image . Height - info -> originalHeight ",koral--@android-gif-drawable/cc5b4f8e43463995a84efd594f89a21f906c2d20,CVE-2019-11932,https://github.com/koral--/android-gif-drawable/commit/cc5b4f8e43463995a84efd594f89a21f906c2d20,2019-10-03T22:15Z 665,CWE-362,"CWE-362 long keyctl_read_key ( key_serial_t keyid , char __user * buffer , size_t buflen ) { struct key * key ; key_ref_t key_ref ; long ret ; key_ref = lookup_user_key ( keyid , 0 , 0 ) ; if ( IS_ERR ( key_ref ) ) { ret = - ENOKEY ; goto error ; } key = key_ref_to_ptr ( key_ref ) ; ret = key_permission ( key_ref , KEY_NEED_READ ) ; if ( ret == 0 ) goto can_read_key ; if ( ret != - EACCES ) goto error ; if ( ! is_key_possessed ( key_ref ) ) { ret = - EACCES ; goto error2 ; } can_read_key : ret = key_validate ( key ) ; if ( ret == 0 ) { ret = - EOPNOTSUPP ; if ( key -> type -> read ) { down_read ( & key -> sem ) ; ret = key -> type -> read ( key , buffer , buflen ) ; up_read ( & key -> sem ) ; } } error2 : key_put ( key ) ; error : return ret ; } "," : ret = - EOPNOTSUPP ; if ( key -> type -> read ) { down_read ( & key -> sem ) ; ret = == 0 ) ret = key -> type type -> read ( key , buffer , buflen ) ; up_read ( & key sem ) ; } error2 : ",torvalds@linux/b4a1b4f5047e4f54e194681125c74c0aa64d637d,CVE-2015-7550,https://github.com/torvalds/linux/commit/b4a1b4f5047e4f54e194681125c74c0aa64d637d,2016-02-08T03:59Z 666,CWE-287,"CWE-287 ret_t cherokee_validator_ldap_check ( cherokee_validator_ldap_t * ldap , cherokee_connection_t * conn ) { int re ; ret_t ret ; size_t size ; char * dn ; LDAPMessage * message ; LDAPMessage * first ; char * attrs [ ] = { LDAP_NO_ATTRS , NULL } ; cherokee_validator_ldap_props_t * props = VAL_LDAP_PROP ( ldap ) ; if ( ( conn -> validator == NULL ) || cherokee_buffer_is_empty ( & conn -> validator -> user ) ) return ret_error ; size = cherokee_buffer_cnt_cspn ( & conn -> validator -> user , 0 , ""*()"" ) ; if ( size != conn -> validator -> user . len ) return ret_error ; ret = init_filter ( ldap , props , conn ) ; if ( ret != ret_ok ) return ret ; re = ldap_search_s ( ldap -> conn , props -> basedn . buf , LDAP_SCOPE_SUBTREE , ldap -> filter . buf , attrs , 0 , & message ) ; if ( re != LDAP_SUCCESS ) { LOG_ERROR ( CHEROKEE_ERROR_VALIDATOR_LDAP_SEARCH , props -> filter . buf ? props -> filter . buf : """" ) ; return ret_error ; } TRACE ( ENTRIES , ""subtreesearch(%s):done\\n"" , ldap -> filter . buf ? ldap -> filter . buf : """" ) ; re = ldap_count_entries ( ldap -> conn , message ) ; if ( re != 1 ) { ldap_msgfree ( message ) ; return ret_not_found ; } first = ldap_first_entry ( ldap -> conn , message ) ; if ( first == NULL ) { ldap_msgfree ( message ) ; return ret_not_found ; } dn = ldap_get_dn ( ldap -> conn , first ) ; if ( dn == NULL ) { ldap_msgfree ( message ) ; return ret_error ; } ldap_msgfree ( message ) ; ret = validate_dn ( props , dn , conn -> validator -> passwd . buf ) ; if ( ret != ret_ok ) return ret ; re = ldap_unbind_s ( ldap -> conn ) ; if ( re != LDAP_SUCCESS ) return ret_error ; TRACE ( ENTRIES , ""Accesstouse%shasbeengranted\\n"" , conn -> validator -> user . buf ) ; return ret_ok ; } "," -> user ) || cherokee_buffer_is_empty ( & conn -> validator -> passwd ) ",cherokee@webserver/fbda667221c51f0aa476a02366e0cf66cb012f88,CVE-2014-4668,https://github.com/cherokee/webserver/commit/fbda667221c51f0aa476a02366e0cf66cb012f88,2014-07-02T04:14Z 667,CWE-252,"CWE-252 static Image * ReadPICTImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define ThrowPICTException ( exception , message ) { if ( tile_image != ( Image * ) NULL ) tile_image = DestroyImage ( tile_image ) ; if ( read_info != ( ImageInfo * ) NULL ) read_info = DestroyImageInfo ( read_info ) ; ThrowReaderException ( ( exception ) , ( message ) ) ; } char geometry [ MagickPathExtent ] , header_ole [ 4 ] ; Image * image , * tile_image ; ImageInfo * read_info ; int c , code ; MagickBooleanType jpeg , status ; PICTRectangle frame ; PICTPixmap pixmap ; Quantum index ; register Quantum * q ; register ssize_t i , x ; size_t extent , length ; ssize_t count , flags , j , version , y ; StringInfo * profile ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } read_info = ( ImageInfo * ) NULL ; tile_image = ( Image * ) NULL ; pixmap . bits_per_pixel = 0 ; pixmap . component_count = 0 ; header_ole [ 0 ] = ReadBlobByte ( image ) ; header_ole [ 1 ] = ReadBlobByte ( image ) ; header_ole [ 2 ] = ReadBlobByte ( image ) ; header_ole [ 3 ] = ReadBlobByte ( image ) ; if ( ! ( ( header_ole [ 0 ] == 0x50 ) && ( header_ole [ 1 ] == 0x49 ) && ( header_ole [ 2 ] == 0x43 ) && ( header_ole [ 3 ] == 0x54 ) ) ) for ( i = 0 ; i < 508 ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; ( void ) ReadBlobMSBShort ( image ) ; if ( ReadRectangle ( image , & frame ) == MagickFalse ) ThrowPICTException ( CorruptImageError , ""ImproperImageHeader"" ) ; while ( ( c = ReadBlobByte ( image ) ) == 0 ) ; if ( c != 0x11 ) ThrowPICTException ( CorruptImageError , ""ImproperImageHeader"" ) ; version = ( ssize_t ) ReadBlobByte ( image ) ; if ( version == 2 ) { c = ReadBlobByte ( image ) ; if ( c != 0xff ) ThrowPICTException ( CorruptImageError , ""ImproperImageHeader"" ) ; } else if ( version != 1 ) ThrowPICTException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ( frame . left < 0 ) || ( frame . right < 0 ) || ( frame . top < 0 ) || ( frame . bottom < 0 ) || ( frame . left >= frame . right ) || ( frame . top >= frame . bottom ) ) ThrowPICTException ( CorruptImageError , ""ImproperImageHeader"" ) ; flags = 0 ; image -> depth = 8 ; image -> columns = ( size_t ) ( frame . right - frame . left ) ; image -> rows = ( size_t ) ( frame . bottom - frame . top ) ; image -> resolution . x = DefaultResolution ; image -> resolution . y = DefaultResolution ; image -> units = UndefinedResolution ; if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) { ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status != MagickFalse ) status = ResetImagePixels ( image , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; jpeg = MagickFalse ; for ( code = 0 ; EOFBlob ( image ) == MagickFalse ; ) { if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; if ( ( version == 1 ) || ( ( TellBlob ( image ) % 2 ) != 0 ) ) code = ReadBlobByte ( image ) ; if ( version == 2 ) code = ReadBlobMSBSignedShort ( image ) ; if ( code < 0 ) break ; if ( code == 0 ) continue ; if ( code > 0xa1 ) { if ( image -> debug != MagickFalse ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""%04X:"" , code ) ; } else { if ( image -> debug != MagickFalse ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""%04X%s:%s"" , code , codes [ code ] . name , codes [ code ] . description ) ; switch ( code ) { case 0x01 : { length = ReadBlobMSBShort ( image ) ; if ( length != 0x000a ) { for ( i = 0 ; i < ( ssize_t ) ( length - 2 ) ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; break ; } if ( ReadRectangle ( image , & frame ) == MagickFalse ) ThrowPICTException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ( ( frame . left & 0x8000 ) != 0 ) || ( ( frame . top & 0x8000 ) != 0 ) ) break ; image -> columns = ( size_t ) ( frame . right - frame . left ) ; image -> rows = ( size_t ) ( frame . bottom - frame . top ) ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status != MagickFalse ) status = ResetImagePixels ( image , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; break ; } case 0x12 : case 0x13 : case 0x14 : { ssize_t pattern ; size_t height , width ; pattern = ( ssize_t ) ReadBlobMSBShort ( image ) ; for ( i = 0 ; i < 8 ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; if ( pattern == 2 ) { for ( i = 0 ; i < 5 ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; break ; } if ( pattern != 1 ) ThrowPICTException ( CorruptImageError , ""UnknownPatternType"" ) ; length = ReadBlobMSBShort ( image ) ; if ( ReadRectangle ( image , & frame ) == MagickFalse ) ThrowPICTException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ReadPixmap ( image , & pixmap ) == MagickFalse ) ThrowPICTException ( CorruptImageError , ""ImproperImageHeader"" ) ; image -> depth = ( size_t ) pixmap . component_size ; image -> resolution . x = 1.0 * pixmap . horizontal_resolution ; image -> resolution . y = 1.0 * pixmap . vertical_resolution ; image -> units = PixelsPerInchResolution ; ( void ) ReadBlobMSBLong ( image ) ; flags = ( ssize_t ) ReadBlobMSBShort ( image ) ; length = ReadBlobMSBShort ( image ) ; for ( i = 0 ; i <= ( ssize_t ) length ; i ++ ) ( void ) ReadBlobMSBLong ( image ) ; width = ( size_t ) ( frame . bottom - frame . top ) ; height = ( size_t ) ( frame . right - frame . left ) ; if ( pixmap . bits_per_pixel <= 8 ) length &= 0x7fff ; if ( pixmap . bits_per_pixel == 16 ) width <<= 1 ; if ( length == 0 ) length = width ; if ( length < 8 ) { for ( i = 0 ; i < ( ssize_t ) ( length * height ) ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; } else for ( i = 0 ; i < ( ssize_t ) height ; i ++ ) { if ( EOFBlob ( image ) != MagickFalse ) break ; if ( length > 200 ) { for ( j = 0 ; j < ( ssize_t ) ReadBlobMSBShort ( image ) ; j ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; } else for ( j = 0 ; j < ( ssize_t ) ReadBlobByte ( image ) ; j ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; } break ; } case 0x1b : { image -> background_color . red = ( Quantum ) ScaleShortToQuantum ( ReadBlobMSBShort ( image ) ) ; image -> background_color . green = ( Quantum ) ScaleShortToQuantum ( ReadBlobMSBShort ( image ) ) ; image -> background_color . blue = ( Quantum ) ScaleShortToQuantum ( ReadBlobMSBShort ( image ) ) ; break ; } case 0x70 : case 0x71 : case 0x72 : case 0x73 : case 0x74 : case 0x75 : case 0x76 : case 0x77 : { length = ReadBlobMSBShort ( image ) ; for ( i = 0 ; i < ( ssize_t ) ( length - 2 ) ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; break ; } case 0x90 : case 0x91 : case 0x98 : case 0x99 : case 0x9a : case 0x9b : { PICTRectangle source , destination ; register unsigned char * p ; size_t j ; ssize_t bytes_per_line ; unsigned char * pixels ; bytes_per_line = 0 ; if ( ( code != 0x9a ) && ( code != 0x9b ) ) bytes_per_line = ( ssize_t ) ReadBlobMSBShort ( image ) ; else { ( void ) ReadBlobMSBShort ( image ) ; ( void ) ReadBlobMSBShort ( image ) ; ( void ) ReadBlobMSBShort ( image ) ; } if ( ReadRectangle ( image , & frame ) == MagickFalse ) ThrowPICTException ( CorruptImageError , ""ImproperImageHeader"" ) ; tile_image = CloneImage ( image , ( size_t ) ( frame . right - frame . left ) , ( size_t ) ( frame . bottom - frame . top ) , MagickTrue , exception ) ; if ( tile_image == ( Image * ) NULL ) ThrowPICTException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ( code == 0x9a ) || ( code == 0x9b ) || ( ( bytes_per_line & 0x8000 ) != 0 ) ) { if ( ReadPixmap ( image , & pixmap ) == MagickFalse ) ThrowPICTException ( CorruptImageError , ""ImproperImageHeader"" ) ; tile_image -> depth = ( size_t ) pixmap . component_size ; tile_image -> alpha_trait = pixmap . component_count == 4 ? BlendPixelTrait : UndefinedPixelTrait ; tile_image -> resolution . x = ( double ) pixmap . horizontal_resolution ; tile_image -> resolution . y = ( double ) pixmap . vertical_resolution ; tile_image -> units = PixelsPerInchResolution ; if ( tile_image -> alpha_trait != UndefinedPixelTrait ) ( void ) SetImageAlpha ( tile_image , OpaqueAlpha , exception ) ; } if ( ( code != 0x9a ) && ( code != 0x9b ) ) { tile_image -> colors = 2 ; if ( ( bytes_per_line & 0x8000 ) != 0 ) { ( void ) ReadBlobMSBLong ( image ) ; flags = ( ssize_t ) ReadBlobMSBShort ( image ) ; tile_image -> colors = 1UL * ReadBlobMSBShort ( image ) + 1 ; } status = AcquireImageColormap ( tile_image , tile_image -> colors , exception ) ; if ( status == MagickFalse ) ThrowPICTException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; if ( ( bytes_per_line & 0x8000 ) != 0 ) { for ( i = 0 ; i < ( ssize_t ) tile_image -> colors ; i ++ ) { j = ReadBlobMSBShort ( image ) % tile_image -> colors ; if ( ( flags & 0x8000 ) != 0 ) j = ( size_t ) i ; tile_image -> colormap [ j ] . red = ( Quantum ) ScaleShortToQuantum ( ReadBlobMSBShort ( image ) ) ; tile_image -> colormap [ j ] . green = ( Quantum ) ScaleShortToQuantum ( ReadBlobMSBShort ( image ) ) ; tile_image -> colormap [ j ] . blue = ( Quantum ) ScaleShortToQuantum ( ReadBlobMSBShort ( image ) ) ; } } else { for ( i = 0 ; i < ( ssize_t ) tile_image -> colors ; i ++ ) { tile_image -> colormap [ i ] . red = ( Quantum ) ( QuantumRange - tile_image -> colormap [ i ] . red ) ; tile_image -> colormap [ i ] . green = ( Quantum ) ( QuantumRange - tile_image -> colormap [ i ] . green ) ; tile_image -> colormap [ i ] . blue = ( Quantum ) ( QuantumRange - tile_image -> colormap [ i ] . blue ) ; } } } if ( EOFBlob ( image ) != MagickFalse ) ThrowPICTException ( CorruptImageError , ""InsufficientImageDataInFile"" ) ; if ( ReadRectangle ( image , & source ) == MagickFalse ) ThrowPICTException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ReadRectangle ( image , & destination ) == MagickFalse ) ThrowPICTException ( CorruptImageError , ""ImproperImageHeader"" ) ; ( void ) ReadBlobMSBShort ( image ) ; if ( ( code == 0x91 ) || ( code == 0x99 ) || ( code == 0x9b ) ) { length = ReadBlobMSBShort ( image ) ; for ( i = 0 ; i < ( ssize_t ) ( length - 2 ) ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; } if ( ( code != 0x9a ) && ( code != 0x9b ) && ( bytes_per_line & 0x8000 ) == 0 ) pixels = DecodeImage ( image , tile_image , ( size_t ) bytes_per_line , 1 , & extent ) ; else pixels = DecodeImage ( image , tile_image , ( size_t ) bytes_per_line , ( unsigned int ) pixmap . bits_per_pixel , & extent ) ; if ( pixels == ( unsigned char * ) NULL ) ThrowPICTException ( CorruptImageError , ""UnableToUncompressImage"" ) ; p = pixels ; for ( y = 0 ; y < ( ssize_t ) tile_image -> rows ; y ++ ) { if ( p > ( pixels + extent + image -> columns ) ) { pixels = ( unsigned char * ) RelinquishMagickMemory ( pixels ) ; ThrowPICTException ( CorruptImageError , ""NotEnoughPixelData"" ) ; } q = QueueAuthenticPixels ( tile_image , 0 , y , tile_image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) tile_image -> columns ; x ++ ) { if ( tile_image -> storage_class == PseudoClass ) { index = ( Quantum ) ConstrainColormapIndex ( tile_image , ( ssize_t ) * p , exception ) ; SetPixelIndex ( tile_image , index , q ) ; SetPixelRed ( tile_image , tile_image -> colormap [ ( ssize_t ) index ] . red , q ) ; SetPixelGreen ( tile_image , tile_image -> colormap [ ( ssize_t ) index ] . green , q ) ; SetPixelBlue ( tile_image , tile_image -> colormap [ ( ssize_t ) index ] . blue , q ) ; } else { if ( pixmap . bits_per_pixel == 16 ) { i = ( ssize_t ) ( * p ++ ) ; j = ( size_t ) ( * p ) ; SetPixelRed ( tile_image , ScaleCharToQuantum ( ( unsigned char ) ( ( i & 0x7c ) << 1 ) ) , q ) ; SetPixelGreen ( tile_image , ScaleCharToQuantum ( ( unsigned char ) ( ( ( i & 0x03 ) << 6 ) | ( ( j & 0xe0 ) >> 2 ) ) ) , q ) ; SetPixelBlue ( tile_image , ScaleCharToQuantum ( ( unsigned char ) ( ( j & 0x1f ) << 3 ) ) , q ) ; } else if ( tile_image -> alpha_trait == UndefinedPixelTrait ) { if ( p > ( pixels + extent + 2 * image -> columns ) ) ThrowPICTException ( CorruptImageError , ""NotEnoughPixelData"" ) ; SetPixelRed ( tile_image , ScaleCharToQuantum ( * p ) , q ) ; SetPixelGreen ( tile_image , ScaleCharToQuantum ( * ( p + tile_image -> columns ) ) , q ) ; SetPixelBlue ( tile_image , ScaleCharToQuantum ( * ( p + 2 * tile_image -> columns ) ) , q ) ; } else { if ( p > ( pixels + extent + 3 * image -> columns ) ) ThrowPICTException ( CorruptImageError , ""NotEnoughPixelData"" ) ; SetPixelAlpha ( tile_image , ScaleCharToQuantum ( * p ) , q ) ; SetPixelRed ( tile_image , ScaleCharToQuantum ( * ( p + tile_image -> columns ) ) , q ) ; SetPixelGreen ( tile_image , ScaleCharToQuantum ( * ( p + 2 * tile_image -> columns ) ) , q ) ; SetPixelBlue ( tile_image , ScaleCharToQuantum ( * ( p + 3 * tile_image -> columns ) ) , q ) ; } } p ++ ; q += GetPixelChannels ( tile_image ) ; } if ( SyncAuthenticPixels ( tile_image , exception ) == MagickFalse ) break ; if ( ( tile_image -> storage_class == DirectClass ) && ( pixmap . bits_per_pixel != 16 ) ) { p += ( pixmap . component_count - 1 ) * tile_image -> columns ; if ( p < pixels ) break ; } status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , tile_image -> rows ) ; if ( status == MagickFalse ) break ; } pixels = ( unsigned char * ) RelinquishMagickMemory ( pixels ) ; if ( ( jpeg == MagickFalse ) && ( EOFBlob ( image ) == MagickFalse ) ) if ( ( code == 0x9a ) || ( code == 0x9b ) || ( ( bytes_per_line & 0x8000 ) != 0 ) ) ( void ) CompositeImage ( image , tile_image , CopyCompositeOp , MagickTrue , ( ssize_t ) destination . left , ( ssize_t ) destination . top , exception ) ; tile_image = DestroyImage ( tile_image ) ; break ; } case 0xa1 : { unsigned char * info ; size_t type ; type = ReadBlobMSBShort ( image ) ; length = ReadBlobMSBShort ( image ) ; if ( length == 0 ) break ; ( void ) ReadBlobMSBLong ( image ) ; length -= MagickMin ( length , 4 ) ; if ( length == 0 ) break ; info = ( unsigned char * ) AcquireQuantumMemory ( length , sizeof ( * info ) ) ; if ( info == ( unsigned char * ) NULL ) break ; count = ReadBlob ( image , length , info ) ; if ( count != ( ssize_t ) length ) { info = ( unsigned char * ) RelinquishMagickMemory ( info ) ; ThrowPICTException ( ResourceLimitError , ""UnableToReadImageData"" ) ; } switch ( type ) { case 0xe0 : { profile = BlobToStringInfo ( ( const void * ) NULL , length ) ; SetStringInfoDatum ( profile , info ) ; status = SetImageProfile ( image , ""icc"" , profile , exception ) ; profile = DestroyStringInfo ( profile ) ; if ( status == MagickFalse ) { info = ( unsigned char * ) RelinquishMagickMemory ( info ) ; ThrowPICTException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; } break ; } case 0x1f2 : { profile = BlobToStringInfo ( ( const void * ) NULL , length ) ; SetStringInfoDatum ( profile , info ) ; status = SetImageProfile ( image , ""iptc"" , profile , exception ) ; if ( status == MagickFalse ) { info = ( unsigned char * ) RelinquishMagickMemory ( info ) ; ThrowPICTException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; } profile = DestroyStringInfo ( profile ) ; break ; } default : break ; } info = ( unsigned char * ) RelinquishMagickMemory ( info ) ; break ; } default : { if ( codes [ code ] . length == - 1 ) ( void ) ReadBlobMSBShort ( image ) ; else for ( i = 0 ; i < ( ssize_t ) codes [ code ] . length ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; } } } if ( code == 0xc00 ) { for ( i = 0 ; i < 24 ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; continue ; } if ( ( ( code >= 0xb0 ) && ( code <= 0xcf ) ) || ( ( code >= 0x8000 ) && ( code <= 0x80ff ) ) ) continue ; if ( code == 0x8200 ) { char filename [ MaxTextExtent ] ; FILE * file ; int unique_file ; jpeg = MagickTrue ; read_info = CloneImageInfo ( image_info ) ; SetImageInfoBlob ( read_info , ( void * ) NULL , 0 ) ; file = ( FILE * ) NULL ; unique_file = AcquireUniqueFileResource ( filename ) ; ( void ) FormatLocaleString ( read_info -> filename , MaxTextExtent , ""jpeg:%s"" , filename ) ; if ( unique_file != - 1 ) file = fdopen ( unique_file , ""wb"" ) ; if ( ( unique_file == - 1 ) || ( file == ( FILE * ) NULL ) ) { ( void ) RelinquishUniqueFileResource ( read_info -> filename ) ; ( void ) CopyMagickString ( image -> filename , read_info -> filename , MagickPathExtent ) ; ThrowPICTException ( FileOpenError , ""UnableToCreateTemporaryFile"" ) ; } length = ReadBlobMSBLong ( image ) ; if ( length > 154 ) { for ( i = 0 ; i < 6 ; i ++ ) ( void ) ReadBlobMSBLong ( image ) ; if ( ReadRectangle ( image , & frame ) == MagickFalse ) { ( void ) fclose ( file ) ; ( void ) RelinquishUniqueFileResource ( read_info -> filename ) ; ThrowPICTException ( CorruptImageError , ""ImproperImageHeader"" ) ; } for ( i = 0 ; i < 122 ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; for ( i = 0 ; i < ( ssize_t ) ( length - 154 ) ; i ++ ) { c = ReadBlobByte ( image ) ; if ( c == EOF ) break ; ( void ) fputc ( c , file ) ; } } ( void ) fclose ( file ) ; ( void ) close ( unique_file ) ; tile_image = ReadImage ( read_info , exception ) ; ( void ) RelinquishUniqueFileResource ( filename ) ; read_info = DestroyImageInfo ( read_info ) ; if ( tile_image == ( Image * ) NULL ) continue ; ( void ) FormatLocaleString ( geometry , MagickPathExtent , ""%.20gx%.20g"" , ( double ) MagickMax ( image -> columns , tile_image -> columns ) , ( double ) MagickMax ( image -> rows , tile_image -> rows ) ) ; ( void ) SetImageExtent ( image , MagickMax ( image -> columns , tile_image -> columns ) , MagickMax ( image -> rows , tile_image -> rows ) , exception ) ; ( void ) TransformImageColorspace ( image , tile_image -> colorspace , exception ) ; ( void ) CompositeImage ( image , tile_image , CopyCompositeOp , MagickTrue , ( ssize_t ) frame . left , ( ssize_t ) frame . right , exception ) ; image -> compression = tile_image -> compression ; tile_image = DestroyImage ( tile_image ) ; continue ; } if ( ( code == 0xff ) || ( code == 0xffff ) ) break ; if ( ( ( code >= 0xd0 ) && ( code <= 0xfe ) ) || ( ( code >= 0x8100 ) && ( code <= 0xffff ) ) ) { length = ReadBlobMSBShort ( image ) ; for ( i = 0 ; i < ( ssize_t ) length ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; continue ; } if ( ( code >= 0x100 ) && ( code <= 0x7fff ) ) { length = ( size_t ) ( ( code >> 7 ) & 0xff ) ; for ( i = 0 ; i < ( ssize_t ) length ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; continue ; } } ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," , message ) \\\n{ if ( tile_image ) ) ; \\\n} char geometry [ ) break ; if ( fputc ( c , file ) != c ) break ",ImageMagick@ImageMagick/6b6bff054d569a77973f2140c0e86366e6168a6c,CVE-2018-16643,https://github.com/ImageMagick/ImageMagick/commit/6b6bff054d569a77973f2140c0e86366e6168a6c,2018-09-06T22:29Z 668,CWE-190,"CWE-190 static int jas_iccgetsint32 ( jas_stream_t * in , jas_iccsint32_t * val ) { ulonglong tmp ; if ( jas_iccgetuint ( in , 4 , & tmp ) ) return - 1 ; * val = ( tmp & 0x80000000 ) ? ( - JAS_CAST ( longlong , ( ( ( ~ tmp ) & 0x7fffffff ) + 1 ) ) ) : JAS_CAST ( longlong , tmp ) ; return 0 ; } "," val ) { jas_ulonglong tmp ; if - JAS_CAST ( jas_longlong , ( ( : JAS_CAST ( jas_longlong , tmp ) ",mdadams@jasper/d42b2388f7f8e0332c846675133acea151fc557a,CVE-2016-9557,https://github.com/mdadams/jasper/commit/d42b2388f7f8e0332c846675133acea151fc557a,2017-03-23T18:59Z 669,CWE-476,"CWE-476 int rds_cmsg_atomic ( struct rds_sock * rs , struct rds_message * rm , struct cmsghdr * cmsg ) { struct page * page = NULL ; struct rds_atomic_args * args ; int ret = 0 ; if ( cmsg -> cmsg_len < CMSG_LEN ( sizeof ( struct rds_atomic_args ) ) || rm -> atomic . op_active ) return - EINVAL ; args = CMSG_DATA ( cmsg ) ; switch ( cmsg -> cmsg_type ) { case RDS_CMSG_ATOMIC_FADD : rm -> atomic . op_type = RDS_ATOMIC_TYPE_FADD ; rm -> atomic . op_m_fadd . add = args -> fadd . add ; rm -> atomic . op_m_fadd . nocarry_mask = 0 ; break ; case RDS_CMSG_MASKED_ATOMIC_FADD : rm -> atomic . op_type = RDS_ATOMIC_TYPE_FADD ; rm -> atomic . op_m_fadd . add = args -> m_fadd . add ; rm -> atomic . op_m_fadd . nocarry_mask = args -> m_fadd . nocarry_mask ; break ; case RDS_CMSG_ATOMIC_CSWP : rm -> atomic . op_type = RDS_ATOMIC_TYPE_CSWP ; rm -> atomic . op_m_cswp . compare = args -> cswp . compare ; rm -> atomic . op_m_cswp . swap = args -> cswp . swap ; rm -> atomic . op_m_cswp . compare_mask = ~ 0 ; rm -> atomic . op_m_cswp . swap_mask = ~ 0 ; break ; case RDS_CMSG_MASKED_ATOMIC_CSWP : rm -> atomic . op_type = RDS_ATOMIC_TYPE_CSWP ; rm -> atomic . op_m_cswp . compare = args -> m_cswp . compare ; rm -> atomic . op_m_cswp . swap = args -> m_cswp . swap ; rm -> atomic . op_m_cswp . compare_mask = args -> m_cswp . compare_mask ; rm -> atomic . op_m_cswp . swap_mask = args -> m_cswp . swap_mask ; break ; default : BUG ( ) ; } rm -> atomic . op_notify = ! ! ( args -> flags & RDS_RDMA_NOTIFY_ME ) ; rm -> atomic . op_silent = ! ! ( args -> flags & RDS_RDMA_SILENT ) ; rm -> atomic . op_active = 1 ; rm -> atomic . op_recverr = rs -> rs_recverr ; rm -> atomic . op_sg = rds_message_alloc_sgs ( rm , 1 ) ; if ( ! rm -> atomic . op_sg ) { ret = - ENOMEM ; goto err ; } if ( args -> local_addr & 0x7 ) { ret = - EFAULT ; goto err ; } ret = rds_pin_pages ( args -> local_addr , 1 , & page , 1 ) ; if ( ret != 1 ) goto err ; ret = 0 ; sg_set_page ( rm -> atomic . op_sg , page , 8 , offset_in_page ( args -> local_addr ) ) ; if ( rm -> atomic . op_notify || rm -> atomic . op_recverr ) { rm -> atomic . op_notifier = kmalloc ( sizeof ( * rm -> atomic . op_notifier ) , GFP_KERNEL ) ; if ( ! rm -> atomic . op_notifier ) { ret = - ENOMEM ; goto err ; } rm -> atomic . op_notifier -> n_user_token = args -> user_token ; rm -> atomic . op_notifier -> n_status = RDS_RDMA_SUCCESS ; } rm -> atomic . op_rkey = rds_rdma_cookie_key ( args -> cookie ) ; rm -> atomic . op_remote_addr = args -> remote_addr + rds_rdma_cookie_offset ( args -> cookie ) ; return ret ; err : if ( page ) put_page ( page ) ; kfree ( rm -> atomic . op_notifier ) ; return ret ; } "," page ) ; rm -> atomic . op_active = 0 ; ",torvalds@linux/7d11f77f84b27cef452cee332f4e469503084737,CVE-2018-5333,https://github.com/torvalds/linux/commit/7d11f77f84b27cef452cee332f4e469503084737,2018-01-11T07:29Z 670,CWE-617,"CWE-617 void pci_lintr_release ( struct pci_vdev * dev ) { struct businfo * bi ; struct slotinfo * si ; int pin ; bi = pci_businfo [ dev -> bus ] ; assert ( bi != NULL ) ; si = & bi -> slotinfo [ dev -> slot ] ; for ( pin = 1 ; pin < 4 ; pin ++ ) { si -> si_intpins [ pin ] . ii_count = 0 ; si -> si_intpins [ pin ] . ii_pirq_pin = 0 ; si -> si_intpins [ pin ] . ii_ioapic_irq = 0 ; } } "," bus ] ; if ( bi == NULL ) { pr_err ( ""%s:pci[%s]haswrongbus%dinfo!\\n"" , __func__ , dev -> name , dev -> bus ) ; return ; } si = & ",projectacrn@acrn-hypervisor/2b3dedfb9ba13f15887f22b935d373f36c9a59fa,CVE-2019-18844,https://github.com/projectacrn/acrn-hypervisor/commit/2b3dedfb9ba13f15887f22b935d373f36c9a59fa,2019-11-13T20:15Z 671,CWE-20,"CWE-20 int rds_recvmsg ( struct kiocb * iocb , struct socket * sock , struct msghdr * msg , size_t size , int msg_flags ) { struct sock * sk = sock -> sk ; struct rds_sock * rs = rds_sk_to_rs ( sk ) ; long timeo ; int ret = 0 , nonblock = msg_flags & MSG_DONTWAIT ; struct sockaddr_in * sin ; struct rds_incoming * inc = NULL ; timeo = sock_rcvtimeo ( sk , nonblock ) ; rdsdebug ( ""size%zuflags0x%xtimeo%ld\\n"" , size , msg_flags , timeo ) ; msg -> msg_namelen = 0 ; if ( msg_flags & MSG_OOB ) goto out ; while ( 1 ) { if ( ! list_empty ( & rs -> rs_notify_queue ) ) { ret = rds_notify_queue_get ( rs , msg ) ; break ; } if ( rs -> rs_cong_notify ) { ret = rds_notify_cong ( rs , msg ) ; break ; } if ( ! rds_next_incoming ( rs , & inc ) ) { if ( nonblock ) { ret = - EAGAIN ; break ; } timeo = wait_event_interruptible_timeout ( * sk_sleep ( sk ) , ( ! list_empty ( & rs -> rs_notify_queue ) || rs -> rs_cong_notify || rds_next_incoming ( rs , & inc ) ) , timeo ) ; rdsdebug ( ""recvmsgwokeinc%ptimeo%ld\\n"" , inc , timeo ) ; if ( timeo > 0 || timeo == MAX_SCHEDULE_TIMEOUT ) continue ; ret = timeo ; if ( ret == 0 ) ret = - ETIMEDOUT ; break ; } rdsdebug ( ""copyinginc%pfrom%pI4:%utouser\\n"" , inc , & inc -> i_conn -> c_faddr , ntohs ( inc -> i_hdr . h_sport ) ) ; ret = inc -> i_conn -> c_trans -> inc_copy_to_user ( inc , msg -> msg_iov , size ) ; if ( ret < 0 ) break ; if ( ! rds_still_queued ( rs , inc , ! ( msg_flags & MSG_PEEK ) ) ) { rds_inc_put ( inc ) ; inc = NULL ; rds_stats_inc ( s_recv_deliver_raced ) ; continue ; } if ( ret < be32_to_cpu ( inc -> i_hdr . h_len ) ) { if ( msg_flags & MSG_TRUNC ) ret = be32_to_cpu ( inc -> i_hdr . h_len ) ; msg -> msg_flags |= MSG_TRUNC ; } if ( rds_cmsg_recv ( inc , msg ) ) { ret = - EFAULT ; goto out ; } rds_stats_inc ( s_recv_delivered ) ; sin = ( struct sockaddr_in * ) msg -> msg_name ; if ( sin ) { sin -> sin_family = AF_INET ; sin -> sin_port = inc -> i_hdr . h_sport ; sin -> sin_addr . s_addr = inc -> i_saddr ; memset ( sin -> sin_zero , 0 , sizeof ( sin -> sin_zero ) ) ; msg -> msg_namelen = sizeof ( * sin ) ; } break ; } if ( inc ) rds_inc_put ( inc ) ; out : return ret ; } "," , timeo ) ; if ( ",torvalds@linux/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,CVE-2013-7271,https://github.com/torvalds/linux/commit/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,2014-01-06T16:55Z 672,CWE-22,"CWE-22 int set_interface_var ( const char * iface , const char * var , const char * name , uint32_t val ) { FILE * fp ; char spath [ 64 + IFNAMSIZ ] ; if ( snprintf ( spath , sizeof ( spath ) , var , iface ) >= sizeof ( spath ) ) return - 1 ; if ( access ( spath , F_OK ) != 0 ) return - 1 ; fp = fopen ( spath , ""w"" ) ; if ( ! fp ) { if ( name ) flog ( LOG_ERR , ""failedtoset%s(%u)for%s:%s"" , name , val , iface , strerror ( errno ) ) ; return - 1 ; } fprintf ( fp , ""%u"" , val ) ; fclose ( fp ) ; return 0 ; } "," sizeof ( spath ) ) return - 1 ; if ( strstr ( name , "".."" ) || strchr ( name , '/' ",reubenhwk@radvd/92e22ca23e52066da2258df8c76a2dca8a428bcc,CVE-2011-3602,https://github.com/reubenhwk/radvd/commit/92e22ca23e52066da2258df8c76a2dca8a428bcc,2014-04-27T21:55Z 673,CWE-119,"CWE-119 static void t1mac_output_ascii ( char * s , int len ) { if ( blocktyp == POST_BINARY ) { output_current_post ( ) ; blocktyp = POST_ASCII ; } if ( len > 0 && s [ len - 1 ] == '\\n' ) s [ len - 1 ] = '\\r' ; t1mac_output_data ( ( byte * ) s , len ) ; if ( strncmp ( s , ""/FontName"" , 9 ) == 0 ) { for ( s += 9 ; isspace ( * s ) ; s ++ ) ; if ( * s == '/' ) { const char * t = ++ s ; while ( * t && ! isspace ( * t ) ) t ++ ; free ( font_name ) ; font_name = ( char * ) malloc ( t - s + 1 ) ; memcpy ( font_name , s , t - s ) ; font_name [ t - s ] = 0 ; } } } "," ; isspace ( ( unsigned char ) ! isspace ( ( unsigned char ) ",kohler@t1utils/6b9d1aafcb61a3663c883663eb19ccdbfcde8d33,CVE-2015-3905,https://github.com/kohler/t1utils/commit/6b9d1aafcb61a3663c883663eb19ccdbfcde8d33,2015-06-08T14:59Z 674,CWE-22,"CWE-22 static int pop_sync_mailbox ( struct Context * ctx , int * index_hint ) { int i , j , ret = 0 ; char buf [ LONG_STRING ] ; struct PopData * pop_data = ( struct PopData * ) ctx -> data ; struct Progress progress ; # ifdef USE_HCACHE header_cache_t * hc = NULL ; # endif pop_data -> check_time = 0 ; while ( true ) { if ( pop_reconnect ( ctx ) < 0 ) return - 1 ; mutt_progress_init ( & progress , _ ( ""Markingmessagesdeleted..."" ) , MUTT_PROGRESS_MSG , WriteInc , ctx -> deleted ) ; # ifdef USE_HCACHE hc = pop_hcache_open ( pop_data , ctx -> path ) ; # endif for ( i = 0 , j = 0 , ret = 0 ; ret == 0 && i < ctx -> msgcount ; i ++ ) { if ( ctx -> hdrs [ i ] -> deleted && ctx -> hdrs [ i ] -> refno != - 1 ) { j ++ ; if ( ! ctx -> quiet ) mutt_progress_update ( & progress , j , - 1 ) ; snprintf ( buf , sizeof ( buf ) , ""DELE%d\\r\\n"" , ctx -> hdrs [ i ] -> refno ) ; ret = pop_query ( pop_data , buf , sizeof ( buf ) ) ; if ( ret == 0 ) { mutt_bcache_del ( pop_data -> bcache , ctx -> hdrs [ i ] -> data ) ; # ifdef USE_HCACHE mutt_hcache_delete ( hc , ctx -> hdrs [ i ] -> data , strlen ( ctx -> hdrs [ i ] -> data ) ) ; # endif } } # ifdef USE_HCACHE if ( ctx -> hdrs [ i ] -> changed ) { mutt_hcache_store ( hc , ctx -> hdrs [ i ] -> data , strlen ( ctx -> hdrs [ i ] -> data ) , ctx -> hdrs [ i ] , 0 ) ; } # endif } # ifdef USE_HCACHE mutt_hcache_close ( hc ) ; # endif if ( ret == 0 ) { mutt_str_strfcpy ( buf , ""QUIT\\r\\n"" , sizeof ( buf ) ) ; ret = pop_query ( pop_data , buf , sizeof ( buf ) ) ; } if ( ret == 0 ) { pop_data -> clear_cache = true ; pop_clear_cache ( pop_data ) ; pop_data -> status = POP_DISCONNECTED ; return 0 ; } if ( ret == - 2 ) { mutt_error ( ""%s"" , pop_data -> err_msg ) ; return - 1 ; } } } "," -> bcache , cache_id ( ] -> data ) ",neomutt@neomutt/9bfab35522301794483f8f9ed60820bdec9be59e,CVE-2018-14363,https://github.com/neomutt/neomutt/commit/9bfab35522301794483f8f9ed60820bdec9be59e,2018-07-17T17:29Z 675,CWE-000,"CWE-000 bool_t xdr_krb5_principal ( XDR * xdrs , krb5_principal * objp ) { int ret ; char * p = NULL ; krb5_principal pr = NULL ; static krb5_context context = NULL ; if ( ! context && kadm5_init_krb5_context ( & context ) ) return ( FALSE ) ; switch ( xdrs -> x_op ) { case XDR_ENCODE : if ( * objp ) { if ( ( ret = krb5_unparse_name ( context , * objp , & p ) ) != 0 ) return FALSE ; } if ( ! xdr_nullstring ( xdrs , & p ) ) return FALSE ; if ( p ) free ( p ) ; break ; case XDR_DECODE : if ( ! xdr_nullstring ( xdrs , & p ) ) return FALSE ; if ( p ) { ret = krb5_parse_name ( context , p , & pr ) ; if ( ret != 0 ) return FALSE ; * objp = pr ; free ( p ) ; } else * objp = NULL ; break ; case XDR_FREE : if ( * objp != NULL ) krb5_free_principal ( context , * objp ) ; break ; } return TRUE ; } "," objp ) ; * objp = NULL ; ",krb5@krb5/a197e92349a4aa2141b5dff12e9dd44c2a2166e3,CVE-2014-9421,https://github.com/krb5/krb5/commit/a197e92349a4aa2141b5dff12e9dd44c2a2166e3,2015-02-19T11:59Z 676,CWE-284,"CWE-284 static void uipc_read_task ( void * arg ) { int ch_id ; int result ; UNUSED ( arg ) ; prctl ( PR_SET_NAME , ( unsigned long ) ""uipc-main"" , 0 , 0 , 0 ) ; raise_priority_a2dp ( TASK_UIPC_READ ) ; while ( uipc_main . running ) { uipc_main . read_set = uipc_main . active_set ; result = select ( uipc_main . max_fd + 1 , & uipc_main . read_set , NULL , NULL , NULL ) ; if ( result == 0 ) { BTIF_TRACE_EVENT ( ""selecttimeout"" ) ; continue ; } else if ( result < 0 ) { BTIF_TRACE_EVENT ( ""selectfailed%s"" , strerror ( errno ) ) ; continue ; } UIPC_LOCK ( ) ; uipc_check_interrupt_locked ( ) ; uipc_check_task_flags_locked ( ) ; uipc_check_fd_locked ( UIPC_CH_ID_AV_AUDIO ) ; for ( ch_id = 0 ; ch_id < UIPC_CH_NUM ; ch_id ++ ) { if ( ch_id != UIPC_CH_ID_AV_AUDIO ) uipc_check_fd_locked ( ch_id ) ; } UIPC_UNLOCK ( ) ; } BTIF_TRACE_EVENT ( ""UIPCREADTHREADEXITING"" ) ; uipc_main_cleanup ( ) ; uipc_main . tid = 0 ; BTIF_TRACE_EVENT ( ""UIPCREADTHREADDONE"" ) ; } "," ; result = TEMP_FAILURE_RETRY ( , NULL ) ) ",system@bt/472271b153c5dc53c28beac55480a8d8434b2d5c,CVE-2016-3839,https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c,2016-08-05T20:59Z 677,CWE-415,"CWE-415 int dccp_rcv_state_process ( struct sock * sk , struct sk_buff * skb , struct dccp_hdr * dh , unsigned int len ) { struct dccp_sock * dp = dccp_sk ( sk ) ; struct dccp_skb_cb * dcb = DCCP_SKB_CB ( skb ) ; const int old_state = sk -> sk_state ; int queued = 0 ; if ( sk -> sk_state == DCCP_LISTEN ) { if ( dh -> dccph_type == DCCP_PKT_REQUEST ) { if ( inet_csk ( sk ) -> icsk_af_ops -> conn_request ( sk , skb ) < 0 ) return 1 ; goto discard ; } if ( dh -> dccph_type == DCCP_PKT_RESET ) goto discard ; dcb -> dccpd_reset_code = DCCP_RESET_CODE_NO_CONNECTION ; return 1 ; } else if ( sk -> sk_state == DCCP_CLOSED ) { dcb -> dccpd_reset_code = DCCP_RESET_CODE_NO_CONNECTION ; return 1 ; } if ( sk -> sk_state != DCCP_REQUESTING && dccp_check_seqno ( sk , skb ) ) goto discard ; if ( ( dp -> dccps_role != DCCP_ROLE_CLIENT && dh -> dccph_type == DCCP_PKT_RESPONSE ) || ( dp -> dccps_role == DCCP_ROLE_CLIENT && dh -> dccph_type == DCCP_PKT_REQUEST ) || ( sk -> sk_state == DCCP_RESPOND && dh -> dccph_type == DCCP_PKT_DATA ) ) { dccp_send_sync ( sk , dcb -> dccpd_seq , DCCP_PKT_SYNC ) ; goto discard ; } if ( dccp_parse_options ( sk , NULL , skb ) ) return 1 ; if ( dh -> dccph_type == DCCP_PKT_RESET ) { dccp_rcv_reset ( sk , skb ) ; return 0 ; } else if ( dh -> dccph_type == DCCP_PKT_CLOSEREQ ) { if ( dccp_rcv_closereq ( sk , skb ) ) return 0 ; goto discard ; } else if ( dh -> dccph_type == DCCP_PKT_CLOSE ) { if ( dccp_rcv_close ( sk , skb ) ) return 0 ; goto discard ; } switch ( sk -> sk_state ) { case DCCP_REQUESTING : queued = dccp_rcv_request_sent_state_process ( sk , skb , dh , len ) ; if ( queued >= 0 ) return queued ; __kfree_skb ( skb ) ; return 0 ; case DCCP_PARTOPEN : dccp_handle_ackvec_processing ( sk , skb ) ; dccp_deliver_input_to_ccids ( sk , skb ) ; case DCCP_RESPOND : queued = dccp_rcv_respond_partopen_state_process ( sk , skb , dh , len ) ; break ; } if ( dh -> dccph_type == DCCP_PKT_ACK || dh -> dccph_type == DCCP_PKT_DATAACK ) { switch ( old_state ) { case DCCP_PARTOPEN : sk -> sk_state_change ( sk ) ; sk_wake_async ( sk , SOCK_WAKE_IO , POLL_OUT ) ; break ; } } else if ( unlikely ( dh -> dccph_type == DCCP_PKT_SYNC ) ) { dccp_send_sync ( sk , dcb -> dccpd_seq , DCCP_PKT_SYNCACK ) ; goto discard ; } if ( ! queued ) { discard : __kfree_skb ( skb ) ; } return 0 ; } "," return 1 ; consume_skb ( skb ) ; return 0 ; } if ",torvalds@linux/5edabca9d4cff7f1f2b68f0bac55ef99d9798ba4,CVE-2017-6074,https://github.com/torvalds/linux/commit/5edabca9d4cff7f1f2b68f0bac55ef99d9798ba4,2017-02-18T21:59Z 678,CWE-617,"CWE-617 int pci_emul_add_msixcap ( struct pci_vdev * dev , int msgnum , int barnum ) { uint32_t tab_size ; struct msixcap msixcap ; assert ( msgnum >= 1 && msgnum <= MAX_MSIX_TABLE_ENTRIES ) ; assert ( barnum >= 0 && barnum <= PCIR_MAX_BAR_0 ) ; tab_size = msgnum * MSIX_TABLE_ENTRY_SIZE ; tab_size = roundup2 ( tab_size , 4096 ) ; dev -> msix . table_bar = barnum ; dev -> msix . pba_bar = barnum ; dev -> msix . table_offset = 0 ; dev -> msix . table_count = msgnum ; dev -> msix . pba_offset = tab_size ; dev -> msix . pba_size = PBA_SIZE ( msgnum ) ; pci_msix_table_init ( dev , msgnum ) ; pci_populate_msixcap ( & msixcap , msgnum , barnum , tab_size ) ; pci_emul_alloc_bar ( dev , barnum , PCIBAR_MEM32 , tab_size + dev -> msix . pba_size ) ; return ( pci_emul_add_capability ( dev , ( u_char * ) & msixcap , sizeof ( msixcap ) ) ) ; } "," msixcap msixcap ; if ( msgnum > MAX_MSIX_TABLE_ENTRIES ) { pr_err ( ""%s:Toomanyentries!\\n"" , __func__ ) ; return - 1 ; } tab_size = msgnum msgnum ) ; if ( , msgnum ) != 0 ) return - 1 ",projectacrn@acrn-hypervisor/2b3dedfb9ba13f15887f22b935d373f36c9a59fa,CVE-2019-18844,https://github.com/projectacrn/acrn-hypervisor/commit/2b3dedfb9ba13f15887f22b935d373f36c9a59fa,2019-11-13T20:15Z 679,CWE-264,"CWE-264 int ovl_setattr ( struct dentry * dentry , struct iattr * attr ) { int err ; struct dentry * upperdentry ; err = ovl_want_write ( dentry ) ; if ( err ) goto out ; upperdentry = ovl_dentry_upper ( dentry ) ; if ( upperdentry ) { mutex_lock ( & upperdentry -> d_inode -> i_mutex ) ; err = notify_change ( upperdentry , attr , NULL ) ; mutex_unlock ( & upperdentry -> d_inode -> i_mutex ) ; } else { err = ovl_copy_up_last ( dentry , attr , false ) ; } ovl_drop_write ( dentry ) ; out : return err ; } "," goto out ; err = ovl_copy_up ( dentry ) ; if ( ! err ) { dentry ) ; mutex_lock ( & ) ; } ovl_drop_write ( dentry ",torvalds@linux/acff81ec2c79492b180fade3c2894425cd35a545,CVE-2015-8660,https://github.com/torvalds/linux/commit/acff81ec2c79492b180fade3c2894425cd35a545,2015-12-28T11:59Z 680,CWE-119,"CWE-119 static int check_line_charstring ( void ) { char * p = line ; while ( isspace ( * p ) ) p ++ ; return ( * p == '/' || ( p [ 0 ] == 'd' && p [ 1 ] == 'u' && p [ 2 ] == 'p' ) ) ; } "," ( isspace ( ( unsigned char ) ",kohler@t1utils/6b9d1aafcb61a3663c883663eb19ccdbfcde8d33,CVE-2015-3905,https://github.com/kohler/t1utils/commit/6b9d1aafcb61a3663c883663eb19ccdbfcde8d33,2015-06-08T14:59Z 681,CWE-200,"CWE-200 static int userauth_hostbased ( struct ssh * ssh ) { Authctxt * authctxt = ssh -> authctxt ; struct sshbuf * b ; struct sshkey * key = NULL ; char * pkalg , * cuser , * chost ; u_char * pkblob , * sig ; size_t alen , blen , slen ; int r , pktype , authenticated = 0 ; if ( ! authctxt -> valid ) { debug2 ( ""%s:disabledbecauseofinvaliduser"" , __func__ ) ; return 0 ; } if ( ( r = sshpkt_get_cstring ( ssh , & pkalg , & alen ) ) != 0 || ( r = sshpkt_get_string ( ssh , & pkblob , & blen ) ) != 0 || ( r = sshpkt_get_cstring ( ssh , & chost , NULL ) ) != 0 || ( r = sshpkt_get_cstring ( ssh , & cuser , NULL ) ) != 0 || ( r = sshpkt_get_string ( ssh , & sig , & slen ) ) != 0 ) fatal ( ""%s:packetparsing:%s"" , __func__ , ssh_err ( r ) ) ; debug ( ""%s:cuser%schost%spkalg%sslen%zu"" , __func__ , cuser , chost , pkalg , slen ) ; # ifdef DEBUG_PK debug ( ""signature:"" ) ; sshbuf_dump_data ( sig , siglen , stderr ) ; # endif pktype = sshkey_type_from_name ( pkalg ) ; if ( pktype == KEY_UNSPEC ) { logit ( ""%s:unsupportedpublickeyalgorithm:%s"" , __func__ , pkalg ) ; goto done ; } if ( ( r = sshkey_from_blob ( pkblob , blen , & key ) ) != 0 ) { error ( ""%s:key_from_blob:%s"" , __func__ , ssh_err ( r ) ) ; goto done ; } if ( key == NULL ) { error ( ""%s:cannotdecodekey:%s"" , __func__ , pkalg ) ; goto done ; } if ( key -> type != pktype ) { error ( ""%s:typemismatchfordecodedkey"" ""(received%d,expected%d)"" , __func__ , key -> type , pktype ) ; goto done ; } if ( sshkey_type_plain ( key -> type ) == KEY_RSA && ( ssh -> compat & SSH_BUG_RSASIGMD5 ) != 0 ) { error ( ""RefusingRSAkeybecausepeerusesunsafe"" ""signatureformat"" ) ; goto done ; } if ( match_pattern_list ( pkalg , options . hostbased_key_types , 0 ) != 1 ) { logit ( ""%s:keytype%snotinHostbasedAcceptedKeyTypes"" , __func__ , sshkey_type ( key ) ) ; goto done ; } if ( ( b = sshbuf_new ( ) ) == NULL ) fatal ( ""%s:sshbuf_newfailed"" , __func__ ) ; if ( ( r = sshbuf_put_string ( b , session_id2 , session_id2_len ) ) != 0 || ( r = sshbuf_put_u8 ( b , SSH2_MSG_USERAUTH_REQUEST ) ) != 0 || ( r = sshbuf_put_cstring ( b , authctxt -> user ) ) != 0 || ( r = sshbuf_put_cstring ( b , authctxt -> service ) ) != 0 || ( r = sshbuf_put_cstring ( b , ""hostbased"" ) ) != 0 || ( r = sshbuf_put_string ( b , pkalg , alen ) ) != 0 || ( r = sshbuf_put_string ( b , pkblob , blen ) ) != 0 || ( r = sshbuf_put_cstring ( b , chost ) ) != 0 || ( r = sshbuf_put_cstring ( b , cuser ) ) != 0 ) fatal ( ""%s:buffererror:%s"" , __func__ , ssh_err ( r ) ) ; # ifdef DEBUG_PK sshbuf_dump ( b , stderr ) ; # endif auth2_record_info ( authctxt , ""clientuser\\""%.100s\\"",clienthost\\""%.100s\\"""" , cuser , chost ) ; authenticated = 0 ; if ( PRIVSEP ( hostbased_key_allowed ( authctxt -> pw , cuser , chost , key ) ) && PRIVSEP ( sshkey_verify ( key , sig , slen , sshbuf_ptr ( b ) , sshbuf_len ( b ) , pkalg , ssh -> compat ) ) == 0 ) authenticated = 1 ; auth2_record_key ( authctxt , authenticated , key ) ; sshbuf_free ( b ) ; done : debug2 ( ""%s:authenticated%d"" , __func__ , authenticated ) ; sshkey_free ( key ) ; free ( pkalg ) ; free ( pkblob ) ; free ( cuser ) ; free ( chost ) ; free ( sig ) ; return authenticated ; } "," = 0 ; if ( ( } if ( ! authctxt -> valid || authctxt -> user == NULL ) { debug2 ( ""%s:disabledbecauseofinvaliduser"" , __func__ ) ; goto done ; } if ( ",openbsd@src/779974d35b4859c07bc3cb8a12c74b43b0a7d1e0,CVE-2018-15473,https://github.com/openbsd/src/commit/779974d35b4859c07bc3cb8a12c74b43b0a7d1e0,2018-08-17T19:29Z 682,CWE-119,"CWE-119 static int decode_unsigned_max ( struct vp9_read_bit_buffer * rb , int max ) { const int data = vp9_rb_read_literal ( rb , get_unsigned_bits ( max ) ) ; return data > max ? max : data ; } "," decode_unsigned_max ( struct vpx_read_bit_buffer * rb , int data = vpx_rb_read_literal ( rb , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 683,CWE-824,"CWE-824 static int fetch_uidl ( char * line , void * data ) { int i , index ; struct Context * ctx = ( struct Context * ) data ; struct PopData * pop_data = ( struct PopData * ) ctx -> data ; char * endp = NULL ; errno = 0 ; index = strtol ( line , & endp , 10 ) ; if ( errno ) return - 1 ; while ( * endp == '' ) endp ++ ; memmove ( line , endp , strlen ( endp ) + 1 ) ; for ( i = 0 ; i < ctx -> msgcount ; i ++ ) if ( mutt_str_strcmp ( line , ctx -> hdrs [ i ] -> data ) == 0 ) break ; if ( i == ctx -> msgcount ) { mutt_debug ( 1 , ""newheader%d%s\\n"" , index , line ) ; if ( i >= ctx -> hdrmax ) mx_alloc_memory ( ctx ) ; ctx -> msgcount ++ ; ctx -> hdrs [ i ] = mutt_header_new ( ) ; ctx -> hdrs [ i ] -> data = mutt_str_strdup ( line ) ; } else if ( ctx -> hdrs [ i ] -> index != index - 1 ) pop_data -> clear_cache = true ; ctx -> hdrs [ i ] -> refno = index ; ctx -> hdrs [ i ] -> index = index - 1 ; return 0 ; } "," 1 ) ; if ( strlen ( line ) == 0 ) return - 1 ; ",neomutt@neomutt/93b8ac558752d09e1c56d4f1bc82631316fa9c82,CVE-2018-14356,https://github.com/neomutt/neomutt/commit/93b8ac558752d09e1c56d4f1bc82631316fa9c82,2018-07-17T17:29Z 684,CWE-000,"CWE-000 krb5_error_code pkinit_check_kdc_pkid ( krb5_context context , pkinit_plg_crypto_context plg_cryptoctx , pkinit_req_crypto_context req_cryptoctx , pkinit_identity_crypto_context id_cryptoctx , unsigned char * pdid_buf , unsigned int pkid_len , int * valid_kdcPkId ) { krb5_error_code retval = KRB5KDC_ERR_PREAUTH_FAILED ; PKCS7_ISSUER_AND_SERIAL * is = NULL ; const unsigned char * p = pdid_buf ; int status = 1 ; X509 * kdc_cert = sk_X509_value ( id_cryptoctx -> my_certs , id_cryptoctx -> cert_index ) ; * valid_kdcPkId = 0 ; pkiDebug ( ""foundkdcPkIdinASREQ\\n"" ) ; is = d2i_PKCS7_ISSUER_AND_SERIAL ( NULL , & p , ( int ) pkid_len ) ; if ( is == NULL ) goto cleanup ; status = X509_NAME_cmp ( X509_get_issuer_name ( kdc_cert ) , is -> issuer ) ; if ( ! status ) { status = ASN1_INTEGER_cmp ( X509_get_serialNumber ( kdc_cert ) , is -> serial ) ; if ( ! status ) * valid_kdcPkId = 1 ; } retval = 0 ; cleanup : X509_NAME_free ( is -> issuer ) ; ASN1_INTEGER_free ( is -> serial ) ; free ( is ) ; return retval ; } "," == NULL ) return retval ; status = = 0 ; X509_NAME_free ( is ",krb5@krb5/f249555301940c6df3a2cdda13b56b5674eebc2e,CVE-2013-1415,https://github.com/krb5/krb5/commit/f249555301940c6df3a2cdda13b56b5674eebc2e,2013-03-05T05:05Z 685,CWE-000,"CWE-000 void ff_jpeg2000_cleanup ( Jpeg2000Component * comp , Jpeg2000CodingStyle * codsty ) { int reslevelno , bandno , precno ; for ( reslevelno = 0 ; comp -> reslevel && reslevelno < codsty -> nreslevels ; reslevelno ++ ) { Jpeg2000ResLevel * reslevel = comp -> reslevel + reslevelno ; for ( bandno = 0 ; bandno < reslevel -> nbands ; bandno ++ ) { Jpeg2000Band * band = reslevel -> band + bandno ; for ( precno = 0 ; precno < reslevel -> num_precincts_x * reslevel -> num_precincts_y ; precno ++ ) { Jpeg2000Prec * prec = band -> prec + precno ; av_freep ( & prec -> zerobits ) ; av_freep ( & prec -> cblkincl ) ; av_freep ( & prec -> cblk ) ; } av_freep ( & band -> prec ) ; } av_freep ( & reslevel -> band ) ; } ff_dwt_destroy ( & comp -> dwt ) ; av_freep ( & comp -> reslevel ) ; av_freep ( & comp -> i_data ) ; av_freep ( & comp -> f_data ) ; } "," ++ ) { if ( band -> prec ) { ) ; } } ",FFmpeg@FFmpeg/912ce9dd2080c5837285a471d750fa311e09b555,CVE-2013-7017,https://github.com/FFmpeg/FFmpeg/commit/912ce9dd2080c5837285a471d750fa311e09b555,2013-12-09T16:36Z 686,CWE-835,"CWE-835 void xmlParsePEReference ( xmlParserCtxtPtr ctxt ) { const xmlChar * name ; xmlEntityPtr entity = NULL ; xmlParserInputPtr input ; if ( RAW != '%' ) return ; NEXT ; name = xmlParseName ( ctxt ) ; if ( name == NULL ) { xmlFatalErrMsg ( ctxt , XML_ERR_PEREF_NO_NAME , ""PEReference:noname\\n"" ) ; return ; } if ( xmlParserDebugEntities ) xmlGenericError ( xmlGenericErrorContext , ""PEReference:%s\\n"" , name ) ; if ( RAW != ';' ) { xmlFatalErr ( ctxt , XML_ERR_PEREF_SEMICOL_MISSING , NULL ) ; return ; } NEXT ; ctxt -> nbentities ++ ; if ( ( ctxt -> sax != NULL ) && ( ctxt -> sax -> getParameterEntity != NULL ) ) entity = ctxt -> sax -> getParameterEntity ( ctxt -> userData , name ) ; if ( ctxt -> instate == XML_PARSER_EOF ) return ; if ( entity == NULL ) { if ( ( ctxt -> standalone == 1 ) || ( ( ctxt -> hasExternalSubset == 0 ) && ( ctxt -> hasPErefs == 0 ) ) ) { xmlFatalErrMsgStr ( ctxt , XML_ERR_UNDECLARED_ENTITY , ""PEReference:%%%s;notfound\\n"" , name ) ; } else { if ( ( ctxt -> validate ) && ( ctxt -> vctxt . error != NULL ) ) { xmlValidityError ( ctxt , XML_WAR_UNDECLARED_ENTITY , ""PEReference:%%%s;notfound\\n"" , name , NULL ) ; } else xmlWarningMsg ( ctxt , XML_WAR_UNDECLARED_ENTITY , ""PEReference:%%%s;notfound\\n"" , name , NULL ) ; ctxt -> valid = 0 ; } xmlParserEntityCheck ( ctxt , 0 , NULL , 0 ) ; } else { if ( ( entity -> etype != XML_INTERNAL_PARAMETER_ENTITY ) && ( entity -> etype != XML_EXTERNAL_PARAMETER_ENTITY ) ) { xmlWarningMsg ( ctxt , XML_WAR_UNDECLARED_ENTITY , ""Internal:%%%s;isnotaparameterentity\\n"" , name , NULL ) ; } else { xmlChar start [ 4 ] ; xmlCharEncoding enc ; if ( ( entity -> etype == XML_EXTERNAL_PARAMETER_ENTITY ) && ( ( ctxt -> options & XML_PARSE_NOENT ) == 0 ) && ( ( ctxt -> options & XML_PARSE_DTDVALID ) == 0 ) && ( ( ctxt -> options & XML_PARSE_DTDLOAD ) == 0 ) && ( ( ctxt -> options & XML_PARSE_DTDATTR ) == 0 ) && ( ctxt -> replaceEntities == 0 ) && ( ctxt -> validate == 0 ) ) return ; input = xmlNewEntityInputStream ( ctxt , entity ) ; if ( xmlPushInput ( ctxt , input ) < 0 ) return ; if ( entity -> etype == XML_EXTERNAL_PARAMETER_ENTITY ) { GROW if ( ctxt -> instate == XML_PARSER_EOF ) return ; if ( ( ctxt -> input -> end - ctxt -> input -> cur ) >= 4 ) { start [ 0 ] = RAW ; start [ 1 ] = NXT ( 1 ) ; start [ 2 ] = NXT ( 2 ) ; start [ 3 ] = NXT ( 3 ) ; enc = xmlDetectCharEncoding ( start , 4 ) ; if ( enc != XML_CHAR_ENCODING_NONE ) { xmlSwitchEncoding ( ctxt , enc ) ; } } if ( ( CMP5 ( CUR_PTR , '<' , '?' , 'x' , 'm' , 'l' ) ) && ( IS_BLANK_CH ( NXT ( 5 ) ) ) ) { xmlParseTextDecl ( ctxt ) ; } } } } ctxt -> hasPErefs = 1 ; } "," < 0 ) { xmlFreeInputStream ( input ) ; return ; } if ( entity ",GNOME@libxml2/899a5d9f0ed13b8e32449a08a361e0de127dd961,CVE-2017-16932,https://github.com/GNOME/libxml2/commit/899a5d9f0ed13b8e32449a08a361e0de127dd961,2017-11-23T21:29Z 687,CWE-264,"CWE-264 static int dccp_v6_send_response ( const struct sock * sk , struct request_sock * req ) { struct inet_request_sock * ireq = inet_rsk ( req ) ; struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct sk_buff * skb ; struct in6_addr * final_p , final ; struct flowi6 fl6 ; int err = - 1 ; struct dst_entry * dst ; memset ( & fl6 , 0 , sizeof ( fl6 ) ) ; fl6 . flowi6_proto = IPPROTO_DCCP ; fl6 . daddr = ireq -> ir_v6_rmt_addr ; fl6 . saddr = ireq -> ir_v6_loc_addr ; fl6 . flowlabel = 0 ; fl6 . flowi6_oif = ireq -> ir_iif ; fl6 . fl6_dport = ireq -> ir_rmt_port ; fl6 . fl6_sport = htons ( ireq -> ir_num ) ; security_req_classify_flow ( req , flowi6_to_flowi ( & fl6 ) ) ; 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 ) ; dst = NULL ; goto done ; } skb = dccp_make_response ( sk , dst , req ) ; if ( skb != NULL ) { struct dccp_hdr * dh = dccp_hdr ( skb ) ; dh -> dccph_checksum = dccp_v6_csum_finish ( skb , & ireq -> ir_v6_loc_addr , & ireq -> ir_v6_rmt_addr ) ; fl6 . daddr = ireq -> ir_v6_rmt_addr ; err = ip6_xmit ( sk , skb , & fl6 , np -> opt , np -> tclass ) ; err = net_xmit_eval ( err ) ; } done : dst_release ( dst ) ; return err ; } "," ) ) ; rcu_read_lock ( ) ; & fl6 , rcu_dereference ( np -> opt ) , & final ) ; rcu_read_unlock ( -> ir_v6_rmt_addr ; rcu_read_lock ( ) ; & fl6 , rcu_dereference ( np -> opt ) , np -> tclass np -> tclass ) ; rcu_read_unlock ( ",torvalds@linux/45f6fad84cc305103b28d73482b344d7f5b76f39,CVE-2016-3841,https://github.com/torvalds/linux/commit/45f6fad84cc305103b28d73482b344d7f5b76f39,2016-08-06T20:59Z 688,CWE-119,"CWE-119 static TX_MODE select_tx_mode ( const VP9_COMP * cpi ) { if ( cpi -> oxcf . lossless ) { return ONLY_4X4 ; } else if ( cpi -> common . current_video_frame == 0 ) { return TX_MODE_SELECT ; } else { if ( cpi -> sf . tx_size_search_method == USE_LARGESTALL ) { return ALLOW_32X32 ; } else if ( cpi -> sf . tx_size_search_method == USE_FULL_RD ) { const MV_REFERENCE_FRAME frame_type = get_frame_type ( cpi ) ; return cpi -> rd_tx_select_threshes [ frame_type ] [ ALLOW_32X32 ] > cpi -> rd_tx_select_threshes [ frame_type ] [ TX_MODE_SELECT ] ? ALLOW_32X32 : TX_MODE_SELECT ; } else { unsigned int total = 0 ; int i ; for ( i = 0 ; i < TX_SIZES ; ++ i ) total += cpi -> tx_stepdown_count [ i ] ; if ( total ) { const double fraction = ( double ) cpi -> tx_stepdown_count [ 0 ] / total ; return fraction > 0.90 ? ALLOW_32X32 : TX_MODE_SELECT ; } else { return cpi -> common . tx_mode ; } } } } "," VP9_COMP * cpi , MACROBLOCKD * const xd { if ( xd -> lossless ) return ONLY_4X4 ; return ONLY_4X4 ; if ( cpi -> common . frame_type == KEY_FRAME && cpi -> sf . use_nonrd_pick_mode ) return ALLOW_16X16 ; if ( cpi == USE_LARGESTALL ) return ALLOW_32X32 ; return ALLOW_32X32 ; else if ( tx_size_search_method == USE_FULL_RD || cpi -> sf . tx_size_search_method == USE_TX_8X8 ) return TX_MODE_SELECT ; else return cpi -> tx_mode ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 689,CWE-119,"CWE-119 void * H264SwDecMalloc ( u32 size ) { return malloc ( size ) ; } "," ( u32 size , u32 num ) { if ( size > UINT32_MAX / num ) { return NULL ; } return malloc ( malloc ( size * num ",frameworks@av/2b6f22dc64d456471a1dc6df09d515771d1427c8,CVE-2016-2463,https://android.googlesource.com/platform/frameworks/av/+/2b6f22dc64d456471a1dc6df09d515771d1427c8,2016-06-13T01:59Z 690,CWE-134,"CWE-134 int print_calc ( image_desc_t * im ) { long i , ii , validsteps ; double printval ; struct tm tmvdef ; int graphelement = 0 ; long vidx ; int max_ii ; double magfact = - 1 ; char * si_symb = """" ; char * percent_s ; int prline_cnt = 0 ; time_t now = time ( NULL ) ; localtime_r ( & now , & tmvdef ) ; for ( i = 0 ; i < im -> gdes_c ; i ++ ) { vidx = im -> gdes [ i ] . vidx ; switch ( im -> gdes [ i ] . gf ) { case GF_PRINT : case GF_GPRINT : if ( im -> gdes [ vidx ] . gf == GF_VDEF ) { printval = im -> gdes [ vidx ] . vf . val ; localtime_r ( & im -> gdes [ vidx ] . vf . when , & tmvdef ) ; } else { max_ii = ( ( im -> gdes [ vidx ] . end - im -> gdes [ vidx ] . start ) / im -> gdes [ vidx ] . step * im -> gdes [ vidx ] . ds_cnt ) ; printval = DNAN ; validsteps = 0 ; for ( ii = im -> gdes [ vidx ] . ds ; ii < max_ii ; ii += im -> gdes [ vidx ] . ds_cnt ) { if ( ! finite ( im -> gdes [ vidx ] . data [ ii ] ) ) continue ; if ( isnan ( printval ) ) { printval = im -> gdes [ vidx ] . data [ ii ] ; validsteps ++ ; continue ; } switch ( im -> gdes [ i ] . cf ) { case CF_HWPREDICT : case CF_MHWPREDICT : case CF_DEVPREDICT : case CF_DEVSEASONAL : case CF_SEASONAL : case CF_AVERAGE : validsteps ++ ; printval += im -> gdes [ vidx ] . data [ ii ] ; break ; case CF_MINIMUM : printval = min ( printval , im -> gdes [ vidx ] . data [ ii ] ) ; break ; case CF_FAILURES : case CF_MAXIMUM : printval = max ( printval , im -> gdes [ vidx ] . data [ ii ] ) ; break ; case CF_LAST : printval = im -> gdes [ vidx ] . data [ ii ] ; } } if ( im -> gdes [ i ] . cf == CF_AVERAGE || im -> gdes [ i ] . cf > CF_LAST ) { if ( validsteps > 1 ) { printval = ( printval / validsteps ) ; } } } if ( ! im -> gdes [ i ] . strftm && ( percent_s = strstr ( im -> gdes [ i ] . format , ""%S"" ) ) != NULL ) { if ( magfact < 0.0 ) { auto_scale ( im , & printval , & si_symb , & magfact ) ; if ( printval == 0.0 ) magfact = - 1.0 ; } else { printval /= magfact ; } * ( ++ percent_s ) = 's' ; } else if ( ! im -> gdes [ i ] . strftm && strstr ( im -> gdes [ i ] . format , ""%s"" ) != NULL ) { auto_scale ( im , & printval , & si_symb , & magfact ) ; } if ( im -> gdes [ i ] . gf == GF_PRINT ) { rrd_infoval_t prline ; if ( im -> gdes [ i ] . strftm ) { prline . u_str = ( char * ) malloc ( ( FMT_LEG_LEN + 2 ) * sizeof ( char ) ) ; if ( im -> gdes [ vidx ] . vf . never == 1 ) { time_clean ( prline . u_str , im -> gdes [ i ] . format ) ; } else { strftime ( prline . u_str , FMT_LEG_LEN , im -> gdes [ i ] . format , & tmvdef ) ; } } else if ( bad_format ( im -> gdes [ i ] . format ) ) { rrd_set_error ( ""badformatforPRINTin\'%s\'"" , im -> gdes [ i ] . format ) ; return - 1 ; } else { prline . u_str = sprintf_alloc ( im -> gdes [ i ] . format , printval , si_symb ) ; } grinfo_push ( im , sprintf_alloc ( ""print[%ld]"" , prline_cnt ++ ) , RD_I_STR , prline ) ; free ( prline . u_str ) ; } else { if ( im -> gdes [ i ] . strftm ) { if ( im -> gdes [ vidx ] . vf . never == 1 ) { time_clean ( im -> gdes [ i ] . legend , im -> gdes [ i ] . format ) ; } else { strftime ( im -> gdes [ i ] . legend , FMT_LEG_LEN , im -> gdes [ i ] . format , & tmvdef ) ; } } else { if ( bad_format ( im -> gdes [ i ] . format ) ) { rrd_set_error ( ""badformatforGPRINTin\'%s\'"" , im -> gdes [ i ] . format ) ; return - 1 ; } snprintf ( im -> gdes [ i ] . legend , FMT_LEG_LEN - 2 , im -> gdes [ i ] . format , printval , si_symb ) ; } graphelement = 1 ; } break ; case GF_LINE : case GF_AREA : case GF_GRAD : case GF_TICK : graphelement = 1 ; break ; case GF_HRULE : if ( isnan ( im -> gdes [ i ] . yrule ) ) { im -> gdes [ i ] . yrule = im -> gdes [ vidx ] . vf . val ; } ; graphelement = 1 ; break ; case GF_VRULE : if ( im -> gdes [ i ] . xrule == 0 ) { im -> gdes [ i ] . xrule = im -> gdes [ vidx ] . vf . when ; } ; graphelement = 1 ; break ; case GF_COMMENT : case GF_TEXTALIGN : case GF_DEF : case GF_CDEF : case GF_VDEF : # ifdef WITH_PIECHART case GF_PART : # endif case GF_SHIFT : case GF_XPORT : break ; case GF_STACK : rrd_set_error ( ""STACKshouldalreadybeturnedintoLINEorAREAhere"" ) ; return - 1 ; break ; case GF_XAXIS : case GF_YAXIS : break ; } } return graphelement ; } "," else if ( bad_format_print ( im -> ) ) { return - 1 { if ( bad_format_print ( im -> ) ) { return - 1 ",oetiker@rrdtool-1.x/64ed5314af1255ab6dded45f70b39cdeab5ae2ec,CVE-2014-6262,https://github.com/oetiker/rrdtool-1.x/commit/64ed5314af1255ab6dded45f70b39cdeab5ae2ec,2020-02-12T02:15Z 691,CWE-119,"CWE-119 static Sdb * store_versioninfo_gnu_verneed ( ELFOBJ * bin , Elf_ ( Shdr ) * shdr , int sz ) { ut8 * end , * need = NULL ; const char * section_name = """" ; Elf_ ( Shdr ) * link_shdr = NULL ; const char * link_section_name = """" ; Sdb * sdb_vernaux = NULL ; Sdb * sdb_version = NULL ; Sdb * sdb = NULL ; int i , cnt ; if ( ! bin || ! bin -> dynstr ) { return NULL ; } if ( shdr -> sh_link > bin -> ehdr . e_shnum ) { return NULL ; } if ( shdr -> sh_size < 1 ) { return NULL ; } sdb = sdb_new0 ( ) ; if ( ! sdb ) { return NULL ; } link_shdr = & bin -> shdr [ shdr -> sh_link ] ; if ( bin -> shstrtab && shdr -> sh_name < bin -> shstrtab_size ) { section_name = & bin -> shstrtab [ shdr -> sh_name ] ; } if ( bin -> shstrtab && link_shdr -> sh_name < bin -> shstrtab_size ) { link_section_name = & bin -> shstrtab [ link_shdr -> sh_name ] ; } if ( ! ( need = ( ut8 * ) calloc ( R_MAX ( 1 , shdr -> sh_size ) , sizeof ( ut8 ) ) ) ) { bprintf ( ""Warning:CannotallocatememoryforElf_(Verneed)\\n"" ) ; goto beach ; } end = need + shdr -> sh_size ; sdb_set ( sdb , ""section_name"" , section_name , 0 ) ; sdb_num_set ( sdb , ""num_entries"" , shdr -> sh_info , 0 ) ; sdb_num_set ( sdb , ""addr"" , shdr -> sh_addr , 0 ) ; sdb_num_set ( sdb , ""offset"" , shdr -> sh_offset , 0 ) ; sdb_num_set ( sdb , ""link"" , shdr -> sh_link , 0 ) ; sdb_set ( sdb , ""link_section_name"" , link_section_name , 0 ) ; if ( shdr -> sh_offset > bin -> size || shdr -> sh_offset + shdr -> sh_size > bin -> size ) { goto beach ; } if ( shdr -> sh_offset + shdr -> sh_size < shdr -> sh_size ) { goto beach ; } i = r_buf_read_at ( bin -> b , shdr -> sh_offset , need , shdr -> sh_size ) ; if ( i < 0 ) goto beach ; for ( i = 0 , cnt = 0 ; cnt < shdr -> sh_info ; ++ cnt ) { int j , isum ; ut8 * vstart = need + i ; Elf_ ( Verneed ) vvn = { 0 } ; if ( vstart + sizeof ( Elf_ ( Verneed ) ) > end ) { goto beach ; } Elf_ ( Verneed ) * entry = & vvn ; char key [ 32 ] = { 0 } ; sdb_version = sdb_new0 ( ) ; if ( ! sdb_version ) { goto beach ; } j = 0 ; vvn . vn_version = READ16 ( vstart , j ) vvn . vn_cnt = READ16 ( vstart , j ) vvn . vn_file = READ32 ( vstart , j ) vvn . vn_aux = READ32 ( vstart , j ) vvn . vn_next = READ32 ( vstart , j ) sdb_num_set ( sdb_version , ""vn_version"" , entry -> vn_version , 0 ) ; sdb_num_set ( sdb_version , ""idx"" , i , 0 ) ; if ( entry -> vn_file > bin -> dynstr_size ) { goto beach ; } { char * s = r_str_ndup ( & bin -> dynstr [ entry -> vn_file ] , 16 ) ; sdb_set ( sdb_version , ""file_name"" , s , 0 ) ; free ( s ) ; } sdb_num_set ( sdb_version , ""cnt"" , entry -> vn_cnt , 0 ) ; st32 vnaux = entry -> vn_aux ; if ( vnaux < 1 ) { goto beach ; } vstart += vnaux ; for ( j = 0 , isum = i + entry -> vn_aux ; j < entry -> vn_cnt && vstart + sizeof ( Elf_ ( Vernaux ) ) <= end ; ++ j ) { int k ; Elf_ ( Vernaux ) * aux = NULL ; Elf_ ( Vernaux ) vaux = { 0 } ; sdb_vernaux = sdb_new0 ( ) ; if ( ! sdb_vernaux ) { goto beach ; } aux = ( Elf_ ( Vernaux ) * ) & vaux ; k = 0 ; vaux . vna_hash = READ32 ( vstart , k ) vaux . vna_flags = READ16 ( vstart , k ) vaux . vna_other = READ16 ( vstart , k ) vaux . vna_name = READ32 ( vstart , k ) vaux . vna_next = READ32 ( vstart , k ) if ( aux -> vna_name > bin -> dynstr_size ) { goto beach ; } sdb_num_set ( sdb_vernaux , ""idx"" , isum , 0 ) ; if ( aux -> vna_name > 0 && aux -> vna_name + 8 < bin -> dynstr_size ) { char name [ 16 ] ; strncpy ( name , & bin -> dynstr [ aux -> vna_name ] , sizeof ( name ) - 1 ) ; name [ sizeof ( name ) - 1 ] = 0 ; sdb_set ( sdb_vernaux , ""name"" , name , 0 ) ; } sdb_set ( sdb_vernaux , ""flags"" , get_ver_flags ( aux -> vna_flags ) , 0 ) ; sdb_num_set ( sdb_vernaux , ""version"" , aux -> vna_other , 0 ) ; isum += aux -> vna_next ; vstart += aux -> vna_next ; snprintf ( key , sizeof ( key ) , ""vernaux%d"" , j ) ; sdb_ns_set ( sdb_version , key , sdb_vernaux ) ; } if ( ( int ) entry -> vn_next < 0 ) { bprintf ( ""Invalidvn_next\\n"" ) ; break ; } i += entry -> vn_next ; snprintf ( key , sizeof ( key ) , ""version%d"" , cnt ) ; sdb_ns_set ( sdb , key , sdb_version ) ; if ( ! entry -> vn_next ) { break ; } } free ( need ) ; return sdb ; beach : free ( need ) ; sdb_free ( sdb_vernaux ) ; sdb_free ( sdb_version ) ; sdb_free ( sdb ) ; return NULL ; } "," sh_size < 1 || shdr -> sh_size > SIZE_MAX ",radare@radare2/0b973e28166636e0ff1fad80baa0385c9c09c53a,CVE-2017-16357,https://github.com/radare/radare2/commit/0b973e28166636e0ff1fad80baa0385c9c09c53a,2017-11-01T17:29Z 692,CWE-119,"CWE-119 static int compare_tile_buffers ( const void * a , const void * b ) { const TileBuffer * const buf1 = ( const TileBuffer * ) a ; const TileBuffer * const buf2 = ( const TileBuffer * ) b ; if ( buf1 -> size < buf2 -> size ) { return 1 ; } else if ( buf1 -> size == buf2 -> size ) { return 0 ; } else { return - 1 ; } } "," ) b ; return ( int ) ( buf2 -> size - buf1 -> size buf1 -> size ) ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 693,CWE-119,"CWE-119 protected int file_trycdf ( struct magic_set * ms , int fd , const unsigned char * buf , size_t nbytes ) { cdf_info_t info ; cdf_header_t h ; cdf_sat_t sat , ssat ; cdf_stream_t sst , scn ; cdf_dir_t dir ; int i ; const char * expn = """" ; const char * corrupt = ""corrupt:"" ; info . i_fd = fd ; info . i_buf = buf ; info . i_len = nbytes ; if ( ms -> flags & MAGIC_APPLE ) return 0 ; if ( cdf_read_header ( & info , & h ) == - 1 ) return 0 ; # ifdef CDF_DEBUG cdf_dump_header ( & h ) ; # endif if ( ( i = cdf_read_sat ( & info , & h , & sat ) ) == - 1 ) { expn = ""Can\'treadSAT"" ; goto out0 ; } # ifdef CDF_DEBUG cdf_dump_sat ( ""SAT"" , & sat , CDF_SEC_SIZE ( & h ) ) ; # endif if ( ( i = cdf_read_ssat ( & info , & h , & sat , & ssat ) ) == - 1 ) { expn = ""Can\'treadSSAT"" ; goto out1 ; } # ifdef CDF_DEBUG cdf_dump_sat ( ""SSAT"" , & ssat , CDF_SHORT_SEC_SIZE ( & h ) ) ; # endif if ( ( i = cdf_read_dir ( & info , & h , & sat , & dir ) ) == - 1 ) { expn = ""Can\'treaddirectory"" ; goto out2 ; } const cdf_directory_t * root_storage ; if ( ( i = cdf_read_short_stream ( & info , & h , & sat , & dir , & sst , & root_storage ) ) == - 1 ) { expn = ""Cannotreadshortstream"" ; goto out3 ; } # ifdef CDF_DEBUG cdf_dump_dir ( & info , & h , & sat , & ssat , & sst , & dir ) ; # endif # ifdef notdef if ( root_storage ) { if ( NOTMIME ( ms ) ) { char clsbuf [ 128 ] ; if ( file_printf ( ms , ""CLSID%s,"" , format_clsid ( clsbuf , sizeof ( clsbuf ) , root_storage -> d_storage_uuid ) ) == - 1 ) return - 1 ; } } # endif if ( ( i = cdf_read_summary_info ( & info , & h , & sat , & ssat , & sst , & dir , & scn ) ) == - 1 ) { if ( errno == ESRCH ) { corrupt = expn ; expn = ""Nosummaryinfo"" ; } else { expn = ""Cannotreadsummaryinfo"" ; } goto out4 ; } # ifdef CDF_DEBUG cdf_dump_summary_info ( & h , & scn ) ; # endif if ( ( i = cdf_file_summary_info ( ms , & h , & scn , root_storage -> d_storage_uuid ) ) < 0 ) expn = ""Can\'texpandsummary_info"" ; if ( i == 0 ) { const char * str = NULL ; cdf_directory_t * d ; char name [ __arraycount ( d -> d_name ) ] ; size_t j , k ; for ( j = 0 ; str == NULL && j < dir . dir_len ; j ++ ) { d = & dir . dir_tab [ j ] ; for ( k = 0 ; k < sizeof ( name ) ; k ++ ) name [ k ] = ( char ) cdf_tole2 ( d -> d_name [ k ] ) ; str = cdf_app_to_mime ( name , NOTMIME ( ms ) ? name2desc : name2mime ) ; } if ( NOTMIME ( ms ) ) { if ( str != NULL ) { if ( file_printf ( ms , ""%s"" , str ) == - 1 ) return - 1 ; i = 1 ; } } else { if ( str == NULL ) str = ""vnd.ms-office"" ; if ( file_printf ( ms , ""application/%s"" , str ) == - 1 ) return - 1 ; i = 1 ; } } free ( scn . sst_tab ) ; out4 : free ( sst . sst_tab ) ; out3 : free ( dir . dir_tab ) ; out2 : free ( ssat . sat_tab ) ; out1 : free ( sat . sat_tab ) ; out0 : if ( i == - 1 ) { if ( NOTMIME ( ms ) ) { if ( file_printf ( ms , ""CompositeDocumentFileV2Document"" ) == - 1 ) return - 1 ; if ( * expn ) if ( file_printf ( ms , "",%s%s"" , corrupt , expn ) == - 1 ) return - 1 ; } else { if ( file_printf ( ms , ""application/CDFV2-corrupt"" ) == - 1 ) return - 1 ; } i = 1 ; } return i ; } "," scn , root_storage ) ) < ",file@file/6d209c1c489457397a5763bca4b28e43aac90391,CVE-2014-0207,https://github.com/file/file/commit/6d209c1c489457397a5763bca4b28e43aac90391,2014-07-09T11:07Z 694,CWE-189,"CWE-189 struct xt_table_info * xt_alloc_table_info ( unsigned int size ) { struct xt_table_info * info = NULL ; size_t sz = sizeof ( * info ) + size ; if ( ( SMP_ALIGN ( size ) >> PAGE_SHIFT ) + 2 > totalram_pages ) return NULL ; if ( sz <= ( PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER ) ) info = kmalloc ( sz , GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY ) ; if ( ! info ) { info = vmalloc ( sz ) ; if ( ! info ) return NULL ; } memset ( info , 0 , sizeof ( * info ) ) ; info -> size = size ; return info ; } "," ) + size ; if ( sz < sizeof ( * info ) ) return NULL ",torvalds@linux/d157bd761585605b7882935ffb86286919f62ea1,CVE-2016-3135,https://github.com/torvalds/linux/commit/d157bd761585605b7882935ffb86286919f62ea1,2016-04-27T17:59Z 695,CWE-400,"CWE-400 static inline int add_post_vars ( zval * arr , post_var_data_t * vars , zend_bool eof TSRMLS_DC ) { uint64_t max_vars = PG ( max_input_vars ) ; vars -> ptr = vars -> str . c ; vars -> end = vars -> str . c + vars -> str . len ; while ( add_post_var ( arr , vars , eof TSRMLS_CC ) ) { if ( ++ vars -> cnt > max_vars ) { php_error_docref ( NULL TSRMLS_CC , E_WARNING , ""Inputvariablesexceeded%"" PRIu64 ""."" ""Toincreasethelimitchangemax_input_varsinphp.ini."" , max_vars ) ; return FAILURE ; } } if ( ! eof ) { memmove ( vars -> str . c , vars -> ptr , vars -> str . len = vars -> end - vars -> ptr ) ; } return SUCCESS ; } "," ( ! eof && vars -> str . c != vars -> ptr ",php@php-src/0f8cf3b8497dc45c010c44ed9e96518e11e19fc3,CVE-2017-11142,https://github.com/php/php-src/commit/0f8cf3b8497dc45c010c44ed9e96518e11e19fc3,2017-07-10T14:29Z 696,CWE-000,"CWE-000 static int ax25_create ( struct net * net , struct socket * sock , int protocol , int kern ) { struct sock * sk ; ax25_cb * ax25 ; if ( ! net_eq ( net , & init_net ) ) return - EAFNOSUPPORT ; switch ( sock -> type ) { case SOCK_DGRAM : if ( protocol == 0 || protocol == PF_AX25 ) protocol = AX25_P_TEXT ; break ; case SOCK_SEQPACKET : switch ( protocol ) { case 0 : case PF_AX25 : protocol = AX25_P_TEXT ; break ; case AX25_P_SEGMENT : # ifdef CONFIG_INET case AX25_P_ARP : case AX25_P_IP : # endif # ifdef CONFIG_NETROM case AX25_P_NETROM : # endif # ifdef CONFIG_ROSE case AX25_P_ROSE : # endif return - ESOCKTNOSUPPORT ; # ifdef CONFIG_NETROM_MODULE case AX25_P_NETROM : if ( ax25_protocol_is_registered ( AX25_P_NETROM ) ) return - ESOCKTNOSUPPORT ; break ; # endif # ifdef CONFIG_ROSE_MODULE case AX25_P_ROSE : if ( ax25_protocol_is_registered ( AX25_P_ROSE ) ) return - ESOCKTNOSUPPORT ; # endif default : break ; } break ; case SOCK_RAW : break ; default : return - ESOCKTNOSUPPORT ; } sk = sk_alloc ( net , PF_AX25 , GFP_ATOMIC , & ax25_proto , kern ) ; if ( sk == NULL ) return - ENOMEM ; ax25 = ax25_sk ( sk ) -> cb = ax25_create_cb ( ) ; if ( ! ax25 ) { sk_free ( sk ) ; return - ENOMEM ; } sock_init_data ( sock , sk ) ; sk -> sk_destruct = ax25_free_sock ; sock -> ops = & ax25_proto_ops ; sk -> sk_protocol = protocol ; ax25 -> sk = sk ; return 0 ; } "," ; if ( protocol < 0 || protocol > SK_PROTOCOL_MAX ) return - EINVAL ; if ( ",torvalds@linux/79462ad02e861803b3840cc782248c7359451cd9,CVE-2015-8543,https://github.com/torvalds/linux/commit/79462ad02e861803b3840cc782248c7359451cd9,2015-12-28T11:59Z 697,CWE-400,"CWE-400 asmlinkage void do_page_fault ( struct pt_regs * regs , unsigned long writeaccess , unsigned long textaccess , unsigned long address ) { struct task_struct * tsk ; struct mm_struct * mm ; struct vm_area_struct * vma ; const struct exception_table_entry * fixup ; pte_t * pte ; int fault ; tsk = current ; mm = tsk -> mm ; local_irq_enable ( ) ; perf_sw_event ( PERF_COUNT_SW_PAGE_FAULTS , 1 , 0 , regs , address ) ; if ( in_atomic ( ) || ! mm ) goto no_context ; down_read ( & mm -> mmap_sem ) ; vma = find_vma ( mm , address ) ; if ( ! vma ) { # ifdef DEBUG_FAULT print_task ( tsk ) ; printk ( ""%s:%dfault,addressis0x%08xPC%016Lxtextaccess%dwriteaccess%d\\n"" , __func__ , __LINE__ , address , regs -> pc , textaccess , writeaccess ) ; show_regs ( regs ) ; # endif goto bad_area ; } if ( vma -> vm_start <= address ) { goto good_area ; } if ( ! ( vma -> vm_flags & VM_GROWSDOWN ) ) { # ifdef DEBUG_FAULT print_task ( tsk ) ; printk ( ""%s:%dfault,addressis0x%08xPC%016Lxtextaccess%dwriteaccess%d\\n"" , __func__ , __LINE__ , address , regs -> pc , textaccess , writeaccess ) ; show_regs ( regs ) ; print_vma ( vma ) ; # endif goto bad_area ; } if ( expand_stack ( vma , address ) ) { # ifdef DEBUG_FAULT print_task ( tsk ) ; printk ( ""%s:%dfault,addressis0x%08xPC%016Lxtextaccess%dwriteaccess%d\\n"" , __func__ , __LINE__ , address , regs -> pc , textaccess , writeaccess ) ; show_regs ( regs ) ; # endif goto bad_area ; } good_area : if ( textaccess ) { if ( ! ( vma -> vm_flags & VM_EXEC ) ) goto bad_area ; } else { if ( writeaccess ) { if ( ! ( vma -> vm_flags & VM_WRITE ) ) goto bad_area ; } else { if ( ! ( vma -> vm_flags & VM_READ ) ) goto bad_area ; } } fault = handle_mm_fault ( mm , vma , address , writeaccess ? FAULT_FLAG_WRITE : 0 ) ; if ( unlikely ( fault & VM_FAULT_ERROR ) ) { if ( fault & VM_FAULT_OOM ) goto out_of_memory ; else if ( fault & VM_FAULT_SIGBUS ) goto do_sigbus ; BUG ( ) ; } if ( fault & VM_FAULT_MAJOR ) { tsk -> maj_flt ++ ; perf_sw_event ( PERF_COUNT_SW_PAGE_FAULTS_MAJ , 1 , 0 , regs , address ) ; } else { tsk -> min_flt ++ ; perf_sw_event ( PERF_COUNT_SW_PAGE_FAULTS_MIN , 1 , 0 , regs , address ) ; } pte = lookup_pte ( mm , address ) ; if ( ! pte ) { goto no_pte ; } __do_tlb_refill ( address , textaccess , pte ) ; no_pte : up_read ( & mm -> mmap_sem ) ; return ; bad_area : # ifdef DEBUG_FAULT printk ( ""fault:badarea\\n"" ) ; # endif up_read ( & mm -> mmap_sem ) ; if ( user_mode ( regs ) ) { static int count = 0 ; siginfo_t info ; if ( count < 4 ) { count ++ ; printk ( ""usermodebad_areaaddress=%08lxpid=%d(%s)pc=%08lx\\n"" , address , task_pid_nr ( current ) , current -> comm , ( unsigned long ) regs -> pc ) ; # if 0 show_regs ( regs ) ; # endif } if ( is_global_init ( tsk ) ) { panic ( ""INIThadusermodebad_area\\n"" ) ; } tsk -> thread . address = address ; tsk -> thread . error_code = writeaccess ; info . si_signo = SIGSEGV ; info . si_errno = 0 ; info . si_addr = ( void * ) address ; force_sig_info ( SIGSEGV , & info , tsk ) ; return ; } no_context : # ifdef DEBUG_FAULT printk ( ""fault:Nocontext\\n"" ) ; # endif fixup = search_exception_tables ( regs -> pc ) ; if ( fixup ) { regs -> pc = fixup -> fixup ; return ; } if ( address < PAGE_SIZE ) printk ( KERN_ALERT ""UnabletohandlekernelNULLpointerdereference"" ) ; else printk ( KERN_ALERT ""Unabletohandlekernelpagingrequest"" ) ; printk ( ""atvirtualaddress%08lx\\n"" , address ) ; printk ( KERN_ALERT ""pc=%08Lx%08Lx\\n"" , regs -> pc >> 32 , regs -> pc & 0xffffffff ) ; die ( ""Oops"" , regs , writeaccess ) ; do_exit ( SIGKILL ) ; out_of_memory : up_read ( & mm -> mmap_sem ) ; if ( ! user_mode ( regs ) ) goto no_context ; pagefault_out_of_memory ( ) ; return ; do_sigbus : printk ( ""fault:Dosigbus\\n"" ) ; up_read ( & mm -> mmap_sem ) ; tsk -> thread . address = address ; tsk -> thread . error_code = writeaccess ; tsk -> thread . trap_no = 14 ; force_sig ( SIGBUS , tsk ) ; if ( ! user_mode ( regs ) ) goto no_context ; } "," , 1 , regs , address , 1 , regs , address PERF_COUNT_SW_PAGE_FAULTS_MIN , 1 , regs , ",torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,CVE-2011-2918,https://github.com/torvalds/linux/commit/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,2012-05-24T23:55Z 698,CWE-000,"CWE-000 static int em_grp45 ( struct x86_emulate_ctxt * ctxt ) { int rc = X86EMUL_CONTINUE ; switch ( ctxt -> modrm_reg ) { case 2 : { long int old_eip ; old_eip = ctxt -> _eip ; ctxt -> _eip = ctxt -> src . val ; ctxt -> src . val = old_eip ; rc = em_push ( ctxt ) ; break ; } case 4 : ctxt -> _eip = ctxt -> src . val ; break ; case 5 : rc = em_jmp_far ( ctxt ) ; break ; case 6 : rc = em_push ( ctxt ) ; break ; } return rc ; } "," -> _eip ; rc = assign_eip_near ( ctxt , ctxt -> src src . val ) ; if ( rc != X86EMUL_CONTINUE ) break case 4 : rc = assign_eip_near ( ctxt , ctxt -> src src . val ) ",torvalds@linux/234f3ce485d54017f15cf5e0699cff4100121601,CVE-2014-3647,https://github.com/torvalds/linux/commit/234f3ce485d54017f15cf5e0699cff4100121601,2014-11-10T11:55Z 699,CWE-77,"CWE-77 static void cmd_parse_lsub ( struct ImapData * idata , char * s ) { char buf [ STRING ] ; char errstr [ STRING ] ; struct Buffer err , token ; struct Url url ; struct ImapList list ; if ( idata -> cmddata && idata -> cmdtype == IMAP_CT_LIST ) { cmd_parse_list ( idata , s ) ; return ; } if ( ! ImapCheckSubscribed ) return ; idata -> cmdtype = IMAP_CT_LIST ; idata -> cmddata = & list ; cmd_parse_list ( idata , s ) ; idata -> cmddata = NULL ; if ( ! list . name || list . noselect ) return ; mutt_debug ( 3 , ""Subscribingto%s\\n"" , list . name ) ; mutt_str_strfcpy ( buf , ""mailboxes\\"""" , sizeof ( buf ) ) ; mutt_account_tourl ( & idata -> conn -> account , & url ) ; imap_quote_string ( errstr , sizeof ( errstr ) , list . name ) ; url . path = errstr + 1 ; url . path [ strlen ( url . path ) - 1 ] = '\\0' ; if ( mutt_str_strcmp ( url . user , ImapUser ) == 0 ) url . user = NULL ; url_tostring ( & url , buf + 11 , sizeof ( buf ) - 11 , 0 ) ; mutt_str_strcat ( buf , sizeof ( buf ) , ""\\"""" ) ; mutt_buffer_init ( & token ) ; mutt_buffer_init ( & err ) ; err . data = errstr ; err . dsize = sizeof ( errstr ) ; if ( mutt_parse_rc_line ( buf , & token , & err ) ) mutt_debug ( 1 , ""Erroraddingsubscribedmailbox:%s\\n"" , errstr ) ; FREE ( & token . data ) ; } "," list . name , true ",neomutt@neomutt/e52393740334443ae0206cab2d7caef381646725,CVE-2018-14357,https://github.com/neomutt/neomutt/commit/e52393740334443ae0206cab2d7caef381646725,2018-07-17T17:29Z 700,CWE-399,"CWE-399 static int process_one_ticket ( struct ceph_auth_client * ac , struct ceph_crypto_key * secret , void * * p , void * end , void * dbuf , void * ticket_buf ) { struct ceph_x_info * xi = ac -> private ; int type ; u8 tkt_struct_v , blob_struct_v ; struct ceph_x_ticket_handler * th ; void * dp , * dend ; int dlen ; char is_enc ; struct timespec validity ; struct ceph_crypto_key old_key ; void * tp , * tpend ; struct ceph_timespec new_validity ; struct ceph_crypto_key new_session_key ; struct ceph_buffer * new_ticket_blob ; unsigned long new_expires , new_renew_after ; u64 new_secret_id ; int ret ; ceph_decode_need ( p , end , sizeof ( u32 ) + 1 , bad ) ; type = ceph_decode_32 ( p ) ; dout ( ""tickettype%d%s\\n"" , type , ceph_entity_type_name ( type ) ) ; tkt_struct_v = ceph_decode_8 ( p ) ; if ( tkt_struct_v != 1 ) goto bad ; th = get_ticket_handler ( ac , type ) ; if ( IS_ERR ( th ) ) { ret = PTR_ERR ( th ) ; goto out ; } dlen = ceph_x_decrypt ( secret , p , end , dbuf , TEMP_TICKET_BUF_LEN ) ; if ( dlen <= 0 ) { ret = dlen ; goto out ; } dout ( ""decrypted%dbytes\\n"" , dlen ) ; dp = dbuf ; dend = dp + dlen ; tkt_struct_v = ceph_decode_8 ( & dp ) ; if ( tkt_struct_v != 1 ) goto bad ; memcpy ( & old_key , & th -> session_key , sizeof ( old_key ) ) ; ret = ceph_crypto_key_decode ( & new_session_key , & dp , dend ) ; if ( ret ) goto out ; ceph_decode_copy ( & dp , & new_validity , sizeof ( new_validity ) ) ; ceph_decode_timespec ( & validity , & new_validity ) ; new_expires = get_seconds ( ) + validity . tv_sec ; new_renew_after = new_expires - ( validity . tv_sec / 4 ) ; dout ( ""expires=%lurenew_after=%lu\\n"" , new_expires , new_renew_after ) ; ceph_decode_8_safe ( p , end , is_enc , bad ) ; tp = ticket_buf ; if ( is_enc ) { dout ( ""encryptedticket\\n"" ) ; dlen = ceph_x_decrypt ( & old_key , p , end , ticket_buf , TEMP_TICKET_BUF_LEN ) ; if ( dlen < 0 ) { ret = dlen ; goto out ; } dlen = ceph_decode_32 ( & tp ) ; } else { ceph_decode_32_safe ( p , end , dlen , bad ) ; ceph_decode_need ( p , end , dlen , bad ) ; ceph_decode_copy ( p , ticket_buf , dlen ) ; } tpend = tp + dlen ; dout ( ""ticketblobis%dbytes\\n"" , dlen ) ; ceph_decode_need ( & tp , tpend , 1 + sizeof ( u64 ) , bad ) ; blob_struct_v = ceph_decode_8 ( & tp ) ; new_secret_id = ceph_decode_64 ( & tp ) ; ret = ceph_decode_buffer ( & new_ticket_blob , & tp , tpend ) ; if ( ret ) goto out ; ceph_crypto_key_destroy ( & th -> session_key ) ; if ( th -> ticket_blob ) ceph_buffer_put ( th -> ticket_blob ) ; th -> session_key = new_session_key ; th -> ticket_blob = new_ticket_blob ; th -> validity = new_validity ; th -> secret_id = new_secret_id ; th -> expires = new_expires ; th -> renew_after = new_renew_after ; dout ( ""gotticketservice%d(%s)secret_id%lldlen%d\\n"" , type , ceph_entity_type_name ( type ) , th -> secret_id , ( int ) th -> ticket_blob -> vec . iov_len ) ; xi -> have_keys |= th -> service ; out : return ret ; bad : ret = - EINVAL ; goto out ; } "," void * end ) { struct ; void * dbuf = NULL ; void * struct ceph_crypto_key old_key ; void * ticket_buf = NULL , end , & dbuf , 0 ) ; if bad ) ; if ( is_enc ) { dout ( ""encryptedticket\\n"" ) ; dlen = ceph_x_decrypt ( & old_key , p , end , & ticket_buf , 0 ) ; if out ; } tp = ticket_buf ; bad ) ; ticket_buf = kmalloc ( dlen , GFP_NOFS ) ; if ( ! ticket_buf ) { ret = - ENOMEM ; goto out ; } tp = ticket_buf ; ; out : kfree ( ticket_buf ) ; kfree ( dbuf ) ; ",torvalds@linux/c27a3e4d667fdcad3db7b104f75659478e0c68d8,CVE-2014-6418,https://github.com/torvalds/linux/commit/c27a3e4d667fdcad3db7b104f75659478e0c68d8,2014-09-28T10:55Z 701,CWE-189,"CWE-189 Datum hstore_from_array ( PG_FUNCTION_ARGS ) { ArrayType * in_array = PG_GETARG_ARRAYTYPE_P ( 0 ) ; int ndims = ARR_NDIM ( in_array ) ; int count ; int32 buflen ; HStore * out ; Pairs * pairs ; Datum * in_datums ; bool * in_nulls ; int in_count ; int i ; Assert ( ARR_ELEMTYPE ( in_array ) == TEXTOID ) ; switch ( ndims ) { case 0 : out = hstorePairs ( NULL , 0 , 0 ) ; PG_RETURN_POINTER ( out ) ; case 1 : if ( ( ARR_DIMS ( in_array ) [ 0 ] ) % 2 ) ereport ( ERROR , ( errcode ( ERRCODE_ARRAY_SUBSCRIPT_ERROR ) , errmsg ( ""arraymusthaveevennumberofelements"" ) ) ) ; break ; case 2 : if ( ( ARR_DIMS ( in_array ) [ 1 ] ) != 2 ) ereport ( ERROR , ( errcode ( ERRCODE_ARRAY_SUBSCRIPT_ERROR ) , errmsg ( ""arraymusthavetwocolumns"" ) ) ) ; break ; default : ereport ( ERROR , ( errcode ( ERRCODE_ARRAY_SUBSCRIPT_ERROR ) , errmsg ( ""wrongnumberofarraysubscripts"" ) ) ) ; } deconstruct_array ( in_array , TEXTOID , - 1 , false , 'i' , & in_datums , & in_nulls , & in_count ) ; count = in_count / 2 ; pairs = palloc ( count * sizeof ( Pairs ) ) ; for ( i = 0 ; i < count ; ++ i ) { if ( in_nulls [ i * 2 ] ) ereport ( ERROR , ( errcode ( ERRCODE_NULL_VALUE_NOT_ALLOWED ) , errmsg ( ""nullvaluenotallowedforhstorekey"" ) ) ) ; if ( in_nulls [ i * 2 + 1 ] ) { pairs [ i ] . key = VARDATA_ANY ( in_datums [ i * 2 ] ) ; pairs [ i ] . val = NULL ; pairs [ i ] . keylen = hstoreCheckKeyLen ( VARSIZE_ANY_EXHDR ( in_datums [ i * 2 ] ) ) ; pairs [ i ] . vallen = 4 ; pairs [ i ] . isnull = true ; pairs [ i ] . needfree = false ; } else { pairs [ i ] . key = VARDATA_ANY ( in_datums [ i * 2 ] ) ; pairs [ i ] . val = VARDATA_ANY ( in_datums [ i * 2 + 1 ] ) ; pairs [ i ] . keylen = hstoreCheckKeyLen ( VARSIZE_ANY_EXHDR ( in_datums [ i * 2 ] ) ) ; pairs [ i ] . vallen = hstoreCheckValLen ( VARSIZE_ANY_EXHDR ( in_datums [ i * 2 + 1 ] ) ) ; pairs [ i ] . isnull = false ; pairs [ i ] . needfree = false ; } } count = hstoreUniquePairs ( pairs , count , & buflen ) ; out = hstorePairs ( pairs , count , buflen ) ; PG_RETURN_POINTER ( out ) ; } "," / 2 ; if ( count > MaxAllocSize / sizeof ( Pairs ) ) ereport ( ERROR , ( errcode ( ERRCODE_PROGRAM_LIMIT_EXCEEDED ) , errmsg ( ""numberofpairs(%d)exceedsthemaximumallowed(%d)"" , count , ( int ) ( MaxAllocSize / sizeof ( Pairs ) ) ) ) ) ; ",postgres@postgres/31400a673325147e1205326008e32135a78b4d8a,CVE-2014-2669,https://github.com/postgres/postgres/commit/31400a673325147e1205326008e32135a78b4d8a,2014-03-31T14:58Z 702,CWE-000,"CWE-000 static void put_prev_task ( struct rq * rq , struct task_struct * prev ) { if ( prev -> se . on_rq ) update_rq_clock ( rq ) ; rq -> skip_clock_update = 0 ; prev -> sched_class -> put_prev_task ( rq , prev ) ; } "," rq ) ; prev -> sched_class ",torvalds@linux/f26f9aff6aaf67e9a430d16c266f91b13a5bff64,CVE-2011-4621,https://github.com/torvalds/linux/commit/f26f9aff6aaf67e9a430d16c266f91b13a5bff64,2012-05-17T11:00Z 703,CWE-362,"CWE-362 int ssl3_get_new_session_ticket ( SSL * s ) { int ok , al , ret = 0 , ticklen ; long n ; const unsigned char * p ; unsigned char * d ; n = s -> method -> ssl_get_message ( s , SSL3_ST_CR_SESSION_TICKET_A , SSL3_ST_CR_SESSION_TICKET_B , SSL3_MT_NEWSESSION_TICKET , 16384 , & ok ) ; if ( ! ok ) return ( ( int ) n ) ; if ( n < 6 ) { al = SSL_AD_DECODE_ERROR ; SSLerr ( SSL_F_SSL3_GET_NEW_SESSION_TICKET , SSL_R_LENGTH_MISMATCH ) ; goto f_err ; } p = d = ( unsigned char * ) s -> init_msg ; n2l ( p , s -> session -> tlsext_tick_lifetime_hint ) ; n2s ( p , ticklen ) ; if ( ticklen + 6 != n ) { al = SSL_AD_DECODE_ERROR ; SSLerr ( SSL_F_SSL3_GET_NEW_SESSION_TICKET , SSL_R_LENGTH_MISMATCH ) ; goto f_err ; } OPENSSL_free ( s -> session -> tlsext_tick ) ; s -> session -> tlsext_ticklen = 0 ; s -> session -> tlsext_tick = OPENSSL_malloc ( ticklen ) ; if ( ! s -> session -> tlsext_tick ) { SSLerr ( SSL_F_SSL3_GET_NEW_SESSION_TICKET , ERR_R_MALLOC_FAILURE ) ; goto err ; } memcpy ( s -> session -> tlsext_tick , p , ticklen ) ; s -> session -> tlsext_ticklen = ticklen ; EVP_Digest ( p , ticklen , s -> session -> session_id , & s -> session -> session_id_length , EVP_sha256 ( ) , NULL ) ; ret = 1 ; return ( ret ) ; f_err : ssl3_send_alert ( s , SSL3_AL_FATAL , al ) ; err : s -> state = SSL_ST_ERR ; return ( - 1 ) ; } "," -> init_msg ; if ( s -> session -> session_id_length > 0 ) { int i = s -> session_ctx -> session_cache_mode ; SSL_SESSION * new_sess ; if ( i & SSL_SESS_CACHE_CLIENT ) { if ( i & SSL_SESS_CACHE_NO_INTERNAL_STORE ) { if ( s -> session_ctx -> remove_session_cb != NULL ) s -> session_ctx -> remove_session_cb ( s -> session_ctx , s -> session ) ; } else { SSL_CTX_remove_session ( s -> session_ctx , s -> session ) ; } } if ( ( new_sess = ssl_session_dup ( s -> session , 0 ) ) == 0 ) { al = SSL_AD_INTERNAL_ERROR ; SSLerr ( SSL_F_SSL3_GET_NEW_SESSION_TICKET , ERR_R_MALLOC_FAILURE ) ; goto f_err ; } SSL_SESSION_free ( s -> session ) ; s -> session = new_sess ; } ",openssl@openssl/98ece4eebfb6cd45cc8d550c6ac0022965071afc,CVE-2015-1791,https://github.com/openssl/openssl/commit/98ece4eebfb6cd45cc8d550c6ac0022965071afc,2015-06-12T19:59Z 704,CWE-772,"CWE-772 int button_open ( Button * b ) { char * p , name [ 256 ] ; int r ; assert ( b ) ; b -> fd = safe_close ( b -> fd ) ; p = strjoina ( ""/dev/input/"" , b -> name ) ; b -> fd = open ( p , O_RDWR | O_CLOEXEC | O_NOCTTY | O_NONBLOCK ) ; if ( b -> fd < 0 ) return log_warning_errno ( errno , ""Failedtoopen%s:%m"" , p ) ; r = button_suitable ( b ) ; if ( r < 0 ) return log_warning_errno ( r , ""Failedtodeterminewhetherinputdeviceisrelevanttous:%m"" ) ; if ( r == 0 ) return log_debug_errno ( SYNTHETIC_ERRNO ( EADDRNOTAVAIL ) , ""Device%sdoesnotexposekeysorswitchesrelevanttous,ignoring."" , p ) ; if ( ioctl ( b -> fd , EVIOCGNAME ( sizeof ( name ) ) , name ) < 0 ) { r = log_error_errno ( errno , ""Failedtogetinputname:%m"" ) ; goto fail ; } ( void ) button_set_mask ( b ) ; r = sd_event_add_io ( b -> manager -> event , & b -> io_event_source , b -> fd , EPOLLIN , button_dispatch , b ) ; if ( r < 0 ) { log_error_errno ( r , ""Failedtoaddbuttonevent:%m"" ) ; goto fail ; } log_info ( ""Watchingsystembuttonson/dev/input/%s(%s)"" , b -> name , name ) ; return 0 ; fail : b -> fd = safe_close ( b -> fd ) ; return r ; } "," b ) ; b -> io_event_source = sd_event_source_unref ( b -> io_event_source ) ; ",systemd@systemd/b2774a3ae692113e1f47a336a6c09bac9cfb49ad,CVE-2019-20386,https://github.com/systemd/systemd/commit/b2774a3ae692113e1f47a336a6c09bac9cfb49ad,2020-01-21T06:15Z 705,CWE-119,"CWE-119 int test ( char * URL ) { int errors = 0 ; ( void ) URL ; errors += test_weird_arguments ( ) ; errors += test_unsigned_short_formatting ( ) ; errors += test_signed_short_formatting ( ) ; errors += test_unsigned_int_formatting ( ) ; errors += test_signed_int_formatting ( ) ; errors += test_unsigned_long_formatting ( ) ; errors += test_signed_long_formatting ( ) ; errors += test_curl_off_t_formatting ( ) ; errors += test_string_formatting ( ) ; if ( errors ) return TEST_ERR_MAJOR_BAD ; else return 0 ; } "," ( ) ; errors += test_float_formatting ( ) ; ",curl@curl/3ab3c16db6a5674f53cf23d56512a405fde0b2c9,CVE-2016-9586,https://github.com/curl/curl/commit/curl-7_51_0-162-g3ab3c16,2018-04-23T18:29Z 706,CWE-476,"CWE-476 bool ExprResolveLhs ( struct xkb_context * ctx , const ExprDef * expr , const char * * elem_rtrn , const char * * field_rtrn , ExprDef * * index_rtrn ) { switch ( expr -> expr . op ) { case EXPR_IDENT : * elem_rtrn = NULL ; * field_rtrn = xkb_atom_text ( ctx , expr -> ident . ident ) ; * index_rtrn = NULL ; return ( * field_rtrn != NULL ) ; case EXPR_FIELD_REF : * elem_rtrn = xkb_atom_text ( ctx , expr -> field_ref . element ) ; * field_rtrn = xkb_atom_text ( ctx , expr -> field_ref . field ) ; * index_rtrn = NULL ; return true ; case EXPR_ARRAY_REF : * elem_rtrn = xkb_atom_text ( ctx , expr -> array_ref . element ) ; * field_rtrn = xkb_atom_text ( ctx , expr -> array_ref . field ) ; * index_rtrn = expr -> array_ref . entry ; return true ; default : break ; } log_wsgo ( ctx , ""Unexpectedoperator%dinResolveLhs\\n"" , expr -> expr . op ) ; return false ; } "," NULL ; return ( * elem_rtrn != NULL && * field_rtrn != NULL ) ; case EXPR_ARRAY_REF . entry ; if ( expr -> array_ref . element != XKB_ATOM_NONE && * elem_rtrn == NULL ) return false ; if ( * field_rtrn == NULL ) return false ; ",xkbcommon@libxkbcommon/bb4909d2d8fa6b08155e449986a478101e2b2634,CVE-2018-15859,https://github.com/xkbcommon/libxkbcommon/commit/bb4909d2d8fa6b08155e449986a478101e2b2634,2018-08-25T21:29Z 707,CWE-000,"CWE-000 static void sas_scsi_clear_queue_lu ( struct list_head * error_q , struct scsi_cmnd * my_cmd ) { struct scsi_cmnd * cmd , * n ; list_for_each_entry_safe ( cmd , n , error_q , eh_entry ) { if ( cmd -> device -> sdev_target == my_cmd -> device -> sdev_target && cmd -> device -> lun == my_cmd -> device -> lun ) sas_eh_defer_cmd ( cmd ) ; } } "," -> lun ) sas_eh_finish_cmd ( cmd ) ",torvalds@linux/318aaf34f1179b39fa9c30fa0f3288b645beee39,CVE-2018-10021,https://github.com/torvalds/linux/commit/318aaf34f1179b39fa9c30fa0f3288b645beee39,2018-04-11T17:29Z 708,CWE-125,"CWE-125 static stmt_ty ast_for_funcdef_impl ( struct compiling * c , const node * n0 , asdl_seq * decorator_seq , bool is_async ) { const node * const n = is_async ? CHILD ( n0 , 1 ) : n0 ; identifier name ; arguments_ty args ; asdl_seq * body ; expr_ty returns = NULL ; int name_i = 1 ; int end_lineno , end_col_offset ; REQ ( n , funcdef ) ; name = NEW_IDENTIFIER ( CHILD ( n , name_i ) ) ; if ( ! name ) return NULL ; if ( forbidden_name ( c , name , CHILD ( n , name_i ) , 0 ) ) return NULL ; args = ast_for_arguments ( c , CHILD ( n , name_i + 1 ) ) ; if ( ! args ) return NULL ; if ( TYPE ( CHILD ( n , name_i + 2 ) ) == RARROW ) { returns = ast_for_expr ( c , CHILD ( n , name_i + 3 ) ) ; if ( ! returns ) return NULL ; name_i += 2 ; } body = ast_for_suite ( c , CHILD ( n , name_i + 3 ) ) ; if ( ! body ) return NULL ; get_last_end_pos ( body , & end_lineno , & end_col_offset ) ; if ( is_async ) return AsyncFunctionDef ( name , args , body , decorator_seq , returns , LINENO ( n0 ) , n0 -> n_col_offset , end_lineno , end_col_offset , c -> c_arena ) ; else return FunctionDef ( name , args , body , decorator_seq , returns , LINENO ( n ) , n -> n_col_offset , end_lineno , end_col_offset , c -> c_arena ) ; } "," , end_col_offset ; node * tc ; string type_comment = NULL ; 2 ; } if ( TYPE ( CHILD ( n , name_i + 3 ) ) == TYPE_COMMENT ) { type_comment = NEW_TYPE_COMMENT ( CHILD ( n , name_i + 3 ) ) ; if ( ! type_comment ) return NULL ; name_i += 1 ; } ; if ( NCH ( CHILD ( n , name_i + 3 ) ) > 1 ) { tc = CHILD ( CHILD ( n , name_i + 3 ) , 1 ) ; if ( TYPE ( tc ) == TYPE_COMMENT ) { if ( type_comment != NULL ) { ast_error ( c , n , ""Cannothavetwotypecommentsondef"" ) ; return NULL ; } type_comment = NEW_TYPE_COMMENT ( tc ) ; if ( ! type_comment ) return NULL ; } } if ( decorator_seq , returns , type_comment , returns , type_comment , ",python@typed_ast/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,CVE-2019-19275,https://github.com/python/typed_ast/commit/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,2019-11-26T15:15Z 709,CWE-416,"CWE-416 int sctp_do_peeloff ( struct sock * sk , sctp_assoc_t id , struct socket * * sockp ) { struct sctp_association * asoc = sctp_id2assoc ( sk , id ) ; struct sctp_sock * sp = sctp_sk ( sk ) ; struct socket * sock ; int err = 0 ; if ( ! asoc ) return - EINVAL ; if ( waitqueue_active ( & asoc -> wait ) ) return - EBUSY ; if ( ! sctp_style ( sk , UDP ) ) return - EINVAL ; err = sock_create ( sk -> sk_family , SOCK_SEQPACKET , IPPROTO_SCTP , & sock ) ; if ( err < 0 ) return err ; sctp_copy_sock ( sock -> sk , sk , asoc ) ; sp -> pf -> to_sk_daddr ( & asoc -> peer . primary_addr , sk ) ; sctp_sock_migrate ( sk , sock -> sk , asoc , SCTP_SOCKET_UDP_HIGH_BANDWIDTH ) ; * sockp = sock ; return err ; } "," err = 0 ; if ( ! net_eq ( current -> nsproxy -> net_ns , sock_net ( sk ) ) ) return - EINVAL ",torvalds@linux/df80cd9b28b9ebaa284a41df611dbf3a2d05ca74,CVE-2017-15115,https://github.com/torvalds/linux/commit/df80cd9b28b9ebaa284a41df611dbf3a2d05ca74,2017-11-15T21:29Z 710,CWE-20,"CWE-20 static int encrypt ( struct blkcipher_desc * desc , struct scatterlist * dst , struct scatterlist * src , unsigned int nbytes ) { struct blkcipher_walk walk ; struct crypto_blkcipher * tfm = desc -> tfm ; struct salsa20_ctx * ctx = crypto_blkcipher_ctx ( tfm ) ; int err ; blkcipher_walk_init ( & walk , dst , src , nbytes ) ; err = blkcipher_walk_virt_block ( desc , & walk , 64 ) ; salsa20_ivsetup ( ctx , walk . iv ) ; if ( likely ( walk . nbytes == nbytes ) ) { salsa20_encrypt_bytes ( ctx , walk . dst . virt . addr , walk . src . virt . addr , nbytes ) ; return blkcipher_walk_done ( desc , & walk , 0 ) ; } while ( walk . nbytes >= 64 ) { salsa20_encrypt_bytes ( ctx , walk . dst . virt . addr , walk . src . virt . addr , walk . nbytes - ( walk . nbytes % 64 ) ) ; err = blkcipher_walk_done ( desc , & walk , walk . nbytes % 64 ) ; } if ( walk . nbytes ) { salsa20_encrypt_bytes ( ctx , walk . dst . virt . addr , walk . src . virt . addr , walk . nbytes ) ; err = blkcipher_walk_done ( desc , & walk , 0 ) ; } return err ; } "," iv ) ; while ( walk ",torvalds@linux/ecaaab5649781c5a0effdaf298a925063020500e,CVE-2017-17805,https://github.com/torvalds/linux/commit/ecaaab5649781c5a0effdaf298a925063020500e,2017-12-20T23:29Z 711,CWE-200,"CWE-200 static int vsock_stream_recvmsg ( struct kiocb * kiocb , struct socket * sock , struct msghdr * msg , size_t len , int flags ) { struct sock * sk ; struct vsock_sock * vsk ; int err ; size_t target ; ssize_t copied ; long timeout ; struct vsock_transport_recv_notify_data recv_data ; DEFINE_WAIT ( wait ) ; sk = sock -> sk ; vsk = vsock_sk ( sk ) ; err = 0 ; lock_sock ( sk ) ; if ( sk -> sk_state != SS_CONNECTED ) { if ( sock_flag ( sk , SOCK_DONE ) ) err = 0 ; else err = - ENOTCONN ; goto out ; } if ( flags & MSG_OOB ) { err = - EOPNOTSUPP ; goto out ; } if ( sk -> sk_shutdown & RCV_SHUTDOWN ) { err = 0 ; goto out ; } if ( ! len ) { err = 0 ; goto out ; } target = sock_rcvlowat ( sk , flags & MSG_WAITALL , len ) ; if ( target >= transport -> stream_rcvhiwat ( vsk ) ) { err = - ENOMEM ; goto out ; } timeout = sock_rcvtimeo ( sk , flags & MSG_DONTWAIT ) ; copied = 0 ; err = transport -> notify_recv_init ( vsk , target , & recv_data ) ; if ( err < 0 ) goto out ; prepare_to_wait ( sk_sleep ( sk ) , & wait , TASK_INTERRUPTIBLE ) ; while ( 1 ) { s64 ready = vsock_stream_has_data ( vsk ) ; if ( ready < 0 ) { err = - ENOMEM ; goto out_wait ; } else if ( ready > 0 ) { ssize_t read ; err = transport -> notify_recv_pre_dequeue ( vsk , target , & recv_data ) ; if ( err < 0 ) break ; read = transport -> stream_dequeue ( vsk , msg -> msg_iov , len - copied , flags ) ; if ( read < 0 ) { err = - ENOMEM ; break ; } copied += read ; err = transport -> notify_recv_post_dequeue ( vsk , target , read , ! ( flags & MSG_PEEK ) , & recv_data ) ; if ( err < 0 ) goto out_wait ; if ( read >= target || flags & MSG_PEEK ) break ; target -= read ; } else { if ( sk -> sk_err != 0 || ( sk -> sk_shutdown & RCV_SHUTDOWN ) || ( vsk -> peer_shutdown & SEND_SHUTDOWN ) ) { break ; } if ( timeout == 0 ) { err = - EAGAIN ; break ; } err = transport -> notify_recv_pre_block ( vsk , target , & recv_data ) ; if ( err < 0 ) break ; release_sock ( sk ) ; timeout = schedule_timeout ( timeout ) ; lock_sock ( sk ) ; if ( signal_pending ( current ) ) { err = sock_intr_errno ( timeout ) ; break ; } else if ( timeout == 0 ) { err = - EAGAIN ; break ; } prepare_to_wait ( sk_sleep ( sk ) , & wait , TASK_INTERRUPTIBLE ) ; } } if ( sk -> sk_err ) err = - sk -> sk_err ; else if ( sk -> sk_shutdown & RCV_SHUTDOWN ) err = 0 ; if ( copied > 0 ) { if ( ! ( flags & MSG_PEEK ) ) { if ( vsk -> peer_shutdown & SEND_SHUTDOWN ) { if ( vsock_stream_has_data ( vsk ) <= 0 ) { sk -> sk_state = SS_UNCONNECTED ; sock_set_flag ( sk , SOCK_DONE ) ; sk -> sk_state_change ( sk ) ; } } } err = copied ; } out_wait : finish_wait ( sk_sleep ( sk ) , & wait ) ; out : release_sock ( sk ) ; return err ; } "," = 0 ; msg -> msg_namelen = 0 ; ",torvalds@linux/d5e0d0f607a7a029c6563a0470d88255c89a8d11,CVE-2013-3237,https://github.com/torvalds/linux/commit/d5e0d0f607a7a029c6563a0470d88255c89a8d11,2013-04-22T11:41Z 712,CWE-119,"CWE-119 int my_csr_reader ( const char * i_csr_file_in , unsigned int * * o_row_idx , unsigned int * * o_column_idx , REALTYPE * * o_values , unsigned int * o_row_count , unsigned int * o_column_count , unsigned int * o_element_count ) { FILE * l_csr_file_handle ; const unsigned int l_line_length = 512 ; char l_line [ 512 + 1 ] ; unsigned int l_header_read = 0 ; unsigned int * l_row_idx_id = NULL ; unsigned int l_i = 0 ; l_csr_file_handle = fopen ( i_csr_file_in , ""r"" ) ; if ( l_csr_file_handle == NULL ) { fprintf ( stderr , ""cannotopenCSRfile!\\n"" ) ; return - 1 ; } while ( fgets ( l_line , l_line_length , l_csr_file_handle ) != NULL ) { if ( strlen ( l_line ) == l_line_length ) { fprintf ( stderr , ""couldnotreadfilelength!\\n"" ) ; return - 1 ; } if ( l_line [ 0 ] == '%' ) { continue ; } else { if ( l_header_read == 0 ) { if ( sscanf ( l_line , ""%u%u%u"" , o_row_count , o_column_count , o_element_count ) == 3 ) { * o_column_idx = ( unsigned int * ) malloc ( sizeof ( unsigned int ) * ( * o_element_count ) ) ; * o_row_idx = ( unsigned int * ) malloc ( sizeof ( unsigned int ) * ( * o_row_count + 1 ) ) ; * o_values = ( REALTYPE * ) malloc ( sizeof ( double ) * ( * o_element_count ) ) ; l_row_idx_id = ( unsigned int * ) malloc ( sizeof ( unsigned int ) * ( * o_row_count ) ) ; if ( ( * o_row_idx == NULL ) || ( * o_column_idx == NULL ) || ( * o_values == NULL ) || ( l_row_idx_id == NULL ) ) { fprintf ( stderr , ""couldnotallocatespdata!\\n"" ) ; return - 1 ; } memset ( * o_row_idx , 0 , sizeof ( unsigned int ) * ( * o_row_count + 1 ) ) ; memset ( * o_column_idx , 0 , sizeof ( unsigned int ) * ( * o_element_count ) ) ; memset ( * o_values , 0 , sizeof ( double ) * ( * o_element_count ) ) ; memset ( l_row_idx_id , 0 , sizeof ( unsigned int ) * ( * o_row_count ) ) ; for ( l_i = 0 ; l_i < ( * o_row_count + 1 ) ; l_i ++ ) ( * o_row_idx ) [ l_i ] = ( * o_element_count ) ; ( * o_row_idx ) [ 0 ] = 0 ; l_i = 0 ; l_header_read = 1 ; } else { fprintf ( stderr , ""couldnotcsrdescription!\\n"" ) ; return - 1 ; } } else { unsigned int l_row , l_column ; REALTYPE l_value ; if ( sscanf ( l_line , ""%u%u%lf"" , & l_row , & l_column , & l_value ) != 3 ) { fprintf ( stderr , ""couldnotreadelement!\\n"" ) ; return - 1 ; } l_row -- ; l_column -- ; ( * o_column_idx ) [ l_i ] = l_column ; ( * o_values ) [ l_i ] = l_value ; l_i ++ ; l_row_idx_id [ l_row ] = 1 ; ( * o_row_idx ) [ l_row + 1 ] = l_i ; } } } fclose ( l_csr_file_handle ) ; if ( l_i != ( * o_element_count ) ) { fprintf ( stderr , ""wewerenotabletoreadallelements!\\n"" ) ; return - 1 ; } for ( l_i = 0 ; l_i < ( * o_row_count ) ; l_i ++ ) { if ( l_row_idx_id [ l_i ] == 0 ) { ( * o_row_idx ) [ l_i + 1 ] = ( * o_row_idx ) [ l_i ] ; } } if ( l_row_idx_id != NULL ) { free ( l_row_idx_id ) ; } return 0 ; } "," { if ( 3 == , o_element_count ) && 0 != * o_row_count && 0 != * o_column_count && 0 != * o_element_count ) { * o_column_idx ",hfp@libxsmm/151481489192e6d1997f8bde52c5c425ea41741d,CVE-2018-20542,https://github.com/hfp/libxsmm/commit/151481489192e6d1997f8bde52c5c425ea41741d,2018-12-28T16:29Z 713,CWE-787,"CWE-787 static Image * ReadWPGImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { typedef struct { size_t FileId ; MagickOffsetType DataOffset ; unsigned int ProductType ; unsigned int FileType ; unsigned char MajorVersion ; unsigned char MinorVersion ; unsigned int EncryptKey ; unsigned int Reserved ; } WPGHeader ; typedef struct { unsigned char RecType ; size_t RecordLength ; } WPGRecord ; typedef struct { unsigned char Class ; unsigned char RecType ; size_t Extension ; size_t RecordLength ; } WPG2Record ; typedef struct { unsigned HorizontalUnits ; unsigned VerticalUnits ; unsigned char PosSizePrecision ; } WPG2Start ; typedef struct { unsigned int Width ; unsigned int Height ; unsigned int Depth ; unsigned int HorzRes ; unsigned int VertRes ; } WPGBitmapType1 ; typedef struct { unsigned int Width ; unsigned int Height ; unsigned char Depth ; unsigned char Compression ; } WPG2BitmapType1 ; typedef struct { unsigned int RotAngle ; unsigned int LowLeftX ; unsigned int LowLeftY ; unsigned int UpRightX ; unsigned int UpRightY ; unsigned int Width ; unsigned int Height ; unsigned int Depth ; unsigned int HorzRes ; unsigned int VertRes ; } WPGBitmapType2 ; typedef struct { unsigned int StartIndex ; unsigned int NumOfEntries ; } WPGColorMapRec ; Image * image ; unsigned int status ; WPGHeader Header ; WPGRecord Rec ; WPG2Record Rec2 ; WPG2Start StartWPG ; WPGBitmapType1 BitmapHeader1 ; WPG2BitmapType1 Bitmap2Header1 ; WPGBitmapType2 BitmapHeader2 ; WPGColorMapRec WPG_Palette ; int i , bpp , WPG2Flags ; ssize_t ldblk ; size_t one ; unsigned char * BImgBuff ; tCTM CTM ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; one = 1 ; image = AcquireImage ( image_info , exception ) ; image -> depth = 8 ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } Header . FileId = ReadBlobLSBLong ( image ) ; Header . DataOffset = ( MagickOffsetType ) ReadBlobLSBLong ( image ) ; Header . ProductType = ReadBlobLSBShort ( image ) ; Header . FileType = ReadBlobLSBShort ( image ) ; Header . MajorVersion = ReadBlobByte ( image ) ; Header . MinorVersion = ReadBlobByte ( image ) ; Header . EncryptKey = ReadBlobLSBShort ( image ) ; Header . Reserved = ReadBlobLSBShort ( image ) ; if ( Header . FileId != 0x435057FF || ( Header . ProductType >> 8 ) != 0x16 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( Header . EncryptKey != 0 ) ThrowReaderException ( CoderError , ""EncryptedWPGImageFileNotSupported"" ) ; image -> columns = 1 ; image -> rows = 1 ; image -> colors = 0 ; bpp = 0 ; BitmapHeader2 . RotAngle = 0 ; switch ( Header . FileType ) { case 1 : while ( ! EOFBlob ( image ) ) { ( void ) SeekBlob ( image , Header . DataOffset , SEEK_SET ) ; if ( EOFBlob ( image ) ) break ; Rec . RecType = ( i = ReadBlobByte ( image ) ) ; if ( i == EOF ) break ; Rd_WP_DWORD ( image , & Rec . RecordLength ) ; if ( EOFBlob ( image ) ) break ; Header . DataOffset = TellBlob ( image ) + Rec . RecordLength ; switch ( Rec . RecType ) { case 0x0B : BitmapHeader1 . Width = ReadBlobLSBShort ( image ) ; BitmapHeader1 . Height = ReadBlobLSBShort ( image ) ; if ( ( BitmapHeader1 . Width == 0 ) || ( BitmapHeader1 . Height == 0 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; BitmapHeader1 . Depth = ReadBlobLSBShort ( image ) ; BitmapHeader1 . HorzRes = ReadBlobLSBShort ( image ) ; BitmapHeader1 . VertRes = ReadBlobLSBShort ( image ) ; if ( BitmapHeader1 . HorzRes && BitmapHeader1 . VertRes ) { image -> units = PixelsPerCentimeterResolution ; image -> resolution . x = BitmapHeader1 . HorzRes / 470.0 ; image -> resolution . y = BitmapHeader1 . VertRes / 470.0 ; } image -> columns = BitmapHeader1 . Width ; image -> rows = BitmapHeader1 . Height ; bpp = BitmapHeader1 . Depth ; goto UnpackRaster ; case 0x0E : WPG_Palette . StartIndex = ReadBlobLSBShort ( image ) ; WPG_Palette . NumOfEntries = ReadBlobLSBShort ( image ) ; image -> colors = WPG_Palette . NumOfEntries ; if ( ! AcquireImageColormap ( image , image -> colors , exception ) ) goto NoMemory ; for ( i = WPG_Palette . StartIndex ; i < ( int ) WPG_Palette . NumOfEntries ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; } break ; case 0x11 : if ( Rec . RecordLength > 8 ) image = ExtractPostscript ( image , image_info , TellBlob ( image ) + 8 , ( ssize_t ) Rec . RecordLength - 8 , exception ) ; break ; case 0x14 : BitmapHeader2 . RotAngle = ReadBlobLSBShort ( image ) ; BitmapHeader2 . LowLeftX = ReadBlobLSBShort ( image ) ; BitmapHeader2 . LowLeftY = ReadBlobLSBShort ( image ) ; BitmapHeader2 . UpRightX = ReadBlobLSBShort ( image ) ; BitmapHeader2 . UpRightY = ReadBlobLSBShort ( image ) ; BitmapHeader2 . Width = ReadBlobLSBShort ( image ) ; BitmapHeader2 . Height = ReadBlobLSBShort ( image ) ; if ( ( BitmapHeader2 . Width == 0 ) || ( BitmapHeader2 . Height == 0 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; BitmapHeader2 . Depth = ReadBlobLSBShort ( image ) ; BitmapHeader2 . HorzRes = ReadBlobLSBShort ( image ) ; BitmapHeader2 . VertRes = ReadBlobLSBShort ( image ) ; image -> units = PixelsPerCentimeterResolution ; image -> page . width = ( unsigned int ) ( ( BitmapHeader2 . LowLeftX - BitmapHeader2 . UpRightX ) / 470.0 ) ; image -> page . height = ( unsigned int ) ( ( BitmapHeader2 . LowLeftX - BitmapHeader2 . UpRightY ) / 470.0 ) ; image -> page . x = ( int ) ( BitmapHeader2 . LowLeftX / 470.0 ) ; image -> page . y = ( int ) ( BitmapHeader2 . LowLeftX / 470.0 ) ; if ( BitmapHeader2 . HorzRes && BitmapHeader2 . VertRes ) { image -> resolution . x = BitmapHeader2 . HorzRes / 470.0 ; image -> resolution . y = BitmapHeader2 . VertRes / 470.0 ; } image -> columns = BitmapHeader2 . Width ; image -> rows = BitmapHeader2 . Height ; bpp = BitmapHeader2 . Depth ; UnpackRaster : if ( ( image -> colors == 0 ) && ( bpp != 24 ) ) { image -> colors = one << bpp ; if ( ! AcquireImageColormap ( image , image -> colors , exception ) ) { NoMemory : ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; } for ( i = 0 ; ( i < ( int ) image -> colors ) && ( i < 256 ) ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( WPG1_Palette [ i ] . Red ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( WPG1_Palette [ i ] . Green ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( WPG1_Palette [ i ] . Blue ) ; } } else { if ( bpp < 24 ) if ( ( image -> colors < ( one << bpp ) ) && ( bpp != 24 ) ) image -> colormap = ( PixelInfo * ) ResizeQuantumMemory ( image -> colormap , ( size_t ) ( one << bpp ) , sizeof ( * image -> colormap ) ) ; } if ( bpp == 1 ) { if ( image -> colormap [ 0 ] . red == 0 && image -> colormap [ 0 ] . green == 0 && image -> colormap [ 0 ] . blue == 0 && image -> colormap [ 1 ] . red == 0 && image -> colormap [ 1 ] . green == 0 && image -> colormap [ 1 ] . blue == 0 ) { image -> colormap [ 1 ] . red = image -> colormap [ 1 ] . green = image -> colormap [ 1 ] . blue = QuantumRange ; } } if ( UnpackWPGRaster ( image , bpp , exception ) < 0 ) { DecompressionFailed : ThrowReaderException ( CoderError , ""UnableToDecompressImage"" ) ; } if ( Rec . RecType == 0x14 && BitmapHeader2 . RotAngle != 0 && ! image_info -> ping ) { if ( BitmapHeader2 . RotAngle & 0x8000 ) { Image * flop_image ; flop_image = FlopImage ( image , exception ) ; if ( flop_image != ( Image * ) NULL ) { DuplicateBlob ( flop_image , image ) ; ( void ) RemoveLastImageFromList ( & image ) ; AppendImageToList ( & image , flop_image ) ; } } if ( BitmapHeader2 . RotAngle & 0x2000 ) { Image * flip_image ; flip_image = FlipImage ( image , exception ) ; if ( flip_image != ( Image * ) NULL ) { DuplicateBlob ( flip_image , image ) ; ( void ) RemoveLastImageFromList ( & image ) ; AppendImageToList ( & image , flip_image ) ; } } if ( BitmapHeader2 . RotAngle & 0x0FFF ) { Image * rotate_image ; rotate_image = RotateImage ( image , ( BitmapHeader2 . RotAngle & 0x0FFF ) , exception ) ; if ( rotate_image != ( Image * ) NULL ) { DuplicateBlob ( rotate_image , image ) ; ( void ) RemoveLastImageFromList ( & image ) ; AppendImageToList ( & image , rotate_image ) ; } } } AcquireNextImage ( image_info , image , exception ) ; image -> depth = 8 ; if ( image -> next == ( Image * ) NULL ) goto Finish ; image = SyncNextImageInList ( image ) ; image -> columns = image -> rows = 0 ; image -> colors = 0 ; break ; case 0x1B : if ( Rec . RecordLength > 0x3C ) image = ExtractPostscript ( image , image_info , TellBlob ( image ) + 0x3C , ( ssize_t ) Rec . RecordLength - 0x3C , exception ) ; break ; } } break ; case 2 : ( void ) memset ( CTM , 0 , sizeof ( CTM ) ) ; StartWPG . PosSizePrecision = 0 ; while ( ! EOFBlob ( image ) ) { ( void ) SeekBlob ( image , Header . DataOffset , SEEK_SET ) ; if ( EOFBlob ( image ) ) break ; Rec2 . Class = ( i = ReadBlobByte ( image ) ) ; if ( i == EOF ) break ; Rec2 . RecType = ( i = ReadBlobByte ( image ) ) ; if ( i == EOF ) break ; Rd_WP_DWORD ( image , & Rec2 . Extension ) ; Rd_WP_DWORD ( image , & Rec2 . RecordLength ) ; if ( EOFBlob ( image ) ) break ; Header . DataOffset = TellBlob ( image ) + Rec2 . RecordLength ; switch ( Rec2 . RecType ) { case 1 : StartWPG . HorizontalUnits = ReadBlobLSBShort ( image ) ; StartWPG . VerticalUnits = ReadBlobLSBShort ( image ) ; StartWPG . PosSizePrecision = ReadBlobByte ( image ) ; break ; case 0x0C : WPG_Palette . StartIndex = ReadBlobLSBShort ( image ) ; WPG_Palette . NumOfEntries = ReadBlobLSBShort ( image ) ; image -> colors = WPG_Palette . NumOfEntries ; if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; for ( i = WPG_Palette . StartIndex ; i < ( int ) WPG_Palette . NumOfEntries ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( ( char ) ReadBlobByte ( image ) ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( ( char ) ReadBlobByte ( image ) ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( ( char ) ReadBlobByte ( image ) ) ; ( void ) ReadBlobByte ( image ) ; } break ; case 0x0E : Bitmap2Header1 . Width = ReadBlobLSBShort ( image ) ; Bitmap2Header1 . Height = ReadBlobLSBShort ( image ) ; if ( ( Bitmap2Header1 . Width == 0 ) || ( Bitmap2Header1 . Height == 0 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; Bitmap2Header1 . Depth = ReadBlobByte ( image ) ; Bitmap2Header1 . Compression = ReadBlobByte ( image ) ; if ( Bitmap2Header1 . Compression > 1 ) continue ; switch ( Bitmap2Header1 . Depth ) { case 1 : bpp = 1 ; break ; case 2 : bpp = 2 ; break ; case 3 : bpp = 4 ; break ; case 4 : bpp = 8 ; break ; case 8 : bpp = 24 ; break ; default : continue ; } image -> columns = Bitmap2Header1 . Width ; image -> rows = Bitmap2Header1 . Height ; if ( ( image -> colors == 0 ) && ( bpp != 24 ) ) { size_t one ; one = 1 ; image -> colors = one << bpp ; if ( ! AcquireImageColormap ( image , image -> colors , exception ) ) goto NoMemory ; } else { if ( bpp < 24 ) if ( image -> colors < ( one << bpp ) && bpp != 24 ) image -> colormap = ( PixelInfo * ) ResizeQuantumMemory ( image -> colormap , ( size_t ) ( one << bpp ) , sizeof ( * image -> colormap ) ) ; } switch ( Bitmap2Header1 . Compression ) { case 0 : { ldblk = ( ssize_t ) ( ( bpp * image -> columns + 7 ) / 8 ) ; BImgBuff = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) ldblk + 1 , sizeof ( * BImgBuff ) ) ; if ( BImgBuff == ( unsigned char * ) NULL ) goto NoMemory ; for ( i = 0 ; i < ( ssize_t ) image -> rows ; i ++ ) { ( void ) ReadBlob ( image , ldblk , BImgBuff ) ; InsertRow ( image , BImgBuff , i , bpp , exception ) ; } if ( BImgBuff ) BImgBuff = ( unsigned char * ) RelinquishMagickMemory ( BImgBuff ) ; ; break ; } case 1 : { if ( UnpackWPG2Raster ( image , bpp , exception ) < 0 ) goto DecompressionFailed ; break ; } } if ( CTM [ 0 ] [ 0 ] < 0 && ! image_info -> ping ) { Image * flop_image ; flop_image = FlopImage ( image , exception ) ; if ( flop_image != ( Image * ) NULL ) { DuplicateBlob ( flop_image , image ) ; ( void ) RemoveLastImageFromList ( & image ) ; AppendImageToList ( & image , flop_image ) ; } } if ( CTM [ 1 ] [ 1 ] < 0 && ! image_info -> ping ) { Image * flip_image ; flip_image = FlipImage ( image , exception ) ; if ( flip_image != ( Image * ) NULL ) { DuplicateBlob ( flip_image , image ) ; ( void ) RemoveLastImageFromList ( & image ) ; AppendImageToList ( & image , flip_image ) ; } } AcquireNextImage ( image_info , image , exception ) ; image -> depth = 8 ; if ( image -> next == ( Image * ) NULL ) goto Finish ; image = SyncNextImageInList ( image ) ; image -> columns = image -> rows = 1 ; image -> colors = 0 ; break ; case 0x12 : i = ReadBlobLSBShort ( image ) ; if ( Rec2 . RecordLength > ( unsigned int ) i ) image = ExtractPostscript ( image , image_info , TellBlob ( image ) + i , ( ssize_t ) ( Rec2 . RecordLength - i - 2 ) , exception ) ; break ; case 0x1B : WPG2Flags = LoadWPG2Flags ( image , StartWPG . PosSizePrecision , NULL , & CTM ) ; ( void ) WPG2Flags ; break ; } } break ; default : { ThrowReaderException ( CoderError , ""DataEncodingSchemeIsNotSupported"" ) ; } } status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; Finish : ( void ) CloseBlob ( image ) ; { Image * p ; ssize_t scene = 0 ; p = image ; image = NULL ; while ( p != ( Image * ) NULL ) { Image * tmp = p ; if ( ( p -> rows == 0 ) || ( p -> columns == 0 ) ) { p = p -> previous ; DeleteImageFromList ( & tmp ) ; } else { image = p ; p = p -> previous ; } } for ( p = image ; p != ( Image * ) NULL ; p = p -> next ) p -> scene = ( size_t ) scene ++ ; } if ( image == ( Image * ) NULL ) ThrowReaderException ( CorruptImageError , ""ImageFileDoesNotContainAnyImageData"" ) ; return ( image ) ; } "," -> rows = 1 ; image -> ( BImgBuff ) ; break ; ",ImageMagick@ImageMagick/998c687fb83993c13fa711d75f59a95b38ceab77,CVE-2016-7526,https://github.com/ImageMagick/ImageMagick/commit/998c687fb83993c13fa711d75f59a95b38ceab77,2017-04-20T18:59Z 714,CWE-264,"CWE-264 static int em_loop ( struct x86_emulate_ctxt * ctxt ) { register_address_increment ( ctxt , reg_rmw ( ctxt , VCPU_REGS_RCX ) , - 1 ) ; if ( ( address_mask ( ctxt , reg_read ( ctxt , VCPU_REGS_RCX ) ) != 0 ) && ( ctxt -> b == 0xe2 || test_cc ( ctxt -> b ^ 0x5 , ctxt -> eflags ) ) ) jmp_rel ( ctxt , ctxt -> src . val ) ; return X86EMUL_CONTINUE ; } "," ctxt ) { int rc = X86EMUL_CONTINUE ; ) ) ) rc = ) ; return rc ; } ",torvalds@linux/234f3ce485d54017f15cf5e0699cff4100121601,CVE-2014-3647,https://github.com/torvalds/linux/commit/234f3ce485d54017f15cf5e0699cff4100121601,2014-11-10T11:55Z 715,CWE-119,"CWE-119 void cJSON_AddItemReferenceToArray ( cJSON * array , cJSON * item ) { cJSON_AddItemToArray ( array , create_reference ( item ) ) ; } "," ",esnet@iperf/91f2fa59e8ed80dfbf400add0164ee0e508e412a,CVE-2016-4303,https://github.com/esnet/iperf/commit/91f2fa59e8ed80dfbf400add0164ee0e508e412a,2016-09-26T14:59Z 716,CWE-476,"CWE-476 static int hi3660_stub_clk_probe ( struct platform_device * pdev ) { struct device * dev = & pdev -> dev ; struct resource * res ; unsigned int i ; int ret ; stub_clk_chan . cl . dev = dev ; stub_clk_chan . cl . tx_done = NULL ; stub_clk_chan . cl . tx_block = false ; stub_clk_chan . cl . knows_txdone = false ; stub_clk_chan . mbox = mbox_request_channel ( & stub_clk_chan . cl , 0 ) ; if ( IS_ERR ( stub_clk_chan . mbox ) ) return PTR_ERR ( stub_clk_chan . mbox ) ; res = platform_get_resource ( pdev , IORESOURCE_MEM , 0 ) ; freq_reg = devm_ioremap ( dev , res -> start , resource_size ( res ) ) ; if ( ! freq_reg ) return - ENOMEM ; freq_reg += HI3660_STUB_CLOCK_DATA ; for ( i = 0 ; i < HI3660_CLK_STUB_NUM ; i ++ ) { ret = devm_clk_hw_register ( & pdev -> dev , & hi3660_stub_clks [ i ] . hw ) ; if ( ret ) return ret ; } return devm_of_clk_add_hw_provider ( & pdev -> dev , hi3660_stub_clk_hw_get , hi3660_stub_clks ) ; } "," 0 ) ; if ( ! res ) return - EINVAL ; ",torvalds@linux/9903e41ae1f5d50c93f268ca3304d4d7c64b9311,CVE-2018-10074,https://github.com/torvalds/linux/commit/9903e41ae1f5d50c93f268ca3304d4d7c64b9311,2018-04-12T18:29Z 717,CWE-119,"CWE-119 static void header_seek ( SF_PRIVATE * psf , sf_count_t position , int whence ) { switch ( whence ) { case SEEK_SET : if ( position > SIGNED_SIZEOF ( psf -> header ) ) { psf_fseek ( psf , position , whence ) ; return ; } ; if ( position > psf -> headend ) psf -> headend += psf_fread ( psf -> header + psf -> headend , 1 , position - psf -> headend , psf ) ; psf -> headindex = position ; break ; case SEEK_CUR : if ( psf -> headindex + position < 0 ) break ; if ( psf -> headindex >= SIGNED_SIZEOF ( psf -> header ) ) { psf_fseek ( psf , position , whence ) ; return ; } ; if ( psf -> headindex + position <= psf -> headend ) { psf -> headindex += position ; break ; } ; if ( psf -> headindex + position > SIGNED_SIZEOF ( psf -> header ) ) { psf -> headindex = psf -> headend ; psf_fseek ( psf , position , SEEK_CUR ) ; break ; } ; psf -> headend += psf_fread ( psf -> header + psf -> headend , 1 , position - ( psf -> headend - psf -> headindex ) , psf ) ; psf -> headindex = psf -> headend ; break ; case SEEK_END : default : psf_log_printf ( psf , ""Badwhenceparaminheader_seek().\\n"" ) ; break ; } ; return ; } "," : if ( psf -> header . indx + position >= psf -> header . len ) psf_bump_header_allocation ( psf , position ) ; if ( position > psf -> header . len ) { psf_fseek > psf -> header . end ) psf -> header . end += psf_fread ( psf -> header . ptr + psf -> header . end , 1 , - psf -> header . end , psf ) ; psf -> header . indx = position ; ( psf -> header . indx + position >= psf -> header . len ) psf_bump_header_allocation ( psf , position ) ; if ( psf -> header . indx + position < ( psf -> header . indx >= psf -> header . len ) { psf_fseek ( psf -> header . indx + position <= <= psf -> header . end ) { psf -> header . indx += position ; ( psf -> header . indx + position > + position > psf -> header . len ) { psf -> header . indx = psf -> = psf -> header . end ; psf_fseek ( ; psf -> header . end += psf_fread ( psf -> header . ptr + psf -> header . end , 1 , ( psf -> header . end - psf -> - psf -> header . indx ) , psf ) ; psf -> header . indx = psf -> = psf -> header . end ; break ; ",erikd@libsndfile/708e996c87c5fae77b104ccfeb8f6db784c32074,CVE-2017-7586,https://github.com/erikd/libsndfile/commit/708e996c87c5fae77b104ccfeb8f6db784c32074,2017-04-07T20:59Z 718,CWE-362,"CWE-362 int ext4_collapse_range ( struct inode * inode , loff_t offset , loff_t len ) { struct super_block * sb = inode -> i_sb ; ext4_lblk_t punch_start , punch_stop ; handle_t * handle ; unsigned int credits ; loff_t new_size , ioffset ; int ret ; if ( ! ext4_test_inode_flag ( inode , EXT4_INODE_EXTENTS ) ) return - EOPNOTSUPP ; if ( offset & ( EXT4_CLUSTER_SIZE ( sb ) - 1 ) || len & ( EXT4_CLUSTER_SIZE ( sb ) - 1 ) ) return - EINVAL ; if ( ! S_ISREG ( inode -> i_mode ) ) return - EINVAL ; trace_ext4_collapse_range ( inode , offset , len ) ; punch_start = offset >> EXT4_BLOCK_SIZE_BITS ( sb ) ; punch_stop = ( offset + len ) >> EXT4_BLOCK_SIZE_BITS ( sb ) ; if ( ext4_should_journal_data ( inode ) ) { ret = ext4_force_commit ( inode -> i_sb ) ; if ( ret ) return ret ; } ioffset = round_down ( offset , PAGE_SIZE ) ; ret = filemap_write_and_wait_range ( inode -> i_mapping , ioffset , LLONG_MAX ) ; if ( ret ) return ret ; mutex_lock ( & inode -> i_mutex ) ; if ( offset + len >= i_size_read ( inode ) ) { ret = - EINVAL ; goto out_mutex ; } if ( ! ext4_test_inode_flag ( inode , EXT4_INODE_EXTENTS ) ) { ret = - EOPNOTSUPP ; goto out_mutex ; } truncate_pagecache ( inode , ioffset ) ; ext4_inode_block_unlocked_dio ( inode ) ; inode_dio_wait ( inode ) ; credits = ext4_writepage_trans_blocks ( inode ) ; handle = ext4_journal_start ( inode , EXT4_HT_TRUNCATE , credits ) ; if ( IS_ERR ( handle ) ) { ret = PTR_ERR ( handle ) ; goto out_dio ; } down_write ( & EXT4_I ( inode ) -> i_data_sem ) ; ext4_discard_preallocations ( inode ) ; ret = ext4_es_remove_extent ( inode , punch_start , EXT_MAX_BLOCKS - punch_start ) ; if ( ret ) { up_write ( & EXT4_I ( inode ) -> i_data_sem ) ; goto out_stop ; } ret = ext4_ext_remove_space ( inode , punch_start , punch_stop - 1 ) ; if ( ret ) { up_write ( & EXT4_I ( inode ) -> i_data_sem ) ; goto out_stop ; } ext4_discard_preallocations ( inode ) ; ret = ext4_ext_shift_extents ( inode , handle , punch_stop , punch_stop - punch_start , SHIFT_LEFT ) ; if ( ret ) { up_write ( & EXT4_I ( inode ) -> i_data_sem ) ; goto out_stop ; } new_size = i_size_read ( inode ) - len ; i_size_write ( inode , new_size ) ; EXT4_I ( inode ) -> i_disksize = new_size ; up_write ( & EXT4_I ( inode ) -> i_data_sem ) ; if ( IS_SYNC ( inode ) ) ext4_handle_sync ( handle ) ; inode -> i_mtime = inode -> i_ctime = ext4_current_time ( inode ) ; ext4_mark_inode_dirty ( handle , inode ) ; out_stop : ext4_journal_stop ( handle ) ; out_dio : ext4_inode_resume_unlocked_dio ( inode ) ; out_mutex : mutex_unlock ( & inode -> i_mutex ) ; return ret ; } "," out_mutex ; } ext4_inode_block_unlocked_dio ( inode ) ; inode_dio_wait ( inode ) ; down_write ( & EXT4_I ( inode ) -> i_mmap_sem ) ; ioffset ) ; credits = ext4_writepage_trans_blocks ) ; goto out_mmap ; } down_write handle ) ; out_mmap : up_write ( & EXT4_I ( inode ) -> i_mmap_sem ) ; ext4_inode_resume_unlocked_dio ( inode ",torvalds@linux/ea3d7209ca01da209cda6f0dea8be9cc4b7a933b,CVE-2015-8839,https://github.com/torvalds/linux/commit/ea3d7209ca01da209cda6f0dea8be9cc4b7a933b,2016-05-02T10:59Z 719,CWE-125,"CWE-125 struct _mdi * _WM_ParseNewMidi ( uint8_t * midi_data , uint32_t midi_size ) { struct _mdi * mdi ; uint32_t tmp_val ; uint32_t midi_type ; uint32_t track_size ; uint8_t * * tracks ; uint32_t end_of_tracks = 0 ; uint32_t no_tracks ; uint32_t i ; uint32_t divisions = 96 ; uint32_t tempo = 500000 ; float samples_per_delta_f = 0.0 ; uint32_t sample_count = 0 ; float sample_count_f = 0.0 ; float sample_remainder = 0.0 ; uint8_t * sysex_store = NULL ; uint32_t * track_delta ; uint8_t * track_end ; uint32_t smallest_delta = 0 ; uint32_t subtract_delta = 0 ; uint8_t * running_event ; uint32_t setup_ret = 0 ; if ( midi_size < 14 ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_CORUPT , ""(tooshort)"" , 0 ) ; return ( NULL ) ; } if ( ! memcmp ( midi_data , ""RIFF"" , 4 ) ) { if ( midi_size < 34 ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_CORUPT , ""(tooshort)"" , 0 ) ; return ( NULL ) ; } midi_data += 20 ; midi_size -= 20 ; } if ( memcmp ( midi_data , ""MThd"" , 4 ) ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_NOT_MIDI , NULL , 0 ) ; return ( NULL ) ; } midi_data += 4 ; midi_size -= 4 ; tmp_val = * midi_data ++ << 24 ; tmp_val |= * midi_data ++ << 16 ; tmp_val |= * midi_data ++ << 8 ; tmp_val |= * midi_data ++ ; midi_size -= 4 ; if ( tmp_val != 6 ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_CORUPT , NULL , 0 ) ; return ( NULL ) ; } tmp_val = * midi_data ++ << 8 ; tmp_val |= * midi_data ++ ; midi_size -= 2 ; if ( tmp_val > 2 ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_INVALID , NULL , 0 ) ; return ( NULL ) ; } midi_type = tmp_val ; tmp_val = * midi_data ++ << 8 ; tmp_val |= * midi_data ++ ; midi_size -= 2 ; if ( tmp_val < 1 ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_CORUPT , ""(notracks)"" , 0 ) ; return ( NULL ) ; } no_tracks = tmp_val ; if ( ( midi_type == 0 ) && ( no_tracks > 1 ) ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_INVALID , ""(expected1trackfortype0midifile,foundmore)"" , 0 ) ; return ( NULL ) ; } divisions = * midi_data ++ << 8 ; divisions |= * midi_data ++ ; midi_size -= 2 ; if ( divisions & 0x00008000 ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_INVALID , NULL , 0 ) ; return ( NULL ) ; } samples_per_delta_f = _WM_GetSamplesPerTick ( divisions , tempo ) ; mdi = _WM_initMDI ( ) ; _WM_midi_setup_divisions ( mdi , divisions ) ; tracks = malloc ( sizeof ( uint8_t * ) * no_tracks ) ; track_delta = malloc ( sizeof ( uint32_t ) * no_tracks ) ; track_end = malloc ( sizeof ( uint8_t ) * no_tracks ) ; running_event = malloc ( sizeof ( uint8_t ) * no_tracks ) ; smallest_delta = 0xffffffff ; for ( i = 0 ; i < no_tracks ; i ++ ) { if ( midi_size < 8 ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_CORUPT , ""(tooshort)"" , 0 ) ; goto _end ; } if ( memcmp ( midi_data , ""MTrk"" , 4 ) != 0 ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_CORUPT , ""(missingtrackheader)"" , 0 ) ; goto _end ; } midi_data += 4 ; midi_size -= 4 ; track_size = * midi_data ++ << 24 ; track_size |= * midi_data ++ << 16 ; track_size |= * midi_data ++ << 8 ; track_size |= * midi_data ++ ; midi_size -= 4 ; if ( midi_size < track_size ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_CORUPT , ""(tooshort)"" , 0 ) ; goto _end ; } if ( track_size < 3 ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_CORUPT , ""(badtracksize)"" , 0 ) ; goto _end ; } if ( ( midi_data [ track_size - 3 ] != 0xFF ) || ( midi_data [ track_size - 2 ] != 0x2F ) || ( midi_data [ track_size - 1 ] != 0x00 ) ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_CORUPT , ""(missingEOT)"" , 0 ) ; goto _end ; } tracks [ i ] = midi_data ; midi_data += track_size ; midi_size -= track_size ; track_end [ i ] = 0 ; running_event [ i ] = 0 ; track_delta [ i ] = 0 ; while ( * tracks [ i ] > 0x7F ) { track_delta [ i ] = ( track_delta [ i ] << 7 ) + ( * tracks [ i ] & 0x7F ) ; tracks [ i ] ++ ; } track_delta [ i ] = ( track_delta [ i ] << 7 ) + ( * tracks [ i ] & 0x7F ) ; tracks [ i ] ++ ; if ( midi_type == 1 ) { if ( track_delta [ i ] < smallest_delta ) { smallest_delta = track_delta [ i ] ; } } else { if ( i == 0 ) smallest_delta = track_delta [ i ] ; } } subtract_delta = smallest_delta ; sample_count_f = ( ( ( float ) smallest_delta * samples_per_delta_f ) + sample_remainder ) ; sample_count = ( uint32_t ) sample_count_f ; sample_remainder = sample_count_f - ( float ) sample_count ; mdi -> events [ mdi -> event_count - 1 ] . samples_to_next += sample_count ; mdi -> extra_info . approx_total_samples += sample_count ; if ( midi_type == 1 ) { while ( end_of_tracks != no_tracks ) { smallest_delta = 0 ; for ( i = 0 ; i < no_tracks ; i ++ ) { if ( track_end [ i ] ) continue ; if ( track_delta [ i ] ) { track_delta [ i ] -= subtract_delta ; if ( track_delta [ i ] ) { if ( ( ! smallest_delta ) || ( smallest_delta > track_delta [ i ] ) ) { smallest_delta = track_delta [ i ] ; } continue ; } } do { setup_ret = _WM_SetupMidiEvent ( mdi , tracks [ i ] , running_event [ i ] ) ; if ( setup_ret == 0 ) { goto _end ; } if ( tracks [ i ] [ 0 ] > 0x7f ) { if ( tracks [ i ] [ 0 ] < 0xf0 ) { running_event [ i ] = tracks [ i ] [ 0 ] ; } else if ( ( tracks [ i ] [ 0 ] == 0xf0 ) || ( tracks [ i ] [ 0 ] == 0xf7 ) ) { running_event [ i ] = 0 ; } else if ( ( tracks [ i ] [ 0 ] == 0xff ) && ( tracks [ i ] [ 1 ] == 0x2f ) && ( tracks [ i ] [ 2 ] == 0x00 ) ) { end_of_tracks ++ ; track_end [ i ] = 1 ; tracks [ i ] += 3 ; goto NEXT_TRACK ; } else if ( ( tracks [ i ] [ 0 ] == 0xff ) && ( tracks [ i ] [ 1 ] == 0x51 ) && ( tracks [ i ] [ 2 ] == 0x03 ) ) { tempo = ( tracks [ i ] [ 3 ] << 16 ) + ( tracks [ i ] [ 4 ] << 8 ) + tracks [ i ] [ 5 ] ; if ( ! tempo ) tempo = 500000 ; samples_per_delta_f = _WM_GetSamplesPerTick ( divisions , tempo ) ; } } tracks [ i ] += setup_ret ; if ( * tracks [ i ] > 0x7f ) { do { track_delta [ i ] = ( track_delta [ i ] << 7 ) + ( * tracks [ i ] & 0x7F ) ; tracks [ i ] ++ ; } while ( * tracks [ i ] > 0x7f ) ; } track_delta [ i ] = ( track_delta [ i ] << 7 ) + ( * tracks [ i ] & 0x7F ) ; tracks [ i ] ++ ; } while ( ! track_delta [ i ] ) ; if ( ( ! smallest_delta ) || ( smallest_delta > track_delta [ i ] ) ) { smallest_delta = track_delta [ i ] ; } NEXT_TRACK : continue ; } subtract_delta = smallest_delta ; sample_count_f = ( ( ( float ) smallest_delta * samples_per_delta_f ) + sample_remainder ) ; sample_count = ( uint32_t ) sample_count_f ; sample_remainder = sample_count_f - ( float ) sample_count ; mdi -> events [ mdi -> event_count - 1 ] . samples_to_next += sample_count ; mdi -> extra_info . approx_total_samples += sample_count ; } } else { if ( midi_type == 2 ) { mdi -> is_type2 = 1 ; } sample_remainder = 0.0 ; for ( i = 0 ; i < no_tracks ; i ++ ) { running_event [ i ] = 0 ; do { setup_ret = _WM_SetupMidiEvent ( mdi , tracks [ i ] , running_event [ i ] ) ; if ( setup_ret == 0 ) { goto _end ; } if ( tracks [ i ] [ 0 ] > 0x7f ) { if ( tracks [ i ] [ 0 ] < 0xf0 ) { running_event [ i ] = tracks [ i ] [ 0 ] ; } else if ( ( tracks [ i ] [ 0 ] == 0xf0 ) || ( tracks [ i ] [ 0 ] == 0xf7 ) ) { running_event [ i ] = 0 ; } else if ( ( tracks [ i ] [ 0 ] == 0xff ) && ( tracks [ i ] [ 1 ] == 0x2f ) && ( tracks [ i ] [ 2 ] == 0x00 ) ) { track_end [ i ] = 1 ; goto NEXT_TRACK2 ; } else if ( ( tracks [ i ] [ 0 ] == 0xff ) && ( tracks [ i ] [ 1 ] == 0x51 ) && ( tracks [ i ] [ 2 ] == 0x03 ) ) { tempo = ( tracks [ i ] [ 3 ] << 16 ) + ( tracks [ i ] [ 4 ] << 8 ) + tracks [ i ] [ 5 ] ; if ( ! tempo ) tempo = 500000 ; samples_per_delta_f = _WM_GetSamplesPerTick ( divisions , tempo ) ; } } tracks [ i ] += setup_ret ; track_delta [ i ] = 0 ; if ( * tracks [ i ] > 0x7f ) { do { track_delta [ i ] = ( track_delta [ i ] << 7 ) + ( * tracks [ i ] & 0x7F ) ; tracks [ i ] ++ ; } while ( * tracks [ i ] > 0x7f ) ; } track_delta [ i ] = ( track_delta [ i ] << 7 ) + ( * tracks [ i ] & 0x7F ) ; tracks [ i ] ++ ; sample_count_f = ( ( ( float ) track_delta [ i ] * samples_per_delta_f ) + sample_remainder ) ; sample_count = ( uint32_t ) sample_count_f ; sample_remainder = sample_count_f - ( float ) sample_count ; mdi -> events [ mdi -> event_count - 1 ] . samples_to_next += sample_count ; mdi -> extra_info . approx_total_samples += sample_count ; NEXT_TRACK2 : smallest_delta = track_delta [ i ] ; UNUSED ( smallest_delta ) ; } while ( track_end [ i ] == 0 ) ; } } if ( ( mdi -> reverb = _WM_init_reverb ( _WM_SampleRate , _WM_reverb_room_width , _WM_reverb_room_length , _WM_reverb_listen_posx , _WM_reverb_listen_posy ) ) == NULL ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_MEM , ""toinitreverb"" , 0 ) ; goto _end ; } mdi -> extra_info . current_sample = 0 ; mdi -> current_event = & mdi -> events [ 0 ] ; mdi -> samples_to_mix = 0 ; mdi -> note = NULL ; _WM_ResetToStart ( mdi ) ; _end : free ( sysex_store ) ; free ( track_end ) ; free ( track_delta ) ; free ( running_event ) ; free ( tracks ) ; if ( mdi -> reverb ) return ( mdi ) ; _WM_freeMDI ( mdi ) ; return ( NULL ) ; } "," uint32_t midi_type ; uint8_t * * tracks ; uint32_t * track_size ; uint32_t end_of_tracks no_tracks ) ; track_size = malloc ( sizeof ( uint32_t ) * no_tracks ) ; -= 4 ; tmp_val = * midi_data << 24 ; tmp_val |= * midi_data << 16 ; tmp_val |= * midi_data << 8 ; tmp_val |= * midi_data ( midi_size < tmp_val ) { _WM_GLOBAL_ERROR } if ( tmp_val < 3 ) ( midi_data [ tmp_val - 3 ] ( midi_data [ tmp_val - 2 ] ( midi_data [ tmp_val - 1 ] = midi_data ; track_size [ i ] = tmp_val ; midi_data += tmp_val ; midi_size -= ; midi_size -= tmp_val ; track_end [ ] ++ ; track_size [ i ] -- ; i ] ++ ; track_size [ i ] -- i ] , track_size [ i ] , += 3 ; track_size [ i ] -= 3 ; += setup_ret ; track_size [ i ] -= setup_ret ; { do { if ( ! track_size [ i ] ) break ; ] ++ ; track_size [ i ] -- ; ) ; } if ( ! track_size [ i ] ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_CORUPT , ""(tooshort)"" , 0 ) ; goto _end ; } i ] ++ ; track_size [ i ] -- i ] , track_size [ i ] , += setup_ret ; track_size [ i ] -= setup_ret ; { do { if ( ! track_size [ i ] ) break ; ] ++ ; track_size [ i ] -- ; ) ; } if ( ! track_size [ i ] ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_CORUPT , ""(tooshort)"" , 0 ) ; goto _end ; } i ] ++ ; track_size [ i ] -- tracks ) ; free ( track_size ) ; ",Mindwerks@wildmidi/ad6d7cf88d6673167ca1f517248af9409a9f1be1,CVE-2017-11664,https://github.com/Mindwerks/wildmidi/commit/ad6d7cf88d6673167ca1f517248af9409a9f1be1,2017-08-17T16:29Z 720,CWE-119,"CWE-119 int sock_setsockopt ( struct socket * sock , int level , int optname , char __user * optval , unsigned int optlen ) { struct sock * sk = sock -> sk ; int val ; int valbool ; struct linger ling ; int ret = 0 ; if ( optname == SO_BINDTODEVICE ) return sock_setbindtodevice ( sk , optval , optlen ) ; if ( optlen < sizeof ( int ) ) return - EINVAL ; if ( get_user ( val , ( int __user * ) optval ) ) return - EFAULT ; valbool = val ? 1 : 0 ; lock_sock ( sk ) ; switch ( optname ) { case SO_DEBUG : if ( val && ! capable ( CAP_NET_ADMIN ) ) ret = - EACCES ; else sock_valbool_flag ( sk , SOCK_DBG , valbool ) ; break ; case SO_REUSEADDR : sk -> sk_reuse = ( valbool ? SK_CAN_REUSE : SK_NO_REUSE ) ; break ; case SO_REUSEPORT : sk -> sk_reuseport = valbool ; break ; case SO_TYPE : case SO_PROTOCOL : case SO_DOMAIN : case SO_ERROR : ret = - ENOPROTOOPT ; break ; case SO_DONTROUTE : sock_valbool_flag ( sk , SOCK_LOCALROUTE , valbool ) ; break ; case SO_BROADCAST : sock_valbool_flag ( sk , SOCK_BROADCAST , valbool ) ; break ; case SO_SNDBUF : val = min_t ( u32 , val , sysctl_wmem_max ) ; set_sndbuf : sk -> sk_userlocks |= SOCK_SNDBUF_LOCK ; sk -> sk_sndbuf = max_t ( u32 , val * 2 , SOCK_MIN_SNDBUF ) ; sk -> sk_write_space ( sk ) ; break ; case SO_SNDBUFFORCE : if ( ! capable ( CAP_NET_ADMIN ) ) { ret = - EPERM ; break ; } goto set_sndbuf ; case SO_RCVBUF : val = min_t ( u32 , val , sysctl_rmem_max ) ; set_rcvbuf : sk -> sk_userlocks |= SOCK_RCVBUF_LOCK ; sk -> sk_rcvbuf = max_t ( u32 , val * 2 , SOCK_MIN_RCVBUF ) ; break ; case SO_RCVBUFFORCE : if ( ! capable ( CAP_NET_ADMIN ) ) { ret = - EPERM ; break ; } goto set_rcvbuf ; case SO_KEEPALIVE : # ifdef CONFIG_INET if ( sk -> sk_protocol == IPPROTO_TCP && sk -> sk_type == SOCK_STREAM ) tcp_set_keepalive ( sk , valbool ) ; # endif sock_valbool_flag ( sk , SOCK_KEEPOPEN , valbool ) ; break ; case SO_OOBINLINE : sock_valbool_flag ( sk , SOCK_URGINLINE , valbool ) ; break ; case SO_NO_CHECK : sk -> sk_no_check_tx = valbool ; break ; case SO_PRIORITY : if ( ( val >= 0 && val <= 6 ) || ns_capable ( sock_net ( sk ) -> user_ns , CAP_NET_ADMIN ) ) sk -> sk_priority = val ; else ret = - EPERM ; break ; case SO_LINGER : if ( optlen < sizeof ( ling ) ) { ret = - EINVAL ; break ; } if ( copy_from_user ( & ling , optval , sizeof ( ling ) ) ) { ret = - EFAULT ; break ; } if ( ! ling . l_onoff ) sock_reset_flag ( sk , SOCK_LINGER ) ; else { # if ( BITS_PER_LONG == 32 ) if ( ( unsigned int ) ling . l_linger >= MAX_SCHEDULE_TIMEOUT / HZ ) sk -> sk_lingertime = MAX_SCHEDULE_TIMEOUT ; else # endif sk -> sk_lingertime = ( unsigned int ) ling . l_linger * HZ ; sock_set_flag ( sk , SOCK_LINGER ) ; } break ; case SO_BSDCOMPAT : sock_warn_obsolete_bsdism ( ""setsockopt"" ) ; break ; case SO_PASSCRED : if ( valbool ) set_bit ( SOCK_PASSCRED , & sock -> flags ) ; else clear_bit ( SOCK_PASSCRED , & sock -> flags ) ; break ; case SO_TIMESTAMP : case SO_TIMESTAMPNS : if ( valbool ) { if ( optname == SO_TIMESTAMP ) sock_reset_flag ( sk , SOCK_RCVTSTAMPNS ) ; else sock_set_flag ( sk , SOCK_RCVTSTAMPNS ) ; sock_set_flag ( sk , SOCK_RCVTSTAMP ) ; sock_enable_timestamp ( sk , SOCK_TIMESTAMP ) ; } else { sock_reset_flag ( sk , SOCK_RCVTSTAMP ) ; sock_reset_flag ( sk , SOCK_RCVTSTAMPNS ) ; } break ; case SO_TIMESTAMPING : if ( val & ~ SOF_TIMESTAMPING_MASK ) { ret = - EINVAL ; break ; } if ( val & SOF_TIMESTAMPING_OPT_ID && ! ( sk -> sk_tsflags & SOF_TIMESTAMPING_OPT_ID ) ) { if ( sk -> sk_protocol == IPPROTO_TCP && sk -> sk_type == SOCK_STREAM ) { if ( ( 1 << sk -> sk_state ) & ( TCPF_CLOSE | TCPF_LISTEN ) ) { ret = - EINVAL ; break ; } sk -> sk_tskey = tcp_sk ( sk ) -> snd_una ; } else { sk -> sk_tskey = 0 ; } } sk -> sk_tsflags = val ; if ( val & SOF_TIMESTAMPING_RX_SOFTWARE ) sock_enable_timestamp ( sk , SOCK_TIMESTAMPING_RX_SOFTWARE ) ; else sock_disable_timestamp ( sk , ( 1UL << SOCK_TIMESTAMPING_RX_SOFTWARE ) ) ; break ; case SO_RCVLOWAT : if ( val < 0 ) val = INT_MAX ; sk -> sk_rcvlowat = val ? : 1 ; break ; case SO_RCVTIMEO : ret = sock_set_timeout ( & sk -> sk_rcvtimeo , optval , optlen ) ; break ; case SO_SNDTIMEO : ret = sock_set_timeout ( & sk -> sk_sndtimeo , optval , optlen ) ; break ; case SO_ATTACH_FILTER : ret = - EINVAL ; if ( optlen == sizeof ( struct sock_fprog ) ) { struct sock_fprog fprog ; ret = - EFAULT ; if ( copy_from_user ( & fprog , optval , sizeof ( fprog ) ) ) break ; ret = sk_attach_filter ( & fprog , sk ) ; } break ; case SO_ATTACH_BPF : ret = - EINVAL ; if ( optlen == sizeof ( u32 ) ) { u32 ufd ; ret = - EFAULT ; if ( copy_from_user ( & ufd , optval , sizeof ( ufd ) ) ) break ; ret = sk_attach_bpf ( ufd , sk ) ; } break ; case SO_ATTACH_REUSEPORT_CBPF : ret = - EINVAL ; if ( optlen == sizeof ( struct sock_fprog ) ) { struct sock_fprog fprog ; ret = - EFAULT ; if ( copy_from_user ( & fprog , optval , sizeof ( fprog ) ) ) break ; ret = sk_reuseport_attach_filter ( & fprog , sk ) ; } break ; case SO_ATTACH_REUSEPORT_EBPF : ret = - EINVAL ; if ( optlen == sizeof ( u32 ) ) { u32 ufd ; ret = - EFAULT ; if ( copy_from_user ( & ufd , optval , sizeof ( ufd ) ) ) break ; ret = sk_reuseport_attach_bpf ( ufd , sk ) ; } break ; case SO_DETACH_FILTER : ret = sk_detach_filter ( sk ) ; break ; case SO_LOCK_FILTER : if ( sock_flag ( sk , SOCK_FILTER_LOCKED ) && ! valbool ) ret = - EPERM ; else sock_valbool_flag ( sk , SOCK_FILTER_LOCKED , valbool ) ; break ; case SO_PASSSEC : if ( valbool ) set_bit ( SOCK_PASSSEC , & sock -> flags ) ; else clear_bit ( SOCK_PASSSEC , & sock -> flags ) ; break ; case SO_MARK : if ( ! ns_capable ( sock_net ( sk ) -> user_ns , CAP_NET_ADMIN ) ) ret = - EPERM ; else sk -> sk_mark = val ; break ; case SO_RXQ_OVFL : sock_valbool_flag ( sk , SOCK_RXQ_OVFL , valbool ) ; break ; case SO_WIFI_STATUS : sock_valbool_flag ( sk , SOCK_WIFI_STATUS , valbool ) ; break ; case SO_PEEK_OFF : if ( sock -> ops -> set_peek_off ) ret = sock -> ops -> set_peek_off ( sk , val ) ; else ret = - EOPNOTSUPP ; break ; case SO_NOFCS : sock_valbool_flag ( sk , SOCK_NOFCS , valbool ) ; break ; case SO_SELECT_ERR_QUEUE : sock_valbool_flag ( sk , SOCK_SELECT_ERR_QUEUE , valbool ) ; break ; # ifdef CONFIG_NET_RX_BUSY_POLL case SO_BUSY_POLL : if ( ( val > sk -> sk_ll_usec ) && ! capable ( CAP_NET_ADMIN ) ) ret = - EPERM ; else { if ( val < 0 ) ret = - EINVAL ; else sk -> sk_ll_usec = val ; } break ; # endif case SO_MAX_PACING_RATE : sk -> sk_max_pacing_rate = val ; sk -> sk_pacing_rate = min ( sk -> sk_pacing_rate , sk -> sk_max_pacing_rate ) ; break ; case SO_INCOMING_CPU : sk -> sk_incoming_cpu = val ; break ; case SO_CNX_ADVICE : if ( val == 1 ) dst_negative_advice ( sk ) ; break ; default : ret = - ENOPROTOOPT ; break ; } release_sock ( sk ) ; return ret ; } "," = max_t ( int , val * = max_t ( int , val * ",torvalds@linux/b98b0bc8c431e3ceb4b26b0dfc8db509518fb290,CVE-2016-9793,https://github.com/torvalds/linux/commit/b98b0bc8c431e3ceb4b26b0dfc8db509518fb290,2016-12-28T07:59Z 721,CWE-119,"CWE-119 static int udf_load_logicalvol ( struct super_block * sb , sector_t block , struct kernel_lb_addr * fileset ) { struct logicalVolDesc * lvd ; int i , j , offset ; uint8_t type ; struct udf_sb_info * sbi = UDF_SB ( sb ) ; struct genericPartitionMap * gpm ; uint16_t ident ; struct buffer_head * bh ; int ret = 0 ; bh = udf_read_tagged ( sb , block , block , & ident ) ; if ( ! bh ) return 1 ; BUG_ON ( ident != TAG_IDENT_LVD ) ; lvd = ( struct logicalVolDesc * ) bh -> b_data ; ret = udf_sb_alloc_partition_maps ( sb , le32_to_cpu ( lvd -> numPartitionMaps ) ) ; if ( ret ) goto out_bh ; for ( i = 0 , offset = 0 ; i < sbi -> s_partitions && offset < le32_to_cpu ( lvd -> mapTableLength ) ; i ++ , offset += gpm -> partitionMapLength ) { struct udf_part_map * map = & sbi -> s_partmaps [ i ] ; gpm = ( struct genericPartitionMap * ) & ( lvd -> partitionMaps [ offset ] ) ; type = gpm -> partitionMapType ; if ( type == 1 ) { struct genericPartitionMap1 * gpm1 = ( struct genericPartitionMap1 * ) gpm ; map -> s_partition_type = UDF_TYPE1_MAP15 ; map -> s_volumeseqnum = le16_to_cpu ( gpm1 -> volSeqNum ) ; map -> s_partition_num = le16_to_cpu ( gpm1 -> partitionNum ) ; map -> s_partition_func = NULL ; } else if ( type == 2 ) { struct udfPartitionMap2 * upm2 = ( struct udfPartitionMap2 * ) gpm ; if ( ! strncmp ( upm2 -> partIdent . ident , UDF_ID_VIRTUAL , strlen ( UDF_ID_VIRTUAL ) ) ) { u16 suf = le16_to_cpu ( ( ( __le16 * ) upm2 -> partIdent . identSuffix ) [ 0 ] ) ; if ( suf < 0x0200 ) { map -> s_partition_type = UDF_VIRTUAL_MAP15 ; map -> s_partition_func = udf_get_pblock_virt15 ; } else { map -> s_partition_type = UDF_VIRTUAL_MAP20 ; map -> s_partition_func = udf_get_pblock_virt20 ; } } else if ( ! strncmp ( upm2 -> partIdent . ident , UDF_ID_SPARABLE , strlen ( UDF_ID_SPARABLE ) ) ) { uint32_t loc ; struct sparingTable * st ; struct sparablePartitionMap * spm = ( struct sparablePartitionMap * ) gpm ; map -> s_partition_type = UDF_SPARABLE_MAP15 ; map -> s_type_specific . s_sparing . s_packet_len = le16_to_cpu ( spm -> packetLength ) ; for ( j = 0 ; j < spm -> numSparingTables ; j ++ ) { struct buffer_head * bh2 ; loc = le32_to_cpu ( spm -> locSparingTable [ j ] ) ; bh2 = udf_read_tagged ( sb , loc , loc , & ident ) ; map -> s_type_specific . s_sparing . s_spar_map [ j ] = bh2 ; if ( bh2 == NULL ) continue ; st = ( struct sparingTable * ) bh2 -> b_data ; if ( ident != 0 || strncmp ( st -> sparingIdent . ident , UDF_ID_SPARING , strlen ( UDF_ID_SPARING ) ) ) { brelse ( bh2 ) ; map -> s_type_specific . s_sparing . s_spar_map [ j ] = NULL ; } } map -> s_partition_func = udf_get_pblock_spar15 ; } else if ( ! strncmp ( upm2 -> partIdent . ident , UDF_ID_METADATA , strlen ( UDF_ID_METADATA ) ) ) { struct udf_meta_data * mdata = & map -> s_type_specific . s_metadata ; struct metadataPartitionMap * mdm = ( struct metadataPartitionMap * ) & ( lvd -> partitionMaps [ offset ] ) ; udf_debug ( ""ParsingLogicalvolpart%dtype%did=%s\\n"" , i , type , UDF_ID_METADATA ) ; map -> s_partition_type = UDF_METADATA_MAP25 ; map -> s_partition_func = udf_get_pblock_meta25 ; mdata -> s_meta_file_loc = le32_to_cpu ( mdm -> metadataFileLoc ) ; mdata -> s_mirror_file_loc = le32_to_cpu ( mdm -> metadataMirrorFileLoc ) ; mdata -> s_bitmap_file_loc = le32_to_cpu ( mdm -> metadataBitmapFileLoc ) ; mdata -> s_alloc_unit_size = le32_to_cpu ( mdm -> allocUnitSize ) ; mdata -> s_align_unit_size = le16_to_cpu ( mdm -> alignUnitSize ) ; if ( mdm -> flags & 0x01 ) mdata -> s_flags |= MF_DUPLICATE_MD ; udf_debug ( ""MetadataIdentsuffix=0x%x\\n"" , le16_to_cpu ( * ( __le16 * ) mdm -> partIdent . identSuffix ) ) ; udf_debug ( ""Metadatapartnum=%d\\n"" , le16_to_cpu ( mdm -> partitionNum ) ) ; udf_debug ( ""Metadatapartallocunitsize=%d\\n"" , le32_to_cpu ( mdm -> allocUnitSize ) ) ; udf_debug ( ""Metadatafileloc=%d\\n"" , le32_to_cpu ( mdm -> metadataFileLoc ) ) ; udf_debug ( ""Mirrorfileloc=%d\\n"" , le32_to_cpu ( mdm -> metadataMirrorFileLoc ) ) ; udf_debug ( ""Bitmapfileloc=%d\\n"" , le32_to_cpu ( mdm -> metadataBitmapFileLoc ) ) ; udf_debug ( ""Flags:%d%d\\n"" , mdata -> s_flags , mdm -> flags ) ; } else { udf_debug ( ""Unknownident:%s\\n"" , upm2 -> partIdent . ident ) ; continue ; } map -> s_volumeseqnum = le16_to_cpu ( upm2 -> volSeqNum ) ; map -> s_partition_num = le16_to_cpu ( upm2 -> partitionNum ) ; } udf_debug ( ""Partition(%d:%d)type%donvolume%d\\n"" , i , map -> s_partition_num , type , map -> s_volumeseqnum ) ; } if ( fileset ) { struct long_ad * la = ( struct long_ad * ) & ( lvd -> logicalVolContentsUse [ 0 ] ) ; * fileset = lelb_to_cpu ( la -> extLocation ) ; udf_debug ( ""FileSetfoundinLogicalVolDescatblock=%d,partition=%d\\n"" , fileset -> logicalBlockNum , fileset -> partitionReferenceNum ) ; } if ( lvd -> integritySeqExt . extLength ) udf_load_logicalvolint ( sb , leea_to_cpu ( lvd -> integritySeqExt ) ) ; out_bh : brelse ( bh ) ; return ret ; } "," * bh ; unsigned int table_len ; -> b_data ; table_len = le32_to_cpu ( lvd -> mapTableLength ) ; if ( sizeof ( * lvd ) + table_len > sb -> s_blocksize ) { udf_err ( sb , ""errorloadinglogicalvolumedescriptor:"" ""Partitiontabletoolong(%u>%lu)\\n"" , table_len , sb -> s_blocksize - sizeof ( * lvd ) ) ; goto out_bh ; } && offset < table_len ; i ++ ",torvalds@linux/adee11b2085bee90bd8f4f52123ffb07882d6256,CVE-2012-3400,https://github.com/torvalds/linux/commit/adee11b2085bee90bd8f4f52123ffb07882d6256,2012-10-03T11:02Z 722,CWE-476,"CWE-476 jas_image_t * bmp_decode ( jas_stream_t * in , char * optstr ) { jas_image_t * image ; bmp_hdr_t hdr ; bmp_info_t * info ; uint_fast16_t cmptno ; jas_image_cmptparm_t cmptparms [ 3 ] ; jas_image_cmptparm_t * cmptparm ; uint_fast16_t numcmpts ; long n ; if ( optstr ) { jas_eprintf ( ""warning:ignoringBMPdecoderoptions\\n"" ) ; } jas_eprintf ( ""THEBMPFORMATISNOTFULLYSUPPORTED!\\n"" ""THATIS,THEJASPERSOFTWARECANNOTDECODEALLTYPESOFBMPDATA.\\n"" ""IFYOUHAVEANYPROBLEMS,PLEASETRYCONVERTINGYOURIMAGEDATA\\n"" ""TOTHEPNMFORMAT,ANDUSINGTHISFORMATINSTEAD.\\n"" ) ; if ( bmp_gethdr ( in , & hdr ) ) { jas_eprintf ( ""cannotgetheader\\n"" ) ; return 0 ; } JAS_DBGLOG ( 1 , ( ""BMPheader:magic0x%x;siz%d;res1%d;res2%d;off%d\\n"" , hdr . magic , hdr . siz , hdr . reserved1 , hdr . reserved2 , hdr . off ) ) ; if ( ! ( info = bmp_getinfo ( in ) ) ) { jas_eprintf ( ""cannotgetinfo\\n"" ) ; return 0 ; } JAS_DBGLOG ( 1 , ( ""BMPinformation:len%d;width%d;height%d;numplanes%d;"" ""depth%d;enctype%d;siz%d;hres%d;vres%d;numcolors%d;"" ""mincolors%d\\n"" , info -> len , info -> width , info -> height , info -> numplanes , info -> depth , info -> enctype , info -> siz , info -> hres , info -> vres , info -> numcolors , info -> mincolors ) ) ; if ( ! bmp_issupported ( & hdr , info ) ) { jas_eprintf ( ""error:unsupportedBMPencoding\\n"" ) ; bmp_info_destroy ( info ) ; return 0 ; } if ( ( n = hdr . off - ( BMP_HDRLEN + BMP_INFOLEN + BMP_PALLEN ( info ) ) ) < 0 ) { jas_eprintf ( ""error:possiblybadbitmapoffset?\\n"" ) ; return 0 ; } if ( n > 0 ) { jas_eprintf ( ""skippingunknowndatainBMPfile\\n"" ) ; if ( bmp_gobble ( in , n ) ) { bmp_info_destroy ( info ) ; return 0 ; } } numcmpts = bmp_numcmpts ( info ) ; for ( cmptno = 0 , cmptparm = cmptparms ; cmptno < numcmpts ; ++ cmptno , ++ cmptparm ) { cmptparm -> tlx = 0 ; cmptparm -> tly = 0 ; cmptparm -> hstep = 1 ; cmptparm -> vstep = 1 ; cmptparm -> width = info -> width ; cmptparm -> height = info -> height ; cmptparm -> prec = 8 ; cmptparm -> sgnd = false ; } if ( ! ( image = jas_image_create ( numcmpts , cmptparms , JAS_CLRSPC_UNKNOWN ) ) ) { bmp_info_destroy ( info ) ; return 0 ; } if ( numcmpts == 3 ) { jas_image_setclrspc ( image , JAS_CLRSPC_SRGB ) ; jas_image_setcmpttype ( image , 0 , JAS_IMAGE_CT_COLOR ( JAS_CLRSPC_CHANIND_RGB_R ) ) ; jas_image_setcmpttype ( image , 1 , JAS_IMAGE_CT_COLOR ( JAS_CLRSPC_CHANIND_RGB_G ) ) ; jas_image_setcmpttype ( image , 2 , JAS_IMAGE_CT_COLOR ( JAS_CLRSPC_CHANIND_RGB_B ) ) ; } else { jas_image_setclrspc ( image , JAS_CLRSPC_SGRAY ) ; jas_image_setcmpttype ( image , 0 , JAS_IMAGE_CT_COLOR ( JAS_CLRSPC_CHANIND_GRAY_Y ) ) ; } if ( bmp_getdata ( in , info , image ) ) { bmp_info_destroy ( info ) ; jas_image_destroy ( image ) ; return 0 ; } bmp_info_destroy ( info ) ; return image ; } "," long n ; image = 0 ; info = 0 ; ""cannotgetheader\\n"" ) ; goto error ; } JAS_DBGLOG ""cannotgetinfo\\n"" ) ; goto error ; } JAS_DBGLOG 1 , ( ""BMPinformation:len%ld;width%ld;height%ld;numplanes%d;"" ""depth%d;enctype%ld;siz%ld;hres%ld;vres%ld;numcolors%ld;"" ""mincolors%ld\\n"" , JAS_CAST ( long , info -> info -> len ) , JAS_CAST ( long info -> width ) , JAS_CAST ( long info -> height ) , JAS_CAST ( long info -> numplanes ) , JAS_CAST ( long , info -> depth info -> depth ) , JAS_CAST ( long info -> enctype ) , JAS_CAST ( long info -> siz ) , JAS_CAST ( long info -> hres ) , JAS_CAST ( long info -> vres ) , JAS_CAST ( long , info -> numcolors info -> numcolors ) , JAS_CAST ( long mincolors ) ) ) ; if ( info -> width < 0 || info -> height < 0 || info -> numplanes < 0 || info -> depth < 0 || info -> siz < 0 || info -> hres < 0 || info -> vres < 0 ) { jas_eprintf ( ""corruptbitstream\\n"" ) ; goto error ; } if ( ! ""error:unsupportedBMPencoding\\n"" ) ; goto error ; } if ""error:possiblybadbitmapoffset?\\n"" ) ; goto error ; } if ) ) { goto error ; } } ) ) { goto error ; } if ) ) { goto error ; } info ) ; return image ; error : if ( info ) { bmp_info_destroy ( info ) ; } if ( image ) { image ) ; } 0 ; } ",mdadams@jasper/5d66894d2313e3f3469f19066e149e08ff076698,CVE-2016-8884,https://github.com/mdadams/jasper/commit/5d66894d2313e3f3469f19066e149e08ff076698,2017-03-28T14:59Z 723,CWE-125,"CWE-125 void qedi_dbg_notice ( struct qedi_dbg_ctx * qedi , const char * func , u32 line , const char * fmt , ... ) { va_list va ; struct va_format vaf ; char nfunc [ 32 ] ; memset ( nfunc , 0 , sizeof ( nfunc ) ) ; memcpy ( nfunc , func , sizeof ( nfunc ) - 1 ) ; va_start ( va , fmt ) ; vaf . fmt = fmt ; vaf . va = & va ; if ( ! ( qedi_dbg_log & QEDI_LOG_NOTICE ) ) goto ret ; if ( likely ( qedi ) && likely ( qedi -> pdev ) ) pr_notice ( ""[%s]:[%s:%d]:%d:%pV"" , dev_name ( & qedi -> pdev -> dev ) , nfunc , line , qedi -> host_no , & vaf ) ; else pr_notice ( ""[0000:00:00.0]:[%s:%d]:%pV"" , nfunc , line , & vaf ) ; ret : va_end ( va ) ; } "," struct va_format vaf ; va_start ( dev ) , func , line , ( ""[0000:00:00.0]:[%s:%d]:%pV"" , func , line , ",torvalds@linux/c09581a52765a85f19fc35340127396d5e3379cc,CVE-2019-15090,https://github.com/torvalds/linux/commit/c09581a52765a85f19fc35340127396d5e3379cc,2019-08-16T00:15Z 724,CWE-119,"CWE-119 IHEVCD_ERROR_T ihevcd_cabac_init ( cab_ctxt_t * ps_cabac , bitstrm_t * ps_bitstrm , WORD32 qp , WORD32 cabac_init_idc , const UWORD8 * pu1_init_ctxt ) { ASSERT ( ps_cabac != NULL ) ; ASSERT ( ps_bitstrm != NULL ) ; ASSERT ( ( qp >= 0 ) && ( qp < 52 ) ) ; ASSERT ( ( cabac_init_idc >= 0 ) && ( cabac_init_idc < 3 ) ) ; UNUSED ( qp ) ; UNUSED ( cabac_init_idc ) ; # if FULLRANGE ps_cabac -> u4_range = ( UWORD32 ) 510 << RANGE_SHIFT ; BITS_GET ( ps_cabac -> u4_ofst , ps_bitstrm -> pu4_buf , ps_bitstrm -> u4_bit_ofst , ps_bitstrm -> u4_cur_word , ps_bitstrm -> u4_nxt_word , ( 9 + RANGE_SHIFT ) ) ; # else ps_cabac -> u4_range = ( UWORD32 ) 510 ; BITS_GET ( ps_cabac -> u4_ofst , ps_bitstrm -> pu4_buf , ps_bitstrm -> u4_bit_ofst , ps_bitstrm -> u4_cur_word , ps_bitstrm -> u4_nxt_word , 9 ) ; # endif memcpy ( ps_cabac -> au1_ctxt_models , pu1_init_ctxt , IHEVC_CAB_CTXT_END ) ; DEBUG_RANGE_OFST ( ""init"" , ps_cabac -> u4_range , ps_cabac -> u4_ofst ) ; return ( ( IHEVCD_ERROR_T ) IHEVCD_SUCCESS ) ; } "," u4_ofst ) ; if ( ps_cabac -> u4_ofst >= ps_cabac -> u4_range ) { return ( ( IHEVCD_ERROR_T ) IHEVCD_FAIL ) ; } ",external@libhevc/bcfc7124f6ef9f1ec128fb2e90de774a5b33d199,CVE-2017-0589,https://android.googlesource.com/platform/external/libhevc/+/bcfc7124f6ef9f1ec128fb2e90de774a5b33d199,2017-05-12T15:29Z 725,CWE-200,"CWE-200 static void on_page_prepare ( GtkNotebook * assistant , GtkWidget * page , gpointer user_data ) { if ( ! is_processing_finished ( ) ) { show_next_step_button ( ) ; clear_warnings ( ) ; } gtk_widget_hide ( g_btn_detail ) ; gtk_widget_hide ( g_btn_onfail ) ; if ( ! g_expert_mode ) gtk_widget_hide ( g_btn_repeat ) ; save_items_from_notepad ( ) ; save_text_from_text_view ( g_tv_comment , FILENAME_COMMENT ) ; if ( pages [ PAGENO_SUMMARY ] . page_widget == page ) { if ( ! g_expert_mode ) { int n = select_next_page_no ( pages [ PAGENO_SUMMARY ] . page_no , NULL ) ; log_info ( ""switchingtopage_no:%d"" , n ) ; gtk_notebook_set_current_page ( assistant , n ) ; return ; } } if ( pages [ PAGENO_EDIT_ELEMENTS ] . page_widget == page ) { if ( highlight_forbidden ( ) ) { add_sensitive_data_warning ( ) ; show_warnings ( ) ; gtk_expander_set_expanded ( g_exp_search , TRUE ) ; } else gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( g_rb_custom_search ) , TRUE ) ; show_warnings ( ) ; } if ( pages [ PAGENO_REVIEW_DATA ] . page_widget == page ) { update_ls_details_checkboxes ( g_event_selected ) ; gtk_widget_set_sensitive ( g_btn_next , gtk_toggle_button_get_active ( g_tb_approve_bt ) ) ; } if ( pages [ PAGENO_EDIT_COMMENT ] . page_widget == page ) { gtk_widget_show ( g_btn_detail ) ; gtk_widget_set_sensitive ( g_btn_next , false ) ; on_comment_changed ( gtk_text_view_get_buffer ( g_tv_comment ) , NULL ) ; } if ( pages [ PAGENO_EVENT_PROGRESS ] . page_widget == page ) { log_info ( ""g_event_selected:\'%s\'"" , g_event_selected ) ; if ( g_event_selected && g_event_selected [ 0 ] ) { clear_warnings ( ) ; start_event_run ( g_event_selected ) ; } } if ( pages [ PAGENO_EVENT_SELECTOR ] . page_widget == page ) { if ( ! g_expert_mode && ! g_auto_event_list ) hide_next_step_button ( ) ; } } "," g_tv_comment , FILENAME_COMMENT ) ; problem_data_reload_from_dump_dir ( ) ; update_gui_state_from_problem_data ( 0 ",abrt@libreport/257578a23d1537a2d235aaa2b1488ee4f818e360,CVE-2015-5302,https://github.com/abrt/libreport/commit/257578a23d1537a2d235aaa2b1488ee4f818e360,2015-12-07T18:59Z 726,CWE-200,"CWE-200 static long __media_device_enum_links ( struct media_device * mdev , struct media_links_enum * links ) { struct media_entity * entity ; entity = find_entity ( mdev , links -> entity ) ; if ( entity == NULL ) return - EINVAL ; if ( links -> pads ) { unsigned int p ; for ( p = 0 ; p < entity -> num_pads ; p ++ ) { struct media_pad_desc pad ; media_device_kpad_to_upad ( & entity -> pads [ p ] , & pad ) ; if ( copy_to_user ( & links -> pads [ p ] , & pad , sizeof ( pad ) ) ) return - EFAULT ; } } if ( links -> links ) { struct media_link_desc __user * ulink ; unsigned int l ; for ( l = 0 , ulink = links -> links ; l < entity -> num_links ; l ++ ) { struct media_link_desc link ; if ( entity -> links [ l ] . source -> entity != entity ) continue ; media_device_kpad_to_upad ( entity -> links [ l ] . source , & link . source ) ; media_device_kpad_to_upad ( entity -> links [ l ] . sink , & link . sink ) ; link . flags = entity -> links [ l ] . flags ; if ( copy_to_user ( ulink , & link , sizeof ( * ulink ) ) ) return - EFAULT ; ulink ++ ; } } return 0 ; } "," media_pad_desc pad ; memset ( & pad , 0 , sizeof ( pad ) ) ; ) continue ; memset ( & link , 0 , sizeof ( link ) ) ; ",torvalds@linux/c88e739b1fad662240e99ecbd0bdaac871717987,CVE-2014-9895,https://github.com/torvalds/linux/commit/c88e739b1fad662240e99ecbd0bdaac871717987,2016-08-06T10:59Z 727,CWE-908,"CWE-908 static int md_analyze_line ( MD_CTX * ctx , OFF beg , OFF * p_end , const MD_LINE_ANALYSIS * pivot_line , MD_LINE_ANALYSIS * line ) { unsigned total_indent = 0 ; int n_parents = 0 ; int n_brothers = 0 ; int n_children = 0 ; MD_CONTAINER container = { 0 } ; int prev_line_has_list_loosening_effect = ctx -> last_line_has_list_loosening_effect ; OFF off = beg ; OFF hr_killer = 0 ; int ret = 0 ; line -> indent = md_line_indentation ( ctx , total_indent , off , & off ) ; total_indent += line -> indent ; line -> beg = off ; while ( n_parents < ctx -> n_containers ) { MD_CONTAINER * c = & ctx -> containers [ n_parents ] ; if ( c -> ch == _T ( '>' ) && line -> indent < ctx -> code_indent_offset && off < ctx -> size && CH ( off ) == _T ( '>' ) ) { off ++ ; total_indent ++ ; line -> indent = md_line_indentation ( ctx , total_indent , off , & off ) ; total_indent += line -> indent ; if ( line -> indent > 0 ) line -> indent -- ; line -> beg = off ; } else if ( c -> ch != _T ( '>' ) && line -> indent >= c -> contents_indent ) { line -> indent -= c -> contents_indent ; } else { break ; } n_parents ++ ; } if ( off >= ctx -> size || ISNEWLINE ( off ) ) { if ( n_brothers + n_children == 0 ) { while ( n_parents < ctx -> n_containers && ctx -> containers [ n_parents ] . ch != _T ( '>' ) ) n_parents ++ ; } } while ( TRUE ) { if ( pivot_line -> type == MD_LINE_FENCEDCODE ) { line -> beg = off ; if ( line -> indent < ctx -> code_indent_offset ) { if ( md_is_closing_code_fence ( ctx , CH ( pivot_line -> beg ) , off , & off ) ) { line -> type = MD_LINE_BLANK ; ctx -> last_line_has_list_loosening_effect = FALSE ; break ; } } if ( n_parents == ctx -> n_containers ) { if ( line -> indent > pivot_line -> indent ) line -> indent -= pivot_line -> indent ; else line -> indent = 0 ; line -> type = MD_LINE_FENCEDCODE ; break ; } } if ( pivot_line -> type == MD_LINE_HTML && ctx -> html_block_type > 0 ) { if ( n_parents < ctx -> n_containers ) { ctx -> html_block_type = 0 ; } else { int html_block_type ; html_block_type = md_is_html_block_end_condition ( ctx , off , & off ) ; if ( html_block_type > 0 ) { MD_ASSERT ( html_block_type == ctx -> html_block_type ) ; ctx -> html_block_type = 0 ; if ( html_block_type == 6 || html_block_type == 7 ) { line -> type = MD_LINE_BLANK ; line -> indent = 0 ; break ; } } line -> type = MD_LINE_HTML ; n_parents = ctx -> n_containers ; break ; } } if ( off >= ctx -> size || ISNEWLINE ( off ) ) { if ( pivot_line -> type == MD_LINE_INDENTEDCODE && n_parents == ctx -> n_containers ) { line -> type = MD_LINE_INDENTEDCODE ; if ( line -> indent > ctx -> code_indent_offset ) line -> indent -= ctx -> code_indent_offset ; else line -> indent = 0 ; ctx -> last_line_has_list_loosening_effect = FALSE ; } else { line -> type = MD_LINE_BLANK ; ctx -> last_line_has_list_loosening_effect = ( n_parents > 0 && n_brothers + n_children == 0 && ctx -> containers [ n_parents - 1 ] . ch != _T ( '>' ) ) ; # if 1 if ( n_parents > 0 && ctx -> containers [ n_parents - 1 ] . ch != _T ( '>' ) && n_brothers + n_children == 0 && ctx -> current_block == NULL && ctx -> n_block_bytes > ( int ) sizeof ( MD_BLOCK ) ) { MD_BLOCK * top_block = ( MD_BLOCK * ) ( ( char * ) ctx -> block_bytes + ctx -> n_block_bytes - sizeof ( MD_BLOCK ) ) ; if ( top_block -> type == MD_BLOCK_LI ) ctx -> last_list_item_starts_with_two_blank_lines = TRUE ; } # endif } break ; } else { # if 1 ctx -> last_line_has_list_loosening_effect = FALSE ; if ( ctx -> last_list_item_starts_with_two_blank_lines ) { if ( n_parents > 0 && ctx -> containers [ n_parents - 1 ] . ch != _T ( '>' ) && n_brothers + n_children == 0 && ctx -> current_block == NULL && ctx -> n_block_bytes > ( int ) sizeof ( MD_BLOCK ) ) { MD_BLOCK * top_block = ( MD_BLOCK * ) ( ( char * ) ctx -> block_bytes + ctx -> n_block_bytes - sizeof ( MD_BLOCK ) ) ; if ( top_block -> type == MD_BLOCK_LI ) n_parents -- ; } ctx -> last_list_item_starts_with_two_blank_lines = FALSE ; } # endif } if ( line -> indent < ctx -> code_indent_offset && pivot_line -> type == MD_LINE_TEXT && ( CH ( off ) == _T ( '=' ) || CH ( off ) == _T ( '-' ) ) && ( n_parents == ctx -> n_containers ) ) { unsigned level ; if ( md_is_setext_underline ( ctx , off , & off , & level ) ) { line -> type = MD_LINE_SETEXTUNDERLINE ; line -> data = level ; break ; } } if ( line -> indent < ctx -> code_indent_offset && ISANYOF ( off , _T ( ""-_*"" ) ) && off >= hr_killer ) { if ( md_is_hr_line ( ctx , off , & off , & hr_killer ) ) { line -> type = MD_LINE_HR ; break ; } } if ( n_parents < ctx -> n_containers && n_brothers + n_children == 0 ) { OFF tmp ; if ( md_is_container_mark ( ctx , line -> indent , off , & tmp , & container ) && md_is_container_compatible ( & ctx -> containers [ n_parents ] , & container ) ) { pivot_line = & md_dummy_blank_line ; off = tmp ; total_indent += container . contents_indent - container . mark_indent ; line -> indent = md_line_indentation ( ctx , total_indent , off , & off ) ; total_indent += line -> indent ; line -> beg = off ; if ( off >= ctx -> size || ISNEWLINE ( off ) ) { container . contents_indent ++ ; } else if ( line -> indent <= ctx -> code_indent_offset ) { container . contents_indent += line -> indent ; line -> indent = 0 ; } else { container . contents_indent += 1 ; line -> indent -- ; } ctx -> containers [ n_parents ] . mark_indent = container . mark_indent ; ctx -> containers [ n_parents ] . contents_indent = container . contents_indent ; n_brothers ++ ; continue ; } } if ( line -> indent >= ctx -> code_indent_offset && ( pivot_line -> type == MD_LINE_BLANK || pivot_line -> type == MD_LINE_INDENTEDCODE ) ) { line -> type = MD_LINE_INDENTEDCODE ; MD_ASSERT ( line -> indent >= ctx -> code_indent_offset ) ; line -> indent -= ctx -> code_indent_offset ; line -> data = 0 ; break ; } if ( line -> indent < ctx -> code_indent_offset && md_is_container_mark ( ctx , line -> indent , off , & off , & container ) ) { if ( pivot_line -> type == MD_LINE_TEXT && n_parents == ctx -> n_containers && ( off >= ctx -> size || ISNEWLINE ( off ) ) && container . ch != _T ( '>' ) ) { } else if ( pivot_line -> type == MD_LINE_TEXT && n_parents == ctx -> n_containers && ( container . ch == _T ( '.' ) || container . ch == _T ( ')' ) ) && container . start != 1 ) { } else { total_indent += container . contents_indent - container . mark_indent ; line -> indent = md_line_indentation ( ctx , total_indent , off , & off ) ; total_indent += line -> indent ; line -> beg = off ; line -> data = container . ch ; if ( off >= ctx -> size || ISNEWLINE ( off ) ) { container . contents_indent ++ ; } else if ( line -> indent <= ctx -> code_indent_offset ) { container . contents_indent += line -> indent ; line -> indent = 0 ; } else { container . contents_indent += 1 ; line -> indent -- ; } if ( n_brothers + n_children == 0 ) pivot_line = & md_dummy_blank_line ; if ( n_children == 0 ) MD_CHECK ( md_leave_child_containers ( ctx , n_parents + n_brothers ) ) ; n_children ++ ; MD_CHECK ( md_push_container ( ctx , & container ) ) ; continue ; } } if ( pivot_line -> type == MD_LINE_TABLE && n_parents == ctx -> n_containers ) { line -> type = MD_LINE_TABLE ; break ; } if ( line -> indent < ctx -> code_indent_offset && CH ( off ) == _T ( '#' ) ) { unsigned level ; if ( md_is_atxheader_line ( ctx , off , & line -> beg , & off , & level ) ) { line -> type = MD_LINE_ATXHEADER ; line -> data = level ; break ; } } if ( CH ( off ) == _T ( '`' ) || CH ( off ) == _T ( '~' ) ) { if ( md_is_opening_code_fence ( ctx , off , & off ) ) { line -> type = MD_LINE_FENCEDCODE ; line -> data = 1 ; break ; } } if ( CH ( off ) == _T ( '<' ) && ! ( ctx -> parser . flags & MD_FLAG_NOHTMLBLOCKS ) ) { ctx -> html_block_type = md_is_html_block_start_condition ( ctx , off ) ; if ( ctx -> html_block_type == 7 && pivot_line -> type == MD_LINE_TEXT ) ctx -> html_block_type = 0 ; if ( ctx -> html_block_type > 0 ) { if ( md_is_html_block_end_condition ( ctx , off , & off ) == ctx -> html_block_type ) { ctx -> html_block_type = 0 ; } line -> type = MD_LINE_HTML ; break ; } } if ( ( ctx -> parser . flags & MD_FLAG_TABLES ) && pivot_line -> type == MD_LINE_TEXT && ( CH ( off ) == _T ( '|' ) || CH ( off ) == _T ( '-' ) || CH ( off ) == _T ( ':' ) ) && n_parents == ctx -> n_containers ) { unsigned col_count ; if ( ctx -> current_block != NULL && ctx -> current_block -> n_lines == 1 && md_is_table_underline ( ctx , off , & off , & col_count ) ) { line -> data = col_count ; line -> type = MD_LINE_TABLEUNDERLINE ; break ; } } line -> type = MD_LINE_TEXT ; if ( pivot_line -> type == MD_LINE_TEXT && n_brothers + n_children == 0 ) { n_parents = ctx -> n_containers ; } if ( ( ctx -> parser . flags & MD_FLAG_TASKLISTS ) && n_brothers + n_children > 0 && ISANYOF_ ( ctx -> containers [ ctx -> n_containers - 1 ] . ch , _T ( ""-+*.)"" ) ) ) { OFF tmp = off ; while ( tmp < ctx -> size && tmp < off + 3 && ISBLANK ( tmp ) ) tmp ++ ; if ( tmp + 2 < ctx -> size && CH ( tmp ) == _T ( '[' ) && ISANYOF ( tmp + 1 , _T ( ""xX"" ) ) && CH ( tmp + 2 ) == _T ( ']' ) && ( tmp + 3 == ctx -> size || ISBLANK ( tmp + 3 ) || ISNEWLINE ( tmp + 3 ) ) ) { MD_CONTAINER * task_container = ( n_children > 0 ? & ctx -> containers [ ctx -> n_containers - 1 ] : & container ) ; task_container -> is_task = TRUE ; task_container -> task_mark_off = tmp + 1 ; off = tmp + 3 ; while ( ISWHITESPACE ( off ) ) off ++ ; line -> beg = off ; } } break ; } # if defined __linux__ && ! defined MD4C_USE_UTF16 if ( ctx -> doc_ends_with_newline && off < ctx -> size ) { while ( TRUE ) { off += ( OFF ) strcspn ( STR ( off ) , ""\\r\\n"" ) ; if ( CH ( off ) == _T ( '\\0' ) ) off ++ ; else break ; } } else # endif { while ( off + 3 < ctx -> size && ! ISNEWLINE ( off + 0 ) && ! ISNEWLINE ( off + 1 ) && ! ISNEWLINE ( off + 2 ) && ! ISNEWLINE ( off + 3 ) ) off += 4 ; while ( off < ctx -> size && ! ISNEWLINE ( off ) ) off ++ ; } line -> end = off ; if ( line -> type == MD_LINE_ATXHEADER ) { OFF tmp = line -> end ; while ( tmp > line -> beg && CH ( tmp - 1 ) == _T ( '' ) ) tmp -- ; while ( tmp > line -> beg && CH ( tmp - 1 ) == _T ( '#' ) ) tmp -- ; if ( tmp == line -> beg || CH ( tmp - 1 ) == _T ( '' ) || ( ctx -> parser . flags & MD_FLAG_PERMISSIVEATXHEADERS ) ) line -> end = tmp ; } if ( line -> type != MD_LINE_INDENTEDCODE && line -> type != MD_LINE_FENCEDCODE ) { while ( line -> end > line -> beg && CH ( line -> end - 1 ) == _T ( '' ) ) line -> end -- ; } if ( off < ctx -> size && CH ( off ) == _T ( '\\r' ) ) off ++ ; if ( off < ctx -> size && CH ( off ) == _T ( '\\n' ) ) off ++ ; * p_end = off ; if ( prev_line_has_list_loosening_effect && line -> type != MD_LINE_BLANK && n_parents + n_brothers > 0 ) { MD_CONTAINER * c = & ctx -> containers [ n_parents + n_brothers - 1 ] ; if ( c -> ch != _T ( '>' ) ) { MD_BLOCK * block = ( MD_BLOCK * ) ( ( ( char * ) ctx -> block_bytes ) + c -> block_byte_off ) ; block -> flags |= MD_BLOCK_LOOSE_LIST ; } } if ( n_children == 0 && n_parents + n_brothers < ctx -> n_containers ) MD_CHECK ( md_leave_child_containers ( ctx , n_parents + n_brothers ) ) ; if ( n_brothers > 0 ) { MD_ASSERT ( n_brothers == 1 ) ; MD_CHECK ( md_push_container_bytes ( ctx , MD_BLOCK_LI , ctx -> containers [ n_parents ] . task_mark_off , ( ctx -> containers [ n_parents ] . is_task ? CH ( ctx -> containers [ n_parents ] . task_mark_off ) : 0 ) , MD_BLOCK_CONTAINER_CLOSER ) ) ; MD_CHECK ( md_push_container_bytes ( ctx , MD_BLOCK_LI , container . task_mark_off , ( container . is_task ? CH ( container . task_mark_off ) : 0 ) , MD_BLOCK_CONTAINER_OPENER ) ) ; ctx -> containers [ n_parents ] . is_task = container . is_task ; ctx -> containers [ n_parents ] . task_mark_off = container . task_mark_off ; } if ( n_children > 0 ) MD_CHECK ( md_enter_child_containers ( ctx , n_children ) ) ; abort : return ret ; } "," == MD_LINE_TEXT && off < ctx -> size && ISANYOF2 ( off , _T ( '=' ( '=' ) , _T ( '-' ctx -> code_indent_offset && off < ctx -> size && off >= off >= hr_killer && ISANYOF ( off , _T ( ""-_*"" ) ) ) { if ( -> n_containers && ISANYOF2_ container . ch , _T ( '.' ( '.' ) , _T ( ')' -> code_indent_offset && off < ctx -> size && } if ( off < ctx -> size && ISANYOF2 ( off , _T ( '`' ) , _T ( '~' ) ) ) { if ( md_is_opening_code_fence ( ctx , off , & off ) ) { line -> type = MD_LINE_FENCEDCODE ; line -> data = 1 ; break ; } } if ( off < ctx -> size && == _T ( '<' ) && type == MD_LINE_TEXT && off < ctx -> size && ISANYOF3 ( off , _T ( '|' ( '|' ) , _T ( '-' ( '-' ) , _T ( ':' ':' ) ) && n_parents == ctx ",mity@md4c/4fc808d8fe8d8904f8525bb4231d854f45e23a19,CVE-2021-30027,https://github.com/mity/md4c/commit/4fc808d8fe8d8904f8525bb4231d854f45e23a19,2021-04-29T15:15Z 728,CWE-125,"CWE-125 static Image * ReadSUNImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define RMT_EQUAL_RGB 1 # define RMT_NONE 0 # define RMT_RAW 2 # define RT_STANDARD 1 # define RT_ENCODED 2 # define RT_FORMAT_RGB 3 typedef struct _SUNInfo { unsigned int magic , width , height , depth , length , type , maptype , maplength ; } SUNInfo ; Image * image ; int bit ; MagickBooleanType status ; MagickSizeType number_pixels ; register Quantum * q ; register ssize_t i , x ; register unsigned char * p ; size_t bytes_per_line , extent , height , length ; ssize_t count , y ; SUNInfo sun_info ; unsigned char * sun_data , * sun_pixels ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } ( void ) ResetMagickMemory ( & sun_info , 0 , sizeof ( sun_info ) ) ; sun_info . magic = ReadBlobMSBLong ( image ) ; do { if ( sun_info . magic != 0x59a66a95 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; sun_info . width = ReadBlobMSBLong ( image ) ; sun_info . height = ReadBlobMSBLong ( image ) ; sun_info . depth = ReadBlobMSBLong ( image ) ; sun_info . length = ReadBlobMSBLong ( image ) ; sun_info . type = ReadBlobMSBLong ( image ) ; sun_info . maptype = ReadBlobMSBLong ( image ) ; sun_info . maplength = ReadBlobMSBLong ( image ) ; extent = sun_info . height * sun_info . width ; if ( ( sun_info . height != 0 ) && ( sun_info . width != extent / sun_info . height ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ( sun_info . type != RT_STANDARD ) && ( sun_info . type != RT_ENCODED ) && ( sun_info . type != RT_FORMAT_RGB ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ( sun_info . maptype == RMT_NONE ) && ( sun_info . maplength != 0 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ( sun_info . depth == 0 ) || ( sun_info . depth > 32 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ( sun_info . maptype != RMT_NONE ) && ( sun_info . maptype != RMT_EQUAL_RGB ) && ( sun_info . maptype != RMT_RAW ) ) ThrowReaderException ( CoderError , ""ColormapTypeNotSupported"" ) ; image -> columns = sun_info . width ; image -> rows = sun_info . height ; image -> depth = sun_info . depth <= 8 ? sun_info . depth : MAGICKCORE_QUANTUM_DEPTH ; if ( sun_info . depth < 24 ) { size_t one ; image -> colors = sun_info . maplength ; one = 1 ; if ( sun_info . maptype == RMT_NONE ) image -> colors = one << sun_info . depth ; if ( sun_info . maptype == RMT_EQUAL_RGB ) image -> colors = sun_info . maplength / 3 ; if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; } switch ( sun_info . maptype ) { case RMT_NONE : break ; case RMT_EQUAL_RGB : { unsigned char * sun_colormap ; sun_colormap = ( unsigned char * ) AcquireQuantumMemory ( image -> colors , sizeof ( * sun_colormap ) ) ; if ( sun_colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; count = ReadBlob ( image , image -> colors , sun_colormap ) ; if ( count != ( ssize_t ) image -> colors ) ThrowReaderException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) image -> colormap [ i ] . red = ( MagickRealType ) ScaleCharToQuantum ( sun_colormap [ i ] ) ; count = ReadBlob ( image , image -> colors , sun_colormap ) ; if ( count != ( ssize_t ) image -> colors ) ThrowReaderException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) image -> colormap [ i ] . green = ( MagickRealType ) ScaleCharToQuantum ( sun_colormap [ i ] ) ; count = ReadBlob ( image , image -> colors , sun_colormap ) ; if ( count != ( ssize_t ) image -> colors ) ThrowReaderException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) image -> colormap [ i ] . blue = ( MagickRealType ) ScaleCharToQuantum ( sun_colormap [ i ] ) ; sun_colormap = ( unsigned char * ) RelinquishMagickMemory ( sun_colormap ) ; break ; } case RMT_RAW : { unsigned char * sun_colormap ; sun_colormap = ( unsigned char * ) AcquireQuantumMemory ( sun_info . maplength , sizeof ( * sun_colormap ) ) ; if ( sun_colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; count = ReadBlob ( image , sun_info . maplength , sun_colormap ) ; if ( count != ( ssize_t ) sun_info . maplength ) ThrowReaderException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; sun_colormap = ( unsigned char * ) RelinquishMagickMemory ( sun_colormap ) ; break ; } default : ThrowReaderException ( CoderError , ""ColormapTypeNotSupported"" ) ; } image -> alpha_trait = sun_info . depth == 32 ? BlendPixelTrait : UndefinedPixelTrait ; image -> columns = sun_info . width ; image -> rows = sun_info . height ; if ( image_info -> ping != MagickFalse ) { ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; if ( ( sun_info . length * sizeof ( * sun_data ) ) / sizeof ( * sun_data ) != sun_info . length || ! sun_info . length ) ThrowReaderException ( ResourceLimitError , ""ImproperImageHeader"" ) ; number_pixels = ( MagickSizeType ) image -> columns * image -> rows ; if ( ( sun_info . type != RT_ENCODED ) && ( ( number_pixels * sun_info . depth ) > ( 8 * sun_info . length ) ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; bytes_per_line = sun_info . width * sun_info . depth ; sun_data = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) MagickMax ( sun_info . length , bytes_per_line * sun_info . width ) , sizeof ( * sun_data ) ) ; if ( sun_data == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; count = ( ssize_t ) ReadBlob ( image , sun_info . length , sun_data ) ; if ( count != ( ssize_t ) sun_info . length ) ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; height = sun_info . height ; if ( ( height == 0 ) || ( sun_info . width == 0 ) || ( sun_info . depth == 0 ) || ( ( bytes_per_line / sun_info . depth ) != sun_info . width ) ) ThrowReaderException ( ResourceLimitError , ""ImproperImageHeader"" ) ; bytes_per_line += 15 ; bytes_per_line <<= 1 ; if ( ( bytes_per_line >> 1 ) != ( sun_info . width * sun_info . depth + 15 ) ) ThrowReaderException ( ResourceLimitError , ""ImproperImageHeader"" ) ; bytes_per_line >>= 4 ; sun_pixels = ( unsigned char * ) AcquireQuantumMemory ( height , bytes_per_line * sizeof ( * sun_pixels ) ) ; if ( sun_pixels == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; if ( sun_info . type == RT_ENCODED ) ( void ) DecodeImage ( sun_data , sun_info . length , sun_pixels , bytes_per_line * height ) ; else { if ( sun_info . length > ( height * bytes_per_line ) ) ThrowReaderException ( ResourceLimitError , ""ImproperImageHeader"" ) ; ( void ) CopyMagickMemory ( sun_pixels , sun_data , sun_info . length ) ; } sun_data = ( unsigned char * ) RelinquishMagickMemory ( sun_data ) ; p = sun_pixels ; if ( sun_info . depth == 1 ) for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ( ssize_t ) image -> columns - 7 ) ; x += 8 ) { for ( bit = 7 ; bit >= 0 ; bit -- ) { SetPixelIndex ( image , ( Quantum ) ( ( * p ) & ( 0x01 << bit ) ? 0x00 : 0x01 ) , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } if ( ( image -> columns % 8 ) != 0 ) { for ( bit = 7 ; bit >= ( int ) ( 8 - ( image -> columns % 8 ) ) ; bit -- ) { SetPixelIndex ( image , ( Quantum ) ( ( * p ) & ( 0x01 << bit ) ? 0x00 : 0x01 ) , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } if ( ( ( ( image -> columns / 8 ) + ( image -> columns % 8 ? 1 : 0 ) ) % 2 ) != 0 ) p ++ ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } else if ( image -> storage_class == PseudoClass ) { if ( bytes_per_line == 0 ) bytes_per_line = image -> columns ; length = image -> rows * ( image -> columns + image -> columns % 2 ) ; if ( ( ( sun_info . type == RT_ENCODED ) && ( length > ( bytes_per_line * image -> rows ) ) ) || ( ( sun_info . type != RT_ENCODED ) && ( length > sun_info . length ) ) ) ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelIndex ( image , * p ++ , q ) ; q += GetPixelChannels ( image ) ; } if ( ( image -> columns % 2 ) != 0 ) p ++ ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } else { size_t bytes_per_pixel ; bytes_per_pixel = 3 ; if ( image -> alpha_trait != UndefinedPixelTrait ) bytes_per_pixel ++ ; if ( bytes_per_line == 0 ) bytes_per_line = bytes_per_pixel * image -> columns ; length = image -> rows * ( bytes_per_line + bytes_per_line % 2 ) ; if ( ( ( sun_info . type == RT_ENCODED ) && ( length > ( bytes_per_line * image -> rows ) ) ) || ( ( sun_info . type != RT_ENCODED ) && ( length > sun_info . length ) ) ) ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { if ( image -> alpha_trait != UndefinedPixelTrait ) SetPixelAlpha ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; if ( sun_info . type == RT_STANDARD ) { SetPixelBlue ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelGreen ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelRed ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; } else { SetPixelRed ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelGreen ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelBlue ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; } if ( image -> colors != 0 ) { SetPixelRed ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) GetPixelRed ( image , q ) ] . red ) , q ) ; SetPixelGreen ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) GetPixelGreen ( image , q ) ] . green ) , q ) ; SetPixelBlue ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) GetPixelBlue ( image , q ) ] . blue ) , q ) ; } q += GetPixelChannels ( image ) ; } if ( ( ( bytes_per_pixel * image -> columns ) % 2 ) != 0 ) p ++ ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } if ( image -> storage_class == PseudoClass ) ( void ) SyncImage ( image , exception ) ; sun_pixels = ( unsigned char * ) RelinquishMagickMemory ( sun_pixels ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; sun_info . magic = ReadBlobMSBLong ( image ) ; if ( sun_info . magic == 0x59a66a95 ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( sun_info . magic == 0x59a66a95 ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," extent , height ; ssize_t count PseudoClass ) { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns image -> columns ; x ++ ) { SetPixelIndex ( image , * p ++ , q ) ; q += GetPixelChannels ( image ) ; } if ( ( image -> columns % 2 ) != 0 ) p ++ ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } else { size_t bytes_per_pixel ; bytes_per_pixel = 3 ; if ( image -> alpha_trait != UndefinedPixelTrait ) bytes_per_pixel ++ ; if ( bytes_per_line == 0 ) bytes_per_line = bytes_per_pixel * image -> columns ; for ( ++ ) { if ( image -> alpha_trait != UndefinedPixelTrait ) SetPixelAlpha ( image , ScaleCharToQuantum ( * p ++ * p ++ ) q ) ; if ( sun_info . type == RT_STANDARD ) { SetPixelBlue ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelGreen ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelRed ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; } else { SetPixelRed ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelGreen ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelBlue ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; } if ( image -> colors != 0 ) { SetPixelRed ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) GetPixelRed ( image , q ) ] . red ) , q ) ; SetPixelGreen ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) GetPixelGreen ( image , q ) ] . green ) , q ) ; SetPixelBlue ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) GetPixelBlue ( image , q ) ] . blue ) , q ) ; } if ( ( ( bytes_per_pixel * ",ImageMagick@ImageMagick/8ea44b48a182dd46d018f4b4f09a5e2ee9638105,CVE-2015-8958,https://github.com/ImageMagick/ImageMagick/commit/8ea44b48a182dd46d018f4b4f09a5e2ee9638105,2017-04-20T18:59Z 729,CWE-295,"CWE-295 static krb5_error_code tgs_make_reply ( krb5_context context , krb5_kdc_configuration * config , KDC_REQ_BODY * b , krb5_const_principal tgt_name , const EncTicketPart * tgt , const krb5_keyblock * replykey , int rk_is_subkey , const EncryptionKey * serverkey , const krb5_keyblock * sessionkey , krb5_kvno kvno , AuthorizationData * auth_data , hdb_entry_ex * server , krb5_principal server_principal , const char * server_name , hdb_entry_ex * client , krb5_principal client_principal , hdb_entry_ex * krbtgt , krb5_enctype krbtgt_etype , krb5_principals spp , const krb5_data * rspac , const METHOD_DATA * enc_pa_data , const char * * e_text , krb5_data * reply ) { KDC_REP rep ; EncKDCRepPart ek ; EncTicketPart et ; KDCOptions f = b -> kdc_options ; krb5_error_code ret ; int is_weak = 0 ; memset ( & rep , 0 , sizeof ( rep ) ) ; memset ( & et , 0 , sizeof ( et ) ) ; memset ( & ek , 0 , sizeof ( ek ) ) ; rep . pvno = 5 ; rep . msg_type = krb_tgs_rep ; et . authtime = tgt -> authtime ; _kdc_fix_time ( & b -> till ) ; et . endtime = min ( tgt -> endtime , * b -> till ) ; ALLOC ( et . starttime ) ; * et . starttime = kdc_time ; ret = check_tgs_flags ( context , config , b , tgt , & et ) ; if ( ret ) goto out ; # define GLOBAL_FORCE_TRANSITED_CHECK ( config -> trpolicy == TRPOLICY_ALWAYS_CHECK ) # define GLOBAL_ALLOW_PER_PRINCIPAL ( config -> trpolicy == TRPOLICY_ALLOW_PER_PRINCIPAL ) # define GLOBAL_ALLOW_DISABLE_TRANSITED_CHECK ( config -> trpolicy == TRPOLICY_ALWAYS_HONOUR_REQUEST ) # define PRINCIPAL_FORCE_TRANSITED_CHECK ( P ) 0 # define PRINCIPAL_ALLOW_DISABLE_TRANSITED_CHECK ( P ) 0 ret = fix_transited_encoding ( context , config , ! f . disable_transited_check || GLOBAL_FORCE_TRANSITED_CHECK || PRINCIPAL_FORCE_TRANSITED_CHECK ( server ) || ! ( ( GLOBAL_ALLOW_PER_PRINCIPAL && PRINCIPAL_ALLOW_DISABLE_TRANSITED_CHECK ( server ) ) || GLOBAL_ALLOW_DISABLE_TRANSITED_CHECK ) , & tgt -> transited , & et , krb5_principal_get_realm ( context , client_principal ) , krb5_principal_get_realm ( context , server -> entry . principal ) , krb5_principal_get_realm ( context , krbtgt -> entry . principal ) ) ; if ( ret ) goto out ; copy_Realm ( & server_principal -> realm , & rep . ticket . realm ) ; _krb5_principal2principalname ( & rep . ticket . sname , server_principal ) ; copy_Realm ( & tgt_name -> realm , & rep . crealm ) ; copy_PrincipalName ( & tgt_name -> name , & rep . cname ) ; rep . ticket . tkt_vno = 5 ; ek . caddr = et . caddr ; { time_t life ; life = et . endtime - * et . starttime ; if ( client && client -> entry . max_life ) life = min ( life , * client -> entry . max_life ) ; if ( server -> entry . max_life ) life = min ( life , * server -> entry . max_life ) ; et . endtime = * et . starttime + life ; } if ( f . renewable_ok && tgt -> flags . renewable && et . renew_till == NULL && et . endtime < * b -> till && tgt -> renew_till != NULL ) { et . flags . renewable = 1 ; ALLOC ( et . renew_till ) ; * et . renew_till = * b -> till ; } if ( et . renew_till ) { time_t renew ; renew = * et . renew_till - * et . starttime ; if ( client && client -> entry . max_renew ) renew = min ( renew , * client -> entry . max_renew ) ; if ( server -> entry . max_renew ) renew = min ( renew , * server -> entry . max_renew ) ; * et . renew_till = * et . starttime + renew ; } if ( et . renew_till ) { * et . renew_till = min ( * et . renew_till , * tgt -> renew_till ) ; * et . starttime = min ( * et . starttime , * et . renew_till ) ; et . endtime = min ( et . endtime , * et . renew_till ) ; } * et . starttime = min ( * et . starttime , et . endtime ) ; if ( * et . starttime == et . endtime ) { ret = KRB5KDC_ERR_NEVER_VALID ; goto out ; } if ( et . renew_till && et . endtime == * et . renew_till ) { free ( et . renew_till ) ; et . renew_till = NULL ; et . flags . renewable = 0 ; } et . flags . pre_authent = tgt -> flags . pre_authent ; et . flags . hw_authent = tgt -> flags . hw_authent ; et . flags . anonymous = tgt -> flags . anonymous ; et . flags . ok_as_delegate = server -> entry . flags . ok_as_delegate ; if ( rspac -> length ) { ret = _kdc_tkt_add_if_relevant_ad ( context , & et , KRB5_AUTHDATA_WIN2K_PAC , rspac ) ; if ( ret ) goto out ; } if ( auth_data ) { unsigned int i = 0 ; if ( et . authorization_data == NULL ) { et . authorization_data = calloc ( 1 , sizeof ( * et . authorization_data ) ) ; if ( et . authorization_data == NULL ) { ret = ENOMEM ; krb5_set_error_message ( context , ret , ""malloc:outofmemory"" ) ; goto out ; } } for ( i = 0 ; i < auth_data -> len ; i ++ ) { ret = add_AuthorizationData ( et . authorization_data , & auth_data -> val [ i ] ) ; if ( ret ) { krb5_set_error_message ( context , ret , ""malloc:outofmemory"" ) ; goto out ; } } ret = find_KRB5SignedPath ( context , et . authorization_data , NULL ) ; if ( ret == 0 ) { if ( et . authorization_data -> len == 1 ) { free_AuthorizationData ( et . authorization_data ) ; free ( et . authorization_data ) ; et . authorization_data = NULL ; } else { AuthorizationData * ad = et . authorization_data ; free_AuthorizationDataElement ( & ad -> val [ ad -> len - 1 ] ) ; ad -> len -- ; } } } ret = krb5_copy_keyblock_contents ( context , sessionkey , & et . key ) ; if ( ret ) goto out ; et . crealm = tgt_name -> realm ; et . cname = tgt_name -> name ; ek . key = et . key ; ek . last_req . val = calloc ( 1 , sizeof ( * ek . last_req . val ) ) ; if ( ek . last_req . val == NULL ) { ret = ENOMEM ; goto out ; } ek . last_req . len = 1 ; ek . nonce = b -> nonce ; ek . flags = et . flags ; ek . authtime = et . authtime ; ek . starttime = et . starttime ; ek . endtime = et . endtime ; ek . renew_till = et . renew_till ; ek . srealm = rep . ticket . realm ; ek . sname = rep . ticket . sname ; _kdc_log_timestamp ( context , config , ""TGS-REQ"" , et . authtime , et . starttime , et . endtime , et . renew_till ) ; { char * r = get_krbtgt_realm ( & ek . sname ) ; if ( r == NULL || strcmp ( r , ek . srealm ) == 0 ) { ret = _kdc_add_KRB5SignedPath ( context , config , krbtgt , krbtgt_etype , client_principal , NULL , spp , & et ) ; if ( ret ) goto out ; } } if ( enc_pa_data -> len ) { rep . padata = calloc ( 1 , sizeof ( * rep . padata ) ) ; if ( rep . padata == NULL ) { ret = ENOMEM ; goto out ; } ret = copy_METHOD_DATA ( enc_pa_data , rep . padata ) ; if ( ret ) goto out ; } if ( krb5_enctype_valid ( context , serverkey -> keytype ) != 0 && _kdc_is_weak_exception ( server -> entry . principal , serverkey -> keytype ) ) { krb5_enctype_enable ( context , serverkey -> keytype ) ; is_weak = 1 ; } ret = _kdc_encode_reply ( context , config , NULL , 0 , & rep , & et , & ek , serverkey -> keytype , kvno , serverkey , 0 , replykey , rk_is_subkey , e_text , reply ) ; if ( is_weak ) krb5_enctype_disable ( context , serverkey -> keytype ) ; out : free_TGS_REP ( & rep ) ; free_TransitedEncoding ( & et . transited ) ; if ( et . starttime ) free ( et . starttime ) ; if ( et . renew_till ) free ( et . renew_till ) ; if ( et . authorization_data ) { free_AuthorizationData ( et . authorization_data ) ; free ( et . authorization_data ) ; } free_LastReq ( & ek . last_req ) ; memset ( et . key . keyvalue . data , 0 , et . key . keyvalue . length ) ; free_EncryptionKey ( & et . key ) ; return ret ; } "," , krb5_principal client_principal , const char * tgt_realm principal ) , tgt_realm ) ; if ",heimdal@heimdal/b1e699103f08d6a0ca46a122193c9da65f6cf837,CVE-2017-6594,https://github.com/heimdal/heimdal/commit/b1e699103f08d6a0ca46a122193c9da65f6cf837,2017-08-28T19:29Z 730,CWE-835,"CWE-835 static Image * ReadBMPImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { BMPInfo bmp_info ; Image * image ; MagickBooleanType status ; MagickOffsetType offset , start_position ; MemoryInfo * pixel_info ; Quantum index ; register Quantum * q ; register ssize_t i , x ; register unsigned char * p ; size_t bit , bytes_per_line , length ; ssize_t count , y ; unsigned char magick [ 12 ] , * pixels ; unsigned int blue , green , offset_bits , red ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } ( void ) memset ( & bmp_info , 0 , sizeof ( bmp_info ) ) ; bmp_info . ba_offset = 0 ; start_position = 0 ; offset_bits = 0 ; count = ReadBlob ( image , 2 , magick ) ; if ( count != 2 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; do { PixelInfo quantum_bits ; PixelPacket shift ; start_position = TellBlob ( image ) - 2 ; bmp_info . ba_offset = 0 ; while ( LocaleNCompare ( ( char * ) magick , ""BA"" , 2 ) == 0 ) { bmp_info . file_size = ReadBlobLSBLong ( image ) ; bmp_info . ba_offset = ReadBlobLSBLong ( image ) ; bmp_info . offset_bits = ReadBlobLSBLong ( image ) ; count = ReadBlob ( image , 2 , magick ) ; if ( count != 2 ) break ; } if ( image -> debug != MagickFalse ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""Magick:%c%c"" , magick [ 0 ] , magick [ 1 ] ) ; if ( ( count != 2 ) || ( ( LocaleNCompare ( ( char * ) magick , ""BM"" , 2 ) != 0 ) && ( LocaleNCompare ( ( char * ) magick , ""CI"" , 2 ) != 0 ) ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; bmp_info . file_size = ReadBlobLSBLong ( image ) ; ( void ) ReadBlobLSBLong ( image ) ; bmp_info . offset_bits = ReadBlobLSBLong ( image ) ; bmp_info . size = ReadBlobLSBLong ( image ) ; if ( image -> debug != MagickFalse ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""BMPsize:%u"" , bmp_info . size ) ; if ( bmp_info . size == 12 ) { ( void ) CopyMagickString ( image -> magick , ""BMP2"" , MagickPathExtent ) ; bmp_info . width = ( ssize_t ) ( ( short ) ReadBlobLSBShort ( image ) ) ; bmp_info . height = ( ssize_t ) ( ( short ) ReadBlobLSBShort ( image ) ) ; bmp_info . planes = ReadBlobLSBShort ( image ) ; bmp_info . bits_per_pixel = ReadBlobLSBShort ( image ) ; bmp_info . x_pixels = 0 ; bmp_info . y_pixels = 0 ; bmp_info . number_colors = 0 ; bmp_info . compression = BI_RGB ; bmp_info . image_size = 0 ; bmp_info . alpha_mask = 0 ; if ( image -> debug != MagickFalse ) { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""Format:OS/2Bitmap"" ) ; ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""Geometry:%.20gx%.20g"" , ( double ) bmp_info . width , ( double ) bmp_info . height ) ; } } else { if ( bmp_info . size < 40 ) ThrowReaderException ( CorruptImageError , ""NonOS2HeaderSizeError"" ) ; bmp_info . width = ( ssize_t ) ReadBlobLSBSignedLong ( image ) ; bmp_info . height = ( ssize_t ) ReadBlobLSBSignedLong ( image ) ; bmp_info . planes = ReadBlobLSBShort ( image ) ; bmp_info . bits_per_pixel = ReadBlobLSBShort ( image ) ; bmp_info . compression = ReadBlobLSBLong ( image ) ; bmp_info . image_size = ReadBlobLSBLong ( image ) ; bmp_info . x_pixels = ReadBlobLSBLong ( image ) ; bmp_info . y_pixels = ReadBlobLSBLong ( image ) ; bmp_info . number_colors = ReadBlobLSBLong ( image ) ; if ( bmp_info . number_colors > GetBlobSize ( image ) ) ThrowReaderException ( CorruptImageError , ""InsufficientImageDataInFile"" ) ; bmp_info . colors_important = ReadBlobLSBLong ( image ) ; if ( image -> debug != MagickFalse ) { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""Format:MSWindowsbitmap"" ) ; ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""Geometry:%.20gx%.20g"" , ( double ) bmp_info . width , ( double ) bmp_info . height ) ; ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""Bitsperpixel:%.20g"" , ( double ) bmp_info . bits_per_pixel ) ; switch ( bmp_info . compression ) { case BI_RGB : { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""Compression:BI_RGB"" ) ; break ; } case BI_RLE4 : { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""Compression:BI_RLE4"" ) ; break ; } case BI_RLE8 : { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""Compression:BI_RLE8"" ) ; break ; } case BI_BITFIELDS : { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""Compression:BI_BITFIELDS"" ) ; break ; } case BI_PNG : { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""Compression:BI_PNG"" ) ; break ; } case BI_JPEG : { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""Compression:BI_JPEG"" ) ; break ; } default : { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""Compression:UNKNOWN(%u)"" , bmp_info . compression ) ; } } ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""Numberofcolors:%u"" , bmp_info . number_colors ) ; } bmp_info . red_mask = ReadBlobLSBLong ( image ) ; bmp_info . green_mask = ReadBlobLSBLong ( image ) ; bmp_info . blue_mask = ReadBlobLSBLong ( image ) ; if ( bmp_info . size > 40 ) { double gamma ; bmp_info . alpha_mask = ReadBlobLSBLong ( image ) ; bmp_info . colorspace = ReadBlobLSBSignedLong ( image ) ; # define BMP_DENOM ( ( double ) 0x40000000 ) bmp_info . red_primary . x = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . red_primary . y = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . red_primary . z = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . green_primary . x = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . green_primary . y = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . green_primary . z = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . blue_primary . x = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . blue_primary . y = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; bmp_info . blue_primary . z = ( double ) ReadBlobLSBLong ( image ) / BMP_DENOM ; gamma = bmp_info . red_primary . x + bmp_info . red_primary . y + bmp_info . red_primary . z ; gamma = PerceptibleReciprocal ( gamma ) ; bmp_info . red_primary . x *= gamma ; bmp_info . red_primary . y *= gamma ; image -> chromaticity . red_primary . x = bmp_info . red_primary . x ; image -> chromaticity . red_primary . y = bmp_info . red_primary . y ; gamma = bmp_info . green_primary . x + bmp_info . green_primary . y + bmp_info . green_primary . z ; gamma = PerceptibleReciprocal ( gamma ) ; bmp_info . green_primary . x *= gamma ; bmp_info . green_primary . y *= gamma ; image -> chromaticity . green_primary . x = bmp_info . green_primary . x ; image -> chromaticity . green_primary . y = bmp_info . green_primary . y ; gamma = bmp_info . blue_primary . x + bmp_info . blue_primary . y + bmp_info . blue_primary . z ; gamma = PerceptibleReciprocal ( gamma ) ; bmp_info . blue_primary . x *= gamma ; bmp_info . blue_primary . y *= gamma ; image -> chromaticity . blue_primary . x = bmp_info . blue_primary . x ; image -> chromaticity . blue_primary . y = bmp_info . blue_primary . y ; bmp_info . gamma_scale . x = ( double ) ReadBlobLSBLong ( image ) / 0x10000 ; bmp_info . gamma_scale . y = ( double ) ReadBlobLSBLong ( image ) / 0x10000 ; bmp_info . gamma_scale . z = ( double ) ReadBlobLSBLong ( image ) / 0x10000 ; image -> gamma = ( bmp_info . gamma_scale . x + bmp_info . gamma_scale . y + bmp_info . gamma_scale . z ) / 3.0 ; } else ( void ) CopyMagickString ( image -> magick , ""BMP3"" , MagickPathExtent ) ; if ( bmp_info . size > 108 ) { size_t intent ; intent = ReadBlobLSBLong ( image ) ; switch ( ( int ) intent ) { case LCS_GM_BUSINESS : { image -> rendering_intent = SaturationIntent ; break ; } case LCS_GM_GRAPHICS : { image -> rendering_intent = RelativeIntent ; break ; } case LCS_GM_IMAGES : { image -> rendering_intent = PerceptualIntent ; break ; } case LCS_GM_ABS_COLORIMETRIC : { image -> rendering_intent = AbsoluteIntent ; break ; } } ( void ) ReadBlobLSBLong ( image ) ; ( void ) ReadBlobLSBLong ( image ) ; ( void ) ReadBlobLSBLong ( image ) ; } } if ( ( MagickSizeType ) bmp_info . file_size > GetBlobSize ( image ) ) ( void ) ThrowMagickException ( exception , GetMagickModule ( ) , CorruptImageError , ""LengthAndFilesizeDoNotMatch"" , ""`%s\'"" , image -> filename ) ; else if ( ( MagickSizeType ) bmp_info . file_size < GetBlobSize ( image ) ) ( void ) ThrowMagickException ( exception , GetMagickModule ( ) , CorruptImageWarning , ""LengthAndFilesizeDoNotMatch"" , ""`%s\'"" , image -> filename ) ; if ( bmp_info . width <= 0 ) ThrowReaderException ( CorruptImageError , ""NegativeOrZeroImageSize"" ) ; if ( bmp_info . height == 0 ) ThrowReaderException ( CorruptImageError , ""NegativeOrZeroImageSize"" ) ; if ( bmp_info . planes != 1 ) ThrowReaderException ( CorruptImageError , ""StaticPlanesValueNotEqualToOne"" ) ; if ( ( bmp_info . bits_per_pixel != 1 ) && ( bmp_info . bits_per_pixel != 4 ) && ( bmp_info . bits_per_pixel != 8 ) && ( bmp_info . bits_per_pixel != 16 ) && ( bmp_info . bits_per_pixel != 24 ) && ( bmp_info . bits_per_pixel != 32 ) ) ThrowReaderException ( CorruptImageError , ""UnrecognizedBitsPerPixel"" ) ; if ( bmp_info . bits_per_pixel < 16 && bmp_info . number_colors > ( 1U << bmp_info . bits_per_pixel ) ) ThrowReaderException ( CorruptImageError , ""UnrecognizedNumberOfColors"" ) ; if ( ( bmp_info . compression == 1 ) && ( bmp_info . bits_per_pixel != 8 ) ) ThrowReaderException ( CorruptImageError , ""UnrecognizedBitsPerPixel"" ) ; if ( ( bmp_info . compression == 2 ) && ( bmp_info . bits_per_pixel != 4 ) ) ThrowReaderException ( CorruptImageError , ""UnrecognizedBitsPerPixel"" ) ; if ( ( bmp_info . compression == 3 ) && ( bmp_info . bits_per_pixel < 16 ) ) ThrowReaderException ( CorruptImageError , ""UnrecognizedBitsPerPixel"" ) ; switch ( bmp_info . compression ) { case BI_RGB : image -> compression = NoCompression ; break ; case BI_RLE8 : case BI_RLE4 : image -> compression = RLECompression ; break ; case BI_BITFIELDS : break ; case BI_JPEG : ThrowReaderException ( CoderError , ""JPEGCompressNotSupported"" ) ; case BI_PNG : ThrowReaderException ( CoderError , ""PNGCompressNotSupported"" ) ; default : ThrowReaderException ( CorruptImageError , ""UnrecognizedImageCompression"" ) ; } image -> columns = ( size_t ) MagickAbsoluteValue ( bmp_info . width ) ; image -> rows = ( size_t ) MagickAbsoluteValue ( bmp_info . height ) ; image -> depth = bmp_info . bits_per_pixel <= 8 ? bmp_info . bits_per_pixel : 8 ; image -> alpha_trait = ( ( bmp_info . alpha_mask != 0 ) && ( bmp_info . compression == BI_BITFIELDS ) ) ? BlendPixelTrait : UndefinedPixelTrait ; if ( bmp_info . bits_per_pixel < 16 ) { size_t one ; image -> storage_class = PseudoClass ; image -> colors = bmp_info . number_colors ; one = 1 ; if ( image -> colors == 0 ) image -> colors = one << bmp_info . bits_per_pixel ; } image -> resolution . x = ( double ) bmp_info . x_pixels / 100.0 ; image -> resolution . y = ( double ) bmp_info . y_pixels / 100.0 ; image -> units = PixelsPerCentimeterResolution ; if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; if ( image -> storage_class == PseudoClass ) { unsigned char * bmp_colormap ; size_t packet_size ; if ( image -> debug != MagickFalse ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""Readingcolormapof%.20gcolors"" , ( double ) image -> colors ) ; if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; bmp_colormap = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) image -> colors , 4 * sizeof ( * bmp_colormap ) ) ; if ( bmp_colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; if ( ( bmp_info . size == 12 ) || ( bmp_info . size == 64 ) ) packet_size = 3 ; else packet_size = 4 ; offset = SeekBlob ( image , start_position + 14 + bmp_info . size , SEEK_SET ) ; if ( offset < 0 ) { bmp_colormap = ( unsigned char * ) RelinquishMagickMemory ( bmp_colormap ) ; ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; } count = ReadBlob ( image , packet_size * image -> colors , bmp_colormap ) ; if ( count != ( ssize_t ) ( packet_size * image -> colors ) ) { bmp_colormap = ( unsigned char * ) RelinquishMagickMemory ( bmp_colormap ) ; ThrowReaderException ( CorruptImageError , ""InsufficientImageDataInFile"" ) ; } p = bmp_colormap ; for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { image -> colormap [ i ] . blue = ( MagickRealType ) ScaleCharToQuantum ( * p ++ ) ; image -> colormap [ i ] . green = ( MagickRealType ) ScaleCharToQuantum ( * p ++ ) ; image -> colormap [ i ] . red = ( MagickRealType ) ScaleCharToQuantum ( * p ++ ) ; if ( packet_size == 4 ) p ++ ; } bmp_colormap = ( unsigned char * ) RelinquishMagickMemory ( bmp_colormap ) ; } if ( bmp_info . offset_bits == offset_bits ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; offset_bits = bmp_info . offset_bits ; offset = SeekBlob ( image , start_position + bmp_info . offset_bits , SEEK_SET ) ; if ( offset < 0 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( bmp_info . compression == BI_RLE4 ) bmp_info . bits_per_pixel <<= 1 ; bytes_per_line = 4 * ( ( image -> columns * bmp_info . bits_per_pixel + 31 ) / 32 ) ; length = ( size_t ) bytes_per_line * image -> rows ; if ( ( bmp_info . compression == BI_RGB ) || ( bmp_info . compression == BI_BITFIELDS ) ) { if ( ( MagickSizeType ) length > GetBlobSize ( image ) ) ThrowReaderException ( CorruptImageError , ""InsufficientImageDataInFile"" ) ; pixel_info = AcquireVirtualMemory ( image -> rows , MagickMax ( bytes_per_line , image -> columns + 256UL ) * sizeof ( * pixels ) ) ; if ( pixel_info == ( MemoryInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; pixels = ( unsigned char * ) GetVirtualMemoryBlob ( pixel_info ) ; if ( image -> debug != MagickFalse ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""Readingpixels(%.20gbytes)"" , ( double ) length ) ; count = ReadBlob ( image , length , pixels ) ; if ( count != ( ssize_t ) length ) { pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , ""InsufficientImageDataInFile"" ) ; } } else { pixel_info = AcquireVirtualMemory ( image -> rows , MagickMax ( bytes_per_line , image -> columns + 256UL ) * sizeof ( * pixels ) ) ; if ( pixel_info == ( MemoryInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; pixels = ( unsigned char * ) GetVirtualMemoryBlob ( pixel_info ) ; status = DecodeImage ( image , bmp_info . compression , pixels , image -> columns * image -> rows ) ; if ( status == MagickFalse ) { pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , ""UnableToRunlengthDecodeImage"" ) ; } } if ( bmp_info . compression == BI_RGB ) { if ( ( image -> alpha_trait == UndefinedPixelTrait ) && ( bmp_info . size == 40 ) && ( bmp_info . bits_per_pixel == 32 ) ) { bytes_per_line = 4 * ( image -> columns ) ; for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { p = pixels + ( image -> rows - y - 1 ) * bytes_per_line ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { if ( * ( p + 3 ) != 0 ) { image -> alpha_trait = BlendPixelTrait ; y = - 1 ; break ; } p += 4 ; } } } bmp_info . alpha_mask = image -> alpha_trait != UndefinedPixelTrait ? 0xff000000U : 0U ; bmp_info . red_mask = 0x00ff0000U ; bmp_info . green_mask = 0x0000ff00U ; bmp_info . blue_mask = 0x000000ffU ; if ( bmp_info . bits_per_pixel == 16 ) { bmp_info . red_mask = 0x00007c00U ; bmp_info . green_mask = 0x000003e0U ; bmp_info . blue_mask = 0x0000001fU ; } } ( void ) memset ( & shift , 0 , sizeof ( shift ) ) ; ( void ) memset ( & quantum_bits , 0 , sizeof ( quantum_bits ) ) ; if ( ( bmp_info . bits_per_pixel == 16 ) || ( bmp_info . bits_per_pixel == 32 ) ) { register unsigned int sample ; if ( bmp_info . red_mask != 0 ) while ( ( ( bmp_info . red_mask << shift . red ) & 0x80000000UL ) == 0 ) { shift . red ++ ; if ( shift . red >= 32U ) break ; } if ( bmp_info . green_mask != 0 ) while ( ( ( bmp_info . green_mask << shift . green ) & 0x80000000UL ) == 0 ) { shift . green ++ ; if ( shift . green >= 32U ) break ; } if ( bmp_info . blue_mask != 0 ) while ( ( ( bmp_info . blue_mask << shift . blue ) & 0x80000000UL ) == 0 ) { shift . blue ++ ; if ( shift . blue >= 32U ) break ; } if ( bmp_info . alpha_mask != 0 ) while ( ( ( bmp_info . alpha_mask << shift . alpha ) & 0x80000000UL ) == 0 ) { shift . alpha ++ ; if ( shift . alpha >= 32U ) break ; } sample = shift . red ; while ( ( ( bmp_info . red_mask << sample ) & 0x80000000UL ) != 0 ) { sample ++ ; if ( sample >= 32U ) break ; } quantum_bits . red = ( MagickRealType ) ( sample - shift . red ) ; sample = shift . green ; while ( ( ( bmp_info . green_mask << sample ) & 0x80000000UL ) != 0 ) { sample ++ ; if ( sample >= 32U ) break ; } quantum_bits . green = ( MagickRealType ) ( sample - shift . green ) ; sample = shift . blue ; while ( ( ( bmp_info . blue_mask << sample ) & 0x80000000UL ) != 0 ) { sample ++ ; if ( sample >= 32U ) break ; } quantum_bits . blue = ( MagickRealType ) ( sample - shift . blue ) ; sample = shift . alpha ; while ( ( ( bmp_info . alpha_mask << sample ) & 0x80000000UL ) != 0 ) { sample ++ ; if ( sample >= 32U ) break ; } quantum_bits . alpha = ( MagickRealType ) ( sample - shift . alpha ) ; } switch ( bmp_info . bits_per_pixel ) { case 1 : { for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { p = pixels + ( image -> rows - y - 1 ) * bytes_per_line ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ( ssize_t ) image -> columns - 7 ) ; x += 8 ) { for ( bit = 0 ; bit < 8 ; bit ++ ) { index = ( Quantum ) ( ( ( * p ) & ( 0x80 >> bit ) ) != 0 ? 0x01 : 0x00 ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } if ( ( image -> columns % 8 ) != 0 ) { for ( bit = 0 ; bit < ( image -> columns % 8 ) ; bit ++ ) { index = ( Quantum ) ( ( ( * p ) & ( 0x80 >> bit ) ) != 0 ? 0x01 : 0x00 ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) ( image -> rows - y ) , image -> rows ) ; if ( status == MagickFalse ) break ; } } ( void ) SyncImage ( image , exception ) ; break ; } case 4 : { for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { p = pixels + ( image -> rows - y - 1 ) * bytes_per_line ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ( ssize_t ) image -> columns - 1 ) ; x += 2 ) { ValidateColormapValue ( image , ( ssize_t ) ( ( * p >> 4 ) & 0x0f ) , & index , exception ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; ValidateColormapValue ( image , ( ssize_t ) ( * p & 0x0f ) , & index , exception ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; p ++ ; } if ( ( image -> columns % 2 ) != 0 ) { ValidateColormapValue ( image , ( ssize_t ) ( ( * p >> 4 ) & 0xf ) , & index , exception ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; p ++ ; x ++ ; } if ( x < ( ssize_t ) image -> columns ) break ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) ( image -> rows - y ) , image -> rows ) ; if ( status == MagickFalse ) break ; } } ( void ) SyncImage ( image , exception ) ; break ; } case 8 : { if ( ( bmp_info . compression == BI_RLE8 ) || ( bmp_info . compression == BI_RLE4 ) ) bytes_per_line = image -> columns ; for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { p = pixels + ( image -> rows - y - 1 ) * bytes_per_line ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = ( ssize_t ) image -> columns ; x != 0 ; -- x ) { ValidateColormapValue ( image , ( ssize_t ) * p ++ , & index , exception ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; offset = ( MagickOffsetType ) ( image -> rows - y - 1 ) ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) ( image -> rows - y ) , image -> rows ) ; if ( status == MagickFalse ) break ; } } ( void ) SyncImage ( image , exception ) ; break ; } case 16 : { unsigned int alpha , pixel ; if ( ( bmp_info . compression != BI_RGB ) && ( bmp_info . compression != BI_BITFIELDS ) ) { pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , ""UnrecognizedImageCompression"" ) ; } bytes_per_line = 2 * ( image -> columns + image -> columns % 2 ) ; image -> storage_class = DirectClass ; for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { p = pixels + ( image -> rows - y - 1 ) * bytes_per_line ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { pixel = ( unsigned int ) ( * p ++ ) ; pixel |= ( * p ++ ) << 8 ; red = ( ( pixel & bmp_info . red_mask ) << shift . red ) >> 16 ; if ( quantum_bits . red == 5 ) red |= ( ( red & 0xe000 ) >> 5 ) ; if ( quantum_bits . red <= 8 ) red |= ( ( red & 0xff00 ) >> 8 ) ; green = ( ( pixel & bmp_info . green_mask ) << shift . green ) >> 16 ; if ( quantum_bits . green == 5 ) green |= ( ( green & 0xe000 ) >> 5 ) ; if ( quantum_bits . green == 6 ) green |= ( ( green & 0xc000 ) >> 6 ) ; if ( quantum_bits . green <= 8 ) green |= ( ( green & 0xff00 ) >> 8 ) ; blue = ( ( pixel & bmp_info . blue_mask ) << shift . blue ) >> 16 ; if ( quantum_bits . blue == 5 ) blue |= ( ( blue & 0xe000 ) >> 5 ) ; if ( quantum_bits . blue <= 8 ) blue |= ( ( blue & 0xff00 ) >> 8 ) ; SetPixelRed ( image , ScaleShortToQuantum ( ( unsigned short ) red ) , q ) ; SetPixelGreen ( image , ScaleShortToQuantum ( ( unsigned short ) green ) , q ) ; SetPixelBlue ( image , ScaleShortToQuantum ( ( unsigned short ) blue ) , q ) ; SetPixelAlpha ( image , OpaqueAlpha , q ) ; if ( image -> alpha_trait != UndefinedPixelTrait ) { alpha = ( ( pixel & bmp_info . alpha_mask ) << shift . alpha ) >> 16 ; if ( quantum_bits . alpha <= 8 ) alpha |= ( ( alpha & 0xff00 ) >> 8 ) ; SetPixelAlpha ( image , ScaleShortToQuantum ( ( unsigned short ) alpha ) , q ) ; } q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; offset = ( MagickOffsetType ) ( image -> rows - y - 1 ) ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) ( image -> rows - y ) , image -> rows ) ; if ( status == MagickFalse ) break ; } } break ; } case 24 : { bytes_per_line = 4 * ( ( image -> columns * 24 + 31 ) / 32 ) ; for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { p = pixels + ( image -> rows - y - 1 ) * bytes_per_line ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelBlue ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelGreen ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelRed ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelAlpha ( image , OpaqueAlpha , q ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; offset = ( MagickOffsetType ) ( image -> rows - y - 1 ) ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) ( image -> rows - y ) , image -> rows ) ; if ( status == MagickFalse ) break ; } } break ; } case 32 : { if ( ( bmp_info . compression != BI_RGB ) && ( bmp_info . compression != BI_BITFIELDS ) ) { pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , ""UnrecognizedImageCompression"" ) ; } bytes_per_line = 4 * ( image -> columns ) ; for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { unsigned int alpha , pixel ; p = pixels + ( image -> rows - y - 1 ) * bytes_per_line ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { pixel = ( unsigned int ) ( * p ++ ) ; pixel |= ( ( unsigned int ) * p ++ << 8 ) ; pixel |= ( ( unsigned int ) * p ++ << 16 ) ; pixel |= ( ( unsigned int ) * p ++ << 24 ) ; red = ( ( pixel & bmp_info . red_mask ) << shift . red ) >> 16 ; if ( quantum_bits . red == 8 ) red |= ( red >> 8 ) ; green = ( ( pixel & bmp_info . green_mask ) << shift . green ) >> 16 ; if ( quantum_bits . green == 8 ) green |= ( green >> 8 ) ; blue = ( ( pixel & bmp_info . blue_mask ) << shift . blue ) >> 16 ; if ( quantum_bits . blue == 8 ) blue |= ( blue >> 8 ) ; SetPixelRed ( image , ScaleShortToQuantum ( ( unsigned short ) red ) , q ) ; SetPixelGreen ( image , ScaleShortToQuantum ( ( unsigned short ) green ) , q ) ; SetPixelBlue ( image , ScaleShortToQuantum ( ( unsigned short ) blue ) , q ) ; SetPixelAlpha ( image , OpaqueAlpha , q ) ; if ( image -> alpha_trait != UndefinedPixelTrait ) { alpha = ( ( pixel & bmp_info . alpha_mask ) << shift . alpha ) >> 16 ; if ( quantum_bits . alpha == 8 ) alpha |= ( alpha >> 8 ) ; SetPixelAlpha ( image , ScaleShortToQuantum ( ( unsigned short ) alpha ) , q ) ; } q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; offset = ( MagickOffsetType ) ( image -> rows - y - 1 ) ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) ( image -> rows - y ) , image -> rows ) ; if ( status == MagickFalse ) break ; } } break ; } default : { pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; } } pixel_info = RelinquishVirtualMemory ( pixel_info ) ; if ( y > 0 ) break ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } if ( bmp_info . height < 0 ) { Image * flipped_image ; flipped_image = FlipImage ( image , exception ) ; if ( flipped_image != ( Image * ) NULL ) { DuplicateBlob ( flipped_image , image ) ; ReplaceImageInList ( & image , flipped_image ) ; image = flipped_image ; } } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; * magick = '\\0' ; if ( bmp_info . ba_offset != 0 ) { offset = SeekBlob ( image , ( MagickOffsetType ) bmp_info . ba_offset , SEEK_SET ) ; if ( offset < 0 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; } count = ReadBlob ( image , 2 , magick ) ; if ( ( count == 2 ) && ( IsBMP ( magick , 2 ) != MagickFalse ) ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { status = MagickFalse ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( IsBMP ( magick , 2 ) != MagickFalse ) ; ( void ) CloseBlob ( image ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; return ( GetFirstImageInList ( image ) ) ; } "," ; if ( ( MagickSizeType ) ) break ; offset = ( MagickOffsetType ) bmp_info . ba_offset bmp_info . ba_offset ; if ( offset != 0 ) if ( ( offset < ( offset < TellBlob ( image ) ) || ( SeekBlob ( image , offset , SEEK_SET ) != offset ) ) ThrowReaderException ( ""ImproperImageHeader"" ) ; * magick = '\\0' ; count = ReadBlob ",ImageMagick@ImageMagick/db0add932fb850d762b02604ca3053b7d7ab6deb,CVE-2018-20467,https://github.com/ImageMagick/ImageMagick/commit/db0add932fb850d762b02604ca3053b7d7ab6deb,2018-12-26T03:29Z 731,CWE-362,"CWE-362 struct sock * dccp_v4_request_recv_sock ( struct sock * sk , struct sk_buff * skb , struct request_sock * req , struct dst_entry * dst ) { struct inet_request_sock * ireq ; struct inet_sock * newinet ; struct sock * newsk ; if ( sk_acceptq_is_full ( sk ) ) goto exit_overflow ; if ( dst == NULL && ( dst = inet_csk_route_req ( sk , req ) ) == NULL ) goto exit ; newsk = dccp_create_openreq_child ( sk , req , skb ) ; if ( newsk == NULL ) goto exit_nonewsk ; sk_setup_caps ( newsk , dst ) ; newinet = inet_sk ( newsk ) ; ireq = inet_rsk ( req ) ; newinet -> inet_daddr = ireq -> rmt_addr ; newinet -> inet_rcv_saddr = ireq -> loc_addr ; newinet -> inet_saddr = ireq -> loc_addr ; newinet -> opt = ireq -> opt ; ireq -> opt = NULL ; newinet -> mc_index = inet_iif ( skb ) ; newinet -> mc_ttl = ip_hdr ( skb ) -> ttl ; newinet -> inet_id = jiffies ; dccp_sync_mss ( newsk , dst_mtu ( dst ) ) ; if ( __inet_inherit_port ( sk , newsk ) < 0 ) { sock_put ( newsk ) ; goto exit ; } __inet_hash_nolisten ( newsk , NULL ) ; return newsk ; exit_overflow : NET_INC_STATS_BH ( sock_net ( sk ) , LINUX_MIB_LISTENOVERFLOWS ) ; exit_nonewsk : dst_release ( dst ) ; exit : NET_INC_STATS_BH ( sock_net ( sk ) , LINUX_MIB_LISTENDROPS ) ; return NULL ; } "," ; newinet -> inet_opt = ireq -> ",torvalds@linux/f6d8bd051c391c1c0458a30b2a7abcd939329259,CVE-2012-3552,https://github.com/torvalds/linux/commit/f6d8bd051c391c1c0458a30b2a7abcd939329259,2012-10-03T11:02Z 732,CWE-119,"CWE-119 void ParseNameValue ( const char * buffer , int bufsize , struct NameValueParserData * data ) { struct xmlparser parser ; data -> l_head = NULL ; data -> portListing = NULL ; data -> portListingLength = 0 ; parser . xmlstart = buffer ; parser . xmlsize = bufsize ; parser . data = data ; parser . starteltfunc = NameValueParserStartElt ; parser . endeltfunc = NameValueParserEndElt ; parser . datafunc = NameValueParserGetData ; parser . attfunc = 0 ; parsexml ( & parser ) ; } "," xmlparser parser ; memset ( data , 0 , sizeof ( struct NameValueParserData ) ) ; parser . ",miniupnp@miniupnp/7aeb624b44f86d335841242ff427433190e7168a,CVE-2017-1000494,https://github.com/miniupnp/miniupnp/commit/7aeb624b44f86d335841242ff427433190e7168a,2018-01-03T14:29Z 733,CWE-125,"CWE-125 static void ip_cmsg_recv_checksum ( struct msghdr * msg , struct sk_buff * skb , int tlen , int offset ) { __wsum csum = skb -> csum ; if ( skb -> ip_summed != CHECKSUM_COMPLETE ) return ; if ( offset != 0 ) csum = csum_sub ( csum , csum_partial ( skb_transport_header ( skb ) + tlen , offset , 0 ) ) ; put_cmsg ( msg , SOL_IP , IP_CHECKSUM , sizeof ( __wsum ) , & csum ) ; } "," != 0 ) { int tend_off = skb_transport_offset ( skb ) + tlen ; ( csum , skb_checksum ( skb , tend_off , offset , 0 ) ) ; } ",torvalds@linux/ca4ef4574f1ee5252e2cd365f8f5d5bafd048f32,CVE-2017-6347,https://github.com/torvalds/linux/commit/ca4ef4574f1ee5252e2cd365f8f5d5bafd048f32,2017-03-01T20:59Z 734,CWE-189,"CWE-189 int kvm_iommu_map_pages ( struct kvm * kvm , struct kvm_memory_slot * slot ) { gfn_t gfn , end_gfn ; pfn_t pfn ; int r = 0 ; struct iommu_domain * domain = kvm -> arch . iommu_domain ; int flags ; if ( ! domain ) return 0 ; gfn = slot -> base_gfn ; end_gfn = gfn + slot -> npages ; flags = IOMMU_READ ; if ( ! ( slot -> flags & KVM_MEM_READONLY ) ) flags |= IOMMU_WRITE ; if ( ! kvm -> arch . iommu_noncoherent ) flags |= IOMMU_CACHE ; while ( gfn < end_gfn ) { unsigned long page_size ; if ( iommu_iova_to_phys ( domain , gfn_to_gpa ( gfn ) ) ) { gfn += 1 ; continue ; } page_size = kvm_host_page_size ( kvm , gfn ) ; while ( ( gfn + ( page_size >> PAGE_SHIFT ) ) > end_gfn ) page_size >>= 1 ; while ( ( gfn << PAGE_SHIFT ) & ( page_size - 1 ) ) page_size >>= 1 ; while ( __gfn_to_hva_memslot ( slot , gfn ) & ( page_size - 1 ) ) page_size >>= 1 ; pfn = kvm_pin_pages ( slot , gfn , page_size ) ; if ( is_error_noslot_pfn ( pfn ) ) { gfn += 1 ; continue ; } r = iommu_map ( domain , gfn_to_gpa ( gfn ) , pfn_to_hpa ( pfn ) , page_size , flags ) ; if ( r ) { printk ( KERN_ERR ""kvm_iommu_map_address:"" ""iommufailedtomappfn=%llx\\n"" , pfn ) ; goto unmap_pages ; } gfn += page_size >> PAGE_SHIFT ; } return 0 ; unmap_pages : kvm_iommu_put_pages ( kvm , slot -> base_gfn , gfn ) ; return r ; } "," pfn ) ; kvm_unpin_pages ( kvm , pfn , page_size ) ; base_gfn , gfn - slot -> base_gfn ",torvalds@linux/350b8bdd689cd2ab2c67c8a86a0be86cfa0751a7,CVE-2014-3601,https://github.com/torvalds/linux/commit/350b8bdd689cd2ab2c67c8a86a0be86cfa0751a7,2014-09-01T01:55Z 735,CWE-119,"CWE-119 static int ttusbdecfe_dvbs_diseqc_send_master_cmd ( struct dvb_frontend * fe , struct dvb_diseqc_master_cmd * cmd ) { struct ttusbdecfe_state * state = ( struct ttusbdecfe_state * ) fe -> demodulator_priv ; u8 b [ ] = { 0x00 , 0xff , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 } ; memcpy ( & b [ 4 ] , cmd -> msg , cmd -> msg_len ) ; state -> config -> send_command ( fe , 0x72 , sizeof ( b ) - ( 6 - cmd -> msg_len ) , b , NULL , NULL ) ; return 0 ; } "," 0x00 } ; if ( cmd -> msg_len > sizeof ( b ) - 4 ) return - EINVAL ; ",torvalds@linux/f2e323ec96077642d397bb1c355def536d489d16,CVE-2014-8884,https://github.com/torvalds/linux/commit/f2e323ec96077642d397bb1c355def536d489d16,2014-11-30T01:59Z 736,CWE-264,"CWE-264 void perf_event_disable ( struct perf_event * event ) { struct perf_event_context * ctx = event -> ctx ; struct task_struct * task = ctx -> task ; if ( ! task ) { cpu_function_call ( event -> cpu , __perf_event_disable , event ) ; return ; } retry : if ( ! task_function_call ( task , __perf_event_disable , event ) ) return ; raw_spin_lock_irq ( & ctx -> lock ) ; if ( event -> state == PERF_EVENT_STATE_ACTIVE ) { raw_spin_unlock_irq ( & ctx -> lock ) ; task = ctx -> task ; goto retry ; } if ( event -> state == PERF_EVENT_STATE_INACTIVE ) { update_group_times ( event ) ; event -> state = PERF_EVENT_STATE_OFF ; } raw_spin_unlock_irq ( & ctx -> lock ) ; } "," perf_event_context * ctx ; ctx = perf_event_ctx_lock ( event ) event ) ; _perf_event_disable ( event ) ; perf_event_ctx_unlock ( event , ctx ) ; } ",torvalds@linux/f63a8daa5812afef4f06c962351687e1ff9ccb2b,CVE-2016-6787,https://github.com/torvalds/linux/commit/f63a8daa5812afef4f06c962351687e1ff9ccb2b,2016-12-28T07:59Z 737,CWE-125,"CWE-125 static inline unsigned int ReadPropertyUnsignedLong ( const EndianType endian , const unsigned char * buffer ) { unsigned int value ; if ( endian == LSBEndian ) { value = ( unsigned int ) ( ( buffer [ 3 ] << 24 ) | ( buffer [ 2 ] << 16 ) | ( buffer [ 1 ] << 8 ) | ( buffer [ 0 ] ) ) ; return ( ( unsigned int ) ( value & 0xffffffff ) ) ; } value = ( unsigned int ) ( ( buffer [ 0 ] << 24 ) | ( buffer [ 1 ] << 16 ) | ( buffer [ 2 ] << 8 ) | buffer [ 3 ] ) ; return ( ( unsigned int ) ( value & 0xffffffff ) ) ; } "," unsigned int ) buffer [ 3 ] << 24 ; value |= ( unsigned int ) buffer [ 2 ] << 16 ; value |= ( unsigned int ) buffer [ 1 ] << 8 ; value |= ( unsigned int ) buffer [ 0 [ 0 ] ; return ( ; return ( value & 0xffffffff value & 0xffffffff ) ; } unsigned int ) buffer [ 0 ] << 24 ; value |= ( unsigned int ) buffer [ 1 ] << 16 ; value |= ( unsigned int ) buffer [ 2 ] << 8 ; value |= ( unsigned int ) buffer [ 3 [ 3 ] ; return ( value & & 0xffffffff ) ; } ",ImageMagick@ImageMagick/d8ab7f046587f2e9f734b687ba7e6e10147c294b,CVE-2016-5842,https://github.com/ImageMagick/ImageMagick/commit/d8ab7f046587f2e9f734b687ba7e6e10147c294b,2016-12-13T15:59Z 738,CWE-362,"CWE-362 static bool add_free_nid ( struct f2fs_sb_info * sbi , nid_t nid , bool build ) { struct f2fs_nm_info * nm_i = NM_I ( sbi ) ; struct free_nid * i ; struct nat_entry * ne ; int err ; if ( unlikely ( nid == 0 ) ) return false ; if ( build ) { ne = __lookup_nat_cache ( nm_i , nid ) ; if ( ne && ( ! get_nat_flag ( ne , IS_CHECKPOINTED ) || nat_get_blkaddr ( ne ) != NULL_ADDR ) ) return false ; } i = f2fs_kmem_cache_alloc ( free_nid_slab , GFP_NOFS ) ; i -> nid = nid ; i -> state = NID_NEW ; if ( radix_tree_preload ( GFP_NOFS ) ) { kmem_cache_free ( free_nid_slab , i ) ; return true ; } spin_lock ( & nm_i -> nid_list_lock ) ; err = __insert_nid_to_list ( sbi , i , FREE_NID_LIST , true ) ; spin_unlock ( & nm_i -> nid_list_lock ) ; radix_tree_preload_end ( ) ; if ( err ) { kmem_cache_free ( free_nid_slab , i ) ; return true ; } return true ; } "," free_nid * i , * e ; int err = - EINVAL ; bool ret = false return false ; i = f2fs_kmem_cache_alloc ( free_nid_slab , GFP_NOFS ) ; i -> nid = nid ; i -> state = NID_NEW ; if ( radix_tree_preload ( GFP_NOFS ) ) goto err ; spin_lock ( & nm_i -> nid_list_lock ) ; NULL_ADDR ) ) goto err_out ; e = __lookup_free_nid_list ( nm_i , nid ) ; if ( e ) { if ( e -> state == NID_NEW ) ret = true ; goto err_out ; } } ret = true ; err = __insert_nid_to_list ( sbi , i , FREE_NID_LIST , true ) ; err_out : spin_unlock ( & nm_i -> nid_list_lock ) ; radix_tree_preload_end ( ) ; err : if ( err ) kmem_cache_free ( free_nid_slab , i ) ; return ret ; } ",torvalds@linux/30a61ddf8117c26ac5b295e1233eaa9629a94ca3,CVE-2017-18249,https://github.com/torvalds/linux/commit/30a61ddf8117c26ac5b295e1233eaa9629a94ca3,2018-03-26T20:29Z 739,CWE-119,"CWE-119 static void set_ppflags ( const vpx_codec_alg_priv_t * ctx , vp9_ppflags_t * flags ) { flags -> post_proc_flag = # if CONFIG_POSTPROC_VISUALIZER ( ctx -> dbg_color_ref_frame_flag ? VP9D_DEBUG_CLR_FRM_REF_BLKS : 0 ) | ( ctx -> dbg_color_mb_modes_flag ? VP9D_DEBUG_CLR_BLK_MODES : 0 ) | ( ctx -> dbg_color_b_modes_flag ? VP9D_DEBUG_CLR_BLK_MODES : 0 ) | ( ctx -> dbg_display_mv_flag ? VP9D_DEBUG_DRAW_MV : 0 ) | # endif ctx -> postproc_cfg . post_proc_flag ; flags -> deblocking_level = ctx -> postproc_cfg . deblocking_level ; flags -> noise_level = ctx -> postproc_cfg . noise_level ; # if CONFIG_POSTPROC_VISUALIZER flags -> display_ref_frame_flag = ctx -> dbg_color_ref_frame_flag ; flags -> display_mb_modes_flag = ctx -> dbg_color_mb_modes_flag ; flags -> display_b_modes_flag = ctx -> dbg_color_b_modes_flag ; flags -> display_mv_flag = ctx -> dbg_display_mv_flag ; # endif } "," -> post_proc_flag = ctx -> postproc_cfg . noise_level ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 740,CWE-20,"CWE-20 static int xen_netbk_get_extras ( struct xenvif * vif , struct xen_netif_extra_info * extras , int work_to_do ) { struct xen_netif_extra_info extra ; RING_IDX cons = vif -> tx . req_cons ; do { if ( unlikely ( work_to_do -- <= 0 ) ) { netdev_dbg ( vif -> dev , ""Missingextrainfo\\n"" ) ; return - EBADR ; } memcpy ( & extra , RING_GET_REQUEST ( & vif -> tx , cons ) , sizeof ( extra ) ) ; if ( unlikely ( ! extra . type || extra . type >= XEN_NETIF_EXTRA_TYPE_MAX ) ) { vif -> tx . req_cons = ++ cons ; netdev_dbg ( vif -> dev , ""Invalidextratype:%d\\n"" , extra . type ) ; return - EINVAL ; } memcpy ( & extras [ extra . type - 1 ] , & extra , sizeof ( extra ) ) ; vif -> tx . req_cons = ++ cons ; } while ( extra . flags & XEN_NETIF_EXTRA_FLAG_MORE ) ; return work_to_do ; } "," ) ) { netdev_err ( vif -> dev , ""Missingextrainfo\\n"" ) ; netbk_fatal_tx_err ( vif ++ cons ; netdev_err ( vif -> extra . type ) ; netbk_fatal_tx_err ( vif ",torvalds@linux/48856286b64e4b66ec62b94e504d0b29c1ade664,CVE-2013-0216,https://github.com/torvalds/linux/commit/48856286b64e4b66ec62b94e504d0b29c1ade664,2013-02-18T04:41Z 741,CWE-119,"CWE-119 static int key_notify_policy_flush ( const struct km_event * c ) { struct sk_buff * skb_out ; struct sadb_msg * hdr ; skb_out = alloc_skb ( sizeof ( struct sadb_msg ) + 16 , GFP_ATOMIC ) ; if ( ! skb_out ) return - ENOBUFS ; hdr = ( struct sadb_msg * ) skb_put ( skb_out , sizeof ( struct sadb_msg ) ) ; hdr -> sadb_msg_type = SADB_X_SPDFLUSH ; hdr -> sadb_msg_seq = c -> seq ; hdr -> sadb_msg_pid = c -> portid ; hdr -> sadb_msg_version = PF_KEY_V2 ; hdr -> sadb_msg_errno = ( uint8_t ) 0 ; hdr -> sadb_msg_satype = SADB_SATYPE_UNSPEC ; hdr -> sadb_msg_len = ( sizeof ( struct sadb_msg ) / sizeof ( uint64_t ) ) ; pfkey_broadcast ( skb_out , GFP_ATOMIC , BROADCAST_ALL , NULL , c -> net ) ; return 0 ; } "," ) ) ; hdr -> sadb_msg_reserved = 0 ; ",torvalds@linux/a5cc68f3d63306d0d288f31edfc2ae6ef8ecd887,CVE-2013-2234,https://github.com/torvalds/linux/commit/a5cc68f3d63306d0d288f31edfc2ae6ef8ecd887,2013-07-04T21:55Z 742,CWE-200,"CWE-200 static void snd_timer_user_ccallback ( struct snd_timer_instance * timeri , int event , struct timespec * tstamp , unsigned long resolution ) { struct snd_timer_user * tu = timeri -> callback_data ; struct snd_timer_tread r1 ; unsigned long flags ; if ( event >= SNDRV_TIMER_EVENT_START && event <= SNDRV_TIMER_EVENT_PAUSE ) tu -> tstamp = * tstamp ; if ( ( tu -> filter & ( 1 << event ) ) == 0 || ! tu -> tread ) return ; r1 . event = event ; r1 . tstamp = * tstamp ; r1 . val = resolution ; spin_lock_irqsave ( & tu -> qlock , flags ) ; snd_timer_user_append_to_tqueue ( tu , & r1 ) ; spin_unlock_irqrestore ( & tu -> qlock , flags ) ; kill_fasync ( & tu -> fasync , SIGIO , POLL_IN ) ; wake_up ( & tu -> qchange_sleep ) ; } "," ) return ; memset ( & r1 , 0 , sizeof ( r1 ) ) ; ",torvalds@linux/9a47e9cff994f37f7f0dbd9ae23740d0f64f9fe6,CVE-2016-4578,https://github.com/torvalds/linux/commit/9a47e9cff994f37f7f0dbd9ae23740d0f64f9fe6,2016-05-23T10:59Z 743,CWE-190,"CWE-190 static int b_unpack ( lua_State * L ) { Header h ; const char * fmt = luaL_checkstring ( L , 1 ) ; size_t ld ; const char * data = luaL_checklstring ( L , 2 , & ld ) ; size_t pos = luaL_optinteger ( L , 3 , 1 ) - 1 ; defaultoptions ( & h ) ; lua_settop ( L , 2 ) ; while ( * fmt ) { int opt = * fmt ++ ; size_t size = optsize ( L , opt , & fmt ) ; pos += gettoalign ( pos , & h , opt , size ) ; luaL_argcheck ( L , pos + size <= ld , 2 , ""datastringtooshort"" ) ; luaL_checkstack ( L , 1 , ""toomanyresults"" ) ; switch ( opt ) { case 'b' : case 'B' : case 'h' : case 'H' : case 'l' : case 'L' : case 'T' : case 'i' : case 'I' : { int issigned = islower ( opt ) ; lua_Number res = getinteger ( data + pos , h . endian , issigned , size ) ; lua_pushnumber ( L , res ) ; break ; } case 'x' : { break ; } case 'f' : { float f ; memcpy ( & f , data + pos , size ) ; correctbytes ( ( char * ) & f , sizeof ( f ) , h . endian ) ; lua_pushnumber ( L , f ) ; break ; } case 'd' : { double d ; memcpy ( & d , data + pos , size ) ; correctbytes ( ( char * ) & d , sizeof ( d ) , h . endian ) ; lua_pushnumber ( L , d ) ; break ; } case 'c' : { if ( size == 0 ) { if ( ! lua_isnumber ( L , - 1 ) ) luaL_error ( L , ""format`c0\'needsaprevioussize"" ) ; size = lua_tonumber ( L , - 1 ) ; lua_pop ( L , 1 ) ; luaL_argcheck ( L , pos + size <= ld , 2 , ""datastringtooshort"" ) ; } lua_pushlstring ( L , data + pos , size ) ; break ; } case 's' : { const char * e = ( const char * ) memchr ( data + pos , '\\0' , ld - pos ) ; if ( e == NULL ) luaL_error ( L , ""unfinishedstringindata"" ) ; size = ( e - ( data + pos ) ) + 1 ; lua_pushlstring ( L , data + pos , size - 1 ) ; break ; } default : controloptions ( L , opt , & fmt , & h ) ; } pos += size ; } lua_pushinteger ( L , pos + 1 ) ; return lua_gettop ( L ) - 2 ; } "," - 1 ; int n = 0 ; ( & h ) ; while ( L , 2 , ""toomanyresults"" ) res ) ; n ++ ; f ) ; n ++ ; d ) ; n ++ ; { if ( n == 0 || ( L , ""format\'c0\'needsaprevioussize"" ) ; size 1 ) ; n -- ; ( L , size <= ld size <= ld && pos <= ld - size , 2 , ""datastringtooshort"" , size ) ; n ++ 1 ) ; n ++ ; ) ; return n + 1 ; } ",antirez@redis/1eb08bcd4634ae42ec45e8284923ac048beaa4c3,CVE-2018-11219,https://github.com/antirez/redis/commit/1eb08bcd4634ae42ec45e8284923ac048beaa4c3,2018-06-17T17:29Z 744,CWE-125,"CWE-125 void olsr_print ( netdissect_options * ndo , const u_char * pptr , u_int length , int is_ipv6 ) { union { const struct olsr_common * common ; const struct olsr_msg4 * msg4 ; const struct olsr_msg6 * msg6 ; const struct olsr_hello * hello ; const struct olsr_hello_link * hello_link ; const struct olsr_tc * tc ; const struct olsr_hna4 * hna ; } ptr ; u_int msg_type , msg_len , msg_tlen , hello_len ; uint16_t name_entry_type , name_entry_len ; u_int name_entry_padding ; uint8_t link_type , neighbor_type ; const u_char * tptr , * msg_data ; tptr = pptr ; if ( length < sizeof ( struct olsr_common ) ) { goto trunc ; } ND_TCHECK2 ( * tptr , sizeof ( struct olsr_common ) ) ; ptr . common = ( const struct olsr_common * ) tptr ; length = min ( length , EXTRACT_16BITS ( ptr . common -> packet_len ) ) ; ND_PRINT ( ( ndo , ""OLSRv%i,seq0x%04x,length%u"" , ( is_ipv6 == 0 ) ? 4 : 6 , EXTRACT_16BITS ( ptr . common -> packet_seq ) , length ) ) ; tptr += sizeof ( struct olsr_common ) ; if ( ndo -> ndo_vflag < 1 ) { return ; } while ( tptr < ( pptr + length ) ) { union { const struct olsr_msg4 * v4 ; const struct olsr_msg6 * v6 ; } msgptr ; int msg_len_valid = 0 ; ND_TCHECK2 ( * tptr , sizeof ( struct olsr_msg4 ) ) ; if ( is_ipv6 ) { msgptr . v6 = ( const struct olsr_msg6 * ) tptr ; msg_type = msgptr . v6 -> msg_type ; msg_len = EXTRACT_16BITS ( msgptr . v6 -> msg_len ) ; if ( ( msg_len >= sizeof ( struct olsr_msg6 ) ) && ( msg_len <= length ) ) msg_len_valid = 1 ; if ( msg_type == 0 || msg_len == 0 ) { return ; } ND_PRINT ( ( ndo , ""\\n\\t%sMessage(%#04x),originator%s,ttl%u,hop%u"" ""\\n\\tvtime%.3fs,msg-seq0x%04x,length%u%s"" , tok2str ( olsr_msg_values , ""Unknown"" , msg_type ) , msg_type , ip6addr_string ( ndo , msgptr . v6 -> originator ) , msgptr . v6 -> ttl , msgptr . v6 -> hopcount , ME_TO_DOUBLE ( msgptr . v6 -> vtime ) , EXTRACT_16BITS ( msgptr . v6 -> msg_seq ) , msg_len , ( msg_len_valid == 0 ) ? ""(invalid)"" : """" ) ) ; if ( ! msg_len_valid ) { return ; } msg_tlen = msg_len - sizeof ( struct olsr_msg6 ) ; msg_data = tptr + sizeof ( struct olsr_msg6 ) ; } else { msgptr . v4 = ( const struct olsr_msg4 * ) tptr ; msg_type = msgptr . v4 -> msg_type ; msg_len = EXTRACT_16BITS ( msgptr . v4 -> msg_len ) ; if ( ( msg_len >= sizeof ( struct olsr_msg4 ) ) && ( msg_len <= length ) ) msg_len_valid = 1 ; if ( msg_type == 0 || msg_len == 0 ) { return ; } ND_PRINT ( ( ndo , ""\\n\\t%sMessage(%#04x),originator%s,ttl%u,hop%u"" ""\\n\\tvtime%.3fs,msg-seq0x%04x,length%u%s"" , tok2str ( olsr_msg_values , ""Unknown"" , msg_type ) , msg_type , ipaddr_string ( ndo , msgptr . v4 -> originator ) , msgptr . v4 -> ttl , msgptr . v4 -> hopcount , ME_TO_DOUBLE ( msgptr . v4 -> vtime ) , EXTRACT_16BITS ( msgptr . v4 -> msg_seq ) , msg_len , ( msg_len_valid == 0 ) ? ""(invalid)"" : """" ) ) ; if ( ! msg_len_valid ) { return ; } msg_tlen = msg_len - sizeof ( struct olsr_msg4 ) ; msg_data = tptr + sizeof ( struct olsr_msg4 ) ; } switch ( msg_type ) { case OLSR_HELLO_MSG : case OLSR_HELLO_LQ_MSG : if ( msg_tlen < sizeof ( struct olsr_hello ) ) goto trunc ; ND_TCHECK2 ( * msg_data , sizeof ( struct olsr_hello ) ) ; ptr . hello = ( const struct olsr_hello * ) msg_data ; ND_PRINT ( ( ndo , ""\\n\\thello-time%.3fs,MPRwillingness%u"" , ME_TO_DOUBLE ( ptr . hello -> htime ) , ptr . hello -> will ) ) ; msg_data += sizeof ( struct olsr_hello ) ; msg_tlen -= sizeof ( struct olsr_hello ) ; while ( msg_tlen >= sizeof ( struct olsr_hello_link ) ) { int hello_len_valid = 0 ; ND_TCHECK2 ( * msg_data , sizeof ( struct olsr_hello_link ) ) ; ptr . hello_link = ( const struct olsr_hello_link * ) msg_data ; hello_len = EXTRACT_16BITS ( ptr . hello_link -> len ) ; link_type = OLSR_EXTRACT_LINK_TYPE ( ptr . hello_link -> link_code ) ; neighbor_type = OLSR_EXTRACT_NEIGHBOR_TYPE ( ptr . hello_link -> link_code ) ; if ( ( hello_len <= msg_tlen ) && ( hello_len >= sizeof ( struct olsr_hello_link ) ) ) hello_len_valid = 1 ; ND_PRINT ( ( ndo , ""\\n\\tlink-type%s,neighbor-type%s,len%u%s"" , tok2str ( olsr_link_type_values , ""Unknown"" , link_type ) , tok2str ( olsr_neighbor_type_values , ""Unknown"" , neighbor_type ) , hello_len , ( hello_len_valid == 0 ) ? ""(invalid)"" : """" ) ) ; if ( hello_len_valid == 0 ) break ; msg_data += sizeof ( struct olsr_hello_link ) ; msg_tlen -= sizeof ( struct olsr_hello_link ) ; hello_len -= sizeof ( struct olsr_hello_link ) ; ND_TCHECK2 ( * msg_data , hello_len ) ; if ( msg_type == OLSR_HELLO_MSG ) { if ( olsr_print_neighbor ( ndo , msg_data , hello_len ) == - 1 ) goto trunc ; } else { if ( is_ipv6 ) { if ( olsr_print_lq_neighbor6 ( ndo , msg_data , hello_len ) == - 1 ) goto trunc ; } else { if ( olsr_print_lq_neighbor4 ( ndo , msg_data , hello_len ) == - 1 ) goto trunc ; } } msg_data += hello_len ; msg_tlen -= hello_len ; } break ; case OLSR_TC_MSG : case OLSR_TC_LQ_MSG : if ( msg_tlen < sizeof ( struct olsr_tc ) ) goto trunc ; ND_TCHECK2 ( * msg_data , sizeof ( struct olsr_tc ) ) ; ptr . tc = ( const struct olsr_tc * ) msg_data ; ND_PRINT ( ( ndo , ""\\n\\tadvertisedneighborseq0x%04x"" , EXTRACT_16BITS ( ptr . tc -> ans_seq ) ) ) ; msg_data += sizeof ( struct olsr_tc ) ; msg_tlen -= sizeof ( struct olsr_tc ) ; if ( msg_type == OLSR_TC_MSG ) { if ( olsr_print_neighbor ( ndo , msg_data , msg_tlen ) == - 1 ) goto trunc ; } else { if ( is_ipv6 ) { if ( olsr_print_lq_neighbor6 ( ndo , msg_data , msg_tlen ) == - 1 ) goto trunc ; } else { if ( olsr_print_lq_neighbor4 ( ndo , msg_data , msg_tlen ) == - 1 ) goto trunc ; } } break ; case OLSR_MID_MSG : { size_t addr_size = sizeof ( struct in_addr ) ; if ( is_ipv6 ) addr_size = sizeof ( struct in6_addr ) ; while ( msg_tlen >= addr_size ) { ND_TCHECK2 ( * msg_data , addr_size ) ; ND_PRINT ( ( ndo , ""\\n\\tinterfaceaddress%s"" , is_ipv6 ? ip6addr_string ( ndo , msg_data ) : ipaddr_string ( ndo , msg_data ) ) ) ; msg_data += addr_size ; msg_tlen -= addr_size ; } break ; } case OLSR_HNA_MSG : if ( is_ipv6 ) { int i = 0 ; ND_PRINT ( ( ndo , ""\\n\\tAdvertisednetworks(total%u)"" , ( unsigned int ) ( msg_tlen / sizeof ( struct olsr_hna6 ) ) ) ) ; while ( msg_tlen >= sizeof ( struct olsr_hna6 ) ) { const struct olsr_hna6 * hna6 ; ND_TCHECK2 ( * msg_data , sizeof ( struct olsr_hna6 ) ) ; hna6 = ( const struct olsr_hna6 * ) msg_data ; ND_PRINT ( ( ndo , ""\\n\\t#%i:%s/%u"" , i , ip6addr_string ( ndo , hna6 -> network ) , mask62plen ( hna6 -> mask ) ) ) ; msg_data += sizeof ( struct olsr_hna6 ) ; msg_tlen -= sizeof ( struct olsr_hna6 ) ; } } else { int col = 0 ; ND_PRINT ( ( ndo , ""\\n\\tAdvertisednetworks(total%u)"" , ( unsigned int ) ( msg_tlen / sizeof ( struct olsr_hna4 ) ) ) ) ; while ( msg_tlen >= sizeof ( struct olsr_hna4 ) ) { ND_TCHECK2 ( * msg_data , sizeof ( struct olsr_hna4 ) ) ; ptr . hna = ( const struct olsr_hna4 * ) msg_data ; if ( ! ptr . hna -> network [ 0 ] && ! ptr . hna -> network [ 1 ] && ! ptr . hna -> network [ 2 ] && ! ptr . hna -> network [ 3 ] && ! ptr . hna -> mask [ GW_HNA_PAD ] && ptr . hna -> mask [ GW_HNA_FLAGS ] ) { ND_PRINT ( ( ndo , ""%sSmart-Gateway:%s%s%s%s%s%u/%u"" , col == 0 ? ""\\n\\t"" : "","" , ( ptr . hna -> mask [ GW_HNA_FLAGS ] & GW_HNA_FLAG_LINKSPEED ) ? ""LINKSPEED"" : """" , ( ptr . hna -> mask [ GW_HNA_FLAGS ] & GW_HNA_FLAG_IPV4 ) ? ""IPV4"" : """" , ( ptr . hna -> mask [ GW_HNA_FLAGS ] & GW_HNA_FLAG_IPV4_NAT ) ? ""IPV4-NAT"" : """" , ( ptr . hna -> mask [ GW_HNA_FLAGS ] & GW_HNA_FLAG_IPV6 ) ? ""IPV6"" : """" , ( ptr . hna -> mask [ GW_HNA_FLAGS ] & GW_HNA_FLAG_IPV6PREFIX ) ? ""IPv6-PREFIX"" : """" , ( ptr . hna -> mask [ GW_HNA_FLAGS ] & GW_HNA_FLAG_LINKSPEED ) ? deserialize_gw_speed ( ptr . hna -> mask [ GW_HNA_UPLINK ] ) : 0 , ( ptr . hna -> mask [ GW_HNA_FLAGS ] & GW_HNA_FLAG_LINKSPEED ) ? deserialize_gw_speed ( ptr . hna -> mask [ GW_HNA_DOWNLINK ] ) : 0 ) ) ; } else { ND_PRINT ( ( ndo , ""%s%s/%u"" , col == 0 ? ""\\n\\t"" : "","" , ipaddr_string ( ndo , ptr . hna -> network ) , mask2plen ( EXTRACT_32BITS ( ptr . hna -> mask ) ) ) ) ; } msg_data += sizeof ( struct olsr_hna4 ) ; msg_tlen -= sizeof ( struct olsr_hna4 ) ; col = ( col + 1 ) % 4 ; } } break ; case OLSR_NAMESERVICE_MSG : { u_int name_entries = EXTRACT_16BITS ( msg_data + 2 ) ; u_int addr_size = 4 ; int name_entries_valid = 0 ; u_int i ; if ( is_ipv6 ) addr_size = 16 ; if ( ( name_entries > 0 ) && ( ( name_entries * ( 4 + addr_size ) ) <= msg_tlen ) ) name_entries_valid = 1 ; if ( msg_tlen < 4 ) goto trunc ; ND_TCHECK2 ( * msg_data , 4 ) ; ND_PRINT ( ( ndo , ""\\n\\tVersion%u,Entries%u%s"" , EXTRACT_16BITS ( msg_data ) , name_entries , ( name_entries_valid == 0 ) ? ""(invalid)"" : """" ) ) ; if ( name_entries_valid == 0 ) break ; msg_data += 4 ; msg_tlen -= 4 ; for ( i = 0 ; i < name_entries ; i ++ ) { int name_entry_len_valid = 0 ; if ( msg_tlen < 4 ) break ; ND_TCHECK2 ( * msg_data , 4 ) ; name_entry_type = EXTRACT_16BITS ( msg_data ) ; name_entry_len = EXTRACT_16BITS ( msg_data + 2 ) ; msg_data += 4 ; msg_tlen -= 4 ; if ( ( name_entry_len > 0 ) && ( ( addr_size + name_entry_len ) <= msg_tlen ) ) name_entry_len_valid = 1 ; ND_PRINT ( ( ndo , ""\\n\\t#%u:type%#06x,length%u%s"" , ( unsigned int ) i , name_entry_type , name_entry_len , ( name_entry_len_valid == 0 ) ? ""(invalid)"" : """" ) ) ; if ( name_entry_len_valid == 0 ) break ; name_entry_padding = 0 ; if ( name_entry_len % 4 != 0 ) name_entry_padding = 4 - ( name_entry_len % 4 ) ; if ( msg_tlen < addr_size + name_entry_len + name_entry_padding ) goto trunc ; ND_TCHECK2 ( * msg_data , addr_size + name_entry_len + name_entry_padding ) ; if ( is_ipv6 ) ND_PRINT ( ( ndo , "",address%s,name\\"""" , ip6addr_string ( ndo , msg_data ) ) ) ; else ND_PRINT ( ( ndo , "",address%s,name\\"""" , ipaddr_string ( ndo , msg_data ) ) ) ; ( void ) fn_printn ( ndo , msg_data + addr_size , name_entry_len , NULL ) ; ND_PRINT ( ( ndo , ""\\"""" ) ) ; msg_data += addr_size + name_entry_len + name_entry_padding ; msg_tlen -= addr_size + name_entry_len + name_entry_padding ; } break ; } case OLSR_POWERINFO_MSG : default : print_unknown_data ( ndo , msg_data , ""\\n\\t"" , msg_tlen ) ; break ; } tptr += msg_len ; } return ; trunc : ND_PRINT ( ( ndo , ""[|olsr]"" ) ) ; } "," = 0 ; if ( is_ipv6 ) { sizeof ( struct olsr_msg6 ) ) ; msgptr . v6 } else { ND_TCHECK2 ( * tptr , sizeof ( struct olsr_msg4 ) ) ; { u_int name_entries ; u_int addr_size ; int name_entries_valid ; u_int i ; if ( msg_tlen < 4 ) goto trunc ; ND_TCHECK2 ( * msg_data , 4 ) ; name_entries 2 ) ; addr_size = 4 = 4 ; if ( is_ipv6 ) addr_size = 16 ; name_entries_valid = 0 name_entries_valid = 0 ; if ( name_entries_valid = 1 ; ND_PRINT ( ",the-tcpdump-group@tcpdump/0cb1b8a434b599b8d636db029aadb757c24e39d6,CVE-2017-13688,https://github.com/the-tcpdump-group/tcpdump/commit/0cb1b8a434b599b8d636db029aadb757c24e39d6,2017-09-14T06:29Z 745,CWE-119,"CWE-119 static void oz_usb_handle_ep_data ( struct oz_usb_ctx * usb_ctx , struct oz_usb_hdr * usb_hdr , int len ) { struct oz_data * data_hdr = ( struct oz_data * ) usb_hdr ; switch ( data_hdr -> format ) { case OZ_DATA_F_MULTIPLE_FIXED : { struct oz_multiple_fixed * body = ( struct oz_multiple_fixed * ) data_hdr ; u8 * data = body -> data ; int n ; if ( ! body -> unit_size ) break ; n = ( len - sizeof ( struct oz_multiple_fixed ) + 1 ) / body -> unit_size ; while ( n -- ) { oz_hcd_data_ind ( usb_ctx -> hport , body -> endpoint , data , body -> unit_size ) ; data += body -> unit_size ; } } break ; case OZ_DATA_F_ISOC_FIXED : { struct oz_isoc_fixed * body = ( struct oz_isoc_fixed * ) data_hdr ; int data_len = len - sizeof ( struct oz_isoc_fixed ) + 1 ; int unit_size = body -> unit_size ; u8 * data = body -> data ; int count ; int i ; if ( ! unit_size ) break ; count = data_len / unit_size ; for ( i = 0 ; i < count ; i ++ ) { oz_hcd_data_ind ( usb_ctx -> hport , body -> endpoint , data , unit_size ) ; data += unit_size ; } } break ; } } "," -> data ; unsigned body -> unit_size || len < sizeof ( struct oz_multiple_fixed ) - 1 ( len - ( struct oz_multiple_fixed ) - 1 ) ) / body ",torvalds@linux/9a59029bc218b48eff8b5d4dde5662fd79d3e1a8,CVE-2015-4002,https://github.com/torvalds/linux/commit/9a59029bc218b48eff8b5d4dde5662fd79d3e1a8,2015-06-07T23:59Z 746,CWE-119,"CWE-119 int vp8_receive_raw_frame ( VP8_COMP * cpi , unsigned int frame_flags , YV12_BUFFER_CONFIG * sd , int64_t time_stamp , int64_t end_time ) { # if HAVE_NEON int64_t store_reg [ 8 ] ; # if CONFIG_RUNTIME_CPU_DETECT VP8_COMMON * cm = & cpi -> common ; # endif # endif struct vpx_usec_timer timer ; int res = 0 ; # if HAVE_NEON # if CONFIG_RUNTIME_CPU_DETECT if ( cm -> cpu_caps & HAS_NEON ) # endif { vp8_push_neon ( store_reg ) ; } # endif vpx_usec_timer_start ( & timer ) ; if ( sd -> y_width != cpi -> oxcf . Width || sd -> y_height != cpi -> oxcf . Height ) { assert ( cpi -> oxcf . lag_in_frames < 2 ) ; dealloc_raw_frame_buffers ( cpi ) ; alloc_raw_frame_buffers ( cpi ) ; } if ( vp8_lookahead_push ( cpi -> lookahead , sd , time_stamp , end_time , frame_flags , cpi -> active_map_enabled ? cpi -> active_map : NULL ) ) res = - 1 ; vpx_usec_timer_mark ( & timer ) ; cpi -> time_receive_data += vpx_usec_timer_elapsed ( & timer ) ; # if HAVE_NEON # if CONFIG_RUNTIME_CPU_DETECT if ( cm -> cpu_caps & HAS_NEON ) # endif { vp8_pop_neon ( store_reg ) ; } # endif return res ; } "," end_time ) { struct vpx_usec_timer timer = 0 ; vpx_usec_timer_start ( & timer ) ; return res ; ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 747,CWE-269,"CWE-269 static int store_xauthority ( void ) { fs_build_mnt_dir ( ) ; char * src ; char * dest = RUN_XAUTHORITY_FILE ; FILE * fp = fopen ( dest , ""w"" ) ; if ( fp ) { fprintf ( fp , ""\\n"" ) ; SET_PERMS_STREAM ( fp , getuid ( ) , getgid ( ) , 0600 ) ; fclose ( fp ) ; } if ( asprintf ( & src , ""%s/.Xauthority"" , cfg . homedir ) == - 1 ) errExit ( ""asprintf"" ) ; struct stat s ; if ( stat ( src , & s ) == 0 ) { if ( is_link ( src ) ) { fprintf ( stderr , ""Error:invalid.Xauthorityfile\\n"" ) ; exit ( 1 ) ; } pid_t child = fork ( ) ; if ( child < 0 ) errExit ( ""fork"" ) ; if ( child == 0 ) { drop_privs ( 0 ) ; int rv = copy_file ( src , dest ) ; if ( rv ) fprintf ( stderr , ""Warning:cannottransfer.Xauthorityinprivatehomedirectory\\n"" ) ; else { fs_logger2 ( ""clone"" , dest ) ; } _exit ( 0 ) ; } waitpid ( child , NULL , 0 ) ; if ( chown ( dest , getuid ( ) , getgid ( ) ) == - 1 ) errExit ( ""fchown"" ) ; if ( chmod ( dest , 0600 ) == - 1 ) errExit ( ""fchmod"" ) ; return 1 ; } return 0 ; } "," ( stderr , ""Warning:invalid.Xauthorityfile\\n"" ) ; return 0 ; } copy_file_as_user ( src , ( src , dest , getuid getgid ( ) , 0600 ) ; fs_logger2 ( ""clone"" , dest ) ; return ",netblue30@firejail/903fd8a0789ca3cc3c21d84cd0282481515592ef,CVE-2017-5940,https://github.com/netblue30/firejail/commit/903fd8a0789ca3cc3c21d84cd0282481515592ef,2017-02-09T18:59Z 748,CWE-20,"CWE-20 static void cmd_parse_status ( struct ImapData * idata , char * s ) { char * value = NULL ; struct Buffy * inc = NULL ; struct ImapMbox mx ; struct ImapStatus * status = NULL ; unsigned int olduv , oldun ; unsigned int litlen ; short new = 0 ; short new_msg_count = 0 ; char * mailbox = imap_next_word ( s ) ; if ( imap_get_literal_count ( mailbox , & litlen ) == 0 ) { if ( imap_cmd_step ( idata ) != IMAP_CMD_CONTINUE ) { idata -> status = IMAP_FATAL ; return ; } mailbox = idata -> buf ; s = mailbox + litlen ; * s = '\\0' ; s ++ ; SKIPWS ( s ) ; } else { s = imap_next_word ( mailbox ) ; * ( s - 1 ) = '\\0' ; imap_unmunge_mbox_name ( idata , mailbox ) ; } status = imap_mboxcache_get ( idata , mailbox , 1 ) ; olduv = status -> uidvalidity ; oldun = status -> uidnext ; if ( * s ++ != '(' ) { mutt_debug ( 1 , ""ErrorparsingSTATUS\\n"" ) ; return ; } while ( * s && * s != ')' ) { value = imap_next_word ( s ) ; errno = 0 ; const unsigned long ulcount = strtoul ( value , & value , 10 ) ; if ( ( ( errno == ERANGE ) && ( ulcount == ULONG_MAX ) ) || ( ( unsigned int ) ulcount != ulcount ) ) { mutt_debug ( 1 , ""ErrorparsingSTATUSnumber\\n"" ) ; return ; } const unsigned int count = ( unsigned int ) ulcount ; if ( mutt_str_strncmp ( ""MESSAGES"" , s , 8 ) == 0 ) { status -> messages = count ; new_msg_count = 1 ; } else if ( mutt_str_strncmp ( ""RECENT"" , s , 6 ) == 0 ) status -> recent = count ; else if ( mutt_str_strncmp ( ""UIDNEXT"" , s , 7 ) == 0 ) status -> uidnext = count ; else if ( mutt_str_strncmp ( ""UIDVALIDITY"" , s , 11 ) == 0 ) status -> uidvalidity = count ; else if ( mutt_str_strncmp ( ""UNSEEN"" , s , 6 ) == 0 ) status -> unseen = count ; s = value ; if ( * s && * s != ')' ) s = imap_next_word ( s ) ; } mutt_debug ( 3 , ""%s(UIDVALIDITY:%u,UIDNEXT:%u)%dmessages,%drecent,%dunseen\\n"" , status -> name , status -> uidvalidity , status -> uidnext , status -> messages , status -> recent , status -> unseen ) ; if ( idata -> cmddata && idata -> cmdtype == IMAP_CT_STATUS ) { memcpy ( idata -> cmddata , status , sizeof ( struct ImapStatus ) ) ; return ; } mutt_debug ( 3 , ""RunningdefaultSTATUShandler\\n"" ) ; for ( inc = Incoming ; inc ; inc = inc -> next ) { if ( inc -> magic != MUTT_IMAP ) continue ; if ( imap_parse_path ( inc -> path , & mx ) < 0 ) { mutt_debug ( 1 , ""Errorparsingmailbox%s,skipping\\n"" , inc -> path ) ; continue ; } if ( imap_account_match ( & idata -> conn -> account , & mx . account ) ) { if ( mx . mbox ) { value = mutt_str_strdup ( mx . mbox ) ; imap_fix_path ( idata , mx . mbox , value , mutt_str_strlen ( value ) + 1 ) ; FREE ( & mx . mbox ) ; } else value = mutt_str_strdup ( ""INBOX"" ) ; if ( value && ( imap_mxcmp ( mailbox , value ) == 0 ) ) { mutt_debug ( 3 , ""Found%sinbuffylist(OV:%uON:%uU:%d)\\n"" , mailbox , olduv , oldun , status -> unseen ) ; if ( MailCheckRecent ) { if ( olduv && olduv == status -> uidvalidity ) { if ( oldun < status -> uidnext ) new = ( status -> unseen > 0 ) ; } else if ( ! olduv && ! oldun ) { new = ( status -> recent > 0 ) ; } else new = ( status -> unseen > 0 ) ; } else new = ( status -> unseen > 0 ) ; # ifdef USE_SIDEBAR if ( ( inc -> new != new ) || ( inc -> msg_count != status -> messages ) || ( inc -> msg_unread != status -> unseen ) ) { mutt_menu_set_current_redraw ( REDRAW_SIDEBAR ) ; } # endif inc -> new = new ; if ( new_msg_count ) inc -> msg_count = status -> messages ; inc -> msg_unread = status -> unseen ; if ( inc -> new ) { status -> uidnext = oldun ; } FREE ( & value ) ; return ; } FREE ( & value ) ; } FREE ( & mx . mbox ) ; } } "," status = IMAP_FATAL ; return ; } if ( strlen ( idata -> buf ) < litlen ) { mutt_debug ( 1 , ""ErrorparsingSTATUSmailbox\\n"" ) ",neomutt@neomutt/3c49c44be9b459d9c616bcaef6eb5d51298c1741,CVE-2018-14351,https://github.com/neomutt/neomutt/commit/3c49c44be9b459d9c616bcaef6eb5d51298c1741,2018-07-17T17:29Z 749,CWE-000,"CWE-000 int sas_discover_end_dev ( struct domain_device * dev ) { int res ; res = sas_notify_lldd_dev_found ( dev ) ; if ( res ) return res ; sas_discover_event ( dev -> port , DISCE_PROBE ) ; return 0 ; } "," return res ; return 0 ; ",torvalds@linux/0558f33c06bb910e2879e355192227a8e8f0219d,CVE-2017-18232,https://github.com/torvalds/linux/commit/0558f33c06bb910e2879e355192227a8e8f0219d,2018-03-15T04:29Z 750,CWE-908,"CWE-908 static int ext4_ext_split ( handle_t * handle , struct inode * inode , unsigned int flags , struct ext4_ext_path * path , struct ext4_extent * newext , int at ) { struct buffer_head * bh = NULL ; int depth = ext_depth ( inode ) ; struct ext4_extent_header * neh ; struct ext4_extent_idx * fidx ; int i = at , k , m , a ; ext4_fsblk_t newblock , oldblock ; __le32 border ; ext4_fsblk_t * ablocks = NULL ; int err = 0 ; if ( unlikely ( path [ depth ] . p_ext > EXT_MAX_EXTENT ( path [ depth ] . p_hdr ) ) ) { EXT4_ERROR_INODE ( inode , ""p_ext>EXT_MAX_EXTENT!"" ) ; return - EFSCORRUPTED ; } if ( path [ depth ] . p_ext != EXT_MAX_EXTENT ( path [ depth ] . p_hdr ) ) { border = path [ depth ] . p_ext [ 1 ] . ee_block ; ext_debug ( ""leafwillbesplit."" ""nextleafstartsat%d\\n"" , le32_to_cpu ( border ) ) ; } else { border = newext -> ee_block ; ext_debug ( ""leafwillbeadded."" ""nextleafstartsat%d\\n"" , le32_to_cpu ( border ) ) ; } ablocks = kcalloc ( depth , sizeof ( ext4_fsblk_t ) , GFP_NOFS ) ; if ( ! ablocks ) return - ENOMEM ; ext_debug ( ""allocate%dblocksforindexes/leaf\\n"" , depth - at ) ; for ( a = 0 ; a < depth - at ; a ++ ) { newblock = ext4_ext_new_meta_block ( handle , inode , path , newext , & err , flags ) ; if ( newblock == 0 ) goto cleanup ; ablocks [ a ] = newblock ; } newblock = ablocks [ -- a ] ; if ( unlikely ( newblock == 0 ) ) { EXT4_ERROR_INODE ( inode , ""newblock==0!"" ) ; err = - EFSCORRUPTED ; goto cleanup ; } bh = sb_getblk_gfp ( inode -> i_sb , newblock , __GFP_MOVABLE | GFP_NOFS ) ; if ( unlikely ( ! bh ) ) { err = - ENOMEM ; goto cleanup ; } lock_buffer ( bh ) ; err = ext4_journal_get_create_access ( handle , bh ) ; if ( err ) goto cleanup ; neh = ext_block_hdr ( bh ) ; neh -> eh_entries = 0 ; neh -> eh_max = cpu_to_le16 ( ext4_ext_space_block ( inode , 0 ) ) ; neh -> eh_magic = EXT4_EXT_MAGIC ; neh -> eh_depth = 0 ; if ( unlikely ( path [ depth ] . p_hdr -> eh_entries != path [ depth ] . p_hdr -> eh_max ) ) { EXT4_ERROR_INODE ( inode , ""eh_entries%d!=eh_max%d!"" , path [ depth ] . p_hdr -> eh_entries , path [ depth ] . p_hdr -> eh_max ) ; err = - EFSCORRUPTED ; goto cleanup ; } m = EXT_MAX_EXTENT ( path [ depth ] . p_hdr ) - path [ depth ] . p_ext ++ ; ext4_ext_show_move ( inode , path , newblock , depth ) ; if ( m ) { struct ext4_extent * ex ; ex = EXT_FIRST_EXTENT ( neh ) ; memmove ( ex , path [ depth ] . p_ext , sizeof ( struct ext4_extent ) * m ) ; le16_add_cpu ( & neh -> eh_entries , m ) ; } ext4_extent_block_csum_set ( inode , neh ) ; set_buffer_uptodate ( bh ) ; unlock_buffer ( bh ) ; err = ext4_handle_dirty_metadata ( handle , inode , bh ) ; if ( err ) goto cleanup ; brelse ( bh ) ; bh = NULL ; if ( m ) { err = ext4_ext_get_access ( handle , inode , path + depth ) ; if ( err ) goto cleanup ; le16_add_cpu ( & path [ depth ] . p_hdr -> eh_entries , - m ) ; err = ext4_ext_dirty ( handle , inode , path + depth ) ; if ( err ) goto cleanup ; } k = depth - at - 1 ; if ( unlikely ( k < 0 ) ) { EXT4_ERROR_INODE ( inode , ""k%d<0!"" , k ) ; err = - EFSCORRUPTED ; goto cleanup ; } if ( k ) ext_debug ( ""create%dintermediateindices\\n"" , k ) ; i = depth - 1 ; while ( k -- ) { oldblock = newblock ; newblock = ablocks [ -- a ] ; bh = sb_getblk ( inode -> i_sb , newblock ) ; if ( unlikely ( ! bh ) ) { err = - ENOMEM ; goto cleanup ; } lock_buffer ( bh ) ; err = ext4_journal_get_create_access ( handle , bh ) ; if ( err ) goto cleanup ; neh = ext_block_hdr ( bh ) ; neh -> eh_entries = cpu_to_le16 ( 1 ) ; neh -> eh_magic = EXT4_EXT_MAGIC ; neh -> eh_max = cpu_to_le16 ( ext4_ext_space_block_idx ( inode , 0 ) ) ; neh -> eh_depth = cpu_to_le16 ( depth - i ) ; fidx = EXT_FIRST_INDEX ( neh ) ; fidx -> ei_block = border ; ext4_idx_store_pblock ( fidx , oldblock ) ; ext_debug ( ""int.indexat%d(block%llu):%u->%llu\\n"" , i , newblock , le32_to_cpu ( border ) , oldblock ) ; if ( unlikely ( EXT_MAX_INDEX ( path [ i ] . p_hdr ) != EXT_LAST_INDEX ( path [ i ] . p_hdr ) ) ) { EXT4_ERROR_INODE ( inode , ""EXT_MAX_INDEX!=EXT_LAST_INDEXee_block%d!"" , le32_to_cpu ( path [ i ] . p_ext -> ee_block ) ) ; err = - EFSCORRUPTED ; goto cleanup ; } m = EXT_MAX_INDEX ( path [ i ] . p_hdr ) - path [ i ] . p_idx ++ ; ext_debug ( ""cur0x%p,last0x%p\\n"" , path [ i ] . p_idx , EXT_MAX_INDEX ( path [ i ] . p_hdr ) ) ; ext4_ext_show_move ( inode , path , newblock , i ) ; if ( m ) { memmove ( ++ fidx , path [ i ] . p_idx , sizeof ( struct ext4_extent_idx ) * m ) ; le16_add_cpu ( & neh -> eh_entries , m ) ; } ext4_extent_block_csum_set ( inode , neh ) ; set_buffer_uptodate ( bh ) ; unlock_buffer ( bh ) ; err = ext4_handle_dirty_metadata ( handle , inode , bh ) ; if ( err ) goto cleanup ; brelse ( bh ) ; bh = NULL ; if ( m ) { err = ext4_ext_get_access ( handle , inode , path + i ) ; if ( err ) goto cleanup ; le16_add_cpu ( & path [ i ] . p_hdr -> eh_entries , - m ) ; err = ext4_ext_dirty ( handle , inode , path + i ) ; if ( err ) goto cleanup ; } i -- ; } err = ext4_ext_insert_index ( handle , inode , path + at , le32_to_cpu ( border ) , newblock ) ; cleanup : if ( bh ) { if ( buffer_locked ( bh ) ) unlock_buffer ( bh ) ; brelse ( bh ) ; } if ( err ) { for ( i = 0 ; i < depth ; i ++ ) { if ( ! ablocks [ i ] ) continue ; ext4_free_blocks ( handle , inode , NULL , ablocks [ i ] , 1 , EXT4_FREE_BLOCKS_METADATA ) ; } } kfree ( ablocks ) ; return err ; } "," = 0 ; size_t ext_size = 0 ; ) ; } ext_size = sizeof ( struct ext4_extent_header ) + sizeof ( struct ext4_extent ) * le16_to_cpu ( neh -> eh_entries ) ; memset ( bh -> b_data + ext_size , 0 , inode -> i_sb -> s_blocksize - ext_size ) ; ) ; } ext_size = sizeof ( struct ext4_extent_header ) + ( sizeof ( struct ext4_extent ) * le16_to_cpu ( neh -> eh_entries ) ) ; memset ( bh -> b_data + ext_size , 0 , inode -> i_sb -> s_blocksize - ext_size ) ; ",torvalds@linux/592acbf16821288ecdc4192c47e3774a4c48bb64,CVE-2019-11833,https://github.com/torvalds/linux/commit/592acbf16821288ecdc4192c47e3774a4c48bb64,2019-05-15T13:29Z 751,CWE-787,"CWE-787 WORD32 ixheaacd_qmf_hbe_data_reinit ( ia_esbr_hbe_txposer_struct * ptr_hbe_txposer , WORD16 * p_freq_band_tab [ 2 ] , WORD16 * p_num_sfb , WORD32 upsamp_4_flag ) { WORD32 synth_size , sfb , patch , stop_patch ; if ( ptr_hbe_txposer != NULL ) { ptr_hbe_txposer -> start_band = p_freq_band_tab [ LOW ] [ 0 ] ; ptr_hbe_txposer -> end_band = p_freq_band_tab [ LOW ] [ p_num_sfb [ LOW ] ] ; ptr_hbe_txposer -> synth_size = 4 * ( ( ptr_hbe_txposer -> start_band + 4 ) / 8 + 1 ) ; ptr_hbe_txposer -> k_start = ixheaacd_start_subband2kL_tbl [ ptr_hbe_txposer -> start_band ] ; ptr_hbe_txposer -> upsamp_4_flag = upsamp_4_flag ; if ( upsamp_4_flag ) { if ( ptr_hbe_txposer -> k_start + ptr_hbe_txposer -> synth_size > 16 ) ptr_hbe_txposer -> k_start = 16 - ptr_hbe_txposer -> synth_size ; } else if ( ptr_hbe_txposer -> core_frame_length == 768 ) { if ( ptr_hbe_txposer -> k_start + ptr_hbe_txposer -> synth_size > 24 ) ptr_hbe_txposer -> k_start = 24 - ptr_hbe_txposer -> synth_size ; } memset ( ptr_hbe_txposer -> synth_buf , 0 , 1280 * sizeof ( FLOAT32 ) ) ; synth_size = ptr_hbe_txposer -> synth_size ; ptr_hbe_txposer -> synth_buf_offset = 18 * synth_size ; switch ( synth_size ) { case 4 : ptr_hbe_txposer -> synth_cos_tab = ( FLOAT32 * ) ixheaacd_synth_cos_table_kl_4 ; ptr_hbe_txposer -> analy_cos_sin_tab = ( FLOAT32 * ) ixheaacd_analy_cos_sin_table_kl_8 ; ixheaacd_real_synth_fft = & ixheaacd_real_synth_fft_p2 ; ixheaacd_cmplx_anal_fft = & ixheaacd_cmplx_anal_fft_p2 ; break ; case 8 : ptr_hbe_txposer -> synth_cos_tab = ( FLOAT32 * ) ixheaacd_synth_cos_table_kl_8 ; ptr_hbe_txposer -> analy_cos_sin_tab = ( FLOAT32 * ) ixheaacd_analy_cos_sin_table_kl_16 ; ixheaacd_real_synth_fft = & ixheaacd_real_synth_fft_p2 ; ixheaacd_cmplx_anal_fft = & ixheaacd_cmplx_anal_fft_p2 ; break ; case 12 : ptr_hbe_txposer -> synth_cos_tab = ( FLOAT32 * ) ixheaacd_synth_cos_table_kl_12 ; ptr_hbe_txposer -> analy_cos_sin_tab = ( FLOAT32 * ) ixheaacd_analy_cos_sin_table_kl_24 ; ixheaacd_real_synth_fft = & ixheaacd_real_synth_fft_p3 ; ixheaacd_cmplx_anal_fft = & ixheaacd_cmplx_anal_fft_p3 ; break ; case 16 : ptr_hbe_txposer -> synth_cos_tab = ( FLOAT32 * ) ixheaacd_synth_cos_table_kl_16 ; ptr_hbe_txposer -> analy_cos_sin_tab = ( FLOAT32 * ) ixheaacd_analy_cos_sin_table_kl_32 ; ixheaacd_real_synth_fft = & ixheaacd_real_synth_fft_p2 ; ixheaacd_cmplx_anal_fft = & ixheaacd_cmplx_anal_fft_p2 ; break ; case 20 : ptr_hbe_txposer -> synth_cos_tab = ( FLOAT32 * ) ixheaacd_synth_cos_table_kl_20 ; ptr_hbe_txposer -> analy_cos_sin_tab = ( FLOAT32 * ) ixheaacd_analy_cos_sin_table_kl_40 ; break ; default : ptr_hbe_txposer -> synth_cos_tab = ( FLOAT32 * ) ixheaacd_synth_cos_table_kl_4 ; ptr_hbe_txposer -> analy_cos_sin_tab = ( FLOAT32 * ) ixheaacd_analy_cos_sin_table_kl_8 ; ixheaacd_real_synth_fft = & ixheaacd_real_synth_fft_p2 ; ixheaacd_cmplx_anal_fft = & ixheaacd_cmplx_anal_fft_p2 ; } ptr_hbe_txposer -> synth_wind_coeff = ixheaacd_map_prot_filter ( synth_size ) ; memset ( ptr_hbe_txposer -> analy_buf , 0 , 640 * sizeof ( FLOAT32 ) ) ; synth_size = 2 * ptr_hbe_txposer -> synth_size ; ptr_hbe_txposer -> analy_wind_coeff = ixheaacd_map_prot_filter ( synth_size ) ; memset ( ptr_hbe_txposer -> x_over_qmf , 0 , MAX_NUM_PATCHES * sizeof ( WORD32 ) ) ; sfb = 0 ; if ( upsamp_4_flag ) { stop_patch = MAX_NUM_PATCHES ; ptr_hbe_txposer -> max_stretch = MAX_STRETCH ; } else { stop_patch = MAX_STRETCH ; } for ( patch = 1 ; patch <= stop_patch ; patch ++ ) { while ( sfb <= p_num_sfb [ LOW ] && p_freq_band_tab [ LOW ] [ sfb ] <= patch * ptr_hbe_txposer -> start_band ) sfb ++ ; if ( sfb <= p_num_sfb [ LOW ] ) { if ( ( patch * ptr_hbe_txposer -> start_band - p_freq_band_tab [ LOW ] [ sfb - 1 ] ) <= 3 ) { ptr_hbe_txposer -> x_over_qmf [ patch - 1 ] = p_freq_band_tab [ LOW ] [ sfb - 1 ] ; } else { WORD32 sfb = 0 ; while ( sfb <= p_num_sfb [ HIGH ] && p_freq_band_tab [ HIGH ] [ sfb ] <= patch * ptr_hbe_txposer -> start_band ) sfb ++ ; ptr_hbe_txposer -> x_over_qmf [ patch - 1 ] = p_freq_band_tab [ HIGH ] [ sfb - 1 ] ; } } else { ptr_hbe_txposer -> x_over_qmf [ patch - 1 ] = ptr_hbe_txposer -> end_band ; ptr_hbe_txposer -> max_stretch = min ( patch , MAX_STRETCH ) ; break ; } } } if ( ptr_hbe_txposer -> k_start < 0 ) { return - 1 ; } return 0 ; } "," ) ixheaacd_analy_cos_sin_table_kl_8 ; ptr_hbe_txposer -> & ixheaacd_real_synth_fft_p2 ; ptr_hbe_txposer -> ) ixheaacd_analy_cos_sin_table_kl_16 ; ptr_hbe_txposer -> & ixheaacd_real_synth_fft_p2 ; ptr_hbe_txposer -> ) ixheaacd_analy_cos_sin_table_kl_24 ; ptr_hbe_txposer -> & ixheaacd_real_synth_fft_p3 ; ptr_hbe_txposer -> ) ixheaacd_analy_cos_sin_table_kl_32 ; ptr_hbe_txposer -> & ixheaacd_real_synth_fft_p2 ; ptr_hbe_txposer -> ) ixheaacd_analy_cos_sin_table_kl_8 ; ptr_hbe_txposer -> & ixheaacd_real_synth_fft_p2 ; ptr_hbe_txposer -> ; break ; } } if 1 ; } } ",external@libxaac/04e8cd58f075bec5892e369c8deebca9c67e855c,CVE-2018-9496,https://android.googlesource.com/platform/external/libxaac/+/04e8cd58f075bec5892e369c8deebca9c67e855c,2018-10-02T19:29Z 752,CWE-787,"CWE-787 static int tga_readheader ( FILE * fp , unsigned int * bits_per_pixel , unsigned int * width , unsigned int * height , int * flip_image ) { int palette_size ; unsigned char tga [ TGA_HEADER_SIZE ] ; unsigned char id_len , image_type ; unsigned char pixel_depth , image_desc ; unsigned short cmap_len , cmap_entry_size ; unsigned short image_w , image_h ; if ( ! bits_per_pixel || ! width || ! height || ! flip_image ) { return 0 ; } if ( fread ( tga , TGA_HEADER_SIZE , 1 , fp ) != 1 ) { fprintf ( stderr , ""\\nError:freadreturnanumberofelementdifferentfromtheexpected.\\n"" ) ; return 0 ; } id_len = tga [ 0 ] ; image_type = tga [ 2 ] ; cmap_len = get_ushort ( & tga [ 5 ] ) ; cmap_entry_size = tga [ 7 ] ; # if 0 x_origin = get_ushort ( & tga [ 8 ] ) ; y_origin = get_ushort ( & tga [ 10 ] ) ; # endif image_w = get_ushort ( & tga [ 12 ] ) ; image_h = get_ushort ( & tga [ 14 ] ) ; pixel_depth = tga [ 16 ] ; image_desc = tga [ 17 ] ; * bits_per_pixel = ( unsigned int ) pixel_depth ; * width = ( unsigned int ) image_w ; * height = ( unsigned int ) image_h ; if ( id_len ) { unsigned char * id = ( unsigned char * ) malloc ( id_len ) ; if ( id == 0 ) { fprintf ( stderr , ""tga_readheader:memoryout\\n"" ) ; return 0 ; } if ( ! fread ( id , id_len , 1 , fp ) ) { fprintf ( stderr , ""\\nError:freadreturnanumberofelementdifferentfromtheexpected.\\n"" ) ; free ( id ) ; return 0 ; } free ( id ) ; } if ( image_type > 8 ) { fprintf ( stderr , ""Sorry,compressedtgafilesarenotcurrentlysupported.\\n"" ) ; return 0 ; } * flip_image = ! ( image_desc & 32 ) ; palette_size = cmap_len * ( cmap_entry_size / 8 ) ; if ( palette_size > 0 ) { fprintf ( stderr , ""Filecontainsapalette-notyetsupported."" ) ; fseek ( fp , palette_size , SEEK_CUR ) ; } return 1 ; } "," ; cmap_len = get_tga_ushort ( & tga 0 x_origin = get_tga_ushort ( & tga ; y_origin = get_tga_ushort ( & tga endif image_w = get_tga_ushort ( & tga ; image_h = get_tga_ushort ( & tga ",uclouvain@openjpeg/2cd30c2b06ce332dede81cccad8b334cde997281,CVE-2017-14040,https://github.com/uclouvain/openjpeg/commit/2cd30c2b06ce332dede81cccad8b334cde997281,2017-08-30T22:29Z 753,CWE-264,"CWE-264 static ssize_t ucma_write ( struct file * filp , const char __user * buf , size_t len , loff_t * pos ) { struct ucma_file * file = filp -> private_data ; struct rdma_ucm_cmd_hdr hdr ; ssize_t ret ; if ( len < sizeof ( hdr ) ) return - EINVAL ; if ( copy_from_user ( & hdr , buf , sizeof ( hdr ) ) ) return - EFAULT ; if ( hdr . cmd >= ARRAY_SIZE ( ucma_cmd_table ) ) return - EINVAL ; if ( hdr . in + sizeof ( hdr ) > len ) return - EINVAL ; if ( ! ucma_cmd_table [ hdr . cmd ] ) return - ENOSYS ; ret = ucma_cmd_table [ hdr . cmd ] ( file , buf + sizeof ( hdr ) , hdr . in , hdr . out ) ; if ( ! ret ) ret = len ; return ret ; } "," ; ssize_t ret ; if ( WARN_ON_ONCE ( ! ib_safe_file_access ( filp ) ) ) return - EACCES ",torvalds@linux/e6bd18f57aad1a2d1ef40e646d03ed0f2515c9e3,CVE-2016-4565,https://github.com/torvalds/linux/commit/e6bd18f57aad1a2d1ef40e646d03ed0f2515c9e3,2016-05-23T10:59Z 754,CWE-189,"CWE-189 static void sample_to_timespec ( const clockid_t which_clock , union cpu_time_count cpu , struct timespec * tp ) { if ( CPUCLOCK_WHICH ( which_clock ) == CPUCLOCK_SCHED ) { tp -> tv_sec = div_long_long_rem ( cpu . sched , NSEC_PER_SEC , & tp -> tv_nsec ) ; } else { cputime_to_timespec ( cpu . cpu , tp ) ; } } "," == CPUCLOCK_SCHED ) * tp = ns_to_timespec ( cpu . cpu . sched ) ; else cputime_to_timespec ( cpu ) ; } ",torvalds@linux/f8bd2258e2d520dff28c855658bd24bdafb5102d,CVE-2011-3209,https://github.com/torvalds/linux/commit/f8bd2258e2d520dff28c855658bd24bdafb5102d,2012-10-03T11:02Z 755,CWE-125,"CWE-125 uint32 TIFFNumberOfStrips ( TIFF * tif ) { TIFFDirectory * td = & tif -> tif_dir ; uint32 nstrips ; if ( td -> td_nstrips ) return td -> td_nstrips ; nstrips = ( td -> td_rowsperstrip == ( uint32 ) - 1 ? 1 : TIFFhowmany_32 ( td -> td_imagelength , td -> td_rowsperstrip ) ) ; if ( td -> td_planarconfig == PLANARCONFIG_SEPARATE ) nstrips = _TIFFMultiply32 ( tif , nstrips , ( uint32 ) td -> td_samplesperpixel , ""TIFFNumberOfStrips"" ) ; return ( nstrips ) ; } "," ; uint32 nstrips ; nstrips = ",vadz@libtiff/9a72a69e035ee70ff5c41541c8c61cd97990d018,CVE-2016-10270,https://github.com/vadz/libtiff/commit/9a72a69e035ee70ff5c41541c8c61cd97990d018,2017-03-24T19:59Z 756,CWE-20,"CWE-20 int rds_recvmsg ( struct kiocb * iocb , struct socket * sock , struct msghdr * msg , size_t size , int msg_flags ) { struct sock * sk = sock -> sk ; struct rds_sock * rs = rds_sk_to_rs ( sk ) ; long timeo ; int ret = 0 , nonblock = msg_flags & MSG_DONTWAIT ; struct sockaddr_in * sin ; struct rds_incoming * inc = NULL ; timeo = sock_rcvtimeo ( sk , nonblock ) ; rdsdebug ( ""size%zuflags0x%xtimeo%ld\\n"" , size , msg_flags , timeo ) ; msg -> msg_namelen = 0 ; if ( msg_flags & MSG_OOB ) goto out ; while ( 1 ) { if ( ! list_empty ( & rs -> rs_notify_queue ) ) { ret = rds_notify_queue_get ( rs , msg ) ; break ; } if ( rs -> rs_cong_notify ) { ret = rds_notify_cong ( rs , msg ) ; break ; } if ( ! rds_next_incoming ( rs , & inc ) ) { if ( nonblock ) { ret = - EAGAIN ; break ; } timeo = wait_event_interruptible_timeout ( * sk_sleep ( sk ) , ( ! list_empty ( & rs -> rs_notify_queue ) || rs -> rs_cong_notify || rds_next_incoming ( rs , & inc ) ) , timeo ) ; rdsdebug ( ""recvmsgwokeinc%ptimeo%ld\\n"" , inc , timeo ) ; if ( timeo > 0 || timeo == MAX_SCHEDULE_TIMEOUT ) continue ; ret = timeo ; if ( ret == 0 ) ret = - ETIMEDOUT ; break ; } rdsdebug ( ""copyinginc%pfrom%pI4:%utouser\\n"" , inc , & inc -> i_conn -> c_faddr , ntohs ( inc -> i_hdr . h_sport ) ) ; ret = inc -> i_conn -> c_trans -> inc_copy_to_user ( inc , msg -> msg_iov , size ) ; if ( ret < 0 ) break ; if ( ! rds_still_queued ( rs , inc , ! ( msg_flags & MSG_PEEK ) ) ) { rds_inc_put ( inc ) ; inc = NULL ; rds_stats_inc ( s_recv_deliver_raced ) ; continue ; } if ( ret < be32_to_cpu ( inc -> i_hdr . h_len ) ) { if ( msg_flags & MSG_TRUNC ) ret = be32_to_cpu ( inc -> i_hdr . h_len ) ; msg -> msg_flags |= MSG_TRUNC ; } if ( rds_cmsg_recv ( inc , msg ) ) { ret = - EFAULT ; goto out ; } rds_stats_inc ( s_recv_delivered ) ; sin = ( struct sockaddr_in * ) msg -> msg_name ; if ( sin ) { sin -> sin_family = AF_INET ; sin -> sin_port = inc -> i_hdr . h_sport ; sin -> sin_addr . s_addr = inc -> i_saddr ; memset ( sin -> sin_zero , 0 , sizeof ( sin -> sin_zero ) ) ; msg -> msg_namelen = sizeof ( * sin ) ; } break ; } if ( inc ) rds_inc_put ( inc ) ; out : return ret ; } "," , timeo ) ; if ( ",torvalds@linux/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,CVE-2013-7271,https://github.com/torvalds/linux/commit/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,2014-01-06T16:55Z 757,CWE-264,"CWE-264 static authz_status lua_authz_check ( request_rec * r , const char * require_line , const void * parsed_require_line ) { apr_pool_t * pool ; ap_lua_vm_spec * spec ; lua_State * L ; ap_lua_server_cfg * server_cfg = ap_get_module_config ( r -> server -> module_config , & lua_module ) ; const ap_lua_dir_cfg * cfg = ap_get_module_config ( r -> per_dir_config , & lua_module ) ; const lua_authz_provider_spec * prov_spec = parsed_require_line ; int result ; int nargs = 0 ; spec = create_vm_spec ( & pool , r , cfg , server_cfg , prov_spec -> file_name , NULL , 0 , prov_spec -> function_name , ""authzprovider"" ) ; L = ap_lua_get_lua_state ( pool , spec , r ) ; if ( L == NULL ) { ap_log_rerror ( APLOG_MARK , APLOG_ERR , 0 , r , APLOGNO ( 02314 ) ""UnabletocompileVMforauthzprovider%s"" , prov_spec -> name ) ; return AUTHZ_GENERAL_ERROR ; } lua_getglobal ( L , prov_spec -> function_name ) ; if ( ! lua_isfunction ( L , - 1 ) ) { ap_log_rerror ( APLOG_MARK , APLOG_CRIT , 0 , r , APLOGNO ( 02319 ) ""Unabletofindentryfunction\'%s\'in%s(notavalidfunction)"" , prov_spec -> function_name , prov_spec -> file_name ) ; ap_lua_release_state ( L , spec , r ) ; return AUTHZ_GENERAL_ERROR ; } ap_lua_run_lua_request ( L , r ) ; if ( prov_spec -> args ) { int i ; if ( ! lua_checkstack ( L , prov_spec -> args -> nelts ) ) { ap_log_rerror ( APLOG_MARK , APLOG_ERR , 0 , r , APLOGNO ( 02315 ) ""Error:authzprovider%s:toomanyarguments"" , prov_spec -> name ) ; ap_lua_release_state ( L , spec , r ) ; return AUTHZ_GENERAL_ERROR ; } for ( i = 0 ; i < prov_spec -> args -> nelts ; i ++ ) { const char * arg = APR_ARRAY_IDX ( prov_spec -> args , i , const char * ) ; lua_pushstring ( L , arg ) ; } nargs = prov_spec -> args -> nelts ; } if ( lua_pcall ( L , 1 + nargs , 1 , 0 ) ) { const char * err = lua_tostring ( L , - 1 ) ; ap_log_rerror ( APLOG_MARK , APLOG_ERR , 0 , r , APLOGNO ( 02316 ) ""Errorexecutingauthzprovider%s:%s"" , prov_spec -> name , err ) ; ap_lua_release_state ( L , spec , r ) ; return AUTHZ_GENERAL_ERROR ; } if ( ! lua_isnumber ( L , - 1 ) ) { ap_log_rerror ( APLOG_MARK , APLOG_ERR , 0 , r , APLOGNO ( 02317 ) ""Error:authzprovider%sdidnotreturninteger"" , prov_spec -> name ) ; ap_lua_release_state ( L , spec , r ) ; return AUTHZ_GENERAL_ERROR ; } result = lua_tointeger ( L , - 1 ) ; ap_lua_release_state ( L , spec , r ) ; switch ( result ) { case AUTHZ_DENIED : case AUTHZ_GRANTED : case AUTHZ_NEUTRAL : case AUTHZ_GENERAL_ERROR : case AUTHZ_DENIED_NO_USER : return result ; default : ap_log_rerror ( APLOG_MARK , APLOG_ERR , 0 , r , APLOGNO ( 02318 ) ""Error:authzprovider%s:invalidreturnvalue%d"" , prov_spec -> name , result ) ; } return AUTHZ_GENERAL_ERROR ; } "," ) ; const lua_authz_provider_func * prov_func = parsed_require_line ; const * prov_spec = prov_func -> spec ; int result ; if ( prov_func -> args ) ( L , prov_func -> args -> ; i < prov_func -> args -> = APR_ARRAY_IDX ( prov_func -> args , } nargs = prov_func -> args -> ",apache@httpd/3f1693d558d0758f829c8b53993f1749ddf6ffcb,CVE-2014-8109,https://github.com/apache/httpd/commit/3f1693d558d0758f829c8b53993f1749ddf6ffcb,2014-12-29T23:59Z 758,CWE-476,"CWE-476 int expand_downwards ( struct vm_area_struct * vma , unsigned long address ) { struct mm_struct * mm = vma -> vm_mm ; struct vm_area_struct * prev ; int error ; address &= PAGE_MASK ; error = security_mmap_addr ( address ) ; if ( error ) return error ; prev = vma -> vm_prev ; if ( prev && ! ( prev -> vm_flags & VM_GROWSDOWN ) && ( prev -> vm_flags & ( VM_WRITE | VM_READ | VM_EXEC ) ) ) { if ( address - prev -> vm_end < stack_guard_gap ) return - ENOMEM ; } if ( unlikely ( anon_vma_prepare ( vma ) ) ) return - ENOMEM ; anon_vma_lock_write ( vma -> anon_vma ) ; if ( address < vma -> vm_start ) { unsigned long size , grow ; size = vma -> vm_end - address ; grow = ( vma -> vm_start - address ) >> PAGE_SHIFT ; error = - ENOMEM ; if ( grow <= vma -> vm_pgoff ) { error = acct_stack_growth ( vma , size , grow ) ; if ( ! error ) { spin_lock ( & mm -> page_table_lock ) ; if ( vma -> vm_flags & VM_LOCKED ) mm -> locked_vm += grow ; vm_stat_account ( mm , vma -> vm_flags , grow ) ; anon_vma_interval_tree_pre_update_vma ( vma ) ; vma -> vm_start = address ; vma -> vm_pgoff -= grow ; anon_vma_interval_tree_post_update_vma ( vma ) ; vma_gap_update ( vma ) ; spin_unlock ( & mm -> page_table_lock ) ; perf_event_mmap ( vma ) ; } } } anon_vma_unlock_write ( vma -> anon_vma ) ; khugepaged_enter_vma_merge ( vma , vma -> vm_flags ) ; validate_mm ( mm ) ; return error ; } "," ; int error = 0 &= PAGE_MASK ; if ( address < mmap_min_addr ) return - EPERM ; prev = ",torvalds@linux/0a1d52994d440e21def1c2174932410b4f2a98a1,CVE-2019-9213,https://github.com/torvalds/linux/commit/0a1d52994d440e21def1c2174932410b4f2a98a1,2019-03-05T22:29Z 759,CWE-285,"CWE-285 int xfs_set_acl ( struct inode * inode , struct posix_acl * acl , int type ) { int error = 0 ; if ( ! acl ) goto set_acl ; error = - E2BIG ; if ( acl -> a_count > XFS_ACL_MAX_ENTRIES ( XFS_M ( inode -> i_sb ) ) ) return error ; if ( type == ACL_TYPE_ACCESS ) { umode_t mode = inode -> i_mode ; error = posix_acl_equiv_mode ( acl , & mode ) ; if ( error <= 0 ) { acl = NULL ; if ( error < 0 ) return error ; } error = xfs_set_mode ( inode , mode ) ; if ( error ) return error ; } set_acl : return __xfs_set_acl ( inode , type , acl ) ; } "," { umode_t mode ; error = ; error = posix_acl_update_mode ( inode , & mode , & mode , & acl if ( error ) return error return error ; error = xfs_set_mode ",torvalds@linux/073931017b49d9458aa351605b43a7e34598caef,CVE-2016-7097,https://github.com/torvalds/linux/commit/073931017b49d9458aa351605b43a7e34598caef,2016-10-16T21:59Z 760,CWE-59,"CWE-59 static int mount_entry ( const char * fsname , const char * target , const char * fstype , unsigned long mountflags , const char * data , int optional ) { # ifdef HAVE_STATVFS struct statvfs sb ; # endif if ( mount ( fsname , target , fstype , mountflags & ~ MS_REMOUNT , data ) ) { if ( optional ) { INFO ( ""failedtomount\'%s\'on\'%s\'(optional):%s"" , fsname , target , strerror ( errno ) ) ; return 0 ; } else { SYSERROR ( ""failedtomount\'%s\'on\'%s\'"" , fsname , target ) ; return - 1 ; } } if ( ( mountflags & MS_REMOUNT ) || ( mountflags & MS_BIND ) ) { DEBUG ( ""remounting%son%storespectbindorremountoptions"" , fsname ? fsname : ""(none)"" , target ? target : ""(none)"" ) ; unsigned long rqd_flags = 0 ; if ( mountflags & MS_RDONLY ) rqd_flags |= MS_RDONLY ; # ifdef HAVE_STATVFS if ( statvfs ( fsname , & sb ) == 0 ) { unsigned long required_flags = rqd_flags ; if ( sb . f_flag & MS_NOSUID ) required_flags |= MS_NOSUID ; if ( sb . f_flag & MS_NODEV ) required_flags |= MS_NODEV ; if ( sb . f_flag & MS_RDONLY ) required_flags |= MS_RDONLY ; if ( sb . f_flag & MS_NOEXEC ) required_flags |= MS_NOEXEC ; DEBUG ( ""(atremount)flagsfor%swas%lu,requiredextraflagsare%lu"" , fsname , sb . f_flag , required_flags ) ; if ( ! ( mountflags & MS_REMOUNT ) ) { if ( ! ( required_flags & ~ mountflags ) && rqd_flags == 0 ) { DEBUG ( ""mountflagsalreadywas%lu,skippingremount"" , mountflags ) ; goto skipremount ; } } mountflags |= required_flags ; } # endif if ( mount ( fsname , target , fstype , mountflags | MS_REMOUNT , data ) ) { if ( optional ) { INFO ( ""failedtomount\'%s\'on\'%s\'(optional):%s"" , fsname , target , strerror ( errno ) ) ; return 0 ; } else { SYSERROR ( ""failedtomount\'%s\'on\'%s\'"" , fsname , target ) ; return - 1 ; } } } # ifdef HAVE_STATVFS skipremount : # endif DEBUG ( ""mounted\'%s\'on\'%s\',type\'%s\'"" , fsname , target , fstype ) ; return 0 ; } "," , int optional , const char * rootfs endif if ( safe_mount ( fsname , MS_REMOUNT , data , rootfs , data ) < 0 ",lxc@lxc/592fd47a6245508b79fe6ac819fe6d3b2c1289be,CVE-2015-1335,https://github.com/lxc/lxc/commit/592fd47a6245508b79fe6ac819fe6d3b2c1289be,2015-10-01T20:59Z 761,CWE-119,"CWE-119 static Image * ReadDPXImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { char magick [ 4 ] , value [ MaxTextExtent ] ; DPXInfo dpx ; Image * image ; MagickBooleanType status ; MagickOffsetType offset ; QuantumInfo * quantum_info ; QuantumType quantum_type ; register ssize_t i ; size_t extent , samples_per_pixel ; ssize_t count , n , row , y ; unsigned char component_type ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } offset = 0 ; count = ReadBlob ( image , 4 , ( unsigned char * ) magick ) ; offset += count ; if ( ( count != 4 ) || ( ( LocaleNCompare ( magick , ""SDPX"" , 4 ) != 0 ) && ( LocaleNCompare ( ( char * ) magick , ""XPDS"" , 4 ) != 0 ) ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; image -> endian = LSBEndian ; if ( LocaleNCompare ( magick , ""SDPX"" , 4 ) == 0 ) image -> endian = MSBEndian ; ( void ) ResetMagickMemory ( & dpx , 0 , sizeof ( dpx ) ) ; dpx . file . image_offset = ReadBlobLong ( image ) ; offset += 4 ; offset += ReadBlob ( image , sizeof ( dpx . file . version ) , ( unsigned char * ) dpx . file . version ) ; ( void ) FormatImageProperty ( image , ""dpx:file.version"" , ""%.8s"" , dpx . file . version ) ; dpx . file . file_size = ReadBlobLong ( image ) ; offset += 4 ; dpx . file . ditto_key = ReadBlobLong ( image ) ; offset += 4 ; if ( dpx . file . ditto_key != ~ 0U ) ( void ) FormatImageProperty ( image , ""dpx:file.ditto.key"" , ""%u"" , dpx . file . ditto_key ) ; dpx . file . generic_size = ReadBlobLong ( image ) ; offset += 4 ; dpx . file . industry_size = ReadBlobLong ( image ) ; offset += 4 ; dpx . file . user_size = ReadBlobLong ( image ) ; offset += 4 ; offset += ReadBlob ( image , sizeof ( dpx . file . filename ) , ( unsigned char * ) dpx . file . filename ) ; ( void ) FormatImageProperty ( image , ""dpx:file.filename"" , ""%.100s"" , dpx . file . filename ) ; ( void ) FormatImageProperty ( image , ""document"" , ""%.100s"" , dpx . file . filename ) ; offset += ReadBlob ( image , sizeof ( dpx . file . timestamp ) , ( unsigned char * ) dpx . file . timestamp ) ; if ( * dpx . file . timestamp != '\\0' ) ( void ) FormatImageProperty ( image , ""dpx:file.timestamp"" , ""%.24s"" , dpx . file . timestamp ) ; offset += ReadBlob ( image , sizeof ( dpx . file . creator ) , ( unsigned char * ) dpx . file . creator ) ; if ( * dpx . file . creator == '\\0' ) { ( void ) FormatImageProperty ( image , ""dpx:file.creator"" , ""%.100s"" , GetMagickVersion ( ( size_t * ) NULL ) ) ; ( void ) FormatImageProperty ( image , ""software"" , ""%.100s"" , GetMagickVersion ( ( size_t * ) NULL ) ) ; } else { ( void ) FormatImageProperty ( image , ""dpx:file.creator"" , ""%.100s"" , dpx . file . creator ) ; ( void ) FormatImageProperty ( image , ""software"" , ""%.100s"" , dpx . file . creator ) ; } offset += ReadBlob ( image , sizeof ( dpx . file . project ) , ( unsigned char * ) dpx . file . project ) ; if ( * dpx . file . project != '\\0' ) { ( void ) FormatImageProperty ( image , ""dpx:file.project"" , ""%.200s"" , dpx . file . project ) ; ( void ) FormatImageProperty ( image , ""comment"" , ""%.100s"" , dpx . file . project ) ; } offset += ReadBlob ( image , sizeof ( dpx . file . copyright ) , ( unsigned char * ) dpx . file . copyright ) ; if ( * dpx . file . copyright != '\\0' ) { ( void ) FormatImageProperty ( image , ""dpx:file.copyright"" , ""%.200s"" , dpx . file . copyright ) ; ( void ) FormatImageProperty ( image , ""copyright"" , ""%.100s"" , dpx . file . copyright ) ; } dpx . file . encrypt_key = ReadBlobLong ( image ) ; offset += 4 ; if ( dpx . file . encrypt_key != ~ 0U ) ( void ) FormatImageProperty ( image , ""dpx:file.encrypt_key"" , ""%u"" , dpx . file . encrypt_key ) ; offset += ReadBlob ( image , sizeof ( dpx . file . reserve ) , ( unsigned char * ) dpx . file . reserve ) ; dpx . image . orientation = ReadBlobShort ( image ) ; if ( dpx . image . orientation > 7 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; offset += 2 ; if ( dpx . image . orientation != ( unsigned short ) ~ 0 ) ( void ) FormatImageProperty ( image , ""dpx:image.orientation"" , ""%d"" , dpx . image . orientation ) ; switch ( dpx . image . orientation ) { default : case 0 : image -> orientation = TopLeftOrientation ; break ; case 1 : image -> orientation = TopRightOrientation ; break ; case 2 : image -> orientation = BottomLeftOrientation ; break ; case 3 : image -> orientation = BottomRightOrientation ; break ; case 4 : image -> orientation = LeftTopOrientation ; break ; case 5 : image -> orientation = RightTopOrientation ; break ; case 6 : image -> orientation = LeftBottomOrientation ; break ; case 7 : image -> orientation = RightBottomOrientation ; break ; } dpx . image . number_elements = ReadBlobShort ( image ) ; if ( dpx . image . number_elements > MaxNumberImageElements ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; offset += 2 ; dpx . image . pixels_per_line = ReadBlobLong ( image ) ; offset += 4 ; image -> columns = dpx . image . pixels_per_line ; dpx . image . lines_per_element = ReadBlobLong ( image ) ; offset += 4 ; image -> rows = dpx . image . lines_per_element ; for ( i = 0 ; i < 8 ; i ++ ) { char property [ MaxTextExtent ] ; dpx . image . image_element [ i ] . data_sign = ReadBlobLong ( image ) ; offset += 4 ; dpx . image . image_element [ i ] . low_data = ReadBlobLong ( image ) ; offset += 4 ; dpx . image . image_element [ i ] . low_quantity = ReadBlobFloat ( image ) ; offset += 4 ; dpx . image . image_element [ i ] . high_data = ReadBlobLong ( image ) ; offset += 4 ; dpx . image . image_element [ i ] . high_quantity = ReadBlobFloat ( image ) ; offset += 4 ; dpx . image . image_element [ i ] . descriptor = ( unsigned char ) ReadBlobByte ( image ) ; offset ++ ; dpx . image . image_element [ i ] . transfer_characteristic = ( unsigned char ) ReadBlobByte ( image ) ; ( void ) FormatLocaleString ( property , MaxTextExtent , ""dpx:image.element[%lu].transfer-characteristic"" , ( long ) i ) ; ( void ) FormatImageProperty ( image , property , ""%s"" , GetImageTransferCharacteristic ( ( DPXTransferCharacteristic ) dpx . image . image_element [ i ] . transfer_characteristic ) ) ; offset ++ ; dpx . image . image_element [ i ] . colorimetric = ( unsigned char ) ReadBlobByte ( image ) ; offset ++ ; dpx . image . image_element [ i ] . bit_size = ( unsigned char ) ReadBlobByte ( image ) ; offset ++ ; dpx . image . image_element [ i ] . packing = ReadBlobShort ( image ) ; offset += 2 ; dpx . image . image_element [ i ] . encoding = ReadBlobShort ( image ) ; offset += 2 ; dpx . image . image_element [ i ] . data_offset = ReadBlobLong ( image ) ; offset += 4 ; dpx . image . image_element [ i ] . end_of_line_padding = ReadBlobLong ( image ) ; offset += 4 ; dpx . image . image_element [ i ] . end_of_image_padding = ReadBlobLong ( image ) ; offset += 4 ; offset += ReadBlob ( image , sizeof ( dpx . image . image_element [ i ] . description ) , ( unsigned char * ) dpx . image . image_element [ i ] . description ) ; } ( void ) SetImageColorspace ( image , RGBColorspace ) ; offset += ReadBlob ( image , sizeof ( dpx . image . reserve ) , ( unsigned char * ) dpx . image . reserve ) ; if ( dpx . file . image_offset >= 1664U ) { dpx . orientation . x_offset = ReadBlobLong ( image ) ; offset += 4 ; if ( dpx . orientation . x_offset != ~ 0U ) ( void ) FormatImageProperty ( image , ""dpx:orientation.x_offset"" , ""%u"" , dpx . orientation . x_offset ) ; dpx . orientation . y_offset = ReadBlobLong ( image ) ; offset += 4 ; if ( dpx . orientation . y_offset != ~ 0U ) ( void ) FormatImageProperty ( image , ""dpx:orientation.y_offset"" , ""%u"" , dpx . orientation . y_offset ) ; dpx . orientation . x_center = ReadBlobFloat ( image ) ; offset += 4 ; if ( IsFloatDefined ( dpx . orientation . x_center ) != MagickFalse ) ( void ) FormatImageProperty ( image , ""dpx:orientation.x_center"" , ""%g"" , dpx . orientation . x_center ) ; dpx . orientation . y_center = ReadBlobFloat ( image ) ; offset += 4 ; if ( IsFloatDefined ( dpx . orientation . y_center ) != MagickFalse ) ( void ) FormatImageProperty ( image , ""dpx:orientation.y_center"" , ""%g"" , dpx . orientation . y_center ) ; dpx . orientation . x_size = ReadBlobLong ( image ) ; offset += 4 ; if ( dpx . orientation . x_size != ~ 0U ) ( void ) FormatImageProperty ( image , ""dpx:orientation.x_size"" , ""%u"" , dpx . orientation . x_size ) ; dpx . orientation . y_size = ReadBlobLong ( image ) ; offset += 4 ; if ( dpx . orientation . y_size != ~ 0U ) ( void ) FormatImageProperty ( image , ""dpx:orientation.y_size"" , ""%u"" , dpx . orientation . y_size ) ; offset += ReadBlob ( image , sizeof ( dpx . orientation . filename ) , ( unsigned char * ) dpx . orientation . filename ) ; if ( * dpx . orientation . filename != '\\0' ) ( void ) FormatImageProperty ( image , ""dpx:orientation.filename"" , ""%.100s"" , dpx . orientation . filename ) ; offset += ReadBlob ( image , sizeof ( dpx . orientation . timestamp ) , ( unsigned char * ) dpx . orientation . timestamp ) ; if ( * dpx . orientation . timestamp != '\\0' ) ( void ) FormatImageProperty ( image , ""dpx:orientation.timestamp"" , ""%.24s"" , dpx . orientation . timestamp ) ; offset += ReadBlob ( image , sizeof ( dpx . orientation . device ) , ( unsigned char * ) dpx . orientation . device ) ; if ( * dpx . orientation . device != '\\0' ) ( void ) FormatImageProperty ( image , ""dpx:orientation.device"" , ""%.32s"" , dpx . orientation . device ) ; offset += ReadBlob ( image , sizeof ( dpx . orientation . serial ) , ( unsigned char * ) dpx . orientation . serial ) ; if ( * dpx . orientation . serial != '\\0' ) ( void ) FormatImageProperty ( image , ""dpx:orientation.serial"" , ""%.32s"" , dpx . orientation . serial ) ; for ( i = 0 ; i < 4 ; i ++ ) { dpx . orientation . border [ i ] = ReadBlobShort ( image ) ; offset += 2 ; } if ( ( dpx . orientation . border [ 0 ] != ( unsigned short ) ( ~ 0 ) ) && ( dpx . orientation . border [ 1 ] != ( unsigned short ) ( ~ 0 ) ) ) ( void ) FormatImageProperty ( image , ""dpx:orientation.border"" , ""%dx%d%+d%+d"" , dpx . orientation . border [ 0 ] , dpx . orientation . border [ 1 ] , dpx . orientation . border [ 2 ] , dpx . orientation . border [ 3 ] ) ; for ( i = 0 ; i < 2 ; i ++ ) { dpx . orientation . aspect_ratio [ i ] = ReadBlobLong ( image ) ; offset += 4 ; } if ( ( dpx . orientation . aspect_ratio [ 0 ] != ~ 0U ) && ( dpx . orientation . aspect_ratio [ 1 ] != ~ 0U ) ) ( void ) FormatImageProperty ( image , ""dpx:orientation.aspect_ratio"" , ""%ux%u"" , dpx . orientation . aspect_ratio [ 0 ] , dpx . orientation . aspect_ratio [ 1 ] ) ; offset += ReadBlob ( image , sizeof ( dpx . orientation . reserve ) , ( unsigned char * ) dpx . orientation . reserve ) ; } if ( dpx . file . image_offset >= 1920U ) { offset += ReadBlob ( image , sizeof ( dpx . film . id ) , ( unsigned char * ) dpx . film . id ) ; if ( * dpx . film . id != '\\0' ) ( void ) FormatImageProperty ( image , ""dpx:film.id"" , ""%.2s"" , dpx . film . id ) ; offset += ReadBlob ( image , sizeof ( dpx . film . type ) , ( unsigned char * ) dpx . film . type ) ; if ( * dpx . film . type != '\\0' ) ( void ) FormatImageProperty ( image , ""dpx:film.type"" , ""%.2s"" , dpx . film . type ) ; offset += ReadBlob ( image , sizeof ( dpx . film . offset ) , ( unsigned char * ) dpx . film . offset ) ; if ( * dpx . film . offset != '\\0' ) ( void ) FormatImageProperty ( image , ""dpx:film.offset"" , ""%.2s"" , dpx . film . offset ) ; offset += ReadBlob ( image , sizeof ( dpx . film . prefix ) , ( unsigned char * ) dpx . film . prefix ) ; if ( * dpx . film . prefix != '\\0' ) ( void ) FormatImageProperty ( image , ""dpx:film.prefix"" , ""%.6s"" , dpx . film . prefix ) ; offset += ReadBlob ( image , sizeof ( dpx . film . count ) , ( unsigned char * ) dpx . film . count ) ; if ( * dpx . film . count != '\\0' ) ( void ) FormatImageProperty ( image , ""dpx:film.count"" , ""%.4s"" , dpx . film . count ) ; offset += ReadBlob ( image , sizeof ( dpx . film . format ) , ( unsigned char * ) dpx . film . format ) ; if ( * dpx . film . format != '\\0' ) ( void ) FormatImageProperty ( image , ""dpx:film.format"" , ""%.4s"" , dpx . film . format ) ; dpx . film . frame_position = ReadBlobLong ( image ) ; offset += 4 ; if ( dpx . film . frame_position != ~ 0U ) ( void ) FormatImageProperty ( image , ""dpx:film.frame_position"" , ""%u"" , dpx . film . frame_position ) ; dpx . film . sequence_extent = ReadBlobLong ( image ) ; offset += 4 ; if ( dpx . film . sequence_extent != ~ 0U ) ( void ) FormatImageProperty ( image , ""dpx:film.sequence_extent"" , ""%u"" , dpx . film . sequence_extent ) ; dpx . film . held_count = ReadBlobLong ( image ) ; offset += 4 ; if ( dpx . film . held_count != ~ 0U ) ( void ) FormatImageProperty ( image , ""dpx:film.held_count"" , ""%u"" , dpx . film . held_count ) ; dpx . film . frame_rate = ReadBlobFloat ( image ) ; offset += 4 ; if ( IsFloatDefined ( dpx . film . frame_rate ) != MagickFalse ) ( void ) FormatImageProperty ( image , ""dpx:film.frame_rate"" , ""%g"" , dpx . film . frame_rate ) ; dpx . film . shutter_angle = ReadBlobFloat ( image ) ; offset += 4 ; if ( IsFloatDefined ( dpx . film . shutter_angle ) != MagickFalse ) ( void ) FormatImageProperty ( image , ""dpx:film.shutter_angle"" , ""%g"" , dpx . film . shutter_angle ) ; offset += ReadBlob ( image , sizeof ( dpx . film . frame_id ) , ( unsigned char * ) dpx . film . frame_id ) ; if ( * dpx . film . frame_id != '\\0' ) ( void ) FormatImageProperty ( image , ""dpx:film.frame_id"" , ""%.32s"" , dpx . film . frame_id ) ; offset += ReadBlob ( image , sizeof ( dpx . film . slate ) , ( unsigned char * ) dpx . film . slate ) ; if ( * dpx . film . slate != '\\0' ) ( void ) FormatImageProperty ( image , ""dpx:film.slate"" , ""%.100s"" , dpx . film . slate ) ; offset += ReadBlob ( image , sizeof ( dpx . film . reserve ) , ( unsigned char * ) dpx . film . reserve ) ; } if ( dpx . file . image_offset >= 2048U ) { dpx . television . time_code = ( unsigned int ) ReadBlobLong ( image ) ; offset += 4 ; TimeCodeToString ( dpx . television . time_code , value ) ; ( void ) SetImageProperty ( image , ""dpx:television.time.code"" , value ) ; dpx . television . user_bits = ( unsigned int ) ReadBlobLong ( image ) ; offset += 4 ; TimeCodeToString ( dpx . television . user_bits , value ) ; ( void ) SetImageProperty ( image , ""dpx:television.user.bits"" , value ) ; dpx . television . interlace = ( unsigned char ) ReadBlobByte ( image ) ; offset ++ ; if ( dpx . television . interlace != 0 ) ( void ) FormatImageProperty ( image , ""dpx:television.interlace"" , ""%.20g"" , ( double ) dpx . television . interlace ) ; dpx . television . field_number = ( unsigned char ) ReadBlobByte ( image ) ; offset ++ ; if ( dpx . television . field_number != 0 ) ( void ) FormatImageProperty ( image , ""dpx:television.field_number"" , ""%.20g"" , ( double ) dpx . television . field_number ) ; dpx . television . video_signal = ( unsigned char ) ReadBlobByte ( image ) ; offset ++ ; if ( dpx . television . video_signal != 0 ) ( void ) FormatImageProperty ( image , ""dpx:television.video_signal"" , ""%.20g"" , ( double ) dpx . television . video_signal ) ; dpx . television . padding = ( unsigned char ) ReadBlobByte ( image ) ; offset ++ ; if ( dpx . television . padding != 0 ) ( void ) FormatImageProperty ( image , ""dpx:television.padding"" , ""%d"" , dpx . television . padding ) ; dpx . television . horizontal_sample_rate = ReadBlobFloat ( image ) ; offset += 4 ; if ( IsFloatDefined ( dpx . television . horizontal_sample_rate ) != MagickFalse ) ( void ) FormatImageProperty ( image , ""dpx:television.horizontal_sample_rate"" , ""%g"" , dpx . television . horizontal_sample_rate ) ; dpx . television . vertical_sample_rate = ReadBlobFloat ( image ) ; offset += 4 ; if ( IsFloatDefined ( dpx . television . vertical_sample_rate ) != MagickFalse ) ( void ) FormatImageProperty ( image , ""dpx:television.vertical_sample_rate"" , ""%g"" , dpx . television . vertical_sample_rate ) ; dpx . television . frame_rate = ReadBlobFloat ( image ) ; offset += 4 ; if ( IsFloatDefined ( dpx . television . frame_rate ) != MagickFalse ) ( void ) FormatImageProperty ( image , ""dpx:television.frame_rate"" , ""%g"" , dpx . television . frame_rate ) ; dpx . television . time_offset = ReadBlobFloat ( image ) ; offset += 4 ; if ( IsFloatDefined ( dpx . television . time_offset ) != MagickFalse ) ( void ) FormatImageProperty ( image , ""dpx:television.time_offset"" , ""%g"" , dpx . television . time_offset ) ; dpx . television . gamma = ReadBlobFloat ( image ) ; offset += 4 ; if ( IsFloatDefined ( dpx . television . gamma ) != MagickFalse ) ( void ) FormatImageProperty ( image , ""dpx:television.gamma"" , ""%g"" , dpx . television . gamma ) ; dpx . television . black_level = ReadBlobFloat ( image ) ; offset += 4 ; if ( IsFloatDefined ( dpx . television . black_level ) != MagickFalse ) ( void ) FormatImageProperty ( image , ""dpx:television.black_level"" , ""%g"" , dpx . television . black_level ) ; dpx . television . black_gain = ReadBlobFloat ( image ) ; offset += 4 ; if ( IsFloatDefined ( dpx . television . black_gain ) != MagickFalse ) ( void ) FormatImageProperty ( image , ""dpx:television.black_gain"" , ""%g"" , dpx . television . black_gain ) ; dpx . television . break_point = ReadBlobFloat ( image ) ; offset += 4 ; if ( IsFloatDefined ( dpx . television . break_point ) != MagickFalse ) ( void ) FormatImageProperty ( image , ""dpx:television.break_point"" , ""%g"" , dpx . television . break_point ) ; dpx . television . white_level = ReadBlobFloat ( image ) ; offset += 4 ; if ( IsFloatDefined ( dpx . television . white_level ) != MagickFalse ) ( void ) FormatImageProperty ( image , ""dpx:television.white_level"" , ""%g"" , dpx . television . white_level ) ; dpx . television . integration_times = ReadBlobFloat ( image ) ; offset += 4 ; if ( IsFloatDefined ( dpx . television . integration_times ) != MagickFalse ) ( void ) FormatImageProperty ( image , ""dpx:television.integration_times"" , ""%g"" , dpx . television . integration_times ) ; offset += ReadBlob ( image , sizeof ( dpx . television . reserve ) , ( unsigned char * ) dpx . television . reserve ) ; } if ( dpx . file . image_offset > 2080U ) { offset += ReadBlob ( image , sizeof ( dpx . user . id ) , ( unsigned char * ) dpx . user . id ) ; if ( * dpx . user . id != '\\0' ) ( void ) FormatImageProperty ( image , ""dpx:user.id"" , ""%.32s"" , dpx . user . id ) ; if ( ( dpx . file . user_size != ~ 0U ) && ( ( size_t ) dpx . file . user_size > sizeof ( dpx . user . id ) ) ) { StringInfo * profile ; profile = BlobToStringInfo ( ( const void * ) NULL , dpx . file . user_size - sizeof ( dpx . user . id ) ) ; if ( profile == ( StringInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; offset += ReadBlob ( image , GetStringInfoLength ( profile ) , GetStringInfoDatum ( profile ) ) ; ( void ) SetImageProfile ( image , ""dpx:user-data"" , profile ) ; profile = DestroyStringInfo ( profile ) ; } } for ( ; offset < ( MagickOffsetType ) dpx . file . image_offset ; offset ++ ) ( void ) ReadBlobByte ( image ) ; if ( image_info -> ping != MagickFalse ) { ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } for ( n = 0 ; n < ( ssize_t ) dpx . image . number_elements ; n ++ ) { if ( ( dpx . image . image_element [ n ] . data_offset != ~ 0U ) && ( dpx . image . image_element [ n ] . data_offset != 0U ) ) { MagickOffsetType data_offset ; data_offset = ( MagickOffsetType ) dpx . image . image_element [ n ] . data_offset ; if ( data_offset < offset ) offset = SeekBlob ( image , data_offset , SEEK_SET ) ; else for ( ; offset < data_offset ; offset ++ ) ( void ) ReadBlobByte ( image ) ; if ( offset != data_offset ) ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; } SetPrimaryChromaticity ( ( DPXColorimetric ) dpx . image . image_element [ n ] . colorimetric , & image -> chromaticity ) ; image -> depth = dpx . image . image_element [ n ] . bit_size ; samples_per_pixel = 1 ; quantum_type = GrayQuantum ; component_type = dpx . image . image_element [ n ] . descriptor ; switch ( component_type ) { case CbYCrY422ComponentType : { samples_per_pixel = 2 ; quantum_type = CbYCrYQuantum ; break ; } case CbYACrYA4224ComponentType : case CbYCr444ComponentType : { samples_per_pixel = 3 ; quantum_type = CbYCrQuantum ; break ; } case RGBComponentType : { samples_per_pixel = 3 ; quantum_type = RGBQuantum ; break ; } case ABGRComponentType : case RGBAComponentType : { image -> matte = MagickTrue ; samples_per_pixel = 4 ; quantum_type = RGBAQuantum ; break ; } default : break ; } switch ( component_type ) { case CbYCrY422ComponentType : case CbYACrYA4224ComponentType : case CbYCr444ComponentType : { ( void ) SetImageColorspace ( image , Rec709YCbCrColorspace ) ; break ; } case LumaComponentType : { ( void ) SetImageColorspace ( image , GRAYColorspace ) ; break ; } default : { ( void ) SetImageColorspace ( image , RGBColorspace ) ; if ( dpx . image . image_element [ n ] . transfer_characteristic == LogarithmicColorimetric ) ( void ) SetImageColorspace ( image , LogColorspace ) ; if ( dpx . image . image_element [ n ] . transfer_characteristic == PrintingDensityColorimetric ) ( void ) SetImageColorspace ( image , LogColorspace ) ; break ; } } extent = GetBytesPerRow ( image -> columns , samples_per_pixel , image -> depth , dpx . image . image_element [ n ] . packing == 0 ? MagickFalse : MagickTrue ) ; status = MagickTrue ; row = 0 ; quantum_info = AcquireQuantumInfo ( image_info , image ) ; if ( quantum_info == ( QuantumInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; SetQuantumQuantum ( quantum_info , 32 ) ; SetQuantumPack ( quantum_info , dpx . image . image_element [ n ] . packing == 0 ? MagickTrue : MagickFalse ) ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { MagickBooleanType sync ; register PixelPacket * q ; size_t length ; ssize_t count , offset ; unsigned char * pixels ; if ( status == MagickFalse ) continue ; pixels = GetQuantumPixels ( quantum_info ) ; { count = ReadBlob ( image , extent , pixels ) ; if ( ( image -> progress_monitor != ( MagickProgressMonitor ) NULL ) && ( image -> previous == ( Image * ) NULL ) ) { MagickBooleanType proceed ; proceed = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) row , image -> rows ) ; if ( proceed == MagickFalse ) status = MagickFalse ; } offset = row ++ ; } if ( count != ( ssize_t ) extent ) status = MagickFalse ; q = QueueAuthenticPixels ( image , 0 , offset , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) { status = MagickFalse ; continue ; } length = ImportQuantumPixels ( image , ( CacheView * ) NULL , quantum_info , quantum_type , pixels , exception ) ; ( void ) length ; sync = SyncAuthenticPixels ( image , exception ) ; if ( sync == MagickFalse ) status = MagickFalse ; } quantum_info = DestroyQuantumInfo ( quantum_info ) ; if ( status == MagickFalse ) ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; SetQuantumImageType ( image , quantum_type ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; } ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," return ( GetFirstImageInList ( image ) ) ; } status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ",ImageMagick@ImageMagick/f6e9d0d9955e85bdd7540b251cd50d598dacc5e6,CVE-2016-10066,https://github.com/ImageMagick/ImageMagick/commit/f6e9d0d9955e85bdd7540b251cd50d598dacc5e6,2017-03-03T17:59Z 762,CWE-190,"CWE-190 void posixtimer_rearm ( struct siginfo * info ) { struct k_itimer * timr ; unsigned long flags ; timr = lock_timer ( info -> si_tid , & flags ) ; if ( ! timr ) return ; if ( timr -> it_requeue_pending == info -> si_sys_private ) { timr -> kclock -> timer_rearm ( timr ) ; timr -> it_active = 1 ; timr -> it_overrun_last = timr -> it_overrun ; timr -> it_overrun = - 1 ; ++ timr -> it_requeue_pending ; info -> si_overrun += timr -> it_overrun_last ; } unlock_timer ( timr , flags ) ; } "," it_overrun = - 1LL ; ++ timr info -> si_overrun = timer_overrun_to_int ( timr , info -> si_overrun ) ; } unlock_timer ",torvalds@linux/78c9c4dfbf8c04883941445a195276bb4bb92c76,CVE-2018-12896,https://github.com/torvalds/linux/commit/78c9c4dfbf8c04883941445a195276bb4bb92c76,2018-07-02T17:29Z 763,CWE-522,"CWE-522 int credential_from_url_gently ( struct credential * c , const char * url , int quiet ) { const char * at , * colon , * cp , * slash , * host , * proto_end ; credential_clear ( c ) ; proto_end = strstr ( url , ""://"" ) ; if ( ! proto_end ) return 0 ; cp = proto_end + 3 ; at = strchr ( cp , '@' ) ; colon = strchr ( cp , ':' ) ; slash = strchrnul ( cp , '/' ) ; if ( ! at || slash <= at ) { host = cp ; } else if ( ! colon || at <= colon ) { c -> username = url_decode_mem ( cp , at - cp ) ; host = at + 1 ; } else { c -> username = url_decode_mem ( cp , colon - cp ) ; c -> password = url_decode_mem ( colon + 1 , at - ( colon + 1 ) ) ; host = at + 1 ; } if ( proto_end - url > 0 ) c -> protocol = xmemdupz ( url , proto_end - url ) ; c -> host = url_decode_mem ( host , slash - host ) ; while ( * slash == '/' ) slash ++ ; if ( * slash ) { char * p ; c -> path = url_decode ( slash ) ; p = c -> path + strlen ( c -> path ) - 1 ; while ( p > c -> path && * p == '/' ) * p -- = '\\0' ; } if ( check_url_component ( url , quiet , ""username"" , c -> username ) < 0 || check_url_component ( url , quiet , ""password"" , c -> password ) < 0 || check_url_component ( url , quiet , ""protocol"" , c -> protocol ) < 0 || check_url_component ( url , quiet , ""host"" , c -> host ) < 0 || check_url_component ( url , quiet , ""path"" , c -> path ) < 0 ) return - 1 ; return 0 ; } "," ! proto_end ) { if ( ! quiet ) warning ( _ ( ""urlhasnoscheme:%s"" ) , url ) ; return - 1 ; } cp = proto_end ",git@git/c44088ecc4b0722636e0a305f9608d3047197282,CVE-2020-11008,https://github.com/git/git/commit/c44088ecc4b0722636e0a305f9608d3047197282,2020-04-21T19:15Z 764,CWE-200,"CWE-200 bool __net_get_random_once ( void * buf , int nbytes , bool * done , struct static_key * done_key ) { static DEFINE_SPINLOCK ( lock ) ; unsigned long flags ; spin_lock_irqsave ( & lock , flags ) ; if ( * done ) { spin_unlock_irqrestore ( & lock , flags ) ; return false ; } get_random_bytes ( buf , nbytes ) ; * done = true ; spin_unlock_irqrestore ( & lock , flags ) ; __net_random_once_disable_jump ( done_key ) ; return true ; } "," struct static_key * once_key ) { static ; __net_random_once_disable_jump ( once_key ) ; return ",torvalds@linux/3d4405226d27b3a215e4d03cfa51f536244e5de7,CVE-2014-7284,https://github.com/torvalds/linux/commit/3d4405226d27b3a215e4d03cfa51f536244e5de7,2014-10-13T10:55Z 765,CWE-416,"CWE-416 static void ffs_user_copy_worker ( struct work_struct * work ) { struct ffs_io_data * io_data = container_of ( work , struct ffs_io_data , work ) ; int ret = io_data -> req -> status ? io_data -> req -> status : io_data -> req -> actual ; if ( io_data -> read && ret > 0 ) { use_mm ( io_data -> mm ) ; ret = copy_to_iter ( io_data -> buf , ret , & io_data -> data ) ; if ( iov_iter_count ( & io_data -> data ) ) ret = - EFAULT ; unuse_mm ( io_data -> mm ) ; } io_data -> kiocb -> ki_complete ( io_data -> kiocb , ret , ret ) ; if ( io_data -> ffs -> ffs_eventfd && ! ( io_data -> kiocb -> ki_flags & IOCB_EVENTFD ) ) eventfd_signal ( io_data -> ffs -> ffs_eventfd , 1 ) ; usb_ep_free_request ( io_data -> ep , io_data -> req ) ; io_data -> kiocb -> private = NULL ; if ( io_data -> read ) kfree ( io_data -> to_free ) ; kfree ( io_data -> buf ) ; kfree ( io_data ) ; } "," -> actual ; bool kiocb_has_eventfd = io_data -> kiocb ki_flags & IOCB_EVENTFD ; if ( io_data -> read && ret > 0 ) { use_mm ( io_data -> mm ) ; ret = copy_to_iter ( io_data -> buf , ret , & io_data -> data ) ; if ( iov_iter_count ( & io_data -> data ) ) ret = - EFAULT ; unuse_mm ( io_data -> mm ) ; } io_data -> kiocb -> ki_complete ( io_data -> kiocb , ret , ret ) ; if ( io_data -> ffs -> ffs_eventfd && ! kiocb_has_eventfd ) eventfd_signal ( -> req ) ; if ( ",torvalds@linux/38740a5b87d53ceb89eb2c970150f6e94e00373a,CVE-2016-7912,https://github.com/torvalds/linux/commit/38740a5b87d53ceb89eb2c970150f6e94e00373a,2016-11-16T05:59Z 766,CWE-17,"CWE-17 int ip_forward ( struct sk_buff * skb ) { u32 mtu ; struct iphdr * iph ; struct rtable * rt ; struct ip_options * opt = & ( IPCB ( skb ) -> opt ) ; if ( skb -> pkt_type != PACKET_HOST ) goto drop ; if ( skb_warn_if_lro ( skb ) ) goto drop ; if ( ! xfrm4_policy_check ( NULL , XFRM_POLICY_FWD , skb ) ) goto drop ; if ( IPCB ( skb ) -> opt . router_alert && ip_call_ra_chain ( skb ) ) return NET_RX_SUCCESS ; skb_forward_csum ( skb ) ; if ( ip_hdr ( skb ) -> ttl <= 1 ) goto too_many_hops ; if ( ! xfrm4_route_forward ( skb ) ) goto drop ; rt = skb_rtable ( skb ) ; if ( opt -> is_strictroute && rt -> rt_uses_gateway ) goto sr_failed ; IPCB ( skb ) -> flags |= IPSKB_FORWARDED ; mtu = ip_dst_mtu_maybe_forward ( & rt -> dst , true ) ; if ( ! ip_may_fragment ( skb ) && ip_exceeds_mtu ( skb , mtu ) ) { IP_INC_STATS ( dev_net ( rt -> dst . dev ) , IPSTATS_MIB_FRAGFAILS ) ; icmp_send ( skb , ICMP_DEST_UNREACH , ICMP_FRAG_NEEDED , htonl ( mtu ) ) ; goto drop ; } if ( skb_cow ( skb , LL_RESERVED_SPACE ( rt -> dst . dev ) + rt -> dst . header_len ) ) goto drop ; iph = ip_hdr ( skb ) ; ip_decrease_ttl ( iph ) ; if ( rt -> rt_flags & RTCF_DOREDIRECT && ! opt -> srr && ! skb_sec_path ( skb ) ) ip_rt_send_redirect ( skb ) ; skb -> priority = rt_tos2priority ( iph -> tos ) ; return NF_HOOK ( NFPROTO_IPV4 , NF_INET_FORWARD , skb , skb -> dev , rt -> dst . dev , ip_forward_finish ) ; sr_failed : icmp_send ( skb , ICMP_DEST_UNREACH , ICMP_SR_FAILED , 0 ) ; goto drop ; too_many_hops : IP_INC_STATS_BH ( dev_net ( skb_dst ( skb ) -> dev ) , IPSTATS_MIB_INHDRERRORS ) ; icmp_send ( skb , ICMP_TIME_EXCEEDED , ICMP_EXC_TTL , 0 ) ; drop : kfree_skb ( skb ) ; return NET_RX_DROP ; } "," ; if ( IPCB ( skb ) -> flags & IPSKB_DOREDIRECT && ! opt ",torvalds@linux/df4d92549f23e1c037e83323aff58a21b3de7fe0,CVE-2015-1465,https://github.com/torvalds/linux/commit/df4d92549f23e1c037e83323aff58a21b3de7fe0,2015-04-05T21:59Z 767,CWE-20,"CWE-20 static void ikev2_parent_inR1outI2_continue ( struct pluto_crypto_req_cont * pcrc , struct pluto_crypto_req * r , err_t ugh ) { struct dh_continuation * dh = ( struct dh_continuation * ) pcrc ; struct msg_digest * md = dh -> md ; struct state * const st = md -> st ; stf_status e ; DBG ( DBG_CONTROLMORE , DBG_log ( ""ikev2parentinR1outI2:calculatingg^{xy},sendingI2"" ) ) ; if ( st == NULL ) { loglog ( RC_LOG_SERIOUS , ""%s:Requestwasdisconnectedfromstate"" , __FUNCTION__ ) ; if ( dh -> md ) release_md ( dh -> md ) ; return ; } passert ( ugh == NULL ) ; passert ( cur_state == NULL ) ; passert ( st != NULL ) ; passert ( st -> st_suspended_md == dh -> md ) ; set_suspended ( st , NULL ) ; set_cur_state ( st ) ; st -> st_calculating = FALSE ; e = ikev2_parent_inR1outI2_tail ( pcrc , r ) ; if ( dh -> md != NULL ) { complete_v2_state_transition ( & dh -> md , e ) ; if ( dh -> md ) release_md ( dh -> md ) ; } reset_globals ( ) ; passert ( GLOBALS_ARE_RESET ( ) ) ; } "," ( ) ; } ",libreswan@libreswan/2899351224fe2940aec37d7656e1e392c0fe07f0,CVE-2013-7294,https://github.com/libreswan/libreswan/commit/2899351224fe2940aec37d7656e1e392c0fe07f0,2014-01-16T05:05Z 768,CWE-264,"CWE-264 static int trusted_update ( struct key * key , struct key_preparsed_payload * prep ) { struct trusted_key_payload * p = key -> payload . data [ 0 ] ; struct trusted_key_payload * new_p ; struct trusted_key_options * new_o ; size_t datalen = prep -> datalen ; char * datablob ; int ret = 0 ; if ( ! p -> migratable ) return - EPERM ; if ( datalen <= 0 || datalen > 32767 || ! prep -> data ) return - EINVAL ; datablob = kmalloc ( datalen + 1 , GFP_KERNEL ) ; if ( ! datablob ) return - ENOMEM ; new_o = trusted_options_alloc ( ) ; if ( ! new_o ) { ret = - ENOMEM ; goto out ; } new_p = trusted_payload_alloc ( key ) ; if ( ! new_p ) { ret = - ENOMEM ; goto out ; } memcpy ( datablob , prep -> data , datalen ) ; datablob [ datalen ] = '\\0' ; ret = datablob_parse ( datablob , new_p , new_o ) ; if ( ret != Opt_update ) { ret = - EINVAL ; kfree ( new_p ) ; goto out ; } if ( ! new_o -> keyhandle ) { ret = - EINVAL ; kfree ( new_p ) ; goto out ; } new_p -> migratable = p -> migratable ; new_p -> key_len = p -> key_len ; memcpy ( new_p -> key , p -> key , p -> key_len ) ; dump_payload ( p ) ; dump_payload ( new_p ) ; ret = key_seal ( new_p , new_o ) ; if ( ret < 0 ) { pr_info ( ""trusted_key:key_sealfailed(%d)\\n"" , ret ) ; kfree ( new_p ) ; goto out ; } if ( new_o -> pcrlock ) { ret = pcrlock ( new_o -> pcrlock ) ; if ( ret < 0 ) { pr_info ( ""trusted_key:pcrlockfailed(%d)\\n"" , ret ) ; kfree ( new_p ) ; goto out ; } } rcu_assign_keypointer ( key , new_p ) ; call_rcu ( & p -> rcu , trusted_rcu_free ) ; out : kfree ( datablob ) ; kfree ( new_o ) ; return ret ; } "," struct trusted_key_payload * p ; struct trusted_key_payload * new_p ; struct trusted_key_options * new_o ; size_t datalen = prep -> datalen ; char * datablob ; int ret = 0 ; if ( test_bit ( KEY_FLAG_NEGATIVE , & key -> flags ) ) return - ENOKEY ; 0 ] ; if ( ! ",torvalds@linux/096fe9eaea40a17e125569f9e657e34cdb6d73bd,CVE-2015-8539,https://github.com/torvalds/linux/commit/096fe9eaea40a17e125569f9e657e34cdb6d73bd,2016-02-08T03:59Z 769,CWE-476,"CWE-476 static int bmp_getint32 ( jas_stream_t * in , int_fast32_t * val ) { int n ; uint_fast32_t v ; int c ; for ( n = 4 , v = 0 ; ; ) { if ( ( c = jas_stream_getc ( in ) ) == EOF ) { return - 1 ; } v |= ( c << 24 ) ; if ( -- n <= 0 ) { break ; } v >>= 8 ; } if ( val ) { * val = v ; } return 0 ; } "," v |= ( JAS_CAST ( uint_fast32_t , c ) << 24 ) ",mdadams@jasper/8f62b4761711d036fd8964df256b938c809b7fca,CVE-2016-8690,https://github.com/mdadams/jasper/commit/8f62b4761711d036fd8964df256b938c809b7fca,2017-02-15T19:59Z 770,CWE-20,"CWE-20 static void rose_loopback_timer ( unsigned long param ) { struct sk_buff * skb ; struct net_device * dev ; rose_address * dest ; struct sock * sk ; unsigned short frametype ; unsigned int lci_i , lci_o ; while ( ( skb = skb_dequeue ( & loopback_queue ) ) != NULL ) { lci_i = ( ( skb -> data [ 0 ] << 8 ) & 0xF00 ) + ( ( skb -> data [ 1 ] << 0 ) & 0x0FF ) ; frametype = skb -> data [ 2 ] ; dest = ( rose_address * ) ( skb -> data + 4 ) ; lci_o = ROSE_DEFAULT_MAXVC + 1 - lci_i ; skb_reset_transport_header ( skb ) ; sk = rose_find_socket ( lci_o , rose_loopback_neigh ) ; if ( sk ) { if ( rose_process_rx_frame ( sk , skb ) == 0 ) kfree_skb ( skb ) ; continue ; } if ( frametype == ROSE_CALL_REQUEST ) { if ( ( dev = rose_dev_get ( dest ) ) != NULL ) { if ( rose_rx_call_request ( skb , dev , rose_loopback_neigh , lci_o ) == 0 ) kfree_skb ( skb ) ; } else { kfree_skb ( skb ) ; } } else { kfree_skb ( skb ) ; } } } "," NULL ) { if ( skb -> len < ROSE_MIN_LEN ) { kfree_skb ( skb ) ; continue ; } 2 ] ; if ( frametype == ROSE_CALL_REQUEST && ( skb -> len <= ROSE_CALL_REQ_FACILITIES_OFF || skb -> data [ ROSE_CALL_REQ_ADDR_LEN_OFF ] != ROSE_CALL_REQ_ADDR_LEN_VAL ) ) { kfree_skb ( skb ) ; continue ; } -> data + ROSE_CALL_REQ_DEST_ADDR_OFF ) ; lci_o ",torvalds@linux/e0bccd315db0c2f919e7fcf9cb60db21d9986f52,CVE-2011-4914,https://github.com/torvalds/linux/commit/e0bccd315db0c2f919e7fcf9cb60db21d9986f52,2012-06-21T23:55Z 771,CWE-399,"CWE-399 int __kvm_set_memory_region ( struct kvm * kvm , struct kvm_userspace_memory_region * mem , int user_alloc ) { int r ; gfn_t base_gfn ; unsigned long npages ; struct kvm_memory_slot * memslot , * slot ; struct kvm_memory_slot old , new ; struct kvm_memslots * slots , * old_memslots ; r = check_memory_region_flags ( mem ) ; if ( r ) goto out ; r = - EINVAL ; if ( mem -> memory_size & ( PAGE_SIZE - 1 ) ) goto out ; if ( mem -> guest_phys_addr & ( PAGE_SIZE - 1 ) ) goto out ; if ( user_alloc && ( ( mem -> userspace_addr & ( PAGE_SIZE - 1 ) ) || ! access_ok ( VERIFY_WRITE , ( void __user * ) ( unsigned long ) mem -> userspace_addr , mem -> memory_size ) ) ) goto out ; if ( mem -> slot >= KVM_MEM_SLOTS_NUM ) goto out ; if ( mem -> guest_phys_addr + mem -> memory_size < mem -> guest_phys_addr ) goto out ; memslot = id_to_memslot ( kvm -> memslots , mem -> slot ) ; base_gfn = mem -> guest_phys_addr >> PAGE_SHIFT ; npages = mem -> memory_size >> PAGE_SHIFT ; r = - EINVAL ; if ( npages > KVM_MEM_MAX_NR_PAGES ) goto out ; if ( ! npages ) mem -> flags &= ~ KVM_MEM_LOG_DIRTY_PAGES ; new = old = * memslot ; new . id = mem -> slot ; new . base_gfn = base_gfn ; new . npages = npages ; new . flags = mem -> flags ; r = - EINVAL ; if ( npages && old . npages && npages != old . npages ) goto out_free ; if ( ! npages && ! old . npages ) goto out_free ; r = - EEXIST ; kvm_for_each_memslot ( slot , kvm -> memslots ) { if ( slot -> id >= KVM_MEMORY_SLOTS || slot == memslot ) continue ; if ( ! ( ( base_gfn + npages <= slot -> base_gfn ) || ( base_gfn >= slot -> base_gfn + slot -> npages ) ) ) goto out_free ; } if ( ! ( new . flags & KVM_MEM_LOG_DIRTY_PAGES ) ) new . dirty_bitmap = NULL ; r = - ENOMEM ; if ( ! old . npages ) { new . user_alloc = user_alloc ; new . userspace_addr = mem -> userspace_addr ; if ( kvm_arch_create_memslot ( & new , npages ) ) goto out_free ; } else if ( npages && mem -> userspace_addr != old . userspace_addr ) { r = - EINVAL ; goto out_free ; } if ( ( new . flags & KVM_MEM_LOG_DIRTY_PAGES ) && ! new . dirty_bitmap ) { if ( kvm_create_dirty_bitmap ( & new ) < 0 ) goto out_free ; } if ( ! npages || base_gfn != old . base_gfn ) { struct kvm_memory_slot * slot ; r = - ENOMEM ; slots = kmemdup ( kvm -> memslots , sizeof ( struct kvm_memslots ) , GFP_KERNEL ) ; if ( ! slots ) goto out_free ; slot = id_to_memslot ( slots , mem -> slot ) ; slot -> flags |= KVM_MEMSLOT_INVALID ; update_memslots ( slots , NULL ) ; old_memslots = kvm -> memslots ; rcu_assign_pointer ( kvm -> memslots , slots ) ; synchronize_srcu_expedited ( & kvm -> srcu ) ; kvm_arch_flush_shadow_memslot ( kvm , slot ) ; kfree ( old_memslots ) ; } r = kvm_arch_prepare_memory_region ( kvm , & new , old , mem , user_alloc ) ; if ( r ) goto out_free ; if ( npages ) { r = kvm_iommu_map_pages ( kvm , & new ) ; if ( r ) goto out_free ; } else kvm_iommu_unmap_pages ( kvm , & old ) ; r = - ENOMEM ; slots = kmemdup ( kvm -> memslots , sizeof ( struct kvm_memslots ) , GFP_KERNEL ) ; if ( ! slots ) goto out_free ; if ( ! npages ) { new . dirty_bitmap = NULL ; memset ( & new . arch , 0 , sizeof ( new . arch ) ) ; } update_memslots ( slots , & new ) ; old_memslots = kvm -> memslots ; rcu_assign_pointer ( kvm -> memslots , slots ) ; synchronize_srcu_expedited ( & kvm -> srcu ) ; kvm_arch_commit_memory_region ( kvm , mem , old , user_alloc ) ; kvm_free_physmem_slot ( & old , & new ) ; kfree ( old_memslots ) ; return 0 ; out_free : kvm_free_physmem_slot ( & new , & old ) ; out : return r ; } "," srcu ) ; kvm_iommu_unmap_pages ( kvm , & old ) ; ) goto out_free ; r = ; if ( npages ) { r = kvm_iommu_map_pages ( kvm , & new ) ; if ( r ) goto out_slots ; } if ( return 0 ; out_slots : kfree ( slots ) ; ",torvalds@linux/e40f193f5bb022e927a57a4f5d5194e4f12ddb74,CVE-2013-4592,https://github.com/torvalds/linux/commit/e40f193f5bb022e927a57a4f5d5194e4f12ddb74,2013-11-20T13:19Z 772,CWE-000,"CWE-000 unsigned int nf_nat_redirect_ipv4 ( struct sk_buff * skb , const struct nf_nat_ipv4_multi_range_compat * mr , unsigned int hooknum ) { struct nf_conn * ct ; enum ip_conntrack_info ctinfo ; __be32 newdst ; struct nf_nat_range newrange ; NF_CT_ASSERT ( hooknum == NF_INET_PRE_ROUTING || hooknum == NF_INET_LOCAL_OUT ) ; ct = nf_ct_get ( skb , & ctinfo ) ; NF_CT_ASSERT ( ct && ( ctinfo == IP_CT_NEW || ctinfo == IP_CT_RELATED ) ) ; if ( hooknum == NF_INET_LOCAL_OUT ) { newdst = htonl ( 0x7F000001 ) ; } else { struct in_device * indev ; struct in_ifaddr * ifa ; newdst = 0 ; rcu_read_lock ( ) ; indev = __in_dev_get_rcu ( skb -> dev ) ; if ( indev != NULL ) { ifa = indev -> ifa_list ; newdst = ifa -> ifa_local ; } rcu_read_unlock ( ) ; if ( ! newdst ) return NF_DROP ; } memset ( & newrange . min_addr , 0 , sizeof ( newrange . min_addr ) ) ; memset ( & newrange . max_addr , 0 , sizeof ( newrange . max_addr ) ) ; newrange . flags = mr -> range [ 0 ] . flags | NF_NAT_RANGE_MAP_IPS ; newrange . min_addr . ip = newdst ; newrange . max_addr . ip = newdst ; newrange . min_proto = mr -> range [ 0 ] . min ; newrange . max_proto = mr -> range [ 0 ] . max ; return nf_nat_setup_info ( ct , & newrange , NF_NAT_MANIP_DST ) ; } "," if ( indev && indev -> ifa_list ) { ifa ",torvalds@linux/94f9cd81436c85d8c3a318ba92e236ede73752fc,CVE-2015-8787,https://github.com/torvalds/linux/commit/94f9cd81436c85d8c3a318ba92e236ede73752fc,2016-02-08T03:59Z 773,CWE-000,"CWE-000 int fdt_find_regions ( const void * fdt , char * const inc [ ] , int inc_count , char * const exc_prop [ ] , int exc_prop_count , struct fdt_region region [ ] , int max_regions , char * path , int path_len , int add_string_tab ) { int stack [ FDT_MAX_DEPTH ] = { 0 } ; char * end ; int nextoffset = 0 ; uint32_t tag ; int count = 0 ; int start = - 1 ; int depth = - 1 ; int want = 0 ; int base = fdt_off_dt_struct ( fdt ) ; end = path ; * end = '\\0' ; do { const struct fdt_property * prop ; const char * name ; const char * str ; int include = 0 ; int stop_at = 0 ; int offset ; int len ; offset = nextoffset ; tag = fdt_next_tag ( fdt , offset , & nextoffset ) ; stop_at = nextoffset ; switch ( tag ) { case FDT_PROP : include = want >= 2 ; stop_at = offset ; prop = fdt_get_property_by_offset ( fdt , offset , NULL ) ; str = fdt_string ( fdt , fdt32_to_cpu ( prop -> nameoff ) ) ; if ( ! str ) return - FDT_ERR_BADSTRUCTURE ; if ( str_in_list ( str , exc_prop , exc_prop_count ) ) include = 0 ; break ; case FDT_NOP : include = want >= 2 ; stop_at = offset ; break ; case FDT_BEGIN_NODE : depth ++ ; if ( depth == FDT_MAX_DEPTH ) return - FDT_ERR_BADSTRUCTURE ; name = fdt_get_name ( fdt , offset , & len ) ; if ( end - path + 2 + len >= path_len ) return - FDT_ERR_NOSPACE ; if ( end != path + 1 ) * end ++ = '/' ; strcpy ( end , name ) ; end += len ; stack [ depth ] = want ; if ( want == 1 ) stop_at = offset ; if ( str_in_list ( path , inc , inc_count ) ) want = 2 ; else if ( want ) want -- ; else stop_at = offset ; include = want ; break ; case FDT_END_NODE : if ( depth < 0 ) return - FDT_ERR_BADSTRUCTURE ; include = want ; want = stack [ depth -- ] ; while ( end > path && * -- end != '/' ) ; * end = '\\0' ; break ; case FDT_END : include = 1 ; break ; } if ( include && start == - 1 ) { if ( count && count <= max_regions && offset == region [ count - 1 ] . offset + region [ count - 1 ] . size - base ) start = region [ -- count ] . offset - base ; else start = offset ; } if ( ! include && start != - 1 ) { if ( count < max_regions ) { region [ count ] . offset = base + start ; region [ count ] . size = stop_at - start ; } count ++ ; start = - 1 ; } } while ( tag != FDT_END ) ; if ( nextoffset != fdt_size_dt_struct ( fdt ) ) return - FDT_ERR_BADLAYOUT ; if ( count < max_regions ) { region [ count ] . offset = base + start ; region [ count ] . size = nextoffset - start ; if ( add_string_tab ) region [ count ] . size += fdt_size_dt_strings ( fdt ) ; } count ++ ; return count ; } "," fdt ) ; bool expect_end = false ; = nextoffset ; if ( expect_end && tag != FDT_END ) return - FDT_ERR_BADLAYOUT ; & len ) ; if ( ! depth && * name ) return - FDT_ERR_BADLAYOUT = '\\0' ; if ( depth == - 1 ) expect_end = true ; ",u-boot@u-boot/8a7d4cf9820ea16fabd25a6379351b4dc291204b,CVE-2021-27097,https://github.com/u-boot/u-boot/commit/8a7d4cf9820ea16fabd25a6379351b4dc291204b,2021-02-17T23:15Z 774,CWE-787,"CWE-787 int ParseDsdiffHeaderConfig ( FILE * infile , char * infilename , char * fourcc , WavpackContext * wpc , WavpackConfig * config ) { int64_t infilesize , total_samples ; DFFFileHeader dff_file_header ; DFFChunkHeader dff_chunk_header ; uint32_t bcount ; infilesize = DoGetFileSize ( infile ) ; memcpy ( & dff_file_header , fourcc , 4 ) ; if ( ( ! DoReadFile ( infile , ( ( char * ) & dff_file_header ) + 4 , sizeof ( DFFFileHeader ) - 4 , & bcount ) || bcount != sizeof ( DFFFileHeader ) - 4 ) || strncmp ( dff_file_header . formType , ""DSD"" , 4 ) ) { error_line ( ""%sisnotavalid.DFFfile!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & dff_file_header , sizeof ( DFFFileHeader ) ) ) { error_line ( ""%s"" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } # if 1 WavpackBigEndianToNative ( & dff_file_header , DFFFileHeaderFormat ) ; if ( infilesize && ! ( config -> qmode & QMODE_IGNORE_LENGTH ) && dff_file_header . ckDataSize && dff_file_header . ckDataSize + 1 && dff_file_header . ckDataSize + 12 != infilesize ) { error_line ( ""%sisnotavalid.DFFfile(bytotalsize)!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } if ( debug_logging_mode ) error_line ( ""fileheaderindicatedlength=%lld"" , dff_file_header . ckDataSize ) ; # endif while ( 1 ) { if ( ! DoReadFile ( infile , & dff_chunk_header , sizeof ( DFFChunkHeader ) , & bcount ) || bcount != sizeof ( DFFChunkHeader ) ) { error_line ( ""%sisnotavalid.DFFfile!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & dff_chunk_header , sizeof ( DFFChunkHeader ) ) ) { error_line ( ""%s"" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } WavpackBigEndianToNative ( & dff_chunk_header , DFFChunkHeaderFormat ) ; if ( debug_logging_mode ) error_line ( ""chunkheaderindicatedlength=%lld"" , dff_chunk_header . ckDataSize ) ; if ( ! strncmp ( dff_chunk_header . ckID , ""FVER"" , 4 ) ) { uint32_t version ; if ( dff_chunk_header . ckDataSize != sizeof ( version ) || ! DoReadFile ( infile , & version , sizeof ( version ) , & bcount ) || bcount != sizeof ( version ) ) { error_line ( ""%sisnotavalid.DFFfile!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & version , sizeof ( version ) ) ) { error_line ( ""%s"" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } WavpackBigEndianToNative ( & version , ""L"" ) ; if ( debug_logging_mode ) error_line ( ""dsdifffileversion=0x%08x"" , version ) ; } else if ( ! strncmp ( dff_chunk_header . ckID , ""PROP"" , 4 ) ) { char * prop_chunk ; if ( dff_chunk_header . ckDataSize < 4 || dff_chunk_header . ckDataSize > 1024 ) { error_line ( ""%sisnotavalid.DFFfile!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } if ( debug_logging_mode ) error_line ( ""gotPROPchunkof%dbytestotal"" , ( int ) dff_chunk_header . ckDataSize ) ; prop_chunk = malloc ( ( size_t ) dff_chunk_header . ckDataSize ) ; if ( ! DoReadFile ( infile , prop_chunk , ( uint32_t ) dff_chunk_header . ckDataSize , & bcount ) || bcount != dff_chunk_header . ckDataSize ) { error_line ( ""%sisnotavalid.DFFfile!"" , infilename ) ; free ( prop_chunk ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , prop_chunk , ( uint32_t ) dff_chunk_header . ckDataSize ) ) { error_line ( ""%s"" , WavpackGetErrorMessage ( wpc ) ) ; free ( prop_chunk ) ; return WAVPACK_SOFT_ERROR ; } if ( ! strncmp ( prop_chunk , ""SND"" , 4 ) ) { char * cptr = prop_chunk + 4 , * eptr = prop_chunk + dff_chunk_header . ckDataSize ; uint16_t numChannels , chansSpecified , chanMask = 0 ; uint32_t sampleRate ; while ( eptr - cptr >= sizeof ( dff_chunk_header ) ) { memcpy ( & dff_chunk_header , cptr , sizeof ( dff_chunk_header ) ) ; cptr += sizeof ( dff_chunk_header ) ; WavpackBigEndianToNative ( & dff_chunk_header , DFFChunkHeaderFormat ) ; if ( eptr - cptr >= dff_chunk_header . ckDataSize ) { if ( ! strncmp ( dff_chunk_header . ckID , ""FS"" , 4 ) && dff_chunk_header . ckDataSize == 4 ) { memcpy ( & sampleRate , cptr , sizeof ( sampleRate ) ) ; WavpackBigEndianToNative ( & sampleRate , ""L"" ) ; cptr += dff_chunk_header . ckDataSize ; if ( debug_logging_mode ) error_line ( ""gotsamplerateof%uHz"" , sampleRate ) ; } else if ( ! strncmp ( dff_chunk_header . ckID , ""CHNL"" , 4 ) && dff_chunk_header . ckDataSize >= 2 ) { memcpy ( & numChannels , cptr , sizeof ( numChannels ) ) ; WavpackBigEndianToNative ( & numChannels , ""S"" ) ; cptr += sizeof ( numChannels ) ; chansSpecified = ( int ) ( dff_chunk_header . ckDataSize - sizeof ( numChannels ) ) / 4 ; while ( chansSpecified -- ) { if ( ! strncmp ( cptr , ""SLFT"" , 4 ) || ! strncmp ( cptr , ""MLFT"" , 4 ) ) chanMask |= 0x1 ; else if ( ! strncmp ( cptr , ""SRGT"" , 4 ) || ! strncmp ( cptr , ""MRGT"" , 4 ) ) chanMask |= 0x2 ; else if ( ! strncmp ( cptr , ""LS"" , 4 ) ) chanMask |= 0x10 ; else if ( ! strncmp ( cptr , ""RS"" , 4 ) ) chanMask |= 0x20 ; else if ( ! strncmp ( cptr , ""C"" , 4 ) ) chanMask |= 0x4 ; else if ( ! strncmp ( cptr , ""LFE"" , 4 ) ) chanMask |= 0x8 ; else if ( debug_logging_mode ) error_line ( ""undefinedchannelID%c%c%c%c"" , cptr [ 0 ] , cptr [ 1 ] , cptr [ 2 ] , cptr [ 3 ] ) ; cptr += 4 ; } if ( debug_logging_mode ) error_line ( ""%dchannels,mask=0x%08x"" , numChannels , chanMask ) ; } else if ( ! strncmp ( dff_chunk_header . ckID , ""CMPR"" , 4 ) && dff_chunk_header . ckDataSize >= 4 ) { if ( strncmp ( cptr , ""DSD"" , 4 ) ) { error_line ( ""DSDIFFfilesmustbeuncompressed,not\\""%c%c%c%c\\""!"" , cptr [ 0 ] , cptr [ 1 ] , cptr [ 2 ] , cptr [ 3 ] ) ; free ( prop_chunk ) ; return WAVPACK_SOFT_ERROR ; } cptr += dff_chunk_header . ckDataSize ; } else { if ( debug_logging_mode ) error_line ( ""gotPROP/SNDchunktype\\""%c%c%c%c\\""of%dbytes"" , dff_chunk_header . ckID [ 0 ] , dff_chunk_header . ckID [ 1 ] , dff_chunk_header . ckID [ 2 ] , dff_chunk_header . ckID [ 3 ] , dff_chunk_header . ckDataSize ) ; cptr += dff_chunk_header . ckDataSize ; } } else { error_line ( ""%sisnotavalid.DFFfile!"" , infilename ) ; free ( prop_chunk ) ; return WAVPACK_SOFT_ERROR ; } } if ( chanMask && ( config -> channel_mask || ( config -> qmode & QMODE_CHANS_UNASSIGNED ) ) ) { error_line ( ""thisDSDIFFfilealreadyhaschannelorderinformation!"" ) ; free ( prop_chunk ) ; return WAVPACK_SOFT_ERROR ; } else if ( chanMask ) config -> channel_mask = chanMask ; config -> bits_per_sample = 8 ; config -> bytes_per_sample = 1 ; config -> num_channels = numChannels ; config -> sample_rate = sampleRate / 8 ; config -> qmode |= QMODE_DSD_MSB_FIRST ; } else if ( debug_logging_mode ) error_line ( ""gotunknownPROPchunktype\\""%c%c%c%c\\""of%dbytes"" , prop_chunk [ 0 ] , prop_chunk [ 1 ] , prop_chunk [ 2 ] , prop_chunk [ 3 ] , dff_chunk_header . ckDataSize ) ; free ( prop_chunk ) ; } else if ( ! strncmp ( dff_chunk_header . ckID , ""DSD"" , 4 ) ) { total_samples = dff_chunk_header . ckDataSize / config -> num_channels ; break ; } else { int bytes_to_copy = ( int ) ( ( ( dff_chunk_header . ckDataSize ) + 1 ) & ~ ( int64_t ) 1 ) ; char * buff = malloc ( bytes_to_copy ) ; if ( debug_logging_mode ) error_line ( ""extraunknownchunk\\""%c%c%c%c\\""of%dbytes"" , dff_chunk_header . ckID [ 0 ] , dff_chunk_header . ckID [ 1 ] , dff_chunk_header . ckID [ 2 ] , dff_chunk_header . ckID [ 3 ] , dff_chunk_header . ckDataSize ) ; if ( ! DoReadFile ( infile , buff , bytes_to_copy , & bcount ) || bcount != bytes_to_copy || ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , buff , bytes_to_copy ) ) ) { error_line ( ""%s"" , WavpackGetErrorMessage ( wpc ) ) ; free ( buff ) ; return WAVPACK_SOFT_ERROR ; } free ( buff ) ; } } if ( debug_logging_mode ) error_line ( ""settingconfigurationwith%lldsamples"" , total_samples ) ; if ( ! WavpackSetConfiguration64 ( wpc , config , total_samples , NULL ) ) { error_line ( ""%s:%s"" , infilename , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } return WAVPACK_NO_ERROR ; } "," char * buff ; if ( bytes_to_copy < 0 || bytes_to_copy > 4194304 ) { error_line ( ""%sisnotavalid.DFFfile!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } buff ",dbry@WavPack/6f8bb34c2993a48ab9afbe353e6d0cff7c8d821d,CVE-2018-10540,https://github.com/dbry/WavPack/commit/6f8bb34c2993a48ab9afbe353e6d0cff7c8d821d,2018-04-29T15:29Z 775,CWE-000,"CWE-000 BIO * PKCS7_dataDecode ( PKCS7 * p7 , EVP_PKEY * pkey , BIO * in_bio , X509 * pcert ) { int i , j ; BIO * out = NULL , * btmp = NULL , * etmp = NULL , * bio = NULL ; X509_ALGOR * xa ; ASN1_OCTET_STRING * data_body = NULL ; const EVP_MD * evp_md ; const EVP_CIPHER * evp_cipher = NULL ; EVP_CIPHER_CTX * evp_ctx = NULL ; X509_ALGOR * enc_alg = NULL ; STACK_OF ( X509_ALGOR ) * md_sk = NULL ; STACK_OF ( PKCS7_RECIP_INFO ) * rsk = NULL ; PKCS7_RECIP_INFO * ri = NULL ; unsigned char * ek = NULL , * tkey = NULL ; int eklen = 0 , tkeylen = 0 ; if ( p7 == NULL ) { PKCS7err ( PKCS7_F_PKCS7_DATADECODE , PKCS7_R_INVALID_NULL_POINTER ) ; return NULL ; } if ( p7 -> d . ptr == NULL ) { PKCS7err ( PKCS7_F_PKCS7_DATADECODE , PKCS7_R_NO_CONTENT ) ; return NULL ; } i = OBJ_obj2nid ( p7 -> type ) ; p7 -> state = PKCS7_S_HEADER ; switch ( i ) { case NID_pkcs7_signed : data_body = PKCS7_get_octet_string ( p7 -> d . sign -> contents ) ; if ( ! PKCS7_is_detached ( p7 ) && data_body == NULL ) { PKCS7err ( PKCS7_F_PKCS7_DATADECODE , PKCS7_R_INVALID_SIGNED_DATA_TYPE ) ; goto err ; } md_sk = p7 -> d . sign -> md_algs ; break ; case NID_pkcs7_signedAndEnveloped : rsk = p7 -> d . signed_and_enveloped -> recipientinfo ; md_sk = p7 -> d . signed_and_enveloped -> md_algs ; data_body = p7 -> d . signed_and_enveloped -> enc_data -> enc_data ; enc_alg = p7 -> d . signed_and_enveloped -> enc_data -> algorithm ; evp_cipher = EVP_get_cipherbyobj ( enc_alg -> algorithm ) ; if ( evp_cipher == NULL ) { PKCS7err ( PKCS7_F_PKCS7_DATADECODE , PKCS7_R_UNSUPPORTED_CIPHER_TYPE ) ; goto err ; } break ; case NID_pkcs7_enveloped : rsk = p7 -> d . enveloped -> recipientinfo ; enc_alg = p7 -> d . enveloped -> enc_data -> algorithm ; data_body = p7 -> d . enveloped -> enc_data -> enc_data ; evp_cipher = EVP_get_cipherbyobj ( enc_alg -> algorithm ) ; if ( evp_cipher == NULL ) { PKCS7err ( PKCS7_F_PKCS7_DATADECODE , PKCS7_R_UNSUPPORTED_CIPHER_TYPE ) ; goto err ; } break ; default : PKCS7err ( PKCS7_F_PKCS7_DATADECODE , PKCS7_R_UNSUPPORTED_CONTENT_TYPE ) ; goto err ; } if ( md_sk != NULL ) { for ( i = 0 ; i < sk_X509_ALGOR_num ( md_sk ) ; i ++ ) { xa = sk_X509_ALGOR_value ( md_sk , i ) ; if ( ( btmp = BIO_new ( BIO_f_md ( ) ) ) == NULL ) { PKCS7err ( PKCS7_F_PKCS7_DATADECODE , ERR_R_BIO_LIB ) ; goto err ; } j = OBJ_obj2nid ( xa -> algorithm ) ; evp_md = EVP_get_digestbynid ( j ) ; if ( evp_md == NULL ) { PKCS7err ( PKCS7_F_PKCS7_DATADECODE , PKCS7_R_UNKNOWN_DIGEST_TYPE ) ; goto err ; } BIO_set_md ( btmp , evp_md ) ; if ( out == NULL ) out = btmp ; else BIO_push ( out , btmp ) ; btmp = NULL ; } } if ( evp_cipher != NULL ) { if ( ( etmp = BIO_new ( BIO_f_cipher ( ) ) ) == NULL ) { PKCS7err ( PKCS7_F_PKCS7_DATADECODE , ERR_R_BIO_LIB ) ; goto err ; } if ( pcert ) { for ( i = 0 ; i < sk_PKCS7_RECIP_INFO_num ( rsk ) ; i ++ ) { ri = sk_PKCS7_RECIP_INFO_value ( rsk , i ) ; if ( ! pkcs7_cmp_ri ( ri , pcert ) ) break ; ri = NULL ; } if ( ri == NULL ) { PKCS7err ( PKCS7_F_PKCS7_DATADECODE , PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE ) ; goto err ; } } if ( pcert == NULL ) { for ( i = 0 ; i < sk_PKCS7_RECIP_INFO_num ( rsk ) ; i ++ ) { ri = sk_PKCS7_RECIP_INFO_value ( rsk , i ) ; if ( pkcs7_decrypt_rinfo ( & ek , & eklen , ri , pkey ) < 0 ) goto err ; ERR_clear_error ( ) ; } } else { if ( pkcs7_decrypt_rinfo ( & ek , & eklen , ri , pkey ) < 0 ) goto err ; ERR_clear_error ( ) ; } evp_ctx = NULL ; BIO_get_cipher_ctx ( etmp , & evp_ctx ) ; if ( EVP_CipherInit_ex ( evp_ctx , evp_cipher , NULL , NULL , NULL , 0 ) <= 0 ) goto err ; if ( EVP_CIPHER_asn1_to_param ( evp_ctx , enc_alg -> parameter ) < 0 ) goto err ; tkeylen = EVP_CIPHER_CTX_key_length ( evp_ctx ) ; tkey = OPENSSL_malloc ( tkeylen ) ; if ( ! tkey ) goto err ; if ( EVP_CIPHER_CTX_rand_key ( evp_ctx , tkey ) <= 0 ) goto err ; if ( ek == NULL ) { ek = tkey ; eklen = tkeylen ; tkey = NULL ; } if ( eklen != EVP_CIPHER_CTX_key_length ( evp_ctx ) ) { if ( ! EVP_CIPHER_CTX_set_key_length ( evp_ctx , eklen ) ) { OPENSSL_clear_free ( ek , eklen ) ; ek = tkey ; eklen = tkeylen ; tkey = NULL ; } } ERR_clear_error ( ) ; if ( EVP_CipherInit_ex ( evp_ctx , NULL , NULL , ek , NULL , 0 ) <= 0 ) goto err ; OPENSSL_clear_free ( ek , eklen ) ; ek = NULL ; OPENSSL_clear_free ( tkey , tkeylen ) ; tkey = NULL ; if ( out == NULL ) out = etmp ; else BIO_push ( out , etmp ) ; etmp = NULL ; } if ( PKCS7_is_detached ( p7 ) || ( in_bio != NULL ) ) { bio = in_bio ; } else { if ( data_body -> length > 0 ) bio = BIO_new_mem_buf ( data_body -> data , data_body -> length ) ; else { bio = BIO_new ( BIO_s_mem ( ) ) ; BIO_set_mem_eof_return ( bio , 0 ) ; } if ( bio == NULL ) goto err ; } BIO_push ( out , bio ) ; bio = NULL ; return out ; err : OPENSSL_clear_free ( ek , eklen ) ; OPENSSL_clear_free ( tkey , tkeylen ) ; BIO_free_all ( out ) ; BIO_free_all ( btmp ) ; BIO_free_all ( etmp ) ; BIO_free_all ( bio ) ; return NULL ; } "," } if ( data_body == NULL && in_bio == NULL ) { PKCS7err ( PKCS7_F_PKCS7_DATADECODE , PKCS7_R_NO_CONTENT ) ; goto err ; } if ( } if ( in_bio != NULL != NULL ) { bio = ",openssl@openssl/59302b600e8d5b77ef144e447bb046fd7ab72686,CVE-2015-1790,https://github.com/openssl/openssl/commit/59302b600e8d5b77ef144e447bb046fd7ab72686,2015-06-12T19:59Z 776,CWE-20,"CWE-20 int serverCron ( struct aeEventLoop * eventLoop , long long id , void * clientData ) { int j , loops = server . cronloops ++ ; REDIS_NOTUSED ( eventLoop ) ; REDIS_NOTUSED ( id ) ; REDIS_NOTUSED ( clientData ) ; server . unixtime = time ( NULL ) ; updateLRUClock ( ) ; if ( server . shutdown_asap ) { if ( prepareForShutdown ( ) == REDIS_OK ) exit ( 0 ) ; redisLog ( REDIS_WARNING , ""SIGTERMreceivedbuterrorstryingtoshutdowntheserver,checkthelogsformoreinformation"" ) ; } for ( j = 0 ; j < server . dbnum ; j ++ ) { long long size , used , vkeys ; size = dictSlots ( server . db [ j ] . dict ) ; used = dictSize ( server . db [ j ] . dict ) ; vkeys = dictSize ( server . db [ j ] . expires ) ; if ( ! ( loops % 50 ) && ( used || vkeys ) ) { redisLog ( REDIS_VERBOSE , ""DB%d:%lldkeys(%lldvolatile)in%lldslotsHT."" , j , used , vkeys , size ) ; } } if ( server . bgsavechildpid == - 1 && server . bgrewritechildpid == - 1 ) { if ( ! ( loops % 10 ) ) tryResizeHashTables ( ) ; if ( server . activerehashing ) incrementallyRehash ( ) ; } if ( ! ( loops % 50 ) ) { redisLog ( REDIS_VERBOSE , ""%dclientsconnected(%dslaves),%zubytesinuse"" , listLength ( server . clients ) - listLength ( server . slaves ) , listLength ( server . slaves ) , zmalloc_used_memory ( ) ) ; } if ( ( server . maxidletime && ! ( loops % 100 ) ) || server . bpop_blocked_clients ) closeTimedoutClients ( ) ; if ( server . bgsavechildpid != - 1 || server . bgrewritechildpid != - 1 ) { int statloc ; pid_t pid ; if ( ( pid = wait3 ( & statloc , WNOHANG , NULL ) ) != 0 ) { if ( pid == server . bgsavechildpid ) { backgroundSaveDoneHandler ( statloc ) ; } else { backgroundRewriteDoneHandler ( statloc ) ; } updateDictResizePolicy ( ) ; } } else { time_t now = time ( NULL ) ; for ( j = 0 ; j < server . saveparamslen ; j ++ ) { struct saveparam * sp = server . saveparams + j ; if ( server . dirty >= sp -> changes && now - server . lastsave > sp -> seconds ) { redisLog ( REDIS_NOTICE , ""%dchangesin%dseconds.Saving..."" , sp -> changes , sp -> seconds ) ; rdbSaveBackground ( server . dbfilename ) ; break ; } } } if ( server . masterhost == NULL ) activeExpireCycle ( ) ; if ( vmCanSwapOut ( ) ) { while ( server . vm_enabled && zmalloc_used_memory ( ) > server . vm_max_memory ) { int retval = ( server . vm_max_threads == 0 ) ? vmSwapOneObjectBlocking ( ) : vmSwapOneObjectThreaded ( ) ; if ( retval == REDIS_ERR && ! ( loops % 300 ) && zmalloc_used_memory ( ) > ( server . vm_max_memory + server . vm_max_memory / 10 ) ) { redisLog ( REDIS_WARNING , ""WARNING:vm-max-memorylimitexceededbymorethan10%%butunabletoswapmoreobjectsout!"" ) ; } if ( retval == REDIS_ERR || server . vm_max_threads > 0 ) break ; } } if ( ! ( loops % 10 ) ) replicationCron ( ) ; return 100 ; } "," ( ) ; while ( server ( server . ds_enabled && zmalloc_used_memory ( > server . cache_max_memory ) { cacheFreeOneEntry ( ) ; } if ( ",antirez@redis/697af434fbeb2e3ba2ba9687cd283ed1a2734fa5,CVE-2013-0178,https://github.com/antirez/redis/commit/697af434fbeb2e3ba2ba9687cd283ed1a2734fa5,2019-11-01T19:15Z 777,CWE-264,"CWE-264 static void uv__process_child_init ( const uv_process_options_t * options , int stdio_count , int ( * pipes ) [ 2 ] , int error_fd ) { int close_fd ; int use_fd ; int fd ; if ( options -> flags & UV_PROCESS_DETACHED ) setsid ( ) ; for ( fd = 0 ; fd < stdio_count ; fd ++ ) { close_fd = pipes [ fd ] [ 0 ] ; use_fd = pipes [ fd ] [ 1 ] ; if ( use_fd < 0 ) { if ( fd >= 3 ) continue ; else { use_fd = open ( ""/dev/null"" , fd == 0 ? O_RDONLY : O_RDWR ) ; close_fd = use_fd ; if ( use_fd == - 1 ) { uv__write_int ( error_fd , - errno ) ; perror ( ""failedtoopenstdio"" ) ; _exit ( 127 ) ; } } } if ( fd == use_fd ) uv__cloexec ( use_fd , 0 ) ; else dup2 ( use_fd , fd ) ; if ( fd <= 2 ) uv__nonblock ( fd , 0 ) ; if ( close_fd != - 1 ) uv__close ( close_fd ) ; } for ( fd = 0 ; fd < stdio_count ; fd ++ ) { use_fd = pipes [ fd ] [ 1 ] ; if ( use_fd >= 0 && fd != use_fd ) close ( use_fd ) ; } if ( options -> cwd != NULL && chdir ( options -> cwd ) ) { uv__write_int ( error_fd , - errno ) ; perror ( ""chdir()"" ) ; _exit ( 127 ) ; } if ( ( options -> flags & UV_PROCESS_SETGID ) && setgid ( options -> gid ) ) { uv__write_int ( error_fd , - errno ) ; perror ( ""setgid()"" ) ; _exit ( 127 ) ; } if ( ( options -> flags & UV_PROCESS_SETUID ) && setuid ( options -> uid ) ) { uv__write_int ( error_fd , - errno ) ; perror ( ""setuid()"" ) ; _exit ( 127 ) ; } if ( options -> env != NULL ) { environ = options -> env ; } execvp ( options -> file , options -> args ) ; uv__write_int ( error_fd , - errno ) ; perror ( ""execvp()"" ) ; _exit ( 127 ) ; } "," } if ( options -> flags & ( UV_PROCESS_SETUID | UV_PROCESS_SETGID ) ) { SAVE_ERRNO ( setgroups ( 0 , NULL ) ) ; } if ( ",libuv@libuv/66ab38918c911bcff025562cf06237d7fedaba0c,CVE-2015-0278,https://github.com/libuv/libuv/commit/66ab38918c911bcff025562cf06237d7fedaba0c,2015-05-18T15:59Z 778,CWE-119,"CWE-119 static int cxusb_ctrl_msg ( struct dvb_usb_device * d , u8 cmd , u8 * wbuf , int wlen , u8 * rbuf , int rlen ) { struct cxusb_state * st = d -> priv ; int ret , wo ; if ( 1 + wlen > MAX_XFER_SIZE ) { warn ( ""i2cwr:len=%distoobig!\\n"" , wlen ) ; return - EOPNOTSUPP ; } wo = ( rbuf == NULL || rlen == 0 ) ; mutex_lock ( & d -> data_mutex ) ; st -> data [ 0 ] = cmd ; memcpy ( & st -> data [ 1 ] , wbuf , wlen ) ; if ( wo ) ret = dvb_usb_generic_write ( d , st -> data , 1 + wlen ) ; else ret = dvb_usb_generic_rw ( d , st -> data , 1 + wlen , rbuf , rlen , 0 ) ; mutex_unlock ( & d -> data_mutex ) ; return ret ; } "," ; int ret ; if ( EOPNOTSUPP ; } if ( rlen > MAX_XFER_SIZE ) { warn ( ""i2crd:len=%distoobig!\\n"" , rlen ) ; return - EOPNOTSUPP ; } mutex_lock ( & wlen ) ; ret = dvb_usb_generic_rw + wlen , st -> data , rlen , rlen , 0 ) ; if ( ! ret && rbuf && rlen ) memcpy ( rbuf , st -> data , rlen ",torvalds@linux/3f190e3aec212fc8c61e202c51400afa7384d4bc,CVE-2017-8063,https://github.com/torvalds/linux/commit/3f190e3aec212fc8c61e202c51400afa7384d4bc,2017-04-23T05:59Z 779,CWE-835,"CWE-835 static void setup_connection ( GsmXSMPClient * client ) { GIOChannel * channel ; int fd ; g_debug ( ""GsmXSMPClient:Settingupnewconnection"" ) ; fd = IceConnectionNumber ( client -> priv -> ice_connection ) ; fcntl ( fd , F_SETFD , fcntl ( fd , F_GETFD , 0 ) | FD_CLOEXEC ) ; channel = g_io_channel_unix_new ( fd ) ; client -> priv -> watch_id = g_io_add_watch ( channel , G_IO_IN | G_IO_ERR , ( GIOFunc ) client_iochannel_watch , client ) ; g_io_channel_unref ( channel ) ; client -> priv -> protocol_timeout = g_timeout_add_seconds ( 5 , ( GSourceFunc ) _client_protocol_timeout , client ) ; set_description ( client ) ; g_debug ( ""GsmXSMPClient:Newclient\'%s\'"" , client -> priv -> description ) ; } "," channel ) ; set_description ( client ",GNOME@gnome-session/b0dc999e0b45355314616321dbb6cb71e729fc9d,CVE-2017-11171,https://github.com/GNOME/gnome-session/commit/b0dc999e0b45355314616321dbb6cb71e729fc9d,2017-07-11T20:29Z 780,CWE-200,"CWE-200 long vorbis_book_decodev_add ( codebook * book , ogg_int32_t * a , oggpack_buffer * b , int n , int point ) { if ( book -> used_entries > 0 ) { ogg_int32_t * v = book -> dec_buf ; int i , j ; if ( ! v ) return - 1 ; for ( i = 0 ; i < n ; ) { if ( decode_map ( book , b , v , point ) ) return - 1 ; for ( j = 0 ; j < book -> dim ; j ++ ) a [ i ++ ] += v [ j ] ; } } return 0 ; } "," book -> dim && i < n ",external@tremolo/eeb4e45d5683f88488c083ecf142dc89bc3f0b47,CVE-2017-0814,https://android.googlesource.com/platform/external/tremolo/+/eeb4e45d5683f88488c083ecf142dc89bc3f0b47,2017-10-04T01:29Z 781,CWE-20,"CWE-20 void BezierCircle ( double r , char * action ) { outpos += sprintf ( outpos , ""%12.3f0m%12.3f%12.3f%12.3f%12.3f0%12.3fc\\n"" , - r , - r , r * BzK , - r * BzK , r , r ) ; outpos += sprintf ( outpos , ""%12.3f%12.3f%12.3f%12.3f%12.3f0c\\n"" , r * BzK , r , r , r * BzK , r ) ; outpos += sprintf ( outpos , ""%12.3f%12.3f%12.3f%12.3f0%12.3fc\\n"" , r , - r * BzK , r * BzK , - r , - r ) ; outpos += sprintf ( outpos , ""%12.3f%12.3f%12.3f%12.3f%12.3f0c%s\\n"" , - r * BzK , - r , - r , - r * BzK , - r , action ) ; } "," action ) { char * outpos = outputbuffer ; action ) ; sendClean ( outputbuffer ) ; ",TeX-Live@texlive-source/9216833a3888a4105a18e8c349f65b045ddb1079,CVE-2019-18604,https://github.com/TeX-Live/texlive-source/commit/9216833a3888a4105a18e8c349f65b045ddb1079,2019-10-29T19:15Z 782,CWE-310,"CWE-310 static noinline int create_pending_snapshot ( struct btrfs_trans_handle * trans , struct btrfs_fs_info * fs_info , struct btrfs_pending_snapshot * pending ) { struct btrfs_key key ; struct btrfs_root_item * new_root_item ; struct btrfs_root * tree_root = fs_info -> tree_root ; struct btrfs_root * root = pending -> root ; struct btrfs_root * parent_root ; struct btrfs_block_rsv * rsv ; struct inode * parent_inode ; struct btrfs_path * path ; struct btrfs_dir_item * dir_item ; struct dentry * parent ; struct dentry * dentry ; struct extent_buffer * tmp ; struct extent_buffer * old ; struct timespec cur_time = CURRENT_TIME ; int ret ; u64 to_reserve = 0 ; u64 index = 0 ; u64 objectid ; u64 root_flags ; uuid_le new_uuid ; path = btrfs_alloc_path ( ) ; if ( ! path ) { ret = pending -> error = - ENOMEM ; goto path_alloc_fail ; } new_root_item = kmalloc ( sizeof ( * new_root_item ) , GFP_NOFS ) ; if ( ! new_root_item ) { ret = pending -> error = - ENOMEM ; goto root_item_alloc_fail ; } ret = btrfs_find_free_objectid ( tree_root , & objectid ) ; if ( ret ) { pending -> error = ret ; goto no_free_objectid ; } btrfs_reloc_pre_snapshot ( trans , pending , & to_reserve ) ; if ( to_reserve > 0 ) { ret = btrfs_block_rsv_add ( root , & pending -> block_rsv , to_reserve , BTRFS_RESERVE_NO_FLUSH ) ; if ( ret ) { pending -> error = ret ; goto no_free_objectid ; } } ret = btrfs_qgroup_inherit ( trans , fs_info , root -> root_key . objectid , objectid , pending -> inherit ) ; if ( ret ) { pending -> error = ret ; goto no_free_objectid ; } key . objectid = objectid ; key . offset = ( u64 ) - 1 ; key . type = BTRFS_ROOT_ITEM_KEY ; rsv = trans -> block_rsv ; trans -> block_rsv = & pending -> block_rsv ; dentry = pending -> dentry ; parent = dget_parent ( dentry ) ; parent_inode = parent -> d_inode ; parent_root = BTRFS_I ( parent_inode ) -> root ; record_root_in_trans ( trans , parent_root ) ; ret = btrfs_set_inode_index ( parent_inode , & index ) ; BUG_ON ( ret ) ; dir_item = btrfs_lookup_dir_item ( NULL , parent_root , path , btrfs_ino ( parent_inode ) , dentry -> d_name . name , dentry -> d_name . len , 0 ) ; if ( dir_item != NULL && ! IS_ERR ( dir_item ) ) { pending -> error = - EEXIST ; goto fail ; } else if ( IS_ERR ( dir_item ) ) { ret = PTR_ERR ( dir_item ) ; btrfs_abort_transaction ( trans , root , ret ) ; goto fail ; } btrfs_release_path ( path ) ; ret = btrfs_run_delayed_items ( trans , root ) ; if ( ret ) { btrfs_abort_transaction ( trans , root , ret ) ; goto fail ; } record_root_in_trans ( trans , root ) ; btrfs_set_root_last_snapshot ( & root -> root_item , trans -> transid ) ; memcpy ( new_root_item , & root -> root_item , sizeof ( * new_root_item ) ) ; btrfs_check_and_init_root_item ( new_root_item ) ; root_flags = btrfs_root_flags ( new_root_item ) ; if ( pending -> readonly ) root_flags |= BTRFS_ROOT_SUBVOL_RDONLY ; else root_flags &= ~ BTRFS_ROOT_SUBVOL_RDONLY ; btrfs_set_root_flags ( new_root_item , root_flags ) ; btrfs_set_root_generation_v2 ( new_root_item , trans -> transid ) ; uuid_le_gen ( & new_uuid ) ; memcpy ( new_root_item -> uuid , new_uuid . b , BTRFS_UUID_SIZE ) ; memcpy ( new_root_item -> parent_uuid , root -> root_item . uuid , BTRFS_UUID_SIZE ) ; new_root_item -> otime . sec = cpu_to_le64 ( cur_time . tv_sec ) ; new_root_item -> otime . nsec = cpu_to_le32 ( cur_time . tv_nsec ) ; btrfs_set_root_otransid ( new_root_item , trans -> transid ) ; memset ( & new_root_item -> stime , 0 , sizeof ( new_root_item -> stime ) ) ; memset ( & new_root_item -> rtime , 0 , sizeof ( new_root_item -> rtime ) ) ; btrfs_set_root_stransid ( new_root_item , 0 ) ; btrfs_set_root_rtransid ( new_root_item , 0 ) ; old = btrfs_lock_root_node ( root ) ; ret = btrfs_cow_block ( trans , root , old , NULL , 0 , & old ) ; if ( ret ) { btrfs_tree_unlock ( old ) ; free_extent_buffer ( old ) ; btrfs_abort_transaction ( trans , root , ret ) ; goto fail ; } btrfs_set_lock_blocking ( old ) ; ret = btrfs_copy_root ( trans , root , old , & tmp , objectid ) ; btrfs_tree_unlock ( old ) ; free_extent_buffer ( old ) ; if ( ret ) { btrfs_abort_transaction ( trans , root , ret ) ; goto fail ; } root -> force_cow = 1 ; smp_wmb ( ) ; btrfs_set_root_node ( new_root_item , tmp ) ; key . offset = trans -> transid ; ret = btrfs_insert_root ( trans , tree_root , & key , new_root_item ) ; btrfs_tree_unlock ( tmp ) ; free_extent_buffer ( tmp ) ; if ( ret ) { btrfs_abort_transaction ( trans , root , ret ) ; goto fail ; } ret = btrfs_add_root_ref ( trans , tree_root , objectid , parent_root -> root_key . objectid , btrfs_ino ( parent_inode ) , index , dentry -> d_name . name , dentry -> d_name . len ) ; if ( ret ) { btrfs_abort_transaction ( trans , root , ret ) ; goto fail ; } key . offset = ( u64 ) - 1 ; pending -> snap = btrfs_read_fs_root_no_name ( root -> fs_info , & key ) ; if ( IS_ERR ( pending -> snap ) ) { ret = PTR_ERR ( pending -> snap ) ; btrfs_abort_transaction ( trans , root , ret ) ; goto fail ; } ret = btrfs_reloc_post_snapshot ( trans , pending ) ; if ( ret ) { btrfs_abort_transaction ( trans , root , ret ) ; goto fail ; } ret = btrfs_run_delayed_refs ( trans , root , ( unsigned long ) - 1 ) ; if ( ret ) { btrfs_abort_transaction ( trans , root , ret ) ; goto fail ; } ret = btrfs_insert_dir_item ( trans , parent_root , dentry -> d_name . name , dentry -> d_name . len , parent_inode , & key , BTRFS_FT_DIR , index ) ; BUG_ON ( ret == - EEXIST ) ; if ( ret ) { btrfs_abort_transaction ( trans , root , ret ) ; goto fail ; } btrfs_i_size_write ( parent_inode , parent_inode -> i_size + dentry -> d_name . len * 2 ) ; parent_inode -> i_mtime = parent_inode -> i_ctime = CURRENT_TIME ; ret = btrfs_update_inode_fallback ( trans , parent_root , parent_inode ) ; if ( ret ) btrfs_abort_transaction ( trans , root , ret ) ; fail : dput ( parent ) ; trans -> block_rsv = rsv ; no_free_objectid : kfree ( new_root_item ) ; root_item_alloc_fail : btrfs_free_path ( path ) ; path_alloc_fail : btrfs_block_rsv_release ( root , & pending -> block_rsv , ( u64 ) - 1 ) ; return ret ; } "," == - EEXIST || ret == - EOVERFLOW ",torvalds@linux/9c52057c698fb96f8f07e7a4bcf4801a092bda89,CVE-2012-5375,https://github.com/torvalds/linux/commit/9c52057c698fb96f8f07e7a4bcf4801a092bda89,2013-02-18T11:56Z 783,CWE-119,"CWE-119 void unix_notinflight ( struct file * fp ) { struct sock * s = unix_get_socket ( fp ) ; if ( s ) { struct unix_sock * u = unix_sk ( s ) ; spin_lock ( & unix_gc_lock ) ; BUG_ON ( list_empty ( & u -> link ) ) ; if ( atomic_long_dec_and_test ( & u -> inflight ) ) list_del_init ( & u -> link ) ; unix_tot_inflight -- ; spin_unlock ( & unix_gc_lock ) ; } } "," fp ) ; spin_lock ( & unix_gc_lock ) ; unix_sk ( s ) ; BUG_ON unix_tot_inflight -- ; } fp -> f_cred -> user -> unix_inflight -- ; ) ; } ",torvalds@linux/712f4aad406bb1ed67f3f98d04c044191f0ff593,CVE-2013-4312,https://github.com/torvalds/linux/commit/712f4aad406bb1ed67f3f98d04c044191f0ff593,2016-02-08T03:59Z 784,CWE-119,"CWE-119 static int aiff_read_chanmap ( SF_PRIVATE * psf , unsigned dword ) { const AIFF_CAF_CHANNEL_MAP * map_info ; unsigned channel_bitmap , channel_decriptions , bytesread ; int layout_tag ; bytesread = psf_binheader_readf ( psf , ""444"" , & layout_tag , & channel_bitmap , & channel_decriptions ) ; if ( ( map_info = aiff_caf_of_channel_layout_tag ( layout_tag ) ) == NULL ) return 0 ; psf_log_printf ( psf , ""Tag:%x\\n"" , layout_tag ) ; if ( map_info ) psf_log_printf ( psf , ""Layout:%s\\n"" , map_info -> name ) ; if ( bytesread < dword ) psf_binheader_readf ( psf , ""j"" , dword - bytesread ) ; if ( map_info -> channel_map != NULL ) { size_t chanmap_size = psf -> sf . channels * sizeof ( psf -> channel_map [ 0 ] ) ; free ( psf -> channel_map ) ; if ( ( psf -> channel_map = malloc ( chanmap_size ) ) == NULL ) return SFE_MALLOC_FAILED ; memcpy ( psf -> channel_map , map_info -> channel_map , chanmap_size ) ; } ; return 0 ; } "," size_t chanmap_size = SF_MIN ( sf . channels , layout_tag & 0xffff ) ",erikd@libsndfile/f833c53cb596e9e1792949f762e0b33661822748,CVE-2017-6892,https://github.com/erikd/libsndfile/commit/f833c53cb596e9e1792949f762e0b33661822748,2017-06-12T16:29Z 785,CWE-119,"CWE-119 void vp9_setup_scale_factors_for_frame ( struct scale_factors * sf , int other_w , int other_h , int this_w , int this_h ) { if ( ! check_scale_factors ( other_w , other_h , this_w , this_h ) ) { sf -> x_scale_fp = REF_INVALID_SCALE ; sf -> y_scale_fp = REF_INVALID_SCALE ; return ; } sf -> x_scale_fp = get_fixed_point_scale_factor ( other_w , this_w ) ; sf -> y_scale_fp = get_fixed_point_scale_factor ( other_h , this_h ) ; sf -> x_step_q4 = scaled_x ( 16 , sf ) ; sf -> y_step_q4 = scaled_y ( 16 , sf ) ; if ( vp9_is_scaled ( sf ) ) { sf -> scale_value_x = scaled_x ; sf -> scale_value_y = scaled_y ; } else { sf -> scale_value_x = unscaled_value ; sf -> scale_value_y = unscaled_value ; } if ( sf -> x_step_q4 == 16 ) { if ( sf -> y_step_q4 == 16 ) { sf -> predict [ 0 ] [ 0 ] [ 0 ] = vp9_convolve_copy ; sf -> predict [ 0 ] [ 0 ] [ 1 ] = vp9_convolve_avg ; sf -> predict [ 0 ] [ 1 ] [ 0 ] = vp9_convolve8_vert ; sf -> predict [ 0 ] [ 1 ] [ 1 ] = vp9_convolve8_avg_vert ; sf -> predict [ 1 ] [ 0 ] [ 0 ] = vp9_convolve8_horiz ; sf -> predict [ 1 ] [ 0 ] [ 1 ] = vp9_convolve8_avg_horiz ; } else { sf -> predict [ 0 ] [ 0 ] [ 0 ] = vp9_convolve8_vert ; sf -> predict [ 0 ] [ 0 ] [ 1 ] = vp9_convolve8_avg_vert ; sf -> predict [ 0 ] [ 1 ] [ 0 ] = vp9_convolve8_vert ; sf -> predict [ 0 ] [ 1 ] [ 1 ] = vp9_convolve8_avg_vert ; sf -> predict [ 1 ] [ 0 ] [ 0 ] = vp9_convolve8 ; sf -> predict [ 1 ] [ 0 ] [ 1 ] = vp9_convolve8_avg ; } } else { if ( sf -> y_step_q4 == 16 ) { sf -> predict [ 0 ] [ 0 ] [ 0 ] = vp9_convolve8_horiz ; sf -> predict [ 0 ] [ 0 ] [ 1 ] = vp9_convolve8_avg_horiz ; sf -> predict [ 0 ] [ 1 ] [ 0 ] = vp9_convolve8 ; sf -> predict [ 0 ] [ 1 ] [ 1 ] = vp9_convolve8_avg ; sf -> predict [ 1 ] [ 0 ] [ 0 ] = vp9_convolve8_horiz ; sf -> predict [ 1 ] [ 0 ] [ 1 ] = vp9_convolve8_avg_horiz ; } else { sf -> predict [ 0 ] [ 0 ] [ 0 ] = vp9_convolve8 ; sf -> predict [ 0 ] [ 0 ] [ 1 ] = vp9_convolve8_avg ; sf -> predict [ 0 ] [ 1 ] [ 0 ] = vp9_convolve8 ; sf -> predict [ 0 ] [ 1 ] [ 1 ] = vp9_convolve8_avg ; sf -> predict [ 1 ] [ 0 ] [ 0 ] = vp9_convolve8 ; sf -> predict [ 1 ] [ 0 ] [ 1 ] = vp9_convolve8_avg ; } } sf -> predict [ 1 ] [ 1 ] [ 0 ] = vp9_convolve8 ; sf -> predict [ 1 ] [ 1 ] [ 1 ] = vp9_convolve8_avg ; } "," this_h ) { # endif if ( ! valid_ref_frame_size ( other_w , 0 ] = vpx_convolve_copy ; sf -> predict [ 0 ] [ 0 ] [ 1 ] = vpx_convolve_avg ; sf -> predict [ 0 ] [ 1 ] [ 0 ] = vpx_convolve8_vert ; sf -> predict [ 0 ] [ 1 ] [ 1 ] = vpx_convolve8_avg_vert ; sf -> predict [ 1 ] [ 0 ] [ 0 ] = vpx_convolve8_horiz ; sf -> predict [ 1 ] [ 0 ] [ 1 ] = vpx_convolve8_avg_horiz ; } else 0 ] = vpx_scaled_vert ; sf -> predict [ 0 ] [ 0 ] [ 1 ] = vpx_scaled_avg_vert ; sf -> predict [ 0 ] [ 1 ] [ 0 ] = vpx_scaled_vert ; sf -> predict [ 0 ] [ 1 ] [ 1 ] = vpx_scaled_avg_vert ; sf -> predict [ 1 ] [ 0 ] [ 0 ] = vpx_scaled_2d ; sf -> predict [ 1 ] [ 0 ] [ 1 ] = vpx_scaled_avg_2d ; } } 0 ] = vpx_scaled_horiz ; sf -> predict [ 0 ] [ 0 ] [ 1 ] = vpx_scaled_avg_horiz ; sf -> predict [ 0 ] [ 1 ] [ 0 ] = vpx_scaled_2d ; sf -> predict [ 0 ] [ 1 ] [ 1 ] = vpx_scaled_avg_2d ; sf -> predict [ 1 ] [ 0 ] [ 0 ] = vpx_scaled_horiz ; sf -> predict [ 1 ] [ 0 ] [ 1 ] = vpx_scaled_avg_horiz ; } else 0 ] = vpx_scaled_2d ; sf -> predict [ 0 ] [ 0 ] [ 1 ] = vpx_scaled_avg_2d ; sf -> predict [ 0 ] [ 1 ] [ 0 ] = vpx_scaled_2d ; sf -> predict [ 0 ] [ 1 ] [ 1 ] = vpx_scaled_avg_2d ; sf -> predict [ 1 ] [ 0 ] [ 0 ] = vpx_scaled_2d ; sf -> predict [ 1 ] [ 0 ] [ 1 ] = vpx_scaled_avg_2d ; } } if ( ( sf -> x_step_q4 != 16 ) || ( sf -> y_step_q4 != 16 ) ) { sf -> predict [ 1 ] [ 1 ] [ 0 ] = vpx_scaled_2d ; sf -> predict [ 1 ] [ 1 ] [ 1 ] = vpx_scaled_avg_2d ; } else { sf -> predict [ 1 ] [ 1 ] [ 0 ] = vpx_convolve8 ; sf -> predict [ 1 ] [ 1 ] [ 1 ] = vpx_convolve8_avg ; } # if CONFIG_VP9_HIGHBITDEPTH if ( use_highbd ) { if ( sf -> x_step_q4 == 16 ) { if ( sf -> y_step_q4 == 16 ) { sf -> highbd_predict [ 0 ] [ 0 ] [ 0 ] = vpx_highbd_convolve_copy ; sf -> highbd_predict [ 0 ] [ 0 ] [ 1 ] = vpx_highbd_convolve_avg ; sf -> highbd_predict [ 0 ] [ 1 ] [ 0 ] = vpx_highbd_convolve8_vert ; sf -> highbd_predict [ 0 ] [ 1 ] [ 1 ] = vpx_highbd_convolve8_avg_vert ; sf -> highbd_predict [ 1 ] [ 0 ] [ 0 ] = vpx_highbd_convolve8_horiz ; sf -> highbd_predict [ 1 ] [ 0 ] [ 1 ] = vpx_highbd_convolve8_avg_horiz ; } else { sf -> highbd_predict [ 0 ] [ 0 ] [ 0 ] = vpx_highbd_convolve8_vert ; sf -> highbd_predict [ 0 ] [ 0 ] [ 1 ] = vpx_highbd_convolve8_avg_vert ; sf -> highbd_predict [ 0 ] [ 1 ] [ 0 ] = vpx_highbd_convolve8_vert ; sf -> highbd_predict [ 0 ] [ 1 ] [ 1 ] = vpx_highbd_convolve8_avg_vert ; sf -> highbd_predict [ 1 ] [ 0 ] [ 0 ] = vpx_highbd_convolve8 ; sf -> highbd_predict [ 1 ] [ 0 ] [ 1 ] = vpx_highbd_convolve8_avg ; } } else { if ( sf -> y_step_q4 == 16 ) { sf -> highbd_predict [ 0 ] [ 0 ] [ 0 ] = vpx_highbd_convolve8_horiz ; sf -> highbd_predict [ 0 ] [ 0 ] [ 1 ] = vpx_highbd_convolve8_avg_horiz ; sf -> highbd_predict [ 0 ] [ 1 ] [ 0 ] = vpx_highbd_convolve8 ; sf -> highbd_predict [ 0 ] [ 1 ] [ 1 ] = vpx_highbd_convolve8_avg ; sf -> highbd_predict [ 1 ] [ 0 ] [ 0 ] = vpx_highbd_convolve8_horiz ; sf -> highbd_predict [ 1 ] [ 0 ] [ 1 ] = vpx_highbd_convolve8_avg_horiz ; } else { sf -> highbd_predict [ 0 ] [ 0 ] [ 0 ] = vpx_highbd_convolve8 ; sf -> highbd_predict [ 0 ] [ 0 ] [ 1 ] = vpx_highbd_convolve8_avg ; sf -> highbd_predict [ 0 ] [ 1 ] [ 0 ] = vpx_highbd_convolve8 ; sf -> highbd_predict [ 0 ] [ 1 ] [ 1 ] = vpx_highbd_convolve8_avg ; sf -> highbd_predict [ 1 ] [ 0 ] [ 0 ] = vpx_highbd_convolve8 ; sf -> highbd_predict [ 1 ] [ 0 ] [ 1 ] = vpx_highbd_convolve8_avg ; } } sf -> highbd_predict [ 1 ] [ 1 ] [ 0 ] = vpx_highbd_convolve8 ; sf -> highbd_predict [ 1 ] [ 1 ] [ 1 ] = vpx_highbd_convolve8_avg ; } # endif } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 786,CWE-787,"CWE-787 GPMF_ERR IsValidSize ( GPMF_stream * ms , uint32_t size ) { if ( ms ) { int32_t nestsize = ( int32_t ) ms -> nest_size [ ms -> nest_level ] ; if ( nestsize == 0 && ms -> nest_level == 0 ) nestsize = ms -> buffer_size_longs ; if ( size + 2 <= nestsize ) return GPMF_OK ; } return GPMF_ERROR_BAD_STRUCTURE ; } "," ms ) { uint32_t nestsize = ( nestsize = ( uint32_t ) ms -> ",gopro@gpmf-parser/341f12cd5b97ab419e53853ca00176457c9f1681,CVE-2019-15148,https://github.com/gopro/gpmf-parser/commit/341f12cd5b97ab419e53853ca00176457c9f1681,2019-08-18T19:15Z 787,CWE-399,"CWE-399 int handle_unaligned_access ( insn_size_t instruction , struct pt_regs * regs , struct mem_access * ma , int expected , unsigned long address ) { u_int rm ; int ret , index ; if ( instruction_size ( instruction ) != 2 ) return - EINVAL ; index = ( instruction >> 8 ) & 15 ; rm = regs -> regs [ index ] ; if ( ! expected ) { unaligned_fixups_notify ( current , instruction , regs ) ; perf_sw_event ( PERF_COUNT_SW_ALIGNMENT_FAULTS , 1 , 0 , regs , address ) ; } ret = - EFAULT ; switch ( instruction & 0xF000 ) { case 0x0000 : if ( instruction == 0x000B ) { ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) regs -> pc = regs -> pr ; } else if ( ( instruction & 0x00FF ) == 0x0023 ) { ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) regs -> pc += rm + 4 ; } else if ( ( instruction & 0x00FF ) == 0x0003 ) { ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) { regs -> pr = regs -> pc + 4 ; regs -> pc += rm + 4 ; } } else { goto simple ; } break ; case 0x1000 : goto simple ; case 0x2000 : goto simple ; case 0x4000 : if ( ( instruction & 0x00FF ) == 0x002B ) { ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) regs -> pc = rm ; } else if ( ( instruction & 0x00FF ) == 0x000B ) { ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) { regs -> pr = regs -> pc + 4 ; regs -> pc = rm ; } } else { goto simple ; } break ; case 0x5000 : goto simple ; case 0x6000 : goto simple ; case 0x8000 : switch ( instruction & 0x0F00 ) { case 0x0100 : goto simple ; case 0x0500 : goto simple ; case 0x0B00 : break ; case 0x0F00 : ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) { # if defined ( CONFIG_CPU_SH4 ) || defined ( CONFIG_SH7705_CACHE_32KB ) if ( ( regs -> sr & 0x00000001 ) != 0 ) regs -> pc += 4 ; else # endif regs -> pc += SH_PC_8BIT_OFFSET ( instruction ) ; } break ; case 0x0900 : break ; case 0x0D00 : ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) { # if defined ( CONFIG_CPU_SH4 ) || defined ( CONFIG_SH7705_CACHE_32KB ) if ( ( regs -> sr & 0x00000001 ) == 0 ) regs -> pc += 4 ; else # endif regs -> pc += SH_PC_8BIT_OFFSET ( instruction ) ; } break ; } break ; case 0xA000 : ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) regs -> pc += SH_PC_12BIT_OFFSET ( instruction ) ; break ; case 0xB000 : ret = handle_delayslot ( regs , instruction , ma ) ; if ( ret == 0 ) { regs -> pr = regs -> pc + 4 ; regs -> pc += SH_PC_12BIT_OFFSET ( instruction ) ; } break ; } return ret ; simple : ret = handle_unaligned_ins ( instruction , regs , ma ) ; if ( ret == 0 ) regs -> pc += instruction_size ( instruction ) ; return ret ; } "," , 1 , regs , address ",torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,CVE-2011-2918,https://github.com/torvalds/linux/commit/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,2012-05-24T23:55Z 788,CWE-119,"CWE-119 static int mark_source_chains ( const struct xt_table_info * newinfo , unsigned int valid_hooks , void * entry0 ) { unsigned int hook ; for ( hook = 0 ; hook < NF_INET_NUMHOOKS ; hook ++ ) { unsigned int pos = newinfo -> hook_entry [ hook ] ; struct ip6t_entry * e = ( struct ip6t_entry * ) ( entry0 + pos ) ; if ( ! ( valid_hooks & ( 1 << hook ) ) ) continue ; e -> counters . pcnt = pos ; for ( ; ; ) { const struct xt_standard_target * t = ( void * ) ip6t_get_target_c ( e ) ; int visited = e -> comefrom & ( 1 << hook ) ; if ( e -> comefrom & ( 1 << NF_INET_NUMHOOKS ) ) { pr_err ( ""iptables:loophook%upos%u%08X.\\n"" , hook , pos , e -> comefrom ) ; return 0 ; } e -> comefrom |= ( ( 1 << hook ) | ( 1 << NF_INET_NUMHOOKS ) ) ; if ( ( e -> target_offset == sizeof ( struct ip6t_entry ) && ( strcmp ( t -> target . u . user . name , XT_STANDARD_TARGET ) == 0 ) && t -> verdict < 0 && unconditional ( & e -> ipv6 ) ) || visited ) { unsigned int oldpos , size ; if ( ( strcmp ( t -> target . u . user . name , XT_STANDARD_TARGET ) == 0 ) && t -> verdict < - NF_MAX_VERDICT - 1 ) { duprintf ( ""mark_source_chains:bad"" ""negativeverdict(%i)\\n"" , t -> verdict ) ; return 0 ; } do { e -> comefrom ^= ( 1 << NF_INET_NUMHOOKS ) ; # ifdef DEBUG_IP_FIREWALL_USER if ( e -> comefrom & ( 1 << NF_INET_NUMHOOKS ) ) { duprintf ( ""Backunset"" ""onhook%u"" ""rule%u\\n"" , hook , pos ) ; } # endif oldpos = pos ; pos = e -> counters . pcnt ; e -> counters . pcnt = 0 ; if ( pos == oldpos ) goto next ; e = ( struct ip6t_entry * ) ( entry0 + pos ) ; } while ( oldpos == pos + e -> next_offset ) ; size = e -> next_offset ; e = ( struct ip6t_entry * ) ( entry0 + pos + size ) ; e -> counters . pcnt = pos ; pos += size ; } else { int newpos = t -> verdict ; if ( strcmp ( t -> target . u . user . name , XT_STANDARD_TARGET ) == 0 && newpos >= 0 ) { if ( newpos > newinfo -> size - sizeof ( struct ip6t_entry ) ) { duprintf ( ""mark_source_chains:"" ""badverdict(%i)\\n"" , newpos ) ; return 0 ; } duprintf ( ""Jumprule%u->%u\\n"" , pos , newpos ) ; } else { newpos = pos + e -> next_offset ; } e = ( struct ip6t_entry * ) ( entry0 + newpos ) ; e -> counters . pcnt = pos ; pos = newpos ; } } next : duprintf ( ""Finishedchain%u\\n"" , hook ) ; } return 1 ; } "," if ( ( unconditional ( e ) && ( verdict < 0 ) || visited ",torvalds@linux/54d83fc74aa9ec72794373cb47432c5f7fb1a309,CVE-2016-3134,https://github.com/torvalds/linux/commit/54d83fc74aa9ec72794373cb47432c5f7fb1a309,2016-04-27T17:59Z 789,CWE-787,"CWE-787 int pdf_load_xrefs ( FILE * fp , pdf_t * pdf ) { int i , ver , is_linear ; long pos , pos_count ; char x , * c , buf [ 256 ] ; c = NULL ; pdf -> n_xrefs = 0 ; fseek ( fp , 0 , SEEK_SET ) ; while ( get_next_eof ( fp ) >= 0 ) ++ pdf -> n_xrefs ; if ( ! pdf -> n_xrefs ) return 0 ; fseek ( fp , 0 , SEEK_SET ) ; pdf -> xrefs = calloc ( 1 , sizeof ( xref_t ) * pdf -> n_xrefs ) ; ver = 1 ; for ( i = 0 ; i < pdf -> n_xrefs ; i ++ ) { if ( ( pos = get_next_eof ( fp ) ) < 0 ) break ; pdf -> xrefs [ i ] . version = ver ++ ; pos_count = 0 ; while ( SAFE_F ( fp , ( ( x = fgetc ( fp ) ) != 'f' ) ) ) fseek ( fp , pos - ( ++ pos_count ) , SEEK_SET ) ; if ( pos_count >= sizeof ( buf ) ) { ERR ( ""Failedtolocatethestartxreftoken."" ""ThismightbeacorruptPDF.\\n"" ) ; return - 1 ; } memset ( buf , 0 , sizeof ( buf ) ) ; SAFE_E ( fread ( buf , 1 , pos_count , fp ) , pos_count , ""Failedtoreadstartxref.\\n"" ) ; c = buf ; while ( * c == '' || * c == '\\n' || * c == '\\r' ) ++ c ; pdf -> xrefs [ i ] . start = atol ( c ) ; if ( pdf -> xrefs [ i ] . start == 0 ) get_xref_linear_skipped ( fp , & pdf -> xrefs [ i ] ) ; else { pos = ftell ( fp ) ; fseek ( fp , pdf -> xrefs [ i ] . start , SEEK_SET ) ; pdf -> xrefs [ i ] . end = get_next_eof ( fp ) ; fseek ( fp , pos , SEEK_SET ) ; } if ( ! is_valid_xref ( fp , pdf , & pdf -> xrefs [ i ] ) ) { is_linear = pdf -> xrefs [ i ] . is_linear ; memset ( & pdf -> xrefs [ i ] , 0 , sizeof ( xref_t ) ) ; pdf -> xrefs [ i ] . is_linear = is_linear ; rewind ( fp ) ; get_next_eof ( fp ) ; continue ; } load_xref_entries ( fp , & pdf -> xrefs [ i ] ) ; } if ( pdf -> xrefs [ 0 ] . is_linear ) resolve_linearized_pdf ( pdf ) ; load_creator ( fp , pdf ) ; return pdf -> n_xrefs ; } "," -> xrefs = safe_calloc ( sizeof ( xref_t ",enferex@pdfresurrect/0c4120fffa3dffe97b95c486a120eded82afe8a6,CVE-2019-14934,https://github.com/enferex/pdfresurrect/commit/0c4120fffa3dffe97b95c486a120eded82afe8a6,2019-08-11T22:15Z 790,CWE-552,"CWE-552 static ssize_t _hostsock_recv ( oe_fd_t * sock_ , void * buf , size_t count , int flags ) { ssize_t ret = - 1 ; sock_t * sock = _cast_sock ( sock_ ) ; oe_errno = 0 ; if ( ! sock || ( count && ! buf ) ) OE_RAISE_ERRNO ( OE_EINVAL ) ; if ( buf ) { if ( oe_memset_s ( buf , count , 0 , count ) != OE_OK ) OE_RAISE_ERRNO ( OE_EINVAL ) ; } if ( oe_syscall_recv_ocall ( & ret , sock -> host_fd , buf , count , flags ) != OE_OK ) OE_RAISE_ERRNO ( OE_EINVAL ) ; done : return ret ; } "," ! buf ) || count > OE_SSIZE_MAX OE_EINVAL ) ; if ( ret > ( ssize_t ) count ) { ret = - 1 ; OE_RAISE_ERRNO ( OE_EINVAL ) ; } ",openenclave@openenclave/bcac8e7acb514429fee9e0b5d0c7a0308fd4d76b,CVE-2020-15224,https://github.com/openenclave/openenclave/commit/bcac8e7acb514429fee9e0b5d0c7a0308fd4d76b,2020-10-14T19:15Z 791,CWE-416,"CWE-416 void inet6_destroy_sock ( struct sock * sk ) { struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct sk_buff * skb ; struct ipv6_txoptions * opt ; skb = xchg ( & np -> pktoptions , NULL ) ; if ( skb ) kfree_skb ( skb ) ; skb = xchg ( & np -> rxpmtu , NULL ) ; if ( skb ) kfree_skb ( skb ) ; fl6_free_socklist ( sk ) ; opt = xchg ( & np -> opt , NULL ) ; if ( opt ) sock_kfree_s ( sk , opt , opt -> tot_len ) ; } "," = xchg ( ( __force struct ipv6_txoptions * * ) ( opt ) { atomic_sub ( opt -> tot_len opt -> tot_len , & sk -> sk_omem_alloc ) ; txopt_put ( opt ) ; } } ",torvalds@linux/45f6fad84cc305103b28d73482b344d7f5b76f39,CVE-2016-3841,https://github.com/torvalds/linux/commit/45f6fad84cc305103b28d73482b344d7f5b76f39,2016-08-06T20:59Z 792,CWE-399,"CWE-399 int CMS_verify ( CMS_ContentInfo * cms , STACK_OF ( X509 ) * certs , X509_STORE * store , BIO * dcont , BIO * out , unsigned int flags ) { CMS_SignerInfo * si ; STACK_OF ( CMS_SignerInfo ) * sinfos ; STACK_OF ( X509 ) * cms_certs = NULL ; STACK_OF ( X509_CRL ) * crls = NULL ; X509 * signer ; int i , scount = 0 , ret = 0 ; BIO * cmsbio = NULL , * tmpin = NULL ; if ( ! dcont && ! check_content ( cms ) ) return 0 ; sinfos = CMS_get0_SignerInfos ( cms ) ; if ( sk_CMS_SignerInfo_num ( sinfos ) <= 0 ) { CMSerr ( CMS_F_CMS_VERIFY , CMS_R_NO_SIGNERS ) ; goto err ; } for ( i = 0 ; i < sk_CMS_SignerInfo_num ( sinfos ) ; i ++ ) { si = sk_CMS_SignerInfo_value ( sinfos , i ) ; CMS_SignerInfo_get0_algs ( si , NULL , & signer , NULL , NULL ) ; if ( signer ) scount ++ ; } if ( scount != sk_CMS_SignerInfo_num ( sinfos ) ) scount += CMS_set1_signers_certs ( cms , certs , flags ) ; if ( scount != sk_CMS_SignerInfo_num ( sinfos ) ) { CMSerr ( CMS_F_CMS_VERIFY , CMS_R_SIGNER_CERTIFICATE_NOT_FOUND ) ; goto err ; } if ( ! ( flags & CMS_NO_SIGNER_CERT_VERIFY ) ) { cms_certs = CMS_get1_certs ( cms ) ; if ( ! ( flags & CMS_NOCRL ) ) crls = CMS_get1_crls ( cms ) ; for ( i = 0 ; i < sk_CMS_SignerInfo_num ( sinfos ) ; i ++ ) { si = sk_CMS_SignerInfo_value ( sinfos , i ) ; if ( ! cms_signerinfo_verify_cert ( si , store , cms_certs , crls , flags ) ) goto err ; } } if ( ! ( flags & CMS_NO_ATTR_VERIFY ) ) { for ( i = 0 ; i < sk_CMS_SignerInfo_num ( sinfos ) ; i ++ ) { si = sk_CMS_SignerInfo_value ( sinfos , i ) ; if ( CMS_signed_get_attr_count ( si ) < 0 ) continue ; if ( CMS_SignerInfo_verify ( si ) <= 0 ) goto err ; } } if ( dcont && ( BIO_method_type ( dcont ) == BIO_TYPE_MEM ) ) { char * ptr ; long len ; len = BIO_get_mem_data ( dcont , & ptr ) ; tmpin = BIO_new_mem_buf ( ptr , len ) ; if ( tmpin == NULL ) { CMSerr ( CMS_F_CMS_VERIFY , ERR_R_MALLOC_FAILURE ) ; return 0 ; } } else tmpin = dcont ; cmsbio = CMS_dataInit ( cms , tmpin ) ; if ( ! cmsbio ) goto err ; if ( ! cms_copy_content ( out , cmsbio , flags ) ) goto err ; if ( ! ( flags & CMS_NO_CONTENT_VERIFY ) ) { for ( i = 0 ; i < sk_CMS_SignerInfo_num ( sinfos ) ; i ++ ) { si = sk_CMS_SignerInfo_value ( sinfos , i ) ; if ( CMS_SignerInfo_verify_content ( si , cmsbio ) <= 0 ) { CMSerr ( CMS_F_CMS_VERIFY , CMS_R_CONTENT_VERIFY_ERROR ) ; goto err ; } } } ret = 1 ; err : if ( dcont && ( tmpin == dcont ) ) do_free_upto ( cmsbio , dcont ) ; else BIO_free_all ( cmsbio ) ; if ( cms_certs ) sk_X509_pop_free ( cms_certs , X509_free ) ; if ( crls ) sk_X509_CRL_pop_free ( crls , X509_CRL_free ) ; return ret ; } "," , * tmpin = NULL , * tmpout = dcont ; if ( ! ( flags & SMIME_BINARY ) && dcont ) { tmpout = cms_get_text_bio ( out , flags ) ; if ( ! tmpout ) { CMSerr ( CMS_F_CMS_VERIFY , ERR_R_MALLOC_FAILURE ) ; goto err ; } ( cms , tmpout ) ; if ( ! cmsbio ) goto err ; SMIME_crlf_copy ( dcont , cmsbio , flags & ~ SMIME_TEXT ) ; if ( flags & CMS_TEXT ) { if ( ! SMIME_text ( tmpout , out ) ) { CMSerr ( CMS_F_CMS_VERIFY , CMS_R_SMIME_TEXT_ERROR ) ; goto err ; } } } else { cmsbio = CMS_dataInit ( cms , goto err ; } : if ( ! ( flags & SMIME_BINARY ) && dcont ) { do_free_upto ( cmsbio , tmpout ) ; if ( tmpin != dcont ) BIO_free ( tmpin ) ; } else { if ( cmsbio ) ; } if ( tmpout && out != tmpout ) BIO_free_all ( tmpout ) ; ",openssl@openssl/cd30f03ac5bf2962f44bd02ae8d88245dff2f12c,CVE-2015-1792,https://github.com/openssl/openssl/commit/cd30f03ac5bf2962f44bd02ae8d88245dff2f12c,2015-06-12T19:59Z 793,CWE-416,"CWE-416 static int do_ipv6_getsockopt ( struct sock * sk , int level , int optname , char __user * optval , int __user * optlen , unsigned int flags ) { struct ipv6_pinfo * np = inet6_sk ( sk ) ; int len ; int val ; if ( ip6_mroute_opt ( optname ) ) return ip6_mroute_getsockopt ( sk , optname , optval , optlen ) ; if ( get_user ( len , optlen ) ) return - EFAULT ; switch ( optname ) { case IPV6_ADDRFORM : if ( sk -> sk_protocol != IPPROTO_UDP && sk -> sk_protocol != IPPROTO_UDPLITE && sk -> sk_protocol != IPPROTO_TCP ) return - ENOPROTOOPT ; if ( sk -> sk_state != TCP_ESTABLISHED ) return - ENOTCONN ; val = sk -> sk_family ; break ; case MCAST_MSFILTER : { struct group_filter gsf ; int err ; if ( len < GROUP_FILTER_SIZE ( 0 ) ) return - EINVAL ; if ( copy_from_user ( & gsf , optval , GROUP_FILTER_SIZE ( 0 ) ) ) return - EFAULT ; if ( gsf . gf_group . ss_family != AF_INET6 ) return - EADDRNOTAVAIL ; lock_sock ( sk ) ; err = ip6_mc_msfget ( sk , & gsf , ( struct group_filter __user * ) optval , optlen ) ; release_sock ( sk ) ; return err ; } case IPV6_2292PKTOPTIONS : { struct msghdr msg ; struct sk_buff * skb ; if ( sk -> sk_type != SOCK_STREAM ) return - ENOPROTOOPT ; msg . msg_control = optval ; msg . msg_controllen = len ; msg . msg_flags = flags ; lock_sock ( sk ) ; skb = np -> pktoptions ; if ( skb ) ip6_datagram_recv_ctl ( sk , & msg , skb ) ; release_sock ( sk ) ; if ( ! skb ) { if ( np -> rxopt . bits . rxinfo ) { struct in6_pktinfo src_info ; src_info . ipi6_ifindex = np -> mcast_oif ? np -> mcast_oif : np -> sticky_pktinfo . ipi6_ifindex ; src_info . ipi6_addr = np -> mcast_oif ? sk -> sk_v6_daddr : np -> sticky_pktinfo . ipi6_addr ; put_cmsg ( & msg , SOL_IPV6 , IPV6_PKTINFO , sizeof ( src_info ) , & src_info ) ; } if ( np -> rxopt . bits . rxhlim ) { int hlim = np -> mcast_hops ; put_cmsg ( & msg , SOL_IPV6 , IPV6_HOPLIMIT , sizeof ( hlim ) , & hlim ) ; } if ( np -> rxopt . bits . rxtclass ) { int tclass = ( int ) ip6_tclass ( np -> rcv_flowinfo ) ; put_cmsg ( & msg , SOL_IPV6 , IPV6_TCLASS , sizeof ( tclass ) , & tclass ) ; } if ( np -> rxopt . bits . rxoinfo ) { struct in6_pktinfo src_info ; src_info . ipi6_ifindex = np -> mcast_oif ? np -> mcast_oif : np -> sticky_pktinfo . ipi6_ifindex ; src_info . ipi6_addr = np -> mcast_oif ? sk -> sk_v6_daddr : np -> sticky_pktinfo . ipi6_addr ; put_cmsg ( & msg , SOL_IPV6 , IPV6_2292PKTINFO , sizeof ( src_info ) , & src_info ) ; } if ( np -> rxopt . bits . rxohlim ) { int hlim = np -> mcast_hops ; put_cmsg ( & msg , SOL_IPV6 , IPV6_2292HOPLIMIT , sizeof ( hlim ) , & hlim ) ; } if ( np -> rxopt . bits . rxflow ) { __be32 flowinfo = np -> rcv_flowinfo ; put_cmsg ( & msg , SOL_IPV6 , IPV6_FLOWINFO , sizeof ( flowinfo ) , & flowinfo ) ; } } len -= msg . msg_controllen ; return put_user ( len , optlen ) ; } case IPV6_MTU : { struct dst_entry * dst ; val = 0 ; rcu_read_lock ( ) ; dst = __sk_dst_get ( sk ) ; if ( dst ) val = dst_mtu ( dst ) ; rcu_read_unlock ( ) ; if ( ! val ) return - ENOTCONN ; break ; } case IPV6_V6ONLY : val = sk -> sk_ipv6only ; break ; case IPV6_RECVPKTINFO : val = np -> rxopt . bits . rxinfo ; break ; case IPV6_2292PKTINFO : val = np -> rxopt . bits . rxoinfo ; break ; case IPV6_RECVHOPLIMIT : val = np -> rxopt . bits . rxhlim ; break ; case IPV6_2292HOPLIMIT : val = np -> rxopt . bits . rxohlim ; break ; case IPV6_RECVRTHDR : val = np -> rxopt . bits . srcrt ; break ; case IPV6_2292RTHDR : val = np -> rxopt . bits . osrcrt ; break ; case IPV6_HOPOPTS : case IPV6_RTHDRDSTOPTS : case IPV6_RTHDR : case IPV6_DSTOPTS : { lock_sock ( sk ) ; len = ipv6_getsockopt_sticky ( sk , np -> opt , optname , optval , len ) ; release_sock ( sk ) ; if ( len < 0 ) return len ; return put_user ( len , optlen ) ; } case IPV6_RECVHOPOPTS : val = np -> rxopt . bits . hopopts ; break ; case IPV6_2292HOPOPTS : val = np -> rxopt . bits . ohopopts ; break ; case IPV6_RECVDSTOPTS : val = np -> rxopt . bits . dstopts ; break ; case IPV6_2292DSTOPTS : val = np -> rxopt . bits . odstopts ; break ; case IPV6_TCLASS : val = np -> tclass ; break ; case IPV6_RECVTCLASS : val = np -> rxopt . bits . rxtclass ; break ; case IPV6_FLOWINFO : val = np -> rxopt . bits . rxflow ; break ; case IPV6_RECVPATHMTU : val = np -> rxopt . bits . rxpmtu ; break ; case IPV6_PATHMTU : { struct dst_entry * dst ; struct ip6_mtuinfo mtuinfo ; if ( len < sizeof ( mtuinfo ) ) return - EINVAL ; len = sizeof ( mtuinfo ) ; memset ( & mtuinfo , 0 , sizeof ( mtuinfo ) ) ; rcu_read_lock ( ) ; dst = __sk_dst_get ( sk ) ; if ( dst ) mtuinfo . ip6m_mtu = dst_mtu ( dst ) ; rcu_read_unlock ( ) ; if ( ! mtuinfo . ip6m_mtu ) return - ENOTCONN ; if ( put_user ( len , optlen ) ) return - EFAULT ; if ( copy_to_user ( optval , & mtuinfo , len ) ) return - EFAULT ; return 0 ; } case IPV6_TRANSPARENT : val = inet_sk ( sk ) -> transparent ; break ; case IPV6_RECVORIGDSTADDR : val = np -> rxopt . bits . rxorigdstaddr ; break ; case IPV6_UNICAST_HOPS : case IPV6_MULTICAST_HOPS : { struct dst_entry * dst ; if ( optname == IPV6_UNICAST_HOPS ) val = np -> hop_limit ; else val = np -> mcast_hops ; if ( val < 0 ) { rcu_read_lock ( ) ; dst = __sk_dst_get ( sk ) ; if ( dst ) val = ip6_dst_hoplimit ( dst ) ; rcu_read_unlock ( ) ; } if ( val < 0 ) val = sock_net ( sk ) -> ipv6 . devconf_all -> hop_limit ; break ; } case IPV6_MULTICAST_LOOP : val = np -> mc_loop ; break ; case IPV6_MULTICAST_IF : val = np -> mcast_oif ; break ; case IPV6_UNICAST_IF : val = ( __force int ) htonl ( ( __u32 ) np -> ucast_oif ) ; break ; case IPV6_MTU_DISCOVER : val = np -> pmtudisc ; break ; case IPV6_RECVERR : val = np -> recverr ; break ; case IPV6_FLOWINFO_SEND : val = np -> sndflow ; break ; case IPV6_FLOWLABEL_MGR : { struct in6_flowlabel_req freq ; int flags ; if ( len < sizeof ( freq ) ) return - EINVAL ; if ( copy_from_user ( & freq , optval , sizeof ( freq ) ) ) return - EFAULT ; if ( freq . flr_action != IPV6_FL_A_GET ) return - EINVAL ; len = sizeof ( freq ) ; flags = freq . flr_flags ; memset ( & freq , 0 , sizeof ( freq ) ) ; val = ipv6_flowlabel_opt_get ( sk , & freq , flags ) ; if ( val < 0 ) return val ; if ( put_user ( len , optlen ) ) return - EFAULT ; if ( copy_to_user ( optval , & freq , len ) ) return - EFAULT ; return 0 ; } case IPV6_ADDR_PREFERENCES : val = 0 ; if ( np -> srcprefs & IPV6_PREFER_SRC_TMP ) val |= IPV6_PREFER_SRC_TMP ; else if ( np -> srcprefs & IPV6_PREFER_SRC_PUBLIC ) val |= IPV6_PREFER_SRC_PUBLIC ; else { val |= IPV6_PREFER_SRC_PUBTMP_DEFAULT ; } if ( np -> srcprefs & IPV6_PREFER_SRC_COA ) val |= IPV6_PREFER_SRC_COA ; else val |= IPV6_PREFER_SRC_HOME ; break ; case IPV6_MINHOPCOUNT : val = np -> min_hopcount ; break ; case IPV6_DONTFRAG : val = np -> dontfrag ; break ; case IPV6_AUTOFLOWLABEL : val = np -> autoflowlabel ; break ; default : return - ENOPROTOOPT ; } len = min_t ( unsigned int , sizeof ( int ) , len ) ; if ( put_user ( len , optlen ) ) return - EFAULT ; if ( copy_to_user ( optval , & val , len ) ) return - EFAULT ; return 0 ; } "," IPV6_DSTOPTS : { struct ipv6_txoptions * opt ; sk ) ; opt = rcu_dereference_protected ( np -> opt , sock_owned_by_user ( sk ) ) ; ( sk , opt , optname ",torvalds@linux/45f6fad84cc305103b28d73482b344d7f5b76f39,CVE-2016-3841,https://github.com/torvalds/linux/commit/45f6fad84cc305103b28d73482b344d7f5b76f39,2016-08-06T20:59Z 794,CWE-119,"CWE-119 static __exit void sctp_exit ( void ) { sctp_v6_del_protocol ( ) ; sctp_v4_del_protocol ( ) ; unregister_pernet_subsys ( & sctp_net_ops ) ; sctp_v6_protosw_exit ( ) ; sctp_v4_protosw_exit ( ) ; sctp_v6_pf_exit ( ) ; sctp_v4_pf_exit ( ) ; sctp_sysctl_unregister ( ) ; free_pages ( ( unsigned long ) sctp_assoc_hashtable , get_order ( sctp_assoc_hashsize * sizeof ( struct sctp_hashbucket ) ) ) ; kfree ( sctp_ep_hashtable ) ; free_pages ( ( unsigned long ) sctp_port_hashtable , get_order ( sctp_port_hashsize * sizeof ( struct sctp_bind_hashbucket ) ) ) ; percpu_counter_destroy ( & sctp_sockets_allocated ) ; rcu_barrier ( ) ; kmem_cache_destroy ( sctp_chunk_cachep ) ; kmem_cache_destroy ( sctp_bucket_cachep ) ; } "," unregister_pernet_subsys ( & sctp_ctrlsock_ops ) ; sctp_v6_protosw_exit ; sctp_v4_protosw_exit ( ) ; unregister_pernet_subsys ( & sctp_defaults_ops ",torvalds@linux/8e2d61e0aed2b7c4ecb35844fe07e0b2b762dee4,CVE-2015-5283,https://github.com/torvalds/linux/commit/8e2d61e0aed2b7c4ecb35844fe07e0b2b762dee4,2015-10-19T10:59Z 795,CWE-284,"CWE-284 void _modinit ( module_t * m ) { service_named_bind_command ( ""chanserv"" , & cs_flags ) ; } "," cs_flags ) ; add_bool_conf_item ( ""ANOPE_FLAGS_COMPAT"" , & chansvs . me -> conf_table , 0 , & anope_flags_compat , true ) ; hook_add_event ( ""nick_can_register"" ) ; hook_add_nick_can_register ( check_registration_keywords ) ; hook_add_event ( ""user_can_register"" ) ; hook_add_user_can_register ( check_registration_keywords ) ; ",atheme@atheme/c597156adc60a45b5f827793cd420945f47bc03b,CVE-2014-9773,https://github.com/atheme/atheme/commit/c597156adc60a45b5f827793cd420945f47bc03b,2016-06-13T19:59Z 796,CWE-399,"CWE-399 static int masq_inet_event ( struct notifier_block * this , unsigned long event , void * ptr ) { struct net_device * dev = ( ( struct in_ifaddr * ) ptr ) -> ifa_dev -> dev ; struct netdev_notifier_info info ; netdev_notifier_info_init ( & info , dev ) ; return masq_device_event ( this , event , & info ) ; } "," ) { struct in_device * idev = ( ( ) -> ifa_dev ; struct netdev_notifier_info netdev_notifier_info info ; if ( idev -> dead ) return NOTIFY_DONE ; & info , idev -> ",torvalds@linux/fbd40ea0180a2d328c5adc61414dc8bab9335ce2,CVE-2016-3156,https://github.com/torvalds/linux/commit/fbd40ea0180a2d328c5adc61414dc8bab9335ce2,2016-04-27T17:59Z 797,CWE-362,"CWE-362 void flush_tlb_mm_range ( struct mm_struct * mm , unsigned long start , unsigned long end , unsigned long vmflag ) { unsigned long addr ; unsigned long base_pages_to_flush = TLB_FLUSH_ALL ; preempt_disable ( ) ; if ( current -> active_mm != mm ) goto out ; if ( ! current -> mm ) { leave_mm ( smp_processor_id ( ) ) ; goto out ; } if ( ( end != TLB_FLUSH_ALL ) && ! ( vmflag & VM_HUGETLB ) ) base_pages_to_flush = ( end - start ) >> PAGE_SHIFT ; if ( base_pages_to_flush > tlb_single_page_flush_ceiling ) { base_pages_to_flush = TLB_FLUSH_ALL ; count_vm_tlb_event ( NR_TLB_LOCAL_FLUSH_ALL ) ; local_flush_tlb ( ) ; } else { for ( addr = start ; addr < end ; addr += PAGE_SIZE ) { count_vm_tlb_event ( NR_TLB_LOCAL_FLUSH_ONE ) ; __flush_tlb_single ( addr ) ; } } trace_tlb_flush ( TLB_LOCAL_MM_SHOOTDOWN , base_pages_to_flush ) ; out : if ( base_pages_to_flush == TLB_FLUSH_ALL ) { start = 0UL ; end = TLB_FLUSH_ALL ; } if ( cpumask_any_but ( mm_cpumask ( mm ) , smp_processor_id ( ) ) < nr_cpu_ids ) flush_tlb_others ( mm_cpumask ( mm ) , mm , start , end ) ; preempt_enable ( ) ; } "," != mm ) { smp_mb ( ) ; goto out ; } ) ) ; smp_mb ( ) ; ",torvalds@linux/71b3c126e61177eb693423f2e18a1914205b165e,CVE-2016-2069,https://github.com/torvalds/linux/commit/71b3c126e61177eb693423f2e18a1914205b165e,2016-04-27T17:59Z 798,CWE-119,"CWE-119 static void show_psnr ( struct stream_state * stream ) { int i ; double ovpsnr ; if ( ! stream -> psnr_count ) return ; fprintf ( stderr , ""Stream%dPSNR(Overall/Avg/Y/U/V)"" , stream -> index ) ; ovpsnr = sse_to_psnr ( ( double ) stream -> psnr_samples_total , 255.0 , ( double ) stream -> psnr_sse_total ) ; fprintf ( stderr , ""%.3f"" , ovpsnr ) ; for ( i = 0 ; i < 4 ; i ++ ) { fprintf ( stderr , ""%.3f"" , stream -> psnr_totals [ i ] / stream -> psnr_count ) ; } fprintf ( stderr , ""\\n"" ) ; } "," stream_state * stream , double peak -> psnr_samples_total , peak , ( double ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 799,CWE-119,"CWE-119 static char * get_pid_environ_val ( pid_t pid , char * val ) { char temp [ 500 ] ; int i = 0 ; int foundit = 0 ; FILE * fp ; sprintf ( temp , ""/proc/%d/environ"" , pid ) ; fp = fopen ( temp , ""r"" ) ; if ( fp == NULL ) return NULL ; for ( ; ; ) { temp [ i ] = fgetc ( fp ) ; if ( foundit == 1 && ( temp [ i ] == 0 || temp [ i ] == '\\0' || temp [ i ] == EOF ) ) { char * ret ; temp [ i ] = 0 ; ret = malloc ( strlen ( temp ) + 10 ) ; sprintf ( ret , ""%s"" , temp ) ; fclose ( fp ) ; return ret ; } switch ( temp [ i ] ) { case EOF : fclose ( fp ) ; return NULL ; case '=' : temp [ i ] = 0 ; if ( ! strcmp ( temp , val ) ) { foundit = 1 ; } i = 0 ; break ; case '\\0' : i = 0 ; break ; default : i ++ ; } } } "," val ) { int temp_size = 500 ; char * temp = malloc ( temp_size ) ; int i ; ) { if ( i >= temp_size ) { temp_size *= 2 ; temp = realloc ( temp , temp_size ) ; } ",kmatheussen@das_watchdog/bd20bb02e75e2c0483832b52f2577253febfb690,CVE-2015-2831,https://github.com/kmatheussen/das_watchdog/commit/bd20bb02e75e2c0483832b52f2577253febfb690,2015-04-14T18:59Z 800,CWE-362,"CWE-362 static void smp_task_done ( struct sas_task * task ) { if ( ! del_timer ( & task -> slow_task -> timer ) ) return ; complete ( & task -> slow_task -> completion ) ; } "," task ) { del_timer ( & -> timer ) ; complete ( ",torvalds@linux/b90cd6f2b905905fb42671009dc0e27c310a16ae,CVE-2018-20836,https://github.com/torvalds/linux/commit/b90cd6f2b905905fb42671009dc0e27c310a16ae,2019-05-07T14:29Z 801,CWE-787,"CWE-787 void pdf_summarize ( FILE * fp , const pdf_t * pdf , const char * name , pdf_flag_t flags ) { int i , j , page , n_versions , n_entries ; FILE * dst , * out ; char * dst_name , * c ; dst = NULL ; dst_name = NULL ; if ( name ) { dst_name = malloc ( strlen ( name ) * 2 + 16 ) ; sprintf ( dst_name , ""%s/%s"" , name , name ) ; if ( ( c = strrchr ( dst_name , '.' ) ) && ( strncmp ( c , "".pdf"" , 4 ) == 0 ) ) * c = '\\0' ; strcat ( dst_name , "".summary"" ) ; if ( ! ( dst = fopen ( dst_name , ""w"" ) ) ) { ERR ( ""Couldnotopenfile\'%s\'forwriting\\n"" , dst_name ) ; return ; } } out = ( dst ) ? dst : stdout ; n_versions = pdf -> n_xrefs ; if ( n_versions && pdf -> xrefs [ 0 ] . is_linear ) -- n_versions ; for ( i = 1 ; i < pdf -> n_xrefs ; ++ i ) if ( pdf -> xrefs [ i ] . end == 0 ) -- n_versions ; if ( ! pdf -> n_xrefs || ( ! n_versions && pdf -> xrefs [ 0 ] . is_linear ) ) n_versions = 1 ; n_entries = 0 ; for ( i = 0 ; ! ( const int ) pdf -> has_xref_streams && i < pdf -> n_xrefs ; i ++ ) { if ( flags & PDF_FLAG_QUIET ) continue ; for ( j = 0 ; j < pdf -> xrefs [ i ] . n_entries ; j ++ ) { ++ n_entries ; fprintf ( out , ""%s:--%c--Version%d--Object%d(%s)"" , pdf -> name , pdf_get_object_status ( pdf , i , j ) , pdf -> xrefs [ i ] . version , pdf -> xrefs [ i ] . entries [ j ] . obj_id , get_type ( fp , pdf -> xrefs [ i ] . entries [ j ] . obj_id , & pdf -> xrefs [ i ] ) ) ; if ( 0 ) fprintf ( out , ""Page(%d)\\n"" , page ) ; else fprintf ( out , ""\\n"" ) ; } } if ( ! ( flags & PDF_FLAG_QUIET ) ) { if ( pdf -> has_xref_streams || ! n_entries ) fprintf ( out , ""%s:ThisPDFcontainspotentialcrossreferencestreams.\\n"" ""%s:Anobjectsummaryisnotavailable.\\n"" , pdf -> name , pdf -> name ) ; fprintf ( out , ""----------%s----------\\n"" ""Versions:%d\\n"" , pdf -> name , n_versions ) ; if ( ! pdf -> has_xref_streams ) for ( i = 0 ; i < pdf -> n_xrefs ; i ++ ) { if ( pdf -> xrefs [ i ] . is_linear ) continue ; n_entries = pdf -> xrefs [ i ] . n_entries ; if ( pdf -> xrefs [ 0 ] . is_linear ) n_entries += pdf -> xrefs [ 0 ] . n_entries ; if ( pdf -> xrefs [ i ] . version && n_entries ) fprintf ( out , ""Version%d--%dobjects\\n"" , pdf -> xrefs [ i ] . version , n_entries ) ; } } else fprintf ( out , ""%s:%d\\n"" , pdf -> name , n_versions ) ; if ( dst ) { fclose ( dst ) ; free ( dst_name ) ; } } "," { dst_name = safe_calloc ( strlen ( ",enferex@pdfresurrect/0c4120fffa3dffe97b95c486a120eded82afe8a6,CVE-2019-14934,https://github.com/enferex/pdfresurrect/commit/0c4120fffa3dffe97b95c486a120eded82afe8a6,2019-08-11T22:15Z 802,CWE-617,"CWE-617 int lldp_decode ( struct lldpd * cfg , char * frame , int s , struct lldpd_hardware * hardware , struct lldpd_chassis * * newchassis , struct lldpd_port * * newport ) { struct lldpd_chassis * chassis ; struct lldpd_port * port ; const char lldpaddr [ ] = LLDP_MULTICAST_ADDR ; const char dot1 [ ] = LLDP_TLV_ORG_DOT1 ; const char dot3 [ ] = LLDP_TLV_ORG_DOT3 ; const char med [ ] = LLDP_TLV_ORG_MED ; const char dcbx [ ] = LLDP_TLV_ORG_DCBX ; unsigned char orgid [ 3 ] ; int length , gotend = 0 , ttl_received = 0 ; int tlv_size , tlv_type , tlv_subtype ; u_int8_t * pos , * tlv ; char * b ; # ifdef ENABLE_DOT1 struct lldpd_vlan * vlan = NULL ; int vlan_len ; struct lldpd_ppvid * ppvid ; struct lldpd_pi * pi = NULL ; # endif struct lldpd_mgmt * mgmt ; int af ; u_int8_t addr_str_length , addr_str_buffer [ 32 ] ; u_int8_t addr_family , addr_length , * addr_ptr , iface_subtype ; u_int32_t iface_number , iface ; # ifdef ENABLE_CUSTOM struct lldpd_custom * custom = NULL ; # endif log_debug ( ""lldp"" , ""receiveLLDPPDUon%s"" , hardware -> h_ifname ) ; if ( ( chassis = calloc ( 1 , sizeof ( struct lldpd_chassis ) ) ) == NULL ) { log_warn ( ""lldp"" , ""failedtoallocateremotechassis"" ) ; return - 1 ; } TAILQ_INIT ( & chassis -> c_mgmt ) ; if ( ( port = calloc ( 1 , sizeof ( struct lldpd_port ) ) ) == NULL ) { log_warn ( ""lldp"" , ""failedtoallocateremoteport"" ) ; free ( chassis ) ; return - 1 ; } # ifdef ENABLE_DOT1 TAILQ_INIT ( & port -> p_vlans ) ; TAILQ_INIT ( & port -> p_ppvids ) ; TAILQ_INIT ( & port -> p_pids ) ; # endif # ifdef ENABLE_CUSTOM TAILQ_INIT ( & port -> p_custom_list ) ; # endif length = s ; pos = ( u_int8_t * ) frame ; if ( length < 2 * ETHER_ADDR_LEN + sizeof ( u_int16_t ) ) { log_warnx ( ""lldp"" , ""tooshortframereceivedon%s"" , hardware -> h_ifname ) ; goto malformed ; } if ( PEEK_CMP ( lldpaddr , ETHER_ADDR_LEN ) != 0 ) { log_info ( ""lldp"" , ""framenottargetedatLLDPmulticastaddressreceivedon%s"" , hardware -> h_ifname ) ; goto malformed ; } PEEK_DISCARD ( ETHER_ADDR_LEN ) ; if ( PEEK_UINT16 != ETHERTYPE_LLDP ) { log_info ( ""lldp"" , ""nonLLDPframereceivedon%s"" , hardware -> h_ifname ) ; goto malformed ; } while ( length && ( ! gotend ) ) { if ( length < 2 ) { log_warnx ( ""lldp"" , ""tlvheadertooshortreceivedon%s"" , hardware -> h_ifname ) ; goto malformed ; } tlv_size = PEEK_UINT16 ; tlv_type = tlv_size >> 9 ; tlv_size = tlv_size & 0x1ff ; ( void ) PEEK_SAVE ( tlv ) ; if ( length < tlv_size ) { log_warnx ( ""lldp"" , ""frametooshortfortlvreceivedon%s"" , hardware -> h_ifname ) ; goto malformed ; } switch ( tlv_type ) { case LLDP_TLV_END : if ( tlv_size != 0 ) { log_warnx ( ""lldp"" , ""lldpendreceivedwithsizenotnullon%s"" , hardware -> h_ifname ) ; goto malformed ; } if ( length ) log_debug ( ""lldp"" , ""extradataafterlldpendon%s"" , hardware -> h_ifname ) ; gotend = 1 ; break ; case LLDP_TLV_CHASSIS_ID : case LLDP_TLV_PORT_ID : CHECK_TLV_SIZE ( 2 , ""PortId"" ) ; tlv_subtype = PEEK_UINT8 ; if ( ( tlv_subtype == 0 ) || ( tlv_subtype > 7 ) ) { log_warnx ( ""lldp"" , ""unknownsubtypefortlvidreceivedon%s"" , hardware -> h_ifname ) ; goto malformed ; } if ( ( b = ( char * ) calloc ( 1 , tlv_size - 1 ) ) == NULL ) { log_warn ( ""lldp"" , ""unabletoallocatememoryforidtlv"" ""receivedon%s"" , hardware -> h_ifname ) ; goto malformed ; } PEEK_BYTES ( b , tlv_size - 1 ) ; if ( tlv_type == LLDP_TLV_PORT_ID ) { port -> p_id_subtype = tlv_subtype ; port -> p_id = b ; port -> p_id_len = tlv_size - 1 ; } else { chassis -> c_id_subtype = tlv_subtype ; chassis -> c_id = b ; chassis -> c_id_len = tlv_size - 1 ; } break ; case LLDP_TLV_TTL : CHECK_TLV_SIZE ( 2 , ""TTL"" ) ; chassis -> c_ttl = PEEK_UINT16 ; ttl_received = 1 ; break ; case LLDP_TLV_PORT_DESCR : case LLDP_TLV_SYSTEM_NAME : case LLDP_TLV_SYSTEM_DESCR : if ( tlv_size < 1 ) { log_debug ( ""lldp"" , ""emptytlvreceivedon%s"" , hardware -> h_ifname ) ; break ; } if ( ( b = ( char * ) calloc ( 1 , tlv_size + 1 ) ) == NULL ) { log_warn ( ""lldp"" , ""unabletoallocatememoryforstringtlv"" ""receivedon%s"" , hardware -> h_ifname ) ; goto malformed ; } PEEK_BYTES ( b , tlv_size ) ; if ( tlv_type == LLDP_TLV_PORT_DESCR ) port -> p_descr = b ; else if ( tlv_type == LLDP_TLV_SYSTEM_NAME ) chassis -> c_name = b ; else chassis -> c_descr = b ; break ; case LLDP_TLV_SYSTEM_CAP : CHECK_TLV_SIZE ( 4 , ""Systemcapabilities"" ) ; chassis -> c_cap_available = PEEK_UINT16 ; chassis -> c_cap_enabled = PEEK_UINT16 ; break ; case LLDP_TLV_MGMT_ADDR : CHECK_TLV_SIZE ( 1 , ""Managementaddress"" ) ; addr_str_length = PEEK_UINT8 ; if ( addr_str_length > sizeof ( addr_str_buffer ) ) { log_warnx ( ""lldp"" , ""toolargemanagementaddresson%s"" , hardware -> h_ifname ) ; goto malformed ; } CHECK_TLV_SIZE ( 1 + addr_str_length , ""Managementaddress"" ) ; PEEK_BYTES ( addr_str_buffer , addr_str_length ) ; addr_length = addr_str_length - 1 ; addr_family = addr_str_buffer [ 0 ] ; addr_ptr = & addr_str_buffer [ 1 ] ; CHECK_TLV_SIZE ( 1 + addr_str_length + 5 , ""Managementaddress"" ) ; iface_subtype = PEEK_UINT8 ; iface_number = PEEK_UINT32 ; af = lldpd_af_from_lldp_proto ( addr_family ) ; if ( af == LLDPD_AF_UNSPEC ) break ; if ( iface_subtype == LLDP_MGMT_IFACE_IFINDEX ) iface = iface_number ; else iface = 0 ; mgmt = lldpd_alloc_mgmt ( af , addr_ptr , addr_length , iface ) ; if ( mgmt == NULL ) { assert ( errno == ENOMEM ) ; log_warn ( ""lldp"" , ""unabletoallocatememory"" ""formanagementaddress"" ) ; goto malformed ; } TAILQ_INSERT_TAIL ( & chassis -> c_mgmt , mgmt , m_entries ) ; break ; case LLDP_TLV_ORG : CHECK_TLV_SIZE ( 1 + ( int ) sizeof ( orgid ) , ""Organisational"" ) ; PEEK_BYTES ( orgid , sizeof ( orgid ) ) ; tlv_subtype = PEEK_UINT8 ; if ( memcmp ( dot1 , orgid , sizeof ( orgid ) ) == 0 ) { # ifndef ENABLE_DOT1 hardware -> h_rx_unrecognized_cnt ++ ; # else switch ( tlv_subtype ) { case LLDP_TLV_DOT1_VLANNAME : CHECK_TLV_SIZE ( 7 , ""VLAN"" ) ; if ( ( vlan = ( struct lldpd_vlan * ) calloc ( 1 , sizeof ( struct lldpd_vlan ) ) ) == NULL ) { log_warn ( ""lldp"" , ""unabletoallocvlan"" ""structurefor"" ""tlvreceivedon%s"" , hardware -> h_ifname ) ; goto malformed ; } vlan -> v_vid = PEEK_UINT16 ; vlan_len = PEEK_UINT8 ; CHECK_TLV_SIZE ( 7 + vlan_len , ""VLAN"" ) ; if ( ( vlan -> v_name = ( char * ) calloc ( 1 , vlan_len + 1 ) ) == NULL ) { log_warn ( ""lldp"" , ""unabletoallocvlannamefor"" ""tlvreceivedon%s"" , hardware -> h_ifname ) ; goto malformed ; } PEEK_BYTES ( vlan -> v_name , vlan_len ) ; TAILQ_INSERT_TAIL ( & port -> p_vlans , vlan , v_entries ) ; vlan = NULL ; break ; case LLDP_TLV_DOT1_PVID : CHECK_TLV_SIZE ( 6 , ""PVID"" ) ; port -> p_pvid = PEEK_UINT16 ; break ; case LLDP_TLV_DOT1_PPVID : CHECK_TLV_SIZE ( 7 , ""PPVID"" ) ; if ( ( ppvid = ( struct lldpd_ppvid * ) calloc ( 1 , sizeof ( struct lldpd_ppvid ) ) ) == NULL ) { log_warn ( ""lldp"" , ""unabletoallocppvid"" ""structurefor"" ""tlvreceivedon%s"" , hardware -> h_ifname ) ; goto malformed ; } ppvid -> p_cap_status = PEEK_UINT8 ; ppvid -> p_ppvid = PEEK_UINT16 ; TAILQ_INSERT_TAIL ( & port -> p_ppvids , ppvid , p_entries ) ; break ; case LLDP_TLV_DOT1_PI : CHECK_TLV_SIZE ( 5 , ""PI"" ) ; if ( ( pi = ( struct lldpd_pi * ) calloc ( 1 , sizeof ( struct lldpd_pi ) ) ) == NULL ) { log_warn ( ""lldp"" , ""unabletoallocPI"" ""structurefor"" ""tlvreceivedon%s"" , hardware -> h_ifname ) ; goto malformed ; } pi -> p_pi_len = PEEK_UINT8 ; CHECK_TLV_SIZE ( 5 + pi -> p_pi_len , ""PI"" ) ; if ( ( pi -> p_pi = ( char * ) calloc ( 1 , pi -> p_pi_len ) ) == NULL ) { log_warn ( ""lldp"" , ""unabletoallocpidnamefor"" ""tlvreceivedon%s"" , hardware -> h_ifname ) ; goto malformed ; } PEEK_BYTES ( pi -> p_pi , pi -> p_pi_len ) ; TAILQ_INSERT_TAIL ( & port -> p_pids , pi , p_entries ) ; pi = NULL ; break ; default : hardware -> h_rx_unrecognized_cnt ++ ; } # endif } else if ( memcmp ( dot3 , orgid , sizeof ( orgid ) ) == 0 ) { # ifndef ENABLE_DOT3 hardware -> h_rx_unrecognized_cnt ++ ; # else switch ( tlv_subtype ) { case LLDP_TLV_DOT3_MAC : CHECK_TLV_SIZE ( 9 , ""MAC/PHY"" ) ; port -> p_macphy . autoneg_support = PEEK_UINT8 ; port -> p_macphy . autoneg_enabled = ( port -> p_macphy . autoneg_support & 0x2 ) >> 1 ; port -> p_macphy . autoneg_support = port -> p_macphy . autoneg_support & 0x1 ; port -> p_macphy . autoneg_advertised = PEEK_UINT16 ; port -> p_macphy . mau_type = PEEK_UINT16 ; break ; case LLDP_TLV_DOT3_LA : CHECK_TLV_SIZE ( 9 , ""Linkaggregation"" ) ; PEEK_DISCARD_UINT8 ; port -> p_aggregid = PEEK_UINT32 ; break ; case LLDP_TLV_DOT3_MFS : CHECK_TLV_SIZE ( 6 , ""MFS"" ) ; port -> p_mfs = PEEK_UINT16 ; break ; case LLDP_TLV_DOT3_POWER : CHECK_TLV_SIZE ( 7 , ""Power"" ) ; port -> p_power . devicetype = PEEK_UINT8 ; port -> p_power . supported = ( port -> p_power . devicetype & 0x2 ) >> 1 ; port -> p_power . enabled = ( port -> p_power . devicetype & 0x4 ) >> 2 ; port -> p_power . paircontrol = ( port -> p_power . devicetype & 0x8 ) >> 3 ; port -> p_power . devicetype = ( port -> p_power . devicetype & 0x1 ) ? LLDP_DOT3_POWER_PSE : LLDP_DOT3_POWER_PD ; port -> p_power . pairs = PEEK_UINT8 ; port -> p_power . class = PEEK_UINT8 ; if ( tlv_size >= 12 ) { port -> p_power . powertype = PEEK_UINT8 ; port -> p_power . source = ( port -> p_power . powertype & ( 1 << 5 | 1 << 4 ) ) >> 4 ; port -> p_power . priority = ( port -> p_power . powertype & ( 1 << 1 | 1 << 0 ) ) ; port -> p_power . powertype = ( port -> p_power . powertype & ( 1 << 7 ) ) ? LLDP_DOT3_POWER_8023AT_TYPE1 : LLDP_DOT3_POWER_8023AT_TYPE2 ; port -> p_power . requested = PEEK_UINT16 ; port -> p_power . allocated = PEEK_UINT16 ; } else port -> p_power . powertype = LLDP_DOT3_POWER_8023AT_OFF ; break ; default : hardware -> h_rx_unrecognized_cnt ++ ; } # endif } else if ( memcmp ( med , orgid , sizeof ( orgid ) ) == 0 ) { # ifndef ENABLE_LLDPMED hardware -> h_rx_unrecognized_cnt ++ ; # else u_int32_t policy ; unsigned loctype ; unsigned power ; switch ( tlv_subtype ) { case LLDP_TLV_MED_CAP : CHECK_TLV_SIZE ( 7 , ""LLDP-MEDcapabilities"" ) ; chassis -> c_med_cap_available = PEEK_UINT16 ; chassis -> c_med_type = PEEK_UINT8 ; port -> p_med_cap_enabled |= LLDP_MED_CAP_CAP ; break ; case LLDP_TLV_MED_POLICY : CHECK_TLV_SIZE ( 8 , ""LLDP-MEDpolicy"" ) ; policy = PEEK_UINT32 ; if ( ( ( policy >> 24 ) < 1 ) || ( ( policy >> 24 ) > LLDP_MED_APPTYPE_LAST ) ) { log_info ( ""lldp"" , ""unknownpolicyfield%d"" ""receivedon%s"" , policy , hardware -> h_ifname ) ; break ; } port -> p_med_policy [ ( policy >> 24 ) - 1 ] . type = ( policy >> 24 ) ; port -> p_med_policy [ ( policy >> 24 ) - 1 ] . unknown = ( ( policy & 0x800000 ) != 0 ) ; port -> p_med_policy [ ( policy >> 24 ) - 1 ] . tagged = ( ( policy & 0x400000 ) != 0 ) ; port -> p_med_policy [ ( policy >> 24 ) - 1 ] . vid = ( policy & 0x001FFE00 ) >> 9 ; port -> p_med_policy [ ( policy >> 24 ) - 1 ] . priority = ( policy & 0x1C0 ) >> 6 ; port -> p_med_policy [ ( policy >> 24 ) - 1 ] . dscp = policy & 0x3F ; port -> p_med_cap_enabled |= LLDP_MED_CAP_POLICY ; break ; case LLDP_TLV_MED_LOCATION : CHECK_TLV_SIZE ( 5 , ""LLDP-MEDLocation"" ) ; loctype = PEEK_UINT8 ; if ( ( loctype < 1 ) || ( loctype > LLDP_MED_LOCFORMAT_LAST ) ) { log_info ( ""lldp"" , ""unknownlocationtype"" ""receivedon%s"" , hardware -> h_ifname ) ; break ; } if ( ( port -> p_med_location [ loctype - 1 ] . data = ( char * ) malloc ( tlv_size - 5 ) ) == NULL ) { log_warn ( ""lldp"" , ""unabletoallocatememory"" ""forLLDP-MEDlocationfor"" ""framereceivedon%s"" , hardware -> h_ifname ) ; goto malformed ; } PEEK_BYTES ( port -> p_med_location [ loctype - 1 ] . data , tlv_size - 5 ) ; port -> p_med_location [ loctype - 1 ] . data_len = tlv_size - 5 ; port -> p_med_location [ loctype - 1 ] . format = loctype ; port -> p_med_cap_enabled |= LLDP_MED_CAP_LOCATION ; break ; case LLDP_TLV_MED_MDI : CHECK_TLV_SIZE ( 7 , ""LLDP-MEDPoE-MDI"" ) ; power = PEEK_UINT8 ; switch ( power & 0xC0 ) { case 0x0 : port -> p_med_power . devicetype = LLDP_MED_POW_TYPE_PSE ; port -> p_med_cap_enabled |= LLDP_MED_CAP_MDI_PSE ; switch ( power & 0x30 ) { case 0x0 : port -> p_med_power . source = LLDP_MED_POW_SOURCE_UNKNOWN ; break ; case 0x10 : port -> p_med_power . source = LLDP_MED_POW_SOURCE_PRIMARY ; break ; case 0x20 : port -> p_med_power . source = LLDP_MED_POW_SOURCE_BACKUP ; break ; default : port -> p_med_power . source = LLDP_MED_POW_SOURCE_RESERVED ; } break ; case 0x40 : port -> p_med_power . devicetype = LLDP_MED_POW_TYPE_PD ; port -> p_med_cap_enabled |= LLDP_MED_CAP_MDI_PD ; switch ( power & 0x30 ) { case 0x0 : port -> p_med_power . source = LLDP_MED_POW_SOURCE_UNKNOWN ; break ; case 0x10 : port -> p_med_power . source = LLDP_MED_POW_SOURCE_PSE ; break ; case 0x20 : port -> p_med_power . source = LLDP_MED_POW_SOURCE_LOCAL ; break ; default : port -> p_med_power . source = LLDP_MED_POW_SOURCE_BOTH ; } break ; default : port -> p_med_power . devicetype = LLDP_MED_POW_TYPE_RESERVED ; } if ( ( power & 0x0F ) > LLDP_MED_POW_PRIO_LOW ) port -> p_med_power . priority = LLDP_MED_POW_PRIO_UNKNOWN ; else port -> p_med_power . priority = power & 0x0F ; port -> p_med_power . val = PEEK_UINT16 ; break ; case LLDP_TLV_MED_IV_HW : case LLDP_TLV_MED_IV_SW : case LLDP_TLV_MED_IV_FW : case LLDP_TLV_MED_IV_SN : case LLDP_TLV_MED_IV_MANUF : case LLDP_TLV_MED_IV_MODEL : case LLDP_TLV_MED_IV_ASSET : if ( tlv_size <= 4 ) b = NULL ; else { if ( ( b = ( char * ) malloc ( tlv_size - 3 ) ) == NULL ) { log_warn ( ""lldp"" , ""unabletoallocate"" ""memoryforLLDP-MED"" ""inventoryforframe"" ""receivedon%s"" , hardware -> h_ifname ) ; goto malformed ; } PEEK_BYTES ( b , tlv_size - 4 ) ; b [ tlv_size - 4 ] = '\\0' ; } switch ( tlv_subtype ) { case LLDP_TLV_MED_IV_HW : chassis -> c_med_hw = b ; break ; case LLDP_TLV_MED_IV_FW : chassis -> c_med_fw = b ; break ; case LLDP_TLV_MED_IV_SW : chassis -> c_med_sw = b ; break ; case LLDP_TLV_MED_IV_SN : chassis -> c_med_sn = b ; break ; case LLDP_TLV_MED_IV_MANUF : chassis -> c_med_manuf = b ; break ; case LLDP_TLV_MED_IV_MODEL : chassis -> c_med_model = b ; break ; case LLDP_TLV_MED_IV_ASSET : chassis -> c_med_asset = b ; break ; } port -> p_med_cap_enabled |= LLDP_MED_CAP_IV ; break ; default : hardware -> h_rx_unrecognized_cnt ++ ; } # endif } else if ( memcmp ( dcbx , orgid , sizeof ( orgid ) ) == 0 ) { log_debug ( ""lldp"" , ""unsupportedDCBXtlvreceivedon%s-ignore"" , hardware -> h_ifname ) ; hardware -> h_rx_unrecognized_cnt ++ ; } else { log_debug ( ""lldp"" , ""unknownorgtlv[%02x:%02x:%02x]receivedon%s"" , orgid [ 0 ] , orgid [ 1 ] , orgid [ 2 ] , hardware -> h_ifname ) ; hardware -> h_rx_unrecognized_cnt ++ ; # ifdef ENABLE_CUSTOM custom = ( struct lldpd_custom * ) calloc ( 1 , sizeof ( struct lldpd_custom ) ) ; if ( ! custom ) { log_warn ( ""lldp"" , ""unabletoallocatememoryforcustomTLV"" ) ; goto malformed ; } custom -> oui_info_len = tlv_size > 4 ? tlv_size - 4 : 0 ; memcpy ( custom -> oui , orgid , sizeof ( custom -> oui ) ) ; custom -> subtype = tlv_subtype ; if ( custom -> oui_info_len > 0 ) { custom -> oui_info = malloc ( custom -> oui_info_len ) ; if ( ! custom -> oui_info ) { log_warn ( ""lldp"" , ""unabletoallocatememoryforcustomTLVdata"" ) ; goto malformed ; } PEEK_BYTES ( custom -> oui_info , custom -> oui_info_len ) ; } TAILQ_INSERT_TAIL ( & port -> p_custom_list , custom , next ) ; custom = NULL ; # endif } break ; default : log_warnx ( ""lldp"" , ""unknowntlv(%d)receivedon%s"" , tlv_type , hardware -> h_ifname ) ; goto malformed ; } if ( pos > tlv + tlv_size ) { log_warnx ( ""lldp"" , ""BUG:alreadypastTLV!"" ) ; goto malformed ; } PEEK_DISCARD ( tlv + tlv_size - pos ) ; } if ( ( chassis -> c_id == NULL ) || ( port -> p_id == NULL ) || ( ! ttl_received ) || ( gotend == 0 ) ) { log_warnx ( ""lldp"" , ""somemandatorytlvaremissingforframereceivedon%s"" , hardware -> h_ifname ) ; goto malformed ; } * newchassis = chassis ; * newport = port ; return 1 ; malformed : # ifdef ENABLE_CUSTOM free ( custom ) ; # endif # ifdef ENABLE_DOT1 free ( vlan ) ; free ( pi ) ; # endif lldpd_chassis_cleanup ( chassis , 1 ) ; lldpd_port_cleanup ( port , 1 ) ; free ( port ) ; return - 1 ; } "," NULL ) { if ( errno == == ENOMEM ) log_warn ( ""lldp"" , ""unabletoallocatememory"" ""formanagementaddress"" ) ; else log_warn ( ""lldp"" , ""toolargemanagementaddress"" ""receivedon%s"" , hardware -> h_ifname ",vincentbernat@lldpd/793526f8884455f43daecd0a2c46772388417a00,CVE-2015-8012,https://github.com/vincentbernat/lldpd/commit/793526f8884455f43daecd0a2c46772388417a00,2020-01-28T19:15Z 803,CWE-787,"CWE-787 static plist_t parse_bin_node ( struct bplist_data * bplist , const char * * object ) { uint16_t type = 0 ; uint64_t size = 0 ; if ( ! object ) return NULL ; type = ( * * object ) & BPLIST_MASK ; size = ( * * object ) & BPLIST_FILL ; ( * object ) ++ ; if ( size == BPLIST_FILL ) { switch ( type ) { case BPLIST_DATA : case BPLIST_STRING : case BPLIST_UNICODE : case BPLIST_ARRAY : case BPLIST_SET : case BPLIST_DICT : { uint16_t next_size = * * object & BPLIST_FILL ; if ( ( * * object & BPLIST_MASK ) != BPLIST_UINT ) { PLIST_BIN_ERR ( ""%s:invalidsizenodetypefornodetype0x%02x:found0x%02x,expected0x%02x\\n"" , __func__ , type , * * object & BPLIST_MASK , BPLIST_UINT ) ; return NULL ; } ( * object ) ++ ; next_size = 1 << next_size ; if ( * object + next_size > bplist -> offset_table ) { PLIST_BIN_ERR ( ""%s:sizenodedatabytesfornodetype0x%02xpointoutsideofvalidrange\\n"" , __func__ , type ) ; return NULL ; } size = UINT_TO_HOST ( * object , next_size ) ; ( * object ) += next_size ; break ; } default : break ; } } switch ( type ) { case BPLIST_NULL : switch ( size ) { case BPLIST_TRUE : { plist_data_t data = plist_new_plist_data ( ) ; data -> type = PLIST_BOOLEAN ; data -> boolval = TRUE ; data -> length = 1 ; return node_create ( NULL , data ) ; } case BPLIST_FALSE : { plist_data_t data = plist_new_plist_data ( ) ; data -> type = PLIST_BOOLEAN ; data -> boolval = FALSE ; data -> length = 1 ; return node_create ( NULL , data ) ; } case BPLIST_NULL : default : return NULL ; } case BPLIST_UINT : if ( * object + ( uint64_t ) ( 1 << size ) > bplist -> offset_table ) { PLIST_BIN_ERR ( ""%s:BPLIST_UINTdatabytespointoutsideofvalidrange\\n"" , __func__ ) ; return NULL ; } return parse_uint_node ( object , size ) ; case BPLIST_REAL : if ( * object + ( uint64_t ) ( 1 << size ) > bplist -> offset_table ) { PLIST_BIN_ERR ( ""%s:BPLIST_REALdatabytespointoutsideofvalidrange\\n"" , __func__ ) ; return NULL ; } return parse_real_node ( object , size ) ; case BPLIST_DATE : if ( 3 != size ) { PLIST_BIN_ERR ( ""%s:invaliddatasizeforBPLIST_DATEnode\\n"" , __func__ ) ; return NULL ; } if ( * object + ( uint64_t ) ( 1 << size ) > bplist -> offset_table ) { PLIST_BIN_ERR ( ""%s:BPLIST_DATEdatabytespointoutsideofvalidrange\\n"" , __func__ ) ; return NULL ; } return parse_date_node ( object , size ) ; case BPLIST_DATA : if ( * object + size > bplist -> offset_table ) { PLIST_BIN_ERR ( ""%s:BPLIST_DATAdatabytespointoutsideofvalidrange\\n"" , __func__ ) ; return NULL ; } return parse_data_node ( object , size ) ; case BPLIST_STRING : if ( * object + size > bplist -> offset_table ) { PLIST_BIN_ERR ( ""%s:BPLIST_STRINGdatabytespointoutsideofvalidrange\\n"" , __func__ ) ; return NULL ; } return parse_string_node ( object , size ) ; case BPLIST_UNICODE : if ( size * 2 < size ) { PLIST_BIN_ERR ( ""%s:IntegeroverflowwhencalculatingBPLIST_UNICODEdatasize.\\n"" , __func__ ) ; return NULL ; } if ( * object + size * 2 > bplist -> offset_table ) { PLIST_BIN_ERR ( ""%s:BPLIST_UNICODEdatabytespointoutsideofvalidrange\\n"" , __func__ ) ; return NULL ; } return parse_unicode_node ( object , size ) ; case BPLIST_SET : case BPLIST_ARRAY : if ( * object + size > bplist -> offset_table ) { PLIST_BIN_ERR ( ""%s:BPLIST_ARRAYdatabytespointoutsideofvalidrange\\n"" , __func__ ) ; return NULL ; } return parse_array_node ( bplist , object , size ) ; case BPLIST_UID : if ( * object + size + 1 > bplist -> offset_table ) { PLIST_BIN_ERR ( ""%s:BPLIST_UIDdatabytespointoutsideofvalidrange\\n"" , __func__ ) ; return NULL ; } return parse_uid_node ( object , size ) ; case BPLIST_DICT : if ( * object + size > bplist -> offset_table ) { PLIST_BIN_ERR ( ""%s:BPLIST_REALdatabytespointoutsideofvalidrange\\n"" , __func__ ) ; return NULL ; } return parse_dict_node ( bplist , object , size ) ; default : PLIST_BIN_ERR ( ""%s:unexpectednodetype0x%02x\\n"" , __func__ , type ) ; return NULL ; } return NULL ; } "," object + size < * object || * object + size : if ( * object + size < * object || size * 2 < * object || * object + size * 2 object + size < * object || * object + size object + size < * object || * object + size > bplist -> offset_table ) { PLIST_BIN_ERR ( ""%s:BPLIST_DICTdatabytespointoutsideofvalidrange\\n"" , __func__ ) ",libimobiledevice@libplist/32ee5213fe64f1e10ec76c1ee861ee6f233120dd,CVE-2017-6439,https://github.com/libimobiledevice/libplist/commit/32ee5213fe64f1e10ec76c1ee861ee6f233120dd,2017-03-15T14:59Z 804,CWE-20,"CWE-20 error_t ksz8851Init ( NetInterface * interface ) { Ksz8851Context * context ; context = ( Ksz8851Context * ) interface -> nicContext ; TRACE_INFO ( ""InitializingKSZ8851Ethernetcontroller...\\r\\n"" ) ; # if ( KSZ8851_SPI_SUPPORT == ENABLED ) interface -> spiDriver -> init ( ) ; # endif interface -> extIntDriver -> init ( ) ; TRACE_DEBUG ( ""CIDER=0x%04"" PRIX16 ""\\r\\n"" , ksz8851ReadReg ( interface , KSZ8851_REG_CIDER ) ) ; TRACE_DEBUG ( ""PHY1ILR=0x%04"" PRIX16 ""\\r\\n"" , ksz8851ReadReg ( interface , KSZ8851_REG_PHY1ILR ) ) ; TRACE_DEBUG ( ""PHY1IHR=0x%04"" PRIX16 ""\\r\\n"" , ksz8851ReadReg ( interface , KSZ8851_REG_PHY1IHR ) ) ; if ( ksz8851ReadReg ( interface , KSZ8851_REG_CIDER ) != KSZ8851_REV_A3_ID ) { return ERROR_WRONG_IDENTIFIER ; } ksz8851DumpReg ( interface ) ; context -> frameId = 0 ; context -> txBuffer = memPoolAlloc ( ETH_MAX_FRAME_SIZE ) ; context -> rxBuffer = memPoolAlloc ( ETH_MAX_FRAME_SIZE ) ; if ( context -> txBuffer == NULL || context -> rxBuffer == NULL ) { memPoolFree ( context -> txBuffer ) ; memPoolFree ( context -> rxBuffer ) ; return ERROR_OUT_OF_MEMORY ; } ksz8851WriteReg ( interface , KSZ8851_REG_MARH , htons ( interface -> macAddr . w [ 0 ] ) ) ; ksz8851WriteReg ( interface , KSZ8851_REG_MARM , htons ( interface -> macAddr . w [ 1 ] ) ) ; ksz8851WriteReg ( interface , KSZ8851_REG_MARL , htons ( interface -> macAddr . w [ 2 ] ) ) ; ksz8851WriteReg ( interface , KSZ8851_REG_TXCR , TXCR_TXFCE | TXCR_TXPE | TXCR_TXCE ) ; ksz8851WriteReg ( interface , KSZ8851_REG_TXFDPR , TXFDPR_TXFPAI ) ; ksz8851WriteReg ( interface , KSZ8851_REG_RXCR1 , RXCR1_RXPAFMA | RXCR1_RXFCE | RXCR1_RXBE | RXCR1_RXME | RXCR1_RXUE ) ; ksz8851WriteReg ( interface , KSZ8851_REG_RXCR2 , RXCR2_SRDBL2 | RXCR2_IUFFP | RXCR2_RXIUFCEZ ) ; ksz8851WriteReg ( interface , KSZ8851_REG_RXQCR , RXQCR_RXFCTE | RXQCR_ADRFE ) ; ksz8851WriteReg ( interface , KSZ8851_REG_RXFDPR , RXFDPR_RXFPAI ) ; ksz8851WriteReg ( interface , KSZ8851_REG_RXFCTR , 1 ) ; ksz8851ClearBit ( interface , KSZ8851_REG_P1CR , P1CR_FORCE_DUPLEX ) ; ksz8851SetBit ( interface , KSZ8851_REG_P1CR , P1CR_RESTART_AN ) ; ksz8851SetBit ( interface , KSZ8851_REG_ISR , ISR_LCIS | ISR_TXIS | ISR_RXIS | ISR_RXOIS | ISR_TXPSIS | ISR_RXPSIS | ISR_TXSAIS | ISR_RXWFDIS | ISR_RXMPDIS | ISR_LDIS | ISR_EDIS | ISR_SPIBEIS ) ; ksz8851SetBit ( interface , KSZ8851_REG_IER , IER_LCIE | IER_TXIE | IER_RXIE ) ; ksz8851SetBit ( interface , KSZ8851_REG_TXCR , TXCR_TXE ) ; ksz8851SetBit ( interface , KSZ8851_REG_RXCR1 , RXCR1_RXE ) ; osSetEvent ( & interface -> nicTxEvent ) ; interface -> nicEvent = TRUE ; osSetEvent ( & netEvent ) ; return NO_ERROR ; } "," ( interface , KSZ8851_CIDER ) ) ; ( interface , KSZ8851_PHY1ILR ) ) ; ( interface , KSZ8851_PHY1IHR ) ) ; ( interface , KSZ8851_CIDER ) != ( KSZ8851_CIDER_FAMILY_ID_DEFAULT | KSZ8851_CIDER_CHIP_ID_DEFAULT | KSZ8851_CIDER_REV_ID_A3 ) ) { return ( interface , KSZ8851_MARH , htons ( ( interface , KSZ8851_MARM , htons ( ( interface , KSZ8851_MARL , htons ( ( interface , KSZ8851_TXCR , KSZ8851_TXCR_TXFCE | KSZ8851_TXCR_TXPE | KSZ8851_TXCR_TXCE ) ; ksz8851WriteReg ( interface , KSZ8851_TXFDPR , KSZ8851_TXFDPR_TXFPAI ) ; ksz8851WriteReg ( interface , KSZ8851_RXCR1 , KSZ8851_RXCR1_RXPAFMA | KSZ8851_RXCR1_RXFCE | KSZ8851_RXCR1_RXBE | KSZ8851_RXCR1_RXME | KSZ8851_RXCR1_RXUE ) ; ksz8851WriteReg ( interface , KSZ8851_RXCR2 , KSZ8851_RXCR2_SRDBL_SINGLE_FRAME | KSZ8851_RXCR2_IUFFP | KSZ8851_RXCR2_RXIUFCEZ ) ; ksz8851WriteReg ( interface , KSZ8851_RXQCR , KSZ8851_RXQCR_RXFCTE | KSZ8851_RXQCR_ADRFE ) ; ksz8851WriteReg ( interface , KSZ8851_RXFDPR , KSZ8851_RXFDPR_RXFPAI ) ; ksz8851WriteReg ( interface , KSZ8851_RXFCTR , 1 ) ( interface , KSZ8851_P1CR , KSZ8851_P1CR_FORCE_DUPLEX ) ; ksz8851SetBit ( interface , KSZ8851_P1CR , KSZ8851_P1CR_RESTART_AN ) ; ksz8851SetBit ( interface , KSZ8851_ISR , KSZ8851_ISR_LCIS | KSZ8851_ISR_TXIS | KSZ8851_ISR_RXIS | KSZ8851_ISR_RXOIS | KSZ8851_ISR_TXPSIS | KSZ8851_ISR_RXPSIS | KSZ8851_ISR_TXSAIS | KSZ8851_ISR_RXWFDIS | KSZ8851_ISR_RXMPDIS | KSZ8851_ISR_LDIS | KSZ8851_ISR_EDIS | KSZ8851_ISR_SPIBEIS ) ; ksz8851SetBit ( interface , KSZ8851_IER , KSZ8851_IER_LCIE | KSZ8851_IER_TXIE | KSZ8851_IER_RXIE ) ; ksz8851SetBit ( interface , KSZ8851_TXCR , KSZ8851_TXCR_TXE ) ; ksz8851SetBit ( interface , KSZ8851_RXCR1 , KSZ8851_RXCR1_RXE ) ; osSetEvent ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 805,CWE-416,"CWE-416 void ppp_unregister_channel ( struct ppp_channel * chan ) { struct channel * pch = chan -> ppp ; struct ppp_net * pn ; if ( ! pch ) return ; chan -> ppp = NULL ; down_write ( & pch -> chan_sem ) ; spin_lock_bh ( & pch -> downl ) ; pch -> chan = NULL ; spin_unlock_bh ( & pch -> downl ) ; up_write ( & pch -> chan_sem ) ; ppp_disconnect_channel ( pch ) ; pn = ppp_pernet ( pch -> chan_net ) ; spin_lock_bh ( & pn -> all_channels_lock ) ; list_del ( & pch -> list ) ; spin_unlock_bh ( & pn -> all_channels_lock ) ; pch -> file . dead = 1 ; wake_up_interruptible ( & pch -> file . rwait ) ; if ( atomic_dec_and_test ( & pch -> file . refcnt ) ) ppp_destroy_channel ( pch ) ; } "," all_channels_lock ) ; put_net ( pch -> chan_net ) ; pch -> chan_net = NULL ; ",torvalds@linux/1f461dcdd296eecedaffffc6bae2bfa90bd7eb89,CVE-2016-4805,https://github.com/torvalds/linux/commit/1f461dcdd296eecedaffffc6bae2bfa90bd7eb89,2016-05-23T10:59Z 806,CWE-362,"CWE-362 static int do_setxattr ( struct btrfs_trans_handle * trans , struct inode * inode , const char * name , const void * value , size_t size , int flags ) { struct btrfs_dir_item * di ; struct btrfs_root * root = BTRFS_I ( inode ) -> root ; struct btrfs_path * path ; size_t name_len = strlen ( name ) ; int ret = 0 ; if ( name_len + size > BTRFS_MAX_XATTR_SIZE ( root ) ) return - ENOSPC ; path = btrfs_alloc_path ( ) ; if ( ! path ) return - ENOMEM ; if ( flags & XATTR_REPLACE ) { di = btrfs_lookup_xattr ( trans , root , path , btrfs_ino ( inode ) , name , name_len , - 1 ) ; if ( IS_ERR ( di ) ) { ret = PTR_ERR ( di ) ; goto out ; } else if ( ! di ) { ret = - ENODATA ; goto out ; } ret = btrfs_delete_one_dir_name ( trans , root , path , di ) ; if ( ret ) goto out ; btrfs_release_path ( path ) ; if ( ! value ) goto out ; } else { di = btrfs_lookup_xattr ( NULL , root , path , btrfs_ino ( inode ) , name , name_len , 0 ) ; if ( IS_ERR ( di ) ) { ret = PTR_ERR ( di ) ; goto out ; } if ( ! di && ! value ) goto out ; btrfs_release_path ( path ) ; } again : ret = btrfs_insert_xattr_item ( trans , root , path , btrfs_ino ( inode ) , name , name_len , value , size ) ; if ( ret == - EOVERFLOW ) ret = - EEXIST ; if ( ret == - EEXIST ) { if ( flags & XATTR_CREATE ) goto out ; btrfs_release_path ( path ) ; di = btrfs_lookup_xattr ( trans , root , path , btrfs_ino ( inode ) , name , name_len , - 1 ) ; if ( IS_ERR ( di ) ) { ret = PTR_ERR ( di ) ; goto out ; } else if ( ! di ) { btrfs_release_path ( path ) ; goto again ; } ret = btrfs_delete_one_dir_name ( trans , root , path , di ) ; if ( ret ) goto out ; if ( value ) { btrfs_release_path ( path ) ; goto again ; } } out : btrfs_free_path ( path ) ; return ret ; } "," btrfs_dir_item * di = NULL - ENOMEM ; path -> skip_release_on_error = 1 ; if ( ! value ) { di = btrfs_lookup_xattr ( trans , root , path , btrfs_ino ( inode ) , name , name_len , - 1 ) ; if ( ! di && ( flags & & XATTR_REPLACE ) ) ret = - ENODATA ; else if ( di ) ret = btrfs_delete_one_dir_name ( trans , , path , di ) ; out ; } if ( flags & XATTR_REPLACE ) { ASSERT ( mutex_is_locked ( & inode -> i_mutex ) ) ; di = btrfs_lookup_xattr ( NULL , root , path , btrfs_ino ( inode ) , name , name_len , 0 ) ; if ( ! out ; } btrfs_release_path ( path ) ; di = NULL ; } ret = btrfs_insert_xattr_item ( trans , , path , btrfs_ino ( inode ) , name , name_len , value , size ) ; if ( ret == - EOVERFLOW ) { ret = 0 ; btrfs_assert_tree_locked ( path -> nodes [ 0 ] ) ; di = btrfs_match_dir_item_name ( root , path , name , name_len ) ; if ( ! di && ! ( flags & XATTR_REPLACE ) ) { ret = - ENOSPC ; goto out ; goto out ; } } else if ( ret == - EEXIST ) { ret = 0 ; di = btrfs_match_dir_item_name ( root , path , name , name_len ) ; ASSERT ( di ) ; } else if ( ret ) { goto out ; out ; } if ( di && ( flags & & XATTR_CREATE ) ) { ret = - EEXIST ; goto out ; } if ( di ) { const int slot = path -> slots [ 0 ] ; struct extent_buffer * leaf = path -> nodes [ 0 ] ; const u16 old_data_len = btrfs_dir_data_len ( leaf , di ) ; const u32 item_size = btrfs_item_size_nr ( leaf , slot ) ; const u32 data_size = sizeof ( * di ) + name_len + size ; struct btrfs_item * item ; unsigned long data_ptr ; char * ptr ; if ( size > old_data_len ) { if ( btrfs_leaf_free_space ( root , leaf ) < ( size - old_data_len ) ) { ret = - ENOSPC ; goto out out ; } } if ( old_data_len + name_len + sizeof ( * di ) == item_size ) { if ( size > old_data_len ) btrfs_extend_item ( root , path , size - old_data_len ) ; else if ( size < old_data_len ) btrfs_truncate_item ( root , path , data_size , 1 ) ; } else { ret = btrfs_delete_one_dir_name goto out ; btrfs_extend_item ( root , path , data_size ) ; } item = btrfs_item_nr ( slot ) ; ptr = btrfs_item_ptr ( leaf , slot , char ) ; ptr += btrfs_item_size ( leaf , item ) - data_size ; di = ( struct btrfs_dir_item * ) ptr ; btrfs_set_dir_data_len ( leaf , di , size ) ; data_ptr = ( ( unsigned long ) ( di + 1 ) ) + name_len ; write_extent_buffer ( leaf , value , data_ptr , size ) ; btrfs_mark_buffer_dirty ( leaf ) ; } else { } out : ",torvalds@linux/5f5bc6b1e2d5a6f827bc860ef2dc5b6f365d1339,CVE-2014-9710,https://github.com/torvalds/linux/commit/5f5bc6b1e2d5a6f827bc860ef2dc5b6f365d1339,2015-05-27T10:59Z 807,CWE-125,"CWE-125 int wasm_dis ( WasmOp * op , const unsigned char * buf , int buf_len ) { op -> len = 1 ; op -> op = buf [ 0 ] ; if ( op -> op > 0xbf ) return 1 ; WasmOpDef * opdef = & opcodes [ op -> op ] ; switch ( op -> op ) { case WASM_OP_TRAP : case WASM_OP_NOP : case WASM_OP_ELSE : case WASM_OP_RETURN : case WASM_OP_DROP : case WASM_OP_SELECT : case WASM_OP_I32EQZ : case WASM_OP_I32EQ : case WASM_OP_I32NE : case WASM_OP_I32LTS : case WASM_OP_I32LTU : case WASM_OP_I32GTS : case WASM_OP_I32GTU : case WASM_OP_I32LES : case WASM_OP_I32LEU : case WASM_OP_I32GES : case WASM_OP_I32GEU : case WASM_OP_I64EQZ : case WASM_OP_I64EQ : case WASM_OP_I64NE : case WASM_OP_I64LTS : case WASM_OP_I64LTU : case WASM_OP_I64GTS : case WASM_OP_I64GTU : case WASM_OP_I64LES : case WASM_OP_I64LEU : case WASM_OP_I64GES : case WASM_OP_I64GEU : case WASM_OP_F32EQ : case WASM_OP_F32NE : case WASM_OP_F32LT : case WASM_OP_F32GT : case WASM_OP_F32LE : case WASM_OP_F32GE : case WASM_OP_F64EQ : case WASM_OP_F64NE : case WASM_OP_F64LT : case WASM_OP_F64GT : case WASM_OP_F64LE : case WASM_OP_F64GE : case WASM_OP_I32CLZ : case WASM_OP_I32CTZ : case WASM_OP_I32POPCNT : case WASM_OP_I32ADD : case WASM_OP_I32SUB : case WASM_OP_I32MUL : case WASM_OP_I32DIVS : case WASM_OP_I32DIVU : case WASM_OP_I32REMS : case WASM_OP_I32REMU : case WASM_OP_I32AND : case WASM_OP_I32OR : case WASM_OP_I32XOR : case WASM_OP_I32SHL : case WASM_OP_I32SHRS : case WASM_OP_I32SHRU : case WASM_OP_I32ROTL : case WASM_OP_I32ROTR : case WASM_OP_I64CLZ : case WASM_OP_I64CTZ : case WASM_OP_I64POPCNT : case WASM_OP_I64ADD : case WASM_OP_I64SUB : case WASM_OP_I64MUL : case WASM_OP_I64DIVS : case WASM_OP_I64DIVU : case WASM_OP_I64REMS : case WASM_OP_I64REMU : case WASM_OP_I64AND : case WASM_OP_I64OR : case WASM_OP_I64XOR : case WASM_OP_I64SHL : case WASM_OP_I64SHRS : case WASM_OP_I64SHRU : case WASM_OP_I64ROTL : case WASM_OP_I64ROTR : case WASM_OP_F32ABS : case WASM_OP_F32NEG : case WASM_OP_F32CEIL : case WASM_OP_F32FLOOR : case WASM_OP_F32TRUNC : case WASM_OP_F32NEAREST : case WASM_OP_F32SQRT : case WASM_OP_F32ADD : case WASM_OP_F32SUB : case WASM_OP_F32MUL : case WASM_OP_F32DIV : case WASM_OP_F32MIN : case WASM_OP_F32MAX : case WASM_OP_F32COPYSIGN : case WASM_OP_F64ABS : case WASM_OP_F64NEG : case WASM_OP_F64CEIL : case WASM_OP_F64FLOOR : case WASM_OP_F64TRUNC : case WASM_OP_F64NEAREST : case WASM_OP_F64SQRT : case WASM_OP_F64ADD : case WASM_OP_F64SUB : case WASM_OP_F64MUL : case WASM_OP_F64DIV : case WASM_OP_F64MIN : case WASM_OP_F64MAX : case WASM_OP_F64COPYSIGN : case WASM_OP_I32WRAPI64 : case WASM_OP_I32TRUNCSF32 : case WASM_OP_I32TRUNCUF32 : case WASM_OP_I32TRUNCSF64 : case WASM_OP_I32TRUNCUF64 : case WASM_OP_I64EXTENDSI32 : case WASM_OP_I64EXTENDUI32 : case WASM_OP_I64TRUNCSF32 : case WASM_OP_I64TRUNCUF32 : case WASM_OP_I64TRUNCSF64 : case WASM_OP_I64TRUNCUF64 : case WASM_OP_F32CONVERTSI32 : case WASM_OP_F32CONVERTUI32 : case WASM_OP_F32CONVERTSI64 : case WASM_OP_F32CONVERTUI64 : case WASM_OP_F32DEMOTEF64 : case WASM_OP_F64CONVERTSI32 : case WASM_OP_F64CONVERTUI32 : case WASM_OP_F64CONVERTSI64 : case WASM_OP_F64CONVERTUI64 : case WASM_OP_F64PROMOTEF32 : case WASM_OP_I32REINTERPRETF32 : case WASM_OP_I64REINTERPRETF64 : case WASM_OP_F32REINTERPRETI32 : case WASM_OP_F64REINTERPRETI64 : case WASM_OP_END : { snprintf ( op -> txt , R_ASM_BUFSIZE , ""%s"" , opdef -> txt ) ; } break ; case WASM_OP_BLOCK : case WASM_OP_LOOP : case WASM_OP_IF : { st32 val = 0 ; size_t n = read_i32_leb128 ( buf + 1 , buf + buf_len , & val ) ; if ( ! ( n > 0 && n < buf_len ) ) goto err ; switch ( 0x80 - val ) { case R_BIN_WASM_VALUETYPE_EMPTY : snprintf ( op -> txt , R_ASM_BUFSIZE , ""%s"" , opdef -> txt ) ; break ; case R_BIN_WASM_VALUETYPE_i32 : snprintf ( op -> txt , R_ASM_BUFSIZE , ""%s(resulti32)"" , opdef -> txt ) ; break ; case R_BIN_WASM_VALUETYPE_i64 : snprintf ( op -> txt , R_ASM_BUFSIZE , ""%s(resulti64)"" , opdef -> txt ) ; break ; case R_BIN_WASM_VALUETYPE_f32 : snprintf ( op -> txt , R_ASM_BUFSIZE , ""%s(resultf32)"" , opdef -> txt ) ; break ; case R_BIN_WASM_VALUETYPE_f64 : snprintf ( op -> txt , R_ASM_BUFSIZE , ""%s(resultf64)"" , opdef -> txt ) ; break ; default : snprintf ( op -> txt , R_ASM_BUFSIZE , ""%s(result?)"" , opdef -> txt ) ; break ; } op -> len += n ; } break ; case WASM_OP_BR : case WASM_OP_BRIF : case WASM_OP_CALL : { ut32 val = 0 ; size_t n = read_u32_leb128 ( buf + 1 , buf + buf_len , & val ) ; if ( ! ( n > 0 && n < buf_len ) ) goto err ; snprintf ( op -> txt , R_ASM_BUFSIZE , ""%s%d"" , opdef -> txt , val ) ; op -> len += n ; } break ; case WASM_OP_BRTABLE : { ut32 count = 0 , * table = NULL , def = 0 ; size_t n = read_u32_leb128 ( buf + 1 , buf + buf_len , & count ) ; if ( ! ( n > 0 && n < buf_len ) ) goto err ; if ( ! ( table = calloc ( count , sizeof ( ut32 ) ) ) ) goto err ; int i = 0 ; op -> len += n ; for ( i = 0 ; i < count ; i ++ ) { n = read_u32_leb128 ( buf + op -> len , buf + buf_len , & table [ i ] ) ; if ( ! ( op -> len + n <= buf_len ) ) goto beach ; op -> len += n ; } n = read_u32_leb128 ( buf + op -> len , buf + buf_len , & def ) ; if ( ! ( n > 0 && n + op -> len < buf_len ) ) goto beach ; op -> len += n ; snprintf ( op -> txt , R_ASM_BUFSIZE , ""%s%d"" , opdef -> txt , count ) ; for ( i = 0 ; i < count && strlen ( op -> txt ) < R_ASM_BUFSIZE ; i ++ ) { snprintf ( op -> txt + strlen ( op -> txt ) , R_ASM_BUFSIZE , ""%d"" , table [ i ] ) ; } snprintf ( op -> txt + strlen ( op -> txt ) , R_ASM_BUFSIZE , ""%d"" , def ) ; free ( table ) ; break ; beach : free ( table ) ; goto err ; } break ; case WASM_OP_CALLINDIRECT : { ut32 val = 0 , reserved = 0 ; size_t n = read_u32_leb128 ( buf + 1 , buf + buf_len , & val ) ; if ( ! ( n > 0 && n < buf_len ) ) goto err ; op -> len += n ; n = read_u32_leb128 ( buf + op -> len , buf + buf_len , & reserved ) ; if ( ! ( n == 1 && op -> len + n <= buf_len ) ) goto err ; reserved &= 0x1 ; snprintf ( op -> txt , R_ASM_BUFSIZE , ""%s%d%d"" , opdef -> txt , val , reserved ) ; op -> len += n ; } break ; case WASM_OP_GETLOCAL : case WASM_OP_SETLOCAL : case WASM_OP_TEELOCAL : case WASM_OP_GETGLOBAL : case WASM_OP_SETGLOBAL : { ut32 val = 0 ; size_t n = read_u32_leb128 ( buf + 1 , buf + buf_len , & val ) ; if ( ! ( n > 0 && n < buf_len ) ) goto err ; snprintf ( op -> txt , R_ASM_BUFSIZE , ""%s%d"" , opdef -> txt , val ) ; op -> len += n ; } break ; case WASM_OP_I32LOAD : case WASM_OP_I64LOAD : case WASM_OP_F32LOAD : case WASM_OP_F64LOAD : case WASM_OP_I32LOAD8S : case WASM_OP_I32LOAD8U : case WASM_OP_I32LOAD16S : case WASM_OP_I32LOAD16U : case WASM_OP_I64LOAD8S : case WASM_OP_I64LOAD8U : case WASM_OP_I64LOAD16S : case WASM_OP_I64LOAD16U : case WASM_OP_I64LOAD32S : case WASM_OP_I64LOAD32U : case WASM_OP_I32STORE : case WASM_OP_I64STORE : case WASM_OP_F32STORE : case WASM_OP_F64STORE : case WASM_OP_I32STORE8 : case WASM_OP_I32STORE16 : case WASM_OP_I64STORE8 : case WASM_OP_I64STORE16 : case WASM_OP_I64STORE32 : { ut32 flag = 0 , offset = 0 ; size_t n = read_u32_leb128 ( buf + 1 , buf + buf_len , & flag ) ; if ( ! ( n > 0 && n < buf_len ) ) goto err ; op -> len += n ; n = read_u32_leb128 ( buf + op -> len , buf + buf_len , & offset ) ; if ( ! ( n > 0 && op -> len + n <= buf_len ) ) goto err ; snprintf ( op -> txt , R_ASM_BUFSIZE , ""%s%d%d"" , opdef -> txt , flag , offset ) ; op -> len += n ; } break ; case WASM_OP_CURRENTMEMORY : case WASM_OP_GROWMEMORY : { ut32 reserved = 0 ; size_t n = read_u32_leb128 ( buf + 1 , buf + buf_len , & reserved ) ; if ( ! ( n == 1 && n < buf_len ) ) goto err ; reserved &= 0x1 ; snprintf ( op -> txt , R_ASM_BUFSIZE , ""%s%d"" , opdef -> txt , reserved ) ; op -> len += n ; } break ; case WASM_OP_I32CONST : { st32 val = 0 ; size_t n = read_i32_leb128 ( buf + 1 , buf + buf_len , & val ) ; if ( ! ( n > 0 && n < buf_len ) ) goto err ; snprintf ( op -> txt , R_ASM_BUFSIZE , ""%s%"" PFMT32d , opdef -> txt , val ) ; op -> len += n ; } break ; case WASM_OP_I64CONST : { st64 val = 0 ; size_t n = read_i64_leb128 ( buf + 1 , buf + buf_len , & val ) ; if ( ! ( n > 0 && n < buf_len ) ) goto err ; snprintf ( op -> txt , R_ASM_BUFSIZE , ""%s%"" PFMT64d , opdef -> txt , val ) ; op -> len += n ; } break ; case WASM_OP_F32CONST : { ut32 val = 0 ; size_t n = read_u32_leb128 ( buf + 1 , buf + buf_len , & val ) ; if ( ! ( n > 0 && n < buf_len ) ) goto err ; long double d = ( long double ) val ; snprintf ( op -> txt , R_ASM_BUFSIZE , ""%s%"" LDBLFMT , opdef -> txt , d ) ; op -> len += n ; } break ; case WASM_OP_F64CONST : { ut64 val = 0 ; size_t n = read_u64_leb128 ( buf + 1 , buf + buf_len , & val ) ; if ( ! ( n > 0 && n < buf_len ) ) goto err ; long double d = ( long double ) val ; snprintf ( op -> txt , R_ASM_BUFSIZE , ""%s%"" LDBLFMT , opdef -> txt , d ) ; op -> len += n ; } break ; default : goto err ; } return op -> len ; err : op -> len = 1 ; snprintf ( op -> txt , R_ASM_BUFSIZE , ""invalid"" ) ; return op -> len ; } "," > 0xbf ) { return 1 ; } buf_len ) ) { goto err ; } ) ) ) { goto err ; } buf_len ) ) { goto beach ; } buf_len ) ) { goto beach ; } -> txt ) + 10 ++ ) { int optxtlen = strlen ( op -> txt ) ; -> txt + optxtlen , R_ASM_BUFSIZE - optxtlen , ""%d"" , ",radare@radare2/52b1526443c1f433087928291d1c3d37a5600515,CVE-2017-15368,https://github.com/radare/radare2/commit/52b1526443c1f433087928291d1c3d37a5600515,2017-10-16T01:29Z 808,CWE-436,"CWE-436 static void flatpak_proxy_client_finalize ( GObject * object ) { FlatpakProxyClient * client = FLATPAK_PROXY_CLIENT ( object ) ; client -> proxy -> clients = g_list_remove ( client -> proxy -> clients , client ) ; g_clear_object ( & client -> proxy ) ; g_hash_table_destroy ( client -> rewrite_reply ) ; g_hash_table_destroy ( client -> get_owner_reply ) ; g_hash_table_destroy ( client -> unique_id_policy ) ; free_side ( & client -> client_side ) ; free_side ( & client -> bus_side ) ; G_OBJECT_CLASS ( flatpak_proxy_client_parent_class ) -> finalize ( object ) ; } "," client -> proxy ) ; g_byte_array_free ( client -> auth_buffer , TRUE ",flatpak@flatpak/52346bf187b5a7f1c0fe9075b328b7ad6abe78f6,CVE-2018-6560,https://github.com/flatpak/flatpak/commit/52346bf187b5a7f1c0fe9075b328b7ad6abe78f6,2018-02-02T14:29Z 809,CWE-119,"CWE-119 void vp9_encode_intra_block_plane ( MACROBLOCK * x , BLOCK_SIZE bsize , int plane ) { const MACROBLOCKD * const xd = & x -> e_mbd ; struct encode_b_args arg = { x , NULL , & xd -> mi [ 0 ] -> mbmi . skip } ; vp9_foreach_transformed_block_in_plane ( xd , bsize , plane , encode_block_intra , & arg ) ; } "," , plane , vp9_encode_block_intra , & arg ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 810,CWE-20,"CWE-20 static int trusted_update ( struct key * key , struct key_preparsed_payload * prep ) { struct trusted_key_payload * p ; struct trusted_key_payload * new_p ; struct trusted_key_options * new_o ; size_t datalen = prep -> datalen ; char * datablob ; int ret = 0 ; if ( test_bit ( KEY_FLAG_NEGATIVE , & key -> flags ) ) return - ENOKEY ; p = key -> payload . data [ 0 ] ; if ( ! p -> migratable ) return - EPERM ; if ( datalen <= 0 || datalen > 32767 || ! prep -> data ) return - EINVAL ; datablob = kmalloc ( datalen + 1 , GFP_KERNEL ) ; if ( ! datablob ) return - ENOMEM ; new_o = trusted_options_alloc ( ) ; if ( ! new_o ) { ret = - ENOMEM ; goto out ; } new_p = trusted_payload_alloc ( key ) ; if ( ! new_p ) { ret = - ENOMEM ; goto out ; } memcpy ( datablob , prep -> data , datalen ) ; datablob [ datalen ] = '\\0' ; ret = datablob_parse ( datablob , new_p , new_o ) ; if ( ret != Opt_update ) { ret = - EINVAL ; kzfree ( new_p ) ; goto out ; } if ( ! new_o -> keyhandle ) { ret = - EINVAL ; kzfree ( new_p ) ; goto out ; } new_p -> migratable = p -> migratable ; new_p -> key_len = p -> key_len ; memcpy ( new_p -> key , p -> key , p -> key_len ) ; dump_payload ( p ) ; dump_payload ( new_p ) ; ret = key_seal ( new_p , new_o ) ; if ( ret < 0 ) { pr_info ( ""trusted_key:key_sealfailed(%d)\\n"" , ret ) ; kzfree ( new_p ) ; goto out ; } if ( new_o -> pcrlock ) { ret = pcrlock ( new_o -> pcrlock ) ; if ( ret < 0 ) { pr_info ( ""trusted_key:pcrlockfailed(%d)\\n"" , ret ) ; kzfree ( new_p ) ; goto out ; } } rcu_assign_keypointer ( key , new_p ) ; call_rcu ( & p -> rcu , trusted_rcu_free ) ; out : kzfree ( datablob ) ; kzfree ( new_o ) ; return ret ; } "," ; if ( key_is_negative ( key ) ) return ",torvalds@linux/363b02dab09b3226f3bd1420dad9c72b79a42a76,CVE-2017-15951,https://github.com/torvalds/linux/commit/363b02dab09b3226f3bd1420dad9c72b79a42a76,2017-10-28T02:29Z 811,CWE-190,"CWE-190 int lzo1x_decompress_safe ( const unsigned char * in , size_t in_len , unsigned char * out , size_t * out_len ) { unsigned char * op ; const unsigned char * ip ; size_t t , next ; size_t state = 0 ; const unsigned char * m_pos ; const unsigned char * const ip_end = in + in_len ; unsigned char * const op_end = out + * out_len ; op = out ; ip = in ; if ( unlikely ( in_len < 3 ) ) goto input_overrun ; if ( * ip > 17 ) { t = * ip ++ - 17 ; if ( t < 4 ) { next = t ; goto match_next ; } goto copy_literal_run ; } for ( ; ; ) { t = * ip ++ ; if ( t < 16 ) { if ( likely ( state == 0 ) ) { if ( unlikely ( t == 0 ) ) { while ( unlikely ( * ip == 0 ) ) { t += 255 ; ip ++ ; NEED_IP ( 1 ) ; } t += 15 + * ip ++ ; } t += 3 ; copy_literal_run : # if defined ( CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS ) if ( likely ( HAVE_IP ( t + 15 ) && HAVE_OP ( t + 15 ) ) ) { const unsigned char * ie = ip + t ; unsigned char * oe = op + t ; do { COPY8 ( op , ip ) ; op += 8 ; ip += 8 ; COPY8 ( op , ip ) ; op += 8 ; ip += 8 ; } while ( ip < ie ) ; ip = ie ; op = oe ; } else # endif { NEED_OP ( t ) ; NEED_IP ( t + 3 ) ; do { * op ++ = * ip ++ ; } while ( -- t > 0 ) ; } state = 4 ; continue ; } else if ( state != 4 ) { next = t & 3 ; m_pos = op - 1 ; m_pos -= t >> 2 ; m_pos -= * ip ++ << 2 ; TEST_LB ( m_pos ) ; NEED_OP ( 2 ) ; op [ 0 ] = m_pos [ 0 ] ; op [ 1 ] = m_pos [ 1 ] ; op += 2 ; goto match_next ; } else { next = t & 3 ; m_pos = op - ( 1 + M2_MAX_OFFSET ) ; m_pos -= t >> 2 ; m_pos -= * ip ++ << 2 ; t = 3 ; } } else if ( t >= 64 ) { next = t & 3 ; m_pos = op - 1 ; m_pos -= ( t >> 2 ) & 7 ; m_pos -= * ip ++ << 3 ; t = ( t >> 5 ) - 1 + ( 3 - 1 ) ; } else if ( t >= 32 ) { t = ( t & 31 ) + ( 3 - 1 ) ; if ( unlikely ( t == 2 ) ) { while ( unlikely ( * ip == 0 ) ) { t += 255 ; ip ++ ; NEED_IP ( 1 ) ; } t += 31 + * ip ++ ; NEED_IP ( 2 ) ; } m_pos = op - 1 ; next = get_unaligned_le16 ( ip ) ; ip += 2 ; m_pos -= next >> 2 ; next &= 3 ; } else { m_pos = op ; m_pos -= ( t & 8 ) << 11 ; t = ( t & 7 ) + ( 3 - 1 ) ; if ( unlikely ( t == 2 ) ) { while ( unlikely ( * ip == 0 ) ) { t += 255 ; ip ++ ; NEED_IP ( 1 ) ; } t += 7 + * ip ++ ; NEED_IP ( 2 ) ; } next = get_unaligned_le16 ( ip ) ; ip += 2 ; m_pos -= next >> 2 ; next &= 3 ; if ( m_pos == op ) goto eof_found ; m_pos -= 0x4000 ; } TEST_LB ( m_pos ) ; # if defined ( CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS ) if ( op - m_pos >= 8 ) { unsigned char * oe = op + t ; if ( likely ( HAVE_OP ( t + 15 ) ) ) { do { COPY8 ( op , m_pos ) ; op += 8 ; m_pos += 8 ; COPY8 ( op , m_pos ) ; op += 8 ; m_pos += 8 ; } while ( op < oe ) ; op = oe ; if ( HAVE_IP ( 6 ) ) { state = next ; COPY4 ( op , ip ) ; op += next ; ip += next ; continue ; } } else { NEED_OP ( t ) ; do { * op ++ = * m_pos ++ ; } while ( op < oe ) ; } } else # endif { unsigned char * oe = op + t ; NEED_OP ( t ) ; op [ 0 ] = m_pos [ 0 ] ; op [ 1 ] = m_pos [ 1 ] ; op += 2 ; m_pos += 2 ; do { * op ++ = * m_pos ++ ; } while ( op < oe ) ; } match_next : state = next ; t = next ; # if defined ( CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS ) if ( likely ( HAVE_IP ( 6 ) && HAVE_OP ( 4 ) ) ) { COPY4 ( op , ip ) ; op += t ; ip += t ; } else # endif { NEED_IP ( t + 3 ) ; NEED_OP ( t ) ; while ( t > 0 ) { * op ++ = * ip ++ ; t -- ; } } } eof_found : * out_len = op - out ; return ( t != 3 ? LZO_E_ERROR : ip == ip_end ? LZO_E_OK : ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN ) ; input_overrun : * out_len = op - out ; return LZO_E_INPUT_OVERRUN ; output_overrun : * out_len = op - out ; return LZO_E_OUTPUT_OVERRUN ; lookbehind_overrun : * out_len = op - out ; return LZO_E_LOOKBEHIND_OVERRUN ; } "," NEED_IP ( 1 , 0 HAVE_IP ( t , 15 ) && HAVE_OP ( t , 15 ) ) NEED_OP ( t , 0 NEED_IP ( t , 3 ) ; NEED_OP ( 2 , 0 NEED_IP ( 1 , 0 NEED_IP ( 2 , 0 NEED_IP ( 1 , 0 NEED_IP ( 2 , 0 HAVE_OP ( t , 15 ) ) HAVE_IP ( 6 , 0 NEED_OP ( t , 0 NEED_OP ( t , 0 HAVE_IP ( 6 , 0 HAVE_OP ( 4 , 0 NEED_IP ( t , 3 ) ; NEED_OP ( t , 0 ",torvalds@linux/206a81c18401c0cde6e579164f752c4b147324ce,CVE-2014-4608,https://github.com/torvalds/linux/commit/206a81c18401c0cde6e579164f752c4b147324ce,2014-07-03T04:22Z 812,CWE-000,"CWE-000 int fit_image_load ( bootm_headers_t * images , ulong addr , const char * * fit_unamep , const char * * fit_uname_configp , int arch , int image_type , int bootstage_id , enum fit_load_op load_op , ulong * datap , ulong * lenp ) { int cfg_noffset , noffset ; const char * fit_uname ; const char * fit_uname_config ; const char * fit_base_uname_config ; const void * fit ; void * buf ; void * loadbuf ; size_t size ; int type_ok , os_ok ; ulong load , load_end , data , len ; uint8_t os , comp ; # ifndef USE_HOSTCC uint8_t os_arch ; # endif const char * prop_name ; int ret ; fit = map_sysmem ( addr , 0 ) ; fit_uname = fit_unamep ? * fit_unamep : NULL ; fit_uname_config = fit_uname_configp ? * fit_uname_configp : NULL ; fit_base_uname_config = NULL ; prop_name = fit_get_image_type_property ( image_type ) ; printf ( ""##Loading%sfromFITImageat%08lx...\\n"" , prop_name , addr ) ; bootstage_mark ( bootstage_id + BOOTSTAGE_SUB_FORMAT ) ; if ( fit_check_format ( fit , IMAGE_SIZE_INVAL ) ) { printf ( ""BadFIT%simageformat!\\n"" , prop_name ) ; bootstage_error ( bootstage_id + BOOTSTAGE_SUB_FORMAT ) ; return - ENOEXEC ; } bootstage_mark ( bootstage_id + BOOTSTAGE_SUB_FORMAT_OK ) ; if ( fit_uname ) { bootstage_mark ( bootstage_id + BOOTSTAGE_SUB_UNIT_NAME ) ; noffset = fit_image_get_node ( fit , fit_uname ) ; } else { bootstage_mark ( bootstage_id + BOOTSTAGE_SUB_NO_UNIT_NAME ) ; if ( IMAGE_ENABLE_BEST_MATCH && ! fit_uname_config ) { cfg_noffset = fit_conf_find_compat ( fit , gd_fdt_blob ( ) ) ; } else { cfg_noffset = fit_conf_get_node ( fit , fit_uname_config ) ; } if ( cfg_noffset < 0 ) { puts ( ""Couldnotfindconfigurationnode\\n"" ) ; bootstage_error ( bootstage_id + BOOTSTAGE_SUB_NO_UNIT_NAME ) ; return - ENOENT ; } fit_base_uname_config = fdt_get_name ( fit , cfg_noffset , NULL ) ; printf ( ""Using\'%s\'configuration\\n"" , fit_base_uname_config ) ; if ( image_type == IH_TYPE_KERNEL ) images -> fit_uname_cfg = fit_base_uname_config ; if ( FIT_IMAGE_ENABLE_VERIFY && images -> verify ) { puts ( ""VerifyingHashIntegrity..."" ) ; if ( fit_config_verify ( fit , cfg_noffset ) ) { puts ( ""BadDataHash\\n"" ) ; bootstage_error ( bootstage_id + BOOTSTAGE_SUB_HASH ) ; return - EACCES ; } puts ( ""OK\\n"" ) ; } bootstage_mark ( BOOTSTAGE_ID_FIT_CONFIG ) ; noffset = fit_conf_get_prop_node ( fit , cfg_noffset , prop_name ) ; fit_uname = fit_get_name ( fit , noffset , NULL ) ; } if ( noffset < 0 ) { printf ( ""Couldnotfindsubimagenodetype\'%s\'\\n"" , prop_name ) ; bootstage_error ( bootstage_id + BOOTSTAGE_SUB_SUBNODE ) ; return - ENOENT ; } printf ( ""Trying\'%s\'%ssubimage\\n"" , fit_uname , prop_name ) ; ret = fit_image_select ( fit , noffset , images -> verify ) ; if ( ret ) { bootstage_error ( bootstage_id + BOOTSTAGE_SUB_HASH ) ; return ret ; } bootstage_mark ( bootstage_id + BOOTSTAGE_SUB_CHECK_ARCH ) ; if ( ! host_build ( ) && IS_ENABLED ( CONFIG_SANDBOX ) ) { if ( ! fit_image_check_target_arch ( fit , noffset ) ) { puts ( ""UnsupportedArchitecture\\n"" ) ; bootstage_error ( bootstage_id + BOOTSTAGE_SUB_CHECK_ARCH ) ; return - ENOEXEC ; } } # ifndef USE_HOSTCC fit_image_get_arch ( fit , noffset , & os_arch ) ; images -> os . arch = os_arch ; # endif bootstage_mark ( bootstage_id + BOOTSTAGE_SUB_CHECK_ALL ) ; type_ok = fit_image_check_type ( fit , noffset , image_type ) || fit_image_check_type ( fit , noffset , IH_TYPE_FIRMWARE ) || ( image_type == IH_TYPE_KERNEL && fit_image_check_type ( fit , noffset , IH_TYPE_KERNEL_NOLOAD ) ) ; os_ok = image_type == IH_TYPE_FLATDT || image_type == IH_TYPE_FPGA || fit_image_check_os ( fit , noffset , IH_OS_LINUX ) || fit_image_check_os ( fit , noffset , IH_OS_U_BOOT ) || fit_image_check_os ( fit , noffset , IH_OS_OPENRTOS ) || fit_image_check_os ( fit , noffset , IH_OS_EFI ) || fit_image_check_os ( fit , noffset , IH_OS_VXWORKS ) ; if ( ( ! type_ok || ! os_ok ) && image_type != IH_TYPE_LOADABLE ) { fit_image_get_os ( fit , noffset , & os ) ; printf ( ""No%s%s%sImage\\n"" , genimg_get_os_name ( os ) , genimg_get_arch_name ( arch ) , genimg_get_type_name ( image_type ) ) ; bootstage_error ( bootstage_id + BOOTSTAGE_SUB_CHECK_ALL ) ; return - EIO ; } bootstage_mark ( bootstage_id + BOOTSTAGE_SUB_CHECK_ALL_OK ) ; if ( fit_image_get_data_and_size ( fit , noffset , ( const void * * ) & buf , & size ) ) { printf ( ""Couldnotfind%ssubimagedata!\\n"" , prop_name ) ; bootstage_error ( bootstage_id + BOOTSTAGE_SUB_GET_DATA ) ; return - ENOENT ; } if ( IS_ENABLED ( CONFIG_FIT_CIPHER ) && IMAGE_ENABLE_DECRYPT ) { puts ( ""DecryptingData..."" ) ; if ( fit_image_uncipher ( fit , noffset , & buf , & size ) ) { puts ( ""Error\\n"" ) ; return - EACCES ; } puts ( ""OK\\n"" ) ; } if ( ! host_build ( ) && IS_ENABLED ( CONFIG_FIT_IMAGE_POST_PROCESS ) ) board_fit_image_post_process ( & buf , & size ) ; len = ( ulong ) size ; bootstage_mark ( bootstage_id + BOOTSTAGE_SUB_GET_DATA_OK ) ; data = map_to_sysmem ( buf ) ; load = data ; if ( load_op == FIT_LOAD_IGNORED ) { } else if ( fit_image_get_load ( fit , noffset , & load ) ) { if ( load_op == FIT_LOAD_REQUIRED ) { printf ( ""Can\'tget%ssubimageloadaddress!\\n"" , prop_name ) ; bootstage_error ( bootstage_id + BOOTSTAGE_SUB_LOAD ) ; return - EBADF ; } } else if ( load_op != FIT_LOAD_OPTIONAL_NON_ZERO || load ) { ulong image_start , image_end ; image_start = addr ; image_end = addr + fit_get_size ( fit ) ; load_end = load + len ; if ( image_type != IH_TYPE_KERNEL && load < image_end && load_end > image_start ) { printf ( ""Error:%soverwritten\\n"" , prop_name ) ; return - EXDEV ; } printf ( ""Loading%sfrom0x%08lxto0x%08lx\\n"" , prop_name , data , load ) ; } else { load = data ; } comp = IH_COMP_NONE ; loadbuf = buf ; if ( ! fit_image_get_comp ( fit , noffset , & comp ) && comp != IH_COMP_NONE && ! ( image_type == IH_TYPE_KERNEL || image_type == IH_TYPE_KERNEL_NOLOAD || image_type == IH_TYPE_RAMDISK ) ) { ulong max_decomp_len = len * 20 ; if ( load == data ) { loadbuf = malloc ( max_decomp_len ) ; load = map_to_sysmem ( loadbuf ) ; } else { loadbuf = map_sysmem ( load , max_decomp_len ) ; } if ( image_decomp ( comp , load , data , image_type , loadbuf , buf , len , max_decomp_len , & load_end ) ) { printf ( ""Errordecompressing%s\\n"" , prop_name ) ; return - ENOEXEC ; } len = load_end - load ; } else if ( load != data ) { loadbuf = map_sysmem ( load , len ) ; memcpy ( loadbuf , buf , len ) ; } if ( image_type == IH_TYPE_RAMDISK && comp != IH_COMP_NONE ) puts ( ""WARNING:\'compression\'nodesforramdisksaredeprecated,"" ""pleasefixyour.itsfile!\\n"" ) ; if ( image_type == IH_TYPE_FLATDT && fdt_check_header ( loadbuf ) ) { puts ( ""SubimagedataisnotaFDT"" ) ; return - ENOEXEC ; } bootstage_mark ( bootstage_id + BOOTSTAGE_SUB_LOAD ) ; * datap = load ; * lenp = len ; if ( fit_unamep ) * fit_unamep = ( char * ) fit_uname ; if ( fit_uname_configp ) * fit_uname_configp = ( char * ) ( fit_uname_config ? : fit_base_uname_config ) ; return noffset ; } "," BOOTSTAGE_SUB_FORMAT ) ; ret = fit_check_format ( fit , IMAGE_SIZE_INVAL ) ; if ( ret { printf ( ""BadFIT%simageformat!(err=%d)\\n"" , prop_name , ret ) ; if ( CONFIG_IS_ENABLED ( FIT_SIGNATURE ) && ret == - EADDRNOTAVAIL ) printf ( ""Signaturecheckingpreventsuseofunitaddresses(@)innodes\\n"" ) ; bootstage_error ) ; return ret ; } bootstage_mark ",u-boot@u-boot/3f04db891a353f4b127ed57279279f851c6b4917,CVE-2021-27138,https://github.com/u-boot/u-boot/commit/3f04db891a353f4b127ed57279279f851c6b4917,2021-02-17T23:15Z 813,CWE-119,"CWE-119 void receive_tcppacket ( connection_t * c , const char * buffer , int len ) { vpn_packet_t outpkt ; outpkt . len = len ; if ( c -> options & OPTION_TCPONLY ) outpkt . priority = 0 ; else outpkt . priority = - 1 ; memcpy ( outpkt . data , buffer , len ) ; receive_packet ( c -> node , & outpkt ) ; } "," { vpn_packet_t outpkt ; if ( len > sizeof outpkt . data ) return ",gsliepen@tinc/17a33dfd95b1a29e90db76414eb9622df9632320,CVE-2013-1428,https://github.com/gsliepen/tinc/commit/17a33dfd95b1a29e90db76414eb9622df9632320,2013-04-26T16:55Z 814,CWE-264,"CWE-264 static __init int hardware_setup ( void ) { int r = - ENOMEM , i , msr ; rdmsrl_safe ( MSR_EFER , & host_efer ) ; for ( i = 0 ; i < ARRAY_SIZE ( vmx_msr_index ) ; ++ i ) kvm_define_shared_msr ( i , vmx_msr_index [ i ] ) ; vmx_io_bitmap_a = ( unsigned long * ) __get_free_page ( GFP_KERNEL ) ; if ( ! vmx_io_bitmap_a ) return r ; vmx_io_bitmap_b = ( unsigned long * ) __get_free_page ( GFP_KERNEL ) ; if ( ! vmx_io_bitmap_b ) goto out ; vmx_msr_bitmap_legacy = ( unsigned long * ) __get_free_page ( GFP_KERNEL ) ; if ( ! vmx_msr_bitmap_legacy ) goto out1 ; vmx_msr_bitmap_legacy_x2apic = ( unsigned long * ) __get_free_page ( GFP_KERNEL ) ; if ( ! vmx_msr_bitmap_legacy_x2apic ) goto out2 ; vmx_msr_bitmap_longmode = ( unsigned long * ) __get_free_page ( GFP_KERNEL ) ; if ( ! vmx_msr_bitmap_longmode ) goto out3 ; vmx_msr_bitmap_longmode_x2apic = ( unsigned long * ) __get_free_page ( GFP_KERNEL ) ; if ( ! vmx_msr_bitmap_longmode_x2apic ) goto out4 ; if ( nested ) { vmx_msr_bitmap_nested = ( unsigned long * ) __get_free_page ( GFP_KERNEL ) ; if ( ! vmx_msr_bitmap_nested ) goto out5 ; } vmx_vmread_bitmap = ( unsigned long * ) __get_free_page ( GFP_KERNEL ) ; if ( ! vmx_vmread_bitmap ) goto out6 ; vmx_vmwrite_bitmap = ( unsigned long * ) __get_free_page ( GFP_KERNEL ) ; if ( ! vmx_vmwrite_bitmap ) goto out7 ; memset ( vmx_vmread_bitmap , 0xff , PAGE_SIZE ) ; memset ( vmx_vmwrite_bitmap , 0xff , PAGE_SIZE ) ; memset ( vmx_io_bitmap_a , 0xff , PAGE_SIZE ) ; clear_bit ( 0x80 , vmx_io_bitmap_a ) ; memset ( vmx_io_bitmap_b , 0xff , PAGE_SIZE ) ; memset ( vmx_msr_bitmap_legacy , 0xff , PAGE_SIZE ) ; memset ( vmx_msr_bitmap_longmode , 0xff , PAGE_SIZE ) ; if ( nested ) memset ( vmx_msr_bitmap_nested , 0xff , PAGE_SIZE ) ; if ( setup_vmcs_config ( & vmcs_config ) < 0 ) { r = - EIO ; goto out8 ; } if ( boot_cpu_has ( X86_FEATURE_NX ) ) kvm_enable_efer_bits ( EFER_NX ) ; if ( ! cpu_has_vmx_vpid ( ) ) enable_vpid = 0 ; if ( ! cpu_has_vmx_shadow_vmcs ( ) ) enable_shadow_vmcs = 0 ; if ( enable_shadow_vmcs ) init_vmcs_shadow_fields ( ) ; if ( ! cpu_has_vmx_ept ( ) || ! cpu_has_vmx_ept_4levels ( ) ) { enable_ept = 0 ; enable_unrestricted_guest = 0 ; enable_ept_ad_bits = 0 ; } if ( ! cpu_has_vmx_ept_ad_bits ( ) ) enable_ept_ad_bits = 0 ; if ( ! cpu_has_vmx_unrestricted_guest ( ) ) enable_unrestricted_guest = 0 ; if ( ! cpu_has_vmx_flexpriority ( ) ) flexpriority_enabled = 0 ; if ( ! flexpriority_enabled ) kvm_x86_ops -> set_apic_access_page_addr = NULL ; if ( ! cpu_has_vmx_tpr_shadow ( ) ) kvm_x86_ops -> update_cr8_intercept = NULL ; if ( enable_ept && ! cpu_has_vmx_ept_2m_page ( ) ) kvm_disable_largepages ( ) ; if ( ! cpu_has_vmx_ple ( ) ) ple_gap = 0 ; if ( ! cpu_has_vmx_apicv ( ) ) enable_apicv = 0 ; if ( cpu_has_vmx_tsc_scaling ( ) ) { kvm_has_tsc_control = true ; kvm_max_tsc_scaling_ratio = KVM_VMX_TSC_MULTIPLIER_MAX ; kvm_tsc_scaling_ratio_frac_bits = 48 ; } vmx_disable_intercept_for_msr ( MSR_FS_BASE , false ) ; vmx_disable_intercept_for_msr ( MSR_GS_BASE , false ) ; vmx_disable_intercept_for_msr ( MSR_KERNEL_GS_BASE , true ) ; vmx_disable_intercept_for_msr ( MSR_IA32_SYSENTER_CS , false ) ; vmx_disable_intercept_for_msr ( MSR_IA32_SYSENTER_ESP , false ) ; vmx_disable_intercept_for_msr ( MSR_IA32_SYSENTER_EIP , false ) ; vmx_disable_intercept_for_msr ( MSR_IA32_BNDCFGS , true ) ; memcpy ( vmx_msr_bitmap_legacy_x2apic , vmx_msr_bitmap_legacy , PAGE_SIZE ) ; memcpy ( vmx_msr_bitmap_longmode_x2apic , vmx_msr_bitmap_longmode , PAGE_SIZE ) ; set_bit ( 0 , vmx_vpid_bitmap ) ; if ( enable_apicv ) { for ( msr = 0x800 ; msr <= 0x8ff ; msr ++ ) vmx_disable_intercept_msr_read_x2apic ( msr ) ; vmx_enable_intercept_msr_read_x2apic ( 0x802 ) ; vmx_enable_intercept_msr_read_x2apic ( 0x839 ) ; vmx_disable_intercept_msr_write_x2apic ( 0x808 ) ; vmx_disable_intercept_msr_write_x2apic ( 0x80b ) ; vmx_disable_intercept_msr_write_x2apic ( 0x83f ) ; } if ( enable_ept ) { kvm_mmu_set_mask_ptes ( 0ull , ( enable_ept_ad_bits ) ? VMX_EPT_ACCESS_BIT : 0ull , ( enable_ept_ad_bits ) ? VMX_EPT_DIRTY_BIT : 0ull , 0ull , VMX_EPT_EXECUTABLE_MASK ) ; ept_set_mmio_spte_mask ( ) ; kvm_enable_tdp ( ) ; } else kvm_disable_tdp ( ) ; update_ple_window_actual_max ( ) ; if ( ! enable_ept || ! enable_ept_ad_bits || ! cpu_has_vmx_pml ( ) ) enable_pml = 0 ; if ( ! enable_pml ) { kvm_x86_ops -> slot_enable_log_dirty = NULL ; kvm_x86_ops -> slot_disable_log_dirty = NULL ; kvm_x86_ops -> flush_log_dirty = NULL ; kvm_x86_ops -> enable_log_dirty_pt_masked = NULL ; } kvm_set_posted_intr_wakeup_handler ( wakeup_handler ) ; return alloc_kvm_area ( ) ; out8 : free_page ( ( unsigned long ) vmx_vmwrite_bitmap ) ; out7 : free_page ( ( unsigned long ) vmx_vmread_bitmap ) ; out6 : if ( nested ) free_page ( ( unsigned long ) vmx_msr_bitmap_nested ) ; out5 : free_page ( ( unsigned long ) vmx_msr_bitmap_longmode_x2apic ) ; out4 : free_page ( ( unsigned long ) vmx_msr_bitmap_longmode ) ; out3 : free_page ( ( unsigned long ) vmx_msr_bitmap_legacy_x2apic ) ; out2 : free_page ( ( unsigned long ) vmx_msr_bitmap_legacy ) ; out1 : free_page ( ( unsigned long ) vmx_io_bitmap_b ) ; out : free_page ( ( unsigned long ) vmx_io_bitmap_a ) ; return r ; } "," vmx_vpid_bitmap ) ; for ( msr 0x83f ) ; if ( enable_ept ",torvalds@linux/3ce424e45411cf5a13105e0386b6ecf6eeb4f66f,CVE-2016-4440,https://github.com/torvalds/linux/commit/3ce424e45411cf5a13105e0386b6ecf6eeb4f66f,2016-06-27T10:59Z 815,CWE-476,"CWE-476 static Sdb * store_versioninfo_gnu_verdef ( ELFOBJ * bin , Elf_ ( Shdr ) * shdr , int sz ) { const char * section_name = """" ; const char * link_section_name = """" ; char * end = NULL ; Elf_ ( Shdr ) * link_shdr = NULL ; ut8 dfs [ sizeof ( Elf_ ( Verdef ) ) ] = { 0 } ; Sdb * sdb ; int cnt , i ; if ( shdr -> sh_link > bin -> ehdr . e_shnum ) { return false ; } link_shdr = & bin -> shdr [ shdr -> sh_link ] ; if ( shdr -> sh_size < 1 || shdr -> sh_size > SIZE_MAX ) { return false ; } Elf_ ( Verdef ) * defs = calloc ( shdr -> sh_size , sizeof ( char ) ) ; if ( ! defs ) { return false ; } if ( bin -> shstrtab && shdr -> sh_name < bin -> shstrtab_size ) { section_name = & bin -> shstrtab [ shdr -> sh_name ] ; } if ( link_shdr && bin -> shstrtab && link_shdr -> sh_name < bin -> shstrtab_size ) { link_section_name = & bin -> shstrtab [ link_shdr -> sh_name ] ; } if ( ! defs ) { bprintf ( ""Warning:Cannotallocatememory(CheckElf_(Verdef))\\n"" ) ; return NULL ; } sdb = sdb_new0 ( ) ; end = ( char * ) defs + shdr -> sh_size ; sdb_set ( sdb , ""section_name"" , section_name , 0 ) ; sdb_num_set ( sdb , ""entries"" , shdr -> sh_info , 0 ) ; sdb_num_set ( sdb , ""addr"" , shdr -> sh_addr , 0 ) ; sdb_num_set ( sdb , ""offset"" , shdr -> sh_offset , 0 ) ; sdb_num_set ( sdb , ""link"" , shdr -> sh_link , 0 ) ; sdb_set ( sdb , ""link_section_name"" , link_section_name , 0 ) ; for ( cnt = 0 , i = 0 ; i >= 0 && cnt < shdr -> sh_info && ( ( char * ) defs + i < end ) ; ++ cnt ) { Sdb * sdb_verdef = sdb_new0 ( ) ; char * vstart = ( ( char * ) defs ) + i ; char key [ 32 ] = { 0 } ; Elf_ ( Verdef ) * verdef = ( Elf_ ( Verdef ) * ) vstart ; Elf_ ( Verdaux ) aux = { 0 } ; int j = 0 ; int isum = 0 ; r_buf_read_at ( bin -> b , shdr -> sh_offset + i , dfs , sizeof ( Elf_ ( Verdef ) ) ) ; verdef -> vd_version = READ16 ( dfs , j ) verdef -> vd_flags = READ16 ( dfs , j ) verdef -> vd_ndx = READ16 ( dfs , j ) verdef -> vd_cnt = READ16 ( dfs , j ) verdef -> vd_hash = READ32 ( dfs , j ) verdef -> vd_aux = READ32 ( dfs , j ) verdef -> vd_next = READ32 ( dfs , j ) int vdaux = verdef -> vd_aux ; if ( vdaux < 1 ) { sdb_free ( sdb_verdef ) ; goto out_error ; } vstart += vdaux ; if ( vstart > end || vstart + sizeof ( Elf_ ( Verdaux ) ) > end ) { sdb_free ( sdb_verdef ) ; goto out_error ; } j = 0 ; aux . vda_name = READ32 ( vstart , j ) aux . vda_next = READ32 ( vstart , j ) isum = i + verdef -> vd_aux ; if ( aux . vda_name > bin -> dynstr_size ) { sdb_free ( sdb_verdef ) ; goto out_error ; } sdb_num_set ( sdb_verdef , ""idx"" , i , 0 ) ; sdb_num_set ( sdb_verdef , ""vd_version"" , verdef -> vd_version , 0 ) ; sdb_num_set ( sdb_verdef , ""vd_ndx"" , verdef -> vd_ndx , 0 ) ; sdb_num_set ( sdb_verdef , ""vd_cnt"" , verdef -> vd_cnt , 0 ) ; sdb_set ( sdb_verdef , ""vda_name"" , & bin -> dynstr [ aux . vda_name ] , 0 ) ; sdb_set ( sdb_verdef , ""flags"" , get_ver_flags ( verdef -> vd_flags ) , 0 ) ; for ( j = 1 ; j < verdef -> vd_cnt ; ++ j ) { int k ; Sdb * sdb_parent = sdb_new0 ( ) ; isum += aux . vda_next ; vstart += aux . vda_next ; if ( vstart > end || vstart + sizeof ( Elf_ ( Verdaux ) ) > end ) { sdb_free ( sdb_verdef ) ; sdb_free ( sdb_parent ) ; goto out_error ; } k = 0 ; aux . vda_name = READ32 ( vstart , k ) aux . vda_next = READ32 ( vstart , k ) if ( aux . vda_name > bin -> dynstr_size ) { sdb_free ( sdb_verdef ) ; sdb_free ( sdb_parent ) ; goto out_error ; } sdb_num_set ( sdb_parent , ""idx"" , isum , 0 ) ; sdb_num_set ( sdb_parent , ""parent"" , j , 0 ) ; sdb_set ( sdb_parent , ""vda_name"" , & bin -> dynstr [ aux . vda_name ] , 0 ) ; snprintf ( key , sizeof ( key ) , ""parent%d"" , j - 1 ) ; sdb_ns_set ( sdb_verdef , key , sdb_parent ) ; } snprintf ( key , sizeof ( key ) , ""verdef%d"" , cnt ) ; sdb_ns_set ( sdb , key , sdb_verdef ) ; if ( ! verdef -> vd_next ) { sdb_free ( sdb_verdef ) ; goto out_error ; } if ( ( st32 ) verdef -> vd_next < 1 ) { eprintf ( ""Warning:Invalidvd_nextintheELFversion\\n"" ) ; break ; } i += verdef -> vd_next ; } free ( defs ) ; return sdb ; out_error : free ( defs ) ; sdb_free ( sdb ) ; return NULL ; } "," sh_info && ( end - * ) defs > i ) ; ++ vdaux < 1 || ( char * ) UINTPTR_MAX - vstart < vdaux > end || end - vstart < sizeof ( Elf_ Verdaux ) ) ) { sdb_free > end || end - vstart < sizeof ( Elf_ Verdaux ) ) ) { sdb_free ",radare@radare2/62e39f34b2705131a2d08aff0c2e542c6a52cf0e,CVE-2017-16359,https://github.com/radare/radare2/commit/62e39f34b2705131a2d08aff0c2e542c6a52cf0e,2017-11-01T17:29Z 816,CWE-284,"CWE-284 void close_uinput ( void ) { BTIF_TRACE_DEBUG ( ""%s"" , __FUNCTION__ ) ; if ( uinput_fd > 0 ) { ioctl ( uinput_fd , UI_DEV_DESTROY ) ; close ( uinput_fd ) ; uinput_fd = - 1 ; } } "," 0 ) { TEMP_FAILURE_RETRY ( uinput_fd , UI_DEV_DESTROY ) ",system@bt/472271b153c5dc53c28beac55480a8d8434b2d5c,CVE-2016-3839,https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c,2016-08-05T20:59Z 817,CWE-119,"CWE-119 static int calc_pframe_target_size_one_pass_vbr ( const VP9_COMP * const cpi ) { static const int af_ratio = 10 ; const RATE_CONTROL * const rc = & cpi -> rc ; int target ; # if USE_ALTREF_FOR_ONE_PASS target = ( ! rc -> is_src_frame_alt_ref && ( cpi -> refresh_golden_frame || cpi -> refresh_alt_ref_frame ) ) ? ( rc -> av_per_frame_bandwidth * rc -> baseline_gf_interval * af_ratio ) / ( rc -> baseline_gf_interval + af_ratio - 1 ) : ( rc -> av_per_frame_bandwidth * rc -> baseline_gf_interval ) / ( rc -> baseline_gf_interval + af_ratio - 1 ) ; # else target = rc -> av_per_frame_bandwidth ; # endif return vp9_rc_clamp_pframe_target_size ( cpi , target ) ; } "," ( rc -> avg_frame_bandwidth * rc -> ( rc -> avg_frame_bandwidth * rc -> = rc -> avg_frame_bandwidth ; # endif ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 818,CWE-668,"CWE-668 int main ( int argc , const char * argv [ ] ) { struct group * grent ; const char * cmd ; const char * path ; int i ; struct passwd * pw ; grent = getgrnam ( ABUILD_GROUP ) ; if ( grent == NULL ) errx ( 1 , ""%s:Groupnotfound"" , ABUILD_GROUP ) ; char * name = NULL ; pw = getpwuid ( getuid ( ) ) ; if ( pw ) name = pw -> pw_name ; if ( ! is_in_group ( grent -> gr_gid ) ) { errx ( 1 , ""User%sisnotamemberofgroup%s\\n"" , name ? name : ""(unknown)"" , ABUILD_GROUP ) ; } if ( name == NULL ) warnx ( ""Couldnotfindusernameforuid%d\\n"" , getuid ( ) ) ; setenv ( ""USER"" , name ? : """" , 1 ) ; cmd = strrchr ( argv [ 0 ] , '/' ) ; if ( cmd ) cmd ++ ; else cmd = argv [ 0 ] ; cmd = strchr ( cmd , '-' ) ; if ( cmd == NULL ) errx ( 1 , ""Callingcommandhasno\'-\'"" ) ; cmd ++ ; path = get_command_path ( cmd ) ; if ( path == NULL ) errx ( 1 , ""%s:Notavalidsubcommand"" , cmd ) ; for ( i = 1 ; i < argc ; i ++ ) if ( strcmp ( argv [ i ] , ""--allow-untrusted"" ) == 0 ) errx ( 1 , ""%s:notallowedoption"" , ""--allow-untrusted"" ) ; argv [ 0 ] = path ; setuid ( 0 ) ; setgid ( 0 ) ; execv ( path , ( char * const * ) argv ) ; perror ( path ) ; return 1 ; } "," i ++ ) check_option ( argv [ i ] ) ; argv ",sroracle@abuild/4f90ce92778d0ee302e288def75591b96a397c8b,CVE-2019-12875,https://github.com/sroracle/abuild/commit/4f90ce92778d0ee302e288def75591b96a397c8b,2019-06-18T19:15Z 819,CWE-125,"CWE-125 PyObject * ast2obj_mod ( void * _o ) { mod_ty o = ( mod_ty ) _o ; PyObject * result = NULL , * value = NULL ; if ( ! o ) { Py_INCREF ( Py_None ) ; return Py_None ; } switch ( o -> kind ) { case Module_kind : result = PyType_GenericNew ( Module_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_list ( o -> v . Module . body , ast2obj_stmt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_body , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . Module . type_ignores , ast2obj_type_ignore ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_type_ignores , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Interactive_kind : result = PyType_GenericNew ( Interactive_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_list ( o -> v . Interactive . body , ast2obj_stmt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_body , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Expression_kind : result = PyType_GenericNew ( Expression_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . Expression . body ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_body , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case FunctionType_kind : result = PyType_GenericNew ( FunctionType_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_list ( o -> v . FunctionType . argtypes , ast2obj_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_argtypes , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . FunctionType . returns ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_returns , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Suite_kind : result = PyType_GenericNew ( Suite_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_list ( o -> v . Suite . body , ast2obj_stmt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_body , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; } return result ; failed : Py_XDECREF ( value ) ; Py_XDECREF ( result ) ; return NULL ; } "," o ) { Py_RETURN_NONE ; } switch ",python@typed_ast/156afcb26c198e162504a57caddfe0acd9ed7dce,CVE-2019-19275,https://github.com/python/typed_ast/commit/156afcb26c198e162504a57caddfe0acd9ed7dce,2019-11-26T15:15Z 820,CWE-835,"CWE-835 static void feed_table_block_tag ( struct table * tbl , char * line , struct table_mode * mode , int indent , int cmd ) { int offset ; if ( mode -> indent_level <= 0 && indent == - 1 ) return ; if ( mode -> indent_level >= CHAR_MAX && indent == 1 ) return ; setwidth ( tbl , mode ) ; feed_table_inline_tag ( tbl , line , mode , - 1 ) ; clearcontentssize ( tbl , mode ) ; if ( indent == 1 ) { mode -> indent_level ++ ; if ( mode -> indent_level <= MAX_INDENT_LEVEL ) tbl -> indent += INDENT_INCR ; } else if ( indent == - 1 ) { mode -> indent_level -- ; if ( mode -> indent_level < MAX_INDENT_LEVEL ) tbl -> indent -= INDENT_INCR ; } offset = tbl -> indent ; if ( cmd == HTML_DT ) { if ( mode -> indent_level > 0 && mode -> indent_level <= MAX_INDENT_LEVEL ) offset -= INDENT_INCR ; } if ( tbl -> indent > 0 ) { check_minimum0 ( tbl , 0 ) ; addcontentssize ( tbl , offset ) ; } } "," INDENT_INCR ; } if ( tbl -> indent < 0 ) tbl -> indent = 0 ; -= INDENT_INCR ; if ( offset < 0 ) offset = 0 ; ",tats@w3m/8354763b90490d4105695df52674d0fcef823e92,CVE-2018-6196,https://github.com/tats/w3m/commit/8354763b90490d4105695df52674d0fcef823e92,2018-01-25T03:29Z 821,CWE-189,"CWE-189 static int cdf_check_stream_offset ( const cdf_stream_t * sst , const cdf_header_t * h , const void * p , size_t tail , int line ) { const char * b = ( const char * ) sst -> sst_tab ; const char * e = ( ( const char * ) p ) + tail ; ( void ) & line ; if ( e >= b && ( size_t ) ( e - b ) <= CDF_SEC_SIZE ( h ) * sst -> sst_len ) return 0 ; DPRINTF ( ( ""%d:offsetbegin%p<end%p||%"" SIZE_T_FORMAT ""u"" "">%"" SIZE_T_FORMAT ""u[%"" SIZE_T_FORMAT ""u%"" SIZE_T_FORMAT ""u]\\n"" , line , b , e , ( size_t ) ( e - b ) , CDF_SEC_SIZE ( h ) * sst -> sst_len , CDF_SEC_SIZE ( h ) , sst -> sst_len ) ) ; errno = EFTYPE ; return - 1 ; } "," + tail ; size_t ss = sst -> sst_dirlen < h -> h_min_size_standard_stream ? CDF_SHORT_SEC_SIZE ( h ) : CDF_SEC_SIZE ( h ) ; b ) <= ss * sst -> b ) , ss * sst -> -> sst_len , ss , sst -> ",file@file/36fadd29849b8087af9f4586f89dbf74ea45be67,CVE-2014-3479,https://github.com/file/file/commit/36fadd29849b8087af9f4586f89dbf74ea45be67,2014-07-09T11:07Z 822,CWE-674,"CWE-674 int yyparse ( void * yyscanner , HEX_LEX_ENVIRONMENT * lex_env ) { int yychar ; YY_INITIAL_VALUE ( static YYSTYPE yyval_default ; ) YYSTYPE yylval YY_INITIAL_VALUE ( = yyval_default ) ; int yynerrs ; int yystate ; int yyerrstatus ; yytype_int16 yyssa [ YYINITDEPTH ] ; yytype_int16 * yyss ; yytype_int16 * yyssp ; YYSTYPE yyvsa [ YYINITDEPTH ] ; YYSTYPE * yyvs ; YYSTYPE * yyvsp ; YYSIZE_T yystacksize ; int yyn ; int yyresult ; int yytoken = 0 ; YYSTYPE yyval ; # if YYERROR_VERBOSE char yymsgbuf [ 128 ] ; char * yymsg = yymsgbuf ; YYSIZE_T yymsg_alloc = sizeof yymsgbuf ; # endif # define YYPOPSTACK ( N ) ( yyvsp -= ( N ) , yyssp -= ( N ) ) int yylen = 0 ; yyssp = yyss = yyssa ; yyvsp = yyvs = yyvsa ; yystacksize = YYINITDEPTH ; YYDPRINTF ( ( stderr , ""Startingparse\\n"" ) ) ; yystate = 0 ; yyerrstatus = 0 ; yynerrs = 0 ; yychar = YYEMPTY ; goto yysetstate ; yynewstate : yyssp ++ ; yysetstate : * yyssp = yystate ; if ( yyss + yystacksize - 1 <= yyssp ) { YYSIZE_T yysize = yyssp - yyss + 1 ; # ifdef yyoverflow { YYSTYPE * yyvs1 = yyvs ; yytype_int16 * yyss1 = yyss ; yyoverflow ( YY_ ( ""memoryexhausted"" ) , & yyss1 , yysize * sizeof ( * yyssp ) , & yyvs1 , yysize * sizeof ( * yyvsp ) , & yystacksize ) ; yyss = yyss1 ; yyvs = yyvs1 ; } # else # ifndef YYSTACK_RELOCATE goto yyexhaustedlab ; # else if ( YYMAXDEPTH <= yystacksize ) goto yyexhaustedlab ; yystacksize *= 2 ; if ( YYMAXDEPTH < yystacksize ) yystacksize = YYMAXDEPTH ; { yytype_int16 * yyss1 = yyss ; union yyalloc * yyptr = ( union yyalloc * ) YYSTACK_ALLOC ( YYSTACK_BYTES ( yystacksize ) ) ; if ( ! yyptr ) goto yyexhaustedlab ; YYSTACK_RELOCATE ( yyss_alloc , yyss ) ; YYSTACK_RELOCATE ( yyvs_alloc , yyvs ) ; # undef YYSTACK_RELOCATE if ( yyss1 != yyssa ) YYSTACK_FREE ( yyss1 ) ; } # endif # endif yyssp = yyss + yysize - 1 ; yyvsp = yyvs + yysize - 1 ; YYDPRINTF ( ( stderr , ""Stacksizeincreasedto%lu\\n"" , ( unsigned long int ) yystacksize ) ) ; if ( yyss + yystacksize - 1 <= yyssp ) YYABORT ; } YYDPRINTF ( ( stderr , ""Enteringstate%d\\n"" , yystate ) ) ; if ( yystate == YYFINAL ) YYACCEPT ; goto yybackup ; yybackup : yyn = yypact [ yystate ] ; if ( yypact_value_is_default ( yyn ) ) goto yydefault ; if ( yychar == YYEMPTY ) { YYDPRINTF ( ( stderr , ""Readingatoken:"" ) ) ; yychar = yylex ( & yylval , yyscanner , lex_env ) ; } if ( yychar <= YYEOF ) { yychar = yytoken = YYEOF ; YYDPRINTF ( ( stderr , ""Nowatendofinput.\\n"" ) ) ; } else { yytoken = YYTRANSLATE ( yychar ) ; YY_SYMBOL_PRINT ( ""Nexttokenis"" , yytoken , & yylval , & yylloc ) ; } yyn += yytoken ; if ( yyn < 0 || YYLAST < yyn || yycheck [ yyn ] != yytoken ) goto yydefault ; yyn = yytable [ yyn ] ; if ( yyn <= 0 ) { if ( yytable_value_is_error ( yyn ) ) goto yyerrlab ; yyn = - yyn ; goto yyreduce ; } if ( yyerrstatus ) yyerrstatus -- ; YY_SYMBOL_PRINT ( ""Shifting"" , yytoken , & yylval , & yylloc ) ; yychar = YYEMPTY ; yystate = yyn ; YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN * ++ yyvsp = yylval ; YY_IGNORE_MAYBE_UNINITIALIZED_END goto yynewstate ; yydefault : yyn = yydefact [ yystate ] ; if ( yyn == 0 ) goto yyerrlab ; goto yyreduce ; yyreduce : yylen = yyr2 [ yyn ] ; yyval = yyvsp [ 1 - yylen ] ; YY_REDUCE_PRINT ( yyn ) ; switch ( yyn ) { case 2 : # line 106 ""hex_grammar.y"" { RE_AST * re_ast = yyget_extra ( yyscanner ) ; re_ast -> root_node = ( yyvsp [ - 1 ] . re_node ) ; } # line 1330 ""hex_grammar.c"" break ; case 3 : # line 115 ""hex_grammar.y"" { ( yyval . re_node ) = ( yyvsp [ 0 ] . re_node ) ; } # line 1338 ""hex_grammar.c"" break ; case 4 : # line 119 ""hex_grammar.y"" { ( yyval . re_node ) = yr_re_node_create ( RE_NODE_CONCAT , ( yyvsp [ - 1 ] . re_node ) , ( yyvsp [ 0 ] . re_node ) ) ; DESTROY_NODE_IF ( ( yyval . re_node ) == NULL , ( yyvsp [ - 1 ] . re_node ) ) ; DESTROY_NODE_IF ( ( yyval . re_node ) == NULL , ( yyvsp [ 0 ] . re_node ) ) ; ERROR_IF ( ( yyval . re_node ) == NULL , ERROR_INSUFFICIENT_MEMORY ) ; } # line 1351 ""hex_grammar.c"" break ; case 5 : # line 128 ""hex_grammar.y"" { RE_NODE * new_concat ; RE_NODE * leftmost_concat = NULL ; RE_NODE * leftmost_node = ( yyvsp [ - 1 ] . re_node ) ; ( yyval . re_node ) = NULL ; while ( leftmost_node -> type == RE_NODE_CONCAT ) { leftmost_concat = leftmost_node ; leftmost_node = leftmost_node -> left ; } new_concat = yr_re_node_create ( RE_NODE_CONCAT , ( yyvsp [ - 2 ] . re_node ) , leftmost_node ) ; if ( new_concat != NULL ) { if ( leftmost_concat != NULL ) { leftmost_concat -> left = new_concat ; ( yyval . re_node ) = yr_re_node_create ( RE_NODE_CONCAT , ( yyvsp [ - 1 ] . re_node ) , ( yyvsp [ 0 ] . re_node ) ) ; } else { ( yyval . re_node ) = yr_re_node_create ( RE_NODE_CONCAT , new_concat , ( yyvsp [ 0 ] . re_node ) ) ; } } DESTROY_NODE_IF ( ( yyval . re_node ) == NULL , ( yyvsp [ - 2 ] . re_node ) ) ; DESTROY_NODE_IF ( ( yyval . re_node ) == NULL , ( yyvsp [ - 1 ] . re_node ) ) ; DESTROY_NODE_IF ( ( yyval . re_node ) == NULL , ( yyvsp [ 0 ] . re_node ) ) ; ERROR_IF ( ( yyval . re_node ) == NULL , ERROR_INSUFFICIENT_MEMORY ) ; } # line 1413 ""hex_grammar.c"" break ; case 6 : # line 190 ""hex_grammar.y"" { ( yyval . re_node ) = ( yyvsp [ 0 ] . re_node ) ; } # line 1421 ""hex_grammar.c"" break ; case 7 : # line 194 ""hex_grammar.y"" { ( yyval . re_node ) = yr_re_node_create ( RE_NODE_CONCAT , ( yyvsp [ - 1 ] . re_node ) , ( yyvsp [ 0 ] . re_node ) ) ; DESTROY_NODE_IF ( ( yyval . re_node ) == NULL , ( yyvsp [ - 1 ] . re_node ) ) ; DESTROY_NODE_IF ( ( yyval . re_node ) == NULL , ( yyvsp [ 0 ] . re_node ) ) ; ERROR_IF ( ( yyval . re_node ) == NULL , ERROR_INSUFFICIENT_MEMORY ) ; } # line 1434 ""hex_grammar.c"" break ; case 8 : # line 207 ""hex_grammar.y"" { ( yyval . re_node ) = ( yyvsp [ 0 ] . re_node ) ; } # line 1442 ""hex_grammar.c"" break ; case 9 : # line 211 ""hex_grammar.y"" { ( yyval . re_node ) = ( yyvsp [ 0 ] . re_node ) ; ( yyval . re_node ) -> greedy = FALSE ; } # line 1451 ""hex_grammar.c"" break ; case 10 : # line 220 ""hex_grammar.y"" { lex_env -> token_count ++ ; if ( lex_env -> token_count > MAX_HEX_STRING_TOKENS ) { yr_re_node_destroy ( ( yyvsp [ 0 ] . re_node ) ) ; yyerror ( yyscanner , lex_env , ""stringtoolong"" ) ; YYABORT ; } ( yyval . re_node ) = ( yyvsp [ 0 ] . re_node ) ; } # line 1468 ""hex_grammar.c"" break ; case 11 : # line 233 ""hex_grammar.y"" { lex_env -> inside_or ++ ; } # line 1476 ""hex_grammar.c"" break ; case 12 : # line 237 ""hex_grammar.y"" { ( yyval . re_node ) = ( yyvsp [ - 1 ] . re_node ) ; lex_env -> inside_or -- ; } # line 1485 ""hex_grammar.c"" break ; case 13 : # line 246 ""hex_grammar.y"" { if ( ( yyvsp [ - 1 ] . integer ) <= 0 ) { yyerror ( yyscanner , lex_env , ""invalidjumplength"" ) ; YYABORT ; } if ( lex_env -> inside_or && ( yyvsp [ - 1 ] . integer ) > STRING_CHAINING_THRESHOLD ) { yyerror ( yyscanner , lex_env , ""jumpsover"" STR ( STRING_CHAINING_THRESHOLD ) ""nowallowedinsidealternation(|)"" ) ; YYABORT ; } ( yyval . re_node ) = yr_re_node_create ( RE_NODE_RANGE_ANY , NULL , NULL ) ; ERROR_IF ( ( yyval . re_node ) == NULL , ERROR_INSUFFICIENT_MEMORY ) ; ( yyval . re_node ) -> start = ( int ) ( yyvsp [ - 1 ] . integer ) ; ( yyval . re_node ) -> end = ( int ) ( yyvsp [ - 1 ] . integer ) ; } # line 1512 ""hex_grammar.c"" break ; case 14 : # line 269 ""hex_grammar.y"" { if ( lex_env -> inside_or && ( ( yyvsp [ - 3 ] . integer ) > STRING_CHAINING_THRESHOLD || ( yyvsp [ - 1 ] . integer ) > STRING_CHAINING_THRESHOLD ) ) { yyerror ( yyscanner , lex_env , ""jumpsover"" STR ( STRING_CHAINING_THRESHOLD ) ""nowallowedinsidealternation(|)"" ) ; YYABORT ; } if ( ( yyvsp [ - 3 ] . integer ) < 0 || ( yyvsp [ - 1 ] . integer ) < 0 ) { yyerror ( yyscanner , lex_env , ""invalidnegativejumplength"" ) ; YYABORT ; } if ( ( yyvsp [ - 3 ] . integer ) > ( yyvsp [ - 1 ] . integer ) ) { yyerror ( yyscanner , lex_env , ""invalidjumprange"" ) ; YYABORT ; } ( yyval . re_node ) = yr_re_node_create ( RE_NODE_RANGE_ANY , NULL , NULL ) ; ERROR_IF ( ( yyval . re_node ) == NULL , ERROR_INSUFFICIENT_MEMORY ) ; ( yyval . re_node ) -> start = ( int ) ( yyvsp [ - 3 ] . integer ) ; ( yyval . re_node ) -> end = ( int ) ( yyvsp [ - 1 ] . integer ) ; } # line 1548 ""hex_grammar.c"" break ; case 15 : # line 301 ""hex_grammar.y"" { if ( lex_env -> inside_or ) { yyerror ( yyscanner , lex_env , ""unboundedjumpsnotallowedinsidealternation(|)"" ) ; YYABORT ; } if ( ( yyvsp [ - 2 ] . integer ) < 0 ) { yyerror ( yyscanner , lex_env , ""invalidnegativejumplength"" ) ; YYABORT ; } ( yyval . re_node ) = yr_re_node_create ( RE_NODE_RANGE_ANY , NULL , NULL ) ; ERROR_IF ( ( yyval . re_node ) == NULL , ERROR_INSUFFICIENT_MEMORY ) ; ( yyval . re_node ) -> start = ( int ) ( yyvsp [ - 2 ] . integer ) ; ( yyval . re_node ) -> end = INT_MAX ; } # line 1574 ""hex_grammar.c"" break ; case 16 : # line 323 ""hex_grammar.y"" { if ( lex_env -> inside_or ) { yyerror ( yyscanner , lex_env , ""unboundedjumpsnotallowedinsidealternation(|)"" ) ; YYABORT ; } ( yyval . re_node ) = yr_re_node_create ( RE_NODE_RANGE_ANY , NULL , NULL ) ; ERROR_IF ( ( yyval . re_node ) == NULL , ERROR_INSUFFICIENT_MEMORY ) ; ( yyval . re_node ) -> start = 0 ; ( yyval . re_node ) -> end = INT_MAX ; } # line 1594 ""hex_grammar.c"" break ; case 17 : # line 343 ""hex_grammar.y"" { ( yyval . re_node ) = ( yyvsp [ 0 ] . re_node ) ; } # line 1602 ""hex_grammar.c"" break ; case 18 : # line 347 ""hex_grammar.y"" { mark_as_not_fast_regexp ( ) ; ( yyval . re_node ) = yr_re_node_create ( RE_NODE_ALT , ( yyvsp [ - 2 ] . re_node ) , ( yyvsp [ 0 ] . re_node ) ) ; DESTROY_NODE_IF ( ( yyval . re_node ) == NULL , ( yyvsp [ - 2 ] . re_node ) ) ; DESTROY_NODE_IF ( ( yyval . re_node ) == NULL , ( yyvsp [ 0 ] . re_node ) ) ; ERROR_IF ( ( yyval . re_node ) == NULL , ERROR_INSUFFICIENT_MEMORY ) ; } # line 1617 ""hex_grammar.c"" break ; case 19 : # line 361 ""hex_grammar.y"" { ( yyval . re_node ) = yr_re_node_create ( RE_NODE_LITERAL , NULL , NULL ) ; ERROR_IF ( ( yyval . re_node ) == NULL , ERROR_INSUFFICIENT_MEMORY ) ; ( yyval . re_node ) -> value = ( int ) ( yyvsp [ 0 ] . integer ) ; } # line 1629 ""hex_grammar.c"" break ; case 20 : # line 369 ""hex_grammar.y"" { uint8_t mask = ( uint8_t ) ( ( yyvsp [ 0 ] . integer ) >> 8 ) ; if ( mask == 0x00 ) { ( yyval . re_node ) = yr_re_node_create ( RE_NODE_ANY , NULL , NULL ) ; ERROR_IF ( ( yyval . re_node ) == NULL , ERROR_INSUFFICIENT_MEMORY ) ; } else { ( yyval . re_node ) = yr_re_node_create ( RE_NODE_MASKED_LITERAL , NULL , NULL ) ; ERROR_IF ( ( yyval . re_node ) == NULL , ERROR_INSUFFICIENT_MEMORY ) ; ( yyval . re_node ) -> value = ( yyvsp [ 0 ] . integer ) & 0xFF ; ( yyval . re_node ) -> mask = mask ; } } # line 1653 ""hex_grammar.c"" break ; # line 1657 ""hex_grammar.c"" default : break ; } YY_SYMBOL_PRINT ( ""->$$="" , yyr1 [ yyn ] , & yyval , & yyloc ) ; YYPOPSTACK ( yylen ) ; yylen = 0 ; YY_STACK_PRINT ( yyss , yyssp ) ; * ++ yyvsp = yyval ; yyn = yyr1 [ yyn ] ; yystate = yypgoto [ yyn - YYNTOKENS ] + * yyssp ; if ( 0 <= yystate && yystate <= YYLAST && yycheck [ yystate ] == * yyssp ) yystate = yytable [ yystate ] ; else yystate = yydefgoto [ yyn - YYNTOKENS ] ; goto yynewstate ; yyerrlab : yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE ( yychar ) ; if ( ! yyerrstatus ) { ++ yynerrs ; # if ! YYERROR_VERBOSE yyerror ( yyscanner , lex_env , YY_ ( ""syntaxerror"" ) ) ; # else # define YYSYNTAX_ERROR yysyntax_error ( & yymsg_alloc , & yymsg , yyssp , yytoken ) { char const * yymsgp = YY_ ( ""syntaxerror"" ) ; int yysyntax_error_status ; yysyntax_error_status = YYSYNTAX_ERROR ; if ( yysyntax_error_status == 0 ) yymsgp = yymsg ; else if ( yysyntax_error_status == 1 ) { if ( yymsg != yymsgbuf ) YYSTACK_FREE ( yymsg ) ; yymsg = ( char * ) YYSTACK_ALLOC ( yymsg_alloc ) ; if ( ! yymsg ) { yymsg = yymsgbuf ; yymsg_alloc = sizeof yymsgbuf ; yysyntax_error_status = 2 ; } else { yysyntax_error_status = YYSYNTAX_ERROR ; yymsgp = yymsg ; } } yyerror ( yyscanner , lex_env , yymsgp ) ; if ( yysyntax_error_status == 2 ) goto yyexhaustedlab ; } # undef YYSYNTAX_ERROR # endif } if ( yyerrstatus == 3 ) { if ( yychar <= YYEOF ) { if ( yychar == YYEOF ) YYABORT ; } else { yydestruct ( ""Error:discarding"" , yytoken , & yylval , yyscanner , lex_env ) ; yychar = YYEMPTY ; } } goto yyerrlab1 ; yyerrorlab : if ( 0 ) goto yyerrorlab ; YYPOPSTACK ( yylen ) ; yylen = 0 ; YY_STACK_PRINT ( yyss , yyssp ) ; yystate = * yyssp ; goto yyerrlab1 ; yyerrlab1 : yyerrstatus = 3 ; for ( ; ; ) { yyn = yypact [ yystate ] ; if ( ! yypact_value_is_default ( yyn ) ) { yyn += YYTERROR ; if ( 0 <= yyn && yyn <= YYLAST && yycheck [ yyn ] == YYTERROR ) { yyn = yytable [ yyn ] ; if ( 0 < yyn ) break ; } } if ( yyssp == yyss ) YYABORT ; yydestruct ( ""Error:popping"" , yystos [ yystate ] , yyvsp , yyscanner , lex_env ) ; YYPOPSTACK ( 1 ) ; yystate = * yyssp ; YY_STACK_PRINT ( yyss , yyssp ) ; } YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN * ++ yyvsp = yylval ; YY_IGNORE_MAYBE_UNINITIALIZED_END YY_SYMBOL_PRINT ( ""Shifting"" , yystos [ yyn ] , yyvsp , yylsp ) ; yystate = yyn ; goto yynewstate ; yyacceptlab : yyresult = 0 ; goto yyreturn ; yyabortlab : yyresult = 1 ; goto yyreturn ; # if ! defined yyoverflow || YYERROR_VERBOSE yyexhaustedlab : yyerror ( yyscanner , lex_env , YY_ ( ""memoryexhausted"" ) ) ; yyresult = 2 ; # endif yyreturn : if ( yychar != YYEMPTY ) { yytoken = YYTRANSLATE ( yychar ) ; yydestruct ( ""Cleanup:discardinglookahead"" , yytoken , & yylval , yyscanner , lex_env ) ; } YYPOPSTACK ( yylen ) ; YY_STACK_PRINT ( yyss , yyssp ) ; while ( yyssp != yyss ) { yydestruct ( ""Cleanup:popping"" , yystos [ * yyssp ] , yyvsp , yyscanner , lex_env ) ; YYPOPSTACK ( 1 ) ; } # ifndef yyoverflow if ( yyss != yyssa ) YYSTACK_FREE ( yyss ) ; # endif # if YYERROR_VERBOSE if ( yymsg != yymsgbuf ) YYSTACK_FREE ( yymsg ) ; # endif return yyresult ; } "," : # line 113 ""hex_grammar.y"" { RE_AST } # line 1337 ""hex_grammar.c"" break ; : # line 122 ""hex_grammar.y"" { ( } # line 1345 ""hex_grammar.c"" break ; : # line 126 ""hex_grammar.y"" { incr_ast_levels ( ) ; ( yyval . } # line 1360 ""hex_grammar.c"" break ; : # line 137 ""hex_grammar.y"" { RE_NODE ] . re_node ) ; incr_ast_levels ( } # line 1424 ""hex_grammar.c"" break ; : # line 201 ""hex_grammar.y"" { ( } # line 1432 ""hex_grammar.c"" break ; : # line 205 ""hex_grammar.y"" { incr_ast_levels ( ) ; ( yyval . } # line 1447 ""hex_grammar.c"" break ; : # line 220 ""hex_grammar.y"" { ( } # line 1455 ""hex_grammar.c"" break ; : # line 224 ""hex_grammar.y"" { ( } # line 1464 ""hex_grammar.c"" break ; : # line 233 ""hex_grammar.y"" { lex_env } # line 1481 ""hex_grammar.c"" break ; : # line 246 ""hex_grammar.y"" { lex_env } # line 1489 ""hex_grammar.c"" break ; : # line 250 ""hex_grammar.y"" { ( } # line 1498 ""hex_grammar.c"" break ; : # line 259 ""hex_grammar.y"" { if } # line 1525 ""hex_grammar.c"" break ; : # line 282 ""hex_grammar.y"" { if } # line 1561 ""hex_grammar.c"" break ; : # line 314 ""hex_grammar.y"" { if } # line 1587 ""hex_grammar.c"" break ; : # line 336 ""hex_grammar.y"" { if } # line 1607 ""hex_grammar.c"" break ; : # line 356 ""hex_grammar.y"" { ( } # line 1615 ""hex_grammar.c"" break ; : # line 360 ""hex_grammar.y"" { mark_as_not_fast_regexp ( ) ; incr_ast_levels ( ) ; } # line 1631 ""hex_grammar.c"" break ; : # line 375 ""hex_grammar.y"" { ( } # line 1643 ""hex_grammar.c"" break ; : # line 383 ""hex_grammar.y"" { uint8_t } # line 1667 ""hex_grammar.c"" break ; ; # line 1671 ""hex_grammar.c"" default : ",VirusTotal@yara/10e8bd3071677dd1fa76beeef4bc2fc427cea5e7,CVE-2017-9438,https://github.com/VirusTotal/yara/commit/10e8bd3071677dd1fa76beeef4bc2fc427cea5e7,2017-06-05T17:29Z 823,CWE-119,"CWE-119 static void optimize_b ( MACROBLOCK * mb , int ib , int type , ENTROPY_CONTEXT * a , ENTROPY_CONTEXT * l ) { BLOCK * b ; BLOCKD * d ; vp8_token_state tokens [ 17 ] [ 2 ] ; unsigned best_mask [ 2 ] ; const short * dequant_ptr ; const short * coeff_ptr ; short * qcoeff_ptr ; short * dqcoeff_ptr ; int eob ; int i0 ; int rc ; int x ; int sz = 0 ; int next ; int rdmult ; int rddiv ; int final_eob ; int rd_cost0 ; int rd_cost1 ; int rate0 ; int rate1 ; int error0 ; int error1 ; int t0 ; int t1 ; int best ; int band ; int pt ; int i ; int err_mult = plane_rd_mult [ type ] ; b = & mb -> block [ ib ] ; d = & mb -> e_mbd . block [ ib ] ; # if 0 vp8_strict_quantize_b ( b , d ) ; # endif dequant_ptr = d -> dequant ; coeff_ptr = b -> coeff ; qcoeff_ptr = d -> qcoeff ; dqcoeff_ptr = d -> dqcoeff ; i0 = ! type ; eob = * d -> eob ; rdmult = mb -> rdmult * err_mult ; if ( mb -> e_mbd . mode_info_context -> mbmi . ref_frame == INTRA_FRAME ) rdmult = ( rdmult * 9 ) >> 4 ; rddiv = mb -> rddiv ; best_mask [ 0 ] = best_mask [ 1 ] = 0 ; tokens [ eob ] [ 0 ] . rate = 0 ; tokens [ eob ] [ 0 ] . error = 0 ; tokens [ eob ] [ 0 ] . next = 16 ; tokens [ eob ] [ 0 ] . token = DCT_EOB_TOKEN ; tokens [ eob ] [ 0 ] . qc = 0 ; * ( tokens [ eob ] + 1 ) = * ( tokens [ eob ] + 0 ) ; next = eob ; for ( i = eob ; i -- > i0 ; ) { int base_bits ; int d2 ; int dx ; rc = vp8_default_zig_zag1d [ i ] ; x = qcoeff_ptr [ rc ] ; if ( x ) { int shortcut = 0 ; error0 = tokens [ next ] [ 0 ] . error ; error1 = tokens [ next ] [ 1 ] . error ; rate0 = tokens [ next ] [ 0 ] . rate ; rate1 = tokens [ next ] [ 1 ] . rate ; t0 = ( vp8_dct_value_tokens_ptr + x ) -> Token ; if ( next < 16 ) { band = vp8_coef_bands [ i + 1 ] ; pt = vp8_prev_token_class [ t0 ] ; rate0 += mb -> token_costs [ type ] [ band ] [ pt ] [ tokens [ next ] [ 0 ] . token ] ; rate1 += mb -> token_costs [ type ] [ band ] [ pt ] [ tokens [ next ] [ 1 ] . token ] ; } rd_cost0 = RDCOST ( rdmult , rddiv , rate0 , error0 ) ; rd_cost1 = RDCOST ( rdmult , rddiv , rate1 , error1 ) ; if ( rd_cost0 == rd_cost1 ) { rd_cost0 = RDTRUNC ( rdmult , rddiv , rate0 , error0 ) ; rd_cost1 = RDTRUNC ( rdmult , rddiv , rate1 , error1 ) ; } best = rd_cost1 < rd_cost0 ; base_bits = * ( vp8_dct_value_cost_ptr + x ) ; dx = dqcoeff_ptr [ rc ] - coeff_ptr [ rc ] ; d2 = dx * dx ; tokens [ i ] [ 0 ] . rate = base_bits + ( best ? rate1 : rate0 ) ; tokens [ i ] [ 0 ] . error = d2 + ( best ? error1 : error0 ) ; tokens [ i ] [ 0 ] . next = next ; tokens [ i ] [ 0 ] . token = t0 ; tokens [ i ] [ 0 ] . qc = x ; best_mask [ 0 ] |= best << i ; rate0 = tokens [ next ] [ 0 ] . rate ; rate1 = tokens [ next ] [ 1 ] . rate ; if ( ( abs ( x ) * dequant_ptr [ rc ] > abs ( coeff_ptr [ rc ] ) ) && ( abs ( x ) * dequant_ptr [ rc ] < abs ( coeff_ptr [ rc ] ) + dequant_ptr [ rc ] ) ) shortcut = 1 ; else shortcut = 0 ; if ( shortcut ) { sz = - ( x < 0 ) ; x -= 2 * sz + 1 ; } if ( ! x ) { t0 = tokens [ next ] [ 0 ] . token == DCT_EOB_TOKEN ? DCT_EOB_TOKEN : ZERO_TOKEN ; t1 = tokens [ next ] [ 1 ] . token == DCT_EOB_TOKEN ? DCT_EOB_TOKEN : ZERO_TOKEN ; } else { t0 = t1 = ( vp8_dct_value_tokens_ptr + x ) -> Token ; } if ( next < 16 ) { band = vp8_coef_bands [ i + 1 ] ; if ( t0 != DCT_EOB_TOKEN ) { pt = vp8_prev_token_class [ t0 ] ; rate0 += mb -> token_costs [ type ] [ band ] [ pt ] [ tokens [ next ] [ 0 ] . token ] ; } if ( t1 != DCT_EOB_TOKEN ) { pt = vp8_prev_token_class [ t1 ] ; rate1 += mb -> token_costs [ type ] [ band ] [ pt ] [ tokens [ next ] [ 1 ] . token ] ; } } rd_cost0 = RDCOST ( rdmult , rddiv , rate0 , error0 ) ; rd_cost1 = RDCOST ( rdmult , rddiv , rate1 , error1 ) ; if ( rd_cost0 == rd_cost1 ) { rd_cost0 = RDTRUNC ( rdmult , rddiv , rate0 , error0 ) ; rd_cost1 = RDTRUNC ( rdmult , rddiv , rate1 , error1 ) ; } best = rd_cost1 < rd_cost0 ; base_bits = * ( vp8_dct_value_cost_ptr + x ) ; if ( shortcut ) { dx -= ( dequant_ptr [ rc ] + sz ) ^ sz ; d2 = dx * dx ; } tokens [ i ] [ 1 ] . rate = base_bits + ( best ? rate1 : rate0 ) ; tokens [ i ] [ 1 ] . error = d2 + ( best ? error1 : error0 ) ; tokens [ i ] [ 1 ] . next = next ; tokens [ i ] [ 1 ] . token = best ? t1 : t0 ; tokens [ i ] [ 1 ] . qc = x ; best_mask [ 1 ] |= best << i ; next = i ; } else { band = vp8_coef_bands [ i + 1 ] ; t0 = tokens [ next ] [ 0 ] . token ; t1 = tokens [ next ] [ 1 ] . token ; if ( t0 != DCT_EOB_TOKEN ) { tokens [ next ] [ 0 ] . rate += mb -> token_costs [ type ] [ band ] [ 0 ] [ t0 ] ; tokens [ next ] [ 0 ] . token = ZERO_TOKEN ; } if ( t1 != DCT_EOB_TOKEN ) { tokens [ next ] [ 1 ] . rate += mb -> token_costs [ type ] [ band ] [ 0 ] [ t1 ] ; tokens [ next ] [ 1 ] . token = ZERO_TOKEN ; } } } band = vp8_coef_bands [ i + 1 ] ; VP8_COMBINEENTROPYCONTEXTS ( pt , * a , * l ) ; rate0 = tokens [ next ] [ 0 ] . rate ; rate1 = tokens [ next ] [ 1 ] . rate ; error0 = tokens [ next ] [ 0 ] . error ; error1 = tokens [ next ] [ 1 ] . error ; t0 = tokens [ next ] [ 0 ] . token ; t1 = tokens [ next ] [ 1 ] . token ; rate0 += mb -> token_costs [ type ] [ band ] [ pt ] [ t0 ] ; rate1 += mb -> token_costs [ type ] [ band ] [ pt ] [ t1 ] ; rd_cost0 = RDCOST ( rdmult , rddiv , rate0 , error0 ) ; rd_cost1 = RDCOST ( rdmult , rddiv , rate1 , error1 ) ; if ( rd_cost0 == rd_cost1 ) { rd_cost0 = RDTRUNC ( rdmult , rddiv , rate0 , error0 ) ; rd_cost1 = RDTRUNC ( rdmult , rddiv , rate1 , error1 ) ; } best = rd_cost1 < rd_cost0 ; final_eob = i0 - 1 ; for ( i = next ; i < eob ; i = next ) { x = tokens [ i ] [ best ] . qc ; if ( x ) final_eob = i ; rc = vp8_default_zig_zag1d [ i ] ; qcoeff_ptr [ rc ] = x ; dqcoeff_ptr [ rc ] = x * dequant_ptr [ rc ] ; next = tokens [ i ] [ best ] . next ; best = ( best_mask [ best ] >> i ) & 1 ; } final_eob ++ ; * a = * l = ( final_eob != ! type ) ; * d -> eob = ( char ) final_eob ; } "," ib ] ; dequant_ptr = d ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 824,CWE-000,"CWE-000 static int process_options ( int argc , char * argv [ ] , char * operation ) { int error = 0 ; int i = 0 ; if ( ( error = handle_options ( & argc , & argv , my_long_options , get_one_option ) ) ) goto exit ; if ( opt_print_defaults ) { error = - 1 ; goto exit ; } if ( opt_basedir ) { i = ( int ) strlength ( opt_basedir ) ; if ( opt_basedir [ i - 1 ] != FN_LIBCHAR || opt_basedir [ i - 1 ] != FN_LIBCHAR2 ) { char buff [ FN_REFLEN ] ; strncpy ( buff , opt_basedir , sizeof ( buff ) - 1 ) ; # ifdef __WIN__ strncat ( buff , ""/"" , sizeof ( buff ) - strlen ( buff ) - 1 ) ; # else strncat ( buff , FN_DIRSEP , sizeof ( buff ) - strlen ( buff ) - 1 ) ; # endif buff [ sizeof ( buff ) - 1 ] = 0 ; my_free ( opt_basedir ) ; opt_basedir = my_strdup ( buff , MYF ( MY_FAE ) ) ; } } if ( ! opt_no_defaults && ( ( error = get_default_values ( ) ) ) ) { error = - 1 ; goto exit ; } strcpy ( operation , """" ) ; if ( ( error = check_options ( argc , argv , operation ) ) ) { goto exit ; } if ( opt_verbose ) { printf ( ""#basedir=%s\\n"" , opt_basedir ) ; printf ( ""#plugin_dir=%s\\n"" , opt_plugin_dir ) ; printf ( ""#datadir=%s\\n"" , opt_datadir ) ; printf ( ""#plugin_ini=%s\\n"" , opt_plugin_ini ) ; } exit : return error ; } "," FN_REFLEN ] ; memset ( buff , 0 , sizeof ( buff ) ) ; ",mysql@mysql-server/0dbd5a8797ed4bd18e8b883988fb62177eb0f73f,CVE-2016-0546,https://github.com/mysql/mysql-server/commit/0dbd5a8797ed4bd18e8b883988fb62177eb0f73f,2016-01-21T03:01Z 825,CWE-20,"CWE-20 int user_update ( struct key * key , struct key_preparsed_payload * prep ) { struct user_key_payload * zap = NULL ; int ret ; ret = key_payload_reserve ( key , prep -> datalen ) ; if ( ret < 0 ) return ret ; key -> expiry = prep -> expiry ; if ( ! test_bit ( KEY_FLAG_NEGATIVE , & key -> flags ) ) zap = dereference_key_locked ( key ) ; rcu_assign_keypointer ( key , prep -> payload . data [ 0 ] ) ; prep -> payload . data [ 0 ] = NULL ; if ( zap ) call_rcu ( & zap -> rcu , user_free_payload_rcu ) ; return ret ; } "," ; if ( key_is_positive ( key ) ) zap ",torvalds@linux/363b02dab09b3226f3bd1420dad9c72b79a42a76,CVE-2017-15951,https://github.com/torvalds/linux/commit/363b02dab09b3226f3bd1420dad9c72b79a42a76,2017-10-28T02:29Z 826,CWE-200,"CWE-200 static int hci_sock_getsockopt ( struct socket * sock , int level , int optname , char __user * optval , int __user * optlen ) { struct hci_ufilter uf ; struct sock * sk = sock -> sk ; int len , opt , err = 0 ; BT_DBG ( ""sk%p,opt%d"" , sk , optname ) ; if ( get_user ( len , optlen ) ) return - EFAULT ; lock_sock ( sk ) ; if ( hci_pi ( sk ) -> channel != HCI_CHANNEL_RAW ) { err = - EINVAL ; goto done ; } switch ( optname ) { case HCI_DATA_DIR : if ( hci_pi ( sk ) -> cmsg_mask & HCI_CMSG_DIR ) opt = 1 ; else opt = 0 ; if ( put_user ( opt , optval ) ) err = - EFAULT ; break ; case HCI_TIME_STAMP : if ( hci_pi ( sk ) -> cmsg_mask & HCI_CMSG_TSTAMP ) opt = 1 ; else opt = 0 ; if ( put_user ( opt , optval ) ) err = - EFAULT ; break ; case HCI_FILTER : { struct hci_filter * f = & hci_pi ( sk ) -> filter ; uf . type_mask = f -> type_mask ; uf . opcode = f -> opcode ; uf . event_mask [ 0 ] = * ( ( u32 * ) f -> event_mask + 0 ) ; uf . event_mask [ 1 ] = * ( ( u32 * ) f -> event_mask + 1 ) ; } len = min_t ( unsigned int , len , sizeof ( uf ) ) ; if ( copy_to_user ( optval , & uf , len ) ) err = - EFAULT ; break ; default : err = - ENOPROTOOPT ; break ; } done : release_sock ( sk ) ; return err ; } "," ) -> filter ; memset ( & uf , 0 , sizeof ( uf ) ) ",torvalds@linux/e15ca9a0ef9a86f0477530b0f44a725d67f889ee,CVE-2012-6544,https://github.com/torvalds/linux/commit/e15ca9a0ef9a86f0477530b0f44a725d67f889ee,2013-03-15T20:55Z 827,CWE-119,"CWE-119 int vp8_decode_frame ( VP8D_COMP * pbi ) { vp8_reader * const bc = & pbi -> mbc [ 8 ] ; VP8_COMMON * const pc = & pbi -> common ; MACROBLOCKD * const xd = & pbi -> mb ; const unsigned char * data = pbi -> fragments . ptrs [ 0 ] ; const unsigned char * data_end = data + pbi -> fragments . sizes [ 0 ] ; ptrdiff_t first_partition_length_in_bytes ; int i , j , k , l ; const int * const mb_feature_data_bits = vp8_mb_feature_data_bits ; int corrupt_tokens = 0 ; int prev_independent_partitions = pbi -> independent_partitions ; YV12_BUFFER_CONFIG * yv12_fb_new = pbi -> dec_fb_ref [ INTRA_FRAME ] ; xd -> corrupted = 0 ; yv12_fb_new -> corrupted = 0 ; if ( data_end - data < 3 ) { if ( ! pbi -> ec_active ) { vpx_internal_error ( & pc -> error , VPX_CODEC_CORRUPT_FRAME , ""Truncatedpacket"" ) ; } pc -> frame_type = INTER_FRAME ; pc -> version = 0 ; pc -> show_frame = 1 ; first_partition_length_in_bytes = 0 ; } else { unsigned char clear_buffer [ 10 ] ; const unsigned char * clear = data ; if ( pbi -> decrypt_cb ) { int n = ( int ) ( data_end - data ) ; if ( n > 10 ) n = 10 ; pbi -> decrypt_cb ( pbi -> decrypt_state , data , clear_buffer , n ) ; clear = clear_buffer ; } pc -> frame_type = ( FRAME_TYPE ) ( clear [ 0 ] & 1 ) ; pc -> version = ( clear [ 0 ] >> 1 ) & 7 ; pc -> show_frame = ( clear [ 0 ] >> 4 ) & 1 ; first_partition_length_in_bytes = ( clear [ 0 ] | ( clear [ 1 ] << 8 ) | ( clear [ 2 ] << 16 ) ) >> 5 ; if ( ! pbi -> ec_active && ( data + first_partition_length_in_bytes > data_end || data + first_partition_length_in_bytes < data ) ) vpx_internal_error ( & pc -> error , VPX_CODEC_CORRUPT_FRAME , ""Truncatedpacketorcorruptpartition0length"" ) ; data += 3 ; clear += 3 ; vp8_setup_version ( pc ) ; if ( pc -> frame_type == KEY_FRAME ) { if ( ! pbi -> ec_active || data + 3 < data_end ) { if ( clear [ 0 ] != 0x9d || clear [ 1 ] != 0x01 || clear [ 2 ] != 0x2a ) vpx_internal_error ( & pc -> error , VPX_CODEC_UNSUP_BITSTREAM , ""Invalidframesynccode"" ) ; } if ( ! pbi -> ec_active || data + 6 < data_end ) { pc -> Width = ( clear [ 3 ] | ( clear [ 4 ] << 8 ) ) & 0x3fff ; pc -> horiz_scale = clear [ 4 ] >> 6 ; pc -> Height = ( clear [ 5 ] | ( clear [ 6 ] << 8 ) ) & 0x3fff ; pc -> vert_scale = clear [ 6 ] >> 6 ; } data += 7 ; clear += 7 ; } else { vpx_memcpy ( & xd -> pre , yv12_fb_new , sizeof ( YV12_BUFFER_CONFIG ) ) ; vpx_memcpy ( & xd -> dst , yv12_fb_new , sizeof ( YV12_BUFFER_CONFIG ) ) ; } } if ( ( ! pbi -> decoded_key_frame && pc -> frame_type != KEY_FRAME ) ) { return - 1 ; } init_frame ( pbi ) ; if ( vp8dx_start_decode ( bc , data , ( unsigned int ) ( data_end - data ) , pbi -> decrypt_cb , pbi -> decrypt_state ) ) vpx_internal_error ( & pc -> error , VPX_CODEC_MEM_ERROR , ""Failedtoallocatebooldecoder0"" ) ; if ( pc -> frame_type == KEY_FRAME ) { ( void ) vp8_read_bit ( bc ) ; pc -> clamp_type = ( CLAMP_TYPE ) vp8_read_bit ( bc ) ; } xd -> segmentation_enabled = ( unsigned char ) vp8_read_bit ( bc ) ; if ( xd -> segmentation_enabled ) { xd -> update_mb_segmentation_map = ( unsigned char ) vp8_read_bit ( bc ) ; xd -> update_mb_segmentation_data = ( unsigned char ) vp8_read_bit ( bc ) ; if ( xd -> update_mb_segmentation_data ) { xd -> mb_segement_abs_delta = ( unsigned char ) vp8_read_bit ( bc ) ; vpx_memset ( xd -> segment_feature_data , 0 , sizeof ( xd -> segment_feature_data ) ) ; for ( i = 0 ; i < MB_LVL_MAX ; i ++ ) { for ( j = 0 ; j < MAX_MB_SEGMENTS ; j ++ ) { if ( vp8_read_bit ( bc ) ) { xd -> segment_feature_data [ i ] [ j ] = ( signed char ) vp8_read_literal ( bc , mb_feature_data_bits [ i ] ) ; if ( vp8_read_bit ( bc ) ) xd -> segment_feature_data [ i ] [ j ] = - xd -> segment_feature_data [ i ] [ j ] ; } else xd -> segment_feature_data [ i ] [ j ] = 0 ; } } } if ( xd -> update_mb_segmentation_map ) { vpx_memset ( xd -> mb_segment_tree_probs , 255 , sizeof ( xd -> mb_segment_tree_probs ) ) ; for ( i = 0 ; i < MB_FEATURE_TREE_PROBS ; i ++ ) { if ( vp8_read_bit ( bc ) ) xd -> mb_segment_tree_probs [ i ] = ( vp8_prob ) vp8_read_literal ( bc , 8 ) ; } } } else { xd -> update_mb_segmentation_map = 0 ; xd -> update_mb_segmentation_data = 0 ; } pc -> filter_type = ( LOOPFILTERTYPE ) vp8_read_bit ( bc ) ; pc -> filter_level = vp8_read_literal ( bc , 6 ) ; pc -> sharpness_level = vp8_read_literal ( bc , 3 ) ; xd -> mode_ref_lf_delta_update = 0 ; xd -> mode_ref_lf_delta_enabled = ( unsigned char ) vp8_read_bit ( bc ) ; if ( xd -> mode_ref_lf_delta_enabled ) { xd -> mode_ref_lf_delta_update = ( unsigned char ) vp8_read_bit ( bc ) ; if ( xd -> mode_ref_lf_delta_update ) { for ( i = 0 ; i < MAX_REF_LF_DELTAS ; i ++ ) { if ( vp8_read_bit ( bc ) ) { xd -> ref_lf_deltas [ i ] = ( signed char ) vp8_read_literal ( bc , 6 ) ; if ( vp8_read_bit ( bc ) ) xd -> ref_lf_deltas [ i ] = xd -> ref_lf_deltas [ i ] * - 1 ; } } for ( i = 0 ; i < MAX_MODE_LF_DELTAS ; i ++ ) { if ( vp8_read_bit ( bc ) ) { xd -> mode_lf_deltas [ i ] = ( signed char ) vp8_read_literal ( bc , 6 ) ; if ( vp8_read_bit ( bc ) ) xd -> mode_lf_deltas [ i ] = xd -> mode_lf_deltas [ i ] * - 1 ; } } } } setup_token_decoder ( pbi , data + first_partition_length_in_bytes ) ; xd -> current_bc = & pbi -> mbc [ 0 ] ; { int Q , q_update ; Q = vp8_read_literal ( bc , 7 ) ; pc -> base_qindex = Q ; q_update = 0 ; pc -> y1dc_delta_q = get_delta_q ( bc , pc -> y1dc_delta_q , & q_update ) ; pc -> y2dc_delta_q = get_delta_q ( bc , pc -> y2dc_delta_q , & q_update ) ; pc -> y2ac_delta_q = get_delta_q ( bc , pc -> y2ac_delta_q , & q_update ) ; pc -> uvdc_delta_q = get_delta_q ( bc , pc -> uvdc_delta_q , & q_update ) ; pc -> uvac_delta_q = get_delta_q ( bc , pc -> uvac_delta_q , & q_update ) ; if ( q_update ) vp8cx_init_de_quantizer ( pbi ) ; vp8_mb_init_dequantizer ( pbi , & pbi -> mb ) ; } if ( pc -> frame_type != KEY_FRAME ) { pc -> refresh_golden_frame = vp8_read_bit ( bc ) ; # if CONFIG_ERROR_CONCEALMENT xd -> corrupted |= vp8dx_bool_error ( bc ) ; if ( pbi -> ec_active && xd -> corrupted ) pc -> refresh_golden_frame = 0 ; # endif pc -> refresh_alt_ref_frame = vp8_read_bit ( bc ) ; # if CONFIG_ERROR_CONCEALMENT xd -> corrupted |= vp8dx_bool_error ( bc ) ; if ( pbi -> ec_active && xd -> corrupted ) pc -> refresh_alt_ref_frame = 0 ; # endif pc -> copy_buffer_to_gf = 0 ; if ( ! pc -> refresh_golden_frame ) pc -> copy_buffer_to_gf = vp8_read_literal ( bc , 2 ) ; # if CONFIG_ERROR_CONCEALMENT xd -> corrupted |= vp8dx_bool_error ( bc ) ; if ( pbi -> ec_active && xd -> corrupted ) pc -> copy_buffer_to_gf = 0 ; # endif pc -> copy_buffer_to_arf = 0 ; if ( ! pc -> refresh_alt_ref_frame ) pc -> copy_buffer_to_arf = vp8_read_literal ( bc , 2 ) ; # if CONFIG_ERROR_CONCEALMENT xd -> corrupted |= vp8dx_bool_error ( bc ) ; if ( pbi -> ec_active && xd -> corrupted ) pc -> copy_buffer_to_arf = 0 ; # endif pc -> ref_frame_sign_bias [ GOLDEN_FRAME ] = vp8_read_bit ( bc ) ; pc -> ref_frame_sign_bias [ ALTREF_FRAME ] = vp8_read_bit ( bc ) ; } pc -> refresh_entropy_probs = vp8_read_bit ( bc ) ; # if CONFIG_ERROR_CONCEALMENT xd -> corrupted |= vp8dx_bool_error ( bc ) ; if ( pbi -> ec_active && xd -> corrupted ) pc -> refresh_entropy_probs = 0 ; # endif if ( pc -> refresh_entropy_probs == 0 ) { vpx_memcpy ( & pc -> lfc , & pc -> fc , sizeof ( pc -> fc ) ) ; } pc -> refresh_last_frame = pc -> frame_type == KEY_FRAME || vp8_read_bit ( bc ) ; # if CONFIG_ERROR_CONCEALMENT xd -> corrupted |= vp8dx_bool_error ( bc ) ; if ( pbi -> ec_active && xd -> corrupted ) pc -> refresh_last_frame = 1 ; # endif if ( 0 ) { FILE * z = fopen ( ""decodestats.stt"" , ""a"" ) ; fprintf ( z , ""%6dF:%d,G:%d,A:%d,L:%d,Q:%d\\n"" , pc -> current_video_frame , pc -> frame_type , pc -> refresh_golden_frame , pc -> refresh_alt_ref_frame , pc -> refresh_last_frame , pc -> base_qindex ) ; fclose ( z ) ; } { pbi -> independent_partitions = 1 ; for ( i = 0 ; i < BLOCK_TYPES ; i ++ ) for ( j = 0 ; j < COEF_BANDS ; j ++ ) for ( k = 0 ; k < PREV_COEF_CONTEXTS ; k ++ ) for ( l = 0 ; l < ENTROPY_NODES ; l ++ ) { vp8_prob * const p = pc -> fc . coef_probs [ i ] [ j ] [ k ] + l ; if ( vp8_read ( bc , vp8_coef_update_probs [ i ] [ j ] [ k ] [ l ] ) ) { * p = ( vp8_prob ) vp8_read_literal ( bc , 8 ) ; } if ( k > 0 && * p != pc -> fc . coef_probs [ i ] [ j ] [ k - 1 ] [ l ] ) pbi -> independent_partitions = 0 ; } } vpx_memset ( xd -> qcoeff , 0 , sizeof ( xd -> qcoeff ) ) ; vp8_decode_mode_mvs ( pbi ) ; # if CONFIG_ERROR_CONCEALMENT if ( pbi -> ec_active && pbi -> mvs_corrupt_from_mb < ( unsigned int ) pc -> mb_cols * pc -> mb_rows ) { vp8_estimate_missing_mvs ( pbi ) ; } # endif vpx_memset ( pc -> above_context , 0 , sizeof ( ENTROPY_CONTEXT_PLANES ) * pc -> mb_cols ) ; pbi -> frame_corrupt_residual = 0 ; # if CONFIG_MULTITHREAD if ( pbi -> b_multithreaded_rd && pc -> multi_token_partition != ONE_PARTITION ) { unsigned int thread ; vp8mt_decode_mb_rows ( pbi , xd ) ; vp8_yv12_extend_frame_borders ( yv12_fb_new ) ; for ( thread = 0 ; thread < pbi -> decoding_thread_count ; ++ thread ) corrupt_tokens |= pbi -> mb_row_di [ thread ] . mbd . corrupted ; } else # endif { decode_mb_rows ( pbi ) ; corrupt_tokens |= xd -> corrupted ; } yv12_fb_new -> corrupted = vp8dx_bool_error ( bc ) ; yv12_fb_new -> corrupted |= corrupt_tokens ; if ( ! pbi -> decoded_key_frame ) { if ( pc -> frame_type == KEY_FRAME && ! yv12_fb_new -> corrupted ) pbi -> decoded_key_frame = 1 ; else vpx_internal_error ( & pbi -> common . error , VPX_CODEC_CORRUPT_FRAME , ""Astreammuststartwithacompletekeyframe"" ) ; } if ( pc -> refresh_entropy_probs == 0 ) { vpx_memcpy ( & pc -> fc , & pc -> lfc , sizeof ( pc -> fc ) ) ; pbi -> independent_partitions = prev_independent_partitions ; } # ifdef PACKET_TESTING { FILE * f = fopen ( ""decompressor.VP8"" , ""ab"" ) ; unsigned int size = pbi -> bc2 . pos + pbi -> bc . pos + 8 ; fwrite ( ( void * ) & size , 4 , 1 , f ) ; fwrite ( ( void * ) pbi -> Source , size , 1 , f ) ; fclose ( f ) ; } # endif return 0 ; } "," ( int ) MIN ( sizeof ( clear_buffer ) , data_end - data - data ) ; pbi -> += 7 ; } else { } else { memcpy ( & xd ) ) ; memcpy ( & xd bc ) ; memset ( xd -> update_mb_segmentation_map ) { memset ( xd -> 0 ) { memcpy ( & pc ; } } memset ( xd -> } # endif memset ( pc -> 0 ) { memcpy ( & pc ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 828,CWE-772,"CWE-772 getprivs_ret * get_privs_2_svc ( krb5_ui_4 * arg , struct svc_req * rqstp ) { static getprivs_ret ret ; gss_buffer_desc client_name , service_name ; OM_uint32 minor_stat ; kadm5_server_handle_t handle ; const char * errmsg = NULL ; xdr_free ( xdr_getprivs_ret , & ret ) ; if ( ( ret . code = new_server_handle ( * arg , rqstp , & handle ) ) ) goto exit_func ; if ( ( ret . code = check_handle ( ( void * ) handle ) ) ) goto exit_func ; ret . api_version = handle -> api_version ; if ( setup_gss_names ( rqstp , & client_name , & service_name ) < 0 ) { ret . code = KADM5_FAILURE ; goto exit_func ; } ret . code = kadm5_get_privs ( ( void * ) handle , & ret . privs ) ; if ( ret . code != 0 ) errmsg = krb5_get_error_message ( handle -> context , ret . code ) ; log_done ( ""kadm5_get_privs"" , client_name . value , errmsg , & client_name , & service_name , rqstp ) ; if ( errmsg != NULL ) krb5_free_error_message ( handle -> context , errmsg ) ; gss_release_buffer ( & minor_stat , & client_name ) ; gss_release_buffer ( & minor_stat , & service_name ) ; exit_func : free_server_handle ( handle ) ; return & ret ; } "," ; gss_buffer_desc client_name = GSS_C_EMPTY_BUFFER ; gss_buffer_desc service_name = GSS_C_EMPTY_BUFFER ; OM_uint32 minor_stat errmsg ) ; exit_func : service_name ) ; free_server_handle ( handle ",krb5@krb5/83ed75feba32e46f736fcce0d96a0445f29b96c2,CVE-2015-8631,https://github.com/krb5/krb5/commit/83ed75feba32e46f736fcce0d96a0445f29b96c2,2016-02-13T02:59Z 829,CWE-000,"CWE-000 void sctp_assoc_update ( struct sctp_association * asoc , struct sctp_association * new ) { struct sctp_transport * trans ; struct list_head * pos , * temp ; asoc -> c = new -> c ; asoc -> peer . rwnd = new -> peer . rwnd ; asoc -> peer . sack_needed = new -> peer . sack_needed ; asoc -> peer . i = new -> peer . i ; sctp_tsnmap_init ( & asoc -> peer . tsn_map , SCTP_TSN_MAP_INITIAL , asoc -> peer . i . initial_tsn , GFP_ATOMIC ) ; list_for_each_safe ( pos , temp , & asoc -> peer . transport_addr_list ) { trans = list_entry ( pos , struct sctp_transport , transports ) ; if ( ! sctp_assoc_lookup_paddr ( new , & trans -> ipaddr ) ) { sctp_assoc_rm_peer ( asoc , trans ) ; continue ; } if ( asoc -> state >= SCTP_STATE_ESTABLISHED ) sctp_transport_reset ( trans ) ; } if ( asoc -> state >= SCTP_STATE_ESTABLISHED ) { asoc -> next_tsn = new -> next_tsn ; asoc -> ctsn_ack_point = new -> ctsn_ack_point ; asoc -> adv_peer_ack_point = new -> adv_peer_ack_point ; sctp_ssnmap_clear ( asoc -> ssnmap ) ; sctp_ulpq_flush ( & asoc -> ulpq ) ; asoc -> overall_error_count = 0 ; } else { list_for_each_entry ( trans , & new -> peer . transport_addr_list , transports ) { if ( ! sctp_assoc_lookup_paddr ( asoc , & trans -> ipaddr ) ) sctp_assoc_add_peer ( asoc , & trans -> ipaddr , GFP_ATOMIC , trans -> state ) ; } asoc -> ctsn_ack_point = asoc -> next_tsn - 1 ; asoc -> adv_peer_ack_point = asoc -> ctsn_ack_point ; if ( ! asoc -> ssnmap ) { asoc -> ssnmap = new -> ssnmap ; new -> ssnmap = NULL ; } if ( ! asoc -> assoc_id ) { sctp_assoc_set_id ( asoc , GFP_ATOMIC ) ; } } kfree ( asoc -> peer . peer_random ) ; asoc -> peer . peer_random = new -> peer . peer_random ; new -> peer . peer_random = NULL ; kfree ( asoc -> peer . peer_chunks ) ; asoc -> peer . peer_chunks = new -> peer . peer_chunks ; new -> peer . peer_chunks = NULL ; kfree ( asoc -> peer . peer_hmacs ) ; asoc -> peer . peer_hmacs = new -> peer . peer_hmacs ; new -> peer . peer_hmacs = NULL ; sctp_auth_key_put ( asoc -> asoc_shared_key ) ; sctp_auth_asoc_init_active_key ( asoc , GFP_ATOMIC ) ; } "," -> peer . auth_capable = new -> peer . auth_capable ; asoc -> peer . ",torvalds@linux/1be9a950c646c9092fb3618197f7b6bfb50e82aa,CVE-2014-5077,https://github.com/torvalds/linux/commit/1be9a950c646c9092fb3618197f7b6bfb50e82aa,2014-08-01T11:13Z 830,CWE-20,"CWE-20 static int aac_send_raw_srb ( struct aac_dev * dev , void __user * arg ) { struct fib * srbfib ; int status ; struct aac_srb * srbcmd = NULL ; struct user_aac_srb * user_srbcmd = NULL ; struct user_aac_srb __user * user_srb = arg ; struct aac_srb_reply __user * user_reply ; struct aac_srb_reply * reply ; u32 fibsize = 0 ; u32 flags = 0 ; s32 rcode = 0 ; u32 data_dir ; void __user * sg_user [ 32 ] ; void * sg_list [ 32 ] ; u32 sg_indx = 0 ; u32 byte_count = 0 ; u32 actual_fibsize64 , actual_fibsize = 0 ; int i ; if ( dev -> in_reset ) { dprintk ( ( KERN_DEBUG ""aacraid:sendrawsrb-EBUSY\\n"" ) ) ; return - EBUSY ; } if ( ! capable ( CAP_SYS_ADMIN ) ) { dprintk ( ( KERN_DEBUG ""aacraid:Nopermissiontosendrawsrb\\n"" ) ) ; return - EPERM ; } if ( ! ( srbfib = aac_fib_alloc ( dev ) ) ) { return - ENOMEM ; } aac_fib_init ( srbfib ) ; srbfib -> hw_fib_va -> header . XferState &= ~ cpu_to_le32 ( FastResponseCapable ) ; srbcmd = ( struct aac_srb * ) fib_data ( srbfib ) ; memset ( sg_list , 0 , sizeof ( sg_list ) ) ; if ( copy_from_user ( & fibsize , & user_srb -> count , sizeof ( u32 ) ) ) { dprintk ( ( KERN_DEBUG ""aacraid:Couldnotcopydatasizefromuser\\n"" ) ) ; rcode = - EFAULT ; goto cleanup ; } if ( fibsize > ( dev -> max_fib_size - sizeof ( struct aac_fibhdr ) ) ) { rcode = - EINVAL ; goto cleanup ; } user_srbcmd = kmalloc ( fibsize , GFP_KERNEL ) ; if ( ! user_srbcmd ) { dprintk ( ( KERN_DEBUG ""aacraid:Couldnotmakeacopyofthesrb\\n"" ) ) ; rcode = - ENOMEM ; goto cleanup ; } if ( copy_from_user ( user_srbcmd , user_srb , fibsize ) ) { dprintk ( ( KERN_DEBUG ""aacraid:Couldnotcopysrbfromuser\\n"" ) ) ; rcode = - EFAULT ; goto cleanup ; } user_reply = arg + fibsize ; flags = user_srbcmd -> flags ; srbcmd -> function = cpu_to_le32 ( SRBF_ExecuteScsi ) ; srbcmd -> channel = cpu_to_le32 ( user_srbcmd -> channel ) ; srbcmd -> id = cpu_to_le32 ( user_srbcmd -> id ) ; srbcmd -> lun = cpu_to_le32 ( user_srbcmd -> lun ) ; srbcmd -> timeout = cpu_to_le32 ( user_srbcmd -> timeout ) ; srbcmd -> flags = cpu_to_le32 ( flags ) ; srbcmd -> retry_limit = 0 ; srbcmd -> cdb_size = cpu_to_le32 ( user_srbcmd -> cdb_size ) ; memcpy ( srbcmd -> cdb , user_srbcmd -> cdb , sizeof ( srbcmd -> cdb ) ) ; switch ( flags & ( SRB_DataIn | SRB_DataOut ) ) { case SRB_DataOut : data_dir = DMA_TO_DEVICE ; break ; case ( SRB_DataIn | SRB_DataOut ) : data_dir = DMA_BIDIRECTIONAL ; break ; case SRB_DataIn : data_dir = DMA_FROM_DEVICE ; break ; default : data_dir = DMA_NONE ; } if ( user_srbcmd -> sg . count > ARRAY_SIZE ( sg_list ) ) { dprintk ( ( KERN_DEBUG ""aacraid:toomanysgentries%d\\n"" , le32_to_cpu ( srbcmd -> sg . count ) ) ) ; rcode = - EINVAL ; goto cleanup ; } actual_fibsize = sizeof ( struct aac_srb ) - sizeof ( struct sgentry ) + ( ( user_srbcmd -> sg . count & 0xff ) * sizeof ( struct sgentry ) ) ; actual_fibsize64 = actual_fibsize + ( user_srbcmd -> sg . count & 0xff ) * ( sizeof ( struct sgentry64 ) - sizeof ( struct sgentry ) ) ; if ( ( actual_fibsize != fibsize ) && ( actual_fibsize64 != fibsize ) ) { dprintk ( ( KERN_DEBUG ""aacraid:BadSizespecifiedin"" ""RawSRBcommandcalculatedfibsize=%lu;%lu"" ""user_srbcmd->sg.count=%daac_srb=%lusgentry=%lu;%lu"" ""issuedfibsize=%d\\n"" , actual_fibsize , actual_fibsize64 , user_srbcmd -> sg . count , sizeof ( struct aac_srb ) , sizeof ( struct sgentry ) , sizeof ( struct sgentry64 ) , fibsize ) ) ; rcode = - EINVAL ; goto cleanup ; } if ( ( data_dir == DMA_NONE ) && user_srbcmd -> sg . count ) { dprintk ( ( KERN_DEBUG ""aacraid:SGwithnodirectionspecifiedinRawSRBcommand\\n"" ) ) ; rcode = - EINVAL ; goto cleanup ; } byte_count = 0 ; if ( dev -> adapter_info . options & AAC_OPT_SGMAP_HOST64 ) { struct user_sgmap64 * upsg = ( struct user_sgmap64 * ) & user_srbcmd -> sg ; struct sgmap64 * psg = ( struct sgmap64 * ) & srbcmd -> sg ; if ( actual_fibsize64 == fibsize ) { actual_fibsize = actual_fibsize64 ; for ( i = 0 ; i < upsg -> count ; i ++ ) { u64 addr ; void * p ; if ( upsg -> sg [ i ] . count > ( ( dev -> adapter_info . options & AAC_OPT_NEW_COMM ) ? ( dev -> scsi_host_ptr -> max_sectors << 9 ) : 65536 ) ) { rcode = - EINVAL ; goto cleanup ; } p = kmalloc ( upsg -> sg [ i ] . count , GFP_KERNEL | __GFP_DMA ) ; if ( ! p ) { dprintk ( ( KERN_DEBUG ""aacraid:CouldnotallocateSGbuffer-size=%dbuffernumber%dof%d\\n"" , upsg -> sg [ i ] . count , i , upsg -> count ) ) ; rcode = - ENOMEM ; goto cleanup ; } addr = ( u64 ) upsg -> sg [ i ] . addr [ 0 ] ; addr += ( ( u64 ) upsg -> sg [ i ] . addr [ 1 ] ) << 32 ; sg_user [ i ] = ( void __user * ) ( uintptr_t ) addr ; sg_list [ i ] = p ; sg_indx = i ; if ( flags & SRB_DataOut ) { if ( copy_from_user ( p , sg_user [ i ] , upsg -> sg [ i ] . count ) ) { dprintk ( ( KERN_DEBUG ""aacraid:Couldnotcopysgdatafromuser\\n"" ) ) ; rcode = - EFAULT ; goto cleanup ; } } addr = pci_map_single ( dev -> pdev , p , upsg -> sg [ i ] . count , data_dir ) ; psg -> sg [ i ] . addr [ 0 ] = cpu_to_le32 ( addr & 0xffffffff ) ; psg -> sg [ i ] . addr [ 1 ] = cpu_to_le32 ( addr >> 32 ) ; byte_count += upsg -> sg [ i ] . count ; psg -> sg [ i ] . count = cpu_to_le32 ( upsg -> sg [ i ] . count ) ; } } else { struct user_sgmap * usg ; usg = kmalloc ( actual_fibsize - sizeof ( struct aac_srb ) + sizeof ( struct sgmap ) , GFP_KERNEL ) ; if ( ! usg ) { dprintk ( ( KERN_DEBUG ""aacraid:AllocationerrorinRawSRBcommand\\n"" ) ) ; rcode = - ENOMEM ; goto cleanup ; } memcpy ( usg , upsg , actual_fibsize - sizeof ( struct aac_srb ) + sizeof ( struct sgmap ) ) ; actual_fibsize = actual_fibsize64 ; for ( i = 0 ; i < usg -> count ; i ++ ) { u64 addr ; void * p ; if ( usg -> sg [ i ] . count > ( ( dev -> adapter_info . options & AAC_OPT_NEW_COMM ) ? ( dev -> scsi_host_ptr -> max_sectors << 9 ) : 65536 ) ) { kfree ( usg ) ; rcode = - EINVAL ; goto cleanup ; } p = kmalloc ( usg -> sg [ i ] . count , GFP_KERNEL | __GFP_DMA ) ; if ( ! p ) { dprintk ( ( KERN_DEBUG ""aacraid:CouldnotallocateSGbuffer-size=%dbuffernumber%dof%d\\n"" , usg -> sg [ i ] . count , i , usg -> count ) ) ; kfree ( usg ) ; rcode = - ENOMEM ; goto cleanup ; } sg_user [ i ] = ( void __user * ) ( uintptr_t ) usg -> sg [ i ] . addr ; sg_list [ i ] = p ; sg_indx = i ; if ( flags & SRB_DataOut ) { if ( copy_from_user ( p , sg_user [ i ] , upsg -> sg [ i ] . count ) ) { kfree ( usg ) ; dprintk ( ( KERN_DEBUG ""aacraid:Couldnotcopysgdatafromuser\\n"" ) ) ; rcode = - EFAULT ; goto cleanup ; } } addr = pci_map_single ( dev -> pdev , p , usg -> sg [ i ] . count , data_dir ) ; psg -> sg [ i ] . addr [ 0 ] = cpu_to_le32 ( addr & 0xffffffff ) ; psg -> sg [ i ] . addr [ 1 ] = cpu_to_le32 ( addr >> 32 ) ; byte_count += usg -> sg [ i ] . count ; psg -> sg [ i ] . count = cpu_to_le32 ( usg -> sg [ i ] . count ) ; } kfree ( usg ) ; } srbcmd -> count = cpu_to_le32 ( byte_count ) ; psg -> count = cpu_to_le32 ( sg_indx + 1 ) ; status = aac_fib_send ( ScsiPortCommand64 , srbfib , actual_fibsize , FsaNormal , 1 , 1 , NULL , NULL ) ; } else { struct user_sgmap * upsg = & user_srbcmd -> sg ; struct sgmap * psg = & srbcmd -> sg ; if ( actual_fibsize64 == fibsize ) { struct user_sgmap64 * usg = ( struct user_sgmap64 * ) upsg ; for ( i = 0 ; i < upsg -> count ; i ++ ) { uintptr_t addr ; void * p ; if ( usg -> sg [ i ] . count > ( ( dev -> adapter_info . options & AAC_OPT_NEW_COMM ) ? ( dev -> scsi_host_ptr -> max_sectors << 9 ) : 65536 ) ) { rcode = - EINVAL ; goto cleanup ; } p = kmalloc ( usg -> sg [ i ] . count , GFP_KERNEL | __GFP_DMA ) ; if ( ! p ) { dprintk ( ( KERN_DEBUG ""aacraid:CouldnotallocateSGbuffer-size=%dbuffernumber%dof%d\\n"" , usg -> sg [ i ] . count , i , usg -> count ) ) ; rcode = - ENOMEM ; goto cleanup ; } addr = ( u64 ) usg -> sg [ i ] . addr [ 0 ] ; addr += ( ( u64 ) usg -> sg [ i ] . addr [ 1 ] ) << 32 ; sg_user [ i ] = ( void __user * ) addr ; sg_list [ i ] = p ; sg_indx = i ; if ( flags & SRB_DataOut ) { if ( copy_from_user ( p , sg_user [ i ] , usg -> sg [ i ] . count ) ) { dprintk ( ( KERN_DEBUG ""aacraid:Couldnotcopysgdatafromuser\\n"" ) ) ; rcode = - EFAULT ; goto cleanup ; } } addr = pci_map_single ( dev -> pdev , p , usg -> sg [ i ] . count , data_dir ) ; psg -> sg [ i ] . addr = cpu_to_le32 ( addr & 0xffffffff ) ; byte_count += usg -> sg [ i ] . count ; psg -> sg [ i ] . count = cpu_to_le32 ( usg -> sg [ i ] . count ) ; } } else { for ( i = 0 ; i < upsg -> count ; i ++ ) { dma_addr_t addr ; void * p ; if ( upsg -> sg [ i ] . count > ( ( dev -> adapter_info . options & AAC_OPT_NEW_COMM ) ? ( dev -> scsi_host_ptr -> max_sectors << 9 ) : 65536 ) ) { rcode = - EINVAL ; goto cleanup ; } p = kmalloc ( upsg -> sg [ i ] . count , GFP_KERNEL ) ; if ( ! p ) { dprintk ( ( KERN_DEBUG ""aacraid:CouldnotallocateSGbuffer-size=%dbuffernumber%dof%d\\n"" , upsg -> sg [ i ] . count , i , upsg -> count ) ) ; rcode = - ENOMEM ; goto cleanup ; } sg_user [ i ] = ( void __user * ) ( uintptr_t ) upsg -> sg [ i ] . addr ; sg_list [ i ] = p ; sg_indx = i ; if ( flags & SRB_DataOut ) { if ( copy_from_user ( p , sg_user [ i ] , upsg -> sg [ i ] . count ) ) { dprintk ( ( KERN_DEBUG ""aacraid:Couldnotcopysgdatafromuser\\n"" ) ) ; rcode = - EFAULT ; goto cleanup ; } } addr = pci_map_single ( dev -> pdev , p , upsg -> sg [ i ] . count , data_dir ) ; psg -> sg [ i ] . addr = cpu_to_le32 ( addr ) ; byte_count += upsg -> sg [ i ] . count ; psg -> sg [ i ] . count = cpu_to_le32 ( upsg -> sg [ i ] . count ) ; } } srbcmd -> count = cpu_to_le32 ( byte_count ) ; psg -> count = cpu_to_le32 ( sg_indx + 1 ) ; status = aac_fib_send ( ScsiPortCommand , srbfib , actual_fibsize , FsaNormal , 1 , 1 , NULL , NULL ) ; } if ( status == - ERESTARTSYS ) { rcode = - ERESTARTSYS ; goto cleanup ; } if ( status != 0 ) { dprintk ( ( KERN_DEBUG ""aacraid:Couldnotsendrawsrbfibtohba\\n"" ) ) ; rcode = - ENXIO ; goto cleanup ; } if ( flags & SRB_DataIn ) { for ( i = 0 ; i <= sg_indx ; i ++ ) { byte_count = le32_to_cpu ( ( dev -> adapter_info . options & AAC_OPT_SGMAP_HOST64 ) ? ( ( struct sgmap64 * ) & srbcmd -> sg ) -> sg [ i ] . count : srbcmd -> sg . sg [ i ] . count ) ; if ( copy_to_user ( sg_user [ i ] , sg_list [ i ] , byte_count ) ) { dprintk ( ( KERN_DEBUG ""aacraid:Couldnotcopysgdatatouser\\n"" ) ) ; rcode = - EFAULT ; goto cleanup ; } } } reply = ( struct aac_srb_reply * ) fib_data ( srbfib ) ; if ( copy_to_user ( user_reply , reply , sizeof ( struct aac_srb_reply ) ) ) { dprintk ( ( KERN_DEBUG ""aacraid:Couldnotcopyreplytouser\\n"" ) ) ; rcode = - EFAULT ; goto cleanup ; } cleanup : kfree ( user_srbcmd ) ; for ( i = 0 ; i <= sg_indx ; i ++ ) { kfree ( sg_list [ i ] ) ; } if ( rcode != - ERESTARTSYS ) { aac_fib_complete ( srbfib ) ; aac_fib_free ( srbfib ) ; } return rcode ; } "," } if ( ( fibsize < ( sizeof ( struct user_aac_srb ) - sizeof ( struct user_sgentry ) ) ) || ( ( struct aac_fibhdr ) ",torvalds@linux/b4789b8e6be3151a955ade74872822f30e8cd914,CVE-2013-6380,https://github.com/torvalds/linux/commit/b4789b8e6be3151a955ade74872822f30e8cd914,2013-11-27T04:43Z 831,CWE-119,"CWE-119 static int PredictorEncodeTile ( TIFF * tif , uint8 * bp0 , tmsize_t cc0 , uint16 s ) { static const char module [ ] = ""PredictorEncodeTile"" ; TIFFPredictorState * sp = PredictorState ( tif ) ; uint8 * working_copy ; tmsize_t cc = cc0 , rowsize ; unsigned char * bp ; int result_code ; assert ( sp != NULL ) ; assert ( sp -> encodepfunc != NULL ) ; assert ( sp -> encodetile != NULL ) ; working_copy = ( uint8 * ) _TIFFmalloc ( cc0 ) ; if ( working_copy == NULL ) { TIFFErrorExt ( tif -> tif_clientdata , module , ""Outofmemoryallocating"" TIFF_SSIZE_FORMAT ""bytetempbuffer."" , cc0 ) ; return 0 ; } memcpy ( working_copy , bp0 , cc0 ) ; bp = working_copy ; rowsize = sp -> rowsize ; assert ( rowsize > 0 ) ; assert ( ( cc0 % rowsize ) == 0 ) ; while ( cc > 0 ) { ( * sp -> encodepfunc ) ( tif , bp , rowsize ) ; cc -= rowsize ; bp += rowsize ; } result_code = ( * sp -> encodetile ) ( tif , working_copy , cc0 , s ) ; _TIFFfree ( working_copy ) ; return result_code ; } "," 0 ) ; if ( ( cc0 % rowsize ) != 0 ) { TIFFErrorExt ( tif -> tif_clientdata , ""PredictorEncodeTile"" , ""%s"" , ""(cc0%rowsize)!=0"" ) ; return 0 ; } while ( cc ",vadz@libtiff/3ca657a8793dd011bf869695d72ad31c779c3cc1,CVE-2016-9535,https://github.com/vadz/libtiff/commit/3ca657a8793dd011bf869695d72ad31c779c3cc1,2016-11-22T19:59Z 832,CWE-362,"CWE-362 void sctp_generate_proto_unreach_event ( unsigned long data ) { struct sctp_transport * transport = ( struct sctp_transport * ) data ; struct sctp_association * asoc = transport -> asoc ; struct net * net = sock_net ( asoc -> base . sk ) ; bh_lock_sock ( asoc -> base . sk ) ; if ( sock_owned_by_user ( asoc -> base . sk ) ) { pr_debug ( ""%s:sockisbusy\\n"" , __func__ ) ; if ( ! mod_timer ( & transport -> proto_unreach_timer , jiffies + ( HZ / 20 ) ) ) sctp_association_hold ( asoc ) ; goto out_unlock ; } if ( asoc -> base . dead ) goto out_unlock ; sctp_do_sm ( net , SCTP_EVENT_T_OTHER , SCTP_ST_OTHER ( SCTP_EVENT_ICMP_PROTO_UNREACH ) , asoc -> state , asoc -> ep , asoc , transport , GFP_ATOMIC ) ; out_unlock : bh_unlock_sock ( asoc -> base . sk ) ; sctp_association_put ( asoc ) ; } "," asoc ; struct sock * sk = asoc -> base . sk ; struct = sock_net ( sk ) ; ; bh_lock_sock ( sk ) ; ( sock_owned_by_user ( sk ) ) : bh_unlock_sock ( sk ) ; ",torvalds@linux/635682a14427d241bab7bbdeebb48a7d7b91638e,CVE-2015-8767,https://github.com/torvalds/linux/commit/635682a14427d241bab7bbdeebb48a7d7b91638e,2016-02-08T03:59Z 833,CWE-125,"CWE-125 int yr_re_exec ( uint8_t * re_code , uint8_t * input_data , size_t input_size , int flags , RE_MATCH_CALLBACK_FUNC callback , void * callback_args ) { uint8_t * ip ; uint8_t * input ; uint8_t mask ; uint8_t value ; RE_FIBER_LIST fibers ; RE_THREAD_STORAGE * storage ; RE_FIBER * fiber ; RE_FIBER * next_fiber ; int error ; int bytes_matched ; int max_bytes_matched ; int match ; int character_size ; int input_incr ; int kill ; int action ; int result = - 1 ; # define ACTION_NONE 0 # define ACTION_CONTINUE 1 # define ACTION_KILL 2 # define ACTION_KILL_TAIL 3 # define prolog if ( bytes_matched >= max_bytes_matched ) { action = ACTION_KILL ; break ; } # define fail_if_error ( e ) switch ( e ) { case ERROR_INSUFFICIENT_MEMORY : return - 2 ; case ERROR_TOO_MANY_RE_FIBERS : return - 4 ; } if ( _yr_re_alloc_storage ( & storage ) != ERROR_SUCCESS ) return - 2 ; if ( flags & RE_FLAGS_WIDE ) character_size = 2 ; else character_size = 1 ; input = input_data ; input_incr = character_size ; if ( flags & RE_FLAGS_BACKWARDS ) { input -= character_size ; input_incr = - input_incr ; } max_bytes_matched = ( int ) yr_min ( input_size , RE_SCAN_LIMIT ) ; max_bytes_matched = max_bytes_matched - max_bytes_matched % character_size ; bytes_matched = 0 ; error = _yr_re_fiber_create ( & storage -> fiber_pool , & fiber ) ; fail_if_error ( error ) ; fiber -> ip = re_code ; fibers . head = fiber ; fibers . tail = fiber ; error = _yr_re_fiber_sync ( & fibers , & storage -> fiber_pool , fiber ) ; fail_if_error ( error ) ; while ( fibers . head != NULL ) { fiber = fibers . head ; while ( fiber != NULL ) { ip = fiber -> ip ; action = ACTION_NONE ; switch ( * ip ) { case RE_OPCODE_ANY : prolog ; match = ( flags & RE_FLAGS_DOT_ALL ) || ( * input != 0x0A ) ; action = match ? ACTION_NONE : ACTION_KILL ; fiber -> ip += 1 ; break ; case RE_OPCODE_REPEAT_ANY_GREEDY : case RE_OPCODE_REPEAT_ANY_UNGREEDY : prolog ; match = ( flags & RE_FLAGS_DOT_ALL ) || ( * input != 0x0A ) ; action = match ? ACTION_NONE : ACTION_KILL ; break ; case RE_OPCODE_LITERAL : prolog ; if ( flags & RE_FLAGS_NO_CASE ) match = yr_lowercase [ * input ] == yr_lowercase [ * ( ip + 1 ) ] ; else match = ( * input == * ( ip + 1 ) ) ; action = match ? ACTION_NONE : ACTION_KILL ; fiber -> ip += 2 ; break ; case RE_OPCODE_MASKED_LITERAL : prolog ; value = * ( int16_t * ) ( ip + 1 ) & 0xFF ; mask = * ( int16_t * ) ( ip + 1 ) >> 8 ; match = ( ( * input & mask ) == value ) ; action = match ? ACTION_NONE : ACTION_KILL ; fiber -> ip += 3 ; break ; case RE_OPCODE_CLASS : prolog ; match = CHAR_IN_CLASS ( * input , ip + 1 ) ; if ( ! match && ( flags & RE_FLAGS_NO_CASE ) ) match = CHAR_IN_CLASS ( yr_altercase [ * input ] , ip + 1 ) ; action = match ? ACTION_NONE : ACTION_KILL ; fiber -> ip += 33 ; break ; case RE_OPCODE_WORD_CHAR : prolog ; match = IS_WORD_CHAR ( * input ) ; action = match ? ACTION_NONE : ACTION_KILL ; fiber -> ip += 1 ; break ; case RE_OPCODE_NON_WORD_CHAR : prolog ; match = ! IS_WORD_CHAR ( * input ) ; action = match ? ACTION_NONE : ACTION_KILL ; fiber -> ip += 1 ; break ; case RE_OPCODE_SPACE : case RE_OPCODE_NON_SPACE : prolog ; switch ( * input ) { case '' : case '\\t' : case '\\r' : case '\\n' : case '\\v' : case '\\f' : match = TRUE ; break ; default : match = FALSE ; } if ( * ip == RE_OPCODE_NON_SPACE ) match = ! match ; action = match ? ACTION_NONE : ACTION_KILL ; fiber -> ip += 1 ; break ; case RE_OPCODE_DIGIT : prolog ; match = isdigit ( * input ) ; action = match ? ACTION_NONE : ACTION_KILL ; fiber -> ip += 1 ; break ; case RE_OPCODE_NON_DIGIT : prolog ; match = ! isdigit ( * input ) ; action = match ? ACTION_NONE : ACTION_KILL ; fiber -> ip += 1 ; break ; case RE_OPCODE_WORD_BOUNDARY : case RE_OPCODE_NON_WORD_BOUNDARY : if ( bytes_matched == 0 && ! ( flags & RE_FLAGS_NOT_AT_START ) && ! ( flags & RE_FLAGS_BACKWARDS ) ) match = TRUE ; else if ( bytes_matched >= max_bytes_matched ) match = TRUE ; else if ( IS_WORD_CHAR ( * ( input - input_incr ) ) != IS_WORD_CHAR ( * input ) ) match = TRUE ; else match = FALSE ; if ( * ip == RE_OPCODE_NON_WORD_BOUNDARY ) match = ! match ; action = match ? ACTION_CONTINUE : ACTION_KILL ; fiber -> ip += 1 ; break ; case RE_OPCODE_MATCH_AT_START : if ( flags & RE_FLAGS_BACKWARDS ) kill = input_size > ( size_t ) bytes_matched ; else kill = ( flags & RE_FLAGS_NOT_AT_START ) || ( bytes_matched != 0 ) ; action = kill ? ACTION_KILL : ACTION_CONTINUE ; fiber -> ip += 1 ; break ; case RE_OPCODE_MATCH_AT_END : kill = flags & RE_FLAGS_BACKWARDS || input_size > ( size_t ) bytes_matched ; action = kill ? ACTION_KILL : ACTION_CONTINUE ; fiber -> ip += 1 ; break ; case RE_OPCODE_MATCH : result = bytes_matched ; if ( flags & RE_FLAGS_EXHAUSTIVE ) { if ( callback != NULL ) { int cb_result ; if ( flags & RE_FLAGS_BACKWARDS ) cb_result = callback ( input + character_size , bytes_matched , flags , callback_args ) ; else cb_result = callback ( input_data , bytes_matched , flags , callback_args ) ; switch ( cb_result ) { case ERROR_INSUFFICIENT_MEMORY : return - 2 ; case ERROR_TOO_MANY_MATCHES : return - 3 ; default : if ( cb_result != ERROR_SUCCESS ) return - 4 ; } } action = ACTION_KILL ; } else { action = ACTION_KILL_TAIL ; } break ; default : assert ( FALSE ) ; } switch ( action ) { case ACTION_KILL : fiber = _yr_re_fiber_kill ( & fibers , & storage -> fiber_pool , fiber ) ; break ; case ACTION_KILL_TAIL : _yr_re_fiber_kill_tail ( & fibers , & storage -> fiber_pool , fiber ) ; fiber = NULL ; break ; case ACTION_CONTINUE : error = _yr_re_fiber_sync ( & fibers , & storage -> fiber_pool , fiber ) ; fail_if_error ( error ) ; break ; default : next_fiber = fiber -> next ; error = _yr_re_fiber_sync ( & fibers , & storage -> fiber_pool , fiber ) ; fail_if_error ( error ) ; fiber = next_fiber ; } } if ( flags & RE_FLAGS_WIDE && bytes_matched < max_bytes_matched && * ( input + 1 ) != 0 ) { _yr_re_fiber_kill_all ( & fibers , & storage -> fiber_pool ) ; } input += input_incr ; bytes_matched += character_size ; if ( flags & RE_FLAGS_SCAN && bytes_matched < max_bytes_matched ) { error = _yr_re_fiber_create ( & storage -> fiber_pool , & fiber ) ; fail_if_error ( error ) ; fiber -> ip = re_code ; _yr_re_fiber_append ( & fibers , fiber ) ; error = _yr_re_fiber_sync ( & fibers , & storage -> fiber_pool , fiber ) ; fail_if_error ( error ) ; } } return result ; } "," input_data , size_t input_forwards_size , size_t input_backwards_size , int flags # define prolog { if ( ( bytes_matched >= >= max_bytes_matched ) || ( character_size == 2 && * ( input + 1 ) != 0 ) ) { action = ACTION_KILL ; break ; } } # define ( e ) { 4 ; } } RE_FLAGS_BACKWARDS ) { max_bytes_matched = ( int ) yr_min ( input_backwards_size , RE_SCAN_LIMIT ) ; input_incr ; } else { ) yr_min ( input_forwards_size , RE_SCAN_LIMIT ) RE_SCAN_LIMIT ) ; } ; match = _yr_re_is_word_char ( input , character_size ) ; action match = ! _yr_re_is_word_char ( input , character_size ) ; action == 0 && input_backwards_size < character_size ) { match = TRUE = TRUE ; } >= max_bytes_matched ) { = TRUE ; } else { assert ( input < input_data + input_forwards_size ) ; assert ( input >= input_data - input_backwards_size ) ; assert ( input - input - input_incr < input_data + input_forwards_size ) ; assert ( input - input_incr >= input_data - input_backwards_size ) ; match = _yr_re_is_word_char ( input , character_size ) != _yr_re_is_word_char ( input - input_incr , character_size ) ; } if ( * ) kill = input_backwards_size > ( size_t else kill = input_backwards_size > 0 || ( bytes_matched & RE_FLAGS_BACKWARDS || input_forwards_size > ( size_t next_fiber ; } } input += ",VirusTotal@yara/83d799804648c2a0895d40a19835d9b757c6fa4e,CVE-2017-8294,https://github.com/VirusTotal/yara/commit/83d799804648c2a0895d40a19835d9b757c6fa4e,2017-04-27T14:59Z 834,CWE-119,"CWE-119 void vp8_rd_pick_inter_mode ( VP8_COMP * cpi , MACROBLOCK * x , int recon_yoffset , int recon_uvoffset , int * returnrate , int * returndistortion , int * returnintra ) { BLOCK * b = & x -> block [ 0 ] ; BLOCKD * d = & x -> e_mbd . block [ 0 ] ; MACROBLOCKD * xd = & x -> e_mbd ; int_mv best_ref_mv_sb [ 2 ] ; int_mv mode_mv_sb [ 2 ] [ MB_MODE_COUNT ] ; int_mv best_ref_mv ; int_mv * mode_mv ; MB_PREDICTION_MODE this_mode ; int num00 ; int best_mode_index = 0 ; BEST_MODE best_mode ; int i ; int mode_index ; int mdcounts [ 4 ] ; int rate ; RATE_DISTORTION rd ; int uv_intra_rate , uv_intra_distortion , uv_intra_rate_tokenonly ; int uv_intra_tteob = 0 ; int uv_intra_done = 0 ; MB_PREDICTION_MODE uv_intra_mode = 0 ; int_mv mvp ; int near_sadidx [ 8 ] = { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 } ; int saddone = 0 ; int sr = 0 ; unsigned char * plane [ 4 ] [ 3 ] ; int ref_frame_map [ 4 ] ; int sign_bias = 0 ; int intra_rd_penalty = 10 * vp8_dc_quant ( cpi -> common . base_qindex , cpi -> common . y1dc_delta_q ) ; # if CONFIG_TEMPORAL_DENOISING unsigned int zero_mv_sse = INT_MAX , best_sse = INT_MAX , best_rd_sse = INT_MAX ; # endif mode_mv = mode_mv_sb [ sign_bias ] ; best_ref_mv . as_int = 0 ; best_mode . rd = INT_MAX ; best_mode . yrd = INT_MAX ; best_mode . intra_rd = INT_MAX ; vpx_memset ( mode_mv_sb , 0 , sizeof ( mode_mv_sb ) ) ; vpx_memset ( & best_mode . mbmode , 0 , sizeof ( best_mode . mbmode ) ) ; vpx_memset ( & best_mode . bmodes , 0 , sizeof ( best_mode . bmodes ) ) ; get_reference_search_order ( cpi , ref_frame_map ) ; if ( ref_frame_map [ 1 ] > 0 ) { sign_bias = vp8_find_near_mvs_bias ( & x -> e_mbd , x -> e_mbd . mode_info_context , mode_mv_sb , best_ref_mv_sb , mdcounts , ref_frame_map [ 1 ] , cpi -> common . ref_frame_sign_bias ) ; mode_mv = mode_mv_sb [ sign_bias ] ; best_ref_mv . as_int = best_ref_mv_sb [ sign_bias ] . as_int ; } get_predictor_pointers ( cpi , plane , recon_yoffset , recon_uvoffset ) ; * returnintra = INT_MAX ; x -> mbs_tested_so_far ++ ; x -> skip = 0 ; for ( mode_index = 0 ; mode_index < MAX_MODES ; mode_index ++ ) { int this_rd = INT_MAX ; int disable_skip = 0 ; int other_cost = 0 ; int this_ref_frame = ref_frame_map [ vp8_ref_frame_order [ mode_index ] ] ; if ( best_mode . rd <= x -> rd_threshes [ mode_index ] ) continue ; if ( this_ref_frame < 0 ) continue ; rd . rate2 = 0 ; rd . distortion2 = 0 ; this_mode = vp8_mode_order [ mode_index ] ; x -> e_mbd . mode_info_context -> mbmi . mode = this_mode ; x -> e_mbd . mode_info_context -> mbmi . ref_frame = this_ref_frame ; if ( cpi -> is_src_frame_alt_ref && ( cpi -> oxcf . arnr_max_frames == 0 ) ) { if ( this_mode != ZEROMV || x -> e_mbd . mode_info_context -> mbmi . ref_frame != ALTREF_FRAME ) continue ; } if ( x -> e_mbd . mode_info_context -> mbmi . ref_frame ) { x -> e_mbd . pre . y_buffer = plane [ this_ref_frame ] [ 0 ] ; x -> e_mbd . pre . u_buffer = plane [ this_ref_frame ] [ 1 ] ; x -> e_mbd . pre . v_buffer = plane [ this_ref_frame ] [ 2 ] ; if ( sign_bias != cpi -> common . ref_frame_sign_bias [ this_ref_frame ] ) { sign_bias = cpi -> common . ref_frame_sign_bias [ this_ref_frame ] ; mode_mv = mode_mv_sb [ sign_bias ] ; best_ref_mv . as_int = best_ref_mv_sb [ sign_bias ] . as_int ; } } if ( x -> mode_test_hit_counts [ mode_index ] && ( cpi -> mode_check_freq [ mode_index ] > 1 ) ) { if ( x -> mbs_tested_so_far <= cpi -> mode_check_freq [ mode_index ] * x -> mode_test_hit_counts [ mode_index ] ) { x -> rd_thresh_mult [ mode_index ] += 4 ; if ( x -> rd_thresh_mult [ mode_index ] > MAX_THRESHMULT ) x -> rd_thresh_mult [ mode_index ] = MAX_THRESHMULT ; x -> rd_threshes [ mode_index ] = ( cpi -> rd_baseline_thresh [ mode_index ] >> 7 ) * x -> rd_thresh_mult [ mode_index ] ; continue ; } } x -> mode_test_hit_counts [ mode_index ] ++ ; if ( x -> zbin_mode_boost_enabled ) { if ( this_ref_frame == INTRA_FRAME ) x -> zbin_mode_boost = 0 ; else { if ( vp8_mode_order [ mode_index ] == ZEROMV ) { if ( this_ref_frame != LAST_FRAME ) x -> zbin_mode_boost = GF_ZEROMV_ZBIN_BOOST ; else x -> zbin_mode_boost = LF_ZEROMV_ZBIN_BOOST ; } else if ( vp8_mode_order [ mode_index ] == SPLITMV ) x -> zbin_mode_boost = 0 ; else x -> zbin_mode_boost = MV_ZBIN_BOOST ; } vp8_update_zbin_extra ( cpi , x ) ; } if ( ! uv_intra_done && this_ref_frame == INTRA_FRAME ) { rd_pick_intra_mbuv_mode ( x , & uv_intra_rate , & uv_intra_rate_tokenonly , & uv_intra_distortion ) ; uv_intra_mode = x -> e_mbd . mode_info_context -> mbmi . uv_mode ; for ( i = 16 ; i < 24 ; i ++ ) uv_intra_tteob += x -> e_mbd . eobs [ i ] ; uv_intra_done = 1 ; } switch ( this_mode ) { case B_PRED : { int tmp_rd ; int distortion ; tmp_rd = rd_pick_intra4x4mby_modes ( x , & rate , & rd . rate_y , & distortion , best_mode . yrd ) ; rd . rate2 += rate ; rd . distortion2 += distortion ; if ( tmp_rd < best_mode . yrd ) { rd . rate2 += uv_intra_rate ; rd . rate_uv = uv_intra_rate_tokenonly ; rd . distortion2 += uv_intra_distortion ; rd . distortion_uv = uv_intra_distortion ; } else { this_rd = INT_MAX ; disable_skip = 1 ; } } break ; case SPLITMV : { int tmp_rd ; int this_rd_thresh ; int distortion ; this_rd_thresh = ( vp8_ref_frame_order [ mode_index ] == 1 ) ? x -> rd_threshes [ THR_NEW1 ] : x -> rd_threshes [ THR_NEW3 ] ; this_rd_thresh = ( vp8_ref_frame_order [ mode_index ] == 2 ) ? x -> rd_threshes [ THR_NEW2 ] : this_rd_thresh ; tmp_rd = vp8_rd_pick_best_mbsegmentation ( cpi , x , & best_ref_mv , best_mode . yrd , mdcounts , & rate , & rd . rate_y , & distortion , this_rd_thresh ) ; rd . rate2 += rate ; rd . distortion2 += distortion ; if ( tmp_rd < best_mode . yrd ) { rd_inter4x4_uv ( cpi , x , & rd . rate_uv , & rd . distortion_uv , cpi -> common . full_pixel ) ; rd . rate2 += rd . rate_uv ; rd . distortion2 += rd . distortion_uv ; } else { this_rd = INT_MAX ; disable_skip = 1 ; } } break ; case DC_PRED : case V_PRED : case H_PRED : case TM_PRED : { int distortion ; x -> e_mbd . mode_info_context -> mbmi . ref_frame = INTRA_FRAME ; vp8_build_intra_predictors_mby_s ( xd , xd -> dst . y_buffer - xd -> dst . y_stride , xd -> dst . y_buffer - 1 , xd -> dst . y_stride , xd -> predictor , 16 ) ; macro_block_yrd ( x , & rd . rate_y , & distortion ) ; rd . rate2 += rd . rate_y ; rd . distortion2 += distortion ; rd . rate2 += x -> mbmode_cost [ x -> e_mbd . frame_type ] [ x -> e_mbd . mode_info_context -> mbmi . mode ] ; rd . rate2 += uv_intra_rate ; rd . rate_uv = uv_intra_rate_tokenonly ; rd . distortion2 += uv_intra_distortion ; rd . distortion_uv = uv_intra_distortion ; } break ; case NEWMV : { int thissme ; int bestsme = INT_MAX ; int step_param = cpi -> sf . first_step ; int further_steps ; int n ; int do_refine = 1 ; int sadpb = x -> sadperbit16 ; int_mv mvp_full ; int col_min = ( ( best_ref_mv . as_mv . col + 7 ) >> 3 ) - MAX_FULL_PEL_VAL ; int row_min = ( ( best_ref_mv . as_mv . row + 7 ) >> 3 ) - MAX_FULL_PEL_VAL ; int col_max = ( best_ref_mv . as_mv . col >> 3 ) + MAX_FULL_PEL_VAL ; int row_max = ( best_ref_mv . as_mv . row >> 3 ) + MAX_FULL_PEL_VAL ; int tmp_col_min = x -> mv_col_min ; int tmp_col_max = x -> mv_col_max ; int tmp_row_min = x -> mv_row_min ; int tmp_row_max = x -> mv_row_max ; if ( ! saddone ) { vp8_cal_sad ( cpi , xd , x , recon_yoffset , & near_sadidx [ 0 ] ) ; saddone = 1 ; } vp8_mv_pred ( cpi , & x -> e_mbd , x -> e_mbd . mode_info_context , & mvp , x -> e_mbd . mode_info_context -> mbmi . ref_frame , cpi -> common . ref_frame_sign_bias , & sr , & near_sadidx [ 0 ] ) ; mvp_full . as_mv . col = mvp . as_mv . col >> 3 ; mvp_full . as_mv . row = mvp . as_mv . row >> 3 ; if ( x -> mv_col_min < col_min ) x -> mv_col_min = col_min ; if ( x -> mv_col_max > col_max ) x -> mv_col_max = col_max ; if ( x -> mv_row_min < row_min ) x -> mv_row_min = row_min ; if ( x -> mv_row_max > row_max ) x -> mv_row_max = row_max ; if ( sr > step_param ) step_param = sr ; { bestsme = cpi -> diamond_search_sad ( x , b , d , & mvp_full , & d -> bmi . mv , step_param , sadpb , & num00 , & cpi -> fn_ptr [ BLOCK_16X16 ] , x -> mvcost , & best_ref_mv ) ; mode_mv [ NEWMV ] . as_int = d -> bmi . mv . as_int ; n = 0 ; further_steps = ( cpi -> sf . max_step_search_steps - 1 ) - step_param ; n = num00 ; num00 = 0 ; if ( n > further_steps ) do_refine = 0 ; while ( n < further_steps ) { n ++ ; if ( num00 ) num00 -- ; else { thissme = cpi -> diamond_search_sad ( x , b , d , & mvp_full , & d -> bmi . mv , step_param + n , sadpb , & num00 , & cpi -> fn_ptr [ BLOCK_16X16 ] , x -> mvcost , & best_ref_mv ) ; if ( num00 > ( further_steps - n ) ) do_refine = 0 ; if ( thissme < bestsme ) { bestsme = thissme ; mode_mv [ NEWMV ] . as_int = d -> bmi . mv . as_int ; } else { d -> bmi . mv . as_int = mode_mv [ NEWMV ] . as_int ; } } } } if ( do_refine == 1 ) { int search_range ; search_range = 8 ; thissme = cpi -> refining_search_sad ( x , b , d , & d -> bmi . mv , sadpb , search_range , & cpi -> fn_ptr [ BLOCK_16X16 ] , x -> mvcost , & best_ref_mv ) ; if ( thissme < bestsme ) { bestsme = thissme ; mode_mv [ NEWMV ] . as_int = d -> bmi . mv . as_int ; } else { d -> bmi . mv . as_int = mode_mv [ NEWMV ] . as_int ; } } x -> mv_col_min = tmp_col_min ; x -> mv_col_max = tmp_col_max ; x -> mv_row_min = tmp_row_min ; x -> mv_row_max = tmp_row_max ; if ( bestsme < INT_MAX ) { int dis ; unsigned int sse ; cpi -> find_fractional_mv_step ( x , b , d , & d -> bmi . mv , & best_ref_mv , x -> errorperbit , & cpi -> fn_ptr [ BLOCK_16X16 ] , x -> mvcost , & dis , & sse ) ; } mode_mv [ NEWMV ] . as_int = d -> bmi . mv . as_int ; rd . rate2 += vp8_mv_bit_cost ( & mode_mv [ NEWMV ] , & best_ref_mv , x -> mvcost , 96 ) ; } case NEARESTMV : case NEARMV : vp8_clamp_mv2 ( & mode_mv [ this_mode ] , xd ) ; if ( ( ( this_mode == NEARMV ) || ( this_mode == NEARESTMV ) ) && ( mode_mv [ this_mode ] . as_int == 0 ) ) continue ; case ZEROMV : if ( ( ( mode_mv [ this_mode ] . as_mv . row >> 3 ) < x -> mv_row_min ) || ( ( mode_mv [ this_mode ] . as_mv . row >> 3 ) > x -> mv_row_max ) || ( ( mode_mv [ this_mode ] . as_mv . col >> 3 ) < x -> mv_col_min ) || ( ( mode_mv [ this_mode ] . as_mv . col >> 3 ) > x -> mv_col_max ) ) continue ; vp8_set_mbmode_and_mvs ( x , this_mode , & mode_mv [ this_mode ] ) ; this_rd = evaluate_inter_mode_rd ( mdcounts , & rd , & disable_skip , cpi , x ) ; break ; default : break ; } this_rd = calculate_final_rd_costs ( this_rd , & rd , & other_cost , disable_skip , uv_intra_tteob , intra_rd_penalty , cpi , x ) ; if ( ( x -> e_mbd . mode_info_context -> mbmi . ref_frame == INTRA_FRAME ) && ( this_rd < best_mode . intra_rd ) ) { best_mode . intra_rd = this_rd ; * returnintra = rd . distortion2 ; } # if CONFIG_TEMPORAL_DENOISING if ( cpi -> oxcf . noise_sensitivity ) { unsigned int sse ; vp8_get_inter_mbpred_error ( x , & cpi -> fn_ptr [ BLOCK_16X16 ] , & sse , mode_mv [ this_mode ] ) ; if ( sse < best_rd_sse ) best_rd_sse = sse ; if ( this_mode == ZEROMV && sse < zero_mv_sse ) { zero_mv_sse = sse ; x -> best_zeromv_reference_frame = x -> e_mbd . mode_info_context -> mbmi . ref_frame ; } if ( x -> e_mbd . mode_info_context -> mbmi . mode == NEWMV && sse < best_sse ) { best_sse = sse ; vp8_get_inter_mbpred_error ( x , & cpi -> fn_ptr [ BLOCK_16X16 ] , & best_sse , mode_mv [ this_mode ] ) ; x -> best_sse_inter_mode = NEWMV ; x -> best_sse_mv = x -> e_mbd . mode_info_context -> mbmi . mv ; x -> need_to_clamp_best_mvs = x -> e_mbd . mode_info_context -> mbmi . need_to_clamp_mvs ; x -> best_reference_frame = x -> e_mbd . mode_info_context -> mbmi . ref_frame ; } } # endif if ( this_rd < best_mode . rd || x -> skip ) { best_mode_index = mode_index ; * returnrate = rd . rate2 ; * returndistortion = rd . distortion2 ; if ( this_mode <= B_PRED ) { x -> e_mbd . mode_info_context -> mbmi . uv_mode = uv_intra_mode ; x -> e_mbd . mode_info_context -> mbmi . mv . as_int = 0 ; } update_best_mode ( & best_mode , this_rd , & rd , other_cost , x ) ; x -> rd_thresh_mult [ mode_index ] = ( x -> rd_thresh_mult [ mode_index ] >= ( MIN_THRESHMULT + 2 ) ) ? x -> rd_thresh_mult [ mode_index ] - 2 : MIN_THRESHMULT ; } else { x -> rd_thresh_mult [ mode_index ] += 4 ; if ( x -> rd_thresh_mult [ mode_index ] > MAX_THRESHMULT ) x -> rd_thresh_mult [ mode_index ] = MAX_THRESHMULT ; } x -> rd_threshes [ mode_index ] = ( cpi -> rd_baseline_thresh [ mode_index ] >> 7 ) * x -> rd_thresh_mult [ mode_index ] ; if ( x -> skip ) break ; } if ( ( cpi -> rd_baseline_thresh [ best_mode_index ] > 0 ) && ( cpi -> rd_baseline_thresh [ best_mode_index ] < ( INT_MAX >> 2 ) ) ) { int best_adjustment = ( x -> rd_thresh_mult [ best_mode_index ] >> 2 ) ; x -> rd_thresh_mult [ best_mode_index ] = ( x -> rd_thresh_mult [ best_mode_index ] >= ( MIN_THRESHMULT + best_adjustment ) ) ? x -> rd_thresh_mult [ best_mode_index ] - best_adjustment : MIN_THRESHMULT ; x -> rd_threshes [ best_mode_index ] = ( cpi -> rd_baseline_thresh [ best_mode_index ] >> 7 ) * x -> rd_thresh_mult [ best_mode_index ] ; } # if CONFIG_TEMPORAL_DENOISING if ( cpi -> oxcf . noise_sensitivity ) { if ( x -> best_sse_inter_mode == DC_PRED ) { x -> best_sse_inter_mode = best_mode . mbmode . mode ; x -> best_sse_mv = best_mode . mbmode . mv ; x -> need_to_clamp_best_mvs = best_mode . mbmode . need_to_clamp_mvs ; x -> best_reference_frame = best_mode . mbmode . ref_frame ; best_sse = best_rd_sse ; } vp8_denoiser_denoise_mb ( & cpi -> denoiser , x , best_sse , zero_mv_sse , recon_yoffset , recon_uvoffset ) ; if ( best_mode . mbmode . ref_frame == INTRA_FRAME && x -> best_zeromv_reference_frame != INTRA_FRAME ) { int this_rd = INT_MAX ; int disable_skip = 0 ; int other_cost = 0 ; int this_ref_frame = x -> best_zeromv_reference_frame ; rd . rate2 = x -> ref_frame_cost [ this_ref_frame ] + vp8_cost_mv_ref ( ZEROMV , mdcounts ) ; rd . distortion2 = 0 ; x -> e_mbd . mode_info_context -> mbmi . ref_frame = this_ref_frame ; x -> e_mbd . pre . y_buffer = plane [ this_ref_frame ] [ 0 ] ; x -> e_mbd . pre . u_buffer = plane [ this_ref_frame ] [ 1 ] ; x -> e_mbd . pre . v_buffer = plane [ this_ref_frame ] [ 2 ] ; x -> e_mbd . mode_info_context -> mbmi . mode = ZEROMV ; x -> e_mbd . mode_info_context -> mbmi . uv_mode = DC_PRED ; x -> e_mbd . mode_info_context -> mbmi . mv . as_int = 0 ; this_rd = evaluate_inter_mode_rd ( mdcounts , & rd , & disable_skip , cpi , x ) ; this_rd = calculate_final_rd_costs ( this_rd , & rd , & other_cost , disable_skip , uv_intra_tteob , intra_rd_penalty , cpi , x ) ; if ( this_rd < best_mode . rd || x -> skip ) { best_mode_index = mode_index ; * returnrate = rd . rate2 ; * returndistortion = rd . distortion2 ; update_best_mode ( & best_mode , this_rd , & rd , other_cost , x ) ; } } } # endif if ( cpi -> is_src_frame_alt_ref && ( best_mode . mbmode . mode != ZEROMV || best_mode . mbmode . ref_frame != ALTREF_FRAME ) ) { x -> e_mbd . mode_info_context -> mbmi . mode = ZEROMV ; x -> e_mbd . mode_info_context -> mbmi . ref_frame = ALTREF_FRAME ; x -> e_mbd . mode_info_context -> mbmi . mv . as_int = 0 ; x -> e_mbd . mode_info_context -> mbmi . uv_mode = DC_PRED ; x -> e_mbd . mode_info_context -> mbmi . mb_skip_coeff = ( cpi -> common . mb_no_coeff_skip ) ; x -> e_mbd . mode_info_context -> mbmi . partitioning = 0 ; return ; } vpx_memcpy ( & x -> e_mbd . mode_info_context -> mbmi , & best_mode . mbmode , sizeof ( MB_MODE_INFO ) ) ; if ( best_mode . mbmode . mode == B_PRED ) { for ( i = 0 ; i < 16 ; i ++ ) xd -> mode_info_context -> bmi [ i ] . as_mode = best_mode . bmodes [ i ] . as_mode ; } if ( best_mode . mbmode . mode == SPLITMV ) { for ( i = 0 ; i < 16 ; i ++ ) xd -> mode_info_context -> bmi [ i ] . mv . as_int = best_mode . bmodes [ i ] . mv . as_int ; vpx_memcpy ( x -> partition_info , & best_mode . partition , sizeof ( PARTITION_INFO ) ) ; x -> e_mbd . mode_info_context -> mbmi . mv . as_int = x -> partition_info -> bmi [ 15 ] . mv . as_int ; } if ( sign_bias != cpi -> common . ref_frame_sign_bias [ xd -> mode_info_context -> mbmi . ref_frame ] ) best_ref_mv . as_int = best_ref_mv_sb [ ! sign_bias ] . as_int ; rd_update_mvcount ( x , & best_ref_mv ) ; } "," int * returnintra , int mb_row , int mb_col int zero_mv_sse = UINT_MAX , best_sse = , best_sse = UINT_MAX , best_rd_sse = , best_rd_sse = UINT_MAX ; # endif = INT_MAX ; memset ( mode_mv_sb , ) ) ; memset ( & best_mode ) ) ; memset ( & best_mode mv . as_int ; further_steps = noise_sensitivity ) { int block_index = mb_row * cpi -> common . mb_cols + mb_col ; recon_yoffset , recon_uvoffset , & cpi -> common . lf_info , mb_row , mb_col , block_index skip ) { * returnrate = return ; } memcpy ( & x . as_int ; memcpy ( x -> ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 835,CWE-399,"CWE-399 static void init_vmcb ( struct vcpu_svm * svm ) { struct vmcb_control_area * control = & svm -> vmcb -> control ; struct vmcb_save_area * save = & svm -> vmcb -> save ; svm -> vcpu . fpu_active = 1 ; svm -> vcpu . arch . hflags = 0 ; set_cr_intercept ( svm , INTERCEPT_CR0_READ ) ; set_cr_intercept ( svm , INTERCEPT_CR3_READ ) ; set_cr_intercept ( svm , INTERCEPT_CR4_READ ) ; set_cr_intercept ( svm , INTERCEPT_CR0_WRITE ) ; set_cr_intercept ( svm , INTERCEPT_CR3_WRITE ) ; set_cr_intercept ( svm , INTERCEPT_CR4_WRITE ) ; set_cr_intercept ( svm , INTERCEPT_CR8_WRITE ) ; set_dr_intercepts ( svm ) ; set_exception_intercept ( svm , PF_VECTOR ) ; set_exception_intercept ( svm , UD_VECTOR ) ; set_exception_intercept ( svm , MC_VECTOR ) ; set_intercept ( svm , INTERCEPT_INTR ) ; set_intercept ( svm , INTERCEPT_NMI ) ; set_intercept ( svm , INTERCEPT_SMI ) ; set_intercept ( svm , INTERCEPT_SELECTIVE_CR0 ) ; set_intercept ( svm , INTERCEPT_RDPMC ) ; set_intercept ( svm , INTERCEPT_CPUID ) ; set_intercept ( svm , INTERCEPT_INVD ) ; set_intercept ( svm , INTERCEPT_HLT ) ; set_intercept ( svm , INTERCEPT_INVLPG ) ; set_intercept ( svm , INTERCEPT_INVLPGA ) ; set_intercept ( svm , INTERCEPT_IOIO_PROT ) ; set_intercept ( svm , INTERCEPT_MSR_PROT ) ; set_intercept ( svm , INTERCEPT_TASK_SWITCH ) ; set_intercept ( svm , INTERCEPT_SHUTDOWN ) ; set_intercept ( svm , INTERCEPT_VMRUN ) ; set_intercept ( svm , INTERCEPT_VMMCALL ) ; set_intercept ( svm , INTERCEPT_VMLOAD ) ; set_intercept ( svm , INTERCEPT_VMSAVE ) ; set_intercept ( svm , INTERCEPT_STGI ) ; set_intercept ( svm , INTERCEPT_CLGI ) ; set_intercept ( svm , INTERCEPT_SKINIT ) ; set_intercept ( svm , INTERCEPT_WBINVD ) ; set_intercept ( svm , INTERCEPT_MONITOR ) ; set_intercept ( svm , INTERCEPT_MWAIT ) ; set_intercept ( svm , INTERCEPT_XSETBV ) ; control -> iopm_base_pa = iopm_base ; control -> msrpm_base_pa = __pa ( svm -> msrpm ) ; control -> int_ctl = V_INTR_MASKING_MASK ; init_seg ( & save -> es ) ; init_seg ( & save -> ss ) ; init_seg ( & save -> ds ) ; init_seg ( & save -> fs ) ; init_seg ( & save -> gs ) ; save -> cs . selector = 0xf000 ; save -> cs . base = 0xffff0000 ; save -> cs . attrib = SVM_SELECTOR_READ_MASK | SVM_SELECTOR_P_MASK | SVM_SELECTOR_S_MASK | SVM_SELECTOR_CODE_MASK ; save -> cs . limit = 0xffff ; save -> gdtr . limit = 0xffff ; save -> idtr . limit = 0xffff ; init_sys_seg ( & save -> ldtr , SEG_TYPE_LDT ) ; init_sys_seg ( & save -> tr , SEG_TYPE_BUSY_TSS16 ) ; svm_set_efer ( & svm -> vcpu , 0 ) ; save -> dr6 = 0xffff0ff0 ; kvm_set_rflags ( & svm -> vcpu , 2 ) ; save -> rip = 0x0000fff0 ; svm -> vcpu . arch . regs [ VCPU_REGS_RIP ] = save -> rip ; svm_set_cr0 ( & svm -> vcpu , X86_CR0_NW | X86_CR0_CD | X86_CR0_ET ) ; kvm_mmu_reset_context ( & svm -> vcpu ) ; save -> cr4 = X86_CR4_PAE ; if ( npt_enabled ) { control -> nested_ctl = 1 ; clr_intercept ( svm , INTERCEPT_INVLPG ) ; clr_exception_intercept ( svm , PF_VECTOR ) ; clr_cr_intercept ( svm , INTERCEPT_CR3_READ ) ; clr_cr_intercept ( svm , INTERCEPT_CR3_WRITE ) ; save -> g_pat = svm -> vcpu . arch . pat ; save -> cr3 = 0 ; save -> cr4 = 0 ; } svm -> asid_generation = 0 ; svm -> nested . vmcb = 0 ; svm -> vcpu . arch . hflags = 0 ; if ( boot_cpu_has ( X86_FEATURE_PAUSEFILTER ) ) { control -> pause_filter_count = 3000 ; set_intercept ( svm , INTERCEPT_PAUSE ) ; } mark_all_dirty ( svm -> vmcb ) ; enable_gif ( svm ) ; } "," svm , MC_VECTOR ) ; set_exception_intercept ( svm , AC_VECTOR ",torvalds@linux/54a20552e1eae07aa240fa370a0293e006b5faed,CVE-2015-5307,https://github.com/torvalds/linux/commit/54a20552e1eae07aa240fa370a0293e006b5faed,2015-11-16T11:59Z 836,CWE-119,"CWE-119 hive_h * hivex_open ( const char * filename , int flags ) { hive_h * h = NULL ; assert ( sizeof ( struct ntreg_header ) == 0x1000 ) ; assert ( offsetof ( struct ntreg_header , csum ) == 0x1fc ) ; h = calloc ( 1 , sizeof * h ) ; if ( h == NULL ) goto error ; h -> msglvl = flags & HIVEX_OPEN_MSGLVL_MASK ; const char * debug = getenv ( ""HIVEX_DEBUG"" ) ; if ( debug && STREQ ( debug , ""1"" ) ) h -> msglvl = 2 ; DEBUG ( 2 , ""createdhandle%p"" , h ) ; h -> writable = ! ! ( flags & HIVEX_OPEN_WRITE ) ; h -> filename = strdup ( filename ) ; if ( h -> filename == NULL ) goto error ; # ifdef O_CLOEXEC h -> fd = open ( filename , O_RDONLY | O_CLOEXEC | O_BINARY ) ; # else h -> fd = open ( filename , O_RDONLY | O_BINARY ) ; # endif if ( h -> fd == - 1 ) goto error ; # ifndef O_CLOEXEC fcntl ( h -> fd , F_SETFD , FD_CLOEXEC ) ; # endif struct stat statbuf ; if ( fstat ( h -> fd , & statbuf ) == - 1 ) goto error ; h -> size = statbuf . st_size ; if ( ! h -> writable ) { h -> addr = mmap ( NULL , h -> size , PROT_READ , MAP_SHARED , h -> fd , 0 ) ; if ( h -> addr == MAP_FAILED ) goto error ; DEBUG ( 2 , ""mappedfileat%p"" , h -> addr ) ; } else { h -> addr = malloc ( h -> size ) ; if ( h -> addr == NULL ) goto error ; if ( full_read ( h -> fd , h -> addr , h -> size ) < h -> size ) goto error ; if ( close ( h -> fd ) == - 1 ) goto error ; h -> fd = - 1 ; } if ( h -> hdr -> magic [ 0 ] != 'r' || h -> hdr -> magic [ 1 ] != 'e' || h -> hdr -> magic [ 2 ] != 'g' || h -> hdr -> magic [ 3 ] != 'f' ) { SET_ERRNO ( ENOTSUP , ""%s:notaWindowsNTRegistryhivefile"" , filename ) ; goto error ; } uint32_t major_ver = le32toh ( h -> hdr -> major_ver ) ; if ( major_ver != 1 ) { SET_ERRNO ( ENOTSUP , ""%s:hivefilemajorversion%"" PRIu32 ""(expected1)"" , filename , major_ver ) ; goto error ; } h -> bitmap = calloc ( 1 + h -> size / 32 , 1 ) ; if ( h -> bitmap == NULL ) goto error ; uint32_t sum = header_checksum ( h ) ; if ( sum != le32toh ( h -> hdr -> csum ) ) { SET_ERRNO ( EINVAL , ""%s:badchecksuminhiveheader"" , filename ) ; goto error ; } h -> last_modified = le64toh ( ( int64_t ) h -> hdr -> last_modified ) ; if ( h -> msglvl >= 2 ) { char * name = _hivex_windows_utf16_to_utf8 ( h -> hdr -> name , 64 ) ; fprintf ( stderr , ""hivex_open:headerfields:\\n"" ""fileversion%"" PRIu32 "".%"" PRIu32 ""\\n"" ""sequencenos%"" PRIu32 ""%"" PRIu32 ""\\n"" ""(sequencesnosshouldmatchifhivewassynchedatshutdown)\\n"" ""lastmodified%"" PRIu64 ""\\n"" ""(Windowsfiletime,x100nssince1601-01-01)\\n"" ""originalfilename%s\\n"" ""(only32charsarestored,nameisprobablytruncated)\\n"" ""rootoffset0x%x+0x1000\\n"" ""endoflastpage0x%x+0x1000(totalfilesize0x%zx)\\n"" ""checksum0x%x(calculated0x%x)\\n"" , major_ver , le32toh ( h -> hdr -> minor_ver ) , le32toh ( h -> hdr -> sequence1 ) , le32toh ( h -> hdr -> sequence2 ) , h -> last_modified , name ? name : ""(conversionfailed)"" , le32toh ( h -> hdr -> offset ) , le32toh ( h -> hdr -> blocks ) , h -> size , le32toh ( h -> hdr -> csum ) , sum ) ; free ( name ) ; } h -> rootoffs = le32toh ( h -> hdr -> offset ) + 0x1000 ; h -> endpages = le32toh ( h -> hdr -> blocks ) + 0x1000 ; DEBUG ( 2 , ""rootoffset=0x%zx"" , h -> rootoffs ) ; int seen_root_block = 0 , bad_root_block = 0 ; size_t pages = 0 ; size_t smallest_page = SIZE_MAX , largest_page = 0 ; size_t blocks = 0 ; size_t smallest_block = SIZE_MAX , largest_block = 0 , blocks_bytes = 0 ; size_t used_blocks = 0 ; size_t used_size = 0 ; size_t off ; struct ntreg_hbin_page * page ; for ( off = 0x1000 ; off < h -> size ; off += le32toh ( page -> page_size ) ) { if ( off >= h -> endpages ) break ; page = ( struct ntreg_hbin_page * ) ( ( char * ) h -> addr + off ) ; if ( page -> magic [ 0 ] != 'h' || page -> magic [ 1 ] != 'b' || page -> magic [ 2 ] != 'i' || page -> magic [ 3 ] != 'n' ) { SET_ERRNO ( ENOTSUP , ""%s:trailinggarbageatendoffile"" ""(at0x%zx,after%zupages)"" , filename , off , pages ) ; goto error ; } size_t page_size = le32toh ( page -> page_size ) ; DEBUG ( 2 , ""pageat0x%zx,size%zu"" , off , page_size ) ; pages ++ ; if ( page_size < smallest_page ) smallest_page = page_size ; if ( page_size > largest_page ) largest_page = page_size ; if ( page_size <= sizeof ( struct ntreg_hbin_page ) || ( page_size & 0x0fff ) != 0 ) { SET_ERRNO ( ENOTSUP , ""%s:pagesize%zuat0x%zx,badregistry"" , filename , page_size , off ) ; goto error ; } size_t blkoff ; struct ntreg_hbin_block * block ; size_t seg_len ; for ( blkoff = off + 0x20 ; blkoff < off + page_size ; blkoff += seg_len ) { blocks ++ ; int is_root = blkoff == h -> rootoffs ; if ( is_root ) seen_root_block = 1 ; block = ( struct ntreg_hbin_block * ) ( ( char * ) h -> addr + blkoff ) ; int used ; seg_len = block_len ( h , blkoff , & used ) ; if ( seg_len <= 4 || ( seg_len & 3 ) != 0 ) { SET_ERRNO ( ENOTSUP , ""%s:blocksize%"" PRIu32 ""at0x%zx,badregistry"" , filename , le32toh ( block -> seg_len ) , blkoff ) ; goto error ; } if ( h -> msglvl >= 2 ) { unsigned char * id = ( unsigned char * ) block -> id ; int id0 = id [ 0 ] , id1 = id [ 1 ] ; fprintf ( stderr , ""%s:%s:"" ""%sblockid%d,%d(%c%c)at0x%zxsize%zu%s\\n"" , ""hivex"" , __func__ , used ? ""used"" : ""free"" , id0 , id1 , c_isprint ( id0 ) ? id0 : '.' , c_isprint ( id1 ) ? id1 : '.' , blkoff , seg_len , is_root ? ""(root)"" : """" ) ; } blocks_bytes += seg_len ; if ( seg_len < smallest_block ) smallest_block = seg_len ; if ( seg_len > largest_block ) largest_block = seg_len ; if ( is_root && ! used ) bad_root_block = 1 ; if ( used ) { used_blocks ++ ; used_size += seg_len ; if ( is_root && ( block -> id [ 0 ] != 'n' || block -> id [ 1 ] != 'k' ) ) bad_root_block = 1 ; BITMAP_SET ( h -> bitmap , blkoff ) ; } } } if ( ! seen_root_block ) { SET_ERRNO ( ENOTSUP , ""%s:norootblockfound"" , filename ) ; goto error ; } if ( bad_root_block ) { SET_ERRNO ( ENOTSUP , ""%s:badrootblock(freeornotnk)"" , filename ) ; goto error ; } DEBUG ( 1 , ""successfullyreadWindowsRegistryhivefile:\\n"" ""pages:%zu[sml:%zu,lge:%zu]\\n"" ""blocks:%zu[sml:%zu,avg:%zu,lge:%zu]\\n"" ""blocksused:%zu\\n"" ""bytesused:%zu"" , pages , smallest_page , largest_page , blocks , smallest_block , blocks_bytes / blocks , largest_block , used_blocks , used_size ) ; return h ; error : ; int err = errno ; if ( h ) { free ( h -> bitmap ) ; if ( h -> addr && h -> size && h -> addr != MAP_FAILED ) { if ( ! h -> writable ) munmap ( h -> addr , h -> size ) ; else free ( h -> addr ) ; } if ( h -> fd >= 0 ) close ( h -> fd ) ; free ( h -> filename ) ; free ( h ) ; } errno = err ; return NULL ; } "," . st_size ; if ( h -> size < 0x2000 ) { SET_ERRNO ( EINVAL , ""%s:fileistoosmalltobeaWindowsNTRegistryhivefile"" , filename ) ; goto error ; } ",libguestfs@hivex/357f26fa64fd1d9ccac2331fe174a8ee9c607adb,CVE-2014-9273,https://github.com/libguestfs/hivex/commit/357f26fa64fd1d9ccac2331fe174a8ee9c607adb,2014-12-08T16:59Z 837,CWE-119,"CWE-119 private int cdf_file_summary_info ( struct magic_set * ms , const cdf_header_t * h , const cdf_stream_t * sst , const uint64_t clsid [ 2 ] ) { cdf_summary_info_header_t si ; cdf_property_info_t * info ; size_t count ; int m ; if ( cdf_unpack_summary_info ( sst , h , & si , & info , & count ) == - 1 ) return - 1 ; if ( NOTMIME ( ms ) ) { const char * str ; if ( file_printf ( ms , ""CompositeDocumentFileV2Document"" ) == - 1 ) return - 1 ; if ( file_printf ( ms , "",%sEndian"" , si . si_byte_order == 0xfffe ? ""Little"" : ""Big"" ) == - 1 ) return - 2 ; switch ( si . si_os ) { case 2 : if ( file_printf ( ms , "",Os:Windows,Version%d.%d"" , si . si_os_version & 0xff , ( uint32_t ) si . si_os_version >> 8 ) == - 1 ) return - 2 ; break ; case 1 : if ( file_printf ( ms , "",Os:MacOS,Version%d.%d"" , ( uint32_t ) si . si_os_version >> 8 , si . si_os_version & 0xff ) == - 1 ) return - 2 ; break ; default : if ( file_printf ( ms , "",Os%d,Version:%d.%d"" , si . si_os , si . si_os_version & 0xff , ( uint32_t ) si . si_os_version >> 8 ) == - 1 ) return - 2 ; break ; } str = cdf_clsid_to_mime ( clsid , clsid2desc ) ; if ( str ) if ( file_printf ( ms , "",%s"" , str ) == - 1 ) return - 2 ; } m = cdf_file_property_info ( ms , info , count , clsid ) ; free ( info ) ; return m == - 1 ? - 2 : m ; } "," sst , const cdf_directory_t * root_storage ) { cdf_summary_info_header_t break ; } if ( root_storage ) { = cdf_clsid_to_mime ( root_storage -> d_storage_uuid , clsid2desc ) - 2 ; } , count , root_storage ) ; free ",file@file/6d209c1c489457397a5763bca4b28e43aac90391,CVE-2014-0207,https://github.com/file/file/commit/6d209c1c489457397a5763bca4b28e43aac90391,2014-07-09T11:07Z 838,CWE-200,"CWE-200 WORD32 ih264d_parse_sps ( dec_struct_t * ps_dec , dec_bit_stream_t * ps_bitstrm ) { UWORD8 i ; dec_seq_params_t * ps_seq = NULL ; UWORD8 u1_profile_idc , u1_level_idc , u1_seq_parameter_set_id ; UWORD16 i2_max_frm_num ; UWORD32 * pu4_bitstrm_buf = ps_bitstrm -> pu4_buffer ; UWORD32 * pu4_bitstrm_ofst = & ps_bitstrm -> u4_ofst ; UWORD8 u1_frm , uc_constraint_set0_flag , uc_constraint_set1_flag ; WORD32 i4_cropped_ht , i4_cropped_wd ; UWORD32 u4_temp ; WORD32 pic_height_in_map_units_minus1 = 0 ; UWORD32 u2_pic_wd = 0 ; UWORD32 u2_pic_ht = 0 ; UWORD32 u2_frm_wd_y = 0 ; UWORD32 u2_frm_ht_y = 0 ; UWORD32 u2_frm_wd_uv = 0 ; UWORD32 u2_frm_ht_uv = 0 ; UWORD32 u2_crop_offset_y = 0 ; UWORD32 u2_crop_offset_uv = 0 ; WORD32 ret ; UWORD32 u4_num_reorder_frames ; WORD32 i4_i ; UWORD8 u1_frame_cropping_flag , u1_frame_cropping_rect_left_ofst , u1_frame_cropping_rect_right_ofst , u1_frame_cropping_rect_top_ofst , u1_frame_cropping_rect_bottom_ofst ; SWITCHONTRACE ; u1_profile_idc = ih264d_get_bits_h264 ( ps_bitstrm , 8 ) ; COPYTHECONTEXT ( ""SPS:profile_idc"" , u1_profile_idc ) ; uc_constraint_set0_flag = ih264d_get_bit_h264 ( ps_bitstrm ) ; uc_constraint_set1_flag = ih264d_get_bit_h264 ( ps_bitstrm ) ; ih264d_get_bit_h264 ( ps_bitstrm ) ; ih264d_get_bits_h264 ( ps_bitstrm , 5 ) ; if ( ( u1_profile_idc != MAIN_PROFILE_IDC ) && ( u1_profile_idc != BASE_PROFILE_IDC ) && ( u1_profile_idc != HIGH_PROFILE_IDC ) ) { if ( ( u1_profile_idc != EXTENDED_PROFILE_IDC ) || ( ( uc_constraint_set1_flag != 1 ) && ( uc_constraint_set0_flag != 1 ) ) ) { return ( ERROR_FEATURE_UNAVAIL ) ; } } u1_level_idc = ih264d_get_bits_h264 ( ps_bitstrm , 8 ) ; COPYTHECONTEXT ( ""SPS:u4_level_idc"" , u1_level_idc ) ; u4_temp = ih264d_uev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; if ( u4_temp & MASK_ERR_SEQ_SET_ID ) return ERROR_INV_SPS_PPS_T ; u1_seq_parameter_set_id = u4_temp ; COPYTHECONTEXT ( ""SPS:seq_parameter_set_id"" , u1_seq_parameter_set_id ) ; ps_seq = ps_dec -> pv_scratch_sps_pps ; if ( ps_dec -> i4_header_decoded & 1 ) { * ps_seq = * ps_dec -> ps_cur_sps ; } if ( ( ps_dec -> i4_header_decoded & 1 ) && ( ps_seq -> u1_profile_idc != u1_profile_idc ) ) { ps_dec -> u1_res_changed = 1 ; return IVD_RES_CHANGED ; } if ( ( ps_dec -> i4_header_decoded & 1 ) && ( ps_seq -> u1_level_idc != u1_level_idc ) ) { ps_dec -> u1_res_changed = 1 ; return IVD_RES_CHANGED ; } ps_seq -> u1_profile_idc = u1_profile_idc ; ps_seq -> u1_level_idc = u1_level_idc ; ps_seq -> u1_seq_parameter_set_id = u1_seq_parameter_set_id ; ps_seq -> i4_chroma_format_idc = 1 ; ps_seq -> i4_bit_depth_luma_minus8 = 0 ; ps_seq -> i4_bit_depth_chroma_minus8 = 0 ; ps_seq -> i4_qpprime_y_zero_transform_bypass_flag = 0 ; ps_seq -> i4_seq_scaling_matrix_present_flag = 0 ; if ( u1_profile_idc == HIGH_PROFILE_IDC ) { ps_seq -> i4_chroma_format_idc = ih264d_uev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; if ( ps_seq -> i4_chroma_format_idc != 1 ) { return ERROR_INV_SPS_PPS_T ; } ps_seq -> i4_bit_depth_luma_minus8 = ih264d_uev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; if ( ps_seq -> i4_bit_depth_luma_minus8 != 0 ) { return ERROR_INV_SPS_PPS_T ; } ps_seq -> i4_bit_depth_chroma_minus8 = ih264d_uev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; if ( ps_seq -> i4_bit_depth_chroma_minus8 != 0 ) { return ERROR_INV_SPS_PPS_T ; } ps_seq -> i4_qpprime_y_zero_transform_bypass_flag = ( WORD32 ) ih264d_get_bit_h264 ( ps_bitstrm ) ; if ( ps_seq -> i4_qpprime_y_zero_transform_bypass_flag != 0 ) { return ERROR_INV_SPS_PPS_T ; } ps_seq -> i4_seq_scaling_matrix_present_flag = ( WORD32 ) ih264d_get_bit_h264 ( ps_bitstrm ) ; if ( ps_seq -> i4_seq_scaling_matrix_present_flag ) { for ( i4_i = 0 ; i4_i < 8 ; i4_i ++ ) { ps_seq -> u1_seq_scaling_list_present_flag [ i4_i ] = ih264d_get_bit_h264 ( ps_bitstrm ) ; ps_seq -> u1_use_default_scaling_matrix_flag [ i4_i ] = 0 ; if ( ps_seq -> u1_seq_scaling_list_present_flag [ i4_i ] ) { if ( i4_i < 6 ) { ih264d_scaling_list ( ps_seq -> i2_scalinglist4x4 [ i4_i ] , 16 , & ps_seq -> u1_use_default_scaling_matrix_flag [ i4_i ] , ps_bitstrm ) ; } else { ih264d_scaling_list ( ps_seq -> i2_scalinglist8x8 [ i4_i - 6 ] , 64 , & ps_seq -> u1_use_default_scaling_matrix_flag [ i4_i ] , ps_bitstrm ) ; } } } } } u4_temp = 4 + ih264d_uev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; if ( u4_temp > MAX_BITS_IN_FRAME_NUM ) { return ERROR_INV_SPS_PPS_T ; } ps_seq -> u1_bits_in_frm_num = u4_temp ; COPYTHECONTEXT ( ""SPS:log2_max_frame_num_minus4"" , ( ps_seq -> u1_bits_in_frm_num - 4 ) ) ; i2_max_frm_num = ( 1 << ( ps_seq -> u1_bits_in_frm_num ) ) ; ps_seq -> u2_u4_max_pic_num_minus1 = i2_max_frm_num - 1 ; u4_temp = ih264d_uev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; if ( u4_temp > MAX_PIC_ORDER_CNT_TYPE ) { return ERROR_INV_POC_TYPE_T ; } ps_seq -> u1_pic_order_cnt_type = u4_temp ; COPYTHECONTEXT ( ""SPS:pic_order_cnt_type"" , ps_seq -> u1_pic_order_cnt_type ) ; ps_seq -> u1_num_ref_frames_in_pic_order_cnt_cycle = 1 ; if ( ps_seq -> u1_pic_order_cnt_type == 0 ) { u4_temp = 4 + ih264d_uev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; if ( u4_temp > MAX_BITS_IN_POC_LSB ) { return ERROR_INV_SPS_PPS_T ; } ps_seq -> u1_log2_max_pic_order_cnt_lsb_minus = u4_temp ; ps_seq -> i4_max_pic_order_cntLsb = ( 1 << u4_temp ) ; COPYTHECONTEXT ( ""SPS:log2_max_pic_order_cnt_lsb_minus4"" , ( u4_temp - 4 ) ) ; } else if ( ps_seq -> u1_pic_order_cnt_type == 1 ) { ps_seq -> u1_delta_pic_order_always_zero_flag = ih264d_get_bit_h264 ( ps_bitstrm ) ; COPYTHECONTEXT ( ""SPS:delta_pic_order_always_zero_flag"" , ps_seq -> u1_delta_pic_order_always_zero_flag ) ; ps_seq -> i4_ofst_for_non_ref_pic = ih264d_sev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; COPYTHECONTEXT ( ""SPS:offset_for_non_ref_pic"" , ps_seq -> i4_ofst_for_non_ref_pic ) ; ps_seq -> i4_ofst_for_top_to_bottom_field = ih264d_sev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; COPYTHECONTEXT ( ""SPS:offset_for_top_to_bottom_field"" , ps_seq -> i4_ofst_for_top_to_bottom_field ) ; u4_temp = ih264d_uev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; if ( u4_temp > 255 ) return ERROR_INV_SPS_PPS_T ; ps_seq -> u1_num_ref_frames_in_pic_order_cnt_cycle = u4_temp ; COPYTHECONTEXT ( ""SPS:num_ref_frames_in_pic_order_cnt_cycle"" , ps_seq -> u1_num_ref_frames_in_pic_order_cnt_cycle ) ; for ( i = 0 ; i < ps_seq -> u1_num_ref_frames_in_pic_order_cnt_cycle ; i ++ ) { ps_seq -> i4_ofst_for_ref_frame [ i ] = ih264d_sev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; COPYTHECONTEXT ( ""SPS:offset_for_ref_frame"" , ps_seq -> i4_ofst_for_ref_frame [ i ] ) ; } } u4_temp = ih264d_uev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; if ( ( u4_temp > H264_MAX_REF_PICS ) ) { return ERROR_NUM_REF ; } if ( ( ps_dec -> i4_header_decoded & 1 ) && ( ps_seq -> u1_num_ref_frames != u4_temp ) ) { ps_dec -> u1_res_changed = 1 ; return IVD_RES_CHANGED ; } ps_seq -> u1_num_ref_frames = u4_temp ; COPYTHECONTEXT ( ""SPS:num_ref_frames"" , ps_seq -> u1_num_ref_frames ) ; ps_seq -> u1_gaps_in_frame_num_value_allowed_flag = ih264d_get_bit_h264 ( ps_bitstrm ) ; COPYTHECONTEXT ( ""SPS:gaps_in_frame_num_value_allowed_flag"" , ps_seq -> u1_gaps_in_frame_num_value_allowed_flag ) ; ps_seq -> u2_frm_wd_in_mbs = 1 + ih264d_uev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; COPYTHECONTEXT ( ""SPS:pic_width_in_mbs_minus1"" , ps_seq -> u2_frm_wd_in_mbs - 1 ) ; u2_pic_wd = ( ps_seq -> u2_frm_wd_in_mbs << 4 ) ; pic_height_in_map_units_minus1 = ih264d_uev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; ps_seq -> u2_frm_ht_in_mbs = 1 + pic_height_in_map_units_minus1 ; u2_pic_ht = ( ps_seq -> u2_frm_ht_in_mbs << 4 ) ; ps_seq -> u2_max_mb_addr = ( ps_seq -> u2_frm_wd_in_mbs * ps_seq -> u2_frm_ht_in_mbs ) - 1 ; ps_seq -> u2_total_num_of_mbs = ps_seq -> u2_max_mb_addr + 1 ; ps_seq -> u1_level_idc = ih264d_correct_level_idc ( u1_level_idc , ps_seq -> u2_total_num_of_mbs ) ; u1_frm = ih264d_get_bit_h264 ( ps_bitstrm ) ; if ( ( ps_dec -> i4_header_decoded & 1 ) && ( ps_seq -> u1_frame_mbs_only_flag != u1_frm ) ) { ps_dec -> u1_res_changed = 1 ; return IVD_RES_CHANGED ; } ps_seq -> u1_frame_mbs_only_flag = u1_frm ; COPYTHECONTEXT ( ""SPS:frame_mbs_only_flag"" , u1_frm ) ; if ( ! u1_frm ) { u2_pic_ht <<= 1 ; ps_seq -> u1_mb_aff_flag = ih264d_get_bit_h264 ( ps_bitstrm ) ; COPYTHECONTEXT ( ""SPS:mb_adaptive_frame_field_flag"" , ps_seq -> u1_mb_aff_flag ) ; } else ps_seq -> u1_mb_aff_flag = 0 ; ps_seq -> u1_direct_8x8_inference_flag = ih264d_get_bit_h264 ( ps_bitstrm ) ; COPYTHECONTEXT ( ""SPS:direct_8x8_inference_flag"" , ps_seq -> u1_direct_8x8_inference_flag ) ; u1_frame_cropping_flag = ih264d_get_bit_h264 ( ps_bitstrm ) ; COPYTHECONTEXT ( ""SPS:frame_cropping_flag"" , u1_frame_cropping_flag ) ; if ( u1_frame_cropping_flag ) { u1_frame_cropping_rect_left_ofst = ih264d_uev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; COPYTHECONTEXT ( ""SPS:frame_cropping_rect_left_offset"" , u1_frame_cropping_rect_left_ofst ) ; u1_frame_cropping_rect_right_ofst = ih264d_uev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; COPYTHECONTEXT ( ""SPS:frame_cropping_rect_right_offset"" , u1_frame_cropping_rect_right_ofst ) ; u1_frame_cropping_rect_top_ofst = ih264d_uev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; COPYTHECONTEXT ( ""SPS:frame_cropping_rect_top_offset"" , u1_frame_cropping_rect_top_ofst ) ; u1_frame_cropping_rect_bottom_ofst = ih264d_uev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; COPYTHECONTEXT ( ""SPS:frame_cropping_rect_bottom_offset"" , u1_frame_cropping_rect_bottom_ofst ) ; } ps_seq -> u1_vui_parameters_present_flag = ih264d_get_bit_h264 ( ps_bitstrm ) ; COPYTHECONTEXT ( ""SPS:vui_parameters_present_flag"" , ps_seq -> u1_vui_parameters_present_flag ) ; u2_frm_wd_y = u2_pic_wd + ( UWORD8 ) ( PAD_LEN_Y_H << 1 ) ; if ( 1 == ps_dec -> u4_share_disp_buf ) { if ( ps_dec -> u4_app_disp_width > u2_frm_wd_y ) u2_frm_wd_y = ps_dec -> u4_app_disp_width ; } u2_frm_ht_y = u2_pic_ht + ( UWORD8 ) ( PAD_LEN_Y_V << 2 ) ; u2_frm_wd_uv = u2_pic_wd + ( UWORD8 ) ( PAD_LEN_UV_H << 2 ) ; u2_frm_wd_uv = MAX ( u2_frm_wd_uv , u2_frm_wd_y ) ; u2_frm_ht_uv = ( u2_pic_ht >> 1 ) + ( UWORD8 ) ( PAD_LEN_UV_V << 2 ) ; u2_frm_ht_uv = MAX ( u2_frm_ht_uv , ( u2_frm_ht_y >> 1 ) ) ; { UWORD16 u2_rgt_ofst = 0 ; UWORD16 u2_lft_ofst = 0 ; UWORD16 u2_top_ofst = 0 ; UWORD16 u2_btm_ofst = 0 ; UWORD8 u1_frm_mbs_flag ; UWORD8 u1_vert_mult_factor ; if ( u1_frame_cropping_flag ) { u2_rgt_ofst = u1_frame_cropping_rect_right_ofst << 1 ; u2_lft_ofst = u1_frame_cropping_rect_left_ofst << 1 ; u1_frm_mbs_flag = ( 1 == ps_seq -> u1_frame_mbs_only_flag ) ; u1_vert_mult_factor = ( 2 - u1_frm_mbs_flag ) ; u2_btm_ofst = ( u1_frame_cropping_rect_bottom_ofst << u1_vert_mult_factor ) ; u2_top_ofst = ( u1_frame_cropping_rect_top_ofst << u1_vert_mult_factor ) ; } u2_crop_offset_y = ( u2_frm_wd_y * u2_top_ofst ) + ( u2_lft_ofst ) ; u2_crop_offset_uv = ( u2_frm_wd_uv * ( u2_top_ofst >> 1 ) ) + ( u2_lft_ofst >> 1 ) * YUV420SP_FACTOR ; i4_cropped_ht = u2_pic_ht - ( u2_btm_ofst + u2_top_ofst ) ; i4_cropped_wd = u2_pic_wd - ( u2_rgt_ofst + u2_lft_ofst ) ; if ( ( i4_cropped_ht < MB_SIZE ) || ( i4_cropped_wd < MB_SIZE ) ) { return ERROR_INV_SPS_PPS_T ; } if ( ( ps_dec -> i4_header_decoded & 1 ) && ( ps_dec -> u2_pic_wd != u2_pic_wd ) ) { ps_dec -> u1_res_changed = 1 ; return IVD_RES_CHANGED ; } if ( ( ps_dec -> i4_header_decoded & 1 ) && ( ps_dec -> u2_pic_ht != u2_pic_ht ) ) { ps_dec -> u1_res_changed = 1 ; return IVD_RES_CHANGED ; } if ( ( u2_pic_wd > H264_MAX_FRAME_WIDTH ) || ( u2_pic_ht > H264_MAX_FRAME_HEIGHT ) || ( u2_pic_wd < H264_MIN_FRAME_WIDTH ) || ( u2_pic_ht < H264_MIN_FRAME_HEIGHT ) || ( u2_pic_wd * ( UWORD32 ) u2_pic_ht > H264_MAX_FRAME_SIZE ) ) { return IVD_STREAM_WIDTH_HEIGHT_NOT_SUPPORTED ; } if ( ( u2_pic_wd << ps_seq -> u1_mb_aff_flag ) > H264_MAX_FRAME_WIDTH ) { return IVD_STREAM_WIDTH_HEIGHT_NOT_SUPPORTED ; } } if ( ( ps_dec -> i4_header_decoded & 1 ) && ( 1 == ps_seq -> u1_vui_parameters_present_flag ) && ( 1 == ps_seq -> s_vui . u1_bitstream_restriction_flag ) ) { u4_num_reorder_frames = ps_seq -> s_vui . u4_num_reorder_frames ; } else { u4_num_reorder_frames = - 1 ; } if ( 1 == ps_seq -> u1_vui_parameters_present_flag ) { ret = ih264d_parse_vui_parametres ( & ps_seq -> s_vui , ps_bitstrm ) ; if ( ret != OK ) return ret ; } if ( ( ps_dec -> i4_header_decoded & 1 ) && ( - 1 != ( WORD32 ) u4_num_reorder_frames ) && ( 1 == ps_seq -> u1_vui_parameters_present_flag ) && ( 1 == ps_seq -> s_vui . u1_bitstream_restriction_flag ) && ( ps_seq -> s_vui . u4_num_reorder_frames != u4_num_reorder_frames ) ) { ps_dec -> u1_res_changed = 1 ; return IVD_RES_CHANGED ; } if ( ps_bitstrm -> u4_ofst > ps_bitstrm -> u4_max_ofst ) { return ERROR_INV_SPS_PPS_T ; } ps_dec -> u2_disp_height = i4_cropped_ht ; ps_dec -> u2_disp_width = i4_cropped_wd ; ps_dec -> u2_pic_wd = u2_pic_wd ; ps_dec -> u2_pic_ht = u2_pic_ht ; ps_dec -> u2_frm_wd_y = u2_frm_wd_y ; ps_dec -> u2_frm_ht_y = u2_frm_ht_y ; ps_dec -> u2_frm_wd_uv = u2_frm_wd_uv ; ps_dec -> u2_frm_ht_uv = u2_frm_ht_uv ; ps_dec -> s_pad_mgr . u1_pad_len_y_v = ( UWORD8 ) ( PAD_LEN_Y_V << ( 1 - u1_frm ) ) ; ps_dec -> s_pad_mgr . u1_pad_len_cr_v = ( UWORD8 ) ( PAD_LEN_UV_V << ( 1 - u1_frm ) ) ; ps_dec -> u2_frm_wd_in_mbs = ps_seq -> u2_frm_wd_in_mbs ; ps_dec -> u2_frm_ht_in_mbs = ps_seq -> u2_frm_ht_in_mbs ; ps_dec -> u2_crop_offset_y = u2_crop_offset_y ; ps_dec -> u2_crop_offset_uv = u2_crop_offset_uv ; ps_seq -> u1_is_valid = TRUE ; ps_dec -> ps_sps [ u1_seq_parameter_set_id ] = * ps_seq ; ps_dec -> ps_cur_sps = & ps_dec -> ps_sps [ u1_seq_parameter_set_id ] ; return OK ; } "," u1_level_idc , u1_seq_parameter_set_id , u1_mb_aff_flag = 0 ! u1_frm ) u1_mb_aff_flag = ih264d_get_bit_h264 ( ps_bitstrm ) ; if ( ( ps_dec -> i4_header_decoded & 1 ) && ( ps_seq -> u1_mb_aff_flag != u1_mb_aff_flag ) ) { ps_dec -> u1_res_changed = 1 ; return IVD_RES_CHANGED ; } if ( ! u1_frm ) -> u1_mb_aff_flag = u1_mb_aff_flag ; COPYTHECONTEXT ( ",external@libavc/42cf02965b11c397dd37a0063e683cef005bc0ae,CVE-2017-13204,https://android.googlesource.com/platform/external/libavc/+/42cf02965b11c397dd37a0063e683cef005bc0ae,2018-01-12T23:29Z 839,CWE-200,"CWE-200 static int do_video_set_spu_palette ( unsigned int fd , unsigned int cmd , struct compat_video_spu_palette __user * up ) { struct video_spu_palette __user * up_native ; compat_uptr_t palp ; int length , err ; err = get_user ( palp , & up -> palette ) ; err |= get_user ( length , & up -> length ) ; up_native = compat_alloc_user_space ( sizeof ( struct video_spu_palette ) ) ; err = put_user ( compat_ptr ( palp ) , & up_native -> palette ) ; err |= put_user ( length , & up_native -> length ) ; if ( err ) return - EFAULT ; err = sys_ioctl ( fd , cmd , ( unsigned long ) up_native ) ; return err ; } "," -> length ) ; if ( err ) return - EFAULT ",torvalds@linux/12176503366885edd542389eed3aaf94be163fdb,CVE-2013-1928,https://github.com/torvalds/linux/commit/12176503366885edd542389eed3aaf94be163fdb,2013-04-29T14:55Z 840,CWE-119,"CWE-119 static vpx_codec_err_t ctrl_set_svc_parameters ( vpx_codec_alg_priv_t * ctx , int ctr_id , va_list args ) { VP9_COMP * const cpi = ctx -> cpi ; vpx_svc_parameters_t * const params = va_arg ( args , vpx_svc_parameters_t * ) ; if ( params == NULL ) return VPX_CODEC_INVALID_PARAM ; cpi -> svc . spatial_layer_id = params -> spatial_layer ; cpi -> svc . temporal_layer_id = params -> temporal_layer ; cpi -> lst_fb_idx = params -> lst_fb_idx ; cpi -> gld_fb_idx = params -> gld_fb_idx ; cpi -> alt_fb_idx = params -> alt_fb_idx ; if ( vp9_set_size_literal ( ctx -> cpi , params -> width , params -> height ) != 0 ) return VPX_CODEC_INVALID_PARAM ; ctx -> cfg . rc_max_quantizer = params -> max_quantizer ; ctx -> cfg . rc_min_quantizer = params -> min_quantizer ; set_encoder_config ( & ctx -> oxcf , & ctx -> cfg , & ctx -> extra_cfg ) ; vp9_change_config ( ctx -> cpi , & ctx -> oxcf ) ; return VPX_CODEC_OK ; } "," * ctx , va_list args ) -> cpi ; vpx_svc_extra_cfg_t * const params ( args , vpx_svc_extra_cfg_t * ) ; * ) ; int sl , tl ; for ( sl = 0 ; sl < cpi -> svc -> svc . number_spatial_layers ; ++ sl ) { for ( tl = 0 ; tl < cpi -> svc -> svc . number_temporal_layers ; ++ tl ) { const int layer = LAYER_IDS_TO_IDX ( sl , tl , cpi -> svc . number_temporal_layers ) ; LAYER_CONTEXT * lc = & cpi -> svc . layer_context [ layer ] ; lc -> max_q = params -> = params -> max_quantizers [ sl ] ; lc -> min_q = params -> = params -> min_quantizers [ sl ] ; lc -> scaling_factor_num = params -> = params -> scaling_factor_num [ sl ] ; lc -> scaling_factor_den = params -> = params -> scaling_factor_den [ sl ] ; } } return VPX_CODEC_OK ; ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 841,CWE-000,"CWE-000 static int ip6_frag_queue ( struct frag_queue * fq , struct sk_buff * skb , struct frag_hdr * fhdr , int nhoff ) { struct sk_buff * prev , * next ; struct net_device * dev ; int offset , end ; struct net * net = dev_net ( skb_dst ( skb ) -> dev ) ; if ( fq -> q . last_in & INET_FRAG_COMPLETE ) goto err ; offset = ntohs ( fhdr -> frag_off ) & ~ 0x7 ; end = offset + ( ntohs ( ipv6_hdr ( skb ) -> payload_len ) - ( ( u8 * ) ( fhdr + 1 ) - ( u8 * ) ( ipv6_hdr ( skb ) + 1 ) ) ) ; if ( ( unsigned int ) end > IPV6_MAXPLEN ) { IP6_INC_STATS_BH ( net , ip6_dst_idev ( skb_dst ( skb ) ) , IPSTATS_MIB_INHDRERRORS ) ; icmpv6_param_prob ( skb , ICMPV6_HDR_FIELD , ( ( u8 * ) & fhdr -> frag_off - skb_network_header ( skb ) ) ) ; return - 1 ; } if ( skb -> ip_summed == CHECKSUM_COMPLETE ) { const unsigned char * nh = skb_network_header ( skb ) ; skb -> csum = csum_sub ( skb -> csum , csum_partial ( nh , ( u8 * ) ( fhdr + 1 ) - nh , 0 ) ) ; } if ( ! ( fhdr -> frag_off & htons ( IP6_MF ) ) ) { if ( end < fq -> q . len || ( ( fq -> q . last_in & INET_FRAG_LAST_IN ) && end != fq -> q . len ) ) goto err ; fq -> q . last_in |= INET_FRAG_LAST_IN ; fq -> q . len = end ; } else { if ( end & 0x7 ) { IP6_INC_STATS_BH ( net , ip6_dst_idev ( skb_dst ( skb ) ) , IPSTATS_MIB_INHDRERRORS ) ; icmpv6_param_prob ( skb , ICMPV6_HDR_FIELD , offsetof ( struct ipv6hdr , payload_len ) ) ; return - 1 ; } if ( end > fq -> q . len ) { if ( fq -> q . last_in & INET_FRAG_LAST_IN ) goto err ; fq -> q . len = end ; } } if ( end == offset ) goto err ; if ( ! pskb_pull ( skb , ( u8 * ) ( fhdr + 1 ) - skb -> data ) ) goto err ; if ( pskb_trim_rcsum ( skb , end - offset ) ) goto err ; prev = fq -> q . fragments_tail ; if ( ! prev || FRAG6_CB ( prev ) -> offset < offset ) { next = NULL ; goto found ; } prev = NULL ; for ( next = fq -> q . fragments ; next != NULL ; next = next -> next ) { if ( FRAG6_CB ( next ) -> offset >= offset ) break ; prev = next ; } found : if ( prev ) { int i = ( FRAG6_CB ( prev ) -> offset + prev -> len ) - offset ; if ( i > 0 ) { offset += i ; if ( end <= offset ) goto err ; if ( ! pskb_pull ( skb , i ) ) goto err ; if ( skb -> ip_summed != CHECKSUM_UNNECESSARY ) skb -> ip_summed = CHECKSUM_NONE ; } } while ( next && FRAG6_CB ( next ) -> offset < end ) { int i = end - FRAG6_CB ( next ) -> offset ; if ( i < next -> len ) { if ( ! pskb_pull ( next , i ) ) goto err ; FRAG6_CB ( next ) -> offset += i ; fq -> q . meat -= i ; if ( next -> ip_summed != CHECKSUM_UNNECESSARY ) next -> ip_summed = CHECKSUM_NONE ; break ; } else { struct sk_buff * free_it = next ; next = next -> next ; if ( prev ) prev -> next = next ; else fq -> q . fragments = next ; fq -> q . meat -= free_it -> len ; frag_kfree_skb ( fq -> q . net , free_it ) ; } } FRAG6_CB ( skb ) -> offset = offset ; skb -> next = next ; if ( ! next ) fq -> q . fragments_tail = skb ; if ( prev ) prev -> next = skb ; else fq -> q . fragments = skb ; dev = skb -> dev ; if ( dev ) { fq -> iif = dev -> ifindex ; skb -> dev = NULL ; } fq -> q . stamp = skb -> tstamp ; fq -> q . meat += skb -> len ; atomic_add ( skb -> truesize , & fq -> q . net -> mem ) ; if ( offset == 0 ) { fq -> nhoffset = nhoff ; fq -> q . last_in |= INET_FRAG_FIRST_IN ; } if ( fq -> q . last_in == ( INET_FRAG_FIRST_IN | INET_FRAG_LAST_IN ) && fq -> q . meat == fq -> q . len ) return ip6_frag_reasm ( fq , prev , dev ) ; write_lock ( & ip6_frags . lock ) ; list_move_tail ( & fq -> q . lru_list , & fq -> q . net -> lru_list ) ; write_unlock ( & ip6_frags . lock ) ; return - 1 ; err : IP6_INC_STATS ( net , ip6_dst_idev ( skb_dst ( skb ) ) , IPSTATS_MIB_REASMFAILS ) ; kfree_skb ( skb ) ; return - 1 ; } "," if ( prev && ( FRAG6_CB ( ) - offset > 0 ) > 0 ) goto discard_fq ; if ( next && < end ) goto discard_fq ; FRAG6_CB ( skb - 1 ; discard_fq : fq_kill ( fq ) ; ",torvalds@linux/70789d7052239992824628db8133de08dc78e593,CVE-2012-4444,https://github.com/torvalds/linux/commit/70789d7052239992824628db8133de08dc78e593,2012-12-21T11:47Z 842,CWE-190,"CWE-190 static int tiffcp ( TIFF * in , TIFF * out ) { uint16 bitspersample , samplesperpixel ; uint16 input_compression , input_photometric ; copyFunc cf ; uint32 width , length ; struct cpTag * p ; CopyField ( TIFFTAG_IMAGEWIDTH , width ) ; CopyField ( TIFFTAG_IMAGELENGTH , length ) ; CopyField ( TIFFTAG_BITSPERSAMPLE , bitspersample ) ; CopyField ( TIFFTAG_SAMPLESPERPIXEL , samplesperpixel ) ; if ( compression != ( uint16 ) - 1 ) TIFFSetField ( out , TIFFTAG_COMPRESSION , compression ) ; else CopyField ( TIFFTAG_COMPRESSION , compression ) ; TIFFGetFieldDefaulted ( in , TIFFTAG_COMPRESSION , & input_compression ) ; TIFFGetFieldDefaulted ( in , TIFFTAG_PHOTOMETRIC , & input_photometric ) ; if ( input_compression == COMPRESSION_JPEG ) { TIFFSetField ( in , TIFFTAG_JPEGCOLORMODE , JPEGCOLORMODE_RGB ) ; } else if ( input_photometric == PHOTOMETRIC_YCBCR ) { uint16 subsamplinghor , subsamplingver ; TIFFGetFieldDefaulted ( in , TIFFTAG_YCBCRSUBSAMPLING , & subsamplinghor , & subsamplingver ) ; if ( subsamplinghor != 1 || subsamplingver != 1 ) { fprintf ( stderr , ""tiffcp:%s:Can\'tcopy/convertsubsampledimage.\\n"" , TIFFFileName ( in ) ) ; return FALSE ; } } if ( compression == COMPRESSION_JPEG ) { if ( input_photometric == PHOTOMETRIC_RGB && jpegcolormode == JPEGCOLORMODE_RGB ) TIFFSetField ( out , TIFFTAG_PHOTOMETRIC , PHOTOMETRIC_YCBCR ) ; else TIFFSetField ( out , TIFFTAG_PHOTOMETRIC , input_photometric ) ; } else if ( compression == COMPRESSION_SGILOG || compression == COMPRESSION_SGILOG24 ) TIFFSetField ( out , TIFFTAG_PHOTOMETRIC , samplesperpixel == 1 ? PHOTOMETRIC_LOGL : PHOTOMETRIC_LOGLUV ) ; else if ( input_compression == COMPRESSION_JPEG && samplesperpixel == 3 ) { TIFFSetField ( out , TIFFTAG_PHOTOMETRIC , PHOTOMETRIC_RGB ) ; } else CopyTag ( TIFFTAG_PHOTOMETRIC , 1 , TIFF_SHORT ) ; if ( fillorder != 0 ) TIFFSetField ( out , TIFFTAG_FILLORDER , fillorder ) ; else CopyTag ( TIFFTAG_FILLORDER , 1 , TIFF_SHORT ) ; TIFFGetFieldDefaulted ( in , TIFFTAG_ORIENTATION , & orientation ) ; switch ( orientation ) { case ORIENTATION_BOTRIGHT : case ORIENTATION_RIGHTBOT : TIFFWarning ( TIFFFileName ( in ) , ""usingbottom-leftorientation"" ) ; orientation = ORIENTATION_BOTLEFT ; case ORIENTATION_LEFTBOT : case ORIENTATION_BOTLEFT : break ; case ORIENTATION_TOPRIGHT : case ORIENTATION_RIGHTTOP : default : TIFFWarning ( TIFFFileName ( in ) , ""usingtop-leftorientation"" ) ; orientation = ORIENTATION_TOPLEFT ; case ORIENTATION_LEFTTOP : case ORIENTATION_TOPLEFT : break ; } TIFFSetField ( out , TIFFTAG_ORIENTATION , orientation ) ; if ( outtiled == - 1 ) outtiled = TIFFIsTiled ( in ) ; if ( outtiled ) { if ( tilewidth == ( uint32 ) - 1 ) TIFFGetField ( in , TIFFTAG_TILEWIDTH , & tilewidth ) ; if ( tilelength == ( uint32 ) - 1 ) TIFFGetField ( in , TIFFTAG_TILELENGTH , & tilelength ) ; TIFFDefaultTileSize ( out , & tilewidth , & tilelength ) ; TIFFSetField ( out , TIFFTAG_TILEWIDTH , tilewidth ) ; TIFFSetField ( out , TIFFTAG_TILELENGTH , tilelength ) ; } else { if ( rowsperstrip == ( uint32 ) 0 ) { if ( ! TIFFGetField ( in , TIFFTAG_ROWSPERSTRIP , & rowsperstrip ) ) { rowsperstrip = TIFFDefaultStripSize ( out , rowsperstrip ) ; } if ( rowsperstrip > length && rowsperstrip != ( uint32 ) - 1 ) rowsperstrip = length ; } else if ( rowsperstrip == ( uint32 ) - 1 ) rowsperstrip = length ; TIFFSetField ( out , TIFFTAG_ROWSPERSTRIP , rowsperstrip ) ; } if ( config != ( uint16 ) - 1 ) TIFFSetField ( out , TIFFTAG_PLANARCONFIG , config ) ; else CopyField ( TIFFTAG_PLANARCONFIG , config ) ; if ( samplesperpixel <= 4 ) CopyTag ( TIFFTAG_TRANSFERFUNCTION , 4 , TIFF_SHORT ) ; CopyTag ( TIFFTAG_COLORMAP , 4 , TIFF_SHORT ) ; switch ( compression ) { case COMPRESSION_JPEG : TIFFSetField ( out , TIFFTAG_JPEGQUALITY , quality ) ; TIFFSetField ( out , TIFFTAG_JPEGCOLORMODE , jpegcolormode ) ; break ; case COMPRESSION_JBIG : CopyTag ( TIFFTAG_FAXRECVPARAMS , 1 , TIFF_LONG ) ; CopyTag ( TIFFTAG_FAXRECVTIME , 1 , TIFF_LONG ) ; CopyTag ( TIFFTAG_FAXSUBADDRESS , 1 , TIFF_ASCII ) ; CopyTag ( TIFFTAG_FAXDCS , 1 , TIFF_ASCII ) ; break ; case COMPRESSION_LZW : case COMPRESSION_ADOBE_DEFLATE : case COMPRESSION_DEFLATE : case COMPRESSION_LZMA : if ( predictor != ( uint16 ) - 1 ) TIFFSetField ( out , TIFFTAG_PREDICTOR , predictor ) ; else CopyField ( TIFFTAG_PREDICTOR , predictor ) ; if ( preset != - 1 ) { if ( compression == COMPRESSION_ADOBE_DEFLATE || compression == COMPRESSION_DEFLATE ) TIFFSetField ( out , TIFFTAG_ZIPQUALITY , preset ) ; else if ( compression == COMPRESSION_LZMA ) TIFFSetField ( out , TIFFTAG_LZMAPRESET , preset ) ; } break ; case COMPRESSION_CCITTFAX3 : case COMPRESSION_CCITTFAX4 : if ( compression == COMPRESSION_CCITTFAX3 ) { if ( g3opts != ( uint32 ) - 1 ) TIFFSetField ( out , TIFFTAG_GROUP3OPTIONS , g3opts ) ; else CopyField ( TIFFTAG_GROUP3OPTIONS , g3opts ) ; } else CopyTag ( TIFFTAG_GROUP4OPTIONS , 1 , TIFF_LONG ) ; CopyTag ( TIFFTAG_BADFAXLINES , 1 , TIFF_LONG ) ; CopyTag ( TIFFTAG_CLEANFAXDATA , 1 , TIFF_LONG ) ; CopyTag ( TIFFTAG_CONSECUTIVEBADFAXLINES , 1 , TIFF_LONG ) ; CopyTag ( TIFFTAG_FAXRECVPARAMS , 1 , TIFF_LONG ) ; CopyTag ( TIFFTAG_FAXRECVTIME , 1 , TIFF_LONG ) ; CopyTag ( TIFFTAG_FAXSUBADDRESS , 1 , TIFF_ASCII ) ; break ; } { uint32 len32 ; void * * data ; if ( TIFFGetField ( in , TIFFTAG_ICCPROFILE , & len32 , & data ) ) TIFFSetField ( out , TIFFTAG_ICCPROFILE , len32 , data ) ; } { uint16 ninks ; const char * inknames ; if ( TIFFGetField ( in , TIFFTAG_NUMBEROFINKS , & ninks ) ) { TIFFSetField ( out , TIFFTAG_NUMBEROFINKS , ninks ) ; if ( TIFFGetField ( in , TIFFTAG_INKNAMES , & inknames ) ) { int inknameslen = strlen ( inknames ) + 1 ; const char * cp = inknames ; while ( ninks > 1 ) { cp = strchr ( cp , '\\0' ) ; cp ++ ; inknameslen += ( strlen ( cp ) + 1 ) ; ninks -- ; } TIFFSetField ( out , TIFFTAG_INKNAMES , inknameslen , inknames ) ; } } } { unsigned short pg0 , pg1 ; if ( pageInSeq == 1 ) { if ( pageNum < 0 ) { if ( TIFFGetField ( in , TIFFTAG_PAGENUMBER , & pg0 , & pg1 ) ) TIFFSetField ( out , TIFFTAG_PAGENUMBER , pg0 , pg1 ) ; } else TIFFSetField ( out , TIFFTAG_PAGENUMBER , pageNum ++ , 0 ) ; } else { if ( TIFFGetField ( in , TIFFTAG_PAGENUMBER , & pg0 , & pg1 ) ) { if ( pageNum < 0 ) TIFFSetField ( out , TIFFTAG_PAGENUMBER , pg0 , pg1 ) ; else TIFFSetField ( out , TIFFTAG_PAGENUMBER , pageNum ++ , 0 ) ; } } } for ( p = tags ; p < & tags [ NTAGS ] ; p ++ ) CopyTag ( p -> tag , p -> count , p -> type ) ; cf = pickCopyFunc ( in , out , bitspersample , samplesperpixel ) ; return ( cf ? ( * cf ) ( in , out , length , width , samplesperpixel ) : FALSE ) ; } "," bitspersample , samplesperpixel = 1 input_compression , input_photometric = PHOTOMETRIC_MINISBLACK ",vadz@libtiff/43c0b81a818640429317c80fea1e66771e85024b,CVE-2016-9538,https://github.com/vadz/libtiff/commit/43c0b81a818640429317c80fea1e66771e85024b#diff-c8b4b355f9b5c06d585b23138e1c185f,2016-11-22T19:59Z 843,CWE-20,"CWE-20 static int check_symlinks ( struct archive_write_disk * a ) { # if ! defined ( HAVE_LSTAT ) ( void ) a ; return ( ARCHIVE_OK ) ; # else char * pn ; char c ; int r ; struct stat st ; pn = a -> name ; if ( archive_strlen ( & ( a -> path_safe ) ) > 0 ) { char * p = a -> path_safe . s ; while ( ( * pn != '\\0' ) && ( * p == * pn ) ) ++ p , ++ pn ; } if ( pn == a -> name && pn [ 0 ] == '/' ) ++ pn ; c = pn [ 0 ] ; while ( pn [ 0 ] != '\\0' && ( pn [ 0 ] != '/' || pn [ 1 ] != '\\0' ) ) { while ( * pn != '\\0' && * pn != '/' ) ++ pn ; c = pn [ 0 ] ; pn [ 0 ] = '\\0' ; r = lstat ( a -> name , & st ) ; if ( r != 0 ) { if ( errno == ENOENT ) { break ; } else { return ( ARCHIVE_FAILED ) ; } } else if ( S_ISLNK ( st . st_mode ) ) { if ( c == '\\0' ) { if ( unlink ( a -> name ) ) { archive_set_error ( & a -> archive , errno , ""Couldnotremovesymlink%s"" , a -> name ) ; pn [ 0 ] = c ; return ( ARCHIVE_FAILED ) ; } a -> pst = NULL ; if ( ! S_ISLNK ( a -> mode ) ) { archive_set_error ( & a -> archive , 0 , ""Removingsymlink%s"" , a -> name ) ; } pn [ 0 ] = c ; return ( 0 ) ; } else if ( a -> flags & ARCHIVE_EXTRACT_UNLINK ) { if ( unlink ( a -> name ) != 0 ) { archive_set_error ( & a -> archive , 0 , ""Cannotremoveinterveningsymlink%s"" , a -> name ) ; pn [ 0 ] = c ; return ( ARCHIVE_FAILED ) ; } a -> pst = NULL ; } else { archive_set_error ( & a -> archive , 0 , ""Cannotextractthroughsymlink%s"" , a -> name ) ; pn [ 0 ] = c ; return ( ARCHIVE_FAILED ) ; } } pn [ 0 ] = c ; if ( pn [ 0 ] != '\\0' ) pn ++ ; } pn [ 0 ] = c ; archive_strcpy ( & a -> path_safe , a -> name ) ; return ( ARCHIVE_OK ) ; # endif } "," a ) { struct archive_string error_string ; int error_number ; int rc ; archive_string_init ( & error_string ) ; rc = check_symlinks_fsobj ( a -> name , & error_number , & error_string , a -> flags ) ; if ; if ( rc != ARCHIVE_OK ) { archive_set_error -> archive , error_number , ""%s"" , error_string . s ) ; } ) ; } archive_string_free ( & error_string ) ; = NULL ; return rc ; } ",libarchive@libarchive/dfd6b54ce33960e420fb206d8872fb759b577ad9,CVE-2016-5418,https://github.com/libarchive/libarchive/commit/dfd6b54ce33960e420fb206d8872fb759b577ad9,2016-09-21T14:25Z 844,CWE-59,"CWE-59 static int fill_autodev ( const struct lxc_rootfs * rootfs ) { int ret ; char path [ MAXPATHLEN ] ; int i ; mode_t cmask ; INFO ( ""Creatinginitialconsolesundercontainer/dev"" ) ; ret = snprintf ( path , MAXPATHLEN , ""%s/dev"" , rootfs -> path ? rootfs -> mount : """" ) ; if ( ret < 0 || ret >= MAXPATHLEN ) { ERROR ( ""Errorcalculatingcontainer/devlocation"" ) ; return - 1 ; } if ( ! dir_exists ( path ) ) return 0 ; INFO ( ""Populatingcontainer/dev"" ) ; cmask = umask ( S_IXUSR | S_IXGRP | S_IXOTH ) ; for ( i = 0 ; i < sizeof ( lxc_devs ) / sizeof ( lxc_devs [ 0 ] ) ; i ++ ) { const struct lxc_devs * d = & lxc_devs [ i ] ; ret = snprintf ( path , MAXPATHLEN , ""%s/dev/%s"" , rootfs -> path ? rootfs -> mount : """" , d -> name ) ; if ( ret < 0 || ret >= MAXPATHLEN ) return - 1 ; ret = mknod ( path , d -> mode , makedev ( d -> maj , d -> min ) ) ; if ( ret && errno != EEXIST ) { char hostpath [ MAXPATHLEN ] ; FILE * pathfile ; ret = snprintf ( hostpath , MAXPATHLEN , ""/dev/%s"" , d -> name ) ; if ( ret < 0 || ret >= MAXPATHLEN ) return - 1 ; pathfile = fopen ( path , ""wb"" ) ; if ( ! pathfile ) { SYSERROR ( ""Failedtocreatedevicemounttarget\'%s\'"" , path ) ; return - 1 ; } fclose ( pathfile ) ; if ( mount ( hostpath , path , 0 , MS_BIND , NULL ) != 0 ) { SYSERROR ( ""Failedbindmountingdevice%sfromhostintocontainer"" , d -> name ) ; return - 1 ; } } } umask ( cmask ) ; INFO ( ""Populatedcontainer/dev"" ) ; return 0 ; } "," ; if ( safe_mount ( hostpath , path , 0 , MS_BIND , NULL , rootfs -> path ? rootfs -> mount : NULL ) != ",lxc@lxc/592fd47a6245508b79fe6ac819fe6d3b2c1289be,CVE-2015-1335,https://github.com/lxc/lxc/commit/592fd47a6245508b79fe6ac819fe6d3b2c1289be,2015-10-01T20:59Z 845,CWE-399,"CWE-399 static void __udf_read_inode ( struct inode * inode ) { struct buffer_head * bh = NULL ; struct fileEntry * fe ; struct extendedFileEntry * efe ; uint16_t ident ; struct udf_inode_info * iinfo = UDF_I ( inode ) ; struct udf_sb_info * sbi = UDF_SB ( inode -> i_sb ) ; unsigned int link_count ; bh = udf_read_ptagged ( inode -> i_sb , & iinfo -> i_location , 0 , & ident ) ; if ( ! bh ) { udf_err ( inode -> i_sb , ""(ino%ld)failed!bh\\n"" , inode -> i_ino ) ; make_bad_inode ( inode ) ; return ; } if ( ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE && ident != TAG_IDENT_USE ) { udf_err ( inode -> i_sb , ""(ino%ld)failedident=%d\\n"" , inode -> i_ino , ident ) ; brelse ( bh ) ; make_bad_inode ( inode ) ; return ; } fe = ( struct fileEntry * ) bh -> b_data ; efe = ( struct extendedFileEntry * ) bh -> b_data ; if ( fe -> icbTag . strategyType == cpu_to_le16 ( 4096 ) ) { struct buffer_head * ibh ; ibh = udf_read_ptagged ( inode -> i_sb , & iinfo -> i_location , 1 , & ident ) ; if ( ident == TAG_IDENT_IE && ibh ) { struct buffer_head * nbh = NULL ; struct kernel_lb_addr loc ; struct indirectEntry * ie ; ie = ( struct indirectEntry * ) ibh -> b_data ; loc = lelb_to_cpu ( ie -> indirectICB . extLocation ) ; if ( ie -> indirectICB . extLength && ( nbh = udf_read_ptagged ( inode -> i_sb , & loc , 0 , & ident ) ) ) { if ( ident == TAG_IDENT_FE || ident == TAG_IDENT_EFE ) { memcpy ( & iinfo -> i_location , & loc , sizeof ( struct kernel_lb_addr ) ) ; brelse ( bh ) ; brelse ( ibh ) ; brelse ( nbh ) ; __udf_read_inode ( inode ) ; return ; } brelse ( nbh ) ; } } brelse ( ibh ) ; } else if ( fe -> icbTag . strategyType != cpu_to_le16 ( 4 ) ) { udf_err ( inode -> i_sb , ""unsupportedstrategytype:%d\\n"" , le16_to_cpu ( fe -> icbTag . strategyType ) ) ; brelse ( bh ) ; make_bad_inode ( inode ) ; return ; } if ( fe -> icbTag . strategyType == cpu_to_le16 ( 4 ) ) iinfo -> i_strat4096 = 0 ; else iinfo -> i_strat4096 = 1 ; iinfo -> i_alloc_type = le16_to_cpu ( fe -> icbTag . flags ) & ICBTAG_FLAG_AD_MASK ; iinfo -> i_unique = 0 ; iinfo -> i_lenEAttr = 0 ; iinfo -> i_lenExtents = 0 ; iinfo -> i_lenAlloc = 0 ; iinfo -> i_next_alloc_block = 0 ; iinfo -> i_next_alloc_goal = 0 ; if ( fe -> descTag . tagIdent == cpu_to_le16 ( TAG_IDENT_EFE ) ) { iinfo -> i_efe = 1 ; iinfo -> i_use = 0 ; if ( udf_alloc_i_data ( inode , inode -> i_sb -> s_blocksize - sizeof ( struct extendedFileEntry ) ) ) { make_bad_inode ( inode ) ; return ; } memcpy ( iinfo -> i_ext . i_data , bh -> b_data + sizeof ( struct extendedFileEntry ) , inode -> i_sb -> s_blocksize - sizeof ( struct extendedFileEntry ) ) ; } else if ( fe -> descTag . tagIdent == cpu_to_le16 ( TAG_IDENT_FE ) ) { iinfo -> i_efe = 0 ; iinfo -> i_use = 0 ; if ( udf_alloc_i_data ( inode , inode -> i_sb -> s_blocksize - sizeof ( struct fileEntry ) ) ) { make_bad_inode ( inode ) ; return ; } memcpy ( iinfo -> i_ext . i_data , bh -> b_data + sizeof ( struct fileEntry ) , inode -> i_sb -> s_blocksize - sizeof ( struct fileEntry ) ) ; } else if ( fe -> descTag . tagIdent == cpu_to_le16 ( TAG_IDENT_USE ) ) { iinfo -> i_efe = 0 ; iinfo -> i_use = 1 ; iinfo -> i_lenAlloc = le32_to_cpu ( ( ( struct unallocSpaceEntry * ) bh -> b_data ) -> lengthAllocDescs ) ; if ( udf_alloc_i_data ( inode , inode -> i_sb -> s_blocksize - sizeof ( struct unallocSpaceEntry ) ) ) { make_bad_inode ( inode ) ; return ; } memcpy ( iinfo -> i_ext . i_data , bh -> b_data + sizeof ( struct unallocSpaceEntry ) , inode -> i_sb -> s_blocksize - sizeof ( struct unallocSpaceEntry ) ) ; return ; } read_lock ( & sbi -> s_cred_lock ) ; i_uid_write ( inode , le32_to_cpu ( fe -> uid ) ) ; if ( ! uid_valid ( inode -> i_uid ) || UDF_QUERY_FLAG ( inode -> i_sb , UDF_FLAG_UID_IGNORE ) || UDF_QUERY_FLAG ( inode -> i_sb , UDF_FLAG_UID_SET ) ) inode -> i_uid = UDF_SB ( inode -> i_sb ) -> s_uid ; i_gid_write ( inode , le32_to_cpu ( fe -> gid ) ) ; if ( ! gid_valid ( inode -> i_gid ) || UDF_QUERY_FLAG ( inode -> i_sb , UDF_FLAG_GID_IGNORE ) || UDF_QUERY_FLAG ( inode -> i_sb , UDF_FLAG_GID_SET ) ) inode -> i_gid = UDF_SB ( inode -> i_sb ) -> s_gid ; if ( fe -> icbTag . fileType != ICBTAG_FILE_TYPE_DIRECTORY && sbi -> s_fmode != UDF_INVALID_MODE ) inode -> i_mode = sbi -> s_fmode ; else if ( fe -> icbTag . fileType == ICBTAG_FILE_TYPE_DIRECTORY && sbi -> s_dmode != UDF_INVALID_MODE ) inode -> i_mode = sbi -> s_dmode ; else inode -> i_mode = udf_convert_permissions ( fe ) ; inode -> i_mode &= ~ sbi -> s_umask ; read_unlock ( & sbi -> s_cred_lock ) ; link_count = le16_to_cpu ( fe -> fileLinkCount ) ; if ( ! link_count ) link_count = 1 ; set_nlink ( inode , link_count ) ; inode -> i_size = le64_to_cpu ( fe -> informationLength ) ; iinfo -> i_lenExtents = inode -> i_size ; if ( iinfo -> i_efe == 0 ) { inode -> i_blocks = le64_to_cpu ( fe -> logicalBlocksRecorded ) << ( inode -> i_sb -> s_blocksize_bits - 9 ) ; if ( ! udf_disk_stamp_to_time ( & inode -> i_atime , fe -> accessTime ) ) inode -> i_atime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & inode -> i_mtime , fe -> modificationTime ) ) inode -> i_mtime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & inode -> i_ctime , fe -> attrTime ) ) inode -> i_ctime = sbi -> s_record_time ; iinfo -> i_unique = le64_to_cpu ( fe -> uniqueID ) ; iinfo -> i_lenEAttr = le32_to_cpu ( fe -> lengthExtendedAttr ) ; iinfo -> i_lenAlloc = le32_to_cpu ( fe -> lengthAllocDescs ) ; iinfo -> i_checkpoint = le32_to_cpu ( fe -> checkpoint ) ; } else { inode -> i_blocks = le64_to_cpu ( efe -> logicalBlocksRecorded ) << ( inode -> i_sb -> s_blocksize_bits - 9 ) ; if ( ! udf_disk_stamp_to_time ( & inode -> i_atime , efe -> accessTime ) ) inode -> i_atime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & inode -> i_mtime , efe -> modificationTime ) ) inode -> i_mtime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & iinfo -> i_crtime , efe -> createTime ) ) iinfo -> i_crtime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & inode -> i_ctime , efe -> attrTime ) ) inode -> i_ctime = sbi -> s_record_time ; iinfo -> i_unique = le64_to_cpu ( efe -> uniqueID ) ; iinfo -> i_lenEAttr = le32_to_cpu ( efe -> lengthExtendedAttr ) ; iinfo -> i_lenAlloc = le32_to_cpu ( efe -> lengthAllocDescs ) ; iinfo -> i_checkpoint = le32_to_cpu ( efe -> checkpoint ) ; } switch ( fe -> icbTag . fileType ) { case ICBTAG_FILE_TYPE_DIRECTORY : inode -> i_op = & udf_dir_inode_operations ; inode -> i_fop = & udf_dir_operations ; inode -> i_mode |= S_IFDIR ; inc_nlink ( inode ) ; break ; case ICBTAG_FILE_TYPE_REALTIME : case ICBTAG_FILE_TYPE_REGULAR : case ICBTAG_FILE_TYPE_UNDEF : case ICBTAG_FILE_TYPE_VAT20 : if ( iinfo -> i_alloc_type == ICBTAG_FLAG_AD_IN_ICB ) inode -> i_data . a_ops = & udf_adinicb_aops ; else inode -> i_data . a_ops = & udf_aops ; inode -> i_op = & udf_file_inode_operations ; inode -> i_fop = & udf_file_operations ; inode -> i_mode |= S_IFREG ; break ; case ICBTAG_FILE_TYPE_BLOCK : inode -> i_mode |= S_IFBLK ; break ; case ICBTAG_FILE_TYPE_CHAR : inode -> i_mode |= S_IFCHR ; break ; case ICBTAG_FILE_TYPE_FIFO : init_special_inode ( inode , inode -> i_mode | S_IFIFO , 0 ) ; break ; case ICBTAG_FILE_TYPE_SOCKET : init_special_inode ( inode , inode -> i_mode | S_IFSOCK , 0 ) ; break ; case ICBTAG_FILE_TYPE_SYMLINK : inode -> i_data . a_ops = & udf_symlink_aops ; inode -> i_op = & udf_symlink_inode_operations ; inode -> i_mode = S_IFLNK | S_IRWXUGO ; break ; case ICBTAG_FILE_TYPE_MAIN : udf_debug ( ""METADATAFILE-----\\n"" ) ; break ; case ICBTAG_FILE_TYPE_MIRROR : udf_debug ( ""METADATAMIRRORFILE-----\\n"" ) ; break ; case ICBTAG_FILE_TYPE_BITMAP : udf_debug ( ""METADATABITMAPFILE-----\\n"" ) ; break ; default : udf_err ( inode -> i_sb , ""(ino%ld)failedunknownfiletype=%d\\n"" , inode -> i_ino , fe -> icbTag . fileType ) ; make_bad_inode ( inode ) ; return ; } if ( S_ISCHR ( inode -> i_mode ) || S_ISBLK ( inode -> i_mode ) ) { struct deviceSpec * dsea = ( struct deviceSpec * ) udf_get_extendedattr ( inode , 12 , 1 ) ; if ( dsea ) { init_special_inode ( inode , inode -> i_mode , MKDEV ( le32_to_cpu ( dsea -> majorDeviceIdent ) , le32_to_cpu ( dsea -> minorDeviceIdent ) ) ) ; } else make_bad_inode ( inode ) ; } brelse ( bh ) ; } "," int link_count ; unsigned int indirections = 0 ; reread : ) { struct kernel_lb_addr loc ; indirectICB . extLength ) { brelse ( bh ) ; brelse ( ibh ) ; memcpy ( & iinfo -> i_location , & loc & loc , sizeof ( struct kernel_lb_addr ) ) ; if ( ++ indirections > UDF_MAX_ICB_NESTING ) { udf_err ( inode -> i_sb , ""toomanyICBsinICBhierarchy"" ""(max%dsupported)\\n"" , UDF_MAX_ICB_NESTING ) ; make_bad_inode ( inode ) return ; } goto reread ; } } ",torvalds@linux/c03aa9f6e1f938618e6db2e23afef0574efeeb65,CVE-2014-6410,https://github.com/torvalds/linux/commit/c03aa9f6e1f938618e6db2e23afef0574efeeb65,2014-09-28T10:55Z 846,CWE-119,"CWE-119 static void build_masks ( const loop_filter_info_n * const lfi_n , const MODE_INFO * mi , const int shift_y , const int shift_uv , LOOP_FILTER_MASK * lfm ) { const MB_MODE_INFO * mbmi = & mi -> mbmi ; const BLOCK_SIZE block_size = mbmi -> sb_type ; const TX_SIZE tx_size_y = mbmi -> tx_size ; const TX_SIZE tx_size_uv = get_uv_tx_size ( mbmi ) ; const int filter_level = get_filter_level ( lfi_n , mbmi ) ; uint64_t * const left_y = & lfm -> left_y [ tx_size_y ] ; uint64_t * const above_y = & lfm -> above_y [ tx_size_y ] ; uint64_t * const int_4x4_y = & lfm -> int_4x4_y ; uint16_t * const left_uv = & lfm -> left_uv [ tx_size_uv ] ; uint16_t * const above_uv = & lfm -> above_uv [ tx_size_uv ] ; uint16_t * const int_4x4_uv = & lfm -> int_4x4_uv ; int i ; if ( ! filter_level ) { return ; } else { const int w = num_8x8_blocks_wide_lookup [ block_size ] ; const int h = num_8x8_blocks_high_lookup [ block_size ] ; int index = shift_y ; for ( i = 0 ; i < h ; i ++ ) { vpx_memset ( & lfm -> lfl_y [ index ] , filter_level , w ) ; index += 8 ; } } * above_y |= above_prediction_mask [ block_size ] << shift_y ; * above_uv |= above_prediction_mask_uv [ block_size ] << shift_uv ; * left_y |= left_prediction_mask [ block_size ] << shift_y ; * left_uv |= left_prediction_mask_uv [ block_size ] << shift_uv ; if ( mbmi -> skip && is_inter_block ( mbmi ) ) return ; * above_y |= ( size_mask [ block_size ] & above_64x64_txform_mask [ tx_size_y ] ) << shift_y ; * above_uv |= ( size_mask_uv [ block_size ] & above_64x64_txform_mask_uv [ tx_size_uv ] ) << shift_uv ; * left_y |= ( size_mask [ block_size ] & left_64x64_txform_mask [ tx_size_y ] ) << shift_y ; * left_uv |= ( size_mask_uv [ block_size ] & left_64x64_txform_mask_uv [ tx_size_uv ] ) << shift_uv ; if ( tx_size_y == TX_4X4 ) * int_4x4_y |= ( size_mask [ block_size ] & 0xffffffffffffffff ) << shift_y ; if ( tx_size_uv == TX_4X4 ) * int_4x4_uv |= ( size_mask_uv [ block_size ] & 0xffff ) << shift_uv ; } "," TX_SIZE tx_size_uv = get_uv_tx_size_impl ( tx_size_y , block_size , 1 , 1 ) ; const ++ ) { memset ( & lfm block_size ] & 0xffffffffffffffffULL ) << shift_y ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 847,CWE-20,"CWE-20 int ff_amf_get_field_value ( const uint8_t * data , const uint8_t * data_end , const uint8_t * name , uint8_t * dst , int dst_size ) { int namelen = strlen ( name ) ; int len ; while ( * data != AMF_DATA_TYPE_OBJECT && data < data_end ) { len = ff_amf_tag_size ( data , data_end ) ; if ( len < 0 ) len = data_end - data ; data += len ; } if ( data_end - data < 3 ) return - 1 ; data ++ ; for ( ; ; ) { int size = bytestream_get_be16 ( & data ) ; if ( ! size ) break ; if ( size < 0 || size >= data_end - data ) return - 1 ; data += size ; if ( size == namelen && ! memcmp ( data - size , name , namelen ) ) { switch ( * data ++ ) { case AMF_DATA_TYPE_NUMBER : snprintf ( dst , dst_size , ""%g"" , av_int2double ( AV_RB64 ( data ) ) ) ; break ; case AMF_DATA_TYPE_BOOL : snprintf ( dst , dst_size , ""%s"" , * data ? ""true"" : ""false"" ) ; break ; case AMF_DATA_TYPE_STRING : len = bytestream_get_be16 ( & data ) ; av_strlcpy ( dst , data , FFMIN ( len + 1 , dst_size ) ) ; break ; default : return - 1 ; } return 0 ; } len = ff_amf_tag_size ( data , data_end ) ; if ( len < 0 || len >= data_end - data ) return - 1 ; data += len ; } return - 1 ; } "," dst_size ) { GetByteContext gb ; if ( ; if ( data >= data_end ) return - - 1 ; bytestream2_init ( & gb , data , data_end - data ) ; data ) ; return amf_get_field_value2 ( & gb , name , , name , dst , dst_size dst , dst_size ) ; } ",FFmpeg@FFmpeg/ffcc82219cef0928bed2d558b19ef6ea35634130,CVE-2017-11665,https://github.com/FFmpeg/FFmpeg/commit/ffcc82219cef0928bed2d558b19ef6ea35634130,2017-07-27T12:29Z 848,CWE-119,"CWE-119 static void t1_check_unusual_charstring ( void ) { char * p = strstr ( t1_line_array , charstringname ) + strlen ( charstringname ) ; int i ; if ( sscanf ( p , ""%i"" , & i ) != 1 ) { strcpy ( t1_buf_array , t1_line_array ) ; t1_getline ( ) ; strcat ( t1_buf_array , t1_line_array ) ; strcpy ( t1_line_array , t1_buf_array ) ; t1_line_ptr = eol ( t1_line_array ) ; } } "," ( ) ; alloc_array ( t1_buf , strlen ( t1_line_array ) + strlen ( t1_buf_array ) + 1 , T1_BUF_SIZE ) ; t1_buf_array , t1_line_array ) ; alloc_array ( t1_line , strlen ( t1_buf_array ) + 1 , T1_BUF_SIZE ",TeX-Live@texlive-source/6ed0077520e2b0da1fd060c7f88db7b2e6068e4c,CVE-2018-17407,https://github.com/TeX-Live/texlive-source/commit/6ed0077520e2b0da1fd060c7f88db7b2e6068e4c,2018-09-23T21:29Z 849,CWE-362,"CWE-362 static void flush_end_io ( struct request * flush_rq , int error ) { struct request_queue * q = flush_rq -> q ; struct list_head * running ; bool queued = false ; struct request * rq , * n ; unsigned long flags = 0 ; struct blk_flush_queue * fq = blk_get_flush_queue ( q , flush_rq -> mq_ctx ) ; if ( q -> mq_ops ) { spin_lock_irqsave ( & fq -> mq_flush_lock , flags ) ; flush_rq -> tag = - 1 ; } running = & fq -> flush_queue [ fq -> flush_running_idx ] ; BUG_ON ( fq -> flush_pending_idx == fq -> flush_running_idx ) ; fq -> flush_running_idx ^= 1 ; if ( ! q -> mq_ops ) elv_completed_request ( q , flush_rq ) ; list_for_each_entry_safe ( rq , n , running , flush . list ) { unsigned int seq = blk_flush_cur_seq ( rq ) ; BUG_ON ( seq != REQ_FSEQ_PREFLUSH && seq != REQ_FSEQ_POSTFLUSH ) ; queued |= blk_flush_complete_seq ( rq , fq , seq , error ) ; } if ( queued || fq -> flush_queue_delayed ) { WARN_ON ( q -> mq_ops ) ; blk_run_queue_async ( q ) ; } fq -> flush_queue_delayed = 0 ; if ( q -> mq_ops ) spin_unlock_irqrestore ( & fq -> mq_flush_lock , flags ) ; } "," mq_ops ) { struct blk_mq_hw_ctx * hctx ; mq_flush_lock , flags ) ; hctx = q -> mq_ops -> map_queue ( q , flush_rq -> mq_ctx -> cpu ) ; blk_mq_tag_set_rq ( hctx , flush_rq -> tag , fq -> orig_rq ",torvalds@linux/0048b4837affd153897ed1222283492070027aa9,CVE-2015-9016,https://github.com/torvalds/linux/commit/0048b4837affd153897ed1222283492070027aa9,2018-04-05T18:29Z 850,CWE-269,"CWE-269 uint32_t virtio_config_readb ( VirtIODevice * vdev , uint32_t addr ) { VirtioDeviceClass * k = VIRTIO_DEVICE_GET_CLASS ( vdev ) ; uint8_t val ; k -> get_config ( vdev , vdev -> config ) ; if ( addr > ( vdev -> config_len - sizeof ( val ) ) ) return ( uint32_t ) - 1 ; val = ldub_p ( vdev -> config + addr ) ; return val ; } "," uint8_t val ; if ( addr + sizeof ( val ) > vdev -> config_len ) { return ( uint32_t ) - 1 ; } -> config ) ; val = ",qemu@qemu/5f5a1318653c08e435cfa52f60b6a712815b659d,CVE-2013-2016,https://github.com/qemu/qemu/commit/5f5a1318653c08e435cfa52f60b6a712815b659d,2019-12-30T22:15Z 851,CWE-400,"CWE-400 int regexec ( Reprog * prog , const char * sp , Resub * sub , int eflags ) { Resub scratch ; int i ; if ( ! sub ) sub = & scratch ; sub -> nsub = prog -> nsub ; for ( i = 0 ; i < MAXSUB ; ++ i ) sub -> sub [ i ] . sp = sub -> sub [ i ] . ep = NULL ; return ! match ( prog -> start , sp , sp , prog -> flags | eflags , sub ) ; } "," NULL ; return match ( prog eflags , sub , 0 ",ccxvii@mujs/00d4606c3baf813b7b1c176823b2729bf51002a2,CVE-2019-11413,https://github.com/ccxvii/mujs/commit/00d4606c3baf813b7b1c176823b2729bf51002a2,2019-04-22T11:29Z 852,CWE-119,"CWE-119 static void swabHorDiff16 ( TIFF * tif , uint8 * cp0 , tmsize_t cc ) { uint16 * wp = ( uint16 * ) cp0 ; tmsize_t wc = cc / 2 ; horDiff16 ( tif , cp0 , cc ) ; TIFFSwabArrayOfShort ( wp , wc ) ; } "," static int swabHorDiff16 ( TIFF / 2 ; if ( ! , cc ) ) return 0 wc ) ; return 1 ; ",vadz@libtiff/3ca657a8793dd011bf869695d72ad31c779c3cc1,CVE-2016-9535,https://github.com/vadz/libtiff/commit/3ca657a8793dd011bf869695d72ad31c779c3cc1,2016-11-22T19:59Z 853,CWE-000,"CWE-000 static int sessionCookieDirective ( MaState * state , cchar * key , cchar * value ) { char * options , * option , * ovalue , * tok ; if ( ! maTokenize ( state , value , ""%*"" , & options ) ) { return MPR_ERR_BAD_SYNTAX ; } if ( smatch ( options , ""disable"" ) ) { httpSetAuthSession ( state -> route -> auth , 0 ) ; return 0 ; } else if ( smatch ( options , ""enable"" ) ) { httpSetAuthSession ( state -> route -> auth , 1 ) ; return 0 ; } for ( option = maGetNextArg ( options , & tok ) ; option ; option = maGetNextArg ( tok , & tok ) ) { option = stok ( option , ""=\\t,"" , & ovalue ) ; ovalue = strim ( ovalue , ""\\""\'"" , MPR_TRIM_BOTH ) ; if ( ! ovalue || * ovalue == '\\0' ) continue ; if ( smatch ( option , ""visible"" ) ) { httpSetRouteSessionVisibility ( state -> route , scaselessmatch ( ovalue , ""visible"" ) ) ; } else if ( smatch ( option , ""name"" ) ) { httpSetRouteCookie ( state -> route , ovalue ) ; } else { mprLog ( ""errorappwebconfig"" , 0 , ""UnknownSessionCookieoption%s"" , option ) ; return MPR_ERR_BAD_SYNTAX ; } } return 0 ; } "," { option = ssplit ( option , ",embedthis@appweb/7e6a925f5e86a19a7934a94bbd6959101d0b84eb,CVE-2014-9708,https://github.com/embedthis/appweb/commit/7e6a925f5e86a19a7934a94bbd6959101d0b84eb,2015-03-31T14:59Z 854,CWE-362,"CWE-362 int inet_sk_rebuild_header ( struct sock * sk ) { struct inet_sock * inet = inet_sk ( sk ) ; struct rtable * rt = ( struct rtable * ) __sk_dst_check ( sk , 0 ) ; __be32 daddr ; int err ; if ( rt ) return 0 ; daddr = inet -> inet_daddr ; if ( inet -> opt && inet -> opt -> srr ) daddr = inet -> opt -> faddr ; rt = ip_route_output_ports ( sock_net ( sk ) , sk , daddr , inet -> inet_saddr , inet -> inet_dport , inet -> inet_sport , sk -> sk_protocol , RT_CONN_FLAGS ( sk ) , sk -> sk_bound_dev_if ) ; if ( ! IS_ERR ( rt ) ) { err = 0 ; sk_setup_caps ( sk , & rt -> dst ) ; } else { err = PTR_ERR ( rt ) ; sk -> sk_route_caps = 0 ; if ( ! sysctl_ip_dynaddr || sk -> sk_state != TCP_SYN_SENT || ( sk -> sk_userlocks & SOCK_BINDADDR_LOCK ) || ( err = inet_sk_reselect_saddr ( sk ) ) != 0 ) sk -> sk_err_soft = - err ; } return err ; } "," __be32 daddr ; struct ip_options_rcu * inet_opt ; return 0 ; rcu_read_lock ( ) ; inet_opt = rcu_dereference ( inet -> inet_opt ) ; ; if ( inet_opt && inet_opt -> opt . srr ) daddr = inet_opt -> opt . faddr ; rcu_read_unlock ( ) ; rt = ",torvalds@linux/f6d8bd051c391c1c0458a30b2a7abcd939329259,CVE-2012-3552,https://github.com/torvalds/linux/commit/f6d8bd051c391c1c0458a30b2a7abcd939329259,2012-10-03T11:02Z 855,CWE-125,"CWE-125 void ntlm_populate_message_header ( NTLM_MESSAGE_HEADER * header , UINT32 MessageType ) { CopyMemory ( header -> Signature , NTLM_SIGNATURE , sizeof ( NTLM_SIGNATURE ) ) ; header -> MessageType = MessageType ; } "," static ",FreeRDP@FreeRDP/2ee663f39dc8dac3d9988e847db19b2d7e3ac8c6,CVE-2018-8789,https://github.com/FreeRDP/FreeRDP/commit/2ee663f39dc8dac3d9988e847db19b2d7e3ac8c6,2018-11-29T18:29Z 856,CWE-362,"CWE-362 fm_mgr_config_errno_t fm_mgr_config_mgr_connect ( fm_config_conx_hdl * hdl , fm_mgr_type_t mgr ) { char s_path [ 256 ] ; char c_path [ 256 ] ; char * mgr_prefix ; p_hsm_com_client_hdl_t * mgr_hdl ; pid_t pid ; memset ( s_path , 0 , sizeof ( s_path ) ) ; memset ( c_path , 0 , sizeof ( c_path ) ) ; pid = getpid ( ) ; switch ( mgr ) { case FM_MGR_SM : mgr_prefix = HSM_FM_SCK_SM ; mgr_hdl = & hdl -> sm_hdl ; break ; case FM_MGR_PM : mgr_prefix = HSM_FM_SCK_PM ; mgr_hdl = & hdl -> pm_hdl ; break ; case FM_MGR_FE : mgr_prefix = HSM_FM_SCK_FE ; mgr_hdl = & hdl -> fe_hdl ; break ; default : return FM_CONF_INIT_ERR ; } sprintf ( s_path , ""%s%s%d"" , HSM_FM_SCK_PREFIX , mgr_prefix , hdl -> instance ) ; sprintf ( c_path , ""%s%s%d_C_%lu"" , HSM_FM_SCK_PREFIX , mgr_prefix , hdl -> instance , ( long unsigned ) pid ) ; if ( * mgr_hdl == NULL ) { if ( hcom_client_init ( mgr_hdl , s_path , c_path , 32768 ) != HSM_COM_OK ) { return FM_CONF_INIT_ERR ; } } if ( hcom_client_connect ( * mgr_hdl ) == HSM_COM_OK ) { hdl -> conx_mask |= mgr ; return FM_CONF_OK ; } return FM_CONF_CONX_ERR ; } "," * mgr_hdl ; memset ( s_path ( c_path ) ) ; switch ( c_path , ""%s%s%d_C_XXXXXX"" , HSM_FM_SCK_PREFIX , hdl -> instance ) ; if ",01org@opa-fm/c5759e7b76f5bf844be6c6641cc1b356bbc83869,CVE-2015-5232,https://github.com/01org/opa-fm/commit/c5759e7b76f5bf844be6c6641cc1b356bbc83869,2017-06-07T20:29Z 857,CWE-119,"CWE-119 static int fx_command ( effect_handle_t self , uint32_t cmdCode , uint32_t cmdSize , void * pCmdData , uint32_t * replySize , void * pReplyData ) { struct effect_s * effect = ( struct effect_s * ) self ; if ( effect == NULL ) return - EINVAL ; switch ( cmdCode ) { case EFFECT_CMD_INIT : if ( pReplyData == NULL || * replySize != sizeof ( int ) ) return - EINVAL ; * ( int * ) pReplyData = 0 ; break ; case EFFECT_CMD_SET_CONFIG : { if ( pCmdData == NULL || cmdSize != sizeof ( effect_config_t ) || pReplyData == NULL || * replySize != sizeof ( int ) ) { ALOGV ( ""fx_command()EFFECT_CMD_SET_CONFIGinvalidargs"" ) ; return - EINVAL ; } * ( int * ) pReplyData = session_set_config ( effect -> session , ( effect_config_t * ) pCmdData ) ; if ( * ( int * ) pReplyData != 0 ) break ; if ( effect -> state != EFFECT_STATE_ACTIVE ) * ( int * ) pReplyData = effect_set_state ( effect , EFFECT_STATE_CONFIG ) ; } break ; case EFFECT_CMD_GET_CONFIG : if ( pReplyData == NULL || * replySize != sizeof ( effect_config_t ) ) { ALOGV ( ""fx_command()EFFECT_CMD_GET_CONFIGinvalidargs"" ) ; return - EINVAL ; } session_get_config ( effect -> session , ( effect_config_t * ) pReplyData ) ; break ; case EFFECT_CMD_RESET : break ; case EFFECT_CMD_GET_PARAM : { if ( pCmdData == NULL || cmdSize < ( int ) sizeof ( effect_param_t ) || pReplyData == NULL || * replySize < ( int ) sizeof ( effect_param_t ) ) { ALOGV ( ""fx_command()EFFECT_CMD_GET_PARAMinvalidargs"" ) ; return - EINVAL ; } effect_param_t * p = ( effect_param_t * ) pCmdData ; memcpy ( pReplyData , pCmdData , sizeof ( effect_param_t ) + p -> psize ) ; p = ( effect_param_t * ) pReplyData ; p -> status = - ENOSYS ; } break ; case EFFECT_CMD_SET_PARAM : { if ( pCmdData == NULL || cmdSize < ( int ) sizeof ( effect_param_t ) || pReplyData == NULL || * replySize != sizeof ( int32_t ) ) { ALOGV ( ""fx_command()EFFECT_CMD_SET_PARAMinvalidargs"" ) ; return - EINVAL ; } effect_param_t * p = ( effect_param_t * ) pCmdData ; if ( p -> psize != sizeof ( int32_t ) ) { ALOGV ( ""fx_command()EFFECT_CMD_SET_PARAMinvalidparamformat"" ) ; return - EINVAL ; } * ( int * ) pReplyData = - ENOSYS ; } break ; case EFFECT_CMD_ENABLE : if ( pReplyData == NULL || * replySize != sizeof ( int ) ) { ALOGV ( ""fx_command()EFFECT_CMD_ENABLEinvalidargs"" ) ; return - EINVAL ; } * ( int * ) pReplyData = effect_set_state ( effect , EFFECT_STATE_ACTIVE ) ; break ; case EFFECT_CMD_DISABLE : if ( pReplyData == NULL || * replySize != sizeof ( int ) ) { ALOGV ( ""fx_command()EFFECT_CMD_DISABLEinvalidargs"" ) ; return - EINVAL ; } * ( int * ) pReplyData = effect_set_state ( effect , EFFECT_STATE_CONFIG ) ; break ; case EFFECT_CMD_SET_DEVICE : case EFFECT_CMD_SET_INPUT_DEVICE : case EFFECT_CMD_SET_VOLUME : case EFFECT_CMD_SET_AUDIO_MODE : if ( pCmdData == NULL || cmdSize != sizeof ( uint32_t ) ) { ALOGV ( ""fx_command()%sinvalidargs"" , cmdCode == EFFECT_CMD_SET_DEVICE ? ""EFFECT_CMD_SET_DEVICE"" : cmdCode == EFFECT_CMD_SET_INPUT_DEVICE ? ""EFFECT_CMD_SET_INPUT_DEVICE"" : cmdCode == EFFECT_CMD_SET_VOLUME ? ""EFFECT_CMD_SET_VOLUME"" : cmdCode == EFFECT_CMD_SET_AUDIO_MODE ? ""EFFECT_CMD_SET_AUDIO_MODE"" : """" ) ; return - EINVAL ; } ALOGV ( ""fx_command()%svalue%08x"" , cmdCode == EFFECT_CMD_SET_DEVICE ? ""EFFECT_CMD_SET_DEVICE"" : cmdCode == EFFECT_CMD_SET_INPUT_DEVICE ? ""EFFECT_CMD_SET_INPUT_DEVICE"" : cmdCode == EFFECT_CMD_SET_VOLUME ? ""EFFECT_CMD_SET_VOLUME"" : cmdCode == EFFECT_CMD_SET_AUDIO_MODE ? ""EFFECT_CMD_SET_AUDIO_MODE"" : """" , * ( int * ) pCmdData ) ; break ; default : return - EINVAL ; } return 0 ; } "," ( int ) sizeof ( effect_param_t ) || ( ( effect_param_t * ) pCmdData ) -> psize > * replySize - ",hardware@qcom@audio/073a80800f341325932c66818ce4302b312909a4,CVE-2016-3745,https://android.googlesource.com/platform/hardware/qcom/audio/+/073a80800f341325932c66818ce4302b312909a4,2016-07-11T01:59Z 858,CWE-399,"CWE-399 static Image * ReadPSImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define BoundingBox ""BoundingBox:"" # define BeginDocument ""BeginDocument:"" # define BeginXMPPacket ""begin="" # define EndXMPPacket ""end="" # define ICCProfile ""BeginICCProfile:"" # define CMYKCustomColor ""CMYKCustomColor:"" # define CMYKProcessColor ""CMYKProcessColor:"" # define DocumentMedia ""DocumentMedia:"" # define DocumentCustomColors ""DocumentCustomColors:"" # define DocumentProcessColors ""DocumentProcessColors:"" # define EndDocument ""EndDocument:"" # define HiResBoundingBox ""HiResBoundingBox:"" # define ImageData ""ImageData:"" # define PageBoundingBox ""PageBoundingBox:"" # define LanguageLevel ""LanguageLevel:"" # define PageMedia ""PageMedia:"" # define Pages ""Pages:"" # define PhotoshopProfile ""BeginPhotoshop:"" # define PostscriptLevel ""!PS-"" # define RenderPostscriptText ""RenderingPostscript..."" # define SpotColor ""+"" char command [ MagickPathExtent ] , * density , filename [ MagickPathExtent ] , geometry [ MagickPathExtent ] , input_filename [ MagickPathExtent ] , message [ MagickPathExtent ] , * options , postscript_filename [ MagickPathExtent ] ; const char * option ; const DelegateInfo * delegate_info ; GeometryInfo geometry_info ; Image * image , * next , * postscript_image ; ImageInfo * read_info ; int c , file ; MagickBooleanType cmyk , fitPage , skip , status ; MagickStatusType flags ; PointInfo delta , resolution ; RectangleInfo page ; register char * p ; register ssize_t i ; SegmentInfo bounds , hires_bounds ; short int hex_digits [ 256 ] ; size_t length ; ssize_t count , priority ; StringInfo * profile ; unsigned long columns , extent , language_level , pages , rows , scene , spotcolor ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } status = AcquireUniqueSymbolicLink ( image_info -> filename , input_filename ) ; if ( status == MagickFalse ) { ThrowFileException ( exception , FileOpenError , ""UnableToCreateTemporaryFile"" , image_info -> filename ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } ( void ) memset ( hex_digits , 0 , sizeof ( hex_digits ) ) ; hex_digits [ ( int ) '0' ] = 0 ; hex_digits [ ( int ) '1' ] = 1 ; hex_digits [ ( int ) '2' ] = 2 ; hex_digits [ ( int ) '3' ] = 3 ; hex_digits [ ( int ) '4' ] = 4 ; hex_digits [ ( int ) '5' ] = 5 ; hex_digits [ ( int ) '6' ] = 6 ; hex_digits [ ( int ) '7' ] = 7 ; hex_digits [ ( int ) '8' ] = 8 ; hex_digits [ ( int ) '9' ] = 9 ; hex_digits [ ( int ) 'a' ] = 10 ; hex_digits [ ( int ) 'b' ] = 11 ; hex_digits [ ( int ) 'c' ] = 12 ; hex_digits [ ( int ) 'd' ] = 13 ; hex_digits [ ( int ) 'e' ] = 14 ; hex_digits [ ( int ) 'f' ] = 15 ; hex_digits [ ( int ) 'A' ] = 10 ; hex_digits [ ( int ) 'B' ] = 11 ; hex_digits [ ( int ) 'C' ] = 12 ; hex_digits [ ( int ) 'D' ] = 13 ; hex_digits [ ( int ) 'E' ] = 14 ; hex_digits [ ( int ) 'F' ] = 15 ; delta . x = DefaultResolution ; delta . y = DefaultResolution ; if ( ( image -> resolution . x == 0.0 ) || ( image -> resolution . y == 0.0 ) ) { flags = ParseGeometry ( PSDensityGeometry , & geometry_info ) ; image -> resolution . x = geometry_info . rho ; image -> resolution . y = geometry_info . sigma ; if ( ( flags & SigmaValue ) == 0 ) image -> resolution . y = image -> resolution . x ; } if ( image_info -> density != ( char * ) NULL ) { flags = ParseGeometry ( image_info -> density , & geometry_info ) ; image -> resolution . x = geometry_info . rho ; image -> resolution . y = geometry_info . sigma ; if ( ( flags & SigmaValue ) == 0 ) image -> resolution . y = image -> resolution . x ; } ( void ) ParseAbsoluteGeometry ( PSPageGeometry , & page ) ; if ( image_info -> page != ( char * ) NULL ) ( void ) ParseAbsoluteGeometry ( image_info -> page , & page ) ; resolution = image -> resolution ; page . width = ( size_t ) ceil ( ( double ) ( page . width * resolution . x / delta . x ) - 0.5 ) ; page . height = ( size_t ) ceil ( ( double ) ( page . height * resolution . y / delta . y ) - 0.5 ) ; ( void ) memset ( & bounds , 0 , sizeof ( bounds ) ) ; ( void ) memset ( command , 0 , sizeof ( command ) ) ; cmyk = image_info -> colorspace == CMYKColorspace ? MagickTrue : MagickFalse ; ( void ) memset ( & hires_bounds , 0 , sizeof ( hires_bounds ) ) ; columns = 0 ; rows = 0 ; priority = 0 ; rows = 0 ; extent = 0 ; spotcolor = 0 ; language_level = 1 ; pages = ( ~ 0UL ) ; skip = MagickFalse ; p = command ; for ( c = ReadBlobByte ( image ) ; c != EOF ; c = ReadBlobByte ( image ) ) { * p ++ = ( char ) c ; if ( ( strchr ( ""\\n\\r%"" , c ) == ( char * ) NULL ) && ( ( size_t ) ( p - command ) < ( MagickPathExtent - 1 ) ) ) continue ; * p = '\\0' ; p = command ; if ( LocaleNCompare ( BeginDocument , command , strlen ( BeginDocument ) ) == 0 ) skip = MagickTrue ; if ( LocaleNCompare ( EndDocument , command , strlen ( EndDocument ) ) == 0 ) skip = MagickFalse ; if ( skip != MagickFalse ) continue ; if ( LocaleNCompare ( PostscriptLevel , command , strlen ( PostscriptLevel ) ) == 0 ) { ( void ) SetImageProperty ( image , ""ps:Level"" , command + 4 , exception ) ; if ( GlobExpression ( command , ""*EPSF-*"" , MagickTrue ) != MagickFalse ) pages = 1 ; } if ( LocaleNCompare ( LanguageLevel , command , strlen ( LanguageLevel ) ) == 0 ) ( void ) sscanf ( command , LanguageLevel ""%lu"" , & language_level ) ; if ( LocaleNCompare ( Pages , command , strlen ( Pages ) ) == 0 ) ( void ) sscanf ( command , Pages ""%lu"" , & pages ) ; if ( LocaleNCompare ( ImageData , command , strlen ( ImageData ) ) == 0 ) ( void ) sscanf ( command , ImageData ""%lu%lu"" , & columns , & rows ) ; length = strlen ( DocumentProcessColors ) ; if ( LocaleNCompare ( DocumentProcessColors , command , length ) == 0 ) { if ( ( GlobExpression ( command , ""*Cyan*"" , MagickTrue ) != MagickFalse ) || ( GlobExpression ( command , ""*Magenta*"" , MagickTrue ) != MagickFalse ) || ( GlobExpression ( command , ""*Yellow*"" , MagickTrue ) != MagickFalse ) ) cmyk = MagickTrue ; } if ( LocaleNCompare ( CMYKCustomColor , command , strlen ( CMYKCustomColor ) ) == 0 ) cmyk = MagickTrue ; if ( LocaleNCompare ( CMYKProcessColor , command , strlen ( CMYKProcessColor ) ) == 0 ) cmyk = MagickTrue ; length = strlen ( DocumentCustomColors ) ; if ( ( LocaleNCompare ( DocumentCustomColors , command , length ) == 0 ) || ( LocaleNCompare ( CMYKCustomColor , command , strlen ( CMYKCustomColor ) ) == 0 ) || ( LocaleNCompare ( SpotColor , command , strlen ( SpotColor ) ) == 0 ) ) { char property [ MagickPathExtent ] , * value ; register char * q ; ( void ) FormatLocaleString ( property , MagickPathExtent , ""ps:SpotColor-%.20g"" , ( double ) ( spotcolor ++ ) ) ; for ( q = command ; * q != '\\0' ; q ++ ) if ( isspace ( ( int ) ( unsigned char ) * q ) != 0 ) break ; value = ConstantString ( q ) ; ( void ) SubstituteString ( & value , ""("" , """" ) ; ( void ) SubstituteString ( & value , "")"" , """" ) ; ( void ) StripString ( value ) ; if ( * value != '\\0' ) ( void ) SetImageProperty ( image , property , value , exception ) ; value = DestroyString ( value ) ; continue ; } if ( image_info -> page != ( char * ) NULL ) continue ; count = 0 ; i = 0 ; if ( LocaleNCompare ( BoundingBox , command , strlen ( BoundingBox ) ) == 0 ) { count = ( ssize_t ) sscanf ( command , BoundingBox ""%lf%lf%lf%lf"" , & bounds . x1 , & bounds . y1 , & bounds . x2 , & bounds . y2 ) ; i = 2 ; } if ( LocaleNCompare ( DocumentMedia , command , strlen ( DocumentMedia ) ) == 0 ) { count = ( ssize_t ) sscanf ( command , DocumentMedia ""%lf%lf%lf%lf"" , & bounds . x1 , & bounds . y1 , & bounds . x2 , & bounds . y2 ) ; i = 1 ; } if ( LocaleNCompare ( HiResBoundingBox , command , strlen ( HiResBoundingBox ) ) == 0 ) { count = ( ssize_t ) sscanf ( command , HiResBoundingBox ""%lf%lf%lf%lf"" , & bounds . x1 , & bounds . y1 , & bounds . x2 , & bounds . y2 ) ; i = 3 ; } if ( LocaleNCompare ( PageBoundingBox , command , strlen ( PageBoundingBox ) ) == 0 ) { count = ( ssize_t ) sscanf ( command , PageBoundingBox ""%lf%lf%lf%lf"" , & bounds . x1 , & bounds . y1 , & bounds . x2 , & bounds . y2 ) ; i = 1 ; } if ( LocaleNCompare ( PageMedia , command , strlen ( PageMedia ) ) == 0 ) { count = ( ssize_t ) sscanf ( command , PageMedia ""%lf%lf%lf%lf"" , & bounds . x1 , & bounds . y1 , & bounds . x2 , & bounds . y2 ) ; i = 1 ; } if ( ( count != 4 ) || ( i < ( ssize_t ) priority ) ) continue ; if ( ( fabs ( bounds . x2 - bounds . x1 ) <= fabs ( hires_bounds . x2 - hires_bounds . x1 ) ) || ( fabs ( bounds . y2 - bounds . y1 ) <= fabs ( hires_bounds . y2 - hires_bounds . y1 ) ) ) if ( i == ( ssize_t ) priority ) continue ; hires_bounds = bounds ; priority = i ; } if ( ( fabs ( hires_bounds . x2 - hires_bounds . x1 ) >= MagickEpsilon ) && ( fabs ( hires_bounds . y2 - hires_bounds . y1 ) >= MagickEpsilon ) ) { ( void ) FormatLocaleString ( geometry , MagickPathExtent , ""%gx%g%+.15g%+.15g"" , hires_bounds . x2 - hires_bounds . x1 , hires_bounds . y2 - hires_bounds . y1 , hires_bounds . x1 , hires_bounds . y1 ) ; ( void ) SetImageProperty ( image , ""ps:HiResBoundingBox"" , geometry , exception ) ; page . width = ( size_t ) ceil ( ( double ) ( ( hires_bounds . x2 - hires_bounds . x1 ) * resolution . x / delta . x ) - 0.5 ) ; page . height = ( size_t ) ceil ( ( double ) ( ( hires_bounds . y2 - hires_bounds . y1 ) * resolution . y / delta . y ) - 0.5 ) ; } fitPage = MagickFalse ; option = GetImageOption ( image_info , ""eps:fit-page"" ) ; if ( option != ( char * ) NULL ) { char * page_geometry ; page_geometry = GetPageGeometry ( option ) ; flags = ParseMetaGeometry ( page_geometry , & page . x , & page . y , & page . width , & page . height ) ; if ( flags == NoValue ) { ( void ) ThrowMagickException ( exception , GetMagickModule ( ) , OptionError , ""InvalidGeometry"" , ""`%s\'"" , option ) ; image = DestroyImage ( image ) ; return ( ( Image * ) NULL ) ; } page . width = ( size_t ) ceil ( ( double ) ( page . width * image -> resolution . x / delta . x ) - 0.5 ) ; page . height = ( size_t ) ceil ( ( double ) ( page . height * image -> resolution . y / delta . y ) - 0.5 ) ; page_geometry = DestroyString ( page_geometry ) ; fitPage = MagickTrue ; } if ( IssRGBCompatibleColorspace ( image_info -> colorspace ) != MagickFalse ) cmyk = MagickFalse ; file = AcquireUniqueFileResource ( postscript_filename ) ; if ( file == - 1 ) { ThrowFileException ( exception , FileOpenError , ""UnableToOpenFile"" , image_info -> filename ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } ( void ) CopyMagickString ( command , ""/setpagedevice{pop}bind1indexwhere{"" ""dupwcheck{31rollput}{popdef}ifelse}{def}ifelse\\n"" ""<true>>setpagedevice\\n"" , MagickPathExtent ) ; count = write ( file , command , ( unsigned int ) strlen ( command ) ) ; if ( image_info -> page == ( char * ) NULL ) { char translate_geometry [ MagickPathExtent ] ; ( void ) FormatLocaleString ( translate_geometry , MagickPathExtent , ""%g%gtranslate\\n"" , - bounds . x1 , - bounds . y1 ) ; count = write ( file , translate_geometry , ( unsigned int ) strlen ( translate_geometry ) ) ; } file = close ( file ) - 1 ; if ( image_info -> monochrome != MagickFalse ) delegate_info = GetDelegateInfo ( ""ps:mono"" , ( char * ) NULL , exception ) ; else if ( cmyk != MagickFalse ) delegate_info = GetDelegateInfo ( ""ps:cmyk"" , ( char * ) NULL , exception ) ; else delegate_info = GetDelegateInfo ( ""ps:alpha"" , ( char * ) NULL , exception ) ; if ( delegate_info == ( const DelegateInfo * ) NULL ) { ( void ) RelinquishUniqueFileResource ( postscript_filename ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } density = AcquireString ( """" ) ; options = AcquireString ( """" ) ; ( void ) FormatLocaleString ( density , MagickPathExtent , ""%gx%g"" , resolution . x , resolution . y ) ; ( void ) FormatLocaleString ( options , MagickPathExtent , ""-g%.20gx%.20g"" , ( double ) page . width , ( double ) page . height ) ; read_info = CloneImageInfo ( image_info ) ; * read_info -> magick = '\\0' ; if ( read_info -> number_scenes != 0 ) { char pages [ MagickPathExtent ] ; ( void ) FormatLocaleString ( pages , MagickPathExtent , ""-dFirstPage=%.20g"" ""-dLastPage=%.20g"" , ( double ) read_info -> scene + 1 , ( double ) ( read_info -> scene + read_info -> number_scenes ) ) ; ( void ) ConcatenateMagickString ( options , pages , MagickPathExtent ) ; read_info -> number_scenes = 0 ; if ( read_info -> scenes != ( char * ) NULL ) * read_info -> scenes = '\\0' ; } if ( * image_info -> magick == 'E' ) { option = GetImageOption ( image_info , ""eps:use-cropbox"" ) ; if ( ( option == ( const char * ) NULL ) || ( IsStringTrue ( option ) != MagickFalse ) ) ( void ) ConcatenateMagickString ( options , ""-dEPSCrop"" , MagickPathExtent ) ; if ( fitPage != MagickFalse ) ( void ) ConcatenateMagickString ( options , ""-dEPSFitPage"" , MagickPathExtent ) ; } ( void ) CopyMagickString ( filename , read_info -> filename , MagickPathExtent ) ; ( void ) AcquireUniqueFilename ( filename ) ; ( void ) RelinquishUniqueFileResource ( filename ) ; ( void ) ConcatenateMagickString ( filename , ""%d"" , MagickPathExtent ) ; ( void ) FormatLocaleString ( command , MagickPathExtent , GetDelegateCommands ( delegate_info ) , read_info -> antialias != MagickFalse ? 4 : 1 , read_info -> antialias != MagickFalse ? 4 : 1 , density , options , filename , postscript_filename , input_filename ) ; options = DestroyString ( options ) ; density = DestroyString ( density ) ; * message = '\\0' ; status = InvokePostscriptDelegate ( read_info -> verbose , command , message , exception ) ; ( void ) InterpretImageFilename ( image_info , image , filename , 1 , read_info -> filename , exception ) ; if ( ( status == MagickFalse ) || ( IsPostscriptRendered ( read_info -> filename ) == MagickFalse ) ) { ( void ) ConcatenateMagickString ( command , ""-cshowpage"" , MagickPathExtent ) ; status = InvokePostscriptDelegate ( read_info -> verbose , command , message , exception ) ; } ( void ) RelinquishUniqueFileResource ( postscript_filename ) ; ( void ) RelinquishUniqueFileResource ( input_filename ) ; postscript_image = ( Image * ) NULL ; if ( status == MagickFalse ) for ( i = 1 ; ; i ++ ) { ( void ) InterpretImageFilename ( image_info , image , filename , ( int ) i , read_info -> filename , exception ) ; if ( IsPostscriptRendered ( read_info -> filename ) == MagickFalse ) break ; ( void ) RelinquishUniqueFileResource ( read_info -> filename ) ; } else for ( i = 1 ; ; i ++ ) { ( void ) InterpretImageFilename ( image_info , image , filename , ( int ) i , read_info -> filename , exception ) ; if ( IsPostscriptRendered ( read_info -> filename ) == MagickFalse ) break ; read_info -> blob = NULL ; read_info -> length = 0 ; next = ReadImage ( read_info , exception ) ; ( void ) RelinquishUniqueFileResource ( read_info -> filename ) ; if ( next == ( Image * ) NULL ) break ; AppendImageToList ( & postscript_image , next ) ; } ( void ) RelinquishUniqueFileResource ( read_info -> filename ) ; read_info = DestroyImageInfo ( read_info ) ; if ( postscript_image == ( Image * ) NULL ) { if ( * message != '\\0' ) ( void ) ThrowMagickException ( exception , GetMagickModule ( ) , DelegateError , ""PostscriptDelegateFailed"" , ""`%s\'"" , message ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } if ( LocaleCompare ( postscript_image -> magick , ""BMP"" ) == 0 ) { Image * cmyk_image ; cmyk_image = ConsolidateCMYKImages ( postscript_image , exception ) ; if ( cmyk_image != ( Image * ) NULL ) { postscript_image = DestroyImageList ( postscript_image ) ; postscript_image = cmyk_image ; } } ( void ) SeekBlob ( image , 0 , SEEK_SET ) ; for ( c = ReadBlobByte ( image ) ; c != EOF ; c = ReadBlobByte ( image ) ) { * p ++ = ( char ) c ; if ( ( strchr ( ""\\n\\r%"" , c ) == ( char * ) NULL ) && ( ( size_t ) ( p - command ) < ( MagickPathExtent - 1 ) ) ) continue ; * p = '\\0' ; p = command ; if ( LocaleNCompare ( BeginDocument , command , strlen ( BeginDocument ) ) == 0 ) skip = MagickTrue ; if ( LocaleNCompare ( EndDocument , command , strlen ( EndDocument ) ) == 0 ) skip = MagickFalse ; if ( skip != MagickFalse ) continue ; if ( LocaleNCompare ( ICCProfile , command , strlen ( ICCProfile ) ) == 0 ) { unsigned char * datum ; profile = AcquireStringInfo ( MagickPathExtent ) ; datum = GetStringInfoDatum ( profile ) ; for ( i = 0 ; ( c = ProfileInteger ( image , hex_digits ) ) != EOF ; i ++ ) { if ( i >= ( ssize_t ) GetStringInfoLength ( profile ) ) { SetStringInfoLength ( profile , ( size_t ) i << 1 ) ; datum = GetStringInfoDatum ( profile ) ; } datum [ i ] = ( unsigned char ) c ; } SetStringInfoLength ( profile , ( size_t ) i + 1 ) ; ( void ) SetImageProfile ( image , ""icc"" , profile , exception ) ; profile = DestroyStringInfo ( profile ) ; continue ; } if ( LocaleNCompare ( PhotoshopProfile , command , strlen ( PhotoshopProfile ) ) == 0 ) { unsigned char * q ; count = ( ssize_t ) sscanf ( command , PhotoshopProfile ""%lu"" , & extent ) ; if ( count != 1 ) continue ; length = extent ; if ( ( MagickSizeType ) length > GetBlobSize ( image ) ) ThrowReaderException ( CorruptImageError , ""InsufficientImageDataInFile"" ) ; profile = BlobToStringInfo ( ( const void * ) NULL , length ) ; if ( profile != ( StringInfo * ) NULL ) { q = GetStringInfoDatum ( profile ) ; for ( i = 0 ; i < ( ssize_t ) length ; i ++ ) * q ++ = ( unsigned char ) ProfileInteger ( image , hex_digits ) ; ( void ) SetImageProfile ( image , ""8bim"" , profile , exception ) ; profile = DestroyStringInfo ( profile ) ; } continue ; } if ( LocaleNCompare ( BeginXMPPacket , command , strlen ( BeginXMPPacket ) ) == 0 ) { p = command ; profile = StringToStringInfo ( command ) ; for ( i = ( ssize_t ) GetStringInfoLength ( profile ) - 1 ; c != EOF ; i ++ ) { SetStringInfoLength ( profile , ( size_t ) ( i + 1 ) ) ; c = ReadBlobByte ( image ) ; GetStringInfoDatum ( profile ) [ i ] = ( unsigned char ) c ; * p ++ = ( char ) c ; if ( ( strchr ( ""\\n\\r%"" , c ) == ( char * ) NULL ) && ( ( size_t ) ( p - command ) < ( MagickPathExtent - 1 ) ) ) continue ; * p = '\\0' ; p = command ; if ( LocaleNCompare ( EndXMPPacket , command , strlen ( EndXMPPacket ) ) == 0 ) break ; } SetStringInfoLength ( profile , ( size_t ) i ) ; ( void ) SetImageProfile ( image , ""xmp"" , profile , exception ) ; profile = DestroyStringInfo ( profile ) ; continue ; } } ( void ) CloseBlob ( image ) ; if ( image_info -> number_scenes != 0 ) { Image * clone_image ; for ( i = 0 ; i < ( ssize_t ) image_info -> scene ; i ++ ) { clone_image = CloneImage ( postscript_image , 1 , 1 , MagickTrue , exception ) ; if ( clone_image != ( Image * ) NULL ) PrependImageToList ( & postscript_image , clone_image ) ; } } do { ( void ) CopyMagickString ( postscript_image -> filename , filename , MagickPathExtent ) ; ( void ) CopyMagickString ( postscript_image -> magick , image -> magick , MagickPathExtent ) ; if ( columns != 0 ) postscript_image -> magick_columns = columns ; if ( rows != 0 ) postscript_image -> magick_rows = rows ; postscript_image -> page = page ; ( void ) CloneImageProfiles ( postscript_image , image ) ; ( void ) CloneImageProperties ( postscript_image , image ) ; next = SyncNextImageInList ( postscript_image ) ; if ( next != ( Image * ) NULL ) postscript_image = next ; } while ( next != ( Image * ) NULL ) ; image = DestroyImageList ( image ) ; scene = 0 ; for ( next = GetFirstImageInList ( postscript_image ) ; next != ( Image * ) NULL ; ) { next -> scene = scene ++ ; next = GetNextImageInList ( next ) ; } return ( GetFirstImageInList ( postscript_image ) ) ; } "," ""`%s\'"" , option ) ; page_geometry = DestroyString ( page_geometry ",ImageMagick@ImageMagick/35ccb468ee2dcbe8ce9cf1e2f1957acc27f54c34,CVE-2019-13137,https://github.com/ImageMagick/ImageMagick/commit/35ccb468ee2dcbe8ce9cf1e2f1957acc27f54c34,2019-07-01T20:15Z 859,CWE-264,"CWE-264 static int do_ipv6_getsockopt ( struct sock * sk , int level , int optname , char __user * optval , int __user * optlen , unsigned int flags ) { struct ipv6_pinfo * np = inet6_sk ( sk ) ; int len ; int val ; if ( ip6_mroute_opt ( optname ) ) return ip6_mroute_getsockopt ( sk , optname , optval , optlen ) ; if ( get_user ( len , optlen ) ) return - EFAULT ; switch ( optname ) { case IPV6_ADDRFORM : if ( sk -> sk_protocol != IPPROTO_UDP && sk -> sk_protocol != IPPROTO_UDPLITE && sk -> sk_protocol != IPPROTO_TCP ) return - ENOPROTOOPT ; if ( sk -> sk_state != TCP_ESTABLISHED ) return - ENOTCONN ; val = sk -> sk_family ; break ; case MCAST_MSFILTER : { struct group_filter gsf ; int err ; if ( len < GROUP_FILTER_SIZE ( 0 ) ) return - EINVAL ; if ( copy_from_user ( & gsf , optval , GROUP_FILTER_SIZE ( 0 ) ) ) return - EFAULT ; if ( gsf . gf_group . ss_family != AF_INET6 ) return - EADDRNOTAVAIL ; lock_sock ( sk ) ; err = ip6_mc_msfget ( sk , & gsf , ( struct group_filter __user * ) optval , optlen ) ; release_sock ( sk ) ; return err ; } case IPV6_2292PKTOPTIONS : { struct msghdr msg ; struct sk_buff * skb ; if ( sk -> sk_type != SOCK_STREAM ) return - ENOPROTOOPT ; msg . msg_control = optval ; msg . msg_controllen = len ; msg . msg_flags = flags ; lock_sock ( sk ) ; skb = np -> pktoptions ; if ( skb ) ip6_datagram_recv_ctl ( sk , & msg , skb ) ; release_sock ( sk ) ; if ( ! skb ) { if ( np -> rxopt . bits . rxinfo ) { struct in6_pktinfo src_info ; src_info . ipi6_ifindex = np -> mcast_oif ? np -> mcast_oif : np -> sticky_pktinfo . ipi6_ifindex ; src_info . ipi6_addr = np -> mcast_oif ? sk -> sk_v6_daddr : np -> sticky_pktinfo . ipi6_addr ; put_cmsg ( & msg , SOL_IPV6 , IPV6_PKTINFO , sizeof ( src_info ) , & src_info ) ; } if ( np -> rxopt . bits . rxhlim ) { int hlim = np -> mcast_hops ; put_cmsg ( & msg , SOL_IPV6 , IPV6_HOPLIMIT , sizeof ( hlim ) , & hlim ) ; } if ( np -> rxopt . bits . rxtclass ) { int tclass = ( int ) ip6_tclass ( np -> rcv_flowinfo ) ; put_cmsg ( & msg , SOL_IPV6 , IPV6_TCLASS , sizeof ( tclass ) , & tclass ) ; } if ( np -> rxopt . bits . rxoinfo ) { struct in6_pktinfo src_info ; src_info . ipi6_ifindex = np -> mcast_oif ? np -> mcast_oif : np -> sticky_pktinfo . ipi6_ifindex ; src_info . ipi6_addr = np -> mcast_oif ? sk -> sk_v6_daddr : np -> sticky_pktinfo . ipi6_addr ; put_cmsg ( & msg , SOL_IPV6 , IPV6_2292PKTINFO , sizeof ( src_info ) , & src_info ) ; } if ( np -> rxopt . bits . rxohlim ) { int hlim = np -> mcast_hops ; put_cmsg ( & msg , SOL_IPV6 , IPV6_2292HOPLIMIT , sizeof ( hlim ) , & hlim ) ; } if ( np -> rxopt . bits . rxflow ) { __be32 flowinfo = np -> rcv_flowinfo ; put_cmsg ( & msg , SOL_IPV6 , IPV6_FLOWINFO , sizeof ( flowinfo ) , & flowinfo ) ; } } len -= msg . msg_controllen ; return put_user ( len , optlen ) ; } case IPV6_MTU : { struct dst_entry * dst ; val = 0 ; rcu_read_lock ( ) ; dst = __sk_dst_get ( sk ) ; if ( dst ) val = dst_mtu ( dst ) ; rcu_read_unlock ( ) ; if ( ! val ) return - ENOTCONN ; break ; } case IPV6_V6ONLY : val = sk -> sk_ipv6only ; break ; case IPV6_RECVPKTINFO : val = np -> rxopt . bits . rxinfo ; break ; case IPV6_2292PKTINFO : val = np -> rxopt . bits . rxoinfo ; break ; case IPV6_RECVHOPLIMIT : val = np -> rxopt . bits . rxhlim ; break ; case IPV6_2292HOPLIMIT : val = np -> rxopt . bits . rxohlim ; break ; case IPV6_RECVRTHDR : val = np -> rxopt . bits . srcrt ; break ; case IPV6_2292RTHDR : val = np -> rxopt . bits . osrcrt ; break ; case IPV6_HOPOPTS : case IPV6_RTHDRDSTOPTS : case IPV6_RTHDR : case IPV6_DSTOPTS : { lock_sock ( sk ) ; len = ipv6_getsockopt_sticky ( sk , np -> opt , optname , optval , len ) ; release_sock ( sk ) ; if ( len < 0 ) return len ; return put_user ( len , optlen ) ; } case IPV6_RECVHOPOPTS : val = np -> rxopt . bits . hopopts ; break ; case IPV6_2292HOPOPTS : val = np -> rxopt . bits . ohopopts ; break ; case IPV6_RECVDSTOPTS : val = np -> rxopt . bits . dstopts ; break ; case IPV6_2292DSTOPTS : val = np -> rxopt . bits . odstopts ; break ; case IPV6_TCLASS : val = np -> tclass ; break ; case IPV6_RECVTCLASS : val = np -> rxopt . bits . rxtclass ; break ; case IPV6_FLOWINFO : val = np -> rxopt . bits . rxflow ; break ; case IPV6_RECVPATHMTU : val = np -> rxopt . bits . rxpmtu ; break ; case IPV6_PATHMTU : { struct dst_entry * dst ; struct ip6_mtuinfo mtuinfo ; if ( len < sizeof ( mtuinfo ) ) return - EINVAL ; len = sizeof ( mtuinfo ) ; memset ( & mtuinfo , 0 , sizeof ( mtuinfo ) ) ; rcu_read_lock ( ) ; dst = __sk_dst_get ( sk ) ; if ( dst ) mtuinfo . ip6m_mtu = dst_mtu ( dst ) ; rcu_read_unlock ( ) ; if ( ! mtuinfo . ip6m_mtu ) return - ENOTCONN ; if ( put_user ( len , optlen ) ) return - EFAULT ; if ( copy_to_user ( optval , & mtuinfo , len ) ) return - EFAULT ; return 0 ; } case IPV6_TRANSPARENT : val = inet_sk ( sk ) -> transparent ; break ; case IPV6_RECVORIGDSTADDR : val = np -> rxopt . bits . rxorigdstaddr ; break ; case IPV6_UNICAST_HOPS : case IPV6_MULTICAST_HOPS : { struct dst_entry * dst ; if ( optname == IPV6_UNICAST_HOPS ) val = np -> hop_limit ; else val = np -> mcast_hops ; if ( val < 0 ) { rcu_read_lock ( ) ; dst = __sk_dst_get ( sk ) ; if ( dst ) val = ip6_dst_hoplimit ( dst ) ; rcu_read_unlock ( ) ; } if ( val < 0 ) val = sock_net ( sk ) -> ipv6 . devconf_all -> hop_limit ; break ; } case IPV6_MULTICAST_LOOP : val = np -> mc_loop ; break ; case IPV6_MULTICAST_IF : val = np -> mcast_oif ; break ; case IPV6_UNICAST_IF : val = ( __force int ) htonl ( ( __u32 ) np -> ucast_oif ) ; break ; case IPV6_MTU_DISCOVER : val = np -> pmtudisc ; break ; case IPV6_RECVERR : val = np -> recverr ; break ; case IPV6_FLOWINFO_SEND : val = np -> sndflow ; break ; case IPV6_FLOWLABEL_MGR : { struct in6_flowlabel_req freq ; int flags ; if ( len < sizeof ( freq ) ) return - EINVAL ; if ( copy_from_user ( & freq , optval , sizeof ( freq ) ) ) return - EFAULT ; if ( freq . flr_action != IPV6_FL_A_GET ) return - EINVAL ; len = sizeof ( freq ) ; flags = freq . flr_flags ; memset ( & freq , 0 , sizeof ( freq ) ) ; val = ipv6_flowlabel_opt_get ( sk , & freq , flags ) ; if ( val < 0 ) return val ; if ( put_user ( len , optlen ) ) return - EFAULT ; if ( copy_to_user ( optval , & freq , len ) ) return - EFAULT ; return 0 ; } case IPV6_ADDR_PREFERENCES : val = 0 ; if ( np -> srcprefs & IPV6_PREFER_SRC_TMP ) val |= IPV6_PREFER_SRC_TMP ; else if ( np -> srcprefs & IPV6_PREFER_SRC_PUBLIC ) val |= IPV6_PREFER_SRC_PUBLIC ; else { val |= IPV6_PREFER_SRC_PUBTMP_DEFAULT ; } if ( np -> srcprefs & IPV6_PREFER_SRC_COA ) val |= IPV6_PREFER_SRC_COA ; else val |= IPV6_PREFER_SRC_HOME ; break ; case IPV6_MINHOPCOUNT : val = np -> min_hopcount ; break ; case IPV6_DONTFRAG : val = np -> dontfrag ; break ; case IPV6_AUTOFLOWLABEL : val = np -> autoflowlabel ; break ; default : return - ENOPROTOOPT ; } len = min_t ( unsigned int , sizeof ( int ) , len ) ; if ( put_user ( len , optlen ) ) return - EFAULT ; if ( copy_to_user ( optval , & val , len ) ) return - EFAULT ; return 0 ; } "," IPV6_DSTOPTS : { struct ipv6_txoptions * opt ; sk ) ; opt = rcu_dereference_protected ( np -> opt , sock_owned_by_user ( sk ) ) ; ( sk , opt , optname ",torvalds@linux/45f6fad84cc305103b28d73482b344d7f5b76f39,CVE-2016-3841,https://github.com/torvalds/linux/commit/45f6fad84cc305103b28d73482b344d7f5b76f39,2016-08-06T20:59Z 860,CWE-189,"CWE-189 static struct berval * * krb5_encode_krbsecretkey ( krb5_key_data * key_data_in , int n_key_data , krb5_kvno mkvno ) { struct berval * * ret = NULL ; int currkvno ; int num_versions = 1 ; int i , j , last ; krb5_error_code err = 0 ; krb5_key_data * key_data ; if ( n_key_data <= 0 ) return NULL ; key_data = k5calloc ( n_key_data , sizeof ( * key_data ) , & err ) ; if ( key_data_in == NULL ) goto cleanup ; memcpy ( key_data , key_data_in , n_key_data * sizeof ( * key_data ) ) ; for ( i = 0 ; i < n_key_data ; i ++ ) { if ( key_data [ i ] . key_data_ver == 1 ) { key_data [ i ] . key_data_ver = 2 ; key_data [ i ] . key_data_type [ 1 ] = KRB5_KDB_SALTTYPE_NORMAL ; key_data [ i ] . key_data_length [ 1 ] = 0 ; key_data [ i ] . key_data_contents [ 1 ] = NULL ; } } for ( i = 0 ; i < n_key_data - 1 ; i ++ ) if ( key_data [ i ] . key_data_kvno != key_data [ i + 1 ] . key_data_kvno ) num_versions ++ ; ret = ( struct berval * * ) calloc ( num_versions + 1 , sizeof ( struct berval * ) ) ; if ( ret == NULL ) { err = ENOMEM ; goto cleanup ; } for ( i = 0 , last = 0 , j = 0 , currkvno = key_data [ 0 ] . key_data_kvno ; i < n_key_data ; i ++ ) { krb5_data * code ; if ( i == n_key_data - 1 || key_data [ i + 1 ] . key_data_kvno != currkvno ) { ret [ j ] = k5alloc ( sizeof ( struct berval ) , & err ) ; if ( ret [ j ] == NULL ) goto cleanup ; err = asn1_encode_sequence_of_keys ( key_data + last , ( krb5_int16 ) i - last + 1 , mkvno , & code ) ; if ( err ) goto cleanup ; ret [ j ] -> bv_len = code -> length ; ret [ j ] -> bv_val = code -> data ; free ( code ) ; j ++ ; last = i + 1 ; currkvno = key_data [ i ] . key_data_kvno ; } } ret [ num_versions ] = NULL ; cleanup : free ( key_data ) ; if ( err != 0 ) { if ( ret != NULL ) { for ( i = 0 ; i <= num_versions ; i ++ ) if ( ret [ i ] != NULL ) free ( ret [ i ] ) ; free ( ret ) ; ret = NULL ; } } return ret ; } "," + 1 ; if ( i < n_key_data - 1 ) key_data [ i + 1 ",krb5@krb5/dc7ed55c689d57de7f7408b34631bf06fec9dab1,CVE-2014-4345,https://github.com/krb5/krb5/commit/dc7ed55c689d57de7f7408b34631bf06fec9dab1,2014-08-14T05:01Z 861,CWE-119,"CWE-119 static void ctrycatchfinally ( JF , js_Ast * trystm , js_Ast * catchvar , js_Ast * catchstm , js_Ast * finallystm ) { int L1 , L2 , L3 ; L1 = emitjump ( J , F , OP_TRY ) ; { L2 = emitjump ( J , F , OP_TRY ) ; { cstm ( J , F , finallystm ) ; emit ( J , F , OP_THROW ) ; } label ( J , F , L2 ) ; if ( F -> strict ) { checkfutureword ( J , F , catchvar ) ; if ( ! strcmp ( catchvar -> string , ""arguments"" ) ) jsC_error ( J , catchvar , ""redefining\'arguments\'isnotallowedinstrictmode"" ) ; if ( ! strcmp ( catchvar -> string , ""eval"" ) ) jsC_error ( J , catchvar , ""redefining\'eval\'isnotallowedinstrictmode"" ) ; } emitline ( J , F , catchvar ) ; emitstring ( J , F , OP_CATCH , catchvar -> string ) ; cstm ( J , F , catchstm ) ; emit ( J , F , OP_ENDCATCH ) ; L3 = emitjump ( J , F , OP_JUMP ) ; } label ( J , F , L1 ) ; cstm ( J , F , trystm ) ; emit ( J , F , OP_ENDTRY ) ; label ( J , F , L3 ) ; cstm ( J , F , finallystm ) ; } "," OP_ENDCATCH ) ; emit ( J , F , OP_ENDTRY ) ; ",ccxvii@mujs/1e5479084bc9852854feb1ba9bf68b52cd127e02,CVE-2019-11412,https://github.com/ccxvii/mujs/commit/1e5479084bc9852854feb1ba9bf68b52cd127e02,2019-04-22T11:29Z 862,CWE-119,"CWE-119 LIBXSMM_API_INTERN void libxsmm_sparse_csc_reader ( libxsmm_generated_code * io_generated_code , const char * i_csc_file_in , unsigned int * * o_row_idx , unsigned int * * o_column_idx , double * * o_values , unsigned int * o_row_count , unsigned int * o_column_count , unsigned int * o_element_count ) { FILE * l_csc_file_handle ; const unsigned int l_line_length = 512 ; char l_line [ 512 + 1 ] ; unsigned int l_header_read = 0 ; unsigned int * l_column_idx_id = NULL ; unsigned int l_i = 0 ; l_csc_file_handle = fopen ( i_csc_file_in , ""r"" ) ; if ( l_csc_file_handle == NULL ) { LIBXSMM_HANDLE_ERROR ( io_generated_code , LIBXSMM_ERR_CSC_INPUT ) ; return ; } while ( fgets ( l_line , l_line_length , l_csc_file_handle ) != NULL ) { if ( strlen ( l_line ) == l_line_length ) { free ( * o_row_idx ) ; free ( * o_column_idx ) ; free ( * o_values ) ; free ( l_column_idx_id ) ; * o_row_idx = 0 ; * o_column_idx = 0 ; * o_values = 0 ; fclose ( l_csc_file_handle ) ; LIBXSMM_HANDLE_ERROR ( io_generated_code , LIBXSMM_ERR_CSC_READ_LEN ) ; return ; } if ( l_line [ 0 ] == '%' ) { continue ; } else { if ( l_header_read == 0 ) { if ( sscanf ( l_line , ""%u%u%u"" , o_row_count , o_column_count , o_element_count ) == 3 ) { * o_row_idx = ( unsigned int * ) malloc ( sizeof ( unsigned int ) * ( * o_element_count ) ) ; * o_column_idx = ( unsigned int * ) malloc ( sizeof ( unsigned int ) * ( ( size_t ) ( * o_column_count ) + 1 ) ) ; * o_values = ( double * ) malloc ( sizeof ( double ) * ( * o_element_count ) ) ; l_column_idx_id = ( unsigned int * ) malloc ( sizeof ( unsigned int ) * ( * o_column_count ) ) ; if ( ( * o_row_idx == NULL ) || ( * o_column_idx == NULL ) || ( * o_values == NULL ) || ( l_column_idx_id == NULL ) ) { free ( * o_row_idx ) ; free ( * o_column_idx ) ; free ( * o_values ) ; free ( l_column_idx_id ) ; * o_row_idx = 0 ; * o_column_idx = 0 ; * o_values = 0 ; fclose ( l_csc_file_handle ) ; LIBXSMM_HANDLE_ERROR ( io_generated_code , LIBXSMM_ERR_CSC_ALLOC_DATA ) ; return ; } memset ( * o_row_idx , 0 , sizeof ( unsigned int ) * ( * o_element_count ) ) ; memset ( * o_column_idx , 0 , sizeof ( unsigned int ) * ( ( size_t ) ( * o_column_count ) + 1 ) ) ; memset ( * o_values , 0 , sizeof ( double ) * ( * o_element_count ) ) ; memset ( l_column_idx_id , 0 , sizeof ( unsigned int ) * ( * o_column_count ) ) ; for ( l_i = 0 ; l_i <= * o_column_count ; ++ l_i ) { ( * o_column_idx ) [ l_i ] = * o_element_count ; } ( * o_column_idx ) [ 0 ] = 0 ; l_i = 0 ; l_header_read = 1 ; } else { LIBXSMM_HANDLE_ERROR ( io_generated_code , LIBXSMM_ERR_CSC_READ_DESC ) ; fclose ( l_csc_file_handle ) ; return ; } } else { unsigned int l_row = 0 , l_column = 0 ; double l_value = 0 ; if ( sscanf ( l_line , ""%u%u%lf"" , & l_row , & l_column , & l_value ) != 3 ) { free ( * o_row_idx ) ; free ( * o_column_idx ) ; free ( * o_values ) ; free ( l_column_idx_id ) ; * o_row_idx = 0 ; * o_column_idx = 0 ; * o_values = 0 ; fclose ( l_csc_file_handle ) ; LIBXSMM_HANDLE_ERROR ( io_generated_code , LIBXSMM_ERR_CSC_READ_ELEMS ) ; return ; } l_row -- ; l_column -- ; ( * o_row_idx ) [ l_i ] = l_row ; ( * o_values ) [ l_i ] = l_value ; l_i ++ ; l_column_idx_id [ l_column ] = 1 ; ( * o_column_idx ) [ l_column + 1 ] = l_i ; } } } fclose ( l_csc_file_handle ) ; if ( l_i != ( * o_element_count ) ) { free ( * o_row_idx ) ; free ( * o_column_idx ) ; free ( * o_values ) ; free ( l_column_idx_id ) ; * o_row_idx = 0 ; * o_column_idx = 0 ; * o_values = 0 ; LIBXSMM_HANDLE_ERROR ( io_generated_code , LIBXSMM_ERR_CSC_LEN ) ; return ; } if ( l_column_idx_id != NULL ) { for ( l_i = 0 ; l_i < ( * o_column_count ) ; l_i ++ ) { if ( l_column_idx_id [ l_i ] == 0 ) { ( * o_column_idx ) [ l_i + 1 ] = ( * o_column_idx ) [ l_i ] ; } } free ( l_column_idx_id ) ; } } "," { if ( 3 == , o_element_count ) && 0 != * o_row_count && 0 != * o_column_count && 0 != * o_element_count ) { * o_row_idx return ; } LIBXSMM_ASSERT ( 0 != l_row && 0 != l_column ) ; ",hfp@libxsmm/151481489192e6d1997f8bde52c5c425ea41741d,CVE-2018-20542,https://github.com/hfp/libxsmm/commit/151481489192e6d1997f8bde52c5c425ea41741d,2018-12-28T16:29Z 863,CWE-787,"CWE-787 static int tcos_decipher ( sc_card_t * card , const u8 * crgram , size_t crgram_len , u8 * out , size_t outlen ) { sc_context_t * ctx ; sc_apdu_t apdu ; u8 rbuf [ SC_MAX_APDU_BUFFER_SIZE ] ; u8 sbuf [ SC_MAX_APDU_BUFFER_SIZE ] ; tcos_data * data ; int tcos3 , r ; assert ( card != NULL && crgram != NULL && out != NULL ) ; ctx = card -> ctx ; tcos3 = ( card -> type == SC_CARD_TYPE_TCOS_V3 ) ; data = ( tcos_data * ) card -> drv_data ; LOG_FUNC_CALLED ( ctx ) ; sc_log ( ctx , ""TCOS3:%dPKCS1:%d\\n"" , tcos3 , ! ! ( data -> pad_flags & SC_ALGORITHM_RSA_PAD_PKCS1 ) ) ; sc_format_apdu ( card , & apdu , crgram_len > 255 ? SC_APDU_CASE_4_EXT : SC_APDU_CASE_4_SHORT , 0x2A , 0x80 , 0x86 ) ; apdu . resp = rbuf ; apdu . resplen = sizeof ( rbuf ) ; apdu . le = crgram_len ; apdu . data = sbuf ; apdu . lc = apdu . datalen = crgram_len + 1 ; sbuf [ 0 ] = tcos3 ? 0x00 : ( ( data -> pad_flags & SC_ALGORITHM_RSA_PAD_PKCS1 ) ? 0x81 : 0x02 ) ; memcpy ( sbuf + 1 , crgram , crgram_len ) ; r = sc_transmit_apdu ( card , & apdu ) ; LOG_TEST_RET ( card -> ctx , r , ""APDUtransmitfailed"" ) ; if ( apdu . sw1 == 0x90 && apdu . sw2 == 0x00 ) { size_t len = ( apdu . resplen > outlen ) ? outlen : apdu . resplen ; unsigned int offset = 0 ; if ( tcos3 && ( data -> pad_flags & SC_ALGORITHM_RSA_PAD_PKCS1 ) && apdu . resp [ 0 ] == 0 && apdu . resp [ 1 ] == 2 ) { offset = 2 ; while ( offset < len && apdu . resp [ offset ] != 0 ) ++ offset ; offset = ( offset < len - 1 ) ? offset + 1 : 0 ; } memcpy ( out , apdu . resp + offset , len - offset ) ; SC_FUNC_RETURN ( card -> ctx , SC_LOG_DEBUG_VERBOSE , len - offset ) ; } SC_FUNC_RETURN ( card -> ctx , SC_LOG_DEBUG_VERBOSE , sc_check_sw ( card , apdu . sw1 , apdu . sw2 ) ) ; } "," 0x02 ) ; if ( sizeof sbuf - 1 < crgram_len ) return SC_ERROR_INVALID_ARGUMENTS ; ",OpenSC@OpenSC/9d294de90d1cc66956389856e60b6944b27b4817,CVE-2020-26572,https://github.com/OpenSC/OpenSC/commit/9d294de90d1cc66956389856e60b6944b27b4817,2020-10-06T02:15Z 864,CWE-787,"CWE-787 static RD_BOOL mcs_recv_connect_response ( STREAM mcs_data ) { UNUSED ( mcs_data ) ; uint8 result ; int length ; STREAM s ; RD_BOOL is_fastpath ; uint8 fastpath_hdr ; logger ( Protocol , Debug , ""%s()"" , __func__ ) ; s = iso_recv ( & is_fastpath , & fastpath_hdr ) ; if ( s == NULL ) return False ; ber_parse_header ( s , MCS_CONNECT_RESPONSE , & length ) ; ber_parse_header ( s , BER_TAG_RESULT , & length ) ; in_uint8 ( s , result ) ; if ( result != 0 ) { logger ( Protocol , Error , ""mcs_recv_connect_response(),result=%d"" , result ) ; return False ; } ber_parse_header ( s , BER_TAG_INTEGER , & length ) ; in_uint8s ( s , length ) ; mcs_parse_domain_params ( s ) ; ber_parse_header ( s , BER_TAG_OCTET_STRING , & length ) ; sec_process_mcs_data ( s ) ; return s_check_end ( s ) ; } "," uint8 result ; uint32 length ; STREAM ; STREAM s ; struct stream packet return False ; packet = * s ; length ) ; if ( ! s_check_rem ( s , length ) ) { rdp_protocol_error ( ""mcs_recv_connect_response(),consumeconnectidfromstreamwouldoverrun"" , & packet ) ; } ",rdesktop@rdesktop/4dca546d04321a610c1835010b5dad85163b65e1,CVE-2018-8800,https://github.com/rdesktop/rdesktop/commit/4dca546d04321a610c1835010b5dad85163b65e1,2019-02-05T20:29Z 865,CWE-617,"CWE-617 krb5_error_code process_tgs_req ( struct server_handle * handle , krb5_data * pkt , const krb5_fulladdr * from , krb5_data * * response ) { krb5_keyblock * subkey = 0 ; krb5_keyblock * header_key = NULL ; krb5_kdc_req * request = 0 ; krb5_db_entry * server = NULL ; krb5_db_entry * stkt_server = NULL ; krb5_kdc_rep reply ; krb5_enc_kdc_rep_part reply_encpart ; krb5_ticket ticket_reply , * header_ticket = 0 ; int st_idx = 0 ; krb5_enc_tkt_part enc_tkt_reply ; int newtransited = 0 ; krb5_error_code retval = 0 ; krb5_keyblock encrypting_key ; krb5_timestamp kdc_time , authtime = 0 ; krb5_keyblock session_key ; krb5_keyblock * reply_key = NULL ; krb5_key_data * server_key ; krb5_principal cprinc = NULL , sprinc = NULL , altcprinc = NULL ; krb5_last_req_entry * nolrarray [ 2 ] , nolrentry ; int errcode ; const char * status = 0 ; krb5_enc_tkt_part * header_enc_tkt = NULL ; krb5_enc_tkt_part * subject_tkt = NULL ; krb5_db_entry * client = NULL , * header_server = NULL ; krb5_db_entry * local_tgt , * local_tgt_storage = NULL ; krb5_pa_s4u_x509_user * s4u_x509_user = NULL ; krb5_authdata * * kdc_issued_auth_data = NULL ; unsigned int c_flags = 0 , s_flags = 0 ; krb5_boolean is_referral ; const char * emsg = NULL ; krb5_kvno ticket_kvno = 0 ; struct kdc_request_state * state = NULL ; krb5_pa_data * pa_tgs_req ; krb5_data scratch ; krb5_pa_data * * e_data = NULL ; kdc_realm_t * kdc_active_realm = NULL ; krb5_audit_state * au_state = NULL ; krb5_data * * auth_indicators = NULL ; memset ( & reply , 0 , sizeof ( reply ) ) ; memset ( & reply_encpart , 0 , sizeof ( reply_encpart ) ) ; memset ( & ticket_reply , 0 , sizeof ( ticket_reply ) ) ; memset ( & enc_tkt_reply , 0 , sizeof ( enc_tkt_reply ) ) ; session_key . contents = NULL ; retval = decode_krb5_tgs_req ( pkt , & request ) ; if ( retval ) return retval ; sprinc = request -> server ; if ( request -> msg_type != KRB5_TGS_REQ ) { krb5_free_kdc_req ( handle -> kdc_err_context , request ) ; return KRB5_BADMSGTYPE ; } kdc_active_realm = setup_server_realm ( handle , request -> server ) ; if ( kdc_active_realm == NULL ) { krb5_free_kdc_req ( handle -> kdc_err_context , request ) ; return KRB5KDC_ERR_WRONG_REALM ; } errcode = kdc_make_rstate ( kdc_active_realm , & state ) ; if ( errcode != 0 ) { krb5_free_kdc_req ( handle -> kdc_err_context , request ) ; return errcode ; } errcode = kau_init_kdc_req ( kdc_context , request , from , & au_state ) ; if ( errcode ) { krb5_free_kdc_req ( handle -> kdc_err_context , request ) ; return errcode ; } kau_tgs_req ( kdc_context , TRUE , au_state ) ; errcode = kdc_process_tgs_req ( kdc_active_realm , request , from , pkt , & header_ticket , & header_server , & header_key , & subkey , & pa_tgs_req ) ; if ( header_ticket && header_ticket -> enc_part2 ) cprinc = header_ticket -> enc_part2 -> client ; if ( errcode ) { status = ""PROCESS_TGS"" ; goto cleanup ; } if ( ! header_ticket ) { errcode = KRB5_NO_TKT_SUPPLIED ; status = ""UNEXPECTEDNULLinheader_ticket"" ; goto cleanup ; } errcode = kau_make_tkt_id ( kdc_context , header_ticket , & au_state -> tkt_in_id ) ; if ( errcode ) { status = ""GENERATE_TICKET_ID"" ; goto cleanup ; } scratch . length = pa_tgs_req -> length ; scratch . data = ( char * ) pa_tgs_req -> contents ; errcode = kdc_find_fast ( & request , & scratch , subkey , header_ticket -> enc_part2 -> session , state , NULL ) ; sprinc = request -> server ; if ( errcode != 0 ) { status = ""FIND_FAST"" ; goto cleanup ; } errcode = get_local_tgt ( kdc_context , & sprinc -> realm , header_server , & local_tgt , & local_tgt_storage ) ; if ( errcode ) { status = ""GET_LOCAL_TGT"" ; goto cleanup ; } au_state -> request = request ; header_enc_tkt = header_ticket -> enc_part2 ; au_state -> stage = SRVC_PRINC ; setflag ( s_flags , KRB5_KDB_FLAG_ALIAS_OK ) ; if ( isflagset ( request -> kdc_options , KDC_OPT_CANONICALIZE ) ) { setflag ( c_flags , KRB5_KDB_FLAG_CANONICALIZE ) ; setflag ( s_flags , KRB5_KDB_FLAG_CANONICALIZE ) ; } errcode = search_sprinc ( kdc_active_realm , request , s_flags , & server , & status ) ; if ( errcode != 0 ) goto cleanup ; sprinc = server -> princ ; is_referral = is_cross_tgs_principal ( server -> princ ) && ! krb5_principal_compare ( kdc_context , request -> server , server -> princ ) ; au_state -> stage = VALIDATE_POL ; if ( ( errcode = krb5_timeofday ( kdc_context , & kdc_time ) ) ) { status = ""TIME_OF_DAY"" ; goto cleanup ; } if ( ( retval = validate_tgs_request ( kdc_active_realm , request , * server , header_ticket , kdc_time , & status , & e_data ) ) ) { if ( ! status ) status = ""UNKNOWN_REASON"" ; if ( retval == KDC_ERR_POLICY || retval == KDC_ERR_BADOPTION ) au_state -> violation = PROT_CONSTRAINT ; errcode = retval + ERROR_TABLE_BASE_krb5 ; goto cleanup ; } if ( ! is_local_principal ( kdc_active_realm , header_enc_tkt -> client ) ) setflag ( c_flags , KRB5_KDB_FLAG_CROSS_REALM ) ; errcode = kdc_process_s4u2self_req ( kdc_active_realm , request , header_enc_tkt -> client , server , subkey , header_enc_tkt -> session , kdc_time , & s4u_x509_user , & client , & status ) ; if ( s4u_x509_user != NULL || errcode != 0 ) { if ( s4u_x509_user != NULL ) au_state -> s4u2self_user = s4u_x509_user -> user_id . user ; if ( errcode == KDC_ERR_POLICY || errcode == KDC_ERR_BADOPTION ) au_state -> violation = PROT_CONSTRAINT ; au_state -> status = status ; kau_s4u2self ( kdc_context , errcode ? FALSE : TRUE , au_state ) ; au_state -> s4u2self_user = NULL ; } if ( errcode ) goto cleanup ; if ( s4u_x509_user != NULL ) { setflag ( c_flags , KRB5_KDB_FLAG_PROTOCOL_TRANSITION ) ; if ( is_referral ) { errcode = KRB5KDC_ERR_S_PRINCIPAL_UNKNOWN ; status = ""LOOKING_UP_SERVER"" ; goto cleanup ; } } errcode = decrypt_2ndtkt ( kdc_active_realm , request , c_flags , & stkt_server , & status ) ; if ( errcode ) goto cleanup ; if ( isflagset ( request -> kdc_options , KDC_OPT_CNAME_IN_ADDL_TKT ) ) { errcode = kdc_process_s4u2proxy_req ( kdc_active_realm , request , request -> second_ticket [ st_idx ] -> enc_part2 , stkt_server , header_ticket -> enc_part2 -> client , request -> server , & status ) ; if ( errcode == KDC_ERR_POLICY || errcode == KDC_ERR_BADOPTION ) au_state -> violation = PROT_CONSTRAINT ; else if ( errcode ) au_state -> violation = LOCAL_POLICY ; au_state -> status = status ; retval = kau_make_tkt_id ( kdc_context , request -> second_ticket [ st_idx ] , & au_state -> evid_tkt_id ) ; if ( retval ) { status = ""GENERATE_TICKET_ID"" ; errcode = retval ; goto cleanup ; } kau_s4u2proxy ( kdc_context , errcode ? FALSE : TRUE , au_state ) ; if ( errcode ) goto cleanup ; setflag ( c_flags , KRB5_KDB_FLAG_CONSTRAINED_DELEGATION ) ; assert ( krb5_is_tgs_principal ( header_ticket -> server ) ) ; assert ( client == NULL ) ; client = stkt_server ; stkt_server = NULL ; } else if ( request -> kdc_options & KDC_OPT_ENC_TKT_IN_SKEY ) { krb5_db_free_principal ( kdc_context , stkt_server ) ; stkt_server = NULL ; } else assert ( stkt_server == NULL ) ; au_state -> stage = ISSUE_TKT ; errcode = gen_session_key ( kdc_active_realm , request , server , & session_key , & status ) ; if ( errcode ) goto cleanup ; if ( isflagset ( c_flags , KRB5_KDB_FLAG_CONSTRAINED_DELEGATION ) ) subject_tkt = request -> second_ticket [ st_idx ] -> enc_part2 ; else subject_tkt = header_enc_tkt ; authtime = subject_tkt -> times . authtime ; if ( s4u_x509_user == NULL ) { errcode = get_auth_indicators ( kdc_context , subject_tkt , local_tgt , & auth_indicators ) ; if ( errcode ) { status = ""GET_AUTH_INDICATORS"" ; goto cleanup ; } } errcode = check_indicators ( kdc_context , server , auth_indicators ) ; if ( errcode ) { status = ""HIGHER_AUTHENTICATION_REQUIRED"" ; goto cleanup ; } if ( is_referral ) ticket_reply . server = server -> princ ; else ticket_reply . server = request -> server ; enc_tkt_reply . flags = OPTS2FLAGS ( request -> kdc_options ) ; enc_tkt_reply . flags |= COPY_TKT_FLAGS ( header_enc_tkt -> flags ) ; enc_tkt_reply . times . starttime = 0 ; if ( isflagset ( server -> attributes , KRB5_KDB_OK_AS_DELEGATE ) ) setflag ( enc_tkt_reply . flags , TKT_FLG_OK_AS_DELEGATE ) ; setflag ( enc_tkt_reply . flags , TKT_FLG_ENC_PA_REP ) ; enc_tkt_reply . caddrs = header_enc_tkt -> caddrs ; reply_encpart . caddrs = 0 ; reply_encpart . enc_padata = NULL ; if ( isflagset ( request -> kdc_options , KDC_OPT_FORWARDABLE ) ) { if ( isflagset ( c_flags , KRB5_KDB_FLAG_PROTOCOL_TRANSITION ) ) { if ( client != NULL && isflagset ( client -> attributes , KRB5_KDB_DISALLOW_FORWARDABLE ) ) clear ( enc_tkt_reply . flags , TKT_FLG_FORWARDABLE ) ; else if ( ! isflagset ( header_enc_tkt -> flags , TKT_FLG_FORWARDABLE ) ) clear ( enc_tkt_reply . flags , TKT_FLG_FORWARDABLE ) ; else if ( ! is_referral && ! isflagset ( server -> attributes , KRB5_KDB_OK_TO_AUTH_AS_DELEGATE ) ) clear ( enc_tkt_reply . flags , TKT_FLG_FORWARDABLE ) ; } } if ( isflagset ( request -> kdc_options , KDC_OPT_FORWARDED ) || isflagset ( request -> kdc_options , KDC_OPT_PROXY ) ) { enc_tkt_reply . caddrs = request -> addresses ; reply_encpart . caddrs = request -> addresses ; } if ( isflagset ( request -> kdc_options , KDC_OPT_REQUEST_ANONYMOUS ) && ! isflagset ( header_enc_tkt -> flags , TKT_FLG_ANONYMOUS ) ) clear ( enc_tkt_reply . flags , TKT_FLG_ANONYMOUS ) ; if ( isflagset ( request -> kdc_options , KDC_OPT_POSTDATED ) ) { setflag ( enc_tkt_reply . flags , TKT_FLG_INVALID ) ; enc_tkt_reply . times . starttime = request -> from ; } else enc_tkt_reply . times . starttime = kdc_time ; if ( isflagset ( request -> kdc_options , KDC_OPT_VALIDATE ) ) { assert ( isflagset ( c_flags , KRB5_KDB_FLAGS_S4U ) == 0 ) ; ticket_reply = * ( header_ticket ) ; enc_tkt_reply = * ( header_ticket -> enc_part2 ) ; enc_tkt_reply . authorization_data = NULL ; clear ( enc_tkt_reply . flags , TKT_FLG_INVALID ) ; } if ( isflagset ( request -> kdc_options , KDC_OPT_RENEW ) ) { krb5_timestamp old_starttime ; krb5_deltat old_life ; assert ( isflagset ( c_flags , KRB5_KDB_FLAGS_S4U ) == 0 ) ; ticket_reply = * ( header_ticket ) ; enc_tkt_reply = * ( header_ticket -> enc_part2 ) ; enc_tkt_reply . authorization_data = NULL ; old_starttime = enc_tkt_reply . times . starttime ? enc_tkt_reply . times . starttime : enc_tkt_reply . times . authtime ; old_life = ts_delta ( enc_tkt_reply . times . endtime , old_starttime ) ; enc_tkt_reply . times . starttime = kdc_time ; enc_tkt_reply . times . endtime = ts_min ( header_ticket -> enc_part2 -> times . renew_till , ts_incr ( kdc_time , old_life ) ) ; } else { enc_tkt_reply . times . starttime = kdc_time ; kdc_get_ticket_endtime ( kdc_active_realm , enc_tkt_reply . times . starttime , header_enc_tkt -> times . endtime , request -> till , client , server , & enc_tkt_reply . times . endtime ) ; } kdc_get_ticket_renewtime ( kdc_active_realm , request , header_enc_tkt , client , server , & enc_tkt_reply ) ; enc_tkt_reply . times . authtime = authtime ; if ( enc_tkt_reply . times . starttime == enc_tkt_reply . times . authtime ) enc_tkt_reply . times . starttime = 0 ; if ( isflagset ( c_flags , KRB5_KDB_FLAG_PROTOCOL_TRANSITION ) ) { altcprinc = s4u_x509_user -> user_id . user ; } else if ( isflagset ( c_flags , KRB5_KDB_FLAG_CONSTRAINED_DELEGATION ) ) { altcprinc = subject_tkt -> client ; } else { altcprinc = NULL ; } if ( isflagset ( request -> kdc_options , KDC_OPT_ENC_TKT_IN_SKEY ) ) { krb5_enc_tkt_part * t2enc = request -> second_ticket [ st_idx ] -> enc_part2 ; encrypting_key = * ( t2enc -> session ) ; } else { if ( ( errcode = krb5_dbe_find_enctype ( kdc_context , server , - 1 , - 1 , 0 , & server_key ) ) ) { status = ""FINDING_SERVER_KEY"" ; goto cleanup ; } if ( ( errcode = krb5_dbe_decrypt_key_data ( kdc_context , NULL , server_key , & encrypting_key , NULL ) ) ) { status = ""DECRYPT_SERVER_KEY"" ; goto cleanup ; } } if ( isflagset ( c_flags , KRB5_KDB_FLAG_CONSTRAINED_DELEGATION ) ) { clear ( server -> attributes , KRB5_KDB_NO_AUTH_DATA_REQUIRED ) ; } if ( isflagset ( server -> attributes , KRB5_KDB_NO_AUTH_DATA_REQUIRED ) == 0 ) { if ( ! isflagset ( c_flags , KRB5_KDB_FLAGS_S4U ) ) { setflag ( c_flags , KRB5_KDB_FLAG_INCLUDE_PAC ) ; setflag ( c_flags , KRB5_KDB_FLAG_MAP_PRINCIPALS ) ; assert ( client == NULL ) ; errcode = krb5_db_get_principal ( kdc_context , subject_tkt -> client , c_flags , & client ) ; } } if ( isflagset ( c_flags , KRB5_KDB_FLAG_PROTOCOL_TRANSITION ) && ! isflagset ( c_flags , KRB5_KDB_FLAG_CROSS_REALM ) ) enc_tkt_reply . client = s4u_x509_user -> user_id . user ; else enc_tkt_reply . client = subject_tkt -> client ; enc_tkt_reply . session = & session_key ; enc_tkt_reply . transited . tr_type = KRB5_DOMAIN_X500_COMPRESS ; enc_tkt_reply . transited . tr_contents = empty_string ; if ( krb5_realm_compare ( kdc_context , header_ticket -> server , tgs_server ) || krb5_realm_compare ( kdc_context , header_ticket -> server , enc_tkt_reply . client ) ) { enc_tkt_reply . transited = header_enc_tkt -> transited ; } else { if ( header_enc_tkt -> transited . tr_type != KRB5_DOMAIN_X500_COMPRESS ) { status = ""VALIDATE_TRANSIT_TYPE"" ; errcode = KRB5KDC_ERR_TRTYPE_NOSUPP ; goto cleanup ; } memset ( & enc_tkt_reply . transited , 0 , sizeof ( enc_tkt_reply . transited ) ) ; enc_tkt_reply . transited . tr_type = KRB5_DOMAIN_X500_COMPRESS ; if ( ( errcode = add_to_transited ( & header_enc_tkt -> transited . tr_contents , & enc_tkt_reply . transited . tr_contents , header_ticket -> server , enc_tkt_reply . client , request -> server ) ) ) { status = ""ADD_TO_TRANSITED_LIST"" ; goto cleanup ; } newtransited = 1 ; } if ( isflagset ( c_flags , KRB5_KDB_FLAG_CROSS_REALM ) ) { errcode = validate_transit_path ( kdc_context , header_enc_tkt -> client , server , header_server ) ; if ( errcode ) { status = ""NON_TRANSITIVE"" ; goto cleanup ; } } if ( ! isflagset ( request -> kdc_options , KDC_OPT_DISABLE_TRANSITED_CHECK ) ) { errcode = kdc_check_transited_list ( kdc_active_realm , & enc_tkt_reply . transited . tr_contents , krb5_princ_realm ( kdc_context , header_enc_tkt -> client ) , krb5_princ_realm ( kdc_context , request -> server ) ) ; if ( errcode == 0 ) { setflag ( enc_tkt_reply . flags , TKT_FLG_TRANSIT_POLICY_CHECKED ) ; } else { log_tgs_badtrans ( kdc_context , cprinc , sprinc , & enc_tkt_reply . transited . tr_contents , errcode ) ; } } else krb5_klog_syslog ( LOG_INFO , _ ( ""notcheckingtransitpath"" ) ) ; if ( kdc_active_realm -> realm_reject_bad_transit && ! isflagset ( enc_tkt_reply . flags , TKT_FLG_TRANSIT_POLICY_CHECKED ) ) { errcode = KRB5KDC_ERR_POLICY ; status = ""BAD_TRANSIT"" ; au_state -> violation = LOCAL_POLICY ; goto cleanup ; } errcode = handle_authdata ( kdc_context , c_flags , client , server , header_server , local_tgt , subkey != NULL ? subkey : header_ticket -> enc_part2 -> session , & encrypting_key , header_key , pkt , request , s4u_x509_user ? s4u_x509_user -> user_id . user : NULL , subject_tkt , auth_indicators , & enc_tkt_reply ) ; if ( errcode ) { krb5_klog_syslog ( LOG_INFO , _ ( ""TGS_REQ:handle_authdata(%d)"" ) , errcode ) ; status = ""HANDLE_AUTHDATA"" ; goto cleanup ; } ticket_reply . enc_part2 = & enc_tkt_reply ; if ( isflagset ( request -> kdc_options , KDC_OPT_ENC_TKT_IN_SKEY ) ) { krb5_enc_tkt_part * t2enc = request -> second_ticket [ st_idx ] -> enc_part2 ; krb5_principal client2 = t2enc -> client ; if ( ! krb5_principal_compare ( kdc_context , request -> server , client2 ) ) { altcprinc = client2 ; errcode = KRB5KDC_ERR_SERVER_NOMATCH ; status = ""2ND_TKT_MISMATCH"" ; au_state -> status = status ; kau_u2u ( kdc_context , FALSE , au_state ) ; goto cleanup ; } ticket_kvno = 0 ; ticket_reply . enc_part . enctype = t2enc -> session -> enctype ; kau_u2u ( kdc_context , TRUE , au_state ) ; st_idx ++ ; } else { ticket_kvno = server_key -> key_data_kvno ; } errcode = krb5_encrypt_tkt_part ( kdc_context , & encrypting_key , & ticket_reply ) ; if ( ! isflagset ( request -> kdc_options , KDC_OPT_ENC_TKT_IN_SKEY ) ) krb5_free_keyblock_contents ( kdc_context , & encrypting_key ) ; if ( errcode ) { status = ""ENCRYPT_TICKET"" ; goto cleanup ; } ticket_reply . enc_part . kvno = ticket_kvno ; au_state -> stage = ENCR_REP ; reply . msg_type = KRB5_TGS_REP ; if ( isflagset ( c_flags , KRB5_KDB_FLAG_PROTOCOL_TRANSITION ) && krb5int_find_pa_data ( kdc_context , request -> padata , KRB5_PADATA_S4U_X509_USER ) != NULL ) { errcode = kdc_make_s4u2self_rep ( kdc_context , subkey , header_ticket -> enc_part2 -> session , s4u_x509_user , & reply , & reply_encpart ) ; if ( errcode ) { status = ""MAKE_S4U2SELF_PADATA"" ; au_state -> status = status ; } kau_s4u2self ( kdc_context , errcode ? FALSE : TRUE , au_state ) ; if ( errcode ) goto cleanup ; } reply . client = enc_tkt_reply . client ; reply . enc_part . kvno = 0 ; reply . ticket = & ticket_reply ; reply_encpart . session = & session_key ; reply_encpart . nonce = request -> nonce ; reply_encpart . times = enc_tkt_reply . times ; nolrentry . lr_type = KRB5_LRQ_NONE ; nolrentry . value = 0 ; nolrentry . magic = 0 ; nolrarray [ 0 ] = & nolrentry ; nolrarray [ 1 ] = 0 ; reply_encpart . last_req = nolrarray ; reply_encpart . key_exp = 0 ; reply_encpart . flags = enc_tkt_reply . flags ; reply_encpart . server = ticket_reply . server ; reply . enc_part . enctype = subkey ? subkey -> enctype : header_ticket -> enc_part2 -> session -> enctype ; errcode = kdc_fast_response_handle_padata ( state , request , & reply , subkey ? subkey -> enctype : header_ticket -> enc_part2 -> session -> enctype ) ; if ( errcode != 0 ) { status = ""MAKE_FAST_RESPONSE"" ; goto cleanup ; } errcode = kdc_fast_handle_reply_key ( state , subkey ? subkey : header_ticket -> enc_part2 -> session , & reply_key ) ; if ( errcode ) { status = ""MAKE_FAST_REPLY_KEY"" ; goto cleanup ; } errcode = return_enc_padata ( kdc_context , pkt , request , reply_key , server , & reply_encpart , is_referral && isflagset ( s_flags , KRB5_KDB_FLAG_CANONICALIZE ) ) ; if ( errcode ) { status = ""KDC_RETURN_ENC_PADATA"" ; goto cleanup ; } errcode = kau_make_tkt_id ( kdc_context , & ticket_reply , & au_state -> tkt_out_id ) ; if ( errcode ) { status = ""GENERATE_TICKET_ID"" ; goto cleanup ; } if ( kdc_fast_hide_client ( state ) ) reply . client = ( krb5_principal ) krb5_anonymous_principal ( ) ; errcode = krb5_encode_kdc_rep ( kdc_context , KRB5_TGS_REP , & reply_encpart , subkey ? 1 : 0 , reply_key , & reply , response ) ; if ( errcode ) { status = ""ENCODE_KDC_REP"" ; } else { status = ""ISSUE"" ; } memset ( ticket_reply . enc_part . ciphertext . data , 0 , ticket_reply . enc_part . ciphertext . length ) ; free ( ticket_reply . enc_part . ciphertext . data ) ; memset ( reply . enc_part . ciphertext . data , 0 , reply . enc_part . ciphertext . length ) ; free ( reply . enc_part . ciphertext . data ) ; cleanup : assert ( status != NULL ) ; if ( reply_key ) krb5_free_keyblock ( kdc_context , reply_key ) ; if ( errcode ) emsg = krb5_get_error_message ( kdc_context , errcode ) ; au_state -> status = status ; if ( ! errcode ) au_state -> reply = & reply ; kau_tgs_req ( kdc_context , errcode ? FALSE : TRUE , au_state ) ; kau_free_kdc_req ( au_state ) ; log_tgs_req ( kdc_context , from , request , & reply , cprinc , sprinc , altcprinc , authtime , c_flags , status , errcode , emsg ) ; if ( errcode ) { krb5_free_error_message ( kdc_context , emsg ) ; emsg = NULL ; } if ( errcode ) { int got_err = 0 ; if ( status == 0 ) { status = krb5_get_error_message ( kdc_context , errcode ) ; got_err = 1 ; } errcode -= ERROR_TABLE_BASE_krb5 ; if ( errcode < 0 || errcode > KRB_ERR_MAX ) errcode = KRB_ERR_GENERIC ; retval = prepare_error_tgs ( state , request , header_ticket , errcode , ( server != NULL ) ? server -> princ : NULL , response , status , e_data ) ; if ( got_err ) { krb5_free_error_message ( kdc_context , status ) ; status = 0 ; } } if ( header_ticket != NULL ) krb5_free_ticket ( kdc_context , header_ticket ) ; if ( request != NULL ) krb5_free_kdc_req ( kdc_context , request ) ; if ( state ) kdc_free_rstate ( state ) ; krb5_db_free_principal ( kdc_context , server ) ; krb5_db_free_principal ( kdc_context , stkt_server ) ; krb5_db_free_principal ( kdc_context , header_server ) ; krb5_db_free_principal ( kdc_context , client ) ; krb5_db_free_principal ( kdc_context , local_tgt_storage ) ; if ( session_key . contents != NULL ) krb5_free_keyblock_contents ( kdc_context , & session_key ) ; if ( newtransited ) free ( enc_tkt_reply . transited . tr_contents . data ) ; if ( s4u_x509_user != NULL ) krb5_free_pa_s4u_x509_user ( kdc_context , s4u_x509_user ) ; if ( kdc_issued_auth_data != NULL ) krb5_free_authdata ( kdc_context , kdc_issued_auth_data ) ; if ( subkey != NULL ) krb5_free_keyblock ( kdc_context , subkey ) ; if ( header_key != NULL ) krb5_free_keyblock ( kdc_context , header_key ) ; if ( reply . padata ) krb5_free_pa_data ( kdc_context , reply . padata ) ; if ( reply_encpart . enc_padata ) krb5_free_pa_data ( kdc_context , reply_encpart . enc_padata ) ; if ( enc_tkt_reply . authorization_data != NULL ) krb5_free_authdata ( kdc_context , enc_tkt_reply . authorization_data ) ; krb5_free_pa_data ( kdc_context , e_data ) ; k5_free_data_ptr_list ( auth_indicators ) ; return retval ; } "," ; cleanup : if ( status == NULL ) status = ""UNKNOWN_REASON"" ; if ( ",krb5@krb5/ffb35baac6981f9e8914f8f3bffd37f284b85970,CVE-2017-11368,https://github.com/krb5/krb5/commit/ffb35baac6981f9e8914f8f3bffd37f284b85970,2017-08-09T18:29Z 866,CWE-119,"CWE-119 static const xmlChar * xmlParseNameComplex ( xmlParserCtxtPtr ctxt ) { int len = 0 , l ; int c ; int count = 0 ; # ifdef DEBUG nbParseNameComplex ++ ; # endif GROW ; if ( ctxt -> instate == XML_PARSER_EOF ) return ( NULL ) ; c = CUR_CHAR ( l ) ; if ( ( ctxt -> options & XML_PARSE_OLD10 ) == 0 ) { if ( ( c == '' ) || ( c == '>' ) || ( c == '/' ) || ( ! ( ( ( c >= 'a' ) && ( c <= 'z' ) ) || ( ( c >= 'A' ) && ( c <= 'Z' ) ) || ( c == '_' ) || ( c == ':' ) || ( ( c >= 0xC0 ) && ( c <= 0xD6 ) ) || ( ( c >= 0xD8 ) && ( c <= 0xF6 ) ) || ( ( c >= 0xF8 ) && ( c <= 0x2FF ) ) || ( ( c >= 0x370 ) && ( c <= 0x37D ) ) || ( ( c >= 0x37F ) && ( c <= 0x1FFF ) ) || ( ( c >= 0x200C ) && ( c <= 0x200D ) ) || ( ( c >= 0x2070 ) && ( c <= 0x218F ) ) || ( ( c >= 0x2C00 ) && ( c <= 0x2FEF ) ) || ( ( c >= 0x3001 ) && ( c <= 0xD7FF ) ) || ( ( c >= 0xF900 ) && ( c <= 0xFDCF ) ) || ( ( c >= 0xFDF0 ) && ( c <= 0xFFFD ) ) || ( ( c >= 0x10000 ) && ( c <= 0xEFFFF ) ) ) ) ) { return ( NULL ) ; } len += l ; NEXTL ( l ) ; c = CUR_CHAR ( l ) ; while ( ( c != '' ) && ( c != '>' ) && ( c != '/' ) && ( ( ( c >= 'a' ) && ( c <= 'z' ) ) || ( ( c >= 'A' ) && ( c <= 'Z' ) ) || ( ( c >= '0' ) && ( c <= '9' ) ) || ( c == '_' ) || ( c == ':' ) || ( c == '-' ) || ( c == '.' ) || ( c == 0xB7 ) || ( ( c >= 0xC0 ) && ( c <= 0xD6 ) ) || ( ( c >= 0xD8 ) && ( c <= 0xF6 ) ) || ( ( c >= 0xF8 ) && ( c <= 0x2FF ) ) || ( ( c >= 0x300 ) && ( c <= 0x36F ) ) || ( ( c >= 0x370 ) && ( c <= 0x37D ) ) || ( ( c >= 0x37F ) && ( c <= 0x1FFF ) ) || ( ( c >= 0x200C ) && ( c <= 0x200D ) ) || ( ( c >= 0x203F ) && ( c <= 0x2040 ) ) || ( ( c >= 0x2070 ) && ( c <= 0x218F ) ) || ( ( c >= 0x2C00 ) && ( c <= 0x2FEF ) ) || ( ( c >= 0x3001 ) && ( c <= 0xD7FF ) ) || ( ( c >= 0xF900 ) && ( c <= 0xFDCF ) ) || ( ( c >= 0xFDF0 ) && ( c <= 0xFFFD ) ) || ( ( c >= 0x10000 ) && ( c <= 0xEFFFF ) ) ) ) { if ( count ++ > XML_PARSER_CHUNK_SIZE ) { count = 0 ; GROW ; if ( ctxt -> instate == XML_PARSER_EOF ) return ( NULL ) ; } len += l ; NEXTL ( l ) ; c = CUR_CHAR ( l ) ; } } else { if ( ( c == '' ) || ( c == '>' ) || ( c == '/' ) || ( ! IS_LETTER ( c ) && ( c != '_' ) && ( c != ':' ) ) ) { return ( NULL ) ; } len += l ; NEXTL ( l ) ; c = CUR_CHAR ( l ) ; while ( ( c != '' ) && ( c != '>' ) && ( c != '/' ) && ( ( IS_LETTER ( c ) ) || ( IS_DIGIT ( c ) ) || ( c == '.' ) || ( c == '-' ) || ( c == '_' ) || ( c == ':' ) || ( IS_COMBINING ( c ) ) || ( IS_EXTENDER ( c ) ) ) ) { if ( count ++ > XML_PARSER_CHUNK_SIZE ) { count = 0 ; GROW ; if ( ctxt -> instate == XML_PARSER_EOF ) return ( NULL ) ; } len += l ; NEXTL ( l ) ; c = CUR_CHAR ( l ) ; if ( c == 0 ) { count = 0 ; GROW ; if ( ctxt -> instate == XML_PARSER_EOF ) return ( NULL ) ; c = CUR_CHAR ( l ) ; } } } if ( ( len > XML_MAX_NAME_LENGTH ) && ( ( ctxt -> options & XML_PARSE_HUGE ) == 0 ) ) { xmlFatalErr ( ctxt , XML_ERR_NAME_TOO_LONG , ""Name"" ) ; return ( NULL ) ; } if ( ( * ctxt -> input -> cur == '\\n' ) && ( ctxt -> input -> cur [ - 1 ] == '\\r' ) ) return ( xmlDictLookup ( ctxt -> dict , ctxt -> input -> cur - ( len + 1 ) , len ) ) ; return ( xmlDictLookup ( ctxt -> dict , ctxt -> input -> cur - len , len ) ) ; } "," l ) ; } } if XML_ERR_NAME_TOO_LONG , ""Name"" ) ; return ( NULL ) ; } if ( ctxt -> input -> cur - ctxt -> input -> base < len ) { xmlFatalErr ( ctxt , XML_ERR_INTERNAL_ERROR , ""unexpectedchangeofinputbuffer"" ",GNOME@libxml2/e26630548e7d138d2c560844c43820b6767251e3,CVE-2017-16931,https://github.com/GNOME/libxml2/commit/e26630548e7d138d2c560844c43820b6767251e3,2017-11-23T21:29Z 867,CWE-401,"CWE-401 static int i40e_setup_macvlans ( struct i40e_vsi * vsi , u16 macvlan_cnt , u16 qcnt , struct net_device * vdev ) { struct i40e_pf * pf = vsi -> back ; struct i40e_hw * hw = & pf -> hw ; struct i40e_vsi_context ctxt ; u16 sections , qmap , num_qps ; struct i40e_channel * ch ; int i , pow , ret = 0 ; u8 offset = 0 ; if ( vsi -> type != I40E_VSI_MAIN || ! macvlan_cnt ) return - EINVAL ; num_qps = vsi -> num_queue_pairs - ( macvlan_cnt * qcnt ) ; pow = fls ( roundup_pow_of_two ( num_qps ) - 1 ) ; qmap = ( offset << I40E_AQ_VSI_TC_QUE_OFFSET_SHIFT ) | ( pow << I40E_AQ_VSI_TC_QUE_NUMBER_SHIFT ) ; sections = I40E_AQ_VSI_PROP_QUEUE_MAP_VALID ; sections |= I40E_AQ_VSI_PROP_SCHED_VALID ; memset ( & ctxt , 0 , sizeof ( ctxt ) ) ; ctxt . seid = vsi -> seid ; ctxt . pf_num = vsi -> back -> hw . pf_id ; ctxt . vf_num = 0 ; ctxt . uplink_seid = vsi -> uplink_seid ; ctxt . info = vsi -> info ; ctxt . info . tc_mapping [ 0 ] = cpu_to_le16 ( qmap ) ; ctxt . info . mapping_flags |= cpu_to_le16 ( I40E_AQ_VSI_QUE_MAP_CONTIG ) ; ctxt . info . queue_mapping [ 0 ] = cpu_to_le16 ( vsi -> base_queue ) ; ctxt . info . valid_sections |= cpu_to_le16 ( sections ) ; vsi -> rss_size = max_t ( u16 , num_qps , qcnt ) ; ret = i40e_vsi_config_rss ( vsi ) ; if ( ret ) { dev_info ( & pf -> pdev -> dev , ""FailedtoreconfigRSSfornum_queues(%u)\\n"" , vsi -> rss_size ) ; return ret ; } vsi -> reconfig_rss = true ; dev_dbg ( & vsi -> back -> pdev -> dev , ""ReconfiguredRSSwithnum_queues(%u)\\n"" , vsi -> rss_size ) ; vsi -> next_base_queue = num_qps ; vsi -> cnt_q_avail = vsi -> num_queue_pairs - num_qps ; ret = i40e_aq_update_vsi_params ( hw , & ctxt , NULL ) ; if ( ret ) { dev_info ( & pf -> pdev -> dev , ""Updatevsitcconfigfailed,err%saq_err%s\\n"" , i40e_stat_str ( hw , ret ) , i40e_aq_str ( hw , hw -> aq . asq_last_status ) ) ; return ret ; } i40e_vsi_update_queue_map ( vsi , & ctxt ) ; vsi -> info . valid_sections = 0 ; INIT_LIST_HEAD ( & vsi -> macvlan_list ) ; for ( i = 0 ; i < macvlan_cnt ; i ++ ) { ch = kzalloc ( sizeof ( * ch ) , GFP_KERNEL ) ; if ( ! ch ) { ret = - ENOMEM ; goto err_free ; } INIT_LIST_HEAD ( & ch -> list ) ; ch -> num_queue_pairs = qcnt ; if ( ! i40e_setup_channel ( pf , vsi , ch ) ) { ret = - EINVAL ; goto err_free ; } ch -> parent_vsi = vsi ; vsi -> cnt_q_avail -= ch -> num_queue_pairs ; vsi -> macvlan_cnt ++ ; list_add_tail ( & ch -> list , & vsi -> macvlan_list ) ; } return ret ; err_free : dev_info ( & pf -> pdev -> dev , ""Failedtosetupmacvlans\\n"" ) ; i40e_free_macvlan_channels ( vsi ) ; return ret ; } "," - EINVAL ; kfree ( ch ) ; ",torvalds@linux/27d461333459d282ffa4a2bdb6b215a59d493a8f,CVE-2019-19043,https://github.com/torvalds/linux/commit/27d461333459d282ffa4a2bdb6b215a59d493a8f,2019-11-18T06:15Z 868,CWE-119,"CWE-119 static __u8 * ch_report_fixup ( struct hid_device * hdev , __u8 * rdesc , unsigned int * rsize ) { if ( * rsize >= 17 && rdesc [ 11 ] == 0x3c && rdesc [ 12 ] == 0x02 ) { hid_info ( hdev , ""fixingupCherryCymotionreportdescriptor\\n"" ) ; rdesc [ 11 ] = rdesc [ 16 ] = 0xff ; rdesc [ 12 ] = rdesc [ 17 ] = 0x03 ; } return rdesc ; } "," * rsize >= 18 && rdesc [ ",torvalds@linux/4ab25786c87eb20857bbb715c3ae34ec8fd6a214,CVE-2014-3184,https://github.com/torvalds/linux/commit/4ab25786c87eb20857bbb715c3ae34ec8fd6a214,2014-09-28T10:55Z 869,CWE-20,"CWE-20 static ssize_t map_write ( struct file * file , const char __user * buf , size_t count , loff_t * ppos , int cap_setid , struct uid_gid_map * map , struct uid_gid_map * parent_map ) { struct seq_file * seq = file -> private_data ; struct user_namespace * ns = seq -> private ; struct uid_gid_map new_map ; unsigned idx ; struct uid_gid_extent extent ; char * kbuf = NULL , * pos , * next_line ; ssize_t ret ; if ( ( * ppos != 0 ) || ( count >= PAGE_SIZE ) ) return - EINVAL ; kbuf = memdup_user_nul ( buf , count ) ; if ( IS_ERR ( kbuf ) ) return PTR_ERR ( kbuf ) ; mutex_lock ( & userns_state_mutex ) ; memset ( & new_map , 0 , sizeof ( struct uid_gid_map ) ) ; ret = - EPERM ; if ( map -> nr_extents != 0 ) goto out ; if ( cap_valid ( cap_setid ) && ! file_ns_capable ( file , ns , CAP_SYS_ADMIN ) ) goto out ; ret = - EINVAL ; pos = kbuf ; for ( ; pos ; pos = next_line ) { next_line = strchr ( pos , '\\n' ) ; if ( next_line ) { * next_line = '\\0' ; next_line ++ ; if ( * next_line == '\\0' ) next_line = NULL ; } pos = skip_spaces ( pos ) ; extent . first = simple_strtoul ( pos , & pos , 10 ) ; if ( ! isspace ( * pos ) ) goto out ; pos = skip_spaces ( pos ) ; extent . lower_first = simple_strtoul ( pos , & pos , 10 ) ; if ( ! isspace ( * pos ) ) goto out ; pos = skip_spaces ( pos ) ; extent . count = simple_strtoul ( pos , & pos , 10 ) ; if ( * pos && ! isspace ( * pos ) ) goto out ; pos = skip_spaces ( pos ) ; if ( * pos != '\\0' ) goto out ; if ( ( extent . first == ( u32 ) - 1 ) || ( extent . lower_first == ( u32 ) - 1 ) ) goto out ; if ( ( extent . first + extent . count ) <= extent . first ) goto out ; if ( ( extent . lower_first + extent . count ) <= extent . lower_first ) goto out ; if ( mappings_overlap ( & new_map , & extent ) ) goto out ; if ( ( new_map . nr_extents + 1 ) == UID_GID_MAP_MAX_EXTENTS && ( next_line != NULL ) ) goto out ; ret = insert_extent ( & new_map , & extent ) ; if ( ret < 0 ) goto out ; ret = - EINVAL ; } if ( new_map . nr_extents == 0 ) goto out ; ret = - EPERM ; if ( ! new_idmap_permitted ( file , ns , cap_setid , & new_map ) ) goto out ; ret = sort_idmaps ( & new_map ) ; if ( ret < 0 ) goto out ; ret = - EPERM ; for ( idx = 0 ; idx < new_map . nr_extents ; idx ++ ) { struct uid_gid_extent * e ; u32 lower_first ; if ( new_map . nr_extents <= UID_GID_MAP_MAX_BASE_EXTENTS ) e = & new_map . extent [ idx ] ; else e = & new_map . forward [ idx ] ; lower_first = map_id_range_down ( parent_map , e -> lower_first , e -> count ) ; if ( lower_first == ( u32 ) - 1 ) goto out ; e -> lower_first = lower_first ; } if ( new_map . nr_extents <= UID_GID_MAP_MAX_BASE_EXTENTS ) { memcpy ( map -> extent , new_map . extent , new_map . nr_extents * sizeof ( new_map . extent [ 0 ] ) ) ; } else { map -> forward = new_map . forward ; map -> reverse = new_map . reverse ; } smp_wmb ( ) ; map -> nr_extents = new_map . nr_extents ; * ppos = count ; ret = count ; out : if ( ret < 0 && new_map . nr_extents > UID_GID_MAP_MAX_BASE_EXTENTS ) { kfree ( new_map . forward ) ; kfree ( new_map . reverse ) ; map -> forward = NULL ; map -> reverse = NULL ; map -> nr_extents = 0 ; } mutex_unlock ( & userns_state_mutex ) ; kfree ( kbuf ) ; return ret ; } "," & new_map ) ) goto out lower_first ; } ret = sort_idmaps ( & new_map ) ; if ( ret < 0 ) goto out ; ",torvalds@linux/d2f007dbe7e4c9583eea6eb04d60001e85c6f1bd,CVE-2018-18955,https://github.com/torvalds/linux/commit/d2f007dbe7e4c9583eea6eb04d60001e85c6f1bd,2018-11-16T20:29Z 870,CWE-787,"CWE-787 static int _server_handle_vCont ( libgdbr_t * g , int ( * cmd_cb ) ( void * , const char * , char * , size_t ) , void * core_ptr ) { char * action = NULL ; if ( send_ack ( g ) < 0 ) { return - 1 ; } g -> data [ g -> data_len ] = '\\0' ; if ( g -> data [ 5 ] == '?' ) { return send_msg ( g , ""vCont;c;s"" ) ; } if ( ! ( action = strtok ( g -> data , "";"" ) ) ) { return send_msg ( g , ""E01"" ) ; } while ( action = strtok ( NULL , "";"" ) ) { eprintf ( ""action:%s\\n"" , action ) ; switch ( action [ 0 ] ) { case 's' : if ( cmd_cb ( core_ptr , ""ds"" , NULL , 0 ) < 0 ) { send_msg ( g , ""E01"" ) ; return - 1 ; } return send_msg ( g , ""OK"" ) ; case 'c' : if ( cmd_cb ( core_ptr , ""dc"" , NULL , 0 ) < 0 ) { send_msg ( g , ""E01"" ) ; return - 1 ; } return send_msg ( g , ""OK"" ) ; default : return send_msg ( g , ""E01"" ) ; } } } "," ; } } return - 1 ; ",radare@radare2/796dd28aaa6b9fa76d99c42c4d5ff8b257cc2191,CVE-2017-9949,https://github.com/radare/radare2/commit/796dd28aaa6b9fa76d99c42c4d5ff8b257cc2191,2017-06-26T20:29Z 871,CWE-476,"CWE-476 smb_sdrc_t smb2_flush ( smb_request_t * sr ) { smb_ofile_t * of = NULL ; uint16_t StructSize ; uint16_t reserved1 ; uint32_t reserved2 ; smb2fid_t smb2fid ; uint32_t status ; int rc = 0 ; rc = smb_mbc_decodef ( & sr -> smb_data , ""wwlqq"" , & StructSize , & reserved1 , & reserved2 , & smb2fid . persistent , & smb2fid . temporal ) ; if ( rc ) return ( SDRC_ERROR ) ; if ( StructSize != 24 ) return ( SDRC_ERROR ) ; status = smb2sr_lookup_fid ( sr , & smb2fid ) ; if ( status ) { smb2sr_put_error ( sr , status ) ; return ( SDRC_SUCCESS ) ; } of = sr -> fid_ofile ; if ( ( of -> f_node -> flags & NODE_FLAGS_WRITE_THROUGH ) == 0 ) ( void ) smb_fsop_commit ( sr , of -> f_cr , of -> f_node ) ; ( void ) smb_mbc_encodef ( & sr -> reply , ""wwl"" , 4 , 0 ) ; return ( SDRC_SUCCESS ) ; } "," sr ) { uint16_t StructSize ; ) ; } smb_ofile_flush ( sr , sr -> fid_ofile sr -> fid_ofile ) ; ( ",illumos@illumos-gate/6d1c73b5858fefc6161c7d686345f0dc887ea799,CVE-2016-6561,https://github.com/illumos/illumos-gate/commit/6d1c73b5858fefc6161c7d686345f0dc887ea799,2017-03-31T19:59Z 872,CWE-190,"CWE-190 jpc_streamlist_t * jpc_ppmstabtostreams ( jpc_ppxstab_t * tab ) { jpc_streamlist_t * streams ; uchar * dataptr ; uint_fast32_t datacnt ; uint_fast32_t tpcnt ; jpc_ppxstabent_t * ent ; int entno ; jas_stream_t * stream ; int n ; if ( ! ( streams = jpc_streamlist_create ( ) ) ) { goto error ; } if ( ! tab -> numents ) { return streams ; } entno = 0 ; ent = tab -> ents [ entno ] ; dataptr = ent -> data ; datacnt = ent -> len ; for ( ; ; ) { if ( datacnt < 4 ) { goto error ; } if ( ! ( stream = jas_stream_memopen ( 0 , 0 ) ) ) { goto error ; } if ( jpc_streamlist_insert ( streams , jpc_streamlist_numstreams ( streams ) , stream ) ) { goto error ; } tpcnt = ( dataptr [ 0 ] << 24 ) | ( dataptr [ 1 ] << 16 ) | ( dataptr [ 2 ] << 8 ) | dataptr [ 3 ] ; datacnt -= 4 ; dataptr += 4 ; while ( tpcnt ) { if ( ! datacnt ) { if ( ++ entno >= tab -> numents ) { goto error ; } ent = tab -> ents [ entno ] ; dataptr = ent -> data ; datacnt = ent -> len ; } n = JAS_MIN ( tpcnt , datacnt ) ; if ( jas_stream_write ( stream , dataptr , n ) != n ) { goto error ; } tpcnt -= n ; dataptr += n ; datacnt -= n ; } jas_stream_rewind ( stream ) ; if ( ! datacnt ) { if ( ++ entno >= tab -> numents ) { break ; } ent = tab -> ents [ entno ] ; dataptr = ent -> data ; datacnt = ent -> len ; } } return streams ; error : if ( streams ) { jpc_streamlist_destroy ( streams ) ; } return 0 ; } "," * streams ; jas_uchar * dataptr ; ",mdadams@jasper/d42b2388f7f8e0332c846675133acea151fc557a,CVE-2016-9557,https://github.com/mdadams/jasper/commit/d42b2388f7f8e0332c846675133acea151fc557a,2017-03-23T18:59Z 873,CWE-119,"CWE-119 static void decode_mb_rows ( VP8D_COMP * pbi ) { VP8_COMMON * const pc = & pbi -> common ; MACROBLOCKD * const xd = & pbi -> mb ; MODE_INFO * lf_mic = xd -> mode_info_context ; int ibc = 0 ; int num_part = 1 << pc -> multi_token_partition ; int recon_yoffset , recon_uvoffset ; int mb_row , mb_col ; int mb_idx = 0 ; YV12_BUFFER_CONFIG * yv12_fb_new = pbi -> dec_fb_ref [ INTRA_FRAME ] ; int recon_y_stride = yv12_fb_new -> y_stride ; int recon_uv_stride = yv12_fb_new -> uv_stride ; unsigned char * ref_buffer [ MAX_REF_FRAMES ] [ 3 ] ; unsigned char * dst_buffer [ 3 ] ; unsigned char * lf_dst [ 3 ] ; unsigned char * eb_dst [ 3 ] ; int i ; int ref_fb_corrupted [ MAX_REF_FRAMES ] ; ref_fb_corrupted [ INTRA_FRAME ] = 0 ; for ( i = 1 ; i < MAX_REF_FRAMES ; i ++ ) { YV12_BUFFER_CONFIG * this_fb = pbi -> dec_fb_ref [ i ] ; ref_buffer [ i ] [ 0 ] = this_fb -> y_buffer ; ref_buffer [ i ] [ 1 ] = this_fb -> u_buffer ; ref_buffer [ i ] [ 2 ] = this_fb -> v_buffer ; ref_fb_corrupted [ i ] = this_fb -> corrupted ; } eb_dst [ 0 ] = lf_dst [ 0 ] = dst_buffer [ 0 ] = yv12_fb_new -> y_buffer ; eb_dst [ 1 ] = lf_dst [ 1 ] = dst_buffer [ 1 ] = yv12_fb_new -> u_buffer ; eb_dst [ 2 ] = lf_dst [ 2 ] = dst_buffer [ 2 ] = yv12_fb_new -> v_buffer ; xd -> up_available = 0 ; if ( pc -> filter_level ) vp8_loop_filter_frame_init ( pc , xd , pc -> filter_level ) ; vp8_setup_intra_recon_top_line ( yv12_fb_new ) ; for ( mb_row = 0 ; mb_row < pc -> mb_rows ; mb_row ++ ) { if ( num_part > 1 ) { xd -> current_bc = & pbi -> mbc [ ibc ] ; ibc ++ ; if ( ibc == num_part ) ibc = 0 ; } recon_yoffset = mb_row * recon_y_stride * 16 ; recon_uvoffset = mb_row * recon_uv_stride * 8 ; xd -> above_context = pc -> above_context ; vpx_memset ( xd -> left_context , 0 , sizeof ( ENTROPY_CONTEXT_PLANES ) ) ; xd -> left_available = 0 ; xd -> mb_to_top_edge = - ( ( mb_row * 16 ) << 3 ) ; xd -> mb_to_bottom_edge = ( ( pc -> mb_rows - 1 - mb_row ) * 16 ) << 3 ; xd -> recon_above [ 0 ] = dst_buffer [ 0 ] + recon_yoffset ; xd -> recon_above [ 1 ] = dst_buffer [ 1 ] + recon_uvoffset ; xd -> recon_above [ 2 ] = dst_buffer [ 2 ] + recon_uvoffset ; xd -> recon_left [ 0 ] = xd -> recon_above [ 0 ] - 1 ; xd -> recon_left [ 1 ] = xd -> recon_above [ 1 ] - 1 ; xd -> recon_left [ 2 ] = xd -> recon_above [ 2 ] - 1 ; xd -> recon_above [ 0 ] -= xd -> dst . y_stride ; xd -> recon_above [ 1 ] -= xd -> dst . uv_stride ; xd -> recon_above [ 2 ] -= xd -> dst . uv_stride ; xd -> recon_left_stride [ 0 ] = xd -> dst . y_stride ; xd -> recon_left_stride [ 1 ] = xd -> dst . uv_stride ; setup_intra_recon_left ( xd -> recon_left [ 0 ] , xd -> recon_left [ 1 ] , xd -> recon_left [ 2 ] , xd -> dst . y_stride , xd -> dst . uv_stride ) ; for ( mb_col = 0 ; mb_col < pc -> mb_cols ; mb_col ++ ) { xd -> mb_to_left_edge = - ( ( mb_col * 16 ) << 3 ) ; xd -> mb_to_right_edge = ( ( pc -> mb_cols - 1 - mb_col ) * 16 ) << 3 ; # if CONFIG_ERROR_CONCEALMENT { int corrupt_residual = ( ! pbi -> independent_partitions && pbi -> frame_corrupt_residual ) || vp8dx_bool_error ( xd -> current_bc ) ; if ( pbi -> ec_active && xd -> mode_info_context -> mbmi . ref_frame == INTRA_FRAME && corrupt_residual ) { vp8_interpolate_motion ( xd , mb_row , mb_col , pc -> mb_rows , pc -> mb_cols , pc -> mode_info_stride ) ; } } # endif xd -> dst . y_buffer = dst_buffer [ 0 ] + recon_yoffset ; xd -> dst . u_buffer = dst_buffer [ 1 ] + recon_uvoffset ; xd -> dst . v_buffer = dst_buffer [ 2 ] + recon_uvoffset ; xd -> pre . y_buffer = ref_buffer [ xd -> mode_info_context -> mbmi . ref_frame ] [ 0 ] + recon_yoffset ; xd -> pre . u_buffer = ref_buffer [ xd -> mode_info_context -> mbmi . ref_frame ] [ 1 ] + recon_uvoffset ; xd -> pre . v_buffer = ref_buffer [ xd -> mode_info_context -> mbmi . ref_frame ] [ 2 ] + recon_uvoffset ; xd -> corrupted |= ref_fb_corrupted [ xd -> mode_info_context -> mbmi . ref_frame ] ; decode_macroblock ( pbi , xd , mb_idx ) ; mb_idx ++ ; xd -> left_available = 1 ; xd -> corrupted |= vp8dx_bool_error ( xd -> current_bc ) ; xd -> recon_above [ 0 ] += 16 ; xd -> recon_above [ 1 ] += 8 ; xd -> recon_above [ 2 ] += 8 ; xd -> recon_left [ 0 ] += 16 ; xd -> recon_left [ 1 ] += 8 ; xd -> recon_left [ 2 ] += 8 ; recon_yoffset += 16 ; recon_uvoffset += 8 ; ++ xd -> mode_info_context ; xd -> above_context ++ ; } vp8_extend_mb_row ( yv12_fb_new , xd -> dst . y_buffer + 16 , xd -> dst . u_buffer + 8 , xd -> dst . v_buffer + 8 ) ; ++ xd -> mode_info_context ; xd -> up_available = 1 ; if ( pc -> filter_level ) { if ( mb_row > 0 ) { if ( pc -> filter_type == NORMAL_LOOPFILTER ) vp8_loop_filter_row_normal ( pc , lf_mic , mb_row - 1 , recon_y_stride , recon_uv_stride , lf_dst [ 0 ] , lf_dst [ 1 ] , lf_dst [ 2 ] ) ; else vp8_loop_filter_row_simple ( pc , lf_mic , mb_row - 1 , recon_y_stride , recon_uv_stride , lf_dst [ 0 ] , lf_dst [ 1 ] , lf_dst [ 2 ] ) ; if ( mb_row > 1 ) { yv12_extend_frame_left_right_c ( yv12_fb_new , eb_dst [ 0 ] , eb_dst [ 1 ] , eb_dst [ 2 ] ) ; eb_dst [ 0 ] += recon_y_stride * 16 ; eb_dst [ 1 ] += recon_uv_stride * 8 ; eb_dst [ 2 ] += recon_uv_stride * 8 ; } lf_dst [ 0 ] += recon_y_stride * 16 ; lf_dst [ 1 ] += recon_uv_stride * 8 ; lf_dst [ 2 ] += recon_uv_stride * 8 ; lf_mic += pc -> mb_cols ; lf_mic ++ ; } } else { if ( mb_row > 0 ) { yv12_extend_frame_left_right_c ( yv12_fb_new , eb_dst [ 0 ] , eb_dst [ 1 ] , eb_dst [ 2 ] ) ; eb_dst [ 0 ] += recon_y_stride * 16 ; eb_dst [ 1 ] += recon_uv_stride * 8 ; eb_dst [ 2 ] += recon_uv_stride * 8 ; } } } if ( pc -> filter_level ) { if ( pc -> filter_type == NORMAL_LOOPFILTER ) vp8_loop_filter_row_normal ( pc , lf_mic , mb_row - 1 , recon_y_stride , recon_uv_stride , lf_dst [ 0 ] , lf_dst [ 1 ] , lf_dst [ 2 ] ) ; else vp8_loop_filter_row_simple ( pc , lf_mic , mb_row - 1 , recon_y_stride , recon_uv_stride , lf_dst [ 0 ] , lf_dst [ 1 ] , lf_dst [ 2 ] ) ; yv12_extend_frame_left_right_c ( yv12_fb_new , eb_dst [ 0 ] , eb_dst [ 1 ] , eb_dst [ 2 ] ) ; eb_dst [ 0 ] += recon_y_stride * 16 ; eb_dst [ 1 ] += recon_uv_stride * 8 ; eb_dst [ 2 ] += recon_uv_stride * 8 ; } yv12_extend_frame_left_right_c ( yv12_fb_new , eb_dst [ 0 ] , eb_dst [ 1 ] , eb_dst [ 2 ] ) ; yv12_extend_frame_top_c ( yv12_fb_new ) ; yv12_extend_frame_bottom_c ( yv12_fb_new ) ; } "," -> above_context ; memset ( xd -> + recon_uvoffset ; if ( xd -> mode_info_context -> mbmi . ref_frame >= LAST_FRAME ) { const MV_REFERENCE_FRAME ref = xd -> mode_info_context -> mbmi . ref_frame ; = ref_buffer [ ref ] [ 0 = ref_buffer [ ref ] [ 1 = ref_buffer [ ref ] [ 2 + recon_uvoffset ; } else { xd -> pre . y_buffer = 0 ; xd -> pre . u_buffer = 0 ; xd -> pre . v_buffer = 0 ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 874,CWE-200,"CWE-200 static void set_orig_addr ( struct msghdr * m , struct tipc_msg * msg ) { struct sockaddr_tipc * addr = ( struct sockaddr_tipc * ) m -> msg_name ; if ( addr ) { addr -> family = AF_TIPC ; addr -> addrtype = TIPC_ADDR_ID ; addr -> addr . id . ref = msg_origport ( msg ) ; addr -> addr . id . node = msg_orignode ( msg ) ; addr -> addr . name . domain = 0 ; addr -> scope = 0 ; m -> msg_namelen = sizeof ( struct sockaddr_tipc ) ; } } "," addrtype = TIPC_ADDR_ID ; memset ( & addr -> addr , 0 , sizeof ( addr -> addr ) ) ",torvalds@linux/60085c3d009b0df252547adb336d1ccca5ce52ec,CVE-2013-3235,https://github.com/torvalds/linux/commit/60085c3d009b0df252547adb336d1ccca5ce52ec,2013-04-22T11:41Z 875,CWE-20,"CWE-20 int __kvm_set_memory_region ( struct kvm * kvm , struct kvm_userspace_memory_region * mem , int user_alloc ) { int r ; gfn_t base_gfn ; unsigned long npages ; unsigned long i ; struct kvm_memory_slot * memslot ; struct kvm_memory_slot old , new ; struct kvm_memslots * slots , * old_memslots ; r = - EINVAL ; if ( mem -> memory_size & ( PAGE_SIZE - 1 ) ) goto out ; if ( mem -> guest_phys_addr & ( PAGE_SIZE - 1 ) ) goto out ; if ( user_alloc && ( mem -> userspace_addr & ( PAGE_SIZE - 1 ) ) ) goto out ; if ( mem -> slot >= KVM_MEMORY_SLOTS + KVM_PRIVATE_MEM_SLOTS ) goto out ; if ( mem -> guest_phys_addr + mem -> memory_size < mem -> guest_phys_addr ) goto out ; memslot = & kvm -> memslots -> memslots [ mem -> slot ] ; base_gfn = mem -> guest_phys_addr >> PAGE_SHIFT ; npages = mem -> memory_size >> PAGE_SHIFT ; r = - EINVAL ; if ( npages > KVM_MEM_MAX_NR_PAGES ) goto out ; if ( ! npages ) mem -> flags &= ~ KVM_MEM_LOG_DIRTY_PAGES ; new = old = * memslot ; new . id = mem -> slot ; new . base_gfn = base_gfn ; new . npages = npages ; new . flags = mem -> flags ; r = - EINVAL ; if ( npages && old . npages && npages != old . npages ) goto out_free ; r = - EEXIST ; for ( i = 0 ; i < KVM_MEMORY_SLOTS ; ++ i ) { struct kvm_memory_slot * s = & kvm -> memslots -> memslots [ i ] ; if ( s == memslot || ! s -> npages ) continue ; if ( ! ( ( base_gfn + npages <= s -> base_gfn ) || ( base_gfn >= s -> base_gfn + s -> npages ) ) ) goto out_free ; } if ( ! ( new . flags & KVM_MEM_LOG_DIRTY_PAGES ) ) new . dirty_bitmap = NULL ; r = - ENOMEM ; # ifndef CONFIG_S390 if ( npages && ! new . rmap ) { new . rmap = vzalloc ( npages * sizeof ( * new . rmap ) ) ; if ( ! new . rmap ) goto out_free ; new . user_alloc = user_alloc ; new . userspace_addr = mem -> userspace_addr ; } if ( ! npages ) goto skip_lpage ; for ( i = 0 ; i < KVM_NR_PAGE_SIZES - 1 ; ++ i ) { unsigned long ugfn ; unsigned long j ; int lpages ; int level = i + 2 ; ( void ) level ; if ( new . lpage_info [ i ] ) continue ; lpages = 1 + ( ( base_gfn + npages - 1 ) >> KVM_HPAGE_GFN_SHIFT ( level ) ) ; lpages -= base_gfn >> KVM_HPAGE_GFN_SHIFT ( level ) ; new . lpage_info [ i ] = vzalloc ( lpages * sizeof ( * new . lpage_info [ i ] ) ) ; if ( ! new . lpage_info [ i ] ) goto out_free ; if ( base_gfn & ( KVM_PAGES_PER_HPAGE ( level ) - 1 ) ) new . lpage_info [ i ] [ 0 ] . write_count = 1 ; if ( ( base_gfn + npages ) & ( KVM_PAGES_PER_HPAGE ( level ) - 1 ) ) new . lpage_info [ i ] [ lpages - 1 ] . write_count = 1 ; ugfn = new . userspace_addr >> PAGE_SHIFT ; if ( ( base_gfn ^ ugfn ) & ( KVM_PAGES_PER_HPAGE ( level ) - 1 ) || ! largepages_enabled ) for ( j = 0 ; j < lpages ; ++ j ) new . lpage_info [ i ] [ j ] . write_count = 1 ; } skip_lpage : if ( ( new . flags & KVM_MEM_LOG_DIRTY_PAGES ) && ! new . dirty_bitmap ) { if ( kvm_create_dirty_bitmap ( & new ) < 0 ) goto out_free ; } # else new . user_alloc = user_alloc ; if ( user_alloc ) new . userspace_addr = mem -> userspace_addr ; # endif if ( ! npages ) { r = - ENOMEM ; slots = kzalloc ( sizeof ( struct kvm_memslots ) , GFP_KERNEL ) ; if ( ! slots ) goto out_free ; memcpy ( slots , kvm -> memslots , sizeof ( struct kvm_memslots ) ) ; if ( mem -> slot >= slots -> nmemslots ) slots -> nmemslots = mem -> slot + 1 ; slots -> generation ++ ; slots -> memslots [ mem -> slot ] . flags |= KVM_MEMSLOT_INVALID ; old_memslots = kvm -> memslots ; rcu_assign_pointer ( kvm -> memslots , slots ) ; synchronize_srcu_expedited ( & kvm -> srcu ) ; kvm_arch_flush_shadow ( kvm ) ; kfree ( old_memslots ) ; } r = kvm_arch_prepare_memory_region ( kvm , & new , old , mem , user_alloc ) ; if ( r ) goto out_free ; if ( npages ) { r = kvm_iommu_map_pages ( kvm , & new ) ; if ( r ) goto out_free ; } r = - ENOMEM ; slots = kzalloc ( sizeof ( struct kvm_memslots ) , GFP_KERNEL ) ; if ( ! slots ) goto out_free ; memcpy ( slots , kvm -> memslots , sizeof ( struct kvm_memslots ) ) ; if ( mem -> slot >= slots -> nmemslots ) slots -> nmemslots = mem -> slot + 1 ; slots -> generation ++ ; if ( ! npages ) { new . rmap = NULL ; new . dirty_bitmap = NULL ; for ( i = 0 ; i < KVM_NR_PAGE_SIZES - 1 ; ++ i ) new . lpage_info [ i ] = NULL ; } slots -> memslots [ mem -> slot ] = new ; old_memslots = kvm -> memslots ; rcu_assign_pointer ( kvm -> memslots , slots ) ; synchronize_srcu_expedited ( & kvm -> srcu ) ; kvm_arch_commit_memory_region ( kvm , mem , old , user_alloc ) ; kvm_free_physmem_slot ( & old , & new ) ; kfree ( old_memslots ) ; return 0 ; out_free : kvm_free_physmem_slot ( & new , & old ) ; out : return r ; } "," ( user_alloc && ( PAGE_SIZE - 1 ) ) || ! access_ok ( VERIFY_WRITE , mem -> userspace_addr , mem -> memory_size ",torvalds@linux/fa3d315a4ce2c0891cdde262562e710d95fba19e,CVE-2013-1943,https://github.com/torvalds/linux/commit/fa3d315a4ce2c0891cdde262562e710d95fba19e,2013-07-16T14:08Z 876,CWE-772,"CWE-772 static Image * ReadMATImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { Image * image , * image2 = NULL , * rotated_image ; register Quantum * q ; unsigned int status ; MATHeader MATLAB_HDR ; size_t size ; size_t CellType ; QuantumInfo * quantum_info ; ImageInfo * clone_info ; int i ; ssize_t ldblk ; unsigned char * BImgBuff = NULL ; double MinVal , MaxVal ; unsigned z , z2 ; unsigned Frames ; int logging ; int sample_size ; MagickOffsetType filepos = 0x80 ; BlobInfo * blob ; size_t one ; unsigned int ( * ReadBlobXXXLong ) ( Image * image ) ; unsigned short ( * ReadBlobXXXShort ) ( Image * image ) ; void ( * ReadBlobDoublesXXX ) ( Image * image , size_t len , double * data ) ; void ( * ReadBlobFloatsXXX ) ( Image * image , size_t len , float * data ) ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; logging = LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""enter"" ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } clone_info = CloneImageInfo ( image_info ) ; if ( ReadBlob ( image , 124 , ( unsigned char * ) & MATLAB_HDR . identific ) != 124 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( strncmp ( MATLAB_HDR . identific , ""MATLAB"" , 6 ) != 0 ) { image2 = ReadMATImageV4 ( image_info , image , exception ) ; if ( image2 == NULL ) goto MATLAB_KO ; image = image2 ; goto END_OF_READING ; } MATLAB_HDR . Version = ReadBlobLSBShort ( image ) ; if ( ReadBlob ( image , 2 , ( unsigned char * ) & MATLAB_HDR . EndianIndicator ) != 2 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""Endian%c%c"" , MATLAB_HDR . EndianIndicator [ 0 ] , MATLAB_HDR . EndianIndicator [ 1 ] ) ; if ( ! strncmp ( MATLAB_HDR . EndianIndicator , ""IM"" , 2 ) ) { ReadBlobXXXLong = ReadBlobLSBLong ; ReadBlobXXXShort = ReadBlobLSBShort ; ReadBlobDoublesXXX = ReadBlobDoublesLSB ; ReadBlobFloatsXXX = ReadBlobFloatsLSB ; image -> endian = LSBEndian ; } else if ( ! strncmp ( MATLAB_HDR . EndianIndicator , ""MI"" , 2 ) ) { ReadBlobXXXLong = ReadBlobMSBLong ; ReadBlobXXXShort = ReadBlobMSBShort ; ReadBlobDoublesXXX = ReadBlobDoublesMSB ; ReadBlobFloatsXXX = ReadBlobFloatsMSB ; image -> endian = MSBEndian ; } else goto MATLAB_KO ; if ( strncmp ( MATLAB_HDR . identific , ""MATLAB"" , 6 ) ) MATLAB_KO : ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; filepos = TellBlob ( image ) ; while ( ! EOFBlob ( image ) ) { Frames = 1 ; ( void ) SeekBlob ( image , filepos , SEEK_SET ) ; MATLAB_HDR . DataType = ReadBlobXXXLong ( image ) ; if ( EOFBlob ( image ) ) break ; MATLAB_HDR . ObjectSize = ReadBlobXXXLong ( image ) ; if ( EOFBlob ( image ) ) break ; filepos += MATLAB_HDR . ObjectSize + 4 + 4 ; image2 = image ; # if defined ( MAGICKCORE_ZLIB_DELEGATE ) if ( MATLAB_HDR . DataType == miCOMPRESSED ) { image2 = DecompressBlock ( image , MATLAB_HDR . ObjectSize , clone_info , exception ) ; if ( image2 == NULL ) continue ; MATLAB_HDR . DataType = ReadBlobXXXLong ( image2 ) ; } # endif if ( MATLAB_HDR . DataType != miMATRIX ) continue ; MATLAB_HDR . unknown1 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . unknown2 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . unknown5 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . StructureClass = MATLAB_HDR . unknown5 & 0xFF ; MATLAB_HDR . StructureFlag = ( MATLAB_HDR . unknown5 >> 8 ) & 0xFF ; MATLAB_HDR . unknown3 = ReadBlobXXXLong ( image2 ) ; if ( image != image2 ) MATLAB_HDR . unknown4 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . unknown4 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . DimFlag = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . SizeX = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . SizeY = ReadBlobXXXLong ( image2 ) ; switch ( MATLAB_HDR . DimFlag ) { case 8 : z2 = z = 1 ; break ; case 12 : z2 = z = ReadBlobXXXLong ( image2 ) ; ( void ) ReadBlobXXXLong ( image2 ) ; if ( z != 3 ) ThrowReaderException ( CoderError , ""MultidimensionalMatricesAreNotSupported"" ) ; break ; case 16 : z2 = z = ReadBlobXXXLong ( image2 ) ; if ( z != 3 && z != 1 ) ThrowReaderException ( CoderError , ""MultidimensionalMatricesAreNotSupported"" ) ; Frames = ReadBlobXXXLong ( image2 ) ; if ( Frames == 0 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; break ; default : ThrowReaderException ( CoderError , ""MultidimensionalMatricesAreNotSupported"" ) ; } MATLAB_HDR . Flag1 = ReadBlobXXXShort ( image2 ) ; MATLAB_HDR . NameFlag = ReadBlobXXXShort ( image2 ) ; if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATLAB_HDR.StructureClass%d"" , MATLAB_HDR . StructureClass ) ; if ( MATLAB_HDR . StructureClass != mxCHAR_CLASS && MATLAB_HDR . StructureClass != mxSINGLE_CLASS && MATLAB_HDR . StructureClass != mxDOUBLE_CLASS && MATLAB_HDR . StructureClass != mxINT8_CLASS && MATLAB_HDR . StructureClass != mxUINT8_CLASS && MATLAB_HDR . StructureClass != mxINT16_CLASS && MATLAB_HDR . StructureClass != mxUINT16_CLASS && MATLAB_HDR . StructureClass != mxINT32_CLASS && MATLAB_HDR . StructureClass != mxUINT32_CLASS && MATLAB_HDR . StructureClass != mxINT64_CLASS && MATLAB_HDR . StructureClass != mxUINT64_CLASS ) ThrowReaderException ( CoderError , ""UnsupportedCellTypeInTheMatrix"" ) ; switch ( MATLAB_HDR . NameFlag ) { case 0 : size = ReadBlobXXXLong ( image2 ) ; size = 4 * ( ssize_t ) ( ( size + 3 + 1 ) / 4 ) ; ( void ) SeekBlob ( image2 , size , SEEK_CUR ) ; break ; case 1 : case 2 : case 3 : case 4 : ( void ) ReadBlob ( image2 , 4 , ( unsigned char * ) & size ) ; break ; default : goto MATLAB_KO ; } CellType = ReadBlobXXXLong ( image2 ) ; if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATLAB_HDR.CellType:%.20g"" , ( double ) CellType ) ; ( void ) ReadBlob ( image2 , 4 , ( unsigned char * ) & size ) ; NEXT_FRAME : switch ( CellType ) { case miINT8 : case miUINT8 : sample_size = 8 ; if ( MATLAB_HDR . StructureFlag & FLAG_LOGICAL ) image -> depth = 1 ; else image -> depth = 8 ; ldblk = ( ssize_t ) MATLAB_HDR . SizeX ; break ; case miINT16 : case miUINT16 : sample_size = 16 ; image -> depth = 16 ; ldblk = ( ssize_t ) ( 2 * MATLAB_HDR . SizeX ) ; break ; case miINT32 : case miUINT32 : sample_size = 32 ; image -> depth = 32 ; ldblk = ( ssize_t ) ( 4 * MATLAB_HDR . SizeX ) ; break ; case miINT64 : case miUINT64 : sample_size = 64 ; image -> depth = 64 ; ldblk = ( ssize_t ) ( 8 * MATLAB_HDR . SizeX ) ; break ; case miSINGLE : sample_size = 32 ; image -> depth = 32 ; ( void ) SetImageOption ( clone_info , ""quantum:format"" , ""floating-point"" ) ; if ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) { } ldblk = ( ssize_t ) ( 4 * MATLAB_HDR . SizeX ) ; break ; case miDOUBLE : sample_size = 64 ; image -> depth = 64 ; ( void ) SetImageOption ( clone_info , ""quantum:format"" , ""floating-point"" ) ; DisableMSCWarning ( 4127 ) if ( sizeof ( double ) != 8 ) RestoreMSCWarning ThrowReaderException ( CoderError , ""IncompatibleSizeOfDouble"" ) ; if ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) { } ldblk = ( ssize_t ) ( 8 * MATLAB_HDR . SizeX ) ; break ; default : ThrowReaderException ( CoderError , ""UnsupportedCellTypeInTheMatrix"" ) ; } ( void ) sample_size ; image -> columns = MATLAB_HDR . SizeX ; image -> rows = MATLAB_HDR . SizeY ; quantum_info = AcquireQuantumInfo ( clone_info , image ) ; if ( quantum_info == ( QuantumInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; one = 1 ; image -> colors = one << image -> depth ; if ( image -> columns == 0 || image -> rows == 0 ) goto MATLAB_KO ; if ( ( MATLAB_HDR . DimFlag == 8 ) && ( ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) == 0 ) ) { image -> type = GrayscaleType ; SetImageColorspace ( image , GRAYColorspace , exception ) ; } if ( image_info -> ping ) { size_t temp = image -> columns ; image -> columns = image -> rows ; image -> rows = temp ; goto done_reading ; } status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; BImgBuff = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) ( ldblk ) , sizeof ( double ) ) ; if ( BImgBuff == NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; ( void ) ResetMagickMemory ( BImgBuff , 0 , ldblk * sizeof ( double ) ) ; MinVal = 0 ; MaxVal = 0 ; if ( CellType == miDOUBLE || CellType == miSINGLE ) { CalcMinMax ( image2 , image_info -> endian , MATLAB_HDR . SizeX , MATLAB_HDR . SizeY , CellType , ldblk , BImgBuff , & quantum_info -> minimum , & quantum_info -> maximum ) ; } if ( z == 1 ) z = 0 ; do { for ( i = 0 ; i < ( ssize_t ) MATLAB_HDR . SizeY ; i ++ ) { q = GetAuthenticPixels ( image , 0 , MATLAB_HDR . SizeY - i - 1 , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) { if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATsetimagepixelsreturnsunexpectedNULLonarow%u."" , ( unsigned ) ( MATLAB_HDR . SizeY - i - 1 ) ) ; goto done_reading ; } if ( ReadBlob ( image2 , ldblk , ( unsigned char * ) BImgBuff ) != ( ssize_t ) ldblk ) { if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATcannotreadscanrow%ufromafile."" , ( unsigned ) ( MATLAB_HDR . SizeY - i - 1 ) ) ; goto ExitLoop ; } if ( ( CellType == miINT8 || CellType == miUINT8 ) && ( MATLAB_HDR . StructureFlag & FLAG_LOGICAL ) ) { FixLogical ( ( unsigned char * ) BImgBuff , ldblk ) ; if ( ImportQuantumPixels ( image , ( CacheView * ) NULL , quantum_info , z2qtype [ z ] , BImgBuff , exception ) <= 0 ) { ImportQuantumPixelsFailed : if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATfailedtoImportQuantumPixelsforarow%u"" , ( unsigned ) ( MATLAB_HDR . SizeY - i - 1 ) ) ; break ; } } else { if ( ImportQuantumPixels ( image , ( CacheView * ) NULL , quantum_info , z2qtype [ z ] , BImgBuff , exception ) <= 0 ) goto ImportQuantumPixelsFailed ; if ( z <= 1 && ( CellType == miINT8 || CellType == miINT16 || CellType == miINT32 || CellType == miINT64 ) ) FixSignedValues ( image , q , MATLAB_HDR . SizeX ) ; } if ( ! SyncAuthenticPixels ( image , exception ) ) { if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATfailedtosyncimagepixelsforarow%u"" , ( unsigned ) ( MATLAB_HDR . SizeY - i - 1 ) ) ; goto ExitLoop ; } } } while ( z -- >= 2 ) ; ExitLoop : if ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) { CellType = ReadBlobXXXLong ( image2 ) ; i = ReadBlobXXXLong ( image2 ) ; if ( CellType == miDOUBLE || CellType == miSINGLE ) { CalcMinMax ( image2 , image_info -> endian , MATLAB_HDR . SizeX , MATLAB_HDR . SizeY , CellType , ldblk , BImgBuff , & MinVal , & MaxVal ) ; } if ( CellType == miDOUBLE ) for ( i = 0 ; i < ( ssize_t ) MATLAB_HDR . SizeY ; i ++ ) { ReadBlobDoublesXXX ( image2 , ldblk , ( double * ) BImgBuff ) ; InsertComplexDoubleRow ( image , ( double * ) BImgBuff , i , MinVal , MaxVal , exception ) ; } if ( CellType == miSINGLE ) for ( i = 0 ; i < ( ssize_t ) MATLAB_HDR . SizeY ; i ++ ) { ReadBlobFloatsXXX ( image2 , ldblk , ( float * ) BImgBuff ) ; InsertComplexFloatRow ( image , ( float * ) BImgBuff , i , MinVal , MaxVal , exception ) ; } } if ( ( MATLAB_HDR . DimFlag == 8 ) && ( ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) == 0 ) ) image -> type = GrayscaleType ; if ( image -> depth == 1 ) image -> type = BilevelType ; if ( image2 == image ) image2 = NULL ; rotated_image = RotateImage ( image , 90.0 , exception ) ; if ( rotated_image != ( Image * ) NULL ) { rotated_image -> page . x = 0 ; rotated_image -> page . y = 0 ; blob = rotated_image -> blob ; rotated_image -> blob = image -> blob ; rotated_image -> colors = image -> colors ; image -> blob = blob ; AppendImageToList ( & image , rotated_image ) ; DeleteImageFromList ( & image ) ; } done_reading : if ( image2 != NULL ) if ( image2 != image ) { DeleteImageFromList ( & image2 ) ; if ( clone_info ) { if ( clone_info -> file ) { fclose ( clone_info -> file ) ; clone_info -> file = NULL ; ( void ) remove_utf8 ( clone_info -> filename ) ; } } } AcquireNextImage ( image_info , image , exception ) ; if ( image -> next == ( Image * ) NULL ) break ; image = SyncNextImageInList ( image ) ; image -> columns = image -> rows = 0 ; image -> colors = 0 ; RelinquishMagickMemory ( BImgBuff ) ; BImgBuff = NULL ; if ( -- Frames > 0 ) { z = z2 ; if ( image2 == NULL ) image2 = image ; goto NEXT_FRAME ; } if ( ( image2 != NULL ) && ( image2 != image ) ) { DeleteImageFromList ( & image2 ) ; if ( clone_info ) { if ( clone_info -> file ) { fclose ( clone_info -> file ) ; clone_info -> file = NULL ; ( void ) remove_utf8 ( clone_info -> filename ) ; } } } } RelinquishMagickMemory ( BImgBuff ) ; quantum_info = DestroyQuantumInfo ( quantum_info ) ; END_OF_READING : clone_info = DestroyImageInfo ( clone_info ) ; CloseBlob ( image ) ; { Image * p ; ssize_t scene = 0 ; p = image ; image = NULL ; while ( p != ( Image * ) NULL ) { Image * tmp = p ; if ( ( p -> rows == 0 ) || ( p -> columns == 0 ) ) { p = p -> previous ; DeleteImageFromList ( & tmp ) ; } else { image = p ; p = p -> previous ; } } for ( p = image ; p != ( Image * ) NULL ; p = p -> next ) p -> scene = scene ++ ; } if ( clone_info != NULL ) { if ( clone_info -> file ) { fclose ( clone_info -> file ) ; clone_info -> file = NULL ; ( void ) remove_utf8 ( clone_info -> filename ) ; } DestroyImageInfo ( clone_info ) ; clone_info = NULL ; } if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""return"" ) ; if ( image == NULL ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; return ( image ) ; } "," ) ; } quantum_info = ( QuantumInfo * ) NULL ; BImgBuff ) ; if ( quantum_info != ( QuantumInfo * ) NULL ) ",ImageMagick@ImageMagick/79e5dbcdd1fc2f714f9bae548bc55d5073f3ed20,CVE-2017-13146,https://github.com/ImageMagick/ImageMagick/commit/79e5dbcdd1fc2f714f9bae548bc55d5073f3ed20,2017-08-23T06:29Z 877,CWE-119,"CWE-119 php_stream * php_stream_url_wrap_http_ex ( php_stream_wrapper * wrapper , const char * path , const char * mode , int options , char * * opened_path , php_stream_context * context , int redirect_max , int flags STREAMS_DC TSRMLS_DC ) { php_stream * stream = NULL ; php_url * resource = NULL ; int use_ssl ; int use_proxy = 0 ; char * scratch = NULL ; char * tmp = NULL ; char * ua_str = NULL ; zval * * ua_zval = NULL , * * tmpzval = NULL , * ssl_proxy_peer_name = NULL ; int scratch_len = 0 ; int body = 0 ; char location [ HTTP_HEADER_BLOCK_SIZE ] ; zval * response_header = NULL ; int reqok = 0 ; char * http_header_line = NULL ; char tmp_line [ 128 ] ; size_t chunk_size = 0 , file_size = 0 ; int eol_detect = 0 ; char * transport_string , * errstr = NULL ; int transport_len , have_header = 0 , request_fulluri = 0 , ignore_errors = 0 ; char * protocol_version = NULL ; int protocol_version_len = 3 ; struct timeval timeout ; char * user_headers = NULL ; int header_init = ( ( flags & HTTP_WRAPPER_HEADER_INIT ) != 0 ) ; int redirected = ( ( flags & HTTP_WRAPPER_REDIRECTED ) != 0 ) ; int follow_location = 1 ; php_stream_filter * transfer_encoding = NULL ; int response_code ; tmp_line [ 0 ] = '\\0' ; if ( redirect_max < 1 ) { php_stream_wrapper_log_error ( wrapper , options TSRMLS_CC , ""Redirectionlimitreached,aborting"" ) ; return NULL ; } resource = php_url_parse ( path ) ; if ( resource == NULL ) { return NULL ; } if ( strncasecmp ( resource -> scheme , ""http"" , sizeof ( ""http"" ) ) && strncasecmp ( resource -> scheme , ""https"" , sizeof ( ""https"" ) ) ) { if ( ! context || php_stream_context_get_option ( context , wrapper -> wops -> label , ""proxy"" , & tmpzval ) == FAILURE || Z_TYPE_PP ( tmpzval ) != IS_STRING || Z_STRLEN_PP ( tmpzval ) <= 0 ) { php_url_free ( resource ) ; return php_stream_open_wrapper_ex ( path , mode , REPORT_ERRORS , NULL , context ) ; } request_fulluri = 1 ; use_ssl = 0 ; use_proxy = 1 ; transport_len = Z_STRLEN_PP ( tmpzval ) ; transport_string = estrndup ( Z_STRVAL_PP ( tmpzval ) , Z_STRLEN_PP ( tmpzval ) ) ; } else { if ( strpbrk ( mode , ""awx+"" ) ) { php_stream_wrapper_log_error ( wrapper , options TSRMLS_CC , ""HTTPwrapperdoesnotsupportwriteableconnections"" ) ; php_url_free ( resource ) ; return NULL ; } use_ssl = resource -> scheme && ( strlen ( resource -> scheme ) > 4 ) && resource -> scheme [ 4 ] == 's' ; if ( use_ssl && resource -> port == 0 ) resource -> port = 443 ; else if ( resource -> port == 0 ) resource -> port = 80 ; if ( context && php_stream_context_get_option ( context , wrapper -> wops -> label , ""proxy"" , & tmpzval ) == SUCCESS && Z_TYPE_PP ( tmpzval ) == IS_STRING && Z_STRLEN_PP ( tmpzval ) > 0 ) { use_proxy = 1 ; transport_len = Z_STRLEN_PP ( tmpzval ) ; transport_string = estrndup ( Z_STRVAL_PP ( tmpzval ) , Z_STRLEN_PP ( tmpzval ) ) ; } else { transport_len = spprintf ( & transport_string , 0 , ""%s://%s:%d"" , use_ssl ? ""ssl"" : ""tcp"" , resource -> host , resource -> port ) ; } } if ( context && php_stream_context_get_option ( context , wrapper -> wops -> label , ""timeout"" , & tmpzval ) == SUCCESS ) { SEPARATE_ZVAL ( tmpzval ) ; convert_to_double_ex ( tmpzval ) ; timeout . tv_sec = ( time_t ) Z_DVAL_PP ( tmpzval ) ; timeout . tv_usec = ( size_t ) ( ( Z_DVAL_PP ( tmpzval ) - timeout . tv_sec ) * 1000000 ) ; } else { timeout . tv_sec = FG ( default_socket_timeout ) ; timeout . tv_usec = 0 ; } stream = php_stream_xport_create ( transport_string , transport_len , options , STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT , NULL , & timeout , context , & errstr , NULL ) ; if ( stream ) { php_stream_set_option ( stream , PHP_STREAM_OPTION_READ_TIMEOUT , 0 , & timeout ) ; } if ( errstr ) { php_stream_wrapper_log_error ( wrapper , options TSRMLS_CC , ""%s"" , errstr ) ; efree ( errstr ) ; errstr = NULL ; } efree ( transport_string ) ; if ( stream && use_proxy && use_ssl ) { smart_str header = { 0 } ; if ( ! context || php_stream_context_get_option ( context , ""ssl"" , ""peer_name"" , & tmpzval ) == FAILURE ) { MAKE_STD_ZVAL ( ssl_proxy_peer_name ) ; ZVAL_STRING ( ssl_proxy_peer_name , resource -> host , 1 ) ; php_stream_context_set_option ( stream -> context , ""ssl"" , ""peer_name"" , ssl_proxy_peer_name ) ; } smart_str_appendl ( & header , ""CONNECT"" , sizeof ( ""CONNECT"" ) - 1 ) ; smart_str_appends ( & header , resource -> host ) ; smart_str_appendc ( & header , ':' ) ; smart_str_append_unsigned ( & header , resource -> port ) ; smart_str_appendl ( & header , ""HTTP/1.0\\r\\n"" , sizeof ( ""HTTP/1.0\\r\\n"" ) - 1 ) ; if ( context && php_stream_context_get_option ( context , ""http"" , ""header"" , & tmpzval ) == SUCCESS ) { char * s , * p ; if ( Z_TYPE_PP ( tmpzval ) == IS_ARRAY ) { HashPosition pos ; zval * * tmpheader = NULL ; for ( zend_hash_internal_pointer_reset_ex ( Z_ARRVAL_PP ( tmpzval ) , & pos ) ; SUCCESS == zend_hash_get_current_data_ex ( Z_ARRVAL_PP ( tmpzval ) , ( void * ) & tmpheader , & pos ) ; zend_hash_move_forward_ex ( Z_ARRVAL_PP ( tmpzval ) , & pos ) ) { if ( Z_TYPE_PP ( tmpheader ) == IS_STRING ) { s = Z_STRVAL_PP ( tmpheader ) ; do { while ( * s == '' || * s == '\\t' ) s ++ ; p = s ; while ( * p != 0 && * p != ':' && * p != '\\r' && * p != '\\n' ) p ++ ; if ( * p == ':' ) { p ++ ; if ( p - s == sizeof ( ""Proxy-Authorization:"" ) - 1 && zend_binary_strcasecmp ( s , sizeof ( ""Proxy-Authorization:"" ) - 1 , ""Proxy-Authorization:"" , sizeof ( ""Proxy-Authorization:"" ) - 1 ) == 0 ) { while ( * p != 0 && * p != '\\r' && * p != '\\n' ) p ++ ; smart_str_appendl ( & header , s , p - s ) ; smart_str_appendl ( & header , ""\\r\\n"" , sizeof ( ""\\r\\n"" ) - 1 ) ; goto finish ; } else { while ( * p != 0 && * p != '\\r' && * p != '\\n' ) p ++ ; } } s = p ; while ( * s == '\\r' || * s == '\\n' ) s ++ ; } while ( * s != 0 ) ; } } } else if ( Z_TYPE_PP ( tmpzval ) == IS_STRING && Z_STRLEN_PP ( tmpzval ) ) { s = Z_STRVAL_PP ( tmpzval ) ; do { while ( * s == '' || * s == '\\t' ) s ++ ; p = s ; while ( * p != 0 && * p != ':' && * p != '\\r' && * p != '\\n' ) p ++ ; if ( * p == ':' ) { p ++ ; if ( p - s == sizeof ( ""Proxy-Authorization:"" ) - 1 && zend_binary_strcasecmp ( s , sizeof ( ""Proxy-Authorization:"" ) - 1 , ""Proxy-Authorization:"" , sizeof ( ""Proxy-Authorization:"" ) - 1 ) == 0 ) { while ( * p != 0 && * p != '\\r' && * p != '\\n' ) p ++ ; smart_str_appendl ( & header , s , p - s ) ; smart_str_appendl ( & header , ""\\r\\n"" , sizeof ( ""\\r\\n"" ) - 1 ) ; goto finish ; } else { while ( * p != 0 && * p != '\\r' && * p != '\\n' ) p ++ ; } } s = p ; while ( * s == '\\r' || * s == '\\n' ) s ++ ; } while ( * s != 0 ) ; } } finish : smart_str_appendl ( & header , ""\\r\\n"" , sizeof ( ""\\r\\n"" ) - 1 ) ; if ( php_stream_write ( stream , header . c , header . len ) != header . len ) { php_stream_wrapper_log_error ( wrapper , options TSRMLS_CC , ""CannotconnecttoHTTPSserverthroughproxy"" ) ; php_stream_close ( stream ) ; stream = NULL ; } smart_str_free ( & header ) ; if ( stream ) { char header_line [ HTTP_HEADER_BLOCK_SIZE ] ; while ( php_stream_gets ( stream , header_line , HTTP_HEADER_BLOCK_SIZE - 1 ) != NULL ) { if ( header_line [ 0 ] == '\\n' || header_line [ 0 ] == '\\r' || header_line [ 0 ] == '\\0' ) { break ; } } } if ( stream ) { if ( php_stream_xport_crypto_setup ( stream , STREAM_CRYPTO_METHOD_SSLv23_CLIENT , NULL TSRMLS_CC ) < 0 || php_stream_xport_crypto_enable ( stream , 1 TSRMLS_CC ) < 0 ) { php_stream_wrapper_log_error ( wrapper , options TSRMLS_CC , ""CannotconnecttoHTTPSserverthroughproxy"" ) ; php_stream_close ( stream ) ; stream = NULL ; } } } if ( stream == NULL ) goto out ; if ( options & STREAM_WILL_CAST ) chunk_size = php_stream_set_chunk_size ( stream , 1 ) ; eol_detect = stream -> flags & ( PHP_STREAM_FLAG_DETECT_EOL | PHP_STREAM_FLAG_EOL_MAC ) ; stream -> flags &= ~ ( PHP_STREAM_FLAG_DETECT_EOL | PHP_STREAM_FLAG_EOL_MAC ) ; php_stream_context_set ( stream , context ) ; php_stream_notify_info ( context , PHP_STREAM_NOTIFY_CONNECT , NULL , 0 ) ; if ( header_init && context && php_stream_context_get_option ( context , ""http"" , ""max_redirects"" , & tmpzval ) == SUCCESS ) { SEPARATE_ZVAL ( tmpzval ) ; convert_to_long_ex ( tmpzval ) ; redirect_max = Z_LVAL_PP ( tmpzval ) ; } if ( context && php_stream_context_get_option ( context , ""http"" , ""method"" , & tmpzval ) == SUCCESS ) { if ( Z_TYPE_PP ( tmpzval ) == IS_STRING && Z_STRLEN_PP ( tmpzval ) > 0 ) { if ( ! redirected || ( Z_STRLEN_PP ( tmpzval ) == 3 && memcmp ( ""GET"" , Z_STRVAL_PP ( tmpzval ) , 3 ) == 0 ) || ( Z_STRLEN_PP ( tmpzval ) == 4 && memcmp ( ""HEAD"" , Z_STRVAL_PP ( tmpzval ) , 4 ) == 0 ) ) { scratch_len = strlen ( path ) + 29 + Z_STRLEN_PP ( tmpzval ) ; scratch = emalloc ( scratch_len ) ; strlcpy ( scratch , Z_STRVAL_PP ( tmpzval ) , Z_STRLEN_PP ( tmpzval ) + 1 ) ; strncat ( scratch , """" , 1 ) ; } } } if ( context && php_stream_context_get_option ( context , ""http"" , ""protocol_version"" , & tmpzval ) == SUCCESS ) { SEPARATE_ZVAL ( tmpzval ) ; convert_to_double_ex ( tmpzval ) ; protocol_version_len = spprintf ( & protocol_version , 0 , ""%.1F"" , Z_DVAL_PP ( tmpzval ) ) ; } if ( ! scratch ) { scratch_len = strlen ( path ) + 29 + protocol_version_len ; scratch = emalloc ( scratch_len ) ; strncpy ( scratch , ""GET"" , scratch_len ) ; } if ( ! request_fulluri && context && php_stream_context_get_option ( context , ""http"" , ""request_fulluri"" , & tmpzval ) == SUCCESS ) { zval ztmp = * * tmpzval ; zval_copy_ctor ( & ztmp ) ; convert_to_boolean ( & ztmp ) ; request_fulluri = Z_BVAL ( ztmp ) ? 1 : 0 ; zval_dtor ( & ztmp ) ; } if ( request_fulluri ) { strcat ( scratch , path ) ; } else { if ( resource -> path && * resource -> path ) { strlcat ( scratch , resource -> path , scratch_len ) ; } else { strlcat ( scratch , ""/"" , scratch_len ) ; } if ( resource -> query ) { strlcat ( scratch , ""?"" , scratch_len ) ; strlcat ( scratch , resource -> query , scratch_len ) ; } } if ( protocol_version ) { strlcat ( scratch , ""HTTP/"" , scratch_len ) ; strlcat ( scratch , protocol_version , scratch_len ) ; strlcat ( scratch , ""\\r\\n"" , scratch_len ) ; } else { strlcat ( scratch , ""HTTP/1.0\\r\\n"" , scratch_len ) ; } php_stream_write ( stream , scratch , strlen ( scratch ) ) ; if ( context && php_stream_context_get_option ( context , ""http"" , ""header"" , & tmpzval ) == SUCCESS ) { tmp = NULL ; if ( Z_TYPE_PP ( tmpzval ) == IS_ARRAY ) { HashPosition pos ; zval * * tmpheader = NULL ; smart_str tmpstr = { 0 } ; for ( zend_hash_internal_pointer_reset_ex ( Z_ARRVAL_PP ( tmpzval ) , & pos ) ; SUCCESS == zend_hash_get_current_data_ex ( Z_ARRVAL_PP ( tmpzval ) , ( void * ) & tmpheader , & pos ) ; zend_hash_move_forward_ex ( Z_ARRVAL_PP ( tmpzval ) , & pos ) ) { if ( Z_TYPE_PP ( tmpheader ) == IS_STRING ) { smart_str_appendl ( & tmpstr , Z_STRVAL_PP ( tmpheader ) , Z_STRLEN_PP ( tmpheader ) ) ; smart_str_appendl ( & tmpstr , ""\\r\\n"" , sizeof ( ""\\r\\n"" ) - 1 ) ; } } smart_str_0 ( & tmpstr ) ; if ( tmpstr . c ) { tmp = php_trim ( tmpstr . c , strlen ( tmpstr . c ) , NULL , 0 , NULL , 3 TSRMLS_CC ) ; smart_str_free ( & tmpstr ) ; } } if ( Z_TYPE_PP ( tmpzval ) == IS_STRING && Z_STRLEN_PP ( tmpzval ) ) { tmp = php_trim ( Z_STRVAL_PP ( tmpzval ) , Z_STRLEN_PP ( tmpzval ) , NULL , 0 , NULL , 3 TSRMLS_CC ) ; } if ( tmp && strlen ( tmp ) > 0 ) { char * s ; user_headers = estrdup ( tmp ) ; php_strtolower ( tmp , strlen ( tmp ) ) ; if ( ! header_init ) { strip_header ( user_headers , tmp , ""content-length:"" ) ; strip_header ( user_headers , tmp , ""content-type:"" ) ; } if ( ( s = strstr ( tmp , ""user-agent:"" ) ) && ( s == tmp || * ( s - 1 ) == '\\r' || * ( s - 1 ) == '\\n' || * ( s - 1 ) == '\\t' || * ( s - 1 ) == '' ) ) { have_header |= HTTP_HEADER_USER_AGENT ; } if ( ( s = strstr ( tmp , ""host:"" ) ) && ( s == tmp || * ( s - 1 ) == '\\r' || * ( s - 1 ) == '\\n' || * ( s - 1 ) == '\\t' || * ( s - 1 ) == '' ) ) { have_header |= HTTP_HEADER_HOST ; } if ( ( s = strstr ( tmp , ""from:"" ) ) && ( s == tmp || * ( s - 1 ) == '\\r' || * ( s - 1 ) == '\\n' || * ( s - 1 ) == '\\t' || * ( s - 1 ) == '' ) ) { have_header |= HTTP_HEADER_FROM ; } if ( ( s = strstr ( tmp , ""authorization:"" ) ) && ( s == tmp || * ( s - 1 ) == '\\r' || * ( s - 1 ) == '\\n' || * ( s - 1 ) == '\\t' || * ( s - 1 ) == '' ) ) { have_header |= HTTP_HEADER_AUTH ; } if ( ( s = strstr ( tmp , ""content-length:"" ) ) && ( s == tmp || * ( s - 1 ) == '\\r' || * ( s - 1 ) == '\\n' || * ( s - 1 ) == '\\t' || * ( s - 1 ) == '' ) ) { have_header |= HTTP_HEADER_CONTENT_LENGTH ; } if ( ( s = strstr ( tmp , ""content-type:"" ) ) && ( s == tmp || * ( s - 1 ) == '\\r' || * ( s - 1 ) == '\\n' || * ( s - 1 ) == '\\t' || * ( s - 1 ) == '' ) ) { have_header |= HTTP_HEADER_TYPE ; } if ( ( s = strstr ( tmp , ""connection:"" ) ) && ( s == tmp || * ( s - 1 ) == '\\r' || * ( s - 1 ) == '\\n' || * ( s - 1 ) == '\\t' || * ( s - 1 ) == '' ) ) { have_header |= HTTP_HEADER_CONNECTION ; } if ( use_proxy && use_ssl && ( s = strstr ( tmp , ""proxy-authorization:"" ) ) && ( s == tmp || * ( s - 1 ) == '\\r' || * ( s - 1 ) == '\\n' || * ( s - 1 ) == '\\t' || * ( s - 1 ) == '' ) ) { char * p = s + sizeof ( ""proxy-authorization:"" ) - 1 ; while ( s > tmp && ( * ( s - 1 ) == '' || * ( s - 1 ) == '\\t' ) ) s -- ; while ( * p != 0 && * p != '\\r' && * p != '\\n' ) p ++ ; while ( * p == '\\r' || * p == '\\n' ) p ++ ; if ( * p == 0 ) { if ( s == tmp ) { efree ( user_headers ) ; user_headers = NULL ; } else { while ( s > tmp && ( * ( s - 1 ) == '\\r' || * ( s - 1 ) == '\\n' ) ) s -- ; user_headers [ s - tmp ] = 0 ; } } else { memmove ( user_headers + ( s - tmp ) , user_headers + ( p - tmp ) , strlen ( p ) + 1 ) ; } } } if ( tmp ) { efree ( tmp ) ; } } if ( ( ( have_header & HTTP_HEADER_AUTH ) == 0 ) && resource -> user ) { php_url_decode ( resource -> user , strlen ( resource -> user ) ) ; strcpy ( scratch , resource -> user ) ; strcat ( scratch , "":"" ) ; if ( resource -> pass ) { php_url_decode ( resource -> pass , strlen ( resource -> pass ) ) ; strcat ( scratch , resource -> pass ) ; } tmp = ( char * ) php_base64_encode ( ( unsigned char * ) scratch , strlen ( scratch ) , NULL ) ; if ( snprintf ( scratch , scratch_len , ""Authorization:Basic%s\\r\\n"" , tmp ) > 0 ) { php_stream_write ( stream , scratch , strlen ( scratch ) ) ; php_stream_notify_info ( context , PHP_STREAM_NOTIFY_AUTH_REQUIRED , NULL , 0 ) ; } efree ( tmp ) ; tmp = NULL ; } if ( ( ( have_header & HTTP_HEADER_FROM ) == 0 ) && FG ( from_address ) ) { if ( snprintf ( scratch , scratch_len , ""From:%s\\r\\n"" , FG ( from_address ) ) > 0 ) php_stream_write ( stream , scratch , strlen ( scratch ) ) ; } if ( ( have_header & HTTP_HEADER_HOST ) == 0 ) { if ( ( use_ssl && resource -> port != 443 && resource -> port != 0 ) || ( ! use_ssl && resource -> port != 80 && resource -> port != 0 ) ) { if ( snprintf ( scratch , scratch_len , ""Host:%s:%i\\r\\n"" , resource -> host , resource -> port ) > 0 ) php_stream_write ( stream , scratch , strlen ( scratch ) ) ; } else { if ( snprintf ( scratch , scratch_len , ""Host:%s\\r\\n"" , resource -> host ) > 0 ) { php_stream_write ( stream , scratch , strlen ( scratch ) ) ; } } } if ( ( have_header & HTTP_HEADER_CONNECTION ) == 0 ) { php_stream_write_string ( stream , ""Connection:close\\r\\n"" ) ; } if ( context && php_stream_context_get_option ( context , ""http"" , ""user_agent"" , & ua_zval ) == SUCCESS && Z_TYPE_PP ( ua_zval ) == IS_STRING ) { ua_str = Z_STRVAL_PP ( ua_zval ) ; } else if ( FG ( user_agent ) ) { ua_str = FG ( user_agent ) ; } if ( ( ( have_header & HTTP_HEADER_USER_AGENT ) == 0 ) && ua_str ) { # define _UA_HEADER ""User-Agent:%s\\r\\n"" char * ua ; size_t ua_len ; ua_len = sizeof ( _UA_HEADER ) + strlen ( ua_str ) ; if ( ua_len > sizeof ( _UA_HEADER ) ) { ua = emalloc ( ua_len + 1 ) ; if ( ( ua_len = slprintf ( ua , ua_len , _UA_HEADER , ua_str ) ) > 0 ) { ua [ ua_len ] = 0 ; php_stream_write ( stream , ua , ua_len ) ; } else { php_error_docref ( NULL TSRMLS_CC , E_WARNING , ""CannotconstructUser-agentheader"" ) ; } if ( ua ) { efree ( ua ) ; } } } if ( user_headers ) { if ( header_init && context && ! ( have_header & HTTP_HEADER_CONTENT_LENGTH ) && php_stream_context_get_option ( context , ""http"" , ""content"" , & tmpzval ) == SUCCESS && Z_TYPE_PP ( tmpzval ) == IS_STRING && Z_STRLEN_PP ( tmpzval ) > 0 ) { scratch_len = slprintf ( scratch , scratch_len , ""Content-Length:%d\\r\\n"" , Z_STRLEN_PP ( tmpzval ) ) ; php_stream_write ( stream , scratch , scratch_len ) ; have_header |= HTTP_HEADER_CONTENT_LENGTH ; } php_stream_write ( stream , user_headers , strlen ( user_headers ) ) ; php_stream_write ( stream , ""\\r\\n"" , sizeof ( ""\\r\\n"" ) - 1 ) ; efree ( user_headers ) ; } if ( header_init && context && php_stream_context_get_option ( context , ""http"" , ""content"" , & tmpzval ) == SUCCESS && Z_TYPE_PP ( tmpzval ) == IS_STRING && Z_STRLEN_PP ( tmpzval ) > 0 ) { if ( ! ( have_header & HTTP_HEADER_CONTENT_LENGTH ) ) { scratch_len = slprintf ( scratch , scratch_len , ""Content-Length:%d\\r\\n"" , Z_STRLEN_PP ( tmpzval ) ) ; php_stream_write ( stream , scratch , scratch_len ) ; } if ( ! ( have_header & HTTP_HEADER_TYPE ) ) { php_stream_write ( stream , ""Content-Type:application/x-www-form-urlencoded\\r\\n"" , sizeof ( ""Content-Type:application/x-www-form-urlencoded\\r\\n"" ) - 1 ) ; php_error_docref ( NULL TSRMLS_CC , E_NOTICE , ""Content-typenotspecifiedassumingapplication/x-www-form-urlencoded"" ) ; } php_stream_write ( stream , ""\\r\\n"" , sizeof ( ""\\r\\n"" ) - 1 ) ; php_stream_write ( stream , Z_STRVAL_PP ( tmpzval ) , Z_STRLEN_PP ( tmpzval ) ) ; } else { php_stream_write ( stream , ""\\r\\n"" , sizeof ( ""\\r\\n"" ) - 1 ) ; } location [ 0 ] = '\\0' ; if ( ! EG ( active_symbol_table ) ) { zend_rebuild_symbol_table ( TSRMLS_C ) ; } if ( header_init ) { zval * ztmp ; MAKE_STD_ZVAL ( ztmp ) ; array_init ( ztmp ) ; ZEND_SET_SYMBOL ( EG ( active_symbol_table ) , ""http_response_header"" , ztmp ) ; } { zval * * rh ; if ( zend_hash_find ( EG ( active_symbol_table ) , ""http_response_header"" , sizeof ( ""http_response_header"" ) , ( void * * ) & rh ) != SUCCESS || Z_TYPE_PP ( rh ) != IS_ARRAY ) { php_stream_wrapper_log_error ( wrapper , options TSRMLS_CC , ""HTTPrequestfailed,http_response_headeroverwritten"" ) ; goto out ; } response_header = * rh ; Z_ADDREF_P ( response_header ) ; } if ( ! php_stream_eof ( stream ) ) { size_t tmp_line_len ; if ( php_stream_get_line ( stream , tmp_line , sizeof ( tmp_line ) - 1 , & tmp_line_len ) != NULL ) { zval * http_response ; if ( tmp_line_len > 9 ) { response_code = atoi ( tmp_line + 9 ) ; } else { response_code = 0 ; } if ( context && SUCCESS == php_stream_context_get_option ( context , ""http"" , ""ignore_errors"" , & tmpzval ) ) { ignore_errors = zend_is_true ( * tmpzval ) ; } if ( ( options & STREAM_ONLY_GET_HEADERS ) || ignore_errors ) { reqok = 1 ; } if ( response_code >= 100 && response_code < 200 ) { while ( ! php_stream_eof ( stream ) && php_stream_get_line ( stream , tmp_line , sizeof ( tmp_line ) - 1 , & tmp_line_len ) != NULL && ( tmp_line_len < sizeof ( ""HTTP/1"" ) - 1 || strncasecmp ( tmp_line , ""HTTP/1"" , sizeof ( ""HTTP/1"" ) - 1 ) ) ) ; if ( tmp_line_len > 9 ) { response_code = atoi ( tmp_line + 9 ) ; } else { response_code = 0 ; } } if ( response_code >= 200 && response_code < 400 ) { reqok = 1 ; } else { switch ( response_code ) { case 403 : php_stream_notify_error ( context , PHP_STREAM_NOTIFY_AUTH_RESULT , tmp_line , response_code ) ; break ; default : if ( ! tmp_line_len ) { tmp_line [ 0 ] = '\\0' ; } php_stream_notify_error ( context , PHP_STREAM_NOTIFY_FAILURE , tmp_line , response_code ) ; } } if ( tmp_line [ tmp_line_len - 1 ] == '\\n' ) { -- tmp_line_len ; if ( tmp_line [ tmp_line_len - 1 ] == '\\r' ) { -- tmp_line_len ; } } MAKE_STD_ZVAL ( http_response ) ; ZVAL_STRINGL ( http_response , tmp_line , tmp_line_len , 1 ) ; zend_hash_next_index_insert ( Z_ARRVAL_P ( response_header ) , & http_response , sizeof ( zval * ) , NULL ) ; } } else { php_stream_wrapper_log_error ( wrapper , options TSRMLS_CC , ""HTTPrequestfailed,unexpectedendofsocket!"" ) ; goto out ; } http_header_line = emalloc ( HTTP_HEADER_BLOCK_SIZE ) ; while ( ! body && ! php_stream_eof ( stream ) ) { size_t http_header_line_length ; if ( php_stream_get_line ( stream , http_header_line , HTTP_HEADER_BLOCK_SIZE , & http_header_line_length ) && * http_header_line != '\\n' && * http_header_line != '\\r' ) { char * e = http_header_line + http_header_line_length - 1 ; if ( * e != '\\n' ) { do { if ( php_stream_get_line ( stream , http_header_line , HTTP_HEADER_BLOCK_SIZE , & http_header_line_length ) == NULL ) { php_stream_wrapper_log_error ( wrapper , options TSRMLS_CC , ""FailedtoreadHTTPheaders"" ) ; goto out ; } e = http_header_line + http_header_line_length - 1 ; } while ( * e != '\\n' ) ; continue ; } while ( * e == '\\n' || * e == '\\r' ) { e -- ; } http_header_line_length = e - http_header_line + 1 ; http_header_line [ http_header_line_length ] = '\\0' ; if ( ! strncasecmp ( http_header_line , ""Location:"" , 10 ) ) { if ( context && php_stream_context_get_option ( context , ""http"" , ""follow_location"" , & tmpzval ) == SUCCESS ) { SEPARATE_ZVAL ( tmpzval ) ; convert_to_long_ex ( tmpzval ) ; follow_location = Z_LVAL_PP ( tmpzval ) ; } else if ( ! ( response_code >= 300 && response_code < 304 || 307 == response_code || 308 == response_code ) ) { follow_location = 0 ; } strlcpy ( location , http_header_line + 10 , sizeof ( location ) ) ; } else if ( ! strncasecmp ( http_header_line , ""Content-Type:"" , 14 ) ) { php_stream_notify_info ( context , PHP_STREAM_NOTIFY_MIME_TYPE_IS , http_header_line + 14 , 0 ) ; } else if ( ! strncasecmp ( http_header_line , ""Content-Length:"" , 16 ) ) { file_size = atoi ( http_header_line + 16 ) ; php_stream_notify_file_size ( context , file_size , http_header_line , 0 ) ; } else if ( ! strncasecmp ( http_header_line , ""Transfer-Encoding:chunked"" , sizeof ( ""Transfer-Encoding:chunked"" ) ) ) { if ( ! ( options & STREAM_ONLY_GET_HEADERS ) ) { long decode = 1 ; if ( context && php_stream_context_get_option ( context , ""http"" , ""auto_decode"" , & tmpzval ) == SUCCESS ) { SEPARATE_ZVAL ( tmpzval ) ; convert_to_boolean ( * tmpzval ) ; decode = Z_LVAL_PP ( tmpzval ) ; } if ( decode ) { transfer_encoding = php_stream_filter_create ( ""dechunk"" , NULL , php_stream_is_persistent ( stream ) TSRMLS_CC ) ; if ( transfer_encoding ) { continue ; } } } } if ( http_header_line [ 0 ] == '\\0' ) { body = 1 ; } else { zval * http_header ; MAKE_STD_ZVAL ( http_header ) ; ZVAL_STRINGL ( http_header , http_header_line , http_header_line_length , 1 ) ; zend_hash_next_index_insert ( Z_ARRVAL_P ( response_header ) , & http_header , sizeof ( zval * ) , NULL ) ; } } else { break ; } } if ( ! reqok || ( location [ 0 ] != '\\0' && follow_location ) ) { if ( ! follow_location || ( ( ( options & STREAM_ONLY_GET_HEADERS ) || ignore_errors ) && redirect_max <= 1 ) ) { goto out ; } if ( location [ 0 ] != '\\0' ) php_stream_notify_info ( context , PHP_STREAM_NOTIFY_REDIRECTED , location , 0 ) ; php_stream_close ( stream ) ; stream = NULL ; if ( location [ 0 ] != '\\0' ) { char new_path [ HTTP_HEADER_BLOCK_SIZE ] ; char loc_path [ HTTP_HEADER_BLOCK_SIZE ] ; * new_path = '\\0' ; if ( strlen ( location ) < 8 || ( strncasecmp ( location , ""http://"" , sizeof ( ""http://"" ) - 1 ) && strncasecmp ( location , ""https://"" , sizeof ( ""https://"" ) - 1 ) && strncasecmp ( location , ""ftp://"" , sizeof ( ""ftp://"" ) - 1 ) && strncasecmp ( location , ""ftps://"" , sizeof ( ""ftps://"" ) - 1 ) ) ) { if ( * location != '/' ) { if ( * ( location + 1 ) != '\\0' && resource -> path ) { char * s = strrchr ( resource -> path , '/' ) ; if ( ! s ) { s = resource -> path ; if ( ! s [ 0 ] ) { efree ( s ) ; s = resource -> path = estrdup ( ""/"" ) ; } else { * s = '/' ; } } s [ 1 ] = '\\0' ; if ( resource -> path && * ( resource -> path ) == '/' && * ( resource -> path + 1 ) == '\\0' ) { snprintf ( loc_path , sizeof ( loc_path ) - 1 , ""%s%s"" , resource -> path , location ) ; } else { snprintf ( loc_path , sizeof ( loc_path ) - 1 , ""%s/%s"" , resource -> path , location ) ; } } else { snprintf ( loc_path , sizeof ( loc_path ) - 1 , ""/%s"" , location ) ; } } else { strlcpy ( loc_path , location , sizeof ( loc_path ) ) ; } if ( ( use_ssl && resource -> port != 443 ) || ( ! use_ssl && resource -> port != 80 ) ) { snprintf ( new_path , sizeof ( new_path ) - 1 , ""%s://%s:%d%s"" , resource -> scheme , resource -> host , resource -> port , loc_path ) ; } else { snprintf ( new_path , sizeof ( new_path ) - 1 , ""%s://%s%s"" , resource -> scheme , resource -> host , loc_path ) ; } } else { strlcpy ( new_path , location , sizeof ( new_path ) ) ; } php_url_free ( resource ) ; if ( ( resource = php_url_parse ( new_path ) ) == NULL ) { php_stream_wrapper_log_error ( wrapper , options TSRMLS_CC , ""InvalidredirectURL!%s"" , new_path ) ; goto out ; } # define CHECK_FOR_CNTRL_CHARS ( val ) { if ( val ) { unsigned char * s , * e ; int l ; l = php_url_decode ( val , strlen ( val ) ) ; s = ( unsigned char * ) val ; e = s + l ; while ( s < e ) { if ( iscntrl ( * s ) ) { php_stream_wrapper_log_error ( wrapper , options TSRMLS_CC , ""InvalidredirectURL!%s"" , new_path ) ; goto out ; } s ++ ; } } } if ( strncasecmp ( new_path , ""http://"" , sizeof ( ""http://"" ) - 1 ) || strncasecmp ( new_path , ""https://"" , sizeof ( ""https://"" ) - 1 ) ) { CHECK_FOR_CNTRL_CHARS ( resource -> user ) CHECK_FOR_CNTRL_CHARS ( resource -> pass ) CHECK_FOR_CNTRL_CHARS ( resource -> path ) } stream = php_stream_url_wrap_http_ex ( wrapper , new_path , mode , options , opened_path , context , -- redirect_max , HTTP_WRAPPER_REDIRECTED STREAMS_CC TSRMLS_CC ) ; } else { php_stream_wrapper_log_error ( wrapper , options TSRMLS_CC , ""HTTPrequestfailed!%s"" , tmp_line ) ; } } out : if ( protocol_version ) { efree ( protocol_version ) ; } if ( http_header_line ) { efree ( http_header_line ) ; } if ( scratch ) { efree ( scratch ) ; } if ( resource ) { php_url_free ( resource ) ; } if ( stream ) { if ( header_init ) { stream -> wrapperdata = response_header ; } else { if ( response_header ) { Z_DELREF_P ( response_header ) ; } } php_stream_notify_progress_init ( context , 0 , file_size ) ; if ( options & STREAM_WILL_CAST ) php_stream_set_chunk_size ( stream , chunk_size ) ; stream -> flags |= eol_detect ; stream -> position = 0 ; strlcpy ( stream -> mode , mode , sizeof ( stream -> mode ) ) ; if ( transfer_encoding ) { php_stream_filter_append ( & stream -> readfilters , transfer_encoding ) ; } } else { if ( response_header ) { Z_DELREF_P ( response_header ) ; } if ( transfer_encoding ) { php_stream_filter_free ( transfer_encoding TSRMLS_CC ) ; } } return stream ; } "," } if ( tmp_line_len >= 1 && ; if ( tmp_line_len >= 1 && ; } } \\\n} if ( strncasecmp ",php@php-src/523f230c831d7b33353203fa34aee4e92ac12bba,CVE-2018-7584,https://github.com/php/php-src/commit/523f230c831d7b33353203fa34aee4e92ac12bba,2018-03-01T19:29Z 878,CWE-125,"CWE-125 static PyObject * decode_unicode_with_escapes ( struct compiling * c , const node * n , const char * s , size_t len ) { PyObject * u ; char * buf ; char * p ; const char * end ; if ( len > SIZE_MAX / 6 ) return NULL ; u = PyBytes_FromStringAndSize ( ( char * ) NULL , len * 6 ) ; if ( u == NULL ) return NULL ; p = buf = PyBytes_AsString ( u ) ; end = s + len ; while ( s < end ) { if ( * s == '\\\\' ) { * p ++ = * s ++ ; if ( * s & 0x80 ) { strcpy ( p , ""u005c"" ) ; p += 5 ; } } if ( * s & 0x80 ) { PyObject * w ; int kind ; void * data ; Py_ssize_t len , i ; w = decode_utf8 ( c , & s , end ) ; if ( w == NULL ) { Py_DECREF ( u ) ; return NULL ; } kind = PyUnicode_KIND ( w ) ; data = PyUnicode_DATA ( w ) ; len = PyUnicode_GET_LENGTH ( w ) ; for ( i = 0 ; i < len ; i ++ ) { Py_UCS4 chr = PyUnicode_READ ( kind , data , i ) ; sprintf ( p , ""\\\\U%08x"" , chr ) ; p += 10 ; } assert ( p - buf <= Py_SIZE ( u ) ) ; Py_DECREF ( w ) ; } else { * p ++ = * s ++ ; } } len = p - buf ; s = buf ; return PyUnicode_DecodeUnicodeEscape ( s , len , NULL ) ; } "," { PyObject * v , * char * end ; const char * first_invalid_escape ; if ( s >= end || p += 5 ; if ( s >= end ) break - buf <= PyBytes_GET_SIZE ( u ) = buf ; v = _PyUnicode_DecodeUnicodeEscape ( s , len , NULL , & first_invalid_escape ) ; if ( v != NULL && first_invalid_escape != NULL ) { if ( warn_invalid_escape_sequence ( c , n , * first_invalid_escape ) < 0 ) { Py_XDECREF ( u ) ; Py_DECREF ( v ) ; return NULL ; } } Py_XDECREF ( u ) ; return v ; } ",python@typed_ast/156afcb26c198e162504a57caddfe0acd9ed7dce,CVE-2019-19275,https://github.com/python/typed_ast/commit/156afcb26c198e162504a57caddfe0acd9ed7dce,2019-11-26T15:15Z 879,CWE-125,"CWE-125 int libevt_record_values_read_event ( libevt_record_values_t * record_values , uint8_t * record_data , size_t record_data_size , uint8_t strict_mode , libcerror_error_t * * error ) { static char * function = ""libevt_record_values_read_event"" ; size_t record_data_offset = 0 ; size_t strings_data_offset = 0 ; ssize_t value_data_size = 0 ; uint32_t data_offset = 0 ; uint32_t data_size = 0 ; uint32_t members_data_size = 0 ; uint32_t size = 0 ; uint32_t size_copy = 0 ; uint32_t strings_offset = 0 ; uint32_t strings_size = 0 ; uint32_t user_sid_offset = 0 ; uint32_t user_sid_size = 0 ; # if defined ( HAVE_DEBUG_OUTPUT ) uint32_t value_32bit = 0 ; uint16_t value_16bit = 0 ; # endif if ( record_values == NULL ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_ARGUMENTS , LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE , ""%s:invalidrecordvalues."" , function ) ; return ( - 1 ) ; } if ( record_data == NULL ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_ARGUMENTS , LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE , ""%s:invalidrecorddata."" , function ) ; return ( - 1 ) ; } if ( record_data_size > ( size_t ) SSIZE_MAX ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_ARGUMENTS , LIBCERROR_ARGUMENT_ERROR_VALUE_EXCEEDS_MAXIMUM , ""%s:invalidrecorddatasizevalueexceedsmaximum."" , function ) ; return ( - 1 ) ; } if ( record_data_size < ( sizeof ( evt_record_event_header_t ) + 4 ) ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS , ""%s:recorddatasizevalueoutofbounds."" , function ) ; return ( - 1 ) ; } byte_stream_copy_to_uint32_little_endian ( ( ( evt_record_event_header_t * ) record_data ) -> size , size ) ; byte_stream_copy_to_uint32_little_endian ( ( ( evt_record_event_header_t * ) record_data ) -> record_number , record_values -> number ) ; byte_stream_copy_to_uint32_little_endian ( ( ( evt_record_event_header_t * ) record_data ) -> creation_time , record_values -> creation_time ) ; byte_stream_copy_to_uint32_little_endian ( ( ( evt_record_event_header_t * ) record_data ) -> written_time , record_values -> written_time ) ; byte_stream_copy_to_uint32_little_endian ( ( ( evt_record_event_header_t * ) record_data ) -> event_identifier , record_values -> event_identifier ) ; byte_stream_copy_to_uint16_little_endian ( ( ( evt_record_event_header_t * ) record_data ) -> event_type , record_values -> event_type ) ; byte_stream_copy_to_uint16_little_endian ( ( ( evt_record_event_header_t * ) record_data ) -> event_category , record_values -> event_category ) ; byte_stream_copy_to_uint32_little_endian ( ( ( evt_record_event_header_t * ) record_data ) -> strings_offset , strings_offset ) ; byte_stream_copy_to_uint32_little_endian ( ( ( evt_record_event_header_t * ) record_data ) -> user_sid_size , user_sid_size ) ; byte_stream_copy_to_uint32_little_endian ( ( ( evt_record_event_header_t * ) record_data ) -> user_sid_offset , user_sid_offset ) ; byte_stream_copy_to_uint32_little_endian ( ( ( evt_record_event_header_t * ) record_data ) -> data_size , data_size ) ; byte_stream_copy_to_uint32_little_endian ( ( ( evt_record_event_header_t * ) record_data ) -> data_offset , data_offset ) ; byte_stream_copy_to_uint32_little_endian ( & ( record_data [ record_data_size - 4 ] ) , size_copy ) ; # if defined ( HAVE_DEBUG_OUTPUT ) if ( libcnotify_verbose != 0 ) { libcnotify_printf ( ""%s:size\\t\\t\\t\\t\\t:%"" PRIu32 ""\\n"" , function , size ) ; libcnotify_printf ( ""%s:signature\\t\\t\\t\\t:%c%c%c%c\\n"" , function , ( ( evt_record_event_header_t * ) record_data ) -> signature [ 0 ] , ( ( evt_record_event_header_t * ) record_data ) -> signature [ 1 ] , ( ( evt_record_event_header_t * ) record_data ) -> signature [ 2 ] , ( ( evt_record_event_header_t * ) record_data ) -> signature [ 3 ] ) ; libcnotify_printf ( ""%s:recordnumber\\t\\t\\t\\t:%"" PRIu32 ""\\n"" , function , record_values -> number ) ; if ( libevt_debug_print_posix_time_value ( function , ""creationtime\\t\\t\\t\\t"" , ( ( evt_record_event_header_t * ) record_data ) -> creation_time , 4 , LIBFDATETIME_ENDIAN_LITTLE , LIBFDATETIME_POSIX_TIME_VALUE_TYPE_SECONDS_32BIT_SIGNED , LIBFDATETIME_STRING_FORMAT_TYPE_CTIME | LIBFDATETIME_STRING_FORMAT_FLAG_DATE_TIME , error ) != 1 ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_PRINT_FAILED , ""%s:unabletoprintPOSIXtimevalue."" , function ) ; goto on_error ; } if ( libevt_debug_print_posix_time_value ( function , ""writtentime\\t\\t\\t\\t"" , ( ( evt_record_event_header_t * ) record_data ) -> written_time , 4 , LIBFDATETIME_ENDIAN_LITTLE , LIBFDATETIME_POSIX_TIME_VALUE_TYPE_SECONDS_32BIT_SIGNED , LIBFDATETIME_STRING_FORMAT_TYPE_CTIME | LIBFDATETIME_STRING_FORMAT_FLAG_DATE_TIME , error ) != 1 ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_PRINT_FAILED , ""%s:unabletoprintPOSIXtimevalue."" , function ) ; goto on_error ; } libcnotify_printf ( ""%s:eventidentifier\\t\\t\\t:0x%08"" PRIx32 ""\\n"" , function , record_values -> event_identifier ) ; libcnotify_printf ( ""%s:eventidentifier:code\\t\\t\\t:%"" PRIu32 ""\\n"" , function , record_values -> event_identifier & 0x0000ffffUL ) ; libcnotify_printf ( ""%s:eventidentifier:facility\\t\\t:%"" PRIu32 ""\\n"" , function , ( record_values -> event_identifier & 0x0fff0000UL ) >> 16 ) ; libcnotify_printf ( ""%s:eventidentifier:reserved\\t\\t:%"" PRIu32 ""\\n"" , function , ( record_values -> event_identifier & 0x10000000UL ) >> 28 ) ; libcnotify_printf ( ""%s:eventidentifier:customerflags\\t:%"" PRIu32 ""\\n"" , function , ( record_values -> event_identifier & 0x20000000UL ) >> 29 ) ; libcnotify_printf ( ""%s:eventidentifier:severity\\t\\t:%"" PRIu32 ""("" , function , ( record_values -> event_identifier & 0xc0000000UL ) >> 30 ) ; libevt_debug_print_event_identifier_severity ( record_values -> event_identifier ) ; libcnotify_printf ( "")\\n"" ) ; libcnotify_printf ( ""%s:eventtype\\t\\t\\t\\t:%"" PRIu16 ""("" , function , record_values -> event_type ) ; libevt_debug_print_event_type ( record_values -> event_type ) ; libcnotify_printf ( "")\\n"" ) ; byte_stream_copy_to_uint16_little_endian ( ( ( evt_record_event_header_t * ) record_data ) -> number_of_strings , value_16bit ) ; libcnotify_printf ( ""%s:numberofstrings\\t\\t\\t:%"" PRIu16 ""\\n"" , function , value_16bit ) ; libcnotify_printf ( ""%s:eventcategory\\t\\t\\t\\t:%"" PRIu16 ""\\n"" , function , record_values -> event_category ) ; byte_stream_copy_to_uint16_little_endian ( ( ( evt_record_event_header_t * ) record_data ) -> event_flags , value_16bit ) ; libcnotify_printf ( ""%s:eventflags\\t\\t\\t\\t:0x%04"" PRIx16 ""\\n"" , function , value_16bit ) ; byte_stream_copy_to_uint32_little_endian ( ( ( evt_record_event_header_t * ) record_data ) -> closing_record_number , value_32bit ) ; libcnotify_printf ( ""%s:closingrecordvaluesnumber\\t\\t:%"" PRIu32 ""\\n"" , function , value_32bit ) ; libcnotify_printf ( ""%s:stringsoffset\\t\\t\\t\\t:%"" PRIu32 ""\\n"" , function , strings_offset ) ; libcnotify_printf ( ""%s:usersecurityidentifier(SID)size\\t:%"" PRIu32 ""\\n"" , function , user_sid_size ) ; libcnotify_printf ( ""%s:usersecurityidentifier(SID)offset\\t:%"" PRIu32 ""\\n"" , function , user_sid_offset ) ; libcnotify_printf ( ""%s:datasize\\t\\t\\t\\t:%"" PRIu32 ""\\n"" , function , data_size ) ; libcnotify_printf ( ""%s:dataoffset\\t\\t\\t\\t:%"" PRIu32 ""\\n"" , function , data_offset ) ; } # endif record_data_offset = sizeof ( evt_record_event_header_t ) ; if ( ( user_sid_offset == 0 ) && ( user_sid_size != 0 ) ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS , ""%s:userSIDoffsetorsizevalueoutofbounds."" , function ) ; goto on_error ; } if ( user_sid_offset != 0 ) { if ( ( ( size_t ) user_sid_offset < record_data_offset ) || ( ( size_t ) user_sid_offset >= ( record_data_size - 4 ) ) ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS , ""%s:userSIDoffsetvalueoutofbounds."" , function ) ; goto on_error ; } if ( user_sid_size != 0 ) { if ( ( size_t ) ( user_sid_offset + user_sid_size ) > ( record_data_size - 4 ) ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS , ""%s:userSIDsizevalueoutofbounds."" , function ) ; goto on_error ; } } } if ( ( ( size_t ) strings_offset < user_sid_offset ) || ( ( size_t ) strings_offset >= ( record_data_size - 4 ) ) ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS , ""%s:stringsoffsetvalueoutofbounds."" , function ) ; goto on_error ; } if ( ( ( size_t ) data_offset < strings_offset ) || ( ( size_t ) data_offset >= ( record_data_size - 4 ) ) ) { if ( data_size != 0 ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS , ""%s:dataoffsetvalueoutofbounds."" , function ) ; goto on_error ; } data_offset = ( uint32_t ) record_data_size - 4 ; } if ( ( ( size_t ) strings_offset >= ( record_data_size - 4 ) ) && ( strings_offset != data_offset ) ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS , ""%s:stringsoffsetvalueoutofbounds."" , function ) ; goto on_error ; } if ( strings_offset != 0 ) { if ( strings_offset < record_data_offset ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS , ""%s:stringsoffsetvalueoutofbounds."" , function ) ; goto on_error ; } } if ( user_sid_offset != 0 ) { members_data_size = user_sid_offset - ( uint32_t ) record_data_offset ; } else if ( strings_offset != 0 ) { members_data_size = strings_offset - ( uint32_t ) record_data_offset ; } if ( strings_offset != 0 ) { strings_size = data_offset - strings_offset ; } if ( data_size != 0 ) { if ( ( size_t ) ( data_offset + data_size ) > ( record_data_size - 4 ) ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS , ""%s:datasizevalueoutofbounds."" , function ) ; goto on_error ; } } if ( members_data_size != 0 ) { # if defined ( HAVE_DEBUG_OUTPUT ) if ( libcnotify_verbose != 0 ) { libcnotify_printf ( ""%s:membersdata:\\n"" , function ) ; libcnotify_print_data ( & ( record_data [ record_data_offset ] ) , members_data_size , LIBCNOTIFY_PRINT_DATA_FLAG_GROUP_DATA ) ; } # endif if ( libfvalue_value_type_initialize ( & ( record_values -> source_name ) , LIBFVALUE_VALUE_TYPE_STRING_UTF16 , error ) != 1 ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED , ""%s:unabletocreatesourcenamevalue."" , function ) ; goto on_error ; } value_data_size = libfvalue_value_type_set_data_string ( record_values -> source_name , & ( record_data [ record_data_offset ] ) , members_data_size , LIBFVALUE_CODEPAGE_UTF16_LITTLE_ENDIAN , LIBFVALUE_VALUE_DATA_FLAG_MANAGED , error ) ; if ( value_data_size == - 1 ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_SET_FAILED , ""%s:unabletosetdataofsourcenamevalue."" , function ) ; goto on_error ; } # if defined ( HAVE_DEBUG_OUTPUT ) if ( libcnotify_verbose != 0 ) { libcnotify_printf ( ""%s:sourcename\\t\\t\\t\\t:"" , function ) ; if ( libfvalue_value_print ( record_values -> source_name , 0 , 0 , error ) != 1 ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_PRINT_FAILED , ""%s:unabletoprintsourcenamevalue."" , function ) ; goto on_error ; } libcnotify_printf ( ""\\n"" ) ; } # endif record_data_offset += value_data_size ; members_data_size -= ( uint32_t ) value_data_size ; if ( libfvalue_value_type_initialize ( & ( record_values -> computer_name ) , LIBFVALUE_VALUE_TYPE_STRING_UTF16 , error ) != 1 ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED , ""%s:unabletocreatecomputernamevalue."" , function ) ; goto on_error ; } value_data_size = libfvalue_value_type_set_data_string ( record_values -> computer_name , & ( record_data [ record_data_offset ] ) , members_data_size , LIBFVALUE_CODEPAGE_UTF16_LITTLE_ENDIAN , LIBFVALUE_VALUE_DATA_FLAG_MANAGED , error ) ; if ( value_data_size == - 1 ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_SET_FAILED , ""%s:unabletosetdataofcomputernamevalue."" , function ) ; goto on_error ; } # if defined ( HAVE_DEBUG_OUTPUT ) if ( libcnotify_verbose != 0 ) { libcnotify_printf ( ""%s:computername\\t\\t\\t\\t:"" , function ) ; if ( libfvalue_value_print ( record_values -> computer_name , 0 , 0 , error ) != 1 ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_PRINT_FAILED , ""%s:unabletoprintcomputernamevalue."" , function ) ; goto on_error ; } libcnotify_printf ( ""\\n"" ) ; } # endif record_data_offset += value_data_size ; members_data_size -= ( uint32_t ) value_data_size ; if ( members_data_size > 0 ) { # if defined ( HAVE_DEBUG_OUTPUT ) if ( libcnotify_verbose != 0 ) { libcnotify_printf ( ""%s:memberstrailingdata:\\n"" , function ) ; libcnotify_print_data ( & ( record_data [ record_data_offset ] ) , members_data_size , LIBCNOTIFY_PRINT_DATA_FLAG_GROUP_DATA ) ; } # endif record_data_offset += members_data_size ; } } if ( user_sid_size != 0 ) { if ( libfvalue_value_type_initialize ( & ( record_values -> user_security_identifier ) , LIBFVALUE_VALUE_TYPE_NT_SECURITY_IDENTIFIER , error ) != 1 ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED , ""%s:unabletocreateusersecurityidentifier(SID)value."" , function ) ; goto on_error ; } if ( libfvalue_value_set_data ( record_values -> user_security_identifier , & ( record_data [ user_sid_offset ] ) , ( size_t ) user_sid_size , LIBFVALUE_ENDIAN_LITTLE , LIBFVALUE_VALUE_DATA_FLAG_MANAGED , error ) != 1 ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_SET_FAILED , ""%s:unabletosetdataofusersecurityidentifier(SID)value."" , function ) ; goto on_error ; } # if defined ( HAVE_DEBUG_OUTPUT ) if ( libcnotify_verbose != 0 ) { libcnotify_printf ( ""%s:usersecurityidentifier(SID)\\t\\t:"" , function ) ; if ( libfvalue_value_print ( record_values -> user_security_identifier , 0 , 0 , error ) != 1 ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_PRINT_FAILED , ""%s:unabletoprintusersecurityidentifier(SID)value."" , function ) ; goto on_error ; } libcnotify_printf ( ""\\n"" ) ; } # endif record_data_offset += user_sid_size ; } if ( strings_size != 0 ) { # if defined ( HAVE_DEBUG_OUTPUT ) if ( libcnotify_verbose != 0 ) { libcnotify_printf ( ""%s:stringsdata:\\n"" , function ) ; libcnotify_print_data ( & ( record_data [ strings_offset ] ) , strings_size , LIBCNOTIFY_PRINT_DATA_FLAG_GROUP_DATA ) ; } # endif if ( size_copy == 0 ) { strings_data_offset = strings_offset + strings_size - 2 ; while ( strings_data_offset > strings_offset ) { if ( ( record_data [ strings_data_offset ] != 0 ) || ( record_data [ strings_data_offset + 1 ] != 0 ) ) { strings_size += 2 ; break ; } strings_data_offset -= 2 ; strings_size -= 2 ; } } if ( libfvalue_value_type_initialize ( & ( record_values -> strings ) , LIBFVALUE_VALUE_TYPE_STRING_UTF16 , error ) != 1 ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED , ""%s:unabletocreatestringsvalue."" , function ) ; goto on_error ; } value_data_size = libfvalue_value_type_set_data_strings_array ( record_values -> strings , & ( record_data [ strings_offset ] ) , strings_size , LIBFVALUE_CODEPAGE_UTF16_LITTLE_ENDIAN , error ) ; if ( value_data_size == - 1 ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_SET_FAILED , ""%s:unabletosetdataofstringsvalue."" , function ) ; goto on_error ; } record_data_offset += strings_size ; } if ( data_size != 0 ) { # if defined ( HAVE_DEBUG_OUTPUT ) if ( libcnotify_verbose != 0 ) { libcnotify_printf ( ""%s:data:\\n"" , function ) ; libcnotify_print_data ( & ( record_data [ data_offset ] ) , ( size_t ) data_size , LIBCNOTIFY_PRINT_DATA_FLAG_GROUP_DATA ) ; } # endif if ( libfvalue_value_type_initialize ( & ( record_values -> data ) , LIBFVALUE_VALUE_TYPE_BINARY_DATA , error ) != 1 ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED , ""%s:unabletocreatedatavalue."" , function ) ; goto on_error ; } if ( libfvalue_value_set_data ( record_values -> data , & ( record_data [ record_data_offset ] ) , ( size_t ) data_size , LIBFVALUE_ENDIAN_LITTLE , LIBFVALUE_VALUE_DATA_FLAG_MANAGED , error ) != 1 ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_SET_FAILED , ""%s:unabletosetdataofdatavalue."" , function ) ; goto on_error ; } # if defined ( HAVE_DEBUG_OUTPUT ) record_data_offset += data_size ; # endif } # if defined ( HAVE_DEBUG_OUTPUT ) if ( libcnotify_verbose != 0 ) { if ( record_data_offset < ( record_data_size - 4 ) ) { libcnotify_printf ( ""%s:padding:\\n"" , function ) ; libcnotify_print_data ( & ( record_data [ record_data_offset ] ) , ( size_t ) record_data_size - record_data_offset - 4 , LIBCNOTIFY_PRINT_DATA_FLAG_GROUP_DATA ) ; } libcnotify_printf ( ""%s:sizecopy\\t\\t\\t\\t:%"" PRIu32 ""\\n"" , function , size_copy ) ; libcnotify_printf ( ""\\n"" ) ; } # endif if ( ( strict_mode == 0 ) && ( size_copy == 0 ) ) { size_copy = size ; } if ( size != size_copy ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_INPUT , LIBCERROR_INPUT_ERROR_VALUE_MISMATCH , ""%s:valuemismatchforsizeandsizecopy."" , function ) ; goto on_error ; } if ( record_data_size != ( size_t ) size ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_INPUT , LIBCERROR_INPUT_ERROR_VALUE_MISMATCH , ""%s:valuemismatchforrecord_valuesdatasizeandsize."" , function ) ; goto on_error ; } return ( 1 ) ; on_error : if ( record_values -> data != NULL ) { libfvalue_value_free ( & ( record_values -> data ) , NULL ) ; } if ( record_values -> strings != NULL ) { libfvalue_value_free ( & ( record_values -> strings ) , NULL ) ; } if ( record_values -> user_security_identifier != NULL ) { libfvalue_value_free ( & ( record_values -> user_security_identifier ) , NULL ) ; } if ( record_values -> computer_name != NULL ) { libfvalue_value_free ( & ( record_values -> computer_name ) , NULL ) ; } if ( record_values -> source_name != NULL ) { libfvalue_value_free ( & ( record_values -> source_name ) , NULL ) ; } return ( - 1 ) ; } "," { if ( user_sid_size > ( ( record_data_size - 4 ) - user_sid_offset ) ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS , ""%s:userSIDdatasizevalueoutofbounds."" , function ) ; goto on_error ; } if ( 0 ) { if ( strings_size > ( ( record_data_size - 4 ) - strings_offset ) ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS , ""%s:stringssizevalueoutofbounds."" , function ) ; goto on_error ; } 0 ) { if ( data_size > ( ( record_data_size - 4 ) - record_data_offset ) ) { libcerror_error_set ( error , LIBCERROR_ERROR_DOMAIN_RUNTIME , LIBCERROR_RUNTIME_ERROR_VALUE_OUT_OF_BOUNDS , ""%s:datasizevalueoutofbounds."" , function ) ; goto on_error ; } ( record_data [ record_data_offset ] ) , ",libyal@libevt/9d2cc3ca0a1612a6b271abcacffc2e3eea42925e,CVE-2018-8754,https://github.com/libyal/libevt/commit/9d2cc3ca0a1612a6b271abcacffc2e3eea42925e,2018-03-18T03:29Z 880,CWE-119,"CWE-119 int ParseWave64HeaderConfig ( FILE * infile , char * infilename , char * fourcc , WavpackContext * wpc , WavpackConfig * config ) { int64_t total_samples = 0 , infilesize ; Wave64ChunkHeader chunk_header ; Wave64FileHeader filehdr ; WaveHeader WaveHeader ; uint32_t bcount ; infilesize = DoGetFileSize ( infile ) ; memcpy ( & filehdr , fourcc , 4 ) ; if ( ! DoReadFile ( infile , ( ( char * ) & filehdr ) + 4 , sizeof ( Wave64FileHeader ) - 4 , & bcount ) || bcount != sizeof ( Wave64FileHeader ) - 4 || memcmp ( filehdr . ckID , riff_guid , sizeof ( riff_guid ) ) || memcmp ( filehdr . formType , wave_guid , sizeof ( wave_guid ) ) ) { error_line ( ""%sisnotavalid.W64file!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & filehdr , sizeof ( filehdr ) ) ) { error_line ( ""%s"" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } # if 1 WavpackLittleEndianToNative ( & filehdr , Wave64ChunkHeaderFormat ) ; if ( infilesize && ! ( config -> qmode & QMODE_IGNORE_LENGTH ) && filehdr . ckSize && filehdr . ckSize + 1 && filehdr . ckSize != infilesize ) { error_line ( ""%sisnotavalid.W64file!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } # endif while ( 1 ) { if ( ! DoReadFile ( infile , & chunk_header , sizeof ( Wave64ChunkHeader ) , & bcount ) || bcount != sizeof ( Wave64ChunkHeader ) ) { error_line ( ""%sisnotavalid.W64file!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & chunk_header , sizeof ( Wave64ChunkHeader ) ) ) { error_line ( ""%s"" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } WavpackLittleEndianToNative ( & chunk_header , Wave64ChunkHeaderFormat ) ; chunk_header . ckSize -= sizeof ( chunk_header ) ; if ( ! memcmp ( chunk_header . ckID , fmt_guid , sizeof ( fmt_guid ) ) ) { int supported = TRUE , format ; chunk_header . ckSize = ( chunk_header . ckSize + 7 ) & ~ 7L ; if ( chunk_header . ckSize < 16 || chunk_header . ckSize > sizeof ( WaveHeader ) || ! DoReadFile ( infile , & WaveHeader , ( uint32_t ) chunk_header . ckSize , & bcount ) || bcount != chunk_header . ckSize ) { error_line ( ""%sisnotavalid.W64file!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & WaveHeader , ( uint32_t ) chunk_header . ckSize ) ) { error_line ( ""%s"" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } WavpackLittleEndianToNative ( & WaveHeader , WaveHeaderFormat ) ; if ( debug_logging_mode ) { error_line ( ""formattagsize=%d"" , chunk_header . ckSize ) ; error_line ( ""FormatTag=%x,NumChannels=%d,BitsPerSample=%d"" , WaveHeader . FormatTag , WaveHeader . NumChannels , WaveHeader . BitsPerSample ) ; error_line ( ""BlockAlign=%d,SampleRate=%d,BytesPerSecond=%d"" , WaveHeader . BlockAlign , WaveHeader . SampleRate , WaveHeader . BytesPerSecond ) ; if ( chunk_header . ckSize > 16 ) error_line ( ""cbSize=%d,ValidBitsPerSample=%d"" , WaveHeader . cbSize , WaveHeader . ValidBitsPerSample ) ; if ( chunk_header . ckSize > 20 ) error_line ( ""ChannelMask=%x,SubFormat=%d"" , WaveHeader . ChannelMask , WaveHeader . SubFormat ) ; } if ( chunk_header . ckSize > 16 && WaveHeader . cbSize == 2 ) config -> qmode |= QMODE_ADOBE_MODE ; format = ( WaveHeader . FormatTag == 0xfffe && chunk_header . ckSize == 40 ) ? WaveHeader . SubFormat : WaveHeader . FormatTag ; config -> bits_per_sample = ( chunk_header . ckSize == 40 && WaveHeader . ValidBitsPerSample ) ? WaveHeader . ValidBitsPerSample : WaveHeader . BitsPerSample ; if ( format != 1 && format != 3 ) supported = FALSE ; if ( format == 3 && config -> bits_per_sample != 32 ) supported = FALSE ; if ( ! WaveHeader . NumChannels || WaveHeader . NumChannels > 256 || WaveHeader . BlockAlign / WaveHeader . NumChannels < ( config -> bits_per_sample + 7 ) / 8 || WaveHeader . BlockAlign / WaveHeader . NumChannels > 4 || WaveHeader . BlockAlign % WaveHeader . NumChannels ) supported = FALSE ; if ( config -> bits_per_sample < 1 || config -> bits_per_sample > 32 ) supported = FALSE ; if ( ! supported ) { error_line ( ""%sisanunsupported.W64format!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } if ( chunk_header . ckSize < 40 ) { if ( ! config -> channel_mask && ! ( config -> qmode & QMODE_CHANS_UNASSIGNED ) ) { if ( WaveHeader . NumChannels <= 2 ) config -> channel_mask = 0x5 - WaveHeader . NumChannels ; else if ( WaveHeader . NumChannels <= 18 ) config -> channel_mask = ( 1 << WaveHeader . NumChannels ) - 1 ; else config -> channel_mask = 0x3ffff ; } } else if ( WaveHeader . ChannelMask && ( config -> channel_mask || ( config -> qmode & QMODE_CHANS_UNASSIGNED ) ) ) { error_line ( ""thisW64filealreadyhaschannelorderinformation!"" ) ; return WAVPACK_SOFT_ERROR ; } else if ( WaveHeader . ChannelMask ) config -> channel_mask = WaveHeader . ChannelMask ; if ( format == 3 ) config -> float_norm_exp = 127 ; else if ( ( config -> qmode & QMODE_ADOBE_MODE ) && WaveHeader . BlockAlign / WaveHeader . NumChannels == 4 ) { if ( WaveHeader . BitsPerSample == 24 ) config -> float_norm_exp = 127 + 23 ; else if ( WaveHeader . BitsPerSample == 32 ) config -> float_norm_exp = 127 + 15 ; } if ( debug_logging_mode ) { if ( config -> float_norm_exp == 127 ) error_line ( ""dataformat:normalized32-bitfloatingpoint"" ) ; else error_line ( ""dataformat:%d-bitintegersstoredin%dbyte(s)"" , config -> bits_per_sample , WaveHeader . BlockAlign / WaveHeader . NumChannels ) ; } } else if ( ! memcmp ( chunk_header . ckID , data_guid , sizeof ( data_guid ) ) ) { if ( ! WaveHeader . NumChannels ) { error_line ( ""%sisnotavalid.W64file!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } if ( ( config -> qmode & QMODE_IGNORE_LENGTH ) || chunk_header . ckSize <= 0 ) { config -> qmode |= QMODE_IGNORE_LENGTH ; if ( infilesize && DoGetFilePosition ( infile ) != - 1 ) total_samples = ( infilesize - DoGetFilePosition ( infile ) ) / WaveHeader . BlockAlign ; else total_samples = - 1 ; } else { if ( infilesize && infilesize - chunk_header . ckSize > 16777216 ) { error_line ( ""this.W64filehasover16MBofextraRIFFdata,probablyiscorrupt!"" ) ; return WAVPACK_SOFT_ERROR ; } total_samples = chunk_header . ckSize / WaveHeader . BlockAlign ; if ( ! total_samples ) { error_line ( ""this.W64filehasnoaudiosamples,probablyiscorrupt!"" ) ; return WAVPACK_SOFT_ERROR ; } if ( total_samples > MAX_WAVPACK_SAMPLES ) { error_line ( ""%shastoomanysamplesforWavPack!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } } config -> bytes_per_sample = WaveHeader . BlockAlign / WaveHeader . NumChannels ; config -> num_channels = WaveHeader . NumChannels ; config -> sample_rate = WaveHeader . SampleRate ; break ; } else { int bytes_to_copy = ( chunk_header . ckSize + 7 ) & ~ 7L ; char * buff ; if ( bytes_to_copy < 0 || bytes_to_copy > 4194304 ) { error_line ( ""%sisnotavalid.W64file!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } buff = malloc ( bytes_to_copy ) ; if ( debug_logging_mode ) error_line ( ""extraunknownchunk\\""%c%c%c%c\\""of%dbytes"" , chunk_header . ckID [ 0 ] , chunk_header . ckID [ 1 ] , chunk_header . ckID [ 2 ] , chunk_header . ckID [ 3 ] , chunk_header . ckSize ) ; if ( ! DoReadFile ( infile , buff , bytes_to_copy , & bcount ) || bcount != bytes_to_copy || ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , buff , bytes_to_copy ) ) ) { error_line ( ""%s"" , WavpackGetErrorMessage ( wpc ) ) ; free ( buff ) ; return WAVPACK_SOFT_ERROR ; } free ( buff ) ; } } if ( ! WavpackSetConfiguration64 ( wpc , config , total_samples , NULL ) ) { error_line ( ""%s:%s"" , infilename , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } return WAVPACK_NO_ERROR ; } "," WaveHeader WaveHeader ; int format_chunk = 0 ; , format ; if ( format_chunk ++ ) { error_line ( ""%sisnotavalid.W64file!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } ",dbry@WavPack/26cb47f99d481ad9b93eeff80d26e6b63bbd7e15,CVE-2018-10537,https://github.com/dbry/WavPack/commit/26cb47f99d481ad9b93eeff80d26e6b63bbd7e15,2018-04-29T15:29Z 881,CWE-824,"CWE-824 int ParseDsdiffHeaderConfig ( FILE * infile , char * infilename , char * fourcc , WavpackContext * wpc , WavpackConfig * config ) { int64_t infilesize , total_samples ; DFFFileHeader dff_file_header ; DFFChunkHeader dff_chunk_header ; uint32_t bcount ; infilesize = DoGetFileSize ( infile ) ; memcpy ( & dff_file_header , fourcc , 4 ) ; if ( ( ! DoReadFile ( infile , ( ( char * ) & dff_file_header ) + 4 , sizeof ( DFFFileHeader ) - 4 , & bcount ) || bcount != sizeof ( DFFFileHeader ) - 4 ) || strncmp ( dff_file_header . formType , ""DSD"" , 4 ) ) { error_line ( ""%sisnotavalid.DFFfile!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & dff_file_header , sizeof ( DFFFileHeader ) ) ) { error_line ( ""%s"" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } # if 1 WavpackBigEndianToNative ( & dff_file_header , DFFFileHeaderFormat ) ; if ( infilesize && ! ( config -> qmode & QMODE_IGNORE_LENGTH ) && dff_file_header . ckDataSize && dff_file_header . ckDataSize + 1 && dff_file_header . ckDataSize + 12 != infilesize ) { error_line ( ""%sisnotavalid.DFFfile(bytotalsize)!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } if ( debug_logging_mode ) error_line ( ""fileheaderindicatedlength=%lld"" , dff_file_header . ckDataSize ) ; # endif while ( 1 ) { if ( ! DoReadFile ( infile , & dff_chunk_header , sizeof ( DFFChunkHeader ) , & bcount ) || bcount != sizeof ( DFFChunkHeader ) ) { error_line ( ""%sisnotavalid.DFFfile!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & dff_chunk_header , sizeof ( DFFChunkHeader ) ) ) { error_line ( ""%s"" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } WavpackBigEndianToNative ( & dff_chunk_header , DFFChunkHeaderFormat ) ; if ( debug_logging_mode ) error_line ( ""chunkheaderindicatedlength=%lld"" , dff_chunk_header . ckDataSize ) ; if ( ! strncmp ( dff_chunk_header . ckID , ""FVER"" , 4 ) ) { uint32_t version ; if ( dff_chunk_header . ckDataSize != sizeof ( version ) || ! DoReadFile ( infile , & version , sizeof ( version ) , & bcount ) || bcount != sizeof ( version ) ) { error_line ( ""%sisnotavalid.DFFfile!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & version , sizeof ( version ) ) ) { error_line ( ""%s"" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } WavpackBigEndianToNative ( & version , ""L"" ) ; if ( debug_logging_mode ) error_line ( ""dsdifffileversion=0x%08x"" , version ) ; } else if ( ! strncmp ( dff_chunk_header . ckID , ""PROP"" , 4 ) ) { char * prop_chunk ; if ( dff_chunk_header . ckDataSize < 4 || dff_chunk_header . ckDataSize > 1024 ) { error_line ( ""%sisnotavalid.DFFfile!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } if ( debug_logging_mode ) error_line ( ""gotPROPchunkof%dbytestotal"" , ( int ) dff_chunk_header . ckDataSize ) ; prop_chunk = malloc ( ( size_t ) dff_chunk_header . ckDataSize ) ; if ( ! DoReadFile ( infile , prop_chunk , ( uint32_t ) dff_chunk_header . ckDataSize , & bcount ) || bcount != dff_chunk_header . ckDataSize ) { error_line ( ""%sisnotavalid.DFFfile!"" , infilename ) ; free ( prop_chunk ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , prop_chunk , ( uint32_t ) dff_chunk_header . ckDataSize ) ) { error_line ( ""%s"" , WavpackGetErrorMessage ( wpc ) ) ; free ( prop_chunk ) ; return WAVPACK_SOFT_ERROR ; } if ( ! strncmp ( prop_chunk , ""SND"" , 4 ) ) { char * cptr = prop_chunk + 4 , * eptr = prop_chunk + dff_chunk_header . ckDataSize ; uint16_t numChannels = 0 , chansSpecified , chanMask = 0 ; uint32_t sampleRate ; while ( eptr - cptr >= sizeof ( dff_chunk_header ) ) { memcpy ( & dff_chunk_header , cptr , sizeof ( dff_chunk_header ) ) ; cptr += sizeof ( dff_chunk_header ) ; WavpackBigEndianToNative ( & dff_chunk_header , DFFChunkHeaderFormat ) ; if ( dff_chunk_header . ckDataSize > 0 && dff_chunk_header . ckDataSize <= eptr - cptr ) { if ( ! strncmp ( dff_chunk_header . ckID , ""FS"" , 4 ) && dff_chunk_header . ckDataSize == 4 ) { memcpy ( & sampleRate , cptr , sizeof ( sampleRate ) ) ; WavpackBigEndianToNative ( & sampleRate , ""L"" ) ; cptr += dff_chunk_header . ckDataSize ; if ( debug_logging_mode ) error_line ( ""gotsamplerateof%uHz"" , sampleRate ) ; } else if ( ! strncmp ( dff_chunk_header . ckID , ""CHNL"" , 4 ) && dff_chunk_header . ckDataSize >= 2 ) { memcpy ( & numChannels , cptr , sizeof ( numChannels ) ) ; WavpackBigEndianToNative ( & numChannels , ""S"" ) ; cptr += sizeof ( numChannels ) ; chansSpecified = ( int ) ( dff_chunk_header . ckDataSize - sizeof ( numChannels ) ) / 4 ; if ( numChannels < chansSpecified || numChannels < 1 || numChannels > 256 ) { error_line ( ""%sisnotavalid.DFFfile!"" , infilename ) ; free ( prop_chunk ) ; return WAVPACK_SOFT_ERROR ; } while ( chansSpecified -- ) { if ( ! strncmp ( cptr , ""SLFT"" , 4 ) || ! strncmp ( cptr , ""MLFT"" , 4 ) ) chanMask |= 0x1 ; else if ( ! strncmp ( cptr , ""SRGT"" , 4 ) || ! strncmp ( cptr , ""MRGT"" , 4 ) ) chanMask |= 0x2 ; else if ( ! strncmp ( cptr , ""LS"" , 4 ) ) chanMask |= 0x10 ; else if ( ! strncmp ( cptr , ""RS"" , 4 ) ) chanMask |= 0x20 ; else if ( ! strncmp ( cptr , ""C"" , 4 ) ) chanMask |= 0x4 ; else if ( ! strncmp ( cptr , ""LFE"" , 4 ) ) chanMask |= 0x8 ; else if ( debug_logging_mode ) error_line ( ""undefinedchannelID%c%c%c%c"" , cptr [ 0 ] , cptr [ 1 ] , cptr [ 2 ] , cptr [ 3 ] ) ; cptr += 4 ; } if ( debug_logging_mode ) error_line ( ""%dchannels,mask=0x%08x"" , numChannels , chanMask ) ; } else if ( ! strncmp ( dff_chunk_header . ckID , ""CMPR"" , 4 ) && dff_chunk_header . ckDataSize >= 4 ) { if ( strncmp ( cptr , ""DSD"" , 4 ) ) { error_line ( ""DSDIFFfilesmustbeuncompressed,not\\""%c%c%c%c\\""!"" , cptr [ 0 ] , cptr [ 1 ] , cptr [ 2 ] , cptr [ 3 ] ) ; free ( prop_chunk ) ; return WAVPACK_SOFT_ERROR ; } cptr += dff_chunk_header . ckDataSize ; } else { if ( debug_logging_mode ) error_line ( ""gotPROP/SNDchunktype\\""%c%c%c%c\\""of%dbytes"" , dff_chunk_header . ckID [ 0 ] , dff_chunk_header . ckID [ 1 ] , dff_chunk_header . ckID [ 2 ] , dff_chunk_header . ckID [ 3 ] , dff_chunk_header . ckDataSize ) ; cptr += dff_chunk_header . ckDataSize ; } } else { error_line ( ""%sisnotavalid.DFFfile!"" , infilename ) ; free ( prop_chunk ) ; return WAVPACK_SOFT_ERROR ; } } if ( chanMask && ( config -> channel_mask || ( config -> qmode & QMODE_CHANS_UNASSIGNED ) ) ) { error_line ( ""thisDSDIFFfilealreadyhaschannelorderinformation!"" ) ; free ( prop_chunk ) ; return WAVPACK_SOFT_ERROR ; } else if ( chanMask ) config -> channel_mask = chanMask ; config -> bits_per_sample = 8 ; config -> bytes_per_sample = 1 ; config -> num_channels = numChannels ; config -> sample_rate = sampleRate / 8 ; config -> qmode |= QMODE_DSD_MSB_FIRST ; } else if ( debug_logging_mode ) error_line ( ""gotunknownPROPchunktype\\""%c%c%c%c\\""of%dbytes"" , prop_chunk [ 0 ] , prop_chunk [ 1 ] , prop_chunk [ 2 ] , prop_chunk [ 3 ] , dff_chunk_header . ckDataSize ) ; free ( prop_chunk ) ; } else if ( ! strncmp ( dff_chunk_header . ckID , ""DSD"" , 4 ) ) { if ( ! config -> num_channels ) { error_line ( ""%sisnotavalid.DFFfile!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } total_samples = dff_chunk_header . ckDataSize / config -> num_channels ; break ; } else { int bytes_to_copy = ( int ) ( ( ( dff_chunk_header . ckDataSize ) + 1 ) & ~ ( int64_t ) 1 ) ; char * buff ; if ( bytes_to_copy < 0 || bytes_to_copy > 4194304 ) { error_line ( ""%sisnotavalid.DFFfile!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } buff = malloc ( bytes_to_copy ) ; if ( debug_logging_mode ) error_line ( ""extraunknownchunk\\""%c%c%c%c\\""of%dbytes"" , dff_chunk_header . ckID [ 0 ] , dff_chunk_header . ckID [ 1 ] , dff_chunk_header . ckID [ 2 ] , dff_chunk_header . ckID [ 3 ] , dff_chunk_header . ckDataSize ) ; if ( ! DoReadFile ( infile , buff , bytes_to_copy , & bcount ) || bcount != bytes_to_copy || ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , buff , bytes_to_copy ) ) ) { error_line ( ""%s"" , WavpackGetErrorMessage ( wpc ) ) ; free ( buff ) ; return WAVPACK_SOFT_ERROR ; } free ( buff ) ; } } if ( debug_logging_mode ) error_line ( ""settingconfigurationwith%lldsamples"" , total_samples ) ; if ( ! WavpackSetConfiguration64 ( wpc , config , total_samples , NULL ) ) { error_line ( ""%s:%s"" , infilename , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } return WAVPACK_NO_ERROR ; } "," ; uint32_t sampleRate = 0 config -> num_channels || ! config -> sample_rate ",dbry@WavPack/bc6cba3f552c44565f7f1e66dc1580189addb2b4,CVE-2019-11498,https://github.com/dbry/WavPack/commit/bc6cba3f552c44565f7f1e66dc1580189addb2b4,2019-04-24T05:29Z 882,CWE-125,"CWE-125 void vtp_print ( netdissect_options * ndo , const u_char * pptr , u_int length ) { int type , len , tlv_len , tlv_value , mgmtd_len ; const u_char * tptr ; const struct vtp_vlan_ * vtp_vlan ; if ( length < VTP_HEADER_LEN ) goto trunc ; tptr = pptr ; ND_TCHECK2 ( * tptr , VTP_HEADER_LEN ) ; type = * ( tptr + 1 ) ; ND_PRINT ( ( ndo , ""VTPv%u,Message%s(0x%02x),length%u"" , * tptr , tok2str ( vtp_message_type_values , ""Unknownmessagetype"" , type ) , type , length ) ) ; if ( ndo -> ndo_vflag < 1 ) { return ; } ND_PRINT ( ( ndo , ""\\n\\tDomainname:"" ) ) ; mgmtd_len = * ( tptr + 3 ) ; if ( mgmtd_len < 1 || mgmtd_len > 32 ) { ND_PRINT ( ( ndo , ""[invalidMgmtDLen%d]"" , mgmtd_len ) ) ; return ; } fn_printzp ( ndo , tptr + 4 , mgmtd_len , NULL ) ; ND_PRINT ( ( ndo , "",%s:%u"" , tok2str ( vtp_header_values , ""Unknown"" , type ) , * ( tptr + 2 ) ) ) ; tptr += VTP_HEADER_LEN ; switch ( type ) { case VTP_SUMMARY_ADV : ND_TCHECK2 ( * tptr , 8 ) ; ND_PRINT ( ( ndo , ""\\n\\tConfigRev%x,Updater%s"" , EXTRACT_32BITS ( tptr ) , ipaddr_string ( ndo , tptr + 4 ) ) ) ; tptr += 8 ; ND_TCHECK2 ( * tptr , VTP_UPDATE_TIMESTAMP_LEN ) ; ND_PRINT ( ( ndo , "",Timestamp0x%08x0x%08x0x%08x"" , EXTRACT_32BITS ( tptr ) , EXTRACT_32BITS ( tptr + 4 ) , EXTRACT_32BITS ( tptr + 8 ) ) ) ; tptr += VTP_UPDATE_TIMESTAMP_LEN ; ND_TCHECK2 ( * tptr , VTP_MD5_DIGEST_LEN ) ; ND_PRINT ( ( ndo , "",MD5digest:%08x%08x%08x%08x"" , EXTRACT_32BITS ( tptr ) , EXTRACT_32BITS ( tptr + 4 ) , EXTRACT_32BITS ( tptr + 8 ) , EXTRACT_32BITS ( tptr + 12 ) ) ) ; tptr += VTP_MD5_DIGEST_LEN ; break ; case VTP_SUBSET_ADV : ND_TCHECK_32BITS ( tptr ) ; ND_PRINT ( ( ndo , "",ConfigRev%x"" , EXTRACT_32BITS ( tptr ) ) ) ; tptr += 4 ; while ( tptr < ( pptr + length ) ) { ND_TCHECK_8BITS ( tptr ) ; len = * tptr ; if ( len == 0 ) break ; ND_TCHECK2 ( * tptr , len ) ; vtp_vlan = ( const struct vtp_vlan_ * ) tptr ; ND_TCHECK ( * vtp_vlan ) ; ND_PRINT ( ( ndo , ""\\n\\tVLANinfostatus%s,type%s,VLAN-id%u,MTU%u,SAID0x%08x,Name"" , tok2str ( vtp_vlan_status , ""Unknown"" , vtp_vlan -> status ) , tok2str ( vtp_vlan_type_values , ""Unknown"" , vtp_vlan -> type ) , EXTRACT_16BITS ( & vtp_vlan -> vlanid ) , EXTRACT_16BITS ( & vtp_vlan -> mtu ) , EXTRACT_32BITS ( & vtp_vlan -> index ) ) ) ; fn_printzp ( ndo , tptr + VTP_VLAN_INFO_OFFSET , vtp_vlan -> name_len , NULL ) ; len -= VTP_VLAN_INFO_OFFSET + 4 * ( ( vtp_vlan -> name_len + 3 ) / 4 ) ; tptr += VTP_VLAN_INFO_OFFSET + 4 * ( ( vtp_vlan -> name_len + 3 ) / 4 ) ; while ( len > 0 ) { type = * tptr ; tlv_len = * ( tptr + 1 ) ; ND_PRINT ( ( ndo , ""\\n\\t\\t%s(0x%04x)TLV"" , tok2str ( vtp_vlan_tlv_values , ""Unknown"" , type ) , type ) ) ; if ( type == 0 || tlv_len == 0 ) { return ; } ND_TCHECK2 ( * tptr , tlv_len * 2 + 2 ) ; tlv_value = EXTRACT_16BITS ( tptr + 2 ) ; switch ( type ) { case VTP_VLAN_STE_HOP_COUNT : ND_PRINT ( ( ndo , "",%u"" , tlv_value ) ) ; break ; case VTP_VLAN_PRUNING : ND_PRINT ( ( ndo , "",%s(%u)"" , tlv_value == 1 ? ""Enabled"" : ""Disabled"" , tlv_value ) ) ; break ; case VTP_VLAN_STP_TYPE : ND_PRINT ( ( ndo , "",%s(%u)"" , tok2str ( vtp_stp_type_values , ""Unknown"" , tlv_value ) , tlv_value ) ) ; break ; case VTP_VLAN_BRIDGE_TYPE : ND_PRINT ( ( ndo , "",%s(%u)"" , tlv_value == 1 ? ""SRB"" : ""SRT"" , tlv_value ) ) ; break ; case VTP_VLAN_BACKUP_CRF_MODE : ND_PRINT ( ( ndo , "",%s(%u)"" , tlv_value == 1 ? ""Backup"" : ""Notbackup"" , tlv_value ) ) ; break ; case VTP_VLAN_SOURCE_ROUTING_RING_NUMBER : case VTP_VLAN_SOURCE_ROUTING_BRIDGE_NUMBER : case VTP_VLAN_PARENT_VLAN : case VTP_VLAN_TRANS_BRIDGED_VLAN : case VTP_VLAN_ARP_HOP_COUNT : default : print_unknown_data ( ndo , tptr , ""\\n\\t\\t"" , 2 + tlv_len * 2 ) ; break ; } len -= 2 + tlv_len * 2 ; tptr += 2 + tlv_len * 2 ; } } break ; case VTP_ADV_REQUEST : ND_TCHECK2 ( * tptr , 4 ) ; ND_PRINT ( ( ndo , ""\\n\\tStartvalue:%u"" , EXTRACT_32BITS ( tptr ) ) ) ; break ; case VTP_JOIN_MESSAGE : break ; default : break ; } return ; trunc : ND_PRINT ( ( ndo , ""[|vtp]"" ) ) ; } "," ) tptr ; if ( len < VTP_VLAN_INFO_FIXED_PART_LEN ) goto trunc ; ) ) ; len -= VTP_VLAN_INFO_FIXED_PART_LEN ; tptr += VTP_VLAN_INFO_FIXED_PART_LEN ; if ( len < 4 * ( ( vtp_vlan -> name_len vtp_vlan -> name_len + 3 ) / 4 ) ) goto trunc ; ND_TCHECK2 ( * tptr , vtp_vlan -> name_len vtp_vlan -> name_len ) ; fn_printzp ( ndo , tptr , vtp_vlan -> name_len vtp_vlan -> name_len , NULL ) ; len -= 4 * ( ( vtp_vlan -> name_len + 3 ) / 4 ) ; tptr += 4 * ( ( vtp_vlan -> name_len 0 ) { if ( len < 2 ) goto trunc ; ND_TCHECK2 ( * tptr , 2 ) ; ; if ( len < tlv_len * 2 + 2 ) { ND_PRINT ( ( ndo , ""(TLVgoespasttheendofthepacket)"" ) ) ; return ; } 2 ) ; if ( tlv_len != 1 ) { ND_PRINT ( ( ndo , ""(invalidTLVlength%u!=1)"" , tlv_len ) ) ; return ; } else { break ; } } ",the-tcpdump-group@tcpdump/ae83295915d08a854de27a88efac5dd7353e6d3f,CVE-2017-13033,https://github.com/the-tcpdump-group/tcpdump/commit/ae83295915d08a854de27a88efac5dd7353e6d3f,2017-09-14T06:29Z 883,CWE-20,"CWE-20 static int _snd_timer_stop ( struct snd_timer_instance * timeri , int keep_flag , int event ) { struct snd_timer * timer ; unsigned long flags ; if ( snd_BUG_ON ( ! timeri ) ) return - ENXIO ; if ( timeri -> flags & SNDRV_TIMER_IFLG_SLAVE ) { if ( ! keep_flag ) { spin_lock_irqsave ( & slave_active_lock , flags ) ; timeri -> flags &= ~ SNDRV_TIMER_IFLG_RUNNING ; spin_unlock_irqrestore ( & slave_active_lock , flags ) ; } goto __end ; } timer = timeri -> timer ; if ( ! timer ) return - EINVAL ; spin_lock_irqsave ( & timer -> lock , flags ) ; list_del_init ( & timeri -> ack_list ) ; list_del_init ( & timeri -> active_list ) ; if ( ( timeri -> flags & SNDRV_TIMER_IFLG_RUNNING ) && ! ( -- timer -> running ) ) { timer -> hw . stop ( timer ) ; if ( timer -> flags & SNDRV_TIMER_FLG_RESCHED ) { timer -> flags &= ~ SNDRV_TIMER_FLG_RESCHED ; snd_timer_reschedule ( timer , 0 ) ; if ( timer -> flags & SNDRV_TIMER_FLG_CHANGE ) { timer -> flags &= ~ SNDRV_TIMER_FLG_CHANGE ; timer -> hw . start ( timer ) ; } } } if ( ! keep_flag ) timeri -> flags &= ~ ( SNDRV_TIMER_IFLG_RUNNING | SNDRV_TIMER_IFLG_START ) ; spin_unlock_irqrestore ( & timer -> lock , flags ) ; __end : if ( event != SNDRV_TIMER_EVENT_RESOLUTION ) snd_timer_notify1 ( timeri , event ) ; return 0 ; } "," ~ SNDRV_TIMER_IFLG_RUNNING ; list_del_init ( & timeri -> ack_list ) ; list_del_init ( & timeri -> active_list ) ; ",torvalds@linux/b5a663aa426f4884c71cd8580adae73f33570f0d,CVE-2016-2548,https://github.com/torvalds/linux/commit/b5a663aa426f4884c71cd8580adae73f33570f0d,2016-04-27T17:59Z 884,CWE-20,"CWE-20 void sink ( int argc , char * * argv , const char * src ) { static BUF buffer ; struct stat stb ; enum { YES , NO , DISPLAYED } wrerr ; BUF * bp ; off_t i ; size_t j , count ; int amt , exists , first , ofd ; mode_t mode , omode , mask ; off_t size , statbytes ; unsigned long long ull ; int setimes , targisdir , wrerrno = 0 ; char ch , * cp , * np , * targ , * why , * vect [ 1 ] , buf [ 2048 ] , visbuf [ 2048 ] ; char * * patterns = NULL ; size_t n , npatterns = 0 ; struct timeval tv [ 2 ] ; # define atime tv [ 0 ] # define mtime tv [ 1 ] # define SCREWUP ( str ) { why = str ; goto screwup ; } if ( TYPE_OVERFLOW ( time_t , 0 ) || TYPE_OVERFLOW ( off_t , 0 ) ) SCREWUP ( ""Unexpectedoff_t/time_tsize"" ) ; setimes = targisdir = 0 ; mask = umask ( 0 ) ; if ( ! pflag ) ( void ) umask ( mask ) ; if ( argc != 1 ) { run_err ( ""ambiguoustarget"" ) ; exit ( 1 ) ; } targ = * argv ; if ( targetshouldbedirectory ) verifydir ( targ ) ; ( void ) atomicio ( vwrite , remout , """" , 1 ) ; if ( stat ( targ , & stb ) == 0 && S_ISDIR ( stb . st_mode ) ) targisdir = 1 ; if ( src != NULL && ! iamrecursive && ! Tflag ) { if ( brace_expand ( src , & patterns , & npatterns ) != 0 ) fatal ( ""%s:couldnotexpandpattern"" , __func__ ) ; } for ( first = 1 ; ; first = 0 ) { cp = buf ; if ( atomicio ( read , remin , cp , 1 ) != 1 ) goto done ; if ( * cp ++ == '\\n' ) SCREWUP ( ""unexpected"" ) ; do { if ( atomicio ( read , remin , & ch , sizeof ( ch ) ) != sizeof ( ch ) ) SCREWUP ( ""lostconnection"" ) ; * cp ++ = ch ; } while ( cp < & buf [ sizeof ( buf ) - 1 ] && ch != '\\n' ) ; * cp = 0 ; if ( verbose_mode ) fmprintf ( stderr , ""Sink:%s"" , buf ) ; if ( buf [ 0 ] == '\\01' || buf [ 0 ] == '\\02' ) { if ( iamremote == 0 ) { ( void ) snmprintf ( visbuf , sizeof ( visbuf ) , NULL , ""%s"" , buf + 1 ) ; ( void ) atomicio ( vwrite , STDERR_FILENO , visbuf , strlen ( visbuf ) ) ; } if ( buf [ 0 ] == '\\02' ) exit ( 1 ) ; ++ errs ; continue ; } if ( buf [ 0 ] == 'E' ) { ( void ) atomicio ( vwrite , remout , """" , 1 ) ; goto done ; } if ( ch == '\\n' ) * -- cp = 0 ; cp = buf ; if ( * cp == 'T' ) { setimes ++ ; cp ++ ; if ( ! isdigit ( ( unsigned char ) * cp ) ) SCREWUP ( ""mtime.secnotpresent"" ) ; ull = strtoull ( cp , & cp , 10 ) ; if ( ! cp || * cp ++ != '' ) SCREWUP ( ""mtime.secnotdelimited"" ) ; if ( TYPE_OVERFLOW ( time_t , ull ) ) setimes = 0 ; mtime . tv_sec = ull ; mtime . tv_usec = strtol ( cp , & cp , 10 ) ; if ( ! cp || * cp ++ != '' || mtime . tv_usec < 0 || mtime . tv_usec > 999999 ) SCREWUP ( ""mtime.usecnotdelimited"" ) ; if ( ! isdigit ( ( unsigned char ) * cp ) ) SCREWUP ( ""atime.secnotpresent"" ) ; ull = strtoull ( cp , & cp , 10 ) ; if ( ! cp || * cp ++ != '' ) SCREWUP ( ""atime.secnotdelimited"" ) ; if ( TYPE_OVERFLOW ( time_t , ull ) ) setimes = 0 ; atime . tv_sec = ull ; atime . tv_usec = strtol ( cp , & cp , 10 ) ; if ( ! cp || * cp ++ != '\\0' || atime . tv_usec < 0 || atime . tv_usec > 999999 ) SCREWUP ( ""atime.usecnotdelimited"" ) ; ( void ) atomicio ( vwrite , remout , """" , 1 ) ; continue ; } if ( * cp != 'C' && * cp != 'D' ) { if ( first ) { run_err ( ""%s"" , cp ) ; exit ( 1 ) ; } SCREWUP ( ""expectedcontrolrecord"" ) ; } mode = 0 ; for ( ++ cp ; cp < buf + 5 ; cp ++ ) { if ( * cp < '0' || * cp > '7' ) SCREWUP ( ""badmode"" ) ; mode = ( mode << 3 ) | ( * cp - '0' ) ; } if ( ! pflag ) mode &= ~ mask ; if ( * cp ++ != '' ) SCREWUP ( ""modenotdelimited"" ) ; if ( ! isdigit ( ( unsigned char ) * cp ) ) SCREWUP ( ""sizenotpresent"" ) ; ull = strtoull ( cp , & cp , 10 ) ; if ( ! cp || * cp ++ != '' ) SCREWUP ( ""sizenotdelimited"" ) ; if ( TYPE_OVERFLOW ( off_t , ull ) ) SCREWUP ( ""sizeoutofrange"" ) ; size = ( off_t ) ull ; if ( * cp == '\\0' || strchr ( cp , '/' ) != NULL || strcmp ( cp , ""."" ) == 0 || strcmp ( cp , "".."" ) == 0 ) { run_err ( ""error:unexpectedfilename:%s"" , cp ) ; exit ( 1 ) ; } if ( npatterns > 0 ) { for ( n = 0 ; n < npatterns ; n ++ ) { if ( fnmatch ( patterns [ n ] , cp , 0 ) == 0 ) break ; } if ( n >= npatterns ) SCREWUP ( ""filenamedoesnotmatchrequest"" ) ; } if ( targisdir ) { static char * namebuf ; static size_t cursize ; size_t need ; need = strlen ( targ ) + strlen ( cp ) + 250 ; if ( need > cursize ) { free ( namebuf ) ; namebuf = xmalloc ( need ) ; cursize = need ; } ( void ) snprintf ( namebuf , need , ""%s%s%s"" , targ , strcmp ( targ , ""/"" ) ? ""/"" : """" , cp ) ; np = namebuf ; } else np = targ ; curfile = cp ; exists = stat ( np , & stb ) == 0 ; if ( buf [ 0 ] == 'D' ) { int mod_flag = pflag ; if ( ! iamrecursive ) SCREWUP ( ""receiveddirectorywithout-r"" ) ; if ( exists ) { if ( ! S_ISDIR ( stb . st_mode ) ) { errno = ENOTDIR ; goto bad ; } if ( pflag ) ( void ) chmod ( np , mode ) ; } else { mod_flag = 1 ; if ( mkdir ( np , mode | S_IRWXU ) == - 1 ) goto bad ; } vect [ 0 ] = xstrdup ( np ) ; sink ( 1 , vect , src ) ; if ( setimes ) { setimes = 0 ; if ( utimes ( vect [ 0 ] , tv ) == - 1 ) run_err ( ""%s:settimes:%s"" , vect [ 0 ] , strerror ( errno ) ) ; } if ( mod_flag ) ( void ) chmod ( vect [ 0 ] , mode ) ; free ( vect [ 0 ] ) ; continue ; } omode = mode ; mode |= S_IWUSR ; if ( ( ofd = open ( np , O_WRONLY | O_CREAT , mode ) ) == - 1 ) { bad : run_err ( ""%s:%s"" , np , strerror ( errno ) ) ; continue ; } ( void ) atomicio ( vwrite , remout , """" , 1 ) ; if ( ( bp = allocbuf ( & buffer , ofd , COPY_BUFLEN ) ) == NULL ) { ( void ) close ( ofd ) ; continue ; } cp = bp -> buf ; wrerr = NO ; statbytes = 0 ; if ( showprogress ) start_progress_meter ( curfile , size , & statbytes ) ; set_nonblock ( remin ) ; for ( count = i = 0 ; i < size ; i += bp -> cnt ) { amt = bp -> cnt ; if ( i + amt > size ) amt = size - i ; count += amt ; do { j = atomicio6 ( read , remin , cp , amt , scpio , & statbytes ) ; if ( j == 0 ) { run_err ( ""%s"" , j != EPIPE ? strerror ( errno ) : ""droppedconnection"" ) ; exit ( 1 ) ; } amt -= j ; cp += j ; } while ( amt > 0 ) ; if ( count == bp -> cnt ) { if ( wrerr == NO ) { if ( atomicio ( vwrite , ofd , bp -> buf , count ) != count ) { wrerr = YES ; wrerrno = errno ; } } count = 0 ; cp = bp -> buf ; } } unset_nonblock ( remin ) ; if ( count != 0 && wrerr == NO && atomicio ( vwrite , ofd , bp -> buf , count ) != count ) { wrerr = YES ; wrerrno = errno ; } if ( wrerr == NO && ( ! exists || S_ISREG ( stb . st_mode ) ) && ftruncate ( ofd , size ) != 0 ) { run_err ( ""%s:truncate:%s"" , np , strerror ( errno ) ) ; wrerr = DISPLAYED ; } if ( pflag ) { if ( exists || omode != mode ) # ifdef HAVE_FCHMOD if ( fchmod ( ofd , omode ) ) { # else if ( chmod ( np , omode ) ) { # endif run_err ( ""%s:setmode:%s"" , np , strerror ( errno ) ) ; wrerr = DISPLAYED ; } } else { if ( ! exists && omode != mode ) # ifdef HAVE_FCHMOD if ( fchmod ( ofd , omode & ~ mask ) ) { # else if ( chmod ( np , omode & ~ mask ) ) { # endif run_err ( ""%s:setmode:%s"" , np , strerror ( errno ) ) ; wrerr = DISPLAYED ; } } if ( close ( ofd ) == - 1 ) { wrerr = YES ; wrerrno = errno ; } ( void ) response ( ) ; if ( showprogress ) stop_progress_meter ( ) ; if ( setimes && wrerr == NO ) { setimes = 0 ; if ( utimes ( np , tv ) == - 1 ) { run_err ( ""%s:settimes:%s"" , np , strerror ( errno ) ) ; wrerr = DISPLAYED ; } } switch ( wrerr ) { case YES : run_err ( ""%s:%s"" , np , strerror ( wrerrno ) ) ; break ; case NO : ( void ) atomicio ( vwrite , remout , """" , 1 ) ; break ; case DISPLAYED : break ; } } done : for ( n = 0 ; n < npatterns ; n ++ ) free ( patterns [ n ] ) ; free ( patterns ) ; return ; screwup : for ( n = 0 ; n < npatterns ; n ++ ) free ( patterns [ n ] ) ; free ( patterns ) ; run_err ( ""protocolerror:%s"" , why ) ; exit ( 1 ) ; } "," struct stat stb ; BUF * , targisdir , wrerr ; char ch ; wrerr = 0 ; statbytes = { if ( ! wrerr ) { if count ) { note_err ( ""%s:%s"" , np , strerror ( errno ) ) ; wrerr = 1 ; } } != 0 && ! wrerr && atomicio ( count ) { note_err ( ""%s:%s"" , np , strerror ( errno ) ) ; wrerr = 1 ; } if ( ! wrerr && ( ! != 0 ) note_err ( ""%s:truncate:%s"" , ) ) ; if ( pflag { # endif note_err ( ""%s:setmode:%s"" , errno ) ) ; } } { # endif note_err ( ""%s:setmode:%s"" , errno ) ) ; } } - 1 ) note_err ( np , ""%s:close:%s"" , np , strerror ( errno ) ) ; ( void ) ( setimes && ! wrerr ) { setimes 1 ) { note_err ( ""%s:settimes:%s"" , ) ) ; } } if ( note_err ( NULL ) == 0 ) ( void ) 1 ) ; } done : ",openssh@openssh-portable/aad87b88fc2536b1ea023213729aaf4eaabe1894,CVE-2020-12062,https://github.com/openssh/openssh-portable/commit/aad87b88fc2536b1ea023213729aaf4eaabe1894,2020-06-01T16:15Z 885,CWE-284,"CWE-284 static void cs_cmd_flags ( sourceinfo_t * si , int parc , char * parv [ ] ) { chanacs_t * ca ; mowgli_node_t * n ; char * channel = parv [ 0 ] ; char * target = sstrdup ( parv [ 1 ] ) ; char * flagstr = parv [ 2 ] ; const char * str1 ; unsigned int addflags , removeflags , restrictflags ; hook_channel_acl_req_t req ; mychan_t * mc ; if ( parc < 1 ) { command_fail ( si , fault_needmoreparams , STR_INSUFFICIENT_PARAMS , ""FLAGS"" ) ; command_fail ( si , fault_needmoreparams , _ ( ""Syntax:FLAGS[target][flags]"" ) ) ; return ; } mc = mychan_find ( channel ) ; if ( ! mc ) { command_fail ( si , fault_nosuch_target , _ ( ""Channel\\2%s\\2isnotregistered."" ) , channel ) ; return ; } if ( metadata_find ( mc , ""private:close:closer"" ) && ( target || ! has_priv ( si , PRIV_CHAN_AUSPEX ) ) ) { command_fail ( si , fault_noprivs , _ ( ""\\2%s\\2isclosed."" ) , channel ) ; return ; } if ( ! target || ( target && target [ 0 ] == '+' && flagstr == NULL ) ) { unsigned int flags = ( target != NULL ) ? flags_to_bitmask ( target , 0 ) : 0 ; do_list ( si , mc , flags ) ; return ; } else if ( ! strcasecmp ( target , ""LIST"" ) && myentity_find_ext ( target ) == NULL ) { do_list ( si , mc , 0 ) ; free ( target ) ; return ; } else if ( ! strcasecmp ( target , ""CLEAR"" ) && myentity_find_ext ( target ) == NULL ) { free ( target ) ; if ( ! chanacs_source_has_flag ( mc , si , CA_FOUNDER ) ) { command_fail ( si , fault_noprivs , ""Youarenotauthorizedtoperformthisoperation."" ) ; return ; } mowgli_node_t * tn ; MOWGLI_ITER_FOREACH_SAFE ( n , tn , mc -> chanacs . head ) { ca = n -> data ; if ( ca -> level & CA_FOUNDER ) continue ; object_unref ( ca ) ; } logcommand ( si , CMDLOG_DO , ""CLEAR:FLAGS:\\2%s\\2"" , mc -> name ) ; command_success_nodata ( si , _ ( ""Clearedflagsin\\2%s\\2."" ) , mc -> name ) ; return ; } else if ( ! strcasecmp ( target , ""MODIFY"" ) && myentity_find_ext ( target ) == NULL ) { free ( target ) ; if ( parc < 3 ) { command_fail ( si , fault_needmoreparams , STR_INSUFFICIENT_PARAMS , ""FLAGS"" ) ; command_fail ( si , fault_needmoreparams , _ ( ""Syntax:FLAGS<#channel>MODIFY[target]"" ) ) ; return ; } flagstr = strchr ( parv [ 2 ] , '' ) ; if ( flagstr ) * flagstr ++ = '\\0' ; target = strdup ( parv [ 2 ] ) ; } { myentity_t * mt ; if ( ! si -> smu ) { command_fail ( si , fault_noprivs , _ ( ""Youarenotloggedin."" ) ) ; return ; } if ( ! flagstr ) { if ( ! ( mc -> flags & MC_PUBACL ) && ! chanacs_source_has_flag ( mc , si , CA_ACLVIEW ) ) { command_fail ( si , fault_noprivs , _ ( ""Youarenotauthorizedtoexecutethiscommand."" ) ) ; return ; } if ( validhostmask ( target ) ) ca = chanacs_find_host_literal ( mc , target , 0 ) ; else { if ( ! ( mt = myentity_find_ext ( target ) ) ) { command_fail ( si , fault_nosuch_target , _ ( ""\\2%s\\2isnotregistered."" ) , target ) ; return ; } free ( target ) ; target = sstrdup ( mt -> name ) ; ca = chanacs_find_literal ( mc , mt , 0 ) ; } if ( ca != NULL ) { str1 = bitmask_to_flags2 ( ca -> level , 0 ) ; command_success_string ( si , str1 , _ ( ""Flagsfor\\2%s\\2in\\2%s\\2are\\2%s\\2."" ) , target , channel , str1 ) ; } else command_success_string ( si , """" , _ ( ""Noflagsfor\\2%s\\2in\\2%s\\2."" ) , target , channel ) ; logcommand ( si , CMDLOG_GET , ""FLAGS:\\2%s\\2on\\2%s\\2"" , mc -> name , target ) ; return ; } restrictflags = chanacs_source_flags ( mc , si ) ; if ( restrictflags & CA_FOUNDER ) restrictflags = ca_all ; else { if ( ! ( restrictflags & CA_FLAGS ) ) { if ( restrictflags & CA_AKICK || si -> smu == NULL || irccasecmp ( target , entity ( si -> smu ) -> name ) || strcmp ( flagstr , ""-*"" ) ) { command_fail ( si , fault_noprivs , _ ( ""Youarenotauthorizedtoexecutethiscommand."" ) ) ; return ; } } if ( irccasecmp ( target , entity ( si -> smu ) -> name ) ) restrictflags = allow_flags ( mc , restrictflags ) ; else restrictflags |= allow_flags ( mc , restrictflags ) ; } if ( * flagstr == '+' || * flagstr == '-' || * flagstr == '=' ) { flags_make_bitmasks ( flagstr , & addflags , & removeflags ) ; if ( addflags == 0 && removeflags == 0 ) { command_fail ( si , fault_badparams , _ ( ""Novalidflagsgiven,use/%s%sHELPFLAGSforalist"" ) , ircd -> uses_rcommand ? """" : ""msg"" , chansvs . me -> disp ) ; return ; } } else { addflags = get_template_flags ( mc , flagstr ) ; if ( addflags == 0 ) { if ( * target == '+' || * target == '-' || * target == '=' ) command_fail ( si , fault_badparams , _ ( ""Usage:FLAGS%s[target][flags]"" ) , mc -> name ) ; else command_fail ( si , fault_badparams , _ ( ""Invalidtemplatenamegiven,use/%s%sTEMPLATE%sforalist"" ) , ircd -> uses_rcommand ? """" : ""msg"" , chansvs . me -> disp , mc -> name ) ; return ; } removeflags = ca_all & ~ addflags ; } if ( ! validhostmask ( target ) ) { if ( ! ( mt = myentity_find_ext ( target ) ) ) { command_fail ( si , fault_nosuch_target , _ ( ""\\2%s\\2isnotregistered."" ) , target ) ; return ; } free ( target ) ; target = sstrdup ( mt -> name ) ; ca = chanacs_open ( mc , mt , NULL , true , entity ( si -> smu ) ) ; if ( ca -> level & CA_FOUNDER && removeflags & CA_FLAGS && ! ( removeflags & CA_FOUNDER ) ) { command_fail ( si , fault_noprivs , _ ( ""Youmaynotremoveafounder\'s+faccess."" ) ) ; return ; } if ( ca -> level & CA_FOUNDER && removeflags & CA_FOUNDER && mychan_num_founders ( mc ) == 1 ) { command_fail ( si , fault_noprivs , _ ( ""Youmaynotremovethelastfounder."" ) ) ; return ; } if ( ! ( ca -> level & CA_FOUNDER ) && addflags & CA_FOUNDER ) { if ( mychan_num_founders ( mc ) >= chansvs . maxfounders ) { command_fail ( si , fault_noprivs , _ ( ""Only%dfoundersallowedperchannel."" ) , chansvs . maxfounders ) ; chanacs_close ( ca ) ; return ; } if ( ! myentity_can_register_channel ( mt ) ) { command_fail ( si , fault_toomany , _ ( ""\\2%s\\2hastoomanychannelsregistered."" ) , mt -> name ) ; chanacs_close ( ca ) ; return ; } if ( ! myentity_allow_foundership ( mt ) ) { command_fail ( si , fault_toomany , _ ( ""\\2%s\\2cannottakefoundershipofachannel."" ) , mt -> name ) ; chanacs_close ( ca ) ; return ; } } if ( addflags & CA_FOUNDER ) addflags |= CA_FLAGS , removeflags &= ~ CA_FLAGS ; if ( isuser ( mt ) && ( MU_NEVEROP & user ( mt ) -> flags && addflags != CA_AKICK && addflags != 0 && ( ca -> level == 0 || ca -> level == CA_AKICK ) ) ) { command_fail ( si , fault_noprivs , _ ( ""\\2%s\\2doesnotwishtobeaddedtochannelaccesslists(NEVEROPset)."" ) , mt -> name ) ; chanacs_close ( ca ) ; return ; } if ( ca -> level == 0 && chanacs_is_table_full ( ca ) ) { command_fail ( si , fault_toomany , _ ( ""Channel%saccesslistisfull."" ) , mc -> name ) ; chanacs_close ( ca ) ; return ; } req . ca = ca ; req . oldlevel = ca -> level ; if ( ! chanacs_modify ( ca , & addflags , & removeflags , restrictflags ) ) { command_fail ( si , fault_noprivs , _ ( ""Youarenotallowedtoset\\2%s\\2on\\2%s\\2in\\2%s\\2."" ) , bitmask_to_flags2 ( addflags , removeflags ) , mt -> name , mc -> name ) ; chanacs_close ( ca ) ; return ; } req . newlevel = ca -> level ; hook_call_channel_acl_change ( & req ) ; chanacs_close ( ca ) ; } else { if ( addflags & CA_FOUNDER ) { command_fail ( si , fault_badparams , _ ( ""Youmaynotsetfounderstatusonahostmask."" ) ) ; return ; } ca = chanacs_open ( mc , NULL , target , true , entity ( si -> smu ) ) ; if ( ca -> level == 0 && chanacs_is_table_full ( ca ) ) { command_fail ( si , fault_toomany , _ ( ""Channel%saccesslistisfull."" ) , mc -> name ) ; chanacs_close ( ca ) ; return ; } req . ca = ca ; req . oldlevel = ca -> level ; if ( ! chanacs_modify ( ca , & addflags , & removeflags , restrictflags ) ) { command_fail ( si , fault_noprivs , _ ( ""Youarenotallowedtoset\\2%s\\2on\\2%s\\2in\\2%s\\2."" ) , bitmask_to_flags2 ( addflags , removeflags ) , target , mc -> name ) ; chanacs_close ( ca ) ; return ; } req . newlevel = ca -> level ; hook_call_channel_acl_change ( & req ) ; chanacs_close ( ca ) ; } if ( ( addflags | removeflags ) == 0 ) { command_fail ( si , fault_nochange , _ ( ""Channelaccessto\\2%s\\2for\\2%s\\2unchanged."" ) , channel , target ) ; return ; } flagstr = bitmask_to_flags2 ( addflags , removeflags ) ; command_success_nodata ( si , _ ( ""Flags\\2%s\\2wereseton\\2%s\\2in\\2%s\\2."" ) , flagstr , target , channel ) ; logcommand ( si , CMDLOG_SET , ""FLAGS:\\2%s\\2\\2%s\\2\\2%s\\2"" , mc -> name , target , flagstr ) ; verbose ( mc , ""\\2%s\\2setflags\\2%s\\2on\\2%s\\2"" , get_source_name ( si ) , flagstr , target ) ; } free ( target ) ; } "," else if ( anope_flags_compat && else if ( anope_flags_compat && else if ( anope_flags_compat && ",atheme@atheme/c597156adc60a45b5f827793cd420945f47bc03b,CVE-2014-9773,https://github.com/atheme/atheme/commit/c597156adc60a45b5f827793cd420945f47bc03b,2016-06-13T19:59Z 886,CWE-476,"CWE-476 static int ghash_final ( struct shash_desc * desc , u8 * dst ) { struct ghash_desc_ctx * dctx = shash_desc_ctx ( desc ) ; struct ghash_ctx * ctx = crypto_shash_ctx ( desc -> tfm ) ; u8 * buf = dctx -> buffer ; ghash_flush ( ctx , dctx ) ; memcpy ( dst , buf , GHASH_BLOCK_SIZE ) ; return 0 ; } "," -> buffer ; if ( ! ctx -> gf128 ) return - ENOKEY ; ",torvalds@linux/7ed47b7d142ec99ad6880bbbec51e9f12b3af74c,CVE-2011-4081,https://github.com/torvalds/linux/commit/7ed47b7d142ec99ad6880bbbec51e9f12b3af74c,2012-05-24T23:55Z 887,CWE-200,"CWE-200 static int read_gab2_sub ( AVFormatContext * s , AVStream * st , AVPacket * pkt ) { if ( pkt -> size >= 7 && pkt -> size < INT_MAX - AVPROBE_PADDING_SIZE && ! strcmp ( pkt -> data , ""GAB2"" ) && AV_RL16 ( pkt -> data + 5 ) == 2 ) { uint8_t desc [ 256 ] ; int score = AVPROBE_SCORE_EXTENSION , ret ; AVIStream * ast = st -> priv_data ; AVInputFormat * sub_demuxer ; AVRational time_base ; int size ; AVIOContext * pb = avio_alloc_context ( pkt -> data + 7 , pkt -> size - 7 , 0 , NULL , NULL , NULL , NULL ) ; AVProbeData pd ; unsigned int desc_len = avio_rl32 ( pb ) ; if ( desc_len > pb -> buf_end - pb -> buf_ptr ) goto error ; ret = avio_get_str16le ( pb , desc_len , desc , sizeof ( desc ) ) ; avio_skip ( pb , desc_len - ret ) ; if ( * desc ) av_dict_set ( & st -> metadata , ""title"" , desc , 0 ) ; avio_rl16 ( pb ) ; avio_rl32 ( pb ) ; size = pb -> buf_end - pb -> buf_ptr ; pd = ( AVProbeData ) { . buf = av_mallocz ( size + AVPROBE_PADDING_SIZE ) , . buf_size = size } ; if ( ! pd . buf ) goto error ; memcpy ( pd . buf , pb -> buf_ptr , size ) ; sub_demuxer = av_probe_input_format2 ( & pd , 1 , & score ) ; av_freep ( & pd . buf ) ; if ( ! sub_demuxer ) goto error ; if ( ! ( ast -> sub_ctx = avformat_alloc_context ( ) ) ) goto error ; ast -> sub_ctx -> pb = pb ; if ( ff_copy_whiteblacklists ( ast -> sub_ctx , s ) < 0 ) goto error ; if ( ! avformat_open_input ( & ast -> sub_ctx , """" , sub_demuxer , NULL ) ) { if ( ast -> sub_ctx -> nb_streams != 1 ) goto error ; ff_read_packet ( ast -> sub_ctx , & ast -> sub_pkt ) ; avcodec_parameters_copy ( st -> codecpar , ast -> sub_ctx -> streams [ 0 ] -> codecpar ) ; time_base = ast -> sub_ctx -> streams [ 0 ] -> time_base ; avpriv_set_pts_info ( st , 64 , time_base . num , time_base . den ) ; } ast -> sub_buffer = pkt -> data ; memset ( pkt , 0 , sizeof ( * pkt ) ) ; return 1 ; error : av_freep ( & ast -> sub_ctx ) ; av_freep ( & pb ) ; } return 0 ; } "," ; if ( strcmp ( sub_demuxer -> name , ""srt"" ) && strcmp ( sub_demuxer -> name , ""ass"" ) ) goto error ; if ( ",FFmpeg@FFmpeg/a5d849b149ca67ced2d271dc84db0bc95a548abb,CVE-2017-9993,https://github.com/FFmpeg/FFmpeg/commit/a5d849b149ca67ced2d271dc84db0bc95a548abb,2017-06-28T06:29Z 888,CWE-000,"CWE-000 static krb5_error_code recvauth_common ( krb5_context context , krb5_auth_context * auth_context , krb5_pointer fd , char * appl_version , krb5_principal server , krb5_int32 flags , krb5_keytab keytab , krb5_ticket * * ticket , krb5_data * version ) { krb5_auth_context new_auth_context ; krb5_flags ap_option = 0 ; krb5_error_code retval , problem ; krb5_data inbuf ; krb5_data outbuf ; krb5_rcache rcache = 0 ; krb5_octet response ; krb5_data null_server ; int need_error_free = 0 ; int local_rcache = 0 , local_authcon = 0 ; problem = 0 ; response = 0 ; if ( ! ( flags & KRB5_RECVAUTH_SKIP_VERSION ) ) { if ( ( retval = krb5_read_message ( context , fd , & inbuf ) ) ) return ( retval ) ; if ( strcmp ( inbuf . data , sendauth_version ) ) { problem = KRB5_SENDAUTH_BADAUTHVERS ; response = 1 ; } free ( inbuf . data ) ; } if ( flags & KRB5_RECVAUTH_BADAUTHVERS ) { problem = KRB5_SENDAUTH_BADAUTHVERS ; response = 1 ; } if ( ( retval = krb5_read_message ( context , fd , & inbuf ) ) ) return ( retval ) ; if ( appl_version && strcmp ( inbuf . data , appl_version ) ) { if ( ! problem ) { problem = KRB5_SENDAUTH_BADAPPLVERS ; response = 2 ; } } if ( version && ! problem ) * version = inbuf ; else free ( inbuf . data ) ; if ( ( krb5_net_write ( context , * ( ( int * ) fd ) , ( char * ) & response , 1 ) ) < 0 ) { return ( problem ) ; } if ( problem ) return ( problem ) ; if ( ( retval = krb5_read_message ( context , fd , & inbuf ) ) ) return retval ; if ( * auth_context == NULL ) { problem = krb5_auth_con_init ( context , & new_auth_context ) ; * auth_context = new_auth_context ; local_authcon = 1 ; } krb5_auth_con_getrcache ( context , * auth_context , & rcache ) ; if ( ( ! problem ) && rcache == NULL ) { if ( server != NULL && server -> length > 0 ) { problem = krb5_get_server_rcache ( context , & server -> data [ 0 ] , & rcache ) ; } else { null_server . length = 7 ; null_server . data = ""default"" ; problem = krb5_get_server_rcache ( context , & null_server , & rcache ) ; } if ( ! problem ) problem = krb5_auth_con_setrcache ( context , * auth_context , rcache ) ; local_rcache = 1 ; } if ( ! problem ) { problem = krb5_rd_req ( context , auth_context , & inbuf , server , keytab , & ap_option , ticket ) ; free ( inbuf . data ) ; } if ( problem ) { krb5_error error ; const char * message ; memset ( & error , 0 , sizeof ( error ) ) ; krb5_us_timeofday ( context , & error . stime , & error . susec ) ; if ( server ) error . server = server ; else { ( void ) krb5_parse_name ( context , ""????"" , & error . server ) ; need_error_free = 1 ; } error . error = problem - ERROR_TABLE_BASE_krb5 ; if ( error . error > 127 ) error . error = KRB_ERR_GENERIC ; message = error_message ( problem ) ; error . text . length = strlen ( message ) + 1 ; error . text . data = strdup ( message ) ; if ( ! error . text . data ) { retval = ENOMEM ; goto cleanup ; } if ( ( retval = krb5_mk_error ( context , & error , & outbuf ) ) ) { free ( error . text . data ) ; goto cleanup ; } free ( error . text . data ) ; if ( need_error_free ) krb5_free_principal ( context , error . server ) ; } else { outbuf . length = 0 ; outbuf . data = 0 ; } retval = krb5_write_message ( context , fd , & outbuf ) ; if ( outbuf . data ) { free ( outbuf . data ) ; retval = problem ; goto cleanup ; } if ( retval ) goto cleanup ; if ( ( ap_option & AP_OPTS_MUTUAL_REQUIRED ) ) { if ( ( retval = krb5_mk_rep ( context , * auth_context , & outbuf ) ) ) { return ( retval ) ; } retval = krb5_write_message ( context , fd , & outbuf ) ; free ( outbuf . data ) ; } cleanup : ; if ( retval ) { if ( local_authcon ) { krb5_auth_con_free ( context , * auth_context ) ; } else if ( local_rcache && rcache != NULL ) { krb5_rc_close ( context , rcache ) ; krb5_auth_con_setrcache ( context , * auth_context , NULL ) ; } } return retval ; } "," krb5_data null_server ; krb5_data d ; retval ) ; d = make_data ( ( char * ) sendauth_version , strlen ( sendauth_version ) + 1 ) ; if ( ! data_eq ( inbuf , d ) ) { if ( appl_version != NULL && ! problem ) { d = make_data ( appl_version , strlen ( appl_version ) + 1 ) ; if ( ! data_eq ( inbuf , d ) ) { problem ",krb5@krb5/102bb6ebf20f9174130c85c3b052ae104e5073ec,CVE-2014-5355,https://github.com/krb5/krb5/commit/102bb6ebf20f9174130c85c3b052ae104e5073ec,2015-02-20T11:59Z 889,CWE-119,"CWE-119 static INLINE int write_bit_gte ( vp9_writer * w , int word , int test ) { vp9_write_literal ( w , word >= test , 1 ) ; return word >= test ; } "," int write_bit_gte ( vpx_writer * w , test ) { vpx_write_literal ( w , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 890,CWE-285,"CWE-285 static int __btrfs_set_acl ( struct btrfs_trans_handle * trans , struct inode * inode , struct posix_acl * acl , int type ) { int ret , size = 0 ; const char * name ; char * value = NULL ; switch ( type ) { case ACL_TYPE_ACCESS : name = XATTR_NAME_POSIX_ACL_ACCESS ; if ( acl ) { ret = posix_acl_equiv_mode ( acl , & inode -> i_mode ) ; if ( ret < 0 ) return ret ; if ( ret == 0 ) acl = NULL ; } ret = 0 ; break ; case ACL_TYPE_DEFAULT : if ( ! S_ISDIR ( inode -> i_mode ) ) return acl ? - EINVAL : 0 ; name = XATTR_NAME_POSIX_ACL_DEFAULT ; break ; default : return - EINVAL ; } if ( acl ) { size = posix_acl_xattr_size ( acl -> a_count ) ; value = kmalloc ( size , GFP_KERNEL ) ; if ( ! value ) { ret = - ENOMEM ; goto out ; } ret = posix_acl_to_xattr ( & init_user_ns , acl , value , size ) ; if ( ret < 0 ) goto out ; } ret = __btrfs_setxattr ( trans , inode , name , value , size , 0 ) ; out : kfree ( value ) ; if ( ! ret ) set_cached_acl ( inode , type , acl ) ; return ret ; } "," { ret = posix_acl_update_mode ( inode , & inode inode -> i_mode , & acl ) ; if ( ret ) return ret ; } ret ",torvalds@linux/073931017b49d9458aa351605b43a7e34598caef,CVE-2016-7097,https://github.com/torvalds/linux/commit/073931017b49d9458aa351605b43a7e34598caef,2016-10-16T21:59Z 891,CWE-20,"CWE-20 void rose_write_internal ( struct sock * sk , int frametype ) { struct rose_sock * rose = rose_sk ( sk ) ; struct sk_buff * skb ; unsigned char * dptr ; unsigned char lci1 , lci2 ; char buffer [ 100 ] ; int len , faclen = 0 ; len = AX25_BPQ_HEADER_LEN + AX25_MAX_HEADER_LEN + ROSE_MIN_LEN + 1 ; switch ( frametype ) { case ROSE_CALL_REQUEST : len += 1 + ROSE_ADDR_LEN + ROSE_ADDR_LEN ; faclen = rose_create_facilities ( buffer , rose ) ; len += faclen ; break ; case ROSE_CALL_ACCEPTED : case ROSE_CLEAR_REQUEST : case ROSE_RESET_REQUEST : len += 2 ; break ; } if ( ( skb = alloc_skb ( len , GFP_ATOMIC ) ) == NULL ) return ; skb_reserve ( skb , AX25_BPQ_HEADER_LEN + AX25_MAX_HEADER_LEN + 1 ) ; dptr = skb_put ( skb , skb_tailroom ( skb ) ) ; lci1 = ( rose -> lci >> 8 ) & 0x0F ; lci2 = ( rose -> lci >> 0 ) & 0xFF ; switch ( frametype ) { case ROSE_CALL_REQUEST : * dptr ++ = ROSE_GFI | lci1 ; * dptr ++ = lci2 ; * dptr ++ = frametype ; * dptr ++ = 0xAA ; memcpy ( dptr , & rose -> dest_addr , ROSE_ADDR_LEN ) ; dptr += ROSE_ADDR_LEN ; memcpy ( dptr , & rose -> source_addr , ROSE_ADDR_LEN ) ; dptr += ROSE_ADDR_LEN ; memcpy ( dptr , buffer , faclen ) ; dptr += faclen ; break ; case ROSE_CALL_ACCEPTED : * dptr ++ = ROSE_GFI | lci1 ; * dptr ++ = lci2 ; * dptr ++ = frametype ; * dptr ++ = 0x00 ; * dptr ++ = 0 ; break ; case ROSE_CLEAR_REQUEST : * dptr ++ = ROSE_GFI | lci1 ; * dptr ++ = lci2 ; * dptr ++ = frametype ; * dptr ++ = rose -> cause ; * dptr ++ = rose -> diagnostic ; break ; case ROSE_RESET_REQUEST : * dptr ++ = ROSE_GFI | lci1 ; * dptr ++ = lci2 ; * dptr ++ = frametype ; * dptr ++ = ROSE_DTE_ORIGINATED ; * dptr ++ = 0 ; break ; case ROSE_RR : case ROSE_RNR : * dptr ++ = ROSE_GFI | lci1 ; * dptr ++ = lci2 ; * dptr = frametype ; * dptr ++ |= ( rose -> vr << 5 ) & 0xE0 ; break ; case ROSE_CLEAR_CONFIRMATION : case ROSE_RESET_CONFIRMATION : * dptr ++ = ROSE_GFI | lci1 ; * dptr ++ = lci2 ; * dptr ++ = frametype ; break ; default : printk ( KERN_ERR ""ROSE:rose_write_internal-invalidframetype%02X\\n"" , frametype ) ; kfree_skb ( skb ) ; return ; } rose_transmit_link ( skb , rose -> neighbour ) ; } "," dptr ++ = ROSE_CALL_REQ_ADDR_LEN_VAL ; memcpy ( ",torvalds@linux/e0bccd315db0c2f919e7fcf9cb60db21d9986f52,CVE-2011-4914,https://github.com/torvalds/linux/commit/e0bccd315db0c2f919e7fcf9cb60db21d9986f52,2012-06-21T23:55Z 892,CWE-400,"CWE-400 struct mnt_namespace * copy_mnt_ns ( unsigned long flags , struct mnt_namespace * ns , struct user_namespace * user_ns , struct fs_struct * new_fs ) { struct mnt_namespace * new_ns ; struct vfsmount * rootmnt = NULL , * pwdmnt = NULL ; struct mount * p , * q ; struct mount * old ; struct mount * new ; int copy_flags ; BUG_ON ( ! ns ) ; if ( likely ( ! ( flags & CLONE_NEWNS ) ) ) { get_mnt_ns ( ns ) ; return ns ; } old = ns -> root ; new_ns = alloc_mnt_ns ( user_ns ) ; if ( IS_ERR ( new_ns ) ) return new_ns ; namespace_lock ( ) ; copy_flags = CL_COPY_UNBINDABLE | CL_EXPIRE ; if ( user_ns != ns -> user_ns ) copy_flags |= CL_SHARED_TO_SLAVE | CL_UNPRIVILEGED ; new = copy_tree ( old , old -> mnt . mnt_root , copy_flags ) ; if ( IS_ERR ( new ) ) { namespace_unlock ( ) ; free_mnt_ns ( new_ns ) ; return ERR_CAST ( new ) ; } new_ns -> root = new ; list_add_tail ( & new_ns -> list , & new -> mnt_list ) ; p = old ; q = new ; while ( p ) { q -> mnt_ns = new_ns ; if ( new_fs ) { if ( & p -> mnt == new_fs -> root . mnt ) { new_fs -> root . mnt = mntget ( & q -> mnt ) ; rootmnt = & p -> mnt ; } if ( & p -> mnt == new_fs -> pwd . mnt ) { new_fs -> pwd . mnt = mntget ( & q -> mnt ) ; pwdmnt = & p -> mnt ; } } p = next_mnt ( p , old ) ; q = next_mnt ( q , new ) ; if ( ! q ) break ; while ( p -> mnt . mnt_root != q -> mnt . mnt_root ) p = next_mnt ( p , old ) ; } namespace_unlock ( ) ; if ( rootmnt ) mntput ( rootmnt ) ; if ( pwdmnt ) mntput ( pwdmnt ) ; return new_ns ; } "," = new_ns ; new_ns -> mounts ++ ; ",torvalds@linux/d29216842a85c7970c536108e093963f02714498,CVE-2016-6213,https://github.com/torvalds/linux/commit/d29216842a85c7970c536108e093963f02714498,2016-12-28T07:59Z 893,CWE-119,"CWE-119 int vp8_alloc_frame_buffers ( VP8_COMMON * oci , int width , int height ) { int i ; vp8_de_alloc_frame_buffers ( oci ) ; if ( ( width & 0xf ) != 0 ) width += 16 - ( width & 0xf ) ; if ( ( height & 0xf ) != 0 ) height += 16 - ( height & 0xf ) ; for ( i = 0 ; i < NUM_YV12_BUFFERS ; i ++ ) { oci -> fb_idx_ref_cnt [ i ] = 0 ; oci -> yv12_fb [ i ] . flags = 0 ; if ( vp8_yv12_alloc_frame_buffer ( & oci -> yv12_fb [ i ] , width , height , VP8BORDERINPIXELS ) < 0 ) goto allocation_fail ; } oci -> new_fb_idx = 0 ; oci -> lst_fb_idx = 1 ; oci -> gld_fb_idx = 2 ; oci -> alt_fb_idx = 3 ; oci -> fb_idx_ref_cnt [ 0 ] = 1 ; oci -> fb_idx_ref_cnt [ 1 ] = 1 ; oci -> fb_idx_ref_cnt [ 2 ] = 1 ; oci -> fb_idx_ref_cnt [ 3 ] = 1 ; if ( vp8_yv12_alloc_frame_buffer ( & oci -> temp_scale_frame , width , 16 , VP8BORDERINPIXELS ) < 0 ) goto allocation_fail ; oci -> mb_rows = height >> 4 ; oci -> mb_cols = width >> 4 ; oci -> MBs = oci -> mb_rows * oci -> mb_cols ; oci -> mode_info_stride = oci -> mb_cols + 1 ; oci -> mip = vpx_calloc ( ( oci -> mb_cols + 1 ) * ( oci -> mb_rows + 1 ) , sizeof ( MODE_INFO ) ) ; if ( ! oci -> mip ) goto allocation_fail ; oci -> mi = oci -> mip + oci -> mode_info_stride + 1 ; oci -> above_context = vpx_calloc ( sizeof ( ENTROPY_CONTEXT_PLANES ) * oci -> mb_cols , 1 ) ; if ( ! oci -> above_context ) goto allocation_fail ; # if CONFIG_POSTPROC if ( vp8_yv12_alloc_frame_buffer ( & oci -> post_proc_buffer , width , height , VP8BORDERINPIXELS ) < 0 ) goto allocation_fail ; oci -> post_proc_buffer_int_used = 0 ; vpx_memset ( & oci -> postproc_state , 0 , sizeof ( oci -> postproc_state ) ) ; vpx_memset ( oci -> post_proc_buffer . buffer_alloc , 128 , oci -> post_proc_buffer . frame_size ) ; oci -> pp_limits_buffer = vpx_memalign ( 16 , 24 * ( ( oci -> mb_cols + 1 ) & ~ 1 ) ) ; if ( ! oci -> pp_limits_buffer ) goto allocation_fail ; # endif return 0 ; allocation_fail : vp8_de_alloc_frame_buffers ( oci ) ; return 1 ; } "," = 0 ; memset ( & oci ) ) ; memset ( oci -> ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 894,CWE-416,"CWE-416 static PHP_MINIT_FUNCTION ( zip ) { # ifdef PHP_ZIP_USE_OO zend_class_entry ce ; memcpy ( & zip_object_handlers , zend_get_std_object_handlers ( ) , sizeof ( zend_object_handlers ) ) ; zip_object_handlers . clone_obj = NULL ; zip_object_handlers . get_property_ptr_ptr = php_zip_get_property_ptr_ptr ; zip_object_handlers . get_properties = php_zip_get_properties ; zip_object_handlers . read_property = php_zip_read_property ; zip_object_handlers . has_property = php_zip_has_property ; INIT_CLASS_ENTRY ( ce , ""ZipArchive"" , zip_class_functions ) ; ce . create_object = php_zip_object_new ; zip_class_entry = zend_register_internal_class ( & ce TSRMLS_CC ) ; zend_hash_init ( & zip_prop_handlers , 0 , NULL , NULL , 1 ) ; php_zip_register_prop_handler ( & zip_prop_handlers , ""status"" , php_zip_status , NULL , NULL , IS_LONG TSRMLS_CC ) ; php_zip_register_prop_handler ( & zip_prop_handlers , ""statusSys"" , php_zip_status_sys , NULL , NULL , IS_LONG TSRMLS_CC ) ; php_zip_register_prop_handler ( & zip_prop_handlers , ""numFiles"" , php_zip_get_num_files , NULL , NULL , IS_LONG TSRMLS_CC ) ; php_zip_register_prop_handler ( & zip_prop_handlers , ""filename"" , NULL , NULL , php_zipobj_get_filename , IS_STRING TSRMLS_CC ) ; php_zip_register_prop_handler ( & zip_prop_handlers , ""comment"" , NULL , php_zipobj_get_zip_comment , NULL , IS_STRING TSRMLS_CC ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""CREATE"" , ZIP_CREATE ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""EXCL"" , ZIP_EXCL ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""CHECKCONS"" , ZIP_CHECKCONS ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""OVERWRITE"" , ZIP_OVERWRITE ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""FL_NOCASE"" , ZIP_FL_NOCASE ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""FL_NODIR"" , ZIP_FL_NODIR ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""FL_COMPRESSED"" , ZIP_FL_COMPRESSED ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""FL_UNCHANGED"" , ZIP_FL_UNCHANGED ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""CM_DEFAULT"" , ZIP_CM_DEFAULT ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""CM_STORE"" , ZIP_CM_STORE ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""CM_SHRINK"" , ZIP_CM_SHRINK ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""CM_REDUCE_1"" , ZIP_CM_REDUCE_1 ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""CM_REDUCE_2"" , ZIP_CM_REDUCE_2 ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""CM_REDUCE_3"" , ZIP_CM_REDUCE_3 ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""CM_REDUCE_4"" , ZIP_CM_REDUCE_4 ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""CM_IMPLODE"" , ZIP_CM_IMPLODE ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""CM_DEFLATE"" , ZIP_CM_DEFLATE ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""CM_DEFLATE64"" , ZIP_CM_DEFLATE64 ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""CM_PKWARE_IMPLODE"" , ZIP_CM_PKWARE_IMPLODE ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""CM_BZIP2"" , ZIP_CM_BZIP2 ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""CM_LZMA"" , ZIP_CM_LZMA ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""CM_TERSE"" , ZIP_CM_TERSE ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""CM_LZ77"" , ZIP_CM_LZ77 ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""CM_WAVPACK"" , ZIP_CM_WAVPACK ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""CM_PPMD"" , ZIP_CM_PPMD ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""ER_OK"" , ZIP_ER_OK ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""ER_MULTIDISK"" , ZIP_ER_MULTIDISK ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""ER_RENAME"" , ZIP_ER_RENAME ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""ER_CLOSE"" , ZIP_ER_CLOSE ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""ER_SEEK"" , ZIP_ER_SEEK ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""ER_READ"" , ZIP_ER_READ ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""ER_WRITE"" , ZIP_ER_WRITE ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""ER_CRC"" , ZIP_ER_CRC ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""ER_ZIPCLOSED"" , ZIP_ER_ZIPCLOSED ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""ER_NOENT"" , ZIP_ER_NOENT ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""ER_EXISTS"" , ZIP_ER_EXISTS ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""ER_OPEN"" , ZIP_ER_OPEN ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""ER_TMPOPEN"" , ZIP_ER_TMPOPEN ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""ER_ZLIB"" , ZIP_ER_ZLIB ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""ER_MEMORY"" , ZIP_ER_MEMORY ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""ER_CHANGED"" , ZIP_ER_CHANGED ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""ER_COMPNOTSUPP"" , ZIP_ER_COMPNOTSUPP ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""ER_EOF"" , ZIP_ER_EOF ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""ER_INVAL"" , ZIP_ER_INVAL ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""ER_NOZIP"" , ZIP_ER_NOZIP ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""ER_INTERNAL"" , ZIP_ER_INTERNAL ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""ER_INCONS"" , ZIP_ER_INCONS ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""ER_REMOVE"" , ZIP_ER_REMOVE ) ; REGISTER_ZIP_CLASS_CONST_LONG ( ""ER_DELETED"" , ZIP_ER_DELETED ) ; php_register_url_stream_wrapper ( ""zip"" , & php_stream_zip_wrapper TSRMLS_CC ) ; # endif le_zip_dir = zend_register_list_destructors_ex ( php_zip_free_dir , NULL , le_zip_dir_name , module_number ) ; le_zip_entry = zend_register_list_destructors_ex ( php_zip_free_entry , NULL , le_zip_entry_name , module_number ) ; return SUCCESS ; } "," ; zip_object_handlers . get_gc = php_zip_get_gc ; zip_object_handlers . ",php@php-src/f6aef68089221c5ea047d4a74224ee3deead99a6,CVE-2016-5773,https://github.com/php/php-src/commit/f6aef68089221c5ea047d4a74224ee3deead99a6?w=1,2016-08-07T10:59Z 895,CWE-190,"CWE-190 int mem_check_range ( struct rxe_mem * mem , u64 iova , size_t length ) { switch ( mem -> type ) { case RXE_MEM_TYPE_DMA : return 0 ; case RXE_MEM_TYPE_MR : case RXE_MEM_TYPE_FMR : return ( ( iova < mem -> iova ) || ( ( iova + length ) > ( mem -> iova + mem -> length ) ) ) ? - EFAULT : 0 ; default : return - EFAULT ; } } "," case RXE_MEM_TYPE_FMR : if ( iova < mem -> iova || length > mem -> length || iova > mem -> iova mem -> length - length ) return - EFAULT ; return 0 ; default ",torvalds@linux/647bf3d8a8e5777319da92af672289b2a6c4dc66,CVE-2016-8636,https://github.com/torvalds/linux/commit/647bf3d8a8e5777319da92af672289b2a6c4dc66,2017-02-22T16:59Z 896,CWE-125,"CWE-125 static void icmp6_nodeinfo_print ( netdissect_options * ndo , u_int icmp6len , const u_char * bp , const u_char * ep ) { const struct icmp6_nodeinfo * ni6 ; const struct icmp6_hdr * dp ; const u_char * cp ; size_t siz , i ; int needcomma ; if ( ep < bp ) return ; dp = ( const struct icmp6_hdr * ) bp ; ni6 = ( const struct icmp6_nodeinfo * ) bp ; siz = ep - bp ; switch ( ni6 -> ni_type ) { case ICMP6_NI_QUERY : if ( siz == sizeof ( * dp ) + 4 ) { ND_PRINT ( ( ndo , ""who-are-yourequest"" ) ) ; break ; } ND_PRINT ( ( ndo , ""nodeinformationquery"" ) ) ; ND_TCHECK2 ( * dp , sizeof ( * ni6 ) ) ; ni6 = ( const struct icmp6_nodeinfo * ) dp ; ND_PRINT ( ( ndo , ""("" ) ) ; switch ( EXTRACT_16BITS ( & ni6 -> ni_qtype ) ) { case NI_QTYPE_NOOP : ND_PRINT ( ( ndo , ""noop"" ) ) ; break ; case NI_QTYPE_SUPTYPES : ND_PRINT ( ( ndo , ""supportedqtypes"" ) ) ; i = EXTRACT_16BITS ( & ni6 -> ni_flags ) ; if ( i ) ND_PRINT ( ( ndo , ""[%s]"" , ( i & 0x01 ) ? ""C"" : """" ) ) ; break ; case NI_QTYPE_FQDN : ND_PRINT ( ( ndo , ""DNSname"" ) ) ; break ; case NI_QTYPE_NODEADDR : ND_PRINT ( ( ndo , ""nodeaddresses"" ) ) ; i = ni6 -> ni_flags ; if ( ! i ) break ; ND_PRINT ( ( ndo , ""[%s%s%s%s%s%s]"" , ( i & NI_NODEADDR_FLAG_ANYCAST ) ? ""a"" : """" , ( i & NI_NODEADDR_FLAG_GLOBAL ) ? ""G"" : """" , ( i & NI_NODEADDR_FLAG_SITELOCAL ) ? ""S"" : """" , ( i & NI_NODEADDR_FLAG_LINKLOCAL ) ? ""L"" : """" , ( i & NI_NODEADDR_FLAG_COMPAT ) ? ""C"" : """" , ( i & NI_NODEADDR_FLAG_ALL ) ? ""A"" : """" ) ) ; break ; default : ND_PRINT ( ( ndo , ""unknown"" ) ) ; break ; } if ( ni6 -> ni_qtype == NI_QTYPE_NOOP || ni6 -> ni_qtype == NI_QTYPE_SUPTYPES ) { if ( siz != sizeof ( * ni6 ) ) if ( ndo -> ndo_vflag ) ND_PRINT ( ( ndo , "",invalidlen"" ) ) ; ND_PRINT ( ( ndo , "")"" ) ) ; break ; } if ( siz == sizeof ( * ni6 ) ) { ND_PRINT ( ( ndo , "",03draft"" ) ) ; ND_PRINT ( ( ndo , "")"" ) ) ; break ; } switch ( ni6 -> ni_code ) { case ICMP6_NI_SUBJ_IPV6 : if ( ! ND_TTEST2 ( * dp , sizeof ( * ni6 ) + sizeof ( struct in6_addr ) ) ) break ; if ( siz != sizeof ( * ni6 ) + sizeof ( struct in6_addr ) ) { if ( ndo -> ndo_vflag ) ND_PRINT ( ( ndo , "",invalidsubjectlen"" ) ) ; break ; } ND_PRINT ( ( ndo , "",subject=%s"" , ip6addr_string ( ndo , ni6 + 1 ) ) ) ; break ; case ICMP6_NI_SUBJ_FQDN : ND_PRINT ( ( ndo , "",subject=DNSname"" ) ) ; cp = ( const u_char * ) ( ni6 + 1 ) ; if ( cp [ 0 ] == ep - cp - 1 ) { if ( ndo -> ndo_vflag ) ND_PRINT ( ( ndo , "",03draft"" ) ) ; cp ++ ; ND_PRINT ( ( ndo , "",\\"""" ) ) ; while ( cp < ep ) { safeputchar ( ndo , * cp ) ; cp ++ ; } ND_PRINT ( ( ndo , ""\\"""" ) ) ; } else dnsname_print ( ndo , cp , ep ) ; break ; case ICMP6_NI_SUBJ_IPV4 : if ( ! ND_TTEST2 ( * dp , sizeof ( * ni6 ) + sizeof ( struct in_addr ) ) ) break ; if ( siz != sizeof ( * ni6 ) + sizeof ( struct in_addr ) ) { if ( ndo -> ndo_vflag ) ND_PRINT ( ( ndo , "",invalidsubjectlen"" ) ) ; break ; } ND_PRINT ( ( ndo , "",subject=%s"" , ipaddr_string ( ndo , ni6 + 1 ) ) ) ; break ; default : ND_PRINT ( ( ndo , "",unknownsubject"" ) ) ; break ; } ND_PRINT ( ( ndo , "")"" ) ) ; break ; case ICMP6_NI_REPLY : if ( icmp6len > siz ) { ND_PRINT ( ( ndo , ""[|icmp6:nodeinformationreply]"" ) ) ; break ; } needcomma = 0 ; ni6 = ( const struct icmp6_nodeinfo * ) dp ; ND_PRINT ( ( ndo , ""nodeinformationreply"" ) ) ; ND_PRINT ( ( ndo , ""("" ) ) ; switch ( ni6 -> ni_code ) { case ICMP6_NI_SUCCESS : if ( ndo -> ndo_vflag ) { ND_PRINT ( ( ndo , ""success"" ) ) ; needcomma ++ ; } break ; case ICMP6_NI_REFUSED : ND_PRINT ( ( ndo , ""refused"" ) ) ; needcomma ++ ; if ( siz != sizeof ( * ni6 ) ) if ( ndo -> ndo_vflag ) ND_PRINT ( ( ndo , "",invalidlength"" ) ) ; break ; case ICMP6_NI_UNKNOWN : ND_PRINT ( ( ndo , ""unknown"" ) ) ; needcomma ++ ; if ( siz != sizeof ( * ni6 ) ) if ( ndo -> ndo_vflag ) ND_PRINT ( ( ndo , "",invalidlength"" ) ) ; break ; } if ( ni6 -> ni_code != ICMP6_NI_SUCCESS ) { ND_PRINT ( ( ndo , "")"" ) ) ; break ; } switch ( EXTRACT_16BITS ( & ni6 -> ni_qtype ) ) { case NI_QTYPE_NOOP : if ( needcomma ) ND_PRINT ( ( ndo , "","" ) ) ; ND_PRINT ( ( ndo , ""noop"" ) ) ; if ( siz != sizeof ( * ni6 ) ) if ( ndo -> ndo_vflag ) ND_PRINT ( ( ndo , "",invalidlength"" ) ) ; break ; case NI_QTYPE_SUPTYPES : if ( needcomma ) ND_PRINT ( ( ndo , "","" ) ) ; ND_PRINT ( ( ndo , ""supportedqtypes"" ) ) ; i = EXTRACT_16BITS ( & ni6 -> ni_flags ) ; if ( i ) ND_PRINT ( ( ndo , ""[%s]"" , ( i & 0x01 ) ? ""C"" : """" ) ) ; break ; case NI_QTYPE_FQDN : if ( needcomma ) ND_PRINT ( ( ndo , "","" ) ) ; ND_PRINT ( ( ndo , ""DNSname"" ) ) ; cp = ( const u_char * ) ( ni6 + 1 ) + 4 ; if ( cp [ 0 ] == ep - cp - 1 ) { if ( ndo -> ndo_vflag ) ND_PRINT ( ( ndo , "",03draft"" ) ) ; cp ++ ; ND_PRINT ( ( ndo , "",\\"""" ) ) ; while ( cp < ep ) { safeputchar ( ndo , * cp ) ; cp ++ ; } ND_PRINT ( ( ndo , ""\\"""" ) ) ; } else dnsname_print ( ndo , cp , ep ) ; if ( ( EXTRACT_16BITS ( & ni6 -> ni_flags ) & 0x01 ) != 0 ) ND_PRINT ( ( ndo , ""[TTL=%u]"" , EXTRACT_32BITS ( ni6 + 1 ) ) ) ; break ; case NI_QTYPE_NODEADDR : if ( needcomma ) ND_PRINT ( ( ndo , "","" ) ) ; ND_PRINT ( ( ndo , ""nodeaddresses"" ) ) ; i = sizeof ( * ni6 ) ; while ( i < siz ) { if ( i + sizeof ( struct in6_addr ) + sizeof ( int32_t ) > siz ) break ; ND_PRINT ( ( ndo , ""%s"" , ip6addr_string ( ndo , bp + i ) ) ) ; i += sizeof ( struct in6_addr ) ; ND_PRINT ( ( ndo , ""(%d)"" , ( int32_t ) EXTRACT_32BITS ( bp + i ) ) ) ; i += sizeof ( int32_t ) ; } i = ni6 -> ni_flags ; if ( ! i ) break ; ND_PRINT ( ( ndo , ""[%s%s%s%s%s%s%s]"" , ( i & NI_NODEADDR_FLAG_ANYCAST ) ? ""a"" : """" , ( i & NI_NODEADDR_FLAG_GLOBAL ) ? ""G"" : """" , ( i & NI_NODEADDR_FLAG_SITELOCAL ) ? ""S"" : """" , ( i & NI_NODEADDR_FLAG_LINKLOCAL ) ? ""L"" : """" , ( i & NI_NODEADDR_FLAG_COMPAT ) ? ""C"" : """" , ( i & NI_NODEADDR_FLAG_ALL ) ? ""A"" : """" , ( i & NI_NODEADDR_FLAG_TRUNCATE ) ? ""T"" : """" ) ) ; break ; default : if ( needcomma ) ND_PRINT ( ( ndo , "","" ) ) ; ND_PRINT ( ( ndo , ""unknown"" ) ) ; break ; } ND_PRINT ( ( ndo , "")"" ) ) ; break ; } return ; trunc : ND_PRINT ( ( ndo , ""[|icmp6]"" ) ) ; } "," = 0 ; ND_TCHECK2 ( * dp , sizeof ( * ni6 ) ) ; ) + 4 ; ND_TCHECK ( cp [ 0 ] ) ",the-tcpdump-group@tcpdump/f4b9e24c7384d882a7f434cc7413925bf871d63e,CVE-2017-13041,https://github.com/the-tcpdump-group/tcpdump/commit/f4b9e24c7384d882a7f434cc7413925bf871d63e,2017-09-14T06:29Z 897,CWE-119,"CWE-119 static void finish_object ( struct object * obj , struct strbuf * path , const char * name , void * cb_data ) { struct rev_list_info * info = cb_data ; if ( obj -> type == OBJ_BLOB && ! has_object_file ( & obj -> oid ) ) die ( ""missingblobobject\'%s\'"" , oid_to_hex ( & obj -> oid ) ) ; if ( info -> revs -> verify_objects && ! obj -> parsed && obj -> type != OBJ_COMMIT ) parse_object ( obj -> oid . hash ) ; } "," * obj , const char * ",git@git/de1e67d0703894cb6ea782e36abb63976ab07e60,CVE-2016-2324,https://github.com/git/git/commit/de1e67d0703894cb6ea782e36abb63976ab07e60,2016-04-08T14:59Z 898,CWE-362,"CWE-362 static int smb_send_kvec ( struct TCP_Server_Info * server , struct kvec * iov , size_t n_vec , size_t * sent ) { int rc = 0 ; int i = 0 ; struct msghdr smb_msg ; unsigned int remaining ; size_t first_vec = 0 ; struct socket * ssocket = server -> ssocket ; * sent = 0 ; if ( ssocket == NULL ) return - ENOTSOCK ; smb_msg . msg_name = ( struct sockaddr * ) & server -> dstaddr ; smb_msg . msg_namelen = sizeof ( struct sockaddr ) ; smb_msg . msg_control = NULL ; smb_msg . msg_controllen = 0 ; if ( server -> noblocksnd ) smb_msg . msg_flags = MSG_DONTWAIT + MSG_NOSIGNAL ; else smb_msg . msg_flags = MSG_NOSIGNAL ; remaining = 0 ; for ( i = 0 ; i < n_vec ; i ++ ) remaining += iov [ i ] . iov_len ; i = 0 ; while ( remaining ) { rc = kernel_sendmsg ( ssocket , & smb_msg , & iov [ first_vec ] , n_vec - first_vec , remaining ) ; if ( rc == - ENOSPC || rc == - EAGAIN ) { WARN_ON_ONCE ( rc == - ENOSPC ) ; i ++ ; if ( i >= 14 || ( ! server -> noblocksnd && ( i > 2 ) ) ) { cERROR ( 1 , ""sendsonsock%pstuckfor15"" ""seconds"" , ssocket ) ; rc = - EAGAIN ; break ; } msleep ( 1 << i ) ; continue ; } if ( rc < 0 ) break ; * sent += rc ; if ( rc == remaining ) { remaining = 0 ; break ; } if ( rc > remaining ) { cERROR ( 1 , ""sent%drequested%d"" , rc , remaining ) ; break ; } if ( rc == 0 ) { cERROR ( 1 , ""tcpsentnodata"" ) ; msleep ( 500 ) ; continue ; } remaining -= rc ; for ( i = first_vec ; i < n_vec ; i ++ ) { if ( iov [ i ] . iov_len ) { if ( rc > iov [ i ] . iov_len ) { rc -= iov [ i ] . iov_len ; iov [ i ] . iov_len = 0 ; } else { iov [ i ] . iov_base += rc ; iov [ i ] . iov_len -= rc ; first_vec = i ; break ; } } } i = 0 ; rc = 0 ; } return rc ; } "," sent = 0 ; smb_msg . ",torvalds@linux/ea702b80e0bbb2448e201472127288beb82ca2fe,CVE-2013-3302,https://github.com/torvalds/linux/commit/ea702b80e0bbb2448e201472127288beb82ca2fe,2013-04-29T14:55Z 899,CWE-416,"CWE-416 static void buffer_pipe_buf_get ( struct pipe_inode_info * pipe , struct pipe_buffer * buf ) { struct buffer_ref * ref = ( struct buffer_ref * ) buf -> private ; ref -> ref ++ ; } "," static bool buffer_pipe_buf_get ( struct -> private ; if ( ref -> ref > INT_MAX / 2 ) return false ; ref ++ ; return true ; ",torvalds@linux/15fab63e1e57be9fdb5eec1bbc5916e9825e9acb,CVE-2019-11487,https://github.com/torvalds/linux/commit/15fab63e1e57be9fdb5eec1bbc5916e9825e9acb,2019-04-23T22:29Z 900,CWE-189,"CWE-189 void set_fat ( DOS_FS * fs , uint32_t cluster , int32_t new ) { unsigned char * data = NULL ; int size ; loff_t offs ; if ( new == - 1 ) new = FAT_EOF ( fs ) ; else if ( ( long ) new == - 2 ) new = FAT_BAD ( fs ) ; switch ( fs -> fat_bits ) { case 12 : data = fs -> fat + cluster * 3 / 2 ; offs = fs -> fat_start + cluster * 3 / 2 ; if ( cluster & 1 ) { FAT_ENTRY prevEntry ; get_fat ( & prevEntry , fs -> fat , cluster - 1 , fs ) ; data [ 0 ] = ( ( new & 0xf ) << 4 ) | ( prevEntry . value >> 8 ) ; data [ 1 ] = new >> 4 ; } else { FAT_ENTRY subseqEntry ; if ( cluster != fs -> clusters - 1 ) get_fat ( & subseqEntry , fs -> fat , cluster + 1 , fs ) ; else subseqEntry . value = 0 ; data [ 0 ] = new & 0xff ; data [ 1 ] = ( new >> 8 ) | ( ( 0xff & subseqEntry . value ) << 4 ) ; } size = 2 ; break ; case 16 : data = fs -> fat + cluster * 2 ; offs = fs -> fat_start + cluster * 2 ; * ( unsigned short * ) data = htole16 ( new ) ; size = 2 ; break ; case 32 : { FAT_ENTRY curEntry ; get_fat ( & curEntry , fs -> fat , cluster , fs ) ; data = fs -> fat + cluster * 4 ; offs = fs -> fat_start + cluster * 4 ; * ( uint32_t * ) data = htole32 ( ( new & 0xfffffff ) | ( curEntry . reserved << 28 ) ) ; size = 4 ; } break ; default : die ( ""BadFATentrysize:%dbits."" , fs -> fat_bits ) ; } fs_write ( offs , size , data ) ; if ( fs -> nfats > 1 ) { fs_write ( offs + fs -> fat_size , size , data ) ; } } "," fs -> clusters + 1 ) get_fat ",dosfstools@dosfstools/07908124838afcc99c577d1d3e84cef2dbd39cb7,CVE-2015-8872,https://github.com/dosfstools/dosfstools/commit/07908124838afcc99c577d1d3e84cef2dbd39cb7,2016-06-03T14:59Z 901,CWE-119,"CWE-119 void vp8_optimize_mby ( MACROBLOCK * x ) { int b ; int type ; int has_2nd_order ; ENTROPY_CONTEXT_PLANES t_above , t_left ; ENTROPY_CONTEXT * ta ; ENTROPY_CONTEXT * tl ; if ( ! x -> e_mbd . above_context ) return ; if ( ! x -> e_mbd . left_context ) return ; vpx_memcpy ( & t_above , x -> e_mbd . above_context , sizeof ( ENTROPY_CONTEXT_PLANES ) ) ; vpx_memcpy ( & t_left , x -> e_mbd . left_context , sizeof ( ENTROPY_CONTEXT_PLANES ) ) ; ta = ( ENTROPY_CONTEXT * ) & t_above ; tl = ( ENTROPY_CONTEXT * ) & t_left ; has_2nd_order = ( x -> e_mbd . mode_info_context -> mbmi . mode != B_PRED && x -> e_mbd . mode_info_context -> mbmi . mode != SPLITMV ) ; type = has_2nd_order ? PLANE_TYPE_Y_NO_DC : PLANE_TYPE_Y_WITH_DC ; for ( b = 0 ; b < 16 ; b ++ ) { optimize_b ( x , b , type , ta + vp8_block2above [ b ] , tl + vp8_block2left [ b ] ) ; } if ( has_2nd_order ) { b = 24 ; optimize_b ( x , b , PLANE_TYPE_Y2 , ta + vp8_block2above [ b ] , tl + vp8_block2left [ b ] ) ; check_reset_2nd_coeffs ( & x -> e_mbd , PLANE_TYPE_Y2 , ta + vp8_block2above [ b ] , tl + vp8_block2left [ b ] ) ; } } "," ) return ; memcpy ( & t_above ) ) ; memcpy ( & t_left ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 902,CWE-000,"CWE-000 void ping_unhash ( struct sock * sk ) { struct inet_sock * isk = inet_sk ( sk ) ; pr_debug ( ""ping_unhash(isk=%p,isk->num=%u)\\n"" , isk , isk -> inet_num ) ; if ( sk_hashed ( sk ) ) { write_lock_bh ( & ping_table . lock ) ; hlist_nulls_del ( & sk -> sk_nulls_node ) ; sock_put ( sk ) ; isk -> inet_num = 0 ; isk -> inet_sport = 0 ; sock_prot_inuse_add ( sock_net ( sk ) , sk -> sk_prot , - 1 ) ; write_unlock_bh ( & ping_table . lock ) ; } } "," sk_nulls_node ) ; sk_nulls_node_init ( & sk -> sk_nulls_node ) ; ",torvalds@linux/a134f083e79fb4c3d0a925691e732c56911b4326,CVE-2015-3636,https://github.com/torvalds/linux/commit/a134f083e79fb4c3d0a925691e732c56911b4326,2015-08-06T01:59Z 903,CWE-20,"CWE-20 WORD32 ih264d_mark_err_slice_skip ( dec_struct_t * ps_dec , WORD32 num_mb_skip , UWORD8 u1_is_idr_slice , UWORD16 u2_frame_num , pocstruct_t * ps_cur_poc , WORD32 prev_slice_err ) { WORD32 i2_cur_mb_addr ; UWORD32 u1_num_mbs , u1_num_mbsNby2 ; UWORD32 u1_mb_idx = ps_dec -> u1_mb_idx ; UWORD32 i2_mb_skip_run ; UWORD32 u1_num_mbs_next , u1_end_of_row ; const UWORD32 i2_pic_wdin_mbs = ps_dec -> u2_frm_wd_in_mbs ; UWORD32 u1_slice_end ; UWORD32 u1_tfr_n_mb ; UWORD32 u1_decode_nmb ; dec_bit_stream_t * const ps_bitstrm = ps_dec -> ps_bitstrm ; dec_slice_params_t * ps_slice = ps_dec -> ps_cur_slice ; UWORD32 * pu4_bitstrm_buf = ps_bitstrm -> pu4_buffer ; UWORD32 * pu4_bitstrm_ofst = & ps_bitstrm -> u4_ofst ; deblk_mb_t * ps_cur_deblk_mb ; dec_mb_info_t * ps_cur_mb_info ; parse_pmbarams_t * ps_parse_mb_data ; UWORD32 u1_inter_mb_type ; UWORD32 u1_deblk_mb_type ; UWORD16 u2_total_mbs_coded ; UWORD32 u1_mbaff = ps_slice -> u1_mbaff_frame_flag ; parse_part_params_t * ps_part_info ; WORD32 ret ; if ( ps_dec -> ps_dec_err_status -> u1_err_flag & REJECT_CUR_PIC ) { ih264d_err_pic_dispbuf_mgr ( ps_dec ) ; return 0 ; } if ( prev_slice_err == 1 ) { ps_dec -> ps_cur_slice -> u2_frame_num = u2_frame_num ; if ( ! ps_dec -> u1_first_slice_in_stream ) { ih264d_end_of_pic ( ps_dec , u1_is_idr_slice , ps_dec -> ps_cur_slice -> u2_frame_num ) ; ps_dec -> s_cur_pic_poc . u2_frame_num = ps_dec -> ps_cur_slice -> u2_frame_num ; } { WORD32 i , j , poc = 0 ; ps_dec -> ps_cur_slice -> u2_first_mb_in_slice = 0 ; ps_dec -> pf_mvpred = ih264d_mvpred_nonmbaff ; ps_dec -> p_form_mb_part_info = ih264d_form_mb_part_info_bp ; ps_dec -> p_motion_compensate = ih264d_motion_compensate_bp ; if ( ps_dec -> ps_cur_pic != NULL ) poc = ps_dec -> ps_cur_pic -> i4_poc + 2 ; j = 0 ; for ( i = 0 ; i < MAX_NUM_PIC_PARAMS ; i ++ ) if ( ps_dec -> ps_pps [ i ] . u1_is_valid == TRUE ) j = i ; { ps_dec -> ps_cur_slice -> u1_bottom_field_flag = 0 ; ps_dec -> ps_cur_slice -> u1_field_pic_flag = 0 ; ps_dec -> ps_cur_slice -> u1_slice_type = P_SLICE ; ps_dec -> ps_cur_slice -> u1_nal_ref_idc = 1 ; ps_dec -> ps_cur_slice -> u1_nal_unit_type = 1 ; ret = ih264d_start_of_pic ( ps_dec , poc , ps_cur_poc , ps_dec -> ps_cur_slice -> u2_frame_num , & ps_dec -> ps_pps [ j ] ) ; if ( ret != OK ) { return ret ; } } ps_dec -> ps_ref_pic_buf_lx [ 0 ] [ 0 ] -> u1_pic_buf_id = 0 ; ps_dec -> u4_output_present = 0 ; { ih264d_get_next_display_field ( ps_dec , ps_dec -> ps_out_buffer , & ( ps_dec -> s_disp_op ) ) ; if ( 0 != ps_dec -> s_disp_op . u4_error_code ) { ps_dec -> u4_fmt_conv_cur_row = ps_dec -> s_disp_frame_info . u4_y_ht ; } else ps_dec -> u4_output_present = 1 ; } if ( ps_dec -> u1_separate_parse == 1 ) { if ( ps_dec -> u4_dec_thread_created == 0 ) { ithread_create ( ps_dec -> pv_dec_thread_handle , NULL , ( void * ) ih264d_decode_picture_thread , ( void * ) ps_dec ) ; ps_dec -> u4_dec_thread_created = 1 ; } if ( ( ps_dec -> u4_num_cores == 3 ) && ( ( ps_dec -> u4_app_disable_deblk_frm == 0 ) || ps_dec -> i1_recon_in_thread3_flag ) && ( ps_dec -> u4_bs_deblk_thread_created == 0 ) ) { ps_dec -> u4_start_recon_deblk = 0 ; ithread_create ( ps_dec -> pv_bs_deblk_thread_handle , NULL , ( void * ) ih264d_recon_deblk_thread , ( void * ) ps_dec ) ; ps_dec -> u4_bs_deblk_thread_created = 1 ; } } } } else { dec_slice_struct_t * ps_parse_cur_slice ; ps_parse_cur_slice = ps_dec -> ps_dec_slice_buf + ps_dec -> u2_cur_slice_num ; if ( ps_dec -> u1_slice_header_done && ps_parse_cur_slice == ps_dec -> ps_parse_cur_slice ) { u1_num_mbs = ps_dec -> u4_num_mbs_cur_nmb ; if ( u1_num_mbs ) { ps_cur_mb_info = ps_dec -> ps_nmb_info + u1_num_mbs - 1 ; } else { if ( ps_dec -> u1_separate_parse ) { ps_cur_mb_info = ps_dec -> ps_nmb_info - 1 ; } else { ps_cur_mb_info = ps_dec -> ps_nmb_info + ps_dec -> u4_num_mbs_prev_nmb - 1 ; } } ps_dec -> u2_mby = ps_cur_mb_info -> u2_mby ; ps_dec -> u2_mbx = ps_cur_mb_info -> u2_mbx ; ps_dec -> u1_mb_ngbr_availablity = ps_cur_mb_info -> u1_mb_ngbr_availablity ; ps_dec -> pv_parse_tu_coeff_data = ps_dec -> pv_prev_mb_parse_tu_coeff_data ; ps_dec -> u2_cur_mb_addr -- ; ps_dec -> i4_submb_ofst -= SUB_BLK_SIZE ; if ( u1_num_mbs ) { if ( ps_dec -> u1_pr_sl_type == P_SLICE || ps_dec -> u1_pr_sl_type == B_SLICE ) { ps_dec -> pf_mvpred_ref_tfr_nby2mb ( ps_dec , u1_mb_idx , u1_num_mbs ) ; ps_dec -> ps_part = ps_dec -> ps_parse_part_params ; } u1_num_mbs_next = i2_pic_wdin_mbs - ps_dec -> u2_mbx - 1 ; u1_end_of_row = ( ! u1_num_mbs_next ) && ( ! ( u1_mbaff && ( u1_num_mbs & 0x01 ) ) ) ; u1_slice_end = 1 ; u1_tfr_n_mb = 1 ; ps_cur_mb_info -> u1_end_of_slice = u1_slice_end ; if ( ps_dec -> u1_separate_parse ) { ih264d_parse_tfr_nmb ( ps_dec , u1_mb_idx , u1_num_mbs , u1_num_mbs_next , u1_tfr_n_mb , u1_end_of_row ) ; ps_dec -> ps_nmb_info += u1_num_mbs ; } else { ih264d_decode_recon_tfr_nmb ( ps_dec , u1_mb_idx , u1_num_mbs , u1_num_mbs_next , u1_tfr_n_mb , u1_end_of_row ) ; } ps_dec -> u2_total_mbs_coded += u1_num_mbs ; ps_dec -> u1_mb_idx = 0 ; ps_dec -> u4_num_mbs_cur_nmb = 0 ; } if ( ps_dec -> u2_total_mbs_coded >= ps_dec -> u2_frm_ht_in_mbs * ps_dec -> u2_frm_wd_in_mbs ) { ps_dec -> u1_pic_decode_done = 1 ; return 0 ; } ps_dec -> u2_cur_slice_num ++ ; ps_dec -> i2_prev_slice_mbx = ps_dec -> u2_mbx ; ps_dec -> i2_prev_slice_mby = ps_dec -> u2_mby ; ps_dec -> ps_parse_cur_slice ++ ; } else { ps_dec -> ps_parse_cur_slice = ps_dec -> ps_dec_slice_buf + ps_dec -> u2_cur_slice_num ; } } { WORD32 num_entries ; WORD32 size ; UWORD8 * pu1_buf ; num_entries = MAX_FRAMES ; if ( ( 1 >= ps_dec -> ps_cur_sps -> u1_num_ref_frames ) && ( 0 == ps_dec -> i4_display_delay ) ) { num_entries = 1 ; } num_entries = ( ( 2 * num_entries ) + 1 ) ; if ( BASE_PROFILE_IDC != ps_dec -> ps_cur_sps -> u1_profile_idc ) { num_entries *= 2 ; } size = num_entries * sizeof ( void * ) ; size += PAD_MAP_IDX_POC * sizeof ( void * ) ; pu1_buf = ( UWORD8 * ) ps_dec -> pv_map_ref_idx_to_poc_buf ; pu1_buf += size * ps_dec -> u2_cur_slice_num ; ps_dec -> ps_parse_cur_slice -> ppv_map_ref_idx_to_poc = ( volatile void * * ) pu1_buf ; } ps_dec -> ps_cur_slice -> u2_first_mb_in_slice = ps_dec -> u2_total_mbs_coded << u1_mbaff ; ps_dec -> ps_cur_slice -> i1_slice_alpha_c0_offset = 0 ; ps_dec -> ps_cur_slice -> i1_slice_beta_offset = 0 ; if ( ps_dec -> ps_cur_slice -> u1_field_pic_flag ) ps_dec -> u2_prv_frame_num = ps_dec -> ps_cur_slice -> u2_frame_num ; ps_dec -> ps_parse_cur_slice -> u4_first_mb_in_slice = ps_dec -> u2_total_mbs_coded << u1_mbaff ; ps_dec -> ps_parse_cur_slice -> u2_log2Y_crwd = ps_dec -> ps_cur_slice -> u2_log2Y_crwd ; if ( ps_dec -> u1_separate_parse ) { ps_dec -> ps_parse_cur_slice -> pv_tu_coeff_data_start = ps_dec -> pv_parse_tu_coeff_data ; } else { ps_dec -> pv_proc_tu_coeff_data = ps_dec -> pv_parse_tu_coeff_data ; } u1_inter_mb_type = P_MB ; u1_deblk_mb_type = D_INTER_MB ; ps_dec -> ps_cur_slice -> u1_slice_type = P_SLICE ; ps_dec -> ps_parse_cur_slice -> slice_type = P_SLICE ; ps_dec -> pf_mvpred_ref_tfr_nby2mb = ih264d_mv_pred_ref_tfr_nby2_pmb ; ps_dec -> ps_part = ps_dec -> ps_parse_part_params ; ps_dec -> u1_slice_header_done = 2 ; ps_dec -> u1_qp = ps_slice -> u1_slice_qp ; ih264d_update_qp ( ps_dec , 0 ) ; u1_mb_idx = ps_dec -> u1_mb_idx ; ps_parse_mb_data = ps_dec -> ps_parse_mb_data ; u1_num_mbs = u1_mb_idx ; u1_slice_end = 0 ; u1_tfr_n_mb = 0 ; u1_decode_nmb = 0 ; u1_num_mbsNby2 = 0 ; i2_cur_mb_addr = ps_dec -> u2_total_mbs_coded ; i2_mb_skip_run = num_mb_skip ; while ( ! u1_slice_end ) { UWORD8 u1_mb_type ; if ( i2_cur_mb_addr > ps_dec -> ps_cur_sps -> u2_max_mb_addr ) break ; ps_cur_mb_info = ps_dec -> ps_nmb_info + u1_num_mbs ; ps_dec -> u4_num_mbs_cur_nmb = u1_num_mbs ; ps_cur_mb_info -> u1_Mux = 0 ; ps_dec -> u4_num_pmbair = ( u1_num_mbs >> u1_mbaff ) ; ps_cur_deblk_mb = ps_dec -> ps_deblk_mbn + u1_num_mbs ; ps_cur_mb_info -> u1_end_of_slice = 0 ; ps_parse_mb_data -> u1_num_part = 1 ; ps_parse_mb_data -> u1_isI_mb = 0 ; if ( u1_mbaff ) ih264d_get_mb_info_cavlc_mbaff ( ps_dec , i2_cur_mb_addr , ps_cur_mb_info , i2_mb_skip_run ) ; else ih264d_get_mb_info_cavlc_nonmbaff ( ps_dec , i2_cur_mb_addr , ps_cur_mb_info , i2_mb_skip_run ) ; if ( ps_dec -> u4_app_disable_deblk_frm == 0 ) { ih264d_set_deblocking_parameters ( ps_cur_deblk_mb , ps_slice , ps_dec -> u1_mb_ngbr_availablity , ps_dec -> u1_cur_mb_fld_dec_flag ) ; } ps_dec -> i1_prev_mb_qp_delta = 0 ; ps_dec -> u1_sub_mb_num = 0 ; ps_cur_mb_info -> u1_mb_type = MB_SKIP ; ps_cur_mb_info -> u1_mb_mc_mode = PRED_16x16 ; ps_cur_mb_info -> u1_cbp = 0 ; ps_part_info = ps_dec -> ps_part ; ps_part_info -> u1_is_direct = PART_DIRECT_16x16 ; ps_part_info -> u1_sub_mb_num = 0 ; ps_dec -> ps_part ++ ; ih264d_update_nnz_for_skipmb ( ps_dec , ps_cur_mb_info , CAVLC ) ; ps_cur_mb_info -> ps_curmb -> u1_mb_type = u1_inter_mb_type ; ps_cur_deblk_mb -> u1_mb_type |= u1_deblk_mb_type ; i2_mb_skip_run -- ; ps_cur_deblk_mb -> u1_mb_qp = ps_dec -> u1_qp ; if ( u1_mbaff ) { ih264d_update_mbaff_left_nnz ( ps_dec , ps_cur_mb_info ) ; } i2_cur_mb_addr ++ ; u1_num_mbs ++ ; u1_num_mbsNby2 ++ ; ps_parse_mb_data ++ ; u1_num_mbs_next = i2_pic_wdin_mbs - ps_dec -> u2_mbx - 1 ; u1_end_of_row = ( ! u1_num_mbs_next ) && ( ! ( u1_mbaff && ( u1_num_mbs & 0x01 ) ) ) ; u1_slice_end = ! i2_mb_skip_run ; u1_tfr_n_mb = ( u1_num_mbs == ps_dec -> u1_recon_mb_grp ) || u1_end_of_row || u1_slice_end ; u1_decode_nmb = u1_tfr_n_mb || u1_slice_end ; ps_cur_mb_info -> u1_end_of_slice = u1_slice_end ; if ( u1_decode_nmb ) { ps_dec -> pf_mvpred_ref_tfr_nby2mb ( ps_dec , u1_mb_idx , u1_num_mbs ) ; u1_num_mbsNby2 = 0 ; ps_parse_mb_data = ps_dec -> ps_parse_mb_data ; ps_dec -> ps_part = ps_dec -> ps_parse_part_params ; if ( ps_dec -> u1_separate_parse ) { ih264d_parse_tfr_nmb ( ps_dec , u1_mb_idx , u1_num_mbs , u1_num_mbs_next , u1_tfr_n_mb , u1_end_of_row ) ; ps_dec -> ps_nmb_info += u1_num_mbs ; } else { ih264d_decode_recon_tfr_nmb ( ps_dec , u1_mb_idx , u1_num_mbs , u1_num_mbs_next , u1_tfr_n_mb , u1_end_of_row ) ; } ps_dec -> u2_total_mbs_coded += u1_num_mbs ; if ( u1_tfr_n_mb ) u1_num_mbs = 0 ; u1_mb_idx = u1_num_mbs ; ps_dec -> u1_mb_idx = u1_num_mbs ; } } ps_dec -> u4_num_mbs_cur_nmb = 0 ; ps_dec -> ps_cur_slice -> u4_mbs_in_slice = i2_cur_mb_addr - ps_dec -> ps_parse_cur_slice -> u4_first_mb_in_slice ; H264_DEC_DEBUG_PRINT ( ""Mbsinslice:%d\\n"" , ps_dec -> ps_cur_slice -> u4_mbs_in_slice ) ; ps_dec -> u2_cur_slice_num ++ ; if ( ps_dec -> u4_first_slice_in_pic != 0 ) ps_dec -> ps_parse_cur_slice ++ ; ps_dec -> i2_prev_slice_mbx = ps_dec -> u2_mbx ; ps_dec -> i2_prev_slice_mby = ps_dec -> u2_mby ; if ( ps_dec -> u2_total_mbs_coded >= ps_dec -> u2_frm_ht_in_mbs * ps_dec -> u2_frm_wd_in_mbs ) { ps_dec -> u1_pic_decode_done = 1 ; } return 0 ; } "," 0 ; } ps_dec -> ps_dpb_cmds -> u1_long_term_reference_flag = 0 ; ",external@libavc/d4841f1161bdb5e13cb19e81af42437a634dd6ef,CVE-2016-3755,https://android.googlesource.com/platform/external/libavc/+/d4841f1161bdb5e13cb19e81af42437a634dd6ef,2016-07-11T01:59Z 904,CWE-362,"CWE-362 static ssize_t environ_read ( struct file * file , char __user * buf , size_t count , loff_t * ppos ) { char * page ; unsigned long src = * ppos ; int ret = 0 ; struct mm_struct * mm = file -> private_data ; unsigned long env_start , env_end ; if ( ! mm ) return 0 ; page = ( char * ) __get_free_page ( GFP_TEMPORARY ) ; if ( ! page ) return - ENOMEM ; ret = 0 ; if ( ! atomic_inc_not_zero ( & mm -> mm_users ) ) goto free ; down_read ( & mm -> mmap_sem ) ; env_start = mm -> env_start ; env_end = mm -> env_end ; up_read ( & mm -> mmap_sem ) ; while ( count > 0 ) { size_t this_len , max_len ; int retval ; if ( src >= ( env_end - env_start ) ) break ; this_len = env_end - ( env_start + src ) ; max_len = min_t ( size_t , PAGE_SIZE , count ) ; this_len = min ( max_len , this_len ) ; retval = access_remote_vm ( mm , ( env_start + src ) , page , this_len , 0 ) ; if ( retval <= 0 ) { ret = retval ; break ; } if ( copy_to_user ( buf , page , retval ) ) { ret = - EFAULT ; break ; } ret += retval ; src += retval ; buf += retval ; count -= retval ; } * ppos = src ; mmput ( mm ) ; free : free_page ( ( unsigned long ) page ) ; return ret ; } "," ( ! mm || ! mm -> env_end ",torvalds@linux/8148a73c9901a8794a50f950083c00ccf97d43b3,CVE-2016-7916,https://github.com/torvalds/linux/commit/8148a73c9901a8794a50f950083c00ccf97d43b3,2016-11-16T05:59Z 905,CWE-20,"CWE-20 int parse_rock_ridge_inode ( struct iso_directory_record * de , struct inode * inode ) { int result = parse_rock_ridge_inode_internal ( de , inode , 0 ) ; if ( ( ISOFS_SB ( inode -> i_sb ) -> s_rock_offset == - 1 ) && ( ISOFS_SB ( inode -> i_sb ) -> s_rock == 2 ) ) { result = parse_rock_ridge_inode_internal ( de , inode , 14 ) ; } return result ; } "," inode * inode , int relocated ) { int flags = relocated ? RR_RELOC_DE : 0 ; int result = , inode , flags ) ; if , inode , flags | RR_REGARD_XA ) ; } ",torvalds@linux/410dd3cf4c9b36f27ed4542ee18b1af5e68645a4,CVE-2014-5472,https://github.com/torvalds/linux/commit/410dd3cf4c9b36f27ed4542ee18b1af5e68645a4,2014-09-01T01:55Z 906,CWE-399,"CWE-399 static struct fsnotify_group * inotify_new_group ( struct user_struct * user , unsigned int max_events ) { struct fsnotify_group * group ; group = fsnotify_alloc_group ( & inotify_fsnotify_ops ) ; if ( IS_ERR ( group ) ) return group ; group -> max_events = max_events ; spin_lock_init ( & group -> inotify_data . idr_lock ) ; idr_init ( & group -> inotify_data . idr ) ; group -> inotify_data . last_wd = 0 ; group -> inotify_data . user = user ; group -> inotify_data . fa = NULL ; return group ; } "," * inotify_new_group ( unsigned int max_events -> inotify_data . fa = NULL ; group -> -> inotify_data . user = get_current_user ( ) ; if ( atomic_inc_return ( & group -> inotify_data . user -> inotify_devs ) > inotify_max_user_instances ) { fsnotify_put_group ( group ) ; return ERR_PTR ( - EMFILE ) ; } return group ; ",torvalds@linux/d0de4dc584ec6aa3b26fffea320a8457827768fc,CVE-2011-1479,https://github.com/torvalds/linux/commit/d0de4dc584ec6aa3b26fffea320a8457827768fc,2012-06-21T23:55Z 907,CWE-119,"CWE-119 static int filter_frame ( AVFilterLink * inlink , AVFrame * in ) { GradFunContext * s = inlink -> dst -> priv ; AVFilterLink * outlink = inlink -> dst -> outputs [ 0 ] ; AVFrame * out ; int p , direct ; if ( av_frame_is_writable ( in ) ) { direct = 1 ; out = in ; } else { direct = 0 ; out = ff_get_video_buffer ( outlink , outlink -> w , outlink -> h ) ; if ( ! out ) { av_frame_free ( & in ) ; return AVERROR ( ENOMEM ) ; } av_frame_copy_props ( out , in ) ; } for ( p = 0 ; p < 4 && in -> data [ p ] ; p ++ ) { int w = inlink -> w ; int h = inlink -> h ; int r = s -> radius ; if ( p ) { w = s -> chroma_w ; h = s -> chroma_h ; r = s -> chroma_r ; } if ( FFMIN ( w , h ) > 2 * r ) filter ( s , out -> data [ p ] , in -> data [ p ] , w , h , out -> linesize [ p ] , in -> linesize [ p ] , r ) ; else if ( out -> data [ p ] != in -> data [ p ] ) av_image_copy_plane ( out -> data [ p ] , out -> linesize [ p ] , in -> data [ p ] , in -> linesize [ p ] , w , h ) ; } if ( ! direct ) av_frame_free ( & in ) ; return ff_filter_frame ( outlink , out ) ; } "," [ p ] && in -> linesize [ p ] ",FFmpeg@FFmpeg/e43a0a232dbf6d3c161823c2e07c52e76227a1bc,CVE-2013-4263,https://github.com/FFmpeg/FFmpeg/commit/e43a0a232dbf6d3c161823c2e07c52e76227a1bc,2013-11-23T17:55Z 908,CWE-189,"CWE-189 Datum hstore_recv ( PG_FUNCTION_ARGS ) { int32 buflen ; HStore * out ; Pairs * pairs ; int32 i ; int32 pcount ; StringInfo buf = ( StringInfo ) PG_GETARG_POINTER ( 0 ) ; pcount = pq_getmsgint ( buf , 4 ) ; if ( pcount == 0 ) { out = hstorePairs ( NULL , 0 , 0 ) ; PG_RETURN_POINTER ( out ) ; } pairs = palloc ( pcount * sizeof ( Pairs ) ) ; for ( i = 0 ; i < pcount ; ++ i ) { int rawlen = pq_getmsgint ( buf , 4 ) ; int len ; if ( rawlen < 0 ) ereport ( ERROR , ( errcode ( ERRCODE_NULL_VALUE_NOT_ALLOWED ) , errmsg ( ""nullvaluenotallowedforhstorekey"" ) ) ) ; pairs [ i ] . key = pq_getmsgtext ( buf , rawlen , & len ) ; pairs [ i ] . keylen = hstoreCheckKeyLen ( len ) ; pairs [ i ] . needfree = true ; rawlen = pq_getmsgint ( buf , 4 ) ; if ( rawlen < 0 ) { pairs [ i ] . val = NULL ; pairs [ i ] . vallen = 0 ; pairs [ i ] . isnull = true ; } else { pairs [ i ] . val = pq_getmsgtext ( buf , rawlen , & len ) ; pairs [ i ] . vallen = hstoreCheckValLen ( len ) ; pairs [ i ] . isnull = false ; } } pcount = hstoreUniquePairs ( pairs , pcount , & buflen ) ; out = hstorePairs ( pairs , pcount , buflen ) ; PG_RETURN_POINTER ( out ) ; } "," ) ; } if ( pcount < 0 || pcount > MaxAllocSize / sizeof ( Pairs ) ) ereport ( ERROR , ( errcode ( ERRCODE_PROGRAM_LIMIT_EXCEEDED ) , errmsg ( ""numberofpairs(%d)exceedsthemaximumallowed(%d)"" , pcount , ( int ) ( MaxAllocSize / sizeof ( Pairs ) ) ) ) ) ; ",postgres@postgres/31400a673325147e1205326008e32135a78b4d8a,CVE-2014-2669,https://github.com/postgres/postgres/commit/31400a673325147e1205326008e32135a78b4d8a,2014-03-31T14:58Z 909,CWE-476,"CWE-476 INTERNAL void vterm_screen_free ( VTermScreen * screen ) { vterm_allocator_free ( screen -> vt , screen -> buffers [ 0 ] ) ; if ( screen -> buffers [ 1 ] ) vterm_allocator_free ( screen -> vt , screen -> buffers [ 1 ] ) ; vterm_allocator_free ( screen -> vt , screen -> sb_buffer ) ; vterm_allocator_free ( screen -> vt , screen ) ; } "," ] ) ; vterm_allocator_free ( screen ",vim@vim/cd929f7ba8cc5b6d6dcf35c8b34124e969fed6b8,CVE-2018-20786,https://github.com/vim/vim/commit/cd929f7ba8cc5b6d6dcf35c8b34124e969fed6b8,2019-02-24T14:29Z 910,CWE-119,"CWE-119 static int check_mem_access ( struct bpf_verifier_env * env , int insn_idx , u32 regno , int off , int bpf_size , enum bpf_access_type t , int value_regno ) { struct bpf_verifier_state * state = env -> cur_state ; struct bpf_reg_state * regs = cur_regs ( env ) ; struct bpf_reg_state * reg = regs + regno ; int size , err = 0 ; size = bpf_size_to_bytes ( bpf_size ) ; if ( size < 0 ) return size ; err = check_ptr_alignment ( env , reg , off , size ) ; if ( err ) return err ; off += reg -> off ; if ( reg -> type == PTR_TO_MAP_VALUE ) { if ( t == BPF_WRITE && value_regno >= 0 && is_pointer_value ( env , value_regno ) ) { verbose ( env , ""R%dleaksaddrintomap\\n"" , value_regno ) ; return - EACCES ; } err = check_map_access ( env , regno , off , size , false ) ; if ( ! err && t == BPF_READ && value_regno >= 0 ) mark_reg_unknown ( env , regs , value_regno ) ; } else if ( reg -> type == PTR_TO_CTX ) { enum bpf_reg_type reg_type = SCALAR_VALUE ; if ( t == BPF_WRITE && value_regno >= 0 && is_pointer_value ( env , value_regno ) ) { verbose ( env , ""R%dleaksaddrintoctx\\n"" , value_regno ) ; return - EACCES ; } if ( reg -> off ) { verbose ( env , ""dereferenceofmodifiedctxptrR%doff=%d+%d,ctx+constisallowed,ctx+const+constisnot\\n"" , regno , reg -> off , off - reg -> off ) ; return - EACCES ; } if ( ! tnum_is_const ( reg -> var_off ) || reg -> var_off . value ) { char tn_buf [ 48 ] ; tnum_strn ( tn_buf , sizeof ( tn_buf ) , reg -> var_off ) ; verbose ( env , ""variablectxaccessvar_off=%soff=%dsize=%d"" , tn_buf , off , size ) ; return - EACCES ; } err = check_ctx_access ( env , insn_idx , off , size , t , & reg_type ) ; if ( ! err && t == BPF_READ && value_regno >= 0 ) { if ( reg_type == SCALAR_VALUE ) mark_reg_unknown ( env , regs , value_regno ) ; else mark_reg_known_zero ( env , regs , value_regno ) ; regs [ value_regno ] . id = 0 ; regs [ value_regno ] . off = 0 ; regs [ value_regno ] . range = 0 ; regs [ value_regno ] . type = reg_type ; } } else if ( reg -> type == PTR_TO_STACK ) { if ( ! tnum_is_const ( reg -> var_off ) ) { char tn_buf [ 48 ] ; tnum_strn ( tn_buf , sizeof ( tn_buf ) , reg -> var_off ) ; verbose ( env , ""variablestackaccessvar_off=%soff=%dsize=%d"" , tn_buf , off , size ) ; return - EACCES ; } off += reg -> var_off . value ; if ( off >= 0 || off < - MAX_BPF_STACK ) { verbose ( env , ""invalidstackoff=%dsize=%d\\n"" , off , size ) ; return - EACCES ; } if ( env -> prog -> aux -> stack_depth < - off ) env -> prog -> aux -> stack_depth = - off ; if ( t == BPF_WRITE ) err = check_stack_write ( env , state , off , size , value_regno ) ; else err = check_stack_read ( env , state , off , size , value_regno ) ; } else if ( reg_is_pkt_pointer ( reg ) ) { if ( t == BPF_WRITE && ! may_access_direct_pkt_data ( env , NULL , t ) ) { verbose ( env , ""cannotwriteintopacket\\n"" ) ; return - EACCES ; } if ( t == BPF_WRITE && value_regno >= 0 && is_pointer_value ( env , value_regno ) ) { verbose ( env , ""R%dleaksaddrintopacket\\n"" , value_regno ) ; return - EACCES ; } err = check_packet_access ( env , regno , off , size , false ) ; if ( ! err && t == BPF_READ && value_regno >= 0 ) mark_reg_unknown ( env , regs , value_regno ) ; } else { verbose ( env , ""R%dinvalidmemaccess\'%s\'\\n"" , regno , reg_type_str [ reg -> type ] ) ; return - EACCES ; } if ( ! err && size < BPF_REG_SIZE && value_regno >= 0 && t == BPF_READ && regs [ value_regno ] . type == SCALAR_VALUE ) { regs [ value_regno ] . var_off = tnum_cast ( regs [ value_regno ] . var_off , size ) ; __update_reg_bounds ( & regs [ value_regno ] ) ; } return err ; } "," SCALAR_VALUE ) { coerce_reg_to_size ( & [ value_regno ] , size ) ; } ",torvalds@linux/0c17d1d2c61936401f4702e1846e2c19b200f958,CVE-2017-16996,https://github.com/torvalds/linux/commit/0c17d1d2c61936401f4702e1846e2c19b200f958,2017-12-27T17:08Z 911,CWE-190,"CWE-190 static int readContigStripsIntoBuffer ( TIFF * in , uint8 * buf ) { uint8 * bufp = buf ; int32 bytes_read = 0 ; uint16 strip , nstrips = TIFFNumberOfStrips ( in ) ; uint32 stripsize = TIFFStripSize ( in ) ; uint32 rows = 0 ; uint32 rps = TIFFGetFieldDefaulted ( in , TIFFTAG_ROWSPERSTRIP , & rps ) ; tsize_t scanline_size = TIFFScanlineSize ( in ) ; if ( scanline_size == 0 ) { TIFFError ( """" , ""TIFFscanlinesizeiszero!"" ) ; return 0 ; } for ( strip = 0 ; strip < nstrips ; strip ++ ) { bytes_read = TIFFReadEncodedStrip ( in , strip , bufp , - 1 ) ; rows = bytes_read / scanline_size ; if ( ( strip < ( nstrips - 1 ) ) && ( bytes_read != ( int32 ) stripsize ) ) TIFFError ( """" , ""Strip%d:read%lubytes,stripsize%lu"" , ( int ) strip + 1 , ( unsigned long ) bytes_read , ( unsigned long ) stripsize ) ; if ( bytes_read < 0 && ! ignore ) { TIFFError ( """" , ""Errorreadingstrip%luafter%lurows"" , ( unsigned long ) strip , ( unsigned long ) rows ) ; return 0 ; } bufp += bytes_read ; } return 1 ; } "," = 0 ; uint32 strip , nstrips ",vadz@libtiff/43c0b81a818640429317c80fea1e66771e85024b,CVE-2016-9538,https://github.com/vadz/libtiff/commit/43c0b81a818640429317c80fea1e66771e85024b,2016-11-22T19:59Z 912,CWE-125,"CWE-125 static char * search_make_new ( const struct search_state * const state , int n , const char * const base_name ) { const size_t base_len = strlen ( base_name ) ; const char need_to_append_dot = base_name [ base_len - 1 ] == '.' ? 0 : 1 ; struct search_domain * dom ; for ( dom = state -> head ; dom ; dom = dom -> next ) { if ( ! n -- ) { const u8 * const postfix = ( ( u8 * ) dom ) + sizeof ( struct search_domain ) ; const int postfix_len = dom -> len ; char * const newname = ( char * ) mm_malloc ( base_len + need_to_append_dot + postfix_len + 1 ) ; if ( ! newname ) return NULL ; memcpy ( newname , base_name , base_len ) ; if ( need_to_append_dot ) newname [ base_len ] = '.' ; memcpy ( newname + base_len + need_to_append_dot , postfix , postfix_len ) ; newname [ base_len + need_to_append_dot + postfix_len ] = 0 ; return newname ; } } EVUTIL_ASSERT ( 0 ) ; return NULL ; } "," base_name ) ; char need_to_append_dot ; struct search_domain * dom ; if ( ! base_len ) return NULL ; need_to_append_dot = base_name : 1 ; for ( dom ",libevent@libevent/ec65c42052d95d2c23d1d837136d1cf1d9ecef9e,CVE-2016-10197,https://github.com/libevent/libevent/commit/ec65c42052d95d2c23d1d837136d1cf1d9ecef9e,2017-03-15T15:59Z 913,CWE-284,"CWE-284 void GKI_delay ( UINT32 timeout_ms ) { struct timespec delay ; delay . tv_sec = timeout_ms / 1000 ; delay . tv_nsec = 1000 * 1000 * ( timeout_ms % 1000 ) ; int err ; do { err = nanosleep ( & delay , & delay ) ; } while ( err == - 1 && errno == EINTR ) ; } "," { err = TEMP_FAILURE_RETRY ( , & delay ) ",system@bt/472271b153c5dc53c28beac55480a8d8434b2d5c,CVE-2016-3839,https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c,2016-08-05T20:59Z 914,CWE-20,"CWE-20 static int caif_stream_recvmsg ( struct kiocb * iocb , struct socket * sock , struct msghdr * msg , size_t size , int flags ) { struct sock * sk = sock -> sk ; int copied = 0 ; int target ; int err = 0 ; long timeo ; err = - EOPNOTSUPP ; if ( flags & MSG_OOB ) goto out ; msg -> msg_namelen = 0 ; err = - EAGAIN ; if ( sk -> sk_state == CAIF_CONNECTING ) goto out ; caif_read_lock ( sk ) ; target = sock_rcvlowat ( sk , flags & MSG_WAITALL , size ) ; timeo = sock_rcvtimeo ( sk , flags & MSG_DONTWAIT ) ; do { int chunk ; struct sk_buff * skb ; lock_sock ( sk ) ; skb = skb_dequeue ( & sk -> sk_receive_queue ) ; caif_check_flow_release ( sk ) ; if ( skb == NULL ) { if ( copied >= target ) goto unlock ; err = sock_error ( sk ) ; if ( err ) goto unlock ; err = - ECONNRESET ; if ( sk -> sk_shutdown & RCV_SHUTDOWN ) goto unlock ; err = - EPIPE ; if ( sk -> sk_state != CAIF_CONNECTED ) goto unlock ; if ( sock_flag ( sk , SOCK_DEAD ) ) goto unlock ; release_sock ( sk ) ; err = - EAGAIN ; if ( ! timeo ) break ; caif_read_unlock ( sk ) ; timeo = caif_stream_data_wait ( sk , timeo ) ; if ( signal_pending ( current ) ) { err = sock_intr_errno ( timeo ) ; goto out ; } caif_read_lock ( sk ) ; continue ; unlock : release_sock ( sk ) ; break ; } release_sock ( sk ) ; chunk = min_t ( unsigned int , skb -> len , size ) ; if ( memcpy_toiovec ( msg -> msg_iov , skb -> data , chunk ) ) { skb_queue_head ( & sk -> sk_receive_queue , skb ) ; if ( copied == 0 ) copied = - EFAULT ; break ; } copied += chunk ; size -= chunk ; if ( ! ( flags & MSG_PEEK ) ) { skb_pull ( skb , chunk ) ; if ( skb -> len ) { skb_queue_head ( & sk -> sk_receive_queue , skb ) ; break ; } kfree_skb ( skb ) ; } else { skb_queue_head ( & sk -> sk_receive_queue , skb ) ; break ; } } while ( size ) ; caif_read_unlock ( sk ) ; out : return copied ? : err ; } "," goto out ; err = - ",torvalds@linux/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,CVE-2013-7271,https://github.com/torvalds/linux/commit/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,2014-01-06T16:55Z 915,CWE-119,"CWE-119 static Image * ReadRLEImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define SkipLinesOp 0x01 # define SetColorOp 0x02 # define SkipPixelsOp 0x03 # define ByteDataOp 0x05 # define RunDataOp 0x06 # define EOFOp 0x07 char magick [ 12 ] ; Image * image ; int opcode , operand , status ; MagickStatusType flags ; MagickSizeType number_pixels ; MemoryInfo * pixel_info ; Quantum index ; register ssize_t x ; register Quantum * q ; register ssize_t i ; register unsigned char * p ; size_t bits_per_pixel , map_length , number_colormaps , number_planes , number_planes_filled , one , offset , pixel_info_length ; ssize_t count , y ; unsigned char background_color [ 256 ] , * colormap , pixel , plane , * pixels ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; count = ReadBlob ( image , 2 , ( unsigned char * ) magick ) ; if ( ( count != 2 ) || ( memcmp ( magick , ""\\122\\314"" , 2 ) != 0 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; do { image -> page . x = ReadBlobLSBShort ( image ) ; image -> page . y = ReadBlobLSBShort ( image ) ; image -> columns = ReadBlobLSBShort ( image ) ; image -> rows = ReadBlobLSBShort ( image ) ; flags = ( MagickStatusType ) ReadBlobByte ( image ) ; image -> alpha_trait = flags & 0x04 ? BlendPixelTrait : UndefinedPixelTrait ; number_planes = ( size_t ) ReadBlobByte ( image ) ; bits_per_pixel = ( size_t ) ReadBlobByte ( image ) ; number_colormaps = ( size_t ) ReadBlobByte ( image ) ; map_length = ( unsigned char ) ReadBlobByte ( image ) ; if ( map_length >= 64 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; one = 1 ; map_length = one << map_length ; if ( ( number_planes == 0 ) || ( number_planes == 2 ) || ( ( flags & 0x04 ) && ( number_colormaps > 254 ) ) || ( bits_per_pixel != 8 ) || ( image -> columns == 0 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( flags & 0x02 ) { for ( i = 0 ; i < ( ssize_t ) number_planes ; i ++ ) background_color [ i ] = 0 ; ( void ) ReadBlobByte ( image ) ; } else { p = background_color ; for ( i = 0 ; i < ( ssize_t ) number_planes ; i ++ ) * p ++ = ( unsigned char ) ReadBlobByte ( image ) ; } if ( ( number_planes & 0x01 ) == 0 ) ( void ) ReadBlobByte ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } colormap = ( unsigned char * ) NULL ; if ( number_colormaps != 0 ) { colormap = ( unsigned char * ) AcquireQuantumMemory ( number_colormaps , 3 * map_length * sizeof ( * colormap ) ) ; if ( colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; p = colormap ; for ( i = 0 ; i < ( ssize_t ) number_colormaps ; i ++ ) for ( x = 0 ; x < ( ssize_t ) map_length ; x ++ ) * p ++ = ( unsigned char ) ScaleShortToQuantum ( ReadBlobLSBShort ( image ) ) ; } if ( ( flags & 0x08 ) != 0 ) { char * comment ; size_t length ; length = ReadBlobLSBShort ( image ) ; if ( length != 0 ) { comment = ( char * ) AcquireQuantumMemory ( length , sizeof ( * comment ) ) ; if ( comment == ( char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; count = ReadBlob ( image , length - 1 , ( unsigned char * ) comment ) ; comment [ length - 1 ] = '\\0' ; ( void ) SetImageProperty ( image , ""comment"" , comment , exception ) ; comment = DestroyString ( comment ) ; if ( ( length & 0x01 ) == 0 ) ( void ) ReadBlobByte ( image ) ; } } if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; if ( image -> alpha_trait != UndefinedPixelTrait ) number_planes ++ ; number_pixels = ( MagickSizeType ) image -> columns * image -> rows ; number_planes_filled = ( number_planes % 2 == 0 ) ? number_planes : number_planes + 1 ; if ( ( number_pixels * number_planes_filled ) != ( size_t ) ( number_pixels * number_planes_filled ) ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; pixel_info = AcquireVirtualMemory ( image -> columns , image -> rows * MagickMax ( number_planes_filled , 4 ) * sizeof ( * pixels ) ) ; if ( pixel_info == ( MemoryInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; pixel_info_length = image -> columns * image -> rows * MagickMax ( number_planes_filled , 4 ) ; pixels = ( unsigned char * ) GetVirtualMemoryBlob ( pixel_info ) ; if ( ( flags & 0x01 ) && ! ( flags & 0x02 ) ) { ssize_t j ; p = pixels ; for ( i = 0 ; i < ( ssize_t ) number_pixels ; i ++ ) { if ( image -> alpha_trait == UndefinedPixelTrait ) for ( j = 0 ; j < ( ssize_t ) number_planes ; j ++ ) * p ++ = background_color [ j ] ; else { for ( j = 0 ; j < ( ssize_t ) ( number_planes - 1 ) ; j ++ ) * p ++ = background_color [ j ] ; * p ++ = 0 ; } } } plane = 0 ; x = 0 ; y = 0 ; opcode = ReadBlobByte ( image ) ; do { switch ( opcode & 0x3f ) { case SkipLinesOp : { operand = ReadBlobByte ( image ) ; if ( opcode & 0x40 ) operand = ReadBlobLSBSignedShort ( image ) ; x = 0 ; y += operand ; break ; } case SetColorOp : { operand = ReadBlobByte ( image ) ; plane = ( unsigned char ) operand ; if ( plane == 255 ) plane = ( unsigned char ) ( number_planes - 1 ) ; x = 0 ; break ; } case SkipPixelsOp : { operand = ReadBlobByte ( image ) ; if ( opcode & 0x40 ) operand = ReadBlobLSBSignedShort ( image ) ; x += operand ; break ; } case ByteDataOp : { operand = ReadBlobByte ( image ) ; if ( opcode & 0x40 ) operand = ReadBlobLSBSignedShort ( image ) ; offset = ( ( image -> rows - y - 1 ) * image -> columns * number_planes ) + x * number_planes + plane ; operand ++ ; if ( offset + ( ( size_t ) operand * number_planes ) > pixel_info_length ) { if ( number_colormaps != 0 ) colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; } p = pixels + offset ; for ( i = 0 ; i < ( ssize_t ) operand ; i ++ ) { pixel = ( unsigned char ) ReadBlobByte ( image ) ; if ( ( y < ( ssize_t ) image -> rows ) && ( ( x + i ) < ( ssize_t ) image -> columns ) ) * p = pixel ; p += number_planes ; } if ( operand & 0x01 ) ( void ) ReadBlobByte ( image ) ; x += operand ; break ; } case RunDataOp : { operand = ReadBlobByte ( image ) ; if ( opcode & 0x40 ) operand = ReadBlobLSBSignedShort ( image ) ; pixel = ( unsigned char ) ReadBlobByte ( image ) ; ( void ) ReadBlobByte ( image ) ; offset = ( ( image -> rows - y - 1 ) * image -> columns * number_planes ) + x * number_planes + plane ; operand ++ ; if ( offset + ( ( size_t ) operand * number_planes ) > pixel_info_length ) { if ( number_colormaps != 0 ) colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; } p = pixels + offset ; for ( i = 0 ; i < ( ssize_t ) operand ; i ++ ) { if ( ( y < ( ssize_t ) image -> rows ) && ( ( x + i ) < ( ssize_t ) image -> columns ) ) * p = pixel ; p += number_planes ; } x += operand ; break ; } default : break ; } opcode = ReadBlobByte ( image ) ; } while ( ( ( opcode & 0x3f ) != EOFOp ) && ( opcode != EOF ) ) ; if ( number_colormaps != 0 ) { MagickStatusType mask ; mask = ( MagickStatusType ) ( map_length - 1 ) ; p = pixels ; x = ( ssize_t ) number_planes ; if ( number_colormaps == 1 ) for ( i = 0 ; i < ( ssize_t ) number_pixels ; i ++ ) { ValidateColormapValue ( image , * p & mask , & index , exception ) ; * p = colormap [ ( ssize_t ) index ] ; p ++ ; } else if ( ( number_planes >= 3 ) && ( number_colormaps >= 3 ) ) for ( i = 0 ; i < ( ssize_t ) number_pixels ; i ++ ) for ( x = 0 ; x < ( ssize_t ) number_planes ; x ++ ) { ValidateColormapValue ( image , ( size_t ) ( x * map_length + ( * p & mask ) ) , & index , exception ) ; * p = colormap [ ( ssize_t ) index ] ; p ++ ; } if ( ( i < ( ssize_t ) number_pixels ) || ( x < ( ssize_t ) number_planes ) ) { colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; } } if ( number_planes >= 3 ) { p = pixels ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelGreen ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelBlue ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; if ( image -> alpha_trait != UndefinedPixelTrait ) SetPixelAlpha ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } else { if ( number_colormaps == 0 ) map_length = 256 ; if ( AcquireImageColormap ( image , map_length , exception ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; p = colormap ; if ( number_colormaps == 1 ) for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { image -> colormap [ i ] . red = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) i ) ; image -> colormap [ i ] . green = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) i ) ; image -> colormap [ i ] . blue = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) i ) ; } else if ( number_colormaps > 1 ) for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { image -> colormap [ i ] . red = ( MagickRealType ) ScaleCharToQuantum ( * p ) ; image -> colormap [ i ] . green = ( MagickRealType ) ScaleCharToQuantum ( * ( p + map_length ) ) ; image -> colormap [ i ] . blue = ( MagickRealType ) ScaleCharToQuantum ( * ( p + map_length * 2 ) ) ; p ++ ; } p = pixels ; if ( image -> alpha_trait == UndefinedPixelTrait ) { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelIndex ( image , * p ++ , q ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } ( void ) SyncImage ( image , exception ) ; } else { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { ValidateColormapValue ( image , ( ssize_t ) * p ++ , & index , exception ) ; SetPixelRed ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) index ] . red ) , q ) ; ValidateColormapValue ( image , ( ssize_t ) * p ++ , & index , exception ) ; SetPixelGreen ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) index ] . green ) , q ) ; ValidateColormapValue ( image , ( ssize_t ) * p ++ , & index , exception ) ; SetPixelBlue ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) index ] . blue ) , q ) ; SetPixelAlpha ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; q += GetPixelChannels ( image ) ; } if ( x < ( ssize_t ) image -> columns ) break ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } image -> colormap = ( PixelInfo * ) RelinquishMagickMemory ( image -> colormap ) ; image -> storage_class = DirectClass ; image -> colors = 0 ; } } if ( number_colormaps != 0 ) colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; pixel_info = RelinquishVirtualMemory ( pixel_info ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; ( void ) ReadBlobByte ( image ) ; count = ReadBlob ( image , 2 , ( unsigned char * ) magick ) ; if ( ( count != 0 ) && ( memcmp ( magick , ""\\122\\314"" , 2 ) == 0 ) ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( ( count != 0 ) && ( memcmp ( magick , ""\\122\\314"" , 2 ) == 0 ) ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," , one , pixel_info_length ; ssize_t count , offset , y ; ; if ( ( offset < 0 ) || ( ) > pixel_info_length ) ; if ( ( offset < 0 ) || ( ) > pixel_info_length ) ",ImageMagick@ImageMagick/139d4323c40d7363bfdd2382c3821a6f76d69430,CVE-2016-10050,https://github.com/ImageMagick/ImageMagick/commit/139d4323c40d7363bfdd2382c3821a6f76d69430,2017-03-23T17:59Z 916,CWE-787,"CWE-787 static void nsc_rle_decompress_data ( NSC_CONTEXT * context ) { UINT16 i ; BYTE * rle ; UINT32 planeSize ; UINT32 originalSize ; rle = context -> Planes ; for ( i = 0 ; i < 4 ; i ++ ) { originalSize = context -> OrgByteCount [ i ] ; planeSize = context -> PlaneByteCount [ i ] ; if ( planeSize == 0 ) FillMemory ( context -> priv -> PlaneBuffers [ i ] , originalSize , 0xFF ) ; else if ( planeSize < originalSize ) nsc_rle_decode ( rle , context -> priv -> PlaneBuffers [ i ] , originalSize ) ; else CopyMemory ( context -> priv -> PlaneBuffers [ i ] , rle , originalSize ) ; rle += planeSize ; } } "," static BOOL nsc_rle_decompress_data ( NSC_CONTEXT UINT32 originalSize ; if ( ! context ) return FALSE ; == 0 ) { if ( context -> priv -> PlaneBuffersLength < originalSize ) return FALSE ; 0xFF ) ; } < originalSize ) { if ( ! i ] , context -> priv -> PlaneBuffersLength , originalSize ) ) return FALSE ; } else { if ( context -> priv -> PlaneBuffersLength < originalSize ) return FALSE ; CopyMemory ( context originalSize ) ; } planeSize ; } return TRUE ; ",FreeRDP@FreeRDP/d1112c279bd1a327e8e4d0b5f371458bf2579659,CVE-2018-8788,https://github.com/FreeRDP/FreeRDP/commit/d1112c279bd1a327e8e4d0b5f371458bf2579659,2018-11-29T18:29Z 917,CWE-264,"CWE-264 int fscrypt_process_policy ( struct inode * inode , const struct fscrypt_policy * policy ) { if ( policy -> version != 0 ) return - EINVAL ; if ( ! inode_has_encryption_context ( inode ) ) { if ( ! inode -> i_sb -> s_cop -> empty_dir ) return - EOPNOTSUPP ; if ( ! inode -> i_sb -> s_cop -> empty_dir ( inode ) ) return - ENOTEMPTY ; return create_encryption_context_from_policy ( inode , policy ) ; } if ( is_encryption_context_consistent_with_policy ( inode , policy ) ) return 0 ; printk ( KERN_WARNING ""%s:Policyinconsistentwithencryptioncontext\\n"" , __func__ ) ; return - EINVAL ; } "," policy ) { if ( ! inode_owner_or_capable ( inode ) ) return - EACCES ; ",torvalds@linux/163ae1c6ad6299b19e22b4a35d5ab24a89791a98,CVE-2016-10318,https://github.com/torvalds/linux/commit/163ae1c6ad6299b19e22b4a35d5ab24a89791a98,2017-04-04T16:59Z 918,CWE-000,"CWE-000 static int virtualHostDirective ( MaState * state , cchar * key , cchar * value ) { state = maPushState ( state ) ; if ( state -> enabled ) { state -> route = httpCreateInheritedRoute ( httpGetHostDefaultRoute ( state -> host ) ) ; state -> route -> ssl = 0 ; state -> auth = state -> route -> auth ; state -> host = httpCloneHost ( state -> host ) ; httpResetRoutes ( state -> host ) ; httpSetRouteHost ( state -> route , state -> host ) ; httpSetHostDefaultRoute ( state -> host , state -> route ) ; if ( value ) { httpSetHostName ( state -> host , stok ( sclone ( value ) , ""\\t,"" , NULL ) ) ; httpSetRouteName ( state -> route , sfmt ( ""default-%s"" , state -> host -> name ) ) ; state -> endpoints = sclone ( value ) ; } } return 0 ; } "," -> host , ssplit ( sclone ( ",embedthis@appweb/7e6a925f5e86a19a7934a94bbd6959101d0b84eb,CVE-2014-9708,https://github.com/embedthis/appweb/commit/7e6a925f5e86a19a7934a94bbd6959101d0b84eb,2015-03-31T14:59Z 919,CWE-476,"CWE-476 struct key * request_key_and_link ( struct key_type * type , const char * description , const void * callout_info , size_t callout_len , void * aux , struct key * dest_keyring , unsigned long flags ) { struct keyring_search_context ctx = { . index_key . type = type , . index_key . description = description , . cred = current_cred ( ) , . match_data . cmp = type -> match , . match_data . raw_data = description , . match_data . lookup_type = KEYRING_SEARCH_LOOKUP_DIRECT , } ; struct key * key ; key_ref_t key_ref ; int ret ; kenter ( ""%s,%s,%p,%zu,%p,%p,%lx"" , ctx . index_key . type -> name , ctx . index_key . description , callout_info , callout_len , aux , dest_keyring , flags ) ; if ( type -> match_preparse ) { ret = type -> match_preparse ( & ctx . match_data ) ; if ( ret < 0 ) { key = ERR_PTR ( ret ) ; goto error ; } } key_ref = search_process_keyrings ( & ctx ) ; if ( ! IS_ERR ( key_ref ) ) { key = key_ref_to_ptr ( key_ref ) ; if ( dest_keyring ) { construct_get_dest_keyring ( & dest_keyring ) ; ret = key_link ( dest_keyring , key ) ; key_put ( dest_keyring ) ; if ( ret < 0 ) { key_put ( key ) ; key = ERR_PTR ( ret ) ; goto error_free ; } } } else if ( PTR_ERR ( key_ref ) != - EAGAIN ) { key = ERR_CAST ( key_ref ) ; } else { key = ERR_PTR ( - ENOKEY ) ; if ( ! callout_info ) goto error_free ; key = construct_key_and_link ( & ctx , callout_info , callout_len , aux , dest_keyring , flags ) ; } error_free : if ( type -> match_free ) type -> match_free ( & ctx . match_data ) ; error : kleave ( ""=%p"" , key ) ; return key ; } "," . cmp = key_default_cmp , . match_data ",torvalds@linux/c06cfb08b88dfbe13be44a69ae2fdc3a7c902d81,CVE-2017-2647,https://github.com/torvalds/linux/commit/c06cfb08b88dfbe13be44a69ae2fdc3a7c902d81,2017-03-31T04:59Z 920,CWE-200,"CWE-200 static int rawv6_recvmsg ( struct kiocb * iocb , struct sock * sk , struct msghdr * msg , size_t len , int noblock , int flags , int * addr_len ) { struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct sockaddr_in6 * sin6 = ( struct sockaddr_in6 * ) msg -> msg_name ; struct sk_buff * skb ; size_t copied ; int err ; if ( flags & MSG_OOB ) return - EOPNOTSUPP ; if ( addr_len ) * addr_len = sizeof ( * sin6 ) ; if ( flags & MSG_ERRQUEUE ) return ipv6_recv_error ( sk , msg , len ) ; if ( np -> rxpmtu && np -> rxopt . bits . rxpmtu ) return ipv6_recv_rxpmtu ( sk , msg , len ) ; skb = skb_recv_datagram ( sk , flags , noblock , & err ) ; if ( ! skb ) goto out ; copied = skb -> len ; if ( copied > len ) { copied = len ; msg -> msg_flags |= MSG_TRUNC ; } if ( skb_csum_unnecessary ( skb ) ) { err = skb_copy_datagram_iovec ( skb , 0 , msg -> msg_iov , copied ) ; } else if ( msg -> msg_flags & MSG_TRUNC ) { if ( __skb_checksum_complete ( skb ) ) goto csum_copy_err ; err = skb_copy_datagram_iovec ( skb , 0 , msg -> msg_iov , copied ) ; } else { err = skb_copy_and_csum_datagram_iovec ( skb , 0 , msg -> msg_iov ) ; if ( err == - EINVAL ) goto csum_copy_err ; } if ( err ) goto out_free ; if ( sin6 ) { sin6 -> sin6_family = AF_INET6 ; sin6 -> sin6_port = 0 ; sin6 -> sin6_addr = ipv6_hdr ( skb ) -> saddr ; sin6 -> sin6_flowinfo = 0 ; sin6 -> sin6_scope_id = ipv6_iface_scope_id ( & sin6 -> sin6_addr , IP6CB ( skb ) -> iif ) ; } sock_recv_ts_and_drops ( msg , sk , skb ) ; if ( np -> rxopt . all ) ip6_datagram_recv_ctl ( sk , msg , skb ) ; err = copied ; if ( flags & MSG_TRUNC ) err = skb -> len ; out_free : skb_free_datagram ( sk , skb ) ; out : return err ; csum_copy_err : skb_kill_datagram ( sk , skb , flags ) ; err = ( flags & MSG_DONTWAIT ) ? - EAGAIN : - EHOSTUNREACH ; goto out ; } "," return - EOPNOTSUPP ; if ( ) -> iif ) ; * addr_len = sizeof ( * sin6 ",torvalds@linux/bceaa90240b6019ed73b49965eac7d167610be69,CVE-2013-7281,https://github.com/torvalds/linux/commit/bceaa90240b6019ed73b49965eac7d167610be69,2014-01-08T16:55Z 921,CWE-119,"CWE-119 static bool parse_notify ( struct pool * pool , json_t * val ) { char * job_id , * prev_hash , * coinbase1 , * coinbase2 , * bbversion , * nbit , * ntime , header [ 228 ] ; unsigned char * cb1 = NULL , * cb2 = NULL ; size_t cb1_len , cb2_len , alloc_len ; bool clean , ret = false ; int merkles , i ; json_t * arr ; arr = json_array_get ( val , 4 ) ; if ( ! arr || ! json_is_array ( arr ) ) goto out ; merkles = json_array_size ( arr ) ; job_id = json_array_string ( val , 0 ) ; prev_hash = __json_array_string ( val , 1 ) ; coinbase1 = json_array_string ( val , 2 ) ; coinbase2 = json_array_string ( val , 3 ) ; bbversion = __json_array_string ( val , 5 ) ; nbit = __json_array_string ( val , 6 ) ; ntime = __json_array_string ( val , 7 ) ; clean = json_is_true ( json_array_get ( val , 8 ) ) ; if ( ! job_id || ! prev_hash || ! coinbase1 || ! coinbase2 || ! bbversion || ! nbit || ! ntime ) { if ( job_id ) free ( job_id ) ; if ( coinbase1 ) free ( coinbase1 ) ; if ( coinbase2 ) free ( coinbase2 ) ; goto out ; } cg_wlock ( & pool -> data_lock ) ; free ( pool -> swork . job_id ) ; pool -> swork . job_id = job_id ; snprintf ( pool -> prev_hash , 65 , ""%s"" , prev_hash ) ; cb1_len = strlen ( coinbase1 ) / 2 ; cb2_len = strlen ( coinbase2 ) / 2 ; snprintf ( pool -> bbversion , 9 , ""%s"" , bbversion ) ; snprintf ( pool -> nbit , 9 , ""%s"" , nbit ) ; snprintf ( pool -> ntime , 9 , ""%s"" , ntime ) ; pool -> swork . clean = clean ; alloc_len = pool -> coinbase_len = cb1_len + pool -> n1_len + pool -> n2size + cb2_len ; pool -> nonce2_offset = cb1_len + pool -> n1_len ; for ( i = 0 ; i < pool -> merkles ; i ++ ) free ( pool -> swork . merkle_bin [ i ] ) ; if ( merkles ) { pool -> swork . merkle_bin = realloc ( pool -> swork . merkle_bin , sizeof ( char * ) * merkles + 1 ) ; for ( i = 0 ; i < merkles ; i ++ ) { char * merkle = json_array_string ( arr , i ) ; pool -> swork . merkle_bin [ i ] = malloc ( 32 ) ; if ( unlikely ( ! pool -> swork . merkle_bin [ i ] ) ) quit ( 1 , ""Failedtomallocpoolsworkmerkle_bin"" ) ; if ( opt_protocol ) applog ( LOG_DEBUG , ""merkle%d:%s"" , i , merkle ) ; ret = hex2bin ( pool -> swork . merkle_bin [ i ] , merkle , 32 ) ; free ( merkle ) ; if ( unlikely ( ! ret ) ) { applog ( LOG_ERR , ""Failedtoconvertmerkletomerkle_bininparse_notify"" ) ; goto out_unlock ; } } } pool -> merkles = merkles ; if ( clean ) pool -> nonce2 = 0 ; # if 0 header_len = strlen ( pool -> bbversion ) + strlen ( pool -> prev_hash ) ; 32 + strlen ( pool -> ntime ) + strlen ( pool -> nbit ) + 8 + 96 ; # endif snprintf ( header , 225 , ""%s%s%s%s%s%s%s"" , pool -> bbversion , pool -> prev_hash , blank_merkle , pool -> ntime , pool -> nbit , ""00000000"" , workpadding ) ; ret = hex2bin ( pool -> header_bin , header , 112 ) ; if ( unlikely ( ! ret ) ) { applog ( LOG_ERR , ""Failedtoconvertheadertoheader_bininparse_notify"" ) ; goto out_unlock ; } cb1 = alloca ( cb1_len ) ; ret = hex2bin ( cb1 , coinbase1 , cb1_len ) ; if ( unlikely ( ! ret ) ) { applog ( LOG_ERR , ""Failedtoconvertcb1tocb1_bininparse_notify"" ) ; goto out_unlock ; } cb2 = alloca ( cb2_len ) ; ret = hex2bin ( cb2 , coinbase2 , cb2_len ) ; if ( unlikely ( ! ret ) ) { applog ( LOG_ERR , ""Failedtoconvertcb2tocb2_bininparse_notify"" ) ; goto out_unlock ; } free ( pool -> coinbase ) ; align_len ( & alloc_len ) ; pool -> coinbase = calloc ( alloc_len , 1 ) ; if ( unlikely ( ! pool -> coinbase ) ) quit ( 1 , ""Failedtocallocpoolcoinbaseinparse_notify"" ) ; memcpy ( pool -> coinbase , cb1 , cb1_len ) ; memcpy ( pool -> coinbase + cb1_len , pool -> nonce1bin , pool -> n1_len ) ; memcpy ( pool -> coinbase + cb1_len + pool -> n1_len + pool -> n2size , cb2 , cb2_len ) ; if ( opt_debug ) { char * cb = bin2hex ( pool -> coinbase , pool -> coinbase_len ) ; applog ( LOG_DEBUG , ""Pool%dcoinbase%s"" , pool -> pool_no , cb ) ; free ( cb ) ; } out_unlock : cg_wunlock ( & pool -> data_lock ) ; if ( opt_protocol ) { applog ( LOG_DEBUG , ""job_id:%s"" , job_id ) ; applog ( LOG_DEBUG , ""prev_hash:%s"" , prev_hash ) ; applog ( LOG_DEBUG , ""coinbase1:%s"" , coinbase1 ) ; applog ( LOG_DEBUG , ""coinbase2:%s"" , coinbase2 ) ; applog ( LOG_DEBUG , ""bbversion:%s"" , bbversion ) ; applog ( LOG_DEBUG , ""nbit:%s"" , nbit ) ; applog ( LOG_DEBUG , ""ntime:%s"" , ntime ) ; applog ( LOG_DEBUG , ""clean:%s"" , clean ? ""yes"" : ""no"" ) ; } free ( coinbase1 ) ; free ( coinbase2 ) ; pool -> getwork_requested ++ ; total_getworks ++ ; if ( pool == current_pool ( ) ) opt_work_update = true ; out : return ret ; } "," if ( ! valid_hex ( job_id ) || ! valid_hex ( prev_hash ) || ! valid_hex ( coinbase1 ) || ! valid_hex ( coinbase2 ) || ! valid_hex ( bbversion ) || ! valid_hex ( nbit ) || ! valid_hex ( ntime ) ) { free ( job_id ) ( job_id ) ; free ( coinbase1 ) ; free ( coinbase2 ",sgminer-dev@sgminer/e1c5050734123973b99d181c45e74b2cbb00272e,CVE-2014-4502,https://github.com/sgminer-dev/sgminer/commit/e1c5050734123973b99d181c45e74b2cbb00272e,2014-07-23T14:55Z 922,CWE-284,"CWE-284 static uint16_t transmit_data_on ( int fd , uint8_t * data , uint16_t length ) { assert ( data != NULL ) ; assert ( length > 0 ) ; uint16_t transmitted_length = 0 ; while ( length > 0 ) { ssize_t ret = write ( fd , data + transmitted_length , length ) ; switch ( ret ) { case - 1 : LOG_ERROR ( ""In%s,errorwritingtotheserialportwithfd%d:%s"" , __func__ , fd , strerror ( errno ) ) ; return transmitted_length ; case 0 : return transmitted_length ; default : transmitted_length += ret ; length -= ret ; break ; } } return transmitted_length ; } "," ssize_t ret = TEMP_FAILURE_RETRY ( transmitted_length , length ) ",system@bt/472271b153c5dc53c28beac55480a8d8434b2d5c,CVE-2016-3839,https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c,2016-08-05T20:59Z 923,CWE-190,"CWE-190 void * xcalloc ( size_t num , size_t size ) { void * ptr = malloc ( num * size ) ; if ( ptr ) { memset ( ptr , '\\0' , ( num * size ) ) ; } return ptr ; } "," size ) { size_t res ; if ( check_mul_overflow ( num , size , & res ) ) abort ( ) ; void * ptr ; ptr = malloc = malloc ( res ) ; if '\\0' , ( res ) ) ; ",verdammelt@tnef/c5044689e50039635e7700fe2472fd632ac77176,CVE-2017-6308,https://github.com/verdammelt/tnef/commit/c5044689e50039635e7700fe2472fd632ac77176,2017-02-24T04:59Z 924,CWE-400,"CWE-400 void exit_io_context ( void ) { struct io_context * ioc ; task_lock ( current ) ; ioc = current -> io_context ; current -> io_context = NULL ; task_unlock ( current ) ; if ( atomic_dec_and_test ( & ioc -> nr_tasks ) ) { if ( ioc -> aic && ioc -> aic -> exit ) ioc -> aic -> exit ( ioc -> aic ) ; cfq_exit ( ioc ) ; put_io_context ( ioc ) ; } } "," ioc ) ; } ) ; } ",torvalds@linux/61cc74fbb87af6aa551a06a370590c9bc07e29d9,CVE-2012-0879,https://github.com/torvalds/linux/commit/61cc74fbb87af6aa551a06a370590c9bc07e29d9,2012-05-17T11:00Z 925,CWE-125,"CWE-125 static PyObject * ast_type_reduce ( PyObject * self , PyObject * unused ) { PyObject * res ; _Py_IDENTIFIER ( __dict__ ) ; PyObject * dict = _PyObject_GetAttrId ( self , & PyId___dict__ ) ; if ( dict == NULL ) { if ( PyErr_ExceptionMatches ( PyExc_AttributeError ) ) PyErr_Clear ( ) ; else return NULL ; } if ( dict ) { res = Py_BuildValue ( ""O()O"" , Py_TYPE ( self ) , dict ) ; Py_DECREF ( dict ) ; return res ; } return Py_BuildValue ( ""O()"" , Py_TYPE ( self ) ) ; } "," unused ) { _Py_IDENTIFIER ( __dict__ PyObject * dict ; if ( lookup_attr_id ( self , , & PyId___dict__ , & dict ) < 0 ) { return NULL ; dict ) { return Py_BuildValue ( ""O()N"" , Py_TYPE ( , dict ) ; } return ",python@typed_ast/156afcb26c198e162504a57caddfe0acd9ed7dce,CVE-2019-19275,https://github.com/python/typed_ast/commit/156afcb26c198e162504a57caddfe0acd9ed7dce,2019-11-26T15:15Z 926,CWE-400,"CWE-400 static int usb_enumerate_device_otg ( struct usb_device * udev ) { int err = 0 ; # ifdef CONFIG_USB_OTG if ( ! udev -> bus -> is_b_host && udev -> config && udev -> parent == udev -> bus -> root_hub ) { struct usb_otg_descriptor * desc = NULL ; struct usb_bus * bus = udev -> bus ; unsigned port1 = udev -> portnum ; err = __usb_get_extra_descriptor ( udev -> rawdescriptors [ 0 ] , le16_to_cpu ( udev -> config [ 0 ] . desc . wTotalLength ) , USB_DT_OTG , ( void * * ) & desc ) ; if ( err || ! ( desc -> bmAttributes & USB_OTG_HNP ) ) return 0 ; dev_info ( & udev -> dev , ""Dual-RoleOTGdeviceon%sHNPport\\n"" , ( port1 == bus -> otg_port ) ? """" : ""non-"" ) ; if ( port1 == bus -> otg_port ) { bus -> b_hnp_enable = 1 ; err = usb_control_msg ( udev , usb_sndctrlpipe ( udev , 0 ) , USB_REQ_SET_FEATURE , 0 , USB_DEVICE_B_HNP_ENABLE , 0 , NULL , 0 , USB_CTRL_SET_TIMEOUT ) ; if ( err < 0 ) { dev_err ( & udev -> dev , ""can\'tsetHNPmode:%d\\n"" , err ) ; bus -> b_hnp_enable = 0 ; } } else if ( desc -> bLength == sizeof ( struct usb_otg_descriptor ) ) { err = usb_control_msg ( udev , usb_sndctrlpipe ( udev , 0 ) , USB_REQ_SET_FEATURE , 0 , USB_DEVICE_A_ALT_HNP_SUPPORT , 0 , NULL , 0 , USB_CTRL_SET_TIMEOUT ) ; if ( err < 0 ) dev_err ( & udev -> dev , ""seta_alt_hnp_supportfailed:%d\\n"" , err ) ; } } # endif return err ; } "," ) & desc , sizeof ( * desc ) ",torvalds@linux/704620afc70cf47abb9d6a1a57f3825d2bca49cf,CVE-2018-20169,https://github.com/torvalds/linux/commit/704620afc70cf47abb9d6a1a57f3825d2bca49cf,2018-12-17T07:29Z 927,CWE-264,"CWE-264 static long perf_ioctl ( struct file * file , unsigned int cmd , unsigned long arg ) { struct perf_event * event = file -> private_data ; void ( * func ) ( struct perf_event * ) ; u32 flags = arg ; switch ( cmd ) { case PERF_EVENT_IOC_ENABLE : func = perf_event_enable ; break ; case PERF_EVENT_IOC_DISABLE : func = perf_event_disable ; break ; case PERF_EVENT_IOC_RESET : func = perf_event_reset ; break ; case PERF_EVENT_IOC_REFRESH : return perf_event_refresh ( event , arg ) ; case PERF_EVENT_IOC_PERIOD : return perf_event_period ( event , ( u64 __user * ) arg ) ; case PERF_EVENT_IOC_ID : { u64 id = primary_event_id ( event ) ; if ( copy_to_user ( ( void __user * ) arg , & id , sizeof ( id ) ) ) return - EFAULT ; return 0 ; } case PERF_EVENT_IOC_SET_OUTPUT : { int ret ; if ( arg != - 1 ) { struct perf_event * output_event ; struct fd output ; ret = perf_fget_light ( arg , & output ) ; if ( ret ) return ret ; output_event = output . file -> private_data ; ret = perf_event_set_output ( event , output_event ) ; fdput ( output ) ; } else { ret = perf_event_set_output ( event , NULL ) ; } return ret ; } case PERF_EVENT_IOC_SET_FILTER : return perf_event_set_filter ( event , ( void __user * ) arg ) ; default : return - ENOTTY ; } if ( flags & PERF_IOC_FLAG_GROUP ) perf_event_for_each ( event , func ) ; else perf_event_for_each_child ( event , func ) ; return 0 ; } "," -> private_data ; struct perf_event_context * ctx ; long ret ; ctx = perf_event_ctx_lock ( event ) ; ret = _perf_ioctl ( event , cmd , arg ) arg ) ; perf_event_ctx_unlock ( event , ( event , ctx ) ; return ret ; ret ; } ",torvalds@linux/f63a8daa5812afef4f06c962351687e1ff9ccb2b,CVE-2016-6787,https://github.com/torvalds/linux/commit/f63a8daa5812afef4f06c962351687e1ff9ccb2b,2016-12-28T07:59Z 928,CWE-189,"CWE-189 static void tcp_cwnd_reduction ( struct sock * sk , const int prior_unsacked , int fast_rexmit , int flag ) { struct tcp_sock * tp = tcp_sk ( sk ) ; int sndcnt = 0 ; int delta = tp -> snd_ssthresh - tcp_packets_in_flight ( tp ) ; int newly_acked_sacked = prior_unsacked - ( tp -> packets_out - tp -> sacked_out ) ; tp -> prr_delivered += newly_acked_sacked ; if ( delta < 0 ) { u64 dividend = ( u64 ) tp -> snd_ssthresh * tp -> prr_delivered + tp -> prior_cwnd - 1 ; sndcnt = div_u64 ( dividend , tp -> prior_cwnd ) - tp -> prr_out ; } else if ( ( flag & FLAG_RETRANS_DATA_ACKED ) && ! ( flag & FLAG_LOST_RETRANS ) ) { sndcnt = min_t ( int , delta , max_t ( int , tp -> prr_delivered - tp -> prr_out , newly_acked_sacked ) + 1 ) ; } else { sndcnt = min ( delta , newly_acked_sacked ) ; } sndcnt = max ( sndcnt , ( fast_rexmit ? 1 : 0 ) ) ; tp -> snd_cwnd = tcp_packets_in_flight ( tp ) + sndcnt ; } "," sacked_out ) ; if ( newly_acked_sacked <= 0 || WARN_ON_ONCE ( ! tp -> prior_cwnd ) ) return ; ",torvalds@linux/8b8a321ff72c785ed5e8b4cf6eda20b35d427390,CVE-2016-2070,https://github.com/torvalds/linux/commit/8b8a321ff72c785ed5e8b4cf6eda20b35d427390,2016-05-02T10:59Z 929,CWE-119,"CWE-119 static MB_PREDICTION_MODE read_intra_mode_uv ( VP9_COMMON * cm , vp9_reader * r , MB_PREDICTION_MODE y_mode ) { const MB_PREDICTION_MODE uv_mode = read_intra_mode ( r , cm -> fc . uv_mode_prob [ y_mode ] ) ; if ( ! cm -> frame_parallel_decoding_mode ) ++ cm -> counts . uv_mode [ y_mode ] [ uv_mode ] ; return uv_mode ; } "," static PREDICTION_MODE read_intra_mode_uv ( VP9_COMMON * cm , MACROBLOCKD * xd , vpx_reader * r , * r , PREDICTION_MODE y_mode ) { ) { const PREDICTION_MODE uv_mode = read_intra_mode cm -> fc -> uv_mode_prob [ y_mode ] ) ; FRAME_COUNTS * counts = xd -> counts ; if ( counts ) ++ counts -> uv_mode [ y_mode ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 930,CWE-476,"CWE-476 static void * skcipher_bind ( const char * name , u32 type , u32 mask ) { return crypto_alloc_skcipher ( name , type , mask ) ; } "," mask ) { struct skcipher_tfm * tfm ; struct crypto_skcipher * skcipher ; tfm = kzalloc ( sizeof ( * tfm ) , GFP_KERNEL ) ; if ( ! tfm ) return ERR_PTR ( - ENOMEM ) ; skcipher = crypto_alloc_skcipher ( name mask ) ; if ( IS_ERR ( skcipher ) ) { kfree ( tfm ) ; return ERR_CAST ( skcipher ) ; } tfm -> skcipher = skcipher ; return tfm ; ",torvalds@linux/dd504589577d8e8e70f51f997ad487a4cb6c026f,CVE-2015-8970,https://github.com/torvalds/linux/commit/dd504589577d8e8e70f51f997ad487a4cb6c026f,2016-11-28T03:59Z 931,CWE-401,"CWE-401 static noinline_for_stack int ccp_run_sha_cmd ( struct ccp_cmd_queue * cmd_q , struct ccp_cmd * cmd ) { struct ccp_sha_engine * sha = & cmd -> u . sha ; struct ccp_dm_workarea ctx ; struct ccp_data src ; struct ccp_op op ; unsigned int ioffset , ooffset ; unsigned int digest_size ; int sb_count ; const void * init ; u64 block_size ; int ctx_size ; int ret ; switch ( sha -> type ) { case CCP_SHA_TYPE_1 : if ( sha -> ctx_len < SHA1_DIGEST_SIZE ) return - EINVAL ; block_size = SHA1_BLOCK_SIZE ; break ; case CCP_SHA_TYPE_224 : if ( sha -> ctx_len < SHA224_DIGEST_SIZE ) return - EINVAL ; block_size = SHA224_BLOCK_SIZE ; break ; case CCP_SHA_TYPE_256 : if ( sha -> ctx_len < SHA256_DIGEST_SIZE ) return - EINVAL ; block_size = SHA256_BLOCK_SIZE ; break ; case CCP_SHA_TYPE_384 : if ( cmd_q -> ccp -> vdata -> version < CCP_VERSION ( 4 , 0 ) || sha -> ctx_len < SHA384_DIGEST_SIZE ) return - EINVAL ; block_size = SHA384_BLOCK_SIZE ; break ; case CCP_SHA_TYPE_512 : if ( cmd_q -> ccp -> vdata -> version < CCP_VERSION ( 4 , 0 ) || sha -> ctx_len < SHA512_DIGEST_SIZE ) return - EINVAL ; block_size = SHA512_BLOCK_SIZE ; break ; default : return - EINVAL ; } if ( ! sha -> ctx ) return - EINVAL ; if ( ! sha -> final && ( sha -> src_len & ( block_size - 1 ) ) ) return - EINVAL ; if ( cmd_q -> ccp -> vdata -> version == CCP_VERSION ( 3 , 0 ) ) { if ( ! sha -> src_len ) { unsigned int digest_len ; const u8 * sha_zero ; if ( ! sha -> final ) return 0 ; if ( sha -> msg_bits ) return - EINVAL ; switch ( sha -> type ) { case CCP_SHA_TYPE_1 : sha_zero = sha1_zero_message_hash ; digest_len = SHA1_DIGEST_SIZE ; break ; case CCP_SHA_TYPE_224 : sha_zero = sha224_zero_message_hash ; digest_len = SHA224_DIGEST_SIZE ; break ; case CCP_SHA_TYPE_256 : sha_zero = sha256_zero_message_hash ; digest_len = SHA256_DIGEST_SIZE ; break ; default : return - EINVAL ; } scatterwalk_map_and_copy ( ( void * ) sha_zero , sha -> ctx , 0 , digest_len , 1 ) ; return 0 ; } } switch ( sha -> type ) { case CCP_SHA_TYPE_1 : digest_size = SHA1_DIGEST_SIZE ; init = ( void * ) ccp_sha1_init ; ctx_size = SHA1_DIGEST_SIZE ; sb_count = 1 ; if ( cmd_q -> ccp -> vdata -> version != CCP_VERSION ( 3 , 0 ) ) ooffset = ioffset = CCP_SB_BYTES - SHA1_DIGEST_SIZE ; else ooffset = ioffset = 0 ; break ; case CCP_SHA_TYPE_224 : digest_size = SHA224_DIGEST_SIZE ; init = ( void * ) ccp_sha224_init ; ctx_size = SHA256_DIGEST_SIZE ; sb_count = 1 ; ioffset = 0 ; if ( cmd_q -> ccp -> vdata -> version != CCP_VERSION ( 3 , 0 ) ) ooffset = CCP_SB_BYTES - SHA224_DIGEST_SIZE ; else ooffset = 0 ; break ; case CCP_SHA_TYPE_256 : digest_size = SHA256_DIGEST_SIZE ; init = ( void * ) ccp_sha256_init ; ctx_size = SHA256_DIGEST_SIZE ; sb_count = 1 ; ooffset = ioffset = 0 ; break ; case CCP_SHA_TYPE_384 : digest_size = SHA384_DIGEST_SIZE ; init = ( void * ) ccp_sha384_init ; ctx_size = SHA512_DIGEST_SIZE ; sb_count = 2 ; ioffset = 0 ; ooffset = 2 * CCP_SB_BYTES - SHA384_DIGEST_SIZE ; break ; case CCP_SHA_TYPE_512 : digest_size = SHA512_DIGEST_SIZE ; init = ( void * ) ccp_sha512_init ; ctx_size = SHA512_DIGEST_SIZE ; sb_count = 2 ; ooffset = ioffset = 0 ; break ; default : ret = - EINVAL ; goto e_data ; } if ( sha -> src_len && ! sha -> src ) return - EINVAL ; memset ( & op , 0 , sizeof ( op ) ) ; op . cmd_q = cmd_q ; op . jobid = CCP_NEW_JOBID ( cmd_q -> ccp ) ; op . sb_ctx = cmd_q -> sb_ctx ; op . u . sha . type = sha -> type ; op . u . sha . msg_bits = sha -> msg_bits ; ret = ccp_init_dm_workarea ( & ctx , cmd_q , sb_count * CCP_SB_BYTES , DMA_BIDIRECTIONAL ) ; if ( ret ) return ret ; if ( sha -> first ) { switch ( sha -> type ) { case CCP_SHA_TYPE_1 : case CCP_SHA_TYPE_224 : case CCP_SHA_TYPE_256 : memcpy ( ctx . address + ioffset , init , ctx_size ) ; break ; case CCP_SHA_TYPE_384 : case CCP_SHA_TYPE_512 : memcpy ( ctx . address + ctx_size / 2 , init , ctx_size / 2 ) ; memcpy ( ctx . address , init + ctx_size / 2 , ctx_size / 2 ) ; break ; default : ret = - EINVAL ; goto e_ctx ; } } else { ret = ccp_set_dm_area ( & ctx , 0 , sha -> ctx , 0 , sb_count * CCP_SB_BYTES ) ; if ( ret ) goto e_ctx ; } ret = ccp_copy_to_sb ( cmd_q , & ctx , op . jobid , op . sb_ctx , CCP_PASSTHRU_BYTESWAP_256BIT ) ; if ( ret ) { cmd -> engine_error = cmd_q -> cmd_error ; goto e_ctx ; } if ( sha -> src ) { ret = ccp_init_data ( & src , cmd_q , sha -> src , sha -> src_len , block_size , DMA_TO_DEVICE ) ; if ( ret ) goto e_ctx ; while ( src . sg_wa . bytes_left ) { ccp_prepare_data ( & src , NULL , & op , block_size , false ) ; if ( sha -> final && ! src . sg_wa . bytes_left ) op . eom = 1 ; ret = cmd_q -> ccp -> vdata -> perform -> sha ( & op ) ; if ( ret ) { cmd -> engine_error = cmd_q -> cmd_error ; goto e_data ; } ccp_process_data ( & src , NULL , & op ) ; } } else { op . eom = 1 ; ret = cmd_q -> ccp -> vdata -> perform -> sha ( & op ) ; if ( ret ) { cmd -> engine_error = cmd_q -> cmd_error ; goto e_data ; } } ret = ccp_copy_from_sb ( cmd_q , & ctx , op . jobid , op . sb_ctx , CCP_PASSTHRU_BYTESWAP_256BIT ) ; if ( ret ) { cmd -> engine_error = cmd_q -> cmd_error ; goto e_data ; } if ( sha -> final ) { switch ( sha -> type ) { case CCP_SHA_TYPE_1 : case CCP_SHA_TYPE_224 : case CCP_SHA_TYPE_256 : ccp_get_dm_area ( & ctx , ooffset , sha -> ctx , 0 , digest_size ) ; break ; case CCP_SHA_TYPE_384 : case CCP_SHA_TYPE_512 : ccp_get_dm_area ( & ctx , 0 , sha -> ctx , LSB_ITEM_SIZE - ooffset , LSB_ITEM_SIZE ) ; ccp_get_dm_area ( & ctx , LSB_ITEM_SIZE + ooffset , sha -> ctx , 0 , LSB_ITEM_SIZE - ooffset ) ; break ; default : ret = - EINVAL ; goto e_ctx ; } } else { ccp_get_dm_area ( & ctx , 0 , sha -> ctx , 0 , sb_count * CCP_SB_BYTES ) ; } if ( sha -> final && sha -> opad ) { struct ccp_cmd hmac_cmd ; struct scatterlist sg ; u8 * hmac_buf ; if ( sha -> opad_len != block_size ) { ret = - EINVAL ; goto e_data ; } hmac_buf = kmalloc ( block_size + digest_size , GFP_KERNEL ) ; if ( ! hmac_buf ) { ret = - ENOMEM ; goto e_data ; } sg_init_one ( & sg , hmac_buf , block_size + digest_size ) ; scatterwalk_map_and_copy ( hmac_buf , sha -> opad , 0 , block_size , 0 ) ; switch ( sha -> type ) { case CCP_SHA_TYPE_1 : case CCP_SHA_TYPE_224 : case CCP_SHA_TYPE_256 : memcpy ( hmac_buf + block_size , ctx . address + ooffset , digest_size ) ; break ; case CCP_SHA_TYPE_384 : case CCP_SHA_TYPE_512 : memcpy ( hmac_buf + block_size , ctx . address + LSB_ITEM_SIZE + ooffset , LSB_ITEM_SIZE ) ; memcpy ( hmac_buf + block_size + ( LSB_ITEM_SIZE - ooffset ) , ctx . address , LSB_ITEM_SIZE ) ; break ; default : ret = - EINVAL ; goto e_ctx ; } memset ( & hmac_cmd , 0 , sizeof ( hmac_cmd ) ) ; hmac_cmd . engine = CCP_ENGINE_SHA ; hmac_cmd . u . sha . type = sha -> type ; hmac_cmd . u . sha . ctx = sha -> ctx ; hmac_cmd . u . sha . ctx_len = sha -> ctx_len ; hmac_cmd . u . sha . src = & sg ; hmac_cmd . u . sha . src_len = block_size + digest_size ; hmac_cmd . u . sha . opad = NULL ; hmac_cmd . u . sha . opad_len = 0 ; hmac_cmd . u . sha . first = 1 ; hmac_cmd . u . sha . final = 1 ; hmac_cmd . u . sha . msg_bits = ( block_size + digest_size ) << 3 ; ret = ccp_run_sha_cmd ( cmd_q , & hmac_cmd ) ; if ( ret ) cmd -> engine_error = hmac_cmd . engine_error ; kfree ( hmac_buf ) ; } e_data : if ( sha -> src ) ccp_free_data ( & src , cmd_q ) ; e_ctx : ccp_dm_free ( & ctx ) ; return ret ; } "," ; default : kfree ( hmac_buf ) ; EINVAL ; goto e_data ; } memset ",torvalds@linux/128c66429247add5128c03dc1e144ca56f05a4e2,CVE-2019-18808,https://github.com/torvalds/linux/commit/128c66429247add5128c03dc1e144ca56f05a4e2,2019-11-07T16:15Z 932,CWE-189,"CWE-189 static int g2m_init_buffers ( G2MContext * c ) { int aligned_height ; if ( ! c -> framebuf || c -> old_width < c -> width || c -> old_height < c -> height ) { c -> framebuf_stride = FFALIGN ( c -> width * 3 , 16 ) ; aligned_height = FFALIGN ( c -> height , 16 ) ; av_free ( c -> framebuf ) ; c -> framebuf = av_mallocz ( c -> framebuf_stride * aligned_height ) ; if ( ! c -> framebuf ) return AVERROR ( ENOMEM ) ; } if ( ! c -> synth_tile || ! c -> jpeg_tile || c -> old_tile_w < c -> tile_width || c -> old_tile_h < c -> tile_height ) { c -> tile_stride = FFALIGN ( c -> tile_width * 3 , 16 ) ; aligned_height = FFALIGN ( c -> tile_height , 16 ) ; av_free ( c -> synth_tile ) ; av_free ( c -> jpeg_tile ) ; av_free ( c -> kempf_buf ) ; av_free ( c -> kempf_flags ) ; c -> synth_tile = av_mallocz ( c -> tile_stride * aligned_height ) ; c -> jpeg_tile = av_mallocz ( c -> tile_stride * aligned_height ) ; c -> kempf_buf = av_mallocz ( ( c -> tile_width + 1 ) * aligned_height + FF_INPUT_BUFFER_PADDING_SIZE ) ; c -> kempf_flags = av_mallocz ( c -> tile_width * aligned_height ) ; if ( ! c -> synth_tile || ! c -> jpeg_tile || ! c -> kempf_buf || ! c -> kempf_flags ) return AVERROR ( ENOMEM ) ; } return 0 ; } "," c -> tile_width , 16 ) , 16 ) * 3 ",FFmpeg@FFmpeg/821a5938d100458f4d09d634041b05c860554ce0,CVE-2013-7013,https://github.com/FFmpeg/FFmpeg/commit/821a5938d100458f4d09d634041b05c860554ce0,2013-12-09T16:36Z 933,CWE-326,"CWE-326 static VALUE ossl_cipher_pkcs5_keyivgen ( int argc , VALUE * argv , VALUE self ) { EVP_CIPHER_CTX * ctx ; const EVP_MD * digest ; VALUE vpass , vsalt , viter , vdigest ; unsigned char key [ EVP_MAX_KEY_LENGTH ] , iv [ EVP_MAX_IV_LENGTH ] , * salt = NULL ; int iter ; rb_scan_args ( argc , argv , ""13"" , & vpass , & vsalt , & viter , & vdigest ) ; StringValue ( vpass ) ; if ( ! NIL_P ( vsalt ) ) { StringValue ( vsalt ) ; if ( RSTRING_LEN ( vsalt ) != PKCS5_SALT_LEN ) ossl_raise ( eCipherError , ""saltmustbean8-octetstring"" ) ; salt = ( unsigned char * ) RSTRING_PTR ( vsalt ) ; } iter = NIL_P ( viter ) ? 2048 : NUM2INT ( viter ) ; digest = NIL_P ( vdigest ) ? EVP_md5 ( ) : GetDigestPtr ( vdigest ) ; GetCipher ( self , ctx ) ; EVP_BytesToKey ( EVP_CIPHER_CTX_cipher ( ctx ) , digest , salt , ( unsigned char * ) RSTRING_PTR ( vpass ) , RSTRING_LENINT ( vpass ) , iter , key , iv ) ; if ( EVP_CipherInit_ex ( ctx , NULL , NULL , key , iv , - 1 ) != 1 ) ossl_raise ( eCipherError , NULL ) ; OPENSSL_cleanse ( key , sizeof key ) ; OPENSSL_cleanse ( iv , sizeof iv ) ; return Qnil ; } "," iv ) ; rb_ivar_set ( self , id_key_set , Qtrue ) ; ",ruby@openssl/8108e0a6db133f3375608303fdd2083eb5115062,CVE-2016-7798,https://github.com/ruby/openssl/commit/8108e0a6db133f3375608303fdd2083eb5115062,2017-01-30T22:59Z 934,CWE-119,"CWE-119 void jpc_qmfb_join_colgrp ( jpc_fix_t * a , int numrows , int stride , int parity ) { int bufsize = JPC_CEILDIVPOW2 ( numrows , 1 ) ; jpc_fix_t joinbuf [ QMFB_JOINBUFSIZE * JPC_QMFB_COLGRPSIZE ] ; jpc_fix_t * buf = joinbuf ; jpc_fix_t * srcptr ; jpc_fix_t * dstptr ; register jpc_fix_t * srcptr2 ; register jpc_fix_t * dstptr2 ; register int n ; register int i ; int hstartcol ; if ( bufsize > QMFB_JOINBUFSIZE ) { if ( ! ( buf = jas_alloc3 ( bufsize , JPC_QMFB_COLGRPSIZE , sizeof ( jpc_fix_t ) ) ) ) { abort ( ) ; } } hstartcol = ( numrows + 1 - parity ) >> 1 ; n = hstartcol ; srcptr = & a [ 0 ] ; dstptr = buf ; while ( n -- > 0 ) { dstptr2 = dstptr ; srcptr2 = srcptr ; for ( i = 0 ; i < JPC_QMFB_COLGRPSIZE ; ++ i ) { * dstptr2 = * srcptr2 ; ++ dstptr2 ; ++ srcptr2 ; } srcptr += stride ; dstptr += JPC_QMFB_COLGRPSIZE ; } srcptr = & a [ hstartcol * stride ] ; dstptr = & a [ ( 1 - parity ) * stride ] ; n = numrows - hstartcol ; while ( n -- > 0 ) { dstptr2 = dstptr ; srcptr2 = srcptr ; for ( i = 0 ; i < JPC_QMFB_COLGRPSIZE ; ++ i ) { * dstptr2 = * srcptr2 ; ++ dstptr2 ; ++ srcptr2 ; } dstptr += 2 * stride ; srcptr += stride ; } srcptr = buf ; dstptr = & a [ parity * stride ] ; n = hstartcol ; while ( n -- > 0 ) { dstptr2 = dstptr ; srcptr2 = srcptr ; for ( i = 0 ; i < JPC_QMFB_COLGRPSIZE ; ++ i ) { * dstptr2 = * srcptr2 ; ++ dstptr2 ; ++ srcptr2 ; } dstptr += 2 * stride ; srcptr += JPC_QMFB_COLGRPSIZE ; } if ( buf != joinbuf ) { jas_free ( buf ) ; } } "," ",mdadams@jasper/4a59cfaf9ab3d48fca4a15c0d2674bf7138e3d1a,CVE-2016-8654,https://github.com/mdadams/jasper/commit/4a59cfaf9ab3d48fca4a15c0d2674bf7138e3d1a,2018-08-01T16:29Z 935,CWE-119,"CWE-119 static int stellaris_enet_init ( SysBusDevice * sbd ) { DeviceState * dev = DEVICE ( sbd ) ; stellaris_enet_state * s = STELLARIS_ENET ( dev ) ; memory_region_init_io ( & s -> mmio , OBJECT ( s ) , & stellaris_enet_ops , s , ""stellaris_enet"" , 0x1000 ) ; sysbus_init_mmio ( sbd , & s -> mmio ) ; sysbus_init_irq ( sbd , & s -> irq ) ; qemu_macaddr_default_if_unset ( & s -> conf . macaddr ) ; s -> nic = qemu_new_nic ( & net_stellaris_enet_info , & s -> conf , object_get_typename ( OBJECT ( dev ) ) , dev -> id , s ) ; qemu_format_nic_info_str ( qemu_get_queue ( s -> nic ) , s -> conf . macaddr . a ) ; stellaris_enet_reset ( s ) ; register_savevm ( dev , ""stellaris_enet"" , - 1 , 1 , stellaris_enet_save , stellaris_enet_load , s ) ; return 0 ; } "," s ) ; return 0 ; ",qemu@qemu/2e1198672759eda6e122ff38fcf6df06f27e0fe2,CVE-2013-4532,https://github.com/qemu/qemu/commit/2e1198672759eda6e122ff38fcf6df06f27e0fe2,2020-01-02T16:15Z 936,CWE-125,"CWE-125 u_int chdlc_if_print ( netdissect_options * ndo , const struct pcap_pkthdr * h , register const u_char * p ) { register u_int length = h -> len ; register u_int caplen = h -> caplen ; if ( caplen < CHDLC_HDRLEN ) { ND_PRINT ( ( ndo , ""[|chdlc]"" ) ) ; return ( caplen ) ; } return ( chdlc_print ( ndo , p , length ) ) ; } "," p ) { return chdlc_print ( ndo , p , h -> len ) ; } ",the-tcpdump-group@tcpdump/a1eefe986065846b6c69dbc09afd9fa1a02c4a3d,CVE-2017-13687,https://github.com/the-tcpdump-group/tcpdump/commit/a1eefe986065846b6c69dbc09afd9fa1a02c4a3d,2017-09-14T06:29Z 937,CWE-20,"CWE-20 int cifs_mount ( struct super_block * sb , struct cifs_sb_info * cifs_sb , char * mount_data_global , const char * devname ) { int rc ; int xid ; struct smb_vol * volume_info ; struct cifsSesInfo * pSesInfo ; struct cifsTconInfo * tcon ; struct TCP_Server_Info * srvTcp ; char * full_path ; char * mount_data = mount_data_global ; struct tcon_link * tlink ; # ifdef CONFIG_CIFS_DFS_UPCALL struct dfs_info3_param * referrals = NULL ; unsigned int num_referrals = 0 ; int referral_walks_count = 0 ; try_mount_again : # endif rc = 0 ; tcon = NULL ; pSesInfo = NULL ; srvTcp = NULL ; full_path = NULL ; tlink = NULL ; xid = GetXid ( ) ; volume_info = kzalloc ( sizeof ( struct smb_vol ) , GFP_KERNEL ) ; if ( ! volume_info ) { rc = - ENOMEM ; goto out ; } if ( cifs_parse_mount_options ( mount_data , devname , volume_info ) ) { rc = - EINVAL ; goto out ; } if ( volume_info -> nullauth ) { cFYI ( 1 , ""nulluser"" ) ; volume_info -> username = """" ; } else if ( volume_info -> username ) { cFYI ( 1 , ""Username:%s"" , volume_info -> username ) ; } else { cifserror ( ""Nousernamespecified"" ) ; rc = - EINVAL ; goto out ; } if ( volume_info -> iocharset == NULL ) { volume_info -> local_nls = load_nls_default ( ) ; } else { volume_info -> local_nls = load_nls ( volume_info -> iocharset ) ; if ( volume_info -> local_nls == NULL ) { cERROR ( 1 , ""CIFSmounterror:iocharset%snotfound"" , volume_info -> iocharset ) ; rc = - ELIBACC ; goto out ; } } cifs_sb -> local_nls = volume_info -> local_nls ; srvTcp = cifs_get_tcp_session ( volume_info ) ; if ( IS_ERR ( srvTcp ) ) { rc = PTR_ERR ( srvTcp ) ; goto out ; } pSesInfo = cifs_get_smb_ses ( srvTcp , volume_info ) ; if ( IS_ERR ( pSesInfo ) ) { rc = PTR_ERR ( pSesInfo ) ; pSesInfo = NULL ; goto mount_fail_check ; } setup_cifs_sb ( volume_info , cifs_sb ) ; if ( pSesInfo -> capabilities & CAP_LARGE_FILES ) sb -> s_maxbytes = MAX_LFS_FILESIZE ; else sb -> s_maxbytes = MAX_NON_LFS ; sb -> s_time_gran = 100 ; tcon = cifs_get_tcon ( pSesInfo , volume_info ) ; if ( IS_ERR ( tcon ) ) { rc = PTR_ERR ( tcon ) ; tcon = NULL ; goto remote_path_check ; } if ( ! tcon -> ipc ) { CIFSSMBQFSDeviceInfo ( xid , tcon ) ; CIFSSMBQFSAttributeInfo ( xid , tcon ) ; } if ( tcon -> ses -> capabilities & CAP_UNIX ) reset_cifs_unix_caps ( xid , tcon , sb , volume_info ) ; else tcon -> unix_ext = 0 ; if ( ( cifs_sb -> mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS ) == 0 ) convert_delimiter ( cifs_sb -> prepath , CIFS_DIR_SEP ( cifs_sb ) ) ; if ( ( tcon -> unix_ext == 0 ) && ( cifs_sb -> rsize > ( 1024 * 127 ) ) ) { cifs_sb -> rsize = 1024 * 127 ; cFYI ( DBG2 , ""noverylargereadsupport,rsizenow127K"" ) ; } if ( ! ( tcon -> ses -> capabilities & CAP_LARGE_WRITE_X ) ) cifs_sb -> wsize = min ( cifs_sb -> wsize , ( tcon -> ses -> server -> maxBuf - MAX_CIFS_HDR_SIZE ) ) ; if ( ! ( tcon -> ses -> capabilities & CAP_LARGE_READ_X ) ) cifs_sb -> rsize = min ( cifs_sb -> rsize , ( tcon -> ses -> server -> maxBuf - MAX_CIFS_HDR_SIZE ) ) ; remote_path_check : if ( ! rc && cifs_sb -> prepathlen && tcon ) { full_path = cifs_build_path_to_root ( cifs_sb , tcon ) ; if ( full_path == NULL ) { rc = - ENOMEM ; goto mount_fail_check ; } rc = is_path_accessible ( xid , tcon , cifs_sb , full_path ) ; if ( rc != 0 && rc != - EREMOTE ) { kfree ( full_path ) ; goto mount_fail_check ; } kfree ( full_path ) ; } if ( rc == - EREMOTE ) { # ifdef CONFIG_CIFS_DFS_UPCALL if ( referral_walks_count > MAX_NESTED_LINKS ) { rc = - ELOOP ; goto mount_fail_check ; } if ( ( cifs_sb -> mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS ) == 0 ) convert_delimiter ( cifs_sb -> prepath , CIFS_DIR_SEP ( cifs_sb ) ) ; full_path = build_unc_path_to_root ( volume_info , cifs_sb ) ; if ( IS_ERR ( full_path ) ) { rc = PTR_ERR ( full_path ) ; goto mount_fail_check ; } cFYI ( 1 , ""Gettingreferralfor:%s"" , full_path ) ; rc = get_dfs_path ( xid , pSesInfo , full_path + 1 , cifs_sb -> local_nls , & num_referrals , & referrals , cifs_sb -> mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR ) ; if ( ! rc && num_referrals > 0 ) { char * fake_devname = NULL ; if ( mount_data != mount_data_global ) kfree ( mount_data ) ; mount_data = cifs_compose_mount_options ( cifs_sb -> mountdata , full_path + 1 , referrals , & fake_devname ) ; free_dfs_info_array ( referrals , num_referrals ) ; kfree ( fake_devname ) ; kfree ( full_path ) ; if ( IS_ERR ( mount_data ) ) { rc = PTR_ERR ( mount_data ) ; mount_data = NULL ; goto mount_fail_check ; } if ( tcon ) cifs_put_tcon ( tcon ) ; else if ( pSesInfo ) cifs_put_smb_ses ( pSesInfo ) ; cleanup_volume_info ( & volume_info ) ; referral_walks_count ++ ; FreeXid ( xid ) ; goto try_mount_again ; } # else rc = - EOPNOTSUPP ; # endif } if ( rc ) goto mount_fail_check ; tlink = kzalloc ( sizeof * tlink , GFP_KERNEL ) ; if ( tlink == NULL ) { rc = - ENOMEM ; goto mount_fail_check ; } tlink -> tl_uid = pSesInfo -> linux_uid ; tlink -> tl_tcon = tcon ; tlink -> tl_time = jiffies ; set_bit ( TCON_LINK_MASTER , & tlink -> tl_flags ) ; set_bit ( TCON_LINK_IN_TREE , & tlink -> tl_flags ) ; cifs_sb -> master_tlink = tlink ; spin_lock ( & cifs_sb -> tlink_tree_lock ) ; tlink_rb_insert ( & cifs_sb -> tlink_tree , tlink ) ; spin_unlock ( & cifs_sb -> tlink_tree_lock ) ; queue_delayed_work ( system_nrt_wq , & cifs_sb -> prune_tlinks , TLINK_IDLE_EXPIRE ) ; mount_fail_check : if ( rc ) { if ( mount_data != mount_data_global ) kfree ( mount_data ) ; if ( tcon ) cifs_put_tcon ( tcon ) ; else if ( pSesInfo ) cifs_put_smb_ses ( pSesInfo ) ; else cifs_put_tcp_session ( srvTcp ) ; goto out ; } out : cleanup_volume_info ( & volume_info ) ; FreeXid ( xid ) ; return rc ; } "," ( ! rc && tcon ) ",torvalds@linux/70945643722ffeac779d2529a348f99567fa5c33,CVE-2011-3363,https://github.com/torvalds/linux/commit/70945643722ffeac779d2529a348f99567fa5c33,2012-05-24T23:55Z 938,CWE-125,"CWE-125 void __sock_recv_timestamp ( struct msghdr * msg , struct sock * sk , struct sk_buff * skb ) { int need_software_tstamp = sock_flag ( sk , SOCK_RCVTSTAMP ) ; struct scm_timestamping tss ; int empty = 1 ; struct skb_shared_hwtstamps * shhwtstamps = skb_hwtstamps ( skb ) ; if ( need_software_tstamp && skb -> tstamp == 0 ) __net_timestamp ( skb ) ; if ( need_software_tstamp ) { if ( ! sock_flag ( sk , SOCK_RCVTSTAMPNS ) ) { struct timeval tv ; skb_get_timestamp ( skb , & tv ) ; put_cmsg ( msg , SOL_SOCKET , SCM_TIMESTAMP , sizeof ( tv ) , & tv ) ; } else { struct timespec ts ; skb_get_timestampns ( skb , & ts ) ; put_cmsg ( msg , SOL_SOCKET , SCM_TIMESTAMPNS , sizeof ( ts ) , & ts ) ; } } memset ( & tss , 0 , sizeof ( tss ) ) ; if ( ( sk -> sk_tsflags & SOF_TIMESTAMPING_SOFTWARE ) && ktime_to_timespec_cond ( skb -> tstamp , tss . ts + 0 ) ) empty = 0 ; if ( shhwtstamps && ( sk -> sk_tsflags & SOF_TIMESTAMPING_RAW_HARDWARE ) && ktime_to_timespec_cond ( shhwtstamps -> hwtstamp , tss . ts + 2 ) ) empty = 0 ; if ( ! empty ) { put_cmsg ( msg , SOL_SOCKET , SCM_TIMESTAMPING , sizeof ( tss ) , & tss ) ; if ( skb_is_err_queue ( skb ) && skb -> len && ( sk -> sk_tsflags & SOF_TIMESTAMPING_OPT_STATS ) ) put_cmsg ( msg , SOL_SOCKET , SCM_TIMESTAMPING_OPT_STATS , skb -> len , skb -> data ) ; } } "," -> len && SKB_EXT_ERR ( skb ) -> opt_stats ) put_cmsg ( ",torvalds@linux/4ef1b2869447411ad3ef91ad7d4891a83c1a509a,CVE-2017-7277,https://github.com/torvalds/linux/commit/4ef1b2869447411ad3ef91ad7d4891a83c1a509a,2017-03-28T06:59Z 939,CWE-200,"CWE-200 static int raptor_rdfxml_parse_start ( raptor_parser * rdf_parser ) { raptor_uri * uri = rdf_parser -> base_uri ; raptor_rdfxml_parser * rdf_xml_parser ; rdf_xml_parser = ( raptor_rdfxml_parser * ) rdf_parser -> context ; if ( ! uri ) return 1 ; raptor_sax2_set_option ( rdf_xml_parser -> sax2 , RAPTOR_OPTION_NORMALIZE_LANGUAGE , NULL , RAPTOR_OPTIONS_GET_NUMERIC ( rdf_parser , RAPTOR_OPTION_NORMALIZE_LANGUAGE ) ) ; raptor_sax2_set_option ( rdf_xml_parser -> sax2 , RAPTOR_OPTION_NO_NET , NULL , RAPTOR_OPTIONS_GET_NUMERIC ( rdf_parser , RAPTOR_OPTION_NO_NET ) ) ; raptor_sax2_set_option ( rdf_xml_parser -> sax2 , RAPTOR_OPTION_NO_FILE , NULL , RAPTOR_OPTIONS_GET_NUMERIC ( rdf_parser , RAPTOR_OPTION_NO_FILE ) ) ; if ( rdf_parser -> uri_filter ) raptor_sax2_set_uri_filter ( rdf_xml_parser -> sax2 , rdf_parser -> uri_filter , rdf_parser -> uri_filter_user_data ) ; raptor_sax2_parse_start ( rdf_xml_parser -> sax2 , uri ) ; if ( rdf_xml_parser -> id_set ) { raptor_free_id_set ( rdf_xml_parser -> id_set ) ; rdf_xml_parser -> id_set = NULL ; } if ( RAPTOR_OPTIONS_GET_NUMERIC ( rdf_parser , RAPTOR_OPTION_CHECK_RDF_ID ) ) { rdf_xml_parser -> id_set = raptor_new_id_set ( rdf_parser -> world ) ; if ( ! rdf_xml_parser -> id_set ) return 1 ; } return 0 ; } "," ) ) ; raptor_sax2_set_option ( rdf_xml_parser -> sax2 , RAPTOR_OPTION_LOAD_EXTERNAL_ENTITIES , NULL , RAPTOR_OPTIONS_GET_NUMERIC ( rdf_parser , RAPTOR_OPTION_LOAD_EXTERNAL_ENTITIES ) ) ; ",dajobe@raptor/a676f235309a59d4aa78eeffd2574ae5d341fcb0,CVE-2012-0037,https://github.com/dajobe/raptor/commit/a676f235309a59d4aa78eeffd2574ae5d341fcb0,2012-06-17T03:41Z 940,CWE-310,"CWE-310 int ssl3_get_key_exchange ( SSL * s ) { # ifndef OPENSSL_NO_RSA unsigned char * q , md_buf [ EVP_MAX_MD_SIZE * 2 ] ; # endif EVP_MD_CTX md_ctx ; unsigned char * param , * p ; int al , j , ok ; long i , param_len , n , alg_k , alg_a ; EVP_PKEY * pkey = NULL ; const EVP_MD * md = NULL ; # ifndef OPENSSL_NO_RSA RSA * rsa = NULL ; # endif # ifndef OPENSSL_NO_DH DH * dh = NULL ; # endif # ifndef OPENSSL_NO_ECDH EC_KEY * ecdh = NULL ; BN_CTX * bn_ctx = NULL ; EC_POINT * srvr_ecpoint = NULL ; int curve_nid = 0 ; int encoded_pt_len = 0 ; # endif EVP_MD_CTX_init ( & md_ctx ) ; n = s -> method -> ssl_get_message ( s , SSL3_ST_CR_KEY_EXCH_A , SSL3_ST_CR_KEY_EXCH_B , - 1 , s -> max_cert_list , & ok ) ; if ( ! ok ) return ( ( int ) n ) ; alg_k = s -> s3 -> tmp . new_cipher -> algorithm_mkey ; if ( s -> s3 -> tmp . message_type != SSL3_MT_SERVER_KEY_EXCHANGE ) { if ( alg_k & ( SSL_kDHE | SSL_kECDHE ) ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_UNEXPECTED_MESSAGE ) ; al = SSL_AD_UNEXPECTED_MESSAGE ; goto f_err ; } # ifndef OPENSSL_NO_PSK if ( alg_k & SSL_kPSK ) { s -> session -> sess_cert = ssl_sess_cert_new ( ) ; if ( s -> ctx -> psk_identity_hint ) OPENSSL_free ( s -> ctx -> psk_identity_hint ) ; s -> ctx -> psk_identity_hint = NULL ; } # endif s -> s3 -> tmp . reuse_message = 1 ; return ( 1 ) ; } param = p = ( unsigned char * ) s -> init_msg ; if ( s -> session -> sess_cert != NULL ) { # ifndef OPENSSL_NO_RSA if ( s -> session -> sess_cert -> peer_rsa_tmp != NULL ) { RSA_free ( s -> session -> sess_cert -> peer_rsa_tmp ) ; s -> session -> sess_cert -> peer_rsa_tmp = NULL ; } # endif # ifndef OPENSSL_NO_DH if ( s -> session -> sess_cert -> peer_dh_tmp ) { DH_free ( s -> session -> sess_cert -> peer_dh_tmp ) ; s -> session -> sess_cert -> peer_dh_tmp = NULL ; } # endif # ifndef OPENSSL_NO_ECDH if ( s -> session -> sess_cert -> peer_ecdh_tmp ) { EC_KEY_free ( s -> session -> sess_cert -> peer_ecdh_tmp ) ; s -> session -> sess_cert -> peer_ecdh_tmp = NULL ; } # endif } else { s -> session -> sess_cert = ssl_sess_cert_new ( ) ; } param_len = 0 ; alg_a = s -> s3 -> tmp . new_cipher -> algorithm_auth ; al = SSL_AD_DECODE_ERROR ; # ifndef OPENSSL_NO_PSK if ( alg_k & SSL_kPSK ) { char tmp_id_hint [ PSK_MAX_IDENTITY_LEN + 1 ] ; param_len = 2 ; if ( param_len > n ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_LENGTH_TOO_SHORT ) ; goto f_err ; } n2s ( p , i ) ; if ( i > PSK_MAX_IDENTITY_LEN ) { al = SSL_AD_HANDSHAKE_FAILURE ; SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_DATA_LENGTH_TOO_LONG ) ; goto f_err ; } if ( i > n - param_len ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_BAD_PSK_IDENTITY_HINT_LENGTH ) ; goto f_err ; } param_len += i ; memcpy ( tmp_id_hint , p , i ) ; memset ( tmp_id_hint + i , 0 , PSK_MAX_IDENTITY_LEN + 1 - i ) ; if ( s -> ctx -> psk_identity_hint != NULL ) OPENSSL_free ( s -> ctx -> psk_identity_hint ) ; s -> ctx -> psk_identity_hint = BUF_strdup ( tmp_id_hint ) ; if ( s -> ctx -> psk_identity_hint == NULL ) { al = SSL_AD_HANDSHAKE_FAILURE ; SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , ERR_R_MALLOC_FAILURE ) ; goto f_err ; } p += i ; n -= param_len ; } else # endif # ifndef OPENSSL_NO_SRP if ( alg_k & SSL_kSRP ) { param_len = 2 ; if ( param_len > n ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_LENGTH_TOO_SHORT ) ; goto f_err ; } n2s ( p , i ) ; if ( i > n - param_len ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_BAD_SRP_N_LENGTH ) ; goto f_err ; } param_len += i ; if ( ! ( s -> srp_ctx . N = BN_bin2bn ( p , i , NULL ) ) ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , ERR_R_BN_LIB ) ; goto err ; } p += i ; if ( 2 > n - param_len ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_LENGTH_TOO_SHORT ) ; goto f_err ; } param_len += 2 ; n2s ( p , i ) ; if ( i > n - param_len ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_BAD_SRP_G_LENGTH ) ; goto f_err ; } param_len += i ; if ( ! ( s -> srp_ctx . g = BN_bin2bn ( p , i , NULL ) ) ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , ERR_R_BN_LIB ) ; goto err ; } p += i ; if ( 1 > n - param_len ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_LENGTH_TOO_SHORT ) ; goto f_err ; } param_len += 1 ; i = ( unsigned int ) ( p [ 0 ] ) ; p ++ ; if ( i > n - param_len ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_BAD_SRP_S_LENGTH ) ; goto f_err ; } param_len += i ; if ( ! ( s -> srp_ctx . s = BN_bin2bn ( p , i , NULL ) ) ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , ERR_R_BN_LIB ) ; goto err ; } p += i ; if ( 2 > n - param_len ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_LENGTH_TOO_SHORT ) ; goto f_err ; } param_len += 2 ; n2s ( p , i ) ; if ( i > n - param_len ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_BAD_SRP_B_LENGTH ) ; goto f_err ; } param_len += i ; if ( ! ( s -> srp_ctx . B = BN_bin2bn ( p , i , NULL ) ) ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , ERR_R_BN_LIB ) ; goto err ; } p += i ; n -= param_len ; if ( ! srp_verify_server_param ( s , & al ) ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_BAD_SRP_PARAMETERS ) ; goto f_err ; } # ifndef OPENSSL_NO_RSA if ( alg_a & SSL_aRSA ) pkey = X509_get_pubkey ( s -> session -> sess_cert -> peer_pkeys [ SSL_PKEY_RSA_ENC ] . x509 ) ; # else if ( 0 ) ; # endif # ifndef OPENSSL_NO_DSA else if ( alg_a & SSL_aDSS ) pkey = X509_get_pubkey ( s -> session -> sess_cert -> peer_pkeys [ SSL_PKEY_DSA_SIGN ] . x509 ) ; # endif } else # endif # ifndef OPENSSL_NO_RSA if ( alg_k & SSL_kRSA ) { if ( ( rsa = RSA_new ( ) ) == NULL ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , ERR_R_MALLOC_FAILURE ) ; goto err ; } param_len = 2 ; if ( param_len > n ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_LENGTH_TOO_SHORT ) ; goto f_err ; } n2s ( p , i ) ; if ( i > n - param_len ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_BAD_RSA_MODULUS_LENGTH ) ; goto f_err ; } param_len += i ; if ( ! ( rsa -> n = BN_bin2bn ( p , i , rsa -> n ) ) ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , ERR_R_BN_LIB ) ; goto err ; } p += i ; if ( 2 > n - param_len ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_LENGTH_TOO_SHORT ) ; goto f_err ; } param_len += 2 ; n2s ( p , i ) ; if ( i > n - param_len ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_BAD_RSA_E_LENGTH ) ; goto f_err ; } param_len += i ; if ( ! ( rsa -> e = BN_bin2bn ( p , i , rsa -> e ) ) ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , ERR_R_BN_LIB ) ; goto err ; } p += i ; n -= param_len ; if ( alg_a & SSL_aRSA ) pkey = X509_get_pubkey ( s -> session -> sess_cert -> peer_pkeys [ SSL_PKEY_RSA_ENC ] . x509 ) ; else { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , ERR_R_INTERNAL_ERROR ) ; goto err ; } s -> session -> sess_cert -> peer_rsa_tmp = rsa ; rsa = NULL ; } # else if ( 0 ) ; # endif # ifndef OPENSSL_NO_DH else if ( alg_k & SSL_kDHE ) { if ( ( dh = DH_new ( ) ) == NULL ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , ERR_R_DH_LIB ) ; goto err ; } param_len = 2 ; if ( param_len > n ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_LENGTH_TOO_SHORT ) ; goto f_err ; } n2s ( p , i ) ; if ( i > n - param_len ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_BAD_DH_P_LENGTH ) ; goto f_err ; } param_len += i ; if ( ! ( dh -> p = BN_bin2bn ( p , i , NULL ) ) ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , ERR_R_BN_LIB ) ; goto err ; } p += i ; if ( 2 > n - param_len ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_LENGTH_TOO_SHORT ) ; goto f_err ; } param_len += 2 ; n2s ( p , i ) ; if ( i > n - param_len ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_BAD_DH_G_LENGTH ) ; goto f_err ; } param_len += i ; if ( ! ( dh -> g = BN_bin2bn ( p , i , NULL ) ) ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , ERR_R_BN_LIB ) ; goto err ; } p += i ; if ( 2 > n - param_len ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_LENGTH_TOO_SHORT ) ; goto f_err ; } param_len += 2 ; n2s ( p , i ) ; if ( i > n - param_len ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_BAD_DH_PUB_KEY_LENGTH ) ; goto f_err ; } param_len += i ; if ( ! ( dh -> pub_key = BN_bin2bn ( p , i , NULL ) ) ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , ERR_R_BN_LIB ) ; goto err ; } p += i ; n -= param_len ; if ( ! ssl_security ( s , SSL_SECOP_TMP_DH , DH_security_bits ( dh ) , 0 , dh ) ) { al = SSL_AD_HANDSHAKE_FAILURE ; SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_DH_KEY_TOO_SMALL ) ; goto f_err ; } # ifndef OPENSSL_NO_RSA if ( alg_a & SSL_aRSA ) pkey = X509_get_pubkey ( s -> session -> sess_cert -> peer_pkeys [ SSL_PKEY_RSA_ENC ] . x509 ) ; # else if ( 0 ) ; # endif # ifndef OPENSSL_NO_DSA else if ( alg_a & SSL_aDSS ) pkey = X509_get_pubkey ( s -> session -> sess_cert -> peer_pkeys [ SSL_PKEY_DSA_SIGN ] . x509 ) ; # endif s -> session -> sess_cert -> peer_dh_tmp = dh ; dh = NULL ; } else if ( ( alg_k & SSL_kDHr ) || ( alg_k & SSL_kDHd ) ) { al = SSL_AD_ILLEGAL_PARAMETER ; SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_TRIED_TO_USE_UNSUPPORTED_CIPHER ) ; goto f_err ; } # endif # ifndef OPENSSL_NO_ECDH else if ( alg_k & SSL_kECDHE ) { EC_GROUP * ngroup ; const EC_GROUP * group ; if ( ( ecdh = EC_KEY_new ( ) ) == NULL ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , ERR_R_MALLOC_FAILURE ) ; goto err ; } param_len = 4 ; if ( param_len > n ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_LENGTH_TOO_SHORT ) ; goto f_err ; } if ( ! tls1_check_curve ( s , p , 3 ) ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_WRONG_CURVE ) ; goto f_err ; } if ( ( curve_nid = tls1_ec_curve_id2nid ( * ( p + 2 ) ) ) == 0 ) { al = SSL_AD_INTERNAL_ERROR ; SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_UNABLE_TO_FIND_ECDH_PARAMETERS ) ; goto f_err ; } ngroup = EC_GROUP_new_by_curve_name ( curve_nid ) ; if ( ngroup == NULL ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , ERR_R_EC_LIB ) ; goto err ; } if ( EC_KEY_set_group ( ecdh , ngroup ) == 0 ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , ERR_R_EC_LIB ) ; goto err ; } EC_GROUP_free ( ngroup ) ; group = EC_KEY_get0_group ( ecdh ) ; if ( SSL_C_IS_EXPORT ( s -> s3 -> tmp . new_cipher ) && ( EC_GROUP_get_degree ( group ) > 163 ) ) { al = SSL_AD_EXPORT_RESTRICTION ; SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_ECGROUP_TOO_LARGE_FOR_CIPHER ) ; goto f_err ; } p += 3 ; if ( ( ( srvr_ecpoint = EC_POINT_new ( group ) ) == NULL ) || ( ( bn_ctx = BN_CTX_new ( ) ) == NULL ) ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , ERR_R_MALLOC_FAILURE ) ; goto err ; } encoded_pt_len = * p ; p += 1 ; if ( ( encoded_pt_len > n - param_len ) || ( EC_POINT_oct2point ( group , srvr_ecpoint , p , encoded_pt_len , bn_ctx ) == 0 ) ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_BAD_ECPOINT ) ; goto f_err ; } param_len += encoded_pt_len ; n -= param_len ; p += encoded_pt_len ; if ( 0 ) ; # ifndef OPENSSL_NO_RSA else if ( alg_a & SSL_aRSA ) pkey = X509_get_pubkey ( s -> session -> sess_cert -> peer_pkeys [ SSL_PKEY_RSA_ENC ] . x509 ) ; # endif # ifndef OPENSSL_NO_ECDSA else if ( alg_a & SSL_aECDSA ) pkey = X509_get_pubkey ( s -> session -> sess_cert -> peer_pkeys [ SSL_PKEY_ECC ] . x509 ) ; # endif EC_KEY_set_public_key ( ecdh , srvr_ecpoint ) ; s -> session -> sess_cert -> peer_ecdh_tmp = ecdh ; ecdh = NULL ; BN_CTX_free ( bn_ctx ) ; bn_ctx = NULL ; EC_POINT_free ( srvr_ecpoint ) ; srvr_ecpoint = NULL ; } else if ( alg_k ) { al = SSL_AD_UNEXPECTED_MESSAGE ; SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_UNEXPECTED_MESSAGE ) ; goto f_err ; } # endif if ( pkey != NULL ) { if ( SSL_USE_SIGALGS ( s ) ) { int rv ; if ( 2 > n ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_LENGTH_TOO_SHORT ) ; goto f_err ; } rv = tls12_check_peer_sigalg ( & md , s , p , pkey ) ; if ( rv == - 1 ) goto err ; else if ( rv == 0 ) { goto f_err ; } # ifdef SSL_DEBUG fprintf ( stderr , ""USINGTLSv1.2HASH%s\\n"" , EVP_MD_name ( md ) ) ; # endif p += 2 ; n -= 2 ; } else md = EVP_sha1 ( ) ; if ( 2 > n ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_LENGTH_TOO_SHORT ) ; goto f_err ; } n2s ( p , i ) ; n -= 2 ; j = EVP_PKEY_size ( pkey ) ; if ( ( i != n ) || ( n > j ) || ( n <= 0 ) ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_WRONG_SIGNATURE_LENGTH ) ; goto f_err ; } # ifndef OPENSSL_NO_RSA if ( pkey -> type == EVP_PKEY_RSA && ! SSL_USE_SIGALGS ( s ) ) { int num ; unsigned int size ; j = 0 ; q = md_buf ; for ( num = 2 ; num > 0 ; num -- ) { EVP_MD_CTX_set_flags ( & md_ctx , EVP_MD_CTX_FLAG_NON_FIPS_ALLOW ) ; EVP_DigestInit_ex ( & md_ctx , ( num == 2 ) ? s -> ctx -> md5 : s -> ctx -> sha1 , NULL ) ; EVP_DigestUpdate ( & md_ctx , & ( s -> s3 -> client_random [ 0 ] ) , SSL3_RANDOM_SIZE ) ; EVP_DigestUpdate ( & md_ctx , & ( s -> s3 -> server_random [ 0 ] ) , SSL3_RANDOM_SIZE ) ; EVP_DigestUpdate ( & md_ctx , param , param_len ) ; EVP_DigestFinal_ex ( & md_ctx , q , & size ) ; q += size ; j += size ; } i = RSA_verify ( NID_md5_sha1 , md_buf , j , p , n , pkey -> pkey . rsa ) ; if ( i < 0 ) { al = SSL_AD_DECRYPT_ERROR ; SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_BAD_RSA_DECRYPT ) ; goto f_err ; } if ( i == 0 ) { al = SSL_AD_DECRYPT_ERROR ; SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_BAD_SIGNATURE ) ; goto f_err ; } } else # endif { EVP_VerifyInit_ex ( & md_ctx , md , NULL ) ; EVP_VerifyUpdate ( & md_ctx , & ( s -> s3 -> client_random [ 0 ] ) , SSL3_RANDOM_SIZE ) ; EVP_VerifyUpdate ( & md_ctx , & ( s -> s3 -> server_random [ 0 ] ) , SSL3_RANDOM_SIZE ) ; EVP_VerifyUpdate ( & md_ctx , param , param_len ) ; if ( EVP_VerifyFinal ( & md_ctx , p , ( int ) n , pkey ) <= 0 ) { al = SSL_AD_DECRYPT_ERROR ; SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_BAD_SIGNATURE ) ; goto f_err ; } } } else { if ( ! ( alg_a & ( SSL_aNULL | SSL_aSRP ) ) && ! ( alg_k & SSL_kPSK ) ) { if ( ssl3_check_cert_and_algorithm ( s ) ) SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , ERR_R_INTERNAL_ERROR ) ; goto err ; } if ( n != 0 ) { SSLerr ( SSL_F_SSL3_GET_KEY_EXCHANGE , SSL_R_EXTRA_DATA_IN_MESSAGE ) ; goto f_err ; } } EVP_PKEY_free ( pkey ) ; EVP_MD_CTX_cleanup ( & md_ctx ) ; return ( 1 ) ; f_err : ssl3_send_alert ( s , SSL3_AL_FATAL , al ) ; err : EVP_PKEY_free ( pkey ) ; # ifndef OPENSSL_NO_RSA if ( rsa != NULL ) RSA_free ( rsa ) ; # endif # ifndef OPENSSL_NO_DH if ( dh != NULL ) DH_free ( dh ) ; # endif # ifndef OPENSSL_NO_ECDH BN_CTX_free ( bn_ctx ) ; EC_POINT_free ( srvr_ecpoint ) ; if ( ecdh != NULL ) EC_KEY_free ( ecdh ) ; # endif EVP_MD_CTX_cleanup ( & md_ctx ) ; return ( - 1 ) ; } "," { if ( ! SSL_C_IS_EXPORT ( s -> s3 -> tmp . new_cipher ) ) { al = SSL_AD_UNEXPECTED_MESSAGE ; SSLerr ( SSL_F_SSL3_GET_SERVER_CERTIFICATE , SSL_R_UNEXPECTED_MESSAGE ) ; goto f_err ; } if ( ",openssl@openssl/ce325c60c74b0fa784f5872404b722e120e5cab0,CVE-2015-0204,https://github.com/openssl/openssl/commit/ce325c60c74b0fa784f5872404b722e120e5cab0,2015-01-09T02:59Z 941,CWE-120,"CWE-120 SecureElementStatus_t SecureElementProcessJoinAccept ( JoinReqIdentifier_t joinReqType , uint8_t * joinEui , uint16_t devNonce , uint8_t * encJoinAccept , uint8_t encJoinAcceptSize , uint8_t * decJoinAccept , uint8_t * versionMinor ) { if ( ( encJoinAccept == NULL ) || ( decJoinAccept == NULL ) || ( versionMinor == NULL ) ) { return SECURE_ELEMENT_ERROR_NPE ; } KeyIdentifier_t encKeyID = NWK_KEY ; if ( joinReqType != JOIN_REQ ) { encKeyID = J_S_ENC_KEY ; } memcpy1 ( decJoinAccept , encJoinAccept , encJoinAcceptSize ) ; if ( SecureElementAesEncrypt ( encJoinAccept + LORAMAC_MHDR_FIELD_SIZE , encJoinAcceptSize - LORAMAC_MHDR_FIELD_SIZE , encKeyID , decJoinAccept + LORAMAC_MHDR_FIELD_SIZE ) != SECURE_ELEMENT_SUCCESS ) { return SECURE_ELEMENT_FAIL_ENCRYPT ; } * versionMinor = ( ( decJoinAccept [ 11 ] & 0x80 ) == 0x80 ) ? 1 : 0 ; uint32_t mic = 0 ; mic = ( ( uint32_t ) decJoinAccept [ encJoinAcceptSize - LORAMAC_MIC_FIELD_SIZE ] << 0 ) ; mic |= ( ( uint32_t ) decJoinAccept [ encJoinAcceptSize - LORAMAC_MIC_FIELD_SIZE + 1 ] << 8 ) ; mic |= ( ( uint32_t ) decJoinAccept [ encJoinAcceptSize - LORAMAC_MIC_FIELD_SIZE + 2 ] << 16 ) ; mic |= ( ( uint32_t ) decJoinAccept [ encJoinAcceptSize - LORAMAC_MIC_FIELD_SIZE + 3 ] << 24 ) ; if ( * versionMinor == 0 ) { if ( SecureElementVerifyAesCmac ( decJoinAccept , ( encJoinAcceptSize - LORAMAC_MIC_FIELD_SIZE ) , mic , NWK_KEY ) != SECURE_ELEMENT_SUCCESS ) { return SECURE_ELEMENT_FAIL_CMAC ; } } # if ( USE_LRWAN_1_1_X_CRYPTO == 1 ) else if ( * versionMinor == 1 ) { uint8_t micHeader11 [ JOIN_ACCEPT_MIC_COMPUTATION_OFFSET ] = { 0 } ; uint16_t bufItr = 0 ; micHeader11 [ bufItr ++ ] = ( uint8_t ) joinReqType ; memcpyr ( micHeader11 + bufItr , joinEui , LORAMAC_JOIN_EUI_FIELD_SIZE ) ; bufItr += LORAMAC_JOIN_EUI_FIELD_SIZE ; micHeader11 [ bufItr ++ ] = devNonce & 0xFF ; micHeader11 [ bufItr ++ ] = ( devNonce >> 8 ) & 0xFF ; uint8_t localBuffer [ LORAMAC_JOIN_ACCEPT_FRAME_MAX_SIZE + JOIN_ACCEPT_MIC_COMPUTATION_OFFSET ] = { 0 } ; memcpy1 ( localBuffer , micHeader11 , JOIN_ACCEPT_MIC_COMPUTATION_OFFSET ) ; memcpy1 ( localBuffer + JOIN_ACCEPT_MIC_COMPUTATION_OFFSET - 1 , decJoinAccept , encJoinAcceptSize ) ; if ( SecureElementVerifyAesCmac ( localBuffer , encJoinAcceptSize + JOIN_ACCEPT_MIC_COMPUTATION_OFFSET - LORAMAC_MHDR_FIELD_SIZE - LORAMAC_MIC_FIELD_SIZE , mic , J_S_INT_KEY ) != SECURE_ELEMENT_SUCCESS ) { return SECURE_ELEMENT_FAIL_CMAC ; } } # endif else { return SECURE_ELEMENT_ERROR_INVALID_LORAWAM_SPEC_VERSION ; } return SECURE_ELEMENT_SUCCESS ; } "," { return SECURE_ELEMENT_ERROR_NPE ; } if ( encJoinAcceptSize > LORAMAC_JOIN_ACCEPT_FRAME_MAX_SIZE ) { return SECURE_ELEMENT_ERROR_BUF_SIZE ",Lora-net@LoRaMac-node/e3063a91daa7ad8a687223efa63079f0c24568e4,CVE-2020-11068,https://github.com/Lora-net/LoRaMac-node/commit/e3063a91daa7ad8a687223efa63079f0c24568e4,2020-06-23T17:15Z 942,CWE-400,"CWE-400 ssize_t nghttp2_session_mem_recv ( nghttp2_session * session , const uint8_t * in , size_t inlen ) { const uint8_t * first = in , * last = in + inlen ; nghttp2_inbound_frame * iframe = & session -> iframe ; size_t readlen ; ssize_t padlen ; int rv ; int busy = 0 ; nghttp2_frame_hd cont_hd ; nghttp2_stream * stream ; size_t pri_fieldlen ; nghttp2_mem * mem ; DEBUGF ( ""recv:connectionrecv_window_size=%d,local_window=%d\\n"" , session -> recv_window_size , session -> local_window_size ) ; mem = & session -> mem ; rv = nghttp2_session_adjust_idle_stream ( session ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } if ( ! nghttp2_session_want_read ( session ) ) { return ( ssize_t ) inlen ; } for ( ; ; ) { switch ( iframe -> state ) { case NGHTTP2_IB_READ_CLIENT_MAGIC : readlen = nghttp2_min ( inlen , iframe -> payloadleft ) ; if ( memcmp ( & NGHTTP2_CLIENT_MAGIC [ NGHTTP2_CLIENT_MAGIC_LEN - iframe -> payloadleft ] , in , readlen ) != 0 ) { return NGHTTP2_ERR_BAD_CLIENT_MAGIC ; } iframe -> payloadleft -= readlen ; in += readlen ; if ( iframe -> payloadleft == 0 ) { session_inbound_frame_reset ( session ) ; iframe -> state = NGHTTP2_IB_READ_FIRST_SETTINGS ; } break ; case NGHTTP2_IB_READ_FIRST_SETTINGS : DEBUGF ( ""recv:[IB_READ_FIRST_SETTINGS]\\n"" ) ; readlen = inbound_frame_buf_read ( iframe , in , last ) ; in += readlen ; if ( nghttp2_buf_mark_avail ( & iframe -> sbuf ) ) { return in - first ; } if ( iframe -> sbuf . pos [ 3 ] != NGHTTP2_SETTINGS || ( iframe -> sbuf . pos [ 4 ] & NGHTTP2_FLAG_ACK ) ) { rv = session_call_error_callback ( session , NGHTTP2_ERR_SETTINGS_EXPECTED , ""Remotepeerreturnedunexpecteddatawhileweexpected"" ""SETTINGSframe.Perhaps,peerdoesnotsupportHTTP/2"" ""properly."" ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } rv = nghttp2_session_terminate_session_with_reason ( session , NGHTTP2_PROTOCOL_ERROR , ""SETTINGSexpected"" ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } return ( ssize_t ) inlen ; } iframe -> state = NGHTTP2_IB_READ_HEAD ; case NGHTTP2_IB_READ_HEAD : { int on_begin_frame_called = 0 ; DEBUGF ( ""recv:[IB_READ_HEAD]\\n"" ) ; readlen = inbound_frame_buf_read ( iframe , in , last ) ; in += readlen ; if ( nghttp2_buf_mark_avail ( & iframe -> sbuf ) ) { return in - first ; } nghttp2_frame_unpack_frame_hd ( & iframe -> frame . hd , iframe -> sbuf . pos ) ; iframe -> payloadleft = iframe -> frame . hd . length ; DEBUGF ( ""recv:payloadlen=%zu,type=%u,flags=0x%02x,stream_id=%d\\n"" , iframe -> frame . hd . length , iframe -> frame . hd . type , iframe -> frame . hd . flags , iframe -> frame . hd . stream_id ) ; if ( iframe -> frame . hd . length > session -> local_settings . max_frame_size ) { DEBUGF ( ""recv:lengthistoolarge%zu>%u\\n"" , iframe -> frame . hd . length , session -> local_settings . max_frame_size ) ; rv = nghttp2_session_terminate_session_with_reason ( session , NGHTTP2_FRAME_SIZE_ERROR , ""toolargeframesize"" ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } return ( ssize_t ) inlen ; } switch ( iframe -> frame . hd . type ) { case NGHTTP2_DATA : { DEBUGF ( ""recv:DATA\\n"" ) ; iframe -> frame . hd . flags &= ( NGHTTP2_FLAG_END_STREAM | NGHTTP2_FLAG_PADDED ) ; busy = 1 ; rv = session_on_data_received_fail_fast ( session ) ; if ( iframe -> state == NGHTTP2_IB_IGN_ALL ) { return ( ssize_t ) inlen ; } if ( rv == NGHTTP2_ERR_IGN_PAYLOAD ) { DEBUGF ( ""recv:DATAnotallowedstream_id=%d\\n"" , iframe -> frame . hd . stream_id ) ; iframe -> state = NGHTTP2_IB_IGN_DATA ; break ; } if ( nghttp2_is_fatal ( rv ) ) { return rv ; } rv = inbound_frame_handle_pad ( iframe , & iframe -> frame . hd ) ; if ( rv < 0 ) { rv = nghttp2_session_terminate_session_with_reason ( session , NGHTTP2_PROTOCOL_ERROR , ""DATA:insufficientpaddingspace"" ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } return ( ssize_t ) inlen ; } if ( rv == 1 ) { iframe -> state = NGHTTP2_IB_READ_PAD_DATA ; break ; } iframe -> state = NGHTTP2_IB_READ_DATA ; break ; } case NGHTTP2_HEADERS : DEBUGF ( ""recv:HEADERS\\n"" ) ; iframe -> frame . hd . flags &= ( NGHTTP2_FLAG_END_STREAM | NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_PADDED | NGHTTP2_FLAG_PRIORITY ) ; rv = inbound_frame_handle_pad ( iframe , & iframe -> frame . hd ) ; if ( rv < 0 ) { rv = nghttp2_session_terminate_session_with_reason ( session , NGHTTP2_PROTOCOL_ERROR , ""HEADERS:insufficientpaddingspace"" ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } return ( ssize_t ) inlen ; } if ( rv == 1 ) { iframe -> state = NGHTTP2_IB_READ_NBYTE ; break ; } pri_fieldlen = nghttp2_frame_priority_len ( iframe -> frame . hd . flags ) ; if ( pri_fieldlen > 0 ) { if ( iframe -> payloadleft < pri_fieldlen ) { busy = 1 ; iframe -> state = NGHTTP2_IB_FRAME_SIZE_ERROR ; break ; } iframe -> state = NGHTTP2_IB_READ_NBYTE ; inbound_frame_set_mark ( iframe , pri_fieldlen ) ; break ; } rv = session_call_on_begin_frame ( session , & iframe -> frame . hd ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } on_begin_frame_called = 1 ; rv = session_process_headers_frame ( session ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } busy = 1 ; if ( iframe -> state == NGHTTP2_IB_IGN_ALL ) { return ( ssize_t ) inlen ; } if ( rv == NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE ) { rv = nghttp2_session_add_rst_stream ( session , iframe -> frame . hd . stream_id , NGHTTP2_INTERNAL_ERROR ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } iframe -> state = NGHTTP2_IB_IGN_HEADER_BLOCK ; break ; } if ( rv == NGHTTP2_ERR_IGN_HEADER_BLOCK ) { iframe -> state = NGHTTP2_IB_IGN_HEADER_BLOCK ; break ; } iframe -> state = NGHTTP2_IB_READ_HEADER_BLOCK ; break ; case NGHTTP2_PRIORITY : DEBUGF ( ""recv:PRIORITY\\n"" ) ; iframe -> frame . hd . flags = NGHTTP2_FLAG_NONE ; if ( iframe -> payloadleft != NGHTTP2_PRIORITY_SPECLEN ) { busy = 1 ; iframe -> state = NGHTTP2_IB_FRAME_SIZE_ERROR ; break ; } iframe -> state = NGHTTP2_IB_READ_NBYTE ; inbound_frame_set_mark ( iframe , NGHTTP2_PRIORITY_SPECLEN ) ; break ; case NGHTTP2_RST_STREAM : case NGHTTP2_WINDOW_UPDATE : # ifdef DEBUGBUILD switch ( iframe -> frame . hd . type ) { case NGHTTP2_RST_STREAM : DEBUGF ( ""recv:RST_STREAM\\n"" ) ; break ; case NGHTTP2_WINDOW_UPDATE : DEBUGF ( ""recv:WINDOW_UPDATE\\n"" ) ; break ; } # endif iframe -> frame . hd . flags = NGHTTP2_FLAG_NONE ; if ( iframe -> payloadleft != 4 ) { busy = 1 ; iframe -> state = NGHTTP2_IB_FRAME_SIZE_ERROR ; break ; } iframe -> state = NGHTTP2_IB_READ_NBYTE ; inbound_frame_set_mark ( iframe , 4 ) ; break ; case NGHTTP2_SETTINGS : DEBUGF ( ""recv:SETTINGS\\n"" ) ; iframe -> frame . hd . flags &= NGHTTP2_FLAG_ACK ; if ( ( iframe -> frame . hd . length % NGHTTP2_FRAME_SETTINGS_ENTRY_LENGTH ) || ( ( iframe -> frame . hd . flags & NGHTTP2_FLAG_ACK ) && iframe -> payloadleft > 0 ) ) { busy = 1 ; iframe -> state = NGHTTP2_IB_FRAME_SIZE_ERROR ; break ; } iframe -> state = NGHTTP2_IB_READ_SETTINGS ; if ( iframe -> payloadleft ) { nghttp2_settings_entry * min_header_table_size_entry ; iframe -> max_niv = iframe -> frame . hd . length / NGHTTP2_FRAME_SETTINGS_ENTRY_LENGTH + 1 ; if ( iframe -> max_niv - 1 > session -> max_settings ) { rv = nghttp2_session_terminate_session_with_reason ( session , NGHTTP2_ENHANCE_YOUR_CALM , ""SETTINGS:toomanysettingentries"" ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } return ( ssize_t ) inlen ; } iframe -> iv = nghttp2_mem_malloc ( mem , sizeof ( nghttp2_settings_entry ) * iframe -> max_niv ) ; if ( ! iframe -> iv ) { return NGHTTP2_ERR_NOMEM ; } min_header_table_size_entry = & iframe -> iv [ iframe -> max_niv - 1 ] ; min_header_table_size_entry -> settings_id = NGHTTP2_SETTINGS_HEADER_TABLE_SIZE ; min_header_table_size_entry -> value = UINT32_MAX ; inbound_frame_set_mark ( iframe , NGHTTP2_FRAME_SETTINGS_ENTRY_LENGTH ) ; break ; } busy = 1 ; inbound_frame_set_mark ( iframe , 0 ) ; break ; case NGHTTP2_PUSH_PROMISE : DEBUGF ( ""recv:PUSH_PROMISE\\n"" ) ; iframe -> frame . hd . flags &= ( NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_PADDED ) ; rv = inbound_frame_handle_pad ( iframe , & iframe -> frame . hd ) ; if ( rv < 0 ) { rv = nghttp2_session_terminate_session_with_reason ( session , NGHTTP2_PROTOCOL_ERROR , ""PUSH_PROMISE:insufficientpaddingspace"" ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } return ( ssize_t ) inlen ; } if ( rv == 1 ) { iframe -> state = NGHTTP2_IB_READ_NBYTE ; break ; } if ( iframe -> payloadleft < 4 ) { busy = 1 ; iframe -> state = NGHTTP2_IB_FRAME_SIZE_ERROR ; break ; } iframe -> state = NGHTTP2_IB_READ_NBYTE ; inbound_frame_set_mark ( iframe , 4 ) ; break ; case NGHTTP2_PING : DEBUGF ( ""recv:PING\\n"" ) ; iframe -> frame . hd . flags &= NGHTTP2_FLAG_ACK ; if ( iframe -> payloadleft != 8 ) { busy = 1 ; iframe -> state = NGHTTP2_IB_FRAME_SIZE_ERROR ; break ; } iframe -> state = NGHTTP2_IB_READ_NBYTE ; inbound_frame_set_mark ( iframe , 8 ) ; break ; case NGHTTP2_GOAWAY : DEBUGF ( ""recv:GOAWAY\\n"" ) ; iframe -> frame . hd . flags = NGHTTP2_FLAG_NONE ; if ( iframe -> payloadleft < 8 ) { busy = 1 ; iframe -> state = NGHTTP2_IB_FRAME_SIZE_ERROR ; break ; } iframe -> state = NGHTTP2_IB_READ_NBYTE ; inbound_frame_set_mark ( iframe , 8 ) ; break ; case NGHTTP2_CONTINUATION : DEBUGF ( ""recv:unexpectedCONTINUATION\\n"" ) ; rv = nghttp2_session_terminate_session_with_reason ( session , NGHTTP2_PROTOCOL_ERROR , ""CONTINUATION:unexpected"" ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } return ( ssize_t ) inlen ; default : DEBUGF ( ""recv:extensionframe\\n"" ) ; if ( check_ext_type_set ( session -> user_recv_ext_types , iframe -> frame . hd . type ) ) { if ( ! session -> callbacks . unpack_extension_callback ) { busy = 1 ; iframe -> state = NGHTTP2_IB_IGN_PAYLOAD ; break ; } busy = 1 ; iframe -> state = NGHTTP2_IB_READ_EXTENSION_PAYLOAD ; break ; } else { switch ( iframe -> frame . hd . type ) { case NGHTTP2_ALTSVC : if ( ( session -> builtin_recv_ext_types & NGHTTP2_TYPEMASK_ALTSVC ) == 0 ) { busy = 1 ; iframe -> state = NGHTTP2_IB_IGN_PAYLOAD ; break ; } DEBUGF ( ""recv:ALTSVC\\n"" ) ; iframe -> frame . hd . flags = NGHTTP2_FLAG_NONE ; iframe -> frame . ext . payload = & iframe -> ext_frame_payload . altsvc ; if ( session -> server ) { busy = 1 ; iframe -> state = NGHTTP2_IB_IGN_PAYLOAD ; break ; } if ( iframe -> payloadleft < 2 ) { busy = 1 ; iframe -> state = NGHTTP2_IB_FRAME_SIZE_ERROR ; break ; } busy = 1 ; iframe -> state = NGHTTP2_IB_READ_NBYTE ; inbound_frame_set_mark ( iframe , 2 ) ; break ; case NGHTTP2_ORIGIN : if ( ! ( session -> builtin_recv_ext_types & NGHTTP2_TYPEMASK_ORIGIN ) ) { busy = 1 ; iframe -> state = NGHTTP2_IB_IGN_PAYLOAD ; break ; } DEBUGF ( ""recv:ORIGIN\\n"" ) ; iframe -> frame . ext . payload = & iframe -> ext_frame_payload . origin ; if ( session -> server || iframe -> frame . hd . stream_id || ( iframe -> frame . hd . flags & 0xf0 ) ) { busy = 1 ; iframe -> state = NGHTTP2_IB_IGN_PAYLOAD ; break ; } iframe -> frame . hd . flags = NGHTTP2_FLAG_NONE ; if ( iframe -> payloadleft ) { iframe -> raw_lbuf = nghttp2_mem_malloc ( mem , iframe -> payloadleft ) ; if ( iframe -> raw_lbuf == NULL ) { return NGHTTP2_ERR_NOMEM ; } nghttp2_buf_wrap_init ( & iframe -> lbuf , iframe -> raw_lbuf , iframe -> payloadleft ) ; } else { busy = 1 ; } iframe -> state = NGHTTP2_IB_READ_ORIGIN_PAYLOAD ; break ; default : busy = 1 ; iframe -> state = NGHTTP2_IB_IGN_PAYLOAD ; break ; } } } if ( ! on_begin_frame_called ) { switch ( iframe -> state ) { case NGHTTP2_IB_IGN_HEADER_BLOCK : case NGHTTP2_IB_IGN_PAYLOAD : case NGHTTP2_IB_FRAME_SIZE_ERROR : case NGHTTP2_IB_IGN_DATA : case NGHTTP2_IB_IGN_ALL : break ; default : rv = session_call_on_begin_frame ( session , & iframe -> frame . hd ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } } } break ; } case NGHTTP2_IB_READ_NBYTE : DEBUGF ( ""recv:[IB_READ_NBYTE]\\n"" ) ; readlen = inbound_frame_buf_read ( iframe , in , last ) ; in += readlen ; iframe -> payloadleft -= readlen ; DEBUGF ( ""recv:readlen=%zu,payloadleft=%zu,left=%zd\\n"" , readlen , iframe -> payloadleft , nghttp2_buf_mark_avail ( & iframe -> sbuf ) ) ; if ( nghttp2_buf_mark_avail ( & iframe -> sbuf ) ) { return in - first ; } switch ( iframe -> frame . hd . type ) { case NGHTTP2_HEADERS : if ( iframe -> padlen == 0 && ( iframe -> frame . hd . flags & NGHTTP2_FLAG_PADDED ) ) { pri_fieldlen = nghttp2_frame_priority_len ( iframe -> frame . hd . flags ) ; padlen = inbound_frame_compute_pad ( iframe ) ; if ( padlen < 0 || ( size_t ) padlen + pri_fieldlen > 1 + iframe -> payloadleft ) { rv = nghttp2_session_terminate_session_with_reason ( session , NGHTTP2_PROTOCOL_ERROR , ""HEADERS:invalidpadding"" ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } return ( ssize_t ) inlen ; } iframe -> frame . headers . padlen = ( size_t ) padlen ; if ( pri_fieldlen > 0 ) { if ( iframe -> payloadleft < pri_fieldlen ) { busy = 1 ; iframe -> state = NGHTTP2_IB_FRAME_SIZE_ERROR ; break ; } iframe -> state = NGHTTP2_IB_READ_NBYTE ; inbound_frame_set_mark ( iframe , pri_fieldlen ) ; break ; } else { inbound_frame_set_mark ( iframe , 0 ) ; } } rv = session_process_headers_frame ( session ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } busy = 1 ; if ( iframe -> state == NGHTTP2_IB_IGN_ALL ) { return ( ssize_t ) inlen ; } if ( rv == NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE ) { rv = nghttp2_session_add_rst_stream ( session , iframe -> frame . hd . stream_id , NGHTTP2_INTERNAL_ERROR ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } iframe -> state = NGHTTP2_IB_IGN_HEADER_BLOCK ; break ; } if ( rv == NGHTTP2_ERR_IGN_HEADER_BLOCK ) { iframe -> state = NGHTTP2_IB_IGN_HEADER_BLOCK ; break ; } iframe -> state = NGHTTP2_IB_READ_HEADER_BLOCK ; break ; case NGHTTP2_PRIORITY : rv = session_process_priority_frame ( session ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } if ( iframe -> state == NGHTTP2_IB_IGN_ALL ) { return ( ssize_t ) inlen ; } session_inbound_frame_reset ( session ) ; break ; case NGHTTP2_RST_STREAM : rv = session_process_rst_stream_frame ( session ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } if ( iframe -> state == NGHTTP2_IB_IGN_ALL ) { return ( ssize_t ) inlen ; } session_inbound_frame_reset ( session ) ; break ; case NGHTTP2_PUSH_PROMISE : if ( iframe -> padlen == 0 && ( iframe -> frame . hd . flags & NGHTTP2_FLAG_PADDED ) ) { padlen = inbound_frame_compute_pad ( iframe ) ; if ( padlen < 0 || ( size_t ) padlen + 4 > 1 + iframe -> payloadleft ) { rv = nghttp2_session_terminate_session_with_reason ( session , NGHTTP2_PROTOCOL_ERROR , ""PUSH_PROMISE:invalidpadding"" ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } return ( ssize_t ) inlen ; } iframe -> frame . push_promise . padlen = ( size_t ) padlen ; if ( iframe -> payloadleft < 4 ) { busy = 1 ; iframe -> state = NGHTTP2_IB_FRAME_SIZE_ERROR ; break ; } iframe -> state = NGHTTP2_IB_READ_NBYTE ; inbound_frame_set_mark ( iframe , 4 ) ; break ; } rv = session_process_push_promise_frame ( session ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } busy = 1 ; if ( iframe -> state == NGHTTP2_IB_IGN_ALL ) { return ( ssize_t ) inlen ; } if ( rv == NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE ) { rv = nghttp2_session_add_rst_stream ( session , iframe -> frame . push_promise . promised_stream_id , NGHTTP2_INTERNAL_ERROR ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } iframe -> state = NGHTTP2_IB_IGN_HEADER_BLOCK ; break ; } if ( rv == NGHTTP2_ERR_IGN_HEADER_BLOCK ) { iframe -> state = NGHTTP2_IB_IGN_HEADER_BLOCK ; break ; } iframe -> state = NGHTTP2_IB_READ_HEADER_BLOCK ; break ; case NGHTTP2_PING : rv = session_process_ping_frame ( session ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } if ( iframe -> state == NGHTTP2_IB_IGN_ALL ) { return ( ssize_t ) inlen ; } session_inbound_frame_reset ( session ) ; break ; case NGHTTP2_GOAWAY : { size_t debuglen ; debuglen = iframe -> frame . hd . length - 8 ; if ( debuglen > 0 ) { iframe -> raw_lbuf = nghttp2_mem_malloc ( mem , debuglen ) ; if ( iframe -> raw_lbuf == NULL ) { return NGHTTP2_ERR_NOMEM ; } nghttp2_buf_wrap_init ( & iframe -> lbuf , iframe -> raw_lbuf , debuglen ) ; } busy = 1 ; iframe -> state = NGHTTP2_IB_READ_GOAWAY_DEBUG ; break ; } case NGHTTP2_WINDOW_UPDATE : rv = session_process_window_update_frame ( session ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } if ( iframe -> state == NGHTTP2_IB_IGN_ALL ) { return ( ssize_t ) inlen ; } session_inbound_frame_reset ( session ) ; break ; case NGHTTP2_ALTSVC : { size_t origin_len ; origin_len = nghttp2_get_uint16 ( iframe -> sbuf . pos ) ; DEBUGF ( ""recv:origin_len=%zu\\n"" , origin_len ) ; if ( origin_len > iframe -> payloadleft ) { busy = 1 ; iframe -> state = NGHTTP2_IB_FRAME_SIZE_ERROR ; break ; } if ( iframe -> frame . hd . length > 2 ) { iframe -> raw_lbuf = nghttp2_mem_malloc ( mem , iframe -> frame . hd . length - 2 ) ; if ( iframe -> raw_lbuf == NULL ) { return NGHTTP2_ERR_NOMEM ; } nghttp2_buf_wrap_init ( & iframe -> lbuf , iframe -> raw_lbuf , iframe -> frame . hd . length ) ; } busy = 1 ; iframe -> state = NGHTTP2_IB_READ_ALTSVC_PAYLOAD ; break ; } default : session_inbound_frame_reset ( session ) ; break ; } break ; case NGHTTP2_IB_READ_HEADER_BLOCK : case NGHTTP2_IB_IGN_HEADER_BLOCK : { ssize_t data_readlen ; size_t trail_padlen ; int final ; # ifdef DEBUGBUILD if ( iframe -> state == NGHTTP2_IB_READ_HEADER_BLOCK ) { DEBUGF ( ""recv:[IB_READ_HEADER_BLOCK]\\n"" ) ; } else { DEBUGF ( ""recv:[IB_IGN_HEADER_BLOCK]\\n"" ) ; } # endif readlen = inbound_frame_payload_readlen ( iframe , in , last ) ; DEBUGF ( ""recv:readlen=%zu,payloadleft=%zu\\n"" , readlen , iframe -> payloadleft - readlen ) ; data_readlen = inbound_frame_effective_readlen ( iframe , iframe -> payloadleft - readlen , readlen ) ; if ( data_readlen == - 1 ) { data_readlen = 0 ; } trail_padlen = nghttp2_frame_trail_padlen ( & iframe -> frame , iframe -> padlen ) ; final = ( iframe -> frame . hd . flags & NGHTTP2_FLAG_END_HEADERS ) && iframe -> payloadleft - ( size_t ) data_readlen == trail_padlen ; if ( data_readlen > 0 || ( data_readlen == 0 && final ) ) { size_t hd_proclen = 0 ; DEBUGF ( ""recv:blockfinal=%d\\n"" , final ) ; rv = inflate_header_block ( session , & iframe -> frame , & hd_proclen , ( uint8_t * ) in , ( size_t ) data_readlen , final , iframe -> state == NGHTTP2_IB_READ_HEADER_BLOCK ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } if ( iframe -> state == NGHTTP2_IB_IGN_ALL ) { return ( ssize_t ) inlen ; } if ( rv == NGHTTP2_ERR_PAUSE ) { in += hd_proclen ; iframe -> payloadleft -= hd_proclen ; return in - first ; } if ( rv == NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE ) { in += hd_proclen ; iframe -> payloadleft -= hd_proclen ; rv = nghttp2_session_add_rst_stream ( session , iframe -> frame . hd . type == NGHTTP2_PUSH_PROMISE ? iframe -> frame . push_promise . promised_stream_id : iframe -> frame . hd . stream_id , NGHTTP2_INTERNAL_ERROR ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } busy = 1 ; iframe -> state = NGHTTP2_IB_IGN_HEADER_BLOCK ; break ; } in += readlen ; iframe -> payloadleft -= readlen ; if ( rv == NGHTTP2_ERR_HEADER_COMP ) { if ( iframe -> payloadleft == 0 ) { session_inbound_frame_reset ( session ) ; } else { busy = 1 ; iframe -> state = NGHTTP2_IB_IGN_PAYLOAD ; } break ; } } else { in += readlen ; iframe -> payloadleft -= readlen ; } if ( iframe -> payloadleft ) { break ; } if ( ( iframe -> frame . hd . flags & NGHTTP2_FLAG_END_HEADERS ) == 0 ) { inbound_frame_set_mark ( iframe , NGHTTP2_FRAME_HDLEN ) ; iframe -> padlen = 0 ; if ( iframe -> state == NGHTTP2_IB_READ_HEADER_BLOCK ) { iframe -> state = NGHTTP2_IB_EXPECT_CONTINUATION ; } else { iframe -> state = NGHTTP2_IB_IGN_CONTINUATION ; } } else { if ( iframe -> state == NGHTTP2_IB_READ_HEADER_BLOCK ) { rv = session_after_header_block_received ( session ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } } session_inbound_frame_reset ( session ) ; } break ; } case NGHTTP2_IB_IGN_PAYLOAD : DEBUGF ( ""recv:[IB_IGN_PAYLOAD]\\n"" ) ; readlen = inbound_frame_payload_readlen ( iframe , in , last ) ; iframe -> payloadleft -= readlen ; in += readlen ; DEBUGF ( ""recv:readlen=%zu,payloadleft=%zu\\n"" , readlen , iframe -> payloadleft ) ; if ( iframe -> payloadleft ) { break ; } switch ( iframe -> frame . hd . type ) { case NGHTTP2_HEADERS : case NGHTTP2_PUSH_PROMISE : case NGHTTP2_CONTINUATION : session -> hd_inflater . ctx . bad = 1 ; break ; default : break ; } session_inbound_frame_reset ( session ) ; break ; case NGHTTP2_IB_FRAME_SIZE_ERROR : DEBUGF ( ""recv:[IB_FRAME_SIZE_ERROR]\\n"" ) ; rv = session_handle_frame_size_error ( session ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } assert ( iframe -> state == NGHTTP2_IB_IGN_ALL ) ; return ( ssize_t ) inlen ; case NGHTTP2_IB_READ_SETTINGS : DEBUGF ( ""recv:[IB_READ_SETTINGS]\\n"" ) ; readlen = inbound_frame_buf_read ( iframe , in , last ) ; iframe -> payloadleft -= readlen ; in += readlen ; DEBUGF ( ""recv:readlen=%zu,payloadleft=%zu\\n"" , readlen , iframe -> payloadleft ) ; if ( nghttp2_buf_mark_avail ( & iframe -> sbuf ) ) { break ; } if ( readlen > 0 ) { inbound_frame_set_settings_entry ( iframe ) ; } if ( iframe -> payloadleft ) { inbound_frame_set_mark ( iframe , NGHTTP2_FRAME_SETTINGS_ENTRY_LENGTH ) ; break ; } rv = session_process_settings_frame ( session ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } if ( iframe -> state == NGHTTP2_IB_IGN_ALL ) { return ( ssize_t ) inlen ; } session_inbound_frame_reset ( session ) ; break ; case NGHTTP2_IB_READ_GOAWAY_DEBUG : DEBUGF ( ""recv:[IB_READ_GOAWAY_DEBUG]\\n"" ) ; readlen = inbound_frame_payload_readlen ( iframe , in , last ) ; if ( readlen > 0 ) { iframe -> lbuf . last = nghttp2_cpymem ( iframe -> lbuf . last , in , readlen ) ; iframe -> payloadleft -= readlen ; in += readlen ; } DEBUGF ( ""recv:readlen=%zu,payloadleft=%zu\\n"" , readlen , iframe -> payloadleft ) ; if ( iframe -> payloadleft ) { assert ( nghttp2_buf_avail ( & iframe -> lbuf ) > 0 ) ; break ; } rv = session_process_goaway_frame ( session ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } if ( iframe -> state == NGHTTP2_IB_IGN_ALL ) { return ( ssize_t ) inlen ; } session_inbound_frame_reset ( session ) ; break ; case NGHTTP2_IB_EXPECT_CONTINUATION : case NGHTTP2_IB_IGN_CONTINUATION : # ifdef DEBUGBUILD if ( iframe -> state == NGHTTP2_IB_EXPECT_CONTINUATION ) { fprintf ( stderr , ""recv:[IB_EXPECT_CONTINUATION]\\n"" ) ; } else { fprintf ( stderr , ""recv:[IB_IGN_CONTINUATION]\\n"" ) ; } # endif readlen = inbound_frame_buf_read ( iframe , in , last ) ; in += readlen ; if ( nghttp2_buf_mark_avail ( & iframe -> sbuf ) ) { return in - first ; } nghttp2_frame_unpack_frame_hd ( & cont_hd , iframe -> sbuf . pos ) ; iframe -> payloadleft = cont_hd . length ; DEBUGF ( ""recv:payloadlen=%zu,type=%u,flags=0x%02x,stream_id=%d\\n"" , cont_hd . length , cont_hd . type , cont_hd . flags , cont_hd . stream_id ) ; if ( cont_hd . type != NGHTTP2_CONTINUATION || cont_hd . stream_id != iframe -> frame . hd . stream_id ) { DEBUGF ( ""recv:expectedstream_id=%d,type=%d,butgotstream_id=%d,"" ""type=%u\\n"" , iframe -> frame . hd . stream_id , NGHTTP2_CONTINUATION , cont_hd . stream_id , cont_hd . type ) ; rv = nghttp2_session_terminate_session_with_reason ( session , NGHTTP2_PROTOCOL_ERROR , ""unexpectednon-CONTINUATIONframeorstream_idisinvalid"" ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } return ( ssize_t ) inlen ; } iframe -> frame . hd . flags = ( uint8_t ) ( iframe -> frame . hd . flags | ( cont_hd . flags & NGHTTP2_FLAG_END_HEADERS ) ) ; iframe -> frame . hd . length += cont_hd . length ; busy = 1 ; if ( iframe -> state == NGHTTP2_IB_EXPECT_CONTINUATION ) { iframe -> state = NGHTTP2_IB_READ_HEADER_BLOCK ; rv = session_call_on_begin_frame ( session , & cont_hd ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } } else { iframe -> state = NGHTTP2_IB_IGN_HEADER_BLOCK ; } break ; case NGHTTP2_IB_READ_PAD_DATA : DEBUGF ( ""recv:[IB_READ_PAD_DATA]\\n"" ) ; readlen = inbound_frame_buf_read ( iframe , in , last ) ; in += readlen ; iframe -> payloadleft -= readlen ; DEBUGF ( ""recv:readlen=%zu,payloadleft=%zu,left=%zu\\n"" , readlen , iframe -> payloadleft , nghttp2_buf_mark_avail ( & iframe -> sbuf ) ) ; if ( nghttp2_buf_mark_avail ( & iframe -> sbuf ) ) { return in - first ; } rv = nghttp2_session_update_recv_connection_window_size ( session , readlen ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } if ( iframe -> state == NGHTTP2_IB_IGN_ALL ) { return ( ssize_t ) inlen ; } rv = nghttp2_session_consume ( session , iframe -> frame . hd . stream_id , readlen ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } if ( iframe -> state == NGHTTP2_IB_IGN_ALL ) { return ( ssize_t ) inlen ; } stream = nghttp2_session_get_stream ( session , iframe -> frame . hd . stream_id ) ; if ( stream ) { rv = nghttp2_session_update_recv_stream_window_size ( session , stream , readlen , iframe -> payloadleft || ( iframe -> frame . hd . flags & NGHTTP2_FLAG_END_STREAM ) == 0 ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } } busy = 1 ; padlen = inbound_frame_compute_pad ( iframe ) ; if ( padlen < 0 ) { rv = nghttp2_session_terminate_session_with_reason ( session , NGHTTP2_PROTOCOL_ERROR , ""DATA:invalidpadding"" ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } return ( ssize_t ) inlen ; } iframe -> frame . data . padlen = ( size_t ) padlen ; iframe -> state = NGHTTP2_IB_READ_DATA ; break ; case NGHTTP2_IB_READ_DATA : stream = nghttp2_session_get_stream ( session , iframe -> frame . hd . stream_id ) ; if ( ! stream ) { busy = 1 ; iframe -> state = NGHTTP2_IB_IGN_DATA ; break ; } DEBUGF ( ""recv:[IB_READ_DATA]\\n"" ) ; readlen = inbound_frame_payload_readlen ( iframe , in , last ) ; iframe -> payloadleft -= readlen ; in += readlen ; DEBUGF ( ""recv:readlen=%zu,payloadleft=%zu\\n"" , readlen , iframe -> payloadleft ) ; if ( readlen > 0 ) { ssize_t data_readlen ; rv = nghttp2_session_update_recv_connection_window_size ( session , readlen ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } if ( iframe -> state == NGHTTP2_IB_IGN_ALL ) { return ( ssize_t ) inlen ; } rv = nghttp2_session_update_recv_stream_window_size ( session , stream , readlen , iframe -> payloadleft || ( iframe -> frame . hd . flags & NGHTTP2_FLAG_END_STREAM ) == 0 ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } data_readlen = inbound_frame_effective_readlen ( iframe , iframe -> payloadleft , readlen ) ; if ( data_readlen == - 1 ) { data_readlen = 0 ; } padlen = ( ssize_t ) readlen - data_readlen ; if ( padlen > 0 ) { rv = nghttp2_session_consume ( session , iframe -> frame . hd . stream_id , ( size_t ) padlen ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } if ( iframe -> state == NGHTTP2_IB_IGN_ALL ) { return ( ssize_t ) inlen ; } } DEBUGF ( ""recv:data_readlen=%zd\\n"" , data_readlen ) ; if ( data_readlen > 0 ) { if ( session_enforce_http_messaging ( session ) ) { if ( nghttp2_http_on_data_chunk ( stream , ( size_t ) data_readlen ) != 0 ) { if ( session -> opt_flags & NGHTTP2_OPTMASK_NO_AUTO_WINDOW_UPDATE ) { rv = session_update_connection_consumed_size ( session , ( size_t ) data_readlen ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } if ( iframe -> state == NGHTTP2_IB_IGN_DATA ) { return ( ssize_t ) inlen ; } } rv = nghttp2_session_add_rst_stream ( session , iframe -> frame . hd . stream_id , NGHTTP2_PROTOCOL_ERROR ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } busy = 1 ; iframe -> state = NGHTTP2_IB_IGN_DATA ; break ; } } if ( session -> callbacks . on_data_chunk_recv_callback ) { rv = session -> callbacks . on_data_chunk_recv_callback ( session , iframe -> frame . hd . flags , iframe -> frame . hd . stream_id , in - readlen , ( size_t ) data_readlen , session -> user_data ) ; if ( rv == NGHTTP2_ERR_PAUSE ) { return in - first ; } if ( nghttp2_is_fatal ( rv ) ) { return NGHTTP2_ERR_CALLBACK_FAILURE ; } } } } if ( iframe -> payloadleft ) { break ; } rv = session_process_data_frame ( session ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } session_inbound_frame_reset ( session ) ; break ; case NGHTTP2_IB_IGN_DATA : DEBUGF ( ""recv:[IB_IGN_DATA]\\n"" ) ; readlen = inbound_frame_payload_readlen ( iframe , in , last ) ; iframe -> payloadleft -= readlen ; in += readlen ; DEBUGF ( ""recv:readlen=%zu,payloadleft=%zu\\n"" , readlen , iframe -> payloadleft ) ; if ( readlen > 0 ) { rv = nghttp2_session_update_recv_connection_window_size ( session , readlen ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } if ( iframe -> state == NGHTTP2_IB_IGN_ALL ) { return ( ssize_t ) inlen ; } if ( session -> opt_flags & NGHTTP2_OPTMASK_NO_AUTO_WINDOW_UPDATE ) { rv = session_update_connection_consumed_size ( session , readlen ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } if ( iframe -> state == NGHTTP2_IB_IGN_ALL ) { return ( ssize_t ) inlen ; } } } if ( iframe -> payloadleft ) { break ; } session_inbound_frame_reset ( session ) ; break ; case NGHTTP2_IB_IGN_ALL : return ( ssize_t ) inlen ; case NGHTTP2_IB_READ_EXTENSION_PAYLOAD : DEBUGF ( ""recv:[IB_READ_EXTENSION_PAYLOAD]\\n"" ) ; readlen = inbound_frame_payload_readlen ( iframe , in , last ) ; iframe -> payloadleft -= readlen ; in += readlen ; DEBUGF ( ""recv:readlen=%zu,payloadleft=%zu\\n"" , readlen , iframe -> payloadleft ) ; if ( readlen > 0 ) { rv = session_call_on_extension_chunk_recv_callback ( session , in - readlen , readlen ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } if ( rv != 0 ) { busy = 1 ; iframe -> state = NGHTTP2_IB_IGN_PAYLOAD ; break ; } } if ( iframe -> payloadleft > 0 ) { break ; } rv = session_process_extension_frame ( session ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } session_inbound_frame_reset ( session ) ; break ; case NGHTTP2_IB_READ_ALTSVC_PAYLOAD : DEBUGF ( ""recv:[IB_READ_ALTSVC_PAYLOAD]\\n"" ) ; readlen = inbound_frame_payload_readlen ( iframe , in , last ) ; if ( readlen > 0 ) { iframe -> lbuf . last = nghttp2_cpymem ( iframe -> lbuf . last , in , readlen ) ; iframe -> payloadleft -= readlen ; in += readlen ; } DEBUGF ( ""recv:readlen=%zu,payloadleft=%zu\\n"" , readlen , iframe -> payloadleft ) ; if ( iframe -> payloadleft ) { assert ( nghttp2_buf_avail ( & iframe -> lbuf ) > 0 ) ; break ; } rv = session_process_altsvc_frame ( session ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } session_inbound_frame_reset ( session ) ; break ; case NGHTTP2_IB_READ_ORIGIN_PAYLOAD : DEBUGF ( ""recv:[IB_READ_ORIGIN_PAYLOAD]\\n"" ) ; readlen = inbound_frame_payload_readlen ( iframe , in , last ) ; if ( readlen > 0 ) { iframe -> lbuf . last = nghttp2_cpymem ( iframe -> lbuf . last , in , readlen ) ; iframe -> payloadleft -= readlen ; in += readlen ; } DEBUGF ( ""recv:readlen=%zu,payloadleft=%zu\\n"" , readlen , iframe -> payloadleft ) ; if ( iframe -> payloadleft ) { assert ( nghttp2_buf_avail ( & iframe -> lbuf ) > 0 ) ; break ; } rv = session_process_origin_frame ( session ) ; if ( nghttp2_is_fatal ( rv ) ) { return rv ; } if ( iframe -> state == NGHTTP2_IB_IGN_ALL ) { return ( ssize_t ) inlen ; } session_inbound_frame_reset ( session ) ; break ; } if ( ! busy && in == last ) { break ; } busy = 0 ; } assert ( in == last ) ; return in - first ; } "," break ; } if ( session -> obq_flood_counter_ >= session -> max_outbound_ack && ! ( iframe -> frame . hd . flags & NGHTTP2_FLAG_ACK ) ) { return NGHTTP2_ERR_FLOODED ; } ",nghttp2@nghttp2/f8da73bd042f810f34d19f9eae02b46d870af394,CVE-2020-11080,https://github.com/nghttp2/nghttp2/commit/f8da73bd042f810f34d19f9eae02b46d870af394,2020-06-03T23:15Z 943,CWE-400,"CWE-400 static struct mnt_namespace * alloc_mnt_ns ( struct user_namespace * user_ns ) { struct mnt_namespace * new_ns ; struct ucounts * ucounts ; int ret ; ucounts = inc_mnt_namespaces ( user_ns ) ; if ( ! ucounts ) return ERR_PTR ( - ENOSPC ) ; new_ns = kmalloc ( sizeof ( struct mnt_namespace ) , GFP_KERNEL ) ; if ( ! new_ns ) { dec_mnt_namespaces ( ucounts ) ; return ERR_PTR ( - ENOMEM ) ; } ret = ns_alloc_inum ( & new_ns -> ns ) ; if ( ret ) { kfree ( new_ns ) ; dec_mnt_namespaces ( ucounts ) ; return ERR_PTR ( ret ) ; } new_ns -> ns . ops = & mntns_operations ; new_ns -> seq = atomic64_add_return ( 1 , & mnt_ns_seq ) ; atomic_set ( & new_ns -> count , 1 ) ; new_ns -> root = NULL ; INIT_LIST_HEAD ( & new_ns -> list ) ; init_waitqueue_head ( & new_ns -> poll ) ; new_ns -> event = 0 ; new_ns -> user_ns = get_user_ns ( user_ns ) ; new_ns -> ucounts = ucounts ; return new_ns ; } "," = ucounts ; new_ns -> mounts = 0 ; new_ns -> pending_mounts = 0 ; ",torvalds@linux/d29216842a85c7970c536108e093963f02714498,CVE-2016-6213,https://github.com/torvalds/linux/commit/d29216842a85c7970c536108e093963f02714498,2016-12-28T07:59Z 944,CWE-416,"CWE-416 struct ipv6_txoptions * ipv6_dup_options ( struct sock * sk , struct ipv6_txoptions * opt ) { struct ipv6_txoptions * opt2 ; opt2 = sock_kmalloc ( sk , opt -> tot_len , GFP_ATOMIC ) ; if ( opt2 ) { long dif = ( char * ) opt2 - ( char * ) opt ; memcpy ( opt2 , opt , opt -> tot_len ) ; if ( opt2 -> hopopt ) * ( ( char * * ) & opt2 -> hopopt ) += dif ; if ( opt2 -> dst0opt ) * ( ( char * * ) & opt2 -> dst0opt ) += dif ; if ( opt2 -> dst1opt ) * ( ( char * * ) & opt2 -> dst1opt ) += dif ; if ( opt2 -> srcrt ) * ( ( char * * ) & opt2 -> srcrt ) += dif ; } return opt2 ; } "," += dif ; atomic_set ( & opt2 -> refcnt , 1 ) ; ",torvalds@linux/45f6fad84cc305103b28d73482b344d7f5b76f39,CVE-2016-3841,https://github.com/torvalds/linux/commit/45f6fad84cc305103b28d73482b344d7f5b76f39,2016-08-06T20:59Z 945,CWE-20,"CWE-20 __init int intel_pmu_init ( void ) { union cpuid10_edx edx ; union cpuid10_eax eax ; union cpuid10_ebx ebx ; struct event_constraint * c ; unsigned int unused ; int version ; if ( ! cpu_has ( & boot_cpu_data , X86_FEATURE_ARCH_PERFMON ) ) { switch ( boot_cpu_data . x86 ) { case 0x6 : return p6_pmu_init ( ) ; case 0xb : return knc_pmu_init ( ) ; case 0xf : return p4_pmu_init ( ) ; } return - ENODEV ; } cpuid ( 10 , & eax . full , & ebx . full , & unused , & edx . full ) ; if ( eax . split . mask_length < ARCH_PERFMON_EVENTS_COUNT ) return - ENODEV ; version = eax . split . version_id ; if ( version < 2 ) x86_pmu = core_pmu ; else x86_pmu = intel_pmu ; x86_pmu . version = version ; x86_pmu . num_counters = eax . split . num_counters ; x86_pmu . cntval_bits = eax . split . bit_width ; x86_pmu . cntval_mask = ( 1ULL << eax . split . bit_width ) - 1 ; x86_pmu . events_maskl = ebx . full ; x86_pmu . events_mask_len = eax . split . mask_length ; x86_pmu . max_pebs_events = min_t ( unsigned , MAX_PEBS_EVENTS , x86_pmu . num_counters ) ; if ( version > 1 ) x86_pmu . num_counters_fixed = max ( ( int ) edx . split . num_counters_fixed , 3 ) ; if ( version > 1 ) { u64 capabilities ; rdmsrl ( MSR_IA32_PERF_CAPABILITIES , capabilities ) ; x86_pmu . intel_cap . capabilities = capabilities ; } intel_ds_init ( ) ; x86_add_quirk ( intel_arch_events_quirk ) ; switch ( boot_cpu_data . x86_model ) { case 14 : pr_cont ( ""Coreevents,"" ) ; break ; case 15 : x86_add_quirk ( intel_clovertown_quirk ) ; case 22 : case 23 : case 29 : memcpy ( hw_cache_event_ids , core2_hw_cache_event_ids , sizeof ( hw_cache_event_ids ) ) ; intel_pmu_lbr_init_core ( ) ; x86_pmu . event_constraints = intel_core2_event_constraints ; x86_pmu . pebs_constraints = intel_core2_pebs_event_constraints ; pr_cont ( ""Core2events,"" ) ; break ; case 26 : case 30 : case 46 : memcpy ( hw_cache_event_ids , nehalem_hw_cache_event_ids , sizeof ( hw_cache_event_ids ) ) ; memcpy ( hw_cache_extra_regs , nehalem_hw_cache_extra_regs , sizeof ( hw_cache_extra_regs ) ) ; intel_pmu_lbr_init_nhm ( ) ; x86_pmu . event_constraints = intel_nehalem_event_constraints ; x86_pmu . pebs_constraints = intel_nehalem_pebs_event_constraints ; x86_pmu . enable_all = intel_pmu_nhm_enable_all ; x86_pmu . extra_regs = intel_nehalem_extra_regs ; intel_perfmon_event_map [ PERF_COUNT_HW_STALLED_CYCLES_FRONTEND ] = X86_CONFIG ( . event = 0x0e , . umask = 0x01 , . inv = 1 , . cmask = 1 ) ; intel_perfmon_event_map [ PERF_COUNT_HW_STALLED_CYCLES_BACKEND ] = X86_CONFIG ( . event = 0xb1 , . umask = 0x3f , . inv = 1 , . cmask = 1 ) ; x86_add_quirk ( intel_nehalem_quirk ) ; pr_cont ( ""Nehalemevents,"" ) ; break ; case 28 : case 38 : case 39 : case 53 : case 54 : memcpy ( hw_cache_event_ids , atom_hw_cache_event_ids , sizeof ( hw_cache_event_ids ) ) ; intel_pmu_lbr_init_atom ( ) ; x86_pmu . event_constraints = intel_gen_event_constraints ; x86_pmu . pebs_constraints = intel_atom_pebs_event_constraints ; pr_cont ( ""Atomevents,"" ) ; break ; case 37 : case 44 : case 47 : memcpy ( hw_cache_event_ids , westmere_hw_cache_event_ids , sizeof ( hw_cache_event_ids ) ) ; memcpy ( hw_cache_extra_regs , nehalem_hw_cache_extra_regs , sizeof ( hw_cache_extra_regs ) ) ; intel_pmu_lbr_init_nhm ( ) ; x86_pmu . event_constraints = intel_westmere_event_constraints ; x86_pmu . enable_all = intel_pmu_nhm_enable_all ; x86_pmu . pebs_constraints = intel_westmere_pebs_event_constraints ; x86_pmu . extra_regs = intel_westmere_extra_regs ; x86_pmu . er_flags |= ERF_HAS_RSP_1 ; intel_perfmon_event_map [ PERF_COUNT_HW_STALLED_CYCLES_FRONTEND ] = X86_CONFIG ( . event = 0x0e , . umask = 0x01 , . inv = 1 , . cmask = 1 ) ; intel_perfmon_event_map [ PERF_COUNT_HW_STALLED_CYCLES_BACKEND ] = X86_CONFIG ( . event = 0xb1 , . umask = 0x3f , . inv = 1 , . cmask = 1 ) ; pr_cont ( ""Westmereevents,"" ) ; break ; case 42 : case 45 : x86_add_quirk ( intel_sandybridge_quirk ) ; memcpy ( hw_cache_event_ids , snb_hw_cache_event_ids , sizeof ( hw_cache_event_ids ) ) ; memcpy ( hw_cache_extra_regs , snb_hw_cache_extra_regs , sizeof ( hw_cache_extra_regs ) ) ; intel_pmu_lbr_init_snb ( ) ; x86_pmu . event_constraints = intel_snb_event_constraints ; x86_pmu . pebs_constraints = intel_snb_pebs_event_constraints ; x86_pmu . pebs_aliases = intel_pebs_aliases_snb ; x86_pmu . extra_regs = intel_snb_extra_regs ; x86_pmu . er_flags |= ERF_HAS_RSP_1 ; x86_pmu . er_flags |= ERF_NO_HT_SHARING ; intel_perfmon_event_map [ PERF_COUNT_HW_STALLED_CYCLES_FRONTEND ] = X86_CONFIG ( . event = 0x0e , . umask = 0x01 , . inv = 1 , . cmask = 1 ) ; intel_perfmon_event_map [ PERF_COUNT_HW_STALLED_CYCLES_BACKEND ] = X86_CONFIG ( . event = 0xb1 , . umask = 0x01 , . inv = 1 , . cmask = 1 ) ; pr_cont ( ""SandyBridgeevents,"" ) ; break ; case 58 : case 62 : memcpy ( hw_cache_event_ids , snb_hw_cache_event_ids , sizeof ( hw_cache_event_ids ) ) ; memcpy ( hw_cache_extra_regs , snb_hw_cache_extra_regs , sizeof ( hw_cache_extra_regs ) ) ; intel_pmu_lbr_init_snb ( ) ; x86_pmu . event_constraints = intel_ivb_event_constraints ; x86_pmu . pebs_constraints = intel_ivb_pebs_event_constraints ; x86_pmu . pebs_aliases = intel_pebs_aliases_snb ; x86_pmu . extra_regs = intel_snb_extra_regs ; x86_pmu . er_flags |= ERF_HAS_RSP_1 ; x86_pmu . er_flags |= ERF_NO_HT_SHARING ; intel_perfmon_event_map [ PERF_COUNT_HW_STALLED_CYCLES_FRONTEND ] = X86_CONFIG ( . event = 0x0e , . umask = 0x01 , . inv = 1 , . cmask = 1 ) ; pr_cont ( ""IvyBridgeevents,"" ) ; break ; default : switch ( x86_pmu . version ) { case 1 : x86_pmu . event_constraints = intel_v1_event_constraints ; pr_cont ( ""genericarchitectedperfmonv1,"" ) ; break ; default : x86_pmu . event_constraints = intel_gen_event_constraints ; pr_cont ( ""genericarchitectedperfmon,"" ) ; break ; } } if ( x86_pmu . num_counters > INTEL_PMC_MAX_GENERIC ) { WARN ( 1 , KERN_ERR ""hwperfevents%d>max(%d),clipping!"" , x86_pmu . num_counters , INTEL_PMC_MAX_GENERIC ) ; x86_pmu . num_counters = INTEL_PMC_MAX_GENERIC ; } x86_pmu . intel_ctrl = ( 1 << x86_pmu . num_counters ) - 1 ; if ( x86_pmu . num_counters_fixed > INTEL_PMC_MAX_FIXED ) { WARN ( 1 , KERN_ERR ""hwperfeventsfixed%d>max(%d),clipping!"" , x86_pmu . num_counters_fixed , INTEL_PMC_MAX_FIXED ) ; x86_pmu . num_counters_fixed = INTEL_PMC_MAX_FIXED ; } x86_pmu . intel_ctrl |= ( ( 1LL << x86_pmu . num_counters_fixed ) - 1 ) << INTEL_PMC_IDX_FIXED ; if ( x86_pmu . event_constraints ) { for_each_event_constraint ( c , x86_pmu . event_constraints ) { if ( c -> cmask != X86_RAW_EVENT_MASK || c -> idxmsk64 == INTEL_PMC_MSK_FIXED_REF_CYCLES ) { continue ; } c -> idxmsk64 |= ( 1ULL << x86_pmu . num_counters ) - 1 ; c -> weight += x86_pmu . num_counters ; } } return 0 ; } "," = intel_pebs_aliases_snb ; if ( boot_cpu_data . x86_model == 45 ) x86_pmu . extra_regs = intel_snbep_extra_regs ; else = intel_pebs_aliases_snb ; if ( boot_cpu_data . x86_model == 62 ) x86_pmu . extra_regs = intel_snbep_extra_regs ; else ",torvalds@linux/f1923820c447e986a9da0fc6bf60c1dccdf0408e,CVE-2013-2146,https://github.com/torvalds/linux/commit/f1923820c447e986a9da0fc6bf60c1dccdf0408e,2013-06-07T14:03Z 946,CWE-119,"CWE-119 static void decode_residue ( vorb * f , float * residue_buffers [ ] , int ch , int n , int rn , uint8 * do_not_decode ) { int i , j , pass ; Residue * r = f -> residue_config + rn ; int rtype = f -> residue_types [ rn ] ; int c = r -> classbook ; int classwords = f -> codebooks [ c ] . dimensions ; int n_read = r -> end - r -> begin ; int part_read = n_read / r -> part_size ; int temp_alloc_point = temp_alloc_save ( f ) ; # ifndef STB_VORBIS_DIVIDES_IN_RESIDUE uint8 * * * part_classdata = ( uint8 * * * ) temp_block_array ( f , f -> channels , part_read * sizeof ( * * part_classdata ) ) ; # else int * * classifications = ( int * * ) temp_block_array ( f , f -> channels , part_read * sizeof ( * * classifications ) ) ; # endif CHECK ( f ) ; for ( i = 0 ; i < ch ; ++ i ) if ( ! do_not_decode [ i ] ) memset ( residue_buffers [ i ] , 0 , sizeof ( float ) * n ) ; if ( rtype == 2 && ch != 1 ) { for ( j = 0 ; j < ch ; ++ j ) if ( ! do_not_decode [ j ] ) break ; if ( j == ch ) goto done ; for ( pass = 0 ; pass < 8 ; ++ pass ) { int pcount = 0 , class_set = 0 ; if ( ch == 2 ) { while ( pcount < part_read ) { int z = r -> begin + pcount * r -> part_size ; int c_inter = ( z & 1 ) , p_inter = z >> 1 ; if ( pass == 0 ) { Codebook * c = f -> codebooks + r -> classbook ; int q ; DECODE ( q , f , c ) ; if ( q == EOP ) goto done ; # ifndef STB_VORBIS_DIVIDES_IN_RESIDUE part_classdata [ 0 ] [ class_set ] = r -> classdata [ q ] ; # else for ( i = classwords - 1 ; i >= 0 ; -- i ) { classifications [ 0 ] [ i + pcount ] = q % r -> classifications ; q /= r -> classifications ; } # endif } for ( i = 0 ; i < classwords && pcount < part_read ; ++ i , ++ pcount ) { int z = r -> begin + pcount * r -> part_size ; # ifndef STB_VORBIS_DIVIDES_IN_RESIDUE int c = part_classdata [ 0 ] [ class_set ] [ i ] ; # else int c = classifications [ 0 ] [ pcount ] ; # endif int b = r -> residue_books [ c ] [ pass ] ; if ( b >= 0 ) { Codebook * book = f -> codebooks + b ; # ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK if ( ! codebook_decode_deinterleave_repeat ( f , book , residue_buffers , ch , & c_inter , & p_inter , n , r -> part_size ) ) goto done ; # else if ( ! codebook_decode_deinterleave_repeat ( f , book , residue_buffers , ch , & c_inter , & p_inter , n , r -> part_size ) ) goto done ; # endif } else { z += r -> part_size ; c_inter = z & 1 ; p_inter = z >> 1 ; } } # ifndef STB_VORBIS_DIVIDES_IN_RESIDUE ++ class_set ; # endif } } else if ( ch == 1 ) { while ( pcount < part_read ) { int z = r -> begin + pcount * r -> part_size ; int c_inter = 0 , p_inter = z ; if ( pass == 0 ) { Codebook * c = f -> codebooks + r -> classbook ; int q ; DECODE ( q , f , c ) ; if ( q == EOP ) goto done ; # ifndef STB_VORBIS_DIVIDES_IN_RESIDUE part_classdata [ 0 ] [ class_set ] = r -> classdata [ q ] ; # else for ( i = classwords - 1 ; i >= 0 ; -- i ) { classifications [ 0 ] [ i + pcount ] = q % r -> classifications ; q /= r -> classifications ; } # endif } for ( i = 0 ; i < classwords && pcount < part_read ; ++ i , ++ pcount ) { int z = r -> begin + pcount * r -> part_size ; # ifndef STB_VORBIS_DIVIDES_IN_RESIDUE int c = part_classdata [ 0 ] [ class_set ] [ i ] ; # else int c = classifications [ 0 ] [ pcount ] ; # endif int b = r -> residue_books [ c ] [ pass ] ; if ( b >= 0 ) { Codebook * book = f -> codebooks + b ; if ( ! codebook_decode_deinterleave_repeat ( f , book , residue_buffers , ch , & c_inter , & p_inter , n , r -> part_size ) ) goto done ; } else { z += r -> part_size ; c_inter = 0 ; p_inter = z ; } } # ifndef STB_VORBIS_DIVIDES_IN_RESIDUE ++ class_set ; # endif } } else { while ( pcount < part_read ) { int z = r -> begin + pcount * r -> part_size ; int c_inter = z % ch , p_inter = z / ch ; if ( pass == 0 ) { Codebook * c = f -> codebooks + r -> classbook ; int q ; DECODE ( q , f , c ) ; if ( q == EOP ) goto done ; # ifndef STB_VORBIS_DIVIDES_IN_RESIDUE part_classdata [ 0 ] [ class_set ] = r -> classdata [ q ] ; # else for ( i = classwords - 1 ; i >= 0 ; -- i ) { classifications [ 0 ] [ i + pcount ] = q % r -> classifications ; q /= r -> classifications ; } # endif } for ( i = 0 ; i < classwords && pcount < part_read ; ++ i , ++ pcount ) { int z = r -> begin + pcount * r -> part_size ; # ifndef STB_VORBIS_DIVIDES_IN_RESIDUE int c = part_classdata [ 0 ] [ class_set ] [ i ] ; # else int c = classifications [ 0 ] [ pcount ] ; # endif int b = r -> residue_books [ c ] [ pass ] ; if ( b >= 0 ) { Codebook * book = f -> codebooks + b ; if ( ! codebook_decode_deinterleave_repeat ( f , book , residue_buffers , ch , & c_inter , & p_inter , n , r -> part_size ) ) goto done ; } else { z += r -> part_size ; c_inter = z % ch ; p_inter = z / ch ; } } # ifndef STB_VORBIS_DIVIDES_IN_RESIDUE ++ class_set ; # endif } } } goto done ; } CHECK ( f ) ; for ( pass = 0 ; pass < 8 ; ++ pass ) { int pcount = 0 , class_set = 0 ; while ( pcount < part_read ) { if ( pass == 0 ) { for ( j = 0 ; j < ch ; ++ j ) { if ( ! do_not_decode [ j ] ) { Codebook * c = f -> codebooks + r -> classbook ; int temp ; DECODE ( temp , f , c ) ; if ( temp == EOP ) goto done ; # ifndef STB_VORBIS_DIVIDES_IN_RESIDUE part_classdata [ j ] [ class_set ] = r -> classdata [ temp ] ; # else for ( i = classwords - 1 ; i >= 0 ; -- i ) { classifications [ j ] [ i + pcount ] = temp % r -> classifications ; temp /= r -> classifications ; } # endif } } } for ( i = 0 ; i < classwords && pcount < part_read ; ++ i , ++ pcount ) { for ( j = 0 ; j < ch ; ++ j ) { if ( ! do_not_decode [ j ] ) { # ifndef STB_VORBIS_DIVIDES_IN_RESIDUE int c = part_classdata [ j ] [ class_set ] [ i ] ; # else int c = classifications [ j ] [ pcount ] ; # endif int b = r -> residue_books [ c ] [ pass ] ; if ( b >= 0 ) { float * target = residue_buffers [ j ] ; int offset = r -> begin + pcount * r -> part_size ; int n = r -> part_size ; Codebook * book = f -> codebooks + b ; if ( ! residue_decode ( f , book , target , offset , n , rtype ) ) goto done ; } } } } # ifndef STB_VORBIS_DIVIDES_IN_RESIDUE ++ class_set ; # endif } } done : CHECK ( f ) ; # ifndef STB_VORBIS_DIVIDES_IN_RESIDUE temp_free ( f , part_classdata ) ; # else temp_free ( f , classifications ) ; # endif temp_alloc_restore ( f , temp_alloc_point ) ; } "," . dimensions ; unsigned int actual_size = rtype == 2 ? n * 2 : n ; unsigned int limit_r_begin = ( r -> begin < actual_size ? r -> begin : actual_size ) ; unsigned int limit_r_end = ( r -> end < actual_size ? r -> end : actual_size ) ; int n_read = limit_r_end - limit_r_begin ; int part_read ",nothings@stb/244d83bc3d859293f55812d48b3db168e581f6ab,CVE-2018-1000050,https://github.com/nothings/stb/commit/244d83bc3d859293f55812d48b3db168e581f6ab,2018-02-09T23:29Z 947,CWE-200,"CWE-200 static void tcp_send_challenge_ack ( struct sock * sk , const struct sk_buff * skb ) { static u32 challenge_timestamp ; static unsigned int challenge_count ; struct tcp_sock * tp = tcp_sk ( sk ) ; u32 now ; if ( tcp_oow_rate_limited ( sock_net ( sk ) , skb , LINUX_MIB_TCPACKSKIPPEDCHALLENGE , & tp -> last_oow_ack_time ) ) return ; now = jiffies / HZ ; if ( now != challenge_timestamp ) { challenge_timestamp = now ; challenge_count = 0 ; } if ( ++ challenge_count <= sysctl_tcp_challenge_ack_limit ) { NET_INC_STATS ( sock_net ( sk ) , LINUX_MIB_TCPCHALLENGEACK ) ; tcp_send_ack ( sk ) ; } } "," ) ; u32 count , challenge_timestamp ) { u32 half = ( sysctl_tcp_challenge_ack_limit + 1 ) >> 1 ; = now ; WRITE_ONCE ( challenge_count , half + prandom_u32_max ( sysctl_tcp_challenge_ack_limit ) ) ; } count = READ_ONCE ( challenge_count ) ; if ( count > 0 ) { WRITE_ONCE ( challenge_count , count - 1 ) ; NET_INC_STATS ( sock_net ",torvalds@linux/75ff39ccc1bd5d3c455b6822ab09e533c551f758,CVE-2016-5696,https://github.com/torvalds/linux/commit/75ff39ccc1bd5d3c455b6822ab09e533c551f758,2016-08-06T20:59Z 948,CWE-200,"CWE-200 static void llc_cmsg_rcv ( struct msghdr * msg , struct sk_buff * skb ) { struct llc_sock * llc = llc_sk ( skb -> sk ) ; if ( llc -> cmsg_flags & LLC_CMSG_PKTINFO ) { struct llc_pktinfo info ; info . lpi_ifindex = llc_sk ( skb -> sk ) -> dev -> ifindex ; llc_pdu_decode_dsap ( skb , & info . lpi_sap ) ; llc_pdu_decode_da ( skb , info . lpi_mac ) ; put_cmsg ( msg , SOL_LLC , LLC_OPT_PKTINFO , sizeof ( info ) , & info ) ; } } "," struct llc_pktinfo info ; memset ( & info , 0 , sizeof ( info ) ) ",torvalds@linux/b8670c09f37bdf2847cc44f36511a53afc6161fd,CVE-2016-4485,https://github.com/torvalds/linux/commit/b8670c09f37bdf2847cc44f36511a53afc6161fd,2016-05-23T10:59Z 949,CWE-119,"CWE-119 static void pack_mb_tokens ( vp9_writer * w , TOKENEXTRA * * tp , const TOKENEXTRA * stop ) { TOKENEXTRA * p = * tp ; while ( p < stop && p -> token != EOSB_TOKEN ) { const int t = p -> token ; const struct vp9_token * const a = & vp9_coef_encodings [ t ] ; const vp9_extra_bit * const b = & vp9_extra_bits [ t ] ; int i = 0 ; int v = a -> value ; int n = a -> len ; if ( p -> skip_eob_node ) { n -= p -> skip_eob_node ; i = 2 * p -> skip_eob_node ; } if ( t >= TWO_TOKEN && t < EOB_TOKEN ) { int len = UNCONSTRAINED_NODES - p -> skip_eob_node ; int bits = v >> ( n - len ) ; vp9_write_tree ( w , vp9_coef_tree , p -> context_tree , bits , len , i ) ; vp9_write_tree ( w , vp9_coef_con_tree , vp9_pareto8_full [ p -> context_tree [ PIVOT_NODE ] - 1 ] , v , n - len , 0 ) ; } else { vp9_write_tree ( w , vp9_coef_tree , p -> context_tree , v , n , i ) ; } if ( b -> base_val ) { const int e = p -> extra , l = b -> len ; if ( l ) { const unsigned char * pb = b -> prob ; int v = e >> 1 ; int n = l ; int i = 0 ; do { const int bb = ( v >> -- n ) & 1 ; vp9_write ( w , bb , pb [ i >> 1 ] ) ; i = b -> tree [ i + bb ] ; } while ( n ) ; } vp9_write_bit ( w , e & 1 ) ; } ++ p ; } * tp = p + ( p -> token == EOSB_TOKEN ) ; } "," void pack_mb_tokens ( vpx_writer * w , const TOKENEXTRA * const stop , vpx_bit_depth_t bit_depth ) { TOKENEXTRA t ] ; int i = 0 ; int v = a -> value ; int n = a -> len ; # if CONFIG_VP9_HIGHBITDEPTH const vp9_extra_bit * b ; if ( bit_depth == VPX_BITS_12 ) b = & vp9_extra_bits_high12 [ t ] ; else if ( bit_depth == VPX_BITS_10 ) b = & vp9_extra_bits_high10 [ t ] ; else b = & t ] ; # else const vp9_extra_bit * const b = & vp9_extra_bits [ t ] ; ( void ) bit_depth ; # endif if ( p & 1 ; vpx_write ( w , ) ; } vpx_write_bit ( w , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 950,CWE-119,"CWE-119 void vp9_pack_bitstream ( VP9_COMP * cpi , uint8_t * dest , size_t * size ) { uint8_t * data = dest ; size_t first_part_size , uncompressed_hdr_size ; struct vp9_write_bit_buffer wb = { data , 0 } ; struct vp9_write_bit_buffer saved_wb ; write_uncompressed_header ( cpi , & wb ) ; saved_wb = wb ; vp9_wb_write_literal ( & wb , 0 , 16 ) ; uncompressed_hdr_size = vp9_rb_bytes_written ( & wb ) ; data += uncompressed_hdr_size ; vp9_compute_update_table ( ) ; vp9_clear_system_state ( ) ; first_part_size = write_compressed_header ( cpi , data ) ; data += first_part_size ; vp9_wb_write_literal ( & saved_wb , ( int ) first_part_size , 16 ) ; data += encode_tiles ( cpi , data ) ; * size = data - dest ; } "," uncompressed_hdr_size ; struct vpx_write_bit_buffer wb = { } ; struct vpx_write_bit_buffer saved_wb ; write_uncompressed_header = wb ; vpx_wb_write_literal ( & wb ; uncompressed_hdr_size = vpx_wb_bytes_written ( & wb += uncompressed_hdr_size ; vpx_clear_system_state ( ) ; += first_part_size ; vpx_wb_write_literal ( & saved_wb ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 951,CWE-476,"CWE-476 static int dev_get_valid_name ( struct net * net , struct net_device * dev , const char * name ) { BUG_ON ( ! net ) ; if ( ! dev_valid_name ( name ) ) return - EINVAL ; if ( strchr ( name , '%' ) ) return dev_alloc_name_ns ( net , dev , name ) ; else if ( __dev_get_by_name ( net , name ) ) return - EEXIST ; else if ( dev -> name != name ) strlcpy ( dev -> name , name , IFNAMSIZ ) ; return 0 ; } "," int dev_get_valid_name ( ",torvalds@linux/0ad646c81b2182f7fa67ec0c8c825e0ee165696d,CVE-2018-7191,https://github.com/torvalds/linux/commit/0ad646c81b2182f7fa67ec0c8c825e0ee165696d,2019-05-17T05:29Z 952,CWE-125,"CWE-125 static int usbhid_parse ( struct hid_device * hid ) { struct usb_interface * intf = to_usb_interface ( hid -> dev . parent ) ; struct usb_host_interface * interface = intf -> cur_altsetting ; struct usb_device * dev = interface_to_usbdev ( intf ) ; struct hid_descriptor * hdesc ; u32 quirks = 0 ; unsigned int rsize = 0 ; char * rdesc ; int ret , n ; quirks = usbhid_lookup_quirk ( le16_to_cpu ( dev -> descriptor . idVendor ) , le16_to_cpu ( dev -> descriptor . idProduct ) ) ; if ( quirks & HID_QUIRK_IGNORE ) return - ENODEV ; if ( interface -> desc . bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT ) { if ( interface -> desc . bInterfaceProtocol == USB_INTERFACE_PROTOCOL_KEYBOARD || interface -> desc . bInterfaceProtocol == USB_INTERFACE_PROTOCOL_MOUSE ) quirks |= HID_QUIRK_NOGET ; } if ( usb_get_extra_descriptor ( interface , HID_DT_HID , & hdesc ) && ( ! interface -> desc . bNumEndpoints || usb_get_extra_descriptor ( & interface -> endpoint [ 0 ] , HID_DT_HID , & hdesc ) ) ) { dbg_hid ( ""classdescriptornotpresent\\n"" ) ; return - ENODEV ; } hid -> version = le16_to_cpu ( hdesc -> bcdHID ) ; hid -> country = hdesc -> bCountryCode ; for ( n = 0 ; n < hdesc -> bNumDescriptors ; n ++ ) if ( hdesc -> desc [ n ] . bDescriptorType == HID_DT_REPORT ) rsize = le16_to_cpu ( hdesc -> desc [ n ] . wDescriptorLength ) ; if ( ! rsize || rsize > HID_MAX_DESCRIPTOR_SIZE ) { dbg_hid ( ""weirdsizeofreportdescriptor(%u)\\n"" , rsize ) ; return - EINVAL ; } rdesc = kmalloc ( rsize , GFP_KERNEL ) ; if ( ! rdesc ) return - ENOMEM ; hid_set_idle ( dev , interface -> desc . bInterfaceNumber , 0 , 0 ) ; ret = hid_get_class_descriptor ( dev , interface -> desc . bInterfaceNumber , HID_DT_REPORT , rdesc , rsize ) ; if ( ret < 0 ) { dbg_hid ( ""readingreportdescriptorfailed\\n"" ) ; kfree ( rdesc ) ; goto err ; } ret = hid_parse_report ( hid , rdesc , rsize ) ; kfree ( rdesc ) ; if ( ret ) { dbg_hid ( ""parsingreportdescriptorfailed\\n"" ) ; goto err ; } hid -> quirks |= quirks ; return 0 ; err : return ret ; } "," ret , n ; int num_descriptors ; size_t offset = offsetof ( struct hid_descriptor , desc ) ENODEV ; } if ( hdesc -> bLength < sizeof ( struct hid_descriptor ) ) { dbg_hid ( ""hiddescriptoristooshort\\n"" ) ; return - EINVAL ; } hdesc -> bCountryCode ; num_descriptors = min_t ( int , hdesc -> bNumDescriptors , ( hdesc -> bLength - offset ) / sizeof ( struct hid_class_descriptor ) ) ; n < num_descriptors ; n ++ ",torvalds@linux/f043bfc98c193c284e2cd768fefabe18ac2fed9b,CVE-2017-16533,https://github.com/torvalds/linux/commit/f043bfc98c193c284e2cd768fefabe18ac2fed9b,2017-11-04T01:29Z 953,CWE-125,"CWE-125 static const u_char * ikev2_ID_print ( netdissect_options * ndo , u_char tpay , const struct isakmp_gen * ext , u_int item_len _U_ , const u_char * ep _U_ , uint32_t phase _U_ , uint32_t doi _U_ , uint32_t proto _U_ , int depth _U_ ) { struct ikev2_id id ; int id_len , idtype_len , i ; unsigned int dumpascii , dumphex ; const unsigned char * typedata ; ND_TCHECK ( * ext ) ; UNALIGNED_MEMCPY ( & id , ext , sizeof ( id ) ) ; ikev2_pay_print ( ndo , NPSTR ( tpay ) , id . h . critical ) ; id_len = ntohs ( id . h . len ) ; ND_PRINT ( ( ndo , ""len=%d"" , id_len - 4 ) ) ; if ( 2 < ndo -> ndo_vflag && 4 < id_len ) { ND_PRINT ( ( ndo , """" ) ) ; if ( ! rawprint ( ndo , ( const uint8_t * ) ( ext + 1 ) , id_len - 4 ) ) goto trunc ; } idtype_len = id_len - sizeof ( struct ikev2_id ) ; dumpascii = 0 ; dumphex = 0 ; typedata = ( const unsigned char * ) ( ext ) + sizeof ( struct ikev2_id ) ; switch ( id . type ) { case ID_IPV4_ADDR : ND_PRINT ( ( ndo , ""ipv4:"" ) ) ; dumphex = 1 ; break ; case ID_FQDN : ND_PRINT ( ( ndo , ""fqdn:"" ) ) ; dumpascii = 1 ; break ; case ID_RFC822_ADDR : ND_PRINT ( ( ndo , ""rfc822:"" ) ) ; dumpascii = 1 ; break ; case ID_IPV6_ADDR : ND_PRINT ( ( ndo , ""ipv6:"" ) ) ; dumphex = 1 ; break ; case ID_DER_ASN1_DN : ND_PRINT ( ( ndo , ""dn:"" ) ) ; dumphex = 1 ; break ; case ID_DER_ASN1_GN : ND_PRINT ( ( ndo , ""gn:"" ) ) ; dumphex = 1 ; break ; case ID_KEY_ID : ND_PRINT ( ( ndo , ""keyid:"" ) ) ; dumphex = 1 ; break ; } if ( dumpascii ) { ND_TCHECK2 ( * typedata , idtype_len ) ; for ( i = 0 ; i < idtype_len ; i ++ ) { if ( ND_ISPRINT ( typedata [ i ] ) ) { ND_PRINT ( ( ndo , ""%c"" , typedata [ i ] ) ) ; } else { ND_PRINT ( ( ndo , ""."" ) ) ; } } } if ( dumphex ) { if ( ! rawprint ( ndo , ( const uint8_t * ) typedata , idtype_len ) ) goto trunc ; } return ( const u_char * ) ext + id_len ; trunc : ND_PRINT ( ( ndo , ""[|%s]"" , NPSTR ( tpay ) ) ) ; return NULL ; } "," _U_ ) { const struct ikev2_id * idp ; * typedata ; idp = ( const struct ikev2_id * ) ext ; ND_TCHECK ( * idp ) ; UNALIGNED_MEMCPY ",the-tcpdump-group@tcpdump/8dca25d26c7ca2caf6138267f6f17111212c156e,CVE-2017-13690,https://github.com/the-tcpdump-group/tcpdump/commit/8dca25d26c7ca2caf6138267f6f17111212c156e,2017-09-14T06:29Z 954,CWE-264,"CWE-264 NORET_TYPE void do_exit ( long code ) { struct task_struct * tsk = current ; int group_dead ; profile_task_exit ( tsk ) ; WARN_ON ( atomic_read ( & tsk -> fs_excl ) ) ; if ( unlikely ( in_interrupt ( ) ) ) panic ( ""Aiee,killinginterrupthandler!"" ) ; if ( unlikely ( ! tsk -> pid ) ) panic ( ""Attemptedtokilltheidletask!"" ) ; tracehook_report_exit ( & code ) ; if ( unlikely ( tsk -> flags & PF_EXITING ) ) { printk ( KERN_ALERT ""Fixingrecursivefaultbutrebootisneeded!\\n"" ) ; tsk -> flags |= PF_EXITPIDONE ; if ( tsk -> io_context ) exit_io_context ( ) ; set_current_state ( TASK_UNINTERRUPTIBLE ) ; schedule ( ) ; } exit_signals ( tsk ) ; smp_mb ( ) ; spin_unlock_wait ( & tsk -> pi_lock ) ; if ( unlikely ( in_atomic ( ) ) ) printk ( KERN_INFO ""note:%s[%d]exitedwithpreempt_count%d\\n"" , current -> comm , task_pid_nr ( current ) , preempt_count ( ) ) ; acct_update_integrals ( tsk ) ; if ( tsk -> mm ) { update_hiwater_rss ( tsk -> mm ) ; update_hiwater_vm ( tsk -> mm ) ; } group_dead = atomic_dec_and_test ( & tsk -> signal -> live ) ; if ( group_dead ) { hrtimer_cancel ( & tsk -> signal -> real_timer ) ; exit_itimers ( tsk -> signal ) ; } acct_collect ( code , group_dead ) ; # ifdef CONFIG_FUTEX if ( unlikely ( tsk -> robust_list ) ) exit_robust_list ( tsk ) ; # ifdef CONFIG_COMPAT if ( unlikely ( tsk -> compat_robust_list ) ) compat_exit_robust_list ( tsk ) ; # endif # endif if ( group_dead ) tty_audit_exit ( ) ; if ( unlikely ( tsk -> audit_context ) ) audit_free ( tsk ) ; tsk -> exit_code = code ; taskstats_exit ( tsk , group_dead ) ; exit_mm ( tsk ) ; if ( group_dead ) acct_process ( ) ; trace_sched_process_exit ( tsk ) ; exit_sem ( tsk ) ; exit_files ( tsk ) ; exit_fs ( tsk ) ; check_stack_usage ( ) ; exit_thread ( ) ; cgroup_exit ( tsk , 1 ) ; exit_keys ( tsk ) ; if ( group_dead && tsk -> signal -> leader ) disassociate_ctty ( 1 ) ; module_put ( task_thread_info ( tsk ) -> exec_domain -> module ) ; if ( tsk -> binfmt ) module_put ( tsk -> binfmt -> module ) ; proc_exit_connector ( tsk ) ; exit_notify ( tsk , group_dead ) ; # ifdef CONFIG_NUMA mpol_put ( tsk -> mempolicy ) ; tsk -> mempolicy = NULL ; # endif # ifdef CONFIG_FUTEX if ( unlikely ( ! list_empty ( & tsk -> pi_state_list ) ) ) exit_pi_state_list ( tsk ) ; if ( unlikely ( current -> pi_state_cache ) ) kfree ( current -> pi_state_cache ) ; # endif debug_check_no_locks_held ( tsk ) ; tsk -> flags |= PF_EXITPIDONE ; if ( tsk -> io_context ) exit_io_context ( ) ; if ( tsk -> splice_pipe ) __free_pipe_info ( tsk -> splice_pipe ) ; preempt_disable ( ) ; tsk -> state = TASK_DEAD ; schedule ( ) ; BUG ( ) ; for ( ; ; ) cpu_relax ( ) ; } "," group_dead ) ; if ( group_dead ) tty_audit_exit ( ) ; if ( unlikely ( tsk -> audit_context ) ) audit_free ( tsk ) ; tsk -> exit_code = code ; taskstats_exit ( tsk , group_dead ) ; exit_mm ( tsk ) ; if ( group_dead ) acct_process ( ) ; trace_sched_process_exit ( tsk ) ; exit_sem ( tsk ) ; exit_files ( tsk ) ; exit_fs ( tsk ) ; check_stack_usage ( ) ; exit_thread ( ) ; cgroup_exit ( tsk , 1 ) ; exit_keys ( tsk ) ; if ( group_dead && tsk -> signal -> leader ) disassociate_ctty ( 1 ) ; module_put ( task_thread_info ( tsk ) -> exec_domain -> module ) ; if ( tsk -> binfmt ) module_put ( tsk -> binfmt -> module ) ; proc_exit_connector ( tsk ) ; exit_notify ( tsk , group_dead ) ; # ifdef CONFIG_NUMA mpol_put ( tsk -> mempolicy ) ; tsk -> mempolicy = NULL ; # endif ( unlikely ( ! list_empty ( ",torvalds@linux/8141c7f3e7aee618312fa1c15109e1219de784a7,CVE-2012-0028,https://github.com/torvalds/linux/commit/8141c7f3e7aee618312fa1c15109e1219de784a7,2012-06-21T23:55Z 955,CWE-119,"CWE-119 static void show_object ( struct object * obj , struct strbuf * path , const char * last , void * data ) { char * name = path_name ( path , last ) ; add_preferred_base_object ( name ) ; add_object_entry ( obj -> oid . hash , obj -> type , name , 0 ) ; obj -> flags |= OBJECT_ADDED ; free ( ( char * ) name ) ; } "," * obj , const char * const char * name , void * data ) { add_preferred_base_object ( name |= OBJECT_ADDED ; } ",git@git/de1e67d0703894cb6ea782e36abb63976ab07e60,CVE-2016-2324,https://github.com/git/git/commit/de1e67d0703894cb6ea782e36abb63976ab07e60,2016-04-08T14:59Z 956,CWE-416,"CWE-416 static int mif_process_cmpt ( mif_hdr_t * hdr , char * buf ) { jas_tvparser_t * tvp ; mif_cmpt_t * cmpt ; int id ; cmpt = 0 ; tvp = 0 ; if ( ! ( cmpt = mif_cmpt_create ( ) ) ) { goto error ; } cmpt -> tlx = 0 ; cmpt -> tly = 0 ; cmpt -> sampperx = 0 ; cmpt -> samppery = 0 ; cmpt -> width = 0 ; cmpt -> height = 0 ; cmpt -> prec = 0 ; cmpt -> sgnd = - 1 ; cmpt -> data = 0 ; if ( ! ( tvp = jas_tvparser_create ( buf ) ) ) { goto error ; } while ( ! ( id = jas_tvparser_next ( tvp ) ) ) { switch ( jas_taginfo_nonull ( jas_taginfos_lookup ( mif_tags , jas_tvparser_gettag ( tvp ) ) ) -> id ) { case MIF_TLX : cmpt -> tlx = atoi ( jas_tvparser_getval ( tvp ) ) ; break ; case MIF_TLY : cmpt -> tly = atoi ( jas_tvparser_getval ( tvp ) ) ; break ; case MIF_WIDTH : cmpt -> width = atoi ( jas_tvparser_getval ( tvp ) ) ; break ; case MIF_HEIGHT : cmpt -> height = atoi ( jas_tvparser_getval ( tvp ) ) ; break ; case MIF_HSAMP : cmpt -> sampperx = atoi ( jas_tvparser_getval ( tvp ) ) ; break ; case MIF_VSAMP : cmpt -> samppery = atoi ( jas_tvparser_getval ( tvp ) ) ; break ; case MIF_PREC : cmpt -> prec = atoi ( jas_tvparser_getval ( tvp ) ) ; break ; case MIF_SGND : cmpt -> sgnd = atoi ( jas_tvparser_getval ( tvp ) ) ; break ; case MIF_DATA : if ( ! ( cmpt -> data = jas_strdup ( jas_tvparser_getval ( tvp ) ) ) ) { return - 1 ; } break ; } } jas_tvparser_destroy ( tvp ) ; if ( ! cmpt -> sampperx || ! cmpt -> samppery ) { goto error ; } if ( mif_hdr_addcmpt ( hdr , hdr -> numcmpts , cmpt ) ) { goto error ; } return 0 ; error : if ( cmpt ) { mif_cmpt_destroy ( cmpt ) ; } if ( tvp ) { jas_tvparser_destroy ( tvp ) ; } return - 1 ; } "," ; } } if ( ! error ; } jas_tvparser_destroy ( tvp ) ; ",mdadams@jasper/df5d2867e8004e51e18b89865bc4aa69229227b3,CVE-2015-5221,https://github.com/mdadams/jasper/commit/df5d2867e8004e51e18b89865bc4aa69229227b3,2017-07-25T18:29Z 957,CWE-401,"CWE-401 static int ath10k_usb_hif_tx_sg ( struct ath10k * ar , u8 pipe_id , struct ath10k_hif_sg_item * items , int n_items ) { struct ath10k_usb * ar_usb = ath10k_usb_priv ( ar ) ; struct ath10k_usb_pipe * pipe = & ar_usb -> pipes [ pipe_id ] ; struct ath10k_urb_context * urb_context ; struct sk_buff * skb ; struct urb * urb ; int ret , i ; for ( i = 0 ; i < n_items ; i ++ ) { urb_context = ath10k_usb_alloc_urb_from_pipe ( pipe ) ; if ( ! urb_context ) { ret = - ENOMEM ; goto err ; } skb = items [ i ] . transfer_context ; urb_context -> skb = skb ; urb = usb_alloc_urb ( 0 , GFP_ATOMIC ) ; if ( ! urb ) { ret = - ENOMEM ; goto err_free_urb_to_pipe ; } usb_fill_bulk_urb ( urb , ar_usb -> udev , pipe -> usb_pipe_handle , skb -> data , skb -> len , ath10k_usb_transmit_complete , urb_context ) ; if ( ! ( skb -> len % pipe -> max_packet_size ) ) { urb -> transfer_flags |= URB_ZERO_PACKET ; } usb_anchor_urb ( urb , & pipe -> urb_submitted ) ; ret = usb_submit_urb ( urb , GFP_ATOMIC ) ; if ( ret ) { ath10k_dbg ( ar , ATH10K_DBG_USB_BULK , ""usbbulktransmitfailed:%d\\n"" , ret ) ; usb_unanchor_urb ( urb ) ; ret = - EINVAL ; goto err_free_urb_to_pipe ; } usb_free_urb ( urb ) ; } return 0 ; err_free_urb_to_pipe : ath10k_usb_free_urb_to_pipe ( urb_context -> pipe , urb_context ) ; err : return ret ; } "," urb ) ; usb_free_urb ( urb ) ; ",torvalds@linux/b8d17e7d93d2beb89e4f34c59996376b8b544792,CVE-2019-19078,https://github.com/torvalds/linux/commit/b8d17e7d93d2beb89e4f34c59996376b8b544792,2019-11-18T06:15Z 958,CWE-787,"CWE-787 VOID ixheaacd_esbr_radix4bfly ( const WORD32 * w , WORD32 * x , WORD32 index1 , WORD32 index ) { int i ; WORD32 l1 , l2 , h2 , fft_jmp ; WORD32 xt0_0 , yt0_0 , xt1_0 , yt1_0 , xt2_0 , yt2_0 ; WORD32 xh0_0 , xh1_0 , xh20_0 , xh21_0 , xl0_0 , xl1_0 , xl20_0 , xl21_0 ; WORD32 x_0 , x_1 , x_l1_0 , x_l1_1 , x_l2_0 , x_l2_1 ; WORD32 x_h2_0 , x_h2_1 ; WORD32 si10 , si20 , si30 , co10 , co20 , co30 ; WORD64 mul_1 , mul_2 , mul_3 , mul_4 , mul_5 , mul_6 ; WORD64 mul_7 , mul_8 , mul_9 , mul_10 , mul_11 , mul_12 ; WORD32 * x_l1 ; WORD32 * x_l2 ; WORD32 * x_h2 ; const WORD32 * w_ptr = w ; WORD32 i1 ; h2 = index << 1 ; l1 = index << 2 ; l2 = ( index << 2 ) + ( index << 1 ) ; x_l1 = & ( x [ l1 ] ) ; x_l2 = & ( x [ l2 ] ) ; x_h2 = & ( x [ h2 ] ) ; fft_jmp = 6 * ( index ) ; for ( i1 = 0 ; i1 < index1 ; i1 ++ ) { for ( i = 0 ; i < index ; i ++ ) { si10 = ( * w_ptr ++ ) ; co10 = ( * w_ptr ++ ) ; si20 = ( * w_ptr ++ ) ; co20 = ( * w_ptr ++ ) ; si30 = ( * w_ptr ++ ) ; co30 = ( * w_ptr ++ ) ; x_0 = x [ 0 ] ; x_h2_0 = x [ h2 ] ; x_l1_0 = x [ l1 ] ; x_l2_0 = x [ l2 ] ; xh0_0 = x_0 + x_l1_0 ; xl0_0 = x_0 - x_l1_0 ; xh20_0 = x_h2_0 + x_l2_0 ; xl20_0 = x_h2_0 - x_l2_0 ; x [ 0 ] = xh0_0 + xh20_0 ; xt0_0 = xh0_0 - xh20_0 ; x_1 = x [ 1 ] ; x_h2_1 = x [ h2 + 1 ] ; x_l1_1 = x [ l1 + 1 ] ; x_l2_1 = x [ l2 + 1 ] ; xh1_0 = x_1 + x_l1_1 ; xl1_0 = x_1 - x_l1_1 ; xh21_0 = x_h2_1 + x_l2_1 ; xl21_0 = x_h2_1 - x_l2_1 ; x [ 1 ] = xh1_0 + xh21_0 ; yt0_0 = xh1_0 - xh21_0 ; xt1_0 = xl0_0 + xl21_0 ; xt2_0 = xl0_0 - xl21_0 ; yt2_0 = xl1_0 + xl20_0 ; yt1_0 = xl1_0 - xl20_0 ; mul_11 = ixheaacd_mult64 ( xt2_0 , co30 ) ; mul_3 = ixheaacd_mult64 ( yt2_0 , si30 ) ; x [ l2 ] = ( WORD32 ) ( ( mul_3 + mul_11 ) >> 32 ) << RADIXSHIFT ; mul_5 = ixheaacd_mult64 ( xt2_0 , si30 ) ; mul_9 = ixheaacd_mult64 ( yt2_0 , co30 ) ; x [ l2 + 1 ] = ( WORD32 ) ( ( mul_9 - mul_5 ) >> 32 ) << RADIXSHIFT ; mul_12 = ixheaacd_mult64 ( xt0_0 , co20 ) ; mul_2 = ixheaacd_mult64 ( yt0_0 , si20 ) ; x [ l1 ] = ( WORD32 ) ( ( mul_2 + mul_12 ) >> 32 ) << RADIXSHIFT ; mul_6 = ixheaacd_mult64 ( xt0_0 , si20 ) ; mul_8 = ixheaacd_mult64 ( yt0_0 , co20 ) ; x [ l1 + 1 ] = ( WORD32 ) ( ( mul_8 - mul_6 ) >> 32 ) << RADIXSHIFT ; mul_4 = ixheaacd_mult64 ( xt1_0 , co10 ) ; mul_1 = ixheaacd_mult64 ( yt1_0 , si10 ) ; x [ h2 ] = ( WORD32 ) ( ( mul_1 + mul_4 ) >> 32 ) << RADIXSHIFT ; mul_10 = ixheaacd_mult64 ( xt1_0 , si10 ) ; mul_7 = ixheaacd_mult64 ( yt1_0 , co10 ) ; x [ h2 + 1 ] = ( WORD32 ) ( ( mul_7 - mul_10 ) >> 32 ) << RADIXSHIFT ; x += 2 ; } x += fft_jmp ; w_ptr = w_ptr - fft_jmp ; } } "," , fft_jmp ; WORD64 xt0_0 , yt0_0 , yt2_0 ; WORD64 xh0_0 , xh1_0 ; xh0_0 = ( WORD64 ) x_0 + ( WORD64 ) x_l1_0 ; xl0_0 ; xl0_0 = ( WORD64 ) x_0 - ( WORD64 ) x_l1_0 ; xh20_0 ; xh20_0 = ( WORD64 ) x_h2_0 + ( WORD64 ) x_l2_0 ; xl20_0 ; xl20_0 = ( WORD64 ) x_h2_0 - ( WORD64 ) x_l2_0 ; x 0 ] = ( WORD32 ) ixheaacd_add64_sat ( xh0_0 , xh20_0 ) ; xt0_0 = ; xt0_0 = ( WORD64 ) xh0_0 - ( WORD64 ) xh20_0 ; x_1 ; xh1_0 = ( WORD64 ) x_1 + ( WORD64 ) x_l1_1 ; xl1_0 ; xl1_0 = ( WORD64 ) x_1 - ( WORD64 ) x_l1_1 ; xh21_0 ; xh21_0 = ( WORD64 ) x_h2_1 + ( WORD64 ) x_l2_1 ; xl21_0 ; xl21_0 = ( WORD64 ) x_h2_1 - ( WORD64 ) x_l2_1 ; x 1 ] = ( WORD32 ) ixheaacd_add64_sat ( xh1_0 , xh21_0 ) ; yt0_0 = ; yt0_0 = ( WORD64 ) xh1_0 - ( WORD64 ) xh21_0 ; xt1_0 ; xt1_0 = ( WORD64 ) xl0_0 + ( WORD64 ) xl21_0 ; xt2_0 ; xt2_0 = ( WORD64 ) xl0_0 - ( WORD64 ) xl21_0 ; yt2_0 ; yt2_0 = ( WORD64 ) xl1_0 + ( WORD64 ) xl20_0 ; yt1_0 ; yt1_0 = ( WORD64 ) xl1_0 - ( WORD64 ) xl20_0 ; mul_11 ",external@libxaac/04e8cd58f075bec5892e369c8deebca9c67e855c,CVE-2018-9496,https://android.googlesource.com/platform/external/libxaac/+/04e8cd58f075bec5892e369c8deebca9c67e855c,2018-10-02T19:29Z 959,CWE-000,"CWE-000 static int asn1_find_indefinite_length ( const unsigned char * data , size_t datalen , size_t * _dp , size_t * _len , const char * * _errmsg ) { unsigned char tag , tmp ; size_t dp = * _dp , len , n ; int indef_level = 1 ; next_tag : if ( unlikely ( datalen - dp < 2 ) ) { if ( datalen == dp ) goto missing_eoc ; goto data_overrun_error ; } tag = data [ dp ++ ] ; if ( tag == 0 ) { if ( data [ dp ++ ] != 0 ) goto invalid_eoc ; if ( -- indef_level <= 0 ) { * _len = dp - * _dp ; * _dp = dp ; return 0 ; } goto next_tag ; } if ( unlikely ( ( tag & 0x1f ) == ASN1_LONG_TAG ) ) { do { if ( unlikely ( datalen - dp < 2 ) ) goto data_overrun_error ; tmp = data [ dp ++ ] ; } while ( tmp & 0x80 ) ; } len = data [ dp ++ ] ; if ( len <= 0x7f ) { dp += len ; goto next_tag ; } if ( unlikely ( len == ASN1_INDEFINITE_LENGTH ) ) { if ( unlikely ( ( tag & ASN1_CONS_BIT ) == ASN1_PRIM << 5 ) ) goto indefinite_len_primitive ; indef_level ++ ; goto next_tag ; } n = len - 0x80 ; if ( unlikely ( n > sizeof ( size_t ) - 1 ) ) goto length_too_long ; if ( unlikely ( n > datalen - dp ) ) goto data_overrun_error ; for ( len = 0 ; n > 0 ; n -- ) { len <<= 8 ; len |= data [ dp ++ ] ; } dp += len ; goto next_tag ; length_too_long : * _errmsg = ""Unsupportedlength"" ; goto error ; indefinite_len_primitive : * _errmsg = ""Indefinitelenprimitivenotpermitted"" ; goto error ; invalid_eoc : * _errmsg = ""InvalidlengthEOC"" ; goto error ; data_overrun_error : * _errmsg = ""Dataoverrunerror"" ; goto error ; missing_eoc : * _errmsg = ""MissingEOCinindefinitelencons"" ; error : * _dp = dp ; return - 1 ; } "," ( tag == ASN1_EOC ) { if <= 0x7f ) goto check_length ; if ( unlikely > sizeof ( len ) - 1 goto data_overrun_error ; len = 0 ; for ( ; n > ] ; } check_length : if ( len > datalen - dp ) goto data_overrun_error ; ",torvalds@linux/23c8a812dc3c621009e4f0e5342aa4e2ede1ceaa,CVE-2016-0758,https://github.com/torvalds/linux/commit/23c8a812dc3c621009e4f0e5342aa4e2ede1ceaa,2016-06-27T10:59Z 960,CWE-200,"CWE-200 static void * __alloc_from_pool ( size_t size , struct page * * ret_page , gfp_t flags ) { unsigned long val ; void * ptr = NULL ; if ( ! atomic_pool ) { WARN ( 1 , ""coherentpoolnotinitialised!\\n"" ) ; return NULL ; } val = gen_pool_alloc ( atomic_pool , size ) ; if ( val ) { phys_addr_t phys = gen_pool_virt_to_phys ( atomic_pool , val ) ; * ret_page = phys_to_page ( phys ) ; ptr = ( void * ) val ; if ( flags & __GFP_ZERO ) memset ( ptr , 0 , size ) ; } return ptr ; } "," ) val ; memset ( ptr ",torvalds@linux/6829e274a623187c24f7cfc0e3d35f25d087fcc5,CVE-2015-8950,https://github.com/torvalds/linux/commit/6829e274a623187c24f7cfc0e3d35f25d087fcc5,2016-10-10T10:59Z 961,CWE-59,"CWE-59 static inline int mount_entry_on_systemfs ( struct mntent * mntent ) { return mount_entry_on_generic ( mntent , mntent -> mnt_dir ) ; } "," mntent -> mnt_dir , NULL ",lxc@lxc/592fd47a6245508b79fe6ac819fe6d3b2c1289be,CVE-2015-1335,https://github.com/lxc/lxc/commit/592fd47a6245508b79fe6ac819fe6d3b2c1289be,2015-10-01T20:59Z 962,CWE-119,"CWE-119 int phar_verify_signature ( php_stream * fp , size_t end_of_phar , php_uint32 sig_type , char * sig , int sig_len , char * fname , char * * signature , int * signature_len , char * * error ) { int read_size , len ; zend_off_t read_len ; unsigned char buf [ 1024 ] ; php_stream_rewind ( fp ) ; switch ( sig_type ) { case PHAR_SIG_OPENSSL : { # ifdef PHAR_HAVE_OPENSSL BIO * in ; EVP_PKEY * key ; EVP_MD * mdtype = ( EVP_MD * ) EVP_sha1 ( ) ; EVP_MD_CTX md_ctx ; # else int tempsig ; # endif zend_string * pubkey = NULL ; char * pfile ; php_stream * pfp ; # ifndef PHAR_HAVE_OPENSSL if ( ! zend_hash_str_exists ( & module_registry , ""openssl"" , sizeof ( ""openssl"" ) - 1 ) ) { if ( error ) { spprintf ( error , 0 , ""opensslnotloaded"" ) ; } return FAILURE ; } # endif spprintf ( & pfile , 0 , ""%s.pubkey"" , fname ) ; pfp = php_stream_open_wrapper ( pfile , ""rb"" , 0 , NULL ) ; efree ( pfile ) ; if ( ! pfp || ! ( pubkey = php_stream_copy_to_mem ( pfp , PHP_STREAM_COPY_ALL , 0 ) ) || ! ZSTR_LEN ( pubkey ) ) { if ( pfp ) { php_stream_close ( pfp ) ; } if ( error ) { spprintf ( error , 0 , ""opensslpublickeycouldnotberead"" ) ; } return FAILURE ; } php_stream_close ( pfp ) ; # ifndef PHAR_HAVE_OPENSSL tempsig = sig_len ; if ( FAILURE == phar_call_openssl_signverify ( 0 , fp , end_of_phar , pubkey ? ZSTR_VAL ( pubkey ) : NULL , pubkey ? ZSTR_LEN ( pubkey ) : 0 , & sig , & tempsig ) ) { if ( pubkey ) { zend_string_release ( pubkey ) ; } if ( error ) { spprintf ( error , 0 , ""opensslsignaturecouldnotbeverified"" ) ; } return FAILURE ; } if ( pubkey ) { zend_string_release ( pubkey ) ; } sig_len = tempsig ; # else in = BIO_new_mem_buf ( pubkey ? ZSTR_VAL ( pubkey ) : NULL , pubkey ? ZSTR_LEN ( pubkey ) : 0 ) ; if ( NULL == in ) { zend_string_release ( pubkey ) ; if ( error ) { spprintf ( error , 0 , ""opensslsignaturecouldnotbeprocessed"" ) ; } return FAILURE ; } key = PEM_read_bio_PUBKEY ( in , NULL , NULL , NULL ) ; BIO_free ( in ) ; zend_string_release ( pubkey ) ; if ( NULL == key ) { if ( error ) { spprintf ( error , 0 , ""opensslsignaturecouldnotbeprocessed"" ) ; } return FAILURE ; } EVP_VerifyInit ( & md_ctx , mdtype ) ; read_len = end_of_phar ; if ( read_len > sizeof ( buf ) ) { read_size = sizeof ( buf ) ; } else { read_size = ( int ) read_len ; } php_stream_seek ( fp , 0 , SEEK_SET ) ; while ( read_size && ( len = php_stream_read ( fp , ( char * ) buf , read_size ) ) > 0 ) { EVP_VerifyUpdate ( & md_ctx , buf , len ) ; read_len -= ( zend_off_t ) len ; if ( read_len < read_size ) { read_size = ( int ) read_len ; } } if ( EVP_VerifyFinal ( & md_ctx , ( unsigned char * ) sig , sig_len , key ) != 1 ) { EVP_MD_CTX_cleanup ( & md_ctx ) ; if ( error ) { spprintf ( error , 0 , ""brokenopensslsignature"" ) ; } return FAILURE ; } EVP_MD_CTX_cleanup ( & md_ctx ) ; # endif * signature_len = phar_hex_str ( ( const char * ) sig , sig_len , signature ) ; } break ; # ifdef PHAR_HASH_OK case PHAR_SIG_SHA512 : { unsigned char digest [ 64 ] ; PHP_SHA512_CTX context ; PHP_SHA512Init ( & context ) ; read_len = end_of_phar ; if ( read_len > sizeof ( buf ) ) { read_size = sizeof ( buf ) ; } else { read_size = ( int ) read_len ; } while ( ( len = php_stream_read ( fp , ( char * ) buf , read_size ) ) > 0 ) { PHP_SHA512Update ( & context , buf , len ) ; read_len -= ( zend_off_t ) len ; if ( read_len < read_size ) { read_size = ( int ) read_len ; } } PHP_SHA512Final ( digest , & context ) ; if ( memcmp ( digest , sig , sizeof ( digest ) ) ) { if ( error ) { spprintf ( error , 0 , ""brokensignature"" ) ; } return FAILURE ; } * signature_len = phar_hex_str ( ( const char * ) digest , sizeof ( digest ) , signature ) ; break ; } case PHAR_SIG_SHA256 : { unsigned char digest [ 32 ] ; PHP_SHA256_CTX context ; PHP_SHA256Init ( & context ) ; read_len = end_of_phar ; if ( read_len > sizeof ( buf ) ) { read_size = sizeof ( buf ) ; } else { read_size = ( int ) read_len ; } while ( ( len = php_stream_read ( fp , ( char * ) buf , read_size ) ) > 0 ) { PHP_SHA256Update ( & context , buf , len ) ; read_len -= ( zend_off_t ) len ; if ( read_len < read_size ) { read_size = ( int ) read_len ; } } PHP_SHA256Final ( digest , & context ) ; if ( memcmp ( digest , sig , sizeof ( digest ) ) ) { if ( error ) { spprintf ( error , 0 , ""brokensignature"" ) ; } return FAILURE ; } * signature_len = phar_hex_str ( ( const char * ) digest , sizeof ( digest ) , signature ) ; break ; } # else case PHAR_SIG_SHA512 : case PHAR_SIG_SHA256 : if ( error ) { spprintf ( error , 0 , ""unsupportedsignature"" ) ; } return FAILURE ; # endif case PHAR_SIG_SHA1 : { unsigned char digest [ 20 ] ; PHP_SHA1_CTX context ; PHP_SHA1Init ( & context ) ; read_len = end_of_phar ; if ( read_len > sizeof ( buf ) ) { read_size = sizeof ( buf ) ; } else { read_size = ( int ) read_len ; } while ( ( len = php_stream_read ( fp , ( char * ) buf , read_size ) ) > 0 ) { PHP_SHA1Update ( & context , buf , len ) ; read_len -= ( zend_off_t ) len ; if ( read_len < read_size ) { read_size = ( int ) read_len ; } } PHP_SHA1Final ( digest , & context ) ; if ( memcmp ( digest , sig , sizeof ( digest ) ) ) { if ( error ) { spprintf ( error , 0 , ""brokensignature"" ) ; } return FAILURE ; } * signature_len = phar_hex_str ( ( const char * ) digest , sizeof ( digest ) , signature ) ; break ; } case PHAR_SIG_MD5 : { unsigned char digest [ 16 ] ; PHP_MD5_CTX context ; PHP_MD5Init ( & context ) ; read_len = end_of_phar ; if ( read_len > sizeof ( buf ) ) { read_size = sizeof ( buf ) ; } else { read_size = ( int ) read_len ; } while ( ( len = php_stream_read ( fp , ( char * ) buf , read_size ) ) > 0 ) { PHP_MD5Update ( & context , buf , len ) ; read_len -= ( zend_off_t ) len ; if ( read_len < read_size ) { read_size = ( int ) read_len ; } } PHP_MD5Final ( digest , & context ) ; if ( memcmp ( digest , sig , sizeof ( digest ) ) ) { if ( error ) { spprintf ( error , 0 , ""brokensignature"" ) ; } return FAILURE ; } * signature_len = phar_hex_str ( ( const char * ) digest , sizeof ( digest ) , signature ) ; break ; } default : if ( error ) { spprintf ( error , 0 , ""brokenorunsupportedsignature"" ) ; } return FAILURE ; } return SUCCESS ; } "," PHP_SHA512_CTX context ; if ( sig_len < sizeof ( digest ) ) { if ( error ) { spprintf ( error , 0 , ""brokensignature"" ) ; } return FAILURE ; } PHP_SHA256_CTX context ; if ( sig_len < sizeof ( digest ) ) { if ( error ) { spprintf ( error , 0 , ""brokensignature"" ) ; } return FAILURE ; } PHP_SHA1_CTX context ; if ( sig_len < sizeof ( digest ) ) { if ( error ) { spprintf ( error , 0 , ""brokensignature"" ) ; } return FAILURE ; } PHP_MD5_CTX context ; if ( sig_len < sizeof ( digest ) ) { FAILURE ; } PHP_MD5Init ( & context ) ; read_len = end_of_phar ; if ( read_len > sizeof ( buf ) ) { read_size = sizeof ( buf ) ; } else { read_size = ( int ) read_len ; } while ( ( len = php_stream_read ( fp , ( char * ) buf , read_size ) ) > 0 ) { PHP_MD5Update ( & context , buf , len ) ; read_len -= ( zend_off_t ) len ; if ( read_len < read_size ) { read_size = ( int ) read_len ; } } PHP_MD5Final ( digest , & context ) ; if ( memcmp ( digest , sig , sizeof ( digest ) ) ) { if ( error ) { spprintf ( error , 0 , ""brokensignature"" ) ; } return FAILURE ; } ",php@php-src/0bfb970f43acd1e81d11be1154805f86655f15d5,CVE-2016-7414,https://github.com/php/php-src/commit/0bfb970f43acd1e81d11be1154805f86655f15d5?w=1,2016-09-17T21:59Z 963,CWE-125,"CWE-125 static void hid_input_field ( struct hid_device * hid , struct hid_field * field , __u8 * data , int interrupt ) { unsigned n ; unsigned count = field -> report_count ; unsigned offset = field -> report_offset ; unsigned size = field -> report_size ; __s32 min = field -> logical_minimum ; __s32 max = field -> logical_maximum ; __s32 * value ; value = kmalloc ( sizeof ( __s32 ) * count , GFP_ATOMIC ) ; if ( ! value ) return ; for ( n = 0 ; n < count ; n ++ ) { value [ n ] = min < 0 ? snto32 ( hid_field_extract ( hid , data , offset + n * size , size ) , size ) : hid_field_extract ( hid , data , offset + n * size , size ) ; if ( ! ( field -> flags & HID_MAIN_ITEM_VARIABLE ) && value [ n ] >= min && value [ n ] <= max && field -> usage [ value [ n ] - min ] . hid == HID_UP_KEYBOARD + 1 ) goto exit ; } for ( n = 0 ; n < count ; n ++ ) { if ( HID_MAIN_ITEM_VARIABLE & field -> flags ) { hid_process_event ( hid , field , & field -> usage [ n ] , value [ n ] , interrupt ) ; continue ; } if ( field -> value [ n ] >= min && field -> value [ n ] <= max && field -> usage [ field -> value [ n ] - min ] . hid && search ( value , field -> value [ n ] , count ) ) hid_process_event ( hid , field , & field -> usage [ field -> value [ n ] - min ] , 0 , interrupt ) ; if ( value [ n ] >= min && value [ n ] <= max && field -> usage [ value [ n ] - min ] . hid && search ( field -> value , value [ n ] , count ) ) hid_process_event ( hid , field , & field -> usage [ value [ n ] - min ] , 1 , interrupt ) ; } memcpy ( field -> value , value , count * sizeof ( __s32 ) ) ; exit : kfree ( value ) ; } "," ] <= max && value [ n ] - min < field -> maxusage && field -> value [ n ] - min < field -> maxusage && field -> <= max && value [ n ] - min < field -> maxusage && ",torvalds@linux/50220dead1650609206efe91f0cc116132d59b3f,CVE-2016-7915,https://github.com/torvalds/linux/commit/50220dead1650609206efe91f0cc116132d59b3f,2016-11-16T05:59Z 964,CWE-119,"CWE-119 static void write_display_size ( const VP9_COMMON * cm , struct vp9_write_bit_buffer * wb ) { const int scaling_active = cm -> width != cm -> display_width || cm -> height != cm -> display_height ; vp9_wb_write_bit ( wb , scaling_active ) ; if ( scaling_active ) { vp9_wb_write_literal ( wb , cm -> display_width - 1 , 16 ) ; vp9_wb_write_literal ( wb , cm -> display_height - 1 , 16 ) ; } } "," cm , struct vpx_write_bit_buffer * wb ) -> display_height ; vpx_wb_write_bit ( wb , scaling_active ) { vpx_wb_write_literal ( wb , 16 ) ; vpx_wb_write_literal ( wb , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 965,CWE-119,"CWE-119 static void dex_parse_debug_item ( RBinFile * binfile , RBinDexObj * bin , RBinDexClass * c , int MI , int MA , int paddr , int ins_size , int insns_size , char * class_name , int regsz , int debug_info_off ) { struct r_bin_t * rbin = binfile -> rbin ; const ut8 * p4 = r_buf_get_at ( binfile -> buf , debug_info_off , NULL ) ; const ut8 * p4_end = p4 + binfile -> buf -> length - debug_info_off ; ut64 line_start ; ut64 parameters_size ; ut64 param_type_idx ; ut16 argReg = regsz - ins_size ; ut64 source_file_idx = c -> source_file ; RList * params , * debug_positions , * emitted_debug_locals = NULL ; bool keep = true ; if ( argReg >= regsz ) { } p4 = r_uleb128 ( p4 , p4_end - p4 , & line_start ) ; p4 = r_uleb128 ( p4 , p4_end - p4 , & parameters_size ) ; ut32 address = 0 ; ut32 line = line_start ; if ( ! ( debug_positions = r_list_newf ( ( RListFree ) free ) ) ) { return ; } if ( ! ( emitted_debug_locals = r_list_newf ( ( RListFree ) free ) ) ) { r_list_free ( debug_positions ) ; return ; } struct dex_debug_local_t debug_locals [ regsz ] ; memset ( debug_locals , 0 , sizeof ( struct dex_debug_local_t ) * regsz ) ; if ( ! ( MA & 0x0008 ) ) { debug_locals [ argReg ] . name = ""this"" ; debug_locals [ argReg ] . descriptor = r_str_newf ( ""%s;"" , class_name ) ; debug_locals [ argReg ] . startAddress = 0 ; debug_locals [ argReg ] . signature = NULL ; debug_locals [ argReg ] . live = true ; argReg ++ ; } if ( ! ( params = dex_method_signature2 ( bin , MI ) ) ) { r_list_free ( debug_positions ) ; r_list_free ( emitted_debug_locals ) ; return ; } RListIter * iter = r_list_iterator ( params ) ; char * name ; char * type ; int reg ; r_list_foreach ( params , iter , type ) { if ( ( argReg >= regsz ) || ! type || parameters_size <= 0 ) { r_list_free ( debug_positions ) ; r_list_free ( params ) ; r_list_free ( emitted_debug_locals ) ; return ; } p4 = r_uleb128 ( p4 , p4_end - p4 , & param_type_idx ) ; param_type_idx -= 1 ; name = getstr ( bin , param_type_idx ) ; reg = argReg ; switch ( type [ 0 ] ) { case 'D' : case 'J' : argReg += 2 ; break ; default : argReg += 1 ; break ; } if ( name ) { debug_locals [ reg ] . name = name ; debug_locals [ reg ] . descriptor = type ; debug_locals [ reg ] . signature = NULL ; debug_locals [ reg ] . startAddress = address ; debug_locals [ reg ] . live = true ; } -- parameters_size ; } ut8 opcode = * ( p4 ++ ) & 0xff ; while ( keep ) { switch ( opcode ) { case 0x0 : keep = false ; break ; case 0x1 : { ut64 addr_diff ; p4 = r_uleb128 ( p4 , p4_end - p4 , & addr_diff ) ; address += addr_diff ; } break ; case 0x2 : { st64 line_diff = r_sleb128 ( & p4 , p4_end ) ; line += line_diff ; } break ; case 0x3 : { ut64 register_num ; ut64 name_idx ; ut64 type_idx ; p4 = r_uleb128 ( p4 , p4_end - p4 , & register_num ) ; p4 = r_uleb128 ( p4 , p4_end - p4 , & name_idx ) ; name_idx -= 1 ; p4 = r_uleb128 ( p4 , p4_end - p4 , & type_idx ) ; type_idx -= 1 ; if ( register_num >= regsz ) { r_list_free ( debug_positions ) ; r_list_free ( params ) ; return ; } if ( debug_locals [ register_num ] . live ) { struct dex_debug_local_t * local = malloc ( sizeof ( struct dex_debug_local_t ) ) ; if ( ! local ) { keep = false ; break ; } local -> name = debug_locals [ register_num ] . name ; local -> descriptor = debug_locals [ register_num ] . descriptor ; local -> startAddress = debug_locals [ register_num ] . startAddress ; local -> signature = debug_locals [ register_num ] . signature ; local -> live = true ; local -> reg = register_num ; local -> endAddress = address ; r_list_append ( emitted_debug_locals , local ) ; } debug_locals [ register_num ] . name = getstr ( bin , name_idx ) ; debug_locals [ register_num ] . descriptor = dex_type_descriptor ( bin , type_idx ) ; debug_locals [ register_num ] . startAddress = address ; debug_locals [ register_num ] . signature = NULL ; debug_locals [ register_num ] . live = true ; } break ; case 0x4 : { ut64 register_num ; ut64 name_idx ; ut64 type_idx ; ut64 sig_idx ; p4 = r_uleb128 ( p4 , p4_end - p4 , & register_num ) ; p4 = r_uleb128 ( p4 , p4_end - p4 , & name_idx ) ; name_idx -= 1 ; p4 = r_uleb128 ( p4 , p4_end - p4 , & type_idx ) ; type_idx -= 1 ; p4 = r_uleb128 ( p4 , p4_end - p4 , & sig_idx ) ; sig_idx -= 1 ; if ( register_num >= regsz ) { r_list_free ( debug_positions ) ; r_list_free ( params ) ; return ; } if ( debug_locals [ register_num ] . live ) { struct dex_debug_local_t * local = malloc ( sizeof ( struct dex_debug_local_t ) ) ; if ( ! local ) { keep = false ; break ; } local -> name = debug_locals [ register_num ] . name ; local -> descriptor = debug_locals [ register_num ] . descriptor ; local -> startAddress = debug_locals [ register_num ] . startAddress ; local -> signature = debug_locals [ register_num ] . signature ; local -> live = true ; local -> reg = register_num ; local -> endAddress = address ; r_list_append ( emitted_debug_locals , local ) ; } debug_locals [ register_num ] . name = getstr ( bin , name_idx ) ; debug_locals [ register_num ] . descriptor = dex_type_descriptor ( bin , type_idx ) ; debug_locals [ register_num ] . startAddress = address ; debug_locals [ register_num ] . signature = getstr ( bin , sig_idx ) ; debug_locals [ register_num ] . live = true ; } break ; case 0x5 : { ut64 register_num ; p4 = r_uleb128 ( p4 , p4_end - p4 , & register_num ) ; if ( debug_locals [ register_num ] . live ) { struct dex_debug_local_t * local = malloc ( sizeof ( struct dex_debug_local_t ) ) ; if ( ! local ) { keep = false ; break ; } local -> name = debug_locals [ register_num ] . name ; local -> descriptor = debug_locals [ register_num ] . descriptor ; local -> startAddress = debug_locals [ register_num ] . startAddress ; local -> signature = debug_locals [ register_num ] . signature ; local -> live = true ; local -> reg = register_num ; local -> endAddress = address ; r_list_append ( emitted_debug_locals , local ) ; } debug_locals [ register_num ] . live = false ; } break ; case 0x6 : { ut64 register_num ; p4 = r_uleb128 ( p4 , p4_end - p4 , & register_num ) ; if ( ! debug_locals [ register_num ] . live ) { debug_locals [ register_num ] . startAddress = address ; debug_locals [ register_num ] . live = true ; } } break ; case 0x7 : break ; case 0x8 : break ; case 0x9 : { p4 = r_uleb128 ( p4 , p4_end - p4 , & source_file_idx ) ; source_file_idx -- ; } break ; default : { int adjusted_opcode = opcode - 0x0a ; address += ( adjusted_opcode / 15 ) ; line += - 4 + ( adjusted_opcode % 15 ) ; struct dex_debug_position_t * position = malloc ( sizeof ( struct dex_debug_position_t ) ) ; if ( ! position ) { keep = false ; break ; } position -> source_file_idx = source_file_idx ; position -> address = address ; position -> line = line ; r_list_append ( debug_positions , position ) ; } break ; } opcode = * ( p4 ++ ) & 0xff ; } if ( ! binfile -> sdb_addrinfo ) { binfile -> sdb_addrinfo = sdb_new0 ( ) ; } char * fileline ; char offset [ 64 ] ; char * offset_ptr ; RListIter * iter1 ; struct dex_debug_position_t * pos ; r_list_foreach ( debug_positions , iter1 , pos ) { fileline = r_str_newf ( ""%s|%"" PFMT64d , getstr ( bin , pos -> source_file_idx ) , pos -> line ) ; offset_ptr = sdb_itoa ( pos -> address + paddr , offset , 16 ) ; sdb_set ( binfile -> sdb_addrinfo , offset_ptr , fileline , 0 ) ; sdb_set ( binfile -> sdb_addrinfo , fileline , offset_ptr , 0 ) ; } if ( ! dexdump ) { r_list_free ( debug_positions ) ; r_list_free ( emitted_debug_locals ) ; r_list_free ( params ) ; return ; } RListIter * iter2 ; struct dex_debug_position_t * position ; rbin -> cb_printf ( ""positions:\\n"" ) ; r_list_foreach ( debug_positions , iter2 , position ) { rbin -> cb_printf ( ""0x%04llxline=%llu\\n"" , position -> address , position -> line ) ; } rbin -> cb_printf ( ""locals:\\n"" ) ; RListIter * iter3 ; struct dex_debug_local_t * local ; r_list_foreach ( emitted_debug_locals , iter3 , local ) { if ( local -> signature ) { rbin -> cb_printf ( ""0x%04x-0x%04xreg=%d%s%s%s\\n"" , local -> startAddress , local -> endAddress , local -> reg , local -> name , local -> descriptor , local -> signature ) ; } else { rbin -> cb_printf ( ""0x%04x-0x%04xreg=%d%s%s\\n"" , local -> startAddress , local -> endAddress , local -> reg , local -> name , local -> descriptor ) ; } } for ( reg = 0 ; reg < regsz ; reg ++ ) { if ( debug_locals [ reg ] . live ) { if ( debug_locals [ reg ] . signature ) { rbin -> cb_printf ( ""0x%04x-0x%04xreg=%d%s%s"" ""%s\\n"" , debug_locals [ reg ] . startAddress , insns_size , reg , debug_locals [ reg ] . name , debug_locals [ reg ] . descriptor , debug_locals [ reg ] . signature ) ; } else { rbin -> cb_printf ( ""0x%04x-0x%04xreg=%d%s%s"" ""\\n"" , debug_locals [ reg ] . startAddress , insns_size , reg , debug_locals [ reg ] . name , debug_locals [ reg ] . descriptor ) ; } } } r_list_free ( debug_positions ) ; r_list_free ( emitted_debug_locals ) ; r_list_free ( params ) ; } "," if ( argReg > regsz ) { regsz ) { return ; ",radare@radare2/ad55822430a03fe075221b543efb434567e9e431,CVE-2017-6319,https://github.com/radare/radare2/commit/ad55822430a03fe075221b543efb434567e9e431,2017-03-02T01:59Z 966,CWE-444,"CWE-444 VALUE request_env ( agooReq req , VALUE self ) { if ( Qnil == ( VALUE ) req -> env ) { volatile VALUE env = rb_hash_new ( ) ; rb_hash_aset ( env , request_method_val , req_method ( req ) ) ; rb_hash_aset ( env , script_name_val , req_script_name ( req ) ) ; rb_hash_aset ( env , path_info_val , req_path_info ( req ) ) ; rb_hash_aset ( env , query_string_val , req_query_string ( req ) ) ; rb_hash_aset ( env , server_name_val , req_server_name ( req ) ) ; rb_hash_aset ( env , server_port_val , req_server_port ( req ) ) ; fill_headers ( req , env ) ; rb_hash_aset ( env , rack_version_val , rack_version_val_val ) ; rb_hash_aset ( env , rack_url_scheme_val , req_rack_url_scheme ( req ) ) ; rb_hash_aset ( env , rack_input_val , req_rack_input ( req ) ) ; rb_hash_aset ( env , rack_errors_val , req_rack_errors ( req ) ) ; rb_hash_aset ( env , rack_multithread_val , req_rack_multithread ( req ) ) ; rb_hash_aset ( env , rack_multiprocess_val , Qfalse ) ; rb_hash_aset ( env , rack_run_once_val , Qfalse ) ; rb_hash_aset ( env , rack_logger_val , req_rack_logger ( req ) ) ; rb_hash_aset ( env , rack_upgrade_val , req_rack_upgrade ( req ) ) ; rb_hash_aset ( env , rack_hijackq_val , Qtrue ) ; rb_hash_aset ( env , rack_hijack_val , self ) ; rb_hash_aset ( env , rack_hijack_io_val , Qnil ) ; if ( agoo_server . rack_early_hints ) { volatile VALUE eh = agoo_early_hints_new ( req ) ; rb_hash_aset ( env , early_hints_val , eh ) ; } req -> env = ( void * ) env ; } return ( VALUE ) req -> env ; } "," ( env , remote_addr_val , req_remote_addr ( req ) ) ; rb_hash_aset ( env , server_port_val , req_server_port ( req ) ) ; rb_hash_aset ( env , server_name_val , req_server_name ( req ) ",ohler55@agoo/23d03535cf7b50d679a60a953a0cae9519a4a130,CVE-2020-7670,https://github.com/ohler55/agoo/commit/23d03535cf7b50d679a60a953a0cae9519a4a130,2020-06-10T16:15Z 967,CWE-19,"CWE-19 int xfs_attr3_leaf_getvalue ( struct xfs_buf * bp , struct xfs_da_args * args ) { struct xfs_attr_leafblock * leaf ; struct xfs_attr3_icleaf_hdr ichdr ; struct xfs_attr_leaf_entry * entry ; struct xfs_attr_leaf_name_local * name_loc ; struct xfs_attr_leaf_name_remote * name_rmt ; int valuelen ; leaf = bp -> b_addr ; xfs_attr3_leaf_hdr_from_disk ( & ichdr , leaf ) ; ASSERT ( ichdr . count < XFS_LBSIZE ( args -> dp -> i_mount ) / 8 ) ; ASSERT ( args -> index < ichdr . count ) ; entry = & xfs_attr3_leaf_entryp ( leaf ) [ args -> index ] ; if ( entry -> flags & XFS_ATTR_LOCAL ) { name_loc = xfs_attr3_leaf_name_local ( leaf , args -> index ) ; ASSERT ( name_loc -> namelen == args -> namelen ) ; ASSERT ( memcmp ( args -> name , name_loc -> nameval , args -> namelen ) == 0 ) ; valuelen = be16_to_cpu ( name_loc -> valuelen ) ; if ( args -> flags & ATTR_KERNOVAL ) { args -> valuelen = valuelen ; return 0 ; } if ( args -> valuelen < valuelen ) { args -> valuelen = valuelen ; return XFS_ERROR ( ERANGE ) ; } args -> valuelen = valuelen ; memcpy ( args -> value , & name_loc -> nameval [ args -> namelen ] , valuelen ) ; } else { name_rmt = xfs_attr3_leaf_name_remote ( leaf , args -> index ) ; ASSERT ( name_rmt -> namelen == args -> namelen ) ; ASSERT ( memcmp ( args -> name , name_rmt -> name , args -> namelen ) == 0 ) ; valuelen = be32_to_cpu ( name_rmt -> valuelen ) ; args -> rmtblkno = be32_to_cpu ( name_rmt -> valueblk ) ; args -> rmtblkcnt = xfs_attr3_rmt_blocks ( args -> dp -> i_mount , valuelen ) ; if ( args -> flags & ATTR_KERNOVAL ) { args -> valuelen = valuelen ; return 0 ; } if ( args -> valuelen < valuelen ) { args -> valuelen = valuelen ; return XFS_ERROR ( ERANGE ) ; } args -> valuelen = valuelen ; } return 0 ; } "," 0 ) ; args -> rmtvaluelen = be32_to_cpu ( -> i_mount , args -> rmtvaluelen ) ; if -> valuelen = args -> rmtvaluelen ; return 0 -> valuelen < args -> rmtvaluelen ) { args -> valuelen = args -> rmtvaluelen ; return XFS_ERROR -> valuelen = args -> rmtvaluelen ; } return ",torvalds@linux/8275cdd0e7ac550dcce2b3ef6d2fb3b808c1ae59,CVE-2015-0274,https://github.com/torvalds/linux/commit/8275cdd0e7ac550dcce2b3ef6d2fb3b808c1ae59,2015-03-16T10:59Z 968,CWE-189,"CWE-189 struct xt_table_info * xt_alloc_table_info ( unsigned int size ) { struct xt_table_info * info = NULL ; size_t sz = sizeof ( * info ) + size ; if ( ( SMP_ALIGN ( size ) >> PAGE_SHIFT ) + 2 > totalram_pages ) return NULL ; if ( sz <= ( PAGE_SIZE << PAGE_ALLOC_COSTLY_ORDER ) ) info = kmalloc ( sz , GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY ) ; if ( ! info ) { info = vmalloc ( sz ) ; if ( ! info ) return NULL ; } memset ( info , 0 , sizeof ( * info ) ) ; info -> size = size ; return info ; } "," ) + size ; if ( sz < sizeof ( * info ) ) return NULL ",torvalds@linux/d157bd761585605b7882935ffb86286919f62ea1,CVE-2016-3135,https://github.com/torvalds/linux/commit/d157bd761585605b7882935ffb86286919f62ea1,2016-04-27T17:59Z 969,CWE-125,"CWE-125 int dbd_st_prepare ( SV * sth , imp_sth_t * imp_sth , char * statement , SV * attribs ) { int i ; SV * * svp ; dTHX ; # if MYSQL_VERSION_ID >= SERVER_PREPARE_VERSION # if MYSQL_VERSION_ID < CALL_PLACEHOLDER_VERSION char * str_ptr , * str_last_ptr ; # if MYSQL_VERSION_ID < LIMIT_PLACEHOLDER_VERSION int limit_flag = 0 ; # endif # endif int col_type , prepare_retval ; MYSQL_BIND * bind , * bind_end ; imp_sth_phb_t * fbind ; # endif D_imp_xxh ( sth ) ; D_imp_dbh_from_sth ; if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\t->dbd_st_prepareMYSQL_VERSION_ID%d,SQLstatement:%s\\n"" , MYSQL_VERSION_ID , statement ) ; # if MYSQL_VERSION_ID >= SERVER_PREPARE_VERSION imp_sth -> use_server_side_prepare = imp_dbh -> use_server_side_prepare ; if ( attribs ) { svp = DBD_ATTRIB_GET_SVP ( attribs , ""mysql_server_prepare"" , 20 ) ; imp_sth -> use_server_side_prepare = ( svp ) ? SvTRUE ( * svp ) : imp_dbh -> use_server_side_prepare ; svp = DBD_ATTRIB_GET_SVP ( attribs , ""async"" , 5 ) ; if ( svp && SvTRUE ( * svp ) ) { # if MYSQL_ASYNC imp_sth -> is_async = TRUE ; imp_sth -> use_server_side_prepare = FALSE ; # else do_error ( sth , 2000 , ""AsyncsupportwasnotbuiltintothisversionofDBD::mysql"" , ""HY000"" ) ; return 0 ; # endif } } imp_sth -> fetch_done = 0 ; # endif imp_sth -> done_desc = 0 ; imp_sth -> result = NULL ; imp_sth -> currow = 0 ; svp = DBD_ATTRIB_GET_SVP ( attribs , ""mysql_use_result"" , 16 ) ; imp_sth -> use_mysql_use_result = svp ? SvTRUE ( * svp ) : imp_dbh -> use_mysql_use_result ; for ( i = 0 ; i < AV_ATTRIB_LAST ; i ++ ) imp_sth -> av_attr [ i ] = Nullav ; mysql_st_free_result_sets ( sth , imp_sth ) ; # if MYSQL_VERSION_ID >= SERVER_PREPARE_VERSION && MYSQL_VERSION_ID < CALL_PLACEHOLDER_VERSION if ( imp_sth -> use_server_side_prepare ) { if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\t\\tuse_server_side_prepareset,checkrestrictions\\n"" ) ; if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , # if MYSQL_VERSION_ID < LIMIT_PLACEHOLDER_VERSION ""\\t\\tneedtotestforLIMIT&CALL\\n"" ) ; # else ""\\t\\tneedtotestforrestrictions\\n"" ) ; # endif str_last_ptr = statement + strlen ( statement ) ; for ( str_ptr = statement ; str_ptr < str_last_ptr ; str_ptr ++ ) { # if MYSQL_VERSION_ID < LIMIT_PLACEHOLDER_VERSION if ( limit_flag ) { if ( * str_ptr == '?' ) { if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\t\\tLIMITand?found,settouse_server_side_prepare=0\\n"" ) ; imp_sth -> use_server_side_prepare = 0 ; break ; } } else if ( str_ptr < str_last_ptr - 6 && isspace ( * ( str_ptr + 0 ) ) && tolower ( * ( str_ptr + 1 ) ) == 'l' && tolower ( * ( str_ptr + 2 ) ) == 'i' && tolower ( * ( str_ptr + 3 ) ) == 'm' && tolower ( * ( str_ptr + 4 ) ) == 'i' && tolower ( * ( str_ptr + 5 ) ) == 't' && isspace ( * ( str_ptr + 6 ) ) ) { if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""LIMITsetlimitflagto1\\n"" ) ; limit_flag = 1 ; } # endif if ( str_ptr < str_last_ptr - 4 && tolower ( * ( str_ptr + 0 ) ) == 'c' && tolower ( * ( str_ptr + 1 ) ) == 'a' && tolower ( * ( str_ptr + 2 ) ) == 'l' && tolower ( * ( str_ptr + 3 ) ) == 'l' && isspace ( * ( str_ptr + 4 ) ) ) { if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""DisablePSmodeforCALL()\\n"" ) ; imp_sth -> use_server_side_prepare = 0 ; break ; } } } # endif # if MYSQL_VERSION_ID >= SERVER_PREPARE_VERSION if ( imp_sth -> use_server_side_prepare ) { if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\t\\tuse_server_side_prepareset\\n"" ) ; if ( imp_sth -> stmt ) fprintf ( stderr , ""ERROR:Tryingtopreparenewstmtwhilewehave\\\nalreadynotclosedone\\n"" ) ; imp_sth -> stmt = mysql_stmt_init ( imp_dbh -> pmysql ) ; if ( ! imp_sth -> stmt ) { if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\t\\tERROR:UnabletoreturnMYSQL_STMTstructure\\\nfrommysql_stmt_init():ERRORNO:%dERRORMSG:%s\\n"" , mysql_errno ( imp_dbh -> pmysql ) , mysql_error ( imp_dbh -> pmysql ) ) ; } prepare_retval = mysql_stmt_prepare ( imp_sth -> stmt , statement , strlen ( statement ) ) ; if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\t\\tmysql_stmt_preparereturned%d\\n"" , prepare_retval ) ; if ( prepare_retval ) { if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\t\\tmysql_stmt_prepare%d%s\\n"" , mysql_stmt_errno ( imp_sth -> stmt ) , mysql_stmt_error ( imp_sth -> stmt ) ) ; if ( mysql_stmt_errno ( imp_sth -> stmt ) == ER_UNSUPPORTED_PS ) { if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\t\\tSETTINGimp_sth->use_server_side_prepareto0\\n"" ) ; imp_sth -> use_server_side_prepare = 0 ; } else { do_error ( sth , mysql_stmt_errno ( imp_sth -> stmt ) , mysql_stmt_error ( imp_sth -> stmt ) , mysql_sqlstate ( imp_dbh -> pmysql ) ) ; mysql_stmt_close ( imp_sth -> stmt ) ; imp_sth -> stmt = NULL ; return FALSE ; } } else { DBIc_NUM_PARAMS ( imp_sth ) = mysql_stmt_param_count ( imp_sth -> stmt ) ; if ( DBIc_NUM_PARAMS ( imp_sth ) > 0 ) { int has_statement_fields = imp_sth -> stmt -> fields != 0 ; imp_sth -> bind = alloc_bind ( DBIc_NUM_PARAMS ( imp_sth ) ) ; imp_sth -> fbind = alloc_fbind ( DBIc_NUM_PARAMS ( imp_sth ) ) ; imp_sth -> has_been_bound = 0 ; for ( i = 0 , bind = imp_sth -> bind , fbind = imp_sth -> fbind , bind_end = bind + DBIc_NUM_PARAMS ( imp_sth ) ; bind < bind_end ; bind ++ , fbind ++ , i ++ ) { col_type = ( has_statement_fields ? imp_sth -> stmt -> fields [ i ] . type : MYSQL_TYPE_STRING ) ; bind -> buffer_type = mysql_to_perl_type ( col_type ) ; if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\t\\tmysql_to_perl_typereturned%d\\n"" , col_type ) ; bind -> buffer = NULL ; bind -> length = & ( fbind -> length ) ; bind -> is_null = ( char * ) & ( fbind -> is_null ) ; fbind -> is_null = 1 ; fbind -> length = 0 ; } } } } # endif # if MYSQL_VERSION_ID >= SERVER_PREPARE_VERSION if ( imp_sth -> use_server_side_prepare == 0 ) DBIc_NUM_PARAMS ( imp_sth ) = count_params ( ( imp_xxh_t * ) imp_dbh , aTHX_ statement , imp_dbh -> bind_comment_placeholders ) ; # else DBIc_NUM_PARAMS ( imp_sth ) = count_params ( ( imp_xxh_t * ) imp_dbh , aTHX_ statement , imp_dbh -> bind_comment_placeholders ) ; # endif imp_sth -> params = alloc_param ( DBIc_NUM_PARAMS ( imp_sth ) ) ; DBIc_IMPSET_on ( imp_sth ) ; if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""\\t<-dbd_st_prepare\\n"" ) ; return 1 ; } "," # endif int prepare_retval ; MYSQL_BIND ( stderr , ""ERROR:Tryingtopreparenewstmtwhilewehave\\\nalreadynotclosedone\\n"" ) ; imp_sth imp_xxh ) , ""\\t\\tERROR:UnabletoreturnMYSQL_STMTstructure\\\nfrommysql_stmt_init():ERRORNO:%dERRORMSG:%s\\n"" , mysql_errno ( 0 ) { imp_sth -> bind ++ ) { bind -> buffer_type = MYSQL_TYPE_STRING ; bind -> ",perl5-dbi@DBD-mysql/793b72b1a0baa5070adacaac0e12fd995a6fbabe,CVE-2016-1249,https://github.com/perl5-dbi/DBD-mysql/commit/793b72b1a0baa5070adacaac0e12fd995a6fbabe,2017-02-17T02:59Z 970,CWE-20,"CWE-20 static noinline void key_gc_unused_keys ( struct list_head * keys ) { while ( ! list_empty ( keys ) ) { struct key * key = list_entry ( keys -> next , struct key , graveyard_link ) ; list_del ( & key -> graveyard_link ) ; kdebug ( ""-%u"" , key -> serial ) ; key_check ( key ) ; if ( key -> type -> destroy ) key -> type -> destroy ( key ) ; security_key_free ( key ) ; if ( test_bit ( KEY_FLAG_IN_QUOTA , & key -> flags ) ) { spin_lock ( & key -> user -> lock ) ; key -> user -> qnkeys -- ; key -> user -> qnbytes -= key -> quotalen ; spin_unlock ( & key -> user -> lock ) ; } atomic_dec ( & key -> user -> nkeys ) ; if ( test_bit ( KEY_FLAG_INSTANTIATED , & key -> flags ) ) atomic_dec ( & key -> user -> nikeys ) ; key_user_put ( key -> user ) ; kfree ( key -> description ) ; # ifdef KEY_DEBUGGING key -> magic = KEY_DEBUG_MAGIC_X ; # endif kmem_cache_free ( key_jar , key ) ; } } "," ; if ( test_bit ( KEY_FLAG_INSTANTIATED , & key -> flags ) && ! test_bit ( KEY_FLAG_NEGATIVE , & key -> flags ) && ",torvalds@linux/ce1fad2740c648a4340f6f6c391a8a83769d2e8c,CVE-2015-7872,https://github.com/torvalds/linux/commit/ce1fad2740c648a4340f6f6c391a8a83769d2e8c,2015-11-16T11:59Z 971,CWE-189,"CWE-189 static ltxtquery * queryin ( char * buf ) { QPRS_STATE state ; int32 i ; ltxtquery * query ; int32 commonlen ; ITEM * ptr ; NODE * tmp ; int32 pos = 0 ; # ifdef BS_DEBUG char pbuf [ 16384 ] , * cur ; # endif state . buf = buf ; state . state = WAITOPERAND ; state . count = 0 ; state . num = 0 ; state . str = NULL ; state . sumlen = 0 ; state . lenop = 64 ; state . curop = state . op = ( char * ) palloc ( state . lenop ) ; * ( state . curop ) = '\\0' ; makepol ( & state ) ; if ( ! state . num ) ereport ( ERROR , ( errcode ( ERRCODE_SYNTAX_ERROR ) , errmsg ( ""syntaxerror"" ) , errdetail ( ""Emptyquery."" ) ) ) ; commonlen = COMPUTESIZE ( state . num , state . sumlen ) ; query = ( ltxtquery * ) palloc ( commonlen ) ; SET_VARSIZE ( query , commonlen ) ; query -> size = state . num ; ptr = GETQUERY ( query ) ; for ( i = 0 ; i < state . num ; i ++ ) { ptr [ i ] . type = state . str -> type ; ptr [ i ] . val = state . str -> val ; ptr [ i ] . distance = state . str -> distance ; ptr [ i ] . length = state . str -> length ; ptr [ i ] . flag = state . str -> flag ; tmp = state . str -> next ; pfree ( state . str ) ; state . str = tmp ; } memcpy ( ( void * ) GETOPERAND ( query ) , ( void * ) state . op , state . sumlen ) ; pfree ( state . op ) ; pos = 0 ; findoprnd ( ptr , & pos ) ; return query ; } "," ) ) ; if ( LTXTQUERY_TOO_BIG ( state . num , state . sumlen ) ) ereport ( ERROR , ( errcode ( ERRCODE_PROGRAM_LIMIT_EXCEEDED ) , errmsg ( ""ltxtqueryistoolarge"" ) ) ) ; ",postgres@postgres/31400a673325147e1205326008e32135a78b4d8a,CVE-2014-2669,https://github.com/postgres/postgres/commit/31400a673325147e1205326008e32135a78b4d8a,2014-03-31T14:58Z 972,CWE-000,"CWE-000 static void SaltTextAway ( XtermWidget xw , int which , CELL * cellc , CELL * cell ) { TScreen * screen = TScreenOf ( xw ) ; SelectedCells * scp ; int i ; int eol ; int need = 0 ; Char * line ; Char * lp ; CELL first = * cellc ; CELL last = * cell ; if ( which < 0 || which >= MAX_SELECTIONS ) { TRACE ( ( ""SaltTextAway-whichselection?\\n"" ) ) ; return ; } scp = & ( screen -> selected_cells [ which ] ) ; TRACE ( ( ""SaltTextAwaywhich=%d,first=%d,%d,last=%d,%d\\n"" , which , first . row , first . col , last . row , last . col ) ) ; if ( isSameRow ( & first , & last ) && first . col > last . col ) { int tmp ; EXCHANGE ( first . col , last . col , tmp ) ; } -- last . col ; if ( isSameRow ( & last , & first ) ) { need = Length ( screen , first . row , first . col , last . col ) ; } else { need += Length ( screen , first . row , first . col , screen -> max_col ) + 1 ; for ( i = first . row + 1 ; i < last . row ; i ++ ) need += Length ( screen , i , 0 , screen -> max_col ) + 1 ; if ( last . col >= 0 ) need += Length ( screen , last . row , 0 , last . col ) ; } if_OPT_WIDE_CHARS ( screen , { need *= 4 ; } ) ; if ( need < 0 ) return ; if ( scp -> data_limit <= ( unsigned ) need ) { if ( ( line = ( Char * ) malloc ( ( size_t ) need + 1 ) ) == 0 ) SysError ( ERROR_BMALLOC2 ) ; free ( scp -> data_buffer ) ; scp -> data_buffer = line ; scp -> data_limit = ( size_t ) ( need + 1 ) ; } else { line = scp -> data_buffer ; } if ( line == 0 ) return ; line [ need ] = '\\0' ; lp = line ; if ( isSameRow ( & last , & first ) ) { lp = SaveText ( screen , last . row , first . col , last . col , lp , & eol ) ; } else { lp = SaveText ( screen , first . row , first . col , screen -> max_col , lp , & eol ) ; if ( eol ) * lp ++ = '\\n' ; for ( i = first . row + 1 ; i < last . row ; i ++ ) { lp = SaveText ( screen , i , 0 , screen -> max_col , lp , & eol ) ; if ( eol ) * lp ++ = '\\n' ; } if ( last . col >= 0 ) lp = SaveText ( screen , last . row , 0 , last . col , lp , & eol ) ; } * lp = '\\0' ; TRACE ( ( ""SaltedTEXT:%u:%s\\n"" , ( unsigned ) ( lp - line ) , visibleChars ( line , ( unsigned ) ( lp - line ) ) ) ) ; scp -> data_length = ( size_t ) ( lp - line ) ; } "," ; int need = 0 ; size_t have screen , { if ( need > 0 ) { if ( screen -> max_combining > 0 ) need += screen -> max_combining ; need *= 6 ; } } ) ; = '\\0' ; have = ( size_t ) ( lp - line ) ; if ( ( have * 2 ) < ( size_t ) need ) { scp -> data_limit = have + 1 ; line = realloc ( line , scp -> data_limit ) ; } ( unsigned ) have , visibleChars ( ( unsigned ) have ) ) ) -> data_length = have ; } ",ThomasDickey@xterm-snapshots/82ba55b8f994ab30ff561a347b82ea340ba7075c,CVE-2021-27135,https://github.com/ThomasDickey/xterm-snapshots/commit/82ba55b8f994ab30ff561a347b82ea340ba7075c,2021-02-10T16:15Z 973,CWE-20,"CWE-20 int ext4_orphan_del ( handle_t * handle , struct inode * inode ) { struct list_head * prev ; struct ext4_inode_info * ei = EXT4_I ( inode ) ; struct ext4_sb_info * sbi ; __u32 ino_next ; struct ext4_iloc iloc ; int err = 0 ; if ( handle && ! ext4_handle_valid ( handle ) ) return 0 ; mutex_lock ( & EXT4_SB ( inode -> i_sb ) -> s_orphan_lock ) ; if ( list_empty ( & ei -> i_orphan ) ) goto out ; ino_next = NEXT_ORPHAN ( inode ) ; prev = ei -> i_orphan . prev ; sbi = EXT4_SB ( inode -> i_sb ) ; jbd_debug ( 4 , ""removeinode%lufromorphanlist\\n"" , inode -> i_ino ) ; list_del_init ( & ei -> i_orphan ) ; if ( sbi -> s_journal && ! handle ) goto out ; err = ext4_reserve_inode_write ( handle , inode , & iloc ) ; if ( err ) goto out_err ; if ( prev == & sbi -> s_orphan ) { jbd_debug ( 4 , ""superblockwillpointto%u\\n"" , ino_next ) ; BUFFER_TRACE ( sbi -> s_sbh , ""get_write_access"" ) ; err = ext4_journal_get_write_access ( handle , sbi -> s_sbh ) ; if ( err ) goto out_brelse ; sbi -> s_es -> s_last_orphan = cpu_to_le32 ( ino_next ) ; err = ext4_handle_dirty_super ( handle , inode -> i_sb ) ; } else { struct ext4_iloc iloc2 ; struct inode * i_prev = & list_entry ( prev , struct ext4_inode_info , i_orphan ) -> vfs_inode ; jbd_debug ( 4 , ""orphaninode%luwillpointto%u\\n"" , i_prev -> i_ino , ino_next ) ; err = ext4_reserve_inode_write ( handle , i_prev , & iloc2 ) ; if ( err ) goto out_brelse ; NEXT_ORPHAN ( i_prev ) = ino_next ; err = ext4_mark_iloc_dirty ( handle , i_prev , & iloc2 ) ; } if ( err ) goto out_brelse ; NEXT_ORPHAN ( inode ) = 0 ; err = ext4_mark_iloc_dirty ( handle , inode , & iloc ) ; out_err : ext4_std_error ( inode -> i_sb , err ) ; out : mutex_unlock ( & EXT4_SB ( inode -> i_sb ) -> s_orphan_lock ) ; return err ; out_brelse : brelse ( iloc . bh ) ; goto out_err ; } "," ; if ( ! EXT4_SB ( inode -> i_sb ) -> s_journal ) return 0 ; if ( ! handle ) ",torvalds@linux/c9b92530a723ac5ef8e352885a1862b18f31b2f5,CVE-2015-7509,https://github.com/torvalds/linux/commit/c9b92530a723ac5ef8e352885a1862b18f31b2f5,2015-12-28T11:59Z 974,CWE-119,"CWE-119 void ftoa_bounded_extra ( JsVarFloat val , char * str , size_t len , int radix , int fractionalDigits ) { const JsVarFloat stopAtError = 0.0000001 ; if ( isnan ( val ) ) strncpy ( str , ""NaN"" , len ) ; else if ( ! isfinite ( val ) ) { if ( val < 0 ) strncpy ( str , ""-Infinity"" , len ) ; else strncpy ( str , ""Infinity"" , len ) ; } else { if ( val < 0 ) { if ( -- len <= 0 ) { * str = 0 ; return ; } * ( str ++ ) = '-' ; val = - val ; } if ( ( ( JsVarInt ) ( val + stopAtError ) ) == ( 1 + ( JsVarInt ) val ) ) val = ( JsVarFloat ) ( 1 + ( JsVarInt ) val ) ; JsVarFloat d = 1 ; while ( d * radix <= val ) d *= radix ; while ( d >= 1 ) { int v = ( int ) ( val / d ) ; val -= v * d ; if ( -- len <= 0 ) { * str = 0 ; return ; } * ( str ++ ) = itoch ( v ) ; d /= radix ; } # ifndef USE_NO_FLOATS if ( ( ( fractionalDigits < 0 ) && val > 0 ) || fractionalDigits > 0 ) { bool hasPt = false ; val *= radix ; while ( ( ( fractionalDigits < 0 ) && ( fractionalDigits > - 12 ) && ( val > stopAtError ) ) || ( fractionalDigits > 0 ) ) { int v = ( int ) ( val + ( ( fractionalDigits == 1 ) ? 0.4 : 0.00000001 ) ) ; val = ( val - v ) * radix ; if ( v == radix ) v = radix - 1 ; if ( ! hasPt ) { hasPt = true ; if ( -- len <= 0 ) { * str = 0 ; return ; } * ( str ++ ) = '.' ; } if ( -- len <= 0 ) { * str = 0 ; return ; } * ( str ++ ) = itoch ( v ) ; fractionalDigits -- ; } } # endif * ( str ++ ) = 0 ; } } "," fractionalDigits ) { assert ( len > 9 ) ; val ) ) strcpy ( str , str , ""NaN"" ) ; else < 0 ) strcpy ( str , str , ""-Infinity"" ) ; else ) ; else strcpy ( str , str , ""Infinity"" ) ; } ",espruino@Espruino/0a7619875bf79877907205f6bee08465b89ff10b,CVE-2018-11595,https://github.com/espruino/Espruino/commit/0a7619875bf79877907205f6bee08465b89ff10b,2018-05-31T16:29Z 975,CWE-787,"CWE-787 opj_image_t * pgxtoimage ( const char * filename , opj_cparameters_t * parameters ) { FILE * f = NULL ; int w , h , prec ; int i , numcomps , max ; OPJ_COLOR_SPACE color_space ; opj_image_cmptparm_t cmptparm ; opj_image_t * image = NULL ; int adjustS , ushift , dshift , force8 ; char endian1 , endian2 , sign ; char signtmp [ 32 ] ; char temp [ 32 ] ; int bigendian ; opj_image_comp_t * comp = NULL ; numcomps = 1 ; color_space = OPJ_CLRSPC_GRAY ; memset ( & cmptparm , 0 , sizeof ( opj_image_cmptparm_t ) ) ; max = 0 ; f = fopen ( filename , ""rb"" ) ; if ( ! f ) { fprintf ( stderr , ""Failedtoopen%sforreading!\\n"" , filename ) ; return NULL ; } fseek ( f , 0 , SEEK_SET ) ; if ( fscanf ( f , ""PG%[\\t]%c%c%[\\t+-]%d%[\\t]%d%[\\t]%d"" , temp , & endian1 , & endian2 , signtmp , & prec , temp , & w , temp , & h ) != 9 ) { fclose ( f ) ; fprintf ( stderr , ""ERROR:Failedtoreadtherightnumberofelementfromthefscanf()function!\\n"" ) ; return NULL ; } i = 0 ; sign = '+' ; while ( signtmp [ i ] != '\\0' ) { if ( signtmp [ i ] == '-' ) { sign = '-' ; } i ++ ; } fgetc ( f ) ; if ( endian1 == 'M' && endian2 == 'L' ) { bigendian = 1 ; } else if ( endian2 == 'M' && endian1 == 'L' ) { bigendian = 0 ; } else { fclose ( f ) ; fprintf ( stderr , ""Badpgxheader,pleasecheckinputfile\\n"" ) ; return NULL ; } cmptparm . x0 = ( OPJ_UINT32 ) parameters -> image_offset_x0 ; cmptparm . y0 = ( OPJ_UINT32 ) parameters -> image_offset_y0 ; cmptparm . w = ! cmptparm . x0 ? ( OPJ_UINT32 ) ( ( w - 1 ) * parameters -> subsampling_dx + 1 ) : cmptparm . x0 + ( OPJ_UINT32 ) ( w - 1 ) * ( OPJ_UINT32 ) parameters -> subsampling_dx + 1 ; cmptparm . h = ! cmptparm . y0 ? ( OPJ_UINT32 ) ( ( h - 1 ) * parameters -> subsampling_dy + 1 ) : cmptparm . y0 + ( OPJ_UINT32 ) ( h - 1 ) * ( OPJ_UINT32 ) parameters -> subsampling_dy + 1 ; if ( sign == '-' ) { cmptparm . sgnd = 1 ; } else { cmptparm . sgnd = 0 ; } if ( prec < 8 ) { force8 = 1 ; ushift = 8 - prec ; dshift = prec - ushift ; if ( cmptparm . sgnd ) { adjustS = ( 1 << ( prec - 1 ) ) ; } else { adjustS = 0 ; } cmptparm . sgnd = 0 ; prec = 8 ; } else { ushift = dshift = force8 = adjustS = 0 ; } cmptparm . prec = ( OPJ_UINT32 ) prec ; cmptparm . bpp = ( OPJ_UINT32 ) prec ; cmptparm . dx = ( OPJ_UINT32 ) parameters -> subsampling_dx ; cmptparm . dy = ( OPJ_UINT32 ) parameters -> subsampling_dy ; image = opj_image_create ( ( OPJ_UINT32 ) numcomps , & cmptparm , color_space ) ; if ( ! image ) { fclose ( f ) ; return NULL ; } image -> x0 = cmptparm . x0 ; image -> y0 = cmptparm . x0 ; image -> x1 = cmptparm . w ; image -> y1 = cmptparm . h ; comp = & image -> comps [ 0 ] ; for ( i = 0 ; i < w * h ; i ++ ) { int v ; if ( force8 ) { v = readuchar ( f ) + adjustS ; v = ( v << ushift ) + ( v >> dshift ) ; comp -> data [ i ] = ( unsigned char ) v ; if ( v > max ) { max = v ; } continue ; } if ( comp -> prec == 8 ) { if ( ! comp -> sgnd ) { v = readuchar ( f ) ; } else { v = ( char ) readuchar ( f ) ; } } else if ( comp -> prec <= 16 ) { if ( ! comp -> sgnd ) { v = readushort ( f , bigendian ) ; } else { v = ( short ) readushort ( f , bigendian ) ; } } else { if ( ! comp -> sgnd ) { v = ( int ) readuint ( f , bigendian ) ; } else { v = ( int ) readuint ( f , bigendian ) ; } } if ( v > max ) { max = v ; } comp -> data [ i ] = v ; } fclose ( f ) ; comp -> bpp = ( OPJ_UINT32 ) int_floorlog2 ( max ) + 1 ; return image ; } "," ( f , ""PG%31[\\t]%c%c%31[\\t+-]%d%31[\\t]%d%31[\\t]%d"" , temp , ",uclouvain@openjpeg/e5285319229a5d77bf316bb0d3a6cbd3cb8666d9,CVE-2017-14041,https://github.com/uclouvain/openjpeg/commit/e5285319229a5d77bf316bb0d3a6cbd3cb8666d9,2017-08-30T22:29Z 976,CWE-787,"CWE-787 static void test_function ( char * ( * my_asnprintf ) ( char * , size_t * , const char * , ... ) ) { char buf [ 8 ] ; int size ; for ( size = 0 ; size <= 8 ; size ++ ) { size_t length = size ; char * result = my_asnprintf ( NULL , & length , ""%d"" , 12345 ) ; ASSERT ( result != NULL ) ; ASSERT ( strcmp ( result , ""12345"" ) == 0 ) ; ASSERT ( length == 5 ) ; free ( result ) ; } for ( size = 0 ; size <= 8 ; size ++ ) { size_t length ; char * result ; memcpy ( buf , ""DEADBEEF"" , 8 ) ; length = size ; result = my_asnprintf ( buf , & length , ""%d"" , 12345 ) ; ASSERT ( result != NULL ) ; ASSERT ( strcmp ( result , ""12345"" ) == 0 ) ; ASSERT ( length == 5 ) ; if ( size < 6 ) ASSERT ( result != buf ) ; ASSERT ( memcmp ( buf + size , & ""DEADBEEF"" [ size ] , 8 - size ) == 0 ) ; if ( result != buf ) free ( result ) ; } } "," ( size < 5 + 1 ) ASSERT ( ) ; } for ( size = 0 ; size <= 8 ; size ++ ) { size_t length ; char * result ; memcpy ( buf , ""DEADBEEF"" , 8 ) ; length = size ; result = my_asnprintf ( buf , & length , ""%2.0f"" , 1.6314159265358979e+125 ) ; ASSERT ( result != NULL ) ; ASSERT ( strcmp ( result , ""163141592653589790215729350939528493057529598899734151772468186268423257777068536614838678161083520756952076273094236944990208"" ) == 0 ) ; ASSERT ( length == 126 ) ; if ( size < 126 + 1 ) ASSERT ( result != buf ) ; ASSERT ( memcmp ( buf + size , & ""DEADBEEF"" [ size ] , 8 - size ) == 0 ) ; if ( result != buf ) free ( result ) ; } ",coreutils@gnulib/278b4175c9d7dd47c1a3071554aac02add3b3c35,CVE-2018-17942,https://github.com/coreutils/gnulib/commit/278b4175c9d7dd47c1a3071554aac02add3b3c35,2018-10-03T08:29Z 977,CWE-200,"CWE-200 void add_interrupt_randomness ( int irq , int irq_flags ) { struct entropy_store * r ; struct fast_pool * fast_pool = this_cpu_ptr ( & irq_randomness ) ; struct pt_regs * regs = get_irq_regs ( ) ; unsigned long now = jiffies ; cycles_t cycles = random_get_entropy ( ) ; __u32 c_high , j_high ; __u64 ip ; unsigned long seed ; int credit = 0 ; if ( cycles == 0 ) cycles = get_reg ( fast_pool , regs ) ; c_high = ( sizeof ( cycles ) > 4 ) ? cycles >> 32 : 0 ; j_high = ( sizeof ( now ) > 4 ) ? now >> 32 : 0 ; fast_pool -> pool [ 0 ] ^= cycles ^ j_high ^ irq ; fast_pool -> pool [ 1 ] ^= now ^ c_high ; ip = regs ? instruction_pointer ( regs ) : _RET_IP_ ; fast_pool -> pool [ 2 ] ^= ip ; fast_pool -> pool [ 3 ] ^= ( sizeof ( ip ) > 4 ) ? ip >> 32 : get_reg ( fast_pool , regs ) ; fast_mix ( fast_pool ) ; add_interrupt_bench ( cycles ) ; if ( unlikely ( crng_init == 0 ) ) { if ( ( fast_pool -> count >= 64 ) && crng_fast_load ( ( char * ) fast_pool -> pool , sizeof ( fast_pool -> pool ) ) ) { fast_pool -> count = 0 ; fast_pool -> last = now ; } return ; } if ( ( fast_pool -> count < 64 ) && ! time_after ( now , fast_pool -> last + HZ ) ) return ; r = & input_pool ; if ( ! spin_trylock ( & r -> lock ) ) return ; fast_pool -> last = now ; __mix_pool_bytes ( r , & fast_pool -> pool , sizeof ( fast_pool -> pool ) ) ; if ( arch_get_random_seed_long ( & seed ) ) { __mix_pool_bytes ( r , & seed , sizeof ( seed ) ) ; credit = 1 ; } spin_unlock ( & r -> lock ) ; fast_pool -> count = 0 ; credit_entropy_bits ( r , credit + 1 ) ; } "," cycles ) ; this_cpu_add ( net_rand_state . s1 , fast_pool -> pool [ cycles & 3 ] ) ; ",torvalds@linux/f227e3ec3b5cad859ad15666874405e8c1bbc1d4,CVE-2020-16166,https://github.com/torvalds/linux/commit/f227e3ec3b5cad859ad15666874405e8c1bbc1d4,2020-07-30T21:15Z 978,CWE-119,"CWE-119 void jslGetTokenString ( char * str , size_t len ) { if ( lex -> tk == LEX_ID ) { strncpy ( str , ""ID:"" , len ) ; strncat ( str , jslGetTokenValueAsString ( ) , len ) ; } else if ( lex -> tk == LEX_STR ) { strncpy ( str , ""String:\'"" , len ) ; strncat ( str , jslGetTokenValueAsString ( ) , len ) ; strncat ( str , ""\'"" , len ) ; } else jslTokenAsString ( lex -> tk , str , len ) ; } "," LEX_ID ) { espruino_snprintf ( str , ( str , len , ""ID:%s"" , jslGetTokenValueAsString ( jslGetTokenValueAsString ( ) ) ; } LEX_STR ) { espruino_snprintf ( str , ( str , len , ""String:\'%s\'"" , jslGetTokenValueAsString ( jslGetTokenValueAsString ( ) ) ; } ",espruino@Espruino/0a7619875bf79877907205f6bee08465b89ff10b,CVE-2018-11595,https://github.com/espruino/Espruino/commit/0a7619875bf79877907205f6bee08465b89ff10b,2018-05-31T16:29Z 979,CWE-22,"CWE-22 local void process ( char * path ) { int method = - 1 ; size_t len ; struct stat st ; static char * sufs [ ] = { "".z"" , ""-z"" , ""_z"" , "".Z"" , "".gz"" , ""-gz"" , "".zz"" , ""-zz"" , "".zip"" , "".ZIP"" , "".tgz"" , NULL } ; if ( path == NULL ) { strcpy ( g . inf , """" ) ; g . ind = 0 ; g . name = NULL ; g . mtime = g . headis & 2 ? ( fstat ( g . ind , & st ) ? time ( NULL ) : st . st_mtime ) : 0 ; len = 0 ; } else { if ( path != g . inf ) { strncpy ( g . inf , path , sizeof ( g . inf ) ) ; if ( g . inf [ sizeof ( g . inf ) - 1 ] ) bail ( ""nametoolong:"" , path ) ; } len = strlen ( g . inf ) ; if ( lstat ( g . inf , & st ) ) { if ( errno == ENOENT && ( g . list || g . decode ) ) { char * * try = sufs ; do { if ( * try == NULL || len + strlen ( * try ) >= sizeof ( g . inf ) ) break ; strcpy ( g . inf + len , * try ++ ) ; errno = 0 ; } while ( lstat ( g . inf , & st ) && errno == ENOENT ) ; } # ifdef EOVERFLOW if ( errno == EOVERFLOW || errno == EFBIG ) bail ( g . inf , ""toolarge--notcompiledwithlargefilesupport"" ) ; # endif if ( errno ) { g . inf [ len ] = 0 ; complain ( ""%sdoesnotexist--skipping"" , g . inf ) ; return ; } len = strlen ( g . inf ) ; } if ( ( st . st_mode & S_IFMT ) != S_IFREG && ( st . st_mode & S_IFMT ) != S_IFLNK && ( st . st_mode & S_IFMT ) != S_IFDIR ) { complain ( ""%sisaspecialfileordevice--skipping"" , g . inf ) ; return ; } if ( ( st . st_mode & S_IFMT ) == S_IFLNK && ! g . force && ! g . pipeout ) { complain ( ""%sisasymboliclink--skipping"" , g . inf ) ; return ; } if ( ( st . st_mode & S_IFMT ) == S_IFDIR && ! g . recurse ) { complain ( ""%sisadirectory--skipping"" , g . inf ) ; return ; } if ( ( st . st_mode & S_IFMT ) == S_IFDIR ) { char * roll , * item , * cut , * base , * bigger ; size_t len , hold ; DIR * here ; struct dirent * next ; here = opendir ( g . inf ) ; if ( here == NULL ) return ; hold = 512 ; roll = MALLOC ( hold ) ; if ( roll == NULL ) bail ( ""notenoughmemory"" , """" ) ; * roll = 0 ; item = roll ; while ( ( next = readdir ( here ) ) != NULL ) { if ( next -> d_name [ 0 ] == 0 || ( next -> d_name [ 0 ] == '.' && ( next -> d_name [ 1 ] == 0 || ( next -> d_name [ 1 ] == '.' && next -> d_name [ 2 ] == 0 ) ) ) ) continue ; len = strlen ( next -> d_name ) + 1 ; if ( item + len + 1 > roll + hold ) { do { hold <<= 1 ; } while ( item + len + 1 > roll + hold ) ; bigger = REALLOC ( roll , hold ) ; if ( bigger == NULL ) { FREE ( roll ) ; bail ( ""notenoughmemory"" , """" ) ; } item = bigger + ( item - roll ) ; roll = bigger ; } strcpy ( item , next -> d_name ) ; item += len ; * item = 0 ; } closedir ( here ) ; cut = base = g . inf + strlen ( g . inf ) ; if ( base > g . inf && base [ - 1 ] != ( unsigned char ) '/' ) { if ( ( size_t ) ( base - g . inf ) >= sizeof ( g . inf ) ) bail ( ""pathtoolong"" , g . inf ) ; * base ++ = '/' ; } item = roll ; while ( * item ) { strncpy ( base , item , sizeof ( g . inf ) - ( base - g . inf ) ) ; if ( g . inf [ sizeof ( g . inf ) - 1 ] ) { strcpy ( g . inf + ( sizeof ( g . inf ) - 4 ) , ""..."" ) ; bail ( ""pathtoolong:"" , g . inf ) ; } process ( g . inf ) ; item += strlen ( item ) + 1 ; } * cut = 0 ; FREE ( roll ) ; return ; } if ( ! ( g . force || g . list || g . decode ) && len >= strlen ( g . sufx ) && strcmp ( g . inf + len - strlen ( g . sufx ) , g . sufx ) == 0 ) { complain ( ""%sendswith%s--skipping"" , g . inf , g . sufx ) ; return ; } if ( g . decode == 1 && ! g . pipeout && ! g . list ) { int suf = compressed_suffix ( g . inf ) ; if ( suf == 0 ) { complain ( ""%sdoesnothavecompressedsuffix--skipping"" , g . inf ) ; return ; } len -= suf ; } g . ind = open ( g . inf , O_RDONLY , 0 ) ; if ( g . ind < 0 ) bail ( ""readerroron"" , g . inf ) ; g . name = g . headis & 1 ? justname ( g . inf ) : NULL ; g . mtime = g . headis & 2 ? st . st_mtime : 0 ; } SET_BINARY_MODE ( g . ind ) ; g . hname = NULL ; if ( g . decode ) { in_init ( ) ; method = get_header ( 1 ) ; if ( method != 8 && method != 257 && ! ( method == - 2 && g . force && g . pipeout && g . decode != 2 && ! g . list ) ) { RELEASE ( g . hname ) ; if ( g . ind != 0 ) close ( g . ind ) ; if ( method != - 1 ) complain ( method < 0 ? ""%sisnotcompressed--skipping"" : ""%shasunknowncompressionmethod--skipping"" , g . inf ) ; return ; } if ( g . decode == 2 ) { if ( method == 8 ) infchk ( ) ; else { unlzw ( ) ; if ( g . list ) { g . in_tot -= 3 ; show_info ( method , 0 , g . out_tot , 0 ) ; } } RELEASE ( g . hname ) ; if ( g . ind != 0 ) close ( g . ind ) ; return ; } } if ( g . list ) { list_info ( ) ; RELEASE ( g . hname ) ; if ( g . ind != 0 ) close ( g . ind ) ; return ; } if ( path == NULL || g . pipeout ) { g . outf = MALLOC ( strlen ( """" ) + 1 ) ; if ( g . outf == NULL ) bail ( ""notenoughmemory"" , """" ) ; strcpy ( g . outf , """" ) ; g . outd = 1 ; if ( ! g . decode && ! g . force && isatty ( g . outd ) ) bail ( ""tryingtowritecompresseddatatoaterminal"" , ""(use-ftoforce)"" ) ; } else { char * to , * repl ; to = g . inf ; if ( g . decode && ( g . headis & 1 ) != 0 && g . hname != NULL ) { to = g . hname ; len = strlen ( g . hname ) ; } repl = g . decode && strcmp ( to + len , "".tgz"" ) ? """" : "".tar"" ; g . outf = MALLOC ( len + ( g . decode ? strlen ( repl ) : strlen ( g . sufx ) ) + 1 ) ; if ( g . outf == NULL ) bail ( ""notenoughmemory"" , """" ) ; memcpy ( g . outf , to , len ) ; strcpy ( g . outf + len , g . decode ? repl : g . sufx ) ; g . outd = open ( g . outf , O_CREAT | O_TRUNC | O_WRONLY | ( g . force ? 0 : O_EXCL ) , 0600 ) ; if ( g . outd < 0 && errno == EEXIST && isatty ( 0 ) && g . verbosity ) { int ch , reply ; fprintf ( stderr , ""%sexists--overwrite(y/n)?"" , g . outf ) ; fflush ( stderr ) ; reply = - 1 ; do { ch = getchar ( ) ; if ( reply < 0 && ch != '' && ch != '\\t' ) reply = ch == 'y' || ch == 'Y' ? 1 : 0 ; } while ( ch != EOF && ch != '\\n' && ch != '\\r' ) ; if ( reply == 1 ) g . outd = open ( g . outf , O_CREAT | O_TRUNC | O_WRONLY , 0600 ) ; } if ( g . outd < 0 && errno == EEXIST ) { complain ( ""%sexists--skipping"" , g . outf ) ; RELEASE ( g . outf ) ; RELEASE ( g . hname ) ; if ( g . ind != 0 ) close ( g . ind ) ; return ; } if ( g . outd < 0 ) bail ( ""writeerroron"" , g . outf ) ; } SET_BINARY_MODE ( g . outd ) ; RELEASE ( g . hname ) ; if ( g . verbosity > 1 ) fprintf ( stderr , ""%sto%s"" , g . inf , g . outf ) ; if ( g . decode ) { if ( method == 8 ) infchk ( ) ; else if ( method == 257 ) unlzw ( ) ; else cat ( ) ; } # ifndef NOTHREAD else if ( g . procs > 1 ) parallel_compress ( ) ; # endif else single_compress ( 0 ) ; if ( g . verbosity > 1 ) { putc ( '\\n' , stderr ) ; fflush ( stderr ) ; } if ( g . ind != 0 ) close ( g . ind ) ; if ( g . outd != 1 ) { if ( close ( g . outd ) ) bail ( ""writeerroron"" , g . outf ) ; g . outd = - 1 ; if ( g . ind != 0 ) { copymeta ( g . inf , g . outf ) ; if ( ! g . keep ) unlink ( g . inf ) ; } if ( g . decode && ( g . headis & 2 ) != 0 && g . stamp ) touch ( g . outf , g . stamp ) ; } RELEASE ( g . outf ) ; } "," char * to = g . inf , * sufx = """" ; size_t pre = 0 ; if ( g . decode ) { if ( ( g . NULL ) { pre = justname ( g . inf ) - g . inf ; to = justname ( g . hname g . hname ) = strlen ( to ) ; } else if ( strcmp ( to , "".tgz"" ) == 0 ) sufx = "".tar"" ; } else sufx = g . sufx ; g . outf = MALLOC ( pre + len + strlen ( sufx ) + 1 ) . outf , g . inf , pre ) ; memcpy ( g . . outf + pre , to , len ) ; strcpy ( g . outf + pre + len , sufx ) ; ",madler@pigz/fdad1406b3ec809f4954ff7cdf9e99eb18c2458f,CVE-2015-1191,https://github.com/madler/pigz/commit/fdad1406b3ec809f4954ff7cdf9e99eb18c2458f,2015-01-21T18:59Z 980,CWE-119,"CWE-119 void cJSON_DeleteItemFromArray ( cJSON * array , int which ) { cJSON_Delete ( cJSON_DetachItemFromArray ( array , which ) ) ; } "," ",esnet@iperf/91f2fa59e8ed80dfbf400add0164ee0e508e412a,CVE-2016-4303,https://github.com/esnet/iperf/commit/91f2fa59e8ed80dfbf400add0164ee0e508e412a,2016-09-26T14:59Z 981,CWE-252,"CWE-252 static MagickBooleanType ConcatenateImages ( int argc , char * * argv , ExceptionInfo * exception ) { FILE * input , * output ; int c ; register ssize_t i ; if ( ExpandFilenames ( & argc , & argv ) == MagickFalse ) ThrowFileException ( exception , ResourceLimitError , ""MemoryAllocationFailed"" , GetExceptionMessage ( errno ) ) ; output = fopen_utf8 ( argv [ argc - 1 ] , ""wb"" ) ; if ( output == ( FILE * ) NULL ) { ThrowFileException ( exception , FileOpenError , ""UnableToOpenFile"" , argv [ argc - 1 ] ) ; return ( MagickFalse ) ; } for ( i = 2 ; i < ( ssize_t ) ( argc - 1 ) ; i ++ ) { # if 0 fprintf ( stderr , ""DEBUG:ConcatenateImage:\\""%s\\""\\n"" , argv [ i ] ) ; # endif input = fopen_utf8 ( argv [ i ] , ""rb"" ) ; if ( input == ( FILE * ) NULL ) { ThrowFileException ( exception , FileOpenError , ""UnableToOpenFile"" , argv [ i ] ) ; continue ; } for ( c = fgetc ( input ) ; c != EOF ; c = fgetc ( input ) ) ( void ) fputc ( ( char ) c , output ) ; ( void ) fclose ( input ) ; ( void ) remove_utf8 ( argv [ i ] ) ; } ( void ) fclose ( output ) ; return ( MagickTrue ) ; } "," * output ; MagickBooleanType status ; ) ; } status = MagickTrue ; i ++ ) { input = fopen_utf8 input ) ) if ( fputc ( ( char ) c , output ) != c ) status = MagickFalse ; ( void ) fclose ( input ) ; ( ( void ) remove_utf8 ( argv [ i ] ) ; } ( void ) fclose ( output ) ; ; return ( status ) ; } ",ImageMagick@ImageMagick/933e96f01a8c889c7bf5ffd30020e86a02a046e7,CVE-2016-10060,https://github.com/ImageMagick/ImageMagick/commit/933e96f01a8c889c7bf5ffd30020e86a02a046e7,2017-03-02T21:59Z 982,CWE-119,"CWE-119 vpx_codec_err_t vpx_svc_set_options ( SvcContext * svc_ctx , const char * options ) { SvcInternal * const si = get_svc_internal ( svc_ctx ) ; if ( svc_ctx == NULL || options == NULL || si == NULL ) { return VPX_CODEC_INVALID_PARAM ; } strncpy ( si -> options , options , sizeof ( si -> options ) ) ; si -> options [ sizeof ( si -> options ) - 1 ] = '\\0' ; return VPX_CODEC_OK ; } "," options ) { SvcInternal_t * const si ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 983,CWE-20,"CWE-20 static struct block_device * ext3_blkdev_get ( dev_t dev , struct super_block * sb ) { struct block_device * bdev ; char b [ BDEVNAME_SIZE ] ; bdev = blkdev_get_by_dev ( dev , FMODE_READ | FMODE_WRITE | FMODE_EXCL , sb ) ; if ( IS_ERR ( bdev ) ) goto fail ; return bdev ; fail : ext3_msg ( sb , ""error:failedtoopenjournaldevice%s:%ld"" , __bdevname ( dev , b ) , PTR_ERR ( bdev ) ) ; return NULL ; } "," ( sb , KERN_ERR , ",torvalds@linux/8d0c2d10dd72c5292eda7a06231056a4c972e4cc,CVE-2013-1848,https://github.com/torvalds/linux/commit/8d0c2d10dd72c5292eda7a06231056a4c972e4cc,2013-03-22T11:59Z 984,CWE-264,"CWE-264 int setpwnam ( struct passwd * pwd ) { FILE * fp = NULL , * pwf = NULL ; int save_errno ; int found ; int namelen ; int buflen = 256 ; int contlen , rc ; char * linebuf = NULL ; char * tmpname = NULL ; char * atomic_dir = ""/etc"" ; pw_init ( ) ; if ( ( fp = xfmkstemp ( & tmpname , atomic_dir ) ) == NULL ) return - 1 ; if ( fchown ( fileno ( fp ) , ( uid_t ) 0 , ( gid_t ) 0 ) < 0 ) goto fail ; if ( lckpwdf ( ) < 0 ) goto fail ; pwf = fopen ( PASSWD_FILE , ""r"" ) ; if ( ! pwf ) goto fail ; namelen = strlen ( pwd -> pw_name ) ; linebuf = malloc ( buflen ) ; if ( ! linebuf ) goto fail ; found = false ; while ( fgets ( linebuf , buflen , pwf ) != NULL ) { contlen = strlen ( linebuf ) ; while ( linebuf [ contlen - 1 ] != '\\n' && ! feof ( pwf ) ) { char * tmp ; buflen *= 2 ; tmp = realloc ( linebuf , buflen ) ; if ( tmp == NULL ) goto fail ; linebuf = tmp ; if ( fgets ( & linebuf [ contlen ] , buflen / 2 , pwf ) == NULL ) break ; contlen = strlen ( linebuf ) ; } if ( ! found && linebuf [ namelen ] == ':' && ! strncmp ( linebuf , pwd -> pw_name , namelen ) ) { if ( putpwent ( pwd , fp ) < 0 ) goto fail ; found = true ; continue ; } fputs ( linebuf , fp ) ; } if ( fchmod ( fileno ( fp ) , 0644 ) < 0 ) goto fail ; rc = close_stream ( fp ) ; fp = NULL ; if ( rc != 0 ) goto fail ; fclose ( pwf ) ; pwf = NULL ; if ( ! found ) { errno = ENOENT ; goto fail ; } unlink ( PASSWD_FILE "".OLD"" ) ; ignore_result ( link ( PASSWD_FILE , PASSWD_FILE "".OLD"" ) ) ; if ( rename ( tmpname , PASSWD_FILE ) < 0 ) goto fail ; ulckpwdf ( ) ; return 0 ; fail : save_errno = errno ; ulckpwdf ( ) ; if ( fp != NULL ) fclose ( fp ) ; if ( tmpname != NULL ) unlink ( tmpname ) ; free ( tmpname ) ; if ( pwf != NULL ) fclose ( pwf ) ; free ( linebuf ) ; errno = save_errno ; return - 1 ; } "," passwd * pwd , const char * prefix = NULL ; pw_init ( ) & tmpname , ""/etc"" , prefix ) ) == ",karelzak@util-linux/bde91c85bdc77975155058276f99d2e0f5eab5a9,CVE-2015-5224,https://github.com/karelzak/util-linux/commit/bde91c85bdc77975155058276f99d2e0f5eab5a9,2017-08-23T15:29Z 985,CWE-119,"CWE-119 static unsigned int convert_distribution ( unsigned int i , vp9_tree tree , unsigned int branch_ct [ ] [ 2 ] , const unsigned int num_events [ ] ) { unsigned int left , right ; if ( tree [ i ] <= 0 ) left = num_events [ - tree [ i ] ] ; else left = convert_distribution ( tree [ i ] , tree , branch_ct , num_events ) ; if ( tree [ i + 1 ] <= 0 ) right = num_events [ - tree [ i + 1 ] ] ; else right = convert_distribution ( tree [ i + 1 ] , tree , branch_ct , num_events ) ; branch_ct [ i >> 1 ] [ 0 ] = left ; branch_ct [ i >> 1 ] [ 1 ] = right ; return left + right ; } "," int i , vpx_tree tree , unsigned ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 986,CWE-125,"CWE-125 int pure_strcmp ( const char * const s1 , const char * const s2 ) { return pure_memcmp ( s1 , s2 , strlen ( s1 ) + 1U ) ; } "," s2 ) { const size_t s1_len = strlen ( s1 ) ; const size_t s2_len = strlen ( s2 ) ; const size_t len = ( s1_len < s2_len ) ? s1_len : s2_len ; , s2 , len + 1 ) ; } ",jedisct1@pure-ftpd/bf6fcd4935e95128cf22af5924cdc8fe5c0579da,CVE-2020-9365,https://github.com/jedisct1/pure-ftpd/commit/bf6fcd4935e95128cf22af5924cdc8fe5c0579da,2020-02-24T16:15Z 987,CWE-346,"CWE-346 static gboolean _handle_carbons ( xmpp_stanza_t * const stanza ) { xmpp_stanza_t * carbons = xmpp_stanza_get_child_by_ns ( stanza , STANZA_NS_CARBONS ) ; if ( ! carbons ) { return FALSE ; } const char * name = xmpp_stanza_get_name ( carbons ) ; if ( ! name ) { log_error ( ""UnabletoretrievestanzanameforCarbon"" ) ; return TRUE ; } if ( g_strcmp0 ( name , ""private"" ) == 0 ) { log_info ( ""Carbonreceivedwithprivateelement."" ) ; return FALSE ; } if ( ( g_strcmp0 ( name , ""received"" ) != 0 ) && ( g_strcmp0 ( name , ""sent"" ) != 0 ) ) { log_warning ( ""Carbonreceivedwithunrecognisedstanzaname:%s"" , name ) ; return TRUE ; } xmpp_stanza_t * forwarded = xmpp_stanza_get_child_by_ns ( carbons , STANZA_NS_FORWARD ) ; if ( ! forwarded ) { log_warning ( ""Carbonreceivedwithnoforwardedelement"" ) ; return TRUE ; } xmpp_stanza_t * message = xmpp_stanza_get_child_by_name ( forwarded , STANZA_NAME_MESSAGE ) ; if ( ! message ) { log_warning ( ""Carbonreceivedwithnomessageelement"" ) ; return TRUE ; } char * message_txt = xmpp_message_get_body ( message ) ; if ( ! message_txt ) { log_warning ( ""Carbonreceivedwithnomessage."" ) ; return TRUE ; } const gchar * to = xmpp_stanza_get_to ( message ) ; const gchar * from = xmpp_stanza_get_from ( message ) ; if ( ! to ) to = from ; Jid * jid_from = jid_create ( from ) ; Jid * jid_to = jid_create ( to ) ; Jid * my_jid = jid_create ( connection_get_fulljid ( ) ) ; char * enc_message = NULL ; xmpp_stanza_t * x = xmpp_stanza_get_child_by_ns ( message , STANZA_NS_ENCRYPTED ) ; if ( x ) { enc_message = xmpp_stanza_get_text ( x ) ; } if ( g_strcmp0 ( my_jid -> barejid , jid_to -> barejid ) == 0 ) { sv_ev_incoming_carbon ( jid_from -> barejid , jid_from -> resourcepart , message_txt , enc_message ) ; } else { sv_ev_outgoing_carbon ( jid_to -> barejid , message_txt , enc_message ) ; } xmpp_ctx_t * ctx = connection_get_ctx ( ) ; xmpp_free ( ctx , message_txt ) ; xmpp_free ( ctx , enc_message ) ; jid_destroy ( jid_from ) ; jid_destroy ( jid_to ) ; jid_destroy ( my_jid ) ; return TRUE ; } "," TRUE ; } Jid * my_jid = jid_create ( connection_get_fulljid ( ) ) ; const char * const stanza_from = xmpp_stanza_get_from ( stanza ) ; Jid * msg_jid = jid_create ( stanza_from ) ; if ( g_strcmp0 ( my_jid -> barejid , msg_jid -> barejid ) != 0 ) { log_warning ( ""Invalidcarbonreceived,from:%s"" , stanza_from ) ; return TRUE ; } jid_create ( to ) ; char ",boothj5@profanity/8e75437a7e43d4c55e861691f74892e666e29b0b,CVE-2017-5592,https://github.com/boothj5/profanity/commit/8e75437a7e43d4c55e861691f74892e666e29b0b,2017-02-09T20:59Z 988,CWE-119,"CWE-119 void configSetCommand ( client * c ) { robj * o ; long long ll ; int err ; serverAssertWithInfo ( c , c -> argv [ 2 ] , sdsEncodedObject ( c -> argv [ 2 ] ) ) ; serverAssertWithInfo ( c , c -> argv [ 3 ] , sdsEncodedObject ( c -> argv [ 3 ] ) ) ; o = c -> argv [ 3 ] ; if ( 0 ) { config_set_special_field ( ""dbfilename"" ) { if ( ! pathIsBaseName ( o -> ptr ) ) { addReplyError ( c , ""dbfilenamecan\'tbeapath,justafilename"" ) ; return ; } zfree ( server . rdb_filename ) ; server . rdb_filename = zstrdup ( o -> ptr ) ; } config_set_special_field ( ""requirepass"" ) { if ( sdslen ( o -> ptr ) > CONFIG_AUTHPASS_MAX_LEN ) goto badfmt ; zfree ( server . requirepass ) ; server . requirepass = ( ( char * ) o -> ptr ) [ 0 ] ? zstrdup ( o -> ptr ) : NULL ; } config_set_special_field ( ""masterauth"" ) { zfree ( server . masterauth ) ; server . masterauth = ( ( char * ) o -> ptr ) [ 0 ] ? zstrdup ( o -> ptr ) : NULL ; } config_set_special_field ( ""cluster-announce-ip"" ) { zfree ( server . cluster_announce_ip ) ; server . cluster_announce_ip = ( ( char * ) o -> ptr ) [ 0 ] ? zstrdup ( o -> ptr ) : NULL ; } config_set_special_field ( ""maxclients"" ) { int orig_value = server . maxclients ; if ( getLongLongFromObject ( o , & ll ) == C_ERR || ll < 1 ) goto badfmt ; server . maxclients = ll ; if ( ll > orig_value ) { adjustOpenFilesLimit ( ) ; if ( server . maxclients != ll ) { addReplyErrorFormat ( c , ""Theoperatingsystemisnotabletohandlethespecifiednumberofclients,trywith%d"" , server . maxclients ) ; server . maxclients = orig_value ; return ; } if ( ( unsigned int ) aeGetSetSize ( server . el ) < server . maxclients + CONFIG_FDSET_INCR ) { if ( aeResizeSetSize ( server . el , server . maxclients + CONFIG_FDSET_INCR ) == AE_ERR ) { addReplyError ( c , ""TheeventloopAPIusedbyRedisisnotabletohandlethespecifiednumberofclients"" ) ; server . maxclients = orig_value ; return ; } } } } config_set_special_field ( ""appendonly"" ) { int enable = yesnotoi ( o -> ptr ) ; if ( enable == - 1 ) goto badfmt ; if ( enable == 0 && server . aof_state != AOF_OFF ) { stopAppendOnly ( ) ; } else if ( enable && server . aof_state == AOF_OFF ) { if ( startAppendOnly ( ) == C_ERR ) { addReplyError ( c , ""UnabletoturnonAOF.Checkserverlogs."" ) ; return ; } } } config_set_special_field ( ""save"" ) { int vlen , j ; sds * v = sdssplitlen ( o -> ptr , sdslen ( o -> ptr ) , """" , 1 , & vlen ) ; if ( vlen & 1 ) { sdsfreesplitres ( v , vlen ) ; goto badfmt ; } for ( j = 0 ; j < vlen ; j ++ ) { char * eptr ; long val ; val = strtoll ( v [ j ] , & eptr , 10 ) ; if ( eptr [ 0 ] != '\\0' || ( ( j & 1 ) == 0 && val < 1 ) || ( ( j & 1 ) == 1 && val < 0 ) ) { sdsfreesplitres ( v , vlen ) ; goto badfmt ; } } resetServerSaveParams ( ) ; for ( j = 0 ; j < vlen ; j += 2 ) { time_t seconds ; int changes ; seconds = strtoll ( v [ j ] , NULL , 10 ) ; changes = strtoll ( v [ j + 1 ] , NULL , 10 ) ; appendServerSaveParams ( seconds , changes ) ; } sdsfreesplitres ( v , vlen ) ; } config_set_special_field ( ""dir"" ) { if ( chdir ( ( char * ) o -> ptr ) == - 1 ) { addReplyErrorFormat ( c , ""Changingdirectory:%s"" , strerror ( errno ) ) ; return ; } } config_set_special_field ( ""client-output-buffer-limit"" ) { int vlen , j ; sds * v = sdssplitlen ( o -> ptr , sdslen ( o -> ptr ) , """" , 1 , & vlen ) ; if ( vlen % 4 ) { sdsfreesplitres ( v , vlen ) ; goto badfmt ; } for ( j = 0 ; j < vlen ; j ++ ) { long val ; if ( ( j % 4 ) == 0 ) { if ( getClientTypeByName ( v [ j ] ) == - 1 ) { sdsfreesplitres ( v , vlen ) ; goto badfmt ; } } else { val = memtoll ( v [ j ] , & err ) ; if ( err || val < 0 ) { sdsfreesplitres ( v , vlen ) ; goto badfmt ; } } } for ( j = 0 ; j < vlen ; j += 4 ) { int class ; unsigned long long hard , soft ; int soft_seconds ; class = getClientTypeByName ( v [ j ] ) ; hard = strtoll ( v [ j + 1 ] , NULL , 10 ) ; soft = strtoll ( v [ j + 2 ] , NULL , 10 ) ; soft_seconds = strtoll ( v [ j + 3 ] , NULL , 10 ) ; server . client_obuf_limits [ class ] . hard_limit_bytes = hard ; server . client_obuf_limits [ class ] . soft_limit_bytes = soft ; server . client_obuf_limits [ class ] . soft_limit_seconds = soft_seconds ; } sdsfreesplitres ( v , vlen ) ; } config_set_special_field ( ""notify-keyspace-events"" ) { int flags = keyspaceEventsStringToFlags ( o -> ptr ) ; if ( flags == - 1 ) goto badfmt ; server . notify_keyspace_events = flags ; } config_set_special_field ( ""slave-announce-ip"" ) { zfree ( server . slave_announce_ip ) ; server . slave_announce_ip = ( ( char * ) o -> ptr ) [ 0 ] ? zstrdup ( o -> ptr ) : NULL ; } config_set_bool_field ( ""rdbcompression"" , server . rdb_compression ) { } config_set_bool_field ( ""repl-disable-tcp-nodelay"" , server . repl_disable_tcp_nodelay ) { } config_set_bool_field ( ""repl-diskless-sync"" , server . repl_diskless_sync ) { } config_set_bool_field ( ""cluster-require-full-coverage"" , server . cluster_require_full_coverage ) { } config_set_bool_field ( ""aof-rewrite-incremental-fsync"" , server . aof_rewrite_incremental_fsync ) { } config_set_bool_field ( ""aof-load-truncated"" , server . aof_load_truncated ) { } config_set_bool_field ( ""aof-use-rdb-preamble"" , server . aof_use_rdb_preamble ) { } config_set_bool_field ( ""slave-serve-stale-data"" , server . repl_serve_stale_data ) { } config_set_bool_field ( ""slave-read-only"" , server . repl_slave_ro ) { } config_set_bool_field ( ""activerehashing"" , server . activerehashing ) { } config_set_bool_field ( ""protected-mode"" , server . protected_mode ) { } config_set_bool_field ( ""stop-writes-on-bgsave-error"" , server . stop_writes_on_bgsave_err ) { } config_set_bool_field ( ""lazyfree-lazy-eviction"" , server . lazyfree_lazy_eviction ) { } config_set_bool_field ( ""lazyfree-lazy-expire"" , server . lazyfree_lazy_expire ) { } config_set_bool_field ( ""lazyfree-lazy-server-del"" , server . lazyfree_lazy_server_del ) { } config_set_bool_field ( ""slave-lazy-flush"" , server . repl_slave_lazy_flush ) { } config_set_bool_field ( ""no-appendfsync-on-rewrite"" , server . aof_no_fsync_on_rewrite ) { } config_set_numerical_field ( ""tcp-keepalive"" , server . tcpkeepalive , 0 , LLONG_MAX ) { } config_set_numerical_field ( ""maxmemory-samples"" , server . maxmemory_samples , 1 , LLONG_MAX ) { } config_set_numerical_field ( ""lfu-log-factor"" , server . lfu_log_factor , 0 , LLONG_MAX ) { } config_set_numerical_field ( ""lfu-decay-time"" , server . lfu_decay_time , 0 , LLONG_MAX ) { } config_set_numerical_field ( ""timeout"" , server . maxidletime , 0 , LONG_MAX ) { } config_set_numerical_field ( ""auto-aof-rewrite-percentage"" , server . aof_rewrite_perc , 0 , LLONG_MAX ) { } config_set_numerical_field ( ""auto-aof-rewrite-min-size"" , server . aof_rewrite_min_size , 0 , LLONG_MAX ) { } config_set_numerical_field ( ""hash-max-ziplist-entries"" , server . hash_max_ziplist_entries , 0 , LLONG_MAX ) { } config_set_numerical_field ( ""hash-max-ziplist-value"" , server . hash_max_ziplist_value , 0 , LLONG_MAX ) { } config_set_numerical_field ( ""list-max-ziplist-size"" , server . list_max_ziplist_size , INT_MIN , INT_MAX ) { } config_set_numerical_field ( ""list-compress-depth"" , server . list_compress_depth , 0 , INT_MAX ) { } config_set_numerical_field ( ""set-max-intset-entries"" , server . set_max_intset_entries , 0 , LLONG_MAX ) { } config_set_numerical_field ( ""zset-max-ziplist-entries"" , server . zset_max_ziplist_entries , 0 , LLONG_MAX ) { } config_set_numerical_field ( ""zset-max-ziplist-value"" , server . zset_max_ziplist_value , 0 , LLONG_MAX ) { } config_set_numerical_field ( ""hll-sparse-max-bytes"" , server . hll_sparse_max_bytes , 0 , LLONG_MAX ) { } config_set_numerical_field ( ""lua-time-limit"" , server . lua_time_limit , 0 , LLONG_MAX ) { } config_set_numerical_field ( ""slowlog-log-slower-than"" , server . slowlog_log_slower_than , 0 , LLONG_MAX ) { } config_set_numerical_field ( ""slowlog-max-len"" , ll , 0 , LLONG_MAX ) { server . slowlog_max_len = ( unsigned ) ll ; } config_set_numerical_field ( ""latency-monitor-threshold"" , server . latency_monitor_threshold , 0 , LLONG_MAX ) { } config_set_numerical_field ( ""repl-ping-slave-period"" , server . repl_ping_slave_period , 1 , LLONG_MAX ) { } config_set_numerical_field ( ""repl-timeout"" , server . repl_timeout , 1 , LLONG_MAX ) { } config_set_numerical_field ( ""repl-backlog-ttl"" , server . repl_backlog_time_limit , 0 , LLONG_MAX ) { } config_set_numerical_field ( ""repl-diskless-sync-delay"" , server . repl_diskless_sync_delay , 0 , LLONG_MAX ) { } config_set_numerical_field ( ""slave-priority"" , server . slave_priority , 0 , LLONG_MAX ) { } config_set_numerical_field ( ""slave-announce-port"" , server . slave_announce_port , 0 , 65535 ) { } config_set_numerical_field ( ""min-slaves-to-write"" , server . repl_min_slaves_to_write , 0 , LLONG_MAX ) { refreshGoodSlavesCount ( ) ; } config_set_numerical_field ( ""min-slaves-max-lag"" , server . repl_min_slaves_max_lag , 0 , LLONG_MAX ) { refreshGoodSlavesCount ( ) ; } config_set_numerical_field ( ""cluster-node-timeout"" , server . cluster_node_timeout , 0 , LLONG_MAX ) { } config_set_numerical_field ( ""cluster-announce-port"" , server . cluster_announce_port , 0 , 65535 ) { } config_set_numerical_field ( ""cluster-announce-bus-port"" , server . cluster_announce_bus_port , 0 , 65535 ) { } config_set_numerical_field ( ""cluster-migration-barrier"" , server . cluster_migration_barrier , 0 , LLONG_MAX ) { } config_set_numerical_field ( ""cluster-slave-validity-factor"" , server . cluster_slave_validity_factor , 0 , LLONG_MAX ) { } config_set_numerical_field ( ""hz"" , server . hz , 0 , LLONG_MAX ) { if ( server . hz < CONFIG_MIN_HZ ) server . hz = CONFIG_MIN_HZ ; if ( server . hz > CONFIG_MAX_HZ ) server . hz = CONFIG_MAX_HZ ; } config_set_numerical_field ( ""watchdog-period"" , ll , 0 , LLONG_MAX ) { if ( ll ) enableWatchdog ( ll ) ; else disableWatchdog ( ) ; } config_set_memory_field ( ""maxmemory"" , server . maxmemory ) { if ( server . maxmemory ) { if ( server . maxmemory < zmalloc_used_memory ( ) ) { serverLog ( LL_WARNING , ""WARNING:thenewmaxmemoryvaluesetviaCONFIGSETissmallerthanthecurrentmemoryusage.Thiswillresultinkeysevictionand/orinabilitytoacceptnewwritecommandsdependingonthemaxmemory-policy."" ) ; } freeMemoryIfNeeded ( ) ; } } config_set_memory_field ( ""repl-backlog-size"" , ll ) { resizeReplicationBacklog ( ll ) ; } config_set_enum_field ( ""loglevel"" , server . verbosity , loglevel_enum ) { } config_set_enum_field ( ""maxmemory-policy"" , server . maxmemory_policy , maxmemory_policy_enum ) { } config_set_enum_field ( ""appendfsync"" , server . aof_fsync , aof_fsync_enum ) { } config_set_else { addReplyErrorFormat ( c , ""UnsupportedCONFIGparameter:%s"" , ( char * ) c -> argv [ 2 ] -> ptr ) ; return ; } addReply ( c , shared . ok ) ; return ; badfmt : addReplyErrorFormat ( c , ""Invalidargument\'%s\'forCONFIGSET\'%s\'"" , ( char * ) o -> ptr , ( char * ) c -> argv [ 2 ] -> ptr ) ; } "," 0 ) { int class = getClientTypeByName ( v j ] ) ; if ( class == - 1 || class == CLIENT_TYPE_MASTER ",antirez@redis/6d9f8e2462fc2c426d48c941edeb78e5df7d2977,CVE-2016-8339,https://github.com/antirez/redis/commit/6d9f8e2462fc2c426d48c941edeb78e5df7d2977,2016-10-28T14:59Z 989,CWE-476,"CWE-476 static int dev_get_valid_name ( struct net * net , struct net_device * dev , const char * name ) { BUG_ON ( ! net ) ; if ( ! dev_valid_name ( name ) ) return - EINVAL ; if ( strchr ( name , '%' ) ) return dev_alloc_name_ns ( net , dev , name ) ; else if ( __dev_get_by_name ( net , name ) ) return - EEXIST ; else if ( dev -> name != name ) strlcpy ( dev -> name , name , IFNAMSIZ ) ; return 0 ; } "," int dev_get_valid_name ( ",torvalds@linux/0ad646c81b2182f7fa67ec0c8c825e0ee165696d,CVE-2018-7191,https://github.com/torvalds/linux/commit/0ad646c81b2182f7fa67ec0c8c825e0ee165696d,2019-05-17T05:29Z 990,CWE-295,"CWE-295 int options_cmdline ( char * arg1 , char * arg2 ) { char * name ; CONF_TYPE type ; # ifdef USE_WIN32 ( void ) arg2 ; # endif if ( ! arg1 ) { name = # ifdef CONFDIR CONFDIR # ifdef USE_WIN32 ""\\\\"" # else ""/"" # endif # endif ""stunnel.conf"" ; type = CONF_FILE ; } else if ( ! strcasecmp ( arg1 , ""-help"" ) ) { parse_global_option ( CMD_PRINT_HELP , NULL , NULL ) ; parse_service_option ( CMD_PRINT_HELP , NULL , NULL , NULL ) ; log_flush ( LOG_MODE_INFO ) ; return 2 ; } else if ( ! strcasecmp ( arg1 , ""-version"" ) ) { parse_global_option ( CMD_PRINT_DEFAULTS , NULL , NULL ) ; parse_service_option ( CMD_PRINT_DEFAULTS , NULL , NULL , NULL ) ; log_flush ( LOG_MODE_INFO ) ; return 2 ; } else if ( ! strcasecmp ( arg1 , ""-sockets"" ) ) { socket_options_print ( ) ; log_flush ( LOG_MODE_INFO ) ; return 2 ; } else if ( ! strcasecmp ( arg1 , ""-options"" ) ) { print_ssl_options ( ) ; log_flush ( LOG_MODE_INFO ) ; return 2 ; } else # ifndef USE_WIN32 if ( ! strcasecmp ( arg1 , ""-fd"" ) ) { if ( ! arg2 ) { s_log ( LOG_ERR , ""Nofiledescriptorspecified"" ) ; print_syntax ( ) ; return 1 ; } name = arg2 ; type = CONF_FD ; } else # endif { name = arg1 ; type = CONF_FILE ; } if ( type == CONF_FILE ) { # ifdef HAVE_REALPATH char * real_path = NULL ; # ifdef MAXPATHLEN real_path = malloc ( MAXPATHLEN ) ; # endif real_path = realpath ( name , real_path ) ; if ( ! real_path ) { s_log ( LOG_ERR , ""Invalidconfigurationfilename\\""%s\\"""" , name ) ; ioerror ( ""realpath"" ) ; return 1 ; } configuration_file = str_dup ( real_path ) ; free ( real_path ) ; # else configuration_file = str_dup ( name ) ; # endif # ifndef USE_WIN32 } else if ( type == CONF_FD ) { configuration_file = str_dup ( name ) ; # endif } return options_parse ( type ) ; } "," NULL , NULL , NULL parse_global_option ( CMD_PRINT_DEFAULTS , NULL ",mtrojnar@stunnel/ebad9ddc4efb2635f37174c9d800d06206f1edf9,CVE-2021-20230,https://github.com/mtrojnar/stunnel/commit/ebad9ddc4efb2635f37174c9d800d06206f1edf9,2021-02-23T17:15Z 991,CWE-20,"CWE-20 int bt_sock_stream_recvmsg ( struct kiocb * iocb , struct socket * sock , struct msghdr * msg , size_t size , int flags ) { struct sock * sk = sock -> sk ; int err = 0 ; size_t target , copied = 0 ; long timeo ; if ( flags & MSG_OOB ) return - EOPNOTSUPP ; msg -> msg_namelen = 0 ; BT_DBG ( ""sk%psize%zu"" , sk , size ) ; lock_sock ( sk ) ; target = sock_rcvlowat ( sk , flags & MSG_WAITALL , size ) ; timeo = sock_rcvtimeo ( sk , flags & MSG_DONTWAIT ) ; do { struct sk_buff * skb ; int chunk ; skb = skb_dequeue ( & sk -> sk_receive_queue ) ; if ( ! skb ) { if ( copied >= target ) break ; err = sock_error ( sk ) ; if ( err ) break ; if ( sk -> sk_shutdown & RCV_SHUTDOWN ) break ; err = - EAGAIN ; if ( ! timeo ) break ; timeo = bt_sock_data_wait ( sk , timeo ) ; if ( signal_pending ( current ) ) { err = sock_intr_errno ( timeo ) ; goto out ; } continue ; } chunk = min_t ( unsigned int , skb -> len , size ) ; if ( skb_copy_datagram_iovec ( skb , 0 , msg -> msg_iov , chunk ) ) { skb_queue_head ( & sk -> sk_receive_queue , skb ) ; if ( ! copied ) copied = - EFAULT ; break ; } copied += chunk ; size -= chunk ; sock_recv_ts_and_drops ( msg , sk , skb ) ; if ( ! ( flags & MSG_PEEK ) ) { int skb_len = skb_headlen ( skb ) ; if ( chunk <= skb_len ) { __skb_pull ( skb , chunk ) ; } else { struct sk_buff * frag ; __skb_pull ( skb , skb_len ) ; chunk -= skb_len ; skb_walk_frags ( skb , frag ) { if ( chunk <= frag -> len ) { skb -> len -= chunk ; skb -> data_len -= chunk ; __skb_pull ( frag , chunk ) ; break ; } else if ( frag -> len ) { chunk -= frag -> len ; skb -> len -= frag -> len ; skb -> data_len -= frag -> len ; __skb_pull ( frag , frag -> len ) ; } } } if ( skb -> len ) { skb_queue_head ( & sk -> sk_receive_queue , skb ) ; break ; } kfree_skb ( skb ) ; } else { skb_queue_head ( & sk -> sk_receive_queue , skb ) ; break ; } } while ( size ) ; out : release_sock ( sk ) ; return copied ? : err ; } "," return - EOPNOTSUPP ; BT_DBG ( ",torvalds@linux/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,CVE-2013-7271,https://github.com/torvalds/linux/commit/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,2014-01-06T16:55Z 992,CWE-125,"CWE-125 PyObject * ast2obj_excepthandler ( void * _o ) { excepthandler_ty o = ( excepthandler_ty ) _o ; PyObject * result = NULL , * value = NULL ; if ( ! o ) { Py_INCREF ( Py_None ) ; return Py_None ; } switch ( o -> kind ) { case ExceptHandler_kind : result = PyType_GenericNew ( ExceptHandler_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . ExceptHandler . type ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_type , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_identifier ( o -> v . ExceptHandler . name ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_name , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . ExceptHandler . body , ast2obj_stmt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_body , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; } value = ast2obj_int ( o -> lineno ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_lineno , value ) < 0 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_int ( o -> col_offset ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_col_offset , value ) < 0 ) goto failed ; Py_DECREF ( value ) ; return result ; failed : Py_XDECREF ( value ) ; Py_XDECREF ( result ) ; return NULL ; } "," o ) { Py_RETURN_NONE ; } switch ",python@typed_ast/156afcb26c198e162504a57caddfe0acd9ed7dce,CVE-2019-19275,https://github.com/python/typed_ast/commit/156afcb26c198e162504a57caddfe0acd9ed7dce,2019-11-26T15:15Z 993,CWE-125,"CWE-125 void process_packet_tail ( struct msg_digest * md ) { struct state * st = md -> st ; enum state_kind from_state = md -> v1_from_state ; const struct state_v1_microcode * smc = md -> smc ; bool new_iv_set = md -> new_iv_set ; bool self_delete = FALSE ; if ( md -> hdr . isa_flags & ISAKMP_FLAGS_v1_ENCRYPTION ) { endpoint_buf b ; dbg ( ""receivedencryptedpacketfrom%s"" , str_endpoint ( & md -> sender , & b ) ) ; if ( st == NULL ) { libreswan_log ( ""discardingencryptedmessageforanunknownISAKMPSA"" ) ; return ; } if ( st -> st_skeyid_e_nss == NULL ) { loglog ( RC_LOG_SERIOUS , ""discardingencryptedmessagebecausewehaven\'tyetnegotiatedkeyingmaterial"" ) ; return ; } md -> encrypted = TRUE ; const struct encrypt_desc * e = st -> st_oakley . ta_encrypt ; if ( pbs_left ( & md -> message_pbs ) % e -> enc_blocksize != 0 ) { loglog ( RC_LOG_SERIOUS , ""malformedmessage:notamultipleofencryptionblocksize"" ) ; return ; } md -> raw_packet = clone_bytes_as_chunk ( md -> packet_pbs . start , pbs_room ( & md -> packet_pbs ) , ""rawpacket"" ) ; if ( ! new_iv_set ) { if ( st -> st_v1_iv . len == 0 ) { init_phase2_iv ( st , & md -> hdr . isa_msgid ) ; } else { restore_new_iv ( st , st -> st_v1_iv ) ; } } passert ( st -> st_v1_new_iv . len >= e -> enc_blocksize ) ; st -> st_v1_new_iv . len = e -> enc_blocksize ; if ( DBGP ( DBG_CRYPT ) ) { DBG_log ( ""decrypting%ubytesusingalgorithm%s"" , ( unsigned ) pbs_left ( & md -> message_pbs ) , st -> st_oakley . ta_encrypt -> common . fqn ) ; DBG_dump_hunk ( ""IVbefore:"" , st -> st_v1_new_iv ) ; } e -> encrypt_ops -> do_crypt ( e , md -> message_pbs . cur , pbs_left ( & md -> message_pbs ) , st -> st_enc_key_nss , st -> st_v1_new_iv . ptr , FALSE ) ; if ( DBGP ( DBG_CRYPT ) ) { DBG_dump_hunk ( ""IVafter:"" , st -> st_v1_new_iv ) ; DBG_log ( ""decryptedpayload(startsatoffset%td):"" , md -> message_pbs . cur - md -> message_pbs . roof ) ; DBG_dump ( NULL , md -> message_pbs . start , md -> message_pbs . roof - md -> message_pbs . start ) ; } } else { if ( smc -> flags & SMF_INPUT_ENCRYPTED ) { loglog ( RC_LOG_SERIOUS , ""packetrejected:shouldhavebeenencrypted"" ) ; SEND_NOTIFICATION ( INVALID_FLAGS ) ; return ; } } { enum next_payload_types_ikev1 np = md -> hdr . isa_np ; lset_t needed = smc -> req_payloads ; const char * excuse = LIN ( SMF_PSK_AUTH | SMF_FIRST_ENCRYPTED_INPUT , smc -> flags ) ? ""probableauthenticationfailure(mismatchofpresharedsecrets?):"" : """" ; while ( np != ISAKMP_NEXT_NONE ) { struct_desc * sd = v1_payload_desc ( np ) ; if ( md -> digest_roof >= elemsof ( md -> digest ) ) { loglog ( RC_LOG_SERIOUS , ""morethan%zupayloadsinmessage;ignored"" , elemsof ( md -> digest ) ) ; if ( ! md -> encrypted ) { SEND_NOTIFICATION ( PAYLOAD_MALFORMED ) ; } return ; } struct payload_digest * const pd = md -> digest + md -> digest_roof ; if ( st != NULL && st -> st_connection != NULL && ( st -> st_connection -> policy & POLICY_AGGRESSIVE ) == LEMPTY ) { switch ( np ) { case ISAKMP_NEXT_NATD_RFC : case ISAKMP_NEXT_NATOA_RFC : if ( ( st -> hidden_variables . st_nat_traversal & NAT_T_WITH_RFC_VALUES ) == LEMPTY ) { DBG ( DBG_NATT , DBG_log ( ""st_nat_traversalwas:%s"" , bitnamesof ( natt_bit_names , st -> hidden_variables . st_nat_traversal ) ) ) ; sd = NULL ; } break ; default : break ; } } if ( sd == NULL ) { switch ( np ) { case ISAKMP_NEXT_ID : sd = ( IS_PHASE1 ( from_state ) || IS_PHASE15 ( from_state ) ) ? & isakmp_identification_desc : & isakmp_ipsec_identification_desc ; break ; case ISAKMP_NEXT_NATD_DRAFTS : np = ISAKMP_NEXT_NATD_RFC ; sd = & isakmp_nat_d_drafts ; break ; case ISAKMP_NEXT_NATOA_DRAFTS : np = ISAKMP_NEXT_NATOA_RFC ; sd = & isakmp_nat_oa_drafts ; break ; case ISAKMP_NEXT_SAK : loglog ( RC_LOG_SERIOUS , ""%smessagewithunsupportedpayloadISAKMP_NEXT_SAK(orISAKMP_NEXT_NATD_BADDRAFTS)ignored"" , excuse ) ; if ( ! in_struct ( & pd -> payload , & isakmp_ignore_desc , & md -> message_pbs , & pd -> pbs ) ) { loglog ( RC_LOG_SERIOUS , ""%smalformedpayloadinpacket"" , excuse ) ; if ( ! md -> encrypted ) { SEND_NOTIFICATION ( PAYLOAD_MALFORMED ) ; } return ; } np = pd -> payload . generic . isag_np ; continue ; default : loglog ( RC_LOG_SERIOUS , ""%smessageignoredbecauseitcontainsanunknownorunexpectedpayloadtype(%s)attheoutermostlevel"" , excuse , enum_show ( & ikev1_payload_names , np ) ) ; if ( ! md -> encrypted ) { SEND_NOTIFICATION ( INVALID_PAYLOAD_TYPE ) ; } return ; } passert ( sd != NULL ) ; } passert ( np < LELEM_ROOF ) ; { lset_t s = LELEM ( np ) ; if ( LDISJOINT ( s , needed | smc -> opt_payloads | LELEM ( ISAKMP_NEXT_VID ) | LELEM ( ISAKMP_NEXT_N ) | LELEM ( ISAKMP_NEXT_D ) | LELEM ( ISAKMP_NEXT_CR ) | LELEM ( ISAKMP_NEXT_CERT ) ) ) { loglog ( RC_LOG_SERIOUS , ""%smessageignoredbecauseitcontainsapayloadtype(%s)unexpectedbystate%s"" , excuse , enum_show ( & ikev1_payload_names , np ) , st -> st_state -> name ) ; if ( ! md -> encrypted ) { SEND_NOTIFICATION ( INVALID_PAYLOAD_TYPE ) ; } return ; } DBG ( DBG_PARSING , DBG_log ( ""gotpayload0x%"" PRIxLSET ""(%s)needed:0x%"" PRIxLSET ""opt:0x%"" PRIxLSET , s , enum_show ( & ikev1_payload_names , np ) , needed , smc -> opt_payloads ) ) ; needed &= ~ s ; } pd -> payload_type = np ; if ( ! in_struct ( & pd -> payload , sd , & md -> message_pbs , & pd -> pbs ) ) { loglog ( RC_LOG_SERIOUS , ""%smalformedpayloadinpacket"" , excuse ) ; if ( ! md -> encrypted ) { SEND_NOTIFICATION ( PAYLOAD_MALFORMED ) ; } return ; } switch ( np ) { case ISAKMP_NEXT_ID : case ISAKMP_NEXT_NATOA_RFC : DBG ( DBG_PARSING , DBG_dump ( ""obj:"" , pd -> pbs . cur , pbs_left ( & pd -> pbs ) ) ) ; break ; default : break ; } { passert ( np < elemsof ( md -> chain ) ) ; struct payload_digest * * p = & md -> chain [ np ] ; while ( * p != NULL ) p = & ( * p ) -> next ; * p = pd ; pd -> next = NULL ; } np = pd -> payload . generic . isag_np ; md -> digest_roof ++ ; excuse = """" ; } DBG ( DBG_PARSING , { if ( pbs_left ( & md -> message_pbs ) != 0 ) DBG_log ( ""removing%dbytesofpadding"" , ( int ) pbs_left ( & md -> message_pbs ) ) ; } ) ; md -> message_pbs . roof = md -> message_pbs . cur ; if ( needed != 0 ) { loglog ( RC_LOG_SERIOUS , ""messagefor%sismissingpayloads%s"" , finite_states [ from_state ] -> name , bitnamesof ( payload_name_ikev1 , needed ) ) ; if ( ! md -> encrypted ) { SEND_NOTIFICATION ( PAYLOAD_MALFORMED ) ; } return ; } } if ( ! check_v1_HASH ( smc -> hash_type , smc -> message , st , md ) ) { return ; } if ( IS_PHASE1 ( from_state ) || IS_PHASE15 ( from_state ) ) { if ( md -> chain [ ISAKMP_NEXT_SA ] != NULL && md -> hdr . isa_np != ISAKMP_NEXT_SA ) { loglog ( RC_LOG_SERIOUS , ""malformedPhase1message:doesnotstartwithanSApayload"" ) ; if ( ! md -> encrypted ) { SEND_NOTIFICATION ( PAYLOAD_MALFORMED ) ; } return ; } } else if ( IS_QUICK ( from_state ) ) { if ( md -> hdr . isa_np != ISAKMP_NEXT_HASH ) { loglog ( RC_LOG_SERIOUS , ""malformedQuickModemessage:doesnotstartwithaHASHpayload"" ) ; if ( ! md -> encrypted ) { SEND_NOTIFICATION ( PAYLOAD_MALFORMED ) ; } return ; } { struct payload_digest * p ; int i ; p = md -> chain [ ISAKMP_NEXT_SA ] ; i = 1 ; while ( p != NULL ) { if ( p != & md -> digest [ i ] ) { loglog ( RC_LOG_SERIOUS , ""malformedQuickModemessage:SApayloadisinwrongposition"" ) ; if ( ! md -> encrypted ) { SEND_NOTIFICATION ( PAYLOAD_MALFORMED ) ; } return ; } p = p -> next ; i ++ ; } } { struct payload_digest * id = md -> chain [ ISAKMP_NEXT_ID ] ; if ( id != NULL ) { if ( id -> next == NULL || id -> next -> next != NULL ) { loglog ( RC_LOG_SERIOUS , ""malformedQuickModemessage:ifanyIDpayloadispresent,theremustbeexactlytwo"" ) ; SEND_NOTIFICATION ( PAYLOAD_MALFORMED ) ; return ; } if ( id + 1 != id -> next ) { loglog ( RC_LOG_SERIOUS , ""malformedQuickModemessage:theIDpayloadsarenotadjacent"" ) ; SEND_NOTIFICATION ( PAYLOAD_MALFORMED ) ; return ; } } } } { struct payload_digest * p = md -> chain [ ISAKMP_NEXT_N ] ; while ( p != NULL ) { switch ( p -> payload . notification . isan_type ) { case R_U_THERE : case R_U_THERE_ACK : case ISAKMP_N_CISCO_LOAD_BALANCE : case PAYLOAD_MALFORMED : case INVALID_MESSAGE_ID : case IPSEC_RESPONDER_LIFETIME : if ( md -> hdr . isa_xchg == ISAKMP_XCHG_INFO ) { break ; } default : if ( st == NULL ) { DBG ( DBG_CONTROL , DBG_log ( ""ignoringinformationalpayload%s,nocorrespondingstate"" , enum_show ( & ikev1_notify_names , p -> payload . notification . isan_type ) ) ) ; } else { loglog ( RC_LOG_SERIOUS , ""ignoringinformationalpayload%s,msgid=%08"" PRIx32 "",length=%d"" , enum_show ( & ikev1_notify_names , p -> payload . notification . isan_type ) , st -> st_v1_msgid . id , p -> payload . notification . isan_length ) ; DBG_dump_pbs ( & p -> pbs ) ; } } if ( DBGP ( DBG_BASE ) ) { DBG_dump ( ""info:"" , p -> pbs . cur , pbs_left ( & p -> pbs ) ) ; } p = p -> next ; } p = md -> chain [ ISAKMP_NEXT_D ] ; while ( p != NULL ) { self_delete |= accept_delete ( md , p ) ; if ( DBGP ( DBG_BASE ) ) { DBG_dump ( ""del:"" , p -> pbs . cur , pbs_left ( & p -> pbs ) ) ; } if ( md -> st != st ) { pexpect ( md -> st == NULL ) ; dbg ( ""zappingSTasaccept_delete()zappedMD.ST"" ) ; st = md -> st ; } p = p -> next ; } p = md -> chain [ ISAKMP_NEXT_VID ] ; while ( p != NULL ) { handle_vendorid ( md , ( char * ) p -> pbs . cur , pbs_left ( & p -> pbs ) , FALSE ) ; p = p -> next ; } } if ( self_delete ) { accept_self_delete ( md ) ; st = md -> st ; } pexpect ( st == md -> st ) ; statetime_t start = statetime_start ( md -> st ) ; complete_v1_state_transition ( md , smc -> processor ( st , md ) ) ; statetime_stop ( & start , ""%s()"" , __func__ ) ; } "," np ) , finite_states [ smc -> state ] -> name ) ",libreswan@libreswan/471a3e41a449d7c753bc4edbba4239501bb62ba8,CVE-2020-1763,https://github.com/libreswan/libreswan/commit/471a3e41a449d7c753bc4edbba4239501bb62ba8,2020-05-12T14:15Z 994,CWE-787,"CWE-787 void impeg2d_dec_hdr ( void * pv_dec , impeg2d_video_decode_ip_t * ps_ip , impeg2d_video_decode_op_t * ps_op ) { UWORD32 u4_bits_read ; dec_state_t * ps_dec ; UWORD32 u4_size = ps_ip -> s_ivd_video_decode_ip_t . u4_num_Bytes ; ps_dec = ( dec_state_t * ) pv_dec ; ps_op -> s_ivd_video_decode_op_t . u4_error_code = 0 ; if ( u4_size > MAX_BITSTREAM_BUFFER_SIZE ) { u4_size = MAX_BITSTREAM_BUFFER_SIZE ; } memcpy ( ps_dec -> pu1_input_buffer , ps_ip -> s_ivd_video_decode_ip_t . pv_stream_buffer , u4_size ) ; impeg2d_bit_stream_init ( & ( ps_dec -> s_bit_stream ) , ps_dec -> pu1_input_buffer , u4_size ) ; { { IMPEG2D_ERROR_CODES_T e_error ; e_error = impeg2d_process_video_header ( ps_dec ) ; if ( ( IMPEG2D_ERROR_CODES_T ) IVD_ERROR_NONE != e_error ) { ps_op -> s_ivd_video_decode_op_t . u4_error_code = e_error ; u4_bits_read = impeg2d_bit_stream_num_bits_read ( & ps_dec -> s_bit_stream ) ; ps_op -> s_ivd_video_decode_op_t . u4_num_bytes_consumed = u4_bits_read >> 3 ; if ( ps_op -> s_ivd_video_decode_op_t . u4_num_bytes_consumed > ps_ip -> s_ivd_video_decode_ip_t . u4_num_Bytes ) { ps_op -> s_ivd_video_decode_op_t . u4_num_bytes_consumed = ps_ip -> s_ivd_video_decode_ip_t . u4_num_Bytes ; } if ( ps_op -> s_ivd_video_decode_op_t . u4_error_code == 0 ) ps_op -> s_ivd_video_decode_op_t . u4_error_code = e_error ; if ( IMPEG2D_UNSUPPORTED_DIMENSIONS == e_error ) { ps_op -> s_ivd_video_decode_op_t . u4_num_bytes_consumed = 0 ; ps_dec -> u2_header_done = 0 ; ps_op -> s_ivd_video_decode_op_t . u4_pic_ht = ps_dec -> u2_reinit_max_height ; ps_op -> s_ivd_video_decode_op_t . u4_pic_wd = ps_dec -> u2_reinit_max_width ; } impeg2d_next_code ( ps_dec , SEQUENCE_HEADER_CODE ) ; return ; } } ps_op -> s_ivd_video_decode_op_t . u4_pic_ht = ps_dec -> u2_vertical_size ; ps_op -> s_ivd_video_decode_op_t . u4_pic_wd = ps_dec -> u2_horizontal_size ; ps_op -> s_ivd_video_decode_op_t . e_pic_type = IV_NA_FRAME ; ps_op -> s_ivd_video_decode_op_t . u4_error_code = IV_SUCCESS ; u4_bits_read = impeg2d_bit_stream_num_bits_read ( & ps_dec -> s_bit_stream ) ; ps_op -> s_ivd_video_decode_op_t . u4_num_bytes_consumed = u4_bits_read >> 3 ; if ( ps_op -> s_ivd_video_decode_op_t . u4_num_bytes_consumed > ps_ip -> s_ivd_video_decode_ip_t . u4_num_Bytes ) { ps_op -> s_ivd_video_decode_op_t . u4_num_bytes_consumed = ps_ip -> s_ivd_video_decode_ip_t . u4_num_Bytes ; } ps_op -> s_ivd_video_decode_op_t . u4_frame_decoded_flag = 0 ; ps_dec -> u2_header_done = 1 ; } } "," = 0 ; if ( 0 == ps_dec -> u4_frm_buf_stride ) { ps_dec -> u4_frm_buf_stride = ps_dec -> u2_horizontal_size ; } ",external@libmpeg2/bef16671c891e16f25a7b174bc528eea109357be,CVE-2018-9497,https://android.googlesource.com/platform/external/libmpeg2/+/bef16671c891e16f25a7b174bc528eea109357be,2018-10-02T19:29Z 995,CWE-190,"CWE-190 bool layer_resize ( int layer , int x_size , int y_size ) { int old_height ; int old_width ; struct map_tile * tile ; int tile_width ; int tile_height ; struct map_tile * tilemap ; struct map_trigger * trigger ; struct map_zone * zone ; int x , y , i ; old_width = s_map -> layers [ layer ] . width ; old_height = s_map -> layers [ layer ] . height ; if ( ! ( tilemap = malloc ( x_size * y_size * sizeof ( struct map_tile ) ) ) ) return false ; for ( x = 0 ; x < x_size ; ++ x ) { for ( y = 0 ; y < y_size ; ++ y ) { if ( x < old_width && y < old_height ) { tilemap [ x + y * x_size ] = s_map -> layers [ layer ] . tilemap [ x + y * old_width ] ; } else { tile = & tilemap [ x + y * x_size ] ; tile -> frames_left = tileset_get_delay ( s_map -> tileset , 0 ) ; tile -> tile_index = 0 ; } } } free ( s_map -> layers [ layer ] . tilemap ) ; s_map -> layers [ layer ] . tilemap = tilemap ; s_map -> layers [ layer ] . width = x_size ; s_map -> layers [ layer ] . height = y_size ; tileset_get_size ( s_map -> tileset , & tile_width , & tile_height ) ; s_map -> width = 0 ; s_map -> height = 0 ; for ( i = 0 ; i < s_map -> num_layers ; ++ i ) { if ( ! s_map -> layers [ i ] . is_parallax ) { s_map -> width = fmax ( s_map -> width , s_map -> layers [ i ] . width * tile_width ) ; s_map -> height = fmax ( s_map -> height , s_map -> layers [ i ] . height * tile_height ) ; } } for ( i = ( int ) vector_len ( s_map -> zones ) - 1 ; i >= 0 ; -- i ) { zone = vector_get ( s_map -> zones , i ) ; if ( zone -> bounds . x1 >= s_map -> width || zone -> bounds . y1 >= s_map -> height ) vector_remove ( s_map -> zones , i ) ; else { if ( zone -> bounds . x2 > s_map -> width ) zone -> bounds . x2 = s_map -> width ; if ( zone -> bounds . y2 > s_map -> height ) zone -> bounds . y2 = s_map -> height ; } } for ( i = ( int ) vector_len ( s_map -> triggers ) - 1 ; i >= 0 ; -- i ) { trigger = vector_get ( s_map -> triggers , i ) ; if ( trigger -> x >= s_map -> width || trigger -> y >= s_map -> height ) vector_remove ( s_map -> triggers , i ) ; } return true ; } "," * zone ; size_t tilemap_size ; . height ; tilemap_size = x_size * y_size struct map_tile ) ; if ( x_size == 0 || tilemap_size / x_size / sizeof ( struct map_tile ) != y_size || ! ( tilemap = malloc ( tilemap_size ",fatcerberus@minisphere/252c1ca184cb38e1acb917aa0e451c5f08519996,CVE-2018-1000524,https://github.com/fatcerberus/minisphere/commit/252c1ca184cb38e1acb917aa0e451c5f08519996,2018-06-26T16:29Z 996,CWE-125,"CWE-125 static void ip_printroute ( netdissect_options * ndo , register const u_char * cp , u_int length ) { register u_int ptr ; register u_int len ; if ( length < 3 ) { ND_PRINT ( ( ndo , ""[badlength%u]"" , length ) ) ; return ; } if ( ( length + 1 ) & 3 ) ND_PRINT ( ( ndo , ""[badlength%u]"" , length ) ) ; ptr = cp [ 2 ] - 1 ; if ( ptr < 3 || ( ( ptr + 1 ) & 3 ) || ptr > length + 1 ) ND_PRINT ( ( ndo , ""[badptr%u]"" , cp [ 2 ] ) ) ; for ( len = 3 ; len < length ; len += 4 ) { ND_PRINT ( ( ndo , ""%s"" , ipaddr_string ( ndo , & cp [ len ] ) ) ) ; if ( ptr > len ) ND_PRINT ( ( ndo , "","" ) ) ; } } "," static int ip_printroute ( netdissect_options ) ; return ( 0 ) , length ) ) ; ND_TCHECK ( cp [ 2 ] 4 ) { ND_TCHECK2 ( cp [ len ] , 4 ) ; ) ; } return ( 0 ) ; trunc : return ( - 1 ) ; ",the-tcpdump-group@tcpdump/eee0b04bcfdae319c242b0b8fc3d07029ee65b8c,CVE-2017-13022,https://github.com/the-tcpdump-group/tcpdump/commit/eee0b04bcfdae319c242b0b8fc3d07029ee65b8c,2017-09-14T06:29Z 997,CWE-119,"CWE-119 static char * print_string ( cJSON * item ) { return print_string_ptr ( item -> valuestring ) ; } "," cJSON * item , printbuffer * p item -> valuestring , p ",esnet@iperf/91f2fa59e8ed80dfbf400add0164ee0e508e412a,CVE-2016-4303,https://github.com/esnet/iperf/commit/91f2fa59e8ed80dfbf400add0164ee0e508e412a,2016-09-26T14:59Z 998,CWE-119,"CWE-119 vpx_codec_err_t vpx_codec_encode ( vpx_codec_ctx_t * ctx , const vpx_image_t * img , vpx_codec_pts_t pts , unsigned long duration , vpx_enc_frame_flags_t flags , unsigned long deadline ) { vpx_codec_err_t res = VPX_CODEC_OK ; if ( ! ctx || ( img && ! duration ) ) res = VPX_CODEC_INVALID_PARAM ; else if ( ! ctx -> iface || ! ctx -> priv ) res = VPX_CODEC_ERROR ; else if ( ! ( ctx -> iface -> caps & VPX_CODEC_CAP_ENCODER ) ) res = VPX_CODEC_INCAPABLE ; else { unsigned int num_enc = ctx -> priv -> enc . total_encoders ; FLOATING_POINT_INIT ( ) ; if ( num_enc == 1 ) res = ctx -> iface -> enc . encode ( ctx -> priv -> alg_priv , img , pts , duration , flags , deadline ) ; else { int i ; ctx += num_enc - 1 ; if ( img ) img += num_enc - 1 ; for ( i = num_enc - 1 ; i >= 0 ; i -- ) { if ( ( res = ctx -> iface -> enc . encode ( ctx -> priv -> alg_priv , img , pts , duration , flags , deadline ) ) ) break ; ctx -- ; if ( img ) img -- ; } ctx ++ ; } FLOATING_POINT_RESTORE ( ) ; } return SAVE_STATUS ( ctx , res ) ; } "," . encode ( get_alg_priv ( ctx ) , img , . encode ( get_alg_priv ( ctx ) , img , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 999,CWE-119,"CWE-119 int main ( int argc , char * * argv ) { char * filein , * str , * tempfile , * prestring , * outprotos , * protostr ; const char * spacestr = """" ; char buf [ L_BUF_SIZE ] ; l_uint8 * allheaders ; l_int32 i , maxindex , in_line , nflags , protos_added , firstfile , len , ret ; size_t nbytes ; L_BYTEA * ba , * ba2 ; SARRAY * sa , * safirst ; static char mainName [ ] = ""xtractprotos"" ; if ( argc == 1 ) { fprintf ( stderr , ""xtractprotos[-prestring=][-protos=]"" ""[listofCfiles]\\n"" ""wheretheprestringisprependedtoeachprototype,and\\n"" ""protoscanbeeither\'inline\'orthenameofanoutput"" ""prototypefile\\n"" ) ; return 1 ; } prestring = outprotos = NULL ; in_line = FALSE ; nflags = 0 ; maxindex = L_MIN ( 3 , argc ) ; for ( i = 1 ; i < maxindex ; i ++ ) { if ( argv [ i ] [ 0 ] == '-' ) { if ( ! strncmp ( argv [ i ] , ""-prestring"" , 10 ) ) { nflags ++ ; ret = sscanf ( argv [ i ] + 1 , ""prestring=%s"" , buf ) ; if ( ret != 1 ) { fprintf ( stderr , ""parsefailureforprestring\\n"" ) ; return 1 ; } if ( ( len = strlen ( buf ) ) > L_BUF_SIZE - 3 ) { L_WARNING ( ""prestringtoolarge;omitting!\\n"" , mainName ) ; } else { buf [ len ] = '' ; buf [ len + 1 ] = '\\0' ; prestring = stringNew ( buf ) ; } } else if ( ! strncmp ( argv [ i ] , ""-protos"" , 7 ) ) { nflags ++ ; ret = sscanf ( argv [ i ] + 1 , ""protos=%s"" , buf ) ; if ( ret != 1 ) { fprintf ( stderr , ""parsefailureforprotos\\n"" ) ; return 1 ; } outprotos = stringNew ( buf ) ; if ( ! strncmp ( outprotos , ""inline"" , 7 ) ) in_line = TRUE ; } } } if ( argc - nflags < 2 ) { fprintf ( stderr , ""nofilesspecified!\\n"" ) ; return 1 ; } ba = l_byteaCreate ( 500 ) ; sa = sarrayCreate ( 0 ) ; sarrayAddString ( sa , ( char * ) ""/*"" , L_COPY ) ; snprintf ( buf , L_BUF_SIZE , ""*Theseprototypeswereautogen\'dbyxtractprotos,v.%s"" , version ) ; sarrayAddString ( sa , buf , L_COPY ) ; sarrayAddString ( sa , ( char * ) ""*/"" , L_COPY ) ; sarrayAddString ( sa , ( char * ) ""#ifdef__cplusplus"" , L_COPY ) ; sarrayAddString ( sa , ( char * ) ""extern\\""C\\""{"" , L_COPY ) ; sarrayAddString ( sa , ( char * ) ""#endif/*__cplusplus*/\\n"" , L_COPY ) ; str = sarrayToString ( sa , 1 ) ; l_byteaAppendString ( ba , str ) ; lept_free ( str ) ; sarrayDestroy ( & sa ) ; firstfile = 1 + nflags ; protos_added = FALSE ; if ( ( tempfile = l_makeTempFilename ( ) ) == NULL ) { fprintf ( stderr , ""failuretomakeawriteabletempfile\\n"" ) ; return 1 ; } for ( i = firstfile ; i < argc ; i ++ ) { filein = argv [ i ] ; len = strlen ( filein ) ; if ( filein [ len - 1 ] == 'h' ) continue ; snprintf ( buf , L_BUF_SIZE , ""cpp-ansi-DNO_PROTOS%s%s"" , filein , tempfile ) ; ret = system ( buf ) ; if ( ret ) { fprintf ( stderr , ""cppfailurefor%s;continuing\\n"" , filein ) ; continue ; } if ( ( str = parseForProtos ( tempfile , prestring ) ) == NULL ) { fprintf ( stderr , ""parsefailurefor%s;continuing\\n"" , filein ) ; continue ; } if ( strlen ( str ) > 1 ) { l_byteaAppendString ( ba , str ) ; protos_added = TRUE ; } lept_free ( str ) ; } lept_rmfile ( tempfile ) ; lept_free ( tempfile ) ; sa = sarrayCreate ( 0 ) ; sarrayAddString ( sa , ( char * ) ""\\n#ifdef__cplusplus"" , L_COPY ) ; sarrayAddString ( sa , ( char * ) ""}"" , L_COPY ) ; sarrayAddString ( sa , ( char * ) ""#endif/*__cplusplus*/"" , L_COPY ) ; str = sarrayToString ( sa , 1 ) ; l_byteaAppendString ( ba , str ) ; lept_free ( str ) ; sarrayDestroy ( & sa ) ; protostr = ( char * ) l_byteaCopyData ( ba , & nbytes ) ; l_byteaDestroy ( & ba ) ; if ( ! outprotos ) { fprintf ( stderr , ""%s\\n"" , protostr ) ; lept_free ( protostr ) ; return 0 ; } if ( ! protos_added ) { fprintf ( stderr , ""Noprotosfound\\n"" ) ; lept_free ( protostr ) ; return 1 ; } ba = l_byteaInitFromFile ( ""allheaders_top.txt"" ) ; if ( ! in_line ) { snprintf ( buf , sizeof ( buf ) , ""#include\\""%s\\""\\n"" , outprotos ) ; l_byteaAppendString ( ba , buf ) ; l_binaryWrite ( outprotos , ""w"" , protostr , nbytes ) ; } else { l_byteaAppendString ( ba , protostr ) ; } ba2 = l_byteaInitFromFile ( ""allheaders_bot.txt"" ) ; l_byteaJoin ( ba , & ba2 ) ; l_byteaWrite ( ""allheaders.h"" , ba , 0 , 0 ) ; l_byteaDestroy ( & ba ) ; lept_free ( protostr ) ; return 0 ; } "," char buf [ L_BUFSIZE ] ; l_uint8 + 1 , ""prestring=%490s"" , buf ) ) ) > L_BUFSIZE - 3 ) + 1 , ""protos=%490s"" , buf ) ( buf , L_BUFSIZE , ""*Theseprototypeswereautogen\'dbyxtractprotos,v.%s"" , ( buf , L_BUFSIZE , ""cpp-ansi-DNO_PROTOS%s%s"" , ",DanBloomberg@leptonica/ee301cb2029db8a6289c5295daa42bba7715e99a,CVE-2018-7186,https://github.com/DanBloomberg/leptonica/commit/ee301cb2029db8a6289c5295daa42bba7715e99a,2018-02-16T16:29Z 1000,CWE-20,"CWE-20 static unsigned char * read_chunk ( struct mschm_decompressor_p * self , struct mschmd_header * chm , struct mspack_file * fh , unsigned int chunk_num ) { struct mspack_system * sys = self -> system ; unsigned char * buf ; if ( chunk_num > chm -> num_chunks ) return NULL ; if ( ! chm -> chunk_cache ) { size_t size = sizeof ( unsigned char * ) * chm -> num_chunks ; if ( ! ( chm -> chunk_cache = ( unsigned char * * ) sys -> alloc ( sys , size ) ) ) { self -> error = MSPACK_ERR_NOMEMORY ; return NULL ; } memset ( chm -> chunk_cache , 0 , size ) ; } if ( chm -> chunk_cache [ chunk_num ] ) return chm -> chunk_cache [ chunk_num ] ; if ( ! ( buf = ( unsigned char * ) sys -> alloc ( sys , chm -> chunk_size ) ) ) { self -> error = MSPACK_ERR_NOMEMORY ; return NULL ; } if ( sys -> seek ( fh , ( off_t ) ( chm -> dir_offset + ( chunk_num * chm -> chunk_size ) ) , MSPACK_SYS_SEEK_START ) ) { self -> error = MSPACK_ERR_SEEK ; sys -> free ( buf ) ; return NULL ; } if ( sys -> read ( fh , buf , ( int ) chm -> chunk_size ) != ( int ) chm -> chunk_size ) { self -> error = MSPACK_ERR_READ ; sys -> free ( buf ) ; return NULL ; } if ( ! ( ( buf [ 0 ] == 0x50 ) && ( buf [ 1 ] == 0x4D ) && ( buf [ 2 ] == 0x47 ) && ( ( buf [ 3 ] == 0x4C ) || ( buf [ 3 ] == 0x49 ) ) ) ) { self -> error = MSPACK_ERR_SEEK ; sys -> free ( buf ) ; return NULL ; } return chm -> chunk_cache [ chunk_num ] = buf ; } "," if ( chunk_num >= chm -> num_chunks ",kyz@libmspack/72e70a921f0f07fee748aec2274b30784e1d312a,CVE-2018-14680,https://github.com/kyz/libmspack/commit/72e70a921f0f07fee748aec2274b30784e1d312a,2018-07-28T23:29Z 1001,CWE-264,"CWE-264 static int validate_group ( struct perf_event * event ) { struct perf_event * sibling , * leader = event -> group_leader ; struct pmu_hw_events fake_pmu ; DECLARE_BITMAP ( fake_used_mask , ARMPMU_MAX_HWEVENTS ) ; memset ( fake_used_mask , 0 , sizeof ( fake_used_mask ) ) ; fake_pmu . used_mask = fake_used_mask ; if ( ! validate_event ( & fake_pmu , leader ) ) return - EINVAL ; list_for_each_entry ( sibling , & leader -> sibling_list , group_entry ) { if ( ! validate_event ( & fake_pmu , sibling ) ) return - EINVAL ; } if ( ! validate_event ( & fake_pmu , event ) ) return - EINVAL ; return 0 ; } "," ! validate_event ( event -> pmu , ! validate_event ( event -> pmu , ! validate_event ( event -> pmu , ",torvalds@linux/8fff105e13041e49b82f92eef034f363a6b1c071,CVE-2015-8955,https://github.com/torvalds/linux/commit/8fff105e13041e49b82f92eef034f363a6b1c071,2016-10-10T10:59Z 1002,CWE-000,"CWE-000 static void do_winop ( void ) { int arg1 = term . csi_argv [ 1 ] , arg2 = term . csi_argv [ 2 ] ; if ( * cfg . suppress_win && contains ( cfg . suppress_win , term . csi_argv [ 0 ] ) ) return ; switch ( term . csi_argv [ 0 ] ) { when 1 : win_set_iconic ( false ) ; when 2 : win_set_iconic ( true ) ; when 3 : win_set_pos ( arg1 , arg2 ) ; when 4 : win_set_pixels ( arg1 , arg2 ) ; when 5 : if ( term . csi_argc != 1 ) return ; win_set_zorder ( true ) ; when 6 : if ( term . csi_argc != 1 ) return ; win_set_zorder ( false ) ; when 7 : win_invalidate_all ( false ) ; when 8 : { int def1 = term . csi_argv_defined [ 1 ] , def2 = term . csi_argv_defined [ 2 ] ; int rows , cols ; win_get_screen_chars ( & rows , & cols ) ; win_set_chars ( arg1 ? : def1 ? rows : term . rows , arg2 ? : def2 ? cols : term . cols ) ; } when 9 : { if ( term . csi_argc != 2 ) return ; int rows0 = term . rows0 , cols0 = term . cols0 ; if ( arg1 == 2 ) { win_set_geom ( 0 , - 1 , 0 , - 1 ) ; term . rows0 = rows0 ; term . cols0 = cols0 ; } else if ( arg1 == 3 ) { win_set_geom ( - 1 , 0 , - 1 , 0 ) ; term . rows0 = rows0 ; term . cols0 = cols0 ; } else if ( arg1 == 1 ) { win_maximise ( 1 ) ; term . rows0 = rows0 ; term . cols0 = cols0 ; } else if ( arg1 == 0 ) { win_maximise ( 0 ) ; win_set_chars ( rows0 , cols0 ) ; } } when 10 : if ( term . csi_argc != 2 ) return ; if ( arg1 == 2 ) win_maximise ( - 2 ) ; else if ( arg1 == 1 || arg1 == 0 ) win_maximise ( arg1 ? 2 : 0 ) ; when 11 : child_write ( win_is_iconic ( ) ? ""\\e[2t"" : ""\\e[1t"" , 4 ) ; when 13 : { int x , y ; win_get_scrpos ( & x , & y , arg1 == 2 ) ; child_printf ( ""\\e[3;%u;%ut"" , ( ushort ) x , ( ushort ) y ) ; } when 14 : { int height , width ; win_get_pixels ( & height , & width , arg1 == 2 ) ; child_printf ( ""\\e[4;%d;%dt"" , height , width ) ; } when 15 : { int w , h ; search_monitors ( & w , & h , 0 , false , 0 ) ; child_printf ( ""\\e[5;%d;%dt"" , h , w ) ; } when 16 : child_printf ( ""\\e[6;%d;%dt"" , cell_height , cell_width ) ; when 18 : child_printf ( ""\\e[8;%d;%dt"" , term . rows , term . cols ) ; when 19 : { # ifdef size_of_monitor_only # warning not what xterm reports int rows , cols ; win_get_screen_chars ( & rows , & cols ) ; child_printf ( ""\\e[9;%d;%dt"" , rows , cols ) ; # else int w , h ; search_monitors ( & w , & h , 0 , false , 0 ) ; child_printf ( ""\\e[9;%d;%dt"" , h / cell_height , w / cell_width ) ; # endif } when 22 : if ( arg1 == 0 || arg1 == 2 ) win_save_title ( ) ; when 23 : if ( arg1 == 0 || arg1 == 2 ) win_restore_title ( ) ; } } "," ) ; } usleep ( 1000 ) ; 2 : 0 ) ; usleep ( 1000 ",mintty@mintty/bd52109993440b6996760aaccb66e68e782762b9,CVE-2021-28848,https://github.com/mintty/mintty/commit/bd52109993440b6996760aaccb66e68e782762b9,2021-06-03T12:15Z 1003,CWE-617,"CWE-617 int ff_mpeg4_decode_picture_header ( Mpeg4DecContext * ctx , GetBitContext * gb ) { MpegEncContext * s = & ctx -> m ; unsigned startcode , v ; int ret ; int vol = 0 ; align_get_bits ( gb ) ; if ( ! s -> studio_profile && s -> avctx -> bits_per_raw_sample != 8 ) s -> avctx -> bits_per_raw_sample = 0 ; if ( s -> codec_tag == AV_RL32 ( ""WV1F"" ) && show_bits ( gb , 24 ) == 0x575630 ) { skip_bits ( gb , 24 ) ; if ( get_bits ( gb , 8 ) == 0xF0 ) goto end ; } startcode = 0xff ; for ( ; ; ) { if ( get_bits_count ( gb ) >= gb -> size_in_bits ) { if ( gb -> size_in_bits == 8 && ( ctx -> divx_version >= 0 || ctx -> xvid_build >= 0 ) || s -> codec_tag == AV_RL32 ( ""QMP4"" ) ) { av_log ( s -> avctx , AV_LOG_VERBOSE , ""frameskip%d\\n"" , gb -> size_in_bits ) ; return FRAME_SKIPPED ; } else return AVERROR_INVALIDDATA ; } v = get_bits ( gb , 8 ) ; startcode = ( ( startcode << 8 ) | v ) & 0xffffffff ; if ( ( startcode & 0xFFFFFF00 ) != 0x100 ) continue ; if ( s -> avctx -> debug & FF_DEBUG_STARTCODE ) { av_log ( s -> avctx , AV_LOG_DEBUG , ""startcode:%3X"" , startcode ) ; if ( startcode <= 0x11F ) av_log ( s -> avctx , AV_LOG_DEBUG , ""VideoObjectStart"" ) ; else if ( startcode <= 0x12F ) av_log ( s -> avctx , AV_LOG_DEBUG , ""VideoObjectLayerStart"" ) ; else if ( startcode <= 0x13F ) av_log ( s -> avctx , AV_LOG_DEBUG , ""Reserved"" ) ; else if ( startcode <= 0x15F ) av_log ( s -> avctx , AV_LOG_DEBUG , ""FGSbpstart"" ) ; else if ( startcode <= 0x1AF ) av_log ( s -> avctx , AV_LOG_DEBUG , ""Reserved"" ) ; else if ( startcode == 0x1B0 ) av_log ( s -> avctx , AV_LOG_DEBUG , ""VisualObjectSeqStart"" ) ; else if ( startcode == 0x1B1 ) av_log ( s -> avctx , AV_LOG_DEBUG , ""VisualObjectSeqEnd"" ) ; else if ( startcode == 0x1B2 ) av_log ( s -> avctx , AV_LOG_DEBUG , ""UserData"" ) ; else if ( startcode == 0x1B3 ) av_log ( s -> avctx , AV_LOG_DEBUG , ""GroupofVOPstart"" ) ; else if ( startcode == 0x1B4 ) av_log ( s -> avctx , AV_LOG_DEBUG , ""VideoSessionError"" ) ; else if ( startcode == 0x1B5 ) av_log ( s -> avctx , AV_LOG_DEBUG , ""VisualObjectStart"" ) ; else if ( startcode == 0x1B6 ) av_log ( s -> avctx , AV_LOG_DEBUG , ""VideoObjectPlanestart"" ) ; else if ( startcode == 0x1B7 ) av_log ( s -> avctx , AV_LOG_DEBUG , ""slicestart"" ) ; else if ( startcode == 0x1B8 ) av_log ( s -> avctx , AV_LOG_DEBUG , ""extensionstart"" ) ; else if ( startcode == 0x1B9 ) av_log ( s -> avctx , AV_LOG_DEBUG , ""fgsstart"" ) ; else if ( startcode == 0x1BA ) av_log ( s -> avctx , AV_LOG_DEBUG , ""FBAObjectstart"" ) ; else if ( startcode == 0x1BB ) av_log ( s -> avctx , AV_LOG_DEBUG , ""FBAObjectPlanestart"" ) ; else if ( startcode == 0x1BC ) av_log ( s -> avctx , AV_LOG_DEBUG , ""MeshObjectstart"" ) ; else if ( startcode == 0x1BD ) av_log ( s -> avctx , AV_LOG_DEBUG , ""MeshObjectPlanestart"" ) ; else if ( startcode == 0x1BE ) av_log ( s -> avctx , AV_LOG_DEBUG , ""StillTextureObjectstart"" ) ; else if ( startcode == 0x1BF ) av_log ( s -> avctx , AV_LOG_DEBUG , ""TextureSpatialLayerstart"" ) ; else if ( startcode == 0x1C0 ) av_log ( s -> avctx , AV_LOG_DEBUG , ""TextureSNRLayerstart"" ) ; else if ( startcode == 0x1C1 ) av_log ( s -> avctx , AV_LOG_DEBUG , ""TextureTilestart"" ) ; else if ( startcode == 0x1C2 ) av_log ( s -> avctx , AV_LOG_DEBUG , ""TextureShapeLayerstart"" ) ; else if ( startcode == 0x1C3 ) av_log ( s -> avctx , AV_LOG_DEBUG , ""stuffingstart"" ) ; else if ( startcode <= 0x1C5 ) av_log ( s -> avctx , AV_LOG_DEBUG , ""reserved"" ) ; else if ( startcode <= 0x1FF ) av_log ( s -> avctx , AV_LOG_DEBUG , ""Systemstart"" ) ; av_log ( s -> avctx , AV_LOG_DEBUG , ""at%d\\n"" , get_bits_count ( gb ) ) ; } if ( startcode >= 0x120 && startcode <= 0x12F ) { if ( vol ) { av_log ( s -> avctx , AV_LOG_WARNING , ""IgnoringmultipleVOLheaders\\n"" ) ; continue ; } vol ++ ; if ( ( ret = decode_vol_header ( ctx , gb ) ) < 0 ) return ret ; } else if ( startcode == USER_DATA_STARTCODE ) { decode_user_data ( ctx , gb ) ; } else if ( startcode == GOP_STARTCODE ) { mpeg4_decode_gop_header ( s , gb ) ; } else if ( startcode == VOS_STARTCODE ) { int profile , level ; mpeg4_decode_profile_level ( s , gb , & profile , & level ) ; if ( profile == FF_PROFILE_MPEG4_SIMPLE_STUDIO && ( level > 0 && level < 9 ) ) { s -> studio_profile = 1 ; next_start_code_studio ( gb ) ; extension_and_user_data ( s , gb , 0 ) ; } else if ( s -> studio_profile ) { avpriv_request_sample ( s -> avctx , ""Mixesstudioandnonstudioprofile\\n"" ) ; return AVERROR_PATCHWELCOME ; } s -> avctx -> profile = profile ; s -> avctx -> level = level ; } else if ( startcode == VISUAL_OBJ_STARTCODE ) { if ( s -> studio_profile ) { if ( ( ret = decode_studiovisualobject ( ctx , gb ) ) < 0 ) return ret ; } else mpeg4_decode_visual_object ( s , gb ) ; } else if ( startcode == VOP_STARTCODE ) { break ; } align_get_bits ( gb ) ; startcode = 0xff ; } end : if ( s -> avctx -> flags & AV_CODEC_FLAG_LOW_DELAY ) s -> low_delay = 1 ; s -> avctx -> has_b_frames = ! s -> low_delay ; if ( s -> studio_profile ) { av_assert0 ( s -> avctx -> profile == FF_PROFILE_MPEG4_SIMPLE_STUDIO ) ; if ( ! s -> avctx -> bits_per_raw_sample ) { av_log ( s -> avctx , AV_LOG_ERROR , ""MissingVOLheader\\n"" ) ; return AVERROR_INVALIDDATA ; } return decode_studio_vop_header ( ctx , gb ) ; } else return decode_vop_header ( ctx , gb ) ; } "," studio_profile ) { if ( ! ",FFmpeg@FFmpeg/bd27a9364ca274ca97f1df6d984e88a0700fb235,CVE-2018-13304,https://github.com/FFmpeg/FFmpeg/commit/bd27a9364ca274ca97f1df6d984e88a0700fb235,2018-07-05T17:29Z 1004,CWE-189,"CWE-189 asmlinkage long sys_oabi_semtimedop ( int semid , struct oabi_sembuf __user * tsops , unsigned nsops , const struct timespec __user * timeout ) { struct sembuf * sops ; struct timespec local_timeout ; long err ; int i ; if ( nsops < 1 ) return - EINVAL ; sops = kmalloc ( sizeof ( * sops ) * nsops , GFP_KERNEL ) ; if ( ! sops ) return - ENOMEM ; err = 0 ; for ( i = 0 ; i < nsops ; i ++ ) { __get_user_error ( sops [ i ] . sem_num , & tsops -> sem_num , err ) ; __get_user_error ( sops [ i ] . sem_op , & tsops -> sem_op , err ) ; __get_user_error ( sops [ i ] . sem_flg , & tsops -> sem_flg , err ) ; tsops ++ ; } if ( timeout ) { err |= copy_from_user ( & local_timeout , timeout , sizeof ( * timeout ) ) ; timeout = & local_timeout ; } if ( err ) { err = - EFAULT ; } else { mm_segment_t fs = get_fs ( ) ; set_fs ( KERNEL_DS ) ; err = sys_semtimedop ( semid , sops , nsops , timeout ) ; set_fs ( fs ) ; } kfree ( sops ) ; return err ; } "," nsops < 1 || nsops > SEMOPM ",torvalds@linux/0f22072ab50cac7983f9660d33974b45184da4f9,CVE-2011-1759,https://github.com/torvalds/linux/commit/0f22072ab50cac7983f9660d33974b45184da4f9,2012-06-13T10:24Z 1005,CWE-119,"CWE-119 void vp8_mbpost_proc_across_ip_c ( unsigned char * src , int pitch , int rows , int cols , int flimit ) { int r , c , i ; unsigned char * s = src ; unsigned char d [ 16 ] ; for ( r = 0 ; r < rows ; r ++ ) { int sumsq = 0 ; int sum = 0 ; for ( i = - 8 ; i < 0 ; i ++ ) s [ i ] = s [ 0 ] ; for ( i = cols ; i < cols + 17 ; i ++ ) s [ i ] = s [ cols - 1 ] ; for ( i = - 8 ; i <= 6 ; i ++ ) { sumsq += s [ i ] * s [ i ] ; sum += s [ i ] ; d [ i + 8 ] = 0 ; } for ( c = 0 ; c < cols + 8 ; c ++ ) { int x = s [ c + 7 ] - s [ c - 8 ] ; int y = s [ c + 7 ] + s [ c - 8 ] ; sum += x ; sumsq += x * y ; d [ c & 15 ] = s [ c ] ; if ( sumsq * 15 - sum * sum < flimit ) { d [ c & 15 ] = ( 8 + sum + s [ c ] ) >> 4 ; } s [ c - 8 ] = d [ ( c - 8 ) & 15 ] ; } s += pitch ; } } "," ( i = 0 ; i < 17 ; i ++ ) s [ i + cols ] = s ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1006,CWE-787,"CWE-787 static grub_disk_addr_t grub_ext2_read_block ( grub_fshelp_node_t node , grub_disk_addr_t fileblock ) { struct grub_ext2_data * data = node -> data ; struct grub_ext2_inode * inode = & node -> inode ; int blknr = - 1 ; unsigned int blksz = EXT2_BLOCK_SIZE ( data ) ; int log2_blksz = LOG2_EXT2_BLOCK_SIZE ( data ) ; if ( grub_le_to_cpu32 ( inode -> flags ) & EXT4_EXTENTS_FLAG ) { # ifndef _MSC_VER char buf [ EXT2_BLOCK_SIZE ( data ) ] ; # else char * buf = grub_malloc ( EXT2_BLOCK_SIZE ( data ) ) ; # endif struct grub_ext4_extent_header * leaf ; struct grub_ext4_extent * ext ; int i ; leaf = grub_ext4_find_leaf ( data , buf , ( struct grub_ext4_extent_header * ) inode -> blocks . dir_blocks , fileblock ) ; if ( ! leaf ) { grub_error ( GRUB_ERR_BAD_FS , ""invalidextent"" ) ; return - 1 ; } ext = ( struct grub_ext4_extent * ) ( leaf + 1 ) ; for ( i = 0 ; i < grub_le_to_cpu16 ( leaf -> entries ) ; i ++ ) { if ( fileblock < grub_le_to_cpu32 ( ext [ i ] . block ) ) break ; } if ( -- i >= 0 ) { fileblock -= grub_le_to_cpu32 ( ext [ i ] . block ) ; if ( fileblock >= grub_le_to_cpu16 ( ext [ i ] . len ) ) return 0 ; else { grub_disk_addr_t start ; start = grub_le_to_cpu16 ( ext [ i ] . start_hi ) ; start = ( start << 32 ) + grub_le_to_cpu32 ( ext [ i ] . start ) ; return fileblock + start ; } } else { grub_error ( GRUB_ERR_BAD_FS , ""somethingwrongwithextent"" ) ; return - 1 ; } } if ( fileblock < INDIRECT_BLOCKS ) blknr = grub_le_to_cpu32 ( inode -> blocks . dir_blocks [ fileblock ] ) ; else if ( fileblock < INDIRECT_BLOCKS + blksz / 4 ) { grub_uint32_t * indir ; indir = grub_malloc ( blksz ) ; if ( ! indir ) return grub_errno ; if ( grub_disk_read ( data -> disk , ( ( grub_disk_addr_t ) grub_le_to_cpu32 ( inode -> blocks . indir_block ) ) << log2_blksz , 0 , blksz , indir ) ) return grub_errno ; blknr = grub_le_to_cpu32 ( indir [ fileblock - INDIRECT_BLOCKS ] ) ; grub_free ( indir ) ; } else if ( fileblock < ( grub_disk_addr_t ) ( INDIRECT_BLOCKS + blksz / 4 ) * ( grub_disk_addr_t ) ( blksz / 4 + 1 ) ) { unsigned int perblock = blksz / 4 ; unsigned int rblock = fileblock - ( INDIRECT_BLOCKS + blksz / 4 ) ; grub_uint32_t * indir ; indir = grub_malloc ( blksz ) ; if ( ! indir ) return grub_errno ; if ( grub_disk_read ( data -> disk , ( ( grub_disk_addr_t ) grub_le_to_cpu32 ( inode -> blocks . double_indir_block ) ) << log2_blksz , 0 , blksz , indir ) ) return grub_errno ; if ( grub_disk_read ( data -> disk , ( ( grub_disk_addr_t ) grub_le_to_cpu32 ( indir [ rblock / perblock ] ) ) << log2_blksz , 0 , blksz , indir ) ) return grub_errno ; blknr = grub_le_to_cpu32 ( indir [ rblock % perblock ] ) ; grub_free ( indir ) ; } else { grub_error ( GRUB_ERR_NOT_IMPLEMENTED_YET , ""ext2fsdoesn\'tsupporttripleindirectblocks"" ) ; } return blknr ; } "," < INDIRECT_BLOCKS ) { ] ) ; } ",radare@radare2/796dd28aaa6b9fa76d99c42c4d5ff8b257cc2191,CVE-2017-9949,https://github.com/radare/radare2/commit/796dd28aaa6b9fa76d99c42c4d5ff8b257cc2191,2017-06-26T20:29Z 1007,CWE-119,"CWE-119 static int DecodeGifImg ( struct ngiflib_img * i ) { struct ngiflib_decode_context context ; long npix ; u8 * stackp ; u8 * stack_top ; u16 clr ; u16 eof ; u16 free ; u16 act_code = 0 ; u16 old_code = 0 ; u16 read_byt ; u16 ab_prfx [ 4096 ] ; u8 ab_suffx [ 4096 ] ; u8 ab_stack [ 4096 ] ; u8 flags ; u8 casspecial = 0 ; if ( ! i ) return - 1 ; i -> posX = GetWord ( i -> parent ) ; i -> posY = GetWord ( i -> parent ) ; i -> width = GetWord ( i -> parent ) ; i -> height = GetWord ( i -> parent ) ; if ( ( i -> width > i -> parent -> width ) || ( i -> height > i -> parent -> height ) ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent -> log ) fprintf ( i -> parent -> log , ""***ERROR***ImagebiggerthanglobalGIFcanvas!\\n"" ) ; # endif return - 1 ; } if ( ( i -> posX + i -> width ) > i -> parent -> width ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent -> log ) fprintf ( i -> parent -> log , ""***WARNING***AdjustingXposition\\n"" ) ; # endif i -> posX = i -> parent -> width - i -> width ; } if ( ( i -> posY + i -> height ) > i -> parent -> height ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent -> log ) fprintf ( i -> parent -> log , ""***WARNING***AdjustingYposition\\n"" ) ; # endif i -> posY = i -> parent -> height - i -> height ; } context . Xtogo = i -> width ; context . curY = i -> posY ; # ifdef NGIFLIB_INDEXED_ONLY # ifdef NGIFLIB_ENABLE_CALLBACKS context . line_p . p8 = i -> parent -> frbuff . p8 + ( u32 ) i -> posY * i -> parent -> width ; context . frbuff_p . p8 = context . line_p . p8 + i -> posX ; # else context . frbuff_p . p8 = i -> parent -> frbuff . p8 + ( u32 ) i -> posY * i -> parent -> width + i -> posX ; # endif # else if ( i -> parent -> mode & NGIFLIB_MODE_INDEXED ) { # ifdef NGIFLIB_ENABLE_CALLBACKS context . line_p . p8 = i -> parent -> frbuff . p8 + ( u32 ) i -> posY * i -> parent -> width ; context . frbuff_p . p8 = context . line_p . p8 + i -> posX ; # else context . frbuff_p . p8 = i -> parent -> frbuff . p8 + ( u32 ) i -> posY * i -> parent -> width + i -> posX ; # endif } else { # ifdef NGIFLIB_ENABLE_CALLBACKS context . line_p . p32 = i -> parent -> frbuff . p32 + ( u32 ) i -> posY * i -> parent -> width ; context . frbuff_p . p32 = context . line_p . p32 + i -> posX ; # else context . frbuff_p . p32 = i -> parent -> frbuff . p32 + ( u32 ) i -> posY * i -> parent -> width + i -> posX ; # endif } # endif npix = ( long ) i -> width * i -> height ; flags = GetByte ( i -> parent ) ; i -> interlaced = ( flags & 64 ) >> 6 ; context . pass = i -> interlaced ? 1 : 0 ; i -> sort_flag = ( flags & 32 ) >> 5 ; i -> localpalbits = ( flags & 7 ) + 1 ; if ( flags & 128 ) { int k ; int localpalsize = 1 << i -> localpalbits ; # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent && i -> parent -> log ) fprintf ( i -> parent -> log , ""Localpalette\\n"" ) ; # endif i -> palette = ( struct ngiflib_rgb * ) ngiflib_malloc ( sizeof ( struct ngiflib_rgb ) * localpalsize ) ; for ( k = 0 ; k < localpalsize ; k ++ ) { i -> palette [ k ] . r = GetByte ( i -> parent ) ; i -> palette [ k ] . g = GetByte ( i -> parent ) ; i -> palette [ k ] . b = GetByte ( i -> parent ) ; } # ifdef NGIFLIB_ENABLE_CALLBACKS if ( i -> parent -> palette_cb ) i -> parent -> palette_cb ( i -> parent , i -> palette , localpalsize ) ; # endif } else { i -> palette = i -> parent -> palette ; i -> localpalbits = i -> parent -> imgbits ; } i -> ncolors = 1 << i -> localpalbits ; i -> imgbits = GetByte ( i -> parent ) ; # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent && i -> parent -> log ) { if ( i -> interlaced ) fprintf ( i -> parent -> log , ""interlaced"" ) ; fprintf ( i -> parent -> log , ""imgpos(%hu,%hu)size%hux%hupalbits=%hhuimgbits=%hhuncolors=%hu\\n"" , i -> posX , i -> posY , i -> width , i -> height , i -> localpalbits , i -> imgbits , i -> ncolors ) ; } # endif if ( i -> imgbits == 1 ) { i -> imgbits = 2 ; } clr = 1 << i -> imgbits ; eof = clr + 1 ; free = clr + 2 ; context . nbbit = i -> imgbits + 1 ; context . max = clr + clr - 1 ; stackp = stack_top = ab_stack + 4096 ; context . restbits = 0 ; context . restbyte = 0 ; context . lbyte = 0 ; for ( ; ; ) { act_code = GetGifWord ( i , & context ) ; if ( act_code == eof ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent && i -> parent -> log ) fprintf ( i -> parent -> log , ""Endofimagecode\\n"" ) ; # endif return 0 ; } if ( npix == 0 ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent && i -> parent -> log ) fprintf ( i -> parent -> log , ""assezdepixels,Onsecasse!\\n"" ) ; # endif return 1 ; } if ( act_code == clr ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent && i -> parent -> log ) fprintf ( i -> parent -> log , ""Codeclear(free=%hu)npix=%ld\\n"" , free , npix ) ; # endif free = clr + 2 ; context . nbbit = i -> imgbits + 1 ; context . max = clr + clr - 1 ; act_code = GetGifWord ( i , & context ) ; casspecial = ( u8 ) act_code ; old_code = act_code ; WritePixel ( i , & context , casspecial ) ; npix -- ; } else { read_byt = act_code ; if ( act_code >= free ) { * ( -- stackp ) = casspecial ; act_code = old_code ; } while ( act_code > clr ) { * ( -- stackp ) = ab_suffx [ act_code ] ; act_code = ab_prfx [ act_code ] ; } casspecial = ( u8 ) act_code ; * ( -- stackp ) = casspecial ; WritePixels ( i , & context , stackp , stack_top - stackp ) ; npix -= ( stack_top - stackp ) ; stackp = stack_top ; if ( free < 4096 ) { ab_prfx [ free ] = old_code ; ab_suffx [ free ] = ( u8 ) act_code ; free ++ ; if ( ( free > context . max ) && ( context . nbbit < 12 ) ) { context . nbbit ++ ; context . max += context . max + 1 ; } } old_code = read_byt ; } } return 0 ; } "," = act_code ; if ( npix > 0 ) = casspecial ; if ( npix >= ( stack_top - stackp - stackp ) ) { WritePixels ( i , & context , stackp , stack_top - stackp ) ; } else if ( npix > 0 ) { WritePixels ( i , & context , stackp , npix ) ; } npix -= ( ",miniupnp@ngiflib/cf429e0a2fe26b5f01ce0c8e9b79432e94509b6e,CVE-2018-10717,https://github.com/miniupnp/ngiflib/commit/cf429e0a2fe26b5f01ce0c8e9b79432e94509b6e,2018-05-03T17:29Z 1008,CWE-20,"CWE-20 int cdf_read_property_info ( const cdf_stream_t * sst , const cdf_header_t * h , uint32_t offs , cdf_property_info_t * * info , size_t * count , size_t * maxcount ) { const cdf_section_header_t * shp ; cdf_section_header_t sh ; const uint8_t * p , * q , * e ; int16_t s16 ; int32_t s32 ; uint32_t u32 ; int64_t s64 ; uint64_t u64 ; cdf_timestamp_t tp ; size_t i , o , o4 , nelements , j ; cdf_property_info_t * inp ; if ( offs > UINT32_MAX / 4 ) { errno = EFTYPE ; goto out ; } shp = CAST ( const cdf_section_header_t * , ( const void * ) ( ( const char * ) sst -> sst_tab + offs ) ) ; if ( cdf_check_stream_offset ( sst , h , shp , sizeof ( * shp ) , __LINE__ ) == - 1 ) goto out ; sh . sh_len = CDF_TOLE4 ( shp -> sh_len ) ; # define CDF_SHLEN_LIMIT ( UINT32_MAX / 8 ) if ( sh . sh_len > CDF_SHLEN_LIMIT ) { errno = EFTYPE ; goto out ; } sh . sh_properties = CDF_TOLE4 ( shp -> sh_properties ) ; # define CDF_PROP_LIMIT ( UINT32_MAX / ( 4 * sizeof ( * inp ) ) ) if ( sh . sh_properties > CDF_PROP_LIMIT ) goto out ; DPRINTF ( ( ""sectionlen:%uproperties%u\\n"" , sh . sh_len , sh . sh_properties ) ) ; if ( * maxcount ) { if ( * maxcount > CDF_PROP_LIMIT ) goto out ; * maxcount += sh . sh_properties ; inp = CAST ( cdf_property_info_t * , realloc ( * info , * maxcount * sizeof ( * inp ) ) ) ; } else { * maxcount = sh . sh_properties ; inp = CAST ( cdf_property_info_t * , malloc ( * maxcount * sizeof ( * inp ) ) ) ; } if ( inp == NULL ) goto out ; * info = inp ; inp += * count ; * count += sh . sh_properties ; p = CAST ( const uint8_t * , ( const void * ) ( ( const char * ) ( const void * ) sst -> sst_tab + offs + sizeof ( sh ) ) ) ; e = CAST ( const uint8_t * , ( const void * ) ( ( ( const char * ) ( const void * ) shp ) + sh . sh_len ) ) ; if ( cdf_check_stream_offset ( sst , h , e , 0 , __LINE__ ) == - 1 ) goto out ; for ( i = 0 ; i < sh . sh_properties ; i ++ ) { size_t ofs = CDF_GETUINT32 ( p , ( i << 1 ) + 1 ) ; q = ( const uint8_t * ) ( const void * ) ( ( const char * ) ( const void * ) p + ofs - 2 * sizeof ( uint32_t ) ) ; if ( q > e ) { DPRINTF ( ( ""Ranoftheend%p>%p\\n"" , q , e ) ) ; goto out ; } inp [ i ] . pi_id = CDF_GETUINT32 ( p , i << 1 ) ; inp [ i ] . pi_type = CDF_GETUINT32 ( q , 0 ) ; DPRINTF ( ( ""%"" SIZE_T_FORMAT ""u)id=%xtype=%xoffs=0x%tx,0x%x\\n"" , i , inp [ i ] . pi_id , inp [ i ] . pi_type , q - p , offs ) ) ; if ( inp [ i ] . pi_type & CDF_VECTOR ) { nelements = CDF_GETUINT32 ( q , 1 ) ; if ( nelements == 0 ) { DPRINTF ( ( ""CDF_VECTORwithnelements==0\\n"" ) ) ; goto out ; } o = 2 ; } else { nelements = 1 ; o = 1 ; } o4 = o * sizeof ( uint32_t ) ; if ( inp [ i ] . pi_type & ( CDF_ARRAY | CDF_BYREF | CDF_RESERVED ) ) goto unknown ; switch ( inp [ i ] . pi_type & CDF_TYPEMASK ) { case CDF_NULL : case CDF_EMPTY : break ; case CDF_SIGNED16 : if ( inp [ i ] . pi_type & CDF_VECTOR ) goto unknown ; ( void ) memcpy ( & s16 , & q [ o4 ] , sizeof ( s16 ) ) ; inp [ i ] . pi_s16 = CDF_TOLE2 ( s16 ) ; break ; case CDF_SIGNED32 : if ( inp [ i ] . pi_type & CDF_VECTOR ) goto unknown ; ( void ) memcpy ( & s32 , & q [ o4 ] , sizeof ( s32 ) ) ; inp [ i ] . pi_s32 = CDF_TOLE4 ( ( uint32_t ) s32 ) ; break ; case CDF_BOOL : case CDF_UNSIGNED32 : if ( inp [ i ] . pi_type & CDF_VECTOR ) goto unknown ; ( void ) memcpy ( & u32 , & q [ o4 ] , sizeof ( u32 ) ) ; inp [ i ] . pi_u32 = CDF_TOLE4 ( u32 ) ; break ; case CDF_SIGNED64 : if ( inp [ i ] . pi_type & CDF_VECTOR ) goto unknown ; ( void ) memcpy ( & s64 , & q [ o4 ] , sizeof ( s64 ) ) ; inp [ i ] . pi_s64 = CDF_TOLE8 ( ( uint64_t ) s64 ) ; break ; case CDF_UNSIGNED64 : if ( inp [ i ] . pi_type & CDF_VECTOR ) goto unknown ; ( void ) memcpy ( & u64 , & q [ o4 ] , sizeof ( u64 ) ) ; inp [ i ] . pi_u64 = CDF_TOLE8 ( ( uint64_t ) u64 ) ; break ; case CDF_FLOAT : if ( inp [ i ] . pi_type & CDF_VECTOR ) goto unknown ; ( void ) memcpy ( & u32 , & q [ o4 ] , sizeof ( u32 ) ) ; u32 = CDF_TOLE4 ( u32 ) ; memcpy ( & inp [ i ] . pi_f , & u32 , sizeof ( inp [ i ] . pi_f ) ) ; break ; case CDF_DOUBLE : if ( inp [ i ] . pi_type & CDF_VECTOR ) goto unknown ; ( void ) memcpy ( & u64 , & q [ o4 ] , sizeof ( u64 ) ) ; u64 = CDF_TOLE8 ( ( uint64_t ) u64 ) ; memcpy ( & inp [ i ] . pi_d , & u64 , sizeof ( inp [ i ] . pi_d ) ) ; break ; case CDF_LENGTH32_STRING : case CDF_LENGTH32_WSTRING : if ( nelements > 1 ) { size_t nelem = inp - * info ; if ( * maxcount > CDF_PROP_LIMIT || nelements > CDF_PROP_LIMIT ) goto out ; * maxcount += nelements ; inp = CAST ( cdf_property_info_t * , realloc ( * info , * maxcount * sizeof ( * inp ) ) ) ; if ( inp == NULL ) goto out ; * info = inp ; inp = * info + nelem ; } DPRINTF ( ( ""nelements=%"" SIZE_T_FORMAT ""u\\n"" , nelements ) ) ; for ( j = 0 ; j < nelements && i < sh . sh_properties ; j ++ , i ++ ) { uint32_t l = CDF_GETUINT32 ( q , o ) ; inp [ i ] . pi_str . s_len = l ; inp [ i ] . pi_str . s_buf = ( const char * ) ( const void * ) ( & q [ o4 + sizeof ( l ) ] ) ; DPRINTF ( ( ""l=%d,r=%"" SIZE_T_FORMAT ""u,s=%s\\n"" , l , CDF_ROUND ( l , sizeof ( l ) ) , inp [ i ] . pi_str . s_buf ) ) ; if ( l & 1 ) l ++ ; o += l >> 1 ; if ( q + o >= e ) goto out ; o4 = o * sizeof ( uint32_t ) ; } i -- ; break ; case CDF_FILETIME : if ( inp [ i ] . pi_type & CDF_VECTOR ) goto unknown ; ( void ) memcpy ( & tp , & q [ o4 ] , sizeof ( tp ) ) ; inp [ i ] . pi_tp = CDF_TOLE8 ( ( uint64_t ) tp ) ; break ; case CDF_CLIPBOARD : if ( inp [ i ] . pi_type & CDF_VECTOR ) goto unknown ; break ; default : unknown : DPRINTF ( ( ""Don\'tknowhowtodealwith%x\\n"" , inp [ i ] . pi_type ) ) ; break ; } } return 0 ; out : free ( * info ) ; return - 1 ; } "," ) { size_t tail = ( i << ) + 1 ; if ( cdf_check_stream_offset ( sst , h , p , tail * sizeof ( uint32_t ) , __LINE__ ) == - 1 ) goto out ; size_t ofs = CDF_GETUINT32 ( p , tail ",file@file/93e063ee374b6a75729df9e7201fb511e47e259d,CVE-2014-3487,https://github.com/file/file/commit/93e063ee374b6a75729df9e7201fb511e47e259d,2014-07-09T11:07Z 1009,CWE-125,"CWE-125 int yr_re_fast_exec ( uint8_t * code , uint8_t * input_data , size_t input_forwards_size , size_t input_backwards_size , int flags , RE_MATCH_CALLBACK_FUNC callback , void * callback_args , int * matches ) { RE_REPEAT_ANY_ARGS * repeat_any_args ; uint8_t * code_stack [ MAX_FAST_RE_STACK ] ; uint8_t * input_stack [ MAX_FAST_RE_STACK ] ; int matches_stack [ MAX_FAST_RE_STACK ] ; uint8_t * ip = code ; uint8_t * input = input_data ; uint8_t * next_input ; uint8_t * next_opcode ; uint8_t mask ; uint8_t value ; int i ; int stop ; int input_incr ; int sp = 0 ; int bytes_matched ; int max_bytes_matched ; max_bytes_matched = flags & RE_FLAGS_BACKWARDS ? ( int ) input_backwards_size : ( int ) input_forwards_size ; input_incr = flags & RE_FLAGS_BACKWARDS ? - 1 : 1 ; if ( flags & RE_FLAGS_BACKWARDS ) input -- ; code_stack [ sp ] = code ; input_stack [ sp ] = input ; matches_stack [ sp ] = 0 ; sp ++ ; while ( sp > 0 ) { sp -- ; ip = code_stack [ sp ] ; input = input_stack [ sp ] ; bytes_matched = matches_stack [ sp ] ; stop = FALSE ; while ( ! stop ) { if ( * ip == RE_OPCODE_MATCH ) { if ( flags & RE_FLAGS_EXHAUSTIVE ) { FAIL_ON_ERROR ( callback ( flags & RE_FLAGS_BACKWARDS ? input + 1 : input_data , bytes_matched , flags , callback_args ) ) ; break ; } else { if ( matches != NULL ) * matches = bytes_matched ; return ERROR_SUCCESS ; } } if ( bytes_matched >= max_bytes_matched ) break ; switch ( * ip ) { case RE_OPCODE_LITERAL : if ( * input == * ( ip + 1 ) ) { bytes_matched ++ ; input += input_incr ; ip += 2 ; } else { stop = TRUE ; } break ; case RE_OPCODE_MASKED_LITERAL : value = * ( int16_t * ) ( ip + 1 ) & 0xFF ; mask = * ( int16_t * ) ( ip + 1 ) >> 8 ; if ( ( * input & mask ) == value ) { bytes_matched ++ ; input += input_incr ; ip += 3 ; } else { stop = TRUE ; } break ; case RE_OPCODE_ANY : bytes_matched ++ ; input += input_incr ; ip += 1 ; break ; case RE_OPCODE_REPEAT_ANY_UNGREEDY : repeat_any_args = ( RE_REPEAT_ANY_ARGS * ) ( ip + 1 ) ; next_opcode = ip + 1 + sizeof ( RE_REPEAT_ANY_ARGS ) ; for ( i = repeat_any_args -> min + 1 ; i <= repeat_any_args -> max ; i ++ ) { next_input = input + i * input_incr ; if ( bytes_matched + i >= max_bytes_matched ) break ; if ( * ( next_opcode ) != RE_OPCODE_LITERAL || ( * ( next_opcode ) == RE_OPCODE_LITERAL && * ( next_opcode + 1 ) == * next_input ) ) { if ( sp >= MAX_FAST_RE_STACK ) return - 4 ; code_stack [ sp ] = next_opcode ; input_stack [ sp ] = next_input ; matches_stack [ sp ] = bytes_matched + i ; sp ++ ; } } input += input_incr * repeat_any_args -> min ; bytes_matched += repeat_any_args -> min ; ip = next_opcode ; break ; default : assert ( FALSE ) ; } } } if ( matches != NULL ) * matches = - 1 ; return ERROR_SUCCESS ; } "," ++ ) { if ( bytes_matched max_bytes_matched ) break ; next_input = input + i * input_incr -> min ; bytes_matched = yr_min ( bytes_matched , max_bytes_matched ) ; ",VirusTotal@yara/992480c30f75943e9cd6245bb2015c7737f9b661,CVE-2017-9465,https://github.com/VirusTotal/yara/commit/992480c30f75943e9cd6245bb2015c7737f9b661,2017-06-06T21:29Z 1010,CWE-787,"CWE-787 void jslTokenAsString ( int token , char * str , size_t len ) { if ( token > 32 && token < 128 ) { assert ( len >= 4 ) ; str [ 0 ] = '\\'' ; str [ 1 ] = ( char ) token ; str [ 2 ] = '\\'' ; str [ 3 ] = 0 ; return ; } switch ( token ) { case LEX_EOF : strncpy ( str , ""EOF"" , len ) ; return ; case LEX_ID : strncpy ( str , ""ID"" , len ) ; return ; case LEX_INT : strncpy ( str , ""INT"" , len ) ; return ; case LEX_FLOAT : strncpy ( str , ""FLOAT"" , len ) ; return ; case LEX_STR : strncpy ( str , ""STRING"" , len ) ; return ; case LEX_UNFINISHED_STR : strncpy ( str , ""UNFINISHEDSTRING"" , len ) ; return ; case LEX_TEMPLATE_LITERAL : strncpy ( str , ""TEMPLATELITERAL"" , len ) ; return ; case LEX_UNFINISHED_TEMPLATE_LITERAL : strncpy ( str , ""UNFINISHEDTEMPLATELITERAL"" , len ) ; return ; case LEX_REGEX : strncpy ( str , ""REGEX"" , len ) ; return ; case LEX_UNFINISHED_REGEX : strncpy ( str , ""UNFINISHEDREGEX"" , len ) ; return ; case LEX_UNFINISHED_COMMENT : strncpy ( str , ""UNFINISHEDCOMMENT"" , len ) ; return ; } if ( token >= _LEX_OPERATOR_START && token < _LEX_R_LIST_END ) { const char tokenNames [ ] = ""==\\0"" ""===\\0"" ""!=\\0"" ""!==\\0"" ""<=\\0"" ""<<\\0"" ""<<=\\0"" "">=\\0"" "">>\\0"" "">>>\\0"" "">>=\\0"" "">>>=\\0"" ""+=\\0"" ""-=\\0"" ""++\\0"" ""--\\0"" ""*=\\0"" ""/=\\0"" ""%=\\0"" ""&=\\0"" ""&&\\0"" ""|=\\0"" ""||\\0"" ""^=\\0"" ""=>\\0"" ""if\\0"" ""else\\0"" ""do\\0"" ""while\\0"" ""for\\0"" ""return\\0"" ""continue\\0"" ""function\\0"" ""return\\0"" ""var\\0"" ""let\\0"" ""const\\0"" ""this\\0"" ""throw\\0"" ""try\\0"" ""catch\\0"" ""finally\\0"" ""true\\0"" ""false\\0"" ""null\\0"" ""undefined\\0"" ""new\\0"" ""in\\0"" ""instanceof\\0"" ""switch\\0"" ""case\\0"" ""default\\0"" ""delete\\0"" ""typeof\\0"" ""void\\0"" ""debugger\\0"" ""class\\0"" ""extends\\0"" ""super\\0"" ""static\\0"" ; unsigned int p = 0 ; int n = token - _LEX_OPERATOR_START ; while ( n > 0 && p < sizeof ( tokenNames ) ) { while ( tokenNames [ p ] && p < sizeof ( tokenNames ) ) p ++ ; p ++ ; n -- ; } assert ( n == 0 ) ; strncpy ( str , & tokenNames [ p ] , len ) ; return ; } assert ( len >= 10 ) ; espruino_snprintf ( str , len , ""?[%d]"" , token ) ; } "," len ) { assert ( len > 28 ) ; case LEX_EOF : strcpy ( str , str , ""EOF"" ) ; return case LEX_ID : strcpy ( str , str , ""ID"" ) ; return case LEX_INT : strcpy ( str , str , ""INT"" ) ; return case LEX_FLOAT : strcpy ( str , str , ""FLOAT"" ) ; return case LEX_STR : strcpy ( str , str , ""STRING"" ) ; return case LEX_UNFINISHED_STR : strcpy ( str , str , ""UNFINISHEDSTRING"" ) ; return case LEX_TEMPLATE_LITERAL : strcpy ( str , str , ""TEMPLATELITERAL"" ) ; return case LEX_UNFINISHED_TEMPLATE_LITERAL : strcpy ( str , str , ""UNFINISHEDTEMPLATELITERAL"" ) ; return case LEX_REGEX : strcpy ( str , str , ""REGEX"" ) ; return case LEX_UNFINISHED_REGEX : strcpy ( str , str , ""UNFINISHEDREGEX"" ) ; return case LEX_UNFINISHED_COMMENT : strcpy ( str , str , ""UNFINISHEDCOMMENT"" ) ; return 0 ) ; strcpy ( str , [ p ] ) ; return return ; } espruino_snprintf ( str ",espruino@Espruino/bed844f109b6c222816740555068de2e101e8018,CVE-2018-11593,https://github.com/espruino/Espruino/commit/bed844f109b6c222816740555068de2e101e8018,2018-05-31T16:29Z 1011,CWE-284,"CWE-284 static void mntput_no_expire ( struct mount * mnt ) { rcu_read_lock ( ) ; mnt_add_count ( mnt , - 1 ) ; if ( likely ( mnt -> mnt_ns ) ) { rcu_read_unlock ( ) ; return ; } lock_mount_hash ( ) ; if ( mnt_get_count ( mnt ) ) { rcu_read_unlock ( ) ; unlock_mount_hash ( ) ; return ; } if ( unlikely ( mnt -> mnt . mnt_flags & MNT_DOOMED ) ) { rcu_read_unlock ( ) ; unlock_mount_hash ( ) ; return ; } mnt -> mnt . mnt_flags |= MNT_DOOMED ; rcu_read_unlock ( ) ; list_del ( & mnt -> mnt_instance ) ; unlock_mount_hash ( ) ; if ( likely ( ! ( mnt -> mnt . mnt_flags & MNT_INTERNAL ) ) ) { struct task_struct * task = current ; if ( likely ( ! ( task -> flags & PF_KTHREAD ) ) ) { init_task_work ( & mnt -> mnt_rcu , __cleanup_mnt ) ; if ( ! task_work_add ( task , & mnt -> mnt_rcu , true ) ) return ; } if ( llist_add ( & mnt -> mnt_llist , & delayed_mntput_list ) ) schedule_delayed_work ( & delayed_mntput_work , 1 ) ; return ; } cleanup_mnt ( mnt ) ; } "," mnt_instance ) ; if ( unlikely ( ! list_empty ( & mnt -> mnt_mounts ) ) ) { struct mount * p , * tmp ; list_for_each_entry_safe ( p , tmp , & mnt -> mnt_mounts , mnt_child ) { umount_mnt ( p ) ; } } ",torvalds@linux/ce07d891a0891d3c0d0c2d73d577490486b809e1,CVE-2014-9717,https://github.com/torvalds/linux/commit/ce07d891a0891d3c0d0c2d73d577490486b809e1,2016-05-02T10:59Z 1012,CWE-119,"CWE-119 static void encode_term_subexp ( vp9_writer * w , int word ) { if ( ! write_bit_gte ( w , word , 16 ) ) { vp9_write_literal ( w , word , 4 ) ; } else if ( ! write_bit_gte ( w , word , 32 ) ) { vp9_write_literal ( w , word - 16 , 4 ) ; } else if ( ! write_bit_gte ( w , word , 64 ) ) { vp9_write_literal ( w , word - 32 , 5 ) ; } else { encode_uniform ( w , word - 64 ) ; } } "," void encode_term_subexp ( vpx_writer * w , ) ) { vpx_write_literal ( w , ) ) { vpx_write_literal ( w , ) ) { vpx_write_literal ( w , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1013,CWE-125,"CWE-125 int jpc_dec_decodepkts ( jpc_dec_t * dec , jas_stream_t * pkthdrstream , jas_stream_t * in ) { jpc_dec_tile_t * tile ; jpc_pi_t * pi ; int ret ; tile = dec -> curtile ; pi = tile -> pi ; for ( ; ; ) { if ( ! tile -> pkthdrstream || jas_stream_peekc ( tile -> pkthdrstream ) == EOF ) { switch ( jpc_dec_lookahead ( in ) ) { case JPC_MS_EOC : case JPC_MS_SOT : return 0 ; break ; case JPC_MS_SOP : case JPC_MS_EPH : case 0 : break ; default : return - 1 ; break ; } } if ( ( ret = jpc_pi_next ( pi ) ) ) { return ret ; } if ( dec -> maxpkts >= 0 && dec -> numpkts >= dec -> maxpkts ) { jas_eprintf ( ""warning:stoppingdecodeprematurelyasrequested\\n"" ) ; return 0 ; } if ( jas_getdbglevel ( ) >= 1 ) { jas_eprintf ( ""packetoffset=%08ldprg=%dcmptno=%02d"" ""rlvlno=%02dprcno=%03dlyrno=%02d\\n"" , ( long ) jas_stream_getrwcount ( in ) , jpc_pi_prg ( pi ) , jpc_pi_cmptno ( pi ) , jpc_pi_rlvlno ( pi ) , jpc_pi_prcno ( pi ) , jpc_pi_lyrno ( pi ) ) ; } if ( jpc_dec_decodepkt ( dec , pkthdrstream , in , jpc_pi_cmptno ( pi ) , jpc_pi_rlvlno ( pi ) , jpc_pi_prcno ( pi ) , jpc_pi_lyrno ( pi ) ) ) { return - 1 ; } ++ dec -> numpkts ; } return 0 ; } "," ",mdadams@jasper/aa0b0f79ade5eef8b0e7a214c03f5af54b36ba7d,CVE-2016-9583,https://github.com/mdadams/jasper/commit/aa0b0f79ade5eef8b0e7a214c03f5af54b36ba7d,2018-08-01T17:29Z 1014,CWE-119,"CWE-119 enum nss_status _nss_mymachines_getpwnam_r ( const char * name , struct passwd * pwd , char * buffer , size_t buflen , int * errnop ) { _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL ; _cleanup_bus_message_unref_ sd_bus_message * reply = NULL ; _cleanup_bus_flush_close_unref_ sd_bus * bus = NULL ; const char * p , * e , * machine ; uint32_t mapped ; uid_t uid ; size_t l ; int r ; assert ( name ) ; assert ( pwd ) ; p = startswith ( name , ""vu-"" ) ; if ( ! p ) goto not_found ; e = strrchr ( p , '-' ) ; if ( ! e || e == p ) goto not_found ; r = parse_uid ( e + 1 , & uid ) ; if ( r < 0 ) goto not_found ; machine = strndupa ( p , e - p ) ; if ( ! machine_name_is_valid ( machine ) ) goto not_found ; r = sd_bus_open_system ( & bus ) ; if ( r < 0 ) goto fail ; r = sd_bus_call_method ( bus , ""org.freedesktop.machine1"" , ""/org/freedesktop/machine1"" , ""org.freedesktop.machine1.Manager"" , ""MapFromMachineUser"" , & error , & reply , ""su"" , machine , ( uint32_t ) uid ) ; if ( r < 0 ) { if ( sd_bus_error_has_name ( & error , BUS_ERROR_NO_SUCH_USER_MAPPING ) ) goto not_found ; goto fail ; } r = sd_bus_message_read ( reply , ""u"" , & mapped ) ; if ( r < 0 ) goto fail ; l = strlen ( name ) ; if ( buflen < l + 1 ) { * errnop = ENOMEM ; return NSS_STATUS_TRYAGAIN ; } memcpy ( buffer , name , l + 1 ) ; pwd -> pw_name = buffer ; pwd -> pw_uid = mapped ; pwd -> pw_gid = 65534 ; pwd -> pw_gecos = buffer ; pwd -> pw_passwd = ( char * ) ""*"" ; pwd -> pw_dir = ( char * ) ""/"" ; pwd -> pw_shell = ( char * ) ""/sbin/nologin"" ; * errnop = 0 ; return NSS_STATUS_SUCCESS ; not_found : * errnop = 0 ; return NSS_STATUS_NOTFOUND ; fail : * errnop = - r ; return NSS_STATUS_UNAVAIL ; } "," e == p ) goto not_found ; if ( e - p > HOST_NAME_MAX - 1 ",keszybz@systemd/cb31827d62066a04b02111df3052949fda4b6888,CVE-2015-7510,https://github.com/keszybz/systemd/commit/cb31827d62066a04b02111df3052949fda4b6888,2017-09-25T21:29Z 1015,CWE-119,"CWE-119 static int udf_symlink_filler ( struct file * file , struct page * page ) { struct inode * inode = page -> mapping -> host ; struct buffer_head * bh = NULL ; unsigned char * symlink ; int err = - EIO ; unsigned char * p = kmap ( page ) ; struct udf_inode_info * iinfo ; uint32_t pos ; iinfo = UDF_I ( inode ) ; pos = udf_block_map ( inode , 0 ) ; down_read ( & iinfo -> i_data_sem ) ; if ( iinfo -> i_alloc_type == ICBTAG_FLAG_AD_IN_ICB ) { symlink = iinfo -> i_ext . i_data + iinfo -> i_lenEAttr ; } else { bh = sb_bread ( inode -> i_sb , pos ) ; if ( ! bh ) goto out ; symlink = bh -> b_data ; } udf_pc_to_char ( inode -> i_sb , symlink , inode -> i_size , p ) ; brelse ( bh ) ; up_read ( & iinfo -> i_data_sem ) ; SetPageUptodate ( page ) ; kunmap ( page ) ; unlock_page ( page ) ; return 0 ; out : up_read ( & iinfo -> i_data_sem ) ; SetPageError ( page ) ; kunmap ( page ) ; unlock_page ( page ) ; return err ; } "," ; int err ; unsigned char uint32_t pos ; if ( inode -> i_size > inode -> i_sb -> s_blocksize ) { err = - ENAMETOOLONG ; goto out_unmap ; } ! bh ) { err = - EIO ; goto out_unlock_inode ; } symlink = bh return 0 ; out_unlock_inode : up_read ( page ) ; out_unmap : ",torvalds@linux/a1d47b262952a45aae62bd49cfaf33dd76c11a2c,CVE-2014-9728,https://github.com/torvalds/linux/commit/a1d47b262952a45aae62bd49cfaf33dd76c11a2c,2015-08-31T10:59Z 1016,CWE-264,"CWE-264 static void vmx_set_msr_bitmap ( struct kvm_vcpu * vcpu ) { unsigned long * msr_bitmap ; if ( is_guest_mode ( vcpu ) ) msr_bitmap = vmx_msr_bitmap_nested ; else if ( vcpu -> arch . apic_base & X2APIC_ENABLE ) { if ( is_long_mode ( vcpu ) ) msr_bitmap = vmx_msr_bitmap_longmode_x2apic ; else msr_bitmap = vmx_msr_bitmap_legacy_x2apic ; } else { if ( is_long_mode ( vcpu ) ) msr_bitmap = vmx_msr_bitmap_longmode ; else msr_bitmap = vmx_msr_bitmap_legacy ; } vmcs_write64 ( MSR_BITMAP , __pa ( msr_bitmap ) ) ; } "," else if ( cpu_has_secondary_exec_ctrls ( ) && ( vmcs_read32 ( SECONDARY_VM_EXEC_CONTROL ) & SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE ) ) { if ",torvalds@linux/3ce424e45411cf5a13105e0386b6ecf6eeb4f66f,CVE-2016-4440,https://github.com/torvalds/linux/commit/3ce424e45411cf5a13105e0386b6ecf6eeb4f66f,2016-06-27T10:59Z 1017,CWE-000,"CWE-000 static krb5_error_code krb5_ldap_get_password_policy_from_dn ( krb5_context context , char * pol_name , char * pol_dn , osa_policy_ent_t * policy ) { krb5_error_code st = 0 , tempst = 0 ; LDAP * ld = NULL ; LDAPMessage * result = NULL , * ent = NULL ; kdb5_dal_handle * dal_handle = NULL ; krb5_ldap_context * ldap_context = NULL ; krb5_ldap_server_handle * ldap_server_handle = NULL ; krb5_clear_error_message ( context ) ; if ( pol_dn == NULL ) return EINVAL ; * policy = NULL ; SETUP_CONTEXT ( ) ; GET_HANDLE ( ) ; * ( policy ) = ( osa_policy_ent_t ) malloc ( sizeof ( osa_policy_ent_rec ) ) ; if ( * policy == NULL ) { st = ENOMEM ; goto cleanup ; } memset ( * policy , 0 , sizeof ( osa_policy_ent_rec ) ) ; LDAP_SEARCH ( pol_dn , LDAP_SCOPE_BASE , ""(objectclass=krbPwdPolicy)"" , password_policy_attributes ) ; ent = ldap_first_entry ( ld , result ) ; if ( ent != NULL ) { if ( ( st = populate_policy ( context , ld , ent , pol_name , * policy ) ) != 0 ) goto cleanup ; } cleanup : ldap_msgfree ( result ) ; if ( st != 0 ) { if ( * policy != NULL ) { krb5_ldap_free_password_policy ( context , * policy ) ; * policy = NULL ; } } krb5_ldap_put_handle_to_pool ( ldap_context , ldap_server_handle ) ; return st ; } "," if ( ent == NULL ) { st = KRB5_KDB_NOENTRY ; goto cleanup ; cleanup ; } st = populate_policy ( context , ld , ent , pol_name , * policy ) ; ",krb5@krb5/d1f707024f1d0af6e54a18885322d70fa15ec4d3,CVE-2014-5353,https://github.com/krb5/krb5/commit/d1f707024f1d0af6e54a18885322d70fa15ec4d3,2014-12-16T23:59Z 1018,CWE-119,"CWE-119 IHEVCD_ERROR_T ihevcd_parse_pps ( codec_t * ps_codec ) { IHEVCD_ERROR_T ret = ( IHEVCD_ERROR_T ) IHEVCD_SUCCESS ; WORD32 value ; WORD32 pps_id ; pps_t * ps_pps ; sps_t * ps_sps ; bitstrm_t * ps_bitstrm = & ps_codec -> s_parse . s_bitstrm ; if ( 0 == ps_codec -> i4_sps_done ) return IHEVCD_INVALID_HEADER ; UEV_PARSE ( ""pic_parameter_set_id"" , value , ps_bitstrm ) ; pps_id = value ; if ( ( pps_id >= MAX_PPS_CNT ) || ( pps_id < 0 ) ) { if ( ps_codec -> i4_pps_done ) return IHEVCD_UNSUPPORTED_PPS_ID ; else pps_id = 0 ; } ps_pps = ( ps_codec -> s_parse . ps_pps_base + MAX_PPS_CNT - 1 ) ; ps_pps -> i1_pps_id = pps_id ; UEV_PARSE ( ""seq_parameter_set_id"" , value , ps_bitstrm ) ; ps_pps -> i1_sps_id = value ; ps_pps -> i1_sps_id = CLIP3 ( ps_pps -> i1_sps_id , 0 , MAX_SPS_CNT - 2 ) ; ps_sps = ( ps_codec -> s_parse . ps_sps_base + ps_pps -> i1_sps_id ) ; if ( 0 == ps_sps -> i1_sps_valid ) { return IHEVCD_INVALID_HEADER ; } BITS_PARSE ( ""dependent_slices_enabled_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_dependent_slice_enabled_flag = value ; BITS_PARSE ( ""output_flag_present_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_output_flag_present_flag = value ; BITS_PARSE ( ""num_extra_slice_header_bits"" , value , ps_bitstrm , 3 ) ; ps_pps -> i1_num_extra_slice_header_bits = value ; BITS_PARSE ( ""sign_data_hiding_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_sign_data_hiding_flag = value ; BITS_PARSE ( ""cabac_init_present_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_cabac_init_present_flag = value ; UEV_PARSE ( ""num_ref_idx_l0_default_active_minus1"" , value , ps_bitstrm ) ; ps_pps -> i1_num_ref_idx_l0_default_active = value + 1 ; UEV_PARSE ( ""num_ref_idx_l1_default_active_minus1"" , value , ps_bitstrm ) ; ps_pps -> i1_num_ref_idx_l1_default_active = value + 1 ; SEV_PARSE ( ""pic_init_qp_minus26"" , value , ps_bitstrm ) ; ps_pps -> i1_pic_init_qp = value + 26 ; BITS_PARSE ( ""constrained_intra_pred_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_constrained_intra_pred_flag = value ; BITS_PARSE ( ""transform_skip_enabled_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_transform_skip_enabled_flag = value ; BITS_PARSE ( ""cu_qp_delta_enabled_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_cu_qp_delta_enabled_flag = value ; if ( ps_pps -> i1_cu_qp_delta_enabled_flag ) { UEV_PARSE ( ""diff_cu_qp_delta_depth"" , value , ps_bitstrm ) ; ps_pps -> i1_diff_cu_qp_delta_depth = value ; } else { ps_pps -> i1_diff_cu_qp_delta_depth = 0 ; } ps_pps -> i1_log2_min_cu_qp_delta_size = ps_sps -> i1_log2_ctb_size - ps_pps -> i1_diff_cu_qp_delta_depth ; SEV_PARSE ( ""cb_qp_offset"" , value , ps_bitstrm ) ; ps_pps -> i1_pic_cb_qp_offset = value ; SEV_PARSE ( ""cr_qp_offset"" , value , ps_bitstrm ) ; ps_pps -> i1_pic_cr_qp_offset = value ; BITS_PARSE ( ""slicelevel_chroma_qp_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_pic_slice_level_chroma_qp_offsets_present_flag = value ; BITS_PARSE ( ""weighted_pred_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_weighted_pred_flag = value ; BITS_PARSE ( ""weighted_bipred_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_weighted_bipred_flag = value ; BITS_PARSE ( ""transquant_bypass_enable_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_transquant_bypass_enable_flag = value ; BITS_PARSE ( ""tiles_enabled_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_tiles_enabled_flag = value ; BITS_PARSE ( ""entropy_coding_sync_enabled_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_entropy_coding_sync_enabled_flag = value ; ps_pps -> i1_loop_filter_across_tiles_enabled_flag = 0 ; if ( ps_pps -> i1_tiles_enabled_flag ) { UEV_PARSE ( ""num_tile_columns_minus1"" , value , ps_bitstrm ) ; ps_pps -> i1_num_tile_columns = value + 1 ; UEV_PARSE ( ""num_tile_rows_minus1"" , value , ps_bitstrm ) ; ps_pps -> i1_num_tile_rows = value + 1 ; if ( ( ps_pps -> i1_num_tile_columns < 1 ) || ( ps_pps -> i1_num_tile_columns > ps_sps -> i2_pic_wd_in_ctb ) || ( ps_pps -> i1_num_tile_rows < 1 ) || ( ps_pps -> i1_num_tile_rows > ps_sps -> i2_pic_ht_in_ctb ) ) return IHEVCD_INVALID_HEADER ; BITS_PARSE ( ""uniform_spacing_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_uniform_spacing_flag = value ; { WORD32 start ; WORD32 i , j ; start = 0 ; for ( i = 0 ; i < ps_pps -> i1_num_tile_columns ; i ++ ) { tile_t * ps_tile ; if ( ! ps_pps -> i1_uniform_spacing_flag ) { if ( i < ( ps_pps -> i1_num_tile_columns - 1 ) ) { UEV_PARSE ( ""column_width_minus1[i]"" , value , ps_bitstrm ) ; value += 1 ; } else { value = ps_sps -> i2_pic_wd_in_ctb - start ; } } else { value = ( ( i + 1 ) * ps_sps -> i2_pic_wd_in_ctb ) / ps_pps -> i1_num_tile_columns - ( i * ps_sps -> i2_pic_wd_in_ctb ) / ps_pps -> i1_num_tile_columns ; } for ( j = 0 ; j < ps_pps -> i1_num_tile_rows ; j ++ ) { ps_tile = ps_pps -> ps_tile + j * ps_pps -> i1_num_tile_columns + i ; ps_tile -> u1_pos_x = start ; ps_tile -> u2_wd = value ; } start += value ; if ( ( start > ps_sps -> i2_pic_wd_in_ctb ) || ( value <= 0 ) ) return IHEVCD_INVALID_HEADER ; } start = 0 ; for ( i = 0 ; i < ( ps_pps -> i1_num_tile_rows ) ; i ++ ) { tile_t * ps_tile ; if ( ! ps_pps -> i1_uniform_spacing_flag ) { if ( i < ( ps_pps -> i1_num_tile_rows - 1 ) ) { UEV_PARSE ( ""row_height_minus1[i]"" , value , ps_bitstrm ) ; value += 1 ; } else { value = ps_sps -> i2_pic_ht_in_ctb - start ; } } else { value = ( ( i + 1 ) * ps_sps -> i2_pic_ht_in_ctb ) / ps_pps -> i1_num_tile_rows - ( i * ps_sps -> i2_pic_ht_in_ctb ) / ps_pps -> i1_num_tile_rows ; } for ( j = 0 ; j < ps_pps -> i1_num_tile_columns ; j ++ ) { ps_tile = ps_pps -> ps_tile + i * ps_pps -> i1_num_tile_columns + j ; ps_tile -> u1_pos_y = start ; ps_tile -> u2_ht = value ; } start += value ; if ( ( start > ps_sps -> i2_pic_ht_in_ctb ) || ( value <= 0 ) ) return IHEVCD_INVALID_HEADER ; } } BITS_PARSE ( ""loop_filter_across_tiles_enabled_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_loop_filter_across_tiles_enabled_flag = value ; } else { ps_pps -> i1_num_tile_columns = 1 ; ps_pps -> i1_num_tile_rows = 1 ; ps_pps -> i1_uniform_spacing_flag = 1 ; ps_pps -> ps_tile -> u1_pos_x = 0 ; ps_pps -> ps_tile -> u1_pos_y = 0 ; ps_pps -> ps_tile -> u2_wd = ps_sps -> i2_pic_wd_in_ctb ; ps_pps -> ps_tile -> u2_ht = ps_sps -> i2_pic_ht_in_ctb ; } BITS_PARSE ( ""loop_filter_across_slices_enabled_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_loop_filter_across_slices_enabled_flag = value ; BITS_PARSE ( ""deblocking_filter_control_present_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_deblocking_filter_control_present_flag = value ; ps_pps -> i1_pic_disable_deblocking_filter_flag = 0 ; ps_pps -> i1_deblocking_filter_override_enabled_flag = 0 ; ps_pps -> i1_beta_offset_div2 = 0 ; ps_pps -> i1_tc_offset_div2 = 0 ; if ( ps_pps -> i1_deblocking_filter_control_present_flag ) { BITS_PARSE ( ""deblocking_filter_override_enabled_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_deblocking_filter_override_enabled_flag = value ; BITS_PARSE ( ""pic_disable_deblocking_filter_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_pic_disable_deblocking_filter_flag = value ; if ( ! ps_pps -> i1_pic_disable_deblocking_filter_flag ) { SEV_PARSE ( ""pps_beta_offset_div2"" , value , ps_bitstrm ) ; ps_pps -> i1_beta_offset_div2 = value ; SEV_PARSE ( ""pps_tc_offset_div2"" , value , ps_bitstrm ) ; ps_pps -> i1_tc_offset_div2 = value ; } } BITS_PARSE ( ""pps_scaling_list_data_present_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_pps_scaling_list_data_present_flag = value ; if ( ps_pps -> i1_pps_scaling_list_data_present_flag ) { COPY_DEFAULT_SCALING_LIST ( ps_pps -> pi2_scaling_mat ) ; ihevcd_scaling_list_data ( ps_codec , ps_pps -> pi2_scaling_mat ) ; } BITS_PARSE ( ""lists_modification_present_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_lists_modification_present_flag = value ; UEV_PARSE ( ""log2_parallel_merge_level_minus2"" , value , ps_bitstrm ) ; ps_pps -> i1_log2_parallel_merge_level = value + 2 ; BITS_PARSE ( ""slice_header_extension_present_flag"" , value , ps_bitstrm , 1 ) ; ps_pps -> i1_slice_header_extension_present_flag = value ; BITS_PARSE ( ""pps_extension_flag"" , value , ps_bitstrm , 1 ) ; ps_codec -> i4_pps_done = 1 ; return ret ; } "," i1_tiles_enabled_flag ) { WORD32 wd = ALIGN64 ( ps_codec -> i4_wd ) ; WORD32 ht = ALIGN64 ( ps_codec -> i4_ht ) ; WORD32 max_tile_cols = ( wd + MIN_TILE_WD - 1 ) / MIN_TILE_WD ; WORD32 max_tile_rows = ( ht + MIN_TILE_HT - 1 ) / MIN_TILE_HT ; -> i1_num_tile_columns > max_tile_cols ) || ( -> i1_num_tile_rows > max_tile_rows ) ) return ",external@libhevc/ebaa71da6362c497310377df509651974401d258,CVE-2017-0637,https://android.googlesource.com/platform/external/libhevc/+/ebaa71da6362c497310377df509651974401d258,2017-06-14T13:29Z 1019,CWE-119,"CWE-119 static int gfs2_bmap_alloc ( struct inode * inode , const sector_t lblock , struct buffer_head * bh_map , struct metapath * mp , const unsigned int sheight , const unsigned int height , const unsigned int maxlen ) { struct gfs2_inode * ip = GFS2_I ( inode ) ; struct gfs2_sbd * sdp = GFS2_SB ( inode ) ; struct buffer_head * dibh = mp -> mp_bh [ 0 ] ; u64 bn , dblock = 0 ; unsigned n , i , blks , alloced = 0 , iblks = 0 , branch_start = 0 ; unsigned dblks = 0 ; unsigned ptrs_per_blk ; const unsigned end_of_metadata = height - 1 ; int eob = 0 ; enum alloc_state state ; __be64 * ptr ; __be64 zero_bn = 0 ; BUG_ON ( sheight < 1 ) ; BUG_ON ( dibh == NULL ) ; gfs2_trans_add_bh ( ip -> i_gl , dibh , 1 ) ; if ( height == sheight ) { struct buffer_head * bh ; ptr = metapointer ( end_of_metadata , mp ) ; bh = mp -> mp_bh [ end_of_metadata ] ; dblks = gfs2_extent_length ( bh -> b_data , bh -> b_size , ptr , maxlen , & eob ) ; BUG_ON ( dblks < 1 ) ; state = ALLOC_DATA ; } else { ptrs_per_blk = height > 1 ? sdp -> sd_inptrs : sdp -> sd_diptrs ; dblks = min ( maxlen , ptrs_per_blk - mp -> mp_list [ end_of_metadata ] ) ; if ( height == ip -> i_height ) { iblks = height - sheight ; state = ALLOC_GROW_DEPTH ; } else { state = ALLOC_GROW_HEIGHT ; iblks = height - ip -> i_height ; branch_start = metapath_branch_start ( mp ) ; iblks += ( height - branch_start ) ; } } blks = dblks + iblks ; i = sheight ; do { int error ; n = blks - alloced ; error = gfs2_alloc_block ( ip , & bn , & n ) ; if ( error ) return error ; alloced += n ; if ( state != ALLOC_DATA || gfs2_is_jdata ( ip ) ) gfs2_trans_add_unrevoke ( sdp , bn , n ) ; switch ( state ) { case ALLOC_GROW_HEIGHT : if ( i == 1 ) { ptr = ( __be64 * ) ( dibh -> b_data + sizeof ( struct gfs2_dinode ) ) ; zero_bn = * ptr ; } for ( ; i - 1 < height - ip -> i_height && n > 0 ; i ++ , n -- ) gfs2_indirect_init ( mp , ip -> i_gl , i , 0 , bn ++ ) ; if ( i - 1 == height - ip -> i_height ) { i -- ; gfs2_buffer_copy_tail ( mp -> mp_bh [ i ] , sizeof ( struct gfs2_meta_header ) , dibh , sizeof ( struct gfs2_dinode ) ) ; gfs2_buffer_clear_tail ( dibh , sizeof ( struct gfs2_dinode ) + sizeof ( __be64 ) ) ; ptr = ( __be64 * ) ( mp -> mp_bh [ i ] -> b_data + sizeof ( struct gfs2_meta_header ) ) ; * ptr = zero_bn ; state = ALLOC_GROW_DEPTH ; for ( i = branch_start ; i < height ; i ++ ) { if ( mp -> mp_bh [ i ] == NULL ) break ; brelse ( mp -> mp_bh [ i ] ) ; mp -> mp_bh [ i ] = NULL ; } i = branch_start ; } if ( n == 0 ) break ; case ALLOC_GROW_DEPTH : if ( i > 1 && i < height ) gfs2_trans_add_bh ( ip -> i_gl , mp -> mp_bh [ i - 1 ] , 1 ) ; for ( ; i < height && n > 0 ; i ++ , n -- ) gfs2_indirect_init ( mp , ip -> i_gl , i , mp -> mp_list [ i - 1 ] , bn ++ ) ; if ( i == height ) state = ALLOC_DATA ; if ( n == 0 ) break ; case ALLOC_DATA : BUG_ON ( n > dblks ) ; BUG_ON ( mp -> mp_bh [ end_of_metadata ] == NULL ) ; gfs2_trans_add_bh ( ip -> i_gl , mp -> mp_bh [ end_of_metadata ] , 1 ) ; dblks = n ; ptr = metapointer ( end_of_metadata , mp ) ; dblock = bn ; while ( n -- > 0 ) * ptr ++ = cpu_to_be64 ( bn ++ ) ; break ; } } while ( ( state != ALLOC_DATA ) || ! dblock ) ; ip -> i_height = height ; gfs2_add_inode_blocks ( & ip -> i_inode , alloced ) ; gfs2_dinode_out ( ip , mp -> mp_bh [ 0 ] -> b_data ) ; map_bh ( bh_map , inode -> i_sb , dblock ) ; bh_map -> b_size = dblks << inode -> i_blkbits ; set_buffer_new ( bh_map ) ; return 0 ; } "," ) ; struct super_block * sb = sdp -> sd_vfs ; struct height - 1 ; int ret ++ ) ; if ( buffer_zeronew ( bh_map ) ) { ret = sb_issue_zeroout ( sb , dblock , dblks , GFP_NOFS ) ; if ( ret ) { fs_err ( sdp , ""Failedtozerodatabuffers\\n"" ) ; clear_buffer_zeronew ( bh_map ) ; } } ",torvalds@linux/64dd153c83743af81f20924c6343652d731eeecb,CVE-2011-4098,https://github.com/torvalds/linux/commit/64dd153c83743af81f20924c6343652d731eeecb,2013-06-08T13:05Z 1020,CWE-119,"CWE-119 int psf_binheader_writef ( SF_PRIVATE * psf , const char * format , ... ) { va_list argptr ; sf_count_t countdata ; unsigned long longdata ; unsigned int data ; float floatdata ; double doubledata ; void * bindata ; size_t size ; char c , * strptr ; int count = 0 , trunc_8to4 ; trunc_8to4 = SF_FALSE ; va_start ( argptr , format ) ; while ( ( c = * format ++ ) ) { switch ( c ) { case '' : break ; case 'e' : psf -> rwf_endian = SF_ENDIAN_LITTLE ; break ; case 'E' : psf -> rwf_endian = SF_ENDIAN_BIG ; break ; case 't' : trunc_8to4 = SF_TRUE ; break ; case 'T' : trunc_8to4 = SF_FALSE ; break ; case 'm' : data = va_arg ( argptr , unsigned int ) ; header_put_marker ( psf , data ) ; count += 4 ; break ; case '1' : data = va_arg ( argptr , unsigned int ) ; header_put_byte ( psf , data ) ; count += 1 ; break ; case '2' : data = va_arg ( argptr , unsigned int ) ; if ( psf -> rwf_endian == SF_ENDIAN_BIG ) { header_put_be_short ( psf , data ) ; } else { header_put_le_short ( psf , data ) ; } ; count += 2 ; break ; case '3' : data = va_arg ( argptr , unsigned int ) ; if ( psf -> rwf_endian == SF_ENDIAN_BIG ) { header_put_be_3byte ( psf , data ) ; } else { header_put_le_3byte ( psf , data ) ; } ; count += 3 ; break ; case '4' : data = va_arg ( argptr , unsigned int ) ; if ( psf -> rwf_endian == SF_ENDIAN_BIG ) { header_put_be_int ( psf , data ) ; } else { header_put_le_int ( psf , data ) ; } ; count += 4 ; break ; case '8' : countdata = va_arg ( argptr , sf_count_t ) ; if ( psf -> rwf_endian == SF_ENDIAN_BIG && trunc_8to4 == SF_FALSE ) { header_put_be_8byte ( psf , countdata ) ; count += 8 ; } else if ( psf -> rwf_endian == SF_ENDIAN_LITTLE && trunc_8to4 == SF_FALSE ) { header_put_le_8byte ( psf , countdata ) ; count += 8 ; } else if ( psf -> rwf_endian == SF_ENDIAN_BIG && trunc_8to4 == SF_TRUE ) { longdata = countdata & 0xFFFFFFFF ; header_put_be_int ( psf , longdata ) ; count += 4 ; } else if ( psf -> rwf_endian == SF_ENDIAN_LITTLE && trunc_8to4 == SF_TRUE ) { longdata = countdata & 0xFFFFFFFF ; header_put_le_int ( psf , longdata ) ; count += 4 ; } break ; case 'f' : floatdata = ( float ) va_arg ( argptr , double ) ; if ( psf -> rwf_endian == SF_ENDIAN_BIG ) float32_be_write ( floatdata , psf -> header + psf -> headindex ) ; else float32_le_write ( floatdata , psf -> header + psf -> headindex ) ; psf -> headindex += 4 ; count += 4 ; break ; case 'd' : doubledata = va_arg ( argptr , double ) ; if ( psf -> rwf_endian == SF_ENDIAN_BIG ) double64_be_write ( doubledata , psf -> header + psf -> headindex ) ; else double64_le_write ( doubledata , psf -> header + psf -> headindex ) ; psf -> headindex += 8 ; count += 8 ; break ; case 's' : strptr = va_arg ( argptr , char * ) ; size = strlen ( strptr ) + 1 ; size += ( size & 1 ) ; if ( psf -> rwf_endian == SF_ENDIAN_BIG ) header_put_be_int ( psf , size ) ; else header_put_le_int ( psf , size ) ; memcpy ( & ( psf -> header [ psf -> headindex ] ) , strptr , size ) ; psf -> headindex += size ; psf -> header [ psf -> headindex - 1 ] = 0 ; count += 4 + size ; break ; case 'S' : strptr = va_arg ( argptr , char * ) ; size = strlen ( strptr ) ; if ( psf -> rwf_endian == SF_ENDIAN_BIG ) header_put_be_int ( psf , size ) ; else header_put_le_int ( psf , size ) ; memcpy ( & ( psf -> header [ psf -> headindex ] ) , strptr , size + 1 ) ; size += ( size & 1 ) ; psf -> headindex += size ; psf -> header [ psf -> headindex ] = 0 ; count += 4 + size ; break ; case 'p' : strptr = va_arg ( argptr , char * ) ; size = strlen ( strptr ) ; size = ( size & 1 ) ? size : size + 1 ; size = ( size > 254 ) ? 254 : size ; header_put_byte ( psf , size ) ; memcpy ( & ( psf -> header [ psf -> headindex ] ) , strptr , size ) ; psf -> headindex += size ; count += 1 + size ; break ; case 'b' : bindata = va_arg ( argptr , void * ) ; size = va_arg ( argptr , size_t ) ; if ( psf -> headindex + size < sizeof ( psf -> header ) ) { memcpy ( & ( psf -> header [ psf -> headindex ] ) , bindata , size ) ; psf -> headindex += size ; count += size ; } ; break ; case 'z' : size = va_arg ( argptr , size_t ) ; count += size ; while ( size ) { psf -> header [ psf -> headindex ] = 0 ; psf -> headindex ++ ; size -- ; } ; break ; case 'h' : bindata = va_arg ( argptr , void * ) ; memcpy ( & ( psf -> header [ psf -> headindex ] ) , bindata , 16 ) ; psf -> headindex += 16 ; count += 16 ; break ; case 'j' : size = va_arg ( argptr , size_t ) ; psf -> headindex += size ; count += size ; break ; case 'o' : size = va_arg ( argptr , size_t ) ; if ( size < sizeof ( psf -> header ) ) { psf -> headindex = size ; count = 0 ; } ; break ; default : psf_log_printf ( psf , ""***Invalidformatspecifier`%c\'\\n"" , c ) ; psf -> error = SFE_INTERNAL ; break ; } ; } ; va_end ( argptr ) ; return count ; } "," ) ) { if ( psf -> header . indx + 16 >= psf -> header . len && psf_bump_header_allocation ( psf , 16 ) ) return count ; psf -> header . ptr + psf -> header . indx ) ; else psf -> header . ptr + psf -> header . indx ) ; psf -> header . indx += 4 ; psf -> header . ptr + psf -> header . indx ) ; else psf -> header . ptr + psf -> header . indx ) ; psf -> header . indx += 8 ; & 1 ) ; if ( psf -> header . indx + ( sf_count_t ) size >= psf -> header . len && psf_bump_header_allocation ( psf , 16 ) ) return count psf -> header . ptr [ psf -> header . indx ] ) , ; psf -> header . indx += size ; psf -> header . ptr [ psf -> [ psf -> header . indx - 1 ] ( psf -> header . indx + ( sf_count_t ) size > psf -> header . len && psf_bump_header_allocation ( psf , size ) ) return count ; if ( psf -> psf -> header . ptr [ psf -> header . indx ] ) , ; psf -> header . indx += size ; psf -> header . ptr [ psf -> [ psf -> header . indx ] = 0 : size ; if ( psf -> header . indx + ( sf_count_t ) size > psf -> header . len && psf_bump_header_allocation ( psf , size ) ) return count ; psf -> header . ptr [ psf -> header . indx ] ) , ; psf -> header . indx += size ; ( psf -> header . indx + ( sf_count_t ) size > psf -> header . len && psf_bump_header_allocation ( psf , size ) ) return count ; memcpy ( & ( psf -> header . ptr [ psf -> header . indx ] ) , bindata , size ) ; psf -> header . indx += size ; count += size ; break ; case 'z' : size = va_arg ( argptr , size_t ) ; if ( psf -> header . indx + ( sf_count_t ) size > psf -> header . len && psf_bump_header_allocation ( psf , size ) ) return count ; count += size ; while ( size ) { psf -> header . ptr [ psf -> [ psf -> header . indx ] = 0 ; ; psf -> header . indx ++ ; size psf -> header . ptr [ psf -> header . indx ] ) , ; psf -> header . indx += 16 ; size_t ) ; if ( psf -> header . indx + ( sf_count_t ) size > psf -> header . len && psf_bump_header_allocation ( psf , size ) ) return count ; psf -> header . indx += size ; ; if ( ( sf_count_t ) size >= psf -> header . len && psf_bump_header_allocation ( psf , size ) ) return count ; psf -> header . indx = size ; break ; ",erikd@libsndfile/708e996c87c5fae77b104ccfeb8f6db784c32074,CVE-2017-7586,https://github.com/erikd/libsndfile/commit/708e996c87c5fae77b104ccfeb8f6db784c32074,2017-04-07T20:59Z 1021,CWE-125,"CWE-125 static int cx24116_send_diseqc_msg ( struct dvb_frontend * fe , struct dvb_diseqc_master_cmd * d ) { struct cx24116_state * state = fe -> demodulator_priv ; int i , ret ; if ( debug ) { printk ( KERN_INFO ""cx24116:%s("" , __func__ ) ; for ( i = 0 ; i < d -> msg_len ; ) { printk ( KERN_INFO ""0x%02x"" , d -> msg [ i ] ) ; if ( ++ i < d -> msg_len ) printk ( KERN_INFO "","" ) ; } printk ( "")toneburst=%d\\n"" , toneburst ) ; } if ( d -> msg_len > ( CX24116_ARGLEN - CX24116_DISEQC_MSGOFS ) ) return - EINVAL ; for ( i = 0 ; i < d -> msg_len ; i ++ ) state -> dsec_cmd . args [ CX24116_DISEQC_MSGOFS + i ] = d -> msg [ i ] ; state -> dsec_cmd . args [ CX24116_DISEQC_MSGLEN ] = d -> msg_len ; state -> dsec_cmd . len = CX24116_DISEQC_MSGOFS + state -> dsec_cmd . args [ CX24116_DISEQC_MSGLEN ] ; if ( toneburst == CX24116_DISEQC_MESGCACHE ) return 0 ; else if ( toneburst == CX24116_DISEQC_TONEOFF ) state -> dsec_cmd . args [ CX24116_DISEQC_BURST ] = 0 ; else if ( toneburst == CX24116_DISEQC_TONECACHE ) { if ( d -> msg_len >= 4 && d -> msg [ 2 ] == 0x38 ) state -> dsec_cmd . args [ CX24116_DISEQC_BURST ] = ( ( d -> msg [ 3 ] & 4 ) >> 2 ) ; if ( debug ) dprintk ( ""%sburst=%d\\n"" , __func__ , state -> dsec_cmd . args [ CX24116_DISEQC_BURST ] ) ; } ret = cx24116_wait_for_lnb ( fe ) ; if ( ret != 0 ) return ret ; msleep ( 100 ) ; ret = cx24116_cmd_execute ( fe , & state -> dsec_cmd ) ; if ( ret != 0 ) return ret ; msleep ( ( state -> dsec_cmd . args [ CX24116_DISEQC_MSGLEN ] << 4 ) + ( ( toneburst == CX24116_DISEQC_TONEOFF ) ? 30 : 60 ) ) ; return 0 ; } "," ; if ( d -> msg_len > sizeof ( d -> msg ) ) return - EINVAL ; if ( ) ; } for ( i ",torvalds@linux/1fa2337a315a2448c5434f41e00d56b01a22283c,CVE-2015-9289,https://github.com/torvalds/linux/commit/1fa2337a315a2448c5434f41e00d56b01a22283c,2019-07-27T22:15Z 1022,CWE-200,"CWE-200 static int sco_sock_getsockopt_old ( struct socket * sock , int optname , char __user * optval , int __user * optlen ) { struct sock * sk = sock -> sk ; struct sco_options opts ; struct sco_conninfo cinfo ; int len , err = 0 ; BT_DBG ( ""sk%p"" , sk ) ; if ( get_user ( len , optlen ) ) return - EFAULT ; lock_sock ( sk ) ; switch ( optname ) { case SCO_OPTIONS : if ( sk -> sk_state != BT_CONNECTED ) { err = - ENOTCONN ; break ; } opts . mtu = sco_pi ( sk ) -> conn -> mtu ; BT_DBG ( ""mtu%d"" , opts . mtu ) ; len = min_t ( unsigned int , len , sizeof ( opts ) ) ; if ( copy_to_user ( optval , ( char * ) & opts , len ) ) err = - EFAULT ; break ; case SCO_CONNINFO : if ( sk -> sk_state != BT_CONNECTED ) { err = - ENOTCONN ; break ; } cinfo . hci_handle = sco_pi ( sk ) -> conn -> hcon -> handle ; memcpy ( cinfo . dev_class , sco_pi ( sk ) -> conn -> hcon -> dev_class , 3 ) ; len = min_t ( unsigned int , len , sizeof ( cinfo ) ) ; if ( copy_to_user ( optval , ( char * ) & cinfo , len ) ) err = - EFAULT ; break ; default : err = - ENOPROTOOPT ; break ; } release_sock ( sk ) ; return err ; } "," break ; } memset ( & cinfo , 0 , sizeof ( cinfo ) ) ; ",torvalds@linux/c4c896e1471aec3b004a693c689f60be3b17ac86,CVE-2011-1078,https://github.com/torvalds/linux/commit/c4c896e1471aec3b004a693c689f60be3b17ac86,2012-06-21T23:55Z 1023,CWE-125,"CWE-125 static Image * ReadSUNImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define RMT_EQUAL_RGB 1 # define RMT_NONE 0 # define RMT_RAW 2 # define RT_STANDARD 1 # define RT_ENCODED 2 # define RT_FORMAT_RGB 3 typedef struct _SUNInfo { unsigned int magic , width , height , depth , length , type , maptype , maplength ; } SUNInfo ; Image * image ; int bit ; MagickBooleanType status ; MagickSizeType number_pixels ; register Quantum * q ; register ssize_t i , x ; register unsigned char * p ; size_t bytes_per_line , extent , length ; ssize_t count , y ; SUNInfo sun_info ; unsigned char * sun_data , * sun_pixels ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } ( void ) ResetMagickMemory ( & sun_info , 0 , sizeof ( sun_info ) ) ; sun_info . magic = ReadBlobMSBLong ( image ) ; do { if ( sun_info . magic != 0x59a66a95 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; sun_info . width = ReadBlobMSBLong ( image ) ; sun_info . height = ReadBlobMSBLong ( image ) ; sun_info . depth = ReadBlobMSBLong ( image ) ; sun_info . length = ReadBlobMSBLong ( image ) ; sun_info . type = ReadBlobMSBLong ( image ) ; sun_info . maptype = ReadBlobMSBLong ( image ) ; sun_info . maplength = ReadBlobMSBLong ( image ) ; extent = sun_info . height * sun_info . width ; if ( ( sun_info . height != 0 ) && ( sun_info . width != extent / sun_info . height ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ( sun_info . type != RT_STANDARD ) && ( sun_info . type != RT_ENCODED ) && ( sun_info . type != RT_FORMAT_RGB ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ( sun_info . maptype == RMT_NONE ) && ( sun_info . maplength != 0 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ( sun_info . depth == 0 ) || ( sun_info . depth > 32 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ( sun_info . maptype != RMT_NONE ) && ( sun_info . maptype != RMT_EQUAL_RGB ) && ( sun_info . maptype != RMT_RAW ) ) ThrowReaderException ( CoderError , ""ColormapTypeNotSupported"" ) ; image -> columns = sun_info . width ; image -> rows = sun_info . height ; image -> depth = sun_info . depth <= 8 ? sun_info . depth : MAGICKCORE_QUANTUM_DEPTH ; if ( sun_info . depth < 24 ) { size_t one ; image -> colors = sun_info . maplength ; one = 1 ; if ( sun_info . maptype == RMT_NONE ) image -> colors = one << sun_info . depth ; if ( sun_info . maptype == RMT_EQUAL_RGB ) image -> colors = sun_info . maplength / 3 ; if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; } switch ( sun_info . maptype ) { case RMT_NONE : break ; case RMT_EQUAL_RGB : { unsigned char * sun_colormap ; sun_colormap = ( unsigned char * ) AcquireQuantumMemory ( image -> colors , sizeof ( * sun_colormap ) ) ; if ( sun_colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; count = ReadBlob ( image , image -> colors , sun_colormap ) ; if ( count != ( ssize_t ) image -> colors ) ThrowReaderException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) image -> colormap [ i ] . red = ( MagickRealType ) ScaleCharToQuantum ( sun_colormap [ i ] ) ; count = ReadBlob ( image , image -> colors , sun_colormap ) ; if ( count != ( ssize_t ) image -> colors ) ThrowReaderException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) image -> colormap [ i ] . green = ( MagickRealType ) ScaleCharToQuantum ( sun_colormap [ i ] ) ; count = ReadBlob ( image , image -> colors , sun_colormap ) ; if ( count != ( ssize_t ) image -> colors ) ThrowReaderException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) image -> colormap [ i ] . blue = ( MagickRealType ) ScaleCharToQuantum ( sun_colormap [ i ] ) ; sun_colormap = ( unsigned char * ) RelinquishMagickMemory ( sun_colormap ) ; break ; } case RMT_RAW : { unsigned char * sun_colormap ; sun_colormap = ( unsigned char * ) AcquireQuantumMemory ( sun_info . maplength , sizeof ( * sun_colormap ) ) ; if ( sun_colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; count = ReadBlob ( image , sun_info . maplength , sun_colormap ) ; if ( count != ( ssize_t ) sun_info . maplength ) ThrowReaderException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; sun_colormap = ( unsigned char * ) RelinquishMagickMemory ( sun_colormap ) ; break ; } default : ThrowReaderException ( CoderError , ""ColormapTypeNotSupported"" ) ; } image -> alpha_trait = sun_info . depth == 32 ? BlendPixelTrait : UndefinedPixelTrait ; image -> columns = sun_info . width ; image -> rows = sun_info . height ; if ( image_info -> ping != MagickFalse ) { ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; if ( ( sun_info . length * sizeof ( * sun_data ) ) / sizeof ( * sun_data ) != sun_info . length || ! sun_info . length ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; number_pixels = ( MagickSizeType ) image -> columns * image -> rows ; if ( ( sun_info . type != RT_ENCODED ) && ( sun_info . depth >= 8 ) && ( ( number_pixels * ( ( sun_info . depth + 7 ) / 8 ) ) > sun_info . length ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; bytes_per_line = sun_info . width * sun_info . depth ; sun_data = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) MagickMax ( sun_info . length , bytes_per_line * sun_info . width ) , sizeof ( * sun_data ) ) ; if ( sun_data == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; count = ( ssize_t ) ReadBlob ( image , sun_info . length , sun_data ) ; if ( count != ( ssize_t ) sun_info . length ) ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; sun_pixels = sun_data ; bytes_per_line = 0 ; if ( sun_info . type == RT_ENCODED ) { size_t height ; height = sun_info . height ; if ( ( height == 0 ) || ( sun_info . width == 0 ) || ( sun_info . depth == 0 ) || ( ( bytes_per_line / sun_info . depth ) != sun_info . width ) ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; bytes_per_line += 15 ; bytes_per_line <<= 1 ; if ( ( bytes_per_line >> 1 ) != ( sun_info . width * sun_info . depth + 15 ) ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; bytes_per_line >>= 4 ; sun_pixels = ( unsigned char * ) AcquireQuantumMemory ( height , bytes_per_line * sizeof ( * sun_pixels ) ) ; if ( sun_pixels == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; ( void ) DecodeImage ( sun_data , sun_info . length , sun_pixels , bytes_per_line * height ) ; sun_data = ( unsigned char * ) RelinquishMagickMemory ( sun_data ) ; } p = sun_pixels ; if ( sun_info . depth == 1 ) for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ( ssize_t ) image -> columns - 7 ) ; x += 8 ) { for ( bit = 7 ; bit >= 0 ; bit -- ) { SetPixelIndex ( image , ( Quantum ) ( ( * p ) & ( 0x01 << bit ) ? 0x00 : 0x01 ) , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } if ( ( image -> columns % 8 ) != 0 ) { for ( bit = 7 ; bit >= ( int ) ( 8 - ( image -> columns % 8 ) ) ; bit -- ) { SetPixelIndex ( image , ( Quantum ) ( ( * p ) & ( 0x01 << bit ) ? 0x00 : 0x01 ) , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } if ( ( ( ( image -> columns / 8 ) + ( image -> columns % 8 ? 1 : 0 ) ) % 2 ) != 0 ) p ++ ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } else if ( image -> storage_class == PseudoClass ) { if ( bytes_per_line == 0 ) bytes_per_line = image -> columns ; length = image -> rows * ( image -> columns + image -> columns % 2 ) ; if ( ( ( sun_info . type == RT_ENCODED ) && ( length > ( bytes_per_line * image -> rows ) ) ) || ( ( sun_info . type != RT_ENCODED ) && ( length > sun_info . length ) ) ) ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelIndex ( image , * p ++ , q ) ; q += GetPixelChannels ( image ) ; } if ( ( image -> columns % 2 ) != 0 ) p ++ ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } else { size_t bytes_per_pixel ; bytes_per_pixel = 3 ; if ( image -> alpha_trait != UndefinedPixelTrait ) bytes_per_pixel ++ ; if ( bytes_per_line == 0 ) bytes_per_line = bytes_per_pixel * image -> columns ; length = image -> rows * ( bytes_per_line + image -> columns % 2 ) ; if ( ( ( sun_info . type == RT_ENCODED ) && ( length > ( bytes_per_line * image -> rows ) ) ) || ( ( sun_info . type != RT_ENCODED ) && ( length > sun_info . length ) ) ) ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { if ( image -> alpha_trait != UndefinedPixelTrait ) SetPixelAlpha ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; if ( sun_info . type == RT_STANDARD ) { SetPixelBlue ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelGreen ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelRed ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; } else { SetPixelRed ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelGreen ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelBlue ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; } if ( image -> colors != 0 ) { SetPixelRed ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) GetPixelRed ( image , q ) ] . red ) , q ) ; SetPixelGreen ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) GetPixelGreen ( image , q ) ] . green ) , q ) ; SetPixelBlue ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) GetPixelBlue ( image , q ) ] . blue ) , q ) ; } q += GetPixelChannels ( image ) ; } if ( ( ( bytes_per_pixel * image -> columns ) % 2 ) != 0 ) p ++ ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } if ( image -> storage_class == PseudoClass ) ( void ) SyncImage ( image , exception ) ; sun_pixels = ( unsigned char * ) RelinquishMagickMemory ( sun_pixels ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; sun_info . magic = ReadBlobMSBLong ( image ) ; if ( sun_info . magic == 0x59a66a95 ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( sun_info . magic == 0x59a66a95 ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," RT_ENCODED ) && ( ( number_pixels * sun_info . depth sun_info . depth ) > ( 8 * sun_info . length sun_info . length ) ( bytes_per_line + bytes_per_line % 2 ) ",ImageMagick@ImageMagick/b8f17d08b7418204bf8a05a5c24e87b2fc395b75,CVE-2015-8958,https://github.com/ImageMagick/ImageMagick/commit/b8f17d08b7418204bf8a05a5c24e87b2fc395b75,2017-04-20T18:59Z 1024,CWE-269,"CWE-269 static int store_xauthority ( void ) { fs_build_mnt_dir ( ) ; char * src ; char * dest = RUN_XAUTHORITY_FILE ; FILE * fp = fopen ( dest , ""w"" ) ; if ( fp ) { fprintf ( fp , ""\\n"" ) ; SET_PERMS_STREAM ( fp , getuid ( ) , getgid ( ) , 0600 ) ; fclose ( fp ) ; } if ( asprintf ( & src , ""%s/.Xauthority"" , cfg . homedir ) == - 1 ) errExit ( ""asprintf"" ) ; struct stat s ; if ( stat ( src , & s ) == 0 ) { if ( is_link ( src ) ) { fprintf ( stderr , ""Warning:invalid.Xauthorityfile\\n"" ) ; return 0 ; } pid_t child = fork ( ) ; if ( child < 0 ) errExit ( ""fork"" ) ; if ( child == 0 ) { drop_privs ( 0 ) ; int rv = copy_file ( src , dest , getuid ( ) , getgid ( ) , 0600 ) ; if ( rv ) fprintf ( stderr , ""Warning:cannottransfer.Xauthorityinprivatehomedirectory\\n"" ) ; else { fs_logger2 ( ""clone"" , dest ) ; } _exit ( 0 ) ; } waitpid ( child , NULL , 0 ) ; return 1 ; } return 0 ; } "," 0 ; } copy_file_as_user ( src , 0600 ) ; fs_logger2 ( ""clone"" ""clone"" , dest ) ; return ",netblue30@firejail/b8a4ff9775318ca5e679183884a6a63f3da8f863,CVE-2017-5940,https://github.com/netblue30/firejail/commit/b8a4ff9775318ca5e679183884a6a63f3da8f863,2017-02-09T18:59Z 1025,CWE-20,"CWE-20 static gboolean parse_toshiba_packet ( FILE_T fh , struct wtap_pkthdr * phdr , Buffer * buf , int * err , gchar * * err_info ) { union wtap_pseudo_header * pseudo_header = & phdr -> pseudo_header ; char line [ TOSHIBA_LINE_LENGTH ] ; int num_items_scanned ; guint pkt_len ; int pktnum , hr , min , sec , csec ; char channel [ 10 ] , direction [ 10 ] ; int i , hex_lines ; guint8 * pd ; if ( file_gets ( line , TOSHIBA_LINE_LENGTH , fh ) == NULL ) { * err = file_error ( fh , err_info ) ; if ( * err == 0 ) { * err = WTAP_ERR_SHORT_READ ; } return FALSE ; } num_items_scanned = sscanf ( line , ""%9d]%2d:%2d:%2d.%9d%9s%9s"" , & pktnum , & hr , & min , & sec , & csec , channel , direction ) ; if ( num_items_scanned != 7 ) { * err = WTAP_ERR_BAD_FILE ; * err_info = g_strdup ( ""toshiba:recordheaderisn\'tvalid"" ) ; return FALSE ; } do { if ( file_gets ( line , TOSHIBA_LINE_LENGTH , fh ) == NULL ) { * err = file_error ( fh , err_info ) ; if ( * err == 0 ) { * err = WTAP_ERR_SHORT_READ ; } return FALSE ; } line [ 16 ] = '\\0' ; } while ( strcmp ( line , ""OFFSET0001-0203"" ) != 0 ) ; num_items_scanned = sscanf ( line + 64 , ""LEN=%9u"" , & pkt_len ) ; if ( num_items_scanned != 1 ) { * err = WTAP_ERR_BAD_FILE ; * err_info = g_strdup ( ""toshiba:OFFSETlinedoesn\'thavevalidLENitem"" ) ; return FALSE ; } if ( pkt_len > WTAP_MAX_PACKET_SIZE ) { * err = WTAP_ERR_BAD_FILE ; * err_info = g_strdup_printf ( ""toshiba:Filehas%u-bytepacket,biggerthanmaximumof%u"" , pkt_len , WTAP_MAX_PACKET_SIZE ) ; return FALSE ; } phdr -> rec_type = REC_TYPE_PACKET ; phdr -> presence_flags = WTAP_HAS_TS | WTAP_HAS_CAP_LEN ; phdr -> ts . secs = hr * 3600 + min * 60 + sec ; phdr -> ts . nsecs = csec * 10000000 ; phdr -> caplen = pkt_len ; phdr -> len = pkt_len ; switch ( channel [ 0 ] ) { case 'B' : phdr -> pkt_encap = WTAP_ENCAP_ISDN ; pseudo_header -> isdn . uton = ( direction [ 0 ] == 'T' ) ; pseudo_header -> isdn . channel = ( guint8 ) strtol ( & channel [ 1 ] , NULL , 10 ) ; break ; case 'D' : phdr -> pkt_encap = WTAP_ENCAP_ISDN ; pseudo_header -> isdn . uton = ( direction [ 0 ] == 'T' ) ; pseudo_header -> isdn . channel = 0 ; break ; default : phdr -> pkt_encap = WTAP_ENCAP_ETHERNET ; pseudo_header -> eth . fcs_len = - 1 ; break ; } ws_buffer_assure_space ( buf , pkt_len ) ; pd = ws_buffer_start_ptr ( buf ) ; hex_lines = pkt_len / 16 + ( ( pkt_len % 16 ) ? 1 : 0 ) ; for ( i = 0 ; i < hex_lines ; i ++ ) { if ( file_gets ( line , TOSHIBA_LINE_LENGTH , fh ) == NULL ) { * err = file_error ( fh , err_info ) ; if ( * err == 0 ) { * err = WTAP_ERR_SHORT_READ ; } return FALSE ; } if ( ! parse_single_hex_dump_line ( line , pd , i * 16 ) ) { * err = WTAP_ERR_BAD_FILE ; * err_info = g_strdup ( ""toshiba:hexdumpnotvalid"" ) ; return FALSE ; } } return TRUE ; } "," int num_items_scanned ; int pkt_len , pktnum , hr + 64 , ""LEN=%9d"" , & pkt_len g_strdup ( ""toshiba:OFFSETlinedoesn\'thavevalidLENitem"" ) ; return FALSE ; } if ( pkt_len < 0 ) { * err = WTAP_ERR_BAD_FILE ; * err_info = g_strdup ( ""toshiba:packetheaderhasanegativepacketlength"" ",wireshark@wireshark/3270dfac43da861c714df76513456b46765ff47f,CVE-2016-5355,https://github.com/wireshark/wireshark/commit/3270dfac43da861c714df76513456b46765ff47f,2016-08-07T16:59Z 1026,CWE-200,"CWE-200 static int iucv_sock_recvmsg ( struct kiocb * iocb , struct socket * sock , struct msghdr * msg , size_t len , int flags ) { int noblock = flags & MSG_DONTWAIT ; struct sock * sk = sock -> sk ; struct iucv_sock * iucv = iucv_sk ( sk ) ; unsigned int copied , rlen ; struct sk_buff * skb , * rskb , * cskb ; int err = 0 ; if ( ( sk -> sk_state == IUCV_DISCONN ) && skb_queue_empty ( & iucv -> backlog_skb_q ) && skb_queue_empty ( & sk -> sk_receive_queue ) && list_empty ( & iucv -> message_q . list ) ) return 0 ; if ( flags & ( MSG_OOB ) ) return - EOPNOTSUPP ; skb = skb_recv_datagram ( sk , flags , noblock , & err ) ; if ( ! skb ) { if ( sk -> sk_shutdown & RCV_SHUTDOWN ) return 0 ; return err ; } rlen = skb -> len ; copied = min_t ( unsigned int , rlen , len ) ; if ( ! rlen ) sk -> sk_shutdown = sk -> sk_shutdown | RCV_SHUTDOWN ; cskb = skb ; if ( skb_copy_datagram_iovec ( cskb , 0 , msg -> msg_iov , copied ) ) { if ( ! ( flags & MSG_PEEK ) ) skb_queue_head ( & sk -> sk_receive_queue , skb ) ; return - EFAULT ; } if ( sk -> sk_type == SOCK_SEQPACKET ) { if ( copied < rlen ) msg -> msg_flags |= MSG_TRUNC ; msg -> msg_flags |= MSG_EOR ; } err = put_cmsg ( msg , SOL_IUCV , SCM_IUCV_TRGCLS , CB_TRGCLS_LEN , CB_TRGCLS ( skb ) ) ; if ( err ) { if ( ! ( flags & MSG_PEEK ) ) skb_queue_head ( & sk -> sk_receive_queue , skb ) ; return err ; } if ( ! ( flags & MSG_PEEK ) ) { if ( sk -> sk_type == SOCK_STREAM ) { skb_pull ( skb , copied ) ; if ( skb -> len ) { skb_queue_head ( & sk -> sk_receive_queue , skb ) ; goto done ; } } kfree_skb ( skb ) ; if ( iucv -> transport == AF_IUCV_TRANS_HIPER ) { atomic_inc ( & iucv -> msg_recv ) ; if ( atomic_read ( & iucv -> msg_recv ) > iucv -> msglimit ) { WARN_ON ( 1 ) ; iucv_sock_close ( sk ) ; return - EFAULT ; } } spin_lock_bh ( & iucv -> message_q . lock ) ; rskb = skb_dequeue ( & iucv -> backlog_skb_q ) ; while ( rskb ) { if ( sock_queue_rcv_skb ( sk , rskb ) ) { skb_queue_head ( & iucv -> backlog_skb_q , rskb ) ; break ; } else { rskb = skb_dequeue ( & iucv -> backlog_skb_q ) ; } } if ( skb_queue_empty ( & iucv -> backlog_skb_q ) ) { if ( ! list_empty ( & iucv -> message_q . list ) ) iucv_process_message_q ( sk ) ; if ( atomic_read ( & iucv -> msg_recv ) >= iucv -> msglimit / 2 ) { err = iucv_send_ctrl ( sk , AF_IUCV_FLAG_WIN ) ; if ( err ) { sk -> sk_state = IUCV_DISCONN ; sk -> sk_state_change ( sk ) ; } } } spin_unlock_bh ( & iucv -> message_q . lock ) ; } done : if ( sk -> sk_type == SOCK_SEQPACKET && ( flags & MSG_TRUNC ) ) copied = rlen ; return copied ; } "," ; int err = 0 ; msg -> msg_namelen ",torvalds@linux/a5598bd9c087dc0efc250a5221e5d0e6f584ee88,CVE-2013-3229,https://github.com/torvalds/linux/commit/a5598bd9c087dc0efc250a5221e5d0e6f584ee88,2013-04-22T11:41Z 1027,CWE-000,"CWE-000 static inline int process_nested_data ( UNSERIALIZE_PARAMETER , HashTable * ht , long elements , int objprops ) { while ( elements -- > 0 ) { zval * key , * data , * * old_data ; ALLOC_INIT_ZVAL ( key ) ; if ( ! php_var_unserialize ( & key , p , max , NULL TSRMLS_CC ) ) { zval_dtor ( key ) ; FREE_ZVAL ( key ) ; return 0 ; } if ( Z_TYPE_P ( key ) != IS_LONG && Z_TYPE_P ( key ) != IS_STRING ) { zval_dtor ( key ) ; FREE_ZVAL ( key ) ; return 0 ; } ALLOC_INIT_ZVAL ( data ) ; if ( ! php_var_unserialize ( & data , p , max , var_hash TSRMLS_CC ) ) { zval_dtor ( key ) ; FREE_ZVAL ( key ) ; zval_dtor ( data ) ; FREE_ZVAL ( data ) ; return 0 ; } if ( ! objprops ) { switch ( Z_TYPE_P ( key ) ) { case IS_LONG : if ( zend_hash_index_find ( ht , Z_LVAL_P ( key ) , ( void * * ) & old_data ) == SUCCESS ) { var_push_dtor ( var_hash , old_data ) ; } zend_hash_index_update ( ht , Z_LVAL_P ( key ) , & data , sizeof ( data ) , NULL ) ; break ; case IS_STRING : if ( zend_symtable_find ( ht , Z_STRVAL_P ( key ) , Z_STRLEN_P ( key ) + 1 , ( void * * ) & old_data ) == SUCCESS ) { var_push_dtor ( var_hash , old_data ) ; } zend_symtable_update ( ht , Z_STRVAL_P ( key ) , Z_STRLEN_P ( key ) + 1 , & data , sizeof ( data ) , NULL ) ; break ; } } else { convert_to_string ( key ) ; if ( zend_symtable_find ( ht , Z_STRVAL_P ( key ) , Z_STRLEN_P ( key ) + 1 , ( void * * ) & old_data ) == SUCCESS ) { var_push_dtor ( var_hash , old_data ) ; } zend_hash_update ( ht , Z_STRVAL_P ( key ) , Z_STRLEN_P ( key ) + 1 , & data , sizeof data , NULL ) ; } zval_dtor ( key ) ; FREE_ZVAL ( key ) ; if ( elements && * ( * p - 1 ) != ';' && * ( * p - 1 ) != '}' ) { ( * p ) -- ; return 0 ; } } return 1 ; } "," ; if ( zend_hash_find ( ht , ",php@php-src/b585a3aed7880a5fa5c18e2b838fc96f40e075bd,CVE-2015-0231,https://github.com/php/php-src/commit/b585a3aed7880a5fa5c18e2b838fc96f40e075bd,2015-01-27T20:03Z 1028,CWE-200,"CWE-200 static int tipc_nl_compat_link_dump ( struct tipc_nl_compat_msg * msg , struct nlattr * * attrs ) { struct nlattr * link [ TIPC_NLA_LINK_MAX + 1 ] ; struct tipc_link_info link_info ; int err ; if ( ! attrs [ TIPC_NLA_LINK ] ) return - EINVAL ; err = nla_parse_nested ( link , TIPC_NLA_LINK_MAX , attrs [ TIPC_NLA_LINK ] , NULL ) ; if ( err ) return err ; link_info . dest = nla_get_flag ( link [ TIPC_NLA_LINK_DEST ] ) ; link_info . up = htonl ( nla_get_flag ( link [ TIPC_NLA_LINK_UP ] ) ) ; strcpy ( link_info . str , nla_data ( link [ TIPC_NLA_LINK_NAME ] ) ) ; return tipc_add_tlv ( msg -> rep , TIPC_TLV_LINK_INFO , & link_info , sizeof ( link_info ) ) ; } "," ) ) ; nla_strlcpy ( link_info . TIPC_NLA_LINK_NAME ] ) , TIPC_MAX_LINK_NAME ",torvalds@linux/5d2be1422e02ccd697ccfcd45c85b4a26e6178e2,CVE-2016-5243,https://github.com/torvalds/linux/commit/5d2be1422e02ccd697ccfcd45c85b4a26e6178e2,2016-06-27T10:59Z 1029,CWE-416,"CWE-416 int ipmi_si_mem_setup ( struct si_sm_io * io ) { unsigned long addr = io -> addr_data ; int mapsize , idx ; if ( ! addr ) return - ENODEV ; io -> io_cleanup = mem_cleanup ; switch ( io -> regsize ) { case 1 : io -> inputb = intf_mem_inb ; io -> outputb = intf_mem_outb ; break ; case 2 : io -> inputb = intf_mem_inw ; io -> outputb = intf_mem_outw ; break ; case 4 : io -> inputb = intf_mem_inl ; io -> outputb = intf_mem_outl ; break ; # ifdef readq case 8 : io -> inputb = mem_inq ; io -> outputb = mem_outq ; break ; # endif default : dev_warn ( io -> dev , ""Invalidregistersize:%d\\n"" , io -> regsize ) ; return - EINVAL ; } for ( idx = 0 ; idx < io -> io_size ; idx ++ ) { if ( request_mem_region ( addr + idx * io -> regspacing , io -> regsize , DEVICE_NAME ) == NULL ) { mem_region_cleanup ( io , idx ) ; return - EIO ; } } mapsize = ( ( io -> io_size * io -> regspacing ) - ( io -> regspacing - io -> regsize ) ) ; io -> addr = ioremap ( addr , mapsize ) ; if ( io -> addr == NULL ) { mem_region_cleanup ( io , io -> io_size ) ; return - EIO ; } return 0 ; } "," - ENODEV ; switch ( io EIO ; } io -> io_cleanup = mem_cleanup ; ",torvalds@linux/401e7e88d4ef80188ffa07095ac00456f901b8c4,CVE-2019-11811,https://github.com/torvalds/linux/commit/401e7e88d4ef80188ffa07095ac00456f901b8c4,2019-05-07T14:29Z 1030,CWE-416,"CWE-416 static int splice_pipe_to_pipe ( struct pipe_inode_info * ipipe , struct pipe_inode_info * opipe , size_t len , unsigned int flags ) { struct pipe_buffer * ibuf , * obuf ; int ret = 0 , nbuf ; bool input_wakeup = false ; retry : ret = ipipe_prep ( ipipe , flags ) ; if ( ret ) return ret ; ret = opipe_prep ( opipe , flags ) ; if ( ret ) return ret ; pipe_double_lock ( ipipe , opipe ) ; do { if ( ! opipe -> readers ) { send_sig ( SIGPIPE , current , 0 ) ; if ( ! ret ) ret = - EPIPE ; break ; } if ( ! ipipe -> nrbufs && ! ipipe -> writers ) break ; if ( ! ipipe -> nrbufs || opipe -> nrbufs >= opipe -> buffers ) { if ( ret ) break ; if ( flags & SPLICE_F_NONBLOCK ) { ret = - EAGAIN ; break ; } pipe_unlock ( ipipe ) ; pipe_unlock ( opipe ) ; goto retry ; } ibuf = ipipe -> bufs + ipipe -> curbuf ; nbuf = ( opipe -> curbuf + opipe -> nrbufs ) & ( opipe -> buffers - 1 ) ; obuf = opipe -> bufs + nbuf ; if ( len >= ibuf -> len ) { * obuf = * ibuf ; ibuf -> ops = NULL ; opipe -> nrbufs ++ ; ipipe -> curbuf = ( ipipe -> curbuf + 1 ) & ( ipipe -> buffers - 1 ) ; ipipe -> nrbufs -- ; input_wakeup = true ; } else { pipe_buf_get ( ipipe , ibuf ) ; * obuf = * ibuf ; obuf -> flags &= ~ PIPE_BUF_FLAG_GIFT ; obuf -> len = len ; opipe -> nrbufs ++ ; ibuf -> offset += obuf -> len ; ibuf -> len -= obuf -> len ; } ret += obuf -> len ; len -= obuf -> len ; } while ( len ) ; pipe_unlock ( ipipe ) ; pipe_unlock ( opipe ) ; if ( ret > 0 ) wakeup_pipe_readers ( opipe ) ; if ( input_wakeup ) wakeup_pipe_writers ( ipipe ) ; return ret ; } "," } else { if ( ! , ibuf ) ) { if ( ret == 0 ) ret = - EFAULT ; break ; } * obuf = ",torvalds@linux/15fab63e1e57be9fdb5eec1bbc5916e9825e9acb,CVE-2019-11487,https://github.com/torvalds/linux/commit/15fab63e1e57be9fdb5eec1bbc5916e9825e9acb,2019-04-23T22:29Z 1031,CWE-119,"CWE-119 static void tokenadd ( struct jv_parser * p , char c ) { assert ( p -> tokenpos <= p -> tokenlen ) ; if ( p -> tokenpos == p -> tokenlen ) { p -> tokenlen = p -> tokenlen * 2 + 256 ; p -> tokenbuf = jv_mem_realloc ( p -> tokenbuf , p -> tokenlen ) ; } assert ( p -> tokenpos < p -> tokenlen ) ; p -> tokenbuf [ p -> tokenpos ++ ] = c ; } "," p -> tokenpos >= ( p -> tokenlen p -> tokenlen - 1 ) ",stedolan@jq/8eb1367ca44e772963e704a700ef72ae2e12babd,CVE-2015-8863,https://github.com/stedolan/jq/commit/8eb1367ca44e772963e704a700ef72ae2e12babd,2016-05-06T17:59Z 1032,CWE-119,"CWE-119 static vp9_variance_fn_t get_block_variance_fn ( BLOCK_SIZE bsize ) { switch ( bsize ) { case BLOCK_8X8 : return vp9_mse8x8 ; case BLOCK_16X8 : return vp9_mse16x8 ; case BLOCK_8X16 : return vp9_mse8x16 ; default : return vp9_mse16x16 ; } } "," static vpx_variance_fn_t get_block_variance_fn ( BLOCK_SIZE BLOCK_8X8 : return vpx_mse8x8 ; case BLOCK_16X8 BLOCK_16X8 : return vpx_mse16x8 ; case BLOCK_8X16 BLOCK_8X16 : return vpx_mse8x16 ; default : default : return vpx_mse16x16 ; } } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1033,CWE-000,"CWE-000 static void _isdn_setup ( struct net_device * dev ) { isdn_net_local * lp = netdev_priv ( dev ) ; ether_setup ( dev ) ; dev -> flags = IFF_NOARP | IFF_POINTOPOINT ; dev -> header_ops = NULL ; dev -> netdev_ops = & isdn_netdev_ops ; dev -> tx_queue_len = 30 ; lp -> p_encap = ISDN_NET_ENCAP_RAWIP ; lp -> magic = ISDN_NET_MAGIC ; lp -> last = lp ; lp -> next = lp ; lp -> isdn_device = - 1 ; lp -> isdn_channel = - 1 ; lp -> pre_device = - 1 ; lp -> pre_channel = - 1 ; lp -> exclusive = - 1 ; lp -> ppp_slot = - 1 ; lp -> pppbind = - 1 ; skb_queue_head_init ( & lp -> super_tx_queue ) ; lp -> l2_proto = ISDN_PROTO_L2_X75I ; lp -> l3_proto = ISDN_PROTO_L3_TRANS ; lp -> triggercps = 6000 ; lp -> slavedelay = 10 * HZ ; lp -> hupflags = ISDN_INHUP ; lp -> onhtime = 10 ; lp -> dialmax = 1 ; lp -> flags = ISDN_NET_CBHUP | ISDN_NET_DM_MANUAL ; lp -> cbdelay = 25 ; lp -> dialtimeout = - 1 ; lp -> dialwait = 5 * HZ ; lp -> dialstarted = 0 ; lp -> dialwait_timer = 0 ; } "," ; dev -> priv_flags &= ~ IFF_TX_SKB_SHARING ; dev -> ",torvalds@linux/550fd08c2cebad61c548def135f67aba284c6162,CVE-2011-4112,https://github.com/torvalds/linux/commit/550fd08c2cebad61c548def135f67aba284c6162,2012-05-17T11:00Z 1034,CWE-834,"CWE-834 static av_cold int rl2_read_header ( AVFormatContext * s ) { AVIOContext * pb = s -> pb ; AVStream * st ; unsigned int frame_count ; unsigned int audio_frame_counter = 0 ; unsigned int video_frame_counter = 0 ; unsigned int back_size ; unsigned short sound_rate ; unsigned short rate ; unsigned short channels ; unsigned short def_sound_size ; unsigned int signature ; unsigned int pts_den = 11025 ; unsigned int pts_num = 1103 ; unsigned int * chunk_offset = NULL ; int * chunk_size = NULL ; int * audio_size = NULL ; int i ; int ret = 0 ; avio_skip ( pb , 4 ) ; back_size = avio_rl32 ( pb ) ; signature = avio_rb32 ( pb ) ; avio_skip ( pb , 4 ) ; frame_count = avio_rl32 ( pb ) ; if ( back_size > INT_MAX / 2 || frame_count > INT_MAX / sizeof ( uint32_t ) ) return AVERROR_INVALIDDATA ; avio_skip ( pb , 2 ) ; sound_rate = avio_rl16 ( pb ) ; rate = avio_rl16 ( pb ) ; channels = avio_rl16 ( pb ) ; def_sound_size = avio_rl16 ( pb ) ; st = avformat_new_stream ( s , NULL ) ; if ( ! st ) return AVERROR ( ENOMEM ) ; st -> codecpar -> codec_type = AVMEDIA_TYPE_VIDEO ; st -> codecpar -> codec_id = AV_CODEC_ID_RL2 ; st -> codecpar -> codec_tag = 0 ; st -> codecpar -> width = 320 ; st -> codecpar -> height = 200 ; st -> codecpar -> extradata_size = EXTRADATA1_SIZE ; if ( signature == RLV3_TAG && back_size > 0 ) st -> codecpar -> extradata_size += back_size ; if ( ff_get_extradata ( s , st -> codecpar , pb , st -> codecpar -> extradata_size ) < 0 ) return AVERROR ( ENOMEM ) ; if ( sound_rate ) { if ( ! channels || channels > 42 ) { av_log ( s , AV_LOG_ERROR , ""Invalidnumberofchannels:%d\\n"" , channels ) ; return AVERROR_INVALIDDATA ; } pts_num = def_sound_size ; pts_den = rate ; st = avformat_new_stream ( s , NULL ) ; if ( ! st ) return AVERROR ( ENOMEM ) ; st -> codecpar -> codec_type = AVMEDIA_TYPE_AUDIO ; st -> codecpar -> codec_id = AV_CODEC_ID_PCM_U8 ; st -> codecpar -> codec_tag = 1 ; st -> codecpar -> channels = channels ; st -> codecpar -> bits_per_coded_sample = 8 ; st -> codecpar -> sample_rate = rate ; st -> codecpar -> bit_rate = st -> codecpar -> channels * st -> codecpar -> sample_rate * st -> codecpar -> bits_per_coded_sample ; st -> codecpar -> block_align = st -> codecpar -> channels * st -> codecpar -> bits_per_coded_sample / 8 ; avpriv_set_pts_info ( st , 32 , 1 , rate ) ; } avpriv_set_pts_info ( s -> streams [ 0 ] , 32 , pts_num , pts_den ) ; chunk_size = av_malloc ( frame_count * sizeof ( uint32_t ) ) ; audio_size = av_malloc ( frame_count * sizeof ( uint32_t ) ) ; chunk_offset = av_malloc ( frame_count * sizeof ( uint32_t ) ) ; if ( ! chunk_size || ! audio_size || ! chunk_offset ) { av_free ( chunk_size ) ; av_free ( audio_size ) ; av_free ( chunk_offset ) ; return AVERROR ( ENOMEM ) ; } for ( i = 0 ; i < frame_count ; i ++ ) chunk_size [ i ] = avio_rl32 ( pb ) ; for ( i = 0 ; i < frame_count ; i ++ ) chunk_offset [ i ] = avio_rl32 ( pb ) ; for ( i = 0 ; i < frame_count ; i ++ ) audio_size [ i ] = avio_rl32 ( pb ) & 0xFFFF ; for ( i = 0 ; i < frame_count ; i ++ ) { if ( chunk_size [ i ] < 0 || audio_size [ i ] > chunk_size [ i ] ) { ret = AVERROR_INVALIDDATA ; break ; } if ( sound_rate && audio_size [ i ] ) { av_add_index_entry ( s -> streams [ 1 ] , chunk_offset [ i ] , audio_frame_counter , audio_size [ i ] , 0 , AVINDEX_KEYFRAME ) ; audio_frame_counter += audio_size [ i ] / channels ; } av_add_index_entry ( s -> streams [ 0 ] , chunk_offset [ i ] + audio_size [ i ] , video_frame_counter , chunk_size [ i ] - audio_size [ i ] , 0 , AVINDEX_KEYFRAME ) ; ++ video_frame_counter ; } av_free ( chunk_size ) ; av_free ( audio_size ) ; av_free ( chunk_offset ) ; return ret ; } "," i ++ ) { if ( avio_feof ( pb ) ) return AVERROR_INVALIDDATA ; pb ) ; } i ++ ) { if ( avio_feof ( pb ) ) return AVERROR_INVALIDDATA ; pb ) ; } i ++ ) { if ( avio_feof ( pb ) ) return AVERROR_INVALIDDATA ; & 0xFFFF ; } ",FFmpeg@FFmpeg/96f24d1bee7fe7bac08e2b7c74db1a046c9dc0de,CVE-2017-14056,https://github.com/FFmpeg/FFmpeg/commit/96f24d1bee7fe7bac08e2b7c74db1a046c9dc0de,2017-08-31T15:29Z 1035,CWE-369,"CWE-369 static OPJ_BOOL opj_pi_next_pcrl ( opj_pi_iterator_t * pi ) { opj_pi_comp_t * comp = NULL ; opj_pi_resolution_t * res = NULL ; OPJ_UINT32 index = 0 ; if ( ! pi -> first ) { comp = & pi -> comps [ pi -> compno ] ; goto LABEL_SKIP ; } else { OPJ_UINT32 compno , resno ; pi -> first = 0 ; pi -> dx = 0 ; pi -> dy = 0 ; for ( compno = 0 ; compno < pi -> numcomps ; compno ++ ) { comp = & pi -> comps [ compno ] ; for ( resno = 0 ; resno < comp -> numresolutions ; resno ++ ) { OPJ_UINT32 dx , dy ; res = & comp -> resolutions [ resno ] ; dx = comp -> dx * ( 1u << ( res -> pdx + comp -> numresolutions - 1 - resno ) ) ; dy = comp -> dy * ( 1u << ( res -> pdy + comp -> numresolutions - 1 - resno ) ) ; pi -> dx = ! pi -> dx ? dx : opj_uint_min ( pi -> dx , dx ) ; pi -> dy = ! pi -> dy ? dy : opj_uint_min ( pi -> dy , dy ) ; } } } if ( ! pi -> tp_on ) { pi -> poc . ty0 = pi -> ty0 ; pi -> poc . tx0 = pi -> tx0 ; pi -> poc . ty1 = pi -> ty1 ; pi -> poc . tx1 = pi -> tx1 ; } for ( pi -> y = pi -> poc . ty0 ; pi -> y < pi -> poc . ty1 ; pi -> y += ( OPJ_INT32 ) ( pi -> dy - ( OPJ_UINT32 ) ( pi -> y % ( OPJ_INT32 ) pi -> dy ) ) ) { for ( pi -> x = pi -> poc . tx0 ; pi -> x < pi -> poc . tx1 ; pi -> x += ( OPJ_INT32 ) ( pi -> dx - ( OPJ_UINT32 ) ( pi -> x % ( OPJ_INT32 ) pi -> dx ) ) ) { for ( pi -> compno = pi -> poc . compno0 ; pi -> compno < pi -> poc . compno1 ; pi -> compno ++ ) { comp = & pi -> comps [ pi -> compno ] ; for ( pi -> resno = pi -> poc . resno0 ; pi -> resno < opj_uint_min ( pi -> poc . resno1 , comp -> numresolutions ) ; pi -> resno ++ ) { OPJ_UINT32 levelno ; OPJ_INT32 trx0 , try0 ; OPJ_INT32 trx1 , try1 ; OPJ_UINT32 rpx , rpy ; OPJ_INT32 prci , prcj ; res = & comp -> resolutions [ pi -> resno ] ; levelno = comp -> numresolutions - 1 - pi -> resno ; trx0 = opj_int_ceildiv ( pi -> tx0 , ( OPJ_INT32 ) ( comp -> dx << levelno ) ) ; try0 = opj_int_ceildiv ( pi -> ty0 , ( OPJ_INT32 ) ( comp -> dy << levelno ) ) ; trx1 = opj_int_ceildiv ( pi -> tx1 , ( OPJ_INT32 ) ( comp -> dx << levelno ) ) ; try1 = opj_int_ceildiv ( pi -> ty1 , ( OPJ_INT32 ) ( comp -> dy << levelno ) ) ; rpx = res -> pdx + levelno ; rpy = res -> pdy + levelno ; if ( ! ( ( pi -> y % ( OPJ_INT32 ) ( comp -> dy << rpy ) == 0 ) || ( ( pi -> y == pi -> ty0 ) && ( ( try0 << levelno ) % ( 1 << rpy ) ) ) ) ) { continue ; } if ( ! ( ( pi -> x % ( OPJ_INT32 ) ( comp -> dx << rpx ) == 0 ) || ( ( pi -> x == pi -> tx0 ) && ( ( trx0 << levelno ) % ( 1 << rpx ) ) ) ) ) { continue ; } if ( ( res -> pw == 0 ) || ( res -> ph == 0 ) ) { continue ; } if ( ( trx0 == trx1 ) || ( try0 == try1 ) ) { continue ; } prci = opj_int_floordivpow2 ( opj_int_ceildiv ( pi -> x , ( OPJ_INT32 ) ( comp -> dx << levelno ) ) , ( OPJ_INT32 ) res -> pdx ) - opj_int_floordivpow2 ( trx0 , ( OPJ_INT32 ) res -> pdx ) ; prcj = opj_int_floordivpow2 ( opj_int_ceildiv ( pi -> y , ( OPJ_INT32 ) ( comp -> dy << levelno ) ) , ( OPJ_INT32 ) res -> pdy ) - opj_int_floordivpow2 ( try0 , ( OPJ_INT32 ) res -> pdy ) ; pi -> precno = ( OPJ_UINT32 ) ( prci + prcj * ( OPJ_INT32 ) res -> pw ) ; for ( pi -> layno = pi -> poc . layno0 ; pi -> layno < pi -> poc . layno1 ; pi -> layno ++ ) { index = pi -> layno * pi -> step_l + pi -> resno * pi -> step_r + pi -> compno * pi -> step_c + pi -> precno * pi -> step_p ; if ( ! pi -> include [ index ] ) { pi -> include [ index ] = 1 ; return OPJ_TRUE ; } LABEL_SKIP : ; } } } } } return OPJ_FALSE ; } "," ; if ( rpx >= 31 || ( ( comp -> dx << rpx ) >> rpx ) != comp -> dx || rpy >= 31 || ( ( comp -> dy << rpy ) >> rpy ) != comp -> dy ) { continue ; } if ( ",uclouvain@openjpeg/d27ccf01c68a31ad62b33d2dc1ba2bb1eeaafe7b,CVE-2016-10506,https://github.com/uclouvain/openjpeg/commit/d27ccf01c68a31ad62b33d2dc1ba2bb1eeaafe7b,2017-08-30T09:29Z 1036,CWE-000,"CWE-000 static krb5_error_code pkinit_server_return_padata ( krb5_context context , krb5_pa_data * padata , krb5_data * req_pkt , krb5_kdc_req * request , krb5_kdc_rep * reply , krb5_keyblock * encrypting_key , krb5_pa_data * * send_pa , krb5_kdcpreauth_callbacks cb , krb5_kdcpreauth_rock rock , krb5_kdcpreauth_moddata moddata , krb5_kdcpreauth_modreq modreq ) { krb5_error_code retval = 0 ; krb5_data scratch = { 0 , 0 , NULL } ; krb5_pa_pk_as_req * reqp = NULL ; krb5_pa_pk_as_req_draft9 * reqp9 = NULL ; int i = 0 ; unsigned char * subjectPublicKey = NULL ; unsigned char * dh_pubkey = NULL , * server_key = NULL ; unsigned int subjectPublicKey_len = 0 ; unsigned int server_key_len = 0 , dh_pubkey_len = 0 ; krb5_kdc_dh_key_info dhkey_info ; krb5_data * encoded_dhkey_info = NULL ; krb5_pa_pk_as_rep * rep = NULL ; krb5_pa_pk_as_rep_draft9 * rep9 = NULL ; krb5_data * out_data = NULL ; krb5_octet_data secret ; krb5_enctype enctype = - 1 ; krb5_reply_key_pack * key_pack = NULL ; krb5_reply_key_pack_draft9 * key_pack9 = NULL ; krb5_data * encoded_key_pack = NULL ; pkinit_kdc_context plgctx ; pkinit_kdc_req_context reqctx ; int fixed_keypack = 0 ; * send_pa = NULL ; if ( padata -> pa_type == KRB5_PADATA_PKINIT_KX ) { return return_pkinit_kx ( context , request , reply , encrypting_key , send_pa ) ; } if ( padata -> length <= 0 || padata -> contents == NULL ) return 0 ; if ( modreq == NULL ) { pkiDebug ( ""missingrequestcontext\\n"" ) ; return EINVAL ; } plgctx = pkinit_find_realm_context ( context , moddata , request -> server ) ; if ( plgctx == NULL ) { pkiDebug ( ""Unabletolocatecorrectrealmcontext\\n"" ) ; return ENOENT ; } pkiDebug ( ""pkinit_return_padata:entered!\\n"" ) ; reqctx = ( pkinit_kdc_req_context ) modreq ; if ( encrypting_key -> contents ) { free ( encrypting_key -> contents ) ; encrypting_key -> length = 0 ; encrypting_key -> contents = NULL ; } for ( i = 0 ; i < request -> nktypes ; i ++ ) { enctype = request -> ktype [ i ] ; if ( ! krb5_c_valid_enctype ( enctype ) ) continue ; else { pkiDebug ( ""KDCpickedetype=%d\\n"" , enctype ) ; break ; } } if ( i == request -> nktypes ) { retval = KRB5KDC_ERR_ETYPE_NOSUPP ; goto cleanup ; } switch ( ( int ) reqctx -> pa_type ) { case KRB5_PADATA_PK_AS_REQ : init_krb5_pa_pk_as_rep ( & rep ) ; if ( rep == NULL ) { retval = ENOMEM ; goto cleanup ; } rep -> choice = choice_pa_pk_as_rep_encKeyPack ; break ; case KRB5_PADATA_PK_AS_REP_OLD : case KRB5_PADATA_PK_AS_REQ_OLD : init_krb5_pa_pk_as_rep_draft9 ( & rep9 ) ; if ( rep9 == NULL ) { retval = ENOMEM ; goto cleanup ; } rep9 -> choice = choice_pa_pk_as_rep_draft9_encKeyPack ; break ; default : retval = KRB5KDC_ERR_PREAUTH_FAILED ; goto cleanup ; } if ( reqctx -> rcv_auth_pack != NULL && reqctx -> rcv_auth_pack -> clientPublicValue != NULL ) { subjectPublicKey = reqctx -> rcv_auth_pack -> clientPublicValue -> subjectPublicKey . data ; subjectPublicKey_len = reqctx -> rcv_auth_pack -> clientPublicValue -> subjectPublicKey . length ; rep -> choice = choice_pa_pk_as_rep_dhInfo ; } else if ( reqctx -> rcv_auth_pack9 != NULL && reqctx -> rcv_auth_pack9 -> clientPublicValue != NULL ) { subjectPublicKey = reqctx -> rcv_auth_pack9 -> clientPublicValue -> subjectPublicKey . data ; subjectPublicKey_len = reqctx -> rcv_auth_pack9 -> clientPublicValue -> subjectPublicKey . length ; rep9 -> choice = choice_pa_pk_as_rep_draft9_dhSignedData ; } if ( rep != NULL && ( rep -> choice == choice_pa_pk_as_rep_dhInfo || rep -> choice == choice_pa_pk_as_rep_draft9_dhSignedData ) ) { pkiDebug ( ""receivedDHkeydeliveryASREQ\\n"" ) ; retval = server_process_dh ( context , plgctx -> cryptoctx , reqctx -> cryptoctx , plgctx -> idctx , subjectPublicKey , subjectPublicKey_len , & dh_pubkey , & dh_pubkey_len , & server_key , & server_key_len ) ; if ( retval ) { pkiDebug ( ""failedtoprocess/createdhparamters\\n"" ) ; goto cleanup ; } } if ( ( rep9 != NULL && rep9 -> choice == choice_pa_pk_as_rep_draft9_dhSignedData ) || ( rep != NULL && rep -> choice == choice_pa_pk_as_rep_dhInfo ) ) { dhkey_info . subjectPublicKey . length = dh_pubkey_len ; dhkey_info . subjectPublicKey . data = dh_pubkey ; dhkey_info . nonce = request -> nonce ; dhkey_info . dhKeyExpiration = 0 ; retval = k5int_encode_krb5_kdc_dh_key_info ( & dhkey_info , & encoded_dhkey_info ) ; if ( retval ) { pkiDebug ( ""encode_krb5_kdc_dh_key_infofailed\\n"" ) ; goto cleanup ; } # ifdef DEBUG_ASN1 print_buffer_bin ( ( unsigned char * ) encoded_dhkey_info -> data , encoded_dhkey_info -> length , ""/tmp/kdc_dh_key_info"" ) ; # endif switch ( ( int ) padata -> pa_type ) { case KRB5_PADATA_PK_AS_REQ : retval = cms_signeddata_create ( context , plgctx -> cryptoctx , reqctx -> cryptoctx , plgctx -> idctx , CMS_SIGN_SERVER , 1 , ( unsigned char * ) encoded_dhkey_info -> data , encoded_dhkey_info -> length , & rep -> u . dh_Info . dhSignedData . data , & rep -> u . dh_Info . dhSignedData . length ) ; if ( retval ) { pkiDebug ( ""failedtocreatepkcs7signeddata\\n"" ) ; goto cleanup ; } break ; case KRB5_PADATA_PK_AS_REP_OLD : case KRB5_PADATA_PK_AS_REQ_OLD : retval = cms_signeddata_create ( context , plgctx -> cryptoctx , reqctx -> cryptoctx , plgctx -> idctx , CMS_SIGN_DRAFT9 , 1 , ( unsigned char * ) encoded_dhkey_info -> data , encoded_dhkey_info -> length , & rep9 -> u . dhSignedData . data , & rep9 -> u . dhSignedData . length ) ; if ( retval ) { pkiDebug ( ""failedtocreatepkcs7signeddata\\n"" ) ; goto cleanup ; } break ; } } else { pkiDebug ( ""receivedRSAkeydeliveryASREQ\\n"" ) ; retval = krb5_c_make_random_key ( context , enctype , encrypting_key ) ; if ( retval ) { pkiDebug ( ""unabletomakeasessionkey\\n"" ) ; goto cleanup ; } for ( i = 0 ; request -> padata [ i ] != NULL ; i ++ ) { pkiDebug ( ""%s:Checkingpa_type0x%08x\\n"" , __FUNCTION__ , request -> padata [ i ] -> pa_type ) ; if ( request -> padata [ i ] -> pa_type == 132 ) fixed_keypack = 1 ; } pkiDebug ( ""%s:returnchecksuminsteadofnonce=%d\\n"" , __FUNCTION__ , fixed_keypack ) ; if ( ( int ) padata -> pa_type == KRB5_PADATA_PK_AS_REQ || fixed_keypack ) { init_krb5_reply_key_pack ( & key_pack ) ; if ( key_pack == NULL ) { retval = ENOMEM ; goto cleanup ; } retval = krb5_c_make_checksum ( context , 0 , encrypting_key , KRB5_KEYUSAGE_TGS_REQ_AUTH_CKSUM , req_pkt , & key_pack -> asChecksum ) ; if ( retval ) { pkiDebug ( ""unabletocalculateASREQchecksum\\n"" ) ; goto cleanup ; } # ifdef DEBUG_CKSUM pkiDebug ( ""calculatingchecksumonbufsize=%d\\n"" , req_pkt -> length ) ; print_buffer ( req_pkt -> data , req_pkt -> length ) ; pkiDebug ( ""checksumsize=%d\\n"" , key_pack -> asChecksum . length ) ; print_buffer ( key_pack -> asChecksum . contents , key_pack -> asChecksum . length ) ; pkiDebug ( ""encryptingkey(%d)\\n"" , encrypting_key -> length ) ; print_buffer ( encrypting_key -> contents , encrypting_key -> length ) ; # endif krb5_copy_keyblock_contents ( context , encrypting_key , & key_pack -> replyKey ) ; retval = k5int_encode_krb5_reply_key_pack ( key_pack , & encoded_key_pack ) ; if ( retval ) { pkiDebug ( ""failedtoencodereply_key_pack\\n"" ) ; goto cleanup ; } } switch ( ( int ) padata -> pa_type ) { case KRB5_PADATA_PK_AS_REQ : rep -> choice = choice_pa_pk_as_rep_encKeyPack ; retval = cms_envelopeddata_create ( context , plgctx -> cryptoctx , reqctx -> cryptoctx , plgctx -> idctx , padata -> pa_type , 1 , ( unsigned char * ) encoded_key_pack -> data , encoded_key_pack -> length , & rep -> u . encKeyPack . data , & rep -> u . encKeyPack . length ) ; break ; case KRB5_PADATA_PK_AS_REP_OLD : case KRB5_PADATA_PK_AS_REQ_OLD : if ( ! fixed_keypack ) { init_krb5_reply_key_pack_draft9 ( & key_pack9 ) ; if ( key_pack9 == NULL ) { retval = ENOMEM ; goto cleanup ; } key_pack9 -> nonce = reqctx -> rcv_auth_pack9 -> pkAuthenticator . nonce ; krb5_copy_keyblock_contents ( context , encrypting_key , & key_pack9 -> replyKey ) ; retval = k5int_encode_krb5_reply_key_pack_draft9 ( key_pack9 , & encoded_key_pack ) ; if ( retval ) { pkiDebug ( ""failedtoencodereply_key_pack\\n"" ) ; goto cleanup ; } } rep9 -> choice = choice_pa_pk_as_rep_draft9_encKeyPack ; retval = cms_envelopeddata_create ( context , plgctx -> cryptoctx , reqctx -> cryptoctx , plgctx -> idctx , padata -> pa_type , 1 , ( unsigned char * ) encoded_key_pack -> data , encoded_key_pack -> length , & rep9 -> u . encKeyPack . data , & rep9 -> u . encKeyPack . length ) ; break ; } if ( retval ) { pkiDebug ( ""failedtocreatepkcs7envelopeddata:%s\\n"" , error_message ( retval ) ) ; goto cleanup ; } # ifdef DEBUG_ASN1 print_buffer_bin ( ( unsigned char * ) encoded_key_pack -> data , encoded_key_pack -> length , ""/tmp/kdc_key_pack"" ) ; switch ( ( int ) padata -> pa_type ) { case KRB5_PADATA_PK_AS_REQ : print_buffer_bin ( rep -> u . encKeyPack . data , rep -> u . encKeyPack . length , ""/tmp/kdc_enc_key_pack"" ) ; break ; case KRB5_PADATA_PK_AS_REP_OLD : case KRB5_PADATA_PK_AS_REQ_OLD : print_buffer_bin ( rep9 -> u . encKeyPack . data , rep9 -> u . encKeyPack . length , ""/tmp/kdc_enc_key_pack"" ) ; break ; } # endif } if ( ( rep != NULL && rep -> choice == choice_pa_pk_as_rep_dhInfo ) && ( ( reqctx -> rcv_auth_pack != NULL && reqctx -> rcv_auth_pack -> supportedKDFs != NULL ) ) ) { if ( reqctx -> rcv_auth_pack != NULL && reqctx -> rcv_auth_pack -> supportedKDFs != NULL ) { retval = pkinit_pick_kdf_alg ( context , reqctx -> rcv_auth_pack -> supportedKDFs , & ( rep -> u . dh_Info . kdfID ) ) ; if ( retval ) { pkiDebug ( ""pkinit_pick_kdf_algfailed:%s\\n"" , error_message ( retval ) ) ; goto cleanup ; } } } switch ( ( int ) padata -> pa_type ) { case KRB5_PADATA_PK_AS_REQ : retval = k5int_encode_krb5_pa_pk_as_rep ( rep , & out_data ) ; break ; case KRB5_PADATA_PK_AS_REP_OLD : case KRB5_PADATA_PK_AS_REQ_OLD : retval = k5int_encode_krb5_pa_pk_as_rep_draft9 ( rep9 , & out_data ) ; break ; } if ( retval ) { pkiDebug ( ""failedtoencodeAS_REP\\n"" ) ; goto cleanup ; } # ifdef DEBUG_ASN1 if ( out_data != NULL ) print_buffer_bin ( ( unsigned char * ) out_data -> data , out_data -> length , ""/tmp/kdc_as_rep"" ) ; # endif if ( ( rep9 != NULL && rep9 -> choice == choice_pa_pk_as_rep_draft9_dhSignedData ) || ( rep != NULL && rep -> choice == choice_pa_pk_as_rep_dhInfo ) ) { if ( rep -> u . dh_Info . kdfID ) { secret . data = server_key ; secret . length = server_key_len ; retval = pkinit_alg_agility_kdf ( context , & secret , rep -> u . dh_Info . kdfID , request -> client , request -> server , enctype , ( krb5_octet_data * ) req_pkt , ( krb5_octet_data * ) out_data , encrypting_key ) ; if ( retval ) { pkiDebug ( ""pkinit_alg_agility_kdffailed:%s\\n"" , error_message ( retval ) ) ; goto cleanup ; } } else { retval = pkinit_octetstring2key ( context , enctype , server_key , server_key_len , encrypting_key ) ; if ( retval ) { pkiDebug ( ""pkinit_octetstring2keyfailed:%s\\n"" , error_message ( retval ) ) ; goto cleanup ; } } } * send_pa = malloc ( sizeof ( krb5_pa_data ) ) ; if ( * send_pa == NULL ) { retval = ENOMEM ; free ( out_data -> data ) ; free ( out_data ) ; out_data = NULL ; goto cleanup ; } ( * send_pa ) -> magic = KV5M_PA_DATA ; switch ( ( int ) padata -> pa_type ) { case KRB5_PADATA_PK_AS_REQ : ( * send_pa ) -> pa_type = KRB5_PADATA_PK_AS_REP ; break ; case KRB5_PADATA_PK_AS_REQ_OLD : case KRB5_PADATA_PK_AS_REP_OLD : ( * send_pa ) -> pa_type = KRB5_PADATA_PK_AS_REP_OLD ; break ; } ( * send_pa ) -> length = out_data -> length ; ( * send_pa ) -> contents = ( krb5_octet * ) out_data -> data ; cleanup : pkinit_fini_kdc_req_context ( context , reqctx ) ; free ( scratch . data ) ; free ( out_data ) ; if ( encoded_dhkey_info != NULL ) krb5_free_data ( context , encoded_dhkey_info ) ; if ( encoded_key_pack != NULL ) krb5_free_data ( context , encoded_key_pack ) ; free ( dh_pubkey ) ; free ( server_key ) ; switch ( ( int ) padata -> pa_type ) { case KRB5_PADATA_PK_AS_REQ : free_krb5_pa_pk_as_req ( & reqp ) ; free_krb5_pa_pk_as_rep ( & rep ) ; free_krb5_reply_key_pack ( & key_pack ) ; break ; case KRB5_PADATA_PK_AS_REP_OLD : case KRB5_PADATA_PK_AS_REQ_OLD : free_krb5_pa_pk_as_req_draft9 ( & reqp9 ) ; free_krb5_pa_pk_as_rep_draft9 ( & rep9 ) ; if ( ! fixed_keypack ) free_krb5_reply_key_pack_draft9 ( & key_pack9 ) ; else free_krb5_reply_key_pack ( & key_pack ) ; break ; } if ( retval ) pkiDebug ( ""pkinit_verify_padatafailure"" ) ; return retval ; } "," if ( rep != NULL && rep . data = ( char * ) ",krb5@krb5/db64ca25d661a47b996b4e2645998b5d7f0eb52c,CVE-2012-1016,https://github.com/krb5/krb5/commit/db64ca25d661a47b996b4e2645998b5d7f0eb52c,2013-03-05T04:54Z 1037,CWE-120,"CWE-120 MagickExport void * AcquireQuantumMemory ( const size_t count , const size_t quantum ) { size_t extent ; if ( CheckMemoryOverflow ( count , quantum ) != MagickFalse ) return ( ( void * ) NULL ) ; extent = count * quantum ; return ( AcquireMagickMemory ( extent ) ) ; } "," ; if ( HeapOverflowSanityCheck ( count , ",ImageMagick@ImageMagick/e45e48b881038487d0bc94d92a16c1537616cc0a,CVE-2016-10066,https://github.com/ImageMagick/ImageMagick/commit/e45e48b881038487d0bc94d92a16c1537616cc0a,2017-03-03T17:59Z 1038,CWE-119,"CWE-119 static bool parse_reconnect ( struct pool * pool , json_t * val ) { char * sockaddr_url , * stratum_port , * tmp ; char * url , * port , address [ 256 ] ; memset ( address , 0 , 255 ) ; url = ( char * ) json_string_value ( json_array_get ( val , 0 ) ) ; if ( ! url ) url = pool -> sockaddr_url ; else { char * dot_pool , * dot_reconnect ; dot_pool = strchr ( pool -> sockaddr_url , '.' ) ; if ( ! dot_pool ) { applog ( LOG_ERR , ""Deniedstratumreconnectrequestforpoolwithoutdomain\'%s\'"" , pool -> sockaddr_url ) ; return false ; } dot_reconnect = strchr ( url , '.' ) ; if ( ! dot_reconnect ) { applog ( LOG_ERR , ""Deniedstratumreconnectrequesttourlwithoutdomain\'%s\'"" , url ) ; return false ; } if ( strcmp ( dot_pool , dot_reconnect ) ) { applog ( LOG_ERR , ""Deniedstratumreconnectrequesttonon-matchingdomainurl\'%s\'"" , pool -> sockaddr_url ) ; return false ; } } port = ( char * ) json_string_value ( json_array_get ( val , 1 ) ) ; if ( ! port ) port = pool -> stratum_port ; sprintf ( address , ""%s:%s"" , url , port ) ; if ( ! extract_sockaddr ( address , & sockaddr_url , & stratum_port ) ) return false ; applog ( LOG_WARNING , ""Stratumreconnectrequestedfrompool%dto%s"" , pool -> pool_no , address ) ; clear_pool_work ( pool ) ; mutex_lock ( & pool -> stratum_lock ) ; __suspend_stratum ( pool ) ; tmp = pool -> sockaddr_url ; pool -> sockaddr_url = sockaddr_url ; pool -> stratum_url = pool -> sockaddr_url ; free ( tmp ) ; tmp = pool -> stratum_port ; pool -> stratum_port = stratum_port ; free ( tmp ) ; mutex_unlock ( & pool -> stratum_lock ) ; if ( ! restart_stratum ( pool ) ) { pool_failed ( pool ) ; return false ; } return true ; } "," -> stratum_port ; snprintf ( address , 254 , ""%s:%s"" , ",ckolivas@cgminer/e1c5050734123973b99d181c45e74b2cbb00272e,CVE-2014-4501,https://github.com/ckolivas/cgminer/commit/e1c5050734123973b99d181c45e74b2cbb00272e,2014-07-23T14:55Z 1039,CWE-22,"CWE-22 void wiki_handle_rest_call ( HttpRequest * req , HttpResponse * res , char * func ) { if ( func != NULL && * func != '\\0' ) { if ( ! strcmp ( func , ""page/get"" ) ) { char * page = http_request_param_get ( req , ""page"" ) ; if ( page == NULL ) page = http_request_get_query_string ( req ) ; if ( page && ( access ( page , R_OK ) == 0 ) ) { http_response_printf ( res , ""%s"" , file_read ( page ) ) ; http_response_send ( res ) ; return ; } } else if ( ! strcmp ( func , ""page/set"" ) ) { char * wikitext = NULL , * page = NULL ; if ( ( ( wikitext = http_request_param_get ( req , ""text"" ) ) != NULL ) && ( ( page = http_request_param_get ( req , ""page"" ) ) != NULL ) ) { file_write ( page , wikitext ) ; http_response_printf ( res , ""success"" ) ; http_response_send ( res ) ; return ; } } else if ( ! strcmp ( func , ""page/delete"" ) ) { char * page = http_request_param_get ( req , ""page"" ) ; if ( page == NULL ) page = http_request_get_query_string ( req ) ; if ( page && ( unlink ( page ) > 0 ) ) { http_response_printf ( res , ""success"" ) ; http_response_send ( res ) ; return ; } } else if ( ! strcmp ( func , ""page/exists"" ) ) { char * page = http_request_param_get ( req , ""page"" ) ; if ( page == NULL ) page = http_request_get_query_string ( req ) ; if ( page && ( access ( page , R_OK ) == 0 ) ) { http_response_printf ( res , ""success"" ) ; http_response_send ( res ) ; return ; } } else if ( ! strcmp ( func , ""pages"" ) || ! strcmp ( func , ""search"" ) ) { WikiPageList * * pages = NULL ; int n_pages , i ; char * expr = http_request_param_get ( req , ""expr"" ) ; if ( expr == NULL ) expr = http_request_get_query_string ( req ) ; pages = wiki_get_pages ( & n_pages , expr ) ; if ( pages ) { for ( i = 0 ; i < n_pages ; i ++ ) { struct tm * pTm ; char datebuf [ 64 ] ; pTm = localtime ( & pages [ i ] -> mtime ) ; strftime ( datebuf , sizeof ( datebuf ) , ""%Y-%m-%d%H:%M"" , pTm ) ; http_response_printf ( res , ""%s\\t%s\\n"" , pages [ i ] -> name , datebuf ) ; } http_response_send ( res ) ; return ; } } } http_response_set_status ( res , 500 , ""Error"" ) ; http_response_printf ( res , ""Failed\\n"" ) ; http_response_send ( res ) ; return ; } "," ( page && page_name_is_good ( page ) && ) ) { if ( page_name_is_good ( page ) ) { ; return ; } ( page && page_name_is_good ( page ) && if ( page && page_name_is_good ( page ) ",yarolig@didiwiki/5e5c796617e1712905dc5462b94bd5e6c08d15ea,CVE-2013-7448,https://github.com/yarolig/didiwiki/commit/5e5c796617e1712905dc5462b94bd5e6c08d15ea,2016-02-23T19:59Z 1040,CWE-119,"CWE-119 static int start_decoder ( vorb * f ) { uint8 header [ 6 ] , x , y ; int len , i , j , k , max_submaps = 0 ; int longest_floorlist = 0 ; if ( ! start_page ( f ) ) return FALSE ; if ( ! ( f -> page_flag & PAGEFLAG_first_page ) ) return error ( f , VORBIS_invalid_first_page ) ; if ( f -> page_flag & PAGEFLAG_last_page ) return error ( f , VORBIS_invalid_first_page ) ; if ( f -> page_flag & PAGEFLAG_continued_packet ) return error ( f , VORBIS_invalid_first_page ) ; if ( f -> segment_count != 1 ) return error ( f , VORBIS_invalid_first_page ) ; if ( f -> segments [ 0 ] != 30 ) return error ( f , VORBIS_invalid_first_page ) ; if ( get8 ( f ) != VORBIS_packet_id ) return error ( f , VORBIS_invalid_first_page ) ; if ( ! getn ( f , header , 6 ) ) return error ( f , VORBIS_unexpected_eof ) ; if ( ! vorbis_validate ( header ) ) return error ( f , VORBIS_invalid_first_page ) ; if ( get32 ( f ) != 0 ) return error ( f , VORBIS_invalid_first_page ) ; f -> channels = get8 ( f ) ; if ( ! f -> channels ) return error ( f , VORBIS_invalid_first_page ) ; if ( f -> channels > STB_VORBIS_MAX_CHANNELS ) return error ( f , VORBIS_too_many_channels ) ; f -> sample_rate = get32 ( f ) ; if ( ! f -> sample_rate ) return error ( f , VORBIS_invalid_first_page ) ; get32 ( f ) ; get32 ( f ) ; get32 ( f ) ; x = get8 ( f ) ; { int log0 , log1 ; log0 = x & 15 ; log1 = x >> 4 ; f -> blocksize_0 = 1 << log0 ; f -> blocksize_1 = 1 << log1 ; if ( log0 < 6 || log0 > 13 ) return error ( f , VORBIS_invalid_setup ) ; if ( log1 < 6 || log1 > 13 ) return error ( f , VORBIS_invalid_setup ) ; if ( log0 > log1 ) return error ( f , VORBIS_invalid_setup ) ; } x = get8 ( f ) ; if ( ! ( x & 1 ) ) return error ( f , VORBIS_invalid_first_page ) ; if ( ! start_page ( f ) ) return FALSE ; if ( ! start_packet ( f ) ) return FALSE ; do { len = next_segment ( f ) ; skip ( f , len ) ; f -> bytes_in_seg = 0 ; } while ( len ) ; if ( ! start_packet ( f ) ) return FALSE ; # ifndef STB_VORBIS_NO_PUSHDATA_API if ( IS_PUSH_MODE ( f ) ) { if ( ! is_whole_packet_present ( f , TRUE ) ) { if ( f -> error == VORBIS_invalid_stream ) f -> error = VORBIS_invalid_setup ; return FALSE ; } } # endif crc32_init ( ) ; if ( get8_packet ( f ) != VORBIS_packet_setup ) return error ( f , VORBIS_invalid_setup ) ; for ( i = 0 ; i < 6 ; ++ i ) header [ i ] = get8_packet ( f ) ; if ( ! vorbis_validate ( header ) ) return error ( f , VORBIS_invalid_setup ) ; f -> codebook_count = get_bits ( f , 8 ) + 1 ; f -> codebooks = ( Codebook * ) setup_malloc ( f , sizeof ( * f -> codebooks ) * f -> codebook_count ) ; if ( f -> codebooks == NULL ) return error ( f , VORBIS_outofmem ) ; memset ( f -> codebooks , 0 , sizeof ( * f -> codebooks ) * f -> codebook_count ) ; for ( i = 0 ; i < f -> codebook_count ; ++ i ) { uint32 * values ; int ordered , sorted_count ; int total = 0 ; uint8 * lengths ; Codebook * c = f -> codebooks + i ; CHECK ( f ) ; x = get_bits ( f , 8 ) ; if ( x != 0x42 ) return error ( f , VORBIS_invalid_setup ) ; x = get_bits ( f , 8 ) ; if ( x != 0x43 ) return error ( f , VORBIS_invalid_setup ) ; x = get_bits ( f , 8 ) ; if ( x != 0x56 ) return error ( f , VORBIS_invalid_setup ) ; x = get_bits ( f , 8 ) ; c -> dimensions = ( get_bits ( f , 8 ) << 8 ) + x ; x = get_bits ( f , 8 ) ; y = get_bits ( f , 8 ) ; c -> entries = ( get_bits ( f , 8 ) << 16 ) + ( y << 8 ) + x ; ordered = get_bits ( f , 1 ) ; c -> sparse = ordered ? 0 : get_bits ( f , 1 ) ; if ( c -> dimensions == 0 && c -> entries != 0 ) return error ( f , VORBIS_invalid_setup ) ; if ( c -> sparse ) lengths = ( uint8 * ) setup_temp_malloc ( f , c -> entries ) ; else lengths = c -> codeword_lengths = ( uint8 * ) setup_malloc ( f , c -> entries ) ; if ( ! lengths ) return error ( f , VORBIS_outofmem ) ; if ( ordered ) { int current_entry = 0 ; int current_length = get_bits ( f , 5 ) + 1 ; while ( current_entry < c -> entries ) { int limit = c -> entries - current_entry ; int n = get_bits ( f , ilog ( limit ) ) ; if ( current_entry + n > ( int ) c -> entries ) { return error ( f , VORBIS_invalid_setup ) ; } memset ( lengths + current_entry , current_length , n ) ; current_entry += n ; ++ current_length ; } } else { for ( j = 0 ; j < c -> entries ; ++ j ) { int present = c -> sparse ? get_bits ( f , 1 ) : 1 ; if ( present ) { lengths [ j ] = get_bits ( f , 5 ) + 1 ; ++ total ; if ( lengths [ j ] == 32 ) return error ( f , VORBIS_invalid_setup ) ; } else { lengths [ j ] = NO_CODE ; } } } if ( c -> sparse && total >= c -> entries >> 2 ) { if ( c -> entries > ( int ) f -> setup_temp_memory_required ) f -> setup_temp_memory_required = c -> entries ; c -> codeword_lengths = ( uint8 * ) setup_malloc ( f , c -> entries ) ; if ( c -> codeword_lengths == NULL ) return error ( f , VORBIS_outofmem ) ; memcpy ( c -> codeword_lengths , lengths , c -> entries ) ; setup_temp_free ( f , lengths , c -> entries ) ; lengths = c -> codeword_lengths ; c -> sparse = 0 ; } if ( c -> sparse ) { sorted_count = total ; } else { sorted_count = 0 ; # ifndef STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH for ( j = 0 ; j < c -> entries ; ++ j ) if ( lengths [ j ] > STB_VORBIS_FAST_HUFFMAN_LENGTH && lengths [ j ] != NO_CODE ) ++ sorted_count ; # endif } c -> sorted_entries = sorted_count ; values = NULL ; CHECK ( f ) ; if ( ! c -> sparse ) { c -> codewords = ( uint32 * ) setup_malloc ( f , sizeof ( c -> codewords [ 0 ] ) * c -> entries ) ; if ( ! c -> codewords ) return error ( f , VORBIS_outofmem ) ; } else { unsigned int size ; if ( c -> sorted_entries ) { c -> codeword_lengths = ( uint8 * ) setup_malloc ( f , c -> sorted_entries ) ; if ( ! c -> codeword_lengths ) return error ( f , VORBIS_outofmem ) ; c -> codewords = ( uint32 * ) setup_temp_malloc ( f , sizeof ( * c -> codewords ) * c -> sorted_entries ) ; if ( ! c -> codewords ) return error ( f , VORBIS_outofmem ) ; values = ( uint32 * ) setup_temp_malloc ( f , sizeof ( * values ) * c -> sorted_entries ) ; if ( ! values ) return error ( f , VORBIS_outofmem ) ; } size = c -> entries + ( sizeof ( * c -> codewords ) + sizeof ( * values ) ) * c -> sorted_entries ; if ( size > f -> setup_temp_memory_required ) f -> setup_temp_memory_required = size ; } if ( ! compute_codewords ( c , lengths , c -> entries , values ) ) { if ( c -> sparse ) setup_temp_free ( f , values , 0 ) ; return error ( f , VORBIS_invalid_setup ) ; } if ( c -> sorted_entries ) { c -> sorted_codewords = ( uint32 * ) setup_malloc ( f , sizeof ( * c -> sorted_codewords ) * ( c -> sorted_entries + 1 ) ) ; if ( c -> sorted_codewords == NULL ) return error ( f , VORBIS_outofmem ) ; c -> sorted_values = ( int * ) setup_malloc ( f , sizeof ( * c -> sorted_values ) * ( c -> sorted_entries + 1 ) ) ; if ( c -> sorted_values == NULL ) return error ( f , VORBIS_outofmem ) ; ++ c -> sorted_values ; c -> sorted_values [ - 1 ] = - 1 ; compute_sorted_huffman ( c , lengths , values ) ; } if ( c -> sparse ) { setup_temp_free ( f , values , sizeof ( * values ) * c -> sorted_entries ) ; setup_temp_free ( f , c -> codewords , sizeof ( * c -> codewords ) * c -> sorted_entries ) ; setup_temp_free ( f , lengths , c -> entries ) ; c -> codewords = NULL ; } compute_accelerated_huffman ( c ) ; CHECK ( f ) ; c -> lookup_type = get_bits ( f , 4 ) ; if ( c -> lookup_type > 2 ) return error ( f , VORBIS_invalid_setup ) ; if ( c -> lookup_type > 0 ) { uint16 * mults ; c -> minimum_value = float32_unpack ( get_bits ( f , 32 ) ) ; c -> delta_value = float32_unpack ( get_bits ( f , 32 ) ) ; c -> value_bits = get_bits ( f , 4 ) + 1 ; c -> sequence_p = get_bits ( f , 1 ) ; if ( c -> lookup_type == 1 ) { c -> lookup_values = lookup1_values ( c -> entries , c -> dimensions ) ; } else { c -> lookup_values = c -> entries * c -> dimensions ; } if ( c -> lookup_values == 0 ) return error ( f , VORBIS_invalid_setup ) ; mults = ( uint16 * ) setup_temp_malloc ( f , sizeof ( mults [ 0 ] ) * c -> lookup_values ) ; if ( mults == NULL ) return error ( f , VORBIS_outofmem ) ; for ( j = 0 ; j < ( int ) c -> lookup_values ; ++ j ) { int q = get_bits ( f , c -> value_bits ) ; if ( q == EOP ) { setup_temp_free ( f , mults , sizeof ( mults [ 0 ] ) * c -> lookup_values ) ; return error ( f , VORBIS_invalid_setup ) ; } mults [ j ] = q ; } # ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK if ( c -> lookup_type == 1 ) { int len , sparse = c -> sparse ; float last = 0 ; if ( sparse ) { if ( c -> sorted_entries == 0 ) goto skip ; c -> multiplicands = ( codetype * ) setup_malloc ( f , sizeof ( c -> multiplicands [ 0 ] ) * c -> sorted_entries * c -> dimensions ) ; } else c -> multiplicands = ( codetype * ) setup_malloc ( f , sizeof ( c -> multiplicands [ 0 ] ) * c -> entries * c -> dimensions ) ; if ( c -> multiplicands == NULL ) { setup_temp_free ( f , mults , sizeof ( mults [ 0 ] ) * c -> lookup_values ) ; return error ( f , VORBIS_outofmem ) ; } len = sparse ? c -> sorted_entries : c -> entries ; for ( j = 0 ; j < len ; ++ j ) { unsigned int z = sparse ? c -> sorted_values [ j ] : j ; unsigned int div = 1 ; for ( k = 0 ; k < c -> dimensions ; ++ k ) { int off = ( z / div ) % c -> lookup_values ; float val = mults [ off ] ; val = mults [ off ] * c -> delta_value + c -> minimum_value + last ; c -> multiplicands [ j * c -> dimensions + k ] = val ; if ( c -> sequence_p ) last = val ; if ( k + 1 < c -> dimensions ) { if ( div > UINT_MAX / ( unsigned int ) c -> lookup_values ) { setup_temp_free ( f , mults , sizeof ( mults [ 0 ] ) * c -> lookup_values ) ; return error ( f , VORBIS_invalid_setup ) ; } div *= c -> lookup_values ; } } } c -> lookup_type = 2 ; } else # endif { float last = 0 ; CHECK ( f ) ; c -> multiplicands = ( codetype * ) setup_malloc ( f , sizeof ( c -> multiplicands [ 0 ] ) * c -> lookup_values ) ; if ( c -> multiplicands == NULL ) { setup_temp_free ( f , mults , sizeof ( mults [ 0 ] ) * c -> lookup_values ) ; return error ( f , VORBIS_outofmem ) ; } for ( j = 0 ; j < ( int ) c -> lookup_values ; ++ j ) { float val = mults [ j ] * c -> delta_value + c -> minimum_value + last ; c -> multiplicands [ j ] = val ; if ( c -> sequence_p ) last = val ; } } # ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK skip : ; # endif setup_temp_free ( f , mults , sizeof ( mults [ 0 ] ) * c -> lookup_values ) ; CHECK ( f ) ; } CHECK ( f ) ; } x = get_bits ( f , 6 ) + 1 ; for ( i = 0 ; i < x ; ++ i ) { uint32 z = get_bits ( f , 16 ) ; if ( z != 0 ) return error ( f , VORBIS_invalid_setup ) ; } f -> floor_count = get_bits ( f , 6 ) + 1 ; f -> floor_config = ( Floor * ) setup_malloc ( f , f -> floor_count * sizeof ( * f -> floor_config ) ) ; if ( f -> floor_config == NULL ) return error ( f , VORBIS_outofmem ) ; for ( i = 0 ; i < f -> floor_count ; ++ i ) { f -> floor_types [ i ] = get_bits ( f , 16 ) ; if ( f -> floor_types [ i ] > 1 ) return error ( f , VORBIS_invalid_setup ) ; if ( f -> floor_types [ i ] == 0 ) { Floor0 * g = & f -> floor_config [ i ] . floor0 ; g -> order = get_bits ( f , 8 ) ; g -> rate = get_bits ( f , 16 ) ; g -> bark_map_size = get_bits ( f , 16 ) ; g -> amplitude_bits = get_bits ( f , 6 ) ; g -> amplitude_offset = get_bits ( f , 8 ) ; g -> number_of_books = get_bits ( f , 4 ) + 1 ; for ( j = 0 ; j < g -> number_of_books ; ++ j ) g -> book_list [ j ] = get_bits ( f , 8 ) ; return error ( f , VORBIS_feature_not_supported ) ; } else { stbv__floor_ordering p [ 31 * 8 + 2 ] ; Floor1 * g = & f -> floor_config [ i ] . floor1 ; int max_class = - 1 ; g -> partitions = get_bits ( f , 5 ) ; for ( j = 0 ; j < g -> partitions ; ++ j ) { g -> partition_class_list [ j ] = get_bits ( f , 4 ) ; if ( g -> partition_class_list [ j ] > max_class ) max_class = g -> partition_class_list [ j ] ; } for ( j = 0 ; j <= max_class ; ++ j ) { g -> class_dimensions [ j ] = get_bits ( f , 3 ) + 1 ; g -> class_subclasses [ j ] = get_bits ( f , 2 ) ; if ( g -> class_subclasses [ j ] ) { g -> class_masterbooks [ j ] = get_bits ( f , 8 ) ; if ( g -> class_masterbooks [ j ] >= f -> codebook_count ) return error ( f , VORBIS_invalid_setup ) ; } for ( k = 0 ; k < 1 << g -> class_subclasses [ j ] ; ++ k ) { g -> subclass_books [ j ] [ k ] = get_bits ( f , 8 ) - 1 ; if ( g -> subclass_books [ j ] [ k ] >= f -> codebook_count ) return error ( f , VORBIS_invalid_setup ) ; } } g -> floor1_multiplier = get_bits ( f , 2 ) + 1 ; g -> rangebits = get_bits ( f , 4 ) ; g -> Xlist [ 0 ] = 0 ; g -> Xlist [ 1 ] = 1 << g -> rangebits ; g -> values = 2 ; for ( j = 0 ; j < g -> partitions ; ++ j ) { int c = g -> partition_class_list [ j ] ; for ( k = 0 ; k < g -> class_dimensions [ c ] ; ++ k ) { g -> Xlist [ g -> values ] = get_bits ( f , g -> rangebits ) ; ++ g -> values ; } } for ( j = 0 ; j < g -> values ; ++ j ) { p [ j ] . x = g -> Xlist [ j ] ; p [ j ] . id = j ; } qsort ( p , g -> values , sizeof ( p [ 0 ] ) , point_compare ) ; for ( j = 0 ; j < g -> values ; ++ j ) g -> sorted_order [ j ] = ( uint8 ) p [ j ] . id ; for ( j = 2 ; j < g -> values ; ++ j ) { int low , hi ; neighbors ( g -> Xlist , j , & low , & hi ) ; g -> neighbors [ j ] [ 0 ] = low ; g -> neighbors [ j ] [ 1 ] = hi ; } if ( g -> values > longest_floorlist ) longest_floorlist = g -> values ; } } f -> residue_count = get_bits ( f , 6 ) + 1 ; f -> residue_config = ( Residue * ) setup_malloc ( f , f -> residue_count * sizeof ( f -> residue_config [ 0 ] ) ) ; if ( f -> residue_config == NULL ) return error ( f , VORBIS_outofmem ) ; memset ( f -> residue_config , 0 , f -> residue_count * sizeof ( f -> residue_config [ 0 ] ) ) ; for ( i = 0 ; i < f -> residue_count ; ++ i ) { uint8 residue_cascade [ 64 ] ; Residue * r = f -> residue_config + i ; f -> residue_types [ i ] = get_bits ( f , 16 ) ; if ( f -> residue_types [ i ] > 2 ) return error ( f , VORBIS_invalid_setup ) ; r -> begin = get_bits ( f , 24 ) ; r -> end = get_bits ( f , 24 ) ; if ( r -> end < r -> begin ) return error ( f , VORBIS_invalid_setup ) ; r -> part_size = get_bits ( f , 24 ) + 1 ; r -> classifications = get_bits ( f , 6 ) + 1 ; r -> classbook = get_bits ( f , 8 ) ; if ( r -> classbook >= f -> codebook_count ) return error ( f , VORBIS_invalid_setup ) ; for ( j = 0 ; j < r -> classifications ; ++ j ) { uint8 high_bits = 0 ; uint8 low_bits = get_bits ( f , 3 ) ; if ( get_bits ( f , 1 ) ) high_bits = get_bits ( f , 5 ) ; residue_cascade [ j ] = high_bits * 8 + low_bits ; } r -> residue_books = ( short ( * ) [ 8 ] ) setup_malloc ( f , sizeof ( r -> residue_books [ 0 ] ) * r -> classifications ) ; if ( r -> residue_books == NULL ) return error ( f , VORBIS_outofmem ) ; for ( j = 0 ; j < r -> classifications ; ++ j ) { for ( k = 0 ; k < 8 ; ++ k ) { if ( residue_cascade [ j ] & ( 1 << k ) ) { r -> residue_books [ j ] [ k ] = get_bits ( f , 8 ) ; if ( r -> residue_books [ j ] [ k ] >= f -> codebook_count ) return error ( f , VORBIS_invalid_setup ) ; } else { r -> residue_books [ j ] [ k ] = - 1 ; } } } r -> classdata = ( uint8 * * ) setup_malloc ( f , sizeof ( * r -> classdata ) * f -> codebooks [ r -> classbook ] . entries ) ; if ( ! r -> classdata ) return error ( f , VORBIS_outofmem ) ; memset ( r -> classdata , 0 , sizeof ( * r -> classdata ) * f -> codebooks [ r -> classbook ] . entries ) ; for ( j = 0 ; j < f -> codebooks [ r -> classbook ] . entries ; ++ j ) { int classwords = f -> codebooks [ r -> classbook ] . dimensions ; int temp = j ; r -> classdata [ j ] = ( uint8 * ) setup_malloc ( f , sizeof ( r -> classdata [ j ] [ 0 ] ) * classwords ) ; if ( r -> classdata [ j ] == NULL ) return error ( f , VORBIS_outofmem ) ; for ( k = classwords - 1 ; k >= 0 ; -- k ) { r -> classdata [ j ] [ k ] = temp % r -> classifications ; temp /= r -> classifications ; } } } f -> mapping_count = get_bits ( f , 6 ) + 1 ; f -> mapping = ( Mapping * ) setup_malloc ( f , f -> mapping_count * sizeof ( * f -> mapping ) ) ; if ( f -> mapping == NULL ) return error ( f , VORBIS_outofmem ) ; memset ( f -> mapping , 0 , f -> mapping_count * sizeof ( * f -> mapping ) ) ; for ( i = 0 ; i < f -> mapping_count ; ++ i ) { Mapping * m = f -> mapping + i ; int mapping_type = get_bits ( f , 16 ) ; if ( mapping_type != 0 ) return error ( f , VORBIS_invalid_setup ) ; m -> chan = ( MappingChannel * ) setup_malloc ( f , f -> channels * sizeof ( * m -> chan ) ) ; if ( m -> chan == NULL ) return error ( f , VORBIS_outofmem ) ; if ( get_bits ( f , 1 ) ) m -> submaps = get_bits ( f , 4 ) + 1 ; else m -> submaps = 1 ; if ( m -> submaps > max_submaps ) max_submaps = m -> submaps ; if ( get_bits ( f , 1 ) ) { m -> coupling_steps = get_bits ( f , 8 ) + 1 ; for ( k = 0 ; k < m -> coupling_steps ; ++ k ) { m -> chan [ k ] . magnitude = get_bits ( f , ilog ( f -> channels - 1 ) ) ; m -> chan [ k ] . angle = get_bits ( f , ilog ( f -> channels - 1 ) ) ; if ( m -> chan [ k ] . magnitude >= f -> channels ) return error ( f , VORBIS_invalid_setup ) ; if ( m -> chan [ k ] . angle >= f -> channels ) return error ( f , VORBIS_invalid_setup ) ; if ( m -> chan [ k ] . magnitude == m -> chan [ k ] . angle ) return error ( f , VORBIS_invalid_setup ) ; } } else m -> coupling_steps = 0 ; if ( get_bits ( f , 2 ) ) return error ( f , VORBIS_invalid_setup ) ; if ( m -> submaps > 1 ) { for ( j = 0 ; j < f -> channels ; ++ j ) { m -> chan [ j ] . mux = get_bits ( f , 4 ) ; if ( m -> chan [ j ] . mux >= m -> submaps ) return error ( f , VORBIS_invalid_setup ) ; } } else for ( j = 0 ; j < f -> channels ; ++ j ) m -> chan [ j ] . mux = 0 ; for ( j = 0 ; j < m -> submaps ; ++ j ) { get_bits ( f , 8 ) ; m -> submap_floor [ j ] = get_bits ( f , 8 ) ; m -> submap_residue [ j ] = get_bits ( f , 8 ) ; if ( m -> submap_floor [ j ] >= f -> floor_count ) return error ( f , VORBIS_invalid_setup ) ; if ( m -> submap_residue [ j ] >= f -> residue_count ) return error ( f , VORBIS_invalid_setup ) ; } } f -> mode_count = get_bits ( f , 6 ) + 1 ; for ( i = 0 ; i < f -> mode_count ; ++ i ) { Mode * m = f -> mode_config + i ; m -> blockflag = get_bits ( f , 1 ) ; m -> windowtype = get_bits ( f , 16 ) ; m -> transformtype = get_bits ( f , 16 ) ; m -> mapping = get_bits ( f , 8 ) ; if ( m -> windowtype != 0 ) return error ( f , VORBIS_invalid_setup ) ; if ( m -> transformtype != 0 ) return error ( f , VORBIS_invalid_setup ) ; if ( m -> mapping >= f -> mapping_count ) return error ( f , VORBIS_invalid_setup ) ; } flush_packet ( f ) ; f -> previous_length = 0 ; for ( i = 0 ; i < f -> channels ; ++ i ) { f -> channel_buffers [ i ] = ( float * ) setup_malloc ( f , sizeof ( float ) * f -> blocksize_1 ) ; f -> previous_window [ i ] = ( float * ) setup_malloc ( f , sizeof ( float ) * f -> blocksize_1 / 2 ) ; f -> finalY [ i ] = ( int16 * ) setup_malloc ( f , sizeof ( int16 ) * longest_floorlist ) ; if ( f -> channel_buffers [ i ] == NULL || f -> previous_window [ i ] == NULL || f -> finalY [ i ] == NULL ) return error ( f , VORBIS_outofmem ) ; # ifdef STB_VORBIS_NO_DEFER_FLOOR f -> floor_buffers [ i ] = ( float * ) setup_malloc ( f , sizeof ( float ) * f -> blocksize_1 / 2 ) ; if ( f -> floor_buffers [ i ] == NULL ) return error ( f , VORBIS_outofmem ) ; # endif } if ( ! init_blocksize ( f , 0 , f -> blocksize_0 ) ) return FALSE ; if ( ! init_blocksize ( f , 1 , f -> blocksize_1 ) ) return FALSE ; f -> blocksize [ 0 ] = f -> blocksize_0 ; f -> blocksize [ 1 ] = f -> blocksize_1 ; # ifdef STB_VORBIS_DIVIDE_TABLE if ( integer_divide_table [ 1 ] [ 1 ] == 0 ) for ( i = 0 ; i < DIVTAB_NUMER ; ++ i ) for ( j = 1 ; j < DIVTAB_DENOM ; ++ j ) integer_divide_table [ i ] [ j ] = i / j ; # endif { uint32 imdct_mem = ( f -> blocksize_1 * sizeof ( float ) >> 1 ) ; uint32 classify_mem ; int i , max_part_read = 0 ; for ( i = 0 ; i < f -> residue_count ; ++ i ) { Residue * r = f -> residue_config + i ; int n_read = r -> end - r -> begin ; int part_read = n_read / r -> part_size ; if ( part_read > max_part_read ) max_part_read = part_read ; } # ifndef STB_VORBIS_DIVIDES_IN_RESIDUE classify_mem = f -> channels * ( sizeof ( void * ) + max_part_read * sizeof ( uint8 * ) ) ; # else classify_mem = f -> channels * ( sizeof ( void * ) + max_part_read * sizeof ( int * ) ) ; # endif f -> temp_memory_required = classify_mem ; if ( imdct_mem > f -> temp_memory_required ) f -> temp_memory_required = imdct_mem ; } f -> first_decode = TRUE ; if ( f -> alloc . alloc_buffer ) { assert ( f -> temp_offset == f -> alloc . alloc_buffer_length_in_bytes ) ; if ( f -> setup_offset + sizeof ( * f ) + f -> temp_memory_required > ( unsigned ) f -> temp_offset ) return error ( f , VORBIS_outofmem ) ; } f -> first_audio_page_offset = stb_vorbis_get_file_offset ( f ) ; return TRUE ; } "," + i ; unsigned int actual_size = f -> blocksize_1 / 2 ; unsigned int limit_r_begin = r -> begin < actual_size ? r -> begin : actual_size ; unsigned int limit_r_end = r -> end < actual_size ? r -> end : actual_size ; int n_read = limit_r_end - limit_r_begin ; int part_read ",nothings@stb/244d83bc3d859293f55812d48b3db168e581f6ab,CVE-2018-1000050,https://github.com/nothings/stb/commit/244d83bc3d859293f55812d48b3db168e581f6ab,2018-02-09T23:29Z 1041,CWE-119,"CWE-119 int nfssvc_decode_writeargs ( struct svc_rqst * rqstp , __be32 * p , struct nfsd_writeargs * args ) { unsigned int len , hdr , dlen ; struct kvec * head = rqstp -> rq_arg . head ; int v ; p = decode_fh ( p , & args -> fh ) ; if ( ! p ) return 0 ; p ++ ; args -> offset = ntohl ( * p ++ ) ; p ++ ; len = args -> len = ntohl ( * p ++ ) ; if ( len > NFSSVC_MAXBLKSIZE_V2 ) return 0 ; hdr = ( void * ) p - head -> iov_base ; dlen = head -> iov_len + rqstp -> rq_arg . page_len - hdr ; if ( dlen < XDR_QUADLEN ( len ) * 4 ) return 0 ; rqstp -> rq_vec [ 0 ] . iov_base = ( void * ) p ; rqstp -> rq_vec [ 0 ] . iov_len = head -> iov_len - hdr ; v = 0 ; while ( len > rqstp -> rq_vec [ v ] . iov_len ) { len -= rqstp -> rq_vec [ v ] . iov_len ; v ++ ; rqstp -> rq_vec [ v ] . iov_base = page_address ( rqstp -> rq_pages [ v ] ) ; rqstp -> rq_vec [ v ] . iov_len = PAGE_SIZE ; } rqstp -> rq_vec [ v ] . iov_len = len ; args -> vlen = v + 1 ; return 1 ; } "," head -> iov_base ; if ( hdr > head -> iov_len ) return 0 ",torvalds@linux/13bf9fbff0e5e099e2b6f003a0ab8ae145436309,CVE-2017-7895,https://github.com/torvalds/linux/commit/13bf9fbff0e5e099e2b6f003a0ab8ae145436309,2017-04-28T10:59Z 1042,CWE-476,"CWE-476 static ssize_t o2nm_node_num_store ( struct config_item * item , const char * page , size_t count ) { struct o2nm_node * node = to_o2nm_node ( item ) ; struct o2nm_cluster * cluster = to_o2nm_cluster_from_node ( node ) ; unsigned long tmp ; char * p = ( char * ) page ; int ret = 0 ; tmp = simple_strtoul ( p , & p , 0 ) ; if ( ! p || ( * p && ( * p != '\\n' ) ) ) return - EINVAL ; if ( tmp >= O2NM_MAX_NODES ) return - ERANGE ; if ( ! test_bit ( O2NM_NODE_ATTR_ADDRESS , & node -> nd_set_attributes ) || ! test_bit ( O2NM_NODE_ATTR_PORT , & node -> nd_set_attributes ) ) return - EINVAL ; write_lock ( & cluster -> cl_nodes_lock ) ; if ( cluster -> cl_nodes [ tmp ] ) ret = - EEXIST ; else if ( test_and_set_bit ( O2NM_NODE_ATTR_NUM , & node -> nd_set_attributes ) ) ret = - EBUSY ; else { cluster -> cl_nodes [ tmp ] = node ; node -> nd_num = tmp ; set_bit ( tmp , cluster -> cl_nodes_bitmap ) ; } write_unlock ( & cluster -> cl_nodes_lock ) ; if ( ret ) return ret ; return count ; } "," o2nm_cluster * cluster ; unsigned long - EINVAL ; o2nm_lock_subsystem ( ) ; cluster = to_o2nm_cluster_from_node ( node ) ; if ( ! cluster ) { o2nm_unlock_subsystem ( ) ; return - EINVAL ; } cl_nodes_lock ) ; o2nm_unlock_subsystem ( ) ; ",torvalds@linux/853bc26a7ea39e354b9f8889ae7ad1492ffa28d2,CVE-2017-18216,https://github.com/torvalds/linux/commit/853bc26a7ea39e354b9f8889ae7ad1492ffa28d2,2018-03-05T18:29Z 1043,CWE-476,"CWE-476 static void tw5864_handle_frame ( struct tw5864_h264_frame * frame ) { # define SKIP_VLCBUF_BYTES 3 struct tw5864_input * input = frame -> input ; struct tw5864_dev * dev = input -> root ; struct tw5864_buf * vb ; struct vb2_v4l2_buffer * v4l2_buf ; int frame_len = frame -> vlc_len - SKIP_VLCBUF_BYTES ; u8 * dst = input -> buf_cur_ptr ; u8 tail_mask , vlc_mask = 0 ; int i ; u8 vlc_first_byte = ( ( u8 * ) ( frame -> vlc . addr + SKIP_VLCBUF_BYTES ) ) [ 0 ] ; unsigned long flags ; int zero_run ; u8 * src ; u8 * src_end ; # ifdef DEBUG if ( frame -> checksum != tw5864_vlc_checksum ( ( u32 * ) frame -> vlc . addr , frame_len ) ) dev_err ( & dev -> pci -> dev , ""Checksumofencodedframedoesn\'tmatch!\\n"" ) ; # endif spin_lock_irqsave ( & input -> slock , flags ) ; vb = input -> vb ; input -> vb = NULL ; spin_unlock_irqrestore ( & input -> slock , flags ) ; v4l2_buf = to_vb2_v4l2_buffer ( & vb -> vb . vb2_buf ) ; if ( ! vb ) { dev_dbg ( & dev -> pci -> dev , ""vbisempty,droppingframe\\n"" ) ; return ; } if ( input -> buf_cur_space_left < frame_len * 5 / 4 ) { dev_err_once ( & dev -> pci -> dev , ""Leftspaceinvb2buffer,%dbytes,islessthanconsideredsafelyenoughtoputframeoflength%d.Droppingthisframe.\\n"" , input -> buf_cur_space_left , frame_len ) ; return ; } for ( i = 0 ; i < 8 - input -> tail_nb_bits ; i ++ ) vlc_mask |= 1 << i ; tail_mask = ( ~ vlc_mask ) & 0xff ; dst [ 0 ] = ( input -> tail & tail_mask ) | ( vlc_first_byte & vlc_mask ) ; frame_len -- ; dst ++ ; src = frame -> vlc . addr + SKIP_VLCBUF_BYTES + 1 ; src_end = src + frame_len ; zero_run = 0 ; for ( ; src < src_end ; src ++ ) { if ( zero_run < 2 ) { if ( * src == 0 ) ++ zero_run ; else zero_run = 0 ; } else { if ( ( * src & ~ 0x03 ) == 0 ) * dst ++ = 0x03 ; zero_run = * src == 0 ; } * dst ++ = * src ; } vb2_set_plane_payload ( & vb -> vb . vb2_buf , 0 , dst - ( u8 * ) vb2_plane_vaddr ( & vb -> vb . vb2_buf , 0 ) ) ; vb -> vb . vb2_buf . timestamp = frame -> timestamp ; v4l2_buf -> field = V4L2_FIELD_INTERLACED ; v4l2_buf -> sequence = frame -> seqno ; if ( frame -> gop_seqno && tw5864_is_motion_triggered ( frame ) ) { struct v4l2_event ev = { . type = V4L2_EVENT_MOTION_DET , . u . motion_det = { . flags = V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ , . frame_sequence = v4l2_buf -> sequence , } , } ; v4l2_event_queue ( & input -> vdev , & ev ) ; } vb2_buffer_done ( & vb -> vb . vb2_buf , VB2_BUF_STATE_DONE ) ; } "," flags ) ; if ( ! vb ) { dev_dbg ( & dev -> pci -> dev , ""vbisempty,droppingframe\\n"" ) ; return ; } vb2_buf ) ; if ( input ",torvalds@linux/2e7682ebfc750177a4944eeb56e97a3f05734528,CVE-2019-20806,https://github.com/torvalds/linux/commit/2e7682ebfc750177a4944eeb56e97a3f05734528,2020-05-27T12:15Z 1044,CWE-190,"CWE-190 void * zcalloc ( size_t size ) { void * ptr = calloc ( 1 , size + PREFIX_SIZE ) ; if ( ! ptr ) zmalloc_oom_handler ( size ) ; # ifdef HAVE_MALLOC_SIZE update_zmalloc_stat_alloc ( zmalloc_size ( ptr ) ) ; return ptr ; # else * ( ( size_t * ) ptr ) = size ; update_zmalloc_stat_alloc ( size + PREFIX_SIZE ) ; return ( char * ) ptr + PREFIX_SIZE ; # endif } "," size ) { ASSERT_NO_SIZE_OVERFLOW ( size ) ; ",redis@redis/c992857618db99776917f10bf4f2345a5fdc78b0,CVE-2021-21309,https://github.com/redis/redis/commit/c992857618db99776917f10bf4f2345a5fdc78b0,2021-02-26T22:15Z 1045,CWE-189,"CWE-189 sf_count_t psf_fwrite ( const void * ptr , sf_count_t bytes , sf_count_t items , SF_PRIVATE * psf ) { sf_count_t total = 0 ; ssize_t count ; if ( psf -> virtual_io ) return psf -> vio . write ( ptr , bytes * items , psf -> vio_user_data ) / bytes ; items *= bytes ; if ( items <= 0 ) return 0 ; while ( items > 0 ) { count = ( items > SENSIBLE_SIZE ) ? SENSIBLE_SIZE : items ; count = write ( psf -> file . filedes , ( ( const char * ) ptr ) + total , count ) ; if ( count == - 1 ) { if ( errno == EINTR ) continue ; psf_log_syserr ( psf , errno ) ; break ; } ; if ( count == 0 ) break ; total += count ; items -= count ; } ; if ( psf -> is_pipe ) psf -> pipeoffset += total ; return total / bytes ; } "," ; ssize_t count ; if ( bytes == 0 || items == 0 ) return 0 ",erikd@libsndfile/725c7dbb95bfaf8b4bb7b04820e3a00cceea9ce6,CVE-2014-9756,https://github.com/erikd/libsndfile/commit/725c7dbb95bfaf8b4bb7b04820e3a00cceea9ce6,2015-11-19T20:59Z 1046,CWE-125,"CWE-125 static int rx_cache_find ( const struct rx_header * rxh , const struct ip * ip , int sport , int32_t * opcode ) { int i ; struct rx_cache_entry * rxent ; uint32_t clip ; uint32_t sip ; UNALIGNED_MEMCPY ( & clip , & ip -> ip_dst , sizeof ( uint32_t ) ) ; UNALIGNED_MEMCPY ( & sip , & ip -> ip_src , sizeof ( uint32_t ) ) ; i = rx_cache_hint ; do { rxent = & rx_cache [ i ] ; if ( rxent -> callnum == EXTRACT_32BITS ( & rxh -> callNumber ) && rxent -> client . s_addr == clip && rxent -> server . s_addr == sip && rxent -> serviceId == EXTRACT_32BITS ( & rxh -> serviceId ) && rxent -> dport == sport ) { rx_cache_hint = i ; * opcode = rxent -> opcode ; return ( 1 ) ; } if ( ++ i >= RX_CACHE_SIZE ) i = 0 ; } while ( i != rx_cache_hint ) ; return ( 0 ) ; } "," -> serviceId == EXTRACT_16BITS ( & rxh ",the-tcpdump-group@tcpdump/c24922e692a52121e853a84ead6b9337f4c08a94,CVE-2018-14466,https://github.com/the-tcpdump-group/tcpdump/commit/c24922e692a52121e853a84ead6b9337f4c08a94,2019-10-03T16:15Z 1047,CWE-476,"CWE-476 long keyctl_read_key ( key_serial_t keyid , char __user * buffer , size_t buflen ) { struct key * key ; key_ref_t key_ref ; long ret ; key_ref = lookup_user_key ( keyid , 0 , 0 ) ; if ( IS_ERR ( key_ref ) ) { ret = - ENOKEY ; goto error ; } key = key_ref_to_ptr ( key_ref ) ; ret = key_permission ( key_ref , KEY_NEED_READ ) ; if ( ret == 0 ) goto can_read_key ; if ( ret != - EACCES ) goto error2 ; if ( ! is_key_possessed ( key_ref ) ) { ret = - EACCES ; goto error2 ; } can_read_key : ret = - EOPNOTSUPP ; if ( key -> type -> read ) { down_read ( & key -> sem ) ; ret = key_validate ( key ) ; if ( ret == 0 ) ret = key -> type -> read ( key , buffer , buflen ) ; up_read ( & key -> sem ) ; } error2 : key_put ( key ) ; error : return ret ; } "," key_ref ) ; if ( test_bit ( KEY_FLAG_NEGATIVE , & key -> flags ) ) { ret = - ENOKEY ; goto error2 ; } ",torvalds@linux/37863c43b2c6464f252862bf2e9768264e961678,CVE-2017-12192,https://github.com/torvalds/linux/commit/37863c43b2c6464f252862bf2e9768264e961678,2017-10-12T00:29Z 1048,CWE-120,"CWE-120 int mwifiex_cmd_802_11_ad_hoc_start ( struct mwifiex_private * priv , struct host_cmd_ds_command * cmd , struct cfg80211_ssid * req_ssid ) { int rsn_ie_len = 0 ; struct mwifiex_adapter * adapter = priv -> adapter ; struct host_cmd_ds_802_11_ad_hoc_start * adhoc_start = & cmd -> params . adhoc_start ; struct mwifiex_bssdescriptor * bss_desc ; u32 cmd_append_size = 0 ; u32 i ; u16 tmp_cap ; struct mwifiex_ie_types_chan_list_param_set * chan_tlv ; u8 radio_type ; struct mwifiex_ie_types_htcap * ht_cap ; struct mwifiex_ie_types_htinfo * ht_info ; u8 * pos = ( u8 * ) adhoc_start + sizeof ( struct host_cmd_ds_802_11_ad_hoc_start ) ; if ( ! adapter ) return - 1 ; cmd -> command = cpu_to_le16 ( HostCmd_CMD_802_11_AD_HOC_START ) ; bss_desc = & priv -> curr_bss_params . bss_descriptor ; priv -> attempted_bss_desc = bss_desc ; memset ( adhoc_start -> ssid , 0 , IEEE80211_MAX_SSID_LEN ) ; memcpy ( adhoc_start -> ssid , req_ssid -> ssid , req_ssid -> ssid_len ) ; mwifiex_dbg ( adapter , INFO , ""info:ADHOC_S_CMD:SSID=%s\\n"" , adhoc_start -> ssid ) ; memset ( bss_desc -> ssid . ssid , 0 , IEEE80211_MAX_SSID_LEN ) ; memcpy ( bss_desc -> ssid . ssid , req_ssid -> ssid , req_ssid -> ssid_len ) ; bss_desc -> ssid . ssid_len = req_ssid -> ssid_len ; adhoc_start -> bss_mode = HostCmd_BSS_MODE_IBSS ; bss_desc -> bss_mode = NL80211_IFTYPE_ADHOC ; adhoc_start -> beacon_period = cpu_to_le16 ( priv -> beacon_period ) ; bss_desc -> beacon_period = priv -> beacon_period ; # define DS_PARA_IE_ID 3 # define DS_PARA_IE_LEN 1 adhoc_start -> phy_param_set . ds_param_set . element_id = DS_PARA_IE_ID ; adhoc_start -> phy_param_set . ds_param_set . len = DS_PARA_IE_LEN ; if ( ! mwifiex_get_cfp ( priv , adapter -> adhoc_start_band , ( u16 ) priv -> adhoc_channel , 0 ) ) { struct mwifiex_chan_freq_power * cfp ; cfp = mwifiex_get_cfp ( priv , adapter -> adhoc_start_band , FIRST_VALID_CHANNEL , 0 ) ; if ( cfp ) priv -> adhoc_channel = ( u8 ) cfp -> channel ; } if ( ! priv -> adhoc_channel ) { mwifiex_dbg ( adapter , ERROR , ""ADHOC_S_CMD:adhoc_channelcannotbe0\\n"" ) ; return - 1 ; } mwifiex_dbg ( adapter , INFO , ""info:ADHOC_S_CMD:creatingADHOConchannel%d\\n"" , priv -> adhoc_channel ) ; priv -> curr_bss_params . bss_descriptor . channel = priv -> adhoc_channel ; priv -> curr_bss_params . band = adapter -> adhoc_start_band ; bss_desc -> channel = priv -> adhoc_channel ; adhoc_start -> phy_param_set . ds_param_set . current_chan = priv -> adhoc_channel ; memcpy ( & bss_desc -> phy_param_set , & adhoc_start -> phy_param_set , sizeof ( union ieee_types_phy_param_set ) ) ; # define IBSS_PARA_IE_ID 6 # define IBSS_PARA_IE_LEN 2 adhoc_start -> ss_param_set . ibss_param_set . element_id = IBSS_PARA_IE_ID ; adhoc_start -> ss_param_set . ibss_param_set . len = IBSS_PARA_IE_LEN ; adhoc_start -> ss_param_set . ibss_param_set . atim_window = cpu_to_le16 ( priv -> atim_window ) ; memcpy ( & bss_desc -> ss_param_set , & adhoc_start -> ss_param_set , sizeof ( union ieee_types_ss_param_set ) ) ; bss_desc -> cap_info_bitmap |= WLAN_CAPABILITY_IBSS ; tmp_cap = WLAN_CAPABILITY_IBSS ; if ( priv -> sec_info . encryption_mode ) { mwifiex_dbg ( adapter , INFO , ""info:ADHOC_S_CMD:wep_statussetprivacytoWEP\\n"" ) ; bss_desc -> privacy = MWIFIEX_802_11_PRIV_FILTER_8021X_WEP ; tmp_cap |= WLAN_CAPABILITY_PRIVACY ; } else { mwifiex_dbg ( adapter , INFO , ""info:ADHOC_S_CMD:wep_statusNOTset,\\t"" ""settingprivacytoACCEPTALL\\n"" ) ; bss_desc -> privacy = MWIFIEX_802_11_PRIV_FILTER_ACCEPT_ALL ; } memset ( adhoc_start -> data_rate , 0 , sizeof ( adhoc_start -> data_rate ) ) ; mwifiex_get_active_data_rates ( priv , adhoc_start -> data_rate ) ; if ( ( adapter -> adhoc_start_band & BAND_G ) && ( priv -> curr_pkt_filter & HostCmd_ACT_MAC_ADHOC_G_PROTECTION_ON ) ) { if ( mwifiex_send_cmd ( priv , HostCmd_CMD_MAC_CONTROL , HostCmd_ACT_GEN_SET , 0 , & priv -> curr_pkt_filter , false ) ) { mwifiex_dbg ( adapter , ERROR , ""ADHOC_S_CMD:GProtectionconfigfailed\\n"" ) ; return - 1 ; } } for ( i = 0 ; i < sizeof ( adhoc_start -> data_rate ) ; i ++ ) if ( ! adhoc_start -> data_rate [ i ] ) break ; priv -> curr_bss_params . num_of_rates = i ; memcpy ( & priv -> curr_bss_params . data_rates , & adhoc_start -> data_rate , priv -> curr_bss_params . num_of_rates ) ; mwifiex_dbg ( adapter , INFO , ""info:ADHOC_S_CMD:rates=%4ph\\n"" , adhoc_start -> data_rate ) ; mwifiex_dbg ( adapter , INFO , ""info:ADHOC_S_CMD:AD-HOCStartcommandisready\\n"" ) ; if ( IS_SUPPORT_MULTI_BANDS ( adapter ) ) { chan_tlv = ( struct mwifiex_ie_types_chan_list_param_set * ) pos ; chan_tlv -> header . type = cpu_to_le16 ( TLV_TYPE_CHANLIST ) ; chan_tlv -> header . len = cpu_to_le16 ( sizeof ( struct mwifiex_chan_scan_param_set ) ) ; memset ( chan_tlv -> chan_scan_param , 0x00 , sizeof ( struct mwifiex_chan_scan_param_set ) ) ; chan_tlv -> chan_scan_param [ 0 ] . chan_number = ( u8 ) priv -> curr_bss_params . bss_descriptor . channel ; mwifiex_dbg ( adapter , INFO , ""info:ADHOC_S_CMD:TLVChan=%d\\n"" , chan_tlv -> chan_scan_param [ 0 ] . chan_number ) ; chan_tlv -> chan_scan_param [ 0 ] . radio_type = mwifiex_band_to_radio_type ( priv -> curr_bss_params . band ) ; if ( adapter -> adhoc_start_band & BAND_GN || adapter -> adhoc_start_band & BAND_AN ) { if ( adapter -> sec_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_ABOVE ) chan_tlv -> chan_scan_param [ 0 ] . radio_type |= ( IEEE80211_HT_PARAM_CHA_SEC_ABOVE << 4 ) ; else if ( adapter -> sec_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_BELOW ) chan_tlv -> chan_scan_param [ 0 ] . radio_type |= ( IEEE80211_HT_PARAM_CHA_SEC_BELOW << 4 ) ; } mwifiex_dbg ( adapter , INFO , ""info:ADHOC_S_CMD:TLVBand=%d\\n"" , chan_tlv -> chan_scan_param [ 0 ] . radio_type ) ; pos += sizeof ( chan_tlv -> header ) + sizeof ( struct mwifiex_chan_scan_param_set ) ; cmd_append_size += sizeof ( chan_tlv -> header ) + sizeof ( struct mwifiex_chan_scan_param_set ) ; } cmd_append_size += mwifiex_cmd_append_vsie_tlv ( priv , MWIFIEX_VSIE_MASK_ADHOC , & pos ) ; if ( priv -> sec_info . wpa_enabled ) { rsn_ie_len = mwifiex_append_rsn_ie_wpa_wpa2 ( priv , & pos ) ; if ( rsn_ie_len == - 1 ) return - 1 ; cmd_append_size += rsn_ie_len ; } if ( adapter -> adhoc_11n_enabled ) { ht_cap = ( struct mwifiex_ie_types_htcap * ) pos ; memset ( ht_cap , 0 , sizeof ( struct mwifiex_ie_types_htcap ) ) ; ht_cap -> header . type = cpu_to_le16 ( WLAN_EID_HT_CAPABILITY ) ; ht_cap -> header . len = cpu_to_le16 ( sizeof ( struct ieee80211_ht_cap ) ) ; radio_type = mwifiex_band_to_radio_type ( priv -> adapter -> config_bands ) ; mwifiex_fill_cap_info ( priv , radio_type , & ht_cap -> ht_cap ) ; if ( adapter -> sec_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_NONE ) { u16 tmp_ht_cap ; tmp_ht_cap = le16_to_cpu ( ht_cap -> ht_cap . cap_info ) ; tmp_ht_cap &= ~ IEEE80211_HT_CAP_SUP_WIDTH_20_40 ; tmp_ht_cap &= ~ IEEE80211_HT_CAP_SGI_40 ; ht_cap -> ht_cap . cap_info = cpu_to_le16 ( tmp_ht_cap ) ; } pos += sizeof ( struct mwifiex_ie_types_htcap ) ; cmd_append_size += sizeof ( struct mwifiex_ie_types_htcap ) ; ht_info = ( struct mwifiex_ie_types_htinfo * ) pos ; memset ( ht_info , 0 , sizeof ( struct mwifiex_ie_types_htinfo ) ) ; ht_info -> header . type = cpu_to_le16 ( WLAN_EID_HT_OPERATION ) ; ht_info -> header . len = cpu_to_le16 ( sizeof ( struct ieee80211_ht_operation ) ) ; ht_info -> ht_oper . primary_chan = ( u8 ) priv -> curr_bss_params . bss_descriptor . channel ; if ( adapter -> sec_chan_offset ) { ht_info -> ht_oper . ht_param = adapter -> sec_chan_offset ; ht_info -> ht_oper . ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY ; } ht_info -> ht_oper . operation_mode = cpu_to_le16 ( IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT ) ; ht_info -> ht_oper . basic_set [ 0 ] = 0xff ; pos += sizeof ( struct mwifiex_ie_types_htinfo ) ; cmd_append_size += sizeof ( struct mwifiex_ie_types_htinfo ) ; } cmd -> size = cpu_to_le16 ( ( u16 ) ( sizeof ( struct host_cmd_ds_802_11_ad_hoc_start ) + S_DS_GEN + cmd_append_size ) ) ; if ( adapter -> adhoc_start_band == BAND_B ) tmp_cap &= ~ WLAN_CAPABILITY_SHORT_SLOT_TIME ; else tmp_cap |= WLAN_CAPABILITY_SHORT_SLOT_TIME ; adhoc_start -> cap_info_bitmap = cpu_to_le16 ( tmp_cap ) ; return 0 ; } "," , IEEE80211_MAX_SSID_LEN ) ; if ( req_ssid -> ssid_len > IEEE80211_MAX_SSID_LEN ) req_ssid -> ssid_len = IEEE80211_MAX_SSID_LEN ",torvalds@linux/5c455c5ab332773464d02ba17015acdca198f03d,CVE-2020-36158,https://github.com/torvalds/linux/commit/5c455c5ab332773464d02ba17015acdca198f03d,2021-01-05T05:15Z 1049,CWE-400,"CWE-400 int xfs_attr_shortform_list ( xfs_attr_list_context_t * context ) { attrlist_cursor_kern_t * cursor ; xfs_attr_sf_sort_t * sbuf , * sbp ; xfs_attr_shortform_t * sf ; xfs_attr_sf_entry_t * sfe ; xfs_inode_t * dp ; int sbsize , nsbuf , count , i ; int error ; ASSERT ( context != NULL ) ; dp = context -> dp ; ASSERT ( dp != NULL ) ; ASSERT ( dp -> i_afp != NULL ) ; sf = ( xfs_attr_shortform_t * ) dp -> i_afp -> if_u1 . if_data ; ASSERT ( sf != NULL ) ; if ( ! sf -> hdr . count ) return 0 ; cursor = context -> cursor ; ASSERT ( cursor != NULL ) ; trace_xfs_attr_list_sf ( context ) ; if ( context -> bufsize == 0 || ( XFS_ISRESET_CURSOR ( cursor ) && ( dp -> i_afp -> if_bytes + sf -> hdr . count * 16 ) < context -> bufsize ) ) { for ( i = 0 , sfe = & sf -> list [ 0 ] ; i < sf -> hdr . count ; i ++ ) { error = context -> put_listent ( context , sfe -> flags , sfe -> nameval , ( int ) sfe -> namelen , ( int ) sfe -> valuelen , & sfe -> nameval [ sfe -> namelen ] ) ; if ( context -> seen_enough ) break ; if ( error ) return error ; sfe = XFS_ATTR_SF_NEXTENTRY ( sfe ) ; } trace_xfs_attr_list_sf_all ( context ) ; return 0 ; } if ( context -> bufsize == 0 ) return 0 ; sbsize = sf -> hdr . count * sizeof ( * sbuf ) ; sbp = sbuf = kmem_alloc ( sbsize , KM_SLEEP | KM_NOFS ) ; nsbuf = 0 ; for ( i = 0 , sfe = & sf -> list [ 0 ] ; i < sf -> hdr . count ; i ++ ) { if ( unlikely ( ( ( char * ) sfe < ( char * ) sf ) || ( ( char * ) sfe >= ( ( char * ) sf + dp -> i_afp -> if_bytes ) ) ) ) { XFS_CORRUPTION_ERROR ( ""xfs_attr_shortform_list"" , XFS_ERRLEVEL_LOW , context -> dp -> i_mount , sfe ) ; kmem_free ( sbuf ) ; return - EFSCORRUPTED ; } sbp -> entno = i ; sbp -> hash = xfs_da_hashname ( sfe -> nameval , sfe -> namelen ) ; sbp -> name = sfe -> nameval ; sbp -> namelen = sfe -> namelen ; sbp -> valuelen = sfe -> valuelen ; sbp -> flags = sfe -> flags ; sfe = XFS_ATTR_SF_NEXTENTRY ( sfe ) ; sbp ++ ; nsbuf ++ ; } xfs_sort ( sbuf , nsbuf , sizeof ( * sbuf ) , xfs_attr_shortform_compare ) ; count = 0 ; cursor -> initted = 1 ; cursor -> blkno = 0 ; for ( sbp = sbuf , i = 0 ; i < nsbuf ; i ++ , sbp ++ ) { if ( sbp -> hash == cursor -> hashval ) { if ( cursor -> offset == count ) { break ; } count ++ ; } else if ( sbp -> hash > cursor -> hashval ) { break ; } } if ( i == nsbuf ) { kmem_free ( sbuf ) ; return 0 ; } for ( ; i < nsbuf ; i ++ , sbp ++ ) { if ( cursor -> hashval != sbp -> hash ) { cursor -> hashval = sbp -> hash ; cursor -> offset = 0 ; } error = context -> put_listent ( context , sbp -> flags , sbp -> name , sbp -> namelen , sbp -> valuelen , & sbp -> name [ sbp -> namelen ] ) ; if ( error ) return error ; if ( context -> seen_enough ) break ; cursor -> offset ++ ; } kmem_free ( sbuf ) ; return 0 ; } "," ( error ) { kmem_free ( sbuf ) ; return error ; } ",torvalds@linux/2e83b79b2d6c78bf1b4aa227938a214dcbddc83f,CVE-2016-9685,https://github.com/torvalds/linux/commit/2e83b79b2d6c78bf1b4aa227938a214dcbddc83f,2016-12-28T07:59Z 1050,CWE-310,"CWE-310 int X509_verify ( X509 * a , EVP_PKEY * r ) { return ( ASN1_item_verify ( ASN1_ITEM_rptr ( X509_CINF ) , a -> sig_alg , a -> signature , a -> cert_info , r ) ) ; } "," r ) { if ( X509_ALGOR_cmp ( a -> sig_alg , a -> cert_info -> signature ) ) return 0 ; ",openssl@openssl/684400ce192dac51df3d3e92b61830a6ef90be3e,CVE-2014-8275,https://github.com/openssl/openssl/commit/684400ce192dac51df3d3e92b61830a6ef90be3e,2015-01-09T02:59Z 1051,CWE-20,"CWE-20 static int snd_hrtimer_start ( struct snd_timer * t ) { struct snd_hrtimer * stime = t -> private_data ; atomic_set ( & stime -> running , 0 ) ; hrtimer_cancel ( & stime -> hrt ) ; hrtimer_start ( & stime -> hrt , ns_to_ktime ( t -> sticks * resolution ) , HRTIMER_MODE_REL ) ; atomic_set ( & stime -> running , 1 ) ; return 0 ; } "," 0 ) ; hrtimer_try_to_cancel ( & stime ",torvalds@linux/2ba1fe7a06d3624f9a7586d672b55f08f7c670f3,CVE-2016-2549,https://github.com/torvalds/linux/commit/2ba1fe7a06d3624f9a7586d672b55f08f7c670f3,2016-04-27T17:59Z 1052,CWE-125,"CWE-125 static int forward_search_range ( regex_t * reg , const UChar * str , const UChar * end , UChar * s , UChar * range , UChar * * low , UChar * * high , UChar * * low_prev ) { UChar * p , * pprev = ( UChar * ) NULL ; # ifdef ONIG_DEBUG_SEARCH fprintf ( stderr , ""forward_search_range:str:%d,end:%d,s:%d,range:%d\\n"" , ( int ) str , ( int ) end , ( int ) s , ( int ) range ) ; # endif p = s ; if ( reg -> dmin > 0 ) { if ( ONIGENC_IS_SINGLEBYTE ( reg -> enc ) ) { p += reg -> dmin ; } else { UChar * q = p + reg -> dmin ; while ( p < q ) p += enclen ( reg -> enc , p ) ; } } retry : switch ( reg -> optimize ) { case ONIG_OPTIMIZE_EXACT : p = slow_search ( reg -> enc , reg -> exact , reg -> exact_end , p , end , range ) ; break ; case ONIG_OPTIMIZE_EXACT_IC : p = slow_search_ic ( reg -> enc , reg -> case_fold_flag , reg -> exact , reg -> exact_end , p , end , range ) ; break ; case ONIG_OPTIMIZE_EXACT_BM : p = bm_search ( reg , reg -> exact , reg -> exact_end , p , end , range ) ; break ; case ONIG_OPTIMIZE_EXACT_BM_NOT_REV : p = bm_search_notrev ( reg , reg -> exact , reg -> exact_end , p , end , range ) ; break ; case ONIG_OPTIMIZE_MAP : p = map_search ( reg -> enc , reg -> map , p , range ) ; break ; } if ( p && p < range ) { if ( p - reg -> dmin < s ) { retry_gate : pprev = p ; p += enclen ( reg -> enc , p ) ; goto retry ; } if ( reg -> sub_anchor ) { UChar * prev ; switch ( reg -> sub_anchor ) { case ANCHOR_BEGIN_LINE : if ( ! ON_STR_BEGIN ( p ) ) { prev = onigenc_get_prev_char_head ( reg -> enc , ( pprev ? pprev : str ) , p ) ; if ( ! ONIGENC_IS_MBC_NEWLINE ( reg -> enc , prev , end ) ) goto retry_gate ; } break ; case ANCHOR_END_LINE : if ( ON_STR_END ( p ) ) { # ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE prev = ( UChar * ) onigenc_get_prev_char_head ( reg -> enc , ( pprev ? pprev : str ) , p ) ; if ( prev && ONIGENC_IS_MBC_NEWLINE ( reg -> enc , prev , end ) ) goto retry_gate ; # endif } else if ( ! ONIGENC_IS_MBC_NEWLINE ( reg -> enc , p , end ) # ifdef USE_CRNL_AS_LINE_TERMINATOR && ! ONIGENC_IS_MBC_CRNL ( reg -> enc , p , end ) # endif ) goto retry_gate ; break ; } } if ( reg -> dmax == 0 ) { * low = p ; if ( low_prev ) { if ( * low > s ) * low_prev = onigenc_get_prev_char_head ( reg -> enc , s , p ) ; else * low_prev = onigenc_get_prev_char_head ( reg -> enc , ( pprev ? pprev : str ) , p ) ; } } else { if ( reg -> dmax != ONIG_INFINITE_DISTANCE ) { * low = p - reg -> dmax ; if ( * low > s ) { * low = onigenc_get_right_adjust_char_head_with_prev ( reg -> enc , s , * low , ( const UChar * * ) low_prev ) ; if ( low_prev && IS_NULL ( * low_prev ) ) * low_prev = onigenc_get_prev_char_head ( reg -> enc , ( pprev ? pprev : s ) , * low ) ; } else { if ( low_prev ) * low_prev = onigenc_get_prev_char_head ( reg -> enc , ( pprev ? pprev : str ) , * low ) ; } } } * high = p - reg -> dmin ; # ifdef ONIG_DEBUG_SEARCH fprintf ( stderr , ""forward_search_rangesuccess:low:%d,high:%d,dmin:%d,dmax:%d\\n"" , ( int ) ( * low - str ) , ( int ) ( * high - str ) , reg -> dmin , reg -> dmax ) ; # endif return 1 ; } return 0 ; } "," -> dmin ; if ( q >= end ) return 0 ; ",kkos@oniguruma/9690d3ab1f9bcd2db8cbe1fe3ee4a5da606b8814,CVE-2017-9227,https://github.com/kkos/oniguruma/commit/9690d3ab1f9bcd2db8cbe1fe3ee4a5da606b8814,2017-05-24T15:29Z 1053,CWE-787,"CWE-787 static int l2cap_build_conf_req ( struct sock * sk , void * data ) { struct l2cap_pinfo * pi = l2cap_pi ( sk ) ; struct l2cap_conf_req * req = data ; struct l2cap_conf_rfc rfc = { . mode = L2CAP_MODE_BASIC } ; void * ptr = req -> data ; BT_DBG ( ""sk%p"" , sk ) ; switch ( pi -> mode ) { case L2CAP_MODE_BASIC : if ( pi -> imtu != L2CAP_DEFAULT_MTU ) l2cap_add_conf_opt ( & ptr , L2CAP_CONF_MTU , 2 , pi -> imtu ) ; break ; case L2CAP_MODE_ERTM : rfc . mode = L2CAP_MODE_ERTM ; rfc . txwin_size = L2CAP_DEFAULT_RX_WINDOW ; rfc . max_transmit = L2CAP_DEFAULT_MAX_RECEIVE ; rfc . retrans_timeout = cpu_to_le16 ( L2CAP_DEFAULT_RETRANS_TO ) ; rfc . monitor_timeout = cpu_to_le16 ( L2CAP_DEFAULT_MONITOR_TO ) ; rfc . max_pdu_size = cpu_to_le16 ( L2CAP_DEFAULT_MAX_RX_APDU ) ; l2cap_add_conf_opt ( & ptr , L2CAP_CONF_RFC , sizeof ( rfc ) , ( unsigned long ) & rfc ) ; break ; } req -> dcid = cpu_to_le16 ( pi -> dcid ) ; req -> flags = cpu_to_le16 ( 0 ) ; return ptr - data ; } "," . mode = L2CAP_MODE_ERTM } ; void sk ) ; if ( pi -> num_conf_req || pi -> num_conf_rsp ) goto done ; switch ( pi -> mode ) { case L2CAP_MODE_STREAMING : case L2CAP_MODE_ERTM : pi -> conf_state |= L2CAP_CONF_STATE2_DEVICE ; if ( ! l2cap_mode_supported ( pi -> mode , pi -> conn -> feat_mask ) ) { struct l2cap_disconn_req req ; req . dcid = cpu_to_le16 ( pi -> dcid ) ; req . scid = cpu_to_le16 ( pi -> scid ) ; l2cap_send_cmd ( pi -> conn , l2cap_get_ident ( pi -> conn ) , L2CAP_DISCONN_REQ , sizeof ( req ) , & req ) ; } break ; default : pi -> mode = l2cap_select_mode ( rfc . mode , pi -> conn -> feat_mask ) ; break ; } done : . txwin_size = L2CAP_DEFAULT_TX_WINDOW ; rfc . . retrans_timeout = 0 ; rfc . . monitor_timeout = 0 ; rfc . max_pdu_size = cpu_to_le16 ( L2CAP_DEFAULT_MAX_RX_APDU ) ; l2cap_add_conf_opt ( & ptr , L2CAP_CONF_RFC , sizeof ( rfc ) , ( unsigned long ) & rfc ) ; break ; case L2CAP_MODE_STREAMING : rfc . mode = L2CAP_MODE_STREAMING ; rfc . txwin_size = 0 ; rfc . max_transmit = 0 ; rfc . retrans_timeout = 0 ; rfc . monitor_timeout = 0 ; rfc . ",torvalds@linux/f2fcfcd670257236ebf2088bbdf26f6a8ef459fe,CVE-2017-1000251,https://github.com/torvalds/linux/commit/f2fcfcd670257236ebf2088bbdf26f6a8ef459fe,2017-09-12T17:29Z 1054,CWE-284,"CWE-284 int sock_recv_all ( int sock_fd , uint8_t * buf , int len ) { int r = len ; int ret = - 1 ; while ( r ) { do ret = recv ( sock_fd , buf , r , MSG_WAITALL ) ; while ( ret < 0 && errno == EINTR ) ; if ( ret <= 0 ) { BTIF_TRACE_ERROR ( ""sockfd:%drecverrno:%d,ret:%d"" , sock_fd , errno , ret ) ; return - 1 ; } buf += ret ; r -= ret ; } return len ; } "," do ret = TEMP_FAILURE_RETRY ( r , MSG_WAITALL ) ",system@bt/472271b153c5dc53c28beac55480a8d8434b2d5c,CVE-2016-3839,https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c,2016-08-05T20:59Z 1055,CWE-119,"CWE-119 static int http_read_header ( URLContext * h , int * new_location ) { HTTPContext * s = h -> priv_data ; char line [ MAX_URL_SIZE ] ; int err = 0 ; s -> chunksize = - 1 ; for ( ; ; ) { if ( ( err = http_get_line ( s , line , sizeof ( line ) ) ) < 0 ) return err ; av_log ( h , AV_LOG_TRACE , ""header=\'%s\'\\n"" , line ) ; err = process_line ( h , line , s -> line_count , new_location ) ; if ( err < 0 ) return err ; if ( err == 0 ) break ; s -> line_count ++ ; } if ( s -> seekable == - 1 && s -> is_mediagateway && s -> filesize == 2000000000 ) h -> is_streamed = 1 ; cookie_string ( s -> cookie_dict , & s -> cookies ) ; av_dict_free ( & s -> cookie_dict ) ; return err ; } "," -> chunksize = UINT64_MAX ; for ( ",FFmpeg@FFmpeg/2a05c8f813de6f2278827734bf8102291e7484aa,CVE-2016-10190,https://github.com/FFmpeg/FFmpeg/commit/2a05c8f813de6f2278827734bf8102291e7484aa,2017-02-09T15:59Z 1056,CWE-200,"CWE-200 WORD32 ih264d_parse_nal_unit ( iv_obj_t * dec_hdl , ivd_video_decode_op_t * ps_dec_op , UWORD8 * pu1_buf , UWORD32 u4_length ) { dec_bit_stream_t * ps_bitstrm ; dec_struct_t * ps_dec = ( dec_struct_t * ) dec_hdl -> pv_codec_handle ; ivd_video_decode_ip_t * ps_dec_in = ( ivd_video_decode_ip_t * ) ps_dec -> pv_dec_in ; dec_slice_params_t * ps_cur_slice = ps_dec -> ps_cur_slice ; UWORD8 u1_first_byte , u1_nal_ref_idc ; UWORD8 u1_nal_unit_type ; WORD32 i_status = OK ; ps_bitstrm = ps_dec -> ps_bitstrm ; if ( pu1_buf ) { if ( u4_length ) { ps_dec_op -> u4_frame_decoded_flag = 0 ; ih264d_process_nal_unit ( ps_dec -> ps_bitstrm , pu1_buf , u4_length ) ; SWITCHOFFTRACE ; u1_first_byte = ih264d_get_bits_h264 ( ps_bitstrm , 8 ) ; if ( NAL_FORBIDDEN_BIT ( u1_first_byte ) ) { H264_DEC_DEBUG_PRINT ( ""\\nForbiddenbitsetinNalUnit,Let\'stry\\n"" ) ; } u1_nal_unit_type = NAL_UNIT_TYPE ( u1_first_byte ) ; if ( ( ps_dec -> u4_slice_start_code_found == 1 ) && ( ps_dec -> u1_pic_decode_done != 1 ) && ( u1_nal_unit_type > IDR_SLICE_NAL ) ) { return ERROR_INCOMPLETE_FRAME ; } ps_dec -> u1_nal_unit_type = u1_nal_unit_type ; u1_nal_ref_idc = ( UWORD8 ) ( NAL_REF_IDC ( u1_first_byte ) ) ; switch ( u1_nal_unit_type ) { case SLICE_DATA_PARTITION_A_NAL : case SLICE_DATA_PARTITION_B_NAL : case SLICE_DATA_PARTITION_C_NAL : if ( ! ps_dec -> i4_decode_header ) ih264d_parse_slice_partition ( ps_dec , ps_bitstrm ) ; break ; case IDR_SLICE_NAL : case SLICE_NAL : DEBUG_THREADS_PRINTF ( ""DecodingasliceNAL\\n"" ) ; if ( ! ps_dec -> i4_decode_header ) { if ( ps_dec -> i4_header_decoded == 3 ) { ps_dec -> u4_slice_start_code_found = 1 ; ih264d_rbsp_to_sodb ( ps_dec -> ps_bitstrm ) ; i_status = ih264d_parse_decode_slice ( ( UWORD8 ) ( u1_nal_unit_type == IDR_SLICE_NAL ) , u1_nal_ref_idc , ps_dec ) ; if ( ( ps_dec -> u4_first_slice_in_pic != 0 ) && ( ( ps_dec -> ps_dec_err_status -> u1_err_flag & REJECT_CUR_PIC ) == 0 ) ) { ps_dec -> u4_first_slice_in_pic = 1 ; } if ( i_status != OK ) { return i_status ; } } else { H264_DEC_DEBUG_PRINT ( ""\\nSliceNALSuppliedbutnoheaderhasbeensupplied\\n"" ) ; } } break ; case SEI_NAL : if ( ! ps_dec -> i4_decode_header ) { ih264d_rbsp_to_sodb ( ps_dec -> ps_bitstrm ) ; i_status = ih264d_parse_sei_message ( ps_dec , ps_bitstrm ) ; if ( i_status != OK ) return i_status ; ih264d_parse_sei ( ps_dec , ps_bitstrm ) ; } break ; case SEQ_PARAM_NAL : ih264d_rbsp_to_sodb ( ps_dec -> ps_bitstrm ) ; i_status = ih264d_parse_sps ( ps_dec , ps_bitstrm ) ; if ( i_status == ERROR_INV_SPS_PPS_T ) return i_status ; if ( ! i_status ) ps_dec -> i4_header_decoded |= 0x1 ; break ; case PIC_PARAM_NAL : ih264d_rbsp_to_sodb ( ps_dec -> ps_bitstrm ) ; i_status = ih264d_parse_pps ( ps_dec , ps_bitstrm ) ; if ( i_status == ERROR_INV_SPS_PPS_T ) return i_status ; if ( ! i_status ) ps_dec -> i4_header_decoded |= 0x2 ; break ; case ACCESS_UNIT_DELIMITER_RBSP : if ( ! ps_dec -> i4_decode_header ) { ih264d_access_unit_delimiter_rbsp ( ps_dec ) ; } break ; case END_OF_STREAM_RBSP : if ( ! ps_dec -> i4_decode_header ) { ih264d_parse_end_of_stream ( ps_dec ) ; } break ; case FILLER_DATA_NAL : if ( ! ps_dec -> i4_decode_header ) { ih264d_parse_filler_data ( ps_dec , ps_bitstrm ) ; } break ; default : H264_DEC_DEBUG_PRINT ( ""\\nUnknownNALtype%d\\n"" , u1_nal_unit_type ) ; break ; } } } return i_status ; } "," ; if ( i_status != OK ",external@libavc/0b23c81c3dd9ec38f7e6806a3955fed1925541a0,CVE-2017-0555,https://android.googlesource.com/platform/external/libavc/+/0b23c81c3dd9ec38f7e6806a3955fed1925541a0,2017-04-07T22:59Z 1057,CWE-000,"CWE-000 static void addFormVars ( cchar * buf ) { char * pair , * tok ; pair = stok ( sclone ( buf ) , ""&"" , & tok ) ; while ( pair != 0 ) { mprAddItem ( app -> formData , sclone ( pair ) ) ; pair = stok ( 0 , ""&"" , & tok ) ; } } "," while ( pair ) { mprAddItem ",embedthis@appweb/7e6a925f5e86a19a7934a94bbd6959101d0b84eb,CVE-2014-9708,https://github.com/embedthis/appweb/commit/7e6a925f5e86a19a7934a94bbd6959101d0b84eb,2015-03-31T14:59Z 1058,CWE-476,"CWE-476 int crypto_rng_reset ( struct crypto_rng * tfm , const u8 * seed , unsigned int slen ) { u8 * buf = NULL ; int err ; if ( ! seed && slen ) { buf = kmalloc ( slen , GFP_KERNEL ) ; if ( ! buf ) return - ENOMEM ; get_random_bytes ( buf , slen ) ; seed = buf ; } err = tfm -> seed ( tfm , seed , slen ) ; kfree ( buf ) ; return err ; } "," } err = crypto_rng_alg ( tfm ) -> seed ( ",torvalds@linux/94f1bb15bed84ad6c893916b7e7b9db6f1d7eec6,CVE-2017-15116,https://github.com/torvalds/linux/commit/94f1bb15bed84ad6c893916b7e7b9db6f1d7eec6,2017-11-30T18:29Z 1059,CWE-416,"CWE-416 static struct ucounts * get_ucounts ( struct user_namespace * ns , kuid_t uid ) { struct hlist_head * hashent = ucounts_hashentry ( ns , uid ) ; struct ucounts * ucounts , * new ; spin_lock_irq ( & ucounts_lock ) ; ucounts = find_ucounts ( ns , uid , hashent ) ; if ( ! ucounts ) { spin_unlock_irq ( & ucounts_lock ) ; new = kzalloc ( sizeof ( * new ) , GFP_KERNEL ) ; if ( ! new ) return NULL ; new -> ns = ns ; new -> uid = uid ; atomic_set ( & new -> count , 0 ) ; spin_lock_irq ( & ucounts_lock ) ; ucounts = find_ucounts ( ns , uid , hashent ) ; if ( ucounts ) { kfree ( new ) ; } else { hlist_add_head ( & new -> node , hashent ) ; ucounts = new ; } } if ( ! atomic_add_unless ( & ucounts -> count , 1 , INT_MAX ) ) ucounts = NULL ; spin_unlock_irq ( & ucounts_lock ) ; return ucounts ; } "," = uid ; new -> count new -> count = 0 ; spin_lock_irq ( } if ( ucounts -> count ucounts -> count == INT_MAX ) ucounts = NULL ; else ucounts -> count += 1 ; spin_unlock_irq ( ",torvalds@linux/040757f738e13caaa9c5078bca79aa97e11dde88,CVE-2017-6874,https://github.com/torvalds/linux/commit/040757f738e13caaa9c5078bca79aa97e11dde88,2017-03-14T09:59Z 1060,CWE-19,"CWE-19 int __sys_recvmmsg ( int fd , struct mmsghdr __user * mmsg , unsigned int vlen , unsigned int flags , struct timespec * timeout ) { int fput_needed , err , datagrams ; struct socket * sock ; struct mmsghdr __user * entry ; struct compat_mmsghdr __user * compat_entry ; struct msghdr msg_sys ; struct timespec end_time ; if ( timeout && poll_select_set_timeout ( & end_time , timeout -> tv_sec , timeout -> tv_nsec ) ) return - EINVAL ; datagrams = 0 ; sock = sockfd_lookup_light ( fd , & err , & fput_needed ) ; if ( ! sock ) return err ; err = sock_error ( sock -> sk ) ; if ( err ) goto out_put ; entry = mmsg ; compat_entry = ( struct compat_mmsghdr __user * ) mmsg ; while ( datagrams < vlen ) { if ( MSG_CMSG_COMPAT & flags ) { err = ___sys_recvmsg ( sock , ( struct user_msghdr __user * ) compat_entry , & msg_sys , flags & ~ MSG_WAITFORONE , datagrams ) ; if ( err < 0 ) break ; err = __put_user ( err , & compat_entry -> msg_len ) ; ++ compat_entry ; } else { err = ___sys_recvmsg ( sock , ( struct user_msghdr __user * ) entry , & msg_sys , flags & ~ MSG_WAITFORONE , datagrams ) ; if ( err < 0 ) break ; err = put_user ( err , & entry -> msg_len ) ; ++ entry ; } if ( err ) break ; ++ datagrams ; if ( flags & MSG_WAITFORONE ) flags |= MSG_DONTWAIT ; if ( timeout ) { ktime_get_ts ( timeout ) ; * timeout = timespec_sub ( end_time , * timeout ) ; if ( timeout -> tv_sec < 0 ) { timeout -> tv_sec = timeout -> tv_nsec = 0 ; break ; } if ( timeout -> tv_nsec == 0 && timeout -> tv_sec == 0 ) break ; } if ( msg_sys . msg_flags & MSG_OOB ) break ; cond_resched ( ) ; } out_put : fput_light ( sock -> file , fput_needed ) ; if ( err == 0 ) return datagrams ; if ( datagrams != 0 ) { if ( err != - EAGAIN ) { sock -> sk -> sk_err = - err ; } return datagrams ; } return err ; } "," ) ; } if ( err == 0 ) goto out_put ; if ( datagrams == 0 ) == 0 ) { datagrams = err ; goto out_put ; } if ( err err ; } out_put : fput_light ( sock -> file , fput_needed ) ; datagrams ; } ",torvalds@linux/34b88a68f26a75e4fded796f1a49c40f82234b7d,CVE-2016-7117,https://github.com/torvalds/linux/commit/34b88a68f26a75e4fded796f1a49c40f82234b7d,2016-10-10T11:00Z 1061,CWE-125,"CWE-125 void ntlm_free_message_fields_buffer ( NTLM_MESSAGE_FIELDS * fields ) { if ( fields ) { if ( fields -> Buffer ) { free ( fields -> Buffer ) ; fields -> Len = 0 ; fields -> MaxLen = 0 ; fields -> Buffer = NULL ; fields -> BufferOffset = 0 ; } } } "," static ",FreeRDP@FreeRDP/2ee663f39dc8dac3d9988e847db19b2d7e3ac8c6,CVE-2018-8789,https://github.com/FreeRDP/FreeRDP/commit/2ee663f39dc8dac3d9988e847db19b2d7e3ac8c6,2018-11-29T18:29Z 1062,CWE-310,"CWE-310 static void prefetch_table ( const volatile byte * tab , size_t len ) { size_t i ; for ( i = 0 ; i < len ; i += 8 * 32 ) { ( void ) tab [ i + 0 * 32 ] ; ( void ) tab [ i + 1 * 32 ] ; ( void ) tab [ i + 2 * 32 ] ; ( void ) tab [ i + 3 * 32 ] ; ( void ) tab [ i + 4 * 32 ] ; ( void ) tab [ i + 5 * 32 ] ; ( void ) tab [ i + 6 * 32 ] ; ( void ) tab [ i + 7 * 32 ] ; } ( void ) tab [ len - 1 ] ; } "," static inline = 0 ; len - i >= 8 * 32 ; i += ] ; } for ( ; i < len ; i += 32 ) { ( void ) tab [ i ] ; } ",gpg@libgcrypt/daedbbb5541cd8ecda1459d3b843ea4d92788762,CVE-2019-12904,https://github.com/gpg/libgcrypt/commit/daedbbb5541cd8ecda1459d3b843ea4d92788762,2019-06-20T00:15Z 1063,CWE-000,"CWE-000 int ext4_ext_get_blocks ( handle_t * handle , struct inode * inode , ext4_lblk_t iblock , unsigned int max_blocks , struct buffer_head * bh_result , int flags ) { struct ext4_ext_path * path = NULL ; struct ext4_extent_header * eh ; struct ext4_extent newex , * ex , * last_ex ; ext4_fsblk_t newblock ; int err = 0 , depth , ret , cache_type ; unsigned int allocated = 0 ; struct ext4_allocation_request ar ; ext4_io_end_t * io = EXT4_I ( inode ) -> cur_aio_dio ; __clear_bit ( BH_New , & bh_result -> b_state ) ; ext_debug ( ""blocks%u/%urequestedforinode%lu\\n"" , iblock , max_blocks , inode -> i_ino ) ; cache_type = ext4_ext_in_cache ( inode , iblock , & newex ) ; if ( cache_type ) { if ( cache_type == EXT4_EXT_CACHE_GAP ) { if ( ( flags & EXT4_GET_BLOCKS_CREATE ) == 0 ) { goto out2 ; } } else if ( cache_type == EXT4_EXT_CACHE_EXTENT ) { newblock = iblock - le32_to_cpu ( newex . ee_block ) + ext_pblock ( & newex ) ; allocated = ext4_ext_get_actual_len ( & newex ) - ( iblock - le32_to_cpu ( newex . ee_block ) ) ; goto out ; } else { BUG ( ) ; } } path = ext4_ext_find_extent ( inode , iblock , NULL ) ; if ( IS_ERR ( path ) ) { err = PTR_ERR ( path ) ; path = NULL ; goto out2 ; } depth = ext_depth ( inode ) ; if ( path [ depth ] . p_ext == NULL && depth != 0 ) { ext4_error ( inode -> i_sb , ""badextentaddress"" ""inode:%lu,iblock:%d,depth:%d"" , inode -> i_ino , iblock , depth ) ; err = - EIO ; goto out2 ; } eh = path [ depth ] . p_hdr ; ex = path [ depth ] . p_ext ; if ( ex ) { ext4_lblk_t ee_block = le32_to_cpu ( ex -> ee_block ) ; ext4_fsblk_t ee_start = ext_pblock ( ex ) ; unsigned short ee_len ; ee_len = ext4_ext_get_actual_len ( ex ) ; if ( iblock >= ee_block && iblock < ee_block + ee_len ) { newblock = iblock - ee_block + ee_start ; allocated = ee_len - ( iblock - ee_block ) ; ext_debug ( ""%ufitinto%u:%d->%llu\\n"" , iblock , ee_block , ee_len , newblock ) ; if ( ! ext4_ext_is_uninitialized ( ex ) ) { ext4_ext_put_in_cache ( inode , ee_block , ee_len , ee_start , EXT4_EXT_CACHE_EXTENT ) ; goto out ; } ret = ext4_ext_handle_uninitialized_extents ( handle , inode , iblock , max_blocks , path , flags , allocated , bh_result , newblock ) ; return ret ; } } if ( ( flags & EXT4_GET_BLOCKS_CREATE ) == 0 ) { ext4_ext_put_gap_in_cache ( inode , path , iblock ) ; goto out2 ; } ar . lleft = iblock ; err = ext4_ext_search_left ( inode , path , & ar . lleft , & ar . pleft ) ; if ( err ) goto out2 ; ar . lright = iblock ; err = ext4_ext_search_right ( inode , path , & ar . lright , & ar . pright ) ; if ( err ) goto out2 ; if ( max_blocks > EXT_INIT_MAX_LEN && ! ( flags & EXT4_GET_BLOCKS_UNINIT_EXT ) ) max_blocks = EXT_INIT_MAX_LEN ; else if ( max_blocks > EXT_UNINIT_MAX_LEN && ( flags & EXT4_GET_BLOCKS_UNINIT_EXT ) ) max_blocks = EXT_UNINIT_MAX_LEN ; newex . ee_block = cpu_to_le32 ( iblock ) ; newex . ee_len = cpu_to_le16 ( max_blocks ) ; err = ext4_ext_check_overlap ( inode , & newex , path ) ; if ( err ) allocated = ext4_ext_get_actual_len ( & newex ) ; else allocated = max_blocks ; ar . inode = inode ; ar . goal = ext4_ext_find_goal ( inode , path , iblock ) ; ar . logical = iblock ; ar . len = allocated ; if ( S_ISREG ( inode -> i_mode ) ) ar . flags = EXT4_MB_HINT_DATA ; else ar . flags = 0 ; newblock = ext4_mb_new_blocks ( handle , & ar , & err ) ; if ( ! newblock ) goto out2 ; ext_debug ( ""allocatenewblock:goal%llu,found%llu/%u\\n"" , ar . goal , newblock , allocated ) ; ext4_ext_store_pblock ( & newex , newblock ) ; newex . ee_len = cpu_to_le16 ( ar . len ) ; if ( flags & EXT4_GET_BLOCKS_UNINIT_EXT ) { ext4_ext_mark_uninitialized ( & newex ) ; if ( flags == EXT4_GET_BLOCKS_PRE_IO ) { if ( io ) io -> flag = EXT4_IO_UNWRITTEN ; else ext4_set_inode_state ( inode , EXT4_STATE_DIO_UNWRITTEN ) ; } } if ( unlikely ( EXT4_I ( inode ) -> i_flags & EXT4_EOFBLOCKS_FL ) ) { if ( eh -> eh_entries ) { last_ex = EXT_LAST_EXTENT ( eh ) ; if ( iblock + ar . len > le32_to_cpu ( last_ex -> ee_block ) + ext4_ext_get_actual_len ( last_ex ) ) EXT4_I ( inode ) -> i_flags &= ~ EXT4_EOFBLOCKS_FL ; } else { WARN_ON ( eh -> eh_entries == 0 ) ; ext4_error ( inode -> i_sb , __func__ , ""inode#%lu,eh->eh_entries=0!"" , inode -> i_ino ) ; } } err = ext4_ext_insert_extent ( handle , inode , path , & newex , flags ) ; if ( err ) { ext4_discard_preallocations ( inode ) ; ext4_free_blocks ( handle , inode , 0 , ext_pblock ( & newex ) , ext4_ext_get_actual_len ( & newex ) , 0 ) ; goto out2 ; } newblock = ext_pblock ( & newex ) ; allocated = ext4_ext_get_actual_len ( & newex ) ; if ( allocated > max_blocks ) allocated = max_blocks ; set_buffer_new ( bh_result ) ; if ( flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE ) ext4_da_update_reserve_space ( inode , allocated , 1 ) ; if ( ( flags & EXT4_GET_BLOCKS_UNINIT_EXT ) == 0 ) { ext4_ext_put_in_cache ( inode , iblock , allocated , newblock , EXT4_EXT_CACHE_EXTENT ) ; ext4_update_inode_fsync_trans ( handle , inode , 1 ) ; } else ext4_update_inode_fsync_trans ( handle , inode , 0 ) ; out : if ( allocated > max_blocks ) allocated = max_blocks ; ext4_ext_show_leaf ( inode , path ) ; set_buffer_mapped ( bh_result ) ; bh_result -> b_bdev = inode -> i_sb -> s_bdev ; bh_result -> b_blocknr = newblock ; out2 : if ( path ) { ext4_ext_drop_refs ( path ) ; kfree ( path ) ; } return err ? err : allocated ; } "," ; if ( ( flags & EXT4_GET_BLOCKS_PRE_IO ) ) { if ( ) ; } if ( ext4_should_dioread_nolock ( inode ) ) set_buffer_uninit ( bh_result ) ; ",torvalds@linux/744692dc059845b2a3022119871846e74d4f6e11,CVE-2015-8324,https://github.com/torvalds/linux/commit/744692dc059845b2a3022119871846e74d4f6e11,2016-05-02T10:59Z 1064,CWE-000,"CWE-000 static int update_open_stateid ( struct nfs4_state * state , nfs4_stateid * open_stateid , nfs4_stateid * delegation , int open_flags ) { struct nfs_inode * nfsi = NFS_I ( state -> inode ) ; struct nfs_delegation * deleg_cur ; int ret = 0 ; open_flags &= ( FMODE_READ | FMODE_WRITE ) ; rcu_read_lock ( ) ; deleg_cur = rcu_dereference ( nfsi -> delegation ) ; if ( deleg_cur == NULL ) goto no_delegation ; spin_lock ( & deleg_cur -> lock ) ; if ( nfsi -> delegation != deleg_cur || ( deleg_cur -> type & open_flags ) != open_flags ) goto no_delegation_unlock ; if ( delegation == NULL ) delegation = & deleg_cur -> stateid ; else if ( memcmp ( deleg_cur -> stateid . data , delegation -> data , NFS4_STATEID_SIZE ) != 0 ) goto no_delegation_unlock ; nfs_mark_delegation_referenced ( deleg_cur ) ; __update_open_stateid ( state , open_stateid , & deleg_cur -> stateid , open_flags ) ; ret = 1 ; no_delegation_unlock : spin_unlock ( & deleg_cur -> lock ) ; no_delegation : rcu_read_unlock ( ) ; if ( ! ret && open_stateid != NULL ) { __update_open_stateid ( state , open_stateid , NULL , open_flags ) ; ret = 1 ; } return ret ; } "," * delegation , fmode_t fmode ) { struct = 0 ; fmode &= ( FMODE_READ -> type & fmode ) != fmode ) goto no_delegation_unlock -> stateid , fmode ) ; ret , NULL , fmode ) ; ret ",torvalds@linux/dc0b027dfadfcb8a5504f7d8052754bf8d501ab9,CVE-2011-4324,https://github.com/torvalds/linux/commit/dc0b027dfadfcb8a5504f7d8052754bf8d501ab9,2012-06-21T23:55Z 1065,CWE-200,"CWE-200 static Image * ReadGIFImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define BitSet ( byte , bit ) ( ( ( byte ) & ( bit ) ) == ( bit ) ) # define LSBFirstOrder ( x , y ) ( ( ( y ) << 8 ) | ( x ) ) Image * image , * meta_image ; int number_extensionss = 0 ; MagickBooleanType status ; RectangleInfo page ; register ssize_t i ; register unsigned char * p ; size_t delay , dispose , duration , global_colors , image_count , iterations , one ; ssize_t count , opacity ; unsigned char background , c , flag , * global_colormap , buffer [ 257 ] ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } count = ReadBlob ( image , 6 , buffer ) ; if ( ( count != 6 ) || ( ( LocaleNCompare ( ( char * ) buffer , ""GIF87"" , 5 ) != 0 ) && ( LocaleNCompare ( ( char * ) buffer , ""GIF89"" , 5 ) != 0 ) ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; page . width = ReadBlobLSBShort ( image ) ; page . height = ReadBlobLSBShort ( image ) ; flag = ( unsigned char ) ReadBlobByte ( image ) ; background = ( unsigned char ) ReadBlobByte ( image ) ; c = ( unsigned char ) ReadBlobByte ( image ) ; one = 1 ; global_colors = one << ( ( ( size_t ) flag & 0x07 ) + 1 ) ; global_colormap = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) MagickMax ( global_colors , 256 ) , 3UL * sizeof ( * global_colormap ) ) ; if ( global_colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; if ( BitSet ( ( int ) flag , 0x80 ) != 0 ) { count = ReadBlob ( image , ( size_t ) ( 3 * global_colors ) , global_colormap ) ; if ( count != ( ssize_t ) ( 3 * global_colors ) ) { global_colormap = ( unsigned char * ) RelinquishMagickMemory ( global_colormap ) ; ThrowReaderException ( CorruptImageError , ""InsufficientImageDataInFile"" ) ; } } delay = 0 ; dispose = 0 ; duration = 0 ; iterations = 1 ; opacity = ( - 1 ) ; image_count = 0 ; meta_image = AcquireImage ( image_info , exception ) ; for ( ; ; ) { count = ReadBlob ( image , 1 , & c ) ; if ( count != 1 ) break ; if ( c == ( unsigned char ) ';' ) break ; if ( c == ( unsigned char ) '!' ) { count = ReadBlob ( image , 1 , & c ) ; if ( count != 1 ) { global_colormap = ( unsigned char * ) RelinquishMagickMemory ( global_colormap ) ; meta_image = DestroyImage ( meta_image ) ; ThrowReaderException ( CorruptImageError , ""UnableToReadExtensionBlock"" ) ; } switch ( c ) { case 0xf9 : { while ( ReadBlobBlock ( image , buffer ) != 0 ) ; dispose = ( size_t ) ( buffer [ 0 ] >> 2 ) ; delay = ( size_t ) ( ( buffer [ 2 ] << 8 ) | buffer [ 1 ] ) ; if ( ( ssize_t ) ( buffer [ 0 ] & 0x01 ) == 0x01 ) opacity = ( ssize_t ) buffer [ 3 ] ; break ; } case 0xfe : { char * comments ; size_t length ; comments = AcquireString ( ( char * ) NULL ) ; for ( length = 0 ; ; length += count ) { count = ( ssize_t ) ReadBlobBlock ( image , buffer ) ; if ( count == 0 ) break ; buffer [ count ] = '\\0' ; ( void ) ConcatenateString ( & comments , ( const char * ) buffer ) ; } ( void ) SetImageProperty ( meta_image , ""comment"" , comments , exception ) ; comments = DestroyString ( comments ) ; break ; } case 0xff : { MagickBooleanType loop ; loop = MagickFalse ; if ( ReadBlobBlock ( image , buffer ) != 0 ) loop = LocaleNCompare ( ( char * ) buffer , ""NETSCAPE2.0"" , 11 ) == 0 ? MagickTrue : MagickFalse ; if ( loop != MagickFalse ) { while ( ReadBlobBlock ( image , buffer ) != 0 ) iterations = ( size_t ) ( ( buffer [ 2 ] << 8 ) | buffer [ 1 ] ) ; break ; } else { char name [ MagickPathExtent ] ; int block_length , info_length , reserved_length ; MagickBooleanType i8bim , icc , iptc , magick ; StringInfo * profile ; unsigned char * info ; icc = LocaleNCompare ( ( char * ) buffer , ""ICCRGBG1012"" , 11 ) == 0 ? MagickTrue : MagickFalse ; magick = LocaleNCompare ( ( char * ) buffer , ""ImageMagick"" , 11 ) == 0 ? MagickTrue : MagickFalse ; i8bim = LocaleNCompare ( ( char * ) buffer , ""MGK8BIM0000"" , 11 ) == 0 ? MagickTrue : MagickFalse ; iptc = LocaleNCompare ( ( char * ) buffer , ""MGKIPTC0000"" , 11 ) == 0 ? MagickTrue : MagickFalse ; number_extensionss ++ ; ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""ReadingGIFapplicationextension"" ) ; info = ( unsigned char * ) AcquireQuantumMemory ( 255UL , sizeof ( * info ) ) ; if ( info == ( unsigned char * ) NULL ) { meta_image = DestroyImage ( meta_image ) ; ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; } reserved_length = 255 ; for ( info_length = 0 ; ; ) { block_length = ( int ) ReadBlobBlock ( image , & info [ info_length ] ) ; if ( block_length == 0 ) break ; info_length += block_length ; if ( info_length > ( reserved_length - 255 ) ) { reserved_length += 4096 ; info = ( unsigned char * ) ResizeQuantumMemory ( info , ( size_t ) reserved_length , sizeof ( * info ) ) ; if ( info == ( unsigned char * ) NULL ) { meta_image = DestroyImage ( meta_image ) ; ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; } } } profile = BlobToStringInfo ( info , ( size_t ) info_length ) ; if ( profile == ( StringInfo * ) NULL ) { meta_image = DestroyImage ( meta_image ) ; ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; } if ( i8bim != MagickFalse ) ( void ) CopyMagickString ( name , ""8bim"" , sizeof ( name ) ) ; else if ( icc != MagickFalse ) ( void ) CopyMagickString ( name , ""icc"" , sizeof ( name ) ) ; else if ( iptc != MagickFalse ) ( void ) CopyMagickString ( name , ""iptc"" , sizeof ( name ) ) ; else if ( magick != MagickFalse ) { ( void ) CopyMagickString ( name , ""magick"" , sizeof ( name ) ) ; meta_image -> gamma = StringToDouble ( ( char * ) info + 6 , ( char * * ) NULL ) ; } else ( void ) FormatLocaleString ( name , sizeof ( name ) , ""gif:%.11s"" , buffer ) ; info = ( unsigned char * ) RelinquishMagickMemory ( info ) ; if ( magick == MagickFalse ) ( void ) SetImageProfile ( meta_image , name , profile , exception ) ; profile = DestroyStringInfo ( profile ) ; ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""profilename=%s"" , name ) ; } break ; } default : { while ( ReadBlobBlock ( image , buffer ) != 0 ) ; break ; } } } if ( c != ( unsigned char ) ',' ) continue ; if ( image_count != 0 ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; global_colormap = ( unsigned char * ) RelinquishMagickMemory ( global_colormap ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; } image_count ++ ; meta_image -> scene = image -> scene ; ( void ) CloneImageProperties ( image , meta_image ) ; DestroyImageProperties ( meta_image ) ; ( void ) CloneImageProfiles ( image , meta_image ) ; DestroyImageProfiles ( meta_image ) ; image -> storage_class = PseudoClass ; image -> compression = LZWCompression ; page . x = ( ssize_t ) ReadBlobLSBShort ( image ) ; page . y = ( ssize_t ) ReadBlobLSBShort ( image ) ; image -> columns = ReadBlobLSBShort ( image ) ; image -> rows = ReadBlobLSBShort ( image ) ; image -> depth = 8 ; flag = ( unsigned char ) ReadBlobByte ( image ) ; image -> interlace = BitSet ( ( int ) flag , 0x40 ) != 0 ? GIFInterlace : NoInterlace ; image -> colors = BitSet ( ( int ) flag , 0x80 ) == 0 ? global_colors : one << ( ( size_t ) ( flag & 0x07 ) + 1 ) ; if ( opacity >= ( ssize_t ) image -> colors ) opacity = ( - 1 ) ; image -> page . width = page . width ; image -> page . height = page . height ; image -> page . y = page . y ; image -> page . x = page . x ; image -> delay = delay ; image -> ticks_per_second = 100 ; image -> dispose = ( DisposeType ) dispose ; image -> iterations = iterations ; image -> alpha_trait = opacity >= 0 ? BlendPixelTrait : UndefinedPixelTrait ; delay = 0 ; dispose = 0 ; if ( ( image -> columns == 0 ) || ( image -> rows == 0 ) ) { global_colormap = ( unsigned char * ) RelinquishMagickMemory ( global_colormap ) ; meta_image = DestroyImage ( meta_image ) ; ThrowReaderException ( CorruptImageError , ""NegativeOrZeroImageSize"" ) ; } if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) { global_colormap = ( unsigned char * ) RelinquishMagickMemory ( global_colormap ) ; meta_image = DestroyImage ( meta_image ) ; ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; } if ( BitSet ( ( int ) flag , 0x80 ) == 0 ) { p = global_colormap ; for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { image -> colormap [ i ] . red = ( double ) ScaleCharToQuantum ( * p ++ ) ; image -> colormap [ i ] . green = ( double ) ScaleCharToQuantum ( * p ++ ) ; image -> colormap [ i ] . blue = ( double ) ScaleCharToQuantum ( * p ++ ) ; if ( i == opacity ) { image -> colormap [ i ] . alpha = ( double ) TransparentAlpha ; image -> transparent_color = image -> colormap [ opacity ] ; } } image -> background_color = image -> colormap [ MagickMin ( ( ssize_t ) background , ( ssize_t ) image -> colors - 1 ) ] ; } else { unsigned char * colormap ; colormap = ( unsigned char * ) AcquireQuantumMemory ( image -> colors , 3 * sizeof ( * colormap ) ) ; if ( colormap == ( unsigned char * ) NULL ) { global_colormap = ( unsigned char * ) RelinquishMagickMemory ( global_colormap ) ; meta_image = DestroyImage ( meta_image ) ; ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; } count = ReadBlob ( image , ( 3 * image -> colors ) * sizeof ( * colormap ) , colormap ) ; if ( count != ( ssize_t ) ( 3 * image -> colors ) ) { global_colormap = ( unsigned char * ) RelinquishMagickMemory ( global_colormap ) ; colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; meta_image = DestroyImage ( meta_image ) ; ThrowReaderException ( CorruptImageError , ""InsufficientImageDataInFile"" ) ; } p = colormap ; for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { image -> colormap [ i ] . red = ( double ) ScaleCharToQuantum ( * p ++ ) ; image -> colormap [ i ] . green = ( double ) ScaleCharToQuantum ( * p ++ ) ; image -> colormap [ i ] . blue = ( double ) ScaleCharToQuantum ( * p ++ ) ; if ( i == opacity ) image -> colormap [ i ] . alpha = ( double ) TransparentAlpha ; } colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; } if ( image -> gamma == 1.0 ) { for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) if ( IsPixelInfoGray ( image -> colormap + i ) == MagickFalse ) break ; ( void ) SetImageColorspace ( image , i == ( ssize_t ) image -> colors ? GRAYColorspace : RGBColorspace , exception ) ; } if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; if ( image_info -> ping != MagickFalse ) status = PingGIFImage ( image , exception ) ; else status = DecodeImage ( image , opacity , exception ) ; if ( ( image_info -> ping == MagickFalse ) && ( status == MagickFalse ) ) { global_colormap = ( unsigned char * ) RelinquishMagickMemory ( global_colormap ) ; meta_image = DestroyImage ( meta_image ) ; ThrowReaderException ( CorruptImageError , ""CorruptImage"" ) ; } duration += image -> delay * image -> iterations ; if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; opacity = ( - 1 ) ; status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) image -> scene - 1 , image -> scene ) ; if ( status == MagickFalse ) break ; } image -> duration = duration ; meta_image = DestroyImage ( meta_image ) ; global_colormap = ( unsigned char * ) RelinquishMagickMemory ( global_colormap ) ; if ( ( image -> columns == 0 ) || ( image -> rows == 0 ) ) ThrowReaderException ( CorruptImageError , ""NegativeOrZeroImageSize"" ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," ResourceLimitError , ""MemoryAllocationFailed"" ) ; ( void ) ResetMagickMemory ( global_colormap , 0 , 3 * MagickMax ( global_colors , 256 ) * sizeof ( * global_colormap ) ",ImageMagick@ImageMagick/9fd10cf630832b36a588c1545d8736539b2f1fb5,CVE-2017-15277,https://github.com/ImageMagick/ImageMagick/commit/9fd10cf630832b36a588c1545d8736539b2f1fb5,2017-10-12T08:29Z 1066,CWE-284,"CWE-284 static inline int btif_hl_select_close_connected ( void ) { char sig_on = btif_hl_signal_select_close_connected ; BTIF_TRACE_DEBUG ( ""btif_hl_select_close_connected"" ) ; return send ( signal_fds [ 1 ] , & sig_on , sizeof ( sig_on ) , 0 ) ; } "," ) ; return TEMP_FAILURE_RETRY ( , 0 ) ) ",system@bt/472271b153c5dc53c28beac55480a8d8434b2d5c,CVE-2016-3839,https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c,2016-08-05T20:59Z 1067,CWE-287,"CWE-287 static void oidc_scrub_headers ( request_rec * r ) { oidc_cfg * cfg = ap_get_module_config ( r -> server -> module_config , & auth_openidc_module ) ; if ( cfg -> scrub_request_headers != 0 ) { oidc_scrub_request_headers ( r , OIDC_DEFAULT_HEADER_PREFIX , oidc_cfg_dir_authn_header ( r ) ) ; if ( ( strstr ( cfg -> claim_prefix , OIDC_DEFAULT_HEADER_PREFIX ) != cfg -> claim_prefix ) ) { oidc_scrub_request_headers ( r , cfg -> claim_prefix , NULL ) ; } } } "," void oidc_scrub_headers ( ",pingidentity@mod_auth_openidc/21e3728a825c41ab41efa75e664108051bb9665e,CVE-2017-6413,https://github.com/pingidentity/mod_auth_openidc/commit/21e3728a825c41ab41efa75e664108051bb9665e,2017-03-02T06:59Z 1068,CWE-119,"CWE-119 static void model_rd_for_sb ( VP9_COMP * cpi , BLOCK_SIZE bsize , MACROBLOCK * x , MACROBLOCKD * xd , int * out_rate_sum , int64_t * out_dist_sum ) { int i ; int64_t rate_sum = 0 ; int64_t dist_sum = 0 ; const int ref = xd -> mi [ 0 ] -> mbmi . ref_frame [ 0 ] ; unsigned int sse ; for ( i = 0 ; i < MAX_MB_PLANE ; ++ i ) { struct macroblock_plane * const p = & x -> plane [ i ] ; struct macroblockd_plane * const pd = & xd -> plane [ i ] ; const BLOCK_SIZE bs = get_plane_block_size ( bsize , pd ) ; ( void ) cpi -> fn_ptr [ bs ] . vf ( p -> src . buf , p -> src . stride , pd -> dst . buf , pd -> dst . stride , & sse ) ; if ( i == 0 ) x -> pred_sse [ ref ] = sse ; if ( cpi -> speed > 4 ) { int64_t rate ; int64_t dist ; int64_t square_error = sse ; int quantizer = ( pd -> dequant [ 1 ] >> 3 ) ; if ( quantizer < 120 ) rate = ( square_error * ( 280 - quantizer ) ) >> 8 ; else rate = 0 ; dist = ( square_error * quantizer ) >> 8 ; rate_sum += rate ; dist_sum += dist ; } else { int rate ; int64_t dist ; vp9_model_rd_from_var_lapndz ( sse , 1 << num_pels_log2_lookup [ bs ] , pd -> dequant [ 1 ] >> 3 , & rate , & dist ) ; rate_sum += rate ; dist_sum += dist ; } } * out_rate_sum = ( int ) rate_sum ; * out_dist_sum = dist_sum << 4 ; } "," int64_t * out_dist_sum , int * skip_txfm_sb , int64_t * skip_sse_sb int sse ; unsigned int var = 0 ; unsigned int sum_sse = 0 ; int64_t total_sse = 0 ; int skip_flag = 1 ; const int shift = 6 ; int rate ; int64_t dist ; const int dequant_shift = # if CONFIG_VP9_HIGHBITDEPTH ( xd -> cur_buf -> flags & YV12_FLAG_HIGHBITDEPTH ) ? xd -> bd - 5 : # endif 3 ; x -> pred_sse [ ref ] = 0 ; pd ) ; const TX_SIZE max_tx_size = max_txsize_lookup [ bs ] [ bs ] ; const BLOCK_SIZE unit_size = txsize_to_bsize [ max_tx_size ] ; const int64_t dc_thr = p -> quant_thred [ 0 ] >> shift ; const int64_t ac_thr = p -> quant_thred [ 1 ] >> shift ; const int64_t low_dc_thr = MIN ( 50 , dc_thr >> 2 ) ; const int64_t low_ac_thr = MIN ( 80 , ac_thr >> 2 ) ; int bw = 1 << ( b_width_log2_lookup [ bs ] - b_width_log2_lookup [ unit_size ] ) ; int bh = 1 << ( b_height_log2_lookup [ bs ] - b_width_log2_lookup [ unit_size ] ) ; int idx , idy ; int lw = b_width_log2_lookup [ unit_size ] + 2 ; int lh = b_height_log2_lookup [ unit_size ] + 2 ; sum_sse = 0 ; for ( idy = 0 ; idy < bh ; ++ idy ) { for ( idx = 0 ; idx < bw ; ++ idx ) { uint8_t * src = p -> src src . buf + ( idy * p -> src src . stride << lh ) + ( idx << lw ) ; uint8_t * dst = pd -> dst dst . buf + ( idy * pd -> dst dst . stride << lh ) + ( idx << lh ) ; int block_idx = ( idy << 1 ) + idx ; int low_err_skip = 0 ; var = cpi -> fn_ptr [ unit_size ] . vf ( src , p -> src . stride , dst , pd -> dst . stride sse ) ; x -> bsse [ ( i << 2 ) + block_idx ] = sse ; sum_sse += sse ; x -> skip_txfm [ ( i << 2 ) + block_idx ] = SKIP_TXFM_NONE ; if ( ! x -> select_tx_size ) { if ( var < ac_thr || var == 0 ) == 0 ) { x -> skip_txfm [ ( i << 2 ) + block_idx ] = SKIP_TXFM_AC_ONLY ; if ( sse - var < dc_thr || sse == var ) { x -> skip_txfm [ ( i << 2 ) + block_idx ] = SKIP_TXFM_AC_DC ; if ( ! sse || ( var < low_ac_thr && sse - var < low_dc_thr ) ) low_err_skip = 1 ; } } } if ( skip_flag && ! low_err_skip ) skip_flag = 0 ; if ( i == 0 ) x -> pred_sse [ ref [ ref ] += sse ; } } total_sse += sum_sse ; if ( cpi ( cpi -> sf . simple_model_rd_from_var ) { int64_t int64_t rate ; const int64_t square_error = int64_t square_error = sum_sse ; int quantizer 1 ] >> dequant_shift ) ; if } else { vp9_model_rd_from_var_lapndz ( sum_sse , num_pels_log2_lookup [ bs ] , pd -> dequant [ 1 ] >> dequant_shift , & rate , } } * skip_txfm_sb = skip_flag ; * skip_sse_sb = total_sse << 4 ; * ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1069,CWE-264,"CWE-264 static void mincore_pmd_range ( struct vm_area_struct * vma , pud_t * pud , unsigned long addr , unsigned long end , unsigned char * vec ) { unsigned long next ; pmd_t * pmd ; pmd = pmd_offset ( pud , addr ) ; do { next = pmd_addr_end ( addr , end ) ; if ( pmd_trans_huge ( * pmd ) ) { if ( mincore_huge_pmd ( vma , pmd , addr , next , vec ) ) { vec += ( next - addr ) >> PAGE_SHIFT ; continue ; } } if ( pmd_none_or_clear_bad ( pmd ) ) mincore_unmapped_range ( vma , addr , next , vec ) ; else mincore_pte_range ( vma , pmd , addr , next , vec ) ; vec += ( next - addr ) >> PAGE_SHIFT ; } while ( pmd ++ , addr = next , addr != end ) ; } "," } if ( pmd_none_or_trans_huge_or_clear_bad ( pmd ) ",torvalds@linux/4a1d704194a441bf83c636004a479e01360ec850,CVE-2012-1179,https://github.com/torvalds/linux/commit/4a1d704194a441bf83c636004a479e01360ec850,2012-05-17T11:00Z 1070,CWE-125,"CWE-125 static void esis_print ( netdissect_options * ndo , const uint8_t * pptr , u_int length ) { const uint8_t * optr ; u_int li , esis_pdu_type , source_address_length , source_address_number ; const struct esis_header_t * esis_header ; if ( ! ndo -> ndo_eflag ) ND_PRINT ( ( ndo , ""ES-IS"" ) ) ; if ( length <= 2 ) { ND_PRINT ( ( ndo , ndo -> ndo_qflag ? ""badpkt!"" : ""noheaderatall!"" ) ) ; return ; } esis_header = ( const struct esis_header_t * ) pptr ; ND_TCHECK ( * esis_header ) ; li = esis_header -> length_indicator ; optr = pptr ; if ( esis_header -> nlpid != NLPID_ESIS ) { ND_PRINT ( ( ndo , ""nlpid0x%02xpacketnotsupported"" , esis_header -> nlpid ) ) ; return ; } if ( esis_header -> version != ESIS_VERSION ) { ND_PRINT ( ( ndo , ""version%dpacketnotsupported"" , esis_header -> version ) ) ; return ; } if ( li > length ) { ND_PRINT ( ( ndo , ""lengthindicator(%u)>PDUsize(%u)!"" , li , length ) ) ; return ; } if ( li < sizeof ( struct esis_header_t ) + 2 ) { ND_PRINT ( ( ndo , ""lengthindicator%u<minPDUsize:"" , li ) ) ; while ( pptr < ndo -> ndo_snapend ) ND_PRINT ( ( ndo , ""%02X"" , * pptr ++ ) ) ; return ; } esis_pdu_type = esis_header -> type & ESIS_PDU_TYPE_MASK ; if ( ndo -> ndo_vflag < 1 ) { ND_PRINT ( ( ndo , ""%s%s,length%u"" , ndo -> ndo_eflag ? """" : "","" , tok2str ( esis_pdu_values , ""unknowntype(%u)"" , esis_pdu_type ) , length ) ) ; return ; } else ND_PRINT ( ( ndo , ""%slength%u\\n\\t%s(%u)"" , ndo -> ndo_eflag ? """" : "","" , length , tok2str ( esis_pdu_values , ""unknowntype:%u"" , esis_pdu_type ) , esis_pdu_type ) ) ; ND_PRINT ( ( ndo , "",v:%u%s"" , esis_header -> version , esis_header -> version == ESIS_VERSION ? """" : ""unsupported"" ) ) ; ND_PRINT ( ( ndo , "",checksum:0x%04x"" , EXTRACT_16BITS ( esis_header -> cksum ) ) ) ; osi_print_cksum ( ndo , pptr , EXTRACT_16BITS ( esis_header -> cksum ) , 7 , li ) ; ND_PRINT ( ( ndo , "",holdingtime:%us,lengthindicator:%u"" , EXTRACT_16BITS ( esis_header -> holdtime ) , li ) ) ; if ( ndo -> ndo_vflag > 1 ) print_unknown_data ( ndo , optr , ""\\n\\t"" , sizeof ( struct esis_header_t ) ) ; pptr += sizeof ( struct esis_header_t ) ; li -= sizeof ( struct esis_header_t ) ; switch ( esis_pdu_type ) { case ESIS_PDU_REDIRECT : { const uint8_t * dst , * snpa , * neta ; u_int dstl , snpal , netal ; ND_TCHECK ( * pptr ) ; if ( li < 1 ) { ND_PRINT ( ( ndo , "",badredirect/li"" ) ) ; return ; } dstl = * pptr ; pptr ++ ; li -- ; ND_TCHECK2 ( * pptr , dstl ) ; if ( li < dstl ) { ND_PRINT ( ( ndo , "",badredirect/li"" ) ) ; return ; } dst = pptr ; pptr += dstl ; li -= dstl ; ND_PRINT ( ( ndo , ""\\n\\t%s"" , isonsap_string ( ndo , dst , dstl ) ) ) ; ND_TCHECK ( * pptr ) ; if ( li < 1 ) { ND_PRINT ( ( ndo , "",badredirect/li"" ) ) ; return ; } snpal = * pptr ; pptr ++ ; li -- ; ND_TCHECK2 ( * pptr , snpal ) ; if ( li < snpal ) { ND_PRINT ( ( ndo , "",badredirect/li"" ) ) ; return ; } snpa = pptr ; pptr += snpal ; li -= snpal ; ND_TCHECK ( * pptr ) ; if ( li < 1 ) { ND_PRINT ( ( ndo , "",badredirect/li"" ) ) ; return ; } netal = * pptr ; pptr ++ ; ND_TCHECK2 ( * pptr , netal ) ; if ( li < netal ) { ND_PRINT ( ( ndo , "",badredirect/li"" ) ) ; return ; } neta = pptr ; pptr += netal ; li -= netal ; if ( snpal == 6 ) ND_PRINT ( ( ndo , ""\\n\\tSNPA(length:%u):%s"" , snpal , etheraddr_string ( ndo , snpa ) ) ) ; else ND_PRINT ( ( ndo , ""\\n\\tSNPA(length:%u):%s"" , snpal , linkaddr_string ( ndo , snpa , LINKADDR_OTHER , snpal ) ) ) ; if ( netal != 0 ) ND_PRINT ( ( ndo , ""\\n\\tNET(length:%u)%s"" , netal , isonsap_string ( ndo , neta , netal ) ) ) ; break ; } case ESIS_PDU_ESH : ND_TCHECK ( * pptr ) ; if ( li < 1 ) { ND_PRINT ( ( ndo , "",badesh/li"" ) ) ; return ; } source_address_number = * pptr ; pptr ++ ; li -- ; ND_PRINT ( ( ndo , ""\\n\\tNumberofSourceAddresses:%u"" , source_address_number ) ) ; while ( source_address_number > 0 ) { ND_TCHECK ( * pptr ) ; if ( li < 1 ) { ND_PRINT ( ( ndo , "",badesh/li"" ) ) ; return ; } source_address_length = * pptr ; pptr ++ ; li -- ; ND_TCHECK2 ( * pptr , source_address_length ) ; if ( li < source_address_length ) { ND_PRINT ( ( ndo , "",badesh/li"" ) ) ; return ; } ND_PRINT ( ( ndo , ""\\n\\tNET(length:%u):%s"" , source_address_length , isonsap_string ( ndo , pptr , source_address_length ) ) ) ; pptr += source_address_length ; li -= source_address_length ; source_address_number -- ; } break ; case ESIS_PDU_ISH : { ND_TCHECK ( * pptr ) ; if ( li < 1 ) { ND_PRINT ( ( ndo , "",badish/li"" ) ) ; return ; } source_address_length = * pptr ; pptr ++ ; li -- ; ND_TCHECK2 ( * pptr , source_address_length ) ; if ( li < source_address_length ) { ND_PRINT ( ( ndo , "",badish/li"" ) ) ; return ; } ND_PRINT ( ( ndo , ""\\n\\tNET(length:%u):%s"" , source_address_length , isonsap_string ( ndo , pptr , source_address_length ) ) ) ; pptr += source_address_length ; li -= source_address_length ; break ; } default : if ( ndo -> ndo_vflag <= 1 ) { if ( pptr < ndo -> ndo_snapend ) print_unknown_data ( ndo , pptr , ""\\n\\t"" , ndo -> ndo_snapend - pptr ) ; } return ; } while ( li != 0 ) { u_int op , opli ; const uint8_t * tptr ; if ( li < 2 ) { ND_PRINT ( ( ndo , "",badopts/li"" ) ) ; return ; } ND_TCHECK2 ( * pptr , 2 ) ; op = * pptr ++ ; opli = * pptr ++ ; li -= 2 ; if ( opli > li ) { ND_PRINT ( ( ndo , "",opt(%d)toolong"" , op ) ) ; return ; } li -= opli ; tptr = pptr ; ND_PRINT ( ( ndo , ""\\n\\t%sOption#%u,length%u,value:"" , tok2str ( esis_option_values , ""Unknown"" , op ) , op , opli ) ) ; switch ( op ) { case ESIS_OPTION_ES_CONF_TIME : if ( opli == 2 ) { ND_TCHECK2 ( * pptr , 2 ) ; ND_PRINT ( ( ndo , ""%us"" , EXTRACT_16BITS ( tptr ) ) ) ; } else ND_PRINT ( ( ndo , ""(badlength)"" ) ) ; break ; case ESIS_OPTION_PROTOCOLS : while ( opli > 0 ) { ND_TCHECK ( * pptr ) ; ND_PRINT ( ( ndo , ""%s(0x%02x)"" , tok2str ( nlpid_values , ""unknown"" , * tptr ) , * tptr ) ) ; if ( opli > 1 ) ND_PRINT ( ( ndo , "","" ) ) ; tptr ++ ; opli -- ; } break ; case ESIS_OPTION_QOS_MAINTENANCE : case ESIS_OPTION_SECURITY : case ESIS_OPTION_PRIORITY : case ESIS_OPTION_ADDRESS_MASK : case ESIS_OPTION_SNPA_MASK : default : print_unknown_data ( ndo , tptr , ""\\n\\t"" , opli ) ; break ; } if ( ndo -> ndo_vflag > 1 ) print_unknown_data ( ndo , pptr , ""\\n\\t"" , opli ) ; pptr += opli ; } trunc : return ; } "," ND_TCHECK ( * tptr ) ; ND_PRINT } trunc : ND_PRINT ( ( ndo , ""[|esis]"" ) ) ; } ",the-tcpdump-group@tcpdump/331530a4076c69bbd2e3214db6ccbe834fb75640,CVE-2017-13047,https://github.com/the-tcpdump-group/tcpdump/commit/331530a4076c69bbd2e3214db6ccbe834fb75640,2017-09-14T06:29Z 1071,CWE-120,"CWE-120 static int parse_user_name ( char * user_input , char * * ret_username ) { register char * ptr ; register int index = 0 ; char username [ PAM_MAX_RESP_SIZE ] ; * ret_username = NULL ; bzero ( ( void * ) username , PAM_MAX_RESP_SIZE ) ; ptr = user_input ; while ( ( * ptr == '' ) || ( * ptr == '\\t' ) ) ptr ++ ; if ( * ptr == '\\0' ) { return ( PAM_BUF_ERR ) ; } while ( * ptr != '\\0' ) { if ( ( * ptr == '' ) || ( * ptr == '\\t' ) ) break ; else { username [ index ] = * ptr ; index ++ ; ptr ++ ; } } if ( ( * ret_username = malloc ( index + 1 ) ) == NULL ) return ( PAM_BUF_ERR ) ; ( void ) strcpy ( * ret_username , username ) ; return ( PAM_SUCCESS ) ; } "," == '\\t' ) || ( index >= PAM_MAX_RESP_SIZE ) ) { break ; } else { username } if ( index >= PAM_MAX_RESP_SIZE || * ret_username = strdup ( username ) ) == PAM_BUF_ERR ) ; return ( PAM_SUCCESS ",illumos@illumos-gate/1d276e0b382cf066dae93640746d8b4c54d15452,CVE-2020-27678,https://github.com/illumos/illumos-gate/commit/1d276e0b382cf066dae93640746d8b4c54d15452,2020-10-26T12:17Z 1072,CWE-119,"CWE-119 static int read_segment_id ( vp9_reader * r , const struct segmentation * seg ) { return vp9_read_tree ( r , vp9_segment_tree , seg -> tree_probs ) ; } "," int read_segment_id ( vpx_reader * r , ) { return vpx_read_tree ( r , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1073,CWE-200,"CWE-200 int vmw_gb_surface_define_ioctl ( struct drm_device * dev , void * data , struct drm_file * file_priv ) { struct vmw_private * dev_priv = vmw_priv ( dev ) ; struct vmw_user_surface * user_srf ; struct vmw_surface * srf ; struct vmw_resource * res ; struct vmw_resource * tmp ; union drm_vmw_gb_surface_create_arg * arg = ( union drm_vmw_gb_surface_create_arg * ) data ; struct drm_vmw_gb_surface_create_req * req = & arg -> req ; struct drm_vmw_gb_surface_create_rep * rep = & arg -> rep ; struct ttm_object_file * tfile = vmw_fpriv ( file_priv ) -> tfile ; int ret ; uint32_t size ; uint32_t backup_handle ; if ( req -> multisample_count != 0 ) return - EINVAL ; if ( req -> mip_levels > DRM_VMW_MAX_MIP_LEVELS ) return - EINVAL ; if ( unlikely ( vmw_user_surface_size == 0 ) ) vmw_user_surface_size = ttm_round_pot ( sizeof ( * user_srf ) ) + 128 ; size = vmw_user_surface_size + 128 ; ret = vmw_surface_gb_priv_define ( dev , size , req -> svga3d_flags , req -> format , req -> drm_surface_flags & drm_vmw_surface_flag_scanout , req -> mip_levels , req -> multisample_count , req -> array_size , req -> base_size , & srf ) ; if ( unlikely ( ret != 0 ) ) return ret ; user_srf = container_of ( srf , struct vmw_user_surface , srf ) ; if ( drm_is_primary_client ( file_priv ) ) user_srf -> master = drm_master_get ( file_priv -> master ) ; ret = ttm_read_lock ( & dev_priv -> reservation_sem , true ) ; if ( unlikely ( ret != 0 ) ) return ret ; res = & user_srf -> srf . res ; if ( req -> buffer_handle != SVGA3D_INVALID_ID ) { ret = vmw_user_dmabuf_lookup ( tfile , req -> buffer_handle , & res -> backup , & user_srf -> backup_base ) ; if ( ret == 0 && res -> backup -> base . num_pages * PAGE_SIZE < res -> backup_size ) { DRM_ERROR ( ""Surfacebackupbufferistoosmall.\\n"" ) ; vmw_dmabuf_unreference ( & res -> backup ) ; ret = - EINVAL ; goto out_unlock ; } } else if ( req -> drm_surface_flags & drm_vmw_surface_flag_create_buffer ) ret = vmw_user_dmabuf_alloc ( dev_priv , tfile , res -> backup_size , req -> drm_surface_flags & drm_vmw_surface_flag_shareable , & backup_handle , & res -> backup , & user_srf -> backup_base ) ; if ( unlikely ( ret != 0 ) ) { vmw_resource_unreference ( & res ) ; goto out_unlock ; } tmp = vmw_resource_reference ( res ) ; ret = ttm_prime_object_init ( tfile , res -> backup_size , & user_srf -> prime , req -> drm_surface_flags & drm_vmw_surface_flag_shareable , VMW_RES_SURFACE , & vmw_user_surface_base_release , NULL ) ; if ( unlikely ( ret != 0 ) ) { vmw_resource_unreference ( & tmp ) ; vmw_resource_unreference ( & res ) ; goto out_unlock ; } rep -> handle = user_srf -> prime . base . hash . key ; rep -> backup_size = res -> backup_size ; if ( res -> backup ) { rep -> buffer_map_handle = drm_vma_node_offset_addr ( & res -> backup -> base . vma_node ) ; rep -> buffer_size = res -> backup -> base . num_pages * PAGE_SIZE ; rep -> buffer_handle = backup_handle ; } else { rep -> buffer_map_handle = 0 ; rep -> buffer_size = 0 ; rep -> buffer_handle = SVGA3D_INVALID_ID ; } vmw_resource_unreference ( & res ) ; out_unlock : ttm_read_unlock ( & dev_priv -> reservation_sem ) ; return ret ; } "," ; uint32_t backup_handle = 0 ret == 0 ) { if ( res -> backup goto out_unlock ; } else { backup_handle = req -> buffer_handle ; } ",torvalds@linux/07678eca2cf9c9a18584e546c2b2a0d0c9a3150c,CVE-2017-9605,https://github.com/torvalds/linux/commit/07678eca2cf9c9a18584e546c2b2a0d0c9a3150c,2017-06-13T19:29Z 1074,CWE-362,"CWE-362 static struct desc_struct * get_desc ( unsigned short sel ) { struct desc_ptr gdt_desc = { 0 , 0 } ; unsigned long desc_base ; # ifdef CONFIG_MODIFY_LDT_SYSCALL if ( ( sel & SEGMENT_TI_MASK ) == SEGMENT_LDT ) { struct desc_struct * desc = NULL ; struct ldt_struct * ldt ; sel >>= 3 ; mutex_lock ( & current -> active_mm -> context . lock ) ; ldt = current -> active_mm -> context . ldt ; if ( ldt && sel < ldt -> nr_entries ) desc = & ldt -> entries [ sel ] ; mutex_unlock ( & current -> active_mm -> context . lock ) ; return desc ; } # endif native_store_gdt ( & gdt_desc ) ; desc_base = sel & ~ ( SEGMENT_RPL_MASK | SEGMENT_TI_MASK ) ; if ( desc_base > gdt_desc . size ) return NULL ; return ( struct desc_struct * ) ( gdt_desc . address + desc_base ) ; } "," static bool get_desc ( struct desc_struct * out , unsigned short sel SEGMENT_LDT ) { bool success = false ; struct ldt_struct -> nr_entries ) { * out = ldt -> entries sel ] ; success = true ; } ) ; return success ; } # size ) return false ; * out = * ( struct desc_struct desc_base ) ; return true ; ",torvalds@linux/de9f869616dd95e95c00bdd6b0fcd3421e8a4323,CVE-2019-13233,https://github.com/torvalds/linux/commit/de9f869616dd95e95c00bdd6b0fcd3421e8a4323,2019-07-04T13:15Z 1075,CWE-119,"CWE-119 static void extend_plane ( uint8_t * const src , int src_stride , int width , int height , int extend_top , int extend_left , int extend_bottom , int extend_right ) { int i ; const int linesize = extend_left + extend_right + width ; uint8_t * src_ptr1 = src ; uint8_t * src_ptr2 = src + width - 1 ; uint8_t * dst_ptr1 = src - extend_left ; uint8_t * dst_ptr2 = src + width ; for ( i = 0 ; i < height ; ++ i ) { vpx_memset ( dst_ptr1 , src_ptr1 [ 0 ] , extend_left ) ; vpx_memset ( dst_ptr2 , src_ptr2 [ 0 ] , extend_right ) ; src_ptr1 += src_stride ; src_ptr2 += src_stride ; dst_ptr1 += src_stride ; dst_ptr2 += src_stride ; } src_ptr1 = src - extend_left ; src_ptr2 = src + src_stride * ( height - 1 ) - extend_left ; dst_ptr1 = src + src_stride * - extend_top - extend_left ; dst_ptr2 = src + src_stride * height - extend_left ; for ( i = 0 ; i < extend_top ; ++ i ) { vpx_memcpy ( dst_ptr1 , src_ptr1 , linesize ) ; dst_ptr1 += src_stride ; } for ( i = 0 ; i < extend_bottom ; ++ i ) { vpx_memcpy ( dst_ptr2 , src_ptr2 , linesize ) ; dst_ptr2 += src_stride ; } } "," i ) { memset ( dst_ptr1 , extend_left ) ; memset ( dst_ptr2 , i ) { memcpy ( dst_ptr1 , i ) { memcpy ( dst_ptr2 , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1076,CWE-310,"CWE-310 static void sctp_v6_get_dst ( struct sctp_transport * t , union sctp_addr * saddr , struct flowi * fl , struct sock * sk ) { struct sctp_association * asoc = t -> asoc ; struct dst_entry * dst = NULL ; struct flowi6 * fl6 = & fl -> u . ip6 ; struct sctp_bind_addr * bp ; struct sctp_sockaddr_entry * laddr ; union sctp_addr * baddr = NULL ; union sctp_addr * daddr = & t -> ipaddr ; union sctp_addr dst_saddr ; __u8 matchlen = 0 ; __u8 bmatchlen ; sctp_scope_t scope ; memset ( fl6 , 0 , sizeof ( struct flowi6 ) ) ; fl6 -> daddr = daddr -> v6 . sin6_addr ; fl6 -> fl6_dport = daddr -> v6 . sin6_port ; fl6 -> flowi6_proto = IPPROTO_SCTP ; if ( ipv6_addr_type ( & daddr -> v6 . sin6_addr ) & IPV6_ADDR_LINKLOCAL ) fl6 -> flowi6_oif = daddr -> v6 . sin6_scope_id ; pr_debug ( ""%s:dst=%pI6"" , __func__ , & fl6 -> daddr ) ; if ( asoc ) fl6 -> fl6_sport = htons ( asoc -> base . bind_addr . port ) ; if ( saddr ) { fl6 -> saddr = saddr -> v6 . sin6_addr ; fl6 -> fl6_sport = saddr -> v6 . sin6_port ; pr_debug ( ""src=%pI6-"" , & fl6 -> saddr ) ; } dst = ip6_dst_lookup_flow ( sk , fl6 , NULL , false ) ; if ( ! asoc || saddr ) goto out ; bp = & asoc -> base . bind_addr ; scope = sctp_scope ( daddr ) ; if ( ! IS_ERR ( dst ) ) { sctp_v6_to_addr ( & dst_saddr , & fl6 -> saddr , htons ( bp -> port ) ) ; rcu_read_lock ( ) ; list_for_each_entry_rcu ( laddr , & bp -> address_list , list ) { if ( ! laddr -> valid || ( laddr -> state != SCTP_ADDR_SRC ) ) continue ; if ( ( laddr -> a . sa . sa_family == AF_INET6 ) && ( sctp_v6_cmp_addr ( & dst_saddr , & laddr -> a ) ) ) { rcu_read_unlock ( ) ; goto out ; } } rcu_read_unlock ( ) ; dst_release ( dst ) ; dst = NULL ; } rcu_read_lock ( ) ; list_for_each_entry_rcu ( laddr , & bp -> address_list , list ) { if ( ! laddr -> valid ) continue ; if ( ( laddr -> state == SCTP_ADDR_SRC ) && ( laddr -> a . sa . sa_family == AF_INET6 ) && ( scope <= sctp_scope ( & laddr -> a ) ) ) { bmatchlen = sctp_v6_addr_match_len ( daddr , & laddr -> a ) ; if ( ! baddr || ( matchlen < bmatchlen ) ) { baddr = & laddr -> a ; matchlen = bmatchlen ; } } } rcu_read_unlock ( ) ; if ( baddr ) { fl6 -> saddr = baddr -> v6 . sin6_addr ; fl6 -> fl6_sport = baddr -> v6 . sin6_port ; dst = ip6_dst_lookup_flow ( sk , fl6 , NULL , false ) ; } out : if ( ! IS_ERR_OR_NULL ( dst ) ) { struct rt6_info * rt ; rt = ( struct rt6_info * ) dst ; t -> dst = dst ; t -> dst_cookie = rt -> rt6i_node ? rt -> rt6i_node -> fn_sernum : 0 ; pr_debug ( ""rt6_dst:%pI6rt6_src:%pI6\\n"" , & rt -> rt6i_dst . addr , & fl6 -> saddr ) ; } else { t -> dst = NULL ; pr_debug ( ""noroute\\n"" ) ; } } "," bp ; struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct sctp_addr dst_saddr ; struct in6_addr * final_p , final ; ) ; } final_p = fl6_update_dst ( fl6 , np -> opt , & final ) ; , fl6 , final_p , false ) . sin6_port ; final_p = fl6_update_dst ( fl6 , np -> opt , & final ) ; , fl6 , final_p , false ) ",torvalds@linux/95ee62083cb6453e056562d91f597552021e6ae7,CVE-2013-4350,https://github.com/torvalds/linux/commit/95ee62083cb6453e056562d91f597552021e6ae7,2013-09-25T10:31Z 1077,CWE-400,"CWE-400 static void kgdb_hw_overflow_handler ( struct perf_event * event , int nmi , struct perf_sample_data * data , struct pt_regs * regs ) { struct task_struct * tsk = current ; int i ; for ( i = 0 ; i < 4 ; i ++ ) if ( breakinfo [ i ] . enabled ) tsk -> thread . debugreg6 |= ( DR_TRAP0 << i ) ; } "," perf_event * event , struct perf_sample_data ",torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,CVE-2011-2918,https://github.com/torvalds/linux/commit/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,2012-05-24T23:55Z 1078,CWE-674,"CWE-674 const u_char * smb_fdata ( netdissect_options * ndo , const u_char * buf , const char * fmt , const u_char * maxbuf , int unicodestr ) { static int depth = 0 ; char s [ 128 ] ; char * p ; while ( * fmt ) { switch ( * fmt ) { case '*' : fmt ++ ; while ( buf < maxbuf ) { const u_char * buf2 ; depth ++ ; buf2 = smb_fdata ( ndo , buf , fmt , maxbuf , unicodestr ) ; depth -- ; if ( buf2 == NULL ) return ( NULL ) ; if ( buf2 == buf ) return ( buf ) ; buf = buf2 ; } return ( buf ) ; case '|' : fmt ++ ; if ( buf >= maxbuf ) return ( buf ) ; break ; case '%' : fmt ++ ; buf = maxbuf ; break ; case '#' : fmt ++ ; return ( buf ) ; break ; case '[' : fmt ++ ; if ( buf >= maxbuf ) return ( buf ) ; memset ( s , 0 , sizeof ( s ) ) ; p = strchr ( fmt , ']' ) ; if ( ( size_t ) ( p - fmt + 1 ) > sizeof ( s ) ) { return ( buf ) ; } strncpy ( s , fmt , p - fmt ) ; s [ p - fmt ] = '\\0' ; fmt = p + 1 ; buf = smb_fdata1 ( ndo , buf , s , maxbuf , unicodestr ) ; if ( buf == NULL ) return ( NULL ) ; break ; default : ND_PRINT ( ( ndo , ""%c"" , * fmt ) ) ; fmt ++ ; break ; } } if ( ! depth && buf < maxbuf ) { size_t len = PTR_DIFF ( maxbuf , buf ) ; ND_PRINT ( ( ndo , ""Data:(%lubytes)\\n"" , ( unsigned long ) len ) ) ; smb_print_data ( ndo , buf , len ) ; return ( buf + len ) ; } return ( buf ) ; } "," depth ++ ; if ( depth == 10 ) ND_PRINT ( ( ndo , ""(toomanynestedlevels,notrecursing)"" ) ) ; else ",the-tcpdump-group@tcpdump/24182d959f661327525a20d9a94c98a8ec016778,CVE-2018-16452,https://github.com/the-tcpdump-group/tcpdump/commit/24182d959f661327525a20d9a94c98a8ec016778,2019-10-03T16:15Z 1079,CWE-835,"CWE-835 void gsm_xsmp_client_connect ( GsmXSMPClient * client , SmsConn conn , unsigned long * mask_ret , SmsCallbacks * callbacks_ret ) { client -> priv -> conn = conn ; if ( client -> priv -> protocol_timeout ) { g_source_remove ( client -> priv -> protocol_timeout ) ; client -> priv -> protocol_timeout = 0 ; } g_debug ( ""GsmXSMPClient:Initializingclient%s"" , client -> priv -> description ) ; * mask_ret = 0 ; * mask_ret |= SmsRegisterClientProcMask ; callbacks_ret -> register_client . callback = register_client_callback ; callbacks_ret -> register_client . manager_data = client ; * mask_ret |= SmsInteractRequestProcMask ; callbacks_ret -> interact_request . callback = interact_request_callback ; callbacks_ret -> interact_request . manager_data = client ; * mask_ret |= SmsInteractDoneProcMask ; callbacks_ret -> interact_done . callback = interact_done_callback ; callbacks_ret -> interact_done . manager_data = client ; * mask_ret |= SmsSaveYourselfRequestProcMask ; callbacks_ret -> save_yourself_request . callback = save_yourself_request_callback ; callbacks_ret -> save_yourself_request . manager_data = client ; * mask_ret |= SmsSaveYourselfP2RequestProcMask ; callbacks_ret -> save_yourself_phase2_request . callback = save_yourself_phase2_request_callback ; callbacks_ret -> save_yourself_phase2_request . manager_data = client ; * mask_ret |= SmsSaveYourselfDoneProcMask ; callbacks_ret -> save_yourself_done . callback = save_yourself_done_callback ; callbacks_ret -> save_yourself_done . manager_data = client ; * mask_ret |= SmsCloseConnectionProcMask ; callbacks_ret -> close_connection . callback = close_connection_callback ; callbacks_ret -> close_connection . manager_data = client ; * mask_ret |= SmsSetPropertiesProcMask ; callbacks_ret -> set_properties . callback = set_properties_callback ; callbacks_ret -> set_properties . manager_data = client ; * mask_ret |= SmsDeletePropertiesProcMask ; callbacks_ret -> delete_properties . callback = delete_properties_callback ; callbacks_ret -> delete_properties . manager_data = client ; * mask_ret |= SmsGetPropertiesProcMask ; callbacks_ret -> get_properties . callback = get_properties_callback ; callbacks_ret -> get_properties . manager_data = client ; } "," = conn ; g_debug ( ""GsmXSMPClient:Initializingclient%s"" ",GNOME@gnome-session/b0dc999e0b45355314616321dbb6cb71e729fc9d,CVE-2017-11171,https://github.com/GNOME/gnome-session/commit/b0dc999e0b45355314616321dbb6cb71e729fc9d,2017-07-11T20:29Z 1080,CWE-20,"CWE-20 static int wb_prep ( netdissect_options * ndo , const struct pkt_prep * prep , u_int len ) { int n ; const struct pgstate * ps ; const u_char * ep = ndo -> ndo_snapend ; ND_PRINT ( ( ndo , ""wb-prep:"" ) ) ; if ( len < sizeof ( * prep ) ) { return ( - 1 ) ; } n = EXTRACT_32BITS ( & prep -> pp_n ) ; ps = ( const struct pgstate * ) ( prep + 1 ) ; while ( -- n >= 0 && ! ND_TTEST ( * ps ) ) { const struct id_off * io , * ie ; char c = '<' ; ND_PRINT ( ( ndo , ""%u/%s:%u"" , EXTRACT_32BITS ( & ps -> slot ) , ipaddr_string ( ndo , & ps -> page . p_sid ) , EXTRACT_32BITS ( & ps -> page . p_uid ) ) ) ; io = ( struct id_off * ) ( ps + 1 ) ; for ( ie = io + ps -> nid ; io < ie && ! ND_TTEST ( * io ) ; ++ io ) { ND_PRINT ( ( ndo , ""%c%s:%u"" , c , ipaddr_string ( ndo , & io -> id ) , EXTRACT_32BITS ( & io -> off ) ) ) ; c = ',' ; } ND_PRINT ( ( ndo , "">"" ) ) ; ps = ( struct pgstate * ) io ; } return ( ( u_char * ) ps <= ep ? 0 : - 1 ) ; } "," >= 0 && ND_TTEST ( * < ie && ND_TTEST ( * ",the-tcpdump-group@tcpdump/3ed82f4ed0095768529afc22b923c8f7171fff70,CVE-2015-3138,https://github.com/the-tcpdump-group/tcpdump/commit/3ed82f4ed0095768529afc22b923c8f7171fff70,2017-09-28T01:29Z 1081,CWE-20,"CWE-20 error_t ksz8851SendPacket ( NetInterface * interface , const NetBuffer * buffer , size_t offset , NetTxAncillary * ancillary ) { size_t n ; size_t length ; Ksz8851TxHeader header ; Ksz8851Context * context ; context = ( Ksz8851Context * ) interface -> nicContext ; length = netBufferGetLength ( buffer ) - offset ; if ( length > ETH_MAX_FRAME_SIZE ) { osSetEvent ( & interface -> nicTxEvent ) ; return ERROR_INVALID_LENGTH ; } n = ksz8851ReadReg ( interface , KSZ8851_REG_TXMIR ) & TXMIR_TXMA_MASK ; if ( n < ( length + 8 ) ) { return ERROR_FAILURE ; } netBufferRead ( context -> txBuffer , buffer , offset , length ) ; header . controlWord = htole16 ( TX_CTRL_TXIC | ( context -> frameId ++ & TX_CTRL_TXFID ) ) ; header . byteCount = htole16 ( length ) ; ksz8851SetBit ( interface , KSZ8851_REG_RXQCR , RXQCR_SDA ) ; ksz8851WriteFifo ( interface , ( uint8_t * ) & header , sizeof ( Ksz8851TxHeader ) ) ; ksz8851WriteFifo ( interface , context -> txBuffer , length ) ; ksz8851ClearBit ( interface , KSZ8851_REG_RXQCR , RXQCR_SDA ) ; ksz8851SetBit ( interface , KSZ8851_REG_TXQCR , TXQCR_METFE ) ; n = ksz8851ReadReg ( interface , KSZ8851_REG_TXMIR ) & TXMIR_TXMA_MASK ; if ( n >= ( ETH_MAX_FRAME_SIZE + 8 ) ) { osSetEvent ( & interface -> nicTxEvent ) ; } return NO_ERROR ; } "," ( interface , KSZ8851_TXMIR ) & KSZ8851_TXMIR_TXMA ; if ( = htole16 ( KSZ8851_TX_CTRL_TXIC | ( context frameId ++ & KSZ8851_TX_CTRL_TXFID ) ) ; ( interface , KSZ8851_RXQCR , KSZ8851_RXQCR_SDA ) ; ksz8851WriteFifo ( interface , KSZ8851_RXQCR , KSZ8851_RXQCR_SDA ) ; ksz8851SetBit ( interface , KSZ8851_TXQCR , KSZ8851_TXQCR_METFE ) ; n ( interface , KSZ8851_TXMIR ) & KSZ8851_TXMIR_TXMA ; if ( ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 1082,CWE-310,"CWE-310 static VALUE ossl_cipher_set_key ( VALUE self , VALUE key ) { EVP_CIPHER_CTX * ctx ; int key_len ; StringValue ( key ) ; GetCipher ( self , ctx ) ; key_len = EVP_CIPHER_CTX_key_length ( ctx ) ; if ( RSTRING_LEN ( key ) != key_len ) ossl_raise ( rb_eArgError , ""keymustbe%dbytes"" , key_len ) ; if ( EVP_CipherInit_ex ( ctx , NULL , NULL , ( unsigned char * ) RSTRING_PTR ( key ) , NULL , - 1 ) != 1 ) ossl_raise ( eCipherError , NULL ) ; return key ; } "," NULL ) ; rb_ivar_set ( self , id_key_set , Qtrue ) ; ",ruby@openssl/8108e0a6db133f3375608303fdd2083eb5115062,CVE-2016-7798,https://github.com/ruby/openssl/commit/8108e0a6db133f3375608303fdd2083eb5115062,2017-01-30T22:59Z 1083,CWE-476,"CWE-476 static bool assoc_array_insert_into_terminal_node ( struct assoc_array_edit * edit , const struct assoc_array_ops * ops , const void * index_key , struct assoc_array_walk_result * result ) { struct assoc_array_shortcut * shortcut , * new_s0 ; struct assoc_array_node * node , * new_n0 , * new_n1 , * side ; struct assoc_array_ptr * ptr ; unsigned long dissimilarity , base_seg , blank ; size_t keylen ; bool have_meta ; int level , diff ; int slot , next_slot , free_slot , i , j ; node = result -> terminal_node . node ; level = result -> terminal_node . level ; edit -> segment_cache [ ASSOC_ARRAY_FAN_OUT ] = result -> terminal_node . slot ; pr_devel ( ""-->%s()\\n"" , __func__ ) ; free_slot = - 1 ; for ( i = 0 ; i < ASSOC_ARRAY_FAN_OUT ; i ++ ) { ptr = node -> slots [ i ] ; if ( ! ptr ) { free_slot = i ; continue ; } if ( assoc_array_ptr_is_leaf ( ptr ) && ops -> compare_object ( assoc_array_ptr_to_leaf ( ptr ) , index_key ) ) { pr_devel ( ""replaceinslot%d\\n"" , i ) ; edit -> leaf_p = & node -> slots [ i ] ; edit -> dead_leaf = node -> slots [ i ] ; pr_devel ( ""<--%s()=ok[replace]\\n"" , __func__ ) ; return true ; } } if ( free_slot >= 0 ) { pr_devel ( ""insertinfreeslot%d\\n"" , free_slot ) ; edit -> leaf_p = & node -> slots [ free_slot ] ; edit -> adjust_count_on = node ; pr_devel ( ""<--%s()=ok[insert]\\n"" , __func__ ) ; return true ; } new_n0 = kzalloc ( sizeof ( struct assoc_array_node ) , GFP_KERNEL ) ; if ( ! new_n0 ) return false ; edit -> new_meta [ 0 ] = assoc_array_node_to_ptr ( new_n0 ) ; new_n1 = kzalloc ( sizeof ( struct assoc_array_node ) , GFP_KERNEL ) ; if ( ! new_n1 ) return false ; edit -> new_meta [ 1 ] = assoc_array_node_to_ptr ( new_n1 ) ; pr_devel ( ""nospareslots\\n"" ) ; have_meta = false ; for ( i = 0 ; i < ASSOC_ARRAY_FAN_OUT ; i ++ ) { ptr = node -> slots [ i ] ; if ( assoc_array_ptr_is_meta ( ptr ) ) { edit -> segment_cache [ i ] = 0xff ; have_meta = true ; continue ; } base_seg = ops -> get_object_key_chunk ( assoc_array_ptr_to_leaf ( ptr ) , level ) ; base_seg >>= level & ASSOC_ARRAY_KEY_CHUNK_MASK ; edit -> segment_cache [ i ] = base_seg & ASSOC_ARRAY_FAN_MASK ; } if ( have_meta ) { pr_devel ( ""havemeta\\n"" ) ; goto split_node ; } dissimilarity = 0 ; base_seg = edit -> segment_cache [ 0 ] ; for ( i = 1 ; i < ASSOC_ARRAY_FAN_OUT ; i ++ ) dissimilarity |= edit -> segment_cache [ i ] ^ base_seg ; pr_devel ( ""onlyleaves;dissimilarity=%lx\\n"" , dissimilarity ) ; if ( ( dissimilarity & ASSOC_ARRAY_FAN_MASK ) == 0 ) { if ( ( edit -> segment_cache [ ASSOC_ARRAY_FAN_OUT ] ^ base_seg ) == 0 ) goto all_leaves_cluster_together ; goto present_leaves_cluster_but_not_new_leaf ; } split_node : pr_devel ( ""splitnode\\n"" ) ; edit -> set [ 0 ] . to = assoc_array_node_to_ptr ( new_n0 ) ; new_n0 -> back_pointer = node -> back_pointer ; new_n0 -> parent_slot = node -> parent_slot ; new_n1 -> back_pointer = assoc_array_node_to_ptr ( new_n0 ) ; new_n1 -> parent_slot = - 1 ; do_split_node : pr_devel ( ""do_split_node\\n"" ) ; new_n0 -> nr_leaves_on_branch = node -> nr_leaves_on_branch ; new_n1 -> nr_leaves_on_branch = 0 ; for ( i = 0 ; i < ASSOC_ARRAY_FAN_OUT ; i ++ ) { slot = edit -> segment_cache [ i ] ; if ( slot != 0xff ) for ( j = i + 1 ; j < ASSOC_ARRAY_FAN_OUT + 1 ; j ++ ) if ( edit -> segment_cache [ j ] == slot ) goto found_slot_for_multiple_occupancy ; } found_slot_for_multiple_occupancy : pr_devel ( ""sameslot:%x%x[%02x]\\n"" , i , j , slot ) ; BUG_ON ( i >= ASSOC_ARRAY_FAN_OUT ) ; BUG_ON ( j >= ASSOC_ARRAY_FAN_OUT + 1 ) ; BUG_ON ( slot >= ASSOC_ARRAY_FAN_OUT ) ; new_n1 -> parent_slot = slot ; for ( i = 0 ; i < ASSOC_ARRAY_FAN_OUT ; i ++ ) if ( assoc_array_ptr_is_meta ( node -> slots [ i ] ) ) new_n0 -> slots [ i ] = node -> slots [ i ] ; else new_n0 -> slots [ i ] = NULL ; BUG_ON ( new_n0 -> slots [ slot ] != NULL ) ; new_n0 -> slots [ slot ] = assoc_array_node_to_ptr ( new_n1 ) ; free_slot = - 1 ; next_slot = 0 ; for ( i = 0 ; i < ASSOC_ARRAY_FAN_OUT ; i ++ ) { if ( assoc_array_ptr_is_meta ( node -> slots [ i ] ) ) continue ; if ( edit -> segment_cache [ i ] == slot ) { new_n1 -> slots [ next_slot ++ ] = node -> slots [ i ] ; new_n1 -> nr_leaves_on_branch ++ ; } else { do { free_slot ++ ; } while ( new_n0 -> slots [ free_slot ] != NULL ) ; new_n0 -> slots [ free_slot ] = node -> slots [ i ] ; } } pr_devel ( ""filtered:f=%xn=%x\\n"" , free_slot , next_slot ) ; if ( edit -> segment_cache [ ASSOC_ARRAY_FAN_OUT ] != slot ) { do { free_slot ++ ; } while ( new_n0 -> slots [ free_slot ] != NULL ) ; edit -> leaf_p = & new_n0 -> slots [ free_slot ] ; edit -> adjust_count_on = new_n0 ; } else { edit -> leaf_p = & new_n1 -> slots [ next_slot ++ ] ; edit -> adjust_count_on = new_n1 ; } BUG_ON ( next_slot <= 1 ) ; edit -> set_backpointers_to = assoc_array_node_to_ptr ( new_n0 ) ; for ( i = 0 ; i < ASSOC_ARRAY_FAN_OUT ; i ++ ) { if ( edit -> segment_cache [ i ] == 0xff ) { ptr = node -> slots [ i ] ; BUG_ON ( assoc_array_ptr_is_leaf ( ptr ) ) ; if ( assoc_array_ptr_is_node ( ptr ) ) { side = assoc_array_ptr_to_node ( ptr ) ; edit -> set_backpointers [ i ] = & side -> back_pointer ; } else { shortcut = assoc_array_ptr_to_shortcut ( ptr ) ; edit -> set_backpointers [ i ] = & shortcut -> back_pointer ; } } } ptr = node -> back_pointer ; if ( ! ptr ) edit -> set [ 0 ] . ptr = & edit -> array -> root ; else if ( assoc_array_ptr_is_node ( ptr ) ) edit -> set [ 0 ] . ptr = & assoc_array_ptr_to_node ( ptr ) -> slots [ node -> parent_slot ] ; else edit -> set [ 0 ] . ptr = & assoc_array_ptr_to_shortcut ( ptr ) -> next_node ; edit -> excised_meta [ 0 ] = assoc_array_node_to_ptr ( node ) ; pr_devel ( ""<--%s()=ok[splitnode]\\n"" , __func__ ) ; return true ; present_leaves_cluster_but_not_new_leaf : pr_devel ( ""presentleavesclusterbutnotnewleaf\\n"" ) ; new_n0 -> back_pointer = node -> back_pointer ; new_n0 -> parent_slot = node -> parent_slot ; new_n0 -> nr_leaves_on_branch = node -> nr_leaves_on_branch ; new_n1 -> back_pointer = assoc_array_node_to_ptr ( new_n0 ) ; new_n1 -> parent_slot = edit -> segment_cache [ 0 ] ; new_n1 -> nr_leaves_on_branch = node -> nr_leaves_on_branch ; edit -> adjust_count_on = new_n0 ; for ( i = 0 ; i < ASSOC_ARRAY_FAN_OUT ; i ++ ) new_n1 -> slots [ i ] = node -> slots [ i ] ; new_n0 -> slots [ edit -> segment_cache [ 0 ] ] = assoc_array_node_to_ptr ( new_n0 ) ; edit -> leaf_p = & new_n0 -> slots [ edit -> segment_cache [ ASSOC_ARRAY_FAN_OUT ] ] ; edit -> set [ 0 ] . ptr = & assoc_array_ptr_to_node ( node -> back_pointer ) -> slots [ node -> parent_slot ] ; edit -> set [ 0 ] . to = assoc_array_node_to_ptr ( new_n0 ) ; edit -> excised_meta [ 0 ] = assoc_array_node_to_ptr ( node ) ; pr_devel ( ""<--%s()=ok[insertnodebefore]\\n"" , __func__ ) ; return true ; all_leaves_cluster_together : pr_devel ( ""allleavesclustertogether\\n"" ) ; diff = INT_MAX ; for ( i = 0 ; i < ASSOC_ARRAY_FAN_OUT ; i ++ ) { int x = ops -> diff_objects ( assoc_array_ptr_to_leaf ( node -> slots [ i ] ) , index_key ) ; if ( x < diff ) { BUG_ON ( x < 0 ) ; diff = x ; } } BUG_ON ( diff == INT_MAX ) ; BUG_ON ( diff < level + ASSOC_ARRAY_LEVEL_STEP ) ; keylen = round_up ( diff , ASSOC_ARRAY_KEY_CHUNK_SIZE ) ; keylen >>= ASSOC_ARRAY_KEY_CHUNK_SHIFT ; new_s0 = kzalloc ( sizeof ( struct assoc_array_shortcut ) + keylen * sizeof ( unsigned long ) , GFP_KERNEL ) ; if ( ! new_s0 ) return false ; edit -> new_meta [ 2 ] = assoc_array_shortcut_to_ptr ( new_s0 ) ; edit -> set [ 0 ] . to = assoc_array_shortcut_to_ptr ( new_s0 ) ; new_s0 -> back_pointer = node -> back_pointer ; new_s0 -> parent_slot = node -> parent_slot ; new_s0 -> next_node = assoc_array_node_to_ptr ( new_n0 ) ; new_n0 -> back_pointer = assoc_array_shortcut_to_ptr ( new_s0 ) ; new_n0 -> parent_slot = 0 ; new_n1 -> back_pointer = assoc_array_node_to_ptr ( new_n0 ) ; new_n1 -> parent_slot = - 1 ; new_s0 -> skip_to_level = level = diff & ~ ASSOC_ARRAY_LEVEL_STEP_MASK ; pr_devel ( ""skip_to_level=%d[diff%d]\\n"" , level , diff ) ; BUG_ON ( level <= 0 ) ; for ( i = 0 ; i < keylen ; i ++ ) new_s0 -> index_key [ i ] = ops -> get_key_chunk ( index_key , i * ASSOC_ARRAY_KEY_CHUNK_SIZE ) ; blank = ULONG_MAX << ( level & ASSOC_ARRAY_KEY_CHUNK_MASK ) ; pr_devel ( ""blankoff[%zu]%d:%lx\\n"" , keylen - 1 , level , blank ) ; new_s0 -> index_key [ keylen - 1 ] &= ~ blank ; for ( i = 0 ; i < ASSOC_ARRAY_FAN_OUT ; i ++ ) { ptr = node -> slots [ i ] ; base_seg = ops -> get_object_key_chunk ( assoc_array_ptr_to_leaf ( ptr ) , level ) ; base_seg >>= level & ASSOC_ARRAY_KEY_CHUNK_MASK ; edit -> segment_cache [ i ] = base_seg & ASSOC_ARRAY_FAN_MASK ; } base_seg = ops -> get_key_chunk ( index_key , level ) ; base_seg >>= level & ASSOC_ARRAY_KEY_CHUNK_MASK ; edit -> segment_cache [ ASSOC_ARRAY_FAN_OUT ] = base_seg & ASSOC_ARRAY_FAN_MASK ; goto do_split_node ; } "," goto all_leaves_cluster_together ; pr_devel ( ""presentleavesclusterbutnotnewleaf\\n"" ) ; } split_node return true ; all_leaves_cluster_together : pr_devel ",torvalds@linux/ea6789980fdaa610d7eb63602c746bf6ec70cd2b,CVE-2017-12193,https://github.com/torvalds/linux/commit/ea6789980fdaa610d7eb63602c746bf6ec70cd2b,2017-11-22T18:29Z 1084,CWE-20,"CWE-20 static void settings_init ( void ) { settings . use_cas = true ; settings . access = 0700 ; settings . port = 11211 ; settings . udpport = 11211 ; settings . inter = NULL ; settings . maxbytes = 64 * 1024 * 1024 ; settings . maxconns = 1024 ; settings . verbose = 0 ; settings . oldest_live = 0 ; settings . oldest_cas = 0 ; settings . evict_to_free = 1 ; settings . socketpath = NULL ; settings . factor = 1.25 ; settings . chunk_size = 48 ; settings . num_threads = 4 ; settings . num_threads_per_udp = 0 ; settings . prefix_delimiter = ':' ; settings . detail_enabled = 0 ; settings . reqs_per_event = 20 ; settings . backlog = 1024 ; settings . binding_protocol = negotiating_prot ; settings . item_size_max = 1024 * 1024 ; settings . slab_page_size = 1024 * 1024 ; settings . slab_chunk_size_max = settings . slab_page_size / 2 ; settings . sasl = false ; settings . maxconns_fast = true ; settings . lru_crawler = false ; settings . lru_crawler_sleep = 100 ; settings . lru_crawler_tocrawl = 0 ; settings . lru_maintainer_thread = false ; settings . lru_segmented = true ; settings . hot_lru_pct = 20 ; settings . warm_lru_pct = 40 ; settings . hot_max_factor = 0.2 ; settings . warm_max_factor = 2.0 ; settings . inline_ascii_response = false ; settings . temp_lru = false ; settings . temporary_ttl = 61 ; settings . idle_timeout = 0 ; settings . hashpower_init = 0 ; settings . slab_reassign = true ; settings . slab_automove = 1 ; settings . slab_automove_ratio = 0.8 ; settings . slab_automove_window = 30 ; settings . shutdown_command = false ; settings . tail_repair_time = TAIL_REPAIR_TIME_DEFAULT ; settings . flush_enabled = true ; settings . dump_enabled = true ; settings . crawls_persleep = 1000 ; settings . logger_watcher_buf_size = LOGGER_WATCHER_BUF_SIZE ; settings . logger_buf_size = LOGGER_BUF_SIZE ; settings . drop_privileges = true ; # ifdef MEMCACHED_DEBUG settings . relaxed_privileges = false ; # endif } "," . udpport = 0 ; settings . ",memcached@memcached/dbb7a8af90054bf4ef51f5814ef7ceb17d83d974,CVE-2018-1000115,https://github.com/memcached/memcached/commit/dbb7a8af90054bf4ef51f5814ef7ceb17d83d974,2018-03-05T14:29Z 1085,CWE-399,"CWE-399 static guint32 finalizer_thread ( gpointer unused ) { while ( ! finished ) { g_assert ( mono_domain_get ( ) == mono_get_root_domain ( ) ) ; # ifdef MONO_HAS_SEMAPHORES MONO_SEM_WAIT ( & finalizer_sem ) ; # else WaitForSingleObjectEx ( finalizer_event , INFINITE , FALSE ) ; # endif mono_console_handle_async_ops ( ) ; # ifndef DISABLE_ATTACH mono_attach_maybe_start ( ) ; # endif if ( domains_to_finalize ) { mono_finalizer_lock ( ) ; if ( domains_to_finalize ) { DomainFinalizationReq * req = domains_to_finalize -> data ; domains_to_finalize = g_slist_remove ( domains_to_finalize , req ) ; mono_finalizer_unlock ( ) ; finalize_domain_objects ( req ) ; } else { mono_finalizer_unlock ( ) ; } } mono_gc_invoke_finalizers ( ) ; SetEvent ( pending_done_event ) ; } SetEvent ( shutdown_event ) ; return 0 ; } "," ; # endif reference_queue_proccess_all ( ) ; ",mono@mono/8eb1189099e02372fd45ca1c67230eccf1edddc0,CVE-2011-0991,https://github.com/mono/mono/commit/8eb1189099e02372fd45ca1c67230eccf1edddc0,2011-04-13T21:55Z 1086,CWE-787,"CWE-787 VOID ixheaacd_esbr_postradixcompute2 ( WORD32 * ptr_y , WORD32 * ptr_x , const WORD32 * pdig_rev_tbl , WORD32 npoints ) { WORD32 i , k ; WORD32 h2 ; WORD32 x_0 , x_1 , x_2 , x_3 ; WORD32 x_4 , x_5 , x_6 , x_7 ; WORD32 x_8 , x_9 , x_a , x_b , x_c , x_d , x_e , x_f ; WORD32 n00 , n10 , n20 , n30 , n01 , n11 , n21 , n31 ; WORD32 n02 , n12 , n22 , n32 , n03 , n13 , n23 , n33 ; WORD32 n0 , j0 ; WORD32 * x2 , * x0 ; WORD32 * y0 , * y1 , * y2 , * y3 ; y0 = ptr_y ; y2 = ptr_y + ( WORD32 ) npoints ; x0 = ptr_x ; x2 = ptr_x + ( WORD32 ) ( npoints >> 1 ) ; y1 = y0 + ( WORD32 ) ( npoints >> 2 ) ; y3 = y2 + ( WORD32 ) ( npoints >> 2 ) ; j0 = 8 ; n0 = npoints >> 1 ; for ( k = 0 ; k < 2 ; k ++ ) { for ( i = 0 ; i < npoints >> 1 ; i += 8 ) { h2 = * pdig_rev_tbl ++ >> 2 ; x_0 = * x0 ++ ; x_1 = * x0 ++ ; x_2 = * x0 ++ ; x_3 = * x0 ++ ; x_4 = * x0 ++ ; x_5 = * x0 ++ ; x_6 = * x0 ++ ; x_7 = * x0 ++ ; n00 = x_0 + x_2 ; n01 = x_1 + x_3 ; n20 = x_0 - x_2 ; n21 = x_1 - x_3 ; n10 = x_4 + x_6 ; n11 = x_5 + x_7 ; n30 = x_4 - x_6 ; n31 = x_5 - x_7 ; y0 [ h2 ] = n00 ; y0 [ h2 + 1 ] = n01 ; y1 [ h2 ] = n10 ; y1 [ h2 + 1 ] = n11 ; y2 [ h2 ] = n20 ; y2 [ h2 + 1 ] = n21 ; y3 [ h2 ] = n30 ; y3 [ h2 + 1 ] = n31 ; x_8 = * x2 ++ ; x_9 = * x2 ++ ; x_a = * x2 ++ ; x_b = * x2 ++ ; x_c = * x2 ++ ; x_d = * x2 ++ ; x_e = * x2 ++ ; x_f = * x2 ++ ; n02 = x_8 + x_a ; n03 = x_9 + x_b ; n22 = x_8 - x_a ; n23 = x_9 - x_b ; n12 = x_c + x_e ; n13 = x_d + x_f ; n32 = x_c - x_e ; n33 = x_d - x_f ; y0 [ h2 + 2 ] = n02 ; y0 [ h2 + 3 ] = n03 ; y1 [ h2 + 2 ] = n12 ; y1 [ h2 + 3 ] = n13 ; y2 [ h2 + 2 ] = n22 ; y2 [ h2 + 3 ] = n23 ; y3 [ h2 + 2 ] = n32 ; y3 [ h2 + 3 ] = n33 ; } x0 += ( WORD32 ) npoints >> 1 ; x2 += ( WORD32 ) npoints >> 1 ; } } "," x_e , x_f ; WORD32 n0 x0 ++ ; y0 [ h2 ] = ixheaacd_add32_sat ( x_0 , x_2 ) ; y0 [ h2 + 1 ] = ixheaacd_add32_sat ( x_1 , x_3 ) ; y1 [ h2 ] = ixheaacd_add32_sat ( x_4 , x_6 ) ; y1 [ h2 + 1 ] = ixheaacd_add32_sat ( x_5 , x_7 ) ; y2 [ h2 ] = ixheaacd_sub32_sat ( x_0 , x_2 ) ; y2 [ h2 + 1 ] = ixheaacd_sub32_sat ( x_1 , x_3 ) ; y3 [ h2 ] = ixheaacd_sub32_sat ( x_4 , x_6 ) ; y3 [ h2 + 1 ] = ixheaacd_sub32_sat ( x_5 , x_7 ) ; x_8 = * x2 ++ ; x_9 = * x2 ++ ; x_a = * x2 ++ ; x_b = * x2 ++ ; x_c = * x2 ++ ; x_d = * x2 ++ ; x_e = * x2 ++ ; x_f = * x2 ++ ; y0 [ h2 + 2 ] = ixheaacd_add32_sat ( x_8 , x_a ) ; y0 [ h2 + 3 ] = ixheaacd_add32_sat ( x_9 , x_b ) ; y1 [ y1 [ h2 + 2 ] = ixheaacd_add32_sat ( x_c , x_e ) ; y1 [ [ h2 + 3 ] = ixheaacd_add32_sat ( x_d , x_f ) ; y2 [ h2 + 2 ] = ixheaacd_sub32_sat ( x_8 , x_a ) ; y2 [ h2 + 3 ] = ixheaacd_sub32_sat ( x_9 , x_b ) ; y3 [ y3 [ h2 + 2 ] = ixheaacd_sub32_sat ( x_c , x_e ) ; y3 [ [ h2 + 3 ] = ixheaacd_sub32_sat ( x_d , x_f ) ; } x0 ",external@libxaac/04e8cd58f075bec5892e369c8deebca9c67e855c,CVE-2018-9496,https://android.googlesource.com/platform/external/libxaac/+/04e8cd58f075bec5892e369c8deebca9c67e855c,2018-10-02T19:29Z 1087,CWE-189,"CWE-189 int drm_mode_dirtyfb_ioctl ( struct drm_device * dev , void * data , struct drm_file * file_priv ) { struct drm_clip_rect __user * clips_ptr ; struct drm_clip_rect * clips = NULL ; struct drm_mode_fb_dirty_cmd * r = data ; struct drm_mode_object * obj ; struct drm_framebuffer * fb ; unsigned flags ; int num_clips ; int ret = 0 ; if ( ! drm_core_check_feature ( dev , DRIVER_MODESET ) ) return - EINVAL ; mutex_lock ( & dev -> mode_config . mutex ) ; obj = drm_mode_object_find ( dev , r -> fb_id , DRM_MODE_OBJECT_FB ) ; if ( ! obj ) { DRM_ERROR ( ""invalidframebufferid\\n"" ) ; ret = - EINVAL ; goto out_err1 ; } fb = obj_to_fb ( obj ) ; num_clips = r -> num_clips ; clips_ptr = ( struct drm_clip_rect * ) ( unsigned long ) r -> clips_ptr ; if ( ! num_clips != ! clips_ptr ) { ret = - EINVAL ; goto out_err1 ; } flags = DRM_MODE_FB_DIRTY_FLAGS & r -> flags ; if ( flags & DRM_MODE_FB_DIRTY_ANNOTATE_COPY && ( num_clips % 2 ) ) { ret = - EINVAL ; goto out_err1 ; } if ( num_clips && clips_ptr ) { clips = kzalloc ( num_clips * sizeof ( * clips ) , GFP_KERNEL ) ; if ( ! clips ) { ret = - ENOMEM ; goto out_err1 ; } ret = copy_from_user ( clips , clips_ptr , num_clips * sizeof ( * clips ) ) ; if ( ret ) { ret = - EFAULT ; goto out_err2 ; } } if ( fb -> funcs -> dirty ) { ret = fb -> funcs -> dirty ( fb , file_priv , flags , r -> color , clips , num_clips ) ; } else { ret = - ENOSYS ; goto out_err2 ; } out_err2 : kfree ( clips ) ; out_err1 : mutex_unlock ( & dev -> mode_config . mutex ) ; return ret ; } "," clips_ptr ) { if ( num_clips < 0 || num_clips > DRM_MODE_FB_DIRTY_MAX_CLIPS ) { ret = - EINVAL ; goto out_err1 ; } ",torvalds@linux/a5cd335165e31db9dbab636fd29895d41da55dd2,CVE-2012-0044,https://github.com/torvalds/linux/commit/a5cd335165e31db9dbab636fd29895d41da55dd2,2012-05-17T11:00Z 1088,CWE-264,"CWE-264 static inline int unuse_pmd_range ( struct vm_area_struct * vma , pud_t * pud , unsigned long addr , unsigned long end , swp_entry_t entry , struct page * page ) { pmd_t * pmd ; unsigned long next ; int ret ; pmd = pmd_offset ( pud , addr ) ; do { next = pmd_addr_end ( addr , end ) ; if ( unlikely ( pmd_trans_huge ( * pmd ) ) ) continue ; if ( pmd_none_or_clear_bad ( pmd ) ) continue ; ret = unuse_pte_range ( vma , pmd , addr , next , entry , page ) ; if ( ret ) return ret ; } while ( pmd ++ , addr = next , addr != end ) ; return 0 ; } "," ; if ( pmd_none_or_trans_huge_or_clear_bad ( pmd ) ",torvalds@linux/4a1d704194a441bf83c636004a479e01360ec850,CVE-2012-1179,https://github.com/torvalds/linux/commit/4a1d704194a441bf83c636004a479e01360ec850,2012-05-17T11:00Z 1089,CWE-399,"CWE-399 static int misaligned_fpu_store ( struct pt_regs * regs , __u32 opcode , int displacement_not_indexed , int width_shift , int do_paired_load ) { int error ; int srcreg ; __u64 address ; error = generate_and_check_address ( regs , opcode , displacement_not_indexed , width_shift , & address ) ; if ( error < 0 ) { return error ; } perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , address ) ; srcreg = ( opcode >> 4 ) & 0x3f ; if ( user_mode ( regs ) ) { __u64 buffer ; __u32 buflo = 0xffffffffUL , bufhi = 0xffffffffUL ; if ( ! access_ok ( VERIFY_WRITE , ( unsigned long ) address , 1UL << width_shift ) ) { return - 1 ; } if ( last_task_used_math == current ) { enable_fpu ( ) ; save_fpu ( current ) ; disable_fpu ( ) ; last_task_used_math = NULL ; regs -> sr |= SR_FD ; } switch ( width_shift ) { case 2 : buflo = current -> thread . xstate -> hardfpu . fp_regs [ srcreg ] ; break ; case 3 : if ( do_paired_load ) { buflo = current -> thread . xstate -> hardfpu . fp_regs [ srcreg ] ; bufhi = current -> thread . xstate -> hardfpu . fp_regs [ srcreg + 1 ] ; } else { # if defined ( CONFIG_CPU_LITTLE_ENDIAN ) bufhi = current -> thread . xstate -> hardfpu . fp_regs [ srcreg ] ; buflo = current -> thread . xstate -> hardfpu . fp_regs [ srcreg + 1 ] ; # else buflo = current -> thread . xstate -> hardfpu . fp_regs [ srcreg ] ; bufhi = current -> thread . xstate -> hardfpu . fp_regs [ srcreg + 1 ] ; # endif } break ; default : printk ( ""Unexpectedwidth_shift%dinmisaligned_fpu_store,PC=%08lx\\n"" , width_shift , ( unsigned long ) regs -> pc ) ; break ; } * ( __u32 * ) & buffer = buflo ; * ( 1 + ( __u32 * ) & buffer ) = bufhi ; if ( __copy_user ( ( void * ) ( int ) address , & buffer , ( 1 << width_shift ) ) > 0 ) { return - 1 ; } return 0 ; } else { die ( ""MisalignedFPUloadinsidekernel"" , regs , 0 ) ; return - 1 ; } } "," , 1 , regs , address ",torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,CVE-2011-2918,https://github.com/torvalds/linux/commit/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,2012-05-24T23:55Z 1090,CWE-125,"CWE-125 static void core_anal_bytes ( RCore * core , const ut8 * buf , int len , int nops , int fmt ) { int stacksize = r_config_get_i ( core -> config , ""esil.stack.depth"" ) ; bool iotrap = r_config_get_i ( core -> config , ""esil.iotrap"" ) ; bool romem = r_config_get_i ( core -> config , ""esil.romem"" ) ; bool stats = r_config_get_i ( core -> config , ""esil.stats"" ) ; bool be = core -> print -> big_endian ; bool use_color = core -> print -> flags & R_PRINT_FLAGS_COLOR ; core -> parser -> relsub = r_config_get_i ( core -> config , ""asm.relsub"" ) ; int ret , i , j , idx , size ; const char * color = """" ; const char * esilstr ; const char * opexstr ; RAnalHint * hint ; RAnalEsil * esil = NULL ; RAsmOp asmop ; RAnalOp op = { 0 } ; ut64 addr ; bool isFirst = true ; unsigned int addrsize = r_config_get_i ( core -> config , ""esil.addr.size"" ) ; int totalsize = 0 ; if ( use_color ) { color = core -> cons -> pal . label ; } switch ( fmt ) { case 'j' : r_cons_printf ( ""["" ) ; break ; case 'r' : esil = r_anal_esil_new ( stacksize , iotrap , addrsize ) ; if ( ! esil ) { return ; } r_anal_esil_to_reil_setup ( esil , core -> anal , romem , stats ) ; r_anal_esil_set_pc ( esil , core -> offset ) ; break ; } for ( i = idx = ret = 0 ; idx < len && ( ! nops || ( nops && i < nops ) ) ; i ++ , idx += ret ) { addr = core -> offset + idx ; hint = r_anal_hint_get ( core -> anal , addr ) ; r_asm_set_pc ( core -> assembler , addr ) ; ( void ) r_asm_disassemble ( core -> assembler , & asmop , buf + idx , len - idx ) ; ret = r_anal_op ( core -> anal , & op , core -> offset + idx , buf + idx , len - idx , R_ANAL_OP_MASK_ESIL ) ; esilstr = R_STRBUF_SAFEGET ( & op . esil ) ; opexstr = R_STRBUF_SAFEGET ( & op . opex ) ; char * mnem = strdup ( r_asm_op_get_asm ( & asmop ) ) ; char * sp = strchr ( mnem , '' ) ; if ( sp ) { * sp = 0 ; if ( op . prefix ) { char * arg = strdup ( sp + 1 ) ; char * sp = strchr ( arg , '' ) ; if ( sp ) { * sp = 0 ; } free ( mnem ) ; mnem = arg ; } } if ( ret < 1 && fmt != 'd' ) { eprintf ( ""Oopsat0x%08"" PFMT64x ""("" , core -> offset + idx ) ; for ( i = idx , j = 0 ; i < core -> blocksize && j < 3 ; ++ i , ++ j ) { eprintf ( ""%02x"" , buf [ i ] ) ; } eprintf ( ""...)\\n"" ) ; free ( mnem ) ; break ; } size = ( hint && hint -> size ) ? hint -> size : op . size ; if ( fmt == 'd' ) { char * opname = strdup ( r_asm_op_get_asm ( & asmop ) ) ; if ( opname ) { r_str_split ( opname , '' ) ; char * d = r_asm_describe ( core -> assembler , opname ) ; if ( d && * d ) { r_cons_printf ( ""%s:%s\\n"" , opname , d ) ; free ( d ) ; } else { eprintf ( ""Unknownopcode\\n"" ) ; } free ( opname ) ; } } else if ( fmt == 'e' ) { if ( * esilstr ) { if ( use_color ) { r_cons_printf ( ""%s0x%"" PFMT64x Color_RESET ""%s\\n"" , color , core -> offset + idx , esilstr ) ; } else { r_cons_printf ( ""0x%"" PFMT64x ""%s\\n"" , core -> offset + idx , esilstr ) ; } } } else if ( fmt == 's' ) { totalsize += op . size ; } else if ( fmt == 'r' ) { if ( * esilstr ) { if ( use_color ) { r_cons_printf ( ""%s0x%"" PFMT64x Color_RESET ""\\n"" , color , core -> offset + idx ) ; } else { r_cons_printf ( ""0x%"" PFMT64x ""\\n"" , core -> offset + idx ) ; } r_anal_esil_parse ( esil , esilstr ) ; r_anal_esil_dumpstack ( esil ) ; r_anal_esil_stack_free ( esil ) ; } } else if ( fmt == 'j' ) { if ( isFirst ) { isFirst = false ; } else { r_cons_print ( "","" ) ; } r_cons_printf ( ""{\\""opcode\\"":\\""%s\\"","" , r_asm_op_get_asm ( & asmop ) ) ; { char strsub [ 128 ] = { 0 } ; r_parse_varsub ( core -> parser , NULL , core -> offset + idx , asmop . size , r_asm_op_get_asm ( & asmop ) , strsub , sizeof ( strsub ) ) ; { ut64 killme = UT64_MAX ; if ( r_io_read_i ( core -> io , op . ptr , & killme , op . refptr , be ) ) { core -> parser -> relsub_addr = killme ; } } char * p = strdup ( strsub ) ; if ( p ) { r_parse_filter ( core -> parser , addr , core -> flags , p , strsub , sizeof ( strsub ) , be ) ; free ( p ) ; } r_cons_printf ( ""\\""disasm\\"":\\""%s\\"","" , strsub ) ; } r_cons_printf ( ""\\""mnemonic\\"":\\""%s\\"","" , mnem ) ; if ( hint && hint -> opcode ) { r_cons_printf ( ""\\""ophint\\"":\\""%s\\"","" , hint -> opcode ) ; } r_cons_printf ( ""\\""sign\\"":%s,"" , r_str_bool ( op . sign ) ) ; r_cons_printf ( ""\\""prefix\\"":%"" PFMT64u "","" , op . prefix ) ; r_cons_printf ( ""\\""id\\"":%d,"" , op . id ) ; if ( opexstr && * opexstr ) { r_cons_printf ( ""\\""opex\\"":%s,"" , opexstr ) ; } r_cons_printf ( ""\\""addr\\"":%"" PFMT64u "","" , core -> offset + idx ) ; r_cons_printf ( ""\\""bytes\\"":\\"""" ) ; for ( j = 0 ; j < size ; j ++ ) { r_cons_printf ( ""%02x"" , buf [ j + idx ] ) ; } r_cons_printf ( ""\\"","" ) ; if ( op . val != UT64_MAX ) { r_cons_printf ( ""\\""val\\"":%"" PFMT64u "","" , op . val ) ; } if ( op . ptr != UT64_MAX ) { r_cons_printf ( ""\\""ptr\\"":%"" PFMT64u "","" , op . ptr ) ; } r_cons_printf ( ""\\""size\\"":%d,"" , size ) ; r_cons_printf ( ""\\""type\\"":\\""%s\\"","" , r_anal_optype_to_string ( op . type ) ) ; if ( op . reg ) { r_cons_printf ( ""\\""reg\\"":\\""%s\\"","" , op . reg ) ; } if ( op . ireg ) { r_cons_printf ( ""\\""ireg\\"":\\""%s\\"","" , op . ireg ) ; } if ( op . scale ) { r_cons_printf ( ""\\""scale\\"":%d,"" , op . scale ) ; } if ( hint && hint -> esil ) { r_cons_printf ( ""\\""esil\\"":\\""%s\\"","" , hint -> esil ) ; } else if ( * esilstr ) { r_cons_printf ( ""\\""esil\\"":\\""%s\\"","" , esilstr ) ; } if ( hint && hint -> jump != UT64_MAX ) { op . jump = hint -> jump ; } if ( op . jump != UT64_MAX ) { r_cons_printf ( ""\\""jump\\"":%"" PFMT64u "","" , op . jump ) ; } if ( hint && hint -> fail != UT64_MAX ) { op . fail = hint -> fail ; } if ( op . refptr != - 1 ) { r_cons_printf ( ""\\""refptr\\"":%d,"" , op . refptr ) ; } if ( op . fail != UT64_MAX ) { r_cons_printf ( ""\\""fail\\"":%"" PFMT64u "","" , op . fail ) ; } r_cons_printf ( ""\\""cycles\\"":%d,"" , op . cycles ) ; if ( op . failcycles ) { r_cons_printf ( ""\\""failcycles\\"":%d,"" , op . failcycles ) ; } r_cons_printf ( ""\\""delay\\"":%d,"" , op . delay ) ; { const char * p = r_anal_stackop_tostring ( op . stackop ) ; if ( p && * p && strcmp ( p , ""null"" ) ) r_cons_printf ( ""\\""stack\\"":\\""%s\\"","" , p ) ; } if ( op . stackptr ) { r_cons_printf ( ""\\""stackptr\\"":%d,"" , op . stackptr ) ; } { const char * arg = ( op . type & R_ANAL_OP_TYPE_COND ) ? r_anal_cond_tostring ( op . cond ) : NULL ; if ( arg ) { r_cons_printf ( ""\\""cond\\"":\\""%s\\"","" , arg ) ; } } r_cons_printf ( ""\\""family\\"":\\""%s\\""}"" , r_anal_op_family_to_string ( op . family ) ) ; } else { # define printline ( k , fmt , arg ) { if ( use_color ) r_cons_printf ( ""%s%s:"" Color_RESET , color , k ) ; else r_cons_printf ( ""%s:"" , k ) ; if ( fmt ) r_cons_printf ( fmt , arg ) ; } printline ( ""address"" , ""0x%"" PFMT64x ""\\n"" , core -> offset + idx ) ; printline ( ""opcode"" , ""%s\\n"" , r_asm_op_get_asm ( & asmop ) ) ; printline ( ""mnemonic"" , ""%s\\n"" , mnem ) ; if ( hint ) { if ( hint -> opcode ) { printline ( ""ophint"" , ""%s\\n"" , hint -> opcode ) ; } # if 0 if ( hint -> addr != UT64_MAX ) { printline ( ""addr"" , ""0x%08"" PFMT64x ""\\n"" , ( hint -> addr + idx ) ) ; } # endif } printline ( ""prefix"" , ""%"" PFMT64u ""\\n"" , op . prefix ) ; printline ( ""id"" , ""%d\\n"" , op . id ) ; # if 0 if ( opexstr && * opexstr ) { printline ( ""opex"" , ""%s\\n"" , opexstr ) ; } # endif printline ( ""bytes"" , NULL , 0 ) ; for ( j = 0 ; j < size ; j ++ ) { r_cons_printf ( ""%02x"" , buf [ j + idx ] ) ; } r_cons_newline ( ) ; if ( op . val != UT64_MAX ) printline ( ""val"" , ""0x%08"" PFMT64x ""\\n"" , op . val ) ; if ( op . ptr != UT64_MAX ) printline ( ""ptr"" , ""0x%08"" PFMT64x ""\\n"" , op . ptr ) ; if ( op . refptr != - 1 ) printline ( ""refptr"" , ""%d\\n"" , op . refptr ) ; printline ( ""size"" , ""%d\\n"" , size ) ; printline ( ""sign"" , ""%s\\n"" , r_str_bool ( op . sign ) ) ; printline ( ""type"" , ""%s\\n"" , r_anal_optype_to_string ( op . type ) ) ; printline ( ""cycles"" , ""%d\\n"" , op . cycles ) ; if ( op . failcycles ) { printline ( ""failcycles"" , ""%d\\n"" , op . failcycles ) ; } { const char * t2 = r_anal_optype_to_string ( op . type2 ) ; if ( t2 && strcmp ( t2 , ""null"" ) ) { printline ( ""type2"" , ""%s\\n"" , t2 ) ; } } if ( op . reg ) { printline ( ""reg"" , ""%s\\n"" , op . reg ) ; } if ( op . ireg ) { printline ( ""ireg"" , ""%s\\n"" , op . ireg ) ; } if ( op . scale ) { printline ( ""scale"" , ""%d\\n"" , op . scale ) ; } if ( hint && hint -> esil ) { printline ( ""esil"" , ""%s\\n"" , hint -> esil ) ; } else if ( * esilstr ) { printline ( ""esil"" , ""%s\\n"" , esilstr ) ; } if ( hint && hint -> jump != UT64_MAX ) { op . jump = hint -> jump ; } if ( op . jump != UT64_MAX ) { printline ( ""jump"" , ""0x%08"" PFMT64x ""\\n"" , op . jump ) ; } if ( op . direction != 0 ) { const char * dir = op . direction == 1 ? ""read"" : op . direction == 2 ? ""write"" : op . direction == 4 ? ""exec"" : op . direction == 8 ? ""ref"" : ""none"" ; printline ( ""direction"" , ""%s\\n"" , dir ) ; } if ( hint && hint -> fail != UT64_MAX ) { op . fail = hint -> fail ; } if ( op . fail != UT64_MAX ) { printline ( ""fail"" , ""0x%08"" PFMT64x ""\\n"" , op . fail ) ; } if ( op . delay ) { printline ( ""delay"" , ""%d\\n"" , op . delay ) ; } printline ( ""stack"" , ""%s\\n"" , r_anal_stackop_tostring ( op . stackop ) ) ; { const char * arg = ( op . type & R_ANAL_OP_TYPE_COND ) ? r_anal_cond_tostring ( op . cond ) : NULL ; if ( arg ) { printline ( ""cond"" , ""%s\\n"" , arg ) ; } } printline ( ""family"" , ""%s\\n"" , r_anal_op_family_to_string ( op . family ) ) ; printline ( ""stackop"" , ""%s\\n"" , r_anal_stackop_tostring ( op . stackop ) ) ; if ( op . stackptr ) { printline ( ""stackptr"" , ""%"" PFMT64u ""\\n"" , op . stackptr ) ; } } free ( mnem ) ; r_anal_hint_free ( hint ) ; r_anal_op_fini ( & op ) ; } r_anal_op_fini ( & op ) ; if ( fmt == 'j' ) { r_cons_printf ( ""]"" ) ; r_cons_newline ( ) ; } else if ( fmt == 's' ) { r_cons_printf ( ""%d\\n"" , totalsize ) ; } r_anal_esil_free ( esil ) ; } "," 0 ) ; int minsz = R_MIN ( len , size ) ; minsz = R_MAX ( minsz , 0 ) ; ; j < minsz ; j ++ ++ ) { ut8 ch = ( ( j + idx - 1 ) > minsz ) ? 0xff : buf [ j + idx ] ; r_cons_printf ( ""%02x"" , ch != UT64_MAX ) { val ) ; } != UT64_MAX ) { ptr ) ; } - 1 ) { refptr ) ; } ",radare@radare2/a1bc65c3db593530775823d6d7506a457ed95267,CVE-2018-20461,https://github.com/radare/radare2/commit/a1bc65c3db593530775823d6d7506a457ed95267,2018-12-25T19:29Z 1091,CWE-119,"CWE-119 int main ( int argc , char * argv [ ] ) { char * fin , * fout ; FILE * fpin , * fpout ; uint8_t * inbuf , * outbuf ; uint8_t * inbuf_u , * outbuf_u ; uint8_t * inbuf_v , * outbuf_v ; int f , frames ; int width , height , target_width , target_height ; if ( argc < 5 ) { printf ( ""Incorrectparameters:\\n"" ) ; usage ( argv [ 0 ] ) ; return 1 ; } fin = argv [ 1 ] ; fout = argv [ 4 ] ; if ( ! parse_dim ( argv [ 2 ] , & width , & height ) ) { printf ( ""Incorrectparameters:%s\\n"" , argv [ 2 ] ) ; usage ( argv [ 0 ] ) ; return 1 ; } if ( ! parse_dim ( argv [ 3 ] , & target_width , & target_height ) ) { printf ( ""Incorrectparameters:%s\\n"" , argv [ 3 ] ) ; usage ( argv [ 0 ] ) ; return 1 ; } fpin = fopen ( fin , ""rb"" ) ; if ( fpin == NULL ) { printf ( ""Can\'topenfile%storead\\n"" , fin ) ; usage ( argv [ 0 ] ) ; return 1 ; } fpout = fopen ( fout , ""wb"" ) ; if ( fpout == NULL ) { printf ( ""Can\'topenfile%stowrite\\n"" , fout ) ; usage ( argv [ 0 ] ) ; return 1 ; } if ( argc >= 6 ) frames = atoi ( argv [ 5 ] ) ; else frames = INT_MAX ; printf ( ""Inputsize:%dx%d\\n"" , width , height ) ; printf ( ""Targetsize:%dx%d,Frames:"" , target_width , target_height ) ; if ( frames == INT_MAX ) printf ( ""All\\n"" ) ; else printf ( ""%d\\n"" , frames ) ; inbuf = ( uint8_t * ) malloc ( width * height * 3 / 2 ) ; outbuf = ( uint8_t * ) malloc ( target_width * target_height * 3 / 2 ) ; inbuf_u = inbuf + width * height ; inbuf_v = inbuf_u + width * height / 4 ; outbuf_u = outbuf + target_width * target_height ; outbuf_v = outbuf_u + target_width * target_height / 4 ; f = 0 ; while ( f < frames ) { if ( fread ( inbuf , width * height * 3 / 2 , 1 , fpin ) != 1 ) break ; vp9_resize_frame420 ( inbuf , width , inbuf_u , inbuf_v , width / 2 , height , width , outbuf , target_width , outbuf_u , outbuf_v , target_width / 2 , target_height , target_width ) ; fwrite ( outbuf , target_width * target_height * 3 / 2 , 1 , fpout ) ; f ++ ; } printf ( ""%dframesprocessed\\n"" , f ) ; fclose ( fpin ) ; fclose ( fpout ) ; free ( inbuf ) ; free ( outbuf ) ; return 0 ; } "," target_width , target_height ; exec_name = argv [ 0 ] ; usage ( ) ; return ; usage ( ) ; return ; usage ( ) ; return ; usage ( ) ; return ; usage ( ) ; return ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1092,CWE-125,"CWE-125 static irqreturn_t snd_msnd_interrupt ( int irq , void * dev_id ) { struct snd_msnd * chip = dev_id ; void * pwDSPQData = chip -> mappedbase + DSPQ_DATA_BUFF ; while ( readw ( chip -> DSPQ + JQS_wTail ) != readw ( chip -> DSPQ + JQS_wHead ) ) { u16 wTmp ; snd_msnd_eval_dsp_msg ( chip , readw ( pwDSPQData + 2 * readw ( chip -> DSPQ + JQS_wHead ) ) ) ; wTmp = readw ( chip -> DSPQ + JQS_wHead ) + 1 ; if ( wTmp > readw ( chip -> DSPQ + JQS_wSize ) ) writew ( 0 , chip -> DSPQ + JQS_wHead ) ; else writew ( wTmp , chip -> DSPQ + JQS_wHead ) ; } inb ( chip -> io + HP_RXL ) ; return IRQ_HANDLED ; } "," + DSPQ_DATA_BUFF ; u16 head , tail , size ; head = readw ( + JQS_wHead ) ; tail = readw ( chip -> DSPQ + JQS_wTail ) ; size = readw ( chip + JQS_wSize ) ; if ( head > size || tail > size ) goto out ; while ( head != tail ) { snd_msnd_eval_dsp_msg ( chip , readw ( pwDSPQData + 2 * head ) ) ; if ( ++ head > size ) head = 0 ; writew ( head , chip -> ) ; } out : ",torvalds@linux/20e2b791796bd68816fa115f12be5320de2b8021,CVE-2017-9985,https://github.com/torvalds/linux/commit/20e2b791796bd68816fa115f12be5320de2b8021,2017-06-28T06:29Z 1093,CWE-125,"CWE-125 static OPCODE_DESC * avr_op_analyze ( RAnal * anal , RAnalOp * op , ut64 addr , const ut8 * buf , int len , CPU_MODEL * cpu ) { OPCODE_DESC * opcode_desc ; ut16 ins = ( buf [ 1 ] << 8 ) | buf [ 0 ] ; int fail ; char * t ; memset ( op , 0 , sizeof ( RAnalOp ) ) ; op -> ptr = UT64_MAX ; op -> val = UT64_MAX ; op -> jump = UT64_MAX ; r_strbuf_init ( & op -> esil ) ; for ( opcode_desc = opcodes ; opcode_desc -> handler ; opcode_desc ++ ) { if ( ( ins & opcode_desc -> mask ) == opcode_desc -> selector ) { fail = 0 ; op -> cycles = opcode_desc -> cycles ; op -> size = opcode_desc -> size ; op -> type = opcode_desc -> type ; op -> jump = UT64_MAX ; op -> fail = UT64_MAX ; op -> addr = addr ; r_strbuf_setf ( & op -> esil , """" ) ; opcode_desc -> handler ( anal , op , buf , len , & fail , cpu ) ; if ( fail ) { goto INVALID_OP ; } if ( op -> cycles <= 0 ) { opcode_desc -> cycles = 2 ; } op -> nopcode = ( op -> type == R_ANAL_OP_TYPE_UNK ) ; t = r_strbuf_get ( & op -> esil ) ; if ( t && strlen ( t ) > 1 ) { t += strlen ( t ) - 1 ; if ( * t == ',' ) { * t = '\\0' ; } } return opcode_desc ; } } if ( ( ins & 0xff00 ) == 0xff00 && ( ins & 0xf ) > 7 ) { goto INVALID_OP ; } INVALID_OP : op -> family = R_ANAL_OP_FAMILY_UNKNOWN ; op -> type = R_ANAL_OP_TYPE_UNK ; op -> addr = addr ; op -> fail = UT64_MAX ; op -> jump = UT64_MAX ; op -> ptr = UT64_MAX ; op -> val = UT64_MAX ; op -> nopcode = 1 ; op -> cycles = 1 ; op -> size = 2 ; r_strbuf_set ( & op -> esil , ""1,$"" ) ; return NULL ; } "," * opcode_desc ; if ( len < 2 ) { return NULL ; } ",radare@radare2/b35530fa0681b27eba084de5527037ebfb397422,CVE-2018-11377,https://github.com/radare/radare2/commit/b35530fa0681b27eba084de5527037ebfb397422,2018-05-22T19:29Z 1094,CWE-755,"CWE-755 void acpi_ns_terminate ( void ) { acpi_status status ; ACPI_FUNCTION_TRACE ( ns_terminate ) ; # ifdef ACPI_EXEC_APP { union acpi_operand_object * prev ; union acpi_operand_object * next ; next = acpi_gbl_module_code_list ; while ( next ) { prev = next ; next = next -> method . mutex ; prev -> method . mutex = NULL ; acpi_ut_remove_reference ( prev ) ; } } # endif acpi_ns_delete_namespace_subtree ( acpi_gbl_root_node ) ; status = acpi_ut_acquire_mutex ( ACPI_MTX_NAMESPACE ) ; if ( ACPI_FAILURE ( status ) ) { return_VOID ; } acpi_ns_delete_node ( acpi_gbl_root_node ) ; ( void ) acpi_ut_release_mutex ( ACPI_MTX_NAMESPACE ) ; ACPI_DEBUG_PRINT ( ( ACPI_DB_INFO , ""Namespacefreed\\n"" ) ) ; return_VOID ; } "," acpi_status status ; union acpi_operand_object * acpi_operand_object * next ; ACPI_FUNCTION_TRACE ( ns_terminate ) ) ; } acpi_ns_delete_namespace_subtree ( acpi_gbl_root_node ",torvalds@linux/3b2d69114fefa474fca542e51119036dceb4aa6f,CVE-2017-11472,https://github.com/torvalds/linux/commit/3b2d69114fefa474fca542e51119036dceb4aa6f,2017-07-20T04:29Z 1095,CWE-119,"CWE-119 void ParseNameValue ( const char * buffer , int bufsize , struct NameValueParserData * data ) { struct xmlparser parser ; data -> l_head = NULL ; data -> portListing = NULL ; data -> portListingLength = 0 ; parser . xmlstart = buffer ; parser . xmlsize = bufsize ; parser . data = data ; parser . starteltfunc = NameValueParserStartElt ; parser . endeltfunc = NameValueParserEndElt ; parser . datafunc = NameValueParserGetData ; parser . attfunc = 0 ; parsexml ( & parser ) ; } "," xmlparser parser ; memset ( data , 0 , sizeof ( struct NameValueParserData ) ) ; parser . ",miniupnp@miniupnp/7aeb624b44f86d335841242ff427433190e7168a,CVE-2017-1000494,https://github.com/miniupnp/miniupnp/commit/7aeb624b44f86d335841242ff427433190e7168a,2018-01-03T14:29Z 1096,CWE-119,"CWE-119 int mp4client_main ( int argc , char * * argv ) { char c ; const char * str ; int ret_val = 0 ; u32 i , times [ 100 ] , nb_times , dump_mode ; u32 simulation_time_in_ms = 0 ; u32 initial_service_id = 0 ; Bool auto_exit = GF_FALSE ; Bool logs_set = GF_FALSE ; Bool start_fs = GF_FALSE ; Bool use_rtix = GF_FALSE ; Bool pause_at_first = GF_FALSE ; Bool no_cfg_save = GF_FALSE ; Bool is_cfg_only = GF_FALSE ; Double play_from = 0 ; # ifdef GPAC_MEMORY_TRACKING GF_MemTrackerType mem_track = GF_MemTrackerNone ; # endif Double fps = GF_IMPORT_DEFAULT_FPS ; Bool fill_ar , visible , do_uncache , has_command ; char * url_arg , * out_arg , * the_cfg , * rti_file , * views , * mosaic ; FILE * logfile = NULL ; Float scale = 1 ; # ifndef WIN32 dlopen ( NULL , RTLD_NOW | RTLD_GLOBAL ) ; # endif strcpy ( the_url , ""."" ) ; memset ( & user , 0 , sizeof ( GF_User ) ) ; dump_mode = DUMP_NONE ; fill_ar = visible = do_uncache = has_command = GF_FALSE ; url_arg = out_arg = the_cfg = rti_file = views = mosaic = NULL ; nb_times = 0 ; times [ 0 ] = 0 ; for ( i = 1 ; i < ( u32 ) argc ; i ++ ) { char * arg = argv [ i ] ; if ( ! strcmp ( arg , ""-c"" ) || ! strcmp ( arg , ""-cfg"" ) ) { the_cfg = argv [ i + 1 ] ; i ++ ; } else if ( ! strcmp ( arg , ""-mem-track"" ) || ! strcmp ( arg , ""-mem-track-stack"" ) ) { # ifdef GPAC_MEMORY_TRACKING mem_track = ! strcmp ( arg , ""-mem-track-stack"" ) ? GF_MemTrackerBackTrace : GF_MemTrackerSimple ; # else fprintf ( stderr , ""WARNING-GPACnotcompiledwithMemoryTracker-ignoring\\""%s\\""\\n"" , arg ) ; # endif } else if ( ! strcmp ( arg , ""-gui"" ) ) { gui_mode = 1 ; } else if ( ! strcmp ( arg , ""-guid"" ) ) { gui_mode = 2 ; } else if ( ! strcmp ( arg , ""-h"" ) || ! strcmp ( arg , ""-help"" ) ) { PrintUsage ( ) ; return 0 ; } } # ifdef GPAC_MEMORY_TRACKING gf_sys_init ( mem_track ) ; # else gf_sys_init ( GF_MemTrackerNone ) ; # endif gf_sys_set_args ( argc , ( const char * * ) argv ) ; cfg_file = gf_cfg_init ( the_cfg , NULL ) ; if ( ! cfg_file ) { fprintf ( stderr , ""Error:ConfigurationFilenotfound\\n"" ) ; return 1 ; } if ( gf_log_set_tools_levels ( gf_cfg_get_key ( cfg_file , ""General"" , ""Logs"" ) ) != GF_OK ) { return 1 ; } if ( gf_cfg_get_key ( cfg_file , ""General"" , ""Logs"" ) != NULL ) { logs_set = GF_TRUE ; } if ( ! gui_mode ) { str = gf_cfg_get_key ( cfg_file , ""General"" , ""ForceGUI"" ) ; if ( str && ! strcmp ( str , ""yes"" ) ) gui_mode = 1 ; } for ( i = 1 ; i < ( u32 ) argc ; i ++ ) { char * arg = argv [ i ] ; if ( ! strcmp ( arg , ""-rti"" ) ) { rti_file = argv [ i + 1 ] ; i ++ ; } else if ( ! strcmp ( arg , ""-rtix"" ) ) { rti_file = argv [ i + 1 ] ; i ++ ; use_rtix = GF_TRUE ; } else if ( ! stricmp ( arg , ""-size"" ) ) { if ( sscanf ( argv [ i + 1 ] , ""%dx%d"" , & forced_width , & forced_height ) != 2 ) { forced_width = forced_height = 0 ; } i ++ ; } else if ( ! strcmp ( arg , ""-quiet"" ) ) { be_quiet = 1 ; } else if ( ! strcmp ( arg , ""-strict-error"" ) ) { gf_log_set_strict_error ( 1 ) ; } else if ( ! strcmp ( arg , ""-log-file"" ) || ! strcmp ( arg , ""-lf"" ) ) { logfile = gf_fopen ( argv [ i + 1 ] , ""wt"" ) ; gf_log_set_callback ( logfile , on_gpac_log ) ; i ++ ; } else if ( ! strcmp ( arg , ""-logs"" ) ) { if ( gf_log_set_tools_levels ( argv [ i + 1 ] ) != GF_OK ) { return 1 ; } logs_set = GF_TRUE ; i ++ ; } else if ( ! strcmp ( arg , ""-log-clock"" ) || ! strcmp ( arg , ""-lc"" ) ) { log_time_start = 1 ; } else if ( ! strcmp ( arg , ""-log-utc"" ) || ! strcmp ( arg , ""-lu"" ) ) { log_utc_time = 1 ; } # if defined ( __DARWIN__ ) || defined ( __APPLE__ ) else if ( ! strcmp ( arg , ""-thread"" ) ) threading_flags = 0 ; # else else if ( ! strcmp ( arg , ""-no-thread"" ) ) threading_flags = GF_TERM_NO_DECODER_THREAD | GF_TERM_NO_COMPOSITOR_THREAD | GF_TERM_WINDOW_NO_THREAD ; # endif else if ( ! strcmp ( arg , ""-no-cthread"" ) || ! strcmp ( arg , ""-no-compositor-thread"" ) ) threading_flags |= GF_TERM_NO_COMPOSITOR_THREAD ; else if ( ! strcmp ( arg , ""-no-audio"" ) ) no_audio = 1 ; else if ( ! strcmp ( arg , ""-no-regulation"" ) ) no_regulation = 1 ; else if ( ! strcmp ( arg , ""-fs"" ) ) start_fs = 1 ; else if ( ! strcmp ( arg , ""-opt"" ) ) { set_cfg_option ( argv [ i + 1 ] ) ; i ++ ; } else if ( ! strcmp ( arg , ""-conf"" ) ) { set_cfg_option ( argv [ i + 1 ] ) ; is_cfg_only = GF_TRUE ; i ++ ; } else if ( ! strcmp ( arg , ""-ifce"" ) ) { gf_cfg_set_key ( cfg_file , ""Network"" , ""DefaultMCastInterface"" , argv [ i + 1 ] ) ; i ++ ; } else if ( ! stricmp ( arg , ""-help"" ) ) { PrintUsage ( ) ; return 1 ; } else if ( ! stricmp ( arg , ""-noprog"" ) ) { no_prog = 1 ; gf_set_progress_callback ( NULL , progress_quiet ) ; } else if ( ! stricmp ( arg , ""-no-save"" ) || ! stricmp ( arg , ""--no-save"" ) ) { no_cfg_save = 1 ; } else if ( ! stricmp ( arg , ""-ntp-shift"" ) ) { s32 shift = atoi ( argv [ i + 1 ] ) ; i ++ ; gf_net_set_ntp_shift ( shift ) ; } else if ( ! stricmp ( arg , ""-run-for"" ) ) { simulation_time_in_ms = atoi ( argv [ i + 1 ] ) * 1000 ; if ( ! simulation_time_in_ms ) simulation_time_in_ms = 1 ; i ++ ; } else if ( ! strcmp ( arg , ""-out"" ) ) { out_arg = argv [ i + 1 ] ; i ++ ; } else if ( ! stricmp ( arg , ""-fps"" ) ) { fps = atof ( argv [ i + 1 ] ) ; i ++ ; } else if ( ! strcmp ( arg , ""-avi"" ) || ! strcmp ( arg , ""-sha"" ) ) { dump_mode &= 0xFFFF0000 ; if ( ! strcmp ( arg , ""-sha"" ) ) dump_mode |= DUMP_SHA1 ; else dump_mode |= DUMP_AVI ; if ( ( url_arg || ( i + 2 < ( u32 ) argc ) ) && get_time_list ( argv [ i + 1 ] , times , & nb_times ) ) { if ( ! strcmp ( arg , ""-avi"" ) && ( nb_times != 2 ) ) { fprintf ( stderr , ""Onlyonetimeargfoundfor-avi-checkusage\\n"" ) ; return 1 ; } i ++ ; } } else if ( ! strcmp ( arg , ""-rgbds"" ) ) { dump_mode |= DUMP_RGB_DEPTH_SHAPE ; } else if ( ! strcmp ( arg , ""-rgbd"" ) ) { dump_mode |= DUMP_RGB_DEPTH ; } else if ( ! strcmp ( arg , ""-depth"" ) ) { dump_mode |= DUMP_DEPTH_ONLY ; } else if ( ! strcmp ( arg , ""-bmp"" ) ) { dump_mode &= 0xFFFF0000 ; dump_mode |= DUMP_BMP ; if ( ( url_arg || ( i + 2 < ( u32 ) argc ) ) && get_time_list ( argv [ i + 1 ] , times , & nb_times ) ) i ++ ; } else if ( ! strcmp ( arg , ""-png"" ) ) { dump_mode &= 0xFFFF0000 ; dump_mode |= DUMP_PNG ; if ( ( url_arg || ( i + 2 < ( u32 ) argc ) ) && get_time_list ( argv [ i + 1 ] , times , & nb_times ) ) i ++ ; } else if ( ! strcmp ( arg , ""-raw"" ) ) { dump_mode &= 0xFFFF0000 ; dump_mode |= DUMP_RAW ; if ( ( url_arg || ( i + 2 < ( u32 ) argc ) ) && get_time_list ( argv [ i + 1 ] , times , & nb_times ) ) i ++ ; } else if ( ! stricmp ( arg , ""-scale"" ) ) { sscanf ( argv [ i + 1 ] , ""%f"" , & scale ) ; i ++ ; } else if ( ! strcmp ( arg , ""-c"" ) || ! strcmp ( arg , ""-cfg"" ) ) { i ++ ; } if ( ! gui_mode ) { if ( arg [ 0 ] != '-' ) { if ( url_arg ) { fprintf ( stderr , ""SeveralinputURLsprovided(\\""%s\\"",\\""%s\\"").Checkyourcommand-line.\\n"" , url_arg , arg ) ; return 1 ; } url_arg = arg ; } else if ( ! strcmp ( arg , ""-loop"" ) ) loop_at_end = 1 ; else if ( ! strcmp ( arg , ""-bench"" ) ) bench_mode = 1 ; else if ( ! strcmp ( arg , ""-vbench"" ) ) bench_mode = 2 ; else if ( ! strcmp ( arg , ""-sbench"" ) ) bench_mode = 3 ; else if ( ! strcmp ( arg , ""-no-addon"" ) ) enable_add_ons = GF_FALSE ; else if ( ! strcmp ( arg , ""-pause"" ) ) pause_at_first = 1 ; else if ( ! strcmp ( arg , ""-play-from"" ) ) { play_from = atof ( ( const char * ) argv [ i + 1 ] ) ; i ++ ; } else if ( ! strcmp ( arg , ""-speed"" ) ) { playback_speed = FLT2FIX ( atof ( ( const char * ) argv [ i + 1 ] ) ) ; if ( playback_speed <= 0 ) playback_speed = FIX_ONE ; i ++ ; } else if ( ! strcmp ( arg , ""-no-wnd"" ) ) user . init_flags |= GF_TERM_WINDOWLESS ; else if ( ! strcmp ( arg , ""-no-back"" ) ) user . init_flags |= GF_TERM_WINDOW_TRANSPARENT ; else if ( ! strcmp ( arg , ""-align"" ) ) { if ( argv [ i + 1 ] [ 0 ] == 'm' ) align_mode = 1 ; else if ( argv [ i + 1 ] [ 0 ] == 'b' ) align_mode = 2 ; align_mode <<= 8 ; if ( argv [ i + 1 ] [ 1 ] == 'm' ) align_mode |= 1 ; else if ( argv [ i + 1 ] [ 1 ] == 'r' ) align_mode |= 2 ; i ++ ; } else if ( ! strcmp ( arg , ""-fill"" ) ) { fill_ar = GF_TRUE ; } else if ( ! strcmp ( arg , ""-show"" ) ) { visible = 1 ; } else if ( ! strcmp ( arg , ""-uncache"" ) ) { do_uncache = GF_TRUE ; } else if ( ! strcmp ( arg , ""-exit"" ) ) auto_exit = GF_TRUE ; else if ( ! stricmp ( arg , ""-views"" ) ) { views = argv [ i + 1 ] ; i ++ ; } else if ( ! stricmp ( arg , ""-mosaic"" ) ) { mosaic = argv [ i + 1 ] ; i ++ ; } else if ( ! stricmp ( arg , ""-com"" ) ) { has_command = GF_TRUE ; i ++ ; } else if ( ! stricmp ( arg , ""-service"" ) ) { initial_service_id = atoi ( argv [ i + 1 ] ) ; i ++ ; } } } if ( is_cfg_only ) { gf_cfg_del ( cfg_file ) ; fprintf ( stderr , ""GPACConfigupdated\\n"" ) ; return 0 ; } if ( do_uncache ) { const char * cache_dir = gf_cfg_get_key ( cfg_file , ""General"" , ""CacheDirectory"" ) ; do_flatten_cache ( cache_dir ) ; fprintf ( stderr , ""GPACCachedir%sflattened\\n"" , cache_dir ) ; gf_cfg_del ( cfg_file ) ; return 0 ; } if ( dump_mode && ! url_arg ) { FILE * test ; url_arg = ( char * ) gf_cfg_get_key ( cfg_file , ""General"" , ""StartupFile"" ) ; test = url_arg ? gf_fopen ( url_arg , ""rt"" ) : NULL ; if ( ! test ) url_arg = NULL ; else gf_fclose ( test ) ; if ( ! url_arg ) { fprintf ( stderr , ""Missingargumentfordump\\n"" ) ; PrintUsage ( ) ; if ( logfile ) gf_fclose ( logfile ) ; return 1 ; } } if ( ! gui_mode && ! url_arg && ( gf_cfg_get_key ( cfg_file , ""General"" , ""StartupFile"" ) != NULL ) ) { gui_mode = 1 ; } # ifdef WIN32 if ( gui_mode == 1 ) { const char * opt ; TCHAR buffer [ 1024 ] ; DWORD res = GetCurrentDirectory ( 1024 , buffer ) ; buffer [ res ] = 0 ; opt = gf_cfg_get_key ( cfg_file , ""General"" , ""ModulesDirectory"" ) ; if ( strstr ( opt , buffer ) ) { gui_mode = 1 ; } else { gui_mode = 2 ; } } # endif if ( gui_mode == 1 ) { hide_shell ( 1 ) ; } if ( gui_mode ) { no_prog = 1 ; gf_set_progress_callback ( NULL , progress_quiet ) ; } if ( ! url_arg && simulation_time_in_ms ) simulation_time_in_ms += gf_sys_clock ( ) ; # if defined ( __DARWIN__ ) || defined ( __APPLE__ ) carbon_init ( ) ; # endif if ( dump_mode ) rti_file = NULL ; if ( ! logs_set ) { gf_log_set_tool_level ( GF_LOG_ALL , GF_LOG_WARNING ) ; } if ( rti_file || logfile || log_utc_time || log_time_start ) gf_log_set_callback ( NULL , on_gpac_log ) ; if ( rti_file ) init_rti_logs ( rti_file , url_arg , use_rtix ) ; { GF_SystemRTInfo rti ; if ( gf_sys_get_rti ( 0 , & rti , 0 ) ) fprintf ( stderr , ""Systeminfo:%dMBRAM-%dcores\\n"" , ( u32 ) ( rti . physical_memory / 1024 / 1024 ) , rti . nb_cores ) ; } if ( dump_mode ) { user . init_flags |= GF_TERM_NO_DECODER_THREAD | GF_TERM_NO_COMPOSITOR_THREAD | GF_TERM_NO_REGULATION ; if ( ! visible ) user . init_flags |= GF_TERM_INIT_HIDE ; gf_cfg_set_key ( cfg_file , ""Audio"" , ""DriverName"" , ""RawAudioOutput"" ) ; no_cfg_save = GF_TRUE ; } else { init_w = forced_width ; init_h = forced_height ; } user . modules = gf_modules_new ( NULL , cfg_file ) ; if ( user . modules ) i = gf_modules_get_count ( user . modules ) ; if ( ! i || ! user . modules ) { fprintf ( stderr , ""Error:nomodulesfound-exiting\\n"" ) ; if ( user . modules ) gf_modules_del ( user . modules ) ; gf_cfg_del ( cfg_file ) ; gf_sys_close ( ) ; if ( logfile ) gf_fclose ( logfile ) ; return 1 ; } fprintf ( stderr , ""ModulesFound:%d\\n"" , i ) ; str = gf_cfg_get_key ( cfg_file , ""General"" , ""GPACVersion"" ) ; if ( ! str || strcmp ( str , GPAC_FULL_VERSION ) ) { gf_cfg_del_section ( cfg_file , ""PluginsCache"" ) ; gf_cfg_set_key ( cfg_file , ""General"" , ""GPACVersion"" , GPAC_FULL_VERSION ) ; } user . config = cfg_file ; user . EventProc = GPAC_EventProc ; user . opaque = user . modules ; if ( threading_flags ) user . init_flags |= threading_flags ; if ( no_audio ) user . init_flags |= GF_TERM_NO_AUDIO ; if ( no_regulation ) user . init_flags |= GF_TERM_NO_REGULATION ; if ( threading_flags & ( GF_TERM_NO_DECODER_THREAD | GF_TERM_NO_COMPOSITOR_THREAD ) ) term_step = GF_TRUE ; if ( dump_mode ) user . init_flags |= GF_TERM_USE_AUDIO_HW_CLOCK ; if ( bench_mode ) { gf_cfg_discard_changes ( user . config ) ; auto_exit = GF_TRUE ; gf_cfg_set_key ( user . config , ""Audio"" , ""DriverName"" , ""RawAudioOutput"" ) ; if ( bench_mode != 2 ) { gf_cfg_set_key ( user . config , ""Video"" , ""DriverName"" , ""RawVideoOutput"" ) ; gf_cfg_set_key ( user . config , ""RAWVideo"" , ""RawOutput"" , ""null"" ) ; gf_cfg_set_key ( user . config , ""Compositor"" , ""OpenGLMode"" , ""disable"" ) ; } else { gf_cfg_set_key ( user . config , ""Video"" , ""DisableVSync"" , ""yes"" ) ; } } { char dim [ 50 ] ; sprintf ( dim , ""%d"" , forced_width ) ; gf_cfg_set_key ( user . config , ""Compositor"" , ""DefaultWidth"" , forced_width ? dim : NULL ) ; sprintf ( dim , ""%d"" , forced_height ) ; gf_cfg_set_key ( user . config , ""Compositor"" , ""DefaultHeight"" , forced_height ? dim : NULL ) ; } fprintf ( stderr , ""LoadingGPACTerminal\\n"" ) ; i = gf_sys_clock ( ) ; term = gf_term_new ( & user ) ; if ( ! term ) { fprintf ( stderr , ""\\nIniterror-checkyouhaveatleastonevideooutandonerasterizer...\\nFoundmodules:\\n"" ) ; list_modules ( user . modules ) ; gf_modules_del ( user . modules ) ; gf_cfg_discard_changes ( cfg_file ) ; gf_cfg_del ( cfg_file ) ; gf_sys_close ( ) ; if ( logfile ) gf_fclose ( logfile ) ; return 1 ; } fprintf ( stderr , ""TerminalLoadedin%dms\\n"" , gf_sys_clock ( ) - i ) ; if ( bench_mode ) { display_rti = 2 ; gf_term_set_option ( term , GF_OPT_VIDEO_BENCH , ( bench_mode == 3 ) ? 2 : 1 ) ; if ( bench_mode == 1 ) bench_mode = 2 ; } if ( dump_mode ) { if ( fill_ar ) gf_term_set_option ( term , GF_OPT_ASPECT_RATIO , GF_ASPECT_RATIO_FILL_SCREEN ) ; } else { str = gf_cfg_get_key ( cfg_file , ""Video"" , ""DriverName"" ) ; if ( ! bench_mode && ! strcmp ( str , ""RawVideoOutput"" ) ) fprintf ( stderr , ""WARNING:usingrawoutputvideo(memoryonly)-nodisplayused\\n"" ) ; str = gf_cfg_get_key ( cfg_file , ""Audio"" , ""DriverName"" ) ; if ( ! str || ! strcmp ( str , ""NoAudioOutputAvailable"" ) ) fprintf ( stderr , ""WARNING:noaudiooutputavailable-makesurenootherprogramislockingthesoundcard\\n"" ) ; str = gf_cfg_get_key ( cfg_file , ""General"" , ""NoMIMETypeFetch"" ) ; no_mime_check = ( str && ! stricmp ( str , ""yes"" ) ) ? 1 : 0 ; } str = gf_cfg_get_key ( cfg_file , ""HTTPProxy"" , ""Enabled"" ) ; if ( str && ! strcmp ( str , ""yes"" ) ) { str = gf_cfg_get_key ( cfg_file , ""HTTPProxy"" , ""Name"" ) ; if ( str ) fprintf ( stderr , ""HTTPProxy%senabled\\n"" , str ) ; } if ( rti_file ) { str = gf_cfg_get_key ( cfg_file , ""General"" , ""RTIRefreshPeriod"" ) ; if ( str ) { rti_update_time_ms = atoi ( str ) ; } else { gf_cfg_set_key ( cfg_file , ""General"" , ""RTIRefreshPeriod"" , ""200"" ) ; } UpdateRTInfo ( ""AtGPACloadtime\\n"" ) ; } Run = 1 ; if ( dump_mode ) { if ( ! nb_times ) { times [ 0 ] = 0 ; nb_times ++ ; } ret_val = dump_file ( url_arg , out_arg , dump_mode , fps , forced_width , forced_height , scale , times , nb_times ) ; Run = 0 ; } else if ( views ) { } else if ( ! gui_mode && url_arg ) { char * ext ; strcpy ( the_url , url_arg ) ; ext = strrchr ( the_url , '.' ) ; if ( ext && ( ! stricmp ( ext , "".m3u"" ) || ! stricmp ( ext , "".pls"" ) ) ) { GF_Err e = GF_OK ; fprintf ( stderr , ""OpeningPlaylist%s\\n"" , the_url ) ; strcpy ( pl_path , the_url ) ; if ( ! strncmp ( ""http:"" , the_url , 5 ) ) { GF_DownloadSession * sess = gf_dm_sess_new ( term -> downloader , the_url , GF_NETIO_SESSION_NOT_THREADED , NULL , NULL , & e ) ; if ( sess ) { e = gf_dm_sess_process ( sess ) ; if ( ! e ) strcpy ( the_url , gf_dm_sess_get_cache_name ( sess ) ) ; gf_dm_sess_del ( sess ) ; } } playlist = e ? NULL : gf_fopen ( the_url , ""rt"" ) ; readonly_playlist = 1 ; if ( playlist ) { request_next_playlist_item = GF_TRUE ; } else { if ( e ) fprintf ( stderr , ""Failedtoopenplaylist%s:%s\\n"" , the_url , gf_error_to_string ( e ) ) ; fprintf ( stderr , ""Hit\'h\'forhelp\\n\\n"" ) ; } } else { fprintf ( stderr , ""OpeningURL%s\\n"" , the_url ) ; if ( pause_at_first ) fprintf ( stderr , ""[Status:Paused]\\n"" ) ; gf_term_connect_from_time ( term , the_url , ( u64 ) ( play_from * 1000 ) , pause_at_first ) ; } } else { fprintf ( stderr , ""Hit\'h\'forhelp\\n\\n"" ) ; str = gf_cfg_get_key ( cfg_file , ""General"" , ""StartupFile"" ) ; if ( str ) { strcpy ( the_url , ""MP4Client"" GPAC_FULL_VERSION ) ; gf_term_connect ( term , str ) ; startup_file = 1 ; is_connected = 1 ; } } if ( gui_mode == 2 ) gui_mode = 0 ; if ( start_fs ) gf_term_set_option ( term , GF_OPT_FULLSCREEN , 1 ) ; if ( views ) { char szTemp [ 4046 ] ; sprintf ( szTemp , ""views://%s"" , views ) ; gf_term_connect ( term , szTemp ) ; } if ( mosaic ) { char szTemp [ 4046 ] ; sprintf ( szTemp , ""mosaic://%s"" , mosaic ) ; gf_term_connect ( term , szTemp ) ; } if ( bench_mode ) { rti_update_time_ms = 500 ; bench_mode_start = gf_sys_clock ( ) ; } while ( Run ) { if ( ( gui_mode == 1 ) || ! gf_prompt_has_input ( ) ) { if ( reload ) { reload = 0 ; gf_term_disconnect ( term ) ; gf_term_connect ( term , startup_file ? gf_cfg_get_key ( cfg_file , ""General"" , ""StartupFile"" ) : the_url ) ; } if ( restart && gf_term_get_option ( term , GF_OPT_IS_OVER ) ) { restart = 0 ; gf_term_play_from_time ( term , 0 , 0 ) ; } if ( request_next_playlist_item ) { c = '\\n' ; request_next_playlist_item = 0 ; goto force_input ; } if ( has_command && is_connected ) { has_command = GF_FALSE ; for ( i = 0 ; i < ( u32 ) argc ; i ++ ) { if ( ! strcmp ( argv [ i ] , ""-com"" ) ) { gf_term_scene_update ( term , NULL , argv [ i + 1 ] ) ; i ++ ; } } } if ( initial_service_id && is_connected ) { GF_ObjectManager * root_od = gf_term_get_root_object ( term ) ; if ( root_od ) { gf_term_select_service ( term , root_od , initial_service_id ) ; initial_service_id = 0 ; } } if ( ! use_rtix || display_rti ) UpdateRTInfo ( NULL ) ; if ( term_step ) { gf_term_process_step ( term ) ; } else { gf_sleep ( rti_update_time_ms ) ; } if ( auto_exit && eos_seen && gf_term_get_option ( term , GF_OPT_IS_OVER ) ) { Run = GF_FALSE ; } if ( simulation_time_in_ms && ( ( gf_term_get_elapsed_time_in_ms ( term ) > simulation_time_in_ms ) || ( ! url_arg && gf_sys_clock ( ) > simulation_time_in_ms ) ) ) { Run = GF_FALSE ; } continue ; } c = gf_prompt_get_char ( ) ; force_input : switch ( c ) { case 'q' : { GF_Event evt ; memset ( & evt , 0 , sizeof ( GF_Event ) ) ; evt . type = GF_EVENT_QUIT ; gf_term_send_event ( term , & evt ) ; } break ; case 'X' : exit ( 0 ) ; break ; case 'Q' : break ; case 'o' : startup_file = 0 ; gf_term_disconnect ( term ) ; fprintf ( stderr , ""EntertheabsoluteURL\\n"" ) ; if ( 1 > scanf ( ""%s"" , the_url ) ) { fprintf ( stderr , ""CannotreadabsoluteURL,aborting\\n"" ) ; break ; } if ( rti_file ) init_rti_logs ( rti_file , the_url , use_rtix ) ; gf_term_connect ( term , the_url ) ; break ; case 'O' : gf_term_disconnect ( term ) ; fprintf ( stderr , ""EntertheabsoluteURLtotheplaylist\\n"" ) ; if ( 1 > scanf ( ""%s"" , the_url ) ) { fprintf ( stderr , ""CannotreadtheabsoluteURL,aborting.\\n"" ) ; break ; } playlist = gf_fopen ( the_url , ""rt"" ) ; if ( playlist ) { if ( 1 > fscanf ( playlist , ""%s"" , the_url ) ) { fprintf ( stderr , ""CannotreadanyURLfromplaylist,aborting.\\n"" ) ; gf_fclose ( playlist ) ; break ; } fprintf ( stderr , ""OpeningURL%s\\n"" , the_url ) ; gf_term_connect ( term , the_url ) ; } break ; case '\\n' : case 'N' : if ( playlist ) { int res ; gf_term_disconnect ( term ) ; res = fscanf ( playlist , ""%s"" , the_url ) ; if ( ( res == EOF ) && loop_at_end ) { fseek ( playlist , 0 , SEEK_SET ) ; res = fscanf ( playlist , ""%s"" , the_url ) ; } if ( res == EOF ) { fprintf ( stderr , ""Nomoreitems-exiting\\n"" ) ; Run = 0 ; } else if ( the_url [ 0 ] == '#' ) { request_next_playlist_item = GF_TRUE ; } else { fprintf ( stderr , ""OpeningURL%s\\n"" , the_url ) ; gf_term_connect_with_path ( term , the_url , pl_path ) ; } } break ; case 'P' : if ( playlist ) { u32 count ; gf_term_disconnect ( term ) ; if ( 1 > scanf ( ""%u"" , & count ) ) { fprintf ( stderr , ""Cannotreadnumber,aborting.\\n"" ) ; break ; } while ( count ) { if ( fscanf ( playlist , ""%s"" , the_url ) ) { fprintf ( stderr , ""Failedtoreadline,aborting\\n"" ) ; break ; } count -- ; } fprintf ( stderr , ""OpeningURL%s\\n"" , the_url ) ; gf_term_connect ( term , the_url ) ; } break ; case 'r' : if ( is_connected ) reload = 1 ; break ; case 'D' : if ( is_connected ) gf_term_disconnect ( term ) ; break ; case 'p' : if ( is_connected ) { Bool is_pause = gf_term_get_option ( term , GF_OPT_PLAY_STATE ) ; fprintf ( stderr , ""[Status:%s]\\n"" , is_pause ? ""Playing"" : ""Paused"" ) ; gf_term_set_option ( term , GF_OPT_PLAY_STATE , is_pause ? GF_STATE_PLAYING : GF_STATE_PAUSED ) ; } break ; case 's' : if ( is_connected ) { gf_term_set_option ( term , GF_OPT_PLAY_STATE , GF_STATE_STEP_PAUSE ) ; fprintf ( stderr , ""Steptime:"" ) ; PrintTime ( gf_term_get_time_in_ms ( term ) ) ; fprintf ( stderr , ""\\n"" ) ; } break ; case 'z' : case 'T' : if ( ! CanSeek || ( Duration <= 2000 ) ) { fprintf ( stderr , ""scenenotseekable\\n"" ) ; } else { Double res ; s32 seekTo ; fprintf ( stderr , ""Duration:"" ) ; PrintTime ( Duration ) ; res = gf_term_get_time_in_ms ( term ) ; if ( c == 'z' ) { res *= 100 ; res /= ( s64 ) Duration ; fprintf ( stderr , ""(current%.2f%%)\\nEnterSeekpercentage:\\n"" , res ) ; if ( scanf ( ""%d"" , & seekTo ) == 1 ) { if ( seekTo > 100 ) seekTo = 100 ; res = ( Double ) ( s64 ) Duration ; res /= 100 ; res *= seekTo ; gf_term_play_from_time ( term , ( u64 ) ( s64 ) res , 0 ) ; } } else { u32 r , h , m , s ; fprintf ( stderr , ""-CurrentTime:"" ) ; PrintTime ( ( u64 ) res ) ; fprintf ( stderr , ""\\nEnterseektime(Format:s,m:sorh:m:s):\\n"" ) ; h = m = s = 0 ; r = scanf ( ""%d:%d:%d"" , & h , & m , & s ) ; if ( r == 2 ) { s = m ; m = h ; h = 0 ; } else if ( r == 1 ) { s = h ; m = h = 0 ; } if ( r && ( r <= 3 ) ) { u64 time = h * 3600 + m * 60 + s ; gf_term_play_from_time ( term , time * 1000 , 0 ) ; } } } break ; case 't' : { if ( is_connected ) { fprintf ( stderr , ""CurrentTime:"" ) ; PrintTime ( gf_term_get_time_in_ms ( term ) ) ; fprintf ( stderr , ""-Duration:"" ) ; PrintTime ( Duration ) ; fprintf ( stderr , ""\\n"" ) ; } } break ; case 'w' : if ( is_connected ) PrintWorldInfo ( term ) ; break ; case 'v' : if ( is_connected ) PrintODList ( term , NULL , 0 , 0 , ""Root"" ) ; break ; case 'i' : if ( is_connected ) { u32 ID ; fprintf ( stderr , ""EnterODID(0formainOD):"" ) ; fflush ( stderr ) ; if ( scanf ( ""%ud"" , & ID ) == 1 ) { ViewOD ( term , ID , ( u32 ) - 1 , NULL ) ; } else { char str_url [ GF_MAX_PATH ] ; if ( scanf ( ""%s"" , str_url ) == 1 ) ViewOD ( term , 0 , ( u32 ) - 1 , str_url ) ; } } break ; case 'j' : if ( is_connected ) { u32 num ; do { fprintf ( stderr , ""EnterODnumber(0formainOD):"" ) ; fflush ( stderr ) ; } while ( 1 > scanf ( ""%ud"" , & num ) ) ; ViewOD ( term , ( u32 ) - 1 , num , NULL ) ; } break ; case 'b' : if ( is_connected ) ViewODs ( term , 1 ) ; break ; case 'm' : if ( is_connected ) ViewODs ( term , 0 ) ; break ; case 'l' : list_modules ( user . modules ) ; break ; case 'n' : if ( is_connected ) set_navigation ( ) ; break ; case 'x' : if ( is_connected ) gf_term_set_option ( term , GF_OPT_NAVIGATION_TYPE , 0 ) ; break ; case 'd' : if ( is_connected ) { GF_ObjectManager * odm = NULL ; char radname [ GF_MAX_PATH ] , * sExt ; GF_Err e ; u32 i , count , odid ; Bool xml_dump , std_out ; radname [ 0 ] = 0 ; do { fprintf ( stderr , ""EnterInlineODIDifanyor0:"" ) ; fflush ( stderr ) ; } while ( 1 > scanf ( ""%ud"" , & odid ) ) ; if ( odid ) { GF_ObjectManager * root_odm = gf_term_get_root_object ( term ) ; if ( ! root_odm ) break ; count = gf_term_get_object_count ( term , root_odm ) ; for ( i = 0 ; i < count ; i ++ ) { GF_MediaInfo info ; odm = gf_term_get_object ( term , root_odm , i ) ; if ( gf_term_get_object_info ( term , odm , & info ) == GF_OK ) { if ( info . od -> objectDescriptorID == odid ) break ; } odm = NULL ; } } do { fprintf ( stderr , ""Enterfileradicalname(+\\\'.x\\\'forXMLdumping)-\\""std\\""forstderr:"" ) ; fflush ( stderr ) ; } while ( 1 > scanf ( ""%s"" , radname ) ) ; sExt = strrchr ( radname , '.' ) ; xml_dump = 0 ; if ( sExt ) { if ( ! stricmp ( sExt , "".x"" ) ) xml_dump = 1 ; sExt [ 0 ] = 0 ; } std_out = strnicmp ( radname , ""std"" , 3 ) ? 0 : 1 ; e = gf_term_dump_scene ( term , std_out ? NULL : radname , NULL , xml_dump , 0 , odm ) ; fprintf ( stderr , ""Dumpdone(%s)\\n"" , gf_error_to_string ( e ) ) ; } break ; case 'c' : PrintGPACConfig ( ) ; break ; case '3' : { Bool use_3d = ! gf_term_get_option ( term , GF_OPT_USE_OPENGL ) ; if ( gf_term_set_option ( term , GF_OPT_USE_OPENGL , use_3d ) == GF_OK ) { fprintf ( stderr , ""Using%sfor2Ddrawing\\n"" , use_3d ? ""OpenGL"" : ""2Drasterizer"" ) ; } } break ; case 'k' : { Bool opt = gf_term_get_option ( term , GF_OPT_STRESS_MODE ) ; opt = ! opt ; fprintf ( stderr , ""Turningstressmode%s\\n"" , opt ? ""on"" : ""off"" ) ; gf_term_set_option ( term , GF_OPT_STRESS_MODE , opt ) ; } break ; case '4' : gf_term_set_option ( term , GF_OPT_ASPECT_RATIO , GF_ASPECT_RATIO_4_3 ) ; break ; case '5' : gf_term_set_option ( term , GF_OPT_ASPECT_RATIO , GF_ASPECT_RATIO_16_9 ) ; break ; case '6' : gf_term_set_option ( term , GF_OPT_ASPECT_RATIO , GF_ASPECT_RATIO_FILL_SCREEN ) ; break ; case '7' : gf_term_set_option ( term , GF_OPT_ASPECT_RATIO , GF_ASPECT_RATIO_KEEP ) ; break ; case 'C' : switch ( gf_term_get_option ( term , GF_OPT_MEDIA_CACHE ) ) { case GF_MEDIA_CACHE_DISABLED : gf_term_set_option ( term , GF_OPT_MEDIA_CACHE , GF_MEDIA_CACHE_ENABLED ) ; break ; case GF_MEDIA_CACHE_ENABLED : gf_term_set_option ( term , GF_OPT_MEDIA_CACHE , GF_MEDIA_CACHE_DISABLED ) ; break ; case GF_MEDIA_CACHE_RUNNING : fprintf ( stderr , ""StreamingCacheisrunning-pleasestopitfirst\\n"" ) ; continue ; } switch ( gf_term_get_option ( term , GF_OPT_MEDIA_CACHE ) ) { case GF_MEDIA_CACHE_ENABLED : fprintf ( stderr , ""StreamingCacheEnabled\\n"" ) ; break ; case GF_MEDIA_CACHE_DISABLED : fprintf ( stderr , ""StreamingCacheDisabled\\n"" ) ; break ; case GF_MEDIA_CACHE_RUNNING : fprintf ( stderr , ""StreamingCacheRunning\\n"" ) ; break ; } break ; case 'S' : case 'A' : if ( gf_term_get_option ( term , GF_OPT_MEDIA_CACHE ) == GF_MEDIA_CACHE_RUNNING ) { gf_term_set_option ( term , GF_OPT_MEDIA_CACHE , ( c == 'S' ) ? GF_MEDIA_CACHE_DISABLED : GF_MEDIA_CACHE_DISCARD ) ; fprintf ( stderr , ""StreamingCachestopped\\n"" ) ; } else { fprintf ( stderr , ""StreamingCachenotrunning\\n"" ) ; } break ; case 'R' : display_rti = ! display_rti ; ResetCaption ( ) ; break ; case 'F' : if ( display_rti ) display_rti = 0 ; else display_rti = 2 ; ResetCaption ( ) ; break ; case 'u' : { GF_Err e ; char szCom [ 8192 ] ; fprintf ( stderr , ""Entercommandtosend:\\n"" ) ; fflush ( stdin ) ; szCom [ 0 ] = 0 ; if ( 1 > scanf ( ""%[^\\t\\n]"" , szCom ) ) { fprintf ( stderr , ""Cannotreadcommandtosend,aborting.\\n"" ) ; break ; } e = gf_term_scene_update ( term , NULL , szCom ) ; if ( e ) fprintf ( stderr , ""Processingcommandfailed:%s\\n"" , gf_error_to_string ( e ) ) ; } break ; case 'e' : { GF_Err e ; char jsCode [ 8192 ] ; fprintf ( stderr , ""EnterJavaScriptcodetoevaluate:\\n"" ) ; fflush ( stdin ) ; jsCode [ 0 ] = 0 ; if ( 1 > scanf ( ""%[^\\t\\n]"" , jsCode ) ) { fprintf ( stderr , ""Cannotreadcodetoevaluate,aborting.\\n"" ) ; break ; } e = gf_term_scene_update ( term , ""application/ecmascript"" , jsCode ) ; if ( e ) fprintf ( stderr , ""ProcessingJScodefailed:%s\\n"" , gf_error_to_string ( e ) ) ; } break ; case 'L' : { char szLog [ 1024 ] , * cur_logs ; cur_logs = gf_log_get_tools_levels ( ) ; fprintf ( stderr , ""Enternewloglevel(currenttools%s):\\n"" , cur_logs ) ; gf_free ( cur_logs ) ; if ( scanf ( ""%s"" , szLog ) < 1 ) { fprintf ( stderr , ""Cannotreadnewloglevel,aborting.\\n"" ) ; break ; } gf_log_modify_tools_levels ( szLog ) ; } break ; case 'g' : { GF_SystemRTInfo rti ; gf_sys_get_rti ( rti_update_time_ms , & rti , 0 ) ; fprintf ( stderr , ""GPACallocatedmemory"" LLD ""\\n"" , rti . gpac_memory ) ; } break ; case 'M' : { u32 size ; do { fprintf ( stderr , ""EnternewvideocachememoryinkBytes(current%ud):\\n"" , gf_term_get_option ( term , GF_OPT_VIDEO_CACHE_SIZE ) ) ; } while ( 1 > scanf ( ""%ud"" , & size ) ) ; gf_term_set_option ( term , GF_OPT_VIDEO_CACHE_SIZE , size ) ; } break ; case 'H' : { u32 http_bitrate = gf_term_get_option ( term , GF_OPT_HTTP_MAX_RATE ) ; do { fprintf ( stderr , ""Enternewhttpbitrateinbps(0fornone)-currentlimit:%d\\n"" , http_bitrate ) ; } while ( 1 > scanf ( ""%ud"" , & http_bitrate ) ) ; gf_term_set_option ( term , GF_OPT_HTTP_MAX_RATE , http_bitrate ) ; } break ; case 'E' : gf_term_set_option ( term , GF_OPT_RELOAD_CONFIG , 1 ) ; break ; case 'B' : switch_bench ( ! bench_mode ) ; break ; case 'Y' : { char szOpt [ 8192 ] ; fprintf ( stderr , ""Enteroptiontoset(Section:Name=Value):\\n"" ) ; fflush ( stdin ) ; szOpt [ 0 ] = 0 ; if ( 1 > scanf ( ""%[^\\t\\n]"" , szOpt ) ) { fprintf ( stderr , ""Cannotreadoption\\n"" ) ; break ; } set_cfg_option ( szOpt ) ; } break ; case 'Z' : { char szFileName [ 100 ] ; u32 nb_pass , nb_views , offscreen_view = 0 ; GF_VideoSurface fb ; GF_Err e ; nb_pass = 1 ; nb_views = gf_term_get_option ( term , GF_OPT_NUM_STEREO_VIEWS ) ; if ( nb_views > 1 ) { fprintf ( stderr , ""Auto-stereomodedetected-typenumberofviewtodump(0ismainoutput,1to%doffscreenview,%dforalloffscreen,%dforalloffscreenandmain)\\n"" , nb_views , nb_views + 1 , nb_views + 2 ) ; if ( scanf ( ""%d"" , & offscreen_view ) != 1 ) { offscreen_view = 0 ; } if ( offscreen_view == nb_views + 1 ) { offscreen_view = 1 ; nb_pass = nb_views ; } else if ( offscreen_view == nb_views + 2 ) { offscreen_view = 0 ; nb_pass = nb_views + 1 ; } } while ( nb_pass ) { nb_pass -- ; if ( offscreen_view ) { sprintf ( szFileName , ""view%d_dump.png"" , offscreen_view ) ; e = gf_term_get_offscreen_buffer ( term , & fb , offscreen_view - 1 , 0 ) ; } else { sprintf ( szFileName , ""gpac_video_dump_"" LLU "".png"" , gf_net_get_utc ( ) ) ; e = gf_term_get_screen_buffer ( term , & fb ) ; } offscreen_view ++ ; if ( e ) { fprintf ( stderr , ""Errordumpingscreenbuffer%s\\n"" , gf_error_to_string ( e ) ) ; nb_pass = 0 ; } else { # ifndef GPAC_DISABLE_AV_PARSERS u32 dst_size = fb . width * fb . height * 4 ; char * dst = ( char * ) gf_malloc ( sizeof ( char ) * dst_size ) ; e = gf_img_png_enc ( fb . video_buffer , fb . width , fb . height , fb . pitch_y , fb . pixel_format , dst , & dst_size ) ; if ( e ) { fprintf ( stderr , ""ErrorencodingPNG%s\\n"" , gf_error_to_string ( e ) ) ; nb_pass = 0 ; } else { FILE * png = gf_fopen ( szFileName , ""wb"" ) ; if ( ! png ) { fprintf ( stderr , ""Errorwritingfile%s\\n"" , szFileName ) ; nb_pass = 0 ; } else { gf_fwrite ( dst , dst_size , 1 , png ) ; gf_fclose ( png ) ; fprintf ( stderr , ""Dumpto%s\\n"" , szFileName ) ; } } if ( dst ) gf_free ( dst ) ; gf_term_release_screen_buffer ( term , & fb ) ; # endif } } fprintf ( stderr , ""Done:%s\\n"" , szFileName ) ; } break ; case 'G' : { GF_ObjectManager * root_od , * odm ; u32 index ; char szOpt [ 8192 ] ; fprintf ( stderr , ""Enter0-basedindexofobjecttoselectorserviceID:\\n"" ) ; fflush ( stdin ) ; szOpt [ 0 ] = 0 ; if ( 1 > scanf ( ""%[^\\t\\n]"" , szOpt ) ) { fprintf ( stderr , ""CannotreadODID\\n"" ) ; break ; } index = atoi ( szOpt ) ; odm = NULL ; root_od = gf_term_get_root_object ( term ) ; if ( root_od ) { if ( gf_term_find_service ( term , root_od , index ) ) { gf_term_select_service ( term , root_od , index ) ; } else { fprintf ( stderr , ""Cannotfindservice%d-tryingwithobjectindex\\n"" , index ) ; odm = gf_term_get_object ( term , root_od , index ) ; if ( odm ) { gf_term_select_object ( term , odm ) ; } else { fprintf ( stderr , ""Cannotfindobjectatindex%d\\n"" , index ) ; } } } } break ; case 'h' : PrintHelp ( ) ; break ; default : break ; } } if ( bench_mode ) { PrintAVInfo ( GF_TRUE ) ; } if ( simulation_time_in_ms ) { gf_log_set_strict_error ( 0 ) ; } i = gf_sys_clock ( ) ; gf_term_disconnect ( term ) ; if ( rti_file ) UpdateRTInfo ( ""Disconnected\\n"" ) ; fprintf ( stderr , ""Deletingterminal..."" ) ; if ( playlist ) gf_fclose ( playlist ) ; # if defined ( __DARWIN__ ) || defined ( __APPLE__ ) carbon_uninit ( ) ; # endif gf_term_del ( term ) ; fprintf ( stderr , ""done(in%dms)-ranfor%dms\\n"" , gf_sys_clock ( ) - i , gf_sys_clock ( ) ) ; fprintf ( stderr , ""GPACcleanup...\\n"" ) ; gf_modules_del ( user . modules ) ; if ( no_cfg_save ) gf_cfg_discard_changes ( cfg_file ) ; gf_cfg_del ( cfg_file ) ; gf_sys_close ( ) ; if ( rti_logs ) gf_fclose ( rti_logs ) ; if ( logfile ) gf_fclose ( logfile ) ; if ( gui_mode ) { hide_shell ( 2 ) ; } # ifdef GPAC_MEMORY_TRACKING if ( mem_track && ( gf_memory_size ( ) || gf_file_handles_count ( ) ) ) { gf_log_set_tool_level ( GF_LOG_MEMORY , GF_LOG_INFO ) ; gf_memory_print ( ) ; return 2 ; } # endif return ret_val ; } "," * ext ; if ( strlen ( url_arg ) >= sizeof ( the_url ) ) { fprintf ( stderr , ""Inputurl%sistoolong,truncatingto%dchars.\\n"" , url_arg , ( int ) ( sizeof ( the_url ) - 1 ) ) ; strncpy ( the_url , url_arg , sizeof ( the_url ) - 1 ) ; the_url [ sizeof ( the_url ) - 1 ] = 0 ; } else { url_arg ) ; } ! e ) { strncpy ( the_url , ( sess ) , sizeof ( the_url ) - 1 ) ; the_url [ sizeof ( the_cfg ) - 1 ] = 0 ; } gf_dm_sess_del ( sess str ) { strncpy ( the_url , , ""MP4Client"" GPAC_FULL_VERSION , sizeof ( the_url ) - 1 ) ; the_url [ sizeof ( the_url ) - 1 ] = 0 ; gf_term_connect ( ",gpac@gpac/35ab4475a7df9b2a4bcab235e379c0c3ec543658,CVE-2018-20762,https://github.com/gpac/gpac/commit/35ab4475a7df9b2a4bcab235e379c0c3ec543658,2019-02-06T23:29Z 1097,CWE-125,"CWE-125 static int add_attributes ( PyTypeObject * type , char * * attrs , int num_fields ) { int i , result ; _Py_IDENTIFIER ( _attributes ) ; PyObject * s , * l = PyTuple_New ( num_fields ) ; if ( ! l ) return 0 ; for ( i = 0 ; i < num_fields ; i ++ ) { s = PyUnicode_FromString ( attrs [ i ] ) ; if ( ! s ) { Py_DECREF ( l ) ; return 0 ; } PyTuple_SET_ITEM ( l , i , s ) ; } result = _PyObject_SetAttrId ( ( PyObject * ) type , & PyId__attributes , l ) >= 0 ; Py_DECREF ( l ) ; return result ; } "," i , result ; PyObject * ",python@typed_ast/156afcb26c198e162504a57caddfe0acd9ed7dce,CVE-2019-19275,https://github.com/python/typed_ast/commit/156afcb26c198e162504a57caddfe0acd9ed7dce,2019-11-26T15:15Z 1098,CWE-476,"CWE-476 struct key * request_key_and_link ( struct key_type * type , const char * description , const void * callout_info , size_t callout_len , void * aux , struct key * dest_keyring , unsigned long flags ) { struct keyring_search_context ctx = { . index_key . type = type , . index_key . description = description , . cred = current_cred ( ) , . match_data . cmp = type -> match , . match_data . raw_data = description , . match_data . lookup_type = KEYRING_SEARCH_LOOKUP_DIRECT , } ; struct key * key ; key_ref_t key_ref ; int ret ; kenter ( ""%s,%s,%p,%zu,%p,%p,%lx"" , ctx . index_key . type -> name , ctx . index_key . description , callout_info , callout_len , aux , dest_keyring , flags ) ; if ( type -> match_preparse ) { ret = type -> match_preparse ( & ctx . match_data ) ; if ( ret < 0 ) { key = ERR_PTR ( ret ) ; goto error ; } } key_ref = search_process_keyrings ( & ctx ) ; if ( ! IS_ERR ( key_ref ) ) { key = key_ref_to_ptr ( key_ref ) ; if ( dest_keyring ) { construct_get_dest_keyring ( & dest_keyring ) ; ret = key_link ( dest_keyring , key ) ; key_put ( dest_keyring ) ; if ( ret < 0 ) { key_put ( key ) ; key = ERR_PTR ( ret ) ; goto error_free ; } } } else if ( PTR_ERR ( key_ref ) != - EAGAIN ) { key = ERR_CAST ( key_ref ) ; } else { key = ERR_PTR ( - ENOKEY ) ; if ( ! callout_info ) goto error_free ; key = construct_key_and_link ( & ctx , callout_info , callout_len , aux , dest_keyring , flags ) ; } error_free : if ( type -> match_free ) type -> match_free ( & ctx . match_data ) ; error : kleave ( ""=%p"" , key ) ; return key ; } "," . cmp = key_default_cmp , . match_data ",torvalds@linux/c06cfb08b88dfbe13be44a69ae2fdc3a7c902d81,CVE-2017-2647,https://github.com/torvalds/linux/commit/c06cfb08b88dfbe13be44a69ae2fdc3a7c902d81,2017-03-31T04:59Z 1099,CWE-119,"CWE-119 static vpx_codec_err_t vp8e_init ( vpx_codec_ctx_t * ctx , vpx_codec_priv_enc_mr_cfg_t * mr_cfg ) { vpx_codec_err_t res = VPX_CODEC_OK ; struct vpx_codec_alg_priv * priv ; vpx_codec_enc_cfg_t * cfg ; unsigned int i ; struct VP8_COMP * optr ; vp8_rtcd ( ) ; if ( ! ctx -> priv ) { priv = calloc ( 1 , sizeof ( struct vpx_codec_alg_priv ) ) ; if ( ! priv ) { return VPX_CODEC_MEM_ERROR ; } ctx -> priv = & priv -> base ; ctx -> priv -> sz = sizeof ( * ctx -> priv ) ; ctx -> priv -> iface = ctx -> iface ; ctx -> priv -> alg_priv = priv ; ctx -> priv -> init_flags = ctx -> init_flags ; if ( ctx -> config . enc ) { ctx -> priv -> alg_priv -> cfg = * ctx -> config . enc ; ctx -> config . enc = & ctx -> priv -> alg_priv -> cfg ; } cfg = & ctx -> priv -> alg_priv -> cfg ; for ( i = 0 ; extracfg_map [ i ] . usage && extracfg_map [ i ] . usage != cfg -> g_usage ; i ++ ) ; priv -> vp8_cfg = extracfg_map [ i ] . cfg ; priv -> vp8_cfg . pkt_list = & priv -> pkt_list . head ; priv -> cx_data_sz = priv -> cfg . g_w * priv -> cfg . g_h * 3 / 2 * 2 ; if ( priv -> cx_data_sz < 32768 ) priv -> cx_data_sz = 32768 ; priv -> cx_data = malloc ( priv -> cx_data_sz ) ; if ( ! priv -> cx_data ) { return VPX_CODEC_MEM_ERROR ; } if ( mr_cfg ) ctx -> priv -> enc . total_encoders = mr_cfg -> mr_total_resolutions ; else ctx -> priv -> enc . total_encoders = 1 ; res = validate_config ( priv , & priv -> cfg , & priv -> vp8_cfg , 0 ) ; if ( ! res ) { set_vp8e_config ( & ctx -> priv -> alg_priv -> oxcf , ctx -> priv -> alg_priv -> cfg , ctx -> priv -> alg_priv -> vp8_cfg , mr_cfg ) ; optr = vp8_create_compressor ( & ctx -> priv -> alg_priv -> oxcf ) ; if ( ! optr ) res = VPX_CODEC_MEM_ERROR ; else ctx -> priv -> alg_priv -> cpi = optr ; } } return res ; } "," = VPX_CODEC_OK ; vp8_rtcd ( ) ; vpx_dsp_rtcd ( ) ; vpx_scale_rtcd ( ) ; if ( ! ctx -> priv ) { vpx_codec_alg_priv * priv = ( struct vpx_codec_alg_priv ( struct vpx_codec_alg_priv * ) vpx_calloc ( 1 , sizeof ( * priv -> priv = ( vpx_codec_priv_t * ) priv ; ctx enc ) { priv -> cfg = enc = & priv -> cfg ; } priv -> vp8_cfg -> vp8_cfg = default_extracfg ; priv -> set_vp8e_config ( & priv -> oxcf , -> oxcf , priv -> cfg , priv -> vp8_cfg , mr_cfg ) ; priv -> cpi = vp8_create_compressor ( vp8_create_compressor ( & priv -> oxcf ) if ( ! priv -> cpi ) res = = VPX_CODEC_MEM_ERROR ; } } return ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1100,CWE-476,"CWE-476 int xfs_attr_shortform_to_leaf ( struct xfs_da_args * args , struct xfs_buf * * leaf_bp ) { xfs_inode_t * dp ; xfs_attr_shortform_t * sf ; xfs_attr_sf_entry_t * sfe ; xfs_da_args_t nargs ; char * tmpbuffer ; int error , i , size ; xfs_dablk_t blkno ; struct xfs_buf * bp ; xfs_ifork_t * ifp ; trace_xfs_attr_sf_to_leaf ( args ) ; dp = args -> dp ; ifp = dp -> i_afp ; sf = ( xfs_attr_shortform_t * ) ifp -> if_u1 . if_data ; size = be16_to_cpu ( sf -> hdr . totsize ) ; tmpbuffer = kmem_alloc ( size , KM_SLEEP ) ; ASSERT ( tmpbuffer != NULL ) ; memcpy ( tmpbuffer , ifp -> if_u1 . if_data , size ) ; sf = ( xfs_attr_shortform_t * ) tmpbuffer ; xfs_idata_realloc ( dp , - size , XFS_ATTR_FORK ) ; xfs_bmap_local_to_extents_empty ( dp , XFS_ATTR_FORK ) ; bp = NULL ; error = xfs_da_grow_inode ( args , & blkno ) ; if ( error ) { if ( error == - EIO ) goto out ; xfs_idata_realloc ( dp , size , XFS_ATTR_FORK ) ; memcpy ( ifp -> if_u1 . if_data , tmpbuffer , size ) ; goto out ; } ASSERT ( blkno == 0 ) ; error = xfs_attr3_leaf_create ( args , blkno , & bp ) ; if ( error ) { error = xfs_da_shrink_inode ( args , 0 , bp ) ; bp = NULL ; if ( error ) goto out ; xfs_idata_realloc ( dp , size , XFS_ATTR_FORK ) ; memcpy ( ifp -> if_u1 . if_data , tmpbuffer , size ) ; goto out ; } memset ( ( char * ) & nargs , 0 , sizeof ( nargs ) ) ; nargs . dp = dp ; nargs . geo = args -> geo ; nargs . firstblock = args -> firstblock ; nargs . dfops = args -> dfops ; nargs . total = args -> total ; nargs . whichfork = XFS_ATTR_FORK ; nargs . trans = args -> trans ; nargs . op_flags = XFS_DA_OP_OKNOENT ; sfe = & sf -> list [ 0 ] ; for ( i = 0 ; i < sf -> hdr . count ; i ++ ) { nargs . name = sfe -> nameval ; nargs . namelen = sfe -> namelen ; nargs . value = & sfe -> nameval [ nargs . namelen ] ; nargs . valuelen = sfe -> valuelen ; nargs . hashval = xfs_da_hashname ( sfe -> nameval , sfe -> namelen ) ; nargs . flags = XFS_ATTR_NSP_ONDISK_TO_ARGS ( sfe -> flags ) ; error = xfs_attr3_leaf_lookup_int ( bp , & nargs ) ; ASSERT ( error == - ENOATTR ) ; error = xfs_attr3_leaf_add ( bp , & nargs ) ; ASSERT ( error != - ENOSPC ) ; if ( error ) goto out ; sfe = XFS_ATTR_SF_NEXTENTRY ( sfe ) ; } error = 0 ; * leaf_bp = bp ; out : kmem_free ( tmpbuffer ) ; return error ; } "," error ) { if ( bp && ( xfs_da_shrink_inode ( args , bp ) != 0 ) ) goto out ",torvalds@linux/bb3d48dcf86a97dc25fe9fc2c11938e19cb4399a,CVE-2018-13094,https://github.com/torvalds/linux/commit/bb3d48dcf86a97dc25fe9fc2c11938e19cb4399a,2018-07-03T10:29Z 1101,CWE-119,"CWE-119 static int decode_unit ( SCPRContext * s , PixelModel * pixel , unsigned step , unsigned * rval ) { GetByteContext * gb = & s -> gb ; RangeCoder * rc = & s -> rc ; unsigned totfr = pixel -> total_freq ; unsigned value , x = 0 , cumfr = 0 , cnt_x = 0 ; int i , j , ret , c , cnt_c ; if ( ( ret = s -> get_freq ( rc , totfr , & value ) ) < 0 ) return ret ; while ( x < 16 ) { cnt_x = pixel -> lookup [ x ] ; if ( value >= cumfr + cnt_x ) cumfr += cnt_x ; else break ; x ++ ; } c = x * 16 ; cnt_c = 0 ; while ( c < 256 ) { cnt_c = pixel -> freq [ c ] ; if ( value >= cumfr + cnt_c ) cumfr += cnt_c ; else break ; c ++ ; } if ( ( ret = s -> decode ( gb , rc , cumfr , cnt_c , totfr ) ) < 0 ) return ret ; pixel -> freq [ c ] = cnt_c + step ; pixel -> lookup [ x ] = cnt_x + step ; totfr += step ; if ( totfr > BOT ) { totfr = 0 ; for ( i = 0 ; i < 256 ; i ++ ) { unsigned nc = ( pixel -> freq [ i ] >> 1 ) + 1 ; pixel -> freq [ i ] = nc ; totfr += nc ; } for ( i = 0 ; i < 16 ; i ++ ) { unsigned sum = 0 ; unsigned i16_17 = i << 4 ; for ( j = 0 ; j < 16 ; j ++ ) sum += pixel -> freq [ i16_17 + j ] ; pixel -> lookup [ i ] = sum ; } } pixel -> total_freq = totfr ; * rval = c & s -> cbits ; return 0 ; } "," } if ( x >= 16 || c >= 256 ) { return AVERROR_INVALIDDATA ; } if ( ",FFmpeg@FFmpeg/2171dfae8c065878a2e130390eb78cf2947a5b69,CVE-2017-9995,https://github.com/FFmpeg/FFmpeg/commit/2171dfae8c065878a2e130390eb78cf2947a5b69,2017-06-28T06:29Z 1102,CWE-20,"CWE-20 int snd_timer_close ( struct snd_timer_instance * timeri ) { struct snd_timer * timer = NULL ; struct snd_timer_instance * slave , * tmp ; if ( snd_BUG_ON ( ! timeri ) ) return - ENXIO ; snd_timer_stop ( timeri ) ; if ( timeri -> flags & SNDRV_TIMER_IFLG_SLAVE ) { spin_lock_irq ( & slave_active_lock ) ; while ( timeri -> flags & SNDRV_TIMER_IFLG_CALLBACK ) { spin_unlock_irq ( & slave_active_lock ) ; udelay ( 10 ) ; spin_lock_irq ( & slave_active_lock ) ; } spin_unlock_irq ( & slave_active_lock ) ; mutex_lock ( & register_mutex ) ; list_del ( & timeri -> open_list ) ; mutex_unlock ( & register_mutex ) ; } else { timer = timeri -> timer ; if ( snd_BUG_ON ( ! timer ) ) goto out ; spin_lock_irq ( & timer -> lock ) ; while ( timeri -> flags & SNDRV_TIMER_IFLG_CALLBACK ) { spin_unlock_irq ( & timer -> lock ) ; udelay ( 10 ) ; spin_lock_irq ( & timer -> lock ) ; } spin_unlock_irq ( & timer -> lock ) ; mutex_lock ( & register_mutex ) ; list_del ( & timeri -> open_list ) ; if ( timer && list_empty ( & timer -> open_list_head ) && timer -> hw . close ) timer -> hw . close ( timer ) ; list_for_each_entry_safe ( slave , tmp , & timeri -> slave_list_head , open_list ) { spin_lock_irq ( & slave_active_lock ) ; _snd_timer_stop ( slave , 1 , SNDRV_TIMER_EVENT_RESOLUTION ) ; list_move_tail ( & slave -> open_list , & snd_timer_slave_list ) ; slave -> master = NULL ; slave -> timer = NULL ; spin_unlock_irq ( & slave_active_lock ) ; } mutex_unlock ( & register_mutex ) ; } out : if ( timeri -> private_free ) timeri -> private_free ( timeri ) ; kfree ( timeri -> owner ) ; kfree ( timeri ) ; if ( timer ) module_put ( timer -> module ) ; return 0 ; } "," timer ) ; spin_lock_irq ( & slave_active_lock ) ; spin_lock ( & timer -> lock ) ; open_list ) { list_move_tail ( & = NULL ; list_del_init ( & slave -> ack_list ) ; list_del_init ( & slave -> active_list ) ; } spin_unlock ( & timer -> lock ) ; slave_active_lock ) ; mutex_unlock ( & ",torvalds@linux/b5a663aa426f4884c71cd8580adae73f33570f0d,CVE-2016-2548,https://github.com/torvalds/linux/commit/b5a663aa426f4884c71cd8580adae73f33570f0d,2016-04-27T17:59Z 1103,CWE-000,"CWE-000 int tipc_nl_publ_dump ( struct sk_buff * skb , struct netlink_callback * cb ) { int err ; u32 tsk_portid = cb -> args [ 0 ] ; u32 last_publ = cb -> args [ 1 ] ; u32 done = cb -> args [ 2 ] ; struct net * net = sock_net ( skb -> sk ) ; struct tipc_sock * tsk ; if ( ! tsk_portid ) { struct nlattr * * attrs ; struct nlattr * sock [ TIPC_NLA_SOCK_MAX + 1 ] ; err = tipc_nlmsg_parse ( cb -> nlh , & attrs ) ; if ( err ) return err ; err = nla_parse_nested ( sock , TIPC_NLA_SOCK_MAX , attrs [ TIPC_NLA_SOCK ] , tipc_nl_sock_policy ) ; if ( err ) return err ; if ( ! sock [ TIPC_NLA_SOCK_REF ] ) return - EINVAL ; tsk_portid = nla_get_u32 ( sock [ TIPC_NLA_SOCK_REF ] ) ; } if ( done ) return 0 ; tsk = tipc_sk_lookup ( net , tsk_portid ) ; if ( ! tsk ) return - EINVAL ; lock_sock ( & tsk -> sk ) ; err = __tipc_nl_list_sk_publ ( skb , cb , tsk , & last_publ ) ; if ( ! err ) done = 1 ; release_sock ( & tsk -> sk ) ; sock_put ( & tsk -> sk ) ; cb -> args [ 0 ] = tsk_portid ; cb -> args [ 1 ] = last_publ ; cb -> args [ 2 ] = done ; return skb -> len ; } "," return err ; if ( ! attrs [ TIPC_NLA_SOCK attrs [ TIPC_NLA_SOCK ] ) return - EINVAL ; err = nla_parse_nested ( sock , TIPC_NLA_SOCK_MAX , attrs [ TIPC_NLA_SOCK ] , tipc_nl_sock_policy ) ; if ( err ) return err ; if ( ! sock [ TIPC_NLA_SOCK_REF ] [ TIPC_NLA_SOCK_REF ] ) return - - EINVAL ; tsk_portid = nla_get_u32 ( sock [ TIPC_NLA_SOCK_REF ] ) ; } if ( done ) return 0 ; tsk = tipc_sk_lookup ( net , tsk_portid ) ; if ( ! tsk ) return - EINVAL ; ",torvalds@linux/45e093ae2830cd1264677d47ff9a95a71f5d9f9c,CVE-2016-4951,https://github.com/torvalds/linux/commit/45e093ae2830cd1264677d47ff9a95a71f5d9f9c,2016-05-23T10:59Z 1104,CWE-119,"CWE-119 static int update_fragments ( vpx_codec_alg_priv_t * ctx , const uint8_t * data , unsigned int data_sz , vpx_codec_err_t * res ) { * res = VPX_CODEC_OK ; if ( ctx -> fragments . count == 0 ) { vpx_memset ( ( void * ) ctx -> fragments . ptrs , 0 , sizeof ( ctx -> fragments . ptrs ) ) ; vpx_memset ( ctx -> fragments . sizes , 0 , sizeof ( ctx -> fragments . sizes ) ) ; } if ( ctx -> fragments . enabled && ! ( data == NULL && data_sz == 0 ) ) { ctx -> fragments . ptrs [ ctx -> fragments . count ] = data ; ctx -> fragments . sizes [ ctx -> fragments . count ] = data_sz ; ctx -> fragments . count ++ ; if ( ctx -> fragments . count > ( 1 << EIGHT_PARTITION ) + 1 ) { ctx -> fragments . count = 0 ; * res = VPX_CODEC_INVALID_PARAM ; return - 1 ; } return 0 ; } if ( ! ctx -> fragments . enabled ) { ctx -> fragments . ptrs [ 0 ] = data ; ctx -> fragments . sizes [ 0 ] = data_sz ; ctx -> fragments . count = 1 ; } return 1 ; } "," 0 ) { memset ( ( void ) ) ; memset ( ctx -> fragments . enabled && ( data == NULL && data_sz == 0 ) ) { return 0 ; } if ( ! ctx -> fragments . enabled ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1105,CWE-476,"CWE-476 static void m_stop ( struct seq_file * m , void * v ) { struct proc_maps_private * priv = m -> private ; struct vm_area_struct * vma = v ; vma_stop ( priv , vma ) ; if ( priv -> task ) put_task_struct ( priv -> task ) ; } "," = v ; if ( ! IS_ERR ( vma ) ) ",torvalds@linux/76597cd31470fa130784c78fadb4dab2e624a723,CVE-2011-3637,https://github.com/torvalds/linux/commit/76597cd31470fa130784c78fadb4dab2e624a723,2012-05-17T11:00Z 1106,CWE-125,"CWE-125 int usb_get_bos_descriptor ( struct usb_device * dev ) { struct device * ddev = & dev -> dev ; struct usb_bos_descriptor * bos ; struct usb_dev_cap_header * cap ; unsigned char * buffer ; int length , total_len , num , i ; int ret ; bos = kzalloc ( sizeof ( struct usb_bos_descriptor ) , GFP_KERNEL ) ; if ( ! bos ) return - ENOMEM ; ret = usb_get_descriptor ( dev , USB_DT_BOS , 0 , bos , USB_DT_BOS_SIZE ) ; if ( ret < USB_DT_BOS_SIZE ) { dev_err ( ddev , ""unabletogetBOSdescriptor\\n"" ) ; if ( ret >= 0 ) ret = - ENOMSG ; kfree ( bos ) ; return ret ; } length = bos -> bLength ; total_len = le16_to_cpu ( bos -> wTotalLength ) ; num = bos -> bNumDeviceCaps ; kfree ( bos ) ; if ( total_len < length ) return - EINVAL ; dev -> bos = kzalloc ( sizeof ( struct usb_host_bos ) , GFP_KERNEL ) ; if ( ! dev -> bos ) return - ENOMEM ; buffer = kzalloc ( total_len , GFP_KERNEL ) ; if ( ! buffer ) { ret = - ENOMEM ; goto err ; } dev -> bos -> desc = ( struct usb_bos_descriptor * ) buffer ; ret = usb_get_descriptor ( dev , USB_DT_BOS , 0 , buffer , total_len ) ; if ( ret < total_len ) { dev_err ( ddev , ""unabletogetBOSdescriptorset\\n"" ) ; if ( ret >= 0 ) ret = - ENOMSG ; goto err ; } total_len -= length ; for ( i = 0 ; i < num ; i ++ ) { buffer += length ; cap = ( struct usb_dev_cap_header * ) buffer ; length = cap -> bLength ; if ( total_len < length ) break ; total_len -= length ; if ( cap -> bDescriptorType != USB_DT_DEVICE_CAPABILITY ) { dev_warn ( ddev , ""descriptortypeinvalid,skip\\n"" ) ; continue ; } switch ( cap -> bDevCapabilityType ) { case USB_CAP_TYPE_WIRELESS_USB : break ; case USB_CAP_TYPE_EXT : dev -> bos -> ext_cap = ( struct usb_ext_cap_descriptor * ) buffer ; break ; case USB_SS_CAP_TYPE : dev -> bos -> ss_cap = ( struct usb_ss_cap_descriptor * ) buffer ; break ; case USB_SSP_CAP_TYPE : dev -> bos -> ssp_cap = ( struct usb_ssp_cap_descriptor * ) buffer ; break ; case CONTAINER_ID_TYPE : dev -> bos -> ss_id = ( struct usb_ss_container_id_descriptor * ) buffer ; break ; case USB_PTM_CAP_TYPE : dev -> bos -> ptm_cap = ( struct usb_ptm_cap_descriptor * ) buffer ; default : break ; } } return 0 ; err : usb_release_bos_descriptor ( dev ) ; return ret ; } "," ) buffer ; if ( total_len < sizeof ( * cap ) || total_len < cap -> bLength cap -> bLength ) { dev -> bos -> desc -> bNumDeviceCaps = i ; break ; } length = cap -> bLength ; total_len -= ",torvalds@linux/1c0edc3633b56000e18d82fc241e3995ca18a69e,CVE-2017-16535,https://github.com/torvalds/linux/commit/1c0edc3633b56000e18d82fc241e3995ca18a69e,2017-11-04T01:29Z 1107,CWE-17,"CWE-17 void fput ( struct file * file ) { if ( atomic_long_dec_and_test ( & file -> f_count ) ) { struct task_struct * task = current ; file_sb_list_del ( file ) ; if ( likely ( ! in_interrupt ( ) && ! ( task -> flags & PF_KTHREAD ) ) ) { init_task_work ( & file -> f_u . fu_rcuhead , ____fput ) ; if ( ! task_work_add ( task , & file -> f_u . fu_rcuhead , true ) ) return ; } if ( llist_add ( & file -> f_u . fu_llist , & delayed_fput_list ) ) schedule_work ( & delayed_fput_work ) ; } } "," task = current ; if ( ",torvalds@linux/eee5cc2702929fd41cce28058dc6d6717f723f87,CVE-2014-8172,https://github.com/torvalds/linux/commit/eee5cc2702929fd41cce28058dc6d6717f723f87,2015-03-16T10:59Z 1108,CWE-119,"CWE-119 static int udf_read_inode ( struct inode * inode , bool hidden_inode ) { struct buffer_head * bh = NULL ; struct fileEntry * fe ; struct extendedFileEntry * efe ; uint16_t ident ; struct udf_inode_info * iinfo = UDF_I ( inode ) ; struct udf_sb_info * sbi = UDF_SB ( inode -> i_sb ) ; struct kernel_lb_addr * iloc = & iinfo -> i_location ; unsigned int link_count ; unsigned int indirections = 0 ; int ret = - EIO ; reread : if ( iloc -> logicalBlockNum >= sbi -> s_partmaps [ iloc -> partitionReferenceNum ] . s_partition_len ) { udf_debug ( ""block=%d,partition=%doutofrange\\n"" , iloc -> logicalBlockNum , iloc -> partitionReferenceNum ) ; return - EIO ; } bh = udf_read_ptagged ( inode -> i_sb , iloc , 0 , & ident ) ; if ( ! bh ) { udf_err ( inode -> i_sb , ""(ino%ld)failed!bh\\n"" , inode -> i_ino ) ; return - EIO ; } if ( ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE && ident != TAG_IDENT_USE ) { udf_err ( inode -> i_sb , ""(ino%ld)failedident=%d\\n"" , inode -> i_ino , ident ) ; goto out ; } fe = ( struct fileEntry * ) bh -> b_data ; efe = ( struct extendedFileEntry * ) bh -> b_data ; if ( fe -> icbTag . strategyType == cpu_to_le16 ( 4096 ) ) { struct buffer_head * ibh ; ibh = udf_read_ptagged ( inode -> i_sb , iloc , 1 , & ident ) ; if ( ident == TAG_IDENT_IE && ibh ) { struct kernel_lb_addr loc ; struct indirectEntry * ie ; ie = ( struct indirectEntry * ) ibh -> b_data ; loc = lelb_to_cpu ( ie -> indirectICB . extLocation ) ; if ( ie -> indirectICB . extLength ) { brelse ( ibh ) ; memcpy ( & iinfo -> i_location , & loc , sizeof ( struct kernel_lb_addr ) ) ; if ( ++ indirections > UDF_MAX_ICB_NESTING ) { udf_err ( inode -> i_sb , ""toomanyICBsinICBhierarchy"" ""(max%dsupported)\\n"" , UDF_MAX_ICB_NESTING ) ; goto out ; } brelse ( bh ) ; goto reread ; } } brelse ( ibh ) ; } else if ( fe -> icbTag . strategyType != cpu_to_le16 ( 4 ) ) { udf_err ( inode -> i_sb , ""unsupportedstrategytype:%d\\n"" , le16_to_cpu ( fe -> icbTag . strategyType ) ) ; goto out ; } if ( fe -> icbTag . strategyType == cpu_to_le16 ( 4 ) ) iinfo -> i_strat4096 = 0 ; else iinfo -> i_strat4096 = 1 ; iinfo -> i_alloc_type = le16_to_cpu ( fe -> icbTag . flags ) & ICBTAG_FLAG_AD_MASK ; iinfo -> i_unique = 0 ; iinfo -> i_lenEAttr = 0 ; iinfo -> i_lenExtents = 0 ; iinfo -> i_lenAlloc = 0 ; iinfo -> i_next_alloc_block = 0 ; iinfo -> i_next_alloc_goal = 0 ; if ( fe -> descTag . tagIdent == cpu_to_le16 ( TAG_IDENT_EFE ) ) { iinfo -> i_efe = 1 ; iinfo -> i_use = 0 ; ret = udf_alloc_i_data ( inode , inode -> i_sb -> s_blocksize - sizeof ( struct extendedFileEntry ) ) ; if ( ret ) goto out ; memcpy ( iinfo -> i_ext . i_data , bh -> b_data + sizeof ( struct extendedFileEntry ) , inode -> i_sb -> s_blocksize - sizeof ( struct extendedFileEntry ) ) ; } else if ( fe -> descTag . tagIdent == cpu_to_le16 ( TAG_IDENT_FE ) ) { iinfo -> i_efe = 0 ; iinfo -> i_use = 0 ; ret = udf_alloc_i_data ( inode , inode -> i_sb -> s_blocksize - sizeof ( struct fileEntry ) ) ; if ( ret ) goto out ; memcpy ( iinfo -> i_ext . i_data , bh -> b_data + sizeof ( struct fileEntry ) , inode -> i_sb -> s_blocksize - sizeof ( struct fileEntry ) ) ; } else if ( fe -> descTag . tagIdent == cpu_to_le16 ( TAG_IDENT_USE ) ) { iinfo -> i_efe = 0 ; iinfo -> i_use = 1 ; iinfo -> i_lenAlloc = le32_to_cpu ( ( ( struct unallocSpaceEntry * ) bh -> b_data ) -> lengthAllocDescs ) ; ret = udf_alloc_i_data ( inode , inode -> i_sb -> s_blocksize - sizeof ( struct unallocSpaceEntry ) ) ; if ( ret ) goto out ; memcpy ( iinfo -> i_ext . i_data , bh -> b_data + sizeof ( struct unallocSpaceEntry ) , inode -> i_sb -> s_blocksize - sizeof ( struct unallocSpaceEntry ) ) ; return 0 ; } ret = - EIO ; read_lock ( & sbi -> s_cred_lock ) ; i_uid_write ( inode , le32_to_cpu ( fe -> uid ) ) ; if ( ! uid_valid ( inode -> i_uid ) || UDF_QUERY_FLAG ( inode -> i_sb , UDF_FLAG_UID_IGNORE ) || UDF_QUERY_FLAG ( inode -> i_sb , UDF_FLAG_UID_SET ) ) inode -> i_uid = UDF_SB ( inode -> i_sb ) -> s_uid ; i_gid_write ( inode , le32_to_cpu ( fe -> gid ) ) ; if ( ! gid_valid ( inode -> i_gid ) || UDF_QUERY_FLAG ( inode -> i_sb , UDF_FLAG_GID_IGNORE ) || UDF_QUERY_FLAG ( inode -> i_sb , UDF_FLAG_GID_SET ) ) inode -> i_gid = UDF_SB ( inode -> i_sb ) -> s_gid ; if ( fe -> icbTag . fileType != ICBTAG_FILE_TYPE_DIRECTORY && sbi -> s_fmode != UDF_INVALID_MODE ) inode -> i_mode = sbi -> s_fmode ; else if ( fe -> icbTag . fileType == ICBTAG_FILE_TYPE_DIRECTORY && sbi -> s_dmode != UDF_INVALID_MODE ) inode -> i_mode = sbi -> s_dmode ; else inode -> i_mode = udf_convert_permissions ( fe ) ; inode -> i_mode &= ~ sbi -> s_umask ; read_unlock ( & sbi -> s_cred_lock ) ; link_count = le16_to_cpu ( fe -> fileLinkCount ) ; if ( ! link_count ) { if ( ! hidden_inode ) { ret = - ESTALE ; goto out ; } link_count = 1 ; } set_nlink ( inode , link_count ) ; inode -> i_size = le64_to_cpu ( fe -> informationLength ) ; iinfo -> i_lenExtents = inode -> i_size ; if ( iinfo -> i_efe == 0 ) { inode -> i_blocks = le64_to_cpu ( fe -> logicalBlocksRecorded ) << ( inode -> i_sb -> s_blocksize_bits - 9 ) ; if ( ! udf_disk_stamp_to_time ( & inode -> i_atime , fe -> accessTime ) ) inode -> i_atime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & inode -> i_mtime , fe -> modificationTime ) ) inode -> i_mtime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & inode -> i_ctime , fe -> attrTime ) ) inode -> i_ctime = sbi -> s_record_time ; iinfo -> i_unique = le64_to_cpu ( fe -> uniqueID ) ; iinfo -> i_lenEAttr = le32_to_cpu ( fe -> lengthExtendedAttr ) ; iinfo -> i_lenAlloc = le32_to_cpu ( fe -> lengthAllocDescs ) ; iinfo -> i_checkpoint = le32_to_cpu ( fe -> checkpoint ) ; } else { inode -> i_blocks = le64_to_cpu ( efe -> logicalBlocksRecorded ) << ( inode -> i_sb -> s_blocksize_bits - 9 ) ; if ( ! udf_disk_stamp_to_time ( & inode -> i_atime , efe -> accessTime ) ) inode -> i_atime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & inode -> i_mtime , efe -> modificationTime ) ) inode -> i_mtime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & iinfo -> i_crtime , efe -> createTime ) ) iinfo -> i_crtime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & inode -> i_ctime , efe -> attrTime ) ) inode -> i_ctime = sbi -> s_record_time ; iinfo -> i_unique = le64_to_cpu ( efe -> uniqueID ) ; iinfo -> i_lenEAttr = le32_to_cpu ( efe -> lengthExtendedAttr ) ; iinfo -> i_lenAlloc = le32_to_cpu ( efe -> lengthAllocDescs ) ; iinfo -> i_checkpoint = le32_to_cpu ( efe -> checkpoint ) ; } inode -> i_generation = iinfo -> i_unique ; switch ( fe -> icbTag . fileType ) { case ICBTAG_FILE_TYPE_DIRECTORY : inode -> i_op = & udf_dir_inode_operations ; inode -> i_fop = & udf_dir_operations ; inode -> i_mode |= S_IFDIR ; inc_nlink ( inode ) ; break ; case ICBTAG_FILE_TYPE_REALTIME : case ICBTAG_FILE_TYPE_REGULAR : case ICBTAG_FILE_TYPE_UNDEF : case ICBTAG_FILE_TYPE_VAT20 : if ( iinfo -> i_alloc_type == ICBTAG_FLAG_AD_IN_ICB ) inode -> i_data . a_ops = & udf_adinicb_aops ; else inode -> i_data . a_ops = & udf_aops ; inode -> i_op = & udf_file_inode_operations ; inode -> i_fop = & udf_file_operations ; inode -> i_mode |= S_IFREG ; break ; case ICBTAG_FILE_TYPE_BLOCK : inode -> i_mode |= S_IFBLK ; break ; case ICBTAG_FILE_TYPE_CHAR : inode -> i_mode |= S_IFCHR ; break ; case ICBTAG_FILE_TYPE_FIFO : init_special_inode ( inode , inode -> i_mode | S_IFIFO , 0 ) ; break ; case ICBTAG_FILE_TYPE_SOCKET : init_special_inode ( inode , inode -> i_mode | S_IFSOCK , 0 ) ; break ; case ICBTAG_FILE_TYPE_SYMLINK : inode -> i_data . a_ops = & udf_symlink_aops ; inode -> i_op = & udf_symlink_inode_operations ; inode -> i_mode = S_IFLNK | S_IRWXUGO ; break ; case ICBTAG_FILE_TYPE_MAIN : udf_debug ( ""METADATAFILE-----\\n"" ) ; break ; case ICBTAG_FILE_TYPE_MIRROR : udf_debug ( ""METADATAMIRRORFILE-----\\n"" ) ; break ; case ICBTAG_FILE_TYPE_BITMAP : udf_debug ( ""METADATABITMAPFILE-----\\n"" ) ; break ; default : udf_err ( inode -> i_sb , ""(ino%ld)failedunknownfiletype=%d\\n"" , inode -> i_ino , fe -> icbTag . fileType ) ; goto out ; } if ( S_ISCHR ( inode -> i_mode ) || S_ISBLK ( inode -> i_mode ) ) { struct deviceSpec * dsea = ( struct deviceSpec * ) udf_get_extendedattr ( inode , 12 , 1 ) ; if ( dsea ) { init_special_inode ( inode , inode -> i_mode , MKDEV ( le32_to_cpu ( dsea -> majorDeviceIdent ) , le32_to_cpu ( dsea -> minorDeviceIdent ) ) ) ; } else goto out ; } ret = 0 ; out : brelse ( bh ) ; return ret ; } "," -> i_unique ; if ( iinfo -> i_alloc_type == ICBTAG_FLAG_AD_IN_ICB ) { if ( iinfo -> i_lenAlloc != inode -> i_size ) goto out ; if ( inode -> i_size > inode -> i_sb -> s_blocksize - udf_file_entry_alloc_offset ( inode ) ) goto out ; } ",torvalds@linux/e159332b9af4b04d882dbcfe1bb0117f0a6d4b58,CVE-2014-9728,https://github.com/torvalds/linux/commit/e159332b9af4b04d882dbcfe1bb0117f0a6d4b58,2015-08-31T10:59Z 1109,CWE-20,"CWE-20 void enc28j60WritePhyReg ( NetInterface * interface , uint16_t address , uint16_t data ) { enc28j60WriteReg ( interface , ENC28J60_REG_MIREGADR , address & REG_ADDR_MASK ) ; enc28j60WriteReg ( interface , ENC28J60_REG_MIWRL , LSB ( data ) ) ; enc28j60WriteReg ( interface , ENC28J60_REG_MIWRH , MSB ( data ) ) ; while ( ( enc28j60ReadReg ( interface , ENC28J60_REG_MISTAT ) & MISTAT_BUSY ) != 0 ) { } } "," ( interface , ENC28J60_MIREGADR , address & ( interface , ENC28J60_MIWRL , LSB ( ( interface , ENC28J60_MIWRH , MSB ( ( interface , ENC28J60_MISTAT ) & ENC28J60_MISTAT_BUSY ) != 0 ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 1110,CWE-134,"CWE-134 static int bad_format_imginfo ( char * fmt ) { char * ptr ; int n = 0 ; ptr = fmt ; while ( * ptr != '\\0' ) if ( * ptr ++ == '%' ) { if ( * ptr == '\\0' ) return 1 ; if ( * ptr == '%' ) ptr ++ ; else if ( * ptr == 's' || * ptr == 'S' ) { n = 1 ; ptr ++ ; } else { if ( * ptr == '' ) ptr ++ ; while ( * ptr >= '0' && * ptr <= '9' ) ptr ++ ; if ( * ptr ++ != 'l' ) return 1 ; if ( * ptr == 'u' ) ptr ++ ; else return 1 ; n ++ ; } } return ( n != 3 ) ; } "," int bad_format_imginfo ( fmt ) { return bad_format_check ( ""^"" SAFE_STRING ""%s"" SAFE_STRING ""%lu"" SAFE_STRING ""%lu"" SAFE_STRING ""$"" , fmt ) ; } ",oetiker@rrdtool-1.x/85261a013112e278c90224033f5b0592ee387786,CVE-2014-6262,https://github.com/oetiker/rrdtool-1.x/commit/85261a013112e278c90224033f5b0592ee387786,2020-02-12T02:15Z 1111,CWE-362,"CWE-362 void inet_sock_destruct ( struct sock * sk ) { struct inet_sock * inet = inet_sk ( sk ) ; __skb_queue_purge ( & sk -> sk_receive_queue ) ; __skb_queue_purge ( & sk -> sk_error_queue ) ; sk_mem_reclaim ( sk ) ; if ( sk -> sk_type == SOCK_STREAM && sk -> sk_state != TCP_CLOSE ) { pr_err ( ""AttempttoreleaseTCPsocketinstate%d%p\\n"" , sk -> sk_state , sk ) ; return ; } if ( ! sock_flag ( sk , SOCK_DEAD ) ) { pr_err ( ""Attempttoreleasealiveinetsocket%p\\n"" , sk ) ; return ; } WARN_ON ( atomic_read ( & sk -> sk_rmem_alloc ) ) ; WARN_ON ( atomic_read ( & sk -> sk_wmem_alloc ) ) ; WARN_ON ( sk -> sk_wmem_queued ) ; WARN_ON ( sk -> sk_forward_alloc ) ; kfree ( inet -> opt ) ; dst_release ( rcu_dereference_check ( sk -> sk_dst_cache , 1 ) ) ; sk_refcnt_debug_dec ( sk ) ; } "," ; kfree ( rcu_dereference_protected ( inet -> inet_opt , 1 ) ) ; dst_release ",torvalds@linux/f6d8bd051c391c1c0458a30b2a7abcd939329259,CVE-2012-3552,https://github.com/torvalds/linux/commit/f6d8bd051c391c1c0458a30b2a7abcd939329259,2012-10-03T11:02Z 1112,CWE-20,"CWE-20 static int encrypt ( struct blkcipher_desc * desc , struct scatterlist * dst , struct scatterlist * src , unsigned int nbytes ) { struct blkcipher_walk walk ; struct crypto_blkcipher * tfm = desc -> tfm ; struct salsa20_ctx * ctx = crypto_blkcipher_ctx ( tfm ) ; int err ; blkcipher_walk_init ( & walk , dst , src , nbytes ) ; err = blkcipher_walk_virt_block ( desc , & walk , 64 ) ; salsa20_ivsetup ( ctx , walk . iv ) ; if ( likely ( walk . nbytes == nbytes ) ) { salsa20_encrypt_bytes ( ctx , walk . dst . virt . addr , walk . src . virt . addr , nbytes ) ; return blkcipher_walk_done ( desc , & walk , 0 ) ; } while ( walk . nbytes >= 64 ) { salsa20_encrypt_bytes ( ctx , walk . dst . virt . addr , walk . src . virt . addr , walk . nbytes - ( walk . nbytes % 64 ) ) ; err = blkcipher_walk_done ( desc , & walk , walk . nbytes % 64 ) ; } if ( walk . nbytes ) { salsa20_encrypt_bytes ( ctx , walk . dst . virt . addr , walk . src . virt . addr , walk . nbytes ) ; err = blkcipher_walk_done ( desc , & walk , 0 ) ; } return err ; } "," iv ) ; while ( walk ",torvalds@linux/ecaaab5649781c5a0effdaf298a925063020500e,CVE-2017-17805,https://github.com/torvalds/linux/commit/ecaaab5649781c5a0effdaf298a925063020500e,2017-12-20T23:29Z 1113,CWE-835,"CWE-835 static int resp_get_length ( netdissect_options * ndo , register const u_char * bp , int len , const u_char * * endp ) { int result ; u_char c ; int saw_digit ; int neg ; int too_large ; if ( len == 0 ) goto trunc ; ND_TCHECK ( * bp ) ; too_large = 0 ; neg = 0 ; if ( * bp == '-' ) { neg = 1 ; bp ++ ; len -- ; } result = 0 ; saw_digit = 0 ; for ( ; ; ) { if ( len == 0 ) goto trunc ; ND_TCHECK ( * bp ) ; c = * bp ; if ( ! ( c >= '0' && c <= '9' ) ) { if ( ! saw_digit ) goto invalid ; break ; } c -= '0' ; if ( result > ( INT_MAX / 10 ) ) { too_large = 1 ; } else { result *= 10 ; if ( result == INT_MAX && c > ( INT_MAX % 10 ) ) { too_large = 1 ; } else result += c ; } bp ++ ; len -- ; saw_digit = 1 ; } if ( ! saw_digit ) goto invalid ; if ( len == 0 ) goto trunc ; ND_TCHECK ( * bp ) ; if ( * bp != '\\r' ) goto invalid ; bp ++ ; len -- ; if ( len == 0 ) goto trunc ; ND_TCHECK ( * bp ) ; if ( * bp != '\\n' ) goto invalid ; bp ++ ; len -- ; * endp = bp ; if ( neg ) { if ( too_large || result != 1 ) return ( - 4 ) ; result = - 1 ; } return ( too_large ? - 3 : result ) ; trunc : return ( - 2 ) ; invalid : return ( - 5 ) ; } "," ! saw_digit ) { bp ++ ; goto invalid ; } != '\\r' ) { bp ++ ; goto invalid ; } != '\\n' ) { bp ++ ; goto invalid ; } ; trunc : * endp = bp ; ; invalid : * endp = bp ; ",the-tcpdump-group@tcpdump/db24063b01cba8e9d4d88b7d8ac70c9000c104e4,CVE-2017-12989,https://github.com/the-tcpdump-group/tcpdump/commit/db24063b01cba8e9d4d88b7d8ac70c9000c104e4,2017-09-14T06:29Z 1114,CWE-19,"CWE-19 int xfs_attr3_leaf_lookup_int ( struct xfs_buf * bp , struct xfs_da_args * args ) { struct xfs_attr_leafblock * leaf ; struct xfs_attr3_icleaf_hdr ichdr ; struct xfs_attr_leaf_entry * entry ; struct xfs_attr_leaf_entry * entries ; struct xfs_attr_leaf_name_local * name_loc ; struct xfs_attr_leaf_name_remote * name_rmt ; xfs_dahash_t hashval ; int probe ; int span ; trace_xfs_attr_leaf_lookup ( args ) ; leaf = bp -> b_addr ; xfs_attr3_leaf_hdr_from_disk ( & ichdr , leaf ) ; entries = xfs_attr3_leaf_entryp ( leaf ) ; ASSERT ( ichdr . count < XFS_LBSIZE ( args -> dp -> i_mount ) / 8 ) ; hashval = args -> hashval ; probe = span = ichdr . count / 2 ; for ( entry = & entries [ probe ] ; span > 4 ; entry = & entries [ probe ] ) { span /= 2 ; if ( be32_to_cpu ( entry -> hashval ) < hashval ) probe += span ; else if ( be32_to_cpu ( entry -> hashval ) > hashval ) probe -= span ; else break ; } ASSERT ( probe >= 0 && ( ! ichdr . count || probe < ichdr . count ) ) ; ASSERT ( span <= 4 || be32_to_cpu ( entry -> hashval ) == hashval ) ; while ( probe > 0 && be32_to_cpu ( entry -> hashval ) >= hashval ) { entry -- ; probe -- ; } while ( probe < ichdr . count && be32_to_cpu ( entry -> hashval ) < hashval ) { entry ++ ; probe ++ ; } if ( probe == ichdr . count || be32_to_cpu ( entry -> hashval ) != hashval ) { args -> index = probe ; return XFS_ERROR ( ENOATTR ) ; } for ( ; probe < ichdr . count && ( be32_to_cpu ( entry -> hashval ) == hashval ) ; entry ++ , probe ++ ) { if ( ( args -> flags & XFS_ATTR_INCOMPLETE ) != ( entry -> flags & XFS_ATTR_INCOMPLETE ) ) { continue ; } if ( entry -> flags & XFS_ATTR_LOCAL ) { name_loc = xfs_attr3_leaf_name_local ( leaf , probe ) ; if ( name_loc -> namelen != args -> namelen ) continue ; if ( memcmp ( args -> name , name_loc -> nameval , args -> namelen ) != 0 ) continue ; if ( ! xfs_attr_namesp_match ( args -> flags , entry -> flags ) ) continue ; args -> index = probe ; return XFS_ERROR ( EEXIST ) ; } else { name_rmt = xfs_attr3_leaf_name_remote ( leaf , probe ) ; if ( name_rmt -> namelen != args -> namelen ) continue ; if ( memcmp ( args -> name , name_rmt -> name , args -> namelen ) != 0 ) continue ; if ( ! xfs_attr_namesp_match ( args -> flags , entry -> flags ) ) continue ; args -> index = probe ; args -> valuelen = be32_to_cpu ( name_rmt -> valuelen ) ; args -> rmtblkno = be32_to_cpu ( name_rmt -> valueblk ) ; args -> rmtblkcnt = xfs_attr3_rmt_blocks ( args -> dp -> i_mount , args -> valuelen ) ; return XFS_ERROR ( EEXIST ) ; } } args -> index = probe ; return XFS_ERROR ( ENOATTR ) ; } "," ; args -> rmtvaluelen = be32_to_cpu ( name_rmt -> valuelen ) ; args -> rmtblkno = be32_to_cpu ( ( name_rmt -> valueblk ) ; , args -> rmtvaluelen ) ; return ",torvalds@linux/8275cdd0e7ac550dcce2b3ef6d2fb3b808c1ae59,CVE-2015-0274,https://github.com/torvalds/linux/commit/8275cdd0e7ac550dcce2b3ef6d2fb3b808c1ae59,2015-03-16T10:59Z 1115,CWE-358,"CWE-358 void DefragRegisterTests ( void ) { # ifdef UNITTESTS UtRegisterTest ( ""DefragInOrderSimpleTest"" , DefragInOrderSimpleTest ) ; UtRegisterTest ( ""DefragReverseSimpleTest"" , DefragReverseSimpleTest ) ; UtRegisterTest ( ""DefragSturgesNovakBsdTest"" , DefragSturgesNovakBsdTest ) ; UtRegisterTest ( ""DefragSturgesNovakLinuxTest"" , DefragSturgesNovakLinuxTest ) ; UtRegisterTest ( ""DefragSturgesNovakWindowsTest"" , DefragSturgesNovakWindowsTest ) ; UtRegisterTest ( ""DefragSturgesNovakSolarisTest"" , DefragSturgesNovakSolarisTest ) ; UtRegisterTest ( ""DefragSturgesNovakFirstTest"" , DefragSturgesNovakFirstTest ) ; UtRegisterTest ( ""DefragSturgesNovakLastTest"" , DefragSturgesNovakLastTest ) ; UtRegisterTest ( ""DefragIPv4NoDataTest"" , DefragIPv4NoDataTest ) ; UtRegisterTest ( ""DefragIPv4TooLargeTest"" , DefragIPv4TooLargeTest ) ; UtRegisterTest ( ""IPV6DefragInOrderSimpleTest"" , IPV6DefragInOrderSimpleTest ) ; UtRegisterTest ( ""IPV6DefragReverseSimpleTest"" , IPV6DefragReverseSimpleTest ) ; UtRegisterTest ( ""IPV6DefragSturgesNovakBsdTest"" , IPV6DefragSturgesNovakBsdTest ) ; UtRegisterTest ( ""IPV6DefragSturgesNovakLinuxTest"" , IPV6DefragSturgesNovakLinuxTest ) ; UtRegisterTest ( ""IPV6DefragSturgesNovakWindowsTest"" , IPV6DefragSturgesNovakWindowsTest ) ; UtRegisterTest ( ""IPV6DefragSturgesNovakSolarisTest"" , IPV6DefragSturgesNovakSolarisTest ) ; UtRegisterTest ( ""IPV6DefragSturgesNovakFirstTest"" , IPV6DefragSturgesNovakFirstTest ) ; UtRegisterTest ( ""IPV6DefragSturgesNovakLastTest"" , IPV6DefragSturgesNovakLastTest ) ; UtRegisterTest ( ""DefragVlanTest"" , DefragVlanTest ) ; UtRegisterTest ( ""DefragVlanQinQTest"" , DefragVlanQinQTest ) ; UtRegisterTest ( ""DefragTrackerReuseTest"" , DefragTrackerReuseTest ) ; UtRegisterTest ( ""DefragTimeoutTest"" , DefragTimeoutTest ) ; UtRegisterTest ( ""DefragMfIpv4Test"" , DefragMfIpv4Test ) ; UtRegisterTest ( ""DefragMfIpv6Test"" , DefragMfIpv6Test ) ; # endif } "," DefragMfIpv6Test ) ; UtRegisterTest ( ""DefragTestBadProto"" , DefragTestBadProto ) ; ",inliniac@suricata/4a04f814b15762eb446a5ead4d69d021512df6f8,CVE-2017-7177,https://github.com/inliniac/suricata/commit/4a04f814b15762eb446a5ead4d69d021512df6f8,2017-03-18T20:59Z 1116,CWE-415,"CWE-415 static int coolkey_add_object ( coolkey_private_data_t * priv , unsigned long object_id , const u8 * object_data , size_t object_length , int add_v1_record ) { sc_cardctl_coolkey_object_t new_object ; int r ; memset ( & new_object , 0 , sizeof ( new_object ) ) ; new_object . path = coolkey_template_path ; new_object . path . len = 4 ; ulong2bebytes ( new_object . path . value , object_id ) ; new_object . id = object_id ; new_object . length = object_length ; if ( object_data ) { new_object . data = malloc ( object_length + add_v1_record ) ; if ( new_object . data == NULL ) { return SC_ERROR_OUT_OF_MEMORY ; } if ( add_v1_record ) { new_object . data [ 0 ] = COOLKEY_V1_OBJECT ; new_object . length ++ ; } memcpy ( & new_object . data [ add_v1_record ] , object_data , object_length ) ; } r = coolkey_add_object_to_list ( & priv -> objects_list , & new_object ) ; if ( r != SC_SUCCESS ) { free ( new_object . data ) ; new_object . data = NULL ; } return r ; } "," ; if ( coolkey_find_object_by_id ( & priv -> objects_list , object_id ) != NULL ) { return SC_ERROR_INTERNAL ; } if ( ",OpenSC@OpenSC/c246f6f69a749d4f68626b40795a4f69168008f4,CVE-2019-20792,https://github.com/OpenSC/OpenSC/commit/c246f6f69a749d4f68626b40795a4f69168008f4,2020-04-29T04:15Z 1117,CWE-476,"CWE-476 static Sdb * store_versioninfo_gnu_verdef ( ELFOBJ * bin , Elf_ ( Shdr ) * shdr , int sz ) { const char * section_name = """" ; const char * link_section_name = """" ; char * end = NULL ; Elf_ ( Shdr ) * link_shdr = NULL ; ut8 dfs [ sizeof ( Elf_ ( Verdef ) ) ] = { 0 } ; Sdb * sdb ; int cnt , i ; if ( shdr -> sh_link > bin -> ehdr . e_shnum ) { return false ; } link_shdr = & bin -> shdr [ shdr -> sh_link ] ; if ( ( int ) shdr -> sh_size < 1 ) { return false ; } Elf_ ( Verdef ) * defs = calloc ( shdr -> sh_size , sizeof ( char ) ) ; if ( ! defs ) { return false ; } if ( bin -> shstrtab && shdr -> sh_name < bin -> shstrtab_size ) { section_name = & bin -> shstrtab [ shdr -> sh_name ] ; } if ( link_shdr && bin -> shstrtab && link_shdr -> sh_name < bin -> shstrtab_size ) { link_section_name = & bin -> shstrtab [ link_shdr -> sh_name ] ; } if ( ! defs ) { bprintf ( ""Warning:Cannotallocatememory(CheckElf_(Verdef))\\n"" ) ; return NULL ; } sdb = sdb_new0 ( ) ; end = ( char * ) defs + shdr -> sh_size ; sdb_set ( sdb , ""section_name"" , section_name , 0 ) ; sdb_num_set ( sdb , ""entries"" , shdr -> sh_info , 0 ) ; sdb_num_set ( sdb , ""addr"" , shdr -> sh_addr , 0 ) ; sdb_num_set ( sdb , ""offset"" , shdr -> sh_offset , 0 ) ; sdb_num_set ( sdb , ""link"" , shdr -> sh_link , 0 ) ; sdb_set ( sdb , ""link_section_name"" , link_section_name , 0 ) ; for ( cnt = 0 , i = 0 ; i >= 0 && cnt < shdr -> sh_info && ( ( char * ) defs + i < end ) ; ++ cnt ) { Sdb * sdb_verdef = sdb_new0 ( ) ; char * vstart = ( ( char * ) defs ) + i ; char key [ 32 ] = { 0 } ; Elf_ ( Verdef ) * verdef = ( Elf_ ( Verdef ) * ) vstart ; Elf_ ( Verdaux ) aux = { 0 } ; int j = 0 ; int isum = 0 ; r_buf_read_at ( bin -> b , shdr -> sh_offset + i , dfs , sizeof ( Elf_ ( Verdef ) ) ) ; verdef -> vd_version = READ16 ( dfs , j ) verdef -> vd_flags = READ16 ( dfs , j ) verdef -> vd_ndx = READ16 ( dfs , j ) verdef -> vd_cnt = READ16 ( dfs , j ) verdef -> vd_hash = READ32 ( dfs , j ) verdef -> vd_aux = READ32 ( dfs , j ) verdef -> vd_next = READ32 ( dfs , j ) int vdaux = verdef -> vd_aux ; if ( vdaux < 1 || vstart + vdaux < vstart ) { sdb_free ( sdb_verdef ) ; goto out_error ; } vstart += vdaux ; if ( vstart > end || vstart + sizeof ( Elf_ ( Verdaux ) ) > end ) { sdb_free ( sdb_verdef ) ; goto out_error ; } j = 0 ; aux . vda_name = READ32 ( vstart , j ) aux . vda_next = READ32 ( vstart , j ) isum = i + verdef -> vd_aux ; if ( aux . vda_name > bin -> dynstr_size ) { sdb_free ( sdb_verdef ) ; goto out_error ; } sdb_num_set ( sdb_verdef , ""idx"" , i , 0 ) ; sdb_num_set ( sdb_verdef , ""vd_version"" , verdef -> vd_version , 0 ) ; sdb_num_set ( sdb_verdef , ""vd_ndx"" , verdef -> vd_ndx , 0 ) ; sdb_num_set ( sdb_verdef , ""vd_cnt"" , verdef -> vd_cnt , 0 ) ; sdb_set ( sdb_verdef , ""vda_name"" , & bin -> dynstr [ aux . vda_name ] , 0 ) ; sdb_set ( sdb_verdef , ""flags"" , get_ver_flags ( verdef -> vd_flags ) , 0 ) ; for ( j = 1 ; j < verdef -> vd_cnt ; ++ j ) { int k ; Sdb * sdb_parent = sdb_new0 ( ) ; isum += aux . vda_next ; vstart += aux . vda_next ; if ( vstart > end || vstart + sizeof ( Elf_ ( Verdaux ) ) > end ) { sdb_free ( sdb_verdef ) ; sdb_free ( sdb_parent ) ; goto out_error ; } k = 0 ; aux . vda_name = READ32 ( vstart , k ) aux . vda_next = READ32 ( vstart , k ) if ( aux . vda_name > bin -> dynstr_size ) { sdb_free ( sdb_verdef ) ; sdb_free ( sdb_parent ) ; goto out_error ; } sdb_num_set ( sdb_parent , ""idx"" , isum , 0 ) ; sdb_num_set ( sdb_parent , ""parent"" , j , 0 ) ; sdb_set ( sdb_parent , ""vda_name"" , & bin -> dynstr [ aux . vda_name ] , 0 ) ; snprintf ( key , sizeof ( key ) , ""parent%d"" , j - 1 ) ; sdb_ns_set ( sdb_verdef , key , sdb_parent ) ; } snprintf ( key , sizeof ( key ) , ""verdef%d"" , cnt ) ; sdb_ns_set ( sdb , key , sdb_verdef ) ; if ( ! verdef -> vd_next ) { sdb_free ( sdb_verdef ) ; goto out_error ; } if ( ( st32 ) verdef -> vd_next < 1 ) { eprintf ( ""Warning:Invalidvd_nextintheELFversion\\n"" ) ; break ; } i += verdef -> vd_next ; } free ( defs ) ; return sdb ; out_error : free ( defs ) ; sdb_free ( sdb ) ; return NULL ; } "," + i ; size_t vstart_off = i ; < 1 || shdr -> sh_size - vstart_off < vdaux ) { sdb_free ; } vstart += vdaux ; vstart_off . vda_next ; vstart_off += aux . vda_next ; ",radare@radare2/fbaf24bce7ea4211e4608b3ab6c1b45702cb243d,CVE-2017-16359,https://github.com/radare/radare2/commit/fbaf24bce7ea4211e4608b3ab6c1b45702cb243d,2017-11-01T17:29Z 1118,CWE-20,"CWE-20 error_t webSocketParseAuthenticateField ( WebSocket * webSocket , char_t * value ) { # if ( WEB_SOCKET_BASIC_AUTH_SUPPORT == ENABLED || WEB_SOCKET_DIGEST_AUTH_SUPPORT == ENABLED ) size_t n ; char_t * p ; char_t * token ; char_t * separator ; char_t * name ; WebSocketAuthContext * authContext ; authContext = & webSocket -> authContext ; token = osStrtok_r ( value , ""\\t"" , & p ) ; if ( token == NULL ) return ERROR_INVALID_SYNTAX ; if ( ! osStrcasecmp ( token , ""Basic"" ) ) { authContext -> requiredAuthMode = WS_AUTH_MODE_BASIC ; } else if ( ! osStrcasecmp ( token , ""Digest"" ) ) { authContext -> requiredAuthMode = WS_AUTH_MODE_DIGEST ; } else { return ERROR_INVALID_SYNTAX ; } token = osStrtok_r ( NULL , "","" , & p ) ; while ( token != NULL ) { separator = strchr ( token , '=' ) ; if ( separator != NULL ) { * separator = '\\0' ; name = strTrimWhitespace ( token ) ; value = strTrimWhitespace ( separator + 1 ) ; n = osStrlen ( value ) ; if ( n > 0 && value [ n - 1 ] == \'\\""\' ) value [ n - 1 ] = '\\0' ; if ( value [ 0 ] == \'\\""\' ) value ++ ; if ( ! osStrcasecmp ( name , ""realm"" ) ) { strSafeCopy ( authContext -> realm , value , WEB_SOCKET_REALM_MAX_LEN ) ; } # if ( WEB_SOCKET_DIGEST_AUTH_SUPPORT == ENABLED ) else if ( ! osStrcasecmp ( name , ""nonce"" ) ) { strSafeCopy ( authContext -> nonce , value , WEB_SOCKET_NONCE_MAX_LEN + 1 ) ; } else if ( ! osStrcasecmp ( name , ""opaque"" ) ) { strSafeCopy ( authContext -> opaque , value , WEB_SOCKET_OPAQUE_MAX_LEN + 1 ) ; } else if ( ! osStrcasecmp ( name , ""stale"" ) ) { if ( ! osStrcasecmp ( value , ""true"" ) ) authContext -> stale = TRUE ; else authContext -> stale = FALSE ; } # endif token = osStrtok_r ( NULL , "","" , & p ) ; } } # endif return NO_ERROR ; } "," { separator = osStrchr ( token , ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 1119,CWE-125,"CWE-125 static int name_parse ( u8 * packet , int length , int * idx , char * name_out , int name_out_len ) { int name_end = - 1 ; int j = * idx ; int ptr_count = 0 ; # define GET32 ( x ) do { if ( j + 4 > length ) goto err ; memcpy ( & t32_ , packet + j , 4 ) ; j += 4 ; x = ntohl ( t32_ ) ; } while ( 0 ) # define GET16 ( x ) do { if ( j + 2 > length ) goto err ; memcpy ( & t_ , packet + j , 2 ) ; j += 2 ; x = ntohs ( t_ ) ; } while ( 0 ) # define GET8 ( x ) do { if ( j >= length ) goto err ; x = packet [ j ++ ] ; } while ( 0 ) char * cp = name_out ; const char * const end = name_out + name_out_len ; for ( ; ; ) { u8 label_len ; if ( j >= length ) return - 1 ; GET8 ( label_len ) ; if ( ! label_len ) break ; if ( label_len & 0xc0 ) { u8 ptr_low ; GET8 ( ptr_low ) ; if ( name_end < 0 ) name_end = j ; j = ( ( ( int ) label_len & 0x3f ) << 8 ) + ptr_low ; if ( j < 0 || j >= length ) return - 1 ; if ( ++ ptr_count > length ) return - 1 ; continue ; } if ( label_len > 63 ) return - 1 ; if ( cp != name_out ) { if ( cp + 1 >= end ) return - 1 ; * cp ++ = '.' ; } if ( cp + label_len >= end ) return - 1 ; memcpy ( cp , packet + j , label_len ) ; cp += label_len ; j += label_len ; } if ( cp >= end ) return - 1 ; * cp = '\\0' ; if ( name_end < 0 ) * idx = j ; else * idx = name_end ; return 0 ; err : return - 1 ; } "," u8 label_len ; GET8 ( label_len - 1 ; if ( j + label_len > length ) return - 1 ; ",libevent@libevent/96f64a022014a208105ead6c8a7066018449d86d,CVE-2016-10195,https://github.com/libevent/libevent/commit/96f64a022014a208105ead6c8a7066018449d86d,2017-03-15T15:59Z 1120,CWE-119,"CWE-119 static void fpAcc ( TIFF * tif , uint8 * cp0 , tmsize_t cc ) { tmsize_t stride = PredictorState ( tif ) -> stride ; uint32 bps = tif -> tif_dir . td_bitspersample / 8 ; tmsize_t wc = cc / bps ; tmsize_t count = cc ; uint8 * cp = ( uint8 * ) cp0 ; uint8 * tmp = ( uint8 * ) _TIFFmalloc ( cc ) ; assert ( ( cc % ( bps * stride ) ) == 0 ) ; if ( ! tmp ) return ; while ( count > stride ) { REPEAT4 ( stride , cp [ stride ] = ( unsigned char ) ( ( cp [ stride ] + cp [ 0 ] ) & 0xff ) ; cp ++ ) count -= stride ; } _TIFFmemcpy ( tmp , cp0 , cc ) ; cp = ( uint8 * ) cp0 ; for ( count = 0 ; count < wc ; count ++ ) { uint32 byte ; for ( byte = 0 ; byte < bps ; byte ++ ) { # if WORDS_BIGENDIAN cp [ bps * count + byte ] = tmp [ byte * wc + count ] ; # else cp [ bps * count + byte ] = tmp [ ( bps - byte - 1 ) * wc + count ] ; # endif } } _TIFFfree ( tmp ) ; } "," static int fpAcc ( TIFF cc ) ; if ( cc % * stride ) != 0 ) { TIFFErrorExt ( tif -> tif_clientdata , ""fpAcc"" , ""%s"" , ""cc%(bps*stride))!=0"" ) ; return 0 ; } if ( ! tmp ) return 0 tmp ) ; return 1 ; ",vadz@libtiff/3ca657a8793dd011bf869695d72ad31c779c3cc1,CVE-2016-9535,https://github.com/vadz/libtiff/commit/3ca657a8793dd011bf869695d72ad31c779c3cc1,2016-11-22T19:59Z 1121,CWE-20,"CWE-20 static int handle_pte_fault ( struct mm_struct * mm , struct vm_area_struct * vma , unsigned long address , pte_t * pte , pmd_t * pmd , unsigned int flags ) { pte_t entry ; spinlock_t * ptl ; entry = * pte ; barrier ( ) ; if ( ! pte_present ( entry ) ) { if ( pte_none ( entry ) ) { if ( vma -> vm_ops ) { if ( likely ( vma -> vm_ops -> fault ) ) return do_fault ( mm , vma , address , pte , pmd , flags , entry ) ; } return do_anonymous_page ( mm , vma , address , pte , pmd , flags ) ; } return do_swap_page ( mm , vma , address , pte , pmd , flags , entry ) ; } if ( pte_protnone ( entry ) ) return do_numa_page ( mm , vma , address , entry , pte , pmd ) ; ptl = pte_lockptr ( mm , pmd ) ; spin_lock ( ptl ) ; if ( unlikely ( ! pte_same ( * pte , entry ) ) ) goto unlock ; if ( flags & FAULT_FLAG_WRITE ) { if ( ! pte_write ( entry ) ) return do_wp_page ( mm , vma , address , pte , pmd , ptl , entry ) ; entry = pte_mkdirty ( entry ) ; } entry = pte_mkyoung ( entry ) ; if ( ptep_set_access_flags ( vma , address , pte , entry , flags & FAULT_FLAG_WRITE ) ) { update_mmu_cache ( vma , address , pte ) ; } else { if ( flags & FAULT_FLAG_WRITE ) flush_tlb_fix_spurious_fault ( vma , address ) ; } unlock : pte_unmap_unlock ( pte , ptl ) ; return 0 ; } "," -> vm_ops ) return do_fault ( , pte , pmd , flags , entry ) ; return do_anonymous_page ( , address , pte , pmd , flags ) ; ",torvalds@linux/6b7339f4c31ad69c8e9c0b2859276e22cf72176d,CVE-2015-3288,https://github.com/torvalds/linux/commit/6b7339f4c31ad69c8e9c0b2859276e22cf72176d,2016-10-16T21:59Z 1122,CWE-119,"CWE-119 static char * pool_strdup ( const char * s ) { char * r = pool_alloc ( strlen ( s ) + 1 ) ; strcpy ( r , s ) ; return r ; } "," s ) { size_t len = strlen ( s ) + 1 ; = pool_alloc ( len ) ; memcpy ( r , r , s , len ",git@git/34fa79a6cde56d6d428ab0d3160cb094ebad3305,CVE-2016-2315,https://github.com/git/git/commit/34fa79a6cde56d6d428ab0d3160cb094ebad3305,2016-04-08T14:59Z 1123,CWE-20,"CWE-20 void user_describe ( const struct key * key , struct seq_file * m ) { seq_puts ( m , key -> description ) ; if ( key_is_instantiated ( key ) ) seq_printf ( m , "":%u"" , key -> datalen ) ; } "," ; if ( key_is_positive ( key ) ",torvalds@linux/363b02dab09b3226f3bd1420dad9c72b79a42a76,CVE-2017-15951,https://github.com/torvalds/linux/commit/363b02dab09b3226f3bd1420dad9c72b79a42a76,2017-10-28T02:29Z 1124,CWE-264,"CWE-264 static ssize_t map_write ( struct file * file , const char __user * buf , size_t count , loff_t * ppos , int cap_setid , struct uid_gid_map * map , struct uid_gid_map * parent_map ) { struct seq_file * seq = file -> private_data ; struct user_namespace * ns = seq -> private ; struct uid_gid_map new_map ; unsigned idx ; struct uid_gid_extent * extent = NULL ; unsigned long page = 0 ; char * kbuf , * pos , * next_line ; ssize_t ret = - EINVAL ; mutex_lock ( & id_map_mutex ) ; ret = - EPERM ; if ( map -> nr_extents != 0 ) goto out ; if ( cap_valid ( cap_setid ) && ! ns_capable ( ns , cap_setid ) ) goto out ; ret = - ENOMEM ; page = __get_free_page ( GFP_TEMPORARY ) ; kbuf = ( char * ) page ; if ( ! page ) goto out ; ret = - EINVAL ; if ( ( * ppos != 0 ) || ( count >= PAGE_SIZE ) ) goto out ; ret = - EFAULT ; if ( copy_from_user ( kbuf , buf , count ) ) goto out ; kbuf [ count ] = '\\0' ; ret = - EINVAL ; pos = kbuf ; new_map . nr_extents = 0 ; for ( ; pos ; pos = next_line ) { extent = & new_map . extent [ new_map . nr_extents ] ; next_line = strchr ( pos , '\\n' ) ; if ( next_line ) { * next_line = '\\0' ; next_line ++ ; if ( * next_line == '\\0' ) next_line = NULL ; } pos = skip_spaces ( pos ) ; extent -> first = simple_strtoul ( pos , & pos , 10 ) ; if ( ! isspace ( * pos ) ) goto out ; pos = skip_spaces ( pos ) ; extent -> lower_first = simple_strtoul ( pos , & pos , 10 ) ; if ( ! isspace ( * pos ) ) goto out ; pos = skip_spaces ( pos ) ; extent -> count = simple_strtoul ( pos , & pos , 10 ) ; if ( * pos && ! isspace ( * pos ) ) goto out ; pos = skip_spaces ( pos ) ; if ( * pos != '\\0' ) goto out ; if ( ( extent -> first == ( u32 ) - 1 ) || ( extent -> lower_first == ( u32 ) - 1 ) ) goto out ; if ( ( extent -> first + extent -> count ) <= extent -> first ) goto out ; if ( ( extent -> lower_first + extent -> count ) <= extent -> lower_first ) goto out ; if ( mappings_overlap ( & new_map , extent ) ) goto out ; new_map . nr_extents ++ ; if ( ( new_map . nr_extents == UID_GID_MAP_MAX_EXTENTS ) && ( next_line != NULL ) ) goto out ; } if ( new_map . nr_extents == 0 ) goto out ; ret = - EPERM ; if ( ! new_idmap_permitted ( ns , cap_setid , & new_map ) ) goto out ; for ( idx = 0 ; idx < new_map . nr_extents ; idx ++ ) { u32 lower_first ; extent = & new_map . extent [ idx ] ; lower_first = map_id_range_down ( parent_map , extent -> lower_first , extent -> count ) ; if ( lower_first == ( u32 ) - 1 ) goto out ; extent -> lower_first = lower_first ; } memcpy ( map -> extent , new_map . extent , new_map . nr_extents * sizeof ( new_map . extent [ 0 ] ) ) ; smp_wmb ( ) ; map -> nr_extents = new_map . nr_extents ; * ppos = count ; ret = count ; out : mutex_unlock ( & id_map_mutex ) ; if ( page ) free_page ( page ) ; return ret ; } "," ! new_idmap_permitted ( file , ",torvalds@linux/6708075f104c3c9b04b23336bb0366ca30c3931b,CVE-2013-1959,https://github.com/torvalds/linux/commit/6708075f104c3c9b04b23336bb0366ca30c3931b,2013-05-03T11:57Z 1125,CWE-119,"CWE-119 static const ut8 * r_bin_dwarf_parse_comp_unit ( Sdb * s , const ut8 * obuf , RBinDwarfCompUnit * cu , const RBinDwarfDebugAbbrev * da , size_t offset , const ut8 * debug_str , size_t debug_str_len ) { const ut8 * buf = obuf , * buf_end = obuf + ( cu -> hdr . length - 7 ) ; ut64 abbr_code ; size_t i ; if ( cu -> hdr . length > debug_str_len ) { return NULL ; } while ( buf && buf < buf_end && buf >= obuf ) { if ( cu -> length && cu -> capacity == cu -> length ) { r_bin_dwarf_expand_cu ( cu ) ; } buf = r_uleb128 ( buf , buf_end - buf , & abbr_code ) ; if ( abbr_code > da -> length || ! buf ) { return NULL ; } r_bin_dwarf_init_die ( & cu -> dies [ cu -> length ] ) ; if ( ! abbr_code ) { cu -> dies [ cu -> length ] . abbrev_code = 0 ; cu -> length ++ ; buf ++ ; continue ; } cu -> dies [ cu -> length ] . abbrev_code = abbr_code ; cu -> dies [ cu -> length ] . tag = da -> decls [ abbr_code - 1 ] . tag ; abbr_code += offset ; if ( da -> capacity < abbr_code ) { return NULL ; } for ( i = 0 ; i < da -> decls [ abbr_code - 1 ] . length ; i ++ ) { if ( cu -> dies [ cu -> length ] . length == cu -> dies [ cu -> length ] . capacity ) { r_bin_dwarf_expand_die ( & cu -> dies [ cu -> length ] ) ; } if ( i >= cu -> dies [ cu -> length ] . capacity || i >= da -> decls [ abbr_code - 1 ] . capacity ) { eprintf ( ""Warning:malformeddwarfattributecapacitydoesn\'tmatchlength\\n"" ) ; break ; } memset ( & cu -> dies [ cu -> length ] . attr_values [ i ] , 0 , sizeof ( cu -> dies [ cu -> length ] . attr_values [ i ] ) ) ; buf = r_bin_dwarf_parse_attr_value ( buf , buf_end - buf , & da -> decls [ abbr_code - 1 ] . specs [ i ] , & cu -> dies [ cu -> length ] . attr_values [ i ] , & cu -> hdr , debug_str , debug_str_len ) ; if ( cu -> dies [ cu -> length ] . attr_values [ i ] . name == DW_AT_comp_dir ) { const char * name = cu -> dies [ cu -> length ] . attr_values [ i ] . encoding . str_struct . string ; sdb_set ( s , ""DW_AT_comp_dir"" , name , 0 ) ; } cu -> dies [ cu -> length ] . length ++ ; } cu -> length ++ ; } return buf ; } "," . string ; if ( name > 1024 ) { ) ; } else { eprintf ( ""Invalidstringpointerat%p\\n"" , name ) ; } } ",radare@radare2/bd1bab05083d80464fea854bf4b5c49aaf1b8401,CVE-2018-14015,https://github.com/radare/radare2/commit/bd1bab05083d80464fea854bf4b5c49aaf1b8401,2018-07-12T20:29Z 1126,CWE-120,"CWE-120 static block_t * Encode ( encoder_t * p_enc , picture_t * p_pic ) { encoder_sys_t * p_sys = p_enc -> p_sys ; block_t * p_block , * p_output_chain = NULL ; SchroFrame * p_frame ; bool b_go = true ; if ( ! p_pic ) { if ( ! p_sys -> started || p_sys -> b_eos_pulled ) return NULL ; if ( ! p_sys -> b_eos_signalled ) { p_sys -> b_eos_signalled = 1 ; schro_encoder_end_of_stream ( p_sys -> p_schro ) ; } } else { p_sys -> p_format -> interlaced = ! p_pic -> b_progressive ; p_sys -> p_format -> top_field_first = p_pic -> b_top_field_first ; if ( p_sys -> b_auto_field_coding ) schro_encoder_setting_set_double ( p_sys -> p_schro , ""interlaced_coding"" , ! p_pic -> b_progressive ) ; } if ( ! p_sys -> started ) { date_t date ; if ( p_pic -> format . i_chroma != p_enc -> fmt_in . i_codec ) { char chroma_in [ 5 ] , chroma_out [ 5 ] ; vlc_fourcc_to_char ( p_pic -> format . i_chroma , chroma_in ) ; chroma_in [ 4 ] = '\\0' ; chroma_out [ 4 ] = '\\0' ; vlc_fourcc_to_char ( p_enc -> fmt_in . i_codec , chroma_out ) ; msg_Warn ( p_enc , ""Resettingchromafrom%sto%s"" , chroma_out , chroma_in ) ; if ( ! SetEncChromaFormat ( p_enc , p_pic -> format . i_chroma ) ) { msg_Err ( p_enc , ""Couldnotresetchromaformatto%s"" , chroma_in ) ; return NULL ; } } date_Init ( & date , p_enc -> fmt_in . video . i_frame_rate , p_enc -> fmt_in . video . i_frame_rate_base ) ; date_Increment ( & date , 1 ) ; p_sys -> i_pts_offset = date_Get ( & date ) ; if ( schro_encoder_setting_get_double ( p_sys -> p_schro , ""interlaced_coding"" ) > 0.0 ) { date_Set ( & date , 0 ) ; date_Increment ( & date , 1 ) ; p_sys -> i_field_time = date_Get ( & date ) / 2 ; } schro_video_format_set_std_signal_range ( p_sys -> p_format , SCHRO_SIGNAL_RANGE_8BIT_VIDEO ) ; schro_encoder_set_video_format ( p_sys -> p_schro , p_sys -> p_format ) ; schro_encoder_start ( p_sys -> p_schro ) ; p_sys -> started = 1 ; } if ( ! p_sys -> b_eos_signalled ) { picture_Hold ( p_pic ) ; p_frame = CreateSchroFrameFromInputPic ( p_enc , p_pic ) ; if ( ! p_frame ) return NULL ; schro_encoder_push_frame ( p_sys -> p_schro , p_frame ) ; StorePicturePTS ( p_enc , p_sys -> i_input_picnum , p_pic -> date ) ; p_sys -> i_input_picnum ++ ; p_block = block_Alloc ( 1 ) ; if ( ! p_block ) return NULL ; p_block -> i_dts = p_pic -> date - p_sys -> i_pts_offset ; block_FifoPut ( p_sys -> p_dts_fifo , p_block ) ; p_block = NULL ; if ( schro_encoder_setting_get_double ( p_sys -> p_schro , ""interlaced_coding"" ) > 0.0 ) { StorePicturePTS ( p_enc , p_sys -> i_input_picnum , p_pic -> date + p_sys -> i_field_time ) ; p_sys -> i_input_picnum ++ ; p_block = block_Alloc ( 1 ) ; if ( ! p_block ) return NULL ; p_block -> i_dts = p_pic -> date - p_sys -> i_pts_offset + p_sys -> i_field_time ; block_FifoPut ( p_sys -> p_dts_fifo , p_block ) ; p_block = NULL ; } } do { SchroStateEnum state ; state = schro_encoder_wait ( p_sys -> p_schro ) ; switch ( state ) { case SCHRO_STATE_NEED_FRAME : b_go = false ; break ; case SCHRO_STATE_AGAIN : break ; case SCHRO_STATE_END_OF_STREAM : p_sys -> b_eos_pulled = 1 ; b_go = false ; break ; case SCHRO_STATE_HAVE_BUFFER : { SchroBuffer * p_enc_buf ; uint32_t u_pic_num ; int i_presentation_frame ; p_enc_buf = schro_encoder_pull ( p_sys -> p_schro , & i_presentation_frame ) ; p_block = block_Alloc ( p_enc_buf -> length ) ; if ( ! p_block ) return NULL ; memcpy ( p_block -> p_buffer , p_enc_buf -> data , p_enc_buf -> length ) ; schro_buffer_unref ( p_enc_buf ) ; if ( 0 == p_block -> p_buffer [ 4 ] ) { p_block -> i_flags |= BLOCK_FLAG_TYPE_I ; if ( ! p_enc -> fmt_out . p_extra ) { const uint8_t eos [ ] = { 'B' , 'B' , 'C' , 'D' , 0x10 , 0 , 0 , 0 , 13 , 0 , 0 , 0 , 0 } ; uint32_t len = GetDWBE ( p_block -> p_buffer + 5 ) ; p_enc -> fmt_out . p_extra = malloc ( len + sizeof ( eos ) ) ; if ( ! p_enc -> fmt_out . p_extra ) return NULL ; memcpy ( p_enc -> fmt_out . p_extra , p_block -> p_buffer , len ) ; memcpy ( ( uint8_t * ) p_enc -> fmt_out . p_extra + len , eos , sizeof ( eos ) ) ; SetDWBE ( ( uint8_t * ) p_enc -> fmt_out . p_extra + len + sizeof ( eos ) - 4 , len ) ; p_enc -> fmt_out . i_extra = len + sizeof ( eos ) ; } } if ( ReadDiracPictureNumber ( & u_pic_num , p_block ) ) { block_t * p_dts_block = block_FifoGet ( p_sys -> p_dts_fifo ) ; p_block -> i_dts = p_dts_block -> i_dts ; p_block -> i_pts = GetPicturePTS ( p_enc , u_pic_num ) ; block_Release ( p_dts_block ) ; block_ChainAppend ( & p_output_chain , p_block ) ; } else { block_ChainAppend ( & p_output_chain , p_block ) ; } break ; } default : break ; } } while ( b_go ) ; return p_output_chain ; } "," 5 ) ; if ( len > UINT32_MAX - sizeof ( eos ) ) return NULL ; ",videolan@vlc/9bb0353a5c63a7f8c6fc853faa3df4b4df1f5eb5,CVE-2014-9629,https://github.com/videolan/vlc/commit/9bb0353a5c63a7f8c6fc853faa3df4b4df1f5eb5,2020-01-24T22:15Z 1127,CWE-134,"CWE-134 static mf_t * open_mf_pattern ( void * talloc_ctx , struct demuxer * d , char * filename ) { struct mp_log * log = d -> log ; int error_count = 0 ; int count = 0 ; mf_t * mf = talloc_zero ( talloc_ctx , mf_t ) ; mf -> log = log ; if ( filename [ 0 ] == '@' ) { struct stream * s = stream_create ( filename + 1 , d -> stream_origin | STREAM_READ , d -> cancel , d -> global ) ; if ( s ) { while ( 1 ) { char buf [ 512 ] ; int len = stream_read_peek ( s , buf , sizeof ( buf ) ) ; if ( ! len ) break ; bstr data = ( bstr ) { buf , len } ; int pos = bstrchr ( data , '\\n' ) ; data = bstr_splice ( data , 0 , pos < 0 ? data . len : pos + 1 ) ; bstr fname = bstr_strip ( data ) ; if ( fname . len ) { if ( bstrchr ( fname , '\\0' ) >= 0 ) { mp_err ( log , ""invalidfilename\\n"" ) ; break ; } char * entry = bstrto0 ( mf , fname ) ; if ( ! mp_path_exists ( entry ) ) { mp_verbose ( log , ""filenotfound:\'%s\'\\n"" , entry ) ; } else { MP_TARRAY_APPEND ( mf , mf -> names , mf -> nr_of_files , entry ) ; } } stream_seek_skip ( s , stream_tell ( s ) + data . len ) ; } free_stream ( s ) ; mp_info ( log , ""numberoffiles:%d\\n"" , mf -> nr_of_files ) ; goto exit_mf ; } mp_info ( log , ""%sisnotindirectfilelist\\n"" , filename + 1 ) ; } if ( strchr ( filename , ',' ) ) { mp_info ( log , ""filelist:%s\\n"" , filename ) ; bstr bfilename = bstr0 ( filename ) ; while ( bfilename . len ) { bstr bfname ; bstr_split_tok ( bfilename , "","" , & bfname , & bfilename ) ; char * fname2 = bstrdup0 ( mf , bfname ) ; if ( ! mp_path_exists ( fname2 ) ) mp_verbose ( log , ""filenotfound:\'%s\'\\n"" , fname2 ) ; else { mf_add ( mf , fname2 ) ; } talloc_free ( fname2 ) ; } mp_info ( log , ""numberoffiles:%d\\n"" , mf -> nr_of_files ) ; goto exit_mf ; } char * fname = talloc_size ( mf , strlen ( filename ) + 32 ) ; # if HAVE_GLOB if ( ! strchr ( filename , '%' ) ) { strcpy ( fname , filename ) ; if ( ! strchr ( filename , '*' ) ) strcat ( fname , ""*"" ) ; mp_info ( log , ""searchexpr:%s\\n"" , fname ) ; glob_t gg ; if ( glob ( fname , 0 , NULL , & gg ) ) { talloc_free ( mf ) ; return NULL ; } for ( int i = 0 ; i < gg . gl_pathc ; i ++ ) { if ( mp_path_isdir ( gg . gl_pathv [ i ] ) ) continue ; mf_add ( mf , gg . gl_pathv [ i ] ) ; } mp_info ( log , ""numberoffiles:%d\\n"" , mf -> nr_of_files ) ; globfree ( & gg ) ; goto exit_mf ; } # endif mp_info ( log , ""searchexpr:%s\\n"" , filename ) ; while ( error_count < 5 ) { sprintf ( fname , filename , count ++ ) ; if ( ! mp_path_exists ( fname ) ) { error_count ++ ; mp_verbose ( log , ""filenotfound:\'%s\'\\n"" , fname ) ; } else { mf_add ( mf , fname ) ; } } mp_info ( log , ""numberoffiles:%d\\n"" , mf -> nr_of_files ) ; exit_mf : return mf ; } "," exit_mf ; } size_t fname_avail = strlen ( filename ) + 32 ; char * fname = talloc_size ( mf , fname_avail } # endif const char * f = filename ; int MAXDIGS = 3 , nspec = 0 , bad_spec = 0 , c ; while ( nspec < 2 && ( c = * f ++ ) ) { if ( c != '%' ) continue ; if ( * f != '%' ) { nspec ++ ; if ( * f == '.' ) f ++ ; for ( int ndig = 0 ; mp_isdigit ( * f ) && ndig < MAXDIGS ; ndig ++ , f ++ ) ; if ( * f != 'd' ) { bad_spec ++ ; break ; } } f ++ ; } if ( bad_spec || nspec != 1 ) { mp_err ( log , ""unsupportedexprformat:\'%s\'\\n"" , filename ) ; goto exit_mf ; } 5 ) { if ( snprintf ( fname , fname_avail , filename , count ++ ) >= fname_avail ) { mp_err ( log , ""formatresulttoolong:\'%s\'\\n"" , filename ) ; goto exit_mf ; } if ( ! ",mpv-player@mpv/d0c530919d8cd4d7a774e38ab064e0fabdae34e6,CVE-2021-30145,https://github.com/mpv-player/mpv/commit/d0c530919d8cd4d7a774e38ab064e0fabdae34e6,2021-05-18T14:15Z 1128,CWE-125,"CWE-125 void ip6_print ( netdissect_options * ndo , const u_char * bp , u_int length ) { register const struct ip6_hdr * ip6 ; register int advance ; u_int len ; const u_char * ipend ; register const u_char * cp ; register u_int payload_len ; int nh ; int fragmented = 0 ; u_int flow ; ip6 = ( const struct ip6_hdr * ) bp ; ND_TCHECK ( * ip6 ) ; if ( length < sizeof ( struct ip6_hdr ) ) { ND_PRINT ( ( ndo , ""truncated-ip6%u"" , length ) ) ; return ; } if ( ! ndo -> ndo_eflag ) ND_PRINT ( ( ndo , ""IP6"" ) ) ; if ( IP6_VERSION ( ip6 ) != 6 ) { ND_PRINT ( ( ndo , ""versionerror:%u!=6"" , IP6_VERSION ( ip6 ) ) ) ; return ; } payload_len = EXTRACT_16BITS ( & ip6 -> ip6_plen ) ; len = payload_len + sizeof ( struct ip6_hdr ) ; if ( length < len ) ND_PRINT ( ( ndo , ""truncated-ip6-%ubytesmissing!"" , len - length ) ) ; if ( ndo -> ndo_vflag ) { flow = EXTRACT_32BITS ( & ip6 -> ip6_flow ) ; ND_PRINT ( ( ndo , ""("" ) ) ; # if 0 if ( flow & 0x0f000000 ) ND_PRINT ( ( ndo , ""pri0x%02x,"" , ( flow & 0x0f000000 ) >> 24 ) ) ; if ( flow & 0x00ffffff ) ND_PRINT ( ( ndo , ""flowlabel0x%06x,"" , flow & 0x00ffffff ) ) ; # else if ( flow & 0x0ff00000 ) ND_PRINT ( ( ndo , ""class0x%02x,"" , ( flow & 0x0ff00000 ) >> 20 ) ) ; if ( flow & 0x000fffff ) ND_PRINT ( ( ndo , ""flowlabel0x%05x,"" , flow & 0x000fffff ) ) ; # endif ND_PRINT ( ( ndo , ""hlim%u,next-header%s(%u)payloadlength:%u)"" , ip6 -> ip6_hlim , tok2str ( ipproto_values , ""unknown"" , ip6 -> ip6_nxt ) , ip6 -> ip6_nxt , payload_len ) ) ; } ipend = bp + len ; if ( ipend < ndo -> ndo_snapend ) ndo -> ndo_snapend = ipend ; cp = ( const u_char * ) ip6 ; advance = sizeof ( struct ip6_hdr ) ; nh = ip6 -> ip6_nxt ; while ( cp < ndo -> ndo_snapend && advance > 0 ) { cp += advance ; len -= advance ; if ( cp == ( const u_char * ) ( ip6 + 1 ) && nh != IPPROTO_TCP && nh != IPPROTO_UDP && nh != IPPROTO_DCCP && nh != IPPROTO_SCTP ) { ND_PRINT ( ( ndo , ""%s>%s:"" , ip6addr_string ( ndo , & ip6 -> ip6_src ) , ip6addr_string ( ndo , & ip6 -> ip6_dst ) ) ) ; } switch ( nh ) { case IPPROTO_HOPOPTS : advance = hbhopt_print ( ndo , cp ) ; if ( advance < 0 ) return ; nh = * cp ; break ; case IPPROTO_DSTOPTS : advance = dstopt_print ( ndo , cp ) ; if ( advance < 0 ) return ; nh = * cp ; break ; case IPPROTO_FRAGMENT : advance = frag6_print ( ndo , cp , ( const u_char * ) ip6 ) ; if ( advance < 0 || ndo -> ndo_snapend <= cp + advance ) return ; nh = * cp ; fragmented = 1 ; break ; case IPPROTO_MOBILITY_OLD : case IPPROTO_MOBILITY : advance = mobility_print ( ndo , cp , ( const u_char * ) ip6 ) ; nh = * cp ; return ; case IPPROTO_ROUTING : advance = rt6_print ( ndo , cp , ( const u_char * ) ip6 ) ; nh = * cp ; break ; case IPPROTO_SCTP : sctp_print ( ndo , cp , ( const u_char * ) ip6 , len ) ; return ; case IPPROTO_DCCP : dccp_print ( ndo , cp , ( const u_char * ) ip6 , len ) ; return ; case IPPROTO_TCP : tcp_print ( ndo , cp , len , ( const u_char * ) ip6 , fragmented ) ; return ; case IPPROTO_UDP : udp_print ( ndo , cp , len , ( const u_char * ) ip6 , fragmented ) ; return ; case IPPROTO_ICMPV6 : icmp6_print ( ndo , cp , len , ( const u_char * ) ip6 , fragmented ) ; return ; case IPPROTO_AH : advance = ah_print ( ndo , cp ) ; nh = * cp ; break ; case IPPROTO_ESP : { int enh , padlen ; advance = esp_print ( ndo , cp , len , ( const u_char * ) ip6 , & enh , & padlen ) ; nh = enh & 0xff ; len -= padlen ; break ; } case IPPROTO_IPCOMP : { ipcomp_print ( ndo , cp ) ; advance = - 1 ; break ; } case IPPROTO_PIM : pim_print ( ndo , cp , len , ( const u_char * ) ip6 ) ; return ; case IPPROTO_OSPF : ospf6_print ( ndo , cp , len ) ; return ; case IPPROTO_IPV6 : ip6_print ( ndo , cp , len ) ; return ; case IPPROTO_IPV4 : ip_print ( ndo , cp , len ) ; return ; case IPPROTO_PGM : pgm_print ( ndo , cp , len , ( const u_char * ) ip6 ) ; return ; case IPPROTO_GRE : gre_print ( ndo , cp , len ) ; return ; case IPPROTO_RSVP : rsvp_print ( ndo , cp , len ) ; return ; case IPPROTO_NONE : ND_PRINT ( ( ndo , ""nonextheader"" ) ) ; return ; default : ND_PRINT ( ( ndo , ""ip-proto-%d%d"" , nh , len ) ) ; return ; } } return ; trunc : ND_PRINT ( ( ndo , ""[|ip6]"" ) ) ; } "," 0 ) { if ( len < ( u_int ) advance ) goto trunc ; ip6 ) ; if ( advance < 0 ) return ; case IPPROTO_ROUTING : ND_TCHECK ( * cp ) ; ip6 ) ; if ( advance < 0 ) return ; , cp ) ; if ( advance < 0 ) return padlen ) ; if ( advance < 0 ) return ; ",the-tcpdump-group@tcpdump/66df248b49095c261138b5a5e34d341a6bf9ac7f,CVE-2017-12985,https://github.com/the-tcpdump-group/tcpdump/commit/66df248b49095c261138b5a5e34d341a6bf9ac7f,2017-09-14T06:29Z 1129,CWE-125,"CWE-125 MAPI_Attr * * mapi_attr_read ( size_t len , unsigned char * buf ) { size_t idx = 0 ; uint32 i , j ; assert ( len > 4 ) ; uint32 num_properties = GETINT32 ( buf + idx ) ; MAPI_Attr * * attrs = CHECKED_XMALLOC ( MAPI_Attr * , ( num_properties + 1 ) ) ; idx += 4 ; if ( ! attrs ) return NULL ; for ( i = 0 ; i < num_properties ; i ++ ) { MAPI_Attr * a = attrs [ i ] = CHECKED_XCALLOC ( MAPI_Attr , 1 ) ; MAPI_Value * v = NULL ; CHECKINT16 ( idx , len ) ; a -> type = GETINT16 ( buf + idx ) ; idx += 2 ; CHECKINT16 ( idx , len ) ; a -> name = GETINT16 ( buf + idx ) ; idx += 2 ; if ( a -> name & GUID_EXISTS_FLAG ) { a -> guid = CHECKED_XMALLOC ( GUID , 1 ) ; copy_guid_from_buf ( a -> guid , buf + idx , len ) ; idx += sizeof ( GUID ) ; CHECKINT32 ( idx , len ) ; a -> num_names = GETINT32 ( buf + idx ) ; idx += 4 ; if ( a -> num_names > 0 ) { size_t i ; a -> names = CHECKED_XCALLOC ( VarLenData , a -> num_names ) ; for ( i = 0 ; i < a -> num_names ; i ++ ) { size_t j ; CHECKINT32 ( idx , len ) ; a -> names [ i ] . len = GETINT32 ( buf + idx ) ; idx += 4 ; a -> names [ i ] . data = CHECKED_XMALLOC ( unsigned char , a -> names [ i ] . len ) ; for ( j = 0 ; j < ( a -> names [ i ] . len >> 1 ) ; j ++ ) a -> names [ i ] . data [ j ] = ( buf + idx ) [ j * 2 ] ; idx += pad_to_4byte ( a -> names [ i ] . len ) ; } } else { CHECKINT32 ( idx , len ) ; a -> name = GETINT32 ( buf + idx ) ; idx += 4 ; } } if ( a -> type & MULTI_VALUE_FLAG || a -> type == szMAPI_STRING || a -> type == szMAPI_UNICODE_STRING || a -> type == szMAPI_OBJECT || a -> type == szMAPI_BINARY ) { CHECKINT32 ( idx , len ) ; a -> num_values = GETINT32 ( buf + idx ) ; idx += 4 ; } else { a -> num_values = 1 ; } if ( a -> type & MULTI_VALUE_FLAG ) { a -> type -= MULTI_VALUE_FLAG ; } v = alloc_mapi_values ( a ) ; for ( j = 0 ; j < a -> num_values ; j ++ ) { switch ( a -> type ) { case szMAPI_SHORT : v -> len = 2 ; CHECKINT16 ( idx , len ) ; v -> data . bytes2 = GETINT16 ( buf + idx ) ; idx += 4 ; break ; case szMAPI_INT : v -> len = 4 ; CHECKINT32 ( idx , len ) ; v -> data . bytes4 = GETINT32 ( buf + idx ) ; idx += 4 ; v ++ ; break ; case szMAPI_FLOAT : case szMAPI_BOOLEAN : v -> len = 4 ; CHECKINT32 ( idx , len ) ; v -> data . bytes4 = GETINT32 ( buf + idx ) ; idx += v -> len ; break ; case szMAPI_SYSTIME : v -> len = 8 ; CHECKINT32 ( idx , len ) ; v -> data . bytes8 [ 0 ] = GETINT32 ( buf + idx ) ; CHECKINT32 ( idx + 4 , len ) ; v -> data . bytes8 [ 1 ] = GETINT32 ( buf + idx + 4 ) ; idx += 8 ; v ++ ; break ; case szMAPI_DOUBLE : case szMAPI_APPTIME : case szMAPI_CURRENCY : case szMAPI_INT8BYTE : v -> len = 8 ; CHECKINT32 ( idx , len ) ; v -> data . bytes8 [ 0 ] = GETINT32 ( buf + idx ) ; CHECKINT32 ( idx + 4 , len ) ; v -> data . bytes8 [ 1 ] = GETINT32 ( buf + idx + 4 ) ; idx += v -> len ; break ; case szMAPI_CLSID : v -> len = sizeof ( GUID ) ; copy_guid_from_buf ( & v -> data . guid , buf + idx , len ) ; idx += v -> len ; break ; case szMAPI_STRING : case szMAPI_UNICODE_STRING : case szMAPI_OBJECT : case szMAPI_BINARY : CHECKINT32 ( idx , len ) ; v -> len = GETINT32 ( buf + idx ) ; idx += 4 ; if ( a -> type == szMAPI_UNICODE_STRING ) { v -> data . buf = ( unsigned char * ) unicode_to_utf8 ( v -> len , buf + idx ) ; } else { v -> data . buf = CHECKED_XMALLOC ( unsigned char , v -> len ) ; memmove ( v -> data . buf , buf + idx , v -> len ) ; } idx += pad_to_4byte ( v -> len ) ; v ++ ; break ; case szMAPI_NULL : case szMAPI_ERROR : case szMAPI_UNSPECIFIED : fprintf ( stderr , ""Invalidattribute,inputfilemaybecorrupted\\n"" ) ; if ( ! ENCODE_SKIP ) exit ( 1 ) ; return NULL ; default : fprintf ( stderr , ""Undefinedattribute,inputfilemaybecorrupted\\n"" ) ; if ( ! ENCODE_SKIP ) exit ( 1 ) ; return NULL ; } if ( DEBUG_ON ) mapi_attr_dump ( attrs [ i ] ) ; } } attrs [ i ] = NULL ; return attrs ; } "," buf + idx ) ; assert ( ( num_properties + 1 ) != 0 len ) ; assert ( ( idx + ( a -> names [ i ] . len * 2 ) ) <= len ) ; += 4 ; assert ( v -> len + idx <= len ) ; szMAPI_UNICODE_STRING ) { assert ( v -> len != 0 ) ; ",verdammelt@tnef/1a17af1ed0c791aec44dbdc9eab91218cc1e335a,CVE-2017-6307,https://github.com/verdammelt/tnef/commit/1a17af1ed0c791aec44dbdc9eab91218cc1e335a,2017-02-24T04:59Z 1130,CWE-000,"CWE-000 static int udf_read_inode ( struct inode * inode , bool hidden_inode ) { struct buffer_head * bh = NULL ; struct fileEntry * fe ; struct extendedFileEntry * efe ; uint16_t ident ; struct udf_inode_info * iinfo = UDF_I ( inode ) ; struct udf_sb_info * sbi = UDF_SB ( inode -> i_sb ) ; struct kernel_lb_addr * iloc = & iinfo -> i_location ; unsigned int link_count ; unsigned int indirections = 0 ; int ret = - EIO ; reread : if ( iloc -> logicalBlockNum >= sbi -> s_partmaps [ iloc -> partitionReferenceNum ] . s_partition_len ) { udf_debug ( ""block=%d,partition=%doutofrange\\n"" , iloc -> logicalBlockNum , iloc -> partitionReferenceNum ) ; return - EIO ; } bh = udf_read_ptagged ( inode -> i_sb , iloc , 0 , & ident ) ; if ( ! bh ) { udf_err ( inode -> i_sb , ""(ino%ld)failed!bh\\n"" , inode -> i_ino ) ; return - EIO ; } if ( ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE && ident != TAG_IDENT_USE ) { udf_err ( inode -> i_sb , ""(ino%ld)failedident=%d\\n"" , inode -> i_ino , ident ) ; goto out ; } fe = ( struct fileEntry * ) bh -> b_data ; efe = ( struct extendedFileEntry * ) bh -> b_data ; if ( fe -> icbTag . strategyType == cpu_to_le16 ( 4096 ) ) { struct buffer_head * ibh ; ibh = udf_read_ptagged ( inode -> i_sb , iloc , 1 , & ident ) ; if ( ident == TAG_IDENT_IE && ibh ) { struct kernel_lb_addr loc ; struct indirectEntry * ie ; ie = ( struct indirectEntry * ) ibh -> b_data ; loc = lelb_to_cpu ( ie -> indirectICB . extLocation ) ; if ( ie -> indirectICB . extLength ) { brelse ( ibh ) ; memcpy ( & iinfo -> i_location , & loc , sizeof ( struct kernel_lb_addr ) ) ; if ( ++ indirections > UDF_MAX_ICB_NESTING ) { udf_err ( inode -> i_sb , ""toomanyICBsinICBhierarchy"" ""(max%dsupported)\\n"" , UDF_MAX_ICB_NESTING ) ; goto out ; } brelse ( bh ) ; goto reread ; } } brelse ( ibh ) ; } else if ( fe -> icbTag . strategyType != cpu_to_le16 ( 4 ) ) { udf_err ( inode -> i_sb , ""unsupportedstrategytype:%d\\n"" , le16_to_cpu ( fe -> icbTag . strategyType ) ) ; goto out ; } if ( fe -> icbTag . strategyType == cpu_to_le16 ( 4 ) ) iinfo -> i_strat4096 = 0 ; else iinfo -> i_strat4096 = 1 ; iinfo -> i_alloc_type = le16_to_cpu ( fe -> icbTag . flags ) & ICBTAG_FLAG_AD_MASK ; iinfo -> i_unique = 0 ; iinfo -> i_lenEAttr = 0 ; iinfo -> i_lenExtents = 0 ; iinfo -> i_lenAlloc = 0 ; iinfo -> i_next_alloc_block = 0 ; iinfo -> i_next_alloc_goal = 0 ; if ( fe -> descTag . tagIdent == cpu_to_le16 ( TAG_IDENT_EFE ) ) { iinfo -> i_efe = 1 ; iinfo -> i_use = 0 ; ret = udf_alloc_i_data ( inode , inode -> i_sb -> s_blocksize - sizeof ( struct extendedFileEntry ) ) ; if ( ret ) goto out ; memcpy ( iinfo -> i_ext . i_data , bh -> b_data + sizeof ( struct extendedFileEntry ) , inode -> i_sb -> s_blocksize - sizeof ( struct extendedFileEntry ) ) ; } else if ( fe -> descTag . tagIdent == cpu_to_le16 ( TAG_IDENT_FE ) ) { iinfo -> i_efe = 0 ; iinfo -> i_use = 0 ; ret = udf_alloc_i_data ( inode , inode -> i_sb -> s_blocksize - sizeof ( struct fileEntry ) ) ; if ( ret ) goto out ; memcpy ( iinfo -> i_ext . i_data , bh -> b_data + sizeof ( struct fileEntry ) , inode -> i_sb -> s_blocksize - sizeof ( struct fileEntry ) ) ; } else if ( fe -> descTag . tagIdent == cpu_to_le16 ( TAG_IDENT_USE ) ) { iinfo -> i_efe = 0 ; iinfo -> i_use = 1 ; iinfo -> i_lenAlloc = le32_to_cpu ( ( ( struct unallocSpaceEntry * ) bh -> b_data ) -> lengthAllocDescs ) ; ret = udf_alloc_i_data ( inode , inode -> i_sb -> s_blocksize - sizeof ( struct unallocSpaceEntry ) ) ; if ( ret ) goto out ; memcpy ( iinfo -> i_ext . i_data , bh -> b_data + sizeof ( struct unallocSpaceEntry ) , inode -> i_sb -> s_blocksize - sizeof ( struct unallocSpaceEntry ) ) ; return 0 ; } ret = - EIO ; read_lock ( & sbi -> s_cred_lock ) ; i_uid_write ( inode , le32_to_cpu ( fe -> uid ) ) ; if ( ! uid_valid ( inode -> i_uid ) || UDF_QUERY_FLAG ( inode -> i_sb , UDF_FLAG_UID_IGNORE ) || UDF_QUERY_FLAG ( inode -> i_sb , UDF_FLAG_UID_SET ) ) inode -> i_uid = UDF_SB ( inode -> i_sb ) -> s_uid ; i_gid_write ( inode , le32_to_cpu ( fe -> gid ) ) ; if ( ! gid_valid ( inode -> i_gid ) || UDF_QUERY_FLAG ( inode -> i_sb , UDF_FLAG_GID_IGNORE ) || UDF_QUERY_FLAG ( inode -> i_sb , UDF_FLAG_GID_SET ) ) inode -> i_gid = UDF_SB ( inode -> i_sb ) -> s_gid ; if ( fe -> icbTag . fileType != ICBTAG_FILE_TYPE_DIRECTORY && sbi -> s_fmode != UDF_INVALID_MODE ) inode -> i_mode = sbi -> s_fmode ; else if ( fe -> icbTag . fileType == ICBTAG_FILE_TYPE_DIRECTORY && sbi -> s_dmode != UDF_INVALID_MODE ) inode -> i_mode = sbi -> s_dmode ; else inode -> i_mode = udf_convert_permissions ( fe ) ; inode -> i_mode &= ~ sbi -> s_umask ; read_unlock ( & sbi -> s_cred_lock ) ; link_count = le16_to_cpu ( fe -> fileLinkCount ) ; if ( ! link_count ) { if ( ! hidden_inode ) { ret = - ESTALE ; goto out ; } link_count = 1 ; } set_nlink ( inode , link_count ) ; inode -> i_size = le64_to_cpu ( fe -> informationLength ) ; iinfo -> i_lenExtents = inode -> i_size ; if ( iinfo -> i_efe == 0 ) { inode -> i_blocks = le64_to_cpu ( fe -> logicalBlocksRecorded ) << ( inode -> i_sb -> s_blocksize_bits - 9 ) ; if ( ! udf_disk_stamp_to_time ( & inode -> i_atime , fe -> accessTime ) ) inode -> i_atime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & inode -> i_mtime , fe -> modificationTime ) ) inode -> i_mtime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & inode -> i_ctime , fe -> attrTime ) ) inode -> i_ctime = sbi -> s_record_time ; iinfo -> i_unique = le64_to_cpu ( fe -> uniqueID ) ; iinfo -> i_lenEAttr = le32_to_cpu ( fe -> lengthExtendedAttr ) ; iinfo -> i_lenAlloc = le32_to_cpu ( fe -> lengthAllocDescs ) ; iinfo -> i_checkpoint = le32_to_cpu ( fe -> checkpoint ) ; } else { inode -> i_blocks = le64_to_cpu ( efe -> logicalBlocksRecorded ) << ( inode -> i_sb -> s_blocksize_bits - 9 ) ; if ( ! udf_disk_stamp_to_time ( & inode -> i_atime , efe -> accessTime ) ) inode -> i_atime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & inode -> i_mtime , efe -> modificationTime ) ) inode -> i_mtime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & iinfo -> i_crtime , efe -> createTime ) ) iinfo -> i_crtime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & inode -> i_ctime , efe -> attrTime ) ) inode -> i_ctime = sbi -> s_record_time ; iinfo -> i_unique = le64_to_cpu ( efe -> uniqueID ) ; iinfo -> i_lenEAttr = le32_to_cpu ( efe -> lengthExtendedAttr ) ; iinfo -> i_lenAlloc = le32_to_cpu ( efe -> lengthAllocDescs ) ; iinfo -> i_checkpoint = le32_to_cpu ( efe -> checkpoint ) ; } inode -> i_generation = iinfo -> i_unique ; switch ( fe -> icbTag . fileType ) { case ICBTAG_FILE_TYPE_DIRECTORY : inode -> i_op = & udf_dir_inode_operations ; inode -> i_fop = & udf_dir_operations ; inode -> i_mode |= S_IFDIR ; inc_nlink ( inode ) ; break ; case ICBTAG_FILE_TYPE_REALTIME : case ICBTAG_FILE_TYPE_REGULAR : case ICBTAG_FILE_TYPE_UNDEF : case ICBTAG_FILE_TYPE_VAT20 : if ( iinfo -> i_alloc_type == ICBTAG_FLAG_AD_IN_ICB ) inode -> i_data . a_ops = & udf_adinicb_aops ; else inode -> i_data . a_ops = & udf_aops ; inode -> i_op = & udf_file_inode_operations ; inode -> i_fop = & udf_file_operations ; inode -> i_mode |= S_IFREG ; break ; case ICBTAG_FILE_TYPE_BLOCK : inode -> i_mode |= S_IFBLK ; break ; case ICBTAG_FILE_TYPE_CHAR : inode -> i_mode |= S_IFCHR ; break ; case ICBTAG_FILE_TYPE_FIFO : init_special_inode ( inode , inode -> i_mode | S_IFIFO , 0 ) ; break ; case ICBTAG_FILE_TYPE_SOCKET : init_special_inode ( inode , inode -> i_mode | S_IFSOCK , 0 ) ; break ; case ICBTAG_FILE_TYPE_SYMLINK : inode -> i_data . a_ops = & udf_symlink_aops ; inode -> i_op = & udf_symlink_inode_operations ; inode -> i_mode = S_IFLNK | S_IRWXUGO ; break ; case ICBTAG_FILE_TYPE_MAIN : udf_debug ( ""METADATAFILE-----\\n"" ) ; break ; case ICBTAG_FILE_TYPE_MIRROR : udf_debug ( ""METADATAMIRRORFILE-----\\n"" ) ; break ; case ICBTAG_FILE_TYPE_BITMAP : udf_debug ( ""METADATABITMAPFILE-----\\n"" ) ; break ; default : udf_err ( inode -> i_sb , ""(ino%ld)failedunknownfiletype=%d\\n"" , inode -> i_ino , fe -> icbTag . fileType ) ; goto out ; } if ( S_ISCHR ( inode -> i_mode ) || S_ISBLK ( inode -> i_mode ) ) { struct deviceSpec * dsea = ( struct deviceSpec * ) udf_get_extendedattr ( inode , 12 , 1 ) ; if ( dsea ) { init_special_inode ( inode , inode -> i_mode , MKDEV ( le32_to_cpu ( dsea -> majorDeviceIdent ) , le32_to_cpu ( dsea -> minorDeviceIdent ) ) ) ; } else goto out ; } ret = 0 ; out : brelse ( bh ) ; return ret ; } "," -> i_unique ; if ( iinfo -> i_alloc_type == ICBTAG_FLAG_AD_IN_ICB ) { if ( iinfo -> i_lenAlloc != inode -> i_size ) goto out ; if ( inode -> i_size > inode -> i_sb -> s_blocksize - udf_file_entry_alloc_offset ( inode ) ) goto out ; } ",torvalds@linux/e159332b9af4b04d882dbcfe1bb0117f0a6d4b58,CVE-2014-9729,https://github.com/torvalds/linux/commit/e159332b9af4b04d882dbcfe1bb0117f0a6d4b58,2015-08-31T10:59Z 1131,CWE-667,"CWE-667 static int userfaultfd_unregister ( struct userfaultfd_ctx * ctx , unsigned long arg ) { struct mm_struct * mm = ctx -> mm ; struct vm_area_struct * vma , * prev , * cur ; int ret ; struct uffdio_range uffdio_unregister ; unsigned long new_flags ; bool found ; unsigned long start , end , vma_end ; const void __user * buf = ( void __user * ) arg ; ret = - EFAULT ; if ( copy_from_user ( & uffdio_unregister , buf , sizeof ( uffdio_unregister ) ) ) goto out ; ret = validate_range ( mm , uffdio_unregister . start , uffdio_unregister . len ) ; if ( ret ) goto out ; start = uffdio_unregister . start ; end = start + uffdio_unregister . len ; ret = - ENOMEM ; if ( ! mmget_not_zero ( mm ) ) goto out ; down_write ( & mm -> mmap_sem ) ; vma = find_vma_prev ( mm , start , & prev ) ; if ( ! vma ) goto out_unlock ; ret = - EINVAL ; if ( vma -> vm_start >= end ) goto out_unlock ; if ( is_vm_hugetlb_page ( vma ) ) { unsigned long vma_hpagesize = vma_kernel_pagesize ( vma ) ; if ( start & ( vma_hpagesize - 1 ) ) goto out_unlock ; } found = false ; ret = - EINVAL ; for ( cur = vma ; cur && cur -> vm_start < end ; cur = cur -> vm_next ) { cond_resched ( ) ; BUG_ON ( ! ! cur -> vm_userfaultfd_ctx . ctx ^ ! ! ( cur -> vm_flags & ( VM_UFFD_MISSING | VM_UFFD_WP ) ) ) ; if ( ! vma_can_userfault ( cur ) ) goto out_unlock ; found = true ; } BUG_ON ( ! found ) ; if ( vma -> vm_start < start ) prev = vma ; ret = 0 ; do { cond_resched ( ) ; BUG_ON ( ! vma_can_userfault ( vma ) ) ; if ( ! vma -> vm_userfaultfd_ctx . ctx ) goto skip ; WARN_ON ( ! ( vma -> vm_flags & VM_MAYWRITE ) ) ; if ( vma -> vm_start > start ) start = vma -> vm_start ; vma_end = min ( end , vma -> vm_end ) ; if ( userfaultfd_missing ( vma ) ) { struct userfaultfd_wake_range range ; range . start = start ; range . len = vma_end - start ; wake_userfault ( vma -> vm_userfaultfd_ctx . ctx , & range ) ; } new_flags = vma -> vm_flags & ~ ( VM_UFFD_MISSING | VM_UFFD_WP ) ; prev = vma_merge ( mm , prev , start , vma_end , new_flags , vma -> anon_vma , vma -> vm_file , vma -> vm_pgoff , vma_policy ( vma ) , NULL_VM_UFFD_CTX ) ; if ( prev ) { vma = prev ; goto next ; } if ( vma -> vm_start < start ) { ret = split_vma ( mm , vma , start , 1 ) ; if ( ret ) break ; } if ( vma -> vm_end > end ) { ret = split_vma ( mm , vma , end , 0 ) ; if ( ret ) break ; } next : vma -> vm_flags = new_flags ; vma -> vm_userfaultfd_ctx = NULL_VM_UFFD_CTX ; skip : prev = vma ; start = vma -> vm_end ; vma = vma -> vm_next ; } while ( vma && vma -> vm_start < end ) ; out_unlock : up_write ( & mm -> mmap_sem ) ; mmput ( mm ) ; out : return ret ; } "," mmap_sem ) ; if ( ! mmget_still_valid ( mm ) ) goto out_unlock ; ",torvalds@linux/04f5866e41fb70690e28397487d8bd8eea7d712a,CVE-2019-11599,https://github.com/torvalds/linux/commit/04f5866e41fb70690e28397487d8bd8eea7d712a,2019-04-29T18:29Z 1132,CWE-119,"CWE-119 static unsigned int tt_activity_measure ( VP8_COMP * cpi , MACROBLOCK * x ) { unsigned int act ; unsigned int sse ; act = vp8_variance16x16 ( x -> src . y_buffer , x -> src . y_stride , VP8_VAR_OFFS , 0 , & sse ) ; act = act << 4 ; if ( act < 8 << 12 ) act = act < 5 << 12 ? act : 5 << 12 ; return act ; } "," int sse ; ( void ) cpi ; act = vpx_variance16x16 ( x -> ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1133,CWE-119,"CWE-119 static void t1_check_unusual_charstring ( void ) { char * p = strstr ( t1_line_array , charstringname ) + strlen ( charstringname ) ; int i ; if ( sscanf ( p , ""%i"" , & i ) != 1 ) { strcpy ( t1_buf_array , t1_line_array ) ; * ( strend ( t1_buf_array ) - 1 ) = '' ; t1_getline ( ) ; strcat ( t1_buf_array , t1_line_array ) ; strcpy ( t1_line_array , t1_buf_array ) ; t1_line_ptr = eol ( t1_line_array ) ; } } "," ( ) ; alloc_array ( t1_buf , strlen ( t1_line_array ) + strlen ( t1_buf_array ) + 1 , T1_BUF_SIZE ) ; t1_buf_array , t1_line_array ) ; alloc_array ( t1_line , strlen ( t1_buf_array ) + 1 , T1_BUF_SIZE ",TeX-Live@texlive-source/6ed0077520e2b0da1fd060c7f88db7b2e6068e4c,CVE-2018-17407,https://github.com/TeX-Live/texlive-source/commit/6ed0077520e2b0da1fd060c7f88db7b2e6068e4c,2018-09-23T21:29Z 1134,CWE-119,"CWE-119 static vpx_codec_err_t ctrl_get_reference ( vpx_codec_alg_priv_t * ctx , int ctr_id , va_list args ) { vp9_ref_frame_t * data = va_arg ( args , vp9_ref_frame_t * ) ; if ( data ) { YV12_BUFFER_CONFIG * fb ; vp9_get_reference_dec ( ctx -> pbi , data -> idx , & fb ) ; yuvconfig2image ( & data -> img , fb , NULL ) ; return VPX_CODEC_OK ; } else { return VPX_CODEC_INVALID_PARAM ; } } "," * ctx , va_list args ) ; if ( ctx -> frame_parallel_decode ) { set_error_detail ( ctx , ""Notsupportedinframeparalleldecode"" ) ; return VPX_CODEC_INCAPABLE ; } if ( * fb ; VPxWorker * const worker = ctx -> frame_workers ; FrameWorkerData * const frame_worker_data = ( FrameWorkerData * ) worker -> data1 ; fb = get_ref_frame ( & frame_worker_data -> pbi -> common , data -> data -> idx ) ; if ( fb == NULL ) return VPX_CODEC_ERROR ; yuvconfig2image ( ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1135,CWE-000,"CWE-000 static int em_syscall ( struct x86_emulate_ctxt * ctxt ) { struct x86_emulate_ops * ops = ctxt -> ops ; struct desc_struct cs , ss ; u64 msr_data ; u16 cs_sel , ss_sel ; u64 efer = 0 ; if ( ctxt -> mode == X86EMUL_MODE_REAL || ctxt -> mode == X86EMUL_MODE_VM86 ) return emulate_ud ( ctxt ) ; ops -> get_msr ( ctxt , MSR_EFER , & efer ) ; setup_syscalls_segments ( ctxt , & cs , & ss ) ; ops -> get_msr ( ctxt , MSR_STAR , & msr_data ) ; msr_data >>= 32 ; cs_sel = ( u16 ) ( msr_data & 0xfffc ) ; ss_sel = ( u16 ) ( msr_data + 8 ) ; if ( efer & EFER_LMA ) { cs . d = 0 ; cs . l = 1 ; } ops -> set_segment ( ctxt , cs_sel , & cs , 0 , VCPU_SREG_CS ) ; ops -> set_segment ( ctxt , ss_sel , & ss , 0 , VCPU_SREG_SS ) ; ctxt -> regs [ VCPU_REGS_RCX ] = ctxt -> _eip ; if ( efer & EFER_LMA ) { # ifdef CONFIG_X86_64 ctxt -> regs [ VCPU_REGS_R11 ] = ctxt -> eflags & ~ EFLG_RF ; ops -> get_msr ( ctxt , ctxt -> mode == X86EMUL_MODE_PROT64 ? MSR_LSTAR : MSR_CSTAR , & msr_data ) ; ctxt -> _eip = msr_data ; ops -> get_msr ( ctxt , MSR_SYSCALL_MASK , & msr_data ) ; ctxt -> eflags &= ~ ( msr_data | EFLG_RF ) ; # endif } else { ops -> get_msr ( ctxt , MSR_STAR , & msr_data ) ; ctxt -> _eip = ( u32 ) msr_data ; ctxt -> eflags &= ~ ( EFLG_VM | EFLG_IF | EFLG_RF ) ; } return X86EMUL_CONTINUE ; } "," ctxt ) ; if ( ! ( em_syscall_is_enabled ( ctxt ) ) ) return emulate_ud ( ctxt ) ; , & ss ) ; if ( ! ( efer & EFER_SCE ) ) return emulate_ud ( ctxt ",torvalds@linux/c2226fc9e87ba3da060e47333657cd6616652b84,CVE-2012-0045,https://github.com/torvalds/linux/commit/c2226fc9e87ba3da060e47333657cd6616652b84,2012-07-03T16:40Z 1136,CWE-787,"CWE-787 static int cbs_jpeg_split_fragment ( CodedBitstreamContext * ctx , CodedBitstreamFragment * frag , int header ) { AVBufferRef * data_ref ; uint8_t * data ; size_t data_size ; int unit , start , end , marker , next_start , next_marker ; int err , i , j , length ; if ( frag -> data_size < 4 ) { return AVERROR_INVALIDDATA ; } for ( i = 0 ; i + 1 < frag -> data_size && frag -> data [ i ] != 0xff ; i ++ ) ; if ( i > 0 ) { av_log ( ctx -> log_ctx , AV_LOG_WARNING , ""Discarding%dbytesat"" ""beginningofimage.\\n"" , i ) ; } for ( ++ i ; i + 1 < frag -> data_size && frag -> data [ i ] == 0xff ; i ++ ) ; if ( i + 1 >= frag -> data_size && frag -> data [ i ] ) { av_log ( ctx -> log_ctx , AV_LOG_ERROR , ""InvalidJPEGimage:"" ""noSOImarkerfound.\\n"" ) ; return AVERROR_INVALIDDATA ; } marker = frag -> data [ i ] ; if ( marker != JPEG_MARKER_SOI ) { av_log ( ctx -> log_ctx , AV_LOG_ERROR , ""InvalidJPEGimage:first"" ""markeris%02x,shouldbeSOI.\\n"" , marker ) ; return AVERROR_INVALIDDATA ; } for ( ++ i ; i + 1 < frag -> data_size && frag -> data [ i ] == 0xff ; i ++ ) ; if ( i + 1 >= frag -> data_size ) { av_log ( ctx -> log_ctx , AV_LOG_ERROR , ""InvalidJPEGimage:"" ""noimagecontentfound.\\n"" ) ; return AVERROR_INVALIDDATA ; } marker = frag -> data [ i ] ; start = i + 1 ; for ( unit = 0 ; ; unit ++ ) { if ( marker == JPEG_MARKER_EOI ) { break ; } else if ( marker == JPEG_MARKER_SOS ) { for ( i = start ; i + 1 < frag -> data_size ; i ++ ) { if ( frag -> data [ i ] != 0xff ) continue ; end = i ; for ( ++ i ; i + 1 < frag -> data_size && frag -> data [ i ] == 0xff ; i ++ ) ; if ( i + 1 >= frag -> data_size ) { next_marker = - 1 ; } else { if ( frag -> data [ i ] == 0x00 ) continue ; next_marker = frag -> data [ i ] ; next_start = i + 1 ; } break ; } } else { i = start ; if ( i + 2 > frag -> data_size ) { av_log ( ctx -> log_ctx , AV_LOG_ERROR , ""InvalidJPEGimage:"" ""truncatedat%02xmarker.\\n"" , marker ) ; return AVERROR_INVALIDDATA ; } length = AV_RB16 ( frag -> data + i ) ; if ( i + length > frag -> data_size ) { av_log ( ctx -> log_ctx , AV_LOG_ERROR , ""InvalidJPEGimage:"" ""truncatedat%02xmarkersegment.\\n"" , marker ) ; return AVERROR_INVALIDDATA ; } end = start + length ; i = end ; if ( frag -> data [ i ] != 0xff ) { next_marker = - 1 ; } else { for ( ++ i ; i + 1 < frag -> data_size && frag -> data [ i ] == 0xff ; i ++ ) ; if ( i + 1 >= frag -> data_size ) { next_marker = - 1 ; } else { next_marker = frag -> data [ i ] ; next_start = i + 1 ; } } } if ( marker == JPEG_MARKER_SOS ) { length = AV_RB16 ( frag -> data + start ) ; data_ref = NULL ; data = av_malloc ( end - start + AV_INPUT_BUFFER_PADDING_SIZE ) ; if ( ! data ) return AVERROR ( ENOMEM ) ; memcpy ( data , frag -> data + start , length ) ; for ( i = start + length , j = length ; i < end ; i ++ , j ++ ) { if ( frag -> data [ i ] == 0xff ) { while ( frag -> data [ i ] == 0xff ) ++ i ; data [ j ] = 0xff ; } else { data [ j ] = frag -> data [ i ] ; } } data_size = j ; memset ( data + data_size , 0 , AV_INPUT_BUFFER_PADDING_SIZE ) ; } else { data = frag -> data + start ; data_size = end - start ; data_ref = frag -> data_ref ; } err = ff_cbs_insert_unit_data ( ctx , frag , unit , marker , data , data_size , data_ref ) ; if ( err < 0 ) return err ; if ( next_marker == - 1 ) break ; marker = next_marker ; start = next_start ; } return 0 ; } "," start ) ; if ( length > end - start ) return AVERROR_INVALIDDATA ; ",FFmpeg@FFmpeg/1812352d767ccf5431aa440123e2e260a4db2726,CVE-2020-12284,https://github.com/FFmpeg/FFmpeg/commit/1812352d767ccf5431aa440123e2e260a4db2726,2020-04-28T06:15Z 1137,CWE-125,"CWE-125 static stmt_ty ast_for_expr_stmt ( struct compiling * c , const node * n ) { REQ ( n , expr_stmt ) ; if ( NCH ( n ) == 1 ) { expr_ty e = ast_for_testlist ( c , CHILD ( n , 0 ) ) ; if ( ! e ) return NULL ; return Expr ( e , LINENO ( n ) , n -> n_col_offset , n -> n_end_lineno , n -> n_end_col_offset , c -> c_arena ) ; } else if ( TYPE ( CHILD ( n , 1 ) ) == augassign ) { expr_ty expr1 , expr2 ; operator_ty newoperator ; node * ch = CHILD ( n , 0 ) ; expr1 = ast_for_testlist ( c , ch ) ; if ( ! expr1 ) return NULL ; if ( ! set_context ( c , expr1 , Store , ch ) ) return NULL ; switch ( expr1 -> kind ) { case Name_kind : case Attribute_kind : case Subscript_kind : break ; default : ast_error ( c , ch , ""illegalexpressionforaugmentedassignment"" ) ; return NULL ; } ch = CHILD ( n , 2 ) ; if ( TYPE ( ch ) == testlist ) expr2 = ast_for_testlist ( c , ch ) ; else expr2 = ast_for_expr ( c , ch ) ; if ( ! expr2 ) return NULL ; newoperator = ast_for_augassign ( c , CHILD ( n , 1 ) ) ; if ( ! newoperator ) return NULL ; return AugAssign ( expr1 , newoperator , expr2 , LINENO ( n ) , n -> n_col_offset , n -> n_end_lineno , n -> n_end_col_offset , c -> c_arena ) ; } else if ( TYPE ( CHILD ( n , 1 ) ) == annassign ) { expr_ty expr1 , expr2 , expr3 ; node * ch = CHILD ( n , 0 ) ; node * deep , * ann = CHILD ( n , 1 ) ; int simple = 1 ; deep = ch ; while ( NCH ( deep ) == 1 ) { deep = CHILD ( deep , 0 ) ; } if ( NCH ( deep ) > 0 && TYPE ( CHILD ( deep , 0 ) ) == LPAR ) { simple = 0 ; } expr1 = ast_for_testlist ( c , ch ) ; if ( ! expr1 ) { return NULL ; } switch ( expr1 -> kind ) { case Name_kind : if ( forbidden_name ( c , expr1 -> v . Name . id , n , 0 ) ) { return NULL ; } expr1 -> v . Name . ctx = Store ; break ; case Attribute_kind : if ( forbidden_name ( c , expr1 -> v . Attribute . attr , n , 1 ) ) { return NULL ; } expr1 -> v . Attribute . ctx = Store ; break ; case Subscript_kind : expr1 -> v . Subscript . ctx = Store ; break ; case List_kind : ast_error ( c , ch , ""onlysingletarget(notlist)canbeannotated"" ) ; return NULL ; case Tuple_kind : ast_error ( c , ch , ""onlysingletarget(nottuple)canbeannotated"" ) ; return NULL ; default : ast_error ( c , ch , ""illegaltargetforannotation"" ) ; return NULL ; } if ( expr1 -> kind != Name_kind ) { simple = 0 ; } ch = CHILD ( ann , 1 ) ; expr2 = ast_for_expr ( c , ch ) ; if ( ! expr2 ) { return NULL ; } if ( NCH ( ann ) == 2 ) { return AnnAssign ( expr1 , expr2 , NULL , simple , LINENO ( n ) , n -> n_col_offset , n -> n_end_lineno , n -> n_end_col_offset , c -> c_arena ) ; } else { ch = CHILD ( ann , 3 ) ; if ( TYPE ( ch ) == testlist ) { expr3 = ast_for_testlist ( c , ch ) ; } else { expr3 = ast_for_expr ( c , ch ) ; } if ( ! expr3 ) { return NULL ; } return AnnAssign ( expr1 , expr2 , expr3 , simple , LINENO ( n ) , n -> n_col_offset , n -> n_end_lineno , n -> n_end_col_offset , c -> c_arena ) ; } } else { int i ; asdl_seq * targets ; node * value ; expr_ty expression ; REQ ( CHILD ( n , 1 ) , EQUAL ) ; targets = _Py_asdl_seq_new ( NCH ( n ) / 2 , c -> c_arena ) ; if ( ! targets ) return NULL ; for ( i = 0 ; i < NCH ( n ) - 2 ; i += 2 ) { expr_ty e ; node * ch = CHILD ( n , i ) ; if ( TYPE ( ch ) == yield_expr ) { ast_error ( c , ch , ""assignmenttoyieldexpressionnotpossible"" ) ; return NULL ; } e = ast_for_testlist ( c , ch ) ; if ( ! e ) return NULL ; if ( ! set_context ( c , e , Store , CHILD ( n , i ) ) ) return NULL ; asdl_seq_SET ( targets , i / 2 , e ) ; } value = CHILD ( n , NCH ( n ) - 1 ) ; if ( TYPE ( value ) == testlist_star_expr ) expression = ast_for_testlist ( c , value ) ; else expression = ast_for_expr ( c , value ) ; if ( ! expression ) return NULL ; return Assign ( targets , expression , LINENO ( n ) , n -> n_col_offset , n -> n_end_lineno , n -> n_end_col_offset , c -> c_arena ) ; } } "," expr_stmt ) ; int num = NCH ( n ( n ) ; if ( num { int i , nch_minus_type , has_type_comment expr_ty expression ; string type_comment ; EQUAL ) ; has_type_comment = TYPE ( CHILD ( n , num - 1 ) ) == TYPE_COMMENT ; nch_minus_type = num - has_type_comment ; = _Py_asdl_seq_new ( nch_minus_type / 2 , ; i < nch_minus_type - 2 ; ( n , nch_minus_type - 1 ) return NULL ; if ( has_type_comment ) { type_comment = NEW_TYPE_COMMENT ( CHILD ( n , nch_minus_type ) ) ; if ( ! type_comment ) return NULL ; } else type_comment = NULL ; , expression , type_comment , ",python@typed_ast/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,CVE-2019-19275,https://github.com/python/typed_ast/commit/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,2019-11-26T15:15Z 1138,CWE-119,"CWE-119 int vp8_denoiser_filter_c ( YV12_BUFFER_CONFIG * mc_running_avg , YV12_BUFFER_CONFIG * running_avg , MACROBLOCK * signal , unsigned int motion_magnitude , int y_offset , int uv_offset ) { unsigned char * sig = signal -> thismb ; int sig_stride = 16 ; unsigned char * mc_running_avg_y = mc_running_avg -> y_buffer + y_offset ; int mc_avg_y_stride = mc_running_avg -> y_stride ; unsigned char * running_avg_y = running_avg -> y_buffer + y_offset ; int avg_y_stride = running_avg -> y_stride ; int r , c , i ; int sum_diff = 0 ; int adj_val [ 3 ] = { 3 , 4 , 6 } ; if ( motion_magnitude <= MOTION_MAGNITUDE_THRESHOLD ) { for ( i = 0 ; i < 3 ; i ++ ) adj_val [ i ] += 1 ; } for ( r = 0 ; r < 16 ; ++ r ) { for ( c = 0 ; c < 16 ; ++ c ) { int diff = 0 ; int adjustment = 0 ; int absdiff = 0 ; diff = mc_running_avg_y [ c ] - sig [ c ] ; absdiff = abs ( diff ) ; if ( absdiff <= 3 ) { running_avg_y [ c ] = mc_running_avg_y [ c ] ; sum_diff += diff ; } else { if ( absdiff >= 4 && absdiff <= 7 ) adjustment = adj_val [ 0 ] ; else if ( absdiff >= 8 && absdiff <= 15 ) adjustment = adj_val [ 1 ] ; else adjustment = adj_val [ 2 ] ; if ( diff > 0 ) { if ( ( sig [ c ] + adjustment ) > 255 ) running_avg_y [ c ] = 255 ; else running_avg_y [ c ] = sig [ c ] + adjustment ; sum_diff += adjustment ; } else { if ( ( sig [ c ] - adjustment ) < 0 ) running_avg_y [ c ] = 0 ; else running_avg_y [ c ] = sig [ c ] - adjustment ; sum_diff -= adjustment ; } } } sig += sig_stride ; mc_running_avg_y += mc_avg_y_stride ; running_avg_y += avg_y_stride ; } if ( abs ( sum_diff ) > SUM_DIFF_THRESHOLD ) return COPY_BLOCK ; vp8_copy_mem16x16 ( running_avg -> y_buffer + y_offset , avg_y_stride , signal -> thismb , sig_stride ) ; return FILTER_BLOCK ; } "," int vp8_denoiser_filter_c ( unsigned char * char * mc_running_avg_y , int mc_avg_y_stride , unsigned char * char * running_avg_y , int avg_y_stride , unsigned char * sig , int sig_stride , unsigned int motion_magnitude , int increase_denoising ) { unsigned char * running_avg_y_start = running_avg_y ; unsigned char * sig_start = sig ; int sum_diff_thresh ; int r r , c ; int sum_diff 4 , 6 } ; int shift_inc1 = 0 ; int shift_inc2 = 1 ; int col_sum [ 16 ] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 MOTION_MAGNITUDE_THRESHOLD ) { if ( increase_denoising ) { shift_inc1 = 1 ; shift_inc2 = 2 ; } adj_val [ 0 ] += shift_inc2 ; adj_val [ 1 ] += shift_inc2 ; adj_val [ 2 ] += shift_inc2 ; } for absdiff <= 3 + shift_inc1 c ] ; col_sum [ c ] += diff ; absdiff >= 4 + shift_inc1 + adjustment ; col_sum [ c ] += adjustment ; } else { if ( ( sig [ c ] - adjustment ) < 0 ) running_avg_y [ c ] = 0 ; else running_avg_y [ c ] = sig [ c ] - adjustment ; col_sum [ c ] -= adjustment ; } } } sig += sig_stride ; mc_running_avg_y += mc_avg_y_stride ; running_avg_y += avg_y_stride ; } for ( c = 0 ; c < 16 ; ++ c ) { if ( col_sum [ c ] >= 128 ) { col_sum [ c ] = 127 ; } sum_diff += col_sum [ c ] ; } sum_diff_thresh = SUM_DIFF_THRESHOLD ; if ( increase_denoising ) sum_diff_thresh = SUM_DIFF_THRESHOLD_HIGH ; if ( abs ( sum_diff ) > sum_diff_thresh ) { int delta = ( ( abs ( sum_diff ) - sum_diff_thresh ) >> 8 ) + 1 ; if ( delta < 4 ) { sig -= sig_stride * 16 ; mc_running_avg_y -= mc_avg_y_stride * 16 ; running_avg_y -= avg_y_stride * 16 ; for ( r = 0 ; r < 16 ; ++ r ) { for ( c = 0 ; c < 16 ; ++ c ) { int diff = mc_running_avg_y [ c ] c ] - sig [ c ] ; int adjustment = abs ( diff ) ; if ( adjustment > delta ) adjustment = delta ; if ( diff > 0 ) { if ( running_avg_y [ c ] - adjustment < 0 ) running_avg_y [ c ] = 0 ; else running_avg_y [ c ] = running_avg_y [ c ] - adjustment ; col_sum [ c ] -= adjustment ; } else if ( diff < 0 ) { if ( running_avg_y [ c ] + adjustment > 255 ) running_avg_y [ c ] = 255 ; else running_avg_y [ c ] = running_avg_y [ c ] + adjustment ; col_sum [ c ] += adjustment ; } } sig += sig_stride ; mc_running_avg_y += mc_avg_y_stride ; running_avg_y += avg_y_stride ; } sum_diff = 0 ; for ( c = 0 ; c < 16 ; ++ c ) { if ( col_sum [ c ] >= 128 ) { col_sum [ c ] = 127 ; } sum_diff += col_sum [ c ] ; } if sum_diff ) > sum_diff_thresh ) return COPY_BLOCK return COPY_BLOCK ; } else { return COPY_BLOCK ; } } vp8_copy_mem16x16 ( running_avg_y_start , avg_y_stride , , avg_y_stride , sig_start , sig_stride ) ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1139,CWE-119,"CWE-119 static SockState SockParse ( Sock * sockPtr ) { const Tcl_DString * bufPtr ; const Driver * drvPtr ; Request * reqPtr ; char save ; SockState result ; NS_NONNULL_ASSERT ( sockPtr != NULL ) ; drvPtr = sockPtr -> drvPtr ; NsUpdateProgress ( ( Ns_Sock * ) sockPtr ) ; reqPtr = sockPtr -> reqPtr ; bufPtr = & reqPtr -> buffer ; while ( reqPtr -> coff == 0u ) { char * s , * e ; size_t cnt ; s = bufPtr -> string + reqPtr -> roff ; e = memchr ( s , INTCHAR ( '\\n' ) , reqPtr -> avail ) ; if ( unlikely ( e == NULL ) ) { return SOCK_MORE ; } if ( unlikely ( ( e - s ) > drvPtr -> maxline ) ) { sockPtr -> keep = NS_FALSE ; if ( reqPtr -> request . line == NULL ) { Ns_Log ( DriverDebug , ""SockParse:maxlinereachedof%dbytes"" , drvPtr -> maxline ) ; sockPtr -> flags = NS_CONN_REQUESTURITOOLONG ; Ns_Log ( Warning , ""requestlineistoolong(%dbytes)"" , ( int ) ( e - s ) ) ; } else { sockPtr -> flags = NS_CONN_LINETOOLONG ; Ns_Log ( Warning , ""requestheaderlineistoolong(%dbytes)"" , ( int ) ( e - s ) ) ; } } cnt = ( size_t ) ( e - s ) + 1u ; reqPtr -> roff += cnt ; reqPtr -> avail -= cnt ; if ( likely ( e > s ) && likely ( * ( e - 1 ) == '\\r' ) ) { -- e ; } if ( unlikely ( e == s ) && ( reqPtr -> coff == 0u ) ) { reqPtr -> coff = EndOfHeader ( sockPtr ) ; if ( ( sockPtr -> flags & NS_CONN_CONTINUE ) != 0u ) { Ns_Log ( Ns_LogRequestDebug , ""honoring100-continue"" ) ; if ( ( sockPtr -> flags & NS_CONN_ENTITYTOOLARGE ) != 0u ) { Ns_Log ( Ns_LogRequestDebug , ""100-continue:entitytoolarge"" ) ; return SOCK_ENTITYTOOLARGE ; } else { struct iovec iov [ 1 ] ; ssize_t sent ; Ns_Log ( Ns_LogRequestDebug , ""100-continue:replyCONTINUE"" ) ; iov [ 0 ] . iov_base = ( char * ) ""HTTP/1.1100Continue\\r\\n\\r\\n"" ; iov [ 0 ] . iov_len = strlen ( iov [ 0 ] . iov_base ) ; sent = Ns_SockSendBufs ( ( Ns_Sock * ) sockPtr , iov , 1 , NULL , 0u ) ; if ( sent != ( ssize_t ) iov [ 0 ] . iov_len ) { Ns_Log ( Warning , ""couldnotdeliverresponse:100Continue"" ) ; } } } } else { save = * e ; * e = '\\0' ; if ( unlikely ( reqPtr -> request . line == NULL ) ) { Ns_Log ( DriverDebug , ""SockParse(%d):parserequestline<%s>"" , sockPtr -> sock , s ) ; if ( Ns_ParseRequest ( & reqPtr -> request , s ) == NS_ERROR ) { return SOCK_BADREQUEST ; } if ( unlikely ( reqPtr -> request . version < 1.0 ) ) { reqPtr -> coff = reqPtr -> roff ; Ns_Log ( Notice , ""pre-HTTP/1.0request<%s>"" , reqPtr -> request . line ) ; } } else if ( Ns_ParseHeader ( reqPtr -> headers , s , Preserve ) != NS_OK ) { return SOCK_BADHEADER ; } else { if ( unlikely ( Ns_SetSize ( reqPtr -> headers ) > ( size_t ) drvPtr -> maxheaders ) ) { Ns_Log ( DriverDebug , ""SockParse(%d):maxheadersreachedof%dbytes"" , sockPtr -> sock , drvPtr -> maxheaders ) ; return SOCK_TOOMANYHEADERS ; } } * e = save ; } } if ( unlikely ( reqPtr -> request . line == NULL ) ) { return SOCK_BADREQUEST ; } assert ( reqPtr -> coff > 0u ) ; assert ( reqPtr -> request . line != NULL ) ; Ns_Log ( Dev , ""===length<avail(length%"" PRIuz "",avail%"" PRIuz "")tfd%dtfile%pchunkStartOff%"" PRIuz , reqPtr -> length , reqPtr -> avail , sockPtr -> tfd , ( void * ) sockPtr -> tfile , reqPtr -> chunkStartOff ) ; if ( reqPtr -> chunkStartOff != 0u ) { bool complete ; size_t currentContentLength ; complete = ChunkedDecode ( reqPtr , NS_TRUE ) ; currentContentLength = reqPtr -> chunkWriteOff - reqPtr -> coff ; if ( ( ! complete ) || ( reqPtr -> expectedLength != 0u && currentContentLength < reqPtr -> expectedLength ) ) { return SOCK_MORE ; } reqPtr -> length = ( size_t ) currentContentLength ; } if ( reqPtr -> avail < reqPtr -> length ) { Ns_Log ( DriverDebug , ""SockReadwaitformoreinput"" ) ; return SOCK_MORE ; } Ns_Log ( Dev , ""===allrequireddataisavailable(avail%"" PRIuz "",length%"" PRIuz "","" ""readahead%"" TCL_LL_MODIFIER ""dmaxupload%"" TCL_LL_MODIFIER ""d)tfd%d"" , reqPtr -> avail , reqPtr -> length , drvPtr -> readahead , drvPtr -> maxupload , sockPtr -> tfd ) ; result = SOCK_READY ; if ( sockPtr -> tfile != NULL ) { reqPtr -> content = NULL ; reqPtr -> next = NULL ; reqPtr -> avail = 0u ; Ns_Log ( DriverDebug , ""contentspooledtofile:size%"" PRIdz "",file%s"" , reqPtr -> length , sockPtr -> tfile ) ; } else { if ( sockPtr -> tfd > 0 ) { # ifdef _WIN32 assert ( 0 ) ; # else int prot = PROT_READ | PROT_WRITE ; ssize_t rc = ns_write ( sockPtr -> tfd , ""\\0"" , 1 ) ; if ( rc == - 1 ) { Ns_Log ( Error , ""socket:couldnotappendterminating0-byte"" ) ; } sockPtr -> tsize = reqPtr -> length + 1 ; sockPtr -> taddr = mmap ( 0 , sockPtr -> tsize , prot , MAP_PRIVATE , sockPtr -> tfd , 0 ) ; if ( sockPtr -> taddr == MAP_FAILED ) { sockPtr -> taddr = NULL ; result = SOCK_ERROR ; } else { reqPtr -> content = sockPtr -> taddr ; Ns_Log ( Debug , ""contentspooledtommappedfile:readahead=%"" TCL_LL_MODIFIER ""d,filesize=%"" PRIdz , drvPtr -> readahead , sockPtr -> tsize ) ; } # endif } else { reqPtr -> content = bufPtr -> string + reqPtr -> coff ; } reqPtr -> next = reqPtr -> content ; if ( reqPtr -> length > 0u ) { Ns_Log ( DriverDebug , ""SockReadaddsnullterminatingcharacteratcontent[%"" PRIuz ""]"" , reqPtr -> length ) ; reqPtr -> savedChar = reqPtr -> content [ reqPtr -> length ] ; reqPtr -> content [ reqPtr -> length ] = '\\0' ; if ( sockPtr -> taddr == NULL ) { LogBuffer ( DriverDebug , ""UPDATEDBUFFER"" , sockPtr -> reqPtr -> buffer . string , ( size_t ) reqPtr -> buffer . length ) ; } } } return result ; } "," ; Ns_Log ( Debug , ""===length<avail(length%"" PRIuz 0u ) { SockState chunkState ; size_t currentContentLength size_t currentContentLength ; chunkState = ChunkedDecode ( if ( ( chunkState == SOCK_MORE ) || ( SOCK_MORE ; } else if ( chunkState != SOCK_READY ) { return chunkState ; } ",naviserver@naviserver/a5c3079f1d8996d5f34c9384a440acf3519ca3bb,CVE-2020-13111,https://bitbucket.org/naviserver/naviserver/commit/a5c3079f1d8996d5f34c9384a440acf3519ca3bb,2020-05-16T15:15Z 1140,CWE-20,"CWE-20 int ptrace_setxregs ( struct task_struct * child , void __user * uregs ) { struct thread_info * ti = task_thread_info ( child ) ; struct pt_regs * regs = task_pt_regs ( child ) ; elf_xtregs_t * xtregs = uregs ; int ret = 0 ; # if XTENSA_HAVE_COPROCESSORS coprocessor_flush_all ( ti ) ; coprocessor_release_all ( ti ) ; ret |= __copy_from_user ( & ti -> xtregs_cp , & xtregs -> cp0 , sizeof ( xtregs_coprocessor_t ) ) ; # endif ret |= __copy_from_user ( & regs -> xtregs_opt , & xtregs -> opt , sizeof ( xtregs -> opt ) ) ; ret |= __copy_from_user ( & ti -> xtregs_user , & xtregs -> user , sizeof ( xtregs -> user ) ) ; return ret ? - EFAULT : 0 ; } "," ret = 0 ; if ( ! access_ok ( VERIFY_READ , uregs , sizeof ( elf_xtregs_t ) ) ) return - EFAULT ",torvalds@linux/0d0138ebe24b94065580bd2601f8bb7eb6152f56,CVE-2011-2707,https://github.com/torvalds/linux/commit/0d0138ebe24b94065580bd2601f8bb7eb6152f56,2012-05-24T23:55Z 1141,CWE-20,"CWE-20 error_t rawSocketReceiveIpPacket ( Socket * socket , SocketMsg * message , uint_t flags ) { error_t error ; SocketQueueItem * queueItem ; if ( ( flags & SOCKET_FLAG_DONT_WAIT ) == 0 ) { if ( socket -> receiveQueue == NULL ) { socket -> eventMask = SOCKET_EVENT_RX_READY ; osResetEvent ( & socket -> event ) ; osReleaseMutex ( & netMutex ) ; osWaitForEvent ( & socket -> event , socket -> timeout ) ; osAcquireMutex ( & netMutex ) ; } } if ( socket -> receiveQueue != NULL ) { queueItem = socket -> receiveQueue ; message -> length = netBufferRead ( message -> data , queueItem -> buffer , queueItem -> offset , message -> size ) ; message -> srcIpAddr = queueItem -> srcIpAddr ; message -> srcPort = queueItem -> srcPort ; message -> destIpAddr = queueItem -> destIpAddr ; message -> ttl = queueItem -> ancillary . ttl ; # if ( ETH_SUPPORT == ENABLED ) message -> srcMacAddr = queueItem -> ancillary . srcMacAddr ; message -> destMacAddr = queueItem -> ancillary . destMacAddr ; # endif # if ( ETH_PORT_TAGGING_SUPPORT == ENABLED ) message -> switchPort = queueItem -> ancillary . port ; # endif # if ( ETH_TIMESTAMP_SUPPORT == ENABLED ) message -> timestamp = queueItem -> ancillary . timestamp ; # endif if ( ( flags & SOCKET_FLAG_PEEK ) == 0 ) { socket -> receiveQueue = queueItem -> next ; netBufferFree ( queueItem -> buffer ) ; } rawSocketUpdateEvents ( socket ) ; error = NO_ERROR ; } else { message -> length = 0 ; error = ERROR_TIMEOUT ; } return error ; } "," ; message -> interface = queueItem -> interface ; message -> ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 1142,CWE-22,"CWE-22 static void xcopy_pt_undepend_remotedev ( struct xcopy_op * xop ) { struct se_device * remote_dev ; if ( xop -> op_origin == XCOL_SOURCE_RECV_OP ) remote_dev = xop -> dst_dev ; else remote_dev = xop -> src_dev ; pr_debug ( ""Callingconfigfs_undepend_itemfor"" ""remote_dev:%premote_dev->dev_group:%p\\n"" , remote_dev , & remote_dev -> dev_group . cg_item ) ; target_undepend_item ( & remote_dev -> dev_group . cg_item ) ; } "," xop ) { if ( xop == XCOL_SOURCE_RECV_OP ) pr_debug ( ""puttingdstlun_reffor%p\\n"" , xop -> dst_dev xop -> dst_dev ) ; else pr_debug ( ""puttingsrclun_reffor%p\\n"" , xop -> src_dev xop -> src_dev ) ; percpu_ref_put ( xop -> remote_lun_ref ) ; } ",torvalds@linux/2896c93811e39d63a4d9b63ccf12a8fbc226e5e4,CVE-2020-28374,https://github.com/torvalds/linux/commit/2896c93811e39d63a4d9b63ccf12a8fbc226e5e4,2021-01-13T04:15Z 1143,CWE-284,"CWE-284 static int ndp_sock_open ( struct ndp * ndp ) { int sock ; int ret ; int err ; int val ; sock = socket ( PF_INET6 , SOCK_RAW , IPPROTO_ICMPV6 ) ; if ( sock == - 1 ) { err ( ndp , ""FailedtocreateICMP6socket."" ) ; return - errno ; } val = 1 ; ret = setsockopt ( sock , IPPROTO_IPV6 , IPV6_RECVPKTINFO , & val , sizeof ( val ) ) ; if ( ret == - 1 ) { err ( ndp , ""FailedtosetsockoptIPV6_RECVPKTINFO."" ) ; err = - errno ; goto close_sock ; } val = 255 ; ret = setsockopt ( sock , IPPROTO_IPV6 , IPV6_MULTICAST_HOPS , & val , sizeof ( val ) ) ; if ( ret == - 1 ) { err ( ndp , ""FailedtosetsockoptIPV6_MULTICAST_HOPS."" ) ; err = - errno ; goto close_sock ; } ndp -> sock = sock ; return 0 ; close_sock : close ( sock ) ; return err ; } "," ndp , ""FailedtosetsockoptIPV6_MULTICAST_HOPS."" ) ; err = - errno ; goto close_sock ; } val = 1 ; ret = setsockopt ( sock , IPPROTO_IPV6 , IPV6_RECVHOPLIMIT , & val , sizeof ( val ) ) ; if ( ret == - 1 ) { err ( ndp , ""FailedtosetsockoptIPV6_RECVHOPLIMIT,."" ",jpirko@libndp/a4892df306e0532487f1634ba6d4c6d4bb381c7f,CVE-2016-3698,https://github.com/jpirko/libndp/commit/a4892df306e0532487f1634ba6d4c6d4bb381c7f,2016-06-13T19:59Z 1144,CWE-19,"CWE-19 static int ext2_xattr_set2 ( struct inode * inode , struct buffer_head * old_bh , struct ext2_xattr_header * header ) { struct super_block * sb = inode -> i_sb ; struct buffer_head * new_bh = NULL ; int error ; if ( header ) { new_bh = ext2_xattr_cache_find ( inode , header ) ; if ( new_bh ) { if ( new_bh == old_bh ) { ea_bdebug ( new_bh , ""keepingthisblock"" ) ; } else { ea_bdebug ( new_bh , ""reusingblock"" ) ; error = dquot_alloc_block ( inode , 1 ) ; if ( error ) { unlock_buffer ( new_bh ) ; goto cleanup ; } le32_add_cpu ( & HDR ( new_bh ) -> h_refcount , 1 ) ; ea_bdebug ( new_bh , ""refcountnow=%d"" , le32_to_cpu ( HDR ( new_bh ) -> h_refcount ) ) ; } unlock_buffer ( new_bh ) ; } else if ( old_bh && header == HDR ( old_bh ) ) { new_bh = old_bh ; get_bh ( new_bh ) ; ext2_xattr_cache_insert ( new_bh ) ; } else { ext2_fsblk_t goal = ext2_group_first_block_no ( sb , EXT2_I ( inode ) -> i_block_group ) ; int block = ext2_new_block ( inode , goal , & error ) ; if ( error ) goto cleanup ; ea_idebug ( inode , ""creatingblock%d"" , block ) ; new_bh = sb_getblk ( sb , block ) ; if ( unlikely ( ! new_bh ) ) { ext2_free_blocks ( inode , block , 1 ) ; mark_inode_dirty ( inode ) ; error = - ENOMEM ; goto cleanup ; } lock_buffer ( new_bh ) ; memcpy ( new_bh -> b_data , header , new_bh -> b_size ) ; set_buffer_uptodate ( new_bh ) ; unlock_buffer ( new_bh ) ; ext2_xattr_cache_insert ( new_bh ) ; ext2_xattr_update_super_block ( sb ) ; } mark_buffer_dirty ( new_bh ) ; if ( IS_SYNC ( inode ) ) { sync_dirty_buffer ( new_bh ) ; error = - EIO ; if ( buffer_req ( new_bh ) && ! buffer_uptodate ( new_bh ) ) goto cleanup ; } } EXT2_I ( inode ) -> i_file_acl = new_bh ? new_bh -> b_blocknr : 0 ; inode -> i_ctime = CURRENT_TIME_SEC ; if ( IS_SYNC ( inode ) ) { error = sync_inode_metadata ( inode , 1 ) ; if ( error && error != - ENOSPC ) { if ( new_bh && new_bh != old_bh ) { dquot_free_block_nodirty ( inode , 1 ) ; mark_inode_dirty ( inode ) ; } goto cleanup ; } } else mark_inode_dirty ( inode ) ; error = 0 ; if ( old_bh && old_bh != new_bh ) { struct mb_cache_entry * ce ; ce = mb_cache_entry_get ( ext2_xattr_cache , old_bh -> b_bdev , old_bh -> b_blocknr ) ; lock_buffer ( old_bh ) ; if ( HDR ( old_bh ) -> h_refcount == cpu_to_le32 ( 1 ) ) { if ( ce ) mb_cache_entry_free ( ce ) ; ea_bdebug ( old_bh , ""freeing"" ) ; ext2_free_blocks ( inode , old_bh -> b_blocknr , 1 ) ; mark_inode_dirty ( inode ) ; get_bh ( old_bh ) ; bforget ( old_bh ) ; } else { le32_add_cpu ( & HDR ( old_bh ) -> h_refcount , - 1 ) ; if ( ce ) mb_cache_entry_release ( ce ) ; dquot_free_block_nodirty ( inode , 1 ) ; mark_inode_dirty ( inode ) ; mark_buffer_dirty ( old_bh ) ; ea_bdebug ( old_bh , ""refcountnow=%d"" , le32_to_cpu ( HDR ( old_bh ) -> h_refcount ) ) ; } unlock_buffer ( old_bh ) ; } cleanup : brelse ( new_bh ) ; return error ; } "," int error ; struct mb2_cache * ext2_mb_cache = EXT2_SB ( sb ) -> s_mb_cache ; ; ext2_xattr_cache_insert ( ext2_mb_cache , ; ext2_xattr_cache_insert ( ext2_mb_cache , new_bh ) { lock_buffer ( old_bh ) ) { __u32 hash = le32_to_cpu ( HDR ( old_bh ) -> h_hash ) ; mb2_cache_entry_delete_block ( ext2_mb_cache , hash , old_bh -> b_blocknr ) ; ea_bdebug 1 ) ; dquot_free_block_nodirty ( inode ",torvalds@linux/be0726d33cb8f411945884664924bed3cb8c70ee,CVE-2015-8952,https://github.com/torvalds/linux/commit/be0726d33cb8f411945884664924bed3cb8c70ee,2016-10-16T21:59Z 1145,CWE-310,"CWE-310 static int crypto_report_comp ( struct sk_buff * skb , struct crypto_alg * alg ) { struct crypto_report_comp rcomp ; snprintf ( rcomp . type , CRYPTO_MAX_ALG_NAME , ""%s"" , ""compression"" ) ; if ( nla_put ( skb , CRYPTOCFGA_REPORT_COMPRESS , sizeof ( struct crypto_report_comp ) , & rcomp ) ) goto nla_put_failure ; return 0 ; nla_put_failure : return - EMSGSIZE ; } "," crypto_report_comp rcomp ; strncpy ( rcomp . . type , ""compression"" , sizeof ( rcomp . type ) ) ; if ",torvalds@linux/9a5467bf7b6e9e02ec9c3da4e23747c05faeaac6,CVE-2013-2548,https://github.com/torvalds/linux/commit/9a5467bf7b6e9e02ec9c3da4e23747c05faeaac6,2013-03-15T20:55Z 1146,CWE-119,"CWE-119 static vpx_codec_err_t ctrl_set_active_map ( vpx_codec_alg_priv_t * ctx , int ctr_id , va_list args ) { vpx_active_map_t * const map = va_arg ( args , vpx_active_map_t * ) ; if ( map ) { if ( ! vp9_set_active_map ( ctx -> cpi , map -> active_map , map -> rows , map -> cols ) ) return VPX_CODEC_OK ; else return VPX_CODEC_INVALID_PARAM ; } else { return VPX_CODEC_INVALID_PARAM ; } } "," * ctx , va_list args ) -> active_map , ( int ) -> rows , ( int ) ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1147,CWE-285,"CWE-285 static int __jfs_set_acl ( tid_t tid , struct inode * inode , int type , struct posix_acl * acl ) { char * ea_name ; int rc ; int size = 0 ; char * value = NULL ; switch ( type ) { case ACL_TYPE_ACCESS : ea_name = XATTR_NAME_POSIX_ACL_ACCESS ; if ( acl ) { rc = posix_acl_equiv_mode ( acl , & inode -> i_mode ) ; if ( rc < 0 ) return rc ; inode -> i_ctime = CURRENT_TIME ; mark_inode_dirty ( inode ) ; if ( rc == 0 ) acl = NULL ; } break ; case ACL_TYPE_DEFAULT : ea_name = XATTR_NAME_POSIX_ACL_DEFAULT ; break ; default : return - EINVAL ; } if ( acl ) { size = posix_acl_xattr_size ( acl -> a_count ) ; value = kmalloc ( size , GFP_KERNEL ) ; if ( ! value ) return - ENOMEM ; rc = posix_acl_to_xattr ( & init_user_ns , acl , value , size ) ; if ( rc < 0 ) goto out ; } rc = __jfs_setxattr ( tid , inode , ea_name , value , size , 0 ) ; out : kfree ( value ) ; if ( ! rc ) set_cached_acl ( inode , type , acl ) ; return rc ; } "," { rc = posix_acl_update_mode ( inode , & inode inode -> i_mode , & acl ) ; if ( rc ) return rc ; inode -> i_ctime = CURRENT_TIME ; mark_inode_dirty ( inode ) ; } break ; case ACL_TYPE_DEFAULT : ea_name = XATTR_NAME_POSIX_ACL_DEFAULT ; break ; default : return - EINVAL ; } if ( acl ) { size = posix_acl_xattr_size ( acl -> a_count ) ; value = kmalloc ( size , GFP_KERNEL ) ; if ( ! value ) return - ENOMEM ; rc = posix_acl_to_xattr ( & init_user_ns , acl , value , size < 0 ) goto out ; ",torvalds@linux/073931017b49d9458aa351605b43a7e34598caef,CVE-2016-7097,https://github.com/torvalds/linux/commit/073931017b49d9458aa351605b43a7e34598caef,2016-10-16T21:59Z 1148,CWE-476,"CWE-476 static Image * ReadXCFImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { char magick [ 14 ] ; Image * image ; int foundPropEnd = 0 ; MagickBooleanType status ; MagickOffsetType offset ; register ssize_t i ; size_t image_type , length ; ssize_t count ; XCFDocInfo doc_info ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } count = ReadBlob ( image , 14 , ( unsigned char * ) magick ) ; if ( ( count != 14 ) || ( LocaleNCompare ( ( char * ) magick , ""gimpxcf"" , 8 ) != 0 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; ( void ) ResetMagickMemory ( & doc_info , 0 , sizeof ( XCFDocInfo ) ) ; doc_info . exception = exception ; doc_info . width = ReadBlobMSBLong ( image ) ; doc_info . height = ReadBlobMSBLong ( image ) ; if ( ( doc_info . width > 262144 ) || ( doc_info . height > 262144 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; doc_info . image_type = ReadBlobMSBLong ( image ) ; image -> columns = doc_info . width ; image -> rows = doc_info . height ; image_type = doc_info . image_type ; doc_info . file_size = GetBlobSize ( image ) ; image -> compression = NoCompression ; image -> depth = 8 ; status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; } if ( image_type == GIMP_RGB ) ; else if ( image_type == GIMP_GRAY ) image -> colorspace = GRAYColorspace ; else if ( image_type == GIMP_INDEXED ) ThrowReaderException ( CoderError , ""ColormapTypeNotSupported"" ) ; ( void ) SetImageOpacity ( image , OpaqueOpacity ) ; ( void ) SetImageBackgroundColor ( image ) ; while ( ( foundPropEnd == MagickFalse ) && ( EOFBlob ( image ) == MagickFalse ) ) { PropType prop_type = ( PropType ) ReadBlobMSBLong ( image ) ; size_t prop_size = ReadBlobMSBLong ( image ) ; switch ( prop_type ) { case PROP_END : foundPropEnd = 1 ; break ; case PROP_COLORMAP : { size_t num_colours = ReadBlobMSBLong ( image ) ; if ( DiscardBlobBytes ( image , 3 * num_colours ) == MagickFalse ) ThrowFileException ( & image -> exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } case PROP_COMPRESSION : { doc_info . compression = ReadBlobByte ( image ) ; if ( ( doc_info . compression != COMPRESS_NONE ) && ( doc_info . compression != COMPRESS_RLE ) && ( doc_info . compression != COMPRESS_ZLIB ) && ( doc_info . compression != COMPRESS_FRACTAL ) ) ThrowReaderException ( CorruptImageError , ""UnrecognizedImageCompression"" ) ; } break ; case PROP_GUIDES : { if ( DiscardBlobBytes ( image , prop_size ) == MagickFalse ) ThrowFileException ( & image -> exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; } break ; case PROP_RESOLUTION : { ( void ) ReadBlobMSBLong ( image ) ; ( void ) ReadBlobMSBLong ( image ) ; } break ; case PROP_TATTOO : { ( void ) ReadBlobMSBLong ( image ) ; } break ; case PROP_PARASITES : { if ( DiscardBlobBytes ( image , prop_size ) == MagickFalse ) ThrowFileException ( & image -> exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; } break ; case PROP_UNIT : { ( void ) ReadBlobMSBLong ( image ) ; } break ; case PROP_PATHS : { if ( DiscardBlobBytes ( image , prop_size ) == MagickFalse ) ThrowFileException ( & image -> exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; } break ; case PROP_USER_UNIT : { char unit_string [ 1000 ] ; ( void ) ReadBlobMSBLong ( image ) ; ( void ) ReadBlobMSBLong ( image ) ; for ( i = 0 ; i < 5 ; i ++ ) ( void ) ReadBlobStringWithLongSize ( image , unit_string , sizeof ( unit_string ) ) ; } break ; default : { int buf [ 16 ] ; ssize_t amount ; while ( ( prop_size > 0 ) && ( EOFBlob ( image ) == MagickFalse ) ) { amount = ( ssize_t ) MagickMin ( 16 , prop_size ) ; amount = ( ssize_t ) ReadBlob ( image , ( size_t ) amount , ( unsigned char * ) & buf ) ; if ( ! amount ) ThrowReaderException ( CorruptImageError , ""CorruptImage"" ) ; prop_size -= ( size_t ) MagickMin ( 16 , ( size_t ) amount ) ; } } break ; } } if ( foundPropEnd == MagickFalse ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) { ; } else { int current_layer = 0 , foundAllLayers = MagickFalse , number_layers = 0 ; MagickOffsetType oldPos = TellBlob ( image ) ; XCFLayerInfo * layer_info ; do { ssize_t offset = ReadBlobMSBSignedLong ( image ) ; if ( offset == 0 ) foundAllLayers = MagickTrue ; else number_layers ++ ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } } while ( foundAllLayers == MagickFalse ) ; doc_info . number_layers = number_layers ; offset = SeekBlob ( image , oldPos , SEEK_SET ) ; if ( offset < 0 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; length = ( size_t ) number_layers ; layer_info = ( XCFLayerInfo * ) AcquireQuantumMemory ( length , sizeof ( * layer_info ) ) ; if ( layer_info == ( XCFLayerInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; ( void ) ResetMagickMemory ( layer_info , 0 , number_layers * sizeof ( XCFLayerInfo ) ) ; for ( ; ; ) { MagickBooleanType layer_ok ; MagickOffsetType offset , saved_pos ; offset = ( MagickOffsetType ) ReadBlobMSBLong ( image ) ; if ( offset == 0 ) break ; saved_pos = TellBlob ( image ) ; if ( SeekBlob ( image , offset , SEEK_SET ) != offset ) ThrowReaderException ( ResourceLimitError , ""NotEnoughPixelData"" ) ; layer_ok = ReadOneLayer ( image_info , image , & doc_info , & layer_info [ current_layer ] , current_layer ) ; if ( layer_ok == MagickFalse ) { int j ; for ( j = 0 ; j < current_layer ; j ++ ) layer_info [ j ] . image = DestroyImage ( layer_info [ j ] . image ) ; layer_info = ( XCFLayerInfo * ) RelinquishMagickMemory ( layer_info ) ; ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; } offset = SeekBlob ( image , saved_pos , SEEK_SET ) ; current_layer ++ ; } # if 0 { signed int j ; for ( j = number_layers - 1 ; j >= 0 ; j -- ) { if ( layer_info [ j ] . visible ) { CompositeImage ( image , OverCompositeOp , layer_info [ j ] . image , layer_info [ j ] . offset_x , layer_info [ j ] . offset_y ) ; layer_info [ j ] . image = DestroyImage ( layer_info [ j ] . image ) ; if ( image_type == GIMP_GRAY ) { QuantizeInfo qi ; GetQuantizeInfo ( & qi ) ; qi . colorspace = GRAYColorspace ; QuantizeImage ( & qi , layer_info [ j ] . image ) ; } } } } # else { ssize_t j ; for ( j = ( long ) number_layers - 1 ; j >= 0 ; j -- ) AppendImageToList ( & image , layer_info [ j ] . image ) ; } # endif layer_info = ( XCFLayerInfo * ) RelinquishMagickMemory ( layer_info ) ; # if 0 while ( MagickTrue ) { info -> cp += xcf_read_int32 ( info -> fp , & offset , 1 ) ; if ( offset == 0 ) break ; saved_pos = info -> cp ; xcf_seek_pos ( info , offset ) ; channel = xcf_load_channel ( info , gimage ) ; if ( channel == 0 ) goto error ; num_successful_elements ++ ; if ( channel != gimage -> selection_mask ) gimp_image_add_channel ( gimage , channel , - 1 ) ; xcf_seek_pos ( info , saved_pos ) ; } # endif } ( void ) CloseBlob ( image ) ; DestroyImage ( RemoveFirstImageFromList ( & image ) ) ; if ( image_type == GIMP_GRAY ) image -> type = GrayscaleType ; return ( GetFirstImageInList ( image ) ) ; } "," image ) ; if ( GetNextImageInList ( image ) != ( Image * ) NULL ) ",ImageMagick@ImageMagick/d31fec57e9dfb0516deead2053a856e3c71e9751,CVE-2017-6501,https://github.com/ImageMagick/ImageMagick/commit/d31fec57e9dfb0516deead2053a856e3c71e9751,2017-03-06T02:59Z 1149,CWE-400,"CWE-400 static void perf_event_task_output ( struct perf_event * event , struct perf_task_event * task_event ) { struct perf_output_handle handle ; struct perf_sample_data sample ; struct task_struct * task = task_event -> task ; int ret , size = task_event -> event_id . header . size ; perf_event_header__init_id ( & task_event -> event_id . header , & sample , event ) ; ret = perf_output_begin ( & handle , event , task_event -> event_id . header . size , 0 , 0 ) ; if ( ret ) goto out ; task_event -> event_id . pid = perf_event_pid ( event , task ) ; task_event -> event_id . ppid = perf_event_pid ( event , current ) ; task_event -> event_id . tid = perf_event_tid ( event , task ) ; task_event -> event_id . ptid = perf_event_tid ( event , current ) ; perf_output_put ( & handle , task_event -> event_id ) ; perf_event__output_id_sample ( event , & handle , & sample ) ; perf_output_end ( & handle ) ; out : task_event -> event_id . header . size = size ; } "," size , 0 ) ; if ",torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,CVE-2011-2918,https://github.com/torvalds/linux/commit/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,2012-05-24T23:55Z 1150,CWE-119,"CWE-119 php_http_url_t * php_http_url_parse ( const char * str , size_t len , unsigned flags TSRMLS_DC ) { size_t maxlen = 3 * len ; struct parse_state * state = ecalloc ( 1 , sizeof ( * state ) + maxlen ) ; state -> end = str + len ; state -> ptr = str ; state -> flags = flags ; state -> maxlen = maxlen ; TSRMLS_SET_CTX ( state -> ts ) ; if ( ! parse_scheme ( state ) ) { php_error_docref ( NULL TSRMLS_CC , E_WARNING , ""FailedtoparseURLscheme:\'%s\'"" , state -> ptr ) ; efree ( state ) ; return NULL ; } if ( ! parse_hier ( state ) ) { efree ( state ) ; return NULL ; } if ( ! parse_query ( state ) ) { php_error_docref ( NULL TSRMLS_CC , E_WARNING , ""FailedtoparseURLquery:\'%s\'"" , state -> ptr ) ; efree ( state ) ; return NULL ; } if ( ! parse_fragment ( state ) ) { php_error_docref ( NULL TSRMLS_CC , E_WARNING , ""FailedtoparseURLfragment:\'%s\'"" , state -> ptr ) ; efree ( state ) ; return NULL ; } return ( php_http_url_t * ) state ; } "," 3 * len + 8 ",m6w6@ext-http/3724cd76a28be1d6049b5537232e97ac567ae1f5,CVE-2016-5873,https://github.com/m6w6/ext-http/commit/3724cd76a28be1d6049b5537232e97ac,2017-01-23T21:59Z 1151,CWE-189,"CWE-189 static void php_imagepolygon ( INTERNAL_FUNCTION_PARAMETERS , int filled ) { zval * IM , * POINTS ; long NPOINTS , COL ; zval * * var = NULL ; gdImagePtr im ; gdPointPtr points ; int npoints , col , nelem , i ; if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) TSRMLS_CC , ""rall"" , & IM , & POINTS , & NPOINTS , & COL ) == FAILURE ) { return ; } ZEND_FETCH_RESOURCE ( im , gdImagePtr , & IM , - 1 , ""Image"" , le_gd ) ; npoints = NPOINTS ; col = COL ; nelem = zend_hash_num_elements ( Z_ARRVAL_P ( POINTS ) ) ; if ( nelem < 6 ) { php_error_docref ( NULL TSRMLS_CC , E_WARNING , ""Youmusthaveatleast3pointsinyourarray"" ) ; RETURN_FALSE ; } if ( npoints <= 0 ) { php_error_docref ( NULL TSRMLS_CC , E_WARNING , ""Youmustgiveapositivenumberofpoints"" ) ; RETURN_FALSE ; } if ( nelem < npoints * 2 ) { php_error_docref ( NULL TSRMLS_CC , E_WARNING , ""Tryingtouse%dpointsinarraywithonly%dpoints"" , npoints , nelem / 2 ) ; RETURN_FALSE ; } points = ( gdPointPtr ) safe_emalloc ( npoints , sizeof ( gdPoint ) , 0 ) ; for ( i = 0 ; i < npoints ; i ++ ) { if ( zend_hash_index_find ( Z_ARRVAL_P ( POINTS ) , ( i * 2 ) , ( void * * ) & var ) == SUCCESS ) { SEPARATE_ZVAL ( ( var ) ) ; convert_to_long ( * var ) ; points [ i ] . x = Z_LVAL_PP ( var ) ; } if ( zend_hash_index_find ( Z_ARRVAL_P ( POINTS ) , ( i * 2 ) + 1 , ( void * * ) & var ) == SUCCESS ) { SEPARATE_ZVAL ( var ) ; convert_to_long ( * var ) ; points [ i ] . y = Z_LVAL_PP ( var ) ; } } if ( filled ) { gdImageFilledPolygon ( im , points , npoints , col ) ; } else { gdImagePolygon ( im , points , npoints , col ) ; } efree ( points ) ; RETURN_TRUE ; } "," SUCCESS ) { if ( Z_TYPE_PP ( var ) != IS_LONG ) { zval lval ; lval = * * var ; zval_copy_ctor ( & lval ) ; convert_to_long ; convert_to_long ( & lval ) ; points . x = Z_LVAL ( lval ) ; } else { points [ i ] . x = var ) ; } SUCCESS ) { if ( Z_TYPE_PP ( var ) != IS_LONG ) { zval lval ; lval = * * var ; zval_copy_ctor ( & lval ) ; convert_to_long ; convert_to_long ( & lval ) ; points . y = Z_LVAL ( lval ) ; } else { points [ i ] . y = ; } } } ",php@php-src/2938329ce19cb8c4197dec146c3ec887c6f61d01,CVE-2014-2020,https://github.com/php/php-src/commit/2938329ce19cb8c4197dec146c3ec887c6f61d01,2014-02-18T11:55Z 1152,CWE-125,"CWE-125 void common_timer_get ( struct k_itimer * timr , struct itimerspec64 * cur_setting ) { const struct k_clock * kc = timr -> kclock ; ktime_t now , remaining , iv ; struct timespec64 ts64 ; bool sig_none ; sig_none = ( timr -> it_sigev_notify & ~ SIGEV_THREAD_ID ) == SIGEV_NONE ; iv = timr -> it_interval ; if ( iv ) { cur_setting -> it_interval = ktime_to_timespec64 ( iv ) ; } else if ( ! timr -> it_active ) { if ( ! sig_none ) return ; } kc -> clock_get ( timr -> it_clock , & ts64 ) ; now = timespec64_to_ktime ( ts64 ) ; if ( iv && ( timr -> it_requeue_pending & REQUEUE_PENDING || sig_none ) ) timr -> it_overrun += kc -> timer_forward ( timr , now ) ; remaining = kc -> timer_remaining ( timr , now ) ; if ( remaining <= 0 ) { if ( ! sig_none ) cur_setting -> it_value . tv_nsec = 1 ; } else { cur_setting -> it_value = ktime_to_timespec64 ( remaining ) ; } } "," ; sig_none = timr -> it_sigev_notify timr -> it_sigev_notify == SIGEV_NONE ; ",torvalds@linux/cef31d9af908243421258f1df35a4a644604efbe,CVE-2017-18344,https://github.com/torvalds/linux/commit/cef31d9af908243421258f1df35a4a644604efbe,2018-07-26T19:29Z 1153,CWE-119,"CWE-119 MagickBooleanType sixel_decode ( unsigned char * p , unsigned char * * pixels , size_t * pwidth , size_t * pheight , unsigned char * * palette , size_t * ncolors ) { int n , i , r , g , b , sixel_vertical_mask , c ; int posision_x , posision_y ; int max_x , max_y ; int attributed_pan , attributed_pad ; int attributed_ph , attributed_pv ; int repeat_count , color_index , max_color_index = 2 , background_color_index ; int param [ 10 ] ; int sixel_palet [ SIXEL_PALETTE_MAX ] ; unsigned char * imbuf , * dmbuf ; int imsx , imsy ; int dmsx , dmsy ; int y ; posision_x = posision_y = 0 ; max_x = max_y = 0 ; attributed_pan = 2 ; attributed_pad = 1 ; attributed_ph = attributed_pv = 0 ; repeat_count = 1 ; color_index = 0 ; background_color_index = 0 ; imsx = 2048 ; imsy = 2048 ; imbuf = ( unsigned char * ) AcquireQuantumMemory ( imsx * imsy , 1 ) ; if ( imbuf == NULL ) { return ( MagickFalse ) ; } for ( n = 0 ; n < 16 ; n ++ ) { sixel_palet [ n ] = sixel_default_color_table [ n ] ; } for ( r = 0 ; r < 6 ; r ++ ) { for ( g = 0 ; g < 6 ; g ++ ) { for ( b = 0 ; b < 6 ; b ++ ) { sixel_palet [ n ++ ] = SIXEL_RGB ( r * 51 , g * 51 , b * 51 ) ; } } } for ( i = 0 ; i < 24 ; i ++ ) { sixel_palet [ n ++ ] = SIXEL_RGB ( i * 11 , i * 11 , i * 11 ) ; } for ( ; n < SIXEL_PALETTE_MAX ; n ++ ) { sixel_palet [ n ] = SIXEL_RGB ( 255 , 255 , 255 ) ; } ( void ) ResetMagickMemory ( imbuf , background_color_index , imsx * imsy ) ; while ( * p != '\\0' ) { if ( ( p [ 0 ] == '\\033' && p [ 1 ] == 'P' ) || * p == 0x90 ) { if ( * p == '\\033' ) { p ++ ; } p = get_params ( ++ p , param , & n ) ; if ( * p == 'q' ) { p ++ ; if ( n > 0 ) { switch ( param [ 0 ] ) { case 0 : case 1 : attributed_pad = 2 ; break ; case 2 : attributed_pad = 5 ; break ; case 3 : attributed_pad = 4 ; break ; case 4 : attributed_pad = 4 ; break ; case 5 : attributed_pad = 3 ; break ; case 6 : attributed_pad = 3 ; break ; case 7 : attributed_pad = 2 ; break ; case 8 : attributed_pad = 2 ; break ; case 9 : attributed_pad = 1 ; break ; } } if ( n > 2 ) { if ( param [ 2 ] == 0 ) { param [ 2 ] = 10 ; } attributed_pan = attributed_pan * param [ 2 ] / 10 ; attributed_pad = attributed_pad * param [ 2 ] / 10 ; if ( attributed_pan <= 0 ) attributed_pan = 1 ; if ( attributed_pad <= 0 ) attributed_pad = 1 ; } } } else if ( ( p [ 0 ] == '\\033' && p [ 1 ] == '\\\\' ) || * p == 0x9C ) { break ; } else if ( * p == \'""\' ) { p = get_params ( ++ p , param , & n ) ; if ( n > 0 ) attributed_pad = param [ 0 ] ; if ( n > 1 ) attributed_pan = param [ 1 ] ; if ( n > 2 && param [ 2 ] > 0 ) attributed_ph = param [ 2 ] ; if ( n > 3 && param [ 3 ] > 0 ) attributed_pv = param [ 3 ] ; if ( attributed_pan <= 0 ) attributed_pan = 1 ; if ( attributed_pad <= 0 ) attributed_pad = 1 ; if ( imsx < attributed_ph || imsy < attributed_pv ) { dmsx = imsx > attributed_ph ? imsx : attributed_ph ; dmsy = imsy > attributed_pv ? imsy : attributed_pv ; dmbuf = ( unsigned char * ) AcquireQuantumMemory ( dmsx * dmsy , 1 ) ; if ( dmbuf == ( unsigned char * ) NULL ) { imbuf = ( unsigned char * ) RelinquishMagickMemory ( imbuf ) ; return ( MagickFalse ) ; } ( void ) ResetMagickMemory ( dmbuf , background_color_index , dmsx * dmsy ) ; for ( y = 0 ; y < imsy ; ++ y ) { ( void ) CopyMagickMemory ( dmbuf + dmsx * y , imbuf + imsx * y , imsx ) ; } imbuf = ( unsigned char * ) RelinquishMagickMemory ( imbuf ) ; imsx = dmsx ; imsy = dmsy ; imbuf = dmbuf ; } } else if ( * p == '!' ) { p = get_params ( ++ p , param , & n ) ; if ( n > 0 ) { repeat_count = param [ 0 ] ; } } else if ( * p == '#' ) { p = get_params ( ++ p , param , & n ) ; if ( n > 0 ) { if ( ( color_index = param [ 0 ] ) < 0 ) { color_index = 0 ; } else if ( color_index >= SIXEL_PALETTE_MAX ) { color_index = SIXEL_PALETTE_MAX - 1 ; } } if ( n > 4 ) { if ( param [ 1 ] == 1 ) { if ( param [ 2 ] > 360 ) param [ 2 ] = 360 ; if ( param [ 3 ] > 100 ) param [ 3 ] = 100 ; if ( param [ 4 ] > 100 ) param [ 4 ] = 100 ; sixel_palet [ color_index ] = hls_to_rgb ( param [ 2 ] * 100 / 360 , param [ 3 ] , param [ 4 ] ) ; } else if ( param [ 1 ] == 2 ) { if ( param [ 2 ] > 100 ) param [ 2 ] = 100 ; if ( param [ 3 ] > 100 ) param [ 3 ] = 100 ; if ( param [ 4 ] > 100 ) param [ 4 ] = 100 ; sixel_palet [ color_index ] = SIXEL_XRGB ( param [ 2 ] , param [ 3 ] , param [ 4 ] ) ; } } } else if ( * p == '$' ) { p ++ ; posision_x = 0 ; repeat_count = 1 ; } else if ( * p == '-' ) { p ++ ; posision_x = 0 ; posision_y += 6 ; repeat_count = 1 ; } else if ( * p >= '?' && * p <= '\\177' ) { if ( imsx < ( posision_x + repeat_count ) || imsy < ( posision_y + 6 ) ) { int nx = imsx * 2 ; int ny = imsy * 2 ; while ( nx < ( posision_x + repeat_count ) || ny < ( posision_y + 6 ) ) { nx *= 2 ; ny *= 2 ; } dmsx = nx ; dmsy = ny ; dmbuf = ( unsigned char * ) AcquireQuantumMemory ( dmsx * dmsy , 1 ) ; if ( dmbuf == ( unsigned char * ) NULL ) { imbuf = ( unsigned char * ) RelinquishMagickMemory ( imbuf ) ; return ( MagickFalse ) ; } ( void ) ResetMagickMemory ( dmbuf , background_color_index , dmsx * dmsy ) ; for ( y = 0 ; y < imsy ; ++ y ) { ( void ) CopyMagickMemory ( dmbuf + dmsx * y , imbuf + imsx * y , imsx ) ; } imbuf = ( unsigned char * ) RelinquishMagickMemory ( imbuf ) ; imsx = dmsx ; imsy = dmsy ; imbuf = dmbuf ; } if ( color_index > max_color_index ) { max_color_index = color_index ; } if ( ( b = * ( p ++ ) - '?' ) == 0 ) { posision_x += repeat_count ; } else { sixel_vertical_mask = 0x01 ; if ( repeat_count <= 1 ) { for ( i = 0 ; i < 6 ; i ++ ) { if ( ( b & sixel_vertical_mask ) != 0 ) { imbuf [ imsx * ( posision_y + i ) + posision_x ] = color_index ; if ( max_x < posision_x ) { max_x = posision_x ; } if ( max_y < ( posision_y + i ) ) { max_y = posision_y + i ; } } sixel_vertical_mask <<= 1 ; } posision_x += 1 ; } else { for ( i = 0 ; i < 6 ; i ++ ) { if ( ( b & sixel_vertical_mask ) != 0 ) { c = sixel_vertical_mask << 1 ; for ( n = 1 ; ( i + n ) < 6 ; n ++ ) { if ( ( b & c ) == 0 ) { break ; } c <<= 1 ; } for ( y = posision_y + i ; y < posision_y + i + n ; ++ y ) { ( void ) ResetMagickMemory ( imbuf + imsx * y + posision_x , color_index , repeat_count ) ; } if ( max_x < ( posision_x + repeat_count - 1 ) ) { max_x = posision_x + repeat_count - 1 ; } if ( max_y < ( posision_y + i + n - 1 ) ) { max_y = posision_y + i + n - 1 ; } i += ( n - 1 ) ; sixel_vertical_mask <<= ( n - 1 ) ; } sixel_vertical_mask <<= 1 ; } posision_x += repeat_count ; } } repeat_count = 1 ; } else { p ++ ; } } if ( ++ max_x < attributed_ph ) { max_x = attributed_ph ; } if ( ++ max_y < attributed_pv ) { max_y = attributed_pv ; } if ( imsx > max_x || imsy > max_y ) { dmsx = max_x ; dmsy = max_y ; if ( ( dmbuf = ( unsigned char * ) AcquireQuantumMemory ( dmsx * dmsy , 1 ) ) == NULL ) { imbuf = ( unsigned char * ) RelinquishMagickMemory ( imbuf ) ; return ( MagickFalse ) ; } for ( y = 0 ; y < dmsy ; ++ y ) { ( void ) CopyMagickMemory ( dmbuf + dmsx * y , imbuf + imsx * y , dmsx ) ; } imbuf = ( unsigned char * ) RelinquishMagickMemory ( imbuf ) ; imsx = dmsx ; imsy = dmsy ; imbuf = dmbuf ; } * pixels = imbuf ; * pwidth = imsx ; * pheight = imsy ; * ncolors = max_color_index + 1 ; * palette = ( unsigned char * ) AcquireQuantumMemory ( * ncolors , 4 ) ; for ( n = 0 ; n < ( ssize_t ) * ncolors ; ++ n ) { ( * palette ) [ n * 4 + 0 ] = sixel_palet [ n ] >> 16 & 0xff ; ( * palette ) [ n * 4 + 1 ] = sixel_palet [ n ] >> 8 & 0xff ; ( * palette ) [ n * 4 + 2 ] = sixel_palet [ n ] & 0xff ; ( * palette ) [ n * 4 + 3 ] = 0xff ; } return ( MagickTrue ) ; } "," AcquireQuantumMemory ( imsx , imsy ) ; if , background_color_index , ( size_t ) AcquireQuantumMemory ( dmsx , dmsy ) ; if , background_color_index , ( size_t ) , imbuf + ( size_t ) AcquireQuantumMemory ( dmsx , dmsy ) ; if , background_color_index , ( size_t ) , imbuf + ( size_t ) ( imbuf + ( size_t ) AcquireQuantumMemory ( dmsx , dmsy ) ) == ",ImageMagick@ImageMagick/10b3823a7619ed22d42764733eb052c4159bc8c1,CVE-2016-10057,https://github.com/ImageMagick/ImageMagick/commit/10b3823a7619ed22d42764733eb052c4159bc8c1,2017-03-23T17:59Z 1154,CWE-119,"CWE-119 static void t1_check_unusual_charstring ( void ) { char * p = strstr ( t1_line_array , charstringname ) + strlen ( charstringname ) ; int i ; if ( sscanf ( p , ""%i"" , & i ) != 1 ) { strcpy ( t1_buf_array , t1_line_array ) ; * ( strend ( t1_buf_array ) - 1 ) = '' ; t1_getline ( ) ; strcat ( t1_buf_array , t1_line_array ) ; strcpy ( t1_line_array , t1_buf_array ) ; t1_line_ptr = eol ( t1_line_array ) ; } } "," ( ) ; alloc_array ( t1_buf , strlen ( t1_line_array ) + strlen ( t1_buf_array ) + 1 , T1_BUF_SIZE ) ; t1_buf_array , t1_line_array ) ; alloc_array ( t1_line , strlen ( t1_buf_array ) + 1 , T1_BUF_SIZE ",TeX-Live@texlive-source/6ed0077520e2b0da1fd060c7f88db7b2e6068e4c,CVE-2018-17407,https://github.com/TeX-Live/texlive-source/commit/6ed0077520e2b0da1fd060c7f88db7b2e6068e4c,2018-09-23T21:29Z 1155,CWE-119,"CWE-119 static vpx_codec_err_t ctrl_copy_reference ( vpx_codec_alg_priv_t * ctx , int ctr_id , va_list args ) { vpx_ref_frame_t * data = va_arg ( args , vpx_ref_frame_t * ) ; if ( data ) { vpx_ref_frame_t * frame = ( vpx_ref_frame_t * ) data ; YV12_BUFFER_CONFIG sd ; image2yuvconfig ( & frame -> img , & sd ) ; return vp9_copy_reference_dec ( ctx -> pbi , ( VP9_REFFRAME ) frame -> frame_type , & sd ) ; } else { return VPX_CODEC_INVALID_PARAM ; } } "," * ctx , va_list args ) * ) ; if ( ctx -> frame_parallel_decode ) { set_error_detail ( ctx , ""Notsupportedinframeparalleldecode"" ) ; return VPX_CODEC_INCAPABLE ; } YV12_BUFFER_CONFIG sd ; VPxWorker * const worker = ctx -> frame_workers ; FrameWorkerData * const frame_worker_data = ( FrameWorkerData * ) worker -> data1 ; return vp9_copy_reference_dec ( frame_worker_data -> pbi , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1156,CWE-89,"CWE-89 static CURLcode pop3_parse_url_path ( struct connectdata * conn ) { struct pop3_conn * pop3c = & conn -> proto . pop3c ; struct SessionHandle * data = conn -> data ; const char * path = data -> state . path ; pop3c -> mailbox = curl_easy_unescape ( data , path , 0 , NULL ) ; if ( ! pop3c -> mailbox ) return CURLE_OUT_OF_MEMORY ; return CURLE_OK ; } "," . path ; return Curl_urldecode ( data , , 0 , & pop3c -> mailbox pop3c -> mailbox , NULL , TRUE ) ; } ",bagder@curl/75ca568fa1c19de4c5358fed246686de8467c238,CVE-2012-0036,https://github.com/bagder/curl/commit/75ca568fa1c19de4c5358fed246686de8467c238,2012-04-13T20:55Z 1157,CWE-20,"CWE-20 int rose_parse_facilities ( unsigned char * p , struct rose_facilities_struct * facilities ) { int facilities_len , len ; facilities_len = * p ++ ; if ( facilities_len == 0 ) return 0 ; while ( facilities_len > 0 ) { if ( * p == 0x00 ) { facilities_len -- ; p ++ ; switch ( * p ) { case FAC_NATIONAL : len = rose_parse_national ( p + 1 , facilities , facilities_len - 1 ) ; facilities_len -= len + 1 ; p += len + 1 ; break ; case FAC_CCITT : len = rose_parse_ccitt ( p + 1 , facilities , facilities_len - 1 ) ; facilities_len -= len + 1 ; p += len + 1 ; break ; default : printk ( KERN_DEBUG ""ROSE:rose_parse_facilities-unknownfacilitiesfamily%02X\\n"" , * p ) ; facilities_len -- ; p ++ ; break ; } } else break ; } return 1 ; } "," 1 ) ; if ( len < 0 ) return 0 ; 1 ) ; if ( len < 0 ) return 0 ; ",torvalds@linux/be20250c13f88375345ad99950190685eda51eb8,CVE-2011-4913,https://github.com/torvalds/linux/commit/be20250c13f88375345ad99950190685eda51eb8,2012-06-21T23:55Z 1158,CWE-476,"CWE-476 static int hls_slice_header ( HEVCContext * s ) { GetBitContext * gb = & s -> HEVClc -> gb ; SliceHeader * sh = & s -> sh ; int i , ret ; sh -> first_slice_in_pic_flag = get_bits1 ( gb ) ; if ( ( IS_IDR ( s ) || IS_BLA ( s ) ) && sh -> first_slice_in_pic_flag ) { s -> seq_decode = ( s -> seq_decode + 1 ) & 0xff ; s -> max_ra = INT_MAX ; if ( IS_IDR ( s ) ) ff_hevc_clear_refs ( s ) ; } sh -> no_output_of_prior_pics_flag = 0 ; if ( IS_IRAP ( s ) ) sh -> no_output_of_prior_pics_flag = get_bits1 ( gb ) ; sh -> pps_id = get_ue_golomb_long ( gb ) ; if ( sh -> pps_id >= HEVC_MAX_PPS_COUNT || ! s -> ps . pps_list [ sh -> pps_id ] ) { av_log ( s -> avctx , AV_LOG_ERROR , ""PPSidoutofrange:%d\\n"" , sh -> pps_id ) ; return AVERROR_INVALIDDATA ; } if ( ! sh -> first_slice_in_pic_flag && s -> ps . pps != ( HEVCPPS * ) s -> ps . pps_list [ sh -> pps_id ] -> data ) { av_log ( s -> avctx , AV_LOG_ERROR , ""PPSchangedbetweenslices.\\n"" ) ; return AVERROR_INVALIDDATA ; } s -> ps . pps = ( HEVCPPS * ) s -> ps . pps_list [ sh -> pps_id ] -> data ; if ( s -> nal_unit_type == HEVC_NAL_CRA_NUT && s -> last_eos == 1 ) sh -> no_output_of_prior_pics_flag = 1 ; if ( s -> ps . sps != ( HEVCSPS * ) s -> ps . sps_list [ s -> ps . pps -> sps_id ] -> data ) { const HEVCSPS * sps = ( HEVCSPS * ) s -> ps . sps_list [ s -> ps . pps -> sps_id ] -> data ; const HEVCSPS * last_sps = s -> ps . sps ; enum AVPixelFormat pix_fmt ; if ( last_sps && IS_IRAP ( s ) && s -> nal_unit_type != HEVC_NAL_CRA_NUT ) { if ( sps -> width != last_sps -> width || sps -> height != last_sps -> height || sps -> temporal_layer [ sps -> max_sub_layers - 1 ] . max_dec_pic_buffering != last_sps -> temporal_layer [ last_sps -> max_sub_layers - 1 ] . max_dec_pic_buffering ) sh -> no_output_of_prior_pics_flag = 0 ; } ff_hevc_clear_refs ( s ) ; ret = set_sps ( s , sps , sps -> pix_fmt ) ; if ( ret < 0 ) return ret ; pix_fmt = get_format ( s , sps ) ; if ( pix_fmt < 0 ) return pix_fmt ; s -> avctx -> pix_fmt = pix_fmt ; s -> seq_decode = ( s -> seq_decode + 1 ) & 0xff ; s -> max_ra = INT_MAX ; } sh -> dependent_slice_segment_flag = 0 ; if ( ! sh -> first_slice_in_pic_flag ) { int slice_address_length ; if ( s -> ps . pps -> dependent_slice_segments_enabled_flag ) sh -> dependent_slice_segment_flag = get_bits1 ( gb ) ; slice_address_length = av_ceil_log2 ( s -> ps . sps -> ctb_width * s -> ps . sps -> ctb_height ) ; sh -> slice_segment_addr = get_bitsz ( gb , slice_address_length ) ; if ( sh -> slice_segment_addr >= s -> ps . sps -> ctb_width * s -> ps . sps -> ctb_height ) { av_log ( s -> avctx , AV_LOG_ERROR , ""Invalidslicesegmentaddress:%u.\\n"" , sh -> slice_segment_addr ) ; return AVERROR_INVALIDDATA ; } if ( ! sh -> dependent_slice_segment_flag ) { sh -> slice_addr = sh -> slice_segment_addr ; s -> slice_idx ++ ; } } else { sh -> slice_segment_addr = sh -> slice_addr = 0 ; s -> slice_idx = 0 ; s -> slice_initialized = 0 ; } if ( ! sh -> dependent_slice_segment_flag ) { s -> slice_initialized = 0 ; for ( i = 0 ; i < s -> ps . pps -> num_extra_slice_header_bits ; i ++ ) skip_bits ( gb , 1 ) ; sh -> slice_type = get_ue_golomb_long ( gb ) ; if ( ! ( sh -> slice_type == HEVC_SLICE_I || sh -> slice_type == HEVC_SLICE_P || sh -> slice_type == HEVC_SLICE_B ) ) { av_log ( s -> avctx , AV_LOG_ERROR , ""Unknownslicetype:%d.\\n"" , sh -> slice_type ) ; return AVERROR_INVALIDDATA ; } if ( IS_IRAP ( s ) && sh -> slice_type != HEVC_SLICE_I ) { av_log ( s -> avctx , AV_LOG_ERROR , ""InterslicesinanIRAPframe.\\n"" ) ; return AVERROR_INVALIDDATA ; } sh -> pic_output_flag = 1 ; if ( s -> ps . pps -> output_flag_present_flag ) sh -> pic_output_flag = get_bits1 ( gb ) ; if ( s -> ps . sps -> separate_colour_plane_flag ) sh -> colour_plane_id = get_bits ( gb , 2 ) ; if ( ! IS_IDR ( s ) ) { int poc , pos ; sh -> pic_order_cnt_lsb = get_bits ( gb , s -> ps . sps -> log2_max_poc_lsb ) ; poc = ff_hevc_compute_poc ( s -> ps . sps , s -> pocTid0 , sh -> pic_order_cnt_lsb , s -> nal_unit_type ) ; if ( ! sh -> first_slice_in_pic_flag && poc != s -> poc ) { av_log ( s -> avctx , AV_LOG_WARNING , ""IgnoringPOCchangebetweenslices:%d->%d\\n"" , s -> poc , poc ) ; if ( s -> avctx -> err_recognition & AV_EF_EXPLODE ) return AVERROR_INVALIDDATA ; poc = s -> poc ; } s -> poc = poc ; sh -> short_term_ref_pic_set_sps_flag = get_bits1 ( gb ) ; pos = get_bits_left ( gb ) ; if ( ! sh -> short_term_ref_pic_set_sps_flag ) { ret = ff_hevc_decode_short_term_rps ( gb , s -> avctx , & sh -> slice_rps , s -> ps . sps , 1 ) ; if ( ret < 0 ) return ret ; sh -> short_term_rps = & sh -> slice_rps ; } else { int numbits , rps_idx ; if ( ! s -> ps . sps -> nb_st_rps ) { av_log ( s -> avctx , AV_LOG_ERROR , ""NoreflistsintheSPS.\\n"" ) ; return AVERROR_INVALIDDATA ; } numbits = av_ceil_log2 ( s -> ps . sps -> nb_st_rps ) ; rps_idx = numbits > 0 ? get_bits ( gb , numbits ) : 0 ; sh -> short_term_rps = & s -> ps . sps -> st_rps [ rps_idx ] ; } sh -> short_term_ref_pic_set_size = pos - get_bits_left ( gb ) ; pos = get_bits_left ( gb ) ; ret = decode_lt_rps ( s , & sh -> long_term_rps , gb ) ; if ( ret < 0 ) { av_log ( s -> avctx , AV_LOG_WARNING , ""InvalidlongtermRPS.\\n"" ) ; if ( s -> avctx -> err_recognition & AV_EF_EXPLODE ) return AVERROR_INVALIDDATA ; } sh -> long_term_ref_pic_set_size = pos - get_bits_left ( gb ) ; if ( s -> ps . sps -> sps_temporal_mvp_enabled_flag ) sh -> slice_temporal_mvp_enabled_flag = get_bits1 ( gb ) ; else sh -> slice_temporal_mvp_enabled_flag = 0 ; } else { s -> sh . short_term_rps = NULL ; s -> poc = 0 ; } if ( sh -> first_slice_in_pic_flag && s -> temporal_id == 0 && s -> nal_unit_type != HEVC_NAL_TRAIL_N && s -> nal_unit_type != HEVC_NAL_TSA_N && s -> nal_unit_type != HEVC_NAL_STSA_N && s -> nal_unit_type != HEVC_NAL_RADL_N && s -> nal_unit_type != HEVC_NAL_RADL_R && s -> nal_unit_type != HEVC_NAL_RASL_N && s -> nal_unit_type != HEVC_NAL_RASL_R ) s -> pocTid0 = s -> poc ; if ( s -> ps . sps -> sao_enabled ) { sh -> slice_sample_adaptive_offset_flag [ 0 ] = get_bits1 ( gb ) ; if ( s -> ps . sps -> chroma_format_idc ) { sh -> slice_sample_adaptive_offset_flag [ 1 ] = sh -> slice_sample_adaptive_offset_flag [ 2 ] = get_bits1 ( gb ) ; } } else { sh -> slice_sample_adaptive_offset_flag [ 0 ] = 0 ; sh -> slice_sample_adaptive_offset_flag [ 1 ] = 0 ; sh -> slice_sample_adaptive_offset_flag [ 2 ] = 0 ; } sh -> nb_refs [ L0 ] = sh -> nb_refs [ L1 ] = 0 ; if ( sh -> slice_type == HEVC_SLICE_P || sh -> slice_type == HEVC_SLICE_B ) { int nb_refs ; sh -> nb_refs [ L0 ] = s -> ps . pps -> num_ref_idx_l0_default_active ; if ( sh -> slice_type == HEVC_SLICE_B ) sh -> nb_refs [ L1 ] = s -> ps . pps -> num_ref_idx_l1_default_active ; if ( get_bits1 ( gb ) ) { sh -> nb_refs [ L0 ] = get_ue_golomb_long ( gb ) + 1 ; if ( sh -> slice_type == HEVC_SLICE_B ) sh -> nb_refs [ L1 ] = get_ue_golomb_long ( gb ) + 1 ; } if ( sh -> nb_refs [ L0 ] > HEVC_MAX_REFS || sh -> nb_refs [ L1 ] > HEVC_MAX_REFS ) { av_log ( s -> avctx , AV_LOG_ERROR , ""Toomanyrefs:%d/%d.\\n"" , sh -> nb_refs [ L0 ] , sh -> nb_refs [ L1 ] ) ; return AVERROR_INVALIDDATA ; } sh -> rpl_modification_flag [ 0 ] = 0 ; sh -> rpl_modification_flag [ 1 ] = 0 ; nb_refs = ff_hevc_frame_nb_refs ( s ) ; if ( ! nb_refs ) { av_log ( s -> avctx , AV_LOG_ERROR , ""ZerorefsforaframewithPorBslices.\\n"" ) ; return AVERROR_INVALIDDATA ; } if ( s -> ps . pps -> lists_modification_present_flag && nb_refs > 1 ) { sh -> rpl_modification_flag [ 0 ] = get_bits1 ( gb ) ; if ( sh -> rpl_modification_flag [ 0 ] ) { for ( i = 0 ; i < sh -> nb_refs [ L0 ] ; i ++ ) sh -> list_entry_lx [ 0 ] [ i ] = get_bits ( gb , av_ceil_log2 ( nb_refs ) ) ; } if ( sh -> slice_type == HEVC_SLICE_B ) { sh -> rpl_modification_flag [ 1 ] = get_bits1 ( gb ) ; if ( sh -> rpl_modification_flag [ 1 ] == 1 ) for ( i = 0 ; i < sh -> nb_refs [ L1 ] ; i ++ ) sh -> list_entry_lx [ 1 ] [ i ] = get_bits ( gb , av_ceil_log2 ( nb_refs ) ) ; } } if ( sh -> slice_type == HEVC_SLICE_B ) sh -> mvd_l1_zero_flag = get_bits1 ( gb ) ; if ( s -> ps . pps -> cabac_init_present_flag ) sh -> cabac_init_flag = get_bits1 ( gb ) ; else sh -> cabac_init_flag = 0 ; sh -> collocated_ref_idx = 0 ; if ( sh -> slice_temporal_mvp_enabled_flag ) { sh -> collocated_list = L0 ; if ( sh -> slice_type == HEVC_SLICE_B ) sh -> collocated_list = ! get_bits1 ( gb ) ; if ( sh -> nb_refs [ sh -> collocated_list ] > 1 ) { sh -> collocated_ref_idx = get_ue_golomb_long ( gb ) ; if ( sh -> collocated_ref_idx >= sh -> nb_refs [ sh -> collocated_list ] ) { av_log ( s -> avctx , AV_LOG_ERROR , ""Invalidcollocated_ref_idx:%d.\\n"" , sh -> collocated_ref_idx ) ; return AVERROR_INVALIDDATA ; } } } if ( ( s -> ps . pps -> weighted_pred_flag && sh -> slice_type == HEVC_SLICE_P ) || ( s -> ps . pps -> weighted_bipred_flag && sh -> slice_type == HEVC_SLICE_B ) ) { int ret = pred_weight_table ( s , gb ) ; if ( ret < 0 ) return ret ; } sh -> max_num_merge_cand = 5 - get_ue_golomb_long ( gb ) ; if ( sh -> max_num_merge_cand < 1 || sh -> max_num_merge_cand > 5 ) { av_log ( s -> avctx , AV_LOG_ERROR , ""InvalidnumberofmergingMVPcandidates:%d.\\n"" , sh -> max_num_merge_cand ) ; return AVERROR_INVALIDDATA ; } } sh -> slice_qp_delta = get_se_golomb ( gb ) ; if ( s -> ps . pps -> pic_slice_level_chroma_qp_offsets_present_flag ) { sh -> slice_cb_qp_offset = get_se_golomb ( gb ) ; sh -> slice_cr_qp_offset = get_se_golomb ( gb ) ; } else { sh -> slice_cb_qp_offset = 0 ; sh -> slice_cr_qp_offset = 0 ; } if ( s -> ps . pps -> chroma_qp_offset_list_enabled_flag ) sh -> cu_chroma_qp_offset_enabled_flag = get_bits1 ( gb ) ; else sh -> cu_chroma_qp_offset_enabled_flag = 0 ; if ( s -> ps . pps -> deblocking_filter_control_present_flag ) { int deblocking_filter_override_flag = 0 ; if ( s -> ps . pps -> deblocking_filter_override_enabled_flag ) deblocking_filter_override_flag = get_bits1 ( gb ) ; if ( deblocking_filter_override_flag ) { sh -> disable_deblocking_filter_flag = get_bits1 ( gb ) ; if ( ! sh -> disable_deblocking_filter_flag ) { int beta_offset_div2 = get_se_golomb ( gb ) ; int tc_offset_div2 = get_se_golomb ( gb ) ; if ( beta_offset_div2 < - 6 || beta_offset_div2 > 6 || tc_offset_div2 < - 6 || tc_offset_div2 > 6 ) { av_log ( s -> avctx , AV_LOG_ERROR , ""Invaliddeblockfilteroffsets:%d,%d\\n"" , beta_offset_div2 , tc_offset_div2 ) ; return AVERROR_INVALIDDATA ; } sh -> beta_offset = beta_offset_div2 * 2 ; sh -> tc_offset = tc_offset_div2 * 2 ; } } else { sh -> disable_deblocking_filter_flag = s -> ps . pps -> disable_dbf ; sh -> beta_offset = s -> ps . pps -> beta_offset ; sh -> tc_offset = s -> ps . pps -> tc_offset ; } } else { sh -> disable_deblocking_filter_flag = 0 ; sh -> beta_offset = 0 ; sh -> tc_offset = 0 ; } if ( s -> ps . pps -> seq_loop_filter_across_slices_enabled_flag && ( sh -> slice_sample_adaptive_offset_flag [ 0 ] || sh -> slice_sample_adaptive_offset_flag [ 1 ] || ! sh -> disable_deblocking_filter_flag ) ) { sh -> slice_loop_filter_across_slices_enabled_flag = get_bits1 ( gb ) ; } else { sh -> slice_loop_filter_across_slices_enabled_flag = s -> ps . pps -> seq_loop_filter_across_slices_enabled_flag ; } } else if ( ! s -> slice_initialized ) { av_log ( s -> avctx , AV_LOG_ERROR , ""Independentslicesegmentmissing.\\n"" ) ; return AVERROR_INVALIDDATA ; } sh -> num_entry_point_offsets = 0 ; if ( s -> ps . pps -> tiles_enabled_flag || s -> ps . pps -> entropy_coding_sync_enabled_flag ) { unsigned num_entry_point_offsets = get_ue_golomb_long ( gb ) ; if ( num_entry_point_offsets > get_bits_left ( gb ) ) { av_log ( s -> avctx , AV_LOG_ERROR , ""num_entry_point_offsets%disinvalid\\n"" , num_entry_point_offsets ) ; return AVERROR_INVALIDDATA ; } sh -> num_entry_point_offsets = num_entry_point_offsets ; if ( sh -> num_entry_point_offsets > 0 ) { int offset_len = get_ue_golomb_long ( gb ) + 1 ; if ( offset_len < 1 || offset_len > 32 ) { sh -> num_entry_point_offsets = 0 ; av_log ( s -> avctx , AV_LOG_ERROR , ""offset_len%disinvalid\\n"" , offset_len ) ; return AVERROR_INVALIDDATA ; } av_freep ( & sh -> entry_point_offset ) ; av_freep ( & sh -> offset ) ; av_freep ( & sh -> size ) ; sh -> entry_point_offset = av_malloc_array ( sh -> num_entry_point_offsets , sizeof ( unsigned ) ) ; sh -> offset = av_malloc_array ( sh -> num_entry_point_offsets , sizeof ( int ) ) ; sh -> size = av_malloc_array ( sh -> num_entry_point_offsets , sizeof ( int ) ) ; if ( ! sh -> entry_point_offset || ! sh -> offset || ! sh -> size ) { sh -> num_entry_point_offsets = 0 ; av_log ( s -> avctx , AV_LOG_ERROR , ""Failedtoallocatememory\\n"" ) ; return AVERROR ( ENOMEM ) ; } for ( i = 0 ; i < sh -> num_entry_point_offsets ; i ++ ) { unsigned val = get_bits_long ( gb , offset_len ) ; sh -> entry_point_offset [ i ] = val + 1 ; } if ( s -> threads_number > 1 && ( s -> ps . pps -> num_tile_rows > 1 || s -> ps . pps -> num_tile_columns > 1 ) ) { s -> enable_parallel_tiles = 0 ; s -> threads_number = 1 ; } else s -> enable_parallel_tiles = 0 ; } else s -> enable_parallel_tiles = 0 ; } if ( s -> ps . pps -> slice_header_extension_present_flag ) { unsigned int length = get_ue_golomb_long ( gb ) ; if ( length * 8LL > get_bits_left ( gb ) ) { av_log ( s -> avctx , AV_LOG_ERROR , ""toomanyslice_header_extension_data_bytes\\n"" ) ; return AVERROR_INVALIDDATA ; } for ( i = 0 ; i < length ; i ++ ) skip_bits ( gb , 8 ) ; } sh -> slice_qp = 26U + s -> ps . pps -> pic_init_qp_minus26 + sh -> slice_qp_delta ; if ( sh -> slice_qp > 51 || sh -> slice_qp < - s -> ps . sps -> qp_bd_offset ) { av_log ( s -> avctx , AV_LOG_ERROR , ""Theslice_qp%disoutsidethevalidrange"" ""[%d,51].\\n"" , sh -> slice_qp , - s -> ps . sps -> qp_bd_offset ) ; return AVERROR_INVALIDDATA ; } sh -> slice_ctb_addr_rs = sh -> slice_segment_addr ; if ( ! s -> sh . slice_ctb_addr_rs && s -> sh . dependent_slice_segment_flag ) { av_log ( s -> avctx , AV_LOG_ERROR , ""Impossibleslicesegment.\\n"" ) ; return AVERROR_INVALIDDATA ; } if ( get_bits_left ( gb ) < 0 ) { av_log ( s -> avctx , AV_LOG_ERROR , ""Overreadsliceheaderby%dbits\\n"" , - get_bits_left ( gb ) ) ; return AVERROR_INVALIDDATA ; } s -> HEVClc -> first_qp_group = ! s -> sh . dependent_slice_segment_flag ; if ( ! s -> ps . pps -> cu_qp_delta_enabled_flag ) s -> HEVClc -> qp_y = s -> sh . slice_qp ; s -> slice_initialized = 1 ; s -> HEVClc -> tu . cu_qp_offset_cb = 0 ; s -> HEVClc -> tu . cu_qp_offset_cr = 0 ; return 0 ; } "," gb ) ; if ( s -> ref && sh -> first_slice_in_pic_flag ) { av_log ( s -> avctx , AV_LOG_ERROR , ""Twoslicesreportingbeingthefirstinthesameframe.\\n"" ) ; return 1 ; } ",FFmpeg@FFmpeg/54655623a82632e7624714d7b2a3e039dc5faa7e,CVE-2019-11338,https://github.com/FFmpeg/FFmpeg/commit/54655623a82632e7624714d7b2a3e039dc5faa7e,2019-04-19T00:29Z 1159,CWE-20,"CWE-20 WORD32 ih264d_mark_err_slice_skip ( dec_struct_t * ps_dec , WORD32 num_mb_skip , UWORD8 u1_is_idr_slice , UWORD16 u2_frame_num , pocstruct_t * ps_cur_poc , WORD32 prev_slice_err ) { WORD32 i2_cur_mb_addr ; UWORD32 u1_num_mbs , u1_num_mbsNby2 ; UWORD32 u1_mb_idx = ps_dec -> u1_mb_idx ; UWORD32 i2_mb_skip_run ; UWORD32 u1_num_mbs_next , u1_end_of_row ; const UWORD32 i2_pic_wdin_mbs = ps_dec -> u2_frm_wd_in_mbs ; UWORD32 u1_slice_end ; UWORD32 u1_tfr_n_mb ; UWORD32 u1_decode_nmb ; dec_bit_stream_t * const ps_bitstrm = ps_dec -> ps_bitstrm ; dec_slice_params_t * ps_slice = ps_dec -> ps_cur_slice ; UWORD32 * pu4_bitstrm_buf = ps_bitstrm -> pu4_buffer ; UWORD32 * pu4_bitstrm_ofst = & ps_bitstrm -> u4_ofst ; deblk_mb_t * ps_cur_deblk_mb ; dec_mb_info_t * ps_cur_mb_info ; parse_pmbarams_t * ps_parse_mb_data ; UWORD32 u1_inter_mb_type ; UWORD32 u1_deblk_mb_type ; UWORD16 u2_total_mbs_coded ; UWORD32 u1_mbaff = ps_slice -> u1_mbaff_frame_flag ; parse_part_params_t * ps_part_info ; WORD32 ret ; if ( ps_dec -> ps_dec_err_status -> u1_err_flag & REJECT_CUR_PIC ) { ih264d_err_pic_dispbuf_mgr ( ps_dec ) ; return 0 ; } ps_dec -> ps_dpb_cmds -> u1_long_term_reference_flag = 0 ; if ( prev_slice_err == 1 ) { ps_dec -> ps_cur_slice -> u2_frame_num = u2_frame_num ; if ( ! ps_dec -> u1_first_slice_in_stream ) { ih264d_end_of_pic ( ps_dec , u1_is_idr_slice , ps_dec -> ps_cur_slice -> u2_frame_num ) ; ps_dec -> s_cur_pic_poc . u2_frame_num = ps_dec -> ps_cur_slice -> u2_frame_num ; } { WORD32 i , j , poc = 0 ; ps_dec -> ps_cur_slice -> u2_first_mb_in_slice = 0 ; ps_dec -> pf_mvpred = ih264d_mvpred_nonmbaff ; ps_dec -> p_form_mb_part_info = ih264d_form_mb_part_info_bp ; ps_dec -> p_motion_compensate = ih264d_motion_compensate_bp ; if ( ps_dec -> ps_cur_pic != NULL ) poc = ps_dec -> ps_cur_pic -> i4_poc + 2 ; j = 0 ; for ( i = 0 ; i < MAX_NUM_PIC_PARAMS ; i ++ ) if ( ps_dec -> ps_pps [ i ] . u1_is_valid == TRUE ) j = i ; { ps_dec -> ps_cur_slice -> u1_bottom_field_flag = 0 ; ps_dec -> ps_cur_slice -> u1_field_pic_flag = 0 ; ps_dec -> ps_cur_slice -> u1_slice_type = P_SLICE ; ps_dec -> ps_cur_slice -> u1_nal_ref_idc = 1 ; ps_dec -> ps_cur_slice -> u1_nal_unit_type = 1 ; ret = ih264d_start_of_pic ( ps_dec , poc , ps_cur_poc , ps_dec -> ps_cur_slice -> u2_frame_num , & ps_dec -> ps_pps [ j ] ) ; if ( ret != OK ) { return ret ; } } ps_dec -> ps_ref_pic_buf_lx [ 0 ] [ 0 ] -> u1_pic_buf_id = 0 ; ps_dec -> u4_output_present = 0 ; { ih264d_get_next_display_field ( ps_dec , ps_dec -> ps_out_buffer , & ( ps_dec -> s_disp_op ) ) ; if ( 0 != ps_dec -> s_disp_op . u4_error_code ) { ps_dec -> u4_fmt_conv_cur_row = ps_dec -> s_disp_frame_info . u4_y_ht ; } else ps_dec -> u4_output_present = 1 ; } if ( ps_dec -> u1_separate_parse == 1 ) { if ( ps_dec -> u4_dec_thread_created == 0 ) { ithread_create ( ps_dec -> pv_dec_thread_handle , NULL , ( void * ) ih264d_decode_picture_thread , ( void * ) ps_dec ) ; ps_dec -> u4_dec_thread_created = 1 ; } if ( ( ps_dec -> u4_num_cores == 3 ) && ( ( ps_dec -> u4_app_disable_deblk_frm == 0 ) || ps_dec -> i1_recon_in_thread3_flag ) && ( ps_dec -> u4_bs_deblk_thread_created == 0 ) ) { ps_dec -> u4_start_recon_deblk = 0 ; ithread_create ( ps_dec -> pv_bs_deblk_thread_handle , NULL , ( void * ) ih264d_recon_deblk_thread , ( void * ) ps_dec ) ; ps_dec -> u4_bs_deblk_thread_created = 1 ; } } } } else { dec_slice_struct_t * ps_parse_cur_slice ; ps_parse_cur_slice = ps_dec -> ps_dec_slice_buf + ps_dec -> u2_cur_slice_num ; if ( ps_dec -> u1_slice_header_done && ps_parse_cur_slice == ps_dec -> ps_parse_cur_slice ) { u1_num_mbs = ps_dec -> u4_num_mbs_cur_nmb ; if ( u1_num_mbs ) { ps_cur_mb_info = ps_dec -> ps_nmb_info + u1_num_mbs - 1 ; } else { if ( ps_dec -> u1_separate_parse ) { ps_cur_mb_info = ps_dec -> ps_nmb_info - 1 ; } else { ps_cur_mb_info = ps_dec -> ps_nmb_info + ps_dec -> u4_num_mbs_prev_nmb - 1 ; } } ps_dec -> u2_mby = ps_cur_mb_info -> u2_mby ; ps_dec -> u2_mbx = ps_cur_mb_info -> u2_mbx ; ps_dec -> u1_mb_ngbr_availablity = ps_cur_mb_info -> u1_mb_ngbr_availablity ; ps_dec -> pv_parse_tu_coeff_data = ps_dec -> pv_prev_mb_parse_tu_coeff_data ; ps_dec -> u2_cur_mb_addr -- ; ps_dec -> i4_submb_ofst -= SUB_BLK_SIZE ; if ( u1_num_mbs ) { if ( ps_dec -> u1_pr_sl_type == P_SLICE || ps_dec -> u1_pr_sl_type == B_SLICE ) { ps_dec -> pf_mvpred_ref_tfr_nby2mb ( ps_dec , u1_mb_idx , u1_num_mbs ) ; ps_dec -> ps_part = ps_dec -> ps_parse_part_params ; } u1_num_mbs_next = i2_pic_wdin_mbs - ps_dec -> u2_mbx - 1 ; u1_end_of_row = ( ! u1_num_mbs_next ) && ( ! ( u1_mbaff && ( u1_num_mbs & 0x01 ) ) ) ; u1_slice_end = 1 ; u1_tfr_n_mb = 1 ; ps_cur_mb_info -> u1_end_of_slice = u1_slice_end ; if ( ps_dec -> u1_separate_parse ) { ih264d_parse_tfr_nmb ( ps_dec , u1_mb_idx , u1_num_mbs , u1_num_mbs_next , u1_tfr_n_mb , u1_end_of_row ) ; ps_dec -> ps_nmb_info += u1_num_mbs ; } else { ih264d_decode_recon_tfr_nmb ( ps_dec , u1_mb_idx , u1_num_mbs , u1_num_mbs_next , u1_tfr_n_mb , u1_end_of_row ) ; } ps_dec -> u2_total_mbs_coded += u1_num_mbs ; ps_dec -> u1_mb_idx = 0 ; ps_dec -> u4_num_mbs_cur_nmb = 0 ; } if ( ps_dec -> u2_total_mbs_coded >= ps_dec -> u2_frm_ht_in_mbs * ps_dec -> u2_frm_wd_in_mbs ) { ps_dec -> u1_pic_decode_done = 1 ; return 0 ; } ps_dec -> u2_cur_slice_num ++ ; ps_dec -> i2_prev_slice_mbx = ps_dec -> u2_mbx ; ps_dec -> i2_prev_slice_mby = ps_dec -> u2_mby ; ps_dec -> ps_parse_cur_slice ++ ; } else { ps_dec -> ps_parse_cur_slice = ps_dec -> ps_dec_slice_buf + ps_dec -> u2_cur_slice_num ; } } { WORD32 num_entries ; WORD32 size ; UWORD8 * pu1_buf ; num_entries = MAX_FRAMES ; if ( ( 1 >= ps_dec -> ps_cur_sps -> u1_num_ref_frames ) && ( 0 == ps_dec -> i4_display_delay ) ) { num_entries = 1 ; } num_entries = ( ( 2 * num_entries ) + 1 ) ; if ( BASE_PROFILE_IDC != ps_dec -> ps_cur_sps -> u1_profile_idc ) { num_entries *= 2 ; } size = num_entries * sizeof ( void * ) ; size += PAD_MAP_IDX_POC * sizeof ( void * ) ; pu1_buf = ( UWORD8 * ) ps_dec -> pv_map_ref_idx_to_poc_buf ; pu1_buf += size * ps_dec -> u2_cur_slice_num ; ps_dec -> ps_parse_cur_slice -> ppv_map_ref_idx_to_poc = ( volatile void * * ) pu1_buf ; } ps_dec -> ps_cur_slice -> u2_first_mb_in_slice = ps_dec -> u2_total_mbs_coded << u1_mbaff ; ps_dec -> ps_cur_slice -> i1_slice_alpha_c0_offset = 0 ; ps_dec -> ps_cur_slice -> i1_slice_beta_offset = 0 ; if ( ps_dec -> ps_cur_slice -> u1_field_pic_flag ) ps_dec -> u2_prv_frame_num = ps_dec -> ps_cur_slice -> u2_frame_num ; ps_dec -> ps_parse_cur_slice -> u4_first_mb_in_slice = ps_dec -> u2_total_mbs_coded << u1_mbaff ; ps_dec -> ps_parse_cur_slice -> u2_log2Y_crwd = ps_dec -> ps_cur_slice -> u2_log2Y_crwd ; if ( ps_dec -> u1_separate_parse ) { ps_dec -> ps_parse_cur_slice -> pv_tu_coeff_data_start = ps_dec -> pv_parse_tu_coeff_data ; } else { ps_dec -> pv_proc_tu_coeff_data = ps_dec -> pv_parse_tu_coeff_data ; } u1_inter_mb_type = P_MB ; u1_deblk_mb_type = D_INTER_MB ; ps_dec -> ps_cur_slice -> u1_slice_type = P_SLICE ; ps_dec -> ps_parse_cur_slice -> slice_type = P_SLICE ; ps_dec -> pf_mvpred_ref_tfr_nby2mb = ih264d_mv_pred_ref_tfr_nby2_pmb ; ps_dec -> ps_part = ps_dec -> ps_parse_part_params ; ps_dec -> u1_slice_header_done = 2 ; ps_dec -> u1_qp = ps_slice -> u1_slice_qp ; ih264d_update_qp ( ps_dec , 0 ) ; u1_mb_idx = ps_dec -> u1_mb_idx ; ps_parse_mb_data = ps_dec -> ps_parse_mb_data ; u1_num_mbs = u1_mb_idx ; u1_slice_end = 0 ; u1_tfr_n_mb = 0 ; u1_decode_nmb = 0 ; u1_num_mbsNby2 = 0 ; i2_cur_mb_addr = ps_dec -> u2_total_mbs_coded ; i2_mb_skip_run = num_mb_skip ; while ( ! u1_slice_end ) { UWORD8 u1_mb_type ; if ( i2_cur_mb_addr > ps_dec -> ps_cur_sps -> u2_max_mb_addr ) break ; ps_cur_mb_info = ps_dec -> ps_nmb_info + u1_num_mbs ; ps_dec -> u4_num_mbs_cur_nmb = u1_num_mbs ; ps_cur_mb_info -> u1_Mux = 0 ; ps_dec -> u4_num_pmbair = ( u1_num_mbs >> u1_mbaff ) ; ps_cur_deblk_mb = ps_dec -> ps_deblk_mbn + u1_num_mbs ; ps_cur_mb_info -> u1_end_of_slice = 0 ; ps_parse_mb_data -> u1_num_part = 1 ; ps_parse_mb_data -> u1_isI_mb = 0 ; if ( u1_mbaff ) ih264d_get_mb_info_cavlc_mbaff ( ps_dec , i2_cur_mb_addr , ps_cur_mb_info , i2_mb_skip_run ) ; else ih264d_get_mb_info_cavlc_nonmbaff ( ps_dec , i2_cur_mb_addr , ps_cur_mb_info , i2_mb_skip_run ) ; if ( ps_dec -> u4_app_disable_deblk_frm == 0 ) { ih264d_set_deblocking_parameters ( ps_cur_deblk_mb , ps_slice , ps_dec -> u1_mb_ngbr_availablity , ps_dec -> u1_cur_mb_fld_dec_flag ) ; } ps_dec -> i1_prev_mb_qp_delta = 0 ; ps_dec -> u1_sub_mb_num = 0 ; ps_cur_mb_info -> u1_mb_type = MB_SKIP ; ps_cur_mb_info -> u1_mb_mc_mode = PRED_16x16 ; ps_cur_mb_info -> u1_cbp = 0 ; ps_part_info = ps_dec -> ps_part ; ps_part_info -> u1_is_direct = PART_DIRECT_16x16 ; ps_part_info -> u1_sub_mb_num = 0 ; ps_dec -> ps_part ++ ; ih264d_update_nnz_for_skipmb ( ps_dec , ps_cur_mb_info , CAVLC ) ; ps_cur_mb_info -> ps_curmb -> u1_mb_type = u1_inter_mb_type ; ps_cur_deblk_mb -> u1_mb_type |= u1_deblk_mb_type ; i2_mb_skip_run -- ; ps_cur_deblk_mb -> u1_mb_qp = ps_dec -> u1_qp ; if ( u1_mbaff ) { ih264d_update_mbaff_left_nnz ( ps_dec , ps_cur_mb_info ) ; } i2_cur_mb_addr ++ ; u1_num_mbs ++ ; u1_num_mbsNby2 ++ ; ps_parse_mb_data ++ ; u1_num_mbs_next = i2_pic_wdin_mbs - ps_dec -> u2_mbx - 1 ; u1_end_of_row = ( ! u1_num_mbs_next ) && ( ! ( u1_mbaff && ( u1_num_mbs & 0x01 ) ) ) ; u1_slice_end = ! i2_mb_skip_run ; u1_tfr_n_mb = ( u1_num_mbs == ps_dec -> u1_recon_mb_grp ) || u1_end_of_row || u1_slice_end ; u1_decode_nmb = u1_tfr_n_mb || u1_slice_end ; ps_cur_mb_info -> u1_end_of_slice = u1_slice_end ; if ( u1_decode_nmb ) { ps_dec -> pf_mvpred_ref_tfr_nby2mb ( ps_dec , u1_mb_idx , u1_num_mbs ) ; u1_num_mbsNby2 = 0 ; ps_parse_mb_data = ps_dec -> ps_parse_mb_data ; ps_dec -> ps_part = ps_dec -> ps_parse_part_params ; if ( ps_dec -> u1_separate_parse ) { ih264d_parse_tfr_nmb ( ps_dec , u1_mb_idx , u1_num_mbs , u1_num_mbs_next , u1_tfr_n_mb , u1_end_of_row ) ; ps_dec -> ps_nmb_info += u1_num_mbs ; } else { ih264d_decode_recon_tfr_nmb ( ps_dec , u1_mb_idx , u1_num_mbs , u1_num_mbs_next , u1_tfr_n_mb , u1_end_of_row ) ; } ps_dec -> u2_total_mbs_coded += u1_num_mbs ; if ( u1_tfr_n_mb ) u1_num_mbs = 0 ; u1_mb_idx = u1_num_mbs ; ps_dec -> u1_mb_idx = u1_num_mbs ; } } ps_dec -> u4_num_mbs_cur_nmb = 0 ; ps_dec -> ps_cur_slice -> u4_mbs_in_slice = i2_cur_mb_addr - ps_dec -> ps_parse_cur_slice -> u4_first_mb_in_slice ; H264_DEC_DEBUG_PRINT ( ""Mbsinslice:%d\\n"" , ps_dec -> ps_cur_slice -> u4_mbs_in_slice ) ; ps_dec -> u2_cur_slice_num ++ ; if ( ps_dec -> u4_first_slice_in_pic != 0 ) ps_dec -> ps_parse_cur_slice ++ ; ps_dec -> i2_prev_slice_mbx = ps_dec -> u2_mbx ; ps_dec -> i2_prev_slice_mby = ps_dec -> u2_mby ; if ( ps_dec -> u2_total_mbs_coded >= ps_dec -> u2_frm_ht_in_mbs * ps_dec -> u2_frm_wd_in_mbs ) { ps_dec -> u1_pic_decode_done = 1 ; } return 0 ; } "," -> ps_cur_slice -> u1_slice_type = P_SLICE ",external@libavc/cc676ebd95247646e67907ccab150fb77a847335,CVE-2016-3741,https://android.googlesource.com/platform/external/libavc/+/cc676ebd95247646e67907ccab150fb77a847335,2016-07-11T01:59Z 1160,CWE-119,"CWE-119 IMPEG2D_ERROR_CODES_T impeg2d_dec_p_b_slice ( dec_state_t * ps_dec ) { WORD16 * pi2_vld_out ; UWORD32 i ; yuv_buf_t * ps_cur_frm_buf = & ps_dec -> s_cur_frm_buf ; UWORD32 u4_frm_offset = 0 ; const dec_mb_params_t * ps_dec_mb_params ; IMPEG2D_ERROR_CODES_T e_error = ( IMPEG2D_ERROR_CODES_T ) IVD_ERROR_NONE ; pi2_vld_out = ps_dec -> ai2_vld_buf ; memset ( ps_dec -> ai2_pred_mv , 0 , sizeof ( ps_dec -> ai2_pred_mv ) ) ; ps_dec -> u2_prev_intra_mb = 0 ; ps_dec -> u2_first_mb = 1 ; ps_dec -> u2_picture_width = ps_dec -> u2_frame_width ; if ( ps_dec -> u2_picture_structure != FRAME_PICTURE ) { ps_dec -> u2_picture_width <<= 1 ; if ( ps_dec -> u2_picture_structure == BOTTOM_FIELD ) { u4_frm_offset = ps_dec -> u2_frame_width ; } } do { UWORD32 u4_x_offset , u4_y_offset ; UWORD32 u4_x_dst_offset = 0 ; UWORD32 u4_y_dst_offset = 0 ; UWORD8 * pu1_out_p ; UWORD8 * pu1_pred ; WORD32 u4_pred_strd ; IMPEG2D_TRACE_MB_START ( ps_dec -> u2_mb_x , ps_dec -> u2_mb_y ) ; if ( ps_dec -> e_pic_type == B_PIC ) impeg2d_dec_pnb_mb_params ( ps_dec ) ; else impeg2d_dec_p_mb_params ( ps_dec ) ; IMPEG2D_TRACE_MB_START ( ps_dec -> u2_mb_x , ps_dec -> u2_mb_y ) ; u4_x_dst_offset = u4_frm_offset + ( ps_dec -> u2_mb_x << 4 ) ; u4_y_dst_offset = ( ps_dec -> u2_mb_y << 4 ) * ps_dec -> u2_picture_width ; pu1_out_p = ps_cur_frm_buf -> pu1_y + u4_x_dst_offset + u4_y_dst_offset ; if ( ps_dec -> u2_prev_intra_mb == 0 ) { UWORD32 offset_x , offset_y , stride ; UWORD16 index = ( ps_dec -> u2_motion_type ) ; if ( ps_dec -> e_mb_pred == BIDIRECT ) { ps_dec_mb_params = & ps_dec -> ps_func_bi_direct [ index ] ; } else { ps_dec_mb_params = & ps_dec -> ps_func_forw_or_back [ index ] ; } stride = ps_dec -> u2_picture_width ; offset_x = u4_frm_offset + ( ps_dec -> u2_mb_x << 4 ) ; offset_y = ( ps_dec -> u2_mb_y << 4 ) ; ps_dec -> s_dest_buf . pu1_y = ps_cur_frm_buf -> pu1_y + offset_y * stride + offset_x ; stride = stride >> 1 ; ps_dec -> s_dest_buf . pu1_u = ps_cur_frm_buf -> pu1_u + ( offset_y >> 1 ) * stride + ( offset_x >> 1 ) ; ps_dec -> s_dest_buf . pu1_v = ps_cur_frm_buf -> pu1_v + ( offset_y >> 1 ) * stride + ( offset_x >> 1 ) ; PROFILE_DISABLE_MC_IF0 ps_dec_mb_params -> pf_mc ( ps_dec ) ; } for ( i = 0 ; i < NUM_LUMA_BLKS ; ++ i ) { if ( ( ps_dec -> u2_cbp & ( 1 << ( BLOCKS_IN_MB - 1 - i ) ) ) != 0 ) { e_error = ps_dec -> pf_vld_inv_quant ( ps_dec , pi2_vld_out , ps_dec -> pu1_inv_scan_matrix , ps_dec -> u2_prev_intra_mb , Y_LUMA , 0 ) ; if ( ( IMPEG2D_ERROR_CODES_T ) IVD_ERROR_NONE != e_error ) { return e_error ; } u4_x_offset = gai2_impeg2_blk_x_off [ i ] ; if ( ps_dec -> u2_field_dct == 0 ) u4_y_offset = gai2_impeg2_blk_y_off_frm [ i ] ; else u4_y_offset = gai2_impeg2_blk_y_off_fld [ i ] ; IMPEG2D_IDCT_INP_STATISTICS ( pi2_vld_out , ps_dec -> u4_non_zero_cols , ps_dec -> u4_non_zero_rows ) ; PROFILE_DISABLE_IDCT_IF0 { WORD32 idx ; if ( 1 == ( ps_dec -> u4_non_zero_cols | ps_dec -> u4_non_zero_rows ) ) idx = 0 ; else idx = 1 ; if ( 0 == ps_dec -> u2_prev_intra_mb ) { pu1_pred = pu1_out_p + u4_y_offset * ps_dec -> u2_picture_width + u4_x_offset ; u4_pred_strd = ps_dec -> u2_picture_width << ps_dec -> u2_field_dct ; } else { pu1_pred = ( UWORD8 * ) gau1_impeg2_zerobuf ; u4_pred_strd = 8 ; } ps_dec -> pf_idct_recon [ idx * 2 + ps_dec -> i4_last_value_one ] ( pi2_vld_out , ps_dec -> ai2_idct_stg1 , pu1_pred , pu1_out_p + u4_y_offset * ps_dec -> u2_picture_width + u4_x_offset , 8 , u4_pred_strd , ps_dec -> u2_picture_width << ps_dec -> u2_field_dct , ~ ps_dec -> u4_non_zero_cols , ~ ps_dec -> u4_non_zero_rows ) ; } } } u4_x_dst_offset >>= 1 ; u4_y_dst_offset >>= 2 ; if ( ( ps_dec -> u2_cbp & 0x02 ) != 0 ) { pu1_out_p = ps_cur_frm_buf -> pu1_u + u4_x_dst_offset + u4_y_dst_offset ; e_error = ps_dec -> pf_vld_inv_quant ( ps_dec , pi2_vld_out , ps_dec -> pu1_inv_scan_matrix , ps_dec -> u2_prev_intra_mb , U_CHROMA , 0 ) ; if ( ( IMPEG2D_ERROR_CODES_T ) IVD_ERROR_NONE != e_error ) { return e_error ; } IMPEG2D_IDCT_INP_STATISTICS ( pi2_vld_out , ps_dec -> u4_non_zero_cols , ps_dec -> u4_non_zero_rows ) ; PROFILE_DISABLE_IDCT_IF0 { WORD32 idx ; if ( 1 == ( ps_dec -> u4_non_zero_cols | ps_dec -> u4_non_zero_rows ) ) idx = 0 ; else idx = 1 ; if ( 0 == ps_dec -> u2_prev_intra_mb ) { pu1_pred = pu1_out_p ; u4_pred_strd = ps_dec -> u2_picture_width >> 1 ; } else { pu1_pred = ( UWORD8 * ) gau1_impeg2_zerobuf ; u4_pred_strd = 8 ; } ps_dec -> pf_idct_recon [ idx * 2 + ps_dec -> i4_last_value_one ] ( pi2_vld_out , ps_dec -> ai2_idct_stg1 , pu1_pred , pu1_out_p , 8 , u4_pred_strd , ps_dec -> u2_picture_width >> 1 , ~ ps_dec -> u4_non_zero_cols , ~ ps_dec -> u4_non_zero_rows ) ; } } if ( ( ps_dec -> u2_cbp & 0x01 ) != 0 ) { pu1_out_p = ps_cur_frm_buf -> pu1_v + u4_x_dst_offset + u4_y_dst_offset ; e_error = ps_dec -> pf_vld_inv_quant ( ps_dec , pi2_vld_out , ps_dec -> pu1_inv_scan_matrix , ps_dec -> u2_prev_intra_mb , V_CHROMA , 0 ) ; if ( ( IMPEG2D_ERROR_CODES_T ) IVD_ERROR_NONE != e_error ) { return e_error ; } IMPEG2D_IDCT_INP_STATISTICS ( pi2_vld_out , ps_dec -> u4_non_zero_cols , ps_dec -> u4_non_zero_rows ) ; PROFILE_DISABLE_IDCT_IF0 { WORD32 idx ; if ( 1 == ( ps_dec -> u4_non_zero_cols | ps_dec -> u4_non_zero_rows ) ) idx = 0 ; else idx = 1 ; if ( 0 == ps_dec -> u2_prev_intra_mb ) { pu1_pred = pu1_out_p ; u4_pred_strd = ps_dec -> u2_picture_width >> 1 ; } else { pu1_pred = ( UWORD8 * ) gau1_impeg2_zerobuf ; u4_pred_strd = 8 ; } ps_dec -> pf_idct_recon [ idx * 2 + ps_dec -> i4_last_value_one ] ( pi2_vld_out , ps_dec -> ai2_idct_stg1 , pu1_pred , pu1_out_p , 8 , u4_pred_strd , ps_dec -> u2_picture_width >> 1 , ~ ps_dec -> u4_non_zero_cols , ~ ps_dec -> u4_non_zero_rows ) ; } } ps_dec -> u2_num_mbs_left -- ; ps_dec -> u2_first_mb = 0 ; ps_dec -> u2_mb_x ++ ; if ( ps_dec -> s_bit_stream . u4_offset > ps_dec -> s_bit_stream . u4_max_offset ) { return IMPEG2D_BITSTREAM_BUFF_EXCEEDED_ERR ; } else if ( ps_dec -> u2_mb_x == ps_dec -> u2_num_horiz_mb ) { ps_dec -> u2_mb_x = 0 ; ps_dec -> u2_mb_y ++ ; } } while ( ps_dec -> u2_num_mbs_left != 0 && impeg2d_bit_stream_nxt ( & ps_dec -> s_bit_stream , 23 ) != 0x0 ) ; return e_error ; } "," , u4_y_offset ; WORD32 ret ; == B_PIC ) ret = ) ; else ret = ( ps_dec ) ; if ( ret ) return IMPEG2D_MB_TEX_DECODE_ERR ",external@libmpeg2/58a6822d7140137ce957c6d2fc20bae1374186c1,CVE-2016-0835,https://android.googlesource.com/platform/external/libmpeg2/+/58a6822d7140137ce957c6d2fc20bae1374186c1,2016-04-18T00:59Z 1161,CWE-119,"CWE-119 vpx_codec_err_t vp9_copy_reference_dec ( VP9Decoder * pbi , VP9_REFFRAME ref_frame_flag , YV12_BUFFER_CONFIG * sd ) { VP9_COMMON * cm = & pbi -> common ; if ( ref_frame_flag == VP9_LAST_FLAG ) { const YV12_BUFFER_CONFIG * const cfg = & cm -> frame_bufs [ cm -> ref_frame_map [ 0 ] ] . buf ; if ( ! equal_dimensions ( cfg , sd ) ) vpx_internal_error ( & cm -> error , VPX_CODEC_ERROR , ""Incorrectbufferdimensions"" ) ; else vp8_yv12_copy_frame ( cfg , sd ) ; } else { vpx_internal_error ( & cm -> error , VPX_CODEC_ERROR , ""Invalidreferenceframe"" ) ; } return cm -> error . error_code ; } "," const cfg = get_ref_frame ( cm , 0 ) ; if ( cfg == NULL ) { vpx_internal_error ( & cm -> error , VPX_CODEC_ERROR , ""No\'last\'referenceframe"" ) ; return VPX_CODEC_ERROR ; } if ( ! ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1162,CWE-190,"CWE-190 void jas_matrix_asr ( jas_matrix_t * matrix , int n ) { int i ; int j ; jas_seqent_t * rowstart ; int rowstep ; jas_seqent_t * data ; assert ( n >= 0 ) ; if ( jas_matrix_numrows ( matrix ) > 0 && jas_matrix_numcols ( matrix ) > 0 ) { assert ( matrix -> rows_ ) ; rowstep = jas_matrix_rowstep ( matrix ) ; for ( i = matrix -> numrows_ , rowstart = matrix -> rows_ [ 0 ] ; i > 0 ; -- i , rowstart += rowstep ) { for ( j = matrix -> numcols_ , data = rowstart ; j > 0 ; -- j , ++ data ) { * data = jas_seqent_asr ( * data , n ) ; } } } } "," n ) { jas_matind_t i ; jas_matind_t j ; jas_seqent_t * rowstart ; jas_matind_t rowstep ; jas_seqent_t ",mdadams@jasper/d42b2388f7f8e0332c846675133acea151fc557a,CVE-2016-9557,https://github.com/mdadams/jasper/commit/d42b2388f7f8e0332c846675133acea151fc557a,2017-03-23T18:59Z 1163,CWE-119,"CWE-119 void vp9_foreach_transformed_block_in_plane ( const MACROBLOCKD * const xd , BLOCK_SIZE bsize , int plane , foreach_transformed_block_visitor visit , void * arg ) { const struct macroblockd_plane * const pd = & xd -> plane [ plane ] ; const MB_MODE_INFO * mbmi = & xd -> mi [ 0 ] -> mbmi ; const TX_SIZE tx_size = plane ? get_uv_tx_size ( mbmi ) : mbmi -> tx_size ; const BLOCK_SIZE plane_bsize = get_plane_block_size ( bsize , pd ) ; const int num_4x4_w = num_4x4_blocks_wide_lookup [ plane_bsize ] ; const int num_4x4_h = num_4x4_blocks_high_lookup [ plane_bsize ] ; const int step = 1 << ( tx_size << 1 ) ; int i ; if ( xd -> mb_to_right_edge < 0 || xd -> mb_to_bottom_edge < 0 ) { int r , c ; int max_blocks_wide = num_4x4_w ; int max_blocks_high = num_4x4_h ; if ( xd -> mb_to_right_edge < 0 ) max_blocks_wide += ( xd -> mb_to_right_edge >> ( 5 + pd -> subsampling_x ) ) ; if ( xd -> mb_to_bottom_edge < 0 ) max_blocks_high += ( xd -> mb_to_bottom_edge >> ( 5 + pd -> subsampling_y ) ) ; i = 0 ; for ( r = 0 ; r < num_4x4_h ; r += ( 1 << tx_size ) ) { for ( c = 0 ; c < num_4x4_w ; c += ( 1 << tx_size ) ) { if ( r < max_blocks_high && c < max_blocks_wide ) visit ( plane , i , plane_bsize , tx_size , arg ) ; i += step ; } } } else { for ( i = 0 ; i < num_4x4_w * num_4x4_h ; i += step ) visit ( plane , i , plane_bsize , tx_size , arg ) ; } } "," get_uv_tx_size ( mbmi , pd ; int i = 0 , r , c ; const int max_blocks_wide = num_4x4_w + ( xd -> xd -> mb_to_right_edge >= 0 ? 0 : xd -> mb_to_right_edge ) ) ; const int max_blocks_high = num_4x4_h + ( xd -> xd -> mb_to_bottom_edge >= 0 ? 0 : xd -> mb_to_bottom_edge ) ) ; const int extra_step = ( ( num_4x4_w - max_blocks_wide ) >> tx_size ) * step ; for ( = 0 ; r < max_blocks_high r < max_blocks_high ; r += ( 1 << tx_size ) ) { for ( c = 0 ; c < max_blocks_wide c < max_blocks_wide ; c += ( 1 << tx_size ) ) { visit ( plane step ; } i += extra_step ; } } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1164,CWE-254,"CWE-254 void arch_pick_mmap_layout ( struct mm_struct * mm ) { unsigned long random_factor = 0UL ; if ( current -> flags & PF_RANDOMIZE ) random_factor = arch_mmap_rnd ( ) ; mm -> mmap_legacy_base = mmap_legacy_base ( random_factor ) ; if ( mmap_is_legacy ( ) ) { mm -> mmap_base = mm -> mmap_legacy_base ; mm -> get_unmapped_area = arch_get_unmapped_area ; } else { mm -> mmap_base = mmap_base ( random_factor ) ; mm -> get_unmapped_area = arch_get_unmapped_area_topdown ; } } "," -> mmap_legacy_base = TASK_UNMAPPED_BASE + random_factor ; if ( ",torvalds@linux/8b8addf891de8a00e4d39fc32f93f7c5eb8feceb,CVE-2016-3672,https://github.com/torvalds/linux/commit/8b8addf891de8a00e4d39fc32f93f7c5eb8feceb,2016-04-27T17:59Z 1165,CWE-119,"CWE-119 void vp8_copy_mem8x4_c ( unsigned char * src , int src_stride , unsigned char * dst , int dst_stride ) { int r ; for ( r = 0 ; r < 4 ; r ++ ) { # if ! ( CONFIG_FAST_UNALIGNED ) dst [ 0 ] = src [ 0 ] ; dst [ 1 ] = src [ 1 ] ; dst [ 2 ] = src [ 2 ] ; dst [ 3 ] = src [ 3 ] ; dst [ 4 ] = src [ 4 ] ; dst [ 5 ] = src [ 5 ] ; dst [ 6 ] = src [ 6 ] ; dst [ 7 ] = src [ 7 ] ; # else ( ( uint32_t * ) dst ) [ 0 ] = ( ( uint32_t * ) src ) [ 0 ] ; ( ( uint32_t * ) dst ) [ 1 ] = ( ( uint32_t * ) src ) [ 1 ] ; # endif src += src_stride ; dst += dst_stride ; } } "," ++ ) { memcpy ( dst , src , 8 ) ; src += src_stride ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1166,CWE-190,"CWE-190 static size_t optsize ( lua_State * L , char opt , const char * * fmt ) { switch ( opt ) { case 'B' : case 'b' : return sizeof ( char ) ; case 'H' : case 'h' : return sizeof ( short ) ; case 'L' : case 'l' : return sizeof ( long ) ; case 'T' : return sizeof ( size_t ) ; case 'f' : return sizeof ( float ) ; case 'd' : return sizeof ( double ) ; case 'x' : return 1 ; case 'c' : return getnum ( L , fmt , 1 ) ; case 'i' : case 'I' : { int sz = getnum ( L , fmt , sizeof ( int ) ) ; if ( sz > MAXINTSIZE ) luaL_error ( L , ""integralsize%dislargerthanlimitof%d"" , sz , MAXINTSIZE ) ; return sz ; } default : return 0 ; } } "," return getnum ( fmt , 1 = getnum ( fmt , sizeof ",antirez@redis/1eb08bcd4634ae42ec45e8284923ac048beaa4c3,CVE-2018-11219,https://github.com/antirez/redis/commit/1eb08bcd4634ae42ec45e8284923ac048beaa4c3,2018-06-17T17:29Z 1167,CWE-787,"CWE-787 static int gtStripSeparate ( TIFFRGBAImage * img , uint32 * raster , uint32 w , uint32 h ) { TIFF * tif = img -> tif ; tileSeparateRoutine put = img -> put . separate ; unsigned char * buf = NULL ; unsigned char * p0 = NULL , * p1 = NULL , * p2 = NULL , * pa = NULL ; uint32 row , y , nrow , rowstoread ; tmsize_t pos ; tmsize_t scanline ; uint32 rowsperstrip , offset_row ; uint32 imagewidth = img -> width ; tmsize_t stripsize ; tmsize_t bufsize ; int32 fromskew , toskew ; int alpha = img -> alpha ; int ret = 1 , flip ; uint16 colorchannels ; stripsize = TIFFStripSize ( tif ) ; bufsize = _TIFFMultiplySSize ( tif , alpha ? 4 : 3 , stripsize , ""gtStripSeparate"" ) ; if ( bufsize == 0 ) { return ( 0 ) ; } flip = setorientation ( img ) ; if ( flip & FLIP_VERTICALLY ) { y = h - 1 ; toskew = - ( int32 ) ( w + w ) ; } else { y = 0 ; toskew = - ( int32 ) ( w - w ) ; } switch ( img -> photometric ) { case PHOTOMETRIC_MINISWHITE : case PHOTOMETRIC_MINISBLACK : case PHOTOMETRIC_PALETTE : colorchannels = 1 ; break ; default : colorchannels = 3 ; break ; } TIFFGetFieldDefaulted ( tif , TIFFTAG_ROWSPERSTRIP , & rowsperstrip ) ; scanline = TIFFScanlineSize ( tif ) ; fromskew = ( w < imagewidth ? imagewidth - w : 0 ) ; for ( row = 0 ; row < h ; row += nrow ) { rowstoread = rowsperstrip - ( row + img -> row_offset ) % rowsperstrip ; nrow = ( row + rowstoread > h ? h - row : rowstoread ) ; offset_row = row + img -> row_offset ; if ( buf == NULL ) { if ( _TIFFReadEncodedStripAndAllocBuffer ( tif , TIFFComputeStrip ( tif , offset_row , 0 ) , ( void * * ) & buf , bufsize , ( ( row + img -> row_offset ) % rowsperstrip + nrow ) * scanline ) == ( tmsize_t ) ( - 1 ) && ( buf == NULL || img -> stoponerr ) ) { ret = 0 ; break ; } p0 = buf ; if ( colorchannels == 1 ) { p2 = p1 = p0 ; pa = ( alpha ? ( p0 + 3 * stripsize ) : NULL ) ; } else { p1 = p0 + stripsize ; p2 = p1 + stripsize ; pa = ( alpha ? ( p2 + stripsize ) : NULL ) ; } } else if ( TIFFReadEncodedStrip ( tif , TIFFComputeStrip ( tif , offset_row , 0 ) , p0 , ( ( row + img -> row_offset ) % rowsperstrip + nrow ) * scanline ) == ( tmsize_t ) ( - 1 ) && img -> stoponerr ) { ret = 0 ; break ; } if ( colorchannels > 1 && TIFFReadEncodedStrip ( tif , TIFFComputeStrip ( tif , offset_row , 1 ) , p1 , ( ( row + img -> row_offset ) % rowsperstrip + nrow ) * scanline ) == ( tmsize_t ) ( - 1 ) && img -> stoponerr ) { ret = 0 ; break ; } if ( colorchannels > 1 && TIFFReadEncodedStrip ( tif , TIFFComputeStrip ( tif , offset_row , 2 ) , p2 , ( ( row + img -> row_offset ) % rowsperstrip + nrow ) * scanline ) == ( tmsize_t ) ( - 1 ) && img -> stoponerr ) { ret = 0 ; break ; } if ( alpha ) { if ( TIFFReadEncodedStrip ( tif , TIFFComputeStrip ( tif , offset_row , colorchannels ) , pa , ( ( row + img -> row_offset ) % rowsperstrip + nrow ) * scanline ) == ( tmsize_t ) ( - 1 ) && img -> stoponerr ) { ret = 0 ; break ; } } pos = ( ( row + img -> row_offset ) % rowsperstrip ) * scanline + ( ( tmsize_t ) img -> col_offset * img -> samplesperpixel ) ; ( * put ) ( img , raster + y * w , 0 , y , w , nrow , fromskew , toskew , p0 + pos , p1 + pos , p2 + pos , ( alpha ? ( pa + pos ) : NULL ) ) ; y += ( ( flip & FLIP_VERTICALLY ) ? - ( int32 ) nrow : ( int32 ) nrow ) ; } if ( flip & FLIP_HORIZONTALLY ) { uint32 line ; for ( line = 0 ; line < h ; line ++ ) { uint32 * left = raster + ( line * w ) ; uint32 * right = left + w - 1 ; while ( left < right ) { uint32 temp = * left ; * left = * right ; * right = temp ; left ++ ; right -- ; } } } _TIFFfree ( buf ) ; return ( ret ) ; } "," nrow ) { uint32 temp ; -> row_offset ; temp = ( row + img -> row_offset ) % rowsperstrip + nrow ; if ( scanline > 0 && temp > ( size_t ) ( TIFF_TMSIZE_T_MAX / scanline ) ) { TIFFErrorExt ( tif -> tif_clientdata , TIFFFileName ( tif ) , ""IntegeroverflowingtStripSeparate"" ) ; return 0 ; } , bufsize , temp * scanline ) , p0 , temp * scanline ) , p1 , temp * scanline ) , p2 , temp * scanline ) , pa , temp * scanline ) ",OSGeo@gdal/21674033ee246f698887604c7af7ba1962a40ddf,CVE-2019-17546,https://github.com/OSGeo/gdal/commit/21674033ee246f698887604c7af7ba1962a40ddf,2019-10-14T02:15Z 1168,CWE-125,"CWE-125 static int num_stmts ( const node * n ) { int i , l ; node * ch ; switch ( TYPE ( n ) ) { case single_input : if ( TYPE ( CHILD ( n , 0 ) ) == NEWLINE ) return 0 ; else return num_stmts ( CHILD ( n , 0 ) ) ; case file_input : l = 0 ; for ( i = 0 ; i < NCH ( n ) ; i ++ ) { ch = CHILD ( n , i ) ; if ( TYPE ( ch ) == stmt ) l += num_stmts ( ch ) ; } return l ; case stmt : return num_stmts ( CHILD ( n , 0 ) ) ; case compound_stmt : return 1 ; case simple_stmt : return NCH ( n ) / 2 ; case suite : if ( NCH ( n ) == 1 ) return num_stmts ( CHILD ( n , 0 ) ) ; else { i = 2 ; l = 0 ; if ( TYPE ( CHILD ( n , 1 ) ) == TYPE_COMMENT ) i += 2 ; for ( ; i < ( NCH ( n ) - 1 ) ; i ++ ) l += num_stmts ( CHILD ( n , i ) ) ; return l ; } default : { char buf [ 128 ] ; sprintf ( buf , ""Non-statementfound:%d%d"" , TYPE ( n ) , NCH ( n ) ) ; Py_FatalError ( buf ) ; } } assert ( 0 ) ; return 0 ; } "," ; } } abort ( ) ; } ",python@typed_ast/156afcb26c198e162504a57caddfe0acd9ed7dce,CVE-2019-19275,https://github.com/python/typed_ast/commit/156afcb26c198e162504a57caddfe0acd9ed7dce,2019-11-26T15:15Z 1169,CWE-119,"CWE-119 static inline void header_put_be_short ( SF_PRIVATE * psf , int x ) { if ( psf -> headindex < SIGNED_SIZEOF ( psf -> header ) - 2 ) { psf -> header [ psf -> headindex ++ ] = ( x >> 8 ) ; psf -> header [ psf -> headindex ++ ] = x ; } ; } "," x ) { psf -> header psf -> header . ptr [ psf -> header psf -> header . indx ++ ] = psf -> header . ptr [ psf -> header . indx ++ ] = x ; } ",erikd@libsndfile/708e996c87c5fae77b104ccfeb8f6db784c32074,CVE-2017-7586,https://github.com/erikd/libsndfile/commit/708e996c87c5fae77b104ccfeb8f6db784c32074,2017-04-07T20:59Z 1170,CWE-20,"CWE-20 long kernel_wait4 ( pid_t upid , int __user * stat_addr , int options , struct rusage * ru ) { struct wait_opts wo ; struct pid * pid = NULL ; enum pid_type type ; long ret ; if ( options & ~ ( WNOHANG | WUNTRACED | WCONTINUED | __WNOTHREAD | __WCLONE | __WALL ) ) return - EINVAL ; if ( upid == - 1 ) type = PIDTYPE_MAX ; else if ( upid < 0 ) { type = PIDTYPE_PGID ; pid = find_get_pid ( - upid ) ; } else if ( upid == 0 ) { type = PIDTYPE_PGID ; pid = get_task_pid ( current , PIDTYPE_PGID ) ; } else { type = PIDTYPE_PID ; pid = find_get_pid ( upid ) ; } wo . wo_type = type ; wo . wo_pid = pid ; wo . wo_flags = options | WEXITED ; wo . wo_info = NULL ; wo . wo_stat = 0 ; wo . wo_rusage = ru ; ret = do_wait ( & wo ) ; put_pid ( pid ) ; if ( ret > 0 && stat_addr && put_user ( wo . wo_stat , stat_addr ) ) ret = - EFAULT ; return ret ; } "," ( upid == INT_MIN ) return - ESRCH ; if ( upid == ",torvalds@linux/dd83c161fbcc5d8be637ab159c0de015cbff5ba4,CVE-2018-10087,https://github.com/torvalds/linux/commit/dd83c161fbcc5d8be637ab159c0de015cbff5ba4,2018-04-13T13:29Z 1171,CWE-287,"CWE-287 static int unix_stream_sendmsg ( struct kiocb * kiocb , struct socket * sock , struct msghdr * msg , size_t len ) { struct sock_iocb * siocb = kiocb_to_siocb ( kiocb ) ; struct sock * sk = sock -> sk ; struct sock * other = NULL ; int err , size ; struct sk_buff * skb ; int sent = 0 ; struct scm_cookie tmp_scm ; bool fds_sent = false ; int max_level ; if ( NULL == siocb -> scm ) siocb -> scm = & tmp_scm ; wait_for_unix_gc ( ) ; err = scm_send ( sock , msg , siocb -> scm ) ; if ( err < 0 ) return err ; err = - EOPNOTSUPP ; if ( msg -> msg_flags & MSG_OOB ) goto out_err ; if ( msg -> msg_namelen ) { err = sk -> sk_state == TCP_ESTABLISHED ? - EISCONN : - EOPNOTSUPP ; goto out_err ; } else { err = - ENOTCONN ; other = unix_peer ( sk ) ; if ( ! other ) goto out_err ; } if ( sk -> sk_shutdown & SEND_SHUTDOWN ) goto pipe_err ; while ( sent < len ) { size = len - sent ; if ( size > ( ( sk -> sk_sndbuf >> 1 ) - 64 ) ) size = ( sk -> sk_sndbuf >> 1 ) - 64 ; if ( size > SKB_MAX_ALLOC ) size = SKB_MAX_ALLOC ; skb = sock_alloc_send_skb ( sk , size , msg -> msg_flags & MSG_DONTWAIT , & err ) ; if ( skb == NULL ) goto out_err ; size = min_t ( int , size , skb_tailroom ( skb ) ) ; err = unix_scm_to_skb ( siocb -> scm , skb , ! fds_sent ) ; if ( err < 0 ) { kfree_skb ( skb ) ; goto out_err ; } max_level = err + 1 ; fds_sent = true ; err = memcpy_fromiovec ( skb_put ( skb , size ) , msg -> msg_iov , size ) ; if ( err ) { kfree_skb ( skb ) ; goto out_err ; } unix_state_lock ( other ) ; if ( sock_flag ( other , SOCK_DEAD ) || ( other -> sk_shutdown & RCV_SHUTDOWN ) ) goto pipe_err_free ; maybe_add_creds ( skb , sock , other ) ; skb_queue_tail ( & other -> sk_receive_queue , skb ) ; if ( max_level > unix_sk ( other ) -> recursion_level ) unix_sk ( other ) -> recursion_level = max_level ; unix_state_unlock ( other ) ; other -> sk_data_ready ( other , size ) ; sent += size ; } scm_destroy ( siocb -> scm ) ; siocb -> scm = NULL ; return sent ; pipe_err_free : unix_state_unlock ( other ) ; kfree_skb ( skb ) ; pipe_err : if ( sent == 0 && ! ( msg -> msg_flags & MSG_NOSIGNAL ) ) send_sig ( SIGPIPE , current , 0 ) ; err = - EPIPE ; out_err : scm_destroy ( siocb -> scm ) ; siocb -> scm = NULL ; return sent ? : err ; } "," siocb -> scm , false ",torvalds@linux/e0e3cea46d31d23dc40df0a49a7a2c04fe8edfea,CVE-2012-3520,https://github.com/torvalds/linux/commit/e0e3cea46d31d23dc40df0a49a7a2c04fe8edfea,2012-10-03T11:02Z 1172,CWE-190,"CWE-190 int SWFInput_readSBits ( SWFInput input , int number ) { int num = SWFInput_readBits ( input , number ) ; if ( num & ( 1 << ( number - 1 ) ) ) return num - ( 1 << number ) ; else return num ; } "," ; if ( number && ",libming@libming/a009a38dce1d9316cad1ab522b813b1d5ba4c62a,CVE-2019-12980,https://github.com/libming/libming/commit/a009a38dce1d9316cad1ab522b813b1d5ba4c62a,2019-06-26T18:15Z 1173,CWE-119,"CWE-119 int vpx_img_read ( vpx_image_t * img , FILE * file ) { int plane ; for ( plane = 0 ; plane < 3 ; ++ plane ) { unsigned char * buf = img -> planes [ plane ] ; const int stride = img -> stride [ plane ] ; const int w = vpx_img_plane_width ( img , plane ) ; const int h = vpx_img_plane_height ( img , plane ) ; int y ; for ( y = 0 ; y < h ; ++ y ) { if ( fread ( buf , 1 , w , file ) != w ) return 0 ; buf += stride ; } } return 1 ; } "," , plane ) * ( ( img -> fmt & VPX_IMG_FMT_HIGHBITDEPTH ) ? 2 : 1 ) file ) != ( size_t ) ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1174,CWE-119,"CWE-119 static int decode_avp ( struct l2tp_avp_t * avp , const struct l2tp_attr_t * RV , const char * secret , size_t secret_len ) { MD5_CTX md5_ctx ; uint8_t md5 [ MD5_DIGEST_LENGTH ] ; uint8_t p1 [ MD5_DIGEST_LENGTH ] ; uint8_t * prev_block = NULL ; uint16_t attr_len ; uint16_t orig_attr_len ; uint16_t bytes_left ; uint16_t blocks_left ; uint16_t last_block_len ; if ( avp -> length < sizeof ( struct l2tp_avp_t ) + 2 ) { log_warn ( ""l2tp:incorrecthiddenavpreceived(type%hu):"" ""lengthtoosmall(%hubytes)\\n"" , ntohs ( avp -> type ) , avp -> length ) ; return - 1 ; } attr_len = avp -> length - sizeof ( struct l2tp_avp_t ) ; MD5_Init ( & md5_ctx ) ; MD5_Update ( & md5_ctx , & avp -> type , sizeof ( avp -> type ) ) ; MD5_Update ( & md5_ctx , secret , secret_len ) ; MD5_Update ( & md5_ctx , RV -> val . octets , RV -> length ) ; MD5_Final ( p1 , & md5_ctx ) ; if ( attr_len <= MD5_DIGEST_LENGTH ) { memxor ( avp -> val , p1 , attr_len ) ; return 0 ; } memxor ( p1 , avp -> val , MD5_DIGEST_LENGTH ) ; orig_attr_len = ntohs ( * ( uint16_t * ) p1 ) ; if ( orig_attr_len <= MD5_DIGEST_LENGTH - 2 ) { memcpy ( avp -> val , p1 , MD5_DIGEST_LENGTH ) ; return 0 ; } if ( orig_attr_len > attr_len - 2 ) { log_warn ( ""l2tp:incorrecthiddenavpreceived(type%hu):"" ""originalattributelengthtoobig(ciphered"" ""attributelength:%hubytes,advertisedoriginal"" ""attributelength:%hubytes)\\n"" , ntohs ( avp -> type ) , attr_len , orig_attr_len ) ; return - 1 ; } bytes_left = orig_attr_len + 2 - MD5_DIGEST_LENGTH ; last_block_len = bytes_left % MD5_DIGEST_LENGTH ; blocks_left = bytes_left / MD5_DIGEST_LENGTH ; if ( last_block_len ) { prev_block = avp -> val + blocks_left * MD5_DIGEST_LENGTH ; MD5_Init ( & md5_ctx ) ; MD5_Update ( & md5_ctx , secret , secret_len ) ; MD5_Update ( & md5_ctx , prev_block , MD5_DIGEST_LENGTH ) ; MD5_Final ( md5 , & md5_ctx ) ; memxor ( prev_block + MD5_DIGEST_LENGTH , md5 , last_block_len ) ; prev_block -= MD5_DIGEST_LENGTH ; } else prev_block = avp -> val + ( blocks_left - 1 ) * MD5_DIGEST_LENGTH ; while ( prev_block >= avp -> val ) { MD5_Init ( & md5_ctx ) ; MD5_Update ( & md5_ctx , secret , secret_len ) ; MD5_Update ( & md5_ctx , prev_block , MD5_DIGEST_LENGTH ) ; MD5_Final ( md5 , & md5_ctx ) ; memxor ( prev_block + MD5_DIGEST_LENGTH , md5 , MD5_DIGEST_LENGTH ) ; prev_block -= MD5_DIGEST_LENGTH ; } memcpy ( avp -> val , p1 , MD5_DIGEST_LENGTH ) ; return 0 ; } "," NULL ; uint16_t avp_len ; uint16_t uint16_t last_block_len ; avp_len = avp -> flags & L2TP_AVP_LEN_MASK ; if ( avp_len < sizeof ( type ) , avp_len ) ; return } attr_len = avp_len - sizeof ( ",accel-ppp@accel-ppp/2324bcd5ba12cf28f47357a8f03cd41b7c04c52b,CVE-2020-15173,https://github.com/accel-ppp/accel-ppp/commit/2324bcd5ba12cf28f47357a8f03cd41b7c04c52b,2020-09-09T23:15Z 1175,CWE-264,"CWE-264 static int linear_ioctl ( struct dm_target * ti , unsigned int cmd , unsigned long arg ) { struct linear_c * lc = ( struct linear_c * ) ti -> private ; return __blkdev_driver_ioctl ( lc -> dev -> bdev , lc -> dev -> mode , cmd , arg ) ; } "," -> private ; struct dm_dev * dev = lc -> dev ; int r = 0 ; if ( lc -> ( lc -> start || ti -> len != i_size_read ( dev -> bdev -> bd_inode ) >> SECTOR_SHIFT ) r = scsi_verify_blk_ioctl ( NULL , cmd ) ; return r ? : __blkdev_driver_ioctl ( -> bdev , dev -> mode ",torvalds@linux/ec8013beddd717d1740cfefb1a9b900deef85462,CVE-2011-4127,https://github.com/torvalds/linux/commit/ec8013beddd717d1740cfefb1a9b900deef85462,2012-07-03T16:40Z 1176,CWE-125,"CWE-125 static int chacha20_poly1305_ctrl ( EVP_CIPHER_CTX * ctx , int type , int arg , void * ptr ) { EVP_CHACHA_AEAD_CTX * actx = aead_data ( ctx ) ; switch ( type ) { case EVP_CTRL_INIT : if ( actx == NULL ) actx = ctx -> cipher_data = OPENSSL_zalloc ( sizeof ( * actx ) + Poly1305_ctx_size ( ) ) ; if ( actx == NULL ) { EVPerr ( EVP_F_CHACHA20_POLY1305_CTRL , EVP_R_INITIALIZATION_ERROR ) ; return 0 ; } actx -> len . aad = 0 ; actx -> len . text = 0 ; actx -> aad = 0 ; actx -> mac_inited = 0 ; actx -> tag_len = 0 ; actx -> nonce_len = 12 ; actx -> tls_payload_length = NO_TLS_PAYLOAD_LENGTH ; return 1 ; case EVP_CTRL_COPY : if ( actx ) { EVP_CIPHER_CTX * dst = ( EVP_CIPHER_CTX * ) ptr ; dst -> cipher_data = OPENSSL_memdup ( actx , sizeof ( * actx ) + Poly1305_ctx_size ( ) ) ; if ( dst -> cipher_data == NULL ) { EVPerr ( EVP_F_CHACHA20_POLY1305_CTRL , EVP_R_COPY_ERROR ) ; return 0 ; } } return 1 ; case EVP_CTRL_AEAD_SET_IVLEN : if ( arg <= 0 || arg > CHACHA_CTR_SIZE ) return 0 ; actx -> nonce_len = arg ; return 1 ; case EVP_CTRL_AEAD_SET_IV_FIXED : if ( arg != 12 ) return 0 ; actx -> nonce [ 0 ] = actx -> key . counter [ 1 ] = CHACHA_U8TOU32 ( ( unsigned char * ) ptr ) ; actx -> nonce [ 1 ] = actx -> key . counter [ 2 ] = CHACHA_U8TOU32 ( ( unsigned char * ) ptr + 4 ) ; actx -> nonce [ 2 ] = actx -> key . counter [ 3 ] = CHACHA_U8TOU32 ( ( unsigned char * ) ptr + 8 ) ; return 1 ; case EVP_CTRL_AEAD_SET_TAG : if ( arg <= 0 || arg > POLY1305_BLOCK_SIZE ) return 0 ; if ( ptr != NULL ) { memcpy ( actx -> tag , ptr , arg ) ; actx -> tag_len = arg ; } return 1 ; case EVP_CTRL_AEAD_GET_TAG : if ( arg <= 0 || arg > POLY1305_BLOCK_SIZE || ! ctx -> encrypt ) return 0 ; memcpy ( ptr , actx -> tag , arg ) ; return 1 ; case EVP_CTRL_AEAD_TLS1_AAD : if ( arg != EVP_AEAD_TLS1_AAD_LEN ) return 0 ; { unsigned int len ; unsigned char * aad = ptr , temp [ POLY1305_BLOCK_SIZE ] ; len = aad [ EVP_AEAD_TLS1_AAD_LEN - 2 ] << 8 | aad [ EVP_AEAD_TLS1_AAD_LEN - 1 ] ; if ( ! ctx -> encrypt ) { len -= POLY1305_BLOCK_SIZE ; memcpy ( temp , aad , EVP_AEAD_TLS1_AAD_LEN - 2 ) ; aad = temp ; temp [ EVP_AEAD_TLS1_AAD_LEN - 2 ] = ( unsigned char ) ( len >> 8 ) ; temp [ EVP_AEAD_TLS1_AAD_LEN - 1 ] = ( unsigned char ) len ; } actx -> tls_payload_length = len ; actx -> key . counter [ 1 ] = actx -> nonce [ 0 ] ; actx -> key . counter [ 2 ] = actx -> nonce [ 1 ] ^ CHACHA_U8TOU32 ( aad ) ; actx -> key . counter [ 3 ] = actx -> nonce [ 2 ] ^ CHACHA_U8TOU32 ( aad + 4 ) ; actx -> mac_inited = 0 ; chacha20_poly1305_cipher ( ctx , NULL , aad , EVP_AEAD_TLS1_AAD_LEN ) ; return POLY1305_BLOCK_SIZE ; } case EVP_CTRL_AEAD_SET_MAC_KEY : return 1 ; default : return - 1 ; } } "," encrypt ) { if ( len < POLY1305_BLOCK_SIZE ) return 0 ; ",openssl@openssl/00d965474b22b54e4275232bc71ee0c699c5cd21,CVE-2017-3731,https://github.com/openssl/openssl/commit/00d965474b22b54e4275232bc71ee0c699c5cd21,2017-05-04T19:29Z 1177,CWE-264,"CWE-264 struct crypto_alg * crypto_larval_lookup ( const char * name , u32 type , u32 mask ) { struct crypto_alg * alg ; if ( ! name ) return ERR_PTR ( - ENOENT ) ; mask &= ~ ( CRYPTO_ALG_LARVAL | CRYPTO_ALG_DEAD ) ; type &= mask ; alg = crypto_alg_lookup ( name , type , mask ) ; if ( ! alg ) { request_module ( ""%s"" , name ) ; if ( ! ( ( type ^ CRYPTO_ALG_NEED_FALLBACK ) & mask & CRYPTO_ALG_NEED_FALLBACK ) ) request_module ( ""%s-all"" , name ) ; alg = crypto_alg_lookup ( name , type , mask ) ; } if ( alg ) return crypto_is_larval ( alg ) ? crypto_larval_wait ( alg ) : alg ; return crypto_larval_add ( name , type , mask ) ; } "," { request_module ( ""crypto-%s"" , name ) ) request_module ( ""crypto-%s-all"" , name ) ",torvalds@linux/5d26a105b5a73e5635eae0629b42fa0a90e07b7b,CVE-2013-7421,https://github.com/torvalds/linux/commit/5d26a105b5a73e5635eae0629b42fa0a90e07b7b,2015-03-02T11:59Z 1178,CWE-400,"CWE-400 static void perf_event_comm_output ( struct perf_event * event , struct perf_comm_event * comm_event ) { struct perf_output_handle handle ; struct perf_sample_data sample ; int size = comm_event -> event_id . header . size ; int ret ; perf_event_header__init_id ( & comm_event -> event_id . header , & sample , event ) ; ret = perf_output_begin ( & handle , event , comm_event -> event_id . header . size , 0 , 0 ) ; if ( ret ) goto out ; comm_event -> event_id . pid = perf_event_pid ( event , comm_event -> task ) ; comm_event -> event_id . tid = perf_event_tid ( event , comm_event -> task ) ; perf_output_put ( & handle , comm_event -> event_id ) ; __output_copy ( & handle , comm_event -> comm , comm_event -> comm_size ) ; perf_event__output_id_sample ( event , & handle , & sample ) ; perf_output_end ( & handle ) ; out : comm_event -> event_id . header . size = size ; } "," header . size , 0 ) ",torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,CVE-2011-2918,https://github.com/torvalds/linux/commit/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,2012-05-24T23:55Z 1179,CWE-284,"CWE-284 void fslib_copy_libs ( const char * full_path ) { assert ( full_path ) ; if ( arg_debug || arg_debug_private_lib ) printf ( ""fslib_copy_libs%s\\n"" , full_path ) ; if ( access ( full_path , R_OK ) ) { if ( arg_debug || arg_debug_private_lib ) printf ( ""cannotfind%sforprivate-lib,skipping...\\n"" , full_path ) ; return ; } unlink ( RUN_LIB_FILE ) ; create_empty_file_as_root ( RUN_LIB_FILE , 0644 ) ; if ( chown ( RUN_LIB_FILE , getuid ( ) , getgid ( ) ) ) errExit ( ""chown"" ) ; if ( arg_debug || arg_debug_private_lib ) printf ( ""runningfldd%s\\n"" , full_path ) ; sbox_run ( SBOX_USER | SBOX_SECCOMP | SBOX_CAPS_NONE , 3 , PATH_FLDD , full_path , RUN_LIB_FILE ) ; FILE * fp = fopen ( RUN_LIB_FILE , ""r"" ) ; if ( ! fp ) errExit ( ""fopen"" ) ; char buf [ MAXBUF ] ; while ( fgets ( buf , MAXBUF , fp ) ) { char * ptr = strchr ( buf , '\\n' ) ; if ( ptr ) * ptr = '\\0' ; fslib_duplicate ( buf ) ; } fclose ( fp ) ; } "," fp ) ; unlink ( RUN_LIB_FILE ) ; ",netblue30@firejail/eecf35c2f8249489a1d3e512bb07f0d427183134,CVE-2019-12589,https://github.com/netblue30/firejail/commit/eecf35c2f8249489a1d3e512bb07f0d427183134,2019-06-03T03:29Z 1180,CWE-20,"CWE-20 void user_describe ( const struct key * key , struct seq_file * m ) { seq_puts ( m , key -> description ) ; if ( key_is_instantiated ( key ) ) seq_printf ( m , "":%u"" , key -> datalen ) ; } "," ; if ( key_is_positive ( key ) ",torvalds@linux/363b02dab09b3226f3bd1420dad9c72b79a42a76,CVE-2017-15951,https://github.com/torvalds/linux/commit/363b02dab09b3226f3bd1420dad9c72b79a42a76,2017-10-28T02:29Z 1181,CWE-200,"CWE-200 static int rfcomm_sock_getname ( struct socket * sock , struct sockaddr * addr , int * len , int peer ) { struct sockaddr_rc * sa = ( struct sockaddr_rc * ) addr ; struct sock * sk = sock -> sk ; BT_DBG ( ""sock%p,sk%p"" , sock , sk ) ; sa -> rc_family = AF_BLUETOOTH ; sa -> rc_channel = rfcomm_pi ( sk ) -> channel ; if ( peer ) bacpy ( & sa -> rc_bdaddr , & bt_sk ( sk ) -> dst ) ; else bacpy ( & sa -> rc_bdaddr , & bt_sk ( sk ) -> src ) ; * len = sizeof ( struct sockaddr_rc ) ; return 0 ; } "," sock , sk ) ; memset ( sa , 0 , sizeof ( * sa ) ",torvalds@linux/9344a972961d1a6d2c04d9008b13617bcb6ec2ef,CVE-2012-6545,https://github.com/torvalds/linux/commit/9344a972961d1a6d2c04d9008b13617bcb6ec2ef,2013-03-15T20:55Z 1182,CWE-119,"CWE-119 static int handle_packet ( unsigned char * data , int data_len ) { struct mt_mactelnet_hdr pkthdr ; if ( data_len < MT_HEADER_LEN ) { return - 1 ; } parse_packet ( data , & pkthdr ) ; if ( pkthdr . seskey != sessionkey ) { return - 1 ; } if ( pkthdr . ptype == MT_PTYPE_DATA ) { struct mt_packet odata ; struct mt_mactelnet_control_hdr cpkt ; int success = 0 ; init_packet ( & odata , MT_PTYPE_ACK , srcmac , dstmac , sessionkey , pkthdr . counter + ( data_len - MT_HEADER_LEN ) ) ; send_udp ( & odata , 0 ) ; if ( pkthdr . counter > incounter || ( incounter - pkthdr . counter ) > 65535 ) { incounter = pkthdr . counter ; } else { return - 1 ; } success = parse_control_packet ( data + MT_HEADER_LEN , data_len - MT_HEADER_LEN , & cpkt ) ; while ( success ) { if ( cpkt . cptype == MT_CPTYPE_PASSSALT ) { memcpy ( pass_salt , cpkt . data , cpkt . length ) ; send_auth ( username , password ) ; } else if ( cpkt . cptype == MT_CPTYPE_PLAINDATA ) { fwrite ( ( const void * ) cpkt . data , 1 , cpkt . length , stdout ) ; } else if ( cpkt . cptype == MT_CPTYPE_END_AUTH ) { terminal_mode = 1 ; if ( is_a_tty ) { raw_term ( ) ; setvbuf ( stdin , ( char * ) NULL , _IONBF , 0 ) ; signal ( SIGWINCH , sig_winch ) ; } } success = parse_control_packet ( NULL , 0 , & cpkt ) ; } } else if ( pkthdr . ptype == MT_PTYPE_ACK ) { } else if ( pkthdr . ptype == MT_PTYPE_END ) { struct mt_packet odata ; init_packet ( & odata , MT_PTYPE_END , srcmac , dstmac , pkthdr . seskey , 0 ) ; send_udp ( & odata , 0 ) ; if ( ! quiet_mode ) { fprintf ( stderr , _ ( ""Connectionclosed.\\n"" ) ) ; } running = 0 ; } else { fprintf ( stderr , _ ( ""Unhandeledpackettype:%dreceivedfromserver%s\\n"" ) , pkthdr . ptype , ether_ntoa ( ( struct ether_addr * ) dstmac ) ) ; return - 1 ; } return pkthdr . ptype ; } "," MT_CPTYPE_PASSSALT ) { if ( cpkt . length != 16 ) { fprintf ( stderr , _ ( ""Invalidsaltlength:%d(insteadof16)receivedfromserver%s\\n"" ) , cpkt . length , ether_ntoa ( ( struct ether_addr * ) dstmac ) ) ; } . data , 16 ) ; send_auth ",haakonnessjoen@MAC-Telnet/b69d11727d4f0f8cf719c79e3fb700f55ca03e9a,CVE-2016-7115,https://github.com/haakonnessjoen/MAC-Telnet/commit/b69d11727d4f0f8cf719c79e3fb700f55ca03e9a,2016-08-30T17:59Z 1183,CWE-476,"CWE-476 int build_ntlmssp_auth_blob ( unsigned char * * pbuffer , u16 * buflen , struct cifs_ses * ses , const struct nls_table * nls_cp ) { int rc ; AUTHENTICATE_MESSAGE * sec_blob ; __u32 flags ; unsigned char * tmp ; rc = setup_ntlmv2_rsp ( ses , nls_cp ) ; if ( rc ) { cifs_dbg ( VFS , ""Error%dduringNTLMSSPauthentication\\n"" , rc ) ; * buflen = 0 ; goto setup_ntlmv2_ret ; } * pbuffer = kmalloc ( size_of_ntlmssp_blob ( ses ) , GFP_KERNEL ) ; sec_blob = ( AUTHENTICATE_MESSAGE * ) * pbuffer ; memcpy ( sec_blob -> Signature , NTLMSSP_SIGNATURE , 8 ) ; sec_blob -> MessageType = NtLmAuthenticate ; flags = NTLMSSP_NEGOTIATE_56 | NTLMSSP_REQUEST_TARGET | NTLMSSP_NEGOTIATE_TARGET_INFO | NTLMSSP_NEGOTIATE_128 | NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_EXTENDED_SEC ; if ( ses -> server -> sign ) { flags |= NTLMSSP_NEGOTIATE_SIGN ; if ( ! ses -> server -> session_estab || ses -> ntlmssp -> sesskey_per_smbsess ) flags |= NTLMSSP_NEGOTIATE_KEY_XCH ; } tmp = * pbuffer + sizeof ( AUTHENTICATE_MESSAGE ) ; sec_blob -> NegotiateFlags = cpu_to_le32 ( flags ) ; sec_blob -> LmChallengeResponse . BufferOffset = cpu_to_le32 ( sizeof ( AUTHENTICATE_MESSAGE ) ) ; sec_blob -> LmChallengeResponse . Length = 0 ; sec_blob -> LmChallengeResponse . MaximumLength = 0 ; sec_blob -> NtChallengeResponse . BufferOffset = cpu_to_le32 ( tmp - * pbuffer ) ; if ( ses -> user_name != NULL ) { memcpy ( tmp , ses -> auth_key . response + CIFS_SESS_KEY_SIZE , ses -> auth_key . len - CIFS_SESS_KEY_SIZE ) ; tmp += ses -> auth_key . len - CIFS_SESS_KEY_SIZE ; sec_blob -> NtChallengeResponse . Length = cpu_to_le16 ( ses -> auth_key . len - CIFS_SESS_KEY_SIZE ) ; sec_blob -> NtChallengeResponse . MaximumLength = cpu_to_le16 ( ses -> auth_key . len - CIFS_SESS_KEY_SIZE ) ; } else { sec_blob -> NtChallengeResponse . Length = 0 ; sec_blob -> NtChallengeResponse . MaximumLength = 0 ; } if ( ses -> domainName == NULL ) { sec_blob -> DomainName . BufferOffset = cpu_to_le32 ( tmp - * pbuffer ) ; sec_blob -> DomainName . Length = 0 ; sec_blob -> DomainName . MaximumLength = 0 ; tmp += 2 ; } else { int len ; len = cifs_strtoUTF16 ( ( __le16 * ) tmp , ses -> domainName , CIFS_MAX_DOMAINNAME_LEN , nls_cp ) ; len *= 2 ; sec_blob -> DomainName . BufferOffset = cpu_to_le32 ( tmp - * pbuffer ) ; sec_blob -> DomainName . Length = cpu_to_le16 ( len ) ; sec_blob -> DomainName . MaximumLength = cpu_to_le16 ( len ) ; tmp += len ; } if ( ses -> user_name == NULL ) { sec_blob -> UserName . BufferOffset = cpu_to_le32 ( tmp - * pbuffer ) ; sec_blob -> UserName . Length = 0 ; sec_blob -> UserName . MaximumLength = 0 ; tmp += 2 ; } else { int len ; len = cifs_strtoUTF16 ( ( __le16 * ) tmp , ses -> user_name , CIFS_MAX_USERNAME_LEN , nls_cp ) ; len *= 2 ; sec_blob -> UserName . BufferOffset = cpu_to_le32 ( tmp - * pbuffer ) ; sec_blob -> UserName . Length = cpu_to_le16 ( len ) ; sec_blob -> UserName . MaximumLength = cpu_to_le16 ( len ) ; tmp += len ; } sec_blob -> WorkstationName . BufferOffset = cpu_to_le32 ( tmp - * pbuffer ) ; sec_blob -> WorkstationName . Length = 0 ; sec_blob -> WorkstationName . MaximumLength = 0 ; tmp += 2 ; if ( ( ( ses -> ntlmssp -> server_flags & NTLMSSP_NEGOTIATE_KEY_XCH ) || ( ses -> ntlmssp -> server_flags & NTLMSSP_NEGOTIATE_EXTENDED_SEC ) ) && ! calc_seckey ( ses ) ) { memcpy ( tmp , ses -> ntlmssp -> ciphertext , CIFS_CPHTXT_SIZE ) ; sec_blob -> SessionKey . BufferOffset = cpu_to_le32 ( tmp - * pbuffer ) ; sec_blob -> SessionKey . Length = cpu_to_le16 ( CIFS_CPHTXT_SIZE ) ; sec_blob -> SessionKey . MaximumLength = cpu_to_le16 ( CIFS_CPHTXT_SIZE ) ; tmp += CIFS_CPHTXT_SIZE ; } else { sec_blob -> SessionKey . BufferOffset = cpu_to_le32 ( tmp - * pbuffer ) ; sec_blob -> SessionKey . Length = 0 ; sec_blob -> SessionKey . MaximumLength = 0 ; } * buflen = tmp - * pbuffer ; setup_ntlmv2_ret : return rc ; } "," NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_EXTENDED_SEC | NTLMSSP_NEGOTIATE_SEAL -> sign ) flags |= NTLMSSP_NEGOTIATE_SIGN |= NTLMSSP_NEGOTIATE_KEY_XCH ; tmp = * ",torvalds@linux/cabfb3680f78981d26c078a26e5c748531257ebb,CVE-2018-1066,https://github.com/torvalds/linux/commit/cabfb3680f78981d26c078a26e5c748531257ebb,2018-03-02T08:29Z 1184,CWE-522,"CWE-522 int imap_open_connection ( struct ImapAccountData * adata ) { if ( mutt_socket_open ( adata -> conn ) < 0 ) return - 1 ; adata -> state = IMAP_CONNECTED ; if ( imap_cmd_step ( adata ) != IMAP_RES_OK ) { imap_close_connection ( adata ) ; return - 1 ; } if ( mutt_istr_startswith ( adata -> buf , ""*OK"" ) ) { if ( ! mutt_istr_startswith ( adata -> buf , ""*OK[CAPABILITY"" ) && check_capabilities ( adata ) ) { goto bail ; } # ifdef USE_SSL if ( ( adata -> conn -> ssf == 0 ) && ( C_SslForceTls || ( adata -> capabilities & IMAP_CAP_STARTTLS ) ) ) { enum QuadOption ans ; if ( C_SslForceTls ) ans = MUTT_YES ; else if ( ( ans = query_quadoption ( C_SslStarttls , _ ( ""SecureconnectionwithTLS?"" ) ) ) == MUTT_ABORT ) { goto err_close_conn ; } if ( ans == MUTT_YES ) { enum ImapExecResult rc = imap_exec ( adata , ""STARTTLS"" , IMAP_CMD_SINGLE ) ; mutt_socket_empty ( adata -> conn ) ; if ( rc == IMAP_EXEC_FATAL ) goto bail ; if ( rc != IMAP_EXEC_ERROR ) { if ( mutt_ssl_starttls ( adata -> conn ) ) { mutt_error ( _ ( ""CouldnotnegotiateTLSconnection"" ) ) ; goto err_close_conn ; } else { if ( imap_exec ( adata , ""CAPABILITY"" , IMAP_CMD_NO_FLAGS ) ) goto bail ; } } } } if ( C_SslForceTls && ( adata -> conn -> ssf == 0 ) ) { mutt_error ( _ ( ""Encryptedconnectionunavailable"" ) ) ; goto err_close_conn ; } # endif } else if ( mutt_istr_startswith ( adata -> buf , ""*PREAUTH"" ) ) { # ifdef USE_SSL if ( ( adata -> conn -> ssf == 0 ) && C_SslForceTls ) { mutt_error ( _ ( ""Encryptedconnectionunavailable"" ) ) ; goto err_close_conn ; } # endif adata -> state = IMAP_AUTHENTICATED ; if ( check_capabilities ( adata ) != 0 ) goto bail ; FREE ( & adata -> capstr ) ; } else { imap_error ( ""imap_open_connection()"" , adata -> buf ) ; goto bail ; } return 0 ; # ifdef USE_SSL err_close_conn : imap_close_connection ( adata ) ; # endif bail : FREE ( & adata -> capstr ) ; return - 1 ; } "," ) { goto bail ; } if ) ; goto bail ; } else ) ; goto bail ; } # ) ; goto bail ; } # return 0 ; bail : imap_close_connection ( adata ) ; FREE ( & ",neomutt@neomutt/9c36717a3e2af1f2c1b7242035455ec8112b4b06,CVE-2020-28896,https://github.com/neomutt/neomutt/commit/9c36717a3e2af1f2c1b7242035455ec8112b4b06,2020-11-23T19:15Z 1185,CWE-200,"CWE-200 static int crypto_report_kpp ( struct sk_buff * skb , struct crypto_alg * alg ) { struct crypto_report_kpp rkpp ; strlcpy ( rkpp . type , ""kpp"" , sizeof ( rkpp . type ) ) ; if ( nla_put ( skb , CRYPTOCFGA_REPORT_KPP , sizeof ( struct crypto_report_kpp ) , & rkpp ) ) goto nla_put_failure ; return 0 ; nla_put_failure : return - EMSGSIZE ; } "," crypto_report_kpp rkpp ; strncpy ( rkpp . ",torvalds@linux/f43f39958beb206b53292801e216d9b8a660f087,CVE-2018-19854,https://github.com/torvalds/linux/commit/f43f39958beb206b53292801e216d9b8a660f087,2018-12-04T16:29Z 1186,CWE-119,"CWE-119 static void horDiff8 ( TIFF * tif , uint8 * cp0 , tmsize_t cc ) { TIFFPredictorState * sp = PredictorState ( tif ) ; tmsize_t stride = sp -> stride ; unsigned char * cp = ( unsigned char * ) cp0 ; assert ( ( cc % stride ) == 0 ) ; if ( cc > stride ) { cc -= stride ; if ( stride == 3 ) { unsigned int r1 , g1 , b1 ; unsigned int r2 = cp [ 0 ] ; unsigned int g2 = cp [ 1 ] ; unsigned int b2 = cp [ 2 ] ; do { r1 = cp [ 3 ] ; cp [ 3 ] = ( unsigned char ) ( ( r1 - r2 ) & 0xff ) ; r2 = r1 ; g1 = cp [ 4 ] ; cp [ 4 ] = ( unsigned char ) ( ( g1 - g2 ) & 0xff ) ; g2 = g1 ; b1 = cp [ 5 ] ; cp [ 5 ] = ( unsigned char ) ( ( b1 - b2 ) & 0xff ) ; b2 = b1 ; cp += 3 ; } while ( ( cc -= 3 ) > 0 ) ; } else if ( stride == 4 ) { unsigned int r1 , g1 , b1 , a1 ; unsigned int r2 = cp [ 0 ] ; unsigned int g2 = cp [ 1 ] ; unsigned int b2 = cp [ 2 ] ; unsigned int a2 = cp [ 3 ] ; do { r1 = cp [ 4 ] ; cp [ 4 ] = ( unsigned char ) ( ( r1 - r2 ) & 0xff ) ; r2 = r1 ; g1 = cp [ 5 ] ; cp [ 5 ] = ( unsigned char ) ( ( g1 - g2 ) & 0xff ) ; g2 = g1 ; b1 = cp [ 6 ] ; cp [ 6 ] = ( unsigned char ) ( ( b1 - b2 ) & 0xff ) ; b2 = b1 ; a1 = cp [ 7 ] ; cp [ 7 ] = ( unsigned char ) ( ( a1 - a2 ) & 0xff ) ; a2 = a1 ; cp += 4 ; } while ( ( cc -= 4 ) > 0 ) ; } else { cp += cc - 1 ; do { REPEAT4 ( stride , cp [ stride ] = ( unsigned char ) ( ( cp [ stride ] - cp [ 0 ] ) & 0xff ) ; cp -- ) } while ( ( cc -= stride ) > 0 ) ; } } } "," static int horDiff8 ( TIFF ) cp0 ; if ( ( cc % stride ) != 0 ) { TIFFErrorExt ( tif -> tif_clientdata , ""horDiff8"" , ""%s"" , ""(cc%stride)!=0"" ) ; return 0 ; } if ( cc ; } } return 1 ; ",vadz@libtiff/3ca657a8793dd011bf869695d72ad31c779c3cc1,CVE-2016-9535,https://github.com/vadz/libtiff/commit/3ca657a8793dd011bf869695d72ad31c779c3cc1,2016-11-22T19:59Z 1187,CWE-369,"CWE-369 static int set_geometry ( unsigned int cmd , struct floppy_struct * g , int drive , int type , struct block_device * bdev ) { int cnt ; if ( g -> sect <= 0 || g -> head <= 0 || g -> track <= 0 || g -> track > UDP -> tracks >> STRETCH ( g ) || ( g -> stretch & ~ ( FD_STRETCH | FD_SWAPSIDES | FD_SECTBASEMASK ) ) != 0 ) return - EINVAL ; if ( type ) { if ( ! capable ( CAP_SYS_ADMIN ) ) return - EPERM ; mutex_lock ( & open_lock ) ; if ( lock_fdc ( drive ) ) { mutex_unlock ( & open_lock ) ; return - EINTR ; } floppy_type [ type ] = * g ; floppy_type [ type ] . name = ""userformat"" ; for ( cnt = type << 2 ; cnt < ( type << 2 ) + 4 ; cnt ++ ) floppy_sizes [ cnt ] = floppy_sizes [ cnt + 0x80 ] = floppy_type [ type ] . size + 1 ; process_fd_request ( ) ; for ( cnt = 0 ; cnt < N_DRIVE ; cnt ++ ) { struct block_device * bdev = opened_bdev [ cnt ] ; if ( ! bdev || ITYPE ( drive_state [ cnt ] . fd_device ) != type ) continue ; __invalidate_device ( bdev , true ) ; } mutex_unlock ( & open_lock ) ; } else { int oldStretch ; if ( lock_fdc ( drive ) ) return - EINTR ; if ( cmd != FDDEFPRM ) { if ( poll_drive ( true , FD_RAW_NEED_DISK ) == - EINTR ) return - EINTR ; } oldStretch = g -> stretch ; user_params [ drive ] = * g ; if ( buffer_drive == drive ) SUPBOUND ( buffer_max , user_params [ drive ] . sect ) ; current_type [ drive ] = & user_params [ drive ] ; floppy_sizes [ drive ] = user_params [ drive ] . size ; if ( cmd == FDDEFPRM ) DRS -> keep_data = - 1 ; else DRS -> keep_data = 1 ; if ( DRS -> maxblock > user_params [ drive ] . sect || DRS -> maxtrack || ( ( user_params [ drive ] . sect ^ oldStretch ) & ( FD_SWAPSIDES | FD_SECTBASEMASK ) ) ) invalidate_drive ( bdev ) ; else process_fd_request ( ) ; } return 0 ; } "," -> head <= 0 || ( unsigned char ) ( ( g -> sect << 2 ) >> FD_SIZECODE ( g ) ) == ",torvalds@linux/f3554aeb991214cbfafd17d55e2bfddb50282e32,CVE-2019-14284,https://github.com/torvalds/linux/commit/f3554aeb991214cbfafd17d55e2bfddb50282e32,2019-07-26T13:15Z 1188,CWE-787,"CWE-787 void gps_tracker ( void ) { ssize_t unused ; int gpsd_sock ; char line [ 256 ] , * temp ; struct sockaddr_in gpsd_addr ; int ret , is_json , pos ; fd_set read_fd ; struct timeval timeout ; pos = 0 ; gpsd_sock = socket ( AF_INET , SOCK_STREAM , 0 ) ; if ( gpsd_sock < 0 ) { return ; } gpsd_addr . sin_family = AF_INET ; gpsd_addr . sin_port = htons ( 2947 ) ; gpsd_addr . sin_addr . s_addr = inet_addr ( ""127.0.0.1"" ) ; if ( connect ( gpsd_sock , ( struct sockaddr * ) & gpsd_addr , sizeof ( gpsd_addr ) ) < 0 ) { return ; } FD_ZERO ( & read_fd ) ; FD_SET ( gpsd_sock , & read_fd ) ; timeout . tv_sec = 1 ; timeout . tv_usec = 0 ; is_json = select ( gpsd_sock + 1 , & read_fd , NULL , NULL , & timeout ) ; if ( is_json ) { if ( recv ( gpsd_sock , line , sizeof ( line ) - 1 , 0 ) <= 0 ) return ; is_json = ( line [ 0 ] == '{' ) ; if ( is_json ) { memset ( line , 0 , sizeof ( line ) ) ; strcpy ( line , ""?WATCH={\\""json\\"":true};\\n"" ) ; if ( send ( gpsd_sock , line , 22 , 0 ) != 22 ) return ; memset ( line , 0 , sizeof ( line ) ) ; if ( recv ( gpsd_sock , line , sizeof ( line ) - 1 , 0 ) <= 0 ) return ; if ( strncmp ( line , ""{\\""class\\"":\\""DEVICES\\"",\\""devices\\"":[]}"" , 32 ) == 0 ) { close ( gpsd_sock ) ; return ; } else { pos = strlen ( line ) ; } } } while ( G . do_exit == 0 ) { usleep ( 500000 ) ; memset ( G . gps_loc , 0 , sizeof ( float ) * 5 ) ; if ( is_json ) { if ( pos == sizeof ( line ) ) { memset ( line , 0 , sizeof ( line ) ) ; pos = 0 ; } if ( recv ( gpsd_sock , line + pos , sizeof ( line ) - 1 , 0 ) <= 0 ) return ; temp = strstr ( line , ""{\\""class\\"":\\""TPV\\"""" ) ; if ( temp == NULL ) { continue ; } if ( strchr ( temp , '}' ) == NULL ) { pos = strlen ( temp ) ; if ( temp != line ) { memmove ( line , temp , pos ) ; memset ( line + pos , 0 , sizeof ( line ) - pos ) ; } } temp = strstr ( temp , ""\\""lat\\"":"" ) ; if ( temp == NULL ) { continue ; } ret = sscanf ( temp + 6 , ""%f"" , & G . gps_loc [ 0 ] ) ; temp = strstr ( temp , ""\\""lon\\"":"" ) ; if ( temp == NULL ) { continue ; } ret = sscanf ( temp + 6 , ""%f"" , & G . gps_loc [ 1 ] ) ; temp = strstr ( temp , ""\\""alt\\"":"" ) ; if ( temp == NULL ) { continue ; } ret = sscanf ( temp + 6 , ""%f"" , & G . gps_loc [ 4 ] ) ; temp = strstr ( temp , ""\\""speed\\"":"" ) ; if ( temp == NULL ) { continue ; } ret = sscanf ( temp + 6 , ""%f"" , & G . gps_loc [ 2 ] ) ; temp = strstr ( temp , ""{\\""class\\"":\\""TPV\\"""" ) ; if ( temp == NULL ) { memset ( line , 0 , sizeof ( line ) ) ; pos = 0 ; } else { pos = strlen ( temp ) ; memmove ( line , temp , pos ) ; memset ( line + pos , 0 , sizeof ( line ) - pos ) ; } } else { memset ( line , 0 , sizeof ( line ) ) ; snprintf ( line , sizeof ( line ) - 1 , ""PVTAD\\r\\n"" ) ; if ( send ( gpsd_sock , line , 7 , 0 ) != 7 ) return ; memset ( line , 0 , sizeof ( line ) ) ; if ( recv ( gpsd_sock , line , sizeof ( line ) - 1 , 0 ) <= 0 ) return ; if ( memcmp ( line , ""GPSD,P="" , 7 ) != 0 ) continue ; if ( line [ 7 ] == '?' ) continue ; ret = sscanf ( line + 7 , ""%f%f"" , & G . gps_loc [ 0 ] , & G . gps_loc [ 1 ] ) ; if ( ( temp = strstr ( line , ""V="" ) ) == NULL ) continue ; ret = sscanf ( temp + 2 , ""%f"" , & G . gps_loc [ 2 ] ) ; if ( ( temp = strstr ( line , ""T="" ) ) == NULL ) continue ; ret = sscanf ( temp + 2 , ""%f"" , & G . gps_loc [ 3 ] ) ; if ( ( temp = strstr ( line , ""A="" ) ) == NULL ) continue ; ret = sscanf ( temp + 2 , ""%f"" , & G . gps_loc [ 4 ] ) ; } if ( G . record_data ) fputs ( line , G . f_gps ) ; G . save_gps = 1 ; if ( G . do_exit == 0 ) { unused = write ( G . gc_pipe [ 1 ] , G . gps_loc , sizeof ( float ) * 5 ) ; kill ( getppid ( ) , SIGUSR2 ) ; } } } "," line ) - pos - ",aircrack-ng@aircrack-ng/ff70494dd389ba570dbdbf36f217c28d4381c6b5,CVE-2014-8321,https://github.com/aircrack-ng/aircrack-ng/commit/ff70494dd389ba570dbdbf36f217c28d4381c6b5,2020-01-31T22:15Z 1189,CWE-674,"CWE-674 krb5_error_code k5_asn1_full_decode ( const krb5_data * code , const struct atype_info * a , void * * retrep ) { krb5_error_code ret ; const uint8_t * contents , * remainder ; size_t clen , rlen ; taginfo t ; * retrep = NULL ; ret = get_tag ( ( uint8_t * ) code -> data , code -> length , & t , & contents , & clen , & remainder , & rlen ) ; if ( ret ) return ret ; if ( ! check_atype_tag ( a , & t ) ) return ASN1_BAD_ID ; return decode_atype_to_ptr ( & t , contents , clen , a , retrep ) ; } "," , & rlen , 0 ",krb5@krb5/57415dda6cf04e73ffc3723be518eddfae599bfd,CVE-2020-28196,https://github.com/krb5/krb5/commit/57415dda6cf04e73ffc3723be518eddfae599bfd,2020-11-06T08:15Z 1190,CWE-119,"CWE-119 static void user_login ( struct mt_connection * curconn , struct mt_mactelnet_hdr * pkthdr ) { struct mt_packet pdata ; unsigned char md5sum [ 17 ] ; char md5data [ 100 ] ; struct mt_credentials * user ; char * slavename ; read_userfile ( ) ; if ( ( user = find_user ( curconn -> username ) ) != NULL ) { md5_state_t state ; # if defined ( __linux__ ) && defined ( _POSIX_MEMLOCK_RANGE ) mlock ( md5data , sizeof ( md5data ) ) ; mlock ( md5sum , sizeof ( md5sum ) ) ; if ( user -> password != NULL ) { mlock ( user -> password , strlen ( user -> password ) ) ; } # endif md5data [ 0 ] = 0 ; strncpy ( md5data + 1 , user -> password , 82 ) ; memcpy ( md5data + 1 + strlen ( user -> password ) , curconn -> pass_salt , 16 ) ; md5_init ( & state ) ; md5_append ( & state , ( const md5_byte_t * ) md5data , strlen ( user -> password ) + 17 ) ; md5_finish ( & state , ( md5_byte_t * ) md5sum + 1 ) ; md5sum [ 0 ] = 0 ; init_packet ( & pdata , MT_PTYPE_DATA , pkthdr -> dstaddr , pkthdr -> srcaddr , pkthdr -> seskey , curconn -> outcounter ) ; curconn -> outcounter += add_control_packet ( & pdata , MT_CPTYPE_END_AUTH , NULL , 0 ) ; send_udp ( curconn , & pdata ) ; if ( curconn -> state == STATE_ACTIVE ) { return ; } } if ( user == NULL || memcmp ( md5sum , curconn -> trypassword , 17 ) != 0 ) { syslog ( LOG_NOTICE , _ ( ""(%d)Invalidloginby%s."" ) , curconn -> seskey , curconn -> username ) ; abort_connection ( curconn , pkthdr , _ ( ""Loginfailed,incorrectusernameorpassword\\r\\n"" ) ) ; return ; } curconn -> state = STATE_ACTIVE ; curconn -> terminal_mode = 1 ; curconn -> ptsfd = posix_openpt ( O_RDWR ) ; if ( curconn -> ptsfd == - 1 || grantpt ( curconn -> ptsfd ) == - 1 || unlockpt ( curconn -> ptsfd ) == - 1 ) { syslog ( LOG_ERR , ""posix_openpt:%s"" , strerror ( errno ) ) ; abort_connection ( curconn , pkthdr , _ ( ""Terminalerror\\r\\n"" ) ) ; return ; } slavename = ptsname ( curconn -> ptsfd ) ; if ( slavename != NULL ) { pid_t pid ; struct stat sb ; struct passwd * user = ( struct passwd * ) malloc ( sizeof ( struct passwd ) ) ; struct passwd * tmpuser = user ; char * buffer = malloc ( 1024 ) ; if ( user == NULL || buffer == NULL ) { syslog ( LOG_CRIT , _ ( ""(%d)Errorallocatingmemory."" ) , curconn -> seskey ) ; abort_connection ( curconn , pkthdr , _ ( ""Systemerror,outofmemory\\r\\n"" ) ) ; return ; } if ( getpwnam_r ( curconn -> username , user , buffer , 1024 , & tmpuser ) != 0 ) { syslog ( LOG_WARNING , _ ( ""(%d)Loginok,butlocalusernotaccessible(%s)."" ) , curconn -> seskey , curconn -> username ) ; abort_connection ( curconn , pkthdr , _ ( ""Localusernotaccessible\\r\\n"" ) ) ; free ( user ) ; free ( buffer ) ; return ; } chown ( slavename , user -> pw_uid , user -> pw_gid ) ; curconn -> slavefd = open ( slavename , O_RDWR ) ; if ( curconn -> slavefd == - 1 ) { syslog ( LOG_ERR , _ ( ""Erroropening%s:%s"" ) , slavename , strerror ( errno ) ) ; abort_connection ( curconn , pkthdr , _ ( ""Erroropeningterminal\\r\\n"" ) ) ; list_remove_connection ( curconn ) ; return ; } if ( ( pid = fork ( ) ) == 0 ) { struct net_interface * interface ; uwtmp_login ( curconn ) ; syslog ( LOG_INFO , _ ( ""(%d)User%sloggedin."" ) , curconn -> seskey , curconn -> username ) ; setenv ( ""USER"" , user -> pw_name , 1 ) ; setenv ( ""HOME"" , user -> pw_dir , 1 ) ; setenv ( ""SHELL"" , user -> pw_shell , 1 ) ; setenv ( ""TERM"" , curconn -> terminal_type , 1 ) ; close ( sockfd ) ; close ( insockfd ) ; DL_FOREACH ( interfaces , interface ) { if ( interface -> socketfd > 0 ) { close ( interface -> socketfd ) ; } } setsid ( ) ; fcntl ( curconn -> slavefd , F_SETFD , FD_CLOEXEC ) ; close ( curconn -> ptsfd ) ; close ( 0 ) ; dup ( curconn -> slavefd ) ; close ( 1 ) ; dup ( curconn -> slavefd ) ; close ( 2 ) ; dup ( curconn -> slavefd ) ; ioctl ( 0 , TIOCSCTTY , 1 ) ; tcsetpgrp ( 0 , getpid ( ) ) ; if ( ( setgid ( user -> pw_gid ) != 0 ) || ( setuid ( user -> pw_uid ) != 0 ) ) { syslog ( LOG_ERR , _ ( ""(%d)Couldnotlogin%s(%d:%d):setuid/setgid:%s"" ) , curconn -> seskey , curconn -> username , user -> pw_uid , user -> pw_gid , strerror ( errno ) ) ; abort_connection ( curconn , pkthdr , _ ( ""Internalerror\\r\\n"" ) ) ; exit ( 0 ) ; } if ( stat ( _PATH_NOLOGIN , & sb ) == 0 && getuid ( ) != 0 ) { syslog ( LOG_NOTICE , _ ( ""(%d)User%sdisconnectedwith"" _PATH_NOLOGIN ""message."" ) , curconn -> seskey , curconn -> username ) ; display_nologin ( ) ; curconn -> state = STATE_CLOSED ; init_packet ( & pdata , MT_PTYPE_END , pkthdr -> dstaddr , pkthdr -> srcaddr , pkthdr -> seskey , curconn -> outcounter ) ; send_udp ( curconn , & pdata ) ; exit ( 0 ) ; } display_motd ( ) ; chdir ( user -> pw_dir ) ; execl ( user -> pw_shell , user -> pw_shell , ""-"" , ( char * ) 0 ) ; exit ( 0 ) ; } free ( user ) ; free ( buffer ) ; close ( curconn -> slavefd ) ; curconn -> pid = pid ; set_terminal_size ( curconn -> ptsfd , curconn -> terminal_width , curconn -> terminal_height ) ; } } "," * slavename ; int act_pass_len ; } # endif act_pass_len = strlen ( user -> password ) ; act_pass_len = act_pass_len <= 82 ? act_pass_len : 82 ; = 0 ; memcpy ( md5data + -> password , act_pass_len ) ; memcpy + 1 + act_pass_len , curconn -> ) md5data , 1 + act_pass_len + 16 ) ; md5_finish ",haakonnessjoen@MAC-Telnet/b69d11727d4f0f8cf719c79e3fb700f55ca03e9a,CVE-2016-7115,https://github.com/haakonnessjoen/MAC-Telnet/commit/b69d11727d4f0f8cf719c79e3fb700f55ca03e9a,2016-08-30T17:59Z 1191,CWE-59,"CWE-59 static int mount_entry_on_absolute_rootfs ( struct mntent * mntent , const struct lxc_rootfs * rootfs , const char * lxc_name ) { char * aux ; char path [ MAXPATHLEN ] ; int r , ret = 0 , offset ; const char * lxcpath ; lxcpath = lxc_global_config_value ( ""lxc.lxcpath"" ) ; if ( ! lxcpath ) { ERROR ( ""Outofmemory"" ) ; return - 1 ; } r = snprintf ( path , MAXPATHLEN , ""%s/%s/rootfs"" , lxcpath , lxc_name ) ; if ( r < 0 || r >= MAXPATHLEN ) goto skipvarlib ; aux = strstr ( mntent -> mnt_dir , path ) ; if ( aux ) { offset = strlen ( path ) ; goto skipabs ; } skipvarlib : aux = strstr ( mntent -> mnt_dir , rootfs -> path ) ; if ( ! aux ) { WARN ( ""ignoringmountpoint\'%s\'"" , mntent -> mnt_dir ) ; return ret ; } offset = strlen ( rootfs -> path ) ; skipabs : r = snprintf ( path , MAXPATHLEN , ""%s/%s"" , rootfs -> mount , aux + offset ) ; if ( r < 0 || r >= MAXPATHLEN ) { WARN ( ""pathnmetoolongfor\'%s\'"" , mntent -> mnt_dir ) ; return - 1 ; } return mount_entry_on_generic ( mntent , path ) ; } "," mntent , path , rootfs -> mount ",lxc@lxc/592fd47a6245508b79fe6ac819fe6d3b2c1289be,CVE-2015-1335,https://github.com/lxc/lxc/commit/592fd47a6245508b79fe6ac819fe6d3b2c1289be,2015-10-01T20:59Z 1192,CWE-125,"CWE-125 static int forbidden_name ( struct compiling * c , identifier name , const node * n , int full_checks ) { assert ( PyUnicode_Check ( name ) ) ; if ( PyUnicode_CompareWithASCIIString ( name , ""__debug__"" ) == 0 ) { ast_error ( c , n , ""assignmenttokeyword"" ) ; return 1 ; } if ( full_checks ) { const char * const * p ; for ( p = FORBIDDEN ; * p ; p ++ ) { if ( PyUnicode_CompareWithASCIIString ( name , * p ) == 0 ) { ast_error ( c , n , ""assignmenttokeyword"" ) ; return 1 ; } } } return 0 ; } "," ; if ( _PyUnicode_EqualToASCIIString ( name , , ""__debug__"" ) ) { ast_error { if ( _PyUnicode_EqualToASCIIString ( name , * p ) ) { ast_error ",python@typed_ast/156afcb26c198e162504a57caddfe0acd9ed7dce,CVE-2019-19275,https://github.com/python/typed_ast/commit/156afcb26c198e162504a57caddfe0acd9ed7dce,2019-11-26T15:15Z 1193,CWE-772,"CWE-772 struct bio * bio_map_user_iov ( struct request_queue * q , const struct iov_iter * iter , gfp_t gfp_mask ) { int j ; int nr_pages = 0 ; struct page * * pages ; struct bio * bio ; int cur_page = 0 ; int ret , offset ; struct iov_iter i ; struct iovec iov ; iov_for_each ( iov , i , * iter ) { unsigned long uaddr = ( unsigned long ) iov . iov_base ; unsigned long len = iov . iov_len ; unsigned long end = ( uaddr + len + PAGE_SIZE - 1 ) >> PAGE_SHIFT ; unsigned long start = uaddr >> PAGE_SHIFT ; if ( end < start ) return ERR_PTR ( - EINVAL ) ; nr_pages += end - start ; if ( uaddr & queue_dma_alignment ( q ) ) return ERR_PTR ( - EINVAL ) ; } if ( ! nr_pages ) return ERR_PTR ( - EINVAL ) ; bio = bio_kmalloc ( gfp_mask , nr_pages ) ; if ( ! bio ) return ERR_PTR ( - ENOMEM ) ; ret = - ENOMEM ; pages = kcalloc ( nr_pages , sizeof ( struct page * ) , gfp_mask ) ; if ( ! pages ) goto out ; iov_for_each ( iov , i , * iter ) { unsigned long uaddr = ( unsigned long ) iov . iov_base ; unsigned long len = iov . iov_len ; unsigned long end = ( uaddr + len + PAGE_SIZE - 1 ) >> PAGE_SHIFT ; unsigned long start = uaddr >> PAGE_SHIFT ; const int local_nr_pages = end - start ; const int page_limit = cur_page + local_nr_pages ; ret = get_user_pages_fast ( uaddr , local_nr_pages , ( iter -> type & WRITE ) != WRITE , & pages [ cur_page ] ) ; if ( ret < local_nr_pages ) { ret = - EFAULT ; goto out_unmap ; } offset = offset_in_page ( uaddr ) ; for ( j = cur_page ; j < page_limit ; j ++ ) { unsigned int bytes = PAGE_SIZE - offset ; if ( len <= 0 ) break ; if ( bytes > len ) bytes = len ; if ( bio_add_pc_page ( q , bio , pages [ j ] , bytes , offset ) < bytes ) break ; len -= bytes ; offset = 0 ; } cur_page = j ; while ( j < page_limit ) put_page ( pages [ j ++ ] ) ; } kfree ( pages ) ; bio_set_flag ( bio , BIO_USER_MAPPED ) ; bio_get ( bio ) ; return bio ; out_unmap : for ( j = 0 ; j < nr_pages ; j ++ ) { if ( ! pages [ j ] ) break ; put_page ( pages [ j ] ) ; } out : kfree ( pages ) ; bio_put ( bio ) ; return ERR_PTR ( ret ) ; } "," - offset ; unsigned short prev_bi_vcnt = bio -> bi_vcnt ; ) break ; if ( bio -> bi_vcnt == prev_bi_vcnt ) put_page ( pages [ j ] ) ; ",torvalds@linux/95d78c28b5a85bacbc29b8dba7c04babb9b0d467,CVE-2017-12190,https://github.com/torvalds/linux/commit/95d78c28b5a85bacbc29b8dba7c04babb9b0d467,2017-11-22T18:29Z 1194,CWE-000,"CWE-000 static int ras_getcmap ( jas_stream_t * in , ras_hdr_t * hdr , ras_cmap_t * cmap ) { int i ; int j ; int x ; int c ; int numcolors ; int actualnumcolors ; switch ( hdr -> maptype ) { case RAS_MT_NONE : break ; case RAS_MT_EQUALRGB : { jas_eprintf ( ""warning:palettizedimagesnotfullysupported\\n"" ) ; numcolors = 1 << hdr -> depth ; assert ( numcolors <= RAS_CMAP_MAXSIZ ) ; actualnumcolors = hdr -> maplength / 3 ; for ( i = 0 ; i < numcolors ; i ++ ) { cmap -> data [ i ] = 0 ; } if ( ( hdr -> maplength % 3 ) || hdr -> maplength < 0 || hdr -> maplength > 3 * numcolors ) { return - 1 ; } for ( i = 0 ; i < 3 ; i ++ ) { for ( j = 0 ; j < actualnumcolors ; j ++ ) { if ( ( c = jas_stream_getc ( in ) ) == EOF ) { return - 1 ; } x = 0 ; switch ( i ) { case 0 : x = RAS_RED ( c ) ; break ; case 1 : x = RAS_GREEN ( c ) ; break ; case 2 : x = RAS_BLUE ( c ) ; break ; } cmap -> data [ j ] |= x ; } } } break ; default : return - 1 ; break ; } return 0 ; } "," -> depth ; if ( numcolors > RAS_CMAP_MAXSIZ ) { return - 1 ; } actualnumcolors = hdr ",mdadams@jasper/411a4068f8c464e883358bf403a3e25158863823,CVE-2016-9388,https://github.com/mdadams/jasper/commit/411a4068f8c464e883358bf403a3e25158863823,2017-03-23T18:59Z 1195,CWE-89,"CWE-89 static CURLcode smtp_connect ( struct connectdata * conn , bool * done ) { CURLcode result ; struct smtp_conn * smtpc = & conn -> proto . smtpc ; struct SessionHandle * data = conn -> data ; struct pingpong * pp = & smtpc -> pp ; const char * path = conn -> data -> state . path ; int len ; char localhost [ HOSTNAME_MAX + 1 ] ; * done = FALSE ; Curl_reset_reqproto ( conn ) ; result = smtp_init ( conn ) ; if ( CURLE_OK != result ) return result ; conn -> bits . close = FALSE ; pp -> response_time = RESP_TIMEOUT ; pp -> statemach_act = smtp_statemach_act ; pp -> endofresp = smtp_endofresp ; pp -> conn = conn ; if ( conn -> bits . tunnel_proxy && conn -> bits . httpproxy ) { struct HTTP http_proxy ; struct FTP * smtp_save ; smtp_save = data -> state . proto . smtp ; memset ( & http_proxy , 0 , sizeof ( http_proxy ) ) ; data -> state . proto . http = & http_proxy ; result = Curl_proxyCONNECT ( conn , FIRSTSOCKET , conn -> host . name , conn -> remote_port ) ; data -> state . proto . smtp = smtp_save ; if ( CURLE_OK != result ) return result ; } if ( ( conn -> handler -> protocol & CURLPROTO_SMTPS ) && data -> state . used_interface != Curl_if_multi ) { result = Curl_ssl_connect ( conn , FIRSTSOCKET ) ; if ( result ) return result ; } Curl_pp_init ( pp ) ; pp -> response_time = RESP_TIMEOUT ; pp -> statemach_act = smtp_statemach_act ; pp -> endofresp = smtp_endofresp ; pp -> conn = conn ; if ( ! * path ) { if ( ! Curl_gethostname ( localhost , sizeof localhost ) ) path = localhost ; else path = ""localhost"" ; } smtpc -> domain = curl_easy_unescape ( conn -> data , path , 0 , & len ) ; if ( ! smtpc -> domain ) return CURLE_OUT_OF_MEMORY ; state ( conn , SMTP_SERVERGREET ) ; if ( data -> state . used_interface == Curl_if_multi ) result = smtp_multi_statemach ( conn , done ) ; else { result = smtp_easy_statemach ( conn ) ; if ( ! result ) * done = TRUE ; } return result ; } "," state . path ; char localhost ""localhost"" ; } result = Curl_urldecode ( conn -> data , path , 0 , & smtpc -> domain , NULL , TRUE ) ; if ( result ) return result ; state ( ",bagder@curl/75ca568fa1c19de4c5358fed246686de8467c238,CVE-2012-0036,https://github.com/bagder/curl/commit/75ca568fa1c19de4c5358fed246686de8467c238,2012-04-13T20:55Z 1196,CWE-119,"CWE-119 void jslGetTokenString ( char * str , size_t len ) { if ( lex -> tk == LEX_ID ) { strncpy ( str , ""ID:"" , len ) ; strncat ( str , jslGetTokenValueAsString ( ) , len ) ; } else if ( lex -> tk == LEX_STR ) { strncpy ( str , ""String:\'"" , len ) ; strncat ( str , jslGetTokenValueAsString ( ) , len ) ; strncat ( str , ""\'"" , len ) ; } else jslTokenAsString ( lex -> tk , str , len ) ; } "," LEX_ID ) { espruino_snprintf ( str , ( str , len , ""ID:%s"" , jslGetTokenValueAsString ( jslGetTokenValueAsString ( ) ) ; } LEX_STR ) { espruino_snprintf ( str , ( str , len , ""String:\'%s\'"" , jslGetTokenValueAsString ( jslGetTokenValueAsString ( ) ) ; } ",espruino@Espruino/0a7619875bf79877907205f6bee08465b89ff10b,CVE-2018-11595,https://github.com/espruino/Espruino/commit/0a7619875bf79877907205f6bee08465b89ff10b,2018-05-31T16:29Z 1197,CWE-125,"CWE-125 ut32 armass_assemble ( const char * str , ut64 off , int thumb ) { int i , j ; char buf [ 128 ] ; ArmOpcode aop = { . off = off } ; for ( i = j = 0 ; i < sizeof ( buf ) - 1 && str [ i ] ; i ++ , j ++ ) { if ( str [ j ] == '#' ) { i -- ; continue ; } buf [ i ] = tolower ( ( const ut8 ) str [ j ] ) ; } buf [ i ] = 0 ; arm_opcode_parse ( & aop , buf ) ; aop . off = off ; if ( thumb < 0 || thumb > 1 ) { return - 1 ; } if ( ! assemble [ thumb ] ( & aop , off , buf ) ) { return - 1 ; } return aop . o ; } "," && str [ j ] ; i ",devnexen@radare2/88a8adf080a9f8ed5a4250a2507752e133ba54dd,CVE-2018-20459,https://github.com/devnexen/radare2/commit/88a8adf080a9f8ed5a4250a2507752e133ba54dd,2018-12-25T19:29Z 1198,CWE-190,"CWE-190 int pnm_validate ( jas_stream_t * in ) { uchar buf [ 2 ] ; int i ; int n ; assert ( JAS_STREAM_MAXPUTBACK >= 2 ) ; if ( ( n = jas_stream_read ( in , buf , 2 ) ) < 0 ) { return - 1 ; } for ( i = n - 1 ; i >= 0 ; -- i ) { if ( jas_stream_ungetc ( in , buf [ i ] ) == EOF ) { return - 1 ; } } if ( n < 2 ) { return - 1 ; } if ( buf [ 0 ] == 'P' && isdigit ( buf [ 1 ] ) ) { return 0 ; } return - 1 ; } "," in ) { jas_uchar buf [ 2 ",mdadams@jasper/d42b2388f7f8e0332c846675133acea151fc557a,CVE-2016-9557,https://github.com/mdadams/jasper/commit/d42b2388f7f8e0332c846675133acea151fc557a,2017-03-23T18:59Z 1199,CWE-000,"CWE-000 int rds_ib_xmit ( struct rds_connection * conn , struct rds_message * rm , unsigned int hdr_off , unsigned int sg , unsigned int off ) { struct rds_ib_connection * ic = conn -> c_transport_data ; struct ib_device * dev = ic -> i_cm_id -> device ; struct rds_ib_send_work * send = NULL ; struct rds_ib_send_work * first ; struct rds_ib_send_work * prev ; struct ib_send_wr * failed_wr ; struct scatterlist * scat ; u32 pos ; u32 i ; u32 work_alloc ; u32 credit_alloc = 0 ; u32 posted ; u32 adv_credits = 0 ; int send_flags = 0 ; int bytes_sent = 0 ; int ret ; int flow_controlled = 0 ; int nr_sig = 0 ; BUG_ON ( off % RDS_FRAG_SIZE ) ; BUG_ON ( hdr_off != 0 && hdr_off != sizeof ( struct rds_header ) ) ; if ( conn -> c_loopback && rm -> m_inc . i_hdr . h_flags & RDS_FLAG_CONG_BITMAP ) { rds_cong_map_updated ( conn -> c_fcong , ~ ( u64 ) 0 ) ; return sizeof ( struct rds_header ) + RDS_CONG_MAP_BYTES ; } if ( be32_to_cpu ( rm -> m_inc . i_hdr . h_len ) == 0 ) i = 1 ; else i = ceil ( be32_to_cpu ( rm -> m_inc . i_hdr . h_len ) , RDS_FRAG_SIZE ) ; work_alloc = rds_ib_ring_alloc ( & ic -> i_send_ring , i , & pos ) ; if ( work_alloc == 0 ) { set_bit ( RDS_LL_SEND_FULL , & conn -> c_flags ) ; rds_ib_stats_inc ( s_ib_tx_ring_full ) ; ret = - ENOMEM ; goto out ; } if ( ic -> i_flowctl ) { credit_alloc = rds_ib_send_grab_credits ( ic , work_alloc , & posted , 0 , RDS_MAX_ADV_CREDIT ) ; adv_credits += posted ; if ( credit_alloc < work_alloc ) { rds_ib_ring_unalloc ( & ic -> i_send_ring , work_alloc - credit_alloc ) ; work_alloc = credit_alloc ; flow_controlled = 1 ; } if ( work_alloc == 0 ) { set_bit ( RDS_LL_SEND_FULL , & conn -> c_flags ) ; rds_ib_stats_inc ( s_ib_tx_throttle ) ; ret = - ENOMEM ; goto out ; } } if ( ! ic -> i_data_op ) { if ( rm -> data . op_nents ) { rm -> data . op_count = ib_dma_map_sg ( dev , rm -> data . op_sg , rm -> data . op_nents , DMA_TO_DEVICE ) ; rdsdebug ( ""ic%pmappingrm%p:%d\\n"" , ic , rm , rm -> data . op_count ) ; if ( rm -> data . op_count == 0 ) { rds_ib_stats_inc ( s_ib_tx_sg_mapping_failure ) ; rds_ib_ring_unalloc ( & ic -> i_send_ring , work_alloc ) ; ret = - ENOMEM ; goto out ; } } else { rm -> data . op_count = 0 ; } rds_message_addref ( rm ) ; ic -> i_data_op = & rm -> data ; if ( test_bit ( RDS_MSG_ACK_REQUIRED , & rm -> m_flags ) ) rm -> m_inc . i_hdr . h_flags |= RDS_FLAG_ACK_REQUIRED ; if ( test_bit ( RDS_MSG_RETRANSMITTED , & rm -> m_flags ) ) rm -> m_inc . i_hdr . h_flags |= RDS_FLAG_RETRANSMITTED ; if ( rm -> rdma . op_active ) { struct rds_ext_header_rdma ext_hdr ; ext_hdr . h_rdma_rkey = cpu_to_be32 ( rm -> rdma . op_rkey ) ; rds_message_add_extension ( & rm -> m_inc . i_hdr , RDS_EXTHDR_RDMA , & ext_hdr , sizeof ( ext_hdr ) ) ; } if ( rm -> m_rdma_cookie ) { rds_message_add_rdma_dest_extension ( & rm -> m_inc . i_hdr , rds_rdma_cookie_key ( rm -> m_rdma_cookie ) , rds_rdma_cookie_offset ( rm -> m_rdma_cookie ) ) ; } rm -> m_inc . i_hdr . h_ack = cpu_to_be64 ( rds_ib_piggyb_ack ( ic ) ) ; rds_message_make_checksum ( & rm -> m_inc . i_hdr ) ; if ( ic -> i_flowctl ) { rds_ib_send_grab_credits ( ic , 0 , & posted , 1 , RDS_MAX_ADV_CREDIT - adv_credits ) ; adv_credits += posted ; BUG_ON ( adv_credits > 255 ) ; } } if ( rm -> rdma . op_active && rm -> rdma . op_fence ) send_flags = IB_SEND_FENCE ; send = & ic -> i_sends [ pos ] ; first = send ; prev = NULL ; scat = & ic -> i_data_op -> op_sg [ sg ] ; i = 0 ; do { unsigned int len = 0 ; send -> s_wr . send_flags = send_flags ; send -> s_wr . opcode = IB_WR_SEND ; send -> s_wr . num_sge = 1 ; send -> s_wr . next = NULL ; send -> s_queued = jiffies ; send -> s_op = NULL ; send -> s_sge [ 0 ] . addr = ic -> i_send_hdrs_dma + ( pos * sizeof ( struct rds_header ) ) ; send -> s_sge [ 0 ] . length = sizeof ( struct rds_header ) ; memcpy ( & ic -> i_send_hdrs [ pos ] , & rm -> m_inc . i_hdr , sizeof ( struct rds_header ) ) ; if ( i < work_alloc && scat != & rm -> data . op_sg [ rm -> data . op_count ] ) { len = min ( RDS_FRAG_SIZE , ib_sg_dma_len ( dev , scat ) - off ) ; send -> s_wr . num_sge = 2 ; send -> s_sge [ 1 ] . addr = ib_sg_dma_address ( dev , scat ) + off ; send -> s_sge [ 1 ] . length = len ; bytes_sent += len ; off += len ; if ( off == ib_sg_dma_len ( dev , scat ) ) { scat ++ ; off = 0 ; } } rds_ib_set_wr_signal_state ( ic , send , 0 ) ; if ( ic -> i_flowctl && flow_controlled && i == ( work_alloc - 1 ) ) send -> s_wr . send_flags |= IB_SEND_SIGNALED | IB_SEND_SOLICITED ; if ( send -> s_wr . send_flags & IB_SEND_SIGNALED ) nr_sig ++ ; rdsdebug ( ""send%pwr%pnum_sge%unext%p\\n"" , send , & send -> s_wr , send -> s_wr . num_sge , send -> s_wr . next ) ; if ( ic -> i_flowctl && adv_credits ) { struct rds_header * hdr = & ic -> i_send_hdrs [ pos ] ; hdr -> h_credit = adv_credits ; rds_message_make_checksum ( hdr ) ; adv_credits = 0 ; rds_ib_stats_inc ( s_ib_tx_credit_updates ) ; } if ( prev ) prev -> s_wr . next = & send -> s_wr ; prev = send ; pos = ( pos + 1 ) % ic -> i_send_ring . w_nr ; send = & ic -> i_sends [ pos ] ; i ++ ; } while ( i < work_alloc && scat != & rm -> data . op_sg [ rm -> data . op_count ] ) ; if ( hdr_off == 0 ) bytes_sent += sizeof ( struct rds_header ) ; if ( scat == & rm -> data . op_sg [ rm -> data . op_count ] ) { prev -> s_op = ic -> i_data_op ; prev -> s_wr . send_flags |= IB_SEND_SOLICITED ; ic -> i_data_op = NULL ; } if ( i < work_alloc ) { rds_ib_ring_unalloc ( & ic -> i_send_ring , work_alloc - i ) ; work_alloc = i ; } if ( ic -> i_flowctl && i < credit_alloc ) rds_ib_send_add_credits ( conn , credit_alloc - i ) ; if ( nr_sig ) atomic_add ( nr_sig , & ic -> i_signaled_sends ) ; failed_wr = & first -> s_wr ; ret = ib_post_send ( ic -> i_cm_id -> qp , & first -> s_wr , & failed_wr ) ; rdsdebug ( ""ic%pfirst%p(wr%p)ret%dwr%p\\n"" , ic , first , & first -> s_wr , ret , failed_wr ) ; BUG_ON ( failed_wr != & first -> s_wr ) ; if ( ret ) { printk ( KERN_WARNING ""RDS/IB:ib_post_sendto%pI4"" ""returned%d\\n"" , & conn -> c_faddr , ret ) ; rds_ib_ring_unalloc ( & ic -> i_send_ring , work_alloc ) ; rds_ib_sub_signaled ( ic , nr_sig ) ; if ( prev -> s_op ) { ic -> i_data_op = prev -> s_op ; prev -> s_op = NULL ; } rds_ib_conn_error ( ic -> conn , ""ib_post_sendfailed\\n"" ) ; goto out ; } ret = bytes_sent ; out : BUG_ON ( adv_credits ) ; return ret ; } "," 0 ) ; scat = & rm -> data . op_sg [ sg ] ; ret = sizeof ( struct ) + RDS_CONG_MAP_BYTES ; ret = min_t ( int , ret , scat -> length - conn -> c_xmit_data_off ) ; return ret ",torvalds@linux/6094628bfd94323fc1cea05ec2c6affd98c18f7f,CVE-2011-1023,https://github.com/torvalds/linux/commit/6094628bfd94323fc1cea05ec2c6affd98c18f7f,2012-06-21T23:55Z 1200,CWE-476,"CWE-476 static int unimac_mdio_probe ( struct platform_device * pdev ) { struct unimac_mdio_pdata * pdata = pdev -> dev . platform_data ; struct unimac_mdio_priv * priv ; struct device_node * np ; struct mii_bus * bus ; struct resource * r ; int ret ; np = pdev -> dev . of_node ; priv = devm_kzalloc ( & pdev -> dev , sizeof ( * priv ) , GFP_KERNEL ) ; if ( ! priv ) return - ENOMEM ; r = platform_get_resource ( pdev , IORESOURCE_MEM , 0 ) ; priv -> base = devm_ioremap ( & pdev -> dev , r -> start , resource_size ( r ) ) ; if ( ! priv -> base ) { dev_err ( & pdev -> dev , ""failedtoremapregister\\n"" ) ; return - ENOMEM ; } priv -> mii_bus = mdiobus_alloc ( ) ; if ( ! priv -> mii_bus ) return - ENOMEM ; bus = priv -> mii_bus ; bus -> priv = priv ; if ( pdata ) { bus -> name = pdata -> bus_name ; priv -> wait_func = pdata -> wait_func ; priv -> wait_func_data = pdata -> wait_func_data ; bus -> phy_mask = ~ pdata -> phy_mask ; } else { bus -> name = ""unimacMIIbus"" ; priv -> wait_func_data = priv ; priv -> wait_func = unimac_mdio_poll ; } bus -> parent = & pdev -> dev ; bus -> read = unimac_mdio_read ; bus -> write = unimac_mdio_write ; bus -> reset = unimac_mdio_reset ; snprintf ( bus -> id , MII_BUS_ID_SIZE , ""%s-%d"" , pdev -> name , pdev -> id ) ; ret = of_mdiobus_register ( bus , np ) ; if ( ret ) { dev_err ( & pdev -> dev , ""MDIObusregistrationfailed\\n"" ) ; goto out_mdio_free ; } platform_set_drvdata ( pdev , priv ) ; dev_info ( & pdev -> dev , ""BroadcomUniMACMDIObusat0x%p\\n"" , priv -> base ) ; return 0 ; out_mdio_free : mdiobus_free ( bus ) ; return ret ; } "," 0 ) ; if ( ! r ) return - EINVAL ; ",torvalds@linux/297a6961ffb8ff4dc66c9fbf53b924bd1dda05d5,CVE-2018-8043,https://github.com/torvalds/linux/commit/297a6961ffb8ff4dc66c9fbf53b924bd1dda05d5,2018-03-10T22:29Z 1201,CWE-476,"CWE-476 BOOL transport_connect_nla ( rdpTransport * transport ) { freerdp * instance ; rdpSettings * settings ; if ( transport -> layer == TRANSPORT_LAYER_TSG ) return TRUE ; if ( ! transport_connect_tls ( transport ) ) return FALSE ; if ( transport -> settings -> Authentication != TRUE ) return TRUE ; settings = transport -> settings ; instance = ( freerdp * ) settings -> instance ; if ( transport -> credssp == NULL ) transport -> credssp = credssp_new ( instance , transport , settings ) ; if ( credssp_authenticate ( transport -> credssp ) < 0 ) { if ( ! connectErrorCode ) connectErrorCode = AUTHENTICATIONERROR ; fprintf ( stderr , ""Authenticationfailure,checkcredentials.\\n"" ""Ifcredentialsarevalid,theNTLMSSPimplementationmaybetoblame.\\n"" ) ; credssp_free ( transport -> credssp ) ; return FALSE ; } credssp_free ( transport -> credssp ) ; return TRUE ; } "," credssp ) ; transport -> credssp = NULL ; ",FreeRDP@FreeRDP/0773bb9303d24473fe1185d85a424dfe159aff53,CVE-2013-4119,https://github.com/FreeRDP/FreeRDP/commit/0773bb9303d24473fe1185d85a424dfe159aff53,2016-10-03T21:59Z 1202,CWE-125,"CWE-125 static int jpc_pi_nextrlcp ( register jpc_pi_t * pi ) { jpc_pchg_t * pchg ; int * prclyrno ; pchg = pi -> pchg ; if ( ! pi -> prgvolfirst ) { assert ( pi -> prcno < pi -> pirlvl -> numprcs ) ; prclyrno = & pi -> pirlvl -> prclyrnos [ pi -> prcno ] ; goto skip ; } else { pi -> prgvolfirst = 0 ; } for ( pi -> rlvlno = pchg -> rlvlnostart ; pi -> rlvlno < pi -> maxrlvls && pi -> rlvlno < pchg -> rlvlnoend ; ++ pi -> rlvlno ) { for ( pi -> lyrno = 0 ; pi -> lyrno < pi -> numlyrs && pi -> lyrno < JAS_CAST ( int , pchg -> lyrnoend ) ; ++ pi -> lyrno ) { for ( pi -> compno = pchg -> compnostart , pi -> picomp = & pi -> picomps [ pi -> compno ] ; pi -> compno < pi -> numcomps && pi -> compno < JAS_CAST ( int , pchg -> compnoend ) ; ++ pi -> compno , ++ pi -> picomp ) { if ( pi -> rlvlno >= pi -> picomp -> numrlvls ) { continue ; } pi -> pirlvl = & pi -> picomp -> pirlvls [ pi -> rlvlno ] ; for ( pi -> prcno = 0 , prclyrno = pi -> pirlvl -> prclyrnos ; pi -> prcno < pi -> pirlvl -> numprcs ; ++ pi -> prcno , ++ prclyrno ) { if ( pi -> lyrno >= * prclyrno ) { * prclyrno = pi -> lyrno ; ++ ( * prclyrno ) ; return 0 ; } skip : ; } } } } return 1 ; } "," ",mdadams@jasper/aa0b0f79ade5eef8b0e7a214c03f5af54b36ba7d,CVE-2016-9583,https://github.com/mdadams/jasper/commit/aa0b0f79ade5eef8b0e7a214c03f5af54b36ba7d,2018-08-01T17:29Z 1203,CWE-78,"CWE-78 static int bin_symbols ( RCore * r , int mode , ut64 laddr , int va , ut64 at , const char * name , bool exponly , const char * args ) { RBinInfo * info = r_bin_get_info ( r -> bin ) ; RList * entries = r_bin_get_entries ( r -> bin ) ; RBinSymbol * symbol ; RBinAddr * entry ; RListIter * iter ; bool firstexp = true ; bool printHere = false ; int i = 0 , lastfs = 's' ; bool bin_demangle = r_config_get_i ( r -> config , ""bin.demangle"" ) ; if ( ! info ) { return 0 ; } if ( args && * args == '.' ) { printHere = true ; } bool is_arm = info && info -> arch && ! strncmp ( info -> arch , ""arm"" , 3 ) ; const char * lang = bin_demangle ? r_config_get ( r -> config , ""bin.lang"" ) : NULL ; RList * symbols = r_bin_get_symbols ( r -> bin ) ; r_spaces_push ( & r -> anal -> meta_spaces , ""bin"" ) ; if ( IS_MODE_JSON ( mode ) && ! printHere ) { r_cons_printf ( ""["" ) ; } else if ( IS_MODE_SET ( mode ) ) { r_flag_space_set ( r -> flags , R_FLAGS_FS_SYMBOLS ) ; } else if ( ! at && exponly ) { if ( IS_MODE_RAD ( mode ) ) { r_cons_printf ( ""fsexports\\n"" ) ; } else if ( IS_MODE_NORMAL ( mode ) ) { r_cons_printf ( printHere ? """" : ""[Exports]\\n"" ) ; } } else if ( ! at && ! exponly ) { if ( IS_MODE_RAD ( mode ) ) { r_cons_printf ( ""fssymbols\\n"" ) ; } else if ( IS_MODE_NORMAL ( mode ) ) { r_cons_printf ( printHere ? """" : ""[Symbols]\\n"" ) ; } } if ( IS_MODE_NORMAL ( mode ) ) { r_cons_printf ( ""NumPaddrVaddrBindTypeSizeName\\n"" ) ; } size_t count = 0 ; r_list_foreach ( symbols , iter , symbol ) { if ( ! symbol -> name ) { continue ; } char * r_symbol_name = r_str_escape_utf8 ( symbol -> name , false , true ) ; ut64 addr = compute_addr ( r -> bin , symbol -> paddr , symbol -> vaddr , va ) ; int len = symbol -> size ? symbol -> size : 32 ; SymName sn = { 0 } ; if ( exponly && ! isAnExport ( symbol ) ) { free ( r_symbol_name ) ; continue ; } if ( name && strcmp ( r_symbol_name , name ) ) { free ( r_symbol_name ) ; continue ; } if ( at && ( ! symbol -> size || ! is_in_range ( at , addr , symbol -> size ) ) ) { free ( r_symbol_name ) ; continue ; } if ( ( printHere && ! is_in_range ( r -> offset , symbol -> paddr , len ) ) && ( printHere && ! is_in_range ( r -> offset , addr , len ) ) ) { free ( r_symbol_name ) ; continue ; } count ++ ; snInit ( r , & sn , symbol , lang ) ; if ( IS_MODE_SET ( mode ) && ( is_section_symbol ( symbol ) || is_file_symbol ( symbol ) ) ) { } else if ( IS_MODE_SET ( mode ) && is_special_symbol ( symbol ) ) { if ( is_arm ) { handle_arm_special_symbol ( r , symbol , va ) ; } } else if ( IS_MODE_SET ( mode ) ) { if ( is_arm ) { handle_arm_symbol ( r , symbol , info , va ) ; } select_flag_space ( r , symbol ) ; if ( sn . classname ) { RFlagItem * fi = r_flag_get ( r -> flags , sn . methflag ) ; if ( r -> bin -> prefix ) { char * prname = r_str_newf ( ""%s.%s"" , r -> bin -> prefix , sn . methflag ) ; r_name_filter ( sn . methflag , - 1 ) ; free ( sn . methflag ) ; sn . methflag = prname ; } if ( fi ) { r_flag_item_set_realname ( fi , sn . methname ) ; if ( ( fi -> offset - r -> flags -> base ) == addr ) { r_flag_unset ( r -> flags , fi ) ; } } else { fi = r_flag_set ( r -> flags , sn . methflag , addr , symbol -> size ) ; char * comment = fi -> comment ? strdup ( fi -> comment ) : NULL ; if ( comment ) { r_flag_item_set_comment ( fi , comment ) ; R_FREE ( comment ) ; } } } else { const char * n = sn . demname ? sn . demname : sn . name ; const char * fn = sn . demflag ? sn . demflag : sn . nameflag ; char * fnp = ( r -> bin -> prefix ) ? r_str_newf ( ""%s.%s"" , r -> bin -> prefix , fn ) : strdup ( fn ) ; RFlagItem * fi = r_flag_set ( r -> flags , fnp , addr , symbol -> size ) ; if ( fi ) { r_flag_item_set_realname ( fi , n ) ; fi -> demangled = ( bool ) ( size_t ) sn . demname ; } else { if ( fn ) { eprintf ( ""[Warning]Can\'tfindflag(%s)\\n"" , fn ) ; } } free ( fnp ) ; } if ( sn . demname ) { r_meta_add ( r -> anal , R_META_TYPE_COMMENT , addr , symbol -> size , sn . demname ) ; } r_flag_space_pop ( r -> flags ) ; } else if ( IS_MODE_JSON ( mode ) ) { char * str = r_str_escape_utf8_for_json ( r_symbol_name , - 1 ) ; r_cons_printf ( ""%s{\\""name\\"":\\""%s\\"","" ""\\""demname\\"":\\""%s\\"","" ""\\""flagname\\"":\\""%s\\"","" ""\\""ordinal\\"":%d,"" ""\\""bind\\"":\\""%s\\"","" ""\\""size\\"":%d,"" ""\\""type\\"":\\""%s\\"","" ""\\""vaddr\\"":%"" PFMT64d "","" ""\\""paddr\\"":%"" PFMT64d ""}"" , ( ( exponly && firstexp ) || printHere ) ? """" : ( iter -> p ? "","" : """" ) , str , sn . demname ? sn . demname : """" , sn . nameflag , symbol -> ordinal , symbol -> bind , ( int ) symbol -> size , symbol -> type , ( ut64 ) addr , ( ut64 ) symbol -> paddr ) ; free ( str ) ; } else if ( IS_MODE_SIMPLE ( mode ) ) { const char * name = sn . demname ? sn . demname : r_symbol_name ; r_cons_printf ( ""0x%08"" PFMT64x ""%d%s\\n"" , addr , ( int ) symbol -> size , name ) ; } else if ( IS_MODE_SIMPLEST ( mode ) ) { const char * name = sn . demname ? sn . demname : r_symbol_name ; r_cons_printf ( ""%s\\n"" , name ) ; } else if ( IS_MODE_RAD ( mode ) ) { if ( is_special_symbol ( symbol ) ) { goto next ; } RBinFile * binfile ; RBinPlugin * plugin ; const char * name = sn . demname ? sn . demname : r_symbol_name ; if ( ! name ) { goto next ; } if ( ! strncmp ( name , ""imp."" , 4 ) ) { if ( lastfs != 'i' ) { r_cons_printf ( ""fsimports\\n"" ) ; } lastfs = 'i' ; } else { if ( lastfs != 's' ) { const char * fs = exponly ? ""exports"" : ""symbols"" ; r_cons_printf ( ""fs%s\\n"" , fs ) ; } lastfs = 's' ; } if ( r -> bin -> prefix || * name ) { char * flagname = construct_symbol_flagname ( ""sym"" , name , MAXFLAG_LEN_DEFAULT ) ; if ( ! flagname ) { goto next ; } r_cons_printf ( ""\\""f%s%s%s%u0x%08"" PFMT64x ""\\""\\n"" , r -> bin -> prefix ? r -> bin -> prefix : """" , r -> bin -> prefix ? ""."" : """" , flagname , symbol -> size , addr ) ; free ( flagname ) ; } binfile = r_bin_cur ( r -> bin ) ; plugin = r_bin_file_cur_plugin ( binfile ) ; if ( plugin && plugin -> name ) { if ( r_str_startswith ( plugin -> name , ""pe"" ) ) { char * module = strdup ( r_symbol_name ) ; char * p = strstr ( module , "".dll_"" ) ; if ( p && strstr ( module , ""imp."" ) ) { char * symname = __filterShell ( p + 5 ) ; char * m = __filterShell ( module ) ; * p = 0 ; if ( r -> bin -> prefix ) { r_cons_printf ( ""kbin/pe/%s/%d=%s.%s\\n"" , module , symbol -> ordinal , r -> bin -> prefix , symname ) ; } else { r_cons_printf ( ""kbin/pe/%s/%d=%s\\n"" , module , symbol -> ordinal , symname ) ; } free ( symname ) ; free ( m ) ; } free ( module ) ; } } } else { const char * bind = symbol -> bind ? symbol -> bind : ""NONE"" ; const char * type = symbol -> type ? symbol -> type : ""NONE"" ; const char * name = r_str_get ( sn . demname ? sn . demname : r_symbol_name ) ; r_cons_printf ( ""%03u"" , symbol -> ordinal ) ; if ( symbol -> paddr == UT64_MAX ) { r_cons_printf ( ""----------"" ) ; } else { r_cons_printf ( ""0x%08"" PFMT64x , symbol -> paddr ) ; } r_cons_printf ( ""0x%08"" PFMT64x ""%6s%6s%4d%s%s\\n"" , addr , bind , type , symbol -> size , * name ? """" : """" , name ) ; } next : snFini ( & sn ) ; i ++ ; free ( r_symbol_name ) ; if ( exponly && firstexp ) { firstexp = false ; } if ( printHere ) { break ; } } if ( count == 0 && IS_MODE_JSON ( mode ) ) { r_cons_printf ( ""{}"" ) ; } if ( is_arm ) { r_list_foreach ( entries , iter , entry ) { if ( IS_MODE_SET ( mode ) ) { handle_arm_entry ( r , entry , info , va ) ; } } } if ( IS_MODE_JSON ( mode ) && ! printHere ) { r_cons_printf ( ""]"" ) ; } r_spaces_pop ( & r -> anal -> meta_spaces ) ; return true ; } "," { r_cons_printf ( ""\\""kbin/pe/%s/%d=%s.%s\\""\\n"" , module , { r_cons_printf ( ""\\""kbin/pe/%s/%d=%s\\""\\n"" , module , ",radareorg@radare2/5411543a310a470b1257fb93273cdd6e8dfcb3af,CVE-2019-16718,https://github.com/radareorg/radare2/commit/5411543a310a470b1257fb93273cdd6e8dfcb3af,2019-09-23T14:15Z 1204,CWE-189,"CWE-189 static int nfs4_xdr_dec_getacl ( struct rpc_rqst * rqstp , struct xdr_stream * xdr , struct nfs_getaclres * res ) { struct compound_hdr hdr ; int status ; status = decode_compound_hdr ( xdr , & hdr ) ; if ( status ) goto out ; status = decode_sequence ( xdr , & res -> seq_res , rqstp ) ; if ( status ) goto out ; status = decode_putfh ( xdr ) ; if ( status ) goto out ; status = decode_getacl ( xdr , rqstp , & res -> acl_len ) ; out : return status ; } "," , rqstp , res ) ; out ",torvalds@linux/bf118a342f10dafe44b14451a1392c3254629a1f,CVE-2011-4131,https://github.com/torvalds/linux/commit/bf118a342f10dafe44b14451a1392c3254629a1f,2012-05-17T11:00Z 1205,CWE-59,"CWE-59 static inline int mount_entry_on_systemfs ( struct mntent * mntent ) { return mount_entry_on_generic ( mntent , mntent -> mnt_dir ) ; } "," mntent -> mnt_dir , NULL ",lxc@lxc/592fd47a6245508b79fe6ac819fe6d3b2c1289be,CVE-2015-1335,https://github.com/lxc/lxc/commit/592fd47a6245508b79fe6ac819fe6d3b2c1289be,2015-10-01T20:59Z 1206,CWE-310,"CWE-310 static VALUE ossl_cipher_pkcs5_keyivgen ( int argc , VALUE * argv , VALUE self ) { EVP_CIPHER_CTX * ctx ; const EVP_MD * digest ; VALUE vpass , vsalt , viter , vdigest ; unsigned char key [ EVP_MAX_KEY_LENGTH ] , iv [ EVP_MAX_IV_LENGTH ] , * salt = NULL ; int iter ; rb_scan_args ( argc , argv , ""13"" , & vpass , & vsalt , & viter , & vdigest ) ; StringValue ( vpass ) ; if ( ! NIL_P ( vsalt ) ) { StringValue ( vsalt ) ; if ( RSTRING_LEN ( vsalt ) != PKCS5_SALT_LEN ) ossl_raise ( eCipherError , ""saltmustbean8-octetstring"" ) ; salt = ( unsigned char * ) RSTRING_PTR ( vsalt ) ; } iter = NIL_P ( viter ) ? 2048 : NUM2INT ( viter ) ; digest = NIL_P ( vdigest ) ? EVP_md5 ( ) : GetDigestPtr ( vdigest ) ; GetCipher ( self , ctx ) ; EVP_BytesToKey ( EVP_CIPHER_CTX_cipher ( ctx ) , digest , salt , ( unsigned char * ) RSTRING_PTR ( vpass ) , RSTRING_LENINT ( vpass ) , iter , key , iv ) ; if ( EVP_CipherInit_ex ( ctx , NULL , NULL , key , iv , - 1 ) != 1 ) ossl_raise ( eCipherError , NULL ) ; OPENSSL_cleanse ( key , sizeof key ) ; OPENSSL_cleanse ( iv , sizeof iv ) ; return Qnil ; } "," iv ) ; rb_ivar_set ( self , id_key_set , Qtrue ) ; ",ruby@openssl/8108e0a6db133f3375608303fdd2083eb5115062,CVE-2016-7798,https://github.com/ruby/openssl/commit/8108e0a6db133f3375608303fdd2083eb5115062,2017-01-30T22:59Z 1207,CWE-617,"CWE-617 krb5_error_code kdc_process_s4u2proxy_req ( kdc_realm_t * kdc_active_realm , krb5_kdc_req * request , const krb5_enc_tkt_part * t2enc , const krb5_db_entry * server , krb5_const_principal server_princ , krb5_const_principal proxy_princ , const char * * status ) { krb5_error_code errcode ; if ( request -> kdc_options & ( NON_TGT_OPTION | KDC_OPT_ENC_TKT_IN_SKEY ) ) { return KRB5KDC_ERR_BADOPTION ; } if ( ! krb5_principal_compare ( kdc_context , server -> princ , server_princ ) ) { return KRB5KDC_ERR_SERVER_NOMATCH ; } if ( ! isflagset ( t2enc -> flags , TKT_FLG_FORWARDABLE ) ) { * status = ""EVIDENCE_TKT_NOT_FORWARDABLE"" ; return KRB5_TKT_NOT_FORWARDABLE ; } errcode = check_allowed_to_delegate_to ( kdc_context , t2enc -> client , server , proxy_princ ) ; if ( errcode ) { * status = ""NOT_ALLOWED_TO_DELEGATE"" ; return errcode ; } return 0 ; } "," ) ) { * status = ""INVALID_S4U2PROXY_OPTIONS"" ; ) ) { * status = ""EVIDENCE_TICKET_MISMATCH"" ; ",krb5@krb5/ffb35baac6981f9e8914f8f3bffd37f284b85970,CVE-2017-11368,https://github.com/krb5/krb5/commit/ffb35baac6981f9e8914f8f3bffd37f284b85970,2017-08-09T18:29Z 1208,CWE-264,"CWE-264 int copy_thread ( unsigned long clone_flags , unsigned long stack_start , unsigned long stk_sz , struct task_struct * p ) { struct thread_info * thread = task_thread_info ( p ) ; struct pt_regs * childregs = task_pt_regs ( p ) ; memset ( & thread -> cpu_context , 0 , sizeof ( struct cpu_context_save ) ) ; if ( likely ( ! ( p -> flags & PF_KTHREAD ) ) ) { * childregs = * current_pt_regs ( ) ; childregs -> ARM_r0 = 0 ; if ( stack_start ) childregs -> ARM_sp = stack_start ; } else { memset ( childregs , 0 , sizeof ( struct pt_regs ) ) ; thread -> cpu_context . r4 = stk_sz ; thread -> cpu_context . r5 = stack_start ; childregs -> ARM_cpsr = SVC_MODE ; } thread -> cpu_context . pc = ( unsigned long ) ret_from_fork ; thread -> cpu_context . sp = ( unsigned long ) childregs ; clear_ptrace_hw_breakpoint ( p ) ; if ( clone_flags & CLONE_SETTLS ) thread -> tp_value = childregs -> ARM_r3 ; thread_notify ( THREAD_NOTIFY_COPY , thread ) ; return 0 ; } "," thread -> tp_value [ 0 ] childregs -> ARM_r3 ; thread -> tp_value [ 1 ] = get_tpuser ( ) ",torvalds@linux/a4780adeefd042482f624f5e0d577bf9cdcbb760,CVE-2014-9870,https://github.com/torvalds/linux/commit/a4780adeefd042482f624f5e0d577bf9cdcbb760,2016-08-06T10:59Z 1209,CWE-190,"CWE-190 jas_stream_t * jas_stream_memopen ( char * buf , int bufsize ) { jas_stream_t * stream ; jas_stream_memobj_t * obj ; JAS_DBGLOG ( 100 , ( ""jas_stream_memopen(%p,%d)\\n"" , buf , bufsize ) ) ; if ( ! ( stream = jas_stream_create ( ) ) ) { return 0 ; } stream -> openmode_ = JAS_STREAM_READ | JAS_STREAM_WRITE | JAS_STREAM_BINARY ; jas_stream_initbuf ( stream , JAS_STREAM_FULLBUF , 0 , 0 ) ; stream -> ops_ = & jas_stream_memops ; if ( ! ( obj = jas_malloc ( sizeof ( jas_stream_memobj_t ) ) ) ) { jas_stream_destroy ( stream ) ; return 0 ; } stream -> obj_ = ( void * ) obj ; obj -> myalloc_ = 0 ; obj -> buf_ = 0 ; if ( bufsize <= 0 ) { obj -> bufsize_ = 1024 ; obj -> growable_ = 1 ; } else { obj -> bufsize_ = bufsize ; obj -> growable_ = 0 ; } if ( buf ) { obj -> buf_ = ( unsigned char * ) buf ; } else { obj -> buf_ = jas_malloc ( obj -> bufsize_ ) ; obj -> myalloc_ = 1 ; } if ( ! obj -> buf_ ) { jas_stream_close ( stream ) ; return 0 ; } JAS_DBGLOG ( 100 , ( ""jas_stream_memopenbufferbuf=%pmyalloc=%d\\n"" , obj -> buf_ , obj -> myalloc_ ) ) ; if ( bufsize > 0 && buf ) { obj -> len_ = bufsize ; } else { obj -> len_ = 0 ; } obj -> pos_ = 0 ; return stream ; } "," bufsize ) { char * new_buf ; size_t new_bufsize ; JAS_DBGLOG ( ; if ( bufsize < 0 ) { jas_deprecated ( ""negativebuffersizeforjas_stream_memopen"" ) ; } if ( buf && bufsize <= 0 ) { jas_eprintf ( ""Invaliduseofjas_stream_memopendetected.\\n"" ) ; jas_deprecated ( ""Auser-providedbufferfor"" ""jas_stream_memopencannotbegrowable.\\n"" ) ; } if ( bufsize 0 ) { new_bufsize = 0 ; new_buf = 0 ; } else } else { new_bufsize = bufsize ; = bufsize ; new_buf = buf ; } return jas_stream_memopen2 ( new_buf , new_bufsize ) ; } ",mdadams@jasper/634ce8e8a5accc0fa05dd2c20d42b4749d4b2735,CVE-2016-9262,https://github.com/mdadams/jasper/commit/634ce8e8a5accc0fa05dd2c20d42b4749d4b2735,2017-03-23T18:59Z 1210,CWE-200,"CWE-200 static int userauth_pubkey ( struct ssh * ssh ) { Authctxt * authctxt = ssh -> authctxt ; struct passwd * pw = authctxt -> pw ; struct sshbuf * b ; struct sshkey * key = NULL ; char * pkalg , * userstyle = NULL , * key_s = NULL , * ca_s = NULL ; u_char * pkblob , * sig , have_sig ; size_t blen , slen ; int r , pktype ; int authenticated = 0 ; struct sshauthopt * authopts = NULL ; if ( ! authctxt -> valid ) { debug2 ( ""%s:disabledbecauseofinvaliduser"" , __func__ ) ; return 0 ; } if ( ( r = sshpkt_get_u8 ( ssh , & have_sig ) ) != 0 || ( r = sshpkt_get_cstring ( ssh , & pkalg , NULL ) ) != 0 || ( r = sshpkt_get_string ( ssh , & pkblob , & blen ) ) != 0 ) fatal ( ""%s:parserequestfailed:%s"" , __func__ , ssh_err ( r ) ) ; pktype = sshkey_type_from_name ( pkalg ) ; if ( pktype == KEY_UNSPEC ) { verbose ( ""%s:unsupportedpublickeyalgorithm:%s"" , __func__ , pkalg ) ; goto done ; } if ( ( r = sshkey_from_blob ( pkblob , blen , & key ) ) != 0 ) { error ( ""%s:couldnotparsekey:%s"" , __func__ , ssh_err ( r ) ) ; goto done ; } if ( key == NULL ) { error ( ""%s:cannotdecodekey:%s"" , __func__ , pkalg ) ; goto done ; } if ( key -> type != pktype ) { error ( ""%s:typemismatchfordecodedkey"" ""(received%d,expected%d)"" , __func__ , key -> type , pktype ) ; goto done ; } if ( sshkey_type_plain ( key -> type ) == KEY_RSA && ( ssh -> compat & SSH_BUG_RSASIGMD5 ) != 0 ) { logit ( ""RefusingRSAkeybecauseclientusesunsafe"" ""signaturescheme"" ) ; goto done ; } if ( auth2_key_already_used ( authctxt , key ) ) { logit ( ""refusingpreviously-used%skey"" , sshkey_type ( key ) ) ; goto done ; } if ( match_pattern_list ( pkalg , options . pubkey_key_types , 0 ) != 1 ) { logit ( ""%s:keytype%snotinPubkeyAcceptedKeyTypes"" , __func__ , sshkey_ssh_name ( key ) ) ; goto done ; } key_s = format_key ( key ) ; if ( sshkey_is_cert ( key ) ) ca_s = format_key ( key -> cert -> signature_key ) ; if ( have_sig ) { debug3 ( ""%s:have%ssignaturefor%s%s%s"" , __func__ , pkalg , key_s , ca_s == NULL ? """" : ""CA"" , ca_s == NULL ? """" : ca_s ) ; if ( ( r = sshpkt_get_string ( ssh , & sig , & slen ) ) != 0 || ( r = sshpkt_get_end ( ssh ) ) != 0 ) fatal ( ""%s:%s"" , __func__ , ssh_err ( r ) ) ; if ( ( b = sshbuf_new ( ) ) == NULL ) fatal ( ""%s:sshbuf_newfailed"" , __func__ ) ; if ( ssh -> compat & SSH_OLD_SESSIONID ) { if ( ( r = sshbuf_put ( b , session_id2 , session_id2_len ) ) != 0 ) fatal ( ""%s:sshbuf_putsessionid:%s"" , __func__ , ssh_err ( r ) ) ; } else { if ( ( r = sshbuf_put_string ( b , session_id2 , session_id2_len ) ) != 0 ) fatal ( ""%s:sshbuf_put_stringsessionid:%s"" , __func__ , ssh_err ( r ) ) ; } xasprintf ( & userstyle , ""%s%s%s"" , authctxt -> user , authctxt -> style ? "":"" : """" , authctxt -> style ? authctxt -> style : """" ) ; if ( ( r = sshbuf_put_u8 ( b , SSH2_MSG_USERAUTH_REQUEST ) ) != 0 || ( r = sshbuf_put_cstring ( b , userstyle ) ) != 0 || ( r = sshbuf_put_cstring ( b , authctxt -> service ) ) != 0 || ( r = sshbuf_put_cstring ( b , ""publickey"" ) ) != 0 || ( r = sshbuf_put_u8 ( b , have_sig ) ) != 0 || ( r = sshbuf_put_cstring ( b , pkalg ) != 0 ) || ( r = sshbuf_put_string ( b , pkblob , blen ) ) != 0 ) fatal ( ""%s:buildpacketfailed:%s"" , __func__ , ssh_err ( r ) ) ; # ifdef DEBUG_PK sshbuf_dump ( b , stderr ) ; # endif authenticated = 0 ; if ( PRIVSEP ( user_key_allowed ( ssh , pw , key , 1 , & authopts ) ) && PRIVSEP ( sshkey_verify ( key , sig , slen , sshbuf_ptr ( b ) , sshbuf_len ( b ) , ( ssh -> compat & SSH_BUG_SIGTYPE ) == 0 ? pkalg : NULL , ssh -> compat ) ) == 0 ) { authenticated = 1 ; } sshbuf_free ( b ) ; free ( sig ) ; auth2_record_key ( authctxt , authenticated , key ) ; } else { debug ( ""%s:testpkalg%spkblob%s%s%s"" , __func__ , pkalg , key_s , ca_s == NULL ? """" : ""CA"" , ca_s == NULL ? """" : ca_s ) ; if ( ( r = sshpkt_get_end ( ssh ) ) != 0 ) fatal ( ""%s:%s"" , __func__ , ssh_err ( r ) ) ; if ( PRIVSEP ( user_key_allowed ( ssh , pw , key , 0 , NULL ) ) ) { if ( ( r = sshpkt_start ( ssh , SSH2_MSG_USERAUTH_PK_OK ) ) != 0 || ( r = sshpkt_put_cstring ( ssh , pkalg ) ) != 0 || ( r = sshpkt_put_string ( ssh , pkblob , blen ) ) != 0 || ( r = sshpkt_send ( ssh ) ) != 0 || ( r = ssh_packet_write_wait ( ssh ) ) != 0 ) fatal ( ""%s:%s"" , __func__ , ssh_err ( r ) ) ; authctxt -> postponed = 1 ; } } done : if ( authenticated == 1 && auth_activate_options ( ssh , authopts ) != 0 ) { debug ( ""%s:keyoptionsinconsistentwithexisting"" , __func__ ) ; authenticated = 0 ; } debug2 ( ""%s:authenticated%dpkalg%s"" , __func__ , authenticated , pkalg ) ; sshauthopt_free ( authopts ) ; sshkey_free ( key ) ; free ( userstyle ) ; free ( pkalg ) ; free ( pkblob ) ; free ( key_s ) ; free ( ca_s ) ; return authenticated ; } "," sshbuf * b = NULL char * pkalg = NULL u_char * pkblob = NULL , * sig = NULL ; if ( ( r = r ) ) ; } if ( ! authctxt -> valid || authctxt -> user == NULL ) { debug2 ( ""%s:disabledbecauseofinvaliduser"" , __func__ ) ; goto done b ) ; auth2_record_key ( authctxt ) ) ; if ( ! authctxt -> valid || authctxt -> user == NULL ) { debug2 ( ""%s:disabledbecauseofinvaliduser"" , __func__ ) ; goto done ; } ca_s ) ; free ( sig ) ; ",openbsd@src/779974d35b4859c07bc3cb8a12c74b43b0a7d1e0,CVE-2018-15473,https://github.com/openbsd/src/commit/779974d35b4859c07bc3cb8a12c74b43b0a7d1e0,2018-08-17T19:29Z 1211,CWE-908,"CWE-908 int ParseWave64HeaderConfig ( FILE * infile , char * infilename , char * fourcc , WavpackContext * wpc , WavpackConfig * config ) { int64_t total_samples = 0 , infilesize ; Wave64ChunkHeader chunk_header ; Wave64FileHeader filehdr ; WaveHeader WaveHeader ; int format_chunk = 0 ; uint32_t bcount ; infilesize = DoGetFileSize ( infile ) ; memcpy ( & filehdr , fourcc , 4 ) ; if ( ! DoReadFile ( infile , ( ( char * ) & filehdr ) + 4 , sizeof ( Wave64FileHeader ) - 4 , & bcount ) || bcount != sizeof ( Wave64FileHeader ) - 4 || memcmp ( filehdr . ckID , riff_guid , sizeof ( riff_guid ) ) || memcmp ( filehdr . formType , wave_guid , sizeof ( wave_guid ) ) ) { error_line ( ""%sisnotavalid.W64file!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & filehdr , sizeof ( filehdr ) ) ) { error_line ( ""%s"" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } # if 1 WavpackLittleEndianToNative ( & filehdr , Wave64ChunkHeaderFormat ) ; if ( infilesize && ! ( config -> qmode & QMODE_IGNORE_LENGTH ) && filehdr . ckSize && filehdr . ckSize + 1 && filehdr . ckSize != infilesize ) { error_line ( ""%sisnotavalid.W64file!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } # endif while ( 1 ) { if ( ! DoReadFile ( infile , & chunk_header , sizeof ( Wave64ChunkHeader ) , & bcount ) || bcount != sizeof ( Wave64ChunkHeader ) ) { error_line ( ""%sisnotavalid.W64file!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & chunk_header , sizeof ( Wave64ChunkHeader ) ) ) { error_line ( ""%s"" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } WavpackLittleEndianToNative ( & chunk_header , Wave64ChunkHeaderFormat ) ; chunk_header . ckSize -= sizeof ( chunk_header ) ; if ( ! memcmp ( chunk_header . ckID , fmt_guid , sizeof ( fmt_guid ) ) ) { int supported = TRUE , format ; if ( format_chunk ++ ) { error_line ( ""%sisnotavalid.W64file!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } chunk_header . ckSize = ( chunk_header . ckSize + 7 ) & ~ 7L ; if ( chunk_header . ckSize < 16 || chunk_header . ckSize > sizeof ( WaveHeader ) || ! DoReadFile ( infile , & WaveHeader , ( uint32_t ) chunk_header . ckSize , & bcount ) || bcount != chunk_header . ckSize ) { error_line ( ""%sisnotavalid.W64file!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & WaveHeader , ( uint32_t ) chunk_header . ckSize ) ) { error_line ( ""%s"" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } WavpackLittleEndianToNative ( & WaveHeader , WaveHeaderFormat ) ; if ( debug_logging_mode ) { error_line ( ""formattagsize=%d"" , chunk_header . ckSize ) ; error_line ( ""FormatTag=%x,NumChannels=%d,BitsPerSample=%d"" , WaveHeader . FormatTag , WaveHeader . NumChannels , WaveHeader . BitsPerSample ) ; error_line ( ""BlockAlign=%d,SampleRate=%d,BytesPerSecond=%d"" , WaveHeader . BlockAlign , WaveHeader . SampleRate , WaveHeader . BytesPerSecond ) ; if ( chunk_header . ckSize > 16 ) error_line ( ""cbSize=%d,ValidBitsPerSample=%d"" , WaveHeader . cbSize , WaveHeader . ValidBitsPerSample ) ; if ( chunk_header . ckSize > 20 ) error_line ( ""ChannelMask=%x,SubFormat=%d"" , WaveHeader . ChannelMask , WaveHeader . SubFormat ) ; } if ( chunk_header . ckSize > 16 && WaveHeader . cbSize == 2 ) config -> qmode |= QMODE_ADOBE_MODE ; format = ( WaveHeader . FormatTag == 0xfffe && chunk_header . ckSize == 40 ) ? WaveHeader . SubFormat : WaveHeader . FormatTag ; config -> bits_per_sample = ( chunk_header . ckSize == 40 && WaveHeader . ValidBitsPerSample ) ? WaveHeader . ValidBitsPerSample : WaveHeader . BitsPerSample ; if ( format != 1 && format != 3 ) supported = FALSE ; if ( format == 3 && config -> bits_per_sample != 32 ) supported = FALSE ; if ( ! WaveHeader . NumChannels || WaveHeader . NumChannels > 256 || WaveHeader . BlockAlign / WaveHeader . NumChannels < ( config -> bits_per_sample + 7 ) / 8 || WaveHeader . BlockAlign / WaveHeader . NumChannels > 4 || WaveHeader . BlockAlign % WaveHeader . NumChannels ) supported = FALSE ; if ( config -> bits_per_sample < 1 || config -> bits_per_sample > 32 ) supported = FALSE ; if ( ! supported ) { error_line ( ""%sisanunsupported.W64format!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } if ( chunk_header . ckSize < 40 ) { if ( ! config -> channel_mask && ! ( config -> qmode & QMODE_CHANS_UNASSIGNED ) ) { if ( WaveHeader . NumChannels <= 2 ) config -> channel_mask = 0x5 - WaveHeader . NumChannels ; else if ( WaveHeader . NumChannels <= 18 ) config -> channel_mask = ( 1 << WaveHeader . NumChannels ) - 1 ; else config -> channel_mask = 0x3ffff ; } } else if ( WaveHeader . ChannelMask && ( config -> channel_mask || ( config -> qmode & QMODE_CHANS_UNASSIGNED ) ) ) { error_line ( ""thisW64filealreadyhaschannelorderinformation!"" ) ; return WAVPACK_SOFT_ERROR ; } else if ( WaveHeader . ChannelMask ) config -> channel_mask = WaveHeader . ChannelMask ; if ( format == 3 ) config -> float_norm_exp = 127 ; else if ( ( config -> qmode & QMODE_ADOBE_MODE ) && WaveHeader . BlockAlign / WaveHeader . NumChannels == 4 ) { if ( WaveHeader . BitsPerSample == 24 ) config -> float_norm_exp = 127 + 23 ; else if ( WaveHeader . BitsPerSample == 32 ) config -> float_norm_exp = 127 + 15 ; } if ( debug_logging_mode ) { if ( config -> float_norm_exp == 127 ) error_line ( ""dataformat:normalized32-bitfloatingpoint"" ) ; else error_line ( ""dataformat:%d-bitintegersstoredin%dbyte(s)"" , config -> bits_per_sample , WaveHeader . BlockAlign / WaveHeader . NumChannels ) ; } } else if ( ! memcmp ( chunk_header . ckID , data_guid , sizeof ( data_guid ) ) ) { if ( ! WaveHeader . NumChannels ) { error_line ( ""%sisnotavalid.W64file!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } if ( ( config -> qmode & QMODE_IGNORE_LENGTH ) || chunk_header . ckSize <= 0 ) { config -> qmode |= QMODE_IGNORE_LENGTH ; if ( infilesize && DoGetFilePosition ( infile ) != - 1 ) total_samples = ( infilesize - DoGetFilePosition ( infile ) ) / WaveHeader . BlockAlign ; else total_samples = - 1 ; } else { if ( infilesize && infilesize - chunk_header . ckSize > 16777216 ) { error_line ( ""this.W64filehasover16MBofextraRIFFdata,probablyiscorrupt!"" ) ; return WAVPACK_SOFT_ERROR ; } total_samples = chunk_header . ckSize / WaveHeader . BlockAlign ; if ( ! total_samples ) { error_line ( ""this.W64filehasnoaudiosamples,probablyiscorrupt!"" ) ; return WAVPACK_SOFT_ERROR ; } if ( total_samples > MAX_WAVPACK_SAMPLES ) { error_line ( ""%shastoomanysamplesforWavPack!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } } config -> bytes_per_sample = WaveHeader . BlockAlign / WaveHeader . NumChannels ; config -> num_channels = WaveHeader . NumChannels ; config -> sample_rate = WaveHeader . SampleRate ; break ; } else { int bytes_to_copy = ( chunk_header . ckSize + 7 ) & ~ 7L ; char * buff ; if ( bytes_to_copy < 0 || bytes_to_copy > 4194304 ) { error_line ( ""%sisnotavalid.W64file!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } buff = malloc ( bytes_to_copy ) ; if ( debug_logging_mode ) error_line ( ""extraunknownchunk\\""%c%c%c%c\\""of%dbytes"" , chunk_header . ckID [ 0 ] , chunk_header . ckID [ 1 ] , chunk_header . ckID [ 2 ] , chunk_header . ckID [ 3 ] , chunk_header . ckSize ) ; if ( ! DoReadFile ( infile , buff , bytes_to_copy , & bcount ) || bcount != bytes_to_copy || ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , buff , bytes_to_copy ) ) ) { error_line ( ""%s"" , WavpackGetErrorMessage ( wpc ) ) ; free ( buff ) ; return WAVPACK_SOFT_ERROR ; } free ( buff ) ; } } if ( ! WavpackSetConfiguration64 ( wpc , config , total_samples , NULL ) ) { error_line ( ""%s:%s"" , infilename , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } return WAVPACK_NO_ERROR ; } "," ; uint32_t bcount ; CLEAR ( WaveHeader ) ",dbry@WavPack/33a0025d1d63ccd05d9dbaa6923d52b1446a62fe,CVE-2019-1010319,https://github.com/dbry/WavPack/commit/33a0025d1d63ccd05d9dbaa6923d52b1446a62fe,2019-07-11T20:15Z 1212,CWE-362,"CWE-362 static ssize_t ocfs2_direct_IO ( struct kiocb * iocb , struct iov_iter * iter ) { struct file * file = iocb -> ki_filp ; struct inode * inode = file -> f_mapping -> host ; struct ocfs2_super * osb = OCFS2_SB ( inode -> i_sb ) ; get_block_t * get_block ; if ( OCFS2_I ( inode ) -> ip_dyn_features & OCFS2_INLINE_DATA_FL ) return 0 ; if ( iocb -> ki_pos + iter -> count > i_size_read ( inode ) && ! ocfs2_supports_append_dio ( osb ) ) return 0 ; if ( iov_iter_rw ( iter ) == READ ) get_block = ocfs2_get_block ; else get_block = ocfs2_dio_get_block ; return __blockdev_direct_IO ( iocb , inode , inode -> i_sb -> s_bdev , iter , get_block , ocfs2_dio_end_io , NULL , 0 ) ; } "," ) get_block = ocfs2_lock_get_block ; else get_block else get_block = ocfs2_dio_wr_get_block ; return __blockdev_direct_IO ",torvalds@linux/3e4c56d41eef5595035872a2ec5a483f42e8917f,CVE-2017-18224,https://github.com/torvalds/linux/commit/3e4c56d41eef5595035872a2ec5a483f42e8917f,2018-03-12T03:29Z 1213,CWE-287,"CWE-287 static void _sx_sasl_client_process ( sx_t s , sx_plugin_t p , Gsasl_session * sd , const char * mech , const char * in , int inlen ) { _sx_sasl_t ctx = ( _sx_sasl_t ) p -> private ; _sx_sasl_sess_t sctx = NULL ; char * buf = NULL , * out = NULL , * realm = NULL , * * ext_id ; char hostname [ 256 ] ; int ret ; # ifdef HAVE_SSL int i ; # endif size_t buflen , outlen ; assert ( ctx ) ; assert ( ctx -> cb ) ; if ( mech != NULL ) { _sx_debug ( ZONE , ""authrequestfromclient(mechanism=%s)"" , mech ) ; if ( ! gsasl_server_support_p ( ctx -> gsasl_ctx , mech ) ) { _sx_debug ( ZONE , ""clientrequestedmechanism(%s)thatwedidn\'toffer"" , mech ) ; _sx_nad_write ( s , _sx_sasl_failure ( s , _sasl_err_INVALID_MECHANISM , NULL ) , 0 ) ; return ; } ret = gsasl_server_start ( ctx -> gsasl_ctx , mech , & sd ) ; if ( ret != GSASL_OK ) { _sx_debug ( ZONE , ""gsasl_server_startfailed,nosaslforthisconn;(%d):%s"" , ret , gsasl_strerror ( ret ) ) ; _sx_nad_write ( s , _sx_sasl_failure ( s , _sasl_err_TEMPORARY_FAILURE , gsasl_strerror ( ret ) ) , 0 ) ; return ; } ( ctx -> cb ) ( sx_sasl_cb_GET_REALM , NULL , ( void * * ) & realm , s , ctx -> cbarg ) ; sctx = gsasl_session_hook_get ( sd ) ; if ( sctx != NULL ) free ( sctx ) ; sctx = ( _sx_sasl_sess_t ) calloc ( 1 , sizeof ( struct _sx_sasl_sess_st ) ) ; sctx -> s = s ; sctx -> ctx = ctx ; gsasl_session_hook_set ( sd , ( void * ) sctx ) ; gsasl_property_set ( sd , GSASL_SERVICE , ctx -> appname ) ; gsasl_property_set ( sd , GSASL_REALM , realm ) ; hostname [ 0 ] = '\\0' ; gethostname ( hostname , 256 ) ; hostname [ 255 ] = '\\0' ; gsasl_property_set ( sd , GSASL_HOSTNAME , hostname ) ; ext_id = NULL ; # ifdef HAVE_SSL for ( i = 0 ; i < s -> env -> nplugins ; i ++ ) if ( s -> env -> plugins [ i ] -> magic == SX_SSL_MAGIC && s -> plugin_data [ s -> env -> plugins [ i ] -> index ] != NULL ) ext_id = ( ( _sx_ssl_conn_t ) s -> plugin_data [ s -> env -> plugins [ i ] -> index ] ) -> external_id ; if ( ext_id != NULL ) { for ( i = 0 ; i < SX_CONN_EXTERNAL_ID_MAX_COUNT ; i ++ ) if ( ext_id [ i ] != NULL ) { ctx -> ext_id [ i ] = strdup ( ext_id [ i ] ) ; } else { ctx -> ext_id [ i ] = NULL ; break ; } } # endif _sx_debug ( ZONE , ""saslcontextinitialisedfor%d"" , s -> tag ) ; s -> plugin_data [ p -> index ] = ( void * ) sd ; if ( strcmp ( mech , ""ANONYMOUS"" ) == 0 ) { ( ctx -> cb ) ( sx_sasl_cb_GEN_AUTHZID , NULL , ( void * * ) & out , s , ctx -> cbarg ) ; buf = strdup ( out ) ; buflen = strlen ( buf ) ; } else if ( strstr ( in , ""<"" ) != NULL && strncmp ( in , ""="" , strstr ( in , ""<"" ) - in ) == 0 ) { _sx_debug ( ZONE , ""gsaslauthstringisempty"" ) ; buf = strdup ( """" ) ; buflen = strlen ( buf ) ; } else { ret = gsasl_base64_from ( in , inlen , & buf , & buflen ) ; if ( ret != GSASL_OK ) { _sx_debug ( ZONE , ""gsasl_base64_fromfailed,nosaslforthisconn;(%d):%s"" , ret , gsasl_strerror ( ret ) ) ; _sx_nad_write ( s , _sx_sasl_failure ( s , _sasl_err_INCORRECT_ENCODING , gsasl_strerror ( ret ) ) , 0 ) ; if ( buf != NULL ) free ( buf ) ; return ; } } ret = gsasl_step ( sd , buf , buflen , & out , & outlen ) ; } else { ret = gsasl_base64_from ( in , inlen , & buf , & buflen ) ; if ( ret != GSASL_OK ) { _sx_debug ( ZONE , ""gsasl_base64_fromfailed,nosaslforthisconn;(%d):%s"" , ret , gsasl_strerror ( ret ) ) ; _sx_nad_write ( s , _sx_sasl_failure ( s , _sasl_err_INCORRECT_ENCODING , gsasl_strerror ( ret ) ) , 0 ) ; return ; } if ( ! sd ) { _sx_debug ( ZONE , ""responsesendbeforeauthrequestenablingmechanism(decoded:%.*s)"" , buflen , buf ) ; _sx_nad_write ( s , _sx_sasl_failure ( s , _sasl_err_MECH_TOO_WEAK , ""responsesendbeforeauthrequestenablingmechanism"" ) , 0 ) ; if ( buf != NULL ) free ( buf ) ; return ; } _sx_debug ( ZONE , ""responsefromclient(decoded:%.*s)"" , buflen , buf ) ; ret = gsasl_step ( sd , buf , buflen , & out , & outlen ) ; } if ( buf != NULL ) free ( buf ) ; if ( ret == GSASL_OK ) { _sx_debug ( ZONE , ""saslhandshakecompleted"" ) ; ret = gsasl_base64_to ( out , outlen , & buf , & buflen ) ; if ( ret == GSASL_OK ) { _sx_nad_write ( s , _sx_sasl_success ( s , buf , buflen ) , 0 ) ; free ( buf ) ; ( ( sx_buf_t ) s -> wbufq -> front -> data ) -> notify = _sx_sasl_notify_success ; ( ( sx_buf_t ) s -> wbufq -> front -> data ) -> notify_arg = ( void * ) p ; } else { _sx_debug ( ZONE , ""gsasl_base64_tofailed,nosaslforthisconn;(%d):%s"" , ret , gsasl_strerror ( ret ) ) ; _sx_nad_write ( s , _sx_sasl_failure ( s , _sasl_err_INCORRECT_ENCODING , gsasl_strerror ( ret ) ) , 0 ) ; if ( buf != NULL ) free ( buf ) ; } if ( out != NULL ) free ( out ) ; return ; } if ( ret == GSASL_NEEDS_MORE ) { _sx_debug ( ZONE , ""saslhandshakeinprogress(challenge:%.*s)"" , outlen , out ) ; ret = gsasl_base64_to ( out , outlen , & buf , & buflen ) ; if ( ret == GSASL_OK ) { _sx_nad_write ( s , _sx_sasl_challenge ( s , buf , buflen ) , 0 ) ; free ( buf ) ; } else { _sx_debug ( ZONE , ""gsasl_base64_tofailed,nosaslforthisconn;(%d):%s"" , ret , gsasl_strerror ( ret ) ) ; _sx_nad_write ( s , _sx_sasl_failure ( s , _sasl_err_INCORRECT_ENCODING , gsasl_strerror ( ret ) ) , 0 ) ; if ( buf != NULL ) free ( buf ) ; } if ( out != NULL ) free ( out ) ; return ; } if ( out != NULL ) free ( out ) ; _sx_debug ( ZONE , ""saslhandshakefailed;(%d):%s"" , ret , gsasl_strerror ( ret ) ) ; switch ( ret ) { case GSASL_AUTHENTICATION_ERROR : case GSASL_NO_ANONYMOUS_TOKEN : case GSASL_NO_AUTHID : case GSASL_NO_AUTHZID : case GSASL_NO_PASSWORD : case GSASL_NO_PASSCODE : case GSASL_NO_PIN : case GSASL_NO_SERVICE : case GSASL_NO_HOSTNAME : out = _sasl_err_NOT_AUTHORIZED ; break ; case GSASL_UNKNOWN_MECHANISM : case GSASL_MECHANISM_PARSE_ERROR : out = _sasl_err_INVALID_MECHANISM ; break ; case GSASL_BASE64_ERROR : out = _sasl_err_INCORRECT_ENCODING ; break ; default : out = _sasl_err_MALFORMED_REQUEST ; } _sx_nad_write ( s , _sx_sasl_failure ( s , out , gsasl_strerror ( ret ) ) , 0 ) ; } "," , mech ) || ( ctx -> cb ) ( sx_sasl_cb_CHECK_MECH , ( void * ) mech , NULL , s , ctx -> cbarg ) != sx_sasl_ret_OK ",jabberd2@jabberd2/8416ae54ecefa670534f27a31db71d048b9c7f16,CVE-2017-10807,https://github.com/jabberd2/jabberd2/commit/8416ae54ecefa670534f27a31db71d048b9c7f16,2017-07-04T15:29Z 1214,CWE-119,"CWE-119 static int check_stack_boundary ( struct bpf_verifier_env * env , int regno , int access_size , bool zero_size_allowed , struct bpf_call_arg_meta * meta ) { struct bpf_verifier_state * state = env -> cur_state ; struct bpf_reg_state * regs = state -> regs ; int off , i , slot , spi ; if ( regs [ regno ] . type != PTR_TO_STACK ) { if ( zero_size_allowed && access_size == 0 && register_is_null ( regs [ regno ] ) ) return 0 ; verbose ( env , ""R%dtype=%sexpected=%s\\n"" , regno , reg_type_str [ regs [ regno ] . type ] , reg_type_str [ PTR_TO_STACK ] ) ; return - EACCES ; } if ( ! tnum_is_const ( regs [ regno ] . var_off ) ) { char tn_buf [ 48 ] ; tnum_strn ( tn_buf , sizeof ( tn_buf ) , regs [ regno ] . var_off ) ; verbose ( env , ""invalidvariablestackreadR%dvar_off=%s\\n"" , regno , tn_buf ) ; } off = regs [ regno ] . off + regs [ regno ] . var_off . value ; if ( off >= 0 || off < - MAX_BPF_STACK || off + access_size > 0 || access_size < 0 || ( access_size == 0 && ! zero_size_allowed ) ) { verbose ( env , ""invalidstacktypeR%doff=%daccess_size=%d\\n"" , regno , off , access_size ) ; return - EACCES ; } if ( env -> prog -> aux -> stack_depth < - off ) env -> prog -> aux -> stack_depth = - off ; if ( meta && meta -> raw_mode ) { meta -> access_size = access_size ; meta -> regno = regno ; return 0 ; } for ( i = 0 ; i < access_size ; i ++ ) { slot = - ( off + i ) - 1 ; spi = slot / BPF_REG_SIZE ; if ( state -> allocated_stack <= slot || state -> stack [ spi ] . slot_type [ slot % BPF_REG_SIZE ] != STACK_MISC ) { verbose ( env , ""invalidindirectreadfromstackoff%d+%dsize%d\\n"" , off , i , access_size ) ; return - EACCES ; } } return 0 ; } "," tn_buf ) ; return - EACCES ; ",torvalds@linux/ea25f914dc164c8d56b36147ecc86bc65f83c469,CVE-2017-17857,https://github.com/torvalds/linux/commit/ea25f914dc164c8d56b36147ecc86bc65f83c469,2017-12-27T17:08Z 1215,CWE-416,"CWE-416 static void exif_mnote_data_fuji_load ( ExifMnoteData * en , const unsigned char * buf , unsigned int buf_size ) { ExifMnoteDataFuji * n = ( ExifMnoteDataFuji * ) en ; ExifLong c ; size_t i , tcount , o , datao ; if ( ! n || ! buf || ! buf_size ) { exif_log ( en -> log , EXIF_LOG_CODE_CORRUPT_DATA , ""ExifMnoteDataFuji"" , ""ShortMakerNote"" ) ; return ; } datao = 6 + n -> offset ; if ( CHECKOVERFLOW ( datao , buf_size , 12 ) ) { exif_log ( en -> log , EXIF_LOG_CODE_CORRUPT_DATA , ""ExifMnoteDataFuji"" , ""ShortMakerNote"" ) ; return ; } n -> order = EXIF_BYTE_ORDER_INTEL ; datao += exif_get_long ( buf + datao + 8 , EXIF_BYTE_ORDER_INTEL ) ; if ( CHECKOVERFLOW ( datao , buf_size , 2 ) ) { exif_log ( en -> log , EXIF_LOG_CODE_CORRUPT_DATA , ""ExifMnoteDataFuji"" , ""ShortMakerNote"" ) ; return ; } c = exif_get_short ( buf + datao , EXIF_BYTE_ORDER_INTEL ) ; datao += 2 ; exif_mnote_data_fuji_clear ( n ) ; n -> entries = exif_mem_alloc ( en -> mem , sizeof ( MnoteFujiEntry ) * c ) ; if ( ! n -> entries ) { EXIF_LOG_NO_MEMORY ( en -> log , ""ExifMnoteDataFuji"" , sizeof ( MnoteFujiEntry ) * c ) ; return ; } tcount = 0 ; for ( i = c , o = datao ; i ; -- i , o += 12 ) { size_t s ; if ( CHECKOVERFLOW ( o , buf_size , 12 ) ) { exif_log ( en -> log , EXIF_LOG_CODE_CORRUPT_DATA , ""ExifMnoteDataFuji"" , ""ShortMakerNote"" ) ; break ; } n -> entries [ tcount ] . tag = exif_get_short ( buf + o , n -> order ) ; n -> entries [ tcount ] . format = exif_get_short ( buf + o + 2 , n -> order ) ; n -> entries [ tcount ] . components = exif_get_long ( buf + o + 4 , n -> order ) ; n -> entries [ tcount ] . order = n -> order ; exif_log ( en -> log , EXIF_LOG_CODE_DEBUG , ""ExifMnoteDataFuji"" , ""Loadingentry0x%x(\'%s\')..."" , n -> entries [ tcount ] . tag , mnote_fuji_tag_get_name ( n -> entries [ tcount ] . tag ) ) ; if ( exif_format_get_size ( n -> entries [ tcount ] . format ) && buf_size / exif_format_get_size ( n -> entries [ tcount ] . format ) < n -> entries [ tcount ] . components ) { exif_log ( en -> log , EXIF_LOG_CODE_CORRUPT_DATA , ""ExifMnoteDataFuji"" , ""Tagsizeoverflowdetected(%u*%lu)"" , exif_format_get_size ( n -> entries [ tcount ] . format ) , n -> entries [ tcount ] . components ) ; continue ; } s = exif_format_get_size ( n -> entries [ tcount ] . format ) * n -> entries [ tcount ] . components ; n -> entries [ tcount ] . size = s ; if ( s ) { size_t dataofs = o + 8 ; if ( s > 4 ) dataofs = exif_get_long ( buf + dataofs , n -> order ) + 6 + n -> offset ; if ( CHECKOVERFLOW ( dataofs , buf_size , s ) ) { exif_log ( en -> log , EXIF_LOG_CODE_CORRUPT_DATA , ""ExifMnoteDataFuji"" , ""Tagdatapastendof"" ""buffer(%u>=%u)"" , ( unsigned ) ( dataofs + s ) , buf_size ) ; continue ; } n -> entries [ tcount ] . data = exif_mem_alloc ( en -> mem , s ) ; if ( ! n -> entries [ tcount ] . data ) { EXIF_LOG_NO_MEMORY ( en -> log , ""ExifMnoteDataFuji"" , s ) ; continue ; } memcpy ( n -> entries [ tcount ] . data , buf + dataofs , s ) ; } ++ tcount ; } n -> count = tcount ; } "," size_t s ; memset ( & n -> entries [ tcount ] , 0 , sizeof ( MnoteFujiEntry ) ) ; ",libexif@libexif/ec412aa4583ad71ecabb967d3c77162760169d1f,CVE-2020-13113,https://github.com/libexif/libexif/commit/ec412aa4583ad71ecabb967d3c77162760169d1f,2020-05-21T17:15Z 1216,CWE-19,"CWE-19 static int ext2_fill_super ( struct super_block * sb , void * data , int silent ) { struct buffer_head * bh ; struct ext2_sb_info * sbi ; struct ext2_super_block * es ; struct inode * root ; unsigned long block ; unsigned long sb_block = get_sb_block ( & data ) ; unsigned long logic_sb_block ; unsigned long offset = 0 ; unsigned long def_mount_opts ; long ret = - EINVAL ; int blocksize = BLOCK_SIZE ; int db_count ; int i , j ; __le32 features ; int err ; err = - ENOMEM ; sbi = kzalloc ( sizeof ( * sbi ) , GFP_KERNEL ) ; if ( ! sbi ) goto failed ; sbi -> s_blockgroup_lock = kzalloc ( sizeof ( struct blockgroup_lock ) , GFP_KERNEL ) ; if ( ! sbi -> s_blockgroup_lock ) { kfree ( sbi ) ; goto failed ; } sb -> s_fs_info = sbi ; sbi -> s_sb_block = sb_block ; spin_lock_init ( & sbi -> s_lock ) ; blocksize = sb_min_blocksize ( sb , BLOCK_SIZE ) ; if ( ! blocksize ) { ext2_msg ( sb , KERN_ERR , ""error:unabletosetblocksize"" ) ; goto failed_sbi ; } if ( blocksize != BLOCK_SIZE ) { logic_sb_block = ( sb_block * BLOCK_SIZE ) / blocksize ; offset = ( sb_block * BLOCK_SIZE ) % blocksize ; } else { logic_sb_block = sb_block ; } if ( ! ( bh = sb_bread ( sb , logic_sb_block ) ) ) { ext2_msg ( sb , KERN_ERR , ""error:unabletoreadsuperblock"" ) ; goto failed_sbi ; } es = ( struct ext2_super_block * ) ( ( ( char * ) bh -> b_data ) + offset ) ; sbi -> s_es = es ; sb -> s_magic = le16_to_cpu ( es -> s_magic ) ; if ( sb -> s_magic != EXT2_SUPER_MAGIC ) goto cantfind_ext2 ; def_mount_opts = le32_to_cpu ( es -> s_default_mount_opts ) ; if ( def_mount_opts & EXT2_DEFM_DEBUG ) set_opt ( sbi -> s_mount_opt , DEBUG ) ; if ( def_mount_opts & EXT2_DEFM_BSDGROUPS ) set_opt ( sbi -> s_mount_opt , GRPID ) ; if ( def_mount_opts & EXT2_DEFM_UID16 ) set_opt ( sbi -> s_mount_opt , NO_UID32 ) ; # ifdef CONFIG_EXT2_FS_XATTR if ( def_mount_opts & EXT2_DEFM_XATTR_USER ) set_opt ( sbi -> s_mount_opt , XATTR_USER ) ; # endif # ifdef CONFIG_EXT2_FS_POSIX_ACL if ( def_mount_opts & EXT2_DEFM_ACL ) set_opt ( sbi -> s_mount_opt , POSIX_ACL ) ; # endif if ( le16_to_cpu ( sbi -> s_es -> s_errors ) == EXT2_ERRORS_PANIC ) set_opt ( sbi -> s_mount_opt , ERRORS_PANIC ) ; else if ( le16_to_cpu ( sbi -> s_es -> s_errors ) == EXT2_ERRORS_CONTINUE ) set_opt ( sbi -> s_mount_opt , ERRORS_CONT ) ; else set_opt ( sbi -> s_mount_opt , ERRORS_RO ) ; sbi -> s_resuid = make_kuid ( & init_user_ns , le16_to_cpu ( es -> s_def_resuid ) ) ; sbi -> s_resgid = make_kgid ( & init_user_ns , le16_to_cpu ( es -> s_def_resgid ) ) ; set_opt ( sbi -> s_mount_opt , RESERVATION ) ; if ( ! parse_options ( ( char * ) data , sb ) ) goto failed_mount ; sb -> s_flags = ( sb -> s_flags & ~ MS_POSIXACL ) | ( ( EXT2_SB ( sb ) -> s_mount_opt & EXT2_MOUNT_POSIX_ACL ) ? MS_POSIXACL : 0 ) ; sb -> s_iflags |= SB_I_CGROUPWB ; if ( le32_to_cpu ( es -> s_rev_level ) == EXT2_GOOD_OLD_REV && ( EXT2_HAS_COMPAT_FEATURE ( sb , ~ 0U ) || EXT2_HAS_RO_COMPAT_FEATURE ( sb , ~ 0U ) || EXT2_HAS_INCOMPAT_FEATURE ( sb , ~ 0U ) ) ) ext2_msg ( sb , KERN_WARNING , ""warning:featureflagssetonrev0fs,"" ""runninge2fsckisrecommended"" ) ; features = EXT2_HAS_INCOMPAT_FEATURE ( sb , ~ EXT2_FEATURE_INCOMPAT_SUPP ) ; if ( features ) { ext2_msg ( sb , KERN_ERR , ""error:couldn\'tmountbecauseof"" ""unsupportedoptionalfeatures(%x)"" , le32_to_cpu ( features ) ) ; goto failed_mount ; } if ( ! ( sb -> s_flags & MS_RDONLY ) && ( features = EXT2_HAS_RO_COMPAT_FEATURE ( sb , ~ EXT2_FEATURE_RO_COMPAT_SUPP ) ) ) { ext2_msg ( sb , KERN_ERR , ""error:couldn\'tmountRDWRbecauseof"" ""unsupportedoptionalfeatures(%x)"" , le32_to_cpu ( features ) ) ; goto failed_mount ; } blocksize = BLOCK_SIZE << le32_to_cpu ( sbi -> s_es -> s_log_block_size ) ; if ( sbi -> s_mount_opt & EXT2_MOUNT_DAX ) { if ( blocksize != PAGE_SIZE ) { ext2_msg ( sb , KERN_ERR , ""error:unsupportedblocksizefordax"" ) ; goto failed_mount ; } if ( ! sb -> s_bdev -> bd_disk -> fops -> direct_access ) { ext2_msg ( sb , KERN_ERR , ""error:devicedoesnotsupportdax"" ) ; goto failed_mount ; } } if ( sb -> s_blocksize != blocksize ) { brelse ( bh ) ; if ( ! sb_set_blocksize ( sb , blocksize ) ) { ext2_msg ( sb , KERN_ERR , ""error:badblocksize%d"" , blocksize ) ; goto failed_sbi ; } logic_sb_block = ( sb_block * BLOCK_SIZE ) / blocksize ; offset = ( sb_block * BLOCK_SIZE ) % blocksize ; bh = sb_bread ( sb , logic_sb_block ) ; if ( ! bh ) { ext2_msg ( sb , KERN_ERR , ""error:couldn\'tread"" ""superblockon2ndtry"" ) ; goto failed_sbi ; } es = ( struct ext2_super_block * ) ( ( ( char * ) bh -> b_data ) + offset ) ; sbi -> s_es = es ; if ( es -> s_magic != cpu_to_le16 ( EXT2_SUPER_MAGIC ) ) { ext2_msg ( sb , KERN_ERR , ""error:magicmismatch"" ) ; goto failed_mount ; } } sb -> s_maxbytes = ext2_max_size ( sb -> s_blocksize_bits ) ; sb -> s_max_links = EXT2_LINK_MAX ; if ( le32_to_cpu ( es -> s_rev_level ) == EXT2_GOOD_OLD_REV ) { sbi -> s_inode_size = EXT2_GOOD_OLD_INODE_SIZE ; sbi -> s_first_ino = EXT2_GOOD_OLD_FIRST_INO ; } else { sbi -> s_inode_size = le16_to_cpu ( es -> s_inode_size ) ; sbi -> s_first_ino = le32_to_cpu ( es -> s_first_ino ) ; if ( ( sbi -> s_inode_size < EXT2_GOOD_OLD_INODE_SIZE ) || ! is_power_of_2 ( sbi -> s_inode_size ) || ( sbi -> s_inode_size > blocksize ) ) { ext2_msg ( sb , KERN_ERR , ""error:unsupportedinodesize:%d"" , sbi -> s_inode_size ) ; goto failed_mount ; } } sbi -> s_frag_size = EXT2_MIN_FRAG_SIZE << le32_to_cpu ( es -> s_log_frag_size ) ; if ( sbi -> s_frag_size == 0 ) goto cantfind_ext2 ; sbi -> s_frags_per_block = sb -> s_blocksize / sbi -> s_frag_size ; sbi -> s_blocks_per_group = le32_to_cpu ( es -> s_blocks_per_group ) ; sbi -> s_frags_per_group = le32_to_cpu ( es -> s_frags_per_group ) ; sbi -> s_inodes_per_group = le32_to_cpu ( es -> s_inodes_per_group ) ; if ( EXT2_INODE_SIZE ( sb ) == 0 ) goto cantfind_ext2 ; sbi -> s_inodes_per_block = sb -> s_blocksize / EXT2_INODE_SIZE ( sb ) ; if ( sbi -> s_inodes_per_block == 0 || sbi -> s_inodes_per_group == 0 ) goto cantfind_ext2 ; sbi -> s_itb_per_group = sbi -> s_inodes_per_group / sbi -> s_inodes_per_block ; sbi -> s_desc_per_block = sb -> s_blocksize / sizeof ( struct ext2_group_desc ) ; sbi -> s_sbh = bh ; sbi -> s_mount_state = le16_to_cpu ( es -> s_state ) ; sbi -> s_addr_per_block_bits = ilog2 ( EXT2_ADDR_PER_BLOCK ( sb ) ) ; sbi -> s_desc_per_block_bits = ilog2 ( EXT2_DESC_PER_BLOCK ( sb ) ) ; if ( sb -> s_magic != EXT2_SUPER_MAGIC ) goto cantfind_ext2 ; if ( sb -> s_blocksize != bh -> b_size ) { if ( ! silent ) ext2_msg ( sb , KERN_ERR , ""error:unsupportedblocksize"" ) ; goto failed_mount ; } if ( sb -> s_blocksize != sbi -> s_frag_size ) { ext2_msg ( sb , KERN_ERR , ""error:fragsize%lu!=blocksize%lu"" ""(notsupportedyet)"" , sbi -> s_frag_size , sb -> s_blocksize ) ; goto failed_mount ; } if ( sbi -> s_blocks_per_group > sb -> s_blocksize * 8 ) { ext2_msg ( sb , KERN_ERR , ""error:#blockspergrouptoobig:%lu"" , sbi -> s_blocks_per_group ) ; goto failed_mount ; } if ( sbi -> s_frags_per_group > sb -> s_blocksize * 8 ) { ext2_msg ( sb , KERN_ERR , ""error:#fragmentspergrouptoobig:%lu"" , sbi -> s_frags_per_group ) ; goto failed_mount ; } if ( sbi -> s_inodes_per_group > sb -> s_blocksize * 8 ) { ext2_msg ( sb , KERN_ERR , ""error:#inodespergrouptoobig:%lu"" , sbi -> s_inodes_per_group ) ; goto failed_mount ; } if ( EXT2_BLOCKS_PER_GROUP ( sb ) == 0 ) goto cantfind_ext2 ; sbi -> s_groups_count = ( ( le32_to_cpu ( es -> s_blocks_count ) - le32_to_cpu ( es -> s_first_data_block ) - 1 ) / EXT2_BLOCKS_PER_GROUP ( sb ) ) + 1 ; db_count = ( sbi -> s_groups_count + EXT2_DESC_PER_BLOCK ( sb ) - 1 ) / EXT2_DESC_PER_BLOCK ( sb ) ; sbi -> s_group_desc = kmalloc ( db_count * sizeof ( struct buffer_head * ) , GFP_KERNEL ) ; if ( sbi -> s_group_desc == NULL ) { ext2_msg ( sb , KERN_ERR , ""error:notenoughmemory"" ) ; goto failed_mount ; } bgl_lock_init ( sbi -> s_blockgroup_lock ) ; sbi -> s_debts = kcalloc ( sbi -> s_groups_count , sizeof ( * sbi -> s_debts ) , GFP_KERNEL ) ; if ( ! sbi -> s_debts ) { ext2_msg ( sb , KERN_ERR , ""error:notenoughmemory"" ) ; goto failed_mount_group_desc ; } for ( i = 0 ; i < db_count ; i ++ ) { block = descriptor_loc ( sb , logic_sb_block , i ) ; sbi -> s_group_desc [ i ] = sb_bread ( sb , block ) ; if ( ! sbi -> s_group_desc [ i ] ) { for ( j = 0 ; j < i ; j ++ ) brelse ( sbi -> s_group_desc [ j ] ) ; ext2_msg ( sb , KERN_ERR , ""error:unabletoreadgroupdescriptors"" ) ; goto failed_mount_group_desc ; } } if ( ! ext2_check_descriptors ( sb ) ) { ext2_msg ( sb , KERN_ERR , ""groupdescriptorscorrupted"" ) ; goto failed_mount2 ; } sbi -> s_gdb_count = db_count ; get_random_bytes ( & sbi -> s_next_generation , sizeof ( u32 ) ) ; spin_lock_init ( & sbi -> s_next_gen_lock ) ; spin_lock_init ( & sbi -> s_rsv_window_lock ) ; sbi -> s_rsv_window_root = RB_ROOT ; sbi -> s_rsv_window_head . rsv_start = EXT2_RESERVE_WINDOW_NOT_ALLOCATED ; sbi -> s_rsv_window_head . rsv_end = EXT2_RESERVE_WINDOW_NOT_ALLOCATED ; sbi -> s_rsv_window_head . rsv_alloc_hit = 0 ; sbi -> s_rsv_window_head . rsv_goal_size = 0 ; ext2_rsv_window_add ( sb , & sbi -> s_rsv_window_head ) ; err = percpu_counter_init ( & sbi -> s_freeblocks_counter , ext2_count_free_blocks ( sb ) , GFP_KERNEL ) ; if ( ! err ) { err = percpu_counter_init ( & sbi -> s_freeinodes_counter , ext2_count_free_inodes ( sb ) , GFP_KERNEL ) ; } if ( ! err ) { err = percpu_counter_init ( & sbi -> s_dirs_counter , ext2_count_dirs ( sb ) , GFP_KERNEL ) ; } if ( err ) { ext2_msg ( sb , KERN_ERR , ""error:insufficientmemory"" ) ; goto failed_mount3 ; } sb -> s_op = & ext2_sops ; sb -> s_export_op = & ext2_export_ops ; sb -> s_xattr = ext2_xattr_handlers ; # ifdef CONFIG_QUOTA sb -> dq_op = & dquot_operations ; sb -> s_qcop = & dquot_quotactl_ops ; sb -> s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP ; # endif root = ext2_iget ( sb , EXT2_ROOT_INO ) ; if ( IS_ERR ( root ) ) { ret = PTR_ERR ( root ) ; goto failed_mount3 ; } if ( ! S_ISDIR ( root -> i_mode ) || ! root -> i_blocks || ! root -> i_size ) { iput ( root ) ; ext2_msg ( sb , KERN_ERR , ""error:corruptrootinode,rune2fsck"" ) ; goto failed_mount3 ; } sb -> s_root = d_make_root ( root ) ; if ( ! sb -> s_root ) { ext2_msg ( sb , KERN_ERR , ""error:getrootinodefailed"" ) ; ret = - ENOMEM ; goto failed_mount3 ; } if ( EXT2_HAS_COMPAT_FEATURE ( sb , EXT3_FEATURE_COMPAT_HAS_JOURNAL ) ) ext2_msg ( sb , KERN_WARNING , ""warning:mountingext3filesystemasext2"" ) ; if ( ext2_setup_super ( sb , es , sb -> s_flags & MS_RDONLY ) ) sb -> s_flags |= MS_RDONLY ; ext2_write_super ( sb ) ; return 0 ; cantfind_ext2 : if ( ! silent ) ext2_msg ( sb , KERN_ERR , ""error:can\'tfindanext2filesystemondev%s."" , sb -> s_id ) ; goto failed_mount ; failed_mount3 : percpu_counter_destroy ( & sbi -> s_freeblocks_counter ) ; percpu_counter_destroy ( & sbi -> s_freeinodes_counter ) ; percpu_counter_destroy ( & sbi -> s_dirs_counter ) ; failed_mount2 : for ( i = 0 ; i < db_count ; i ++ ) brelse ( sbi -> s_group_desc [ i ] ) ; failed_mount_group_desc : kfree ( sbi -> s_group_desc ) ; kfree ( sbi -> s_debts ) ; failed_mount : brelse ( bh ) ; failed_sbi : sb -> s_fs_info = NULL ; kfree ( sbi -> s_blockgroup_lock ) ; kfree ( sbi ) ; failed : return ret ; } "," failed_mount3 ; } # ifdef CONFIG_EXT2_FS_XATTR sbi -> s_mb_cache = ext2_xattr_create_cache ( ) ; if ( ! sbi -> s_mb_cache ) { ext2_msg ( sb , KERN_ERR , ""Failedtocreateanmb_cache"" ) ; goto failed_mount3 ; } # endif ; failed_mount3 : if ( sbi -> s_mb_cache ) ext2_xattr_destroy_cache ( sbi -> s_mb_cache ) ; ",torvalds@linux/be0726d33cb8f411945884664924bed3cb8c70ee,CVE-2015-8952,https://github.com/torvalds/linux/commit/be0726d33cb8f411945884664924bed3cb8c70ee,2016-10-16T21:59Z 1217,CWE-20,"CWE-20 static int remove_bond ( const bt_bdaddr_t * bd_addr ) { if ( interface_ready ( ) == FALSE ) return BT_STATUS_NOT_READY ; return btif_dm_remove_bond ( bd_addr ) ; } "," bd_addr ) { if ( is_restricted_mode ( ) && ! btif_storage_is_restricted_device ( bd_addr ) ) return BT_STATUS_SUCCESS ; ",system@bt/37c88107679d36c419572732b4af6e18bb2f7dce,CVE-2016-3760,https://android.googlesource.com/platform/system/bt/+/37c88107679d36c419572732b4af6e18bb2f7dce,2016-07-11T02:00Z 1218,CWE-416,"CWE-416 static int tcpmss_mangle_packet ( struct sk_buff * skb , const struct xt_action_param * par , unsigned int family , unsigned int tcphoff , unsigned int minlen ) { const struct xt_tcpmss_info * info = par -> targinfo ; struct tcphdr * tcph ; int len , tcp_hdrlen ; unsigned int i ; __be16 oldval ; u16 newmss ; u8 * opt ; if ( par -> fragoff != 0 ) return 0 ; if ( ! skb_make_writable ( skb , skb -> len ) ) return - 1 ; len = skb -> len - tcphoff ; if ( len < ( int ) sizeof ( struct tcphdr ) ) return - 1 ; tcph = ( struct tcphdr * ) ( skb_network_header ( skb ) + tcphoff ) ; tcp_hdrlen = tcph -> doff * 4 ; if ( len < tcp_hdrlen ) return - 1 ; if ( info -> mss == XT_TCPMSS_CLAMP_PMTU ) { struct net * net = xt_net ( par ) ; unsigned int in_mtu = tcpmss_reverse_mtu ( net , skb , family ) ; unsigned int min_mtu = min ( dst_mtu ( skb_dst ( skb ) ) , in_mtu ) ; if ( min_mtu <= minlen ) { net_err_ratelimited ( ""unknownorinvalidpath-MTU(%u)\\n"" , min_mtu ) ; return - 1 ; } newmss = min_mtu - minlen ; } else newmss = info -> mss ; opt = ( u_int8_t * ) tcph ; for ( i = sizeof ( struct tcphdr ) ; i <= tcp_hdrlen - TCPOLEN_MSS ; i += optlen ( opt , i ) ) { if ( opt [ i ] == TCPOPT_MSS && opt [ i + 1 ] == TCPOLEN_MSS ) { u_int16_t oldmss ; oldmss = ( opt [ i + 2 ] << 8 ) | opt [ i + 3 ] ; if ( oldmss <= newmss ) return 0 ; opt [ i + 2 ] = ( newmss & 0xff00 ) >> 8 ; opt [ i + 3 ] = newmss & 0x00ff ; inet_proto_csum_replace2 ( & tcph -> check , skb , htons ( oldmss ) , htons ( newmss ) , false ) ; return 0 ; } } if ( len > tcp_hdrlen ) return 0 ; if ( skb_tailroom ( skb ) < TCPOLEN_MSS ) { if ( pskb_expand_head ( skb , 0 , TCPOLEN_MSS - skb_tailroom ( skb ) , GFP_ATOMIC ) ) return - 1 ; tcph = ( struct tcphdr * ) ( skb_network_header ( skb ) + tcphoff ) ; } skb_put ( skb , TCPOLEN_MSS ) ; if ( xt_family ( par ) == NFPROTO_IPV4 ) newmss = min ( newmss , ( u16 ) 536 ) ; else newmss = min ( newmss , ( u16 ) 1220 ) ; opt = ( u_int8_t * ) tcph + sizeof ( struct tcphdr ) ; memmove ( opt + TCPOLEN_MSS , opt , len - sizeof ( struct tcphdr ) ) ; inet_proto_csum_replace2 ( & tcph -> check , skb , htons ( len ) , htons ( len + TCPOLEN_MSS ) , true ) ; opt [ 0 ] = TCPOPT_MSS ; opt [ 1 ] = TCPOLEN_MSS ; opt [ 2 ] = ( newmss & 0xff00 ) >> 8 ; opt [ 3 ] = newmss & 0x00ff ; inet_proto_csum_replace4 ( & tcph -> check , skb , 0 , * ( ( __be32 * ) opt ) , false ) ; oldval = ( ( __be16 * ) tcph ) [ 6 ] ; tcph -> doff += TCPOLEN_MSS / 4 ; inet_proto_csum_replace2 ( & tcph -> check , skb , oldval , ( ( __be16 * ) tcph ) [ 6 ] , false ) ; return TCPOLEN_MSS ; } "," len < tcp_hdrlen || tcp_hdrlen < sizeof ( struct tcphdr ) ; if ( tcp_hdrlen >= 15 * 4 ) return 0 ; if ( ",torvalds@linux/2638fd0f92d4397884fd991d8f4925cb3f081901,CVE-2017-18017,https://github.com/torvalds/linux/commit/2638fd0f92d4397884fd991d8f4925cb3f081901,2018-01-03T06:29Z 1219,CWE-190,"CWE-190 jas_matrix_t * jas_matrix_create ( int numrows , int numcols ) { jas_matrix_t * matrix ; int i ; if ( numrows < 0 || numcols < 0 ) { return 0 ; } if ( ! ( matrix = jas_malloc ( sizeof ( jas_matrix_t ) ) ) ) { return 0 ; } matrix -> flags_ = 0 ; matrix -> numrows_ = numrows ; matrix -> numcols_ = numcols ; matrix -> rows_ = 0 ; matrix -> maxrows_ = numrows ; matrix -> data_ = 0 ; matrix -> datasize_ = numrows * numcols ; if ( matrix -> maxrows_ > 0 ) { if ( ! ( matrix -> rows_ = jas_alloc2 ( matrix -> maxrows_ , sizeof ( jas_seqent_t * ) ) ) ) { jas_matrix_destroy ( matrix ) ; return 0 ; } } if ( matrix -> datasize_ > 0 ) { if ( ! ( matrix -> data_ = jas_alloc2 ( matrix -> datasize_ , sizeof ( jas_seqent_t ) ) ) ) { jas_matrix_destroy ( matrix ) ; return 0 ; } } for ( i = 0 ; i < numrows ; ++ i ) { matrix -> rows_ [ i ] = & matrix -> data_ [ i * matrix -> numcols_ ] ; } for ( i = 0 ; i < matrix -> datasize_ ; ++ i ) { matrix -> data_ [ i ] = 0 ; } matrix -> xstart_ = 0 ; matrix -> ystart_ = 0 ; matrix -> xend_ = matrix -> numcols_ ; matrix -> yend_ = matrix -> numrows_ ; return matrix ; } "," int i ; size_t size ; matrix = 0 ; 0 ) { goto error ; } if ) ) { goto error ; } matrix -> datasize_ = 0 ; if ( ! jas_safe_size_mul ( numrows , numcols , & size ) ) { goto error ; } matrix -> datasize_ = size ; if ( ) ) { goto error ; } } ) ) { goto error ; } } return matrix ; error : if ( matrix ) { jas_matrix_destroy ( matrix ) ; } return 0 ; ",mdadams@jasper/988f8365f7d8ad8073b6786e433d34c553ecf568,CVE-2016-10249,https://github.com/mdadams/jasper/commit/988f8365f7d8ad8073b6786e433d34c553ecf568,2017-03-15T14:59Z 1220,CWE-000,"CWE-000 int ip6_fragment ( struct sk_buff * skb , int ( * output ) ( struct sk_buff * ) ) { struct sk_buff * frag ; struct rt6_info * rt = ( struct rt6_info * ) skb_dst ( skb ) ; struct ipv6_pinfo * np = skb -> sk ? inet6_sk ( skb -> sk ) : NULL ; struct ipv6hdr * tmp_hdr ; struct frag_hdr * fh ; unsigned int mtu , hlen , left , len ; __be32 frag_id = 0 ; int ptr , offset = 0 , err = 0 ; u8 * prevhdr , nexthdr = 0 ; struct net * net = dev_net ( skb_dst ( skb ) -> dev ) ; hlen = ip6_find_1stfragopt ( skb , & prevhdr ) ; nexthdr = * prevhdr ; mtu = ip6_skb_dst_mtu ( skb ) ; if ( ! skb -> local_df && skb -> len > mtu ) { skb -> dev = skb_dst ( skb ) -> dev ; icmpv6_send ( skb , ICMPV6_PKT_TOOBIG , 0 , mtu ) ; IP6_INC_STATS ( net , ip6_dst_idev ( skb_dst ( skb ) ) , IPSTATS_MIB_FRAGFAILS ) ; kfree_skb ( skb ) ; return - EMSGSIZE ; } if ( np && np -> frag_size < mtu ) { if ( np -> frag_size ) mtu = np -> frag_size ; } mtu -= hlen + sizeof ( struct frag_hdr ) ; if ( skb_has_frag_list ( skb ) ) { int first_len = skb_pagelen ( skb ) ; struct sk_buff * frag2 ; if ( first_len - hlen > mtu || ( ( first_len - hlen ) & 7 ) || skb_cloned ( skb ) ) goto slow_path ; skb_walk_frags ( skb , frag ) { if ( frag -> len > mtu || ( ( frag -> len & 7 ) && frag -> next ) || skb_headroom ( frag ) < hlen ) goto slow_path_clean ; if ( skb_shared ( frag ) ) goto slow_path_clean ; BUG_ON ( frag -> sk ) ; if ( skb -> sk ) { frag -> sk = skb -> sk ; frag -> destructor = sock_wfree ; } skb -> truesize -= frag -> truesize ; } err = 0 ; offset = 0 ; frag = skb_shinfo ( skb ) -> frag_list ; skb_frag_list_init ( skb ) ; * prevhdr = NEXTHDR_FRAGMENT ; tmp_hdr = kmemdup ( skb_network_header ( skb ) , hlen , GFP_ATOMIC ) ; if ( ! tmp_hdr ) { IP6_INC_STATS ( net , ip6_dst_idev ( skb_dst ( skb ) ) , IPSTATS_MIB_FRAGFAILS ) ; return - ENOMEM ; } __skb_pull ( skb , hlen ) ; fh = ( struct frag_hdr * ) __skb_push ( skb , sizeof ( struct frag_hdr ) ) ; __skb_push ( skb , hlen ) ; skb_reset_network_header ( skb ) ; memcpy ( skb_network_header ( skb ) , tmp_hdr , hlen ) ; ipv6_select_ident ( fh ) ; fh -> nexthdr = nexthdr ; fh -> reserved = 0 ; fh -> frag_off = htons ( IP6_MF ) ; frag_id = fh -> identification ; first_len = skb_pagelen ( skb ) ; skb -> data_len = first_len - skb_headlen ( skb ) ; skb -> len = first_len ; ipv6_hdr ( skb ) -> payload_len = htons ( first_len - sizeof ( struct ipv6hdr ) ) ; dst_hold ( & rt -> dst ) ; for ( ; ; ) { if ( frag ) { frag -> ip_summed = CHECKSUM_NONE ; skb_reset_transport_header ( frag ) ; fh = ( struct frag_hdr * ) __skb_push ( frag , sizeof ( struct frag_hdr ) ) ; __skb_push ( frag , hlen ) ; skb_reset_network_header ( frag ) ; memcpy ( skb_network_header ( frag ) , tmp_hdr , hlen ) ; offset += skb -> len - hlen - sizeof ( struct frag_hdr ) ; fh -> nexthdr = nexthdr ; fh -> reserved = 0 ; fh -> frag_off = htons ( offset ) ; if ( frag -> next != NULL ) fh -> frag_off |= htons ( IP6_MF ) ; fh -> identification = frag_id ; ipv6_hdr ( frag ) -> payload_len = htons ( frag -> len - sizeof ( struct ipv6hdr ) ) ; ip6_copy_metadata ( frag , skb ) ; } err = output ( skb ) ; if ( ! err ) IP6_INC_STATS ( net , ip6_dst_idev ( & rt -> dst ) , IPSTATS_MIB_FRAGCREATES ) ; if ( err || ! frag ) break ; skb = frag ; frag = skb -> next ; skb -> next = NULL ; } kfree ( tmp_hdr ) ; if ( err == 0 ) { IP6_INC_STATS ( net , ip6_dst_idev ( & rt -> dst ) , IPSTATS_MIB_FRAGOKS ) ; dst_release ( & rt -> dst ) ; return 0 ; } while ( frag ) { skb = frag -> next ; kfree_skb ( frag ) ; frag = skb ; } IP6_INC_STATS ( net , ip6_dst_idev ( & rt -> dst ) , IPSTATS_MIB_FRAGFAILS ) ; dst_release ( & rt -> dst ) ; return err ; slow_path_clean : skb_walk_frags ( skb , frag2 ) { if ( frag2 == frag ) break ; frag2 -> sk = NULL ; frag2 -> destructor = NULL ; skb -> truesize += frag2 -> truesize ; } } slow_path : left = skb -> len - hlen ; ptr = hlen ; * prevhdr = NEXTHDR_FRAGMENT ; while ( left > 0 ) { len = left ; if ( len > mtu ) len = mtu ; if ( len < left ) { len &= ~ 7 ; } if ( ( frag = alloc_skb ( len + hlen + sizeof ( struct frag_hdr ) + LL_ALLOCATED_SPACE ( rt -> dst . dev ) , GFP_ATOMIC ) ) == NULL ) { NETDEBUG ( KERN_INFO ""IPv6:frag:nomemoryfornewfragment!\\n"" ) ; IP6_INC_STATS ( net , ip6_dst_idev ( skb_dst ( skb ) ) , IPSTATS_MIB_FRAGFAILS ) ; err = - ENOMEM ; goto fail ; } ip6_copy_metadata ( frag , skb ) ; skb_reserve ( frag , LL_RESERVED_SPACE ( rt -> dst . dev ) ) ; skb_put ( frag , len + hlen + sizeof ( struct frag_hdr ) ) ; skb_reset_network_header ( frag ) ; fh = ( struct frag_hdr * ) ( skb_network_header ( frag ) + hlen ) ; frag -> transport_header = ( frag -> network_header + hlen + sizeof ( struct frag_hdr ) ) ; if ( skb -> sk ) skb_set_owner_w ( frag , skb -> sk ) ; skb_copy_from_linear_data ( skb , skb_network_header ( frag ) , hlen ) ; fh -> nexthdr = nexthdr ; fh -> reserved = 0 ; if ( ! frag_id ) { ipv6_select_ident ( fh ) ; frag_id = fh -> identification ; } else fh -> identification = frag_id ; if ( skb_copy_bits ( skb , ptr , skb_transport_header ( frag ) , len ) ) BUG ( ) ; left -= len ; fh -> frag_off = htons ( offset ) ; if ( left > 0 ) fh -> frag_off |= htons ( IP6_MF ) ; ipv6_hdr ( frag ) -> payload_len = htons ( frag -> len - sizeof ( struct ipv6hdr ) ) ; ptr += len ; offset += len ; err = output ( frag ) ; if ( err ) goto fail ; IP6_INC_STATS ( net , ip6_dst_idev ( skb_dst ( skb ) ) , IPSTATS_MIB_FRAGCREATES ) ; } IP6_INC_STATS ( net , ip6_dst_idev ( skb_dst ( skb ) ) , IPSTATS_MIB_FRAGOKS ) ; kfree_skb ( skb ) ; return err ; fail : IP6_INC_STATS ( net , ip6_dst_idev ( skb_dst ( skb ) ) , IPSTATS_MIB_FRAGFAILS ) ; kfree_skb ( skb ) ; return err ; } "," ipv6_select_ident ( fh , rt ipv6_select_ident ( fh , rt ",torvalds@linux/87c48fa3b4630905f98268dde838ee43626a060c,CVE-2011-2699,https://github.com/torvalds/linux/commit/87c48fa3b4630905f98268dde838ee43626a060c,2012-05-24T23:55Z 1221,CWE-19,"CWE-19 static void ext4_xattr_cache_insert ( struct mb_cache * ext4_mb_cache , struct buffer_head * bh ) { __u32 hash = le32_to_cpu ( BHDR ( bh ) -> h_hash ) ; struct mb_cache_entry * ce ; int error ; ce = mb_cache_entry_alloc ( ext4_mb_cache , GFP_NOFS ) ; if ( ! ce ) { ea_bdebug ( bh , ""outofmemory"" ) ; return ; } error = mb_cache_entry_insert ( ce , bh -> b_bdev , bh -> b_blocknr , hash ) ; if ( error ) { mb_cache_entry_free ( ce ) ; if ( error == - EBUSY ) { ea_bdebug ( bh , ""alreadyincache"" ) ; error = 0 ; } } else { ea_bdebug ( bh , ""inserting[%x]"" , ( int ) hash ) ; mb_cache_entry_release ( ce ) ; } } "," ext4_xattr_cache_insert ( struct mb2_cache * ext4_mb_cache , h_hash ) ; int error ; int error ; error = mb2_cache_entry_create ( ext4_mb_cache , ext4_mb_cache , GFP_NOFS , hash , bh -> b_blocknr bh -> b_blocknr ) ; if error ) { if ( error - EBUSY ) ea_bdebug ( bh ""alreadyincache"" ) ; } else ea_bdebug ( bh hash ) ; } ",torvalds@linux/82939d7999dfc1f1998c4b1c12e2f19edbdff272,CVE-2015-8952,https://github.com/torvalds/linux/commit/82939d7999dfc1f1998c4b1c12e2f19edbdff272,2016-10-16T21:59Z 1222,CWE-119,"CWE-119 static SCSIRequest * scsi_new_request ( SCSIDevice * d , uint32_t tag , uint32_t lun , void * hba_private ) { SCSIDiskState * s = DO_UPCAST ( SCSIDiskState , qdev , d ) ; SCSIRequest * req ; SCSIDiskReq * r ; req = scsi_req_alloc ( & scsi_disk_reqops , & s -> qdev , tag , lun , hba_private ) ; r = DO_UPCAST ( SCSIDiskReq , req , req ) ; r -> iov . iov_base = qemu_blockalign ( s -> bs , SCSI_DMA_BUF_SIZE ) ; return req ; } "," * req ; req = scsi_req_alloc hba_private ) ; return req ; ",bonzini@qemu/7285477ab11831b1cf56e45878a89170dd06d9b9,CVE-2011-3346,https://github.com/bonzini/qemu/commit/7285477ab11831b1cf56e45878a89170dd06d9b9,2014-04-01T06:35Z 1223,CWE-189,"CWE-189 Datum txid_snapshot_recv ( PG_FUNCTION_ARGS ) { StringInfo buf = ( StringInfo ) PG_GETARG_POINTER ( 0 ) ; TxidSnapshot * snap ; txid last = 0 ; int nxip ; int i ; int avail ; int expect ; txid xmin , xmax ; nxip = pq_getmsgint ( buf , 4 ) ; avail = buf -> len - buf -> cursor ; expect = 8 + 8 + nxip * 8 ; if ( nxip < 0 || nxip > avail || expect > avail ) goto bad_format ; xmin = pq_getmsgint64 ( buf ) ; xmax = pq_getmsgint64 ( buf ) ; if ( xmin == 0 || xmax == 0 || xmin > xmax || xmax > MAX_TXID ) goto bad_format ; snap = palloc ( TXID_SNAPSHOT_SIZE ( nxip ) ) ; snap -> xmin = xmin ; snap -> xmax = xmax ; snap -> nxip = nxip ; SET_VARSIZE ( snap , TXID_SNAPSHOT_SIZE ( nxip ) ) ; for ( i = 0 ; i < nxip ; i ++ ) { txid cur = pq_getmsgint64 ( buf ) ; if ( cur <= last || cur < xmin || cur >= xmax ) goto bad_format ; snap -> xip [ i ] = cur ; last = cur ; } PG_RETURN_POINTER ( snap ) ; bad_format : elog ( ERROR , ""invalidsnapshotdata"" ) ; return ( Datum ) NULL ; } "," int i ; txid xmin , 4 ) ; if ( nxip || nxip > TXID_SNAPSHOT_MAX_NXIP ) goto bad_format ",postgres@postgres/31400a673325147e1205326008e32135a78b4d8a,CVE-2014-2669,https://github.com/postgres/postgres/commit/31400a673325147e1205326008e32135a78b4d8a,2014-03-31T14:58Z 1224,CWE-119,"CWE-119 static inline void header_put_le_3byte ( SF_PRIVATE * psf , int x ) { if ( psf -> headindex < SIGNED_SIZEOF ( psf -> header ) - 3 ) { psf -> header [ psf -> headindex ++ ] = x ; psf -> header [ psf -> headindex ++ ] = ( x >> 8 ) ; psf -> header [ psf -> headindex ++ ] = ( x >> 16 ) ; } ; } "," x ) { psf -> header psf -> header . ptr [ psf -> header psf -> header . indx ++ ] = psf -> header . ptr [ psf -> header . indx ++ ] = psf -> header . ptr [ psf -> header . indx ++ ] = ) ; } ",erikd@libsndfile/708e996c87c5fae77b104ccfeb8f6db784c32074,CVE-2017-7586,https://github.com/erikd/libsndfile/commit/708e996c87c5fae77b104ccfeb8f6db784c32074,2017-04-07T20:59Z 1225,CWE-399,"CWE-399 static int rds_ib_laddr_check ( __be32 addr ) { int ret ; struct rdma_cm_id * cm_id ; struct sockaddr_in sin ; cm_id = rdma_create_id ( NULL , NULL , RDMA_PS_TCP , IB_QPT_RC ) ; if ( IS_ERR ( cm_id ) ) return PTR_ERR ( cm_id ) ; memset ( & sin , 0 , sizeof ( sin ) ) ; sin . sin_family = AF_INET ; sin . sin_addr . s_addr = addr ; ret = rdma_bind_addr ( cm_id , ( struct sockaddr * ) & sin ) ; if ( ret || cm_id -> device -> node_type != RDMA_NODE_IB_CA ) ret = - EADDRNOTAVAIL ; rdsdebug ( ""addr%pI4ret%dnodetype%d\\n"" , & addr , ret , cm_id -> device ? cm_id -> device -> node_type : - 1 ) ; rdma_destroy_id ( cm_id ) ; return ret ; } "," ( ret || ! cm_id -> device || ",torvalds@linux/c2349758acf1874e4c2b93fe41d072336f1a31d0,CVE-2013-7339,https://github.com/torvalds/linux/commit/c2349758acf1874e4c2b93fe41d072336f1a31d0,2014-03-24T16:40Z 1226,CWE-416,"CWE-416 static int xfrm_dump_policy ( struct sk_buff * skb , struct netlink_callback * cb ) { struct net * net = sock_net ( skb -> sk ) ; struct xfrm_policy_walk * walk = ( struct xfrm_policy_walk * ) & cb -> args [ 1 ] ; struct xfrm_dump_info info ; BUILD_BUG_ON ( sizeof ( struct xfrm_policy_walk ) > sizeof ( cb -> args ) - sizeof ( cb -> args [ 0 ] ) ) ; info . in_skb = cb -> skb ; info . out_skb = skb ; info . nlmsg_seq = cb -> nlh -> nlmsg_seq ; info . nlmsg_flags = NLM_F_MULTI ; if ( ! cb -> args [ 0 ] ) { cb -> args [ 0 ] = 1 ; xfrm_policy_walk_init ( walk , XFRM_POLICY_TYPE_ANY ) ; } ( void ) xfrm_policy_walk ( net , walk , dump_one_policy , & info ) ; return skb -> len ; } "," xfrm_policy_walk * ) cb -> args cb -> args ; struct xfrm_dump_info struct xfrm_dump_info info ; info . = NLM_F_MULTI ; ( void ) ",torvalds@linux/1137b5e2529a8f5ca8ee709288ecba3e68044df2,CVE-2017-16939,https://github.com/torvalds/linux/commit/1137b5e2529a8f5ca8ee709288ecba3e68044df2,2017-11-24T10:29Z 1227,CWE-552,"CWE-552 static ssize_t _epoll_write ( oe_fd_t * epoll_ , const void * buf , size_t count ) { ssize_t ret = - 1 ; epoll_t * epoll = _cast_epoll ( epoll_ ) ; oe_errno = 0 ; if ( oe_syscall_write_ocall ( & ret , epoll -> host_fd , buf , count ) != OE_OK ) OE_RAISE_ERRNO ( OE_EINVAL ) ; done : return ret ; } "," ; epoll_t * file = _cast_epoll ( ; if ( ! file || count > OE_SSIZE_MAX ) OE_RAISE_ERRNO ( OE_EINVAL ) ; if ( & ret , file -> host_fd , OE_EINVAL ) ; if ( ret > ( ssize_t ) count ) { ret = - 1 ; OE_RAISE_ERRNO ( OE_EINVAL ) ; } ",openenclave@openenclave/bcac8e7acb514429fee9e0b5d0c7a0308fd4d76b,CVE-2020-15224,https://github.com/openenclave/openenclave/commit/bcac8e7acb514429fee9e0b5d0c7a0308fd4d76b,2020-10-14T19:15Z 1228,CWE-20,"CWE-20 static int ovl_remove_upper ( struct dentry * dentry , bool is_dir ) { struct dentry * upperdir = ovl_dentry_upper ( dentry -> d_parent ) ; struct inode * dir = upperdir -> d_inode ; struct dentry * upper = ovl_dentry_upper ( dentry ) ; int err ; inode_lock_nested ( dir , I_MUTEX_PARENT ) ; err = - ESTALE ; if ( upper -> d_parent == upperdir ) { dget ( upper ) ; if ( is_dir ) err = vfs_rmdir ( dir , upper ) ; else err = vfs_unlink ( dir , upper , NULL ) ; dput ( upper ) ; ovl_dentry_version_inc ( dentry -> d_parent ) ; } if ( ! err ) d_drop ( dentry ) ; inode_unlock ( dir ) ; return err ; } "," dentry * upper ; int err I_MUTEX_PARENT ) ; upper = lookup_one_len ( dentry -> d_name . name , upperdir , dentry -> d_name . len ) ; err = PTR_ERR ( upper ) ; if ( IS_ERR ( upper ) ) goto out_unlock ; if ( upper == ovl_dentry_upper ( dentry ) ) { if ( is_dir NULL ) ; ovl_dentry_version_inc ( dentry ) ; } dput ( upper ) ; dentry ) ; out_unlock : ",torvalds@linux/11f3710417d026ea2f4fcf362d866342c5274185,CVE-2016-6197,https://github.com/torvalds/linux/commit/11f3710417d026ea2f4fcf362d866342c5274185,2016-08-06T20:59Z 1229,CWE-295,"CWE-295 NOEXPORT int init_section ( int eof , SERVICE_OPTIONS * * section_ptr ) { char * errstr ; # ifndef USE_WIN32 ( * section_ptr ) -> option . log_stderr = new_global_options . option . log_stderr ; # endif if ( * section_ptr == & new_service_options ) { errstr = parse_global_option ( CMD_INITIALIZE , NULL , NULL ) ; if ( errstr ) { s_log ( LOG_ERR , ""Globaloptions:%s"" , errstr ) ; return 1 ; } } if ( * section_ptr != & new_service_options || eof ) { if ( * section_ptr == & new_service_options ) s_log ( LOG_INFO , ""Initializinginetdmodeconfiguration"" ) ; else s_log ( LOG_INFO , ""Initializingservice[%s]"" , ( * section_ptr ) -> servname ) ; errstr = parse_service_option ( CMD_INITIALIZE , section_ptr , NULL , NULL ) ; if ( errstr ) { if ( * section_ptr == & new_service_options ) s_log ( LOG_ERR , ""Inetdmode:%s"" , errstr ) ; else s_log ( LOG_ERR , ""Service[%s]:%s"" , ( * section_ptr ) -> servname , errstr ) ; return 1 ; } } return 0 ; } "," ( CMD_INITIALIZE , & new_global_options , eof ) { errstr = parse_service_option ",mtrojnar@stunnel/ebad9ddc4efb2635f37174c9d800d06206f1edf9,CVE-2021-20230,https://github.com/mtrojnar/stunnel/commit/ebad9ddc4efb2635f37174c9d800d06206f1edf9,2021-02-23T17:15Z 1230,CWE-000,"CWE-000 int av_reallocp_array ( void * ptr , size_t nmemb , size_t size ) { void * * ptrptr = ptr ; * ptrptr = av_realloc_f ( * ptrptr , nmemb , size ) ; if ( ! * ptrptr && ! ( nmemb && size ) ) return AVERROR ( ENOMEM ) ; return 0 ; } "," * ptrptr && nmemb && size nmemb && size ) return AVERROR ",FFmpeg@FFmpeg/c94f9e854228e0ea00e1de8769d8d3f7cab84a55,CVE-2013-4265,https://github.com/FFmpeg/FFmpeg/commit/c94f9e854228e0ea00e1de8769d8d3f7cab84a55,2013-11-23T17:55Z 1231,CWE-125,"CWE-125 int parse_file ( FILE * input_file , char * directory , char * body_filename , char * body_pref , int flags ) { uint32 d ; uint16 key ; Attr * attr = NULL ; File * file = NULL ; int rtf_size = 0 , html_size = 0 ; MessageBody body ; memset ( & body , '\\0' , sizeof ( MessageBody ) ) ; g_flags = flags ; d = geti32 ( input_file ) ; if ( d != TNEF_SIGNATURE ) { fprintf ( stdout , ""SeemsnottobeaTNEFfile\\n"" ) ; return 1 ; } key = geti16 ( input_file ) ; debug_print ( ""TNEFKey:%hx\\n"" , key ) ; while ( data_left ( input_file ) ) { attr = read_object ( input_file ) ; if ( attr == NULL ) break ; if ( attr -> name == attATTACHRENDDATA ) { if ( file ) { file_write ( file , directory ) ; file_free ( file ) ; } else { file = CHECKED_XCALLOC ( File , 1 ) ; } } switch ( attr -> lvl_type ) { case LVL_MESSAGE : if ( attr -> name == attBODY ) { body . text_body = get_text_data ( attr ) ; } else if ( attr -> name == attMAPIPROPS ) { MAPI_Attr * * mapi_attrs = mapi_attr_read ( attr -> len , attr -> buf ) ; if ( mapi_attrs ) { int i ; for ( i = 0 ; mapi_attrs [ i ] ; i ++ ) { MAPI_Attr * a = mapi_attrs [ i ] ; if ( a -> name == MAPI_BODY_HTML ) { body . html_bodies = get_html_data ( a ) ; html_size = a -> num_values ; } else if ( a -> name == MAPI_RTF_COMPRESSED ) { body . rtf_bodies = get_rtf_data ( a ) ; rtf_size = a -> num_values ; } } mapi_attr_free_list ( mapi_attrs ) ; XFREE ( mapi_attrs ) ; } } break ; case LVL_ATTACHMENT : file_add_attr ( file , attr ) ; break ; default : fprintf ( stderr , ""Invalidlvltypeonattribute:%d\\n"" , attr -> lvl_type ) ; return 1 ; break ; } attr_free ( attr ) ; XFREE ( attr ) ; } if ( file ) { file_write ( file , directory ) ; file_free ( file ) ; XFREE ( file ) ; } if ( flags & SAVEBODY ) { int i = 0 ; int all_flag = 0 ; if ( strcmp ( body_pref , ""all"" ) == 0 ) { all_flag = 1 ; body_pref = ""rht"" ; } for ( ; i < 3 ; i ++ ) { File * * files = get_body_files ( body_filename , body_pref [ i ] , & body ) ; if ( files ) { int j = 0 ; for ( ; files [ j ] ; j ++ ) { file_write ( files [ j ] , directory ) ; file_free ( files [ j ] ) ; XFREE ( files [ j ] ) ; } XFREE ( files ) ; if ( ! all_flag ) break ; } } } if ( body . text_body ) { free_bodies ( body . text_body , 1 ) ; XFREE ( body . text_body ) ; } if ( rtf_size > 0 ) { free_bodies ( body . rtf_bodies , rtf_size ) ; XFREE ( body . rtf_bodies ) ; } if ( html_size > 0 ) { free_bodies ( body . html_bodies , html_size ) ; XFREE ( body . html_bodies ) ; } return 0 ; } "," ( a -> type == szMAPI_BINARY && a -> else if ( a -> type == szMAPI_BINARY && ",verdammelt@tnef/8dccf79857ceeb7a6d3e42c1e762e7b865d5344d,CVE-2017-6310,https://github.com/verdammelt/tnef/commit/8dccf79857ceeb7a6d3e42c1e762e7b865d5344d,2017-02-24T04:59Z 1232,CWE-787,"CWE-787 static int DecodeGifImg ( struct ngiflib_img * i ) { struct ngiflib_decode_context context ; long npix ; u8 * stackp ; u8 * stack_top ; u16 clr ; u16 eof ; u16 free ; u16 act_code = 0 ; u16 old_code = 0 ; u16 read_byt ; u16 ab_prfx [ 4096 ] ; u8 ab_suffx [ 4096 ] ; u8 ab_stack [ 4096 ] ; u8 flags ; u8 casspecial = 0 ; if ( ! i ) return - 1 ; i -> posX = GetWord ( i -> parent ) ; i -> posY = GetWord ( i -> parent ) ; i -> width = GetWord ( i -> parent ) ; i -> height = GetWord ( i -> parent ) ; if ( ( i -> width > i -> parent -> width ) || ( i -> height > i -> parent -> height ) ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent -> log ) fprintf ( i -> parent -> log , ""***ERROR***ImagebiggerthanglobalGIFcanvas!\\n"" ) ; # endif return - 1 ; } if ( ( i -> posX + i -> width ) > i -> parent -> width ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent -> log ) fprintf ( i -> parent -> log , ""***WARNING***AdjustingXposition\\n"" ) ; # endif i -> posX = i -> parent -> width - i -> width ; } if ( ( i -> posY + i -> height ) > i -> parent -> height ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent -> log ) fprintf ( i -> parent -> log , ""***WARNING***AdjustingYposition\\n"" ) ; # endif i -> posY = i -> parent -> height - i -> height ; } context . Xtogo = i -> width ; context . curY = i -> posY ; # ifdef NGIFLIB_INDEXED_ONLY # ifdef NGIFLIB_ENABLE_CALLBACKS context . line_p . p8 = i -> parent -> frbuff . p8 + ( u32 ) i -> posY * i -> parent -> width ; context . frbuff_p . p8 = context . line_p . p8 + i -> posX ; # else context . frbuff_p . p8 = i -> parent -> frbuff . p8 + ( u32 ) i -> posY * i -> parent -> width + i -> posX ; # endif # else if ( i -> parent -> mode & NGIFLIB_MODE_INDEXED ) { # ifdef NGIFLIB_ENABLE_CALLBACKS context . line_p . p8 = i -> parent -> frbuff . p8 + ( u32 ) i -> posY * i -> parent -> width ; context . frbuff_p . p8 = context . line_p . p8 + i -> posX ; # else context . frbuff_p . p8 = i -> parent -> frbuff . p8 + ( u32 ) i -> posY * i -> parent -> width + i -> posX ; # endif } else { # ifdef NGIFLIB_ENABLE_CALLBACKS context . line_p . p32 = i -> parent -> frbuff . p32 + ( u32 ) i -> posY * i -> parent -> width ; context . frbuff_p . p32 = context . line_p . p32 + i -> posX ; # else context . frbuff_p . p32 = i -> parent -> frbuff . p32 + ( u32 ) i -> posY * i -> parent -> width + i -> posX ; # endif } # endif npix = ( long ) i -> width * i -> height ; flags = GetByte ( i -> parent ) ; i -> interlaced = ( flags & 64 ) >> 6 ; context . pass = i -> interlaced ? 1 : 0 ; i -> sort_flag = ( flags & 32 ) >> 5 ; i -> localpalbits = ( flags & 7 ) + 1 ; if ( flags & 128 ) { int k ; int localpalsize = 1 << i -> localpalbits ; # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent && i -> parent -> log ) fprintf ( i -> parent -> log , ""Localpalette\\n"" ) ; # endif i -> palette = ( struct ngiflib_rgb * ) ngiflib_malloc ( sizeof ( struct ngiflib_rgb ) * localpalsize ) ; for ( k = 0 ; k < localpalsize ; k ++ ) { i -> palette [ k ] . r = GetByte ( i -> parent ) ; i -> palette [ k ] . g = GetByte ( i -> parent ) ; i -> palette [ k ] . b = GetByte ( i -> parent ) ; } # ifdef NGIFLIB_ENABLE_CALLBACKS if ( i -> parent -> palette_cb ) i -> parent -> palette_cb ( i -> parent , i -> palette , localpalsize ) ; # endif } else { i -> palette = i -> parent -> palette ; i -> localpalbits = i -> parent -> imgbits ; } i -> ncolors = 1 << i -> localpalbits ; i -> imgbits = GetByte ( i -> parent ) ; # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent && i -> parent -> log ) { if ( i -> interlaced ) fprintf ( i -> parent -> log , ""interlaced"" ) ; fprintf ( i -> parent -> log , ""imgpos(%hu,%hu)size%hux%hupalbits=%hhuimgbits=%hhuncolors=%hu\\n"" , i -> posX , i -> posY , i -> width , i -> height , i -> localpalbits , i -> imgbits , i -> ncolors ) ; } # endif if ( i -> imgbits == 1 ) { i -> imgbits = 2 ; } clr = 1 << i -> imgbits ; eof = clr + 1 ; free = clr + 2 ; context . nbbit = i -> imgbits + 1 ; context . max = clr + clr - 1 ; stackp = stack_top = ab_stack + 4096 ; context . restbits = 0 ; context . restbyte = 0 ; context . lbyte = 0 ; for ( ; ; ) { act_code = GetGifWord ( i , & context ) ; if ( act_code == eof ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent && i -> parent -> log ) fprintf ( i -> parent -> log , ""Endofimagecode\\n"" ) ; # endif return 0 ; } if ( npix == 0 ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent && i -> parent -> log ) fprintf ( i -> parent -> log , ""assezdepixels,Onsecasse!\\n"" ) ; # endif return 1 ; } if ( act_code == clr ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent && i -> parent -> log ) fprintf ( i -> parent -> log , ""Codeclear(free=%hu)npix=%ld\\n"" , free , npix ) ; # endif free = clr + 2 ; context . nbbit = i -> imgbits + 1 ; context . max = clr + clr - 1 ; act_code = GetGifWord ( i , & context ) ; casspecial = ( u8 ) act_code ; old_code = act_code ; WritePixel ( i , & context , casspecial ) ; npix -- ; } else { read_byt = act_code ; if ( act_code >= free ) { * ( -- stackp ) = casspecial ; act_code = old_code ; } while ( act_code > clr ) { * ( -- stackp ) = ab_suffx [ act_code ] ; act_code = ab_prfx [ act_code ] ; } casspecial = ( u8 ) act_code ; * ( -- stackp ) = casspecial ; WritePixels ( i , & context , stackp , stack_top - stackp ) ; npix -= ( stack_top - stackp ) ; stackp = stack_top ; if ( free < 4096 ) { ab_prfx [ free ] = old_code ; ab_suffx [ free ] = ( u8 ) act_code ; free ++ ; if ( ( free > context . max ) && ( context . nbbit < 12 ) ) { context . nbbit ++ ; context . max += context . max + 1 ; } } old_code = read_byt ; } } return 0 ; } "," = act_code ; if ( npix > 0 ) = casspecial ; if ( npix >= ( stack_top - stackp - stackp ) ) { WritePixels ( i , & context , stackp , stack_top - stackp ) ; } else if ( npix > 0 ) { WritePixels ( i , & context , stackp , npix ) ; } npix -= ( ",miniupnp@ngiflib/cf429e0a2fe26b5f01ce0c8e9b79432e94509b6e,CVE-2018-10717,https://github.com/miniupnp/ngiflib/commit/cf429e0a2fe26b5f01ce0c8e9b79432e94509b6e,2018-05-03T17:29Z 1233,CWE-399,"CWE-399 public int magic_getparam ( struct magic_set * ms , int param , void * val ) { switch ( param ) { case MAGIC_PARAM_INDIR_MAX : * ( size_t * ) val = ms -> indir_max ; return 0 ; case MAGIC_PARAM_NAME_MAX : * ( size_t * ) val = ms -> name_max ; return 0 ; case MAGIC_PARAM_ELF_PHNUM_MAX : * ( size_t * ) val = ms -> elf_phnum_max ; return 0 ; case MAGIC_PARAM_ELF_SHNUM_MAX : * ( size_t * ) val = ms -> elf_shnum_max ; return 0 ; default : errno = EINVAL ; return - 1 ; } } "," return 0 ; case MAGIC_PARAM_ELF_NOTES_MAX : * ( size_t * ) val = ms -> elf_notes_max ; return 0 ; ",file@file/ce90e05774dd77d86cfc8dfa6da57b32816841c4,CVE-2014-9620,https://github.com/file/file/commit/ce90e05774dd77d86cfc8dfa6da57b32816841c4,2015-01-21T18:59Z 1234,CWE-476,"CWE-476 jas_image_t * jp2_decode ( jas_stream_t * in , char * optstr ) { jp2_box_t * box ; int found ; jas_image_t * image ; jp2_dec_t * dec ; bool samedtype ; int dtype ; unsigned int i ; jp2_cmap_t * cmapd ; jp2_pclr_t * pclrd ; jp2_cdef_t * cdefd ; unsigned int channo ; int newcmptno ; int_fast32_t * lutents ; # if 0 jp2_cdefchan_t * cdefent ; int cmptno ; # endif jp2_cmapent_t * cmapent ; jas_icchdr_t icchdr ; jas_iccprof_t * iccprof ; dec = 0 ; box = 0 ; image = 0 ; if ( ! ( dec = jp2_dec_create ( ) ) ) { goto error ; } if ( ! ( box = jp2_box_get ( in ) ) ) { jas_eprintf ( ""error:cannotgetbox\\n"" ) ; goto error ; } if ( box -> type != JP2_BOX_JP ) { jas_eprintf ( ""error:expectingsignaturebox\\n"" ) ; goto error ; } if ( box -> data . jp . magic != JP2_JP_MAGIC ) { jas_eprintf ( ""incorrectmagicnumber\\n"" ) ; goto error ; } jp2_box_destroy ( box ) ; box = 0 ; if ( ! ( box = jp2_box_get ( in ) ) ) { goto error ; } if ( box -> type != JP2_BOX_FTYP ) { jas_eprintf ( ""expectingfiletypebox\\n"" ) ; goto error ; } jp2_box_destroy ( box ) ; box = 0 ; found = 0 ; while ( ( box = jp2_box_get ( in ) ) ) { if ( jas_getdbglevel ( ) >= 1 ) { jas_eprintf ( ""boxtype%s\\n"" , box -> info -> name ) ; } switch ( box -> type ) { case JP2_BOX_JP2C : found = 1 ; break ; case JP2_BOX_IHDR : if ( ! dec -> ihdr ) { dec -> ihdr = box ; box = 0 ; } break ; case JP2_BOX_BPCC : if ( ! dec -> bpcc ) { dec -> bpcc = box ; box = 0 ; } break ; case JP2_BOX_CDEF : if ( ! dec -> cdef ) { dec -> cdef = box ; box = 0 ; } break ; case JP2_BOX_PCLR : if ( ! dec -> pclr ) { dec -> pclr = box ; box = 0 ; } break ; case JP2_BOX_CMAP : if ( ! dec -> cmap ) { dec -> cmap = box ; box = 0 ; } break ; case JP2_BOX_COLR : if ( ! dec -> colr ) { dec -> colr = box ; box = 0 ; } break ; } if ( box ) { jp2_box_destroy ( box ) ; box = 0 ; } if ( found ) { break ; } } if ( ! found ) { jas_eprintf ( ""error:nocodestreamfound\\n"" ) ; goto error ; } if ( ! ( dec -> image = jpc_decode ( in , optstr ) ) ) { jas_eprintf ( ""error:cannotdecodecodestream\\n"" ) ; goto error ; } if ( ! dec -> ihdr ) { jas_eprintf ( ""error:missingIHDRbox\\n"" ) ; goto error ; } if ( dec -> ihdr -> data . ihdr . numcmpts != JAS_CAST ( uint , jas_image_numcmpts ( dec -> image ) ) ) { jas_eprintf ( ""warning:numberofcomponentsmismatch\\n"" ) ; } if ( ! jas_image_numcmpts ( dec -> image ) ) { jas_eprintf ( ""error:nocomponents\\n"" ) ; goto error ; } samedtype = true ; dtype = jas_image_cmptdtype ( dec -> image , 0 ) ; for ( i = 1 ; i < JAS_CAST ( uint , jas_image_numcmpts ( dec -> image ) ) ; ++ i ) { if ( jas_image_cmptdtype ( dec -> image , i ) != dtype ) { samedtype = false ; break ; } } if ( ( samedtype && dec -> ihdr -> data . ihdr . bpc != JP2_DTYPETOBPC ( dtype ) ) || ( ! samedtype && dec -> ihdr -> data . ihdr . bpc != JP2_IHDR_BPCNULL ) ) { jas_eprintf ( ""warning:componentdatatypemismatch\\n"" ) ; } if ( dec -> ihdr -> data . ihdr . comptype != JP2_IHDR_COMPTYPE ) { jas_eprintf ( ""error:unsupportedcompressiontype\\n"" ) ; goto error ; } if ( dec -> bpcc ) { if ( dec -> bpcc -> data . bpcc . numcmpts != JAS_CAST ( uint , jas_image_numcmpts ( dec -> image ) ) ) { jas_eprintf ( ""warning:numberofcomponentsmismatch\\n"" ) ; } if ( ! samedtype ) { for ( i = 0 ; i < JAS_CAST ( uint , jas_image_numcmpts ( dec -> image ) ) ; ++ i ) { if ( jas_image_cmptdtype ( dec -> image , i ) != JP2_BPCTODTYPE ( dec -> bpcc -> data . bpcc . bpcs [ i ] ) ) { jas_eprintf ( ""warning:componentdatatypemismatch\\n"" ) ; } } } else { jas_eprintf ( ""warning:superfluousBPCCbox\\n"" ) ; } } if ( ! dec -> colr ) { jas_eprintf ( ""error:noCOLRbox\\n"" ) ; goto error ; } switch ( dec -> colr -> data . colr . method ) { case JP2_COLR_ENUM : jas_image_setclrspc ( dec -> image , jp2_getcs ( & dec -> colr -> data . colr ) ) ; break ; case JP2_COLR_ICC : iccprof = jas_iccprof_createfrombuf ( dec -> colr -> data . colr . iccp , dec -> colr -> data . colr . iccplen ) ; if ( ! iccprof ) { jas_eprintf ( ""error:failedtoparseICCprofile\\n"" ) ; goto error ; } jas_iccprof_gethdr ( iccprof , & icchdr ) ; jas_eprintf ( ""ICCProfileCS%08x\\n"" , icchdr . colorspc ) ; jas_image_setclrspc ( dec -> image , fromiccpcs ( icchdr . colorspc ) ) ; dec -> image -> cmprof_ = jas_cmprof_createfromiccprof ( iccprof ) ; assert ( dec -> image -> cmprof_ ) ; jas_iccprof_destroy ( iccprof ) ; break ; } if ( dec -> cmap && ! dec -> pclr ) { jas_eprintf ( ""warning:missingPCLRboxorsuperfluousCMAPbox\\n"" ) ; jp2_box_destroy ( dec -> cmap ) ; dec -> cmap = 0 ; } if ( ! dec -> cmap && dec -> pclr ) { jas_eprintf ( ""warning:missingCMAPboxorsuperfluousPCLRbox\\n"" ) ; jp2_box_destroy ( dec -> pclr ) ; dec -> pclr = 0 ; } dec -> numchans = dec -> cmap ? dec -> cmap -> data . cmap . numchans : JAS_CAST ( uint , jas_image_numcmpts ( dec -> image ) ) ; if ( dec -> cmap ) { for ( i = 0 ; i < dec -> numchans ; ++ i ) { if ( dec -> cmap -> data . cmap . ents [ i ] . cmptno >= JAS_CAST ( uint , jas_image_numcmpts ( dec -> image ) ) ) { jas_eprintf ( ""error:invalidcomponentnumberinCMAPbox\\n"" ) ; goto error ; } if ( dec -> cmap -> data . cmap . ents [ i ] . pcol >= dec -> pclr -> data . pclr . numchans ) { jas_eprintf ( ""error:invalidCMAPLUTindex\\n"" ) ; goto error ; } } } if ( ! ( dec -> chantocmptlut = jas_alloc2 ( dec -> numchans , sizeof ( uint_fast16_t ) ) ) ) { jas_eprintf ( ""error:nomemory\\n"" ) ; goto error ; } if ( ! dec -> cmap ) { for ( i = 0 ; i < dec -> numchans ; ++ i ) { dec -> chantocmptlut [ i ] = i ; } } else { cmapd = & dec -> cmap -> data . cmap ; pclrd = & dec -> pclr -> data . pclr ; cdefd = & dec -> cdef -> data . cdef ; for ( channo = 0 ; channo < cmapd -> numchans ; ++ channo ) { cmapent = & cmapd -> ents [ channo ] ; if ( cmapent -> map == JP2_CMAP_DIRECT ) { dec -> chantocmptlut [ channo ] = channo ; } else if ( cmapent -> map == JP2_CMAP_PALETTE ) { lutents = jas_alloc2 ( pclrd -> numlutents , sizeof ( int_fast32_t ) ) ; for ( i = 0 ; i < pclrd -> numlutents ; ++ i ) { lutents [ i ] = pclrd -> lutdata [ cmapent -> pcol + i * pclrd -> numchans ] ; } newcmptno = jas_image_numcmpts ( dec -> image ) ; jas_image_depalettize ( dec -> image , cmapent -> cmptno , pclrd -> numlutents , lutents , JP2_BPCTODTYPE ( pclrd -> bpc [ cmapent -> pcol ] ) , newcmptno ) ; dec -> chantocmptlut [ channo ] = newcmptno ; jas_free ( lutents ) ; # if 0 if ( dec -> cdef ) { cdefent = jp2_cdef_lookup ( cdefd , channo ) ; if ( ! cdefent ) { abort ( ) ; } jas_image_setcmpttype ( dec -> image , newcmptno , jp2_getct ( jas_image_clrspc ( dec -> image ) , cdefent -> type , cdefent -> assoc ) ) ; } else { jas_image_setcmpttype ( dec -> image , newcmptno , jp2_getct ( jas_image_clrspc ( dec -> image ) , 0 , channo + 1 ) ) ; } # endif } } } for ( i = 0 ; i < JAS_CAST ( uint , jas_image_numcmpts ( dec -> image ) ) ; ++ i ) { jas_image_setcmpttype ( dec -> image , i , JAS_IMAGE_CT_UNKNOWN ) ; } if ( dec -> cdef ) { for ( i = 0 ; i < dec -> numchans ; ++ i ) { if ( dec -> cdef -> data . cdef . ents [ i ] . channo >= dec -> numchans ) { jas_eprintf ( ""error:invalidchannelnumberinCDEFbox\\n"" ) ; goto error ; } jas_image_setcmpttype ( dec -> image , dec -> chantocmptlut [ dec -> cdef -> data . cdef . ents [ i ] . channo ] , jp2_getct ( jas_image_clrspc ( dec -> image ) , dec -> cdef -> data . cdef . ents [ i ] . type , dec -> cdef -> data . cdef . ents [ i ] . assoc ) ) ; } } else { for ( i = 0 ; i < dec -> numchans ; ++ i ) { jas_image_setcmpttype ( dec -> image , dec -> chantocmptlut [ i ] , jp2_getct ( jas_image_clrspc ( dec -> image ) , 0 , i + 1 ) ) ; } } for ( i = jas_image_numcmpts ( dec -> image ) ; i > 0 ; -- i ) { if ( jas_image_cmpttype ( dec -> image , i - 1 ) == JAS_IMAGE_CT_UNKNOWN ) { jas_image_delcmpt ( dec -> image , i - 1 ) ; } } if ( ! jas_image_numcmpts ( dec -> image ) ) { jas_eprintf ( ""error:nocomponents\\n"" ) ; goto error ; } # if 0 jas_eprintf ( ""noofcomponentsis%d\\n"" , jas_image_numcmpts ( dec -> image ) ) ; # endif image = dec -> image ; dec -> image = 0 ; jp2_dec_destroy ( dec ) ; return image ; error : if ( box ) { jp2_box_destroy ( box ) ; } if ( dec ) { jp2_dec_destroy ( dec ) ; } return 0 ; } "," { jas_eprintf ( ""gotboxtype%s\\n"" , box -> ",mdadams@jasper/e24bdc716c3327b067c551bc6cfb97fd2370358d,CVE-2016-8887,https://github.com/mdadams/jasper/commit/e24bdc716c3327b067c551bc6cfb97fd2370358d,2017-03-23T18:59Z 1235,CWE-732,"CWE-732 static M_bool M_fs_check_overwrite_allowed ( const char * p1 , const char * p2 , M_uint32 mode ) { M_fs_info_t * info = NULL ; char * pold = NULL ; char * pnew = NULL ; M_fs_type_t type ; M_bool ret = M_TRUE ; if ( mode & M_FS_FILE_MODE_OVERWRITE ) return M_TRUE ; if ( M_fs_info ( & info , p1 , M_FS_PATH_INFO_FLAGS_BASIC ) != M_FS_ERROR_SUCCESS ) return M_FALSE ; type = M_fs_info_get_type ( info ) ; M_fs_info_destroy ( info ) ; if ( type != M_FS_TYPE_DIR ) { if ( M_fs_perms_can_access ( p2 , M_FS_PERMS_MODE_NONE ) == M_FS_ERROR_SUCCESS ) { ret = M_FALSE ; goto done ; } } pold = M_fs_path_basename ( p1 , M_FS_SYSTEM_AUTO ) ; pnew = M_fs_path_join ( p2 , pnew , M_FS_SYSTEM_AUTO ) ; if ( M_fs_perms_can_access ( pnew , M_FS_PERMS_MODE_NONE ) == M_FS_ERROR_SUCCESS ) { ret = M_FALSE ; goto done ; } done : M_free ( pnew ) ; M_free ( pold ) ; return ret ; } "," ",Monetra@mstdlib/db124b8f607dd0a40a9aef2d4d468fad433522a7,CVE-2018-14043,https://github.com/Monetra/mstdlib/commit/db124b8f607dd0a40a9aef2d4d468fad433522a7,2018-07-13T14:29Z 1236,CWE-189,"CWE-189 int sequencer_write ( int dev , struct file * file , const char __user * buf , int count ) { unsigned char event_rec [ EV_SZ ] , ev_code ; int p = 0 , c , ev_size ; int mode = translate_mode ( file ) ; dev = dev >> 4 ; DEB ( printk ( ""sequencer_write(dev=%d,count=%d)\\n"" , dev , count ) ) ; if ( mode == OPEN_READ ) return - EIO ; c = count ; while ( c >= 4 ) { if ( copy_from_user ( ( char * ) event_rec , & ( buf ) [ p ] , 4 ) ) goto out ; ev_code = event_rec [ 0 ] ; if ( ev_code == SEQ_FULLSIZE ) { int err , fmt ; dev = * ( unsigned short * ) & event_rec [ 2 ] ; if ( dev < 0 || dev >= max_synthdev || synth_devs [ dev ] == NULL ) return - ENXIO ; if ( ! ( synth_open_mask & ( 1 << dev ) ) ) return - ENXIO ; fmt = ( * ( short * ) & event_rec [ 0 ] ) & 0xffff ; err = synth_devs [ dev ] -> load_patch ( dev , fmt , buf , p + 4 , c , 0 ) ; if ( err < 0 ) return err ; return err ; } if ( ev_code >= 128 ) { if ( seq_mode == SEQ_2 && ev_code == SEQ_EXTENDED ) { printk ( KERN_WARNING ""Sequencer:Invalidlevel2event%x\\n"" , ev_code ) ; return - EINVAL ; } ev_size = 8 ; if ( c < ev_size ) { if ( ! seq_playing ) seq_startplay ( ) ; return count - c ; } if ( copy_from_user ( ( char * ) & event_rec [ 4 ] , & ( buf ) [ p + 4 ] , 4 ) ) goto out ; } else { if ( seq_mode == SEQ_2 ) { printk ( KERN_WARNING ""Sequencer:4byteeventinlevel2mode\\n"" ) ; return - EINVAL ; } ev_size = 4 ; if ( event_rec [ 0 ] != SEQ_MIDIPUTC ) obsolete_api_used = 1 ; } if ( event_rec [ 0 ] == SEQ_MIDIPUTC ) { if ( ! midi_opened [ event_rec [ 2 ] ] ) { int err , mode ; int dev = event_rec [ 2 ] ; if ( dev >= max_mididev || midi_devs [ dev ] == NULL ) { return - ENXIO ; } mode = translate_mode ( file ) ; if ( ( err = midi_devs [ dev ] -> open ( dev , mode , sequencer_midi_input , sequencer_midi_output ) ) < 0 ) { seq_reset ( ) ; printk ( KERN_WARNING ""SequencerError:UnabletoopenMidi#%d\\n"" , dev ) ; return err ; } midi_opened [ dev ] = 1 ; } } if ( ! seq_queue ( event_rec , ( file -> f_flags & ( O_NONBLOCK ) ? 1 : 0 ) ) ) { int processed = count - c ; if ( ! seq_playing ) seq_startplay ( ) ; if ( ! processed && ( file -> f_flags & O_NONBLOCK ) ) return - EAGAIN ; else return processed ; } p += ev_size ; c -= ev_size ; } if ( ! seq_playing ) seq_startplay ( ) ; out : return count ; } "," fmt , buf + p , c , ",torvalds@linux/b769f49463711205d57286e64cf535ed4daf59e9,CVE-2011-1476,https://github.com/torvalds/linux/commit/b769f49463711205d57286e64cf535ed4daf59e9,2012-06-21T23:55Z 1237,CWE-000,"CWE-000 static void ext4_invalidatepage ( struct page * page , unsigned long offset ) { journal_t * journal = EXT4_JOURNAL ( page -> mapping -> host ) ; if ( offset == 0 ) ClearPageChecked ( page ) ; if ( journal ) jbd2_journal_invalidatepage ( journal , page , offset ) ; else block_invalidatepage ( page , offset ) ; } "," mapping -> host ) ; if ( ext4_should_dioread_nolock ( page -> mapping -> host ) ) ext4_invalidatepage_free_endio ( page , offset ",torvalds@linux/744692dc059845b2a3022119871846e74d4f6e11,CVE-2015-8324,https://github.com/torvalds/linux/commit/744692dc059845b2a3022119871846e74d4f6e11,2016-05-02T10:59Z 1238,CWE-476,"CWE-476 GF_Err SetupWriters ( MovieWriter * mw , GF_List * writers , u8 interleaving ) { u32 i , trackCount ; TrackWriter * writer ; GF_TrackBox * trak ; GF_ISOFile * movie = mw -> movie ; mw -> total_samples = mw -> nb_done = 0 ; if ( ! movie -> moov ) return GF_OK ; trackCount = gf_list_count ( movie -> moov -> trackList ) ; for ( i = 0 ; i < trackCount ; i ++ ) { trak = gf_isom_get_track ( movie -> moov , i + 1 ) ; GF_SAFEALLOC ( writer , TrackWriter ) ; if ( ! writer ) goto exit ; writer -> sampleNumber = 1 ; writer -> mdia = trak -> Media ; writer -> stbl = trak -> Media -> information -> sampleTable ; writer -> timeScale = trak -> Media -> mediaHeader -> timeScale ; writer -> all_dref_mode = Media_SelfContainedType ( writer -> mdia ) ; if ( trak -> sample_encryption ) writer -> prevent_dispatch = GF_TRUE ; writer -> isDone = 0 ; writer -> DTSprev = 0 ; writer -> chunkDur = 0 ; writer -> chunkSize = 0 ; writer -> constant_size = writer -> constant_dur = 0 ; if ( writer -> stbl -> SampleSize -> sampleSize ) writer -> constant_size = writer -> stbl -> SampleSize -> sampleSize ; if ( writer -> stbl -> TimeToSample -> nb_entries == 1 ) { writer -> constant_dur = writer -> stbl -> TimeToSample -> entries [ 0 ] . sampleDelta ; if ( writer -> constant_dur > 1 ) writer -> constant_dur = 0 ; } if ( ! writer -> constant_dur || ! writer -> constant_size || ( writer -> constant_size >= 10 ) ) writer -> constant_size = writer -> constant_dur = 0 ; writer -> stsc = ( GF_SampleToChunkBox * ) gf_isom_box_new ( GF_ISOM_BOX_TYPE_STSC ) ; if ( ! writer -> stsc ) return GF_OUT_OF_MEM ; if ( writer -> stbl -> ChunkOffset -> type == GF_ISOM_BOX_TYPE_STCO ) { writer -> stco = gf_isom_box_new ( GF_ISOM_BOX_TYPE_STCO ) ; } else { writer -> stco = gf_isom_box_new ( GF_ISOM_BOX_TYPE_CO64 ) ; } if ( ! writer -> stco ) return GF_OUT_OF_MEM ; if ( interleaving ) writer -> stbl -> MaxSamplePerChunk = 0 ; if ( Media_IsSelfContained ( writer -> mdia , 1 ) ) mw -> total_samples += writer -> stbl -> SampleSize -> sampleCount ; if ( movie -> storageMode != GF_ISOM_STORE_INTERLEAVED ) { gf_list_add ( writers , writer ) ; } else { if ( writer -> mdia -> information -> InfoHeader && writer -> mdia -> information -> InfoHeader -> type == GF_ISOM_BOX_TYPE_SMHD ) { gf_list_add ( writers , writer ) ; } else { gf_list_insert ( writers , writer , 0 ) ; } } if ( movie -> sample_groups_in_traf && trak -> Media -> information -> sampleTable ) { gf_isom_box_array_del_parent ( & trak -> Media -> information -> sampleTable -> child_boxes , trak -> Media -> information -> sampleTable -> sampleGroupsDescription ) ; trak -> Media -> information -> sampleTable -> sampleGroupsDescription = NULL ; } } return GF_OK ; exit : CleanWriters ( writers ) ; return GF_OUT_OF_MEM ; } "," ++ ) { GF_SampleTableBox * stbl ; 1 ) ; stbl = ( trak -> Media && trak -> Media -> information ) ? trak -> Media -> information -> sampleTable : NULL ; if ( ! stbl || ! stbl -> SampleSize || ! stbl -> ChunkOffset || ! stbl -> SampleToChunk ) { return GF_ISOM_INVALID_FILE ; } ",gpac@gpac/dae9900580a8888969481cd72035408091edb11b,CVE-2020-35981,https://github.com/gpac/gpac/commit/dae9900580a8888969481cd72035408091edb11b,2021-04-21T16:15Z 1239,CWE-787,"CWE-787 static UINT32 nsc_rle_encode ( BYTE * in , BYTE * out , UINT32 originalSize ) { UINT32 left ; UINT32 runlength = 1 ; UINT32 planeSize = 0 ; left = originalSize ; while ( left > 4 && planeSize < originalSize - 4 ) { if ( left > 5 && * in == * ( in + 1 ) ) { runlength ++ ; } else if ( runlength == 1 ) { * out ++ = * in ; planeSize ++ ; } else if ( runlength < 256 ) { * out ++ = * in ; * out ++ = * in ; * out ++ = runlength - 2 ; runlength = 1 ; planeSize += 3 ; } else { * out ++ = * in ; * out ++ = * in ; * out ++ = 0xFF ; * out ++ = ( runlength & 0x000000FF ) ; * out ++ = ( runlength & 0x0000FF00 ) >> 8 ; * out ++ = ( runlength & 0x00FF0000 ) >> 16 ; * out ++ = ( runlength & 0xFF000000 ) >> 24 ; runlength = 1 ; planeSize += 7 ; } in ++ ; left -- ; } if ( planeSize < originalSize - 4 ) CopyMemory ( out , in , 4 ) ; planeSize += 4 ; return planeSize ; } "," UINT32 nsc_rle_encode ( const ",FreeRDP@FreeRDP/d1112c279bd1a327e8e4d0b5f371458bf2579659,CVE-2018-8788,https://github.com/FreeRDP/FreeRDP/commit/d1112c279bd1a327e8e4d0b5f371458bf2579659,2018-11-29T18:29Z 1240,CWE-119,"CWE-119 static void send_auth ( char * username , char * password ) { struct mt_packet data ; unsigned short width = 0 ; unsigned short height = 0 ; char * terminal = getenv ( ""TERM"" ) ; char md5data [ 100 ] ; unsigned char md5sum [ 17 ] ; int plen ; md5_state_t state ; # if defined ( __linux__ ) && defined ( _POSIX_MEMLOCK_RANGE ) mlock ( md5data , sizeof ( md5data ) ) ; mlock ( md5sum , sizeof ( md5data ) ) ; # endif md5data [ 0 ] = 0 ; strncpy ( md5data + 1 , password , 82 ) ; md5data [ 83 ] = '\\0' ; memcpy ( md5data + 1 + strlen ( password ) , pass_salt , 16 ) ; md5_init ( & state ) ; md5_append ( & state , ( const md5_byte_t * ) md5data , strlen ( password ) + 17 ) ; md5_finish ( & state , ( md5_byte_t * ) md5sum + 1 ) ; md5sum [ 0 ] = 0 ; init_packet ( & data , MT_PTYPE_DATA , srcmac , dstmac , sessionkey , outcounter ) ; plen = add_control_packet ( & data , MT_CPTYPE_PASSWORD , md5sum , 17 ) ; plen += add_control_packet ( & data , MT_CPTYPE_USERNAME , username , strlen ( username ) ) ; plen += add_control_packet ( & data , MT_CPTYPE_TERM_TYPE , terminal , strlen ( terminal ) ) ; if ( is_a_tty && get_terminal_size ( & width , & height ) != - 1 ) { width = htole16 ( width ) ; height = htole16 ( height ) ; plen += add_control_packet ( & data , MT_CPTYPE_TERM_WIDTH , & width , 2 ) ; plen += add_control_packet ( & data , MT_CPTYPE_TERM_HEIGHT , & height , 2 ) ; } outcounter += plen ; send_udp ( & data , 1 ) ; } "," ; int plen , act_pass_len ; # endif act_pass_len = strnlen ( password , 82 ) ; = 0 ; memcpy ( md5data + , password , act_pass_len ) ; memcpy ( + 1 + act_pass_len , pass_salt , ) md5data , 1 + act_pass_len + 16 ) ; md5_finish ",haakonnessjoen@MAC-Telnet/b69d11727d4f0f8cf719c79e3fb700f55ca03e9a,CVE-2016-7115,https://github.com/haakonnessjoen/MAC-Telnet/commit/b69d11727d4f0f8cf719c79e3fb700f55ca03e9a,2016-08-30T17:59Z 1241,CWE-000,"CWE-000 void * Sys_LoadDll ( const char * name , qboolean useSystemLib ) { void * dllhandle ; if ( useSystemLib ) Com_Printf ( ""Tryingtoload\\""%s\\""...\\n"" , name ) ; if ( ! useSystemLib || ! ( dllhandle = Sys_LoadLibrary ( name ) ) ) { const char * topDir ; char libPath [ MAX_OSPATH ] ; topDir = Sys_BinaryPath ( ) ; if ( ! * topDir ) topDir = ""."" ; Com_Printf ( ""Tryingtoload\\""%s\\""from\\""%s\\""...\\n"" , name , topDir ) ; Com_sprintf ( libPath , sizeof ( libPath ) , ""%s%c%s"" , topDir , PATH_SEP , name ) ; if ( ! ( dllhandle = Sys_LoadLibrary ( libPath ) ) ) { const char * basePath = Cvar_VariableString ( ""fs_basepath"" ) ; if ( ! basePath || ! * basePath ) basePath = ""."" ; if ( FS_FilenameCompare ( topDir , basePath ) ) { Com_Printf ( ""Tryingtoload\\""%s\\""from\\""%s\\""...\\n"" , name , basePath ) ; Com_sprintf ( libPath , sizeof ( libPath ) , ""%s%c%s"" , basePath , PATH_SEP , name ) ; dllhandle = Sys_LoadLibrary ( libPath ) ; } if ( ! dllhandle ) Com_Printf ( ""Loading\\""%s\\""failed\\n"" , name ) ; } } return dllhandle ; } "," * dllhandle ; if ( COM_CompareExtension ( name , "".pk3"" ) ) { Com_Printf ( ""RejectingDLLnamed\\""%s\\"""" , name ) ; return NULL ; } ",JACoders@OpenJK/b6ff2bcb1e4e6976d61e316175c6d7c99860fe20,CVE-2017-6903,https://github.com/JACoders/OpenJK/commit/b6ff2bcb1e4e6976d61e316175c6d7c99860fe20,2017-03-14T22:59Z 1242,CWE-59,"CWE-59 void shutdown_mib ( void ) { unload_all_mibs ( ) ; if ( tree_top ) { if ( tree_top -> label ) SNMP_FREE ( tree_top -> label ) ; SNMP_FREE ( tree_top ) ; } tree_head = NULL ; Mib = NULL ; if ( _mibindexes ) { int i ; for ( i = 0 ; i < _mibindex ; ++ i ) SNMP_FREE ( _mibindexes [ i ] ) ; free ( _mibindexes ) ; _mibindex = 0 ; _mibindex_max = 0 ; _mibindexes = NULL ; } if ( Prefix != NULL && Prefix != & Standard_Prefix [ 0 ] ) SNMP_FREE ( Prefix ) ; if ( Prefix ) Prefix = NULL ; SNMP_FREE ( confmibs ) ; SNMP_FREE ( confmibdir ) ; } "," ; if ( Prefix != NULL ",net-snmp@net-snmp/4fd9a450444a434a993bc72f7c3486ccce41f602,CVE-2020-15861,https://github.com/net-snmp/net-snmp/commit/4fd9a450444a434a993bc72f7c3486ccce41f602,2020-08-20T01:17Z 1243,CWE-401,"CWE-401 static MagickBooleanType DecodeImage ( Image * image , unsigned char * luma , unsigned char * chroma1 , unsigned char * chroma2 , ExceptionInfo * exception ) { # define IsSync ( sum ) ( ( sum & 0xffffff00UL ) == 0xfffffe00UL ) # define PCDGetBits ( n ) { sum = ( sum << n ) & 0xffffffff ; bits -= n ; while ( bits <= 24 ) { if ( p >= ( buffer + 0x800 ) ) { count = ReadBlob ( image , 0x800 , buffer ) ; p = buffer ; } sum |= ( ( unsigned int ) ( * p ) << ( 24 - bits ) ) ; bits += 8 ; p ++ ; } } typedef struct PCDTable { unsigned int length , sequence ; MagickStatusType mask ; unsigned char key ; } PCDTable ; PCDTable * pcd_table [ 3 ] ; register ssize_t i , j ; register PCDTable * r ; register unsigned char * p , * q ; size_t bits , length , plane , pcd_length [ 3 ] , row , sum ; ssize_t count , quantum ; unsigned char * buffer ; assert ( image != ( const Image * ) NULL ) ; assert ( image -> signature == MagickCoreSignature ) ; if ( image -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image -> filename ) ; assert ( luma != ( unsigned char * ) NULL ) ; assert ( chroma1 != ( unsigned char * ) NULL ) ; assert ( chroma2 != ( unsigned char * ) NULL ) ; buffer = ( unsigned char * ) AcquireQuantumMemory ( 0x800 , sizeof ( * buffer ) ) ; if ( buffer == ( unsigned char * ) NULL ) ThrowBinaryException ( ResourceLimitError , ""MemoryAllocationFailed"" , image -> filename ) ; sum = 0 ; bits = 32 ; p = buffer + 0x800 ; for ( i = 0 ; i < 3 ; i ++ ) { pcd_table [ i ] = ( PCDTable * ) NULL ; pcd_length [ i ] = 0 ; } for ( i = 0 ; i < ( image -> columns > 1536 ? 3 : 1 ) ; i ++ ) { PCDGetBits ( 8 ) ; length = ( sum & 0xff ) + 1 ; pcd_table [ i ] = ( PCDTable * ) AcquireQuantumMemory ( length , sizeof ( * pcd_table [ i ] ) ) ; if ( pcd_table [ i ] == ( PCDTable * ) NULL ) { buffer = ( unsigned char * ) RelinquishMagickMemory ( buffer ) ; ThrowBinaryException ( ResourceLimitError , ""MemoryAllocationFailed"" , image -> filename ) ; } r = pcd_table [ i ] ; for ( j = 0 ; j < ( ssize_t ) length ; j ++ ) { PCDGetBits ( 8 ) ; r -> length = ( unsigned int ) ( sum & 0xff ) + 1 ; if ( r -> length > 16 ) { buffer = ( unsigned char * ) RelinquishMagickMemory ( buffer ) ; return ( MagickFalse ) ; } PCDGetBits ( 16 ) ; r -> sequence = ( unsigned int ) ( sum & 0xffff ) << 16 ; PCDGetBits ( 8 ) ; r -> key = ( unsigned char ) ( sum & 0xff ) ; r -> mask = ( ~ ( ( 1U << ( 32 - r -> length ) ) - 1 ) ) ; r ++ ; } pcd_length [ i ] = ( size_t ) length ; } for ( i = 0 ; i < 1 ; i ++ ) PCDGetBits ( 16 ) ; for ( i = 0 ; i < 1 ; i ++ ) PCDGetBits ( 16 ) ; while ( ( sum & 0x00fff000UL ) != 0x00fff000UL ) PCDGetBits ( 8 ) ; while ( IsSync ( sum ) == 0 ) PCDGetBits ( 1 ) ; count = 0 ; length = 0 ; plane = 0 ; row = 0 ; q = luma ; for ( ; ; ) { if ( IsSync ( sum ) != 0 ) { PCDGetBits ( 16 ) ; row = ( ( sum >> 9 ) & 0x1fff ) ; if ( row == image -> rows ) break ; PCDGetBits ( 8 ) ; plane = sum >> 30 ; PCDGetBits ( 16 ) ; switch ( plane ) { case 0 : { q = luma + row * image -> columns ; count = ( ssize_t ) image -> columns ; break ; } case 2 : { q = chroma1 + ( row >> 1 ) * image -> columns ; count = ( ssize_t ) ( image -> columns >> 1 ) ; plane -- ; break ; } case 3 : { q = chroma2 + ( row >> 1 ) * image -> columns ; count = ( ssize_t ) ( image -> columns >> 1 ) ; plane -- ; break ; } default : { for ( i = 0 ; i < ( image -> columns > 1536 ? 3 : 1 ) ; i ++ ) pcd_table [ i ] = ( PCDTable * ) RelinquishMagickMemory ( pcd_table [ i ] ) ; buffer = ( unsigned char * ) RelinquishMagickMemory ( buffer ) ; ThrowBinaryException ( CorruptImageError , ""CorruptImage"" , image -> filename ) ; } } length = pcd_length [ plane ] ; continue ; } r = pcd_table [ plane ] ; for ( i = 0 ; ( ( i < ( ssize_t ) length ) && ( ( sum & r -> mask ) != r -> sequence ) ) ; i ++ ) r ++ ; if ( ( row > image -> rows ) || ( r == ( PCDTable * ) NULL ) ) { ( void ) ThrowMagickException ( exception , GetMagickModule ( ) , CorruptImageWarning , ""SkipToSyncByte"" , ""`%s\'"" , image -> filename ) ; while ( ( sum & 0x00fff000 ) != 0x00fff000 ) PCDGetBits ( 8 ) ; while ( IsSync ( sum ) == 0 ) PCDGetBits ( 1 ) ; continue ; } if ( r -> key < 128 ) quantum = ( ssize_t ) ( * q ) + r -> key ; else quantum = ( ssize_t ) ( * q ) + r -> key - 256 ; * q = ( unsigned char ) ( ( quantum < 0 ) ? 0 : ( quantum > 255 ) ? 255 : quantum ) ; q ++ ; PCDGetBits ( r -> length ) ; count -- ; } for ( i = 0 ; i < ( image -> columns > 1536 ? 3 : 1 ) ; i ++ ) pcd_table [ i ] = ( PCDTable * ) RelinquishMagickMemory ( pcd_table [ i ] ) ; buffer = ( unsigned char * ) RelinquishMagickMemory ( buffer ) ; return ( MagickTrue ) ; } "," ( n ) \\\n{ sum = ( ++ ; } \\\n} typedef struct PCDTable buffer ) ; for ( j = 0 ; j < i ; j ++ ) pcd_table [ j ] = ( PCDTable * ) RelinquishMagickMemory ( pcd_table [ j ] ) ; RelinquishMagickMemory ( buffer ) ; for ( j = 0 ; j <= i ; j ++ ) pcd_table [ j ] = ( PCDTable * ) RelinquishMagickMemory ( pcd_table [ j ] ",ImageMagick@ImageMagick/1e6a3ace073c9ec9c71e439c111d23c6e66cb6ae,CVE-2019-7175,https://github.com/ImageMagick/ImageMagick/commit/1e6a3ace073c9ec9c71e439c111d23c6e66cb6ae,2019-03-07T23:29Z 1244,CWE-125,"CWE-125 static int handle_keywordonly_args ( struct compiling * c , const node * n , int start , asdl_seq * kwonlyargs , asdl_seq * kwdefaults ) { PyObject * argname ; node * ch ; expr_ty expression , annotation ; arg_ty arg = NULL ; int i = start ; int j = 0 ; if ( kwonlyargs == NULL ) { ast_error ( c , CHILD ( n , start ) , ""namedargumentsmustfollowbare*"" ) ; return - 1 ; } assert ( kwdefaults != NULL ) ; while ( i < NCH ( n ) ) { ch = CHILD ( n , i ) ; switch ( TYPE ( ch ) ) { case vfpdef : case tfpdef : if ( i + 1 < NCH ( n ) && TYPE ( CHILD ( n , i + 1 ) ) == EQUAL ) { expression = ast_for_expr ( c , CHILD ( n , i + 2 ) ) ; if ( ! expression ) goto error ; asdl_seq_SET ( kwdefaults , j , expression ) ; i += 2 ; } else { asdl_seq_SET ( kwdefaults , j , NULL ) ; } if ( NCH ( ch ) == 3 ) { annotation = ast_for_expr ( c , CHILD ( ch , 2 ) ) ; if ( ! annotation ) goto error ; } else { annotation = NULL ; } ch = CHILD ( ch , 0 ) ; argname = NEW_IDENTIFIER ( ch ) ; if ( ! argname ) goto error ; if ( forbidden_name ( c , argname , ch , 0 ) ) goto error ; arg = arg ( argname , annotation , NULL , LINENO ( ch ) , ch -> n_col_offset , c -> c_arena ) ; if ( ! arg ) goto error ; asdl_seq_SET ( kwonlyargs , j ++ , arg ) ; i += 1 ; if ( TYPE ( CHILD ( n , i ) ) == COMMA ) i += 1 ; break ; case TYPE_COMMENT : arg -> type_comment = NEW_TYPE_COMMENT ( ch ) ; if ( ! arg -> type_comment ) goto error ; i += 1 ; break ; case DOUBLESTAR : return i ; default : ast_error ( c , ch , ""unexpectednode"" ) ; goto error ; } } return i ; error : return - 1 ; } "," ; if ( i < NCH ( n ) && ",python@typed_ast/dc317ac9cff859aa84eeabe03fb5004982545b3b,CVE-2019-19275,https://github.com/python/typed_ast/commit/dc317ac9cff859aa84eeabe03fb5004982545b3b,2019-11-26T15:15Z 1245,CWE-20,"CWE-20 static void test_headers_bad ( Test * test , gconstpointer data ) { GHashTable * headers ; headers = web_socket_util_new_headers ( ) ; g_hash_table_insert ( headers , g_strdup ( ""Cookie"" ) , g_strdup ( ""CockpitAuth=v=1;k=blah"" ) ) ; if ( cockpit_auth_check_cookie ( test -> auth , ""/cockpit"" , headers ) ) g_assert_not_reached ( ) ; g_hash_table_remove_all ( headers ) ; g_hash_table_insert ( headers , g_strdup ( ""Cookie"" ) , g_strdup ( ""CockpitAuth=v=2;k=blah"" ) ) ; if ( cockpit_auth_check_cookie ( test -> auth , ""/cockpit"" , headers ) ) g_assert_not_reached ( ) ; g_hash_table_destroy ( headers ) ; } "," ( ) ; g_hash_table_remove_all ( headers ) ; g_hash_table_insert ( headers , g_strdup ( ""Cookie"" ) , g_strdup ( ""cockpit=d"" ) ) ; if ( cockpit_auth_check_cookie ( test -> auth , ""/cockpit"" , headers ) ) g_assert_not_reached ( ) ; ",cockpit-project@cockpit/c51f6177576d7e12614c64d316cf0b67addd17c9,CVE-2019-3804,https://github.com/cockpit-project/cockpit/commit/c51f6177576d7e12614c64d316cf0b67addd17c9,2019-03-26T18:29Z 1246,CWE-918,"CWE-918 static inline char * parse_ip_address_ex ( const char * str , size_t str_len , int * portno , int get_err , zend_string * * err ) { char * colon ; char * host = NULL ; # ifdef HAVE_IPV6 char * p ; if ( * ( str ) == '[' && str_len > 1 ) { p = memchr ( str + 1 , ']' , str_len - 2 ) ; if ( ! p || * ( p + 1 ) != ':' ) { if ( get_err ) { * err = strpprintf ( 0 , ""FailedtoparseIPv6address\\""%s\\"""" , str ) ; } return NULL ; } * portno = atoi ( p + 2 ) ; return estrndup ( str + 1 , p - str - 1 ) ; } # endif if ( str_len ) { colon = memchr ( str , ':' , str_len - 1 ) ; } else { colon = NULL ; } if ( colon ) { * portno = atoi ( colon + 1 ) ; host = estrndup ( str , colon - str ) ; } else { if ( get_err ) { * err = strpprintf ( 0 , ""Failedtoparseaddress\\""%s\\"""" , str ) ; } return NULL ; } return host ; } "," # ifdef HAVE_IPV6 if ( * 1 ) { char * - 2 ) , * e = NULL * portno = strtol ( p + p + 2 , & e , 10 ) ; if ( e && * e ) { if ( get_err ) { * err = strpprintf ( 0 , ""Failedtoparseaddress\\""%s\\"""" , str ) ; } return NULL ; } return estrndup ( colon ) { char * e = NULL ; * portno = strtol ( colon + 1 , & e , 10 ) ; if ( ! e || ! * e ) { return estrndup ( str ) ; } } if ( get_err NULL ; } ",php@php-src/bab0b99f376dac9170ac81382a5ed526938d595a,CVE-2017-7272,https://github.com/php/php-src/commit/bab0b99f376dac9170ac81382a5ed526938d595a,2017-03-27T17:59Z 1247,CWE-000,"CWE-000 static int jpc_qcd_dumpparms ( jpc_ms_t * ms , FILE * out ) { jpc_qcd_t * qcd = & ms -> parms . qcd ; int i ; fprintf ( out , ""qntsty=%d;numguard=%d;numstepsizes=%d\\n"" , ( int ) qcd -> compparms . qntsty , qcd -> compparms . numguard , qcd -> compparms . numstepsizes ) ; for ( i = 0 ; i < qcd -> compparms . numstepsizes ; ++ i ) { fprintf ( out , ""expn[%d]=0x%04x;mant[%d]=0x%04x;\\n"" , i , ( unsigned ) JPC_QCX_GETEXPN ( qcd -> compparms . stepsizes [ i ] ) , i , ( unsigned ) JPC_QCX_GETMANT ( qcd -> compparms . stepsizes [ i ] ) ) ; } return 0 ; } "," , i , JAS_CAST ( unsigned , JPC_QCX_GETEXPN ( qcd i ] ) ) , i , JAS_CAST ( unsigned , JPC_QCX_GETMANT ( qcd ] ) ) ) ",mdadams@jasper/1e84674d95353c64e5c4c0e7232ae86fd6ea813b,CVE-2016-9391,https://github.com/mdadams/jasper/commit/1e84674d95353c64e5c4c0e7232ae86fd6ea813b,2017-03-23T18:59Z 1248,CWE-119,"CWE-119 void vpx_yv12_copy_y_c ( const YV12_BUFFER_CONFIG * src_ybc , YV12_BUFFER_CONFIG * dst_ybc ) { int row ; const uint8_t * src = src_ybc -> y_buffer ; uint8_t * dst = dst_ybc -> y_buffer ; for ( row = 0 ; row < src_ybc -> y_height ; ++ row ) { vpx_memcpy ( dst , src , src_ybc -> y_width ) ; src += src_ybc -> y_stride ; dst += dst_ybc -> y_stride ; } } "," -> y_buffer ; # if CONFIG_VP9_HIGHBITDEPTH if ( src_ybc -> flags & YV12_FLAG_HIGHBITDEPTH ) { const uint16_t * src16 = CONVERT_TO_SHORTPTR ( src ) ; uint16_t * dst16 = CONVERT_TO_SHORTPTR ( dst ) ; row ) { memcpy ( dst16 , src16 , src_ybc -> y_width * sizeof ( uint16_t ) ) ; src16 += src_ybc -> y_stride ; dst16 += dst_ybc -> y_stride ; } return ; } # endif for ( row = 0 ; row < src_ybc -> y_height ; ++ row ) { memcpy ( dst , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1249,CWE-119,"CWE-119 static int get_cox ( Jpeg2000DecoderContext * s , Jpeg2000CodingStyle * c ) { uint8_t byte ; if ( bytestream2_get_bytes_left ( & s -> g ) < 5 ) return AVERROR_INVALIDDATA ; c -> nreslevels = bytestream2_get_byteu ( & s -> g ) + 1 ; if ( c -> nreslevels >= JPEG2000_MAX_RESLEVELS ) { av_log ( s -> avctx , AV_LOG_ERROR , ""nreslevels%disinvalid\\n"" , c -> nreslevels ) ; return AVERROR_INVALIDDATA ; } if ( c -> nreslevels < s -> reduction_factor ) c -> nreslevels2decode = 1 ; else c -> nreslevels2decode = c -> nreslevels - s -> reduction_factor ; c -> log2_cblk_width = ( bytestream2_get_byteu ( & s -> g ) & 15 ) + 2 ; c -> log2_cblk_height = ( bytestream2_get_byteu ( & s -> g ) & 15 ) + 2 ; if ( c -> log2_cblk_width > 10 || c -> log2_cblk_height > 10 || c -> log2_cblk_width + c -> log2_cblk_height > 12 ) { av_log ( s -> avctx , AV_LOG_ERROR , ""cblksizeinvalid\\n"" ) ; return AVERROR_INVALIDDATA ; } c -> cblk_style = bytestream2_get_byteu ( & s -> g ) ; if ( c -> cblk_style != 0 ) { av_log ( s -> avctx , AV_LOG_WARNING , ""extracblkstyles%X\\n"" , c -> cblk_style ) ; } c -> transform = bytestream2_get_byteu ( & s -> g ) ; if ( ( s -> avctx -> flags & CODEC_FLAG_BITEXACT ) && ( c -> transform == FF_DWT97 ) ) c -> transform = FF_DWT97_INT ; if ( c -> csty & JPEG2000_CSTY_PREC ) { int i ; for ( i = 0 ; i < c -> nreslevels ; i ++ ) { byte = bytestream2_get_byte ( & s -> g ) ; c -> log2_prec_widths [ i ] = byte & 0x0F ; c -> log2_prec_heights [ i ] = ( byte >> 4 ) & 0x0F ; } } else { memset ( c -> log2_prec_widths , 15 , sizeof ( c -> log2_prec_widths ) ) ; memset ( c -> log2_prec_heights , 15 , sizeof ( c -> log2_prec_heights ) ) ; } return 0 ; } "," AVERROR_INVALIDDATA ; } if ( c -> log2_cblk_width > 6 || c -> log2_cblk_height > 6 ) { avpriv_request_sample ( s -> avctx , ""cblksize>64"" ) ; return AVERROR_PATCHWELCOME ; } ",FFmpeg@FFmpeg/9a271a9368eaabf99e6c2046103acb33957e63b7,CVE-2013-7018,https://github.com/FFmpeg/FFmpeg/commit/9a271a9368eaabf99e6c2046103acb33957e63b7,2013-12-09T16:36Z 1250,CWE-119,"CWE-119 void ourWriteOut ( CURL * curl , struct OutStruct * outs , const char * writeinfo ) { FILE * stream = stdout ; const char * ptr = writeinfo ; char * stringp = NULL ; long longinfo ; double doubleinfo ; while ( ptr && * ptr ) { if ( '%' == * ptr ) { if ( '%' == ptr [ 1 ] ) { fputc ( '%' , stream ) ; ptr += 2 ; } else { char * end ; char keepit ; int i ; if ( '{' == ptr [ 1 ] ) { bool match = FALSE ; end = strchr ( ptr , '}' ) ; ptr += 2 ; if ( ! end ) { fputs ( ""%{"" , stream ) ; continue ; } keepit = * end ; * end = 0 ; for ( i = 0 ; replacements [ i ] . name ; i ++ ) { if ( curl_strequal ( ptr , replacements [ i ] . name ) ) { match = TRUE ; switch ( replacements [ i ] . id ) { case VAR_EFFECTIVE_URL : if ( ( CURLE_OK == curl_easy_getinfo ( curl , CURLINFO_EFFECTIVE_URL , & stringp ) ) && stringp ) fputs ( stringp , stream ) ; break ; case VAR_HTTP_CODE : if ( CURLE_OK == curl_easy_getinfo ( curl , CURLINFO_RESPONSE_CODE , & longinfo ) ) fprintf ( stream , ""%03ld"" , longinfo ) ; break ; case VAR_HTTP_CODE_PROXY : if ( CURLE_OK == curl_easy_getinfo ( curl , CURLINFO_HTTP_CONNECTCODE , & longinfo ) ) fprintf ( stream , ""%03ld"" , longinfo ) ; break ; case VAR_HEADER_SIZE : if ( CURLE_OK == curl_easy_getinfo ( curl , CURLINFO_HEADER_SIZE , & longinfo ) ) fprintf ( stream , ""%ld"" , longinfo ) ; break ; case VAR_REQUEST_SIZE : if ( CURLE_OK == curl_easy_getinfo ( curl , CURLINFO_REQUEST_SIZE , & longinfo ) ) fprintf ( stream , ""%ld"" , longinfo ) ; break ; case VAR_NUM_CONNECTS : if ( CURLE_OK == curl_easy_getinfo ( curl , CURLINFO_NUM_CONNECTS , & longinfo ) ) fprintf ( stream , ""%ld"" , longinfo ) ; break ; case VAR_REDIRECT_COUNT : if ( CURLE_OK == curl_easy_getinfo ( curl , CURLINFO_REDIRECT_COUNT , & longinfo ) ) fprintf ( stream , ""%ld"" , longinfo ) ; break ; case VAR_REDIRECT_TIME : if ( CURLE_OK == curl_easy_getinfo ( curl , CURLINFO_REDIRECT_TIME , & doubleinfo ) ) fprintf ( stream , ""%.6f"" , doubleinfo ) ; break ; case VAR_TOTAL_TIME : if ( CURLE_OK == curl_easy_getinfo ( curl , CURLINFO_TOTAL_TIME , & doubleinfo ) ) fprintf ( stream , ""%.6f"" , doubleinfo ) ; break ; case VAR_NAMELOOKUP_TIME : if ( CURLE_OK == curl_easy_getinfo ( curl , CURLINFO_NAMELOOKUP_TIME , & doubleinfo ) ) fprintf ( stream , ""%.6f"" , doubleinfo ) ; break ; case VAR_CONNECT_TIME : if ( CURLE_OK == curl_easy_getinfo ( curl , CURLINFO_CONNECT_TIME , & doubleinfo ) ) fprintf ( stream , ""%.6f"" , doubleinfo ) ; break ; case VAR_APPCONNECT_TIME : if ( CURLE_OK == curl_easy_getinfo ( curl , CURLINFO_APPCONNECT_TIME , & doubleinfo ) ) fprintf ( stream , ""%.6f"" , doubleinfo ) ; break ; case VAR_PRETRANSFER_TIME : if ( CURLE_OK == curl_easy_getinfo ( curl , CURLINFO_PRETRANSFER_TIME , & doubleinfo ) ) fprintf ( stream , ""%.6f"" , doubleinfo ) ; break ; case VAR_STARTTRANSFER_TIME : if ( CURLE_OK == curl_easy_getinfo ( curl , CURLINFO_STARTTRANSFER_TIME , & doubleinfo ) ) fprintf ( stream , ""%.6f"" , doubleinfo ) ; break ; case VAR_SIZE_UPLOAD : if ( CURLE_OK == curl_easy_getinfo ( curl , CURLINFO_SIZE_UPLOAD , & doubleinfo ) ) fprintf ( stream , ""%.0f"" , doubleinfo ) ; break ; case VAR_SIZE_DOWNLOAD : if ( CURLE_OK == curl_easy_getinfo ( curl , CURLINFO_SIZE_DOWNLOAD , & doubleinfo ) ) fprintf ( stream , ""%.0f"" , doubleinfo ) ; break ; case VAR_SPEED_DOWNLOAD : if ( CURLE_OK == curl_easy_getinfo ( curl , CURLINFO_SPEED_DOWNLOAD , & doubleinfo ) ) fprintf ( stream , ""%.3f"" , doubleinfo ) ; break ; case VAR_SPEED_UPLOAD : if ( CURLE_OK == curl_easy_getinfo ( curl , CURLINFO_SPEED_UPLOAD , & doubleinfo ) ) fprintf ( stream , ""%.3f"" , doubleinfo ) ; break ; case VAR_CONTENT_TYPE : if ( ( CURLE_OK == curl_easy_getinfo ( curl , CURLINFO_CONTENT_TYPE , & stringp ) ) && stringp ) fputs ( stringp , stream ) ; break ; case VAR_FTP_ENTRY_PATH : if ( ( CURLE_OK == curl_easy_getinfo ( curl , CURLINFO_FTP_ENTRY_PATH , & stringp ) ) && stringp ) fputs ( stringp , stream ) ; break ; case VAR_REDIRECT_URL : if ( ( CURLE_OK == curl_easy_getinfo ( curl , CURLINFO_REDIRECT_URL , & stringp ) ) && stringp ) fputs ( stringp , stream ) ; break ; case VAR_SSL_VERIFY_RESULT : if ( CURLE_OK == curl_easy_getinfo ( curl , CURLINFO_SSL_VERIFYRESULT , & longinfo ) ) fprintf ( stream , ""%ld"" , longinfo ) ; break ; case VAR_PROXY_SSL_VERIFY_RESULT : if ( CURLE_OK == curl_easy_getinfo ( curl , CURLINFO_PROXY_SSL_VERIFYRESULT , & longinfo ) ) fprintf ( stream , ""%ld"" , longinfo ) ; break ; case VAR_EFFECTIVE_FILENAME : if ( outs -> filename ) fprintf ( stream , ""%s"" , outs -> filename ) ; break ; case VAR_PRIMARY_IP : if ( CURLE_OK == curl_easy_getinfo ( curl , CURLINFO_PRIMARY_IP , & stringp ) ) fprintf ( stream , ""%s"" , stringp ) ; break ; case VAR_PRIMARY_PORT : if ( CURLE_OK == curl_easy_getinfo ( curl , CURLINFO_PRIMARY_PORT , & longinfo ) ) fprintf ( stream , ""%ld"" , longinfo ) ; break ; case VAR_LOCAL_IP : if ( CURLE_OK == curl_easy_getinfo ( curl , CURLINFO_LOCAL_IP , & stringp ) ) fprintf ( stream , ""%s"" , stringp ) ; break ; case VAR_LOCAL_PORT : if ( CURLE_OK == curl_easy_getinfo ( curl , CURLINFO_LOCAL_PORT , & longinfo ) ) fprintf ( stream , ""%ld"" , longinfo ) ; break ; case VAR_HTTP_VERSION : if ( CURLE_OK == curl_easy_getinfo ( curl , CURLINFO_HTTP_VERSION , & longinfo ) ) { const char * version = ""0"" ; switch ( longinfo ) { case CURL_HTTP_VERSION_1_0 : version = ""1.0"" ; break ; case CURL_HTTP_VERSION_1_1 : version = ""1.1"" ; break ; case CURL_HTTP_VERSION_2_0 : version = ""2"" ; break ; } fprintf ( stream , version ) ; } break ; case VAR_SCHEME : if ( CURLE_OK == curl_easy_getinfo ( curl , CURLINFO_SCHEME , & stringp ) ) fprintf ( stream , ""%s"" , stringp ) ; break ; default : break ; } break ; } } if ( ! match ) { fprintf ( stderr , ""curl:unknown--write-outvariable:\'%s\'\\n"" , ptr ) ; } ptr = end + 1 ; * end = keepit ; } else { fputc ( '%' , stream ) ; fputc ( ptr [ 1 ] , stream ) ; ptr += 2 ; } } } else if ( '\\\\' == * ptr ) { switch ( ptr [ 1 ] ) { case 'r' : fputc ( '\\r' , stream ) ; break ; case 'n' : fputc ( '\\n' , stream ) ; break ; case 't' : fputc ( '\\t' , stream ) ; break ; default : fputc ( * ptr , stream ) ; fputc ( ptr [ 1 ] , stream ) ; break ; } ptr += 2 ; } else { fputc ( * ptr , stream ) ; ptr ++ ; } } } "," == * ptr && ptr [ 1 ] ",curl@curl/1890d59905414ab84a35892b2e45833654aa5c13,CVE-2017-7407,https://github.com/curl/curl/commit/1890d59905414ab84a35892b2e45833654aa5c13,2017-04-03T20:59Z 1251,CWE-119,"CWE-119 static void encode_rd_sb_row ( VP9_COMP * cpi , const TileInfo * const tile , int mi_row , TOKENEXTRA * * tp ) { VP9_COMMON * const cm = & cpi -> common ; MACROBLOCKD * const xd = & cpi -> mb . e_mbd ; SPEED_FEATURES * const sf = & cpi -> sf ; int mi_col ; vpx_memset ( & xd -> left_context , 0 , sizeof ( xd -> left_context ) ) ; vpx_memset ( xd -> left_seg_context , 0 , sizeof ( xd -> left_seg_context ) ) ; for ( mi_col = tile -> mi_col_start ; mi_col < tile -> mi_col_end ; mi_col += MI_BLOCK_SIZE ) { int dummy_rate ; int64_t dummy_dist ; BLOCK_SIZE i ; MACROBLOCK * x = & cpi -> mb ; if ( sf -> adaptive_pred_interp_filter ) { for ( i = BLOCK_4X4 ; i < BLOCK_8X8 ; ++ i ) { const int num_4x4_w = num_4x4_blocks_wide_lookup [ i ] ; const int num_4x4_h = num_4x4_blocks_high_lookup [ i ] ; const int num_4x4_blk = MAX ( 4 , num_4x4_w * num_4x4_h ) ; for ( x -> sb_index = 0 ; x -> sb_index < 4 ; ++ x -> sb_index ) for ( x -> mb_index = 0 ; x -> mb_index < 4 ; ++ x -> mb_index ) for ( x -> b_index = 0 ; x -> b_index < 16 / num_4x4_blk ; ++ x -> b_index ) get_block_context ( x , i ) -> pred_interp_filter = SWITCHABLE ; } } vp9_zero ( cpi -> mb . pred_mv ) ; if ( ( sf -> partition_search_type == SEARCH_PARTITION && sf -> use_lastframe_partitioning ) || sf -> partition_search_type == FIXED_PARTITION || sf -> partition_search_type == VAR_BASED_PARTITION || sf -> partition_search_type == VAR_BASED_FIXED_PARTITION ) { const int idx_str = cm -> mi_stride * mi_row + mi_col ; MODE_INFO * * mi_8x8 = cm -> mi_grid_visible + idx_str ; MODE_INFO * * prev_mi_8x8 = cm -> prev_mi_grid_visible + idx_str ; cpi -> mb . source_variance = UINT_MAX ; if ( sf -> partition_search_type == FIXED_PARTITION ) { set_offsets ( cpi , tile , mi_row , mi_col , BLOCK_64X64 ) ; set_fixed_partitioning ( cpi , tile , mi_8x8 , mi_row , mi_col , sf -> always_this_block_size ) ; rd_use_partition ( cpi , tile , mi_8x8 , tp , mi_row , mi_col , BLOCK_64X64 , & dummy_rate , & dummy_dist , 1 ) ; } else if ( sf -> partition_search_type == VAR_BASED_FIXED_PARTITION ) { BLOCK_SIZE bsize ; set_offsets ( cpi , tile , mi_row , mi_col , BLOCK_64X64 ) ; bsize = get_rd_var_based_fixed_partition ( cpi , mi_row , mi_col ) ; set_fixed_partitioning ( cpi , tile , mi_8x8 , mi_row , mi_col , bsize ) ; rd_use_partition ( cpi , tile , mi_8x8 , tp , mi_row , mi_col , BLOCK_64X64 , & dummy_rate , & dummy_dist , 1 ) ; } else if ( sf -> partition_search_type == VAR_BASED_PARTITION ) { choose_partitioning ( cpi , tile , mi_row , mi_col ) ; rd_use_partition ( cpi , tile , mi_8x8 , tp , mi_row , mi_col , BLOCK_64X64 , & dummy_rate , & dummy_dist , 1 ) ; } else { if ( ( cm -> current_video_frame % sf -> last_partitioning_redo_frequency ) == 0 || cm -> prev_mi == 0 || cm -> show_frame == 0 || cm -> frame_type == KEY_FRAME || cpi -> rc . is_src_frame_alt_ref || ( ( sf -> use_lastframe_partitioning == LAST_FRAME_PARTITION_LOW_MOTION ) && sb_has_motion ( cm , prev_mi_8x8 ) ) ) { if ( sf -> auto_min_max_partition_size ) { set_offsets ( cpi , tile , mi_row , mi_col , BLOCK_64X64 ) ; rd_auto_partition_range ( cpi , tile , mi_row , mi_col , & sf -> min_partition_size , & sf -> max_partition_size ) ; } rd_pick_partition ( cpi , tile , tp , mi_row , mi_col , BLOCK_64X64 , & dummy_rate , & dummy_dist , 1 , INT64_MAX ) ; } else { if ( sf -> constrain_copy_partition && sb_has_motion ( cm , prev_mi_8x8 ) ) constrain_copy_partitioning ( cpi , tile , mi_8x8 , prev_mi_8x8 , mi_row , mi_col , BLOCK_16X16 ) ; else copy_partitioning ( cm , mi_8x8 , prev_mi_8x8 ) ; rd_use_partition ( cpi , tile , mi_8x8 , tp , mi_row , mi_col , BLOCK_64X64 , & dummy_rate , & dummy_dist , 1 ) ; } } } else { if ( sf -> auto_min_max_partition_size ) { set_offsets ( cpi , tile , mi_row , mi_col , BLOCK_64X64 ) ; rd_auto_partition_range ( cpi , tile , mi_row , mi_col , & sf -> min_partition_size , & sf -> max_partition_size ) ; } rd_pick_partition ( cpi , tile , tp , mi_row , mi_col , BLOCK_64X64 , & dummy_rate , & dummy_dist , 1 , INT64_MAX ) ; } } } "," * cpi , ThreadData * td , TileDataEnc * tile_data , int mi_row , TOKENEXTRA * * tp ) { VP9_COMMON * const cm = & cpi -> common ; TileInfo * const TileInfo * const tile_info = & tile_data -> tile_info ; MACROBLOCK * const x = & td -> mb ; MACROBLOCKD * const xd = & x -> e_mbd ; SPEED_FEATURES * const sf = & cpi -> sf ; int mi_col ; memset ( & xd -> left_context , 0 , sizeof ( xd -> left_context xd -> left_context ) ) ; memset ( xd -> left_seg_context ( xd -> left_seg_context ) ) ; ( mi_col = tile_info -> mi_col_start ; ; mi_col < tile_info -> mi_col_end ; MI_BLOCK_SIZE ) { const struct segmentation * const seg = & cm -> seg ; int64_t dummy_dist ; RD_COST dummy_rdc ; int i ; int seg_skip = 0 ; const int idx_str = cm -> mi_stride * mi_row + mi_col ; MODE_INFO * * mi = cm -> mi_grid_visible + idx_str ; if ( ( i = 0 ; i < ; i < 64 ; ++ i ++ i ) td -> leaf_tree [ i ] . pred_interp_filter = SWITCHABLE ; for ( i = 0 ; i < 64 ; ++ i ) { td -> pc_tree [ i ] . vertical [ 0 ] . pred_interp_filter = SWITCHABLE ; td -> pc_tree [ i ] . vertical [ 1 ] . pred_interp_filter = SWITCHABLE ; td -> pc_tree [ i ] . horizontal [ 0 ] . pred_interp_filter = SWITCHABLE ; td -> pc_tree [ i ] . horizontal [ 1 ] . pred_interp_filter = SWITCHABLE ; } } vp9_zero ( x -> pred_mv ) ; td -> pc_root -> index = 0 ; if ( seg -> enabled ) { const uint8_t * const map = seg -> update_map ? cpi -> segmentation_map : cm -> last_frame_seg_map ; int segment_id = get_segment_id ( cm , map , BLOCK_64X64 , mi_row , mi_col ) ; seg_skip = segfeature_active ( seg , segment_id , SEG_LVL_SKIP ) ; } x -> source_variance = UINT_MAX ; if ( ; if ( sf -> partition_search_type == FIXED_PARTITION || seg_skip ) { const BLOCK_SIZE bsize = seg_skip ? BLOCK_64X64 : sf -> always_this_block_size ; set_offsets ( cpi , tile_info , x , mi_row , mi_col , BLOCK_64X64 ) ; set_fixed_partitioning ( cpi , tile_info , mi , mi_row , mi_col , bsize ) ; rd_use_partition ( cpi , td , tile_data , mi , tp , mi_row , mi_col , BLOCK_64X64 , & dummy_rate , & dummy_dist , 1 , td -> pc_root ) ; } else if ( cpi -> partition_search_skippable_frame ) { BLOCK_SIZE bsize ; set_offsets ( cpi , tile_info , x , mi_row , mi_col , BLOCK_64X64 ) ; bsize = get_rd_var_based_fixed_partition ( cpi , x , mi_row , mi_col ) ; set_fixed_partitioning ( cpi , tile_info , mi , mi_row , mi_col , bsize ) ; rd_use_partition ( cpi , td , tile_data , mi , tp , mi_row , mi_col , BLOCK_64X64 , & dummy_rate , & dummy_dist , 1 , td -> pc_root ) ; } else if ( partition_search_type == VAR_BASED_PARTITION && cm -> frame_type != KEY_FRAME ) { choose_partitioning ( cpi , tile_info , x , mi_row , mi_col ) ; rd_use_partition ( cpi , td , tile_data , mi , tp , mi_row , mi_col , BLOCK_64X64 , & dummy_rate , & dummy_dist , 1 , td -> pc_root ) ; } else { if ( sf -> auto_min_max_partition_size ) { set_offsets ( cpi , tile_info , x , mi_row , mi_col , BLOCK_64X64 ) ; rd_auto_partition_range ( cpi , tile_info , xd , mi_row , mi_col , & x -> min_partition_size , & x -> max_partition_size ) ; } rd_pick_partition ( cpi , td , tile_data , tp , BLOCK_64X64 , & dummy_rdc , INT64_MAX , td -> pc_root ) ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1252,CWE-125,"CWE-125 void lmp_print ( netdissect_options * ndo , register const u_char * pptr , register u_int len ) { const struct lmp_common_header * lmp_com_header ; const struct lmp_object_header * lmp_obj_header ; const u_char * tptr , * obj_tptr ; u_int tlen , lmp_obj_len , lmp_obj_ctype , obj_tlen ; int hexdump ; u_int offset ; u_int link_type ; union { float f ; uint32_t i ; } bw ; tptr = pptr ; lmp_com_header = ( const struct lmp_common_header * ) pptr ; ND_TCHECK ( * lmp_com_header ) ; if ( LMP_EXTRACT_VERSION ( lmp_com_header -> version_res [ 0 ] ) != LMP_VERSION ) { ND_PRINT ( ( ndo , ""LMPversion%upacketnotsupported"" , LMP_EXTRACT_VERSION ( lmp_com_header -> version_res [ 0 ] ) ) ) ; return ; } if ( ndo -> ndo_vflag < 1 ) { ND_PRINT ( ( ndo , ""LMPv%u%sMessage,length:%u"" , LMP_EXTRACT_VERSION ( lmp_com_header -> version_res [ 0 ] ) , tok2str ( lmp_msg_type_values , ""unknown(%u)"" , lmp_com_header -> msg_type ) , len ) ) ; return ; } tlen = EXTRACT_16BITS ( lmp_com_header -> length ) ; ND_PRINT ( ( ndo , ""\\n\\tLMPv%u,msg-type:%s,Flags:[%s],length:%u"" , LMP_EXTRACT_VERSION ( lmp_com_header -> version_res [ 0 ] ) , tok2str ( lmp_msg_type_values , ""unknown,type:%u"" , lmp_com_header -> msg_type ) , bittok2str ( lmp_header_flag_values , ""none"" , lmp_com_header -> flags ) , tlen ) ) ; if ( tlen < sizeof ( const struct lmp_common_header ) ) { ND_PRINT ( ( ndo , ""(tooshort)"" ) ) ; return ; } if ( tlen > len ) { ND_PRINT ( ( ndo , ""(toolong)"" ) ) ; tlen = len ; } tptr += sizeof ( const struct lmp_common_header ) ; tlen -= sizeof ( const struct lmp_common_header ) ; while ( tlen > 0 ) { ND_TCHECK2 ( * tptr , sizeof ( struct lmp_object_header ) ) ; lmp_obj_header = ( const struct lmp_object_header * ) tptr ; lmp_obj_len = EXTRACT_16BITS ( lmp_obj_header -> length ) ; lmp_obj_ctype = ( lmp_obj_header -> ctype ) & 0x7f ; ND_PRINT ( ( ndo , ""\\n\\t%sObject(%u),Class-Type:%s(%u)Flags:[%snegotiable],length:%u"" , tok2str ( lmp_obj_values , ""Unknown"" , lmp_obj_header -> class_num ) , lmp_obj_header -> class_num , tok2str ( lmp_ctype_values , ""Unknown"" , ( ( lmp_obj_header -> class_num ) << 8 ) + lmp_obj_ctype ) , lmp_obj_ctype , ( lmp_obj_header -> ctype ) & 0x80 ? """" : ""non-"" , lmp_obj_len ) ) ; if ( lmp_obj_len < 4 ) { ND_PRINT ( ( ndo , ""(tooshort)"" ) ) ; return ; } if ( ( lmp_obj_len % 4 ) != 0 ) { ND_PRINT ( ( ndo , ""(notamultipleof4)"" ) ) ; return ; } obj_tptr = tptr + sizeof ( struct lmp_object_header ) ; obj_tlen = lmp_obj_len - sizeof ( struct lmp_object_header ) ; ND_TCHECK2 ( * tptr , lmp_obj_len ) ; hexdump = FALSE ; switch ( lmp_obj_header -> class_num ) { case LMP_OBJ_CC_ID : switch ( lmp_obj_ctype ) { case LMP_CTYPE_LOC : case LMP_CTYPE_RMT : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } ND_PRINT ( ( ndo , ""\\n\\tControlChannelID:%u(0x%08x)"" , EXTRACT_32BITS ( obj_tptr ) , EXTRACT_32BITS ( obj_tptr ) ) ) ; break ; default : hexdump = TRUE ; } break ; case LMP_OBJ_LINK_ID : case LMP_OBJ_INTERFACE_ID : switch ( lmp_obj_ctype ) { case LMP_CTYPE_IPV4_LOC : case LMP_CTYPE_IPV4_RMT : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } ND_PRINT ( ( ndo , ""\\n\\tIPv4LinkID:%s(0x%08x)"" , ipaddr_string ( ndo , obj_tptr ) , EXTRACT_32BITS ( obj_tptr ) ) ) ; break ; case LMP_CTYPE_IPV6_LOC : case LMP_CTYPE_IPV6_RMT : if ( obj_tlen != 16 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } ND_PRINT ( ( ndo , ""\\n\\tIPv6LinkID:%s(0x%08x)"" , ip6addr_string ( ndo , obj_tptr ) , EXTRACT_32BITS ( obj_tptr ) ) ) ; break ; case LMP_CTYPE_UNMD_LOC : case LMP_CTYPE_UNMD_RMT : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } ND_PRINT ( ( ndo , ""\\n\\tLinkID:%u(0x%08x)"" , EXTRACT_32BITS ( obj_tptr ) , EXTRACT_32BITS ( obj_tptr ) ) ) ; break ; default : hexdump = TRUE ; } break ; case LMP_OBJ_MESSAGE_ID : switch ( lmp_obj_ctype ) { case LMP_CTYPE_1 : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } ND_PRINT ( ( ndo , ""\\n\\tMessageID:%u(0x%08x)"" , EXTRACT_32BITS ( obj_tptr ) , EXTRACT_32BITS ( obj_tptr ) ) ) ; break ; case LMP_CTYPE_2 : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } ND_PRINT ( ( ndo , ""\\n\\tMessageIDAck:%u(0x%08x)"" , EXTRACT_32BITS ( obj_tptr ) , EXTRACT_32BITS ( obj_tptr ) ) ) ; break ; default : hexdump = TRUE ; } break ; case LMP_OBJ_NODE_ID : switch ( lmp_obj_ctype ) { case LMP_CTYPE_LOC : case LMP_CTYPE_RMT : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } ND_PRINT ( ( ndo , ""\\n\\tNodeID:%s(0x%08x)"" , ipaddr_string ( ndo , obj_tptr ) , EXTRACT_32BITS ( obj_tptr ) ) ) ; break ; default : hexdump = TRUE ; } break ; case LMP_OBJ_CONFIG : switch ( lmp_obj_ctype ) { case LMP_CTYPE_HELLO_CONFIG : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } ND_PRINT ( ( ndo , ""\\n\\tHelloInterval:%u\\n\\tHelloDeadInterval:%u"" , EXTRACT_16BITS ( obj_tptr ) , EXTRACT_16BITS ( obj_tptr + 2 ) ) ) ; break ; default : hexdump = TRUE ; } break ; case LMP_OBJ_HELLO : switch ( lmp_obj_ctype ) { case LMP_CTYPE_HELLO : if ( obj_tlen != 8 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } ND_PRINT ( ( ndo , ""\\n\\tTxSeq:%u,RxSeq:%u"" , EXTRACT_32BITS ( obj_tptr ) , EXTRACT_32BITS ( obj_tptr + 4 ) ) ) ; break ; default : hexdump = TRUE ; } break ; case LMP_OBJ_TE_LINK : switch ( lmp_obj_ctype ) { case LMP_CTYPE_IPV4 : if ( obj_tlen != 12 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } ND_PRINT ( ( ndo , ""\\n\\tFlags:[%s]"" , bittok2str ( lmp_obj_te_link_flag_values , ""none"" , EXTRACT_8BITS ( obj_tptr ) ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\tLocalLink-ID:%s(0x%08x)"" ""\\n\\tRemoteLink-ID:%s(0x%08x)"" , ipaddr_string ( ndo , obj_tptr + 4 ) , EXTRACT_32BITS ( obj_tptr + 4 ) , ipaddr_string ( ndo , obj_tptr + 8 ) , EXTRACT_32BITS ( obj_tptr + 8 ) ) ) ; break ; case LMP_CTYPE_IPV6 : if ( obj_tlen != 36 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } ND_PRINT ( ( ndo , ""\\n\\tFlags:[%s]"" , bittok2str ( lmp_obj_te_link_flag_values , ""none"" , EXTRACT_8BITS ( obj_tptr ) ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\tLocalLink-ID:%s(0x%08x)"" ""\\n\\tRemoteLink-ID:%s(0x%08x)"" , ip6addr_string ( ndo , obj_tptr + 4 ) , EXTRACT_32BITS ( obj_tptr + 4 ) , ip6addr_string ( ndo , obj_tptr + 20 ) , EXTRACT_32BITS ( obj_tptr + 20 ) ) ) ; break ; case LMP_CTYPE_UNMD : if ( obj_tlen != 12 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } ND_PRINT ( ( ndo , ""\\n\\tFlags:[%s]"" , bittok2str ( lmp_obj_te_link_flag_values , ""none"" , EXTRACT_8BITS ( obj_tptr ) ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\tLocalLink-ID:%u(0x%08x)"" ""\\n\\tRemoteLink-ID:%u(0x%08x)"" , EXTRACT_32BITS ( obj_tptr + 4 ) , EXTRACT_32BITS ( obj_tptr + 4 ) , EXTRACT_32BITS ( obj_tptr + 8 ) , EXTRACT_32BITS ( obj_tptr + 8 ) ) ) ; break ; default : hexdump = TRUE ; } break ; case LMP_OBJ_DATA_LINK : switch ( lmp_obj_ctype ) { case LMP_CTYPE_IPV4 : if ( obj_tlen < 12 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } ND_PRINT ( ( ndo , ""\\n\\tFlags:[%s]"" , bittok2str ( lmp_obj_data_link_flag_values , ""none"" , EXTRACT_8BITS ( obj_tptr ) ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\tLocalInterfaceID:%s(0x%08x)"" ""\\n\\tRemoteInterfaceID:%s(0x%08x)"" , ipaddr_string ( ndo , obj_tptr + 4 ) , EXTRACT_32BITS ( obj_tptr + 4 ) , ipaddr_string ( ndo , obj_tptr + 8 ) , EXTRACT_32BITS ( obj_tptr + 8 ) ) ) ; if ( lmp_print_data_link_subobjs ( ndo , obj_tptr , obj_tlen - 12 , 12 ) ) hexdump = TRUE ; break ; case LMP_CTYPE_IPV6 : if ( obj_tlen < 36 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } ND_PRINT ( ( ndo , ""\\n\\tFlags:[%s]"" , bittok2str ( lmp_obj_data_link_flag_values , ""none"" , EXTRACT_8BITS ( obj_tptr ) ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\tLocalInterfaceID:%s(0x%08x)"" ""\\n\\tRemoteInterfaceID:%s(0x%08x)"" , ip6addr_string ( ndo , obj_tptr + 4 ) , EXTRACT_32BITS ( obj_tptr + 4 ) , ip6addr_string ( ndo , obj_tptr + 20 ) , EXTRACT_32BITS ( obj_tptr + 20 ) ) ) ; if ( lmp_print_data_link_subobjs ( ndo , obj_tptr , obj_tlen - 36 , 36 ) ) hexdump = TRUE ; break ; case LMP_CTYPE_UNMD : if ( obj_tlen < 12 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } ND_PRINT ( ( ndo , ""\\n\\tFlags:[%s]"" , bittok2str ( lmp_obj_data_link_flag_values , ""none"" , EXTRACT_8BITS ( obj_tptr ) ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\tLocalInterfaceID:%u(0x%08x)"" ""\\n\\tRemoteInterfaceID:%u(0x%08x)"" , EXTRACT_32BITS ( obj_tptr + 4 ) , EXTRACT_32BITS ( obj_tptr + 4 ) , EXTRACT_32BITS ( obj_tptr + 8 ) , EXTRACT_32BITS ( obj_tptr + 8 ) ) ) ; if ( lmp_print_data_link_subobjs ( ndo , obj_tptr , obj_tlen - 12 , 12 ) ) hexdump = TRUE ; break ; default : hexdump = TRUE ; } break ; case LMP_OBJ_VERIFY_BEGIN : switch ( lmp_obj_ctype ) { case LMP_CTYPE_1 : if ( obj_tlen != 20 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } ND_PRINT ( ( ndo , ""\\n\\tFlags:%s"" , bittok2str ( lmp_obj_begin_verify_flag_values , ""none"" , EXTRACT_16BITS ( obj_tptr ) ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\tVerifyInterval:%u"" , EXTRACT_16BITS ( obj_tptr + 2 ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\tDatalinks:%u"" , EXTRACT_32BITS ( obj_tptr + 4 ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\tEncodingtype:%s"" , tok2str ( gmpls_encoding_values , ""Unknown"" , * ( obj_tptr + 8 ) ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\tVerifyTransportMechanism:%u(0x%x)%s"" , EXTRACT_16BITS ( obj_tptr + 10 ) , EXTRACT_16BITS ( obj_tptr + 10 ) , EXTRACT_16BITS ( obj_tptr + 10 ) & 8000 ? ""(Payloadtestmessagescapable)"" : """" ) ) ; bw . i = EXTRACT_32BITS ( obj_tptr + 12 ) ; ND_PRINT ( ( ndo , ""\\n\\tTransmissionRate:%.3fMbps"" , bw . f * 8 / 1000000 ) ) ; ND_PRINT ( ( ndo , ""\\n\\tWavelength:%u"" , EXTRACT_32BITS ( obj_tptr + 16 ) ) ) ; break ; default : hexdump = TRUE ; } break ; case LMP_OBJ_VERIFY_BEGIN_ACK : switch ( lmp_obj_ctype ) { case LMP_CTYPE_1 : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } ND_PRINT ( ( ndo , ""\\n\\tVerifyDeadInterval:%u"" ""\\n\\tVerifyTransportResponse:%u"" , EXTRACT_16BITS ( obj_tptr ) , EXTRACT_16BITS ( obj_tptr + 2 ) ) ) ; break ; default : hexdump = TRUE ; } break ; case LMP_OBJ_VERIFY_ID : switch ( lmp_obj_ctype ) { case LMP_CTYPE_1 : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } ND_PRINT ( ( ndo , ""\\n\\tVerifyID:%u"" , EXTRACT_32BITS ( obj_tptr ) ) ) ; break ; default : hexdump = TRUE ; } break ; case LMP_OBJ_CHANNEL_STATUS : switch ( lmp_obj_ctype ) { case LMP_CTYPE_IPV4 : offset = 0 ; while ( offset + 8 <= obj_tlen ) { ND_PRINT ( ( ndo , ""\\n\\tInterfaceID:%s(0x%08x)"" , ipaddr_string ( ndo , obj_tptr + offset ) , EXTRACT_32BITS ( obj_tptr + offset ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\t\\tActive:%s(%u)"" , ( EXTRACT_32BITS ( obj_tptr + offset + 4 ) >> 31 ) ? ""Allocated"" : ""Non-allocated"" , ( EXTRACT_32BITS ( obj_tptr + offset + 4 ) >> 31 ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\t\\tDirection:%s(%u)"" , ( EXTRACT_32BITS ( obj_tptr + offset + 4 ) >> 30 ) & 0x1 ? ""Transmit"" : ""Receive"" , ( EXTRACT_32BITS ( obj_tptr + offset + 4 ) >> 30 ) & 0x1 ) ) ; ND_PRINT ( ( ndo , ""\\n\\t\\tChannelStatus:%s(%u)"" , tok2str ( lmp_obj_channel_status_values , ""Unknown"" , EXTRACT_32BITS ( obj_tptr + offset + 4 ) & 0x3FFFFFF ) , EXTRACT_32BITS ( obj_tptr + offset + 4 ) & 0x3FFFFFF ) ) ; offset += 8 ; } break ; case LMP_CTYPE_IPV6 : offset = 0 ; while ( offset + 20 <= obj_tlen ) { ND_PRINT ( ( ndo , ""\\n\\tInterfaceID:%s(0x%08x)"" , ip6addr_string ( ndo , obj_tptr + offset ) , EXTRACT_32BITS ( obj_tptr + offset ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\t\\tActive:%s(%u)"" , ( EXTRACT_32BITS ( obj_tptr + offset + 16 ) >> 31 ) ? ""Allocated"" : ""Non-allocated"" , ( EXTRACT_32BITS ( obj_tptr + offset + 16 ) >> 31 ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\t\\tDirection:%s(%u)"" , ( EXTRACT_32BITS ( obj_tptr + offset + 16 ) >> 30 ) & 0x1 ? ""Transmit"" : ""Receive"" , ( EXTRACT_32BITS ( obj_tptr + offset + 16 ) >> 30 ) & 0x1 ) ) ; ND_PRINT ( ( ndo , ""\\n\\t\\tChannelStatus:%s(%u)"" , tok2str ( lmp_obj_channel_status_values , ""Unknown"" , EXTRACT_32BITS ( obj_tptr + offset + 16 ) & 0x3FFFFFF ) , EXTRACT_32BITS ( obj_tptr + offset + 16 ) & 0x3FFFFFF ) ) ; offset += 20 ; } break ; case LMP_CTYPE_UNMD : offset = 0 ; while ( offset + 8 <= obj_tlen ) { ND_PRINT ( ( ndo , ""\\n\\tInterfaceID:%u(0x%08x)"" , EXTRACT_32BITS ( obj_tptr + offset ) , EXTRACT_32BITS ( obj_tptr + offset ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\t\\tActive:%s(%u)"" , ( EXTRACT_32BITS ( obj_tptr + offset + 4 ) >> 31 ) ? ""Allocated"" : ""Non-allocated"" , ( EXTRACT_32BITS ( obj_tptr + offset + 4 ) >> 31 ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\t\\tDirection:%s(%u)"" , ( EXTRACT_32BITS ( obj_tptr + offset + 4 ) >> 30 ) & 0x1 ? ""Transmit"" : ""Receive"" , ( EXTRACT_32BITS ( obj_tptr + offset + 4 ) >> 30 ) & 0x1 ) ) ; ND_PRINT ( ( ndo , ""\\n\\t\\tChannelStatus:%s(%u)"" , tok2str ( lmp_obj_channel_status_values , ""Unknown"" , EXTRACT_32BITS ( obj_tptr + offset + 4 ) & 0x3FFFFFF ) , EXTRACT_32BITS ( obj_tptr + offset + 4 ) & 0x3FFFFFF ) ) ; offset += 8 ; } break ; default : hexdump = TRUE ; } break ; case LMP_OBJ_CHANNEL_STATUS_REQ : switch ( lmp_obj_ctype ) { case LMP_CTYPE_IPV4 : offset = 0 ; while ( offset + 4 <= obj_tlen ) { ND_PRINT ( ( ndo , ""\\n\\tInterfaceID:%s(0x%08x)"" , ipaddr_string ( ndo , obj_tptr + offset ) , EXTRACT_32BITS ( obj_tptr + offset ) ) ) ; offset += 4 ; } break ; case LMP_CTYPE_IPV6 : offset = 0 ; while ( offset + 16 <= obj_tlen ) { ND_PRINT ( ( ndo , ""\\n\\tInterfaceID:%s(0x%08x)"" , ip6addr_string ( ndo , obj_tptr + offset ) , EXTRACT_32BITS ( obj_tptr + offset ) ) ) ; offset += 16 ; } break ; case LMP_CTYPE_UNMD : offset = 0 ; while ( offset + 4 <= obj_tlen ) { ND_PRINT ( ( ndo , ""\\n\\tInterfaceID:%u(0x%08x)"" , EXTRACT_32BITS ( obj_tptr + offset ) , EXTRACT_32BITS ( obj_tptr + offset ) ) ) ; offset += 4 ; } break ; default : hexdump = TRUE ; } break ; case LMP_OBJ_ERROR_CODE : switch ( lmp_obj_ctype ) { case LMP_CTYPE_BEGIN_VERIFY_ERROR : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } ND_PRINT ( ( ndo , ""\\n\\tErrorCode:%s"" , bittok2str ( lmp_obj_begin_verify_error_values , ""none"" , EXTRACT_32BITS ( obj_tptr ) ) ) ) ; break ; case LMP_CTYPE_LINK_SUMMARY_ERROR : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } ND_PRINT ( ( ndo , ""\\n\\tErrorCode:%s"" , bittok2str ( lmp_obj_link_summary_error_values , ""none"" , EXTRACT_32BITS ( obj_tptr ) ) ) ) ; break ; default : hexdump = TRUE ; } break ; case LMP_OBJ_SERVICE_CONFIG : switch ( lmp_obj_ctype ) { case LMP_CTYPE_SERVICE_CONFIG_SP : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } ND_PRINT ( ( ndo , ""\\n\\tFlags:%s"" , bittok2str ( lmp_obj_service_config_sp_flag_values , ""none"" , EXTRACT_8BITS ( obj_tptr ) ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\tUNIVersion:%u"" , EXTRACT_8BITS ( obj_tptr + 1 ) ) ) ; break ; case LMP_CTYPE_SERVICE_CONFIG_CPSA : if ( obj_tlen != 16 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } link_type = EXTRACT_8BITS ( obj_tptr ) ; ND_PRINT ( ( ndo , ""\\n\\tLinkType:%s(%u)"" , tok2str ( lmp_sd_service_config_cpsa_link_type_values , ""Unknown"" , link_type ) , link_type ) ) ; switch ( link_type ) { case LMP_SD_SERVICE_CONFIG_CPSA_LINK_TYPE_SDH : ND_PRINT ( ( ndo , ""\\n\\tSignalType:%s(%u)"" , tok2str ( lmp_sd_service_config_cpsa_signal_type_sdh_values , ""Unknown"" , EXTRACT_8BITS ( obj_tptr + 1 ) ) , EXTRACT_8BITS ( obj_tptr + 1 ) ) ) ; break ; case LMP_SD_SERVICE_CONFIG_CPSA_LINK_TYPE_SONET : ND_PRINT ( ( ndo , ""\\n\\tSignalType:%s(%u)"" , tok2str ( lmp_sd_service_config_cpsa_signal_type_sonet_values , ""Unknown"" , EXTRACT_8BITS ( obj_tptr + 1 ) ) , EXTRACT_8BITS ( obj_tptr + 1 ) ) ) ; break ; } ND_PRINT ( ( ndo , ""\\n\\tTransparency:%s"" , bittok2str ( lmp_obj_service_config_cpsa_tp_flag_values , ""none"" , EXTRACT_8BITS ( obj_tptr + 2 ) ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\tContiguousConcatenationTypes:%s"" , bittok2str ( lmp_obj_service_config_cpsa_cct_flag_values , ""none"" , EXTRACT_8BITS ( obj_tptr + 3 ) ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\tMinimumNCC:%u"" , EXTRACT_16BITS ( obj_tptr + 4 ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\tMaximumNCC:%u"" , EXTRACT_16BITS ( obj_tptr + 6 ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\tMinimumNVC:%u"" , EXTRACT_16BITS ( obj_tptr + 8 ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\tMaximumNVC:%u"" , EXTRACT_16BITS ( obj_tptr + 10 ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\tLocalInterfaceID:%s(0x%08x)"" , ipaddr_string ( ndo , obj_tptr + 12 ) , EXTRACT_32BITS ( obj_tptr + 12 ) ) ) ; break ; case LMP_CTYPE_SERVICE_CONFIG_TRANSPARENCY_TCM : if ( obj_tlen != 8 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } ND_PRINT ( ( ndo , ""\\n\\tTransparencyFlags:%s"" , bittok2str ( lmp_obj_service_config_nsa_transparency_flag_values , ""none"" , EXTRACT_32BITS ( obj_tptr ) ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\tTCMMonitoringFlags:%s"" , bittok2str ( lmp_obj_service_config_nsa_tcm_flag_values , ""none"" , EXTRACT_8BITS ( obj_tptr + 7 ) ) ) ) ; break ; case LMP_CTYPE_SERVICE_CONFIG_NETWORK_DIVERSITY : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } ND_PRINT ( ( ndo , ""\\n\\tDiversity:Flags:%s"" , bittok2str ( lmp_obj_service_config_nsa_network_diversity_flag_values , ""none"" , EXTRACT_8BITS ( obj_tptr + 3 ) ) ) ) ; break ; default : hexdump = TRUE ; } break ; default : if ( ndo -> ndo_vflag <= 1 ) print_unknown_data ( ndo , obj_tptr , ""\\n\\t"" , obj_tlen ) ; break ; } if ( ndo -> ndo_vflag > 1 || hexdump == TRUE ) print_unknown_data ( ndo , tptr + sizeof ( struct lmp_object_header ) , ""\\n\\t"" , lmp_obj_len - sizeof ( struct lmp_object_header ) ) ; tptr += lmp_obj_len ; tlen -= lmp_obj_len ; } return ; trunc : ND_PRINT ( ( ndo , ""\\n\\t\\tpacketexceededsnapshot"" ) ) ; } "," ; int hexdump , ret ) ) ; ret = lmp_print_data_link_subobjs ( ndo , 12 ) ; if ( ret == - 1 ) goto trunc ; if ( ret == TRUE ) ) ; ret = lmp_print_data_link_subobjs ( ndo , 36 ) ; if ( ret == - 1 ) goto trunc ; if ( ret == TRUE ) ) ; ret = lmp_print_data_link_subobjs ( ndo , 12 ) ; if ( ret == - 1 ) goto trunc ; if ( ret == TRUE ",the-tcpdump-group@tcpdump/d97e94223720684c6aa740ff219e0d19426c2220,CVE-2018-14464,https://github.com/the-tcpdump-group/tcpdump/commit/d97e94223720684c6aa740ff219e0d19426c2220,2019-10-03T16:15Z 1253,CWE-119,"CWE-119 static void inc_mvs ( const MB_MODE_INFO * mbmi , const int_mv mvs [ 2 ] , nmv_context_counts * counts ) { int i ; for ( i = 0 ; i < 1 + has_second_ref ( mbmi ) ; ++ i ) { const MV * ref = & mbmi -> ref_mvs [ mbmi -> ref_frame [ i ] ] [ 0 ] . as_mv ; const MV diff = { mvs [ i ] . as_mv . row - ref -> row , mvs [ i ] . as_mv . col - ref -> col } ; vp9_inc_mv ( & diff , counts ) ; } } "," * mbmi , const MB_MODE_INFO_EXT * mbmi_ext , ref = & mbmi_ext -> ref_mvs [ ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1254,CWE-119,"CWE-119 int main ( int argc , char * * argv ) { FILE * infile = NULL ; vpx_codec_ctx_t codec = { 0 } ; vpx_codec_enc_cfg_t cfg = { 0 } ; int frame_count = 0 ; vpx_image_t raw ; vpx_codec_err_t res ; VpxVideoInfo info = { 0 } ; VpxVideoWriter * writer = NULL ; const VpxInterface * encoder = NULL ; int update_frame_num = 0 ; const int fps = 30 ; const int bitrate = 200 ; exec_name = argv [ 0 ] ; if ( argc != 6 ) die ( ""Invalidnumberofarguments"" ) ; encoder = get_vpx_encoder_by_name ( ""vp8"" ) ; if ( ! encoder ) die ( ""Unsupportedcodec."" ) ; update_frame_num = atoi ( argv [ 5 ] ) ; if ( ! update_frame_num ) die ( ""Couldn\'tparseframenumber\'%s\'\\n"" , argv [ 5 ] ) ; info . codec_fourcc = encoder -> fourcc ; info . frame_width = strtol ( argv [ 1 ] , NULL , 0 ) ; info . frame_height = strtol ( argv [ 2 ] , NULL , 0 ) ; info . time_base . numerator = 1 ; info . time_base . denominator = fps ; if ( info . frame_width <= 0 || info . frame_height <= 0 || ( info . frame_width % 2 ) != 0 || ( info . frame_height % 2 ) != 0 ) { die ( ""Invalidframesize:%dx%d"" , info . frame_width , info . frame_height ) ; } if ( ! vpx_img_alloc ( & raw , VPX_IMG_FMT_I420 , info . frame_width , info . frame_height , 1 ) ) { die ( ""Failedtoallocateimage."" ) ; } printf ( ""Using%s\\n"" , vpx_codec_iface_name ( encoder -> interface ( ) ) ) ; res = vpx_codec_enc_config_default ( encoder -> interface ( ) , & cfg , 0 ) ; if ( res ) die_codec ( & codec , ""Failedtogetdefaultcodecconfig."" ) ; cfg . g_w = info . frame_width ; cfg . g_h = info . frame_height ; cfg . g_timebase . num = info . time_base . numerator ; cfg . g_timebase . den = info . time_base . denominator ; cfg . rc_target_bitrate = bitrate ; writer = vpx_video_writer_open ( argv [ 4 ] , kContainerIVF , & info ) ; if ( ! writer ) die ( ""Failedtoopen%sforwriting."" , argv [ 4 ] ) ; if ( ! ( infile = fopen ( argv [ 3 ] , ""rb"" ) ) ) die ( ""Failedtoopen%sforreading."" , argv [ 3 ] ) ; if ( vpx_codec_enc_init ( & codec , encoder -> interface ( ) , & cfg , 0 ) ) die_codec ( & codec , ""Failedtoinitializeencoder"" ) ; while ( vpx_img_read ( & raw , infile ) ) { if ( frame_count + 1 == update_frame_num ) { vpx_ref_frame_t ref ; ref . frame_type = VP8_LAST_FRAME ; ref . img = raw ; if ( vpx_codec_control ( & codec , VP8_SET_REFERENCE , & ref ) ) die_codec ( & codec , ""Failedtosetreferenceframe"" ) ; } encode_frame ( & codec , & raw , frame_count ++ , writer ) ; } encode_frame ( & codec , NULL , - 1 , writer ) ; printf ( ""\\n"" ) ; fclose ( infile ) ; printf ( ""Processed%dframes.\\n"" , frame_count ) ; vpx_img_free ( & raw ) ; if ( vpx_codec_destroy ( & codec ) ) die_codec ( & codec , ""Failedtodestroycodec."" ) ; vpx_video_writer_close ( writer ) ; return EXIT_SUCCESS ; } "," ( encoder -> codec_interface ( ) ) ( encoder -> codec_interface ( ) , , encoder -> codec_interface ( ) , ) ; } while ( , writer ) ) { } printf ( ""\\n"" ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1255,CWE-399,"CWE-399 static struct sk_buff * batadv_frag_merge_packets ( struct hlist_head * chain , struct sk_buff * skb ) { struct batadv_frag_packet * packet ; struct batadv_frag_list_entry * entry ; struct sk_buff * skb_out = NULL ; int size , hdr_size = sizeof ( struct batadv_frag_packet ) ; packet = ( struct batadv_frag_packet * ) skb -> data ; size = ntohs ( packet -> total_size ) ; if ( size > batadv_frag_size_limit ( ) ) goto free ; entry = hlist_entry ( chain -> first , struct batadv_frag_list_entry , list ) ; hlist_del ( & entry -> list ) ; skb_out = entry -> skb ; kfree ( entry ) ; if ( pskb_expand_head ( skb_out , 0 , size - skb -> len , GFP_ATOMIC ) < 0 ) { kfree_skb ( skb_out ) ; skb_out = NULL ; goto free ; } skb_pull_rcsum ( skb_out , hdr_size ) ; memmove ( skb_out -> data - ETH_HLEN , skb_mac_header ( skb_out ) , ETH_HLEN ) ; skb_set_mac_header ( skb_out , - ETH_HLEN ) ; skb_reset_network_header ( skb_out ) ; skb_reset_transport_header ( skb_out ) ; hlist_for_each_entry ( entry , chain , list ) { size = entry -> skb -> len - hdr_size ; memcpy ( skb_put ( skb_out , size ) , entry -> skb -> data + hdr_size , size ) ; } free : batadv_frag_clear_chain ( chain ) ; return skb_out ; } "," , size - skb_out -> len , ",torvalds@linux/5b6698b0e4a37053de35cc24ee695b98a7eb712b,CVE-2014-9428,https://github.com/torvalds/linux/commit/5b6698b0e4a37053de35cc24ee695b98a7eb712b,2015-01-02T21:59Z 1256,CWE-362,"CWE-362 struct sta_info * sta_info_alloc ( struct ieee80211_sub_if_data * sdata , const u8 * addr , gfp_t gfp ) { struct ieee80211_local * local = sdata -> local ; struct sta_info * sta ; struct timespec uptime ; struct ieee80211_tx_latency_bin_ranges * tx_latency ; int i ; sta = kzalloc ( sizeof ( * sta ) + local -> hw . sta_data_size , gfp ) ; if ( ! sta ) return NULL ; rcu_read_lock ( ) ; tx_latency = rcu_dereference ( local -> tx_latency ) ; if ( tx_latency ) { sta -> tx_lat = kzalloc ( IEEE80211_NUM_TIDS * sizeof ( struct ieee80211_tx_latency_stat ) , GFP_ATOMIC ) ; if ( ! sta -> tx_lat ) { rcu_read_unlock ( ) ; goto free ; } if ( tx_latency -> n_ranges ) { for ( i = 0 ; i < IEEE80211_NUM_TIDS ; i ++ ) { sta -> tx_lat [ i ] . bin_count = tx_latency -> n_ranges + 1 ; sta -> tx_lat [ i ] . bins = kcalloc ( sta -> tx_lat [ i ] . bin_count , sizeof ( u32 ) , GFP_ATOMIC ) ; if ( ! sta -> tx_lat [ i ] . bins ) { rcu_read_unlock ( ) ; goto free ; } } } } rcu_read_unlock ( ) ; spin_lock_init ( & sta -> lock ) ; INIT_WORK ( & sta -> drv_unblock_wk , sta_unblock ) ; INIT_WORK ( & sta -> ampdu_mlme . work , ieee80211_ba_session_work ) ; mutex_init ( & sta -> ampdu_mlme . mtx ) ; # ifdef CONFIG_MAC80211_MESH if ( ieee80211_vif_is_mesh ( & sdata -> vif ) && ! sdata -> u . mesh . user_mpm ) init_timer ( & sta -> plink_timer ) ; sta -> nonpeer_pm = NL80211_MESH_POWER_ACTIVE ; # endif memcpy ( sta -> sta . addr , addr , ETH_ALEN ) ; sta -> local = local ; sta -> sdata = sdata ; sta -> last_rx = jiffies ; sta -> sta_state = IEEE80211_STA_NONE ; do_posix_clock_monotonic_gettime ( & uptime ) ; sta -> last_connected = uptime . tv_sec ; ewma_init ( & sta -> avg_signal , 1024 , 8 ) ; for ( i = 0 ; i < ARRAY_SIZE ( sta -> chain_signal_avg ) ; i ++ ) ewma_init ( & sta -> chain_signal_avg [ i ] , 1024 , 8 ) ; if ( sta_prepare_rate_control ( local , sta , gfp ) ) goto free ; for ( i = 0 ; i < IEEE80211_NUM_TIDS ; i ++ ) { sta -> timer_to_tid [ i ] = i ; } for ( i = 0 ; i < IEEE80211_NUM_ACS ; i ++ ) { skb_queue_head_init ( & sta -> ps_tx_buf [ i ] ) ; skb_queue_head_init ( & sta -> tx_filtered [ i ] ) ; } for ( i = 0 ; i < IEEE80211_NUM_TIDS ; i ++ ) sta -> last_seq_ctrl [ i ] = cpu_to_le16 ( USHRT_MAX ) ; sta -> sta . smps_mode = IEEE80211_SMPS_OFF ; if ( sdata -> vif . type == NL80211_IFTYPE_AP || sdata -> vif . type == NL80211_IFTYPE_AP_VLAN ) { struct ieee80211_supported_band * sband = local -> hw . wiphy -> bands [ ieee80211_get_sdata_band ( sdata ) ] ; u8 smps = ( sband -> ht_cap . cap & IEEE80211_HT_CAP_SM_PS ) >> IEEE80211_HT_CAP_SM_PS_SHIFT ; switch ( smps ) { case WLAN_HT_SMPS_CONTROL_DISABLED : sta -> known_smps_mode = IEEE80211_SMPS_OFF ; break ; case WLAN_HT_SMPS_CONTROL_STATIC : sta -> known_smps_mode = IEEE80211_SMPS_STATIC ; break ; case WLAN_HT_SMPS_CONTROL_DYNAMIC : sta -> known_smps_mode = IEEE80211_SMPS_DYNAMIC ; break ; default : WARN_ON ( 1 ) ; } } sta_dbg ( sdata , ""AllocatedSTA%pM\\n"" , sta -> sta . addr ) ; return sta ; free : if ( sta -> tx_lat ) { for ( i = 0 ; i < IEEE80211_NUM_TIDS ; i ++ ) kfree ( sta -> tx_lat [ i ] . bins ) ; kfree ( sta -> tx_lat ) ; } kfree ( sta ) ; return NULL ; } "," sta -> lock ) ; spin_lock_init ( & sta -> ps_lock ",torvalds@linux/1d147bfa64293b2723c4fec50922168658e613ba,CVE-2014-2706,https://github.com/torvalds/linux/commit/1d147bfa64293b2723c4fec50922168658e613ba,2014-04-14T23:55Z 1257,CWE-264,"CWE-264 static int perf_trace_event_perm ( struct ftrace_event_call * tp_event , struct perf_event * p_event ) { if ( ftrace_event_is_function ( tp_event ) && perf_paranoid_kernel ( ) && ! capable ( CAP_SYS_ADMIN ) ) return - EPERM ; if ( ! ( p_event -> attr . sample_type & PERF_SAMPLE_RAW ) ) return 0 ; if ( p_event -> attach_state == PERF_ATTACH_TASK ) { if ( tp_event -> flags & TRACE_EVENT_FL_CAP_ANY ) return 0 ; } if ( perf_paranoid_tracepoint_raw ( ) && ! capable ( CAP_SYS_ADMIN ) ) return - EPERM ; return 0 ; } "," tp_event ) && perf_paranoid_tracepoint_raw ( ) && ",torvalds@linux/12ae030d54ef250706da5642fc7697cc60ad0df7,CVE-2013-2930,https://github.com/torvalds/linux/commit/12ae030d54ef250706da5642fc7697cc60ad0df7,2013-12-09T18:55Z 1258,CWE-119,"CWE-119 static __exit void sctp_exit ( void ) { sctp_v6_del_protocol ( ) ; sctp_v4_del_protocol ( ) ; unregister_pernet_subsys ( & sctp_net_ops ) ; sctp_v6_protosw_exit ( ) ; sctp_v4_protosw_exit ( ) ; sctp_v6_pf_exit ( ) ; sctp_v4_pf_exit ( ) ; sctp_sysctl_unregister ( ) ; free_pages ( ( unsigned long ) sctp_assoc_hashtable , get_order ( sctp_assoc_hashsize * sizeof ( struct sctp_hashbucket ) ) ) ; kfree ( sctp_ep_hashtable ) ; free_pages ( ( unsigned long ) sctp_port_hashtable , get_order ( sctp_port_hashsize * sizeof ( struct sctp_bind_hashbucket ) ) ) ; percpu_counter_destroy ( & sctp_sockets_allocated ) ; rcu_barrier ( ) ; kmem_cache_destroy ( sctp_chunk_cachep ) ; kmem_cache_destroy ( sctp_bucket_cachep ) ; } "," unregister_pernet_subsys ( & sctp_ctrlsock_ops ) ; sctp_v6_protosw_exit ; sctp_v4_protosw_exit ( ) ; unregister_pernet_subsys ( & sctp_defaults_ops ",torvalds@linux/8e2d61e0aed2b7c4ecb35844fe07e0b2b762dee4,CVE-2015-5283,https://github.com/torvalds/linux/commit/8e2d61e0aed2b7c4ecb35844fe07e0b2b762dee4,2015-10-19T10:59Z 1259,CWE-000,"CWE-000 static int acm_probe ( struct usb_interface * intf , const struct usb_device_id * id ) { struct usb_cdc_union_desc * union_header = NULL ; struct usb_cdc_country_functional_desc * cfd = NULL ; unsigned char * buffer = intf -> altsetting -> extra ; int buflen = intf -> altsetting -> extralen ; struct usb_interface * control_interface ; struct usb_interface * data_interface ; struct usb_endpoint_descriptor * epctrl = NULL ; struct usb_endpoint_descriptor * epread = NULL ; struct usb_endpoint_descriptor * epwrite = NULL ; struct usb_device * usb_dev = interface_to_usbdev ( intf ) ; struct acm * acm ; int minor ; int ctrlsize , readsize ; u8 * buf ; u8 ac_management_function = 0 ; u8 call_management_function = 0 ; int call_interface_num = - 1 ; int data_interface_num = - 1 ; unsigned long quirks ; int num_rx_buf ; int i ; unsigned int elength = 0 ; int combined_interfaces = 0 ; struct device * tty_dev ; int rv = - ENOMEM ; quirks = ( unsigned long ) id -> driver_info ; if ( quirks == IGNORE_DEVICE ) return - ENODEV ; num_rx_buf = ( quirks == SINGLE_RX_URB ) ? 1 : ACM_NR ; if ( quirks == NO_UNION_NORMAL ) { data_interface = usb_ifnum_to_if ( usb_dev , 1 ) ; control_interface = usb_ifnum_to_if ( usb_dev , 0 ) ; goto skip_normal_probe ; } if ( ! buffer ) { dev_err ( & intf -> dev , ""Weirddescriptorreferences\\n"" ) ; return - EINVAL ; } if ( ! buflen ) { if ( intf -> cur_altsetting -> endpoint && intf -> cur_altsetting -> endpoint -> extralen && intf -> cur_altsetting -> endpoint -> extra ) { dev_dbg ( & intf -> dev , ""Seekingextradescriptorsonendpoint\\n"" ) ; buflen = intf -> cur_altsetting -> endpoint -> extralen ; buffer = intf -> cur_altsetting -> endpoint -> extra ; } else { dev_err ( & intf -> dev , ""Zerolengthdescriptorreferences\\n"" ) ; return - EINVAL ; } } while ( buflen > 0 ) { elength = buffer [ 0 ] ; if ( ! elength ) { dev_err ( & intf -> dev , ""skippinggarbagebyte\\n"" ) ; elength = 1 ; goto next_desc ; } if ( buffer [ 1 ] != USB_DT_CS_INTERFACE ) { dev_err ( & intf -> dev , ""skippinggarbage\\n"" ) ; goto next_desc ; } switch ( buffer [ 2 ] ) { case USB_CDC_UNION_TYPE : if ( elength < sizeof ( struct usb_cdc_union_desc ) ) goto next_desc ; if ( union_header ) { dev_err ( & intf -> dev , ""Morethanone"" ""uniondescriptor,skipping...\\n"" ) ; goto next_desc ; } union_header = ( struct usb_cdc_union_desc * ) buffer ; break ; case USB_CDC_COUNTRY_TYPE : if ( elength < sizeof ( struct usb_cdc_country_functional_desc ) ) goto next_desc ; cfd = ( struct usb_cdc_country_functional_desc * ) buffer ; break ; case USB_CDC_HEADER_TYPE : break ; case USB_CDC_ACM_TYPE : if ( elength < 4 ) goto next_desc ; ac_management_function = buffer [ 3 ] ; break ; case USB_CDC_CALL_MANAGEMENT_TYPE : if ( elength < 5 ) goto next_desc ; call_management_function = buffer [ 3 ] ; call_interface_num = buffer [ 4 ] ; break ; default : dev_dbg ( & intf -> dev , ""Ignoringdescriptor:"" ""type%02x,length%ud\\n"" , buffer [ 2 ] , elength ) ; break ; } next_desc : buflen -= elength ; buffer += elength ; } if ( ! union_header ) { if ( call_interface_num > 0 ) { dev_dbg ( & intf -> dev , ""Nouniondescriptor,usingcallmanagementdescriptor\\n"" ) ; if ( quirks & NO_DATA_INTERFACE ) data_interface = usb_ifnum_to_if ( usb_dev , 0 ) ; else data_interface = usb_ifnum_to_if ( usb_dev , ( data_interface_num = call_interface_num ) ) ; control_interface = intf ; } else { if ( intf -> cur_altsetting -> desc . bNumEndpoints != 3 ) { dev_dbg ( & intf -> dev , ""Nouniondescriptor,givingup\\n"" ) ; return - ENODEV ; } else { dev_warn ( & intf -> dev , ""Nouniondescriptor,testingforcastrateddevice\\n"" ) ; combined_interfaces = 1 ; control_interface = data_interface = intf ; goto look_for_collapsed_interface ; } } } else { control_interface = usb_ifnum_to_if ( usb_dev , union_header -> bMasterInterface0 ) ; data_interface = usb_ifnum_to_if ( usb_dev , ( data_interface_num = union_header -> bSlaveInterface0 ) ) ; } if ( ! control_interface || ! data_interface ) { dev_dbg ( & intf -> dev , ""nointerfaces\\n"" ) ; return - ENODEV ; } if ( data_interface_num != call_interface_num ) dev_dbg ( & intf -> dev , ""Separatecallcontrolinterface.Thatisnotfullysupported.\\n"" ) ; if ( control_interface == data_interface ) { dev_warn ( & intf -> dev , ""Controlanddatainterfacesarenotseparated!\\n"" ) ; combined_interfaces = 1 ; quirks |= NO_CAP_LINE ; if ( data_interface -> cur_altsetting -> desc . bNumEndpoints != 3 ) { dev_err ( & intf -> dev , ""Thisneedsexactly3endpoints\\n"" ) ; return - EINVAL ; } look_for_collapsed_interface : for ( i = 0 ; i < 3 ; i ++ ) { struct usb_endpoint_descriptor * ep ; ep = & data_interface -> cur_altsetting -> endpoint [ i ] . desc ; if ( usb_endpoint_is_int_in ( ep ) ) epctrl = ep ; else if ( usb_endpoint_is_bulk_out ( ep ) ) epwrite = ep ; else if ( usb_endpoint_is_bulk_in ( ep ) ) epread = ep ; else return - EINVAL ; } if ( ! epctrl || ! epread || ! epwrite ) return - ENODEV ; else goto made_compressed_probe ; } skip_normal_probe : if ( data_interface -> cur_altsetting -> desc . bInterfaceClass != CDC_DATA_INTERFACE_TYPE ) { if ( control_interface -> cur_altsetting -> desc . bInterfaceClass == CDC_DATA_INTERFACE_TYPE ) { dev_dbg ( & intf -> dev , ""Yourdevicehasswitchedinterfaces.\\n"" ) ; swap ( control_interface , data_interface ) ; } else { return - EINVAL ; } } if ( ! combined_interfaces && intf != control_interface ) return - ENODEV ; if ( ! combined_interfaces && usb_interface_claimed ( data_interface ) ) { dev_dbg ( & intf -> dev , ""Thedatainterfaceisn\'tavailable\\n"" ) ; return - EBUSY ; } if ( data_interface -> cur_altsetting -> desc . bNumEndpoints < 2 || control_interface -> cur_altsetting -> desc . bNumEndpoints == 0 ) return - EINVAL ; epctrl = & control_interface -> cur_altsetting -> endpoint [ 0 ] . desc ; epread = & data_interface -> cur_altsetting -> endpoint [ 0 ] . desc ; epwrite = & data_interface -> cur_altsetting -> endpoint [ 1 ] . desc ; if ( ! usb_endpoint_dir_in ( epread ) ) { dev_dbg ( & intf -> dev , ""Thedatainterfacehasswitchedendpoints\\n"" ) ; swap ( epread , epwrite ) ; } made_compressed_probe : dev_dbg ( & intf -> dev , ""interfacesarevalid\\n"" ) ; acm = kzalloc ( sizeof ( struct acm ) , GFP_KERNEL ) ; if ( acm == NULL ) goto alloc_fail ; minor = acm_alloc_minor ( acm ) ; if ( minor < 0 ) { dev_err ( & intf -> dev , ""nomorefreeacmdevices\\n"" ) ; kfree ( acm ) ; return - ENODEV ; } ctrlsize = usb_endpoint_maxp ( epctrl ) ; readsize = usb_endpoint_maxp ( epread ) * ( quirks == SINGLE_RX_URB ? 1 : 2 ) ; acm -> combined_interfaces = combined_interfaces ; acm -> writesize = usb_endpoint_maxp ( epwrite ) * 20 ; acm -> control = control_interface ; acm -> data = data_interface ; acm -> minor = minor ; acm -> dev = usb_dev ; acm -> ctrl_caps = ac_management_function ; if ( quirks & NO_CAP_LINE ) acm -> ctrl_caps &= ~ USB_CDC_CAP_LINE ; acm -> ctrlsize = ctrlsize ; acm -> readsize = readsize ; acm -> rx_buflimit = num_rx_buf ; INIT_WORK ( & acm -> work , acm_softint ) ; init_waitqueue_head ( & acm -> wioctl ) ; spin_lock_init ( & acm -> write_lock ) ; spin_lock_init ( & acm -> read_lock ) ; mutex_init ( & acm -> mutex ) ; acm -> rx_endpoint = usb_rcvbulkpipe ( usb_dev , epread -> bEndpointAddress ) ; acm -> is_int_ep = usb_endpoint_xfer_int ( epread ) ; if ( acm -> is_int_ep ) acm -> bInterval = epread -> bInterval ; tty_port_init ( & acm -> port ) ; acm -> port . ops = & acm_port_ops ; init_usb_anchor ( & acm -> delayed ) ; acm -> quirks = quirks ; buf = usb_alloc_coherent ( usb_dev , ctrlsize , GFP_KERNEL , & acm -> ctrl_dma ) ; if ( ! buf ) goto alloc_fail2 ; acm -> ctrl_buffer = buf ; if ( acm_write_buffers_alloc ( acm ) < 0 ) goto alloc_fail4 ; acm -> ctrlurb = usb_alloc_urb ( 0 , GFP_KERNEL ) ; if ( ! acm -> ctrlurb ) goto alloc_fail5 ; for ( i = 0 ; i < num_rx_buf ; i ++ ) { struct acm_rb * rb = & ( acm -> read_buffers [ i ] ) ; struct urb * urb ; rb -> base = usb_alloc_coherent ( acm -> dev , readsize , GFP_KERNEL , & rb -> dma ) ; if ( ! rb -> base ) goto alloc_fail6 ; rb -> index = i ; rb -> instance = acm ; urb = usb_alloc_urb ( 0 , GFP_KERNEL ) ; if ( ! urb ) goto alloc_fail6 ; urb -> transfer_flags |= URB_NO_TRANSFER_DMA_MAP ; urb -> transfer_dma = rb -> dma ; if ( acm -> is_int_ep ) { usb_fill_int_urb ( urb , acm -> dev , acm -> rx_endpoint , rb -> base , acm -> readsize , acm_read_bulk_callback , rb , acm -> bInterval ) ; } else { usb_fill_bulk_urb ( urb , acm -> dev , acm -> rx_endpoint , rb -> base , acm -> readsize , acm_read_bulk_callback , rb ) ; } acm -> read_urbs [ i ] = urb ; __set_bit ( i , & acm -> read_urbs_free ) ; } for ( i = 0 ; i < ACM_NW ; i ++ ) { struct acm_wb * snd = & ( acm -> wb [ i ] ) ; snd -> urb = usb_alloc_urb ( 0 , GFP_KERNEL ) ; if ( snd -> urb == NULL ) goto alloc_fail7 ; if ( usb_endpoint_xfer_int ( epwrite ) ) usb_fill_int_urb ( snd -> urb , usb_dev , usb_sndintpipe ( usb_dev , epwrite -> bEndpointAddress ) , NULL , acm -> writesize , acm_write_bulk , snd , epwrite -> bInterval ) ; else usb_fill_bulk_urb ( snd -> urb , usb_dev , usb_sndbulkpipe ( usb_dev , epwrite -> bEndpointAddress ) , NULL , acm -> writesize , acm_write_bulk , snd ) ; snd -> urb -> transfer_flags |= URB_NO_TRANSFER_DMA_MAP ; if ( quirks & SEND_ZERO_PACKET ) snd -> urb -> transfer_flags |= URB_ZERO_PACKET ; snd -> instance = acm ; } usb_set_intfdata ( intf , acm ) ; i = device_create_file ( & intf -> dev , & dev_attr_bmCapabilities ) ; if ( i < 0 ) goto alloc_fail7 ; if ( cfd ) { acm -> country_codes = kmalloc ( cfd -> bLength - 4 , GFP_KERNEL ) ; if ( ! acm -> country_codes ) goto skip_countries ; acm -> country_code_size = cfd -> bLength - 4 ; memcpy ( acm -> country_codes , ( u8 * ) & cfd -> wCountyCode0 , cfd -> bLength - 4 ) ; acm -> country_rel_date = cfd -> iCountryCodeRelDate ; i = device_create_file ( & intf -> dev , & dev_attr_wCountryCodes ) ; if ( i < 0 ) { kfree ( acm -> country_codes ) ; acm -> country_codes = NULL ; acm -> country_code_size = 0 ; goto skip_countries ; } i = device_create_file ( & intf -> dev , & dev_attr_iCountryCodeRelDate ) ; if ( i < 0 ) { device_remove_file ( & intf -> dev , & dev_attr_wCountryCodes ) ; kfree ( acm -> country_codes ) ; acm -> country_codes = NULL ; acm -> country_code_size = 0 ; goto skip_countries ; } } skip_countries : usb_fill_int_urb ( acm -> ctrlurb , usb_dev , usb_rcvintpipe ( usb_dev , epctrl -> bEndpointAddress ) , acm -> ctrl_buffer , ctrlsize , acm_ctrl_irq , acm , epctrl -> bInterval ? epctrl -> bInterval : 16 ) ; acm -> ctrlurb -> transfer_flags |= URB_NO_TRANSFER_DMA_MAP ; acm -> ctrlurb -> transfer_dma = acm -> ctrl_dma ; dev_info ( & intf -> dev , ""ttyACM%d:USBACMdevice\\n"" , minor ) ; acm -> line . dwDTERate = cpu_to_le32 ( 9600 ) ; acm -> line . bDataBits = 8 ; acm_set_line ( acm , & acm -> line ) ; usb_driver_claim_interface ( & acm_driver , data_interface , acm ) ; usb_set_intfdata ( data_interface , acm ) ; usb_get_intf ( control_interface ) ; tty_dev = tty_port_register_device ( & acm -> port , acm_tty_driver , minor , & control_interface -> dev ) ; if ( IS_ERR ( tty_dev ) ) { rv = PTR_ERR ( tty_dev ) ; goto alloc_fail8 ; } if ( quirks & CLEAR_HALT_CONDITIONS ) { usb_clear_halt ( usb_dev , usb_rcvbulkpipe ( usb_dev , epread -> bEndpointAddress ) ) ; usb_clear_halt ( usb_dev , usb_sndbulkpipe ( usb_dev , epwrite -> bEndpointAddress ) ) ; } return 0 ; alloc_fail8 : if ( acm -> country_codes ) { device_remove_file ( & acm -> control -> dev , & dev_attr_wCountryCodes ) ; device_remove_file ( & acm -> control -> dev , & dev_attr_iCountryCodeRelDate ) ; kfree ( acm -> country_codes ) ; } device_remove_file ( & acm -> control -> dev , & dev_attr_bmCapabilities ) ; alloc_fail7 : usb_set_intfdata ( intf , NULL ) ; for ( i = 0 ; i < ACM_NW ; i ++ ) usb_free_urb ( acm -> wb [ i ] . urb ) ; alloc_fail6 : for ( i = 0 ; i < num_rx_buf ; i ++ ) usb_free_urb ( acm -> read_urbs [ i ] ) ; acm_read_buffers_free ( acm ) ; usb_free_urb ( acm -> ctrlurb ) ; alloc_fail5 : acm_write_buffers_free ( acm ) ; alloc_fail4 : usb_free_coherent ( usb_dev , ctrlsize , acm -> ctrl_buffer , acm -> ctrl_dma ) ; alloc_fail2 : acm_release_minor ( acm ) ; kfree ( acm ) ; alloc_fail : return rv ; } "," , 0 ) ; if ( ! data_interface || ! control_interface ) return - ENODEV ",torvalds@linux/8835ba4a39cf53f705417b3b3a94eb067673f2c9,CVE-2016-3138,https://github.com/torvalds/linux/commit/8835ba4a39cf53f705417b3b3a94eb067673f2c9,2016-05-02T10:59Z 1260,CWE-399,"CWE-399 static int misaligned_load ( struct pt_regs * regs , __u32 opcode , int displacement_not_indexed , int width_shift , int do_sign_extend ) { int error ; int destreg ; __u64 address ; error = generate_and_check_address ( regs , opcode , displacement_not_indexed , width_shift , & address ) ; if ( error < 0 ) { return error ; } perf_sw_event ( PERF_COUNT_SW_ALIGNMENT_FAULTS , 1 , 0 , regs , address ) ; destreg = ( opcode >> 4 ) & 0x3f ; if ( user_mode ( regs ) ) { __u64 buffer ; if ( ! access_ok ( VERIFY_READ , ( unsigned long ) address , 1UL << width_shift ) ) { return - 1 ; } if ( __copy_user ( & buffer , ( const void * ) ( int ) address , ( 1 << width_shift ) ) > 0 ) { return - 1 ; } switch ( width_shift ) { case 1 : if ( do_sign_extend ) { regs -> regs [ destreg ] = ( __u64 ) ( __s64 ) * ( __s16 * ) & buffer ; } else { regs -> regs [ destreg ] = ( __u64 ) * ( __u16 * ) & buffer ; } break ; case 2 : regs -> regs [ destreg ] = ( __u64 ) ( __s64 ) * ( __s32 * ) & buffer ; break ; case 3 : regs -> regs [ destreg ] = buffer ; break ; default : printk ( ""Unexpectedwidth_shift%dinmisaligned_load,PC=%08lx\\n"" , width_shift , ( unsigned long ) regs -> pc ) ; break ; } } else { __u64 lo , hi ; switch ( width_shift ) { case 1 : misaligned_kernel_word_load ( address , do_sign_extend , & regs -> regs [ destreg ] ) ; break ; case 2 : asm ( ""ldlo.l%1,0,%0"" : ""=r"" ( lo ) : ""r"" ( address ) ) ; asm ( ""ldhi.l%1,3,%0"" : ""=r"" ( hi ) : ""r"" ( address ) ) ; regs -> regs [ destreg ] = lo | hi ; break ; case 3 : asm ( ""ldlo.q%1,0,%0"" : ""=r"" ( lo ) : ""r"" ( address ) ) ; asm ( ""ldhi.q%1,7,%0"" : ""=r"" ( hi ) : ""r"" ( address ) ) ; regs -> regs [ destreg ] = lo | hi ; break ; default : printk ( ""Unexpectedwidth_shift%dinmisaligned_load,PC=%08lx\\n"" , width_shift , ( unsigned long ) regs -> pc ) ; break ; } } return 0 ; } "," , 1 , regs , address ",torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,CVE-2011-2918,https://github.com/torvalds/linux/commit/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,2012-05-24T23:55Z 1261,CWE-59,"CWE-59 void netsnmp_init_mib ( void ) { const char * prefix ; char * env_var , * entry ; PrefixListPtr pp = & mib_prefixes [ 0 ] ; char * st = NULL ; if ( Mib ) return ; netsnmp_init_mib_internals ( ) ; netsnmp_fixup_mib_directory ( ) ; env_var = strdup ( netsnmp_get_mib_directory ( ) ) ; if ( ! env_var ) return ; netsnmp_mibindex_load ( ) ; DEBUGMSGTL ( ( ""init_mib"" , ""SeenMIBDIRS:Lookingin\'%s\'formibdirs...\\n"" , env_var ) ) ; entry = strtok_r ( env_var , ENV_SEPARATOR , & st ) ; while ( entry ) { add_mibdir ( entry ) ; entry = strtok_r ( NULL , ENV_SEPARATOR , & st ) ; } SNMP_FREE ( env_var ) ; env_var = netsnmp_getenv ( ""MIBFILES"" ) ; if ( env_var != NULL ) { if ( * env_var == '+' ) entry = strtok_r ( env_var + 1 , ENV_SEPARATOR , & st ) ; else entry = strtok_r ( env_var , ENV_SEPARATOR , & st ) ; while ( entry ) { add_mibfile ( entry , NULL , NULL ) ; entry = strtok_r ( NULL , ENV_SEPARATOR , & st ) ; } } netsnmp_init_mib_internals ( ) ; env_var = netsnmp_getenv ( ""MIBS"" ) ; if ( env_var == NULL ) { if ( confmibs != NULL ) env_var = strdup ( confmibs ) ; else env_var = strdup ( NETSNMP_DEFAULT_MIBS ) ; } else { env_var = strdup ( env_var ) ; } if ( env_var && ( ( * env_var == '+' ) || ( * env_var == '-' ) ) ) { entry = ( char * ) malloc ( strlen ( NETSNMP_DEFAULT_MIBS ) + strlen ( env_var ) + 2 ) ; if ( ! entry ) { DEBUGMSGTL ( ( ""init_mib"" , ""envmibsmallocfailed"" ) ) ; SNMP_FREE ( env_var ) ; return ; } else { if ( * env_var == '+' ) sprintf ( entry , ""%s%c%s"" , NETSNMP_DEFAULT_MIBS , ENV_SEPARATOR_CHAR , env_var + 1 ) ; else sprintf ( entry , ""%s%c%s"" , env_var + 1 , ENV_SEPARATOR_CHAR , NETSNMP_DEFAULT_MIBS ) ; } SNMP_FREE ( env_var ) ; env_var = entry ; } DEBUGMSGTL ( ( ""init_mib"" , ""SeenMIBS:Lookingin\'%s\'formibfiles...\\n"" , env_var ) ) ; entry = strtok_r ( env_var , ENV_SEPARATOR , & st ) ; while ( entry ) { if ( strcasecmp ( entry , DEBUG_ALWAYS_TOKEN ) == 0 ) { read_all_mibs ( ) ; } else if ( strstr ( entry , ""/"" ) != NULL ) { read_mib ( entry ) ; } else { netsnmp_read_module ( entry ) ; } entry = strtok_r ( NULL , ENV_SEPARATOR , & st ) ; } adopt_orphans ( ) ; SNMP_FREE ( env_var ) ; env_var = netsnmp_getenv ( ""MIBFILES"" ) ; if ( env_var != NULL ) { if ( ( * env_var == '+' ) || ( * env_var == '-' ) ) { # ifdef NETSNMP_DEFAULT_MIBFILES entry = ( char * ) malloc ( strlen ( NETSNMP_DEFAULT_MIBFILES ) + strlen ( env_var ) + 2 ) ; if ( ! entry ) { DEBUGMSGTL ( ( ""init_mib"" , ""envmibfilesmallocfailed"" ) ) ; } else { if ( * env_var ++ == '+' ) sprintf ( entry , ""%s%c%s"" , NETSNMP_DEFAULT_MIBFILES , ENV_SEPARATOR_CHAR , env_var ) ; else sprintf ( entry , ""%s%c%s"" , env_var , ENV_SEPARATOR_CHAR , NETSNMP_DEFAULT_MIBFILES ) ; } SNMP_FREE ( env_var ) ; env_var = entry ; # else env_var = strdup ( env_var + 1 ) ; # endif } else { env_var = strdup ( env_var ) ; } } else { # ifdef NETSNMP_DEFAULT_MIBFILES env_var = strdup ( NETSNMP_DEFAULT_MIBFILES ) ; # endif } if ( env_var != NULL ) { DEBUGMSGTL ( ( ""init_mib"" , ""SeenMIBFILES:Lookingin\'%s\'formibfiles...\\n"" , env_var ) ) ; entry = strtok_r ( env_var , ENV_SEPARATOR , & st ) ; while ( entry ) { read_mib ( entry ) ; entry = strtok_r ( NULL , ENV_SEPARATOR , & st ) ; } SNMP_FREE ( env_var ) ; } prefix = netsnmp_getenv ( ""PREFIX"" ) ; if ( ! prefix ) prefix = Standard_Prefix ; Prefix = ( char * ) malloc ( strlen ( prefix ) + 2 ) ; if ( ! Prefix ) DEBUGMSGTL ( ( ""init_mib"" , ""Prefixmallocfailed"" ) ) ; else strcpy ( Prefix , prefix ) ; DEBUGMSGTL ( ( ""init_mib"" , ""SeenPREFIX:Lookingin\'%s\'forprefix...\\n"" , Prefix ) ) ; if ( Prefix ) { env_var = & Prefix [ strlen ( Prefix ) - 1 ] ; if ( * env_var == '.' ) * env_var = '\\0' ; } pp -> str = Prefix ; while ( pp -> str ) { pp -> len = strlen ( pp -> str ) ; pp ++ ; } Mib = tree_head ; tree_top = ( struct tree * ) calloc ( 1 , sizeof ( struct tree ) ) ; if ( tree_top ) { tree_top -> label = strdup ( ""(top)"" ) ; tree_top -> child_list = tree_head ; } } "," ) return ; DEBUGMSGTL ( ( add_mibfile ( entry , NULL ) ",net-snmp@net-snmp/4fd9a450444a434a993bc72f7c3486ccce41f602,CVE-2020-15861,https://github.com/net-snmp/net-snmp/commit/4fd9a450444a434a993bc72f7c3486ccce41f602,2020-08-20T01:17Z 1262,CWE-362,"CWE-362 static void sctp_sock_migrate ( struct sock * oldsk , struct sock * newsk , struct sctp_association * assoc , sctp_socket_type_t type ) { struct sctp_sock * oldsp = sctp_sk ( oldsk ) ; struct sctp_sock * newsp = sctp_sk ( newsk ) ; struct sctp_bind_bucket * pp ; struct sctp_endpoint * newep = newsp -> ep ; struct sk_buff * skb , * tmp ; struct sctp_ulpevent * event ; struct sctp_bind_hashbucket * head ; struct list_head tmplist ; newsk -> sk_sndbuf = oldsk -> sk_sndbuf ; newsk -> sk_rcvbuf = oldsk -> sk_rcvbuf ; if ( oldsp -> do_auto_asconf ) { memcpy ( & tmplist , & newsp -> auto_asconf_list , sizeof ( tmplist ) ) ; inet_sk_copy_descendant ( newsk , oldsk ) ; memcpy ( & newsp -> auto_asconf_list , & tmplist , sizeof ( tmplist ) ) ; } else inet_sk_copy_descendant ( newsk , oldsk ) ; newsp -> ep = newep ; newsp -> hmac = NULL ; head = & sctp_port_hashtable [ sctp_phashfn ( sock_net ( oldsk ) , inet_sk ( oldsk ) -> inet_num ) ] ; local_bh_disable ( ) ; spin_lock ( & head -> lock ) ; pp = sctp_sk ( oldsk ) -> bind_hash ; sk_add_bind_node ( newsk , & pp -> owner ) ; sctp_sk ( newsk ) -> bind_hash = pp ; inet_sk ( newsk ) -> inet_num = inet_sk ( oldsk ) -> inet_num ; spin_unlock ( & head -> lock ) ; local_bh_enable ( ) ; sctp_bind_addr_dup ( & newsp -> ep -> base . bind_addr , & oldsp -> ep -> base . bind_addr , GFP_KERNEL ) ; sctp_skb_for_each ( skb , & oldsk -> sk_receive_queue , tmp ) { event = sctp_skb2event ( skb ) ; if ( event -> asoc == assoc ) { __skb_unlink ( skb , & oldsk -> sk_receive_queue ) ; __skb_queue_tail ( & newsk -> sk_receive_queue , skb ) ; sctp_skb_set_owner_r_frag ( skb , newsk ) ; } } skb_queue_head_init ( & newsp -> pd_lobby ) ; atomic_set ( & sctp_sk ( newsk ) -> pd_mode , assoc -> ulpq . pd_mode ) ; if ( atomic_read ( & sctp_sk ( oldsk ) -> pd_mode ) ) { struct sk_buff_head * queue ; if ( assoc -> ulpq . pd_mode ) { queue = & newsp -> pd_lobby ; } else queue = & newsk -> sk_receive_queue ; sctp_skb_for_each ( skb , & oldsp -> pd_lobby , tmp ) { event = sctp_skb2event ( skb ) ; if ( event -> asoc == assoc ) { __skb_unlink ( skb , & oldsp -> pd_lobby ) ; __skb_queue_tail ( queue , skb ) ; sctp_skb_set_owner_r_frag ( skb , newsk ) ; } } if ( assoc -> ulpq . pd_mode ) sctp_clear_pd ( oldsk , NULL ) ; } sctp_skb_for_each ( skb , & assoc -> ulpq . reasm , tmp ) sctp_skb_set_owner_r_frag ( skb , newsk ) ; sctp_skb_for_each ( skb , & assoc -> ulpq . lobby , tmp ) sctp_skb_set_owner_r_frag ( skb , newsk ) ; newsp -> type = type ; lock_sock_nested ( newsk , SINGLE_DEPTH_NESTING ) ; sctp_assoc_migrate ( assoc , newsk ) ; if ( sctp_state ( assoc , CLOSED ) && sctp_style ( newsk , TCP ) ) newsk -> sk_shutdown |= RCV_SHUTDOWN ; newsk -> sk_state = SCTP_SS_ESTABLISHED ; release_sock ( newsk ) ; } "," * head ; newsk -> sk_sndbuf -> sk_rcvbuf ; sctp_copy_descendant ( newsk , ",torvalds@linux/2d45a02d0166caf2627fe91897c6ffc3b19514c4,CVE-2015-3212,https://github.com/torvalds/linux/commit/2d45a02d0166caf2627fe91897c6ffc3b19514c4,2015-08-31T10:59Z 1263,CWE-284,"CWE-284 int uinput_create ( char * name ) { struct uinput_dev dev ; int fd , x = 0 ; for ( x = 0 ; x < MAX_UINPUT_PATHS ; x ++ ) { fd = open ( uinput_dev_path [ x ] , O_RDWR ) ; if ( fd < 0 ) continue ; break ; } if ( x == MAX_UINPUT_PATHS ) { BTIF_TRACE_ERROR ( ""%sERROR:uinputdeviceopenfailed"" , __FUNCTION__ ) ; return - 1 ; } memset ( & dev , 0 , sizeof ( dev ) ) ; if ( name ) strncpy ( dev . name , name , UINPUT_MAX_NAME_SIZE - 1 ) ; dev . id . bustype = BUS_BLUETOOTH ; dev . id . vendor = 0x0000 ; dev . id . product = 0x0000 ; dev . id . version = 0x0000 ; if ( write ( fd , & dev , sizeof ( dev ) ) < 0 ) { BTIF_TRACE_ERROR ( ""%sUnabletowritedeviceinformation"" , __FUNCTION__ ) ; close ( fd ) ; return - 1 ; } ioctl ( fd , UI_SET_EVBIT , EV_KEY ) ; ioctl ( fd , UI_SET_EVBIT , EV_REL ) ; ioctl ( fd , UI_SET_EVBIT , EV_SYN ) ; for ( x = 0 ; key_map [ x ] . name != NULL ; x ++ ) ioctl ( fd , UI_SET_KEYBIT , key_map [ x ] . mapped_id ) ; if ( ioctl ( fd , UI_DEV_CREATE , NULL ) < 0 ) { BTIF_TRACE_ERROR ( ""%sUnabletocreateuinputdevice"" , __FUNCTION__ ) ; close ( fd ) ; return - 1 ; } return fd ; } "," { fd = TEMP_FAILURE_RETRY ( ] , O_RDWR ) ; if ( TEMP_FAILURE_RETRY ( sizeof ( dev ) 1 ; } TEMP_FAILURE_RETRY ( , EV_KEY ) ) ; TEMP_FAILURE_RETRY ( ioctl ( fd , EV_REL ) ) ; TEMP_FAILURE_RETRY ( ioctl ( fd UI_SET_EVBIT , EV_SYN ) x ++ ) TEMP_FAILURE_RETRY ( . mapped_id ) ) ; if ( TEMP_FAILURE_RETRY ( ioctl ( UI_DEV_CREATE , NULL ) ",system@bt/472271b153c5dc53c28beac55480a8d8434b2d5c,CVE-2016-3839,https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c,2016-08-05T20:59Z 1264,CWE-362,"CWE-362 int insn_get_code_seg_params ( struct pt_regs * regs ) { struct desc_struct * desc ; short sel ; if ( v8086_mode ( regs ) ) return INSN_CODE_SEG_PARAMS ( 2 , 2 ) ; sel = get_segment_selector ( regs , INAT_SEG_REG_CS ) ; if ( sel < 0 ) return sel ; desc = get_desc ( sel ) ; if ( ! desc ) return - EINVAL ; if ( ! ( desc -> type & BIT ( 3 ) ) ) return - EINVAL ; switch ( ( desc -> l << 1 ) | desc -> d ) { case 0 : return INSN_CODE_SEG_PARAMS ( 2 , 2 ) ; case 1 : return INSN_CODE_SEG_PARAMS ( 4 , 4 ) ; case 2 : return INSN_CODE_SEG_PARAMS ( 4 , 8 ) ; case 3 : default : return - EINVAL ; } } "," { struct desc_struct desc ; short return sel ; if ( ! if ( ! get_desc ( & desc , sel ) ) return - ! ( desc . type & BIT ( ( desc . l << 1 ) | desc . d ) { ",torvalds@linux/de9f869616dd95e95c00bdd6b0fcd3421e8a4323,CVE-2019-13233,https://github.com/torvalds/linux/commit/de9f869616dd95e95c00bdd6b0fcd3421e8a4323,2019-07-04T13:15Z 1265,CWE-119,"CWE-119 void vp9_lookahead_destroy ( struct lookahead_ctx * ctx ) { if ( ctx ) { if ( ctx -> buf ) { unsigned int i ; for ( i = 0 ; i < ctx -> max_sz ; i ++ ) vp9_free_frame_buffer ( & ctx -> buf [ i ] . img ) ; free ( ctx -> buf ) ; } free ( ctx ) ; } } "," i ++ ) vpx_free_frame_buffer ( & ctx ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1266,CWE-119,"CWE-119 static void filter_selectively_vert ( uint8_t * s , int pitch , unsigned int mask_16x16 , unsigned int mask_8x8 , unsigned int mask_4x4 , unsigned int mask_4x4_int , const loop_filter_info_n * lfi_n , const uint8_t * lfl ) { unsigned int mask ; for ( mask = mask_16x16 | mask_8x8 | mask_4x4 | mask_4x4_int ; mask ; mask >>= 1 ) { const loop_filter_thresh * lfi = lfi_n -> lfthr + * lfl ; if ( mask & 1 ) { if ( mask_16x16 & 1 ) { vp9_lpf_vertical_16 ( s , pitch , lfi -> mblim , lfi -> lim , lfi -> hev_thr ) ; } else if ( mask_8x8 & 1 ) { vp9_lpf_vertical_8 ( s , pitch , lfi -> mblim , lfi -> lim , lfi -> hev_thr , 1 ) ; } else if ( mask_4x4 & 1 ) { vp9_lpf_vertical_4 ( s , pitch , lfi -> mblim , lfi -> lim , lfi -> hev_thr , 1 ) ; } } if ( mask_4x4_int & 1 ) vp9_lpf_vertical_4 ( s + 4 , pitch , lfi -> mblim , lfi -> lim , lfi -> hev_thr , 1 ) ; s += 8 ; lfl += 1 ; mask_16x16 >>= 1 ; mask_8x8 >>= 1 ; mask_4x4 >>= 1 ; mask_4x4_int >>= 1 ; } } "," 1 ) { vpx_lpf_vertical_16 ( s , 1 ) { vpx_lpf_vertical_8 ( s , 1 ) { vpx_lpf_vertical_4 ( s , pitch , lfi -> mblim , lfi -> lim , lfi -> hev_thr , 1 ) ; } } if ( mask_4x4_int & 1 ) vpx_lpf_vertical_4 ( s + ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1267,CWE-399,"CWE-399 SYSCALL_DEFINE1 ( inotify_init1 , int , flags ) { struct fsnotify_group * group ; struct user_struct * user ; int ret ; BUILD_BUG_ON ( IN_CLOEXEC != O_CLOEXEC ) ; BUILD_BUG_ON ( IN_NONBLOCK != O_NONBLOCK ) ; if ( flags & ~ ( IN_CLOEXEC | IN_NONBLOCK ) ) return - EINVAL ; user = get_current_user ( ) ; if ( unlikely ( atomic_read ( & user -> inotify_devs ) >= inotify_max_user_instances ) ) { ret = - EMFILE ; goto out_free_uid ; } group = inotify_new_group ( user , inotify_max_queued_events ) ; if ( IS_ERR ( group ) ) { ret = PTR_ERR ( group ) ; goto out_free_uid ; } atomic_inc ( & user -> inotify_devs ) ; ret = anon_inode_getfd ( ""inotify"" , & inotify_fops , group , O_RDONLY | flags ) ; if ( ret >= 0 ) return ret ; atomic_dec ( & user -> inotify_devs ) ; out_free_uid : free_uid ( user ) ; return ret ; } "," return ret ; fsnotify_put_group ( group ) ; ",torvalds@linux/a2ae4cc9a16e211c8a128ba10d22a85431f093ab,CVE-2010-4250,https://github.com/torvalds/linux/commit/a2ae4cc9a16e211c8a128ba10d22a85431f093ab,2012-06-21T23:55Z 1268,CWE-18,"CWE-18 static krb5_error_code iakerb_alloc_context ( iakerb_ctx_id_t * pctx ) { iakerb_ctx_id_t ctx ; krb5_error_code code ; * pctx = NULL ; ctx = k5alloc ( sizeof ( * ctx ) , & code ) ; if ( ctx == NULL ) goto cleanup ; ctx -> defcred = GSS_C_NO_CREDENTIAL ; ctx -> magic = KG_IAKERB_CONTEXT ; ctx -> state = IAKERB_AS_REQ ; ctx -> count = 0 ; code = krb5_gss_init_context ( & ctx -> k5c ) ; if ( code != 0 ) goto cleanup ; * pctx = ctx ; cleanup : if ( code != 0 ) iakerb_release_context ( ctx ) ; return code ; } "," iakerb_ctx_id_t * pctx , int initiate = 0 ; ctx -> initiate = initiate ; ctx -> established = 0 ; ",krb5@krb5/e04f0283516e80d2f93366e0d479d13c9b5c8c2a,CVE-2015-2696,https://github.com/krb5/krb5/commit/e04f0283516e80d2f93366e0d479d13c9b5c8c2a,2015-11-09T03:59Z 1269,CWE-190,"CWE-190 static int adjust_scalar_min_max_vals ( struct bpf_verifier_env * env , struct bpf_insn * insn , struct bpf_reg_state * dst_reg , struct bpf_reg_state src_reg ) { struct bpf_reg_state * regs = cur_regs ( env ) ; u8 opcode = BPF_OP ( insn -> code ) ; bool src_known , dst_known ; s64 smin_val , smax_val ; u64 umin_val , umax_val ; u64 insn_bitness = ( BPF_CLASS ( insn -> code ) == BPF_ALU64 ) ? 64 : 32 ; smin_val = src_reg . smin_value ; smax_val = src_reg . smax_value ; umin_val = src_reg . umin_value ; umax_val = src_reg . umax_value ; src_known = tnum_is_const ( src_reg . var_off ) ; dst_known = tnum_is_const ( dst_reg -> var_off ) ; switch ( opcode ) { case BPF_ADD : if ( signed_add_overflows ( dst_reg -> smin_value , smin_val ) || signed_add_overflows ( dst_reg -> smax_value , smax_val ) ) { dst_reg -> smin_value = S64_MIN ; dst_reg -> smax_value = S64_MAX ; } else { dst_reg -> smin_value += smin_val ; dst_reg -> smax_value += smax_val ; } if ( dst_reg -> umin_value + umin_val < umin_val || dst_reg -> umax_value + umax_val < umax_val ) { dst_reg -> umin_value = 0 ; dst_reg -> umax_value = U64_MAX ; } else { dst_reg -> umin_value += umin_val ; dst_reg -> umax_value += umax_val ; } dst_reg -> var_off = tnum_add ( dst_reg -> var_off , src_reg . var_off ) ; break ; case BPF_SUB : if ( signed_sub_overflows ( dst_reg -> smin_value , smax_val ) || signed_sub_overflows ( dst_reg -> smax_value , smin_val ) ) { dst_reg -> smin_value = S64_MIN ; dst_reg -> smax_value = S64_MAX ; } else { dst_reg -> smin_value -= smax_val ; dst_reg -> smax_value -= smin_val ; } if ( dst_reg -> umin_value < umax_val ) { dst_reg -> umin_value = 0 ; dst_reg -> umax_value = U64_MAX ; } else { dst_reg -> umin_value -= umax_val ; dst_reg -> umax_value -= umin_val ; } dst_reg -> var_off = tnum_sub ( dst_reg -> var_off , src_reg . var_off ) ; break ; case BPF_MUL : dst_reg -> var_off = tnum_mul ( dst_reg -> var_off , src_reg . var_off ) ; if ( smin_val < 0 || dst_reg -> smin_value < 0 ) { __mark_reg_unbounded ( dst_reg ) ; __update_reg_bounds ( dst_reg ) ; break ; } if ( umax_val > U32_MAX || dst_reg -> umax_value > U32_MAX ) { __mark_reg_unbounded ( dst_reg ) ; __update_reg_bounds ( dst_reg ) ; break ; } dst_reg -> umin_value *= umin_val ; dst_reg -> umax_value *= umax_val ; if ( dst_reg -> umax_value > S64_MAX ) { dst_reg -> smin_value = S64_MIN ; dst_reg -> smax_value = S64_MAX ; } else { dst_reg -> smin_value = dst_reg -> umin_value ; dst_reg -> smax_value = dst_reg -> umax_value ; } break ; case BPF_AND : if ( src_known && dst_known ) { __mark_reg_known ( dst_reg , dst_reg -> var_off . value & src_reg . var_off . value ) ; break ; } dst_reg -> var_off = tnum_and ( dst_reg -> var_off , src_reg . var_off ) ; dst_reg -> umin_value = dst_reg -> var_off . value ; dst_reg -> umax_value = min ( dst_reg -> umax_value , umax_val ) ; if ( dst_reg -> smin_value < 0 || smin_val < 0 ) { dst_reg -> smin_value = S64_MIN ; dst_reg -> smax_value = S64_MAX ; } else { dst_reg -> smin_value = dst_reg -> umin_value ; dst_reg -> smax_value = dst_reg -> umax_value ; } __update_reg_bounds ( dst_reg ) ; break ; case BPF_OR : if ( src_known && dst_known ) { __mark_reg_known ( dst_reg , dst_reg -> var_off . value | src_reg . var_off . value ) ; break ; } dst_reg -> var_off = tnum_or ( dst_reg -> var_off , src_reg . var_off ) ; dst_reg -> umin_value = max ( dst_reg -> umin_value , umin_val ) ; dst_reg -> umax_value = dst_reg -> var_off . value | dst_reg -> var_off . mask ; if ( dst_reg -> smin_value < 0 || smin_val < 0 ) { dst_reg -> smin_value = S64_MIN ; dst_reg -> smax_value = S64_MAX ; } else { dst_reg -> smin_value = dst_reg -> umin_value ; dst_reg -> smax_value = dst_reg -> umax_value ; } __update_reg_bounds ( dst_reg ) ; break ; case BPF_LSH : if ( umax_val >= insn_bitness ) { mark_reg_unknown ( env , regs , insn -> dst_reg ) ; break ; } dst_reg -> smin_value = S64_MIN ; dst_reg -> smax_value = S64_MAX ; if ( dst_reg -> umax_value > 1ULL << ( 63 - umax_val ) ) { dst_reg -> umin_value = 0 ; dst_reg -> umax_value = U64_MAX ; } else { dst_reg -> umin_value <<= umin_val ; dst_reg -> umax_value <<= umax_val ; } if ( src_known ) dst_reg -> var_off = tnum_lshift ( dst_reg -> var_off , umin_val ) ; else dst_reg -> var_off = tnum_lshift ( tnum_unknown , umin_val ) ; __update_reg_bounds ( dst_reg ) ; break ; case BPF_RSH : if ( umax_val >= insn_bitness ) { mark_reg_unknown ( env , regs , insn -> dst_reg ) ; break ; } dst_reg -> smin_value = S64_MIN ; dst_reg -> smax_value = S64_MAX ; if ( src_known ) dst_reg -> var_off = tnum_rshift ( dst_reg -> var_off , umin_val ) ; else dst_reg -> var_off = tnum_rshift ( tnum_unknown , umin_val ) ; dst_reg -> umin_value >>= umax_val ; dst_reg -> umax_value >>= umin_val ; __update_reg_bounds ( dst_reg ) ; break ; default : mark_reg_unknown ( env , regs , insn -> dst_reg ) ; break ; } if ( BPF_CLASS ( insn -> code ) != BPF_ALU64 ) { coerce_reg_to_size ( dst_reg , 4 ) ; coerce_reg_to_size ( & src_reg , 4 ) ; } __reg_deduce_bounds ( dst_reg ) ; __reg_bound_offset ( dst_reg ) ; return 0 ; } "," var_off ) ; if ( ! src_known && opcode != BPF_ADD && opcode != BPF_SUB && opcode != BPF_AND ) { __mark_reg_unknown ( dst_reg ) ; return 0 ; } ",torvalds@linux/bb7f0f989ca7de1153bd128a40a71709e339fa03,CVE-2017-17854,https://github.com/torvalds/linux/commit/bb7f0f989ca7de1153bd128a40a71709e339fa03,2017-12-27T17:08Z 1270,CWE-772,"CWE-772 static Image * ReadSCREENSHOTImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { Image * image ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = ( Image * ) NULL ; # if defined ( MAGICKCORE_WINGDI32_DELEGATE ) { BITMAPINFO bmi ; DISPLAY_DEVICE device ; HBITMAP bitmap , bitmapOld ; HDC bitmapDC , hDC ; Image * screen ; int i ; MagickBooleanType status ; register PixelPacket * q ; register ssize_t x ; RGBTRIPLE * p ; ssize_t y ; assert ( image_info != ( const ImageInfo * ) NULL ) ; i = 0 ; device . cb = sizeof ( device ) ; image = ( Image * ) NULL ; while ( EnumDisplayDevices ( NULL , i , & device , 0 ) && ++ i ) { if ( ( device . StateFlags & DISPLAY_DEVICE_ACTIVE ) != DISPLAY_DEVICE_ACTIVE ) continue ; hDC = CreateDC ( device . DeviceName , device . DeviceName , NULL , NULL ) ; if ( hDC == ( HDC ) NULL ) ThrowReaderException ( CoderError , ""UnableToCreateDC"" ) ; screen = AcquireImage ( image_info ) ; screen -> columns = ( size_t ) GetDeviceCaps ( hDC , HORZRES ) ; screen -> rows = ( size_t ) GetDeviceCaps ( hDC , VERTRES ) ; screen -> storage_class = DirectClass ; status = SetImageExtent ( screen , screen -> columns , screen -> rows ) ; if ( status == MagickFalse ) { InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; } if ( image == ( Image * ) NULL ) image = screen ; else AppendImageToList ( & image , screen ) ; bitmapDC = CreateCompatibleDC ( hDC ) ; if ( bitmapDC == ( HDC ) NULL ) { DeleteDC ( hDC ) ; ThrowReaderException ( CoderError , ""UnableToCreateDC"" ) ; } ( void ) ResetMagickMemory ( & bmi , 0 , sizeof ( BITMAPINFO ) ) ; bmi . bmiHeader . biSize = sizeof ( BITMAPINFOHEADER ) ; bmi . bmiHeader . biWidth = ( LONG ) screen -> columns ; bmi . bmiHeader . biHeight = ( - 1 ) * ( LONG ) screen -> rows ; bmi . bmiHeader . biPlanes = 1 ; bmi . bmiHeader . biBitCount = 24 ; bmi . bmiHeader . biCompression = BI_RGB ; bitmap = CreateDIBSection ( hDC , & bmi , DIB_RGB_COLORS , ( void * * ) & p , NULL , 0 ) ; if ( bitmap == ( HBITMAP ) NULL ) { DeleteDC ( hDC ) ; DeleteDC ( bitmapDC ) ; ThrowReaderException ( CoderError , ""UnableToCreateBitmap"" ) ; } bitmapOld = ( HBITMAP ) SelectObject ( bitmapDC , bitmap ) ; if ( bitmapOld == ( HBITMAP ) NULL ) { DeleteDC ( hDC ) ; DeleteDC ( bitmapDC ) ; DeleteObject ( bitmap ) ; ThrowReaderException ( CoderError , ""UnableToCreateBitmap"" ) ; } BitBlt ( bitmapDC , 0 , 0 , ( int ) screen -> columns , ( int ) screen -> rows , hDC , 0 , 0 , SRCCOPY ) ; ( void ) SelectObject ( bitmapDC , bitmapOld ) ; for ( y = 0 ; y < ( ssize_t ) screen -> rows ; y ++ ) { q = QueueAuthenticPixels ( screen , 0 , y , screen -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) screen -> columns ; x ++ ) { SetPixelRed ( q , ScaleCharToQuantum ( p -> rgbtRed ) ) ; SetPixelGreen ( q , ScaleCharToQuantum ( p -> rgbtGreen ) ) ; SetPixelBlue ( q , ScaleCharToQuantum ( p -> rgbtBlue ) ) ; SetPixelOpacity ( q , OpaqueOpacity ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( screen , exception ) == MagickFalse ) break ; } DeleteDC ( hDC ) ; DeleteDC ( bitmapDC ) ; DeleteObject ( bitmap ) ; } } # elif defined ( MAGICKCORE_X11_DELEGATE ) { const char * option ; XImportInfo ximage_info ; ( void ) exception ; XGetImportInfo ( & ximage_info ) ; option = GetImageOption ( image_info , ""x:screen"" ) ; if ( option != ( const char * ) NULL ) ximage_info . screen = IsMagickTrue ( option ) ; option = GetImageOption ( image_info , ""x:silent"" ) ; if ( option != ( const char * ) NULL ) ximage_info . silent = IsMagickTrue ( option ) ; image = XImportImage ( image_info , & ximage_info ) ; } # endif return ( image ) ; } "," = DirectClass ; if ( image == ( Image * ) NULL ) image = screen ; else AppendImageToList ( & image , screen ) ; ) ; } bitmapDC = CreateCompatibleDC ",ImageMagick@ImageMagick/8c10b9247509c0484b55330458846115131ec2ae,CVE-2017-11447,https://github.com/ImageMagick/ImageMagick/commit/8c10b9247509c0484b55330458846115131ec2ae,2017-07-19T07:29Z 1271,CWE-254,"CWE-254 void impeg2d_dec_user_data ( dec_state_t * ps_dec ) { UWORD32 u4_start_code ; stream_t * ps_stream ; ps_stream = & ps_dec -> s_bit_stream ; u4_start_code = impeg2d_bit_stream_nxt ( ps_stream , START_CODE_LEN ) ; while ( u4_start_code == USER_DATA_START_CODE ) { impeg2d_bit_stream_flush ( ps_stream , START_CODE_LEN ) ; while ( impeg2d_bit_stream_nxt ( ps_stream , START_CODE_PREFIX_LEN ) != START_CODE_PREFIX ) { impeg2d_bit_stream_flush ( ps_stream , 8 ) ; } u4_start_code = impeg2d_bit_stream_nxt ( ps_stream , START_CODE_LEN ) ; } } "," ; while ( ( ) != START_CODE_PREFIX ) && ( ps_stream -> u4_offset < ps_stream -> u4_max_offset ) ",external@libmpeg2/ffab15eb80630dc799eb410855c93525b75233c3,CVE-2016-0824,https://android.googlesource.com/platform/external/libmpeg2/+/ffab15eb80630dc799eb410855c93525b75233c3,2016-03-12T21:59Z 1272,CWE-401,"CWE-401 static ssize_t sof_dfsentry_write ( struct file * file , const char __user * buffer , size_t count , loff_t * ppos ) { # if IS_ENABLED ( CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST ) struct snd_sof_dfsentry * dfse = file -> private_data ; struct snd_sof_dev * sdev = dfse -> sdev ; unsigned long ipc_duration_ms = 0 ; bool flood_duration_test = false ; unsigned long ipc_count = 0 ; struct dentry * dentry ; int err ; # endif size_t size ; char * string ; int ret ; string = kzalloc ( count , GFP_KERNEL ) ; if ( ! string ) return - ENOMEM ; size = simple_write_to_buffer ( string , count , ppos , buffer , count ) ; ret = size ; # if IS_ENABLED ( CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST ) dentry = file -> f_path . dentry ; if ( strcmp ( dentry -> d_name . name , ""ipc_flood_count"" ) && strcmp ( dentry -> d_name . name , ""ipc_flood_duration_ms"" ) ) return - EINVAL ; if ( ! strcmp ( dentry -> d_name . name , ""ipc_flood_duration_ms"" ) ) flood_duration_test = true ; if ( flood_duration_test ) ret = kstrtoul ( string , 0 , & ipc_duration_ms ) ; else ret = kstrtoul ( string , 0 , & ipc_count ) ; if ( ret < 0 ) goto out ; if ( flood_duration_test ) { if ( ! ipc_duration_ms ) { ret = size ; goto out ; } if ( ipc_duration_ms > MAX_IPC_FLOOD_DURATION_MS ) ipc_duration_ms = MAX_IPC_FLOOD_DURATION_MS ; } else { if ( ! ipc_count ) { ret = size ; goto out ; } if ( ipc_count > MAX_IPC_FLOOD_COUNT ) ipc_count = MAX_IPC_FLOOD_COUNT ; } ret = pm_runtime_get_sync ( sdev -> dev ) ; if ( ret < 0 ) { dev_err_ratelimited ( sdev -> dev , ""error:debugfswritefailedtoresume%d\\n"" , ret ) ; pm_runtime_put_noidle ( sdev -> dev ) ; goto out ; } ret = sof_debug_ipc_flood_test ( sdev , dfse , flood_duration_test , ipc_duration_ms , ipc_count ) ; pm_runtime_mark_last_busy ( sdev -> dev ) ; err = pm_runtime_put_autosuspend ( sdev -> dev ) ; if ( err < 0 ) dev_err_ratelimited ( sdev -> dev , ""error:debugfswritefailedtoidle%d\\n"" , err ) ; if ( ret >= 0 ) ret = size ; out : # endif kfree ( string ) ; return ret ; } "," ""ipc_flood_duration_ms"" ) ) { ret = - EINVAL ; - EINVAL ; goto out ; } ",torvalds@linux/c0a333d842ef67ac04adc72ff79dc1ccc3dca4ed,CVE-2019-18812,https://github.com/torvalds/linux/commit/c0a333d842ef67ac04adc72ff79dc1ccc3dca4ed,2019-11-07T16:15Z 1273,CWE-20,"CWE-20 MonoReflectionMethod * mono_reflection_bind_generic_method_parameters ( MonoReflectionMethod * rmethod , MonoArray * types ) { MonoClass * klass ; MonoMethod * method , * inflated ; MonoMethodInflated * imethod ; MonoGenericContext tmp_context ; MonoGenericInst * ginst ; MonoType * * type_argv ; int count , i ; MONO_ARCH_SAVE_REGS ; if ( ! strcmp ( rmethod -> object . vtable -> klass -> name , ""MethodBuilder"" ) ) { # ifndef DISABLE_REFLECTION_EMIT MonoReflectionMethodBuilder * mb = NULL ; MonoReflectionTypeBuilder * tb ; MonoClass * klass ; mb = ( MonoReflectionMethodBuilder * ) rmethod ; tb = ( MonoReflectionTypeBuilder * ) mb -> type ; klass = mono_class_from_mono_type ( mono_reflection_type_get_handle ( ( MonoReflectionType * ) tb ) ) ; method = methodbuilder_to_mono_method ( klass , mb ) ; # else g_assert_not_reached ( ) ; method = NULL ; # endif } else { method = rmethod -> method ; } klass = method -> klass ; if ( method -> is_inflated ) method = ( ( MonoMethodInflated * ) method ) -> declaring ; count = mono_method_signature ( method ) -> generic_param_count ; if ( count != mono_array_length ( types ) ) return NULL ; type_argv = g_new0 ( MonoType * , count ) ; for ( i = 0 ; i < count ; i ++ ) { MonoReflectionType * garg = mono_array_get ( types , gpointer , i ) ; type_argv [ i ] = mono_reflection_type_get_handle ( garg ) ; } ginst = mono_metadata_get_generic_inst ( count , type_argv ) ; g_free ( type_argv ) ; tmp_context . class_inst = klass -> generic_class ? klass -> generic_class -> context . class_inst : NULL ; tmp_context . method_inst = ginst ; inflated = mono_class_inflate_generic_method ( method , & tmp_context ) ; imethod = ( MonoMethodInflated * ) inflated ; if ( method -> klass -> image -> dynamic ) { MonoDynamicImage * image = ( MonoDynamicImage * ) method -> klass -> image ; mono_loader_lock ( ) ; mono_g_hash_table_insert ( image -> generic_def_objects , imethod , rmethod ) ; mono_loader_unlock ( ) ; } return mono_method_get_object ( mono_object_domain ( rmethod ) , inflated , NULL ) ; } "," ) ; } if ( ! mono_verifier_is_method_valid_generic_instantiation ( inflated ) ) mono_raise_exception ( mono_get_exception_argument ( ""typeArguments"" , ""Invalidgenericarguments"" ) ) ; ",mono@mono/cf1ec146f7c6acdc6697032b3aaafc68ffacdcac,CVE-2010-4254,https://github.com/mono/mono/commit/cf1ec146f7c6acdc6697032b3aaafc68ffacdcac,2010-12-06T13:44Z 1274,CWE-119,"CWE-119 static ssize_t exitcode_proc_write ( struct file * file , const char __user * buffer , size_t count , loff_t * pos ) { char * end , buf [ sizeof ( ""nnnnn\\0"" ) ] ; int tmp ; if ( copy_from_user ( buf , buffer , count ) ) return - EFAULT ; tmp = simple_strtol ( buf , & end , 0 ) ; if ( ( * end != '\\0' ) && ! isspace ( * end ) ) return - EINVAL ; uml_exitcode = tmp ; return count ; } "," ) ] ; size_t size ; int tmp ; size = min ( count , sizeof ( buf ) ) ; if ( , buffer , size ) ) return ",torvalds@linux/201f99f170df14ba52ea4c52847779042b7a623b,CVE-2013-4512,https://github.com/torvalds/linux/commit/201f99f170df14ba52ea4c52847779042b7a623b,2013-11-12T14:35Z 1275,CWE-835,"CWE-835 int xmlPushInput ( xmlParserCtxtPtr ctxt , xmlParserInputPtr input ) { int ret ; if ( input == NULL ) return ( - 1 ) ; if ( xmlParserDebugEntities ) { if ( ( ctxt -> input != NULL ) && ( ctxt -> input -> filename ) ) xmlGenericError ( xmlGenericErrorContext , ""%s(%d):"" , ctxt -> input -> filename , ctxt -> input -> line ) ; xmlGenericError ( xmlGenericErrorContext , ""Pushinginput%d:%.30s\\n"" , ctxt -> inputNr + 1 , input -> cur ) ; } ret = inputPush ( ctxt , input ) ; if ( ctxt -> instate == XML_PARSER_EOF ) return ( - 1 ) ; GROW ; return ( ret ) ; } "," input -> cur ) ; } if ( ( ( ctxt -> inputNr > 40 ) && ( ( ctxt -> options & XML_PARSE_HUGE ) == 0 ) ) || ( ctxt -> inputNr > 1024 ) ) { xmlFatalErr ( ctxt , XML_ERR_ENTITY_LOOP , NULL ) ; while ( ctxt -> inputNr > 1 ) xmlFreeInputStream ( inputPop ( ctxt ) ) ; return ( - 1 ",GNOME@libxml2/899a5d9f0ed13b8e32449a08a361e0de127dd961,CVE-2017-16932,https://github.com/GNOME/libxml2/commit/899a5d9f0ed13b8e32449a08a361e0de127dd961,2017-11-23T21:29Z 1276,CWE-000,"CWE-000 static int sanity_check_raw_super ( struct f2fs_sb_info * sbi , struct buffer_head * bh ) { struct f2fs_super_block * raw_super = ( struct f2fs_super_block * ) ( bh -> b_data + F2FS_SUPER_OFFSET ) ; struct super_block * sb = sbi -> sb ; unsigned int blocksize ; if ( F2FS_SUPER_MAGIC != le32_to_cpu ( raw_super -> magic ) ) { f2fs_msg ( sb , KERN_INFO , ""MagicMismatch,valid(0x%x)-read(0x%x)"" , F2FS_SUPER_MAGIC , le32_to_cpu ( raw_super -> magic ) ) ; return 1 ; } if ( F2FS_BLKSIZE != PAGE_SIZE ) { f2fs_msg ( sb , KERN_INFO , ""Invalidpage_cache_size(%lu),supportsonly4KB\\n"" , PAGE_SIZE ) ; return 1 ; } blocksize = 1 << le32_to_cpu ( raw_super -> log_blocksize ) ; if ( blocksize != F2FS_BLKSIZE ) { f2fs_msg ( sb , KERN_INFO , ""Invalidblocksize(%u),supportsonly4KB\\n"" , blocksize ) ; return 1 ; } if ( le32_to_cpu ( raw_super -> log_blocks_per_seg ) != 9 ) { f2fs_msg ( sb , KERN_INFO , ""Invalidlogblockspersegment(%u)\\n"" , le32_to_cpu ( raw_super -> log_blocks_per_seg ) ) ; return 1 ; } if ( le32_to_cpu ( raw_super -> log_sectorsize ) > F2FS_MAX_LOG_SECTOR_SIZE || le32_to_cpu ( raw_super -> log_sectorsize ) < F2FS_MIN_LOG_SECTOR_SIZE ) { f2fs_msg ( sb , KERN_INFO , ""Invalidlogsectorsize(%u)"" , le32_to_cpu ( raw_super -> log_sectorsize ) ) ; return 1 ; } if ( le32_to_cpu ( raw_super -> log_sectors_per_block ) + le32_to_cpu ( raw_super -> log_sectorsize ) != F2FS_MAX_LOG_SECTOR_SIZE ) { f2fs_msg ( sb , KERN_INFO , ""Invalidlogsectorsperblock(%u)logsectorsize(%u)"" , le32_to_cpu ( raw_super -> log_sectors_per_block ) , le32_to_cpu ( raw_super -> log_sectorsize ) ) ; return 1 ; } if ( le32_to_cpu ( raw_super -> node_ino ) != 1 || le32_to_cpu ( raw_super -> meta_ino ) != 2 || le32_to_cpu ( raw_super -> root_ino ) != 3 ) { f2fs_msg ( sb , KERN_INFO , ""InvalidFsMetaIno:node(%u)meta(%u)root(%u)"" , le32_to_cpu ( raw_super -> node_ino ) , le32_to_cpu ( raw_super -> meta_ino ) , le32_to_cpu ( raw_super -> root_ino ) ) ; return 1 ; } if ( sanity_check_area_boundary ( sbi , bh ) ) return 1 ; return 0 ; } "," } if ( le32_to_cpu ( raw_super -> segment_count ) > F2FS_MAX_SEGMENT ) { f2fs_msg ( sb , KERN_INFO , ""Invalidsegmentcount(%u)"" , le32_to_cpu ( raw_super -> segment_count ) ) ; return 1 ; } if ( ",torvalds@linux/b9dd46188edc2f0d1f37328637860bb65a771124,CVE-2017-10662,https://github.com/torvalds/linux/commit/b9dd46188edc2f0d1f37328637860bb65a771124,2017-08-19T18:29Z 1277,CWE-252,"CWE-252 char * _dl_dst_substitute ( struct link_map * l , const char * name , char * result , int is_path ) { char * last_elem , * wp ; last_elem = wp = result ; do { if ( * name == '$' ) { const char * repl ; size_t len ; if ( ( ( ( strncmp ( & name [ 1 ] , ""ORIGIN"" , 6 ) == 0 && ( len = 7 ) != 0 ) || ( strncmp ( & name [ 1 ] , ""PLATFORM"" , 8 ) == 0 && ( len = 9 ) != 0 ) ) && ( name [ len ] == '\\0' || name [ len ] == '/' || ( is_path && name [ len ] == ':' ) ) ) || ( name [ 1 ] == '{' && ( ( strncmp ( & name [ 2 ] , ""ORIGIN}"" , 7 ) == 0 && ( len = 9 ) != 0 ) || ( strncmp ( & name [ 2 ] , ""PLATFORM}"" , 9 ) == 0 && ( len = 11 ) != 0 ) ) ) ) { repl = ( ( len == 7 || name [ 2 ] == 'O' ) ? ( __libc_enable_secure ? NULL : l -> l_origin ) : _dl_platform ) ; if ( repl != NULL && repl != ( const char * ) - 1 ) { wp = __stpcpy ( wp , repl ) ; name += len ; } else { wp = last_elem ; name += len ; while ( * name != '\\0' && ( ! is_path || * name != ':' ) ) ++ name ; } } else * wp ++ = * name ++ ; } else if ( is_path && * name == ':' ) { * wp ++ = * name ++ ; last_elem = wp ; } else * wp ++ = * name ++ ; } while ( * name != '\\0' ) ; * wp = '\\0' ; return result ; } "," is_path ) { const char * const start = name ; 1 ] , ""ORIGIN}"" , 6 ) 1 ] , ""PLATFORM}"" , 8 ) ? ( __libc_enable_secure && ( ( name [ len ] != '\\0' && ( ! is_path || name [ len ] != ':' ) ) || ( name != start && ( ! is_path || name [ - 1 ] != ':' ) ) ) ",bminor@glibc/2864e767053317538feafa815046fff89e5a16be,CVE-1999-0199,https://github.com/bminor/glibc/commit/2864e767053317538feafa815046fff89e5a16be,2020-10-06T13:15Z 1278,CWE-119,"CWE-119 H264SwDecRet H264SwDecInit ( H264SwDecInst * decInst , u32 noOutputReordering ) { u32 rv = 0 ; decContainer_t * pDecCont ; DEC_API_TRC ( ""H264SwDecInit#"" ) ; if ( ( ( - 1 ) >> 1 ) != ( - 1 ) ) { DEC_API_TRC ( ""H264SwDecInit#ERROR:Rightshiftisnotsigned"" ) ; return ( H264SWDEC_INITFAIL ) ; } if ( decInst == NULL ) { DEC_API_TRC ( ""H264SwDecInit#ERROR:decInst==NULL"" ) ; return ( H264SWDEC_PARAM_ERR ) ; } pDecCont = ( decContainer_t * ) H264SwDecMalloc ( sizeof ( decContainer_t ) ) ; if ( pDecCont == NULL ) { DEC_API_TRC ( ""H264SwDecInit#ERROR:Memoryallocationfailed"" ) ; return ( H264SWDEC_MEMFAIL ) ; } # ifdef H264DEC_TRACE sprintf ( pDecCont -> str , ""H264SwDecInit#decInst%pnoOutputReordering%d"" , ( void * ) decInst , noOutputReordering ) ; DEC_API_TRC ( pDecCont -> str ) ; # endif rv = h264bsdInit ( & pDecCont -> storage , noOutputReordering ) ; if ( rv != HANTRO_OK ) { H264SwDecRelease ( pDecCont ) ; return ( H264SWDEC_MEMFAIL ) ; } pDecCont -> decStat = INITIALIZED ; pDecCont -> picNumber = 0 ; # ifdef H264DEC_TRACE sprintf ( pDecCont -> str , ""H264SwDecInit#OK:return%p"" , ( void * ) pDecCont ) ; DEC_API_TRC ( pDecCont -> str ) ; # endif * decInst = ( decContainer_t * ) pDecCont ; return ( H264SWDEC_OK ) ; } "," ( decContainer_t ) , 1 ",frameworks@av/2b6f22dc64d456471a1dc6df09d515771d1427c8,CVE-2016-2463,https://android.googlesource.com/platform/frameworks/av/+/2b6f22dc64d456471a1dc6df09d515771d1427c8,2016-06-13T01:59Z 1279,CWE-416,"CWE-416 static int rawv6_sendmsg ( struct sock * sk , struct msghdr * msg , size_t len ) { struct ipv6_txoptions opt_space ; DECLARE_SOCKADDR ( struct sockaddr_in6 * , sin6 , msg -> msg_name ) ; struct in6_addr * daddr , * final_p , final ; struct inet_sock * inet = inet_sk ( sk ) ; struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct raw6_sock * rp = raw6_sk ( sk ) ; struct ipv6_txoptions * opt = NULL ; struct ip6_flowlabel * flowlabel = NULL ; struct dst_entry * dst = NULL ; struct raw6_frag_vec rfv ; struct flowi6 fl6 ; int addr_len = msg -> msg_namelen ; int hlimit = - 1 ; int tclass = - 1 ; int dontfrag = - 1 ; u16 proto ; int err ; if ( len > INT_MAX ) return - EMSGSIZE ; if ( msg -> msg_flags & MSG_OOB ) return - EOPNOTSUPP ; memset ( & fl6 , 0 , sizeof ( fl6 ) ) ; fl6 . flowi6_mark = sk -> sk_mark ; if ( sin6 ) { if ( addr_len < SIN6_LEN_RFC2133 ) return - EINVAL ; if ( sin6 -> sin6_family && sin6 -> sin6_family != AF_INET6 ) return - EAFNOSUPPORT ; proto = ntohs ( sin6 -> sin6_port ) ; if ( ! proto ) proto = inet -> inet_num ; else if ( proto != inet -> inet_num ) return - EINVAL ; if ( proto > 255 ) return - EINVAL ; daddr = & sin6 -> sin6_addr ; if ( np -> sndflow ) { fl6 . flowlabel = sin6 -> sin6_flowinfo & IPV6_FLOWINFO_MASK ; if ( fl6 . flowlabel & IPV6_FLOWLABEL_MASK ) { flowlabel = fl6_sock_lookup ( sk , fl6 . flowlabel ) ; if ( ! flowlabel ) return - EINVAL ; } } if ( sk -> sk_state == TCP_ESTABLISHED && ipv6_addr_equal ( daddr , & sk -> sk_v6_daddr ) ) daddr = & sk -> sk_v6_daddr ; if ( addr_len >= sizeof ( struct sockaddr_in6 ) && sin6 -> sin6_scope_id && __ipv6_addr_needs_scope_id ( __ipv6_addr_type ( daddr ) ) ) fl6 . flowi6_oif = sin6 -> sin6_scope_id ; } else { if ( sk -> sk_state != TCP_ESTABLISHED ) return - EDESTADDRREQ ; proto = inet -> inet_num ; daddr = & sk -> sk_v6_daddr ; fl6 . flowlabel = np -> flow_label ; } if ( fl6 . flowi6_oif == 0 ) fl6 . flowi6_oif = sk -> sk_bound_dev_if ; if ( msg -> msg_controllen ) { opt = & opt_space ; memset ( opt , 0 , sizeof ( struct ipv6_txoptions ) ) ; opt -> tot_len = sizeof ( struct ipv6_txoptions ) ; err = ip6_datagram_send_ctl ( sock_net ( sk ) , sk , msg , & fl6 , opt , & hlimit , & tclass , & dontfrag ) ; if ( err < 0 ) { fl6_sock_release ( flowlabel ) ; return err ; } if ( ( fl6 . flowlabel & IPV6_FLOWLABEL_MASK ) && ! flowlabel ) { flowlabel = fl6_sock_lookup ( sk , fl6 . flowlabel ) ; if ( ! flowlabel ) return - EINVAL ; } if ( ! ( opt -> opt_nflen | opt -> opt_flen ) ) opt = NULL ; } if ( ! opt ) opt = np -> opt ; if ( flowlabel ) opt = fl6_merge_options ( & opt_space , flowlabel , opt ) ; opt = ipv6_fixup_options ( & opt_space , opt ) ; fl6 . flowi6_proto = proto ; rfv . msg = msg ; rfv . hlen = 0 ; err = rawv6_probe_proto_opt ( & rfv , & fl6 ) ; if ( err ) goto out ; if ( ! ipv6_addr_any ( daddr ) ) fl6 . daddr = * daddr ; else fl6 . daddr . s6_addr [ 15 ] = 0x1 ; if ( ipv6_addr_any ( & fl6 . saddr ) && ! ipv6_addr_any ( & np -> saddr ) ) fl6 . saddr = np -> saddr ; final_p = fl6_update_dst ( & fl6 , opt , & final ) ; if ( ! fl6 . flowi6_oif && ipv6_addr_is_multicast ( & fl6 . daddr ) ) fl6 . flowi6_oif = np -> mcast_oif ; else if ( ! fl6 . flowi6_oif ) fl6 . flowi6_oif = np -> ucast_oif ; security_sk_classify_flow ( sk , flowi6_to_flowi ( & fl6 ) ) ; if ( inet -> hdrincl ) fl6 . flowi6_flags |= FLOWI_FLAG_KNOWN_NH ; dst = ip6_dst_lookup_flow ( sk , & fl6 , final_p ) ; if ( IS_ERR ( dst ) ) { err = PTR_ERR ( dst ) ; goto out ; } if ( hlimit < 0 ) hlimit = ip6_sk_dst_hoplimit ( np , & fl6 , dst ) ; if ( tclass < 0 ) tclass = np -> tclass ; if ( dontfrag < 0 ) dontfrag = np -> dontfrag ; if ( msg -> msg_flags & MSG_CONFIRM ) goto do_confirm ; back_from_confirm : if ( inet -> hdrincl ) err = rawv6_send_hdrinc ( sk , msg , len , & fl6 , & dst , msg -> msg_flags ) ; else { lock_sock ( sk ) ; err = ip6_append_data ( sk , raw6_getfrag , & rfv , len , 0 , hlimit , tclass , opt , & fl6 , ( struct rt6_info * ) dst , msg -> msg_flags , dontfrag ) ; if ( err ) ip6_flush_pending_frames ( sk ) ; else if ( ! ( msg -> msg_flags & MSG_MORE ) ) err = rawv6_push_pending_frames ( sk , & fl6 , rp ) ; release_sock ( sk ) ; } done : dst_release ( dst ) ; out : fl6_sock_release ( flowlabel ) ; return err < 0 ? err : len ; do_confirm : dst_confirm ( dst ) ; if ( ! ( msg -> msg_flags & MSG_PROBE ) || len ) goto back_from_confirm ; err = 0 ; goto done ; } "," len ) { struct ipv6_txoptions * opt_to_free = NULL ; ! opt ) { opt = txopt_get ( np ) ; opt_to_free = opt ; } if ( flowlabel flowlabel ) ; txopt_put ( opt_to_free ) ; ",torvalds@linux/45f6fad84cc305103b28d73482b344d7f5b76f39,CVE-2016-3841,https://github.com/torvalds/linux/commit/45f6fad84cc305103b28d73482b344d7f5b76f39,2016-08-06T20:59Z 1280,CWE-399,"CWE-399 static int br_parse_ip_options ( struct sk_buff * skb ) { struct ip_options * opt ; struct iphdr * iph ; struct net_device * dev = skb -> dev ; u32 len ; iph = ip_hdr ( skb ) ; opt = & ( IPCB ( skb ) -> opt ) ; if ( iph -> ihl < 5 || iph -> version != 4 ) goto inhdr_error ; if ( ! pskb_may_pull ( skb , iph -> ihl * 4 ) ) goto inhdr_error ; iph = ip_hdr ( skb ) ; if ( unlikely ( ip_fast_csum ( ( u8 * ) iph , iph -> ihl ) ) ) goto inhdr_error ; len = ntohs ( iph -> tot_len ) ; if ( skb -> len < len ) { IP_INC_STATS_BH ( dev_net ( dev ) , IPSTATS_MIB_INTRUNCATEDPKTS ) ; goto drop ; } else if ( len < ( iph -> ihl * 4 ) ) goto inhdr_error ; if ( pskb_trim_rcsum ( skb , len ) ) { IP_INC_STATS_BH ( dev_net ( dev ) , IPSTATS_MIB_INDISCARDS ) ; goto drop ; } if ( iph -> ihl == 5 ) { memset ( IPCB ( skb ) , 0 , sizeof ( struct inet_skb_parm ) ) ; return 0 ; } opt -> optlen = iph -> ihl * 4 - sizeof ( struct iphdr ) ; if ( ip_options_compile ( dev_net ( dev ) , opt , skb ) ) goto inhdr_error ; if ( unlikely ( opt -> srr ) ) { struct in_device * in_dev = __in_dev_get_rcu ( dev ) ; if ( in_dev && ! IN_DEV_SOURCE_ROUTE ( in_dev ) ) goto drop ; if ( ip_options_rcv_srr ( skb ) ) goto drop ; } return 0 ; inhdr_error : IP_INC_STATS_BH ( dev_net ( dev ) , IPSTATS_MIB_INHDRERRORS ) ; drop : return - 1 ; } "," drop ; } memset ( IPCB ( skb ) , 0 , sizeof ( struct inet_skb_parm ) ) ; == 5 ) return 0 ; return 0 ; opt -> optlen ",torvalds@linux/f8e9881c2aef1e982e5abc25c046820cd0b7cf64,CVE-2011-4087,https://github.com/torvalds/linux/commit/f8e9881c2aef1e982e5abc25c046820cd0b7cf64,2013-06-08T13:05Z 1281,CWE-285,"CWE-285 static int __reiserfs_set_acl ( struct reiserfs_transaction_handle * th , struct inode * inode , int type , struct posix_acl * acl ) { char * name ; void * value = NULL ; size_t size = 0 ; int error ; switch ( type ) { case ACL_TYPE_ACCESS : name = XATTR_NAME_POSIX_ACL_ACCESS ; if ( acl ) { error = posix_acl_equiv_mode ( acl , & inode -> i_mode ) ; if ( error < 0 ) return error ; else { if ( error == 0 ) acl = NULL ; } } break ; case ACL_TYPE_DEFAULT : name = XATTR_NAME_POSIX_ACL_DEFAULT ; if ( ! S_ISDIR ( inode -> i_mode ) ) return acl ? - EACCES : 0 ; break ; default : return - EINVAL ; } if ( acl ) { value = reiserfs_posix_acl_to_disk ( acl , & size ) ; if ( IS_ERR ( value ) ) return ( int ) PTR_ERR ( value ) ; } error = reiserfs_xattr_set_handle ( th , inode , name , value , size , 0 ) ; if ( error == - ENODATA ) { error = 0 ; if ( type == ACL_TYPE_ACCESS ) { inode -> i_ctime = CURRENT_TIME_SEC ; mark_inode_dirty ( inode ) ; } } kfree ( value ) ; if ( ! error ) set_cached_acl ( inode , type , acl ) ; return error ; } "," { error = posix_acl_update_mode ( inode , & inode inode -> i_mode , & acl ) ; if ( error ) return error ; } break ; ",torvalds@linux/073931017b49d9458aa351605b43a7e34598caef,CVE-2016-7097,https://github.com/torvalds/linux/commit/073931017b49d9458aa351605b43a7e34598caef,2016-10-16T21:59Z 1282,CWE-476,"CWE-476 static int inet_rtm_getroute ( struct sk_buff * in_skb , struct nlmsghdr * nlh , struct netlink_ext_ack * extack ) { struct net * net = sock_net ( in_skb -> sk ) ; struct rtmsg * rtm ; struct nlattr * tb [ RTA_MAX + 1 ] ; struct fib_result res = { } ; struct rtable * rt = NULL ; struct flowi4 fl4 ; __be32 dst = 0 ; __be32 src = 0 ; u32 iif ; int err ; int mark ; struct sk_buff * skb ; u32 table_id = RT_TABLE_MAIN ; kuid_t uid ; err = nlmsg_parse ( nlh , sizeof ( * rtm ) , tb , RTA_MAX , rtm_ipv4_policy , extack ) ; if ( err < 0 ) goto errout ; rtm = nlmsg_data ( nlh ) ; skb = alloc_skb ( NLMSG_GOODSIZE , GFP_KERNEL ) ; if ( ! skb ) { err = - ENOBUFS ; goto errout ; } skb_reset_mac_header ( skb ) ; skb_reset_network_header ( skb ) ; src = tb [ RTA_SRC ] ? nla_get_in_addr ( tb [ RTA_SRC ] ) : 0 ; dst = tb [ RTA_DST ] ? nla_get_in_addr ( tb [ RTA_DST ] ) : 0 ; iif = tb [ RTA_IIF ] ? nla_get_u32 ( tb [ RTA_IIF ] ) : 0 ; mark = tb [ RTA_MARK ] ? nla_get_u32 ( tb [ RTA_MARK ] ) : 0 ; if ( tb [ RTA_UID ] ) uid = make_kuid ( current_user_ns ( ) , nla_get_u32 ( tb [ RTA_UID ] ) ) ; else uid = ( iif ? INVALID_UID : current_uid ( ) ) ; ip_hdr ( skb ) -> protocol = IPPROTO_UDP ; ip_hdr ( skb ) -> saddr = src ; ip_hdr ( skb ) -> daddr = dst ; skb_reserve ( skb , MAX_HEADER + sizeof ( struct iphdr ) ) ; memset ( & fl4 , 0 , sizeof ( fl4 ) ) ; fl4 . daddr = dst ; fl4 . saddr = src ; fl4 . flowi4_tos = rtm -> rtm_tos ; fl4 . flowi4_oif = tb [ RTA_OIF ] ? nla_get_u32 ( tb [ RTA_OIF ] ) : 0 ; fl4 . flowi4_mark = mark ; fl4 . flowi4_uid = uid ; rcu_read_lock ( ) ; if ( iif ) { struct net_device * dev ; dev = dev_get_by_index_rcu ( net , iif ) ; if ( ! dev ) { err = - ENODEV ; goto errout_free ; } skb -> protocol = htons ( ETH_P_IP ) ; skb -> dev = dev ; skb -> mark = mark ; err = ip_route_input_rcu ( skb , dst , src , rtm -> rtm_tos , dev , & res ) ; rt = skb_rtable ( skb ) ; if ( err == 0 && rt -> dst . error ) err = - rt -> dst . error ; } else { rt = ip_route_output_key_hash_rcu ( net , & fl4 , & res , skb ) ; err = 0 ; if ( IS_ERR ( rt ) ) err = PTR_ERR ( rt ) ; else skb_dst_set ( skb , & rt -> dst ) ; } if ( err ) goto errout_free ; if ( rtm -> rtm_flags & RTM_F_NOTIFY ) rt -> rt_flags |= RTCF_NOTIFY ; if ( rtm -> rtm_flags & RTM_F_LOOKUP_TABLE ) table_id = rt -> rt_table_id ; if ( rtm -> rtm_flags & RTM_F_FIB_MATCH ) err = fib_dump_info ( skb , NETLINK_CB ( in_skb ) . portid , nlh -> nlmsg_seq , RTM_NEWROUTE , table_id , rt -> rt_type , res . prefix , res . prefixlen , fl4 . flowi4_tos , res . fi , 0 ) ; else err = rt_fill_info ( net , dst , src , table_id , & fl4 , skb , NETLINK_CB ( in_skb ) . portid , nlh -> nlmsg_seq ) ; if ( err < 0 ) goto errout_free ; rcu_read_unlock ( ) ; err = rtnl_unicast ( skb , net , NETLINK_CB ( in_skb ) . portid ) ; errout : return err ; errout_free : rcu_read_unlock ( ) ; kfree_skb ( skb ) ; goto errout ; } "," & RTM_F_FIB_MATCH ) { if ( ! res . fi ) { err = fib_props [ res . type ] . error ; if ( ! err ) err = - EHOSTUNREACH ; goto errout_free ; goto errout_free ; } err = fib_dump_info ( skb , NETLINK_CB ( in_skb ) . portid , nlh -> nlmsg_seq , RTM_NEWROUTE , table_id , rt -> rt_type , res . prefix , res . prefixlen , fl4 . flowi4_tos , res . fi , 0 ) ; } else { err = rt_fill_info ( net , dst , src , table_id , & fl4 , skb , NETLINK_CB ( in_skb ) . portid , nlh -> nlmsg_seq ) ; } if ( err < 0 ) goto errout_free ; ",torvalds@linux/bc3aae2bbac46dd894c89db5d5e98f7f0ef9e205,CVE-2017-13686,https://github.com/torvalds/linux/commit/bc3aae2bbac46dd894c89db5d5e98f7f0ef9e205,2017-08-24T22:29Z 1283,CWE-119,"CWE-119 static Image * ReadAVSImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { Image * image ; MagickBooleanType status ; register PixelPacket * q ; register ssize_t x ; register unsigned char * p ; size_t height , width ; ssize_t count , y ; unsigned char * pixels ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } width = ReadBlobMSBLong ( image ) ; height = ReadBlobMSBLong ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ( width == 0UL ) || ( height == 0UL ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; do { ssize_t length ; image -> columns = width ; image -> rows = height ; image -> depth = 8 ; if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; pixels = ( unsigned char * ) AcquireQuantumMemory ( image -> columns , 4 * sizeof ( * pixels ) ) ; if ( pixels == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; length = ( size_t ) 4 * image -> columns ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { count = ReadBlob ( image , length , pixels ) ; if ( count != length ) ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; p = pixels ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelAlpha ( q , ScaleCharToQuantum ( * p ++ ) ) ; SetPixelRed ( q , ScaleCharToQuantum ( * p ++ ) ) ; SetPixelGreen ( q , ScaleCharToQuantum ( * p ++ ) ) ; SetPixelBlue ( q , ScaleCharToQuantum ( * p ++ ) ) ; if ( q -> opacity != OpaqueOpacity ) image -> matte = MagickTrue ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } pixels = ( unsigned char * ) RelinquishMagickMemory ( pixels ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; width = ReadBlobMSBLong ( image ) ; height = ReadBlobMSBLong ( image ) ; if ( ( width != 0UL ) && ( height != 0UL ) ) { AcquireNextImage ( image_info , image ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( ( width != 0UL ) && ( height != 0UL ) ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," ) break ; status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; } ",ImageMagick@ImageMagick/f6e9d0d9955e85bdd7540b251cd50d598dacc5e6,CVE-2016-10066,https://github.com/ImageMagick/ImageMagick/commit/f6e9d0d9955e85bdd7540b251cd50d598dacc5e6,2017-03-03T17:59Z 1284,CWE-200,"CWE-200 int res_unpack ( vorbis_info_residue * info , vorbis_info * vi , oggpack_buffer * opb ) { int j , k ; codec_setup_info * ci = ( codec_setup_info * ) vi -> codec_setup ; memset ( info , 0 , sizeof ( * info ) ) ; info -> type = oggpack_read ( opb , 16 ) ; if ( info -> type > 2 || info -> type < 0 ) goto errout ; info -> begin = oggpack_read ( opb , 24 ) ; info -> end = oggpack_read ( opb , 24 ) ; info -> grouping = oggpack_read ( opb , 24 ) + 1 ; info -> partitions = ( char ) ( oggpack_read ( opb , 6 ) + 1 ) ; info -> groupbook = ( unsigned char ) oggpack_read ( opb , 8 ) ; if ( info -> groupbook >= ci -> books ) goto errout ; info -> stagemasks = _ogg_malloc ( info -> partitions * sizeof ( * info -> stagemasks ) ) ; info -> stagebooks = _ogg_malloc ( info -> partitions * 8 * sizeof ( * info -> stagebooks ) ) ; for ( j = 0 ; j < info -> partitions ; j ++ ) { int cascade = oggpack_read ( opb , 3 ) ; if ( oggpack_read ( opb , 1 ) ) cascade |= ( oggpack_read ( opb , 5 ) << 3 ) ; info -> stagemasks [ j ] = cascade ; } for ( j = 0 ; j < info -> partitions ; j ++ ) { for ( k = 0 ; k < 8 ; k ++ ) { if ( ( info -> stagemasks [ j ] >> k ) & 1 ) { unsigned char book = ( unsigned char ) oggpack_read ( opb , 8 ) ; if ( book >= ci -> books ) goto errout ; info -> stagebooks [ j * 8 + k ] = book ; if ( k + 1 > info -> stages ) info -> stages = k + 1 ; } else info -> stagebooks [ j * 8 + k ] = 0xff ; } } if ( oggpack_eop ( opb ) ) goto errout ; return 0 ; errout : res_clear_info ( info ) ; return 1 ; } "," goto errout ; int limit = ( info -> type == 2 ? vi -> channels : 1 ) * ci -> blocksizes [ 1 ] / 2 ; if ( info -> begin > info -> end || info -> end > limit ) { goto errout ; } ",external@tremolo/eeb4e45d5683f88488c083ecf142dc89bc3f0b47,CVE-2017-0814,https://android.googlesource.com/platform/external/tremolo/+/eeb4e45d5683f88488c083ecf142dc89bc3f0b47,2017-10-04T01:29Z 1285,CWE-400,"CWE-400 static void Sp_search ( js_State * J ) { js_Regexp * re ; const char * text ; Resub m ; text = checkstring ( J , 0 ) ; if ( js_isregexp ( J , 1 ) ) js_copy ( J , 1 ) ; else if ( js_isundefined ( J , 1 ) ) js_newregexp ( J , """" , 0 ) ; else js_newregexp ( J , js_tostring ( J , 1 ) , 0 ) ; re = js_toregexp ( J , - 1 ) ; if ( ! js_regexec ( re -> prog , text , & m , 0 ) ) js_pushnumber ( J , js_utfptrtoidx ( text , m . sub [ 0 ] . sp ) ) ; else js_pushnumber ( J , - 1 ) ; } "," if ( ! js_doregexec ( J , re -> prog ",ccxvii@mujs/00d4606c3baf813b7b1c176823b2729bf51002a2,CVE-2019-11413,https://github.com/ccxvii/mujs/commit/00d4606c3baf813b7b1c176823b2729bf51002a2,2019-04-22T11:29Z 1286,CWE-119,"CWE-119 int tcp_read_sock ( struct sock * sk , read_descriptor_t * desc , sk_read_actor_t recv_actor ) { struct sk_buff * skb ; struct tcp_sock * tp = tcp_sk ( sk ) ; u32 seq = tp -> copied_seq ; u32 offset ; int copied = 0 ; if ( sk -> sk_state == TCP_LISTEN ) return - ENOTCONN ; while ( ( skb = tcp_recv_skb ( sk , seq , & offset ) ) != NULL ) { if ( offset < skb -> len ) { int used ; size_t len ; len = skb -> len - offset ; if ( tp -> urg_data ) { u32 urg_offset = tp -> urg_seq - seq ; if ( urg_offset < len ) len = urg_offset ; if ( ! len ) break ; } used = recv_actor ( desc , skb , offset , len ) ; if ( used < 0 ) { if ( ! copied ) copied = used ; break ; } else if ( used <= len ) { seq += used ; copied += used ; offset += used ; } skb = tcp_recv_skb ( sk , seq - 1 , & offset ) ; if ( ! skb || ( offset + 1 != skb -> len ) ) break ; } if ( tcp_hdr ( skb ) -> fin ) { sk_eat_skb ( sk , skb , 0 ) ; ++ seq ; break ; } sk_eat_skb ( sk , skb , 0 ) ; if ( ! desc -> count ) break ; } tp -> copied_seq = seq ; tcp_rcv_space_adjust ( sk ) ; if ( copied > 0 ) tcp_cleanup_rbuf ( sk , copied ) ; return copied ; } "," ) break ; tp -> copied_seq = seq ; } tp -> copied_seq = seq ; ",torvalds@linux/baff42ab1494528907bf4d5870359e31711746ae,CVE-2013-2128,https://github.com/torvalds/linux/commit/baff42ab1494528907bf4d5870359e31711746ae,2013-06-07T14:03Z 1287,CWE-000,"CWE-000 static struct berval * * krb5_encode_krbsecretkey ( krb5_key_data * key_data_in , int n_key_data , krb5_kvno mkvno ) { struct berval * * ret = NULL ; int currkvno ; int num_versions = 1 ; int i , j , last ; krb5_error_code err = 0 ; krb5_key_data * key_data ; if ( n_key_data <= 0 ) return NULL ; key_data = k5calloc ( n_key_data , sizeof ( * key_data ) , & err ) ; if ( key_data_in == NULL ) goto cleanup ; memcpy ( key_data , key_data_in , n_key_data * sizeof ( * key_data ) ) ; for ( i = 0 ; i < n_key_data ; i ++ ) { if ( key_data [ i ] . key_data_ver == 1 ) { key_data [ i ] . key_data_ver = 2 ; key_data [ i ] . key_data_type [ 1 ] = KRB5_KDB_SALTTYPE_NORMAL ; key_data [ i ] . key_data_length [ 1 ] = 0 ; key_data [ i ] . key_data_contents [ 1 ] = NULL ; } } for ( i = 0 ; i < n_key_data - 1 ; i ++ ) if ( key_data [ i ] . key_data_kvno != key_data [ i + 1 ] . key_data_kvno ) num_versions ++ ; ret = ( struct berval * * ) calloc ( num_versions + 1 , sizeof ( struct berval * ) ) ; if ( ret == NULL ) { err = ENOMEM ; goto cleanup ; } for ( i = 0 , last = 0 , j = 0 , currkvno = key_data [ 0 ] . key_data_kvno ; i < n_key_data ; i ++ ) { krb5_data * code ; if ( i == n_key_data - 1 || key_data [ i + 1 ] . key_data_kvno != currkvno ) { ret [ j ] = k5alloc ( sizeof ( struct berval ) , & err ) ; if ( ret [ j ] == NULL ) goto cleanup ; err = asn1_encode_sequence_of_keys ( key_data + last , ( krb5_int16 ) i - last + 1 , mkvno , & code ) ; if ( err ) goto cleanup ; ret [ j ] -> bv_len = code -> length ; ret [ j ] -> bv_val = code -> data ; free ( code ) ; j ++ ; last = i + 1 ; if ( i < n_key_data - 1 ) currkvno = key_data [ i + 1 ] . key_data_kvno ; } } ret [ num_versions ] = NULL ; cleanup : free ( key_data ) ; if ( err != 0 ) { if ( ret != NULL ) { for ( i = 0 ; i <= num_versions ; i ++ ) if ( ret [ i ] != NULL ) free ( ret [ i ] ) ; free ( ret ) ; ret = NULL ; } } return ret ; } "," krb5_key_data * key_data = NULL ; if ( n_key_data < 0 ) return ; if ( key_data == NULL ) = 0 ; ret [ i ] != NULL ; i ++ i ++ ) free ( ret ",krb5@krb5/04038bf3633c4b909b5ded3072dc88c8c419bf16,CVE-2014-5354,https://github.com/krb5/krb5/commit/04038bf3633c4b909b5ded3072dc88c8c419bf16,2014-12-16T23:59Z 1288,CWE-190,"CWE-190 static int _Unpickler_MemoPut ( UnpicklerObject * self , Py_ssize_t idx , PyObject * value ) { PyObject * old_item ; if ( idx >= self -> memo_size ) { if ( _Unpickler_ResizeMemoList ( self , idx * 2 ) < 0 ) return - 1 ; assert ( idx < self -> memo_size ) ; } Py_INCREF ( value ) ; old_item = self -> memo [ idx ] ; self -> memo [ idx ] = value ; if ( old_item != NULL ) { Py_DECREF ( old_item ) ; } else { self -> memo_len ++ ; } return 0 ; } "," * self , size_t idx , PyObject ",python@cpython/a4ae828ee416a66d8c7bf5ee71d653c2cc6a26dd,CVE-2018-20406,https://github.com/python/cpython/commit/a4ae828ee416a66d8c7bf5ee71d653c2cc6a26dd,2018-12-23T23:29Z 1289,CWE-190,"CWE-190 static int fts3tokFilterMethod ( sqlite3_vtab_cursor * pCursor , int idxNum , const char * idxStr , int nVal , sqlite3_value * * apVal ) { int rc = SQLITE_ERROR ; Fts3tokCursor * pCsr = ( Fts3tokCursor * ) pCursor ; Fts3tokTable * pTab = ( Fts3tokTable * ) ( pCursor -> pVtab ) ; UNUSED_PARAMETER ( idxStr ) ; UNUSED_PARAMETER ( nVal ) ; fts3tokResetCursor ( pCsr ) ; if ( idxNum == 1 ) { const char * zByte = ( const char * ) sqlite3_value_text ( apVal [ 0 ] ) ; int nByte = sqlite3_value_bytes ( apVal [ 0 ] ) ; pCsr -> zInput = sqlite3_malloc ( nByte + 1 ) ; if ( pCsr -> zInput == 0 ) { rc = SQLITE_NOMEM ; } else { memcpy ( pCsr -> zInput , zByte , nByte ) ; pCsr -> zInput [ nByte ] = 0 ; rc = pTab -> pMod -> xOpen ( pTab -> pTok , pCsr -> zInput , nByte , & pCsr -> pCsr ) ; if ( rc == SQLITE_OK ) { pCsr -> pCsr -> pTokenizer = pTab -> pTok ; } } } if ( rc != SQLITE_OK ) return rc ; return fts3tokNextMethod ( pCursor ) ; } "," -> zInput = sqlite3_malloc64 ( nByte + ",chromium@chromium/517ac71c9ee27f856f9becde8abea7d1604af9d4,CVE-2019-5827,https://github.com/chromium/chromium/commit/517ac71c9ee27f856f9becde8abea7d1604af9d4,2019-06-27T17:15Z 1290,CWE-362,"CWE-362 static int sock_close ( struct inode * inode , struct file * filp ) { sock_release ( SOCKET_I ( inode ) ) ; return 0 ; } "," filp ) { __sock_release ( SOCKET_I ( ( inode ) , inode ",torvalds@linux/6d8c50dcb029872b298eea68cc6209c866fd3e14,CVE-2018-12232,https://github.com/torvalds/linux/commit/6d8c50dcb029872b298eea68cc6209c866fd3e14,2018-06-12T12:29Z 1291,CWE-125,"CWE-125 stmt_ty AsyncFor ( expr_ty target , expr_ty iter , asdl_seq * body , asdl_seq * orelse , int lineno , int col_offset , int end_lineno , int end_col_offset , PyArena * arena ) { stmt_ty p ; if ( ! target ) { PyErr_SetString ( PyExc_ValueError , ""fieldtargetisrequiredforAsyncFor"" ) ; return NULL ; } if ( ! iter ) { PyErr_SetString ( PyExc_ValueError , ""fielditerisrequiredforAsyncFor"" ) ; return NULL ; } p = ( stmt_ty ) PyArena_Malloc ( arena , sizeof ( * p ) ) ; if ( ! p ) return NULL ; p -> kind = AsyncFor_kind ; p -> v . AsyncFor . target = target ; p -> v . AsyncFor . iter = iter ; p -> v . AsyncFor . body = body ; p -> v . AsyncFor . orelse = orelse ; p -> lineno = lineno ; p -> col_offset = col_offset ; p -> end_lineno = end_lineno ; p -> end_col_offset = end_col_offset ; return p ; } "," * orelse , string type_comment , int lineno , int orelse = orelse ; p -> v . AsyncFor . type_comment = type_comment ",python@typed_ast/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,CVE-2019-19275,https://github.com/python/typed_ast/commit/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,2019-11-26T15:15Z 1292,CWE-362,"CWE-362 int mi_sort_index ( MI_CHECK * param , register MI_INFO * info , char * name ) { reg2 uint key ; reg1 MI_KEYDEF * keyinfo ; File new_file ; my_off_t index_pos [ HA_MAX_POSSIBLE_KEY ] ; uint r_locks , w_locks ; int old_lock ; MYISAM_SHARE * share = info -> s ; MI_STATE_INFO old_state ; DBUG_ENTER ( ""mi_sort_index"" ) ; for ( key = 0 , keyinfo = & share -> keyinfo [ 0 ] ; key < share -> base . keys ; key ++ , keyinfo ++ ) if ( keyinfo -> key_alg == HA_KEY_ALG_RTREE ) DBUG_RETURN ( 0 ) ; if ( ! ( param -> testflag & T_SILENT ) ) printf ( ""-SortingindexforMyISAM-table\'%s\'\\n"" , name ) ; fn_format ( param -> temp_filename , name , """" , MI_NAME_IEXT , 2 + 4 + 32 ) ; if ( ( new_file = mysql_file_create ( mi_key_file_datatmp , fn_format ( param -> temp_filename , param -> temp_filename , """" , INDEX_TMP_EXT , 2 + 4 ) , 0 , param -> tmpfile_createflag , MYF ( 0 ) ) ) <= 0 ) { mi_check_print_error ( param , ""Can\'tcreatenewtempfile:\'%s\'"" , param -> temp_filename ) ; DBUG_RETURN ( - 1 ) ; } if ( filecopy ( param , new_file , share -> kfile , 0L , ( ulong ) share -> base . keystart , ""headerblock"" ) ) goto err ; param -> new_file_pos = share -> base . keystart ; for ( key = 0 , keyinfo = & share -> keyinfo [ 0 ] ; key < share -> base . keys ; key ++ , keyinfo ++ ) { if ( ! mi_is_key_active ( info -> s -> state . key_map , key ) ) continue ; if ( share -> state . key_root [ key ] != HA_OFFSET_ERROR ) { index_pos [ key ] = param -> new_file_pos ; if ( sort_one_index ( param , info , keyinfo , share -> state . key_root [ key ] , new_file ) ) goto err ; } else index_pos [ key ] = HA_OFFSET_ERROR ; } flush_key_blocks ( share -> key_cache , share -> kfile , FLUSH_IGNORE_CHANGED ) ; share -> state . version = ( ulong ) time ( ( time_t * ) 0 ) ; old_state = share -> state ; r_locks = share -> r_locks ; w_locks = share -> w_locks ; old_lock = info -> lock_type ; share -> r_locks = share -> w_locks = share -> tot_locks = 0 ; ( void ) _mi_writeinfo ( info , WRITEINFO_UPDATE_KEYFILE ) ; ( void ) mysql_file_close ( share -> kfile , MYF ( MY_WME ) ) ; share -> kfile = - 1 ; ( void ) mysql_file_close ( new_file , MYF ( MY_WME ) ) ; if ( change_to_newfile ( share -> index_file_name , MI_NAME_IEXT , INDEX_TMP_EXT , MYF ( 0 ) ) || mi_open_keyfile ( share ) ) goto err2 ; info -> lock_type = F_UNLCK ; _mi_readinfo ( info , F_WRLCK , 0 ) ; info -> lock_type = old_lock ; share -> r_locks = r_locks ; share -> w_locks = w_locks ; share -> tot_locks = r_locks + w_locks ; share -> state = old_state ; info -> state -> key_file_length = param -> new_file_pos ; info -> update = ( short ) ( HA_STATE_CHANGED | HA_STATE_ROW_CHANGED ) ; for ( key = 0 ; key < info -> s -> base . keys ; key ++ ) info -> s -> state . key_root [ key ] = index_pos [ key ] ; for ( key = 0 ; key < info -> s -> state . header . max_block_size_index ; key ++ ) info -> s -> state . key_del [ key ] = HA_OFFSET_ERROR ; info -> s -> state . changed &= ~ STATE_NOT_SORTED_PAGES ; DBUG_RETURN ( 0 ) ; err : ( void ) mysql_file_close ( new_file , MYF ( MY_WME ) ) ; err2 : ( void ) mysql_file_delete ( mi_key_file_datatmp , param -> temp_filename , MYF ( MY_WME ) ) ; DBUG_RETURN ( - 1 ) ; } "," char * name , my_bool no_copy_stat , INDEX_TMP_EXT , no_copy_stat ? MYF ( MY_REDEL_NO_COPY_STAT ) : ",MariaDB@server/4e5473862e6852b0f3802b0cd0c6fa10b5253291,CVE-2016-6663,https://github.com/MariaDB/server/commit/4e5473862e6852b0f3802b0cd0c6fa10b5253291,2016-12-13T21:59Z 1293,CWE-264,"CWE-264 static struct ipv6_txoptions * ipv6_update_options ( struct sock * sk , struct ipv6_txoptions * opt ) { if ( inet_sk ( sk ) -> is_icsk ) { if ( opt && ! ( ( 1 << sk -> sk_state ) & ( TCPF_LISTEN | TCPF_CLOSE ) ) && inet_sk ( sk ) -> inet_daddr != LOOPBACK4_IPV6 ) { struct inet_connection_sock * icsk = inet_csk ( sk ) ; icsk -> icsk_ext_hdr_len = opt -> opt_flen + opt -> opt_nflen ; icsk -> icsk_sync_mss ( sk , icsk -> icsk_pmtu_cookie ) ; } } opt = xchg ( & inet6_sk ( sk ) -> opt , opt ) ; sk_dst_reset ( sk ) ; return opt ; } "," = xchg ( ( __force struct ipv6_txoptions * * ) ",torvalds@linux/45f6fad84cc305103b28d73482b344d7f5b76f39,CVE-2016-3841,https://github.com/torvalds/linux/commit/45f6fad84cc305103b28d73482b344d7f5b76f39,2016-08-06T20:59Z 1294,CWE-399,"CWE-399 static int handle_exception ( struct kvm_vcpu * vcpu ) { struct vcpu_vmx * vmx = to_vmx ( vcpu ) ; struct kvm_run * kvm_run = vcpu -> run ; u32 intr_info , ex_no , error_code ; unsigned long cr2 , rip , dr6 ; u32 vect_info ; enum emulation_result er ; vect_info = vmx -> idt_vectoring_info ; intr_info = vmx -> exit_intr_info ; if ( is_machine_check ( intr_info ) ) return handle_machine_check ( vcpu ) ; if ( ( intr_info & INTR_INFO_INTR_TYPE_MASK ) == INTR_TYPE_NMI_INTR ) return 1 ; if ( is_no_device ( intr_info ) ) { vmx_fpu_activate ( vcpu ) ; return 1 ; } if ( is_invalid_opcode ( intr_info ) ) { if ( is_guest_mode ( vcpu ) ) { kvm_queue_exception ( vcpu , UD_VECTOR ) ; return 1 ; } er = emulate_instruction ( vcpu , EMULTYPE_TRAP_UD ) ; if ( er != EMULATE_DONE ) kvm_queue_exception ( vcpu , UD_VECTOR ) ; return 1 ; } error_code = 0 ; if ( intr_info & INTR_INFO_DELIVER_CODE_MASK ) error_code = vmcs_read32 ( VM_EXIT_INTR_ERROR_CODE ) ; if ( ( vect_info & VECTORING_INFO_VALID_MASK ) && ! ( is_page_fault ( intr_info ) && ! ( error_code & PFERR_RSVD_MASK ) ) ) { vcpu -> run -> exit_reason = KVM_EXIT_INTERNAL_ERROR ; vcpu -> run -> internal . suberror = KVM_INTERNAL_ERROR_SIMUL_EX ; vcpu -> run -> internal . ndata = 3 ; vcpu -> run -> internal . data [ 0 ] = vect_info ; vcpu -> run -> internal . data [ 1 ] = intr_info ; vcpu -> run -> internal . data [ 2 ] = error_code ; return 0 ; } if ( is_page_fault ( intr_info ) ) { BUG_ON ( enable_ept ) ; cr2 = vmcs_readl ( EXIT_QUALIFICATION ) ; trace_kvm_page_fault ( cr2 , error_code ) ; if ( kvm_event_needs_reinjection ( vcpu ) ) kvm_mmu_unprotect_page_virt ( vcpu , cr2 ) ; return kvm_mmu_page_fault ( vcpu , cr2 , error_code , NULL , 0 ) ; } ex_no = intr_info & INTR_INFO_VECTOR_MASK ; if ( vmx -> rmode . vm86_active && rmode_exception ( vcpu , ex_no ) ) return handle_rmode_exception ( vcpu , ex_no , error_code ) ; switch ( ex_no ) { case DB_VECTOR : dr6 = vmcs_readl ( EXIT_QUALIFICATION ) ; if ( ! ( vcpu -> guest_debug & ( KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP ) ) ) { vcpu -> arch . dr6 &= ~ 15 ; vcpu -> arch . dr6 |= dr6 | DR6_RTM ; if ( ! ( dr6 & ~ DR6_RESERVED ) ) skip_emulated_instruction ( vcpu ) ; kvm_queue_exception ( vcpu , DB_VECTOR ) ; return 1 ; } kvm_run -> debug . arch . dr6 = dr6 | DR6_FIXED_1 ; kvm_run -> debug . arch . dr7 = vmcs_readl ( GUEST_DR7 ) ; case BP_VECTOR : vmx -> vcpu . arch . event_exit_inst_len = vmcs_read32 ( VM_EXIT_INSTRUCTION_LEN ) ; kvm_run -> exit_reason = KVM_EXIT_DEBUG ; rip = kvm_rip_read ( vcpu ) ; kvm_run -> debug . arch . pc = vmcs_readl ( GUEST_CS_BASE ) + rip ; kvm_run -> debug . arch . exception = ex_no ; break ; default : kvm_run -> exit_reason = KVM_EXIT_EXCEPTION ; kvm_run -> ex . exception = ex_no ; kvm_run -> ex . error_code = error_code ; break ; } return 0 ; } "," ) { case AC_VECTOR : kvm_queue_exception_e ( vcpu , AC_VECTOR , error_code ) ; return 1 ; case ",torvalds@linux/54a20552e1eae07aa240fa370a0293e006b5faed,CVE-2015-5307,https://github.com/torvalds/linux/commit/54a20552e1eae07aa240fa370a0293e006b5faed,2015-11-16T11:59Z 1295,CWE-400,"CWE-400 const char * nghttp2_strerror ( int error_code ) { switch ( error_code ) { case 0 : return ""Success"" ; case NGHTTP2_ERR_INVALID_ARGUMENT : return ""Invalidargument"" ; case NGHTTP2_ERR_BUFFER_ERROR : return ""Outofbufferspace"" ; case NGHTTP2_ERR_UNSUPPORTED_VERSION : return ""UnsupportedSPDYversion"" ; case NGHTTP2_ERR_WOULDBLOCK : return ""Operationwouldblock"" ; case NGHTTP2_ERR_PROTO : return ""Protocolerror"" ; case NGHTTP2_ERR_INVALID_FRAME : return ""Invalidframeoctets"" ; case NGHTTP2_ERR_EOF : return ""EOF"" ; case NGHTTP2_ERR_DEFERRED : return ""Datatransferdeferred"" ; case NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE : return ""NomoreStreamIDavailable"" ; case NGHTTP2_ERR_STREAM_CLOSED : return ""Streamwasalreadyclosedorinvalid"" ; case NGHTTP2_ERR_STREAM_CLOSING : return ""Streamisclosing"" ; case NGHTTP2_ERR_STREAM_SHUT_WR : return ""Thetransmissionisnotallowedforthisstream"" ; case NGHTTP2_ERR_INVALID_STREAM_ID : return ""StreamIDisinvalid"" ; case NGHTTP2_ERR_INVALID_STREAM_STATE : return ""Invalidstreamstate"" ; case NGHTTP2_ERR_DEFERRED_DATA_EXIST : return ""AnotherDATAframehasalreadybeendeferred"" ; case NGHTTP2_ERR_START_STREAM_NOT_ALLOWED : return ""requestHEADERSisnotallowed"" ; case NGHTTP2_ERR_GOAWAY_ALREADY_SENT : return ""GOAWAYhasalreadybeensent"" ; case NGHTTP2_ERR_INVALID_HEADER_BLOCK : return ""Invalidheaderblock"" ; case NGHTTP2_ERR_INVALID_STATE : return ""Invalidstate"" ; case NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE : return ""Theusercallbackfunctionfailedduetothetemporalerror"" ; case NGHTTP2_ERR_FRAME_SIZE_ERROR : return ""Thelengthoftheframeisinvalid"" ; case NGHTTP2_ERR_HEADER_COMP : return ""Headercompression/decompressionerror"" ; case NGHTTP2_ERR_FLOW_CONTROL : return ""Flowcontrolerror"" ; case NGHTTP2_ERR_INSUFF_BUFSIZE : return ""Insufficientbuffersizegiventofunction"" ; case NGHTTP2_ERR_PAUSE : return ""Callbackwaspausedbytheapplication"" ; case NGHTTP2_ERR_TOO_MANY_INFLIGHT_SETTINGS : return ""ToomanyinflightSETTINGS"" ; case NGHTTP2_ERR_PUSH_DISABLED : return ""Serverpushisdisabledbypeer"" ; case NGHTTP2_ERR_DATA_EXIST : return ""DATAorHEADERSframehasalreadybeensubmittedforthestream"" ; case NGHTTP2_ERR_SESSION_CLOSING : return ""Thecurrentsessionisclosing"" ; case NGHTTP2_ERR_HTTP_HEADER : return ""InvalidHTTPheaderfieldwasreceived"" ; case NGHTTP2_ERR_HTTP_MESSAGING : return ""ViolationinHTTPmessagingrule"" ; case NGHTTP2_ERR_REFUSED_STREAM : return ""Streamwasrefused"" ; case NGHTTP2_ERR_INTERNAL : return ""Internalerror"" ; case NGHTTP2_ERR_CANCEL : return ""Cancel"" ; case NGHTTP2_ERR_SETTINGS_EXPECTED : return ""WhenalocalendpointexpectstoreceiveSETTINGSframe,it"" ""receivesanothertypeofframe"" ; case NGHTTP2_ERR_NOMEM : return ""Outofmemory"" ; case NGHTTP2_ERR_CALLBACK_FAILURE : return ""Theusercallbackfunctionfailed"" ; case NGHTTP2_ERR_BAD_CLIENT_MAGIC : return ""Receivedbadclientmagicbytestring"" ; case NGHTTP2_ERR_FLOODED : return ""FloodingwasdetectedinthisHTTP/2session,anditmustbe"" ""closed"" ; default : return ""Unknownerrorcode"" ; } } "," ""FloodingwasdetectedinthisHTTP/2session,anditmustbe"" ""closed"" ; case NGHTTP2_ERR_TOO_MANY_SETTINGS : return ""SETTINGSframecontainedmorethanthemaximumallowedentries"" ; ",nghttp2@nghttp2/336a98feb0d56b9ac54e12736b18785c27f75090,CVE-2020-11080,https://github.com/nghttp2/nghttp2/commit/336a98feb0d56b9ac54e12736b18785c27f75090,2020-06-03T23:15Z 1296,CWE-125,"CWE-125 static UINT rdpei_recv_pdu ( RDPEI_CHANNEL_CALLBACK * callback , wStream * s ) { UINT16 eventId ; UINT32 pduLength ; UINT error ; Stream_Read_UINT16 ( s , eventId ) ; Stream_Read_UINT32 ( s , pduLength ) ; # ifdef WITH_DEBUG_RDPEI WLog_DBG ( TAG , ""rdpei_recv_pdu:eventId:%"" PRIu16 ""(%s)length:%"" PRIu32 """" , eventId , rdpei_eventid_string ( eventId ) , pduLength ) ; # endif switch ( eventId ) { case EVENTID_SC_READY : if ( ( error = rdpei_recv_sc_ready_pdu ( callback , s ) ) ) { WLog_ERR ( TAG , ""rdpei_recv_sc_ready_pdufailedwitherror%"" PRIu32 ""!"" , error ) ; return error ; } if ( ( error = rdpei_send_cs_ready_pdu ( callback ) ) ) { WLog_ERR ( TAG , ""rdpei_send_cs_ready_pdufailedwitherror%"" PRIu32 ""!"" , error ) ; return error ; } break ; case EVENTID_SUSPEND_TOUCH : if ( ( error = rdpei_recv_suspend_touch_pdu ( callback , s ) ) ) { WLog_ERR ( TAG , ""rdpei_recv_suspend_touch_pdufailedwitherror%"" PRIu32 ""!"" , error ) ; return error ; } break ; case EVENTID_RESUME_TOUCH : if ( ( error = rdpei_recv_resume_touch_pdu ( callback , s ) ) ) { WLog_ERR ( TAG , ""rdpei_recv_resume_touch_pdufailedwitherror%"" PRIu32 ""!"" , error ) ; return error ; } break ; default : break ; } return CHANNEL_RC_OK ; } "," UINT error ; if ( Stream_GetRemainingLength ( s ) < 6 ) return ERROR_INVALID_DATA ; ",FreeRDP@FreeRDP/6b485b146a1b9d6ce72dfd7b5f36456c166e7a16,CVE-2020-11089,https://github.com/FreeRDP/FreeRDP/commit/6b485b146a1b9d6ce72dfd7b5f36456c166e7a16,2020-05-29T20:15Z 1297,CWE-134,"CWE-134 static rsRetVal initZMQ ( instanceData * pData ) { DEFiRet ; if ( NULL == s_context ) { zsys_handler_set ( NULL ) ; s_context = zctx_new ( ) ; if ( s_workerThreads > 0 ) zctx_set_iothreads ( s_context , s_workerThreads ) ; } pData -> socket = zsocket_new ( s_context , pData -> type ) ; if ( NULL == pData -> socket ) { errmsg . LogError ( 0 , RS_RET_NO_ERRCODE , ""omzmq3:zsocket_newfailedfor%s:%s"" , pData -> description , zmq_strerror ( errno ) ) ; ABORT_FINALIZE ( RS_RET_NO_ERRCODE ) ; } if ( pData -> identity ) zsocket_set_identity ( pData -> socket , ( char * ) pData -> identity ) ; if ( pData -> sndBuf > - 1 ) zsocket_set_sndbuf ( pData -> socket , pData -> sndBuf ) ; if ( pData -> rcvBuf > - 1 ) zsocket_set_sndbuf ( pData -> socket , pData -> rcvBuf ) ; if ( pData -> linger > - 1 ) zsocket_set_linger ( pData -> socket , pData -> linger ) ; if ( pData -> backlog > - 1 ) zsocket_set_backlog ( pData -> socket , pData -> backlog ) ; if ( pData -> sndTimeout > - 1 ) zsocket_set_sndtimeo ( pData -> socket , pData -> sndTimeout ) ; if ( pData -> rcvTimeout > - 1 ) zsocket_set_rcvtimeo ( pData -> socket , pData -> rcvTimeout ) ; if ( pData -> maxMsgSize > - 1 ) zsocket_set_maxmsgsize ( pData -> socket , pData -> maxMsgSize ) ; if ( pData -> rate > - 1 ) zsocket_set_rate ( pData -> socket , pData -> rate ) ; if ( pData -> recoveryIVL > - 1 ) zsocket_set_recovery_ivl ( pData -> socket , pData -> recoveryIVL ) ; if ( pData -> multicastHops > - 1 ) zsocket_set_multicast_hops ( pData -> socket , pData -> multicastHops ) ; if ( pData -> reconnectIVL > - 1 ) zsocket_set_reconnect_ivl ( pData -> socket , pData -> reconnectIVL ) ; if ( pData -> reconnectIVLMax > - 1 ) zsocket_set_reconnect_ivl_max ( pData -> socket , pData -> reconnectIVLMax ) ; if ( pData -> ipv4Only > - 1 ) zsocket_set_ipv4only ( pData -> socket , pData -> ipv4Only ) ; if ( pData -> affinity != 1 ) zsocket_set_affinity ( pData -> socket , pData -> affinity ) ; if ( pData -> rcvHWM > - 1 ) zsocket_set_rcvhwm ( pData -> socket , pData -> rcvHWM ) ; if ( pData -> sndHWM > - 1 ) zsocket_set_sndhwm ( pData -> socket , pData -> sndHWM ) ; if ( pData -> action == ACTION_BIND ) { if ( - 1 == zsocket_bind ( pData -> socket , ( char * ) pData -> description ) ) { errmsg . LogError ( 0 , RS_RET_NO_ERRCODE , ""omzmq3:bindfailedfor%s:%s"" , pData -> description , zmq_strerror ( errno ) ) ; ABORT_FINALIZE ( RS_RET_NO_ERRCODE ) ; } DBGPRINTF ( ""omzmq3:bindto%ssuccessful\\n"" , pData -> description ) ; } else { if ( - 1 == zsocket_connect ( pData -> socket , ( char * ) pData -> description ) ) { errmsg . LogError ( 0 , RS_RET_NO_ERRCODE , ""omzmq3:connectfailedfor%s:%s"" , pData -> description , zmq_strerror ( errno ) ) ; ABORT_FINALIZE ( RS_RET_NO_ERRCODE ) ; } DBGPRINTF ( ""omzmq3:connectto%ssuccessful"" , pData -> description ) ; } finalize_it : RETiRet ; } "," -> socket , ""%s"" , -> socket , ""%s"" , ",rsyslog@rsyslog/062d0c671a29f7c6f7dff4a2f1f35df375bbb30b,CVE-2017-12588,https://github.com/rsyslog/rsyslog/commit/062d0c671a29f7c6f7dff4a2f1f35df375bbb30b,2017-08-06T14:29Z 1298,CWE-399,"CWE-399 int hugetlb_reserve_pages ( struct inode * inode , long from , long to , struct vm_area_struct * vma , vm_flags_t vm_flags ) { long ret , chg ; struct hstate * h = hstate_inode ( inode ) ; struct hugepage_subpool * spool = subpool_inode ( inode ) ; if ( vm_flags & VM_NORESERVE ) return 0 ; if ( ! vma || vma -> vm_flags & VM_MAYSHARE ) chg = region_chg ( & inode -> i_mapping -> private_list , from , to ) ; else { struct resv_map * resv_map = resv_map_alloc ( ) ; if ( ! resv_map ) return - ENOMEM ; chg = to - from ; set_vma_resv_map ( vma , resv_map ) ; set_vma_resv_flags ( vma , HPAGE_RESV_OWNER ) ; } if ( chg < 0 ) return chg ; if ( hugepage_subpool_get_pages ( spool , chg ) ) return - ENOSPC ; ret = hugetlb_acct_memory ( h , chg ) ; if ( ret < 0 ) { hugepage_subpool_put_pages ( spool , chg ) ; return ret ; } if ( ! vma || vma -> vm_flags & VM_MAYSHARE ) region_add ( & inode -> i_mapping -> private_list , from , to ) ; return 0 ; } "," < 0 ) { ret = chg ; goto out_err ; } if ( hugepage_subpool_get_pages chg ) ) { ret = - ENOSPC ; - ENOSPC ; goto out_err ; } chg ) ; goto out_err ; } if return 0 ; out_err : resv_map_put ( vma ) ; return ret ; ",torvalds@linux/c50ac050811d6485616a193eb0f37bfbd191cc89,CVE-2012-2390,https://github.com/torvalds/linux/commit/c50ac050811d6485616a193eb0f37bfbd191cc89,2012-06-13T10:24Z 1299,CWE-310,"CWE-310 static int sctp_v6_xmit ( struct sk_buff * skb , struct sctp_transport * transport ) { struct sock * sk = skb -> sk ; struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct flowi6 fl6 ; memset ( & fl6 , 0 , sizeof ( fl6 ) ) ; fl6 . flowi6_proto = sk -> sk_protocol ; fl6 . daddr = transport -> ipaddr . v6 . sin6_addr ; fl6 . saddr = transport -> saddr . v6 . sin6_addr ; fl6 . flowlabel = np -> flow_label ; IP6_ECN_flow_xmit ( sk , fl6 . flowlabel ) ; if ( ipv6_addr_type ( & fl6 . saddr ) & IPV6_ADDR_LINKLOCAL ) fl6 . flowi6_oif = transport -> saddr . v6 . sin6_scope_id ; else fl6 . flowi6_oif = sk -> sk_bound_dev_if ; if ( np -> opt && np -> opt -> srcrt ) { struct rt0_hdr * rt0 = ( struct rt0_hdr * ) np -> opt -> srcrt ; fl6 . daddr = * rt0 -> addr ; } pr_debug ( ""%s:skb:%p,len:%d,src:%pI6dst:%pI6\\n"" , __func__ , skb , skb -> len , & fl6 . saddr , & fl6 . daddr ) ; SCTP_INC_STATS ( sock_net ( sk ) , SCTP_MIB_OUTSCTPPACKS ) ; if ( ! ( transport -> param_flags & SPP_PMTUD_ENABLE ) ) skb -> local_df = 1 ; return ip6_xmit ( sk , skb , & fl6 , np -> opt , np -> tclass ) ; } "," ; struct flowi6 * fl6 = & transport -> fl . u . ip6 ; pr_debug ( ""%s:skb:%p,len:%d,src:%pI6dst:%pI6\\n"" , & fl6 -> saddr , & , & fl6 -> daddr ) ; daddr ) ; IP6_ECN_flow_xmit ( sk , fl6 -> flowlabel ) ; if = 1 ; SCTP_INC_STATS ( sock_net ( sk ) , SCTP_MIB_OUTSCTPPACKS ) ; , skb , fl6 , np ",torvalds@linux/95ee62083cb6453e056562d91f597552021e6ae7,CVE-2013-4350,https://github.com/torvalds/linux/commit/95ee62083cb6453e056562d91f597552021e6ae7,2013-09-25T10:31Z 1300,CWE-264,"CWE-264 static struct dentry * ecryptfs_mount ( struct file_system_type * fs_type , int flags , const char * dev_name , void * raw_data ) { struct super_block * s ; struct ecryptfs_sb_info * sbi ; struct ecryptfs_dentry_info * root_info ; const char * err = ""Gettingsbfailed"" ; struct inode * inode ; struct path path ; uid_t check_ruid ; int rc ; sbi = kmem_cache_zalloc ( ecryptfs_sb_info_cache , GFP_KERNEL ) ; if ( ! sbi ) { rc = - ENOMEM ; goto out ; } rc = ecryptfs_parse_options ( sbi , raw_data , & check_ruid ) ; if ( rc ) { err = ""Errorparsingoptions"" ; goto out ; } s = sget ( fs_type , NULL , set_anon_super , flags , NULL ) ; if ( IS_ERR ( s ) ) { rc = PTR_ERR ( s ) ; goto out ; } rc = bdi_setup_and_register ( & sbi -> bdi , ""ecryptfs"" , BDI_CAP_MAP_COPY ) ; if ( rc ) goto out1 ; ecryptfs_set_superblock_private ( s , sbi ) ; s -> s_bdi = & sbi -> bdi ; sbi = NULL ; s -> s_op = & ecryptfs_sops ; s -> s_d_op = & ecryptfs_dops ; err = ""Readingsbfailed"" ; rc = kern_path ( dev_name , LOOKUP_FOLLOW | LOOKUP_DIRECTORY , & path ) ; if ( rc ) { ecryptfs_printk ( KERN_WARNING , ""kern_path()failed\\n"" ) ; goto out1 ; } if ( path . dentry -> d_sb -> s_type == & ecryptfs_fs_type ) { rc = - EINVAL ; printk ( KERN_ERR ""Mountonfilesystemoftype"" ""eCryptfsexplicitlydisalloweddueto"" ""knownincompatibilities\\n"" ) ; goto out_free ; } if ( check_ruid && ! uid_eq ( path . dentry -> d_inode -> i_uid , current_uid ( ) ) ) { rc = - EPERM ; printk ( KERN_ERR ""Mountofdevice(uid:%d)notownedby"" ""requesteduser(uid:%d)\\n"" , i_uid_read ( path . dentry -> d_inode ) , from_kuid ( & init_user_ns , current_uid ( ) ) ) ; goto out_free ; } ecryptfs_set_superblock_lower ( s , path . dentry -> d_sb ) ; s -> s_flags = flags & ~ MS_POSIXACL ; s -> s_flags |= path . dentry -> d_sb -> s_flags & ( MS_RDONLY | MS_POSIXACL ) ; s -> s_maxbytes = path . dentry -> d_sb -> s_maxbytes ; s -> s_blocksize = path . dentry -> d_sb -> s_blocksize ; s -> s_magic = ECRYPTFS_SUPER_MAGIC ; inode = ecryptfs_get_inode ( path . dentry -> d_inode , s ) ; rc = PTR_ERR ( inode ) ; if ( IS_ERR ( inode ) ) goto out_free ; s -> s_root = d_make_root ( inode ) ; if ( ! s -> s_root ) { rc = - ENOMEM ; goto out_free ; } rc = - ENOMEM ; root_info = kmem_cache_zalloc ( ecryptfs_dentry_info_cache , GFP_KERNEL ) ; if ( ! root_info ) goto out_free ; ecryptfs_set_dentry_private ( s -> s_root , root_info ) ; root_info -> lower_path = path ; s -> s_flags |= MS_ACTIVE ; return dget ( s -> s_root ) ; out_free : path_put ( & path ) ; out1 : deactivate_locked_super ( s ) ; out : if ( sbi ) { ecryptfs_destroy_mount_crypt_stat ( & sbi -> mount_crypt_stat ) ; kmem_cache_free ( ecryptfs_sb_info_cache , sbi ) ; } printk ( KERN_ERR ""%s;rc=[%d]\\n"" , err , rc ) ; return ERR_PTR ( rc ) ; } "," = ECRYPTFS_SUPER_MAGIC ; s -> s_stack_depth = path . dentry -> d_sb -> s_stack_depth + 1 ; rc = - EINVAL ; if ( s -> s_stack_depth > FILESYSTEM_MAX_STACK_DEPTH ) { pr_err ( ""eCryptfs:maximumfsstackingdepthexceeded\\n"" ) ; goto out_free ; } ",torvalds@linux/69c433ed2ecd2d3264efd7afec4439524b319121,CVE-2014-9922,https://github.com/torvalds/linux/commit/69c433ed2ecd2d3264efd7afec4439524b319121,2017-04-04T05:59Z 1301,CWE-399,"CWE-399 static int simulate_rdhwr ( struct pt_regs * regs , unsigned int opcode ) { struct thread_info * ti = task_thread_info ( current ) ; if ( ( opcode & OPCODE ) == SPEC3 && ( opcode & FUNC ) == RDHWR ) { int rd = ( opcode & RD ) >> 11 ; int rt = ( opcode & RT ) >> 16 ; perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , 0 ) ; switch ( rd ) { case 0 : regs -> regs [ rt ] = smp_processor_id ( ) ; return 0 ; case 1 : regs -> regs [ rt ] = min ( current_cpu_data . dcache . linesz , current_cpu_data . icache . linesz ) ; return 0 ; case 2 : regs -> regs [ rt ] = read_c0_count ( ) ; return 0 ; case 3 : switch ( current_cpu_data . cputype ) { case CPU_20KC : case CPU_25KF : regs -> regs [ rt ] = 1 ; break ; default : regs -> regs [ rt ] = 2 ; } return 0 ; case 29 : regs -> regs [ rt ] = ti -> tp_value ; return 0 ; default : return - 1 ; } } return - 1 ; } "," , 1 , regs , 0 ",torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,CVE-2011-2918,https://github.com/torvalds/linux/commit/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,2012-05-24T23:55Z 1302,CWE-20,"CWE-20 static Image * ReadMATImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { Image * image , * image2 = NULL , * rotated_image ; PixelPacket * q ; unsigned int status ; MATHeader MATLAB_HDR ; size_t size ; size_t CellType ; QuantumInfo * quantum_info ; ImageInfo * clone_info ; int i ; ssize_t ldblk ; unsigned char * BImgBuff = NULL ; double MinVal , MaxVal ; size_t Unknown6 ; unsigned z , z2 ; unsigned Frames ; int logging ; int sample_size ; MagickOffsetType filepos = 0x80 ; BlobInfo * blob ; size_t one ; unsigned int ( * ReadBlobXXXLong ) ( Image * image ) ; unsigned short ( * ReadBlobXXXShort ) ( Image * image ) ; void ( * ReadBlobDoublesXXX ) ( Image * image , size_t len , double * data ) ; void ( * ReadBlobFloatsXXX ) ( Image * image , size_t len , float * data ) ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; logging = LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""enter"" ) ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } clone_info = CloneImageInfo ( image_info ) ; if ( ReadBlob ( image , 124 , ( unsigned char * ) & MATLAB_HDR . identific ) != 124 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( strncmp ( MATLAB_HDR . identific , ""MATLAB"" , 6 ) != 0 ) { image2 = ReadMATImageV4 ( image_info , image , exception ) ; if ( image2 == NULL ) goto MATLAB_KO ; image = image2 ; goto END_OF_READING ; } MATLAB_HDR . Version = ReadBlobLSBShort ( image ) ; if ( ReadBlob ( image , 2 , ( unsigned char * ) & MATLAB_HDR . EndianIndicator ) != 2 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""Endian%c%c"" , MATLAB_HDR . EndianIndicator [ 0 ] , MATLAB_HDR . EndianIndicator [ 1 ] ) ; if ( ! strncmp ( MATLAB_HDR . EndianIndicator , ""IM"" , 2 ) ) { ReadBlobXXXLong = ReadBlobLSBLong ; ReadBlobXXXShort = ReadBlobLSBShort ; ReadBlobDoublesXXX = ReadBlobDoublesLSB ; ReadBlobFloatsXXX = ReadBlobFloatsLSB ; image -> endian = LSBEndian ; } else if ( ! strncmp ( MATLAB_HDR . EndianIndicator , ""MI"" , 2 ) ) { ReadBlobXXXLong = ReadBlobMSBLong ; ReadBlobXXXShort = ReadBlobMSBShort ; ReadBlobDoublesXXX = ReadBlobDoublesMSB ; ReadBlobFloatsXXX = ReadBlobFloatsMSB ; image -> endian = MSBEndian ; } else goto MATLAB_KO ; if ( strncmp ( MATLAB_HDR . identific , ""MATLAB"" , 6 ) ) MATLAB_KO : ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; filepos = TellBlob ( image ) ; while ( ! EOFBlob ( image ) ) { Frames = 1 ; ( void ) SeekBlob ( image , filepos , SEEK_SET ) ; MATLAB_HDR . DataType = ReadBlobXXXLong ( image ) ; if ( EOFBlob ( image ) ) break ; MATLAB_HDR . ObjectSize = ReadBlobXXXLong ( image ) ; if ( EOFBlob ( image ) ) break ; filepos += MATLAB_HDR . ObjectSize + 4 + 4 ; image2 = image ; # if defined ( MAGICKCORE_ZLIB_DELEGATE ) if ( MATLAB_HDR . DataType == miCOMPRESSED ) { image2 = DecompressBlock ( image , MATLAB_HDR . ObjectSize , clone_info , exception ) ; if ( image2 == NULL ) continue ; MATLAB_HDR . DataType = ReadBlobXXXLong ( image2 ) ; } # endif if ( MATLAB_HDR . DataType != miMATRIX ) continue ; MATLAB_HDR . unknown1 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . unknown2 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . unknown5 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . StructureClass = MATLAB_HDR . unknown5 & 0xFF ; MATLAB_HDR . StructureFlag = ( MATLAB_HDR . unknown5 >> 8 ) & 0xFF ; MATLAB_HDR . unknown3 = ReadBlobXXXLong ( image2 ) ; if ( image != image2 ) MATLAB_HDR . unknown4 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . unknown4 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . DimFlag = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . SizeX = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . SizeY = ReadBlobXXXLong ( image2 ) ; switch ( MATLAB_HDR . DimFlag ) { case 8 : z2 = z = 1 ; break ; case 12 : z2 = z = ReadBlobXXXLong ( image2 ) ; Unknown6 = ReadBlobXXXLong ( image2 ) ; ( void ) Unknown6 ; if ( z != 3 ) ThrowReaderException ( CoderError , ""MultidimensionalMatricesAreNotSupported"" ) ; break ; case 16 : z2 = z = ReadBlobXXXLong ( image2 ) ; if ( z != 3 && z != 1 ) ThrowReaderException ( CoderError , ""MultidimensionalMatricesAreNotSupported"" ) ; Frames = ReadBlobXXXLong ( image2 ) ; break ; default : ThrowReaderException ( CoderError , ""MultidimensionalMatricesAreNotSupported"" ) ; } MATLAB_HDR . Flag1 = ReadBlobXXXShort ( image2 ) ; MATLAB_HDR . NameFlag = ReadBlobXXXShort ( image2 ) ; if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATLAB_HDR.StructureClass%d"" , MATLAB_HDR . StructureClass ) ; if ( MATLAB_HDR . StructureClass != mxCHAR_CLASS && MATLAB_HDR . StructureClass != mxSINGLE_CLASS && MATLAB_HDR . StructureClass != mxDOUBLE_CLASS && MATLAB_HDR . StructureClass != mxINT8_CLASS && MATLAB_HDR . StructureClass != mxUINT8_CLASS && MATLAB_HDR . StructureClass != mxINT16_CLASS && MATLAB_HDR . StructureClass != mxUINT16_CLASS && MATLAB_HDR . StructureClass != mxINT32_CLASS && MATLAB_HDR . StructureClass != mxUINT32_CLASS && MATLAB_HDR . StructureClass != mxINT64_CLASS && MATLAB_HDR . StructureClass != mxUINT64_CLASS ) ThrowReaderException ( CoderError , ""UnsupportedCellTypeInTheMatrix"" ) ; switch ( MATLAB_HDR . NameFlag ) { case 0 : size = ReadBlobXXXLong ( image2 ) ; size = 4 * ( ssize_t ) ( ( size + 3 + 1 ) / 4 ) ; ( void ) SeekBlob ( image2 , size , SEEK_CUR ) ; break ; case 1 : case 2 : case 3 : case 4 : ( void ) ReadBlob ( image2 , 4 , ( unsigned char * ) & size ) ; break ; default : goto MATLAB_KO ; } CellType = ReadBlobXXXLong ( image2 ) ; if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATLAB_HDR.CellType:%.20g"" , ( double ) CellType ) ; ( void ) ReadBlob ( image2 , 4 , ( unsigned char * ) & size ) ; NEXT_FRAME : switch ( CellType ) { case miINT8 : case miUINT8 : sample_size = 8 ; if ( MATLAB_HDR . StructureFlag & FLAG_LOGICAL ) image -> depth = 1 ; else image -> depth = 8 ; ldblk = ( ssize_t ) MATLAB_HDR . SizeX ; break ; case miINT16 : case miUINT16 : sample_size = 16 ; image -> depth = 16 ; ldblk = ( ssize_t ) ( 2 * MATLAB_HDR . SizeX ) ; break ; case miINT32 : case miUINT32 : sample_size = 32 ; image -> depth = 32 ; ldblk = ( ssize_t ) ( 4 * MATLAB_HDR . SizeX ) ; break ; case miINT64 : case miUINT64 : sample_size = 64 ; image -> depth = 64 ; ldblk = ( ssize_t ) ( 8 * MATLAB_HDR . SizeX ) ; break ; case miSINGLE : sample_size = 32 ; image -> depth = 32 ; ( void ) SetImageOption ( clone_info , ""quantum:format"" , ""floating-point"" ) ; if ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) { } ldblk = ( ssize_t ) ( 4 * MATLAB_HDR . SizeX ) ; break ; case miDOUBLE : sample_size = 64 ; image -> depth = 64 ; ( void ) SetImageOption ( clone_info , ""quantum:format"" , ""floating-point"" ) ; DisableMSCWarning ( 4127 ) if ( sizeof ( double ) != 8 ) RestoreMSCWarning ThrowReaderException ( CoderError , ""IncompatibleSizeOfDouble"" ) ; if ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) { } ldblk = ( ssize_t ) ( 8 * MATLAB_HDR . SizeX ) ; break ; default : ThrowReaderException ( CoderError , ""UnsupportedCellTypeInTheMatrix"" ) ; } ( void ) sample_size ; image -> columns = MATLAB_HDR . SizeX ; image -> rows = MATLAB_HDR . SizeY ; quantum_info = AcquireQuantumInfo ( clone_info , image ) ; if ( quantum_info == ( QuantumInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; one = 1 ; image -> colors = one << image -> depth ; if ( image -> columns == 0 || image -> rows == 0 ) goto MATLAB_KO ; if ( ( MATLAB_HDR . DimFlag == 8 ) && ( ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) == 0 ) ) { SetImageColorspace ( image , GRAYColorspace ) ; image -> type = GrayscaleType ; } if ( image_info -> ping ) { size_t temp = image -> columns ; image -> columns = image -> rows ; image -> rows = temp ; goto done_reading ; } status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; } BImgBuff = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) ( ldblk ) , sizeof ( double ) ) ; if ( BImgBuff == NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; MinVal = 0 ; MaxVal = 0 ; if ( CellType == miDOUBLE || CellType == miSINGLE ) { CalcMinMax ( image2 , image_info -> endian , MATLAB_HDR . SizeX , MATLAB_HDR . SizeY , CellType , ldblk , BImgBuff , & quantum_info -> minimum , & quantum_info -> maximum ) ; } if ( z == 1 ) z = 0 ; do { for ( i = 0 ; i < ( ssize_t ) MATLAB_HDR . SizeY ; i ++ ) { q = GetAuthenticPixels ( image , 0 , MATLAB_HDR . SizeY - i - 1 , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) { if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATsetimagepixelsreturnsunexpectedNULLonarow%u."" , ( unsigned ) ( MATLAB_HDR . SizeY - i - 1 ) ) ; goto done_reading ; } if ( ReadBlob ( image2 , ldblk , ( unsigned char * ) BImgBuff ) != ( ssize_t ) ldblk ) { if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATcannotreadscanrow%ufromafile."" , ( unsigned ) ( MATLAB_HDR . SizeY - i - 1 ) ) ; goto ExitLoop ; } if ( ( CellType == miINT8 || CellType == miUINT8 ) && ( MATLAB_HDR . StructureFlag & FLAG_LOGICAL ) ) { FixLogical ( ( unsigned char * ) BImgBuff , ldblk ) ; if ( ImportQuantumPixels ( image , ( CacheView * ) NULL , quantum_info , z2qtype [ z ] , BImgBuff , exception ) <= 0 ) { ImportQuantumPixelsFailed : if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATfailedtoImportQuantumPixelsforarow%u"" , ( unsigned ) ( MATLAB_HDR . SizeY - i - 1 ) ) ; break ; } } else { if ( ImportQuantumPixels ( image , ( CacheView * ) NULL , quantum_info , z2qtype [ z ] , BImgBuff , exception ) <= 0 ) goto ImportQuantumPixelsFailed ; if ( z <= 1 && ( CellType == miINT8 || CellType == miINT16 || CellType == miINT32 || CellType == miINT64 ) ) FixSignedValues ( q , MATLAB_HDR . SizeX ) ; } if ( ! SyncAuthenticPixels ( image , exception ) ) { if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATfailedtosyncimagepixelsforarow%u"" , ( unsigned ) ( MATLAB_HDR . SizeY - i - 1 ) ) ; goto ExitLoop ; } } } while ( z -- >= 2 ) ; quantum_info = DestroyQuantumInfo ( quantum_info ) ; ExitLoop : if ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) { CellType = ReadBlobXXXLong ( image2 ) ; i = ReadBlobXXXLong ( image2 ) ; if ( CellType == miDOUBLE || CellType == miSINGLE ) { CalcMinMax ( image2 , image_info -> endian , MATLAB_HDR . SizeX , MATLAB_HDR . SizeY , CellType , ldblk , BImgBuff , & MinVal , & MaxVal ) ; } if ( CellType == miDOUBLE ) for ( i = 0 ; i < ( ssize_t ) MATLAB_HDR . SizeY ; i ++ ) { ReadBlobDoublesXXX ( image2 , ldblk , ( double * ) BImgBuff ) ; InsertComplexDoubleRow ( ( double * ) BImgBuff , i , image , MinVal , MaxVal ) ; } if ( CellType == miSINGLE ) for ( i = 0 ; i < ( ssize_t ) MATLAB_HDR . SizeY ; i ++ ) { ReadBlobFloatsXXX ( image2 , ldblk , ( float * ) BImgBuff ) ; InsertComplexFloatRow ( ( float * ) BImgBuff , i , image , MinVal , MaxVal ) ; } } if ( ( MATLAB_HDR . DimFlag == 8 ) && ( ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) == 0 ) ) image -> type = GrayscaleType ; if ( image -> depth == 1 ) image -> type = BilevelType ; if ( image2 == image ) image2 = NULL ; rotated_image = RotateImage ( image , 90.0 , exception ) ; if ( rotated_image != ( Image * ) NULL ) { rotated_image -> page . x = 0 ; rotated_image -> page . y = 0 ; blob = rotated_image -> blob ; rotated_image -> blob = image -> blob ; rotated_image -> colors = image -> colors ; image -> blob = blob ; AppendImageToList ( & image , rotated_image ) ; DeleteImageFromList ( & image ) ; } done_reading : if ( image2 != NULL ) if ( image2 != image ) { DeleteImageFromList ( & image2 ) ; if ( clone_info ) { if ( clone_info -> file ) { fclose ( clone_info -> file ) ; clone_info -> file = NULL ; ( void ) remove_utf8 ( clone_info -> filename ) ; } } } AcquireNextImage ( image_info , image ) ; if ( image -> next == ( Image * ) NULL ) break ; image = SyncNextImageInList ( image ) ; image -> columns = image -> rows = 0 ; image -> colors = 0 ; RelinquishMagickMemory ( BImgBuff ) ; BImgBuff = NULL ; if ( -- Frames > 0 ) { z = z2 ; if ( image2 == NULL ) image2 = image ; goto NEXT_FRAME ; } if ( image2 != NULL ) if ( image2 != image ) { DeleteImageFromList ( & image2 ) ; if ( clone_info ) { if ( clone_info -> file ) { fclose ( clone_info -> file ) ; clone_info -> file = NULL ; ( void ) unlink ( clone_info -> filename ) ; } } } } RelinquishMagickMemory ( BImgBuff ) ; END_OF_READING : clone_info = DestroyImageInfo ( clone_info ) ; CloseBlob ( image ) ; { Image * p ; ssize_t scene = 0 ; p = image ; image = NULL ; while ( p != ( Image * ) NULL ) { Image * tmp = p ; if ( ( p -> rows == 0 ) || ( p -> columns == 0 ) ) { p = p -> previous ; DeleteImageFromList ( & tmp ) ; } else { image = p ; p = p -> previous ; } } for ( p = image ; p != ( Image * ) NULL ; p = p -> next ) p -> scene = scene ++ ; } if ( clone_info != NULL ) { if ( clone_info -> file ) { fclose ( clone_info -> file ) ; clone_info -> file = NULL ; ( void ) remove_utf8 ( clone_info -> filename ) ; } DestroyImageInfo ( clone_info ) ; clone_info = NULL ; } if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""return"" ) ; if ( image == NULL ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; return ( image ) ; } "," image2 ) ; if ( Frames == 0 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; ",ImageMagick@ImageMagick/8a370f9ab120faf182aa160900ba692ba8e2bcf0,CVE-2016-10069,https://github.com/ImageMagick/ImageMagick/commit/8a370f9ab120faf182aa160900ba692ba8e2bcf0,2017-03-02T21:59Z 1303,CWE-125,"CWE-125 void nego_process_negotiation_failure ( rdpNego * nego , wStream * s ) { BYTE flags ; UINT16 length ; UINT32 failureCode ; WLog_DBG ( TAG , ""RDP_NEG_FAILURE"" ) ; Stream_Read_UINT8 ( s , flags ) ; Stream_Read_UINT16 ( s , length ) ; Stream_Read_UINT32 ( s , failureCode ) ; switch ( failureCode ) { case SSL_REQUIRED_BY_SERVER : WLog_WARN ( TAG , ""Error:SSL_REQUIRED_BY_SERVER"" ) ; break ; case SSL_NOT_ALLOWED_BY_SERVER : WLog_WARN ( TAG , ""Error:SSL_NOT_ALLOWED_BY_SERVER"" ) ; nego -> sendNegoData = TRUE ; break ; case SSL_CERT_NOT_ON_SERVER : WLog_ERR ( TAG , ""Error:SSL_CERT_NOT_ON_SERVER"" ) ; nego -> sendNegoData = TRUE ; break ; case INCONSISTENT_FLAGS : WLog_ERR ( TAG , ""Error:INCONSISTENT_FLAGS"" ) ; break ; case HYBRID_REQUIRED_BY_SERVER : WLog_WARN ( TAG , ""Error:HYBRID_REQUIRED_BY_SERVER"" ) ; break ; default : WLog_ERR ( TAG , ""Error:Unknownprotocolsecurityerror%"" PRIu32 """" , failureCode ) ; break ; } nego -> state = NEGO_STATE_FAIL ; } "," BOOL nego_process_negotiation_failure ( rdpNego , ""RDP_NEG_FAILURE"" ) ; if ( Stream_GetRemainingLength ( s ) < 7 ) return FALSE = NEGO_STATE_FAIL ; return TRUE ; ",FreeRDP@FreeRDP/6b485b146a1b9d6ce72dfd7b5f36456c166e7a16,CVE-2020-11089,https://github.com/FreeRDP/FreeRDP/commit/6b485b146a1b9d6ce72dfd7b5f36456c166e7a16,2020-05-29T20:15Z 1304,CWE-255,"CWE-255 kadm5_ret_t kadm5_randkey_principal_3 ( void * server_handle , krb5_principal principal , krb5_boolean keepold , int n_ks_tuple , krb5_key_salt_tuple * ks_tuple , krb5_keyblock * * keyblocks , int * n_keys ) { krb5_db_entry * kdb ; osa_princ_ent_rec adb ; krb5_int32 now ; kadm5_policy_ent_rec pol ; int ret , last_pwd ; krb5_boolean have_pol = FALSE ; kadm5_server_handle_t handle = server_handle ; krb5_keyblock * act_mkey ; krb5_kvno act_kvno ; int new_n_ks_tuple = 0 ; krb5_key_salt_tuple * new_ks_tuple = NULL ; if ( keyblocks ) * keyblocks = NULL ; CHECK_HANDLE ( server_handle ) ; krb5_clear_error_message ( handle -> context ) ; if ( principal == NULL ) return EINVAL ; if ( ( ret = kdb_get_entry ( handle , principal , & kdb , & adb ) ) ) return ( ret ) ; ret = apply_keysalt_policy ( handle , adb . policy , n_ks_tuple , ks_tuple , & new_n_ks_tuple , & new_ks_tuple ) ; if ( ret ) goto done ; if ( krb5_principal_compare ( handle -> context , principal , hist_princ ) ) { if ( keepold ) return KADM5_PROTECT_PRINCIPAL ; new_n_ks_tuple = 1 ; } ret = kdb_get_active_mkey ( handle , & act_kvno , & act_mkey ) ; if ( ret ) goto done ; ret = krb5_dbe_crk ( handle -> context , act_mkey , new_ks_tuple , new_n_ks_tuple , keepold , kdb ) ; if ( ret ) goto done ; ret = krb5_dbe_update_mkvno ( handle -> context , kdb , act_kvno ) ; if ( ret ) goto done ; kdb -> attributes &= ~ KRB5_KDB_REQUIRES_PWCHANGE ; ret = krb5_timeofday ( handle -> context , & now ) ; if ( ret ) goto done ; if ( ( adb . aux_attributes & KADM5_POLICY ) ) { ret = get_policy ( handle , adb . policy , & pol , & have_pol ) ; if ( ret ) goto done ; } if ( have_pol ) { ret = krb5_dbe_lookup_last_pwd_change ( handle -> context , kdb , & last_pwd ) ; if ( ret ) goto done ; # if 0 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 ; kdb -> fail_auth_count = 0 ; if ( keyblocks ) { ret = decrypt_key_data ( handle -> context , kdb -> n_key_data , kdb -> key_data , keyblocks , n_keys ) ; if ( ret ) goto done ; } kdb -> mask = KADM5_KEY_DATA | KADM5_FAIL_AUTH_COUNT ; ; ret = k5_kadm5_hook_chpass ( handle -> context , handle -> hook_handles , KADM5_HOOK_STAGE_PRECOMMIT , principal , keepold , new_n_ks_tuple , new_ks_tuple , NULL ) ; if ( ret ) goto done ; if ( ( ret = kdb_put_entry ( handle , kdb , & adb ) ) ) goto done ; ( void ) k5_kadm5_hook_chpass ( handle -> context , handle -> hook_handles , KADM5_HOOK_STAGE_POSTCOMMIT , principal , keepold , new_n_ks_tuple , new_ks_tuple , NULL ) ; ret = KADM5_OK ; done : free ( new_ks_tuple ) ; kdb_free_entry ( handle , kdb , & adb ) ; if ( have_pol ) kadm5_free_policy_ent ( handle -> lhandle , & pol ) ; return ret ; } "," ret , last_pwd , n_new_keys keyblocks ) { n_new_keys = count_new_keys ( kdb -> n_key_data , kdb -> key_data ) ; -> context , n_new_keys , kdb -> ",krb5@krb5/af0ed4df4dfae762ab5fb605f5a0c8f59cb4f6ca,CVE-2014-5351,https://github.com/krb5/krb5/commit/af0ed4df4dfae762ab5fb605f5a0c8f59cb4f6ca,2014-10-10T01:55Z 1305,CWE-120,"CWE-120 static int pad_pkcs1 ( bn_t m , int * p_len , int m_len , int k_len , int operation ) { uint8_t * id , pad = 0 ; int len , result = RLC_OK ; bn_t t ; bn_null ( t ) ; RLC_TRY { bn_new ( t ) ; switch ( operation ) { case RSA_ENC : bn_zero ( m ) ; bn_lsh ( m , m , 8 ) ; bn_add_dig ( m , m , RSA_PUB ) ; * p_len = k_len - 3 - m_len ; for ( int i = 0 ; i < * p_len ; i ++ ) { bn_lsh ( m , m , 8 ) ; do { rand_bytes ( & pad , 1 ) ; } while ( pad == 0 ) ; bn_add_dig ( m , m , pad ) ; } bn_lsh ( m , m , 8 ) ; bn_add_dig ( m , m , 0 ) ; bn_lsh ( m , m , m_len * 8 ) ; break ; case RSA_DEC : m_len = k_len - 1 ; bn_rsh ( t , m , 8 * m_len ) ; if ( ! bn_is_zero ( t ) ) { result = RLC_ERR ; } * p_len = m_len ; m_len -- ; bn_rsh ( t , m , 8 * m_len ) ; pad = ( uint8_t ) t -> dp [ 0 ] ; if ( pad != RSA_PUB ) { result = RLC_ERR ; } do { m_len -- ; bn_rsh ( t , m , 8 * m_len ) ; pad = ( uint8_t ) t -> dp [ 0 ] ; } while ( pad != 0 && m_len > 0 ) ; * p_len -= ( m_len - 1 ) ; bn_mod_2b ( m , m , ( k_len - * p_len ) * 8 ) ; break ; case RSA_SIG : id = hash_id ( MD_MAP , & len ) ; bn_zero ( m ) ; bn_lsh ( m , m , 8 ) ; bn_add_dig ( m , m , RSA_PRV ) ; * p_len = k_len - 3 - m_len - len ; for ( int i = 0 ; i < * p_len ; i ++ ) { bn_lsh ( m , m , 8 ) ; bn_add_dig ( m , m , RSA_PAD ) ; } bn_lsh ( m , m , 8 ) ; bn_add_dig ( m , m , 0 ) ; bn_lsh ( m , m , 8 * len ) ; bn_read_bin ( t , id , len ) ; bn_add ( m , m , t ) ; bn_lsh ( m , m , m_len * 8 ) ; break ; case RSA_SIG_HASH : bn_zero ( m ) ; bn_lsh ( m , m , 8 ) ; bn_add_dig ( m , m , RSA_PRV ) ; * p_len = k_len - 3 - m_len ; for ( int i = 0 ; i < * p_len ; i ++ ) { bn_lsh ( m , m , 8 ) ; bn_add_dig ( m , m , RSA_PAD ) ; } bn_lsh ( m , m , 8 ) ; bn_add_dig ( m , m , 0 ) ; bn_lsh ( m , m , m_len * 8 ) ; break ; case RSA_VER : m_len = k_len - 1 ; bn_rsh ( t , m , 8 * m_len ) ; if ( ! bn_is_zero ( t ) ) { result = RLC_ERR ; } m_len -- ; bn_rsh ( t , m , 8 * m_len ) ; pad = ( uint8_t ) t -> dp [ 0 ] ; if ( pad != RSA_PRV ) { result = RLC_ERR ; } do { m_len -- ; bn_rsh ( t , m , 8 * m_len ) ; pad = ( uint8_t ) t -> dp [ 0 ] ; } while ( pad != 0 && m_len > 0 ) ; if ( m_len == 0 ) { result = RLC_ERR ; } id = hash_id ( MD_MAP , & len ) ; m_len -= len ; bn_rsh ( t , m , m_len * 8 ) ; int r = 0 ; for ( int i = 0 ; i < len ; i ++ ) { pad = ( uint8_t ) t -> dp [ 0 ] ; r |= pad - id [ len - i - 1 ] ; bn_rsh ( t , t , 8 ) ; } * p_len = k_len - m_len ; bn_mod_2b ( m , m , m_len * 8 ) ; result = ( r == 0 ? RLC_OK : RLC_ERR ) ; break ; case RSA_VER_HASH : m_len = k_len - 1 ; bn_rsh ( t , m , 8 * m_len ) ; if ( ! bn_is_zero ( t ) ) { result = RLC_ERR ; } m_len -- ; bn_rsh ( t , m , 8 * m_len ) ; pad = ( uint8_t ) t -> dp [ 0 ] ; if ( pad != RSA_PRV ) { result = RLC_ERR ; } do { m_len -- ; bn_rsh ( t , m , 8 * m_len ) ; pad = ( uint8_t ) t -> dp [ 0 ] ; } while ( pad != 0 && m_len > 0 ) ; if ( m_len == 0 ) { result = RLC_ERR ; } * p_len = k_len - m_len ; bn_mod_2b ( m , m , m_len * 8 ) ; break ; } } RLC_CATCH_ANY { result = RLC_ERR ; } RLC_FINALLY { bn_free ( t ) ; } return result ; } "," , result = RLC_ERR ; bn_t t 8 ) ; result = RLC_OK ; ; if ( bn_is_zero ( t ) ) { * p_len = if ( pad == RSA_PUB ) { RSA_PUB ) { do { m_len 8 ) ; result = ( m_len > 0 ? RLC_OK RLC_ERR ) ; } } break ; case RSA_SIG : id = hash_id ( MD_MAP , & len ) ; bn_zero ( m ) ; bn_lsh ( m , m , 8 ) ; bn_add_dig ( m , m , RSA_PRV ) ; * p_len = k_len - 3 - m_len - len ; for ( int i = 0 ; i < * p_len ; i ++ ) { bn_lsh ( m , m , 8 ) ; bn_add_dig ( m , m , RSA_PAD ) ; } bn_lsh ( m , m , 8 ) ; bn_add_dig ( m , m , 0 ) ; bn_lsh ( m , m , 8 * len ) ; bn_read_bin ( t , id , len ) ; bn_add ( m , m , t ) ; bn_lsh ( m , m , m_len * 8 ) ; result = RLC_OK ; break ; case RSA_SIG_HASH : bn_zero ( m ) ; bn_lsh ( m , m , 8 ) ; bn_add_dig ( m , m , RSA_PRV ) ; * p_len = k_len - 3 - m_len ; for ( int i = 0 ; i < * p_len ; i ++ ) { bn_lsh ( m , m , 8 ) ; bn_add_dig ( m , m , RSA_PAD ) ; } bn_lsh ( m , m , 8 ) ; bn_add_dig ( m , m , 0 ) ; bn_lsh ( m , m , m_len * 8 ) ; result = RLC_OK ; break ; case RSA_VER : m_len = k_len - 1 ; bn_rsh ( t , m , 8 * m_len ) ; if ( bn_is_zero ( t ) ) { m_len -- ; bn_rsh ( t , m , 8 * m_len ) ; pad = ( uint8_t ) t -> dp [ 0 ] ; if ( pad == RSA_PRV ) { int counter = 0 ; do { counter ++ ; m_len -- ; bn_rsh ( t , m , 8 * m_len ) ; pad = ( uint8_t ) t -> dp [ 0 ] ; } while ( pad == RSA_PAD && m_len > 0 ) ; id = hash_id ( MD_MAP , & len ) ; m_len -= len ; bn_rsh ( t , m , m_len * 8 ) ; int r = 0 ; for ( int i = 0 ; i < len ; i ++ ) { pad = ( uint8_t ) t -> dp [ 0 ] ; r |= pad ^ id [ len - i - 1 ] ; bn_rsh ( t , t , 8 ) ; } * p_len = k_len - m_len ; bn_mod_2b ( m , m , m_len * 8 ) ; if ( r && m_len > 0 && counter >= 8 ) { result = RLC_OK ; } } } ; if ( bn_is_zero ( t ) ) { m_len -- ; if ( pad == RSA_PRV ) { RSA_PRV ) { int counter = 0 ; do { counter ++ ; m_len -- ; while ( pad == RSA_PAD && m_len > 0 ) ; * p_len = k_len - m_len ; bn_mod_2b ( m , m , m_len * 8 ) ; if ( m_len > 0 && counter >= 8 ) { result { result = RLC_OK ; } } } break ; } ",relic-toolkit@relic/76c9a1fdf19d9e92e566a77376673e522aae9f80,CVE-2020-36316,https://github.com/relic-toolkit/relic/commit/76c9a1fdf19d9e92e566a77376673e522aae9f80,2021-04-07T21:15Z 1306,CWE-125,"CWE-125 int yr_execute_code ( YR_RULES * rules , YR_SCAN_CONTEXT * context , int timeout , time_t start_time ) { int64_t mem [ MEM_SIZE ] ; int32_t sp = 0 ; uint8_t * ip = rules -> code_start ; YR_VALUE args [ MAX_FUNCTION_ARGS ] ; YR_VALUE * stack ; YR_VALUE r1 ; YR_VALUE r2 ; YR_VALUE r3 ; # ifdef PROFILING_ENABLED YR_RULE * current_rule = NULL ; # endif YR_RULE * rule ; YR_MATCH * match ; YR_OBJECT_FUNCTION * function ; char * identifier ; char * args_fmt ; int i ; int found ; int count ; int result = ERROR_SUCCESS ; int stop = FALSE ; int cycle = 0 ; int tidx = context -> tidx ; int stack_size ; # ifdef PROFILING_ENABLED clock_t start = clock ( ) ; # endif yr_get_configuration ( YR_CONFIG_STACK_SIZE , ( void * ) & stack_size ) ; stack = ( YR_VALUE * ) yr_malloc ( stack_size * sizeof ( YR_VALUE ) ) ; if ( stack == NULL ) return ERROR_INSUFFICIENT_MEMORY ; while ( ! stop ) { switch ( * ip ) { case OP_HALT : assert ( sp == 0 ) ; stop = TRUE ; break ; case OP_PUSH : r1 . i = * ( uint64_t * ) ( ip + 1 ) ; ip += sizeof ( uint64_t ) ; push ( r1 ) ; break ; case OP_POP : pop ( r1 ) ; break ; case OP_CLEAR_M : r1 . i = * ( uint64_t * ) ( ip + 1 ) ; ip += sizeof ( uint64_t ) ; mem [ r1 . i ] = 0 ; break ; case OP_ADD_M : r1 . i = * ( uint64_t * ) ( ip + 1 ) ; ip += sizeof ( uint64_t ) ; pop ( r2 ) ; if ( ! is_undef ( r2 ) ) mem [ r1 . i ] += r2 . i ; break ; case OP_INCR_M : r1 . i = * ( uint64_t * ) ( ip + 1 ) ; ip += sizeof ( uint64_t ) ; mem [ r1 . i ] ++ ; break ; case OP_PUSH_M : r1 . i = * ( uint64_t * ) ( ip + 1 ) ; ip += sizeof ( uint64_t ) ; r1 . i = mem [ r1 . i ] ; push ( r1 ) ; break ; case OP_POP_M : r1 . i = * ( uint64_t * ) ( ip + 1 ) ; ip += sizeof ( uint64_t ) ; pop ( r2 ) ; mem [ r1 . i ] = r2 . i ; break ; case OP_SWAPUNDEF : r1 . i = * ( uint64_t * ) ( ip + 1 ) ; ip += sizeof ( uint64_t ) ; pop ( r2 ) ; if ( is_undef ( r2 ) ) { r1 . i = mem [ r1 . i ] ; push ( r1 ) ; } else { push ( r2 ) ; } break ; case OP_JNUNDEF : pop ( r1 ) ; push ( r1 ) ; ip = jmp_if ( ! is_undef ( r1 ) , ip ) ; break ; case OP_JLE : pop ( r2 ) ; pop ( r1 ) ; push ( r1 ) ; push ( r2 ) ; ip = jmp_if ( r1 . i <= r2 . i , ip ) ; break ; case OP_JTRUE : pop ( r1 ) ; push ( r1 ) ; ip = jmp_if ( ! is_undef ( r1 ) && r1 . i , ip ) ; break ; case OP_JFALSE : pop ( r1 ) ; push ( r1 ) ; ip = jmp_if ( is_undef ( r1 ) || ! r1 . i , ip ) ; break ; case OP_AND : pop ( r2 ) ; pop ( r1 ) ; if ( is_undef ( r1 ) || is_undef ( r2 ) ) r1 . i = 0 ; else r1 . i = r1 . i && r2 . i ; push ( r1 ) ; break ; case OP_OR : pop ( r2 ) ; pop ( r1 ) ; if ( is_undef ( r1 ) ) { push ( r2 ) ; } else if ( is_undef ( r2 ) ) { push ( r1 ) ; } else { r1 . i = r1 . i || r2 . i ; push ( r1 ) ; } break ; case OP_NOT : pop ( r1 ) ; if ( is_undef ( r1 ) ) r1 . i = UNDEFINED ; else r1 . i = ! r1 . i ; push ( r1 ) ; break ; case OP_MOD : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r2 ) ; ensure_defined ( r1 ) ; if ( r2 . i != 0 ) r1 . i = r1 . i % r2 . i ; else r1 . i = UNDEFINED ; push ( r1 ) ; break ; case OP_SHR : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r2 ) ; ensure_defined ( r1 ) ; r1 . i = r1 . i >> r2 . i ; push ( r1 ) ; break ; case OP_SHL : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r2 ) ; ensure_defined ( r1 ) ; r1 . i = r1 . i << r2 . i ; push ( r1 ) ; break ; case OP_BITWISE_NOT : pop ( r1 ) ; ensure_defined ( r1 ) ; r1 . i = ~ r1 . i ; push ( r1 ) ; break ; case OP_BITWISE_AND : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r2 ) ; ensure_defined ( r1 ) ; r1 . i = r1 . i & r2 . i ; push ( r1 ) ; break ; case OP_BITWISE_OR : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r2 ) ; ensure_defined ( r1 ) ; r1 . i = r1 . i | r2 . i ; push ( r1 ) ; break ; case OP_BITWISE_XOR : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r2 ) ; ensure_defined ( r1 ) ; r1 . i = r1 . i ^ r2 . i ; push ( r1 ) ; break ; case OP_PUSH_RULE : rule = * ( YR_RULE * * ) ( ip + 1 ) ; ip += sizeof ( uint64_t ) ; r1 . i = rule -> t_flags [ tidx ] & RULE_TFLAGS_MATCH ? 1 : 0 ; push ( r1 ) ; break ; case OP_INIT_RULE : # ifdef PROFILING_ENABLED current_rule = * ( YR_RULE * * ) ( ip + 1 ) ; # endif ip += sizeof ( uint64_t ) ; break ; case OP_MATCH_RULE : pop ( r1 ) ; rule = * ( YR_RULE * * ) ( ip + 1 ) ; ip += sizeof ( uint64_t ) ; if ( ! is_undef ( r1 ) && r1 . i ) rule -> t_flags [ tidx ] |= RULE_TFLAGS_MATCH ; else if ( RULE_IS_GLOBAL ( rule ) ) rule -> ns -> t_flags [ tidx ] |= NAMESPACE_TFLAGS_UNSATISFIED_GLOBAL ; # ifdef PROFILING_ENABLED rule -> clock_ticks += clock ( ) - start ; start = clock ( ) ; # endif break ; case OP_OBJ_LOAD : identifier = * ( char * * ) ( ip + 1 ) ; ip += sizeof ( uint64_t ) ; r1 . o = ( YR_OBJECT * ) yr_hash_table_lookup ( context -> objects_table , identifier , NULL ) ; assert ( r1 . o != NULL ) ; push ( r1 ) ; break ; case OP_OBJ_FIELD : identifier = * ( char * * ) ( ip + 1 ) ; ip += sizeof ( uint64_t ) ; pop ( r1 ) ; ensure_defined ( r1 ) ; r1 . o = yr_object_lookup_field ( r1 . o , identifier ) ; assert ( r1 . o != NULL ) ; push ( r1 ) ; break ; case OP_OBJ_VALUE : pop ( r1 ) ; ensure_defined ( r1 ) ; switch ( r1 . o -> type ) { case OBJECT_TYPE_INTEGER : r1 . i = ( ( YR_OBJECT_INTEGER * ) r1 . o ) -> value ; break ; case OBJECT_TYPE_FLOAT : if ( isnan ( ( ( YR_OBJECT_DOUBLE * ) r1 . o ) -> value ) ) r1 . i = UNDEFINED ; else r1 . d = ( ( YR_OBJECT_DOUBLE * ) r1 . o ) -> value ; break ; case OBJECT_TYPE_STRING : if ( ( ( YR_OBJECT_STRING * ) r1 . o ) -> value == NULL ) r1 . i = UNDEFINED ; else r1 . p = ( ( YR_OBJECT_STRING * ) r1 . o ) -> value ; break ; default : assert ( FALSE ) ; } push ( r1 ) ; break ; case OP_INDEX_ARRAY : pop ( r1 ) ; pop ( r2 ) ; ensure_defined ( r1 ) ; ensure_defined ( r2 ) ; assert ( r2 . o -> type == OBJECT_TYPE_ARRAY ) ; r1 . o = yr_object_array_get_item ( r2 . o , 0 , ( int ) r1 . i ) ; if ( r1 . o == NULL ) r1 . i = UNDEFINED ; push ( r1 ) ; break ; case OP_LOOKUP_DICT : pop ( r1 ) ; pop ( r2 ) ; ensure_defined ( r1 ) ; ensure_defined ( r2 ) ; assert ( r2 . o -> type == OBJECT_TYPE_DICTIONARY ) ; r1 . o = yr_object_dict_get_item ( r2 . o , 0 , r1 . ss -> c_string ) ; if ( r1 . o == NULL ) r1 . i = UNDEFINED ; push ( r1 ) ; break ; case OP_CALL : args_fmt = * ( char * * ) ( ip + 1 ) ; ip += sizeof ( uint64_t ) ; i = ( int ) strlen ( args_fmt ) ; count = 0 ; while ( i > 0 ) { pop ( r1 ) ; if ( is_undef ( r1 ) ) count ++ ; args [ i - 1 ] = r1 ; i -- ; } pop ( r2 ) ; ensure_defined ( r2 ) ; if ( count > 0 ) { r1 . i = UNDEFINED ; push ( r1 ) ; break ; } function = ( YR_OBJECT_FUNCTION * ) r2 . o ; result = ERROR_INTERNAL_FATAL_ERROR ; for ( i = 0 ; i < MAX_OVERLOADED_FUNCTIONS ; i ++ ) { if ( function -> prototypes [ i ] . arguments_fmt == NULL ) break ; if ( strcmp ( function -> prototypes [ i ] . arguments_fmt , args_fmt ) == 0 ) { result = function -> prototypes [ i ] . code ( args , context , function ) ; break ; } } assert ( i < MAX_OVERLOADED_FUNCTIONS ) ; if ( result == ERROR_SUCCESS ) { r1 . o = function -> return_obj ; push ( r1 ) ; } else { stop = TRUE ; } break ; case OP_FOUND : pop ( r1 ) ; r1 . i = r1 . s -> matches [ tidx ] . tail != NULL ? 1 : 0 ; push ( r1 ) ; break ; case OP_FOUND_AT : pop ( r2 ) ; pop ( r1 ) ; if ( is_undef ( r1 ) ) { r1 . i = 0 ; push ( r1 ) ; break ; } match = r2 . s -> matches [ tidx ] . head ; r3 . i = FALSE ; while ( match != NULL ) { if ( r1 . i == match -> base + match -> offset ) { r3 . i = TRUE ; break ; } if ( r1 . i < match -> base + match -> offset ) break ; match = match -> next ; } push ( r3 ) ; break ; case OP_FOUND_IN : pop ( r3 ) ; pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r1 ) ; ensure_defined ( r2 ) ; match = r3 . s -> matches [ tidx ] . head ; r3 . i = FALSE ; while ( match != NULL && ! r3 . i ) { if ( match -> base + match -> offset >= r1 . i && match -> base + match -> offset <= r2 . i ) { r3 . i = TRUE ; } if ( match -> base + match -> offset > r2 . i ) break ; match = match -> next ; } push ( r3 ) ; break ; case OP_COUNT : pop ( r1 ) ; r1 . i = r1 . s -> matches [ tidx ] . count ; push ( r1 ) ; break ; case OP_OFFSET : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r1 ) ; match = r2 . s -> matches [ tidx ] . head ; i = 1 ; r3 . i = UNDEFINED ; while ( match != NULL && r3 . i == UNDEFINED ) { if ( r1 . i == i ) r3 . i = match -> base + match -> offset ; i ++ ; match = match -> next ; } push ( r3 ) ; break ; case OP_LENGTH : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r1 ) ; match = r2 . s -> matches [ tidx ] . head ; i = 1 ; r3 . i = UNDEFINED ; while ( match != NULL && r3 . i == UNDEFINED ) { if ( r1 . i == i ) r3 . i = match -> match_length ; i ++ ; match = match -> next ; } push ( r3 ) ; break ; case OP_OF : found = 0 ; count = 0 ; pop ( r1 ) ; while ( ! is_undef ( r1 ) ) { if ( r1 . s -> matches [ tidx ] . tail != NULL ) found ++ ; count ++ ; pop ( r1 ) ; } pop ( r2 ) ; if ( is_undef ( r2 ) ) r1 . i = found >= count ? 1 : 0 ; else r1 . i = found >= r2 . i ? 1 : 0 ; push ( r1 ) ; break ; case OP_FILESIZE : r1 . i = context -> file_size ; push ( r1 ) ; break ; case OP_ENTRYPOINT : r1 . i = context -> entry_point ; push ( r1 ) ; break ; case OP_INT8 : pop ( r1 ) ; r1 . i = read_int8_t_little_endian ( context -> iterator , ( size_t ) r1 . i ) ; push ( r1 ) ; break ; case OP_INT16 : pop ( r1 ) ; r1 . i = read_int16_t_little_endian ( context -> iterator , ( size_t ) r1 . i ) ; push ( r1 ) ; break ; case OP_INT32 : pop ( r1 ) ; r1 . i = read_int32_t_little_endian ( context -> iterator , ( size_t ) r1 . i ) ; push ( r1 ) ; break ; case OP_UINT8 : pop ( r1 ) ; r1 . i = read_uint8_t_little_endian ( context -> iterator , ( size_t ) r1 . i ) ; push ( r1 ) ; break ; case OP_UINT16 : pop ( r1 ) ; r1 . i = read_uint16_t_little_endian ( context -> iterator , ( size_t ) r1 . i ) ; push ( r1 ) ; break ; case OP_UINT32 : pop ( r1 ) ; r1 . i = read_uint32_t_little_endian ( context -> iterator , ( size_t ) r1 . i ) ; push ( r1 ) ; break ; case OP_INT8BE : pop ( r1 ) ; r1 . i = read_int8_t_big_endian ( context -> iterator , ( size_t ) r1 . i ) ; push ( r1 ) ; break ; case OP_INT16BE : pop ( r1 ) ; r1 . i = read_int16_t_big_endian ( context -> iterator , ( size_t ) r1 . i ) ; push ( r1 ) ; break ; case OP_INT32BE : pop ( r1 ) ; r1 . i = read_int32_t_big_endian ( context -> iterator , ( size_t ) r1 . i ) ; push ( r1 ) ; break ; case OP_UINT8BE : pop ( r1 ) ; r1 . i = read_uint8_t_big_endian ( context -> iterator , ( size_t ) r1 . i ) ; push ( r1 ) ; break ; case OP_UINT16BE : pop ( r1 ) ; r1 . i = read_uint16_t_big_endian ( context -> iterator , ( size_t ) r1 . i ) ; push ( r1 ) ; break ; case OP_UINT32BE : pop ( r1 ) ; r1 . i = read_uint32_t_big_endian ( context -> iterator , ( size_t ) r1 . i ) ; push ( r1 ) ; break ; case OP_CONTAINS : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r1 ) ; ensure_defined ( r2 ) ; r1 . i = memmem ( r1 . ss -> c_string , r1 . ss -> length , r2 . ss -> c_string , r2 . ss -> length ) != NULL ; push ( r1 ) ; break ; case OP_IMPORT : r1 . i = * ( uint64_t * ) ( ip + 1 ) ; ip += sizeof ( uint64_t ) ; result = yr_modules_load ( ( char * ) r1 . p , context ) ; if ( result != ERROR_SUCCESS ) stop = TRUE ; break ; case OP_MATCHES : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r2 ) ; ensure_defined ( r1 ) ; if ( r1 . ss -> length == 0 ) { r1 . i = FALSE ; push ( r1 ) ; break ; } r1 . i = yr_re_exec ( ( uint8_t * ) r2 . re -> code , ( uint8_t * ) r1 . ss -> c_string , r1 . ss -> length , r2 . re -> flags | RE_FLAGS_SCAN , NULL , NULL ) >= 0 ; push ( r1 ) ; break ; case OP_INT_TO_DBL : r1 . i = * ( uint64_t * ) ( ip + 1 ) ; ip += sizeof ( uint64_t ) ; r2 = stack [ sp - r1 . i ] ; if ( is_undef ( r2 ) ) stack [ sp - r1 . i ] . i = UNDEFINED ; else stack [ sp - r1 . i ] . d = ( double ) r2 . i ; break ; case OP_STR_TO_BOOL : pop ( r1 ) ; ensure_defined ( r1 ) ; r1 . i = r1 . ss -> length > 0 ; push ( r1 ) ; break ; case OP_INT_EQ : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r2 ) ; ensure_defined ( r1 ) ; r1 . i = r1 . i == r2 . i ; push ( r1 ) ; break ; case OP_INT_NEQ : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r2 ) ; ensure_defined ( r1 ) ; r1 . i = r1 . i != r2 . i ; push ( r1 ) ; break ; case OP_INT_LT : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r2 ) ; ensure_defined ( r1 ) ; r1 . i = r1 . i < r2 . i ; push ( r1 ) ; break ; case OP_INT_GT : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r2 ) ; ensure_defined ( r1 ) ; r1 . i = r1 . i > r2 . i ; push ( r1 ) ; break ; case OP_INT_LE : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r2 ) ; ensure_defined ( r1 ) ; r1 . i = r1 . i <= r2 . i ; push ( r1 ) ; break ; case OP_INT_GE : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r2 ) ; ensure_defined ( r1 ) ; r1 . i = r1 . i >= r2 . i ; push ( r1 ) ; break ; case OP_INT_ADD : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r2 ) ; ensure_defined ( r1 ) ; r1 . i = r1 . i + r2 . i ; push ( r1 ) ; break ; case OP_INT_SUB : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r2 ) ; ensure_defined ( r1 ) ; r1 . i = r1 . i - r2 . i ; push ( r1 ) ; break ; case OP_INT_MUL : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r2 ) ; ensure_defined ( r1 ) ; r1 . i = r1 . i * r2 . i ; push ( r1 ) ; break ; case OP_INT_DIV : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r2 ) ; ensure_defined ( r1 ) ; if ( r2 . i != 0 ) r1 . i = r1 . i / r2 . i ; else r1 . i = UNDEFINED ; push ( r1 ) ; break ; case OP_INT_MINUS : pop ( r1 ) ; ensure_defined ( r1 ) ; r1 . i = - r1 . i ; push ( r1 ) ; break ; case OP_DBL_LT : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r2 ) ; ensure_defined ( r1 ) ; r1 . i = r1 . d < r2 . d ; push ( r1 ) ; break ; case OP_DBL_GT : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r2 ) ; ensure_defined ( r1 ) ; r1 . i = r1 . d > r2 . d ; push ( r1 ) ; break ; case OP_DBL_LE : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r2 ) ; ensure_defined ( r1 ) ; r1 . i = r1 . d <= r2 . d ; push ( r1 ) ; break ; case OP_DBL_GE : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r2 ) ; ensure_defined ( r1 ) ; r1 . i = r1 . d >= r2 . d ; push ( r1 ) ; break ; case OP_DBL_EQ : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r2 ) ; ensure_defined ( r1 ) ; r1 . i = r1 . d == r2 . d ; push ( r1 ) ; break ; case OP_DBL_NEQ : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r2 ) ; ensure_defined ( r1 ) ; r1 . i = r1 . d != r2 . d ; push ( r1 ) ; break ; case OP_DBL_ADD : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r2 ) ; ensure_defined ( r1 ) ; r1 . d = r1 . d + r2 . d ; push ( r1 ) ; break ; case OP_DBL_SUB : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r2 ) ; ensure_defined ( r1 ) ; r1 . d = r1 . d - r2 . d ; push ( r1 ) ; break ; case OP_DBL_MUL : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r2 ) ; ensure_defined ( r1 ) ; r1 . d = r1 . d * r2 . d ; push ( r1 ) ; break ; case OP_DBL_DIV : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r2 ) ; ensure_defined ( r1 ) ; r1 . d = r1 . d / r2 . d ; push ( r1 ) ; break ; case OP_DBL_MINUS : pop ( r1 ) ; ensure_defined ( r1 ) ; r1 . d = - r1 . d ; push ( r1 ) ; break ; case OP_STR_EQ : case OP_STR_NEQ : case OP_STR_LT : case OP_STR_LE : case OP_STR_GT : case OP_STR_GE : pop ( r2 ) ; pop ( r1 ) ; ensure_defined ( r1 ) ; ensure_defined ( r2 ) ; switch ( * ip ) { case OP_STR_EQ : r1 . i = ( sized_string_cmp ( r1 . ss , r2 . ss ) == 0 ) ; break ; case OP_STR_NEQ : r1 . i = ( sized_string_cmp ( r1 . ss , r2 . ss ) != 0 ) ; break ; case OP_STR_LT : r1 . i = ( sized_string_cmp ( r1 . ss , r2 . ss ) < 0 ) ; break ; case OP_STR_LE : r1 . i = ( sized_string_cmp ( r1 . ss , r2 . ss ) <= 0 ) ; break ; case OP_STR_GT : r1 . i = ( sized_string_cmp ( r1 . ss , r2 . ss ) > 0 ) ; break ; case OP_STR_GE : r1 . i = ( sized_string_cmp ( r1 . ss , r2 . ss ) >= 0 ) ; break ; } push ( r1 ) ; break ; default : assert ( FALSE ) ; } if ( timeout > 0 ) { if ( ++ cycle == 10 ) { if ( difftime ( time ( NULL ) , start_time ) > timeout ) { # ifdef PROFILING_ENABLED assert ( current_rule != NULL ) ; current_rule -> clock_ticks += clock ( ) - start ; # endif result = ERROR_SCAN_TIMEOUT ; stop = TRUE ; } cycle = 0 ; } } ip ++ ; } yr_modules_unload_all ( context ) ; yr_free ( stack ) ; return result ; } "," -> length , 0 , ",VirusTotal@yara/83d799804648c2a0895d40a19835d9b757c6fa4e,CVE-2017-8294,https://github.com/VirusTotal/yara/commit/83d799804648c2a0895d40a19835d9b757c6fa4e,2017-04-27T14:59Z 1307,CWE-119,"CWE-119 static vpx_codec_err_t vp8_get_reference ( vpx_codec_alg_priv_t * ctx , int ctr_id , va_list args ) { vpx_ref_frame_t * data = va_arg ( args , vpx_ref_frame_t * ) ; if ( data && ! ctx -> yv12_frame_buffers . use_frame_threads ) { vpx_ref_frame_t * frame = ( vpx_ref_frame_t * ) data ; YV12_BUFFER_CONFIG sd ; image2yuvconfig ( & frame -> img , & sd ) ; return vp8dx_get_reference ( ctx -> yv12_frame_buffers . pbi [ 0 ] , frame -> frame_type , & sd ) ; } else return VPX_CODEC_INVALID_PARAM ; } "," vpx_codec_alg_priv_t * ctx , va_list args ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1308,CWE-362,"CWE-362 static void bt_for_each ( struct blk_mq_hw_ctx * hctx , struct blk_mq_bitmap_tags * bt , unsigned int off , busy_iter_fn * fn , void * data , bool reserved ) { struct request * rq ; int bit , i ; for ( i = 0 ; i < bt -> map_nr ; i ++ ) { struct blk_align_bitmap * bm = & bt -> map [ i ] ; for ( bit = find_first_bit ( & bm -> word , bm -> depth ) ; bit < bm -> depth ; bit = find_next_bit ( & bm -> word , bm -> depth , bit + 1 ) ) { rq = blk_mq_tag_to_rq ( hctx -> tags , off + bit ) ; if ( rq -> q == hctx -> queue ) fn ( hctx , rq , data , reserved ) ; } off += ( 1 << bt -> bits_per_word ) ; } } "," { rq = hctx -> tags hctx -> tags -> rqs [ off + bit off + bit ] ; if ( ",torvalds@linux/0048b4837affd153897ed1222283492070027aa9,CVE-2015-9016,https://github.com/torvalds/linux/commit/0048b4837affd153897ed1222283492070027aa9,2018-04-05T18:29Z 1309,CWE-119,"CWE-119 SNDFILE * sf_open ( const char * path , int mode , SF_INFO * sfinfo ) { SF_PRIVATE * psf ; assert ( sizeof ( sf_count_t ) == 8 ) ; if ( ( psf = calloc ( 1 , sizeof ( SF_PRIVATE ) ) ) == NULL ) { sf_errno = SFE_MALLOC_FAILED ; return NULL ; } ; psf_init_files ( psf ) ; psf_log_printf ( psf , ""File:%s\\n"" , path ) ; if ( copy_filename ( psf , path ) != 0 ) { sf_errno = psf -> error ; return NULL ; } ; psf -> file . mode = mode ; if ( strcmp ( path , ""-"" ) == 0 ) psf -> error = psf_set_stdio ( psf ) ; else psf -> error = psf_fopen ( psf ) ; return psf_open_file ( psf , sfinfo ) ; } "," ( psf = psf_allocate ( ) ) == ",erikd@libsndfile/708e996c87c5fae77b104ccfeb8f6db784c32074,CVE-2017-7586,https://github.com/erikd/libsndfile/commit/708e996c87c5fae77b104ccfeb8f6db784c32074,2017-04-07T20:59Z 1310,CWE-119,"CWE-119 static void fix_interp_filter ( VP9_COMMON * cm ) { if ( cm -> interp_filter == SWITCHABLE ) { int count [ SWITCHABLE_FILTERS ] ; int i , j , c = 0 ; for ( i = 0 ; i < SWITCHABLE_FILTERS ; ++ i ) { count [ i ] = 0 ; for ( j = 0 ; j < SWITCHABLE_FILTER_CONTEXTS ; ++ j ) count [ i ] += cm -> counts . switchable_interp [ j ] [ i ] ; c += ( count [ i ] > 0 ) ; } if ( c == 1 ) { for ( i = 0 ; i < SWITCHABLE_FILTERS ; ++ i ) { if ( count [ i ] ) { cm -> interp_filter = i ; break ; } } } } } "," VP9_COMMON * cm , FRAME_COUNTS * counts i ] += counts -> switchable_interp [ j ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1311,CWE-787,"CWE-787 static bool parseOperands ( char * str , ArmOp * op ) { char * t = strdup ( str ) ; int operand = 0 ; char * token = t ; char * x ; int imm_count = 0 ; int mem_opt = 0 ; if ( ! token ) { return false ; } while ( token ) { char * next = strchr ( token , ',' ) ; if ( next ) { * next ++ = 0 ; } while ( token [ 0 ] == '' ) { token ++ ; } op -> operands [ operand ] . type = ARM_NOTYPE ; op -> operands [ operand ] . reg_type = ARM_UNDEFINED ; op -> operands [ operand ] . shift = ARM_NO_SHIFT ; while ( token [ 0 ] == '' || token [ 0 ] == '[' || token [ 0 ] == ']' ) { token ++ ; } if ( ! strncmp ( token , ""lsl"" , 3 ) ) { op -> operands [ operand ] . shift = ARM_LSL ; } else if ( ! strncmp ( token , ""lsr"" , 3 ) ) { op -> operands [ operand ] . shift = ARM_LSR ; } else if ( ! strncmp ( token , ""asr"" , 3 ) ) { op -> operands [ operand ] . shift = ARM_ASR ; } if ( op -> operands [ operand ] . shift != ARM_NO_SHIFT ) { op -> operands_count ++ ; op -> operands [ operand ] . shift_amount = r_num_math ( NULL , token + 4 ) ; if ( op -> operands [ operand ] . shift_amount > 63 ) { return false ; } operand ++ ; token = next ; continue ; } switch ( token [ 0 ] ) { case 'x' : x = strchr ( token , ',' ) ; if ( x ) { x [ 0 ] = '\\0' ; } op -> operands_count ++ ; op -> operands [ operand ] . type = ARM_GPR ; op -> operands [ operand ] . reg_type = ARM_REG64 ; op -> operands [ operand ] . reg = r_num_math ( NULL , token + 1 ) ; if ( op -> operands [ operand ] . reg > 31 ) { return false ; } break ; case 'w' : op -> operands_count ++ ; op -> operands [ operand ] . type = ARM_GPR ; op -> operands [ operand ] . reg_type = ARM_REG32 ; op -> operands [ operand ] . reg = r_num_math ( NULL , token + 1 ) ; if ( op -> operands [ operand ] . reg > 31 ) { return false ; } break ; case 'v' : op -> operands_count ++ ; op -> operands [ operand ] . type = ARM_FP ; op -> operands [ operand ] . reg = r_num_math ( NULL , token + 1 ) ; break ; case 's' : case 'S' : if ( token [ 1 ] == 'P' || token [ 1 ] == 'p' ) { int i ; for ( i = 0 ; msr_const [ i ] . name ; i ++ ) { if ( ! r_str_ncasecmp ( token , msr_const [ i ] . name , strlen ( msr_const [ i ] . name ) ) ) { op -> operands [ operand ] . sp_val = msr_const [ i ] . val ; break ; } } op -> operands_count ++ ; op -> operands [ operand ] . type = ARM_GPR ; op -> operands [ operand ] . reg_type = ARM_SP | ARM_REG64 ; op -> operands [ operand ] . reg = 31 ; break ; } mem_opt = get_mem_option ( token ) ; if ( mem_opt != - 1 ) { op -> operands_count ++ ; op -> operands [ operand ] . type = ARM_MEM_OPT ; op -> operands [ operand ] . mem_option = mem_opt ; } break ; case 'L' : case 'l' : case 'I' : case 'i' : case 'N' : case 'n' : case 'O' : case 'o' : case 'p' : case 'P' : mem_opt = get_mem_option ( token ) ; if ( mem_opt != - 1 ) { op -> operands_count ++ ; op -> operands [ operand ] . type = ARM_MEM_OPT ; op -> operands [ operand ] . mem_option = mem_opt ; } break ; case '-' : op -> operands [ operand ] . sign = - 1 ; default : op -> operands_count ++ ; op -> operands [ operand ] . type = ARM_CONSTANT ; op -> operands [ operand ] . immediate = r_num_math ( NULL , token ) ; imm_count ++ ; break ; } token = next ; operand ++ ; if ( operand > MAX_OPERANDS ) { free ( t ) ; return false ; } } free ( t ) ; return true ; } "," { token ++ ; } if ( operand >= MAX_OPERANDS ) { eprintf ( ""Toomanyoperands\\n"" ) ; return false ",radare@radare2/df167c7db545953bb7f71c72e98e7a3ca0c793bf,CVE-2018-20460,https://github.com/radare/radare2/commit/df167c7db545953bb7f71c72e98e7a3ca0c793bf,2018-12-25T19:29Z 1312,CWE-119,"CWE-119 static void init_encode_frame_mb_context ( VP9_COMP * cpi ) { MACROBLOCK * const x = & cpi -> mb ; VP9_COMMON * const cm = & cpi -> common ; MACROBLOCKD * const xd = & x -> e_mbd ; const int aligned_mi_cols = mi_cols_aligned_to_sb ( cm -> mi_cols ) ; x -> act_zbin_adj = 0 ; vp9_setup_src_planes ( x , cpi -> Source , 0 , 0 ) ; vp9_setup_pre_planes ( xd , 0 , get_ref_frame_buffer ( cpi , LAST_FRAME ) , 0 , 0 , NULL ) ; vp9_setup_dst_planes ( xd , get_frame_new_buffer ( cm ) , 0 , 0 ) ; vp9_setup_block_planes ( & x -> e_mbd , cm -> subsampling_x , cm -> subsampling_y ) ; xd -> mi [ 0 ] -> mbmi . mode = DC_PRED ; xd -> mi [ 0 ] -> mbmi . uv_mode = DC_PRED ; vpx_memset ( xd -> above_context [ 0 ] , 0 , sizeof ( * xd -> above_context [ 0 ] ) * 2 * aligned_mi_cols * MAX_MB_PLANE ) ; vpx_memset ( xd -> above_seg_context , 0 , sizeof ( * xd -> above_seg_context ) * aligned_mi_cols ) ; } "," & cpi -> td . mi_cols ) ; vp9_setup_src_planes ( x cpi -> Source , 0 , subsampling_y ) ; memset ( xd -> MAX_MB_PLANE ) ; memset ( xd -> ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1313,CWE-787,"CWE-787 void pdf_summarize ( FILE * fp , const pdf_t * pdf , const char * name , pdf_flag_t flags ) { int i , j , page , n_versions , n_entries ; FILE * dst , * out ; char * dst_name , * c ; dst = NULL ; dst_name = NULL ; if ( name ) { dst_name = malloc ( strlen ( name ) * 2 + 16 ) ; sprintf ( dst_name , ""%s/%s"" , name , name ) ; if ( ( c = strrchr ( dst_name , '.' ) ) && ( strncmp ( c , "".pdf"" , 4 ) == 0 ) ) * c = '\\0' ; strcat ( dst_name , "".summary"" ) ; if ( ! ( dst = fopen ( dst_name , ""w"" ) ) ) { ERR ( ""Couldnotopenfile\'%s\'forwriting\\n"" , dst_name ) ; return ; } } out = ( dst ) ? dst : stdout ; n_versions = pdf -> n_xrefs ; if ( n_versions && pdf -> xrefs [ 0 ] . is_linear ) -- n_versions ; for ( i = 1 ; i < pdf -> n_xrefs ; ++ i ) if ( pdf -> xrefs [ i ] . end == 0 ) -- n_versions ; if ( ! pdf -> n_xrefs || ( ! n_versions && pdf -> xrefs [ 0 ] . is_linear ) ) n_versions = 1 ; n_entries = 0 ; for ( i = 0 ; ! ( const int ) pdf -> has_xref_streams && i < pdf -> n_xrefs ; i ++ ) { if ( flags & PDF_FLAG_QUIET ) continue ; for ( j = 0 ; j < pdf -> xrefs [ i ] . n_entries ; j ++ ) { ++ n_entries ; fprintf ( out , ""%s:--%c--Version%d--Object%d(%s)"" , pdf -> name , pdf_get_object_status ( pdf , i , j ) , pdf -> xrefs [ i ] . version , pdf -> xrefs [ i ] . entries [ j ] . obj_id , get_type ( fp , pdf -> xrefs [ i ] . entries [ j ] . obj_id , & pdf -> xrefs [ i ] ) ) ; if ( 0 ) fprintf ( out , ""Page(%d)\\n"" , page ) ; else fprintf ( out , ""\\n"" ) ; } } if ( ! ( flags & PDF_FLAG_QUIET ) ) { if ( pdf -> has_xref_streams || ! n_entries ) fprintf ( out , ""%s:ThisPDFcontainspotentialcrossreferencestreams.\\n"" ""%s:Anobjectsummaryisnotavailable.\\n"" , pdf -> name , pdf -> name ) ; fprintf ( out , ""----------%s----------\\n"" ""Versions:%d\\n"" , pdf -> name , n_versions ) ; if ( ! pdf -> has_xref_streams ) for ( i = 0 ; i < pdf -> n_xrefs ; i ++ ) { if ( pdf -> xrefs [ i ] . is_linear ) continue ; n_entries = pdf -> xrefs [ i ] . n_entries ; if ( pdf -> xrefs [ 0 ] . is_linear ) n_entries += pdf -> xrefs [ 0 ] . n_entries ; if ( pdf -> xrefs [ i ] . version && n_entries ) fprintf ( out , ""Version%d--%dobjects\\n"" , pdf -> xrefs [ i ] . version , n_entries ) ; } } else fprintf ( out , ""%s:%d\\n"" , pdf -> name , n_versions ) ; if ( dst ) { fclose ( dst ) ; free ( dst_name ) ; } } "," { dst_name = safe_calloc ( strlen ( ",enferex@pdfresurrect/0c4120fffa3dffe97b95c486a120eded82afe8a6,CVE-2019-14934,https://github.com/enferex/pdfresurrect/commit/0c4120fffa3dffe97b95c486a120eded82afe8a6,2019-08-11T22:15Z 1314,CWE-000,"CWE-000 uint16_t http_DissectRequest ( struct sess * sp ) { struct http_conn * htc ; struct http * hp ; uint16_t retval ; CHECK_OBJ_NOTNULL ( sp , SESS_MAGIC ) ; htc = sp -> htc ; CHECK_OBJ_NOTNULL ( htc , HTTP_CONN_MAGIC ) ; hp = sp -> http ; CHECK_OBJ_NOTNULL ( hp , HTTP_MAGIC ) ; hp -> logtag = HTTP_Rx ; retval = http_splitline ( sp -> wrk , sp -> fd , hp , htc , HTTP_HDR_REQ , HTTP_HDR_URL , HTTP_HDR_PROTO ) ; if ( retval != 0 ) { WSPR ( sp , SLT_HttpGarbage , htc -> rxbuf ) ; return ( retval ) ; } http_ProtoVer ( hp ) ; retval = htc_request_check_host_hdr ( hp ) ; if ( retval != 0 ) { WSP ( sp , SLT_Error , ""DuplicatedHostheader"" ) ; return ( retval ) ; } return ( retval ) ; } "," ; retval = htc_request_check_hdrs ( sp , ( sp , hp ) ; return ) ; } ",varnish@Varnish-Cache/29870c8fe95e4e8a672f6f28c5fbe692bea09e9c,CVE-2015-8852,https://github.com/varnish/Varnish-Cache/commit/29870c8fe95e4e8a672f6f28c5fbe692bea09e9c,2016-04-25T14:59Z 1315,CWE-20,"CWE-20 static Image * ReadRLEImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define SkipLinesOp 0x01 # define SetColorOp 0x02 # define SkipPixelsOp 0x03 # define ByteDataOp 0x05 # define RunDataOp 0x06 # define EOFOp 0x07 char magick [ 12 ] ; Image * image ; IndexPacket index ; int opcode , operand , status ; MagickStatusType flags ; MagickSizeType number_pixels ; MemoryInfo * pixel_info ; register IndexPacket * indexes ; register ssize_t x ; register PixelPacket * q ; register ssize_t i ; register unsigned char * p ; size_t bits_per_pixel , map_length , number_colormaps , number_planes , number_planes_filled , one , pixel_info_length ; ssize_t count , offset , y ; unsigned char background_color [ 256 ] , * colormap , pixel , plane , * pixels ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; count = ReadBlob ( image , 2 , ( unsigned char * ) magick ) ; if ( ( count != 2 ) || ( memcmp ( magick , ""\\122\\314"" , 2 ) != 0 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; do { image -> page . x = ReadBlobLSBShort ( image ) ; image -> page . y = ReadBlobLSBShort ( image ) ; image -> columns = ReadBlobLSBShort ( image ) ; image -> rows = ReadBlobLSBShort ( image ) ; flags = ( MagickStatusType ) ReadBlobByte ( image ) ; image -> matte = flags & 0x04 ? MagickTrue : MagickFalse ; number_planes = ( size_t ) ReadBlobByte ( image ) ; bits_per_pixel = ( size_t ) ReadBlobByte ( image ) ; number_colormaps = ( size_t ) ReadBlobByte ( image ) ; map_length = ( unsigned char ) ReadBlobByte ( image ) ; if ( map_length >= 22 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; one = 1 ; map_length = one << map_length ; if ( ( number_planes == 0 ) || ( number_planes == 2 ) || ( ( flags & 0x04 ) && ( number_colormaps > 254 ) ) || ( bits_per_pixel != 8 ) || ( image -> columns == 0 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( flags & 0x02 ) { for ( i = 0 ; i < ( ssize_t ) number_planes ; i ++ ) background_color [ i ] = 0 ; ( void ) ReadBlobByte ( image ) ; } else { p = background_color ; for ( i = 0 ; i < ( ssize_t ) number_planes ; i ++ ) * p ++ = ( unsigned char ) ReadBlobByte ( image ) ; } if ( ( number_planes & 0x01 ) == 0 ) ( void ) ReadBlobByte ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } colormap = ( unsigned char * ) NULL ; if ( number_colormaps != 0 ) { colormap = ( unsigned char * ) AcquireQuantumMemory ( number_colormaps , 3 * map_length * sizeof ( * colormap ) ) ; if ( colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; p = colormap ; for ( i = 0 ; i < ( ssize_t ) number_colormaps ; i ++ ) for ( x = 0 ; x < ( ssize_t ) map_length ; x ++ ) * p ++ = ( unsigned char ) ScaleQuantumToChar ( ScaleShortToQuantum ( ReadBlobLSBShort ( image ) ) ) ; } if ( ( flags & 0x08 ) != 0 ) { char * comment ; size_t length ; length = ReadBlobLSBShort ( image ) ; if ( length != 0 ) { comment = ( char * ) AcquireQuantumMemory ( length , sizeof ( * comment ) ) ; if ( comment == ( char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; ( void ) ReadBlob ( image , length - 1 , ( unsigned char * ) comment ) ; comment [ length - 1 ] = '\\0' ; ( void ) SetImageProperty ( image , ""comment"" , comment ) ; comment = DestroyString ( comment ) ; if ( ( length & 0x01 ) == 0 ) ( void ) ReadBlobByte ( image ) ; } } if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; } if ( image -> matte != MagickFalse ) number_planes ++ ; number_pixels = ( MagickSizeType ) image -> columns * image -> rows ; number_planes_filled = ( number_planes % 2 == 0 ) ? number_planes : number_planes + 1 ; if ( ( number_pixels * number_planes_filled ) != ( size_t ) ( number_pixels * number_planes_filled ) ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; pixel_info = AcquireVirtualMemory ( image -> columns , image -> rows * MagickMax ( number_planes_filled , 4 ) * sizeof ( * pixels ) ) ; if ( pixel_info == ( MemoryInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; pixel_info_length = image -> columns * image -> rows * MagickMax ( number_planes_filled , 4 ) ; pixels = ( unsigned char * ) GetVirtualMemoryBlob ( pixel_info ) ; ( void ) ResetMagickMemory ( pixels , 0 , pixel_info_length ) ; if ( ( flags & 0x01 ) && ! ( flags & 0x02 ) ) { ssize_t j ; p = pixels ; for ( i = 0 ; i < ( ssize_t ) number_pixels ; i ++ ) { if ( image -> matte == MagickFalse ) for ( j = 0 ; j < ( ssize_t ) number_planes ; j ++ ) * p ++ = background_color [ j ] ; else { for ( j = 0 ; j < ( ssize_t ) ( number_planes - 1 ) ; j ++ ) * p ++ = background_color [ j ] ; * p ++ = 0 ; } } } plane = 0 ; x = 0 ; y = 0 ; opcode = ReadBlobByte ( image ) ; do { switch ( opcode & 0x3f ) { case SkipLinesOp : { operand = ReadBlobByte ( image ) ; if ( opcode & 0x40 ) operand = ReadBlobLSBSignedShort ( image ) ; x = 0 ; y += operand ; break ; } case SetColorOp : { operand = ReadBlobByte ( image ) ; plane = ( unsigned char ) operand ; if ( plane == 255 ) plane = ( unsigned char ) ( number_planes - 1 ) ; x = 0 ; break ; } case SkipPixelsOp : { operand = ReadBlobByte ( image ) ; if ( opcode & 0x40 ) operand = ReadBlobLSBSignedShort ( image ) ; x += operand ; break ; } case ByteDataOp : { operand = ReadBlobByte ( image ) ; if ( opcode & 0x40 ) operand = ReadBlobLSBSignedShort ( image ) ; offset = ( ( image -> rows - y - 1 ) * image -> columns * number_planes ) + x * number_planes + plane ; operand ++ ; if ( ( offset < 0 ) || ( offset + ( ( size_t ) operand * number_planes ) > pixel_info_length ) ) { if ( number_colormaps != 0 ) colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; } p = pixels + offset ; for ( i = 0 ; i < ( ssize_t ) operand ; i ++ ) { pixel = ( unsigned char ) ReadBlobByte ( image ) ; if ( ( y < ( ssize_t ) image -> rows ) && ( ( x + i ) < ( ssize_t ) image -> columns ) ) * p = pixel ; p += number_planes ; } if ( operand & 0x01 ) ( void ) ReadBlobByte ( image ) ; x += operand ; break ; } case RunDataOp : { operand = ReadBlobByte ( image ) ; if ( opcode & 0x40 ) operand = ReadBlobLSBSignedShort ( image ) ; pixel = ( unsigned char ) ReadBlobByte ( image ) ; ( void ) ReadBlobByte ( image ) ; operand ++ ; offset = ( ( image -> rows - y - 1 ) * image -> columns * number_planes ) + x * number_planes + plane ; if ( ( offset < 0 ) || ( offset + ( ( size_t ) operand * number_planes ) > pixel_info_length ) ) { if ( number_colormaps != 0 ) colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; } p = pixels + offset ; for ( i = 0 ; i < ( ssize_t ) operand ; i ++ ) { if ( ( y < ( ssize_t ) image -> rows ) && ( ( x + i ) < ( ssize_t ) image -> columns ) ) * p = pixel ; p += number_planes ; } x += operand ; break ; } default : break ; } opcode = ReadBlobByte ( image ) ; } while ( ( ( opcode & 0x3f ) != EOFOp ) && ( opcode != EOF ) ) ; if ( number_colormaps != 0 ) { MagickStatusType mask ; mask = ( MagickStatusType ) ( map_length - 1 ) ; p = pixels ; x = ( ssize_t ) number_planes ; if ( number_colormaps == 1 ) for ( i = 0 ; i < ( ssize_t ) number_pixels ; i ++ ) { if ( IsValidColormapIndex ( image , * p & mask , & index , exception ) == MagickFalse ) break ; * p = colormap [ ( ssize_t ) index ] ; p ++ ; } else if ( ( number_planes >= 3 ) && ( number_colormaps >= 3 ) ) for ( i = 0 ; i < ( ssize_t ) number_pixels ; i ++ ) for ( x = 0 ; x < ( ssize_t ) number_planes ; x ++ ) { if ( IsValidColormapIndex ( image , ( size_t ) ( x * map_length + ( * p & mask ) ) , & index , exception ) == MagickFalse ) break ; * p = colormap [ ( ssize_t ) index ] ; p ++ ; } if ( ( i < ( ssize_t ) number_pixels ) || ( x < ( ssize_t ) number_planes ) ) { colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; } } if ( number_planes >= 3 ) { p = pixels ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( q , ScaleCharToQuantum ( * p ++ ) ) ; SetPixelGreen ( q , ScaleCharToQuantum ( * p ++ ) ) ; SetPixelBlue ( q , ScaleCharToQuantum ( * p ++ ) ) ; if ( image -> matte != MagickFalse ) SetPixelAlpha ( q , ScaleCharToQuantum ( * p ++ ) ) ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } else { if ( number_colormaps == 0 ) map_length = 256 ; if ( AcquireImageColormap ( image , map_length ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; p = colormap ; if ( number_colormaps == 1 ) for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( ( unsigned char ) i ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( ( unsigned char ) i ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( ( unsigned char ) i ) ; } else if ( number_colormaps > 1 ) for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( * p ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( * ( p + map_length ) ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( * ( p + map_length * 2 ) ) ; p ++ ; } p = pixels ; if ( image -> matte == MagickFalse ) { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; indexes = GetAuthenticIndexQueue ( image ) ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) SetPixelIndex ( indexes + x , * p ++ ) ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } ( void ) SyncImage ( image ) ; } else { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { if ( IsValidColormapIndex ( image , * p ++ , & index , exception ) == MagickFalse ) break ; SetPixelRed ( q , image -> colormap [ ( ssize_t ) index ] . red ) ; if ( IsValidColormapIndex ( image , * p ++ , & index , exception ) == MagickFalse ) break ; SetPixelGreen ( q , image -> colormap [ ( ssize_t ) index ] . green ) ; if ( IsValidColormapIndex ( image , * p ++ , & index , exception ) == MagickFalse ) break ; SetPixelBlue ( q , image -> colormap [ ( ssize_t ) index ] . blue ) ; SetPixelAlpha ( q , ScaleCharToQuantum ( * p ++ ) ) ; q ++ ; } if ( x < ( ssize_t ) image -> columns ) break ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } image -> colormap = ( PixelPacket * ) RelinquishMagickMemory ( image -> colormap ) ; image -> storage_class = DirectClass ; image -> colors = 0 ; } } if ( number_colormaps != 0 ) colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; pixel_info = RelinquishVirtualMemory ( pixel_info ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; ( void ) ReadBlobByte ( image ) ; count = ReadBlob ( image , 2 , ( unsigned char * ) magick ) ; if ( ( count != 0 ) && ( memcmp ( magick , ""\\122\\314"" , 2 ) == 0 ) ) { AcquireNextImage ( image_info , image ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( ( count != 0 ) && ( memcmp ( magick , ""\\122\\314"" , 2 ) == 0 ) ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," define EOFOp 0x07 # define ThrowRLEException ( exception , message ) \\\n{ if ( colormap != ( unsigned char * ) NULL ) colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; if ( pixel_info != ( MemoryInfo * ) NULL ) pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( ( exception ) , ( message ) ) ; \\\n} ) ) ; colormap = ( unsigned char * ) NULL ; pixel_info = ( MemoryInfo * ) NULL ; . x = ( ssize_t ) . y = ( ssize_t ) ""ImproperImageHeader"" ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; != MagickFalse ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" CorruptImageError , ""UnexpectedEndOfFile"" ) ; colormap = ( x ++ ) { ) ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; } != MagickFalse ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" CorruptImageError , ""UnexpectedEndOfFile"" ) ; if ( ( image ) ; if ( opcode == EOF ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; if ( opcode == EOF ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; if ( opcode & 0x40 ) { image ) ; if ( opcode == EOF ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; } image ) ; if ( opcode == EOF ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; if ( opcode == EOF ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; if ( opcode & 0x40 ) { image ) ; if ( opcode == EOF ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; } if ( opcode == EOF ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; if ( opcode & 0x40 ) { image ) ; if ( opcode == EOF ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; } offset = ( ssize_t ) ( ( ( image number_planes + plane ) ) || ( ( offset + operand * number_planes number_planes ) > ( ssize_t ) if ( opcode == EOF ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; if ( opcode & 0x40 ) { image ) ; if ( opcode == EOF ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; } ; offset = ( ssize_t ) ( number_planes + plane ) ) || ( ( offset + operand * number_planes number_planes ) > ( ssize_t ) image ) ; if ( opcode == EOF ) ThrowRLEException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; ( image , ( ssize_t ) ( p & mask ) image , ( ssize_t ) ( x ( image , ( ssize_t ) ( image , ( ssize_t ) ( image , ( ssize_t ) ",ImageMagick@ImageMagick/7fdf9ea808caa3c81a0eb42656e5fafc59084198,CVE-2017-9144,https://github.com/ImageMagick/ImageMagick/commit/7fdf9ea808caa3c81a0eb42656e5fafc59084198,2017-05-22T14:29Z 1316,CWE-362,"CWE-362 int snd_card_new ( struct device * parent , int idx , const char * xid , struct module * module , int extra_size , struct snd_card * * card_ret ) { struct snd_card * card ; int err ; if ( snd_BUG_ON ( ! card_ret ) ) return - EINVAL ; * card_ret = NULL ; if ( extra_size < 0 ) extra_size = 0 ; card = kzalloc ( sizeof ( * card ) + extra_size , GFP_KERNEL ) ; if ( ! card ) return - ENOMEM ; if ( extra_size > 0 ) card -> private_data = ( char * ) card + sizeof ( struct snd_card ) ; if ( xid ) strlcpy ( card -> id , xid , sizeof ( card -> id ) ) ; err = 0 ; mutex_lock ( & snd_card_mutex ) ; if ( idx < 0 ) idx = get_slot_from_bitmask ( idx , module_slot_match , module ) ; if ( idx < 0 ) idx = get_slot_from_bitmask ( idx , check_empty_slot , module ) ; if ( idx < 0 ) err = - ENODEV ; else if ( idx < snd_ecards_limit ) { if ( test_bit ( idx , snd_cards_lock ) ) err = - EBUSY ; } else if ( idx >= SNDRV_CARDS ) err = - ENODEV ; if ( err < 0 ) { mutex_unlock ( & snd_card_mutex ) ; dev_err ( parent , ""cannotfindtheslotforindex%d(range0-%i),error:%d\\n"" , idx , snd_ecards_limit - 1 , err ) ; kfree ( card ) ; return err ; } set_bit ( idx , snd_cards_lock ) ; if ( idx >= snd_ecards_limit ) snd_ecards_limit = idx + 1 ; mutex_unlock ( & snd_card_mutex ) ; card -> dev = parent ; card -> number = idx ; card -> module = module ; INIT_LIST_HEAD ( & card -> devices ) ; init_rwsem ( & card -> controls_rwsem ) ; rwlock_init ( & card -> ctl_files_rwlock ) ; INIT_LIST_HEAD ( & card -> controls ) ; INIT_LIST_HEAD ( & card -> ctl_files ) ; spin_lock_init ( & card -> files_lock ) ; INIT_LIST_HEAD ( & card -> files_list ) ; # ifdef CONFIG_PM mutex_init ( & card -> power_lock ) ; init_waitqueue_head ( & card -> power_sleep ) ; # endif device_initialize ( & card -> card_dev ) ; card -> card_dev . parent = parent ; card -> card_dev . class = sound_class ; card -> card_dev . release = release_card_device ; card -> card_dev . groups = card_dev_attr_groups ; err = kobject_set_name ( & card -> card_dev . kobj , ""card%d"" , idx ) ; if ( err < 0 ) goto __error ; err = snd_ctl_create ( card ) ; if ( err < 0 ) { dev_err ( parent , ""unabletoregistercontrolminors\\n"" ) ; goto __error ; } err = snd_info_card_create ( card ) ; if ( err < 0 ) { dev_err ( parent , ""unabletocreatecardinfo\\n"" ) ; goto __error_ctl ; } * card_ret = card ; return 0 ; __error_ctl : snd_device_free_all ( card ) ; __error : put_device ( & card -> card_dev ) ; return err ; } "," ctl_files_rwlock ) ; mutex_init ( & card -> user_ctl_lock ) ; ",torvalds@linux/07f4d9d74a04aa7c72c5dae0ef97565f28f17b92,CVE-2014-4652,https://github.com/torvalds/linux/commit/07f4d9d74a04aa7c72c5dae0ef97565f28f17b92,2014-07-03T04:22Z 1317,CWE-347,"CWE-347 err_t verify_signed_hash ( const struct RSA_public_key * k , u_char * s , unsigned int s_max_octets , u_char * * psig , size_t hash_len , const u_char * sig_val , size_t sig_len ) { unsigned int padlen ; { chunk_t temp_s ; MP_INT c ; n_to_mpz ( & c , sig_val , sig_len ) ; oswcrypto . mod_exp ( & c , & c , & k -> e , & k -> n ) ; temp_s = mpz_to_n ( & c , sig_len ) ; if ( s_max_octets < sig_len ) { return ""2"" ""exponentiationfailed;toomanyoctets"" ; } memcpy ( s , temp_s . ptr , sig_len ) ; pfree ( temp_s . ptr ) ; mpz_clear ( & c ) ; } padlen = sig_len - 3 - hash_len ; DBG ( DBG_CRYPT , DBG_dump ( ""verify_shdecryptedSIG1:"" , s , sig_len ) ) ; DBG ( DBG_CRYPT , DBG_log ( ""pad_lencalculated:%dhash_len:%d"" , padlen , ( int ) hash_len ) ) ; if ( s [ 0 ] != 0x00 || s [ 1 ] != 0x01 || s [ padlen + 2 ] != 0x00 ) { return ""3"" ""SIGpaddingdoesnotcheckout"" ; } s += padlen + 3 ; ( * psig ) = s ; return NULL ; } "," ""SIGpaddingdoesnotcheckout"" ; } ( * psig ) = s + padlen + 3 + 3 ; { const u_char * p ; size_t cnt_ffs = 0 ; for ( p = s + 2 ; p < s + padlen + 2 ; p ++ ) if ( * p == 0xFF ) cnt_ffs ++ ; if ( cnt_ffs != padlen ) return ""4"" ""invalidPaddingString"" ; } return NULL ; ",xelerance@Openswan/9eaa6c2a823c1d2b58913506a15f9474bf857a3d,CVE-2018-15836,https://github.com/xelerance/Openswan/commit/9eaa6c2a823c1d2b58913506a15f9474bf857a3d,2018-09-26T21:29Z 1318,CWE-284,"CWE-284 int btpan_tap_send ( int tap_fd , const BD_ADDR src , const BD_ADDR dst , UINT16 proto , const char * buf , UINT16 len , BOOLEAN ext , BOOLEAN forward ) { UNUSED ( ext ) ; UNUSED ( forward ) ; if ( tap_fd != INVALID_FD ) { tETH_HDR eth_hdr ; memcpy ( & eth_hdr . h_dest , dst , ETH_ADDR_LEN ) ; memcpy ( & eth_hdr . h_src , src , ETH_ADDR_LEN ) ; eth_hdr . h_proto = htons ( proto ) ; char packet [ TAP_MAX_PKT_WRITE_LEN + sizeof ( tETH_HDR ) ] ; memcpy ( packet , & eth_hdr , sizeof ( tETH_HDR ) ) ; if ( len > TAP_MAX_PKT_WRITE_LEN ) { LOG_ERROR ( ""btpan_tap_sendethpacketsize:%disexceededlimit!"" , len ) ; return - 1 ; } memcpy ( packet + sizeof ( tETH_HDR ) , buf , len ) ; int ret = write ( tap_fd , packet , len + sizeof ( tETH_HDR ) ) ; BTIF_TRACE_DEBUG ( ""ret:%d"" , ret ) ; return ret ; } return - 1 ; } "," int ret = TEMP_FAILURE_RETRY ( sizeof ( tETH_HDR ) ",system@bt/472271b153c5dc53c28beac55480a8d8434b2d5c,CVE-2016-3839,https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c,2016-08-05T20:59Z 1319,CWE-119,"CWE-119 WORD32 ih264d_start_of_pic ( dec_struct_t * ps_dec , WORD32 i4_poc , pocstruct_t * ps_temp_poc , UWORD16 u2_frame_num , dec_pic_params_t * ps_pps ) { pocstruct_t * ps_prev_poc = & ps_dec -> s_cur_pic_poc ; pocstruct_t * ps_cur_poc = ps_temp_poc ; pic_buffer_t * pic_buf ; ivd_video_decode_op_t * ps_dec_output = ( ivd_video_decode_op_t * ) ps_dec -> pv_dec_out ; dec_slice_params_t * ps_cur_slice = ps_dec -> ps_cur_slice ; dec_seq_params_t * ps_seq = ps_pps -> ps_sps ; UWORD8 u1_bottom_field_flag = ps_cur_slice -> u1_bottom_field_flag ; UWORD8 u1_field_pic_flag = ps_cur_slice -> u1_field_pic_flag ; high_profile_tools_t s_high_profile ; WORD32 ret ; H264_MUTEX_LOCK ( & ps_dec -> process_disp_mutex ) ; ps_prev_poc -> i4_pic_order_cnt_lsb = ps_cur_poc -> i4_pic_order_cnt_lsb ; ps_prev_poc -> i4_pic_order_cnt_msb = ps_cur_poc -> i4_pic_order_cnt_msb ; ps_prev_poc -> i4_delta_pic_order_cnt_bottom = ps_cur_poc -> i4_delta_pic_order_cnt_bottom ; ps_prev_poc -> i4_delta_pic_order_cnt [ 0 ] = ps_cur_poc -> i4_delta_pic_order_cnt [ 0 ] ; ps_prev_poc -> i4_delta_pic_order_cnt [ 1 ] = ps_cur_poc -> i4_delta_pic_order_cnt [ 1 ] ; ps_prev_poc -> u1_bot_field = ps_dec -> ps_cur_slice -> u1_bottom_field_flag ; ps_prev_poc -> i4_prev_frame_num_ofst = ps_cur_poc -> i4_prev_frame_num_ofst ; ps_prev_poc -> u2_frame_num = u2_frame_num ; ps_dec -> i1_prev_mb_qp_delta = 0 ; ps_dec -> i1_next_ctxt_idx = 0 ; ps_dec -> u4_nmb_deblk = 0 ; if ( ps_dec -> u4_num_cores == 1 ) ps_dec -> u4_nmb_deblk = 1 ; if ( ps_seq -> u1_mb_aff_flag == 1 ) { ps_dec -> u4_nmb_deblk = 0 ; if ( ps_dec -> u4_num_cores > 2 ) ps_dec -> u4_num_cores = 2 ; } ps_dec -> u4_use_intrapred_line_copy = 0 ; if ( ps_seq -> u1_mb_aff_flag == 0 ) { ps_dec -> u4_use_intrapred_line_copy = 1 ; } ps_dec -> u4_app_disable_deblk_frm = 0 ; if ( ps_dec -> i4_degrade_type && ps_dec -> i4_degrade_pics ) { WORD32 degrade_pic ; ps_dec -> i4_degrade_pic_cnt ++ ; degrade_pic = 0 ; switch ( ps_dec -> i4_degrade_pics ) { case 4 : { degrade_pic = 1 ; break ; } case 3 : { if ( ps_cur_slice -> u1_slice_type != I_SLICE ) degrade_pic = 1 ; break ; } case 2 : { if ( ( ps_cur_slice -> u1_slice_type != I_SLICE ) && ( ps_dec -> i4_degrade_pic_cnt != ps_dec -> i4_nondegrade_interval ) ) degrade_pic = 1 ; break ; } case 1 : { if ( 0 == ps_cur_slice -> u1_nal_ref_idc ) { degrade_pic = 1 ; } break ; } } if ( degrade_pic ) { if ( ps_dec -> i4_degrade_type & 0x2 ) ps_dec -> u4_app_disable_deblk_frm = 1 ; if ( 0 == ps_cur_slice -> u1_nal_ref_idc ) { if ( ps_dec -> i4_degrade_type & 0x4 ) ps_dec -> i4_mv_frac_mask = 0 ; if ( ps_dec -> i4_degrade_type & 0x8 ) ps_dec -> i4_mv_frac_mask = 0 ; } } else ps_dec -> i4_degrade_pic_cnt = 0 ; } { dec_err_status_t * ps_err = ps_dec -> ps_dec_err_status ; if ( ps_dec -> u1_sl_typ_5_9 && ( ( ps_cur_slice -> u1_slice_type == I_SLICE ) || ( ps_cur_slice -> u1_slice_type == SI_SLICE ) ) ) ps_err -> u1_cur_pic_type = PIC_TYPE_I ; else ps_err -> u1_cur_pic_type = PIC_TYPE_UNKNOWN ; if ( ps_err -> u1_pic_aud_i == PIC_TYPE_I ) { ps_err -> u1_cur_pic_type = PIC_TYPE_I ; ps_err -> u1_pic_aud_i = PIC_TYPE_UNKNOWN ; } if ( ps_cur_slice -> u1_nal_unit_type == IDR_SLICE_NAL ) { if ( ps_err -> u1_err_flag ) ih264d_reset_ref_bufs ( ps_dec -> ps_dpb_mgr ) ; ps_err -> u1_err_flag = ACCEPT_ALL_PICS ; } } if ( ps_dec -> u1_init_dec_flag && ps_dec -> s_prev_seq_params . u1_eoseq_pending ) { WORD32 j ; for ( j = 0 ; j < MAX_DISP_BUFS_NEW ; j ++ ) { ih264_buf_mgr_release ( ( buf_mgr_t * ) ps_dec -> pv_pic_buf_mgr , j , BUF_MGR_REF ) ; ih264_buf_mgr_release ( ( buf_mgr_t * ) ps_dec -> pv_mv_buf_mgr , ps_dec -> au1_pic_buf_id_mv_buf_id_map [ j ] , BUF_MGR_REF ) ; ih264_buf_mgr_release ( ( buf_mgr_t * ) ps_dec -> pv_pic_buf_mgr , j , BUF_MGR_IO ) ; } ps_dec -> u1_second_field = 0 ; ps_dec -> i4_cur_display_seq = 0 ; ps_dec -> s_prev_seq_params . u1_eoseq_pending = 0 ; } ret = ih264d_init_pic ( ps_dec , u2_frame_num , i4_poc , ps_pps ) ; if ( ret != OK ) return ret ; ps_dec -> pv_parse_tu_coeff_data = ps_dec -> pv_pic_tu_coeff_data ; ps_dec -> pv_proc_tu_coeff_data = ps_dec -> pv_pic_tu_coeff_data ; ps_dec -> ps_nmb_info = ps_dec -> ps_frm_mb_info ; if ( ps_dec -> u1_separate_parse ) { UWORD16 pic_wd = ps_dec -> u4_width_at_init ; UWORD16 pic_ht = ps_dec -> u4_height_at_init ; UWORD32 num_mbs ; if ( ( NULL != ps_dec -> ps_cur_sps ) && ( 1 == ( ps_dec -> ps_cur_sps -> u1_is_valid ) ) ) { pic_wd = ps_dec -> u2_pic_wd ; pic_ht = ps_dec -> u2_pic_ht ; } num_mbs = ( pic_wd * pic_ht ) >> 8 ; if ( ps_dec -> pu1_dec_mb_map ) { memset ( ( void * ) ps_dec -> pu1_dec_mb_map , 0 , num_mbs ) ; } if ( ps_dec -> pu1_recon_mb_map ) { memset ( ( void * ) ps_dec -> pu1_recon_mb_map , 0 , num_mbs ) ; } if ( ps_dec -> pu2_slice_num_map ) { memset ( ( void * ) ps_dec -> pu2_slice_num_map , 0 , ( num_mbs * sizeof ( UWORD16 ) ) ) ; } } ps_dec -> ps_parse_cur_slice = & ( ps_dec -> ps_dec_slice_buf [ 0 ] ) ; ps_dec -> ps_decode_cur_slice = & ( ps_dec -> ps_dec_slice_buf [ 0 ] ) ; ps_dec -> ps_computebs_cur_slice = & ( ps_dec -> ps_dec_slice_buf [ 0 ] ) ; ps_dec -> u2_cur_slice_num = 0 ; ps_dec -> s_high_profile . u1_scaling_present = 0 ; ps_dec -> s_high_profile . u1_transform8x8_present = 0 ; if ( 1 == ps_dec -> u4_share_disp_buf ) { UWORD32 i ; for ( i = 0 ; i < MAX_DISP_BUFS_NEW ; i ++ ) { if ( 0 == ps_dec -> u4_disp_buf_to_be_freed [ i ] ) continue ; ih264_buf_mgr_release ( ( buf_mgr_t * ) ps_dec -> pv_pic_buf_mgr , i , BUF_MGR_IO ) ; ps_dec -> u4_disp_buf_to_be_freed [ i ] = 0 ; ps_dec -> u4_disp_buf_mapping [ i ] = 0 ; } } if ( ! ( u1_field_pic_flag && 0 != ps_dec -> u1_top_bottom_decoded ) ) { pic_buffer_t * ps_cur_pic ; WORD32 cur_pic_buf_id , cur_mv_buf_id ; col_mv_buf_t * ps_col_mv ; while ( 1 ) { ps_cur_pic = ( pic_buffer_t * ) ih264_buf_mgr_get_next_free ( ( buf_mgr_t * ) ps_dec -> pv_pic_buf_mgr , & cur_pic_buf_id ) ; if ( ps_cur_pic == NULL ) { ps_dec -> i4_error_code = ERROR_UNAVAIL_PICBUF_T ; return ERROR_UNAVAIL_PICBUF_T ; } if ( 0 == ps_dec -> u4_disp_buf_mapping [ cur_pic_buf_id ] ) { break ; } } ps_col_mv = ( col_mv_buf_t * ) ih264_buf_mgr_get_next_free ( ( buf_mgr_t * ) ps_dec -> pv_mv_buf_mgr , & cur_mv_buf_id ) ; if ( ps_col_mv == NULL ) { ps_dec -> i4_error_code = ERROR_UNAVAIL_MVBUF_T ; return ERROR_UNAVAIL_MVBUF_T ; } ps_dec -> ps_cur_pic = ps_cur_pic ; ps_dec -> u1_pic_buf_id = cur_pic_buf_id ; ps_cur_pic -> u4_ts = ps_dec -> u4_ts ; ps_cur_pic -> u1_mv_buf_id = cur_mv_buf_id ; ps_dec -> au1_pic_buf_id_mv_buf_id_map [ cur_pic_buf_id ] = cur_mv_buf_id ; ps_cur_pic -> pu1_col_zero_flag = ( UWORD8 * ) ps_col_mv -> pv_col_zero_flag ; ps_cur_pic -> ps_mv = ( mv_pred_t * ) ps_col_mv -> pv_mv ; ps_dec -> au1_pic_buf_ref_flag [ cur_pic_buf_id ] = 0 ; if ( ps_dec -> u1_first_slice_in_stream ) { ps_dec -> ps_ref_pic_buf_lx [ 0 ] = ps_dec -> ps_dpb_mgr -> ps_init_dpb [ 0 ] ; * ( ps_dec -> ps_dpb_mgr -> ps_init_dpb [ 0 ] [ 0 ] ) = * ps_cur_pic ; * ( ps_dec -> ps_dpb_mgr -> ps_init_dpb [ 0 ] [ MAX_REF_BUFS ] ) = * ps_cur_pic ; } if ( ! ps_dec -> ps_cur_pic ) { WORD32 j ; H264_DEC_DEBUG_PRINT ( ""-------DisplayBuffersReset--------\\n"" ) ; for ( j = 0 ; j < MAX_DISP_BUFS_NEW ; j ++ ) { ih264_buf_mgr_release ( ( buf_mgr_t * ) ps_dec -> pv_pic_buf_mgr , j , BUF_MGR_REF ) ; ih264_buf_mgr_release ( ( buf_mgr_t * ) ps_dec -> pv_mv_buf_mgr , ps_dec -> au1_pic_buf_id_mv_buf_id_map [ j ] , BUF_MGR_REF ) ; ih264_buf_mgr_release ( ( buf_mgr_t * ) ps_dec -> pv_pic_buf_mgr , j , BUF_MGR_IO ) ; } ps_dec -> i4_cur_display_seq = 0 ; ps_dec -> i4_prev_max_display_seq = 0 ; ps_dec -> i4_max_poc = 0 ; ps_cur_pic = ( pic_buffer_t * ) ih264_buf_mgr_get_next_free ( ( buf_mgr_t * ) ps_dec -> pv_pic_buf_mgr , & cur_pic_buf_id ) ; if ( ps_cur_pic == NULL ) { ps_dec -> i4_error_code = ERROR_UNAVAIL_PICBUF_T ; return ERROR_UNAVAIL_PICBUF_T ; } ps_col_mv = ( col_mv_buf_t * ) ih264_buf_mgr_get_next_free ( ( buf_mgr_t * ) ps_dec -> pv_mv_buf_mgr , & cur_mv_buf_id ) ; if ( ps_col_mv == NULL ) { ps_dec -> i4_error_code = ERROR_UNAVAIL_MVBUF_T ; return ERROR_UNAVAIL_MVBUF_T ; } ps_dec -> ps_cur_pic = ps_cur_pic ; ps_dec -> u1_pic_buf_id = cur_pic_buf_id ; ps_cur_pic -> u4_ts = ps_dec -> u4_ts ; ps_dec -> apv_buf_id_pic_buf_map [ cur_pic_buf_id ] = ( void * ) ps_cur_pic ; ps_cur_pic -> u1_mv_buf_id = cur_mv_buf_id ; ps_dec -> au1_pic_buf_id_mv_buf_id_map [ cur_pic_buf_id ] = cur_mv_buf_id ; ps_cur_pic -> pu1_col_zero_flag = ( UWORD8 * ) ps_col_mv -> pv_col_zero_flag ; ps_cur_pic -> ps_mv = ( mv_pred_t * ) ps_col_mv -> pv_mv ; ps_dec -> au1_pic_buf_ref_flag [ cur_pic_buf_id ] = 0 ; } ps_dec -> ps_cur_pic -> u1_picturetype = u1_field_pic_flag ; ps_dec -> ps_cur_pic -> u4_pack_slc_typ = SKIP_NONE ; H264_DEC_DEBUG_PRINT ( ""gotabuffer\\n"" ) ; } else { H264_DEC_DEBUG_PRINT ( ""didnotgetabuffer\\n"" ) ; } ps_dec -> u4_pic_buf_got = 1 ; ps_dec -> ps_cur_pic -> i4_poc = i4_poc ; ps_dec -> ps_cur_pic -> i4_frame_num = u2_frame_num ; ps_dec -> ps_cur_pic -> i4_pic_num = u2_frame_num ; ps_dec -> ps_cur_pic -> i4_top_field_order_cnt = ps_pps -> i4_top_field_order_cnt ; ps_dec -> ps_cur_pic -> i4_bottom_field_order_cnt = ps_pps -> i4_bottom_field_order_cnt ; ps_dec -> ps_cur_pic -> i4_avg_poc = ps_pps -> i4_avg_poc ; ps_dec -> ps_cur_pic -> u4_time_stamp = ps_dec -> u4_pts ; ps_dec -> s_cur_pic = * ( ps_dec -> ps_cur_pic ) ; if ( u1_field_pic_flag && u1_bottom_field_flag ) { WORD32 i4_temp_poc ; WORD32 i4_top_field_order_poc , i4_bot_field_order_poc ; ps_dec -> s_cur_pic . pu1_buf1 += ps_dec -> s_cur_pic . u2_frm_wd_y ; ps_dec -> s_cur_pic . pu1_buf2 += ps_dec -> s_cur_pic . u2_frm_wd_uv ; ps_dec -> s_cur_pic . pu1_buf3 += ps_dec -> s_cur_pic . u2_frm_wd_uv ; ps_dec -> s_cur_pic . ps_mv += ( ( ps_dec -> u2_pic_ht * ps_dec -> u2_pic_wd ) >> 5 ) ; ps_dec -> s_cur_pic . pu1_col_zero_flag += ( ( ps_dec -> u2_pic_ht * ps_dec -> u2_pic_wd ) >> 5 ) ; ps_dec -> ps_cur_pic -> u1_picturetype |= BOT_FLD ; i4_top_field_order_poc = ps_dec -> ps_cur_pic -> i4_top_field_order_cnt ; i4_bot_field_order_poc = ps_dec -> ps_cur_pic -> i4_bottom_field_order_cnt ; i4_temp_poc = MIN ( i4_top_field_order_poc , i4_bot_field_order_poc ) ; ps_dec -> ps_cur_pic -> i4_avg_poc = i4_temp_poc ; } ps_cur_slice -> u1_mbaff_frame_flag = ps_seq -> u1_mb_aff_flag && ( ! u1_field_pic_flag ) ; ps_dec -> ps_cur_pic -> u1_picturetype |= ( ps_cur_slice -> u1_mbaff_frame_flag << 2 ) ; ps_dec -> ps_cur_mb_row = ps_dec -> ps_nbr_mb_row ; ps_dec -> ps_cur_mb_row ++ ; ps_dec -> ps_top_mb_row = ps_dec -> ps_nbr_mb_row + ( ( ps_dec -> u2_frm_wd_in_mbs + 1 ) << ( 1 - ps_dec -> ps_cur_sps -> u1_frame_mbs_only_flag ) ) ; ps_dec -> ps_top_mb_row ++ ; ps_dec -> pu1_y = ps_dec -> pu1_y_scratch [ 0 ] ; ps_dec -> pu1_u = ps_dec -> pu1_u_scratch [ 0 ] ; ps_dec -> pu1_v = ps_dec -> pu1_v_scratch [ 0 ] ; ps_dec -> u1_yuv_scratch_idx = 0 ; ps_dec -> ps_mv_cur = ps_dec -> s_cur_pic . ps_mv ; ps_dec -> ps_mv_top = ps_dec -> ps_mv_top_p [ 0 ] ; ps_dec -> u1_mv_top_p = 0 ; ps_dec -> u1_mb_idx = 0 ; ps_dec -> ps_mv_left = ps_dec -> s_cur_pic . ps_mv ; ps_dec -> pu1_yleft = 0 ; ps_dec -> pu1_uleft = 0 ; ps_dec -> pu1_vleft = 0 ; ps_dec -> u1_not_wait_rec = 2 ; ps_dec -> u2_total_mbs_coded = 0 ; ps_dec -> i4_submb_ofst = - ( SUB_BLK_SIZE ) ; ps_dec -> u4_pred_info_idx = 0 ; ps_dec -> u4_pred_info_pkd_idx = 0 ; ps_dec -> u4_dma_buf_idx = 0 ; ps_dec -> ps_mv = ps_dec -> s_cur_pic . ps_mv ; ps_dec -> ps_mv_bank_cur = ps_dec -> s_cur_pic . ps_mv ; ps_dec -> pu1_col_zero_flag = ps_dec -> s_cur_pic . pu1_col_zero_flag ; ps_dec -> ps_part = ps_dec -> ps_parse_part_params ; ps_dec -> i2_prev_slice_mbx = - 1 ; ps_dec -> i2_prev_slice_mby = 0 ; ps_dec -> u2_mv_2mb [ 0 ] = 0 ; ps_dec -> u2_mv_2mb [ 1 ] = 0 ; ps_dec -> u1_last_pic_not_decoded = 0 ; ps_dec -> u2_cur_slice_num_dec_thread = 0 ; ps_dec -> u2_cur_slice_num_bs = 0 ; ps_dec -> u4_intra_pred_line_ofst = 0 ; ps_dec -> pu1_cur_y_intra_pred_line = ps_dec -> pu1_y_intra_pred_line ; ps_dec -> pu1_cur_u_intra_pred_line = ps_dec -> pu1_u_intra_pred_line ; ps_dec -> pu1_cur_v_intra_pred_line = ps_dec -> pu1_v_intra_pred_line ; ps_dec -> pu1_cur_y_intra_pred_line_base = ps_dec -> pu1_y_intra_pred_line ; ps_dec -> pu1_cur_u_intra_pred_line_base = ps_dec -> pu1_u_intra_pred_line ; ps_dec -> pu1_cur_v_intra_pred_line_base = ps_dec -> pu1_v_intra_pred_line ; ps_dec -> pu1_prev_y_intra_pred_line = ps_dec -> pu1_y_intra_pred_line + ( ps_dec -> u2_frm_wd_in_mbs * MB_SIZE ) ; ps_dec -> pu1_prev_u_intra_pred_line = ps_dec -> pu1_u_intra_pred_line + ps_dec -> u2_frm_wd_in_mbs * BLK8x8SIZE * YUV420SP_FACTOR ; ps_dec -> pu1_prev_v_intra_pred_line = ps_dec -> pu1_v_intra_pred_line + ps_dec -> u2_frm_wd_in_mbs * BLK8x8SIZE ; ps_dec -> ps_deblk_mbn = ps_dec -> ps_deblk_pic ; ps_dec -> ps_deblk_mbn_curr = ps_dec -> ps_deblk_mbn ; ps_dec -> ps_deblk_mbn_prev = ps_dec -> ps_deblk_mbn + ps_dec -> u1_recon_mb_grp ; { if ( ps_cur_slice -> u1_mbaff_frame_flag ) { ps_dec -> pf_compute_bs = ih264d_compute_bs_mbaff ; ps_dec -> pf_mvpred = ih264d_mvpred_mbaff ; } else { ps_dec -> pf_compute_bs = ih264d_compute_bs_non_mbaff ; ps_dec -> u1_cur_mb_fld_dec_flag = ps_cur_slice -> u1_field_pic_flag ; } } { UWORD8 u1_field_pic_flag = ps_dec -> ps_cur_slice -> u1_field_pic_flag ; UWORD8 u1_mbaff = ps_cur_slice -> u1_mbaff_frame_flag ; UWORD8 uc_lastmbs = ( ( ( ps_dec -> u2_pic_wd ) >> 4 ) % ( ps_dec -> u1_recon_mb_grp >> u1_mbaff ) ) ; UWORD16 ui16_lastmbs_widthY = ( uc_lastmbs ? ( uc_lastmbs << 4 ) : ( ( ps_dec -> u1_recon_mb_grp >> u1_mbaff ) << 4 ) ) ; UWORD16 ui16_lastmbs_widthUV = uc_lastmbs ? ( uc_lastmbs << 3 ) : ( ( ps_dec -> u1_recon_mb_grp >> u1_mbaff ) << 3 ) ; ps_dec -> s_tran_addrecon . pu1_dest_y = ps_dec -> s_cur_pic . pu1_buf1 ; ps_dec -> s_tran_addrecon . pu1_dest_u = ps_dec -> s_cur_pic . pu1_buf2 ; ps_dec -> s_tran_addrecon . pu1_dest_v = ps_dec -> s_cur_pic . pu1_buf3 ; ps_dec -> s_tran_addrecon . u2_frm_wd_y = ps_dec -> u2_frm_wd_y << u1_field_pic_flag ; ps_dec -> s_tran_addrecon . u2_frm_wd_uv = ps_dec -> u2_frm_wd_uv << u1_field_pic_flag ; if ( u1_field_pic_flag ) { ui16_lastmbs_widthY += ps_dec -> u2_frm_wd_y ; ui16_lastmbs_widthUV += ps_dec -> u2_frm_wd_uv ; } ps_dec -> s_tran_addrecon . u4_inc_y [ 0 ] = ( ( ps_dec -> u1_recon_mb_grp << 4 ) >> u1_mbaff ) ; ps_dec -> s_tran_addrecon . u4_inc_uv [ 0 ] = ( ( ps_dec -> u1_recon_mb_grp << 4 ) >> u1_mbaff ) ; ps_dec -> s_tran_addrecon . u4_inc_y [ 1 ] = ( ui16_lastmbs_widthY + ( PAD_LEN_Y_H << 1 ) + ps_dec -> s_tran_addrecon . u2_frm_wd_y * ( ( 15 << u1_mbaff ) + u1_mbaff ) ) ; ps_dec -> s_tran_addrecon . u4_inc_uv [ 1 ] = ( ui16_lastmbs_widthUV + ( PAD_LEN_UV_H << 2 ) + ps_dec -> s_tran_addrecon . u2_frm_wd_uv * ( ( 15 << u1_mbaff ) + u1_mbaff ) ) ; ih264d_assign_pic_num ( ps_dec ) ; ps_dec -> s_tran_addrecon . u2_mv_top_left_inc = ( ps_dec -> u1_recon_mb_grp << 2 ) - 1 - ( u1_mbaff << 2 ) ; ps_dec -> s_tran_addrecon . u2_mv_left_inc = ( ( ps_dec -> u1_recon_mb_grp >> u1_mbaff ) - 1 ) << ( 4 + u1_mbaff ) ; } if ( ps_seq -> u1_profile_idc == HIGH_PROFILE_IDC ) { if ( ( ps_seq -> i4_seq_scaling_matrix_present_flag ) || ( ps_pps -> i4_pic_scaling_matrix_present_flag ) ) { ih264d_form_scaling_matrix_picture ( ps_seq , ps_pps , ps_dec ) ; ps_dec -> s_high_profile . u1_scaling_present = 1 ; } else { ih264d_form_default_scaling_matrix ( ps_dec ) ; } if ( ps_pps -> i4_transform_8x8_mode_flag ) { ps_dec -> s_high_profile . u1_transform8x8_present = 1 ; } } else { ih264d_form_default_scaling_matrix ( ps_dec ) ; } ps_dec -> s_high_profile . u1_direct_8x8_inference_flag = ps_seq -> u1_direct_8x8_inference_flag ; ps_dec -> s_high_profile . s_cavlc_ctxt = ps_dec -> s_cavlc_ctxt ; ps_dec -> i1_recon_in_thread3_flag = 1 ; ps_dec -> ps_frame_buf_ip_recon = & ps_dec -> s_tran_addrecon ; if ( ps_dec -> u1_separate_parse ) { memcpy ( & ps_dec -> s_tran_addrecon_parse , & ps_dec -> s_tran_addrecon , sizeof ( tfr_ctxt_t ) ) ; if ( ps_dec -> u4_num_cores >= 3 && ps_dec -> i1_recon_in_thread3_flag ) { memcpy ( & ps_dec -> s_tran_iprecon , & ps_dec -> s_tran_addrecon , sizeof ( tfr_ctxt_t ) ) ; ps_dec -> ps_frame_buf_ip_recon = & ps_dec -> s_tran_iprecon ; } } ih264d_init_deblk_tfr_ctxt ( ps_dec , & ( ps_dec -> s_pad_mgr ) , & ( ps_dec -> s_tran_addrecon ) , ps_dec -> u2_frm_wd_in_mbs , 0 ) ; ps_dec -> ps_cur_deblk_mb = ps_dec -> ps_deblk_pic ; ps_dec -> u4_cur_deblk_mb_num = 0 ; ps_dec -> u4_deblk_mb_x = 0 ; ps_dec -> u4_deblk_mb_y = 0 ; ps_dec -> pu4_wt_ofsts = ps_dec -> pu4_wts_ofsts_mat ; H264_MUTEX_UNLOCK ( & ps_dec -> process_disp_mutex ) ; return OK ; } "," = 0 ; { ps_dec -> ",external@libavc/f634481e940421020e52f511c1fb34aac1db4b2f,CVE-2017-0543,https://android.googlesource.com/platform/external/libavc/+/f634481e940421020e52f511c1fb34aac1db4b2f,2017-04-07T22:59Z 1320,CWE-119,"CWE-119 static int dtls1_buffer_record ( SSL * s , record_pqueue * queue , unsigned char * priority ) { DTLS1_RECORD_DATA * rdata ; pitem * item ; if ( pqueue_size ( queue -> q ) >= 100 ) return 0 ; rdata = OPENSSL_malloc ( sizeof ( DTLS1_RECORD_DATA ) ) ; item = pitem_new ( priority , rdata ) ; if ( rdata == NULL || item == NULL ) { if ( rdata != NULL ) OPENSSL_free ( rdata ) ; if ( item != NULL ) pitem_free ( item ) ; SSLerr ( SSL_F_DTLS1_BUFFER_RECORD , ERR_R_INTERNAL_ERROR ) ; return ( 0 ) ; } rdata -> packet = s -> packet ; rdata -> packet_length = s -> packet_length ; memcpy ( & ( rdata -> rbuf ) , & ( s -> s3 -> rbuf ) , sizeof ( SSL3_BUFFER ) ) ; memcpy ( & ( rdata -> rrec ) , & ( s -> s3 -> rrec ) , sizeof ( SSL3_RECORD ) ) ; item -> data = rdata ; # ifndef OPENSSL_NO_SCTP if ( BIO_dgram_is_sctp ( SSL_get_rbio ( s ) ) && ( s -> state == SSL3_ST_SR_FINISHED_A || s -> state == SSL3_ST_CR_FINISHED_A ) ) { BIO_ctrl ( SSL_get_rbio ( s ) , BIO_CTRL_DGRAM_SCTP_GET_RCVINFO , sizeof ( rdata -> recordinfo ) , & rdata -> recordinfo ) ; } # endif s -> packet = NULL ; s -> packet_length = 0 ; memset ( & ( s -> s3 -> rbuf ) , 0 , sizeof ( SSL3_BUFFER ) ) ; memset ( & ( s -> s3 -> rrec ) , 0 , sizeof ( SSL3_RECORD ) ) ; if ( ! ssl3_setup_buffers ( s ) ) { SSLerr ( SSL_F_DTLS1_BUFFER_RECORD , ERR_R_INTERNAL_ERROR ) ; OPENSSL_free ( rdata ) ; pitem_free ( item ) ; return ( 0 ) ; } if ( pqueue_insert ( queue -> q , item ) == NULL ) { SSLerr ( SSL_F_DTLS1_BUFFER_RECORD , ERR_R_INTERNAL_ERROR ) ; OPENSSL_free ( rdata ) ; pitem_free ( item ) ; return ( 0 ) ; } return ( 1 ) ; } "," ERR_R_INTERNAL_ERROR ) ; if ( rdata -> rbuf . buf != NULL ) OPENSSL_free ( rdata -> rbuf . buf ) ; OPENSSL_free ( rdata ; return ( - 1 ) ; } ERR_R_INTERNAL_ERROR ) ; if ( rdata -> rbuf . buf != NULL ) OPENSSL_free ( rdata -> rbuf . buf ) ; OPENSSL_free ( rdata ; return ( - 1 ) ; } ",openssl@openssl/103b171d8fc282ef435f8de9afbf7782e312961f,CVE-2015-0206,https://github.com/openssl/openssl/commit/103b171d8fc282ef435f8de9afbf7782e312961f,2015-01-09T02:59Z 1321,CWE-310,"CWE-310 static int sctp_v6_xmit ( struct sk_buff * skb , struct sctp_transport * transport ) { struct sock * sk = skb -> sk ; struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct flowi6 fl6 ; memset ( & fl6 , 0 , sizeof ( fl6 ) ) ; fl6 . flowi6_proto = sk -> sk_protocol ; fl6 . daddr = transport -> ipaddr . v6 . sin6_addr ; fl6 . saddr = transport -> saddr . v6 . sin6_addr ; fl6 . flowlabel = np -> flow_label ; IP6_ECN_flow_xmit ( sk , fl6 . flowlabel ) ; if ( ipv6_addr_type ( & fl6 . saddr ) & IPV6_ADDR_LINKLOCAL ) fl6 . flowi6_oif = transport -> saddr . v6 . sin6_scope_id ; else fl6 . flowi6_oif = sk -> sk_bound_dev_if ; if ( np -> opt && np -> opt -> srcrt ) { struct rt0_hdr * rt0 = ( struct rt0_hdr * ) np -> opt -> srcrt ; fl6 . daddr = * rt0 -> addr ; } pr_debug ( ""%s:skb:%p,len:%d,src:%pI6dst:%pI6\\n"" , __func__ , skb , skb -> len , & fl6 . saddr , & fl6 . daddr ) ; SCTP_INC_STATS ( sock_net ( sk ) , SCTP_MIB_OUTSCTPPACKS ) ; if ( ! ( transport -> param_flags & SPP_PMTUD_ENABLE ) ) skb -> local_df = 1 ; return ip6_xmit ( sk , skb , & fl6 , np -> opt , np -> tclass ) ; } "," ; struct flowi6 * fl6 = & transport -> fl . u . ip6 ; pr_debug ( ""%s:skb:%p,len:%d,src:%pI6dst:%pI6\\n"" , & fl6 -> saddr , & , & fl6 -> daddr ) ; daddr ) ; IP6_ECN_flow_xmit ( sk , fl6 -> flowlabel ) ; if = 1 ; SCTP_INC_STATS ( sock_net ( sk ) , SCTP_MIB_OUTSCTPPACKS ) ; , skb , fl6 , np ",torvalds@linux/95ee62083cb6453e056562d91f597552021e6ae7,CVE-2013-4350,https://github.com/torvalds/linux/commit/95ee62083cb6453e056562d91f597552021e6ae7,2013-09-25T10:31Z 1322,CWE-189,"CWE-189 int i915_gem_execbuffer2 ( struct drm_device * dev , void * data , struct drm_file * file ) { struct drm_i915_gem_execbuffer2 * args = data ; struct drm_i915_gem_exec_object2 * exec2_list = NULL ; int ret ; if ( args -> buffer_count < 1 ) { DRM_DEBUG ( ""execbuf2with%dbuffers\\n"" , args -> buffer_count ) ; return - EINVAL ; } exec2_list = kmalloc ( sizeof ( * exec2_list ) * args -> buffer_count , GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY ) ; if ( exec2_list == NULL ) exec2_list = drm_malloc_ab ( sizeof ( * exec2_list ) , args -> buffer_count ) ; if ( exec2_list == NULL ) { DRM_DEBUG ( ""Failedtoallocateexeclistfor%dbuffers\\n"" , args -> buffer_count ) ; return - ENOMEM ; } ret = copy_from_user ( exec2_list , ( struct drm_i915_relocation_entry __user * ) ( uintptr_t ) args -> buffers_ptr , sizeof ( * exec2_list ) * args -> buffer_count ) ; if ( ret != 0 ) { DRM_DEBUG ( ""copy%dexecentriesfailed%d\\n"" , args -> buffer_count , ret ) ; drm_free_large ( exec2_list ) ; return - EFAULT ; } ret = i915_gem_do_execbuffer ( dev , data , file , args , exec2_list ) ; if ( ! ret ) { ret = copy_to_user ( ( struct drm_i915_relocation_entry __user * ) ( uintptr_t ) args -> buffers_ptr , exec2_list , sizeof ( * exec2_list ) * args -> buffer_count ) ; if ( ret ) { ret = - EFAULT ; DRM_DEBUG ( ""failedtocopy%dexecentries"" ""backtouser(%d)\\n"" , args -> buffer_count , ret ) ; } } drm_free_large ( exec2_list ) ; return ret ; } "," buffer_count < 1 || args -> buffer_count > UINT_MAX / sizeof ( * exec2_list ) ",torvalds@linux/ed8cd3b2cd61004cab85380c52b1817aca1ca49b,CVE-2012-2383,https://github.com/torvalds/linux/commit/ed8cd3b2cd61004cab85380c52b1817aca1ca49b,2012-06-13T10:24Z 1323,CWE-362,"CWE-362 static int mptctl_getiocinfo ( unsigned long arg , unsigned int data_size ) { struct mpt_ioctl_iocinfo __user * uarg = ( void __user * ) arg ; struct mpt_ioctl_iocinfo * karg ; MPT_ADAPTER * ioc ; struct pci_dev * pdev ; int iocnum ; unsigned int port ; int cim_rev ; struct scsi_device * sdev ; VirtDevice * vdevice ; if ( data_size == sizeof ( struct mpt_ioctl_iocinfo_rev0 ) ) cim_rev = 0 ; else if ( data_size == sizeof ( struct mpt_ioctl_iocinfo_rev1 ) ) cim_rev = 1 ; else if ( data_size == sizeof ( struct mpt_ioctl_iocinfo ) ) cim_rev = 2 ; else if ( data_size == ( sizeof ( struct mpt_ioctl_iocinfo_rev0 ) + 12 ) ) cim_rev = 0 ; else return - EFAULT ; karg = memdup_user ( uarg , data_size ) ; if ( IS_ERR ( karg ) ) { printk ( KERN_ERR MYNAM ""%s@%d::mpt_ioctl_iocinfo()-memdup_userreturnederror[%ld]\\n"" , __FILE__ , __LINE__ , PTR_ERR ( karg ) ) ; return PTR_ERR ( karg ) ; } if ( ( ( iocnum = mpt_verify_adapter ( karg -> hdr . iocnum , & ioc ) ) < 0 ) || ( ioc == NULL ) ) { printk ( KERN_DEBUG MYNAM ""%s::mptctl_getiocinfo()@%d-ioc%dnotfound!\\n"" , __FILE__ , __LINE__ , iocnum ) ; kfree ( karg ) ; return - ENODEV ; } if ( karg -> hdr . maxDataSize != data_size ) { printk ( MYIOC_s_ERR_FMT ""%s@%d::mptctl_getiocinfo-"" ""Structuresizemismatch.Commandnotcompleted.\\n"" , ioc -> name , __FILE__ , __LINE__ ) ; kfree ( karg ) ; return - EFAULT ; } dctlprintk ( ioc , printk ( MYIOC_s_DEBUG_FMT ""mptctl_getiocinfocalled.\\n"" , ioc -> name ) ) ; if ( ioc -> bus_type == SAS ) karg -> adapterType = MPT_IOCTL_INTERFACE_SAS ; else if ( ioc -> bus_type == FC ) karg -> adapterType = MPT_IOCTL_INTERFACE_FC ; else karg -> adapterType = MPT_IOCTL_INTERFACE_SCSI ; if ( karg -> hdr . port > 1 ) { kfree ( karg ) ; return - EINVAL ; } port = karg -> hdr . port ; karg -> port = port ; pdev = ( struct pci_dev * ) ioc -> pcidev ; karg -> pciId = pdev -> device ; karg -> hwRev = pdev -> revision ; karg -> subSystemDevice = pdev -> subsystem_device ; karg -> subSystemVendor = pdev -> subsystem_vendor ; if ( cim_rev == 1 ) { karg -> pciInfo . u . bits . busNumber = pdev -> bus -> number ; karg -> pciInfo . u . bits . deviceNumber = PCI_SLOT ( pdev -> devfn ) ; karg -> pciInfo . u . bits . functionNumber = PCI_FUNC ( pdev -> devfn ) ; } else if ( cim_rev == 2 ) { karg -> pciInfo . u . bits . busNumber = pdev -> bus -> number ; karg -> pciInfo . u . bits . deviceNumber = PCI_SLOT ( pdev -> devfn ) ; karg -> pciInfo . u . bits . functionNumber = PCI_FUNC ( pdev -> devfn ) ; karg -> pciInfo . segmentID = pci_domain_nr ( pdev -> bus ) ; } karg -> numDevices = 0 ; if ( ioc -> sh ) { shost_for_each_device ( sdev , ioc -> sh ) { vdevice = sdev -> hostdata ; if ( vdevice == NULL || vdevice -> vtarget == NULL ) continue ; if ( vdevice -> vtarget -> tflags & MPT_TARGET_FLAGS_RAID_COMPONENT ) continue ; karg -> numDevices ++ ; } } karg -> FWVersion = ioc -> facts . FWVersion . Word ; karg -> BIOSVersion = ioc -> biosVersion ; strncpy ( karg -> driverVersion , MPT_LINUX_PACKAGE_NAME , MPT_IOCTL_VERSION_LENGTH ) ; karg -> driverVersion [ MPT_IOCTL_VERSION_LENGTH - 1 ] = '\\0' ; karg -> busChangeEvent = 0 ; karg -> hostId = ioc -> pfacts [ port ] . PortSCSIID ; karg -> rsvd [ 0 ] = karg -> rsvd [ 1 ] = 0 ; if ( copy_to_user ( ( char __user * ) arg , karg , data_size ) ) { printk ( MYIOC_s_ERR_FMT ""%s@%d::mptctl_getiocinfo-"" ""Unabletowriteoutmpt_ioctl_iocinfostruct@%p\\n"" , ioc -> name , __FILE__ , __LINE__ , uarg ) ; kfree ( karg ) ; return - EFAULT ; } kfree ( karg ) ; return 0 ; } "," int mptctl_getiocinfo ( MPT_ADAPTER * ioc , * karg ; struct pci_dev * pci_dev * pdev ; unsigned int ( karg ) ; } if ",torvalds@linux/28d76df18f0ad5bcf5fa48510b225f0ed262a99b,CVE-2020-12652,https://github.com/torvalds/linux/commit/28d76df18f0ad5bcf5fa48510b225f0ed262a99b,2020-05-05T05:15Z 1324,CWE-119,"CWE-119 int mp_unpack_full ( lua_State * L , int limit , int offset ) { size_t len ; const char * s ; mp_cur c ; int cnt ; int decode_all = ( ! limit && ! offset ) ; s = luaL_checklstring ( L , 1 , & len ) ; if ( offset < 0 || limit < 0 ) return luaL_error ( L , ""Invalidrequesttounpackwithoffsetof%dandlimitof%d."" , offset , len ) ; else if ( offset > len ) return luaL_error ( L , ""Startoffset%dgreaterthaninputlength%d."" , offset , len ) ; if ( decode_all ) limit = INT_MAX ; mp_cur_init ( & c , ( const unsigned char * ) s + offset , len - offset ) ; for ( cnt = 0 ; c . left > 0 && cnt < limit ; cnt ++ ) { mp_decode_to_lua_type ( L , & c ) ; if ( c . err == MP_CUR_ERROR_EOF ) { return luaL_error ( L , ""Missingbytesininput."" ) ; } else if ( c . err == MP_CUR_ERROR_BADFMT ) { return luaL_error ( L , ""Baddataformatininput."" ) ; } } if ( ! decode_all ) { int offset = len - c . left ; lua_pushinteger ( L , c . left == 0 ? - 1 : offset ) ; lua_insert ( L , 2 ) ; cnt += 1 ; } return cnt ; } "," . left ; luaL_checkstack ( L , 1 , ""infunctionmp_unpack_full"" ) ; ",antirez@redis/5ccb6f7a791bf3490357b00a898885759d98bab0,CVE-2018-11218,https://github.com/antirez/redis/commit/5ccb6f7a791bf3490357b00a898885759d98bab0,2018-06-17T17:29Z 1325,CWE-59,"CWE-59 static inline int mount_entry_on_generic ( struct mntent * mntent , const char * path ) { unsigned long mntflags ; char * mntdata ; int ret ; bool optional = hasmntopt ( mntent , ""optional"" ) != NULL ; ret = mount_entry_create_dir_file ( mntent , path ) ; if ( ret < 0 ) return optional ? 0 : - 1 ; cull_mntent_opt ( mntent ) ; if ( parse_mntopts ( mntent -> mnt_opts , & mntflags , & mntdata ) < 0 ) { free ( mntdata ) ; return - 1 ; } ret = mount_entry ( mntent -> mnt_fsname , path , mntent -> mnt_type , mntflags , mntdata , optional ) ; free ( mntdata ) ; return ret ; } "," char * path , const char * rootfs mntdata , optional , rootfs ",lxc@lxc/592fd47a6245508b79fe6ac819fe6d3b2c1289be,CVE-2015-1335,https://github.com/lxc/lxc/commit/592fd47a6245508b79fe6ac819fe6d3b2c1289be,2015-10-01T20:59Z 1326,CWE-119,"CWE-119 static Image * ReadHRZImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { Image * image ; MagickBooleanType status ; register ssize_t x ; register PixelPacket * q ; register unsigned char * p ; ssize_t count , y ; size_t length ; unsigned char * pixels ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image -> columns = 256 ; image -> rows = 240 ; image -> depth = 8 ; pixels = ( unsigned char * ) AcquireQuantumMemory ( image -> columns , 3 * sizeof ( * pixels ) ) ; if ( pixels == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; length = ( size_t ) ( 3 * image -> columns ) ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { count = ReadBlob ( image , length , pixels ) ; if ( ( size_t ) count != length ) ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; p = pixels ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( q , ScaleCharToQuantum ( 4 * * p ++ ) ) ; SetPixelGreen ( q , ScaleCharToQuantum ( 4 * * p ++ ) ) ; SetPixelBlue ( q , ScaleCharToQuantum ( 4 * * p ++ ) ) ; SetPixelOpacity ( q , OpaqueOpacity ) ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( SetImageProgress ( image , LoadImageTag , y , image -> rows ) == MagickFalse ) break ; } pixels = ( unsigned char * ) RelinquishMagickMemory ( pixels ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," = 8 ; status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; } ",ImageMagick@ImageMagick/f6e9d0d9955e85bdd7540b251cd50d598dacc5e6,CVE-2016-10066,https://github.com/ImageMagick/ImageMagick/commit/f6e9d0d9955e85bdd7540b251cd50d598dacc5e6,2017-03-03T17:59Z 1327,CWE-362,"CWE-362 static void audit_log_execve_info ( struct audit_context * context , struct audit_buffer * * ab ) { int i , len ; size_t len_sent = 0 ; const char __user * p ; char * buf ; p = ( const char __user * ) current -> mm -> arg_start ; audit_log_format ( * ab , ""argc=%d"" , context -> execve . argc ) ; buf = kmalloc ( MAX_EXECVE_AUDIT_LEN + 1 , GFP_KERNEL ) ; if ( ! buf ) { audit_panic ( ""outofmemoryforargvstring"" ) ; return ; } for ( i = 0 ; i < context -> execve . argc ; i ++ ) { len = audit_log_single_execve_arg ( context , ab , i , & len_sent , p , buf ) ; if ( len <= 0 ) break ; p += len ; } kfree ( buf ) ; } "," ab ) { long len_max ; long len_rem ; long len_full ; long len_buf ; long len_abuf ; long len_tmp ; bool require_data ; bool encode ; unsigned int iter ; unsigned int arg ; char * buf_head ; char * buf ; const char char __user * p = ( -> arg_start ; char abuf [ 96 ] ; WARN_ON_ONCE ( MAX_EXECVE_AUDIT_LEN > 7500 ) ; len_max = MAX_EXECVE_AUDIT_LEN ; buf_head = kmalloc ( MAX_EXECVE_AUDIT_LEN + 1 , GFP_KERNEL ) ; if ( ! buf_head ) { audit_panic ( ""outofmemoryforargvstring"" ) ; return ; } buf = buf_head ; argc ) ; len_rem = len_max ; len_buf = 0 ; len_full = 0 ; require_data = true ; encode = false ; iter = 0 ; arg = 0 ; do { if ( len_full == 0 ) len_full = strnlen_user ( p , MAX_ARG_STRLEN ) - 1 ; if ( require_data ) { if ( buf != buf_head ) { memmove ( buf_head , buf , len_buf ) ; buf = buf_head ; } len_tmp = strncpy_from_user ( & buf_head [ len_buf ] , p , len_max - len_buf ) ; if ( len_tmp == - EFAULT ) { send_sig ( SIGKILL , current , 0 ) ; goto out ; } else if ( len_tmp == ( len_max - len_buf ) ) { require_data = true ; encode = true ; len_full = len_full * 2 ; p += len_tmp ; } else { require_data = false ; if ( ! encode ) encode = audit_string_contains_control ( buf , len_tmp ) ; if ( len_full < len_max ) len_full = ( encode ? len_tmp * 2 : len_tmp ) ; p += len_tmp + 1 ; } len_buf += len_tmp ; buf_head [ len_buf ] = '\\0' ; len_abuf = ( encode ? len_buf * 2 : len_buf + 2 ) ; } if ( len_buf > 0 ) { if ( ( sizeof ( abuf ) + 8 ) > len_rem ) { len_rem = len_max ; audit_log_end ( * ab ) ; * ab = audit_log_start ( context , GFP_KERNEL , AUDIT_EXECVE ) ; if if ( ! * ab ) goto out ; } len_tmp = 0 ; if ( require_data || ( iter > 0 ) || ( ( len_abuf + sizeof ( abuf ) ) > len_rem ) ) { if ( iter == 0 ) { len_tmp += snprintf ( & abuf [ len_tmp ] , sizeof ( abuf ) - len_tmp , ""a%d_len=%lu"" , arg , len_full ) ; } len_tmp += snprintf ( & abuf [ len_tmp ] , sizeof ( abuf ) - len_tmp , ""a%d[%d]="" , arg , iter ++ ) ; } else len_tmp += snprintf ( & abuf [ len_tmp ] , sizeof ( abuf ) - len_tmp , ""a%d="" , arg ) ; WARN_ON ( len_tmp >= sizeof ( abuf ) ) ; abuf [ sizeof ( abuf ) - 1 ] = '\\0' ; audit_log_format ( * ab , ""%s"" , abuf ) ; len_rem -= len_tmp ; len_tmp = len_buf ; if ( encode ) { if ( len_abuf > len_rem ) len_tmp = len_rem / 2 ; audit_log_n_hex ( * ab , buf , len_tmp ) ; len_rem -= len_tmp * 2 ; len_abuf -= len_tmp * 2 ; } else { if ( len_abuf > len_rem ) len_tmp = len_rem - 2 ; audit_log_n_string ( * ab , buf , len_tmp ) ; len_rem -= len_tmp + 2 ; len_abuf -= len_tmp ; } len_buf -= len_tmp ; buf += len_tmp ; } if ( ( len_buf == 0 ) && ! require_data ) { arg ++ ; iter = 0 ; len_full = 0 ; require_data = true ; encode = false ; } } while ( arg < context -> execve . argc ) ; out : kfree ( buf_head ) ; } ",torvalds@linux/43761473c254b45883a64441dd0bc85a42f3645c,CVE-2016-6136,https://github.com/torvalds/linux/commit/43761473c254b45883a64441dd0bc85a42f3645c,2016-08-06T20:59Z 1328,CWE-264,"CWE-264 int touch_file ( const char * path , bool parents , usec_t stamp , uid_t uid , gid_t gid , mode_t mode ) { _cleanup_close_ int fd ; int r ; assert ( path ) ; if ( parents ) mkdir_parents ( path , 0755 ) ; fd = open ( path , O_WRONLY | O_CREAT | O_CLOEXEC | O_NOCTTY , mode > 0 ? mode : 0644 ) ; if ( fd < 0 ) return - errno ; if ( mode != MODE_INVALID ) { r = fchmod ( fd , mode ) ; if ( r < 0 ) return - errno ; } if ( uid != UID_INVALID || gid != GID_INVALID ) { r = fchown ( fd , uid , gid ) ; if ( r < 0 ) return - errno ; } if ( stamp != USEC_INFINITY ) { struct timespec ts [ 2 ] ; timespec_store ( & ts [ 0 ] , stamp ) ; ts [ 1 ] = ts [ 0 ] ; r = futimens ( fd , ts ) ; } else r = futimens ( fd , NULL ) ; if ( r < 0 ) return - errno ; return 0 ; } "," | O_NOCTTY , ( mode == 0 || mode == MODE_INVALID ) ? 0644 : mode ) ; if ",systemd@systemd/06eeacb6fe029804f296b065b3ce91e796e1cd0e,CVE-2016-10156,https://github.com/systemd/systemd/commit/06eeacb6fe029804f296b065b3ce91e796e1cd0e,2017-01-23T07:59Z 1329,CWE-20,"CWE-20 static gboolean netscreen_seek_read ( wtap * wth , gint64 seek_off , struct wtap_pkthdr * phdr , Buffer * buf , int * err , gchar * * err_info ) { int pkt_len ; char line [ NETSCREEN_LINE_LENGTH ] ; char cap_int [ NETSCREEN_MAX_INT_NAME_LENGTH ] ; gboolean cap_dir ; char cap_dst [ 13 ] ; if ( file_seek ( wth -> random_fh , seek_off , SEEK_SET , err ) == - 1 ) { return FALSE ; } if ( file_gets ( line , NETSCREEN_LINE_LENGTH , wth -> random_fh ) == NULL ) { * err = file_error ( wth -> random_fh , err_info ) ; if ( * err == 0 ) { * err = WTAP_ERR_SHORT_READ ; } return FALSE ; } pkt_len = parse_netscreen_rec_hdr ( phdr , line , cap_int , & cap_dir , cap_dst , err , err_info ) ; if ( pkt_len == - 1 ) return FALSE ; if ( ! parse_netscreen_hex_dump ( wth -> random_fh , pkt_len , cap_int , cap_dst , phdr , buf , err , err_info ) ) return FALSE ; return TRUE ; } "," err_info ) { char line [ line [ NETSCREEN_LINE_LENGTH ] ; if FALSE ; } return parse_netscreen_packet ( wth -> random_fh , phdr , buf , line , , line , err , err_info err_info ) ; } ",wireshark@wireshark/6a140eca7b78b230f1f90a739a32257476513c78,CVE-2016-5357,https://github.com/wireshark/wireshark/commit/6a140eca7b78b230f1f90a739a32257476513c78,2016-08-07T16:59Z 1330,CWE-000,"CWE-000 inline void update_rq_clock ( struct rq * rq ) { if ( ! rq -> skip_clock_update ) { int cpu = cpu_of ( rq ) ; u64 irq_time ; rq -> clock = sched_clock_cpu ( cpu ) ; irq_time = irq_time_cpu ( cpu ) ; if ( rq -> clock - irq_time > rq -> clock_task ) rq -> clock_task = rq -> clock - irq_time ; sched_irq_time_avg_update ( rq , irq_time ) ; } } "," * rq ) { int cpu ; u64 irq_time ; if ( rq -> skip_clock_update ) return ) ; } ",torvalds@linux/f26f9aff6aaf67e9a430d16c266f91b13a5bff64,CVE-2011-4621,https://github.com/torvalds/linux/commit/f26f9aff6aaf67e9a430d16c266f91b13a5bff64,2012-05-17T11:00Z 1331,CWE-125,"CWE-125 static ssize_t DecodePSDPixels ( const size_t number_compact_pixels , const unsigned char * compact_pixels , const ssize_t depth , const size_t number_pixels , unsigned char * pixels ) { # define CheckNumberCompactPixels if ( packets == 0 ) return ( i ) ; packets -- # define CheckNumberPixels ( count ) if ( ( ( ssize_t ) i + count ) > ( ssize_t ) number_pixels ) return ( i ) ; i += count int pixel ; register ssize_t i , j ; size_t length ; ssize_t packets ; packets = ( ssize_t ) number_compact_pixels ; for ( i = 0 ; ( packets > 1 ) && ( i < ( ssize_t ) number_pixels ) ; ) { packets -- ; length = ( size_t ) ( * compact_pixels ++ ) ; if ( length == 128 ) continue ; if ( length > 128 ) { length = 256 - length + 1 ; CheckNumberCompactPixels ; pixel = ( * compact_pixels ++ ) ; for ( j = 0 ; j < ( ssize_t ) length ; j ++ ) { switch ( depth ) { case 1 : { CheckNumberPixels ( 8 ) ; * pixels ++ = ( pixel >> 7 ) & 0x01 ? 0U : 255U ; * pixels ++ = ( pixel >> 6 ) & 0x01 ? 0U : 255U ; * pixels ++ = ( pixel >> 5 ) & 0x01 ? 0U : 255U ; * pixels ++ = ( pixel >> 4 ) & 0x01 ? 0U : 255U ; * pixels ++ = ( pixel >> 3 ) & 0x01 ? 0U : 255U ; * pixels ++ = ( pixel >> 2 ) & 0x01 ? 0U : 255U ; * pixels ++ = ( pixel >> 1 ) & 0x01 ? 0U : 255U ; * pixels ++ = ( pixel >> 0 ) & 0x01 ? 0U : 255U ; break ; } case 2 : { CheckNumberPixels ( 4 ) ; * pixels ++ = ( unsigned char ) ( ( pixel >> 6 ) & 0x03 ) ; * pixels ++ = ( unsigned char ) ( ( pixel >> 4 ) & 0x03 ) ; * pixels ++ = ( unsigned char ) ( ( pixel >> 2 ) & 0x03 ) ; * pixels ++ = ( unsigned char ) ( ( pixel & 0x03 ) & 0x03 ) ; break ; } case 4 : { CheckNumberPixels ( 2 ) ; * pixels ++ = ( unsigned char ) ( ( pixel >> 4 ) & 0xff ) ; * pixels ++ = ( unsigned char ) ( ( pixel & 0x0f ) & 0xff ) ; break ; } default : { CheckNumberPixels ( 1 ) ; * pixels ++ = ( unsigned char ) pixel ; break ; } } } continue ; } length ++ ; for ( j = 0 ; j < ( ssize_t ) length ; j ++ ) { switch ( depth ) { case 1 : { CheckNumberPixels ( 8 ) ; * pixels ++ = ( * compact_pixels >> 7 ) & 0x01 ? 0U : 255U ; * pixels ++ = ( * compact_pixels >> 6 ) & 0x01 ? 0U : 255U ; * pixels ++ = ( * compact_pixels >> 5 ) & 0x01 ? 0U : 255U ; * pixels ++ = ( * compact_pixels >> 4 ) & 0x01 ? 0U : 255U ; * pixels ++ = ( * compact_pixels >> 3 ) & 0x01 ? 0U : 255U ; * pixels ++ = ( * compact_pixels >> 2 ) & 0x01 ? 0U : 255U ; * pixels ++ = ( * compact_pixels >> 1 ) & 0x01 ? 0U : 255U ; * pixels ++ = ( * compact_pixels >> 0 ) & 0x01 ? 0U : 255U ; break ; } case 2 : { CheckNumberPixels ( 4 ) ; * pixels ++ = ( * compact_pixels >> 6 ) & 0x03 ; * pixels ++ = ( * compact_pixels >> 4 ) & 0x03 ; * pixels ++ = ( * compact_pixels >> 2 ) & 0x03 ; * pixels ++ = ( * compact_pixels & 0x03 ) & 0x03 ; break ; } case 4 : { CheckNumberPixels ( 2 ) ; * pixels ++ = ( * compact_pixels >> 4 ) & 0xff ; * pixels ++ = ( * compact_pixels & 0x0f ) & 0xff ; break ; } default : { CheckNumberPixels ( 1 ) ; * pixels ++ = ( * compact_pixels ) ; break ; } } CheckNumberCompactPixels ; compact_pixels ++ ; } } return ( i ) ; } "," ++ ) { CheckNumberCompactPixels ; ; } } compact_pixels ++ ; ",ImageMagick@ImageMagick/30eec879c8b446b0ea9a3bb0da1a441cc8482bc4,CVE-2016-7521,https://github.com/ImageMagick/ImageMagick/commit/30eec879c8b446b0ea9a3bb0da1a441cc8482bc4,2017-04-20T18:59Z 1332,CWE-120,"CWE-120 static void process_options ( argc , argv ) int argc ; char * argv [ ] ; { int i , l ; while ( argc > 1 && argv [ 1 ] [ 0 ] == '-' ) { argv ++ ; argc -- ; l = ( int ) strlen ( * argv ) ; if ( l < 4 ) l = 4 ; switch ( argv [ 0 ] [ 1 ] ) { case 'D' : case 'd' : if ( ( argv [ 0 ] [ 1 ] == 'D' && ! argv [ 0 ] [ 2 ] ) || ! strcmpi ( * argv , ""-debug"" ) ) { wizard = TRUE , discover = FALSE ; } else if ( ! strncmpi ( * argv , ""-DECgraphics"" , l ) ) { load_symset ( ""DECGraphics"" , PRIMARY ) ; switch_symbols ( TRUE ) ; } else { raw_printf ( ""Unknownoption:%s"" , * argv ) ; } break ; case 'X' : discover = TRUE , wizard = FALSE ; break ; # ifdef NEWS case 'n' : iflags . news = FALSE ; break ; # endif case 'u' : if ( argv [ 0 ] [ 2 ] ) { ( void ) strncpy ( plname , argv [ 0 ] + 2 , sizeof plname - 1 ) ; } else if ( argc > 1 ) { argc -- ; argv ++ ; ( void ) strncpy ( plname , argv [ 0 ] , sizeof plname - 1 ) ; } else { raw_print ( ""Playernameexpectedafter-u"" ) ; } break ; case 'I' : case 'i' : if ( ! strncmpi ( * argv , ""-IBMgraphics"" , l ) ) { load_symset ( ""IBMGraphics"" , PRIMARY ) ; load_symset ( ""RogueIBM"" , ROGUESET ) ; switch_symbols ( TRUE ) ; } else { raw_printf ( ""Unknownoption:%s"" , * argv ) ; } break ; case 'p' : if ( argv [ 0 ] [ 2 ] ) { if ( ( i = str2role ( & argv [ 0 ] [ 2 ] ) ) >= 0 ) flags . initrole = i ; } else if ( argc > 1 ) { argc -- ; argv ++ ; if ( ( i = str2role ( argv [ 0 ] ) ) >= 0 ) flags . initrole = i ; } break ; case 'r' : if ( argv [ 0 ] [ 2 ] ) { if ( ( i = str2race ( & argv [ 0 ] [ 2 ] ) ) >= 0 ) flags . initrace = i ; } else if ( argc > 1 ) { argc -- ; argv ++ ; if ( ( i = str2race ( argv [ 0 ] ) ) >= 0 ) flags . initrace = i ; } break ; case 'w' : config_error_init ( FALSE , ""commandline"" , FALSE ) ; choose_windows ( & argv [ 0 ] [ 2 ] ) ; config_error_done ( ) ; break ; case '@' : flags . randomall = 1 ; break ; default : if ( ( i = str2role ( & argv [ 0 ] [ 1 ] ) ) >= 0 ) { flags . initrole = i ; break ; } } } # ifdef SYSCF if ( argc > 1 ) raw_printf ( ""MAXPLAYERSaresetinsysconffile.\\n"" ) ; # else if ( argc > 1 ) locknum = atoi ( argv [ 1 ] ) ; # endif # ifdef MAX_NR_OF_PLAYERS if ( ! locknum || locknum > MAX_NR_OF_PLAYERS ) locknum = MAX_NR_OF_PLAYERS ; # endif # ifdef SYSCF if ( ! locknum || ( sysopt . maxplayers && locknum > sysopt . maxplayers ) ) locknum = sysopt . maxplayers ; # endif } "," { raw_printf ( ""Unknownoption:%.60s"" , * argv { raw_printf ( ""Unknownoption:%.60s"" , * argv ",NetHack@NetHack/f3def5c0b999478da2d0a8f0b6a7c370a2065f77,CVE-2020-5210,https://github.com/NetHack/NetHack/commit/f3def5c0b999478da2d0a8f0b6a7c370a2065f77,2020-01-28T18:15Z 1333,CWE-200,"CWE-200 static void make_response ( struct xen_blkif_ring * ring , u64 id , unsigned short op , int st ) { struct blkif_response resp ; unsigned long flags ; union blkif_back_rings * blk_rings ; int notify ; resp . id = id ; resp . operation = op ; resp . status = st ; spin_lock_irqsave ( & ring -> blk_ring_lock , flags ) ; blk_rings = & ring -> blk_rings ; switch ( ring -> blkif -> blk_protocol ) { case BLKIF_PROTOCOL_NATIVE : memcpy ( RING_GET_RESPONSE ( & blk_rings -> native , blk_rings -> native . rsp_prod_pvt ) , & resp , sizeof ( resp ) ) ; break ; case BLKIF_PROTOCOL_X86_32 : memcpy ( RING_GET_RESPONSE ( & blk_rings -> x86_32 , blk_rings -> x86_32 . rsp_prod_pvt ) , & resp , sizeof ( resp ) ) ; break ; case BLKIF_PROTOCOL_X86_64 : memcpy ( RING_GET_RESPONSE ( & blk_rings -> x86_64 , blk_rings -> x86_64 . rsp_prod_pvt ) , & resp , sizeof ( resp ) ) ; break ; default : BUG ( ) ; } blk_rings -> common . rsp_prod_pvt ++ ; RING_PUSH_RESPONSES_AND_CHECK_NOTIFY ( & blk_rings -> common , notify ) ; spin_unlock_irqrestore ( & ring -> blk_ring_lock , flags ) ; if ( notify ) notify_remote_via_irq ( ring -> irq ) ; } "," { struct blkif_response * int notify ; spin_lock_irqsave ( & case BLKIF_PROTOCOL_NATIVE : resp = RING_GET_RESPONSE ( & native . rsp_prod_pvt ) ; break case BLKIF_PROTOCOL_X86_32 : resp = RING_GET_RESPONSE ( & x86_32 . rsp_prod_pvt ) ; break case BLKIF_PROTOCOL_X86_64 : resp = RING_GET_RESPONSE ( & . rsp_prod_pvt ) ; break ; ) ; } resp -> id = id ; resp -> operation = op ; resp -> status = st ; ",torvalds@linux/089bc0143f489bd3a4578bdff5f4ca68fb26f341,CVE-2017-10911,https://github.com/torvalds/linux/commit/089bc0143f489bd3a4578bdff5f4ca68fb26f341,2017-07-05T01:29Z 1334,CWE-000,"CWE-000 static void check_1_6_dummy ( kadm5_principal_ent_t entry , long mask , int n_ks_tuple , krb5_key_salt_tuple * ks_tuple , char * * passptr ) { int i ; char * password = * passptr ; if ( ! ( mask & KADM5_ATTRIBUTES ) || ! ( entry -> attributes & KRB5_KDB_DISALLOW_ALL_TIX ) ) return ; for ( i = 0 ; ( unsigned char ) password [ i ] == i + 1 ; i ++ ) ; if ( password [ i ] != '\\0' || i != 255 ) return ; * passptr = NULL ; } "," ; if ( password == NULL || ",krb5@krb5/c5be6209311d4a8f10fda37d0d3f876c1b33b77b,CVE-2012-1013,https://github.com/krb5/krb5/commit/c5be6209311d4a8f10fda37d0d3f876c1b33b77b,2012-06-07T19:55Z 1335,CWE-125,"CWE-125 static void exif_mnote_data_fuji_load ( ExifMnoteData * en , const unsigned char * buf , unsigned int buf_size ) { ExifMnoteDataFuji * n = ( ExifMnoteDataFuji * ) en ; ExifLong c ; size_t i , tcount , o , datao ; if ( ! n || ! buf || ! buf_size ) { exif_log ( en -> log , EXIF_LOG_CODE_CORRUPT_DATA , ""ExifMnoteDataFuji"" , ""ShortMakerNote"" ) ; return ; } datao = 6 + n -> offset ; if ( ( datao + 12 < datao ) || ( datao + 12 < 12 ) || ( datao + 12 > buf_size ) ) { exif_log ( en -> log , EXIF_LOG_CODE_CORRUPT_DATA , ""ExifMnoteDataFuji"" , ""ShortMakerNote"" ) ; return ; } n -> order = EXIF_BYTE_ORDER_INTEL ; datao += exif_get_long ( buf + datao + 8 , EXIF_BYTE_ORDER_INTEL ) ; if ( ( datao + 2 < datao ) || ( datao + 2 < 2 ) || ( datao + 2 > buf_size ) ) { exif_log ( en -> log , EXIF_LOG_CODE_CORRUPT_DATA , ""ExifMnoteDataFuji"" , ""ShortMakerNote"" ) ; return ; } c = exif_get_short ( buf + datao , EXIF_BYTE_ORDER_INTEL ) ; datao += 2 ; exif_mnote_data_fuji_clear ( n ) ; n -> entries = exif_mem_alloc ( en -> mem , sizeof ( MnoteFujiEntry ) * c ) ; if ( ! n -> entries ) { EXIF_LOG_NO_MEMORY ( en -> log , ""ExifMnoteDataFuji"" , sizeof ( MnoteFujiEntry ) * c ) ; return ; } tcount = 0 ; for ( i = c , o = datao ; i ; -- i , o += 12 ) { size_t s ; if ( ( o + 12 < o ) || ( o + 12 < 12 ) || ( o + 12 > buf_size ) ) { exif_log ( en -> log , EXIF_LOG_CODE_CORRUPT_DATA , ""ExifMnoteDataFuji"" , ""ShortMakerNote"" ) ; break ; } n -> entries [ tcount ] . tag = exif_get_short ( buf + o , n -> order ) ; n -> entries [ tcount ] . format = exif_get_short ( buf + o + 2 , n -> order ) ; n -> entries [ tcount ] . components = exif_get_long ( buf + o + 4 , n -> order ) ; n -> entries [ tcount ] . order = n -> order ; exif_log ( en -> log , EXIF_LOG_CODE_DEBUG , ""ExifMnoteDataFuji"" , ""Loadingentry0x%x(\'%s\')..."" , n -> entries [ tcount ] . tag , mnote_fuji_tag_get_name ( n -> entries [ tcount ] . tag ) ) ; s = exif_format_get_size ( n -> entries [ tcount ] . format ) * n -> entries [ tcount ] . components ; n -> entries [ tcount ] . size = s ; if ( s ) { size_t dataofs = o + 8 ; if ( s > 4 ) dataofs = exif_get_long ( buf + dataofs , n -> order ) + 6 + n -> offset ; if ( ( dataofs + s < dataofs ) || ( dataofs + s < s ) || ( dataofs + s >= buf_size ) ) { exif_log ( en -> log , EXIF_LOG_CODE_CORRUPT_DATA , ""ExifMnoteDataFuji"" , ""Tagdatapastendof"" ""buffer(%u>=%u)"" , ( unsigned ) ( dataofs + s ) , buf_size ) ; continue ; } n -> entries [ tcount ] . data = exif_mem_alloc ( en -> mem , s ) ; if ( ! n -> entries [ tcount ] . data ) { EXIF_LOG_NO_MEMORY ( en -> log , ""ExifMnoteDataFuji"" , s ) ; continue ; } memcpy ( n -> entries [ tcount ] . data , buf + dataofs , s ) ; } ++ tcount ; } n -> count = tcount ; } "," ; if ( CHECKOVERFLOW ( datao , buf_size , 12 ) ) { ; if ( CHECKOVERFLOW ( datao , buf_size , 2 ) ) { ; if ( CHECKOVERFLOW ( o , buf_size , 12 ) ) { exif_log ( en -> log , EXIF_LOG_CODE_CORRUPT_DATA , ""ExifMnoteDataFuji"" , ""ShortMakerNote"" ) ; break ; } n -> entries [ tcount ] . tag = exif_get_short ( buf + o , n -> order ) ; n -> entries [ tcount ] . format = exif_get_short ( buf + o + 2 , n -> order ) ; n -> entries [ tcount ] . components = exif_get_long ( buf + o + 4 , n -> order ) ; n -> entries [ tcount ] . order = n -> order ; exif_log ( en -> log , EXIF_LOG_CODE_DEBUG , ""ExifMnoteDataFuji"" , ""Loadingentry0x%x(\'%s\')..."" , n -> entries [ tcount ] . tag , mnote_fuji_tag_get_name ( n -> entries [ tcount ] . tag ) ) ; if ( exif_format_get_size ( n -> entries [ tcount ] . format ) && buf_size / exif_format_get_size ( n -> entries [ tcount ] . format ) < n -> entries [ tcount ] . components ) { exif_log , ""ExifMnoteDataFuji"" , ""Tagsizeoverflowdetected(%u*%lu)"" , exif_format_get_size ( n -> entries ] . format ) , n -> entries ] . components ) ; continue ; } s = exif_format_get_size ; if ( CHECKOVERFLOW ( dataofs , buf_size , s ) ) { exif_log ( en -> log , EXIF_LOG_CODE_CORRUPT_DATA , ""ExifMnoteDataFuji"" , ""Tagdatapastendof"" ""buffer(%u>=%u)"" , ( unsigned ) ( dataofs + s ) , buf_size ) ; continue ; } n -> entries [ tcount ] . data = exif_mem_alloc ( en -> mem , s ) ; if ( ! n -> entries [ tcount ] . data ) { EXIF_LOG_NO_MEMORY ( en -> log , ""ExifMnoteDataFuji"" , s ) ; continue ; } memcpy ( n -> entries [ tcount ] . data , buf + dataofs , s ) ",libexif@libexif/435e21f05001fb03f9f186fa7cbc69454afd00d1,CVE-2020-13112,https://github.com/libexif/libexif/commit/435e21f05001fb03f9f186fa7cbc69454afd00d1,2020-05-21T16:15Z 1336,CWE-119,"CWE-119 static l_int32 pixHtmlViewer ( const char * dirin , const char * dirout , const char * rootname , l_int32 thumbwidth , l_int32 viewwidth ) { char * fname , * fullname , * outname ; char * mainname , * linkname , * linknameshort ; char * viewfile , * thumbfile ; char * shtml , * slink ; char charbuf [ 512 ] ; char htmlstring [ ] = """" ; char framestring [ ] = """" ; l_int32 i , nfiles , index , w , d , nimages , ret ; l_float32 factor ; PIX * pix , * pixthumb , * pixview ; SARRAY * safiles , * sathumbs , * saviews , * sahtml , * salink ; PROCNAME ( ""pixHtmlViewer"" ) ; if ( ! dirin ) return ERROR_INT ( ""dirinnotdefined"" , procName , 1 ) ; if ( ! dirout ) return ERROR_INT ( ""diroutnotdefined"" , procName , 1 ) ; if ( ! rootname ) return ERROR_INT ( ""rootnamenotdefined"" , procName , 1 ) ; if ( thumbwidth == 0 ) thumbwidth = DEFAULT_THUMB_WIDTH ; if ( thumbwidth < MIN_THUMB_WIDTH ) { L_WARNING ( ""thumbwidthtoosmall;usingminvalue\\n"" , procName ) ; thumbwidth = MIN_THUMB_WIDTH ; } if ( viewwidth == 0 ) viewwidth = DEFAULT_VIEW_WIDTH ; if ( viewwidth < MIN_VIEW_WIDTH ) { L_WARNING ( ""viewwidthtoosmall;usingminvalue\\n"" , procName ) ; viewwidth = MIN_VIEW_WIDTH ; } # ifndef _WIN32 snprintf ( charbuf , sizeof ( charbuf ) , ""mkdir-p%s"" , dirout ) ; ret = system ( charbuf ) ; # else ret = CreateDirectory ( dirout , NULL ) ? 0 : 1 ; # endif if ( ret ) { L_ERROR ( ""outputdirectory%snotmade\\n"" , procName , dirout ) ; return 1 ; } if ( ( safiles = getFilenamesInDirectory ( dirin ) ) == NULL ) return ERROR_INT ( ""safilesnotmade"" , procName , 1 ) ; sprintf ( charbuf , ""%s/%s.html"" , dirout , rootname ) ; mainname = stringNew ( charbuf ) ; sprintf ( charbuf , ""%s/%s-links.html"" , dirout , rootname ) ; linkname = stringNew ( charbuf ) ; linknameshort = stringJoin ( rootname , ""-links.html"" ) ; sathumbs = sarrayCreate ( 0 ) ; saviews = sarrayCreate ( 0 ) ; nfiles = sarrayGetCount ( safiles ) ; index = 0 ; for ( i = 0 ; i < nfiles ; i ++ ) { fname = sarrayGetString ( safiles , i , L_NOCOPY ) ; fullname = genPathname ( dirin , fname ) ; fprintf ( stderr , ""name:%s\\n"" , fullname ) ; if ( ( pix = pixRead ( fullname ) ) == NULL ) { fprintf ( stderr , ""file%snotareadableimage\\n"" , fullname ) ; lept_free ( fullname ) ; continue ; } lept_free ( fullname ) ; pixGetDimensions ( pix , & w , NULL , & d ) ; factor = ( l_float32 ) thumbwidth / ( l_float32 ) w ; pixthumb = pixScale ( pix , factor , factor ) ; sprintf ( charbuf , ""%s_thumb_%03d"" , rootname , index ) ; sarrayAddString ( sathumbs , charbuf , L_COPY ) ; outname = genPathname ( dirout , charbuf ) ; WriteFormattedPix ( outname , pixthumb ) ; lept_free ( outname ) ; pixDestroy ( & pixthumb ) ; factor = ( l_float32 ) viewwidth / ( l_float32 ) w ; if ( factor >= 1.0 ) pixview = pixClone ( pix ) ; else pixview = pixScale ( pix , factor , factor ) ; snprintf ( charbuf , sizeof ( charbuf ) , ""%s_view_%03d"" , rootname , index ) ; sarrayAddString ( saviews , charbuf , L_COPY ) ; outname = genPathname ( dirout , charbuf ) ; WriteFormattedPix ( outname , pixview ) ; lept_free ( outname ) ; pixDestroy ( & pixview ) ; pixDestroy ( & pix ) ; index ++ ; } sahtml = sarrayCreate ( 0 ) ; sarrayAddString ( sahtml , htmlstring , L_COPY ) ; sprintf ( charbuf , ""cols=\\""%d,*\\"">"" , thumbwidth + 30 ) ; sarrayAddString ( sahtml , charbuf , L_COPY ) ; sprintf ( charbuf , ""name=\\""thumbs\\""src=\\""%s\\"">"" , linknameshort ) ; sarrayAddString ( sahtml , charbuf , L_COPY ) ; sprintf ( charbuf , ""name=\\""views\\""src=\\""%s\\"">"" , sarrayGetString ( saviews , 0 , L_NOCOPY ) ) ; sarrayAddString ( sahtml , charbuf , L_COPY ) ; sarrayAddString ( sahtml , framestring , L_COPY ) ; shtml = sarrayToString ( sahtml , 1 ) ; l_binaryWrite ( mainname , ""w"" , shtml , strlen ( shtml ) ) ; fprintf ( stderr , ""******************************************\\n"" ""Writinghtmlfile:%s\\n"" ""******************************************\\n"" , mainname ) ; lept_free ( shtml ) ; lept_free ( mainname ) ; nimages = sarrayGetCount ( saviews ) ; fprintf ( stderr , ""num.images=%d\\n"" , nimages ) ; salink = sarrayCreate ( 0 ) ; for ( i = 0 ; i < nimages ; i ++ ) { viewfile = sarrayGetString ( saviews , i , L_NOCOPY ) ; thumbfile = sarrayGetString ( sathumbs , i , L_NOCOPY ) ; sprintf ( charbuf , ""href=\\""%s\\""TARGET=views>src=\\""%s\\"">"" , viewfile , thumbfile ) ; sarrayAddString ( salink , charbuf , L_COPY ) ; } slink = sarrayToString ( salink , 1 ) ; l_binaryWrite ( linkname , ""w"" , slink , strlen ( slink ) ) ; lept_free ( slink ) ; lept_free ( linkname ) ; lept_free ( linknameshort ) ; sarrayDestroy ( & safiles ) ; sarrayDestroy ( & sathumbs ) ; sarrayDestroy ( & saviews ) ; sarrayDestroy ( & sahtml ) ; sarrayDestroy ( & salink ) ; return 0 ; } "," 1 ) ; snprintf ( charbuf , sizeof ( charbuf ) , ""%s/%s.html"" , charbuf ) ; snprintf ( charbuf , sizeof ( charbuf ) , ""%s/%s-links.html"" , factor ) ; snprintf ( charbuf , sizeof ( charbuf ) , ""%s_thumb_%03d"" , ",DanBloomberg@leptonica/c1079bb8e77cdd426759e466729917ca37a3ed9f,CVE-2018-7247,https://github.com/DanBloomberg/leptonica/commit/c1079bb8e77cdd426759e466729917ca37a3ed9f,2018-02-19T18:29Z 1337,CWE-125,"CWE-125 void icmp_print ( netdissect_options * ndo , const u_char * bp , u_int plen , const u_char * bp2 , int fragmented ) { char * cp ; const struct icmp * dp ; const struct icmp_ext_t * ext_dp ; const struct ip * ip ; const char * str , * fmt ; const struct ip * oip ; const struct udphdr * ouh ; const uint8_t * obj_tptr ; uint32_t raw_label ; const u_char * snapend_save ; const struct icmp_mpls_ext_object_header_t * icmp_mpls_ext_object_header ; u_int hlen , dport , mtu , obj_tlen , obj_class_num , obj_ctype ; char buf [ MAXHOSTNAMELEN + 100 ] ; struct cksum_vec vec [ 1 ] ; dp = ( const struct icmp * ) bp ; ext_dp = ( const struct icmp_ext_t * ) bp ; ip = ( const struct ip * ) bp2 ; str = buf ; ND_TCHECK ( dp -> icmp_code ) ; switch ( dp -> icmp_type ) { case ICMP_ECHO : case ICMP_ECHOREPLY : ND_TCHECK ( dp -> icmp_seq ) ; ( void ) snprintf ( buf , sizeof ( buf ) , ""echo%s,id%u,seq%u"" , dp -> icmp_type == ICMP_ECHO ? ""request"" : ""reply"" , EXTRACT_16BITS ( & dp -> icmp_id ) , EXTRACT_16BITS ( & dp -> icmp_seq ) ) ; break ; case ICMP_UNREACH : ND_TCHECK ( dp -> icmp_ip . ip_dst ) ; switch ( dp -> icmp_code ) { case ICMP_UNREACH_PROTOCOL : ND_TCHECK ( dp -> icmp_ip . ip_p ) ; ( void ) snprintf ( buf , sizeof ( buf ) , ""%sprotocol%dunreachable"" , ipaddr_string ( ndo , & dp -> icmp_ip . ip_dst ) , dp -> icmp_ip . ip_p ) ; break ; case ICMP_UNREACH_PORT : ND_TCHECK ( dp -> icmp_ip . ip_p ) ; oip = & dp -> icmp_ip ; hlen = IP_HL ( oip ) * 4 ; ouh = ( const struct udphdr * ) ( ( ( const u_char * ) oip ) + hlen ) ; ND_TCHECK ( ouh -> uh_dport ) ; dport = EXTRACT_16BITS ( & ouh -> uh_dport ) ; switch ( oip -> ip_p ) { case IPPROTO_TCP : ( void ) snprintf ( buf , sizeof ( buf ) , ""%stcpport%sunreachable"" , ipaddr_string ( ndo , & oip -> ip_dst ) , tcpport_string ( ndo , dport ) ) ; break ; case IPPROTO_UDP : ( void ) snprintf ( buf , sizeof ( buf ) , ""%sudpport%sunreachable"" , ipaddr_string ( ndo , & oip -> ip_dst ) , udpport_string ( ndo , dport ) ) ; break ; default : ( void ) snprintf ( buf , sizeof ( buf ) , ""%sprotocol%dport%dunreachable"" , ipaddr_string ( ndo , & oip -> ip_dst ) , oip -> ip_p , dport ) ; break ; } break ; case ICMP_UNREACH_NEEDFRAG : { register const struct mtu_discovery * mp ; mp = ( const struct mtu_discovery * ) ( const u_char * ) & dp -> icmp_void ; mtu = EXTRACT_16BITS ( & mp -> nexthopmtu ) ; if ( mtu ) { ( void ) snprintf ( buf , sizeof ( buf ) , ""%sunreachable-needtofrag(mtu%d)"" , ipaddr_string ( ndo , & dp -> icmp_ip . ip_dst ) , mtu ) ; } else { ( void ) snprintf ( buf , sizeof ( buf ) , ""%sunreachable-needtofrag"" , ipaddr_string ( ndo , & dp -> icmp_ip . ip_dst ) ) ; } } break ; default : fmt = tok2str ( unreach2str , ""#%d%%sunreachable"" , dp -> icmp_code ) ; ( void ) snprintf ( buf , sizeof ( buf ) , fmt , ipaddr_string ( ndo , & dp -> icmp_ip . ip_dst ) ) ; break ; } break ; case ICMP_REDIRECT : ND_TCHECK ( dp -> icmp_ip . ip_dst ) ; fmt = tok2str ( type2str , ""redirect-#%d%%stonet%%s"" , dp -> icmp_code ) ; ( void ) snprintf ( buf , sizeof ( buf ) , fmt , ipaddr_string ( ndo , & dp -> icmp_ip . ip_dst ) , ipaddr_string ( ndo , & dp -> icmp_gwaddr ) ) ; break ; case ICMP_ROUTERADVERT : { register const struct ih_rdiscovery * ihp ; register const struct id_rdiscovery * idp ; u_int lifetime , num , size ; ( void ) snprintf ( buf , sizeof ( buf ) , ""routeradvertisement"" ) ; cp = buf + strlen ( buf ) ; ihp = ( const struct ih_rdiscovery * ) & dp -> icmp_void ; ND_TCHECK ( * ihp ) ; ( void ) strncpy ( cp , ""lifetime"" , sizeof ( buf ) - ( cp - buf ) ) ; cp = buf + strlen ( buf ) ; lifetime = EXTRACT_16BITS ( & ihp -> ird_lifetime ) ; if ( lifetime < 60 ) { ( void ) snprintf ( cp , sizeof ( buf ) - ( cp - buf ) , ""%u"" , lifetime ) ; } else if ( lifetime < 60 * 60 ) { ( void ) snprintf ( cp , sizeof ( buf ) - ( cp - buf ) , ""%u:%02u"" , lifetime / 60 , lifetime % 60 ) ; } else { ( void ) snprintf ( cp , sizeof ( buf ) - ( cp - buf ) , ""%u:%02u:%02u"" , lifetime / 3600 , ( lifetime % 3600 ) / 60 , lifetime % 60 ) ; } cp = buf + strlen ( buf ) ; num = ihp -> ird_addrnum ; ( void ) snprintf ( cp , sizeof ( buf ) - ( cp - buf ) , ""%d:"" , num ) ; cp = buf + strlen ( buf ) ; size = ihp -> ird_addrsiz ; if ( size != 2 ) { ( void ) snprintf ( cp , sizeof ( buf ) - ( cp - buf ) , ""[size%d]"" , size ) ; break ; } idp = ( const struct id_rdiscovery * ) & dp -> icmp_data ; while ( num -- > 0 ) { ND_TCHECK ( * idp ) ; ( void ) snprintf ( cp , sizeof ( buf ) - ( cp - buf ) , ""{%s%u}"" , ipaddr_string ( ndo , & idp -> ird_addr ) , EXTRACT_32BITS ( & idp -> ird_pref ) ) ; cp = buf + strlen ( buf ) ; ++ idp ; } } break ; case ICMP_TIMXCEED : ND_TCHECK ( dp -> icmp_ip . ip_dst ) ; switch ( dp -> icmp_code ) { case ICMP_TIMXCEED_INTRANS : str = ""timeexceededin-transit"" ; break ; case ICMP_TIMXCEED_REASS : str = ""ipreassemblytimeexceeded"" ; break ; default : ( void ) snprintf ( buf , sizeof ( buf ) , ""timeexceeded-#%d"" , dp -> icmp_code ) ; break ; } break ; case ICMP_PARAMPROB : if ( dp -> icmp_code ) ( void ) snprintf ( buf , sizeof ( buf ) , ""parameterproblem-code%d"" , dp -> icmp_code ) ; else { ND_TCHECK ( dp -> icmp_pptr ) ; ( void ) snprintf ( buf , sizeof ( buf ) , ""parameterproblem-octet%d"" , dp -> icmp_pptr ) ; } break ; case ICMP_MASKREPLY : ND_TCHECK ( dp -> icmp_mask ) ; ( void ) snprintf ( buf , sizeof ( buf ) , ""addressmaskis0x%08x"" , EXTRACT_32BITS ( & dp -> icmp_mask ) ) ; break ; case ICMP_TSTAMP : ND_TCHECK ( dp -> icmp_seq ) ; ( void ) snprintf ( buf , sizeof ( buf ) , ""timestampqueryid%useq%u"" , EXTRACT_16BITS ( & dp -> icmp_id ) , EXTRACT_16BITS ( & dp -> icmp_seq ) ) ; break ; case ICMP_TSTAMPREPLY : ND_TCHECK ( dp -> icmp_ttime ) ; ( void ) snprintf ( buf , sizeof ( buf ) , ""timestampreplyid%useq%u:org%s"" , EXTRACT_16BITS ( & dp -> icmp_id ) , EXTRACT_16BITS ( & dp -> icmp_seq ) , icmp_tstamp_print ( EXTRACT_32BITS ( & dp -> icmp_otime ) ) ) ; ( void ) snprintf ( buf + strlen ( buf ) , sizeof ( buf ) - strlen ( buf ) , "",recv%s"" , icmp_tstamp_print ( EXTRACT_32BITS ( & dp -> icmp_rtime ) ) ) ; ( void ) snprintf ( buf + strlen ( buf ) , sizeof ( buf ) - strlen ( buf ) , "",xmit%s"" , icmp_tstamp_print ( EXTRACT_32BITS ( & dp -> icmp_ttime ) ) ) ; break ; default : str = tok2str ( icmp2str , ""type-#%d"" , dp -> icmp_type ) ; break ; } ND_PRINT ( ( ndo , ""ICMP%s,length%u"" , str , plen ) ) ; if ( ndo -> ndo_vflag && ! fragmented ) { uint16_t sum , icmp_sum ; if ( ND_TTEST2 ( * bp , plen ) ) { vec [ 0 ] . ptr = ( const uint8_t * ) ( const void * ) dp ; vec [ 0 ] . len = plen ; sum = in_cksum ( vec , 1 ) ; if ( sum != 0 ) { icmp_sum = EXTRACT_16BITS ( & dp -> icmp_cksum ) ; ND_PRINT ( ( ndo , ""(wrongicmpcksum%x(->%x)!)"" , icmp_sum , in_cksum_shouldbe ( icmp_sum , sum ) ) ) ; } } } if ( ndo -> ndo_vflag >= 1 && ICMP_ERRTYPE ( dp -> icmp_type ) ) { bp += 8 ; ND_PRINT ( ( ndo , ""\\n\\t"" ) ) ; ip = ( const struct ip * ) bp ; snapend_save = ndo -> ndo_snapend ; ip_print ( ndo , bp , EXTRACT_16BITS ( & ip -> ip_len ) ) ; ndo -> ndo_snapend = snapend_save ; } if ( ndo -> ndo_vflag >= 1 && plen > ICMP_EXTD_MINLEN && ICMP_MPLS_EXT_TYPE ( dp -> icmp_type ) ) { ND_TCHECK ( * ext_dp ) ; if ( ! ext_dp -> icmp_length && ND_TTEST2 ( ext_dp -> icmp_ext_version_res , plen - ICMP_EXTD_MINLEN ) ) { vec [ 0 ] . ptr = ( const uint8_t * ) ( const void * ) & ext_dp -> icmp_ext_version_res ; vec [ 0 ] . len = plen - ICMP_EXTD_MINLEN ; if ( in_cksum ( vec , 1 ) ) { return ; } } ND_PRINT ( ( ndo , ""\\n\\tMPLSextensionv%u"" , ICMP_MPLS_EXT_EXTRACT_VERSION ( * ( ext_dp -> icmp_ext_version_res ) ) ) ) ; if ( ICMP_MPLS_EXT_EXTRACT_VERSION ( * ( ext_dp -> icmp_ext_version_res ) ) != ICMP_MPLS_EXT_VERSION ) { ND_PRINT ( ( ndo , ""packetnotsupported"" ) ) ; return ; } hlen = plen - ICMP_EXTD_MINLEN ; if ( ND_TTEST2 ( ext_dp -> icmp_ext_version_res , hlen ) ) { vec [ 0 ] . ptr = ( const uint8_t * ) ( const void * ) & ext_dp -> icmp_ext_version_res ; vec [ 0 ] . len = hlen ; ND_PRINT ( ( ndo , "",checksum0x%04x(%scorrect),length%u"" , EXTRACT_16BITS ( ext_dp -> icmp_ext_checksum ) , in_cksum ( vec , 1 ) ? ""in"" : """" , hlen ) ) ; } hlen -= 4 ; obj_tptr = ( const uint8_t * ) ext_dp -> icmp_ext_data ; while ( hlen > sizeof ( struct icmp_mpls_ext_object_header_t ) ) { icmp_mpls_ext_object_header = ( const struct icmp_mpls_ext_object_header_t * ) obj_tptr ; ND_TCHECK ( * icmp_mpls_ext_object_header ) ; obj_tlen = EXTRACT_16BITS ( icmp_mpls_ext_object_header -> length ) ; obj_class_num = icmp_mpls_ext_object_header -> class_num ; obj_ctype = icmp_mpls_ext_object_header -> ctype ; obj_tptr += sizeof ( struct icmp_mpls_ext_object_header_t ) ; ND_PRINT ( ( ndo , ""\\n\\t%sObject(%u),Class-Type:%u,length%u"" , tok2str ( icmp_mpls_ext_obj_values , ""unknown"" , obj_class_num ) , obj_class_num , obj_ctype , obj_tlen ) ) ; hlen -= sizeof ( struct icmp_mpls_ext_object_header_t ) ; if ( ( obj_class_num == 0 ) || ( obj_tlen < sizeof ( struct icmp_mpls_ext_object_header_t ) ) ) { return ; } obj_tlen -= sizeof ( struct icmp_mpls_ext_object_header_t ) ; switch ( obj_class_num ) { case 1 : switch ( obj_ctype ) { case 1 : ND_TCHECK2 ( * obj_tptr , 4 ) ; raw_label = EXTRACT_32BITS ( obj_tptr ) ; ND_PRINT ( ( ndo , ""\\n\\tlabel%u,exp%u"" , MPLS_LABEL ( raw_label ) , MPLS_EXP ( raw_label ) ) ) ; if ( MPLS_STACK ( raw_label ) ) ND_PRINT ( ( ndo , "",[S]"" ) ) ; ND_PRINT ( ( ndo , "",ttl%u"" , MPLS_TTL ( raw_label ) ) ) ; break ; default : print_unknown_data ( ndo , obj_tptr , ""\\n\\t"" , obj_tlen ) ; } break ; case 2 : default : print_unknown_data ( ndo , obj_tptr , ""\\n\\t"" , obj_tlen ) ; break ; } if ( hlen < obj_tlen ) break ; hlen -= obj_tlen ; obj_tptr += obj_tlen ; } } return ; trunc : ND_PRINT ( ( ndo , ""[|icmp]"" ) ) ; } "," ndo -> ndo_snapend ; ND_TCHECK_16BITS ( & ip -> ip_len ) ",the-tcpdump-group@tcpdump/8509ef02eceb2bbb479cea10fe4a7ec6395f1a8b,CVE-2017-13012,https://github.com/the-tcpdump-group/tcpdump/commit/8509ef02eceb2bbb479cea10fe4a7ec6395f1a8b,2017-09-14T06:29Z 1338,CWE-416,"CWE-416 static int fscrypt_d_revalidate ( struct dentry * dentry , unsigned int flags ) { struct dentry * dir ; struct fscrypt_info * ci ; int dir_has_key , cached_with_key ; if ( flags & LOOKUP_RCU ) return - ECHILD ; dir = dget_parent ( dentry ) ; if ( ! d_inode ( dir ) -> i_sb -> s_cop -> is_encrypted ( d_inode ( dir ) ) ) { dput ( dir ) ; return 0 ; } ci = d_inode ( dir ) -> i_crypt_info ; if ( ci && ci -> ci_keyring_key && ( ci -> ci_keyring_key -> flags & ( ( 1 << KEY_FLAG_INVALIDATED ) | ( 1 << KEY_FLAG_REVOKED ) | ( 1 << KEY_FLAG_DEAD ) ) ) ) ci = NULL ; spin_lock ( & dentry -> d_lock ) ; cached_with_key = dentry -> d_flags & DCACHE_ENCRYPTED_WITH_KEY ; spin_unlock ( & dentry -> d_lock ) ; dir_has_key = ( ci != NULL ) ; dput ( dir ) ; if ( ( ! cached_with_key && d_is_negative ( dentry ) ) || ( ! cached_with_key && dir_has_key ) || ( cached_with_key && ! dir_has_key ) ) return 0 ; return 1 ; } "," dentry * dir ; int dir_has_key 0 ; } spin_lock ( & dir_has_key = ( d_inode ( dir ) -> i_crypt_info != NULL ) ",torvalds@linux/1b53cf9815bb4744958d41f3795d5d5a1d365e2d,CVE-2017-7374,https://github.com/torvalds/linux/commit/1b53cf9815bb4744958d41f3795d5d5a1d365e2d,2017-03-31T20:59Z 1339,CWE-295,"CWE-295 void unbind_ports ( void ) { SERVICE_OPTIONS * opt ; s_poll_init ( fds , 1 ) ; CRYPTO_THREAD_write_lock ( stunnel_locks [ LOCK_SECTIONS ] ) ; opt = service_options . next ; service_options . next = NULL ; service_free ( & service_options ) ; while ( opt ) { unsigned i ; s_log ( LOG_DEBUG , ""Unbindingservice[%s]"" , opt -> servname ) ; for ( i = 0 ; i < opt -> local_addr . num ; ++ i ) unbind_port ( opt , i ) ; if ( opt -> exec_name && opt -> connect_addr . names ) { opt -> option . retry = 0 ; } if ( opt -> ctx ) SSL_CTX_flush_sessions ( opt -> ctx , ( long ) time ( NULL ) + opt -> session_timeout + 1 ) ; s_log ( LOG_DEBUG , ""Service[%s]closed"" , opt -> servname ) ; { SERVICE_OPTIONS * garbage = opt ; opt = opt -> next ; garbage -> next = NULL ; service_free ( garbage ) ; } } CRYPTO_THREAD_unlock ( stunnel_locks [ LOCK_SECTIONS ] ) ; } "," NOEXPORT 1 ) ; for ( opt = service_options . next ; opt ; opt = opt -> next ) { unsigned 0 ; } s_log ( LOG_DEBUG servname ) ; } } ",mtrojnar@stunnel/ebad9ddc4efb2635f37174c9d800d06206f1edf9,CVE-2021-20230,https://github.com/mtrojnar/stunnel/commit/ebad9ddc4efb2635f37174c9d800d06206f1edf9,2021-02-23T17:15Z 1340,CWE-119,"CWE-119 static int parse_device ( dev_t * pdev , struct archive * a , char * val ) { # define MAX_PACK_ARGS 3 unsigned long numbers [ MAX_PACK_ARGS ] ; char * p , * dev ; int argc ; pack_t * pack ; dev_t result ; const char * error = NULL ; memset ( pdev , 0 , sizeof ( * pdev ) ) ; if ( ( dev = strchr ( val , ',' ) ) != NULL ) { * dev ++ = '\\0' ; if ( ( pack = pack_find ( val ) ) == NULL ) { archive_set_error ( a , ARCHIVE_ERRNO_FILE_FORMAT , ""Unknownformat`%s\'"" , val ) ; return ARCHIVE_WARN ; } argc = 0 ; while ( ( p = la_strsep ( & dev , "","" ) ) != NULL ) { if ( * p == '\\0' ) { archive_set_error ( a , ARCHIVE_ERRNO_FILE_FORMAT , ""Missingnumber"" ) ; return ARCHIVE_WARN ; } numbers [ argc ++ ] = ( unsigned long ) mtree_atol ( & p ) ; if ( argc > MAX_PACK_ARGS ) { archive_set_error ( a , ARCHIVE_ERRNO_FILE_FORMAT , ""Toomanyarguments"" ) ; return ARCHIVE_WARN ; } } if ( argc < 2 ) { archive_set_error ( a , ARCHIVE_ERRNO_FILE_FORMAT , ""Notenougharguments"" ) ; return ARCHIVE_WARN ; } result = ( * pack ) ( argc , numbers , & error ) ; if ( error != NULL ) { archive_set_error ( a , ARCHIVE_ERRNO_FILE_FORMAT , ""%s"" , error ) ; return ARCHIVE_WARN ; } } else { result = ( dev_t ) mtree_atol ( & val ) ; } * pdev = result ; return ARCHIVE_OK ; # undef MAX_PACK_ARGS } "," ARCHIVE_WARN ; } if ( argc >= MAX_PACK_ARGS ) { archive_set_error ( a , ARCHIVE_ERRNO_FILE_FORMAT , ""Toomanyarguments"" ) ; return ARCHIVE_WARN ; } p ) ; } if ( ",libarchive@libarchive/a550daeecf6bc689ade371349892ea17b5b97c77,CVE-2016-4301,https://github.com/libarchive/libarchive/commit/a550daeecf6bc689ade371349892ea17b5b97c77,2016-09-21T14:25Z 1341,CWE-119,"CWE-119 static int DecodeGifImg ( struct ngiflib_img * i ) { struct ngiflib_decode_context context ; long npix ; u8 * stackp ; u8 * stack_top ; u16 clr ; u16 eof ; u16 free ; u16 act_code = 0 ; u16 old_code = 0 ; u16 read_byt ; u16 ab_prfx [ 4096 ] ; u8 ab_suffx [ 4096 ] ; u8 ab_stack [ 4096 ] ; u8 flags ; u8 casspecial = 0 ; if ( ! i ) return - 1 ; i -> posX = GetWord ( i -> parent ) ; i -> posY = GetWord ( i -> parent ) ; i -> width = GetWord ( i -> parent ) ; i -> height = GetWord ( i -> parent ) ; context . Xtogo = i -> width ; context . curY = i -> posY ; # ifdef NGIFLIB_INDEXED_ONLY # ifdef NGIFLIB_ENABLE_CALLBACKS context . line_p . p8 = i -> parent -> frbuff . p8 + ( u32 ) i -> posY * i -> parent -> width ; context . frbuff_p . p8 = context . line_p . p8 + i -> posX ; # else context . frbuff_p . p8 = i -> parent -> frbuff . p8 + ( u32 ) i -> posY * i -> parent -> width + i -> posX ; # endif # else if ( i -> parent -> mode & NGIFLIB_MODE_INDEXED ) { # ifdef NGIFLIB_ENABLE_CALLBACKS context . line_p . p8 = i -> parent -> frbuff . p8 + ( u32 ) i -> posY * i -> parent -> width ; context . frbuff_p . p8 = context . line_p . p8 + i -> posX ; # else context . frbuff_p . p8 = i -> parent -> frbuff . p8 + ( u32 ) i -> posY * i -> parent -> width + i -> posX ; # endif } else { # ifdef NGIFLIB_ENABLE_CALLBACKS context . line_p . p32 = i -> parent -> frbuff . p32 + ( u32 ) i -> posY * i -> parent -> width ; context . frbuff_p . p32 = context . line_p . p32 + i -> posX ; # else context . frbuff_p . p32 = i -> parent -> frbuff . p32 + ( u32 ) i -> posY * i -> parent -> width + i -> posX ; # endif } # endif npix = ( long ) i -> width * i -> height ; flags = GetByte ( i -> parent ) ; i -> interlaced = ( flags & 64 ) >> 6 ; context . pass = i -> interlaced ? 1 : 0 ; i -> sort_flag = ( flags & 32 ) >> 5 ; i -> localpalbits = ( flags & 7 ) + 1 ; if ( flags & 128 ) { int k ; int localpalsize = 1 << i -> localpalbits ; # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent && i -> parent -> log ) fprintf ( i -> parent -> log , ""Localpalette\\n"" ) ; # endif i -> palette = ( struct ngiflib_rgb * ) ngiflib_malloc ( sizeof ( struct ngiflib_rgb ) * localpalsize ) ; for ( k = 0 ; k < localpalsize ; k ++ ) { i -> palette [ k ] . r = GetByte ( i -> parent ) ; i -> palette [ k ] . g = GetByte ( i -> parent ) ; i -> palette [ k ] . b = GetByte ( i -> parent ) ; } # ifdef NGIFLIB_ENABLE_CALLBACKS if ( i -> parent -> palette_cb ) i -> parent -> palette_cb ( i -> parent , i -> palette , localpalsize ) ; # endif } else { i -> palette = i -> parent -> palette ; i -> localpalbits = i -> parent -> imgbits ; } i -> ncolors = 1 << i -> localpalbits ; i -> imgbits = GetByte ( i -> parent ) ; # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent && i -> parent -> log ) { if ( i -> interlaced ) fprintf ( i -> parent -> log , ""interlaced"" ) ; fprintf ( i -> parent -> log , ""imgpos(%hu,%hu)size%hux%hupalbits=%hhuimgbits=%hhuncolors=%hu\\n"" , i -> posX , i -> posY , i -> width , i -> height , i -> localpalbits , i -> imgbits , i -> ncolors ) ; } # endif if ( i -> imgbits == 1 ) { i -> imgbits = 2 ; } clr = 1 << i -> imgbits ; eof = clr + 1 ; free = clr + 2 ; context . nbbit = i -> imgbits + 1 ; context . max = clr + clr - 1 ; stackp = stack_top = ab_stack + 4096 ; context . restbits = 0 ; context . restbyte = 0 ; context . lbyte = 0 ; for ( ; ; ) { act_code = GetGifWord ( i , & context ) ; if ( act_code == eof ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent && i -> parent -> log ) fprintf ( i -> parent -> log , ""Endofimagecode\\n"" ) ; # endif return 0 ; } if ( npix == 0 ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent && i -> parent -> log ) fprintf ( i -> parent -> log , ""assezdepixels,Onsecasse!\\n"" ) ; # endif return 1 ; } if ( act_code == clr ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent && i -> parent -> log ) fprintf ( i -> parent -> log , ""Codeclear(free=%hu)npix=%ld\\n"" , free , npix ) ; # endif free = clr + 2 ; context . nbbit = i -> imgbits + 1 ; context . max = clr + clr - 1 ; act_code = GetGifWord ( i , & context ) ; casspecial = ( u8 ) act_code ; old_code = act_code ; WritePixel ( i , & context , casspecial ) ; npix -- ; } else { read_byt = act_code ; if ( act_code >= free ) { * ( -- stackp ) = casspecial ; act_code = old_code ; } while ( act_code > clr ) { * ( -- stackp ) = ab_suffx [ act_code ] ; act_code = ab_prfx [ act_code ] ; } casspecial = ( u8 ) act_code ; * ( -- stackp ) = casspecial ; WritePixels ( i , & context , stackp , stack_top - stackp ) ; npix -= ( stack_top - stackp ) ; stackp = stack_top ; if ( free < 4096 ) { ab_prfx [ free ] = old_code ; ab_suffx [ free ] = ( u8 ) act_code ; free ++ ; if ( ( free > context . max ) && ( context . nbbit < 12 ) ) { context . nbbit ++ ; context . max += context . max + 1 ; } } old_code = read_byt ; } } return 0 ; } "," parent ) ; if ( ( i -> width > i -> parent -> width ) || ( i -> height > i -> parent -> height ) ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent -> log ) fprintf ( i -> parent -> log , ""***ERROR***ImagebiggerthanglobalGIFcanvas!\\n"" ) ; # endif return - 1 ; } if ( ( i -> posX + i -> width ) > i -> parent -> width ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent -> log ) fprintf ( i -> parent -> log , ""***WARNING***AdjustingXposition\\n"" ) ; # endif i -> posX = i -> parent -> width - i -> width ; } if ( ( i -> posY + i -> height ) > i -> parent -> height ) { # if ! defined ( NGIFLIB_NO_FILE ) if ( i -> parent -> log ) fprintf ( i -> parent -> log , ""***WARNING***AdjustingYposition\\n"" ) ; # endif i -> posY = i -> parent -> height - i -> height ; } ",miniupnp@ngiflib/b588a2249c7abbfc52173e32ee11d6facef82f89,CVE-2018-10677,https://github.com/miniupnp/ngiflib/commit/b588a2249c7abbfc52173e32ee11d6facef82f89,2018-05-02T19:29Z 1342,CWE-125,"CWE-125 void processRequest ( struct reqelem * req ) { ssize_t n ; unsigned int l , m ; unsigned char buf [ 2048 ] ; const unsigned char * p ; enum request_type type ; struct device * d = devlist ; unsigned char rbuf [ RESPONSE_BUFFER_SIZE ] ; unsigned char * rp ; unsigned char nrep = 0 ; time_t t ; struct service * newserv = NULL ; struct service * serv ; n = read ( req -> socket , buf , sizeof ( buf ) ) ; if ( n < 0 ) { if ( errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK ) return ; syslog ( LOG_ERR , ""(s=%d)processRequest():read():%m"" , req -> socket ) ; goto error ; } if ( n == 0 ) { syslog ( LOG_INFO , ""(s=%d)requestconnectionclosed"" , req -> socket ) ; goto error ; } t = time ( NULL ) ; type = buf [ 0 ] ; p = buf + 1 ; DECODELENGTH_CHECKLIMIT ( l , p , buf + n ) ; if ( p + l > buf + n ) { syslog ( LOG_WARNING , ""badrequest(lengthencodingl=%un=%u)"" , l , ( unsigned ) n ) ; goto error ; } if ( l == 0 && type != MINISSDPD_SEARCH_ALL && type != MINISSDPD_GET_VERSION && type != MINISSDPD_NOTIF ) { syslog ( LOG_WARNING , ""badrequest(length=0,type=%d)"" , type ) ; goto error ; } syslog ( LOG_INFO , ""(s=%d)requesttype=%dstr=\'%.*s\'"" , req -> socket , type , l , p ) ; switch ( type ) { case MINISSDPD_GET_VERSION : rp = rbuf ; CODELENGTH ( ( sizeof ( MINISSDPD_VERSION ) - 1 ) , rp ) ; memcpy ( rp , MINISSDPD_VERSION , sizeof ( MINISSDPD_VERSION ) - 1 ) ; rp += ( sizeof ( MINISSDPD_VERSION ) - 1 ) ; if ( write_or_buffer ( req , rbuf , rp - rbuf ) < 0 ) { syslog ( LOG_ERR , ""(s=%d)write:%m"" , req -> socket ) ; goto error ; } break ; case MINISSDPD_SEARCH_TYPE : case MINISSDPD_SEARCH_USN : case MINISSDPD_SEARCH_ALL : rp = rbuf + 1 ; while ( d && ( nrep < 255 ) ) { if ( d -> t < t ) { syslog ( LOG_INFO , ""outdateddevice"" ) ; } else { if ( d -> headers [ HEADER_LOCATION ] . l + d -> headers [ HEADER_NT ] . l + d -> headers [ HEADER_USN ] . l + 6 + ( rp - rbuf ) >= ( int ) sizeof ( rbuf ) ) break ; if ( ( type == MINISSDPD_SEARCH_TYPE && 0 == memcmp ( d -> headers [ HEADER_NT ] . p , p , l ) ) || ( type == MINISSDPD_SEARCH_USN && 0 == memcmp ( d -> headers [ HEADER_USN ] . p , p , l ) ) || ( type == MINISSDPD_SEARCH_ALL ) ) { m = d -> headers [ HEADER_LOCATION ] . l ; CODELENGTH ( m , rp ) ; memcpy ( rp , d -> headers [ HEADER_LOCATION ] . p , d -> headers [ HEADER_LOCATION ] . l ) ; rp += d -> headers [ HEADER_LOCATION ] . l ; m = d -> headers [ HEADER_NT ] . l ; CODELENGTH ( m , rp ) ; memcpy ( rp , d -> headers [ HEADER_NT ] . p , d -> headers [ HEADER_NT ] . l ) ; rp += d -> headers [ HEADER_NT ] . l ; m = d -> headers [ HEADER_USN ] . l ; CODELENGTH ( m , rp ) ; memcpy ( rp , d -> headers [ HEADER_USN ] . p , d -> headers [ HEADER_USN ] . l ) ; rp += d -> headers [ HEADER_USN ] . l ; nrep ++ ; } } d = d -> next ; } for ( serv = servicelisthead . lh_first ; serv && ( nrep < 255 ) ; serv = serv -> entries . le_next ) { if ( strlen ( serv -> location ) + strlen ( serv -> st ) + strlen ( serv -> usn ) + 6 + ( rp - rbuf ) >= sizeof ( rbuf ) ) break ; if ( ( type == MINISSDPD_SEARCH_TYPE && 0 == strncmp ( serv -> st , ( const char * ) p , l ) ) || ( type == MINISSDPD_SEARCH_USN && 0 == strncmp ( serv -> usn , ( const char * ) p , l ) ) || ( type == MINISSDPD_SEARCH_ALL ) ) { m = strlen ( serv -> location ) ; CODELENGTH ( m , rp ) ; memcpy ( rp , serv -> location , m ) ; rp += m ; m = strlen ( serv -> st ) ; CODELENGTH ( m , rp ) ; memcpy ( rp , serv -> st , m ) ; rp += m ; m = strlen ( serv -> usn ) ; CODELENGTH ( m , rp ) ; memcpy ( rp , serv -> usn , m ) ; rp += m ; nrep ++ ; } } rbuf [ 0 ] = nrep ; syslog ( LOG_DEBUG , ""(s=%d)response:%ddevice%s"" , req -> socket , nrep , ( nrep > 1 ) ? ""s"" : """" ) ; if ( write_or_buffer ( req , rbuf , rp - rbuf ) < 0 ) { syslog ( LOG_ERR , ""(s=%d)write:%m"" , req -> socket ) ; goto error ; } break ; case MINISSDPD_SUBMIT : newserv = malloc ( sizeof ( struct service ) ) ; if ( ! newserv ) { syslog ( LOG_ERR , ""cannotallocatememory"" ) ; goto error ; } memset ( newserv , 0 , sizeof ( struct service ) ) ; if ( containsForbiddenChars ( p , l ) ) { syslog ( LOG_ERR , ""badrequest(stcontainsforbiddenchars)"" ) ; goto error ; } newserv -> st = malloc ( l + 1 ) ; if ( ! newserv -> st ) { syslog ( LOG_ERR , ""cannotallocatememory"" ) ; goto error ; } memcpy ( newserv -> st , p , l ) ; newserv -> st [ l ] = '\\0' ; p += l ; if ( p >= buf + n ) { syslog ( LOG_WARNING , ""badrequest(missingusn)"" ) ; goto error ; } DECODELENGTH_CHECKLIMIT ( l , p , buf + n ) ; if ( p + l > buf + n ) { syslog ( LOG_WARNING , ""badrequest(lengthencoding)"" ) ; goto error ; } if ( containsForbiddenChars ( p , l ) ) { syslog ( LOG_ERR , ""badrequest(usncontainsforbiddenchars)"" ) ; goto error ; } syslog ( LOG_INFO , ""usn=\'%.*s\'"" , l , p ) ; newserv -> usn = malloc ( l + 1 ) ; if ( ! newserv -> usn ) { syslog ( LOG_ERR , ""cannotallocatememory"" ) ; goto error ; } memcpy ( newserv -> usn , p , l ) ; newserv -> usn [ l ] = '\\0' ; p += l ; DECODELENGTH_CHECKLIMIT ( l , p , buf + n ) ; if ( p + l > buf + n ) { syslog ( LOG_WARNING , ""badrequest(lengthencoding)"" ) ; goto error ; } if ( containsForbiddenChars ( p , l ) ) { syslog ( LOG_ERR , ""badrequest(servercontainsforbiddenchars)"" ) ; goto error ; } syslog ( LOG_INFO , ""server=\'%.*s\'"" , l , p ) ; newserv -> server = malloc ( l + 1 ) ; if ( ! newserv -> server ) { syslog ( LOG_ERR , ""cannotallocatememory"" ) ; goto error ; } memcpy ( newserv -> server , p , l ) ; newserv -> server [ l ] = '\\0' ; p += l ; DECODELENGTH_CHECKLIMIT ( l , p , buf + n ) ; if ( p + l > buf + n ) { syslog ( LOG_WARNING , ""badrequest(lengthencoding)"" ) ; goto error ; } if ( containsForbiddenChars ( p , l ) ) { syslog ( LOG_ERR , ""badrequest(locationcontainsforbiddenchars)"" ) ; goto error ; } syslog ( LOG_INFO , ""location=\'%.*s\'"" , l , p ) ; newserv -> location = malloc ( l + 1 ) ; if ( ! newserv -> location ) { syslog ( LOG_ERR , ""cannotallocatememory"" ) ; goto error ; } memcpy ( newserv -> location , p , l ) ; newserv -> location [ l ] = '\\0' ; for ( serv = servicelisthead . lh_first ; serv ; serv = serv -> entries . le_next ) { if ( 0 == strcmp ( newserv -> usn , serv -> usn ) && 0 == strcmp ( newserv -> st , serv -> st ) ) { syslog ( LOG_INFO , ""Servicealreadyinthelist.Updating..."" ) ; free ( newserv -> st ) ; free ( newserv -> usn ) ; free ( serv -> server ) ; serv -> server = newserv -> server ; free ( serv -> location ) ; serv -> location = newserv -> location ; free ( newserv ) ; newserv = NULL ; return ; } } LIST_INSERT_HEAD ( & servicelisthead , newserv , entries ) ; sendNotifications ( NOTIF_NEW , NULL , newserv ) ; newserv = NULL ; break ; case MINISSDPD_NOTIF : rbuf [ 0 ] = '\\0' ; if ( write_or_buffer ( req , rbuf , 1 ) < 0 ) { syslog ( LOG_ERR , ""(s=%d)write:%m"" , req -> socket ) ; goto error ; } req -> is_notify = 1 ; break ; default : syslog ( LOG_WARNING , ""Unknownrequesttype%d"" , type ) ; rbuf [ 0 ] = '\\0' ; if ( write_or_buffer ( req , rbuf , 1 ) < 0 ) { syslog ( LOG_ERR , ""(s=%d)write:%m"" , req -> socket ) ; goto error ; } } return ; error : if ( newserv ) { free ( newserv -> st ) ; free ( newserv -> usn ) ; free ( newserv -> server ) ; free ( newserv -> location ) ; free ( newserv ) ; newserv = NULL ; } close ( req -> socket ) ; req -> socket = - 1 ; return ; } "," ; if ( l > ( unsigned ) ( buf + n buf + n - p ) ; if ( l > ( unsigned ) ( buf + n buf + n - p ) ; if ( l > ( unsigned ) ( buf + n buf + n - p ) ; if ( l > ( unsigned ) ( buf + n buf + n - p ) ",miniupnp@miniupnp/b238cade9a173c6f751a34acf8ccff838a62aa47,CVE-2016-3178,https://github.com/miniupnp/miniupnp/commit/b238cade9a173c6f751a34acf8ccff838a62aa47,2017-03-24T15:59Z 1343,CWE-908,"CWE-908 INST_HANDLER ( cpse ) { int r = ( buf [ 0 ] & 0xf ) | ( ( buf [ 1 ] & 0x2 ) << 3 ) ; int d = ( ( buf [ 0 ] >> 4 ) & 0xf ) | ( ( buf [ 1 ] & 0x1 ) << 4 ) ; RAnalOp next_op ; avr_op_analyze ( anal , & next_op , op -> addr + op -> size , buf + op -> size , len - op -> size , cpu ) ; r_strbuf_fini ( & next_op . esil ) ; op -> jump = op -> addr + next_op . size + 2 ; op -> cycles = 1 ; ESIL_A ( ""r%d,r%d,^,!,"" , r , d ) ; ESIL_A ( ""?{,%"" PFMT64d "",pc,=,},"" , op -> jump ) ; } "," ; RAnalOp next_op = { 0 } ",radare@radare2/9d348bcc2c4bbd3805e7eec97b594be9febbdf9a,CVE-2018-11383,https://github.com/radare/radare2/commit/9d348bcc2c4bbd3805e7eec97b594be9febbdf9a,2018-05-22T19:29Z 1344,CWE-20,"CWE-20 static Image * ReadDCMImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define ThrowDCMException ( exception , message ) { if ( info . scale != ( Quantum * ) NULL ) info . scale = ( Quantum * ) RelinquishMagickMemory ( info . scale ) ; if ( data != ( unsigned char * ) NULL ) data = ( unsigned char * ) RelinquishMagickMemory ( data ) ; if ( graymap != ( int * ) NULL ) graymap = ( int * ) RelinquishMagickMemory ( graymap ) ; if ( bluemap != ( int * ) NULL ) bluemap = ( int * ) RelinquishMagickMemory ( bluemap ) ; if ( greenmap != ( int * ) NULL ) greenmap = ( int * ) RelinquishMagickMemory ( greenmap ) ; if ( redmap != ( int * ) NULL ) redmap = ( int * ) RelinquishMagickMemory ( redmap ) ; if ( stream_info -> offsets != ( ssize_t * ) NULL ) stream_info -> offsets = ( ssize_t * ) RelinquishMagickMemory ( stream_info -> offsets ) ; if ( stream_info != ( DCMStreamInfo * ) NULL ) stream_info = ( DCMStreamInfo * ) RelinquishMagickMemory ( stream_info ) ; ThrowReaderException ( ( exception ) , ( message ) ) ; } char explicit_vr [ MagickPathExtent ] , implicit_vr [ MagickPathExtent ] , magick [ MagickPathExtent ] , photometric [ MagickPathExtent ] ; DCMInfo info ; DCMStreamInfo * stream_info ; Image * image ; int * bluemap , datum , * greenmap , * graymap , * redmap ; MagickBooleanType explicit_file , explicit_retry , use_explicit ; MagickOffsetType offset ; register unsigned char * p ; register ssize_t i ; size_t colors , height , length , number_scenes , quantum , status , width ; ssize_t count , scene ; unsigned char * data ; unsigned short group , element ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image -> depth = 8UL ; image -> endian = LSBEndian ; ( void ) memset ( & info , 0 , sizeof ( info ) ) ; data = ( unsigned char * ) NULL ; graymap = ( int * ) NULL ; redmap = ( int * ) NULL ; greenmap = ( int * ) NULL ; bluemap = ( int * ) NULL ; stream_info = ( DCMStreamInfo * ) AcquireMagickMemory ( sizeof ( * stream_info ) ) ; if ( stream_info == ( DCMStreamInfo * ) NULL ) ThrowDCMException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; ( void ) memset ( stream_info , 0 , sizeof ( * stream_info ) ) ; count = ReadBlob ( image , 128 , ( unsigned char * ) magick ) ; if ( count != 128 ) ThrowDCMException ( CorruptImageError , ""ImproperImageHeader"" ) ; count = ReadBlob ( image , 4 , ( unsigned char * ) magick ) ; if ( ( count != 4 ) || ( LocaleNCompare ( magick , ""DICM"" , 4 ) != 0 ) ) { offset = SeekBlob ( image , 0L , SEEK_SET ) ; if ( offset < 0 ) ThrowDCMException ( CorruptImageError , ""ImproperImageHeader"" ) ; } ( void ) CopyMagickString ( photometric , ""MONOCHROME1"" , MagickPathExtent ) ; info . bits_allocated = 8 ; info . bytes_per_pixel = 1 ; info . depth = 8 ; info . mask = 0xffff ; info . max_value = 255UL ; info . samples_per_pixel = 1 ; info . signed_data = ( ~ 0UL ) ; info . rescale_slope = 1.0 ; data = ( unsigned char * ) NULL ; element = 0 ; explicit_vr [ 2 ] = '\\0' ; explicit_file = MagickFalse ; colors = 0 ; redmap = ( int * ) NULL ; greenmap = ( int * ) NULL ; bluemap = ( int * ) NULL ; graymap = ( int * ) NULL ; height = 0 ; number_scenes = 1 ; use_explicit = MagickFalse ; explicit_retry = MagickFalse ; width = 0 ; while ( TellBlob ( image ) < ( MagickOffsetType ) GetBlobSize ( image ) ) { for ( group = 0 ; ( group != 0x7FE0 ) || ( element != 0x0010 ) ; ) { image -> offset = ( ssize_t ) TellBlob ( image ) ; group = ReadBlobLSBShort ( image ) ; element = ReadBlobLSBShort ( image ) ; if ( ( group == 0xfffc ) && ( element == 0xfffc ) ) break ; if ( ( group != 0x0002 ) && ( image -> endian == MSBEndian ) ) { group = ( unsigned short ) ( ( group << 8 ) | ( ( group >> 8 ) & 0xFF ) ) ; element = ( unsigned short ) ( ( element << 8 ) | ( ( element >> 8 ) & 0xFF ) ) ; } quantum = 0 ; for ( i = 0 ; dicom_info [ i ] . group < 0xffff ; i ++ ) if ( ( group == dicom_info [ i ] . group ) && ( element == dicom_info [ i ] . element ) ) break ; ( void ) CopyMagickString ( implicit_vr , dicom_info [ i ] . vr , MagickPathExtent ) ; count = ReadBlob ( image , 2 , ( unsigned char * ) explicit_vr ) ; if ( count != 2 ) ThrowDCMException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ( explicit_file == MagickFalse ) && ( group != 0x0002 ) ) explicit_file = ( isupper ( ( unsigned char ) * explicit_vr ) != MagickFalse ) && ( isupper ( ( unsigned char ) * ( explicit_vr + 1 ) ) != MagickFalse ) ? MagickTrue : MagickFalse ; use_explicit = ( ( group == 0x0002 ) && ( explicit_retry == MagickFalse ) ) || ( explicit_file != MagickFalse ) ? MagickTrue : MagickFalse ; if ( ( use_explicit != MagickFalse ) && ( strncmp ( implicit_vr , ""xs"" , 2 ) == 0 ) ) ( void ) CopyMagickString ( implicit_vr , explicit_vr , MagickPathExtent ) ; if ( ( use_explicit == MagickFalse ) || ( strncmp ( implicit_vr , ""!!"" , 2 ) == 0 ) ) { offset = SeekBlob ( image , ( MagickOffsetType ) - 2 , SEEK_CUR ) ; if ( offset < 0 ) ThrowDCMException ( CorruptImageError , ""ImproperImageHeader"" ) ; quantum = 4 ; } else { quantum = 2 ; if ( ( strncmp ( explicit_vr , ""OB"" , 2 ) == 0 ) || ( strncmp ( explicit_vr , ""UN"" , 2 ) == 0 ) || ( strncmp ( explicit_vr , ""OW"" , 2 ) == 0 ) || ( strncmp ( explicit_vr , ""SQ"" , 2 ) == 0 ) ) { ( void ) ReadBlobLSBShort ( image ) ; quantum = 4 ; } } datum = 0 ; if ( quantum == 4 ) { if ( group == 0x0002 ) datum = ReadBlobLSBSignedLong ( image ) ; else datum = ReadBlobSignedLong ( image ) ; } else if ( quantum == 2 ) { if ( group == 0x0002 ) datum = ReadBlobLSBSignedShort ( image ) ; else datum = ReadBlobSignedShort ( image ) ; } quantum = 0 ; length = 1 ; if ( datum != 0 ) { if ( ( strncmp ( implicit_vr , ""OW"" , 2 ) == 0 ) || ( strncmp ( implicit_vr , ""SS"" , 2 ) == 0 ) || ( strncmp ( implicit_vr , ""US"" , 2 ) == 0 ) ) quantum = 2 ; else if ( ( strncmp ( implicit_vr , ""FL"" , 2 ) == 0 ) || ( strncmp ( implicit_vr , ""OF"" , 2 ) == 0 ) || ( strncmp ( implicit_vr , ""SL"" , 2 ) == 0 ) || ( strncmp ( implicit_vr , ""UL"" , 2 ) == 0 ) ) quantum = 4 ; else if ( strncmp ( implicit_vr , ""FD"" , 2 ) == 0 ) quantum = 8 ; else quantum = 1 ; if ( datum != ~ 0 ) length = ( size_t ) datum / quantum ; else { quantum = 0 ; length = 0 ; } } if ( image_info -> verbose != MagickFalse ) { if ( use_explicit == MagickFalse ) explicit_vr [ 0 ] = '\\0' ; for ( i = 0 ; dicom_info [ i ] . description != ( char * ) NULL ; i ++ ) if ( ( group == dicom_info [ i ] . group ) && ( element == dicom_info [ i ] . element ) ) break ; ( void ) FormatLocaleFile ( stdout , ""0x%04lX%4ld%s-%s(0x%04lx,0x%04lx)"" , ( unsigned long ) image -> offset , ( long ) length , implicit_vr , explicit_vr , ( unsigned long ) group , ( unsigned long ) element ) ; if ( dicom_info [ i ] . description != ( char * ) NULL ) ( void ) FormatLocaleFile ( stdout , ""%s"" , dicom_info [ i ] . description ) ; ( void ) FormatLocaleFile ( stdout , "":"" ) ; } if ( ( group == 0x7FE0 ) && ( element == 0x0010 ) ) { if ( image_info -> verbose != MagickFalse ) ( void ) FormatLocaleFile ( stdout , ""\\n"" ) ; break ; } data = ( unsigned char * ) NULL ; if ( ( length == 1 ) && ( quantum == 1 ) ) datum = ReadBlobByte ( image ) ; else if ( ( length == 1 ) && ( quantum == 2 ) ) { if ( group == 0x0002 ) datum = ReadBlobLSBSignedShort ( image ) ; else datum = ReadBlobSignedShort ( image ) ; } else if ( ( length == 1 ) && ( quantum == 4 ) ) { if ( group == 0x0002 ) datum = ReadBlobLSBSignedLong ( image ) ; else datum = ReadBlobSignedLong ( image ) ; } else if ( ( quantum != 0 ) && ( length != 0 ) ) { if ( length > ( size_t ) GetBlobSize ( image ) ) ThrowDCMException ( CorruptImageError , ""InsufficientImageDataInFile"" ) ; if ( ~ length >= 1 ) data = ( unsigned char * ) AcquireQuantumMemory ( length + 1 , quantum * sizeof ( * data ) ) ; if ( data == ( unsigned char * ) NULL ) ThrowDCMException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; count = ReadBlob ( image , ( size_t ) quantum * length , data ) ; if ( count != ( ssize_t ) ( quantum * length ) ) { if ( image_info -> verbose != MagickFalse ) ( void ) FormatLocaleFile ( stdout , ""count=%dquantum=%d"" ""length=%dgroup=%d\\n"" , ( int ) count , ( int ) quantum , ( int ) length , ( int ) group ) ; ThrowDCMException ( CorruptImageError , ""InsufficientImageDataInFile"" ) ; } data [ length * quantum ] = '\\0' ; } if ( ( ( ( unsigned int ) group << 16 ) | element ) == 0xFFFEE0DD ) { if ( data != ( unsigned char * ) NULL ) data = ( unsigned char * ) RelinquishMagickMemory ( data ) ; continue ; } switch ( group ) { case 0x0002 : { switch ( element ) { case 0x0010 : { char transfer_syntax [ MagickPathExtent ] ; if ( ( datum == 0 ) && ( explicit_retry == MagickFalse ) ) { explicit_retry = MagickTrue ; ( void ) SeekBlob ( image , ( MagickOffsetType ) 0 , SEEK_SET ) ; group = 0 ; element = 0 ; if ( image_info -> verbose != MagickFalse ) ( void ) FormatLocaleFile ( stdout , ""Corruptedimage-tryingexplicitformat\\n"" ) ; break ; } * transfer_syntax = '\\0' ; if ( data != ( unsigned char * ) NULL ) ( void ) CopyMagickString ( transfer_syntax , ( char * ) data , MagickPathExtent ) ; if ( image_info -> verbose != MagickFalse ) ( void ) FormatLocaleFile ( stdout , ""transfer_syntax=%s\\n"" , ( const char * ) transfer_syntax ) ; if ( strncmp ( transfer_syntax , ""1.2.840.10008.1.2"" , 17 ) == 0 ) { int subtype , type ; type = 1 ; subtype = 0 ; if ( strlen ( transfer_syntax ) > 17 ) { count = ( ssize_t ) sscanf ( transfer_syntax + 17 , "".%d.%d"" , & type , & subtype ) ; if ( count < 1 ) ThrowDCMException ( CorruptImageError , ""ImproperImageHeader"" ) ; } switch ( type ) { case 1 : { image -> endian = LSBEndian ; break ; } case 2 : { image -> endian = MSBEndian ; break ; } case 4 : { if ( ( subtype >= 80 ) && ( subtype <= 81 ) ) image -> compression = JPEGCompression ; else if ( ( subtype >= 90 ) && ( subtype <= 93 ) ) image -> compression = JPEG2000Compression ; else image -> compression = JPEGCompression ; break ; } case 5 : { image -> compression = RLECompression ; break ; } } } break ; } default : break ; } break ; } case 0x0028 : { switch ( element ) { case 0x0002 : { info . samples_per_pixel = ( size_t ) datum ; if ( ( info . samples_per_pixel == 0 ) || ( info . samples_per_pixel > 4 ) ) ThrowDCMException ( CorruptImageError , ""ImproperImageHeader"" ) ; break ; } case 0x0004 : { if ( data == ( unsigned char * ) NULL ) break ; for ( i = 0 ; i < ( ssize_t ) MagickMin ( length , MagickPathExtent - 1 ) ; i ++ ) photometric [ i ] = ( char ) data [ i ] ; photometric [ i ] = '\\0' ; info . polarity = LocaleCompare ( photometric , ""MONOCHROME1"" ) == 0 ? MagickTrue : MagickFalse ; break ; } case 0x0006 : { if ( datum == 1 ) image -> interlace = PlaneInterlace ; break ; } case 0x0008 : { if ( data == ( unsigned char * ) NULL ) break ; number_scenes = StringToUnsignedLong ( ( char * ) data ) ; break ; } case 0x0010 : { height = ( size_t ) datum ; break ; } case 0x0011 : { width = ( size_t ) datum ; break ; } case 0x0100 : { info . bits_allocated = ( size_t ) datum ; info . bytes_per_pixel = 1 ; if ( datum > 8 ) info . bytes_per_pixel = 2 ; info . depth = info . bits_allocated ; if ( ( info . depth == 0 ) || ( info . depth > 32 ) ) ThrowDCMException ( CorruptImageError , ""ImproperImageHeader"" ) ; info . max_value = ( 1UL << info . bits_allocated ) - 1 ; image -> depth = info . depth ; break ; } case 0x0101 : { info . significant_bits = ( size_t ) datum ; info . bytes_per_pixel = 1 ; if ( info . significant_bits > 8 ) info . bytes_per_pixel = 2 ; info . depth = info . significant_bits ; if ( ( info . depth == 0 ) || ( info . depth > 16 ) ) ThrowDCMException ( CorruptImageError , ""ImproperImageHeader"" ) ; info . max_value = ( 1UL << info . significant_bits ) - 1 ; info . mask = ( size_t ) GetQuantumRange ( info . significant_bits ) ; image -> depth = info . depth ; break ; } case 0x0102 : { break ; } case 0x0103 : { info . signed_data = ( size_t ) datum ; break ; } case 0x1050 : { if ( data != ( unsigned char * ) NULL ) info . window_center = StringToDouble ( ( char * ) data , ( char * * ) NULL ) ; break ; } case 0x1051 : { if ( data != ( unsigned char * ) NULL ) info . window_width = StringToDouble ( ( char * ) data , ( char * * ) NULL ) ; break ; } case 0x1052 : { if ( data != ( unsigned char * ) NULL ) info . rescale_intercept = StringToDouble ( ( char * ) data , ( char * * ) NULL ) ; break ; } case 0x1053 : { if ( data != ( unsigned char * ) NULL ) info . rescale_slope = StringToDouble ( ( char * ) data , ( char * * ) NULL ) ; break ; } case 0x1200 : case 0x3006 : { if ( data == ( unsigned char * ) NULL ) break ; colors = ( size_t ) ( length / info . bytes_per_pixel ) ; datum = ( int ) colors ; if ( graymap != ( int * ) NULL ) graymap = ( int * ) RelinquishMagickMemory ( graymap ) ; graymap = ( int * ) AcquireQuantumMemory ( MagickMax ( colors , 65536 ) , sizeof ( * graymap ) ) ; if ( graymap == ( int * ) NULL ) ThrowDCMException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; ( void ) memset ( graymap , 0 , MagickMax ( colors , 65536 ) * sizeof ( * graymap ) ) ; for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) if ( info . bytes_per_pixel == 1 ) graymap [ i ] = ( int ) data [ i ] ; else graymap [ i ] = ( int ) ( ( short * ) data ) [ i ] ; break ; } case 0x1201 : { unsigned short index ; if ( data == ( unsigned char * ) NULL ) break ; colors = ( size_t ) ( length / 2 ) ; datum = ( int ) colors ; if ( redmap != ( int * ) NULL ) redmap = ( int * ) RelinquishMagickMemory ( redmap ) ; redmap = ( int * ) AcquireQuantumMemory ( MagickMax ( colors , 65536 ) , sizeof ( * redmap ) ) ; if ( redmap == ( int * ) NULL ) ThrowDCMException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; ( void ) memset ( redmap , 0 , MagickMax ( colors , 65536 ) * sizeof ( * redmap ) ) ; p = data ; for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { if ( image -> endian == MSBEndian ) index = ( unsigned short ) ( ( * p << 8 ) | * ( p + 1 ) ) ; else index = ( unsigned short ) ( * p | ( * ( p + 1 ) << 8 ) ) ; redmap [ i ] = ( int ) index ; p += 2 ; } break ; } case 0x1202 : { unsigned short index ; if ( data == ( unsigned char * ) NULL ) break ; colors = ( size_t ) ( length / 2 ) ; datum = ( int ) colors ; if ( greenmap != ( int * ) NULL ) greenmap = ( int * ) RelinquishMagickMemory ( greenmap ) ; greenmap = ( int * ) AcquireQuantumMemory ( MagickMax ( colors , 65536 ) , sizeof ( * greenmap ) ) ; if ( greenmap == ( int * ) NULL ) ThrowDCMException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; ( void ) memset ( greenmap , 0 , MagickMax ( colors , 65536 ) * sizeof ( * greenmap ) ) ; p = data ; for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { if ( image -> endian == MSBEndian ) index = ( unsigned short ) ( ( * p << 8 ) | * ( p + 1 ) ) ; else index = ( unsigned short ) ( * p | ( * ( p + 1 ) << 8 ) ) ; greenmap [ i ] = ( int ) index ; p += 2 ; } break ; } case 0x1203 : { unsigned short index ; if ( data == ( unsigned char * ) NULL ) break ; colors = ( size_t ) ( length / 2 ) ; datum = ( int ) colors ; if ( bluemap != ( int * ) NULL ) bluemap = ( int * ) RelinquishMagickMemory ( bluemap ) ; bluemap = ( int * ) AcquireQuantumMemory ( MagickMax ( colors , 65536 ) , sizeof ( * bluemap ) ) ; if ( bluemap == ( int * ) NULL ) ThrowDCMException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; ( void ) memset ( bluemap , 0 , MagickMax ( colors , 65536 ) * sizeof ( * bluemap ) ) ; p = data ; for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { if ( image -> endian == MSBEndian ) index = ( unsigned short ) ( ( * p << 8 ) | * ( p + 1 ) ) ; else index = ( unsigned short ) ( * p | ( * ( p + 1 ) << 8 ) ) ; bluemap [ i ] = ( int ) index ; p += 2 ; } break ; } default : break ; } break ; } case 0x2050 : { switch ( element ) { case 0x0020 : { if ( ( data != ( unsigned char * ) NULL ) && ( strncmp ( ( char * ) data , ""INVERSE"" , 7 ) == 0 ) ) info . polarity = MagickTrue ; break ; } default : break ; } break ; } default : break ; } if ( data != ( unsigned char * ) NULL ) { char * attribute ; for ( i = 0 ; dicom_info [ i ] . description != ( char * ) NULL ; i ++ ) if ( ( group == dicom_info [ i ] . group ) && ( element == dicom_info [ i ] . element ) ) break ; if ( dicom_info [ i ] . description != ( char * ) NULL ) { attribute = AcquireString ( ""dcm:"" ) ; ( void ) ConcatenateString ( & attribute , dicom_info [ i ] . description ) ; for ( i = 0 ; i < ( ssize_t ) MagickMax ( length , 4 ) ; i ++ ) if ( isprint ( ( int ) data [ i ] ) == MagickFalse ) break ; if ( ( i == ( ssize_t ) length ) || ( length > 4 ) ) { ( void ) SubstituteString ( & attribute , """" , """" ) ; ( void ) SetImageProperty ( image , attribute , ( char * ) data , exception ) ; } attribute = DestroyString ( attribute ) ; } } if ( image_info -> verbose != MagickFalse ) { if ( data == ( unsigned char * ) NULL ) ( void ) FormatLocaleFile ( stdout , ""%d\\n"" , datum ) ; else { for ( i = 0 ; i < ( ssize_t ) MagickMax ( length , 4 ) ; i ++ ) if ( isprint ( ( int ) data [ i ] ) == MagickFalse ) break ; if ( ( i != ( ssize_t ) length ) && ( length <= 4 ) ) { ssize_t j ; datum = 0 ; for ( j = ( ssize_t ) length - 1 ; j >= 0 ; j -- ) datum = ( 256 * datum + data [ j ] ) ; ( void ) FormatLocaleFile ( stdout , ""%d"" , datum ) ; } else for ( i = 0 ; i < ( ssize_t ) length ; i ++ ) if ( isprint ( ( int ) data [ i ] ) != MagickFalse ) ( void ) FormatLocaleFile ( stdout , ""%c"" , data [ i ] ) ; else ( void ) FormatLocaleFile ( stdout , ""%c"" , '.' ) ; ( void ) FormatLocaleFile ( stdout , ""\\n"" ) ; } } if ( data != ( unsigned char * ) NULL ) data = ( unsigned char * ) RelinquishMagickMemory ( data ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } } if ( ( group == 0xfffc ) && ( element == 0xfffc ) ) { Image * last ; last = RemoveLastImageFromList ( & image ) ; if ( last != ( Image * ) NULL ) last = DestroyImage ( last ) ; break ; } if ( ( width == 0 ) || ( height == 0 ) ) ThrowDCMException ( CorruptImageError , ""ImproperImageHeader"" ) ; image -> columns = ( size_t ) width ; image -> rows = ( size_t ) height ; if ( info . signed_data == 0xffff ) info . signed_data = ( size_t ) ( info . significant_bits == 16 ? 1 : 0 ) ; if ( ( image -> compression == JPEGCompression ) || ( image -> compression == JPEG2000Compression ) ) { Image * images ; ImageInfo * read_info ; int c ; for ( i = 0 ; i < ( ssize_t ) stream_info -> remaining ; i ++ ) if ( ReadBlobByte ( image ) == EOF ) break ; ( void ) ( ( ( ssize_t ) ReadBlobLSBShort ( image ) << 16 ) | ReadBlobLSBShort ( image ) ) ; length = ( size_t ) ReadBlobLSBLong ( image ) ; if ( length > ( size_t ) GetBlobSize ( image ) ) ThrowDCMException ( CorruptImageError , ""InsufficientImageDataInFile"" ) ; stream_info -> offset_count = length >> 2 ; if ( stream_info -> offset_count != 0 ) { if ( stream_info -> offsets != ( ssize_t * ) NULL ) stream_info -> offsets = ( ssize_t * ) RelinquishMagickMemory ( stream_info -> offsets ) ; stream_info -> offsets = ( ssize_t * ) AcquireQuantumMemory ( stream_info -> offset_count , sizeof ( * stream_info -> offsets ) ) ; if ( stream_info -> offsets == ( ssize_t * ) NULL ) ThrowDCMException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; for ( i = 0 ; i < ( ssize_t ) stream_info -> offset_count ; i ++ ) stream_info -> offsets [ i ] = ( ssize_t ) ReadBlobLSBSignedLong ( image ) ; offset = TellBlob ( image ) ; for ( i = 0 ; i < ( ssize_t ) stream_info -> offset_count ; i ++ ) stream_info -> offsets [ i ] += offset ; } read_info = CloneImageInfo ( image_info ) ; SetImageInfoBlob ( read_info , ( void * ) NULL , 0 ) ; images = NewImageList ( ) ; for ( scene = 0 ; scene < ( ssize_t ) number_scenes ; scene ++ ) { char filename [ MagickPathExtent ] ; const char * property ; FILE * file ; Image * jpeg_image ; int unique_file ; unsigned int tag ; tag = ( ( unsigned int ) ReadBlobLSBShort ( image ) << 16 ) | ReadBlobLSBShort ( image ) ; length = ( size_t ) ReadBlobLSBLong ( image ) ; if ( tag == 0xFFFEE0DD ) break ; if ( tag != 0xFFFEE000 ) { read_info = DestroyImageInfo ( read_info ) ; ThrowDCMException ( CorruptImageError , ""ImproperImageHeader"" ) ; } file = ( FILE * ) NULL ; unique_file = AcquireUniqueFileResource ( filename ) ; if ( unique_file != - 1 ) file = fdopen ( unique_file , ""wb"" ) ; if ( file == ( FILE * ) NULL ) { ( void ) RelinquishUniqueFileResource ( filename ) ; ThrowFileException ( exception , FileOpenError , ""UnableToCreateTemporaryFile"" , filename ) ; break ; } for ( c = EOF ; length != 0 ; length -- ) { c = ReadBlobByte ( image ) ; if ( c == EOF ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } if ( fputc ( c , file ) != c ) break ; } ( void ) fclose ( file ) ; if ( c == EOF ) break ; ( void ) FormatLocaleString ( read_info -> filename , MagickPathExtent , ""jpeg:%s"" , filename ) ; if ( image -> compression == JPEG2000Compression ) ( void ) FormatLocaleString ( read_info -> filename , MagickPathExtent , ""j2k:%s"" , filename ) ; jpeg_image = ReadImage ( read_info , exception ) ; if ( jpeg_image != ( Image * ) NULL ) { ResetImagePropertyIterator ( image ) ; property = GetNextImageProperty ( image ) ; while ( property != ( const char * ) NULL ) { ( void ) SetImageProperty ( jpeg_image , property , GetImageProperty ( image , property , exception ) , exception ) ; property = GetNextImageProperty ( image ) ; } AppendImageToList ( & images , jpeg_image ) ; } ( void ) RelinquishUniqueFileResource ( filename ) ; } read_info = DestroyImageInfo ( read_info ) ; if ( stream_info -> offsets != ( ssize_t * ) NULL ) stream_info -> offsets = ( ssize_t * ) RelinquishMagickMemory ( stream_info -> offsets ) ; stream_info = ( DCMStreamInfo * ) RelinquishMagickMemory ( stream_info ) ; if ( info . scale != ( Quantum * ) NULL ) info . scale = ( Quantum * ) RelinquishMagickMemory ( info . scale ) ; if ( graymap != ( int * ) NULL ) graymap = ( int * ) RelinquishMagickMemory ( graymap ) ; if ( bluemap != ( int * ) NULL ) bluemap = ( int * ) RelinquishMagickMemory ( bluemap ) ; if ( greenmap != ( int * ) NULL ) greenmap = ( int * ) RelinquishMagickMemory ( greenmap ) ; if ( redmap != ( int * ) NULL ) redmap = ( int * ) RelinquishMagickMemory ( redmap ) ; image = DestroyImageList ( image ) ; return ( GetFirstImageInList ( images ) ) ; } if ( info . depth != ( 1UL * MAGICKCORE_QUANTUM_DEPTH ) ) { QuantumAny range ; length = ( size_t ) ( GetQuantumRange ( info . depth ) + 1 ) ; if ( length > ( size_t ) GetBlobSize ( image ) ) ThrowDCMException ( CorruptImageError , ""InsufficientImageDataInFile"" ) ; if ( info . scale != ( Quantum * ) NULL ) info . scale = ( Quantum * ) RelinquishMagickMemory ( info . scale ) ; info . scale = ( Quantum * ) AcquireQuantumMemory ( MagickMax ( length , 256 ) , sizeof ( * info . scale ) ) ; if ( info . scale == ( Quantum * ) NULL ) ThrowDCMException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; ( void ) memset ( info . scale , 0 , MagickMax ( length , 256 ) * sizeof ( * info . scale ) ) ; range = GetQuantumRange ( info . depth ) ; for ( i = 0 ; i <= ( ssize_t ) GetQuantumRange ( info . depth ) ; i ++ ) info . scale [ i ] = ScaleAnyToQuantum ( ( size_t ) i , range ) ; } if ( image -> compression == RLECompression ) { unsigned int tag ; for ( i = 0 ; i < ( ssize_t ) stream_info -> remaining ; i ++ ) { int c ; c = ReadBlobByte ( image ) ; if ( c == EOF ) break ; } tag = ( ( unsigned int ) ReadBlobLSBShort ( image ) << 16 ) | ReadBlobLSBShort ( image ) ; ( void ) tag ; length = ( size_t ) ReadBlobLSBLong ( image ) ; if ( length > ( size_t ) GetBlobSize ( image ) ) ThrowDCMException ( CorruptImageError , ""InsufficientImageDataInFile"" ) ; stream_info -> offset_count = length >> 2 ; if ( stream_info -> offset_count != 0 ) { if ( stream_info -> offsets != ( ssize_t * ) NULL ) stream_info -> offsets = ( ssize_t * ) RelinquishMagickMemory ( stream_info -> offsets ) ; stream_info -> offsets = ( ssize_t * ) AcquireQuantumMemory ( stream_info -> offset_count , sizeof ( * stream_info -> offsets ) ) ; if ( stream_info -> offsets == ( ssize_t * ) NULL ) ThrowDCMException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; for ( i = 0 ; i < ( ssize_t ) stream_info -> offset_count ; i ++ ) { stream_info -> offsets [ i ] = ( ssize_t ) ReadBlobLSBSignedLong ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) break ; } offset = TellBlob ( image ) + 8 ; for ( i = 0 ; i < ( ssize_t ) stream_info -> offset_count ; i ++ ) stream_info -> offsets [ i ] += offset ; } } for ( scene = 0 ; scene < ( ssize_t ) number_scenes ; scene ++ ) { image -> columns = ( size_t ) width ; image -> rows = ( size_t ) height ; image -> depth = info . depth ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) break ; image -> colorspace = RGBColorspace ; ( void ) SetImageBackgroundColor ( image , exception ) ; if ( ( image -> colormap == ( PixelInfo * ) NULL ) && ( info . samples_per_pixel == 1 ) ) { int index ; size_t one ; one = 1 ; if ( colors == 0 ) colors = one << info . depth ; if ( AcquireImageColormap ( image , colors , exception ) == MagickFalse ) ThrowDCMException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; if ( redmap != ( int * ) NULL ) for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { index = redmap [ i ] ; if ( ( info . scale != ( Quantum * ) NULL ) && ( index >= 0 ) && ( index <= ( int ) info . max_value ) ) index = ( int ) info . scale [ index ] ; image -> colormap [ i ] . red = ( MagickRealType ) index ; } if ( greenmap != ( int * ) NULL ) for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { index = greenmap [ i ] ; if ( ( info . scale != ( Quantum * ) NULL ) && ( index >= 0 ) && ( index <= ( int ) info . max_value ) ) index = ( int ) info . scale [ index ] ; image -> colormap [ i ] . green = ( MagickRealType ) index ; } if ( bluemap != ( int * ) NULL ) for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { index = bluemap [ i ] ; if ( ( info . scale != ( Quantum * ) NULL ) && ( index >= 0 ) && ( index <= ( int ) info . max_value ) ) index = ( int ) info . scale [ index ] ; image -> colormap [ i ] . blue = ( MagickRealType ) index ; } if ( graymap != ( int * ) NULL ) for ( i = 0 ; i < ( ssize_t ) colors ; i ++ ) { index = graymap [ i ] ; if ( ( info . scale != ( Quantum * ) NULL ) && ( index >= 0 ) && ( index <= ( int ) info . max_value ) ) index = ( int ) info . scale [ index ] ; image -> colormap [ i ] . red = ( MagickRealType ) index ; image -> colormap [ i ] . green = ( MagickRealType ) index ; image -> colormap [ i ] . blue = ( MagickRealType ) index ; } } if ( image -> compression == RLECompression ) { unsigned int tag ; for ( i = 0 ; i < ( ssize_t ) stream_info -> remaining ; i ++ ) { int c ; c = ReadBlobByte ( image ) ; if ( c == EOF ) break ; } tag = ( ( unsigned int ) ReadBlobLSBShort ( image ) << 16 ) | ReadBlobLSBShort ( image ) ; stream_info -> remaining = ( size_t ) ReadBlobLSBLong ( image ) ; if ( ( tag != 0xFFFEE000 ) || ( stream_info -> remaining <= 64 ) || ( EOFBlob ( image ) != MagickFalse ) ) { if ( stream_info -> offsets != ( ssize_t * ) NULL ) stream_info -> offsets = ( ssize_t * ) RelinquishMagickMemory ( stream_info -> offsets ) ; ThrowDCMException ( CorruptImageError , ""ImproperImageHeader"" ) ; } stream_info -> count = 0 ; stream_info -> segment_count = ReadBlobLSBLong ( image ) ; for ( i = 0 ; i < 15 ; i ++ ) stream_info -> segments [ i ] = ( ssize_t ) ReadBlobLSBSignedLong ( image ) ; stream_info -> remaining -= 64 ; if ( stream_info -> segment_count > 1 ) { info . bytes_per_pixel = 1 ; info . depth = 8 ; if ( stream_info -> offset_count > 0 ) ( void ) SeekBlob ( image , ( MagickOffsetType ) stream_info -> offsets [ 0 ] + stream_info -> segments [ 0 ] , SEEK_SET ) ; } } if ( ( info . samples_per_pixel > 1 ) && ( image -> interlace == PlaneInterlace ) ) { register ssize_t x ; register Quantum * q ; ssize_t y ; for ( i = 0 ; i < ( ssize_t ) info . samples_per_pixel ; i ++ ) { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = GetAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { switch ( ( int ) i ) { case 0 : { SetPixelRed ( image , ScaleCharToQuantum ( ( unsigned char ) ReadDCMByte ( stream_info , image ) ) , q ) ; break ; } case 1 : { SetPixelGreen ( image , ScaleCharToQuantum ( ( unsigned char ) ReadDCMByte ( stream_info , image ) ) , q ) ; break ; } case 2 : { SetPixelBlue ( image , ScaleCharToQuantum ( ( unsigned char ) ReadDCMByte ( stream_info , image ) ) , q ) ; break ; } case 3 : { SetPixelAlpha ( image , ScaleCharToQuantum ( ( unsigned char ) ReadDCMByte ( stream_info , image ) ) , q ) ; break ; } default : break ; } q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } } else { const char * option ; option = GetImageOption ( image_info , ""dcm:display-range"" ) ; if ( option != ( const char * ) NULL ) { if ( LocaleCompare ( option , ""reset"" ) == 0 ) info . window_width = 0 ; } option = GetImageOption ( image_info , ""dcm:window"" ) ; if ( option != ( char * ) NULL ) { GeometryInfo geometry_info ; MagickStatusType flags ; flags = ParseGeometry ( option , & geometry_info ) ; if ( flags & RhoValue ) info . window_center = geometry_info . rho ; if ( flags & SigmaValue ) info . window_width = geometry_info . sigma ; info . rescale = MagickTrue ; } option = GetImageOption ( image_info , ""dcm:rescale"" ) ; if ( option != ( char * ) NULL ) info . rescale = IsStringTrue ( option ) ; if ( ( info . window_center != 0 ) && ( info . window_width == 0 ) ) info . window_width = info . window_center ; status = ReadDCMPixels ( image , & info , stream_info , MagickTrue , exception ) ; if ( ( status != MagickFalse ) && ( stream_info -> segment_count > 1 ) ) { if ( stream_info -> offset_count > 0 ) ( void ) SeekBlob ( image , ( MagickOffsetType ) stream_info -> offsets [ 0 ] + stream_info -> segments [ 1 ] , SEEK_SET ) ; ( void ) ReadDCMPixels ( image , & info , stream_info , MagickFalse , exception ) ; } } if ( SetImageGray ( image , exception ) != MagickFalse ) ( void ) SetImageColorspace ( image , GRAYColorspace , exception ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; if ( scene < ( ssize_t ) ( number_scenes - 1 ) ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { status = MagickFalse ; break ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } if ( TellBlob ( image ) < ( MagickOffsetType ) GetBlobSize ( image ) ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { status = MagickFalse ; break ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } if ( stream_info -> offsets != ( ssize_t * ) NULL ) stream_info -> offsets = ( ssize_t * ) RelinquishMagickMemory ( stream_info -> offsets ) ; stream_info = ( DCMStreamInfo * ) RelinquishMagickMemory ( stream_info ) ; if ( info . scale != ( Quantum * ) NULL ) info . scale = ( Quantum * ) RelinquishMagickMemory ( info . scale ) ; if ( graymap != ( int * ) NULL ) graymap = ( int * ) RelinquishMagickMemory ( graymap ) ; if ( bluemap != ( int * ) NULL ) bluemap = ( int * ) RelinquishMagickMemory ( bluemap ) ; if ( greenmap != ( int * ) NULL ) greenmap = ( int * ) RelinquishMagickMemory ( greenmap ) ; if ( redmap != ( int * ) NULL ) redmap = ( int * ) RelinquishMagickMemory ( redmap ) ; if ( image == ( Image * ) NULL ) return ( image ) ; ( void ) CloseBlob ( image ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; return ( GetFirstImageInList ( image ) ) ; } "," , message ) \\\n{ if ( info ) ) ; \\\n} char explicit_vr [ ; if ( length > ( size_t ) GetBlobSize ( image ) ) ThrowDCMException ( CorruptImageError , ""InsufficientImageDataInFile"" ) ; if ( ",ImageMagick@ImageMagick/16916c8979c32765c542e216b31cee2671b7afe7,CVE-2018-16644,https://github.com/ImageMagick/ImageMagick/commit/16916c8979c32765c542e216b31cee2671b7afe7,2018-09-06T22:29Z 1345,CWE-354,"CWE-354 void recovery_delete_character ( void ) { if ( strlen ( mnemonic ) > 0 ) { mnemonic [ strlen ( mnemonic ) - 1 ] = '\\0' ; } next_character ( ) ; } "," void ) { if ( ! recovery_started ) { recovery_abort ( ) ; fsm_sendFailure ( FailureType_Failure_UnexpectedMessage , ""NotinRecoverymode"" ) ; layoutHome ( ) ; return ; } ",keepkey@keepkey-firmware/769714fcb569e7a4faff9530a2d9ac1f9d6e5680,CVE-2019-18672,https://github.com/keepkey/keepkey-firmware/commit/769714fcb569e7a4faff9530a2d9ac1f9d6e5680,2019-12-06T18:15Z 1346,CWE-20,"CWE-20 error_t enc624j600UpdateMacAddrFilter ( NetInterface * interface ) { uint_t i ; uint_t k ; uint32_t crc ; uint16_t hashTable [ 4 ] ; MacFilterEntry * entry ; TRACE_DEBUG ( ""UpdatingMACfilter...\\r\\n"" ) ; osMemset ( hashTable , 0 , sizeof ( hashTable ) ) ; for ( i = 0 ; i < MAC_ADDR_FILTER_SIZE ; i ++ ) { entry = & interface -> macAddrFilter [ i ] ; if ( entry -> refCount > 0 ) { crc = enc624j600CalcCrc ( & entry -> addr , sizeof ( MacAddr ) ) ; k = ( crc >> 23 ) & 0x3F ; hashTable [ k / 16 ] |= ( 1 << ( k % 16 ) ) ; } } enc624j600WriteReg ( interface , ENC624J600_REG_EHT1 , hashTable [ 0 ] ) ; enc624j600WriteReg ( interface , ENC624J600_REG_EHT2 , hashTable [ 1 ] ) ; enc624j600WriteReg ( interface , ENC624J600_REG_EHT3 , hashTable [ 2 ] ) ; enc624j600WriteReg ( interface , ENC624J600_REG_EHT4 , hashTable [ 3 ] ) ; TRACE_DEBUG ( ""EHT1=%04"" PRIX16 ""\\r\\n"" , enc624j600ReadReg ( interface , ENC624J600_REG_EHT1 ) ) ; TRACE_DEBUG ( ""EHT2=%04"" PRIX16 ""\\r\\n"" , enc624j600ReadReg ( interface , ENC624J600_REG_EHT2 ) ) ; TRACE_DEBUG ( ""EHT3=%04"" PRIX16 ""\\r\\n"" , enc624j600ReadReg ( interface , ENC624J600_REG_EHT3 ) ) ; TRACE_DEBUG ( ""EHT4=%04"" PRIX16 ""\\r\\n"" , enc624j600ReadReg ( interface , ENC624J600_REG_EHT4 ) ) ; return NO_ERROR ; } "," ( interface , ENC624J600_EHT1 , hashTable [ 0 ] ) ; enc624j600WriteReg ( interface , ENC624J600_EHT2 , hashTable [ ( interface , ENC624J600_EHT3 , hashTable [ ( interface , ENC624J600_EHT4 , hashTable [ ( interface , ENC624J600_EHT1 ) ) ; ( interface , ENC624J600_EHT2 ) ) ; ( interface , ENC624J600_EHT3 ) ) ; ( interface , ENC624J600_EHT4 ) ) ; ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 1347,CWE-125,"CWE-125 static Image * ReadPDBImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { unsigned char attributes , tag [ 3 ] ; Image * image ; MagickBooleanType status ; PDBImage pdb_image ; PDBInfo pdb_info ; Quantum index ; register ssize_t x ; register Quantum * q ; register unsigned char * p ; size_t bits_per_pixel , num_pad_bytes , one , packets ; ssize_t count , img_offset , comment_offset = 0 , y ; unsigned char * pixels ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } count = ReadBlob ( image , sizeof ( pdb_info . name ) , ( unsigned char * ) pdb_info . name ) ; if ( count != sizeof ( pdb_info . name ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; pdb_info . attributes = ( short ) ReadBlobMSBShort ( image ) ; pdb_info . version = ( short ) ReadBlobMSBShort ( image ) ; pdb_info . create_time = ReadBlobMSBLong ( image ) ; pdb_info . modify_time = ReadBlobMSBLong ( image ) ; pdb_info . archive_time = ReadBlobMSBLong ( image ) ; pdb_info . modify_number = ReadBlobMSBLong ( image ) ; pdb_info . application_info = ReadBlobMSBLong ( image ) ; pdb_info . sort_info = ReadBlobMSBLong ( image ) ; ( void ) ReadBlob ( image , 4 , ( unsigned char * ) pdb_info . type ) ; ( void ) ReadBlob ( image , 4 , ( unsigned char * ) pdb_info . id ) ; pdb_info . seed = ReadBlobMSBLong ( image ) ; pdb_info . next_record = ReadBlobMSBLong ( image ) ; pdb_info . number_records = ( short ) ReadBlobMSBShort ( image ) ; if ( ( memcmp ( pdb_info . type , ""vIMG"" , 4 ) != 0 ) || ( memcmp ( pdb_info . id , ""View"" , 4 ) != 0 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( pdb_info . next_record != 0 ) ThrowReaderException ( CoderError , ""MultipleRecordListNotSupported"" ) ; img_offset = ( ssize_t ) ( ( int ) ReadBlobMSBLong ( image ) ) ; attributes = ( unsigned char ) ReadBlobByte ( image ) ; ( void ) attributes ; count = ReadBlob ( image , 3 , ( unsigned char * ) tag ) ; if ( count != 3 || memcmp ( tag , ""\\x6f\\x80\\x00"" , 3 ) != 0 ) ThrowReaderException ( CorruptImageError , ""CorruptImage"" ) ; if ( pdb_info . number_records > 1 ) { comment_offset = ( ssize_t ) ( ( int ) ReadBlobMSBLong ( image ) ) ; attributes = ( unsigned char ) ReadBlobByte ( image ) ; count = ReadBlob ( image , 3 , ( unsigned char * ) tag ) ; if ( count != 3 || memcmp ( tag , ""\\x6f\\x80\\x01"" , 3 ) != 0 ) ThrowReaderException ( CorruptImageError , ""CorruptImage"" ) ; } num_pad_bytes = ( size_t ) ( img_offset - TellBlob ( image ) ) ; while ( num_pad_bytes -- != 0 ) { int c ; c = ReadBlobByte ( image ) ; if ( c == EOF ) break ; } count = ReadBlob ( image , sizeof ( pdb_image . name ) , ( unsigned char * ) pdb_image . name ) ; if ( count != sizeof ( pdb_image . name ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; pdb_image . version = ReadBlobByte ( image ) ; pdb_image . type = ( unsigned char ) ( ( int ) ReadBlobByte ( image ) ) ; pdb_image . reserved_1 = ReadBlobMSBLong ( image ) ; pdb_image . note = ReadBlobMSBLong ( image ) ; pdb_image . x_last = ( short ) ReadBlobMSBShort ( image ) ; pdb_image . y_last = ( short ) ReadBlobMSBShort ( image ) ; pdb_image . reserved_2 = ReadBlobMSBLong ( image ) ; pdb_image . x_anchor = ReadBlobMSBShort ( image ) ; pdb_image . y_anchor = ReadBlobMSBShort ( image ) ; pdb_image . width = ( short ) ReadBlobMSBShort ( image ) ; pdb_image . height = ( short ) ReadBlobMSBShort ( image ) ; image -> columns = ( size_t ) pdb_image . width ; image -> rows = ( size_t ) pdb_image . height ; image -> depth = 8 ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; image -> storage_class = PseudoClass ; bits_per_pixel = pdb_image . type == 0 ? 2UL : pdb_image . type == 2 ? 4UL : 1UL ; one = 1 ; if ( AcquireImageColormap ( image , one << bits_per_pixel , exception ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; if ( image_info -> ping != MagickFalse ) { ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } packets = ( bits_per_pixel * image -> columns + 7 ) / 8 ; pixels = ( unsigned char * ) AcquireQuantumMemory ( packets + 256UL , image -> rows * sizeof ( * pixels ) ) ; if ( pixels == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; switch ( pdb_image . version & 0x07 ) { case 0 : { image -> compression = NoCompression ; count = ( ssize_t ) ReadBlob ( image , packets * image -> rows , pixels ) ; break ; } case 1 : { image -> compression = RLECompression ; if ( ! DecodeImage ( image , pixels , packets * image -> rows ) ) ThrowReaderException ( CorruptImageError , ""RLEDecoderError"" ) ; break ; } default : ThrowReaderException ( CorruptImageError , ""UnrecognizedImageCompressionType"" ) ; } p = pixels ; switch ( bits_per_pixel ) { case 1 : { int bit ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ( ssize_t ) image -> columns - 7 ) ; x += 8 ) { for ( bit = 0 ; bit < 8 ; bit ++ ) { index = ( Quantum ) ( * p & ( 0x80 >> bit ) ? 0x00 : 0x01 ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } ( void ) SyncImage ( image , exception ) ; break ; } case 2 : { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns - 3 ; x += 4 ) { index = ConstrainColormapIndex ( image , 3UL - ( ( * p >> 6 ) & 0x03 ) , exception ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; index = ConstrainColormapIndex ( image , 3UL - ( ( * p >> 4 ) & 0x03 ) , exception ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; index = ConstrainColormapIndex ( image , 3UL - ( ( * p >> 2 ) & 0x03 ) , exception ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; index = ConstrainColormapIndex ( image , 3UL - ( ( * p ) & 0x03 ) , exception ) ; SetPixelIndex ( image , index , q ) ; p ++ ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } ( void ) SyncImage ( image , exception ) ; break ; } case 4 : { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns - 1 ; x += 2 ) { index = ConstrainColormapIndex ( image , 15UL - ( ( * p >> 4 ) & 0x0f ) , exception ) ; SetPixelIndex ( image , index , q ) ; q += GetPixelChannels ( image ) ; index = ConstrainColormapIndex ( image , 15UL - ( ( * p ) & 0x0f ) , exception ) ; SetPixelIndex ( image , index , q ) ; p ++ ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } ( void ) SyncImage ( image , exception ) ; break ; } default : ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; } pixels = ( unsigned char * ) RelinquishMagickMemory ( pixels ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; if ( pdb_info . number_records > 1 ) { char * comment ; int c ; register char * p ; size_t length ; num_pad_bytes = ( size_t ) ( comment_offset - TellBlob ( image ) ) ; while ( num_pad_bytes -- ) ReadBlobByte ( image ) ; c = ReadBlobByte ( image ) ; length = MagickPathExtent ; comment = AcquireString ( ( char * ) NULL ) ; for ( p = comment ; c != EOF ; p ++ ) { if ( ( size_t ) ( p - comment + MagickPathExtent ) >= length ) { * p = '\\0' ; length <<= 1 ; length += MagickPathExtent ; comment = ( char * ) ResizeQuantumMemory ( comment , length + MagickPathExtent , sizeof ( * comment ) ) ; if ( comment == ( char * ) NULL ) break ; p = comment + strlen ( comment ) ; } * p = c ; c = ReadBlobByte ( image ) ; } * p = '\\0' ; if ( comment == ( char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; ( void ) SetImageProperty ( image , ""comment"" , comment , exception ) ; comment = DestroyString ( comment ) ; } ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," ( packets + 257UL , image -> ",ImageMagick@ImageMagick/6d202a0514fb6a406456b8b728cde776becb25f8,CVE-2016-7537,https://github.com/ImageMagick/ImageMagick/commit/6d202a0514fb6a406456b8b728cde776becb25f8,2017-04-19T14:59Z 1348,CWE-416,"CWE-416 void processRequest ( struct reqelem * req ) { ssize_t n ; unsigned int l , m ; unsigned char buf [ 2048 ] ; const unsigned char * p ; int type ; struct device * d = devlist ; unsigned char rbuf [ 4096 ] ; unsigned char * rp = rbuf + 1 ; unsigned char nrep = 0 ; time_t t ; struct service * newserv = NULL ; struct service * serv ; n = read ( req -> socket , buf , sizeof ( buf ) ) ; if ( n < 0 ) { if ( errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK ) return ; syslog ( LOG_ERR , ""(s=%d)processRequest():read():%m"" , req -> socket ) ; goto error ; } if ( n == 0 ) { syslog ( LOG_INFO , ""(s=%d)requestconnectionclosed"" , req -> socket ) ; goto error ; } t = time ( NULL ) ; type = buf [ 0 ] ; p = buf + 1 ; DECODELENGTH_CHECKLIMIT ( l , p , buf + n ) ; if ( p + l > buf + n ) { syslog ( LOG_WARNING , ""badrequest(lengthencoding)"" ) ; goto error ; } if ( l == 0 && type != 3 ) { syslog ( LOG_WARNING , ""badrequest(length=0)"" ) ; goto error ; } syslog ( LOG_INFO , ""(s=%d)requesttype=%dstr=\'%.*s\'"" , req -> socket , type , l , p ) ; switch ( type ) { case 1 : case 2 : case 3 : while ( d && ( nrep < 255 ) ) { if ( d -> t < t ) { syslog ( LOG_INFO , ""outdateddevice"" ) ; } else { if ( d -> headers [ HEADER_LOCATION ] . l + d -> headers [ HEADER_NT ] . l + d -> headers [ HEADER_USN ] . l + 6 + ( rp - rbuf ) >= ( int ) sizeof ( rbuf ) ) break ; if ( ( type == 1 && 0 == memcmp ( d -> headers [ HEADER_NT ] . p , p , l ) ) || ( type == 2 && 0 == memcmp ( d -> headers [ HEADER_USN ] . p , p , l ) ) || ( type == 3 ) ) { m = d -> headers [ HEADER_LOCATION ] . l ; CODELENGTH ( m , rp ) ; memcpy ( rp , d -> headers [ HEADER_LOCATION ] . p , d -> headers [ HEADER_LOCATION ] . l ) ; rp += d -> headers [ HEADER_LOCATION ] . l ; m = d -> headers [ HEADER_NT ] . l ; CODELENGTH ( m , rp ) ; memcpy ( rp , d -> headers [ HEADER_NT ] . p , d -> headers [ HEADER_NT ] . l ) ; rp += d -> headers [ HEADER_NT ] . l ; m = d -> headers [ HEADER_USN ] . l ; CODELENGTH ( m , rp ) ; memcpy ( rp , d -> headers [ HEADER_USN ] . p , d -> headers [ HEADER_USN ] . l ) ; rp += d -> headers [ HEADER_USN ] . l ; nrep ++ ; } } d = d -> next ; } for ( serv = servicelisthead . lh_first ; serv && ( nrep < 255 ) ; serv = serv -> entries . le_next ) { if ( strlen ( serv -> location ) + strlen ( serv -> st ) + strlen ( serv -> usn ) + 6 + ( rp - rbuf ) >= sizeof ( rbuf ) ) break ; if ( ( type == 1 && 0 == strncmp ( serv -> st , ( const char * ) p , l ) ) || ( type == 2 && 0 == strncmp ( serv -> usn , ( const char * ) p , l ) ) || ( type == 3 ) ) { m = strlen ( serv -> location ) ; CODELENGTH ( m , rp ) ; memcpy ( rp , serv -> location , m ) ; rp += m ; m = strlen ( serv -> st ) ; CODELENGTH ( m , rp ) ; memcpy ( rp , serv -> st , m ) ; rp += m ; m = strlen ( serv -> usn ) ; CODELENGTH ( m , rp ) ; memcpy ( rp , serv -> usn , m ) ; rp += m ; nrep ++ ; } } rbuf [ 0 ] = nrep ; syslog ( LOG_DEBUG , ""(s=%d)response:%ddevice%s"" , req -> socket , nrep , ( nrep > 1 ) ? ""s"" : """" ) ; if ( write ( req -> socket , rbuf , rp - rbuf ) < 0 ) { syslog ( LOG_ERR , ""(s=%d)write:%m"" , req -> socket ) ; goto error ; } break ; case 4 : newserv = malloc ( sizeof ( struct service ) ) ; if ( ! newserv ) { syslog ( LOG_ERR , ""cannotallocatememory"" ) ; goto error ; } if ( containsForbiddenChars ( p , l ) ) { syslog ( LOG_ERR , ""badrequest(stcontainsforbiddenchars)"" ) ; goto error ; } newserv -> st = malloc ( l + 1 ) ; if ( ! newserv -> st ) { syslog ( LOG_ERR , ""cannotallocatememory"" ) ; goto error ; } memcpy ( newserv -> st , p , l ) ; newserv -> st [ l ] = '\\0' ; p += l ; if ( p >= buf + n ) { syslog ( LOG_WARNING , ""badrequest(missingusn)"" ) ; goto error ; } DECODELENGTH_CHECKLIMIT ( l , p , buf + n ) ; if ( p + l > buf + n ) { syslog ( LOG_WARNING , ""badrequest(lengthencoding)"" ) ; goto error ; } if ( containsForbiddenChars ( p , l ) ) { syslog ( LOG_ERR , ""badrequest(usncontainsforbiddenchars)"" ) ; goto error ; } syslog ( LOG_INFO , ""usn=\'%.*s\'"" , l , p ) ; newserv -> usn = malloc ( l + 1 ) ; if ( ! newserv -> usn ) { syslog ( LOG_ERR , ""cannotallocatememory"" ) ; goto error ; } memcpy ( newserv -> usn , p , l ) ; newserv -> usn [ l ] = '\\0' ; p += l ; DECODELENGTH_CHECKLIMIT ( l , p , buf + n ) ; if ( p + l > buf + n ) { syslog ( LOG_WARNING , ""badrequest(lengthencoding)"" ) ; goto error ; } if ( containsForbiddenChars ( p , l ) ) { syslog ( LOG_ERR , ""badrequest(servercontainsforbiddenchars)"" ) ; goto error ; } syslog ( LOG_INFO , ""server=\'%.*s\'"" , l , p ) ; newserv -> server = malloc ( l + 1 ) ; if ( ! newserv -> server ) { syslog ( LOG_ERR , ""cannotallocatememory"" ) ; goto error ; } memcpy ( newserv -> server , p , l ) ; newserv -> server [ l ] = '\\0' ; p += l ; DECODELENGTH_CHECKLIMIT ( l , p , buf + n ) ; if ( p + l > buf + n ) { syslog ( LOG_WARNING , ""badrequest(lengthencoding)"" ) ; goto error ; } if ( containsForbiddenChars ( p , l ) ) { syslog ( LOG_ERR , ""badrequest(locationcontainsforbiddenchars)"" ) ; goto error ; } syslog ( LOG_INFO , ""location=\'%.*s\'"" , l , p ) ; newserv -> location = malloc ( l + 1 ) ; if ( ! newserv -> location ) { syslog ( LOG_ERR , ""cannotallocatememory"" ) ; goto error ; } memcpy ( newserv -> location , p , l ) ; newserv -> location [ l ] = '\\0' ; for ( serv = servicelisthead . lh_first ; serv ; serv = serv -> entries . le_next ) { if ( 0 == strcmp ( newserv -> usn , serv -> usn ) && 0 == strcmp ( newserv -> st , serv -> st ) ) { syslog ( LOG_INFO , ""Serviceallreadyinthelist.Updating..."" ) ; free ( newserv -> st ) ; free ( newserv -> usn ) ; free ( serv -> server ) ; serv -> server = newserv -> server ; free ( serv -> location ) ; serv -> location = newserv -> location ; free ( newserv ) ; newserv = NULL ; return ; } } LIST_INSERT_HEAD ( & servicelisthead , newserv , entries ) ; newserv = NULL ; break ; default : syslog ( LOG_WARNING , ""Unknownrequesttype%d"" , type ) ; rbuf [ 0 ] = '\\0' ; if ( write ( req -> socket , rbuf , 1 ) < 0 ) { syslog ( LOG_ERR , ""(s=%d)write:%m"" , req -> socket ) ; goto error ; } } return ; error : if ( newserv ) { free ( newserv -> st ) ; free ( newserv -> usn ) ; free ( newserv -> server ) ; free ( newserv -> location ) ; free ( newserv ) ; newserv = NULL ; } close ( req -> socket ) ; req -> socket = - 1 ; return ; } "," error ; } memset ( newserv , 0 , sizeof ( struct service ) ) ; ",miniupnp@miniupnp/140ee8d2204b383279f854802b27bdb41c1d5d1a,CVE-2016-3179,https://github.com/miniupnp/miniupnp/commit/140ee8d2204b383279f854802b27bdb41c1d5d1a,2017-03-24T15:59Z 1349,CWE-000,"CWE-000 WORD32 ihevcd_ref_list ( codec_t * ps_codec , pps_t * ps_pps , sps_t * ps_sps , slice_header_t * ps_slice_hdr ) { WORD32 i ; WORD32 st_rps_idx ; WORD32 num_neg_pics , num_pos_pics ; WORD8 * pi1_used ; WORD16 * pi2_delta_poc ; UWORD32 u4_max_poc_lsb ; pic_buf_t * ps_pic_buf ; mv_buf_t * ps_mv_buf ; UWORD32 r_idx ; dpb_mgr_t * ps_dpb_mgr = ( dpb_mgr_t * ) ps_codec -> pv_dpb_mgr ; buf_mgr_t * ps_mv_buf_mgr = ( buf_mgr_t * ) ps_codec -> pv_mv_buf_mgr ; WORD32 ai4_poc_st_curr_before [ MAX_DPB_SIZE ] , ai4_poc_st_foll [ MAX_DPB_SIZE ] , ai4_poc_st_curr_after [ MAX_DPB_SIZE ] ; WORD32 ai4_poc_lt_curr [ MAX_DPB_SIZE ] , ai4_poc_lt_foll [ MAX_DPB_SIZE ] ; UWORD32 u4_num_st_curr_before , u4_num_st_foll , u4_num_st_curr_after , u4_num_lt_curr , u4_num_lt_foll ; UWORD32 u4_num_total_curr ; WORD8 ai1_curr_delta_poc_msb_present_flag [ MAX_DPB_SIZE ] , ai1_foll_delta_poc_msb_present_flag [ MAX_DPB_SIZE ] ; pic_buf_t * as_ref_pic_lt_curr [ MAX_DPB_SIZE ] ; pic_buf_t * as_ref_pic_lt_foll [ MAX_DPB_SIZE ] ; pic_buf_t * as_ref_pic_st_curr_after [ MAX_DPB_SIZE ] ; pic_buf_t * as_ref_pic_st_curr_before [ MAX_DPB_SIZE ] ; pic_buf_t * as_ref_pic_st_foll [ MAX_DPB_SIZE ] ; pic_buf_t * as_ref_pic_list_temp0 [ MAX_DPB_SIZE ] , * as_ref_pic_list_temp1 [ MAX_DPB_SIZE ] ; UWORD32 u4_num_rps_curr_temp_list0 , u4_num_rps_curr_temp_list1 ; WORD32 i4_pic_order_cnt_val ; WORD32 i4_poc_lt ; UNUSED ( as_ref_pic_lt_foll ) ; UNUSED ( as_ref_pic_st_foll ) ; UNUSED ( ps_pps ) ; RETURN_IF_NAL_INFO ; u4_max_poc_lsb = ( 1 << ps_sps -> i1_log2_max_pic_order_cnt_lsb ) ; i4_pic_order_cnt_val = ps_slice_hdr -> i4_abs_pic_order_cnt ; if ( 1 == ps_slice_hdr -> i1_short_term_ref_pic_set_sps_flag ) { st_rps_idx = ps_slice_hdr -> i1_short_term_ref_pic_set_idx ; num_neg_pics = ps_sps -> as_stref_picset [ st_rps_idx ] . i1_num_neg_pics ; num_pos_pics = ps_sps -> as_stref_picset [ st_rps_idx ] . i1_num_pos_pics ; pi1_used = ps_sps -> as_stref_picset [ st_rps_idx ] . ai1_used ; pi2_delta_poc = ps_sps -> as_stref_picset [ st_rps_idx ] . ai2_delta_poc ; } else { st_rps_idx = ps_sps -> i1_num_short_term_ref_pic_sets ; num_neg_pics = ps_slice_hdr -> s_stref_picset . i1_num_neg_pics ; num_pos_pics = ps_slice_hdr -> s_stref_picset . i1_num_pos_pics ; pi1_used = ps_slice_hdr -> s_stref_picset . ai1_used ; pi2_delta_poc = ps_slice_hdr -> s_stref_picset . ai2_delta_poc ; } u4_num_st_curr_before = 0 ; u4_num_st_foll = 0 ; for ( i = 0 ; i < num_neg_pics ; i ++ ) { if ( pi1_used [ i ] ) { ai4_poc_st_curr_before [ u4_num_st_curr_before ] = i4_pic_order_cnt_val + pi2_delta_poc [ i ] ; u4_num_st_curr_before ++ ; } else { ai4_poc_st_foll [ u4_num_st_foll ] = i4_pic_order_cnt_val + pi2_delta_poc [ i ] ; u4_num_st_foll ++ ; } } u4_num_st_curr_after = 0 ; for ( i = num_neg_pics ; i < num_neg_pics + num_pos_pics ; i ++ ) { if ( pi1_used [ i ] ) { ai4_poc_st_curr_after [ u4_num_st_curr_after ] = i4_pic_order_cnt_val + pi2_delta_poc [ i ] ; u4_num_st_curr_after ++ ; } else { ai4_poc_st_foll [ u4_num_st_foll ] = i4_pic_order_cnt_val + pi2_delta_poc [ i ] ; u4_num_st_foll ++ ; } } u4_num_lt_curr = 0 ; u4_num_lt_foll = 0 ; for ( i = 0 ; i < ps_slice_hdr -> i1_num_long_term_sps + ps_slice_hdr -> i1_num_long_term_pics ; i ++ ) { i4_poc_lt = ps_slice_hdr -> ai4_poc_lsb_lt [ i ] ; if ( ps_slice_hdr -> ai1_delta_poc_msb_present_flag [ i ] ) { i4_poc_lt += i4_pic_order_cnt_val - ps_slice_hdr -> ai1_delta_poc_msb_cycle_lt [ i ] * u4_max_poc_lsb - ps_slice_hdr -> i4_pic_order_cnt_lsb ; } if ( ps_slice_hdr -> ai1_used_by_curr_pic_lt_flag [ i ] ) { ai4_poc_lt_curr [ u4_num_lt_curr ] = i4_poc_lt ; ai1_curr_delta_poc_msb_present_flag [ u4_num_lt_curr ] = ps_slice_hdr -> ai1_delta_poc_msb_present_flag [ i ] ; u4_num_lt_curr ++ ; } else { ai4_poc_lt_foll [ u4_num_lt_foll ] = i4_poc_lt ; ai1_foll_delta_poc_msb_present_flag [ u4_num_lt_foll ] = ps_slice_hdr -> ai1_delta_poc_msb_present_flag [ i ] ; u4_num_lt_foll ++ ; } } u4_num_total_curr = u4_num_lt_curr + u4_num_st_curr_after + u4_num_st_curr_before ; if ( 0 == ps_codec -> i4_pic_present ) { for ( i = 0 ; i < MAX_DPB_BUFS ; i ++ ) { if ( ps_dpb_mgr -> as_dpb_info [ i ] . ps_pic_buf ) ps_dpb_mgr -> as_dpb_info [ i ] . ps_pic_buf -> u1_used_as_ref = UNUSED_FOR_REF ; } } for ( i = 0 ; i < ( WORD32 ) u4_num_lt_curr ; i ++ ) { if ( 0 == ai1_curr_delta_poc_msb_present_flag [ i ] ) { ps_pic_buf = ihevc_dpb_mgr_get_ref_by_poc_lsb ( ps_dpb_mgr , ai4_poc_lt_curr [ i ] ) ; if ( NULL != ps_pic_buf ) ps_pic_buf -> u1_used_as_ref = LONG_TERM_REF ; as_ref_pic_lt_curr [ i ] = ps_pic_buf ; } else { ps_pic_buf = ihevc_dpb_mgr_get_ref_by_poc ( ps_dpb_mgr , ai4_poc_lt_curr [ i ] ) ; if ( NULL != ps_pic_buf ) ps_pic_buf -> u1_used_as_ref = LONG_TERM_REF ; as_ref_pic_lt_curr [ i ] = ps_pic_buf ; } } for ( i = 0 ; i < ( WORD32 ) u4_num_lt_foll ; i ++ ) { if ( 0 == ai1_foll_delta_poc_msb_present_flag [ i ] ) { ps_pic_buf = ihevc_dpb_mgr_get_ref_by_poc_lsb ( ps_dpb_mgr , ai4_poc_lt_foll [ i ] ) ; if ( NULL != ps_pic_buf ) ps_pic_buf -> u1_used_as_ref = LONG_TERM_REF ; as_ref_pic_lt_foll [ i ] = ps_pic_buf ; } else { ps_pic_buf = ihevc_dpb_mgr_get_ref_by_poc ( ps_dpb_mgr , ai4_poc_lt_foll [ i ] ) ; if ( NULL != ps_pic_buf ) ps_pic_buf -> u1_used_as_ref = LONG_TERM_REF ; as_ref_pic_lt_foll [ i ] = ps_pic_buf ; } } for ( i = 0 ; i < ( WORD32 ) u4_num_st_curr_before ; i ++ ) { ps_pic_buf = ihevc_dpb_mgr_get_ref_by_poc ( ps_dpb_mgr , ai4_poc_st_curr_before [ i ] ) ; if ( NULL != ps_pic_buf ) ps_pic_buf -> u1_used_as_ref = SHORT_TERM_REF ; as_ref_pic_st_curr_before [ i ] = ps_pic_buf ; } for ( i = 0 ; i < ( WORD32 ) u4_num_st_curr_after ; i ++ ) { ps_pic_buf = ihevc_dpb_mgr_get_ref_by_poc ( ps_dpb_mgr , ai4_poc_st_curr_after [ i ] ) ; if ( NULL != ps_pic_buf ) ps_pic_buf -> u1_used_as_ref = SHORT_TERM_REF ; as_ref_pic_st_curr_after [ i ] = ps_pic_buf ; } for ( i = 0 ; i < ( WORD32 ) u4_num_st_foll ; i ++ ) { ps_pic_buf = ihevc_dpb_mgr_get_ref_by_poc ( ps_dpb_mgr , ai4_poc_st_foll [ i ] ) ; if ( NULL != ps_pic_buf ) ps_pic_buf -> u1_used_as_ref = SHORT_TERM_REF ; as_ref_pic_st_foll [ i ] = ps_pic_buf ; } u4_num_rps_curr_temp_list0 = ( WORD32 ) u4_num_total_curr > ps_slice_hdr -> i1_num_ref_idx_l0_active ? ( WORD32 ) u4_num_total_curr : ps_slice_hdr -> i1_num_ref_idx_l0_active ; r_idx = 0 ; if ( ( PSLICE == ps_slice_hdr -> i1_slice_type ) || ( BSLICE == ps_slice_hdr -> i1_slice_type ) ) { while ( r_idx < u4_num_rps_curr_temp_list0 ) { for ( i = 0 ; ( i < ( WORD32 ) u4_num_st_curr_before ) && ( r_idx < u4_num_rps_curr_temp_list0 ) ; r_idx ++ , i ++ ) { if ( NULL == as_ref_pic_st_curr_before [ i ] ) { as_ref_pic_st_curr_before [ i ] = ihevc_dpb_mgr_get_ref_by_nearest_poc ( ps_dpb_mgr , ai4_poc_st_curr_before [ i ] ) ; } as_ref_pic_list_temp0 [ r_idx ] = as_ref_pic_st_curr_before [ i ] ; } for ( i = 0 ; ( i < ( WORD32 ) u4_num_st_curr_after ) && ( r_idx < u4_num_rps_curr_temp_list0 ) ; r_idx ++ , i ++ ) { if ( NULL == as_ref_pic_st_curr_after [ i ] ) { as_ref_pic_st_curr_after [ i ] = ihevc_dpb_mgr_get_ref_by_nearest_poc ( ps_dpb_mgr , ai4_poc_st_curr_after [ i ] ) ; } as_ref_pic_list_temp0 [ r_idx ] = as_ref_pic_st_curr_after [ i ] ; } for ( i = 0 ; ( i < ( WORD32 ) u4_num_lt_curr ) && ( r_idx < u4_num_rps_curr_temp_list0 ) ; r_idx ++ , i ++ ) { if ( NULL == as_ref_pic_lt_curr [ i ] ) { as_ref_pic_lt_curr [ i ] = ihevc_dpb_mgr_get_ref_by_nearest_poc ( ps_dpb_mgr , ai4_poc_lt_curr [ i ] ) ; } as_ref_pic_list_temp0 [ r_idx ] = as_ref_pic_lt_curr [ i ] ; } } for ( r_idx = 0 ; ( WORD32 ) r_idx < ps_slice_hdr -> i1_num_ref_idx_l0_active ; r_idx ++ ) { pic_buf_t * ps_pic_buf ; ps_slice_hdr -> as_ref_pic_list0 [ r_idx ] . pv_pic_buf = ps_slice_hdr -> s_rplm . i1_ref_pic_list_modification_flag_l0 ? ( void * ) as_ref_pic_list_temp0 [ ps_slice_hdr -> s_rplm . i1_list_entry_l0 [ r_idx ] ] : ( void * ) as_ref_pic_list_temp0 [ r_idx ] ; ps_pic_buf = ( pic_buf_t * ) ps_slice_hdr -> as_ref_pic_list0 [ r_idx ] . pv_pic_buf ; if ( ps_pic_buf == NULL ) return IHEVCD_REF_PIC_NOT_FOUND ; ps_mv_buf = ihevcd_mv_mgr_get_poc ( ps_mv_buf_mgr , ps_pic_buf -> i4_abs_poc ) ; ps_slice_hdr -> as_ref_pic_list0 [ r_idx ] . pv_mv_buf = ps_mv_buf ; } if ( ps_slice_hdr -> i1_slice_type == BSLICE ) { u4_num_rps_curr_temp_list1 = ( WORD32 ) u4_num_total_curr > ps_slice_hdr -> i1_num_ref_idx_l1_active ? ( WORD32 ) u4_num_total_curr : ps_slice_hdr -> i1_num_ref_idx_l1_active ; r_idx = 0 ; while ( r_idx < u4_num_rps_curr_temp_list1 ) { for ( i = 0 ; ( i < ( WORD32 ) u4_num_st_curr_after ) && ( r_idx < u4_num_rps_curr_temp_list1 ) ; r_idx ++ , i ++ ) { if ( NULL == as_ref_pic_st_curr_after [ i ] ) { as_ref_pic_st_curr_after [ i ] = ihevc_dpb_mgr_get_ref_by_nearest_poc ( ps_dpb_mgr , ai4_poc_st_curr_after [ i ] ) ; } as_ref_pic_list_temp1 [ r_idx ] = as_ref_pic_st_curr_after [ i ] ; } for ( i = 0 ; ( i < ( WORD32 ) u4_num_st_curr_before ) && ( r_idx < u4_num_rps_curr_temp_list1 ) ; r_idx ++ , i ++ ) { if ( NULL == as_ref_pic_st_curr_before [ i ] ) { as_ref_pic_st_curr_before [ i ] = ihevc_dpb_mgr_get_ref_by_nearest_poc ( ps_dpb_mgr , ai4_poc_st_curr_before [ i ] ) ; } as_ref_pic_list_temp1 [ r_idx ] = as_ref_pic_st_curr_before [ i ] ; } for ( i = 0 ; ( i < ( WORD32 ) u4_num_lt_curr ) && ( r_idx < u4_num_rps_curr_temp_list1 ) ; r_idx ++ , i ++ ) { if ( NULL == as_ref_pic_lt_curr [ i ] ) { as_ref_pic_lt_curr [ i ] = ihevc_dpb_mgr_get_ref_by_nearest_poc ( ps_dpb_mgr , ai4_poc_lt_curr [ i ] ) ; } as_ref_pic_list_temp1 [ r_idx ] = as_ref_pic_lt_curr [ i ] ; } } for ( r_idx = 0 ; ( WORD32 ) r_idx < ps_slice_hdr -> i1_num_ref_idx_l1_active ; r_idx ++ ) { pic_buf_t * ps_pic_buf ; ps_slice_hdr -> as_ref_pic_list1 [ r_idx ] . pv_pic_buf = ps_slice_hdr -> s_rplm . i1_ref_pic_list_modification_flag_l1 ? ( void * ) as_ref_pic_list_temp1 [ ps_slice_hdr -> s_rplm . i1_list_entry_l1 [ r_idx ] ] : ( void * ) as_ref_pic_list_temp1 [ r_idx ] ; ps_pic_buf = ( pic_buf_t * ) ps_slice_hdr -> as_ref_pic_list1 [ r_idx ] . pv_pic_buf ; if ( ps_pic_buf == NULL ) return IHEVCD_REF_PIC_NOT_FOUND ; ps_mv_buf = ihevcd_mv_mgr_get_poc ( ps_mv_buf_mgr , ps_pic_buf -> i4_abs_poc ) ; ps_slice_hdr -> as_ref_pic_list1 [ r_idx ] . pv_mv_buf = ps_mv_buf ; } } } DEBUG_PRINT_REF_LIST_POCS ( i4_pic_order_cnt_val , ps_slice_hdr , ps_dpb_mgr , u4_num_st_curr_before , u4_num_st_curr_after , u4_num_st_foll , u4_num_lt_curr , u4_num_lt_foll , ai4_poc_st_curr_before , ai4_poc_st_curr_after , ai4_poc_st_foll , ai4_poc_lt_curr , ai4_poc_lt_foll ) ; for ( i = 0 ; i < MAX_DPB_BUFS ; i ++ ) { if ( ( ps_dpb_mgr -> as_dpb_info [ i ] . ps_pic_buf ) && ( UNUSED_FOR_REF == ps_dpb_mgr -> as_dpb_info [ i ] . ps_pic_buf -> u1_used_as_ref ) ) { pic_buf_t * ps_pic_buf = ps_dpb_mgr -> as_dpb_info [ i ] . ps_pic_buf ; mv_buf_t * ps_mv_buf ; ihevc_dpb_mgr_del_ref ( ps_dpb_mgr , ( buf_mgr_t * ) ps_codec -> pv_pic_buf_mgr , ps_pic_buf -> i4_abs_poc ) ; ps_mv_buf = ( mv_buf_t * ) ps_codec -> ps_mv_buf ; for ( i = 0 ; i < BUF_MGR_MAX_CNT ; i ++ ) { if ( ps_mv_buf && ps_mv_buf -> i4_abs_poc == ps_pic_buf -> i4_abs_poc ) { ihevc_buf_mgr_release ( ( buf_mgr_t * ) ps_codec -> pv_mv_buf_mgr , i , BUF_MGR_REF ) ; break ; } ps_mv_buf ++ ; } } } return IHEVCD_SUCCESS ; } "," { WORD32 i , j ; for ( j = 0 ; j < ps_codec -> i4_max_dpb_size ; j ++ ) { -> pv_mv_buf_mgr , j , BUF_MGR_REF ) ",external@libhevc/913d9e8d93d6b81bb8eac3fc2c1426651f5b259d,CVE-2017-0642,https://android.googlesource.com/platform/external/libhevc/+/913d9e8d93d6b81bb8eac3fc2c1426651f5b259d,2017-06-14T13:29Z 1350,CWE-264,"CWE-264 long arch_ptrace ( struct task_struct * child , long request , unsigned long addr , unsigned long data ) { int ret ; unsigned long __user * datap = ( unsigned long __user * ) data ; switch ( request ) { case PTRACE_PEEKUSR : ret = ptrace_read_user ( child , addr , datap ) ; break ; case PTRACE_POKEUSR : ret = ptrace_write_user ( child , addr , data ) ; break ; case PTRACE_GETREGS : ret = copy_regset_to_user ( child , & user_arm_view , REGSET_GPR , 0 , sizeof ( struct pt_regs ) , datap ) ; break ; case PTRACE_SETREGS : ret = copy_regset_from_user ( child , & user_arm_view , REGSET_GPR , 0 , sizeof ( struct pt_regs ) , datap ) ; break ; case PTRACE_GETFPREGS : ret = copy_regset_to_user ( child , & user_arm_view , REGSET_FPR , 0 , sizeof ( union fp_state ) , datap ) ; break ; case PTRACE_SETFPREGS : ret = copy_regset_from_user ( child , & user_arm_view , REGSET_FPR , 0 , sizeof ( union fp_state ) , datap ) ; break ; # ifdef CONFIG_IWMMXT case PTRACE_GETWMMXREGS : ret = ptrace_getwmmxregs ( child , datap ) ; break ; case PTRACE_SETWMMXREGS : ret = ptrace_setwmmxregs ( child , datap ) ; break ; # endif case PTRACE_GET_THREAD_AREA : ret = put_user ( task_thread_info ( child ) -> tp_value , datap ) ; break ; case PTRACE_SET_SYSCALL : task_thread_info ( child ) -> syscall = data ; ret = 0 ; break ; # ifdef CONFIG_CRUNCH case PTRACE_GETCRUNCHREGS : ret = ptrace_getcrunchregs ( child , datap ) ; break ; case PTRACE_SETCRUNCHREGS : ret = ptrace_setcrunchregs ( child , datap ) ; break ; # endif # ifdef CONFIG_VFP case PTRACE_GETVFPREGS : ret = copy_regset_to_user ( child , & user_arm_view , REGSET_VFP , 0 , ARM_VFPREGS_SIZE , datap ) ; break ; case PTRACE_SETVFPREGS : ret = copy_regset_from_user ( child , & user_arm_view , REGSET_VFP , 0 , ARM_VFPREGS_SIZE , datap ) ; break ; # endif # ifdef CONFIG_HAVE_HW_BREAKPOINT case PTRACE_GETHBPREGS : if ( ptrace_get_breakpoints ( child ) < 0 ) return - ESRCH ; ret = ptrace_gethbpregs ( child , addr , ( unsigned long __user * ) data ) ; ptrace_put_breakpoints ( child ) ; break ; case PTRACE_SETHBPREGS : if ( ptrace_get_breakpoints ( child ) < 0 ) return - ESRCH ; ret = ptrace_sethbpregs ( child , addr , ( unsigned long __user * ) data ) ; ptrace_put_breakpoints ( child ) ; break ; # endif default : ret = ptrace_request ( child , request , addr , data ) ; break ; } return ret ; } "," ) -> tp_value [ 0 ] ",torvalds@linux/a4780adeefd042482f624f5e0d577bf9cdcbb760,CVE-2014-9870,https://github.com/torvalds/linux/commit/a4780adeefd042482f624f5e0d577bf9cdcbb760,2016-08-06T10:59Z 1351,CWE-388,"CWE-388 static int vc4_get_bcl ( struct drm_device * dev , struct vc4_exec_info * exec ) { struct drm_vc4_submit_cl * args = exec -> args ; void * temp = NULL ; void * bin ; int ret = 0 ; uint32_t bin_offset = 0 ; uint32_t shader_rec_offset = roundup ( bin_offset + args -> bin_cl_size , 16 ) ; uint32_t uniforms_offset = shader_rec_offset + args -> shader_rec_size ; uint32_t exec_size = uniforms_offset + args -> uniforms_size ; uint32_t temp_size = exec_size + ( sizeof ( struct vc4_shader_state ) * args -> shader_rec_count ) ; struct vc4_bo * bo ; if ( shader_rec_offset < args -> bin_cl_size || uniforms_offset < shader_rec_offset || exec_size < uniforms_offset || args -> shader_rec_count >= ( UINT_MAX / sizeof ( struct vc4_shader_state ) ) || temp_size < exec_size ) { DRM_ERROR ( ""overflowinexecarguments\\n"" ) ; goto fail ; } temp = drm_malloc_ab ( temp_size , 1 ) ; if ( ! temp ) { DRM_ERROR ( ""Failedtoallocatestorageforcopying"" ""inbin/renderCLs.\\n"" ) ; ret = - ENOMEM ; goto fail ; } bin = temp + bin_offset ; exec -> shader_rec_u = temp + shader_rec_offset ; exec -> uniforms_u = temp + uniforms_offset ; exec -> shader_state = temp + exec_size ; exec -> shader_state_size = args -> shader_rec_count ; if ( copy_from_user ( bin , ( void __user * ) ( uintptr_t ) args -> bin_cl , args -> bin_cl_size ) ) { ret = - EFAULT ; goto fail ; } if ( copy_from_user ( exec -> shader_rec_u , ( void __user * ) ( uintptr_t ) args -> shader_rec , args -> shader_rec_size ) ) { ret = - EFAULT ; goto fail ; } if ( copy_from_user ( exec -> uniforms_u , ( void __user * ) ( uintptr_t ) args -> uniforms , args -> uniforms_size ) ) { ret = - EFAULT ; goto fail ; } bo = vc4_bo_create ( dev , exec_size , true ) ; if ( IS_ERR ( bo ) ) { DRM_ERROR ( ""Couldn\'tallocateBOforbinning\\n"" ) ; ret = PTR_ERR ( bo ) ; goto fail ; } exec -> exec_bo = & bo -> base ; list_add_tail ( & to_vc4_bo ( & exec -> exec_bo -> base ) -> unref_head , & exec -> unref_list ) ; exec -> ct0ca = exec -> exec_bo -> paddr + bin_offset ; exec -> bin_u = bin ; exec -> shader_rec_v = exec -> exec_bo -> vaddr + shader_rec_offset ; exec -> shader_rec_p = exec -> exec_bo -> paddr + shader_rec_offset ; exec -> shader_rec_size = args -> shader_rec_size ; exec -> uniforms_v = exec -> exec_bo -> vaddr + uniforms_offset ; exec -> uniforms_p = exec -> exec_bo -> paddr + uniforms_offset ; exec -> uniforms_size = args -> uniforms_size ; ret = vc4_validate_bin_cl ( dev , exec -> exec_bo -> vaddr + bin_offset , bin , exec ) ; if ( ret ) goto fail ; ret = vc4_validate_shader_recs ( dev , exec ) ; if ( ret ) goto fail ; ret = vc4_wait_for_seqno ( dev , exec -> bin_dep_seqno , ~ 0ull , true ) ; fail : drm_free_large ( temp ) ; return ret ; } "," ""overflowinexecarguments\\n"" ) ; ret = - EINVAL ; ",torvalds@linux/6b8ac63847bc2f958dd93c09edc941a0118992d9,CVE-2017-5577,https://github.com/torvalds/linux/commit/6b8ac63847bc2f958dd93c09edc941a0118992d9,2017-02-06T06:59Z 1352,CWE-119,"CWE-119 static char * print_object ( cJSON * item , int depth , int fmt ) { char * * entries = 0 , * * names = 0 ; char * out = 0 , * ptr , * ret , * str ; int len = 7 , i = 0 , j ; cJSON * child = item -> child ; int numentries = 0 , fail = 0 ; while ( child ) { ++ numentries ; child = child -> next ; } if ( ! ( entries = ( char * * ) cJSON_malloc ( numentries * sizeof ( char * ) ) ) ) return 0 ; if ( ! ( names = ( char * * ) cJSON_malloc ( numentries * sizeof ( char * ) ) ) ) { cJSON_free ( entries ) ; return 0 ; } memset ( entries , 0 , sizeof ( char * ) * numentries ) ; memset ( names , 0 , sizeof ( char * ) * numentries ) ; child = item -> child ; ++ depth ; if ( fmt ) len += depth ; while ( child ) { names [ i ] = str = print_string_ptr ( child -> string ) ; entries [ i ++ ] = ret = print_value ( child , depth , fmt ) ; if ( str && ret ) len += strlen ( ret ) + strlen ( str ) + 2 + ( fmt ? 2 + depth : 0 ) ; else fail = 1 ; child = child -> next ; } if ( ! fail ) { out = ( char * ) cJSON_malloc ( len ) ; if ( ! out ) fail = 1 ; } if ( fail ) { for ( i = 0 ; i < numentries ; ++ i ) { if ( names [ i ] ) cJSON_free ( names [ i ] ) ; if ( entries [ i ] ) cJSON_free ( entries [ i ] ) ; } cJSON_free ( names ) ; cJSON_free ( entries ) ; return 0 ; } * out = '{' ; ptr = out + 1 ; if ( fmt ) * ptr ++ = '\\n' ; * ptr = 0 ; for ( i = 0 ; i < numentries ; ++ i ) { if ( fmt ) for ( j = 0 ; j < depth ; ++ j ) * ptr ++ = '\\t' ; strcpy ( ptr , names [ i ] ) ; ptr += strlen ( names [ i ] ) ; * ptr ++ = ':' ; if ( fmt ) * ptr ++ = '\\t' ; strcpy ( ptr , entries [ i ] ) ; ptr += strlen ( entries [ i ] ) ; if ( i != numentries - 1 ) * ptr ++ = ',' ; if ( fmt ) * ptr ++ = '\\n' ; * ptr = 0 ; cJSON_free ( names [ i ] ) ; cJSON_free ( entries [ i ] ) ; } cJSON_free ( names ) ; cJSON_free ( entries ) ; if ( fmt ) for ( i = 0 ; i < depth - 1 ; ++ i ) * ptr ++ = '\\t' ; * ptr ++ = '}' ; * ptr ++ = 0 ; return out ; } "," , int fmt , printbuffer * p = 0 ; size_t tmplen = 0 ; ( child ) numentries ++ , child = child -> next ; if ( ! numentries ) { if ( p ) out = ensure ( p , fmt ? depth + 4 : 3 ) ; else out = ( char * ) cJSON_malloc ( fmt ? depth + 4 : 3 ) ; if ( ! out ) return 0 ; ptr = out ; * ptr ++ = '{' ; if ( fmt ) { * ptr ++ = '\\n' ; for ( i = 0 ; i < depth ; i ++ ) * ptr ++ = '\\t' ; } * ptr ++ = '}' ; * ptr ++ = 0 ; return out ; } if ( p ) { i = p -> offset ; len = fmt ? 2 : 1 ; ptr = ensure ( p , len + 1 ) ; if ( ! ptr ) return 0 ; * ptr ++ = '{' ; if ( fmt ) * ptr ++ = '\\n' ; * ptr = 0 ; p -> offset += len ; child = item -> child ; depth ++ ; while ( child ) { if ( fmt ) { ptr = ensure ( p , depth ) ; if ( ! ptr ) return 0 ; for ( j = 0 ; j < depth ; j ++ ) * ptr ++ = '\\t' ; p -> offset += depth ; } print_string_ptr ( child -> string , p ) ; p -> offset = update ( p ) ; len = fmt ? 2 : 1 ; ptr = ensure ( p , len ) ; if ( ! ptr ) return 0 ; * ptr ++ = ':' ; if ( fmt ) * ptr ++ = '\\t' ; p -> offset += len ; print_value ( child , depth , fmt , p ) ; p -> offset = update ( p ) ; len = ( fmt ? 1 : 0 ) + ( child -> next ? 1 : 0 ) ; ptr = ensure ( p , len + 1 ) ; if ( ! ptr ) return 0 ; if ( child -> next ) * ptr ++ = ',' ; if ( fmt ) * ptr ++ = '\\n' ; * ptr = 0 ; p -> offset += len ; child = child -> next ; } ptr = ensure ( p , fmt ? ( depth + 1 ) : 2 ) ; if ( ! ptr ) return 0 ; if ( fmt ) for ( i = 0 ; i < depth - 1 ; i ++ ) * ptr ++ = '\\t' ; * ptr ++ = '}' ; * ptr = 0 ; out = ( p -> buffer ) + i ; } else { entries = ( char * * ) cJSON_malloc ( numentries * sizeof ( char * ) ) ; if ( ! entries ) return 0 ; names = ( char * * ) cJSON_malloc ( numentries * sizeof ( char * ) ) ; if ( ! names ) { cJSON_free ( entries ) ; return 0 ; } memset ( entries , 0 , sizeof ( char * ) * numentries ) ; memset ( names , 0 , sizeof ( char * ) * numentries ) ; child = item -> child ; depth ++ ; if ( fmt ) len += depth ; while ( child && ! fail ) { names [ child -> string , 0 depth , fmt , 0 ! fail ) out = ( = 1 ; if ( fail < numentries ; i ++ ) { if + 1 ; if ( fmt ) * ptr ++ < numentries ; i ++ ) { if ( < depth ; j ++ ) * ptr ++ = '\\t' ; tmplen = strlen ( names [ i ] ) ; memcpy ( ptr , names [ i [ i ] , tmplen ) ; ptr += tmplen ; * ptr = ':' ; if ( fmt ) * ptr ++ - 1 ; i ++ ) * ptr ++ = '}' ; * ptr ++ = 0 ; } return out ; ",esnet@iperf/91f2fa59e8ed80dfbf400add0164ee0e508e412a,CVE-2016-4303,https://github.com/esnet/iperf/commit/91f2fa59e8ed80dfbf400add0164ee0e508e412a,2016-09-26T14:59Z 1353,CWE-125,"CWE-125 static const u_char * ikev2_ID_print ( netdissect_options * ndo , u_char tpay , const struct isakmp_gen * ext , u_int item_len _U_ , const u_char * ep _U_ , uint32_t phase _U_ , uint32_t doi _U_ , uint32_t proto _U_ , int depth _U_ ) { struct ikev2_id id ; int id_len , idtype_len , i ; unsigned int dumpascii , dumphex ; const unsigned char * typedata ; ND_TCHECK ( * ext ) ; UNALIGNED_MEMCPY ( & id , ext , sizeof ( id ) ) ; ikev2_pay_print ( ndo , NPSTR ( tpay ) , id . h . critical ) ; id_len = ntohs ( id . h . len ) ; ND_PRINT ( ( ndo , ""len=%d"" , id_len - 4 ) ) ; if ( 2 < ndo -> ndo_vflag && 4 < id_len ) { ND_PRINT ( ( ndo , """" ) ) ; if ( ! rawprint ( ndo , ( const uint8_t * ) ( ext + 1 ) , id_len - 4 ) ) goto trunc ; } idtype_len = id_len - sizeof ( struct ikev2_id ) ; dumpascii = 0 ; dumphex = 0 ; typedata = ( const unsigned char * ) ( ext ) + sizeof ( struct ikev2_id ) ; switch ( id . type ) { case ID_IPV4_ADDR : ND_PRINT ( ( ndo , ""ipv4:"" ) ) ; dumphex = 1 ; break ; case ID_FQDN : ND_PRINT ( ( ndo , ""fqdn:"" ) ) ; dumpascii = 1 ; break ; case ID_RFC822_ADDR : ND_PRINT ( ( ndo , ""rfc822:"" ) ) ; dumpascii = 1 ; break ; case ID_IPV6_ADDR : ND_PRINT ( ( ndo , ""ipv6:"" ) ) ; dumphex = 1 ; break ; case ID_DER_ASN1_DN : ND_PRINT ( ( ndo , ""dn:"" ) ) ; dumphex = 1 ; break ; case ID_DER_ASN1_GN : ND_PRINT ( ( ndo , ""gn:"" ) ) ; dumphex = 1 ; break ; case ID_KEY_ID : ND_PRINT ( ( ndo , ""keyid:"" ) ) ; dumphex = 1 ; break ; } if ( dumpascii ) { ND_TCHECK2 ( * typedata , idtype_len ) ; for ( i = 0 ; i < idtype_len ; i ++ ) { if ( ND_ISPRINT ( typedata [ i ] ) ) { ND_PRINT ( ( ndo , ""%c"" , typedata [ i ] ) ) ; } else { ND_PRINT ( ( ndo , ""."" ) ) ; } } } if ( dumphex ) { if ( ! rawprint ( ndo , ( const uint8_t * ) typedata , idtype_len ) ) goto trunc ; } return ( const u_char * ) ext + id_len ; trunc : ND_PRINT ( ( ndo , ""[|%s]"" , NPSTR ( tpay ) ) ) ; return NULL ; } "," _U_ ) { const struct ikev2_id * idp ; * typedata ; idp = ( const struct ikev2_id * ) ext ; ND_TCHECK ( * idp ) ; UNALIGNED_MEMCPY ",the-tcpdump-group@tcpdump/8dca25d26c7ca2caf6138267f6f17111212c156e,CVE-2017-13690,https://github.com/the-tcpdump-group/tcpdump/commit/8dca25d26c7ca2caf6138267f6f17111212c156e,2017-09-14T06:29Z 1354,CWE-787,"CWE-787 RD_BOOL ber_parse_header ( STREAM s , int tagval , int * length ) { int tag , len ; if ( tagval > 0xff ) { in_uint16_be ( s , tag ) ; } else { in_uint8 ( s , tag ) ; } if ( tag != tagval ) { logger ( Core , Error , ""ber_parse_header(),expectedtag%d,got%d"" , tagval , tag ) ; return False ; } in_uint8 ( s , len ) ; if ( len & 0x80 ) { len &= ~ 0x80 ; * length = 0 ; while ( len -- ) next_be ( s , * length ) ; } else * length = len ; return s_check ( s ) ; } "," int tagval , uint32 * length ) ",rdesktop@rdesktop/4dca546d04321a610c1835010b5dad85163b65e1,CVE-2018-8800,https://github.com/rdesktop/rdesktop/commit/4dca546d04321a610c1835010b5dad85163b65e1,2019-02-05T20:29Z 1355,CWE-000,"CWE-000 static unsigned int unix_dgram_poll ( struct file * file , struct socket * sock , poll_table * wait ) { struct sock * sk = sock -> sk , * other ; unsigned int mask , writable ; sock_poll_wait ( file , sk_sleep ( sk ) , wait ) ; mask = 0 ; if ( sk -> sk_err || ! skb_queue_empty ( & sk -> sk_error_queue ) ) mask |= POLLERR | ( sock_flag ( sk , SOCK_SELECT_ERR_QUEUE ) ? POLLPRI : 0 ) ; if ( sk -> sk_shutdown & RCV_SHUTDOWN ) mask |= POLLRDHUP | POLLIN | POLLRDNORM ; if ( sk -> sk_shutdown == SHUTDOWN_MASK ) mask |= POLLHUP ; if ( ! skb_queue_empty ( & sk -> sk_receive_queue ) ) mask |= POLLIN | POLLRDNORM ; if ( sk -> sk_type == SOCK_SEQPACKET ) { if ( sk -> sk_state == TCP_CLOSE ) mask |= POLLHUP ; if ( sk -> sk_state == TCP_SYN_SENT ) return mask ; } if ( ! ( poll_requested_events ( wait ) & ( POLLWRBAND | POLLWRNORM | POLLOUT ) ) ) return mask ; writable = unix_writable ( sk ) ; other = unix_peer_get ( sk ) ; if ( other ) { if ( unix_peer ( other ) != sk ) { sock_poll_wait ( file , & unix_sk ( other ) -> peer_wait , wait ) ; if ( unix_recvq_full ( other ) ) writable = 0 ; } sock_put ( other ) ; } if ( writable ) mask |= POLLOUT | POLLWRNORM | POLLWRBAND ; else set_bit ( SOCK_ASYNC_NOSPACE , & sk -> sk_socket -> flags ) ; return mask ; } "," sk ) ; if ( writable ) { unix_state_lock ( sk ) ; other = unix_peer ( sk ) ; if ( other && unix_peer ( other ) != ) != sk && unix_recvq_full ( other ( other ) && unix_dgram_peer_wake_me ( sk , other ) = 0 ; unix_state_unlock ( sk ) ; } ",torvalds@linux/7d267278a9ece963d77eefec61630223fce08c6c,CVE-2013-7446,https://github.com/torvalds/linux/commit/7d267278a9ece963d77eefec61630223fce08c6c,2015-12-28T11:59Z 1356,CWE-125,"CWE-125 static inline signed int ReadPropertyMSBLong ( const unsigned char * * p , size_t * length ) { union { unsigned int unsigned_value ; signed int signed_value ; } quantum ; int c ; register ssize_t i ; unsigned char buffer [ 4 ] ; size_t value ; if ( * length < 4 ) return ( - 1 ) ; for ( i = 0 ; i < 4 ; i ++ ) { c = ( int ) ( * ( * p ) ++ ) ; ( * length ) -- ; buffer [ i ] = ( unsigned char ) c ; } value = ( size_t ) ( buffer [ 0 ] << 24 ) ; value |= buffer [ 1 ] << 16 ; value |= buffer [ 2 ] << 8 ; value |= buffer [ 3 ] ; quantum . unsigned_value = ( value & 0xffffffff ) ; return ( quantum . signed_value ) ; } "," 4 ] ; unsigned int value ; if value = ( unsigned int ) buffer [ 0 ] << 24 ; value |= ; value |= ( unsigned int ) ; value |= ( unsigned int ) ; value |= ( unsigned int ) . unsigned_value = value & 0xffffffff value & 0xffffffff ; return ( ",ImageMagick@ImageMagick/d8ab7f046587f2e9f734b687ba7e6e10147c294b,CVE-2016-5842,https://github.com/ImageMagick/ImageMagick/commit/d8ab7f046587f2e9f734b687ba7e6e10147c294b,2016-12-13T15:59Z 1357,CWE-20,"CWE-20 void Rectangle ( double x , double y , double w , double h ) { outpos += sprintf ( outpos , ""\\n%12.3f%12.3f%12.3f%12.3fre"" , x , y , w , h ) ; } "," h ) { sprintf ( outputbuffer , ""\\n%12.3f%12.3f%12.3f%12.3fre"" , h ) ; sendClean ( outputbuffer ) ; ",TeX-Live@texlive-source/9216833a3888a4105a18e8c349f65b045ddb1079,CVE-2019-18604,https://github.com/TeX-Live/texlive-source/commit/9216833a3888a4105a18e8c349f65b045ddb1079,2019-10-29T19:15Z 1358,CWE-399,"CWE-399 static struct sk_buff * batadv_frag_merge_packets ( struct hlist_head * chain , struct sk_buff * skb ) { struct batadv_frag_packet * packet ; struct batadv_frag_list_entry * entry ; struct sk_buff * skb_out = NULL ; int size , hdr_size = sizeof ( struct batadv_frag_packet ) ; packet = ( struct batadv_frag_packet * ) skb -> data ; size = ntohs ( packet -> total_size ) ; if ( size > batadv_frag_size_limit ( ) ) goto free ; entry = hlist_entry ( chain -> first , struct batadv_frag_list_entry , list ) ; hlist_del ( & entry -> list ) ; skb_out = entry -> skb ; kfree ( entry ) ; if ( pskb_expand_head ( skb_out , 0 , size - skb -> len , GFP_ATOMIC ) < 0 ) { kfree_skb ( skb_out ) ; skb_out = NULL ; goto free ; } skb_pull_rcsum ( skb_out , hdr_size ) ; memmove ( skb_out -> data - ETH_HLEN , skb_mac_header ( skb_out ) , ETH_HLEN ) ; skb_set_mac_header ( skb_out , - ETH_HLEN ) ; skb_reset_network_header ( skb_out ) ; skb_reset_transport_header ( skb_out ) ; hlist_for_each_entry ( entry , chain , list ) { size = entry -> skb -> len - hdr_size ; memcpy ( skb_put ( skb_out , size ) , entry -> skb -> data + hdr_size , size ) ; } free : batadv_frag_clear_chain ( chain ) ; return skb_out ; } "," , size - skb_out -> len , ",torvalds@linux/5b6698b0e4a37053de35cc24ee695b98a7eb712b,CVE-2014-9428,https://github.com/torvalds/linux/commit/5b6698b0e4a37053de35cc24ee695b98a7eb712b,2015-01-02T21:59Z 1359,CWE-20,"CWE-20 void exit_io_context ( void ) { struct io_context * ioc ; task_lock ( current ) ; ioc = current -> io_context ; current -> io_context = NULL ; task_unlock ( current ) ; if ( atomic_dec_and_test ( & ioc -> nr_tasks ) ) { if ( ioc -> aic && ioc -> aic -> exit ) ioc -> aic -> exit ( ioc -> aic ) ; cfq_exit ( ioc ) ; } put_io_context ( ioc ) ; } "," void exit_io_context ( struct task_struct * task ) { struct ; task_lock ( task ) ; ioc ; ioc = task -> io_context ; -> io_context ; task -> io_context = ; task_unlock ( task ) ; if ",torvalds@linux/b69f2292063d2caf37ca9aec7d63ded203701bf3,CVE-2012-0879,https://github.com/torvalds/linux/commit/b69f2292063d2caf37ca9aec7d63ded203701bf3,2012-05-17T11:00Z 1360,CWE-200,"CWE-200 int ptrace_setxregs ( struct task_struct * child , void __user * uregs ) { struct thread_info * ti = task_thread_info ( child ) ; struct pt_regs * regs = task_pt_regs ( child ) ; elf_xtregs_t * xtregs = uregs ; int ret = 0 ; # if XTENSA_HAVE_COPROCESSORS coprocessor_flush_all ( ti ) ; coprocessor_release_all ( ti ) ; ret |= __copy_from_user ( & ti -> xtregs_cp , & xtregs -> cp0 , sizeof ( xtregs_coprocessor_t ) ) ; # endif ret |= __copy_from_user ( & regs -> xtregs_opt , & xtregs -> opt , sizeof ( xtregs -> opt ) ) ; ret |= __copy_from_user ( & ti -> xtregs_user , & xtregs -> user , sizeof ( xtregs -> user ) ) ; return ret ? - EFAULT : 0 ; } "," ret = 0 ; if ( ! access_ok ( VERIFY_READ , uregs , sizeof ( elf_xtregs_t ) ) ) return - EFAULT ",torvalds@linux/0d0138ebe24b94065580bd2601f8bb7eb6152f56,CVE-2011-2707,https://github.com/torvalds/linux/commit/0d0138ebe24b94065580bd2601f8bb7eb6152f56,2012-05-24T23:55Z 1361,CWE-119,"CWE-119 static OM_uint32 kg_unseal_v1_iov ( krb5_context context , OM_uint32 * minor_status , krb5_gss_ctx_id_rec * ctx , gss_iov_buffer_desc * iov , int iov_count , size_t token_wrapper_len , int * conf_state , gss_qop_t * qop_state , int toktype ) { OM_uint32 code ; gss_iov_buffer_t header ; gss_iov_buffer_t trailer ; unsigned char * ptr ; int sealalg ; int signalg ; krb5_checksum cksum ; krb5_checksum md5cksum ; size_t cksum_len = 0 ; size_t conflen = 0 ; int direction ; krb5_ui_4 seqnum ; OM_uint32 retval ; size_t sumlen ; krb5_keyusage sign_usage = KG_USAGE_SIGN ; md5cksum . length = cksum . length = 0 ; md5cksum . contents = cksum . contents = NULL ; header = kg_locate_header_iov ( iov , iov_count , toktype ) ; assert ( header != NULL ) ; trailer = kg_locate_iov ( iov , iov_count , GSS_IOV_BUFFER_TYPE_TRAILER ) ; if ( trailer != NULL && trailer -> buffer . length != 0 ) { * minor_status = ( OM_uint32 ) KRB5_BAD_MSIZE ; return GSS_S_DEFECTIVE_TOKEN ; } if ( header -> buffer . length < token_wrapper_len + 14 ) { * minor_status = 0 ; return GSS_S_DEFECTIVE_TOKEN ; } ptr = ( unsigned char * ) header -> buffer . value + token_wrapper_len ; signalg = ptr [ 0 ] ; signalg |= ptr [ 1 ] << 8 ; sealalg = ptr [ 2 ] ; sealalg |= ptr [ 3 ] << 8 ; if ( ptr [ 4 ] != 0xFF || ptr [ 5 ] != 0xFF ) { * minor_status = 0 ; return GSS_S_DEFECTIVE_TOKEN ; } if ( toktype != KG_TOK_WRAP_MSG && sealalg != 0xFFFF ) { * minor_status = 0 ; return GSS_S_DEFECTIVE_TOKEN ; } if ( toktype == KG_TOK_WRAP_MSG && ! ( sealalg == 0xFFFF || sealalg == ctx -> sealalg ) ) { * minor_status = 0 ; return GSS_S_DEFECTIVE_TOKEN ; } if ( ( ctx -> sealalg == SEAL_ALG_NONE && signalg > 1 ) || ( ctx -> sealalg == SEAL_ALG_1 && signalg != SGN_ALG_3 ) || ( ctx -> sealalg == SEAL_ALG_DES3KD && signalg != SGN_ALG_HMAC_SHA1_DES3_KD ) || ( ctx -> sealalg == SEAL_ALG_MICROSOFT_RC4 && signalg != SGN_ALG_HMAC_MD5 ) ) { * minor_status = 0 ; return GSS_S_DEFECTIVE_TOKEN ; } switch ( signalg ) { case SGN_ALG_DES_MAC_MD5 : case SGN_ALG_MD2_5 : case SGN_ALG_HMAC_MD5 : cksum_len = 8 ; if ( toktype != KG_TOK_WRAP_MSG ) sign_usage = 15 ; break ; case SGN_ALG_3 : cksum_len = 16 ; break ; case SGN_ALG_HMAC_SHA1_DES3_KD : cksum_len = 20 ; break ; default : * minor_status = 0 ; return GSS_S_DEFECTIVE_TOKEN ; } code = kg_get_seq_num ( context , ctx -> seq , ptr + 14 , ptr + 6 , & direction , & seqnum ) ; if ( code != 0 ) { * minor_status = code ; return GSS_S_BAD_SIG ; } if ( toktype == KG_TOK_WRAP_MSG ) { if ( sealalg != 0xFFFF ) { if ( ctx -> sealalg == SEAL_ALG_MICROSOFT_RC4 ) { unsigned char bigend_seqnum [ 4 ] ; krb5_keyblock * enc_key ; size_t i ; store_32_be ( seqnum , bigend_seqnum ) ; code = krb5_k_key_keyblock ( context , ctx -> enc , & enc_key ) ; if ( code != 0 ) { retval = GSS_S_FAILURE ; goto cleanup ; } assert ( enc_key -> length == 16 ) ; for ( i = 0 ; i < enc_key -> length ; i ++ ) ( ( char * ) enc_key -> contents ) [ i ] ^= 0xF0 ; code = kg_arcfour_docrypt_iov ( context , enc_key , 0 , & bigend_seqnum [ 0 ] , 4 , iov , iov_count ) ; krb5_free_keyblock ( context , enc_key ) ; } else { code = kg_decrypt_iov ( context , 0 , ( ( ctx -> gss_flags & GSS_C_DCE_STYLE ) != 0 ) , 0 , 0 , ctx -> enc , KG_USAGE_SEAL , NULL , iov , iov_count ) ; } if ( code != 0 ) { retval = GSS_S_FAILURE ; goto cleanup ; } } conflen = kg_confounder_size ( context , ctx -> enc -> keyblock . enctype ) ; } if ( header -> buffer . length != token_wrapper_len + 14 + cksum_len + conflen ) { retval = GSS_S_DEFECTIVE_TOKEN ; goto cleanup ; } switch ( signalg ) { case SGN_ALG_DES_MAC_MD5 : case SGN_ALG_MD2_5 : case SGN_ALG_DES_MAC : case SGN_ALG_3 : md5cksum . checksum_type = CKSUMTYPE_RSA_MD5 ; break ; case SGN_ALG_HMAC_MD5 : md5cksum . checksum_type = CKSUMTYPE_HMAC_MD5_ARCFOUR ; break ; case SGN_ALG_HMAC_SHA1_DES3_KD : md5cksum . checksum_type = CKSUMTYPE_HMAC_SHA1_DES3 ; break ; default : abort ( ) ; } code = krb5_c_checksum_length ( context , md5cksum . checksum_type , & sumlen ) ; if ( code != 0 ) { retval = GSS_S_FAILURE ; goto cleanup ; } md5cksum . length = sumlen ; code = kg_make_checksum_iov_v1 ( context , md5cksum . checksum_type , cksum_len , ctx -> seq , ctx -> enc , sign_usage , iov , iov_count , toktype , & md5cksum ) ; if ( code != 0 ) { retval = GSS_S_FAILURE ; goto cleanup ; } switch ( signalg ) { case SGN_ALG_DES_MAC_MD5 : case SGN_ALG_3 : code = kg_encrypt_inplace ( context , ctx -> seq , KG_USAGE_SEAL , ( g_OID_equal ( ctx -> mech_used , gss_mech_krb5_old ) ? ctx -> seq -> keyblock . contents : NULL ) , md5cksum . contents , 16 ) ; if ( code != 0 ) { retval = GSS_S_FAILURE ; goto cleanup ; } cksum . length = cksum_len ; cksum . contents = md5cksum . contents + 16 - cksum . length ; code = k5_bcmp ( cksum . contents , ptr + 14 , cksum . length ) ; break ; case SGN_ALG_HMAC_SHA1_DES3_KD : case SGN_ALG_HMAC_MD5 : code = k5_bcmp ( md5cksum . contents , ptr + 14 , cksum_len ) ; break ; default : code = 0 ; retval = GSS_S_DEFECTIVE_TOKEN ; goto cleanup ; break ; } if ( code != 0 ) { code = 0 ; retval = GSS_S_BAD_SIG ; goto cleanup ; } if ( toktype == KG_TOK_WRAP_MSG && ( ctx -> gss_flags & GSS_C_DCE_STYLE ) == 0 ) { retval = kg_fixup_padding_iov ( & code , iov , iov_count ) ; if ( retval != GSS_S_COMPLETE ) goto cleanup ; } if ( conf_state != NULL ) * conf_state = ( sealalg != 0xFFFF ) ; if ( qop_state != NULL ) * qop_state = GSS_C_QOP_DEFAULT ; if ( ( ctx -> initiate && direction != 0xff ) || ( ! ctx -> initiate && direction != 0 ) ) { * minor_status = ( OM_uint32 ) G_BAD_DIRECTION ; retval = GSS_S_BAD_SIG ; } code = 0 ; retval = g_order_check ( & ctx -> seqstate , ( gssint_uint64 ) seqnum ) ; cleanup : krb5_free_checksum_contents ( context , & md5cksum ) ; * minor_status = code ; return retval ; } "," OM_uint32 ) KRB5_BAD_MSIZE ; return GSS_S_DEFECTIVE_TOKEN ; } if ( ctx -> seq == NULL ) { * minor_status = 0 < token_wrapper_len + 22 ) { * ",krb5@krb5/e6ae703ae597d798e310368d52b8f38ee11c6a73,CVE-2014-4342,https://github.com/krb5/krb5/commit/e6ae703ae597d798e310368d52b8f38ee11c6a73,2014-07-20T11:12Z 1362,CWE-264,"CWE-264 static int command_read ( struct pci_dev * dev , int offset , u16 * value , void * data ) { int i ; int ret ; ret = xen_pcibk_read_config_word ( dev , offset , value , data ) ; if ( ! pci_is_enabled ( dev ) ) return ret ; for ( i = 0 ; i < PCI_ROM_RESOURCE ; i ++ ) { if ( dev -> resource [ i ] . flags & IORESOURCE_IO ) * value |= PCI_COMMAND_IO ; if ( dev -> resource [ i ] . flags & IORESOURCE_MEM ) * value |= PCI_COMMAND_MEMORY ; } return ret ; } "," ) { int ret = pci_read_config_word ( dev , offset , value ) ; const struct pci_cmd_info * cmd = data ; * value &= PCI_COMMAND_GUEST ; * value |= * value |= cmd -> val & ~ PCI_COMMAND_GUEST ; return ret ; ",torvalds@linux/af6fc858a35b90e89ea7a7ee58e66628c55c776b,CVE-2015-2150,https://github.com/torvalds/linux/commit/af6fc858a35b90e89ea7a7ee58e66628c55c776b,2015-03-12T14:59Z 1363,CWE-119,"CWE-119 static vpx_codec_err_t ctrl_get_reference ( vpx_codec_alg_priv_t * ctx , int ctr_id , va_list args ) { vp9_ref_frame_t * frame = va_arg ( args , vp9_ref_frame_t * ) ; if ( frame != NULL ) { YV12_BUFFER_CONFIG * fb ; vp9_get_reference_enc ( ctx -> cpi , frame -> idx , & fb ) ; yuvconfig2image ( & frame -> img , fb , NULL ) ; return VPX_CODEC_OK ; } else { return VPX_CODEC_INVALID_PARAM ; } } "," * ctx , va_list args ) { vp9_ref_frame_t * const YV12_BUFFER_CONFIG * fb = get_ref_frame ( & ctx -> cpi ctx -> cpi -> common frame -> idx ) ; if ( fb == NULL ) return VPX_CODEC_ERROR ; yuvconfig2image ( ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1364,CWE-399,"CWE-399 void __scm_destroy ( struct scm_cookie * scm ) { struct scm_fp_list * fpl = scm -> fp ; int i ; if ( fpl ) { scm -> fp = NULL ; for ( i = fpl -> count - 1 ; i >= 0 ; i -- ) fput ( fpl -> fp [ i ] ) ; kfree ( fpl ) ; } } "," ] ) ; free_uid ( fpl -> user ) ; ",torvalds@linux/415e3d3e90ce9e18727e8843ae343eda5a58fad6,CVE-2016-2550,https://github.com/torvalds/linux/commit/415e3d3e90ce9e18727e8843ae343eda5a58fad6,2016-04-27T17:59Z 1365,CWE-399,"CWE-399 long do_io_submit ( aio_context_t ctx_id , long nr , struct iocb __user * __user * iocbpp , bool compat ) { struct kioctx * ctx ; long ret = 0 ; int i = 0 ; struct blk_plug plug ; struct kiocb_batch batch ; if ( unlikely ( nr < 0 ) ) return - EINVAL ; if ( unlikely ( nr > LONG_MAX / sizeof ( * iocbpp ) ) ) nr = LONG_MAX / sizeof ( * iocbpp ) ; if ( unlikely ( ! access_ok ( VERIFY_READ , iocbpp , ( nr * sizeof ( * iocbpp ) ) ) ) ) return - EFAULT ; ctx = lookup_ioctx ( ctx_id ) ; if ( unlikely ( ! ctx ) ) { pr_debug ( ""EINVAL:io_submit:invalidcontextid\\n"" ) ; return - EINVAL ; } kiocb_batch_init ( & batch , nr ) ; blk_start_plug ( & plug ) ; for ( i = 0 ; i < nr ; i ++ ) { struct iocb __user * user_iocb ; struct iocb tmp ; if ( unlikely ( __get_user ( user_iocb , iocbpp + i ) ) ) { ret = - EFAULT ; break ; } if ( unlikely ( copy_from_user ( & tmp , user_iocb , sizeof ( tmp ) ) ) ) { ret = - EFAULT ; break ; } ret = io_submit_one ( ctx , user_iocb , & tmp , & batch , compat ) ; if ( ret ) break ; } blk_finish_plug ( & plug ) ; kiocb_batch_free ( & batch ) ; put_ioctx ( ctx ) ; return i ? i : ret ; } "," ; kiocb_batch_free ( ctx , ",torvalds@linux/802f43594d6e4d2ac61086d239153c17873a0428,CVE-2012-0058,https://github.com/torvalds/linux/commit/802f43594d6e4d2ac61086d239153c17873a0428,2012-05-17T11:00Z 1366,CWE-189,"CWE-189 void dwc3_gadget_giveback ( struct dwc3_ep * dep , struct dwc3_request * req , int status ) { struct dwc3 * dwc = dep -> dwc ; req -> started = false ; list_del ( & req -> list ) ; req -> remaining = 0 ; if ( req -> request . status == - EINPROGRESS ) req -> request . status = status ; if ( req -> trb ) usb_gadget_unmap_request_by_dev ( dwc -> sysdev , & req -> request , req -> direction ) ; req -> trb = NULL ; trace_dwc3_gadget_giveback ( req ) ; spin_unlock ( & dwc -> lock ) ; usb_gadget_giveback_request ( & dep -> endpoint , & req -> request ) ; spin_lock ( & dwc -> lock ) ; if ( dep -> number > 1 ) pm_runtime_put ( dwc -> dev ) ; } "," -> dwc ; dwc3_gadget_del_and_unmap_request ( dep , req , status ) ; spin_unlock lock ) ; } ",torvalds@linux/c91815b596245fd7da349ecc43c8def670d2269e,CVE-2019-14763,https://github.com/torvalds/linux/commit/c91815b596245fd7da349ecc43c8def670d2269e,2019-08-07T22:15Z 1367,CWE-20,"CWE-20 int yyparse ( void ) # else int yyparse ( ) # endif # endif { int yystate ; int yyerrstatus ; yytype_int16 yyssa [ YYINITDEPTH ] ; yytype_int16 * yyss ; yytype_int16 * yyssp ; YYSTYPE yyvsa [ YYINITDEPTH ] ; YYSTYPE * yyvs ; YYSTYPE * yyvsp ; YYSIZE_T yystacksize ; int yyn ; int yyresult ; int yytoken ; YYSTYPE yyval ; # if YYERROR_VERBOSE char yymsgbuf [ 128 ] ; char * yymsg = yymsgbuf ; YYSIZE_T yymsg_alloc = sizeof yymsgbuf ; # endif # define YYPOPSTACK ( N ) ( yyvsp -= ( N ) , yyssp -= ( N ) ) int yylen = 0 ; yytoken = 0 ; yyss = yyssa ; yyvs = yyvsa ; yystacksize = YYINITDEPTH ; YYDPRINTF ( ( stderr , ""Startingparse\\n"" ) ) ; yystate = 0 ; yyerrstatus = 0 ; yynerrs = 0 ; yychar = YYEMPTY ; yyssp = yyss ; yyvsp = yyvs ; goto yysetstate ; yynewstate : yyssp ++ ; yysetstate : * yyssp = yystate ; if ( yyss + yystacksize - 1 <= yyssp ) { YYSIZE_T yysize = yyssp - yyss + 1 ; # ifdef yyoverflow { YYSTYPE * yyvs1 = yyvs ; yytype_int16 * yyss1 = yyss ; yyoverflow ( YY_ ( ""memoryexhausted"" ) , & yyss1 , yysize * sizeof ( * yyssp ) , & yyvs1 , yysize * sizeof ( * yyvsp ) , & yystacksize ) ; yyss = yyss1 ; yyvs = yyvs1 ; } # else # ifndef YYSTACK_RELOCATE goto yyexhaustedlab ; # else if ( YYMAXDEPTH <= yystacksize ) goto yyexhaustedlab ; yystacksize *= 2 ; if ( YYMAXDEPTH < yystacksize ) yystacksize = YYMAXDEPTH ; { yytype_int16 * yyss1 = yyss ; union yyalloc * yyptr = ( union yyalloc * ) YYSTACK_ALLOC ( YYSTACK_BYTES ( yystacksize ) ) ; if ( ! yyptr ) goto yyexhaustedlab ; YYSTACK_RELOCATE ( yyss_alloc , yyss ) ; YYSTACK_RELOCATE ( yyvs_alloc , yyvs ) ; # undef YYSTACK_RELOCATE if ( yyss1 != yyssa ) YYSTACK_FREE ( yyss1 ) ; } # endif # endif yyssp = yyss + yysize - 1 ; yyvsp = yyvs + yysize - 1 ; YYDPRINTF ( ( stderr , ""Stacksizeincreasedto%lu\\n"" , ( unsigned long int ) yystacksize ) ) ; if ( yyss + yystacksize - 1 <= yyssp ) YYABORT ; } YYDPRINTF ( ( stderr , ""Enteringstate%d\\n"" , yystate ) ) ; if ( yystate == YYFINAL ) YYACCEPT ; goto yybackup ; yybackup : yyn = yypact [ yystate ] ; if ( yyn == YYPACT_NINF ) goto yydefault ; if ( yychar == YYEMPTY ) { YYDPRINTF ( ( stderr , ""Readingatoken:"" ) ) ; yychar = YYLEX ; } if ( yychar <= YYEOF ) { yychar = yytoken = YYEOF ; YYDPRINTF ( ( stderr , ""Nowatendofinput.\\n"" ) ) ; } else { yytoken = YYTRANSLATE ( yychar ) ; YY_SYMBOL_PRINT ( ""Nexttokenis"" , yytoken , & yylval , & yylloc ) ; } yyn += yytoken ; if ( yyn < 0 || YYLAST < yyn || yycheck [ yyn ] != yytoken ) goto yydefault ; yyn = yytable [ yyn ] ; if ( yyn <= 0 ) { if ( yyn == 0 || yyn == YYTABLE_NINF ) goto yyerrlab ; yyn = - yyn ; goto yyreduce ; } if ( yyerrstatus ) yyerrstatus -- ; YY_SYMBOL_PRINT ( ""Shifting"" , yytoken , & yylval , & yylloc ) ; yychar = YYEMPTY ; yystate = yyn ; * ++ yyvsp = yylval ; goto yynewstate ; yydefault : yyn = yydefact [ yystate ] ; if ( yyn == 0 ) goto yyerrlab ; goto yyreduce ; yyreduce : yylen = yyr2 [ yyn ] ; yyval = yyvsp [ 1 - yylen ] ; YY_REDUCE_PRINT ( yyn ) ; switch ( yyn ) { case 5 : # line 320 ""ntp_parser.y"" { msyslog ( LOG_ERR , ""syntaxerrorin%sline%d,column%d"" , ip_file -> fname , ip_file -> err_line_no , ip_file -> err_col_no ) ; } break ; case 19 : # line 354 ""ntp_parser.y"" { struct peer_node * my_node = create_peer_node ( ( yyvsp [ ( 1 ) - ( 3 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 3 ) ] . Address_node ) , ( yyvsp [ ( 3 ) - ( 3 ) ] . Queue ) ) ; if ( my_node ) enqueue ( cfgt . peers , my_node ) ; } break ; case 20 : # line 360 ""ntp_parser.y"" { struct peer_node * my_node = create_peer_node ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Address_node ) , NULL ) ; if ( my_node ) enqueue ( cfgt . peers , my_node ) ; } break ; case 27 : # line 377 ""ntp_parser.y"" { ( yyval . Address_node ) = create_address_node ( ( yyvsp [ ( 2 ) - ( 2 ) ] . String ) , AF_INET ) ; } break ; case 28 : # line 378 ""ntp_parser.y"" { ( yyval . Address_node ) = create_address_node ( ( yyvsp [ ( 2 ) - ( 2 ) ] . String ) , AF_INET6 ) ; } break ; case 29 : # line 382 ""ntp_parser.y"" { ( yyval . Address_node ) = create_address_node ( ( yyvsp [ ( 1 ) - ( 1 ) ] . String ) , 0 ) ; } break ; case 30 : # line 386 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Queue ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Attr_val ) ) ; } break ; case 31 : # line 387 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue_in_new_queue ( ( yyvsp [ ( 1 ) - ( 1 ) ] . Attr_val ) ) ; } break ; case 32 : # line 391 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( T_Flag , ( yyvsp [ ( 1 ) - ( 1 ) ] . Integer ) ) ; } break ; case 33 : # line 392 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_dval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Double ) ) ; } break ; case 34 : # line 393 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( T_Flag , ( yyvsp [ ( 1 ) - ( 1 ) ] . Integer ) ) ; } break ; case 35 : # line 394 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( T_Flag , ( yyvsp [ ( 1 ) - ( 1 ) ] . Integer ) ) ; } break ; case 36 : # line 395 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 37 : # line 396 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 38 : # line 397 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 39 : # line 398 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( T_Flag , ( yyvsp [ ( 1 ) - ( 1 ) ] . Integer ) ) ; } break ; case 40 : # line 399 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( T_Flag , ( yyvsp [ ( 1 ) - ( 1 ) ] . Integer ) ) ; } break ; case 41 : # line 400 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( T_Flag , ( yyvsp [ ( 1 ) - ( 1 ) ] . Integer ) ) ; } break ; case 42 : # line 401 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( T_Flag , ( yyvsp [ ( 1 ) - ( 1 ) ] . Integer ) ) ; } break ; case 43 : # line 402 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( T_Flag , ( yyvsp [ ( 1 ) - ( 1 ) ] . Integer ) ) ; } break ; case 44 : # line 403 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 45 : # line 404 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 46 : # line 405 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 47 : # line 415 ""ntp_parser.y"" { struct unpeer_node * my_node = create_unpeer_node ( ( yyvsp [ ( 2 ) - ( 2 ) ] . Address_node ) ) ; if ( my_node ) enqueue ( cfgt . unpeers , my_node ) ; } break ; case 50 : # line 434 ""ntp_parser.y"" { cfgt . broadcastclient = 1 ; } break ; case 51 : # line 436 ""ntp_parser.y"" { append_queue ( cfgt . manycastserver , ( yyvsp [ ( 2 ) - ( 2 ) ] . Queue ) ) ; } break ; case 52 : # line 438 ""ntp_parser.y"" { append_queue ( cfgt . multicastclient , ( yyvsp [ ( 2 ) - ( 2 ) ] . Queue ) ) ; } break ; case 53 : # line 449 ""ntp_parser.y"" { enqueue ( cfgt . vars , create_attr_ival ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ) ; } break ; case 54 : # line 451 ""ntp_parser.y"" { cfgt . auth . control_key = ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ; } break ; case 55 : # line 453 ""ntp_parser.y"" { cfgt . auth . cryptosw ++ ; append_queue ( cfgt . auth . crypto_cmd_list , ( yyvsp [ ( 2 ) - ( 2 ) ] . Queue ) ) ; } break ; case 56 : # line 458 ""ntp_parser.y"" { cfgt . auth . keys = ( yyvsp [ ( 2 ) - ( 2 ) ] . String ) ; } break ; case 57 : # line 460 ""ntp_parser.y"" { cfgt . auth . keysdir = ( yyvsp [ ( 2 ) - ( 2 ) ] . String ) ; } break ; case 58 : # line 462 ""ntp_parser.y"" { cfgt . auth . request_key = ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ; } break ; case 59 : # line 464 ""ntp_parser.y"" { cfgt . auth . revoke = ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ; } break ; case 60 : # line 466 ""ntp_parser.y"" { cfgt . auth . trusted_key_list = ( yyvsp [ ( 2 ) - ( 2 ) ] . Queue ) ; } break ; case 61 : # line 468 ""ntp_parser.y"" { cfgt . auth . ntp_signd_socket = ( yyvsp [ ( 2 ) - ( 2 ) ] . String ) ; } break ; case 63 : # line 474 ""ntp_parser.y"" { ( yyval . Queue ) = create_queue ( ) ; } break ; case 64 : # line 479 ""ntp_parser.y"" { if ( ( yyvsp [ ( 2 ) - ( 2 ) ] . Attr_val ) != NULL ) ( yyval . Queue ) = enqueue ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Queue ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Attr_val ) ) ; else ( yyval . Queue ) = ( yyvsp [ ( 1 ) - ( 2 ) ] . Queue ) ; } break ; case 65 : # line 486 ""ntp_parser.y"" { if ( ( yyvsp [ ( 1 ) - ( 1 ) ] . Attr_val ) != NULL ) ( yyval . Queue ) = enqueue_in_new_queue ( ( yyvsp [ ( 1 ) - ( 1 ) ] . Attr_val ) ) ; else ( yyval . Queue ) = create_queue ( ) ; } break ; case 66 : # line 496 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_sval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . String ) ) ; } break ; case 67 : # line 498 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_sval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . String ) ) ; } break ; case 68 : # line 500 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_sval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . String ) ) ; } break ; case 69 : # line 502 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_sval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . String ) ) ; } break ; case 70 : # line 504 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_sval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . String ) ) ; } break ; case 71 : # line 506 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_sval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . String ) ) ; } break ; case 72 : # line 508 ""ntp_parser.y"" { ( yyval . Attr_val ) = NULL ; cfgt . auth . revoke = ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ; msyslog ( LOG_WARNING , ""\'cryptorevoke%d\'isdeprecated,"" ""pleaseuse\'revoke%d\'instead."" , cfgt . auth . revoke , cfgt . auth . revoke ) ; } break ; case 73 : # line 525 ""ntp_parser.y"" { append_queue ( cfgt . orphan_cmds , ( yyvsp [ ( 2 ) - ( 2 ) ] . Queue ) ) ; } break ; case 74 : # line 529 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Queue ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Attr_val ) ) ; } break ; case 75 : # line 530 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue_in_new_queue ( ( yyvsp [ ( 1 ) - ( 1 ) ] . Attr_val ) ) ; } break ; case 76 : # line 535 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_dval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( double ) ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 77 : # line 537 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_dval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( double ) ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 78 : # line 539 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_dval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( double ) ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 79 : # line 541 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_dval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( double ) ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 80 : # line 543 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_dval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( double ) ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 81 : # line 545 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_dval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Double ) ) ; } break ; case 82 : # line 547 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_dval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Double ) ) ; } break ; case 83 : # line 549 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_dval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Double ) ) ; } break ; case 84 : # line 551 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_dval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Double ) ) ; } break ; case 85 : # line 553 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_dval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( double ) ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 86 : # line 555 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_dval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( double ) ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 87 : # line 565 ""ntp_parser.y"" { append_queue ( cfgt . stats_list , ( yyvsp [ ( 2 ) - ( 2 ) ] . Queue ) ) ; } break ; case 88 : # line 567 ""ntp_parser.y"" { if ( input_from_file ) cfgt . stats_dir = ( yyvsp [ ( 2 ) - ( 2 ) ] . String ) ; else { free ( ( yyvsp [ ( 2 ) - ( 2 ) ] . String ) ) ; yyerror ( ""statsdirremoteconfigurationignored"" ) ; } } break ; case 89 : # line 576 ""ntp_parser.y"" { enqueue ( cfgt . filegen_opts , create_filegen_node ( ( yyvsp [ ( 2 ) - ( 3 ) ] . Integer ) , ( yyvsp [ ( 3 ) - ( 3 ) ] . Queue ) ) ) ; } break ; case 90 : # line 583 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Queue ) , create_ival ( ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ) ; } break ; case 91 : # line 584 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue_in_new_queue ( create_ival ( ( yyvsp [ ( 1 ) - ( 1 ) ] . Integer ) ) ) ; } break ; case 100 : # line 600 ""ntp_parser.y"" { if ( ( yyvsp [ ( 2 ) - ( 2 ) ] . Attr_val ) != NULL ) ( yyval . Queue ) = enqueue ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Queue ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Attr_val ) ) ; else ( yyval . Queue ) = ( yyvsp [ ( 1 ) - ( 2 ) ] . Queue ) ; } break ; case 101 : # line 607 ""ntp_parser.y"" { if ( ( yyvsp [ ( 1 ) - ( 1 ) ] . Attr_val ) != NULL ) ( yyval . Queue ) = enqueue_in_new_queue ( ( yyvsp [ ( 1 ) - ( 1 ) ] . Attr_val ) ) ; else ( yyval . Queue ) = create_queue ( ) ; } break ; case 102 : # line 617 ""ntp_parser.y"" { if ( input_from_file ) ( yyval . Attr_val ) = create_attr_sval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . String ) ) ; else { ( yyval . Attr_val ) = NULL ; free ( ( yyvsp [ ( 2 ) - ( 2 ) ] . String ) ) ; yyerror ( ""filegenfileremoteconfigurationignored"" ) ; } } break ; case 103 : # line 627 ""ntp_parser.y"" { if ( input_from_file ) ( yyval . Attr_val ) = create_attr_ival ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; else { ( yyval . Attr_val ) = NULL ; yyerror ( ""filegentyperemoteconfigurationignored"" ) ; } } break ; case 104 : # line 636 ""ntp_parser.y"" { if ( input_from_file ) ( yyval . Attr_val ) = create_attr_ival ( T_Flag , ( yyvsp [ ( 1 ) - ( 1 ) ] . Integer ) ) ; else { ( yyval . Attr_val ) = NULL ; yyerror ( ""filegenlinkremoteconfigurationignored"" ) ; } } break ; case 105 : # line 645 ""ntp_parser.y"" { if ( input_from_file ) ( yyval . Attr_val ) = create_attr_ival ( T_Flag , ( yyvsp [ ( 1 ) - ( 1 ) ] . Integer ) ) ; else { ( yyval . Attr_val ) = NULL ; yyerror ( ""filegennolinkremoteconfigurationignored"" ) ; } } break ; case 106 : # line 653 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( T_Flag , ( yyvsp [ ( 1 ) - ( 1 ) ] . Integer ) ) ; } break ; case 107 : # line 654 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( T_Flag , ( yyvsp [ ( 1 ) - ( 1 ) ] . Integer ) ) ; } break ; case 115 : # line 674 ""ntp_parser.y"" { append_queue ( cfgt . discard_opts , ( yyvsp [ ( 2 ) - ( 2 ) ] . Queue ) ) ; } break ; case 116 : # line 678 ""ntp_parser.y"" { append_queue ( cfgt . mru_opts , ( yyvsp [ ( 2 ) - ( 2 ) ] . Queue ) ) ; } break ; case 117 : # line 682 ""ntp_parser.y"" { enqueue ( cfgt . restrict_opts , create_restrict_node ( ( yyvsp [ ( 2 ) - ( 3 ) ] . Address_node ) , NULL , ( yyvsp [ ( 3 ) - ( 3 ) ] . Queue ) , ip_file -> line_no ) ) ; } break ; case 118 : # line 687 ""ntp_parser.y"" { enqueue ( cfgt . restrict_opts , create_restrict_node ( ( yyvsp [ ( 2 ) - ( 5 ) ] . Address_node ) , ( yyvsp [ ( 4 ) - ( 5 ) ] . Address_node ) , ( yyvsp [ ( 5 ) - ( 5 ) ] . Queue ) , ip_file -> line_no ) ) ; } break ; case 119 : # line 692 ""ntp_parser.y"" { enqueue ( cfgt . restrict_opts , create_restrict_node ( NULL , NULL , ( yyvsp [ ( 3 ) - ( 3 ) ] . Queue ) , ip_file -> line_no ) ) ; } break ; case 120 : # line 697 ""ntp_parser.y"" { enqueue ( cfgt . restrict_opts , create_restrict_node ( create_address_node ( estrdup ( ""0.0.0.0"" ) , AF_INET ) , create_address_node ( estrdup ( ""0.0.0.0"" ) , AF_INET ) , ( yyvsp [ ( 4 ) - ( 4 ) ] . Queue ) , ip_file -> line_no ) ) ; } break ; case 121 : # line 710 ""ntp_parser.y"" { enqueue ( cfgt . restrict_opts , create_restrict_node ( create_address_node ( estrdup ( ""::"" ) , AF_INET6 ) , create_address_node ( estrdup ( ""::"" ) , AF_INET6 ) , ( yyvsp [ ( 4 ) - ( 4 ) ] . Queue ) , ip_file -> line_no ) ) ; } break ; case 122 : # line 723 ""ntp_parser.y"" { enqueue ( cfgt . restrict_opts , create_restrict_node ( NULL , NULL , enqueue ( ( yyvsp [ ( 3 ) - ( 3 ) ] . Queue ) , create_ival ( ( yyvsp [ ( 2 ) - ( 3 ) ] . Integer ) ) ) , ip_file -> line_no ) ) ; } break ; case 123 : # line 734 ""ntp_parser.y"" { ( yyval . Queue ) = create_queue ( ) ; } break ; case 124 : # line 736 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Queue ) , create_ival ( ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ) ; } break ; case 139 : # line 758 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Queue ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Attr_val ) ) ; } break ; case 140 : # line 760 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue_in_new_queue ( ( yyvsp [ ( 1 ) - ( 1 ) ] . Attr_val ) ) ; } break ; case 141 : # line 764 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 142 : # line 765 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 143 : # line 766 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 144 : # line 771 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Queue ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Attr_val ) ) ; } break ; case 145 : # line 773 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue_in_new_queue ( ( yyvsp [ ( 1 ) - ( 1 ) ] . Attr_val ) ) ; } break ; case 146 : # line 777 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 147 : # line 778 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 148 : # line 779 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 149 : # line 780 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 150 : # line 781 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 151 : # line 782 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 152 : # line 783 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 153 : # line 784 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 154 : # line 793 ""ntp_parser.y"" { enqueue ( cfgt . fudge , create_addr_opts_node ( ( yyvsp [ ( 2 ) - ( 3 ) ] . Address_node ) , ( yyvsp [ ( 3 ) - ( 3 ) ] . Queue ) ) ) ; } break ; case 155 : # line 798 ""ntp_parser.y"" { enqueue ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Queue ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Attr_val ) ) ; } break ; case 156 : # line 800 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue_in_new_queue ( ( yyvsp [ ( 1 ) - ( 1 ) ] . Attr_val ) ) ; } break ; case 157 : # line 804 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_dval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Double ) ) ; } break ; case 158 : # line 805 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_dval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Double ) ) ; } break ; case 159 : # line 806 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 160 : # line 807 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_sval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . String ) ) ; } break ; case 161 : # line 808 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 162 : # line 809 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 163 : # line 810 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 164 : # line 811 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 165 : # line 820 ""ntp_parser.y"" { append_queue ( cfgt . enable_opts , ( yyvsp [ ( 2 ) - ( 2 ) ] . Queue ) ) ; } break ; case 166 : # line 822 ""ntp_parser.y"" { append_queue ( cfgt . disable_opts , ( yyvsp [ ( 2 ) - ( 2 ) ] . Queue ) ) ; } break ; case 167 : # line 827 ""ntp_parser.y"" { if ( ( yyvsp [ ( 2 ) - ( 2 ) ] . Attr_val ) != NULL ) ( yyval . Queue ) = enqueue ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Queue ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Attr_val ) ) ; else ( yyval . Queue ) = ( yyvsp [ ( 1 ) - ( 2 ) ] . Queue ) ; } break ; case 168 : # line 834 ""ntp_parser.y"" { if ( ( yyvsp [ ( 1 ) - ( 1 ) ] . Attr_val ) != NULL ) ( yyval . Queue ) = enqueue_in_new_queue ( ( yyvsp [ ( 1 ) - ( 1 ) ] . Attr_val ) ) ; else ( yyval . Queue ) = create_queue ( ) ; } break ; case 169 : # line 843 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( T_Flag , ( yyvsp [ ( 1 ) - ( 1 ) ] . Integer ) ) ; } break ; case 170 : # line 844 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( T_Flag , ( yyvsp [ ( 1 ) - ( 1 ) ] . Integer ) ) ; } break ; case 171 : # line 845 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( T_Flag , ( yyvsp [ ( 1 ) - ( 1 ) ] . Integer ) ) ; } break ; case 172 : # line 846 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( T_Flag , ( yyvsp [ ( 1 ) - ( 1 ) ] . Integer ) ) ; } break ; case 173 : # line 847 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( T_Flag , ( yyvsp [ ( 1 ) - ( 1 ) ] . Integer ) ) ; } break ; case 174 : # line 848 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( T_Flag , ( yyvsp [ ( 1 ) - ( 1 ) ] . Integer ) ) ; } break ; case 175 : # line 850 ""ntp_parser.y"" { if ( input_from_file ) ( yyval . Attr_val ) = create_attr_ival ( T_Flag , ( yyvsp [ ( 1 ) - ( 1 ) ] . Integer ) ) ; else { ( yyval . Attr_val ) = NULL ; yyerror ( ""enable/disablestatsremoteconfigurationignored"" ) ; } } break ; case 176 : # line 865 ""ntp_parser.y"" { append_queue ( cfgt . tinker , ( yyvsp [ ( 2 ) - ( 2 ) ] . Queue ) ) ; } break ; case 177 : # line 869 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Queue ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Attr_val ) ) ; } break ; case 178 : # line 870 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue_in_new_queue ( ( yyvsp [ ( 1 ) - ( 1 ) ] . Attr_val ) ) ; } break ; case 179 : # line 874 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_dval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Double ) ) ; } break ; case 180 : # line 875 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_dval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Double ) ) ; } break ; case 181 : # line 876 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_dval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Double ) ) ; } break ; case 182 : # line 877 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_dval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Double ) ) ; } break ; case 183 : # line 878 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_dval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Double ) ) ; } break ; case 184 : # line 879 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_dval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Double ) ) ; } break ; case 185 : # line 880 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_dval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Double ) ) ; } break ; case 187 : # line 891 ""ntp_parser.y"" { if ( curr_include_level >= MAXINCLUDELEVEL ) { fprintf ( stderr , ""getconfig:Maximumincludefilelevelexceeded.\\n"" ) ; msyslog ( LOG_ERR , ""getconfig:Maximumincludefilelevelexceeded."" ) ; } else { fp [ curr_include_level + 1 ] = F_OPEN ( FindConfig ( ( yyvsp [ ( 2 ) - ( 3 ) ] . String ) ) , ""r"" ) ; if ( fp [ curr_include_level + 1 ] == NULL ) { fprintf ( stderr , ""getconfig:Couldn\'topen<%s>\\n"" , FindConfig ( ( yyvsp [ ( 2 ) - ( 3 ) ] . String ) ) ) ; msyslog ( LOG_ERR , ""getconfig:Couldn\'topen<%s>"" , FindConfig ( ( yyvsp [ ( 2 ) - ( 3 ) ] . String ) ) ) ; } else ip_file = fp [ ++ curr_include_level ] ; } } break ; case 188 : # line 907 ""ntp_parser.y"" { while ( curr_include_level != - 1 ) FCLOSE ( fp [ curr_include_level -- ] ) ; } break ; case 189 : # line 913 ""ntp_parser.y"" { enqueue ( cfgt . vars , create_attr_dval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Double ) ) ) ; } break ; case 190 : # line 915 ""ntp_parser.y"" { enqueue ( cfgt . vars , create_attr_ival ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ) ; } break ; case 191 : # line 917 ""ntp_parser.y"" { enqueue ( cfgt . vars , create_attr_dval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Double ) ) ) ; } break ; case 192 : # line 919 ""ntp_parser.y"" { } break ; case 193 : # line 921 ""ntp_parser.y"" { enqueue ( cfgt . vars , create_attr_sval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . String ) ) ) ; } break ; case 194 : # line 924 ""ntp_parser.y"" { enqueue ( cfgt . vars , create_attr_sval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . String ) ) ) ; } break ; case 195 : # line 926 ""ntp_parser.y"" { if ( input_from_file ) enqueue ( cfgt . vars , create_attr_sval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . String ) ) ) ; else { free ( ( yyvsp [ ( 2 ) - ( 2 ) ] . String ) ) ; yyerror ( ""logfileremoteconfigurationignored"" ) ; } } break ; case 196 : # line 937 ""ntp_parser.y"" { append_queue ( cfgt . logconfig , ( yyvsp [ ( 2 ) - ( 2 ) ] . Queue ) ) ; } break ; case 197 : # line 939 ""ntp_parser.y"" { append_queue ( cfgt . phone , ( yyvsp [ ( 2 ) - ( 2 ) ] . Queue ) ) ; } break ; case 198 : # line 941 ""ntp_parser.y"" { if ( input_from_file ) enqueue ( cfgt . vars , create_attr_sval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . String ) ) ) ; else { free ( ( yyvsp [ ( 2 ) - ( 2 ) ] . String ) ) ; yyerror ( ""saveconfigdirremoteconfigurationignored"" ) ; } } break ; case 199 : # line 951 ""ntp_parser.y"" { enqueue ( cfgt . setvar , ( yyvsp [ ( 2 ) - ( 2 ) ] . Set_var ) ) ; } break ; case 200 : # line 953 ""ntp_parser.y"" { enqueue ( cfgt . trap , create_addr_opts_node ( ( yyvsp [ ( 2 ) - ( 2 ) ] . Address_node ) , NULL ) ) ; } break ; case 201 : # line 955 ""ntp_parser.y"" { enqueue ( cfgt . trap , create_addr_opts_node ( ( yyvsp [ ( 2 ) - ( 3 ) ] . Address_node ) , ( yyvsp [ ( 3 ) - ( 3 ) ] . Queue ) ) ) ; } break ; case 202 : # line 957 ""ntp_parser.y"" { append_queue ( cfgt . ttl , ( yyvsp [ ( 2 ) - ( 2 ) ] . Queue ) ) ; } break ; case 203 : # line 959 ""ntp_parser.y"" { enqueue ( cfgt . qos , create_attr_sval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . String ) ) ) ; } break ; case 204 : # line 964 ""ntp_parser.y"" { enqueue ( cfgt . vars , create_attr_sval ( T_Driftfile , ( yyvsp [ ( 1 ) - ( 1 ) ] . String ) ) ) ; } break ; case 205 : # line 966 ""ntp_parser.y"" { enqueue ( cfgt . vars , create_attr_dval ( T_WanderThreshold , ( yyvsp [ ( 2 ) - ( 2 ) ] . Double ) ) ) ; enqueue ( cfgt . vars , create_attr_sval ( T_Driftfile , ( yyvsp [ ( 1 ) - ( 2 ) ] . String ) ) ) ; } break ; case 206 : # line 969 ""ntp_parser.y"" { enqueue ( cfgt . vars , create_attr_sval ( T_Driftfile , ""\\0"" ) ) ; } break ; case 207 : # line 974 ""ntp_parser.y"" { ( yyval . Set_var ) = create_setvar_node ( ( yyvsp [ ( 1 ) - ( 4 ) ] . String ) , ( yyvsp [ ( 3 ) - ( 4 ) ] . String ) , ( yyvsp [ ( 4 ) - ( 4 ) ] . Integer ) ) ; } break ; case 208 : # line 976 ""ntp_parser.y"" { ( yyval . Set_var ) = create_setvar_node ( ( yyvsp [ ( 1 ) - ( 3 ) ] . String ) , ( yyvsp [ ( 3 ) - ( 3 ) ] . String ) , 0 ) ; } break ; case 209 : # line 981 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Queue ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Attr_val ) ) ; } break ; case 210 : # line 982 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue_in_new_queue ( ( yyvsp [ ( 1 ) - ( 1 ) ] . Attr_val ) ) ; } break ; case 211 : # line 986 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ; } break ; case 212 : # line 987 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_pval ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Integer ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Address_node ) ) ; } break ; case 213 : # line 991 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Queue ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Attr_val ) ) ; } break ; case 214 : # line 992 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue_in_new_queue ( ( yyvsp [ ( 1 ) - ( 1 ) ] . Attr_val ) ) ; } break ; case 215 : # line 997 ""ntp_parser.y"" { char prefix = ( yyvsp [ ( 1 ) - ( 1 ) ] . String ) [ 0 ] ; char * type = ( yyvsp [ ( 1 ) - ( 1 ) ] . String ) + 1 ; if ( prefix != '+' && prefix != '-' && prefix != '=' ) { yyerror ( ""Logconfigprefixisnot\'+\',\'-\'or\'=\'\\n"" ) ; } else ( yyval . Attr_val ) = create_attr_sval ( prefix , estrdup ( type ) ) ; YYFREE ( ( yyvsp [ ( 1 ) - ( 1 ) ] . String ) ) ; } break ; case 216 : # line 1012 ""ntp_parser.y"" { enqueue ( cfgt . nic_rules , create_nic_rule_node ( ( yyvsp [ ( 3 ) - ( 3 ) ] . Integer ) , NULL , ( yyvsp [ ( 2 ) - ( 3 ) ] . Integer ) ) ) ; } break ; case 217 : # line 1017 ""ntp_parser.y"" { enqueue ( cfgt . nic_rules , create_nic_rule_node ( 0 , ( yyvsp [ ( 3 ) - ( 3 ) ] . String ) , ( yyvsp [ ( 2 ) - ( 3 ) ] . Integer ) ) ) ; } break ; case 227 : # line 1048 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Queue ) , create_ival ( ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ) ; } break ; case 228 : # line 1049 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue_in_new_queue ( create_ival ( ( yyvsp [ ( 1 ) - ( 1 ) ] . Integer ) ) ) ; } break ; case 229 : # line 1054 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Queue ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Attr_val ) ) ; } break ; case 230 : # line 1056 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue_in_new_queue ( ( yyvsp [ ( 1 ) - ( 1 ) ] . Attr_val ) ) ; } break ; case 231 : # line 1061 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( 'i' , ( yyvsp [ ( 1 ) - ( 1 ) ] . Integer ) ) ; } break ; case 233 : # line 1067 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_shorts ( '-' , ( yyvsp [ ( 2 ) - ( 5 ) ] . Integer ) , ( yyvsp [ ( 4 ) - ( 5 ) ] . Integer ) ) ; } break ; case 234 : # line 1071 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Queue ) , create_pval ( ( yyvsp [ ( 2 ) - ( 2 ) ] . String ) ) ) ; } break ; case 235 : # line 1072 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue_in_new_queue ( create_pval ( ( yyvsp [ ( 1 ) - ( 1 ) ] . String ) ) ) ; } break ; case 236 : # line 1076 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Queue ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Address_node ) ) ; } break ; case 237 : # line 1077 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue_in_new_queue ( ( yyvsp [ ( 1 ) - ( 1 ) ] . Address_node ) ) ; } break ; case 238 : # line 1082 ""ntp_parser.y"" { if ( ( yyvsp [ ( 1 ) - ( 1 ) ] . Integer ) != 0 && ( yyvsp [ ( 1 ) - ( 1 ) ] . Integer ) != 1 ) { yyerror ( ""Integervalueisnotboolean(0or1).Assuming1"" ) ; ( yyval . Integer ) = 1 ; } else ( yyval . Integer ) = ( yyvsp [ ( 1 ) - ( 1 ) ] . Integer ) ; } break ; case 239 : # line 1090 ""ntp_parser.y"" { ( yyval . Integer ) = 1 ; } break ; case 240 : # line 1091 ""ntp_parser.y"" { ( yyval . Integer ) = 0 ; } break ; case 241 : # line 1095 ""ntp_parser.y"" { ( yyval . Double ) = ( double ) ( yyvsp [ ( 1 ) - ( 1 ) ] . Integer ) ; } break ; case 243 : # line 1106 ""ntp_parser.y"" { cfgt . sim_details = create_sim_node ( ( yyvsp [ ( 3 ) - ( 5 ) ] . Queue ) , ( yyvsp [ ( 4 ) - ( 5 ) ] . Queue ) ) ; old_config_style = 1 ; } break ; case 244 : # line 1120 ""ntp_parser.y"" { old_config_style = 0 ; } break ; case 245 : # line 1124 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue ( ( yyvsp [ ( 1 ) - ( 3 ) ] . Queue ) , ( yyvsp [ ( 2 ) - ( 3 ) ] . Attr_val ) ) ; } break ; case 246 : # line 1125 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue_in_new_queue ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Attr_val ) ) ; } break ; case 247 : # line 1129 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_dval ( ( yyvsp [ ( 1 ) - ( 3 ) ] . Integer ) , ( yyvsp [ ( 3 ) - ( 3 ) ] . Double ) ) ; } break ; case 248 : # line 1130 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_dval ( ( yyvsp [ ( 1 ) - ( 3 ) ] . Integer ) , ( yyvsp [ ( 3 ) - ( 3 ) ] . Double ) ) ; } break ; case 249 : # line 1134 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Queue ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Sim_server ) ) ; } break ; case 250 : # line 1135 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue_in_new_queue ( ( yyvsp [ ( 1 ) - ( 1 ) ] . Sim_server ) ) ; } break ; case 251 : # line 1140 ""ntp_parser.y"" { ( yyval . Sim_server ) = create_sim_server ( ( yyvsp [ ( 1 ) - ( 5 ) ] . Address_node ) , ( yyvsp [ ( 3 ) - ( 5 ) ] . Double ) , ( yyvsp [ ( 4 ) - ( 5 ) ] . Queue ) ) ; } break ; case 252 : # line 1144 ""ntp_parser.y"" { ( yyval . Double ) = ( yyvsp [ ( 3 ) - ( 4 ) ] . Double ) ; } break ; case 253 : # line 1148 ""ntp_parser.y"" { ( yyval . Address_node ) = ( yyvsp [ ( 3 ) - ( 3 ) ] . Address_node ) ; } break ; case 254 : # line 1152 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Queue ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Sim_script ) ) ; } break ; case 255 : # line 1153 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue_in_new_queue ( ( yyvsp [ ( 1 ) - ( 1 ) ] . Sim_script ) ) ; } break ; case 256 : # line 1158 ""ntp_parser.y"" { ( yyval . Sim_script ) = create_sim_script_info ( ( yyvsp [ ( 3 ) - ( 6 ) ] . Double ) , ( yyvsp [ ( 5 ) - ( 6 ) ] . Queue ) ) ; } break ; case 257 : # line 1162 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue ( ( yyvsp [ ( 1 ) - ( 3 ) ] . Queue ) , ( yyvsp [ ( 2 ) - ( 3 ) ] . Attr_val ) ) ; } break ; case 258 : # line 1163 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue_in_new_queue ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Attr_val ) ) ; } break ; case 259 : # line 1168 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_dval ( ( yyvsp [ ( 1 ) - ( 3 ) ] . Integer ) , ( yyvsp [ ( 3 ) - ( 3 ) ] . Double ) ) ; } break ; case 260 : # line 1170 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_dval ( ( yyvsp [ ( 1 ) - ( 3 ) ] . Integer ) , ( yyvsp [ ( 3 ) - ( 3 ) ] . Double ) ) ; } break ; case 261 : # line 1172 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_dval ( ( yyvsp [ ( 1 ) - ( 3 ) ] . Integer ) , ( yyvsp [ ( 3 ) - ( 3 ) ] . Double ) ) ; } break ; case 262 : # line 1174 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_dval ( ( yyvsp [ ( 1 ) - ( 3 ) ] . Integer ) , ( yyvsp [ ( 3 ) - ( 3 ) ] . Double ) ) ; } break ; case 263 : # line 1176 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_dval ( ( yyvsp [ ( 1 ) - ( 3 ) ] . Integer ) , ( yyvsp [ ( 3 ) - ( 3 ) ] . Double ) ) ; } break ; # line 3826 ""ntp_parser.c"" default : break ; } YY_SYMBOL_PRINT ( ""->$$="" , yyr1 [ yyn ] , & yyval , & yyloc ) ; YYPOPSTACK ( yylen ) ; yylen = 0 ; YY_STACK_PRINT ( yyss , yyssp ) ; * ++ yyvsp = yyval ; yyn = yyr1 [ yyn ] ; yystate = yypgoto [ yyn - YYNTOKENS ] + * yyssp ; if ( 0 <= yystate && yystate <= YYLAST && yycheck [ yystate ] == * yyssp ) yystate = yytable [ yystate ] ; else yystate = yydefgoto [ yyn - YYNTOKENS ] ; goto yynewstate ; yyerrlab : if ( ! yyerrstatus ) { ++ yynerrs ; # if ! YYERROR_VERBOSE yyerror ( YY_ ( ""syntaxerror"" ) ) ; # else { YYSIZE_T yysize = yysyntax_error ( 0 , yystate , yychar ) ; if ( yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM ) { YYSIZE_T yyalloc = 2 * yysize ; if ( ! ( yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM ) ) yyalloc = YYSTACK_ALLOC_MAXIMUM ; if ( yymsg != yymsgbuf ) YYSTACK_FREE ( yymsg ) ; yymsg = ( char * ) YYSTACK_ALLOC ( yyalloc ) ; if ( yymsg ) yymsg_alloc = yyalloc ; else { yymsg = yymsgbuf ; yymsg_alloc = sizeof yymsgbuf ; } } if ( 0 < yysize && yysize <= yymsg_alloc ) { ( void ) yysyntax_error ( yymsg , yystate , yychar ) ; yyerror ( yymsg ) ; } else { yyerror ( YY_ ( ""syntaxerror"" ) ) ; if ( yysize != 0 ) goto yyexhaustedlab ; } } # endif } if ( yyerrstatus == 3 ) { if ( yychar <= YYEOF ) { if ( yychar == YYEOF ) YYABORT ; } else { yydestruct ( ""Error:discarding"" , yytoken , & yylval ) ; yychar = YYEMPTY ; } } goto yyerrlab1 ; yyerrorlab : if ( 0 ) goto yyerrorlab ; YYPOPSTACK ( yylen ) ; yylen = 0 ; YY_STACK_PRINT ( yyss , yyssp ) ; yystate = * yyssp ; goto yyerrlab1 ; yyerrlab1 : yyerrstatus = 3 ; for ( ; ; ) { yyn = yypact [ yystate ] ; if ( yyn != YYPACT_NINF ) { yyn += YYTERROR ; if ( 0 <= yyn && yyn <= YYLAST && yycheck [ yyn ] == YYTERROR ) { yyn = yytable [ yyn ] ; if ( 0 < yyn ) break ; } } if ( yyssp == yyss ) YYABORT ; yydestruct ( ""Error:popping"" , yystos [ yystate ] , yyvsp ) ; YYPOPSTACK ( 1 ) ; yystate = * yyssp ; YY_STACK_PRINT ( yyss , yyssp ) ; } * ++ yyvsp = yylval ; YY_SYMBOL_PRINT ( ""Shifting"" , yystos [ yyn ] , yyvsp , yylsp ) ; yystate = yyn ; goto yynewstate ; yyacceptlab : yyresult = 0 ; goto yyreturn ; yyabortlab : yyresult = 1 ; goto yyreturn ; # if ! defined ( yyoverflow ) || YYERROR_VERBOSE yyexhaustedlab : yyerror ( YY_ ( ""memoryexhausted"" ) ) ; yyresult = 2 ; # endif yyreturn : if ( yychar != YYEMPTY ) yydestruct ( ""Cleanup:discardinglookahead"" , yytoken , & yylval ) ; YYPOPSTACK ( yylen ) ; YY_STACK_PRINT ( yyss , yyssp ) ; while ( yyssp != yyss ) { yydestruct ( ""Cleanup:popping"" , yystos [ * yyssp ] , yyvsp ) ; YYPOPSTACK ( 1 ) ; } # ifndef yyoverflow if ( yyss != yyssa ) YYSTACK_FREE ( yyss ) ; # endif # if YYERROR_VERBOSE if ( yymsg != yymsgbuf ) YYSTACK_FREE ( yymsg ) ; # endif return YYID ( yyresult ) ; } "," { char prefix ; char * char * type ; switch ( ( yyvsp [ . String ) [ 0 ] ) { case '+' : case '-' : case '=' : prefix = ( yyvsp [ ( 1 ) - ( 1 ) ] . String ) [ 0 ] ; type = ( yyvsp [ ( 1 ) - ( 1 ) ] . String ) + 1 ; break ; default : prefix = '=' ; type = ( yyvsp [ ( 1 ) - ( 1 ) ] . String ) ; } ( yyval . Attr_val ) = create_attr_sval ( prefix , estrdup ( type ) ) ; YYFREE ( ( yyvsp [ ( 1 ) - ( 1 ) ] . String ) ) ; } break ; case 216 : # line 1022 ""ntp_parser.y"" { enqueue ( cfgt . nic_rules , create_nic_rule_node ( ( yyvsp [ ( 3 ) - ( 3 ) ] . Integer ) , NULL , ( yyvsp [ ( 2 ) - ( 3 ) ] . Integer ) ) ) ; } break ; case 217 : # line 1027 ""ntp_parser.y"" { enqueue ( cfgt . nic_rules , create_nic_rule_node ( 0 , ( yyvsp [ ( 3 ) - ( 3 ) ] . String ) , ( yyvsp [ ( 2 ) - ( 3 ) ] . Integer ) ) ) ; } break ; case 227 : # line 1058 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Queue ) , create_ival ( ( yyvsp [ ( 2 ) - ( 2 ) ] . Integer ) ) ) ; } break ; case 228 : # line 1059 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue_in_new_queue ( create_ival ( ( yyvsp [ ( 1 ) - ( 1 ) ] . Integer ) ) ) ; } break ; case 229 : # line 1064 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Queue ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Attr_val ) ) ; } break ; case 230 : # line 1066 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue_in_new_queue ( ( yyvsp [ ( 1 ) - ( 1 ) ] . Attr_val ) ) ; } break ; case 231 : # line 1071 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_ival ( 'i' , ( yyvsp [ ( 1 ) - ( 1 ) ] . Integer ) ) ; } break ; case 233 : # line 1077 ""ntp_parser.y"" { ( yyval . Attr_val ) = create_attr_shorts ( '-' , ( yyvsp [ ( 2 ) - ( 5 ) ] . Integer ) , ( yyvsp [ ( 4 ) - ( 5 ) ] . Integer ) ) ; } break ; case 234 : # line 1081 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Queue ) , create_pval ( ( yyvsp [ ( 2 ) - ( 2 ) ] . String ) ) ) ; } break ; case 235 : # line 1082 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue_in_new_queue ( create_pval ( ( yyvsp [ ( 1 ) - ( 1 ) ] . String ) ) ) ; } break ; case 236 : # line 1086 ""ntp_parser.y"" { ( yyval . Queue ) = enqueue ( ( yyvsp [ ( 1 ) - ( 2 ) ] . Queue ) . Queue ) , ( yyvsp [ ( 2 ) - ( 2 ) ] . Address_node ) ) ; } break ; case 237 : # line 1087 ""ntp_parser.y"" { ( yyval . Queue ) . Queue ) = enqueue_in_new_queue ( = enqueue_in_new_queue ( ( yyvsp [ ( 1 ) - ( 1 ) ] . break ; case 238 : # : # line 1092 ""ntp_parser.y"" { if : # line 1100 ""ntp_parser.y"" { ( : # line 1101 ""ntp_parser.y"" { ( : # line 1105 ""ntp_parser.y"" { ( : # line 1116 ""ntp_parser.y"" { cfgt : # line 1130 ""ntp_parser.y"" { old_config_style : # line 1134 ""ntp_parser.y"" { ( : # line 1135 ""ntp_parser.y"" { ( : # line 1139 ""ntp_parser.y"" { ( : # line 1140 ""ntp_parser.y"" { ( : # line 1144 ""ntp_parser.y"" { ( : # line 1145 ""ntp_parser.y"" { ( : # line 1150 ""ntp_parser.y"" { ( : # line 1154 ""ntp_parser.y"" { ( : # line 1158 ""ntp_parser.y"" { ( : # line 1162 ""ntp_parser.y"" { ( : # line 1163 ""ntp_parser.y"" { ( : # line 1168 ""ntp_parser.y"" { ( : # line 1172 ""ntp_parser.y"" { ( : # line 1173 ""ntp_parser.y"" { ( : # line 1178 ""ntp_parser.y"" { ( : # line 1180 ""ntp_parser.y"" { ( : # line 1182 ""ntp_parser.y"" { ( : # line 1184 ""ntp_parser.y"" { ( : # line 1186 ""ntp_parser.y"" { ( ; # line 3836 ""ntp_parser.c"" default : ",ntp-project@ntp/553f2fa65865c31c5e3c48812cfd46176cffdd27,CVE-2015-5194,https://github.com/ntp-project/ntp/commit/553f2fa65865c31c5e3c48812cfd46176cffdd27,2017-07-21T14:29Z 1368,CWE-000,"CWE-000 void sas_init_disc ( struct sas_discovery * disc , struct asd_sas_port * port ) { int i ; static const work_func_t sas_event_fns [ DISC_NUM_EVENTS ] = { [ DISCE_DISCOVER_DOMAIN ] = sas_discover_domain , [ DISCE_REVALIDATE_DOMAIN ] = sas_revalidate_domain , [ DISCE_PROBE ] = sas_probe_devices , [ DISCE_SUSPEND ] = sas_suspend_devices , [ DISCE_RESUME ] = sas_resume_devices , [ DISCE_DESTRUCT ] = sas_destruct_devices , } ; disc -> pending = 0 ; for ( i = 0 ; i < DISC_NUM_EVENTS ; i ++ ) { INIT_SAS_WORK ( & disc -> disc_work [ i ] . work , sas_event_fns [ i ] ) ; disc -> disc_work [ i ] . port = port ; } } "," sas_revalidate_domain , [ DISCE_SUSPEND ] = ] = sas_resume_devices , } ; ",torvalds@linux/0558f33c06bb910e2879e355192227a8e8f0219d,CVE-2017-18232,https://github.com/torvalds/linux/commit/0558f33c06bb910e2879e355192227a8e8f0219d,2018-03-15T04:29Z 1369,CWE-362,"CWE-362 int mi_repair_by_sort ( MI_CHECK * param , register MI_INFO * info , const char * name , int rep_quick ) { int got_error ; uint i ; ulong length ; ha_rows start_records ; my_off_t new_header_length , del ; File new_file ; MI_SORT_PARAM sort_param ; MYISAM_SHARE * share = info -> s ; HA_KEYSEG * keyseg ; ulong * rec_per_key_part ; char llbuff [ 22 ] ; SORT_INFO sort_info ; ulonglong UNINIT_VAR ( key_map ) ; DBUG_ENTER ( ""mi_repair_by_sort"" ) ; start_records = info -> state -> records ; got_error = 1 ; new_file = - 1 ; new_header_length = ( param -> testflag & T_UNPACK ) ? 0 : share -> pack . header_length ; if ( ! ( param -> testflag & T_SILENT ) ) { printf ( ""-recovering(withsort)MyISAM-table\'%s\'\\n"" , name ) ; printf ( ""Datarecords:%s\\n"" , llstr ( start_records , llbuff ) ) ; } param -> testflag |= T_REP ; if ( info -> s -> options & ( HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD ) ) param -> testflag |= T_CALC_CHECKSUM ; bzero ( ( char * ) & sort_info , sizeof ( sort_info ) ) ; bzero ( ( char * ) & sort_param , sizeof ( sort_param ) ) ; if ( ! ( sort_info . key_block = alloc_key_blocks ( param , ( uint ) param -> sort_key_blocks , share -> base . max_key_block_length ) ) || init_io_cache ( & param -> read_cache , info -> dfile , ( uint ) param -> read_buffer_length , READ_CACHE , share -> pack . header_length , 1 , MYF ( MY_WME ) ) || ( ! rep_quick && init_io_cache ( & info -> rec_cache , info -> dfile , ( uint ) param -> write_buffer_length , WRITE_CACHE , new_header_length , 1 , MYF ( MY_WME | MY_WAIT_IF_FULL ) & param -> myf_rw ) ) ) goto err ; sort_info . key_block_end = sort_info . key_block + param -> sort_key_blocks ; info -> opt_flag |= WRITE_CACHE_USED ; info -> rec_cache . file = info -> dfile ; if ( ! mi_alloc_rec_buff ( info , - 1 , & sort_param . record ) || ! mi_alloc_rec_buff ( info , - 1 , & sort_param . rec_buff ) ) { mi_check_print_error ( param , ""Notenoughmemoryforextrarecord"" ) ; goto err ; } if ( ! rep_quick ) { if ( ( new_file = mysql_file_create ( mi_key_file_datatmp , fn_format ( param -> temp_filename , share -> data_file_name , """" , DATA_TMP_EXT , 2 + 4 ) , 0 , param -> tmpfile_createflag , MYF ( 0 ) ) ) < 0 ) { mi_check_print_error ( param , ""Can\'tcreatenewtempfile:\'%s\'"" , param -> temp_filename ) ; goto err ; } if ( new_header_length && filecopy ( param , new_file , info -> dfile , 0L , new_header_length , ""datafile-header"" ) ) goto err ; if ( param -> testflag & T_UNPACK ) { share -> options &= ~ HA_OPTION_COMPRESS_RECORD ; mi_int2store ( share -> state . header . options , share -> options ) ; } share -> state . dellink = HA_OFFSET_ERROR ; info -> rec_cache . file = new_file ; } info -> update = ( short ) ( HA_STATE_CHANGED | HA_STATE_ROW_CHANGED ) ; mi_drop_all_indexes ( param , info , FALSE ) ; key_map = share -> state . key_map ; if ( param -> testflag & T_CREATE_MISSING_KEYS ) { key_map = ~ key_map ; } sort_info . info = info ; sort_info . param = param ; set_data_file_type ( & sort_info , share ) ; sort_param . filepos = new_header_length ; sort_info . dupp = 0 ; sort_info . buff = 0 ; param -> read_cache . end_of_file = sort_info . filelength = mysql_file_seek ( param -> read_cache . file , 0L , MY_SEEK_END , MYF ( 0 ) ) ; sort_param . wordlist = NULL ; init_alloc_root ( & sort_param . wordroot , FTPARSER_MEMROOT_ALLOC_SIZE , 0 ) ; if ( share -> data_file_type == DYNAMIC_RECORD ) length = max ( share -> base . min_pack_length + 1 , share -> base . min_block_length ) ; else if ( share -> data_file_type == COMPRESSED_RECORD ) length = share -> base . min_block_length ; else length = share -> base . pack_reclength ; sort_info . max_records = ( ( param -> testflag & T_CREATE_MISSING_KEYS ) ? info -> state -> records : ( ha_rows ) ( sort_info . filelength / length + 1 ) ) ; sort_param . key_cmp = sort_key_cmp ; sort_param . lock_in_memory = lock_memory ; sort_param . tmpdir = param -> tmpdir ; sort_param . sort_info = & sort_info ; sort_param . fix_datafile = ( my_bool ) ( ! rep_quick ) ; sort_param . master = 1 ; del = info -> state -> del ; param -> glob_crc = 0 ; if ( param -> testflag & T_CALC_CHECKSUM ) sort_param . calc_checksum = 1 ; rec_per_key_part = param -> rec_per_key_part ; for ( sort_param . key = 0 ; sort_param . key < share -> base . keys ; rec_per_key_part += sort_param . keyinfo -> keysegs , sort_param . key ++ ) { sort_param . read_cache = param -> read_cache ; sort_param . keyinfo = share -> keyinfo + sort_param . key ; sort_param . seg = sort_param . keyinfo -> seg ; if ( ! mi_is_key_active ( key_map , sort_param . key ) ) { memcpy ( ( char * ) rec_per_key_part , ( char * ) ( share -> state . rec_per_key_part + ( uint ) ( rec_per_key_part - param -> rec_per_key_part ) ) , sort_param . keyinfo -> keysegs * sizeof ( * rec_per_key_part ) ) ; DBUG_PRINT ( ""repair"" , ( ""skippingseeminglydisabledindex#:%u"" , sort_param . key ) ) ; continue ; } if ( ( ! ( param -> testflag & T_SILENT ) ) ) printf ( ""-Fixingindex%d\\n"" , sort_param . key + 1 ) ; sort_param . max_pos = sort_param . pos = share -> pack . header_length ; keyseg = sort_param . seg ; bzero ( ( char * ) sort_param . unique , sizeof ( sort_param . unique ) ) ; sort_param . key_length = share -> rec_reflength ; for ( i = 0 ; keyseg [ i ] . type != HA_KEYTYPE_END ; i ++ ) { sort_param . key_length += keyseg [ i ] . length ; if ( keyseg [ i ] . flag & HA_SPACE_PACK ) sort_param . key_length += get_pack_length ( keyseg [ i ] . length ) ; if ( keyseg [ i ] . flag & ( HA_BLOB_PART | HA_VAR_LENGTH_PART ) ) sort_param . key_length += 2 + test ( keyseg [ i ] . length >= 127 ) ; if ( keyseg [ i ] . flag & HA_NULL_PART ) sort_param . key_length ++ ; } info -> state -> records = info -> state -> del = share -> state . split = 0 ; info -> state -> empty = 0 ; if ( sort_param . keyinfo -> flag & HA_FULLTEXT ) { uint ft_max_word_len_for_sort = FT_MAX_WORD_LEN_FOR_SORT * sort_param . keyinfo -> seg -> charset -> mbmaxlen ; sort_param . key_length += ft_max_word_len_for_sort - HA_FT_MAXBYTELEN ; if ( sort_param . keyinfo -> parser == & ft_default_parser ) { sort_info . max_records = ( ha_rows ) ( sort_info . filelength / ft_min_word_len + 1 ) ; } else { sort_info . max_records = 10 * max ( param -> sort_buffer_length , MIN_SORT_BUFFER ) / sort_param . key_length ; } sort_param . key_read = sort_ft_key_read ; sort_param . key_write = sort_ft_key_write ; } else { sort_param . key_read = sort_key_read ; sort_param . key_write = sort_key_write ; } if ( _create_index_by_sort ( & sort_param , ( my_bool ) ( ! ( param -> testflag & T_VERBOSE ) ) , param -> sort_buffer_length ) ) { param -> retry_repair = 1 ; goto err ; } sort_param . calc_checksum = 0 ; free_root ( & sort_param . wordroot , MYF ( 0 ) ) ; sort_info . max_records = ( ha_rows ) info -> state -> records ; if ( param -> testflag & T_STATISTICS ) update_key_parts ( sort_param . keyinfo , rec_per_key_part , sort_param . unique , param -> stats_method == MI_STATS_METHOD_IGNORE_NULLS ? sort_param . notnull : NULL , ( ulonglong ) info -> state -> records ) ; mi_set_key_active ( share -> state . key_map , sort_param . key ) ; DBUG_PRINT ( ""repair"" , ( ""setenabledindex#:%u"" , sort_param . key ) ) ; if ( sort_param . fix_datafile ) { param -> read_cache . end_of_file = sort_param . filepos ; if ( write_data_suffix ( & sort_info , 1 ) || end_io_cache ( & info -> rec_cache ) ) goto err ; if ( param -> testflag & T_SAFE_REPAIR ) { if ( info -> state -> records + 1 < start_records ) { info -> state -> records = start_records ; goto err ; } } share -> state . state . data_file_length = info -> state -> data_file_length = sort_param . filepos ; share -> state . version = ( ulong ) time ( ( time_t * ) 0 ) ; mysql_file_close ( info -> dfile , MYF ( 0 ) ) ; info -> dfile = new_file ; share -> data_file_type = sort_info . new_data_file_type ; share -> pack . header_length = ( ulong ) new_header_length ; sort_param . fix_datafile = 0 ; } else info -> state -> data_file_length = sort_param . max_pos ; param -> read_cache . file = info -> dfile ; reinit_io_cache ( & param -> read_cache , READ_CACHE , share -> pack . header_length , 1 , 1 ) ; } if ( param -> testflag & T_WRITE_LOOP ) { ( void ) fputs ( ""\\r"" , stdout ) ; ( void ) fflush ( stdout ) ; } if ( rep_quick && del + sort_info . dupp != info -> state -> del ) { mi_check_print_error ( param , ""Couldn\'tfixtablewithquickrecovery:Foundwrongnumberofdeletedrecords"" ) ; mi_check_print_error ( param , ""Runrecoveryagainwithout-q"" ) ; got_error = 1 ; param -> retry_repair = 1 ; param -> testflag |= T_RETRY_WITHOUT_QUICK ; goto err ; } if ( rep_quick & T_FORCE_UNIQUENESS ) { my_off_t skr = info -> state -> data_file_length + ( share -> options & HA_OPTION_COMPRESS_RECORD ? MEMMAP_EXTRA_MARGIN : 0 ) ; # ifdef USE_RELOC if ( share -> data_file_type == STATIC_RECORD && skr < share -> base . reloc * share -> base . min_pack_length ) skr = share -> base . reloc * share -> base . min_pack_length ; # endif if ( skr != sort_info . filelength ) if ( mysql_file_chsize ( info -> dfile , skr , 0 , MYF ( 0 ) ) ) mi_check_print_warning ( param , ""Can\'tchangesizeofdatafile,error:%d"" , my_errno ) ; } if ( param -> testflag & T_CALC_CHECKSUM ) info -> state -> checksum = param -> glob_crc ; if ( mysql_file_chsize ( share -> kfile , info -> state -> key_file_length , 0 , MYF ( 0 ) ) ) mi_check_print_warning ( param , ""Can\'tchangesizeofindexfile,error:%d"" , my_errno ) ; if ( ! ( param -> testflag & T_SILENT ) ) { if ( start_records != info -> state -> records ) printf ( ""Datarecords:%s\\n"" , llstr ( info -> state -> records , llbuff ) ) ; if ( sort_info . dupp ) mi_check_print_warning ( param , ""%srecordshavebeenremoved"" , llstr ( sort_info . dupp , llbuff ) ) ; } got_error = 0 ; if ( & share -> state . state != info -> state ) memcpy ( & share -> state . state , info -> state , sizeof ( * info -> state ) ) ; err : got_error |= flush_blocks ( param , share -> key_cache , share -> kfile ) ; ( void ) end_io_cache ( & info -> rec_cache ) ; if ( ! got_error ) { if ( new_file >= 0 ) { mysql_file_close ( new_file , MYF ( 0 ) ) ; info -> dfile = new_file = - 1 ; if ( change_to_newfile ( share -> data_file_name , MI_NAME_DEXT , DATA_TMP_EXT , ( param -> testflag & T_BACKUP_DATA ? MYF ( MY_REDEL_MAKE_BACKUP ) : MYF ( 0 ) ) ) || mi_open_datafile ( info , share , name , - 1 ) ) got_error = 1 ; } } if ( got_error ) { if ( ! param -> error_printed ) mi_check_print_error ( param , ""%dwhenfixingtable"" , my_errno ) ; if ( new_file >= 0 ) { ( void ) mysql_file_close ( new_file , MYF ( 0 ) ) ; ( void ) mysql_file_delete ( mi_key_file_datatmp , param -> temp_filename , MYF ( MY_WME ) ) ; if ( info -> dfile == new_file ) if ( unlikely ( mi_open_datafile ( info , share , name , - 1 ) ) ) param -> retry_repair = 0 ; } mi_mark_crashed_on_repair ( info ) ; } else if ( key_map == share -> state . key_map ) share -> state . changed &= ~ STATE_NOT_OPTIMIZED_KEYS ; share -> state . changed |= STATE_NOT_SORTED_PAGES ; my_free ( mi_get_rec_buff_ptr ( info , sort_param . rec_buff ) ) ; my_free ( mi_get_rec_buff_ptr ( info , sort_param . record ) ) ; my_free ( sort_info . key_block ) ; my_free ( sort_info . ft_buf ) ; my_free ( sort_info . buff ) ; ( void ) end_io_cache ( & param -> read_cache ) ; info -> opt_flag &= ~ ( READ_CACHE_USED | WRITE_CACHE_USED ) ; if ( ! got_error && ( param -> testflag & T_UNPACK ) ) { share -> state . header . options [ 0 ] &= ( uchar ) ~ HA_OPTION_COMPRESS_RECORD ; share -> pack . header_length = 0 ; } DBUG_RETURN ( got_error ) ; } "," , int rep_quick , my_bool no_copy_stat 0 ) { myf flags = 0 ; if ( param -> testflag & T_BACKUP_DATA ) flags |= MY_REDEL_MAKE_BACKUP ; if ( no_copy_stat ) flags |= MY_REDEL_NO_COPY_STAT ; , DATA_TMP_EXT , flags ) || mi_open_datafile ",MariaDB@server/4e5473862e6852b0f3802b0cd0c6fa10b5253291,CVE-2016-6663,https://github.com/MariaDB/server/commit/4e5473862e6852b0f3802b0cd0c6fa10b5253291,2016-12-13T21:59Z 1370,CWE-000,"CWE-000 static int uECC_sign_with_k ( const uint8_t * private_key , const uint8_t * message_hash , unsigned hash_size , uECC_word_t * k , uint8_t * signature , uECC_Curve curve ) { uECC_word_t tmp [ uECC_MAX_WORDS ] ; uECC_word_t s [ uECC_MAX_WORDS ] ; uECC_word_t * k2 [ 2 ] = { tmp , s } ; # if uECC_VLI_NATIVE_LITTLE_ENDIAN uECC_word_t * p = ( uECC_word_t * ) signature ; # else uECC_word_t p [ uECC_MAX_WORDS * 2 ] ; # endif uECC_word_t carry ; wordcount_t num_words = curve -> num_words ; wordcount_t num_n_words = BITS_TO_WORDS ( curve -> num_n_bits ) ; bitcount_t num_n_bits = curve -> num_n_bits ; if ( uECC_vli_isZero ( k , num_words ) || uECC_vli_cmp ( curve -> n , k , num_n_words ) != 1 ) { return 0 ; } carry = regularize_k ( k , tmp , s , curve ) ; EccPoint_mult ( p , curve -> G , k2 [ ! carry ] , 0 , num_n_bits + 1 , curve ) ; if ( uECC_vli_isZero ( p , num_words ) ) { return 0 ; } if ( ! g_rng_function ) { uECC_vli_clear ( tmp , num_n_words ) ; tmp [ 0 ] = 1 ; } else if ( ! uECC_generate_random_int ( tmp , curve -> n , num_n_words ) ) { return 0 ; } uECC_vli_modMult ( k , k , tmp , curve -> n , num_n_words ) ; uECC_vli_modInv ( k , k , curve -> n , num_n_words ) ; uECC_vli_modMult ( k , k , tmp , curve -> n , num_n_words ) ; # if uECC_VLI_NATIVE_LITTLE_ENDIAN == 0 uECC_vli_nativeToBytes ( signature , curve -> num_bytes , p ) ; # endif # if uECC_VLI_NATIVE_LITTLE_ENDIAN bcopy ( ( uint8_t * ) tmp , private_key , BITS_TO_BYTES ( curve -> num_n_bits ) ) ; # else uECC_vli_bytesToNative ( tmp , private_key , BITS_TO_BYTES ( curve -> num_n_bits ) ) ; # endif s [ num_n_words - 1 ] = 0 ; uECC_vli_set ( s , p , num_words ) ; uECC_vli_modMult ( s , tmp , s , curve -> n , num_n_words ) ; bits2int ( tmp , message_hash , hash_size , curve ) ; uECC_vli_modAdd ( s , tmp , s , curve -> n , num_n_words ) ; uECC_vli_modMult ( s , s , k , curve -> n , num_n_words ) ; if ( uECC_vli_numBits ( s , num_n_words ) > ( bitcount_t ) curve -> num_bytes * 8 ) { return 0 ; } # if uECC_VLI_NATIVE_LITTLE_ENDIAN bcopy ( ( uint8_t * ) signature + curve -> num_bytes , ( uint8_t * ) s , curve -> num_bytes ) ; # else uECC_vli_nativeToBytes ( signature + curve -> num_bytes , curve -> num_bytes , s ) ; # endif return 1 ; } "," s } ; uECC_word_t * initial_Z = 0 ; curve ) ; if ( g_rng_function ) { if ( ! uECC_generate_random_int ( k2 [ carry ] , curve -> p , num_words ) ) { return 0 ; } initial_Z = k2 [ carry ] ; } carry ] , initial_Z , num_n_bits + ",kmackay@micro-ecc/1b5f5cea5145c96dd8791b9b2c41424fc74c2172,CVE-2020-27209,https://github.com/kmackay/micro-ecc/commit/1b5f5cea5145c96dd8791b9b2c41424fc74c2172,2021-05-20T21:15Z 1371,CWE-125,"CWE-125 static void rpl_daoack_print ( netdissect_options * ndo , const u_char * bp , u_int length ) { const struct nd_rpl_daoack * daoack = ( const struct nd_rpl_daoack * ) bp ; const char * dagid_str = """" ; ND_TCHECK2 ( * daoack , ND_RPL_DAOACK_MIN_LEN ) ; if ( length < ND_RPL_DAOACK_MIN_LEN ) goto tooshort ; bp += ND_RPL_DAOACK_MIN_LEN ; length -= ND_RPL_DAOACK_MIN_LEN ; if ( RPL_DAOACK_D ( daoack -> rpl_flags ) ) { ND_TCHECK2 ( daoack -> rpl_dagid , DAGID_LEN ) ; if ( length < DAGID_LEN ) goto tooshort ; dagid_str = ip6addr_string ( ndo , daoack -> rpl_dagid ) ; bp += DAGID_LEN ; length -= DAGID_LEN ; } ND_PRINT ( ( ndo , ""[dagid:%s,seq:%u,instance:%u,status:%u]"" , dagid_str , daoack -> rpl_daoseq , daoack -> rpl_instanceid , daoack -> rpl_status ) ) ; if ( ndo -> ndo_vflag > 1 ) { const struct rpl_dio_genoption * opt = ( const struct rpl_dio_genoption * ) bp ; rpl_dio_printopt ( ndo , opt , length ) ; } return ; trunc : ND_PRINT ( ( ndo , ""[|dao-truncated]"" ) ) ; return ; tooshort : ND_PRINT ( ( ndo , ""[|dao-lengthtooshort]"" ) ) ; return ; } "," ( ndo , ""%s"" , rpl_tstr ) ) ; ",the-tcpdump-group@tcpdump/d7505276842e85bfd067fa21cdb32b8a2dc3c5e4,CVE-2018-14882,https://github.com/the-tcpdump-group/tcpdump/commit/d7505276842e85bfd067fa21cdb32b8a2dc3c5e4,2019-10-03T16:15Z 1372,CWE-200,"CWE-200 int ping_recvmsg ( struct kiocb * iocb , struct sock * sk , struct msghdr * msg , size_t len , int noblock , int flags , int * addr_len ) { struct inet_sock * isk = inet_sk ( sk ) ; int family = sk -> sk_family ; struct sockaddr_in * sin ; struct sockaddr_in6 * sin6 ; struct sk_buff * skb ; int copied , err ; pr_debug ( ""ping_recvmsg(sk=%p,sk->num=%u)\\n"" , isk , isk -> inet_num ) ; err = - EOPNOTSUPP ; if ( flags & MSG_OOB ) goto out ; if ( addr_len ) { if ( family == AF_INET ) * addr_len = sizeof ( * sin ) ; else if ( family == AF_INET6 && addr_len ) * addr_len = sizeof ( * sin6 ) ; } if ( flags & MSG_ERRQUEUE ) { if ( family == AF_INET ) { return ip_recv_error ( sk , msg , len ) ; # if IS_ENABLED ( CONFIG_IPV6 ) } else if ( family == AF_INET6 ) { return pingv6_ops . ipv6_recv_error ( sk , msg , len ) ; # endif } } skb = skb_recv_datagram ( sk , flags , noblock , & err ) ; if ( ! skb ) goto out ; copied = skb -> len ; if ( copied > len ) { msg -> msg_flags |= MSG_TRUNC ; copied = len ; } err = skb_copy_datagram_iovec ( skb , 0 , msg -> msg_iov , copied ) ; if ( err ) goto done ; sock_recv_timestamp ( msg , sk , skb ) ; if ( family == AF_INET ) { sin = ( struct sockaddr_in * ) msg -> msg_name ; sin -> sin_family = AF_INET ; sin -> sin_port = 0 ; sin -> sin_addr . s_addr = ip_hdr ( skb ) -> saddr ; memset ( sin -> sin_zero , 0 , sizeof ( sin -> sin_zero ) ) ; if ( isk -> cmsg_flags ) ip_cmsg_recv ( msg , skb ) ; # if IS_ENABLED ( CONFIG_IPV6 ) } else if ( family == AF_INET6 ) { struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct ipv6hdr * ip6 = ipv6_hdr ( skb ) ; sin6 = ( struct sockaddr_in6 * ) msg -> msg_name ; sin6 -> sin6_family = AF_INET6 ; sin6 -> sin6_port = 0 ; sin6 -> sin6_addr = ip6 -> saddr ; sin6 -> sin6_flowinfo = 0 ; if ( np -> sndflow ) sin6 -> sin6_flowinfo = ip6_flowinfo ( ip6 ) ; sin6 -> sin6_scope_id = ipv6_iface_scope_id ( & sin6 -> sin6_addr , IP6CB ( skb ) -> iif ) ; if ( inet6_sk ( sk ) -> rxopt . all ) pingv6_ops . ip6_datagram_recv_ctl ( sk , msg , skb ) ; # endif } else { BUG ( ) ; } err = copied ; done : skb_free_datagram ( sk , skb ) ; out : pr_debug ( ""ping_recvmsg->%d\\n"" , err ) ; return err ; } "," sk -> sk_family ; struct sk_buff goto out ; if ( flags AF_INET ) { struct sockaddr_in * ) ) ; * addr_len = sizeof ( * sin ) ; skb ) ; struct sockaddr_in6 * struct sockaddr_in6 * sin6 = ( struct sockaddr_in6 * ) -> iif ) ; * addr_len = sizeof ( * sin6 ",torvalds@linux/bceaa90240b6019ed73b49965eac7d167610be69,CVE-2013-7281,https://github.com/torvalds/linux/commit/bceaa90240b6019ed73b49965eac7d167610be69,2014-01-08T16:55Z 1373,CWE-17,"CWE-17 static long ext4_zero_range ( struct file * file , loff_t offset , loff_t len , int mode ) { struct inode * inode = file_inode ( file ) ; handle_t * handle = NULL ; unsigned int max_blocks ; loff_t new_size = 0 ; int ret = 0 ; int flags ; int credits ; int partial_begin , partial_end ; loff_t start , end ; ext4_lblk_t lblk ; struct address_space * mapping = inode -> i_mapping ; unsigned int blkbits = inode -> i_blkbits ; trace_ext4_zero_range ( inode , offset , len , mode ) ; if ( ! S_ISREG ( inode -> i_mode ) ) return - EINVAL ; if ( ext4_should_journal_data ( inode ) ) { ret = ext4_force_commit ( inode -> i_sb ) ; if ( ret ) return ret ; } if ( mapping -> nrpages && mapping_tagged ( mapping , PAGECACHE_TAG_DIRTY ) ) { ret = filemap_write_and_wait_range ( mapping , offset , offset + len - 1 ) ; if ( ret ) return ret ; } start = round_up ( offset , 1 << blkbits ) ; end = round_down ( ( offset + len ) , 1 << blkbits ) ; if ( start < offset || end > offset + len ) return - EINVAL ; partial_begin = offset & ( ( 1 << blkbits ) - 1 ) ; partial_end = ( offset + len ) & ( ( 1 << blkbits ) - 1 ) ; lblk = start >> blkbits ; max_blocks = ( end >> blkbits ) ; if ( max_blocks < lblk ) max_blocks = 0 ; else max_blocks -= lblk ; flags = EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT | EXT4_GET_BLOCKS_CONVERT_UNWRITTEN | EXT4_EX_NOCACHE ; if ( mode & FALLOC_FL_KEEP_SIZE ) flags |= EXT4_GET_BLOCKS_KEEP_SIZE ; mutex_lock ( & inode -> i_mutex ) ; if ( ! ( ext4_test_inode_flag ( inode , EXT4_INODE_EXTENTS ) ) ) { ret = - EOPNOTSUPP ; goto out_mutex ; } if ( ! ( mode & FALLOC_FL_KEEP_SIZE ) && offset + len > i_size_read ( inode ) ) { new_size = offset + len ; ret = inode_newsize_ok ( inode , new_size ) ; if ( ret ) goto out_mutex ; if ( partial_end ) max_blocks += 1 ; } if ( max_blocks > 0 ) { truncate_pagecache_range ( inode , start , end - 1 ) ; inode -> i_mtime = inode -> i_ctime = ext4_current_time ( inode ) ; ext4_inode_block_unlocked_dio ( inode ) ; inode_dio_wait ( inode ) ; ret = ext4_alloc_file_blocks ( file , lblk , max_blocks , new_size , flags , mode ) ; if ( ret ) goto out_dio ; ret = ext4_es_remove_extent ( inode , 0 , EXT_MAX_BLOCKS ) ; if ( ret ) goto out_dio ; } if ( ! partial_begin && ! partial_end ) goto out_dio ; credits = ( 2 * ext4_ext_index_trans_blocks ( inode , 2 ) ) + 1 ; if ( ext4_should_journal_data ( inode ) ) credits += 2 ; handle = ext4_journal_start ( inode , EXT4_HT_MISC , credits ) ; if ( IS_ERR ( handle ) ) { ret = PTR_ERR ( handle ) ; ext4_std_error ( inode -> i_sb , ret ) ; goto out_dio ; } inode -> i_mtime = inode -> i_ctime = ext4_current_time ( inode ) ; if ( new_size ) { ext4_update_inode_size ( inode , new_size ) ; } else { if ( ( offset + len ) > i_size_read ( inode ) ) ext4_set_inode_flag ( inode , EXT4_INODE_EOFBLOCKS ) ; } ext4_mark_inode_dirty ( handle , inode ) ; ret = ext4_zero_partial_blocks ( handle , inode , offset , len ) ; if ( file -> f_flags & O_SYNC ) ext4_handle_sync ( handle ) ; ext4_journal_stop ( handle ) ; out_dio : ext4_inode_resume_unlocked_dio ( inode ) ; out_mutex : mutex_unlock ( & inode -> i_mutex ) ; return ret ; } "," -= lblk ; mutex_lock ( & inode -> i_mutex ) ; if ( ! ( ext4_test_inode_flag ( inode , EXT4_INODE_EXTENTS ) ) ) { ret = - EOPNOTSUPP ; goto out_mutex ; } if ( ! ( mode & & FALLOC_FL_KEEP_SIZE ) && offset + len > i_size_read ( inode ) ) { new_size = offset + len ; ret = inode_newsize_ok ( inode , new_size ) ; if ( ret ) goto out_mutex ; } flags = EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT ; if ( mode & FALLOC_FL_KEEP_SIZE ) |= EXT4_GET_BLOCKS_KEEP_SIZE ; if ( partial_begin || partial_end ) { ret = ext4_alloc_file_blocks ( file , round_down ( offset , 1 << blkbits ) >> blkbits , ( round_up ( ( offset + len ) , 1 << blkbits ) - round_down ( offset , 1 << blkbits ) ) >> blkbits , new_size , flags , mode ) ; if ( ret ) goto out_mutex ; } if 0 ) { flags |= ( EXT4_GET_BLOCKS_CONVERT_UNWRITTEN | EXT4_EX_NOCACHE ) ; ",torvalds@linux/0f2af21aae11972fa924374ddcf52e88347cf5a8,CVE-2015-0275,https://github.com/torvalds/linux/commit/0f2af21aae11972fa924374ddcf52e88347cf5a8,2015-10-19T10:59Z 1374,CWE-190,"CWE-190 void nw_buf_free ( nw_buf_pool * pool , nw_buf * buf ) { if ( pool -> free < pool -> free_total ) { pool -> free_arr [ pool -> free ++ ] = buf ; } else { uint32_t new_free_total = pool -> free_total * 2 ; void * new_arr = realloc ( pool -> free_arr , new_free_total * sizeof ( nw_buf * ) ) ; if ( new_arr ) { pool -> free_total = new_free_total ; pool -> free_arr = new_arr ; pool -> free_arr [ pool -> free ++ ] = buf ; } else { free ( buf ) ; } } } "," ; } else if ( pool -> free_total < NW_BUF_POOL_MAX_SIZE ) ; } } else { free ( buf ) ; } ",viabtc@viabtc_exchange_server/4a7c27bfe98f409623d4d857894d017ff0672cc9,CVE-2018-17568,https://github.com/viabtc/viabtc_exchange_server/commit/4a7c27bfe98f409623d4d857894d017ff0672cc9#diff-0c23effa84a7b85053bac7981a8580c8,2018-09-26T22:29Z 1375,CWE-000,"CWE-000 struct bpf_map * bpf_map_get_with_uref ( u32 ufd ) { struct fd f = fdget ( ufd ) ; struct bpf_map * map ; map = __bpf_map_get ( f ) ; if ( IS_ERR ( map ) ) return map ; bpf_map_inc ( map , true ) ; fdput ( f ) ; return map ; } "," return map ; map = ",torvalds@linux/92117d8443bc5afacc8d5ba82e541946310f106e,CVE-2016-4558,https://github.com/torvalds/linux/commit/92117d8443bc5afacc8d5ba82e541946310f106e,2016-05-23T10:59Z 1376,CWE-269,"CWE-269 STATIC_OVL void escapes ( cp , tp ) const char * cp ; char * tp ; { while ( * cp ) { int cval = 0 , meta = 0 ; if ( * cp == '\\\\' && cp [ 1 ] && index ( ""mM"" , cp [ 1 ] ) && cp [ 2 ] ) { meta = 1 ; cp += 2 ; } if ( * cp == '\\\\' && cp [ 1 ] && index ( ""0123456789xXoO"" , cp [ 1 ] ) && cp [ 2 ] ) { NEARDATA const char hex [ ] = ""00112233445566778899aAbBcCdDeEfF"" ; const char * dp ; int dcount = 0 ; cp ++ ; if ( * cp == 'x' || * cp == 'X' ) for ( ++ cp ; * cp && ( dp = index ( hex , * cp ) ) && ( dcount ++ < 2 ) ; cp ++ ) cval = ( cval * 16 ) + ( ( int ) ( dp - hex ) / 2 ) ; else if ( * cp == 'o' || * cp == 'O' ) for ( ++ cp ; * cp && ( index ( ""01234567"" , * cp ) ) && ( dcount ++ < 3 ) ; cp ++ ) cval = ( cval * 8 ) + ( * cp - '0' ) ; else for ( ; * cp && ( index ( ""0123456789"" , * cp ) ) && ( dcount ++ < 3 ) ; cp ++ ) cval = ( cval * 10 ) + ( * cp - '0' ) ; } else if ( * cp == '\\\\' && cp [ 1 ] ) { switch ( * ++ cp ) { case '\\\\' : cval = '\\\\' ; break ; case 'n' : cval = '\\n' ; break ; case 't' : cval = '\\t' ; break ; case 'b' : cval = '\\b' ; break ; case 'r' : cval = '\\r' ; break ; default : cval = * cp ; } cp ++ ; } else if ( * cp == '^' && cp [ 1 ] ) { cval = ( * ++ cp & 0x1f ) ; cp ++ ; } else cval = * cp ++ ; if ( meta ) cval |= 0x80 ; * tp ++ = cval ; } * tp = '\\0' ; } "," tp ; { static NEARDATA const char NEARDATA const char oct [ ] = ""01234567"" , dec [ ] = ""0123456789"" , dp ; int cval , meta , dcount ; while ( * cp ) { meta = ( * cp == '\\\\' && ( cp [ 1 ] == 'm' || cp [ 1 ] == 'M' ) && cp [ 2 ] ) ; if ( meta ) cp += 2 ; cval = dcount = 0 ; = 0 ; if ( ( * cp != '\\\\' && * cp != '^' ) || ! cp [ 1 ] ) { cval = * cp ++ ; } else if ( * cp == '^' ) { cval = ( * ++ cp & 0x1f ) ; ++ cp ; } else if ( index ( dec , cp [ 1 ] ) ) { ++ cp ; do { cval = ( cval * 10 ) + ( * cp - '0' ) ; } while ( * ++ cp && index ( dec , * cp ) && ++ dcount < 3 ) ; } else if ( ( cp [ 1 ] == 'o' || cp [ 1 ] == 'O' ) && cp [ 2 ] && index ( oct , cp [ 2 ] ) ) { cp += 2 ; do { cval = ( cval * 8 ) + ( * cp - '0' ) ; } while ( * ++ cp && index ( oct , * cp ) && ++ dcount < 3 ) ; } else if ( ( cp [ 1 ] == 'x' || == 'x' || cp [ 1 ] == 'X' ) == 'X' ) && cp [ 2 ] && ( dp ( hex , cp [ 2 ] ) ) != 0 ) { cp += 2 ; do { cval = ( 2 ) ; } while ( * ++ cp && ( dp = index ( hex , * cp ) ) != 0 && ++ dcount < 2 ) ; } else { switch ( cp ; } ++ cp ; } if ( meta tp ++ = ( char ) ",NetHack@NetHack/612755bfb5c412079795c68ba392df5d93874ed8,CVE-2020-5253,https://github.com/NetHack/NetHack/commit/612755bfb5c412079795c68ba392df5d93874ed8,2020-03-10T17:15Z 1377,CWE-119,"CWE-119 int file_is_y4m ( const char detect [ 4 ] ) { if ( memcmp ( detect , ""YUV4"" , 4 ) == 0 ) { return 1 ; } return 0 ; } "," static ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1378,CWE-190,"CWE-190 static void Process_ipfix_template_add ( exporter_ipfix_domain_t * exporter , void * DataPtr , uint32_t size_left , FlowSource_t * fs ) { input_translation_t * translation_table ; ipfix_template_record_t * ipfix_template_record ; ipfix_template_elements_std_t * NextElement ; int i ; while ( size_left ) { uint32_t table_id , count , size_required ; uint32_t num_extensions = 0 ; if ( size_left && size_left < 4 ) { LogError ( ""Process_ipfix[%u]Templatesizeerrorat%sline%u"" , exporter -> info . id , __FILE__ , __LINE__ , strerror ( errno ) ) ; size_left = 0 ; continue ; } ipfix_template_record = ( ipfix_template_record_t * ) DataPtr ; size_left -= 4 ; table_id = ntohs ( ipfix_template_record -> TemplateID ) ; count = ntohs ( ipfix_template_record -> FieldCount ) ; dbg_printf ( ""\\n[%u]TemplateID:%u\\n"" , exporter -> info . id , table_id ) ; dbg_printf ( ""FieldCount:%ubuffersize:%u\\n"" , count , size_left ) ; memset ( ( void * ) cache . common_extensions , 0 , ( Max_num_extensions + 1 ) * sizeof ( uint32_t ) ) ; memset ( ( void * ) cache . lookup_info , 0 , 65536 * sizeof ( struct element_param_s ) ) ; for ( i = 1 ; ipfix_element_map [ i ] . id != 0 ; i ++ ) { uint32_t Type = ipfix_element_map [ i ] . id ; if ( ipfix_element_map [ i ] . id == ipfix_element_map [ i - 1 ] . id ) continue ; cache . lookup_info [ Type ] . index = i ; } cache . input_order = calloc ( count , sizeof ( struct order_s ) ) ; if ( ! cache . input_order ) { LogError ( ""Process_ipfix:Panic!malloc():%sline%d:%s"" , __FILE__ , __LINE__ , strerror ( errno ) ) ; size_left = 0 ; continue ; } cache . input_count = count ; size_required = 4 * count ; if ( size_left < size_required ) { LogError ( ""Process_ipfix:[%u]Notenoughdatafortemplateelements!required:%i,left:%u"" , exporter -> info . id , size_required , size_left ) ; dbg_printf ( ""ERROR:Notenoughdatafortemplateelements!required:%i,left:%u"" , size_required , size_left ) ; return ; } NextElement = ( ipfix_template_elements_std_t * ) ipfix_template_record -> elements ; for ( i = 0 ; i < count ; i ++ ) { uint16_t Type , Length ; uint32_t ext_id ; int Enterprise ; Type = ntohs ( NextElement -> Type ) ; Length = ntohs ( NextElement -> Length ) ; Enterprise = Type & 0x8000 ? 1 : 0 ; Type = Type & 0x7FFF ; ext_id = MapElement ( Type , Length , i ) ; if ( ext_id && extension_descriptor [ ext_id ] . enabled ) { if ( cache . common_extensions [ ext_id ] == 0 ) { cache . common_extensions [ ext_id ] = 1 ; num_extensions ++ ; } } if ( Enterprise ) { ipfix_template_elements_e_t * e = ( ipfix_template_elements_e_t * ) NextElement ; size_required += 4 ; if ( size_left < size_required ) { LogError ( ""Process_ipfix:[%u]Notenoughdatafortemplateelements!required:%i,left:%u"" , exporter -> info . id , size_required , size_left ) ; dbg_printf ( ""ERROR:Notenoughdatafortemplateelements!required:%i,left:%u"" , size_required , size_left ) ; return ; } if ( ntohl ( e -> EnterpriseNumber ) == IPFIX_ReverseInformationElement ) { dbg_printf ( ""[%i]Enterprise:1,Type:%u,Length%uReverseInformationElement:%u\\n"" , i , Type , Length , ntohl ( e -> EnterpriseNumber ) ) ; } else { dbg_printf ( ""[%i]Enterprise:1,Type:%u,Length%uEnterpriseNumber:%u\\n"" , i , Type , Length , ntohl ( e -> EnterpriseNumber ) ) ; } e ++ ; NextElement = ( ipfix_template_elements_std_t * ) e ; } else { dbg_printf ( ""[%i]Enterprise:0,Type:%u,Length%u\\n"" , i , Type , Length ) ; NextElement ++ ; } } dbg_printf ( ""Processed:%u\\n"" , size_required ) ; if ( compact_input_order ( ) ) { if ( extension_descriptor [ EX_ROUTER_IP_v4 ] . enabled ) { if ( cache . common_extensions [ EX_ROUTER_IP_v4 ] == 0 ) { cache . common_extensions [ EX_ROUTER_IP_v4 ] = 1 ; num_extensions ++ ; } dbg_printf ( ""AddsendingrouterIPaddress(%s)=>Extension:%u\\n"" , fs -> sa_family == PF_INET6 ? ""ipv6"" : ""ipv4"" , EX_ROUTER_IP_v4 ) ; } extension_descriptor [ EX_ROUTER_ID ] . enabled = 0 ; if ( extension_descriptor [ EX_RECEIVED ] . enabled ) { if ( cache . common_extensions [ EX_RECEIVED ] == 0 ) { cache . common_extensions [ EX_RECEIVED ] = 1 ; num_extensions ++ ; } dbg_printf ( ""Forceaddpacketreceivedtime,Extension:%u\\n"" , EX_RECEIVED ) ; } # ifdef DEVEL { int i ; for ( i = 4 ; extension_descriptor [ i ] . id ; i ++ ) { if ( cache . common_extensions [ i ] ) { printf ( ""Enabledextension:%i\\n"" , i ) ; } } } # endif translation_table = setup_translation_table ( exporter , table_id ) ; if ( translation_table -> extension_map_changed ) { dbg_printf ( ""TranslationTablechanged!AddextensionmapID:%i\\n"" , translation_table -> extension_info . map -> map_id ) ; AddExtensionMap ( fs , translation_table -> extension_info . map ) ; translation_table -> extension_map_changed = 0 ; dbg_printf ( ""TranslationTableadded!mapID:%i\\n"" , translation_table -> extension_info . map -> map_id ) ; } if ( ! reorder_sequencer ( translation_table ) ) { LogError ( ""Process_ipfix:[%u]Failedtoreordersequencer.Removetableid:%u"" , exporter -> info . id , table_id ) ; remove_translation_table ( fs , exporter , table_id ) ; } } else { dbg_printf ( ""Templatedoesnotcontainanycommonfields-skip\\n"" ) ; } size_left -= size_required ; DataPtr = DataPtr + size_required + 4 ; if ( size_left < 4 ) { dbg_printf ( ""Skip%ubytespadding\\n"" , size_left ) ; size_left = 0 ; } free ( cache . input_order ) ; cache . input_order = NULL ; } } "," ; if ( size_left < 4 ",phaag@nfdump/3b006ededaf351f1723aea6c727c9edd1b1fff9b,CVE-2019-14459,https://github.com/phaag/nfdump/commit/3b006ededaf351f1723aea6c727c9edd1b1fff9b,2019-07-31T21:15Z 1379,CWE-125,"CWE-125 PIX * pixFewColorsOctcubeQuantMixed ( PIX * pixs , l_int32 level , l_int32 darkthresh , l_int32 lightthresh , l_int32 diffthresh , l_float32 minfract , l_int32 maxspan ) { l_int32 i , j , w , h , wplc , wplm , wpld , ncolors , index ; l_int32 rval , gval , bval , val , minval , maxval ; l_int32 * lut ; l_uint32 * datac , * datam , * datad , * linec , * linem , * lined ; PIX * pixc , * pixm , * pixg , * pixd ; PIXCMAP * cmap , * cmapd ; PROCNAME ( ""pixFewColorsOctcubeQuantMixed"" ) ; if ( ! pixs || pixGetDepth ( pixs ) != 32 ) return ( PIX * ) ERROR_PTR ( ""pixsundefinedornot32bpp"" , procName , NULL ) ; if ( level <= 0 ) level = 3 ; if ( level > 6 ) return ( PIX * ) ERROR_PTR ( ""invalidlevel"" , procName , NULL ) ; if ( darkthresh <= 0 ) darkthresh = 20 ; if ( lightthresh <= 0 ) lightthresh = 244 ; if ( diffthresh <= 0 ) diffthresh = 20 ; if ( minfract <= 0.0 ) minfract = 0.05 ; if ( maxspan <= 2 ) maxspan = 15 ; if ( ( pixc = pixFewColorsOctcubeQuant1 ( pixs , level ) ) == NULL ) return ( PIX * ) ERROR_PTR ( ""toomanycolors"" , procName , NULL ) ; cmap = pixGetColormap ( pixc ) ; ncolors = pixcmapGetCount ( cmap ) ; cmapd = pixcmapCreate ( 8 ) ; lut = ( l_int32 * ) LEPT_CALLOC ( 256 , sizeof ( l_int32 ) ) ; for ( i = 0 ; i < 256 ; i ++ ) lut [ i ] = - 1 ; for ( i = 0 , index = 0 ; i < ncolors ; i ++ ) { pixcmapGetColor ( cmap , i , & rval , & gval , & bval ) ; minval = L_MIN ( rval , gval ) ; minval = L_MIN ( minval , bval ) ; if ( minval > lightthresh ) continue ; maxval = L_MAX ( rval , gval ) ; maxval = L_MAX ( maxval , bval ) ; if ( maxval < darkthresh ) continue ; if ( maxval - minval >= diffthresh ) { pixcmapAddColor ( cmapd , rval , gval , bval ) ; lut [ i ] = index ; index ++ ; } } pixGetDimensions ( pixs , & w , & h , NULL ) ; pixd = pixCreate ( w , h , 8 ) ; pixSetColormap ( pixd , cmapd ) ; pixm = pixCreate ( w , h , 1 ) ; datac = pixGetData ( pixc ) ; datam = pixGetData ( pixm ) ; datad = pixGetData ( pixd ) ; wplc = pixGetWpl ( pixc ) ; wplm = pixGetWpl ( pixm ) ; wpld = pixGetWpl ( pixd ) ; for ( i = 0 ; i < h ; i ++ ) { linec = datac + i * wplc ; linem = datam + i * wplm ; lined = datad + i * wpld ; for ( j = 0 ; j < w ; j ++ ) { val = GET_DATA_BYTE ( linec , j ) ; if ( lut [ val ] == - 1 ) SET_DATA_BIT ( linem , j ) ; else SET_DATA_BYTE ( lined , j , lut [ val ] ) ; } } pixg = pixConvertTo8 ( pixs , 0 ) ; pixGrayQuantFromHisto ( pixd , pixg , pixm , minfract , maxspan ) ; LEPT_FREE ( lut ) ; pixDestroy ( & pixc ) ; pixDestroy ( & pixm ) ; pixDestroy ( & pixg ) ; return pixd ; } "," lined ; PIX * pix1 , if ( ( pix1 = pixFewColorsOctcubeQuant1 ( procName , NULL ) ; pixc = pixConvertTo8 ( pix1 , 1 ) ; pixDestroy ( & pix1 ",DanBloomberg@leptonica/5ee24b398bb67666f6d173763eaaedd9c36fb1e5,CVE-2020-36281,https://github.com/DanBloomberg/leptonica/commit/5ee24b398bb67666f6d173763eaaedd9c36fb1e5,2021-03-12T01:15Z 1380,CWE-399,"CWE-399 int BN_GF2m_mod_inv ( BIGNUM * r , const BIGNUM * a , const BIGNUM * p , BN_CTX * ctx ) { BIGNUM * b , * c = NULL , * u = NULL , * v = NULL , * tmp ; int ret = 0 ; bn_check_top ( a ) ; bn_check_top ( p ) ; BN_CTX_start ( ctx ) ; if ( ( b = BN_CTX_get ( ctx ) ) == NULL ) goto err ; if ( ( c = BN_CTX_get ( ctx ) ) == NULL ) goto err ; if ( ( u = BN_CTX_get ( ctx ) ) == NULL ) goto err ; if ( ( v = BN_CTX_get ( ctx ) ) == NULL ) goto err ; if ( ! BN_GF2m_mod ( u , a , p ) ) goto err ; if ( BN_is_zero ( u ) ) goto err ; if ( ! BN_copy ( v , p ) ) goto err ; # if 0 if ( ! BN_one ( b ) ) goto err ; while ( 1 ) { while ( ! BN_is_odd ( u ) ) { if ( BN_is_zero ( u ) ) goto err ; if ( ! BN_rshift1 ( u , u ) ) goto err ; if ( BN_is_odd ( b ) ) { if ( ! BN_GF2m_add ( b , b , p ) ) goto err ; } if ( ! BN_rshift1 ( b , b ) ) goto err ; } if ( BN_abs_is_word ( u , 1 ) ) break ; if ( BN_num_bits ( u ) < BN_num_bits ( v ) ) { tmp = u ; u = v ; v = tmp ; tmp = b ; b = c ; c = tmp ; } if ( ! BN_GF2m_add ( u , u , v ) ) goto err ; if ( ! BN_GF2m_add ( b , b , c ) ) goto err ; } # else { int i , ubits = BN_num_bits ( u ) , vbits = BN_num_bits ( v ) , top = p -> top ; BN_ULONG * udp , * bdp , * vdp , * cdp ; bn_wexpand ( u , top ) ; udp = u -> d ; for ( i = u -> top ; i < top ; i ++ ) udp [ i ] = 0 ; u -> top = top ; bn_wexpand ( b , top ) ; bdp = b -> d ; bdp [ 0 ] = 1 ; for ( i = 1 ; i < top ; i ++ ) bdp [ i ] = 0 ; b -> top = top ; bn_wexpand ( c , top ) ; cdp = c -> d ; for ( i = 0 ; i < top ; i ++ ) cdp [ i ] = 0 ; c -> top = top ; vdp = v -> d ; while ( 1 ) { while ( ubits && ! ( udp [ 0 ] & 1 ) ) { BN_ULONG u0 , u1 , b0 , b1 , mask ; u0 = udp [ 0 ] ; b0 = bdp [ 0 ] ; mask = ( BN_ULONG ) 0 - ( b0 & 1 ) ; b0 ^= p -> d [ 0 ] & mask ; for ( i = 0 ; i < top - 1 ; i ++ ) { u1 = udp [ i + 1 ] ; udp [ i ] = ( ( u0 >> 1 ) | ( u1 << ( BN_BITS2 - 1 ) ) ) & BN_MASK2 ; u0 = u1 ; b1 = bdp [ i + 1 ] ^ ( p -> d [ i + 1 ] & mask ) ; bdp [ i ] = ( ( b0 >> 1 ) | ( b1 << ( BN_BITS2 - 1 ) ) ) & BN_MASK2 ; b0 = b1 ; } udp [ i ] = u0 >> 1 ; bdp [ i ] = b0 >> 1 ; ubits -- ; } if ( ubits <= BN_BITS2 && udp [ 0 ] == 1 ) break ; if ( ubits < vbits ) { i = ubits ; ubits = vbits ; vbits = i ; tmp = u ; u = v ; v = tmp ; tmp = b ; b = c ; c = tmp ; udp = vdp ; vdp = v -> d ; bdp = cdp ; cdp = c -> d ; } for ( i = 0 ; i < top ; i ++ ) { udp [ i ] ^= vdp [ i ] ; bdp [ i ] ^= cdp [ i ] ; } if ( ubits == vbits ) { BN_ULONG ul ; int utop = ( ubits - 1 ) / BN_BITS2 ; while ( ( ul = udp [ utop ] ) == 0 && utop ) utop -- ; ubits = utop * BN_BITS2 + BN_num_bits_word ( ul ) ; } } bn_correct_top ( b ) ; } # endif if ( ! BN_copy ( r , b ) ) goto err ; bn_check_top ( r ) ; ret = 1 ; err : # ifdef BN_DEBUG bn_correct_top ( c ) ; bn_correct_top ( u ) ; bn_correct_top ( v ) ; # endif BN_CTX_end ( ctx ) ; return ret ; } "," { int i ; int ubits = BN_num_bits ( u ) ; int vbits = BN_num_bits ( v ) ; int top = p ubits <= BN_BITS2 ) { if ( udp [ 0 0 ] == 0 ) goto err ; if ( udp [ 0 ] == ) break ; } ",openssl@openssl/4924b37ee01f71ae19c94a8934b80eeb2f677932,CVE-2015-1788,https://github.com/openssl/openssl/commit/4924b37ee01f71ae19c94a8934b80eeb2f677932,2015-06-12T19:59Z 1381,CWE-119,"CWE-119 static void first_pass_motion_search ( VP8_COMP * cpi , MACROBLOCK * x , int_mv * ref_mv , MV * best_mv , YV12_BUFFER_CONFIG * recon_buffer , int * best_motion_err , int recon_yoffset ) { MACROBLOCKD * const xd = & x -> e_mbd ; BLOCK * b = & x -> block [ 0 ] ; BLOCKD * d = & x -> e_mbd . block [ 0 ] ; int num00 ; int_mv tmp_mv ; int_mv ref_mv_full ; int tmp_err ; int step_param = 3 ; int further_steps = ( MAX_MVSEARCH_STEPS - 1 ) - step_param ; int n ; vp8_variance_fn_ptr_t v_fn_ptr = cpi -> fn_ptr [ BLOCK_16X16 ] ; int new_mv_mode_penalty = 256 ; v_fn_ptr . vf = vp8_mse16x16 ; xd -> pre . y_buffer = recon_buffer -> y_buffer + recon_yoffset ; tmp_mv . as_int = 0 ; ref_mv_full . as_mv . col = ref_mv -> as_mv . col >> 3 ; ref_mv_full . as_mv . row = ref_mv -> as_mv . row >> 3 ; tmp_err = cpi -> diamond_search_sad ( x , b , d , & ref_mv_full , & tmp_mv , step_param , x -> sadperbit16 , & num00 , & v_fn_ptr , x -> mvcost , ref_mv ) ; if ( tmp_err < INT_MAX - new_mv_mode_penalty ) tmp_err += new_mv_mode_penalty ; if ( tmp_err < * best_motion_err ) { * best_motion_err = tmp_err ; best_mv -> row = tmp_mv . as_mv . row ; best_mv -> col = tmp_mv . as_mv . col ; } n = num00 ; num00 = 0 ; while ( n < further_steps ) { n ++ ; if ( num00 ) num00 -- ; else { tmp_err = cpi -> diamond_search_sad ( x , b , d , & ref_mv_full , & tmp_mv , step_param + n , x -> sadperbit16 , & num00 , & v_fn_ptr , x -> mvcost , ref_mv ) ; if ( tmp_err < INT_MAX - new_mv_mode_penalty ) tmp_err += new_mv_mode_penalty ; if ( tmp_err < * best_motion_err ) { * best_motion_err = tmp_err ; best_mv -> row = tmp_mv . as_mv . row ; best_mv -> col = tmp_mv . as_mv . col ; } } } } "," . vf = vpx_mse16x16 ; xd -> ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1382,CWE-000,"CWE-000 static int crypto_report_kpp ( struct sk_buff * skb , struct crypto_alg * alg ) { struct crypto_report_kpp rkpp ; strlcpy ( rkpp . type , ""kpp"" , sizeof ( rkpp . type ) ) ; if ( nla_put ( skb , CRYPTOCFGA_REPORT_KPP , sizeof ( struct crypto_report_kpp ) , & rkpp ) ) goto nla_put_failure ; return 0 ; nla_put_failure : return - EMSGSIZE ; } "," crypto_report_kpp rkpp ; strncpy ( rkpp . ",torvalds@linux/f43f39958beb206b53292801e216d9b8a660f087,CVE-2018-19854,https://github.com/torvalds/linux/commit/f43f39958beb206b53292801e216d9b8a660f087,2018-12-04T16:29Z 1383,CWE-89,"CWE-89 char * curl_easy_escape ( CURL * handle , const char * string , int inlength ) { size_t alloc = ( inlength ? ( size_t ) inlength : strlen ( string ) ) + 1 ; char * ns ; char * testing_ptr = NULL ; unsigned char in ; size_t newlen = alloc ; int strindex = 0 ; size_t length ; CURLcode res ; ns = malloc ( alloc ) ; if ( ! ns ) return NULL ; length = alloc - 1 ; while ( length -- ) { in = * string ; if ( Curl_isunreserved ( in ) ) ns [ strindex ++ ] = in ; else { newlen += 2 ; if ( newlen > alloc ) { alloc *= 2 ; testing_ptr = realloc ( ns , alloc ) ; if ( ! testing_ptr ) { free ( ns ) ; return NULL ; } else { ns = testing_ptr ; } } res = Curl_convert_to_network ( handle , & in , 1 ) ; if ( res ) { free ( ns ) ; return NULL ; } snprintf ( & ns [ strindex ] , 4 , ""%%%02X"" , in ) ; strindex += 3 ; } string ++ ; } ns [ strindex ] = 0 ; return ns ; } "," = alloc ; size_t strindex = 0 ",bagder@curl/75ca568fa1c19de4c5358fed246686de8467c238,CVE-2012-0036,https://github.com/bagder/curl/commit/75ca568fa1c19de4c5358fed246686de8467c238,2012-04-13T20:55Z 1384,CWE-119,"CWE-119 int MSG_ReadBits ( msg_t * msg , int bits ) { int value ; int get ; qboolean sgn ; int i , nbits ; value = 0 ; if ( bits < 0 ) { bits = - bits ; sgn = qtrue ; } else { sgn = qfalse ; } if ( msg -> oob ) { if ( bits == 8 ) { value = msg -> data [ msg -> readcount ] ; msg -> readcount += 1 ; msg -> bit += 8 ; } else if ( bits == 16 ) { short temp ; CopyLittleShort ( & temp , & msg -> data [ msg -> readcount ] ) ; value = temp ; msg -> readcount += 2 ; msg -> bit += 16 ; } else if ( bits == 32 ) { CopyLittleLong ( & value , & msg -> data [ msg -> readcount ] ) ; msg -> readcount += 4 ; msg -> bit += 32 ; } else Com_Error ( ERR_DROP , ""can\'tread%dbits"" , bits ) ; } else { nbits = 0 ; if ( bits & 7 ) { nbits = bits & 7 ; for ( i = 0 ; i < nbits ; i ++ ) { value |= ( Huff_getBit ( msg -> data , & msg -> bit ) << i ) ; } bits = bits - nbits ; } if ( bits ) { for ( i = 0 ; i < bits ; i += 8 ) { Huff_offsetReceive ( msgHuff . decompressor . tree , & get , msg -> data , & msg -> bit ) ; value |= ( get << ( i + nbits ) ) ; } } msg -> readcount = ( msg -> bit >> 3 ) + 1 ; } if ( sgn && bits > 0 && bits < 32 ) { if ( value & ( 1 << ( bits - 1 ) ) ) { value |= - 1 ^ ( ( 1 << bits ) - 1 ) ; } } return value ; } "," , nbits ; if ( msg -> readcount > msg -> cursize ) { return 0 ; } oob ) { if ( msg -> readcount + ( bits >> 3 ) > msg -> cursize ) { msg -> readcount = msg -> cursize + 1 ; return 0 ; } & 7 ; if ( msg -> bit + nbits > msg -> cursize << 3 ) { msg -> readcount = msg -> cursize + 1 ; return 0 ; } msg -> bit , msg -> cursize << 3 ) ) ; if ( msg -> bit > msg -> cursize << 3 ) { msg -> readcount = msg -> cursize + 1 ; return 0 ; } ",ioquake@ioq3/d2b1d124d4055c2fcbe5126863487c52fd58cca1,CVE-2017-11721,https://github.com/ioquake/ioq3/commit/d2b1d124d4055c2fcbe5126863487c52fd58cca1,2017-08-03T08:29Z 1385,CWE-416,"CWE-416 int snd_ctl_add ( struct snd_card * card , struct snd_kcontrol * kcontrol ) { struct snd_ctl_elem_id id ; unsigned int idx ; int err = - EINVAL ; if ( ! kcontrol ) return err ; if ( snd_BUG_ON ( ! card || ! kcontrol -> info ) ) goto error ; id = kcontrol -> id ; down_write ( & card -> controls_rwsem ) ; if ( snd_ctl_find_id ( card , & id ) ) { up_write ( & card -> controls_rwsem ) ; dev_err ( card -> dev , ""control%i:%i:%i:%s:%iisalreadypresent\\n"" , id . iface , id . device , id . subdevice , id . name , id . index ) ; err = - EBUSY ; goto error ; } if ( snd_ctl_find_hole ( card , kcontrol -> count ) < 0 ) { up_write ( & card -> controls_rwsem ) ; err = - ENOMEM ; goto error ; } list_add_tail ( & kcontrol -> list , & card -> controls ) ; card -> controls_count += kcontrol -> count ; kcontrol -> id . numid = card -> last_numid + 1 ; card -> last_numid += kcontrol -> count ; up_write ( & card -> controls_rwsem ) ; for ( idx = 0 ; idx < kcontrol -> count ; idx ++ , id . index ++ , id . numid ++ ) snd_ctl_notify ( card , SNDRV_CTL_EVENT_MASK_ADD , & id ) ; return 0 ; error : snd_ctl_free_one ( kcontrol ) ; return err ; } "," int idx ; unsigned int count ; -> count ; count = kcontrol -> count ; ; idx < count ; idx ",torvalds@linux/fd9f26e4eca5d08a27d12c0933fceef76ed9663d,CVE-2014-4653,https://github.com/torvalds/linux/commit/fd9f26e4eca5d08a27d12c0933fceef76ed9663d,2014-07-03T04:22Z 1386,CWE-000,"CWE-000 int usbnet_probe ( struct usb_interface * udev , const struct usb_device_id * prod ) { struct usbnet * dev ; struct net_device * net ; struct usb_host_interface * interface ; struct driver_info * info ; struct usb_device * xdev ; int status ; const char * name ; struct usb_driver * driver = to_usb_driver ( udev -> dev . driver ) ; if ( ! driver -> supports_autosuspend ) { driver -> supports_autosuspend = 1 ; pm_runtime_enable ( & udev -> dev ) ; } name = udev -> dev . driver -> name ; info = ( struct driver_info * ) prod -> driver_info ; if ( ! info ) { dev_dbg ( & udev -> dev , ""blacklistedby%s\\n"" , name ) ; return - ENODEV ; } xdev = interface_to_usbdev ( udev ) ; interface = udev -> cur_altsetting ; status = - ENOMEM ; net = alloc_etherdev ( sizeof ( * dev ) ) ; if ( ! net ) goto out ; SET_NETDEV_DEV ( net , & udev -> dev ) ; dev = netdev_priv ( net ) ; dev -> udev = xdev ; dev -> intf = udev ; dev -> driver_info = info ; dev -> driver_name = name ; dev -> msg_enable = netif_msg_init ( msg_level , NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK ) ; init_waitqueue_head ( & dev -> wait ) ; skb_queue_head_init ( & dev -> rxq ) ; skb_queue_head_init ( & dev -> txq ) ; skb_queue_head_init ( & dev -> done ) ; skb_queue_head_init ( & dev -> rxq_pause ) ; dev -> bh . func = usbnet_bh ; dev -> bh . data = ( unsigned long ) dev ; INIT_WORK ( & dev -> kevent , usbnet_deferred_kevent ) ; init_usb_anchor ( & dev -> deferred ) ; dev -> delay . function = usbnet_bh ; dev -> delay . data = ( unsigned long ) dev ; init_timer ( & dev -> delay ) ; mutex_init ( & dev -> phy_mutex ) ; mutex_init ( & dev -> interrupt_mutex ) ; dev -> interrupt_count = 0 ; dev -> net = net ; strcpy ( net -> name , ""usb%d"" ) ; memcpy ( net -> dev_addr , node_id , sizeof node_id ) ; dev -> hard_mtu = net -> mtu + net -> hard_header_len ; net -> netdev_ops = & usbnet_netdev_ops ; net -> watchdog_timeo = TX_TIMEOUT_JIFFIES ; net -> ethtool_ops = & usbnet_ethtool_ops ; if ( info -> bind ) { status = info -> bind ( dev , udev ) ; if ( status < 0 ) goto out1 ; if ( ( dev -> driver_info -> flags & FLAG_ETHER ) != 0 && ( ( dev -> driver_info -> flags & FLAG_POINTTOPOINT ) == 0 || ( net -> dev_addr [ 0 ] & 0x02 ) == 0 ) ) strcpy ( net -> name , ""eth%d"" ) ; if ( ( dev -> driver_info -> flags & FLAG_WLAN ) != 0 ) strcpy ( net -> name , ""wlan%d"" ) ; if ( ( dev -> driver_info -> flags & FLAG_WWAN ) != 0 ) strcpy ( net -> name , ""wwan%d"" ) ; if ( ( dev -> driver_info -> flags & FLAG_NOARP ) != 0 ) net -> flags |= IFF_NOARP ; if ( net -> mtu > ( dev -> hard_mtu - net -> hard_header_len ) ) net -> mtu = dev -> hard_mtu - net -> hard_header_len ; } else if ( ! info -> in || ! info -> out ) status = usbnet_get_endpoints ( dev , udev ) ; else { dev -> in = usb_rcvbulkpipe ( xdev , info -> in ) ; dev -> out = usb_sndbulkpipe ( xdev , info -> out ) ; if ( ! ( info -> flags & FLAG_NO_SETINT ) ) status = usb_set_interface ( xdev , interface -> desc . bInterfaceNumber , interface -> desc . bAlternateSetting ) ; else status = 0 ; } if ( status >= 0 && dev -> status ) status = init_status ( dev , udev ) ; if ( status < 0 ) goto out3 ; if ( ! dev -> rx_urb_size ) dev -> rx_urb_size = dev -> hard_mtu ; dev -> maxpacket = usb_maxpacket ( dev -> udev , dev -> out , 1 ) ; if ( ether_addr_equal ( net -> dev_addr , node_id ) ) net -> addr_assign_type = NET_ADDR_RANDOM ; if ( ( dev -> driver_info -> flags & FLAG_WLAN ) != 0 ) SET_NETDEV_DEVTYPE ( net , & wlan_type ) ; if ( ( dev -> driver_info -> flags & FLAG_WWAN ) != 0 ) SET_NETDEV_DEVTYPE ( net , & wwan_type ) ; usbnet_update_max_qlen ( dev ) ; if ( dev -> can_dma_sg && ! ( info -> flags & FLAG_SEND_ZLP ) && ! ( info -> flags & FLAG_MULTI_PACKET ) ) { dev -> padding_pkt = kzalloc ( 1 , GFP_KERNEL ) ; if ( ! dev -> padding_pkt ) { status = - ENOMEM ; goto out4 ; } } status = register_netdev ( net ) ; if ( status ) goto out5 ; netif_info ( dev , probe , dev -> net , ""register\'%s\'atusb-%s-%s,%s,%pM\\n"" , udev -> dev . driver -> name , xdev -> bus -> bus_name , xdev -> devpath , dev -> driver_info -> description , net -> dev_addr ) ; usb_set_intfdata ( udev , dev ) ; netif_device_attach ( net ) ; if ( dev -> driver_info -> flags & FLAG_LINK_INTR ) usbnet_link_change ( dev , 0 , 0 ) ; return 0 ; out5 : kfree ( dev -> padding_pkt ) ; out4 : usb_free_urb ( dev -> interrupt ) ; out3 : if ( info -> unbind ) info -> unbind ( dev , udev ) ; out1 : free_netdev ( net ) ; out : return status ; } "," ; out1 : cancel_work_sync ( & dev -> kevent ) ; del_timer_sync ( & dev -> delay ) ; ",torvalds@linux/1666984c8625b3db19a9abc298931d35ab7bc64b,CVE-2016-3951,https://github.com/torvalds/linux/commit/1666984c8625b3db19a9abc298931d35ab7bc64b,2016-05-02T10:59Z 1387,CWE-190,"CWE-190 MONGO_EXPORT int mongo_insert_batch ( mongo * conn , const char * ns , const bson * * bsons , int count , mongo_write_concern * custom_write_concern , int flags ) { mongo_message * mm ; mongo_write_concern * write_concern = NULL ; int i ; char * data ; int overhead = 16 + 4 + strlen ( ns ) + 1 ; int size = overhead ; if ( mongo_validate_ns ( conn , ns ) != MONGO_OK ) return MONGO_ERROR ; for ( i = 0 ; i < count ; i ++ ) { size += bson_size ( bsons [ i ] ) ; if ( mongo_bson_valid ( conn , bsons [ i ] , 1 ) != MONGO_OK ) return MONGO_ERROR ; } if ( ( size - overhead ) > conn -> max_bson_size ) { conn -> err = MONGO_BSON_TOO_LARGE ; return MONGO_ERROR ; } if ( mongo_choose_write_concern ( conn , custom_write_concern , & write_concern ) == MONGO_ERROR ) { return MONGO_ERROR ; } mm = mongo_message_create ( size , 0 , 0 , MONGO_OP_INSERT ) ; data = & mm -> data ; if ( flags & MONGO_CONTINUE_ON_ERROR ) data = mongo_data_append32 ( data , & ONE ) ; else data = mongo_data_append32 ( data , & ZERO ) ; data = mongo_data_append ( data , ns , strlen ( ns ) + 1 ) ; for ( i = 0 ; i < count ; i ++ ) { data = mongo_data_append ( data , bsons [ i ] -> data , bson_size ( bsons [ i ] ) ) ; } if ( write_concern ) { if ( mongo_message_send ( conn , mm ) == MONGO_ERROR ) { return MONGO_ERROR ; } return mongo_check_last_error ( conn , ns , write_concern ) ; } else { return mongo_message_send ( conn , mm ) ; } } "," * data ; size_t overhead = 16 + 1 ; size_t size = overhead ",10gen-archive@mongo-c-driver-legacy/1a1f5e26a4309480d88598913f9eebf9e9cba8ca,CVE-2020-12135,https://github.com/10gen-archive/mongo-c-driver-legacy/commit/1a1f5e26a4309480d88598913f9eebf9e9cba8ca,2020-04-24T01:15Z 1388,CWE-200,"CWE-200 static void tv_details_row_activated ( GtkTreeView * tree_view , GtkTreePath * tree_path_UNUSED , GtkTreeViewColumn * column , gpointer user_data ) { gchar * item_name ; struct problem_item * item = get_current_problem_item_or_NULL ( tree_view , & item_name ) ; if ( ! item || ! ( item -> flags & CD_FLAG_TXT ) ) goto ret ; if ( ! strchr ( item -> content , '\\n' ) ) goto ret ; gint exitcode ; gchar * arg [ 3 ] ; arg [ 0 ] = ( char * ) ""xdg-open"" ; arg [ 1 ] = concat_path_file ( g_dump_dir_name , item_name ) ; arg [ 2 ] = NULL ; const gboolean spawn_ret = g_spawn_sync ( NULL , arg , NULL , G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL , NULL , NULL , NULL , NULL , & exitcode , NULL ) ; if ( spawn_ret == FALSE || exitcode != EXIT_SUCCESS ) { GtkWidget * dialog = gtk_dialog_new_with_buttons ( _ ( ""View/editatextfile"" ) , GTK_WINDOW ( g_wnd_assistant ) , GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT , NULL , NULL ) ; GtkWidget * vbox = gtk_dialog_get_content_area ( GTK_DIALOG ( dialog ) ) ; GtkWidget * scrolled = gtk_scrolled_window_new ( NULL , NULL ) ; GtkWidget * textview = gtk_text_view_new ( ) ; gtk_dialog_add_button ( GTK_DIALOG ( dialog ) , _ ( ""_Save"" ) , GTK_RESPONSE_OK ) ; gtk_dialog_add_button ( GTK_DIALOG ( dialog ) , _ ( ""_Cancel"" ) , GTK_RESPONSE_CANCEL ) ; gtk_box_pack_start ( GTK_BOX ( vbox ) , scrolled , TRUE , TRUE , 0 ) ; gtk_widget_set_size_request ( scrolled , 640 , 480 ) ; gtk_widget_show ( scrolled ) ; # if ( ( GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION < 7 ) || ( GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION == 7 && GTK_MICRO_VERSION < 8 ) ) gtk_scrolled_window_add_with_viewport ( GTK_SCROLLED_WINDOW ( scrolled ) , textview ) ; # else gtk_container_add ( GTK_CONTAINER ( scrolled ) , textview ) ; # endif gtk_widget_show ( textview ) ; load_text_to_text_view ( GTK_TEXT_VIEW ( textview ) , item_name ) ; if ( gtk_dialog_run ( GTK_DIALOG ( dialog ) ) == GTK_RESPONSE_OK ) save_text_from_text_view ( GTK_TEXT_VIEW ( textview ) , item_name ) ; gtk_widget_destroy ( textview ) ; gtk_widget_destroy ( scrolled ) ; gtk_widget_destroy ( dialog ) ; } free ( arg [ 1 ] ) ; ret : g_free ( item_name ) ; } "," == GTK_RESPONSE_OK ) { item_name ) ; problem_data_reload_from_dump_dir ( ) ; update_gui_state_from_problem_data ( 0 ) ; } ",abrt@libreport/257578a23d1537a2d235aaa2b1488ee4f818e360,CVE-2015-5302,https://github.com/abrt/libreport/commit/257578a23d1537a2d235aaa2b1488ee4f818e360,2015-12-07T18:59Z 1389,CWE-20,"CWE-20 int handle ( int s , unsigned char * data , int len , struct sockaddr_in * s_in ) { char buf [ 2048 ] ; unsigned short * cmd = ( unsigned short * ) buf ; int plen ; struct in_addr * addr = & s_in -> sin_addr ; unsigned short * pid = ( unsigned short * ) data ; if ( len == S_HELLO_LEN && memcmp ( data , ""sorbo"" , 5 ) == 0 ) { unsigned short * id = ( unsigned short * ) ( data + 5 ) ; int x = 2 + 4 + 2 ; * cmd = htons ( S_CMD_INET_CHECK ) ; memcpy ( cmd + 1 , addr , 4 ) ; memcpy ( cmd + 1 + 2 , id , 2 ) ; printf ( ""Inetcheckby%s%d\\n"" , inet_ntoa ( * addr ) , ntohs ( * id ) ) ; if ( send ( s , buf , x , 0 ) != x ) return 1 ; return 0 ; } * cmd ++ = htons ( S_CMD_PACKET ) ; * cmd ++ = * pid ; plen = len - 2 ; last_id = ntohs ( * pid ) ; if ( last_id > 20000 ) wrap = 1 ; if ( wrap && last_id < 100 ) { wrap = 0 ; memset ( ids , 0 , sizeof ( ids ) ) ; } printf ( ""Gotpacket%d%d"" , last_id , plen ) ; if ( is_dup ( last_id ) ) { printf ( ""(DUP)\\n"" ) ; return 0 ; } printf ( ""\\n"" ) ; * cmd ++ = htons ( plen ) ; memcpy ( cmd , data + 2 , plen ) ; plen += 2 + 2 + 2 ; assert ( plen <= ( int ) sizeof ( buf ) ) ; if ( send ( s , buf , plen , 0 ) != plen ) return 1 ; return 0 ; } "," - 2 ; if ( plen < 0 ) return 0 ; ",aircrack-ng@aircrack-ng/da087238963c1239fdabd47dc1b65279605aca70,CVE-2014-8323,https://github.com/aircrack-ng/aircrack-ng/commit/da087238963c1239fdabd47dc1b65279605aca70,2017-10-17T14:29Z 1390,CWE-285,"CWE-285 static int v9fs_xattr_set_acl ( const struct xattr_handler * handler , struct dentry * dentry , struct inode * inode , const char * name , const void * value , size_t size , int flags ) { int retval ; struct posix_acl * acl ; struct v9fs_session_info * v9ses ; v9ses = v9fs_dentry2v9ses ( dentry ) ; if ( ( v9ses -> flags & V9FS_ACCESS_MASK ) != V9FS_ACCESS_CLIENT ) return v9fs_xattr_set ( dentry , handler -> name , value , size , flags ) ; if ( S_ISLNK ( inode -> i_mode ) ) return - EOPNOTSUPP ; if ( ! inode_owner_or_capable ( inode ) ) return - EPERM ; if ( value ) { acl = posix_acl_from_xattr ( & init_user_ns , value , size ) ; if ( IS_ERR ( acl ) ) return PTR_ERR ( acl ) ; else if ( acl ) { retval = posix_acl_valid ( inode -> i_sb -> s_user_ns , acl ) ; if ( retval ) goto err_out ; } } else acl = NULL ; switch ( handler -> flags ) { case ACL_TYPE_ACCESS : if ( acl ) { umode_t mode = inode -> i_mode ; retval = posix_acl_equiv_mode ( acl , & mode ) ; if ( retval < 0 ) goto err_out ; else { struct iattr iattr ; if ( retval == 0 ) { acl = NULL ; value = NULL ; size = 0 ; } iattr . ia_mode = ( ( mode & S_IALLUGO ) | ( inode -> i_mode & ~ S_IALLUGO ) ) ; iattr . ia_valid = ATTR_MODE ; v9fs_vfs_setattr_dotl ( dentry , & iattr ) ; } } break ; case ACL_TYPE_DEFAULT : if ( ! S_ISDIR ( inode -> i_mode ) ) { retval = acl ? - EINVAL : 0 ; goto err_out ; } break ; default : BUG ( ) ; } retval = v9fs_xattr_set ( dentry , handler -> name , value , size , flags ) ; if ( ! retval ) set_cached_acl ( inode , handler -> flags , acl ) ; err_out : posix_acl_release ( acl ) ; return retval ; } "," acl ) { struct iattr iattr ; retval = posix_acl_update_mode ( inode , & iattr . ia_mode , & acl ) ; if ( retval ) goto err_out goto err_out ; if ( ! acl ) { value = NULL ; size = 0 ; } iattr . ia_valid iattr ) ; } break ; ",torvalds@linux/073931017b49d9458aa351605b43a7e34598caef,CVE-2016-7097,https://github.com/torvalds/linux/commit/073931017b49d9458aa351605b43a7e34598caef,2016-10-16T21:59Z 1391,CWE-125,"CWE-125 static int dex_loadcode ( RBinFile * arch , RBinDexObj * bin ) { struct r_bin_t * rbin = arch -> rbin ; int i ; int * methods = NULL ; int sym_count = 0 ; if ( ! bin || bin -> methods_list ) { return false ; } bin -> code_from = UT64_MAX ; bin -> code_to = 0 ; bin -> methods_list = r_list_newf ( ( RListFree ) free ) ; if ( ! bin -> methods_list ) { return false ; } bin -> imports_list = r_list_newf ( ( RListFree ) free ) ; if ( ! bin -> imports_list ) { r_list_free ( bin -> methods_list ) ; return false ; } bin -> classes_list = r_list_newf ( ( RListFree ) __r_bin_class_free ) ; if ( ! bin -> classes_list ) { r_list_free ( bin -> methods_list ) ; r_list_free ( bin -> imports_list ) ; return false ; } if ( bin -> header . method_size > bin -> size ) { bin -> header . method_size = 0 ; return false ; } bin -> header . method_size = R_MIN ( bin -> header . method_size , bin -> size ) ; bin -> header . class_size = R_MIN ( bin -> header . class_size , bin -> size ) ; bin -> header . strings_size = R_MIN ( bin -> header . strings_size , bin -> size ) ; if ( bin -> header . strings_size > bin -> size ) { eprintf ( ""Invalidstringssize\\n"" ) ; return false ; } if ( bin -> classes ) { ut64 amount = sizeof ( int ) * bin -> header . method_size ; if ( amount > UT32_MAX || amount < bin -> header . method_size ) { return false ; } methods = calloc ( 1 , amount + 1 ) ; for ( i = 0 ; i < bin -> header . class_size ; i ++ ) { char * super_name , * class_name ; struct dex_class_t * c = & bin -> classes [ i ] ; class_name = dex_class_name ( bin , c ) ; super_name = dex_class_super_name ( bin , c ) ; if ( dexdump ) { rbin -> cb_printf ( ""Class#%d-\\n"" , i ) ; } parse_class ( arch , bin , c , i , methods , & sym_count ) ; free ( class_name ) ; free ( super_name ) ; } } if ( methods ) { int import_count = 0 ; int sym_count = bin -> methods_list -> length ; for ( i = 0 ; i < bin -> header . method_size ; i ++ ) { int len = 0 ; if ( methods [ i ] ) { continue ; } if ( bin -> methods [ i ] . class_id > bin -> header . types_size - 1 ) { continue ; } if ( is_class_idx_in_code_classes ( bin , bin -> methods [ i ] . class_id ) ) { continue ; } char * class_name = getstr ( bin , bin -> types [ bin -> methods [ i ] . class_id ] . descriptor_id ) ; if ( ! class_name ) { free ( class_name ) ; continue ; } len = strlen ( class_name ) ; if ( len < 1 ) { continue ; } class_name [ len - 1 ] = 0 ; char * method_name = dex_method_name ( bin , i ) ; char * signature = dex_method_signature ( bin , i ) ; if ( method_name && * method_name ) { RBinImport * imp = R_NEW0 ( RBinImport ) ; imp -> name = r_str_newf ( ""%s.method.%s%s"" , class_name , method_name , signature ) ; imp -> type = r_str_const ( ""FUNC"" ) ; imp -> bind = r_str_const ( ""NONE"" ) ; imp -> ordinal = import_count ++ ; r_list_append ( bin -> imports_list , imp ) ; RBinSymbol * sym = R_NEW0 ( RBinSymbol ) ; sym -> name = r_str_newf ( ""imp.%s"" , imp -> name ) ; sym -> type = r_str_const ( ""FUNC"" ) ; sym -> bind = r_str_const ( ""NONE"" ) ; sym -> paddr = sym -> vaddr = bin -> b -> base + bin -> header . method_offset + ( sizeof ( struct dex_method_t ) * i ) ; sym -> ordinal = sym_count ++ ; r_list_append ( bin -> methods_list , sym ) ; sdb_num_set ( mdb , sdb_fmt ( 0 , ""method.%d"" , i ) , sym -> paddr , 0 ) ; } free ( method_name ) ; free ( signature ) ; free ( class_name ) ; } free ( methods ) ; } return true ; } "," header . types_size ) { continue ",radare@radare2/ead645853a63bf83d8386702cad0cf23b31d7eeb,CVE-2017-6387,https://github.com/radare/radare2/commit/ead645853a63bf83d8386702cad0cf23b31d7eeb,2017-03-02T01:59Z 1392,CWE-264,"CWE-264 int rpc_type_of_NPPVariable ( int variable ) { int type ; switch ( variable ) { case NPPVpluginNameString : case NPPVpluginDescriptionString : case NPPVformValue : type = RPC_TYPE_STRING ; break ; case NPPVpluginWindowSize : case NPPVpluginTimerInterval : type = RPC_TYPE_INT32 ; break ; case NPPVpluginNeedsXEmbed : case NPPVpluginWindowBool : case NPPVpluginTransparentBool : case NPPVjavascriptPushCallerBool : case NPPVpluginKeepLibraryInMemory : type = RPC_TYPE_BOOLEAN ; break ; case NPPVpluginScriptableNPObject : type = RPC_TYPE_NP_OBJECT ; break ; default : type = RPC_ERROR_GENERIC ; break ; } return type ; } "," : case NPPVformValue : case NPPVpluginNativeAccessibleAtkPlugId case NPPVpluginKeepLibraryInMemory : case NPPVpluginUrlRequestsDisplayedBool : case NPPVpluginWantsAllNetworkStreams : case NPPVpluginCancelSrcStream : case NPPVSupportsAdvancedKeyHandling : ",davidben@nspluginwrapper/7e4ab8e1189846041f955e6c83f72bc1624e7a98,CVE-2011-2486,https://github.com/davidben/nspluginwrapper/commit/7e4ab8e1189846041f955e6c83f72bc1624e7a98,2012-11-19T12:10Z 1393,CWE-89,"CWE-89 char * curl_easy_unescape ( CURL * handle , const char * string , int length , int * olen ) { int alloc = ( length ? length : ( int ) strlen ( string ) ) + 1 ; char * ns = malloc ( alloc ) ; unsigned char in ; int strindex = 0 ; unsigned long hex ; CURLcode res ; if ( ! ns ) return NULL ; while ( -- alloc > 0 ) { in = * string ; if ( ( '%' == in ) && ISXDIGIT ( string [ 1 ] ) && ISXDIGIT ( string [ 2 ] ) ) { char hexstr [ 3 ] ; char * ptr ; hexstr [ 0 ] = string [ 1 ] ; hexstr [ 1 ] = string [ 2 ] ; hexstr [ 2 ] = 0 ; hex = strtoul ( hexstr , & ptr , 16 ) ; in = curlx_ultouc ( hex ) ; res = Curl_convert_from_network ( handle , & in , 1 ) ; if ( res ) { free ( ns ) ; return NULL ; } string += 2 ; alloc -= 2 ; } ns [ strindex ++ ] = in ; string ++ ; } ns [ strindex ] = 0 ; if ( olen ) * olen = strindex ; return ns ; } "," olen ) { char * str = NULL ; size_t inputlen = length ; size_t outputlen ; CURLcode res ; CURLcode res = Curl_urldecode ( handle , ( handle , string , inputlen , & str , & outputlen , FALSE ) ; if ( res ) return NULL ; if ( * olen = curlx_uztosi ( outputlen ) ; return str ; } ",bagder@curl/75ca568fa1c19de4c5358fed246686de8467c238,CVE-2012-0036,https://github.com/bagder/curl/commit/75ca568fa1c19de4c5358fed246686de8467c238,2012-04-13T20:55Z 1394,CWE-125,"CWE-125 void nego_process_negotiation_response ( rdpNego * nego , wStream * s ) { UINT16 length ; WLog_DBG ( TAG , ""RDP_NEG_RSP"" ) ; if ( Stream_GetRemainingLength ( s ) < 7 ) { WLog_ERR ( TAG , ""InvalidRDP_NEG_RSP"" ) ; nego -> state = NEGO_STATE_FAIL ; return ; } Stream_Read_UINT8 ( s , nego -> flags ) ; Stream_Read_UINT16 ( s , length ) ; Stream_Read_UINT32 ( s , nego -> SelectedProtocol ) ; nego -> state = NEGO_STATE_FINAL ; } "," BOOL nego_process_negotiation_response ( rdpNego NEGO_STATE_FAIL ; return FALSE = NEGO_STATE_FINAL ; return TRUE ; ",FreeRDP@FreeRDP/6b485b146a1b9d6ce72dfd7b5f36456c166e7a16,CVE-2020-11089,https://github.com/FreeRDP/FreeRDP/commit/6b485b146a1b9d6ce72dfd7b5f36456c166e7a16,2020-05-29T20:15Z 1395,CWE-119,"CWE-119 int vp9_rc_regulate_q ( const VP9_COMP * cpi , int target_bits_per_frame , int active_best_quality , int active_worst_quality ) { const VP9_COMMON * const cm = & cpi -> common ; int q = active_worst_quality ; int last_error = INT_MAX ; int i , target_bits_per_mb ; const double correction_factor = get_rate_correction_factor ( cpi ) ; target_bits_per_mb = ( ( uint64_t ) target_bits_per_frame << BPER_MB_NORMBITS ) / cm -> MBs ; i = active_best_quality ; do { const int bits_per_mb_at_this_q = ( int ) vp9_rc_bits_per_mb ( cm -> frame_type , i , correction_factor ) ; if ( bits_per_mb_at_this_q <= target_bits_per_mb ) { if ( ( target_bits_per_mb - bits_per_mb_at_this_q ) <= last_error ) q = i ; else q = i - 1 ; break ; } else { last_error = bits_per_mb_at_this_q - target_bits_per_mb ; } } while ( ++ i <= active_worst_quality ) ; return q ; } "," i , target_bits_per_mb , bits_per_mb_at_this_q ; do { if ( cpi -> oxcf . aq_mode == CYCLIC_REFRESH_AQ && cm -> seg . enabled && cpi -> svc . temporal_layer_id == 0 && cpi -> svc . spatial_layer_id == 0 ) { bits_per_mb_at_this_q = ( int ) vp9_cyclic_refresh_rc_bits_per_mb ( cpi , i , correction_factor ) ; } else { bits_per_mb_at_this_q = ( i , correction_factor , cm -> bit_depth ) ; } if ( bits_per_mb_at_this_q active_worst_quality ) ; if ( cpi -> oxcf . rc_mode == VPX_CBR && ( cpi -> rc . rc_1_frame * cpi -> rc . rc_2_frame == - 1 ) && cpi -> rc . q_1_frame != cpi -> rc . q_2_frame ) { q = clamp ( q , MIN ( cpi -> rc . q_1_frame , cpi -> rc . q_2_frame ) , MAX ( cpi -> rc . q_1_frame , cpi -> rc . q_2_frame ) ) ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1396,CWE-20,"CWE-20 error_t tja1101Init ( NetInterface * interface ) { uint16_t value ; TRACE_INFO ( ""InitializingTJA1101...\\r\\n"" ) ; if ( interface -> phyAddr >= 32 ) { interface -> phyAddr = TJA1101_PHY_ADDR ; } if ( interface -> smiDriver != NULL ) { interface -> smiDriver -> init ( ) ; } if ( interface -> extIntDriver != NULL ) { interface -> extIntDriver -> init ( ) ; } tja1101WritePhyReg ( interface , TJA1101_BASIC_CTRL , TJA1101_BASIC_CTRL_RESET ) ; while ( tja1101ReadPhyReg ( interface , TJA1101_BASIC_CTRL ) & TJA1101_BASIC_CTRL_RESET ) { } tja1101DumpPhyReg ( interface ) ; value = tja1101ReadPhyReg ( interface , TJA1101_EXTENDED_CTRL ) ; value |= TJA1101_EXTENDED_CTRL_CONFIG_EN ; tja1101WritePhyReg ( interface , TJA1101_EXTENDED_CTRL , value ) ; value = tja1101ReadPhyReg ( interface , TJA1101_CONFIG1 ) ; value &= ~ TJA1101_CONFIG1_MII_MODE ; value |= TJA1101_CONFIG1_MII_MODE_RMII_25MHZ ; tja1101WritePhyReg ( interface , TJA1101_CONFIG1 , value ) ; value = tja1101ReadPhyReg ( interface , TJA1101_COMM_CTRL ) ; value |= TJA1101_COMM_CTRL_AUTO_OP ; tja1101WritePhyReg ( interface , TJA1101_COMM_CTRL , value ) ; interface -> phyEvent = TRUE ; osSetEvent ( & netEvent ) ; return NO_ERROR ; } "," ; value |= TJA1101_CONFIG1_MII_MODE_RMII_50MHZ_REF_CLK_OUT ; tja1101WritePhyReg ( ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 1397,CWE-200,"CWE-200 static int crypto_report_cipher ( struct sk_buff * skb , struct crypto_alg * alg ) { struct crypto_report_cipher rcipher ; strlcpy ( rcipher . type , ""cipher"" , sizeof ( rcipher . type ) ) ; rcipher . blocksize = alg -> cra_blocksize ; rcipher . min_keysize = alg -> cra_cipher . cia_min_keysize ; rcipher . max_keysize = alg -> cra_cipher . cia_max_keysize ; if ( nla_put ( skb , CRYPTOCFGA_REPORT_CIPHER , sizeof ( struct crypto_report_cipher ) , & rcipher ) ) goto nla_put_failure ; return 0 ; nla_put_failure : return - EMSGSIZE ; } "," crypto_report_cipher rcipher ; strncpy ( rcipher . ",torvalds@linux/f43f39958beb206b53292801e216d9b8a660f087,CVE-2018-19854,https://github.com/torvalds/linux/commit/f43f39958beb206b53292801e216d9b8a660f087,2018-12-04T16:29Z 1398,CWE-125,"CWE-125 static int wb_prep ( netdissect_options * ndo , const struct pkt_prep * prep , u_int len ) { int n ; const struct pgstate * ps ; const u_char * ep = ndo -> ndo_snapend ; ND_PRINT ( ( ndo , ""wb-prep:"" ) ) ; if ( len < sizeof ( * prep ) ) { return ( - 1 ) ; } n = EXTRACT_32BITS ( & prep -> pp_n ) ; ps = ( const struct pgstate * ) ( prep + 1 ) ; while ( -- n >= 0 && ND_TTEST ( * ps ) ) { const struct id_off * io , * ie ; char c = '<' ; ND_PRINT ( ( ndo , ""%u/%s:%u"" , EXTRACT_32BITS ( & ps -> slot ) , ipaddr_string ( ndo , & ps -> page . p_sid ) , EXTRACT_32BITS ( & ps -> page . p_uid ) ) ) ; io = ( const struct id_off * ) ( ps + 1 ) ; for ( ie = io + ps -> nid ; io < ie && ND_TTEST ( * io ) ; ++ io ) { ND_PRINT ( ( ndo , ""%c%s:%u"" , c , ipaddr_string ( ndo , & io -> id ) , EXTRACT_32BITS ( & io -> off ) ) ) ; c = ',' ; } ND_PRINT ( ( ndo , "">"" ) ) ; ps = ( const struct pgstate * ) io ; } return ( ( const u_char * ) ps <= ep ? 0 : - 1 ) ; } "," * prep ) || ! ND_TTEST ( * prep ) ) return ( - 1 ) ; n = EXTRACT_32BITS ",the-tcpdump-group@tcpdump/cc356512f512e7fa423b3674db4bb31dbe40ffec,CVE-2017-13014,https://github.com/the-tcpdump-group/tcpdump/commit/cc356512f512e7fa423b3674db4bb31dbe40ffec,2017-09-14T06:29Z 1399,CWE-119,"CWE-119 static void mark_commit ( struct commit * c , void * data ) { mark_object ( & c -> object , NULL , NULL , data ) ; } "," , NULL , data ) ; ",git@git/de1e67d0703894cb6ea782e36abb63976ab07e60,CVE-2016-2315,https://github.com/git/git/commit/de1e67d0703894cb6ea782e36abb63976ab07e60,2016-04-08T14:59Z 1400,CWE-476,"CWE-476 static int hi3660_stub_clk_probe ( struct platform_device * pdev ) { struct device * dev = & pdev -> dev ; struct resource * res ; unsigned int i ; int ret ; stub_clk_chan . cl . dev = dev ; stub_clk_chan . cl . tx_done = NULL ; stub_clk_chan . cl . tx_block = false ; stub_clk_chan . cl . knows_txdone = false ; stub_clk_chan . mbox = mbox_request_channel ( & stub_clk_chan . cl , 0 ) ; if ( IS_ERR ( stub_clk_chan . mbox ) ) return PTR_ERR ( stub_clk_chan . mbox ) ; res = platform_get_resource ( pdev , IORESOURCE_MEM , 0 ) ; freq_reg = devm_ioremap ( dev , res -> start , resource_size ( res ) ) ; if ( ! freq_reg ) return - ENOMEM ; freq_reg += HI3660_STUB_CLOCK_DATA ; for ( i = 0 ; i < HI3660_CLK_STUB_NUM ; i ++ ) { ret = devm_clk_hw_register ( & pdev -> dev , & hi3660_stub_clks [ i ] . hw ) ; if ( ret ) return ret ; } return devm_of_clk_add_hw_provider ( & pdev -> dev , hi3660_stub_clk_hw_get , hi3660_stub_clks ) ; } "," 0 ) ; if ( ! res ) return - EINVAL ; ",torvalds@linux/9903e41ae1f5d50c93f268ca3304d4d7c64b9311,CVE-2018-10074,https://github.com/torvalds/linux/commit/9903e41ae1f5d50c93f268ca3304d4d7c64b9311,2018-04-12T18:29Z 1401,CWE-125,"CWE-125 static arguments_ty ast_for_arguments ( struct compiling * c , const node * n ) { int i , j , k , nposargs = 0 , nkwonlyargs = 0 ; int nposdefaults = 0 , found_default = 0 ; asdl_seq * posargs , * posdefaults , * kwonlyargs , * kwdefaults ; arg_ty vararg = NULL , kwarg = NULL ; arg_ty arg = NULL ; node * ch ; if ( TYPE ( n ) == parameters ) { if ( NCH ( n ) == 2 ) return arguments ( NULL , NULL , NULL , NULL , NULL , NULL , c -> c_arena ) ; n = CHILD ( n , 1 ) ; } assert ( TYPE ( n ) == typedargslist || TYPE ( n ) == varargslist ) ; for ( i = 0 ; i < NCH ( n ) ; i ++ ) { ch = CHILD ( n , i ) ; if ( TYPE ( ch ) == STAR ) { i ++ ; if ( i < NCH ( n ) && ( TYPE ( CHILD ( n , i ) ) == tfpdef || TYPE ( CHILD ( n , i ) ) == vfpdef ) ) { i ++ ; } break ; } if ( TYPE ( ch ) == DOUBLESTAR ) break ; if ( TYPE ( ch ) == vfpdef || TYPE ( ch ) == tfpdef ) nposargs ++ ; if ( TYPE ( ch ) == EQUAL ) nposdefaults ++ ; } for ( ; i < NCH ( n ) ; ++ i ) { ch = CHILD ( n , i ) ; if ( TYPE ( ch ) == DOUBLESTAR ) break ; if ( TYPE ( ch ) == tfpdef || TYPE ( ch ) == vfpdef ) nkwonlyargs ++ ; } posargs = ( nposargs ? _Py_asdl_seq_new ( nposargs , c -> c_arena ) : NULL ) ; if ( ! posargs && nposargs ) return NULL ; kwonlyargs = ( nkwonlyargs ? _Py_asdl_seq_new ( nkwonlyargs , c -> c_arena ) : NULL ) ; if ( ! kwonlyargs && nkwonlyargs ) return NULL ; posdefaults = ( nposdefaults ? _Py_asdl_seq_new ( nposdefaults , c -> c_arena ) : NULL ) ; if ( ! posdefaults && nposdefaults ) return NULL ; kwdefaults = ( nkwonlyargs ? _Py_asdl_seq_new ( nkwonlyargs , c -> c_arena ) : NULL ) ; if ( ! kwdefaults && nkwonlyargs ) return NULL ; i = 0 ; j = 0 ; k = 0 ; while ( i < NCH ( n ) ) { ch = CHILD ( n , i ) ; switch ( TYPE ( ch ) ) { case tfpdef : case vfpdef : if ( i + 1 < NCH ( n ) && TYPE ( CHILD ( n , i + 1 ) ) == EQUAL ) { expr_ty expression = ast_for_expr ( c , CHILD ( n , i + 2 ) ) ; if ( ! expression ) return NULL ; assert ( posdefaults != NULL ) ; asdl_seq_SET ( posdefaults , j ++ , expression ) ; i += 2 ; found_default = 1 ; } else if ( found_default ) { ast_error ( c , n , ""non-defaultargumentfollowsdefaultargument"" ) ; return NULL ; } arg = ast_for_arg ( c , ch ) ; if ( ! arg ) return NULL ; asdl_seq_SET ( posargs , k ++ , arg ) ; i += 1 ; if ( i < NCH ( n ) && TYPE ( CHILD ( n , i ) ) == COMMA ) i += 1 ; break ; case STAR : if ( i + 1 >= NCH ( n ) || ( i + 2 == NCH ( n ) && ( TYPE ( CHILD ( n , i + 1 ) ) == COMMA || TYPE ( CHILD ( n , i + 1 ) ) == TYPE_COMMENT ) ) ) { ast_error ( c , CHILD ( n , i ) , ""namedargumentsmustfollowbare*"" ) ; return NULL ; } ch = CHILD ( n , i + 1 ) ; if ( TYPE ( ch ) == COMMA ) { int res = 0 ; i += 2 ; if ( i < NCH ( n ) && TYPE ( CHILD ( n , i ) ) == TYPE_COMMENT ) { ast_error ( c , CHILD ( n , i ) , ""bare*hasassociatedtypecomment"" ) ; return NULL ; } res = handle_keywordonly_args ( c , n , i , kwonlyargs , kwdefaults ) ; if ( res == - 1 ) return NULL ; i = res ; } else { vararg = ast_for_arg ( c , ch ) ; if ( ! vararg ) return NULL ; i += 2 ; if ( i < NCH ( n ) && TYPE ( CHILD ( n , i ) ) == COMMA ) i += 1 ; if ( i < NCH ( n ) && TYPE ( CHILD ( n , i ) ) == TYPE_COMMENT ) { vararg -> type_comment = NEW_TYPE_COMMENT ( CHILD ( n , i ) ) ; if ( ! vararg -> type_comment ) return NULL ; i += 1 ; } if ( i < NCH ( n ) && ( TYPE ( CHILD ( n , i ) ) == tfpdef || TYPE ( CHILD ( n , i ) ) == vfpdef ) ) { int res = 0 ; res = handle_keywordonly_args ( c , n , i , kwonlyargs , kwdefaults ) ; if ( res == - 1 ) return NULL ; i = res ; } } break ; case DOUBLESTAR : ch = CHILD ( n , i + 1 ) ; assert ( TYPE ( ch ) == tfpdef || TYPE ( ch ) == vfpdef ) ; kwarg = ast_for_arg ( c , ch ) ; if ( ! kwarg ) return NULL ; i += 2 ; if ( TYPE ( CHILD ( n , i ) ) == COMMA ) i += 1 ; break ; case TYPE_COMMENT : assert ( i ) ; if ( kwarg ) arg = kwarg ; arg -> type_comment = NEW_TYPE_COMMENT ( ch ) ; if ( ! arg -> type_comment ) return NULL ; i += 1 ; break ; default : PyErr_Format ( PyExc_SystemError , ""unexpectednodeinvarargslist:%d@%d"" , TYPE ( ch ) , i ) ; return NULL ; } } return arguments ( posargs , vararg , kwonlyargs , kwdefaults , kwarg , posdefaults , c -> c_arena ) ; } "," ; if ( i < NCH ( n ) && ",python@typed_ast/a4d78362397fc3bced6ea80fbc7b5f4827aec55e,CVE-2019-19275,https://github.com/python/typed_ast/commit/a4d78362397fc3bced6ea80fbc7b5f4827aec55e,2019-11-26T15:15Z 1402,CWE-119,"CWE-119 static void build_intra_predictors ( const MACROBLOCKD * xd , const uint8_t * ref , int ref_stride , uint8_t * dst , int dst_stride , MB_PREDICTION_MODE mode , TX_SIZE tx_size , int up_available , int left_available , int right_available , int x , int y , int plane ) { int i ; DECLARE_ALIGNED_ARRAY ( 16 , uint8_t , left_col , 64 ) ; DECLARE_ALIGNED_ARRAY ( 16 , uint8_t , above_data , 128 + 16 ) ; uint8_t * above_row = above_data + 16 ; const uint8_t * const_above_row = above_row ; const int bs = 4 << tx_size ; int frame_width , frame_height ; int x0 , y0 ; const struct macroblockd_plane * const pd = & xd -> plane [ plane ] ; once ( init_intra_pred_fn_ptrs ) ; if ( plane == 0 ) { frame_width = xd -> cur_buf -> y_width ; frame_height = xd -> cur_buf -> y_height ; } else { frame_width = xd -> cur_buf -> uv_width ; frame_height = xd -> cur_buf -> uv_height ; } x0 = ( - xd -> mb_to_left_edge >> ( 3 + pd -> subsampling_x ) ) + x ; y0 = ( - xd -> mb_to_top_edge >> ( 3 + pd -> subsampling_y ) ) + y ; vpx_memset ( left_col , 129 , 64 ) ; if ( left_available ) { if ( xd -> mb_to_bottom_edge < 0 ) { if ( y0 + bs <= frame_height ) { for ( i = 0 ; i < bs ; ++ i ) left_col [ i ] = ref [ i * ref_stride - 1 ] ; } else { const int extend_bottom = frame_height - y0 ; for ( i = 0 ; i < extend_bottom ; ++ i ) left_col [ i ] = ref [ i * ref_stride - 1 ] ; for ( ; i < bs ; ++ i ) left_col [ i ] = ref [ ( extend_bottom - 1 ) * ref_stride - 1 ] ; } } else { for ( i = 0 ; i < bs ; ++ i ) left_col [ i ] = ref [ i * ref_stride - 1 ] ; } } if ( up_available ) { const uint8_t * above_ref = ref - ref_stride ; if ( xd -> mb_to_right_edge < 0 ) { if ( x0 + 2 * bs <= frame_width ) { if ( right_available && bs == 4 ) { vpx_memcpy ( above_row , above_ref , 2 * bs ) ; } else { vpx_memcpy ( above_row , above_ref , bs ) ; vpx_memset ( above_row + bs , above_row [ bs - 1 ] , bs ) ; } } else if ( x0 + bs <= frame_width ) { const int r = frame_width - x0 ; if ( right_available && bs == 4 ) { vpx_memcpy ( above_row , above_ref , r ) ; vpx_memset ( above_row + r , above_row [ r - 1 ] , x0 + 2 * bs - frame_width ) ; } else { vpx_memcpy ( above_row , above_ref , bs ) ; vpx_memset ( above_row + bs , above_row [ bs - 1 ] , bs ) ; } } else if ( x0 <= frame_width ) { const int r = frame_width - x0 ; if ( right_available && bs == 4 ) { vpx_memcpy ( above_row , above_ref , r ) ; vpx_memset ( above_row + r , above_row [ r - 1 ] , x0 + 2 * bs - frame_width ) ; } else { vpx_memcpy ( above_row , above_ref , r ) ; vpx_memset ( above_row + r , above_row [ r - 1 ] , x0 + 2 * bs - frame_width ) ; } } above_row [ - 1 ] = left_available ? above_ref [ - 1 ] : 129 ; } else { if ( bs == 4 && right_available && left_available ) { const_above_row = above_ref ; } else { vpx_memcpy ( above_row , above_ref , bs ) ; if ( bs == 4 && right_available ) vpx_memcpy ( above_row + bs , above_ref + bs , bs ) ; else vpx_memset ( above_row + bs , above_row [ bs - 1 ] , bs ) ; above_row [ - 1 ] = left_available ? above_ref [ - 1 ] : 129 ; } } } else { vpx_memset ( above_row , 127 , bs * 2 ) ; above_row [ - 1 ] = 127 ; } if ( mode == DC_PRED ) { dc_pred [ left_available ] [ up_available ] [ tx_size ] ( dst , dst_stride , const_above_row , left_col ) ; } else { pred [ mode ] [ tx_size ] ( dst , dst_stride , const_above_row , left_col ) ; } } "," int dst_stride , PREDICTION_MODE mode , TX_SIZE int i ; DECLARE_ALIGNED ( 16 , uint8_t , left_col [ 32 ] ) ; DECLARE_ALIGNED ( 16 , uint8_t , above_data [ 64 + 16 ] ) ; uint8_t plane ] ; if ( plane + y ; if ( extend_modes [ mode ] & NEED_LEFT ) { if ( left_available ; } } else { memset ( left_col , 129 , bs ) ; } } if ( extend_modes [ mode ] & NEED_ABOVE ) { ( x0 + bs <= frame_width frame_width ) { memcpy ( above_row , above_ref , bs ) ; } else if ( x0 <= frame_width ) - x0 ; memcpy ( above_row , above_ref , r ) ; memset ( above_row + r , above_row [ r - 1 ] , x0 + bs - frame_width ) ; } } else { } else { memcpy ( above_row , above_ref , bs ) ; } } above_row [ - 1 ] = left_available ? above_ref [ - 1 ] : 129 ; } else { memset ( above_row , 127 , bs ) ; above_row [ - 1 ] = 127 ; } } if ( extend_modes [ mode ] & NEED_ABOVERIGHT ) { if ( up_available ) { const uint8_t * above_ref = ref - ref_stride ; if ( xd -> mb_to_right_edge < 0 ) { if ( x0 + 2 * bs <= frame_width ) { if ( right_available && bs == 4 ) { memcpy ( above_row , above_ref , 2 * bs ) ; } else { memcpy ( above_row , above_ref , bs ) ; memset ( above_row + bs , above_row [ bs - 1 ] , bs ) ; } } else if ( x0 + bs <= frame_width ) { const int r = frame_width - x0 ; if ( right_available && bs == 4 ) { memcpy ( above_row , above_ref , r ) ; memset ( above_row + r , above_row [ r - 1 ] , x0 + 2 * bs - frame_width ) ; } else { memcpy ( above_row , above_ref , bs ) ; memset ( above_row + bs , above_row [ bs - 1 ] , bs ) ; } } else if ( x0 <= frame_width ) { const int r = frame_width - x0 ; memcpy ( above_row , above_ref , r ) ; memset ( above_row + r , above_row [ r - 1 ] , x0 + 2 * bs - frame_width ) ; } } else { if ( bs 4 && right_available && left_available ) { const_above_row = above_ref ; } else { memcpy ( above_row , above_ref , bs ) ; if ( bs == 4 && right_available ) memcpy ( above_row + bs , above_ref + bs , bs ) ; else memset ( above_row + bs , above_row [ bs - 1 ] , bs ) ; } } above_row [ - 129 ; } else { memset ( above_row , = 127 ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1403,CWE-000,"CWE-000 static xsltCompMatchPtr xsltCompilePatternInternal ( const xmlChar * pattern , xmlDocPtr doc , xmlNodePtr node , xsltStylesheetPtr style , xsltTransformContextPtr runtime , int novar ) { xsltParserContextPtr ctxt = NULL ; xsltCompMatchPtr element , first = NULL , previous = NULL ; int current , start , end , level , j ; if ( pattern == NULL ) { xsltTransformError ( NULL , NULL , node , ""xsltCompilePattern:NULLpattern\\n"" ) ; return ( NULL ) ; } ctxt = xsltNewParserContext ( style , runtime ) ; if ( ctxt == NULL ) return ( NULL ) ; ctxt -> doc = doc ; ctxt -> elem = node ; current = end = 0 ; while ( pattern [ current ] != 0 ) { start = current ; while ( IS_BLANK_CH ( pattern [ current ] ) ) current ++ ; end = current ; level = 0 ; while ( ( pattern [ end ] != 0 ) && ( ( pattern [ end ] != '|' ) || ( level != 0 ) ) ) { if ( pattern [ end ] == '[' ) level ++ ; else if ( pattern [ end ] == ']' ) level -- ; else if ( pattern [ end ] == '\\'' ) { end ++ ; while ( ( pattern [ end ] != 0 ) && ( pattern [ end ] != '\\'' ) ) end ++ ; } else if ( pattern [ end ] == \'""\' ) { end ++ ; while ( ( pattern [ end ] != 0 ) && ( pattern [ end ] != \'""\' ) ) end ++ ; } end ++ ; } if ( current == end ) { xsltTransformError ( NULL , NULL , node , ""xsltCompilePattern:NULLpattern\\n"" ) ; goto error ; } element = xsltNewCompMatch ( ) ; if ( element == NULL ) { goto error ; } if ( first == NULL ) first = element ; else if ( previous != NULL ) previous -> next = element ; previous = element ; ctxt -> comp = element ; ctxt -> base = xmlStrndup ( & pattern [ start ] , end - start ) ; if ( ctxt -> base == NULL ) goto error ; ctxt -> cur = & ( ctxt -> base ) [ current - start ] ; element -> pattern = ctxt -> base ; element -> nsList = xmlGetNsList ( doc , node ) ; j = 0 ; if ( element -> nsList != NULL ) { while ( element -> nsList [ j ] != NULL ) j ++ ; } element -> nsNr = j ; # ifdef WITH_XSLT_DEBUG_PATTERN xsltGenericDebug ( xsltGenericDebugContext , ""xsltCompilePattern:parsing\'%s\'\\n"" , element -> pattern ) ; # endif element -> priority = 0 ; xsltCompileLocationPathPattern ( ctxt , novar ) ; if ( ctxt -> error ) { xsltTransformError ( NULL , style , node , ""xsltCompilePattern:failedtocompile\'%s\'\\n"" , element -> pattern ) ; if ( style != NULL ) style -> errors ++ ; goto error ; } xsltReverseCompMatch ( ctxt , element ) ; if ( element -> priority == 0 ) { if ( ( ( element -> steps [ 0 ] . op == XSLT_OP_ELEM ) || ( element -> steps [ 0 ] . op == XSLT_OP_ATTR ) || ( element -> steps [ 0 ] . op == XSLT_OP_PI ) ) && ( element -> steps [ 0 ] . value != NULL ) && ( element -> steps [ 1 ] . op == XSLT_OP_END ) ) { ; } else if ( ( element -> steps [ 0 ] . op == XSLT_OP_ATTR ) && ( element -> steps [ 0 ] . value2 != NULL ) && ( element -> steps [ 1 ] . op == XSLT_OP_END ) ) { element -> priority = - 0.25 ; } else if ( ( element -> steps [ 0 ] . op == XSLT_OP_NS ) && ( element -> steps [ 0 ] . value != NULL ) && ( element -> steps [ 1 ] . op == XSLT_OP_END ) ) { element -> priority = - 0.25 ; } else if ( ( element -> steps [ 0 ] . op == XSLT_OP_ATTR ) && ( element -> steps [ 0 ] . value == NULL ) && ( element -> steps [ 0 ] . value2 == NULL ) && ( element -> steps [ 1 ] . op == XSLT_OP_END ) ) { element -> priority = - 0.5 ; } else if ( ( ( element -> steps [ 0 ] . op == XSLT_OP_PI ) || ( element -> steps [ 0 ] . op == XSLT_OP_TEXT ) || ( element -> steps [ 0 ] . op == XSLT_OP_ALL ) || ( element -> steps [ 0 ] . op == XSLT_OP_NODE ) || ( element -> steps [ 0 ] . op == XSLT_OP_COMMENT ) ) && ( element -> steps [ 1 ] . op == XSLT_OP_END ) ) { element -> priority = - 0.5 ; } else { element -> priority = 0.5 ; } } # ifdef WITH_XSLT_DEBUG_PATTERN xsltGenericDebug ( xsltGenericDebugContext , ""xsltCompilePattern:parsed%s,defaultpriority%f\\n"" , element -> pattern , element -> priority ) ; # endif if ( pattern [ end ] == '|' ) end ++ ; current = end ; } if ( end == 0 ) { xsltTransformError ( NULL , style , node , ""xsltCompilePattern:NULLpattern\\n"" ) ; if ( style != NULL ) style -> errors ++ ; goto error ; } xsltFreeParserContext ( ctxt ) ; return ( first ) ; error : if ( ctxt != NULL ) xsltFreeParserContext ( ctxt ) ; if ( first != NULL ) xsltFreeCompMatchList ( first ) ; return ( NULL ) ; } "," ++ ; } if ( pattern [ end ] == 0 ) break ; ",chromium@chromium/094c773bb6c144f07b004ff3d1886100f157f4f6,,https://github.com/chromium/chromium/commit/094c773bb6c144f07b004ff3d1886100f157f4f6, 1404,CWE-119,"CWE-119 void ftoa_bounded_extra ( JsVarFloat val , char * str , size_t len , int radix , int fractionalDigits ) { const JsVarFloat stopAtError = 0.0000001 ; if ( isnan ( val ) ) strncpy ( str , ""NaN"" , len ) ; else if ( ! isfinite ( val ) ) { if ( val < 0 ) strncpy ( str , ""-Infinity"" , len ) ; else strncpy ( str , ""Infinity"" , len ) ; } else { if ( val < 0 ) { if ( -- len <= 0 ) { * str = 0 ; return ; } * ( str ++ ) = '-' ; val = - val ; } if ( ( ( JsVarInt ) ( val + stopAtError ) ) == ( 1 + ( JsVarInt ) val ) ) val = ( JsVarFloat ) ( 1 + ( JsVarInt ) val ) ; JsVarFloat d = 1 ; while ( d * radix <= val ) d *= radix ; while ( d >= 1 ) { int v = ( int ) ( val / d ) ; val -= v * d ; if ( -- len <= 0 ) { * str = 0 ; return ; } * ( str ++ ) = itoch ( v ) ; d /= radix ; } # ifndef USE_NO_FLOATS if ( ( ( fractionalDigits < 0 ) && val > 0 ) || fractionalDigits > 0 ) { bool hasPt = false ; val *= radix ; while ( ( ( fractionalDigits < 0 ) && ( fractionalDigits > - 12 ) && ( val > stopAtError ) ) || ( fractionalDigits > 0 ) ) { int v = ( int ) ( val + ( ( fractionalDigits == 1 ) ? 0.4 : 0.00000001 ) ) ; val = ( val - v ) * radix ; if ( v == radix ) v = radix - 1 ; if ( ! hasPt ) { hasPt = true ; if ( -- len <= 0 ) { * str = 0 ; return ; } * ( str ++ ) = '.' ; } if ( -- len <= 0 ) { * str = 0 ; return ; } * ( str ++ ) = itoch ( v ) ; fractionalDigits -- ; } } # endif * ( str ++ ) = 0 ; } } "," fractionalDigits ) { assert ( len > 9 ) ; val ) ) strcpy ( str , str , ""NaN"" ) ; else < 0 ) strcpy ( str , str , ""-Infinity"" ) ; else ) ; else strcpy ( str , str , ""Infinity"" ) ; } ",espruino@Espruino/0a7619875bf79877907205f6bee08465b89ff10b,CVE-2018-11595,https://github.com/espruino/Espruino/commit/0a7619875bf79877907205f6bee08465b89ff10b,2018-05-31T16:29Z 1405,CWE-190,"CWE-190 jas_iccprof_t * jas_iccprof_createfrombuf ( uchar * buf , int len ) { jas_stream_t * in ; jas_iccprof_t * prof ; if ( ! ( in = jas_stream_memopen ( JAS_CAST ( char * , buf ) , len ) ) ) goto error ; if ( ! ( prof = jas_iccprof_load ( in ) ) ) goto error ; jas_stream_close ( in ) ; return prof ; error : if ( in ) jas_stream_close ( in ) ; return 0 ; } "," * jas_iccprof_createfrombuf ( jas_uchar * buf , ",mdadams@jasper/d42b2388f7f8e0332c846675133acea151fc557a,CVE-2016-9557,https://github.com/mdadams/jasper/commit/d42b2388f7f8e0332c846675133acea151fc557a,2017-03-23T18:59Z 1406,CWE-000,"CWE-000 static struct inode * ext4_alloc_inode ( struct super_block * sb ) { struct ext4_inode_info * ei ; ei = kmem_cache_alloc ( ext4_inode_cachep , GFP_NOFS ) ; if ( ! ei ) return NULL ; ei -> vfs_inode . i_version = 1 ; ei -> vfs_inode . i_data . writeback_index = 0 ; memset ( & ei -> i_cached_extent , 0 , sizeof ( struct ext4_ext_cache ) ) ; INIT_LIST_HEAD ( & ei -> i_prealloc_list ) ; spin_lock_init ( & ei -> i_prealloc_lock ) ; jbd2_journal_init_jbd_inode ( & ei -> jinode , & ei -> vfs_inode ) ; ei -> i_reserved_data_blocks = 0 ; ei -> i_reserved_meta_blocks = 0 ; ei -> i_allocated_meta_blocks = 0 ; ei -> i_da_metadata_calc_len = 0 ; ei -> i_delalloc_reserved_flag = 0 ; spin_lock_init ( & ( ei -> i_block_reservation_lock ) ) ; # ifdef CONFIG_QUOTA ei -> i_reserved_quota = 0 ; # endif INIT_LIST_HEAD ( & ei -> i_completed_io_list ) ; ei -> cur_aio_dio = NULL ; ei -> i_sync_tid = 0 ; ei -> i_datasync_tid = 0 ; return & ei -> vfs_inode ; } "," i_completed_io_list ) ; spin_lock_init ( & ei -> i_completed_io_lock ) ; ",torvalds@linux/744692dc059845b2a3022119871846e74d4f6e11,CVE-2015-8324,https://github.com/torvalds/linux/commit/744692dc059845b2a3022119871846e74d4f6e11,2016-05-02T10:59Z 1407,CWE-476,"CWE-476 static void mem_cgroup_usage_unregister_event ( struct cgroup * cgrp , struct cftype * cft , struct eventfd_ctx * eventfd ) { struct mem_cgroup * memcg = mem_cgroup_from_cont ( cgrp ) ; struct mem_cgroup_thresholds * thresholds ; struct mem_cgroup_threshold_ary * new ; int type = MEMFILE_TYPE ( cft -> private ) ; u64 usage ; int i , j , size ; mutex_lock ( & memcg -> thresholds_lock ) ; if ( type == _MEM ) thresholds = & memcg -> thresholds ; else if ( type == _MEMSWAP ) thresholds = & memcg -> memsw_thresholds ; else BUG ( ) ; BUG_ON ( ! thresholds ) ; usage = mem_cgroup_usage ( memcg , type == _MEMSWAP ) ; __mem_cgroup_threshold ( memcg , type == _MEMSWAP ) ; size = 0 ; for ( i = 0 ; i < thresholds -> primary -> size ; i ++ ) { if ( thresholds -> primary -> entries [ i ] . eventfd != eventfd ) size ++ ; } new = thresholds -> spare ; if ( ! size ) { kfree ( new ) ; new = NULL ; goto swap_buffers ; } new -> size = size ; new -> current_threshold = - 1 ; for ( i = 0 , j = 0 ; i < thresholds -> primary -> size ; i ++ ) { if ( thresholds -> primary -> entries [ i ] . eventfd == eventfd ) continue ; new -> entries [ j ] = thresholds -> primary -> entries [ i ] ; if ( new -> entries [ j ] . threshold < usage ) { ++ new -> current_threshold ; } j ++ ; } swap_buffers : thresholds -> spare = thresholds -> primary ; rcu_assign_pointer ( thresholds -> primary , new ) ; synchronize_rcu ( ) ; mutex_unlock ( & memcg -> thresholds_lock ) ; } "," ! thresholds ) ; if ( ! thresholds -> primary ) goto unlock ( ) ; unlock : ",torvalds@linux/371528caec553785c37f73fa3926ea0de84f986f,CVE-2012-1146,https://github.com/torvalds/linux/commit/371528caec553785c37f73fa3926ea0de84f986f,2012-05-17T11:00Z 1408,CWE-264,"CWE-264 static struct ion_handle * ion_handle_get_by_id ( struct ion_client * client , int id ) { struct ion_handle * handle ; mutex_lock ( & client -> lock ) ; handle = idr_find ( & client -> idr , id ) ; if ( handle ) ion_handle_get ( handle ) ; mutex_unlock ( & client -> lock ) ; return handle ? handle : ERR_PTR ( - EINVAL ) ; } "," struct ion_handle * ; handle = ion_handle_get_by_id_nolock ( client , id ) ; mutex_unlock ; return handle ; } ",torvalds@linux/9590232bb4f4cc824f3425a6e1349afbe6d6d2b7,CVE-2016-9120,https://github.com/torvalds/linux/commit/9590232bb4f4cc824f3425a6e1349afbe6d6d2b7,2016-12-08T21:59Z 1409,CWE-119,"CWE-119 static void write_uncompressed_header ( VP9_COMP * cpi , struct vp9_write_bit_buffer * wb ) { VP9_COMMON * const cm = & cpi -> common ; vp9_wb_write_literal ( wb , VP9_FRAME_MARKER , 2 ) ; write_profile ( cm -> profile , wb ) ; vp9_wb_write_bit ( wb , 0 ) ; vp9_wb_write_bit ( wb , cm -> frame_type ) ; vp9_wb_write_bit ( wb , cm -> show_frame ) ; vp9_wb_write_bit ( wb , cm -> error_resilient_mode ) ; if ( cm -> frame_type == KEY_FRAME ) { const COLOR_SPACE cs = UNKNOWN ; write_sync_code ( wb ) ; if ( cm -> profile > PROFILE_1 ) { assert ( cm -> bit_depth > BITS_8 ) ; vp9_wb_write_bit ( wb , cm -> bit_depth - BITS_10 ) ; } vp9_wb_write_literal ( wb , cs , 3 ) ; if ( cs != SRGB ) { vp9_wb_write_bit ( wb , 0 ) ; if ( cm -> profile >= PROFILE_1 ) { vp9_wb_write_bit ( wb , cm -> subsampling_x ) ; vp9_wb_write_bit ( wb , cm -> subsampling_y ) ; vp9_wb_write_bit ( wb , 0 ) ; } } else { assert ( cm -> profile == PROFILE_1 ) ; vp9_wb_write_bit ( wb , 0 ) ; } write_frame_size ( cm , wb ) ; } else { if ( ! cm -> show_frame ) vp9_wb_write_bit ( wb , cm -> intra_only ) ; if ( ! cm -> error_resilient_mode ) vp9_wb_write_literal ( wb , cm -> reset_frame_context , 2 ) ; if ( cm -> intra_only ) { write_sync_code ( wb ) ; vp9_wb_write_literal ( wb , get_refresh_mask ( cpi ) , REF_FRAMES ) ; write_frame_size ( cm , wb ) ; } else { MV_REFERENCE_FRAME ref_frame ; vp9_wb_write_literal ( wb , get_refresh_mask ( cpi ) , REF_FRAMES ) ; for ( ref_frame = LAST_FRAME ; ref_frame <= ALTREF_FRAME ; ++ ref_frame ) { vp9_wb_write_literal ( wb , get_ref_frame_idx ( cpi , ref_frame ) , REF_FRAMES_LOG2 ) ; vp9_wb_write_bit ( wb , cm -> ref_frame_sign_bias [ ref_frame ] ) ; } write_frame_size_with_refs ( cpi , wb ) ; vp9_wb_write_bit ( wb , cm -> allow_high_precision_mv ) ; fix_interp_filter ( cm ) ; write_interp_filter ( cm -> interp_filter , wb ) ; } } if ( ! cm -> error_resilient_mode ) { vp9_wb_write_bit ( wb , cm -> refresh_frame_context ) ; vp9_wb_write_bit ( wb , cm -> frame_parallel_decoding_mode ) ; } vp9_wb_write_literal ( wb , cm -> frame_context_idx , FRAME_CONTEXTS_LOG2 ) ; encode_loopfilter ( & cm -> lf , wb ) ; encode_quantization ( cm , wb ) ; encode_segmentation ( cpi , wb ) ; write_tile_info ( cm , wb ) ; } "," cpi , struct vpx_write_bit_buffer * wb ) -> common ; MACROBLOCKD * const xd = & cpi -> td . mb . e_mbd ; vpx_wb_write_literal ( wb , wb ) ; vpx_wb_write_bit ( wb , 0 ) ; vpx_wb_write_bit ( wb , frame_type ) ; vpx_wb_write_bit ( wb , show_frame ) ; vpx_wb_write_bit ( wb , KEY_FRAME ) { write_sync_code ( wb ) ; write_bitdepth_colorspace_sampling ( cm , wb ) ; write_frame_size ( cm , wb ) ; } else { if ( ! cm -> show_frame ) vpx_wb_write_bit ( wb , cm -> intra_only ) ; if ( ! cm -> error_resilient_mode ) vpx_wb_write_literal ( wb , cm -> reset_frame_context , 2 ) ; if ( cm -> intra_only ) { write_sync_code ( wb -> profile > PROFILE_0 ) { write_bitdepth_colorspace_sampling ( cm , wb ) ; } vpx_wb_write_literal ( wb , get_refresh_mask ( cpi ) , REF_FRAMES ) ; write_frame_size ( cm , wb ) ; } else { } else { MV_REFERENCE_FRAME ref_frame ; MV_REFERENCE_FRAME ref_frame ; vpx_wb_write_literal ( wb , ref_frame ) { assert ( get_ref_frame_map_idx ( cpi , ref_frame ) != INVALID_IDX ) ; vpx_wb_write_literal ( wb , get_ref_frame_map_idx ( cpi , REF_FRAMES_LOG2 ) ; vpx_wb_write_bit ( wb , wb ) ; vpx_wb_write_bit ( wb , fix_interp_filter ( cm , cpi -> td . counts error_resilient_mode ) { vpx_wb_write_bit ( wb , refresh_frame_context ) ; vpx_wb_write_bit ( wb , ) ; } vpx_wb_write_literal ( wb , ; encode_segmentation ( cm , xd , wb ) ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1410,CWE-134,"CWE-134 void rrd_graph_options ( int argc , char * argv [ ] , image_desc_t * im ) { int stroff ; char * parsetime_error = NULL ; char scan_gtm [ 12 ] , scan_mtm [ 12 ] , scan_ltm [ 12 ] , col_nam [ 12 ] ; time_t start_tmp = 0 , end_tmp = 0 ; long long_tmp ; rrd_time_value_t start_tv , end_tv ; long unsigned int color ; # define LONGOPT_UNITS_SI 255 struct option long_options [ ] = { { ""alt-autoscale"" , no_argument , 0 , 'A' } , { ""imgformat"" , required_argument , 0 , 'a' } , { ""font-smoothing-threshold"" , required_argument , 0 , 'B' } , { ""base"" , required_argument , 0 , 'b' } , { ""color"" , required_argument , 0 , 'c' } , { ""full-size-mode"" , no_argument , 0 , 'D' } , { ""daemon"" , required_argument , 0 , 'd' } , { ""slope-mode"" , no_argument , 0 , 'E' } , { ""end"" , required_argument , 0 , 'e' } , { ""force-rules-legend"" , no_argument , 0 , 'F' } , { ""imginfo"" , required_argument , 0 , 'f' } , { ""graph-render-mode"" , required_argument , 0 , 'G' } , { ""no-legend"" , no_argument , 0 , 'g' } , { ""height"" , required_argument , 0 , 'h' } , { ""no-minor"" , no_argument , 0 , 'I' } , { ""interlaced"" , no_argument , 0 , 'i' } , { ""alt-autoscale-min"" , no_argument , 0 , 'J' } , { ""only-graph"" , no_argument , 0 , 'j' } , { ""units-length"" , required_argument , 0 , 'L' } , { ""lower-limit"" , required_argument , 0 , 'l' } , { ""alt-autoscale-max"" , no_argument , 0 , 'M' } , { ""zoom"" , required_argument , 0 , 'm' } , { ""no-gridfit"" , no_argument , 0 , 'N' } , { ""font"" , required_argument , 0 , 'n' } , { ""logarithmic"" , no_argument , 0 , 'o' } , { ""pango-markup"" , no_argument , 0 , 'P' } , { ""font-render-mode"" , required_argument , 0 , 'R' } , { ""rigid"" , no_argument , 0 , 'r' } , { ""step"" , required_argument , 0 , 'S' } , { ""start"" , required_argument , 0 , 's' } , { ""tabwidth"" , required_argument , 0 , 'T' } , { ""title"" , required_argument , 0 , 't' } , { ""upper-limit"" , required_argument , 0 , 'u' } , { ""vertical-label"" , required_argument , 0 , 'v' } , { ""watermark"" , required_argument , 0 , 'W' } , { ""width"" , required_argument , 0 , 'w' } , { ""units-exponent"" , required_argument , 0 , 'X' } , { ""x-grid"" , required_argument , 0 , 'x' } , { ""alt-y-grid"" , no_argument , 0 , 'Y' } , { ""y-grid"" , required_argument , 0 , 'y' } , { ""lazy"" , no_argument , 0 , 'z' } , { ""units"" , required_argument , 0 , LONGOPT_UNITS_SI } , { ""alt-y-mrtg"" , no_argument , 0 , 1000 } , { ""disable-rrdtool-tag"" , no_argument , 0 , 1001 } , { ""right-axis"" , required_argument , 0 , 1002 } , { ""right-axis-label"" , required_argument , 0 , 1003 } , { ""right-axis-format"" , required_argument , 0 , 1004 } , { ""legend-position"" , required_argument , 0 , 1005 } , { ""legend-direction"" , required_argument , 0 , 1006 } , { ""border"" , required_argument , 0 , 1007 } , { ""grid-dash"" , required_argument , 0 , 1008 } , { ""dynamic-labels"" , no_argument , 0 , 1009 } , { ""left-axis-format"" , required_argument , 0 , 1010 } , { 0 , 0 , 0 , 0 } } ; optind = 0 ; opterr = 0 ; rrd_parsetime ( ""end-24h"" , & start_tv ) ; rrd_parsetime ( ""now"" , & end_tv ) ; while ( 1 ) { int option_index = 0 ; int opt ; int col_start , col_end ; opt = getopt_long ( argc , argv , ""Aa:B:b:c:Dd:Ee:Ff:G:gh:IiJjL:l:Mm:Nn:oPR:rS:s:T:t:u:v:W:w:X:x:Yy:z"" , long_options , & option_index ) ; if ( opt == EOF ) break ; switch ( opt ) { case 'I' : im -> extra_flags |= NOMINOR ; break ; case 'Y' : im -> extra_flags |= ALTYGRID ; break ; case 'A' : im -> extra_flags |= ALTAUTOSCALE ; break ; case 'J' : im -> extra_flags |= ALTAUTOSCALE_MIN ; break ; case 'M' : im -> extra_flags |= ALTAUTOSCALE_MAX ; break ; case 'j' : im -> extra_flags |= ONLY_GRAPH ; break ; case 'g' : im -> extra_flags |= NOLEGEND ; break ; case 1005 : if ( strcmp ( optarg , ""north"" ) == 0 ) { im -> legendposition = NORTH ; } else if ( strcmp ( optarg , ""west"" ) == 0 ) { im -> legendposition = WEST ; } else if ( strcmp ( optarg , ""south"" ) == 0 ) { im -> legendposition = SOUTH ; } else if ( strcmp ( optarg , ""east"" ) == 0 ) { im -> legendposition = EAST ; } else { rrd_set_error ( ""unknownlegend-position\'%s\'"" , optarg ) ; return ; } break ; case 1006 : if ( strcmp ( optarg , ""topdown"" ) == 0 ) { im -> legenddirection = TOP_DOWN ; } else if ( strcmp ( optarg , ""bottomup"" ) == 0 ) { im -> legenddirection = BOTTOM_UP ; } else { rrd_set_error ( ""unknownlegend-position\'%s\'"" , optarg ) ; return ; } break ; case 'F' : im -> extra_flags |= FORCE_RULES_LEGEND ; break ; case 1001 : im -> extra_flags |= NO_RRDTOOL_TAG ; break ; case LONGOPT_UNITS_SI : if ( im -> extra_flags & FORCE_UNITS ) { rrd_set_error ( ""--unitscanonlybeusedonce!"" ) ; return ; } if ( strcmp ( optarg , ""si"" ) == 0 ) im -> extra_flags |= FORCE_UNITS_SI ; else { rrd_set_error ( ""invalidargumentfor--units:%s"" , optarg ) ; return ; } break ; case 'X' : im -> unitsexponent = atoi ( optarg ) ; break ; case 'L' : im -> unitslength = atoi ( optarg ) ; im -> forceleftspace = 1 ; break ; case 'T' : im -> tabwidth = atof ( optarg ) ; break ; case 'S' : im -> step = atoi ( optarg ) ; break ; case 'N' : im -> gridfit = 0 ; break ; case 'P' : im -> with_markup = 1 ; break ; case 's' : if ( ( parsetime_error = rrd_parsetime ( optarg , & start_tv ) ) ) { rrd_set_error ( ""starttime:%s"" , parsetime_error ) ; return ; } break ; case 'e' : if ( ( parsetime_error = rrd_parsetime ( optarg , & end_tv ) ) ) { rrd_set_error ( ""endtime:%s"" , parsetime_error ) ; return ; } break ; case 'x' : if ( strcmp ( optarg , ""none"" ) == 0 ) { im -> draw_x_grid = 0 ; break ; } ; if ( sscanf ( optarg , ""%10[A-Z]:%ld:%10[A-Z]:%ld:%10[A-Z]:%ld:%ld:%n"" , scan_gtm , & im -> xlab_user . gridst , scan_mtm , & im -> xlab_user . mgridst , scan_ltm , & im -> xlab_user . labst , & im -> xlab_user . precis , & stroff ) == 7 && stroff != 0 ) { strncpy ( im -> xlab_form , optarg + stroff , sizeof ( im -> xlab_form ) - 1 ) ; im -> xlab_form [ sizeof ( im -> xlab_form ) - 1 ] = '\\0' ; if ( ( int ) ( im -> xlab_user . gridtm = tmt_conv ( scan_gtm ) ) == - 1 ) { rrd_set_error ( ""unknownkeyword%s"" , scan_gtm ) ; return ; } else if ( ( int ) ( im -> xlab_user . mgridtm = tmt_conv ( scan_mtm ) ) == - 1 ) { rrd_set_error ( ""unknownkeyword%s"" , scan_mtm ) ; return ; } else if ( ( int ) ( im -> xlab_user . labtm = tmt_conv ( scan_ltm ) ) == - 1 ) { rrd_set_error ( ""unknownkeyword%s"" , scan_ltm ) ; return ; } im -> xlab_user . minsec = 1 ; im -> xlab_user . stst = im -> xlab_form ; } else { rrd_set_error ( ""invalidx-gridformat"" ) ; return ; } break ; case 'y' : if ( strcmp ( optarg , ""none"" ) == 0 ) { im -> draw_y_grid = 0 ; break ; } ; if ( sscanf ( optarg , ""%lf:%d"" , & im -> ygridstep , & im -> ylabfact ) == 2 ) { if ( im -> ygridstep <= 0 ) { rrd_set_error ( ""gridstepmustbe>0"" ) ; return ; } else if ( im -> ylabfact < 1 ) { rrd_set_error ( ""labelfactormustbe>0"" ) ; return ; } } else { rrd_set_error ( ""invalidy-gridformat"" ) ; return ; } break ; case 1007 : im -> draw_3d_border = atoi ( optarg ) ; break ; case 1008 : if ( sscanf ( optarg , ""%lf:%lf"" , & im -> grid_dash_on , & im -> grid_dash_off ) != 2 ) { rrd_set_error ( ""expectedgrid-dashformatfloat:float"" ) ; return ; } break ; case 1009 : im -> dynamic_labels = 1 ; break ; case 1002 : if ( sscanf ( optarg , ""%lf:%lf"" , & im -> second_axis_scale , & im -> second_axis_shift ) == 2 ) { if ( im -> second_axis_scale == 0 ) { rrd_set_error ( ""thesecond_axis_scalemustnotbe0"" ) ; return ; } } else { rrd_set_error ( ""invalidright-axisformatexpectedscale:shift"" ) ; return ; } break ; case 1003 : strncpy ( im -> second_axis_legend , optarg , 150 ) ; im -> second_axis_legend [ 150 ] = '\\0' ; break ; case 1004 : if ( bad_format ( optarg ) ) { rrd_set_error ( ""useeither%leor%lfformats"" ) ; return ; } strncpy ( im -> second_axis_format , optarg , 150 ) ; im -> second_axis_format [ 150 ] = '\\0' ; break ; case 1010 : if ( bad_format ( optarg ) ) { rrd_set_error ( ""useeither%leor%lfformats"" ) ; return ; } strncpy ( im -> primary_axis_format , optarg , 150 ) ; im -> primary_axis_format [ 150 ] = '\\0' ; break ; case 'v' : strncpy ( im -> ylegend , optarg , 150 ) ; im -> ylegend [ 150 ] = '\\0' ; break ; case 'u' : im -> maxval = atof ( optarg ) ; break ; case 'l' : im -> minval = atof ( optarg ) ; break ; case 'b' : im -> base = atol ( optarg ) ; if ( im -> base != 1024 && im -> base != 1000 ) { rrd_set_error ( ""theonlysensiblevalueforbaseapartfrom1000is1024"" ) ; return ; } break ; case 'w' : long_tmp = atol ( optarg ) ; if ( long_tmp < 10 ) { rrd_set_error ( ""widthbelow10pixels"" ) ; return ; } im -> xsize = long_tmp ; break ; case 'h' : long_tmp = atol ( optarg ) ; if ( long_tmp < 10 ) { rrd_set_error ( ""heightbelow10pixels"" ) ; return ; } im -> ysize = long_tmp ; break ; case 'D' : im -> extra_flags |= FULL_SIZE_MODE ; break ; case 'i' : break ; case 'r' : im -> rigid = 1 ; break ; case 'f' : im -> imginfo = optarg ; break ; case 'a' : if ( ( int ) ( im -> imgformat = if_conv ( optarg ) ) == - 1 ) { rrd_set_error ( ""unsupportedgraphicsformat\'%s\'"" , optarg ) ; return ; } break ; case 'z' : im -> lazy = 1 ; break ; case 'E' : im -> slopemode = 1 ; break ; case 'o' : im -> logarithmic = 1 ; break ; case 'c' : if ( sscanf ( optarg , ""%10[A-Z]#%n%8lx%n"" , col_nam , & col_start , & color , & col_end ) == 2 ) { int ci ; int col_len = col_end - col_start ; switch ( col_len ) { case 3 : color = ( ( ( color & 0xF00 ) * 0x110000 ) | ( ( color & 0x0F0 ) * 0x011000 ) | ( ( color & 0x00F ) * 0x001100 ) | 0x000000FF ) ; break ; case 4 : color = ( ( ( color & 0xF000 ) * 0x11000 ) | ( ( color & 0x0F00 ) * 0x01100 ) | ( ( color & 0x00F0 ) * 0x00110 ) | ( ( color & 0x000F ) * 0x00011 ) ) ; break ; case 6 : color = ( color << 8 ) + 0xff ; break ; case 8 : break ; default : rrd_set_error ( ""thecolorformatis#RRGGBB[AA]"" ) ; return ; } if ( ( ci = grc_conv ( col_nam ) ) != - 1 ) { im -> graph_col [ ci ] = gfx_hex_to_col ( color ) ; } else { rrd_set_error ( ""invalidcolorname\'%s\'"" , col_nam ) ; return ; } } else { rrd_set_error ( ""invalidcolordefformat"" ) ; return ; } break ; case 'n' : { char prop [ 15 ] ; double size = 1 ; int end ; if ( sscanf ( optarg , ""%10[A-Z]:%lf%n"" , prop , & size , & end ) >= 2 ) { int sindex , propidx ; if ( ( sindex = text_prop_conv ( prop ) ) != - 1 ) { for ( propidx = sindex ; propidx < TEXT_PROP_LAST ; propidx ++ ) { if ( size > 0 ) { rrd_set_font_desc ( im , propidx , NULL , size ) ; } if ( ( int ) strlen ( optarg ) > end + 2 ) { if ( optarg [ end ] == ':' ) { rrd_set_font_desc ( im , propidx , optarg + end + 1 , 0 ) ; } else { rrd_set_error ( ""expected:afterfontsizein\'%s\'"" , optarg ) ; return ; } } if ( propidx == sindex && sindex != 0 ) break ; } } else { rrd_set_error ( ""invalidfonttag\'%s\'"" , prop ) ; return ; } } else { rrd_set_error ( ""invalidtextpropertyformat"" ) ; return ; } break ; } case 'm' : im -> zoom = atof ( optarg ) ; if ( im -> zoom <= 0.0 ) { rrd_set_error ( ""zoomfactormustbe>0"" ) ; return ; } break ; case 't' : strncpy ( im -> title , optarg , 150 ) ; im -> title [ 150 ] = '\\0' ; break ; case 'R' : if ( strcmp ( optarg , ""normal"" ) == 0 ) { cairo_font_options_set_antialias ( im -> font_options , CAIRO_ANTIALIAS_GRAY ) ; cairo_font_options_set_hint_style ( im -> font_options , CAIRO_HINT_STYLE_FULL ) ; } else if ( strcmp ( optarg , ""light"" ) == 0 ) { cairo_font_options_set_antialias ( im -> font_options , CAIRO_ANTIALIAS_GRAY ) ; cairo_font_options_set_hint_style ( im -> font_options , CAIRO_HINT_STYLE_SLIGHT ) ; } else if ( strcmp ( optarg , ""mono"" ) == 0 ) { cairo_font_options_set_antialias ( im -> font_options , CAIRO_ANTIALIAS_NONE ) ; cairo_font_options_set_hint_style ( im -> font_options , CAIRO_HINT_STYLE_FULL ) ; } else { rrd_set_error ( ""unknownfont-render-mode\'%s\'"" , optarg ) ; return ; } break ; case 'G' : if ( strcmp ( optarg , ""normal"" ) == 0 ) im -> graph_antialias = CAIRO_ANTIALIAS_GRAY ; else if ( strcmp ( optarg , ""mono"" ) == 0 ) im -> graph_antialias = CAIRO_ANTIALIAS_NONE ; else { rrd_set_error ( ""unknowngraph-render-mode\'%s\'"" , optarg ) ; return ; } break ; case 'B' : break ; case 'W' : strncpy ( im -> watermark , optarg , 100 ) ; im -> watermark [ 99 ] = '\\0' ; break ; case 'd' : { if ( im -> daemon_addr != NULL ) { rrd_set_error ( ""Youcannotspecify--daemon"" ""morethanonce."" ) ; return ; } im -> daemon_addr = strdup ( optarg ) ; if ( im -> daemon_addr == NULL ) { rrd_set_error ( ""strdupfailed"" ) ; return ; } break ; } case '?' : if ( optopt != 0 ) rrd_set_error ( ""unknownoption\'%c\'"" , optopt ) ; else rrd_set_error ( ""unknownoption\'%s\'"" , argv [ optind - 1 ] ) ; return ; } } { int status = rrdc_connect ( im -> daemon_addr ) ; if ( status != 0 ) return ; } pango_cairo_context_set_font_options ( pango_layout_get_context ( im -> layout ) , im -> font_options ) ; pango_layout_context_changed ( im -> layout ) ; if ( im -> logarithmic && im -> minval <= 0 ) { rrd_set_error ( ""foralogarithmicyaxisyoumustspecifyalower-limit>0"" ) ; return ; } if ( rrd_proc_start_end ( & start_tv , & end_tv , & start_tmp , & end_tmp ) == - 1 ) { return ; } if ( start_tmp < 3600 * 24 * 365 * 10 ) { rrd_set_error ( ""thefirstentrytofetchshouldbeafter1980(%ld)"" , start_tmp ) ; return ; } if ( end_tmp < start_tmp ) { rrd_set_error ( ""start(%ld)shouldbelessthanend(%ld)"" , start_tmp , end_tmp ) ; return ; } im -> start = start_tmp ; im -> end = end_tmp ; im -> step = max ( ( long ) im -> step , ( im -> end - im -> start ) / im -> xsize ) ; } "," : if ( bad_format_axis ( optarg ) ) { return ; } : if ( bad_format_axis ( optarg ) ) { return ; } ",oetiker@rrdtool-1.x/85261a013112e278c90224033f5b0592ee387786,CVE-2014-6262,https://github.com/oetiker/rrdtool-1.x/commit/85261a013112e278c90224033f5b0592ee387786,2020-02-12T02:15Z 1411,CWE-20,"CWE-20 error_t httpClientSetQueryString ( HttpClientContext * context , const char_t * queryString ) { size_t m ; size_t n ; char_t * p ; char_t * q ; if ( context == NULL || queryString == NULL ) return ERROR_INVALID_PARAMETER ; if ( context -> requestState != HTTP_REQ_STATE_FORMAT_HEADER ) return ERROR_WRONG_STATE ; if ( context -> bufferLen > HTTP_CLIENT_BUFFER_SIZE ) return ERROR_INVALID_SYNTAX ; context -> buffer [ context -> bufferLen ] = '\\0' ; p = strchr ( context -> buffer , '' ) ; if ( p == NULL ) return ERROR_INVALID_SYNTAX ; p = strpbrk ( p + 1 , ""?"" ) ; if ( p == NULL ) return ERROR_INVALID_SYNTAX ; if ( * p == '?' ) { q = strchr ( p + 1 , '' ) ; if ( q == NULL ) return ERROR_INVALID_SYNTAX ; m = q - p ; } else { q = p ; m = 0 ; } n = osStrlen ( queryString ) ; if ( n == 0 ) { osMemmove ( p , p + m , context -> buffer + context -> bufferLen + 1 - q ) ; } else { n ++ ; if ( ( context -> bufferLen + n - m ) > HTTP_CLIENT_BUFFER_SIZE ) return ERROR_BUFFER_OVERFLOW ; osMemmove ( p + n , q , context -> buffer + context -> bufferLen + 1 - q ) ; p [ 0 ] = '?' ; osStrncpy ( p + 1 , queryString , n - 1 ) ; } context -> bufferLen = context -> bufferLen + n - m ; return NO_ERROR ; } "," ; p = osStrchr ( context -> { q = osStrchr ( p + ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 1412,CWE-125,"CWE-125 static int handle_keywordonly_args ( struct compiling * c , const node * n , int start , asdl_seq * kwonlyargs , asdl_seq * kwdefaults ) { PyObject * argname ; node * ch ; expr_ty expression , annotation ; arg_ty arg = NULL ; int i = start ; int j = 0 ; if ( kwonlyargs == NULL ) { ast_error ( c , CHILD ( n , start ) , ""namedargumentsmustfollowbare*"" ) ; return - 1 ; } assert ( kwdefaults != NULL ) ; while ( i < NCH ( n ) ) { ch = CHILD ( n , i ) ; switch ( TYPE ( ch ) ) { case vfpdef : case tfpdef : if ( i + 1 < NCH ( n ) && TYPE ( CHILD ( n , i + 1 ) ) == EQUAL ) { expression = ast_for_expr ( c , CHILD ( n , i + 2 ) ) ; if ( ! expression ) goto error ; asdl_seq_SET ( kwdefaults , j , expression ) ; i += 2 ; } else { asdl_seq_SET ( kwdefaults , j , NULL ) ; } if ( NCH ( ch ) == 3 ) { annotation = ast_for_expr ( c , CHILD ( ch , 2 ) ) ; if ( ! annotation ) goto error ; } else { annotation = NULL ; } ch = CHILD ( ch , 0 ) ; argname = NEW_IDENTIFIER ( ch ) ; if ( ! argname ) goto error ; if ( forbidden_name ( c , argname , ch , 0 ) ) goto error ; arg = arg ( argname , annotation , NULL , LINENO ( ch ) , ch -> n_col_offset , ch -> n_end_lineno , ch -> n_end_col_offset , c -> c_arena ) ; if ( ! arg ) goto error ; asdl_seq_SET ( kwonlyargs , j ++ , arg ) ; i += 1 ; if ( TYPE ( CHILD ( n , i ) ) == COMMA ) i += 1 ; break ; case TYPE_COMMENT : arg -> type_comment = NEW_TYPE_COMMENT ( ch ) ; if ( ! arg -> type_comment ) goto error ; i += 1 ; break ; case DOUBLESTAR : return i ; default : ast_error ( c , ch , ""unexpectednode"" ) ; goto error ; } } return i ; error : return - 1 ; } "," ; if ( i < NCH ( n ) && ",python@typed_ast/a4d78362397fc3bced6ea80fbc7b5f4827aec55e,CVE-2019-19275,https://github.com/python/typed_ast/commit/a4d78362397fc3bced6ea80fbc7b5f4827aec55e,2019-11-26T15:15Z 1413,CWE-119,"CWE-119 static void init_frame ( VP8D_COMP * pbi ) { VP8_COMMON * const pc = & pbi -> common ; MACROBLOCKD * const xd = & pbi -> mb ; if ( pc -> frame_type == KEY_FRAME ) { vpx_memcpy ( pc -> fc . mvc , vp8_default_mv_context , sizeof ( vp8_default_mv_context ) ) ; vp8_init_mbmode_probs ( pc ) ; vp8_default_coef_probs ( pc ) ; vpx_memset ( xd -> segment_feature_data , 0 , sizeof ( xd -> segment_feature_data ) ) ; xd -> mb_segement_abs_delta = SEGMENT_DELTADATA ; vpx_memset ( xd -> ref_lf_deltas , 0 , sizeof ( xd -> ref_lf_deltas ) ) ; vpx_memset ( xd -> mode_lf_deltas , 0 , sizeof ( xd -> mode_lf_deltas ) ) ; pc -> refresh_golden_frame = 1 ; pc -> refresh_alt_ref_frame = 1 ; pc -> copy_buffer_to_gf = 0 ; pc -> copy_buffer_to_arf = 0 ; pc -> ref_frame_sign_bias [ GOLDEN_FRAME ] = 0 ; pc -> ref_frame_sign_bias [ ALTREF_FRAME ] = 0 ; } else { if ( ! pc -> use_bilinear_mc_filter ) { xd -> subpixel_predict = vp8_sixtap_predict4x4 ; xd -> subpixel_predict8x4 = vp8_sixtap_predict8x4 ; xd -> subpixel_predict8x8 = vp8_sixtap_predict8x8 ; xd -> subpixel_predict16x16 = vp8_sixtap_predict16x16 ; } else { xd -> subpixel_predict = vp8_bilinear_predict4x4 ; xd -> subpixel_predict8x4 = vp8_bilinear_predict8x4 ; xd -> subpixel_predict8x8 = vp8_bilinear_predict8x8 ; xd -> subpixel_predict16x16 = vp8_bilinear_predict16x16 ; } if ( pbi -> decoded_key_frame && pbi -> ec_enabled && ! pbi -> ec_active ) pbi -> ec_active = 1 ; } xd -> left_context = & pc -> left_context ; xd -> mode_info_context = pc -> mi ; xd -> frame_type = pc -> frame_type ; xd -> mode_info_context -> mbmi . mode = DC_PRED ; xd -> mode_info_stride = pc -> mode_info_stride ; xd -> corrupted = 0 ; xd -> fullpixel_mask = 0xffffffff ; if ( pc -> full_pixel ) xd -> fullpixel_mask = 0xfffffff8 ; } "," KEY_FRAME ) { memcpy ( pc -> pc ) ; memset ( xd -> = SEGMENT_DELTADATA ; memset ( xd -> ) ) ; memset ( xd -> ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1414,CWE-20,"CWE-20 error_t enc624j600ReceivePacket ( NetInterface * interface ) { error_t error ; uint16_t n ; uint32_t status ; Enc624j600Context * context ; context = ( Enc624j600Context * ) interface -> nicContext ; if ( enc624j600ReadReg ( interface , ENC624J600_REG_ESTAT ) & ESTAT_PKTCNT ) { enc624j600WriteReg ( interface , ENC624J600_REG_ERXRDPT , context -> nextPacket ) ; enc624j600ReadBuffer ( interface , ENC624J600_CMD_RRXDATA , ( uint8_t * ) & context -> nextPacket , sizeof ( uint16_t ) ) ; context -> nextPacket = letoh16 ( context -> nextPacket ) ; enc624j600ReadBuffer ( interface , ENC624J600_CMD_RRXDATA , ( uint8_t * ) & n , sizeof ( uint16_t ) ) ; n = letoh16 ( n ) ; enc624j600ReadBuffer ( interface , ENC624J600_CMD_RRXDATA , ( uint8_t * ) & status , sizeof ( uint32_t ) ) ; status = letoh32 ( status ) ; if ( ( status & RSV_RECEIVED_OK ) != 0 ) { n = MIN ( n , ETH_MAX_FRAME_SIZE ) ; enc624j600ReadBuffer ( interface , ENC624J600_CMD_RRXDATA , context -> rxBuffer , n ) ; error = NO_ERROR ; } else { error = ERROR_INVALID_PACKET ; } if ( context -> nextPacket == ENC624J600_RX_BUFFER_START ) { enc624j600WriteReg ( interface , ENC624J600_REG_ERXTAIL , ENC624J600_RX_BUFFER_STOP ) ; } else { enc624j600WriteReg ( interface , ENC624J600_REG_ERXTAIL , context -> nextPacket - 2 ) ; } enc624j600SetBit ( interface , ENC624J600_REG_ECON1 , ECON1_PKTDEC ) ; } else { error = ERROR_BUFFER_EMPTY ; } if ( ! error ) { NetRxAncillary ancillary ; ancillary = NET_DEFAULT_RX_ANCILLARY ; nicProcessPacket ( interface , context -> rxBuffer , n , & ancillary ) ; } return error ; } "," error ; uint16_t length ; uint32_t status uint32_t status ; uint8_t header [ 8 ] ; ( interface , ENC624J600_ESTAT ) & ENC624J600_ESTAT_PKTCNT ) { enc624j600WriteReg ( interface , ENC624J600_ERXRDPT , context -> , ENC624J600_CMD_RRXDATA , header , sizeof ( , sizeof ( header ) ) ; context -> nextPacket = LOAD16LE ( header ) ; length = LOAD16LE ( header + 2 ) ; status = LOAD32LE ( header + 4 ) ; if ( status & ENC624J600_RSV_RECEIVED_OK ) != 0 0 ) { length = MIN ( = MIN ( length , ETH_MAX_FRAME_SIZE ) -> rxBuffer , length ) ; error ( interface , ENC624J600_ERXTAIL , ENC624J600_RX_BUFFER_STOP ) ; ( interface , ENC624J600_ERXTAIL , context -> nextPacket ( interface , ENC624J600_ECON1 , ENC624J600_ECON1_PKTDEC ) ; } -> rxBuffer , length , & ancillary ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 1415,CWE-119,"CWE-119 static int gemsafe_get_cert_len ( sc_card_t * card ) { int r ; u8 ibuf [ GEMSAFE_MAX_OBJLEN ] ; u8 * iptr ; struct sc_path path ; struct sc_file * file ; size_t objlen , certlen ; unsigned int ind , i = 0 ; sc_format_path ( GEMSAFE_PATH , & path ) ; r = sc_select_file ( card , & path , & file ) ; if ( r != SC_SUCCESS || ! file ) return SC_ERROR_INTERNAL ; r = sc_read_binary ( card , 0 , ibuf , GEMSAFE_READ_QUANTUM , 0 ) ; if ( r < 0 ) return SC_ERROR_INTERNAL ; objlen = ( ( ( size_t ) ibuf [ 0 ] ) << 8 ) | ibuf [ 1 ] ; sc_log ( card -> ctx , ""Storedobjectisofsize:%"" SC_FORMAT_LEN_SIZE_T ""u"" , objlen ) ; if ( objlen < 1 || objlen > GEMSAFE_MAX_OBJLEN ) { sc_log ( card -> ctx , ""Invalidobjectsize:%"" SC_FORMAT_LEN_SIZE_T ""u"" , objlen ) ; return SC_ERROR_INTERNAL ; } ind = 2 ; while ( ibuf [ ind ] == 0x01 ) { if ( ibuf [ ind + 1 ] == 0xFE ) { gemsafe_prkeys [ i ] . ref = ibuf [ ind + 4 ] ; sc_log ( card -> ctx , ""Keycontainer%disallocatedanduseskey_ref%d"" , i + 1 , gemsafe_prkeys [ i ] . ref ) ; ind += 9 ; } else { gemsafe_prkeys [ i ] . label = NULL ; gemsafe_cert [ i ] . label = NULL ; sc_log ( card -> ctx , ""Keycontainer%disunallocated"" , i + 1 ) ; ind += 8 ; } i ++ ; } for ( ; i < gemsafe_cert_max ; i ++ ) { gemsafe_prkeys [ i ] . label = NULL ; gemsafe_cert [ i ] . label = NULL ; } iptr = ibuf + GEMSAFE_READ_QUANTUM ; while ( ( size_t ) ( iptr - ibuf ) < objlen ) { r = sc_read_binary ( card , iptr - ibuf , iptr , MIN ( GEMSAFE_READ_QUANTUM , objlen - ( iptr - ibuf ) ) , 0 ) ; if ( r < 0 ) { sc_log ( card -> ctx , ""Couldnotreadcertobject"" ) ; return SC_ERROR_INTERNAL ; } iptr += GEMSAFE_READ_QUANTUM ; } i = 0 ; while ( ind < objlen - 1 ) { if ( ibuf [ ind ] == 0x30 && ibuf [ ind + 1 ] == 0x82 ) { while ( i < gemsafe_cert_max && gemsafe_cert [ i ] . label == NULL ) i ++ ; if ( i == gemsafe_cert_max ) { sc_log ( card -> ctx , ""Warning:Foundorphanedcertificateatoffset%d"" , ind ) ; return SC_SUCCESS ; } if ( ind + 3 >= sizeof ibuf ) return SC_ERROR_INVALID_DATA ; certlen = ( ( ( ( size_t ) ibuf [ ind + 2 ] ) << 8 ) | ibuf [ ind + 3 ] ) + 4 ; sc_log ( card -> ctx , ""Foundcertificateofkeycontainer%datoffset%d,len%"" SC_FORMAT_LEN_SIZE_T ""u"" , i + 1 , ind , certlen ) ; gemsafe_cert [ i ] . index = ind ; gemsafe_cert [ i ] . count = certlen ; ind += certlen ; i ++ ; } else ind ++ ; } for ( ; i < gemsafe_cert_max ; i ++ ) { if ( gemsafe_cert [ i ] . label ) { sc_log ( card -> ctx , ""Warning:Certificateofkeycontainer%dismissing"" , i + 1 ) ; gemsafe_prkeys [ i ] . label = NULL ; gemsafe_cert [ i ] . label = NULL ; } } return SC_SUCCESS ; } "," ] == 0x01 && i < gemsafe_cert_max ",OpenSC@OpenSC/360e95d45ac4123255a4c796db96337f332160ad,CVE-2018-16391,https://github.com/OpenSC/OpenSC/commit/360e95d45ac4123255a4c796db96337f332160ad#diff-477b7a40136bb418b10ce271c8664536,2018-09-03T14:29Z 1416,CWE-264,"CWE-264 static int handle_wrmsr ( struct kvm_vcpu * vcpu ) { struct msr_data msr ; u32 ecx = vcpu -> arch . regs [ VCPU_REGS_RCX ] ; u64 data = ( vcpu -> arch . regs [ VCPU_REGS_RAX ] & - 1u ) | ( ( u64 ) ( vcpu -> arch . regs [ VCPU_REGS_RDX ] & - 1u ) << 32 ) ; msr . data = data ; msr . index = ecx ; msr . host_initiated = false ; if ( vmx_set_msr ( vcpu , & msr ) != 0 ) { trace_kvm_msr_write_ex ( ecx , data ) ; kvm_inject_gp ( vcpu , 0 ) ; return 1 ; } trace_kvm_msr_write ( ecx , data ) ; skip_emulated_instruction ( vcpu ) ; return 1 ; } "," ; if ( kvm_set_msr ( vcpu , ",torvalds@linux/854e8bb1aa06c578c2c9145fa6bfe3680ef63b23,CVE-2014-3610,https://github.com/torvalds/linux/commit/854e8bb1aa06c578c2c9145fa6bfe3680ef63b23,2014-11-10T11:55Z 1417,CWE-611,"CWE-611 static VALUE read_memory ( VALUE klass , VALUE content ) { xmlSchemaPtr schema ; xmlSchemaParserCtxtPtr ctx = xmlSchemaNewMemParserCtxt ( ( const char * ) StringValuePtr ( content ) , ( int ) RSTRING_LEN ( content ) ) ; VALUE rb_schema ; VALUE errors = rb_ary_new ( ) ; xmlSetStructuredErrorFunc ( ( void * ) errors , Nokogiri_error_array_pusher ) ; # ifdef HAVE_XMLSCHEMASETPARSERSTRUCTUREDERRORS xmlSchemaSetParserStructuredErrors ( ctx , Nokogiri_error_array_pusher , ( void * ) errors ) ; # endif schema = xmlSchemaParse ( ctx ) ; xmlSetStructuredErrorFunc ( NULL , NULL ) ; xmlSchemaFreeParserCtxt ( ctx ) ; if ( NULL == schema ) { xmlErrorPtr error = xmlGetLastError ( ) ; if ( error ) Nokogiri_error_raise ( NULL , error ) ; else rb_raise ( rb_eRuntimeError , ""Couldnotparsedocument"" ) ; return Qnil ; } rb_schema = Data_Wrap_Struct ( klass , 0 , dealloc , schema ) ; rb_iv_set ( rb_schema , ""@errors"" , errors ) ; return rb_schema ; } "," VALUE read_memory ( int argc , VALUE * argv , VALUE klass ) { VALUE content ; VALUE parse_options ; int parse_options_int ; xmlSchemaParserCtxtPtr ctx ; xmlSchemaPtr schema ; xmlSchemaPtr schema ; VALUE errors ; VALUE rb_schema ; int scanned_args = 0 ; scanned_args = rb_scan_args ( argc , argv , ""11"" , & content , & parse_options ) ; if ( scanned_args == 1 ) { parse_options = rb_const_get ( rb_const_get ( mNokogiriXml , rb_intern ( ""ParseOptions"" ) ) , rb_intern ( ""DEFAULT_SCHEMA"" ) ) ; } parse_options_int = ( int ) NUM2INT ( rb_funcall ( parse_options , rb_intern ( ""to_i"" ) , 0 ) ) ; ctx = xmlSchemaNewMemParserCtxt ( content ) ) ; errors = rb_ary_new errors ) ; rb_iv_set ( rb_schema , ""@parse_options"" , parse_options ) ; ",sparklemotion@nokogiri/9c87439d9afa14a365ff13e73adc809cb2c3d97b,CVE-2020-26247,https://github.com/sparklemotion/nokogiri/commit/9c87439d9afa14a365ff13e73adc809cb2c3d97b,2020-12-30T19:15Z 1418,CWE-119,"CWE-119 static int au1200fb_fb_mmap ( struct fb_info * info , struct vm_area_struct * vma ) { unsigned int len ; unsigned long start = 0 , off ; struct au1200fb_device * fbdev = info -> par ; if ( vma -> vm_pgoff > ( ~ 0UL >> PAGE_SHIFT ) ) { return - EINVAL ; } start = fbdev -> fb_phys & PAGE_MASK ; len = PAGE_ALIGN ( ( start & ~ PAGE_MASK ) + fbdev -> fb_len ) ; off = vma -> vm_pgoff << PAGE_SHIFT ; if ( ( vma -> vm_end - vma -> vm_start + off ) > len ) { return - EINVAL ; } off += start ; vma -> vm_pgoff = off >> PAGE_SHIFT ; vma -> vm_page_prot = pgprot_noncached ( vma -> vm_page_prot ) ; pgprot_val ( vma -> vm_page_prot ) |= _CACHE_MASK ; return io_remap_pfn_range ( vma , vma -> vm_start , off >> PAGE_SHIFT , vma -> vm_end - vma -> vm_start , vma -> vm_page_prot ) ; } "," vma ) { struct au1200fb_device * info -> par ; vma -> _CACHE_MASK ; return vm_iomap_memory ( vma , ( vma , fbdev -> fb_phys , fbdev -> fb_len ) ; } ",torvalds@linux/7314e613d5ff9f0934f7a0f74ed7973b903315d1,CVE-2013-6763,https://github.com/torvalds/linux/commit/7314e613d5ff9f0934f7a0f74ed7973b903315d1,2013-11-12T14:35Z 1419,CWE-295,"CWE-295 NOEXPORT int options_file ( char * path , CONF_TYPE type , SERVICE_OPTIONS * * section_ptr ) { DISK_FILE * df ; char line_text [ CONFLINELEN ] , * errstr ; char config_line [ CONFLINELEN ] , * config_opt , * config_arg ; int i , line_number = 0 ; # ifndef USE_WIN32 int fd ; char * tmp_str ; # endif s_log ( LOG_NOTICE , ""Readingconfigurationfrom%s%s"" , type == CONF_FD ? ""descriptor"" : ""file"" , path ) ; # ifndef USE_WIN32 if ( type == CONF_FD ) { fd = ( int ) strtol ( path , & tmp_str , 10 ) ; if ( tmp_str == path || * tmp_str ) { s_log ( LOG_ERR , ""Invalidfiledescriptornumber"" ) ; print_syntax ( ) ; return 1 ; } df = file_fdopen ( fd ) ; } else # endif df = file_open ( path , FILE_MODE_READ ) ; if ( ! df ) { s_log ( LOG_ERR , ""Cannotopenconfigurationfile"" ) ; if ( type != CONF_RELOAD ) print_syntax ( ) ; return 1 ; } while ( file_getline ( df , line_text , CONFLINELEN ) >= 0 ) { memcpy ( config_line , line_text , CONFLINELEN ) ; ++ line_number ; config_opt = config_line ; if ( line_number == 1 ) { if ( config_opt [ 0 ] == ( char ) 0xef && config_opt [ 1 ] == ( char ) 0xbb && config_opt [ 2 ] == ( char ) 0xbf ) { s_log ( LOG_NOTICE , ""UTF-8byteordermarkdetected"" ) ; config_opt += 3 ; } else { s_log ( LOG_NOTICE , ""UTF-8byteordermarknotdetected"" ) ; } } while ( isspace ( ( unsigned char ) * config_opt ) ) ++ config_opt ; for ( i = ( int ) strlen ( config_opt ) - 1 ; i >= 0 && isspace ( ( unsigned char ) config_opt [ i ] ) ; -- i ) config_opt [ i ] = '\\0' ; if ( config_opt [ 0 ] == '\\0' || config_opt [ 0 ] == '#' || config_opt [ 0 ] == ';' ) continue ; if ( config_opt [ 0 ] == '[' && config_opt [ strlen ( config_opt ) - 1 ] == ']' ) { if ( init_section ( 0 , section_ptr ) ) { file_close ( df ) ; return 1 ; } { SERVICE_OPTIONS * new_section ; new_section = str_alloc_detached ( sizeof ( SERVICE_OPTIONS ) ) ; new_section -> next = NULL ; ( * section_ptr ) -> next = new_section ; * section_ptr = new_section ; } ++ config_opt ; config_opt [ strlen ( config_opt ) - 1 ] = '\\0' ; ( * section_ptr ) -> servname = str_dup_detached ( config_opt ) ; ( * section_ptr ) -> session = NULL ; parse_service_option ( CMD_SET_COPY , section_ptr , NULL , NULL ) ; continue ; } config_arg = strchr ( config_line , '=' ) ; if ( ! config_arg ) { s_log ( LOG_ERR , ""%s:%d:\\""%s\\"":No\'=\'found"" , path , line_number , line_text ) ; file_close ( df ) ; return 1 ; } * config_arg ++ = '\\0' ; for ( i = ( int ) strlen ( config_opt ) - 1 ; i >= 0 && isspace ( ( unsigned char ) config_opt [ i ] ) ; -- i ) config_opt [ i ] = '\\0' ; while ( isspace ( ( unsigned char ) * config_arg ) ) ++ config_arg ; errstr = option_not_found ; if ( ! new_service_options . next ) errstr = parse_global_option ( CMD_SET_VALUE , config_opt , config_arg ) ; if ( errstr == option_not_found ) errstr = parse_service_option ( CMD_SET_VALUE , section_ptr , config_opt , config_arg ) ; if ( errstr ) { s_log ( LOG_ERR , ""%s:%d:\\""%s\\"":%s"" , path , line_number , line_text , errstr ) ; file_close ( df ) ; return 1 ; } } file_close ( df ) ; return 0 ; } "," ( CMD_SET_VALUE , & new_global_options , ",mtrojnar@stunnel/ebad9ddc4efb2635f37174c9d800d06206f1edf9,CVE-2021-20230,https://github.com/mtrojnar/stunnel/commit/ebad9ddc4efb2635f37174c9d800d06206f1edf9,2021-02-23T17:15Z 1420,CWE-119,"CWE-119 int ImagingPcdDecode ( Imaging im , ImagingCodecState state , UINT8 * buf , int bytes ) { int x ; int chunk ; UINT8 * out ; UINT8 * ptr ; ptr = buf ; chunk = 3 * state -> xsize ; for ( ; ; ) { if ( bytes < chunk ) return ptr - buf ; out = state -> buffer ; for ( x = 0 ; x < state -> xsize ; x ++ ) { out [ 0 ] = ptr [ x ] ; out [ 1 ] = ptr [ ( x + 4 * state -> xsize ) / 2 ] ; out [ 2 ] = ptr [ ( x + 5 * state -> xsize ) / 2 ] ; out += 4 ; } state -> shuffle ( ( UINT8 * ) im -> image [ state -> y ] , state -> buffer , state -> xsize ) ; if ( ++ state -> y >= state -> ysize ) return - 1 ; out = state -> buffer ; for ( x = 0 ; x < state -> xsize ; x ++ ) { out [ 0 ] = ptr [ x + state -> xsize ] ; out [ 1 ] = ptr [ ( x + 4 * state -> xsize ) / 2 ] ; out [ 2 ] = ptr [ ( x + 5 * state -> xsize ) / 2 ] ; out += 4 ; } state -> shuffle ( ( UINT8 * ) im -> image [ state -> y ] , state -> buffer , state -> xsize ) ; if ( ++ state -> y >= state -> ysize ) return - 1 ; ptr += chunk ; bytes -= chunk ; } } "," ; out += 3 ; } state ; out += 3 ; } state ",python-pillow@Pillow/ae453aa18b66af54e7ff716f4ccb33adca60afd4,CVE-2016-2533,https://github.com/python-pillow/Pillow/commit/ae453aa18b66af54e7ff716f4ccb33adca60afd4,2016-04-13T16:59Z 1421,CWE-399,"CWE-399 static void alpha_perf_event_irq_handler ( unsigned long la_ptr , struct pt_regs * regs ) { struct cpu_hw_events * cpuc ; struct perf_sample_data data ; struct perf_event * event ; struct hw_perf_event * hwc ; int idx , j ; __get_cpu_var ( irq_pmi_count ) ++ ; cpuc = & __get_cpu_var ( cpu_hw_events ) ; wrperfmon ( PERFMON_CMD_DISABLE , cpuc -> idx_mask ) ; if ( unlikely ( la_ptr >= alpha_pmu -> num_pmcs ) ) { irq_err_count ++ ; pr_warning ( ""PMI:sillyindex%ld\\n"" , la_ptr ) ; wrperfmon ( PERFMON_CMD_ENABLE , cpuc -> idx_mask ) ; return ; } idx = la_ptr ; perf_sample_data_init ( & data , 0 ) ; for ( j = 0 ; j < cpuc -> n_events ; j ++ ) { if ( cpuc -> current_idx [ j ] == idx ) break ; } if ( unlikely ( j == cpuc -> n_events ) ) { wrperfmon ( PERFMON_CMD_ENABLE , cpuc -> idx_mask ) ; return ; } event = cpuc -> event [ j ] ; if ( unlikely ( ! event ) ) { irq_err_count ++ ; pr_warning ( ""PMI:Noeventatindex%d!\\n"" , idx ) ; wrperfmon ( PERFMON_CMD_ENABLE , cpuc -> idx_mask ) ; return ; } hwc = & event -> hw ; alpha_perf_event_update ( event , hwc , idx , alpha_pmu -> pmc_max_period [ idx ] + 1 ) ; data . period = event -> hw . last_period ; if ( alpha_perf_event_set_period ( event , hwc , idx ) ) { if ( perf_event_overflow ( event , 1 , & data , regs ) ) { alpha_pmu_stop ( event , 0 ) ; } } wrperfmon ( PERFMON_CMD_ENABLE , cpuc -> idx_mask ) ; return ; } "," ( event , & data , ",torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,CVE-2011-2918,https://github.com/torvalds/linux/commit/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,2012-05-24T23:55Z 1422,CWE-119,"CWE-119 static int cdrom_ioctl_media_changed ( struct cdrom_device_info * cdi , unsigned long arg ) { struct cdrom_changer_info * info ; int ret ; cd_dbg ( CD_DO_IOCTL , ""enteringCDROM_MEDIA_CHANGED\\n"" ) ; if ( ! CDROM_CAN ( CDC_MEDIA_CHANGED ) ) return - ENOSYS ; if ( ! CDROM_CAN ( CDC_SELECT_DISC ) || arg == CDSL_CURRENT ) return media_changed ( cdi , 1 ) ; if ( ( unsigned int ) arg >= cdi -> capacity ) return - EINVAL ; info = kmalloc ( sizeof ( * info ) , GFP_KERNEL ) ; if ( ! info ) return - ENOMEM ; ret = cdrom_read_mech_status ( cdi , info ) ; if ( ! ret ) ret = info -> slots [ arg ] . change ; kfree ( info ) ; return ret ; } "," ; if ( arg >= cdi ",torvalds@linux/9de4ee40547fd315d4a0ed1dd15a2fa3559ad707,CVE-2018-10940,https://github.com/torvalds/linux/commit/9de4ee40547fd315d4a0ed1dd15a2fa3559ad707,2018-05-09T17:29Z 1423,CWE-362,"CWE-362 static int fanout_add ( struct sock * sk , u16 id , u16 type_flags ) { struct packet_rollover * rollover = NULL ; struct packet_sock * po = pkt_sk ( sk ) ; struct packet_fanout * f , * match ; u8 type = type_flags & 0xff ; u8 flags = type_flags >> 8 ; int err ; switch ( type ) { case PACKET_FANOUT_ROLLOVER : if ( type_flags & PACKET_FANOUT_FLAG_ROLLOVER ) return - EINVAL ; case PACKET_FANOUT_HASH : case PACKET_FANOUT_LB : case PACKET_FANOUT_CPU : case PACKET_FANOUT_RND : case PACKET_FANOUT_QM : case PACKET_FANOUT_CBPF : case PACKET_FANOUT_EBPF : break ; default : return - EINVAL ; } mutex_lock ( & fanout_mutex ) ; err = - EINVAL ; if ( ! po -> running ) goto out ; err = - EALREADY ; if ( po -> fanout ) goto out ; if ( type == PACKET_FANOUT_ROLLOVER || ( type_flags & PACKET_FANOUT_FLAG_ROLLOVER ) ) { err = - ENOMEM ; rollover = kzalloc ( sizeof ( * rollover ) , GFP_KERNEL ) ; if ( ! rollover ) goto out ; atomic_long_set ( & rollover -> num , 0 ) ; atomic_long_set ( & rollover -> num_huge , 0 ) ; atomic_long_set ( & rollover -> num_failed , 0 ) ; po -> rollover = rollover ; } if ( type_flags & PACKET_FANOUT_FLAG_UNIQUEID ) { if ( id != 0 ) { err = - EINVAL ; goto out ; } if ( ! fanout_find_new_id ( sk , & id ) ) { err = - ENOMEM ; goto out ; } flags &= ~ ( PACKET_FANOUT_FLAG_UNIQUEID >> 8 ) ; } match = NULL ; list_for_each_entry ( f , & fanout_list , list ) { if ( f -> id == id && read_pnet ( & f -> net ) == sock_net ( sk ) ) { match = f ; break ; } } err = - EINVAL ; if ( match && match -> flags != flags ) goto out ; if ( ! match ) { err = - ENOMEM ; match = kzalloc ( sizeof ( * match ) , GFP_KERNEL ) ; if ( ! match ) goto out ; write_pnet ( & match -> net , sock_net ( sk ) ) ; match -> id = id ; match -> type = type ; match -> flags = flags ; INIT_LIST_HEAD ( & match -> list ) ; spin_lock_init ( & match -> lock ) ; refcount_set ( & match -> sk_ref , 0 ) ; fanout_init_data ( match ) ; match -> prot_hook . type = po -> prot_hook . type ; match -> prot_hook . dev = po -> prot_hook . dev ; match -> prot_hook . func = packet_rcv_fanout ; match -> prot_hook . af_packet_priv = match ; match -> prot_hook . id_match = match_fanout_group ; list_add ( & match -> list , & fanout_list ) ; } err = - EINVAL ; if ( match -> type == type && match -> prot_hook . type == po -> prot_hook . type && match -> prot_hook . dev == po -> prot_hook . dev ) { err = - ENOSPC ; if ( refcount_read ( & match -> sk_ref ) < PACKET_FANOUT_MAX ) { __dev_remove_pack ( & po -> prot_hook ) ; po -> fanout = match ; refcount_set ( & match -> sk_ref , refcount_read ( & match -> sk_ref ) + 1 ) ; __fanout_link ( sk , po ) ; err = 0 ; } } out : if ( err && rollover ) { kfree ( rollover ) ; po -> rollover = NULL ; } mutex_unlock ( & fanout_mutex ) ; return err ; } "," err = - EALREADY ; if - EINVAL ; spin_lock ( & po -> bind_lock ) ; if ( po -> running && match -> type ; } } spin_unlock ( & po -> bind_lock ) ; if ( err && ! refcount_read ( & match -> sk_ref ) ) { list_del ( & match -> list ) ; kfree ( match ) ; } ",torvalds@linux/008ba2a13f2d04c947adc536d19debb8fe66f110,CVE-2017-15649,https://github.com/torvalds/linux/commit/008ba2a13f2d04c947adc536d19debb8fe66f110,2017-10-19T22:29Z 1424,CWE-400,"CWE-400 static void perf_output_wakeup ( struct perf_output_handle * handle ) { atomic_set ( & handle -> rb -> poll , POLL_IN ) ; if ( handle -> nmi ) { handle -> event -> pending_wakeup = 1 ; irq_work_queue ( & handle -> event -> pending ) ; } else perf_event_wakeup ( handle -> event ) ; } "," POLL_IN ) ; handle -> event ) ; } ",torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,CVE-2011-2918,https://github.com/torvalds/linux/commit/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,2012-05-24T23:55Z 1425,CWE-119,"CWE-119 int utf8s_to_utf16s ( const u8 * s , int len , wchar_t * pwcs ) { u16 * op ; int size ; unicode_t u ; op = pwcs ; while ( * s && len > 0 ) { if ( * s & 0x80 ) { size = utf8_to_utf32 ( s , len , & u ) ; if ( size < 0 ) return - EINVAL ; if ( u >= PLANE_SIZE ) { u -= PLANE_SIZE ; * op ++ = ( wchar_t ) ( SURROGATE_PAIR | ( ( u >> 10 ) & SURROGATE_BITS ) ) ; * op ++ = ( wchar_t ) ( SURROGATE_PAIR | SURROGATE_LOW | ( u & SURROGATE_BITS ) ) ; } else { * op ++ = ( wchar_t ) u ; } s += size ; len -= size ; } else { * op ++ = * s ++ ; len -- ; } } return op - pwcs ; } "," int len , enum utf16_endian endian , wchar_t * pwcs , int maxlen ; while ( len > 0 len > 0 && maxlen > 0 && * s - EINVAL ; s += size ; len -= size ; PLANE_SIZE ) { if ( maxlen < 2 ) break ; -= PLANE_SIZE ; put_utf16 ( op ++ , SURROGATE_PAIR | ( & SURROGATE_BITS ) , endian ) ; put_utf16 ( op ++ , SURROGATE_PAIR | SURROGATE_LOW & SURROGATE_BITS ) , endian ) ; maxlen -= 2 ; } else } else { put_utf16 ( op ++ , u , endian ) ; maxlen -- ; } } else { } else { put_utf16 ( op ++ , * s ++ , endian ) ; len -- ; maxlen -- ; } ",torvalds@linux/0720a06a7518c9d0c0125bd5d1f3b6264c55c3dd,CVE-2013-1773,https://github.com/torvalds/linux/commit/0720a06a7518c9d0c0125bd5d1f3b6264c55c3dd,2013-02-28T19:55Z 1426,CWE-787,"CWE-787 static int decode_trns_chunk ( AVCodecContext * avctx , PNGDecContext * s , uint32_t length ) { int v , i ; if ( s -> color_type == PNG_COLOR_TYPE_PALETTE ) { if ( length > 256 || ! ( s -> state & PNG_PLTE ) ) return AVERROR_INVALIDDATA ; for ( i = 0 ; i < length ; i ++ ) { v = bytestream2_get_byte ( & s -> gb ) ; s -> palette [ i ] = ( s -> palette [ i ] & 0x00ffffff ) | ( v << 24 ) ; } } else if ( s -> color_type == PNG_COLOR_TYPE_GRAY || s -> color_type == PNG_COLOR_TYPE_RGB ) { if ( ( s -> color_type == PNG_COLOR_TYPE_GRAY && length != 2 ) || ( s -> color_type == PNG_COLOR_TYPE_RGB && length != 6 ) ) return AVERROR_INVALIDDATA ; for ( i = 0 ; i < length / 2 ; i ++ ) { v = av_mod_uintp2 ( bytestream2_get_be16 ( & s -> gb ) , s -> bit_depth ) ; if ( s -> bit_depth > 8 ) AV_WB16 ( & s -> transparent_color_be [ 2 * i ] , v ) ; else s -> transparent_color_be [ i ] = v ; } } else { return AVERROR_INVALIDDATA ; } bytestream2_skip ( & s -> gb , 4 ) ; s -> has_trns = 1 ; return 0 ; } "," , i ; if ( ! ( s -> state & PNG_IHDR ) ) { av_log ( avctx , AV_LOG_ERROR , ""trnsbeforeIHDR\\n"" ) ; return AVERROR_INVALIDDATA ; } if ( s -> state & PNG_IDAT ) { av_log ( avctx , AV_LOG_ERROR , ""trnsafterIDAT\\n"" ) ; return AVERROR_INVALIDDATA ; } != 6 ) || s -> bit_depth == 1 ",FFmpeg@FFmpeg/e477f09d0b3619f3d29173b2cd593e17e2d1978e,CVE-2017-7863,https://github.com/FFmpeg/FFmpeg/commit/e477f09d0b3619f3d29173b2cd593e17e2d1978e,2017-04-14T04:59Z 1427,CWE-399,"CWE-399 int cib_connect ( gboolean full ) { int rc = pcmk_ok ; static gboolean need_pass = TRUE ; CRM_CHECK ( cib != NULL , return - EINVAL ) ; if ( getenv ( ""CIB_passwd"" ) != NULL ) { need_pass = FALSE ; } if ( watch_fencing && st == NULL ) { st = stonith_api_new ( ) ; } if ( watch_fencing && st -> state == stonith_disconnected ) { crm_trace ( ""Connectingtostonith"" ) ; rc = st -> cmds -> connect ( st , crm_system_name , NULL ) ; if ( rc == pcmk_ok ) { crm_trace ( ""Settingupstonithcallbacks"" ) ; st -> cmds -> register_notification ( st , T_STONITH_NOTIFY_FENCE , mon_st_callback ) ; } } if ( cib -> state != cib_connected_query && cib -> state != cib_connected_command ) { crm_trace ( ""ConnectingtotheCIB"" ) ; if ( as_console && need_pass && cib -> variant == cib_remote ) { need_pass = FALSE ; print_as ( ""Password:"" ) ; } rc = cib -> cmds -> signon ( cib , crm_system_name , cib_query ) ; if ( rc != pcmk_ok ) { return rc ; } current_cib = get_cib_copy ( cib ) ; mon_refresh_display ( NULL ) ; if ( full ) { if ( rc == pcmk_ok ) { rc = cib -> cmds -> set_connection_dnotify ( cib , mon_cib_connection_destroy ) ; if ( rc == - EPROTONOSUPPORT ) { print_as ( ""Notificationsetupfailed,won\'tbeabletoreconnectafterfailure"" ) ; if ( as_console ) { sleep ( 2 ) ; } rc = pcmk_ok ; } } if ( rc == pcmk_ok ) { cib -> cmds -> del_notify_callback ( cib , T_CIB_DIFF_NOTIFY , crm_diff_update ) ; rc = cib -> cmds -> add_notify_callback ( cib , T_CIB_DIFF_NOTIFY , crm_diff_update ) ; } if ( rc != pcmk_ok ) { print_as ( ""Notificationsetupfailed,couldnotmonitorCIBactions"" ) ; if ( as_console ) { sleep ( 2 ) ; } clean_up ( - rc ) ; } } } return rc ; } "," { print_as ( ""Notificationsetupnotsupported,won\'tbeabletoreconnectafterfailure"" ) ; if ",ClusterLabs@pacemaker/564f7cc2a51dcd2f28ab12a13394f31be5aa3c93,CVE-2013-0281,https://github.com/ClusterLabs/pacemaker/commit/564f7cc2a51dcd2f28ab12a13394f31be5aa3c93,2013-11-23T11:55Z 1428,CWE-358,"CWE-358 static void DefragTrackerInit ( DefragTracker * dt , Packet * p ) { COPY_ADDRESS ( & p -> src , & dt -> src_addr ) ; COPY_ADDRESS ( & p -> dst , & dt -> dst_addr ) ; if ( PKT_IS_IPV4 ( p ) ) { dt -> id = ( int32_t ) IPV4_GET_IPID ( p ) ; dt -> af = AF_INET ; } else { dt -> id = ( int32_t ) IPV6_EXTHDR_GET_FH_ID ( p ) ; dt -> af = AF_INET6 ; } dt -> vlan_id [ 0 ] = p -> vlan_id [ 0 ] ; dt -> vlan_id [ 1 ] = p -> vlan_id [ 1 ] ; dt -> policy = DefragGetOsPolicy ( p ) ; dt -> host_timeout = DefragPolicyGetHostTimeout ( p ) ; dt -> remove = 0 ; dt -> seen_last = 0 ; TAILQ_INIT ( & dt -> frags ) ; ( void ) DefragTrackerIncrUsecnt ( dt ) ; } "," } dt -> proto = IP_GET_IPPROTO ( p ) ; dt -> ",inliniac@suricata/4a04f814b15762eb446a5ead4d69d021512df6f8,CVE-2017-7177,https://github.com/inliniac/suricata/commit/4a04f814b15762eb446a5ead4d69d021512df6f8,2017-03-18T20:59Z 1429,CWE-20,"CWE-20 error_t ksz8851ReceivePacket ( NetInterface * interface ) { size_t n ; uint16_t status ; Ksz8851Context * context ; NetRxAncillary ancillary ; context = ( Ksz8851Context * ) interface -> nicContext ; status = ksz8851ReadReg ( interface , KSZ8851_REG_RXFHSR ) ; if ( ( status & RXFHSR_RXFV ) != 0 ) { if ( ( status & ( RXFHSR_RXMR | RXFHSR_RXFTL | RXFHSR_RXRF | RXFHSR_RXCE ) ) == 0 ) { n = ksz8851ReadReg ( interface , KSZ8851_REG_RXFHBCR ) & RXFHBCR_RXBC_MASK ; if ( n > 0 && n <= ETH_MAX_FRAME_SIZE ) { ksz8851WriteReg ( interface , KSZ8851_REG_RXFDPR , RXFDPR_RXFPAI ) ; ksz8851SetBit ( interface , KSZ8851_REG_RXQCR , RXQCR_SDA ) ; ksz8851ReadFifo ( interface , context -> rxBuffer , n ) ; ksz8851ClearBit ( interface , KSZ8851_REG_RXQCR , RXQCR_SDA ) ; ancillary = NET_DEFAULT_RX_ANCILLARY ; nicProcessPacket ( interface , context -> rxBuffer , n , & ancillary ) ; return NO_ERROR ; } } } ksz8851SetBit ( interface , KSZ8851_REG_RXQCR , RXQCR_RRXEF ) ; return ERROR_INVALID_PACKET ; } "," ( interface , KSZ8851_RXFHSR ) ; if ( status & KSZ8851_RXFHSR_RXFV ) != 0 status & ( KSZ8851_RXFHSR_RXMR | KSZ8851_RXFHSR_RXFTL | KSZ8851_RXFHSR_RXRF | KSZ8851_RXFHSR_RXCE ) ) == ( interface , KSZ8851_RXFHBCR ) & KSZ8851_RXFHBCR_RXBC ; if ( ( interface , KSZ8851_RXFDPR , KSZ8851_RXFDPR_RXFPAI ) ; ksz8851SetBit ( interface , KSZ8851_RXQCR , KSZ8851_RXQCR_SDA ) ; ksz8851ReadFifo ( interface , KSZ8851_RXQCR , KSZ8851_RXQCR_SDA ) ; ancillary ( interface , KSZ8851_RXQCR , KSZ8851_RXQCR_RRXEF ) ; return ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 1430,CWE-125,"CWE-125 static stmt_ty ast_for_funcdef_impl ( struct compiling * c , const node * n , asdl_seq * decorator_seq , int is_async ) { identifier name ; arguments_ty args ; asdl_seq * body ; expr_ty returns = NULL ; int name_i = 1 ; node * tc ; string type_comment = NULL ; if ( is_async && c -> c_feature_version < 5 ) { ast_error ( c , n , ""AsyncfunctionsareonlysupportedinPython3.5andgreater"" ) ; return NULL ; } REQ ( n , funcdef ) ; name = NEW_IDENTIFIER ( CHILD ( n , name_i ) ) ; if ( ! name ) return NULL ; if ( forbidden_name ( c , name , CHILD ( n , name_i ) , 0 ) ) return NULL ; args = ast_for_arguments ( c , CHILD ( n , name_i + 1 ) ) ; if ( ! args ) return NULL ; if ( TYPE ( CHILD ( n , name_i + 2 ) ) == RARROW ) { returns = ast_for_expr ( c , CHILD ( n , name_i + 3 ) ) ; if ( ! returns ) return NULL ; name_i += 2 ; } if ( TYPE ( CHILD ( n , name_i + 3 ) ) == TYPE_COMMENT ) { type_comment = NEW_TYPE_COMMENT ( CHILD ( n , name_i + 3 ) ) ; name_i += 1 ; } body = ast_for_suite ( c , CHILD ( n , name_i + 3 ) ) ; if ( ! body ) return NULL ; if ( ! type_comment && NCH ( CHILD ( n , name_i + 3 ) ) > 1 ) { tc = CHILD ( CHILD ( n , name_i + 3 ) , 1 ) ; if ( TYPE ( tc ) == TYPE_COMMENT ) type_comment = NEW_TYPE_COMMENT ( tc ) ; } if ( is_async ) return AsyncFunctionDef ( name , args , body , decorator_seq , returns , type_comment , LINENO ( n ) , n -> n_col_offset , c -> c_arena ) ; else return FunctionDef ( name , args , body , decorator_seq , returns , type_comment , LINENO ( n ) , n -> n_col_offset , c -> c_arena ) ; } "," const node * n0 , asdl_seq * * decorator_seq , bool is_async ) { is_async ) { const node * const n = is_async ? CHILD ( n0 , 1 ) : n0 ; , LINENO ( n0 ) , n0 -> n_col_offset , ",python@typed_ast/156afcb26c198e162504a57caddfe0acd9ed7dce,CVE-2019-19275,https://github.com/python/typed_ast/commit/156afcb26c198e162504a57caddfe0acd9ed7dce,2019-11-26T15:15Z 1431,CWE-264,"CWE-264 static void mark_screen_rdonly ( struct mm_struct * mm ) { pgd_t * pgd ; pud_t * pud ; pmd_t * pmd ; pte_t * pte ; spinlock_t * ptl ; int i ; pgd = pgd_offset ( mm , 0xA0000 ) ; if ( pgd_none_or_clear_bad ( pgd ) ) goto out ; pud = pud_offset ( pgd , 0xA0000 ) ; if ( pud_none_or_clear_bad ( pud ) ) goto out ; pmd = pmd_offset ( pud , 0xA0000 ) ; split_huge_page_pmd ( mm , pmd ) ; if ( pmd_none_or_clear_bad ( pmd ) ) goto out ; pte = pte_offset_map_lock ( mm , pmd , 0xA0000 , & ptl ) ; for ( i = 0 ; i < 32 ; i ++ ) { if ( pte_present ( * pte ) ) set_pte ( pte , pte_wrprotect ( * pte ) ) ; pte ++ ; } pte_unmap_unlock ( pte , ptl ) ; out : flush_tlb ( ) ; } "," int i ; down_write ( & mm -> mmap_sem ) ; ; out : up_write ( & mm -> mmap_sem ) ; ",torvalds@linux/4a1d704194a441bf83c636004a479e01360ec850,CVE-2012-1179,https://github.com/torvalds/linux/commit/4a1d704194a441bf83c636004a479e01360ec850,2012-05-17T11:00Z 1432,CWE-20,"CWE-20 static int apparmor_setprocattr ( struct task_struct * task , char * name , void * value , size_t size ) { char * command , * args = value ; size_t arg_size ; int error ; if ( size == 0 ) return - EINVAL ; if ( args [ size - 1 ] != '\\0' ) { if ( size == PAGE_SIZE ) return - EINVAL ; args [ size ] = '\\0' ; } if ( current != task ) return - EACCES ; args = value ; args = strim ( args ) ; command = strsep ( & args , """" ) ; if ( ! args ) return - EINVAL ; args = skip_spaces ( args ) ; if ( ! * args ) return - EINVAL ; arg_size = size - ( args - ( char * ) value ) ; if ( strcmp ( name , ""current"" ) == 0 ) { if ( strcmp ( command , ""changehat"" ) == 0 ) { error = aa_setprocattr_changehat ( args , arg_size , ! AA_DO_TEST ) ; } else if ( strcmp ( command , ""permhat"" ) == 0 ) { error = aa_setprocattr_changehat ( args , arg_size , AA_DO_TEST ) ; } else if ( strcmp ( command , ""changeprofile"" ) == 0 ) { error = aa_setprocattr_changeprofile ( args , ! AA_ONEXEC , ! AA_DO_TEST ) ; } else if ( strcmp ( command , ""permprofile"" ) == 0 ) { error = aa_setprocattr_changeprofile ( args , ! AA_ONEXEC , AA_DO_TEST ) ; } else if ( strcmp ( command , ""permipc"" ) == 0 ) { error = aa_setprocattr_permipc ( args ) ; } else { struct common_audit_data sa ; COMMON_AUDIT_DATA_INIT ( & sa , NONE ) ; sa . aad . op = OP_SETPROCATTR ; sa . aad . info = name ; sa . aad . error = - EINVAL ; return aa_audit ( AUDIT_APPARMOR_DENIED , NULL , GFP_KERNEL , & sa , NULL ) ; } } else if ( strcmp ( name , ""exec"" ) == 0 ) { error = aa_setprocattr_changeprofile ( args , AA_ONEXEC , ! AA_DO_TEST ) ; } else { return - EINVAL ; } if ( ! error ) error = size ; return error ; } "," ( AUDIT_APPARMOR_DENIED , __aa_current_profile ( ) , GFP_KERNEL , & sa , NULL ) ; } ",torvalds@linux/a5b2c5b2ad5853591a6cac6134cd0f599a720865,CVE-2011-3619,https://github.com/torvalds/linux/commit/a5b2c5b2ad5853591a6cac6134cd0f599a720865,2013-06-08T13:05Z 1433,CWE-20,"CWE-20 static int jpc_siz_getparms ( jpc_ms_t * ms , jpc_cstate_t * cstate , jas_stream_t * in ) { jpc_siz_t * siz = & ms -> parms . siz ; unsigned int i ; uint_fast8_t tmp ; cstate = 0 ; if ( jpc_getuint16 ( in , & siz -> caps ) || jpc_getuint32 ( in , & siz -> width ) || jpc_getuint32 ( in , & siz -> height ) || jpc_getuint32 ( in , & siz -> xoff ) || jpc_getuint32 ( in , & siz -> yoff ) || jpc_getuint32 ( in , & siz -> tilewidth ) || jpc_getuint32 ( in , & siz -> tileheight ) || jpc_getuint32 ( in , & siz -> tilexoff ) || jpc_getuint32 ( in , & siz -> tileyoff ) || jpc_getuint16 ( in , & siz -> numcomps ) ) { return - 1 ; } if ( ! siz -> width || ! siz -> height || ! siz -> tilewidth || ! siz -> tileheight || ! siz -> numcomps || siz -> numcomps > 16384 ) { return - 1 ; } if ( siz -> tilexoff >= siz -> width || siz -> tileyoff >= siz -> height ) { jas_eprintf ( ""alltilesareoutsidetheimagearea\\n"" ) ; return - 1 ; } if ( ! ( siz -> comps = jas_alloc2 ( siz -> numcomps , sizeof ( jpc_sizcomp_t ) ) ) ) { return - 1 ; } for ( i = 0 ; i < siz -> numcomps ; ++ i ) { if ( jpc_getuint8 ( in , & tmp ) || jpc_getuint8 ( in , & siz -> comps [ i ] . hsamp ) || jpc_getuint8 ( in , & siz -> comps [ i ] . vsamp ) ) { jas_free ( siz -> comps ) ; return - 1 ; } if ( siz -> comps [ i ] . hsamp == 0 || siz -> comps [ i ] . hsamp > 255 ) { jas_eprintf ( ""invalidXRsizvalue%d\\n"" , siz -> comps [ i ] . hsamp ) ; jas_free ( siz -> comps ) ; return - 1 ; } if ( siz -> comps [ i ] . vsamp == 0 || siz -> comps [ i ] . vsamp > 255 ) { jas_eprintf ( ""invalidYRsizvalue%d\\n"" , siz -> comps [ i ] . vsamp ) ; jas_free ( siz -> comps ) ; return - 1 ; } siz -> comps [ i ] . sgnd = ( tmp >> 7 ) & 1 ; siz -> comps [ i ] . prec = ( tmp & 0x7f ) + 1 ; } if ( jas_stream_eof ( in ) ) { jas_free ( siz -> comps ) ; return - 1 ; } return 0 ; } "," uint_fast8_t tmp ; siz -> comps = 0 ; ) ) { goto error ; } if ( ! siz -> width || ! siz -> height ) { jas_eprintf ( ""referencegridcannothavezeroarea\\n"" ) ; goto error ; } if ( ! siz -> tilewidth || ! siz -> tileheight ) { jas_eprintf ( ""tilecannothavezeroarea\\n"" ) ; goto error ; } if ( ! siz -> numcomps || siz -> numcomps > 16384 ) { jas_eprintf ( ""numberofcomponentsnotinpermissiblerange\\n"" ) ; goto error ; } if ( siz -> xoff >= siz -> width ) { jas_eprintf ( ""XOsiznotinpermissiblerange\\n"" ) ; goto error ; } if ( siz -> yoff >= siz -> height ) { jas_eprintf ( ""YOsiznotinpermissiblerange\\n"" ) ; goto error ; } if ( siz -> tilexoff > siz -> xoff || siz -> tilexoff + siz -> tilewidth <= siz -> xoff ) { jas_eprintf ( ""XTOsiznotinpermissiblerange\\n"" ) ; goto error ; } if ( siz -> tileyoff > siz -> yoff || siz -> tileyoff + siz -> tileheight <= siz -> yoff ) { jas_eprintf ( ""YTOsiznotinpermissiblerange\\n"" ) ; goto error ; } if ( ! ( siz -> comps = jas_alloc2 ( siz -> numcomps , sizeof ( jpc_sizcomp_t ) ) ) ) { goto error ; } for ( i = 0 ; i < siz -> numcomps ; ++ i ) { if ( jpc_getuint8 ( in , & tmp ) || jpc_getuint8 ( in , & siz -> comps [ i ] . hsamp ) || jpc_getuint8 ( in , & siz -> comps [ i ] . vsamp ) ) { goto error ; } if ( siz -> comps [ i ] . hsamp == 0 || siz -> comps [ i ] . hsamp > 255 ) { jas_eprintf ( ""invalidXRsizvalue%d\\n"" , siz -> comps [ i ] . hsamp ) ; goto error ; } if ( siz -> comps [ i ] . vsamp == 0 || siz -> comps [ i ] . vsamp > 255 ) { jas_eprintf ( ""invalidYRsizvalue%d\\n"" , siz -> comps [ i ] . vsamp ) ; goto error ; } siz -> comps [ i ] . sgnd = ( tmp >> 7 ) & 1 ; siz -> comps [ i ] . prec = ( tmp & 0x7f ) + 1 ; } if ( jas_stream_eof ( in ) ) { goto error ; } return 0 ; error : if ( siz -> comps ) { jas_free ( siz -> comps ) ; } 1 ; } ",mdadams@jasper/f7038068550fba0e41e1d0c355787f1dcd5bf330,CVE-2016-9394,https://github.com/mdadams/jasper/commit/f7038068550fba0e41e1d0c355787f1dcd5bf330,2017-03-23T18:59Z 1434,CWE-401,"CWE-401 static int8_t sn_coap_parser_options_parse ( struct coap_s * handle , uint8_t * * packet_data_pptr , sn_coap_hdr_s * dst_coap_msg_ptr , uint8_t * packet_data_start_ptr , uint16_t packet_len ) { uint8_t previous_option_number = 0 ; int8_t ret_status = 0 ; uint16_t message_left = sn_coap_parser_move_packet_ptr ( packet_data_pptr , packet_data_start_ptr , packet_len , 0 ) ; dst_coap_msg_ptr -> token_len = * packet_data_start_ptr & COAP_HEADER_TOKEN_LENGTH_MASK ; if ( dst_coap_msg_ptr -> token_len ) { int8_t ptr_check_result ; if ( ( dst_coap_msg_ptr -> token_len > 8 ) || dst_coap_msg_ptr -> token_ptr ) { tr_error ( ""sn_coap_parser_options_parse-tokennotvalid!"" ) ; return - 1 ; } ptr_check_result = sn_coap_parser_check_packet_ptr ( * packet_data_pptr , packet_data_start_ptr , packet_len , dst_coap_msg_ptr -> token_len ) ; if ( 0 != ptr_check_result ) { tr_error ( ""sn_coap_parser_options_parse-**packet_data_pptroverflow!"" ) ; return - 1 ; } dst_coap_msg_ptr -> token_ptr = sn_coap_protocol_malloc_copy ( handle , * packet_data_pptr , dst_coap_msg_ptr -> token_len ) ; if ( dst_coap_msg_ptr -> token_ptr == NULL ) { tr_error ( ""sn_coap_parser_options_parse-failedtoallocatetoken!"" ) ; return - 1 ; } message_left = sn_coap_parser_move_packet_ptr ( packet_data_pptr , packet_data_start_ptr , packet_len , dst_coap_msg_ptr -> token_len ) ; } while ( message_left && ( * * packet_data_pptr != 0xff ) ) { uint16_t option_len = ( * * packet_data_pptr & 0x0F ) ; uint16_t option_number = ( * * packet_data_pptr >> COAP_OPTIONS_OPTION_NUMBER_SHIFT ) ; message_left = sn_coap_parser_move_packet_ptr ( packet_data_pptr , packet_data_start_ptr , packet_len , 1 ) ; int8_t option_parse_result ; option_parse_result = parse_ext_option ( & option_number , packet_data_pptr , packet_data_start_ptr , packet_len , & message_left ) ; if ( option_parse_result != 0 ) { return - 1 ; } option_number += previous_option_number ; option_parse_result = parse_ext_option ( & option_len , packet_data_pptr , packet_data_start_ptr , packet_len , & message_left ) ; if ( option_parse_result != 0 ) { return - 1 ; } previous_option_number = option_number ; switch ( option_number ) { case COAP_OPTION_MAX_AGE : case COAP_OPTION_PROXY_URI : case COAP_OPTION_ETAG : case COAP_OPTION_URI_HOST : case COAP_OPTION_LOCATION_PATH : case COAP_OPTION_URI_PORT : case COAP_OPTION_LOCATION_QUERY : case COAP_OPTION_OBSERVE : case COAP_OPTION_URI_QUERY : case COAP_OPTION_BLOCK2 : case COAP_OPTION_BLOCK1 : case COAP_OPTION_ACCEPT : case COAP_OPTION_SIZE1 : case COAP_OPTION_SIZE2 : if ( sn_coap_parser_alloc_options ( handle , dst_coap_msg_ptr ) == NULL ) { tr_error ( ""sn_coap_parser_options_parse-failedtoallocateoptions!"" ) ; return - 1 ; } break ; } if ( message_left < option_len ) { tr_error ( ""sn_coap_parser_options_parse-**packet_data_pptrwouldoverflowwhenparsingoptions!"" ) ; return - 1 ; } switch ( option_number ) { case COAP_OPTION_CONTENT_FORMAT : if ( ( option_len > 2 ) || ( dst_coap_msg_ptr -> content_format != COAP_CT_NONE ) ) { tr_error ( ""sn_coap_parser_options_parse-COAP_OPTION_CONTENT_FORMATnotvalid!"" ) ; return - 1 ; } dst_coap_msg_ptr -> content_format = ( sn_coap_content_format_e ) sn_coap_parser_options_parse_uint ( packet_data_pptr , option_len ) ; break ; case COAP_OPTION_MAX_AGE : if ( option_len > 4 ) { tr_error ( ""sn_coap_parser_options_parse-COAP_OPTION_MAX_AGEnotvalid!"" ) ; return - 1 ; } dst_coap_msg_ptr -> options_list_ptr -> max_age = sn_coap_parser_options_parse_uint ( packet_data_pptr , option_len ) ; break ; case COAP_OPTION_PROXY_URI : if ( ( option_len > 1034 ) || ( option_len < 1 ) || dst_coap_msg_ptr -> options_list_ptr -> proxy_uri_ptr ) { tr_error ( ""sn_coap_parser_options_parse-COAP_OPTION_PROXY_URInotvalid!"" ) ; return - 1 ; } dst_coap_msg_ptr -> options_list_ptr -> proxy_uri_len = option_len ; dst_coap_msg_ptr -> options_list_ptr -> proxy_uri_ptr = sn_coap_protocol_malloc_copy ( handle , * packet_data_pptr , option_len ) ; if ( dst_coap_msg_ptr -> options_list_ptr -> proxy_uri_ptr == NULL ) { tr_error ( ""sn_coap_parser_options_parse-COAP_OPTION_PROXY_URIallocationfailed!"" ) ; return - 1 ; } message_left = sn_coap_parser_move_packet_ptr ( packet_data_pptr , packet_data_start_ptr , packet_len , option_len ) ; break ; case COAP_OPTION_ETAG : ret_status = sn_coap_parser_options_parse_multiple_options ( handle , packet_data_pptr , message_left , & dst_coap_msg_ptr -> options_list_ptr -> etag_ptr , ( uint16_t * ) & dst_coap_msg_ptr -> options_list_ptr -> etag_len , COAP_OPTION_ETAG , option_len ) ; if ( ret_status < 0 ) { tr_error ( ""sn_coap_parser_options_parse-COAP_OPTION_ETAGnotvalid!"" ) ; return - 1 ; } break ; case COAP_OPTION_URI_HOST : if ( ( option_len > 255 ) || ( option_len < 1 ) || dst_coap_msg_ptr -> options_list_ptr -> uri_host_ptr ) { tr_error ( ""sn_coap_parser_options_parse-COAP_OPTION_URI_HOSTnotvalid!"" ) ; return - 1 ; } dst_coap_msg_ptr -> options_list_ptr -> uri_host_len = option_len ; dst_coap_msg_ptr -> options_list_ptr -> uri_host_ptr = sn_coap_protocol_malloc_copy ( handle , * packet_data_pptr , option_len ) ; if ( dst_coap_msg_ptr -> options_list_ptr -> uri_host_ptr == NULL ) { tr_error ( ""sn_coap_parser_options_parse-COAP_OPTION_URI_HOSTallocationfailed!"" ) ; return - 1 ; } message_left = sn_coap_parser_move_packet_ptr ( packet_data_pptr , packet_data_start_ptr , packet_len , option_len ) ; break ; case COAP_OPTION_LOCATION_PATH : if ( dst_coap_msg_ptr -> options_list_ptr -> location_path_ptr ) { tr_error ( ""sn_coap_parser_options_parse-COAP_OPTION_LOCATION_PATHexists!"" ) ; return - 1 ; } ret_status = sn_coap_parser_options_parse_multiple_options ( handle , packet_data_pptr , message_left , & dst_coap_msg_ptr -> options_list_ptr -> location_path_ptr , & dst_coap_msg_ptr -> options_list_ptr -> location_path_len , COAP_OPTION_LOCATION_PATH , option_len ) ; if ( ret_status < 0 ) { tr_error ( ""sn_coap_parser_options_parse-COAP_OPTION_LOCATION_PATHnotvalid!"" ) ; return - 1 ; } break ; case COAP_OPTION_URI_PORT : if ( ( option_len > 2 ) || dst_coap_msg_ptr -> options_list_ptr -> uri_port != COAP_OPTION_URI_PORT_NONE ) { tr_error ( ""sn_coap_parser_options_parse-COAP_OPTION_URI_PORTnotvalid!"" ) ; return - 1 ; } dst_coap_msg_ptr -> options_list_ptr -> uri_port = sn_coap_parser_options_parse_uint ( packet_data_pptr , option_len ) ; break ; case COAP_OPTION_LOCATION_QUERY : ret_status = sn_coap_parser_options_parse_multiple_options ( handle , packet_data_pptr , message_left , & dst_coap_msg_ptr -> options_list_ptr -> location_query_ptr , & dst_coap_msg_ptr -> options_list_ptr -> location_query_len , COAP_OPTION_LOCATION_QUERY , option_len ) ; if ( ret_status < 0 ) { tr_error ( ""sn_coap_parser_options_parse-COAP_OPTION_LOCATION_QUERYnotvalid!"" ) ; return - 1 ; } break ; case COAP_OPTION_URI_PATH : ret_status = sn_coap_parser_options_parse_multiple_options ( handle , packet_data_pptr , message_left , & dst_coap_msg_ptr -> uri_path_ptr , & dst_coap_msg_ptr -> uri_path_len , COAP_OPTION_URI_PATH , option_len ) ; if ( ret_status < 0 ) { tr_error ( ""sn_coap_parser_options_parse-COAP_OPTION_URI_PATHnotvalid!"" ) ; return - 1 ; } break ; case COAP_OPTION_OBSERVE : if ( ( option_len > 2 ) || dst_coap_msg_ptr -> options_list_ptr -> observe != COAP_OBSERVE_NONE ) { tr_error ( ""sn_coap_parser_options_parse-COAP_OPTION_OBSERVEnotvalid!"" ) ; return - 1 ; } dst_coap_msg_ptr -> options_list_ptr -> observe = sn_coap_parser_options_parse_uint ( packet_data_pptr , option_len ) ; break ; case COAP_OPTION_URI_QUERY : ret_status = sn_coap_parser_options_parse_multiple_options ( handle , packet_data_pptr , message_left , & dst_coap_msg_ptr -> options_list_ptr -> uri_query_ptr , & dst_coap_msg_ptr -> options_list_ptr -> uri_query_len , COAP_OPTION_URI_QUERY , option_len ) ; if ( ret_status < 0 ) { tr_error ( ""sn_coap_parser_options_parse-COAP_OPTION_URI_QUERYnotvalid!"" ) ; return - 1 ; } break ; case COAP_OPTION_BLOCK2 : if ( ( option_len > 3 ) || dst_coap_msg_ptr -> options_list_ptr -> block2 != COAP_OPTION_BLOCK_NONE ) { tr_error ( ""sn_coap_parser_options_parse-COAP_OPTION_BLOCK2notvalid!"" ) ; return - 1 ; } dst_coap_msg_ptr -> options_list_ptr -> block2 = sn_coap_parser_options_parse_uint ( packet_data_pptr , option_len ) ; break ; case COAP_OPTION_BLOCK1 : if ( ( option_len > 3 ) || dst_coap_msg_ptr -> options_list_ptr -> block1 != COAP_OPTION_BLOCK_NONE ) { tr_error ( ""sn_coap_parser_options_parse-COAP_OPTION_BLOCK1notvalid!"" ) ; return - 1 ; } dst_coap_msg_ptr -> options_list_ptr -> block1 = sn_coap_parser_options_parse_uint ( packet_data_pptr , option_len ) ; break ; case COAP_OPTION_ACCEPT : if ( ( option_len > 2 ) || ( dst_coap_msg_ptr -> options_list_ptr -> accept != COAP_CT_NONE ) ) { tr_error ( ""sn_coap_parser_options_parse-COAP_OPTION_ACCEPTnotvalid!"" ) ; return - 1 ; } dst_coap_msg_ptr -> options_list_ptr -> accept = ( sn_coap_content_format_e ) sn_coap_parser_options_parse_uint ( packet_data_pptr , option_len ) ; break ; case COAP_OPTION_SIZE1 : if ( ( option_len > 4 ) || dst_coap_msg_ptr -> options_list_ptr -> use_size1 ) { tr_error ( ""sn_coap_parser_options_parse-COAP_OPTION_SIZE1notvalid!"" ) ; return - 1 ; } dst_coap_msg_ptr -> options_list_ptr -> use_size1 = true ; dst_coap_msg_ptr -> options_list_ptr -> size1 = sn_coap_parser_options_parse_uint ( packet_data_pptr , option_len ) ; break ; case COAP_OPTION_SIZE2 : if ( ( option_len > 4 ) || dst_coap_msg_ptr -> options_list_ptr -> use_size2 ) { tr_error ( ""sn_coap_parser_options_parse-COAP_OPTION_SIZE2notvalid!"" ) ; return - 1 ; } dst_coap_msg_ptr -> options_list_ptr -> use_size2 = true ; dst_coap_msg_ptr -> options_list_ptr -> size2 = sn_coap_parser_options_parse_uint ( packet_data_pptr , option_len ) ; break ; default : tr_error ( ""sn_coap_parser_options_parse-unknownoption!"" ) ; return - 1 ; } if ( ( * packet_data_pptr - packet_data_start_ptr ) > packet_len ) { return - 1 ; } message_left = sn_coap_parser_move_packet_ptr ( packet_data_pptr , packet_data_start_ptr , packet_len , 0 ) ; } return 0 ; } "," 1 ; } if ( sn_coap_parser_add_u16_limit ( option_number , previous_option_number , & option_number ) != 0 ) { return - 1 ; } option_parse_result = parse_ext_option case COAP_OPTION_ETAG : if ( dst_coap_msg_ptr -> options_list_ptr -> etag_ptr ) { tr_error ( ""sn_coap_parser_options_parse-COAP_OPTION_ETAGexists!"" ) ; return - 1 ; } case COAP_OPTION_LOCATION_QUERY : if ( dst_coap_msg_ptr -> options_list_ptr -> location_query_ptr ) { tr_error ( ""sn_coap_parser_options_parse-COAP_OPTION_LOCATION_QUERYexists!"" ) ; return - 1 ; } case COAP_OPTION_URI_PATH : if ( dst_coap_msg_ptr -> uri_path_ptr ) { tr_error ( ""sn_coap_parser_options_parse-COAP_OPTION_URI_PATHexists!"" ) ; return - 1 ; } ",mjurczak@mbed-coap/4647a68e364401e81dbd370728127d844f221d93,CVE-2020-12887,https://github.com/mjurczak/mbed-coap/commit/4647a68e364401e81dbd370728127d844f221d93,2020-06-18T19:15Z 1435,CWE-125,"CWE-125 struct _mdi * _WM_ParseNewXmi ( uint8_t * xmi_data , uint32_t xmi_size ) { struct _mdi * xmi_mdi = NULL ; uint32_t xmi_tmpdata = 0 ; uint8_t xmi_formcnt = 0 ; uint32_t xmi_catlen = 0 ; uint32_t xmi_subformlen = 0 ; uint32_t i = 0 ; uint32_t j = 0 ; uint32_t xmi_evntlen = 0 ; uint32_t xmi_divisions = 60 ; uint32_t xmi_tempo = 500000 ; uint32_t xmi_sample_count = 0 ; float xmi_sample_count_f = 0.0 ; float xmi_sample_remainder = 0.0 ; float xmi_samples_per_delta_f = 0.0 ; uint8_t xmi_ch = 0 ; uint8_t xmi_note = 0 ; uint32_t * xmi_notelen = NULL ; uint32_t setup_ret = 0 ; uint32_t xmi_delta = 0 ; uint32_t xmi_lowestdelta = 0 ; uint32_t xmi_evnt_cnt = 0 ; if ( memcmp ( xmi_data , ""FORM"" , 4 ) ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_NOT_XMI , NULL , 0 ) ; return NULL ; } xmi_data += 4 ; xmi_size -= 4 ; xmi_tmpdata = * xmi_data ++ << 24 ; xmi_tmpdata |= * xmi_data ++ << 16 ; xmi_tmpdata |= * xmi_data ++ << 8 ; xmi_tmpdata |= * xmi_data ++ ; xmi_size -= 4 ; if ( memcmp ( xmi_data , ""XDIRINFO"" , 8 ) ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_NOT_XMI , NULL , 0 ) ; return NULL ; } xmi_data += 8 ; xmi_size -= 8 ; xmi_data += 4 ; xmi_size -= 4 ; xmi_formcnt = * xmi_data ++ ; if ( xmi_formcnt == 0 ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_NOT_XMI , NULL , 0 ) ; return NULL ; } xmi_size -- ; xmi_tmpdata -= 13 ; xmi_data += xmi_tmpdata ; xmi_size -= xmi_tmpdata ; if ( memcmp ( xmi_data , ""CAT"" , 4 ) ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_NOT_XMI , NULL , 0 ) ; return NULL ; } xmi_data += 4 ; xmi_size -= 4 ; xmi_catlen = * xmi_data ++ << 24 ; xmi_catlen |= * xmi_data ++ << 16 ; xmi_catlen |= * xmi_data ++ << 8 ; xmi_catlen |= * xmi_data ++ ; xmi_size -= 4 ; UNUSED ( xmi_catlen ) ; if ( memcmp ( xmi_data , ""XMID"" , 4 ) ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_NOT_XMI , NULL , 0 ) ; return NULL ; } xmi_data += 4 ; xmi_size -= 4 ; xmi_mdi = _WM_initMDI ( ) ; _WM_midi_setup_divisions ( xmi_mdi , xmi_divisions ) ; _WM_midi_setup_tempo ( xmi_mdi , xmi_tempo ) ; xmi_samples_per_delta_f = _WM_GetSamplesPerTick ( xmi_divisions , xmi_tempo ) ; xmi_notelen = malloc ( sizeof ( uint32_t ) * 16 * 128 ) ; memset ( xmi_notelen , 0 , ( sizeof ( uint32_t ) * 16 * 128 ) ) ; for ( i = 0 ; i < xmi_formcnt ; i ++ ) { if ( memcmp ( xmi_data , ""FORM"" , 4 ) ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_NOT_XMI , NULL , 0 ) ; goto _xmi_end ; } xmi_data += 4 ; xmi_size -= 4 ; xmi_subformlen = * xmi_data ++ << 24 ; xmi_subformlen |= * xmi_data ++ << 16 ; xmi_subformlen |= * xmi_data ++ << 8 ; xmi_subformlen |= * xmi_data ++ ; xmi_size -= 4 ; if ( memcmp ( xmi_data , ""XMID"" , 4 ) ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_NOT_XMI , NULL , 0 ) ; goto _xmi_end ; } xmi_data += 4 ; xmi_size -= 4 ; xmi_subformlen -= 4 ; do { if ( ! memcmp ( xmi_data , ""TIMB"" , 4 ) ) { xmi_data += 4 ; xmi_tmpdata = * xmi_data ++ << 24 ; xmi_tmpdata |= * xmi_data ++ << 16 ; xmi_tmpdata |= * xmi_data ++ << 8 ; xmi_tmpdata |= * xmi_data ++ ; xmi_data += xmi_tmpdata ; xmi_size -= ( 8 + xmi_tmpdata ) ; xmi_subformlen -= ( 8 + xmi_tmpdata ) ; } else if ( ! memcmp ( xmi_data , ""RBRN"" , 4 ) ) { xmi_data += 4 ; xmi_tmpdata = * xmi_data ++ << 24 ; xmi_tmpdata |= * xmi_data ++ << 16 ; xmi_tmpdata |= * xmi_data ++ << 8 ; xmi_tmpdata |= * xmi_data ++ ; xmi_data += xmi_tmpdata ; xmi_size -= ( 8 + xmi_tmpdata ) ; xmi_subformlen -= ( 8 + xmi_tmpdata ) ; } else if ( ! memcmp ( xmi_data , ""EVNT"" , 4 ) ) { xmi_data += 4 ; xmi_evnt_cnt ++ ; xmi_evntlen = * xmi_data ++ << 24 ; xmi_evntlen |= * xmi_data ++ << 16 ; xmi_evntlen |= * xmi_data ++ << 8 ; xmi_evntlen |= * xmi_data ++ ; xmi_size -= 8 ; xmi_subformlen -= 8 ; do { if ( * xmi_data < 0x80 ) { xmi_delta = 0 ; if ( * xmi_data > 0x7f ) { while ( * xmi_data > 0x7f ) { xmi_delta = ( xmi_delta << 7 ) | ( * xmi_data ++ & 0x7f ) ; xmi_size -- ; xmi_evntlen -- ; xmi_subformlen -- ; } } xmi_delta = ( xmi_delta << 7 ) | ( * xmi_data ++ & 0x7f ) ; xmi_size -- ; xmi_evntlen -- ; xmi_subformlen -- ; do { if ( ( xmi_lowestdelta != 0 ) && ( xmi_lowestdelta <= xmi_delta ) ) { xmi_tmpdata = xmi_lowestdelta ; } else { xmi_tmpdata = xmi_delta ; } xmi_sample_count_f = ( ( ( float ) xmi_tmpdata * xmi_samples_per_delta_f ) + xmi_sample_remainder ) ; xmi_sample_count = ( uint32_t ) xmi_sample_count_f ; xmi_sample_remainder = xmi_sample_count_f - ( float ) xmi_sample_count ; xmi_mdi -> events [ xmi_mdi -> event_count - 1 ] . samples_to_next += xmi_sample_count ; xmi_mdi -> extra_info . approx_total_samples += xmi_sample_count ; xmi_lowestdelta = 0 ; for ( j = 0 ; j < ( 16 * 128 ) ; j ++ ) { if ( xmi_notelen [ j ] == 0 ) continue ; xmi_notelen [ j ] -= xmi_tmpdata ; if ( xmi_notelen [ j ] == 0 ) { xmi_ch = j / 128 ; xmi_note = j - ( xmi_ch * 128 ) ; _WM_midi_setup_noteoff ( xmi_mdi , xmi_ch , xmi_note , 0 ) ; } else { if ( ( xmi_lowestdelta == 0 ) || ( xmi_lowestdelta > xmi_notelen [ j ] ) ) { xmi_lowestdelta = xmi_notelen [ j ] ; } } } xmi_delta -= xmi_tmpdata ; } while ( xmi_delta ) ; } else { if ( ( xmi_data [ 0 ] == 0xff ) && ( xmi_data [ 1 ] == 0x51 ) && ( xmi_data [ 2 ] == 0x03 ) ) { setup_ret = 6 ; goto _XMI_Next_Event ; } if ( ( setup_ret = _WM_SetupMidiEvent ( xmi_mdi , xmi_data , 0 ) ) == 0 ) { goto _xmi_end ; } if ( ( * xmi_data & 0xf0 ) == 0x90 ) { xmi_ch = * xmi_data & 0x0f ; xmi_note = xmi_data [ 1 ] ; xmi_data += setup_ret ; xmi_size -= setup_ret ; xmi_evntlen -= setup_ret ; xmi_subformlen -= setup_ret ; xmi_tmpdata = 0 ; if ( * xmi_data > 0x7f ) { while ( * xmi_data > 0x7f ) { xmi_tmpdata = ( xmi_tmpdata << 7 ) | ( * xmi_data ++ & 0x7f ) ; xmi_size -- ; xmi_evntlen -- ; xmi_subformlen -- ; } } xmi_tmpdata = ( xmi_tmpdata << 7 ) | ( * xmi_data ++ & 0x7f ) ; xmi_size -- ; xmi_evntlen -- ; xmi_subformlen -- ; xmi_notelen [ 128 * xmi_ch + xmi_note ] = xmi_tmpdata ; if ( ( xmi_tmpdata > 0 ) && ( ( xmi_lowestdelta == 0 ) || ( xmi_tmpdata < xmi_lowestdelta ) ) ) { xmi_lowestdelta = xmi_tmpdata ; } } else { _XMI_Next_Event : xmi_data += setup_ret ; xmi_size -= setup_ret ; xmi_evntlen -= setup_ret ; xmi_subformlen -= setup_ret ; } } } while ( xmi_evntlen ) ; } else { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_NOT_XMI , NULL , 0 ) ; goto _xmi_end ; } } while ( xmi_subformlen ) ; } if ( ( xmi_mdi -> reverb = _WM_init_reverb ( _WM_SampleRate , _WM_reverb_room_width , _WM_reverb_room_length , _WM_reverb_listen_posx , _WM_reverb_listen_posy ) ) == NULL ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_MEM , ""toinitreverb"" , 0 ) ; goto _xmi_end ; } xmi_mdi -> extra_info . current_sample = 0 ; xmi_mdi -> current_event = & xmi_mdi -> events [ 0 ] ; xmi_mdi -> samples_to_mix = 0 ; xmi_mdi -> note = NULL ; if ( xmi_evnt_cnt > 1 ) { xmi_mdi -> is_type2 = 1 ; } _WM_ResetToStart ( xmi_mdi ) ; _xmi_end : if ( xmi_notelen != NULL ) free ( xmi_notelen ) ; if ( xmi_mdi -> reverb ) return ( xmi_mdi ) ; _WM_freeMDI ( xmi_mdi ) ; return NULL ; } "," , xmi_data , xmi_size , ",Mindwerks@wildmidi/ad6d7cf88d6673167ca1f517248af9409a9f1be1,CVE-2017-11664,https://github.com/Mindwerks/wildmidi/commit/ad6d7cf88d6673167ca1f517248af9409a9f1be1,2017-08-17T16:29Z 1436,CWE-17,"CWE-17 static ssize_t pipe_read ( struct kiocb * iocb , const struct iovec * _iov , unsigned long nr_segs , loff_t pos ) { struct file * filp = iocb -> ki_filp ; struct pipe_inode_info * pipe = filp -> private_data ; int do_wakeup ; ssize_t ret ; struct iovec * iov = ( struct iovec * ) _iov ; size_t total_len ; total_len = iov_length ( iov , nr_segs ) ; if ( unlikely ( total_len == 0 ) ) return 0 ; do_wakeup = 0 ; ret = 0 ; __pipe_lock ( pipe ) ; for ( ; ; ) { int bufs = pipe -> nrbufs ; if ( bufs ) { int curbuf = pipe -> curbuf ; struct pipe_buffer * buf = pipe -> bufs + curbuf ; const struct pipe_buf_operations * ops = buf -> ops ; void * addr ; size_t chars = buf -> len ; int error , atomic ; if ( chars > total_len ) chars = total_len ; error = ops -> confirm ( pipe , buf ) ; if ( error ) { if ( ! ret ) ret = error ; break ; } atomic = ! iov_fault_in_pages_write ( iov , chars ) ; redo : if ( atomic ) addr = kmap_atomic ( buf -> page ) ; else addr = kmap ( buf -> page ) ; error = pipe_iov_copy_to_user ( iov , addr + buf -> offset , chars , atomic ) ; if ( atomic ) kunmap_atomic ( addr ) ; else kunmap ( buf -> page ) ; if ( unlikely ( error ) ) { if ( atomic ) { atomic = 0 ; goto redo ; } if ( ! ret ) ret = error ; break ; } ret += chars ; buf -> offset += chars ; buf -> len -= chars ; if ( buf -> flags & PIPE_BUF_FLAG_PACKET ) { total_len = chars ; buf -> len = 0 ; } if ( ! buf -> len ) { buf -> ops = NULL ; ops -> release ( pipe , buf ) ; curbuf = ( curbuf + 1 ) & ( pipe -> buffers - 1 ) ; pipe -> curbuf = curbuf ; pipe -> nrbufs = -- bufs ; do_wakeup = 1 ; } total_len -= chars ; if ( ! total_len ) break ; } if ( bufs ) continue ; if ( ! pipe -> writers ) break ; if ( ! pipe -> waiting_writers ) { if ( ret ) break ; if ( filp -> f_flags & O_NONBLOCK ) { ret = - EAGAIN ; break ; } } if ( signal_pending ( current ) ) { if ( ! ret ) ret = - ERESTARTSYS ; break ; } if ( do_wakeup ) { wake_up_interruptible_sync_poll ( & pipe -> wait , POLLOUT | POLLWRNORM ) ; kill_fasync ( & pipe -> fasync_writers , SIGIO , POLL_OUT ) ; } pipe_wait ( pipe ) ; } __pipe_unlock ( pipe ) ; if ( do_wakeup ) { wake_up_interruptible_sync_poll ( & pipe -> wait , POLLOUT | POLLWRNORM ) ; kill_fasync ( & pipe -> fasync_writers , SIGIO , POLL_OUT ) ; } if ( ret > 0 ) file_accessed ( filp ) ; return ret ; } "," size_t total_len ; struct iov_iter iter ; ) return 0 ; iov_iter_init ( & iter , iov , nr_segs , total_len , 0 ) -> ops ; size_t chars = buf -> len ; size_t written ; int error ; if ( break ; } written = copy_page_to_iter ( buf -> page , buf -> offset , chars , & iter ) ; if ( unlikely ( written < chars ) ) { if ( ! ret ) ret = - EFAULT ; break ; ",torvalds@linux/637b58c2887e5e57850865839cc75f59184b23d1,CVE-2015-1805,https://github.com/torvalds/linux/commit/637b58c2887e5e57850865839cc75f59184b23d1,2015-08-08T10:59Z 1437,CWE-787,"CWE-787 static MagickBooleanType EncodeImage ( const ImageInfo * image_info , Image * image , const size_t data_size ) { # define MaxCode ( number_bits ) ( ( one << ( number_bits ) ) - 1 ) # define MaxHashTable 5003 # define MaxGIFBits 12UL # define MaxGIFTable ( 1UL << MaxGIFBits ) # define GIFOutputCode ( code ) { if ( bits > 0 ) datum |= ( size_t ) ( code ) << bits ; else datum = ( size_t ) ( code ) ; bits += number_bits ; while ( bits >= 8 ) { packet [ length ++ ] = ( unsigned char ) ( datum & 0xff ) ; if ( length >= 254 ) { ( void ) WriteBlobByte ( image , ( unsigned char ) length ) ; ( void ) WriteBlob ( image , length , packet ) ; length = 0 ; } datum >>= 8 ; bits -= 8 ; } if ( free_code > max_code ) { number_bits ++ ; if ( number_bits == MaxGIFBits ) max_code = MaxGIFTable ; else max_code = MaxCode ( number_bits ) ; } } IndexPacket index ; short * hash_code , * hash_prefix , waiting_code ; size_t bits , clear_code , datum , end_of_information_code , free_code , length , max_code , next_pixel , number_bits , one , pass ; ssize_t displacement , offset , k , y ; unsigned char * packet , * hash_suffix ; assert ( image != ( Image * ) NULL ) ; one = 1 ; packet = ( unsigned char * ) AcquireQuantumMemory ( 256 , sizeof ( * packet ) ) ; hash_code = ( short * ) AcquireQuantumMemory ( MaxHashTable , sizeof ( * hash_code ) ) ; hash_prefix = ( short * ) AcquireQuantumMemory ( MaxHashTable , sizeof ( * hash_prefix ) ) ; hash_suffix = ( unsigned char * ) AcquireQuantumMemory ( MaxHashTable , sizeof ( * hash_suffix ) ) ; if ( ( packet == ( unsigned char * ) NULL ) || ( hash_code == ( short * ) NULL ) || ( hash_prefix == ( short * ) NULL ) || ( hash_suffix == ( unsigned char * ) NULL ) ) { if ( packet != ( unsigned char * ) NULL ) packet = ( unsigned char * ) RelinquishMagickMemory ( packet ) ; if ( hash_code != ( short * ) NULL ) hash_code = ( short * ) RelinquishMagickMemory ( hash_code ) ; if ( hash_prefix != ( short * ) NULL ) hash_prefix = ( short * ) RelinquishMagickMemory ( hash_prefix ) ; if ( hash_suffix != ( unsigned char * ) NULL ) hash_suffix = ( unsigned char * ) RelinquishMagickMemory ( hash_suffix ) ; return ( MagickFalse ) ; } ( void ) memset ( packet , 0 , 256 * sizeof ( * packet ) ) ; ( void ) memset ( hash_code , 0 , MaxHashTable * sizeof ( * hash_code ) ) ; ( void ) memset ( hash_prefix , 0 , MaxHashTable * sizeof ( * hash_prefix ) ) ; ( void ) memset ( hash_suffix , 0 , MaxHashTable * sizeof ( * hash_suffix ) ) ; number_bits = data_size ; max_code = MaxCode ( number_bits ) ; clear_code = ( ( short ) one << ( data_size - 1 ) ) ; end_of_information_code = clear_code + 1 ; free_code = clear_code + 2 ; length = 0 ; datum = 0 ; bits = 0 ; GIFOutputCode ( clear_code ) ; offset = 0 ; pass = 0 ; waiting_code = 0 ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { register const IndexPacket * magick_restrict indexes ; register const PixelPacket * magick_restrict p ; register ssize_t x ; p = GetVirtualPixels ( image , 0 , offset , image -> columns , 1 , & image -> exception ) ; if ( p == ( const PixelPacket * ) NULL ) break ; indexes = GetVirtualIndexQueue ( image ) ; if ( y == 0 ) { waiting_code = ( short ) ( * indexes ) ; p ++ ; } for ( x = ( ssize_t ) ( y == 0 ? 1 : 0 ) ; x < ( ssize_t ) image -> columns ; x ++ ) { index = ( IndexPacket ) ( ( size_t ) GetPixelIndex ( indexes + x ) & 0xff ) ; p ++ ; k = ( ssize_t ) ( ( ( size_t ) index << ( MaxGIFBits - 8 ) ) + waiting_code ) ; if ( k >= MaxHashTable ) k -= MaxHashTable ; next_pixel = MagickFalse ; displacement = 1 ; if ( hash_code [ k ] > 0 ) { if ( ( hash_prefix [ k ] == waiting_code ) && ( hash_suffix [ k ] == ( unsigned char ) index ) ) { waiting_code = hash_code [ k ] ; continue ; } if ( k != 0 ) displacement = MaxHashTable - k ; for ( ; ; ) { k -= displacement ; if ( k < 0 ) k += MaxHashTable ; if ( hash_code [ k ] == 0 ) break ; if ( ( hash_prefix [ k ] == waiting_code ) && ( hash_suffix [ k ] == ( unsigned char ) index ) ) { waiting_code = hash_code [ k ] ; next_pixel = MagickTrue ; break ; } } if ( next_pixel != MagickFalse ) continue ; } GIFOutputCode ( waiting_code ) ; if ( free_code < MaxGIFTable ) { hash_code [ k ] = ( short ) free_code ++ ; hash_prefix [ k ] = waiting_code ; hash_suffix [ k ] = ( unsigned char ) index ; } else { for ( k = 0 ; k < MaxHashTable ; k ++ ) hash_code [ k ] = 0 ; free_code = clear_code + 2 ; GIFOutputCode ( clear_code ) ; number_bits = data_size ; max_code = MaxCode ( number_bits ) ; } waiting_code = ( short ) index ; } if ( image_info -> interlace == NoInterlace ) offset ++ ; else switch ( pass ) { case 0 : default : { offset += 8 ; if ( offset >= ( ssize_t ) image -> rows ) { pass ++ ; offset = 4 ; } break ; } case 1 : { offset += 8 ; if ( offset >= ( ssize_t ) image -> rows ) { pass ++ ; offset = 2 ; } break ; } case 2 : { offset += 4 ; if ( offset >= ( ssize_t ) image -> rows ) { pass ++ ; offset = 1 ; } break ; } case 3 : { offset += 2 ; break ; } } } GIFOutputCode ( waiting_code ) ; GIFOutputCode ( end_of_information_code ) ; if ( bits > 0 ) { packet [ length ++ ] = ( unsigned char ) ( datum & 0xff ) ; if ( length >= 254 ) { ( void ) WriteBlobByte ( image , ( unsigned char ) length ) ; ( void ) WriteBlob ( image , length , packet ) ; length = 0 ; } } if ( length > 0 ) { ( void ) WriteBlobByte ( image , ( unsigned char ) length ) ; ( void ) WriteBlob ( image , length , packet ) ; } hash_suffix = ( unsigned char * ) RelinquishMagickMemory ( hash_suffix ) ; hash_prefix = ( short * ) RelinquishMagickMemory ( hash_prefix ) ; hash_code = ( short * ) RelinquishMagickMemory ( hash_code ) ; packet = ( unsigned char * ) RelinquishMagickMemory ( packet ) ; return ( MagickTrue ) ; } "," ( code ) \\\n{ if ( bits ) ; } \\\n} IndexPacket index ; ++ ) { next_pixel = MagickFalse ; displacement = 1 ; -= MaxHashTable ; if ( k < 0 ) continue ; if ( ",ImageMagick@ImageMagick/19651f3db63fa1511ed83a348c4c82fa553f8d01,CVE-2019-13308,https://github.com/ImageMagick/ImageMagick/commit/19651f3db63fa1511ed83a348c4c82fa553f8d01,2019-07-05T01:15Z 1438,CWE-20,"CWE-20 static void ikev2_parent_inI2outR2_continue ( struct pluto_crypto_req_cont * pcrc , struct pluto_crypto_req * r , err_t ugh ) { struct dh_continuation * dh = ( struct dh_continuation * ) pcrc ; struct msg_digest * md = dh -> md ; struct state * const st = md -> st ; stf_status e ; DBG ( DBG_CONTROLMORE , DBG_log ( ""ikev2parentinI2outR2:calculatingg^{xy},sendingR2"" ) ) ; if ( st == NULL ) { loglog ( RC_LOG_SERIOUS , ""%s:Requestwasdisconnectedfromstate"" , __FUNCTION__ ) ; if ( dh -> md ) release_md ( dh -> md ) ; return ; } passert ( ugh == NULL ) ; passert ( cur_state == NULL ) ; passert ( st != NULL ) ; passert ( st -> st_suspended_md == dh -> md ) ; set_suspended ( st , NULL ) ; set_cur_state ( st ) ; st -> st_calculating = FALSE ; e = ikev2_parent_inI2outR2_tail ( pcrc , r ) ; if ( e > STF_FAIL ) { int v2_notify_num = e - STF_FAIL ; DBG_log ( ""ikev2_parent_inI2outR2_tailreturnedSTF_FAILwith%s"" , enum_name ( & ikev2_notify_names , v2_notify_num ) ) ; } else if ( e != STF_OK ) { DBG_log ( ""ikev2_parent_inI2outR2_tailreturned%s"" , enum_name ( & stfstatus_name , e ) ) ; } if ( dh -> md != NULL ) { complete_v2_state_transition ( & dh -> md , e ) ; if ( dh -> md ) release_md ( dh -> md ) ; } reset_globals ( ) ; passert ( GLOBALS_ARE_RESET ( ) ) ; } "," ( ) ; } ",libreswan@libreswan/2899351224fe2940aec37d7656e1e392c0fe07f0,CVE-2013-7294,https://github.com/libreswan/libreswan/commit/2899351224fe2940aec37d7656e1e392c0fe07f0,2014-01-16T05:05Z 1439,CWE-362,"CWE-362 int main ( int argc , char * argv [ ] ) { p_fm_config_conx_hdlt hdl ; int instance = 0 ; fm_mgr_config_errno_t res ; char * rem_addr = NULL ; char * community = ""public"" ; char Opts [ 256 ] ; int arg ; char * command ; int i ; strcpy ( Opts , ""i:d:h-"" ) ; while ( ( arg = getopt ( argc , argv , Opts ) ) != EOF ) { switch ( arg ) { case 'h' : case '-' : usage ( argv [ 0 ] ) ; return ( 0 ) ; case 'i' : instance = atol ( optarg ) ; break ; case 'd' : rem_addr = optarg ; break ; default : usage ( argv [ 0 ] ) ; return ( - 1 ) ; } } if ( optind >= argc ) { fprintf ( stderr , ""Commandrequired\\n"" ) ; usage ( argv [ 0 ] ) ; return - 1 ; } command = argv [ optind ++ ] ; printf ( ""Connectingto%sFMinstance%d\\n"" , ( rem_addr == NULL ) ? ""LOCAL"" : rem_addr , instance ) ; if ( ( res = fm_mgr_config_init ( & hdl , instance , rem_addr , community ) ) != FM_CONF_OK ) { fprintf ( stderr , ""Failedtoinitializetheclienthandle:%d\\n"" , res ) ; goto die_clean ; } if ( ( res = fm_mgr_config_connect ( hdl ) ) != FM_CONF_OK ) { fprintf ( stderr , ""Failedtoconnect:(%d)%s\\n"" , res , fm_mgr_get_error_str ( res ) ) ; goto die_clean ; } for ( i = 0 ; i < commandListLen ; i ++ ) { if ( strcmp ( command , commandList [ i ] . name ) == 0 ) { return commandList [ i ] . cmdPtr ( hdl , commandList [ i ] . mgr , ( argc - optind ) , & argv [ optind ] ) ; } } fprintf ( stderr , ""Command(%s)isnotvalid\\n"" , command ) ; usage ( argv [ 0 ] ) ; res = - 1 ; die_clean : if ( hdl ) free ( hdl ) ; return res ; } "," { p_fm_config_conx_hdlt hdl = NULL ) ; goto cleanup ; } if ) ; goto cleanup ; } for 0 ) { res = commandList [ i ] ) ; goto cleanup ; - 1 ; cleanup : if ( hdl ) { if ( hdl -> sm_hdl ) { if ( hdl -> sm_hdl -> c_path [ 0 ] ) unlink ( hdl -> sm_hdl -> c_path ) ; } if ( hdl -> pm_hdl ) { if ( hdl -> pm_hdl -> c_path [ 0 ] ) unlink ( hdl -> pm_hdl -> c_path ) ; } if ( hdl -> fe_hdl ) { if ( hdl -> fe_hdl -> c_path [ 0 ] ) unlink ( hdl -> fe_hdl -> c_path ) ; } free ( hdl hdl ) ; } ",01org@opa-fm/c5759e7b76f5bf844be6c6641cc1b356bbc83869,CVE-2015-5232,https://github.com/01org/opa-fm/commit/c5759e7b76f5bf844be6c6641cc1b356bbc83869,2017-06-07T20:29Z 1440,CWE-190,"CWE-190 int main ( int argc , char * * argv ) { int fmtid ; int id ; char * infile ; jas_stream_t * instream ; jas_image_t * image ; int width ; int height ; int depth ; int numcmpts ; int verbose ; char * fmtname ; int debug ; size_t max_mem ; if ( jas_init ( ) ) { abort ( ) ; } cmdname = argv [ 0 ] ; infile = 0 ; verbose = 0 ; debug = 0 ; # if defined ( JAS_DEFAULT_MAX_MEM_USAGE ) max_mem = JAS_DEFAULT_MAX_MEM_USAGE ; # endif while ( ( id = jas_getopt ( argc , argv , opts ) ) >= 0 ) { switch ( id ) { case OPT_VERBOSE : verbose = 1 ; break ; case OPT_VERSION : printf ( ""%s\\n"" , JAS_VERSION ) ; exit ( EXIT_SUCCESS ) ; break ; case OPT_DEBUG : debug = atoi ( jas_optarg ) ; break ; case OPT_INFILE : infile = jas_optarg ; break ; case OPT_MAXMEM : max_mem = strtoull ( jas_optarg , 0 , 10 ) ; break ; case OPT_HELP : default : usage ( ) ; break ; } } jas_setdbglevel ( debug ) ; # if defined ( JAS_DEFAULT_MAX_MEM_USAGE ) jas_set_max_mem_usage ( max_mem ) ; # endif if ( infile ) { if ( ! ( instream = jas_stream_fopen ( infile , ""rb"" ) ) ) { fprintf ( stderr , ""cannotopeninputimagefile%s\\n"" , infile ) ; exit ( EXIT_FAILURE ) ; } } else { if ( ! ( instream = jas_stream_fdopen ( 0 , ""rb"" ) ) ) { fprintf ( stderr , ""cannotopenstandardinput\\n"" ) ; exit ( EXIT_FAILURE ) ; } } if ( ( fmtid = jas_image_getfmt ( instream ) ) < 0 ) { fprintf ( stderr , ""unknownimageformat\\n"" ) ; } if ( ! ( image = jas_image_decode ( instream , fmtid , 0 ) ) ) { jas_stream_close ( instream ) ; fprintf ( stderr , ""cannotloadimage\\n"" ) ; return EXIT_FAILURE ; } jas_stream_close ( instream ) ; if ( ! ( numcmpts = jas_image_numcmpts ( image ) ) ) { fprintf ( stderr , ""warning:imagehasnocomponents\\n"" ) ; } if ( numcmpts ) { width = jas_image_cmptwidth ( image , 0 ) ; height = jas_image_cmptheight ( image , 0 ) ; depth = jas_image_cmptprec ( image , 0 ) ; } else { width = 0 ; height = 0 ; depth = 0 ; } if ( ! ( fmtname = jas_image_fmttostr ( fmtid ) ) ) { abort ( ) ; } printf ( ""%s%d%d%d%d%ld\\n"" , fmtname , numcmpts , width , height , depth , ( long ) jas_image_rawsize ( image ) ) ; jas_image_destroy ( image ) ; jas_image_clearfmts ( ) ; return EXIT_SUCCESS ; } "," size_t max_mem ; size_t max_samples ; char optstr [ 32 ] ; 0 ] ; max_samples = 64 * JAS_MEBI ; break ; case OPT_MAXSAMPLES : max_samples = strtoull ( jas_optarg , 0 , 10 ) ; break ; case ) ; } snprintf ( optstr , sizeof ( optstr ) , ""max_samples=%-zu"" , max_samples ) ; , fmtid , optstr ) ) ) ( ! ( fmtname = jas_image_fmttostr ( fmtid ) ) ) { jas_eprintf ( ""formatnamelookupfailed\\n"" ) ; return EXIT_FAILURE ; } if ( ! ( 0 ; } printf ( ""%s%d%d%d%d%ld\\n"" , fmtname , numcmpts , , depth , JAS_CAST ( long , jas_image_rawsize ( image jas_image_rawsize ( image ) ",mdadams@jasper/d42b2388f7f8e0332c846675133acea151fc557a,CVE-2016-9557,https://github.com/mdadams/jasper/commit/d42b2388f7f8e0332c846675133acea151fc557a,2017-03-23T18:59Z 1441,CWE-20,"CWE-20 int main ( int argc , char * * argv ) { const char * test_name = NULL ; bool skip_sanity_suite = false ; for ( int i = 1 ; i < argc ; ++ i ) { if ( ! strcmp ( ""--help"" , argv [ i ] ) ) { print_usage ( argv [ 0 ] ) ; return 0 ; } if ( ! strcmp ( ""--insanity"" , argv [ i ] ) ) { skip_sanity_suite = true ; continue ; } if ( ! is_valid ( argv [ i ] ) ) { printf ( ""Error:invalidtestname.\\n"" ) ; print_usage ( argv [ 0 ] ) ; return - 1 ; } if ( test_name != NULL ) { printf ( ""Error:invalidarguments.\\n"" ) ; print_usage ( argv [ 0 ] ) ; return - 1 ; } test_name = argv [ i ] ; } if ( is_shell_running ( ) ) { printf ( ""Run\'adbshellstop\'beforerunning%s.\\n"" , argv [ 0 ] ) ; return - 1 ; } config_t * config = config_new ( CONFIG_FILE_PATH ) ; if ( ! config ) { printf ( ""Error:unabletoopenstackconfigfile.\\n"" ) ; print_usage ( argv [ 0 ] ) ; return - 1 ; } for ( const config_section_node_t * node = config_section_begin ( config ) ; node != config_section_end ( config ) ; node = config_section_next ( node ) ) { const char * name = config_section_name ( node ) ; if ( config_has_key ( config , name , ""LinkKey"" ) && string_to_bdaddr ( name , & bt_remote_bdaddr ) ) { break ; } } config_free ( config ) ; if ( bdaddr_is_empty ( & bt_remote_bdaddr ) ) { printf ( ""Error:unabletofindpaireddeviceinconfigfile.\\n"" ) ; print_usage ( argv [ 0 ] ) ; return - 1 ; } if ( ! hal_open ( callbacks_get_adapter_struct ( ) ) ) { printf ( ""UnabletoopenBluetoothHAL.\\n"" ) ; return 1 ; } if ( ! btsocket_init ( ) ) { printf ( ""UnabletoinitializeBluetoothsockets.\\n"" ) ; return 2 ; } if ( ! pan_init ( ) ) { printf ( ""UnabletoinitializePAN.\\n"" ) ; return 3 ; } if ( ! gatt_init ( ) ) { printf ( ""UnabletoinitializeGATT.\\n"" ) ; return 4 ; } watchdog_running = true ; pthread_create ( & watchdog_thread , NULL , watchdog_fn , NULL ) ; static const char * DEFAULT = ""\\x1b[0m"" ; static const char * GREEN = ""\\x1b[0;32m"" ; static const char * RED = ""\\x1b[0;31m"" ; if ( ! isatty ( fileno ( stdout ) ) ) { DEFAULT = GREEN = RED = """" ; } int pass = 0 ; int fail = 0 ; int case_num = 0 ; if ( ! skip_sanity_suite ) { for ( size_t i = 0 ; i < sanity_suite_size ; ++ i ) { if ( ! test_name || ! strcmp ( test_name , sanity_suite [ i ] . function_name ) ) { callbacks_init ( ) ; if ( sanity_suite [ i ] . function ( ) ) { printf ( ""[%4d]%-64s[%sPASS%s]\\n"" , ++ case_num , sanity_suite [ i ] . function_name , GREEN , DEFAULT ) ; ++ pass ; } else { printf ( ""[%4d]%-64s[%sFAIL%s]\\n"" , ++ case_num , sanity_suite [ i ] . function_name , RED , DEFAULT ) ; ++ fail ; } callbacks_cleanup ( ) ; ++ watchdog_id ; } } } if ( fail ) { printf ( ""\\n%sSanitysuitefailedwith%derrors.%s\\n"" , RED , fail , DEFAULT ) ; hal_close ( ) ; return 4 ; } for ( size_t i = 0 ; i < test_suite_size ; ++ i ) { if ( ! test_name || ! strcmp ( test_name , test_suite [ i ] . function_name ) ) { callbacks_init ( ) ; CALL_AND_WAIT ( bt_interface -> enable ( ) , adapter_state_changed ) ; if ( test_suite [ i ] . function ( ) ) { printf ( ""[%4d]%-64s[%sPASS%s]\\n"" , ++ case_num , test_suite [ i ] . function_name , GREEN , DEFAULT ) ; ++ pass ; } else { printf ( ""[%4d]%-64s[%sFAIL%s]\\n"" , ++ case_num , test_suite [ i ] . function_name , RED , DEFAULT ) ; ++ fail ; } CALL_AND_WAIT ( bt_interface -> disable ( ) , adapter_state_changed ) ; callbacks_cleanup ( ) ; ++ watchdog_id ; } } printf ( ""\\n"" ) ; if ( fail ) { printf ( ""%d/%dtestsfailed.Seeaboveforfailedtestcases.\\n"" , fail , sanity_suite_size + test_suite_size ) ; } else { printf ( ""Alltestspassed!\\n"" ) ; } watchdog_running = false ; pthread_join ( watchdog_thread , NULL ) ; hal_close ( ) ; return 0 ; } "," -> enable ( false ",system@bt/37c88107679d36c419572732b4af6e18bb2f7dce,CVE-2016-3760,https://android.googlesource.com/platform/system/bt/+/37c88107679d36c419572732b4af6e18bb2f7dce,2016-07-11T02:00Z 1442,CWE-287,"CWE-287 ret_t cherokee_validator_ldap_check ( cherokee_validator_ldap_t * ldap , cherokee_connection_t * conn ) { int re ; ret_t ret ; size_t size ; char * dn ; LDAPMessage * message ; LDAPMessage * first ; char * attrs [ ] = { LDAP_NO_ATTRS , NULL } ; cherokee_validator_ldap_props_t * props = VAL_LDAP_PROP ( ldap ) ; if ( ( conn -> validator == NULL ) || cherokee_buffer_is_empty ( & conn -> validator -> user ) ) return ret_error ; size = cherokee_buffer_cnt_cspn ( & conn -> validator -> user , 0 , ""*()"" ) ; if ( size != conn -> validator -> user . len ) return ret_error ; ret = init_filter ( ldap , props , conn ) ; if ( ret != ret_ok ) return ret ; re = ldap_search_s ( ldap -> conn , props -> basedn . buf , LDAP_SCOPE_SUBTREE , ldap -> filter . buf , attrs , 0 , & message ) ; if ( re != LDAP_SUCCESS ) { LOG_ERROR ( CHEROKEE_ERROR_VALIDATOR_LDAP_SEARCH , props -> filter . buf ? props -> filter . buf : """" ) ; return ret_error ; } TRACE ( ENTRIES , ""subtreesearch(%s):done\\n"" , ldap -> filter . buf ? ldap -> filter . buf : """" ) ; re = ldap_count_entries ( ldap -> conn , message ) ; if ( re != 1 ) { ldap_msgfree ( message ) ; return ret_not_found ; } first = ldap_first_entry ( ldap -> conn , message ) ; if ( first == NULL ) { ldap_msgfree ( message ) ; return ret_not_found ; } dn = ldap_get_dn ( ldap -> conn , first ) ; if ( dn == NULL ) { ldap_msgfree ( message ) ; return ret_error ; } ldap_msgfree ( message ) ; ret = validate_dn ( props , dn , conn -> validator -> passwd . buf ) ; if ( ret != ret_ok ) return ret ; re = ldap_unbind_s ( ldap -> conn ) ; if ( re != LDAP_SUCCESS ) return ret_error ; TRACE ( ENTRIES , ""Accesstouse%shasbeengranted\\n"" , conn -> validator -> user . buf ) ; return ret_ok ; } "," -> user ) || cherokee_buffer_is_empty ( & conn -> validator -> passwd ) ",cherokee@webserver/fbda667221c51f0aa476a02366e0cf66cb012f88,CVE-2014-4668,https://github.com/cherokee/webserver/commit/fbda667221c51f0aa476a02366e0cf66cb012f88,2014-07-02T04:14Z 1443,CWE-119,"CWE-119 void CLASS panasonic_load_raw ( ) { int row , col , i , j , sh = 0 , pred [ 2 ] , nonz [ 2 ] ; pana_bits ( 0 ) ; for ( row = 0 ; row < height ; row ++ ) { # ifdef LIBRAW_LIBRARY_BUILD checkCancel ( ) ; # endif for ( col = 0 ; col < raw_width ; col ++ ) { if ( ( i = col % 14 ) == 0 ) pred [ 0 ] = pred [ 1 ] = nonz [ 0 ] = nonz [ 1 ] = 0 ; if ( i % 3 == 2 ) sh = 4 >> ( 3 - pana_bits ( 2 ) ) ; if ( nonz [ i & 1 ] ) { if ( ( j = pana_bits ( 8 ) ) ) { if ( ( pred [ i & 1 ] -= 0x80 << sh ) < 0 || sh == 4 ) pred [ i & 1 ] &= ~ ( ( ~ 0u ) << sh ) ; pred [ i & 1 ] += j << sh ; } } else if ( ( nonz [ i & 1 ] = pana_bits ( 8 ) ) || i > 11 ) pred [ i & 1 ] = nonz [ i & 1 ] << 4 | pana_bits ( 4 ) ; if ( ( RAW ( row , col ) = pred [ col & 1 ] ) > 4098 && col < width ) derror ( ) ; } } } "," ; row < raw_height ; row ++ col < width && row < height ",LibRaw@LibRaw/f1394822a0152ceed77815eafa5cac4e8baab10a,CVE-2017-16909,https://github.com/LibRaw/LibRaw/commit/f1394822a0152ceed77815eafa5cac4e8baab10a,2018-12-07T22:29Z 1444,CWE-787,"CWE-787 static int list_devices ( struct file * filp , struct dm_ioctl * param , size_t param_size ) { unsigned int i ; struct hash_cell * hc ; size_t len , needed = 0 ; struct gendisk * disk ; struct dm_name_list * orig_nl , * nl , * old_nl = NULL ; uint32_t * event_nr ; down_write ( & _hash_lock ) ; for ( i = 0 ; i < NUM_BUCKETS ; i ++ ) { list_for_each_entry ( hc , _name_buckets + i , name_list ) { needed += align_val ( offsetof ( struct dm_name_list , name ) + strlen ( hc -> name ) + 1 ) ; needed += align_val ( sizeof ( uint32_t ) ) ; } } nl = orig_nl = get_result_buffer ( param , param_size , & len ) ; if ( len < needed ) { param -> flags |= DM_BUFFER_FULL_FLAG ; goto out ; } param -> data_size = param -> data_start + needed ; nl -> dev = 0 ; for ( i = 0 ; i < NUM_BUCKETS ; i ++ ) { list_for_each_entry ( hc , _name_buckets + i , name_list ) { if ( old_nl ) old_nl -> next = ( uint32_t ) ( ( void * ) nl - ( void * ) old_nl ) ; disk = dm_disk ( hc -> md ) ; nl -> dev = huge_encode_dev ( disk_devt ( disk ) ) ; nl -> next = 0 ; strcpy ( nl -> name , hc -> name ) ; old_nl = nl ; event_nr = align_ptr ( nl -> name + strlen ( hc -> name ) + 1 ) ; * event_nr = dm_get_event_nr ( hc -> md ) ; nl = align_ptr ( event_nr + 1 ) ; } } BUG_ON ( ( char * ) nl - ( char * ) orig_nl != needed ) ; out : up_write ( & _hash_lock ) ; return 0 ; } "," len < needed || len < sizeof ( nl -> dev ) ",torvalds@linux/4edbe1d7bcffcd6269f3b5eb63f710393ff2ec7a,CVE-2021-31916,https://github.com/torvalds/linux/commit/4edbe1d7bcffcd6269f3b5eb63f710393ff2ec7a,2021-05-06T17:15Z 1445,CWE-125,"CWE-125 static Image * ReadMATImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { Image * image , * image2 = NULL , * rotated_image ; PixelPacket * q ; unsigned int status ; MATHeader MATLAB_HDR ; size_t size ; size_t CellType ; QuantumInfo * quantum_info ; ImageInfo * clone_info ; int i ; ssize_t ldblk ; unsigned char * BImgBuff = NULL ; double MinVal , MaxVal ; size_t Unknown6 ; unsigned z , z2 ; unsigned Frames ; int logging ; int sample_size ; MagickOffsetType filepos = 0x80 ; BlobInfo * blob ; size_t one ; unsigned int ( * ReadBlobXXXLong ) ( Image * image ) ; unsigned short ( * ReadBlobXXXShort ) ( Image * image ) ; void ( * ReadBlobDoublesXXX ) ( Image * image , size_t len , double * data ) ; void ( * ReadBlobFloatsXXX ) ( Image * image , size_t len , float * data ) ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; logging = LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""enter"" ) ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } clone_info = CloneImageInfo ( image_info ) ; if ( ReadBlob ( image , 124 , ( unsigned char * ) & MATLAB_HDR . identific ) != 124 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; MATLAB_HDR . Version = ReadBlobLSBShort ( image ) ; if ( ReadBlob ( image , 2 , ( unsigned char * ) & MATLAB_HDR . EndianIndicator ) != 2 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""Endian%c%c"" , MATLAB_HDR . EndianIndicator [ 0 ] , MATLAB_HDR . EndianIndicator [ 1 ] ) ; if ( ! strncmp ( MATLAB_HDR . EndianIndicator , ""IM"" , 2 ) ) { ReadBlobXXXLong = ReadBlobLSBLong ; ReadBlobXXXShort = ReadBlobLSBShort ; ReadBlobDoublesXXX = ReadBlobDoublesLSB ; ReadBlobFloatsXXX = ReadBlobFloatsLSB ; image -> endian = LSBEndian ; } else if ( ! strncmp ( MATLAB_HDR . EndianIndicator , ""MI"" , 2 ) ) { ReadBlobXXXLong = ReadBlobMSBLong ; ReadBlobXXXShort = ReadBlobMSBShort ; ReadBlobDoublesXXX = ReadBlobDoublesMSB ; ReadBlobFloatsXXX = ReadBlobFloatsMSB ; image -> endian = MSBEndian ; } else goto MATLAB_KO ; if ( strncmp ( MATLAB_HDR . identific , ""MATLAB"" , 6 ) ) MATLAB_KO : ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; filepos = TellBlob ( image ) ; while ( ! EOFBlob ( image ) ) { Frames = 1 ; ( void ) SeekBlob ( image , filepos , SEEK_SET ) ; MATLAB_HDR . DataType = ReadBlobXXXLong ( image ) ; if ( EOFBlob ( image ) ) break ; MATLAB_HDR . ObjectSize = ReadBlobXXXLong ( image ) ; if ( EOFBlob ( image ) ) break ; filepos += MATLAB_HDR . ObjectSize + 4 + 4 ; image2 = image ; # if defined ( MAGICKCORE_ZLIB_DELEGATE ) if ( MATLAB_HDR . DataType == miCOMPRESSED ) { image2 = DecompressBlock ( image , MATLAB_HDR . ObjectSize , clone_info , exception ) ; if ( image2 == NULL ) continue ; MATLAB_HDR . DataType = ReadBlobXXXLong ( image2 ) ; } # endif if ( MATLAB_HDR . DataType != miMATRIX ) continue ; MATLAB_HDR . unknown1 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . unknown2 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . unknown5 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . StructureClass = MATLAB_HDR . unknown5 & 0xFF ; MATLAB_HDR . StructureFlag = ( MATLAB_HDR . unknown5 >> 8 ) & 0xFF ; MATLAB_HDR . unknown3 = ReadBlobXXXLong ( image2 ) ; if ( image != image2 ) MATLAB_HDR . unknown4 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . unknown4 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . DimFlag = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . SizeX = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . SizeY = ReadBlobXXXLong ( image2 ) ; switch ( MATLAB_HDR . DimFlag ) { case 8 : z2 = z = 1 ; break ; case 12 : z2 = z = ReadBlobXXXLong ( image2 ) ; Unknown6 = ReadBlobXXXLong ( image2 ) ; ( void ) Unknown6 ; if ( z != 3 ) ThrowReaderException ( CoderError , ""MultidimensionalMatricesAreNotSupported"" ) ; break ; case 16 : z2 = z = ReadBlobXXXLong ( image2 ) ; if ( z != 3 && z != 1 ) ThrowReaderException ( CoderError , ""MultidimensionalMatricesAreNotSupported"" ) ; Frames = ReadBlobXXXLong ( image2 ) ; break ; default : ThrowReaderException ( CoderError , ""MultidimensionalMatricesAreNotSupported"" ) ; } MATLAB_HDR . Flag1 = ReadBlobXXXShort ( image2 ) ; MATLAB_HDR . NameFlag = ReadBlobXXXShort ( image2 ) ; if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATLAB_HDR.StructureClass%d"" , MATLAB_HDR . StructureClass ) ; if ( MATLAB_HDR . StructureClass != mxCHAR_CLASS && MATLAB_HDR . StructureClass != mxSINGLE_CLASS && MATLAB_HDR . StructureClass != mxDOUBLE_CLASS && MATLAB_HDR . StructureClass != mxINT8_CLASS && MATLAB_HDR . StructureClass != mxUINT8_CLASS && MATLAB_HDR . StructureClass != mxINT16_CLASS && MATLAB_HDR . StructureClass != mxUINT16_CLASS && MATLAB_HDR . StructureClass != mxINT32_CLASS && MATLAB_HDR . StructureClass != mxUINT32_CLASS && MATLAB_HDR . StructureClass != mxINT64_CLASS && MATLAB_HDR . StructureClass != mxUINT64_CLASS ) ThrowReaderException ( CoderError , ""UnsupportedCellTypeInTheMatrix"" ) ; switch ( MATLAB_HDR . NameFlag ) { case 0 : size = ReadBlobXXXLong ( image2 ) ; size = 4 * ( ssize_t ) ( ( size + 3 + 1 ) / 4 ) ; ( void ) SeekBlob ( image2 , size , SEEK_CUR ) ; break ; case 1 : case 2 : case 3 : case 4 : ( void ) ReadBlob ( image2 , 4 , ( unsigned char * ) & size ) ; break ; default : goto MATLAB_KO ; } CellType = ReadBlobXXXLong ( image2 ) ; if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATLAB_HDR.CellType:%.20g"" , ( double ) CellType ) ; ( void ) ReadBlob ( image2 , 4 , ( unsigned char * ) & size ) ; NEXT_FRAME : switch ( CellType ) { case miINT8 : case miUINT8 : sample_size = 8 ; if ( MATLAB_HDR . StructureFlag & FLAG_LOGICAL ) image -> depth = 1 ; else image -> depth = 8 ; ldblk = ( ssize_t ) MATLAB_HDR . SizeX ; break ; case miINT16 : case miUINT16 : sample_size = 16 ; image -> depth = 16 ; ldblk = ( ssize_t ) ( 2 * MATLAB_HDR . SizeX ) ; break ; case miINT32 : case miUINT32 : sample_size = 32 ; image -> depth = 32 ; ldblk = ( ssize_t ) ( 4 * MATLAB_HDR . SizeX ) ; break ; case miINT64 : case miUINT64 : sample_size = 64 ; image -> depth = 64 ; ldblk = ( ssize_t ) ( 8 * MATLAB_HDR . SizeX ) ; break ; case miSINGLE : sample_size = 32 ; image -> depth = 32 ; ( void ) SetImageOption ( clone_info , ""quantum:format"" , ""floating-point"" ) ; if ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) { } ldblk = ( ssize_t ) ( 4 * MATLAB_HDR . SizeX ) ; break ; case miDOUBLE : sample_size = 64 ; image -> depth = 64 ; ( void ) SetImageOption ( clone_info , ""quantum:format"" , ""floating-point"" ) ; DisableMSCWarning ( 4127 ) if ( sizeof ( double ) != 8 ) RestoreMSCWarning ThrowReaderException ( CoderError , ""IncompatibleSizeOfDouble"" ) ; if ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) { } ldblk = ( ssize_t ) ( 8 * MATLAB_HDR . SizeX ) ; break ; default : ThrowReaderException ( CoderError , ""UnsupportedCellTypeInTheMatrix"" ) ; } ( void ) sample_size ; image -> columns = MATLAB_HDR . SizeX ; image -> rows = MATLAB_HDR . SizeY ; quantum_info = AcquireQuantumInfo ( clone_info , image ) ; if ( quantum_info == ( QuantumInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; one = 1 ; image -> colors = one << image -> depth ; if ( image -> columns == 0 || image -> rows == 0 ) goto MATLAB_KO ; if ( ( MATLAB_HDR . DimFlag == 8 ) && ( ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) == 0 ) ) { SetImageColorspace ( image , GRAYColorspace ) ; image -> type = GrayscaleType ; } if ( image_info -> ping ) { size_t temp = image -> columns ; image -> columns = image -> rows ; image -> rows = temp ; goto done_reading ; } status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; } BImgBuff = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) ( ldblk ) , sizeof ( double ) ) ; if ( BImgBuff == NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; MinVal = 0 ; MaxVal = 0 ; if ( CellType == miDOUBLE || CellType == miSINGLE ) { CalcMinMax ( image2 , image_info -> endian , MATLAB_HDR . SizeX , MATLAB_HDR . SizeY , CellType , ldblk , BImgBuff , & quantum_info -> minimum , & quantum_info -> maximum ) ; } if ( z == 1 ) z = 0 ; do { for ( i = 0 ; i < ( ssize_t ) MATLAB_HDR . SizeY ; i ++ ) { q = GetAuthenticPixels ( image , 0 , MATLAB_HDR . SizeY - i - 1 , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) { if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATsetimagepixelsreturnsunexpectedNULLonarow%u."" , ( unsigned ) ( MATLAB_HDR . SizeY - i - 1 ) ) ; goto done_reading ; } if ( ReadBlob ( image2 , ldblk , ( unsigned char * ) BImgBuff ) != ( ssize_t ) ldblk ) { if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATcannotreadscanrow%ufromafile."" , ( unsigned ) ( MATLAB_HDR . SizeY - i - 1 ) ) ; goto ExitLoop ; } if ( ( CellType == miINT8 || CellType == miUINT8 ) && ( MATLAB_HDR . StructureFlag & FLAG_LOGICAL ) ) { FixLogical ( ( unsigned char * ) BImgBuff , ldblk ) ; if ( ImportQuantumPixels ( image , ( CacheView * ) NULL , quantum_info , z2qtype [ z ] , BImgBuff , exception ) <= 0 ) { ImportQuantumPixelsFailed : if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATfailedtoImportQuantumPixelsforarow%u"" , ( unsigned ) ( MATLAB_HDR . SizeY - i - 1 ) ) ; break ; } } else { if ( ImportQuantumPixels ( image , ( CacheView * ) NULL , quantum_info , z2qtype [ z ] , BImgBuff , exception ) <= 0 ) goto ImportQuantumPixelsFailed ; if ( z <= 1 && ( CellType == miINT8 || CellType == miINT16 || CellType == miINT32 || CellType == miINT64 ) ) FixSignedValues ( q , MATLAB_HDR . SizeX ) ; } if ( ! SyncAuthenticPixels ( image , exception ) ) { if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATfailedtosyncimagepixelsforarow%u"" , ( unsigned ) ( MATLAB_HDR . SizeY - i - 1 ) ) ; goto ExitLoop ; } } } while ( z -- >= 2 ) ; ExitLoop : if ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) { CellType = ReadBlobXXXLong ( image2 ) ; i = ReadBlobXXXLong ( image2 ) ; if ( CellType == miDOUBLE || CellType == miSINGLE ) { CalcMinMax ( image2 , image_info -> endian , MATLAB_HDR . SizeX , MATLAB_HDR . SizeY , CellType , ldblk , BImgBuff , & MinVal , & MaxVal ) ; } if ( CellType == miDOUBLE ) for ( i = 0 ; i < ( ssize_t ) MATLAB_HDR . SizeY ; i ++ ) { ReadBlobDoublesXXX ( image2 , ldblk , ( double * ) BImgBuff ) ; InsertComplexDoubleRow ( ( double * ) BImgBuff , i , image , MinVal , MaxVal ) ; } if ( CellType == miSINGLE ) for ( i = 0 ; i < ( ssize_t ) MATLAB_HDR . SizeY ; i ++ ) { ReadBlobFloatsXXX ( image2 , ldblk , ( float * ) BImgBuff ) ; InsertComplexFloatRow ( ( float * ) BImgBuff , i , image , MinVal , MaxVal ) ; } } if ( ( MATLAB_HDR . DimFlag == 8 ) && ( ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) == 0 ) ) image -> type = GrayscaleType ; if ( image -> depth == 1 ) image -> type = BilevelType ; if ( image2 == image ) image2 = NULL ; rotated_image = RotateImage ( image , 90.0 , exception ) ; if ( rotated_image != ( Image * ) NULL ) { rotated_image -> page . x = 0 ; rotated_image -> page . y = 0 ; blob = rotated_image -> blob ; rotated_image -> blob = image -> blob ; rotated_image -> colors = image -> colors ; image -> blob = blob ; AppendImageToList ( & image , rotated_image ) ; DeleteImageFromList ( & image ) ; } done_reading : if ( image2 != NULL ) if ( image2 != image ) { DeleteImageFromList ( & image2 ) ; if ( clone_info ) { if ( clone_info -> file ) { fclose ( clone_info -> file ) ; clone_info -> file = NULL ; ( void ) remove_utf8 ( clone_info -> filename ) ; } } } AcquireNextImage ( image_info , image ) ; if ( image -> next == ( Image * ) NULL ) break ; image = SyncNextImageInList ( image ) ; image -> columns = image -> rows = 0 ; image -> colors = 0 ; RelinquishMagickMemory ( BImgBuff ) ; BImgBuff = NULL ; if ( -- Frames > 0 ) { z = z2 ; if ( image2 == NULL ) image2 = image ; goto NEXT_FRAME ; } if ( image2 != NULL ) if ( image2 != image ) { DeleteImageFromList ( & image2 ) ; if ( clone_info ) { if ( clone_info -> file ) { fclose ( clone_info -> file ) ; clone_info -> file = NULL ; ( void ) unlink ( clone_info -> filename ) ; } } } } clone_info = DestroyImageInfo ( clone_info ) ; RelinquishMagickMemory ( BImgBuff ) ; CloseBlob ( image ) ; { Image * p ; ssize_t scene = 0 ; p = image ; image = NULL ; while ( p != ( Image * ) NULL ) { Image * tmp = p ; if ( ( p -> rows == 0 ) || ( p -> columns == 0 ) ) { p = p -> previous ; DeleteImageFromList ( & tmp ) ; } else { image = p ; p = p -> previous ; } } for ( p = image ; p != ( Image * ) NULL ; p = p -> next ) p -> scene = scene ++ ; } if ( clone_info != NULL ) { if ( clone_info -> file ) { fclose ( clone_info -> file ) ; clone_info -> file = NULL ; ( void ) remove_utf8 ( clone_info -> filename ) ; } DestroyImageInfo ( clone_info ) ; clone_info = NULL ; } if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""return"" ) ; if ( image == NULL ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; return ( image ) ; } "," 2 ) ; quantum_info = DestroyQuantumInfo ( quantum_info ) ; ",ImageMagick@ImageMagick/b173a352397877775c51c9a0e9d59eb6ce24c455,CVE-2016-10070,https://github.com/ImageMagick/ImageMagick/commit/b173a352397877775c51c9a0e9d59eb6ce24c455,2017-03-03T18:59Z 1446,CWE-20,"CWE-20 static int vmx_update_pi_irte ( struct kvm * kvm , unsigned int host_irq , uint32_t guest_irq , bool set ) { struct kvm_kernel_irq_routing_entry * e ; struct kvm_irq_routing_table * irq_rt ; struct kvm_lapic_irq irq ; struct kvm_vcpu * vcpu ; struct vcpu_data vcpu_info ; int idx , ret = - EINVAL ; if ( ! kvm_arch_has_assigned_device ( kvm ) || ! irq_remapping_cap ( IRQ_POSTING_CAP ) || ! kvm_vcpu_apicv_active ( kvm -> vcpus [ 0 ] ) ) return 0 ; idx = srcu_read_lock ( & kvm -> irq_srcu ) ; irq_rt = srcu_dereference ( kvm -> irq_routing , & kvm -> irq_srcu ) ; BUG_ON ( guest_irq >= irq_rt -> nr_rt_entries ) ; hlist_for_each_entry ( e , & irq_rt -> map [ guest_irq ] , link ) { if ( e -> type != KVM_IRQ_ROUTING_MSI ) continue ; kvm_set_msi_irq ( kvm , e , & irq ) ; if ( ! kvm_intr_is_single_vcpu ( kvm , & irq , & vcpu ) ) { ret = irq_set_vcpu_affinity ( host_irq , NULL ) ; if ( ret < 0 ) { printk ( KERN_INFO ""failedtobacktoremappedmode,irq:%u\\n"" , host_irq ) ; goto out ; } continue ; } vcpu_info . pi_desc_addr = __pa ( vcpu_to_pi_desc ( vcpu ) ) ; vcpu_info . vector = irq . vector ; trace_kvm_pi_irte_update ( vcpu -> vcpu_id , host_irq , e -> gsi , vcpu_info . vector , vcpu_info . pi_desc_addr , set ) ; if ( set ) ret = irq_set_vcpu_affinity ( host_irq , & vcpu_info ) ; else { pi_set_sn ( vcpu_to_pi_desc ( vcpu ) ) ; ret = irq_set_vcpu_affinity ( host_irq , NULL ) ; pi_clear_sn ( vcpu_to_pi_desc ( vcpu ) ) ; } if ( ret < 0 ) { printk ( KERN_INFO ""%s:failedtoupdatePIIRTE\\n"" , __func__ ) ; goto out ; } } ret = 0 ; out : srcu_read_unlock ( & kvm -> irq_srcu , idx ) ; return ret ; } "," , ret = 0 ; if ( irq_srcu ) ; if ( guest_irq >= irq_rt -> nr_rt_entries || hlist_empty ( & irq_rt -> [ guest_irq ] ) ) { pr_warn_once ( ""norouteforguest_irq%u/%u(brokenuserspace?)\\n"" , guest_irq , irq_rt -> nr_rt_entries ) ; goto out ; } hlist_for_each_entry ( e , & irq_rt -> map [ guest_irq ] ",torvalds@linux/3a8b0677fc6180a467e26cc32ce6b0c09a32f9bb,CVE-2017-1000252,https://github.com/torvalds/linux/commit/3a8b0677fc6180a467e26cc32ce6b0c09a32f9bb,2017-09-26T05:29Z 1447,CWE-416,"CWE-416 static enum hrtimer_restart bfq_idle_slice_timer ( struct hrtimer * timer ) { struct bfq_data * bfqd = container_of ( timer , struct bfq_data , idle_slice_timer ) ; struct bfq_queue * bfqq = bfqd -> in_service_queue ; if ( bfqq ) bfq_idle_slice_timer_body ( bfqq ) ; return HRTIMER_NORESTART ; } "," ) bfq_idle_slice_timer_body ( bfqd , ",torvalds@linux/2f95fa5c955d0a9987ffdc3a095e2f4e62c5f2a9,CVE-2020-12657,https://github.com/torvalds/linux/commit/2f95fa5c955d0a9987ffdc3a095e2f4e62c5f2a9,2020-05-05T07:15Z 1448,CWE-119,"CWE-119 static bool regsafe ( struct bpf_reg_state * rold , struct bpf_reg_state * rcur , struct idpair * idmap ) { if ( ! ( rold -> live & REG_LIVE_READ ) ) return true ; if ( memcmp ( rold , rcur , offsetof ( struct bpf_reg_state , live ) ) == 0 ) return true ; if ( rold -> type == NOT_INIT ) return true ; if ( rcur -> type == NOT_INIT ) return false ; switch ( rold -> type ) { case SCALAR_VALUE : if ( rcur -> type == SCALAR_VALUE ) { return range_within ( rold , rcur ) && tnum_in ( rold -> var_off , rcur -> var_off ) ; } else { return rold -> umin_value == 0 && rold -> umax_value == U64_MAX && rold -> smin_value == S64_MIN && rold -> smax_value == S64_MAX && tnum_is_unknown ( rold -> var_off ) ; } case PTR_TO_MAP_VALUE : return memcmp ( rold , rcur , offsetof ( struct bpf_reg_state , id ) ) == 0 && range_within ( rold , rcur ) && tnum_in ( rold -> var_off , rcur -> var_off ) ; case PTR_TO_MAP_VALUE_OR_NULL : if ( rcur -> type != PTR_TO_MAP_VALUE_OR_NULL ) return false ; if ( memcmp ( rold , rcur , offsetof ( struct bpf_reg_state , id ) ) ) return false ; return check_ids ( rold -> id , rcur -> id , idmap ) ; case PTR_TO_PACKET_META : case PTR_TO_PACKET : if ( rcur -> type != rold -> type ) return false ; if ( rold -> range > rcur -> range ) return false ; if ( rold -> off != rcur -> off ) return false ; if ( rold -> id && ! check_ids ( rold -> id , rcur -> id , idmap ) ) return false ; return range_within ( rold , rcur ) && tnum_in ( rold -> var_off , rcur -> var_off ) ; case PTR_TO_CTX : case CONST_PTR_TO_MAP : case PTR_TO_STACK : case PTR_TO_PACKET_END : default : return false ; } WARN_ON_ONCE ( 1 ) ; return false ; } "," else { return false ; } case ",torvalds@linux/179d1c5602997fef5a940c6ddcf31212cbfebd14,CVE-2017-17855,https://github.com/torvalds/linux/commit/179d1c5602997fef5a940c6ddcf31212cbfebd14,2017-12-27T17:08Z 1449,CWE-200,"CWE-200 static int rfcomm_sock_getname ( struct socket * sock , struct sockaddr * addr , int * len , int peer ) { struct sockaddr_rc * sa = ( struct sockaddr_rc * ) addr ; struct sock * sk = sock -> sk ; BT_DBG ( ""sock%p,sk%p"" , sock , sk ) ; sa -> rc_family = AF_BLUETOOTH ; sa -> rc_channel = rfcomm_pi ( sk ) -> channel ; if ( peer ) bacpy ( & sa -> rc_bdaddr , & bt_sk ( sk ) -> dst ) ; else bacpy ( & sa -> rc_bdaddr , & bt_sk ( sk ) -> src ) ; * len = sizeof ( struct sockaddr_rc ) ; return 0 ; } "," sock , sk ) ; memset ( sa , 0 , sizeof ( * sa ) ",torvalds@linux/9344a972961d1a6d2c04d9008b13617bcb6ec2ef,CVE-2012-6545,https://github.com/torvalds/linux/commit/9344a972961d1a6d2c04d9008b13617bcb6ec2ef,2013-03-15T20:55Z 1450,CWE-476,"CWE-476 void * sspi_SecureHandleGetUpperPointer ( SecHandle * handle ) { void * pointer ; if ( ! handle ) return NULL ; pointer = ( void * ) ~ ( ( size_t ) handle -> dwUpper ) ; return pointer ; } "," ( ! handle || ! SecIsValidHandle ( handle ) ",FreeRDP@FreeRDP/0773bb9303d24473fe1185d85a424dfe159aff53,CVE-2013-4119,https://github.com/FreeRDP/FreeRDP/commit/0773bb9303d24473fe1185d85a424dfe159aff53,2016-10-03T21:59Z 1451,CWE-125,"CWE-125 static int update_prepare_order_info ( rdpContext * context , ORDER_INFO * orderInfo , UINT32 orderType ) { int length = 1 ; orderInfo -> fieldFlags = 0 ; orderInfo -> orderType = orderType ; orderInfo -> controlFlags = ORDER_STANDARD ; orderInfo -> controlFlags |= ORDER_TYPE_CHANGE ; length += 1 ; length += PRIMARY_DRAWING_ORDER_FIELD_BYTES [ orderInfo -> orderType ] ; length += update_prepare_bounds ( context , orderInfo ) ; return length ; } "," ; length += get_primary_drawing_order_field_bytes ( orderInfo -> orderType orderInfo -> orderType , NULL ) ; length += ",FreeRDP@FreeRDP/733ee3208306b1ea32697b356c0215180fc3f049,CVE-2020-11095,https://github.com/FreeRDP/FreeRDP/commit/733ee3208306b1ea32697b356c0215180fc3f049,2020-06-22T22:15Z 1452,CWE-20,"CWE-20 static int ovl_rename2 ( struct inode * olddir , struct dentry * old , struct inode * newdir , struct dentry * new , unsigned int flags ) { int err ; enum ovl_path_type old_type ; enum ovl_path_type new_type ; struct dentry * old_upperdir ; struct dentry * new_upperdir ; struct dentry * olddentry ; struct dentry * newdentry ; struct dentry * trap ; bool old_opaque ; bool new_opaque ; bool new_create = false ; bool cleanup_whiteout = false ; bool overwrite = ! ( flags & RENAME_EXCHANGE ) ; bool is_dir = d_is_dir ( old ) ; bool new_is_dir = false ; struct dentry * opaquedir = NULL ; const struct cred * old_cred = NULL ; struct cred * override_cred = NULL ; err = - EINVAL ; if ( flags & ~ ( RENAME_EXCHANGE | RENAME_NOREPLACE ) ) goto out ; flags &= ~ RENAME_NOREPLACE ; err = ovl_check_sticky ( old ) ; if ( err ) goto out ; old_type = ovl_path_type ( old ) ; err = - EXDEV ; if ( OVL_TYPE_MERGE_OR_LOWER ( old_type ) && is_dir ) goto out ; if ( new -> d_inode ) { err = ovl_check_sticky ( new ) ; if ( err ) goto out ; if ( d_is_dir ( new ) ) new_is_dir = true ; new_type = ovl_path_type ( new ) ; err = - EXDEV ; if ( ! overwrite && OVL_TYPE_MERGE_OR_LOWER ( new_type ) && new_is_dir ) goto out ; err = 0 ; if ( ! OVL_TYPE_UPPER ( new_type ) && ! OVL_TYPE_UPPER ( old_type ) ) { if ( ovl_dentry_lower ( old ) -> d_inode == ovl_dentry_lower ( new ) -> d_inode ) goto out ; } if ( OVL_TYPE_UPPER ( new_type ) && OVL_TYPE_UPPER ( old_type ) ) { if ( ovl_dentry_upper ( old ) -> d_inode == ovl_dentry_upper ( new ) -> d_inode ) goto out ; } } else { if ( ovl_dentry_is_opaque ( new ) ) new_type = __OVL_PATH_UPPER ; else new_type = __OVL_PATH_UPPER | __OVL_PATH_PURE ; } err = ovl_want_write ( old ) ; if ( err ) goto out ; err = ovl_copy_up ( old ) ; if ( err ) goto out_drop_write ; err = ovl_copy_up ( new -> d_parent ) ; if ( err ) goto out_drop_write ; if ( ! overwrite ) { err = ovl_copy_up ( new ) ; if ( err ) goto out_drop_write ; } old_opaque = ! OVL_TYPE_PURE_UPPER ( old_type ) ; new_opaque = ! OVL_TYPE_PURE_UPPER ( new_type ) ; if ( old_opaque || new_opaque ) { err = - ENOMEM ; override_cred = prepare_creds ( ) ; if ( ! override_cred ) goto out_drop_write ; cap_raise ( override_cred -> cap_effective , CAP_SYS_ADMIN ) ; cap_raise ( override_cred -> cap_effective , CAP_DAC_OVERRIDE ) ; cap_raise ( override_cred -> cap_effective , CAP_FOWNER ) ; cap_raise ( override_cred -> cap_effective , CAP_FSETID ) ; cap_raise ( override_cred -> cap_effective , CAP_CHOWN ) ; old_cred = override_creds ( override_cred ) ; } if ( overwrite && OVL_TYPE_MERGE_OR_LOWER ( new_type ) && new_is_dir ) { opaquedir = ovl_check_empty_and_clear ( new ) ; err = PTR_ERR ( opaquedir ) ; if ( IS_ERR ( opaquedir ) ) { opaquedir = NULL ; goto out_revert_creds ; } } if ( overwrite ) { if ( old_opaque ) { if ( new -> d_inode || ! new_opaque ) { flags |= RENAME_WHITEOUT ; } else { flags |= RENAME_EXCHANGE ; } } else if ( is_dir && ! new -> d_inode && new_opaque ) { flags |= RENAME_EXCHANGE ; cleanup_whiteout = true ; } } old_upperdir = ovl_dentry_upper ( old -> d_parent ) ; new_upperdir = ovl_dentry_upper ( new -> d_parent ) ; trap = lock_rename ( new_upperdir , old_upperdir ) ; olddentry = ovl_dentry_upper ( old ) ; newdentry = ovl_dentry_upper ( new ) ; if ( newdentry ) { if ( opaquedir ) { newdentry = opaquedir ; opaquedir = NULL ; } else { dget ( newdentry ) ; } } else { new_create = true ; newdentry = lookup_one_len ( new -> d_name . name , new_upperdir , new -> d_name . len ) ; err = PTR_ERR ( newdentry ) ; if ( IS_ERR ( newdentry ) ) goto out_unlock ; } err = - ESTALE ; if ( olddentry -> d_parent != old_upperdir ) goto out_dput ; if ( newdentry -> d_parent != new_upperdir ) goto out_dput ; if ( olddentry == trap ) goto out_dput ; if ( newdentry == trap ) goto out_dput ; if ( is_dir && ! old_opaque && new_opaque ) { err = ovl_set_opaque ( olddentry ) ; if ( err ) goto out_dput ; } if ( ! overwrite && new_is_dir && old_opaque && ! new_opaque ) { err = ovl_set_opaque ( newdentry ) ; if ( err ) goto out_dput ; } if ( old_opaque || new_opaque ) { err = ovl_do_rename ( old_upperdir -> d_inode , olddentry , new_upperdir -> d_inode , newdentry , flags ) ; } else { BUG_ON ( flags & ~ RENAME_EXCHANGE ) ; err = vfs_rename ( old_upperdir -> d_inode , olddentry , new_upperdir -> d_inode , newdentry , NULL , flags ) ; } if ( err ) { if ( is_dir && ! old_opaque && new_opaque ) ovl_remove_opaque ( olddentry ) ; if ( ! overwrite && new_is_dir && old_opaque && ! new_opaque ) ovl_remove_opaque ( newdentry ) ; goto out_dput ; } if ( is_dir && old_opaque && ! new_opaque ) ovl_remove_opaque ( olddentry ) ; if ( ! overwrite && new_is_dir && ! old_opaque && new_opaque ) ovl_remove_opaque ( newdentry ) ; if ( old_opaque != new_opaque ) { ovl_dentry_set_opaque ( old , new_opaque ) ; if ( ! overwrite ) ovl_dentry_set_opaque ( new , old_opaque ) ; } if ( cleanup_whiteout ) ovl_cleanup ( old_upperdir -> d_inode , newdentry ) ; ovl_dentry_version_inc ( old -> d_parent ) ; ovl_dentry_version_inc ( new -> d_parent ) ; out_dput : dput ( newdentry ) ; out_unlock : unlock_rename ( new_upperdir , old_upperdir ) ; out_revert_creds : if ( old_opaque || new_opaque ) { revert_creds ( old_cred ) ; put_cred ( override_cred ) ; } out_drop_write : ovl_drop_write ( old ) ; out : dput ( opaquedir ) ; return err ; } "," ; olddentry = lookup_one_len ( old -> d_name . . name , old_upperdir , old -> d_name . = PTR_ERR ( olddentry ) ; if ( IS_ERR ( olddentry ) ) goto goto out_unlock ; err = - if ( olddentry != ovl_dentry_upper ( old ) ) goto out_dput_old ; newdentry = lookup_one_len ( new -> d_name . name , new_upperdir , new -> d_name . len ) ; err = PTR_ERR ( newdentry ) ; if ( IS_ERR ( newdentry ) ) goto out_dput_old ; err = - ESTALE ; if ( ovl_dentry_upper ( new ) ) { if ( opaquedir ) { if ( newdentry != opaquedir ) goto out_dput goto out_dput ; } else { if ( newdentry != ovl_dentry_upper ( new ) ) goto out_dput goto out_dput ; } } else { new_create = true ; if ( ! d_is_negative ( newdentry ) && ( ! new_opaque || ! ovl_is_whiteout ( newdentry ) ) ) goto out_dput ; } newdentry ) ; out_dput_old : dput ( olddentry ) ; ",torvalds@linux/11f3710417d026ea2f4fcf362d866342c5274185,CVE-2016-6197,https://github.com/torvalds/linux/commit/11f3710417d026ea2f4fcf362d866342c5274185,2016-08-06T20:59Z 1453,CWE-125,"CWE-125 static int match_at ( regex_t * reg , const UChar * str , const UChar * end , # ifdef USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE const UChar * right_range , # endif const UChar * sstart , UChar * sprev , OnigMatchArg * msa ) { static UChar FinishCode [ ] = { OP_FINISH } ; int i , n , num_mem , best_len , pop_level ; LengthType tlen , tlen2 ; MemNumType mem ; RelAddrType addr ; UChar * s , * q , * sbegin ; int is_alloca ; char * alloc_base ; OnigStackType * stk_base , * stk , * stk_end ; OnigStackType * stkp ; OnigStackIndex si ; OnigStackIndex * repeat_stk ; OnigStackIndex * mem_start_stk , * mem_end_stk ; # ifdef USE_COMBINATION_EXPLOSION_CHECK int scv ; unsigned char * state_check_buff = msa -> state_check_buff ; int num_comb_exp_check = reg -> num_comb_exp_check ; # endif UChar * p = reg -> p ; OnigOptionType option = reg -> options ; OnigEncoding encode = reg -> enc ; OnigCaseFoldType case_fold_flag = reg -> case_fold_flag ; pop_level = reg -> stack_pop_level ; num_mem = reg -> num_mem ; STACK_INIT ( INIT_MATCH_STACK_SIZE ) ; UPDATE_FOR_STACK_REALLOC ; for ( i = 1 ; i <= num_mem ; i ++ ) { mem_start_stk [ i ] = mem_end_stk [ i ] = INVALID_STACK_INDEX ; } # ifdef ONIG_DEBUG_MATCH fprintf ( stderr , ""match_at:str:%d,end:%d,start:%d,sprev:%d\\n"" , ( int ) str , ( int ) end , ( int ) sstart , ( int ) sprev ) ; fprintf ( stderr , ""size:%d,startoffset:%d\\n"" , ( int ) ( end - str ) , ( int ) ( sstart - str ) ) ; # endif STACK_PUSH_ENSURED ( STK_ALT , FinishCode ) ; best_len = ONIG_MISMATCH ; s = ( UChar * ) sstart ; while ( 1 ) { # ifdef ONIG_DEBUG_MATCH { UChar * q , * bp , buf [ 50 ] ; int len ; fprintf ( stderr , ""%4d>\\"""" , ( int ) ( s - str ) ) ; bp = buf ; for ( i = 0 , q = s ; i < 7 && q < end ; i ++ ) { len = enclen ( encode , q ) ; while ( len -- > 0 ) * bp ++ = * q ++ ; } if ( q < end ) { xmemcpy ( bp , ""...\\"""" , 4 ) ; bp += 4 ; } else { xmemcpy ( bp , ""\\"""" , 1 ) ; bp += 1 ; } * bp = 0 ; fputs ( ( char * ) buf , stderr ) ; for ( i = 0 ; i < 20 - ( bp - buf ) ; i ++ ) fputc ( '' , stderr ) ; onig_print_compiled_byte_code ( stderr , p , NULL , encode ) ; fprintf ( stderr , ""\\n"" ) ; } # endif sbegin = s ; switch ( * p ++ ) { case OP_END : MOP_IN ( OP_END ) ; n = s - sstart ; if ( n > best_len ) { OnigRegion * region ; # ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE if ( IS_FIND_LONGEST ( option ) ) { if ( n > msa -> best_len ) { msa -> best_len = n ; msa -> best_s = ( UChar * ) sstart ; } else goto end_best_len ; } # endif best_len = n ; region = msa -> region ; if ( region ) { # ifdef USE_POSIX_API_REGION_OPTION if ( IS_POSIX_REGION ( msa -> options ) ) { posix_regmatch_t * rmt = ( posix_regmatch_t * ) region ; rmt [ 0 ] . rm_so = sstart - str ; rmt [ 0 ] . rm_eo = s - str ; for ( i = 1 ; i <= num_mem ; i ++ ) { if ( mem_end_stk [ i ] != INVALID_STACK_INDEX ) { if ( BIT_STATUS_AT ( reg -> bt_mem_start , i ) ) rmt [ i ] . rm_so = STACK_AT ( mem_start_stk [ i ] ) -> u . mem . pstr - str ; else rmt [ i ] . rm_so = ( UChar * ) ( ( void * ) ( mem_start_stk [ i ] ) ) - str ; rmt [ i ] . rm_eo = ( BIT_STATUS_AT ( reg -> bt_mem_end , i ) ? STACK_AT ( mem_end_stk [ i ] ) -> u . mem . pstr : ( UChar * ) ( ( void * ) mem_end_stk [ i ] ) ) - str ; } else { rmt [ i ] . rm_so = rmt [ i ] . rm_eo = ONIG_REGION_NOTPOS ; } } } else { # endif region -> beg [ 0 ] = sstart - str ; region -> end [ 0 ] = s - str ; for ( i = 1 ; i <= num_mem ; i ++ ) { if ( mem_end_stk [ i ] != INVALID_STACK_INDEX ) { if ( BIT_STATUS_AT ( reg -> bt_mem_start , i ) ) region -> beg [ i ] = STACK_AT ( mem_start_stk [ i ] ) -> u . mem . pstr - str ; else region -> beg [ i ] = ( UChar * ) ( ( void * ) mem_start_stk [ i ] ) - str ; region -> end [ i ] = ( BIT_STATUS_AT ( reg -> bt_mem_end , i ) ? STACK_AT ( mem_end_stk [ i ] ) -> u . mem . pstr : ( UChar * ) ( ( void * ) mem_end_stk [ i ] ) ) - str ; } else { region -> beg [ i ] = region -> end [ i ] = ONIG_REGION_NOTPOS ; } } # ifdef USE_CAPTURE_HISTORY if ( reg -> capture_history != 0 ) { int r ; OnigCaptureTreeNode * node ; if ( IS_NULL ( region -> history_root ) ) { region -> history_root = node = history_node_new ( ) ; CHECK_NULL_RETURN_MEMERR ( node ) ; } else { node = region -> history_root ; history_tree_clear ( node ) ; } node -> group = 0 ; node -> beg = sstart - str ; node -> end = s - str ; stkp = stk_base ; r = make_capture_history_tree ( region -> history_root , & stkp , stk , ( UChar * ) str , reg ) ; if ( r < 0 ) { best_len = r ; goto finish ; } } # endif # ifdef USE_POSIX_API_REGION_OPTION } # endif } } # ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE end_best_len : # endif MOP_OUT ; if ( IS_FIND_CONDITION ( option ) ) { if ( IS_FIND_NOT_EMPTY ( option ) && s == sstart ) { best_len = ONIG_MISMATCH ; goto fail ; } if ( IS_FIND_LONGEST ( option ) && DATA_ENSURE_CHECK1 ) { goto fail ; } } goto finish ; break ; case OP_EXACT1 : MOP_IN ( OP_EXACT1 ) ; # if 0 DATA_ENSURE ( 1 ) ; if ( * p != * s ) goto fail ; p ++ ; s ++ ; # endif if ( * p != * s ++ ) goto fail ; DATA_ENSURE ( 0 ) ; p ++ ; MOP_OUT ; break ; case OP_EXACT1_IC : MOP_IN ( OP_EXACT1_IC ) ; { int len ; UChar * q , lowbuf [ ONIGENC_MBC_CASE_FOLD_MAXLEN ] ; DATA_ENSURE ( 1 ) ; len = ONIGENC_MBC_CASE_FOLD ( encode , case_fold_flag , & s , end , lowbuf ) ; DATA_ENSURE ( 0 ) ; q = lowbuf ; while ( len -- > 0 ) { if ( * p != * q ) { goto fail ; } p ++ ; q ++ ; } } MOP_OUT ; break ; case OP_EXACT2 : MOP_IN ( OP_EXACT2 ) ; DATA_ENSURE ( 2 ) ; if ( * p != * s ) goto fail ; p ++ ; s ++ ; if ( * p != * s ) goto fail ; sprev = s ; p ++ ; s ++ ; MOP_OUT ; continue ; break ; case OP_EXACT3 : MOP_IN ( OP_EXACT3 ) ; DATA_ENSURE ( 3 ) ; if ( * p != * s ) goto fail ; p ++ ; s ++ ; if ( * p != * s ) goto fail ; p ++ ; s ++ ; if ( * p != * s ) goto fail ; sprev = s ; p ++ ; s ++ ; MOP_OUT ; continue ; break ; case OP_EXACT4 : MOP_IN ( OP_EXACT4 ) ; DATA_ENSURE ( 4 ) ; if ( * p != * s ) goto fail ; p ++ ; s ++ ; if ( * p != * s ) goto fail ; p ++ ; s ++ ; if ( * p != * s ) goto fail ; p ++ ; s ++ ; if ( * p != * s ) goto fail ; sprev = s ; p ++ ; s ++ ; MOP_OUT ; continue ; break ; case OP_EXACT5 : MOP_IN ( OP_EXACT5 ) ; DATA_ENSURE ( 5 ) ; if ( * p != * s ) goto fail ; p ++ ; s ++ ; if ( * p != * s ) goto fail ; p ++ ; s ++ ; if ( * p != * s ) goto fail ; p ++ ; s ++ ; if ( * p != * s ) goto fail ; p ++ ; s ++ ; if ( * p != * s ) goto fail ; sprev = s ; p ++ ; s ++ ; MOP_OUT ; continue ; break ; case OP_EXACTN : MOP_IN ( OP_EXACTN ) ; GET_LENGTH_INC ( tlen , p ) ; DATA_ENSURE ( tlen ) ; while ( tlen -- > 0 ) { if ( * p ++ != * s ++ ) goto fail ; } sprev = s - 1 ; MOP_OUT ; continue ; break ; case OP_EXACTN_IC : MOP_IN ( OP_EXACTN_IC ) ; { int len ; UChar * q , * endp , lowbuf [ ONIGENC_MBC_CASE_FOLD_MAXLEN ] ; GET_LENGTH_INC ( tlen , p ) ; endp = p + tlen ; while ( p < endp ) { sprev = s ; DATA_ENSURE ( 1 ) ; len = ONIGENC_MBC_CASE_FOLD ( encode , case_fold_flag , & s , end , lowbuf ) ; DATA_ENSURE ( 0 ) ; q = lowbuf ; while ( len -- > 0 ) { if ( * p != * q ) goto fail ; p ++ ; q ++ ; } } } MOP_OUT ; continue ; break ; case OP_EXACTMB2N1 : MOP_IN ( OP_EXACTMB2N1 ) ; DATA_ENSURE ( 2 ) ; if ( * p != * s ) goto fail ; p ++ ; s ++ ; if ( * p != * s ) goto fail ; p ++ ; s ++ ; MOP_OUT ; break ; case OP_EXACTMB2N2 : MOP_IN ( OP_EXACTMB2N2 ) ; DATA_ENSURE ( 4 ) ; if ( * p != * s ) goto fail ; p ++ ; s ++ ; if ( * p != * s ) goto fail ; p ++ ; s ++ ; sprev = s ; if ( * p != * s ) goto fail ; p ++ ; s ++ ; if ( * p != * s ) goto fail ; p ++ ; s ++ ; MOP_OUT ; continue ; break ; case OP_EXACTMB2N3 : MOP_IN ( OP_EXACTMB2N3 ) ; DATA_ENSURE ( 6 ) ; if ( * p != * s ) goto fail ; p ++ ; s ++ ; if ( * p != * s ) goto fail ; p ++ ; s ++ ; if ( * p != * s ) goto fail ; p ++ ; s ++ ; if ( * p != * s ) goto fail ; p ++ ; s ++ ; sprev = s ; if ( * p != * s ) goto fail ; p ++ ; s ++ ; if ( * p != * s ) goto fail ; p ++ ; s ++ ; MOP_OUT ; continue ; break ; case OP_EXACTMB2N : MOP_IN ( OP_EXACTMB2N ) ; GET_LENGTH_INC ( tlen , p ) ; DATA_ENSURE ( tlen * 2 ) ; while ( tlen -- > 0 ) { if ( * p != * s ) goto fail ; p ++ ; s ++ ; if ( * p != * s ) goto fail ; p ++ ; s ++ ; } sprev = s - 2 ; MOP_OUT ; continue ; break ; case OP_EXACTMB3N : MOP_IN ( OP_EXACTMB3N ) ; GET_LENGTH_INC ( tlen , p ) ; DATA_ENSURE ( tlen * 3 ) ; while ( tlen -- > 0 ) { if ( * p != * s ) goto fail ; p ++ ; s ++ ; if ( * p != * s ) goto fail ; p ++ ; s ++ ; if ( * p != * s ) goto fail ; p ++ ; s ++ ; } sprev = s - 3 ; MOP_OUT ; continue ; break ; case OP_EXACTMBN : MOP_IN ( OP_EXACTMBN ) ; GET_LENGTH_INC ( tlen , p ) ; GET_LENGTH_INC ( tlen2 , p ) ; tlen2 *= tlen ; DATA_ENSURE ( tlen2 ) ; while ( tlen2 -- > 0 ) { if ( * p != * s ) goto fail ; p ++ ; s ++ ; } sprev = s - tlen ; MOP_OUT ; continue ; break ; case OP_CCLASS : MOP_IN ( OP_CCLASS ) ; DATA_ENSURE ( 1 ) ; if ( BITSET_AT ( ( ( BitSetRef ) p ) , * s ) == 0 ) goto fail ; p += SIZE_BITSET ; s += enclen ( encode , s ) ; MOP_OUT ; break ; case OP_CCLASS_MB : MOP_IN ( OP_CCLASS_MB ) ; if ( ! ONIGENC_IS_MBC_HEAD ( encode , s ) ) goto fail ; cclass_mb : GET_LENGTH_INC ( tlen , p ) ; { OnigCodePoint code ; UChar * ss ; int mb_len ; DATA_ENSURE ( 1 ) ; mb_len = enclen ( encode , s ) ; DATA_ENSURE ( mb_len ) ; ss = s ; s += mb_len ; code = ONIGENC_MBC_TO_CODE ( encode , ss , s ) ; # ifdef PLATFORM_UNALIGNED_WORD_ACCESS if ( ! onig_is_in_code_range ( p , code ) ) goto fail ; # else q = p ; ALIGNMENT_RIGHT ( q ) ; if ( ! onig_is_in_code_range ( q , code ) ) goto fail ; # endif } p += tlen ; MOP_OUT ; break ; case OP_CCLASS_MIX : MOP_IN ( OP_CCLASS_MIX ) ; DATA_ENSURE ( 1 ) ; if ( ONIGENC_IS_MBC_HEAD ( encode , s ) ) { p += SIZE_BITSET ; goto cclass_mb ; } else { if ( BITSET_AT ( ( ( BitSetRef ) p ) , * s ) == 0 ) goto fail ; p += SIZE_BITSET ; GET_LENGTH_INC ( tlen , p ) ; p += tlen ; s ++ ; } MOP_OUT ; break ; case OP_CCLASS_NOT : MOP_IN ( OP_CCLASS_NOT ) ; DATA_ENSURE ( 1 ) ; if ( BITSET_AT ( ( ( BitSetRef ) p ) , * s ) != 0 ) goto fail ; p += SIZE_BITSET ; s += enclen ( encode , s ) ; MOP_OUT ; break ; case OP_CCLASS_MB_NOT : MOP_IN ( OP_CCLASS_MB_NOT ) ; DATA_ENSURE ( 1 ) ; if ( ! ONIGENC_IS_MBC_HEAD ( encode , s ) ) { s ++ ; GET_LENGTH_INC ( tlen , p ) ; p += tlen ; goto cc_mb_not_success ; } cclass_mb_not : GET_LENGTH_INC ( tlen , p ) ; { OnigCodePoint code ; UChar * ss ; int mb_len = enclen ( encode , s ) ; if ( ! DATA_ENSURE_CHECK ( mb_len ) ) { DATA_ENSURE ( 1 ) ; s = ( UChar * ) end ; p += tlen ; goto cc_mb_not_success ; } ss = s ; s += mb_len ; code = ONIGENC_MBC_TO_CODE ( encode , ss , s ) ; # ifdef PLATFORM_UNALIGNED_WORD_ACCESS if ( onig_is_in_code_range ( p , code ) ) goto fail ; # else q = p ; ALIGNMENT_RIGHT ( q ) ; if ( onig_is_in_code_range ( q , code ) ) goto fail ; # endif } p += tlen ; cc_mb_not_success : MOP_OUT ; break ; case OP_CCLASS_MIX_NOT : MOP_IN ( OP_CCLASS_MIX_NOT ) ; DATA_ENSURE ( 1 ) ; if ( ONIGENC_IS_MBC_HEAD ( encode , s ) ) { p += SIZE_BITSET ; goto cclass_mb_not ; } else { if ( BITSET_AT ( ( ( BitSetRef ) p ) , * s ) != 0 ) goto fail ; p += SIZE_BITSET ; GET_LENGTH_INC ( tlen , p ) ; p += tlen ; s ++ ; } MOP_OUT ; break ; case OP_CCLASS_NODE : MOP_IN ( OP_CCLASS_NODE ) ; { OnigCodePoint code ; void * node ; int mb_len ; UChar * ss ; DATA_ENSURE ( 1 ) ; GET_POINTER_INC ( node , p ) ; mb_len = enclen ( encode , s ) ; ss = s ; s += mb_len ; DATA_ENSURE ( 0 ) ; code = ONIGENC_MBC_TO_CODE ( encode , ss , s ) ; if ( onig_is_code_in_cc_len ( mb_len , code , node ) == 0 ) goto fail ; } MOP_OUT ; break ; case OP_ANYCHAR : MOP_IN ( OP_ANYCHAR ) ; DATA_ENSURE ( 1 ) ; n = enclen ( encode , s ) ; DATA_ENSURE ( n ) ; if ( ONIGENC_IS_MBC_NEWLINE ( encode , s , end ) ) goto fail ; s += n ; MOP_OUT ; break ; case OP_ANYCHAR_ML : MOP_IN ( OP_ANYCHAR_ML ) ; DATA_ENSURE ( 1 ) ; n = enclen ( encode , s ) ; DATA_ENSURE ( n ) ; s += n ; MOP_OUT ; break ; case OP_ANYCHAR_STAR : MOP_IN ( OP_ANYCHAR_STAR ) ; while ( DATA_ENSURE_CHECK1 ) { STACK_PUSH_ALT ( p , s , sprev ) ; n = enclen ( encode , s ) ; DATA_ENSURE ( n ) ; if ( ONIGENC_IS_MBC_NEWLINE ( encode , s , end ) ) goto fail ; sprev = s ; s += n ; } MOP_OUT ; break ; case OP_ANYCHAR_ML_STAR : MOP_IN ( OP_ANYCHAR_ML_STAR ) ; while ( DATA_ENSURE_CHECK1 ) { STACK_PUSH_ALT ( p , s , sprev ) ; n = enclen ( encode , s ) ; if ( n > 1 ) { DATA_ENSURE ( n ) ; sprev = s ; s += n ; } else { sprev = s ; s ++ ; } } MOP_OUT ; break ; case OP_ANYCHAR_STAR_PEEK_NEXT : MOP_IN ( OP_ANYCHAR_STAR_PEEK_NEXT ) ; while ( DATA_ENSURE_CHECK1 ) { if ( * p == * s ) { STACK_PUSH_ALT ( p + 1 , s , sprev ) ; } n = enclen ( encode , s ) ; DATA_ENSURE ( n ) ; if ( ONIGENC_IS_MBC_NEWLINE ( encode , s , end ) ) goto fail ; sprev = s ; s += n ; } p ++ ; MOP_OUT ; break ; case OP_ANYCHAR_ML_STAR_PEEK_NEXT : MOP_IN ( OP_ANYCHAR_ML_STAR_PEEK_NEXT ) ; while ( DATA_ENSURE_CHECK1 ) { if ( * p == * s ) { STACK_PUSH_ALT ( p + 1 , s , sprev ) ; } n = enclen ( encode , s ) ; if ( n > 1 ) { DATA_ENSURE ( n ) ; sprev = s ; s += n ; } else { sprev = s ; s ++ ; } } p ++ ; MOP_OUT ; break ; # ifdef USE_COMBINATION_EXPLOSION_CHECK case OP_STATE_CHECK_ANYCHAR_STAR : MOP_IN ( OP_STATE_CHECK_ANYCHAR_STAR ) ; GET_STATE_CHECK_NUM_INC ( mem , p ) ; while ( DATA_ENSURE_CHECK1 ) { STATE_CHECK_VAL ( scv , mem ) ; if ( scv ) goto fail ; STACK_PUSH_ALT_WITH_STATE_CHECK ( p , s , sprev , mem ) ; n = enclen ( encode , s ) ; DATA_ENSURE ( n ) ; if ( ONIGENC_IS_MBC_NEWLINE ( encode , s , end ) ) goto fail ; sprev = s ; s += n ; } MOP_OUT ; break ; case OP_STATE_CHECK_ANYCHAR_ML_STAR : MOP_IN ( OP_STATE_CHECK_ANYCHAR_ML_STAR ) ; GET_STATE_CHECK_NUM_INC ( mem , p ) ; while ( DATA_ENSURE_CHECK1 ) { STATE_CHECK_VAL ( scv , mem ) ; if ( scv ) goto fail ; STACK_PUSH_ALT_WITH_STATE_CHECK ( p , s , sprev , mem ) ; n = enclen ( encode , s ) ; if ( n > 1 ) { DATA_ENSURE ( n ) ; sprev = s ; s += n ; } else { sprev = s ; s ++ ; } } MOP_OUT ; break ; # endif case OP_WORD : MOP_IN ( OP_WORD ) ; DATA_ENSURE ( 1 ) ; if ( ! ONIGENC_IS_MBC_WORD ( encode , s , end ) ) goto fail ; s += enclen ( encode , s ) ; MOP_OUT ; break ; case OP_NOT_WORD : MOP_IN ( OP_NOT_WORD ) ; DATA_ENSURE ( 1 ) ; if ( ONIGENC_IS_MBC_WORD ( encode , s , end ) ) goto fail ; s += enclen ( encode , s ) ; MOP_OUT ; break ; case OP_WORD_BOUND : MOP_IN ( OP_WORD_BOUND ) ; if ( ON_STR_BEGIN ( s ) ) { DATA_ENSURE ( 1 ) ; if ( ! ONIGENC_IS_MBC_WORD ( encode , s , end ) ) goto fail ; } else if ( ON_STR_END ( s ) ) { if ( ! ONIGENC_IS_MBC_WORD ( encode , sprev , end ) ) goto fail ; } else { if ( ONIGENC_IS_MBC_WORD ( encode , s , end ) == ONIGENC_IS_MBC_WORD ( encode , sprev , end ) ) goto fail ; } MOP_OUT ; continue ; break ; case OP_NOT_WORD_BOUND : MOP_IN ( OP_NOT_WORD_BOUND ) ; if ( ON_STR_BEGIN ( s ) ) { if ( DATA_ENSURE_CHECK1 && ONIGENC_IS_MBC_WORD ( encode , s , end ) ) goto fail ; } else if ( ON_STR_END ( s ) ) { if ( ONIGENC_IS_MBC_WORD ( encode , sprev , end ) ) goto fail ; } else { if ( ONIGENC_IS_MBC_WORD ( encode , s , end ) != ONIGENC_IS_MBC_WORD ( encode , sprev , end ) ) goto fail ; } MOP_OUT ; continue ; break ; # ifdef USE_WORD_BEGIN_END case OP_WORD_BEGIN : MOP_IN ( OP_WORD_BEGIN ) ; if ( DATA_ENSURE_CHECK1 && ONIGENC_IS_MBC_WORD ( encode , s , end ) ) { if ( ON_STR_BEGIN ( s ) || ! ONIGENC_IS_MBC_WORD ( encode , sprev , end ) ) { MOP_OUT ; continue ; } } goto fail ; break ; case OP_WORD_END : MOP_IN ( OP_WORD_END ) ; if ( ! ON_STR_BEGIN ( s ) && ONIGENC_IS_MBC_WORD ( encode , sprev , end ) ) { if ( ON_STR_END ( s ) || ! ONIGENC_IS_MBC_WORD ( encode , s , end ) ) { MOP_OUT ; continue ; } } goto fail ; break ; # endif case OP_BEGIN_BUF : MOP_IN ( OP_BEGIN_BUF ) ; if ( ! ON_STR_BEGIN ( s ) ) goto fail ; MOP_OUT ; continue ; break ; case OP_END_BUF : MOP_IN ( OP_END_BUF ) ; if ( ! ON_STR_END ( s ) ) goto fail ; MOP_OUT ; continue ; break ; case OP_BEGIN_LINE : MOP_IN ( OP_BEGIN_LINE ) ; if ( ON_STR_BEGIN ( s ) ) { if ( IS_NOTBOL ( msa -> options ) ) goto fail ; MOP_OUT ; continue ; } else if ( ONIGENC_IS_MBC_NEWLINE ( encode , sprev , end ) && ! ON_STR_END ( s ) ) { MOP_OUT ; continue ; } goto fail ; break ; case OP_END_LINE : MOP_IN ( OP_END_LINE ) ; if ( ON_STR_END ( s ) ) { # ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE if ( IS_EMPTY_STR || ! ONIGENC_IS_MBC_NEWLINE ( encode , sprev , end ) ) { # endif if ( IS_NOTEOL ( msa -> options ) ) goto fail ; MOP_OUT ; continue ; # ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE } # endif } else if ( ONIGENC_IS_MBC_NEWLINE ( encode , s , end ) ) { MOP_OUT ; continue ; } # ifdef USE_CRNL_AS_LINE_TERMINATOR else if ( ONIGENC_IS_MBC_CRNL ( encode , s , end ) ) { MOP_OUT ; continue ; } # endif goto fail ; break ; case OP_SEMI_END_BUF : MOP_IN ( OP_SEMI_END_BUF ) ; if ( ON_STR_END ( s ) ) { # ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE if ( IS_EMPTY_STR || ! ONIGENC_IS_MBC_NEWLINE ( encode , sprev , end ) ) { # endif if ( IS_NOTEOL ( msa -> options ) ) goto fail ; MOP_OUT ; continue ; # ifndef USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE } # endif } else if ( ONIGENC_IS_MBC_NEWLINE ( encode , s , end ) && ON_STR_END ( s + enclen ( encode , s ) ) ) { MOP_OUT ; continue ; } # ifdef USE_CRNL_AS_LINE_TERMINATOR else if ( ONIGENC_IS_MBC_CRNL ( encode , s , end ) ) { UChar * ss = s + enclen ( encode , s ) ; ss += enclen ( encode , ss ) ; if ( ON_STR_END ( ss ) ) { MOP_OUT ; continue ; } } # endif goto fail ; break ; case OP_BEGIN_POSITION : MOP_IN ( OP_BEGIN_POSITION ) ; if ( s != msa -> start ) goto fail ; MOP_OUT ; continue ; break ; case OP_MEMORY_START_PUSH : MOP_IN ( OP_MEMORY_START_PUSH ) ; GET_MEMNUM_INC ( mem , p ) ; STACK_PUSH_MEM_START ( mem , s ) ; MOP_OUT ; continue ; break ; case OP_MEMORY_START : MOP_IN ( OP_MEMORY_START ) ; GET_MEMNUM_INC ( mem , p ) ; mem_start_stk [ mem ] = ( OnigStackIndex ) ( ( void * ) s ) ; MOP_OUT ; continue ; break ; case OP_MEMORY_END_PUSH : MOP_IN ( OP_MEMORY_END_PUSH ) ; GET_MEMNUM_INC ( mem , p ) ; STACK_PUSH_MEM_END ( mem , s ) ; MOP_OUT ; continue ; break ; case OP_MEMORY_END : MOP_IN ( OP_MEMORY_END ) ; GET_MEMNUM_INC ( mem , p ) ; mem_end_stk [ mem ] = ( OnigStackIndex ) ( ( void * ) s ) ; MOP_OUT ; continue ; break ; # ifdef USE_SUBEXP_CALL case OP_MEMORY_END_PUSH_REC : MOP_IN ( OP_MEMORY_END_PUSH_REC ) ; GET_MEMNUM_INC ( mem , p ) ; STACK_GET_MEM_START ( mem , stkp ) ; STACK_PUSH_MEM_END ( mem , s ) ; mem_start_stk [ mem ] = GET_STACK_INDEX ( stkp ) ; MOP_OUT ; continue ; break ; case OP_MEMORY_END_REC : MOP_IN ( OP_MEMORY_END_REC ) ; GET_MEMNUM_INC ( mem , p ) ; mem_end_stk [ mem ] = ( OnigStackIndex ) ( ( void * ) s ) ; STACK_GET_MEM_START ( mem , stkp ) ; if ( BIT_STATUS_AT ( reg -> bt_mem_start , mem ) ) mem_start_stk [ mem ] = GET_STACK_INDEX ( stkp ) ; else mem_start_stk [ mem ] = ( OnigStackIndex ) ( ( void * ) stkp -> u . mem . pstr ) ; STACK_PUSH_MEM_END_MARK ( mem ) ; MOP_OUT ; continue ; break ; # endif case OP_BACKREF1 : MOP_IN ( OP_BACKREF1 ) ; mem = 1 ; goto backref ; break ; case OP_BACKREF2 : MOP_IN ( OP_BACKREF2 ) ; mem = 2 ; goto backref ; break ; case OP_BACKREFN : MOP_IN ( OP_BACKREFN ) ; GET_MEMNUM_INC ( mem , p ) ; backref : { int len ; UChar * pstart , * pend ; if ( mem > num_mem ) goto fail ; if ( mem_end_stk [ mem ] == INVALID_STACK_INDEX ) goto fail ; if ( mem_start_stk [ mem ] == INVALID_STACK_INDEX ) goto fail ; if ( BIT_STATUS_AT ( reg -> bt_mem_start , mem ) ) pstart = STACK_AT ( mem_start_stk [ mem ] ) -> u . mem . pstr ; else pstart = ( UChar * ) ( ( void * ) mem_start_stk [ mem ] ) ; pend = ( BIT_STATUS_AT ( reg -> bt_mem_end , mem ) ? STACK_AT ( mem_end_stk [ mem ] ) -> u . mem . pstr : ( UChar * ) ( ( void * ) mem_end_stk [ mem ] ) ) ; n = pend - pstart ; DATA_ENSURE ( n ) ; sprev = s ; STRING_CMP ( pstart , s , n ) ; while ( sprev + ( len = enclen ( encode , sprev ) ) < s ) sprev += len ; MOP_OUT ; continue ; } break ; case OP_BACKREFN_IC : MOP_IN ( OP_BACKREFN_IC ) ; GET_MEMNUM_INC ( mem , p ) ; { int len ; UChar * pstart , * pend ; if ( mem > num_mem ) goto fail ; if ( mem_end_stk [ mem ] == INVALID_STACK_INDEX ) goto fail ; if ( mem_start_stk [ mem ] == INVALID_STACK_INDEX ) goto fail ; if ( BIT_STATUS_AT ( reg -> bt_mem_start , mem ) ) pstart = STACK_AT ( mem_start_stk [ mem ] ) -> u . mem . pstr ; else pstart = ( UChar * ) ( ( void * ) mem_start_stk [ mem ] ) ; pend = ( BIT_STATUS_AT ( reg -> bt_mem_end , mem ) ? STACK_AT ( mem_end_stk [ mem ] ) -> u . mem . pstr : ( UChar * ) ( ( void * ) mem_end_stk [ mem ] ) ) ; n = pend - pstart ; DATA_ENSURE ( n ) ; sprev = s ; STRING_CMP_IC ( case_fold_flag , pstart , & s , n ) ; while ( sprev + ( len = enclen ( encode , sprev ) ) < s ) sprev += len ; MOP_OUT ; continue ; } break ; case OP_BACKREF_MULTI : MOP_IN ( OP_BACKREF_MULTI ) ; { int len , is_fail ; UChar * pstart , * pend , * swork ; GET_LENGTH_INC ( tlen , p ) ; for ( i = 0 ; i < tlen ; i ++ ) { GET_MEMNUM_INC ( mem , p ) ; if ( mem_end_stk [ mem ] == INVALID_STACK_INDEX ) continue ; if ( mem_start_stk [ mem ] == INVALID_STACK_INDEX ) continue ; if ( BIT_STATUS_AT ( reg -> bt_mem_start , mem ) ) pstart = STACK_AT ( mem_start_stk [ mem ] ) -> u . mem . pstr ; else pstart = ( UChar * ) ( ( void * ) mem_start_stk [ mem ] ) ; pend = ( BIT_STATUS_AT ( reg -> bt_mem_end , mem ) ? STACK_AT ( mem_end_stk [ mem ] ) -> u . mem . pstr : ( UChar * ) ( ( void * ) mem_end_stk [ mem ] ) ) ; n = pend - pstart ; DATA_ENSURE ( n ) ; sprev = s ; swork = s ; STRING_CMP_VALUE ( pstart , swork , n , is_fail ) ; if ( is_fail ) continue ; s = swork ; while ( sprev + ( len = enclen ( encode , sprev ) ) < s ) sprev += len ; p += ( SIZE_MEMNUM * ( tlen - i - 1 ) ) ; break ; } if ( i == tlen ) goto fail ; MOP_OUT ; continue ; } break ; case OP_BACKREF_MULTI_IC : MOP_IN ( OP_BACKREF_MULTI_IC ) ; { int len , is_fail ; UChar * pstart , * pend , * swork ; GET_LENGTH_INC ( tlen , p ) ; for ( i = 0 ; i < tlen ; i ++ ) { GET_MEMNUM_INC ( mem , p ) ; if ( mem_end_stk [ mem ] == INVALID_STACK_INDEX ) continue ; if ( mem_start_stk [ mem ] == INVALID_STACK_INDEX ) continue ; if ( BIT_STATUS_AT ( reg -> bt_mem_start , mem ) ) pstart = STACK_AT ( mem_start_stk [ mem ] ) -> u . mem . pstr ; else pstart = ( UChar * ) ( ( void * ) mem_start_stk [ mem ] ) ; pend = ( BIT_STATUS_AT ( reg -> bt_mem_end , mem ) ? STACK_AT ( mem_end_stk [ mem ] ) -> u . mem . pstr : ( UChar * ) ( ( void * ) mem_end_stk [ mem ] ) ) ; n = pend - pstart ; DATA_ENSURE ( n ) ; sprev = s ; swork = s ; STRING_CMP_VALUE_IC ( case_fold_flag , pstart , & swork , n , is_fail ) ; if ( is_fail ) continue ; s = swork ; while ( sprev + ( len = enclen ( encode , sprev ) ) < s ) sprev += len ; p += ( SIZE_MEMNUM * ( tlen - i - 1 ) ) ; break ; } if ( i == tlen ) goto fail ; MOP_OUT ; continue ; } break ; # ifdef USE_BACKREF_WITH_LEVEL case OP_BACKREF_WITH_LEVEL : { int len ; OnigOptionType ic ; LengthType level ; GET_OPTION_INC ( ic , p ) ; GET_LENGTH_INC ( level , p ) ; GET_LENGTH_INC ( tlen , p ) ; sprev = s ; if ( backref_match_at_nested_level ( reg , stk , stk_base , ic , case_fold_flag , ( int ) level , ( int ) tlen , p , & s , end ) ) { while ( sprev + ( len = enclen ( encode , sprev ) ) < s ) sprev += len ; p += ( SIZE_MEMNUM * tlen ) ; } else goto fail ; MOP_OUT ; continue ; } break ; # endif # if 0 case OP_SET_OPTION_PUSH : MOP_IN ( OP_SET_OPTION_PUSH ) ; GET_OPTION_INC ( option , p ) ; STACK_PUSH_ALT ( p , s , sprev ) ; p += SIZE_OP_SET_OPTION + SIZE_OP_FAIL ; MOP_OUT ; continue ; break ; case OP_SET_OPTION : MOP_IN ( OP_SET_OPTION ) ; GET_OPTION_INC ( option , p ) ; MOP_OUT ; continue ; break ; # endif case OP_NULL_CHECK_START : MOP_IN ( OP_NULL_CHECK_START ) ; GET_MEMNUM_INC ( mem , p ) ; STACK_PUSH_NULL_CHECK_START ( mem , s ) ; MOP_OUT ; continue ; break ; case OP_NULL_CHECK_END : MOP_IN ( OP_NULL_CHECK_END ) ; { int isnull ; GET_MEMNUM_INC ( mem , p ) ; STACK_NULL_CHECK ( isnull , mem , s ) ; if ( isnull ) { # ifdef ONIG_DEBUG_MATCH fprintf ( stderr , ""NULL_CHECK_END:skipid:%d,s:%d\\n"" , ( int ) mem , ( int ) s ) ; # endif null_check_found : switch ( * p ++ ) { case OP_JUMP : case OP_PUSH : p += SIZE_RELADDR ; break ; case OP_REPEAT_INC : case OP_REPEAT_INC_NG : case OP_REPEAT_INC_SG : case OP_REPEAT_INC_NG_SG : p += SIZE_MEMNUM ; break ; default : goto unexpected_bytecode_error ; break ; } } } MOP_OUT ; continue ; break ; # ifdef USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT case OP_NULL_CHECK_END_MEMST : MOP_IN ( OP_NULL_CHECK_END_MEMST ) ; { int isnull ; GET_MEMNUM_INC ( mem , p ) ; STACK_NULL_CHECK_MEMST ( isnull , mem , s , reg ) ; if ( isnull ) { # ifdef ONIG_DEBUG_MATCH fprintf ( stderr , ""NULL_CHECK_END_MEMST:skipid:%d,s:%d\\n"" , ( int ) mem , ( int ) s ) ; # endif if ( isnull == - 1 ) goto fail ; goto null_check_found ; } } MOP_OUT ; continue ; break ; # endif # ifdef USE_SUBEXP_CALL case OP_NULL_CHECK_END_MEMST_PUSH : MOP_IN ( OP_NULL_CHECK_END_MEMST_PUSH ) ; { int isnull ; GET_MEMNUM_INC ( mem , p ) ; # ifdef USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT STACK_NULL_CHECK_MEMST_REC ( isnull , mem , s , reg ) ; # else STACK_NULL_CHECK_REC ( isnull , mem , s ) ; # endif if ( isnull ) { # ifdef ONIG_DEBUG_MATCH fprintf ( stderr , ""NULL_CHECK_END_MEMST_PUSH:skipid:%d,s:%d\\n"" , ( int ) mem , ( int ) s ) ; # endif if ( isnull == - 1 ) goto fail ; goto null_check_found ; } else { STACK_PUSH_NULL_CHECK_END ( mem ) ; } } MOP_OUT ; continue ; break ; # endif case OP_JUMP : MOP_IN ( OP_JUMP ) ; GET_RELADDR_INC ( addr , p ) ; p += addr ; MOP_OUT ; CHECK_INTERRUPT_IN_MATCH_AT ; continue ; break ; case OP_PUSH : MOP_IN ( OP_PUSH ) ; GET_RELADDR_INC ( addr , p ) ; STACK_PUSH_ALT ( p + addr , s , sprev ) ; MOP_OUT ; continue ; break ; # ifdef USE_COMBINATION_EXPLOSION_CHECK case OP_STATE_CHECK_PUSH : MOP_IN ( OP_STATE_CHECK_PUSH ) ; GET_STATE_CHECK_NUM_INC ( mem , p ) ; STATE_CHECK_VAL ( scv , mem ) ; if ( scv ) goto fail ; GET_RELADDR_INC ( addr , p ) ; STACK_PUSH_ALT_WITH_STATE_CHECK ( p + addr , s , sprev , mem ) ; MOP_OUT ; continue ; break ; case OP_STATE_CHECK_PUSH_OR_JUMP : MOP_IN ( OP_STATE_CHECK_PUSH_OR_JUMP ) ; GET_STATE_CHECK_NUM_INC ( mem , p ) ; GET_RELADDR_INC ( addr , p ) ; STATE_CHECK_VAL ( scv , mem ) ; if ( scv ) { p += addr ; } else { STACK_PUSH_ALT_WITH_STATE_CHECK ( p + addr , s , sprev , mem ) ; } MOP_OUT ; continue ; break ; case OP_STATE_CHECK : MOP_IN ( OP_STATE_CHECK ) ; GET_STATE_CHECK_NUM_INC ( mem , p ) ; STATE_CHECK_VAL ( scv , mem ) ; if ( scv ) goto fail ; STACK_PUSH_STATE_CHECK ( s , mem ) ; MOP_OUT ; continue ; break ; # endif case OP_POP : MOP_IN ( OP_POP ) ; STACK_POP_ONE ; MOP_OUT ; continue ; break ; case OP_PUSH_OR_JUMP_EXACT1 : MOP_IN ( OP_PUSH_OR_JUMP_EXACT1 ) ; GET_RELADDR_INC ( addr , p ) ; if ( * p == * s && DATA_ENSURE_CHECK1 ) { p ++ ; STACK_PUSH_ALT ( p + addr , s , sprev ) ; MOP_OUT ; continue ; } p += ( addr + 1 ) ; MOP_OUT ; continue ; break ; case OP_PUSH_IF_PEEK_NEXT : MOP_IN ( OP_PUSH_IF_PEEK_NEXT ) ; GET_RELADDR_INC ( addr , p ) ; if ( * p == * s ) { p ++ ; STACK_PUSH_ALT ( p + addr , s , sprev ) ; MOP_OUT ; continue ; } p ++ ; MOP_OUT ; continue ; break ; case OP_REPEAT : MOP_IN ( OP_REPEAT ) ; { GET_MEMNUM_INC ( mem , p ) ; GET_RELADDR_INC ( addr , p ) ; STACK_ENSURE ( 1 ) ; repeat_stk [ mem ] = GET_STACK_INDEX ( stk ) ; STACK_PUSH_REPEAT ( mem , p ) ; if ( reg -> repeat_range [ mem ] . lower == 0 ) { STACK_PUSH_ALT ( p + addr , s , sprev ) ; } } MOP_OUT ; continue ; break ; case OP_REPEAT_NG : MOP_IN ( OP_REPEAT_NG ) ; { GET_MEMNUM_INC ( mem , p ) ; GET_RELADDR_INC ( addr , p ) ; STACK_ENSURE ( 1 ) ; repeat_stk [ mem ] = GET_STACK_INDEX ( stk ) ; STACK_PUSH_REPEAT ( mem , p ) ; if ( reg -> repeat_range [ mem ] . lower == 0 ) { STACK_PUSH_ALT ( p , s , sprev ) ; p += addr ; } } MOP_OUT ; continue ; break ; case OP_REPEAT_INC : MOP_IN ( OP_REPEAT_INC ) ; GET_MEMNUM_INC ( mem , p ) ; si = repeat_stk [ mem ] ; stkp = STACK_AT ( si ) ; repeat_inc : stkp -> u . repeat . count ++ ; if ( stkp -> u . repeat . count >= reg -> repeat_range [ mem ] . upper ) { } else if ( stkp -> u . repeat . count >= reg -> repeat_range [ mem ] . lower ) { STACK_PUSH_ALT ( p , s , sprev ) ; p = STACK_AT ( si ) -> u . repeat . pcode ; } else { p = stkp -> u . repeat . pcode ; } STACK_PUSH_REPEAT_INC ( si ) ; MOP_OUT ; CHECK_INTERRUPT_IN_MATCH_AT ; continue ; break ; case OP_REPEAT_INC_SG : MOP_IN ( OP_REPEAT_INC_SG ) ; GET_MEMNUM_INC ( mem , p ) ; STACK_GET_REPEAT ( mem , stkp ) ; si = GET_STACK_INDEX ( stkp ) ; goto repeat_inc ; break ; case OP_REPEAT_INC_NG : MOP_IN ( OP_REPEAT_INC_NG ) ; GET_MEMNUM_INC ( mem , p ) ; si = repeat_stk [ mem ] ; stkp = STACK_AT ( si ) ; repeat_inc_ng : stkp -> u . repeat . count ++ ; if ( stkp -> u . repeat . count < reg -> repeat_range [ mem ] . upper ) { if ( stkp -> u . repeat . count >= reg -> repeat_range [ mem ] . lower ) { UChar * pcode = stkp -> u . repeat . pcode ; STACK_PUSH_REPEAT_INC ( si ) ; STACK_PUSH_ALT ( pcode , s , sprev ) ; } else { p = stkp -> u . repeat . pcode ; STACK_PUSH_REPEAT_INC ( si ) ; } } else if ( stkp -> u . repeat . count == reg -> repeat_range [ mem ] . upper ) { STACK_PUSH_REPEAT_INC ( si ) ; } MOP_OUT ; CHECK_INTERRUPT_IN_MATCH_AT ; continue ; break ; case OP_REPEAT_INC_NG_SG : MOP_IN ( OP_REPEAT_INC_NG_SG ) ; GET_MEMNUM_INC ( mem , p ) ; STACK_GET_REPEAT ( mem , stkp ) ; si = GET_STACK_INDEX ( stkp ) ; goto repeat_inc_ng ; break ; case OP_PUSH_POS : MOP_IN ( OP_PUSH_POS ) ; STACK_PUSH_POS ( s , sprev ) ; MOP_OUT ; continue ; break ; case OP_POP_POS : MOP_IN ( OP_POP_POS ) ; { STACK_POS_END ( stkp ) ; s = stkp -> u . state . pstr ; sprev = stkp -> u . state . pstr_prev ; } MOP_OUT ; continue ; break ; case OP_PUSH_POS_NOT : MOP_IN ( OP_PUSH_POS_NOT ) ; GET_RELADDR_INC ( addr , p ) ; STACK_PUSH_POS_NOT ( p + addr , s , sprev ) ; MOP_OUT ; continue ; break ; case OP_FAIL_POS : MOP_IN ( OP_FAIL_POS ) ; STACK_POP_TIL_POS_NOT ; goto fail ; break ; case OP_PUSH_STOP_BT : MOP_IN ( OP_PUSH_STOP_BT ) ; STACK_PUSH_STOP_BT ; MOP_OUT ; continue ; break ; case OP_POP_STOP_BT : MOP_IN ( OP_POP_STOP_BT ) ; STACK_STOP_BT_END ; MOP_OUT ; continue ; break ; case OP_LOOK_BEHIND : MOP_IN ( OP_LOOK_BEHIND ) ; GET_LENGTH_INC ( tlen , p ) ; s = ( UChar * ) ONIGENC_STEP_BACK ( encode , str , s , ( int ) tlen ) ; if ( IS_NULL ( s ) ) goto fail ; sprev = ( UChar * ) onigenc_get_prev_char_head ( encode , str , s ) ; MOP_OUT ; continue ; break ; case OP_PUSH_LOOK_BEHIND_NOT : MOP_IN ( OP_PUSH_LOOK_BEHIND_NOT ) ; GET_RELADDR_INC ( addr , p ) ; GET_LENGTH_INC ( tlen , p ) ; q = ( UChar * ) ONIGENC_STEP_BACK ( encode , str , s , ( int ) tlen ) ; if ( IS_NULL ( q ) ) { p += addr ; } else { STACK_PUSH_LOOK_BEHIND_NOT ( p + addr , s , sprev ) ; s = q ; sprev = ( UChar * ) onigenc_get_prev_char_head ( encode , str , s ) ; } MOP_OUT ; continue ; break ; case OP_FAIL_LOOK_BEHIND_NOT : MOP_IN ( OP_FAIL_LOOK_BEHIND_NOT ) ; STACK_POP_TIL_LOOK_BEHIND_NOT ; goto fail ; break ; # ifdef USE_SUBEXP_CALL case OP_CALL : MOP_IN ( OP_CALL ) ; GET_ABSADDR_INC ( addr , p ) ; STACK_PUSH_CALL_FRAME ( p ) ; p = reg -> p + addr ; MOP_OUT ; continue ; break ; case OP_RETURN : MOP_IN ( OP_RETURN ) ; STACK_RETURN ( p ) ; STACK_PUSH_RETURN ; MOP_OUT ; continue ; break ; # endif case OP_FINISH : goto finish ; break ; fail : MOP_OUT ; case OP_FAIL : MOP_IN ( OP_FAIL ) ; STACK_POP ; p = stk -> u . state . pcode ; s = stk -> u . state . pstr ; sprev = stk -> u . state . pstr_prev ; # ifdef USE_COMBINATION_EXPLOSION_CHECK if ( stk -> u . state . state_check != 0 ) { stk -> type = STK_STATE_CHECK_MARK ; stk ++ ; } # endif MOP_OUT ; continue ; break ; default : goto bytecode_error ; } sprev = sbegin ; } finish : STACK_SAVE ; return best_len ; # ifdef ONIG_DEBUG stack_error : STACK_SAVE ; return ONIGERR_STACK_BUG ; # endif bytecode_error : STACK_SAVE ; return ONIGERR_UNDEFINED_BYTECODE ; unexpected_bytecode_error : STACK_SAVE ; return ONIGERR_UNEXPECTED_BYTECODE ; } "," OP_EXACT1 ) ; DATA_ENSURE ( 1 ++ ; s ++ ; MOP_OUT ",kkos@oniguruma/690313a061f7a4fa614ec5cc8368b4f2284e059b,CVE-2017-9224,https://github.com/kkos/oniguruma/commit/690313a061f7a4fa614ec5cc8368b4f2284e059b,2017-05-24T15:29Z 1454,CWE-119,"CWE-119 void vp9_foreach_transformed_block ( const MACROBLOCKD * const xd , BLOCK_SIZE bsize , foreach_transformed_block_visitor visit , void * arg ) { int plane ; for ( plane = 0 ; plane < MAX_MB_PLANE ; plane ++ ) vp9_foreach_transformed_block_in_plane ( xd , bsize , plane , visit , arg ) ; } "," < MAX_MB_PLANE ; ++ plane ) vp9_foreach_transformed_block_in_plane ( ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1455,CWE-20,"CWE-20 int vcc_recvmsg ( struct kiocb * iocb , struct socket * sock , struct msghdr * msg , size_t size , int flags ) { struct sock * sk = sock -> sk ; struct atm_vcc * vcc ; struct sk_buff * skb ; int copied , error = - EINVAL ; msg -> msg_namelen = 0 ; if ( sock -> state != SS_CONNECTED ) return - ENOTCONN ; if ( flags & ~ ( MSG_DONTWAIT | MSG_PEEK ) ) return - EOPNOTSUPP ; vcc = ATM_SD ( sock ) ; if ( test_bit ( ATM_VF_RELEASED , & vcc -> flags ) || test_bit ( ATM_VF_CLOSE , & vcc -> flags ) || ! test_bit ( ATM_VF_READY , & vcc -> flags ) ) return 0 ; skb = skb_recv_datagram ( sk , flags , flags & MSG_DONTWAIT , & error ) ; if ( ! skb ) return error ; copied = skb -> len ; if ( copied > size ) { copied = size ; msg -> msg_flags |= MSG_TRUNC ; } error = skb_copy_datagram_iovec ( skb , 0 , msg -> msg_iov , copied ) ; if ( error ) return error ; sock_recv_ts_and_drops ( msg , sk , skb ) ; if ( ! ( flags & MSG_PEEK ) ) { pr_debug ( ""%d-=%d\\n"" , atomic_read ( & sk -> sk_rmem_alloc ) , skb -> truesize ) ; atm_return ( vcc , skb -> truesize ) ; } skb_free_datagram ( sk , skb ) ; return copied ; } "," = - EINVAL ; if ( ",torvalds@linux/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,CVE-2013-7271,https://github.com/torvalds/linux/commit/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,2014-01-06T16:55Z 1456,CWE-59,"CWE-59 static int mount_entry_on_relative_rootfs ( struct mntent * mntent , const char * rootfs ) { char path [ MAXPATHLEN ] ; int ret ; ret = snprintf ( path , sizeof ( path ) , ""%s/%s"" , rootfs , mntent -> mnt_dir ) ; if ( ret >= sizeof ( path ) ) { ERROR ( ""pathnametoolong"" ) ; return - 1 ; } return mount_entry_on_generic ( mntent , path ) ; } "," mntent , path , rootfs ",lxc@lxc/592fd47a6245508b79fe6ac819fe6d3b2c1289be,CVE-2015-1335,https://github.com/lxc/lxc/commit/592fd47a6245508b79fe6ac819fe6d3b2c1289be,2015-10-01T20:59Z 1457,CWE-20,"CWE-20 static inline int mk_vhost_fdt_open ( int id , unsigned int hash , struct session_request * sr ) { int i ; int fd ; struct vhost_fdt_hash_table * ht = NULL ; struct vhost_fdt_hash_chain * hc ; if ( config -> fdt == MK_FALSE ) { return open ( sr -> real_path . data , sr -> file_info . flags_read_only ) ; } ht = mk_vhost_fdt_table_lookup ( id , sr -> host_conf ) ; if ( mk_unlikely ( ! ht ) ) { return open ( sr -> real_path . data , sr -> file_info . flags_read_only ) ; } hc = mk_vhost_fdt_chain_lookup ( hash , ht ) ; if ( hc ) { hc -> readers ++ ; return hc -> fd ; } fd = open ( sr -> real_path . data , sr -> file_info . flags_read_only ) ; if ( fd == - 1 ) { return - 1 ; } if ( ht -> av_slots <= 0 ) { return fd ; } for ( i = 0 ; i < VHOST_FDT_HASHTABLE_CHAINS ; i ++ ) { hc = & ht -> chain [ i ] ; if ( hc -> fd == - 1 ) { hc -> fd = fd ; hc -> hash = hash ; hc -> readers ++ ; ht -> av_slots -- ; sr -> vhost_fdt_id = id ; sr -> vhost_fdt_hash = hash ; return fd ; } } return - 1 ; } "," = hash ; sr -> fd_is_fdt = MK_TRUE ; ",monkey@monkey/b2d0e6f92310bb14a15aa2f8e96e1fb5379776dd,CVE-2014-5336,https://github.com/monkey/monkey/commit/b2d0e6f92310bb14a15aa2f8e96e1fb5379776dd,2014-08-26T14:55Z 1458,CWE-862,"CWE-862 static void construct_get_dest_keyring ( struct key * * _dest_keyring ) { struct request_key_auth * rka ; const struct cred * cred = current_cred ( ) ; struct key * dest_keyring = * _dest_keyring , * authkey ; kenter ( ""%p"" , dest_keyring ) ; if ( dest_keyring ) { key_get ( dest_keyring ) ; } else { switch ( cred -> jit_keyring ) { case KEY_REQKEY_DEFL_DEFAULT : case KEY_REQKEY_DEFL_REQUESTOR_KEYRING : if ( cred -> request_key_auth ) { authkey = cred -> request_key_auth ; down_read ( & authkey -> sem ) ; rka = authkey -> payload . data [ 0 ] ; if ( ! test_bit ( KEY_FLAG_REVOKED , & authkey -> flags ) ) dest_keyring = key_get ( rka -> dest_keyring ) ; up_read ( & authkey -> sem ) ; if ( dest_keyring ) break ; } case KEY_REQKEY_DEFL_THREAD_KEYRING : dest_keyring = key_get ( cred -> thread_keyring ) ; if ( dest_keyring ) break ; case KEY_REQKEY_DEFL_PROCESS_KEYRING : dest_keyring = key_get ( cred -> process_keyring ) ; if ( dest_keyring ) break ; case KEY_REQKEY_DEFL_SESSION_KEYRING : rcu_read_lock ( ) ; dest_keyring = key_get ( rcu_dereference ( cred -> session_keyring ) ) ; rcu_read_unlock ( ) ; if ( dest_keyring ) break ; case KEY_REQKEY_DEFL_USER_SESSION_KEYRING : dest_keyring = key_get ( cred -> user -> session_keyring ) ; break ; case KEY_REQKEY_DEFL_USER_KEYRING : dest_keyring = key_get ( cred -> user -> uid_keyring ) ; break ; case KEY_REQKEY_DEFL_GROUP_KEYRING : default : BUG ( ) ; } } * _dest_keyring = dest_keyring ; kleave ( ""[dk%d]"" , key_serial ( dest_keyring ) ) ; return ; } "," static int construct_get_dest_keyring ( struct * authkey ; int ret ; } else { bool do_perm_check = true ; ( dest_keyring ) { do_perm_check = false ; break ; } } case KEY_REQKEY_DEFL_THREAD_KEYRING ) ; } if ( dest_keyring && do_perm_check ) { ret = key_permission ( make_key_ref ( dest_keyring , 1 ) , KEY_NEED_WRITE ) ; if ( ret ) { key_put ( dest_keyring ) ; return ret ; } } ) ; return 0 ",torvalds@linux/4dca6ea1d9432052afb06baf2e3ae78188a4410b,CVE-2017-17807,https://github.com/torvalds/linux/commit/4dca6ea1d9432052afb06baf2e3ae78188a4410b,2017-12-20T23:29Z 1459,CWE-119,"CWE-119 static void nonrd_pick_sb_modes ( VP9_COMP * cpi , const TileInfo * const tile , int mi_row , int mi_col , int * rate , int64_t * dist , BLOCK_SIZE bsize ) { VP9_COMMON * const cm = & cpi -> common ; MACROBLOCK * const x = & cpi -> mb ; MACROBLOCKD * const xd = & x -> e_mbd ; set_offsets ( cpi , tile , mi_row , mi_col , bsize ) ; xd -> mi [ 0 ] -> mbmi . sb_type = bsize ; if ( ! frame_is_intra_only ( cm ) ) { vp9_pick_inter_mode ( cpi , x , tile , mi_row , mi_col , rate , dist , bsize ) ; } else { MB_PREDICTION_MODE intramode = DC_PRED ; set_mode_info ( & xd -> mi [ 0 ] -> mbmi , bsize , intramode ) ; } duplicate_mode_info_in_sb ( cm , xd , mi_row , mi_col , bsize ) ; } "," * cpi , TileDataEnc * tile_data , MACROBLOCK * const x , int mi_row , int mi_col , RD_COST * rd_cost , BLOCK_SIZE bsize , PICK_MODE_CONTEXT * ctx ) { VP9_COMMON * const cm = & cpi -> common ; TileInfo * const TileInfo * const tile_info = & tile_data -> tile_info ; MACROBLOCKD * -> e_mbd ; MB_MODE_INFO * mbmi ; ( cpi , tile_info , x , mi_row , mi_col , bsize ) ; mbmi = & xd -> mi ] -> mbmi ; mbmi -> sb_type = bsize ; if ( cpi -> oxcf . aq_mode == CYCLIC_REFRESH_AQ && cm -> seg . enabled ) if ( cyclic_refresh_segment_id_boosted ( mbmi -> segment_id ) ) x -> rdmult = vp9_cyclic_refresh_get_rdmult ( cpi -> cyclic_refresh ) ; if ( cm -> frame_type == KEY_FRAME ) hybrid_intra_mode_search ( cpi , x , rd_cost , bsize , ctx ) ; else if ( segfeature_active ( & cm -> seg , mbmi -> segment_id , SEG_LVL_SKIP ) ) set_mode_info_seg_skip ( x , cm -> tx_mode , rd_cost , bsize ) ; else if ( bsize >= BLOCK_8X8 ) vp9_pick_inter_mode ( cpi , x , tile_data , mi_row , mi_col , rd_cost , bsize , ctx ) ; else vp9_pick_inter_mode_sub8x8 ( cpi , x , mi_row , mi_col , rd_cost , bsize , ctx ) ; duplicate_mode_info_in_sb ( cm , xd , mi_row , mi_col , bsize ) ; if ( rd_cost -> rate == INT_MAX ) vp9_rd_cost_reset ( rd_cost ) ; ctx -> rate = rd_cost -> rate ; ctx -> dist = rd_cost -> dist ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1460,CWE-119,"CWE-119 static int virtnet_probe ( struct virtio_device * vdev ) { int i , err ; struct net_device * dev ; struct virtnet_info * vi ; u16 max_queue_pairs ; if ( ! vdev -> config -> get ) { dev_err ( & vdev -> dev , ""%sfailure:configaccessdisabled\\n"" , __func__ ) ; return - EINVAL ; } if ( ! virtnet_validate_features ( vdev ) ) return - EINVAL ; err = virtio_cread_feature ( vdev , VIRTIO_NET_F_MQ , struct virtio_net_config , max_virtqueue_pairs , & max_queue_pairs ) ; if ( err || max_queue_pairs < VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MIN || max_queue_pairs > VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX || ! virtio_has_feature ( vdev , VIRTIO_NET_F_CTRL_VQ ) ) max_queue_pairs = 1 ; dev = alloc_etherdev_mq ( sizeof ( struct virtnet_info ) , max_queue_pairs ) ; if ( ! dev ) return - ENOMEM ; dev -> priv_flags |= IFF_UNICAST_FLT | IFF_LIVE_ADDR_CHANGE ; dev -> netdev_ops = & virtnet_netdev ; dev -> features = NETIF_F_HIGHDMA ; dev -> ethtool_ops = & virtnet_ethtool_ops ; SET_NETDEV_DEV ( dev , & vdev -> dev ) ; if ( virtio_has_feature ( vdev , VIRTIO_NET_F_CSUM ) ) { dev -> hw_features |= NETIF_F_HW_CSUM | NETIF_F_SG | NETIF_F_FRAGLIST ; if ( csum ) dev -> features |= NETIF_F_HW_CSUM | NETIF_F_SG | NETIF_F_FRAGLIST ; if ( virtio_has_feature ( vdev , VIRTIO_NET_F_GSO ) ) { dev -> hw_features |= NETIF_F_TSO | NETIF_F_UFO | NETIF_F_TSO_ECN | NETIF_F_TSO6 ; } if ( virtio_has_feature ( vdev , VIRTIO_NET_F_HOST_TSO4 ) ) dev -> hw_features |= NETIF_F_TSO ; if ( virtio_has_feature ( vdev , VIRTIO_NET_F_HOST_TSO6 ) ) dev -> hw_features |= NETIF_F_TSO6 ; if ( virtio_has_feature ( vdev , VIRTIO_NET_F_HOST_ECN ) ) dev -> hw_features |= NETIF_F_TSO_ECN ; if ( virtio_has_feature ( vdev , VIRTIO_NET_F_HOST_UFO ) ) dev -> hw_features |= NETIF_F_UFO ; dev -> features |= NETIF_F_GSO_ROBUST ; if ( gso ) dev -> features |= dev -> hw_features & ( NETIF_F_ALL_TSO | NETIF_F_UFO ) ; } if ( virtio_has_feature ( vdev , VIRTIO_NET_F_GUEST_CSUM ) ) dev -> features |= NETIF_F_RXCSUM ; dev -> vlan_features = dev -> features ; if ( virtio_has_feature ( vdev , VIRTIO_NET_F_MAC ) ) virtio_cread_bytes ( vdev , offsetof ( struct virtio_net_config , mac ) , dev -> dev_addr , dev -> addr_len ) ; else eth_hw_addr_random ( dev ) ; vi = netdev_priv ( dev ) ; vi -> dev = dev ; vi -> vdev = vdev ; vdev -> priv = vi ; vi -> stats = alloc_percpu ( struct virtnet_stats ) ; err = - ENOMEM ; if ( vi -> stats == NULL ) goto free ; for_each_possible_cpu ( i ) { struct virtnet_stats * virtnet_stats ; virtnet_stats = per_cpu_ptr ( vi -> stats , i ) ; u64_stats_init ( & virtnet_stats -> tx_syncp ) ; u64_stats_init ( & virtnet_stats -> rx_syncp ) ; } INIT_WORK ( & vi -> config_work , virtnet_config_changed_work ) ; if ( virtio_has_feature ( vdev , VIRTIO_NET_F_GUEST_TSO4 ) || virtio_has_feature ( vdev , VIRTIO_NET_F_GUEST_TSO6 ) || virtio_has_feature ( vdev , VIRTIO_NET_F_GUEST_ECN ) || virtio_has_feature ( vdev , VIRTIO_NET_F_GUEST_UFO ) ) vi -> big_packets = true ; if ( virtio_has_feature ( vdev , VIRTIO_NET_F_MRG_RXBUF ) ) vi -> mergeable_rx_bufs = true ; if ( virtio_has_feature ( vdev , VIRTIO_NET_F_MRG_RXBUF ) || virtio_has_feature ( vdev , VIRTIO_F_VERSION_1 ) ) vi -> hdr_len = sizeof ( struct virtio_net_hdr_mrg_rxbuf ) ; else vi -> hdr_len = sizeof ( struct virtio_net_hdr ) ; if ( virtio_has_feature ( vdev , VIRTIO_F_ANY_LAYOUT ) || virtio_has_feature ( vdev , VIRTIO_F_VERSION_1 ) ) vi -> any_header_sg = true ; if ( virtio_has_feature ( vdev , VIRTIO_NET_F_CTRL_VQ ) ) vi -> has_cvq = true ; if ( vi -> any_header_sg ) dev -> needed_headroom = vi -> hdr_len ; vi -> curr_queue_pairs = 1 ; vi -> max_queue_pairs = max_queue_pairs ; err = init_vqs ( vi ) ; if ( err ) goto free_stats ; # ifdef CONFIG_SYSFS if ( vi -> mergeable_rx_bufs ) dev -> sysfs_rx_queue_group = & virtio_net_mrg_rx_group ; # endif netif_set_real_num_tx_queues ( dev , vi -> curr_queue_pairs ) ; netif_set_real_num_rx_queues ( dev , vi -> curr_queue_pairs ) ; err = register_netdev ( dev ) ; if ( err ) { pr_debug ( ""virtio_net:registeringdevicefailed\\n"" ) ; goto free_vqs ; } virtio_device_ready ( vdev ) ; for ( i = 0 ; i < vi -> curr_queue_pairs ; i ++ ) { try_fill_recv ( vi , & vi -> rq [ i ] , GFP_KERNEL ) ; if ( vi -> rq [ i ] . vq -> num_free == virtqueue_get_vring_size ( vi -> rq [ i ] . vq ) ) { free_unused_bufs ( vi ) ; err = - ENOMEM ; goto free_recv_bufs ; } } vi -> nb . notifier_call = & virtnet_cpu_callback ; err = register_hotcpu_notifier ( & vi -> nb ) ; if ( err ) { pr_debug ( ""virtio_net:registeringcpunotifierfailed\\n"" ) ; goto free_recv_bufs ; } if ( virtio_has_feature ( vi -> vdev , VIRTIO_NET_F_STATUS ) ) { netif_carrier_off ( dev ) ; schedule_work ( & vi -> config_work ) ; } else { vi -> status = VIRTIO_NET_S_LINK_UP ; netif_carrier_on ( dev ) ; } pr_debug ( ""virtnet:registereddevice%swith%dRXandTXvq\'s\\n"" , dev -> name , max_queue_pairs ) ; return 0 ; free_recv_bufs : vi -> vdev -> config -> reset ( vdev ) ; free_receive_bufs ( vi ) ; unregister_netdev ( dev ) ; free_vqs : cancel_delayed_work_sync ( & vi -> refill ) ; free_receive_page_frags ( vi ) ; virtnet_del_vqs ( vi ) ; free_stats : free_percpu ( vi -> stats ) ; free : free_netdev ( dev ) ; return err ; } "," NETIF_F_HW_CSUM | NETIF_F_SG ; if ( NETIF_F_HW_CSUM | NETIF_F_SG ; if ( ",torvalds@linux/48900cb6af4282fa0fb6ff4d72a81aa3dadb5c39,CVE-2015-5156,https://github.com/torvalds/linux/commit/48900cb6af4282fa0fb6ff4d72a81aa3dadb5c39,2015-10-19T10:59Z 1461,CWE-787,"CWE-787 MYSOFA_EXPORT struct MYSOFA_HRTF * mysofa_load ( const char * filename , int * err ) { struct READER reader ; struct MYSOFA_HRTF * hrtf = NULL ; if ( filename == NULL ) filename = CMAKE_INSTALL_PREFIX ""/share/libmysofa/default.sofa"" ; if ( strcmp ( filename , ""-"" ) ) reader . fhd = fopen ( filename , ""rb"" ) ; else reader . fhd = stdin ; if ( ! reader . fhd ) { log ( ""cannotopenfile%s\\n"" , filename ) ; * err = errno ; return NULL ; } reader . gcol = NULL ; reader . all = NULL ; * err = superblockRead ( & reader , & reader . superblock ) ; if ( ! * err ) { hrtf = getHrtf ( & reader , err ) ; } superblockFree ( & reader , & reader . superblock ) ; gcolFree ( reader . gcol ) ; if ( strcmp ( filename , ""-"" ) ) fclose ( reader . fhd ) ; return hrtf ; } "," = NULL ; reader . recursive_counter = 0 ; ",hoene@libmysofa/2e6fac6ab6156dae8e8c6f417741388084b70d6f,CVE-2019-20016,https://github.com/hoene/libmysofa/commit/2e6fac6ab6156dae8e8c6f417741388084b70d6f,2019-12-27T02:15Z 1462,CWE-908,"CWE-908 static Image * ReadRLEImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define SkipLinesOp 0x01 # define SetColorOp 0x02 # define SkipPixelsOp 0x03 # define ByteDataOp 0x05 # define RunDataOp 0x06 # define EOFOp 0x07 char magick [ 12 ] ; Image * image ; int opcode , operand , status ; MagickStatusType flags ; MagickSizeType number_pixels ; MemoryInfo * pixel_info ; Quantum index ; register ssize_t x ; register Quantum * q ; register ssize_t i ; register unsigned char * p ; size_t bits_per_pixel , map_length , number_colormaps , number_planes , number_planes_filled , one , pixel_info_length ; ssize_t count , offset , y ; unsigned char background_color [ 256 ] , * colormap , pixel , plane , * pixels ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; count = ReadBlob ( image , 2 , ( unsigned char * ) magick ) ; if ( ( count != 2 ) || ( memcmp ( magick , ""\\122\\314"" , 2 ) != 0 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; do { image -> page . x = ReadBlobLSBShort ( image ) ; image -> page . y = ReadBlobLSBShort ( image ) ; image -> columns = ReadBlobLSBShort ( image ) ; image -> rows = ReadBlobLSBShort ( image ) ; flags = ( MagickStatusType ) ReadBlobByte ( image ) ; image -> alpha_trait = flags & 0x04 ? BlendPixelTrait : UndefinedPixelTrait ; number_planes = ( size_t ) ReadBlobByte ( image ) ; bits_per_pixel = ( size_t ) ReadBlobByte ( image ) ; number_colormaps = ( size_t ) ReadBlobByte ( image ) ; map_length = ( unsigned char ) ReadBlobByte ( image ) ; if ( map_length >= 22 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; one = 1 ; map_length = one << map_length ; if ( ( number_planes == 0 ) || ( number_planes == 2 ) || ( ( flags & 0x04 ) && ( number_colormaps > 254 ) ) || ( bits_per_pixel != 8 ) || ( image -> columns == 0 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( flags & 0x02 ) { for ( i = 0 ; i < ( ssize_t ) number_planes ; i ++ ) background_color [ i ] = 0 ; ( void ) ReadBlobByte ( image ) ; } else { p = background_color ; for ( i = 0 ; i < ( ssize_t ) number_planes ; i ++ ) * p ++ = ( unsigned char ) ReadBlobByte ( image ) ; } if ( ( number_planes & 0x01 ) == 0 ) ( void ) ReadBlobByte ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } colormap = ( unsigned char * ) NULL ; if ( number_colormaps != 0 ) { colormap = ( unsigned char * ) AcquireQuantumMemory ( number_colormaps , 3 * map_length * sizeof ( * colormap ) ) ; if ( colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; p = colormap ; for ( i = 0 ; i < ( ssize_t ) number_colormaps ; i ++ ) for ( x = 0 ; x < ( ssize_t ) map_length ; x ++ ) * p ++ = ( unsigned char ) ScaleShortToQuantum ( ReadBlobLSBShort ( image ) ) ; } if ( ( flags & 0x08 ) != 0 ) { char * comment ; size_t length ; length = ReadBlobLSBShort ( image ) ; if ( length != 0 ) { comment = ( char * ) AcquireQuantumMemory ( length , sizeof ( * comment ) ) ; if ( comment == ( char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; count = ReadBlob ( image , length - 1 , ( unsigned char * ) comment ) ; comment [ length - 1 ] = '\\0' ; ( void ) SetImageProperty ( image , ""comment"" , comment , exception ) ; comment = DestroyString ( comment ) ; if ( ( length & 0x01 ) == 0 ) ( void ) ReadBlobByte ( image ) ; } } if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; if ( image -> alpha_trait != UndefinedPixelTrait ) number_planes ++ ; number_pixels = ( MagickSizeType ) image -> columns * image -> rows ; number_planes_filled = ( number_planes % 2 == 0 ) ? number_planes : number_planes + 1 ; if ( ( number_pixels * number_planes_filled ) != ( size_t ) ( number_pixels * number_planes_filled ) ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; pixel_info = AcquireVirtualMemory ( image -> columns , image -> rows * MagickMax ( number_planes_filled , 4 ) * sizeof ( * pixels ) ) ; if ( pixel_info == ( MemoryInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; pixel_info_length = image -> columns * image -> rows * MagickMax ( number_planes_filled , 4 ) ; pixels = ( unsigned char * ) GetVirtualMemoryBlob ( pixel_info ) ; if ( ( flags & 0x01 ) && ! ( flags & 0x02 ) ) { ssize_t j ; p = pixels ; for ( i = 0 ; i < ( ssize_t ) number_pixels ; i ++ ) { if ( image -> alpha_trait == UndefinedPixelTrait ) for ( j = 0 ; j < ( ssize_t ) number_planes ; j ++ ) * p ++ = background_color [ j ] ; else { for ( j = 0 ; j < ( ssize_t ) ( number_planes - 1 ) ; j ++ ) * p ++ = background_color [ j ] ; * p ++ = 0 ; } } } plane = 0 ; x = 0 ; y = 0 ; opcode = ReadBlobByte ( image ) ; do { switch ( opcode & 0x3f ) { case SkipLinesOp : { operand = ReadBlobByte ( image ) ; if ( opcode & 0x40 ) operand = ReadBlobLSBSignedShort ( image ) ; x = 0 ; y += operand ; break ; } case SetColorOp : { operand = ReadBlobByte ( image ) ; plane = ( unsigned char ) operand ; if ( plane == 255 ) plane = ( unsigned char ) ( number_planes - 1 ) ; x = 0 ; break ; } case SkipPixelsOp : { operand = ReadBlobByte ( image ) ; if ( opcode & 0x40 ) operand = ReadBlobLSBSignedShort ( image ) ; x += operand ; break ; } case ByteDataOp : { operand = ReadBlobByte ( image ) ; if ( opcode & 0x40 ) operand = ReadBlobLSBSignedShort ( image ) ; offset = ( ( image -> rows - y - 1 ) * image -> columns * number_planes ) + x * number_planes + plane ; operand ++ ; if ( ( offset < 0 ) || ( offset + ( ( size_t ) operand * number_planes ) > pixel_info_length ) ) { if ( number_colormaps != 0 ) colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; } p = pixels + offset ; for ( i = 0 ; i < ( ssize_t ) operand ; i ++ ) { pixel = ( unsigned char ) ReadBlobByte ( image ) ; if ( ( y < ( ssize_t ) image -> rows ) && ( ( x + i ) < ( ssize_t ) image -> columns ) ) * p = pixel ; p += number_planes ; } if ( operand & 0x01 ) ( void ) ReadBlobByte ( image ) ; x += operand ; break ; } case RunDataOp : { operand = ReadBlobByte ( image ) ; if ( opcode & 0x40 ) operand = ReadBlobLSBSignedShort ( image ) ; pixel = ( unsigned char ) ReadBlobByte ( image ) ; ( void ) ReadBlobByte ( image ) ; offset = ( ( image -> rows - y - 1 ) * image -> columns * number_planes ) + x * number_planes + plane ; operand ++ ; if ( ( offset < 0 ) || ( offset + ( ( size_t ) operand * number_planes ) > pixel_info_length ) ) { if ( number_colormaps != 0 ) colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; } p = pixels + offset ; for ( i = 0 ; i < ( ssize_t ) operand ; i ++ ) { if ( ( y < ( ssize_t ) image -> rows ) && ( ( x + i ) < ( ssize_t ) image -> columns ) ) * p = pixel ; p += number_planes ; } x += operand ; break ; } default : break ; } opcode = ReadBlobByte ( image ) ; } while ( ( ( opcode & 0x3f ) != EOFOp ) && ( opcode != EOF ) ) ; if ( number_colormaps != 0 ) { MagickStatusType mask ; mask = ( MagickStatusType ) ( map_length - 1 ) ; p = pixels ; x = ( ssize_t ) number_planes ; if ( number_colormaps == 1 ) for ( i = 0 ; i < ( ssize_t ) number_pixels ; i ++ ) { ValidateColormapValue ( image , * p & mask , & index , exception ) ; * p = colormap [ ( ssize_t ) index ] ; p ++ ; } else if ( ( number_planes >= 3 ) && ( number_colormaps >= 3 ) ) for ( i = 0 ; i < ( ssize_t ) number_pixels ; i ++ ) for ( x = 0 ; x < ( ssize_t ) number_planes ; x ++ ) { ValidateColormapValue ( image , ( size_t ) ( x * map_length + ( * p & mask ) ) , & index , exception ) ; * p = colormap [ ( ssize_t ) index ] ; p ++ ; } if ( ( i < ( ssize_t ) number_pixels ) || ( x < ( ssize_t ) number_planes ) ) { colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; } } if ( number_planes >= 3 ) { p = pixels ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelGreen ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelBlue ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; if ( image -> alpha_trait != UndefinedPixelTrait ) SetPixelAlpha ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } else { if ( number_colormaps == 0 ) map_length = 256 ; if ( AcquireImageColormap ( image , map_length , exception ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; p = colormap ; if ( number_colormaps == 1 ) for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { image -> colormap [ i ] . red = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) i ) ; image -> colormap [ i ] . green = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) i ) ; image -> colormap [ i ] . blue = ( MagickRealType ) ScaleCharToQuantum ( ( unsigned char ) i ) ; } else if ( number_colormaps > 1 ) for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { image -> colormap [ i ] . red = ( MagickRealType ) ScaleCharToQuantum ( * p ) ; image -> colormap [ i ] . green = ( MagickRealType ) ScaleCharToQuantum ( * ( p + map_length ) ) ; image -> colormap [ i ] . blue = ( MagickRealType ) ScaleCharToQuantum ( * ( p + map_length * 2 ) ) ; p ++ ; } p = pixels ; if ( image -> alpha_trait == UndefinedPixelTrait ) { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelIndex ( image , * p ++ , q ) ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } ( void ) SyncImage ( image , exception ) ; } else { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { ValidateColormapValue ( image , ( ssize_t ) * p ++ , & index , exception ) ; SetPixelRed ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) index ] . red ) , q ) ; ValidateColormapValue ( image , ( ssize_t ) * p ++ , & index , exception ) ; SetPixelGreen ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) index ] . green ) , q ) ; ValidateColormapValue ( image , ( ssize_t ) * p ++ , & index , exception ) ; SetPixelBlue ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) index ] . blue ) , q ) ; SetPixelAlpha ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; q += GetPixelChannels ( image ) ; } if ( x < ( ssize_t ) image -> columns ) break ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } image -> colormap = ( PixelInfo * ) RelinquishMagickMemory ( image -> colormap ) ; image -> storage_class = DirectClass ; image -> colors = 0 ; } } if ( number_colormaps != 0 ) colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; pixel_info = RelinquishVirtualMemory ( pixel_info ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; ( void ) ReadBlobByte ( image ) ; count = ReadBlob ( image , 2 , ( unsigned char * ) magick ) ; if ( ( count != 0 ) && ( memcmp ( magick , ""\\122\\314"" , 2 ) == 0 ) ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( ( count != 0 ) && ( memcmp ( magick , ""\\122\\314"" , 2 ) == 0 ) ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," pixel_info ) ; ( void ) ResetMagickMemory ( pixels , 0 , pixel_info_length ) ; ",ImageMagick@ImageMagick/1c358ffe0049f768dd49a8a889c1cbf99ac9849b,CVE-2017-9098,https://github.com/ImageMagick/ImageMagick/commit/1c358ffe0049f768dd49a8a889c1cbf99ac9849b,2017-05-19T19:29Z 1463,CWE-119,"CWE-119 static ssize_t exitcode_proc_write ( struct file * file , const char __user * buffer , size_t count , loff_t * pos ) { char * end , buf [ sizeof ( ""nnnnn\\0"" ) ] ; int tmp ; if ( copy_from_user ( buf , buffer , count ) ) return - EFAULT ; tmp = simple_strtol ( buf , & end , 0 ) ; if ( ( * end != '\\0' ) && ! isspace ( * end ) ) return - EINVAL ; uml_exitcode = tmp ; return count ; } "," ) ] ; size_t size ; int tmp ; size = min ( count , sizeof ( buf ) ) ; if ( , buffer , size ) ) return ",torvalds@linux/201f99f170df14ba52ea4c52847779042b7a623b,CVE-2013-4512,https://github.com/torvalds/linux/commit/201f99f170df14ba52ea4c52847779042b7a623b,2013-11-12T14:35Z 1464,CWE-189,"CWE-189 static int sysMapFD ( int fd , MemMapping * pMap ) { off_t start ; size_t length ; void * memPtr ; assert ( pMap != NULL ) ; if ( getFileStartAndLength ( fd , & start , & length ) < 0 ) return - 1 ; memPtr = mmap ( NULL , length , PROT_READ , MAP_PRIVATE , fd , start ) ; if ( memPtr == MAP_FAILED ) { LOGW ( ""mmap(%d,R,PRIVATE,%d,%d)failed:%s\\n"" , ( int ) length , fd , ( int ) start , strerror ( errno ) ) ; return - 1 ; } pMap -> addr = memPtr ; pMap -> length = length ; pMap -> range_count = 1 ; pMap -> ranges = malloc ( sizeof ( MappedRange ) ) ; pMap -> ranges [ 0 ] . addr = memPtr ; pMap -> ranges [ 0 ] . length = length ; return 0 ; } "," ) ) ; if ( pMap -> ranges == NULL ) { LOGE ( ""mallocfailed:%s\\n"" , strerror ( errno ) ) ; munmap ( memPtr , length ) ; return - 1 ; } ",bootable@recovery/28a566f7731b4cb76d2a9ba16d997ac5aeb07dad,CVE-2016-0849,https://android.googlesource.com/platform/bootable/recovery/+/28a566f7731b4cb76d2a9ba16d997ac5aeb07dad,2016-04-18T00:59Z 1465,CWE-476,"CWE-476 xfs_failaddr_t xfs_dinode_verify ( struct xfs_mount * mp , xfs_ino_t ino , struct xfs_dinode * dip ) { xfs_failaddr_t fa ; uint16_t mode ; uint16_t flags ; uint64_t flags2 ; uint64_t di_size ; if ( dip -> di_magic != cpu_to_be16 ( XFS_DINODE_MAGIC ) ) return __this_address ; if ( dip -> di_version >= 3 ) { if ( ! xfs_sb_version_hascrc ( & mp -> m_sb ) ) return __this_address ; if ( ! xfs_verify_cksum ( ( char * ) dip , mp -> m_sb . sb_inodesize , XFS_DINODE_CRC_OFF ) ) return __this_address ; if ( be64_to_cpu ( dip -> di_ino ) != ino ) return __this_address ; if ( ! uuid_equal ( & dip -> di_uuid , & mp -> m_sb . sb_meta_uuid ) ) return __this_address ; } di_size = be64_to_cpu ( dip -> di_size ) ; if ( di_size & ( 1ULL << 63 ) ) return __this_address ; mode = be16_to_cpu ( dip -> di_mode ) ; if ( mode && xfs_mode_to_ftype ( mode ) == XFS_DIR3_FT_UNKNOWN ) return __this_address ; if ( ( S_ISLNK ( mode ) || S_ISDIR ( mode ) ) && di_size == 0 ) return __this_address ; if ( mode && be32_to_cpu ( dip -> di_nextents ) + be16_to_cpu ( dip -> di_anextents ) > be64_to_cpu ( dip -> di_nblocks ) ) return __this_address ; if ( mode && XFS_DFORK_BOFF ( dip ) > mp -> m_sb . sb_inodesize ) return __this_address ; flags = be16_to_cpu ( dip -> di_flags ) ; if ( mode && ( flags & XFS_DIFLAG_REALTIME ) && ! mp -> m_rtdev_targp ) return __this_address ; switch ( mode & S_IFMT ) { case S_IFIFO : case S_IFCHR : case S_IFBLK : case S_IFSOCK : if ( dip -> di_format != XFS_DINODE_FMT_DEV ) return __this_address ; break ; case S_IFREG : case S_IFLNK : case S_IFDIR : switch ( dip -> di_format ) { case XFS_DINODE_FMT_LOCAL : if ( S_ISREG ( mode ) ) return __this_address ; if ( di_size > XFS_DFORK_DSIZE ( dip , mp ) ) return __this_address ; if ( dip -> di_nextents ) return __this_address ; case XFS_DINODE_FMT_EXTENTS : case XFS_DINODE_FMT_BTREE : break ; default : return __this_address ; } break ; case 0 : break ; default : return __this_address ; } if ( XFS_DFORK_Q ( dip ) ) { switch ( dip -> di_aformat ) { case XFS_DINODE_FMT_LOCAL : if ( dip -> di_anextents ) return __this_address ; case XFS_DINODE_FMT_EXTENTS : case XFS_DINODE_FMT_BTREE : break ; default : return __this_address ; } } else { switch ( dip -> di_aformat ) { case 0 : case XFS_DINODE_FMT_EXTENTS : break ; default : return __this_address ; } if ( dip -> di_anextents ) return __this_address ; } fa = xfs_inode_validate_extsize ( mp , be32_to_cpu ( dip -> di_extsize ) , mode , flags ) ; if ( fa ) return fa ; if ( dip -> di_version < 3 ) return NULL ; flags2 = be64_to_cpu ( dip -> di_flags2 ) ; if ( ( flags2 & ( XFS_DIFLAG2_REFLINK | XFS_DIFLAG2_COWEXTSIZE ) ) && ! xfs_sb_version_hasreflink ( & mp -> m_sb ) ) return __this_address ; if ( ( flags2 & XFS_DIFLAG2_REFLINK ) && ( mode & S_IFMT ) != S_IFREG ) return __this_address ; if ( ( flags2 & XFS_DIFLAG2_REFLINK ) && ( flags & XFS_DIFLAG_REALTIME ) ) return __this_address ; if ( ( flags2 & XFS_DIFLAG2_REFLINK ) && ( flags2 & XFS_DIFLAG2_DAX ) ) return __this_address ; fa = xfs_inode_validate_cowextsize ( mp , be32_to_cpu ( dip -> di_cowextsize ) , mode , flags , flags2 ) ; if ( fa ) return fa ; return NULL ; } "," case S_IFDIR : fa = xfs_dinode_verify_fork ( dip , mp , XFS_DATA_FORK ) ; if ( fa ) return fa ; break ; case 0 : break ; default : return __this_address ; } if ( XFS_DFORK_Q ( dip ) ) { fa = xfs_dinode_verify_fork ( dip , mp , XFS_ATTR_FORK ) ; if ( fa ) return fa ; } else { ",torvalds@linux/23fcb3340d033d9f081e21e6c12c2db7eaa541d3,CVE-2018-13095,https://github.com/torvalds/linux/commit/23fcb3340d033d9f081e21e6c12c2db7eaa541d3,2018-07-03T10:29Z 1466,CWE-119,"CWE-119 static int decode_unit ( SCPRContext * s , PixelModel * pixel , unsigned step , unsigned * rval ) { GetByteContext * gb = & s -> gb ; RangeCoder * rc = & s -> rc ; unsigned totfr = pixel -> total_freq ; unsigned value , x = 0 , cumfr = 0 , cnt_x = 0 ; int i , j , ret , c , cnt_c ; if ( ( ret = s -> get_freq ( rc , totfr , & value ) ) < 0 ) return ret ; while ( x < 16 ) { cnt_x = pixel -> lookup [ x ] ; if ( value >= cumfr + cnt_x ) cumfr += cnt_x ; else break ; x ++ ; } c = x * 16 ; cnt_c = 0 ; while ( c < 256 ) { cnt_c = pixel -> freq [ c ] ; if ( value >= cumfr + cnt_c ) cumfr += cnt_c ; else break ; c ++ ; } if ( ( ret = s -> decode ( gb , rc , cumfr , cnt_c , totfr ) ) < 0 ) return ret ; pixel -> freq [ c ] = cnt_c + step ; pixel -> lookup [ x ] = cnt_x + step ; totfr += step ; if ( totfr > BOT ) { totfr = 0 ; for ( i = 0 ; i < 256 ; i ++ ) { unsigned nc = ( pixel -> freq [ i ] >> 1 ) + 1 ; pixel -> freq [ i ] = nc ; totfr += nc ; } for ( i = 0 ; i < 16 ; i ++ ) { unsigned sum = 0 ; unsigned i16_17 = i << 4 ; for ( j = 0 ; j < 16 ; j ++ ) sum += pixel -> freq [ i16_17 + j ] ; pixel -> lookup [ i ] = sum ; } } pixel -> total_freq = totfr ; * rval = c & s -> cbits ; return 0 ; } "," } if ( x >= 16 || c >= 256 ) { return AVERROR_INVALIDDATA ; } if ( ",FFmpeg@FFmpeg/2171dfae8c065878a2e130390eb78cf2947a5b69,CVE-2017-9995,https://github.com/FFmpeg/FFmpeg/commit/2171dfae8c065878a2e130390eb78cf2947a5b69,2017-06-28T06:29Z 1467,CWE-416,"CWE-416 static int mif_process_cmpt ( mif_hdr_t * hdr , char * buf ) { jas_tvparser_t * tvp ; mif_cmpt_t * cmpt ; int id ; cmpt = 0 ; tvp = 0 ; if ( ! ( cmpt = mif_cmpt_create ( ) ) ) { goto error ; } cmpt -> tlx = 0 ; cmpt -> tly = 0 ; cmpt -> sampperx = 0 ; cmpt -> samppery = 0 ; cmpt -> width = 0 ; cmpt -> height = 0 ; cmpt -> prec = 0 ; cmpt -> sgnd = - 1 ; cmpt -> data = 0 ; if ( ! ( tvp = jas_tvparser_create ( buf ) ) ) { goto error ; } while ( ! ( id = jas_tvparser_next ( tvp ) ) ) { switch ( jas_taginfo_nonull ( jas_taginfos_lookup ( mif_tags , jas_tvparser_gettag ( tvp ) ) ) -> id ) { case MIF_TLX : cmpt -> tlx = atoi ( jas_tvparser_getval ( tvp ) ) ; break ; case MIF_TLY : cmpt -> tly = atoi ( jas_tvparser_getval ( tvp ) ) ; break ; case MIF_WIDTH : cmpt -> width = atoi ( jas_tvparser_getval ( tvp ) ) ; break ; case MIF_HEIGHT : cmpt -> height = atoi ( jas_tvparser_getval ( tvp ) ) ; break ; case MIF_HSAMP : cmpt -> sampperx = atoi ( jas_tvparser_getval ( tvp ) ) ; break ; case MIF_VSAMP : cmpt -> samppery = atoi ( jas_tvparser_getval ( tvp ) ) ; break ; case MIF_PREC : cmpt -> prec = atoi ( jas_tvparser_getval ( tvp ) ) ; break ; case MIF_SGND : cmpt -> sgnd = atoi ( jas_tvparser_getval ( tvp ) ) ; break ; case MIF_DATA : if ( ! ( cmpt -> data = jas_strdup ( jas_tvparser_getval ( tvp ) ) ) ) { return - 1 ; } break ; } } jas_tvparser_destroy ( tvp ) ; if ( ! cmpt -> sampperx || ! cmpt -> samppery ) { goto error ; } if ( mif_hdr_addcmpt ( hdr , hdr -> numcmpts , cmpt ) ) { goto error ; } return 0 ; error : if ( cmpt ) { mif_cmpt_destroy ( cmpt ) ; } if ( tvp ) { jas_tvparser_destroy ( tvp ) ; } return - 1 ; } "," ; } } if ( ! error ; } jas_tvparser_destroy ( tvp ) ; ",mdadams@jasper/df5d2867e8004e51e18b89865bc4aa69229227b3,CVE-2015-5221,https://github.com/mdadams/jasper/commit/df5d2867e8004e51e18b89865bc4aa69229227b3,2017-07-25T18:29Z 1468,CWE-119,"CWE-119 static vpx_codec_err_t vp8e_encode ( vpx_codec_alg_priv_t * ctx , const vpx_image_t * img , vpx_codec_pts_t pts , unsigned long duration , vpx_enc_frame_flags_t flags , unsigned long deadline ) { vpx_codec_err_t res = VPX_CODEC_OK ; if ( ! ctx -> cfg . rc_target_bitrate ) return res ; if ( img ) res = validate_img ( ctx , img ) ; if ( ! res ) res = validate_config ( ctx , & ctx -> cfg , & ctx -> vp8_cfg , 1 ) ; pick_quickcompress_mode ( ctx , duration , deadline ) ; vpx_codec_pkt_list_init ( & ctx -> pkt_list ) ; if ( ( ( flags & VP8_EFLAG_NO_UPD_GF ) && ( flags & VP8_EFLAG_FORCE_GF ) ) || ( ( flags & VP8_EFLAG_NO_UPD_ARF ) && ( flags & VP8_EFLAG_FORCE_ARF ) ) ) { ctx -> base . err_detail = ""Conflictingflags."" ; return VPX_CODEC_INVALID_PARAM ; } if ( flags & ( VP8_EFLAG_NO_REF_LAST | VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF ) ) { int ref = 7 ; if ( flags & VP8_EFLAG_NO_REF_LAST ) ref ^= VP8_LAST_FRAME ; if ( flags & VP8_EFLAG_NO_REF_GF ) ref ^= VP8_GOLD_FRAME ; if ( flags & VP8_EFLAG_NO_REF_ARF ) ref ^= VP8_ALTR_FRAME ; vp8_use_as_reference ( ctx -> cpi , ref ) ; } if ( flags & ( VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_FORCE_GF | VP8_EFLAG_FORCE_ARF ) ) { int upd = 7 ; if ( flags & VP8_EFLAG_NO_UPD_LAST ) upd ^= VP8_LAST_FRAME ; if ( flags & VP8_EFLAG_NO_UPD_GF ) upd ^= VP8_GOLD_FRAME ; if ( flags & VP8_EFLAG_NO_UPD_ARF ) upd ^= VP8_ALTR_FRAME ; vp8_update_reference ( ctx -> cpi , upd ) ; } if ( flags & VP8_EFLAG_NO_UPD_ENTROPY ) { vp8_update_entropy ( ctx -> cpi , 0 ) ; } if ( ctx -> cfg . kf_mode == VPX_KF_AUTO && ctx -> cfg . kf_min_dist == ctx -> cfg . kf_max_dist ) { if ( ++ ctx -> fixed_kf_cntr > ctx -> cfg . kf_min_dist ) { flags |= VPX_EFLAG_FORCE_KF ; ctx -> fixed_kf_cntr = 1 ; } } if ( ! res && ctx -> cpi ) { unsigned int lib_flags ; YV12_BUFFER_CONFIG sd ; int64_t dst_time_stamp , dst_end_time_stamp ; unsigned long size , cx_data_sz ; unsigned char * cx_data ; unsigned char * cx_data_end ; int comp_data_state = 0 ; if ( ctx -> base . init_flags & VPX_CODEC_USE_PSNR ) ( ( VP8_COMP * ) ctx -> cpi ) -> b_calculate_psnr = 1 ; if ( ctx -> base . init_flags & VPX_CODEC_USE_OUTPUT_PARTITION ) ( ( VP8_COMP * ) ctx -> cpi ) -> output_partition = 1 ; lib_flags = ( flags & VPX_EFLAG_FORCE_KF ) ? FRAMEFLAGS_KEY : 0 ; dst_time_stamp = pts * 10000000 * ctx -> cfg . g_timebase . num / ctx -> cfg . g_timebase . den ; dst_end_time_stamp = ( pts + duration ) * 10000000 * ctx -> cfg . g_timebase . num / ctx -> cfg . g_timebase . den ; if ( img != NULL ) { res = image2yuvconfig ( img , & sd ) ; if ( vp8_receive_raw_frame ( ctx -> cpi , ctx -> next_frame_flag | lib_flags , & sd , dst_time_stamp , dst_end_time_stamp ) ) { VP8_COMP * cpi = ( VP8_COMP * ) ctx -> cpi ; res = update_error_state ( ctx , & cpi -> common . error ) ; } ctx -> next_frame_flag = 0 ; } cx_data = ctx -> cx_data ; cx_data_sz = ctx -> cx_data_sz ; cx_data_end = ctx -> cx_data + cx_data_sz ; lib_flags = 0 ; while ( cx_data_sz >= ctx -> cx_data_sz / 2 ) { comp_data_state = vp8_get_compressed_data ( ctx -> cpi , & lib_flags , & size , cx_data , cx_data_end , & dst_time_stamp , & dst_end_time_stamp , ! img ) ; if ( comp_data_state == VPX_CODEC_CORRUPT_FRAME ) return VPX_CODEC_CORRUPT_FRAME ; else if ( comp_data_state == - 1 ) break ; if ( size ) { vpx_codec_pts_t round , delta ; vpx_codec_cx_pkt_t pkt ; VP8_COMP * cpi = ( VP8_COMP * ) ctx -> cpi ; round = ( vpx_codec_pts_t ) 1000000 * ctx -> cfg . g_timebase . num / 2 - 1 ; delta = ( dst_end_time_stamp - dst_time_stamp ) ; pkt . kind = VPX_CODEC_CX_FRAME_PKT ; pkt . data . frame . pts = ( dst_time_stamp * ctx -> cfg . g_timebase . den + round ) / ctx -> cfg . g_timebase . num / 10000000 ; pkt . data . frame . duration = ( unsigned long ) ( ( delta * ctx -> cfg . g_timebase . den + round ) / ctx -> cfg . g_timebase . num / 10000000 ) ; pkt . data . frame . flags = lib_flags << 16 ; if ( lib_flags & FRAMEFLAGS_KEY ) pkt . data . frame . flags |= VPX_FRAME_IS_KEY ; if ( ! cpi -> common . show_frame ) { pkt . data . frame . flags |= VPX_FRAME_IS_INVISIBLE ; pkt . data . frame . pts = ( ( cpi -> last_time_stamp_seen * ctx -> cfg . g_timebase . den + round ) / ctx -> cfg . g_timebase . num / 10000000 ) + 1 ; pkt . data . frame . duration = 0 ; } if ( cpi -> droppable ) pkt . data . frame . flags |= VPX_FRAME_IS_DROPPABLE ; if ( cpi -> output_partition ) { int i ; const int num_partitions = ( 1 << cpi -> common . multi_token_partition ) + 1 ; pkt . data . frame . flags |= VPX_FRAME_IS_FRAGMENT ; for ( i = 0 ; i < num_partitions ; ++ i ) { # if CONFIG_REALTIME_ONLY & CONFIG_ONTHEFLY_BITPACKING pkt . data . frame . buf = cpi -> partition_d [ i ] ; # else pkt . data . frame . buf = cx_data ; cx_data += cpi -> partition_sz [ i ] ; cx_data_sz -= cpi -> partition_sz [ i ] ; # endif pkt . data . frame . sz = cpi -> partition_sz [ i ] ; pkt . data . frame . partition_id = i ; if ( i == ( num_partitions - 1 ) ) pkt . data . frame . flags &= ~ VPX_FRAME_IS_FRAGMENT ; vpx_codec_pkt_list_add ( & ctx -> pkt_list . head , & pkt ) ; } # if CONFIG_REALTIME_ONLY & CONFIG_ONTHEFLY_BITPACKING cx_data_sz -= ctx -> cx_data_sz / 2 ; # endif } else { pkt . data . frame . buf = cx_data ; pkt . data . frame . sz = size ; pkt . data . frame . partition_id = - 1 ; vpx_codec_pkt_list_add ( & ctx -> pkt_list . head , & pkt ) ; cx_data += size ; cx_data_sz -= size ; } } } } return res ; } "," ; if ( ! flags ) { flags = ctx -> control_frame_flags ; } ctx -> control_frame_flags = 0 ; res = set_reference_and_update ( ctx , flags ) ; if ( ctx ( vpx_codec_pts_t ) 10000000 * ctx -> ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1469,CWE-125,"CWE-125 static Image * ReadMATImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { Image * image , * image2 = NULL , * rotated_image ; register Quantum * q ; unsigned int status ; MATHeader MATLAB_HDR ; size_t size ; size_t CellType ; QuantumInfo * quantum_info ; ImageInfo * clone_info ; int i ; ssize_t ldblk ; unsigned char * BImgBuff = NULL ; double MinVal , MaxVal ; unsigned z , z2 ; unsigned Frames ; int logging ; int sample_size ; MagickOffsetType filepos = 0x80 ; BlobInfo * blob ; size_t one ; unsigned int ( * ReadBlobXXXLong ) ( Image * image ) ; unsigned short ( * ReadBlobXXXShort ) ( Image * image ) ; void ( * ReadBlobDoublesXXX ) ( Image * image , size_t len , double * data ) ; void ( * ReadBlobFloatsXXX ) ( Image * image , size_t len , float * data ) ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickCoreSignature ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickCoreSignature ) ; logging = LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""enter"" ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } clone_info = CloneImageInfo ( image_info ) ; if ( ReadBlob ( image , 124 , ( unsigned char * ) & MATLAB_HDR . identific ) != 124 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; MATLAB_HDR . Version = ReadBlobLSBShort ( image ) ; if ( ReadBlob ( image , 2 , ( unsigned char * ) & MATLAB_HDR . EndianIndicator ) != 2 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""Endian%c%c"" , MATLAB_HDR . EndianIndicator [ 0 ] , MATLAB_HDR . EndianIndicator [ 1 ] ) ; if ( ! strncmp ( MATLAB_HDR . EndianIndicator , ""IM"" , 2 ) ) { ReadBlobXXXLong = ReadBlobLSBLong ; ReadBlobXXXShort = ReadBlobLSBShort ; ReadBlobDoublesXXX = ReadBlobDoublesLSB ; ReadBlobFloatsXXX = ReadBlobFloatsLSB ; image -> endian = LSBEndian ; } else if ( ! strncmp ( MATLAB_HDR . EndianIndicator , ""MI"" , 2 ) ) { ReadBlobXXXLong = ReadBlobMSBLong ; ReadBlobXXXShort = ReadBlobMSBShort ; ReadBlobDoublesXXX = ReadBlobDoublesMSB ; ReadBlobFloatsXXX = ReadBlobFloatsMSB ; image -> endian = MSBEndian ; } else goto MATLAB_KO ; if ( strncmp ( MATLAB_HDR . identific , ""MATLAB"" , 6 ) ) MATLAB_KO : ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; filepos = TellBlob ( image ) ; while ( ! EOFBlob ( image ) ) { Frames = 1 ; ( void ) SeekBlob ( image , filepos , SEEK_SET ) ; MATLAB_HDR . DataType = ReadBlobXXXLong ( image ) ; if ( EOFBlob ( image ) ) break ; MATLAB_HDR . ObjectSize = ReadBlobXXXLong ( image ) ; if ( EOFBlob ( image ) ) break ; filepos += MATLAB_HDR . ObjectSize + 4 + 4 ; image2 = image ; # if defined ( MAGICKCORE_ZLIB_DELEGATE ) if ( MATLAB_HDR . DataType == miCOMPRESSED ) { image2 = DecompressBlock ( image , MATLAB_HDR . ObjectSize , clone_info , exception ) ; if ( image2 == NULL ) continue ; MATLAB_HDR . DataType = ReadBlobXXXLong ( image2 ) ; } # endif if ( MATLAB_HDR . DataType != miMATRIX ) continue ; MATLAB_HDR . unknown1 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . unknown2 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . unknown5 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . StructureClass = MATLAB_HDR . unknown5 & 0xFF ; MATLAB_HDR . StructureFlag = ( MATLAB_HDR . unknown5 >> 8 ) & 0xFF ; MATLAB_HDR . unknown3 = ReadBlobXXXLong ( image2 ) ; if ( image != image2 ) MATLAB_HDR . unknown4 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . unknown4 = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . DimFlag = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . SizeX = ReadBlobXXXLong ( image2 ) ; MATLAB_HDR . SizeY = ReadBlobXXXLong ( image2 ) ; switch ( MATLAB_HDR . DimFlag ) { case 8 : z2 = z = 1 ; break ; case 12 : z2 = z = ReadBlobXXXLong ( image2 ) ; ( void ) ReadBlobXXXLong ( image2 ) ; if ( z != 3 ) ThrowReaderException ( CoderError , ""MultidimensionalMatricesAreNotSupported"" ) ; break ; case 16 : z2 = z = ReadBlobXXXLong ( image2 ) ; if ( z != 3 && z != 1 ) ThrowReaderException ( CoderError , ""MultidimensionalMatricesAreNotSupported"" ) ; Frames = ReadBlobXXXLong ( image2 ) ; break ; default : ThrowReaderException ( CoderError , ""MultidimensionalMatricesAreNotSupported"" ) ; } MATLAB_HDR . Flag1 = ReadBlobXXXShort ( image2 ) ; MATLAB_HDR . NameFlag = ReadBlobXXXShort ( image2 ) ; if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATLAB_HDR.StructureClass%d"" , MATLAB_HDR . StructureClass ) ; if ( MATLAB_HDR . StructureClass != mxCHAR_CLASS && MATLAB_HDR . StructureClass != mxSINGLE_CLASS && MATLAB_HDR . StructureClass != mxDOUBLE_CLASS && MATLAB_HDR . StructureClass != mxINT8_CLASS && MATLAB_HDR . StructureClass != mxUINT8_CLASS && MATLAB_HDR . StructureClass != mxINT16_CLASS && MATLAB_HDR . StructureClass != mxUINT16_CLASS && MATLAB_HDR . StructureClass != mxINT32_CLASS && MATLAB_HDR . StructureClass != mxUINT32_CLASS && MATLAB_HDR . StructureClass != mxINT64_CLASS && MATLAB_HDR . StructureClass != mxUINT64_CLASS ) ThrowReaderException ( CoderError , ""UnsupportedCellTypeInTheMatrix"" ) ; switch ( MATLAB_HDR . NameFlag ) { case 0 : size = ReadBlobXXXLong ( image2 ) ; size = 4 * ( ssize_t ) ( ( size + 3 + 1 ) / 4 ) ; ( void ) SeekBlob ( image2 , size , SEEK_CUR ) ; break ; case 1 : case 2 : case 3 : case 4 : ( void ) ReadBlob ( image2 , 4 , ( unsigned char * ) & size ) ; break ; default : goto MATLAB_KO ; } CellType = ReadBlobXXXLong ( image2 ) ; if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATLAB_HDR.CellType:%.20g"" , ( double ) CellType ) ; ( void ) ReadBlob ( image2 , 4 , ( unsigned char * ) & size ) ; NEXT_FRAME : switch ( CellType ) { case miINT8 : case miUINT8 : sample_size = 8 ; if ( MATLAB_HDR . StructureFlag & FLAG_LOGICAL ) image -> depth = 1 ; else image -> depth = 8 ; ldblk = ( ssize_t ) MATLAB_HDR . SizeX ; break ; case miINT16 : case miUINT16 : sample_size = 16 ; image -> depth = 16 ; ldblk = ( ssize_t ) ( 2 * MATLAB_HDR . SizeX ) ; break ; case miINT32 : case miUINT32 : sample_size = 32 ; image -> depth = 32 ; ldblk = ( ssize_t ) ( 4 * MATLAB_HDR . SizeX ) ; break ; case miINT64 : case miUINT64 : sample_size = 64 ; image -> depth = 64 ; ldblk = ( ssize_t ) ( 8 * MATLAB_HDR . SizeX ) ; break ; case miSINGLE : sample_size = 32 ; image -> depth = 32 ; ( void ) SetImageOption ( clone_info , ""quantum:format"" , ""floating-point"" ) ; if ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) { } ldblk = ( ssize_t ) ( 4 * MATLAB_HDR . SizeX ) ; break ; case miDOUBLE : sample_size = 64 ; image -> depth = 64 ; ( void ) SetImageOption ( clone_info , ""quantum:format"" , ""floating-point"" ) ; DisableMSCWarning ( 4127 ) if ( sizeof ( double ) != 8 ) RestoreMSCWarning ThrowReaderException ( CoderError , ""IncompatibleSizeOfDouble"" ) ; if ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) { } ldblk = ( ssize_t ) ( 8 * MATLAB_HDR . SizeX ) ; break ; default : ThrowReaderException ( CoderError , ""UnsupportedCellTypeInTheMatrix"" ) ; } ( void ) sample_size ; image -> columns = MATLAB_HDR . SizeX ; image -> rows = MATLAB_HDR . SizeY ; quantum_info = AcquireQuantumInfo ( clone_info , image ) ; if ( quantum_info == ( QuantumInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; one = 1 ; image -> colors = one << image -> depth ; if ( image -> columns == 0 || image -> rows == 0 ) goto MATLAB_KO ; if ( ( MATLAB_HDR . DimFlag == 8 ) && ( ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) == 0 ) ) { image -> type = GrayscaleType ; SetImageColorspace ( image , GRAYColorspace , exception ) ; } if ( image_info -> ping ) { size_t temp = image -> columns ; image -> columns = image -> rows ; image -> rows = temp ; goto done_reading ; } status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; BImgBuff = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) ( ldblk ) , sizeof ( unsigned char ) ) ; if ( BImgBuff == NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; MinVal = 0 ; MaxVal = 0 ; if ( CellType == miDOUBLE || CellType == miSINGLE ) { CalcMinMax ( image2 , image_info -> endian , MATLAB_HDR . SizeX , MATLAB_HDR . SizeY , CellType , ldblk , BImgBuff , & quantum_info -> minimum , & quantum_info -> maximum ) ; } if ( z == 1 ) z = 0 ; do { for ( i = 0 ; i < ( ssize_t ) MATLAB_HDR . SizeY ; i ++ ) { q = GetAuthenticPixels ( image , 0 , MATLAB_HDR . SizeY - i - 1 , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) { if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATsetimagepixelsreturnsunexpectedNULLonarow%u."" , ( unsigned ) ( MATLAB_HDR . SizeY - i - 1 ) ) ; goto done_reading ; } if ( ReadBlob ( image2 , ldblk , ( unsigned char * ) BImgBuff ) != ( ssize_t ) ldblk ) { if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATcannotreadscanrow%ufromafile."" , ( unsigned ) ( MATLAB_HDR . SizeY - i - 1 ) ) ; goto ExitLoop ; } if ( ( CellType == miINT8 || CellType == miUINT8 ) && ( MATLAB_HDR . StructureFlag & FLAG_LOGICAL ) ) { FixLogical ( ( unsigned char * ) BImgBuff , ldblk ) ; if ( ImportQuantumPixels ( image , ( CacheView * ) NULL , quantum_info , z2qtype [ z ] , BImgBuff , exception ) <= 0 ) { ImportQuantumPixelsFailed : if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATfailedtoImportQuantumPixelsforarow%u"" , ( unsigned ) ( MATLAB_HDR . SizeY - i - 1 ) ) ; break ; } } else { if ( ImportQuantumPixels ( image , ( CacheView * ) NULL , quantum_info , z2qtype [ z ] , BImgBuff , exception ) <= 0 ) goto ImportQuantumPixelsFailed ; if ( z <= 1 && ( CellType == miINT8 || CellType == miINT16 || CellType == miINT32 || CellType == miINT64 ) ) FixSignedValues ( image , q , MATLAB_HDR . SizeX ) ; } if ( ! SyncAuthenticPixels ( image , exception ) ) { if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""MATfailedtosyncimagepixelsforarow%u"" , ( unsigned ) ( MATLAB_HDR . SizeY - i - 1 ) ) ; goto ExitLoop ; } } } while ( z -- >= 2 ) ; ExitLoop : if ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) { CellType = ReadBlobXXXLong ( image2 ) ; i = ReadBlobXXXLong ( image2 ) ; if ( CellType == miDOUBLE || CellType == miSINGLE ) { CalcMinMax ( image2 , image_info -> endian , MATLAB_HDR . SizeX , MATLAB_HDR . SizeY , CellType , ldblk , BImgBuff , & MinVal , & MaxVal ) ; } if ( CellType == miDOUBLE ) for ( i = 0 ; i < ( ssize_t ) MATLAB_HDR . SizeY ; i ++ ) { ReadBlobDoublesXXX ( image2 , ldblk , ( double * ) BImgBuff ) ; InsertComplexDoubleRow ( image , ( double * ) BImgBuff , i , MinVal , MaxVal , exception ) ; } if ( CellType == miSINGLE ) for ( i = 0 ; i < ( ssize_t ) MATLAB_HDR . SizeY ; i ++ ) { ReadBlobFloatsXXX ( image2 , ldblk , ( float * ) BImgBuff ) ; InsertComplexFloatRow ( image , ( float * ) BImgBuff , i , MinVal , MaxVal , exception ) ; } } if ( ( MATLAB_HDR . DimFlag == 8 ) && ( ( MATLAB_HDR . StructureFlag & FLAG_COMPLEX ) == 0 ) ) image -> type = GrayscaleType ; if ( image -> depth == 1 ) image -> type = BilevelType ; if ( image2 == image ) image2 = NULL ; rotated_image = RotateImage ( image , 90.0 , exception ) ; if ( rotated_image != ( Image * ) NULL ) { rotated_image -> page . x = 0 ; rotated_image -> page . y = 0 ; blob = rotated_image -> blob ; rotated_image -> blob = image -> blob ; rotated_image -> colors = image -> colors ; image -> blob = blob ; AppendImageToList ( & image , rotated_image ) ; DeleteImageFromList ( & image ) ; } done_reading : if ( image2 != NULL ) if ( image2 != image ) { DeleteImageFromList ( & image2 ) ; if ( clone_info ) { if ( clone_info -> file ) { fclose ( clone_info -> file ) ; clone_info -> file = NULL ; ( void ) remove_utf8 ( clone_info -> filename ) ; } } } AcquireNextImage ( image_info , image , exception ) ; if ( image -> next == ( Image * ) NULL ) break ; image = SyncNextImageInList ( image ) ; image -> columns = image -> rows = 0 ; image -> colors = 0 ; RelinquishMagickMemory ( BImgBuff ) ; BImgBuff = NULL ; if ( -- Frames > 0 ) { z = z2 ; if ( image2 == NULL ) image2 = image ; goto NEXT_FRAME ; } if ( ( image2 != NULL ) && ( image2 != image ) ) { DeleteImageFromList ( & image2 ) ; if ( clone_info ) { if ( clone_info -> file ) { fclose ( clone_info -> file ) ; clone_info -> file = NULL ; ( void ) remove_utf8 ( clone_info -> filename ) ; } } } } clone_info = DestroyImageInfo ( clone_info ) ; RelinquishMagickMemory ( BImgBuff ) ; CloseBlob ( image ) ; { Image * p ; ssize_t scene = 0 ; p = image ; image = NULL ; while ( p != ( Image * ) NULL ) { Image * tmp = p ; if ( ( p -> rows == 0 ) || ( p -> columns == 0 ) ) { p = p -> previous ; DeleteImageFromList ( & tmp ) ; } else { image = p ; p = p -> previous ; } } for ( p = image ; p != ( Image * ) NULL ; p = p -> next ) p -> scene = scene ++ ; } if ( clone_info != NULL ) { if ( clone_info -> file ) { fclose ( clone_info -> file ) ; clone_info -> file = NULL ; ( void ) remove_utf8 ( clone_info -> filename ) ; } DestroyImageInfo ( clone_info ) ; clone_info = NULL ; } if ( logging ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""return"" ) ; if ( image == NULL ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; return ( image ) ; } "," , sizeof ( double ) ) ; ",ImageMagick@ImageMagick/1bc1fd0ff8c555841c78829217ac81fa0598255d,CVE-2016-10071,https://github.com/ImageMagick/ImageMagick/commit/1bc1fd0ff8c555841c78829217ac81fa0598255d,2017-03-02T21:59Z 1470,CWE-362,"CWE-362 static int perf_swevent_add ( struct perf_event * event , int flags ) { struct swevent_htable * swhash = this_cpu_ptr ( & swevent_htable ) ; struct hw_perf_event * hwc = & event -> hw ; struct hlist_head * head ; if ( is_sampling_event ( event ) ) { hwc -> last_period = hwc -> sample_period ; perf_swevent_set_period ( event ) ; } hwc -> state = ! ( flags & PERF_EF_START ) ; head = find_swevent_head ( swhash , event ) ; if ( ! head ) { WARN_ON_ONCE ( swhash -> online ) ; return - EINVAL ; } hlist_add_head_rcu ( & event -> hlist_entry , head ) ; perf_event_update_userpage ( event ) ; return 0 ; } "," ; if ( WARN_ON_ONCE ( ! head ) ) return - EINVAL - EINVAL ; hlist_add_head_rcu ( & ",torvalds@linux/12ca6ad2e3a896256f086497a7c7406a547ee373,CVE-2015-8963,https://github.com/torvalds/linux/commit/12ca6ad2e3a896256f086497a7c7406a547ee373,2016-11-16T05:59Z 1471,CWE-674,"CWE-674 static int bgp_attr_print ( netdissect_options * ndo , u_int atype , const u_char * pptr , u_int len ) { int i ; uint16_t af ; uint8_t safi , snpa , nhlen ; union { float f ; uint32_t i ; } bw ; int advance ; u_int tlen ; const u_char * tptr ; char buf [ MAXHOSTNAMELEN + 100 ] ; int as_size ; tptr = pptr ; tlen = len ; switch ( atype ) { case BGPTYPE_ORIGIN : if ( len != 1 ) ND_PRINT ( ( ndo , ""invalidlen"" ) ) ; else { ND_TCHECK ( * tptr ) ; ND_PRINT ( ( ndo , ""%s"" , tok2str ( bgp_origin_values , ""UnknownOriginTypecode"" , tptr [ 0 ] ) ) ) ; } break ; case BGPTYPE_AS4_PATH : case BGPTYPE_AS_PATH : if ( len % 2 ) { ND_PRINT ( ( ndo , ""invalidlen"" ) ) ; break ; } if ( ! len ) { ND_PRINT ( ( ndo , ""empty"" ) ) ; break ; } as_size = bgp_attr_get_as_size ( ndo , atype , pptr , len ) ; while ( tptr < pptr + len ) { ND_TCHECK ( tptr [ 0 ] ) ; ND_PRINT ( ( ndo , ""%s"" , tok2str ( bgp_as_path_segment_open_values , ""?"" , tptr [ 0 ] ) ) ) ; ND_TCHECK ( tptr [ 1 ] ) ; for ( i = 0 ; i < tptr [ 1 ] * as_size ; i += as_size ) { ND_TCHECK2 ( tptr [ 2 + i ] , as_size ) ; ND_PRINT ( ( ndo , ""%s"" , as_printf ( ndo , astostr , sizeof ( astostr ) , as_size == 2 ? EXTRACT_16BITS ( & tptr [ 2 + i ] ) : EXTRACT_32BITS ( & tptr [ 2 + i ] ) ) ) ) ; } ND_TCHECK ( tptr [ 0 ] ) ; ND_PRINT ( ( ndo , ""%s"" , tok2str ( bgp_as_path_segment_close_values , ""?"" , tptr [ 0 ] ) ) ) ; ND_TCHECK ( tptr [ 1 ] ) ; tptr += 2 + tptr [ 1 ] * as_size ; } break ; case BGPTYPE_NEXT_HOP : if ( len != 4 ) ND_PRINT ( ( ndo , ""invalidlen"" ) ) ; else { ND_TCHECK2 ( tptr [ 0 ] , 4 ) ; ND_PRINT ( ( ndo , ""%s"" , ipaddr_string ( ndo , tptr ) ) ) ; } break ; case BGPTYPE_MULTI_EXIT_DISC : case BGPTYPE_LOCAL_PREF : if ( len != 4 ) ND_PRINT ( ( ndo , ""invalidlen"" ) ) ; else { ND_TCHECK2 ( tptr [ 0 ] , 4 ) ; ND_PRINT ( ( ndo , ""%u"" , EXTRACT_32BITS ( tptr ) ) ) ; } break ; case BGPTYPE_ATOMIC_AGGREGATE : if ( len != 0 ) ND_PRINT ( ( ndo , ""invalidlen"" ) ) ; break ; case BGPTYPE_AGGREGATOR : if ( len != 6 && len != 8 ) { ND_PRINT ( ( ndo , ""invalidlen"" ) ) ; break ; } ND_TCHECK2 ( tptr [ 0 ] , len ) ; if ( len == 6 ) { ND_PRINT ( ( ndo , ""AS#%s,origin%s"" , as_printf ( ndo , astostr , sizeof ( astostr ) , EXTRACT_16BITS ( tptr ) ) , ipaddr_string ( ndo , tptr + 2 ) ) ) ; } else { ND_PRINT ( ( ndo , ""AS#%s,origin%s"" , as_printf ( ndo , astostr , sizeof ( astostr ) , EXTRACT_32BITS ( tptr ) ) , ipaddr_string ( ndo , tptr + 4 ) ) ) ; } break ; case BGPTYPE_AGGREGATOR4 : if ( len != 8 ) { ND_PRINT ( ( ndo , ""invalidlen"" ) ) ; break ; } ND_TCHECK2 ( tptr [ 0 ] , 8 ) ; ND_PRINT ( ( ndo , ""AS#%s,origin%s"" , as_printf ( ndo , astostr , sizeof ( astostr ) , EXTRACT_32BITS ( tptr ) ) , ipaddr_string ( ndo , tptr + 4 ) ) ) ; break ; case BGPTYPE_COMMUNITIES : if ( len % 4 ) { ND_PRINT ( ( ndo , ""invalidlen"" ) ) ; break ; } while ( tlen > 0 ) { uint32_t comm ; ND_TCHECK2 ( tptr [ 0 ] , 4 ) ; comm = EXTRACT_32BITS ( tptr ) ; switch ( comm ) { case BGP_COMMUNITY_NO_EXPORT : ND_PRINT ( ( ndo , ""NO_EXPORT"" ) ) ; break ; case BGP_COMMUNITY_NO_ADVERT : ND_PRINT ( ( ndo , ""NO_ADVERTISE"" ) ) ; break ; case BGP_COMMUNITY_NO_EXPORT_SUBCONFED : ND_PRINT ( ( ndo , ""NO_EXPORT_SUBCONFED"" ) ) ; break ; default : ND_PRINT ( ( ndo , ""%u:%u%s"" , ( comm >> 16 ) & 0xffff , comm & 0xffff , ( tlen > 4 ) ? "","" : """" ) ) ; break ; } tlen -= 4 ; tptr += 4 ; } break ; case BGPTYPE_ORIGINATOR_ID : if ( len != 4 ) { ND_PRINT ( ( ndo , ""invalidlen"" ) ) ; break ; } ND_TCHECK2 ( tptr [ 0 ] , 4 ) ; ND_PRINT ( ( ndo , ""%s"" , ipaddr_string ( ndo , tptr ) ) ) ; break ; case BGPTYPE_CLUSTER_LIST : if ( len % 4 ) { ND_PRINT ( ( ndo , ""invalidlen"" ) ) ; break ; } while ( tlen > 0 ) { ND_TCHECK2 ( tptr [ 0 ] , 4 ) ; ND_PRINT ( ( ndo , ""%s%s"" , ipaddr_string ( ndo , tptr ) , ( tlen > 4 ) ? "","" : """" ) ) ; tlen -= 4 ; tptr += 4 ; } break ; case BGPTYPE_MP_REACH_NLRI : ND_TCHECK2 ( tptr [ 0 ] , 3 ) ; af = EXTRACT_16BITS ( tptr ) ; safi = tptr [ 2 ] ; ND_PRINT ( ( ndo , ""\\n\\tAFI:%s(%u),%sSAFI:%s(%u)"" , tok2str ( af_values , ""UnknownAFI"" , af ) , af , ( safi > 128 ) ? ""vendorspecific"" : """" , tok2str ( bgp_safi_values , ""UnknownSAFI"" , safi ) , safi ) ) ; switch ( af << 8 | safi ) { case ( AFNUM_INET << 8 | SAFNUM_UNICAST ) : case ( AFNUM_INET << 8 | SAFNUM_MULTICAST ) : case ( AFNUM_INET << 8 | SAFNUM_UNIMULTICAST ) : case ( AFNUM_INET << 8 | SAFNUM_LABUNICAST ) : case ( AFNUM_INET << 8 | SAFNUM_RT_ROUTING_INFO ) : case ( AFNUM_INET << 8 | SAFNUM_VPNUNICAST ) : case ( AFNUM_INET << 8 | SAFNUM_VPNMULTICAST ) : case ( AFNUM_INET << 8 | SAFNUM_VPNUNIMULTICAST ) : case ( AFNUM_INET << 8 | SAFNUM_MULTICAST_VPN ) : case ( AFNUM_INET << 8 | SAFNUM_MDT ) : case ( AFNUM_INET6 << 8 | SAFNUM_UNICAST ) : case ( AFNUM_INET6 << 8 | SAFNUM_MULTICAST ) : case ( AFNUM_INET6 << 8 | SAFNUM_UNIMULTICAST ) : case ( AFNUM_INET6 << 8 | SAFNUM_LABUNICAST ) : case ( AFNUM_INET6 << 8 | SAFNUM_VPNUNICAST ) : case ( AFNUM_INET6 << 8 | SAFNUM_VPNMULTICAST ) : case ( AFNUM_INET6 << 8 | SAFNUM_VPNUNIMULTICAST ) : case ( AFNUM_NSAP << 8 | SAFNUM_UNICAST ) : case ( AFNUM_NSAP << 8 | SAFNUM_MULTICAST ) : case ( AFNUM_NSAP << 8 | SAFNUM_UNIMULTICAST ) : case ( AFNUM_NSAP << 8 | SAFNUM_VPNUNICAST ) : case ( AFNUM_NSAP << 8 | SAFNUM_VPNMULTICAST ) : case ( AFNUM_NSAP << 8 | SAFNUM_VPNUNIMULTICAST ) : case ( AFNUM_L2VPN << 8 | SAFNUM_VPNUNICAST ) : case ( AFNUM_L2VPN << 8 | SAFNUM_VPNMULTICAST ) : case ( AFNUM_L2VPN << 8 | SAFNUM_VPNUNIMULTICAST ) : case ( AFNUM_VPLS << 8 | SAFNUM_VPLS ) : break ; default : ND_TCHECK2 ( tptr [ 0 ] , tlen ) ; ND_PRINT ( ( ndo , ""\\n\\tnoAFI%u/SAFI%udecoder"" , af , safi ) ) ; if ( ndo -> ndo_vflag <= 1 ) print_unknown_data ( ndo , tptr , ""\\n\\t"" , tlen ) ; goto done ; break ; } tptr += 3 ; ND_TCHECK ( tptr [ 0 ] ) ; nhlen = tptr [ 0 ] ; tlen = nhlen ; tptr ++ ; if ( tlen ) { int nnh = 0 ; ND_PRINT ( ( ndo , ""\\n\\tnexthop:"" ) ) ; while ( tlen > 0 ) { if ( nnh ++ > 0 ) { ND_PRINT ( ( ndo , "","" ) ) ; } switch ( af << 8 | safi ) { case ( AFNUM_INET << 8 | SAFNUM_UNICAST ) : case ( AFNUM_INET << 8 | SAFNUM_MULTICAST ) : case ( AFNUM_INET << 8 | SAFNUM_UNIMULTICAST ) : case ( AFNUM_INET << 8 | SAFNUM_LABUNICAST ) : case ( AFNUM_INET << 8 | SAFNUM_RT_ROUTING_INFO ) : case ( AFNUM_INET << 8 | SAFNUM_MULTICAST_VPN ) : case ( AFNUM_INET << 8 | SAFNUM_MDT ) : if ( tlen < ( int ) sizeof ( struct in_addr ) ) { ND_PRINT ( ( ndo , ""invalidlen"" ) ) ; tlen = 0 ; } else { ND_TCHECK2 ( tptr [ 0 ] , sizeof ( struct in_addr ) ) ; ND_PRINT ( ( ndo , ""%s"" , ipaddr_string ( ndo , tptr ) ) ) ; tlen -= sizeof ( struct in_addr ) ; tptr += sizeof ( struct in_addr ) ; } break ; case ( AFNUM_INET << 8 | SAFNUM_VPNUNICAST ) : case ( AFNUM_INET << 8 | SAFNUM_VPNMULTICAST ) : case ( AFNUM_INET << 8 | SAFNUM_VPNUNIMULTICAST ) : if ( tlen < ( int ) ( sizeof ( struct in_addr ) + BGP_VPN_RD_LEN ) ) { ND_PRINT ( ( ndo , ""invalidlen"" ) ) ; tlen = 0 ; } else { ND_TCHECK2 ( tptr [ 0 ] , sizeof ( struct in_addr ) + BGP_VPN_RD_LEN ) ; ND_PRINT ( ( ndo , ""RD:%s,%s"" , bgp_vpn_rd_print ( ndo , tptr ) , ipaddr_string ( ndo , tptr + BGP_VPN_RD_LEN ) ) ) ; tlen -= ( sizeof ( struct in_addr ) + BGP_VPN_RD_LEN ) ; tptr += ( sizeof ( struct in_addr ) + BGP_VPN_RD_LEN ) ; } break ; case ( AFNUM_INET6 << 8 | SAFNUM_UNICAST ) : case ( AFNUM_INET6 << 8 | SAFNUM_MULTICAST ) : case ( AFNUM_INET6 << 8 | SAFNUM_UNIMULTICAST ) : case ( AFNUM_INET6 << 8 | SAFNUM_LABUNICAST ) : if ( tlen < ( int ) sizeof ( struct in6_addr ) ) { ND_PRINT ( ( ndo , ""invalidlen"" ) ) ; tlen = 0 ; } else { ND_TCHECK2 ( tptr [ 0 ] , sizeof ( struct in6_addr ) ) ; ND_PRINT ( ( ndo , ""%s"" , ip6addr_string ( ndo , tptr ) ) ) ; tlen -= sizeof ( struct in6_addr ) ; tptr += sizeof ( struct in6_addr ) ; } break ; case ( AFNUM_INET6 << 8 | SAFNUM_VPNUNICAST ) : case ( AFNUM_INET6 << 8 | SAFNUM_VPNMULTICAST ) : case ( AFNUM_INET6 << 8 | SAFNUM_VPNUNIMULTICAST ) : if ( tlen < ( int ) ( sizeof ( struct in6_addr ) + BGP_VPN_RD_LEN ) ) { ND_PRINT ( ( ndo , ""invalidlen"" ) ) ; tlen = 0 ; } else { ND_TCHECK2 ( tptr [ 0 ] , sizeof ( struct in6_addr ) + BGP_VPN_RD_LEN ) ; ND_PRINT ( ( ndo , ""RD:%s,%s"" , bgp_vpn_rd_print ( ndo , tptr ) , ip6addr_string ( ndo , tptr + BGP_VPN_RD_LEN ) ) ) ; tlen -= ( sizeof ( struct in6_addr ) + BGP_VPN_RD_LEN ) ; tptr += ( sizeof ( struct in6_addr ) + BGP_VPN_RD_LEN ) ; } break ; case ( AFNUM_VPLS << 8 | SAFNUM_VPLS ) : case ( AFNUM_L2VPN << 8 | SAFNUM_VPNUNICAST ) : case ( AFNUM_L2VPN << 8 | SAFNUM_VPNMULTICAST ) : case ( AFNUM_L2VPN << 8 | SAFNUM_VPNUNIMULTICAST ) : if ( tlen < ( int ) sizeof ( struct in_addr ) ) { ND_PRINT ( ( ndo , ""invalidlen"" ) ) ; tlen = 0 ; } else { ND_TCHECK2 ( tptr [ 0 ] , sizeof ( struct in_addr ) ) ; ND_PRINT ( ( ndo , ""%s"" , ipaddr_string ( ndo , tptr ) ) ) ; tlen -= ( sizeof ( struct in_addr ) ) ; tptr += ( sizeof ( struct in_addr ) ) ; } break ; case ( AFNUM_NSAP << 8 | SAFNUM_UNICAST ) : case ( AFNUM_NSAP << 8 | SAFNUM_MULTICAST ) : case ( AFNUM_NSAP << 8 | SAFNUM_UNIMULTICAST ) : ND_TCHECK2 ( tptr [ 0 ] , tlen ) ; ND_PRINT ( ( ndo , ""%s"" , isonsap_string ( ndo , tptr , tlen ) ) ) ; tptr += tlen ; tlen = 0 ; break ; case ( AFNUM_NSAP << 8 | SAFNUM_VPNUNICAST ) : case ( AFNUM_NSAP << 8 | SAFNUM_VPNMULTICAST ) : case ( AFNUM_NSAP << 8 | SAFNUM_VPNUNIMULTICAST ) : if ( tlen < BGP_VPN_RD_LEN + 1 ) { ND_PRINT ( ( ndo , ""invalidlen"" ) ) ; tlen = 0 ; } else { ND_TCHECK2 ( tptr [ 0 ] , tlen ) ; ND_PRINT ( ( ndo , ""RD:%s,%s"" , bgp_vpn_rd_print ( ndo , tptr ) , isonsap_string ( ndo , tptr + BGP_VPN_RD_LEN , tlen - BGP_VPN_RD_LEN ) ) ) ; if ( tlen == BGP_VPN_RD_LEN + 4 + sizeof ( struct in_addr ) && EXTRACT_32BITS ( tptr + BGP_VPN_RD_LEN ) == 0x47000601 ) ND_PRINT ( ( ndo , ""=%s"" , ipaddr_string ( ndo , tptr + BGP_VPN_RD_LEN + 4 ) ) ) ; else if ( tlen == BGP_VPN_RD_LEN + 3 + sizeof ( struct in6_addr ) && EXTRACT_24BITS ( tptr + BGP_VPN_RD_LEN ) == 0x350000 ) ND_PRINT ( ( ndo , ""=%s"" , ip6addr_string ( ndo , tptr + BGP_VPN_RD_LEN + 3 ) ) ) ; tptr += tlen ; tlen = 0 ; } break ; default : ND_TCHECK2 ( tptr [ 0 ] , tlen ) ; ND_PRINT ( ( ndo , ""noAFI%u/SAFI%udecoder"" , af , safi ) ) ; if ( ndo -> ndo_vflag <= 1 ) print_unknown_data ( ndo , tptr , ""\\n\\t"" , tlen ) ; tptr += tlen ; tlen = 0 ; goto done ; break ; } } } ND_PRINT ( ( ndo , "",nh-length:%u"" , nhlen ) ) ; tptr += tlen ; ND_TCHECK ( tptr [ 0 ] ) ; snpa = tptr [ 0 ] ; tptr ++ ; if ( snpa ) { ND_PRINT ( ( ndo , ""\\n\\t%uSNPA"" , snpa ) ) ; for ( ; snpa > 0 ; snpa -- ) { ND_TCHECK ( tptr [ 0 ] ) ; ND_PRINT ( ( ndo , ""\\n\\t%dbytes"" , tptr [ 0 ] ) ) ; tptr += tptr [ 0 ] + 1 ; } } else { ND_PRINT ( ( ndo , "",noSNPA"" ) ) ; } while ( tptr < pptr + len ) { switch ( af << 8 | safi ) { case ( AFNUM_INET << 8 | SAFNUM_UNICAST ) : case ( AFNUM_INET << 8 | SAFNUM_MULTICAST ) : case ( AFNUM_INET << 8 | SAFNUM_UNIMULTICAST ) : advance = decode_prefix4 ( ndo , tptr , len , buf , sizeof ( buf ) ) ; if ( advance == - 1 ) ND_PRINT ( ( ndo , ""\\n\\t(illegalprefixlength)"" ) ) ; else if ( advance == - 2 ) goto trunc ; else if ( advance == - 3 ) break ; else ND_PRINT ( ( ndo , ""\\n\\t%s"" , buf ) ) ; break ; case ( AFNUM_INET << 8 | SAFNUM_LABUNICAST ) : advance = decode_labeled_prefix4 ( ndo , tptr , len , buf , sizeof ( buf ) ) ; if ( advance == - 1 ) ND_PRINT ( ( ndo , ""\\n\\t(illegalprefixlength)"" ) ) ; else if ( advance == - 2 ) goto trunc ; else if ( advance == - 3 ) break ; else ND_PRINT ( ( ndo , ""\\n\\t%s"" , buf ) ) ; break ; case ( AFNUM_INET << 8 | SAFNUM_VPNUNICAST ) : case ( AFNUM_INET << 8 | SAFNUM_VPNMULTICAST ) : case ( AFNUM_INET << 8 | SAFNUM_VPNUNIMULTICAST ) : advance = decode_labeled_vpn_prefix4 ( ndo , tptr , buf , sizeof ( buf ) ) ; if ( advance == - 1 ) ND_PRINT ( ( ndo , ""\\n\\t(illegalprefixlength)"" ) ) ; else if ( advance == - 2 ) goto trunc ; else ND_PRINT ( ( ndo , ""\\n\\t%s"" , buf ) ) ; break ; case ( AFNUM_INET << 8 | SAFNUM_RT_ROUTING_INFO ) : advance = decode_rt_routing_info ( ndo , tptr , buf , sizeof ( buf ) ) ; if ( advance == - 1 ) ND_PRINT ( ( ndo , ""\\n\\t(illegalprefixlength)"" ) ) ; else if ( advance == - 2 ) goto trunc ; else ND_PRINT ( ( ndo , ""\\n\\t%s"" , buf ) ) ; break ; case ( AFNUM_INET << 8 | SAFNUM_MULTICAST_VPN ) : case ( AFNUM_INET6 << 8 | SAFNUM_MULTICAST_VPN ) : advance = decode_multicast_vpn ( ndo , tptr , buf , sizeof ( buf ) ) ; if ( advance == - 1 ) ND_PRINT ( ( ndo , ""\\n\\t(illegalprefixlength)"" ) ) ; else if ( advance == - 2 ) goto trunc ; else ND_PRINT ( ( ndo , ""\\n\\t%s"" , buf ) ) ; break ; case ( AFNUM_INET << 8 | SAFNUM_MDT ) : advance = decode_mdt_vpn_nlri ( ndo , tptr , buf , sizeof ( buf ) ) ; if ( advance == - 1 ) ND_PRINT ( ( ndo , ""\\n\\t(illegalprefixlength)"" ) ) ; else if ( advance == - 2 ) goto trunc ; else ND_PRINT ( ( ndo , ""\\n\\t%s"" , buf ) ) ; break ; case ( AFNUM_INET6 << 8 | SAFNUM_UNICAST ) : case ( AFNUM_INET6 << 8 | SAFNUM_MULTICAST ) : case ( AFNUM_INET6 << 8 | SAFNUM_UNIMULTICAST ) : advance = decode_prefix6 ( ndo , tptr , len , buf , sizeof ( buf ) ) ; if ( advance == - 1 ) ND_PRINT ( ( ndo , ""\\n\\t(illegalprefixlength)"" ) ) ; else if ( advance == - 2 ) goto trunc ; else if ( advance == - 3 ) break ; else ND_PRINT ( ( ndo , ""\\n\\t%s"" , buf ) ) ; break ; case ( AFNUM_INET6 << 8 | SAFNUM_LABUNICAST ) : advance = decode_labeled_prefix6 ( ndo , tptr , len , buf , sizeof ( buf ) ) ; if ( advance == - 1 ) ND_PRINT ( ( ndo , ""\\n\\t(illegalprefixlength)"" ) ) ; else if ( advance == - 2 ) goto trunc ; else if ( advance == - 3 ) break ; else ND_PRINT ( ( ndo , ""\\n\\t%s"" , buf ) ) ; break ; case ( AFNUM_INET6 << 8 | SAFNUM_VPNUNICAST ) : case ( AFNUM_INET6 << 8 | SAFNUM_VPNMULTICAST ) : case ( AFNUM_INET6 << 8 | SAFNUM_VPNUNIMULTICAST ) : advance = decode_labeled_vpn_prefix6 ( ndo , tptr , buf , sizeof ( buf ) ) ; if ( advance == - 1 ) ND_PRINT ( ( ndo , ""\\n\\t(illegalprefixlength)"" ) ) ; else if ( advance == - 2 ) goto trunc ; else ND_PRINT ( ( ndo , ""\\n\\t%s"" , buf ) ) ; break ; case ( AFNUM_VPLS << 8 | SAFNUM_VPLS ) : case ( AFNUM_L2VPN << 8 | SAFNUM_VPNUNICAST ) : case ( AFNUM_L2VPN << 8 | SAFNUM_VPNMULTICAST ) : case ( AFNUM_L2VPN << 8 | SAFNUM_VPNUNIMULTICAST ) : advance = decode_labeled_vpn_l2 ( ndo , tptr , buf , sizeof ( buf ) ) ; if ( advance == - 1 ) ND_PRINT ( ( ndo , ""\\n\\t(illegallength)"" ) ) ; else if ( advance == - 2 ) goto trunc ; else ND_PRINT ( ( ndo , ""\\n\\t%s"" , buf ) ) ; break ; case ( AFNUM_NSAP << 8 | SAFNUM_UNICAST ) : case ( AFNUM_NSAP << 8 | SAFNUM_MULTICAST ) : case ( AFNUM_NSAP << 8 | SAFNUM_UNIMULTICAST ) : advance = decode_clnp_prefix ( ndo , tptr , buf , sizeof ( buf ) ) ; if ( advance == - 1 ) ND_PRINT ( ( ndo , ""\\n\\t(illegalprefixlength)"" ) ) ; else if ( advance == - 2 ) goto trunc ; else ND_PRINT ( ( ndo , ""\\n\\t%s"" , buf ) ) ; break ; case ( AFNUM_NSAP << 8 | SAFNUM_VPNUNICAST ) : case ( AFNUM_NSAP << 8 | SAFNUM_VPNMULTICAST ) : case ( AFNUM_NSAP << 8 | SAFNUM_VPNUNIMULTICAST ) : advance = decode_labeled_vpn_clnp_prefix ( ndo , tptr , buf , sizeof ( buf ) ) ; if ( advance == - 1 ) ND_PRINT ( ( ndo , ""\\n\\t(illegalprefixlength)"" ) ) ; else if ( advance == - 2 ) goto trunc ; else ND_PRINT ( ( ndo , ""\\n\\t%s"" , buf ) ) ; break ; default : ND_TCHECK2 ( * tptr , tlen ) ; ND_PRINT ( ( ndo , ""\\n\\tnoAFI%u/SAFI%udecoder"" , af , safi ) ) ; if ( ndo -> ndo_vflag <= 1 ) print_unknown_data ( ndo , tptr , ""\\n\\t"" , tlen ) ; advance = 0 ; tptr = pptr + len ; break ; } if ( advance < 0 ) break ; tptr += advance ; } done : break ; case BGPTYPE_MP_UNREACH_NLRI : ND_TCHECK2 ( tptr [ 0 ] , BGP_MP_NLRI_MINSIZE ) ; af = EXTRACT_16BITS ( tptr ) ; safi = tptr [ 2 ] ; ND_PRINT ( ( ndo , ""\\n\\tAFI:%s(%u),%sSAFI:%s(%u)"" , tok2str ( af_values , ""UnknownAFI"" , af ) , af , ( safi > 128 ) ? ""vendorspecific"" : """" , tok2str ( bgp_safi_values , ""UnknownSAFI"" , safi ) , safi ) ) ; if ( len == BGP_MP_NLRI_MINSIZE ) ND_PRINT ( ( ndo , ""\\n\\tEnd-of-RibMarker(emptyNLRI)"" ) ) ; tptr += 3 ; while ( tptr < pptr + len ) { switch ( af << 8 | safi ) { case ( AFNUM_INET << 8 | SAFNUM_UNICAST ) : case ( AFNUM_INET << 8 | SAFNUM_MULTICAST ) : case ( AFNUM_INET << 8 | SAFNUM_UNIMULTICAST ) : advance = decode_prefix4 ( ndo , tptr , len , buf , sizeof ( buf ) ) ; if ( advance == - 1 ) ND_PRINT ( ( ndo , ""\\n\\t(illegalprefixlength)"" ) ) ; else if ( advance == - 2 ) goto trunc ; else if ( advance == - 3 ) break ; else ND_PRINT ( ( ndo , ""\\n\\t%s"" , buf ) ) ; break ; case ( AFNUM_INET << 8 | SAFNUM_LABUNICAST ) : advance = decode_labeled_prefix4 ( ndo , tptr , len , buf , sizeof ( buf ) ) ; if ( advance == - 1 ) ND_PRINT ( ( ndo , ""\\n\\t(illegalprefixlength)"" ) ) ; else if ( advance == - 2 ) goto trunc ; else if ( advance == - 3 ) break ; else ND_PRINT ( ( ndo , ""\\n\\t%s"" , buf ) ) ; break ; case ( AFNUM_INET << 8 | SAFNUM_VPNUNICAST ) : case ( AFNUM_INET << 8 | SAFNUM_VPNMULTICAST ) : case ( AFNUM_INET << 8 | SAFNUM_VPNUNIMULTICAST ) : advance = decode_labeled_vpn_prefix4 ( ndo , tptr , buf , sizeof ( buf ) ) ; if ( advance == - 1 ) ND_PRINT ( ( ndo , ""\\n\\t(illegalprefixlength)"" ) ) ; else if ( advance == - 2 ) goto trunc ; else ND_PRINT ( ( ndo , ""\\n\\t%s"" , buf ) ) ; break ; case ( AFNUM_INET6 << 8 | SAFNUM_UNICAST ) : case ( AFNUM_INET6 << 8 | SAFNUM_MULTICAST ) : case ( AFNUM_INET6 << 8 | SAFNUM_UNIMULTICAST ) : advance = decode_prefix6 ( ndo , tptr , len , buf , sizeof ( buf ) ) ; if ( advance == - 1 ) ND_PRINT ( ( ndo , ""\\n\\t(illegalprefixlength)"" ) ) ; else if ( advance == - 2 ) goto trunc ; else if ( advance == - 3 ) break ; else ND_PRINT ( ( ndo , ""\\n\\t%s"" , buf ) ) ; break ; case ( AFNUM_INET6 << 8 | SAFNUM_LABUNICAST ) : advance = decode_labeled_prefix6 ( ndo , tptr , len , buf , sizeof ( buf ) ) ; if ( advance == - 1 ) ND_PRINT ( ( ndo , ""\\n\\t(illegalprefixlength)"" ) ) ; else if ( advance == - 2 ) goto trunc ; else if ( advance == - 3 ) break ; else ND_PRINT ( ( ndo , ""\\n\\t%s"" , buf ) ) ; break ; case ( AFNUM_INET6 << 8 | SAFNUM_VPNUNICAST ) : case ( AFNUM_INET6 << 8 | SAFNUM_VPNMULTICAST ) : case ( AFNUM_INET6 << 8 | SAFNUM_VPNUNIMULTICAST ) : advance = decode_labeled_vpn_prefix6 ( ndo , tptr , buf , sizeof ( buf ) ) ; if ( advance == - 1 ) ND_PRINT ( ( ndo , ""\\n\\t(illegalprefixlength)"" ) ) ; else if ( advance == - 2 ) goto trunc ; else ND_PRINT ( ( ndo , ""\\n\\t%s"" , buf ) ) ; break ; case ( AFNUM_VPLS << 8 | SAFNUM_VPLS ) : case ( AFNUM_L2VPN << 8 | SAFNUM_VPNUNICAST ) : case ( AFNUM_L2VPN << 8 | SAFNUM_VPNMULTICAST ) : case ( AFNUM_L2VPN << 8 | SAFNUM_VPNUNIMULTICAST ) : advance = decode_labeled_vpn_l2 ( ndo , tptr , buf , sizeof ( buf ) ) ; if ( advance == - 1 ) ND_PRINT ( ( ndo , ""\\n\\t(illegallength)"" ) ) ; else if ( advance == - 2 ) goto trunc ; else ND_PRINT ( ( ndo , ""\\n\\t%s"" , buf ) ) ; break ; case ( AFNUM_NSAP << 8 | SAFNUM_UNICAST ) : case ( AFNUM_NSAP << 8 | SAFNUM_MULTICAST ) : case ( AFNUM_NSAP << 8 | SAFNUM_UNIMULTICAST ) : advance = decode_clnp_prefix ( ndo , tptr , buf , sizeof ( buf ) ) ; if ( advance == - 1 ) ND_PRINT ( ( ndo , ""\\n\\t(illegalprefixlength)"" ) ) ; else if ( advance == - 2 ) goto trunc ; else ND_PRINT ( ( ndo , ""\\n\\t%s"" , buf ) ) ; break ; case ( AFNUM_NSAP << 8 | SAFNUM_VPNUNICAST ) : case ( AFNUM_NSAP << 8 | SAFNUM_VPNMULTICAST ) : case ( AFNUM_NSAP << 8 | SAFNUM_VPNUNIMULTICAST ) : advance = decode_labeled_vpn_clnp_prefix ( ndo , tptr , buf , sizeof ( buf ) ) ; if ( advance == - 1 ) ND_PRINT ( ( ndo , ""\\n\\t(illegalprefixlength)"" ) ) ; else if ( advance == - 2 ) goto trunc ; else ND_PRINT ( ( ndo , ""\\n\\t%s"" , buf ) ) ; break ; case ( AFNUM_INET << 8 | SAFNUM_MDT ) : advance = decode_mdt_vpn_nlri ( ndo , tptr , buf , sizeof ( buf ) ) ; if ( advance == - 1 ) ND_PRINT ( ( ndo , ""\\n\\t(illegalprefixlength)"" ) ) ; else if ( advance == - 2 ) goto trunc ; else ND_PRINT ( ( ndo , ""\\n\\t%s"" , buf ) ) ; break ; case ( AFNUM_INET << 8 | SAFNUM_MULTICAST_VPN ) : case ( AFNUM_INET6 << 8 | SAFNUM_MULTICAST_VPN ) : advance = decode_multicast_vpn ( ndo , tptr , buf , sizeof ( buf ) ) ; if ( advance == - 1 ) ND_PRINT ( ( ndo , ""\\n\\t(illegalprefixlength)"" ) ) ; else if ( advance == - 2 ) goto trunc ; else ND_PRINT ( ( ndo , ""\\n\\t%s"" , buf ) ) ; break ; default : ND_TCHECK2 ( * ( tptr - 3 ) , tlen ) ; ND_PRINT ( ( ndo , ""noAFI%u/SAFI%udecoder"" , af , safi ) ) ; if ( ndo -> ndo_vflag <= 1 ) print_unknown_data ( ndo , tptr - 3 , ""\\n\\t"" , tlen ) ; advance = 0 ; tptr = pptr + len ; break ; } if ( advance < 0 ) break ; tptr += advance ; } break ; case BGPTYPE_EXTD_COMMUNITIES : if ( len % 8 ) { ND_PRINT ( ( ndo , ""invalidlen"" ) ) ; break ; } while ( tlen > 0 ) { uint16_t extd_comm ; ND_TCHECK2 ( tptr [ 0 ] , 2 ) ; extd_comm = EXTRACT_16BITS ( tptr ) ; ND_PRINT ( ( ndo , ""\\n\\t%s(0x%04x),Flags[%s]"" , tok2str ( bgp_extd_comm_subtype_values , ""unknownextdcommunitytypecode"" , extd_comm ) , extd_comm , bittok2str ( bgp_extd_comm_flag_values , ""none"" , extd_comm ) ) ) ; ND_TCHECK2 ( * ( tptr + 2 ) , 6 ) ; switch ( extd_comm ) { case BGP_EXT_COM_RT_0 : case BGP_EXT_COM_RO_0 : case BGP_EXT_COM_L2VPN_RT_0 : ND_PRINT ( ( ndo , "":%u:%u(=%s)"" , EXTRACT_16BITS ( tptr + 2 ) , EXTRACT_32BITS ( tptr + 4 ) , ipaddr_string ( ndo , tptr + 4 ) ) ) ; break ; case BGP_EXT_COM_RT_1 : case BGP_EXT_COM_RO_1 : case BGP_EXT_COM_L2VPN_RT_1 : case BGP_EXT_COM_VRF_RT_IMP : ND_PRINT ( ( ndo , "":%s:%u"" , ipaddr_string ( ndo , tptr + 2 ) , EXTRACT_16BITS ( tptr + 6 ) ) ) ; break ; case BGP_EXT_COM_RT_2 : case BGP_EXT_COM_RO_2 : ND_PRINT ( ( ndo , "":%s:%u"" , as_printf ( ndo , astostr , sizeof ( astostr ) , EXTRACT_32BITS ( tptr + 2 ) ) , EXTRACT_16BITS ( tptr + 6 ) ) ) ; break ; case BGP_EXT_COM_LINKBAND : bw . i = EXTRACT_32BITS ( tptr + 2 ) ; ND_PRINT ( ( ndo , "":bandwidth:%.3fMbps"" , bw . f * 8 / 1000000 ) ) ; break ; case BGP_EXT_COM_VPN_ORIGIN : case BGP_EXT_COM_VPN_ORIGIN2 : case BGP_EXT_COM_VPN_ORIGIN3 : case BGP_EXT_COM_VPN_ORIGIN4 : case BGP_EXT_COM_OSPF_RID : case BGP_EXT_COM_OSPF_RID2 : ND_PRINT ( ( ndo , ""%s"" , ipaddr_string ( ndo , tptr + 2 ) ) ) ; break ; case BGP_EXT_COM_OSPF_RTYPE : case BGP_EXT_COM_OSPF_RTYPE2 : ND_PRINT ( ( ndo , "":area:%s,router-type:%s,metric-type:%s%s"" , ipaddr_string ( ndo , tptr + 2 ) , tok2str ( bgp_extd_comm_ospf_rtype_values , ""unknown(0x%02x)"" , * ( tptr + 6 ) ) , ( * ( tptr + 7 ) & BGP_OSPF_RTYPE_METRIC_TYPE ) ? ""E2"" : """" , ( ( * ( tptr + 6 ) == BGP_OSPF_RTYPE_EXT ) || ( * ( tptr + 6 ) == BGP_OSPF_RTYPE_NSSA ) ) ? ""E1"" : """" ) ) ; break ; case BGP_EXT_COM_L2INFO : ND_PRINT ( ( ndo , "":%sControlFlags[0x%02x]:MTU%u"" , tok2str ( l2vpn_encaps_values , ""unknownencaps"" , * ( tptr + 2 ) ) , * ( tptr + 3 ) , EXTRACT_16BITS ( tptr + 4 ) ) ) ; break ; case BGP_EXT_COM_SOURCE_AS : ND_PRINT ( ( ndo , "":AS%u"" , EXTRACT_16BITS ( tptr + 2 ) ) ) ; break ; default : ND_TCHECK2 ( * tptr , 8 ) ; print_unknown_data ( ndo , tptr , ""\\n\\t"" , 8 ) ; break ; } tlen -= 8 ; tptr += 8 ; } break ; case BGPTYPE_PMSI_TUNNEL : { uint8_t tunnel_type , flags ; ND_TCHECK2 ( tptr [ 0 ] , 5 ) ; tunnel_type = * ( tptr + 1 ) ; flags = * tptr ; tlen = len ; ND_PRINT ( ( ndo , ""\\n\\tTunnel-type%s(%u),Flags[%s],MPLSLabel%u"" , tok2str ( bgp_pmsi_tunnel_values , ""Unknown"" , tunnel_type ) , tunnel_type , bittok2str ( bgp_pmsi_flag_values , ""none"" , flags ) , EXTRACT_24BITS ( tptr + 2 ) >> 4 ) ) ; tptr += 5 ; tlen -= 5 ; switch ( tunnel_type ) { case BGP_PMSI_TUNNEL_PIM_SM : case BGP_PMSI_TUNNEL_PIM_BIDIR : ND_TCHECK2 ( tptr [ 0 ] , 8 ) ; ND_PRINT ( ( ndo , ""\\n\\tSender%s,P-Group%s"" , ipaddr_string ( ndo , tptr ) , ipaddr_string ( ndo , tptr + 4 ) ) ) ; break ; case BGP_PMSI_TUNNEL_PIM_SSM : ND_TCHECK2 ( tptr [ 0 ] , 8 ) ; ND_PRINT ( ( ndo , ""\\n\\tRoot-Node%s,P-Group%s"" , ipaddr_string ( ndo , tptr ) , ipaddr_string ( ndo , tptr + 4 ) ) ) ; break ; case BGP_PMSI_TUNNEL_INGRESS : ND_TCHECK2 ( tptr [ 0 ] , 4 ) ; ND_PRINT ( ( ndo , ""\\n\\tTunnel-Endpoint%s"" , ipaddr_string ( ndo , tptr ) ) ) ; break ; case BGP_PMSI_TUNNEL_LDP_P2MP : case BGP_PMSI_TUNNEL_LDP_MP2MP : ND_TCHECK2 ( tptr [ 0 ] , 8 ) ; ND_PRINT ( ( ndo , ""\\n\\tRoot-Node%s,LSP-ID0x%08x"" , ipaddr_string ( ndo , tptr ) , EXTRACT_32BITS ( tptr + 4 ) ) ) ; break ; case BGP_PMSI_TUNNEL_RSVP_P2MP : ND_TCHECK2 ( tptr [ 0 ] , 8 ) ; ND_PRINT ( ( ndo , ""\\n\\tExtended-Tunnel-ID%s,P2MP-ID0x%08x"" , ipaddr_string ( ndo , tptr ) , EXTRACT_32BITS ( tptr + 4 ) ) ) ; break ; default : if ( ndo -> ndo_vflag <= 1 ) { print_unknown_data ( ndo , tptr , ""\\n\\t"" , tlen ) ; } } break ; } case BGPTYPE_AIGP : { uint8_t type ; uint16_t length ; tlen = len ; while ( tlen >= 3 ) { ND_TCHECK2 ( tptr [ 0 ] , 3 ) ; type = * tptr ; length = EXTRACT_16BITS ( tptr + 1 ) ; tptr += 3 ; tlen -= 3 ; ND_PRINT ( ( ndo , ""\\n\\t%sTLV(%u),length%u"" , tok2str ( bgp_aigp_values , ""Unknown"" , type ) , type , length ) ) ; if ( length < 3 ) goto trunc ; length -= 3 ; ND_TCHECK2 ( tptr [ 3 ] , length ) ; switch ( type ) { case BGP_AIGP_TLV : if ( length < 8 ) goto trunc ; ND_PRINT ( ( ndo , "",metric%"" PRIu64 , EXTRACT_64BITS ( tptr ) ) ) ; break ; default : if ( ndo -> ndo_vflag <= 1 ) { print_unknown_data ( ndo , tptr , ""\\n\\t"" , length ) ; } } tptr += length ; tlen -= length ; } break ; } case BGPTYPE_ATTR_SET : ND_TCHECK2 ( tptr [ 0 ] , 4 ) ; if ( len < 4 ) goto trunc ; ND_PRINT ( ( ndo , ""\\n\\tOriginAS:%s"" , as_printf ( ndo , astostr , sizeof ( astostr ) , EXTRACT_32BITS ( tptr ) ) ) ) ; tptr += 4 ; len -= 4 ; while ( len ) { u_int aflags , alenlen , alen ; ND_TCHECK2 ( tptr [ 0 ] , 2 ) ; if ( len < 2 ) goto trunc ; aflags = * tptr ; atype = * ( tptr + 1 ) ; tptr += 2 ; len -= 2 ; alenlen = bgp_attr_lenlen ( aflags , tptr ) ; ND_TCHECK2 ( tptr [ 0 ] , alenlen ) ; if ( len < alenlen ) goto trunc ; alen = bgp_attr_len ( aflags , tptr ) ; tptr += alenlen ; len -= alenlen ; ND_PRINT ( ( ndo , ""\\n\\t%s(%u),length:%u"" , tok2str ( bgp_attr_values , ""UnknownAttribute"" , atype ) , atype , alen ) ) ; if ( aflags ) { ND_PRINT ( ( ndo , "",Flags[%s%s%s%s"" , aflags & 0x80 ? ""O"" : """" , aflags & 0x40 ? ""T"" : """" , aflags & 0x20 ? ""P"" : """" , aflags & 0x10 ? ""E"" : """" ) ) ; if ( aflags & 0xf ) ND_PRINT ( ( ndo , ""+%x"" , aflags & 0xf ) ) ; ND_PRINT ( ( ndo , ""]:"" ) ) ; } if ( ! bgp_attr_print ( ndo , atype , tptr , alen ) ) return 0 ; tptr += alen ; len -= alen ; } break ; case BGPTYPE_LARGE_COMMUNITY : if ( len == 0 || len % 12 ) { ND_PRINT ( ( ndo , ""invalidlen"" ) ) ; break ; } ND_PRINT ( ( ndo , ""\\n\\t"" ) ) ; while ( len > 0 ) { ND_TCHECK2 ( * tptr , 12 ) ; ND_PRINT ( ( ndo , ""%u:%u:%u%s"" , EXTRACT_32BITS ( tptr ) , EXTRACT_32BITS ( tptr + 4 ) , EXTRACT_32BITS ( tptr + 8 ) , ( len > 12 ) ? "","" : """" ) ) ; tptr += 12 ; len -= 12 ; } break ; default : ND_TCHECK2 ( * pptr , len ) ; ND_PRINT ( ( ndo , ""\\n\\tnoAttribute%udecoder"" , atype ) ) ; if ( ndo -> ndo_vflag <= 1 ) print_unknown_data ( ndo , pptr , ""\\n\\t"" , len ) ; break ; } if ( ndo -> ndo_vflag > 1 && len ) { ND_TCHECK2 ( * pptr , len ) ; print_unknown_data ( ndo , pptr , ""\\n\\t"" , len ) ; } return 1 ; trunc : return 0 ; } "," , u_int len , const unsigned attr_set_level } if ( attr_set_level == 10 ) ND_PRINT ( ( ndo , ""(toomanynestedlevels,notrecursing)"" ) ) ; else if ( tptr , alen , attr_set_level + 1 ",the-tcpdump-group@tcpdump/af2cf04a9394c1a56227c2289ae8da262828294a,CVE-2018-16300,https://github.com/the-tcpdump-group/tcpdump/commit/af2cf04a9394c1a56227c2289ae8da262828294a,2019-10-03T16:15Z 1472,CWE-352,"CWE-352 static void do_runtime ( HttpRequest req , HttpResponse res ) { int pid = exist_daemon ( ) ; char buf [ STRLEN ] ; do_head ( res , ""_runtime"" , ""Runtime"" , 1000 ) ; StringBuffer_append ( res -> outputbuffer , ""

Monitruntimestatus

"" ) ; StringBuffer_append ( res -> outputbuffer , ""id=\'status-table\'>"" ""width=\'40%%\'>Parameter"" ""width=\'60%%\'>Value"" ) ; StringBuffer_append ( res -> outputbuffer , ""MonitID%s"" , Run . id ) ; StringBuffer_append ( res -> outputbuffer , ""Host%s"" , Run . system -> name ) ; StringBuffer_append ( res -> outputbuffer , ""Processid%d"" , pid ) ; StringBuffer_append ( res -> outputbuffer , ""EffectiveuserrunningMonit"" ""%s"" , Run . Env . user ) ; StringBuffer_append ( res -> outputbuffer , ""Controlfile%s"" , Run . files . control ) ; if ( Run . files . log ) StringBuffer_append ( res -> outputbuffer , ""Logfile%s"" , Run . files . log ) ; StringBuffer_append ( res -> outputbuffer , ""Pidfile%s"" , Run . files . pid ) ; StringBuffer_append ( res -> outputbuffer , ""Statefile%s"" , Run . files . state ) ; StringBuffer_append ( res -> outputbuffer , ""Debug%s"" , Run . debug ? ""True"" : ""False"" ) ; StringBuffer_append ( res -> outputbuffer , ""Log%s"" , ( Run . flags & Run_Log ) ? ""True"" : ""False"" ) ; StringBuffer_append ( res -> outputbuffer , ""Usesyslog%s"" , ( Run . flags & Run_UseSyslog ) ? ""True"" : ""False"" ) ; if ( Run . eventlist_dir ) { if ( Run . eventlist_slots < 0 ) snprintf ( buf , STRLEN , ""unlimited"" ) ; else snprintf ( buf , STRLEN , ""%d"" , Run . eventlist_slots ) ; StringBuffer_append ( res -> outputbuffer , ""Eventqueue"" ""basedirectory%swith%dslots"" , Run . eventlist_dir , Run . eventlist_slots ) ; } # ifdef HAVE_OPENSSL { const char * options = Ssl_printOptions ( & ( Run . ssl ) , ( char [ STRLEN ] ) { } , STRLEN ) ; if ( options && * options ) StringBuffer_append ( res -> outputbuffer , ""SSLoptions%s"" , options ) ; } # endif if ( Run . mmonits ) { StringBuffer_append ( res -> outputbuffer , ""M/Monitserver(s)"" ) ; for ( Mmonit_T c = Run . mmonits ; c ; c = c -> next ) { StringBuffer_append ( res -> outputbuffer , ""%swithtimeout%s"" , c -> url -> url , Str_milliToTime ( c -> timeout , ( char [ 23 ] ) { } ) ) ; # ifdef HAVE_OPENSSL if ( c -> ssl . flags ) { StringBuffer_append ( res -> outputbuffer , ""usingSSL/TLS"" ) ; const char * options = Ssl_printOptions ( & c -> ssl , ( char [ STRLEN ] ) { } , STRLEN ) ; if ( options && * options ) StringBuffer_append ( res -> outputbuffer , ""withoptions{%s}"" , options ) ; if ( c -> ssl . checksum ) StringBuffer_append ( res -> outputbuffer , ""andcertificatechecksum%sequalto\'%s\'"" , checksumnames [ c -> ssl . checksumType ] , c -> ssl . checksum ) ; } # endif if ( c -> url -> user ) StringBuffer_append ( res -> outputbuffer , ""usingcredentials"" ) ; if ( c -> next ) StringBuffer_append ( res -> outputbuffer , "" "" ) ; } StringBuffer_append ( res -> outputbuffer , """" ) ; } if ( Run . mailservers ) { StringBuffer_append ( res -> outputbuffer , ""Mailserver(s)"" ) ; for ( MailServer_T mta = Run . mailservers ; mta ; mta = mta -> next ) { StringBuffer_append ( res -> outputbuffer , ""%s:%d"" , mta -> host , mta -> port ) ; # ifdef HAVE_OPENSSL if ( mta -> ssl . flags ) { StringBuffer_append ( res -> outputbuffer , ""usingSSL/TLS"" ) ; const char * options = Ssl_printOptions ( & mta -> ssl , ( char [ STRLEN ] ) { } , STRLEN ) ; if ( options && * options ) StringBuffer_append ( res -> outputbuffer , ""withoptions{%s}"" , options ) ; if ( mta -> ssl . checksum ) StringBuffer_append ( res -> outputbuffer , ""andcertificatechecksum%sequalto\'%s\'"" , checksumnames [ mta -> ssl . checksumType ] , mta -> ssl . checksum ) ; } # endif if ( mta -> next ) StringBuffer_append ( res -> outputbuffer , "" "" ) ; } StringBuffer_append ( res -> outputbuffer , """" ) ; } if ( Run . MailFormat . from ) { StringBuffer_append ( res -> outputbuffer , ""Defaultmailfrom"" ) ; if ( Run . MailFormat . from -> name ) StringBuffer_append ( res -> outputbuffer , ""%s<%s>"" , Run . MailFormat . from -> name , Run . MailFormat . from -> address ) ; else StringBuffer_append ( res -> outputbuffer , ""%s"" , Run . MailFormat . from -> address ) ; StringBuffer_append ( res -> outputbuffer , """" ) ; } if ( Run . MailFormat . replyto ) { StringBuffer_append ( res -> outputbuffer , ""Defaultmailreplyto"" ) ; if ( Run . MailFormat . replyto -> name ) StringBuffer_append ( res -> outputbuffer , ""%s<%s>"" , Run . MailFormat . replyto -> name , Run . MailFormat . replyto -> address ) ; else StringBuffer_append ( res -> outputbuffer , ""%s"" , Run . MailFormat . replyto -> address ) ; StringBuffer_append ( res -> outputbuffer , """" ) ; } if ( Run . MailFormat . subject ) StringBuffer_append ( res -> outputbuffer , ""Defaultmailsubject%s"" , Run . MailFormat . subject ) ; if ( Run . MailFormat . message ) StringBuffer_append ( res -> outputbuffer , ""Defaultmailmessage%s"" , Run . MailFormat . message ) ; StringBuffer_append ( res -> outputbuffer , ""LimitforSend/Expectbuffer%s"" , Str_bytesToSize ( Run . limits . sendExpectBuffer , buf ) ) ; StringBuffer_append ( res -> outputbuffer , ""Limitforfilecontentbuffer%s"" , Str_bytesToSize ( Run . limits . fileContentBuffer , buf ) ) ; StringBuffer_append ( res -> outputbuffer , ""LimitforHTTPcontentbuffer%s"" , Str_bytesToSize ( Run . limits . httpContentBuffer , buf ) ) ; StringBuffer_append ( res -> outputbuffer , ""Limitforprogramoutput%s"" , Str_bytesToSize ( Run . limits . programOutput , buf ) ) ; StringBuffer_append ( res -> outputbuffer , ""Limitfornetworktimeout%s"" , Str_milliToTime ( Run . limits . networkTimeout , ( char [ 23 ] ) { } ) ) ; StringBuffer_append ( res -> outputbuffer , ""Limitforcheckprogramtimeout%s"" , Str_milliToTime ( Run . limits . programTimeout , ( char [ 23 ] ) { } ) ) ; StringBuffer_append ( res -> outputbuffer , ""Limitforservicestoptimeout%s"" , Str_milliToTime ( Run . limits . stopTimeout , ( char [ 23 ] ) { } ) ) ; StringBuffer_append ( res -> outputbuffer , ""Limitforservicestarttimeout%s"" , Str_milliToTime ( Run . limits . startTimeout , ( char [ 23 ] ) { } ) ) ; StringBuffer_append ( res -> outputbuffer , ""Limitforservicerestarttimeout%s"" , Str_milliToTime ( Run . limits . restartTimeout , ( char [ 23 ] ) { } ) ) ; StringBuffer_append ( res -> outputbuffer , ""Onreboot%s"" , onrebootnames [ Run . onreboot ] ) ; StringBuffer_append ( res -> outputbuffer , ""Polltime%dsecondswithstartdelay%dseconds"" , Run . polltime , Run . startdelay ) ; if ( Run . httpd . flags & Httpd_Net ) { StringBuffer_append ( res -> outputbuffer , ""httpdbindaddress%s"" , Run . httpd . socket . net . address ? Run . httpd . socket . net . address : ""Any/All"" ) ; StringBuffer_append ( res -> outputbuffer , ""httpdportnumber%d"" , Run . httpd . socket . net . port ) ; } else if ( Run . httpd . flags & Httpd_Unix ) { StringBuffer_append ( res -> outputbuffer , ""httpdunixsocket%s"" , Run . httpd . socket . unix . path ) ; } StringBuffer_append ( res -> outputbuffer , ""httpdsignature%s"" , Run . httpd . flags & Httpd_Signature ? ""True"" : ""False"" ) ; StringBuffer_append ( res -> outputbuffer , ""Usesslencryption%s"" , Run . httpd . flags & Httpd_Ssl ? ""True"" : ""False"" ) ; if ( Run . httpd . flags & Httpd_Ssl ) { StringBuffer_append ( res -> outputbuffer , ""PEMkey/certificatefile%s"" , Run . httpd . socket . net . ssl . pem ) ; if ( Run . httpd . socket . net . ssl . clientpem != NULL ) { StringBuffer_append ( res -> outputbuffer , ""ClientPEMkey/certification"" ""%s"" , ""Enabled"" ) ; StringBuffer_append ( res -> outputbuffer , ""ClientPEMkey/certificatefile"" ""%s"" , Run . httpd . socket . net . ssl . clientpem ) ; } else { StringBuffer_append ( res -> outputbuffer , ""ClientPEMkey/certification"" ""%s"" , ""Disabled"" ) ; } StringBuffer_append ( res -> outputbuffer , ""Allowselfcertifiedcertificates"" ""%s"" , Run . httpd . flags & Httpd_AllowSelfSignedCertificates ? ""True"" : ""False"" ) ; } StringBuffer_append ( res -> outputbuffer , ""httpdauth.style%s"" , Run . httpd . credentials && Engine_hasAllow ( ) ? ""BasicAuthenticationandHost/Netallowlist"" : Run . httpd . credentials ? ""BasicAuthentication"" : Engine_hasAllow ( ) ? ""Host/Netallowlist"" : ""Noauthentication"" ) ; print_alerts ( res , Run . maillist ) ; StringBuffer_append ( res -> outputbuffer , """" ) ; if ( ! is_readonly ( req ) ) { StringBuffer_append ( res -> outputbuffer , ""id=\'buttons\'>"" ) ; StringBuffer_append ( res -> outputbuffer , ""style=\'color:red;\'>method=POSTaction=\'_runtime\'>StopMonithttpserver?"" ""type=hiddenname=\'action\'value=\'stop\'>type=submitvalue=\'Go\'>"" ) ; StringBuffer_append ( res -> outputbuffer , ""method=POSTaction=\'_runtime\'>Forcevalidatenow?type=hiddenname=\'action\'value=\'validate\'>"" ""type=submitvalue=\'Go\'>"" ) ; if ( ( Run . flags & Run_Log ) && ! ( Run . flags & Run_UseSyslog ) ) { StringBuffer_append ( res -> outputbuffer , ""method=GETaction=\'_viewlog\'>ViewMonitlogfile?type=submitvalue=\'Go\'>"" ) ; } StringBuffer_append ( res -> outputbuffer , """" ) ; } do_foot ( res ) ; } "," -> outputbuffer , ""style=\'color:red;\'>"" ""method=POSTaction=\'_runtime\'>StopMonithttpserver?"" ""type=hiddenname=\'securitytoken\'value=\'%s\'>"" ""type=hiddenname=\'action\'value=\'stop\'>"" ""type=submitvalue=\'Go\'>"" """" """" , res -> token ) ; StringBuffer_append ( res -> outputbuffer , """" ""method=POSTaction=\'_runtime\'>Forcevalidatenow?"" ""type=hiddenname=\'securitytoken\'value=\'%s\'>"" ""type=hiddenname=\'action\'value=\'validate\'>"" ""type=submitvalue=\'Go\'>"" """" """" , res -> token ) ; if -> outputbuffer , """" ""method=POSTaction=\'_viewlog\'>ViewMonitlogfile?"" ""type=hiddenname=\'securitytoken\'value=\'%s\'>"" ""type=submitvalue=\'Go\'>"" """" """" , res -> token ) ; } ",tildeslash@monit/c6ec3820e627f85417053e6336de2987f2d863e3,CVE-2016-7067,https://bitbucket.org/tildeslash/monit/commit/c6ec3820e627f85417053e6336de2987f2d863e3,2018-09-10T14:29Z 1473,CWE-119,"CWE-119 void vp8_vertical_band_2_1_scale_c ( unsigned char * source , unsigned int src_pitch , unsigned char * dest , unsigned int dest_pitch , unsigned int dest_width ) { ( void ) dest_pitch ; ( void ) src_pitch ; vpx_memcpy ( dest , source , dest_width ) ; } "," ) src_pitch ; memcpy ( dest , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1474,CWE-120,"CWE-120 bool zx_confirmZxLiquidTx ( uint32_t data_total , const EthereumSignTx * msg ) { ( void ) data_total ; const TokenType * token ; char constr1 [ 40 ] , constr2 [ 40 ] , * arStr = """" ; uint8_t * tokenAddress , * deadlineBytes ; bignum256 tokenAmount , tokenMinAmount , ethMinAmount ; uint64_t deadline ; if ( isAddLiquidityEthCall ( msg ) ) { arStr = ""uniswapaddliquidity"" ; } else if ( isRemoveLiquidityEthCall ( msg ) ) { arStr = ""uniswapremoveliquidity"" ; } else { return false ; } tokenAddress = ( uint8_t * ) ( msg -> data_initial_chunk . bytes + 4 + 32 - 20 ) ; token = tokenByChainAddress ( msg -> chain_id , tokenAddress ) ; bn_from_bytes ( msg -> data_initial_chunk . bytes + 4 + 32 , 32 , & tokenAmount ) ; bn_from_bytes ( msg -> data_initial_chunk . bytes + 4 + 2 * 32 , 32 , & tokenMinAmount ) ; bn_from_bytes ( msg -> data_initial_chunk . bytes + 4 + 3 * 32 , 32 , & ethMinAmount ) ; deadlineBytes = ( uint8_t * ) ( msg -> data_initial_chunk . bytes + 4 + 6 * 32 - 8 ) ; deadline = ( ( uint64_t ) deadlineBytes [ 0 ] << 8 * 7 ) | ( ( uint64_t ) deadlineBytes [ 1 ] << 8 * 6 ) | ( ( uint64_t ) deadlineBytes [ 2 ] << 8 * 5 ) | ( ( uint64_t ) deadlineBytes [ 3 ] << 8 * 4 ) | ( ( uint64_t ) deadlineBytes [ 4 ] << 8 * 3 ) | ( ( uint64_t ) deadlineBytes [ 5 ] << 8 * 2 ) | ( ( uint64_t ) deadlineBytes [ 6 ] << 8 * 1 ) | ( ( uint64_t ) deadlineBytes [ 7 ] ) ; char tokbuf [ 32 ] ; ethereumFormatAmount ( & tokenAmount , token , msg -> chain_id , tokbuf , sizeof ( tokbuf ) ) ; snprintf ( constr1 , 32 , ""%s"" , tokbuf ) ; ethereumFormatAmount ( & tokenMinAmount , token , msg -> chain_id , tokbuf , sizeof ( tokbuf ) ) ; snprintf ( constr2 , 32 , ""%s"" , tokbuf ) ; confirm ( ButtonRequestType_ButtonRequest_ConfirmOutput , arStr , ""%s\\nMinimum%s"" , constr1 , constr2 ) ; if ( ! confirmFromAccountMatch ( msg , arStr ) ) { return false ; } ethereumFormatAmount ( & ethMinAmount , NULL , msg -> chain_id , tokbuf , sizeof ( tokbuf ) ) ; snprintf ( constr1 , 32 , ""%s"" , tokbuf ) ; confirm ( ButtonRequestType_ButtonRequest_ConfirmOutput , arStr , ""Minimum%s"" , constr1 ) ; snprintf ( constr1 , 32 , ""%lld"" , deadline ) ; confirm ( ButtonRequestType_ButtonRequest_ConfirmOutput , arStr , ""Deadline%s"" , ctime ( ( const time_t * ) & deadline ) ) ; return true ; } "," constr1 ) ; confirm ( ButtonRequestType_ButtonRequest_ConfirmOutput ",keepkey@keepkey-firmware/e49d45594002d4d3fbc1f03488e6dfc0a0a65836,CVE-2021-31616,https://github.com/keepkey/keepkey-firmware/commit/e49d45594002d4d3fbc1f03488e6dfc0a0a65836,2021-05-06T13:15Z 1475,CWE-000,"CWE-000 long jpc_bitstream_getbits ( jpc_bitstream_t * bitstream , int n ) { long v ; int u ; assert ( n >= 0 && n < 32 ) ; v = 0 ; while ( -- n >= 0 ) { if ( ( u = jpc_bitstream_getbit ( bitstream ) ) < 0 ) { return - 1 ; } v = ( v << 1 ) | u ; } return v ; } "," int u ; if ( n < 0 || n >= 32 ) { return - 1 ; } v = 0 ",mdadams@jasper/1e84674d95353c64e5c4c0e7232ae86fd6ea813b,CVE-2016-9391,https://github.com/mdadams/jasper/commit/1e84674d95353c64e5c4c0e7232ae86fd6ea813b,2017-03-23T18:59Z 1476,CWE-000,"CWE-000 static ssize_t aio_run_iocb ( struct kiocb * req , unsigned opcode , char __user * buf , size_t len , bool compat ) { struct file * file = req -> ki_filp ; ssize_t ret ; unsigned long nr_segs ; int rw ; fmode_t mode ; aio_rw_op * rw_op ; rw_iter_op * iter_op ; struct iovec inline_vecs [ UIO_FASTIOV ] , * iovec = inline_vecs ; struct iov_iter iter ; switch ( opcode ) { case IOCB_CMD_PREAD : case IOCB_CMD_PREADV : mode = FMODE_READ ; rw = READ ; rw_op = file -> f_op -> aio_read ; iter_op = file -> f_op -> read_iter ; goto rw_common ; case IOCB_CMD_PWRITE : case IOCB_CMD_PWRITEV : mode = FMODE_WRITE ; rw = WRITE ; rw_op = file -> f_op -> aio_write ; iter_op = file -> f_op -> write_iter ; goto rw_common ; rw_common : if ( unlikely ( ! ( file -> f_mode & mode ) ) ) return - EBADF ; if ( ! rw_op && ! iter_op ) return - EINVAL ; if ( opcode == IOCB_CMD_PREADV || opcode == IOCB_CMD_PWRITEV ) ret = aio_setup_vectored_rw ( req , rw , buf , & nr_segs , & len , & iovec , compat ) ; else ret = aio_setup_single_vector ( req , rw , buf , & nr_segs , len , iovec ) ; if ( ! ret ) ret = rw_verify_area ( rw , file , & req -> ki_pos , len ) ; if ( ret < 0 ) { if ( iovec != inline_vecs ) kfree ( iovec ) ; return ret ; } len = ret ; if ( req -> ki_pos < 0 ) { ret = - EINVAL ; break ; } if ( rw == WRITE ) file_start_write ( file ) ; if ( iter_op ) { iov_iter_init ( & iter , rw , iovec , nr_segs , len ) ; ret = iter_op ( req , & iter ) ; } else { ret = rw_op ( req , iovec , nr_segs , req -> ki_pos ) ; } if ( rw == WRITE ) file_end_write ( file ) ; break ; case IOCB_CMD_FDSYNC : if ( ! file -> f_op -> aio_fsync ) return - EINVAL ; ret = file -> f_op -> aio_fsync ( req , 1 ) ; break ; case IOCB_CMD_FSYNC : if ( ! file -> f_op -> aio_fsync ) return - EINVAL ; ret = file -> f_op -> aio_fsync ( req , 0 ) ; break ; default : pr_debug ( ""EINVAL:nooperationprovided\\n"" ) ; return - EINVAL ; } if ( iovec != inline_vecs ) kfree ( iovec ) ; if ( ret != - EIOCBQUEUED ) { if ( unlikely ( ret == - ERESTARTSYS || ret == - ERESTARTNOINTR || ret == - ERESTARTNOHAND || ret == - ERESTART_RESTARTBLOCK ) ) ret = - EINTR ; aio_complete ( req , ret , 0 ) ; } return 0 ; } "," iovec , compat , & iter len , iovec , & iter iter_op ) { ret = iter_op ( req , & iter ) ; } else { ret = rw_op ( req , iter . iov , iter . nr_segs , req ",torvalds@linux/4c185ce06dca14f5cea192f5a2c981ef50663f2b,CVE-2015-8830,https://github.com/torvalds/linux/commit/4c185ce06dca14f5cea192f5a2c981ef50663f2b,2016-05-02T10:59Z 1477,CWE-20,"CWE-20 static int try_read_command ( conn * c ) { assert ( c != NULL ) ; assert ( c -> rcurr <= ( c -> rbuf + c -> rsize ) ) ; assert ( c -> rbytes > 0 ) ; if ( c -> protocol == negotiating_prot || c -> transport == udp_transport ) { if ( ( unsigned char ) c -> rbuf [ 0 ] == ( unsigned char ) PROTOCOL_BINARY_REQ ) { c -> protocol = binary_prot ; } else { c -> protocol = ascii_prot ; } if ( settings . verbose > 1 ) { fprintf ( stderr , ""%d:Clientusingthe%sprotocol\\n"" , c -> sfd , prot_text ( c -> protocol ) ) ; } } if ( c -> protocol == binary_prot ) { if ( c -> rbytes < sizeof ( c -> binary_header ) ) { return 0 ; } else { # ifdef NEED_ALIGN if ( ( ( long ) ( c -> rcurr ) ) % 8 != 0 ) { memmove ( c -> rbuf , c -> rcurr , c -> rbytes ) ; c -> rcurr = c -> rbuf ; if ( settings . verbose > 1 ) { fprintf ( stderr , ""%d:Realigninputbuffer\\n"" , c -> sfd ) ; } } # endif protocol_binary_request_header * req ; req = ( protocol_binary_request_header * ) c -> rcurr ; if ( settings . verbose > 1 ) { int ii ; fprintf ( stderr , ""<%dReadbinaryprotocoldata:"" , c -> sfd ) ; for ( ii = 0 ; ii < sizeof ( req -> bytes ) ; ++ ii ) { if ( ii % 4 == 0 ) { fprintf ( stderr , ""\\n<%d"" , c -> sfd ) ; } fprintf ( stderr , ""0x%02x"" , req -> bytes [ ii ] ) ; } fprintf ( stderr , ""\\n"" ) ; } c -> binary_header = * req ; c -> binary_header . request . keylen = ntohs ( req -> request . keylen ) ; c -> binary_header . request . bodylen = ntohl ( req -> request . bodylen ) ; c -> binary_header . request . cas = ntohll ( req -> request . cas ) ; if ( c -> binary_header . request . magic != PROTOCOL_BINARY_REQ ) { if ( settings . verbose ) { fprintf ( stderr , ""Invalidmagic:%x\\n"" , c -> binary_header . request . magic ) ; } conn_set_state ( c , conn_closing ) ; return - 1 ; } c -> msgcurr = 0 ; c -> msgused = 0 ; c -> iovused = 0 ; if ( add_msghdr ( c ) != 0 ) { out_string ( c , ""SERVER_ERRORoutofmemory"" ) ; return 0 ; } c -> cmd = c -> binary_header . request . opcode ; c -> keylen = c -> binary_header . request . keylen ; c -> opaque = c -> binary_header . request . opaque ; c -> cas = 0 ; dispatch_bin_command ( c ) ; c -> rbytes -= sizeof ( c -> binary_header ) ; c -> rcurr += sizeof ( c -> binary_header ) ; } } else { char * el , * cont ; if ( c -> rbytes == 0 ) return 0 ; el = memchr ( c -> rcurr , '\\n' , c -> rbytes ) ; if ( ! el ) return 0 ; cont = el + 1 ; if ( ( el - c -> rcurr ) > 1 && * ( el - 1 ) == '\\r' ) { el -- ; } * el = '\\0' ; assert ( cont <= ( c -> rcurr + c -> rbytes ) ) ; process_command ( c , c -> rcurr ) ; c -> rbytes -= ( cont - c -> rcurr ) ; c -> rcurr = cont ; assert ( c -> rcurr <= ( c -> rbuf + c -> rsize ) ) ; } return 1 ; } "," ! el ) { if ( c -> rbytes > 1024 ) { char * ptr = c -> rcurr ; while ( * ptr == '' ) { ++ ptr ; } if ( strcmp ( ptr , ""get"" ) && strcmp ( ptr , ""gets"" ) ) { conn_set_state ( c , conn_closing ) ; return 1 ; } } return 0 ; } cont = el ",memcached@memcached/75cc83685e103bc8ba380a57468c8f04413033f9,CVE-2010-1152,https://github.com/memcached/memcached/commit/75cc83685e103bc8ba380a57468c8f04413033f9,2010-04-12T18:30Z 1478,CWE-400,"CWE-400 static int usb_enumerate_device_otg ( struct usb_device * udev ) { int err = 0 ; # ifdef CONFIG_USB_OTG if ( ! udev -> bus -> is_b_host && udev -> config && udev -> parent == udev -> bus -> root_hub ) { struct usb_otg_descriptor * desc = NULL ; struct usb_bus * bus = udev -> bus ; unsigned port1 = udev -> portnum ; err = __usb_get_extra_descriptor ( udev -> rawdescriptors [ 0 ] , le16_to_cpu ( udev -> config [ 0 ] . desc . wTotalLength ) , USB_DT_OTG , ( void * * ) & desc ) ; if ( err || ! ( desc -> bmAttributes & USB_OTG_HNP ) ) return 0 ; dev_info ( & udev -> dev , ""Dual-RoleOTGdeviceon%sHNPport\\n"" , ( port1 == bus -> otg_port ) ? """" : ""non-"" ) ; if ( port1 == bus -> otg_port ) { bus -> b_hnp_enable = 1 ; err = usb_control_msg ( udev , usb_sndctrlpipe ( udev , 0 ) , USB_REQ_SET_FEATURE , 0 , USB_DEVICE_B_HNP_ENABLE , 0 , NULL , 0 , USB_CTRL_SET_TIMEOUT ) ; if ( err < 0 ) { dev_err ( & udev -> dev , ""can\'tsetHNPmode:%d\\n"" , err ) ; bus -> b_hnp_enable = 0 ; } } else if ( desc -> bLength == sizeof ( struct usb_otg_descriptor ) ) { err = usb_control_msg ( udev , usb_sndctrlpipe ( udev , 0 ) , USB_REQ_SET_FEATURE , 0 , USB_DEVICE_A_ALT_HNP_SUPPORT , 0 , NULL , 0 , USB_CTRL_SET_TIMEOUT ) ; if ( err < 0 ) dev_err ( & udev -> dev , ""seta_alt_hnp_supportfailed:%d\\n"" , err ) ; } } # endif return err ; } "," ) & desc , sizeof ( * desc ) ",torvalds@linux/704620afc70cf47abb9d6a1a57f3825d2bca49cf,CVE-2018-20169,https://github.com/torvalds/linux/commit/704620afc70cf47abb9d6a1a57f3825d2bca49cf,2018-12-17T07:29Z 1479,CWE-119,"CWE-119 static int usb_parse_configuration ( struct usb_device * dev , int cfgidx , struct usb_host_config * config , unsigned char * buffer , int size ) { struct device * ddev = & dev -> dev ; unsigned char * buffer0 = buffer ; int cfgno ; int nintf , nintf_orig ; int i , j , n ; struct usb_interface_cache * intfc ; unsigned char * buffer2 ; int size2 ; struct usb_descriptor_header * header ; int len , retval ; u8 inums [ USB_MAXINTERFACES ] , nalts [ USB_MAXINTERFACES ] ; unsigned iad_num = 0 ; memcpy ( & config -> desc , buffer , USB_DT_CONFIG_SIZE ) ; if ( config -> desc . bDescriptorType != USB_DT_CONFIG || config -> desc . bLength < USB_DT_CONFIG_SIZE || config -> desc . bLength > size ) { dev_err ( ddev , ""invaliddescriptorforconfigindex%d:"" ""type=0x%X,length=%d\\n"" , cfgidx , config -> desc . bDescriptorType , config -> desc . bLength ) ; return - EINVAL ; } cfgno = config -> desc . bConfigurationValue ; buffer += config -> desc . bLength ; size -= config -> desc . bLength ; nintf = nintf_orig = config -> desc . bNumInterfaces ; if ( nintf > USB_MAXINTERFACES ) { dev_warn ( ddev , ""config%dhastoomanyinterfaces:%d,"" ""usingmaximumallowed:%d\\n"" , cfgno , nintf , USB_MAXINTERFACES ) ; nintf = USB_MAXINTERFACES ; } n = 0 ; for ( ( buffer2 = buffer , size2 = size ) ; size2 > 0 ; ( buffer2 += header -> bLength , size2 -= header -> bLength ) ) { if ( size2 < sizeof ( struct usb_descriptor_header ) ) { dev_warn ( ddev , ""config%ddescriptorhas%dexcess"" ""byte%s,ignoring\\n"" , cfgno , size2 , plural ( size2 ) ) ; break ; } header = ( struct usb_descriptor_header * ) buffer2 ; if ( ( header -> bLength > size2 ) || ( header -> bLength < 2 ) ) { dev_warn ( ddev , ""config%dhasaninvaliddescriptor"" ""oflength%d,skippingremainderoftheconfig\\n"" , cfgno , header -> bLength ) ; break ; } if ( header -> bDescriptorType == USB_DT_INTERFACE ) { struct usb_interface_descriptor * d ; int inum ; d = ( struct usb_interface_descriptor * ) header ; if ( d -> bLength < USB_DT_INTERFACE_SIZE ) { dev_warn ( ddev , ""config%dhasaninvalid"" ""interfacedescriptoroflength%d,"" ""skipping\\n"" , cfgno , d -> bLength ) ; continue ; } inum = d -> bInterfaceNumber ; if ( ( dev -> quirks & USB_QUIRK_HONOR_BNUMINTERFACES ) && n >= nintf_orig ) { dev_warn ( ddev , ""config%dhasmoreinterface"" ""descriptors,thanitdeclaresin"" ""bNumInterfaces,ignoringinterface"" ""number:%d\\n"" , cfgno , inum ) ; continue ; } if ( inum >= nintf_orig ) dev_warn ( ddev , ""config%dhasaninvalid"" ""interfacenumber:%dbutmaxis%d\\n"" , cfgno , inum , nintf_orig - 1 ) ; for ( i = 0 ; i < n ; ++ i ) { if ( inums [ i ] == inum ) break ; } if ( i < n ) { if ( nalts [ i ] < 255 ) ++ nalts [ i ] ; } else if ( n < USB_MAXINTERFACES ) { inums [ n ] = inum ; nalts [ n ] = 1 ; ++ n ; } } else if ( header -> bDescriptorType == USB_DT_INTERFACE_ASSOCIATION ) { if ( iad_num == USB_MAXIADS ) { dev_warn ( ddev , ""foundmoreInterface"" ""AssociationDescriptors"" ""thanallocatedforin"" ""configuration%d\\n"" , cfgno ) ; } else { config -> intf_assoc [ iad_num ] = ( struct usb_interface_assoc_descriptor * ) header ; iad_num ++ ; } } else if ( header -> bDescriptorType == USB_DT_DEVICE || header -> bDescriptorType == USB_DT_CONFIG ) dev_warn ( ddev , ""config%dcontainsanunexpected"" ""descriptoroftype0x%X,skipping\\n"" , cfgno , header -> bDescriptorType ) ; } size = buffer2 - buffer ; config -> desc . wTotalLength = cpu_to_le16 ( buffer2 - buffer0 ) ; if ( n != nintf ) dev_warn ( ddev , ""config%dhas%dinterface%s,differentfrom"" ""thedescriptor\'svalue:%d\\n"" , cfgno , n , plural ( n ) , nintf_orig ) ; else if ( n == 0 ) dev_warn ( ddev , ""config%dhasnointerfaces?\\n"" , cfgno ) ; config -> desc . bNumInterfaces = nintf = n ; for ( i = 0 ; i < nintf ; ++ i ) { for ( j = 0 ; j < nintf ; ++ j ) { if ( inums [ j ] == i ) break ; } if ( j >= nintf ) dev_warn ( ddev , ""config%dhasnointerfacenumber"" ""%d\\n"" , cfgno , i ) ; } for ( i = 0 ; i < nintf ; ++ i ) { j = nalts [ i ] ; if ( j > USB_MAXALTSETTING ) { dev_warn ( ddev , ""toomanyalternatesettingsfor"" ""config%dinterface%d:%d,"" ""usingmaximumallowed:%d\\n"" , cfgno , inums [ i ] , j , USB_MAXALTSETTING ) ; nalts [ i ] = j = USB_MAXALTSETTING ; } len = sizeof ( * intfc ) + sizeof ( struct usb_host_interface ) * j ; config -> intf_cache [ i ] = intfc = kzalloc ( len , GFP_KERNEL ) ; if ( ! intfc ) return - ENOMEM ; kref_init ( & intfc -> ref ) ; } config -> extra = buffer ; i = find_next_descriptor ( buffer , size , USB_DT_INTERFACE , USB_DT_INTERFACE , & n ) ; config -> extralen = i ; if ( n > 0 ) dev_dbg ( ddev , ""skipped%ddescriptor%safter%s\\n"" , n , plural ( n ) , ""configuration"" ) ; buffer += i ; size -= i ; while ( size > 0 ) { retval = usb_parse_interface ( ddev , cfgno , config , buffer , size , inums , nalts ) ; if ( retval < 0 ) return retval ; buffer += retval ; size -= retval ; } for ( i = 0 ; i < nintf ; ++ i ) { intfc = config -> intf_cache [ i ] ; for ( j = 0 ; j < intfc -> num_altsetting ; ++ j ) { for ( n = 0 ; n < intfc -> num_altsetting ; ++ n ) { if ( intfc -> altsetting [ n ] . desc . bAlternateSetting == j ) break ; } if ( n >= intfc -> num_altsetting ) dev_warn ( ddev , ""config%dinterface%dhasno"" ""altsetting%d\\n"" , cfgno , inums [ i ] , j ) ; } } return 0 ; } "," USB_DT_INTERFACE_ASSOCIATION ) { struct usb_interface_assoc_descriptor * d ; d = ( struct usb_interface_assoc_descriptor * ) header ; if ( d -> bLength < USB_DT_INTERFACE_ASSOCIATION_SIZE ) { dev_warn ( ddev , ""config%dhasaninvalidinterfaceassociationdescriptoroflength%d,skipping\\n"" , cfgno , d -> bLength ) ; continue ; } iad_num ] = d ; iad_num ++ ",torvalds@linux/bd7a3fe770ebd8391d1c7d072ff88e9e76d063eb,CVE-2017-16531,https://github.com/torvalds/linux/commit/bd7a3fe770ebd8391d1c7d072ff88e9e76d063eb,2017-11-04T01:29Z 1480,CWE-190,"CWE-190 static int snd_ctl_elem_add ( struct snd_ctl_file * file , struct snd_ctl_elem_info * info , int replace ) { struct snd_card * card = file -> card ; struct snd_kcontrol kctl , * _kctl ; unsigned int access ; long private_size ; struct user_element * ue ; int idx , err ; if ( ! replace && card -> user_ctl_count >= MAX_USER_CONTROLS ) return - ENOMEM ; if ( info -> count < 1 ) return - EINVAL ; access = info -> access == 0 ? SNDRV_CTL_ELEM_ACCESS_READWRITE : ( info -> access & ( SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE | SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE ) ) ; info -> id . numid = 0 ; memset ( & kctl , 0 , sizeof ( kctl ) ) ; down_write ( & card -> controls_rwsem ) ; _kctl = snd_ctl_find_id ( card , & info -> id ) ; err = 0 ; if ( _kctl ) { if ( replace ) err = snd_ctl_remove ( card , _kctl ) ; else err = - EBUSY ; } else { if ( replace ) err = - ENOENT ; } up_write ( & card -> controls_rwsem ) ; if ( err < 0 ) return err ; memcpy ( & kctl . id , & info -> id , sizeof ( info -> id ) ) ; kctl . count = info -> owner ? info -> owner : 1 ; access |= SNDRV_CTL_ELEM_ACCESS_USER ; if ( info -> type == SNDRV_CTL_ELEM_TYPE_ENUMERATED ) kctl . info = snd_ctl_elem_user_enum_info ; else kctl . info = snd_ctl_elem_user_info ; if ( access & SNDRV_CTL_ELEM_ACCESS_READ ) kctl . get = snd_ctl_elem_user_get ; if ( access & SNDRV_CTL_ELEM_ACCESS_WRITE ) kctl . put = snd_ctl_elem_user_put ; if ( access & SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE ) { kctl . tlv . c = snd_ctl_elem_user_tlv ; access |= SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK ; } switch ( info -> type ) { case SNDRV_CTL_ELEM_TYPE_BOOLEAN : case SNDRV_CTL_ELEM_TYPE_INTEGER : private_size = sizeof ( long ) ; if ( info -> count > 128 ) return - EINVAL ; break ; case SNDRV_CTL_ELEM_TYPE_INTEGER64 : private_size = sizeof ( long long ) ; if ( info -> count > 64 ) return - EINVAL ; break ; case SNDRV_CTL_ELEM_TYPE_ENUMERATED : private_size = sizeof ( unsigned int ) ; if ( info -> count > 128 || info -> value . enumerated . items == 0 ) return - EINVAL ; break ; case SNDRV_CTL_ELEM_TYPE_BYTES : private_size = sizeof ( unsigned char ) ; if ( info -> count > 512 ) return - EINVAL ; break ; case SNDRV_CTL_ELEM_TYPE_IEC958 : private_size = sizeof ( struct snd_aes_iec958 ) ; if ( info -> count != 1 ) return - EINVAL ; break ; default : return - EINVAL ; } private_size *= info -> count ; ue = kzalloc ( sizeof ( struct user_element ) + private_size , GFP_KERNEL ) ; if ( ue == NULL ) return - ENOMEM ; ue -> card = card ; ue -> info = * info ; ue -> info . access = 0 ; ue -> elem_data = ( char * ) ue + sizeof ( * ue ) ; ue -> elem_data_size = private_size ; if ( ue -> info . type == SNDRV_CTL_ELEM_TYPE_ENUMERATED ) { err = snd_ctl_elem_init_enum_names ( ue ) ; if ( err < 0 ) { kfree ( ue ) ; return err ; } } kctl . private_free = snd_ctl_elem_user_free ; _kctl = snd_ctl_new ( & kctl , access ) ; if ( _kctl == NULL ) { kfree ( ue -> priv_data ) ; kfree ( ue ) ; return - ENOMEM ; } _kctl -> private_data = ue ; for ( idx = 0 ; idx < _kctl -> count ; idx ++ ) _kctl -> vd [ idx ] . owner = file ; err = snd_ctl_add ( card , _kctl ) ; if ( err < 0 ) return err ; down_write ( & card -> controls_rwsem ) ; card -> user_ctl_count ++ ; up_write ( & card -> controls_rwsem ) ; return 0 ; } "," ; if ( info -> count < 1 ) return - EINVAL ; access = info -> access == 0 ? SNDRV_CTL_ELEM_ACCESS_READWRITE : ( info -> access & ( SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_INACTIVE | SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE ) ) ; info -> id . numid = 0 ; memset ( & kctl , 0 , sizeof ( kctl ) ) ; if ( replace ) { err = snd_ctl_remove_user_ctl ( file , & info -> id ) ; if ( err ) return err ; } if ( card -> user_ctl_count return - ENOMEM ; memcpy ( ",torvalds@linux/82262a46627bebb0febcc26664746c25cef08563,CVE-2014-4655,https://github.com/torvalds/linux/commit/82262a46627bebb0febcc26664746c25cef08563,2014-07-03T04:22Z 1481,CWE-285,"CWE-285 static int m_authenticate ( struct Client * client_p , struct Client * source_p , int parc , const char * parv [ ] ) { struct Client * agent_p = NULL ; struct Client * saslserv_p = NULL ; if ( ! IsCapable ( source_p , CLICAP_SASL ) ) return 0 ; if ( strlen ( client_p -> id ) == 3 ) { exit_client ( client_p , client_p , client_p , ""Mixingclientandserverprotocol"" ) ; return 0 ; } saslserv_p = find_named_client ( ConfigFileEntry . sasl_service ) ; if ( saslserv_p == NULL || ! IsService ( saslserv_p ) ) { sendto_one ( source_p , form_str ( ERR_SASLABORTED ) , me . name , EmptyString ( source_p -> name ) ? ""*"" : source_p -> name ) ; return 0 ; } if ( source_p -> localClient -> sasl_complete ) { * source_p -> localClient -> sasl_agent = '\\0' ; source_p -> localClient -> sasl_complete = 0 ; } if ( strlen ( parv [ 1 ] ) > 400 ) { sendto_one ( source_p , form_str ( ERR_SASLTOOLONG ) , me . name , EmptyString ( source_p -> name ) ? ""*"" : source_p -> name ) ; return 0 ; } if ( ! * source_p -> id ) { strcpy ( source_p -> id , generate_uid ( ) ) ; add_to_id_hash ( source_p -> id , source_p ) ; } if ( * source_p -> localClient -> sasl_agent ) agent_p = find_id ( source_p -> localClient -> sasl_agent ) ; if ( agent_p == NULL ) { sendto_one ( saslserv_p , "":%sENCAP%sSASL%s%sH%s%s"" , me . id , saslserv_p -> servptr -> name , source_p -> id , saslserv_p -> id , source_p -> host , source_p -> sockhost ) ; if ( ! strcmp ( parv [ 1 ] , ""EXTERNAL"" ) && source_p -> certfp != NULL ) sendto_one ( saslserv_p , "":%sENCAP%sSASL%s%sS%s%s"" , me . id , saslserv_p -> servptr -> name , source_p -> id , saslserv_p -> id , parv [ 1 ] , source_p -> certfp ) ; else sendto_one ( saslserv_p , "":%sENCAP%sSASL%s%sS%s"" , me . id , saslserv_p -> servptr -> name , source_p -> id , saslserv_p -> id , parv [ 1 ] ) ; rb_strlcpy ( source_p -> localClient -> sasl_agent , saslserv_p -> id , IDLEN ) ; } else sendto_one ( agent_p , "":%sENCAP%sSASL%s%sC%s"" , me . id , agent_p -> servptr -> name , source_p -> id , agent_p -> id , parv [ 1 ] ) ; source_p -> localClient -> sasl_out ++ ; return 0 ; } "," client_p , ""Mixingclientandserverprotocol"" ) ; return 0 ; } if ( * parv [ 1 ] == ':' || strchr ( parv [ 1 ] , '' ) ) { exit_client ( client_p , client_p , client_p , ""MalformedAUTHENTICATE"" ",charybdis-ircd@charybdis/818a3fda944b26d4814132cee14cfda4ea4aa824,CVE-2016-7143,https://github.com/charybdis-ircd/charybdis/commit/818a3fda944b26d4814132cee14cfda4ea4aa824,2016-09-21T14:25Z 1482,CWE-284,"CWE-284 int x86_decode_insn ( struct x86_emulate_ctxt * ctxt , void * insn , int insn_len ) { int rc = X86EMUL_CONTINUE ; int mode = ctxt -> mode ; int def_op_bytes , def_ad_bytes , goffset , simd_prefix ; bool op_prefix = false ; bool has_seg_override = false ; struct opcode opcode ; ctxt -> memop . type = OP_NONE ; ctxt -> memopp = NULL ; ctxt -> _eip = ctxt -> eip ; ctxt -> fetch . ptr = ctxt -> fetch . data ; ctxt -> fetch . end = ctxt -> fetch . data + insn_len ; ctxt -> opcode_len = 1 ; if ( insn_len > 0 ) memcpy ( ctxt -> fetch . data , insn , insn_len ) ; else { rc = __do_insn_fetch_bytes ( ctxt , 1 ) ; if ( rc != X86EMUL_CONTINUE ) return rc ; } switch ( mode ) { case X86EMUL_MODE_REAL : case X86EMUL_MODE_VM86 : case X86EMUL_MODE_PROT16 : def_op_bytes = def_ad_bytes = 2 ; break ; case X86EMUL_MODE_PROT32 : def_op_bytes = def_ad_bytes = 4 ; break ; # ifdef CONFIG_X86_64 case X86EMUL_MODE_PROT64 : def_op_bytes = 4 ; def_ad_bytes = 8 ; break ; # endif default : return EMULATION_FAILED ; } ctxt -> op_bytes = def_op_bytes ; ctxt -> ad_bytes = def_ad_bytes ; for ( ; ; ) { switch ( ctxt -> b = insn_fetch ( u8 , ctxt ) ) { case 0x66 : op_prefix = true ; ctxt -> op_bytes = def_op_bytes ^ 6 ; break ; case 0x67 : if ( mode == X86EMUL_MODE_PROT64 ) ctxt -> ad_bytes = def_ad_bytes ^ 12 ; else ctxt -> ad_bytes = def_ad_bytes ^ 6 ; break ; case 0x26 : case 0x2e : case 0x36 : case 0x3e : has_seg_override = true ; ctxt -> seg_override = ( ctxt -> b >> 3 ) & 3 ; break ; case 0x64 : case 0x65 : has_seg_override = true ; ctxt -> seg_override = ctxt -> b & 7 ; break ; case 0x40 ... 0x4f : if ( mode != X86EMUL_MODE_PROT64 ) goto done_prefixes ; ctxt -> rex_prefix = ctxt -> b ; continue ; case 0xf0 : ctxt -> lock_prefix = 1 ; break ; case 0xf2 : case 0xf3 : ctxt -> rep_prefix = ctxt -> b ; break ; default : goto done_prefixes ; } ctxt -> rex_prefix = 0 ; } done_prefixes : if ( ctxt -> rex_prefix & 8 ) ctxt -> op_bytes = 8 ; opcode = opcode_table [ ctxt -> b ] ; if ( ctxt -> b == 0x0f ) { ctxt -> opcode_len = 2 ; ctxt -> b = insn_fetch ( u8 , ctxt ) ; opcode = twobyte_table [ ctxt -> b ] ; if ( ctxt -> b == 0x38 ) { ctxt -> opcode_len = 3 ; ctxt -> b = insn_fetch ( u8 , ctxt ) ; opcode = opcode_map_0f_38 [ ctxt -> b ] ; } } ctxt -> d = opcode . flags ; if ( ctxt -> d & ModRM ) ctxt -> modrm = insn_fetch ( u8 , ctxt ) ; if ( ctxt -> opcode_len == 1 && ( ctxt -> b == 0xc5 || ctxt -> b == 0xc4 ) && ( mode == X86EMUL_MODE_PROT64 || ( ctxt -> modrm & 0xc0 ) == 0xc0 ) ) { ctxt -> d = NotImpl ; } while ( ctxt -> d & GroupMask ) { switch ( ctxt -> d & GroupMask ) { case Group : goffset = ( ctxt -> modrm >> 3 ) & 7 ; opcode = opcode . u . group [ goffset ] ; break ; case GroupDual : goffset = ( ctxt -> modrm >> 3 ) & 7 ; if ( ( ctxt -> modrm >> 6 ) == 3 ) opcode = opcode . u . gdual -> mod3 [ goffset ] ; else opcode = opcode . u . gdual -> mod012 [ goffset ] ; break ; case RMExt : goffset = ctxt -> modrm & 7 ; opcode = opcode . u . group [ goffset ] ; break ; case Prefix : if ( ctxt -> rep_prefix && op_prefix ) return EMULATION_FAILED ; simd_prefix = op_prefix ? 0x66 : ctxt -> rep_prefix ; switch ( simd_prefix ) { case 0x00 : opcode = opcode . u . gprefix -> pfx_no ; break ; case 0x66 : opcode = opcode . u . gprefix -> pfx_66 ; break ; case 0xf2 : opcode = opcode . u . gprefix -> pfx_f2 ; break ; case 0xf3 : opcode = opcode . u . gprefix -> pfx_f3 ; break ; } break ; case Escape : if ( ctxt -> modrm > 0xbf ) opcode = opcode . u . esc -> high [ ctxt -> modrm - 0xc0 ] ; else opcode = opcode . u . esc -> op [ ( ctxt -> modrm >> 3 ) & 7 ] ; break ; case InstrDual : if ( ( ctxt -> modrm >> 6 ) == 3 ) opcode = opcode . u . idual -> mod3 ; else opcode = opcode . u . idual -> mod012 ; break ; case ModeDual : if ( ctxt -> mode == X86EMUL_MODE_PROT64 ) opcode = opcode . u . mdual -> mode64 ; else opcode = opcode . u . mdual -> mode32 ; break ; default : return EMULATION_FAILED ; } ctxt -> d &= ~ ( u64 ) GroupMask ; ctxt -> d |= opcode . flags ; } if ( ctxt -> d == 0 ) return EMULATION_FAILED ; ctxt -> execute = opcode . u . execute ; if ( unlikely ( ctxt -> ud ) && likely ( ! ( ctxt -> d & EmulateOnUD ) ) ) return EMULATION_FAILED ; if ( unlikely ( ctxt -> d & ( NotImpl | Stack | Op3264 | Sse | Mmx | Intercept | CheckPerm | NearBranch | No16 ) ) ) { ctxt -> check_perm = opcode . check_perm ; ctxt -> intercept = opcode . intercept ; if ( ctxt -> d & NotImpl ) return EMULATION_FAILED ; if ( mode == X86EMUL_MODE_PROT64 ) { if ( ctxt -> op_bytes == 4 && ( ctxt -> d & Stack ) ) ctxt -> op_bytes = 8 ; else if ( ctxt -> d & NearBranch ) ctxt -> op_bytes = 8 ; } if ( ctxt -> d & Op3264 ) { if ( mode == X86EMUL_MODE_PROT64 ) ctxt -> op_bytes = 8 ; else ctxt -> op_bytes = 4 ; } if ( ( ctxt -> d & No16 ) && ctxt -> op_bytes == 2 ) ctxt -> op_bytes = 4 ; if ( ctxt -> d & Sse ) ctxt -> op_bytes = 16 ; else if ( ctxt -> d & Mmx ) ctxt -> op_bytes = 8 ; } if ( ctxt -> d & ModRM ) { rc = decode_modrm ( ctxt , & ctxt -> memop ) ; if ( ! has_seg_override ) { has_seg_override = true ; ctxt -> seg_override = ctxt -> modrm_seg ; } } else if ( ctxt -> d & MemAbs ) rc = decode_abs ( ctxt , & ctxt -> memop ) ; if ( rc != X86EMUL_CONTINUE ) goto done ; if ( ! has_seg_override ) ctxt -> seg_override = VCPU_SREG_DS ; ctxt -> memop . addr . mem . seg = ctxt -> seg_override ; rc = decode_operand ( ctxt , & ctxt -> src , ( ctxt -> d >> SrcShift ) & OpMask ) ; if ( rc != X86EMUL_CONTINUE ) goto done ; rc = decode_operand ( ctxt , & ctxt -> src2 , ( ctxt -> d >> Src2Shift ) & OpMask ) ; if ( rc != X86EMUL_CONTINUE ) goto done ; rc = decode_operand ( ctxt , & ctxt -> dst , ( ctxt -> d >> DstShift ) & OpMask ) ; if ( ctxt -> rip_relative ) ctxt -> memopp -> addr . mem . ea = address_mask ( ctxt , ctxt -> memopp -> addr . mem . ea + ctxt -> _eip ) ; done : return ( rc != X86EMUL_CONTINUE ) ? EMULATION_FAILED : EMULATION_OK ; } "," ctxt -> rip_relative && likely ( ctxt -> memopp ) ",torvalds@linux/d9092f52d7e61dd1557f2db2400ddb430e85937e,CVE-2016-8630,https://github.com/torvalds/linux/commit/d9092f52d7e61dd1557f2db2400ddb430e85937e,2016-11-28T03:59Z 1483,CWE-400,"CWE-400 static void perf_event_mmap_output ( struct perf_event * event , struct perf_mmap_event * mmap_event ) { struct perf_output_handle handle ; struct perf_sample_data sample ; int size = mmap_event -> event_id . header . size ; int ret ; perf_event_header__init_id ( & mmap_event -> event_id . header , & sample , event ) ; ret = perf_output_begin ( & handle , event , mmap_event -> event_id . header . size , 0 , 0 ) ; if ( ret ) goto out ; mmap_event -> event_id . pid = perf_event_pid ( event , current ) ; mmap_event -> event_id . tid = perf_event_tid ( event , current ) ; perf_output_put ( & handle , mmap_event -> event_id ) ; __output_copy ( & handle , mmap_event -> file_name , mmap_event -> file_size ) ; perf_event__output_id_sample ( event , & handle , & sample ) ; perf_output_end ( & handle ) ; out : mmap_event -> event_id . header . size = size ; } "," header . size , 0 ) ",torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,CVE-2011-2918,https://github.com/torvalds/linux/commit/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,2012-05-24T23:55Z 1484,CWE-264,"CWE-264 static void ifb_setup ( struct net_device * dev ) { dev -> destructor = free_netdev ; dev -> netdev_ops = & ifb_netdev_ops ; ether_setup ( dev ) ; dev -> tx_queue_len = TX_Q_LIMIT ; dev -> features |= IFB_FEATURES ; dev -> vlan_features |= IFB_FEATURES ; dev -> flags |= IFF_NOARP ; dev -> flags &= ~ IFF_MULTICAST ; dev -> priv_flags &= ~ IFF_XMIT_DST_RELEASE ; random_ether_addr ( dev -> dev_addr ) ; } "," priv_flags &= ~ ( IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING ) ; random_ether_addr ( ",torvalds@linux/550fd08c2cebad61c548def135f67aba284c6162,CVE-2011-4112,https://github.com/torvalds/linux/commit/550fd08c2cebad61c548def135f67aba284c6162,2012-05-17T11:00Z 1485,CWE-119,"CWE-119 void vp8_pick_intra_mode ( MACROBLOCK * x , int * rate_ ) { int error4x4 , error16x16 = INT_MAX ; int rate , best_rate = 0 , distortion , best_sse ; MB_PREDICTION_MODE mode , best_mode = DC_PRED ; int this_rd ; unsigned int sse ; BLOCK * b = & x -> block [ 0 ] ; MACROBLOCKD * xd = & x -> e_mbd ; xd -> mode_info_context -> mbmi . ref_frame = INTRA_FRAME ; pick_intra_mbuv_mode ( x ) ; for ( mode = DC_PRED ; mode <= TM_PRED ; mode ++ ) { xd -> mode_info_context -> mbmi . mode = mode ; vp8_build_intra_predictors_mby_s ( xd , xd -> dst . y_buffer - xd -> dst . y_stride , xd -> dst . y_buffer - 1 , xd -> dst . y_stride , xd -> predictor , 16 ) ; distortion = vp8_variance16x16 ( * ( b -> base_src ) , b -> src_stride , xd -> predictor , 16 , & sse ) ; rate = x -> mbmode_cost [ xd -> frame_type ] [ mode ] ; this_rd = RDCOST ( x -> rdmult , x -> rddiv , rate , distortion ) ; if ( error16x16 > this_rd ) { error16x16 = this_rd ; best_mode = mode ; best_sse = sse ; best_rate = rate ; } } xd -> mode_info_context -> mbmi . mode = best_mode ; error4x4 = pick_intra4x4mby_modes ( x , & rate , & best_sse ) ; if ( error4x4 < error16x16 ) { xd -> mode_info_context -> mbmi . mode = B_PRED ; best_rate = rate ; } * rate_ = best_rate ; } "," ; distortion = vpx_variance16x16 ( * ( ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1486,CWE-20,"CWE-20 error_t enc624j600Init ( NetInterface * interface ) { uint16_t temp ; Enc624j600Context * context ; TRACE_INFO ( ""InitializingENC624J600Ethernetcontroller...\\r\\n"" ) ; interface -> spiDriver -> init ( ) ; interface -> extIntDriver -> init ( ) ; context = ( Enc624j600Context * ) interface -> nicContext ; context -> nextPacket = ENC624J600_RX_BUFFER_START ; context -> rxBuffer = memPoolAlloc ( ETH_MAX_FRAME_SIZE ) ; if ( context -> rxBuffer == NULL ) { return ERROR_OUT_OF_MEMORY ; } enc624j600SoftReset ( interface ) ; enc624j600WriteReg ( interface , ENC624J600_REG_ECON2 , ECON2_ETHEN | ECON2_STRCH ) ; if ( macCompAddr ( & interface -> macAddr , & MAC_UNSPECIFIED_ADDR ) ) { temp = enc624j600ReadReg ( interface , ENC624J600_REG_MAADR1 ) ; interface -> macAddr . w [ 0 ] = letoh16 ( temp ) ; temp = enc624j600ReadReg ( interface , ENC624J600_REG_MAADR2 ) ; interface -> macAddr . w [ 1 ] = letoh16 ( temp ) ; temp = enc624j600ReadReg ( interface , ENC624J600_REG_MAADR3 ) ; interface -> macAddr . w [ 2 ] = letoh16 ( temp ) ; macAddrToEui64 ( & interface -> macAddr , & interface -> eui64 ) ; } else { temp = htole16 ( interface -> macAddr . w [ 0 ] ) ; enc624j600WriteReg ( interface , ENC624J600_REG_MAADR1 , temp ) ; temp = htole16 ( interface -> macAddr . w [ 1 ] ) ; enc624j600WriteReg ( interface , ENC624J600_REG_MAADR2 , temp ) ; temp = htole16 ( interface -> macAddr . w [ 2 ] ) ; enc624j600WriteReg ( interface , ENC624J600_REG_MAADR3 , temp ) ; } enc624j600WriteReg ( interface , ENC624J600_REG_ERXST , ENC624J600_RX_BUFFER_START ) ; enc624j600WriteReg ( interface , ENC624J600_REG_ERXTAIL , ENC624J600_RX_BUFFER_STOP ) ; enc624j600WriteReg ( interface , ENC624J600_REG_ERXFCON , ERXFCON_HTEN | ERXFCON_CRCEN | ERXFCON_RUNTEN | ERXFCON_UCEN | ERXFCON_BCEN ) ; enc624j600WriteReg ( interface , ENC624J600_REG_EHT1 , 0x0000 ) ; enc624j600WriteReg ( interface , ENC624J600_REG_EHT2 , 0x0000 ) ; enc624j600WriteReg ( interface , ENC624J600_REG_EHT3 , 0x0000 ) ; enc624j600WriteReg ( interface , ENC624J600_REG_EHT4 , 0x0000 ) ; enc624j600WriteReg ( interface , ENC624J600_REG_MACON2 , MACON2_DEFER | MACON2_PADCFG0 | MACON2_TXCRCEN | MACON2_R1 ) ; enc624j600WriteReg ( interface , ENC624J600_REG_MAMXFL , ETH_MAX_FRAME_SIZE ) ; enc624j600WritePhyReg ( interface , ENC624J600_PHY_REG_PHANA , PHANA_ADPAUS0 | PHANA_AD100FD | PHANA_AD100 | PHANA_AD10FD | PHANA_AD10 | PHANA_ADIEEE0 ) ; enc624j600WriteReg ( interface , ENC624J600_REG_EIR , 0x0000 ) ; enc624j600WriteReg ( interface , ENC624J600_REG_EIE , EIE_INTIE | EIE_LINKIE | EIE_PKTIE | EIE_TXIE | EIE_TXABTIE ) ; enc624j600SetBit ( interface , ENC624J600_REG_ECON1 , ECON1_RXEN ) ; enc624j600DumpReg ( interface ) ; enc624j600DumpPhyReg ( interface ) ; osSetEvent ( & interface -> nicTxEvent ) ; interface -> nicEvent = TRUE ; osSetEvent ( & netEvent ) ; return NO_ERROR ; } "," ( interface , ENC624J600_ECON2 , ENC624J600_ECON2_ETHEN | ENC624J600_ECON2_STRCH ) ; if ( interface , ENC624J600_MAADR1 ) ; interface ( interface , ENC624J600_MAADR2 ) ; interface ( interface , ENC624J600_MAADR3 ) ; interface ( interface , ENC624J600_MAADR1 , temp ) ( interface , ENC624J600_MAADR2 , temp ) ( interface , ENC624J600_MAADR3 , temp ) ( interface , ENC624J600_ERXST , ENC624J600_RX_BUFFER_START ) ( interface , ENC624J600_ERXTAIL , ENC624J600_RX_BUFFER_STOP ) ( interface , ENC624J600_ERXFCON , ENC624J600_ERXFCON_HTEN | ENC624J600_ERXFCON_CRCEN | ENC624J600_ERXFCON_RUNTEN | ENC624J600_ERXFCON_UCEN | ENC624J600_ERXFCON_BCEN ) ; enc624j600WriteReg ( interface , ENC624J600_EHT1 , 0x0000 ) ( interface , ENC624J600_EHT2 , 0x0000 ) ( interface , ENC624J600_EHT3 , 0x0000 ) ( interface , ENC624J600_EHT4 , 0x0000 ) ( interface , ENC624J600_MACON2 , ENC624J600_MACON2_DEFER | ENC624J600_MACON2_PADCFG_AUTO | ENC624J600_MACON2_TXCRCEN | ENC624J600_MACON2_R1_DEFAULT ) ; enc624j600WriteReg ( interface , ENC624J600_MAMXFL , ETH_MAX_FRAME_SIZE ) ( interface , ENC624J600_PHANA , ENC624J600_PHANA_ADPAUS0 | ENC624J600_PHANA_AD100FD | ENC624J600_PHANA_AD100 | ENC624J600_PHANA_AD10FD | ENC624J600_PHANA_AD10 | ENC624J600_PHANA_ADIEEE_DEFAULT ) ; enc624j600WriteReg ( interface , ENC624J600_EIR , 0x0000 ) ( interface , ENC624J600_EIE , ENC624J600_EIE_INTIE | ENC624J600_EIE_LINKIE | ENC624J600_EIE_PKTIE | ENC624J600_EIE_TXIE | ENC624J600_EIE_TXABTIE ) ; enc624j600SetBit ( interface , ENC624J600_ECON1 , ENC624J600_ECON1_RXEN ) ; enc624j600DumpReg ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 1487,CWE-119,"CWE-119 void psf_asciiheader_printf ( SF_PRIVATE * psf , const char * format , ... ) { va_list argptr ; int maxlen ; char * start ; maxlen = strlen ( ( char * ) psf -> header ) ; start = ( ( char * ) psf -> header ) + maxlen ; maxlen = sizeof ( psf -> header ) - maxlen ; va_start ( argptr , format ) ; vsnprintf ( start , maxlen , format , argptr ) ; va_end ( argptr ) ; start [ maxlen - 1 ] = 0 ; psf -> headindex = strlen ( ( char * ) psf -> header ) ; return ; } "," psf -> header . ptr psf -> header . ptr ; maxlen = psf -> header psf -> header . len - maxlen ; ; psf -> header . indx = strlen ( psf -> header . ptr ",erikd@libsndfile/708e996c87c5fae77b104ccfeb8f6db784c32074,CVE-2017-7586,https://github.com/erikd/libsndfile/commit/708e996c87c5fae77b104ccfeb8f6db784c32074,2017-04-07T20:59Z 1488,CWE-119,"CWE-119 static int mark_source_chains ( const struct xt_table_info * newinfo , unsigned int valid_hooks , void * entry0 ) { unsigned int hook ; for ( hook = 0 ; hook < NF_ARP_NUMHOOKS ; hook ++ ) { unsigned int pos = newinfo -> hook_entry [ hook ] ; struct arpt_entry * e = ( struct arpt_entry * ) ( entry0 + pos ) ; if ( ! ( valid_hooks & ( 1 << hook ) ) ) continue ; e -> counters . pcnt = pos ; for ( ; ; ) { const struct xt_standard_target * t = ( void * ) arpt_get_target_c ( e ) ; int visited = e -> comefrom & ( 1 << hook ) ; if ( e -> comefrom & ( 1 << NF_ARP_NUMHOOKS ) ) { pr_notice ( ""arptables:loophook%upos%u%08X.\\n"" , hook , pos , e -> comefrom ) ; return 0 ; } e -> comefrom |= ( ( 1 << hook ) | ( 1 << NF_ARP_NUMHOOKS ) ) ; if ( ( e -> target_offset == sizeof ( struct arpt_entry ) && ( strcmp ( t -> target . u . user . name , XT_STANDARD_TARGET ) == 0 ) && t -> verdict < 0 && unconditional ( & e -> arp ) ) || visited ) { unsigned int oldpos , size ; if ( ( strcmp ( t -> target . u . user . name , XT_STANDARD_TARGET ) == 0 ) && t -> verdict < - NF_MAX_VERDICT - 1 ) { duprintf ( ""mark_source_chains:bad"" ""negativeverdict(%i)\\n"" , t -> verdict ) ; return 0 ; } do { e -> comefrom ^= ( 1 << NF_ARP_NUMHOOKS ) ; oldpos = pos ; pos = e -> counters . pcnt ; e -> counters . pcnt = 0 ; if ( pos == oldpos ) goto next ; e = ( struct arpt_entry * ) ( entry0 + pos ) ; } while ( oldpos == pos + e -> next_offset ) ; size = e -> next_offset ; e = ( struct arpt_entry * ) ( entry0 + pos + size ) ; e -> counters . pcnt = pos ; pos += size ; } else { int newpos = t -> verdict ; if ( strcmp ( t -> target . u . user . name , XT_STANDARD_TARGET ) == 0 && newpos >= 0 ) { if ( newpos > newinfo -> size - sizeof ( struct arpt_entry ) ) { duprintf ( ""mark_source_chains:"" ""badverdict(%i)\\n"" , newpos ) ; return 0 ; } duprintf ( ""Jumprule%u->%u\\n"" , pos , newpos ) ; } else { newpos = pos + e -> next_offset ; } e = ( struct arpt_entry * ) ( entry0 + newpos ) ; e -> counters . pcnt = pos ; pos = newpos ; } } next : duprintf ( ""Finishedchain%u\\n"" , hook ) ; } return 1 ; } "," if ( ( unconditional ( e ) && ( verdict < 0 ) || visited ",torvalds@linux/54d83fc74aa9ec72794373cb47432c5f7fb1a309,CVE-2016-3134,https://github.com/torvalds/linux/commit/54d83fc74aa9ec72794373cb47432c5f7fb1a309,2016-04-27T17:59Z 1489,CWE-119,"CWE-119 static bool parse_notify ( struct pool * pool , json_t * val ) { char * job_id , * prev_hash , * coinbase1 , * coinbase2 , * bbversion , * nbit , * ntime , header [ 228 ] ; unsigned char * cb1 = NULL , * cb2 = NULL ; size_t cb1_len , cb2_len , alloc_len ; bool clean , ret = false ; int merkles , i ; json_t * arr ; arr = json_array_get ( val , 4 ) ; if ( ! arr || ! json_is_array ( arr ) ) goto out ; merkles = json_array_size ( arr ) ; job_id = json_array_string ( val , 0 ) ; prev_hash = __json_array_string ( val , 1 ) ; coinbase1 = json_array_string ( val , 2 ) ; coinbase2 = json_array_string ( val , 3 ) ; bbversion = __json_array_string ( val , 5 ) ; nbit = __json_array_string ( val , 6 ) ; ntime = __json_array_string ( val , 7 ) ; clean = json_is_true ( json_array_get ( val , 8 ) ) ; if ( ! job_id || ! prev_hash || ! coinbase1 || ! coinbase2 || ! bbversion || ! nbit || ! ntime ) { if ( job_id ) free ( job_id ) ; if ( coinbase1 ) free ( coinbase1 ) ; if ( coinbase2 ) free ( coinbase2 ) ; goto out ; } cg_wlock ( & pool -> data_lock ) ; free ( pool -> swork . job_id ) ; pool -> swork . job_id = job_id ; snprintf ( pool -> prev_hash , 65 , ""%s"" , prev_hash ) ; cb1_len = strlen ( coinbase1 ) / 2 ; cb2_len = strlen ( coinbase2 ) / 2 ; snprintf ( pool -> bbversion , 9 , ""%s"" , bbversion ) ; snprintf ( pool -> nbit , 9 , ""%s"" , nbit ) ; snprintf ( pool -> ntime , 9 , ""%s"" , ntime ) ; pool -> swork . clean = clean ; alloc_len = pool -> coinbase_len = cb1_len + pool -> n1_len + pool -> n2size + cb2_len ; pool -> nonce2_offset = cb1_len + pool -> n1_len ; for ( i = 0 ; i < pool -> merkles ; i ++ ) free ( pool -> swork . merkle_bin [ i ] ) ; if ( merkles ) { pool -> swork . merkle_bin = realloc ( pool -> swork . merkle_bin , sizeof ( char * ) * merkles + 1 ) ; for ( i = 0 ; i < merkles ; i ++ ) { char * merkle = json_array_string ( arr , i ) ; pool -> swork . merkle_bin [ i ] = malloc ( 32 ) ; if ( unlikely ( ! pool -> swork . merkle_bin [ i ] ) ) quit ( 1 , ""Failedtomallocpoolsworkmerkle_bin"" ) ; if ( opt_protocol ) applog ( LOG_DEBUG , ""merkle%d:%s"" , i , merkle ) ; ret = hex2bin ( pool -> swork . merkle_bin [ i ] , merkle , 32 ) ; free ( merkle ) ; if ( unlikely ( ! ret ) ) { applog ( LOG_ERR , ""Failedtoconvertmerkletomerkle_bininparse_notify"" ) ; goto out_unlock ; } } } pool -> merkles = merkles ; if ( clean ) pool -> nonce2 = 0 ; # if 0 header_len = strlen ( pool -> bbversion ) + strlen ( pool -> prev_hash ) ; 32 + strlen ( pool -> ntime ) + strlen ( pool -> nbit ) + 8 + 96 ; # endif snprintf ( header , 225 , ""%s%s%s%s%s%s%s"" , pool -> bbversion , pool -> prev_hash , blank_merkle , pool -> ntime , pool -> nbit , ""00000000"" , workpadding ) ; ret = hex2bin ( pool -> header_bin , header , 112 ) ; if ( unlikely ( ! ret ) ) { applog ( LOG_ERR , ""Failedtoconvertheadertoheader_bininparse_notify"" ) ; goto out_unlock ; } cb1 = alloca ( cb1_len ) ; ret = hex2bin ( cb1 , coinbase1 , cb1_len ) ; if ( unlikely ( ! ret ) ) { applog ( LOG_ERR , ""Failedtoconvertcb1tocb1_bininparse_notify"" ) ; goto out_unlock ; } cb2 = alloca ( cb2_len ) ; ret = hex2bin ( cb2 , coinbase2 , cb2_len ) ; if ( unlikely ( ! ret ) ) { applog ( LOG_ERR , ""Failedtoconvertcb2tocb2_bininparse_notify"" ) ; goto out_unlock ; } free ( pool -> coinbase ) ; align_len ( & alloc_len ) ; pool -> coinbase = calloc ( alloc_len , 1 ) ; if ( unlikely ( ! pool -> coinbase ) ) quit ( 1 , ""Failedtocallocpoolcoinbaseinparse_notify"" ) ; memcpy ( pool -> coinbase , cb1 , cb1_len ) ; memcpy ( pool -> coinbase + cb1_len , pool -> nonce1bin , pool -> n1_len ) ; memcpy ( pool -> coinbase + cb1_len + pool -> n1_len + pool -> n2size , cb2 , cb2_len ) ; if ( opt_debug ) { char * cb = bin2hex ( pool -> coinbase , pool -> coinbase_len ) ; applog ( LOG_DEBUG , ""Pool%dcoinbase%s"" , pool -> pool_no , cb ) ; free ( cb ) ; } out_unlock : cg_wunlock ( & pool -> data_lock ) ; if ( opt_protocol ) { applog ( LOG_DEBUG , ""job_id:%s"" , job_id ) ; applog ( LOG_DEBUG , ""prev_hash:%s"" , prev_hash ) ; applog ( LOG_DEBUG , ""coinbase1:%s"" , coinbase1 ) ; applog ( LOG_DEBUG , ""coinbase2:%s"" , coinbase2 ) ; applog ( LOG_DEBUG , ""bbversion:%s"" , bbversion ) ; applog ( LOG_DEBUG , ""nbit:%s"" , nbit ) ; applog ( LOG_DEBUG , ""ntime:%s"" , ntime ) ; applog ( LOG_DEBUG , ""clean:%s"" , clean ? ""yes"" : ""no"" ) ; } free ( coinbase1 ) ; free ( coinbase2 ) ; pool -> getwork_requested ++ ; total_getworks ++ ; if ( pool == current_pool ( ) ) opt_work_update = true ; out : return ret ; } "," if ( ! valid_hex ( job_id ) || ! valid_hex ( prev_hash ) || ! valid_hex ( coinbase1 ) || ! valid_hex ( coinbase2 ) || ! valid_hex ( bbversion ) || ! valid_hex ( nbit ) || ! valid_hex ( ntime ) ) { free ( job_id ) ( job_id ) ; free ( coinbase1 ) ; free ( coinbase2 ",ckolivas@cgminer/e1c5050734123973b99d181c45e74b2cbb00272e,CVE-2014-4501,https://github.com/ckolivas/cgminer/commit/e1c5050734123973b99d181c45e74b2cbb00272e,2014-07-23T14:55Z 1490,CWE-119,"CWE-119 vpx_codec_err_t vpx_codec_destroy ( vpx_codec_ctx_t * ctx ) { vpx_codec_err_t res ; if ( ! ctx ) res = VPX_CODEC_INVALID_PARAM ; else if ( ! ctx -> iface || ! ctx -> priv ) res = VPX_CODEC_ERROR ; else { if ( ctx -> priv -> alg_priv ) ctx -> iface -> destroy ( ctx -> priv -> alg_priv ) ; ctx -> iface = NULL ; ctx -> name = NULL ; ctx -> priv = NULL ; res = VPX_CODEC_OK ; } return SAVE_STATUS ( ctx , res ) ; } "," ; else { ctx -> iface -> destroy ( ( vpx_codec_alg_priv_t * ) ctx -> priv ) ; ctx ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1491,CWE-20,"CWE-20 static bool nested_vmx_exit_handled ( struct kvm_vcpu * vcpu ) { u32 intr_info = vmcs_read32 ( VM_EXIT_INTR_INFO ) ; struct vcpu_vmx * vmx = to_vmx ( vcpu ) ; struct vmcs12 * vmcs12 = get_vmcs12 ( vcpu ) ; u32 exit_reason = vmx -> exit_reason ; if ( vmx -> nested . nested_run_pending ) return 0 ; if ( unlikely ( vmx -> fail ) ) { pr_info_ratelimited ( ""%sfailedvmentry%x\\n"" , __func__ , vmcs_read32 ( VM_INSTRUCTION_ERROR ) ) ; return 1 ; } switch ( exit_reason ) { case EXIT_REASON_EXCEPTION_NMI : if ( ! is_exception ( intr_info ) ) return 0 ; else if ( is_page_fault ( intr_info ) ) return enable_ept ; return vmcs12 -> exception_bitmap & ( 1u << ( intr_info & INTR_INFO_VECTOR_MASK ) ) ; case EXIT_REASON_EXTERNAL_INTERRUPT : return 0 ; case EXIT_REASON_TRIPLE_FAULT : return 1 ; case EXIT_REASON_PENDING_INTERRUPT : return nested_cpu_has ( vmcs12 , CPU_BASED_VIRTUAL_INTR_PENDING ) ; case EXIT_REASON_NMI_WINDOW : return nested_cpu_has ( vmcs12 , CPU_BASED_VIRTUAL_NMI_PENDING ) ; case EXIT_REASON_TASK_SWITCH : return 1 ; case EXIT_REASON_CPUID : return 1 ; case EXIT_REASON_HLT : return nested_cpu_has ( vmcs12 , CPU_BASED_HLT_EXITING ) ; case EXIT_REASON_INVD : return 1 ; case EXIT_REASON_INVLPG : return nested_cpu_has ( vmcs12 , CPU_BASED_INVLPG_EXITING ) ; case EXIT_REASON_RDPMC : return nested_cpu_has ( vmcs12 , CPU_BASED_RDPMC_EXITING ) ; case EXIT_REASON_RDTSC : return nested_cpu_has ( vmcs12 , CPU_BASED_RDTSC_EXITING ) ; case EXIT_REASON_VMCALL : case EXIT_REASON_VMCLEAR : case EXIT_REASON_VMLAUNCH : case EXIT_REASON_VMPTRLD : case EXIT_REASON_VMPTRST : case EXIT_REASON_VMREAD : case EXIT_REASON_VMRESUME : case EXIT_REASON_VMWRITE : case EXIT_REASON_VMOFF : case EXIT_REASON_VMON : return 1 ; case EXIT_REASON_CR_ACCESS : return nested_vmx_exit_handled_cr ( vcpu , vmcs12 ) ; case EXIT_REASON_DR_ACCESS : return nested_cpu_has ( vmcs12 , CPU_BASED_MOV_DR_EXITING ) ; case EXIT_REASON_IO_INSTRUCTION : return nested_vmx_exit_handled_io ( vcpu , vmcs12 ) ; case EXIT_REASON_MSR_READ : case EXIT_REASON_MSR_WRITE : return nested_vmx_exit_handled_msr ( vcpu , vmcs12 , exit_reason ) ; case EXIT_REASON_INVALID_STATE : return 1 ; case EXIT_REASON_MWAIT_INSTRUCTION : return nested_cpu_has ( vmcs12 , CPU_BASED_MWAIT_EXITING ) ; case EXIT_REASON_MONITOR_INSTRUCTION : return nested_cpu_has ( vmcs12 , CPU_BASED_MONITOR_EXITING ) ; case EXIT_REASON_PAUSE_INSTRUCTION : return nested_cpu_has ( vmcs12 , CPU_BASED_PAUSE_EXITING ) || nested_cpu_has2 ( vmcs12 , SECONDARY_EXEC_PAUSE_LOOP_EXITING ) ; case EXIT_REASON_MCE_DURING_VMENTRY : return 0 ; case EXIT_REASON_TPR_BELOW_THRESHOLD : return 1 ; case EXIT_REASON_APIC_ACCESS : return nested_cpu_has2 ( vmcs12 , SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES ) ; case EXIT_REASON_EPT_VIOLATION : case EXIT_REASON_EPT_MISCONFIG : return 0 ; case EXIT_REASON_PREEMPTION_TIMER : return vmcs12 -> pin_based_vm_exec_control & PIN_BASED_VMX_PREEMPTION_TIMER ; case EXIT_REASON_WBINVD : return nested_cpu_has2 ( vmcs12 , SECONDARY_EXEC_WBINVD_EXITING ) ; case EXIT_REASON_XSETBV : return 1 ; default : return 1 ; } } "," case EXIT_REASON_VMON : case EXIT_REASON_INVEPT : ",torvalds@linux/bfd0a56b90005f8c8a004baf407ad90045c2b11e,CVE-2014-3645,https://github.com/torvalds/linux/commit/bfd0a56b90005f8c8a004baf407ad90045c2b11e,2014-11-10T11:55Z 1492,CWE-119,"CWE-119 static void set_good_speed_feature ( VP9_COMP * cpi , VP9_COMMON * cm , SPEED_FEATURES * sf , int speed ) { sf -> adaptive_rd_thresh = 1 ; sf -> recode_loop = ( speed < 1 ) ? ALLOW_RECODE : ALLOW_RECODE_KFMAXBW ; sf -> allow_skip_recode = 1 ; if ( speed >= 1 ) { sf -> use_square_partition_only = ! frame_is_intra_only ( cm ) ; sf -> less_rectangular_check = 1 ; sf -> tx_size_search_method = vp9_frame_is_boosted ( cpi ) ? USE_FULL_RD : USE_LARGESTALL ; if ( MIN ( cm -> width , cm -> height ) >= 720 ) sf -> disable_split_mask = cm -> show_frame ? DISABLE_ALL_SPLIT : DISABLE_ALL_INTER_SPLIT ; else sf -> disable_split_mask = DISABLE_COMPOUND_SPLIT ; sf -> use_rd_breakout = 1 ; sf -> adaptive_motion_search = 1 ; sf -> auto_mv_step_size = 1 ; sf -> adaptive_rd_thresh = 2 ; sf -> subpel_iters_per_step = 1 ; sf -> mode_skip_start = 10 ; sf -> adaptive_pred_interp_filter = 1 ; sf -> recode_loop = ALLOW_RECODE_KFARFGF ; sf -> intra_y_mode_mask [ TX_32X32 ] = INTRA_DC_H_V ; sf -> intra_uv_mode_mask [ TX_32X32 ] = INTRA_DC_H_V ; sf -> intra_y_mode_mask [ TX_16X16 ] = INTRA_DC_H_V ; sf -> intra_uv_mode_mask [ TX_16X16 ] = INTRA_DC_H_V ; } if ( speed >= 2 ) { sf -> tx_size_search_method = vp9_frame_is_boosted ( cpi ) ? USE_FULL_RD : USE_LARGESTALL ; if ( MIN ( cm -> width , cm -> height ) >= 720 ) sf -> disable_split_mask = cm -> show_frame ? DISABLE_ALL_SPLIT : DISABLE_ALL_INTER_SPLIT ; else sf -> disable_split_mask = LAST_AND_INTRA_SPLIT_ONLY ; sf -> adaptive_pred_interp_filter = 2 ; sf -> reference_masking = 1 ; sf -> mode_search_skip_flags = FLAG_SKIP_INTRA_DIRMISMATCH | FLAG_SKIP_INTRA_BESTINTER | FLAG_SKIP_COMP_BESTINTRA | FLAG_SKIP_INTRA_LOWVAR ; sf -> disable_filter_search_var_thresh = 100 ; sf -> comp_inter_joint_search_thresh = BLOCK_SIZES ; sf -> auto_min_max_partition_size = RELAXED_NEIGHBORING_MIN_MAX ; sf -> use_lastframe_partitioning = LAST_FRAME_PARTITION_LOW_MOTION ; sf -> adjust_partitioning_from_last_frame = 1 ; sf -> last_partitioning_redo_frequency = 3 ; } if ( speed >= 3 ) { if ( MIN ( cm -> width , cm -> height ) >= 720 ) sf -> disable_split_mask = DISABLE_ALL_SPLIT ; else sf -> disable_split_mask = DISABLE_ALL_INTER_SPLIT ; sf -> recode_loop = ALLOW_RECODE_KFMAXBW ; sf -> adaptive_rd_thresh = 3 ; sf -> mode_skip_start = 6 ; sf -> use_fast_coef_updates = ONE_LOOP_REDUCED ; sf -> use_fast_coef_costing = 1 ; } if ( speed >= 4 ) { sf -> use_square_partition_only = 1 ; sf -> tx_size_search_method = USE_LARGESTALL ; sf -> disable_split_mask = DISABLE_ALL_SPLIT ; sf -> adaptive_rd_thresh = 4 ; sf -> mode_search_skip_flags |= FLAG_SKIP_COMP_REFMISMATCH | FLAG_EARLY_TERMINATE ; sf -> disable_filter_search_var_thresh = 200 ; sf -> use_lastframe_partitioning = LAST_FRAME_PARTITION_ALL ; sf -> use_lp32x32fdct = 1 ; } if ( speed >= 5 ) { int i ; sf -> partition_search_type = FIXED_PARTITION ; sf -> optimize_coefficients = 0 ; sf -> search_method = HEX ; sf -> disable_filter_search_var_thresh = 500 ; for ( i = 0 ; i < TX_SIZES ; ++ i ) { sf -> intra_y_mode_mask [ i ] = INTRA_DC_ONLY ; sf -> intra_uv_mode_mask [ i ] = INTRA_DC_ONLY ; } cpi -> allow_encode_breakout = ENCODE_BREAKOUT_ENABLED ; } } "," speed ) { const int boosted = frame_is_boosted ( cpi ) ; adaptive_rd_thresh = 1 ; sf -> 1 ) { if ( ( cpi -> twopass . fr_content_type == FC_GRAPHICS_ANIMATION ) || vp9_internal_image_edge ( cpi ) ) { sf -> use_square_partition_only = ! frame_is_boosted ( cpi ) ; } else { cm ) ; } ; sf -> use_rd_breakout = 1 ; sf -> mv . ; sf -> mv . ] = INTRA_DC_H_V ; sf -> tx_size_search_breakout = 1 ; sf -> partition_search_breakout_rate_thr = 80 -> tx_size_search_method = frame_is_boosted ( cpi ) : USE_LARGESTALL ; sf -> reference_masking = cpi -> oxcf . resize_mode != RESIZE_DYNAMIC ? 1 : 0 ; sf -> mode_search_skip_flags = ( cm -> ( cm -> frame_type == KEY_FRAME ) ? 0 : FLAG_SKIP_INTRA_DIRMISMATCH | FLAG_SKIP_INTRA_BESTINTER ; sf -> allow_partition_search_skip = 1 ; } if 3 ) { sf -> use_square_partition_only = ! frame_is_intra_only ( cm ) ; sf -> tx_size_search_method = frame_is_intra_only ( cm ) ? USE_FULL_RD : USE_LARGESTALL ; sf -> mv . subpel_search_method = SUBPEL_TREE_PRUNED ; sf -> adaptive_pred_interp_filter = 0 ; sf -> adaptive_mode_search = 1 ; sf -> cb_partition_search = ! boosted ; sf -> cb_pred_filter_search = 1 ; sf -> alt_ref_search_fp = 1 ; sf -> ; sf -> intra_y_mode_mask [ TX_32X32 ] = INTRA_DC ; sf -> intra_uv_mode_mask [ TX_32X32 ] = INTRA_DC ; sf -> adaptive_interp_filter_search = 1 ; ; sf -> mv . search_method = BIGDIA ; sf -> mv . subpel_search_method = SUBPEL_TREE_PRUNED_MORE ; sf -> = 4 ; if ( cm -> frame_type != KEY_FRAME ) -> mode_search_skip_flags |= FLAG_EARLY_TERMINATE ; sf ; sf -> use_lp32x32fdct = 1 use_lp32x32fdct = 1 ; sf -> use_fast_coef_updates = ONE_LOOP_REDUCED ; sf -> use_fast_coef_costing = 1 ; sf -> motion_field_mode_search = ! boosted ; sf -> partition_search_breakout_rate_thr = 300 ; sf -> optimize_coefficients = 0 ; sf -> mv . i ] = INTRA_DC ; sf -> i ] = INTRA_DC ; } sf -> partition_search_breakout_rate_thr = 500 ; sf -> mv . reduce_first_step_size = 1 ; sf -> simple_model_rd_from_var = 1 ; } } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1493,CWE-20,"CWE-20 static int dccp_packet ( struct nf_conn * ct , const struct sk_buff * skb , unsigned int dataoff , enum ip_conntrack_info ctinfo , u_int8_t pf , unsigned int hooknum , unsigned int * timeouts ) { struct net * net = nf_ct_net ( ct ) ; enum ip_conntrack_dir dir = CTINFO2DIR ( ctinfo ) ; struct dccp_hdr _dh , * dh ; u_int8_t type , old_state , new_state ; enum ct_dccp_roles role ; dh = skb_header_pointer ( skb , dataoff , sizeof ( _dh ) , & dh ) ; BUG_ON ( dh == NULL ) ; type = dh -> dccph_type ; if ( type == DCCP_PKT_RESET && ! test_bit ( IPS_SEEN_REPLY_BIT , & ct -> status ) ) { nf_ct_kill_acct ( ct , ctinfo , skb ) ; return NF_ACCEPT ; } spin_lock_bh ( & ct -> lock ) ; role = ct -> proto . dccp . role [ dir ] ; old_state = ct -> proto . dccp . state ; new_state = dccp_state_table [ role ] [ type ] [ old_state ] ; switch ( new_state ) { case CT_DCCP_REQUEST : if ( old_state == CT_DCCP_TIMEWAIT && role == CT_DCCP_ROLE_SERVER ) { ct -> proto . dccp . role [ dir ] = CT_DCCP_ROLE_CLIENT ; ct -> proto . dccp . role [ ! dir ] = CT_DCCP_ROLE_SERVER ; } break ; case CT_DCCP_RESPOND : if ( old_state == CT_DCCP_REQUEST ) ct -> proto . dccp . handshake_seq = dccp_hdr_seq ( dh ) ; break ; case CT_DCCP_PARTOPEN : if ( old_state == CT_DCCP_RESPOND && type == DCCP_PKT_ACK && dccp_ack_seq ( dh ) == ct -> proto . dccp . handshake_seq ) set_bit ( IPS_ASSURED_BIT , & ct -> status ) ; break ; case CT_DCCP_IGNORE : if ( ct -> proto . dccp . last_dir == ! dir && ct -> proto . dccp . last_pkt == DCCP_PKT_REQUEST && type == DCCP_PKT_RESPONSE ) { ct -> proto . dccp . role [ ! dir ] = CT_DCCP_ROLE_CLIENT ; ct -> proto . dccp . role [ dir ] = CT_DCCP_ROLE_SERVER ; ct -> proto . dccp . handshake_seq = dccp_hdr_seq ( dh ) ; new_state = CT_DCCP_RESPOND ; break ; } ct -> proto . dccp . last_dir = dir ; ct -> proto . dccp . last_pkt = type ; spin_unlock_bh ( & ct -> lock ) ; if ( LOG_INVALID ( net , IPPROTO_DCCP ) ) nf_log_packet ( net , pf , 0 , skb , NULL , NULL , NULL , ""nf_ct_dccp:invalidpacketignored"" ) ; return NF_ACCEPT ; case CT_DCCP_INVALID : spin_unlock_bh ( & ct -> lock ) ; if ( LOG_INVALID ( net , IPPROTO_DCCP ) ) nf_log_packet ( net , pf , 0 , skb , NULL , NULL , NULL , ""nf_ct_dccp:invalidstatetransition"" ) ; return - NF_ACCEPT ; } ct -> proto . dccp . last_dir = dir ; ct -> proto . dccp . last_pkt = type ; ct -> proto . dccp . state = new_state ; spin_unlock_bh ( & ct -> lock ) ; if ( new_state != old_state ) nf_conntrack_event_cache ( IPCT_PROTOINFO , ct ) ; nf_ct_refresh_acct ( ct , ctinfo , skb , timeouts [ new_state ] ) ; return NF_ACCEPT ; } "," ) , & _dh ) ; BUG_ON ",torvalds@linux/b22f5126a24b3b2f15448c3f2a254fc10cbc2b92,CVE-2014-2523,https://github.com/torvalds/linux/commit/b22f5126a24b3b2f15448c3f2a254fc10cbc2b92,2014-03-24T16:40Z 1494,CWE-200,"CWE-200 int compat_get_timex ( struct timex * txc , const struct compat_timex __user * utp ) { struct compat_timex tx32 ; if ( copy_from_user ( & tx32 , utp , sizeof ( struct compat_timex ) ) ) return - EFAULT ; txc -> modes = tx32 . modes ; txc -> offset = tx32 . offset ; txc -> freq = tx32 . freq ; txc -> maxerror = tx32 . maxerror ; txc -> esterror = tx32 . esterror ; txc -> status = tx32 . status ; txc -> constant = tx32 . constant ; txc -> precision = tx32 . precision ; txc -> tolerance = tx32 . tolerance ; txc -> time . tv_sec = tx32 . time . tv_sec ; txc -> time . tv_usec = tx32 . time . tv_usec ; txc -> tick = tx32 . tick ; txc -> ppsfreq = tx32 . ppsfreq ; txc -> jitter = tx32 . jitter ; txc -> shift = tx32 . shift ; txc -> stabil = tx32 . stabil ; txc -> jitcnt = tx32 . jitcnt ; txc -> calcnt = tx32 . calcnt ; txc -> errcnt = tx32 . errcnt ; txc -> stbcnt = tx32 . stbcnt ; return 0 ; } "," compat_timex tx32 ; memset ( txc , 0 , sizeof ( struct timex ) ) ; ",torvalds@linux/0a0b98734479aa5b3c671d5190e86273372cab95,CVE-2018-11508,https://github.com/torvalds/linux/commit/0a0b98734479aa5b3c671d5190e86273372cab95,2018-05-28T13:29Z 1495,CWE-284,"CWE-284 static void * sock_poll_thread ( void * arg ) { struct pollfd pfds [ MAX_POLL ] ; memset ( pfds , 0 , sizeof ( pfds ) ) ; int h = ( intptr_t ) arg ; for ( ; ; ) { prepare_poll_fds ( h , pfds ) ; int ret = poll ( pfds , ts [ h ] . poll_count , - 1 ) ; if ( ret == - 1 ) { APPL_TRACE_ERROR ( ""pollret-1,exitthethread,errno:%d,err:%s"" , errno , strerror ( errno ) ) ; break ; } if ( ret != 0 ) { int need_process_data_fd = TRUE ; if ( pfds [ 0 ] . revents ) { asrt ( pfds [ 0 ] . fd == ts [ h ] . cmd_fdr ) ; if ( ! process_cmd_sock ( h ) ) { APPL_TRACE_DEBUG ( ""h:%d,process_cmd_sockreturnfalse,exit..."" , h ) ; break ; } if ( ret == 1 ) need_process_data_fd = FALSE ; else ret -- ; } if ( need_process_data_fd ) process_data_sock ( h , pfds , ret ) ; } else { APPL_TRACE_DEBUG ( ""nodata,selectret:%d"" , ret ) } ; } ts [ h ] . thread_id = - 1 ; APPL_TRACE_DEBUG ( ""socketpollthreadexiting,h:%d"" , h ) ; return 0 ; } "," int ret = TEMP_FAILURE_RETRY ( , - 1 ) ",system@bt/472271b153c5dc53c28beac55480a8d8434b2d5c,CVE-2016-3839,https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c,2016-08-05T20:59Z 1496,CWE-416,"CWE-416 void luaD_shrinkstack ( lua_State * L ) { int inuse = stackinuse ( L ) ; int goodsize = inuse + ( inuse / 8 ) + 2 * EXTRA_STACK ; if ( goodsize > LUAI_MAXSTACK ) goodsize = LUAI_MAXSTACK ; if ( inuse <= ( LUAI_MAXSTACK - EXTRA_STACK ) && goodsize < L -> stacksize ) luaD_reallocstack ( L , goodsize , 0 ) ; else condmovestack ( L , { } , { } ) ; luaE_shrinkCI ( L ) ; } "," = inuse + BASIC_STACK_SIZE ; if ( ",lua@lua/6298903e35217ab69c279056f925fb72900ce0b7,CVE-2020-15888,https://github.com/lua/lua/commit/6298903e35217ab69c279056f925fb72900ce0b7,2020-07-21T22:15Z 1497,CWE-125,"CWE-125 PyObject * ast2obj_alias ( void * _o ) { alias_ty o = ( alias_ty ) _o ; PyObject * result = NULL , * value = NULL ; if ( ! o ) { Py_INCREF ( Py_None ) ; return Py_None ; } result = PyType_GenericNew ( alias_type , NULL , NULL ) ; if ( ! result ) return NULL ; value = ast2obj_identifier ( o -> name ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_name , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_identifier ( o -> asname ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_asname , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; return result ; failed : Py_XDECREF ( value ) ; Py_XDECREF ( result ) ; return NULL ; } "," o ) { Py_RETURN_NONE ; } result ",python@typed_ast/156afcb26c198e162504a57caddfe0acd9ed7dce,CVE-2019-19275,https://github.com/python/typed_ast/commit/156afcb26c198e162504a57caddfe0acd9ed7dce,2019-11-26T15:15Z 1498,CWE-125,"CWE-125 static expr_ty ast_for_atom ( struct compiling * c , const node * n ) { node * ch = CHILD ( n , 0 ) ; switch ( TYPE ( ch ) ) { case NAME : { PyObject * name = NEW_IDENTIFIER ( ch ) ; if ( ! name ) return NULL ; return Name ( name , Load , LINENO ( n ) , n -> n_col_offset , c -> c_arena ) ; } case STRING : { PyObject * kind , * str = parsestrplus ( c , n ) ; const char * raw , * s = STR ( CHILD ( n , 0 ) ) ; int quote = Py_CHARMASK ( * s ) ; char * ch , s_kind [ 3 ] = { 0 , 0 , 0 } ; ch = s_kind ; raw = s ; while ( * raw && * raw != '\\'' && * raw != \'""\' ) { * ch ++ = * raw ++ ; } kind = PyUnicode_FromString ( s_kind ) ; if ( ! kind ) { return NULL ; } if ( ! str ) { # ifdef Py_USING_UNICODE if ( PyErr_ExceptionMatches ( PyExc_UnicodeError ) ) { PyObject * type , * value , * tback , * errstr ; PyErr_Fetch ( & type , & value , & tback ) ; errstr = PyObject_Str ( value ) ; if ( errstr ) { char * s = """" ; char buf [ 128 ] ; s = _PyUnicode_AsString ( errstr ) ; PyOS_snprintf ( buf , sizeof ( buf ) , ""(unicodeerror)%s"" , s ) ; ast_error ( n , buf ) ; Py_DECREF ( errstr ) ; } else { ast_error ( n , ""(unicodeerror)unknownerror"" ) ; } Py_DECREF ( type ) ; Py_DECREF ( value ) ; Py_XDECREF ( tback ) ; } # endif return NULL ; } PyArena_AddPyObject ( c -> c_arena , str ) ; return Str ( str , kind , LINENO ( n ) , n -> n_col_offset , c -> c_arena ) ; } case NUMBER : { PyObject * pynum = parsenumber ( c , STR ( ch ) ) ; if ( ! pynum ) return NULL ; PyArena_AddPyObject ( c -> c_arena , pynum ) ; return Num ( pynum , LINENO ( n ) , n -> n_col_offset , c -> c_arena ) ; } case LPAR : ch = CHILD ( n , 1 ) ; if ( TYPE ( ch ) == RPAR ) return Tuple ( NULL , Load , LINENO ( n ) , n -> n_col_offset , c -> c_arena ) ; if ( TYPE ( ch ) == yield_expr ) return ast_for_expr ( c , ch ) ; return ast_for_testlist_comp ( c , ch ) ; case LSQB : ch = CHILD ( n , 1 ) ; if ( TYPE ( ch ) == RSQB ) return List ( NULL , Load , LINENO ( n ) , n -> n_col_offset , c -> c_arena ) ; REQ ( ch , listmaker ) ; if ( NCH ( ch ) == 1 || TYPE ( CHILD ( ch , 1 ) ) == COMMA ) { asdl_seq * elts = seq_for_testlist ( c , ch ) ; if ( ! elts ) return NULL ; return List ( elts , Load , LINENO ( n ) , n -> n_col_offset , c -> c_arena ) ; } else return ast_for_listcomp ( c , ch ) ; case LBRACE : { int i , size ; asdl_seq * keys , * values ; ch = CHILD ( n , 1 ) ; if ( TYPE ( ch ) == RBRACE ) { return Dict ( NULL , NULL , LINENO ( n ) , n -> n_col_offset , c -> c_arena ) ; } else if ( NCH ( ch ) == 1 || TYPE ( CHILD ( ch , 1 ) ) == COMMA ) { asdl_seq * elts ; size = ( NCH ( ch ) + 1 ) / 2 ; elts = asdl_seq_new ( size , c -> c_arena ) ; if ( ! elts ) return NULL ; for ( i = 0 ; i < NCH ( ch ) ; i += 2 ) { expr_ty expression ; expression = ast_for_expr ( c , CHILD ( ch , i ) ) ; if ( ! expression ) return NULL ; asdl_seq_SET ( elts , i / 2 , expression ) ; } return Set ( elts , LINENO ( n ) , n -> n_col_offset , c -> c_arena ) ; } else if ( TYPE ( CHILD ( ch , 1 ) ) == comp_for ) { return ast_for_setcomp ( c , ch ) ; } else if ( NCH ( ch ) > 3 && TYPE ( CHILD ( ch , 3 ) ) == comp_for ) { return ast_for_dictcomp ( c , ch ) ; } else { size = ( NCH ( ch ) + 1 ) / 4 ; keys = asdl_seq_new ( size , c -> c_arena ) ; if ( ! keys ) return NULL ; values = asdl_seq_new ( size , c -> c_arena ) ; if ( ! values ) return NULL ; for ( i = 0 ; i < NCH ( ch ) ; i += 4 ) { expr_ty expression ; expression = ast_for_expr ( c , CHILD ( ch , i ) ) ; if ( ! expression ) return NULL ; asdl_seq_SET ( keys , i / 4 , expression ) ; expression = ast_for_expr ( c , CHILD ( ch , i + 2 ) ) ; if ( ! expression ) return NULL ; asdl_seq_SET ( values , i / 4 , expression ) ; } return Dict ( keys , values , LINENO ( n ) , n -> n_col_offset , c -> c_arena ) ; } } case BACKQUOTE : { expr_ty expression ; if ( Py_Py3kWarningFlag && ! ast_warn ( c , n , ""backquotenotsupportedin3.x;userepr()"" ) ) return NULL ; expression = ast_for_testlist ( c , CHILD ( n , 1 ) ) ; if ( ! expression ) return NULL ; return Repr ( expression , LINENO ( n ) , n -> n_col_offset , c -> c_arena ) ; } default : PyErr_Format ( PyExc_SystemError , ""unhandledatom%d"" , TYPE ( ch ) ) ; return NULL ; } } "," , 0 ) ) ; char errstr ) { const ",python@typed_ast/156afcb26c198e162504a57caddfe0acd9ed7dce,CVE-2019-19275,https://github.com/python/typed_ast/commit/156afcb26c198e162504a57caddfe0acd9ed7dce,2019-11-26T15:15Z 1499,CWE-119,"CWE-119 static vpx_codec_err_t parse_options ( SvcContext * svc_ctx , const char * options ) { char * input_string ; char * option_name ; char * option_value ; char * input_ptr ; int is_keyframe_qaunt_set = 0 ; vpx_codec_err_t res = VPX_CODEC_OK ; if ( options == NULL ) return VPX_CODEC_OK ; input_string = strdup ( options ) ; option_name = strtok_r ( input_string , ""="" , & input_ptr ) ; while ( option_name != NULL ) { option_value = strtok_r ( NULL , """" , & input_ptr ) ; if ( option_value == NULL ) { svc_log ( svc_ctx , SVC_LOG_ERROR , ""optionmissingvalue:%s\\n"" , option_name ) ; res = VPX_CODEC_INVALID_PARAM ; break ; } if ( strcmp ( ""encoding-mode"" , option_name ) == 0 ) { res = set_option_encoding_mode ( svc_ctx , option_value ) ; if ( res != VPX_CODEC_OK ) break ; } else if ( strcmp ( ""layers"" , option_name ) == 0 ) { svc_ctx -> spatial_layers = atoi ( option_value ) ; } else if ( strcmp ( ""scale-factors"" , option_name ) == 0 ) { res = parse_scale_factors ( svc_ctx , option_value ) ; if ( res != VPX_CODEC_OK ) break ; } else if ( strcmp ( ""quantizers"" , option_name ) == 0 ) { res = parse_quantizer_values ( svc_ctx , option_value , 0 ) ; if ( res != VPX_CODEC_OK ) break ; if ( ! is_keyframe_qaunt_set ) { SvcInternal * const si = get_svc_internal ( svc_ctx ) ; memcpy ( get_svc_internal ( svc_ctx ) -> quantizer_keyframe , si -> quantizer , sizeof ( si -> quantizer ) ) ; } } else if ( strcmp ( ""quantizers-keyframe"" , option_name ) == 0 ) { res = parse_quantizer_values ( svc_ctx , option_value , 1 ) ; if ( res != VPX_CODEC_OK ) break ; is_keyframe_qaunt_set = 1 ; } else { svc_log ( svc_ctx , SVC_LOG_ERROR , ""invalidoption:%s\\n"" , option_name ) ; res = VPX_CODEC_INVALID_PARAM ; break ; } option_name = strtok_r ( NULL , ""="" , & input_ptr ) ; } free ( input_string ) ; return res ; } "," * input_ptr ; SvcInternal_t * const si = get_svc_internal ( svc_ctx ) ; vpx_codec_err_t res = VPX_CODEC_OK ; int i , alt_ref_enabled = 0 ; if ( ( strcmp ( ""spatial-layers"" , option_name ) == 0 ) { svc_ctx -> spatial_layers = atoi ( option_value ) ; } else if ( strcmp ( ""temporal-layers"" , option_name ) == 0 ) { svc_ctx -> temporal_layers = atoi ( option_value ) ; } else if ( strcmp ( ""scale-factors"" , option_name ) == 0 ) { res = parse_layer_options_from_string ( svc_ctx , SCALE_FACTOR , option_value , si -> svc_params . scaling_factor_num , si -> svc_params . scaling_factor_den ) ; if ( strcmp ( ""max-quantizers"" , option_name ) == 0 ) { res = parse_layer_options_from_string ( svc_ctx , QUANTIZER , option_value , si -> svc_params . max_quantizers , NULL ) ; if ( strcmp ( ""min-quantizers"" , option_name ) == 0 ) { res = parse_layer_options_from_string ( svc_ctx , QUANTIZER , option_value , si -> svc_params . min_quantizers , NULL ) ; if ) break ; } else if ( strcmp ( ""auto-alt-refs"" , option_name ) == 0 ) { res = parse_layer_options_from_string ( svc_ctx , AUTO_ALT_REF , option_value , si -> enable_auto_alt_ref , NULL ) ; if ) break ; } else if ( strcmp ( ""bitrates"" , option_name ) == 0 ) { res = parse_layer_options_from_string ( svc_ctx , BITRATE , option_value , si -> bitrates , NULL ) ; if ( res != VPX_CODEC_OK ) break ; } else if ( strcmp ( ""multi-frame-contexts"" , option_name ) == 0 ) { si -> use_multiple_frame_contexts = atoi ( option_value ) ; } else input_string ) ; for ( i = 0 ; i < svc_ctx -> spatial_layers ; ++ i ) { if ( si -> svc_params . max_quantizers [ i ] > MAX_QUANTIZER || si -> svc_params . max_quantizers [ i ] < 0 || si -> svc_params . min_quantizers [ i ] > si -> svc_params . max_quantizers [ i ] || si -> svc_params . min_quantizers [ i ] < 0 ) res = VPX_CODEC_INVALID_PARAM ; } if ( si -> use_multiple_frame_contexts && ( svc_ctx -> spatial_layers > 3 || svc_ctx -> spatial_layers * svc_ctx -> temporal_layers > 4 ) ) res = VPX_CODEC_INVALID_PARAM ; for ( i = 0 ; i < svc_ctx -> spatial_layers ; ++ i ) alt_ref_enabled += si -> enable_auto_alt_ref [ i ] ; if ( alt_ref_enabled > REF_FRAMES - svc_ctx -> spatial_layers ) { svc_log ( svc_ctx , SVC_LOG_ERROR , ""svc:autoaltref:Maxinum%d(REF_FRAMES-layers)layerscould"" ""enabledautoaltreferenceframe,but%layersareenabled\\n"" , REF_FRAMES - svc_ctx -> spatial_layers , alt_ref_enabled ) ; res = VPX_CODEC_INVALID_PARAM ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1500,CWE-416,"CWE-416 static int perf_swevent_add ( struct perf_event * event , int flags ) { struct swevent_htable * swhash = this_cpu_ptr ( & swevent_htable ) ; struct hw_perf_event * hwc = & event -> hw ; struct hlist_head * head ; if ( is_sampling_event ( event ) ) { hwc -> last_period = hwc -> sample_period ; perf_swevent_set_period ( event ) ; } hwc -> state = ! ( flags & PERF_EF_START ) ; head = find_swevent_head ( swhash , event ) ; if ( ! head ) { WARN_ON_ONCE ( swhash -> online ) ; return - EINVAL ; } hlist_add_head_rcu ( & event -> hlist_entry , head ) ; perf_event_update_userpage ( event ) ; return 0 ; } "," ; if ( WARN_ON_ONCE ( ! head ) ) return - EINVAL - EINVAL ; hlist_add_head_rcu ( & ",torvalds@linux/12ca6ad2e3a896256f086497a7c7406a547ee373,CVE-2015-8963,https://github.com/torvalds/linux/commit/12ca6ad2e3a896256f086497a7c7406a547ee373,2016-11-16T05:59Z 1501,CWE-119,"CWE-119 static void t1mac_output_ascii ( char * s , int len ) { if ( blocktyp == POST_BINARY ) { output_current_post ( ) ; blocktyp = POST_ASCII ; } if ( len > 0 && s [ len - 1 ] == '\\n' ) s [ len - 1 ] = '\\r' ; t1mac_output_data ( ( byte * ) s , len ) ; if ( strncmp ( s , ""/FontName"" , 9 ) == 0 ) { for ( s += 9 ; isspace ( * s ) ; s ++ ) ; if ( * s == '/' ) { const char * t = ++ s ; while ( * t && ! isspace ( * t ) ) t ++ ; free ( font_name ) ; font_name = ( char * ) malloc ( t - s + 1 ) ; memcpy ( font_name , s , t - s ) ; font_name [ t - s ] = 0 ; } } } "," ; isspace ( ( unsigned char ) ! isspace ( ( unsigned char ) ",kohler@t1utils/6b9d1aafcb61a3663c883663eb19ccdbfcde8d33,CVE-2015-3905,https://github.com/kohler/t1utils/commit/6b9d1aafcb61a3663c883663eb19ccdbfcde8d33,2015-06-08T14:59Z 1502,CWE-000,"CWE-000 kadm5_ret_t kadm5_modify_principal ( void * server_handle , kadm5_principal_ent_t entry , long mask ) { int ret , ret2 , i ; kadm5_policy_ent_rec pol ; krb5_boolean have_pol = FALSE ; krb5_db_entry * kdb ; krb5_tl_data * tl_data_orig ; osa_princ_ent_rec adb ; kadm5_server_handle_t handle = server_handle ; CHECK_HANDLE ( server_handle ) ; krb5_clear_error_message ( handle -> context ) ; if ( ( mask & KADM5_PRINCIPAL ) || ( mask & KADM5_LAST_PWD_CHANGE ) || ( mask & KADM5_MOD_TIME ) || ( mask & KADM5_MOD_NAME ) || ( mask & KADM5_MKVNO ) || ( mask & KADM5_AUX_ATTRIBUTES ) || ( mask & KADM5_KEY_DATA ) || ( mask & KADM5_LAST_SUCCESS ) || ( mask & KADM5_LAST_FAILED ) ) return KADM5_BAD_MASK ; if ( ( mask & ~ ALL_PRINC_MASK ) ) return KADM5_BAD_MASK ; if ( ( mask & KADM5_POLICY ) && ( mask & KADM5_POLICY_CLR ) ) return KADM5_BAD_MASK ; if ( entry == ( kadm5_principal_ent_t ) NULL ) return EINVAL ; if ( mask & KADM5_TL_DATA ) { tl_data_orig = entry -> tl_data ; while ( tl_data_orig ) { if ( tl_data_orig -> tl_data_type < 256 ) return KADM5_BAD_TL_TYPE ; tl_data_orig = tl_data_orig -> tl_data_next ; } } ret = kdb_get_entry ( handle , entry -> principal , & kdb , & adb ) ; if ( ret ) return ( ret ) ; if ( ( mask & KADM5_POLICY ) ) { ret = get_policy ( handle , entry -> policy , & pol , & have_pol ) ; if ( ret ) goto done ; adb . aux_attributes |= KADM5_POLICY ; if ( adb . policy ) free ( adb . policy ) ; adb . policy = strdup ( entry -> policy ) ; } if ( have_pol ) { if ( pol . pw_max_life ) { ret = krb5_dbe_lookup_last_pwd_change ( handle -> context , kdb , & ( kdb -> pw_expiration ) ) ; if ( ret ) goto done ; kdb -> pw_expiration += pol . pw_max_life ; } else { kdb -> pw_expiration = 0 ; } } if ( ( mask & KADM5_POLICY_CLR ) && ( adb . aux_attributes & KADM5_POLICY ) ) { free ( adb . policy ) ; adb . policy = NULL ; adb . aux_attributes &= ~ KADM5_POLICY ; kdb -> pw_expiration = 0 ; } if ( ( mask & KADM5_ATTRIBUTES ) ) kdb -> attributes = entry -> attributes ; if ( ( mask & KADM5_MAX_LIFE ) ) kdb -> max_life = entry -> max_life ; if ( ( mask & KADM5_PRINC_EXPIRE_TIME ) ) kdb -> expiration = entry -> princ_expire_time ; if ( mask & KADM5_PW_EXPIRATION ) kdb -> pw_expiration = entry -> pw_expiration ; if ( mask & KADM5_MAX_RLIFE ) kdb -> max_renewable_life = entry -> max_renewable_life ; if ( ( mask & KADM5_KVNO ) ) { for ( i = 0 ; i < kdb -> n_key_data ; i ++ ) kdb -> key_data [ i ] . key_data_kvno = entry -> kvno ; } if ( mask & KADM5_TL_DATA ) { krb5_tl_data * tl ; for ( tl = entry -> tl_data ; tl ; tl = tl -> tl_data_next ) { ret = krb5_dbe_update_tl_data ( handle -> context , kdb , tl ) ; if ( ret ) { goto done ; } } } if ( mask & KADM5_FAIL_AUTH_COUNT ) { if ( entry -> fail_auth_count != 0 ) { ret = KADM5_BAD_SERVER_PARAMS ; goto done ; } kdb -> fail_auth_count = 0 ; } kdb -> mask = mask ; ret = k5_kadm5_hook_modify ( handle -> context , handle -> hook_handles , KADM5_HOOK_STAGE_PRECOMMIT , entry , mask ) ; if ( ret ) goto done ; ret = kdb_put_entry ( handle , kdb , & adb ) ; if ( ret ) goto done ; ( void ) k5_kadm5_hook_modify ( handle -> context , handle -> hook_handles , KADM5_HOOK_STAGE_POSTCOMMIT , entry , mask ) ; ret = KADM5_OK ; done : if ( have_pol ) { ret2 = kadm5_free_policy_ent ( handle -> lhandle , & pol ) ; ret = ret ? ret : ret2 ; } kdb_free_entry ( handle , kdb , & adb ) ; return ret ; } "," ; if ( entry == NULL ) return EINVAL ; if ( KADM5_POLICY ) && entry -> policy == NULL ) return KADM5_BAD_MASK ; if ( ( mask & KADM5_POLICY ) && ( mask & KADM5_POLICY_CLR ) ) return KADM5_BAD_MASK ; if ( ",krb5@krb5/b863de7fbf080b15e347a736fdda0a82d42f4f6b,CVE-2015-8630,https://github.com/krb5/krb5/commit/b863de7fbf080b15e347a736fdda0a82d42f4f6b,2016-02-13T02:59Z 1503,CWE-119,"CWE-119 static int filter_frame ( AVFilterLink * inlink , AVFrame * frame ) { AVFilterContext * ctx = inlink -> dst ; const AVPixFmtDescriptor * desc = av_pix_fmt_desc_get ( inlink -> format ) ; uint32_t plane_checksum [ 4 ] = { 0 } , checksum = 0 ; int i , plane , vsub = desc -> log2_chroma_h ; for ( plane = 0 ; plane < 4 && frame -> data [ plane ] ; plane ++ ) { int64_t linesize = av_image_get_linesize ( frame -> format , frame -> width , plane ) ; uint8_t * data = frame -> data [ plane ] ; int h = plane == 1 || plane == 2 ? FF_CEIL_RSHIFT ( inlink -> h , vsub ) : inlink -> h ; if ( linesize < 0 ) return linesize ; for ( i = 0 ; i < h ; i ++ ) { plane_checksum [ plane ] = av_adler32_update ( plane_checksum [ plane ] , data , linesize ) ; checksum = av_adler32_update ( checksum , data , linesize ) ; data += frame -> linesize [ plane ] ; } } av_log ( ctx , AV_LOG_INFO , ""n:%"" PRId64 ""pts:%spts_time:%spos:%"" PRId64 """" ""fmt:%ssar:%d/%ds:%dx%di:%ciskey:%dtype:%c"" ""checksum:%08Xplane_checksum:[%08X"" , inlink -> frame_count , av_ts2str ( frame -> pts ) , av_ts2timestr ( frame -> pts , & inlink -> time_base ) , av_frame_get_pkt_pos ( frame ) , desc -> name , frame -> sample_aspect_ratio . num , frame -> sample_aspect_ratio . den , frame -> width , frame -> height , ! frame -> interlaced_frame ? 'P' : frame -> top_field_first ? 'T' : 'B' , frame -> key_frame , av_get_picture_type_char ( frame -> pict_type ) , checksum , plane_checksum [ 0 ] ) ; for ( plane = 1 ; plane < 4 && frame -> data [ plane ] ; plane ++ ) av_log ( ctx , AV_LOG_INFO , ""%08X"" , plane_checksum [ plane ] ) ; av_log ( ctx , AV_LOG_INFO , ""]\\n"" ) ; return ff_filter_frame ( inlink -> dst -> outputs [ 0 ] , frame ) ; } "," frame -> data [ plane ] && frame -> linesize [ plane ] && frame -> linesize [ plane ] ",FFmpeg@FFmpeg/e43a0a232dbf6d3c161823c2e07c52e76227a1bc,CVE-2013-4263,https://github.com/FFmpeg/FFmpeg/commit/e43a0a232dbf6d3c161823c2e07c52e76227a1bc,2013-11-23T17:55Z 1504,CWE-119,"CWE-119 void vp8_print_modes_and_motion_vectors ( MODE_INFO * mi , int rows , int cols , int frame ) { int mb_row ; int mb_col ; int mb_index = 0 ; FILE * mvs = fopen ( ""mvs.stt"" , ""a"" ) ; mb_index = 0 ; fprintf ( mvs , ""MbModesforFrame%d\\n"" , frame ) ; for ( mb_row = 0 ; mb_row < rows ; mb_row ++ ) { for ( mb_col = 0 ; mb_col < cols ; mb_col ++ ) { fprintf ( mvs , ""%2d"" , mi [ mb_index ] . mbmi . mode ) ; mb_index ++ ; } fprintf ( mvs , ""\\n"" ) ; mb_index ++ ; } fprintf ( mvs , ""\\n"" ) ; mb_index = 0 ; fprintf ( mvs , ""MbmvrefforFrame%d\\n"" , frame ) ; for ( mb_row = 0 ; mb_row < rows ; mb_row ++ ) { for ( mb_col = 0 ; mb_col < cols ; mb_col ++ ) { fprintf ( mvs , ""%2d"" , mi [ mb_index ] . mbmi . ref_frame ) ; mb_index ++ ; } fprintf ( mvs , ""\\n"" ) ; mb_index ++ ; } fprintf ( mvs , ""\\n"" ) ; mb_index = 0 ; fprintf ( mvs , ""UVModesforFrame%d\\n"" , frame ) ; for ( mb_row = 0 ; mb_row < rows ; mb_row ++ ) { for ( mb_col = 0 ; mb_col < cols ; mb_col ++ ) { fprintf ( mvs , ""%2d"" , mi [ mb_index ] . mbmi . uv_mode ) ; mb_index ++ ; } mb_index ++ ; fprintf ( mvs , ""\\n"" ) ; } fprintf ( mvs , ""\\n"" ) ; mb_index = 0 ; fprintf ( mvs , ""MbsforFrame%d\\n"" , frame ) ; { int b_row ; for ( b_row = 0 ; b_row < 4 * rows ; b_row ++ ) { int b_col ; int bindex ; for ( b_col = 0 ; b_col < 4 * cols ; b_col ++ ) { mb_index = ( b_row >> 2 ) * ( cols + 1 ) + ( b_col >> 2 ) ; bindex = ( b_row & 3 ) * 4 + ( b_col & 3 ) ; if ( mi [ mb_index ] . mbmi . mode == B_PRED ) fprintf ( mvs , ""%2d"" , mi [ mb_index ] . bmi [ bindex ] . as_mode ) ; else fprintf ( mvs , ""xx"" ) ; } fprintf ( mvs , ""\\n"" ) ; } } fprintf ( mvs , ""\\n"" ) ; mb_index = 0 ; fprintf ( mvs , ""MVsforFrame%d\\n"" , frame ) ; for ( mb_row = 0 ; mb_row < rows ; mb_row ++ ) { for ( mb_col = 0 ; mb_col < cols ; mb_col ++ ) { fprintf ( mvs , ""%5d:%-5d"" , mi [ mb_index ] . mbmi . mv . as_mv . row / 2 , mi [ mb_index ] . mbmi . mv . as_mv . col / 2 ) ; mb_index ++ ; } mb_index ++ ; fprintf ( mvs , ""\\n"" ) ; } fprintf ( mvs , ""\\n"" ) ; mb_index = 0 ; fprintf ( mvs , ""MVsforFrame%d\\n"" , frame ) ; { int b_row ; for ( b_row = 0 ; b_row < 4 * rows ; b_row ++ ) { int b_col ; int bindex ; for ( b_col = 0 ; b_col < 4 * cols ; b_col ++ ) { mb_index = ( b_row >> 2 ) * ( cols + 1 ) + ( b_col >> 2 ) ; bindex = ( b_row & 3 ) * 4 + ( b_col & 3 ) ; fprintf ( mvs , ""%3d:%-3d"" , mi [ mb_index ] . bmi [ bindex ] . mv . as_mv . row , mi [ mb_index ] . bmi [ bindex ] . mv . as_mv . col ) ; } fprintf ( mvs , ""\\n"" ) ; } } fprintf ( mvs , ""\\n"" ) ; fclose ( mvs ) ; } "," , ""\\n"" ) ; fprintf ( ""\\n"" ) ; fprintf ( mvs ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1505,CWE-190,"CWE-190 static PyObject * _pickle_UnpicklerMemoProxy_copy_impl ( UnpicklerMemoProxyObject * self ) { Py_ssize_t i ; PyObject * new_memo = PyDict_New ( ) ; if ( new_memo == NULL ) return NULL ; for ( i = 0 ; i < self -> unpickler -> memo_size ; i ++ ) { int status ; PyObject * key , * value ; value = self -> unpickler -> memo [ i ] ; if ( value == NULL ) continue ; key = PyLong_FromSsize_t ( i ) ; if ( key == NULL ) goto error ; status = PyDict_SetItem ( new_memo , key , value ) ; Py_DECREF ( key ) ; if ( status < 0 ) goto error ; } return new_memo ; error : Py_DECREF ( new_memo ) ; return NULL ; } "," self ) { size_t i ; PyObject ",python@cpython/a4ae828ee416a66d8c7bf5ee71d653c2cc6a26dd,CVE-2018-20406,https://github.com/python/cpython/commit/a4ae828ee416a66d8c7bf5ee71d653c2cc6a26dd,2018-12-23T23:29Z 1506,CWE-119,"CWE-119 cJSON * cJSON_CreateObject ( void ) { cJSON * item = cJSON_New_Item ( ) ; if ( item ) item -> type = cJSON_Object ; return item ; } "," ",esnet@iperf/91f2fa59e8ed80dfbf400add0164ee0e508e412a,CVE-2016-4303,https://github.com/esnet/iperf/commit/91f2fa59e8ed80dfbf400add0164ee0e508e412a,2016-09-26T14:59Z 1507,CWE-125,"CWE-125 static int _6502_op ( RAnal * anal , RAnalOp * op , ut64 addr , const ut8 * data , int len ) { char addrbuf [ 64 ] ; const int buffsize = sizeof ( addrbuf ) - 1 ; memset ( op , '\\0' , sizeof ( RAnalOp ) ) ; op -> size = snes_op_get_size ( 1 , 1 , & snes_op [ data [ 0 ] ] ) ; op -> addr = addr ; op -> type = R_ANAL_OP_TYPE_UNK ; op -> id = data [ 0 ] ; r_strbuf_init ( & op -> esil ) ; switch ( data [ 0 ] ) { case 0x02 : case 0x03 : case 0x04 : case 0x07 : case 0x0b : case 0x0c : case 0x0f : case 0x12 : case 0x13 : case 0x14 : case 0x17 : case 0x1a : case 0x1b : case 0x1c : case 0x1f : case 0x22 : case 0x23 : case 0x27 : case 0x2b : case 0x2f : case 0x32 : case 0x33 : case 0x34 : case 0x37 : case 0x3a : case 0x3b : case 0x3c : case 0x3f : case 0x42 : case 0x43 : case 0x44 : case 0x47 : case 0x4b : case 0x4f : case 0x52 : case 0x53 : case 0x54 : case 0x57 : case 0x5a : case 0x5b : case 0x5c : case 0x5f : case 0x62 : case 0x63 : case 0x64 : case 0x67 : case 0x6b : case 0x6f : case 0x72 : case 0x73 : case 0x74 : case 0x77 : case 0x7a : case 0x7b : case 0x7c : case 0x7f : case 0x80 : case 0x82 : case 0x83 : case 0x87 : case 0x89 : case 0x8b : case 0x8f : case 0x92 : case 0x93 : case 0x97 : case 0x9b : case 0x9c : case 0x9e : case 0x9f : case 0xa3 : case 0xa7 : case 0xab : case 0xaf : case 0xb2 : case 0xb3 : case 0xb7 : case 0xbb : case 0xbf : case 0xc2 : case 0xc3 : case 0xc7 : case 0xcb : case 0xcf : case 0xd2 : case 0xd3 : case 0xd4 : case 0xd7 : case 0xda : case 0xdb : case 0xdc : case 0xdf : case 0xe2 : case 0xe3 : case 0xe7 : case 0xeb : case 0xef : case 0xf2 : case 0xf3 : case 0xf4 : case 0xf7 : case 0xfa : case 0xfb : case 0xfc : case 0xff : op -> size = 1 ; op -> type = R_ANAL_OP_TYPE_ILL ; break ; case 0x00 : op -> cycles = 7 ; op -> type = R_ANAL_OP_TYPE_SWI ; op -> size = 1 ; r_strbuf_set ( & op -> esil , "",1,I,=,0,D,=,flags,0x10,|,0x100,sp,+,=[1],pc,1,+,0xfe,sp,+,=[2],3,sp,-=,0xfffe,[2],pc,="" ) ; break ; case 0x78 : case 0x58 : case 0x38 : case 0x18 : case 0xf8 : case 0xd8 : case 0xb8 : op -> cycles = 2 ; op -> type = R_ANAL_OP_TYPE_NOP ; _6502_anal_esil_flags ( op , data [ 0 ] ) ; break ; case 0x24 : case 0x2c : op -> type = R_ANAL_OP_TYPE_MOV ; _6502_anal_esil_get_addr_pattern3 ( op , data , addrbuf , buffsize , 0 ) ; r_strbuf_setf ( & op -> esil , ""a,%s,[1],&,0x80,&,!,!,N,=,a,%s,[1],&,0x40,&,!,!,V,=,a,%s,[1],&,0xff,&,!,Z,="" , addrbuf , addrbuf , addrbuf ) ; break ; case 0x69 : case 0x65 : case 0x75 : case 0x6d : case 0x7d : case 0x79 : case 0x61 : case 0x71 : op -> type = R_ANAL_OP_TYPE_ADD ; _6502_anal_esil_get_addr_pattern1 ( op , data , addrbuf , buffsize ) ; if ( data [ 0 ] == 0x69 ) r_strbuf_setf ( & op -> esil , ""%s,a,+=,C,NUM,$c7,C,=,a,+=,$c7,C,|="" , addrbuf ) ; else r_strbuf_setf ( & op -> esil , ""%s,[1],a,+=,C,NUM,$c7,C,=,a,+=,$c7,C,|="" , addrbuf ) ; _6502_anal_update_flags ( op , _6502_FLAGS_NZ ) ; r_strbuf_append ( & op -> esil , "",a,a,=,$z,Z,="" ) ; break ; case 0xe9 : case 0xe5 : case 0xf5 : case 0xed : case 0xfd : case 0xf9 : case 0xe1 : case 0xf1 : op -> type = R_ANAL_OP_TYPE_SUB ; _6502_anal_esil_get_addr_pattern1 ( op , data , addrbuf , buffsize ) ; if ( data [ 0 ] == 0xe9 ) r_strbuf_setf ( & op -> esil , ""C,!,%s,+,a,-="" , addrbuf ) ; else r_strbuf_setf ( & op -> esil , ""C,!,%s,[1],+,a,-="" , addrbuf ) ; _6502_anal_update_flags ( op , _6502_FLAGS_BNZ ) ; r_strbuf_append ( & op -> esil , "",a,a,=,$z,Z,=,C,!="" ) ; break ; case 0x09 : case 0x05 : case 0x15 : case 0x0d : case 0x1d : case 0x19 : case 0x01 : case 0x11 : op -> type = R_ANAL_OP_TYPE_OR ; _6502_anal_esil_get_addr_pattern1 ( op , data , addrbuf , buffsize ) ; if ( data [ 0 ] == 0x09 ) r_strbuf_setf ( & op -> esil , ""%s,a,|="" , addrbuf ) ; else r_strbuf_setf ( & op -> esil , ""%s,[1],a,|="" , addrbuf ) ; _6502_anal_update_flags ( op , _6502_FLAGS_NZ ) ; break ; case 0x29 : case 0x25 : case 0x35 : case 0x2d : case 0x3d : case 0x39 : case 0x21 : case 0x31 : op -> type = R_ANAL_OP_TYPE_AND ; _6502_anal_esil_get_addr_pattern1 ( op , data , addrbuf , buffsize ) ; if ( data [ 0 ] == 0x29 ) r_strbuf_setf ( & op -> esil , ""%s,a,&="" , addrbuf ) ; else r_strbuf_setf ( & op -> esil , ""%s,[1],a,&="" , addrbuf ) ; _6502_anal_update_flags ( op , _6502_FLAGS_NZ ) ; break ; case 0x49 : case 0x45 : case 0x55 : case 0x4d : case 0x5d : case 0x59 : case 0x41 : case 0x51 : op -> type = R_ANAL_OP_TYPE_XOR ; _6502_anal_esil_get_addr_pattern1 ( op , data , addrbuf , buffsize ) ; if ( data [ 0 ] == 0x49 ) r_strbuf_setf ( & op -> esil , ""%s,a,^="" , addrbuf ) ; else r_strbuf_setf ( & op -> esil , ""%s,[1],a,^="" , addrbuf ) ; _6502_anal_update_flags ( op , _6502_FLAGS_NZ ) ; break ; case 0x0a : case 0x06 : case 0x16 : case 0x0e : case 0x1e : op -> type = R_ANAL_OP_TYPE_SHL ; if ( data [ 0 ] == 0x0a ) { r_strbuf_set ( & op -> esil , ""1,a,<<=,$c7,C,=,a,a,="" ) ; } else { _6502_anal_esil_get_addr_pattern2 ( op , data , addrbuf , buffsize , 'x' ) ; r_strbuf_setf ( & op -> esil , ""1,%s,[1],<<,%s,=[1],$c7,C,="" , addrbuf , addrbuf ) ; } _6502_anal_update_flags ( op , _6502_FLAGS_NZ ) ; break ; case 0x4a : case 0x46 : case 0x56 : case 0x4e : case 0x5e : op -> type = R_ANAL_OP_TYPE_SHR ; if ( data [ 0 ] == 0x4a ) { r_strbuf_set ( & op -> esil , ""1,a,&,C,=,1,a,>>="" ) ; } else { _6502_anal_esil_get_addr_pattern2 ( op , data , addrbuf , buffsize , 'x' ) ; r_strbuf_setf ( & op -> esil , ""1,%s,[1],&,C,=,1,%s,[1],>>,%s,=[1]"" , addrbuf , addrbuf , addrbuf ) ; } _6502_anal_update_flags ( op , _6502_FLAGS_NZ ) ; break ; case 0x2a : case 0x26 : case 0x36 : case 0x2e : case 0x3e : op -> type = R_ANAL_OP_TYPE_ROL ; if ( data [ 0 ] == 0x2a ) { r_strbuf_set ( & op -> esil , ""1,a,<<,C,|,a,=,$c7,C,=,a,a,="" ) ; } else { _6502_anal_esil_get_addr_pattern2 ( op , data , addrbuf , buffsize , 'x' ) ; r_strbuf_setf ( & op -> esil , ""1,%s,[1],<<,C,|,%s,=[1],$c7,C,="" , addrbuf , addrbuf ) ; } _6502_anal_update_flags ( op , _6502_FLAGS_NZ ) ; break ; case 0x6a : case 0x66 : case 0x76 : case 0x6e : case 0x7e : op -> type = R_ANAL_OP_TYPE_ROR ; if ( data [ 0 ] == 0x6a ) { r_strbuf_set ( & op -> esil , ""C,N,=,1,a,&,C,=,1,a,>>,7,N,<<,|,a,="" ) ; } else { _6502_anal_esil_get_addr_pattern2 ( op , data , addrbuf , buffsize , 'x' ) ; r_strbuf_setf ( & op -> esil , ""C,N,=,1,%s,[1],&,C,=,1,%s,[1],>>,7,N,<<,|,%s,=[1]"" , addrbuf , addrbuf , addrbuf ) ; } _6502_anal_update_flags ( op , _6502_FLAGS_NZ ) ; break ; case 0xe6 : case 0xf6 : case 0xee : case 0xfe : op -> type = R_ANAL_OP_TYPE_STORE ; _6502_anal_esil_get_addr_pattern2 ( op , data , addrbuf , buffsize , 'x' ) ; r_strbuf_setf ( & op -> esil , ""%s,++=[1]"" , addrbuf ) ; _6502_anal_update_flags ( op , _6502_FLAGS_NZ ) ; break ; case 0xc6 : case 0xd6 : case 0xce : case 0xde : op -> type = R_ANAL_OP_TYPE_STORE ; _6502_anal_esil_get_addr_pattern2 ( op , data , addrbuf , buffsize , 'x' ) ; r_strbuf_setf ( & op -> esil , ""%s,--=[1]"" , addrbuf ) ; _6502_anal_update_flags ( op , _6502_FLAGS_NZ ) ; break ; case 0xe8 : case 0xc8 : op -> cycles = 2 ; op -> type = R_ANAL_OP_TYPE_STORE ; _6502_anal_esil_inc_reg ( op , data [ 0 ] , ""+"" ) ; break ; case 0xca : case 0x88 : op -> cycles = 2 ; op -> type = R_ANAL_OP_TYPE_STORE ; _6502_anal_esil_inc_reg ( op , data [ 0 ] , ""-"" ) ; break ; case 0xc9 : case 0xc5 : case 0xd5 : case 0xcd : case 0xdd : case 0xd9 : case 0xc1 : case 0xd1 : op -> type = R_ANAL_OP_TYPE_CMP ; _6502_anal_esil_get_addr_pattern1 ( op , data , addrbuf , buffsize ) ; if ( data [ 0 ] == 0xc9 ) r_strbuf_setf ( & op -> esil , ""%s,a,=="" , addrbuf ) ; else r_strbuf_setf ( & op -> esil , ""%s,[1],a,=="" , addrbuf ) ; _6502_anal_update_flags ( op , _6502_FLAGS_BNZ ) ; r_strbuf_append ( & op -> esil , "",C,!,C,="" ) ; break ; case 0xe0 : case 0xe4 : case 0xec : op -> type = R_ANAL_OP_TYPE_CMP ; _6502_anal_esil_get_addr_pattern3 ( op , data , addrbuf , buffsize , 0 ) ; if ( data [ 0 ] == 0xe0 ) r_strbuf_setf ( & op -> esil , ""%s,x,=="" , addrbuf ) ; else r_strbuf_setf ( & op -> esil , ""%s,[1],x,=="" , addrbuf ) ; _6502_anal_update_flags ( op , _6502_FLAGS_BNZ ) ; r_strbuf_append ( & op -> esil , "",C,!,C,="" ) ; break ; case 0xc0 : case 0xc4 : case 0xcc : op -> type = R_ANAL_OP_TYPE_CMP ; _6502_anal_esil_get_addr_pattern3 ( op , data , addrbuf , buffsize , 0 ) ; if ( data [ 0 ] == 0xc0 ) r_strbuf_setf ( & op -> esil , ""%s,y,=="" , addrbuf ) ; else r_strbuf_setf ( & op -> esil , ""%s,[1],y,=="" , addrbuf ) ; _6502_anal_update_flags ( op , _6502_FLAGS_BNZ ) ; r_strbuf_append ( & op -> esil , "",C,!,C,="" ) ; break ; case 0x10 : case 0x30 : case 0x50 : case 0x70 : case 0x90 : case 0xb0 : case 0xd0 : case 0xf0 : op -> cycles = 2 ; op -> failcycles = 3 ; op -> type = R_ANAL_OP_TYPE_CJMP ; if ( data [ 1 ] <= 127 ) op -> jump = addr + data [ 1 ] + op -> size ; else op -> jump = addr - ( 256 - data [ 1 ] ) + op -> size ; op -> fail = addr + op -> size ; _6502_anal_esil_ccall ( op , data [ 0 ] ) ; break ; case 0x20 : op -> cycles = 6 ; op -> type = R_ANAL_OP_TYPE_CALL ; op -> jump = data [ 1 ] | data [ 2 ] << 8 ; op -> stackop = R_ANAL_STACK_INC ; op -> stackptr = 2 ; r_strbuf_setf ( & op -> esil , ""1,pc,-,0xff,sp,+,=[2],0x%04x,pc,=,2,sp,-="" , op -> jump ) ; break ; case 0x4c : op -> cycles = 3 ; op -> type = R_ANAL_OP_TYPE_JMP ; op -> jump = data [ 1 ] | data [ 2 ] << 8 ; r_strbuf_setf ( & op -> esil , ""0x%04x,pc,="" , op -> jump ) ; break ; case 0x6c : op -> cycles = 5 ; op -> type = R_ANAL_OP_TYPE_UJMP ; r_strbuf_setf ( & op -> esil , ""0x%04x,[2],pc,="" , data [ 1 ] | data [ 2 ] << 8 ) ; break ; case 0x60 : op -> eob = true ; op -> type = R_ANAL_OP_TYPE_RET ; op -> cycles = 6 ; op -> stackop = R_ANAL_STACK_INC ; op -> stackptr = - 2 ; r_strbuf_set ( & op -> esil , ""0x101,sp,+,[2],pc,=,pc,++=,2,sp,+="" ) ; break ; case 0x40 : op -> eob = true ; op -> type = R_ANAL_OP_TYPE_RET ; op -> cycles = 6 ; op -> stackop = R_ANAL_STACK_INC ; op -> stackptr = - 3 ; r_strbuf_set ( & op -> esil , ""0x101,sp,+,[1],flags,=,0x102,sp,+,[2],pc,=,3,sp,+="" ) ; break ; case 0xea : op -> type = R_ANAL_OP_TYPE_NOP ; op -> cycles = 2 ; break ; case 0xa9 : case 0xa5 : case 0xb5 : case 0xad : case 0xbd : case 0xb9 : case 0xa1 : case 0xb1 : op -> type = R_ANAL_OP_TYPE_LOAD ; _6502_anal_esil_get_addr_pattern1 ( op , data , addrbuf , buffsize ) ; if ( data [ 0 ] == 0xa9 ) r_strbuf_setf ( & op -> esil , ""%s,a,="" , addrbuf ) ; else r_strbuf_setf ( & op -> esil , ""%s,[1],a,="" , addrbuf ) ; _6502_anal_update_flags ( op , _6502_FLAGS_NZ ) ; break ; case 0xa2 : case 0xa6 : case 0xb6 : case 0xae : case 0xbe : op -> type = R_ANAL_OP_TYPE_LOAD ; _6502_anal_esil_get_addr_pattern2 ( op , data , addrbuf , buffsize , 'y' ) ; if ( data [ 0 ] == 0xa2 ) r_strbuf_setf ( & op -> esil , ""%s,x,="" , addrbuf ) ; else r_strbuf_setf ( & op -> esil , ""%s,[1],x,="" , addrbuf ) ; _6502_anal_update_flags ( op , _6502_FLAGS_NZ ) ; break ; case 0xa0 : case 0xa4 : case 0xb4 : case 0xac : case 0xbc : op -> type = R_ANAL_OP_TYPE_LOAD ; _6502_anal_esil_get_addr_pattern3 ( op , data , addrbuf , buffsize , 'x' ) ; if ( data [ 0 ] == 0xa0 ) r_strbuf_setf ( & op -> esil , ""%s,y,="" , addrbuf ) ; else r_strbuf_setf ( & op -> esil , ""%s,[1],y,="" , addrbuf ) ; _6502_anal_update_flags ( op , _6502_FLAGS_NZ ) ; break ; case 0x85 : case 0x95 : case 0x8d : case 0x9d : case 0x99 : case 0x81 : case 0x91 : op -> type = R_ANAL_OP_TYPE_STORE ; _6502_anal_esil_get_addr_pattern1 ( op , data , addrbuf , buffsize ) ; r_strbuf_setf ( & op -> esil , ""a,%s,=[1]"" , addrbuf ) ; break ; case 0x86 : case 0x96 : case 0x8e : op -> type = R_ANAL_OP_TYPE_STORE ; _6502_anal_esil_get_addr_pattern2 ( op , data , addrbuf , buffsize , 'y' ) ; r_strbuf_setf ( & op -> esil , ""x,%s,=[1]"" , addrbuf ) ; break ; case 0x84 : case 0x94 : case 0x8c : op -> type = R_ANAL_OP_TYPE_STORE ; _6502_anal_esil_get_addr_pattern3 ( op , data , addrbuf , buffsize , 'x' ) ; r_strbuf_setf ( & op -> esil , ""y,%s,=[1]"" , addrbuf ) ; break ; case 0x08 : case 0x48 : op -> type = R_ANAL_OP_TYPE_PUSH ; op -> cycles = 3 ; op -> stackop = R_ANAL_STACK_INC ; op -> stackptr = 1 ; _6502_anal_esil_push ( op , data [ 0 ] ) ; break ; case 0x28 : case 0x68 : op -> type = R_ANAL_OP_TYPE_POP ; op -> cycles = 4 ; op -> stackop = R_ANAL_STACK_INC ; op -> stackptr = - 1 ; _6502_anal_esil_pop ( op , data [ 0 ] ) ; break ; case 0xaa : case 0x8a : case 0xa8 : case 0x98 : op -> type = R_ANAL_OP_TYPE_MOV ; op -> cycles = 2 ; _6502_anal_esil_mov ( op , data [ 0 ] ) ; break ; case 0x9a : op -> type = R_ANAL_OP_TYPE_MOV ; op -> cycles = 2 ; op -> stackop = R_ANAL_STACK_SET ; _6502_anal_esil_mov ( op , data [ 0 ] ) ; break ; case 0xba : op -> type = R_ANAL_OP_TYPE_MOV ; op -> cycles = 2 ; op -> stackop = R_ANAL_STACK_GET ; _6502_anal_esil_mov ( op , data [ 0 ] ) ; break ; } return op -> size ; } "," ; if ( len > 1 ) { if ( <= 127 ) { -> size ; } else { op -> jump -> size ; } } else { op -> jump = addr ; } ",radare@radare2/bbb4af56003c1afdad67af0c4339267ca38b1017,CVE-2018-12322,https://github.com/radare/radare2/commit/bbb4af56003c1afdad67af0c4339267ca38b1017,2018-06-13T16:29Z 1508,CWE-416,"CWE-416 int dbd_db_login ( SV * dbh , imp_dbh_t * imp_dbh , char * dbname , char * user , char * password ) { # ifdef dTHR dTHR ; # endif dTHX ; D_imp_xxh ( dbh ) ; if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , ""imp_dbh->connect:dsn=%s,uid=%s,pwd=%s\\n"" , dbname ? dbname : ""NULL"" , user ? user : ""NULL"" , password ? password : ""NULL"" ) ; imp_dbh -> stats . auto_reconnects_ok = 0 ; imp_dbh -> stats . auto_reconnects_failed = 0 ; imp_dbh -> bind_type_guessing = FALSE ; imp_dbh -> bind_comment_placeholders = FALSE ; imp_dbh -> has_transactions = TRUE ; imp_dbh -> auto_reconnect = FALSE ; # if defined ( sv_utf8_decode ) && MYSQL_VERSION_ID >= SERVER_PREPARE_VERSION imp_dbh -> enable_utf8 = FALSE ; # endif if ( ! my_login ( aTHX_ dbh , imp_dbh ) ) { do_error ( dbh , mysql_errno ( imp_dbh -> pmysql ) , mysql_error ( imp_dbh -> pmysql ) , mysql_sqlstate ( imp_dbh -> pmysql ) ) ; return FALSE ; } DBIc_ACTIVE_on ( imp_dbh ) ; DBIc_on ( imp_dbh , DBIcf_IMPSET ) ; return TRUE ; } "," ) ) { if ( imp_dbh -> pmysql ) ",perl5-dbi@DBD-mysql/a56ae87a4c1c1fead7d09c3653905841ccccf1cc,CVE-2014-9906,https://github.com/perl5-dbi/DBD-mysql/commit/a56ae87a4c1c1fead7d09c3653905841ccccf1cc,2016-08-19T21:59Z 1509,CWE-284,"CWE-284 void btsock_rfc_signaled ( UNUSED_ATTR int fd , int flags , uint32_t user_id ) { pthread_mutex_lock ( & slot_lock ) ; rfc_slot_t * slot = find_rfc_slot_by_id ( user_id ) ; if ( ! slot ) goto out ; bool need_close = false ; if ( flags & SOCK_THREAD_FD_RD && ! slot -> f . server ) { if ( slot -> f . connected ) { int size = 0 ; if ( ! ( flags & SOCK_THREAD_FD_EXCEPTION ) || ( ioctl ( slot -> fd , FIONREAD , & size ) == 0 && size ) ) pthread_mutex_unlock ( & slot_lock ) ; BTA_JvRfcommWrite ( slot -> rfc_handle , slot -> id ) ; } else { LOG_ERROR ( ""%ssocketsignaledforreadwhiledisconnected,slot:%d,channel:%d"" , __func__ , slot -> id , slot -> scn ) ; need_close = true ; } } if ( flags & SOCK_THREAD_FD_WR ) { if ( ! slot -> f . connected || ! flush_incoming_que_on_wr_signal ( slot ) ) { LOG_ERROR ( ""%ssocketsignaledforwritewhiledisconnected(orwritefailure),slot:%d,channel:%d"" , __func__ , slot -> id , slot -> scn ) ; need_close = true ; } } if ( need_close || ( flags & SOCK_THREAD_FD_EXCEPTION ) ) { int size = 0 ; if ( need_close || ioctl ( slot -> fd , FIONREAD , & size ) != 0 || ! size ) cleanup_rfc_slot ( slot ) ; } out : ; pthread_mutex_unlock ( & slot_lock ) ; } "," ) || ( TEMP_FAILURE_RETRY ( & size ) ) size ) ) { BTA_JvRfcommWrite ( slot id ) ; } ( need_close || TEMP_FAILURE_RETRY ( , & size ) ",system@bt/472271b153c5dc53c28beac55480a8d8434b2d5c,CVE-2016-3839,https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c,2016-08-05T20:59Z 1510,CWE-20,"CWE-20 static void dissect_ppi ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree ) { proto_tree * ppi_tree = NULL , * ppi_flags_tree = NULL , * seg_tree = NULL , * ampdu_tree = NULL ; proto_tree * agg_tree = NULL ; proto_item * ti = NULL ; tvbuff_t * next_tvb ; int offset = 0 ; guint version , flags ; gint tot_len , data_len ; guint data_type ; guint32 dlt ; guint32 n_ext_flags = 0 ; guint32 ampdu_id = 0 ; fragment_head * fd_head = NULL ; fragment_item * ft_fdh = NULL ; gint mpdu_count = 0 ; gchar * mpdu_str ; gboolean first_mpdu = TRUE ; guint last_frame = 0 ; gint len_remain , ampdu_len = 0 ; struct ieee_802_11_phdr phdr ; col_set_str ( pinfo -> cinfo , COL_PROTOCOL , ""PPI"" ) ; col_clear ( pinfo -> cinfo , COL_INFO ) ; version = tvb_get_guint8 ( tvb , offset ) ; flags = tvb_get_guint8 ( tvb , offset + 1 ) ; tot_len = tvb_get_letohs ( tvb , offset + 2 ) ; dlt = tvb_get_letohl ( tvb , offset + 4 ) ; col_add_fstr ( pinfo -> cinfo , COL_INFO , ""PPIversion%u,%ubytes"" , version , tot_len ) ; if ( tree ) { ti = proto_tree_add_protocol_format ( tree , proto_ppi , tvb , 0 , tot_len , ""PPIversion%u,%ubytes"" , version , tot_len ) ; ppi_tree = proto_item_add_subtree ( ti , ett_ppi_pph ) ; proto_tree_add_item ( ppi_tree , hf_ppi_head_version , tvb , offset , 1 , ENC_LITTLE_ENDIAN ) ; ti = proto_tree_add_item ( ppi_tree , hf_ppi_head_flags , tvb , offset + 1 , 1 , ENC_LITTLE_ENDIAN ) ; ppi_flags_tree = proto_item_add_subtree ( ti , ett_ppi_flags ) ; proto_tree_add_item ( ppi_flags_tree , hf_ppi_head_flag_alignment , tvb , offset + 1 , 1 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( ppi_flags_tree , hf_ppi_head_flag_reserved , tvb , offset + 1 , 1 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( ppi_tree , hf_ppi_head_len , tvb , offset + 2 , 2 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( ppi_tree , hf_ppi_head_dlt , tvb , offset + 4 , 4 , ENC_LITTLE_ENDIAN ) ; } tot_len -= PPI_V0_HEADER_LEN ; offset += 8 ; memset ( & phdr , 0 , sizeof ( phdr ) ) ; phdr . fcs_len = - 1 ; phdr . decrypted = FALSE ; phdr . datapad = FALSE ; phdr . phy = PHDR_802_11_PHY_UNKNOWN ; phdr . presence_flags = 0 ; while ( tot_len > 0 ) { data_type = tvb_get_letohs ( tvb , offset ) ; data_len = tvb_get_letohs ( tvb , offset + 2 ) + 4 ; tot_len -= data_len ; switch ( data_type ) { case PPI_80211_COMMON : dissect_80211_common ( tvb , pinfo , ppi_tree , offset , data_len , & phdr ) ; break ; case PPI_80211N_MAC : dissect_80211n_mac ( tvb , pinfo , ppi_tree , offset , data_len , TRUE , & n_ext_flags , & ampdu_id , & phdr ) ; break ; case PPI_80211N_MAC_PHY : dissect_80211n_mac_phy ( tvb , pinfo , ppi_tree , offset , data_len , & n_ext_flags , & ampdu_id , & phdr ) ; break ; case PPI_SPECTRUM_MAP : ADD_BASIC_TAG ( hf_spectrum_map ) ; break ; case PPI_PROCESS_INFO : ADD_BASIC_TAG ( hf_process_info ) ; break ; case PPI_CAPTURE_INFO : ADD_BASIC_TAG ( hf_capture_info ) ; break ; case PPI_AGGREGATION_EXTENSION : dissect_aggregation_extension ( tvb , pinfo , ppi_tree , offset , data_len ) ; break ; case PPI_8023_EXTENSION : dissect_8023_extension ( tvb , pinfo , ppi_tree , offset , data_len ) ; break ; case PPI_GPS_INFO : if ( ppi_gps_handle == NULL ) { proto_tree_add_item ( ppi_tree , hf_ppi_gps , tvb , offset , data_len , ENC_NA ) ; } else { next_tvb = tvb_new_subset ( tvb , offset + 4 , data_len - 4 , - 1 ) ; call_dissector ( ppi_gps_handle , next_tvb , pinfo , ppi_tree ) ; } break ; case PPI_VECTOR_INFO : if ( ppi_vector_handle == NULL ) { proto_tree_add_item ( ppi_tree , hf_ppi_vector , tvb , offset , data_len , ENC_NA ) ; } else { next_tvb = tvb_new_subset ( tvb , offset + 4 , data_len - 4 , - 1 ) ; call_dissector ( ppi_vector_handle , next_tvb , pinfo , ppi_tree ) ; } break ; case PPI_SENSOR_INFO : if ( ppi_sensor_handle == NULL ) { proto_tree_add_item ( ppi_tree , hf_ppi_harris , tvb , offset , data_len , ENC_NA ) ; } else { next_tvb = tvb_new_subset ( tvb , offset + 4 , data_len - 4 , - 1 ) ; call_dissector ( ppi_sensor_handle , next_tvb , pinfo , ppi_tree ) ; } break ; case PPI_ANTENNA_INFO : if ( ppi_antenna_handle == NULL ) { proto_tree_add_item ( ppi_tree , hf_ppi_antenna , tvb , offset , data_len , ENC_NA ) ; } else { next_tvb = tvb_new_subset ( tvb , offset + 4 , data_len - 4 , - 1 ) ; call_dissector ( ppi_antenna_handle , next_tvb , pinfo , ppi_tree ) ; } break ; case FNET_PRIVATE : if ( ppi_fnet_handle == NULL ) { proto_tree_add_item ( ppi_tree , hf_ppi_fnet , tvb , offset , data_len , ENC_NA ) ; } else { next_tvb = tvb_new_subset ( tvb , offset + 4 , data_len - 4 , - 1 ) ; call_dissector ( ppi_fnet_handle , next_tvb , pinfo , ppi_tree ) ; } break ; default : proto_tree_add_item ( ppi_tree , hf_ppi_reserved , tvb , offset , data_len , ENC_NA ) ; } offset += data_len ; if ( IS_PPI_FLAG_ALIGN ( flags ) ) { offset += PADDING4 ( offset ) ; } } if ( ppi_ampdu_reassemble && DOT11N_IS_AGGREGATE ( n_ext_flags ) ) { len_remain = tvb_captured_length_remaining ( tvb , offset ) ; # if 0 if ( DOT11N_MORE_AGGREGATES ( n_ext_flags ) ) { pad_len = PADDING4 ( len_remain ) ; } # endif pinfo -> fragmented = TRUE ; fd_head = fragment_get ( & ampdu_reassembly_table , pinfo , ampdu_id , NULL ) ; while ( fd_head ) { ampdu_len += fd_head -> len + PADDING4 ( fd_head -> len ) + 4 ; fd_head = fd_head -> next ; } if ( ampdu_len > AGGREGATE_MAX ) { if ( tree ) { proto_tree_add_expert_format ( ppi_tree , pinfo , & ei_ppi_invalid_length , tvb , offset , - 1 , ""Aggregatelengthgreaterthanmaximum(%u)"" , AGGREGATE_MAX ) ; THROW ( ReportedBoundsError ) ; } else { return ; } } fragment_add_seq_next ( & ampdu_reassembly_table , tvb , offset , pinfo , ampdu_id , NULL , len_remain , TRUE ) ; pinfo -> fragmented = TRUE ; fd_head = fragment_get ( & ampdu_reassembly_table , pinfo , ampdu_id , NULL ) ; if ( fd_head && tree ) { ft_fdh = fd_head ; seg_tree = proto_tree_add_subtree_format ( ppi_tree , tvb , offset , - 1 , ett_ampdu_segments , & ti , ""A-MPDU(%ubytesw/hdrs):"" , ampdu_len ) ; PROTO_ITEM_SET_GENERATED ( ti ) ; while ( ft_fdh ) { if ( ft_fdh -> tvb_data && ft_fdh -> len ) { last_frame = ft_fdh -> frame ; if ( ! first_mpdu ) proto_item_append_text ( ti , "","" ) ; first_mpdu = FALSE ; proto_item_append_text ( ti , ""#%u(%u)"" , ft_fdh -> frame , ft_fdh -> len ) ; proto_tree_add_uint_format ( seg_tree , hf_ampdu_segment , tvb , 0 , 0 , last_frame , ""Frame:%u(%ubyte%s)"" , last_frame , ft_fdh -> len , plurality ( ft_fdh -> len , """" , ""s"" ) ) ; } ft_fdh = ft_fdh -> next ; } if ( last_frame && last_frame != pinfo -> fd -> num ) proto_tree_add_uint ( seg_tree , hf_ampdu_reassembled_in , tvb , 0 , 0 , last_frame ) ; } if ( fd_head && ! DOT11N_MORE_AGGREGATES ( n_ext_flags ) ) { if ( tree ) { ti = proto_tree_add_protocol_format ( tree , proto_get_id_by_filter_name ( ""wlan_aggregate"" ) , tvb , 0 , tot_len , ""IEEE802.11AggregateMPDU"" ) ; agg_tree = proto_item_add_subtree ( ti , ett_ampdu ) ; } while ( fd_head ) { if ( fd_head -> tvb_data && fd_head -> len ) { mpdu_count ++ ; mpdu_str = wmem_strdup_printf ( wmem_packet_scope ( ) , ""MPDU#%d"" , mpdu_count ) ; next_tvb = tvb_new_chain ( tvb , fd_head -> tvb_data ) ; add_new_data_source ( pinfo , next_tvb , mpdu_str ) ; ampdu_tree = proto_tree_add_subtree ( agg_tree , next_tvb , 0 , - 1 , ett_ampdu_segment , NULL , mpdu_str ) ; call_dissector_with_data ( ieee80211_radio_handle , next_tvb , pinfo , ampdu_tree , & phdr ) ; } fd_head = fd_head -> next ; } proto_tree_add_uint ( seg_tree , hf_ampdu_count , tvb , 0 , 0 , mpdu_count ) ; pinfo -> fragmented = FALSE ; } else { next_tvb = tvb_new_subset_remaining ( tvb , offset ) ; col_set_str ( pinfo -> cinfo , COL_PROTOCOL , ""IEEE802.11n"" ) ; col_set_str ( pinfo -> cinfo , COL_INFO , ""UnreassembledA-MPDUdata"" ) ; call_dissector ( data_handle , next_tvb , pinfo , tree ) ; } return ; } next_tvb = tvb_new_subset_remaining ( tvb , offset ) ; if ( dlt == 105 ) { call_dissector_with_data ( ieee80211_radio_handle , next_tvb , pinfo , tree , & phdr ) ; } else { dissector_try_uint ( wtap_encap_dissector_table , wtap_pcap_encap_to_wtap_encap ( dlt ) , next_tvb , pinfo , tree ) ; } } "," struct ieee_802_11_phdr phdr ; int wtap_encap ; struct eth_phdr eth ; void * phdrp } else { wtap_encap = wtap_pcap_encap_to_wtap_encap ( dlt ) ; switch ( wtap_encap ) { case WTAP_ENCAP_ETHERNET : eth . fcs_len = - 1 ; phdrp = & eth ; break ; default : phdrp = NULL ; break ; } dissector_try_uint_new ( wtap_encap_dissector_table , ( wtap_encap_dissector_table , wtap_encap , next_tvb , pinfo , tree , TRUE , phdrp ",wireshark@wireshark/2c13e97d656c1c0ac4d76eb9d307664aae0e0cf7,CVE-2016-5358,https://github.com/wireshark/wireshark/commit/2c13e97d656c1c0ac4d76eb9d307664aae0e0cf7,2016-08-07T16:59Z 1511,CWE-190,"CWE-190 sds sdsnewlen ( const void * init , size_t initlen ) { void * sh ; sds s ; char type = sdsReqType ( initlen ) ; if ( type == SDS_TYPE_5 && initlen == 0 ) type = SDS_TYPE_8 ; int hdrlen = sdsHdrSize ( type ) ; unsigned char * fp ; sh = s_malloc ( hdrlen + initlen + 1 ) ; if ( sh == NULL ) return NULL ; if ( init == SDS_NOINIT ) init = NULL ; else if ( ! init ) memset ( sh , 0 , hdrlen + initlen + 1 ) ; s = ( char * ) sh + hdrlen ; fp = ( ( unsigned char * ) s ) - 1 ; switch ( type ) { case SDS_TYPE_5 : { * fp = type | ( initlen << SDS_TYPE_BITS ) ; break ; } case SDS_TYPE_8 : { SDS_HDR_VAR ( 8 , s ) ; sh -> len = initlen ; sh -> alloc = initlen ; * fp = type ; break ; } case SDS_TYPE_16 : { SDS_HDR_VAR ( 16 , s ) ; sh -> len = initlen ; sh -> alloc = initlen ; * fp = type ; break ; } case SDS_TYPE_32 : { SDS_HDR_VAR ( 32 , s ) ; sh -> len = initlen ; sh -> alloc = initlen ; * fp = type ; break ; } case SDS_TYPE_64 : { SDS_HDR_VAR ( 64 , s ) ; sh -> len = initlen ; sh -> alloc = initlen ; * fp = type ; break ; } } if ( initlen && init ) memcpy ( s , init , initlen ) ; s [ initlen ] = '\\0' ; return s ; } "," * fp ; assert ( initlen + hdrlen + 1 > initlen ) ; ",redis@redis/c992857618db99776917f10bf4f2345a5fdc78b0,CVE-2021-21309,https://github.com/redis/redis/commit/c992857618db99776917f10bf4f2345a5fdc78b0,2021-02-26T22:15Z 1512,CWE-787,"CWE-787 static void nsc_encode_argb_to_aycocg ( NSC_CONTEXT * context , const BYTE * data , UINT32 scanline ) { UINT16 x ; UINT16 y ; UINT16 rw ; BYTE ccl ; const BYTE * src ; BYTE * yplane = NULL ; BYTE * coplane = NULL ; BYTE * cgplane = NULL ; BYTE * aplane = NULL ; INT16 r_val ; INT16 g_val ; INT16 b_val ; BYTE a_val ; UINT32 tempWidth ; tempWidth = ROUND_UP_TO ( context -> width , 8 ) ; rw = ( context -> ChromaSubsamplingLevel ? tempWidth : context -> width ) ; ccl = context -> ColorLossLevel ; for ( y = 0 ; y < context -> height ; y ++ ) { src = data + ( context -> height - 1 - y ) * scanline ; yplane = context -> priv -> PlaneBuffers [ 0 ] + y * rw ; coplane = context -> priv -> PlaneBuffers [ 1 ] + y * rw ; cgplane = context -> priv -> PlaneBuffers [ 2 ] + y * rw ; aplane = context -> priv -> PlaneBuffers [ 3 ] + y * context -> width ; for ( x = 0 ; x < context -> width ; x ++ ) { switch ( context -> format ) { case PIXEL_FORMAT_BGRX32 : b_val = * src ++ ; g_val = * src ++ ; r_val = * src ++ ; src ++ ; a_val = 0xFF ; break ; case PIXEL_FORMAT_BGRA32 : b_val = * src ++ ; g_val = * src ++ ; r_val = * src ++ ; a_val = * src ++ ; break ; case PIXEL_FORMAT_RGBX32 : r_val = * src ++ ; g_val = * src ++ ; b_val = * src ++ ; src ++ ; a_val = 0xFF ; break ; case PIXEL_FORMAT_RGBA32 : r_val = * src ++ ; g_val = * src ++ ; b_val = * src ++ ; a_val = * src ++ ; break ; case PIXEL_FORMAT_BGR24 : b_val = * src ++ ; g_val = * src ++ ; r_val = * src ++ ; a_val = 0xFF ; break ; case PIXEL_FORMAT_RGB24 : r_val = * src ++ ; g_val = * src ++ ; b_val = * src ++ ; a_val = 0xFF ; break ; case PIXEL_FORMAT_BGR16 : b_val = ( INT16 ) ( ( ( * ( src + 1 ) ) & 0xF8 ) | ( ( * ( src + 1 ) ) >> 5 ) ) ; g_val = ( INT16 ) ( ( ( ( * ( src + 1 ) ) & 0x07 ) << 5 ) | ( ( ( * src ) & 0xE0 ) >> 3 ) ) ; r_val = ( INT16 ) ( ( ( ( * src ) & 0x1F ) << 3 ) | ( ( ( * src ) >> 2 ) & 0x07 ) ) ; a_val = 0xFF ; src += 2 ; break ; case PIXEL_FORMAT_RGB16 : r_val = ( INT16 ) ( ( ( * ( src + 1 ) ) & 0xF8 ) | ( ( * ( src + 1 ) ) >> 5 ) ) ; g_val = ( INT16 ) ( ( ( ( * ( src + 1 ) ) & 0x07 ) << 5 ) | ( ( ( * src ) & 0xE0 ) >> 3 ) ) ; b_val = ( INT16 ) ( ( ( ( * src ) & 0x1F ) << 3 ) | ( ( ( * src ) >> 2 ) & 0x07 ) ) ; a_val = 0xFF ; src += 2 ; break ; case PIXEL_FORMAT_A4 : { int shift ; BYTE idx ; shift = ( 7 - ( x % 8 ) ) ; idx = ( ( * src ) >> shift ) & 1 ; idx |= ( ( ( * ( src + 1 ) ) >> shift ) & 1 ) << 1 ; idx |= ( ( ( * ( src + 2 ) ) >> shift ) & 1 ) << 2 ; idx |= ( ( ( * ( src + 3 ) ) >> shift ) & 1 ) << 3 ; idx *= 3 ; r_val = ( INT16 ) context -> palette [ idx ] ; g_val = ( INT16 ) context -> palette [ idx + 1 ] ; b_val = ( INT16 ) context -> palette [ idx + 2 ] ; if ( shift == 0 ) src += 4 ; } a_val = 0xFF ; break ; case PIXEL_FORMAT_RGB8 : { int idx = ( * src ) * 3 ; r_val = ( INT16 ) context -> palette [ idx ] ; g_val = ( INT16 ) context -> palette [ idx + 1 ] ; b_val = ( INT16 ) context -> palette [ idx + 2 ] ; src ++ ; } a_val = 0xFF ; break ; default : r_val = g_val = b_val = a_val = 0 ; break ; } * yplane ++ = ( BYTE ) ( ( r_val >> 2 ) + ( g_val >> 1 ) + ( b_val >> 2 ) ) ; * coplane ++ = ( BYTE ) ( ( r_val - b_val ) >> ccl ) ; * cgplane ++ = ( BYTE ) ( ( - ( r_val >> 1 ) + g_val - ( b_val >> 1 ) ) >> ccl ) ; * aplane ++ = a_val ; } if ( context -> ChromaSubsamplingLevel && ( x % 2 ) == 1 ) { * yplane = * ( yplane - 1 ) ; * coplane = * ( coplane - 1 ) ; * cgplane = * ( cgplane - 1 ) ; } } if ( context -> ChromaSubsamplingLevel && ( y % 2 ) == 1 ) { yplane = context -> priv -> PlaneBuffers [ 0 ] + y * rw ; coplane = context -> priv -> PlaneBuffers [ 1 ] + y * rw ; cgplane = context -> priv -> PlaneBuffers [ 2 ] + y * rw ; CopyMemory ( yplane , yplane - rw , rw ) ; CopyMemory ( coplane , coplane - rw , rw ) ; CopyMemory ( cgplane , cgplane - rw , rw ) ; } } "," static BOOL nsc_encode_argb_to_aycocg ( NSC_CONTEXT ; UINT32 tempWidth ; if ( ! context || data || ( scanline == 0 ) ) return FALSE -> ColorLossLevel ; if ( context -> priv -> PlaneBuffersLength < rw * scanline ) return FALSE ; if ( rw < scanline * 2 ) return FALSE ; ) ; } return TRUE ; ",FreeRDP@FreeRDP/d1112c279bd1a327e8e4d0b5f371458bf2579659,CVE-2018-8788,https://github.com/FreeRDP/FreeRDP/commit/d1112c279bd1a327e8e4d0b5f371458bf2579659,2018-11-29T18:29Z 1513,CWE-399,"CWE-399 static int dissect_spoolss_keybuffer ( tvbuff_t * tvb , int offset , packet_info * pinfo , proto_tree * tree , dcerpc_info * di , guint8 * drep ) { guint32 size ; int end_offset ; if ( di -> conformant_run ) return offset ; offset = dissect_ndr_uint32 ( tvb , offset , pinfo , tree , di , drep , hf_keybuffer_size , & size ) ; end_offset = offset + ( size * 2 ) ; if ( end_offset < offset ) { end_offset = tvb_reported_length_remaining ( tvb , offset ) + 1 ; } while ( offset < end_offset ) offset = dissect_spoolss_uint16uni ( tvb , offset , pinfo , tree , drep , NULL , hf_keybuffer ) ; return offset ; } "," while ( offset > 0 && offset < end_offset ) { hf_keybuffer ) ; } ",wireshark@wireshark/b4d16b4495b732888e12baf5b8a7e9bf2665e22b,CVE-2016-5350,https://github.com/wireshark/wireshark/commit/b4d16b4495b732888e12baf5b8a7e9bf2665e22b,2016-08-07T16:59Z 1514,CWE-401,"CWE-401 static struct prog_entry * predicate_parse ( const char * str , int nr_parens , int nr_preds , parse_pred_fn parse_pred , void * data , struct filter_parse_error * pe ) { struct prog_entry * prog_stack ; struct prog_entry * prog ; const char * ptr = str ; char * inverts = NULL ; int * op_stack ; int * top ; int invert = 0 ; int ret = - ENOMEM ; int len ; int N = 0 ; int i ; nr_preds += 2 ; op_stack = kmalloc_array ( nr_parens , sizeof ( * op_stack ) , GFP_KERNEL ) ; if ( ! op_stack ) return ERR_PTR ( - ENOMEM ) ; prog_stack = kcalloc ( nr_preds , sizeof ( * prog_stack ) , GFP_KERNEL ) ; if ( ! prog_stack ) { parse_error ( pe , - ENOMEM , 0 ) ; goto out_free ; } inverts = kmalloc_array ( nr_preds , sizeof ( * inverts ) , GFP_KERNEL ) ; if ( ! inverts ) { parse_error ( pe , - ENOMEM , 0 ) ; goto out_free ; } top = op_stack ; prog = prog_stack ; * top = 0 ; while ( * ptr ) { const char * next = ptr ++ ; if ( isspace ( * next ) ) continue ; switch ( * next ) { case '(' : if ( top - op_stack > nr_parens ) return ERR_PTR ( - EINVAL ) ; * ( ++ top ) = invert ; continue ; case '!' : if ( ! is_not ( next ) ) break ; invert = ! invert ; continue ; } if ( N >= nr_preds ) { parse_error ( pe , FILT_ERR_TOO_MANY_PREDS , next - str ) ; goto out_free ; } inverts [ N ] = invert ; prog [ N ] . target = N - 1 ; len = parse_pred ( next , data , ptr - str , pe , & prog [ N ] . pred ) ; if ( len < 0 ) { ret = len ; goto out_free ; } ptr = next + len ; N ++ ; ret = - 1 ; while ( 1 ) { next = ptr ++ ; if ( isspace ( * next ) ) continue ; switch ( * next ) { case ')' : case '\\0' : break ; case '&' : case '|' : if ( next [ 1 ] == next [ 0 ] ) { ptr ++ ; break ; } default : parse_error ( pe , FILT_ERR_TOO_MANY_PREDS , next - str ) ; goto out_free ; } invert = * top & INVERT ; if ( * top & PROCESS_AND ) { update_preds ( prog , N - 1 , invert ) ; * top &= ~ PROCESS_AND ; } if ( * next == '&' ) { * top |= PROCESS_AND ; break ; } if ( * top & PROCESS_OR ) { update_preds ( prog , N - 1 , ! invert ) ; * top &= ~ PROCESS_OR ; } if ( * next == '|' ) { * top |= PROCESS_OR ; break ; } if ( ! * next ) goto out ; if ( top == op_stack ) { ret = - 1 ; parse_error ( pe , FILT_ERR_TOO_MANY_CLOSE , ptr - str ) ; goto out_free ; } top -- ; } } out : if ( top != op_stack ) { parse_error ( pe , FILT_ERR_TOO_MANY_OPEN , ptr - str ) ; goto out_free ; } if ( ! N ) { ret = - EINVAL ; parse_error ( pe , FILT_ERR_NO_FILTER , ptr - str ) ; goto out_free ; } prog [ N ] . pred = NULL ; prog [ N ] . target = 1 ; prog [ N + 1 ] . pred = NULL ; prog [ N + 1 ] . target = 0 ; prog [ N - 1 ] . target = N ; prog [ N - 1 ] . when_to_branch = false ; for ( i = N - 1 ; i -- ; ) { int target = prog [ i ] . target ; if ( prog [ i ] . when_to_branch == prog [ target ] . when_to_branch ) prog [ i ] . target = prog [ target ] . target ; } for ( i = 0 ; i < N ; i ++ ) { invert = inverts [ i ] ^ prog [ i ] . when_to_branch ; prog [ i ] . when_to_branch = invert ; if ( WARN_ON ( prog [ i ] . target <= i ) ) { ret = - EINVAL ; goto out_free ; } } kfree ( op_stack ) ; kfree ( inverts ) ; return prog ; out_free : kfree ( op_stack ) ; kfree ( inverts ) ; if ( prog_stack ) { for ( i = 0 ; prog_stack [ i ] . pred ; i ++ ) kfree ( prog_stack [ i ] . pred ) ; kfree ( prog_stack ) ; } return ERR_PTR ( ret ) ; } "," > nr_parens ) { ret = - EINVAL ; goto out_free ; } * ( ++ ",torvalds@linux/96c5c6e6a5b6db592acae039fed54b5c8844cd35,CVE-2019-19072,https://github.com/torvalds/linux/commit/96c5c6e6a5b6db592acae039fed54b5c8844cd35,2019-11-18T06:15Z 1515,CWE-119,"CWE-119 static int calc_iframe_target_size_one_pass_cbr ( const VP9_COMP * cpi ) { const RATE_CONTROL * rc = & cpi -> rc ; int target ; if ( cpi -> common . current_video_frame == 0 ) { target = ( ( cpi -> oxcf . starting_buffer_level / 2 ) > INT_MAX ) ? INT_MAX : ( int ) ( cpi -> oxcf . starting_buffer_level / 2 ) ; } else { const int initial_boost = 32 ; int kf_boost = MAX ( initial_boost , ( int ) ( 2 * cpi -> output_framerate - 16 ) ) ; if ( rc -> frames_since_key < cpi -> output_framerate / 2 ) { kf_boost = ( int ) ( kf_boost * rc -> frames_since_key / ( cpi -> output_framerate / 2 ) ) ; } target = ( ( 16 + kf_boost ) * rc -> av_per_frame_bandwidth ) >> 4 ; } return vp9_rc_clamp_iframe_target_size ( cpi , target ) ; } "," cpi -> rc ; const VP9EncoderConfig * oxcf = & cpi -> oxcf ; const SVC * const svc = & cpi -> svc = ( ( rc -> starting_buffer_level / 2 int ) ( rc -> starting_buffer_level / 2 ) ; } else { int kf_boost = 32 ; double framerate = cpi -> framerate ; if ( svc -> number_temporal_layers > 1 && oxcf -> rc_mode == VPX_CBR ) { const int layer = LAYER_IDS_TO_IDX ( svc -> spatial_layer_id , svc -> temporal_layer_id , svc -> number_temporal_layers ) ; const LAYER_CONTEXT * lc = & svc -> layer_context [ layer ] ; framerate = lc -> framerate ; } kf_boost = MAX = MAX ( kf_boost , ( int ) ( 2 * framerate - 16 ) -> frames_since_key < framerate / 2 ) frames_since_key / ( framerate / 2 ) * rc -> avg_frame_bandwidth ) >> 4 ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1516,CWE-399,"CWE-399 static void enable_nmi_window ( struct kvm_vcpu * vcpu ) { struct vcpu_svm * svm = to_svm ( vcpu ) ; if ( ( svm -> vcpu . arch . hflags & ( HF_NMI_MASK | HF_IRET_MASK ) ) == HF_NMI_MASK ) return ; svm -> nmi_singlestep = true ; svm -> vmcb -> save . rflags |= ( X86_EFLAGS_TF | X86_EFLAGS_RF ) ; update_db_bp_intercept ( vcpu ) ; } "," X86_EFLAGS_RF ) ; } ",torvalds@linux/cbdb967af3d54993f5814f1cee0ed311a055377d,CVE-2015-8104,https://github.com/torvalds/linux/commit/cbdb967af3d54993f5814f1cee0ed311a055377d,2015-11-16T11:59Z 1517,CWE-119,"CWE-119 static int set_registers ( pegasus_t * pegasus , __u16 indx , __u16 size , void * data ) { int ret ; ret = usb_control_msg ( pegasus -> usb , usb_sndctrlpipe ( pegasus -> usb , 0 ) , PEGASUS_REQ_SET_REGS , PEGASUS_REQT_WRITE , 0 , indx , data , size , 100 ) ; if ( ret < 0 ) netif_dbg ( pegasus , drv , pegasus -> net , ""%sreturned%d\\n"" , __func__ , ret ) ; return ret ; } "," __u16 size , const data ) { u8 * buf ; int ret ; buf = kmemdup ( data , size , GFP_NOIO ) ; if ( ! buf ) return - ENOMEM ; ret = , indx , buf , size , ret ) ; kfree ( buf ) ; ",torvalds@linux/5593523f968bc86d42a035c6df47d5e0979b5ace,CVE-2017-8068,https://github.com/torvalds/linux/commit/5593523f968bc86d42a035c6df47d5e0979b5ace,2017-04-23T05:59Z 1518,CWE-119,"CWE-119 static TX_MODE read_tx_mode ( vp9_reader * r ) { TX_MODE tx_mode = vp9_read_literal ( r , 2 ) ; if ( tx_mode == ALLOW_32X32 ) tx_mode += vp9_read_bit ( r ) ; return tx_mode ; } "," TX_MODE read_tx_mode ( vpx_reader * r ) TX_MODE tx_mode = vpx_read_literal ( r , ) tx_mode += vpx_read_bit ( r ) ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1519,CWE-125,"CWE-125 static int ospf6_decode_v3 ( netdissect_options * ndo , register const struct ospf6hdr * op , register const u_char * dataend ) { register const rtrid_t * ap ; register const struct lsr6 * lsrp ; register const struct lsa6_hdr * lshp ; register const struct lsa6 * lsap ; register int i ; switch ( op -> ospf6_type ) { case OSPF_TYPE_HELLO : { register const struct hello6 * hellop = ( const struct hello6 * ) ( ( const uint8_t * ) op + OSPF6HDR_LEN ) ; ND_PRINT ( ( ndo , ""\\n\\tOptions[%s]"" , bittok2str ( ospf6_option_values , ""none"" , EXTRACT_32BITS ( & hellop -> hello_options ) ) ) ) ; ND_TCHECK ( hellop -> hello_deadint ) ; ND_PRINT ( ( ndo , ""\\n\\tHelloTimer%us,DeadTimer%us,Interface-ID%s,Priority%u"" , EXTRACT_16BITS ( & hellop -> hello_helloint ) , EXTRACT_16BITS ( & hellop -> hello_deadint ) , ipaddr_string ( ndo , & hellop -> hello_ifid ) , hellop -> hello_priority ) ) ; ND_TCHECK ( hellop -> hello_dr ) ; if ( EXTRACT_32BITS ( & hellop -> hello_dr ) != 0 ) ND_PRINT ( ( ndo , ""\\n\\tDesignatedRouter%s"" , ipaddr_string ( ndo , & hellop -> hello_dr ) ) ) ; ND_TCHECK ( hellop -> hello_bdr ) ; if ( EXTRACT_32BITS ( & hellop -> hello_bdr ) != 0 ) ND_PRINT ( ( ndo , "",BackupDesignatedRouter%s"" , ipaddr_string ( ndo , & hellop -> hello_bdr ) ) ) ; if ( ndo -> ndo_vflag > 1 ) { ND_PRINT ( ( ndo , ""\\n\\tNeighborList:"" ) ) ; ap = hellop -> hello_neighbor ; while ( ( const u_char * ) ap < dataend ) { ND_TCHECK ( * ap ) ; ND_PRINT ( ( ndo , ""\\n\\t%s"" , ipaddr_string ( ndo , ap ) ) ) ; ++ ap ; } } break ; } case OSPF_TYPE_DD : { register const struct dd6 * ddp = ( const struct dd6 * ) ( ( const uint8_t * ) op + OSPF6HDR_LEN ) ; ND_TCHECK ( ddp -> db_options ) ; ND_PRINT ( ( ndo , ""\\n\\tOptions[%s]"" , bittok2str ( ospf6_option_values , ""none"" , EXTRACT_32BITS ( & ddp -> db_options ) ) ) ) ; ND_TCHECK ( ddp -> db_flags ) ; ND_PRINT ( ( ndo , "",DDFlags[%s]"" , bittok2str ( ospf6_dd_flag_values , ""none"" , ddp -> db_flags ) ) ) ; ND_TCHECK ( ddp -> db_seq ) ; ND_PRINT ( ( ndo , "",MTU%u,DD-Sequence0x%08x"" , EXTRACT_16BITS ( & ddp -> db_mtu ) , EXTRACT_32BITS ( & ddp -> db_seq ) ) ) ; if ( ndo -> ndo_vflag > 1 ) { lshp = ddp -> db_lshdr ; while ( ( const u_char * ) lshp < dataend ) { if ( ospf6_print_lshdr ( ndo , lshp ++ , dataend ) ) goto trunc ; } } break ; } case OSPF_TYPE_LS_REQ : if ( ndo -> ndo_vflag > 1 ) { lsrp = ( const struct lsr6 * ) ( ( const uint8_t * ) op + OSPF6HDR_LEN ) ; while ( ( const u_char * ) lsrp < dataend ) { ND_TCHECK ( * lsrp ) ; ND_PRINT ( ( ndo , ""\\n\\tAdvertisingRouter%s"" , ipaddr_string ( ndo , & lsrp -> ls_router ) ) ) ; ospf6_print_ls_type ( ndo , EXTRACT_16BITS ( & lsrp -> ls_type ) , & lsrp -> ls_stateid ) ; ++ lsrp ; } } break ; case OSPF_TYPE_LS_UPDATE : if ( ndo -> ndo_vflag > 1 ) { register const struct lsu6 * lsup = ( const struct lsu6 * ) ( ( const uint8_t * ) op + OSPF6HDR_LEN ) ; ND_TCHECK ( lsup -> lsu_count ) ; i = EXTRACT_32BITS ( & lsup -> lsu_count ) ; lsap = lsup -> lsu_lsa ; while ( ( const u_char * ) lsap < dataend && i -- ) { if ( ospf6_print_lsa ( ndo , lsap , dataend ) ) goto trunc ; lsap = ( const struct lsa6 * ) ( ( const u_char * ) lsap + EXTRACT_16BITS ( & lsap -> ls_hdr . ls_length ) ) ; } } break ; case OSPF_TYPE_LS_ACK : if ( ndo -> ndo_vflag > 1 ) { lshp = ( const struct lsa6_hdr * ) ( ( const uint8_t * ) op + OSPF6HDR_LEN ) ; while ( ( const u_char * ) lshp < dataend ) { if ( ospf6_print_lshdr ( ndo , lshp ++ , dataend ) ) goto trunc ; } } break ; default : break ; } return ( 0 ) ; trunc : return ( 1 ) ; } "," op + OSPF6HDR_LEN ) ; ND_TCHECK_32BITS ( & hellop -> hello_options ",the-tcpdump-group@tcpdump/88b2dac837e81cf56dce05e6e7b5989332c0092d,CVE-2017-13036,https://github.com/the-tcpdump-group/tcpdump/commit/88b2dac837e81cf56dce05e6e7b5989332c0092d,2017-09-14T06:29Z 1520,CWE-129,"CWE-129 int snmp_version ( void * context , size_t hdrlen , unsigned char tag , const void * data , size_t datalen ) { if ( * ( unsigned char * ) data > 1 ) return - ENOTSUPP ; return 1 ; } "," { if ( datalen != 1 ) return - EINVAL ; if ( ",torvalds@linux/c4c07b4d6fa1f11880eab8e076d3d060ef3f55fc,CVE-2019-9162,https://github.com/torvalds/linux/commit/c4c07b4d6fa1f11880eab8e076d3d060ef3f55fc,2019-02-25T23:29Z 1521,CWE-119,"CWE-119 void uwbd_start ( struct uwb_rc * rc ) { rc -> uwbd . task = kthread_run ( uwbd , rc , ""uwbd"" ) ; if ( rc -> uwbd . task == NULL ) printk ( KERN_ERR ""UWB:Cannotstartmanagementdaemon;"" ""UWBwon\'twork\\n"" ) ; else rc -> uwbd . pid = rc -> uwbd . task -> pid ; } "," rc ) { struct task_struct * task = kthread_run ; if ( IS_ERR ( task ) ) { uwbd . task = NULL ; printk ( KERN_ERR ""UWBwon\'twork\\n"" ) ; } else { rc -> uwbd . task = task ; rc -> uwbd pid ; } } ",torvalds@linux/bbf26183b7a6236ba602f4d6a2f7cade35bba043,CVE-2017-16526,https://github.com/torvalds/linux/commit/bbf26183b7a6236ba602f4d6a2f7cade35bba043,2017-11-04T01:29Z 1522,CWE-674,"CWE-674 static void yydestruct ( const char * yymsg , int yytype , YYSTYPE * yyvaluep , void * yyscanner , RE_LEX_ENVIRONMENT * lex_env ) { YYUSE ( yyvaluep ) ; YYUSE ( yyscanner ) ; YYUSE ( lex_env ) ; if ( ! yymsg ) yymsg = ""Deleting"" ; YY_SYMBOL_PRINT ( yymsg , yytype , yyvaluep , yylocationp ) ; YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN switch ( yytype ) { case 6 : # line 96 ""re_grammar.y"" { yr_free ( ( ( * yyvaluep ) . class_vector ) ) ; } # line 1045 ""re_grammar.c"" break ; case 26 : # line 97 ""re_grammar.y"" { yr_re_node_destroy ( ( ( * yyvaluep ) . re_node ) ) ; } # line 1051 ""re_grammar.c"" break ; case 27 : # line 98 ""re_grammar.y"" { yr_re_node_destroy ( ( ( * yyvaluep ) . re_node ) ) ; } # line 1057 ""re_grammar.c"" break ; case 28 : # line 99 ""re_grammar.y"" { yr_re_node_destroy ( ( ( * yyvaluep ) . re_node ) ) ; } # line 1063 ""re_grammar.c"" break ; case 29 : # line 100 ""re_grammar.y"" { yr_re_node_destroy ( ( ( * yyvaluep ) . re_node ) ) ; } # line 1069 ""re_grammar.c"" break ; default : break ; } YY_IGNORE_MAYBE_UNINITIALIZED_END } "," : # line 104 ""re_grammar.y"" { yr_free } # line 1053 ""re_grammar.c"" break ; : # line 105 ""re_grammar.y"" { yr_re_node_destroy ( ( ( * yyvaluep ) . re_node ) ) ; } # line 1059 ""re_grammar.c"" break ; : # line 106 ""re_grammar.y"" { yr_re_node_destroy ( ( ( * yyvaluep ) . re_node ) ) ; } # line 1065 ""re_grammar.c"" break ; : # line 107 ""re_grammar.y"" { yr_re_node_destroy ( ( ( * yyvaluep ) . re_node ) ) ; } # line 1071 ""re_grammar.c"" break ; : # line 108 ""re_grammar.y"" { yr_re_node_destroy ( ( ( * yyvaluep ) . re_node ) ) ; } # line 1077 ""re_grammar.c"" break ; ",VirusTotal@yara/925bcf3c3b0a28b5b78e25d9efda5c0bf27ae699,CVE-2017-9304,https://github.com/VirusTotal/yara/commit/925bcf3c3b0a28b5b78e25d9efda5c0bf27ae699,2017-05-31T04:29Z 1523,CWE-125,"CWE-125 void lcdSetPixels_ArrayBuffer_flat ( JsGraphics * gfx , short x , short y , short pixelCount , unsigned int col ) { unsigned char * ptr = ( unsigned char * ) gfx -> backendData ; unsigned int idx = lcdGetPixelIndex_ArrayBuffer ( gfx , x , y , pixelCount ) ; ptr += idx >> 3 ; unsigned int whiteMask = ( 1U << gfx -> data . bpp ) - 1 ; bool shortCut = ( col == 0 || ( col & whiteMask ) == whiteMask ) && ( ! ( gfx -> data . flags & JSGRAPHICSFLAGS_ARRAYBUFFER_VERTICAL_BYTE ) ) ; while ( pixelCount -- ) { if ( gfx -> data . bpp & 7 ) { idx = idx & 7 ; if ( shortCut && idx == 0 ) { int wholeBytes = ( gfx -> data . bpp * ( pixelCount + 1 ) ) >> 3 ; if ( wholeBytes ) { char c = ( char ) ( col ? 0xFF : 0 ) ; pixelCount = ( short ) ( pixelCount + 1 - ( wholeBytes * 8 / gfx -> data . bpp ) ) ; while ( wholeBytes -- ) { * ptr = c ; ptr ++ ; } continue ; } } unsigned int mask = ( unsigned int ) ( 1 << gfx -> data . bpp ) - 1 ; unsigned int existing = ( unsigned int ) * ptr ; unsigned int bitIdx = ( gfx -> data . flags & JSGRAPHICSFLAGS_ARRAYBUFFER_MSB ) ? 8 - ( idx + gfx -> data . bpp ) : idx ; * ptr = ( char ) ( ( existing & ~ ( mask << bitIdx ) ) | ( ( col & mask ) << bitIdx ) ) ; if ( gfx -> data . flags & JSGRAPHICSFLAGS_ARRAYBUFFER_VERTICAL_BYTE ) { ptr ++ ; } else { idx += gfx -> data . bpp ; if ( idx >= 8 ) ptr ++ ; } } else { int i ; for ( i = 0 ; i < gfx -> data . bpp ; i += 8 ) { * ptr = ( char ) ( col >> i ) ; ptr ++ ; } } } } "," : idx ; assert ( ptr >= gfx -> backendData && ptr < ( ( char * ) gfx -> backendData + graphicsGetMemoryRequired ( gfx ) ) ) ; ",espruino@Espruino/8a44b04b584b3d3ab1cb68fed410f7ecb165e50e,CVE-2018-11592,https://github.com/espruino/Espruino/commit/8a44b04b584b3d3ab1cb68fed410f7ecb165e50e,2018-05-31T16:29Z 1524,CWE-119,"CWE-119 static void tokenize_b ( int plane , int block , BLOCK_SIZE plane_bsize , TX_SIZE tx_size , void * arg ) { struct tokenize_b_args * const args = arg ; VP9_COMP * cpi = args -> cpi ; MACROBLOCKD * xd = args -> xd ; TOKENEXTRA * * tp = args -> tp ; uint8_t token_cache [ 32 * 32 ] ; struct macroblock_plane * p = & cpi -> mb . plane [ plane ] ; struct macroblockd_plane * pd = & xd -> plane [ plane ] ; MB_MODE_INFO * mbmi = & xd -> mi [ 0 ] -> mbmi ; int pt ; int c ; TOKENEXTRA * t = * tp ; int eob = p -> eobs [ block ] ; const PLANE_TYPE type = pd -> plane_type ; const int16_t * qcoeff = BLOCK_OFFSET ( p -> qcoeff , block ) ; const int segment_id = mbmi -> segment_id ; const int16_t * scan , * nb ; const scan_order * so ; const int ref = is_inter_block ( mbmi ) ; unsigned int ( * const counts ) [ COEFF_CONTEXTS ] [ ENTROPY_TOKENS ] = cpi -> coef_counts [ tx_size ] [ type ] [ ref ] ; vp9_prob ( * const coef_probs ) [ COEFF_CONTEXTS ] [ UNCONSTRAINED_NODES ] = cpi -> common . fc . coef_probs [ tx_size ] [ type ] [ ref ] ; unsigned int ( * const eob_branch ) [ COEFF_CONTEXTS ] = cpi -> common . counts . eob_branch [ tx_size ] [ type ] [ ref ] ; const uint8_t * const band = get_band_translate ( tx_size ) ; const int seg_eob = get_tx_eob ( & cpi -> common . seg , segment_id , tx_size ) ; int aoff , loff ; txfrm_block_to_raster_xy ( plane_bsize , tx_size , block , & aoff , & loff ) ; pt = get_entropy_context ( tx_size , pd -> above_context + aoff , pd -> left_context + loff ) ; so = get_scan ( xd , tx_size , type , block ) ; scan = so -> scan ; nb = so -> neighbors ; c = 0 ; while ( c < eob ) { int v = 0 ; int skip_eob = 0 ; v = qcoeff [ scan [ c ] ] ; while ( ! v ) { add_token_no_extra ( & t , coef_probs [ band [ c ] ] [ pt ] , ZERO_TOKEN , skip_eob , counts [ band [ c ] ] [ pt ] ) ; eob_branch [ band [ c ] ] [ pt ] += ! skip_eob ; skip_eob = 1 ; token_cache [ scan [ c ] ] = 0 ; ++ c ; pt = get_coef_context ( nb , token_cache , c ) ; v = qcoeff [ scan [ c ] ] ; } add_token ( & t , coef_probs [ band [ c ] ] [ pt ] , vp9_dct_value_tokens_ptr [ v ] . extra , ( uint8_t ) vp9_dct_value_tokens_ptr [ v ] . token , ( uint8_t ) skip_eob , counts [ band [ c ] ] [ pt ] ) ; eob_branch [ band [ c ] ] [ pt ] += ! skip_eob ; token_cache [ scan [ c ] ] = vp9_pt_energy_class [ vp9_dct_value_tokens_ptr [ v ] . token ] ; ++ c ; pt = get_coef_context ( nb , token_cache , c ) ; } if ( c < seg_eob ) { add_token_no_extra ( & t , coef_probs [ band [ c ] ] [ pt ] , EOB_TOKEN , 0 , counts [ band [ c ] ] [ pt ] ) ; ++ eob_branch [ band [ c ] ] [ pt ] ; } * tp = t ; vp9_set_contexts ( xd , pd , plane_bsize , tx_size , c > 0 , aoff , loff ) ; } "," -> cpi ; ThreadData * const td = args -> td ; MACROBLOCK * const x = & td -> mb ; MACROBLOCKD * const xd = & x -> e_mbd ; TOKENEXTRA * p = & x -> plane [ plane plane_type ; const tran_low_t * qcoeff = BLOCK_OFFSET ( p -> qcoeff , block ) ; const int segment_id = mbmi -> segment_id ; const int16_t * scan , * nb ; const scan_order * so ; const int ref = is_inter_block ( mbmi ) ; unsigned int ( * const counts ) [ COEFF_CONTEXTS ] [ ENTROPY_TOKENS ] = td -> rd_counts . coef_counts [ tx_size ] [ type ] [ ref ] ; vpx_prob ( * const common . fc -> coef_probs [ tx_size COEFF_CONTEXTS ] = td -> counts -> eob_branch [ tx_size tx_size ) ; int16_t token ; EXTRABIT extra ; ] ; } vp9_get_token_extra ( v , & token , & extra ) ; pt ] , extra , ( ( uint8_t ) token , ( = vp9_pt_energy_class [ token ] ; ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1525,CWE-674,"CWE-674 static int renameTableSelectCb ( Walker * pWalker , Select * pSelect ) { int i ; RenameCtx * p = pWalker -> u . pRename ; SrcList * pSrc = pSelect -> pSrc ; if ( pSrc == 0 ) { assert ( pWalker -> pParse -> db -> mallocFailed ) ; return WRC_Abort ; } for ( i = 0 ; i < pSrc -> nSrc ; i ++ ) { struct SrcList_item * pItem = & pSrc -> a [ i ] ; if ( pItem -> pTab == p -> pTab ) { renameTokenFind ( pWalker -> pParse , p , pItem -> zName ) ; } } renameWalkWith ( pWalker , pSelect ) ; return WRC_Continue ; } "," pSelect -> pSrc ; if ( pSelect -> selFlags & SF_View ) return WRC_Prune ",sqlite@sqlite/38096961c7cd109110ac21d3ed7dad7e0cb0ae06,CVE-2019-19645,https://github.com/sqlite/sqlite/commit/38096961c7cd109110ac21d3ed7dad7e0cb0ae06,2019-12-09T16:15Z 1526,CWE-000,"CWE-000 long do_shmat ( int shmid , char __user * shmaddr , int shmflg , ulong * raddr , unsigned long shmlba ) { struct shmid_kernel * shp ; unsigned long addr ; unsigned long size ; struct file * file ; int err ; unsigned long flags ; unsigned long prot ; int acc_mode ; struct ipc_namespace * ns ; struct shm_file_data * sfd ; struct path path ; fmode_t f_mode ; unsigned long populate = 0 ; err = - EINVAL ; if ( shmid < 0 ) goto out ; else if ( ( addr = ( ulong ) shmaddr ) ) { if ( addr & ( shmlba - 1 ) ) { if ( shmflg & SHM_RND ) addr &= ~ ( shmlba - 1 ) ; else # ifndef __ARCH_FORCE_SHMLBA if ( addr & ~ PAGE_MASK ) # endif goto out ; } flags = MAP_SHARED | MAP_FIXED ; } else { if ( ( shmflg & SHM_REMAP ) ) goto out ; flags = MAP_SHARED ; } if ( shmflg & SHM_RDONLY ) { prot = PROT_READ ; acc_mode = S_IRUGO ; f_mode = FMODE_READ ; } else { prot = PROT_READ | PROT_WRITE ; acc_mode = S_IRUGO | S_IWUGO ; f_mode = FMODE_READ | FMODE_WRITE ; } if ( shmflg & SHM_EXEC ) { prot |= PROT_EXEC ; acc_mode |= S_IXUGO ; } ns = current -> nsproxy -> ipc_ns ; rcu_read_lock ( ) ; shp = shm_obtain_object_check ( ns , shmid ) ; if ( IS_ERR ( shp ) ) { err = PTR_ERR ( shp ) ; goto out_unlock ; } err = - EACCES ; if ( ipcperms ( ns , & shp -> shm_perm , acc_mode ) ) goto out_unlock ; err = security_shm_shmat ( shp , shmaddr , shmflg ) ; if ( err ) goto out_unlock ; ipc_lock_object ( & shp -> shm_perm ) ; if ( ! ipc_valid_object ( & shp -> shm_perm ) ) { ipc_unlock_object ( & shp -> shm_perm ) ; err = - EIDRM ; goto out_unlock ; } path = shp -> shm_file -> f_path ; path_get ( & path ) ; shp -> shm_nattch ++ ; size = i_size_read ( d_inode ( path . dentry ) ) ; ipc_unlock_object ( & shp -> shm_perm ) ; rcu_read_unlock ( ) ; err = - ENOMEM ; sfd = kzalloc ( sizeof ( * sfd ) , GFP_KERNEL ) ; if ( ! sfd ) { path_put ( & path ) ; goto out_nattch ; } file = alloc_file ( & path , f_mode , is_file_hugepages ( shp -> shm_file ) ? & shm_file_operations_huge : & shm_file_operations ) ; err = PTR_ERR ( file ) ; if ( IS_ERR ( file ) ) { kfree ( sfd ) ; path_put ( & path ) ; goto out_nattch ; } file -> private_data = sfd ; file -> f_mapping = shp -> shm_file -> f_mapping ; sfd -> id = shp -> shm_perm . id ; sfd -> ns = get_ipc_ns ( ns ) ; sfd -> file = shp -> shm_file ; sfd -> vm_ops = NULL ; err = security_mmap_file ( file , prot , flags ) ; if ( err ) goto out_fput ; if ( down_write_killable ( & current -> mm -> mmap_sem ) ) { err = - EINTR ; goto out_fput ; } if ( addr && ! ( shmflg & SHM_REMAP ) ) { err = - EINVAL ; if ( addr + size < addr ) goto invalid ; if ( find_vma_intersection ( current -> mm , addr , addr + size ) ) goto invalid ; } addr = do_mmap_pgoff ( file , addr , size , prot , flags , 0 , & populate , NULL ) ; * raddr = addr ; err = 0 ; if ( IS_ERR_VALUE ( addr ) ) err = ( long ) addr ; invalid : up_write ( & current -> mm -> mmap_sem ) ; if ( populate ) mm_populate ( addr , populate ) ; out_fput : fput ( file ) ; out_nattch : down_write ( & shm_ids ( ns ) . rwsem ) ; shp = shm_lock ( ns , shmid ) ; shp -> shm_nattch -- ; if ( shm_may_destroy ( ns , shp ) ) shm_destroy ( ns , shp ) ; else shm_unlock ( shp ) ; up_write ( & shm_ids ( ns ) . rwsem ) ; return err ; out_unlock : rcu_read_unlock ( ) ; out : return err ; } "," { if ( ( shmflg & SHM_RND ) && addr >= shmlba ",torvalds@linux/95e91b831f87ac8e1f8ed50c14d709089b4e01b8,CVE-2017-5669,https://github.com/torvalds/linux/commit/95e91b831f87ac8e1f8ed50c14d709089b4e01b8,2017-02-24T15:59Z 1527,CWE-404,"CWE-404 static struct svc_serv * nfs_callback_create_svc ( int minorversion ) { struct nfs_callback_data * cb_info = & nfs_callback_info [ minorversion ] ; struct svc_serv * serv ; struct svc_serv_ops * sv_ops ; if ( cb_info -> serv ) { svc_get ( cb_info -> serv ) ; return cb_info -> serv ; } switch ( minorversion ) { case 0 : sv_ops = nfs4_cb_sv_ops [ 0 ] ; break ; default : sv_ops = nfs4_cb_sv_ops [ 1 ] ; } if ( sv_ops == NULL ) return ERR_PTR ( - ENOTSUPP ) ; if ( cb_info -> users ) printk ( KERN_WARNING ""nfs_callback_create_svc:nokthread,%dusers??\\n"" , cb_info -> users ) ; serv = svc_create ( & nfs4_callback_program , NFS4_CALLBACK_BUFSIZE , sv_ops ) ; if ( ! serv ) { printk ( KERN_ERR ""nfs_callback_create_svc:createservicefailed\\n"" ) ; return ERR_PTR ( - ENOMEM ) ; } cb_info -> serv = serv ; serv -> sv_maxconn = 1024 ; dprintk ( ""nfs_callback_create_svc:servicecreated\\n"" ) ; return serv ; } "," ; serv = svc_create_pooled ( & nfs4_callback_program ",torvalds@linux/c70422f760c120480fee4de6c38804c72aa26bc1,CVE-2017-9059,https://github.com/torvalds/linux/commit/c70422f760c120480fee4de6c38804c72aa26bc1,2017-05-18T06:29Z 1528,CWE-347,"CWE-347 void pointZZ_pMul ( PointZZ_p * rop , const PointZZ_p * point , const mpz_t scalar , const CurveZZ_p * curve ) { PointZZ_p R0 , R1 , tmp ; mpz_inits ( R1 . x , R1 . y , tmp . x , tmp . y , NULL ) ; mpz_init_set ( R0 . x , point -> x ) ; mpz_init_set ( R0 . y , point -> y ) ; pointZZ_pDouble ( & R1 , point , curve ) ; int dbits = mpz_sizeinbase ( scalar , 2 ) , i ; for ( i = dbits - 2 ; i >= 0 ; i -- ) { if ( mpz_tstbit ( scalar , i ) ) { mpz_set ( tmp . x , R0 . x ) ; mpz_set ( tmp . y , R0 . y ) ; pointZZ_pAdd ( & R0 , & R1 , & tmp , curve ) ; mpz_set ( tmp . x , R1 . x ) ; mpz_set ( tmp . y , R1 . y ) ; pointZZ_pDouble ( & R1 , & tmp , curve ) ; } else { mpz_set ( tmp . x , R1 . x ) ; mpz_set ( tmp . y , R1 . y ) ; pointZZ_pAdd ( & R1 , & R0 , & tmp , curve ) ; mpz_set ( tmp . x , R0 . x ) ; mpz_set ( tmp . y , R0 . y ) ; pointZZ_pDouble ( & R0 , & tmp , curve ) ; } } mpz_init_set ( rop -> x , R0 . x ) ; mpz_init_set ( rop -> y , R0 . y ) ; mpz_clears ( R0 . x , R0 . y , R1 . x , R1 . y , tmp . x , tmp . y , NULL ) ; } "," curve ) { if ( pointZZ_pIsIdentityElement ( point ) ) { return pointZZ_pSetToIdentityElement ( rop ) ; } ",AntonKueltz@fastecdsa/e592f106edd5acf6dacedfab2ad16fe6c735c9d1,CVE-2020-12607,https://github.com/AntonKueltz/fastecdsa/commit/e592f106edd5acf6dacedfab2ad16fe6c735c9d1,2020-06-02T21:15Z 1529,CWE-772,"CWE-772 gstrings_ret * get_strings_2_svc ( gstrings_arg * arg , struct svc_req * rqstp ) { static gstrings_ret ret ; char * prime_arg ; gss_buffer_desc client_name , service_name ; OM_uint32 minor_stat ; kadm5_server_handle_t handle ; const char * errmsg = NULL ; xdr_free ( xdr_gstrings_ret , & ret ) ; if ( ( ret . code = new_server_handle ( arg -> api_version , rqstp , & handle ) ) ) goto exit_func ; if ( ( ret . code = check_handle ( ( void * ) handle ) ) ) goto exit_func ; ret . api_version = handle -> api_version ; if ( setup_gss_names ( rqstp , & client_name , & service_name ) < 0 ) { ret . code = KADM5_FAILURE ; goto exit_func ; } if ( krb5_unparse_name ( handle -> context , arg -> princ , & prime_arg ) ) { ret . code = KADM5_BAD_PRINCIPAL ; goto exit_func ; } if ( ! cmp_gss_krb5_name ( handle , rqst2name ( rqstp ) , arg -> princ ) && ( CHANGEPW_SERVICE ( rqstp ) || ! kadm5int_acl_check ( handle -> context , rqst2name ( rqstp ) , ACL_INQUIRE , arg -> princ , NULL ) ) ) { ret . code = KADM5_AUTH_GET ; log_unauth ( ""kadm5_get_strings"" , prime_arg , & client_name , & service_name , rqstp ) ; } else { ret . code = kadm5_get_strings ( ( void * ) handle , arg -> princ , & ret . strings , & ret . count ) ; if ( ret . code != 0 ) errmsg = krb5_get_error_message ( handle -> context , ret . code ) ; log_done ( ""kadm5_get_strings"" , prime_arg , errmsg , & client_name , & service_name , rqstp ) ; if ( errmsg != NULL ) krb5_free_error_message ( handle -> context , errmsg ) ; } free ( prime_arg ) ; gss_release_buffer ( & minor_stat , & client_name ) ; gss_release_buffer ( & minor_stat , & service_name ) ; exit_func : free_server_handle ( handle ) ; return & ret ; } "," ; gss_buffer_desc client_name = GSS_C_EMPTY_BUFFER ; gss_buffer_desc service_name = GSS_C_EMPTY_BUFFER ; OM_uint32 minor_stat prime_arg ) ; exit_func : service_name ) ; free_server_handle ( handle ",krb5@krb5/83ed75feba32e46f736fcce0d96a0445f29b96c2,CVE-2015-8631,https://github.com/krb5/krb5/commit/83ed75feba32e46f736fcce0d96a0445f29b96c2,2016-02-13T02:59Z 1530,CWE-264,"CWE-264 int rpc_type_of_NPNVariable ( int variable ) { int type ; switch ( variable ) { case NPNVjavascriptEnabledBool : case NPNVasdEnabledBool : case NPNVisOfflineBool : case NPNVSupportsXEmbedBool : case NPNVSupportsWindowless : type = RPC_TYPE_BOOLEAN ; break ; case NPNVToolkit : case NPNVnetscapeWindow : type = RPC_TYPE_UINT32 ; break ; case NPNVWindowNPObject : case NPNVPluginElementNPObject : type = RPC_TYPE_NP_OBJECT ; break ; default : type = RPC_ERROR_GENERIC ; break ; } return type ; } "," : case NPNVSupportsWindowless : case NPNVprivateModeBool : case NPNVsupportsAdvancedKeyHandling ",davidben@nspluginwrapper/7e4ab8e1189846041f955e6c83f72bc1624e7a98,CVE-2011-2486,https://github.com/davidben/nspluginwrapper/commit/7e4ab8e1189846041f955e6c83f72bc1624e7a98,2012-11-19T12:10Z 1531,CWE-284,"CWE-284 ssize_t socket_write_and_transfer_fd ( const socket_t * socket , const void * buf , size_t count , int fd ) { assert ( socket != NULL ) ; assert ( buf != NULL ) ; if ( fd == INVALID_FD ) return socket_write ( socket , buf , count ) ; struct msghdr msg ; struct iovec iov ; char control_buf [ CMSG_SPACE ( sizeof ( int ) ) ] ; iov . iov_base = ( void * ) buf ; iov . iov_len = count ; msg . msg_iov = & iov ; msg . msg_iovlen = 1 ; msg . msg_control = control_buf ; msg . msg_controllen = sizeof ( control_buf ) ; msg . msg_name = NULL ; msg . msg_namelen = 0 ; struct cmsghdr * header = CMSG_FIRSTHDR ( & msg ) ; header -> cmsg_level = SOL_SOCKET ; header -> cmsg_type = SCM_RIGHTS ; header -> cmsg_len = CMSG_LEN ( sizeof ( int ) ) ; * ( int * ) CMSG_DATA ( header ) = fd ; ssize_t ret = sendmsg ( socket -> fd , & msg , MSG_DONTWAIT ) ; close ( fd ) ; return ret ; } "," ssize_t ret = TEMP_FAILURE_RETRY ( msg , MSG_DONTWAIT ) ",system@bt/472271b153c5dc53c28beac55480a8d8434b2d5c,CVE-2016-3839,https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c,2016-08-05T20:59Z 1532,CWE-284,"CWE-284 int sock_send_all ( int sock_fd , const uint8_t * buf , int len ) { int s = len ; int ret ; while ( s ) { do ret = send ( sock_fd , buf , s , 0 ) ; while ( ret < 0 && errno == EINTR ) ; if ( ret <= 0 ) { BTIF_TRACE_ERROR ( ""sockfd:%dsenderrno:%d,ret:%d"" , sock_fd , errno , ret ) ; return - 1 ; } buf += ret ; s -= ret ; } return len ; } "," do ret = TEMP_FAILURE_RETRY ( s , 0 ) ",system@bt/472271b153c5dc53c28beac55480a8d8434b2d5c,CVE-2016-3839,https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c,2016-08-05T20:59Z 1533,CWE-264,"CWE-264 static void __xml_acl_post_process ( xmlNode * xml ) { xmlNode * cIter = __xml_first_child ( xml ) ; xml_private_t * p = xml -> _private ; if ( is_set ( p -> flags , xpf_created ) ) { xmlAttr * xIter = NULL ; for ( xIter = crm_first_attr ( xml ) ; xIter != NULL ; xIter = xIter -> next ) { const char * prop_name = ( const char * ) xIter -> name ; if ( strcmp ( prop_name , XML_ATTR_ID ) == 0 ) { continue ; } else if ( __xml_acl_check ( xml , NULL , xpf_acl_write ) ) { crm_trace ( ""Creationof%s=%sisallowed"" , crm_element_name ( xml ) , ID ( xml ) ) ; break ; } else { char * path = xml_get_path ( xml ) ; crm_trace ( ""Cannotaddnewnode%sat%s"" , crm_element_name ( xml ) , path ) ; if ( xml != xmlDocGetRootElement ( xml -> doc ) ) { xmlUnlinkNode ( xml ) ; xmlFreeNode ( xml ) ; } free ( path ) ; return ; } } } while ( cIter != NULL ) { xmlNode * child = cIter ; cIter = __xml_next ( cIter ) ; __xml_acl_post_process ( child ) ; } } "," = NULL ; char * path = xml_get_path ( xml ) ; ) == 0 && strstr ( path , ""/"" XML_CIB_TAG_ACLS ""/"" ) == NULL } else { crm_trace ( ""Cannotaddnewnode%sat%s"" ; } } free ( path ) ; ",ClusterLabs@pacemaker/84ac07c7d02b3badd708b1ef13a2159dede70715,CVE-2015-1867,https://github.com/ClusterLabs/pacemaker/commit/84ac07c,2015-08-12T14:59Z 1534,CWE-119,"CWE-119 static l_int32 pixHtmlViewer ( const char * dirin , const char * dirout , const char * rootname , l_int32 thumbwidth , l_int32 viewwidth ) { char * fname , * fullname , * outname ; char * mainname , * linkname , * linknameshort ; char * viewfile , * thumbfile ; char * shtml , * slink ; char charbuf [ 512 ] ; char htmlstring [ ] = """" ; char framestring [ ] = """" ; l_int32 i , nfiles , index , w , d , nimages , ret ; l_float32 factor ; PIX * pix , * pixthumb , * pixview ; SARRAY * safiles , * sathumbs , * saviews , * sahtml , * salink ; PROCNAME ( ""pixHtmlViewer"" ) ; if ( ! dirin ) return ERROR_INT ( ""dirinnotdefined"" , procName , 1 ) ; if ( ! dirout ) return ERROR_INT ( ""diroutnotdefined"" , procName , 1 ) ; if ( ! rootname ) return ERROR_INT ( ""rootnamenotdefined"" , procName , 1 ) ; if ( thumbwidth == 0 ) thumbwidth = DEFAULT_THUMB_WIDTH ; if ( thumbwidth < MIN_THUMB_WIDTH ) { L_WARNING ( ""thumbwidthtoosmall;usingminvalue\\n"" , procName ) ; thumbwidth = MIN_THUMB_WIDTH ; } if ( viewwidth == 0 ) viewwidth = DEFAULT_VIEW_WIDTH ; if ( viewwidth < MIN_VIEW_WIDTH ) { L_WARNING ( ""viewwidthtoosmall;usingminvalue\\n"" , procName ) ; viewwidth = MIN_VIEW_WIDTH ; } # ifndef _WIN32 snprintf ( charbuf , sizeof ( charbuf ) , ""mkdir-p%s"" , dirout ) ; ret = system ( charbuf ) ; # else ret = CreateDirectory ( dirout , NULL ) ? 0 : 1 ; # endif if ( ret ) { L_ERROR ( ""outputdirectory%snotmade\\n"" , procName , dirout ) ; return 1 ; } if ( ( safiles = getFilenamesInDirectory ( dirin ) ) == NULL ) return ERROR_INT ( ""safilesnotmade"" , procName , 1 ) ; sprintf ( charbuf , ""%s/%s.html"" , dirout , rootname ) ; mainname = stringNew ( charbuf ) ; sprintf ( charbuf , ""%s/%s-links.html"" , dirout , rootname ) ; linkname = stringNew ( charbuf ) ; linknameshort = stringJoin ( rootname , ""-links.html"" ) ; sathumbs = sarrayCreate ( 0 ) ; saviews = sarrayCreate ( 0 ) ; nfiles = sarrayGetCount ( safiles ) ; index = 0 ; for ( i = 0 ; i < nfiles ; i ++ ) { fname = sarrayGetString ( safiles , i , L_NOCOPY ) ; fullname = genPathname ( dirin , fname ) ; fprintf ( stderr , ""name:%s\\n"" , fullname ) ; if ( ( pix = pixRead ( fullname ) ) == NULL ) { fprintf ( stderr , ""file%snotareadableimage\\n"" , fullname ) ; lept_free ( fullname ) ; continue ; } lept_free ( fullname ) ; pixGetDimensions ( pix , & w , NULL , & d ) ; factor = ( l_float32 ) thumbwidth / ( l_float32 ) w ; pixthumb = pixScale ( pix , factor , factor ) ; sprintf ( charbuf , ""%s_thumb_%03d"" , rootname , index ) ; sarrayAddString ( sathumbs , charbuf , L_COPY ) ; outname = genPathname ( dirout , charbuf ) ; WriteFormattedPix ( outname , pixthumb ) ; lept_free ( outname ) ; pixDestroy ( & pixthumb ) ; factor = ( l_float32 ) viewwidth / ( l_float32 ) w ; if ( factor >= 1.0 ) pixview = pixClone ( pix ) ; else pixview = pixScale ( pix , factor , factor ) ; snprintf ( charbuf , sizeof ( charbuf ) , ""%s_view_%03d"" , rootname , index ) ; sarrayAddString ( saviews , charbuf , L_COPY ) ; outname = genPathname ( dirout , charbuf ) ; WriteFormattedPix ( outname , pixview ) ; lept_free ( outname ) ; pixDestroy ( & pixview ) ; pixDestroy ( & pix ) ; index ++ ; } sahtml = sarrayCreate ( 0 ) ; sarrayAddString ( sahtml , htmlstring , L_COPY ) ; sprintf ( charbuf , ""cols=\\""%d,*\\"">"" , thumbwidth + 30 ) ; sarrayAddString ( sahtml , charbuf , L_COPY ) ; sprintf ( charbuf , ""name=\\""thumbs\\""src=\\""%s\\"">"" , linknameshort ) ; sarrayAddString ( sahtml , charbuf , L_COPY ) ; sprintf ( charbuf , ""name=\\""views\\""src=\\""%s\\"">"" , sarrayGetString ( saviews , 0 , L_NOCOPY ) ) ; sarrayAddString ( sahtml , charbuf , L_COPY ) ; sarrayAddString ( sahtml , framestring , L_COPY ) ; shtml = sarrayToString ( sahtml , 1 ) ; l_binaryWrite ( mainname , ""w"" , shtml , strlen ( shtml ) ) ; fprintf ( stderr , ""******************************************\\n"" ""Writinghtmlfile:%s\\n"" ""******************************************\\n"" , mainname ) ; lept_free ( shtml ) ; lept_free ( mainname ) ; nimages = sarrayGetCount ( saviews ) ; fprintf ( stderr , ""num.images=%d\\n"" , nimages ) ; salink = sarrayCreate ( 0 ) ; for ( i = 0 ; i < nimages ; i ++ ) { viewfile = sarrayGetString ( saviews , i , L_NOCOPY ) ; thumbfile = sarrayGetString ( sathumbs , i , L_NOCOPY ) ; sprintf ( charbuf , ""href=\\""%s\\""TARGET=views>src=\\""%s\\"">"" , viewfile , thumbfile ) ; sarrayAddString ( salink , charbuf , L_COPY ) ; } slink = sarrayToString ( salink , 1 ) ; l_binaryWrite ( linkname , ""w"" , slink , strlen ( slink ) ) ; lept_free ( slink ) ; lept_free ( linkname ) ; lept_free ( linknameshort ) ; sarrayDestroy ( & safiles ) ; sarrayDestroy ( & sathumbs ) ; sarrayDestroy ( & saviews ) ; sarrayDestroy ( & sahtml ) ; sarrayDestroy ( & salink ) ; return 0 ; } "," 1 ) ; snprintf ( charbuf , sizeof ( charbuf ) , ""%s/%s.html"" , charbuf ) ; snprintf ( charbuf , sizeof ( charbuf ) , ""%s/%s-links.html"" , factor ) ; snprintf ( charbuf , sizeof ( charbuf ) , ""%s_thumb_%03d"" , ",DanBloomberg@leptonica/c1079bb8e77cdd426759e466729917ca37a3ed9f,CVE-2018-7247,https://github.com/DanBloomberg/leptonica/commit/c1079bb8e77cdd426759e466729917ca37a3ed9f,2018-02-19T18:29Z 1535,CWE-119,"CWE-119 static const SvcInternal * get_const_svc_internal ( const SvcContext * svc_ctx ) { if ( svc_ctx == NULL ) return NULL ; return ( const SvcInternal * ) svc_ctx -> internal ; } "," static const SvcInternal_t * get_const_svc_internal ( return ( const SvcInternal_t * ) svc_ctx ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1536,CWE-264,"CWE-264 static void flush_end_io ( struct request * flush_rq , int error ) { struct request_queue * q = flush_rq -> q ; struct list_head * running ; bool queued = false ; struct request * rq , * n ; unsigned long flags = 0 ; struct blk_flush_queue * fq = blk_get_flush_queue ( q , flush_rq -> mq_ctx ) ; if ( q -> mq_ops ) { spin_lock_irqsave ( & fq -> mq_flush_lock , flags ) ; flush_rq -> tag = - 1 ; } running = & fq -> flush_queue [ fq -> flush_running_idx ] ; BUG_ON ( fq -> flush_pending_idx == fq -> flush_running_idx ) ; fq -> flush_running_idx ^= 1 ; if ( ! q -> mq_ops ) elv_completed_request ( q , flush_rq ) ; list_for_each_entry_safe ( rq , n , running , flush . list ) { unsigned int seq = blk_flush_cur_seq ( rq ) ; BUG_ON ( seq != REQ_FSEQ_PREFLUSH && seq != REQ_FSEQ_POSTFLUSH ) ; queued |= blk_flush_complete_seq ( rq , fq , seq , error ) ; } if ( queued || fq -> flush_queue_delayed ) { WARN_ON ( q -> mq_ops ) ; blk_run_queue_async ( q ) ; } fq -> flush_queue_delayed = 0 ; if ( q -> mq_ops ) spin_unlock_irqrestore ( & fq -> mq_flush_lock , flags ) ; } "," mq_ops ) { struct blk_mq_hw_ctx * hctx ; mq_flush_lock , flags ) ; hctx = q -> mq_ops -> map_queue ( q , flush_rq -> mq_ctx -> cpu ) ; blk_mq_tag_set_rq ( hctx , flush_rq -> tag , fq -> orig_rq ",torvalds@linux/0048b4837affd153897ed1222283492070027aa9,CVE-2015-9016,https://github.com/torvalds/linux/commit/0048b4837affd153897ed1222283492070027aa9,2018-04-05T18:29Z 1537,CWE-787,"CWE-787 static RD_BOOL mcs_parse_domain_params ( STREAM s ) { int length ; ber_parse_header ( s , MCS_TAG_DOMAIN_PARAMS , & length ) ; in_uint8s ( s , length ) ; return s_check ( s ) ; } "," s ) { uint32 length ; struct stream packet = * s ; ber_parse_header ( length ) ; if ( ! s_check_rem ( s , length ) ) { rdp_protocol_error ( ""mcs_parse_domain_params(),consumedomainparamsfromstreamwouldoverrun"" , & packet ) ; } ",rdesktop@rdesktop/4dca546d04321a610c1835010b5dad85163b65e1,CVE-2018-8800,https://github.com/rdesktop/rdesktop/commit/4dca546d04321a610c1835010b5dad85163b65e1,2019-02-05T20:29Z 1538,CWE-704,"CWE-704 static void merge_param ( HashTable * params , zval * zdata , zval * * * current_param , zval * * * current_args TSRMLS_DC ) { zval * * ptr , * * zdata_ptr ; php_http_array_hashkey_t hkey = php_http_array_hashkey_init ( 0 ) ; # if 0 { zval tmp ; INIT_PZVAL_ARRAY ( & tmp , params ) ; fprintf ( stderr , ""params="" ) ; zend_print_zval_r ( & tmp , 1 TSRMLS_CC ) ; fprintf ( stderr , ""\\n"" ) ; } # endif hkey . type = zend_hash_get_current_key_ex ( Z_ARRVAL_P ( zdata ) , & hkey . str , & hkey . len , & hkey . num , hkey . dup , NULL ) ; if ( ( hkey . type == HASH_KEY_IS_STRING && ! zend_hash_exists ( params , hkey . str , hkey . len ) ) || ( hkey . type == HASH_KEY_IS_LONG && ! zend_hash_index_exists ( params , hkey . num ) ) ) { zval * tmp , * arg , * * args ; zend_hash_get_current_data ( Z_ARRVAL_P ( zdata ) , ( void * ) & ptr ) ; Z_ADDREF_PP ( ptr ) ; MAKE_STD_ZVAL ( tmp ) ; array_init ( tmp ) ; add_assoc_zval_ex ( tmp , ZEND_STRS ( ""value"" ) , * ptr ) ; MAKE_STD_ZVAL ( arg ) ; array_init ( arg ) ; zend_hash_update ( Z_ARRVAL_P ( tmp ) , ""arguments"" , sizeof ( ""arguments"" ) , ( void * ) & arg , sizeof ( zval * ) , ( void * ) & args ) ; * current_args = args ; if ( hkey . type == HASH_KEY_IS_STRING ) { zend_hash_update ( params , hkey . str , hkey . len , ( void * ) & tmp , sizeof ( zval * ) , ( void * ) & ptr ) ; } else { zend_hash_index_update ( params , hkey . num , ( void * ) & tmp , sizeof ( zval * ) , ( void * ) & ptr ) ; } } else { if ( hkey . type == HASH_KEY_IS_STRING ) { zend_hash_find ( params , hkey . str , hkey . len , ( void * ) & ptr ) ; } else { zend_hash_index_find ( params , hkey . num , ( void * ) & ptr ) ; } zdata_ptr = & zdata ; if ( Z_TYPE_PP ( ptr ) == IS_ARRAY && SUCCESS == zend_hash_find ( Z_ARRVAL_PP ( ptr ) , ""value"" , sizeof ( ""value"" ) , ( void * ) & ptr ) && SUCCESS == zend_hash_get_current_data ( Z_ARRVAL_PP ( zdata_ptr ) , ( void * ) & zdata_ptr ) ) { zval * * test_ptr ; while ( Z_TYPE_PP ( zdata_ptr ) == IS_ARRAY && SUCCESS == zend_hash_get_current_data ( Z_ARRVAL_PP ( zdata_ptr ) , ( void * ) & test_ptr ) ) { if ( Z_TYPE_PP ( test_ptr ) == IS_ARRAY ) { if ( HASH_KEY_IS_STRING == zend_hash_get_current_key_ex ( Z_ARRVAL_PP ( zdata_ptr ) , & hkey . str , & hkey . len , & hkey . num , hkey . dup , NULL ) ) { if ( SUCCESS == zend_hash_find ( Z_ARRVAL_PP ( ptr ) , hkey . str , hkey . len , ( void * ) & ptr ) ) { zdata_ptr = test_ptr ; } else { Z_ADDREF_PP ( test_ptr ) ; zend_hash_update ( Z_ARRVAL_PP ( ptr ) , hkey . str , hkey . len , ( void * ) test_ptr , sizeof ( zval * ) , ( void * ) & ptr ) ; break ; } } else { if ( SUCCESS == zend_hash_index_find ( Z_ARRVAL_PP ( ptr ) , hkey . num , ( void * ) & ptr ) ) { zdata_ptr = test_ptr ; } else if ( hkey . num ) { Z_ADDREF_PP ( test_ptr ) ; zend_hash_index_update ( Z_ARRVAL_PP ( ptr ) , hkey . num , ( void * ) test_ptr , sizeof ( zval * ) , ( void * ) & ptr ) ; break ; } else { Z_ADDREF_PP ( test_ptr ) ; zend_hash_next_index_insert ( Z_ARRVAL_PP ( ptr ) , ( void * ) test_ptr , sizeof ( zval * ) , ( void * ) & ptr ) ; break ; } } } else { Z_ADDREF_PP ( test_ptr ) ; if ( Z_TYPE_PP ( ptr ) != IS_ARRAY ) { zval_dtor ( * ptr ) ; array_init ( * ptr ) ; } if ( HASH_KEY_IS_STRING == zend_hash_get_current_key_ex ( Z_ARRVAL_PP ( zdata_ptr ) , & hkey . str , & hkey . len , & hkey . num , hkey . dup , NULL ) ) { zend_hash_update ( Z_ARRVAL_PP ( ptr ) , hkey . str , hkey . len , ( void * ) test_ptr , sizeof ( zval * ) , ( void * ) & ptr ) ; } else if ( hkey . num ) { zend_hash_index_update ( Z_ARRVAL_PP ( ptr ) , hkey . num , ( void * ) test_ptr , sizeof ( zval * ) , ( void * ) & ptr ) ; } else { zend_hash_next_index_insert ( Z_ARRVAL_PP ( ptr ) , ( void * ) test_ptr , sizeof ( zval * ) , ( void * ) & ptr ) ; } break ; } } } } while ( Z_TYPE_PP ( ptr ) == IS_ARRAY && SUCCESS == zend_hash_get_current_data ( Z_ARRVAL_PP ( ptr ) , ( void * ) & ptr ) ) ; * current_param = ptr ; } "," ) == IS_ARRAY && Z_TYPE_PP ( ptr ) == IS_ARRAY ",m6w6@ext-http/17137d4ab1ce81a2cee0fae842340a344ef3da83,CVE-2016-7398,https://github.com/m6w6/ext-http/commit/17137d4ab1ce81a2cee0fae842340a344ef3da83,2019-09-06T19:15Z 1539,CWE-119,"CWE-119 int y4m_input_open ( y4m_input * _y4m , FILE * _fin , char * _skip , int _nskip , int only_420 ) { char buffer [ 80 ] ; int ret ; int i ; for ( i = 0 ; i < 79 ; i ++ ) { if ( _nskip > 0 ) { buffer [ i ] = * _skip ++ ; _nskip -- ; } else { if ( ! file_read ( buffer + i , 1 , _fin ) ) return - 1 ; } if ( buffer [ i ] == '\\n' ) break ; } if ( _nskip > 0 ) return - 1 ; if ( i == 79 ) { fprintf ( stderr , ""Errorparsingheader;notaYUV2MPEG2file?\\n"" ) ; return - 1 ; } buffer [ i ] = '\\0' ; if ( memcmp ( buffer , ""YUV4MPEG"" , 8 ) ) { fprintf ( stderr , ""IncompletemagicforYUV4MPEGfile.\\n"" ) ; return - 1 ; } if ( buffer [ 8 ] != '2' ) { fprintf ( stderr , ""IncorrectYUVinputfileversion;YUV4MPEG2required.\\n"" ) ; } ret = y4m_parse_tags ( _y4m , buffer + 5 ) ; if ( ret < 0 ) { fprintf ( stderr , ""ErrorparsingYUV4MPEG2header.\\n"" ) ; return ret ; } if ( _y4m -> interlace == '?' ) { fprintf ( stderr , ""Warning:Inputvideointerlacingformatunknown;"" ""assumingprogressivescan.\\n"" ) ; } else if ( _y4m -> interlace != 'p' ) { fprintf ( stderr , ""Inputvideoisinterlaced;"" ""Onlyprogressivescanhandled.\\n"" ) ; return - 1 ; } _y4m -> vpx_fmt = VPX_IMG_FMT_I420 ; _y4m -> vpx_bps = 12 ; if ( strcmp ( _y4m -> chroma_type , ""420"" ) == 0 || strcmp ( _y4m -> chroma_type , ""420jpeg"" ) == 0 ) { _y4m -> src_c_dec_h = _y4m -> dst_c_dec_h = _y4m -> src_c_dec_v = _y4m -> dst_c_dec_v = 2 ; _y4m -> dst_buf_read_sz = _y4m -> pic_w * _y4m -> pic_h + 2 * ( ( _y4m -> pic_w + 1 ) / 2 ) * ( ( _y4m -> pic_h + 1 ) / 2 ) ; _y4m -> aux_buf_sz = _y4m -> aux_buf_read_sz = 0 ; _y4m -> convert = y4m_convert_null ; } else if ( strcmp ( _y4m -> chroma_type , ""420mpeg2"" ) == 0 ) { _y4m -> src_c_dec_h = _y4m -> dst_c_dec_h = _y4m -> src_c_dec_v = _y4m -> dst_c_dec_v = 2 ; _y4m -> dst_buf_read_sz = _y4m -> pic_w * _y4m -> pic_h ; _y4m -> aux_buf_sz = _y4m -> aux_buf_read_sz = 2 * ( ( _y4m -> pic_w + 1 ) / 2 ) * ( ( _y4m -> pic_h + 1 ) / 2 ) ; _y4m -> convert = y4m_convert_42xmpeg2_42xjpeg ; } else if ( strcmp ( _y4m -> chroma_type , ""420paldv"" ) == 0 ) { _y4m -> src_c_dec_h = _y4m -> dst_c_dec_h = _y4m -> src_c_dec_v = _y4m -> dst_c_dec_v = 2 ; _y4m -> dst_buf_read_sz = _y4m -> pic_w * _y4m -> pic_h ; _y4m -> aux_buf_sz = 3 * ( ( _y4m -> pic_w + 1 ) / 2 ) * ( ( _y4m -> pic_h + 1 ) / 2 ) ; _y4m -> aux_buf_read_sz = 2 * ( ( _y4m -> pic_w + 1 ) / 2 ) * ( ( _y4m -> pic_h + 1 ) / 2 ) ; _y4m -> convert = y4m_convert_42xpaldv_42xjpeg ; } else if ( strcmp ( _y4m -> chroma_type , ""422jpeg"" ) == 0 ) { _y4m -> src_c_dec_h = _y4m -> dst_c_dec_h = 2 ; _y4m -> src_c_dec_v = 1 ; _y4m -> dst_c_dec_v = 2 ; _y4m -> dst_buf_read_sz = _y4m -> pic_w * _y4m -> pic_h ; _y4m -> aux_buf_sz = _y4m -> aux_buf_read_sz = 2 * ( ( _y4m -> pic_w + 1 ) / 2 ) * _y4m -> pic_h ; _y4m -> convert = y4m_convert_422jpeg_420jpeg ; } else if ( strcmp ( _y4m -> chroma_type , ""422"" ) == 0 ) { _y4m -> src_c_dec_h = 2 ; _y4m -> src_c_dec_v = 1 ; if ( only_420 ) { _y4m -> dst_c_dec_h = 2 ; _y4m -> dst_c_dec_v = 2 ; _y4m -> dst_buf_read_sz = _y4m -> pic_w * _y4m -> pic_h ; _y4m -> aux_buf_read_sz = 2 * ( ( _y4m -> pic_w + 1 ) / 2 ) * _y4m -> pic_h ; _y4m -> aux_buf_sz = _y4m -> aux_buf_read_sz + ( ( _y4m -> pic_w + 1 ) / 2 ) * _y4m -> pic_h ; _y4m -> convert = y4m_convert_422_420jpeg ; } else { _y4m -> vpx_fmt = VPX_IMG_FMT_I422 ; _y4m -> vpx_bps = 16 ; _y4m -> dst_c_dec_h = _y4m -> src_c_dec_h ; _y4m -> dst_c_dec_v = _y4m -> src_c_dec_v ; _y4m -> dst_buf_read_sz = _y4m -> pic_w * _y4m -> pic_h + 2 * ( ( _y4m -> pic_w + 1 ) / 2 ) * _y4m -> pic_h ; _y4m -> aux_buf_sz = _y4m -> aux_buf_read_sz = 0 ; _y4m -> convert = y4m_convert_null ; } } else if ( strcmp ( _y4m -> chroma_type , ""411"" ) == 0 ) { _y4m -> src_c_dec_h = 4 ; _y4m -> dst_c_dec_h = 2 ; _y4m -> src_c_dec_v = 1 ; _y4m -> dst_c_dec_v = 2 ; _y4m -> dst_buf_read_sz = _y4m -> pic_w * _y4m -> pic_h ; _y4m -> aux_buf_read_sz = 2 * ( ( _y4m -> pic_w + 3 ) / 4 ) * _y4m -> pic_h ; _y4m -> aux_buf_sz = _y4m -> aux_buf_read_sz + ( ( _y4m -> pic_w + 1 ) / 2 ) * _y4m -> pic_h ; _y4m -> convert = y4m_convert_411_420jpeg ; } else if ( strcmp ( _y4m -> chroma_type , ""444"" ) == 0 ) { _y4m -> src_c_dec_h = 1 ; _y4m -> src_c_dec_v = 1 ; if ( only_420 ) { _y4m -> dst_c_dec_h = 2 ; _y4m -> dst_c_dec_v = 2 ; _y4m -> dst_buf_read_sz = _y4m -> pic_w * _y4m -> pic_h ; _y4m -> aux_buf_read_sz = 2 * _y4m -> pic_w * _y4m -> pic_h ; _y4m -> aux_buf_sz = _y4m -> aux_buf_read_sz + ( ( _y4m -> pic_w + 1 ) / 2 ) * _y4m -> pic_h ; _y4m -> convert = y4m_convert_444_420jpeg ; } else { _y4m -> vpx_fmt = VPX_IMG_FMT_I444 ; _y4m -> vpx_bps = 24 ; _y4m -> dst_c_dec_h = _y4m -> src_c_dec_h ; _y4m -> dst_c_dec_v = _y4m -> src_c_dec_v ; _y4m -> dst_buf_read_sz = 3 * _y4m -> pic_w * _y4m -> pic_h ; _y4m -> aux_buf_sz = _y4m -> aux_buf_read_sz = 0 ; _y4m -> convert = y4m_convert_null ; } } else if ( strcmp ( _y4m -> chroma_type , ""444alpha"" ) == 0 ) { _y4m -> src_c_dec_h = 1 ; _y4m -> src_c_dec_v = 1 ; if ( only_420 ) { _y4m -> dst_c_dec_h = 2 ; _y4m -> dst_c_dec_v = 2 ; _y4m -> dst_buf_read_sz = _y4m -> pic_w * _y4m -> pic_h ; _y4m -> aux_buf_sz = _y4m -> aux_buf_read_sz = 3 * _y4m -> pic_w * _y4m -> pic_h ; _y4m -> convert = y4m_convert_444_420jpeg ; } else { _y4m -> vpx_fmt = VPX_IMG_FMT_444A ; _y4m -> vpx_bps = 32 ; _y4m -> dst_c_dec_h = _y4m -> src_c_dec_h ; _y4m -> dst_c_dec_v = _y4m -> src_c_dec_v ; _y4m -> dst_buf_read_sz = 4 * _y4m -> pic_w * _y4m -> pic_h ; _y4m -> aux_buf_sz = _y4m -> aux_buf_read_sz = 0 ; _y4m -> convert = y4m_convert_null ; } } else if ( strcmp ( _y4m -> chroma_type , ""mono"" ) == 0 ) { _y4m -> src_c_dec_h = _y4m -> src_c_dec_v = 0 ; _y4m -> dst_c_dec_h = _y4m -> dst_c_dec_v = 2 ; _y4m -> dst_buf_read_sz = _y4m -> pic_w * _y4m -> pic_h ; _y4m -> aux_buf_sz = _y4m -> aux_buf_read_sz = 0 ; _y4m -> convert = y4m_convert_mono_420jpeg ; } else { fprintf ( stderr , ""Unknownchromasamplingtype:%s\\n"" , _y4m -> chroma_type ) ; return - 1 ; } _y4m -> dst_buf_sz = _y4m -> pic_w * _y4m -> pic_h + 2 * ( ( _y4m -> pic_w + _y4m -> dst_c_dec_h - 1 ) / _y4m -> dst_c_dec_h ) * ( ( _y4m -> pic_h + _y4m -> dst_c_dec_v - 1 ) / _y4m -> dst_c_dec_v ) ; _y4m -> dst_buf = ( unsigned char * ) malloc ( _y4m -> dst_buf_sz ) ; _y4m -> aux_buf = ( unsigned char * ) malloc ( _y4m -> aux_buf_sz ) ; return 0 ; } "," [ 80 ] = { 0 } ; _y4m -> bps = 12 ; = 12 ; _y4m -> bit_depth = 8 ; -> chroma_type , ""420p10"" ) == 0 ) { _y4m -> src_c_dec_h = 2 ; _y4m -> dst_c_dec_h = 2 ; _y4m -> src_c_dec_v = 2 ; _y4m -> dst_c_dec_v = 2 ; _y4m -> dst_buf_read_sz = 2 * ( _y4m -> pic_w * _y4m -> pic_h + 2 * ( ( _y4m -> pic_w + 1 ) / 2 ) * ( ( _y4m -> pic_h + 1 ) / 2 ) ) ; _y4m -> aux_buf_sz = _y4m -> aux_buf_read_sz = 0 ; _y4m -> convert = y4m_convert_null ; _y4m -> bit_depth = 10 ; _y4m -> bps = 15 ; _y4m -> vpx_fmt = VPX_IMG_FMT_I42016 ; if ( only_420 ) { fprintf ( stderr , ""Unsupportedconversionfrom420p10to420jpeg\\n"" ) ; return - 1 ; } } else if ( strcmp ( _y4m -> chroma_type , ""420p12"" ) == 0 ) { _y4m -> src_c_dec_h = 2 ; _y4m -> dst_c_dec_h = 2 ; _y4m -> src_c_dec_v = 2 ; _y4m -> dst_c_dec_v = 2 ; _y4m -> dst_buf_read_sz = 2 * ( _y4m -> pic_w * _y4m -> pic_h + 2 * ( ( _y4m -> pic_w + 1 ) / 2 ) * ( ( _y4m -> pic_h + 1 ) / 2 ) ) ; _y4m -> aux_buf_sz = _y4m -> aux_buf_read_sz = 0 ; _y4m -> convert = y4m_convert_null ; _y4m -> bit_depth = 12 ; _y4m -> bps = 18 ; _y4m -> vpx_fmt = VPX_IMG_FMT_I42016 ; if ( only_420 ) { fprintf ( stderr , ""Unsupportedconversionfrom420p12to420jpeg\\n"" ) ; return - 1 ; } } else if ( strcmp ( _y4m -> chroma_type , ; _y4m -> bps = 16 ; convert = y4m_convert_null ; } } else if ( strcmp ( _y4m -> chroma_type , ""422p10"" ) == 0 ) { _y4m -> src_c_dec_h = 2 ; _y4m -> src_c_dec_v = 1 ; _y4m -> vpx_fmt = VPX_IMG_FMT_I42216 ; _y4m -> bps = 20 ; _y4m -> bit_depth = 10 ; _y4m -> dst_c_dec_h = _y4m -> src_c_dec_h ; _y4m -> dst_c_dec_v = _y4m -> src_c_dec_v ; _y4m -> dst_buf_read_sz = 2 * ( _y4m -> pic_w * _y4m -> pic_h + 2 * ( ( _y4m -> pic_w + 1 ) / 2 ) * _y4m -> pic_h ) ; _y4m -> aux_buf_sz = _y4m -> aux_buf_read_sz = 0 ; _y4m -> convert = y4m_convert_null ; if ( only_420 ) { fprintf ( stderr , ""Unsupportedconversionfrom422p10to420jpeg\\n"" ) ; return - 1 ; } } else if ( strcmp ( _y4m -> chroma_type , ""422p12"" ) == 0 ) { _y4m -> src_c_dec_h = 2 ; _y4m -> src_c_dec_v = 1 ; _y4m -> vpx_fmt = VPX_IMG_FMT_I42216 ; _y4m -> bps = 24 ; _y4m -> bit_depth = 12 ; _y4m -> dst_c_dec_h = _y4m -> src_c_dec_h ; _y4m -> dst_c_dec_v = _y4m -> src_c_dec_v ; _y4m -> dst_buf_read_sz = 2 * ( _y4m -> pic_w * _y4m -> pic_h + 2 * ( ( _y4m -> pic_w + 1 ) / 2 ) * _y4m -> pic_h ) ; _y4m -> aux_buf_sz = _y4m -> aux_buf_read_sz = 0 ; _y4m -> convert = y4m_convert_null ; if ( only_420 ) { fprintf ( stderr , ""Unsupportedconversionfrom422p12to420jpeg\\n"" ) ; return - 1 ; _y4m -> bps = 24 ; -> chroma_type , ""444p10"" ) == 0 = 1 ; _y4m -> vpx_fmt = VPX_IMG_FMT_I44416 ; _y4m -> bps = 30 ; _y4m -> bit_depth = 10 ; _y4m -> dst_c_dec_h = _y4m -> src_c_dec_h ; _y4m -> dst_c_dec_v = _y4m -> src_c_dec_v ; _y4m -> dst_buf_read_sz = 2 * 3 * _y4m -> pic_w * _y4m -> pic_h ; _y4m -> aux_buf_sz = _y4m -> aux_buf_read_sz = 0 ; _y4m -> convert = y4m_convert_null ; only_420 ) { fprintf ( stderr ( stderr , ""Unsupportedconversionfrom444p10to420jpeg\\n"" ) ; return 1 ; } } else if ( strcmp ( _y4m -> chroma_type , ""444p12"" ) == 0 ) { _y4m -> src_c_dec_h = 1 ; _y4m -> src_c_dec_v = 1 ; _y4m -> vpx_fmt = VPX_IMG_FMT_I44416 ; _y4m -> bps = 36 ; _y4m -> bit_depth = 12 ; _y4m -> dst_c_dec_h = _y4m -> src_c_dec_h ; _y4m -> dst_c_dec_v = _y4m -> src_c_dec_v ; _y4m -> dst_buf_read_sz = 2 * 3 * _y4m -> pic_w * _y4m -> pic_h ; _y4m -> aux_buf_sz = _y4m -> aux_buf_read_sz = 0 ; _y4m -> convert = y4m_convert_null ; if ( only_420 ) { fprintf ( stderr , ""Unsupportedconversionfrom444p12to420jpeg\\n"" ) ; return - 1 ; } } else if ( strcmp ( _y4m -> chroma_type , ""444alpha"" ) == 0 ) { _y4m -> src_c_dec_h = 1 ; _y4m -> src_c_dec_v = 1 ; if ( only_420 ) { _y4m -> dst_c_dec_h = 2 ; _y4m -> dst_c_dec_v = 2 ; _y4m -> dst_buf_read_sz = _y4m -> pic_w * _y4m -> pic_h ; _y4m -> aux_buf_sz = _y4m -> aux_buf_read_sz = 3 * _y4m -> pic_w * _y4m -> pic_h ; _y4m -> convert = y4m_convert_444_420jpeg ; } else { _y4m -> vpx_fmt = VPX_IMG_FMT_444A ; _y4m -> bps = 32 ; _y4m -> dst_c_dec_h = _y4m -> src_c_dec_h ; _y4m -> dst_c_dec_v = _y4m -> src_c_dec_v ; _y4m -> dst_buf_read_sz = 4 * _y4m -> pic_w * _y4m -> pic_h ; _y4m -> aux_buf_sz = _y4m -> aux_buf_read_sz = 0 ; _y4m -> convert = y4m_convert_null ; } } else if ( strcmp ( _y4m -> chroma_type , ""mono"" ) == 0 ) { _y4m -> src_c_dec_h = _y4m -> src_c_dec_v = 0 ; _y4m -> dst_c_dec_h = _y4m -> dst_c_dec_v = 2 ; _y4m -> dst_buf_read_sz = _y4m -> pic_w * _y4m -> pic_h ; _y4m -> aux_buf_sz = _y4m -> aux_buf_read_sz = 0 ; _y4m -> convert = y4m_convert_mono_420jpeg ; } else { fprintf ( stderr , ""Unknownchromasamplingtype:%s\\n"" , _y4m -> chroma_type ) ; return - 1 ; } dst_c_dec_v ) ; if ( _y4m -> bit_depth == 8 ) dst_buf_sz ) ; else _y4m -> dst_buf = ( unsigned ) malloc ( 2 * _y4m -> dst_buf_sz ) ; if ( _y4m -> aux_buf_sz > 0 ) _y4m -> aux_buf = ( unsigned char * ) malloc ( _y4m -> aux_buf_sz ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1540,CWE-120,"CWE-120 boolean proc_wizkit_line ( buf ) char * buf ; { struct obj * otmp = readobjnam ( buf , ( struct obj * ) 0 ) ; if ( otmp ) { if ( otmp != & zeroobj ) wizkit_addinv ( otmp ) ; } else { config_error_add ( ""Badwizkititem:\\""%.60s\\"""" , buf ) ; return FALSE ; } return TRUE ; } "," struct obj * otmp ; if ( strlen ( buf ) >= BUFSZ ) buf [ BUFSZ - 1 ] = '\\0' ; ",NetHack@NetHack/f4a840a48f4bcf11757b3d859e9d53cc9d5ef226,CVE-2019-19905,https://github.com/NetHack/NetHack/commit/f4a840a48f4bcf11757b3d859e9d53cc9d5ef226,2019-12-19T18:15Z 1541,CWE-20,"CWE-20 int read_filesystem_tables_4 ( ) { long long directory_table_end , table_start ; if ( read_xattrs_from_disk ( fd , & sBlk . s , no_xattrs , & table_start ) == 0 ) return FALSE ; if ( read_uids_guids ( & table_start ) == FALSE ) return FALSE ; if ( parse_exports_table ( & table_start ) == FALSE ) return FALSE ; if ( read_fragment_table ( & directory_table_end ) == FALSE ) return FALSE ; if ( read_inode_table ( sBlk . s . inode_table_start , sBlk . s . directory_table_start ) == FALSE ) return FALSE ; if ( read_directory_table ( sBlk . s . directory_table_start , directory_table_end ) == FALSE ) return FALSE ; if ( no_xattrs ) sBlk . s . xattr_id_table_start = SQUASHFS_INVALID_BLK ; return TRUE ; } "," { long long table_start ; if ( sBlk . s . xattr_id_table_start != SQUASHFS_INVALID_BLK ) { if ( sBlk . s . xattr_id_table_start >= sBlk . s . bytes_used ) { ERROR ( ""read_filesystem_tables:xattridtablestarttoolargeinsuperblock\\n"" ) ; goto corrupted ; } if ( read_xattrs_from_disk == 0 ) goto corrupted ; } else table_start = sBlk . s . bytes_used ; if ( sBlk . s . id_table_start >= table_start ) { ERROR ( ""read_filesystem_tables:idtablestarttoolargeinsuperblock\\n"" ) ; goto corrupted ; } if ( sBlk . s . no_ids == 0 ) { ERROR ( ""read_filesystem_tables:Badidcountinsuperblock\\n"" ) ; goto corrupted ; } if ( sBlk . s . no_ids > ( sBlk . s . inodes * 2L ) ) { ERROR ( ""read_filesystem_tables:Badidcountinsuperblock\\n"" ) ; goto corrupted ; } if ( read_id_table ( & table_start == FALSE ) goto corrupted ; if ( sBlk . s . lookup_table_start != SQUASHFS_INVALID_BLK ) { if ( sBlk . s . lookup_table_start >= table_start ) { ERROR ( ""read_filesystem_tables:lookuptablestarttoolargeinsuperblock\\n"" ) ; goto corrupted ; } if ( parse_exports_table == FALSE ) goto corrupted ; } if ( sBlk . s . fragments != 0 ) { if ( sBlk . s . fragment_table_start >= table_start ) { ERROR ( ""read_filesystem_tables:fragmenttablestarttoolargeinsuperblock\\n"" ) ; goto corrupted ; } if ( sBlk . s . fragments > sBlk . s . inodes ) { ERROR ( ""read_filesystem_tables:Badfragmentcountinsuperblock\\n"" ) ; goto corrupted ; } if ( read_fragment_table read_fragment_table ( & table_start ) == FALSE ) goto corrupted ; } else { if ( sBlk . s . fragment_table_start != table_start ) { ERROR ( ""read_filesystem_tables:fragmenttablestartinvalidinsuperblock\\n"" ) ; goto corrupted ; } } if ( sBlk . s . directory_table_start >= table_start ) { ERROR ( ""read_filesystem_tables:directorytablestarttoolargeinsuperblock\\n"" ) ; goto corrupted ; } if ( read_directory_table ( sBlk . s . directory_table_start , table_start ) == FALSE ) goto corrupted ; if ( sBlk . s . inode_table_start >= sBlk . s . directory_table_start ) { ERROR ( ""read_filesystem_tables:inodetablestarttoolargeinsuperblock\\n"" ) ; goto corrupted ; } if ( read_inode_table == FALSE ) goto corrupted ; if ( return TRUE ; corrupted : ERROR ( ""Filesystemcorruptiondetected\\n"" ) ; return FALSE ; ",plougher@squashfs-tools/f95864afe8833fe3ad782d714b41378e860977b1,CVE-2015-4646,https://github.com/plougher/squashfs-tools/commit/f95864afe8833fe3ad782d714b41378e860977b1,2017-04-13T17:59Z 1542,CWE-732,"CWE-732 static struct env * createenv ( const struct rule * rule ) { struct env * env ; u_int i ; env = malloc ( sizeof ( * env ) ) ; if ( ! env ) err ( 1 , NULL ) ; RB_INIT ( & env -> root ) ; env -> count = 0 ; if ( rule -> options & KEEPENV ) { extern char * * environ ; for ( i = 0 ; environ [ i ] != NULL ; i ++ ) { struct envnode * node ; const char * e , * eq ; size_t len ; char keybuf [ 1024 ] ; e = environ [ i ] ; if ( ( eq = strchr ( e , '=' ) ) == NULL || eq == e ) continue ; len = eq - e ; if ( len > sizeof ( keybuf ) - 1 ) continue ; memcpy ( keybuf , e , len ) ; keybuf [ len ] = '\\0' ; node = createnode ( keybuf , eq + 1 ) ; if ( RB_INSERT ( envtree , & env -> root , node ) ) { freenode ( node ) ; } else { env -> count ++ ; } } } return env ; } "," rule * rule , const struct passwd * mypw , const struct passwd * targpw count = 0 ; addnode ( env , ""DOAS_USER"" , mypw -> pw_name ) } } } else { static const char * copyset [ ] = { ""DISPLAY"" , ""TERM"" , NULL } ; addnode ( env , ""HOME"" , targpw -> pw_dir ) ; addnode ( env , ""LOGNAME"" , targpw -> pw_name ) ; addnode ( env , ""PATH"" , getenv ( ""PATH"" ) ) ; addnode ( env , ""SHELL"" , targpw -> pw_shell ) ; addnode ( env , ""USER"" , targpw -> pw_name ) ; fillenv ( env , copyset ) ; } ",Duncaen@OpenDoas/01c658f8c45cb92a343be5f32aa6da70b2032168,CVE-2019-25016,https://github.com/Duncaen/OpenDoas/commit/01c658f8c45cb92a343be5f32aa6da70b2032168,2021-01-28T20:15Z 1543,CWE-189,"CWE-189 static struct sk_buff * udp6_ufo_fragment ( struct sk_buff * skb , netdev_features_t features ) { struct sk_buff * segs = ERR_PTR ( - EINVAL ) ; unsigned int mss ; unsigned int unfrag_ip6hlen , unfrag_len ; struct frag_hdr * fptr ; u8 * packet_start , * prevhdr ; u8 nexthdr ; u8 frag_hdr_sz = sizeof ( struct frag_hdr ) ; int offset ; __wsum csum ; int tnl_hlen ; mss = skb_shinfo ( skb ) -> gso_size ; if ( unlikely ( skb -> len <= mss ) ) goto out ; if ( skb_gso_ok ( skb , features | NETIF_F_GSO_ROBUST ) ) { int type = skb_shinfo ( skb ) -> gso_type ; if ( unlikely ( type & ~ ( SKB_GSO_UDP | SKB_GSO_DODGY | SKB_GSO_UDP_TUNNEL | SKB_GSO_GRE | SKB_GSO_IPIP | SKB_GSO_SIT | SKB_GSO_MPLS ) || ! ( type & ( SKB_GSO_UDP ) ) ) ) goto out ; skb_shinfo ( skb ) -> gso_segs = DIV_ROUND_UP ( skb -> len , mss ) ; segs = NULL ; goto out ; } if ( skb -> encapsulation && skb_shinfo ( skb ) -> gso_type & SKB_GSO_UDP_TUNNEL ) segs = skb_udp_tunnel_segment ( skb , features ) ; else { offset = skb_checksum_start_offset ( skb ) ; csum = skb_checksum ( skb , offset , skb -> len - offset , 0 ) ; offset += skb -> csum_offset ; * ( __sum16 * ) ( skb -> data + offset ) = csum_fold ( csum ) ; skb -> ip_summed = CHECKSUM_NONE ; tnl_hlen = skb_tnl_header_len ( skb ) ; if ( skb_headroom ( skb ) < ( tnl_hlen + frag_hdr_sz ) ) { if ( gso_pskb_expand_head ( skb , tnl_hlen + frag_hdr_sz ) ) goto out ; } unfrag_ip6hlen = ip6_find_1stfragopt ( skb , & prevhdr ) ; nexthdr = * prevhdr ; * prevhdr = NEXTHDR_FRAGMENT ; unfrag_len = ( skb_network_header ( skb ) - skb_mac_header ( skb ) ) + unfrag_ip6hlen + tnl_hlen ; packet_start = ( u8 * ) skb -> head + SKB_GSO_CB ( skb ) -> mac_offset ; memmove ( packet_start - frag_hdr_sz , packet_start , unfrag_len ) ; SKB_GSO_CB ( skb ) -> mac_offset -= frag_hdr_sz ; skb -> mac_header -= frag_hdr_sz ; skb -> network_header -= frag_hdr_sz ; fptr = ( struct frag_hdr * ) ( skb_network_header ( skb ) + unfrag_ip6hlen ) ; fptr -> nexthdr = nexthdr ; fptr -> reserved = 0 ; ipv6_select_ident ( fptr , ( struct rt6_info * ) skb_dst ( skb ) ) ; segs = skb_segment ( skb , features ) ; } out : return segs ; } "," ; if ( skb -> mac_header < ( tnl_hlen ",torvalds@linux/0e033e04c2678dbbe74a46b23fffb7bb918c288e,CVE-2013-4563,https://github.com/torvalds/linux/commit/0e033e04c2678dbbe74a46b23fffb7bb918c288e,2013-11-20T13:19Z 1544,CWE-119,"CWE-119 void vp9_setup_in_frame_q_adj ( VP9_COMP * cpi ) { VP9_COMMON * const cm = & cpi -> common ; struct segmentation * const seg = & cm -> seg ; vp9_clear_system_state ( ) ; if ( cm -> frame_type == KEY_FRAME || cpi -> refresh_alt_ref_frame || ( cpi -> refresh_golden_frame && ! cpi -> rc . is_src_frame_alt_ref ) ) { int segment ; vpx_memset ( cpi -> segmentation_map , 0 , cm -> mi_rows * cm -> mi_cols ) ; vpx_memset ( cpi -> complexity_map , 0 , cm -> mi_rows * cm -> mi_cols ) ; vp9_enable_segmentation ( seg ) ; vp9_clearall_segfeatures ( seg ) ; seg -> abs_delta = SEGMENT_DELTADATA ; vp9_disable_segfeature ( seg , 0 , SEG_LVL_ALT_Q ) ; for ( segment = 1 ; segment < 2 ; segment ++ ) { const int qindex_delta = vp9_compute_qdelta_by_rate ( & cpi -> rc , cm -> frame_type , cm -> base_qindex , in_frame_q_adj_ratio [ segment ] ) ; vp9_enable_segfeature ( seg , segment , SEG_LVL_ALT_Q ) ; vp9_set_segdata ( seg , segment , SEG_LVL_ALT_Q , qindex_delta ) ; } } } "," -> seg ; vpx_clear_system_state ( ) ; int segment ; const int aq_strength = get_aq_c_strength ( cm -> base_qindex , cm -> bit_depth ) ; memset ( cpi -> segmentation_map , DEFAULT_AQ2_SEG , cm -> mi_rows * cm -> mi_cols ) ; vp9_clearall_segfeatures ( seg ) ; if ( cpi -> rc . sb64_target_rate < 256 ) { vp9_disable_segmentation ( seg ) ; return ; } vp9_enable_segmentation ( seg ) ; seg -> abs_delta = SEGMENT_DELTADATA ; vp9_disable_segfeature ( seg , DEFAULT_AQ2_SEG , SEG_LVL_ALT_Q ) ; for ( segment = 0 ; segment < AQ_C_SEGMENTS ; ++ segment ) { int qindex_delta ; if ( segment == DEFAULT_AQ2_SEG ) continue ; qindex_delta = vp9_compute_qdelta_by_rate -> base_qindex , aq_c_q_adj_factor [ aq_strength ] [ segment ] , cm -> bit_depth ) ; if ( ( cm -> base_qindex != 0 ) && ( ( cm -> base_qindex + qindex_delta ) == 0 ) ) { qindex_delta = - cm -> base_qindex + 1 ; } if ( ( cm -> base_qindex + qindex_delta ) > 0 ) { vp9_enable_segfeature ( seg } } } } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1545,CWE-125,"CWE-125 static int init_types ( void ) { static int initialized ; if ( initialized ) return 1 ; if ( add_ast_fields ( ) < 0 ) return 0 ; mod_type = make_type ( ""mod"" , & AST_type , NULL , 0 ) ; if ( ! mod_type ) return 0 ; if ( ! add_attributes ( mod_type , NULL , 0 ) ) return 0 ; Module_type = make_type ( ""Module"" , mod_type , Module_fields , 1 ) ; if ( ! Module_type ) return 0 ; Interactive_type = make_type ( ""Interactive"" , mod_type , Interactive_fields , 1 ) ; if ( ! Interactive_type ) return 0 ; Expression_type = make_type ( ""Expression"" , mod_type , Expression_fields , 1 ) ; if ( ! Expression_type ) return 0 ; Suite_type = make_type ( ""Suite"" , mod_type , Suite_fields , 1 ) ; if ( ! Suite_type ) return 0 ; stmt_type = make_type ( ""stmt"" , & AST_type , NULL , 0 ) ; if ( ! stmt_type ) return 0 ; if ( ! add_attributes ( stmt_type , stmt_attributes , 4 ) ) return 0 ; FunctionDef_type = make_type ( ""FunctionDef"" , stmt_type , FunctionDef_fields , 5 ) ; if ( ! FunctionDef_type ) return 0 ; AsyncFunctionDef_type = make_type ( ""AsyncFunctionDef"" , stmt_type , AsyncFunctionDef_fields , 5 ) ; if ( ! AsyncFunctionDef_type ) return 0 ; ClassDef_type = make_type ( ""ClassDef"" , stmt_type , ClassDef_fields , 5 ) ; if ( ! ClassDef_type ) return 0 ; Return_type = make_type ( ""Return"" , stmt_type , Return_fields , 1 ) ; if ( ! Return_type ) return 0 ; Delete_type = make_type ( ""Delete"" , stmt_type , Delete_fields , 1 ) ; if ( ! Delete_type ) return 0 ; Assign_type = make_type ( ""Assign"" , stmt_type , Assign_fields , 2 ) ; if ( ! Assign_type ) return 0 ; AugAssign_type = make_type ( ""AugAssign"" , stmt_type , AugAssign_fields , 3 ) ; if ( ! AugAssign_type ) return 0 ; AnnAssign_type = make_type ( ""AnnAssign"" , stmt_type , AnnAssign_fields , 4 ) ; if ( ! AnnAssign_type ) return 0 ; For_type = make_type ( ""For"" , stmt_type , For_fields , 4 ) ; if ( ! For_type ) return 0 ; AsyncFor_type = make_type ( ""AsyncFor"" , stmt_type , AsyncFor_fields , 4 ) ; if ( ! AsyncFor_type ) return 0 ; While_type = make_type ( ""While"" , stmt_type , While_fields , 3 ) ; if ( ! While_type ) return 0 ; If_type = make_type ( ""If"" , stmt_type , If_fields , 3 ) ; if ( ! If_type ) return 0 ; With_type = make_type ( ""With"" , stmt_type , With_fields , 2 ) ; if ( ! With_type ) return 0 ; AsyncWith_type = make_type ( ""AsyncWith"" , stmt_type , AsyncWith_fields , 2 ) ; if ( ! AsyncWith_type ) return 0 ; Raise_type = make_type ( ""Raise"" , stmt_type , Raise_fields , 2 ) ; if ( ! Raise_type ) return 0 ; Try_type = make_type ( ""Try"" , stmt_type , Try_fields , 4 ) ; if ( ! Try_type ) return 0 ; Assert_type = make_type ( ""Assert"" , stmt_type , Assert_fields , 2 ) ; if ( ! Assert_type ) return 0 ; Import_type = make_type ( ""Import"" , stmt_type , Import_fields , 1 ) ; if ( ! Import_type ) return 0 ; ImportFrom_type = make_type ( ""ImportFrom"" , stmt_type , ImportFrom_fields , 3 ) ; if ( ! ImportFrom_type ) return 0 ; Global_type = make_type ( ""Global"" , stmt_type , Global_fields , 1 ) ; if ( ! Global_type ) return 0 ; Nonlocal_type = make_type ( ""Nonlocal"" , stmt_type , Nonlocal_fields , 1 ) ; if ( ! Nonlocal_type ) return 0 ; Expr_type = make_type ( ""Expr"" , stmt_type , Expr_fields , 1 ) ; if ( ! Expr_type ) return 0 ; Pass_type = make_type ( ""Pass"" , stmt_type , NULL , 0 ) ; if ( ! Pass_type ) return 0 ; Break_type = make_type ( ""Break"" , stmt_type , NULL , 0 ) ; if ( ! Break_type ) return 0 ; Continue_type = make_type ( ""Continue"" , stmt_type , NULL , 0 ) ; if ( ! Continue_type ) return 0 ; expr_type = make_type ( ""expr"" , & AST_type , NULL , 0 ) ; if ( ! expr_type ) return 0 ; if ( ! add_attributes ( expr_type , expr_attributes , 4 ) ) return 0 ; BoolOp_type = make_type ( ""BoolOp"" , expr_type , BoolOp_fields , 2 ) ; if ( ! BoolOp_type ) return 0 ; NamedExpr_type = make_type ( ""NamedExpr"" , expr_type , NamedExpr_fields , 2 ) ; if ( ! NamedExpr_type ) return 0 ; BinOp_type = make_type ( ""BinOp"" , expr_type , BinOp_fields , 3 ) ; if ( ! BinOp_type ) return 0 ; UnaryOp_type = make_type ( ""UnaryOp"" , expr_type , UnaryOp_fields , 2 ) ; if ( ! UnaryOp_type ) return 0 ; Lambda_type = make_type ( ""Lambda"" , expr_type , Lambda_fields , 2 ) ; if ( ! Lambda_type ) return 0 ; IfExp_type = make_type ( ""IfExp"" , expr_type , IfExp_fields , 3 ) ; if ( ! IfExp_type ) return 0 ; Dict_type = make_type ( ""Dict"" , expr_type , Dict_fields , 2 ) ; if ( ! Dict_type ) return 0 ; Set_type = make_type ( ""Set"" , expr_type , Set_fields , 1 ) ; if ( ! Set_type ) return 0 ; ListComp_type = make_type ( ""ListComp"" , expr_type , ListComp_fields , 2 ) ; if ( ! ListComp_type ) return 0 ; SetComp_type = make_type ( ""SetComp"" , expr_type , SetComp_fields , 2 ) ; if ( ! SetComp_type ) return 0 ; DictComp_type = make_type ( ""DictComp"" , expr_type , DictComp_fields , 3 ) ; if ( ! DictComp_type ) return 0 ; GeneratorExp_type = make_type ( ""GeneratorExp"" , expr_type , GeneratorExp_fields , 2 ) ; if ( ! GeneratorExp_type ) return 0 ; Await_type = make_type ( ""Await"" , expr_type , Await_fields , 1 ) ; if ( ! Await_type ) return 0 ; Yield_type = make_type ( ""Yield"" , expr_type , Yield_fields , 1 ) ; if ( ! Yield_type ) return 0 ; YieldFrom_type = make_type ( ""YieldFrom"" , expr_type , YieldFrom_fields , 1 ) ; if ( ! YieldFrom_type ) return 0 ; Compare_type = make_type ( ""Compare"" , expr_type , Compare_fields , 3 ) ; if ( ! Compare_type ) return 0 ; Call_type = make_type ( ""Call"" , expr_type , Call_fields , 3 ) ; if ( ! Call_type ) return 0 ; FormattedValue_type = make_type ( ""FormattedValue"" , expr_type , FormattedValue_fields , 3 ) ; if ( ! FormattedValue_type ) return 0 ; JoinedStr_type = make_type ( ""JoinedStr"" , expr_type , JoinedStr_fields , 1 ) ; if ( ! JoinedStr_type ) return 0 ; Constant_type = make_type ( ""Constant"" , expr_type , Constant_fields , 1 ) ; if ( ! Constant_type ) return 0 ; Attribute_type = make_type ( ""Attribute"" , expr_type , Attribute_fields , 3 ) ; if ( ! Attribute_type ) return 0 ; Subscript_type = make_type ( ""Subscript"" , expr_type , Subscript_fields , 3 ) ; if ( ! Subscript_type ) return 0 ; Starred_type = make_type ( ""Starred"" , expr_type , Starred_fields , 2 ) ; if ( ! Starred_type ) return 0 ; Name_type = make_type ( ""Name"" , expr_type , Name_fields , 2 ) ; if ( ! Name_type ) return 0 ; List_type = make_type ( ""List"" , expr_type , List_fields , 2 ) ; if ( ! List_type ) return 0 ; Tuple_type = make_type ( ""Tuple"" , expr_type , Tuple_fields , 2 ) ; if ( ! Tuple_type ) return 0 ; expr_context_type = make_type ( ""expr_context"" , & AST_type , NULL , 0 ) ; if ( ! expr_context_type ) return 0 ; if ( ! add_attributes ( expr_context_type , NULL , 0 ) ) return 0 ; Load_type = make_type ( ""Load"" , expr_context_type , NULL , 0 ) ; if ( ! Load_type ) return 0 ; Load_singleton = PyType_GenericNew ( Load_type , NULL , NULL ) ; if ( ! Load_singleton ) return 0 ; Store_type = make_type ( ""Store"" , expr_context_type , NULL , 0 ) ; if ( ! Store_type ) return 0 ; Store_singleton = PyType_GenericNew ( Store_type , NULL , NULL ) ; if ( ! Store_singleton ) return 0 ; Del_type = make_type ( ""Del"" , expr_context_type , NULL , 0 ) ; if ( ! Del_type ) return 0 ; Del_singleton = PyType_GenericNew ( Del_type , NULL , NULL ) ; if ( ! Del_singleton ) return 0 ; AugLoad_type = make_type ( ""AugLoad"" , expr_context_type , NULL , 0 ) ; if ( ! AugLoad_type ) return 0 ; AugLoad_singleton = PyType_GenericNew ( AugLoad_type , NULL , NULL ) ; if ( ! AugLoad_singleton ) return 0 ; AugStore_type = make_type ( ""AugStore"" , expr_context_type , NULL , 0 ) ; if ( ! AugStore_type ) return 0 ; AugStore_singleton = PyType_GenericNew ( AugStore_type , NULL , NULL ) ; if ( ! AugStore_singleton ) return 0 ; Param_type = make_type ( ""Param"" , expr_context_type , NULL , 0 ) ; if ( ! Param_type ) return 0 ; Param_singleton = PyType_GenericNew ( Param_type , NULL , NULL ) ; if ( ! Param_singleton ) return 0 ; NamedStore_type = make_type ( ""NamedStore"" , expr_context_type , NULL , 0 ) ; if ( ! NamedStore_type ) return 0 ; NamedStore_singleton = PyType_GenericNew ( NamedStore_type , NULL , NULL ) ; if ( ! NamedStore_singleton ) return 0 ; slice_type = make_type ( ""slice"" , & AST_type , NULL , 0 ) ; if ( ! slice_type ) return 0 ; if ( ! add_attributes ( slice_type , NULL , 0 ) ) return 0 ; Slice_type = make_type ( ""Slice"" , slice_type , Slice_fields , 3 ) ; if ( ! Slice_type ) return 0 ; ExtSlice_type = make_type ( ""ExtSlice"" , slice_type , ExtSlice_fields , 1 ) ; if ( ! ExtSlice_type ) return 0 ; Index_type = make_type ( ""Index"" , slice_type , Index_fields , 1 ) ; if ( ! Index_type ) return 0 ; boolop_type = make_type ( ""boolop"" , & AST_type , NULL , 0 ) ; if ( ! boolop_type ) return 0 ; if ( ! add_attributes ( boolop_type , NULL , 0 ) ) return 0 ; And_type = make_type ( ""And"" , boolop_type , NULL , 0 ) ; if ( ! And_type ) return 0 ; And_singleton = PyType_GenericNew ( And_type , NULL , NULL ) ; if ( ! And_singleton ) return 0 ; Or_type = make_type ( ""Or"" , boolop_type , NULL , 0 ) ; if ( ! Or_type ) return 0 ; Or_singleton = PyType_GenericNew ( Or_type , NULL , NULL ) ; if ( ! Or_singleton ) return 0 ; operator_type = make_type ( ""operator"" , & AST_type , NULL , 0 ) ; if ( ! operator_type ) return 0 ; if ( ! add_attributes ( operator_type , NULL , 0 ) ) return 0 ; Add_type = make_type ( ""Add"" , operator_type , NULL , 0 ) ; if ( ! Add_type ) return 0 ; Add_singleton = PyType_GenericNew ( Add_type , NULL , NULL ) ; if ( ! Add_singleton ) return 0 ; Sub_type = make_type ( ""Sub"" , operator_type , NULL , 0 ) ; if ( ! Sub_type ) return 0 ; Sub_singleton = PyType_GenericNew ( Sub_type , NULL , NULL ) ; if ( ! Sub_singleton ) return 0 ; Mult_type = make_type ( ""Mult"" , operator_type , NULL , 0 ) ; if ( ! Mult_type ) return 0 ; Mult_singleton = PyType_GenericNew ( Mult_type , NULL , NULL ) ; if ( ! Mult_singleton ) return 0 ; MatMult_type = make_type ( ""MatMult"" , operator_type , NULL , 0 ) ; if ( ! MatMult_type ) return 0 ; MatMult_singleton = PyType_GenericNew ( MatMult_type , NULL , NULL ) ; if ( ! MatMult_singleton ) return 0 ; Div_type = make_type ( ""Div"" , operator_type , NULL , 0 ) ; if ( ! Div_type ) return 0 ; Div_singleton = PyType_GenericNew ( Div_type , NULL , NULL ) ; if ( ! Div_singleton ) return 0 ; Mod_type = make_type ( ""Mod"" , operator_type , NULL , 0 ) ; if ( ! Mod_type ) return 0 ; Mod_singleton = PyType_GenericNew ( Mod_type , NULL , NULL ) ; if ( ! Mod_singleton ) return 0 ; Pow_type = make_type ( ""Pow"" , operator_type , NULL , 0 ) ; if ( ! Pow_type ) return 0 ; Pow_singleton = PyType_GenericNew ( Pow_type , NULL , NULL ) ; if ( ! Pow_singleton ) return 0 ; LShift_type = make_type ( ""LShift"" , operator_type , NULL , 0 ) ; if ( ! LShift_type ) return 0 ; LShift_singleton = PyType_GenericNew ( LShift_type , NULL , NULL ) ; if ( ! LShift_singleton ) return 0 ; RShift_type = make_type ( ""RShift"" , operator_type , NULL , 0 ) ; if ( ! RShift_type ) return 0 ; RShift_singleton = PyType_GenericNew ( RShift_type , NULL , NULL ) ; if ( ! RShift_singleton ) return 0 ; BitOr_type = make_type ( ""BitOr"" , operator_type , NULL , 0 ) ; if ( ! BitOr_type ) return 0 ; BitOr_singleton = PyType_GenericNew ( BitOr_type , NULL , NULL ) ; if ( ! BitOr_singleton ) return 0 ; BitXor_type = make_type ( ""BitXor"" , operator_type , NULL , 0 ) ; if ( ! BitXor_type ) return 0 ; BitXor_singleton = PyType_GenericNew ( BitXor_type , NULL , NULL ) ; if ( ! BitXor_singleton ) return 0 ; BitAnd_type = make_type ( ""BitAnd"" , operator_type , NULL , 0 ) ; if ( ! BitAnd_type ) return 0 ; BitAnd_singleton = PyType_GenericNew ( BitAnd_type , NULL , NULL ) ; if ( ! BitAnd_singleton ) return 0 ; FloorDiv_type = make_type ( ""FloorDiv"" , operator_type , NULL , 0 ) ; if ( ! FloorDiv_type ) return 0 ; FloorDiv_singleton = PyType_GenericNew ( FloorDiv_type , NULL , NULL ) ; if ( ! FloorDiv_singleton ) return 0 ; unaryop_type = make_type ( ""unaryop"" , & AST_type , NULL , 0 ) ; if ( ! unaryop_type ) return 0 ; if ( ! add_attributes ( unaryop_type , NULL , 0 ) ) return 0 ; Invert_type = make_type ( ""Invert"" , unaryop_type , NULL , 0 ) ; if ( ! Invert_type ) return 0 ; Invert_singleton = PyType_GenericNew ( Invert_type , NULL , NULL ) ; if ( ! Invert_singleton ) return 0 ; Not_type = make_type ( ""Not"" , unaryop_type , NULL , 0 ) ; if ( ! Not_type ) return 0 ; Not_singleton = PyType_GenericNew ( Not_type , NULL , NULL ) ; if ( ! Not_singleton ) return 0 ; UAdd_type = make_type ( ""UAdd"" , unaryop_type , NULL , 0 ) ; if ( ! UAdd_type ) return 0 ; UAdd_singleton = PyType_GenericNew ( UAdd_type , NULL , NULL ) ; if ( ! UAdd_singleton ) return 0 ; USub_type = make_type ( ""USub"" , unaryop_type , NULL , 0 ) ; if ( ! USub_type ) return 0 ; USub_singleton = PyType_GenericNew ( USub_type , NULL , NULL ) ; if ( ! USub_singleton ) return 0 ; cmpop_type = make_type ( ""cmpop"" , & AST_type , NULL , 0 ) ; if ( ! cmpop_type ) return 0 ; if ( ! add_attributes ( cmpop_type , NULL , 0 ) ) return 0 ; Eq_type = make_type ( ""Eq"" , cmpop_type , NULL , 0 ) ; if ( ! Eq_type ) return 0 ; Eq_singleton = PyType_GenericNew ( Eq_type , NULL , NULL ) ; if ( ! Eq_singleton ) return 0 ; NotEq_type = make_type ( ""NotEq"" , cmpop_type , NULL , 0 ) ; if ( ! NotEq_type ) return 0 ; NotEq_singleton = PyType_GenericNew ( NotEq_type , NULL , NULL ) ; if ( ! NotEq_singleton ) return 0 ; Lt_type = make_type ( ""Lt"" , cmpop_type , NULL , 0 ) ; if ( ! Lt_type ) return 0 ; Lt_singleton = PyType_GenericNew ( Lt_type , NULL , NULL ) ; if ( ! Lt_singleton ) return 0 ; LtE_type = make_type ( ""LtE"" , cmpop_type , NULL , 0 ) ; if ( ! LtE_type ) return 0 ; LtE_singleton = PyType_GenericNew ( LtE_type , NULL , NULL ) ; if ( ! LtE_singleton ) return 0 ; Gt_type = make_type ( ""Gt"" , cmpop_type , NULL , 0 ) ; if ( ! Gt_type ) return 0 ; Gt_singleton = PyType_GenericNew ( Gt_type , NULL , NULL ) ; if ( ! Gt_singleton ) return 0 ; GtE_type = make_type ( ""GtE"" , cmpop_type , NULL , 0 ) ; if ( ! GtE_type ) return 0 ; GtE_singleton = PyType_GenericNew ( GtE_type , NULL , NULL ) ; if ( ! GtE_singleton ) return 0 ; Is_type = make_type ( ""Is"" , cmpop_type , NULL , 0 ) ; if ( ! Is_type ) return 0 ; Is_singleton = PyType_GenericNew ( Is_type , NULL , NULL ) ; if ( ! Is_singleton ) return 0 ; IsNot_type = make_type ( ""IsNot"" , cmpop_type , NULL , 0 ) ; if ( ! IsNot_type ) return 0 ; IsNot_singleton = PyType_GenericNew ( IsNot_type , NULL , NULL ) ; if ( ! IsNot_singleton ) return 0 ; In_type = make_type ( ""In"" , cmpop_type , NULL , 0 ) ; if ( ! In_type ) return 0 ; In_singleton = PyType_GenericNew ( In_type , NULL , NULL ) ; if ( ! In_singleton ) return 0 ; NotIn_type = make_type ( ""NotIn"" , cmpop_type , NULL , 0 ) ; if ( ! NotIn_type ) return 0 ; NotIn_singleton = PyType_GenericNew ( NotIn_type , NULL , NULL ) ; if ( ! NotIn_singleton ) return 0 ; comprehension_type = make_type ( ""comprehension"" , & AST_type , comprehension_fields , 4 ) ; if ( ! comprehension_type ) return 0 ; if ( ! add_attributes ( comprehension_type , NULL , 0 ) ) return 0 ; excepthandler_type = make_type ( ""excepthandler"" , & AST_type , NULL , 0 ) ; if ( ! excepthandler_type ) return 0 ; if ( ! add_attributes ( excepthandler_type , excepthandler_attributes , 4 ) ) return 0 ; ExceptHandler_type = make_type ( ""ExceptHandler"" , excepthandler_type , ExceptHandler_fields , 3 ) ; if ( ! ExceptHandler_type ) return 0 ; arguments_type = make_type ( ""arguments"" , & AST_type , arguments_fields , 6 ) ; if ( ! arguments_type ) return 0 ; if ( ! add_attributes ( arguments_type , NULL , 0 ) ) return 0 ; arg_type = make_type ( ""arg"" , & AST_type , arg_fields , 2 ) ; if ( ! arg_type ) return 0 ; if ( ! add_attributes ( arg_type , arg_attributes , 4 ) ) return 0 ; keyword_type = make_type ( ""keyword"" , & AST_type , keyword_fields , 2 ) ; if ( ! keyword_type ) return 0 ; if ( ! add_attributes ( keyword_type , NULL , 0 ) ) return 0 ; alias_type = make_type ( ""alias"" , & AST_type , alias_fields , 2 ) ; if ( ! alias_type ) return 0 ; if ( ! add_attributes ( alias_type , NULL , 0 ) ) return 0 ; withitem_type = make_type ( ""withitem"" , & AST_type , withitem_fields , 2 ) ; if ( ! withitem_type ) return 0 ; if ( ! add_attributes ( withitem_type , NULL , 0 ) ) return 0 ; initialized = 1 ; return 1 ; } "," , Module_fields , 2 ) ; if ( ! Module_type ) return 0 ; Interactive_type = make_type ( ""Interactive"" , mod_type , Interactive_fields , if ( ! Interactive_type ) return 0 ; Expression_type = make_type ( ""Expression"" , mod_type , , mod_type , Expression_fields , 1 ) ; if ( ! Expression_type ) return 0 ; FunctionType_type = make_type ( ""FunctionType"" , mod_type , , mod_type , FunctionType_fields , 2 ) ; if ( ! FunctionType_type ) return 0 , FunctionDef_fields , 6 ) ; if ( ! FunctionDef_type ) return 0 ; AsyncFunctionDef_type = make_type ( ""AsyncFunctionDef"" , stmt_type , AsyncFunctionDef_fields , 6 ) ; if ( ! AsyncFunctionDef_type ) return 0 ; ClassDef_type = make_type ( ""ClassDef"" , stmt_type , ClassDef_fields , if ( ! ClassDef_type ) return 0 ; Return_type = make_type ( ""Return"" , stmt_type , , stmt_type , Return_fields , 1 ) ; if ( ! Return_type ) return 0 ; Delete_type = make_type ( ""Delete"" , stmt_type , Delete_fields , 1 ) ; if ( ! Delete_type ) return 0 ; Assign_type = make_type ( ""Assign"" , stmt_type , Assign_fields , 3 ) ; if ( ! Assign_type ) return 0 ; AugAssign_type = make_type ( ""AugAssign"" , stmt_type , AugAssign_fields , 3 ) ; if ( ! AugAssign_type ) return 0 ; AnnAssign_type = make_type ( ""AnnAssign"" , stmt_type , AnnAssign_fields , 4 ) ; if ( ! AnnAssign_type ) return 0 ; For_type = make_type ( ""For"" , stmt_type , For_fields , 5 ) if ( ! For_type ) return 0 ; AsyncFor_type = make_type ( ""AsyncFor"" , stmt_type , , stmt_type , AsyncFor_fields , 5 ) if ( ! AsyncFor_type ) return 0 ; While_type = make_type ( ""While"" , stmt_type , , stmt_type , While_fields , 3 ) ; if ( ! While_type ) return 0 ; If_type = make_type ( ""If"" , stmt_type , , stmt_type , If_fields , 3 ) ; if ( ! If_type ) return 0 ; With_type = make_type ( ""With"" , stmt_type , , stmt_type , With_fields , 3 ) ; if ( ! With_type ) return 0 ; AsyncWith_type = make_type ( ""AsyncWith"" , stmt_type , , stmt_type , AsyncWith_fields , 3 ) ; if , arg_fields , 3 ) ; if return 0 ; type_ignore_type = make_type ( ""type_ignore"" , & AST_type , NULL , 0 ) ; if ( ! type_ignore_type ) return 0 ; if ( ! add_attributes ( type_ignore_type , NULL , 0 ) ) return 0 ; TypeIgnore_type = make_type ( ""TypeIgnore"" , type_ignore_type , TypeIgnore_fields , 1 ) ; if ( ! TypeIgnore_type ) return 0 ; ",python@typed_ast/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,CVE-2019-19275,https://github.com/python/typed_ast/commit/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,2019-11-26T15:15Z 1546,CWE-284,"CWE-284 static void update_logging ( ) { bool should_log = module_started && ( logging_enabled_via_api || stack_config -> get_btsnoop_turned_on ( ) ) ; if ( should_log == is_logging ) return ; is_logging = should_log ; if ( should_log ) { btsnoop_net_open ( ) ; const char * log_path = stack_config -> get_btsnoop_log_path ( ) ; if ( stack_config -> get_btsnoop_should_save_last ( ) ) { char last_log_path [ PATH_MAX ] ; snprintf ( last_log_path , PATH_MAX , ""%s.%llu"" , log_path , btsnoop_timestamp ( ) ) ; if ( ! rename ( log_path , last_log_path ) && errno != ENOENT ) LOG_ERROR ( ""%sunabletorename\'%s\'to\'%s\':%s"" , __func__ , log_path , last_log_path , strerror ( errno ) ) ; } logfile_fd = open ( log_path , O_WRONLY | O_CREAT | O_TRUNC , S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH ) ; if ( logfile_fd == INVALID_FD ) { LOG_ERROR ( ""%sunabletoopen\'%s\':%s"" , __func__ , log_path , strerror ( errno ) ) ; is_logging = false ; return ; } write ( logfile_fd , ""btsnoop\\0\\0\\0\\0\\1\\0\\0\\x3\\xea"" , 16 ) ; } else { if ( logfile_fd != INVALID_FD ) close ( logfile_fd ) ; logfile_fd = INVALID_FD ; btsnoop_net_close ( ) ; } } "," } logfile_fd = TEMP_FAILURE_RETRY ( S_IWGRP | S_IROTH ) return ; } TEMP_FAILURE_RETRY ( ""btsnoop\\0\\0\\0\\0\\1\\0\\0\\x3\\xea"" , 16 ) ",system@bt/472271b153c5dc53c28beac55480a8d8434b2d5c,CVE-2016-3839,https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c,2016-08-05T20:59Z 1547,CWE-787,"CWE-787 static void WritePixel ( struct ngiflib_img * i , struct ngiflib_decode_context * context , u8 v ) { struct ngiflib_gif * p = i -> parent ; if ( v != i -> gce . transparent_color || ! i -> gce . transparent_flag ) { # ifndef NGIFLIB_INDEXED_ONLY if ( p -> mode & NGIFLIB_MODE_INDEXED ) { # endif * context -> frbuff_p . p8 = v ; # ifndef NGIFLIB_INDEXED_ONLY } else * context -> frbuff_p . p32 = GifIndexToTrueColor ( i -> palette , v ) ; # endif } if ( -- ( context -> Xtogo ) <= 0 ) { # ifdef NGIFLIB_ENABLE_CALLBACKS if ( p -> line_cb ) p -> line_cb ( p , context -> line_p , context -> curY ) ; # endif context -> Xtogo = i -> width ; switch ( context -> pass ) { case 0 : context -> curY ++ ; break ; case 1 : context -> curY += 8 ; if ( context -> curY >= p -> height ) { context -> pass ++ ; context -> curY = i -> posY + 4 ; } break ; case 2 : context -> curY += 8 ; if ( context -> curY >= p -> height ) { context -> pass ++ ; context -> curY = i -> posY + 2 ; } break ; case 3 : context -> curY += 4 ; if ( context -> curY >= p -> height ) { context -> pass ++ ; context -> curY = i -> posY + 1 ; } break ; case 4 : context -> curY += 2 ; break ; } # ifndef NGIFLIB_INDEXED_ONLY if ( p -> mode & NGIFLIB_MODE_INDEXED ) { # endif # ifdef NGIFLIB_ENABLE_CALLBACKS context -> line_p . p8 = p -> frbuff . p8 + ( u32 ) context -> curY * p -> width ; context -> frbuff_p . p8 = context -> line_p . p8 + i -> posX ; # else context -> frbuff_p . p8 = p -> frbuff . p8 + ( u32 ) context -> curY * p -> width + i -> posX ; # endif # ifndef NGIFLIB_INDEXED_ONLY } else { # ifdef NGIFLIB_ENABLE_CALLBACKS context -> line_p . p32 = p -> frbuff . p32 + ( u32 ) context -> curY * p -> width ; context -> frbuff_p . p32 = context -> line_p . p32 + i -> posX ; # else context -> frbuff_p . p32 = p -> frbuff . p32 + ( u32 ) context -> curY * p -> width + i -> posX ; # endif } # endif } else { # ifndef NGIFLIB_INDEXED_ONLY if ( p -> mode & NGIFLIB_MODE_INDEXED ) { # endif context -> frbuff_p . p8 ++ ; # ifndef NGIFLIB_INDEXED_ONLY } else { context -> frbuff_p . p32 ++ ; } # endif } } "," += 8 ; break ; case += 8 ; break ; case += 4 ; break ; case ; break ; } while ( context -> pass > 0 && context -> pass < 4 && context -> curY >= p -> height ) { switch ( ++ context -> pass ) { case 2 : context -> curY = i -> posY + 4 ; break ; case 3 : context -> curY = i -> posY + 2 ; break ; case 4 : context -> curY = i -> posY + 1 ; break ; } ",miniupnp@ngiflib/37d939a6f511d16d4c95678025c235fe62e6417a,CVE-2019-16347,https://github.com/miniupnp/ngiflib/commit/37d939a6f511d16d4c95678025c235fe62e6417a,2019-09-16T13:15Z 1548,CWE-119,"CWE-119 static void sum_intra_stats ( VP8_COMP * cpi , MACROBLOCK * x ) { const MACROBLOCKD * xd = & x -> e_mbd ; const MB_PREDICTION_MODE m = xd -> mode_info_context -> mbmi . mode ; const MB_PREDICTION_MODE uvm = xd -> mode_info_context -> mbmi . uv_mode ; # ifdef MODE_STATS const int is_key = cpi -> common . frame_type == KEY_FRAME ; ++ ( is_key ? uv_modes : inter_uv_modes ) [ uvm ] ; if ( m == B_PRED ) { unsigned int * const bct = is_key ? b_modes : inter_b_modes ; int b = 0 ; do { ++ bct [ xd -> block [ b ] . bmi . mode ] ; } while ( ++ b < 16 ) ; } # endif ++ x -> ymode_count [ m ] ; ++ x -> uv_mode_count [ uvm ] ; } "," ; } # else ( void ) cpi ; # ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1549,CWE-476,"CWE-476 smb_sdrc_t smb_com_flush ( smb_request_t * sr ) { smb_ofile_t * file ; smb_llist_t * flist ; int rc ; if ( smb_flush_required == 0 ) { rc = smbsr_encode_empty_result ( sr ) ; return ( ( rc == 0 ) ? SDRC_SUCCESS : SDRC_ERROR ) ; } if ( sr -> smb_fid != 0xffff ) { smbsr_lookup_file ( sr ) ; if ( sr -> fid_ofile == NULL ) { smbsr_error ( sr , NT_STATUS_INVALID_HANDLE , ERRDOS , ERRbadfid ) ; return ( SDRC_ERROR ) ; } smb_flush_file ( sr , sr -> fid_ofile ) ; } else { flist = & sr -> tid_tree -> t_ofile_list ; smb_llist_enter ( flist , RW_READER ) ; file = smb_llist_head ( flist ) ; while ( file ) { mutex_enter ( & file -> f_mutex ) ; smb_flush_file ( sr , file ) ; mutex_exit ( & file -> f_mutex ) ; file = smb_llist_next ( flist , file ) ; } smb_llist_exit ( flist ) ; } rc = smbsr_encode_empty_result ( sr ) ; return ( ( rc == 0 ) ? SDRC_SUCCESS : SDRC_ERROR ) ; } "," ) ; } smb_ofile_flush ( sr , f_mutex ) ; smb_ofile_flush ( sr , ",illumos@illumos-gate/6d1c73b5858fefc6161c7d686345f0dc887ea799,CVE-2016-6561,https://github.com/illumos/illumos-gate/commit/6d1c73b5858fefc6161c7d686345f0dc887ea799,2017-03-31T19:59Z 1550,CWE-119,"CWE-119 int utf8s_to_utf16s ( const u8 * s , int len , wchar_t * pwcs ) { u16 * op ; int size ; unicode_t u ; op = pwcs ; while ( * s && len > 0 ) { if ( * s & 0x80 ) { size = utf8_to_utf32 ( s , len , & u ) ; if ( size < 0 ) return - EINVAL ; if ( u >= PLANE_SIZE ) { u -= PLANE_SIZE ; * op ++ = ( wchar_t ) ( SURROGATE_PAIR | ( ( u >> 10 ) & SURROGATE_BITS ) ) ; * op ++ = ( wchar_t ) ( SURROGATE_PAIR | SURROGATE_LOW | ( u & SURROGATE_BITS ) ) ; } else { * op ++ = ( wchar_t ) u ; } s += size ; len -= size ; } else { * op ++ = * s ++ ; len -- ; } } return op - pwcs ; } "," int len , enum utf16_endian endian , wchar_t * pwcs , int maxlen ; while ( len > 0 len > 0 && maxlen > 0 && * s - EINVAL ; s += size ; len -= size ; PLANE_SIZE ) { if ( maxlen < 2 ) break ; -= PLANE_SIZE ; put_utf16 ( op ++ , SURROGATE_PAIR | ( & SURROGATE_BITS ) , endian ) ; put_utf16 ( op ++ , SURROGATE_PAIR | SURROGATE_LOW & SURROGATE_BITS ) , endian ) ; maxlen -= 2 ; } else } else { put_utf16 ( op ++ , u , endian ) ; maxlen -- ; } } else { } else { put_utf16 ( op ++ , * s ++ , endian ) ; len -- ; maxlen -- ; } ",torvalds@linux/0720a06a7518c9d0c0125bd5d1f3b6264c55c3dd,CVE-2013-1773,https://github.com/torvalds/linux/commit/0720a06a7518c9d0c0125bd5d1f3b6264c55c3dd,2013-02-28T19:55Z 1551,CWE-706,"CWE-706 void sink ( int argc , char * * argv ) { static BUF buffer ; struct stat stb ; enum { YES , NO , DISPLAYED } wrerr ; BUF * bp ; off_t i ; size_t j , count ; int amt , exists , first , ofd ; mode_t mode , omode , mask ; off_t size , statbytes ; unsigned long long ull ; int setimes , targisdir , wrerrno = 0 ; char ch , * cp , * np , * targ , * why , * vect [ 1 ] , buf [ 2048 ] , visbuf [ 2048 ] ; struct timeval tv [ 2 ] ; # define atime tv [ 0 ] # define mtime tv [ 1 ] # define SCREWUP ( str ) { why = str ; goto screwup ; } if ( TYPE_OVERFLOW ( time_t , 0 ) || TYPE_OVERFLOW ( off_t , 0 ) ) SCREWUP ( ""Unexpectedoff_t/time_tsize"" ) ; setimes = targisdir = 0 ; mask = umask ( 0 ) ; if ( ! pflag ) ( void ) umask ( mask ) ; if ( argc != 1 ) { run_err ( ""ambiguoustarget"" ) ; exit ( 1 ) ; } targ = * argv ; if ( targetshouldbedirectory ) verifydir ( targ ) ; ( void ) atomicio ( vwrite , remout , """" , 1 ) ; if ( stat ( targ , & stb ) == 0 && S_ISDIR ( stb . st_mode ) ) targisdir = 1 ; for ( first = 1 ; ; first = 0 ) { cp = buf ; if ( atomicio ( read , remin , cp , 1 ) != 1 ) return ; if ( * cp ++ == '\\n' ) SCREWUP ( ""unexpected"" ) ; do { if ( atomicio ( read , remin , & ch , sizeof ( ch ) ) != sizeof ( ch ) ) SCREWUP ( ""lostconnection"" ) ; * cp ++ = ch ; } while ( cp < & buf [ sizeof ( buf ) - 1 ] && ch != '\\n' ) ; * cp = 0 ; if ( verbose_mode ) fmprintf ( stderr , ""Sink:%s"" , buf ) ; if ( buf [ 0 ] == '\\01' || buf [ 0 ] == '\\02' ) { if ( iamremote == 0 ) { ( void ) snmprintf ( visbuf , sizeof ( visbuf ) , NULL , ""%s"" , buf + 1 ) ; ( void ) atomicio ( vwrite , STDERR_FILENO , visbuf , strlen ( visbuf ) ) ; } if ( buf [ 0 ] == '\\02' ) exit ( 1 ) ; ++ errs ; continue ; } if ( buf [ 0 ] == 'E' ) { ( void ) atomicio ( vwrite , remout , """" , 1 ) ; return ; } if ( ch == '\\n' ) * -- cp = 0 ; cp = buf ; if ( * cp == 'T' ) { setimes ++ ; cp ++ ; if ( ! isdigit ( ( unsigned char ) * cp ) ) SCREWUP ( ""mtime.secnotpresent"" ) ; ull = strtoull ( cp , & cp , 10 ) ; if ( ! cp || * cp ++ != '' ) SCREWUP ( ""mtime.secnotdelimited"" ) ; if ( TYPE_OVERFLOW ( time_t , ull ) ) setimes = 0 ; mtime . tv_sec = ull ; mtime . tv_usec = strtol ( cp , & cp , 10 ) ; if ( ! cp || * cp ++ != '' || mtime . tv_usec < 0 || mtime . tv_usec > 999999 ) SCREWUP ( ""mtime.usecnotdelimited"" ) ; if ( ! isdigit ( ( unsigned char ) * cp ) ) SCREWUP ( ""atime.secnotpresent"" ) ; ull = strtoull ( cp , & cp , 10 ) ; if ( ! cp || * cp ++ != '' ) SCREWUP ( ""atime.secnotdelimited"" ) ; if ( TYPE_OVERFLOW ( time_t , ull ) ) setimes = 0 ; atime . tv_sec = ull ; atime . tv_usec = strtol ( cp , & cp , 10 ) ; if ( ! cp || * cp ++ != '\\0' || atime . tv_usec < 0 || atime . tv_usec > 999999 ) SCREWUP ( ""atime.usecnotdelimited"" ) ; ( void ) atomicio ( vwrite , remout , """" , 1 ) ; continue ; } if ( * cp != 'C' && * cp != 'D' ) { if ( first ) { run_err ( ""%s"" , cp ) ; exit ( 1 ) ; } SCREWUP ( ""expectedcontrolrecord"" ) ; } mode = 0 ; for ( ++ cp ; cp < buf + 5 ; cp ++ ) { if ( * cp < '0' || * cp > '7' ) SCREWUP ( ""badmode"" ) ; mode = ( mode << 3 ) | ( * cp - '0' ) ; } if ( ! pflag ) mode &= ~ mask ; if ( * cp ++ != '' ) SCREWUP ( ""modenotdelimited"" ) ; if ( ! isdigit ( ( unsigned char ) * cp ) ) SCREWUP ( ""sizenotpresent"" ) ; ull = strtoull ( cp , & cp , 10 ) ; if ( ! cp || * cp ++ != '' ) SCREWUP ( ""sizenotdelimited"" ) ; if ( TYPE_OVERFLOW ( off_t , ull ) ) SCREWUP ( ""sizeoutofrange"" ) ; size = ( off_t ) ull ; if ( ( strchr ( cp , '/' ) != NULL ) || ( strcmp ( cp , "".."" ) == 0 ) ) { run_err ( ""error:unexpectedfilename:%s"" , cp ) ; exit ( 1 ) ; } if ( targisdir ) { static char * namebuf ; static size_t cursize ; size_t need ; need = strlen ( targ ) + strlen ( cp ) + 250 ; if ( need > cursize ) { free ( namebuf ) ; namebuf = xmalloc ( need ) ; cursize = need ; } ( void ) snprintf ( namebuf , need , ""%s%s%s"" , targ , strcmp ( targ , ""/"" ) ? ""/"" : """" , cp ) ; np = namebuf ; } else np = targ ; curfile = cp ; exists = stat ( np , & stb ) == 0 ; if ( buf [ 0 ] == 'D' ) { int mod_flag = pflag ; if ( ! iamrecursive ) SCREWUP ( ""receiveddirectorywithout-r"" ) ; if ( exists ) { if ( ! S_ISDIR ( stb . st_mode ) ) { errno = ENOTDIR ; goto bad ; } if ( pflag ) ( void ) chmod ( np , mode ) ; } else { mod_flag = 1 ; if ( mkdir ( np , mode | S_IRWXU ) < 0 ) goto bad ; } vect [ 0 ] = xstrdup ( np ) ; sink ( 1 , vect ) ; if ( setimes ) { setimes = 0 ; if ( utimes ( vect [ 0 ] , tv ) < 0 ) run_err ( ""%s:settimes:%s"" , vect [ 0 ] , strerror ( errno ) ) ; } if ( mod_flag ) ( void ) chmod ( vect [ 0 ] , mode ) ; free ( vect [ 0 ] ) ; continue ; } omode = mode ; mode |= S_IWUSR ; if ( ( ofd = open ( np , O_WRONLY | O_CREAT , mode ) ) < 0 ) { bad : run_err ( ""%s:%s"" , np , strerror ( errno ) ) ; continue ; } ( void ) atomicio ( vwrite , remout , """" , 1 ) ; if ( ( bp = allocbuf ( & buffer , ofd , COPY_BUFLEN ) ) == NULL ) { ( void ) close ( ofd ) ; continue ; } cp = bp -> buf ; wrerr = NO ; statbytes = 0 ; if ( showprogress ) start_progress_meter ( curfile , size , & statbytes ) ; set_nonblock ( remin ) ; for ( count = i = 0 ; i < size ; i += bp -> cnt ) { amt = bp -> cnt ; if ( i + amt > size ) amt = size - i ; count += amt ; do { j = atomicio6 ( read , remin , cp , amt , scpio , & statbytes ) ; if ( j == 0 ) { run_err ( ""%s"" , j != EPIPE ? strerror ( errno ) : ""droppedconnection"" ) ; exit ( 1 ) ; } amt -= j ; cp += j ; } while ( amt > 0 ) ; if ( count == bp -> cnt ) { if ( wrerr == NO ) { if ( atomicio ( vwrite , ofd , bp -> buf , count ) != count ) { wrerr = YES ; wrerrno = errno ; } } count = 0 ; cp = bp -> buf ; } } unset_nonblock ( remin ) ; if ( count != 0 && wrerr == NO && atomicio ( vwrite , ofd , bp -> buf , count ) != count ) { wrerr = YES ; wrerrno = errno ; } if ( wrerr == NO && ( ! exists || S_ISREG ( stb . st_mode ) ) && ftruncate ( ofd , size ) != 0 ) { run_err ( ""%s:truncate:%s"" , np , strerror ( errno ) ) ; wrerr = DISPLAYED ; } if ( pflag ) { if ( exists || omode != mode ) # ifdef HAVE_FCHMOD if ( fchmod ( ofd , omode ) ) { # else if ( chmod ( np , omode ) ) { # endif run_err ( ""%s:setmode:%s"" , np , strerror ( errno ) ) ; wrerr = DISPLAYED ; } } else { if ( ! exists && omode != mode ) # ifdef HAVE_FCHMOD if ( fchmod ( ofd , omode & ~ mask ) ) { # else if ( chmod ( np , omode & ~ mask ) ) { # endif run_err ( ""%s:setmode:%s"" , np , strerror ( errno ) ) ; wrerr = DISPLAYED ; } } if ( close ( ofd ) == - 1 ) { wrerr = YES ; wrerrno = errno ; } ( void ) response ( ) ; if ( showprogress ) stop_progress_meter ( ) ; if ( setimes && wrerr == NO ) { setimes = 0 ; if ( utimes ( np , tv ) < 0 ) { run_err ( ""%s:settimes:%s"" , np , strerror ( errno ) ) ; wrerr = DISPLAYED ; } } switch ( wrerr ) { case YES : run_err ( ""%s:%s"" , np , strerror ( wrerrno ) ) ; break ; case NO : ( void ) atomicio ( vwrite , remout , """" , 1 ) ; break ; case DISPLAYED : break ; } } screwup : run_err ( ""protocolerror:%s"" , why ) ; exit ( 1 ) ; } "," ; if ( * cp == '\\0' || strchr ( cp ) != NULL || strcmp ( cp ( cp , ""."" ) == 0 || strcmp ( cp , ) == 0 ) { run_err ",openssh@openssh-portable/6010c0303a422a9c5fa8860c061bf7105eb7f8b2,CVE-2018-20685,https://github.com/openssh/openssh-portable/commit/6010c0303a422a9c5fa8860c061bf7105eb7f8b2,2019-01-10T21:29Z 1552,CWE-20,"CWE-20 int DoOneObject ( char * cinput ) { int num , i , num1 , num2 ; char * s , * t , * StartClean ; double * argbuf = 0 ; SetDefaults ( ) ; s = cinput ; while ( * s != '[' ) s ++ ; s ++ ; t = s ; while ( * t != ']' ) t ++ ; * t ++ = 0 ; while ( * t == '' || * t == '\\t' || * t == '\\n' ) t ++ ; outpos = outputbuffer ; outpos += sprintf ( outpos , ""\\\\axo@setObject{%s}%%\\n{%s%c}%%\\n{"" , s , t , TERMCHAR ) ; if ( * s == '0' && s [ 1 ] == ']' ) { if ( strcmp ( nameobject , ""AxodrawWantsPDF"" ) == 0 ) { identification = 1 ; outpos += sprintf ( outpos , ""Axohelpversion%d.%d.PDFoutput.}"" , VERSION , SUBVERSION ) ; fprintf ( outfile , ""%s"" , outputbuffer ) ; return ( 0 ) ; } else { fprintf ( stderr , ""%s:Illegalrequestinidentificationstring[0]:%s\\n"" , axohelp , nameobject ) ; if ( argbuf ) free ( argbuf ) ; return ( - 1 ) ; } } StartClean = outpos ; nameobject = t ; while ( * t != '' && * t != '\\t' && * t != '\\n' && * t ) t ++ ; * t ++ = 0 ; while ( * t == '' || * t == '\\t' || * t == '\\n' ) t ++ ; if ( ( strcmp ( nameobject , ""Curve"" ) == 0 ) || ( strcmp ( nameobject , ""Polygon"" ) == 0 ) || ( strcmp ( nameobject , ""FilledPolygon"" ) == 0 ) ) { if ( ( argbuf = ReadArray ( t , & num1 , & num2 ) ) == 0 ) return ( - 1 ) ; if ( num2 - 1 != 0 ) { fprintf ( stderr , ""%s:Command%sshouldhavenoextranumbersin%s.\\n"" , axohelp , nameobject , inname ) ; free ( argbuf ) ; return ( - 1 ) ; } else { axolinewidth = argbuf [ 2 * num1 + num2 - 1 ] ; SetLineWidth ( axolinewidth ) ; if ( strcmp ( nameobject , ""Curve"" ) == 0 ) { Curve ( argbuf , num1 ) ; } else if ( strcmp ( nameobject , ""Polygon"" ) == 0 ) { Polygon ( argbuf , num1 , 0 ) ; } else if ( strcmp ( nameobject , ""FilledPolygon"" ) == 0 ) { Polygon ( argbuf , num1 , 1 ) ; } free ( argbuf ) ; } } else if ( strcmp ( nameobject , ""DashCurve"" ) == 0 ) { if ( ( argbuf = ReadArray ( t , & num1 , & num2 ) ) == 0 ) return ( - 1 ) ; if ( num2 != 2 ) { fprintf ( stderr , ""%s:Command%sdoesnothavetwonumbersafterthecoordinates\\ninfile%s.\\n"" , axohelp , nameobject , inname ) ; free ( argbuf ) ; return ( - 1 ) ; } else { axolinewidth = argbuf [ 2 * num1 + num2 - 1 ] ; SetLineWidth ( axolinewidth ) ; DashCurve ( argbuf , num1 ) ; free ( argbuf ) ; } } else { if ( ( argbuf = ReadTail ( t , & num ) ) == 0 ) return ( - 1 ) ; for ( i = 0 ; i < sizeof ( commands ) / sizeof ( KEYWORD ) ; i ++ ) { if ( strcmp ( nameobject , commands [ i ] . name ) == 0 ) { if ( num == commands [ i ] . numargs + 1 ) { axolinewidth = argbuf [ num - 1 ] ; SetLineWidth ( axolinewidth ) ; ( * ( commands [ i ] . func ) ) ( argbuf ) ; free ( argbuf ) ; break ; } else { fprintf ( stderr , ""%s:Command%sshouldhave%d(+1)argumentsin%s.\\n"" , axohelp , nameobject , commands [ i ] . numargs , inname ) ; free ( argbuf ) ; return ( - 1 ) ; } } } if ( i >= sizeof ( commands ) / sizeof ( KEYWORD ) ) { fprintf ( stderr , ""%s:Command%snotrecognizedinfile%s.\\n"" , axohelp , nameobject , inname ) ; free ( argbuf ) ; return ( - 1 ) ; } } outpos += sprintf ( outpos , ""}\\n"" ) ; CleanupOutput ( StartClean ) ; fprintf ( outfile , ""%s"" , outputbuffer ) ; return ( 0 ) ; } "," num1 , num2 , retcode , * t ; double * argbuf = 0 ; retcode = - 1 t ++ ; fprintf ( outfile , ""\\\\axo@setObject{%s}%%\\n{%s%c}%%\\n{"" , s , t , TERMCHAR ) ; = outputbuffer ; nameobject = t ; while ( * t != '' && * t != '\\t' && * t != '\\n' && * t ) t ++ ; * t ++ = 0 ; while ( * t == '' || * t == '\\t' || * t == '\\n' ) t ++ ; if ( 1 ] == 0 ) { if = 1 ; fprintf ( outfile , ""Axohelpversion%d.%d.PDFoutput."" , VERSION , SUBVERSION ) ; goto SUCCESS ; } else { fprintf ( stderr , ""%s:Illegalrequestinidentificationstring[0]:%s\\n"" nameobject ) ; goto EXIT ; } } if ( ( == 0 ) goto EXIT ; if ( inname ) ; goto EXIT ; } else argbuf ) ; argbuf = 0 ; == 0 ) goto EXIT ; if ( inname ) ; goto EXIT ; } else argbuf ) ; argbuf = 0 ; == 0 ) goto EXIT ; for ( argbuf ) ; argbuf = 0 ; inname ) ; goto EXIT ; } } inname ) ; goto EXIT ; } } SUCCESS : retcode = 0 ; EXIT : if ( argbuf ) { argbuf ) ; } fprintf ( outfile , ""}\\n"" ) ; return ( retcode ) ; } ",TeX-Live@texlive-source/9216833a3888a4105a18e8c349f65b045ddb1079,CVE-2019-18604,https://github.com/TeX-Live/texlive-source/commit/9216833a3888a4105a18e8c349f65b045ddb1079,2019-10-29T19:15Z 1553,CWE-399,"CWE-399 public int magic_getparam ( struct magic_set * ms , int param , void * val ) { switch ( param ) { case MAGIC_PARAM_INDIR_MAX : * ( size_t * ) val = ms -> indir_max ; return 0 ; case MAGIC_PARAM_NAME_MAX : * ( size_t * ) val = ms -> name_max ; return 0 ; case MAGIC_PARAM_ELF_PHNUM_MAX : * ( size_t * ) val = ms -> elf_phnum_max ; return 0 ; case MAGIC_PARAM_ELF_SHNUM_MAX : * ( size_t * ) val = ms -> elf_shnum_max ; return 0 ; default : errno = EINVAL ; return - 1 ; } } "," return 0 ; case MAGIC_PARAM_ELF_NOTES_MAX : * ( size_t * ) val = ms -> elf_notes_max ; return 0 ; ",file@file/ce90e05774dd77d86cfc8dfa6da57b32816841c4,CVE-2014-9620,https://github.com/file/file/commit/ce90e05774dd77d86cfc8dfa6da57b32816841c4,2015-01-21T18:59Z 1554,CWE-326,"CWE-326 void __ip_select_ident ( struct net * net , struct iphdr * iph , int segs ) { static u32 ip_idents_hashrnd __read_mostly ; u32 hash , id ; net_get_random_once ( & ip_idents_hashrnd , sizeof ( ip_idents_hashrnd ) ) ; hash = jhash_3words ( ( __force u32 ) iph -> daddr , ( __force u32 ) iph -> saddr , iph -> protocol ^ net_hash_mix ( net ) , ip_idents_hashrnd ) ; id = ip_idents_reserve ( hash , segs ) ; iph -> id = htons ( id ) ; } "," segs ) { u32 hash , , id ; if ( unlikely ( siphash_key_is_zero ( & net -> ipv4 . ip_id_key ) ) ) get_random_bytes ( & net -> ipv4 . ip_id_key , sizeof ( , sizeof ( net -> ipv4 . ip_id_key ) ) ; ; hash = siphash_3u32 ( ( __force iph -> protocol , & net -> ipv4 . ip_id_key ) ; id ",torvalds@linux/df453700e8d81b1bdafdf684365ee2b9431fb702,CVE-2019-10638,https://github.com/torvalds/linux/commit/df453700e8d81b1bdafdf684365ee2b9431fb702,2019-07-05T23:15Z 1555,CWE-125,"CWE-125 int obj2ast_slice ( PyObject * obj , slice_ty * out , PyArena * arena ) { int isinstance ; PyObject * tmp = NULL ; if ( obj == Py_None ) { * out = NULL ; return 0 ; } isinstance = PyObject_IsInstance ( obj , ( PyObject * ) Slice_type ) ; if ( isinstance == - 1 ) { return 1 ; } if ( isinstance ) { expr_ty lower ; expr_ty upper ; expr_ty step ; if ( exists_not_none ( obj , & PyId_lower ) ) { int res ; tmp = _PyObject_GetAttrId ( obj , & PyId_lower ) ; if ( tmp == NULL ) goto failed ; res = obj2ast_expr ( tmp , & lower , arena ) ; if ( res != 0 ) goto failed ; Py_CLEAR ( tmp ) ; } else { lower = NULL ; } if ( exists_not_none ( obj , & PyId_upper ) ) { int res ; tmp = _PyObject_GetAttrId ( obj , & PyId_upper ) ; if ( tmp == NULL ) goto failed ; res = obj2ast_expr ( tmp , & upper , arena ) ; if ( res != 0 ) goto failed ; Py_CLEAR ( tmp ) ; } else { upper = NULL ; } if ( exists_not_none ( obj , & PyId_step ) ) { int res ; tmp = _PyObject_GetAttrId ( obj , & PyId_step ) ; if ( tmp == NULL ) goto failed ; res = obj2ast_expr ( tmp , & step , arena ) ; if ( res != 0 ) goto failed ; Py_CLEAR ( tmp ) ; } else { step = NULL ; } * out = Slice ( lower , upper , step , arena ) ; if ( * out == NULL ) goto failed ; return 0 ; } isinstance = PyObject_IsInstance ( obj , ( PyObject * ) ExtSlice_type ) ; if ( isinstance == - 1 ) { return 1 ; } if ( isinstance ) { asdl_seq * dims ; if ( _PyObject_HasAttrId ( obj , & PyId_dims ) ) { int res ; Py_ssize_t len ; Py_ssize_t i ; tmp = _PyObject_GetAttrId ( obj , & PyId_dims ) ; if ( tmp == NULL ) goto failed ; if ( ! PyList_Check ( tmp ) ) { PyErr_Format ( PyExc_TypeError , ""ExtSlicefield\\""dims\\""mustbealist,nota%.200s"" , tmp -> ob_type -> tp_name ) ; goto failed ; } len = PyList_GET_SIZE ( tmp ) ; dims = _Ta3_asdl_seq_new ( len , arena ) ; if ( dims == NULL ) goto failed ; for ( i = 0 ; i < len ; i ++ ) { slice_ty value ; res = obj2ast_slice ( PyList_GET_ITEM ( tmp , i ) , & value , arena ) ; if ( res != 0 ) goto failed ; if ( len != PyList_GET_SIZE ( tmp ) ) { PyErr_SetString ( PyExc_RuntimeError , ""ExtSlicefield\\""dims\\""changedsizeduringiteration"" ) ; goto failed ; } asdl_seq_SET ( dims , i , value ) ; } Py_CLEAR ( tmp ) ; } else { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""dims\\""missingfromExtSlice"" ) ; return 1 ; } * out = ExtSlice ( dims , arena ) ; if ( * out == NULL ) goto failed ; return 0 ; } isinstance = PyObject_IsInstance ( obj , ( PyObject * ) Index_type ) ; if ( isinstance == - 1 ) { return 1 ; } if ( isinstance ) { expr_ty value ; if ( _PyObject_HasAttrId ( obj , & PyId_value ) ) { int res ; tmp = _PyObject_GetAttrId ( obj , & PyId_value ) ; if ( tmp == NULL ) goto failed ; res = obj2ast_expr ( tmp , & value , arena ) ; if ( res != 0 ) goto failed ; Py_CLEAR ( tmp ) ; } else { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""value\\""missingfromIndex"" ) ; return 1 ; } * out = Index ( value , arena ) ; if ( * out == NULL ) goto failed ; return 0 ; } PyErr_Format ( PyExc_TypeError , ""expectedsomesortofslice,butgot%R"" , obj ) ; failed : Py_XDECREF ( tmp ) ; return 1 ; } "," ; if ( lookup_attr_id ( obj , , & PyId_lower , & tmp ) < 0 ) { return 1 ; } if ( tmp == NULL || tmp == Py_None ) { Py_CLEAR ( tmp ) ; lower = NULL ; } else { int res int res ; res = obj2ast_expr ) ; } if ( lookup_attr_id ( obj , & PyId_upper , & tmp ) < 0 ) { return 1 ; } if ( tmp == NULL || tmp == Py_None ) { Py_CLEAR ( tmp ) ; upper = NULL ; } else { int res ; res = obj2ast_expr ( tmp , & upper , arena ) ; if ( res != 0 ) goto failed ; Py_CLEAR ( tmp ) ; } if ( lookup_attr_id ( obj , & PyId_step , & tmp ) < 0 ) { return 1 ; } if ( tmp == NULL || tmp == Py_None ) { Py_CLEAR ( tmp ) ; step = NULL ; } else { int res ; res = obj2ast_expr ( tmp , & step , arena ) ; if ( res != 0 ) goto failed ; Py_CLEAR ( tmp ) ; } * out = Slice ( lower , upper , step , arena ) ; if ( * out == NULL ) goto failed ; return 0 ; } isinstance = PyObject_IsInstance ( obj , ( PyObject * ) ExtSlice_type ) ; if ( isinstance == - 1 ) { return 1 ; } if ( isinstance ) { asdl_seq * dims ; if ( lookup_attr_id ( obj , & PyId_dims , & tmp ) < 0 ) { return 1 ; } if ( tmp == NULL ) { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""dims\\""missingfromExtSlice"" ) ; return 1 ; } else { int res ; Py_ssize_t i ; if ( ) { slice_ty val ; res = ) , & val , arena ) , i , val ) ; } ( tmp ) ; } * ; if ( lookup_attr_id ( obj , , & PyId_value , & tmp ) < 0 ) { return 1 ; } if ( tmp == NULL ) { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""value\\""missingfromIndex"" ) ; return 1 ; } else { int res int res ; res = obj2ast_expr ) ; } * out = Index ( value , arena ) ; if ( * out == NULL ) goto failed ; return 0 ; } PyErr_Format ( PyExc_TypeError , ( PyExc_TypeError , ""expectedsomesortofslice,butgot%R"" , obj ",python@typed_ast/156afcb26c198e162504a57caddfe0acd9ed7dce,CVE-2019-19275,https://github.com/python/typed_ast/commit/156afcb26c198e162504a57caddfe0acd9ed7dce,2019-11-26T15:15Z 1556,CWE-119,"CWE-119 static void write_intra_mode ( vp9_writer * w , MB_PREDICTION_MODE mode , const vp9_prob * probs ) { vp9_write_token ( w , vp9_intra_mode_tree , probs , & intra_mode_encodings [ mode ] ) ; } "," void write_intra_mode ( vpx_writer * w , * w , PREDICTION_MODE mode , const mode , const vpx_prob * probs ) ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1557,CWE-000,"CWE-000 static int save_new_data ( struct chfn_control * ctl ) { char * gecos ; int len ; len = xasprintf ( & gecos , ""%s,%s,%s,%s,%s"" , ctl -> newf . full_name , ctl -> newf . office , ctl -> newf . office_phone , ctl -> newf . home_phone , ctl -> newf . other ) ; if ( ! ctl -> newf . other ) { while ( len > 0 && gecos [ len - 1 ] == ',' ) len -- ; gecos [ len ] = 0 ; } # ifdef HAVE_LIBUSER if ( set_value_libuser ( ""chfn"" , ctl -> username , ctl -> pw -> pw_uid , LU_GECOS , gecos ) < 0 ) { # else ctl -> pw -> pw_gecos = gecos ; if ( setpwnam ( ctl -> pw ) < 0 ) { warn ( ""setpwnamfailed"" ) ; # endif printf ( _ ( ""Fingerinformation*NOT*changed.Tryagainlater.\\n"" ) ) ; return - 1 ; } free ( gecos ) ; printf ( _ ( ""Fingerinformationchanged.\\n"" ) ) ; return 0 ; } "," ctl -> pw , "".chfn"" ",karelzak@util-linux/bde91c85bdc77975155058276f99d2e0f5eab5a9,CVE-2015-5224,https://github.com/karelzak/util-linux/commit/bde91c85bdc77975155058276f99d2e0f5eab5a9,2017-08-23T15:29Z 1558,CWE-119,"CWE-119 int ieee80211_radiotap_iterator_init ( struct ieee80211_radiotap_iterator * iterator , struct ieee80211_radiotap_header * radiotap_header , int max_length , const struct ieee80211_radiotap_vendor_namespaces * vns ) { if ( radiotap_header -> it_version ) return - EINVAL ; if ( max_length < get_unaligned_le16 ( & radiotap_header -> it_len ) ) return - EINVAL ; iterator -> _rtheader = radiotap_header ; iterator -> _max_length = get_unaligned_le16 ( & radiotap_header -> it_len ) ; iterator -> _arg_index = 0 ; iterator -> _bitmap_shifter = get_unaligned_le32 ( & radiotap_header -> it_present ) ; iterator -> _arg = ( uint8_t * ) radiotap_header + sizeof ( * radiotap_header ) ; iterator -> _reset_on_ext = 0 ; iterator -> _next_bitmap = & radiotap_header -> it_present ; iterator -> _next_bitmap ++ ; iterator -> _vns = vns ; iterator -> current_namespace = & radiotap_ns ; iterator -> is_radiotap_ns = 1 ; if ( iterator -> _bitmap_shifter & ( 1 << IEEE80211_RADIOTAP_EXT ) ) { while ( get_unaligned_le32 ( iterator -> _arg ) & ( 1 << IEEE80211_RADIOTAP_EXT ) ) { iterator -> _arg += sizeof ( uint32_t ) ; if ( ( unsigned long ) iterator -> _arg - ( unsigned long ) iterator -> _rtheader > ( unsigned long ) iterator -> _max_length ) return - EINVAL ; } iterator -> _arg += sizeof ( uint32_t ) ; } iterator -> this_arg = iterator -> _arg ; return 0 ; } "," { if ( max_length < sizeof ( struct ieee80211_radiotap_header ) ) return - EINVAL ; if ( iterator -> _rtheader + sizeof ( uint32_t ) ",torvalds@linux/f5563318ff1bde15b10e736e97ffce13be08bc1a,CVE-2013-7027,https://github.com/torvalds/linux/commit/f5563318ff1bde15b10e736e97ffce13be08bc1a,2013-12-09T18:55Z 1559,CWE-401,"CWE-401 static int nfp_abm_u32_knode_replace ( struct nfp_abm_link * alink , struct tc_cls_u32_knode * knode , __be16 proto , struct netlink_ext_ack * extack ) { struct nfp_abm_u32_match * match = NULL , * iter ; unsigned int tos_off ; u8 mask , val ; int err ; if ( ! nfp_abm_u32_check_knode ( alink -> abm , knode , proto , extack ) ) goto err_delete ; tos_off = proto == htons ( ETH_P_IP ) ? 16 : 20 ; val = be32_to_cpu ( knode -> sel -> keys [ 0 ] . val ) >> tos_off & 0xff ; mask = be32_to_cpu ( knode -> sel -> keys [ 0 ] . mask ) >> tos_off & 0xff ; list_for_each_entry ( iter , & alink -> dscp_map , list ) { u32 cmask ; if ( iter -> handle == knode -> handle ) { match = iter ; continue ; } cmask = iter -> mask & mask ; if ( ( iter -> val & cmask ) == ( val & cmask ) && iter -> band != knode -> res -> classid ) { NL_SET_ERR_MSG_MOD ( extack , ""conflictwithalreadyoffloadedfilter"" ) ; goto err_delete ; } } if ( ! match ) { match = kzalloc ( sizeof ( * match ) , GFP_KERNEL ) ; if ( ! match ) return - ENOMEM ; list_add ( & match -> list , & alink -> dscp_map ) ; } match -> handle = knode -> handle ; match -> band = knode -> res -> classid ; match -> mask = mask ; match -> val = val ; err = nfp_abm_update_band_map ( alink ) ; if ( err ) goto err_delete ; return 0 ; err_delete : nfp_abm_u32_knode_delete ( alink , knode ) ; return - EOPNOTSUPP ; } "," extack ) ) { err = - EOPNOTSUPP ; goto err_delete ; } ""conflictwithalreadyoffloadedfilter"" ) ; err = - EOPNOTSUPP ; ! match ) { err = - ENOMEM ; - ENOMEM ; goto err_delete ; } ) ; return err ; } ",torvalds@linux/78beef629fd95be4ed853b2d37b832f766bd96ca,CVE-2019-19076,https://github.com/torvalds/linux/commit/78beef629fd95be4ed853b2d37b832f766bd96ca,2019-11-18T06:15Z 1560,CWE-189,"CWE-189 static int copy_verifier_state ( struct bpf_verifier_state * dst_state , const struct bpf_verifier_state * src ) { struct bpf_func_state * dst ; int i , err ; for ( i = src -> curframe + 1 ; i <= dst_state -> curframe ; i ++ ) { free_func_state ( dst_state -> frame [ i ] ) ; dst_state -> frame [ i ] = NULL ; } dst_state -> curframe = src -> curframe ; for ( i = 0 ; i <= src -> curframe ; i ++ ) { dst = dst_state -> frame [ i ] ; if ( ! dst ) { dst = kzalloc ( sizeof ( * dst ) , GFP_KERNEL ) ; if ( ! dst ) return - ENOMEM ; dst_state -> frame [ i ] = dst ; } err = copy_func_state ( dst , src -> frame [ i ] ) ; if ( err ) return err ; } return 0 ; } "," NULL ; } dst_state -> speculative = src -> speculative ; ",torvalds@linux/979d63d50c0c0f7bc537bf821e056cc9fe5abd38,CVE-2019-7308,https://github.com/torvalds/linux/commit/979d63d50c0c0f7bc537bf821e056cc9fe5abd38,2019-02-01T22:29Z 1561,CWE-787,"CWE-787 PHP_FUNCTION ( imagegammacorrect ) { zval * IM ; gdImagePtr im ; int i ; double input , output ; if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) TSRMLS_CC , ""rdd"" , & IM , & input , & output ) == FAILURE ) { return ; } ZEND_FETCH_RESOURCE ( im , gdImagePtr , & IM , - 1 , ""Image"" , le_gd ) ; if ( gdImageTrueColor ( im ) ) { int x , y , c ; for ( y = 0 ; y < gdImageSY ( im ) ; y ++ ) { for ( x = 0 ; x < gdImageSX ( im ) ; x ++ ) { c = gdImageGetPixel ( im , x , y ) ; gdImageSetPixel ( im , x , y , gdTrueColorAlpha ( ( int ) ( ( pow ( ( pow ( ( gdTrueColorGetRed ( c ) / 255.0 ) , input ) ) , 1.0 / output ) * 255 ) + .5 ) , ( int ) ( ( pow ( ( pow ( ( gdTrueColorGetGreen ( c ) / 255.0 ) , input ) ) , 1.0 / output ) * 255 ) + .5 ) , ( int ) ( ( pow ( ( pow ( ( gdTrueColorGetBlue ( c ) / 255.0 ) , input ) ) , 1.0 / output ) * 255 ) + .5 ) , gdTrueColorGetAlpha ( c ) ) ) ; } } RETURN_TRUE ; } for ( i = 0 ; i < gdImageColorsTotal ( im ) ; i ++ ) { im -> red [ i ] = ( int ) ( ( pow ( ( pow ( ( im -> red [ i ] / 255.0 ) , input ) ) , 1.0 / output ) * 255 ) + .5 ) ; im -> green [ i ] = ( int ) ( ( pow ( ( pow ( ( im -> green [ i ] / 255.0 ) , input ) ) , 1.0 / output ) * 255 ) + .5 ) ; im -> blue [ i ] = ( int ) ( ( pow ( ( pow ( ( im -> blue [ i ] / 255.0 ) , input ) ) , 1.0 / output ) * 255 ) + .5 ) ; } RETURN_TRUE ; } "," return ; } if ( input <= 0.0 || output <= 0.0 ) { php_error_docref ( NULL TSRMLS_CC , E_WARNING , ""Gammavaluesshouldbepositive"" ) ; RETURN_FALSE ; } ",php@php-src/1bd103df00f49cf4d4ade2cfe3f456ac058a4eae,CVE-2016-7127,https://github.com/php/php-src/commit/1bd103df00f49cf4d4ade2cfe3f456ac058a4eae?w=1,2016-09-12T01:59Z 1562,CWE-119,"CWE-119 static void setup_pass ( struct stream_state * stream , struct VpxEncoderConfig * global , int pass ) { if ( stream -> config . stats_fn ) { if ( ! stats_open_file ( & stream -> stats , stream -> config . stats_fn , pass ) ) fatal ( ""Failedtoopenstatisticsstore"" ) ; } else { if ( ! stats_open_mem ( & stream -> stats , pass ) ) fatal ( ""Failedtoopenstatisticsstore"" ) ; } stream -> config . cfg . g_pass = global -> passes == 2 ? pass ? VPX_RC_LAST_PASS : VPX_RC_FIRST_PASS : VPX_RC_ONE_PASS ; if ( pass ) stream -> config . cfg . rc_twopass_stats_in = stats_get ( & stream -> stats ) ; stream -> cx_time = 0 ; stream -> nbytes = 0 ; stream -> frames_out = 0 ; } "," ) ; } # if CONFIG_FP_MB_STATS if ( stream -> config . fpmb_stats_fn ) { if ( ! stats_open_file ( & stream -> fpmb_stats , stream -> config . fpmb_stats_fn , pass ) ) fatal ( ""Failedtoopenmbstatisticsstore"" ) ; } else { if ( ! stats_open_mem ( & stream -> fpmb_stats , pass ) ) fatal ( ""Failedtoopenmbstatisticsstore"" ) ; } # endif ( pass ) { stats ) ; # if CONFIG_FP_MB_STATS stream -> config . cfg . rc_firstpass_mb_stats_in = stats_get ( & stream -> fpmb_stats ) ; # endif } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1563,CWE-000,"CWE-000 static void sas_scsi_clear_queue_lu ( struct list_head * error_q , struct scsi_cmnd * my_cmd ) { struct scsi_cmnd * cmd , * n ; list_for_each_entry_safe ( cmd , n , error_q , eh_entry ) { if ( cmd -> device -> sdev_target == my_cmd -> device -> sdev_target && cmd -> device -> lun == my_cmd -> device -> lun ) sas_eh_defer_cmd ( cmd ) ; } } "," -> lun ) sas_eh_finish_cmd ( cmd ) ",torvalds@linux/318aaf34f1179b39fa9c30fa0f3288b645beee39,CVE-2018-10021,https://github.com/torvalds/linux/commit/318aaf34f1179b39fa9c30fa0f3288b645beee39,2018-04-11T17:29Z 1564,CWE-74,"CWE-74 static gboolean export_desktop_file ( const char * app , const char * branch , const char * arch , GKeyFile * metadata , const char * const * previous_ids , int parent_fd , const char * name , struct stat * stat_buf , char * * target , GCancellable * cancellable , GError * * error ) { gboolean ret = FALSE ; glnx_autofd int desktop_fd = - 1 ; g_autofree char * tmpfile_name = g_strdup_printf ( ""export-desktop-XXXXXX"" ) ; g_autoptr ( GOutputStream ) out_stream = NULL ; g_autofree gchar * data = NULL ; gsize data_len ; g_autofree gchar * new_data = NULL ; gsize new_data_len ; g_autoptr ( GKeyFile ) keyfile = NULL ; g_autofree gchar * old_exec = NULL ; gint old_argc ; g_auto ( GStrv ) old_argv = NULL ; g_auto ( GStrv ) groups = NULL ; GString * new_exec = NULL ; g_autofree char * escaped_app = maybe_quote ( app ) ; g_autofree char * escaped_branch = maybe_quote ( branch ) ; g_autofree char * escaped_arch = maybe_quote ( arch ) ; int i ; if ( ! flatpak_openat_noatime ( parent_fd , name , & desktop_fd , cancellable , error ) ) goto out ; if ( ! read_fd ( desktop_fd , stat_buf , & data , & data_len , error ) ) goto out ; keyfile = g_key_file_new ( ) ; if ( ! g_key_file_load_from_data ( keyfile , data , data_len , G_KEY_FILE_KEEP_TRANSLATIONS , error ) ) goto out ; if ( g_str_has_suffix ( name , "".service"" ) ) { g_autofree gchar * dbus_name = NULL ; g_autofree gchar * expected_dbus_name = g_strndup ( name , strlen ( name ) - strlen ( "".service"" ) ) ; dbus_name = g_key_file_get_string ( keyfile , ""D-BUSService"" , ""Name"" , NULL ) ; if ( dbus_name == NULL || strcmp ( dbus_name , expected_dbus_name ) != 0 ) { return flatpak_fail_error ( error , FLATPAK_ERROR_EXPORT_FAILED , _ ( ""D-Busservicefile\'%s\'haswrongname"" ) , name ) ; } } if ( g_str_has_suffix ( name , "".desktop"" ) ) { gsize length ; g_auto ( GStrv ) tags = g_key_file_get_string_list ( metadata , ""Application"" , ""tags"" , & length , NULL ) ; if ( tags != NULL ) { g_key_file_set_string_list ( keyfile , G_KEY_FILE_DESKTOP_GROUP , ""X-Flatpak-Tags"" , ( const char * const * ) tags , length ) ; } g_key_file_set_string ( keyfile , G_KEY_FILE_DESKTOP_GROUP , ""X-Flatpak"" , app ) ; if ( previous_ids != NULL ) { const char * X_FLATPAK_RENAMED_FROM = ""X-Flatpak-RenamedFrom"" ; g_auto ( GStrv ) renamed_from = g_key_file_get_string_list ( keyfile , G_KEY_FILE_DESKTOP_GROUP , X_FLATPAK_RENAMED_FROM , NULL , NULL ) ; g_autoptr ( GPtrArray ) merged = g_ptr_array_new_with_free_func ( g_free ) ; g_autoptr ( GHashTable ) seen = g_hash_table_new ( g_str_hash , g_str_equal ) ; const char * new_suffix ; for ( i = 0 ; renamed_from != NULL && renamed_from [ i ] != NULL ; i ++ ) { if ( ! g_hash_table_contains ( seen , renamed_from [ i ] ) ) { gchar * copy = g_strdup ( renamed_from [ i ] ) ; g_hash_table_insert ( seen , copy , copy ) ; g_ptr_array_add ( merged , g_steal_pointer ( & copy ) ) ; } } g_assert ( g_str_has_prefix ( name , app ) ) ; new_suffix = name + strlen ( app ) ; for ( i = 0 ; previous_ids [ i ] != NULL ; i ++ ) { g_autofree gchar * previous_desktop = g_strconcat ( previous_ids [ i ] , new_suffix , NULL ) ; if ( ! g_hash_table_contains ( seen , previous_desktop ) ) { g_hash_table_insert ( seen , previous_desktop , previous_desktop ) ; g_ptr_array_add ( merged , g_steal_pointer ( & previous_desktop ) ) ; } } if ( merged -> len > 0 ) { g_ptr_array_add ( merged , NULL ) ; g_key_file_set_string_list ( keyfile , G_KEY_FILE_DESKTOP_GROUP , X_FLATPAK_RENAMED_FROM , ( const char * const * ) merged -> pdata , merged -> len - 1 ) ; } } } groups = g_key_file_get_groups ( keyfile , NULL ) ; for ( i = 0 ; groups [ i ] != NULL ; i ++ ) { g_auto ( GStrv ) flatpak_run_opts = g_key_file_get_string_list ( keyfile , groups [ i ] , ""X-Flatpak-RunOptions"" , NULL , NULL ) ; g_autofree char * flatpak_run_args = format_flatpak_run_args_from_run_opts ( flatpak_run_opts ) ; g_key_file_remove_key ( keyfile , groups [ i ] , ""X-Flatpak-RunOptions"" , NULL ) ; g_key_file_remove_key ( keyfile , groups [ i ] , ""TryExec"" , NULL ) ; g_key_file_remove_key ( keyfile , groups [ i ] , ""X-GNOME-Bugzilla-ExtraInfoScript"" , NULL ) ; new_exec = g_string_new ( """" ) ; g_string_append_printf ( new_exec , FLATPAK_BINDIR ""/flatpakrun--branch=%s--arch=%s"" , escaped_branch , escaped_arch ) ; if ( flatpak_run_args != NULL ) g_string_append_printf ( new_exec , ""%s"" , flatpak_run_args ) ; old_exec = g_key_file_get_string ( keyfile , groups [ i ] , ""Exec"" , NULL ) ; if ( old_exec && g_shell_parse_argv ( old_exec , & old_argc , & old_argv , NULL ) && old_argc >= 1 ) { int j ; g_autofree char * command = maybe_quote ( old_argv [ 0 ] ) ; g_string_append_printf ( new_exec , ""--command=%s"" , command ) ; for ( j = 1 ; j < old_argc ; j ++ ) { if ( strcasecmp ( old_argv [ j ] , ""%f"" ) == 0 || strcasecmp ( old_argv [ j ] , ""%u"" ) == 0 ) { g_string_append ( new_exec , ""--file-forwarding"" ) ; break ; } } g_string_append ( new_exec , """" ) ; g_string_append ( new_exec , escaped_app ) ; for ( j = 1 ; j < old_argc ; j ++ ) { g_autofree char * arg = maybe_quote ( old_argv [ j ] ) ; if ( strcasecmp ( arg , ""%f"" ) == 0 ) g_string_append_printf ( new_exec , ""@@%s@@"" , arg ) ; else if ( strcasecmp ( arg , ""%u"" ) == 0 ) g_string_append_printf ( new_exec , ""@@u%s@@"" , arg ) ; else g_string_append_printf ( new_exec , ""%s"" , arg ) ; } } else { g_string_append ( new_exec , """" ) ; g_string_append ( new_exec , escaped_app ) ; } g_key_file_set_string ( keyfile , groups [ i ] , G_KEY_FILE_DESKTOP_KEY_EXEC , new_exec -> str ) ; } new_data = g_key_file_to_data ( keyfile , & new_data_len , error ) ; if ( new_data == NULL ) goto out ; if ( ! flatpak_open_in_tmpdir_at ( parent_fd , 0755 , tmpfile_name , & out_stream , cancellable , error ) ) goto out ; if ( ! g_output_stream_write_all ( out_stream , new_data , new_data_len , NULL , cancellable , error ) ) goto out ; if ( ! g_output_stream_close ( out_stream , cancellable , error ) ) goto out ; if ( target ) * target = g_steal_pointer ( & tmpfile_name ) ; ret = TRUE ; out : if ( new_exec != NULL ) g_string_free ( new_exec , TRUE ) ; return ret ; } "," ) ; else if ( strcmp ( arg , ""@@"" ) == 0 || strcmp ( arg , ""@@u"" ) == 0 ) g_print ( _ ( ""SkippinginvalidExecargument%s\\n"" ) , arg ) ; else ",flatpak@flatpak/8279c5818425b6812523e3805bbe242fb6a5d961,CVE-2021-21381,https://github.com/flatpak/flatpak/commit/8279c5818425b6812523e3805bbe242fb6a5d961,2021-03-11T17:15Z 1565,CWE-119,"CWE-119 static const uint8_t * decode_tiles ( VP9Decoder * pbi , const uint8_t * data , const uint8_t * data_end ) { VP9_COMMON * const cm = & pbi -> common ; const int aligned_cols = mi_cols_aligned_to_sb ( cm -> mi_cols ) ; const int tile_cols = 1 << cm -> log2_tile_cols ; const int tile_rows = 1 << cm -> log2_tile_rows ; TileBuffer tile_buffers [ 4 ] [ 1 << 6 ] ; int tile_row , tile_col ; const uint8_t * end = NULL ; vp9_reader r ; assert ( tile_rows <= 4 ) ; assert ( tile_cols <= ( 1 << 6 ) ) ; vpx_memset ( cm -> above_context , 0 , sizeof ( * cm -> above_context ) * MAX_MB_PLANE * 2 * aligned_cols ) ; vpx_memset ( cm -> above_seg_context , 0 , sizeof ( * cm -> above_seg_context ) * aligned_cols ) ; for ( tile_row = 0 ; tile_row < tile_rows ; ++ tile_row ) { for ( tile_col = 0 ; tile_col < tile_cols ; ++ tile_col ) { const int last_tile = tile_row == tile_rows - 1 && tile_col == tile_cols - 1 ; const size_t size = get_tile ( data_end , last_tile , & cm -> error , & data ) ; TileBuffer * const buf = & tile_buffers [ tile_row ] [ tile_col ] ; buf -> data = data ; buf -> size = size ; data += size ; } } for ( tile_row = 0 ; tile_row < tile_rows ; ++ tile_row ) { for ( tile_col = 0 ; tile_col < tile_cols ; ++ tile_col ) { const int col = pbi -> oxcf . inv_tile_order ? tile_cols - tile_col - 1 : tile_col ; const int last_tile = tile_row == tile_rows - 1 && col == tile_cols - 1 ; const TileBuffer * const buf = & tile_buffers [ tile_row ] [ col ] ; TileInfo tile ; vp9_tile_init ( & tile , cm , tile_row , col ) ; setup_token_decoder ( buf -> data , data_end , buf -> size , & cm -> error , & r ) ; decode_tile ( pbi , & tile , & r ) ; if ( last_tile ) end = vp9_reader_find_end ( & r ) ; } } return end ; } "," pbi -> common ; const VPxWorkerInterface * const winterface = vpx_get_worker_interface ( ) , tile_col ; int mi_row , mi_col ; TileData * tile_data = NULL ; = NULL ; if ( cm -> lf . filter_level && ! cm -> skip_loop_filter && pbi -> lf_worker . data1 == NULL ) { CHECK_MEM_ERROR ( cm , pbi -> lf_worker . data1 , vpx_memalign ( 32 , sizeof ( LFWorkerData ) ) ) ; pbi -> lf_worker . hook = ( VPxWorkerHook ) vp9_loop_filter_worker ; if ( pbi -> max_threads > 1 && ! winterface -> reset ( & pbi -> lf_worker ) ) { vpx_internal_error ( & cm -> error , VPX_CODEC_ERROR , ""Loopfilterthreadcreationfailed"" ) ; } } if ( cm -> lf . filter_level && ! cm -> skip_loop_filter ) { LFWorkerData * const lf_data = ( LFWorkerData * ) pbi -> lf_worker . data1 ; winterface -> sync ( & pbi -> lf_worker ) ; vp9_loop_filter_data_reset ( lf_data , get_frame_new_buffer ( cm ) , cm , pbi -> mb . plane ) ; } assert ( tile_rows ) ) ; memset ( cm -> aligned_cols ) ; memset ( cm -> aligned_cols ) ; get_tile_buffers ( pbi , data , data_end , tile_cols , tile_rows , tile_buffers ) ; if ( pbi -> tile_data == NULL || ( tile_cols * tile_rows ) != pbi -> total_tiles ) { vpx_free ( pbi -> tile_data ) ; CHECK_MEM_ERROR ( cm , pbi -> tile_data , vpx_memalign ( 32 , tile_cols * tile_rows * ( sizeof ( * pbi -> tile_data ) ) ) ) ; pbi -> total_tiles = tile_rows * tile_cols ; } ) { const TileBuffer * const buf = & tile_buffers [ tile_row ] [ tile_col ] ; tile_data = pbi -> tile_data + tile_cols * tile_row + tile_col ; tile_data -> cm = cm ; tile_data -> xd = pbi -> mb ; tile_data -> xd . corrupted = 0 ; tile_data -> xd . counts = cm -> frame_parallel_decoding_mode ? NULL : & cm -> counts ; vp9_zero ( tile_data -> dqcoeff ) ; vp9_tile_init ( & tile_data -> xd . tile , tile_data -> cm , tile_row , tile_col ) ; setup_token_decoder ( buf -> data , data_end , buf -> size , & cm -> error , & tile_data -> bit_reader , pbi -> decrypt_cb , pbi -> decrypt_state ) ; vp9_init_macroblockd ( cm , & tile_data -> xd , tile_data -> dqcoeff ) ; } } for ( tile_row = 0 ; tile_row < tile_rows ; ++ tile_row ) { TileInfo tile ; vp9_tile_set_row ( & tile , cm , tile_row ) ; for ( mi_row = tile . mi_row_start ; mi_row < tile . mi_row_end ; mi_row += MI_BLOCK_SIZE ) { for ( tile_col = 0 ; tile_col < tile_cols ; ++ tile_col ) { const int col = pbi -> inv_tile_order ? tile_cols - tile_col - 1 : tile_col ; tile_data = pbi -> tile_data + tile_cols * tile_row + col ; vp9_tile_set_col ( & tile , tile_data -> cm , col ) ; vp9_zero ( tile_data -> xd . left_context ) ; vp9_zero ( tile_data -> xd . left_seg_context ) ; for ( mi_col = tile . mi_col_start ; mi_col < tile . mi_col_end ; mi_col += MI_BLOCK_SIZE ) { decode_partition ( pbi , & tile_data -> xd , mi_row , mi_col , & tile_data -> bit_reader , BLOCK_64X64 , 4 ) ; } pbi -> mb . corrupted |= tile_data -> xd . corrupted ; if ( pbi -> mb . corrupted ) vpx_internal_error ( & cm -> error , VPX_CODEC_CORRUPT_FRAME , ""Failedtodecodetiledata"" ) ; } if ( cm -> lf . filter_level && ! cm -> skip_loop_filter ) { const int lf_start = mi_row - MI_BLOCK_SIZE ; LFWorkerData * const lf_data = ( LFWorkerData * ) pbi -> lf_worker . data1 ; if ( lf_start < 0 ) continue ; if ( mi_row + MI_BLOCK_SIZE >= cm -> mi_rows ) continue ; winterface -> sync ( & pbi -> lf_worker ) ; lf_data -> start = lf_start ; lf_data -> stop = mi_row ; if ( pbi -> max_threads > 1 ) { winterface -> launch ( & pbi -> lf_worker ) ; } else { winterface -> execute ( & pbi -> lf_worker ) ; } } if ( pbi -> frame_parallel_decode ) vp9_frameworker_broadcast ( pbi -> cur_buf , mi_row << MI_BLOCK_SIZE_LOG2 ) ; } } if ( cm -> lf . filter_level && ! cm -> skip_loop_filter ) { LFWorkerData * const lf_data = ( LFWorkerData * ) pbi -> lf_worker . data1 ; winterface -> sync ( & pbi -> lf_worker ) ; lf_data -> start = lf_data -> stop ; lf_data -> stop = cm -> mi_rows ; winterface -> execute ( & pbi -> lf_worker ) ; } tile_data = pbi -> tile_data + tile_cols * tile_rows - 1 tile_rows - 1 ; if ( pbi -> frame_parallel_decode ) vp9_frameworker_broadcast ( pbi -> cur_buf , INT_MAX ) ; return vpx_reader_find_end ( & tile_data -> bit_reader ) ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1566,CWE-119,"CWE-119 VP9Decoder * vp9_decoder_create ( const VP9D_CONFIG * oxcf ) { VP9Decoder * const pbi = vpx_memalign ( 32 , sizeof ( * pbi ) ) ; VP9_COMMON * const cm = pbi ? & pbi -> common : NULL ; if ( ! cm ) return NULL ; vp9_zero ( * pbi ) ; if ( setjmp ( cm -> error . jmp ) ) { cm -> error . setjmp = 0 ; vp9_decoder_remove ( pbi ) ; return NULL ; } cm -> error . setjmp = 1 ; vp9_initialize_dec ( ) ; vp9_rtcd ( ) ; vpx_memset ( & cm -> ref_frame_map , - 1 , sizeof ( cm -> ref_frame_map ) ) ; cm -> current_video_frame = 0 ; pbi -> oxcf = * oxcf ; pbi -> ready_for_new_data = 1 ; pbi -> decoded_key_frame = 0 ; vp9_init_dequantizer ( cm ) ; vp9_loop_filter_init ( cm ) ; cm -> error . setjmp = 0 ; vp9_worker_init ( & pbi -> lf_worker ) ; return pbi ; } "," * vp9_decoder_create ( BufferPool * const pool ) { VP9Decoder { VP9Decoder * volatile ; VP9_COMMON * volatile = 1 ; CHECK_MEM_ERROR ( cm , cm -> fc , ( FRAME_CONTEXT * ) vpx_calloc ( 1 , sizeof ( * cm -> fc ) ) ) ; CHECK_MEM_ERROR ( cm , cm -> frame_contexts , ( FRAME_CONTEXT * ) vpx_calloc ( FRAME_CONTEXTS , sizeof ( * cm -> frame_contexts ) ) ) ; pbi -> need_resync = 1 ; once ( initialize_dec ) ; memset ( & cm ) ) ; memset ( & cm -> next_ref_frame_map , - 1 , sizeof ( cm -> next_ref_frame_map ) ) ; ; pbi -> ready_for_new_data = 1 ; pbi -> common . buffer_pool = pool ; cm -> bit_depth = VPX_BITS_8 ; cm -> dequant_bit_depth = VPX_BITS_8 ; cm -> alloc_mi = vp9_dec_alloc_mi ; cm -> free_mi = vp9_dec_free_mi ; cm -> setup_mi = vp9_dec_setup_mi ; vp9_loop_filter_init ( cm ) ; cm -> error . setjmp = 0 ; = 0 ; vpx_get_worker_interface ( ) -> init ( & pbi ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1567,CWE-401,"CWE-401 GF_Err dinf_Read ( GF_Box * s , GF_BitStream * bs ) { GF_Err e = gf_isom_box_array_read ( s , bs , dinf_AddBox ) ; if ( e ) { return e ; } if ( ! ( ( GF_DataInformationBox * ) s ) -> dref ) { GF_LOG ( GF_LOG_ERROR , GF_LOG_CONTAINER , ( ""[isofile]Missingdrefboxindinf\\n"" ) ) ; ( ( GF_DataInformationBox * ) s ) -> dref = ( GF_DataReferenceBox * ) gf_isom_box_new ( GF_ISOM_BOX_TYPE_DREF ) ; } return GF_OK ; } "," dref ) { GF_Box * dref ; ( ""[isofile]Missingdrefboxindinf\\n"" ) ) ; dref = gf_isom_box_new ( GF_ISOM_BOX_TYPE_DREF GF_DataReferenceBox * ) dref ; gf_isom_box_add_for_dump_mode ( s , dref ) ; } ",gpac@gpac/d2371b4b204f0a3c0af51ad4e9b491144dd1225c,CVE-2018-21017,https://github.com/gpac/gpac/commit/d2371b4b204f0a3c0af51ad4e9b491144dd1225c,2019-09-16T13:15Z 1568,CWE-835,"CWE-835 static void setup_connection ( GsmXSMPClient * client ) { GIOChannel * channel ; int fd ; g_debug ( ""GsmXSMPClient:Settingupnewconnection"" ) ; fd = IceConnectionNumber ( client -> priv -> ice_connection ) ; fcntl ( fd , F_SETFD , fcntl ( fd , F_GETFD , 0 ) | FD_CLOEXEC ) ; channel = g_io_channel_unix_new ( fd ) ; client -> priv -> watch_id = g_io_add_watch ( channel , G_IO_IN | G_IO_ERR , ( GIOFunc ) client_iochannel_watch , client ) ; g_io_channel_unref ( channel ) ; client -> priv -> protocol_timeout = g_timeout_add_seconds ( 5 , ( GSourceFunc ) _client_protocol_timeout , client ) ; set_description ( client ) ; g_debug ( ""GsmXSMPClient:Newclient\'%s\'"" , client -> priv -> description ) ; } "," channel ) ; set_description ( client ",GNOME@gnome-session/b0dc999e0b45355314616321dbb6cb71e729fc9d,CVE-2017-11171,https://github.com/GNOME/gnome-session/commit/b0dc999e0b45355314616321dbb6cb71e729fc9d,2017-07-11T20:29Z 1569,CWE-399,"CWE-399 struct scm_fp_list * scm_fp_dup ( struct scm_fp_list * fpl ) { struct scm_fp_list * new_fpl ; int i ; if ( ! fpl ) return NULL ; new_fpl = kmemdup ( fpl , offsetof ( struct scm_fp_list , fp [ fpl -> count ] ) , GFP_KERNEL ) ; if ( new_fpl ) { for ( i = 0 ; i < fpl -> count ; i ++ ) get_file ( fpl -> fp [ i ] ) ; new_fpl -> max = new_fpl -> count ; } return new_fpl ; } "," -> count ; new_fpl -> user = get_uid ( fpl -> user ) ; ",torvalds@linux/415e3d3e90ce9e18727e8843ae343eda5a58fad6,CVE-2016-2550,https://github.com/torvalds/linux/commit/415e3d3e90ce9e18727e8843ae343eda5a58fad6,2016-04-27T17:59Z 1570,CWE-362,"CWE-362 void cipso_v4_req_delattr ( struct request_sock * req ) { struct ip_options * opt ; struct inet_request_sock * req_inet ; req_inet = inet_rsk ( req ) ; opt = req_inet -> opt ; if ( opt == NULL || opt -> cipso == 0 ) return ; cipso_v4_delopt ( & req_inet -> opt ) ; } "," ) { struct ip_options_rcu * opt ; || opt -> opt . ",torvalds@linux/f6d8bd051c391c1c0458a30b2a7abcd939329259,CVE-2012-3552,https://github.com/torvalds/linux/commit/f6d8bd051c391c1c0458a30b2a7abcd939329259,2012-10-03T11:02Z 1571,CWE-119,"CWE-119 static void tree2tok ( struct vp9_token * tokens , const vp9_tree_index * tree , int i , int v , int l ) { v += v ; ++ l ; do { const vp9_tree_index j = tree [ i ++ ] ; if ( j <= 0 ) { tokens [ - j ] . value = v ; tokens [ - j ] . len = l ; } else { tree2tok ( tokens , tree , j , v , l ) ; } } while ( ++ v & 1 ) ; } "," tokens , const vpx_tree_index * tree , do { const vpx_tree_index j = tree ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1572,CWE-119,"CWE-119 static vpx_codec_err_t encoder_encode ( vpx_codec_alg_priv_t * ctx , const vpx_image_t * img , vpx_codec_pts_t pts , unsigned long duration , vpx_enc_frame_flags_t flags , unsigned long deadline ) { vpx_codec_err_t res = VPX_CODEC_OK ; if ( img ) res = validate_img ( ctx , img ) ; pick_quickcompress_mode ( ctx , duration , deadline ) ; vpx_codec_pkt_list_init ( & ctx -> pkt_list ) ; if ( ( ( flags & VP8_EFLAG_NO_UPD_GF ) && ( flags & VP8_EFLAG_FORCE_GF ) ) || ( ( flags & VP8_EFLAG_NO_UPD_ARF ) && ( flags & VP8_EFLAG_FORCE_ARF ) ) ) { ctx -> base . err_detail = ""Conflictingflags."" ; return VPX_CODEC_INVALID_PARAM ; } if ( flags & ( VP8_EFLAG_NO_REF_LAST | VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_ARF ) ) { int ref = 7 ; if ( flags & VP8_EFLAG_NO_REF_LAST ) ref ^= VP9_LAST_FLAG ; if ( flags & VP8_EFLAG_NO_REF_GF ) ref ^= VP9_GOLD_FLAG ; if ( flags & VP8_EFLAG_NO_REF_ARF ) ref ^= VP9_ALT_FLAG ; vp9_use_as_reference ( ctx -> cpi , ref ) ; } if ( flags & ( VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF | VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_FORCE_GF | VP8_EFLAG_FORCE_ARF ) ) { int upd = 7 ; if ( flags & VP8_EFLAG_NO_UPD_LAST ) upd ^= VP9_LAST_FLAG ; if ( flags & VP8_EFLAG_NO_UPD_GF ) upd ^= VP9_GOLD_FLAG ; if ( flags & VP8_EFLAG_NO_UPD_ARF ) upd ^= VP9_ALT_FLAG ; vp9_update_reference ( ctx -> cpi , upd ) ; } if ( flags & VP8_EFLAG_NO_UPD_ENTROPY ) { vp9_update_entropy ( ctx -> cpi , 0 ) ; } if ( ctx -> cfg . kf_mode == VPX_KF_AUTO && ctx -> cfg . kf_min_dist == ctx -> cfg . kf_max_dist ) { if ( ++ ctx -> fixed_kf_cntr > ctx -> cfg . kf_min_dist ) { flags |= VPX_EFLAG_FORCE_KF ; ctx -> fixed_kf_cntr = 1 ; } } if ( res == VPX_CODEC_OK && ctx -> cpi != NULL ) { unsigned int lib_flags ; YV12_BUFFER_CONFIG sd ; int64_t dst_time_stamp , dst_end_time_stamp ; size_t size , cx_data_sz ; unsigned char * cx_data ; if ( ctx -> base . init_flags & VPX_CODEC_USE_PSNR ) ( ( VP9_COMP * ) ctx -> cpi ) -> b_calculate_psnr = 1 ; lib_flags = ( flags & VPX_EFLAG_FORCE_KF ) ? FRAMEFLAGS_KEY : 0 ; dst_time_stamp = ( pts * 10000000 * ctx -> cfg . g_timebase . num ) / ctx -> cfg . g_timebase . den ; dst_end_time_stamp = ( pts + duration ) * 10000000 * ctx -> cfg . g_timebase . num / ctx -> cfg . g_timebase . den ; if ( img != NULL ) { res = image2yuvconfig ( img , & sd ) ; if ( vp9_receive_raw_frame ( ctx -> cpi , lib_flags , & sd , dst_time_stamp , dst_end_time_stamp ) ) { VP9_COMP * cpi = ( VP9_COMP * ) ctx -> cpi ; res = update_error_state ( ctx , & cpi -> common . error ) ; } } cx_data = ctx -> cx_data ; cx_data_sz = ctx -> cx_data_sz ; lib_flags = 0 ; if ( ctx -> pending_cx_data ) { memmove ( cx_data , ctx -> pending_cx_data , ctx -> pending_cx_data_sz ) ; ctx -> pending_cx_data = cx_data ; cx_data += ctx -> pending_cx_data_sz ; cx_data_sz -= ctx -> pending_cx_data_sz ; if ( cx_data_sz < ctx -> cx_data_sz / 2 ) { ctx -> base . err_detail = ""Compresseddatabuffertoosmall"" ; return VPX_CODEC_ERROR ; } } while ( cx_data_sz >= ctx -> cx_data_sz / 2 && - 1 != vp9_get_compressed_data ( ctx -> cpi , & lib_flags , & size , cx_data , & dst_time_stamp , & dst_end_time_stamp , ! img ) ) { if ( size ) { vpx_codec_pts_t round , delta ; vpx_codec_cx_pkt_t pkt ; VP9_COMP * const cpi = ( VP9_COMP * ) ctx -> cpi ; if ( cpi -> common . show_frame == 0 ) { if ( ctx -> pending_cx_data == 0 ) ctx -> pending_cx_data = cx_data ; ctx -> pending_cx_data_sz += size ; ctx -> pending_frame_sizes [ ctx -> pending_frame_count ++ ] = size ; ctx -> pending_frame_magnitude |= size ; cx_data += size ; cx_data_sz -= size ; continue ; } round = ( vpx_codec_pts_t ) 1000000 * ctx -> cfg . g_timebase . num / 2 - 1 ; delta = ( dst_end_time_stamp - dst_time_stamp ) ; pkt . kind = VPX_CODEC_CX_FRAME_PKT ; pkt . data . frame . pts = ( dst_time_stamp * ctx -> cfg . g_timebase . den + round ) / ctx -> cfg . g_timebase . num / 10000000 ; pkt . data . frame . duration = ( unsigned long ) ( ( delta * ctx -> cfg . g_timebase . den + round ) / ctx -> cfg . g_timebase . num / 10000000 ) ; pkt . data . frame . flags = lib_flags << 16 ; if ( lib_flags & FRAMEFLAGS_KEY ) pkt . data . frame . flags |= VPX_FRAME_IS_KEY ; if ( cpi -> common . show_frame == 0 ) { pkt . data . frame . flags |= VPX_FRAME_IS_INVISIBLE ; pkt . data . frame . pts = ( ( cpi -> last_time_stamp_seen * ctx -> cfg . g_timebase . den + round ) / ctx -> cfg . g_timebase . num / 10000000 ) + 1 ; pkt . data . frame . duration = 0 ; } if ( cpi -> droppable ) pkt . data . frame . flags |= VPX_FRAME_IS_DROPPABLE ; if ( ctx -> pending_cx_data ) { ctx -> pending_frame_sizes [ ctx -> pending_frame_count ++ ] = size ; ctx -> pending_frame_magnitude |= size ; ctx -> pending_cx_data_sz += size ; size += write_superframe_index ( ctx ) ; pkt . data . frame . buf = ctx -> pending_cx_data ; pkt . data . frame . sz = ctx -> pending_cx_data_sz ; ctx -> pending_cx_data = NULL ; ctx -> pending_cx_data_sz = 0 ; ctx -> pending_frame_count = 0 ; ctx -> pending_frame_magnitude = 0 ; } else { pkt . data . frame . buf = cx_data ; pkt . data . frame . sz = size ; } pkt . data . frame . partition_id = - 1 ; vpx_codec_pkt_list_add ( & ctx -> pkt_list . head , & pkt ) ; cx_data += size ; cx_data_sz -= size ; } } } return res ; } "," = VPX_CODEC_OK ; VP9_COMP * const cpi = ctx -> cpi ; const vpx_rational_t * const timebase = & ctx -> cfg . g_timebase ; size_t data_sz ; if ( img != NULL ) { res = validate_img img ) ; if ( res == VPX_CODEC_OK && cpi != NULL ) { data_sz = ctx -> cfg . g_w * ctx -> cfg . g_h * get_image_bps ( img ) / 8 * ( cpi -> multi_arf_allowed ? 8 : 2 ) ; if ( data_sz < 4096 ) data_sz = 4096 ; if ( ctx -> cx_data == NULL || ctx -> cx_data_sz < data_sz ) { ctx -> cx_data_sz = data_sz ; free ( ctx -> cx_data ) ; ctx -> cx_data = ( unsigned char * ) malloc ( ctx -> cx_data_sz ) ; if ( ctx -> cx_data == NULL ) { return VPX_CODEC_MEM_ERROR ; } } } } VPX_CODEC_INVALID_PARAM ; } vp9_apply_encoding_flags ( cpi , flags ) ; if ( ctx == VPX_CODEC_OK && cpi != NULL unsigned int lib_flags = 0 ; int64_t dst_time_stamp = timebase_units_to_ticks ( timebase , pts ) ; int64_t dst_end_time_stamp = timebase_units_to_ticks ( timebase , pts + duration ) ; size_t size & VPX_CODEC_USE_PSNR ) cpi -> b_calculate_psnr = b_calculate_psnr = 1 ; if ( ( vp9_receive_raw_frame ( cpi , flags | ctx -> next_frame_flags , & sd ) ) { res = update_error_state ) ; } ctx -> next_frame_flags = 0 ; ctx -> cx_data_sz ; if ( != vp9_get_compressed_data ( cpi , & size ) { vpx_codec_cx_pkt_t pkt ; vpx_codec_cx_pkt_t pkt ; # if CONFIG_SPATIAL_SVC if ( cpi -> use_svc ) cpi -> svc . layer_context [ cpi -> svc . spatial_layer_id * cpi -> svc . number_temporal_layers ] . layer_size += size ; # endif if ( ! cpi -> common common . show_frame || ( cpi -> use_svc && cpi -> svc . spatial_layer_id < cpi -> svc . number_spatial_layers - 1 ) ) { if -= size ; if ( ctx -> output_cx_pkt_cb . output_cx_pkt ) { pkt . kind = VPX_CODEC_CX_FRAME_PKT ; pkt . data . frame . pts = ticks_to_timebase_units ( timebase , dst_time_stamp ) ; pkt . data . frame . duration = ( unsigned long ) ticks_to_timebase_units ( timebase , dst_end_time_stamp - dst_time_stamp ; pkt . data . frame . flags = get_frame_pkt_flags ( cpi , lib_flags ) ; pkt . data . frame . buf = ctx -> pending_cx_data ; pkt . data . frame . sz = size ; ctx -> pending_cx_data = NULL ; ctx -> pending_cx_data_sz = 0 ; ctx -> pending_frame_count = 0 ; ctx -> pending_frame_magnitude = 0 ; ctx -> output_cx_pkt_cb . output_cx_pkt ( & pkt , ctx -> output_cx_pkt_cb . user_priv ) ; } continue ; } pkt . . pts = ticks_to_timebase_units ( timebase , dst_time_stamp ) ; pkt . unsigned long ) ticks_to_timebase_units ( timebase , dst_end_time_stamp - dst_time_stamp ) ; pkt . flags = get_frame_pkt_flags ( cpi , lib_flags ) ; if ( += size ; if ( ! ctx -> output_cx_pkt_cb . output_cx_pkt ) - 1 ; if ( ctx -> output_cx_pkt_cb . output_cx_pkt ) ctx -> output_cx_pkt_cb . output_cx_pkt ( & pkt , ctx -> output_cx_pkt_cb . user_priv ) ; else -= size ; # if VPX_ENCODER_ABI_VERSION > ( 5 + VPX_CODEC_ABI_VERSION ) # if CONFIG_SPATIAL_SVC if ( cpi -> use_svc && ! ctx -> output_cx_pkt_cb . output_cx_pkt ) { vpx_codec_cx_pkt_t pkt_sizes , pkt_psnr ; int sl ; vp9_zero ( pkt_sizes ) ; vp9_zero ( pkt_psnr ) ; pkt_sizes . kind = VPX_CODEC_SPATIAL_SVC_LAYER_SIZES ; pkt_psnr . kind = VPX_CODEC_SPATIAL_SVC_LAYER_PSNR ; for ( sl = 0 ; sl < cpi -> svc . number_spatial_layers ; ++ sl ) { LAYER_CONTEXT * lc = & cpi -> svc . layer_context [ sl * cpi -> svc . number_temporal_layers ] ; pkt_sizes . data . layer_sizes [ sl ] = lc -> layer_size ; pkt_psnr . data . layer_psnr [ sl ] = lc -> psnr_pkt ; lc -> layer_size = 0 ; } vpx_codec_pkt_list_add ( & ctx -> pkt_list . head , & pkt_sizes ) ; vpx_codec_pkt_list_add ( & ctx -> pkt_list . head , & pkt_psnr ) ; } # endif # endif if ( is_one_pass_cbr_svc ( cpi ) && ( cpi -> svc . spatial_layer_id == cpi -> svc . number_spatial_layers - 1 ) ) { break ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1573,CWE-416,"CWE-416 SYSCALL_DEFINE2 ( timerfd_create , int , clockid , int , flags ) { int ufd ; struct timerfd_ctx * ctx ; BUILD_BUG_ON ( TFD_CLOEXEC != O_CLOEXEC ) ; BUILD_BUG_ON ( TFD_NONBLOCK != O_NONBLOCK ) ; if ( ( flags & ~ TFD_CREATE_FLAGS ) || ( clockid != CLOCK_MONOTONIC && clockid != CLOCK_REALTIME && clockid != CLOCK_REALTIME_ALARM && clockid != CLOCK_BOOTTIME && clockid != CLOCK_BOOTTIME_ALARM ) ) return - EINVAL ; if ( ! capable ( CAP_WAKE_ALARM ) && ( clockid == CLOCK_REALTIME_ALARM || clockid == CLOCK_BOOTTIME_ALARM ) ) return - EPERM ; ctx = kzalloc ( sizeof ( * ctx ) , GFP_KERNEL ) ; if ( ! ctx ) return - ENOMEM ; init_waitqueue_head ( & ctx -> wqh ) ; ctx -> clockid = clockid ; if ( isalarm ( ctx ) ) alarm_init ( & ctx -> t . alarm , ctx -> clockid == CLOCK_REALTIME_ALARM ? ALARM_REALTIME : ALARM_BOOTTIME , timerfd_alarmproc ) ; else hrtimer_init ( & ctx -> t . tmr , clockid , HRTIMER_MODE_ABS ) ; ctx -> moffs = ktime_mono_to_real ( 0 ) ; ufd = anon_inode_getfd ( ""[timerfd]"" , & timerfd_fops , ctx , O_RDWR | ( flags & TFD_SHARED_FCNTL_FLAGS ) ) ; if ( ufd < 0 ) kfree ( ctx ) ; return ufd ; } "," wqh ) ; spin_lock_init ( & ctx -> cancel_lock ) ; ",torvalds@linux/1e38da300e1e395a15048b0af1e5305bd91402f6,CVE-2017-10661,https://github.com/torvalds/linux/commit/1e38da300e1e395a15048b0af1e5305bd91402f6,2017-08-19T18:29Z 1574,CWE-400,"CWE-400 static int attach_recursive_mnt ( struct mount * source_mnt , struct mount * dest_mnt , struct mountpoint * dest_mp , struct path * parent_path ) { HLIST_HEAD ( tree_list ) ; struct mount * child , * p ; struct hlist_node * n ; int err ; if ( IS_MNT_SHARED ( dest_mnt ) ) { err = invent_group_ids ( source_mnt , true ) ; if ( err ) goto out ; err = propagate_mnt ( dest_mnt , dest_mp , source_mnt , & tree_list ) ; lock_mount_hash ( ) ; if ( err ) goto out_cleanup_ids ; for ( p = source_mnt ; p ; p = next_mnt ( p , source_mnt ) ) set_mnt_shared ( p ) ; } else { lock_mount_hash ( ) ; } if ( parent_path ) { detach_mnt ( source_mnt , parent_path ) ; attach_mnt ( source_mnt , dest_mnt , dest_mp ) ; touch_mnt_namespace ( source_mnt -> mnt_ns ) ; } else { mnt_set_mountpoint ( dest_mnt , dest_mp , source_mnt ) ; commit_tree ( source_mnt , NULL ) ; } hlist_for_each_entry_safe ( child , n , & tree_list , mnt_hash ) { struct mount * q ; hlist_del_init ( & child -> mnt_hash ) ; q = __lookup_mnt_last ( & child -> mnt_parent -> mnt , child -> mnt_mountpoint ) ; commit_tree ( child , q ) ; } unlock_mount_hash ( ) ; return 0 ; out_cleanup_ids : while ( ! hlist_empty ( & tree_list ) ) { child = hlist_entry ( tree_list . first , struct mount , mnt_hash ) ; umount_tree ( child , UMOUNT_SYNC ) ; } unlock_mount_hash ( ) ; cleanup_group_ids ( source_mnt , NULL ) ; out : return err ; } "," ) ; struct mnt_namespace * ns = dest_mnt -> mnt_ns ; struct ; if ( ! parent_path ) { err = count_mounts ( ns , source_mnt ) ; if goto out ; } if ( IS_MNT_SHARED ( dest_mnt ) ) { err = invent_group_ids ( source_mnt , true ) ; if ( err ) goto out ; mnt_hash ) ; child -> mnt_parent -> mnt_ns -> pending_mounts = 0 ; ; out : ns -> pending_mounts = 0 ; ",torvalds@linux/d29216842a85c7970c536108e093963f02714498,CVE-2016-6213,https://github.com/torvalds/linux/commit/d29216842a85c7970c536108e093963f02714498,2016-12-28T07:59Z 1575,CWE-674,"CWE-674 static krb5_error_code decode_sequence_of ( const uint8_t * asn1 , size_t len , const struct atype_info * elemtype , void * * seq_out , size_t * count_out ) { krb5_error_code ret ; void * seq = NULL , * elem , * newseq ; const uint8_t * contents ; size_t clen , count = 0 ; taginfo t ; * seq_out = NULL ; * count_out = 0 ; while ( len > 0 ) { ret = get_tag ( asn1 , len , & t , & contents , & clen , & asn1 , & len ) ; if ( ret ) goto error ; if ( ! check_atype_tag ( elemtype , & t ) ) { ret = ASN1_BAD_ID ; goto error ; } newseq = realloc ( seq , ( count + 1 ) * elemtype -> size ) ; if ( newseq == NULL ) { ret = ENOMEM ; goto error ; } seq = newseq ; elem = ( char * ) seq + count * elemtype -> size ; memset ( elem , 0 , elemtype -> size ) ; ret = decode_atype ( & t , contents , clen , elemtype , elem ) ; if ( ret ) goto error ; count ++ ; } * seq_out = seq ; * count_out = count ; return 0 ; error : free_sequence_of ( elemtype , seq , count ) ; free ( seq ) ; return ret ; } "," , & len , 0 ",krb5@krb5/57415dda6cf04e73ffc3723be518eddfae599bfd,CVE-2020-28196,https://github.com/krb5/krb5/commit/57415dda6cf04e73ffc3723be518eddfae599bfd,2020-11-06T08:15Z 1576,CWE-119,"CWE-119 void fadst16_8col ( __m128i * in ) { __m128i s [ 16 ] , x [ 16 ] , u [ 32 ] , v [ 32 ] ; const __m128i k__cospi_p01_p31 = pair_set_epi16 ( cospi_1_64 , cospi_31_64 ) ; const __m128i k__cospi_p31_m01 = pair_set_epi16 ( cospi_31_64 , - cospi_1_64 ) ; const __m128i k__cospi_p05_p27 = pair_set_epi16 ( cospi_5_64 , cospi_27_64 ) ; const __m128i k__cospi_p27_m05 = pair_set_epi16 ( cospi_27_64 , - cospi_5_64 ) ; const __m128i k__cospi_p09_p23 = pair_set_epi16 ( cospi_9_64 , cospi_23_64 ) ; const __m128i k__cospi_p23_m09 = pair_set_epi16 ( cospi_23_64 , - cospi_9_64 ) ; const __m128i k__cospi_p13_p19 = pair_set_epi16 ( cospi_13_64 , cospi_19_64 ) ; const __m128i k__cospi_p19_m13 = pair_set_epi16 ( cospi_19_64 , - cospi_13_64 ) ; const __m128i k__cospi_p17_p15 = pair_set_epi16 ( cospi_17_64 , cospi_15_64 ) ; const __m128i k__cospi_p15_m17 = pair_set_epi16 ( cospi_15_64 , - cospi_17_64 ) ; const __m128i k__cospi_p21_p11 = pair_set_epi16 ( cospi_21_64 , cospi_11_64 ) ; const __m128i k__cospi_p11_m21 = pair_set_epi16 ( cospi_11_64 , - cospi_21_64 ) ; const __m128i k__cospi_p25_p07 = pair_set_epi16 ( cospi_25_64 , cospi_7_64 ) ; const __m128i k__cospi_p07_m25 = pair_set_epi16 ( cospi_7_64 , - cospi_25_64 ) ; const __m128i k__cospi_p29_p03 = pair_set_epi16 ( cospi_29_64 , cospi_3_64 ) ; const __m128i k__cospi_p03_m29 = pair_set_epi16 ( cospi_3_64 , - cospi_29_64 ) ; const __m128i k__cospi_p04_p28 = pair_set_epi16 ( cospi_4_64 , cospi_28_64 ) ; const __m128i k__cospi_p28_m04 = pair_set_epi16 ( cospi_28_64 , - cospi_4_64 ) ; const __m128i k__cospi_p20_p12 = pair_set_epi16 ( cospi_20_64 , cospi_12_64 ) ; const __m128i k__cospi_p12_m20 = pair_set_epi16 ( cospi_12_64 , - cospi_20_64 ) ; const __m128i k__cospi_m28_p04 = pair_set_epi16 ( - cospi_28_64 , cospi_4_64 ) ; const __m128i k__cospi_m12_p20 = pair_set_epi16 ( - cospi_12_64 , cospi_20_64 ) ; const __m128i k__cospi_p08_p24 = pair_set_epi16 ( cospi_8_64 , cospi_24_64 ) ; const __m128i k__cospi_p24_m08 = pair_set_epi16 ( cospi_24_64 , - cospi_8_64 ) ; const __m128i k__cospi_m24_p08 = pair_set_epi16 ( - cospi_24_64 , cospi_8_64 ) ; const __m128i k__cospi_m16_m16 = _mm_set1_epi16 ( - cospi_16_64 ) ; const __m128i k__cospi_p16_p16 = _mm_set1_epi16 ( cospi_16_64 ) ; const __m128i k__cospi_p16_m16 = pair_set_epi16 ( cospi_16_64 , - cospi_16_64 ) ; const __m128i k__cospi_m16_p16 = pair_set_epi16 ( - cospi_16_64 , cospi_16_64 ) ; const __m128i k__DCT_CONST_ROUNDING = _mm_set1_epi32 ( DCT_CONST_ROUNDING ) ; const __m128i kZero = _mm_set1_epi16 ( 0 ) ; u [ 0 ] = _mm_unpacklo_epi16 ( in [ 15 ] , in [ 0 ] ) ; u [ 1 ] = _mm_unpackhi_epi16 ( in [ 15 ] , in [ 0 ] ) ; u [ 2 ] = _mm_unpacklo_epi16 ( in [ 13 ] , in [ 2 ] ) ; u [ 3 ] = _mm_unpackhi_epi16 ( in [ 13 ] , in [ 2 ] ) ; u [ 4 ] = _mm_unpacklo_epi16 ( in [ 11 ] , in [ 4 ] ) ; u [ 5 ] = _mm_unpackhi_epi16 ( in [ 11 ] , in [ 4 ] ) ; u [ 6 ] = _mm_unpacklo_epi16 ( in [ 9 ] , in [ 6 ] ) ; u [ 7 ] = _mm_unpackhi_epi16 ( in [ 9 ] , in [ 6 ] ) ; u [ 8 ] = _mm_unpacklo_epi16 ( in [ 7 ] , in [ 8 ] ) ; u [ 9 ] = _mm_unpackhi_epi16 ( in [ 7 ] , in [ 8 ] ) ; u [ 10 ] = _mm_unpacklo_epi16 ( in [ 5 ] , in [ 10 ] ) ; u [ 11 ] = _mm_unpackhi_epi16 ( in [ 5 ] , in [ 10 ] ) ; u [ 12 ] = _mm_unpacklo_epi16 ( in [ 3 ] , in [ 12 ] ) ; u [ 13 ] = _mm_unpackhi_epi16 ( in [ 3 ] , in [ 12 ] ) ; u [ 14 ] = _mm_unpacklo_epi16 ( in [ 1 ] , in [ 14 ] ) ; u [ 15 ] = _mm_unpackhi_epi16 ( in [ 1 ] , in [ 14 ] ) ; v [ 0 ] = _mm_madd_epi16 ( u [ 0 ] , k__cospi_p01_p31 ) ; v [ 1 ] = _mm_madd_epi16 ( u [ 1 ] , k__cospi_p01_p31 ) ; v [ 2 ] = _mm_madd_epi16 ( u [ 0 ] , k__cospi_p31_m01 ) ; v [ 3 ] = _mm_madd_epi16 ( u [ 1 ] , k__cospi_p31_m01 ) ; v [ 4 ] = _mm_madd_epi16 ( u [ 2 ] , k__cospi_p05_p27 ) ; v [ 5 ] = _mm_madd_epi16 ( u [ 3 ] , k__cospi_p05_p27 ) ; v [ 6 ] = _mm_madd_epi16 ( u [ 2 ] , k__cospi_p27_m05 ) ; v [ 7 ] = _mm_madd_epi16 ( u [ 3 ] , k__cospi_p27_m05 ) ; v [ 8 ] = _mm_madd_epi16 ( u [ 4 ] , k__cospi_p09_p23 ) ; v [ 9 ] = _mm_madd_epi16 ( u [ 5 ] , k__cospi_p09_p23 ) ; v [ 10 ] = _mm_madd_epi16 ( u [ 4 ] , k__cospi_p23_m09 ) ; v [ 11 ] = _mm_madd_epi16 ( u [ 5 ] , k__cospi_p23_m09 ) ; v [ 12 ] = _mm_madd_epi16 ( u [ 6 ] , k__cospi_p13_p19 ) ; v [ 13 ] = _mm_madd_epi16 ( u [ 7 ] , k__cospi_p13_p19 ) ; v [ 14 ] = _mm_madd_epi16 ( u [ 6 ] , k__cospi_p19_m13 ) ; v [ 15 ] = _mm_madd_epi16 ( u [ 7 ] , k__cospi_p19_m13 ) ; v [ 16 ] = _mm_madd_epi16 ( u [ 8 ] , k__cospi_p17_p15 ) ; v [ 17 ] = _mm_madd_epi16 ( u [ 9 ] , k__cospi_p17_p15 ) ; v [ 18 ] = _mm_madd_epi16 ( u [ 8 ] , k__cospi_p15_m17 ) ; v [ 19 ] = _mm_madd_epi16 ( u [ 9 ] , k__cospi_p15_m17 ) ; v [ 20 ] = _mm_madd_epi16 ( u [ 10 ] , k__cospi_p21_p11 ) ; v [ 21 ] = _mm_madd_epi16 ( u [ 11 ] , k__cospi_p21_p11 ) ; v [ 22 ] = _mm_madd_epi16 ( u [ 10 ] , k__cospi_p11_m21 ) ; v [ 23 ] = _mm_madd_epi16 ( u [ 11 ] , k__cospi_p11_m21 ) ; v [ 24 ] = _mm_madd_epi16 ( u [ 12 ] , k__cospi_p25_p07 ) ; v [ 25 ] = _mm_madd_epi16 ( u [ 13 ] , k__cospi_p25_p07 ) ; v [ 26 ] = _mm_madd_epi16 ( u [ 12 ] , k__cospi_p07_m25 ) ; v [ 27 ] = _mm_madd_epi16 ( u [ 13 ] , k__cospi_p07_m25 ) ; v [ 28 ] = _mm_madd_epi16 ( u [ 14 ] , k__cospi_p29_p03 ) ; v [ 29 ] = _mm_madd_epi16 ( u [ 15 ] , k__cospi_p29_p03 ) ; v [ 30 ] = _mm_madd_epi16 ( u [ 14 ] , k__cospi_p03_m29 ) ; v [ 31 ] = _mm_madd_epi16 ( u [ 15 ] , k__cospi_p03_m29 ) ; u [ 0 ] = _mm_add_epi32 ( v [ 0 ] , v [ 16 ] ) ; u [ 1 ] = _mm_add_epi32 ( v [ 1 ] , v [ 17 ] ) ; u [ 2 ] = _mm_add_epi32 ( v [ 2 ] , v [ 18 ] ) ; u [ 3 ] = _mm_add_epi32 ( v [ 3 ] , v [ 19 ] ) ; u [ 4 ] = _mm_add_epi32 ( v [ 4 ] , v [ 20 ] ) ; u [ 5 ] = _mm_add_epi32 ( v [ 5 ] , v [ 21 ] ) ; u [ 6 ] = _mm_add_epi32 ( v [ 6 ] , v [ 22 ] ) ; u [ 7 ] = _mm_add_epi32 ( v [ 7 ] , v [ 23 ] ) ; u [ 8 ] = _mm_add_epi32 ( v [ 8 ] , v [ 24 ] ) ; u [ 9 ] = _mm_add_epi32 ( v [ 9 ] , v [ 25 ] ) ; u [ 10 ] = _mm_add_epi32 ( v [ 10 ] , v [ 26 ] ) ; u [ 11 ] = _mm_add_epi32 ( v [ 11 ] , v [ 27 ] ) ; u [ 12 ] = _mm_add_epi32 ( v [ 12 ] , v [ 28 ] ) ; u [ 13 ] = _mm_add_epi32 ( v [ 13 ] , v [ 29 ] ) ; u [ 14 ] = _mm_add_epi32 ( v [ 14 ] , v [ 30 ] ) ; u [ 15 ] = _mm_add_epi32 ( v [ 15 ] , v [ 31 ] ) ; u [ 16 ] = _mm_sub_epi32 ( v [ 0 ] , v [ 16 ] ) ; u [ 17 ] = _mm_sub_epi32 ( v [ 1 ] , v [ 17 ] ) ; u [ 18 ] = _mm_sub_epi32 ( v [ 2 ] , v [ 18 ] ) ; u [ 19 ] = _mm_sub_epi32 ( v [ 3 ] , v [ 19 ] ) ; u [ 20 ] = _mm_sub_epi32 ( v [ 4 ] , v [ 20 ] ) ; u [ 21 ] = _mm_sub_epi32 ( v [ 5 ] , v [ 21 ] ) ; u [ 22 ] = _mm_sub_epi32 ( v [ 6 ] , v [ 22 ] ) ; u [ 23 ] = _mm_sub_epi32 ( v [ 7 ] , v [ 23 ] ) ; u [ 24 ] = _mm_sub_epi32 ( v [ 8 ] , v [ 24 ] ) ; u [ 25 ] = _mm_sub_epi32 ( v [ 9 ] , v [ 25 ] ) ; u [ 26 ] = _mm_sub_epi32 ( v [ 10 ] , v [ 26 ] ) ; u [ 27 ] = _mm_sub_epi32 ( v [ 11 ] , v [ 27 ] ) ; u [ 28 ] = _mm_sub_epi32 ( v [ 12 ] , v [ 28 ] ) ; u [ 29 ] = _mm_sub_epi32 ( v [ 13 ] , v [ 29 ] ) ; u [ 30 ] = _mm_sub_epi32 ( v [ 14 ] , v [ 30 ] ) ; u [ 31 ] = _mm_sub_epi32 ( v [ 15 ] , v [ 31 ] ) ; v [ 0 ] = _mm_add_epi32 ( u [ 0 ] , k__DCT_CONST_ROUNDING ) ; v [ 1 ] = _mm_add_epi32 ( u [ 1 ] , k__DCT_CONST_ROUNDING ) ; v [ 2 ] = _mm_add_epi32 ( u [ 2 ] , k__DCT_CONST_ROUNDING ) ; v [ 3 ] = _mm_add_epi32 ( u [ 3 ] , k__DCT_CONST_ROUNDING ) ; v [ 4 ] = _mm_add_epi32 ( u [ 4 ] , k__DCT_CONST_ROUNDING ) ; v [ 5 ] = _mm_add_epi32 ( u [ 5 ] , k__DCT_CONST_ROUNDING ) ; v [ 6 ] = _mm_add_epi32 ( u [ 6 ] , k__DCT_CONST_ROUNDING ) ; v [ 7 ] = _mm_add_epi32 ( u [ 7 ] , k__DCT_CONST_ROUNDING ) ; v [ 8 ] = _mm_add_epi32 ( u [ 8 ] , k__DCT_CONST_ROUNDING ) ; v [ 9 ] = _mm_add_epi32 ( u [ 9 ] , k__DCT_CONST_ROUNDING ) ; v [ 10 ] = _mm_add_epi32 ( u [ 10 ] , k__DCT_CONST_ROUNDING ) ; v [ 11 ] = _mm_add_epi32 ( u [ 11 ] , k__DCT_CONST_ROUNDING ) ; v [ 12 ] = _mm_add_epi32 ( u [ 12 ] , k__DCT_CONST_ROUNDING ) ; v [ 13 ] = _mm_add_epi32 ( u [ 13 ] , k__DCT_CONST_ROUNDING ) ; v [ 14 ] = _mm_add_epi32 ( u [ 14 ] , k__DCT_CONST_ROUNDING ) ; v [ 15 ] = _mm_add_epi32 ( u [ 15 ] , k__DCT_CONST_ROUNDING ) ; v [ 16 ] = _mm_add_epi32 ( u [ 16 ] , k__DCT_CONST_ROUNDING ) ; v [ 17 ] = _mm_add_epi32 ( u [ 17 ] , k__DCT_CONST_ROUNDING ) ; v [ 18 ] = _mm_add_epi32 ( u [ 18 ] , k__DCT_CONST_ROUNDING ) ; v [ 19 ] = _mm_add_epi32 ( u [ 19 ] , k__DCT_CONST_ROUNDING ) ; v [ 20 ] = _mm_add_epi32 ( u [ 20 ] , k__DCT_CONST_ROUNDING ) ; v [ 21 ] = _mm_add_epi32 ( u [ 21 ] , k__DCT_CONST_ROUNDING ) ; v [ 22 ] = _mm_add_epi32 ( u [ 22 ] , k__DCT_CONST_ROUNDING ) ; v [ 23 ] = _mm_add_epi32 ( u [ 23 ] , k__DCT_CONST_ROUNDING ) ; v [ 24 ] = _mm_add_epi32 ( u [ 24 ] , k__DCT_CONST_ROUNDING ) ; v [ 25 ] = _mm_add_epi32 ( u [ 25 ] , k__DCT_CONST_ROUNDING ) ; v [ 26 ] = _mm_add_epi32 ( u [ 26 ] , k__DCT_CONST_ROUNDING ) ; v [ 27 ] = _mm_add_epi32 ( u [ 27 ] , k__DCT_CONST_ROUNDING ) ; v [ 28 ] = _mm_add_epi32 ( u [ 28 ] , k__DCT_CONST_ROUNDING ) ; v [ 29 ] = _mm_add_epi32 ( u [ 29 ] , k__DCT_CONST_ROUNDING ) ; v [ 30 ] = _mm_add_epi32 ( u [ 30 ] , k__DCT_CONST_ROUNDING ) ; v [ 31 ] = _mm_add_epi32 ( u [ 31 ] , k__DCT_CONST_ROUNDING ) ; u [ 0 ] = _mm_srai_epi32 ( v [ 0 ] , DCT_CONST_BITS ) ; u [ 1 ] = _mm_srai_epi32 ( v [ 1 ] , DCT_CONST_BITS ) ; u [ 2 ] = _mm_srai_epi32 ( v [ 2 ] , DCT_CONST_BITS ) ; u [ 3 ] = _mm_srai_epi32 ( v [ 3 ] , DCT_CONST_BITS ) ; u [ 4 ] = _mm_srai_epi32 ( v [ 4 ] , DCT_CONST_BITS ) ; u [ 5 ] = _mm_srai_epi32 ( v [ 5 ] , DCT_CONST_BITS ) ; u [ 6 ] = _mm_srai_epi32 ( v [ 6 ] , DCT_CONST_BITS ) ; u [ 7 ] = _mm_srai_epi32 ( v [ 7 ] , DCT_CONST_BITS ) ; u [ 8 ] = _mm_srai_epi32 ( v [ 8 ] , DCT_CONST_BITS ) ; u [ 9 ] = _mm_srai_epi32 ( v [ 9 ] , DCT_CONST_BITS ) ; u [ 10 ] = _mm_srai_epi32 ( v [ 10 ] , DCT_CONST_BITS ) ; u [ 11 ] = _mm_srai_epi32 ( v [ 11 ] , DCT_CONST_BITS ) ; u [ 12 ] = _mm_srai_epi32 ( v [ 12 ] , DCT_CONST_BITS ) ; u [ 13 ] = _mm_srai_epi32 ( v [ 13 ] , DCT_CONST_BITS ) ; u [ 14 ] = _mm_srai_epi32 ( v [ 14 ] , DCT_CONST_BITS ) ; u [ 15 ] = _mm_srai_epi32 ( v [ 15 ] , DCT_CONST_BITS ) ; u [ 16 ] = _mm_srai_epi32 ( v [ 16 ] , DCT_CONST_BITS ) ; u [ 17 ] = _mm_srai_epi32 ( v [ 17 ] , DCT_CONST_BITS ) ; u [ 18 ] = _mm_srai_epi32 ( v [ 18 ] , DCT_CONST_BITS ) ; u [ 19 ] = _mm_srai_epi32 ( v [ 19 ] , DCT_CONST_BITS ) ; u [ 20 ] = _mm_srai_epi32 ( v [ 20 ] , DCT_CONST_BITS ) ; u [ 21 ] = _mm_srai_epi32 ( v [ 21 ] , DCT_CONST_BITS ) ; u [ 22 ] = _mm_srai_epi32 ( v [ 22 ] , DCT_CONST_BITS ) ; u [ 23 ] = _mm_srai_epi32 ( v [ 23 ] , DCT_CONST_BITS ) ; u [ 24 ] = _mm_srai_epi32 ( v [ 24 ] , DCT_CONST_BITS ) ; u [ 25 ] = _mm_srai_epi32 ( v [ 25 ] , DCT_CONST_BITS ) ; u [ 26 ] = _mm_srai_epi32 ( v [ 26 ] , DCT_CONST_BITS ) ; u [ 27 ] = _mm_srai_epi32 ( v [ 27 ] , DCT_CONST_BITS ) ; u [ 28 ] = _mm_srai_epi32 ( v [ 28 ] , DCT_CONST_BITS ) ; u [ 29 ] = _mm_srai_epi32 ( v [ 29 ] , DCT_CONST_BITS ) ; u [ 30 ] = _mm_srai_epi32 ( v [ 30 ] , DCT_CONST_BITS ) ; u [ 31 ] = _mm_srai_epi32 ( v [ 31 ] , DCT_CONST_BITS ) ; s [ 0 ] = _mm_packs_epi32 ( u [ 0 ] , u [ 1 ] ) ; s [ 1 ] = _mm_packs_epi32 ( u [ 2 ] , u [ 3 ] ) ; s [ 2 ] = _mm_packs_epi32 ( u [ 4 ] , u [ 5 ] ) ; s [ 3 ] = _mm_packs_epi32 ( u [ 6 ] , u [ 7 ] ) ; s [ 4 ] = _mm_packs_epi32 ( u [ 8 ] , u [ 9 ] ) ; s [ 5 ] = _mm_packs_epi32 ( u [ 10 ] , u [ 11 ] ) ; s [ 6 ] = _mm_packs_epi32 ( u [ 12 ] , u [ 13 ] ) ; s [ 7 ] = _mm_packs_epi32 ( u [ 14 ] , u [ 15 ] ) ; s [ 8 ] = _mm_packs_epi32 ( u [ 16 ] , u [ 17 ] ) ; s [ 9 ] = _mm_packs_epi32 ( u [ 18 ] , u [ 19 ] ) ; s [ 10 ] = _mm_packs_epi32 ( u [ 20 ] , u [ 21 ] ) ; s [ 11 ] = _mm_packs_epi32 ( u [ 22 ] , u [ 23 ] ) ; s [ 12 ] = _mm_packs_epi32 ( u [ 24 ] , u [ 25 ] ) ; s [ 13 ] = _mm_packs_epi32 ( u [ 26 ] , u [ 27 ] ) ; s [ 14 ] = _mm_packs_epi32 ( u [ 28 ] , u [ 29 ] ) ; s [ 15 ] = _mm_packs_epi32 ( u [ 30 ] , u [ 31 ] ) ; u [ 0 ] = _mm_unpacklo_epi16 ( s [ 8 ] , s [ 9 ] ) ; u [ 1 ] = _mm_unpackhi_epi16 ( s [ 8 ] , s [ 9 ] ) ; u [ 2 ] = _mm_unpacklo_epi16 ( s [ 10 ] , s [ 11 ] ) ; u [ 3 ] = _mm_unpackhi_epi16 ( s [ 10 ] , s [ 11 ] ) ; u [ 4 ] = _mm_unpacklo_epi16 ( s [ 12 ] , s [ 13 ] ) ; u [ 5 ] = _mm_unpackhi_epi16 ( s [ 12 ] , s [ 13 ] ) ; u [ 6 ] = _mm_unpacklo_epi16 ( s [ 14 ] , s [ 15 ] ) ; u [ 7 ] = _mm_unpackhi_epi16 ( s [ 14 ] , s [ 15 ] ) ; v [ 0 ] = _mm_madd_epi16 ( u [ 0 ] , k__cospi_p04_p28 ) ; v [ 1 ] = _mm_madd_epi16 ( u [ 1 ] , k__cospi_p04_p28 ) ; v [ 2 ] = _mm_madd_epi16 ( u [ 0 ] , k__cospi_p28_m04 ) ; v [ 3 ] = _mm_madd_epi16 ( u [ 1 ] , k__cospi_p28_m04 ) ; v [ 4 ] = _mm_madd_epi16 ( u [ 2 ] , k__cospi_p20_p12 ) ; v [ 5 ] = _mm_madd_epi16 ( u [ 3 ] , k__cospi_p20_p12 ) ; v [ 6 ] = _mm_madd_epi16 ( u [ 2 ] , k__cospi_p12_m20 ) ; v [ 7 ] = _mm_madd_epi16 ( u [ 3 ] , k__cospi_p12_m20 ) ; v [ 8 ] = _mm_madd_epi16 ( u [ 4 ] , k__cospi_m28_p04 ) ; v [ 9 ] = _mm_madd_epi16 ( u [ 5 ] , k__cospi_m28_p04 ) ; v [ 10 ] = _mm_madd_epi16 ( u [ 4 ] , k__cospi_p04_p28 ) ; v [ 11 ] = _mm_madd_epi16 ( u [ 5 ] , k__cospi_p04_p28 ) ; v [ 12 ] = _mm_madd_epi16 ( u [ 6 ] , k__cospi_m12_p20 ) ; v [ 13 ] = _mm_madd_epi16 ( u [ 7 ] , k__cospi_m12_p20 ) ; v [ 14 ] = _mm_madd_epi16 ( u [ 6 ] , k__cospi_p20_p12 ) ; v [ 15 ] = _mm_madd_epi16 ( u [ 7 ] , k__cospi_p20_p12 ) ; u [ 0 ] = _mm_add_epi32 ( v [ 0 ] , v [ 8 ] ) ; u [ 1 ] = _mm_add_epi32 ( v [ 1 ] , v [ 9 ] ) ; u [ 2 ] = _mm_add_epi32 ( v [ 2 ] , v [ 10 ] ) ; u [ 3 ] = _mm_add_epi32 ( v [ 3 ] , v [ 11 ] ) ; u [ 4 ] = _mm_add_epi32 ( v [ 4 ] , v [ 12 ] ) ; u [ 5 ] = _mm_add_epi32 ( v [ 5 ] , v [ 13 ] ) ; u [ 6 ] = _mm_add_epi32 ( v [ 6 ] , v [ 14 ] ) ; u [ 7 ] = _mm_add_epi32 ( v [ 7 ] , v [ 15 ] ) ; u [ 8 ] = _mm_sub_epi32 ( v [ 0 ] , v [ 8 ] ) ; u [ 9 ] = _mm_sub_epi32 ( v [ 1 ] , v [ 9 ] ) ; u [ 10 ] = _mm_sub_epi32 ( v [ 2 ] , v [ 10 ] ) ; u [ 11 ] = _mm_sub_epi32 ( v [ 3 ] , v [ 11 ] ) ; u [ 12 ] = _mm_sub_epi32 ( v [ 4 ] , v [ 12 ] ) ; u [ 13 ] = _mm_sub_epi32 ( v [ 5 ] , v [ 13 ] ) ; u [ 14 ] = _mm_sub_epi32 ( v [ 6 ] , v [ 14 ] ) ; u [ 15 ] = _mm_sub_epi32 ( v [ 7 ] , v [ 15 ] ) ; v [ 0 ] = _mm_add_epi32 ( u [ 0 ] , k__DCT_CONST_ROUNDING ) ; v [ 1 ] = _mm_add_epi32 ( u [ 1 ] , k__DCT_CONST_ROUNDING ) ; v [ 2 ] = _mm_add_epi32 ( u [ 2 ] , k__DCT_CONST_ROUNDING ) ; v [ 3 ] = _mm_add_epi32 ( u [ 3 ] , k__DCT_CONST_ROUNDING ) ; v [ 4 ] = _mm_add_epi32 ( u [ 4 ] , k__DCT_CONST_ROUNDING ) ; v [ 5 ] = _mm_add_epi32 ( u [ 5 ] , k__DCT_CONST_ROUNDING ) ; v [ 6 ] = _mm_add_epi32 ( u [ 6 ] , k__DCT_CONST_ROUNDING ) ; v [ 7 ] = _mm_add_epi32 ( u [ 7 ] , k__DCT_CONST_ROUNDING ) ; v [ 8 ] = _mm_add_epi32 ( u [ 8 ] , k__DCT_CONST_ROUNDING ) ; v [ 9 ] = _mm_add_epi32 ( u [ 9 ] , k__DCT_CONST_ROUNDING ) ; v [ 10 ] = _mm_add_epi32 ( u [ 10 ] , k__DCT_CONST_ROUNDING ) ; v [ 11 ] = _mm_add_epi32 ( u [ 11 ] , k__DCT_CONST_ROUNDING ) ; v [ 12 ] = _mm_add_epi32 ( u [ 12 ] , k__DCT_CONST_ROUNDING ) ; v [ 13 ] = _mm_add_epi32 ( u [ 13 ] , k__DCT_CONST_ROUNDING ) ; v [ 14 ] = _mm_add_epi32 ( u [ 14 ] , k__DCT_CONST_ROUNDING ) ; v [ 15 ] = _mm_add_epi32 ( u [ 15 ] , k__DCT_CONST_ROUNDING ) ; u [ 0 ] = _mm_srai_epi32 ( v [ 0 ] , DCT_CONST_BITS ) ; u [ 1 ] = _mm_srai_epi32 ( v [ 1 ] , DCT_CONST_BITS ) ; u [ 2 ] = _mm_srai_epi32 ( v [ 2 ] , DCT_CONST_BITS ) ; u [ 3 ] = _mm_srai_epi32 ( v [ 3 ] , DCT_CONST_BITS ) ; u [ 4 ] = _mm_srai_epi32 ( v [ 4 ] , DCT_CONST_BITS ) ; u [ 5 ] = _mm_srai_epi32 ( v [ 5 ] , DCT_CONST_BITS ) ; u [ 6 ] = _mm_srai_epi32 ( v [ 6 ] , DCT_CONST_BITS ) ; u [ 7 ] = _mm_srai_epi32 ( v [ 7 ] , DCT_CONST_BITS ) ; u [ 8 ] = _mm_srai_epi32 ( v [ 8 ] , DCT_CONST_BITS ) ; u [ 9 ] = _mm_srai_epi32 ( v [ 9 ] , DCT_CONST_BITS ) ; u [ 10 ] = _mm_srai_epi32 ( v [ 10 ] , DCT_CONST_BITS ) ; u [ 11 ] = _mm_srai_epi32 ( v [ 11 ] , DCT_CONST_BITS ) ; u [ 12 ] = _mm_srai_epi32 ( v [ 12 ] , DCT_CONST_BITS ) ; u [ 13 ] = _mm_srai_epi32 ( v [ 13 ] , DCT_CONST_BITS ) ; u [ 14 ] = _mm_srai_epi32 ( v [ 14 ] , DCT_CONST_BITS ) ; u [ 15 ] = _mm_srai_epi32 ( v [ 15 ] , DCT_CONST_BITS ) ; x [ 0 ] = _mm_add_epi16 ( s [ 0 ] , s [ 4 ] ) ; x [ 1 ] = _mm_add_epi16 ( s [ 1 ] , s [ 5 ] ) ; x [ 2 ] = _mm_add_epi16 ( s [ 2 ] , s [ 6 ] ) ; x [ 3 ] = _mm_add_epi16 ( s [ 3 ] , s [ 7 ] ) ; x [ 4 ] = _mm_sub_epi16 ( s [ 0 ] , s [ 4 ] ) ; x [ 5 ] = _mm_sub_epi16 ( s [ 1 ] , s [ 5 ] ) ; x [ 6 ] = _mm_sub_epi16 ( s [ 2 ] , s [ 6 ] ) ; x [ 7 ] = _mm_sub_epi16 ( s [ 3 ] , s [ 7 ] ) ; x [ 8 ] = _mm_packs_epi32 ( u [ 0 ] , u [ 1 ] ) ; x [ 9 ] = _mm_packs_epi32 ( u [ 2 ] , u [ 3 ] ) ; x [ 10 ] = _mm_packs_epi32 ( u [ 4 ] , u [ 5 ] ) ; x [ 11 ] = _mm_packs_epi32 ( u [ 6 ] , u [ 7 ] ) ; x [ 12 ] = _mm_packs_epi32 ( u [ 8 ] , u [ 9 ] ) ; x [ 13 ] = _mm_packs_epi32 ( u [ 10 ] , u [ 11 ] ) ; x [ 14 ] = _mm_packs_epi32 ( u [ 12 ] , u [ 13 ] ) ; x [ 15 ] = _mm_packs_epi32 ( u [ 14 ] , u [ 15 ] ) ; u [ 0 ] = _mm_unpacklo_epi16 ( x [ 4 ] , x [ 5 ] ) ; u [ 1 ] = _mm_unpackhi_epi16 ( x [ 4 ] , x [ 5 ] ) ; u [ 2 ] = _mm_unpacklo_epi16 ( x [ 6 ] , x [ 7 ] ) ; u [ 3 ] = _mm_unpackhi_epi16 ( x [ 6 ] , x [ 7 ] ) ; u [ 4 ] = _mm_unpacklo_epi16 ( x [ 12 ] , x [ 13 ] ) ; u [ 5 ] = _mm_unpackhi_epi16 ( x [ 12 ] , x [ 13 ] ) ; u [ 6 ] = _mm_unpacklo_epi16 ( x [ 14 ] , x [ 15 ] ) ; u [ 7 ] = _mm_unpackhi_epi16 ( x [ 14 ] , x [ 15 ] ) ; v [ 0 ] = _mm_madd_epi16 ( u [ 0 ] , k__cospi_p08_p24 ) ; v [ 1 ] = _mm_madd_epi16 ( u [ 1 ] , k__cospi_p08_p24 ) ; v [ 2 ] = _mm_madd_epi16 ( u [ 0 ] , k__cospi_p24_m08 ) ; v [ 3 ] = _mm_madd_epi16 ( u [ 1 ] , k__cospi_p24_m08 ) ; v [ 4 ] = _mm_madd_epi16 ( u [ 2 ] , k__cospi_m24_p08 ) ; v [ 5 ] = _mm_madd_epi16 ( u [ 3 ] , k__cospi_m24_p08 ) ; v [ 6 ] = _mm_madd_epi16 ( u [ 2 ] , k__cospi_p08_p24 ) ; v [ 7 ] = _mm_madd_epi16 ( u [ 3 ] , k__cospi_p08_p24 ) ; v [ 8 ] = _mm_madd_epi16 ( u [ 4 ] , k__cospi_p08_p24 ) ; v [ 9 ] = _mm_madd_epi16 ( u [ 5 ] , k__cospi_p08_p24 ) ; v [ 10 ] = _mm_madd_epi16 ( u [ 4 ] , k__cospi_p24_m08 ) ; v [ 11 ] = _mm_madd_epi16 ( u [ 5 ] , k__cospi_p24_m08 ) ; v [ 12 ] = _mm_madd_epi16 ( u [ 6 ] , k__cospi_m24_p08 ) ; v [ 13 ] = _mm_madd_epi16 ( u [ 7 ] , k__cospi_m24_p08 ) ; v [ 14 ] = _mm_madd_epi16 ( u [ 6 ] , k__cospi_p08_p24 ) ; v [ 15 ] = _mm_madd_epi16 ( u [ 7 ] , k__cospi_p08_p24 ) ; u [ 0 ] = _mm_add_epi32 ( v [ 0 ] , v [ 4 ] ) ; u [ 1 ] = _mm_add_epi32 ( v [ 1 ] , v [ 5 ] ) ; u [ 2 ] = _mm_add_epi32 ( v [ 2 ] , v [ 6 ] ) ; u [ 3 ] = _mm_add_epi32 ( v [ 3 ] , v [ 7 ] ) ; u [ 4 ] = _mm_sub_epi32 ( v [ 0 ] , v [ 4 ] ) ; u [ 5 ] = _mm_sub_epi32 ( v [ 1 ] , v [ 5 ] ) ; u [ 6 ] = _mm_sub_epi32 ( v [ 2 ] , v [ 6 ] ) ; u [ 7 ] = _mm_sub_epi32 ( v [ 3 ] , v [ 7 ] ) ; u [ 8 ] = _mm_add_epi32 ( v [ 8 ] , v [ 12 ] ) ; u [ 9 ] = _mm_add_epi32 ( v [ 9 ] , v [ 13 ] ) ; u [ 10 ] = _mm_add_epi32 ( v [ 10 ] , v [ 14 ] ) ; u [ 11 ] = _mm_add_epi32 ( v [ 11 ] , v [ 15 ] ) ; u [ 12 ] = _mm_sub_epi32 ( v [ 8 ] , v [ 12 ] ) ; u [ 13 ] = _mm_sub_epi32 ( v [ 9 ] , v [ 13 ] ) ; u [ 14 ] = _mm_sub_epi32 ( v [ 10 ] , v [ 14 ] ) ; u [ 15 ] = _mm_sub_epi32 ( v [ 11 ] , v [ 15 ] ) ; u [ 0 ] = _mm_add_epi32 ( u [ 0 ] , k__DCT_CONST_ROUNDING ) ; u [ 1 ] = _mm_add_epi32 ( u [ 1 ] , k__DCT_CONST_ROUNDING ) ; u [ 2 ] = _mm_add_epi32 ( u [ 2 ] , k__DCT_CONST_ROUNDING ) ; u [ 3 ] = _mm_add_epi32 ( u [ 3 ] , k__DCT_CONST_ROUNDING ) ; u [ 4 ] = _mm_add_epi32 ( u [ 4 ] , k__DCT_CONST_ROUNDING ) ; u [ 5 ] = _mm_add_epi32 ( u [ 5 ] , k__DCT_CONST_ROUNDING ) ; u [ 6 ] = _mm_add_epi32 ( u [ 6 ] , k__DCT_CONST_ROUNDING ) ; u [ 7 ] = _mm_add_epi32 ( u [ 7 ] , k__DCT_CONST_ROUNDING ) ; u [ 8 ] = _mm_add_epi32 ( u [ 8 ] , k__DCT_CONST_ROUNDING ) ; u [ 9 ] = _mm_add_epi32 ( u [ 9 ] , k__DCT_CONST_ROUNDING ) ; u [ 10 ] = _mm_add_epi32 ( u [ 10 ] , k__DCT_CONST_ROUNDING ) ; u [ 11 ] = _mm_add_epi32 ( u [ 11 ] , k__DCT_CONST_ROUNDING ) ; u [ 12 ] = _mm_add_epi32 ( u [ 12 ] , k__DCT_CONST_ROUNDING ) ; u [ 13 ] = _mm_add_epi32 ( u [ 13 ] , k__DCT_CONST_ROUNDING ) ; u [ 14 ] = _mm_add_epi32 ( u [ 14 ] , k__DCT_CONST_ROUNDING ) ; u [ 15 ] = _mm_add_epi32 ( u [ 15 ] , k__DCT_CONST_ROUNDING ) ; v [ 0 ] = _mm_srai_epi32 ( u [ 0 ] , DCT_CONST_BITS ) ; v [ 1 ] = _mm_srai_epi32 ( u [ 1 ] , DCT_CONST_BITS ) ; v [ 2 ] = _mm_srai_epi32 ( u [ 2 ] , DCT_CONST_BITS ) ; v [ 3 ] = _mm_srai_epi32 ( u [ 3 ] , DCT_CONST_BITS ) ; v [ 4 ] = _mm_srai_epi32 ( u [ 4 ] , DCT_CONST_BITS ) ; v [ 5 ] = _mm_srai_epi32 ( u [ 5 ] , DCT_CONST_BITS ) ; v [ 6 ] = _mm_srai_epi32 ( u [ 6 ] , DCT_CONST_BITS ) ; v [ 7 ] = _mm_srai_epi32 ( u [ 7 ] , DCT_CONST_BITS ) ; v [ 8 ] = _mm_srai_epi32 ( u [ 8 ] , DCT_CONST_BITS ) ; v [ 9 ] = _mm_srai_epi32 ( u [ 9 ] , DCT_CONST_BITS ) ; v [ 10 ] = _mm_srai_epi32 ( u [ 10 ] , DCT_CONST_BITS ) ; v [ 11 ] = _mm_srai_epi32 ( u [ 11 ] , DCT_CONST_BITS ) ; v [ 12 ] = _mm_srai_epi32 ( u [ 12 ] , DCT_CONST_BITS ) ; v [ 13 ] = _mm_srai_epi32 ( u [ 13 ] , DCT_CONST_BITS ) ; v [ 14 ] = _mm_srai_epi32 ( u [ 14 ] , DCT_CONST_BITS ) ; v [ 15 ] = _mm_srai_epi32 ( u [ 15 ] , DCT_CONST_BITS ) ; s [ 0 ] = _mm_add_epi16 ( x [ 0 ] , x [ 2 ] ) ; s [ 1 ] = _mm_add_epi16 ( x [ 1 ] , x [ 3 ] ) ; s [ 2 ] = _mm_sub_epi16 ( x [ 0 ] , x [ 2 ] ) ; s [ 3 ] = _mm_sub_epi16 ( x [ 1 ] , x [ 3 ] ) ; s [ 4 ] = _mm_packs_epi32 ( v [ 0 ] , v [ 1 ] ) ; s [ 5 ] = _mm_packs_epi32 ( v [ 2 ] , v [ 3 ] ) ; s [ 6 ] = _mm_packs_epi32 ( v [ 4 ] , v [ 5 ] ) ; s [ 7 ] = _mm_packs_epi32 ( v [ 6 ] , v [ 7 ] ) ; s [ 8 ] = _mm_add_epi16 ( x [ 8 ] , x [ 10 ] ) ; s [ 9 ] = _mm_add_epi16 ( x [ 9 ] , x [ 11 ] ) ; s [ 10 ] = _mm_sub_epi16 ( x [ 8 ] , x [ 10 ] ) ; s [ 11 ] = _mm_sub_epi16 ( x [ 9 ] , x [ 11 ] ) ; s [ 12 ] = _mm_packs_epi32 ( v [ 8 ] , v [ 9 ] ) ; s [ 13 ] = _mm_packs_epi32 ( v [ 10 ] , v [ 11 ] ) ; s [ 14 ] = _mm_packs_epi32 ( v [ 12 ] , v [ 13 ] ) ; s [ 15 ] = _mm_packs_epi32 ( v [ 14 ] , v [ 15 ] ) ; u [ 0 ] = _mm_unpacklo_epi16 ( s [ 2 ] , s [ 3 ] ) ; u [ 1 ] = _mm_unpackhi_epi16 ( s [ 2 ] , s [ 3 ] ) ; u [ 2 ] = _mm_unpacklo_epi16 ( s [ 6 ] , s [ 7 ] ) ; u [ 3 ] = _mm_unpackhi_epi16 ( s [ 6 ] , s [ 7 ] ) ; u [ 4 ] = _mm_unpacklo_epi16 ( s [ 10 ] , s [ 11 ] ) ; u [ 5 ] = _mm_unpackhi_epi16 ( s [ 10 ] , s [ 11 ] ) ; u [ 6 ] = _mm_unpacklo_epi16 ( s [ 14 ] , s [ 15 ] ) ; u [ 7 ] = _mm_unpackhi_epi16 ( s [ 14 ] , s [ 15 ] ) ; v [ 0 ] = _mm_madd_epi16 ( u [ 0 ] , k__cospi_m16_m16 ) ; v [ 1 ] = _mm_madd_epi16 ( u [ 1 ] , k__cospi_m16_m16 ) ; v [ 2 ] = _mm_madd_epi16 ( u [ 0 ] , k__cospi_p16_m16 ) ; v [ 3 ] = _mm_madd_epi16 ( u [ 1 ] , k__cospi_p16_m16 ) ; v [ 4 ] = _mm_madd_epi16 ( u [ 2 ] , k__cospi_p16_p16 ) ; v [ 5 ] = _mm_madd_epi16 ( u [ 3 ] , k__cospi_p16_p16 ) ; v [ 6 ] = _mm_madd_epi16 ( u [ 2 ] , k__cospi_m16_p16 ) ; v [ 7 ] = _mm_madd_epi16 ( u [ 3 ] , k__cospi_m16_p16 ) ; v [ 8 ] = _mm_madd_epi16 ( u [ 4 ] , k__cospi_p16_p16 ) ; v [ 9 ] = _mm_madd_epi16 ( u [ 5 ] , k__cospi_p16_p16 ) ; v [ 10 ] = _mm_madd_epi16 ( u [ 4 ] , k__cospi_m16_p16 ) ; v [ 11 ] = _mm_madd_epi16 ( u [ 5 ] , k__cospi_m16_p16 ) ; v [ 12 ] = _mm_madd_epi16 ( u [ 6 ] , k__cospi_m16_m16 ) ; v [ 13 ] = _mm_madd_epi16 ( u [ 7 ] , k__cospi_m16_m16 ) ; v [ 14 ] = _mm_madd_epi16 ( u [ 6 ] , k__cospi_p16_m16 ) ; v [ 15 ] = _mm_madd_epi16 ( u [ 7 ] , k__cospi_p16_m16 ) ; u [ 0 ] = _mm_add_epi32 ( v [ 0 ] , k__DCT_CONST_ROUNDING ) ; u [ 1 ] = _mm_add_epi32 ( v [ 1 ] , k__DCT_CONST_ROUNDING ) ; u [ 2 ] = _mm_add_epi32 ( v [ 2 ] , k__DCT_CONST_ROUNDING ) ; u [ 3 ] = _mm_add_epi32 ( v [ 3 ] , k__DCT_CONST_ROUNDING ) ; u [ 4 ] = _mm_add_epi32 ( v [ 4 ] , k__DCT_CONST_ROUNDING ) ; u [ 5 ] = _mm_add_epi32 ( v [ 5 ] , k__DCT_CONST_ROUNDING ) ; u [ 6 ] = _mm_add_epi32 ( v [ 6 ] , k__DCT_CONST_ROUNDING ) ; u [ 7 ] = _mm_add_epi32 ( v [ 7 ] , k__DCT_CONST_ROUNDING ) ; u [ 8 ] = _mm_add_epi32 ( v [ 8 ] , k__DCT_CONST_ROUNDING ) ; u [ 9 ] = _mm_add_epi32 ( v [ 9 ] , k__DCT_CONST_ROUNDING ) ; u [ 10 ] = _mm_add_epi32 ( v [ 10 ] , k__DCT_CONST_ROUNDING ) ; u [ 11 ] = _mm_add_epi32 ( v [ 11 ] , k__DCT_CONST_ROUNDING ) ; u [ 12 ] = _mm_add_epi32 ( v [ 12 ] , k__DCT_CONST_ROUNDING ) ; u [ 13 ] = _mm_add_epi32 ( v [ 13 ] , k__DCT_CONST_ROUNDING ) ; u [ 14 ] = _mm_add_epi32 ( v [ 14 ] , k__DCT_CONST_ROUNDING ) ; u [ 15 ] = _mm_add_epi32 ( v [ 15 ] , k__DCT_CONST_ROUNDING ) ; v [ 0 ] = _mm_srai_epi32 ( u [ 0 ] , DCT_CONST_BITS ) ; v [ 1 ] = _mm_srai_epi32 ( u [ 1 ] , DCT_CONST_BITS ) ; v [ 2 ] = _mm_srai_epi32 ( u [ 2 ] , DCT_CONST_BITS ) ; v [ 3 ] = _mm_srai_epi32 ( u [ 3 ] , DCT_CONST_BITS ) ; v [ 4 ] = _mm_srai_epi32 ( u [ 4 ] , DCT_CONST_BITS ) ; v [ 5 ] = _mm_srai_epi32 ( u [ 5 ] , DCT_CONST_BITS ) ; v [ 6 ] = _mm_srai_epi32 ( u [ 6 ] , DCT_CONST_BITS ) ; v [ 7 ] = _mm_srai_epi32 ( u [ 7 ] , DCT_CONST_BITS ) ; v [ 8 ] = _mm_srai_epi32 ( u [ 8 ] , DCT_CONST_BITS ) ; v [ 9 ] = _mm_srai_epi32 ( u [ 9 ] , DCT_CONST_BITS ) ; v [ 10 ] = _mm_srai_epi32 ( u [ 10 ] , DCT_CONST_BITS ) ; v [ 11 ] = _mm_srai_epi32 ( u [ 11 ] , DCT_CONST_BITS ) ; v [ 12 ] = _mm_srai_epi32 ( u [ 12 ] , DCT_CONST_BITS ) ; v [ 13 ] = _mm_srai_epi32 ( u [ 13 ] , DCT_CONST_BITS ) ; v [ 14 ] = _mm_srai_epi32 ( u [ 14 ] , DCT_CONST_BITS ) ; v [ 15 ] = _mm_srai_epi32 ( u [ 15 ] , DCT_CONST_BITS ) ; in [ 0 ] = s [ 0 ] ; in [ 1 ] = _mm_sub_epi16 ( kZero , s [ 8 ] ) ; in [ 2 ] = s [ 12 ] ; in [ 3 ] = _mm_sub_epi16 ( kZero , s [ 4 ] ) ; in [ 4 ] = _mm_packs_epi32 ( v [ 4 ] , v [ 5 ] ) ; in [ 5 ] = _mm_packs_epi32 ( v [ 12 ] , v [ 13 ] ) ; in [ 6 ] = _mm_packs_epi32 ( v [ 8 ] , v [ 9 ] ) ; in [ 7 ] = _mm_packs_epi32 ( v [ 0 ] , v [ 1 ] ) ; in [ 8 ] = _mm_packs_epi32 ( v [ 2 ] , v [ 3 ] ) ; in [ 9 ] = _mm_packs_epi32 ( v [ 10 ] , v [ 11 ] ) ; in [ 10 ] = _mm_packs_epi32 ( v [ 14 ] , v [ 15 ] ) ; in [ 11 ] = _mm_packs_epi32 ( v [ 6 ] , v [ 7 ] ) ; in [ 12 ] = s [ 5 ] ; in [ 13 ] = _mm_sub_epi16 ( kZero , s [ 13 ] ) ; in [ 14 ] = s [ 9 ] ; in [ 15 ] = _mm_sub_epi16 ( kZero , s [ 1 ] ) ; } "," static = _mm_set1_epi16 ( ( int16_t ) = _mm_set1_epi16 ( ( int16_t ) ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1577,CWE-119,"CWE-119 static int frame_max_bits ( const RATE_CONTROL * rc , const VP9_CONFIG * oxcf ) { int64_t max_bits = ( ( int64_t ) rc -> av_per_frame_bandwidth * ( int64_t ) oxcf -> two_pass_vbrmax_section ) / 100 ; if ( max_bits < 0 ) max_bits = 0 ; else if ( max_bits > rc -> max_frame_bandwidth ) max_bits = rc -> max_frame_bandwidth ; return ( int ) max_bits ; } "," rc , const VP9EncoderConfig * oxcf ) ) rc -> avg_frame_bandwidth * ( int64_t ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1578,CWE-190,"CWE-190 static mif_hdr_t * mif_hdr_get ( jas_stream_t * in ) { uchar magicbuf [ MIF_MAGICLEN ] ; char buf [ 4096 ] ; mif_hdr_t * hdr ; bool done ; jas_tvparser_t * tvp ; int id ; hdr = 0 ; tvp = 0 ; if ( jas_stream_read ( in , magicbuf , MIF_MAGICLEN ) != MIF_MAGICLEN ) { goto error ; } if ( magicbuf [ 0 ] != ( MIF_MAGIC >> 24 ) || magicbuf [ 1 ] != ( ( MIF_MAGIC >> 16 ) & 0xff ) || magicbuf [ 2 ] != ( ( MIF_MAGIC >> 8 ) & 0xff ) || magicbuf [ 3 ] != ( MIF_MAGIC & 0xff ) ) { jas_eprintf ( ""error:badsignature\\n"" ) ; goto error ; } if ( ! ( hdr = mif_hdr_create ( 0 ) ) ) { goto error ; } done = false ; do { if ( ! mif_getline ( in , buf , sizeof ( buf ) ) ) { jas_eprintf ( ""mif_getlinefailed\\n"" ) ; goto error ; } if ( buf [ 0 ] == '\\0' ) { continue ; } JAS_DBGLOG ( 10 , ( ""headerline:len=%d;%s\\n"" , strlen ( buf ) , buf ) ) ; if ( ! ( tvp = jas_tvparser_create ( buf ) ) ) { jas_eprintf ( ""jas_tvparser_createfailed\\n"" ) ; goto error ; } if ( jas_tvparser_next ( tvp ) ) { jas_eprintf ( ""cannotgetrecordtype\\n"" ) ; goto error ; } id = jas_taginfo_nonull ( jas_taginfos_lookup ( mif_tags2 , jas_tvparser_gettag ( tvp ) ) ) -> id ; jas_tvparser_destroy ( tvp ) ; tvp = 0 ; switch ( id ) { case MIF_CMPT : if ( mif_process_cmpt ( hdr , buf ) ) { jas_eprintf ( ""cannotgetcomponentinformation\\n"" ) ; goto error ; } break ; case MIF_END : done = 1 ; break ; default : jas_eprintf ( ""invalidheaderinformation:%s\\n"" , buf ) ; goto error ; break ; } } while ( ! done ) ; return hdr ; error : if ( hdr ) { mif_hdr_destroy ( hdr ) ; } if ( tvp ) { jas_tvparser_destroy ( tvp ) ; } return 0 ; } "," in ) { jas_uchar magicbuf [ MIF_MAGICLEN ",mdadams@jasper/d42b2388f7f8e0332c846675133acea151fc557a,CVE-2016-9557,https://github.com/mdadams/jasper/commit/d42b2388f7f8e0332c846675133acea151fc557a,2017-03-23T18:59Z 1579,CWE-119,"CWE-119 void Huff_transmit ( huff_t * huff , int ch , byte * fout ) { int i ; if ( huff -> loc [ ch ] == NULL ) { Huff_transmit ( huff , NYT , fout ) ; for ( i = 7 ; i >= 0 ; i -- ) { add_bit ( ( char ) ( ( ch >> i ) & 0x1 ) , fout ) ; } } else { send ( huff -> loc [ ch ] , NULL , fout ) ; } } "," byte * fout , int maxoffset NYT , fout , maxoffset NULL , fout , maxoffset ",ioquake@ioq3/d2b1d124d4055c2fcbe5126863487c52fd58cca1,CVE-2017-11721,https://github.com/ioquake/ioq3/commit/d2b1d124d4055c2fcbe5126863487c52fd58cca1,2017-08-03T08:29Z 1580,CWE-119,"CWE-119 static void encode_superblock ( VP9_COMP * cpi , TOKENEXTRA * * t , int output_enabled , int mi_row , int mi_col , BLOCK_SIZE bsize ) { VP9_COMMON * const cm = & cpi -> common ; MACROBLOCK * const x = & cpi -> mb ; MACROBLOCKD * const xd = & x -> e_mbd ; MODE_INFO * * mi_8x8 = xd -> mi ; MODE_INFO * mi = mi_8x8 [ 0 ] ; MB_MODE_INFO * mbmi = & mi -> mbmi ; PICK_MODE_CONTEXT * ctx = get_block_context ( x , bsize ) ; unsigned int segment_id = mbmi -> segment_id ; const int mis = cm -> mi_stride ; const int mi_width = num_8x8_blocks_wide_lookup [ bsize ] ; const int mi_height = num_8x8_blocks_high_lookup [ bsize ] ; x -> skip_recode = ! x -> select_txfm_size && mbmi -> sb_type >= BLOCK_8X8 && cpi -> oxcf . aq_mode != COMPLEXITY_AQ && cpi -> oxcf . aq_mode != CYCLIC_REFRESH_AQ && cpi -> sf . allow_skip_recode ; x -> skip_optimize = ctx -> is_coded ; ctx -> is_coded = 1 ; x -> use_lp32x32fdct = cpi -> sf . use_lp32x32fdct ; x -> skip_encode = ( ! output_enabled && cpi -> sf . skip_encode_frame && x -> q_index < QIDX_SKIP_THRESH ) ; if ( x -> skip_encode ) return ; if ( cm -> frame_type == KEY_FRAME ) { if ( cpi -> oxcf . tuning == VP8_TUNE_SSIM ) { adjust_act_zbin ( cpi , x ) ; vp9_update_zbin_extra ( cpi , x ) ; } } else { set_ref_ptrs ( cm , xd , mbmi -> ref_frame [ 0 ] , mbmi -> ref_frame [ 1 ] ) ; if ( cpi -> oxcf . tuning == VP8_TUNE_SSIM ) { adjust_act_zbin ( cpi , x ) ; } cpi -> zbin_mode_boost = get_zbin_mode_boost ( mbmi , cpi -> zbin_mode_boost_enabled ) ; vp9_update_zbin_extra ( cpi , x ) ; } if ( ! is_inter_block ( mbmi ) ) { int plane ; mbmi -> skip = 1 ; for ( plane = 0 ; plane < MAX_MB_PLANE ; ++ plane ) vp9_encode_intra_block_plane ( x , MAX ( bsize , BLOCK_8X8 ) , plane ) ; if ( output_enabled ) sum_intra_stats ( & cm -> counts , mi ) ; vp9_tokenize_sb ( cpi , t , ! output_enabled , MAX ( bsize , BLOCK_8X8 ) ) ; } else { int ref ; const int is_compound = has_second_ref ( mbmi ) ; for ( ref = 0 ; ref < 1 + is_compound ; ++ ref ) { YV12_BUFFER_CONFIG * cfg = get_ref_frame_buffer ( cpi , mbmi -> ref_frame [ ref ] ) ; vp9_setup_pre_planes ( xd , ref , cfg , mi_row , mi_col , & xd -> block_refs [ ref ] -> sf ) ; } vp9_build_inter_predictors_sb ( xd , mi_row , mi_col , MAX ( bsize , BLOCK_8X8 ) ) ; if ( ! x -> skip ) { mbmi -> skip = 1 ; vp9_encode_sb ( x , MAX ( bsize , BLOCK_8X8 ) ) ; vp9_tokenize_sb ( cpi , t , ! output_enabled , MAX ( bsize , BLOCK_8X8 ) ) ; } else { mbmi -> skip = 1 ; if ( output_enabled ) cm -> counts . skip [ vp9_get_skip_context ( xd ) ] [ 1 ] ++ ; reset_skip_context ( xd , MAX ( bsize , BLOCK_8X8 ) ) ; } } if ( output_enabled ) { if ( cm -> tx_mode == TX_MODE_SELECT && mbmi -> sb_type >= BLOCK_8X8 && ! ( is_inter_block ( mbmi ) && ( mbmi -> skip || vp9_segfeature_active ( & cm -> seg , segment_id , SEG_LVL_SKIP ) ) ) ) { ++ get_tx_counts ( max_txsize_lookup [ bsize ] , vp9_get_tx_size_context ( xd ) , & cm -> counts . tx ) [ mbmi -> tx_size ] ; } else { int x , y ; TX_SIZE tx_size ; if ( is_inter_block ( & mi -> mbmi ) ) { tx_size = MIN ( tx_mode_to_biggest_tx_size [ cm -> tx_mode ] , max_txsize_lookup [ bsize ] ) ; } else { tx_size = ( bsize >= BLOCK_8X8 ) ? mbmi -> tx_size : TX_4X4 ; } for ( y = 0 ; y < mi_height ; y ++ ) for ( x = 0 ; x < mi_width ; x ++ ) if ( mi_col + x < cm -> mi_cols && mi_row + y < cm -> mi_rows ) mi_8x8 [ mis * y + x ] -> mbmi . tx_size = tx_size ; } } } "," * cpi , ThreadData * td , , BLOCK_SIZE bsize , PICK_MODE_CONTEXT * ctx x = & td -> mb ; -> mbmi ; const int seg_skip = segfeature_active ( & cm -> seg , mbmi -> segment_id , SEG_LVL_SKIP ) ; const int ! x -> select_tx_size && mbmi -> . allow_skip_recode ; if ( ! x -> skip_recode && ! cpi -> sf . use_nonrd_pick_mode ) memset ( x -> skip_txfm , 0 , sizeof ( x -> skip_txfm ) ) ; ; if ( ! is_inter_block ( mbmi ) ) { int plane ; mbmi -> skip = 1 ; for ( plane = 0 ; plane < MAX_MB_PLANE ; ++ plane ) vp9_encode_intra_block_plane ( x , MAX ( bsize , BLOCK_8X8 ) , plane ) ; if ( output_enabled ) sum_intra_stats ( td -> counts , mi ) ; vp9_tokenize_sb ( cpi , td , t , ! output_enabled , MAX ( bsize , BLOCK_8X8 ) ) ; } else { } else { int ref ; const int is_compound = has_second_ref ( mbmi ) ; [ 1 ] ) ; for ] ) ; assert ( cfg != NULL ) ; ) ; } if ( ! ( cpi -> sf . reuse_inter_pred_sby && ctx -> pred_pixel_ready ) || seg_skip ) vp9_build_inter_predictors_sby ( xd , ) ) ; vp9_build_inter_predictors_sbuv ( xd , mi_row , mi_col , MAX ( bsize , BLOCK_8X8 ) ) ; vp9_encode_sb ( vp9_tokenize_sb ( cpi , td ) ) ; } if ( -> skip || seg_skip ) ) ) bsize ] , get_tx_size_context ( xd ) ) , & td -> counts -> tx ) [ tx_size ; } ++ td -> counts -> tx . tx_totals [ mbmi -> tx_size ] ; ++ td -> counts -> tx . tx_totals [ get_uv_tx_size ( mbmi , & xd -> plane [ 1 ] ) ] ; ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1581,CWE-119,"CWE-119 static int usb_parse_configuration ( struct usb_device * dev , int cfgidx , struct usb_host_config * config , unsigned char * buffer , int size ) { struct device * ddev = & dev -> dev ; unsigned char * buffer0 = buffer ; int cfgno ; int nintf , nintf_orig ; int i , j , n ; struct usb_interface_cache * intfc ; unsigned char * buffer2 ; int size2 ; struct usb_descriptor_header * header ; int len , retval ; u8 inums [ USB_MAXINTERFACES ] , nalts [ USB_MAXINTERFACES ] ; unsigned iad_num = 0 ; memcpy ( & config -> desc , buffer , USB_DT_CONFIG_SIZE ) ; if ( config -> desc . bDescriptorType != USB_DT_CONFIG || config -> desc . bLength < USB_DT_CONFIG_SIZE || config -> desc . bLength > size ) { dev_err ( ddev , ""invaliddescriptorforconfigindex%d:"" ""type=0x%X,length=%d\\n"" , cfgidx , config -> desc . bDescriptorType , config -> desc . bLength ) ; return - EINVAL ; } cfgno = config -> desc . bConfigurationValue ; buffer += config -> desc . bLength ; size -= config -> desc . bLength ; nintf = nintf_orig = config -> desc . bNumInterfaces ; if ( nintf > USB_MAXINTERFACES ) { dev_warn ( ddev , ""config%dhastoomanyinterfaces:%d,"" ""usingmaximumallowed:%d\\n"" , cfgno , nintf , USB_MAXINTERFACES ) ; nintf = USB_MAXINTERFACES ; } n = 0 ; for ( ( buffer2 = buffer , size2 = size ) ; size2 > 0 ; ( buffer2 += header -> bLength , size2 -= header -> bLength ) ) { if ( size2 < sizeof ( struct usb_descriptor_header ) ) { dev_warn ( ddev , ""config%ddescriptorhas%dexcess"" ""byte%s,ignoring\\n"" , cfgno , size2 , plural ( size2 ) ) ; break ; } header = ( struct usb_descriptor_header * ) buffer2 ; if ( ( header -> bLength > size2 ) || ( header -> bLength < 2 ) ) { dev_warn ( ddev , ""config%dhasaninvaliddescriptor"" ""oflength%d,skippingremainderoftheconfig\\n"" , cfgno , header -> bLength ) ; break ; } if ( header -> bDescriptorType == USB_DT_INTERFACE ) { struct usb_interface_descriptor * d ; int inum ; d = ( struct usb_interface_descriptor * ) header ; if ( d -> bLength < USB_DT_INTERFACE_SIZE ) { dev_warn ( ddev , ""config%dhasaninvalid"" ""interfacedescriptoroflength%d,"" ""skipping\\n"" , cfgno , d -> bLength ) ; continue ; } inum = d -> bInterfaceNumber ; if ( ( dev -> quirks & USB_QUIRK_HONOR_BNUMINTERFACES ) && n >= nintf_orig ) { dev_warn ( ddev , ""config%dhasmoreinterface"" ""descriptors,thanitdeclaresin"" ""bNumInterfaces,ignoringinterface"" ""number:%d\\n"" , cfgno , inum ) ; continue ; } if ( inum >= nintf_orig ) dev_warn ( ddev , ""config%dhasaninvalid"" ""interfacenumber:%dbutmaxis%d\\n"" , cfgno , inum , nintf_orig - 1 ) ; for ( i = 0 ; i < n ; ++ i ) { if ( inums [ i ] == inum ) break ; } if ( i < n ) { if ( nalts [ i ] < 255 ) ++ nalts [ i ] ; } else if ( n < USB_MAXINTERFACES ) { inums [ n ] = inum ; nalts [ n ] = 1 ; ++ n ; } } else if ( header -> bDescriptorType == USB_DT_INTERFACE_ASSOCIATION ) { if ( iad_num == USB_MAXIADS ) { dev_warn ( ddev , ""foundmoreInterface"" ""AssociationDescriptors"" ""thanallocatedforin"" ""configuration%d\\n"" , cfgno ) ; } else { config -> intf_assoc [ iad_num ] = ( struct usb_interface_assoc_descriptor * ) header ; iad_num ++ ; } } else if ( header -> bDescriptorType == USB_DT_DEVICE || header -> bDescriptorType == USB_DT_CONFIG ) dev_warn ( ddev , ""config%dcontainsanunexpected"" ""descriptoroftype0x%X,skipping\\n"" , cfgno , header -> bDescriptorType ) ; } size = buffer2 - buffer ; config -> desc . wTotalLength = cpu_to_le16 ( buffer2 - buffer0 ) ; if ( n != nintf ) dev_warn ( ddev , ""config%dhas%dinterface%s,differentfrom"" ""thedescriptor\'svalue:%d\\n"" , cfgno , n , plural ( n ) , nintf_orig ) ; else if ( n == 0 ) dev_warn ( ddev , ""config%dhasnointerfaces?\\n"" , cfgno ) ; config -> desc . bNumInterfaces = nintf = n ; for ( i = 0 ; i < nintf ; ++ i ) { for ( j = 0 ; j < nintf ; ++ j ) { if ( inums [ j ] == i ) break ; } if ( j >= nintf ) dev_warn ( ddev , ""config%dhasnointerfacenumber"" ""%d\\n"" , cfgno , i ) ; } for ( i = 0 ; i < nintf ; ++ i ) { j = nalts [ i ] ; if ( j > USB_MAXALTSETTING ) { dev_warn ( ddev , ""toomanyalternatesettingsfor"" ""config%dinterface%d:%d,"" ""usingmaximumallowed:%d\\n"" , cfgno , inums [ i ] , j , USB_MAXALTSETTING ) ; nalts [ i ] = j = USB_MAXALTSETTING ; } len = sizeof ( * intfc ) + sizeof ( struct usb_host_interface ) * j ; config -> intf_cache [ i ] = intfc = kzalloc ( len , GFP_KERNEL ) ; if ( ! intfc ) return - ENOMEM ; kref_init ( & intfc -> ref ) ; } config -> extra = buffer ; i = find_next_descriptor ( buffer , size , USB_DT_INTERFACE , USB_DT_INTERFACE , & n ) ; config -> extralen = i ; if ( n > 0 ) dev_dbg ( ddev , ""skipped%ddescriptor%safter%s\\n"" , n , plural ( n ) , ""configuration"" ) ; buffer += i ; size -= i ; while ( size > 0 ) { retval = usb_parse_interface ( ddev , cfgno , config , buffer , size , inums , nalts ) ; if ( retval < 0 ) return retval ; buffer += retval ; size -= retval ; } for ( i = 0 ; i < nintf ; ++ i ) { intfc = config -> intf_cache [ i ] ; for ( j = 0 ; j < intfc -> num_altsetting ; ++ j ) { for ( n = 0 ; n < intfc -> num_altsetting ; ++ n ) { if ( intfc -> altsetting [ n ] . desc . bAlternateSetting == j ) break ; } if ( n >= intfc -> num_altsetting ) dev_warn ( ddev , ""config%dinterface%dhasno"" ""altsetting%d\\n"" , cfgno , inums [ i ] , j ) ; } } return 0 ; } "," USB_DT_INTERFACE_ASSOCIATION ) { struct usb_interface_assoc_descriptor * d ; d = ( struct usb_interface_assoc_descriptor * ) header ; if ( d -> bLength < USB_DT_INTERFACE_ASSOCIATION_SIZE ) { dev_warn ( ddev , ""config%dhasaninvalidinterfaceassociationdescriptoroflength%d,skipping\\n"" , cfgno , d -> bLength ) ; continue ; } iad_num ] = d ; iad_num ++ ",torvalds@linux/bd7a3fe770ebd8391d1c7d072ff88e9e76d063eb,CVE-2017-16531,https://github.com/torvalds/linux/commit/bd7a3fe770ebd8391d1c7d072ff88e9e76d063eb,2017-11-04T01:29Z 1582,CWE-119,"CWE-119 static int smbhash ( unsigned char * out , const unsigned char * in , unsigned char * key ) { int rc ; unsigned char key2 [ 8 ] ; struct crypto_skcipher * tfm_des ; struct scatterlist sgin , sgout ; struct skcipher_request * req ; str_to_key ( key , key2 ) ; tfm_des = crypto_alloc_skcipher ( ""ecb(des)"" , 0 , CRYPTO_ALG_ASYNC ) ; if ( IS_ERR ( tfm_des ) ) { rc = PTR_ERR ( tfm_des ) ; cifs_dbg ( VFS , ""couldnotallocatedescryptoAPI\\n"" ) ; goto smbhash_err ; } req = skcipher_request_alloc ( tfm_des , GFP_KERNEL ) ; if ( ! req ) { rc = - ENOMEM ; cifs_dbg ( VFS , ""couldnotallocatedescryptoAPI\\n"" ) ; goto smbhash_free_skcipher ; } crypto_skcipher_setkey ( tfm_des , key2 , 8 ) ; sg_init_one ( & sgin , in , 8 ) ; sg_init_one ( & sgout , out , 8 ) ; skcipher_request_set_callback ( req , 0 , NULL , NULL ) ; skcipher_request_set_crypt ( req , & sgin , & sgout , 8 , NULL ) ; rc = crypto_skcipher_encrypt ( req ) ; if ( rc ) cifs_dbg ( VFS , ""couldnotencryptcryptkeyrc:%d\\n"" , rc ) ; skcipher_request_free ( req ) ; smbhash_free_skcipher : crypto_free_skcipher ( tfm_des ) ; smbhash_err : return rc ; } "," key ) { unsigned char key2 ] ; struct crypto_cipher * tfm_des ; str_to_key ( ; tfm_des = crypto_alloc_cipher ( ""des"" , 0 , , 0 , 0 ) ; if ) ) { cifs_dbg ( VFS ""couldnotallocatedescryptoAPI\\n"" ) ; return PTR_ERR ( tfm_des ) ; } crypto_cipher_setkey ( tfm_des , 8 ) ; crypto_cipher_encrypt_one ( tfm_des , out , in ) ; crypto_free_cipher ( tfm_des ) tfm_des ) ; return 0 ; } ",torvalds@linux/06deeec77a5a689cc94b21a8a91a76e42176685d,CVE-2016-10154,https://github.com/torvalds/linux/commit/06deeec77a5a689cc94b21a8a91a76e42176685d,2017-02-06T06:59Z 1583,CWE-119,"CWE-119 static inline void header_put_be_int ( SF_PRIVATE * psf , int x ) { if ( psf -> headindex < SIGNED_SIZEOF ( psf -> header ) - 4 ) { psf -> header [ psf -> headindex ++ ] = ( x >> 24 ) ; psf -> header [ psf -> headindex ++ ] = ( x >> 16 ) ; psf -> header [ psf -> headindex ++ ] = ( x >> 8 ) ; psf -> header [ psf -> headindex ++ ] = x ; } ; } "," x ) { psf -> header psf -> header . ptr [ psf -> header psf -> header . indx ++ ] = psf -> header . ptr [ psf -> header . indx ++ ] = psf -> header . ptr [ psf -> header . indx ++ ] = psf -> header . ptr [ psf -> header . indx ++ ] = x ; } ",erikd@libsndfile/708e996c87c5fae77b104ccfeb8f6db784c32074,CVE-2017-7586,https://github.com/erikd/libsndfile/commit/708e996c87c5fae77b104ccfeb8f6db784c32074,2017-04-07T20:59Z 1584,CWE-129,"CWE-129 static int cbs_av1_read_uvlc ( CodedBitstreamContext * ctx , GetBitContext * gbc , const char * name , uint32_t * write_to , uint32_t range_min , uint32_t range_max ) { uint32_t value ; int position , zeroes , i , j ; char bits [ 65 ] ; if ( ctx -> trace_enable ) position = get_bits_count ( gbc ) ; zeroes = i = 0 ; while ( 1 ) { if ( get_bits_left ( gbc ) < zeroes + 1 ) { av_log ( ctx -> log_ctx , AV_LOG_ERROR , ""Invaliduvlccodeat"" ""%s:bitstreamended.\\n"" , name ) ; return AVERROR_INVALIDDATA ; } if ( get_bits1 ( gbc ) ) { bits [ i ++ ] = '1' ; break ; } else { bits [ i ++ ] = '0' ; ++ zeroes ; } } if ( zeroes >= 32 ) { value = MAX_UINT_BITS ( 32 ) ; } else { value = get_bits_long ( gbc , zeroes ) ; for ( j = 0 ; j < zeroes ; j ++ ) bits [ i ++ ] = ( value >> ( zeroes - j - 1 ) & 1 ) ? '1' : '0' ; value += ( 1 << zeroes ) - 1 ; } if ( ctx -> trace_enable ) { bits [ i ] = 0 ; ff_cbs_trace_syntax_element ( ctx , position , name , NULL , bits , value ) ; } if ( value < range_min || value > range_max ) { av_log ( ctx -> log_ctx , AV_LOG_ERROR , ""%soutofrange:"" ""%"" PRIu32 "",butmustbein[%"" PRIu32 "",%"" PRIu32 ""].\\n"" , name , value , range_min , range_max ) ; return AVERROR_INVALIDDATA ; } * write_to = value ; return 0 ; } "," ) { uint32_t zeroes , bits_value , ; int position ; if ( ; zeroes = 0 ; while gbc ) < 1 ) { gbc ) ) break ; ++ zeroes ; } if ( zeroes >= 32 ) { value = MAX_UINT_BITS ( 32 ) ; } else { if ( get_bits_left ( gbc ) < zeroes ) { av_log ( ctx -> log_ctx , AV_LOG_ERROR , ""Invaliduvlccodeat"" ""%s:bitstreamended.\\n"" , name ) ; return AVERROR_INVALIDDATA ; } bits_value = get_bits_long ( gbc , zeroes ) ; value = bits_value + ( UINT32_C ( 1 ) << zeroes ) - 1 ; } if ( ctx -> trace_enable ) { char bits [ 65 ] ; int i , j , k ; if ( zeroes >= 32 ) { while ( zeroes > 32 ) { k = FFMIN ( zeroes - 32 , 32 ) ; for ( i = 0 ; i < k ; i ++ ) bits [ i ] = '0' ; bits [ i ] = 0 ; ff_cbs_trace_syntax_element ( ctx , position , name , NULL , bits , 0 ) ; zeroes -= k ; position += k ; } } for ( i = 0 ; i < zeroes ; i ++ ) bits [ i ] = '0' ; bits [ i = '1' ; if ( zeroes < 32 ) { for ( j ] = ( bits_value >> ( zeroes : '0' ; } bits [ i ",FFmpeg@FFmpeg/b97a4b658814b2de8b9f2a3bce491c002d34de31,CVE-2019-1000016,https://github.com/FFmpeg/FFmpeg/commit/b97a4b658814b2de8b9f2a3bce491c002d34de31,2019-02-04T21:29Z 1585,CWE-200,"CWE-200 static void adjust_branches ( struct bpf_prog * prog , int pos , int delta ) { struct bpf_insn * insn = prog -> insnsi ; int insn_cnt = prog -> len ; int i ; for ( i = 0 ; i < insn_cnt ; i ++ , insn ++ ) { if ( BPF_CLASS ( insn -> code ) != BPF_JMP || BPF_OP ( insn -> code ) == BPF_CALL || BPF_OP ( insn -> code ) == BPF_EXIT ) continue ; if ( i < pos && i + insn -> off + 1 > pos ) insn -> off += delta ; else if ( i > pos && i + insn -> off + 1 < pos ) insn -> off -= delta ; } } "," i > pos + delta off + 1 <= pos + delta ) insn -> ",torvalds@linux/a1b14d27ed0965838350f1377ff97c93ee383492,CVE-2016-2383,https://github.com/torvalds/linux/commit/a1b14d27ed0965838350f1377ff97c93ee383492,2016-04-27T17:59Z 1586,CWE-000,"CWE-000 static bool nested_vmx_exit_handled ( struct kvm_vcpu * vcpu ) { u32 intr_info = vmcs_read32 ( VM_EXIT_INTR_INFO ) ; struct vcpu_vmx * vmx = to_vmx ( vcpu ) ; struct vmcs12 * vmcs12 = get_vmcs12 ( vcpu ) ; u32 exit_reason = vmx -> exit_reason ; trace_kvm_nested_vmexit ( kvm_rip_read ( vcpu ) , exit_reason , vmcs_readl ( EXIT_QUALIFICATION ) , vmx -> idt_vectoring_info , intr_info , vmcs_read32 ( VM_EXIT_INTR_ERROR_CODE ) , KVM_ISA_VMX ) ; if ( vmx -> nested . nested_run_pending ) return 0 ; if ( unlikely ( vmx -> fail ) ) { pr_info_ratelimited ( ""%sfailedvmentry%x\\n"" , __func__ , vmcs_read32 ( VM_INSTRUCTION_ERROR ) ) ; return 1 ; } switch ( exit_reason ) { case EXIT_REASON_EXCEPTION_NMI : if ( ! is_exception ( intr_info ) ) return 0 ; else if ( is_page_fault ( intr_info ) ) return enable_ept ; else if ( is_no_device ( intr_info ) && ! ( vmcs12 -> guest_cr0 & X86_CR0_TS ) ) return 0 ; return vmcs12 -> exception_bitmap & ( 1u << ( intr_info & INTR_INFO_VECTOR_MASK ) ) ; case EXIT_REASON_EXTERNAL_INTERRUPT : return 0 ; case EXIT_REASON_TRIPLE_FAULT : return 1 ; case EXIT_REASON_PENDING_INTERRUPT : return nested_cpu_has ( vmcs12 , CPU_BASED_VIRTUAL_INTR_PENDING ) ; case EXIT_REASON_NMI_WINDOW : return nested_cpu_has ( vmcs12 , CPU_BASED_VIRTUAL_NMI_PENDING ) ; case EXIT_REASON_TASK_SWITCH : return 1 ; case EXIT_REASON_CPUID : if ( kvm_register_read ( vcpu , VCPU_REGS_RAX ) == 0xa ) return 0 ; return 1 ; case EXIT_REASON_HLT : return nested_cpu_has ( vmcs12 , CPU_BASED_HLT_EXITING ) ; case EXIT_REASON_INVD : return 1 ; case EXIT_REASON_INVLPG : return nested_cpu_has ( vmcs12 , CPU_BASED_INVLPG_EXITING ) ; case EXIT_REASON_RDPMC : return nested_cpu_has ( vmcs12 , CPU_BASED_RDPMC_EXITING ) ; case EXIT_REASON_RDTSC : return nested_cpu_has ( vmcs12 , CPU_BASED_RDTSC_EXITING ) ; case EXIT_REASON_VMCALL : case EXIT_REASON_VMCLEAR : case EXIT_REASON_VMLAUNCH : case EXIT_REASON_VMPTRLD : case EXIT_REASON_VMPTRST : case EXIT_REASON_VMREAD : case EXIT_REASON_VMRESUME : case EXIT_REASON_VMWRITE : case EXIT_REASON_VMOFF : case EXIT_REASON_VMON : case EXIT_REASON_INVEPT : return 1 ; case EXIT_REASON_CR_ACCESS : return nested_vmx_exit_handled_cr ( vcpu , vmcs12 ) ; case EXIT_REASON_DR_ACCESS : return nested_cpu_has ( vmcs12 , CPU_BASED_MOV_DR_EXITING ) ; case EXIT_REASON_IO_INSTRUCTION : return nested_vmx_exit_handled_io ( vcpu , vmcs12 ) ; case EXIT_REASON_MSR_READ : case EXIT_REASON_MSR_WRITE : return nested_vmx_exit_handled_msr ( vcpu , vmcs12 , exit_reason ) ; case EXIT_REASON_INVALID_STATE : return 1 ; case EXIT_REASON_MWAIT_INSTRUCTION : return nested_cpu_has ( vmcs12 , CPU_BASED_MWAIT_EXITING ) ; case EXIT_REASON_MONITOR_INSTRUCTION : return nested_cpu_has ( vmcs12 , CPU_BASED_MONITOR_EXITING ) ; case EXIT_REASON_PAUSE_INSTRUCTION : return nested_cpu_has ( vmcs12 , CPU_BASED_PAUSE_EXITING ) || nested_cpu_has2 ( vmcs12 , SECONDARY_EXEC_PAUSE_LOOP_EXITING ) ; case EXIT_REASON_MCE_DURING_VMENTRY : return 0 ; case EXIT_REASON_TPR_BELOW_THRESHOLD : return nested_cpu_has ( vmcs12 , CPU_BASED_TPR_SHADOW ) ; case EXIT_REASON_APIC_ACCESS : return nested_cpu_has2 ( vmcs12 , SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES ) ; case EXIT_REASON_EPT_VIOLATION : return 0 ; case EXIT_REASON_EPT_MISCONFIG : return 0 ; case EXIT_REASON_WBINVD : return nested_cpu_has2 ( vmcs12 , SECONDARY_EXEC_WBINVD_EXITING ) ; case EXIT_REASON_XSETBV : return 1 ; default : return 1 ; } } "," case EXIT_REASON_INVEPT : case EXIT_REASON_INVVPID : ",torvalds@linux/a642fc305053cc1c6e47e4f4df327895747ab485,CVE-2014-3646,https://github.com/torvalds/linux/commit/a642fc305053cc1c6e47e4f4df327895747ab485,2014-11-10T11:55Z 1587,CWE-20,"CWE-20 error_t httpParseParam ( const char_t * * pos , HttpParam * param ) { error_t error ; size_t i ; uint8_t c ; bool_t escapeFlag ; bool_t separatorFound ; const char_t * p ; if ( pos == NULL || param == NULL ) return ERROR_INVALID_PARAMETER ; param -> name = NULL ; param -> nameLen = 0 ; param -> value = NULL ; param -> valueLen = 0 ; escapeFlag = FALSE ; separatorFound = FALSE ; error = ERROR_IN_PROGRESS ; i = 0 ; p = * pos ; while ( error == ERROR_IN_PROGRESS ) { c = ( uint8_t ) p [ i ] ; if ( param -> name == NULL ) { if ( c == '\\0' ) { error = ERROR_NOT_FOUND ; } else if ( c == '' || c == '\\t' || c == ',' || c == ';' ) { } else if ( isalnum ( c ) || strchr ( ""!#$%&\'*+-.^_`|~"" , c ) || c >= 128 ) { param -> name = p + i ; } else { error = ERROR_INVALID_SYNTAX ; } } else if ( param -> nameLen == 0 ) { if ( c == '\\0' || c == ',' || c == ';' ) { param -> nameLen = p + i - param -> name ; error = NO_ERROR ; } else if ( c == '' || c == '\\t' ) { param -> nameLen = p + i - param -> name ; } else if ( c == '=' ) { separatorFound = TRUE ; param -> nameLen = p + i - param -> name ; } else if ( isalnum ( c ) || strchr ( ""!#$%&\'*+-.^_`|~"" , c ) || c >= 128 ) { } else { error = ERROR_INVALID_SYNTAX ; } } else if ( ! separatorFound ) { if ( c == '\\0' || c == ',' || c == ';' ) { error = NO_ERROR ; } else if ( c == '' || c == '\\t' ) { } else if ( c == '=' ) { separatorFound = TRUE ; } else if ( c == \'\\""\' ) { i = param -> name + param -> nameLen - p ; error = NO_ERROR ; } else if ( isalnum ( c ) || strchr ( ""!#$%&\'*+-.^_`|~"" , c ) || c >= 128 ) { i = param -> name + param -> nameLen - p ; error = NO_ERROR ; } else { error = ERROR_INVALID_SYNTAX ; } } else if ( param -> value == NULL ) { if ( c == '\\0' || c == ',' || c == ';' ) { error = NO_ERROR ; } else if ( c == '' || c == '\\t' ) { } else if ( c == \'\\""\' ) { param -> value = p + i ; } else if ( isalnum ( c ) || strchr ( ""!#$%&\'*+-.^_`|~"" , c ) || c >= 128 ) { param -> value = p + i ; } else { error = ERROR_INVALID_SYNTAX ; } } else { if ( param -> value [ 0 ] == \'\\""\' ) { if ( c == '\\0' ) { error = ERROR_INVALID_SYNTAX ; } else if ( escapeFlag ) { escapeFlag = FALSE ; } else if ( c == '\\\\' ) { escapeFlag = TRUE ; } else if ( c == \'\\""\' ) { i ++ ; param -> valueLen = p + i - param -> value ; error = NO_ERROR ; } else if ( isprint ( c ) || c == '\\t' || c >= 128 ) { } else { error = ERROR_INVALID_SYNTAX ; } } else { if ( c == '\\0' || c == '' || c == '\\t' || c == ',' || c == ';' ) { param -> valueLen = p + i - param -> value ; error = NO_ERROR ; } else if ( isalnum ( c ) || strchr ( ""!#$%&\'*+-.^_`|~"" , c ) || c >= 128 ) { } else { error = ERROR_INVALID_SYNTAX ; } } } if ( error == ERROR_IN_PROGRESS ) i ++ ; } if ( param -> valueLen >= 2 && param -> value [ 0 ] == \'\\""\' ) { param -> value ++ ; param -> valueLen -= 2 ; } * pos = p + i ; return error ; } "," c ) || osStrchr ( ""!#$%&\'*+-.^_`|~"" , c ) || osStrchr ( ""!#$%&\'*+-.^_`|~"" , c ) || osStrchr ( ""!#$%&\'*+-.^_`|~"" , c ) || osStrchr ( ""!#$%&\'*+-.^_`|~"" , c ) || osStrchr ( ""!#$%&\'*+-.^_`|~"" , ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 1588,CWE-416,"CWE-416 static void ndpi_reset_packet_line_info ( struct ndpi_packet_struct * packet ) { packet -> parsed_lines = 0 , packet -> empty_line_position_set = 0 , packet -> host_line . ptr = NULL , packet -> host_line . len = 0 , packet -> referer_line . ptr = NULL , packet -> referer_line . len = 0 , packet -> content_line . ptr = NULL , packet -> content_line . len = 0 , packet -> accept_line . ptr = NULL , packet -> accept_line . len = 0 , packet -> user_agent_line . ptr = NULL , packet -> user_agent_line . len = 0 , packet -> http_url_name . ptr = NULL , packet -> http_url_name . len = 0 , packet -> http_encoding . ptr = NULL , packet -> http_encoding . len = 0 , packet -> http_transfer_encoding . ptr = NULL , packet -> http_transfer_encoding . len = 0 , packet -> http_contentlen . ptr = NULL , packet -> http_contentlen . len = 0 , packet -> http_cookie . ptr = NULL , packet -> http_cookie . len = 0 , packet -> http_origin . len = 0 , packet -> http_origin . ptr = NULL , packet -> http_x_session_type . ptr = NULL , packet -> http_x_session_type . len = 0 , packet -> server_line . ptr = NULL , packet -> server_line . len = 0 , packet -> http_method . ptr = NULL , packet -> http_method . len = 0 , packet -> http_response . ptr = NULL , packet -> http_response . len = 0 , packet -> http_num_headers = 0 ; } "," , packet -> content_disposition_line . ptr = NULL , packet -> content_disposition_line . len = 0 , packet -> ",ntop@nDPI/6a9f5e4f7c3fd5ddab3e6727b071904d76773952,CVE-2020-15475,https://github.com/ntop/nDPI/commit/6a9f5e4f7c3fd5ddab3e6727b071904d76773952,2020-07-01T11:15Z 1589,CWE-20,"CWE-20 static void * proc_pid_follow_link ( struct dentry * dentry , struct nameidata * nd ) { struct inode * inode = dentry -> d_inode ; int error = - EACCES ; path_put ( & nd -> path ) ; if ( ! proc_fd_access_allowed ( inode ) ) goto out ; error = PROC_I ( inode ) -> op . proc_get_link ( inode , & nd -> path ) ; nd -> last_type = LAST_BIND ; out : return ERR_PTR ( error ) ; } "," path ) ; out : return ",torvalds@linux/86acdca1b63e6890540fa19495cfc708beff3d8b,CVE-2014-0203,https://github.com/torvalds/linux/commit/86acdca1b63e6890540fa19495cfc708beff3d8b,2014-06-23T11:21Z 1590,CWE-617,"CWE-617 static int lookup1_values ( int entries , int dim ) { int r = ( int ) floor ( exp ( ( float ) log ( ( float ) entries ) / dim ) ) ; if ( ( int ) floor ( pow ( ( float ) r + 1 , dim ) ) <= entries ) ++ r ; assert ( pow ( ( float ) r + 1 , dim ) > entries ) ; assert ( ( int ) floor ( pow ( ( float ) r , dim ) ) <= entries ) ; return r ; } "," ++ r ; if ( pow ( , dim ) <= entries ) return - 1 ; if ( ( int dim ) ) > entries ) return - 1 ; return r ",nothings@stb/98fdfc6df88b1e34a736d5e126e6c8139c8de1a6,CVE-2019-13223,https://github.com/nothings/stb/commit/98fdfc6df88b1e34a736d5e126e6c8139c8de1a6,2019-08-15T17:15Z 1591,CWE-20,"CWE-20 static MagickBooleanType ReadDXT1 ( Image * image , DDSInfo * dds_info , ExceptionInfo * exception ) { DDSColors colors ; PixelPacket * q ; register ssize_t i , x ; size_t bits ; ssize_t j , y ; unsigned char code ; unsigned short c0 , c1 ; for ( y = 0 ; y < ( ssize_t ) dds_info -> height ; y += 4 ) { for ( x = 0 ; x < ( ssize_t ) dds_info -> width ; x += 4 ) { q = QueueAuthenticPixels ( image , x , y , Min ( 4 , dds_info -> width - x ) , Min ( 4 , dds_info -> height - y ) , exception ) ; if ( q == ( PixelPacket * ) NULL ) return MagickFalse ; c0 = ReadBlobLSBShort ( image ) ; c1 = ReadBlobLSBShort ( image ) ; bits = ReadBlobLSBLong ( image ) ; CalculateColors ( c0 , c1 , & colors , MagickFalse ) ; for ( j = 0 ; j < 4 ; j ++ ) { for ( i = 0 ; i < 4 ; i ++ ) { if ( ( x + i ) < ( ssize_t ) dds_info -> width && ( y + j ) < ( ssize_t ) dds_info -> height ) { code = ( unsigned char ) ( ( bits >> ( ( j * 4 + i ) * 2 ) ) & 0x3 ) ; SetPixelRed ( q , ScaleCharToQuantum ( colors . r [ code ] ) ) ; SetPixelGreen ( q , ScaleCharToQuantum ( colors . g [ code ] ) ) ; SetPixelBlue ( q , ScaleCharToQuantum ( colors . b [ code ] ) ) ; SetPixelOpacity ( q , ScaleCharToQuantum ( colors . a [ code ] ) ) ; if ( colors . a [ code ] && image -> matte == MagickFalse ) image -> matte = MagickTrue ; q ++ ; } } } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) return MagickFalse ; } } SkipDXTMipmaps ( image , dds_info , 8 ) ; return MagickTrue ; } "," , y , MagickMin ( 4 , x ) , MagickMin ( 4 , ; } } return ( dds_info , 8 , exception ) ) ; } ",ImageMagick@ImageMagick/d7325bac173492b358417a0ad49fabad44447d52,CVE-2014-9907,https://github.com/ImageMagick/ImageMagick/commit/d7325bac173492b358417a0ad49fabad44447d52,2017-04-19T14:59Z 1592,CWE-665,"CWE-665 static int br_parse_ip_options ( struct sk_buff * skb ) { struct ip_options * opt ; struct iphdr * iph ; struct net_device * dev = skb -> dev ; u32 len ; iph = ip_hdr ( skb ) ; opt = & ( IPCB ( skb ) -> opt ) ; if ( iph -> ihl < 5 || iph -> version != 4 ) goto inhdr_error ; if ( ! pskb_may_pull ( skb , iph -> ihl * 4 ) ) goto inhdr_error ; iph = ip_hdr ( skb ) ; if ( unlikely ( ip_fast_csum ( ( u8 * ) iph , iph -> ihl ) ) ) goto inhdr_error ; len = ntohs ( iph -> tot_len ) ; if ( skb -> len < len ) { IP_INC_STATS_BH ( dev_net ( dev ) , IPSTATS_MIB_INTRUNCATEDPKTS ) ; goto drop ; } else if ( len < ( iph -> ihl * 4 ) ) goto inhdr_error ; if ( pskb_trim_rcsum ( skb , len ) ) { IP_INC_STATS_BH ( dev_net ( dev ) , IPSTATS_MIB_INDISCARDS ) ; goto drop ; } if ( iph -> ihl == 5 ) { memset ( IPCB ( skb ) , 0 , sizeof ( struct inet_skb_parm ) ) ; return 0 ; } opt -> optlen = iph -> ihl * 4 - sizeof ( struct iphdr ) ; if ( ip_options_compile ( dev_net ( dev ) , opt , skb ) ) goto inhdr_error ; if ( unlikely ( opt -> srr ) ) { struct in_device * in_dev = __in_dev_get_rcu ( dev ) ; if ( in_dev && ! IN_DEV_SOURCE_ROUTE ( in_dev ) ) goto drop ; if ( ip_options_rcv_srr ( skb ) ) goto drop ; } return 0 ; inhdr_error : IP_INC_STATS_BH ( dev_net ( dev ) , IPSTATS_MIB_INHDRERRORS ) ; drop : return - 1 ; } "," drop ; } memset ( IPCB ( skb ) , 0 , sizeof ( struct inet_skb_parm ) ) ; == 5 ) return 0 ; return 0 ; opt -> optlen ",torvalds@linux/f8e9881c2aef1e982e5abc25c046820cd0b7cf64,CVE-2011-4087,https://github.com/torvalds/linux/commit/f8e9881c2aef1e982e5abc25c046820cd0b7cf64,2013-06-08T13:05Z 1593,CWE-704,"CWE-704 static void merge_param ( HashTable * params , zval * zdata , zval * * * current_param , zval * * * current_args TSRMLS_DC ) { zval * * ptr , * * zdata_ptr ; php_http_array_hashkey_t hkey = php_http_array_hashkey_init ( 0 ) ; # if 0 { zval tmp ; INIT_PZVAL_ARRAY ( & tmp , params ) ; fprintf ( stderr , ""params="" ) ; zend_print_zval_r ( & tmp , 1 TSRMLS_CC ) ; fprintf ( stderr , ""\\n"" ) ; } # endif hkey . type = zend_hash_get_current_key_ex ( Z_ARRVAL_P ( zdata ) , & hkey . str , & hkey . len , & hkey . num , hkey . dup , NULL ) ; if ( ( hkey . type == HASH_KEY_IS_STRING && ! zend_hash_exists ( params , hkey . str , hkey . len ) ) || ( hkey . type == HASH_KEY_IS_LONG && ! zend_hash_index_exists ( params , hkey . num ) ) ) { zval * tmp , * arg , * * args ; zend_hash_get_current_data ( Z_ARRVAL_P ( zdata ) , ( void * ) & ptr ) ; Z_ADDREF_PP ( ptr ) ; MAKE_STD_ZVAL ( tmp ) ; array_init ( tmp ) ; add_assoc_zval_ex ( tmp , ZEND_STRS ( ""value"" ) , * ptr ) ; MAKE_STD_ZVAL ( arg ) ; array_init ( arg ) ; zend_hash_update ( Z_ARRVAL_P ( tmp ) , ""arguments"" , sizeof ( ""arguments"" ) , ( void * ) & arg , sizeof ( zval * ) , ( void * ) & args ) ; * current_args = args ; if ( hkey . type == HASH_KEY_IS_STRING ) { zend_hash_update ( params , hkey . str , hkey . len , ( void * ) & tmp , sizeof ( zval * ) , ( void * ) & ptr ) ; } else { zend_hash_index_update ( params , hkey . num , ( void * ) & tmp , sizeof ( zval * ) , ( void * ) & ptr ) ; } } else { if ( hkey . type == HASH_KEY_IS_STRING ) { zend_hash_find ( params , hkey . str , hkey . len , ( void * ) & ptr ) ; } else { zend_hash_index_find ( params , hkey . num , ( void * ) & ptr ) ; } zdata_ptr = & zdata ; if ( Z_TYPE_PP ( ptr ) == IS_ARRAY && SUCCESS == zend_hash_find ( Z_ARRVAL_PP ( ptr ) , ""value"" , sizeof ( ""value"" ) , ( void * ) & ptr ) && SUCCESS == zend_hash_get_current_data ( Z_ARRVAL_PP ( zdata_ptr ) , ( void * ) & zdata_ptr ) ) { zval * * test_ptr ; while ( Z_TYPE_PP ( zdata_ptr ) == IS_ARRAY && SUCCESS == zend_hash_get_current_data ( Z_ARRVAL_PP ( zdata_ptr ) , ( void * ) & test_ptr ) ) { if ( Z_TYPE_PP ( test_ptr ) == IS_ARRAY ) { if ( HASH_KEY_IS_STRING == zend_hash_get_current_key_ex ( Z_ARRVAL_PP ( zdata_ptr ) , & hkey . str , & hkey . len , & hkey . num , hkey . dup , NULL ) ) { if ( SUCCESS == zend_hash_find ( Z_ARRVAL_PP ( ptr ) , hkey . str , hkey . len , ( void * ) & ptr ) ) { zdata_ptr = test_ptr ; } else { Z_ADDREF_PP ( test_ptr ) ; zend_hash_update ( Z_ARRVAL_PP ( ptr ) , hkey . str , hkey . len , ( void * ) test_ptr , sizeof ( zval * ) , ( void * ) & ptr ) ; break ; } } else { if ( SUCCESS == zend_hash_index_find ( Z_ARRVAL_PP ( ptr ) , hkey . num , ( void * ) & ptr ) ) { zdata_ptr = test_ptr ; } else if ( hkey . num ) { Z_ADDREF_PP ( test_ptr ) ; zend_hash_index_update ( Z_ARRVAL_PP ( ptr ) , hkey . num , ( void * ) test_ptr , sizeof ( zval * ) , ( void * ) & ptr ) ; break ; } else { Z_ADDREF_PP ( test_ptr ) ; zend_hash_next_index_insert ( Z_ARRVAL_PP ( ptr ) , ( void * ) test_ptr , sizeof ( zval * ) , ( void * ) & ptr ) ; break ; } } } else { Z_ADDREF_PP ( test_ptr ) ; if ( Z_TYPE_PP ( ptr ) != IS_ARRAY ) { zval_dtor ( * ptr ) ; array_init ( * ptr ) ; } if ( HASH_KEY_IS_STRING == zend_hash_get_current_key_ex ( Z_ARRVAL_PP ( zdata_ptr ) , & hkey . str , & hkey . len , & hkey . num , hkey . dup , NULL ) ) { zend_hash_update ( Z_ARRVAL_PP ( ptr ) , hkey . str , hkey . len , ( void * ) test_ptr , sizeof ( zval * ) , ( void * ) & ptr ) ; } else if ( hkey . num ) { zend_hash_index_update ( Z_ARRVAL_PP ( ptr ) , hkey . num , ( void * ) test_ptr , sizeof ( zval * ) , ( void * ) & ptr ) ; } else { zend_hash_next_index_insert ( Z_ARRVAL_PP ( ptr ) , ( void * ) test_ptr , sizeof ( zval * ) , ( void * ) & ptr ) ; } break ; } } } } while ( Z_TYPE_PP ( ptr ) == IS_ARRAY && SUCCESS == zend_hash_get_current_data ( Z_ARRVAL_PP ( ptr ) , ( void * ) & ptr ) ) ; * current_param = ptr ; } "," ) == IS_ARRAY && Z_TYPE_PP ( ptr ) == IS_ARRAY ",m6w6@ext-http/17137d4ab1ce81a2cee0fae842340a344ef3da83,CVE-2016-7398,https://github.com/m6w6/ext-http/commit/17137d4ab1ce81a2cee0fae842340a344ef3da83,2019-09-06T19:15Z 1594,CWE-284,"CWE-284 static int a2dp_ctrl_receive ( struct a2dp_stream_common * common , void * buffer , int length ) { int ret = recv ( common -> ctrl_fd , buffer , length , MSG_NOSIGNAL ) ; if ( ret < 0 ) { ERROR ( ""ackfailed(%s)"" , strerror ( errno ) ) ; if ( errno == EINTR ) { ret = recv ( common -> ctrl_fd , buffer , length , MSG_NOSIGNAL ) ; if ( ret < 0 ) { ERROR ( ""ackfailed(%s)"" , strerror ( errno ) ) ; skt_disconnect ( common -> ctrl_fd ) ; common -> ctrl_fd = AUDIO_SKT_DISCONNECTED ; return - 1 ; } } else { skt_disconnect ( common -> ctrl_fd ) ; common -> ctrl_fd = AUDIO_SKT_DISCONNECTED ; return - 1 ; } } return ret ; } "," int ret = TEMP_FAILURE_RETRY ( length , MSG_NOSIGNAL ) { ret = TEMP_FAILURE_RETRY ( length , MSG_NOSIGNAL ) ",system@bt/472271b153c5dc53c28beac55480a8d8434b2d5c,CVE-2016-3839,https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c,2016-08-05T20:59Z 1595,CWE-20,"CWE-20 void BezierOval ( double w , double h , char * action ) { outpos += sprintf ( outpos , ""%12.3f0m%12.3f%12.3f%12.3f%12.3f0%12.3fc\\n"" , - w , - w , h * BzK , - w * BzK , h , h ) ; outpos += sprintf ( outpos , ""%12.3f%12.3f%12.3f%12.3f%12.3f0c\\n"" , w * BzK , h , w , h * BzK , w ) ; outpos += sprintf ( outpos , ""%12.3f%12.3f%12.3f%12.3f0%12.3fc\\n"" , w , - h * BzK , w * BzK , - h , - h ) ; outpos += sprintf ( outpos , ""%12.3f%12.3f%12.3f%12.3f%12.3f0c%s\\n"" , - w * BzK , - h , - w , - h * BzK , - w , action ) ; } "," action ) { char * outpos = outputbuffer ; action ) ; sendClean ( outputbuffer ) ; ",TeX-Live@texlive-source/9216833a3888a4105a18e8c349f65b045ddb1079,CVE-2019-18604,https://github.com/TeX-Live/texlive-source/commit/9216833a3888a4105a18e8c349f65b045ddb1079,2019-10-29T19:15Z 1596,CWE-200,"CWE-200 static void parse_cfg ( int flags , int argc , const char * * argv , cfg_t * cfg ) { int i ; memset ( cfg , 0 , sizeof ( cfg_t ) ) ; cfg -> debug_file = stderr ; for ( i = 0 ; i < argc ; i ++ ) { if ( strncmp ( argv [ i ] , ""max_devices="" , 12 ) == 0 ) sscanf ( argv [ i ] , ""max_devices=%u"" , & cfg -> max_devs ) ; if ( strcmp ( argv [ i ] , ""manual"" ) == 0 ) cfg -> manual = 1 ; if ( strcmp ( argv [ i ] , ""debug"" ) == 0 ) cfg -> debug = 1 ; if ( strcmp ( argv [ i ] , ""nouserok"" ) == 0 ) cfg -> nouserok = 1 ; if ( strcmp ( argv [ i ] , ""openasuser"" ) == 0 ) cfg -> openasuser = 1 ; if ( strcmp ( argv [ i ] , ""alwaysok"" ) == 0 ) cfg -> alwaysok = 1 ; if ( strcmp ( argv [ i ] , ""interactive"" ) == 0 ) cfg -> interactive = 1 ; if ( strcmp ( argv [ i ] , ""cue"" ) == 0 ) cfg -> cue = 1 ; if ( strcmp ( argv [ i ] , ""nodetect"" ) == 0 ) cfg -> nodetect = 1 ; if ( strncmp ( argv [ i ] , ""authfile="" , 9 ) == 0 ) cfg -> auth_file = argv [ i ] + 9 ; if ( strncmp ( argv [ i ] , ""authpending_file="" , 17 ) == 0 ) cfg -> authpending_file = argv [ i ] + 17 ; if ( strncmp ( argv [ i ] , ""origin="" , 7 ) == 0 ) cfg -> origin = argv [ i ] + 7 ; if ( strncmp ( argv [ i ] , ""appid="" , 6 ) == 0 ) cfg -> appid = argv [ i ] + 6 ; if ( strncmp ( argv [ i ] , ""prompt="" , 7 ) == 0 ) cfg -> prompt = argv [ i ] + 7 ; if ( strncmp ( argv [ i ] , ""debug_file="" , 11 ) == 0 ) { const char * filename = argv [ i ] + 11 ; if ( strncmp ( filename , ""stdout"" , 6 ) == 0 ) { cfg -> debug_file = stdout ; } else if ( strncmp ( filename , ""stderr"" , 6 ) == 0 ) { cfg -> debug_file = stderr ; } else if ( strncmp ( filename , ""syslog"" , 6 ) == 0 ) { cfg -> debug_file = ( FILE * ) - 1 ; } else { struct stat st ; FILE * file ; if ( lstat ( filename , & st ) == 0 ) { if ( S_ISREG ( st . st_mode ) ) { file = fopen ( filename , ""a"" ) ; if ( file != NULL ) { cfg -> debug_file = file ; } } } } } } if ( cfg -> debug ) { D ( cfg -> debug_file , ""called."" ) ; D ( cfg -> debug_file , ""flags%dargc%d"" , flags , argc ) ; for ( i = 0 ; i < argc ; i ++ ) { D ( cfg -> debug_file , ""argv[%d]=%s"" , i , argv [ i ] ) ; } D ( cfg -> debug_file , ""max_devices=%d"" , cfg -> max_devs ) ; D ( cfg -> debug_file , ""debug=%d"" , cfg -> debug ) ; D ( cfg -> debug_file , ""interactive=%d"" , cfg -> interactive ) ; D ( cfg -> debug_file , ""cue=%d"" , cfg -> cue ) ; D ( cfg -> debug_file , ""nodetect=%d"" , cfg -> nodetect ) ; D ( cfg -> debug_file , ""manual=%d"" , cfg -> manual ) ; D ( cfg -> debug_file , ""nouserok=%d"" , cfg -> nouserok ) ; D ( cfg -> debug_file , ""openasuser=%d"" , cfg -> openasuser ) ; D ( cfg -> debug_file , ""alwaysok=%d"" , cfg -> alwaysok ) ; D ( cfg -> debug_file , ""authfile=%s"" , cfg -> auth_file ? cfg -> auth_file : ""(null)"" ) ; D ( cfg -> debug_file , ""authpending_file=%s"" , cfg -> authpending_file ? cfg -> authpending_file : ""(null)"" ) ; D ( cfg -> debug_file , ""origin=%s"" , cfg -> origin ? cfg -> origin : ""(null)"" ) ; D ( cfg -> debug_file , ""appid=%s"" , cfg -> appid ? cfg -> appid : ""(null)"" ) ; D ( cfg -> debug_file , ""prompt=%s"" , cfg -> prompt ? cfg -> prompt : ""(null)"" ) ; } } "," cfg ) { struct stat st ; FILE * file = NULL ; int fd = - 1 ; } else { fd = open ( filename , O_WRONLY | O_APPEND | O_CLOEXEC | O_NOFOLLOW | O_NOCTTY ) ; if ( fd >= 0 && ( fstat ( fd , & st == 0 ) && S_ISREG ( st { file = fdopen ( fd , ""a"" ) = file ; cfg -> is_custom_debug_file = 1 ; file = NULL ; fd = - 1 ; } } } ) ; } if ( fd != - 1 ) close ( fd ) ; if ( file != NULL ) fclose ( file ) ; ",Yubico@pam-u2f/18b1914e32b74ff52000f10e97067e841e5fff62,CVE-2019-12210,https://github.com/Yubico/pam-u2f/commit/18b1914e32b74ff52000f10e97067e841e5fff62,2019-06-04T21:29Z 1597,CWE-476,"CWE-476 int build_segment_manager ( struct f2fs_sb_info * sbi ) { struct f2fs_super_block * raw_super = F2FS_RAW_SUPER ( sbi ) ; struct f2fs_checkpoint * ckpt = F2FS_CKPT ( sbi ) ; struct f2fs_sm_info * sm_info ; int err ; sm_info = kzalloc ( sizeof ( struct f2fs_sm_info ) , GFP_KERNEL ) ; if ( ! sm_info ) return - ENOMEM ; sbi -> sm_info = sm_info ; sm_info -> seg0_blkaddr = le32_to_cpu ( raw_super -> segment0_blkaddr ) ; sm_info -> main_blkaddr = le32_to_cpu ( raw_super -> main_blkaddr ) ; sm_info -> segment_count = le32_to_cpu ( raw_super -> segment_count ) ; sm_info -> reserved_segments = le32_to_cpu ( ckpt -> rsvd_segment_count ) ; sm_info -> ovp_segments = le32_to_cpu ( ckpt -> overprov_segment_count ) ; sm_info -> main_segments = le32_to_cpu ( raw_super -> segment_count_main ) ; sm_info -> ssa_blkaddr = le32_to_cpu ( raw_super -> ssa_blkaddr ) ; sm_info -> rec_prefree_segments = sm_info -> main_segments * DEF_RECLAIM_PREFREE_SEGMENTS / 100 ; if ( sm_info -> rec_prefree_segments > DEF_MAX_RECLAIM_PREFREE_SEGMENTS ) sm_info -> rec_prefree_segments = DEF_MAX_RECLAIM_PREFREE_SEGMENTS ; if ( ! test_opt ( sbi , LFS ) ) sm_info -> ipu_policy = 1 << F2FS_IPU_FSYNC ; sm_info -> min_ipu_util = DEF_MIN_IPU_UTIL ; sm_info -> min_fsync_blocks = DEF_MIN_FSYNC_BLOCKS ; sm_info -> min_hot_blocks = DEF_MIN_HOT_BLOCKS ; sm_info -> trim_sections = DEF_BATCHED_TRIM_SECTIONS ; INIT_LIST_HEAD ( & sm_info -> sit_entry_set ) ; if ( test_opt ( sbi , FLUSH_MERGE ) && ! f2fs_readonly ( sbi -> sb ) ) { err = create_flush_cmd_control ( sbi ) ; if ( err ) return err ; } err = create_discard_cmd_control ( sbi ) ; if ( err ) return err ; err = build_sit_info ( sbi ) ; if ( err ) return err ; err = build_free_segmap ( sbi ) ; if ( err ) return err ; err = build_curseg ( sbi ) ; if ( err ) return err ; build_sit_entries ( sbi ) ; init_free_segmap ( sbi ) ; err = build_dirty_segmap ( sbi ) ; if ( err ) return err ; init_min_max_mtime ( sbi ) ; return 0 ; } "," ; if ( ! f2fs_readonly ( ",torvalds@linux/d4fdf8ba0e5808ba9ad6b44337783bd9935e0982,CVE-2017-18241,https://github.com/torvalds/linux/commit/d4fdf8ba0e5808ba9ad6b44337783bd9935e0982,2018-03-21T16:29Z 1598,CWE-125,"CWE-125 static Image * ReadSUNImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define RMT_EQUAL_RGB 1 # define RMT_NONE 0 # define RMT_RAW 2 # define RT_STANDARD 1 # define RT_ENCODED 2 # define RT_FORMAT_RGB 3 typedef struct _SUNInfo { unsigned int magic , width , height , depth , length , type , maptype , maplength ; } SUNInfo ; Image * image ; int bit ; MagickBooleanType status ; MagickSizeType number_pixels ; register Quantum * q ; register ssize_t i , x ; register unsigned char * p ; size_t bytes_per_line , extent , length ; ssize_t count , y ; SUNInfo sun_info ; unsigned char * sun_data , * sun_pixels ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } ( void ) ResetMagickMemory ( & sun_info , 0 , sizeof ( sun_info ) ) ; sun_info . magic = ReadBlobMSBLong ( image ) ; do { if ( sun_info . magic != 0x59a66a95 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; sun_info . width = ReadBlobMSBLong ( image ) ; sun_info . height = ReadBlobMSBLong ( image ) ; sun_info . depth = ReadBlobMSBLong ( image ) ; sun_info . length = ReadBlobMSBLong ( image ) ; sun_info . type = ReadBlobMSBLong ( image ) ; sun_info . maptype = ReadBlobMSBLong ( image ) ; sun_info . maplength = ReadBlobMSBLong ( image ) ; extent = sun_info . height * sun_info . width ; if ( ( sun_info . height != 0 ) && ( sun_info . width != extent / sun_info . height ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ( sun_info . type != RT_STANDARD ) && ( sun_info . type != RT_ENCODED ) && ( sun_info . type != RT_FORMAT_RGB ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ( sun_info . maptype == RMT_NONE ) && ( sun_info . maplength != 0 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ( sun_info . depth == 0 ) || ( sun_info . depth > 32 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ( sun_info . maptype != RMT_NONE ) && ( sun_info . maptype != RMT_EQUAL_RGB ) && ( sun_info . maptype != RMT_RAW ) ) ThrowReaderException ( CoderError , ""ColormapTypeNotSupported"" ) ; image -> columns = sun_info . width ; image -> rows = sun_info . height ; image -> depth = sun_info . depth <= 8 ? sun_info . depth : MAGICKCORE_QUANTUM_DEPTH ; if ( sun_info . depth < 24 ) { size_t one ; image -> colors = sun_info . maplength ; one = 1 ; if ( sun_info . maptype == RMT_NONE ) image -> colors = one << sun_info . depth ; if ( sun_info . maptype == RMT_EQUAL_RGB ) image -> colors = sun_info . maplength / 3 ; if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; } switch ( sun_info . maptype ) { case RMT_NONE : break ; case RMT_EQUAL_RGB : { unsigned char * sun_colormap ; sun_colormap = ( unsigned char * ) AcquireQuantumMemory ( image -> colors , sizeof ( * sun_colormap ) ) ; if ( sun_colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; count = ReadBlob ( image , image -> colors , sun_colormap ) ; if ( count != ( ssize_t ) image -> colors ) ThrowReaderException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) image -> colormap [ i ] . red = ( MagickRealType ) ScaleCharToQuantum ( sun_colormap [ i ] ) ; count = ReadBlob ( image , image -> colors , sun_colormap ) ; if ( count != ( ssize_t ) image -> colors ) ThrowReaderException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) image -> colormap [ i ] . green = ( MagickRealType ) ScaleCharToQuantum ( sun_colormap [ i ] ) ; count = ReadBlob ( image , image -> colors , sun_colormap ) ; if ( count != ( ssize_t ) image -> colors ) ThrowReaderException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) image -> colormap [ i ] . blue = ( MagickRealType ) ScaleCharToQuantum ( sun_colormap [ i ] ) ; sun_colormap = ( unsigned char * ) RelinquishMagickMemory ( sun_colormap ) ; break ; } case RMT_RAW : { unsigned char * sun_colormap ; sun_colormap = ( unsigned char * ) AcquireQuantumMemory ( sun_info . maplength , sizeof ( * sun_colormap ) ) ; if ( sun_colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; count = ReadBlob ( image , sun_info . maplength , sun_colormap ) ; if ( count != ( ssize_t ) sun_info . maplength ) ThrowReaderException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; sun_colormap = ( unsigned char * ) RelinquishMagickMemory ( sun_colormap ) ; break ; } default : ThrowReaderException ( CoderError , ""ColormapTypeNotSupported"" ) ; } image -> alpha_trait = sun_info . depth == 32 ? BlendPixelTrait : UndefinedPixelTrait ; image -> columns = sun_info . width ; image -> rows = sun_info . height ; if ( image_info -> ping != MagickFalse ) { ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; if ( ( sun_info . length * sizeof ( * sun_data ) ) / sizeof ( * sun_data ) != sun_info . length || ! sun_info . length ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; number_pixels = ( MagickSizeType ) image -> columns * image -> rows ; if ( ( sun_info . type != RT_ENCODED ) && ( sun_info . depth >= 8 ) && ( ( number_pixels * ( ( sun_info . depth + 7 ) / 8 ) ) > sun_info . length ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; bytes_per_line = sun_info . width * sun_info . depth ; sun_data = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) MagickMax ( sun_info . length , bytes_per_line * sun_info . width ) , sizeof ( * sun_data ) ) ; if ( sun_data == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; count = ( ssize_t ) ReadBlob ( image , sun_info . length , sun_data ) ; if ( count != ( ssize_t ) sun_info . length ) ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; sun_pixels = sun_data ; bytes_per_line = 0 ; if ( sun_info . type == RT_ENCODED ) { size_t height ; height = sun_info . height ; if ( ( height == 0 ) || ( sun_info . width == 0 ) || ( sun_info . depth == 0 ) || ( ( bytes_per_line / sun_info . depth ) != sun_info . width ) ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; bytes_per_line += 15 ; bytes_per_line <<= 1 ; if ( ( bytes_per_line >> 1 ) != ( sun_info . width * sun_info . depth + 15 ) ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; bytes_per_line >>= 4 ; sun_pixels = ( unsigned char * ) AcquireQuantumMemory ( height , bytes_per_line * sizeof ( * sun_pixels ) ) ; if ( sun_pixels == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; ( void ) DecodeImage ( sun_data , sun_info . length , sun_pixels , bytes_per_line * height ) ; sun_data = ( unsigned char * ) RelinquishMagickMemory ( sun_data ) ; } p = sun_pixels ; if ( sun_info . depth == 1 ) for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ( ssize_t ) image -> columns - 7 ) ; x += 8 ) { for ( bit = 7 ; bit >= 0 ; bit -- ) { SetPixelIndex ( image , ( Quantum ) ( ( * p ) & ( 0x01 << bit ) ? 0x00 : 0x01 ) , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } if ( ( image -> columns % 8 ) != 0 ) { for ( bit = 7 ; bit >= ( int ) ( 8 - ( image -> columns % 8 ) ) ; bit -- ) { SetPixelIndex ( image , ( Quantum ) ( ( * p ) & ( 0x01 << bit ) ? 0x00 : 0x01 ) , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } if ( ( ( ( image -> columns / 8 ) + ( image -> columns % 8 ? 1 : 0 ) ) % 2 ) != 0 ) p ++ ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } else if ( image -> storage_class == PseudoClass ) { if ( bytes_per_line == 0 ) bytes_per_line = image -> columns ; length = image -> rows * ( image -> columns + image -> columns % 2 ) ; if ( ( ( sun_info . type == RT_ENCODED ) && ( length > ( bytes_per_line * image -> rows ) ) ) || ( ( sun_info . type != RT_ENCODED ) && ( length > sun_info . length ) ) ) ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelIndex ( image , * p ++ , q ) ; q += GetPixelChannels ( image ) ; } if ( ( image -> columns % 2 ) != 0 ) p ++ ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } else { size_t bytes_per_pixel ; bytes_per_pixel = 3 ; if ( image -> alpha_trait != UndefinedPixelTrait ) bytes_per_pixel ++ ; if ( bytes_per_line == 0 ) bytes_per_line = bytes_per_pixel * image -> columns ; length = image -> rows * ( bytes_per_line + image -> columns % 2 ) ; if ( ( ( sun_info . type == RT_ENCODED ) && ( length > ( bytes_per_line * image -> rows ) ) ) || ( ( sun_info . type != RT_ENCODED ) && ( length > sun_info . length ) ) ) ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { if ( image -> alpha_trait != UndefinedPixelTrait ) SetPixelAlpha ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; if ( sun_info . type == RT_STANDARD ) { SetPixelBlue ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelGreen ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelRed ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; } else { SetPixelRed ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelGreen ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; SetPixelBlue ( image , ScaleCharToQuantum ( * p ++ ) , q ) ; } if ( image -> colors != 0 ) { SetPixelRed ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) GetPixelRed ( image , q ) ] . red ) , q ) ; SetPixelGreen ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) GetPixelGreen ( image , q ) ] . green ) , q ) ; SetPixelBlue ( image , ClampToQuantum ( image -> colormap [ ( ssize_t ) GetPixelBlue ( image , q ) ] . blue ) , q ) ; } q += GetPixelChannels ( image ) ; } if ( ( ( bytes_per_pixel * image -> columns ) % 2 ) != 0 ) p ++ ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } if ( image -> storage_class == PseudoClass ) ( void ) SyncImage ( image , exception ) ; sun_pixels = ( unsigned char * ) RelinquishMagickMemory ( sun_pixels ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; sun_info . magic = ReadBlobMSBLong ( image ) ; if ( sun_info . magic == 0x59a66a95 ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( sun_info . magic == 0x59a66a95 ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," RT_ENCODED ) && ( ( number_pixels * sun_info . depth sun_info . depth ) > ( 8 * sun_info . length sun_info . length ) ( bytes_per_line + bytes_per_line % 2 ) ",ImageMagick@ImageMagick/b8f17d08b7418204bf8a05a5c24e87b2fc395b75,CVE-2015-8958,https://github.com/ImageMagick/ImageMagick/commit/b8f17d08b7418204bf8a05a5c24e87b2fc395b75,2017-04-20T18:59Z 1599,CWE-20,"CWE-20 void SetTransferMatrix ( double x11 , double x12 , double x21 , double x22 , double x , double y ) { if ( ( fabs ( x11 - 1. ) > 0.001 ) || ( fabs ( x22 - 1. ) > 0.001 ) || ( fabs ( x12 ) > 0.001 ) || ( fabs ( x21 ) > 0.001 ) || ( fabs ( x ) > 0.001 ) || ( fabs ( y ) > 0.001 ) ) { outpos += sprintf ( outpos , ""%12.3f%12.3f%12.3f%12.3f%12.3f%12.3fcm\\n"" , x11 , x12 , x21 , x22 , x , y ) ; } } "," ) ) { sprintf ( outputbuffer , ""%12.3f%12.3f%12.3f%12.3f%12.3f%12.3fcm\\n"" , y ) ; sendClean ( outputbuffer ) ; ",TeX-Live@texlive-source/9216833a3888a4105a18e8c349f65b045ddb1079,CVE-2019-18604,https://github.com/TeX-Live/texlive-source/commit/9216833a3888a4105a18e8c349f65b045ddb1079,2019-10-29T19:15Z 1600,CWE-125,"CWE-125 static BOOL autodetect_recv_bandwidth_measure_results ( rdpRdp * rdp , wStream * s , AUTODETECT_RSP_PDU * autodetectRspPdu ) { BOOL success = TRUE ; if ( autodetectRspPdu -> headerLength != 0x0E ) return FALSE ; WLog_VRB ( AUTODETECT_TAG , ""receivedBandwidthMeasureResultsPDU"" ) ; Stream_Read_UINT32 ( s , rdp -> autodetect -> bandwidthMeasureTimeDelta ) ; Stream_Read_UINT32 ( s , rdp -> autodetect -> bandwidthMeasureByteCount ) ; if ( rdp -> autodetect -> bandwidthMeasureTimeDelta > 0 ) rdp -> autodetect -> netCharBandwidth = rdp -> autodetect -> bandwidthMeasureByteCount * 8 / rdp -> autodetect -> bandwidthMeasureTimeDelta ; else rdp -> autodetect -> netCharBandwidth = 0 ; IFCALLRET ( rdp -> autodetect -> BandwidthMeasureResults , success , rdp -> context , autodetectRspPdu -> sequenceNumber ) ; return success ; } "," , ""receivedBandwidthMeasureResultsPDU"" ) ; if ( Stream_GetRemainingLength ( s ) < 8 ) return - 1 ",FreeRDP@FreeRDP/f5e73cc7c9cd973b516a618da877c87b80950b65,CVE-2020-11047,https://github.com/FreeRDP/FreeRDP/commit/f5e73cc7c9cd973b516a618da877c87b80950b65,2020-05-07T20:15Z 1601,CWE-416,"CWE-416 int ipmi_destroy_user ( struct ipmi_user * user ) { _ipmi_destroy_user ( user ) ; cleanup_srcu_struct ( & user -> release_barrier ) ; kref_put ( & user -> refcount , free_user ) ; return 0 ; } "," _ipmi_destroy_user ( user ) ; kref_put ",torvalds@linux/77f8269606bf95fcb232ee86f6da80886f1dfae8,CVE-2019-9003,https://github.com/torvalds/linux/commit/77f8269606bf95fcb232ee86f6da80886f1dfae8,2019-02-22T15:29Z 1602,CWE-119,"CWE-119 static void encode_mb_row ( VP8_COMP * cpi , VP8_COMMON * cm , int mb_row , MACROBLOCK * x , MACROBLOCKD * xd , TOKENEXTRA * * tp , int * segment_counts , int * totalrate ) { int recon_yoffset , recon_uvoffset ; int mb_col ; int ref_fb_idx = cm -> lst_fb_idx ; int dst_fb_idx = cm -> new_fb_idx ; int recon_y_stride = cm -> yv12_fb [ ref_fb_idx ] . y_stride ; int recon_uv_stride = cm -> yv12_fb [ ref_fb_idx ] . uv_stride ; int map_index = ( mb_row * cpi -> common . mb_cols ) ; # if ( CONFIG_REALTIME_ONLY & CONFIG_ONTHEFLY_BITPACKING ) const int num_part = ( 1 << cm -> multi_token_partition ) ; TOKENEXTRA * tp_start = cpi -> tok ; vp8_writer * w ; # endif # if CONFIG_MULTITHREAD const int nsync = cpi -> mt_sync_range ; const int rightmost_col = cm -> mb_cols + nsync ; volatile const int * last_row_current_mb_col ; volatile int * current_mb_col = & cpi -> mt_current_mb_col [ mb_row ] ; if ( ( cpi -> b_multi_threaded != 0 ) && ( mb_row != 0 ) ) last_row_current_mb_col = & cpi -> mt_current_mb_col [ mb_row - 1 ] ; else last_row_current_mb_col = & rightmost_col ; # endif # if ( CONFIG_REALTIME_ONLY & CONFIG_ONTHEFLY_BITPACKING ) if ( num_part > 1 ) w = & cpi -> bc [ 1 + ( mb_row % num_part ) ] ; else w = & cpi -> bc [ 1 ] ; # endif xd -> above_context = cm -> above_context ; xd -> up_available = ( mb_row != 0 ) ; recon_yoffset = ( mb_row * recon_y_stride * 16 ) ; recon_uvoffset = ( mb_row * recon_uv_stride * 8 ) ; cpi -> tplist [ mb_row ] . start = * tp ; xd -> mb_to_top_edge = - ( ( mb_row * 16 ) << 3 ) ; xd -> mb_to_bottom_edge = ( ( cm -> mb_rows - 1 - mb_row ) * 16 ) << 3 ; x -> mv_row_min = - ( ( mb_row * 16 ) + ( VP8BORDERINPIXELS - 16 ) ) ; x -> mv_row_max = ( ( cm -> mb_rows - 1 - mb_row ) * 16 ) + ( VP8BORDERINPIXELS - 16 ) ; x -> mb_activity_ptr = & cpi -> mb_activity_map [ map_index ] ; for ( mb_col = 0 ; mb_col < cm -> mb_cols ; mb_col ++ ) { # if ( CONFIG_REALTIME_ONLY & CONFIG_ONTHEFLY_BITPACKING ) * tp = cpi -> tok ; # endif xd -> mb_to_left_edge = - ( ( mb_col * 16 ) << 3 ) ; xd -> mb_to_right_edge = ( ( cm -> mb_cols - 1 - mb_col ) * 16 ) << 3 ; x -> mv_col_min = - ( ( mb_col * 16 ) + ( VP8BORDERINPIXELS - 16 ) ) ; x -> mv_col_max = ( ( cm -> mb_cols - 1 - mb_col ) * 16 ) + ( VP8BORDERINPIXELS - 16 ) ; xd -> dst . y_buffer = cm -> yv12_fb [ dst_fb_idx ] . y_buffer + recon_yoffset ; xd -> dst . u_buffer = cm -> yv12_fb [ dst_fb_idx ] . u_buffer + recon_uvoffset ; xd -> dst . v_buffer = cm -> yv12_fb [ dst_fb_idx ] . v_buffer + recon_uvoffset ; xd -> left_available = ( mb_col != 0 ) ; x -> rddiv = cpi -> RDDIV ; x -> rdmult = cpi -> RDMULT ; vp8_copy_mem16x16 ( x -> src . y_buffer , x -> src . y_stride , x -> thismb , 16 ) ; # if CONFIG_MULTITHREAD if ( cpi -> b_multi_threaded != 0 ) { * current_mb_col = mb_col - 1 ; if ( ( mb_col & ( nsync - 1 ) ) == 0 ) { while ( mb_col > ( * last_row_current_mb_col - nsync ) ) { x86_pause_hint ( ) ; thread_sleep ( 0 ) ; } } } # endif if ( cpi -> oxcf . tuning == VP8_TUNE_SSIM ) vp8_activity_masking ( cpi , x ) ; if ( xd -> segmentation_enabled ) { if ( cpi -> segmentation_map [ map_index + mb_col ] <= 3 ) xd -> mode_info_context -> mbmi . segment_id = cpi -> segmentation_map [ map_index + mb_col ] ; else xd -> mode_info_context -> mbmi . segment_id = 0 ; vp8cx_mb_init_quantizer ( cpi , x , 1 ) ; } else xd -> mode_info_context -> mbmi . segment_id = 0 ; x -> active_ptr = cpi -> active_map + map_index + mb_col ; if ( cm -> frame_type == KEY_FRAME ) { * totalrate += vp8cx_encode_intra_macroblock ( cpi , x , tp ) ; # ifdef MODE_STATS y_modes [ xd -> mbmi . mode ] ++ ; # endif } else { * totalrate += vp8cx_encode_inter_macroblock ( cpi , x , tp , recon_yoffset , recon_uvoffset , mb_row , mb_col ) ; # ifdef MODE_STATS inter_y_modes [ xd -> mbmi . mode ] ++ ; if ( xd -> mbmi . mode == SPLITMV ) { int b ; for ( b = 0 ; b < xd -> mbmi . partition_count ; b ++ ) { inter_b_modes [ x -> partition -> bmi [ b ] . mode ] ++ ; } } # endif if ( ( cpi -> current_layer == 0 ) && ( cpi -> cyclic_refresh_mode_enabled && xd -> segmentation_enabled ) ) { cpi -> segmentation_map [ map_index + mb_col ] = xd -> mode_info_context -> mbmi . segment_id ; if ( xd -> mode_info_context -> mbmi . segment_id ) cpi -> cyclic_refresh_map [ map_index + mb_col ] = - 1 ; else if ( ( xd -> mode_info_context -> mbmi . mode == ZEROMV ) && ( xd -> mode_info_context -> mbmi . ref_frame == LAST_FRAME ) ) { if ( cpi -> cyclic_refresh_map [ map_index + mb_col ] == 1 ) cpi -> cyclic_refresh_map [ map_index + mb_col ] = 0 ; } else cpi -> cyclic_refresh_map [ map_index + mb_col ] = 1 ; } } cpi -> tplist [ mb_row ] . stop = * tp ; # if CONFIG_REALTIME_ONLY & CONFIG_ONTHEFLY_BITPACKING { int tok_count = * tp - tp_start ; pack_tokens ( w , tp_start , tok_count ) ; } # endif x -> gf_active_ptr ++ ; x -> mb_activity_ptr ++ ; x -> src . y_buffer += 16 ; x -> src . u_buffer += 8 ; x -> src . v_buffer += 8 ; recon_yoffset += 16 ; recon_uvoffset += 8 ; segment_counts [ xd -> mode_info_context -> mbmi . segment_id ] ++ ; xd -> mode_info_context ++ ; x -> partition_info ++ ; xd -> above_context ++ ; } vp8_extend_mb_row ( & cm -> yv12_fb [ dst_fb_idx ] , xd -> dst . y_buffer + 16 , xd -> dst . u_buffer + 8 , xd -> dst . v_buffer + 8 ) ; # if CONFIG_MULTITHREAD if ( cpi -> b_multi_threaded != 0 ) * current_mb_col = rightmost_col ; # endif xd -> mode_info_context ++ ; x -> partition_info ++ ; } "," endif if ( cpi -> current_layer == 0 ) { if ( xd -> mode == ZEROMV && xd -> mode_info_context == LAST_FRAME ) { if ( cpi -> consec_zero_last [ map_index + mb_col ] < 255 ) cpi -> consec_zero_last [ map_index + mb_col ] += 1 ; if ( cpi -> consec_zero_last_mvbias [ map_index + mb_col ] < 255 ) cpi -> consec_zero_last_mvbias [ map_index + mb_col ] += 1 ; } else { cpi -> consec_zero_last [ map_index + mb_col ] = 0 ; cpi -> consec_zero_last_mvbias [ map_index + mb_col ] = 0 ; } if ( x -> zero_last_dot_suppress ) cpi -> consec_zero_last_mvbias [ map_index + mb_col ] = 0 ; } if ( ( cpi -> current_layer == 0 ) && ( cpi -> cyclic_refresh_mode_enabled && xd -> segmentation_enabled ) ) { cpi -> segmentation_map [ map_index + mb_col ] = xd -> mode_info_context -> mbmi . segment_id ; if ( xd -> mode_info_context -> mbmi . segment_id ) cpi -> cyclic_refresh_map [ map_index + mb_col ] = - 1 ; else if ( ( xd -> mode_info_context -> mbmi . mode == ZEROMV ) && ( xd -> mode_info_context -> mbmi . ref_frame == LAST_FRAME ) - tp_start ; vp8_pack_tokens ( w , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1603,CWE-000,"CWE-000 static int fr_add_pvc ( struct net_device * frad , unsigned int dlci , int type ) { hdlc_device * hdlc = dev_to_hdlc ( frad ) ; pvc_device * pvc ; struct net_device * dev ; int used ; if ( ( pvc = add_pvc ( frad , dlci ) ) == NULL ) { netdev_warn ( frad , ""Memorysqueezeonfr_add_pvc()\\n"" ) ; return - ENOBUFS ; } if ( * get_dev_p ( pvc , type ) ) return - EEXIST ; used = pvc_is_used ( pvc ) ; if ( type == ARPHRD_ETHER ) dev = alloc_netdev ( 0 , ""pvceth%d"" , ether_setup ) ; else dev = alloc_netdev ( 0 , ""pvc%d"" , pvc_setup ) ; if ( ! dev ) { netdev_warn ( frad , ""Memorysqueezeonfr_pvc()\\n"" ) ; delete_unused_pvcs ( hdlc ) ; return - ENOBUFS ; } if ( type == ARPHRD_ETHER ) random_ether_addr ( dev -> dev_addr ) ; else { * ( __be16 * ) dev -> dev_addr = htons ( dlci ) ; dlci_to_q922 ( dev -> broadcast , dlci ) ; } dev -> netdev_ops = & pvc_ops ; dev -> mtu = HDLC_MAX_MTU ; dev -> tx_queue_len = 0 ; dev -> ml_priv = pvc ; if ( register_netdevice ( dev ) != 0 ) { free_netdev ( dev ) ; delete_unused_pvcs ( hdlc ) ; return - EIO ; } dev -> destructor = free_netdev ; * get_dev_p ( pvc , type ) = dev ; if ( ! used ) { state ( hdlc ) -> dce_changed = 1 ; state ( hdlc ) -> dce_pvc_count ++ ; } return 0 ; } "," == ARPHRD_ETHER ) { ether_setup ) ; dev -> priv_flags &= ~ IFF_TX_SKB_SHARING ; } ",torvalds@linux/550fd08c2cebad61c548def135f67aba284c6162,CVE-2011-4112,https://github.com/torvalds/linux/commit/550fd08c2cebad61c548def135f67aba284c6162,2012-05-17T11:00Z 1604,CWE-119,"CWE-119 static void cliprdr_process ( STREAM s ) { uint16 type , status ; uint32 length , format ; uint8 * data ; in_uint16_le ( s , type ) ; in_uint16_le ( s , status ) ; in_uint32_le ( s , length ) ; data = s -> p ; logger ( Clipboard , Debug , ""cliprdr_process(),type=%d,status=%d,length=%d"" , type , status , length ) ; if ( status == CLIPRDR_ERROR ) { switch ( type ) { case CLIPRDR_FORMAT_ACK : cliprdr_send_native_format_announce ( last_formats , last_formats_length ) ; break ; case CLIPRDR_DATA_RESPONSE : ui_clip_request_failed ( ) ; break ; default : logger ( Clipboard , Warning , ""cliprdr_process(),unhandlederror(type=%d)"" , type ) ; } return ; } switch ( type ) { case CLIPRDR_CONNECT : ui_clip_sync ( ) ; break ; case CLIPRDR_FORMAT_ANNOUNCE : ui_clip_format_announce ( data , length ) ; cliprdr_send_packet ( CLIPRDR_FORMAT_ACK , CLIPRDR_RESPONSE , NULL , 0 ) ; return ; case CLIPRDR_FORMAT_ACK : break ; case CLIPRDR_DATA_REQUEST : in_uint32_le ( s , format ) ; ui_clip_request_data ( format ) ; break ; case CLIPRDR_DATA_RESPONSE : ui_clip_handle_data ( data , length ) ; break ; case 7 : break ; default : logger ( Clipboard , Warning , ""cliprdr_process(),unhandledpackettype%d"" , type ) ; } } "," * data ; struct stream packet = * s ; ; if ( ! s_check_rem ( s , length ) ) { rdp_protocol_error ( ""cliprdr_process(),consumeofpacketfromstreamwouldoverrun"" , & packet ) ; } if ( ",rdesktop@rdesktop/4dca546d04321a610c1835010b5dad85163b65e1,CVE-2018-20182,https://github.com/rdesktop/rdesktop/commit/4dca546d04321a610c1835010b5dad85163b65e1,2019-03-15T18:29Z 1605,CWE-000,"CWE-000 int vp8_remove_decoder_instances ( struct frame_buffers * fb ) { if ( ! fb -> use_frame_threads ) { VP8D_COMP * pbi = fb -> pbi [ 0 ] ; if ( ! pbi ) return VPX_CODEC_ERROR ; # if CONFIG_MULTITHREAD if ( pbi -> b_multithreaded_rd ) vp8mt_de_alloc_temp_buffers ( pbi , pbi -> common . mb_rows ) ; vp8_decoder_remove_threads ( pbi ) ; # endif remove_decompressor ( pbi ) ; } else { } return VPX_CODEC_OK ; } "," # if CONFIG_MULTITHREAD vp8_decoder_remove_threads ( pbi ",external@libvpx/6886e8e0a9db2dbad723dc37a548233e004b33bc,CVE-2017-0393,https://android.googlesource.com/platform/external/libvpx/+/6886e8e0a9db2dbad723dc37a548233e004b33bc,2017-01-12T20:59Z 1606,CWE-476,"CWE-476 void formUpdateBuffer ( Anchor * a , Buffer * buf , FormItemList * form ) { Buffer save ; char * p ; int spos , epos , rows , c_rows , pos , col = 0 ; Line * l ; copyBuffer ( & save , buf ) ; gotoLine ( buf , a -> start . line ) ; switch ( form -> type ) { case FORM_TEXTAREA : case FORM_INPUT_TEXT : case FORM_INPUT_FILE : case FORM_INPUT_PASSWORD : case FORM_INPUT_CHECKBOX : case FORM_INPUT_RADIO : # ifdef MENU_SELECT case FORM_SELECT : # endif spos = a -> start . pos ; epos = a -> end . pos ; break ; default : spos = a -> start . pos + 1 ; epos = a -> end . pos - 1 ; } switch ( form -> type ) { case FORM_INPUT_CHECKBOX : case FORM_INPUT_RADIO : if ( buf -> currentLine == NULL || spos >= buf -> currentLine -> len || spos < 0 ) break ; if ( form -> checked ) buf -> currentLine -> lineBuf [ spos ] = '*' ; else buf -> currentLine -> lineBuf [ spos ] = '' ; break ; case FORM_INPUT_TEXT : case FORM_INPUT_FILE : case FORM_INPUT_PASSWORD : case FORM_TEXTAREA : # ifdef MENU_SELECT case FORM_SELECT : if ( form -> type == FORM_SELECT ) { p = form -> label -> ptr ; updateSelectOption ( form , form -> select_option ) ; } else # endif { if ( ! form -> value ) break ; p = form -> value -> ptr ; } l = buf -> currentLine ; if ( ! l ) break ; if ( form -> type == FORM_TEXTAREA ) { int n = a -> y - buf -> currentLine -> linenumber ; if ( n > 0 ) for ( ; l && n ; l = l -> prev , n -- ) ; else if ( n < 0 ) for ( ; l && n ; l = l -> prev , n ++ ) ; if ( ! l ) break ; } rows = form -> rows ? form -> rows : 1 ; col = COLPOS ( l , a -> start . pos ) ; for ( c_rows = 0 ; c_rows < rows ; c_rows ++ , l = l -> next ) { if ( rows > 1 ) { pos = columnPos ( l , col ) ; a = retrieveAnchor ( buf -> formitem , l -> linenumber , pos ) ; if ( a == NULL ) break ; spos = a -> start . pos ; epos = a -> end . pos ; } if ( a -> start . line != a -> end . line || spos > epos || epos >= l -> len || spos < 0 || epos < 0 || COLPOS ( l , epos ) < col ) break ; pos = form_update_line ( l , & p , spos , epos , COLPOS ( l , epos ) - col , rows > 1 , form -> type == FORM_INPUT_PASSWORD ) ; if ( pos != epos ) { shiftAnchorPosition ( buf -> href , buf -> hmarklist , a -> start . line , spos , pos - epos ) ; shiftAnchorPosition ( buf -> name , buf -> hmarklist , a -> start . line , spos , pos - epos ) ; shiftAnchorPosition ( buf -> img , buf -> hmarklist , a -> start . line , spos , pos - epos ) ; shiftAnchorPosition ( buf -> formitem , buf -> hmarklist , a -> start . line , spos , pos - epos ) ; } } break ; } copyBuffer ( buf , & save ) ; arrangeLine ( buf ) ; } "," { if ( l == NULL ) break ; if ( ",tats@w3m/7fdc83b0364005a0b5ed869230dd81752ba022e8,CVE-2018-6197,https://github.com/tats/w3m/commit/7fdc83b0364005a0b5ed869230dd81752ba022e8,2018-01-25T03:29Z 1607,CWE-119,"CWE-119 void * pvPortMalloc ( size_t xWantedSize ) { BlockLink_t * pxBlock , * pxPreviousBlock , * pxNewBlockLink ; void * pvReturn = NULL ; configASSERT ( pxEnd ) ; vTaskSuspendAll ( ) ; { if ( ( xWantedSize & xBlockAllocatedBit ) == 0 ) { if ( xWantedSize > 0 ) { xWantedSize += xHeapStructSize ; if ( ( xWantedSize & portBYTE_ALIGNMENT_MASK ) != 0x00 ) { xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ) ; } else { mtCOVERAGE_TEST_MARKER ( ) ; } } else { mtCOVERAGE_TEST_MARKER ( ) ; } if ( ( xWantedSize > 0 ) && ( xWantedSize <= xFreeBytesRemaining ) ) { pxPreviousBlock = & xStart ; pxBlock = xStart . pxNextFreeBlock ; while ( ( pxBlock -> xBlockSize < xWantedSize ) && ( pxBlock -> pxNextFreeBlock != NULL ) ) { pxPreviousBlock = pxBlock ; pxBlock = pxBlock -> pxNextFreeBlock ; } if ( pxBlock != pxEnd ) { pvReturn = ( void * ) ( ( ( uint8_t * ) pxPreviousBlock -> pxNextFreeBlock ) + xHeapStructSize ) ; pxPreviousBlock -> pxNextFreeBlock = pxBlock -> pxNextFreeBlock ; if ( ( pxBlock -> xBlockSize - xWantedSize ) > heapMINIMUM_BLOCK_SIZE ) { pxNewBlockLink = ( void * ) ( ( ( uint8_t * ) pxBlock ) + xWantedSize ) ; pxNewBlockLink -> xBlockSize = pxBlock -> xBlockSize - xWantedSize ; pxBlock -> xBlockSize = xWantedSize ; prvInsertBlockIntoFreeList ( ( pxNewBlockLink ) ) ; } else { mtCOVERAGE_TEST_MARKER ( ) ; } xFreeBytesRemaining -= pxBlock -> xBlockSize ; if ( xFreeBytesRemaining < xMinimumEverFreeBytesRemaining ) { xMinimumEverFreeBytesRemaining = xFreeBytesRemaining ; } else { mtCOVERAGE_TEST_MARKER ( ) ; } pxBlock -> xBlockSize |= xBlockAllocatedBit ; pxBlock -> pxNextFreeBlock = NULL ; xNumberOfSuccessfulAllocations ++ ; } else { mtCOVERAGE_TEST_MARKER ( ) ; } } else { mtCOVERAGE_TEST_MARKER ( ) ; } } else { mtCOVERAGE_TEST_MARKER ( ) ; } traceMALLOC ( pvReturn , xWantedSize ) ; } ( void ) xTaskResumeAll ( ) ; # if ( configUSE_MALLOC_FAILED_HOOK == 1 ) { if ( pvReturn == NULL ) { extern void vApplicationMallocFailedHook ( void ) ; vApplicationMallocFailedHook ( ) ; } else { mtCOVERAGE_TEST_MARKER ( ) ; } } # endif return pvReturn ; } "," { if ( ( > 0 ) && ( ( xWantedSize + xHeapStructSize ) > xWantedSize ) ) 0x00 ) { if ( ( xWantedSize + ( portBYTE_ALIGNMENT - portBYTE_ALIGNMENT_MASK ) ) ) > xWantedSize ) { xWantedSize += ( portBYTE_ALIGNMENT - ( xWantedSize & portBYTE_ALIGNMENT_MASK ) ) ; } else { xWantedSize = 0 ; } } else { mtCOVERAGE_TEST_MARKER ( ) ; } } else { xWantedSize = 0 ; } if ",FreeRTOS@FreeRTOS-Kernel/c7a9a01c94987082b223d3e59969ede64363da63,CVE-2021-32020,https://github.com/FreeRTOS/FreeRTOS-Kernel/commit/c7a9a01c94987082b223d3e59969ede64363da63,2021-05-03T22:15Z 1608,CWE-119,"CWE-119 void vp9_iht8x8_add ( TX_TYPE tx_type , const int16_t * input , uint8_t * dest , int stride , int eob ) { if ( tx_type == DCT_DCT ) { vp9_idct8x8_add ( input , dest , stride , eob ) ; } else { vp9_iht8x8_64_add ( input , dest , stride , tx_type ) ; } } "," tx_type , const tran_low_t * input , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1609,CWE-400,"CWE-400 static int misaligned_store ( struct pt_regs * regs , __u32 opcode , int displacement_not_indexed , int width_shift ) { int error ; int srcreg ; __u64 address ; error = generate_and_check_address ( regs , opcode , displacement_not_indexed , width_shift , & address ) ; if ( error < 0 ) { return error ; } perf_sw_event ( PERF_COUNT_SW_ALIGNMENT_FAULTS , 1 , 0 , regs , address ) ; srcreg = ( opcode >> 4 ) & 0x3f ; if ( user_mode ( regs ) ) { __u64 buffer ; if ( ! access_ok ( VERIFY_WRITE , ( unsigned long ) address , 1UL << width_shift ) ) { return - 1 ; } switch ( width_shift ) { case 1 : * ( __u16 * ) & buffer = ( __u16 ) regs -> regs [ srcreg ] ; break ; case 2 : * ( __u32 * ) & buffer = ( __u32 ) regs -> regs [ srcreg ] ; break ; case 3 : buffer = regs -> regs [ srcreg ] ; break ; default : printk ( ""Unexpectedwidth_shift%dinmisaligned_store,PC=%08lx\\n"" , width_shift , ( unsigned long ) regs -> pc ) ; break ; } if ( __copy_user ( ( void * ) ( int ) address , & buffer , ( 1 << width_shift ) ) > 0 ) { return - 1 ; } } else { __u64 val = regs -> regs [ srcreg ] ; switch ( width_shift ) { case 1 : misaligned_kernel_word_store ( address , val ) ; break ; case 2 : asm ( ""stlo.l%1,0,%0"" : : ""r"" ( val ) , ""r"" ( address ) ) ; asm ( ""sthi.l%1,3,%0"" : : ""r"" ( val ) , ""r"" ( address ) ) ; break ; case 3 : asm ( ""stlo.q%1,0,%0"" : : ""r"" ( val ) , ""r"" ( address ) ) ; asm ( ""sthi.q%1,7,%0"" : : ""r"" ( val ) , ""r"" ( address ) ) ; break ; default : printk ( ""Unexpectedwidth_shift%dinmisaligned_store,PC=%08lx\\n"" , width_shift , ( unsigned long ) regs -> pc ) ; break ; } } return 0 ; } "," , 1 , regs , address ",torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,CVE-2011-2918,https://github.com/torvalds/linux/commit/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,2012-05-24T23:55Z 1610,CWE-119,"CWE-119 static void fpDiff ( TIFF * tif , uint8 * cp0 , tmsize_t cc ) { tmsize_t stride = PredictorState ( tif ) -> stride ; uint32 bps = tif -> tif_dir . td_bitspersample / 8 ; tmsize_t wc = cc / bps ; tmsize_t count ; uint8 * cp = ( uint8 * ) cp0 ; uint8 * tmp = ( uint8 * ) _TIFFmalloc ( cc ) ; assert ( ( cc % ( bps * stride ) ) == 0 ) ; if ( ! tmp ) return ; _TIFFmemcpy ( tmp , cp0 , cc ) ; for ( count = 0 ; count < wc ; count ++ ) { uint32 byte ; for ( byte = 0 ; byte < bps ; byte ++ ) { # if WORDS_BIGENDIAN cp [ byte * wc + count ] = tmp [ bps * count + byte ] ; # else cp [ ( bps - byte - 1 ) * wc + count ] = tmp [ bps * count + byte ] ; # endif } } _TIFFfree ( tmp ) ; cp = ( uint8 * ) cp0 ; cp += cc - stride - 1 ; for ( count = cc ; count > stride ; count -= stride ) REPEAT4 ( stride , cp [ stride ] = ( unsigned char ) ( ( cp [ stride ] - cp [ 0 ] ) & 0xff ) ; cp -- ) } "," static int fpDiff ( TIFF cc ) ; if ( ( cc stride ) ) != 0 ) { TIFFErrorExt ( tif -> tif_clientdata , ""fpDiff"" , ""%s"" , ""(cc%(bps*stride))!=0"" ) ; return 0 ; } if ( ! tmp ) return 0 cp -- ) return 1 ; ",vadz@libtiff/3ca657a8793dd011bf869695d72ad31c779c3cc1,CVE-2016-9535,https://github.com/vadz/libtiff/commit/3ca657a8793dd011bf869695d72ad31c779c3cc1,2016-11-22T19:59Z 1611,CWE-787,"CWE-787 void process_bitmap_updates ( STREAM s ) { uint16 num_updates ; uint16 left , top , right , bottom , width , height ; uint16 cx , cy , bpp , Bpp , compress , bufsize , size ; uint8 * data , * bmpdata ; int i ; logger ( Protocol , Debug , ""%s()"" , __func__ ) ; in_uint16_le ( s , num_updates ) ; for ( i = 0 ; i < num_updates ; i ++ ) { in_uint16_le ( s , left ) ; in_uint16_le ( s , top ) ; in_uint16_le ( s , right ) ; in_uint16_le ( s , bottom ) ; in_uint16_le ( s , width ) ; in_uint16_le ( s , height ) ; in_uint16_le ( s , bpp ) ; Bpp = ( bpp + 7 ) / 8 ; in_uint16_le ( s , compress ) ; in_uint16_le ( s , bufsize ) ; cx = right - left + 1 ; cy = bottom - top + 1 ; logger ( Graphics , Debug , ""process_bitmap_updates(),[%d,%d,%d,%d],[%d,%d],bpp=%d,compression=%d"" , left , top , right , bottom , width , height , Bpp , compress ) ; if ( ! compress ) { int y ; bmpdata = ( uint8 * ) xmalloc ( width * height * Bpp ) ; for ( y = 0 ; y < height ; y ++ ) { in_uint8a ( s , & bmpdata [ ( height - y - 1 ) * ( width * Bpp ) ] , width * Bpp ) ; } ui_paint_bitmap ( left , top , cx , cy , width , height , bmpdata ) ; xfree ( bmpdata ) ; continue ; } if ( compress & 0x400 ) { size = bufsize ; } else { in_uint8s ( s , 2 ) ; in_uint16_le ( s , size ) ; in_uint8s ( s , 4 ) ; } in_uint8p ( s , data , size ) ; bmpdata = ( uint8 * ) xmalloc ( width * height * Bpp ) ; if ( bitmap_decompress ( bmpdata , width , height , data , size , Bpp ) ) { ui_paint_bitmap ( left , top , cx , cy , width , height , bmpdata ) ; } else { logger ( Graphics , Warning , ""process_bitmap_updates(),failedtodecompressbitmap"" ) ; } xfree ( bmpdata ) ; } } "," s ) { int i ; int i ; uint16 num_updates ; in_uint16_le ( ++ ) { process_bitmap_data ( s ) ; } ",rdesktop@rdesktop/4dca546d04321a610c1835010b5dad85163b65e1,CVE-2018-8800,https://github.com/rdesktop/rdesktop/commit/4dca546d04321a610c1835010b5dad85163b65e1,2019-02-05T20:29Z 1612,CWE-400,"CWE-400 int xfs_attr_shortform_list ( xfs_attr_list_context_t * context ) { attrlist_cursor_kern_t * cursor ; xfs_attr_sf_sort_t * sbuf , * sbp ; xfs_attr_shortform_t * sf ; xfs_attr_sf_entry_t * sfe ; xfs_inode_t * dp ; int sbsize , nsbuf , count , i ; int error ; ASSERT ( context != NULL ) ; dp = context -> dp ; ASSERT ( dp != NULL ) ; ASSERT ( dp -> i_afp != NULL ) ; sf = ( xfs_attr_shortform_t * ) dp -> i_afp -> if_u1 . if_data ; ASSERT ( sf != NULL ) ; if ( ! sf -> hdr . count ) return 0 ; cursor = context -> cursor ; ASSERT ( cursor != NULL ) ; trace_xfs_attr_list_sf ( context ) ; if ( context -> bufsize == 0 || ( XFS_ISRESET_CURSOR ( cursor ) && ( dp -> i_afp -> if_bytes + sf -> hdr . count * 16 ) < context -> bufsize ) ) { for ( i = 0 , sfe = & sf -> list [ 0 ] ; i < sf -> hdr . count ; i ++ ) { error = context -> put_listent ( context , sfe -> flags , sfe -> nameval , ( int ) sfe -> namelen , ( int ) sfe -> valuelen , & sfe -> nameval [ sfe -> namelen ] ) ; if ( context -> seen_enough ) break ; if ( error ) return error ; sfe = XFS_ATTR_SF_NEXTENTRY ( sfe ) ; } trace_xfs_attr_list_sf_all ( context ) ; return 0 ; } if ( context -> bufsize == 0 ) return 0 ; sbsize = sf -> hdr . count * sizeof ( * sbuf ) ; sbp = sbuf = kmem_alloc ( sbsize , KM_SLEEP | KM_NOFS ) ; nsbuf = 0 ; for ( i = 0 , sfe = & sf -> list [ 0 ] ; i < sf -> hdr . count ; i ++ ) { if ( unlikely ( ( ( char * ) sfe < ( char * ) sf ) || ( ( char * ) sfe >= ( ( char * ) sf + dp -> i_afp -> if_bytes ) ) ) ) { XFS_CORRUPTION_ERROR ( ""xfs_attr_shortform_list"" , XFS_ERRLEVEL_LOW , context -> dp -> i_mount , sfe ) ; kmem_free ( sbuf ) ; return - EFSCORRUPTED ; } sbp -> entno = i ; sbp -> hash = xfs_da_hashname ( sfe -> nameval , sfe -> namelen ) ; sbp -> name = sfe -> nameval ; sbp -> namelen = sfe -> namelen ; sbp -> valuelen = sfe -> valuelen ; sbp -> flags = sfe -> flags ; sfe = XFS_ATTR_SF_NEXTENTRY ( sfe ) ; sbp ++ ; nsbuf ++ ; } xfs_sort ( sbuf , nsbuf , sizeof ( * sbuf ) , xfs_attr_shortform_compare ) ; count = 0 ; cursor -> initted = 1 ; cursor -> blkno = 0 ; for ( sbp = sbuf , i = 0 ; i < nsbuf ; i ++ , sbp ++ ) { if ( sbp -> hash == cursor -> hashval ) { if ( cursor -> offset == count ) { break ; } count ++ ; } else if ( sbp -> hash > cursor -> hashval ) { break ; } } if ( i == nsbuf ) { kmem_free ( sbuf ) ; return 0 ; } for ( ; i < nsbuf ; i ++ , sbp ++ ) { if ( cursor -> hashval != sbp -> hash ) { cursor -> hashval = sbp -> hash ; cursor -> offset = 0 ; } error = context -> put_listent ( context , sbp -> flags , sbp -> name , sbp -> namelen , sbp -> valuelen , & sbp -> name [ sbp -> namelen ] ) ; if ( error ) return error ; if ( context -> seen_enough ) break ; cursor -> offset ++ ; } kmem_free ( sbuf ) ; return 0 ; } "," ( error ) { kmem_free ( sbuf ) ; return error ; } ",torvalds@linux/2e83b79b2d6c78bf1b4aa227938a214dcbddc83f,CVE-2016-9685,https://github.com/torvalds/linux/commit/2e83b79b2d6c78bf1b4aa227938a214dcbddc83f,2016-12-28T07:59Z 1613,CWE-125,"CWE-125 void olsr_print ( netdissect_options * ndo , const u_char * pptr , u_int length , int is_ipv6 ) { union { const struct olsr_common * common ; const struct olsr_msg4 * msg4 ; const struct olsr_msg6 * msg6 ; const struct olsr_hello * hello ; const struct olsr_hello_link * hello_link ; const struct olsr_tc * tc ; const struct olsr_hna4 * hna ; } ptr ; u_int msg_type , msg_len , msg_tlen , hello_len ; uint16_t name_entry_type , name_entry_len ; u_int name_entry_padding ; uint8_t link_type , neighbor_type ; const u_char * tptr , * msg_data ; tptr = pptr ; if ( length < sizeof ( struct olsr_common ) ) { goto trunc ; } ND_TCHECK2 ( * tptr , sizeof ( struct olsr_common ) ) ; ptr . common = ( const struct olsr_common * ) tptr ; length = min ( length , EXTRACT_16BITS ( ptr . common -> packet_len ) ) ; ND_PRINT ( ( ndo , ""OLSRv%i,seq0x%04x,length%u"" , ( is_ipv6 == 0 ) ? 4 : 6 , EXTRACT_16BITS ( ptr . common -> packet_seq ) , length ) ) ; tptr += sizeof ( struct olsr_common ) ; if ( ndo -> ndo_vflag < 1 ) { return ; } while ( tptr < ( pptr + length ) ) { union { const struct olsr_msg4 * v4 ; const struct olsr_msg6 * v6 ; } msgptr ; int msg_len_valid = 0 ; ND_TCHECK2 ( * tptr , sizeof ( struct olsr_msg4 ) ) ; if ( is_ipv6 ) { msgptr . v6 = ( const struct olsr_msg6 * ) tptr ; msg_type = msgptr . v6 -> msg_type ; msg_len = EXTRACT_16BITS ( msgptr . v6 -> msg_len ) ; if ( ( msg_len >= sizeof ( struct olsr_msg6 ) ) && ( msg_len <= length ) ) msg_len_valid = 1 ; if ( msg_type == 0 || msg_len == 0 ) { return ; } ND_PRINT ( ( ndo , ""\\n\\t%sMessage(%#04x),originator%s,ttl%u,hop%u"" ""\\n\\tvtime%.3fs,msg-seq0x%04x,length%u%s"" , tok2str ( olsr_msg_values , ""Unknown"" , msg_type ) , msg_type , ip6addr_string ( ndo , msgptr . v6 -> originator ) , msgptr . v6 -> ttl , msgptr . v6 -> hopcount , ME_TO_DOUBLE ( msgptr . v6 -> vtime ) , EXTRACT_16BITS ( msgptr . v6 -> msg_seq ) , msg_len , ( msg_len_valid == 0 ) ? ""(invalid)"" : """" ) ) ; if ( ! msg_len_valid ) { return ; } msg_tlen = msg_len - sizeof ( struct olsr_msg6 ) ; msg_data = tptr + sizeof ( struct olsr_msg6 ) ; } else { msgptr . v4 = ( const struct olsr_msg4 * ) tptr ; msg_type = msgptr . v4 -> msg_type ; msg_len = EXTRACT_16BITS ( msgptr . v4 -> msg_len ) ; if ( ( msg_len >= sizeof ( struct olsr_msg4 ) ) && ( msg_len <= length ) ) msg_len_valid = 1 ; if ( msg_type == 0 || msg_len == 0 ) { return ; } ND_PRINT ( ( ndo , ""\\n\\t%sMessage(%#04x),originator%s,ttl%u,hop%u"" ""\\n\\tvtime%.3fs,msg-seq0x%04x,length%u%s"" , tok2str ( olsr_msg_values , ""Unknown"" , msg_type ) , msg_type , ipaddr_string ( ndo , msgptr . v4 -> originator ) , msgptr . v4 -> ttl , msgptr . v4 -> hopcount , ME_TO_DOUBLE ( msgptr . v4 -> vtime ) , EXTRACT_16BITS ( msgptr . v4 -> msg_seq ) , msg_len , ( msg_len_valid == 0 ) ? ""(invalid)"" : """" ) ) ; if ( ! msg_len_valid ) { return ; } msg_tlen = msg_len - sizeof ( struct olsr_msg4 ) ; msg_data = tptr + sizeof ( struct olsr_msg4 ) ; } switch ( msg_type ) { case OLSR_HELLO_MSG : case OLSR_HELLO_LQ_MSG : if ( msg_tlen < sizeof ( struct olsr_hello ) ) goto trunc ; ND_TCHECK2 ( * msg_data , sizeof ( struct olsr_hello ) ) ; ptr . hello = ( const struct olsr_hello * ) msg_data ; ND_PRINT ( ( ndo , ""\\n\\thello-time%.3fs,MPRwillingness%u"" , ME_TO_DOUBLE ( ptr . hello -> htime ) , ptr . hello -> will ) ) ; msg_data += sizeof ( struct olsr_hello ) ; msg_tlen -= sizeof ( struct olsr_hello ) ; while ( msg_tlen >= sizeof ( struct olsr_hello_link ) ) { int hello_len_valid = 0 ; ND_TCHECK2 ( * msg_data , sizeof ( struct olsr_hello_link ) ) ; ptr . hello_link = ( const struct olsr_hello_link * ) msg_data ; hello_len = EXTRACT_16BITS ( ptr . hello_link -> len ) ; link_type = OLSR_EXTRACT_LINK_TYPE ( ptr . hello_link -> link_code ) ; neighbor_type = OLSR_EXTRACT_NEIGHBOR_TYPE ( ptr . hello_link -> link_code ) ; if ( ( hello_len <= msg_tlen ) && ( hello_len >= sizeof ( struct olsr_hello_link ) ) ) hello_len_valid = 1 ; ND_PRINT ( ( ndo , ""\\n\\tlink-type%s,neighbor-type%s,len%u%s"" , tok2str ( olsr_link_type_values , ""Unknown"" , link_type ) , tok2str ( olsr_neighbor_type_values , ""Unknown"" , neighbor_type ) , hello_len , ( hello_len_valid == 0 ) ? ""(invalid)"" : """" ) ) ; if ( hello_len_valid == 0 ) break ; msg_data += sizeof ( struct olsr_hello_link ) ; msg_tlen -= sizeof ( struct olsr_hello_link ) ; hello_len -= sizeof ( struct olsr_hello_link ) ; ND_TCHECK2 ( * msg_data , hello_len ) ; if ( msg_type == OLSR_HELLO_MSG ) { if ( olsr_print_neighbor ( ndo , msg_data , hello_len ) == - 1 ) goto trunc ; } else { if ( is_ipv6 ) { if ( olsr_print_lq_neighbor6 ( ndo , msg_data , hello_len ) == - 1 ) goto trunc ; } else { if ( olsr_print_lq_neighbor4 ( ndo , msg_data , hello_len ) == - 1 ) goto trunc ; } } msg_data += hello_len ; msg_tlen -= hello_len ; } break ; case OLSR_TC_MSG : case OLSR_TC_LQ_MSG : if ( msg_tlen < sizeof ( struct olsr_tc ) ) goto trunc ; ND_TCHECK2 ( * msg_data , sizeof ( struct olsr_tc ) ) ; ptr . tc = ( const struct olsr_tc * ) msg_data ; ND_PRINT ( ( ndo , ""\\n\\tadvertisedneighborseq0x%04x"" , EXTRACT_16BITS ( ptr . tc -> ans_seq ) ) ) ; msg_data += sizeof ( struct olsr_tc ) ; msg_tlen -= sizeof ( struct olsr_tc ) ; if ( msg_type == OLSR_TC_MSG ) { if ( olsr_print_neighbor ( ndo , msg_data , msg_tlen ) == - 1 ) goto trunc ; } else { if ( is_ipv6 ) { if ( olsr_print_lq_neighbor6 ( ndo , msg_data , msg_tlen ) == - 1 ) goto trunc ; } else { if ( olsr_print_lq_neighbor4 ( ndo , msg_data , msg_tlen ) == - 1 ) goto trunc ; } } break ; case OLSR_MID_MSG : { size_t addr_size = sizeof ( struct in_addr ) ; if ( is_ipv6 ) addr_size = sizeof ( struct in6_addr ) ; while ( msg_tlen >= addr_size ) { ND_TCHECK2 ( * msg_data , addr_size ) ; ND_PRINT ( ( ndo , ""\\n\\tinterfaceaddress%s"" , is_ipv6 ? ip6addr_string ( ndo , msg_data ) : ipaddr_string ( ndo , msg_data ) ) ) ; msg_data += addr_size ; msg_tlen -= addr_size ; } break ; } case OLSR_HNA_MSG : if ( is_ipv6 ) { int i = 0 ; ND_PRINT ( ( ndo , ""\\n\\tAdvertisednetworks(total%u)"" , ( unsigned int ) ( msg_tlen / sizeof ( struct olsr_hna6 ) ) ) ) ; while ( msg_tlen >= sizeof ( struct olsr_hna6 ) ) { const struct olsr_hna6 * hna6 ; ND_TCHECK2 ( * msg_data , sizeof ( struct olsr_hna6 ) ) ; hna6 = ( const struct olsr_hna6 * ) msg_data ; ND_PRINT ( ( ndo , ""\\n\\t#%i:%s/%u"" , i , ip6addr_string ( ndo , hna6 -> network ) , mask62plen ( hna6 -> mask ) ) ) ; msg_data += sizeof ( struct olsr_hna6 ) ; msg_tlen -= sizeof ( struct olsr_hna6 ) ; } } else { int col = 0 ; ND_PRINT ( ( ndo , ""\\n\\tAdvertisednetworks(total%u)"" , ( unsigned int ) ( msg_tlen / sizeof ( struct olsr_hna4 ) ) ) ) ; while ( msg_tlen >= sizeof ( struct olsr_hna4 ) ) { ND_TCHECK2 ( * msg_data , sizeof ( struct olsr_hna4 ) ) ; ptr . hna = ( const struct olsr_hna4 * ) msg_data ; if ( ! ptr . hna -> network [ 0 ] && ! ptr . hna -> network [ 1 ] && ! ptr . hna -> network [ 2 ] && ! ptr . hna -> network [ 3 ] && ! ptr . hna -> mask [ GW_HNA_PAD ] && ptr . hna -> mask [ GW_HNA_FLAGS ] ) { ND_PRINT ( ( ndo , ""%sSmart-Gateway:%s%s%s%s%s%u/%u"" , col == 0 ? ""\\n\\t"" : "","" , ( ptr . hna -> mask [ GW_HNA_FLAGS ] & GW_HNA_FLAG_LINKSPEED ) ? ""LINKSPEED"" : """" , ( ptr . hna -> mask [ GW_HNA_FLAGS ] & GW_HNA_FLAG_IPV4 ) ? ""IPV4"" : """" , ( ptr . hna -> mask [ GW_HNA_FLAGS ] & GW_HNA_FLAG_IPV4_NAT ) ? ""IPV4-NAT"" : """" , ( ptr . hna -> mask [ GW_HNA_FLAGS ] & GW_HNA_FLAG_IPV6 ) ? ""IPV6"" : """" , ( ptr . hna -> mask [ GW_HNA_FLAGS ] & GW_HNA_FLAG_IPV6PREFIX ) ? ""IPv6-PREFIX"" : """" , ( ptr . hna -> mask [ GW_HNA_FLAGS ] & GW_HNA_FLAG_LINKSPEED ) ? deserialize_gw_speed ( ptr . hna -> mask [ GW_HNA_UPLINK ] ) : 0 , ( ptr . hna -> mask [ GW_HNA_FLAGS ] & GW_HNA_FLAG_LINKSPEED ) ? deserialize_gw_speed ( ptr . hna -> mask [ GW_HNA_DOWNLINK ] ) : 0 ) ) ; } else { ND_PRINT ( ( ndo , ""%s%s/%u"" , col == 0 ? ""\\n\\t"" : "","" , ipaddr_string ( ndo , ptr . hna -> network ) , mask2plen ( EXTRACT_32BITS ( ptr . hna -> mask ) ) ) ) ; } msg_data += sizeof ( struct olsr_hna4 ) ; msg_tlen -= sizeof ( struct olsr_hna4 ) ; col = ( col + 1 ) % 4 ; } } break ; case OLSR_NAMESERVICE_MSG : { u_int name_entries = EXTRACT_16BITS ( msg_data + 2 ) ; u_int addr_size = 4 ; int name_entries_valid = 0 ; u_int i ; if ( is_ipv6 ) addr_size = 16 ; if ( ( name_entries > 0 ) && ( ( name_entries * ( 4 + addr_size ) ) <= msg_tlen ) ) name_entries_valid = 1 ; if ( msg_tlen < 4 ) goto trunc ; ND_TCHECK2 ( * msg_data , 4 ) ; ND_PRINT ( ( ndo , ""\\n\\tVersion%u,Entries%u%s"" , EXTRACT_16BITS ( msg_data ) , name_entries , ( name_entries_valid == 0 ) ? ""(invalid)"" : """" ) ) ; if ( name_entries_valid == 0 ) break ; msg_data += 4 ; msg_tlen -= 4 ; for ( i = 0 ; i < name_entries ; i ++ ) { int name_entry_len_valid = 0 ; if ( msg_tlen < 4 ) break ; ND_TCHECK2 ( * msg_data , 4 ) ; name_entry_type = EXTRACT_16BITS ( msg_data ) ; name_entry_len = EXTRACT_16BITS ( msg_data + 2 ) ; msg_data += 4 ; msg_tlen -= 4 ; if ( ( name_entry_len > 0 ) && ( ( addr_size + name_entry_len ) <= msg_tlen ) ) name_entry_len_valid = 1 ; ND_PRINT ( ( ndo , ""\\n\\t#%u:type%#06x,length%u%s"" , ( unsigned int ) i , name_entry_type , name_entry_len , ( name_entry_len_valid == 0 ) ? ""(invalid)"" : """" ) ) ; if ( name_entry_len_valid == 0 ) break ; name_entry_padding = 0 ; if ( name_entry_len % 4 != 0 ) name_entry_padding = 4 - ( name_entry_len % 4 ) ; if ( msg_tlen < addr_size + name_entry_len + name_entry_padding ) goto trunc ; ND_TCHECK2 ( * msg_data , addr_size + name_entry_len + name_entry_padding ) ; if ( is_ipv6 ) ND_PRINT ( ( ndo , "",address%s,name\\"""" , ip6addr_string ( ndo , msg_data ) ) ) ; else ND_PRINT ( ( ndo , "",address%s,name\\"""" , ipaddr_string ( ndo , msg_data ) ) ) ; ( void ) fn_printn ( ndo , msg_data + addr_size , name_entry_len , NULL ) ; ND_PRINT ( ( ndo , ""\\"""" ) ) ; msg_data += addr_size + name_entry_len + name_entry_padding ; msg_tlen -= addr_size + name_entry_len + name_entry_padding ; } break ; } case OLSR_POWERINFO_MSG : default : print_unknown_data ( ndo , msg_data , ""\\n\\t"" , msg_tlen ) ; break ; } tptr += msg_len ; } return ; trunc : ND_PRINT ( ( ndo , ""[|olsr]"" ) ) ; } "," = 0 ; if ( is_ipv6 ) { sizeof ( struct olsr_msg6 ) ) ; msgptr . v6 } else { ND_TCHECK2 ( * tptr , sizeof ( struct olsr_msg4 ) ) ; { u_int name_entries ; u_int addr_size ; int name_entries_valid ; u_int i ; if ( msg_tlen < 4 ) goto trunc ; ND_TCHECK2 ( * msg_data , 4 ) ; name_entries 2 ) ; addr_size = 4 = 4 ; if ( is_ipv6 ) addr_size = 16 ; name_entries_valid = 0 name_entries_valid = 0 ; if ( name_entries_valid = 1 ; ND_PRINT ( ",the-tcpdump-group@tcpdump/0cb1b8a434b599b8d636db029aadb757c24e39d6,CVE-2017-13688,https://github.com/the-tcpdump-group/tcpdump/commit/0cb1b8a434b599b8d636db029aadb757c24e39d6,2017-09-14T06:29Z 1614,CWE-190,"CWE-190 static int tiffcp ( TIFF * in , TIFF * out ) { uint16 bitspersample , samplesperpixel ; uint16 input_compression , input_photometric ; copyFunc cf ; uint32 width , length ; struct cpTag * p ; CopyField ( TIFFTAG_IMAGEWIDTH , width ) ; CopyField ( TIFFTAG_IMAGELENGTH , length ) ; CopyField ( TIFFTAG_BITSPERSAMPLE , bitspersample ) ; CopyField ( TIFFTAG_SAMPLESPERPIXEL , samplesperpixel ) ; if ( compression != ( uint16 ) - 1 ) TIFFSetField ( out , TIFFTAG_COMPRESSION , compression ) ; else CopyField ( TIFFTAG_COMPRESSION , compression ) ; TIFFGetFieldDefaulted ( in , TIFFTAG_COMPRESSION , & input_compression ) ; TIFFGetFieldDefaulted ( in , TIFFTAG_PHOTOMETRIC , & input_photometric ) ; if ( input_compression == COMPRESSION_JPEG ) { TIFFSetField ( in , TIFFTAG_JPEGCOLORMODE , JPEGCOLORMODE_RGB ) ; } else if ( input_photometric == PHOTOMETRIC_YCBCR ) { uint16 subsamplinghor , subsamplingver ; TIFFGetFieldDefaulted ( in , TIFFTAG_YCBCRSUBSAMPLING , & subsamplinghor , & subsamplingver ) ; if ( subsamplinghor != 1 || subsamplingver != 1 ) { fprintf ( stderr , ""tiffcp:%s:Can\'tcopy/convertsubsampledimage.\\n"" , TIFFFileName ( in ) ) ; return FALSE ; } } if ( compression == COMPRESSION_JPEG ) { if ( input_photometric == PHOTOMETRIC_RGB && jpegcolormode == JPEGCOLORMODE_RGB ) TIFFSetField ( out , TIFFTAG_PHOTOMETRIC , PHOTOMETRIC_YCBCR ) ; else TIFFSetField ( out , TIFFTAG_PHOTOMETRIC , input_photometric ) ; } else if ( compression == COMPRESSION_SGILOG || compression == COMPRESSION_SGILOG24 ) TIFFSetField ( out , TIFFTAG_PHOTOMETRIC , samplesperpixel == 1 ? PHOTOMETRIC_LOGL : PHOTOMETRIC_LOGLUV ) ; else if ( input_compression == COMPRESSION_JPEG && samplesperpixel == 3 ) { TIFFSetField ( out , TIFFTAG_PHOTOMETRIC , PHOTOMETRIC_RGB ) ; } else CopyTag ( TIFFTAG_PHOTOMETRIC , 1 , TIFF_SHORT ) ; if ( fillorder != 0 ) TIFFSetField ( out , TIFFTAG_FILLORDER , fillorder ) ; else CopyTag ( TIFFTAG_FILLORDER , 1 , TIFF_SHORT ) ; TIFFGetFieldDefaulted ( in , TIFFTAG_ORIENTATION , & orientation ) ; switch ( orientation ) { case ORIENTATION_BOTRIGHT : case ORIENTATION_RIGHTBOT : TIFFWarning ( TIFFFileName ( in ) , ""usingbottom-leftorientation"" ) ; orientation = ORIENTATION_BOTLEFT ; case ORIENTATION_LEFTBOT : case ORIENTATION_BOTLEFT : break ; case ORIENTATION_TOPRIGHT : case ORIENTATION_RIGHTTOP : default : TIFFWarning ( TIFFFileName ( in ) , ""usingtop-leftorientation"" ) ; orientation = ORIENTATION_TOPLEFT ; case ORIENTATION_LEFTTOP : case ORIENTATION_TOPLEFT : break ; } TIFFSetField ( out , TIFFTAG_ORIENTATION , orientation ) ; if ( outtiled == - 1 ) outtiled = TIFFIsTiled ( in ) ; if ( outtiled ) { if ( tilewidth == ( uint32 ) - 1 ) TIFFGetField ( in , TIFFTAG_TILEWIDTH , & tilewidth ) ; if ( tilelength == ( uint32 ) - 1 ) TIFFGetField ( in , TIFFTAG_TILELENGTH , & tilelength ) ; TIFFDefaultTileSize ( out , & tilewidth , & tilelength ) ; TIFFSetField ( out , TIFFTAG_TILEWIDTH , tilewidth ) ; TIFFSetField ( out , TIFFTAG_TILELENGTH , tilelength ) ; } else { if ( rowsperstrip == ( uint32 ) 0 ) { if ( ! TIFFGetField ( in , TIFFTAG_ROWSPERSTRIP , & rowsperstrip ) ) { rowsperstrip = TIFFDefaultStripSize ( out , rowsperstrip ) ; } if ( rowsperstrip > length && rowsperstrip != ( uint32 ) - 1 ) rowsperstrip = length ; } else if ( rowsperstrip == ( uint32 ) - 1 ) rowsperstrip = length ; TIFFSetField ( out , TIFFTAG_ROWSPERSTRIP , rowsperstrip ) ; } if ( config != ( uint16 ) - 1 ) TIFFSetField ( out , TIFFTAG_PLANARCONFIG , config ) ; else CopyField ( TIFFTAG_PLANARCONFIG , config ) ; if ( samplesperpixel <= 4 ) CopyTag ( TIFFTAG_TRANSFERFUNCTION , 4 , TIFF_SHORT ) ; CopyTag ( TIFFTAG_COLORMAP , 4 , TIFF_SHORT ) ; switch ( compression ) { case COMPRESSION_JPEG : TIFFSetField ( out , TIFFTAG_JPEGQUALITY , quality ) ; TIFFSetField ( out , TIFFTAG_JPEGCOLORMODE , jpegcolormode ) ; break ; case COMPRESSION_JBIG : CopyTag ( TIFFTAG_FAXRECVPARAMS , 1 , TIFF_LONG ) ; CopyTag ( TIFFTAG_FAXRECVTIME , 1 , TIFF_LONG ) ; CopyTag ( TIFFTAG_FAXSUBADDRESS , 1 , TIFF_ASCII ) ; CopyTag ( TIFFTAG_FAXDCS , 1 , TIFF_ASCII ) ; break ; case COMPRESSION_LZW : case COMPRESSION_ADOBE_DEFLATE : case COMPRESSION_DEFLATE : case COMPRESSION_LZMA : if ( predictor != ( uint16 ) - 1 ) TIFFSetField ( out , TIFFTAG_PREDICTOR , predictor ) ; else CopyField ( TIFFTAG_PREDICTOR , predictor ) ; if ( preset != - 1 ) { if ( compression == COMPRESSION_ADOBE_DEFLATE || compression == COMPRESSION_DEFLATE ) TIFFSetField ( out , TIFFTAG_ZIPQUALITY , preset ) ; else if ( compression == COMPRESSION_LZMA ) TIFFSetField ( out , TIFFTAG_LZMAPRESET , preset ) ; } break ; case COMPRESSION_CCITTFAX3 : case COMPRESSION_CCITTFAX4 : if ( compression == COMPRESSION_CCITTFAX3 ) { if ( g3opts != ( uint32 ) - 1 ) TIFFSetField ( out , TIFFTAG_GROUP3OPTIONS , g3opts ) ; else CopyField ( TIFFTAG_GROUP3OPTIONS , g3opts ) ; } else CopyTag ( TIFFTAG_GROUP4OPTIONS , 1 , TIFF_LONG ) ; CopyTag ( TIFFTAG_BADFAXLINES , 1 , TIFF_LONG ) ; CopyTag ( TIFFTAG_CLEANFAXDATA , 1 , TIFF_LONG ) ; CopyTag ( TIFFTAG_CONSECUTIVEBADFAXLINES , 1 , TIFF_LONG ) ; CopyTag ( TIFFTAG_FAXRECVPARAMS , 1 , TIFF_LONG ) ; CopyTag ( TIFFTAG_FAXRECVTIME , 1 , TIFF_LONG ) ; CopyTag ( TIFFTAG_FAXSUBADDRESS , 1 , TIFF_ASCII ) ; break ; } { uint32 len32 ; void * * data ; if ( TIFFGetField ( in , TIFFTAG_ICCPROFILE , & len32 , & data ) ) TIFFSetField ( out , TIFFTAG_ICCPROFILE , len32 , data ) ; } { uint16 ninks ; const char * inknames ; if ( TIFFGetField ( in , TIFFTAG_NUMBEROFINKS , & ninks ) ) { TIFFSetField ( out , TIFFTAG_NUMBEROFINKS , ninks ) ; if ( TIFFGetField ( in , TIFFTAG_INKNAMES , & inknames ) ) { int inknameslen = strlen ( inknames ) + 1 ; const char * cp = inknames ; while ( ninks > 1 ) { cp = strchr ( cp , '\\0' ) ; cp ++ ; inknameslen += ( strlen ( cp ) + 1 ) ; ninks -- ; } TIFFSetField ( out , TIFFTAG_INKNAMES , inknameslen , inknames ) ; } } } { unsigned short pg0 , pg1 ; if ( pageInSeq == 1 ) { if ( pageNum < 0 ) { if ( TIFFGetField ( in , TIFFTAG_PAGENUMBER , & pg0 , & pg1 ) ) TIFFSetField ( out , TIFFTAG_PAGENUMBER , pg0 , pg1 ) ; } else TIFFSetField ( out , TIFFTAG_PAGENUMBER , pageNum ++ , 0 ) ; } else { if ( TIFFGetField ( in , TIFFTAG_PAGENUMBER , & pg0 , & pg1 ) ) { if ( pageNum < 0 ) TIFFSetField ( out , TIFFTAG_PAGENUMBER , pg0 , pg1 ) ; else TIFFSetField ( out , TIFFTAG_PAGENUMBER , pageNum ++ , 0 ) ; } } } for ( p = tags ; p < & tags [ NTAGS ] ; p ++ ) CopyTag ( p -> tag , p -> count , p -> type ) ; cf = pickCopyFunc ( in , out , bitspersample , samplesperpixel ) ; return ( cf ? ( * cf ) ( in , out , length , width , samplesperpixel ) : FALSE ) ; } "," bitspersample , samplesperpixel = 1 input_compression , input_photometric = PHOTOMETRIC_MINISBLACK ",vadz@libtiff/43c0b81a818640429317c80fea1e66771e85024b,CVE-2016-9538,https://github.com/vadz/libtiff/commit/43c0b81a818640429317c80fea1e66771e85024b,2016-11-22T19:59Z 1615,CWE-000,"CWE-000 static int errorLogDirective ( MaState * state , cchar * key , cchar * value ) { MprTicks stamp ; char * option , * ovalue , * tok , * path ; ssize size ; int level , flags , backup ; if ( mprGetCmdlineLogging ( ) ) { mprLog ( ""infoappwebconfig"" , 4 , ""Alreadylogging.IgnoringErrorLogdirective"" ) ; return 0 ; } size = MAXINT ; stamp = 0 ; level = 0 ; backup = 0 ; path = 0 ; flags = 0 ; for ( option = maGetNextArg ( sclone ( value ) , & tok ) ; option ; option = maGetNextArg ( tok , & tok ) ) { if ( ! path ) { path = mprJoinPath ( httpGetRouteVar ( state -> route , ""LOG_DIR"" ) , httpExpandRouteVars ( state -> route , option ) ) ; } else { option = stok ( option , ""=\\t,"" , & ovalue ) ; ovalue = strim ( ovalue , ""\\""\'"" , MPR_TRIM_BOTH ) ; if ( smatch ( option , ""size"" ) ) { size = ( ssize ) getnum ( ovalue ) ; } else if ( smatch ( option , ""level"" ) ) { level = atoi ( ovalue ) ; } else if ( smatch ( option , ""backup"" ) ) { backup = atoi ( ovalue ) ; } else if ( smatch ( option , ""anew"" ) ) { flags |= MPR_LOG_ANEW ; } else if ( smatch ( option , ""stamp"" ) ) { stamp = httpGetTicks ( ovalue ) ; } else { mprLog ( ""errorappwebconfig"" , 0 , ""UnknownErrorLogoption%s"" , option ) ; } } } if ( size < ( 10 * 1000 ) ) { mprLog ( ""errorappwebconfig"" , 0 , ""Sizeistoosmall.Mustbelargerthan10K"" ) ; return MPR_ERR_BAD_SYNTAX ; } if ( path == 0 ) { mprLog ( ""errorappwebconfig"" , 0 , ""Missingfilename"" ) ; return MPR_ERR_BAD_SYNTAX ; } mprSetLogBackup ( size , backup , flags ) ; if ( ! smatch ( path , ""stdout"" ) && ! smatch ( path , ""stderr"" ) ) { path = httpMakePath ( state -> route , state -> configDir , path ) ; } if ( mprStartLogging ( path , MPR_LOG_DETAILED ) < 0 ) { mprLog ( ""errorappwebconfig"" , 0 , ""CannotwritetoErrorLog:%s"" , path ) ; return MPR_ERR_BAD_SYNTAX ; } mprSetLogLevel ( level ) ; mprLogHeader ( ) ; if ( stamp ) { httpSetTimestamp ( stamp ) ; } return 0 ; } "," { option = ssplit ( option , ",embedthis@appweb/7e6a925f5e86a19a7934a94bbd6959101d0b84eb,CVE-2014-9708,https://github.com/embedthis/appweb/commit/7e6a925f5e86a19a7934a94bbd6959101d0b84eb,2015-03-31T14:59Z 1616,CWE-119,"CWE-119 static void build_tree_distribution ( VP9_COMP * cpi , TX_SIZE tx_size , vp9_coeff_stats * coef_branch_ct ) { vp9_coeff_probs_model * coef_probs = cpi -> frame_coef_probs [ tx_size ] ; vp9_coeff_count * coef_counts = cpi -> coef_counts [ tx_size ] ; unsigned int ( * eob_branch_ct ) [ REF_TYPES ] [ COEF_BANDS ] [ COEFF_CONTEXTS ] = cpi -> common . counts . eob_branch [ tx_size ] ; int i , j , k , l , m ; for ( i = 0 ; i < PLANE_TYPES ; ++ i ) { for ( j = 0 ; j < REF_TYPES ; ++ j ) { for ( k = 0 ; k < COEF_BANDS ; ++ k ) { for ( l = 0 ; l < BAND_COEFF_CONTEXTS ( k ) ; ++ l ) { vp9_tree_probs_from_distribution ( vp9_coef_tree , coef_branch_ct [ i ] [ j ] [ k ] [ l ] , coef_counts [ i ] [ j ] [ k ] [ l ] ) ; coef_branch_ct [ i ] [ j ] [ k ] [ l ] [ 0 ] [ 1 ] = eob_branch_ct [ i ] [ j ] [ k ] [ l ] - coef_branch_ct [ i ] [ j ] [ k ] [ l ] [ 0 ] [ 0 ] ; for ( m = 0 ; m < UNCONSTRAINED_NODES ; ++ m ) coef_probs [ i ] [ j ] [ k ] [ l ] [ m ] = get_binary_prob ( coef_branch_ct [ i ] [ j ] [ k ] [ l ] [ m ] [ 0 ] , coef_branch_ct [ i ] [ j ] [ k ] [ l ] [ m ] [ 1 ] ) ; } } } } } "," vp9_coeff_stats * coef_branch_ct , vp9_coeff_probs_model * coef_probs vp9_coeff_probs_model * coef_probs ) { vp9_coeff_count * coef_counts = cpi -> td . rd_counts . coef_counts [ tx_size ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1617,CWE-255,"CWE-255 static int toggle_utf8 ( const char * name , int fd , bool utf8 ) { int r ; struct termios tc = { } ; assert ( name ) ; r = ioctl ( fd , KDSKBMODE , utf8 ? K_UNICODE : K_XLATE ) ; if ( r < 0 ) return log_warning_errno ( errno , ""Failedto%sUTF-8kbdmodeon%s:%m"" , enable_disable ( utf8 ) , name ) ; r = loop_write ( fd , utf8 ? ""\\033%G"" : ""\\033%@"" , 3 , false ) ; if ( r < 0 ) return log_warning_errno ( r , ""Failedto%sUTF-8termprocessingon%s:%m"" , enable_disable ( utf8 ) , name ) ; r = tcgetattr ( fd , & tc ) ; if ( r >= 0 ) { SET_FLAG ( tc . c_iflag , IUTF8 , utf8 ) ; r = tcsetattr ( fd , TCSANOW , & tc ) ; } if ( r < 0 ) return log_warning_errno ( errno , ""Failedto%siutf8flagon%s:%m"" , enable_disable ( utf8 ) , name ) ; log_debug ( ""UTF-8kbdmode%sdon%s"" , enable_disable ( utf8 ) , name ) ; return 0 ; } "," ; assert ( name ) ; r = vt_verify_kbmode ( fd ) ; if ( r == - EBUSY ) { log_warning_errno ( r , ""Virtualconsole%sisnotinK_XLATEorK_UNICODE:%m"" , name ) ; return 0 ; } else if ( r < 0 ) return log_warning_errno ( r , ""Failedtoverifykbdmodeon%s:%m"" , ",systemd@systemd/9725f1a10f80f5e0ae7d9b60547458622aeb322f,CVE-2018-20839,https://github.com/systemd/systemd/commit/9725f1a10f80f5e0ae7d9b60547458622aeb322f,2019-05-17T04:29Z 1618,CWE-119,"CWE-119 static int su3000_frontend_attach ( struct dvb_usb_adapter * d ) { u8 obuf [ 3 ] = { 0xe , 0x80 , 0 } ; u8 ibuf [ ] = { 0 } ; if ( dvb_usb_generic_rw ( d -> dev , obuf , 3 , ibuf , 1 , 0 ) < 0 ) err ( ""command0x0etransferfailed."" ) ; obuf [ 0 ] = 0xe ; obuf [ 1 ] = 0x02 ; obuf [ 2 ] = 1 ; if ( dvb_usb_generic_rw ( d -> dev , obuf , 3 , ibuf , 1 , 0 ) < 0 ) err ( ""command0x0etransferfailed."" ) ; msleep ( 300 ) ; obuf [ 0 ] = 0xe ; obuf [ 1 ] = 0x83 ; obuf [ 2 ] = 0 ; if ( dvb_usb_generic_rw ( d -> dev , obuf , 3 , ibuf , 1 , 0 ) < 0 ) err ( ""command0x0etransferfailed."" ) ; obuf [ 0 ] = 0xe ; obuf [ 1 ] = 0x83 ; obuf [ 2 ] = 1 ; if ( dvb_usb_generic_rw ( d -> dev , obuf , 3 , ibuf , 1 , 0 ) < 0 ) err ( ""command0x0etransferfailed."" ) ; obuf [ 0 ] = 0x51 ; if ( dvb_usb_generic_rw ( d -> dev , obuf , 1 , ibuf , 1 , 0 ) < 0 ) err ( ""command0x51transferfailed."" ) ; d -> fe_adap [ 0 ] . fe = dvb_attach ( ds3000_attach , & su3000_ds3000_config , & d -> dev -> i2c_adap ) ; if ( d -> fe_adap [ 0 ] . fe == NULL ) return - EIO ; if ( dvb_attach ( ts2020_attach , d -> fe_adap [ 0 ] . fe , & dw2104_ts2020_config , & d -> dev -> i2c_adap ) ) { info ( ""AttachedDS3000/TS2020!"" ) ; return 0 ; } info ( ""FailedtoattachDS3000/TS2020!"" ) ; return - EIO ; } "," struct dvb_usb_adapter * adap ) { struct dvb_usb_device * d = adap -> dev ; struct dw2102_state * state = d -> priv ; mutex_lock ( & d -> data_mutex ) ; state -> data [ 0 ] = 0xe ; state -> data [ 1 ] = 0x80 ; state -> data [ 2 ] = 0 ; if ( dvb_usb_generic_rw ( d , state -> data , 3 , state -> data , 1 , 0 ) < 0 ) err ( ""command0x0etransferfailed."" ) ; state -> data [ 0 ] = 0xe ; state -> data [ 1 ] = 0x02 ; state -> data [ 2 ] = 1 ; if ( dvb_usb_generic_rw ( d , state -> data , 3 , , 3 , state -> data , 1 , ""command0x0etransferfailed."" ) ; msleep ( 300 ) ; state -> data [ 0 ] = 0xe ; state -> data [ 1 ] = 0x83 ; state -> data [ 2 ] 2 ] = 0 ; if ( dvb_usb_generic_rw ( d , state -> data , 3 , , 3 , state -> data , 1 , ""command0x0etransferfailed."" ) ; state -> data [ 0 ] = 0xe ; state -> data [ 1 ] = 0x83 ; state -> data [ 2 ] 2 ] = 1 ; if ( dvb_usb_generic_rw ( d , state -> data , 3 , , 3 , state -> data , 1 , ""command0x0etransferfailed."" ) ; state -> data [ 0 ] = 0x51 ; if ( dvb_usb_generic_rw ( d , state -> data , 1 , state -> data , 1 , ) err ( ""command0x51transferfailed."" ) ; ""command0x51transferfailed."" ) ; mutex_unlock ( & d -> data_mutex ) ; adap -> fe_adap [ & d -> i2c_adap ) ; ; if ( adap -> fe_adap [ ( ts2020_attach , adap -> fe_adap [ , & d -> i2c_adap ) ",torvalds@linux/606142af57dad981b78707234cfbd15f9f7b7125,CVE-2017-8062,https://github.com/torvalds/linux/commit/606142af57dad981b78707234cfbd15f9f7b7125,2017-04-23T05:59Z 1619,CWE-362,"CWE-362 static int sock_close ( struct inode * inode , struct file * filp ) { sock_release ( SOCKET_I ( inode ) ) ; return 0 ; } "," filp ) { __sock_release ( SOCKET_I ( ( inode ) , inode ",torvalds@linux/6d8c50dcb029872b298eea68cc6209c866fd3e14,CVE-2018-12232,https://github.com/torvalds/linux/commit/6d8c50dcb029872b298eea68cc6209c866fd3e14,2018-06-12T12:29Z 1620,CWE-119,"CWE-119 vpx_codec_err_t vpx_codec_enc_init_ver ( vpx_codec_ctx_t * ctx , vpx_codec_iface_t * iface , vpx_codec_enc_cfg_t * cfg , vpx_codec_flags_t flags , int ver ) { vpx_codec_err_t res ; if ( ver != VPX_ENCODER_ABI_VERSION ) res = VPX_CODEC_ABI_MISMATCH ; else if ( ! ctx || ! iface || ! cfg ) res = VPX_CODEC_INVALID_PARAM ; else if ( iface -> abi_version != VPX_CODEC_INTERNAL_ABI_VERSION ) res = VPX_CODEC_ABI_MISMATCH ; else if ( ! ( iface -> caps & VPX_CODEC_CAP_ENCODER ) ) res = VPX_CODEC_INCAPABLE ; else if ( ( flags & VPX_CODEC_USE_XMA ) && ! ( iface -> caps & VPX_CODEC_CAP_XMA ) ) res = VPX_CODEC_INCAPABLE ; else if ( ( flags & VPX_CODEC_USE_PSNR ) && ! ( iface -> caps & VPX_CODEC_CAP_PSNR ) ) res = VPX_CODEC_INCAPABLE ; else if ( ( flags & VPX_CODEC_USE_OUTPUT_PARTITION ) && ! ( iface -> caps & VPX_CODEC_CAP_OUTPUT_PARTITION ) ) res = VPX_CODEC_INCAPABLE ; else { ctx -> iface = iface ; ctx -> name = iface -> name ; ctx -> priv = NULL ; ctx -> init_flags = flags ; ctx -> config . enc = cfg ; res = ctx -> iface -> init ( ctx , NULL ) ; if ( res ) { ctx -> err_detail = ctx -> priv ? ctx -> priv -> err_detail : NULL ; vpx_codec_destroy ( ctx ) ; } if ( ctx -> priv ) ctx -> priv -> iface = ctx -> iface ; } return SAVE_STATUS ( ctx , res ) ; } "," * iface , const ( flags & VPX_CODEC_USE_PSNR ) && ) ; } } return SAVE_STATUS ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1621,CWE-119,"CWE-119 static void temporal_filter_predictors_mb_c ( MACROBLOCKD * xd , uint8_t * y_mb_ptr , uint8_t * u_mb_ptr , uint8_t * v_mb_ptr , int stride , int uv_block_size , int mv_row , int mv_col , uint8_t * pred , struct scale_factors * scale , int x , int y ) { const int which_mv = 0 ; const MV mv = { mv_row , mv_col } ; const InterpKernel * const kernel = vp9_get_interp_kernel ( xd -> mi [ 0 ] -> mbmi . interp_filter ) ; enum mv_precision mv_precision_uv ; int uv_stride ; if ( uv_block_size == 8 ) { uv_stride = ( stride + 1 ) >> 1 ; mv_precision_uv = MV_PRECISION_Q4 ; } else { uv_stride = stride ; mv_precision_uv = MV_PRECISION_Q3 ; } vp9_build_inter_predictor ( y_mb_ptr , stride , & pred [ 0 ] , 16 , & mv , scale , 16 , 16 , which_mv , kernel , MV_PRECISION_Q3 , x , y ) ; vp9_build_inter_predictor ( u_mb_ptr , uv_stride , & pred [ 256 ] , uv_block_size , & mv , scale , uv_block_size , uv_block_size , which_mv , kernel , mv_precision_uv , x , y ) ; vp9_build_inter_predictor ( v_mb_ptr , uv_stride , & pred [ 512 ] , uv_block_size , & mv , scale , uv_block_size , uv_block_size , which_mv , kernel , mv_precision_uv , x , y ) ; } "," stride , int uv_block_width , int uv_block_height , int mv_row const kernel = vp9_filter_kernels [ xd -> mi mbmi . interp_filter ] ; enum mv_precision ; if ( uv_block_width == 8 ) MV_PRECISION_Q3 ; } # if CONFIG_VP9_HIGHBITDEPTH if ( xd -> cur_buf -> flags & YV12_FLAG_HIGHBITDEPTH ) { vp9_highbd_build_inter_predictor ( y_mb_ptr , stride , & pred [ 0 ] , 16 , & mv , scale , 16 , 16 , which_mv , kernel , MV_PRECISION_Q3 , x , y , xd -> bd ) ; vp9_highbd_build_inter_predictor ( u_mb_ptr , uv_stride , & pred [ 256 ] , uv_block_width , & mv , scale , uv_block_width , uv_block_height , which_mv , kernel , mv_precision_uv , x , y , xd -> bd ) ; vp9_highbd_build_inter_predictor ( v_mb_ptr , uv_stride , & pred [ 512 ] , uv_block_width , & mv , scale , uv_block_width , uv_block_height , which_mv , kernel , mv_precision_uv , x , y , xd -> bd ) ; return ; } # endif 256 ] , uv_block_width , & mv , scale , uv_block_width , uv_block_height , which_mv , 512 ] , uv_block_width , & mv , scale , uv_block_width , uv_block_height , which_mv , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1622,CWE-120,"CWE-120 boolean parse_config_line ( origbuf ) char * origbuf ; { # if defined ( MICRO ) && ! defined ( NOCWD_ASSUMPTIONS ) static boolean ramdisk_specified = FALSE ; # endif # ifdef SYSCF int n , src = iflags . parse_config_file_src ; # endif char * bufp , buf [ 4 * BUFSZ ] ; uchar translate [ MAXPCHARS ] ; int len ; boolean retval = TRUE ; mungspaces ( strcpy ( buf , origbuf ) ) ; bufp = find_optparam ( buf ) ; if ( ! bufp ) { config_error_add ( ""Notaconfigstatement,missing\'=\'"" ) ; return FALSE ; } ++ bufp ; if ( * bufp == '' ) ++ bufp ; if ( match_varname ( buf , ""OPTIONS"" , 4 ) ) { bufp = find_optparam ( origbuf ) ; ++ bufp ; if ( ! parseoptions ( bufp , TRUE , TRUE ) ) retval = FALSE ; } else if ( match_varname ( buf , ""AUTOPICKUP_EXCEPTION"" , 5 ) ) { add_autopickup_exception ( bufp ) ; } else if ( match_varname ( buf , ""BINDINGS"" , 4 ) ) { if ( ! parsebindings ( bufp ) ) retval = FALSE ; } else if ( match_varname ( buf , ""AUTOCOMPLETE"" , 5 ) ) { parseautocomplete ( bufp , TRUE ) ; } else if ( match_varname ( buf , ""MSGTYPE"" , 7 ) ) { if ( ! msgtype_parse_add ( bufp ) ) retval = FALSE ; # ifdef NOCWD_ASSUMPTIONS } else if ( match_varname ( buf , ""HACKDIR"" , 4 ) ) { adjust_prefix ( bufp , HACKPREFIX ) ; } else if ( match_varname ( buf , ""LEVELDIR"" , 4 ) || match_varname ( buf , ""LEVELS"" , 4 ) ) { adjust_prefix ( bufp , LEVELPREFIX ) ; } else if ( match_varname ( buf , ""SAVEDIR"" , 4 ) ) { adjust_prefix ( bufp , SAVEPREFIX ) ; } else if ( match_varname ( buf , ""BONESDIR"" , 5 ) ) { adjust_prefix ( bufp , BONESPREFIX ) ; } else if ( match_varname ( buf , ""DATADIR"" , 4 ) ) { adjust_prefix ( bufp , DATAPREFIX ) ; } else if ( match_varname ( buf , ""SCOREDIR"" , 4 ) ) { adjust_prefix ( bufp , SCOREPREFIX ) ; } else if ( match_varname ( buf , ""LOCKDIR"" , 4 ) ) { adjust_prefix ( bufp , LOCKPREFIX ) ; } else if ( match_varname ( buf , ""CONFIGDIR"" , 4 ) ) { adjust_prefix ( bufp , CONFIGPREFIX ) ; } else if ( match_varname ( buf , ""TROUBLEDIR"" , 4 ) ) { adjust_prefix ( bufp , TROUBLEPREFIX ) ; # else # ifdef MICRO } else if ( match_varname ( buf , ""HACKDIR"" , 4 ) ) { ( void ) strncpy ( hackdir , bufp , PATHLEN - 1 ) ; # ifdef MFLOPPY } else if ( match_varname ( buf , ""RAMDISK"" , 3 ) ) { # ifndef AMIGA if ( strlen ( bufp ) >= PATHLEN ) bufp [ PATHLEN - 1 ] = '\\0' ; Strcpy ( levels , bufp ) ; ramdisk = ( strcmp ( permbones , levels ) != 0 ) ; ramdisk_specified = TRUE ; # endif # endif } else if ( match_varname ( buf , ""LEVELS"" , 4 ) ) { if ( strlen ( bufp ) >= PATHLEN ) bufp [ PATHLEN - 1 ] = '\\0' ; Strcpy ( permbones , bufp ) ; if ( ! ramdisk_specified || ! * levels ) Strcpy ( levels , bufp ) ; ramdisk = ( strcmp ( permbones , levels ) != 0 ) ; } else if ( match_varname ( buf , ""SAVE"" , 4 ) ) { # ifdef MFLOPPY extern int saveprompt ; # endif char * ptr ; if ( ( ptr = index ( bufp , ';' ) ) != 0 ) { * ptr = '\\0' ; # ifdef MFLOPPY if ( * ( ptr + 1 ) == 'n' || * ( ptr + 1 ) == 'N' ) { saveprompt = FALSE ; } # endif } # if defined ( SYSFLAGS ) && defined ( MFLOPPY ) else saveprompt = sysflags . asksavedisk ; # endif ( void ) strncpy ( SAVEP , bufp , SAVESIZE - 1 ) ; append_slash ( SAVEP ) ; # endif # endif } else if ( match_varname ( buf , ""NAME"" , 4 ) ) { ( void ) strncpy ( plname , bufp , PL_NSIZ - 1 ) ; } else if ( match_varname ( buf , ""ROLE"" , 4 ) || match_varname ( buf , ""CHARACTER"" , 4 ) ) { if ( ( len = str2role ( bufp ) ) >= 0 ) flags . initrole = len ; } else if ( match_varname ( buf , ""DOGNAME"" , 3 ) ) { ( void ) strncpy ( dogname , bufp , PL_PSIZ - 1 ) ; } else if ( match_varname ( buf , ""CATNAME"" , 3 ) ) { ( void ) strncpy ( catname , bufp , PL_PSIZ - 1 ) ; # ifdef SYSCF } else if ( src == SET_IN_SYS && match_varname ( buf , ""WIZARDS"" , 7 ) ) { if ( sysopt . wizards ) free ( ( genericptr_t ) sysopt . wizards ) ; sysopt . wizards = dupstr ( bufp ) ; if ( strlen ( sysopt . wizards ) && strcmp ( sysopt . wizards , ""*"" ) ) { if ( sysopt . fmtd_wizard_list ) free ( ( genericptr_t ) sysopt . fmtd_wizard_list ) ; sysopt . fmtd_wizard_list = build_english_list ( sysopt . wizards ) ; } } else if ( src == SET_IN_SYS && match_varname ( buf , ""SHELLERS"" , 8 ) ) { if ( sysopt . shellers ) free ( ( genericptr_t ) sysopt . shellers ) ; sysopt . shellers = dupstr ( bufp ) ; } else if ( src == SET_IN_SYS && match_varname ( buf , ""EXPLORERS"" , 7 ) ) { if ( sysopt . explorers ) free ( ( genericptr_t ) sysopt . explorers ) ; sysopt . explorers = dupstr ( bufp ) ; } else if ( src == SET_IN_SYS && match_varname ( buf , ""DEBUGFILES"" , 5 ) ) { if ( sysopt . env_dbgfl <= 0 ) { if ( sysopt . debugfiles ) free ( ( genericptr_t ) sysopt . debugfiles ) ; sysopt . debugfiles = dupstr ( bufp ) ; } } else if ( src == SET_IN_SYS && match_varname ( buf , ""DUMPLOGFILE"" , 7 ) ) { # ifdef DUMPLOG if ( sysopt . dumplogfile ) free ( ( genericptr_t ) sysopt . dumplogfile ) ; sysopt . dumplogfile = dupstr ( bufp ) ; # endif # ifdef WIN32 } else if ( src == SET_IN_SYS && match_varname ( buf , ""portable_device_top"" , 8 ) ) { if ( sysopt . portable_device_top ) free ( ( genericptr_t ) sysopt . portable_device_top ) ; sysopt . portable_device_top = dupstr ( bufp ) ; # endif } else if ( src == SET_IN_SYS && match_varname ( buf , ""GENERICUSERS"" , 12 ) ) { if ( sysopt . genericusers ) free ( ( genericptr_t ) sysopt . genericusers ) ; sysopt . genericusers = dupstr ( bufp ) ; } else if ( src == SET_IN_SYS && match_varname ( buf , ""BONES_POOLS"" , 10 ) ) { n = atoi ( bufp ) ; sysopt . bones_pools = ( n <= 0 ) ? 0 : min ( n , 10 ) ; } else if ( src == SET_IN_SYS && match_varname ( buf , ""SUPPORT"" , 7 ) ) { if ( sysopt . support ) free ( ( genericptr_t ) sysopt . support ) ; sysopt . support = dupstr ( bufp ) ; } else if ( src == SET_IN_SYS && match_varname ( buf , ""RECOVER"" , 7 ) ) { if ( sysopt . recover ) free ( ( genericptr_t ) sysopt . recover ) ; sysopt . recover = dupstr ( bufp ) ; } else if ( src == SET_IN_SYS && match_varname ( buf , ""CHECK_SAVE_UID"" , 14 ) ) { n = atoi ( bufp ) ; sysopt . check_save_uid = n ; } else if ( src == SET_IN_SYS && match_varname ( buf , ""CHECK_PLNAME"" , 12 ) ) { n = atoi ( bufp ) ; sysopt . check_plname = n ; } else if ( match_varname ( buf , ""SEDUCE"" , 6 ) ) { n = ! ! atoi ( bufp ) ; if ( src != SET_IN_SYS && n != 0 ) { config_error_add ( ""IllegalvalueinSEDUCE"" ) ; return FALSE ; } sysopt . seduce = n ; sysopt_seduce_set ( sysopt . seduce ) ; } else if ( src == SET_IN_SYS && match_varname ( buf , ""MAXPLAYERS"" , 10 ) ) { n = atoi ( bufp ) ; if ( n < 0 || n > 25 ) { config_error_add ( ""IllegalvalueinMAXPLAYERS(maximumis25)."" ) ; return FALSE ; } sysopt . maxplayers = n ; } else if ( src == SET_IN_SYS && match_varname ( buf , ""PERSMAX"" , 7 ) ) { n = atoi ( bufp ) ; if ( n < 1 ) { config_error_add ( ""IllegalvalueinPERSMAX(minimumis1)."" ) ; return FALSE ; } sysopt . persmax = n ; } else if ( src == SET_IN_SYS && match_varname ( buf , ""PERS_IS_UID"" , 11 ) ) { n = atoi ( bufp ) ; if ( n != 0 && n != 1 ) { config_error_add ( ""IllegalvalueinPERS_IS_UID(mustbe0or1)."" ) ; return FALSE ; } sysopt . pers_is_uid = n ; } else if ( src == SET_IN_SYS && match_varname ( buf , ""ENTRYMAX"" , 8 ) ) { n = atoi ( bufp ) ; if ( n < 10 ) { config_error_add ( ""IllegalvalueinENTRYMAX(minimumis10)."" ) ; return FALSE ; } sysopt . entrymax = n ; } else if ( ( src == SET_IN_SYS ) && match_varname ( buf , ""POINTSMIN"" , 9 ) ) { n = atoi ( bufp ) ; if ( n < 1 ) { config_error_add ( ""IllegalvalueinPOINTSMIN(minimumis1)."" ) ; return FALSE ; } sysopt . pointsmin = n ; } else if ( src == SET_IN_SYS && match_varname ( buf , ""MAX_STATUENAME_RANK"" , 10 ) ) { n = atoi ( bufp ) ; if ( n < 1 ) { config_error_add ( ""IllegalvalueinMAX_STATUENAME_RANK(minimumis1)."" ) ; return FALSE ; } sysopt . tt_oname_maxrank = n ; } else if ( src == SET_IN_SYS && match_varname ( buf , ""PANICTRACE_LIBC"" , 15 ) ) { n = atoi ( bufp ) ; # if defined ( PANICTRACE ) && defined ( PANICTRACE_LIBC ) if ( n < 0 || n > 2 ) { config_error_add ( ""IllegalvalueinPANICTRACE_LIBC(not0,1,2)."" ) ; return FALSE ; } # endif sysopt . panictrace_libc = n ; } else if ( src == SET_IN_SYS && match_varname ( buf , ""PANICTRACE_GDB"" , 14 ) ) { n = atoi ( bufp ) ; # if defined ( PANICTRACE ) if ( n < 0 || n > 2 ) { config_error_add ( ""IllegalvalueinPANICTRACE_GDB(not0,1,2)."" ) ; return FALSE ; } # endif sysopt . panictrace_gdb = n ; } else if ( src == SET_IN_SYS && match_varname ( buf , ""GDBPATH"" , 7 ) ) { # if defined ( PANICTRACE ) && ! defined ( VMS ) if ( ! file_exists ( bufp ) ) { config_error_add ( ""FilespecifiedinGDBPATHdoesnotexist."" ) ; return FALSE ; } # endif if ( sysopt . gdbpath ) free ( ( genericptr_t ) sysopt . gdbpath ) ; sysopt . gdbpath = dupstr ( bufp ) ; } else if ( src == SET_IN_SYS && match_varname ( buf , ""GREPPATH"" , 7 ) ) { # if defined ( PANICTRACE ) && ! defined ( VMS ) if ( ! file_exists ( bufp ) ) { config_error_add ( ""FilespecifiedinGREPPATHdoesnotexist."" ) ; return FALSE ; } # endif if ( sysopt . greppath ) free ( ( genericptr_t ) sysopt . greppath ) ; sysopt . greppath = dupstr ( bufp ) ; } else if ( src == SET_IN_SYS && match_varname ( buf , ""ACCESSIBILITY"" , 13 ) ) { n = atoi ( bufp ) ; if ( n < 0 || n > 1 ) { config_error_add ( ""IllegalvalueinACCESSIBILITY(not0,1)."" ) ; return FALSE ; } sysopt . accessibility = n ; # endif } else if ( match_varname ( buf , ""BOULDER"" , 3 ) ) { ( void ) get_uchars ( bufp , & ov_primary_syms [ SYM_BOULDER + SYM_OFF_X ] , TRUE , 1 , ""BOULDER"" ) ; } else if ( match_varname ( buf , ""MENUCOLOR"" , 9 ) ) { if ( ! add_menu_coloring ( bufp ) ) retval = FALSE ; } else if ( match_varname ( buf , ""HILITE_STATUS"" , 6 ) ) { # ifdef STATUS_HILITES if ( ! parse_status_hl1 ( bufp , TRUE ) ) retval = FALSE ; # endif } else if ( match_varname ( buf , ""WARNINGS"" , 5 ) ) { ( void ) get_uchars ( bufp , translate , FALSE , WARNCOUNT , ""WARNINGS"" ) ; assign_warnings ( translate ) ; } else if ( match_varname ( buf , ""ROGUESYMBOLS"" , 4 ) ) { if ( ! parsesymbols ( bufp , ROGUESET ) ) { config_error_add ( ""ErrorinROGUESYMBOLSdefinition\'%s\'"" , bufp ) ; retval = FALSE ; } switch_symbols ( TRUE ) ; } else if ( match_varname ( buf , ""SYMBOLS"" , 4 ) ) { if ( ! parsesymbols ( bufp , PRIMARY ) ) { config_error_add ( ""ErrorinSYMBOLSdefinition\'%s\'"" , bufp ) ; retval = FALSE ; } switch_symbols ( TRUE ) ; } else if ( match_varname ( buf , ""WIZKIT"" , 6 ) ) { ( void ) strncpy ( wizkit , bufp , WIZKIT_MAX - 1 ) ; # ifdef AMIGA } else if ( match_varname ( buf , ""FONT"" , 4 ) ) { char * t ; if ( t = strchr ( buf + 5 , ':' ) ) { * t = 0 ; amii_set_text_font ( buf + 5 , atoi ( t + 1 ) ) ; * t = ':' ; } } else if ( match_varname ( buf , ""PATH"" , 4 ) ) { ( void ) strncpy ( PATH , bufp , PATHLEN - 1 ) ; } else if ( match_varname ( buf , ""DEPTH"" , 5 ) ) { extern int amii_numcolors ; int val = atoi ( bufp ) ; amii_numcolors = 1L << min ( DEPTH , val ) ; # ifdef SYSFLAGS } else if ( match_varname ( buf , ""DRIPENS"" , 7 ) ) { int i , val ; char * t ; for ( i = 0 , t = strtok ( bufp , "",/"" ) ; t != ( char * ) 0 ; i < 20 && ( t = strtok ( ( char * ) 0 , "",/"" ) ) , ++ i ) { sscanf ( t , ""%d"" , & val ) ; sysflags . amii_dripens [ i ] = val ; } # endif } else if ( match_varname ( buf , ""SCREENMODE"" , 10 ) ) { extern long amii_scrnmode ; if ( ! stricmp ( bufp , ""req"" ) ) amii_scrnmode = 0xffffffff ; else if ( sscanf ( bufp , ""%x"" , & amii_scrnmode ) != 1 ) amii_scrnmode = 0 ; } else if ( match_varname ( buf , ""MSGPENS"" , 7 ) ) { extern int amii_msgAPen , amii_msgBPen ; char * t = strtok ( bufp , "",/"" ) ; if ( t ) { sscanf ( t , ""%d"" , & amii_msgAPen ) ; if ( t = strtok ( ( char * ) 0 , "",/"" ) ) sscanf ( t , ""%d"" , & amii_msgBPen ) ; } } else if ( match_varname ( buf , ""TEXTPENS"" , 8 ) ) { extern int amii_textAPen , amii_textBPen ; char * t = strtok ( bufp , "",/"" ) ; if ( t ) { sscanf ( t , ""%d"" , & amii_textAPen ) ; if ( t = strtok ( ( char * ) 0 , "",/"" ) ) sscanf ( t , ""%d"" , & amii_textBPen ) ; } } else if ( match_varname ( buf , ""MENUPENS"" , 8 ) ) { extern int amii_menuAPen , amii_menuBPen ; char * t = strtok ( bufp , "",/"" ) ; if ( t ) { sscanf ( t , ""%d"" , & amii_menuAPen ) ; if ( t = strtok ( ( char * ) 0 , "",/"" ) ) sscanf ( t , ""%d"" , & amii_menuBPen ) ; } } else if ( match_varname ( buf , ""STATUSPENS"" , 10 ) ) { extern int amii_statAPen , amii_statBPen ; char * t = strtok ( bufp , "",/"" ) ; if ( t ) { sscanf ( t , ""%d"" , & amii_statAPen ) ; if ( t = strtok ( ( char * ) 0 , "",/"" ) ) sscanf ( t , ""%d"" , & amii_statBPen ) ; } } else if ( match_varname ( buf , ""OTHERPENS"" , 9 ) ) { extern int amii_otherAPen , amii_otherBPen ; char * t = strtok ( bufp , "",/"" ) ; if ( t ) { sscanf ( t , ""%d"" , & amii_otherAPen ) ; if ( t = strtok ( ( char * ) 0 , "",/"" ) ) sscanf ( t , ""%d"" , & amii_otherBPen ) ; } } else if ( match_varname ( buf , ""PENS"" , 4 ) ) { extern unsigned short amii_init_map [ AMII_MAXCOLORS ] ; int i ; char * t ; for ( i = 0 , t = strtok ( bufp , "",/"" ) ; i < AMII_MAXCOLORS && t != ( char * ) 0 ; t = strtok ( ( char * ) 0 , "",/"" ) , ++ i ) { sscanf ( t , ""%hx"" , & amii_init_map [ i ] ) ; } amii_setpens ( amii_numcolors = i ) ; } else if ( match_varname ( buf , ""FGPENS"" , 6 ) ) { extern int foreg [ AMII_MAXCOLORS ] ; int i ; char * t ; for ( i = 0 , t = strtok ( bufp , "",/"" ) ; i < AMII_MAXCOLORS && t != ( char * ) 0 ; t = strtok ( ( char * ) 0 , "",/"" ) , ++ i ) { sscanf ( t , ""%d"" , & foreg [ i ] ) ; } } else if ( match_varname ( buf , ""BGPENS"" , 6 ) ) { extern int backg [ AMII_MAXCOLORS ] ; int i ; char * t ; for ( i = 0 , t = strtok ( bufp , "",/"" ) ; i < AMII_MAXCOLORS && t != ( char * ) 0 ; t = strtok ( ( char * ) 0 , "",/"" ) , ++ i ) { sscanf ( t , ""%d"" , & backg [ i ] ) ; } # endif # ifdef USER_SOUNDS } else if ( match_varname ( buf , ""SOUNDDIR"" , 8 ) ) { sounddir = dupstr ( bufp ) ; } else if ( match_varname ( buf , ""SOUND"" , 5 ) ) { add_sound_mapping ( bufp ) ; # endif } else if ( match_varname ( buf , ""QT_TILEWIDTH"" , 12 ) ) { # ifdef QT_GRAPHICS extern char * qt_tilewidth ; if ( qt_tilewidth == NULL ) qt_tilewidth = dupstr ( bufp ) ; # endif } else if ( match_varname ( buf , ""QT_TILEHEIGHT"" , 13 ) ) { # ifdef QT_GRAPHICS extern char * qt_tileheight ; if ( qt_tileheight == NULL ) qt_tileheight = dupstr ( bufp ) ; # endif } else if ( match_varname ( buf , ""QT_FONTSIZE"" , 11 ) ) { # ifdef QT_GRAPHICS extern char * qt_fontsize ; if ( qt_fontsize == NULL ) qt_fontsize = dupstr ( bufp ) ; # endif } else if ( match_varname ( buf , ""QT_COMPACT"" , 10 ) ) { # ifdef QT_GRAPHICS extern int qt_compact_mode ; qt_compact_mode = atoi ( bufp ) ; # endif } else { config_error_add ( ""Unknownconfigstatement"" ) ; return FALSE ; } return retval ; } "," = TRUE ; while ( * origbuf == '' || * origbuf == '\\t' ) ++ origbuf ; ( void ) strncpy ( buf , origbuf , sizeof buf - 1 ) ; buf [ sizeof buf - 1 ] = '\\0' ; mungspaces ( buf ) ; bufp ",NetHack@NetHack/f4a840a48f4bcf11757b3d859e9d53cc9d5ef226,CVE-2019-19905,https://github.com/NetHack/NetHack/commit/f4a840a48f4bcf11757b3d859e9d53cc9d5ef226,2019-12-19T18:15Z 1623,CWE-119,"CWE-119 cJSON * cJSON_CreateFloatArray ( double * numbers , int count ) { int i ; cJSON * n = 0 , * p = 0 , * a = cJSON_CreateArray ( ) ; for ( i = 0 ; a && i < count ; ++ i ) { n = cJSON_CreateFloat ( numbers [ i ] ) ; if ( ! i ) a -> child = n ; else suffix_object ( p , n ) ; p = n ; } return a ; } "," * cJSON_CreateFloatArray ( const float * numbers , < count ; i ++ ) { n { n = cJSON_CreateNumber ( numbers [ ] ) ; if ( ! n ) { cJSON_Delete ( a ) ; return 0 ; } ",esnet@iperf/91f2fa59e8ed80dfbf400add0164ee0e508e412a,CVE-2016-4303,https://github.com/esnet/iperf/commit/91f2fa59e8ed80dfbf400add0164ee0e508e412a,2016-09-26T14:59Z 1624,CWE-400,"CWE-400 static void nlmclnt_unlock_callback ( struct rpc_task * task , void * data ) { struct nlm_rqst * req = data ; u32 status = ntohl ( req -> a_res . status ) ; if ( RPC_ASSASSINATED ( task ) ) goto die ; if ( task -> tk_status < 0 ) { dprintk ( ""lockd:unlockfailed(err=%d)\\n"" , - task -> tk_status ) ; goto retry_rebind ; } if ( status == NLM_LCK_DENIED_GRACE_PERIOD ) { rpc_delay ( task , NLMCLNT_GRACE_WAIT ) ; goto retry_unlock ; } if ( status != NLM_LCK_GRANTED ) printk ( KERN_WARNING ""lockd:unexpectedunlockstatus:%d\\n"" , status ) ; die : return ; retry_rebind : nlm_rebind_host ( req -> a_host ) ; retry_unlock : rpc_restart_call ( task ) ; } "," tk_status ) ; switch ( task -> tk_status ) { case - EACCES : case - EIO : goto die ; default : goto retry_rebind ; } ",torvalds@linux/0b760113a3a155269a3fba93a409c640031dd68f,CVE-2011-2491,https://github.com/torvalds/linux/commit/0b760113a3a155269a3fba93a409c640031dd68f,2013-03-01T12:37Z 1625,CWE-399,"CWE-399 static void __udf_read_inode ( struct inode * inode ) { struct buffer_head * bh = NULL ; struct fileEntry * fe ; struct extendedFileEntry * efe ; uint16_t ident ; struct udf_inode_info * iinfo = UDF_I ( inode ) ; struct udf_sb_info * sbi = UDF_SB ( inode -> i_sb ) ; unsigned int link_count ; bh = udf_read_ptagged ( inode -> i_sb , & iinfo -> i_location , 0 , & ident ) ; if ( ! bh ) { udf_err ( inode -> i_sb , ""(ino%ld)failed!bh\\n"" , inode -> i_ino ) ; make_bad_inode ( inode ) ; return ; } if ( ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE && ident != TAG_IDENT_USE ) { udf_err ( inode -> i_sb , ""(ino%ld)failedident=%d\\n"" , inode -> i_ino , ident ) ; brelse ( bh ) ; make_bad_inode ( inode ) ; return ; } fe = ( struct fileEntry * ) bh -> b_data ; efe = ( struct extendedFileEntry * ) bh -> b_data ; if ( fe -> icbTag . strategyType == cpu_to_le16 ( 4096 ) ) { struct buffer_head * ibh ; ibh = udf_read_ptagged ( inode -> i_sb , & iinfo -> i_location , 1 , & ident ) ; if ( ident == TAG_IDENT_IE && ibh ) { struct buffer_head * nbh = NULL ; struct kernel_lb_addr loc ; struct indirectEntry * ie ; ie = ( struct indirectEntry * ) ibh -> b_data ; loc = lelb_to_cpu ( ie -> indirectICB . extLocation ) ; if ( ie -> indirectICB . extLength && ( nbh = udf_read_ptagged ( inode -> i_sb , & loc , 0 , & ident ) ) ) { if ( ident == TAG_IDENT_FE || ident == TAG_IDENT_EFE ) { memcpy ( & iinfo -> i_location , & loc , sizeof ( struct kernel_lb_addr ) ) ; brelse ( bh ) ; brelse ( ibh ) ; brelse ( nbh ) ; __udf_read_inode ( inode ) ; return ; } brelse ( nbh ) ; } } brelse ( ibh ) ; } else if ( fe -> icbTag . strategyType != cpu_to_le16 ( 4 ) ) { udf_err ( inode -> i_sb , ""unsupportedstrategytype:%d\\n"" , le16_to_cpu ( fe -> icbTag . strategyType ) ) ; brelse ( bh ) ; make_bad_inode ( inode ) ; return ; } if ( fe -> icbTag . strategyType == cpu_to_le16 ( 4 ) ) iinfo -> i_strat4096 = 0 ; else iinfo -> i_strat4096 = 1 ; iinfo -> i_alloc_type = le16_to_cpu ( fe -> icbTag . flags ) & ICBTAG_FLAG_AD_MASK ; iinfo -> i_unique = 0 ; iinfo -> i_lenEAttr = 0 ; iinfo -> i_lenExtents = 0 ; iinfo -> i_lenAlloc = 0 ; iinfo -> i_next_alloc_block = 0 ; iinfo -> i_next_alloc_goal = 0 ; if ( fe -> descTag . tagIdent == cpu_to_le16 ( TAG_IDENT_EFE ) ) { iinfo -> i_efe = 1 ; iinfo -> i_use = 0 ; if ( udf_alloc_i_data ( inode , inode -> i_sb -> s_blocksize - sizeof ( struct extendedFileEntry ) ) ) { make_bad_inode ( inode ) ; return ; } memcpy ( iinfo -> i_ext . i_data , bh -> b_data + sizeof ( struct extendedFileEntry ) , inode -> i_sb -> s_blocksize - sizeof ( struct extendedFileEntry ) ) ; } else if ( fe -> descTag . tagIdent == cpu_to_le16 ( TAG_IDENT_FE ) ) { iinfo -> i_efe = 0 ; iinfo -> i_use = 0 ; if ( udf_alloc_i_data ( inode , inode -> i_sb -> s_blocksize - sizeof ( struct fileEntry ) ) ) { make_bad_inode ( inode ) ; return ; } memcpy ( iinfo -> i_ext . i_data , bh -> b_data + sizeof ( struct fileEntry ) , inode -> i_sb -> s_blocksize - sizeof ( struct fileEntry ) ) ; } else if ( fe -> descTag . tagIdent == cpu_to_le16 ( TAG_IDENT_USE ) ) { iinfo -> i_efe = 0 ; iinfo -> i_use = 1 ; iinfo -> i_lenAlloc = le32_to_cpu ( ( ( struct unallocSpaceEntry * ) bh -> b_data ) -> lengthAllocDescs ) ; if ( udf_alloc_i_data ( inode , inode -> i_sb -> s_blocksize - sizeof ( struct unallocSpaceEntry ) ) ) { make_bad_inode ( inode ) ; return ; } memcpy ( iinfo -> i_ext . i_data , bh -> b_data + sizeof ( struct unallocSpaceEntry ) , inode -> i_sb -> s_blocksize - sizeof ( struct unallocSpaceEntry ) ) ; return ; } read_lock ( & sbi -> s_cred_lock ) ; i_uid_write ( inode , le32_to_cpu ( fe -> uid ) ) ; if ( ! uid_valid ( inode -> i_uid ) || UDF_QUERY_FLAG ( inode -> i_sb , UDF_FLAG_UID_IGNORE ) || UDF_QUERY_FLAG ( inode -> i_sb , UDF_FLAG_UID_SET ) ) inode -> i_uid = UDF_SB ( inode -> i_sb ) -> s_uid ; i_gid_write ( inode , le32_to_cpu ( fe -> gid ) ) ; if ( ! gid_valid ( inode -> i_gid ) || UDF_QUERY_FLAG ( inode -> i_sb , UDF_FLAG_GID_IGNORE ) || UDF_QUERY_FLAG ( inode -> i_sb , UDF_FLAG_GID_SET ) ) inode -> i_gid = UDF_SB ( inode -> i_sb ) -> s_gid ; if ( fe -> icbTag . fileType != ICBTAG_FILE_TYPE_DIRECTORY && sbi -> s_fmode != UDF_INVALID_MODE ) inode -> i_mode = sbi -> s_fmode ; else if ( fe -> icbTag . fileType == ICBTAG_FILE_TYPE_DIRECTORY && sbi -> s_dmode != UDF_INVALID_MODE ) inode -> i_mode = sbi -> s_dmode ; else inode -> i_mode = udf_convert_permissions ( fe ) ; inode -> i_mode &= ~ sbi -> s_umask ; read_unlock ( & sbi -> s_cred_lock ) ; link_count = le16_to_cpu ( fe -> fileLinkCount ) ; if ( ! link_count ) link_count = 1 ; set_nlink ( inode , link_count ) ; inode -> i_size = le64_to_cpu ( fe -> informationLength ) ; iinfo -> i_lenExtents = inode -> i_size ; if ( iinfo -> i_efe == 0 ) { inode -> i_blocks = le64_to_cpu ( fe -> logicalBlocksRecorded ) << ( inode -> i_sb -> s_blocksize_bits - 9 ) ; if ( ! udf_disk_stamp_to_time ( & inode -> i_atime , fe -> accessTime ) ) inode -> i_atime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & inode -> i_mtime , fe -> modificationTime ) ) inode -> i_mtime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & inode -> i_ctime , fe -> attrTime ) ) inode -> i_ctime = sbi -> s_record_time ; iinfo -> i_unique = le64_to_cpu ( fe -> uniqueID ) ; iinfo -> i_lenEAttr = le32_to_cpu ( fe -> lengthExtendedAttr ) ; iinfo -> i_lenAlloc = le32_to_cpu ( fe -> lengthAllocDescs ) ; iinfo -> i_checkpoint = le32_to_cpu ( fe -> checkpoint ) ; } else { inode -> i_blocks = le64_to_cpu ( efe -> logicalBlocksRecorded ) << ( inode -> i_sb -> s_blocksize_bits - 9 ) ; if ( ! udf_disk_stamp_to_time ( & inode -> i_atime , efe -> accessTime ) ) inode -> i_atime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & inode -> i_mtime , efe -> modificationTime ) ) inode -> i_mtime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & iinfo -> i_crtime , efe -> createTime ) ) iinfo -> i_crtime = sbi -> s_record_time ; if ( ! udf_disk_stamp_to_time ( & inode -> i_ctime , efe -> attrTime ) ) inode -> i_ctime = sbi -> s_record_time ; iinfo -> i_unique = le64_to_cpu ( efe -> uniqueID ) ; iinfo -> i_lenEAttr = le32_to_cpu ( efe -> lengthExtendedAttr ) ; iinfo -> i_lenAlloc = le32_to_cpu ( efe -> lengthAllocDescs ) ; iinfo -> i_checkpoint = le32_to_cpu ( efe -> checkpoint ) ; } switch ( fe -> icbTag . fileType ) { case ICBTAG_FILE_TYPE_DIRECTORY : inode -> i_op = & udf_dir_inode_operations ; inode -> i_fop = & udf_dir_operations ; inode -> i_mode |= S_IFDIR ; inc_nlink ( inode ) ; break ; case ICBTAG_FILE_TYPE_REALTIME : case ICBTAG_FILE_TYPE_REGULAR : case ICBTAG_FILE_TYPE_UNDEF : case ICBTAG_FILE_TYPE_VAT20 : if ( iinfo -> i_alloc_type == ICBTAG_FLAG_AD_IN_ICB ) inode -> i_data . a_ops = & udf_adinicb_aops ; else inode -> i_data . a_ops = & udf_aops ; inode -> i_op = & udf_file_inode_operations ; inode -> i_fop = & udf_file_operations ; inode -> i_mode |= S_IFREG ; break ; case ICBTAG_FILE_TYPE_BLOCK : inode -> i_mode |= S_IFBLK ; break ; case ICBTAG_FILE_TYPE_CHAR : inode -> i_mode |= S_IFCHR ; break ; case ICBTAG_FILE_TYPE_FIFO : init_special_inode ( inode , inode -> i_mode | S_IFIFO , 0 ) ; break ; case ICBTAG_FILE_TYPE_SOCKET : init_special_inode ( inode , inode -> i_mode | S_IFSOCK , 0 ) ; break ; case ICBTAG_FILE_TYPE_SYMLINK : inode -> i_data . a_ops = & udf_symlink_aops ; inode -> i_op = & udf_symlink_inode_operations ; inode -> i_mode = S_IFLNK | S_IRWXUGO ; break ; case ICBTAG_FILE_TYPE_MAIN : udf_debug ( ""METADATAFILE-----\\n"" ) ; break ; case ICBTAG_FILE_TYPE_MIRROR : udf_debug ( ""METADATAMIRRORFILE-----\\n"" ) ; break ; case ICBTAG_FILE_TYPE_BITMAP : udf_debug ( ""METADATABITMAPFILE-----\\n"" ) ; break ; default : udf_err ( inode -> i_sb , ""(ino%ld)failedunknownfiletype=%d\\n"" , inode -> i_ino , fe -> icbTag . fileType ) ; make_bad_inode ( inode ) ; return ; } if ( S_ISCHR ( inode -> i_mode ) || S_ISBLK ( inode -> i_mode ) ) { struct deviceSpec * dsea = ( struct deviceSpec * ) udf_get_extendedattr ( inode , 12 , 1 ) ; if ( dsea ) { init_special_inode ( inode , inode -> i_mode , MKDEV ( le32_to_cpu ( dsea -> majorDeviceIdent ) , le32_to_cpu ( dsea -> minorDeviceIdent ) ) ) ; } else make_bad_inode ( inode ) ; } brelse ( bh ) ; } "," int link_count ; unsigned int indirections = 0 ; reread : ) { struct kernel_lb_addr loc ; indirectICB . extLength ) { brelse ( bh ) ; brelse ( ibh ) ; memcpy ( & iinfo -> i_location , & loc & loc , sizeof ( struct kernel_lb_addr ) ) ; if ( ++ indirections > UDF_MAX_ICB_NESTING ) { udf_err ( inode -> i_sb , ""toomanyICBsinICBhierarchy"" ""(max%dsupported)\\n"" , UDF_MAX_ICB_NESTING ) ; make_bad_inode ( inode ) return ; } goto reread ; } } ",torvalds@linux/c03aa9f6e1f938618e6db2e23afef0574efeeb65,CVE-2014-6410,https://github.com/torvalds/linux/commit/c03aa9f6e1f938618e6db2e23afef0574efeeb65,2014-09-28T10:55Z 1626,CWE-119,"CWE-119 static int vorbis_finish_frame ( stb_vorbis * f , int len , int left , int right ) { int prev , i , j ; if ( f -> previous_length ) { int i , j , n = f -> previous_length ; float * w = get_window ( f , n ) ; for ( i = 0 ; i < f -> channels ; ++ i ) { for ( j = 0 ; j < n ; ++ j ) f -> channel_buffers [ i ] [ left + j ] = f -> channel_buffers [ i ] [ left + j ] * w [ j ] + f -> previous_window [ i ] [ j ] * w [ n - 1 - j ] ; } } prev = f -> previous_length ; f -> previous_length = len - right ; for ( i = 0 ; i < f -> channels ; ++ i ) for ( j = 0 ; right + j < len ; ++ j ) f -> previous_window [ i ] [ j ] = f -> channel_buffers [ i ] [ right + j ] ; if ( ! prev ) return 0 ; if ( len < right ) right = len ; f -> samples_output += right - left ; return right - left ; } "," , n ) ; if ( w == NULL ) return 0 ",nothings@stb/98fdfc6df88b1e34a736d5e126e6c8139c8de1a6,CVE-2019-13217,https://github.com/nothings/stb/commit/98fdfc6df88b1e34a736d5e126e6c8139c8de1a6,2019-08-15T17:15Z 1627,CWE-787,"CWE-787 MAPI_Attr * * mapi_attr_read ( size_t len , unsigned char * buf ) { size_t idx = 0 ; uint32 i , j ; assert ( len > 4 ) ; uint32 num_properties = GETINT32 ( buf + idx ) ; MAPI_Attr * * attrs = CHECKED_XMALLOC ( MAPI_Attr * , ( num_properties + 1 ) ) ; idx += 4 ; if ( ! attrs ) return NULL ; for ( i = 0 ; i < num_properties ; i ++ ) { MAPI_Attr * a = attrs [ i ] = CHECKED_XCALLOC ( MAPI_Attr , 1 ) ; MAPI_Value * v = NULL ; CHECKINT16 ( idx , len ) ; a -> type = GETINT16 ( buf + idx ) ; idx += 2 ; CHECKINT16 ( idx , len ) ; a -> name = GETINT16 ( buf + idx ) ; idx += 2 ; if ( a -> name & GUID_EXISTS_FLAG ) { a -> guid = CHECKED_XMALLOC ( GUID , 1 ) ; copy_guid_from_buf ( a -> guid , buf + idx , len ) ; idx += sizeof ( GUID ) ; CHECKINT32 ( idx , len ) ; a -> num_names = GETINT32 ( buf + idx ) ; idx += 4 ; if ( a -> num_names > 0 ) { size_t i ; a -> names = CHECKED_XCALLOC ( VarLenData , a -> num_names ) ; for ( i = 0 ; i < a -> num_names ; i ++ ) { size_t j ; CHECKINT32 ( idx , len ) ; a -> names [ i ] . len = GETINT32 ( buf + idx ) ; idx += 4 ; a -> names [ i ] . data = CHECKED_XMALLOC ( unsigned char , a -> names [ i ] . len ) ; for ( j = 0 ; j < ( a -> names [ i ] . len >> 1 ) ; j ++ ) a -> names [ i ] . data [ j ] = ( buf + idx ) [ j * 2 ] ; idx += pad_to_4byte ( a -> names [ i ] . len ) ; } } else { CHECKINT32 ( idx , len ) ; a -> name = GETINT32 ( buf + idx ) ; idx += 4 ; } } if ( a -> type & MULTI_VALUE_FLAG || a -> type == szMAPI_STRING || a -> type == szMAPI_UNICODE_STRING || a -> type == szMAPI_OBJECT || a -> type == szMAPI_BINARY ) { CHECKINT32 ( idx , len ) ; a -> num_values = GETINT32 ( buf + idx ) ; idx += 4 ; } else { a -> num_values = 1 ; } if ( a -> type & MULTI_VALUE_FLAG ) { a -> type -= MULTI_VALUE_FLAG ; } v = alloc_mapi_values ( a ) ; for ( j = 0 ; j < a -> num_values ; j ++ ) { switch ( a -> type ) { case szMAPI_SHORT : v -> len = 2 ; CHECKINT16 ( idx , len ) ; v -> data . bytes2 = GETINT16 ( buf + idx ) ; idx += 4 ; break ; case szMAPI_INT : v -> len = 4 ; CHECKINT32 ( idx , len ) ; v -> data . bytes4 = GETINT32 ( buf + idx ) ; idx += 4 ; v ++ ; break ; case szMAPI_FLOAT : case szMAPI_BOOLEAN : v -> len = 4 ; CHECKINT32 ( idx , len ) ; v -> data . bytes4 = GETINT32 ( buf + idx ) ; idx += v -> len ; break ; case szMAPI_SYSTIME : v -> len = 8 ; CHECKINT32 ( idx , len ) ; v -> data . bytes8 [ 0 ] = GETINT32 ( buf + idx ) ; CHECKINT32 ( idx + 4 , len ) ; v -> data . bytes8 [ 1 ] = GETINT32 ( buf + idx + 4 ) ; idx += 8 ; v ++ ; break ; case szMAPI_DOUBLE : case szMAPI_APPTIME : case szMAPI_CURRENCY : case szMAPI_INT8BYTE : v -> len = 8 ; CHECKINT32 ( idx , len ) ; v -> data . bytes8 [ 0 ] = GETINT32 ( buf + idx ) ; CHECKINT32 ( idx + 4 , len ) ; v -> data . bytes8 [ 1 ] = GETINT32 ( buf + idx + 4 ) ; idx += v -> len ; break ; case szMAPI_CLSID : v -> len = sizeof ( GUID ) ; copy_guid_from_buf ( & v -> data . guid , buf + idx , len ) ; idx += v -> len ; break ; case szMAPI_STRING : case szMAPI_UNICODE_STRING : case szMAPI_OBJECT : case szMAPI_BINARY : CHECKINT32 ( idx , len ) ; v -> len = GETINT32 ( buf + idx ) ; idx += 4 ; if ( a -> type == szMAPI_UNICODE_STRING ) { v -> data . buf = ( unsigned char * ) unicode_to_utf8 ( v -> len , buf + idx ) ; } else { v -> data . buf = CHECKED_XMALLOC ( unsigned char , v -> len ) ; memmove ( v -> data . buf , buf + idx , v -> len ) ; } idx += pad_to_4byte ( v -> len ) ; v ++ ; break ; case szMAPI_NULL : case szMAPI_ERROR : case szMAPI_UNSPECIFIED : fprintf ( stderr , ""Invalidattribute,inputfilemaybecorrupted\\n"" ) ; if ( ! ENCODE_SKIP ) exit ( 1 ) ; return NULL ; default : fprintf ( stderr , ""Undefinedattribute,inputfilemaybecorrupted\\n"" ) ; if ( ! ENCODE_SKIP ) exit ( 1 ) ; return NULL ; } if ( DEBUG_ON ) mapi_attr_dump ( attrs [ i ] ) ; } } attrs [ i ] = NULL ; return attrs ; } "," buf + idx ) ; assert ( ( num_properties + 1 ) != 0 len ) ; assert ( ( idx + ( a -> names [ i ] . len * 2 ) ) <= len ) ; += 4 ; assert ( v -> len + idx <= len ) ; szMAPI_UNICODE_STRING ) { assert ( v -> len != 0 ) ; ",verdammelt@tnef/1a17af1ed0c791aec44dbdc9eab91218cc1e335a,CVE-2017-6307,https://github.com/verdammelt/tnef/commit/1a17af1ed0c791aec44dbdc9eab91218cc1e335a,2017-02-24T04:59Z 1628,CWE-119,"CWE-119 static const uint8_t * decode_tiles_mt ( VP9Decoder * pbi , const uint8_t * data , const uint8_t * data_end ) { VP9_COMMON * const cm = & pbi -> common ; const uint8_t * bit_reader_end = NULL ; const int aligned_mi_cols = mi_cols_aligned_to_sb ( cm -> mi_cols ) ; const int tile_cols = 1 << cm -> log2_tile_cols ; const int tile_rows = 1 << cm -> log2_tile_rows ; const int num_workers = MIN ( pbi -> oxcf . max_threads & ~ 1 , tile_cols ) ; TileBuffer tile_buffers [ 1 << 6 ] ; int n ; int final_worker = - 1 ; assert ( tile_cols <= ( 1 << 6 ) ) ; assert ( tile_rows == 1 ) ; ( void ) tile_rows ; if ( pbi -> num_tile_workers == 0 ) { const int num_threads = pbi -> oxcf . max_threads & ~ 1 ; int i ; CHECK_MEM_ERROR ( cm , pbi -> tile_workers , vpx_malloc ( num_threads * sizeof ( * pbi -> tile_workers ) ) ) ; for ( i = 0 ; i < num_threads ; ++ i ) { VP9Worker * const worker = & pbi -> tile_workers [ i ] ; ++ pbi -> num_tile_workers ; vp9_worker_init ( worker ) ; CHECK_MEM_ERROR ( cm , worker -> data1 , vpx_memalign ( 32 , sizeof ( TileWorkerData ) ) ) ; CHECK_MEM_ERROR ( cm , worker -> data2 , vpx_malloc ( sizeof ( TileInfo ) ) ) ; if ( i < num_threads - 1 && ! vp9_worker_reset ( worker ) ) { vpx_internal_error ( & cm -> error , VPX_CODEC_ERROR , ""Tiledecoderthreadcreationfailed"" ) ; } } } for ( n = 0 ; n < num_workers ; ++ n ) { pbi -> tile_workers [ n ] . hook = ( VP9WorkerHook ) tile_worker_hook ; } vpx_memset ( cm -> above_context , 0 , sizeof ( * cm -> above_context ) * MAX_MB_PLANE * 2 * aligned_mi_cols ) ; vpx_memset ( cm -> above_seg_context , 0 , sizeof ( * cm -> above_seg_context ) * aligned_mi_cols ) ; for ( n = 0 ; n < tile_cols ; ++ n ) { const size_t size = get_tile ( data_end , n == tile_cols - 1 , & cm -> error , & data ) ; TileBuffer * const buf = & tile_buffers [ n ] ; buf -> data = data ; buf -> size = size ; buf -> col = n ; data += size ; } qsort ( tile_buffers , tile_cols , sizeof ( tile_buffers [ 0 ] ) , compare_tile_buffers ) ; { int group_start = 0 ; while ( group_start < tile_cols ) { const TileBuffer largest = tile_buffers [ group_start ] ; const int group_end = MIN ( group_start + num_workers , tile_cols ) - 1 ; memmove ( tile_buffers + group_start , tile_buffers + group_start + 1 , ( group_end - group_start ) * sizeof ( tile_buffers [ 0 ] ) ) ; tile_buffers [ group_end ] = largest ; group_start = group_end + 1 ; } } n = 0 ; while ( n < tile_cols ) { int i ; for ( i = 0 ; i < num_workers && n < tile_cols ; ++ i ) { VP9Worker * const worker = & pbi -> tile_workers [ i ] ; TileWorkerData * const tile_data = ( TileWorkerData * ) worker -> data1 ; TileInfo * const tile = ( TileInfo * ) worker -> data2 ; TileBuffer * const buf = & tile_buffers [ n ] ; tile_data -> cm = cm ; tile_data -> xd = pbi -> mb ; tile_data -> xd . corrupted = 0 ; vp9_tile_init ( tile , tile_data -> cm , 0 , buf -> col ) ; setup_token_decoder ( buf -> data , data_end , buf -> size , & cm -> error , & tile_data -> bit_reader ) ; init_macroblockd ( cm , & tile_data -> xd ) ; vp9_zero ( tile_data -> xd . dqcoeff ) ; worker -> had_error = 0 ; if ( i == num_workers - 1 || n == tile_cols - 1 ) { vp9_worker_execute ( worker ) ; } else { vp9_worker_launch ( worker ) ; } if ( buf -> col == tile_cols - 1 ) { final_worker = i ; } ++ n ; } for ( ; i > 0 ; -- i ) { VP9Worker * const worker = & pbi -> tile_workers [ i - 1 ] ; pbi -> mb . corrupted |= ! vp9_worker_sync ( worker ) ; } if ( final_worker > - 1 ) { TileWorkerData * const tile_data = ( TileWorkerData * ) pbi -> tile_workers [ final_worker ] . data1 ; bit_reader_end = vp9_reader_find_end ( & tile_data -> bit_reader ) ; final_worker = - 1 ; } } return bit_reader_end ; } "," pbi -> common ; const VPxWorkerInterface * const winterface = vpx_get_worker_interface ( ) ( pbi -> max_threads & ~ tile_buffers [ 1 ] [ 1 = pbi -> max_threads & ~ pbi -> tile_workers ) ) ) ; assert ( ( sizeof ( * pbi -> tile_worker_data ) % 16 ) == 0 ) ; CHECK_MEM_ERROR ( cm , pbi -> tile_worker_data , vpx_memalign ( 32 , num_threads * sizeof ( * pbi -> tile_worker_data ) ) ) ; CHECK_MEM_ERROR ( cm , pbi -> tile_worker_info , vpx_malloc ( num_threads * sizeof ( * pbi -> tile_worker_info i ) { VPxWorker * const worker -> num_tile_workers ; winterface -> init ( worker ) ; if 1 && ! winterface -> reset ( worker ) n ) { VPxWorker * const worker = & [ n ] ; winterface -> sync ( worker ) ; worker -> hook = ( hook = ( VPxWorkerHook ) tile_worker_hook ; ) tile_worker_hook ; worker -> data1 = & pbi -> tile_worker_data [ n ] ; worker -> data2 = & pbi -> tile_worker_info [ n ] ; } memset ( cm -> aligned_mi_cols ) ; memset ( cm -> aligned_mi_cols ) ; get_tile_buffers ( pbi , data , data_end , tile_cols , tile_rows , tile_buffers ) ; qsort ( tile_buffers [ 0 ] , tile_cols , sizeof ( tile_buffers [ 0 ] [ 0 ] ) , compare_tile_buffers ) ; { int group_start = 0 ; while ( group_start < tile_cols ) { const TileBuffer largest = tile_buffers [ 0 ] [ group_start ] ; const int group_end = MIN ( group_start + num_workers , tile_cols ) - 1 ; memmove ( tile_buffers [ 0 ] + group_start , tile_buffers [ 0 ] + group_start + 1 , ( group_end - group_start ) * sizeof ( tile_buffers [ 0 ] [ 0 ] ) ) ; tile_buffers [ 0 ] [ group_end ] = largest ; group_start = group_end + 1 ; } } if ( ! cm -> frame_parallel_decoding_mode ) { int i ; for ( i = 0 ; i < num_workers ; ++ i ) { TileWorkerData * const tile_data = ( TileWorkerData * ) pbi -> tile_workers [ i ] . data1 ; vp9_zero ( tile_data -> counts ) ; } } n = 0 ; while ( n < tile_cols ) { int i ; for ( i = 0 ; i < num_workers && n < tile_cols ; ++ i ) { VPxWorker * const worker = & pbi -> tile_workers [ i ] ; TileWorkerData * const tile_data = ( TileWorkerData * ) worker -> data1 ; TileInfo * const tile = ( TileInfo * ) worker -> data2 ; TileBuffer * const buf = & tile_buffers [ 0 ] [ n ] ; tile_data -> pbi = pbi ; tile_data -> xd = pbi -> mb ; tile_data -> xd . corrupted = 0 ; tile_data -> xd . counts = cm -> frame_parallel_decoding_mode ? 0 : & tile_data -> counts ; vp9_zero ( tile_data -> dqcoeff ) ; vp9_tile_init ( tile , cm , 0 , buf -> col ) ; vp9_tile_init ( & tile_data -> xd . tile , cm , 0 , buf -> col ) ; setup_token_decoder ( buf -> data , data_end , buf -> size , & cm -> error , & tile_data -> bit_reader , pbi -> decrypt_cb , pbi -> decrypt_state ) ; vp9_init_macroblockd ( cm , & tile_data -> xd , tile_data -> dqcoeff ) ; worker -> had_error = 0 ; if ( i == num_workers - 1 || n == tile_cols tile_cols - 1 ) { winterface -> execute ( worker ) } else { winterface -> launch ( worker ) i ) { VPxWorker * const worker corrupted |= ! winterface -> sync ( worker ) ; bit_reader_end = vpx_reader_find_end ( & tile_data - 1 ; } if ( n >= tile_cols && ! cm -> frame_parallel_decoding_mode ) { for ( i = 0 ; i < num_workers ; ++ i ) { TileWorkerData * const tile_data = ( TileWorkerData * ) pbi -> tile_workers [ i ] . data1 ; vp9_accumulate_frame_counts ( cm , & tile_data -> counts , 1 ) ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1629,CWE-835,"CWE-835 void CLASS parse_minolta ( int base ) { int save , tag , len , offset , high = 0 , wide = 0 , i , c ; short sorder = order ; fseek ( ifp , base , SEEK_SET ) ; if ( fgetc ( ifp ) || fgetc ( ifp ) - 'M' || fgetc ( ifp ) - 'R' ) return ; order = fgetc ( ifp ) * 0x101 ; offset = base + get4 ( ) + 8 ; while ( ( save = ftell ( ifp ) ) < offset ) { for ( tag = i = 0 ; i < 4 ; i ++ ) tag = tag << 8 | fgetc ( ifp ) ; len = get4 ( ) ; switch ( tag ) { case 0x505244 : fseek ( ifp , 8 , SEEK_CUR ) ; high = get2 ( ) ; wide = get2 ( ) ; # ifdef LIBRAW_LIBRARY_BUILD imgdata . makernotes . sony . prd_ImageHeight = get2 ( ) ; imgdata . makernotes . sony . prd_ImageWidth = get2 ( ) ; fseek ( ifp , 1L , SEEK_CUR ) ; imgdata . makernotes . sony . prd_RawBitDepth = ( ushort ) fgetc ( ifp ) ; imgdata . makernotes . sony . prd_StorageMethod = ( ushort ) fgetc ( ifp ) ; fseek ( ifp , 4L , SEEK_CUR ) ; imgdata . makernotes . sony . prd_BayerPattern = ( ushort ) fgetc ( ifp ) ; # endif break ; # ifdef LIBRAW_LIBRARY_BUILD case 0x524946 : if ( ! strncasecmp ( model , ""DSLR-A100"" , 9 ) ) { fseek ( ifp , 8 , SEEK_CUR ) ; imgdata . color . WB_Coeffs [ LIBRAW_WBI_Tungsten ] [ 0 ] = get2 ( ) ; imgdata . color . WB_Coeffs [ LIBRAW_WBI_Tungsten ] [ 2 ] = get2 ( ) ; imgdata . color . WB_Coeffs [ LIBRAW_WBI_Daylight ] [ 0 ] = get2 ( ) ; imgdata . color . WB_Coeffs [ LIBRAW_WBI_Daylight ] [ 2 ] = get2 ( ) ; imgdata . color . WB_Coeffs [ LIBRAW_WBI_Cloudy ] [ 0 ] = get2 ( ) ; imgdata . color . WB_Coeffs [ LIBRAW_WBI_Cloudy ] [ 2 ] = get2 ( ) ; imgdata . color . WB_Coeffs [ LIBRAW_WBI_FL_W ] [ 0 ] = get2 ( ) ; imgdata . color . WB_Coeffs [ LIBRAW_WBI_FL_W ] [ 2 ] = get2 ( ) ; imgdata . color . WB_Coeffs [ LIBRAW_WBI_Flash ] [ 0 ] = get2 ( ) ; imgdata . color . WB_Coeffs [ LIBRAW_WBI_Flash ] [ 2 ] = get2 ( ) ; get4 ( ) ; imgdata . color . WB_Coeffs [ LIBRAW_WBI_Shade ] [ 0 ] = get2 ( ) ; imgdata . color . WB_Coeffs [ LIBRAW_WBI_Shade ] [ 2 ] = get2 ( ) ; imgdata . color . WB_Coeffs [ LIBRAW_WBI_FL_D ] [ 0 ] = get2 ( ) ; imgdata . color . WB_Coeffs [ LIBRAW_WBI_FL_D ] [ 2 ] = get2 ( ) ; imgdata . color . WB_Coeffs [ LIBRAW_WBI_FL_N ] [ 0 ] = get2 ( ) ; imgdata . color . WB_Coeffs [ LIBRAW_WBI_FL_N ] [ 2 ] = get2 ( ) ; imgdata . color . WB_Coeffs [ LIBRAW_WBI_FL_WW ] [ 0 ] = get2 ( ) ; imgdata . color . WB_Coeffs [ LIBRAW_WBI_FL_WW ] [ 2 ] = get2 ( ) ; imgdata . color . WB_Coeffs [ LIBRAW_WBI_Daylight ] [ 1 ] = imgdata . color . WB_Coeffs [ LIBRAW_WBI_Daylight ] [ 3 ] = imgdata . color . WB_Coeffs [ LIBRAW_WBI_Tungsten ] [ 1 ] = imgdata . color . WB_Coeffs [ LIBRAW_WBI_Tungsten ] [ 3 ] = imgdata . color . WB_Coeffs [ LIBRAW_WBI_Flash ] [ 1 ] = imgdata . color . WB_Coeffs [ LIBRAW_WBI_Flash ] [ 3 ] = imgdata . color . WB_Coeffs [ LIBRAW_WBI_Cloudy ] [ 1 ] = imgdata . color . WB_Coeffs [ LIBRAW_WBI_Cloudy ] [ 3 ] = imgdata . color . WB_Coeffs [ LIBRAW_WBI_Shade ] [ 1 ] = imgdata . color . WB_Coeffs [ LIBRAW_WBI_Shade ] [ 3 ] = imgdata . color . WB_Coeffs [ LIBRAW_WBI_FL_D ] [ 1 ] = imgdata . color . WB_Coeffs [ LIBRAW_WBI_FL_D ] [ 3 ] = imgdata . color . WB_Coeffs [ LIBRAW_WBI_FL_N ] [ 1 ] = imgdata . color . WB_Coeffs [ LIBRAW_WBI_FL_N ] [ 3 ] = imgdata . color . WB_Coeffs [ LIBRAW_WBI_FL_W ] [ 1 ] = imgdata . color . WB_Coeffs [ LIBRAW_WBI_FL_W ] [ 3 ] = imgdata . color . WB_Coeffs [ LIBRAW_WBI_FL_WW ] [ 1 ] = imgdata . color . WB_Coeffs [ LIBRAW_WBI_FL_WW ] [ 3 ] = 0x100 ; } break ; # endif case 0x574247 : get4 ( ) ; i = strcmp ( model , ""DiMAGEA200"" ) ? 0 : 3 ; FORC4 cam_mul [ c ^ ( c >> 1 ) ^ i ] = get2 ( ) ; break ; case 0x545457 : parse_tiff ( ftell ( ifp ) ) ; data_offset = offset ; } fseek ( ifp , save + len + 8 , SEEK_SET ) ; } raw_height = high ; raw_width = wide ; order = sorder ; } "," + 8 ; # ifdef LIBRAW_LIBRARY_BUILD if ( offset > ifp -> size ( ) - 8 ) offset = ifp -> size ( ) - 8 ; # endif ( ) ; if ( len < 0 ) return ; ",LibRaw@LibRaw/e47384546b43d0fd536e933249047bc397a4d88b,CVE-2018-5813,https://github.com/LibRaw/LibRaw/commit/e47384546b43d0fd536e933249047bc397a4d88b,2018-12-07T22:29Z 1630,CWE-362,"CWE-362 static int fanout_add ( struct sock * sk , u16 id , u16 type_flags ) { struct packet_rollover * rollover = NULL ; struct packet_sock * po = pkt_sk ( sk ) ; struct packet_fanout * f , * match ; u8 type = type_flags & 0xff ; u8 flags = type_flags >> 8 ; int err ; switch ( type ) { case PACKET_FANOUT_ROLLOVER : if ( type_flags & PACKET_FANOUT_FLAG_ROLLOVER ) return - EINVAL ; case PACKET_FANOUT_HASH : case PACKET_FANOUT_LB : case PACKET_FANOUT_CPU : case PACKET_FANOUT_RND : case PACKET_FANOUT_QM : case PACKET_FANOUT_CBPF : case PACKET_FANOUT_EBPF : break ; default : return - EINVAL ; } mutex_lock ( & fanout_mutex ) ; err = - EINVAL ; if ( ! po -> running ) goto out ; err = - EALREADY ; if ( po -> fanout ) goto out ; if ( type == PACKET_FANOUT_ROLLOVER || ( type_flags & PACKET_FANOUT_FLAG_ROLLOVER ) ) { err = - ENOMEM ; rollover = kzalloc ( sizeof ( * rollover ) , GFP_KERNEL ) ; if ( ! rollover ) goto out ; atomic_long_set ( & rollover -> num , 0 ) ; atomic_long_set ( & rollover -> num_huge , 0 ) ; atomic_long_set ( & rollover -> num_failed , 0 ) ; po -> rollover = rollover ; } if ( type_flags & PACKET_FANOUT_FLAG_UNIQUEID ) { if ( id != 0 ) { err = - EINVAL ; goto out ; } if ( ! fanout_find_new_id ( sk , & id ) ) { err = - ENOMEM ; goto out ; } flags &= ~ ( PACKET_FANOUT_FLAG_UNIQUEID >> 8 ) ; } match = NULL ; list_for_each_entry ( f , & fanout_list , list ) { if ( f -> id == id && read_pnet ( & f -> net ) == sock_net ( sk ) ) { match = f ; break ; } } err = - EINVAL ; if ( match && match -> flags != flags ) goto out ; if ( ! match ) { err = - ENOMEM ; match = kzalloc ( sizeof ( * match ) , GFP_KERNEL ) ; if ( ! match ) goto out ; write_pnet ( & match -> net , sock_net ( sk ) ) ; match -> id = id ; match -> type = type ; match -> flags = flags ; INIT_LIST_HEAD ( & match -> list ) ; spin_lock_init ( & match -> lock ) ; refcount_set ( & match -> sk_ref , 0 ) ; fanout_init_data ( match ) ; match -> prot_hook . type = po -> prot_hook . type ; match -> prot_hook . dev = po -> prot_hook . dev ; match -> prot_hook . func = packet_rcv_fanout ; match -> prot_hook . af_packet_priv = match ; match -> prot_hook . id_match = match_fanout_group ; list_add ( & match -> list , & fanout_list ) ; } err = - EINVAL ; if ( match -> type == type && match -> prot_hook . type == po -> prot_hook . type && match -> prot_hook . dev == po -> prot_hook . dev ) { err = - ENOSPC ; if ( refcount_read ( & match -> sk_ref ) < PACKET_FANOUT_MAX ) { __dev_remove_pack ( & po -> prot_hook ) ; po -> fanout = match ; refcount_set ( & match -> sk_ref , refcount_read ( & match -> sk_ref ) + 1 ) ; __fanout_link ( sk , po ) ; err = 0 ; } } out : if ( err && rollover ) { kfree ( rollover ) ; po -> rollover = NULL ; } mutex_unlock ( & fanout_mutex ) ; return err ; } "," err = - EALREADY ; if - EINVAL ; spin_lock ( & po -> bind_lock ) ; if ( po -> running && match -> type ; } } spin_unlock ( & po -> bind_lock ) ; if ( err && ! refcount_read ( & match -> sk_ref ) ) { list_del ( & match -> list ) ; kfree ( match ) ; } ",torvalds@linux/008ba2a13f2d04c947adc536d19debb8fe66f110,CVE-2017-15649,https://github.com/torvalds/linux/commit/008ba2a13f2d04c947adc536d19debb8fe66f110,2017-10-19T22:29Z 1631,CWE-119,"CWE-119 void vp9_vaq_frame_setup ( VP9_COMP * cpi ) { VP9_COMMON * cm = & cpi -> common ; struct segmentation * seg = & cm -> seg ; const double base_q = vp9_convert_qindex_to_q ( cm -> base_qindex ) ; const int base_rdmult = vp9_compute_rd_mult ( cpi , cm -> base_qindex + cm -> y_dc_delta_q ) ; int i ; if ( cm -> frame_type == KEY_FRAME || cpi -> refresh_alt_ref_frame || ( cpi -> refresh_golden_frame && ! cpi -> rc . is_src_frame_alt_ref ) ) { vp9_enable_segmentation ( seg ) ; vp9_clearall_segfeatures ( seg ) ; seg -> abs_delta = SEGMENT_DELTADATA ; vp9_clear_system_state ( ) ; for ( i = ENERGY_MIN ; i <= ENERGY_MAX ; i ++ ) { int qindex_delta , segment_rdmult ; if ( Q_RATIO ( i ) == 1 ) { RDMULT_RATIO ( i ) = 1 ; continue ; } qindex_delta = vp9_compute_qdelta ( & cpi -> rc , base_q , base_q * Q_RATIO ( i ) ) ; vp9_set_segdata ( seg , SEGMENT_ID ( i ) , SEG_LVL_ALT_Q , qindex_delta ) ; vp9_enable_segfeature ( seg , SEGMENT_ID ( i ) , SEG_LVL_ALT_Q ) ; segment_rdmult = vp9_compute_rd_mult ( cpi , cm -> base_qindex + qindex_delta + cm -> y_dc_delta_q ) ; RDMULT_RATIO ( i ) = ( double ) segment_rdmult / base_rdmult ; } } } "," cm -> seg ; int i = SEGMENT_DELTADATA ; vpx_clear_system_state ( ) ; ( i = 0 ; i < MAX_SEGMENTS ; ++ i ) { int { int qindex_delta = vp9_compute_qdelta_by_rate ( & cpi -> rc , cm -> frame_type , cm -> base_qindex , rate_ratio [ i ] , cm -> bit_depth ) ; if ( ; if ( ( cm -> base_qindex != 0 ) && ( ( cm -> base_qindex + qindex_delta ) == 0 ) ) { qindex_delta = - cm -> base_qindex + 1 ; } if ( rate_ratio [ i ] == 1.0 ) { continue ; } continue ; } vp9_set_segdata ( seg ( seg , i , SEG_LVL_ALT_Q , ( seg , i , SEG_LVL_ALT_Q ) SEG_LVL_ALT_Q ) ; } } } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1632,CWE-000,"CWE-000 static int ax25_create ( struct net * net , struct socket * sock , int protocol , int kern ) { struct sock * sk ; ax25_cb * ax25 ; if ( ! net_eq ( net , & init_net ) ) return - EAFNOSUPPORT ; switch ( sock -> type ) { case SOCK_DGRAM : if ( protocol == 0 || protocol == PF_AX25 ) protocol = AX25_P_TEXT ; break ; case SOCK_SEQPACKET : switch ( protocol ) { case 0 : case PF_AX25 : protocol = AX25_P_TEXT ; break ; case AX25_P_SEGMENT : # ifdef CONFIG_INET case AX25_P_ARP : case AX25_P_IP : # endif # ifdef CONFIG_NETROM case AX25_P_NETROM : # endif # ifdef CONFIG_ROSE case AX25_P_ROSE : # endif return - ESOCKTNOSUPPORT ; # ifdef CONFIG_NETROM_MODULE case AX25_P_NETROM : if ( ax25_protocol_is_registered ( AX25_P_NETROM ) ) return - ESOCKTNOSUPPORT ; break ; # endif # ifdef CONFIG_ROSE_MODULE case AX25_P_ROSE : if ( ax25_protocol_is_registered ( AX25_P_ROSE ) ) return - ESOCKTNOSUPPORT ; # endif default : break ; } break ; case SOCK_RAW : break ; default : return - ESOCKTNOSUPPORT ; } sk = sk_alloc ( net , PF_AX25 , GFP_ATOMIC , & ax25_proto , kern ) ; if ( sk == NULL ) return - ENOMEM ; ax25 = ax25_sk ( sk ) -> cb = ax25_create_cb ( ) ; if ( ! ax25 ) { sk_free ( sk ) ; return - ENOMEM ; } sock_init_data ( sock , sk ) ; sk -> sk_destruct = ax25_free_sock ; sock -> ops = & ax25_proto_ops ; sk -> sk_protocol = protocol ; ax25 -> sk = sk ; return 0 ; } "," ; if ( protocol < 0 || protocol > SK_PROTOCOL_MAX ) return - EINVAL ; if ( ",torvalds@linux/79462ad02e861803b3840cc782248c7359451cd9,CVE-2015-8543,https://github.com/torvalds/linux/commit/79462ad02e861803b3840cc782248c7359451cd9,2015-12-28T11:59Z 1633,CWE-119,"CWE-119 static copyFunc pickCopyFunc ( TIFF * in , TIFF * out , uint16 bitspersample , uint16 samplesperpixel ) { uint16 shortv ; uint32 w , l , tw , tl ; int bychunk ; ( void ) TIFFGetField ( in , TIFFTAG_PLANARCONFIG , & shortv ) ; if ( shortv != config && bitspersample != 8 && samplesperpixel > 1 ) { fprintf ( stderr , ""%s:Cannothandledifferentplanarconfigurationw/bits/sample!=8\\n"" , TIFFFileName ( in ) ) ; return ( NULL ) ; } TIFFGetField ( in , TIFFTAG_IMAGEWIDTH , & w ) ; TIFFGetField ( in , TIFFTAG_IMAGELENGTH , & l ) ; if ( ! ( TIFFIsTiled ( out ) || TIFFIsTiled ( in ) ) ) { uint32 irps = ( uint32 ) - 1L ; TIFFGetField ( in , TIFFTAG_ROWSPERSTRIP , & irps ) ; bychunk = ! bias && ( rowsperstrip == irps ) ; } else { if ( bias ) { fprintf ( stderr , ""%s:Cannothandletiledconfigurationw/biasimage\\n"" , TIFFFileName ( in ) ) ; return ( NULL ) ; } if ( TIFFIsTiled ( out ) ) { if ( ! TIFFGetField ( in , TIFFTAG_TILEWIDTH , & tw ) ) tw = w ; if ( ! TIFFGetField ( in , TIFFTAG_TILELENGTH , & tl ) ) tl = l ; bychunk = ( tw == tilewidth && tl == tilelength ) ; } else { TIFFGetField ( in , TIFFTAG_TILEWIDTH , & tw ) ; TIFFGetField ( in , TIFFTAG_TILELENGTH , & tl ) ; bychunk = ( tw == w && tl == rowsperstrip ) ; } } # define T 1 # define F 0 # define pack ( a , b , c , d , e ) ( ( long ) ( ( ( a ) << 11 ) | ( ( b ) << 3 ) | ( ( c ) << 2 ) | ( ( d ) << 1 ) | ( e ) ) ) switch ( pack ( shortv , config , TIFFIsTiled ( in ) , TIFFIsTiled ( out ) , bychunk ) ) { case pack ( PLANARCONFIG_CONTIG , PLANARCONFIG_CONTIG , F , T , F ) : case pack ( PLANARCONFIG_CONTIG , PLANARCONFIG_CONTIG , F , T , T ) : return cpContigStrips2ContigTiles ; case pack ( PLANARCONFIG_CONTIG , PLANARCONFIG_SEPARATE , F , T , F ) : case pack ( PLANARCONFIG_CONTIG , PLANARCONFIG_SEPARATE , F , T , T ) : return cpContigStrips2SeparateTiles ; case pack ( PLANARCONFIG_SEPARATE , PLANARCONFIG_CONTIG , F , T , F ) : case pack ( PLANARCONFIG_SEPARATE , PLANARCONFIG_CONTIG , F , T , T ) : return cpSeparateStrips2ContigTiles ; case pack ( PLANARCONFIG_SEPARATE , PLANARCONFIG_SEPARATE , F , T , F ) : case pack ( PLANARCONFIG_SEPARATE , PLANARCONFIG_SEPARATE , F , T , T ) : return cpSeparateStrips2SeparateTiles ; case pack ( PLANARCONFIG_CONTIG , PLANARCONFIG_CONTIG , T , T , F ) : case pack ( PLANARCONFIG_CONTIG , PLANARCONFIG_CONTIG , T , T , T ) : return cpContigTiles2ContigTiles ; case pack ( PLANARCONFIG_CONTIG , PLANARCONFIG_SEPARATE , T , T , F ) : case pack ( PLANARCONFIG_CONTIG , PLANARCONFIG_SEPARATE , T , T , T ) : return cpContigTiles2SeparateTiles ; case pack ( PLANARCONFIG_SEPARATE , PLANARCONFIG_CONTIG , T , T , F ) : case pack ( PLANARCONFIG_SEPARATE , PLANARCONFIG_CONTIG , T , T , T ) : return cpSeparateTiles2ContigTiles ; case pack ( PLANARCONFIG_SEPARATE , PLANARCONFIG_SEPARATE , T , T , F ) : case pack ( PLANARCONFIG_SEPARATE , PLANARCONFIG_SEPARATE , T , T , T ) : return cpSeparateTiles2SeparateTiles ; case pack ( PLANARCONFIG_CONTIG , PLANARCONFIG_CONTIG , T , F , F ) : case pack ( PLANARCONFIG_CONTIG , PLANARCONFIG_CONTIG , T , F , T ) : return cpContigTiles2ContigStrips ; case pack ( PLANARCONFIG_CONTIG , PLANARCONFIG_SEPARATE , T , F , F ) : case pack ( PLANARCONFIG_CONTIG , PLANARCONFIG_SEPARATE , T , F , T ) : return cpContigTiles2SeparateStrips ; case pack ( PLANARCONFIG_SEPARATE , PLANARCONFIG_CONTIG , T , F , F ) : case pack ( PLANARCONFIG_SEPARATE , PLANARCONFIG_CONTIG , T , F , T ) : return cpSeparateTiles2ContigStrips ; case pack ( PLANARCONFIG_SEPARATE , PLANARCONFIG_SEPARATE , T , F , F ) : case pack ( PLANARCONFIG_SEPARATE , PLANARCONFIG_SEPARATE , T , F , T ) : return cpSeparateTiles2SeparateStrips ; case pack ( PLANARCONFIG_CONTIG , PLANARCONFIG_CONTIG , F , F , F ) : return bias ? cpBiasedContig2Contig : cpContig2ContigByRow ; case pack ( PLANARCONFIG_CONTIG , PLANARCONFIG_CONTIG , F , F , T ) : return cpDecodedStrips ; case pack ( PLANARCONFIG_CONTIG , PLANARCONFIG_SEPARATE , F , F , F ) : case pack ( PLANARCONFIG_CONTIG , PLANARCONFIG_SEPARATE , F , F , T ) : return cpContig2SeparateByRow ; case pack ( PLANARCONFIG_SEPARATE , PLANARCONFIG_CONTIG , F , F , F ) : case pack ( PLANARCONFIG_SEPARATE , PLANARCONFIG_CONTIG , F , F , T ) : return cpSeparate2ContigByRow ; case pack ( PLANARCONFIG_SEPARATE , PLANARCONFIG_SEPARATE , F , F , F ) : case pack ( PLANARCONFIG_SEPARATE , PLANARCONFIG_SEPARATE , F , F , T ) : return cpSeparate2SeparateByRow ; } # undef pack # undef F # undef T fprintf ( stderr , ""tiffcp:%s:Don\'tknowhowtocopy/convertimage.\\n"" , TIFFFileName ( in ) ) ; return ( NULL ) ; } "," ( void ) TIFFGetFieldDefaulted ( in , ",vadz@libtiff/5c080298d59efa53264d7248bbe3a04660db6ef7,CVE-2017-5225,https://github.com/vadz/libtiff/commit/5c080298d59efa53264d7248bbe3a04660db6ef7,2017-01-12T11:59Z 1634,CWE-119,"CWE-119 static vpx_codec_err_t update_error_state ( vpx_codec_alg_priv_t * ctx , const struct vpx_internal_error_info * error ) { if ( error -> error_code ) ctx -> base . err_detail = error -> has_detail ? error -> detail : NULL ; return error -> error_code ; } "," -> error_code ) set_error_detail ( ctx , error -> has_detail detail : NULL ) ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1635,CWE-125,"CWE-125 ut32 armass_assemble ( const char * str , ut64 off , int thumb ) { int i , j ; char buf [ 128 ] ; ArmOpcode aop = { . off = off } ; for ( i = j = 0 ; i < sizeof ( buf ) - 1 && str [ i ] ; i ++ , j ++ ) { if ( str [ j ] == '#' ) { i -- ; continue ; } buf [ i ] = tolower ( ( const ut8 ) str [ j ] ) ; } buf [ i ] = 0 ; arm_opcode_parse ( & aop , buf ) ; aop . off = off ; if ( thumb < 0 || thumb > 1 ) { return - 1 ; } if ( ! assemble [ thumb ] ( & aop , off , buf ) ) { return - 1 ; } return aop . o ; } "," && str [ j ] ; i ",radareorg@radare2/e5c14c167b0dcf0a53d76bd50bacbbcc0dfc1ae7,CVE-2018-20459,https://github.com/radareorg/radare2/commit/e5c14c167b0dcf0a53d76bd50bacbbcc0dfc1ae7,2018-12-25T19:29Z 1636,CWE-399,"CWE-399 static int misaligned_fpu_load ( struct pt_regs * regs , __u32 opcode , int displacement_not_indexed , int width_shift , int do_paired_load ) { int error ; int destreg ; __u64 address ; error = generate_and_check_address ( regs , opcode , displacement_not_indexed , width_shift , & address ) ; if ( error < 0 ) { return error ; } perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , address ) ; destreg = ( opcode >> 4 ) & 0x3f ; if ( user_mode ( regs ) ) { __u64 buffer ; __u32 buflo , bufhi ; if ( ! access_ok ( VERIFY_READ , ( unsigned long ) address , 1UL << width_shift ) ) { return - 1 ; } if ( __copy_user ( & buffer , ( const void * ) ( int ) address , ( 1 << width_shift ) ) > 0 ) { return - 1 ; } if ( last_task_used_math == current ) { enable_fpu ( ) ; save_fpu ( current ) ; disable_fpu ( ) ; last_task_used_math = NULL ; regs -> sr |= SR_FD ; } buflo = * ( __u32 * ) & buffer ; bufhi = * ( 1 + ( __u32 * ) & buffer ) ; switch ( width_shift ) { case 2 : current -> thread . xstate -> hardfpu . fp_regs [ destreg ] = buflo ; break ; case 3 : if ( do_paired_load ) { current -> thread . xstate -> hardfpu . fp_regs [ destreg ] = buflo ; current -> thread . xstate -> hardfpu . fp_regs [ destreg + 1 ] = bufhi ; } else { # if defined ( CONFIG_CPU_LITTLE_ENDIAN ) current -> thread . xstate -> hardfpu . fp_regs [ destreg ] = bufhi ; current -> thread . xstate -> hardfpu . fp_regs [ destreg + 1 ] = buflo ; # else current -> thread . xstate -> hardfpu . fp_regs [ destreg ] = buflo ; current -> thread . xstate -> hardfpu . fp_regs [ destreg + 1 ] = bufhi ; # endif } break ; default : printk ( ""Unexpectedwidth_shift%dinmisaligned_fpu_load,PC=%08lx\\n"" , width_shift , ( unsigned long ) regs -> pc ) ; break ; } return 0 ; } else { die ( ""MisalignedFPUloadinsidekernel"" , regs , 0 ) ; return - 1 ; } } "," , 1 , regs , address ",torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,CVE-2011-2918,https://github.com/torvalds/linux/commit/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,2012-05-24T23:55Z 1637,CWE-125,"CWE-125 static void test_bson_validate ( void ) { char filename [ 64 ] ; size_t offset ; bson_t * b ; int i ; bson_error_t error ; for ( i = 1 ; i <= 38 ; i ++ ) { bson_snprintf ( filename , sizeof filename , ""test%u.bson"" , i ) ; b = get_bson ( filename ) ; BSON_ASSERT ( bson_validate ( b , BSON_VALIDATE_NONE , & offset ) ) ; bson_destroy ( b ) ; } b = get_bson ( ""codewscope.bson"" ) ; BSON_ASSERT ( bson_validate ( b , BSON_VALIDATE_NONE , & offset ) ) ; bson_destroy ( b ) ; b = get_bson ( ""empty_key.bson"" ) ; BSON_ASSERT ( bson_validate ( b , BSON_VALIDATE_NONE | BSON_VALIDATE_UTF8 | BSON_VALIDATE_DOLLAR_KEYS | BSON_VALIDATE_DOT_KEYS , & offset ) ) ; bson_destroy ( b ) ; # define VALIDATE_TEST ( _filename , _flags , _offset , _flag , _msg ) b = get_bson ( _filename ) ; BSON_ASSERT ( ! bson_validate ( b , _flags , & offset ) ) ; ASSERT_CMPSIZE_T ( offset , == , ( size_t ) _offset ) ; BSON_ASSERT ( ! bson_validate_with_error ( b , _flags , & error ) ) ; ASSERT_ERROR_CONTAINS ( error , BSON_ERROR_INVALID , _flag , _msg ) ; bson_destroy ( b ) VALIDATE_TEST ( ""overflow2.bson"" , BSON_VALIDATE_NONE , 9 , BSON_VALIDATE_NONE , ""corruptBSON"" ) ; VALIDATE_TEST ( ""trailingnull.bson"" , BSON_VALIDATE_NONE , 14 , BSON_VALIDATE_NONE , ""corruptBSON"" ) ; VALIDATE_TEST ( ""dollarquery.bson"" , BSON_VALIDATE_DOLLAR_KEYS | BSON_VALIDATE_DOT_KEYS , 4 , BSON_VALIDATE_DOLLAR_KEYS , ""keyscannotbeginwith\\""$\\"":\\""$query\\"""" ) ; VALIDATE_TEST ( ""dotquery.bson"" , BSON_VALIDATE_DOLLAR_KEYS | BSON_VALIDATE_DOT_KEYS , 4 , BSON_VALIDATE_DOT_KEYS , ""keyscannotcontain\\"".\\"":\\""abc.def\\"""" ) ; VALIDATE_TEST ( ""overflow3.bson"" , BSON_VALIDATE_NONE , 9 , BSON_VALIDATE_NONE , ""corruptBSON"" ) ; VALIDATE_TEST ( ""overflow3.bson"" , BSON_VALIDATE_UTF8 , 9 , BSON_VALIDATE_NONE , ""corruptBSON"" ) ; VALIDATE_TEST ( ""overflow4.bson"" , BSON_VALIDATE_NONE , 9 , BSON_VALIDATE_NONE , ""corruptBSON"" ) ; VALIDATE_TEST ( ""empty_key.bson"" , BSON_VALIDATE_EMPTY_KEYS , 4 , BSON_VALIDATE_EMPTY_KEYS , ""emptykey"" ) ; VALIDATE_TEST ( ""test40.bson"" , BSON_VALIDATE_NONE , 6 , BSON_VALIDATE_NONE , ""corruptBSON"" ) ; VALIDATE_TEST ( ""test41.bson"" , BSON_VALIDATE_NONE , 6 , BSON_VALIDATE_NONE , ""corruptBSON"" ) ; VALIDATE_TEST ( ""test42.bson"" , BSON_VALIDATE_NONE , 6 , BSON_VALIDATE_NONE , ""corruptBSON"" ) ; VALIDATE_TEST ( ""test43.bson"" , BSON_VALIDATE_NONE , 6 , BSON_VALIDATE_NONE , ""corruptBSON"" ) ; VALIDATE_TEST ( ""test44.bson"" , BSON_VALIDATE_NONE , 6 , BSON_VALIDATE_NONE , ""corruptBSON"" ) ; VALIDATE_TEST ( ""test45.bson"" , BSON_VALIDATE_NONE , 6 , BSON_VALIDATE_NONE , ""corruptBSON"" ) ; VALIDATE_TEST ( ""test46.bson"" , BSON_VALIDATE_NONE , 6 , BSON_VALIDATE_NONE , ""corruptBSON"" ) ; VALIDATE_TEST ( ""test47.bson"" , BSON_VALIDATE_NONE , 6 , BSON_VALIDATE_NONE , ""corruptBSON"" ) ; VALIDATE_TEST ( ""test48.bson"" , BSON_VALIDATE_NONE , 6 , BSON_VALIDATE_NONE , ""corruptBSON"" ) ; VALIDATE_TEST ( ""test49.bson"" , BSON_VALIDATE_NONE , 6 , BSON_VALIDATE_NONE , ""corruptBSON"" ) ; VALIDATE_TEST ( ""test50.bson"" , BSON_VALIDATE_NONE , 10 , BSON_VALIDATE_NONE , ""corruptcode-with-scope"" ) ; VALIDATE_TEST ( ""test51.bson"" , BSON_VALIDATE_NONE , 10 , BSON_VALIDATE_NONE , ""corruptcode-with-scope"" ) ; VALIDATE_TEST ( ""test52.bson"" , BSON_VALIDATE_NONE , 9 , BSON_VALIDATE_NONE , ""corruptBSON"" ) ; VALIDATE_TEST ( ""test53.bson"" , BSON_VALIDATE_NONE , 6 , BSON_VALIDATE_NONE , ""corruptBSON"" ) ; VALIDATE_TEST ( ""test54.bson"" , BSON_VALIDATE_NONE , 12 , BSON_VALIDATE_NONE , ""corruptBSON"" ) ; b = BCON_NEW ( ""my_dbref"" , ""{"" , ""$ref"" , BCON_UTF8 ( ""collection"" ) , ""$id"" , BCON_INT32 ( 1 ) , ""}"" ) ; BSON_ASSERT ( bson_validate_with_error ( b , BSON_VALIDATE_NONE , & error ) ) ; BSON_ASSERT ( bson_validate_with_error ( b , BSON_VALIDATE_DOLLAR_KEYS , & error ) ) ; bson_destroy ( b ) ; b = BCON_NEW ( ""my_dbref"" , ""{"" , ""$id"" , BCON_INT32 ( 1 ) , ""}"" ) ; BSON_ASSERT ( bson_validate_with_error ( b , BSON_VALIDATE_NONE , & error ) ) ; BSON_ASSERT ( ! bson_validate_with_error ( b , BSON_VALIDATE_DOLLAR_KEYS , & error ) ) ; ASSERT_ERROR_CONTAINS ( error , BSON_ERROR_INVALID , BSON_VALIDATE_DOLLAR_KEYS , ""keyscannotbeginwith\\""$\\"":\\""$id\\"""" ) ; bson_destroy ( b ) ; b = BCON_NEW ( ""my_dbref"" , ""{"" , ""$ref"" , BCON_UTF8 ( ""collection"" ) , ""$ref"" , BCON_UTF8 ( ""collection"" ) , ""}"" ) ; BSON_ASSERT ( bson_validate_with_error ( b , BSON_VALIDATE_NONE , & error ) ) ; BSON_ASSERT ( ! bson_validate_with_error ( b , BSON_VALIDATE_DOLLAR_KEYS , & error ) ) ; ASSERT_ERROR_CONTAINS ( error , BSON_ERROR_INVALID , BSON_VALIDATE_DOLLAR_KEYS , ""keyscannotbeginwith\\""$\\"":\\""$ref\\"""" ) ; bson_destroy ( b ) ; b = BCON_NEW ( ""my_dbref"" , ""{"" , ""$ref"" , BCON_UTF8 ( ""collection"" ) , ""extra"" , BCON_INT32 ( 2 ) , ""$id"" , BCON_INT32 ( 1 ) , ""}"" ) ; BSON_ASSERT ( bson_validate_with_error ( b , BSON_VALIDATE_NONE , & error ) ) ; BSON_ASSERT ( ! bson_validate_with_error ( b , BSON_VALIDATE_DOLLAR_KEYS , & error ) ) ; ASSERT_ERROR_CONTAINS ( error , BSON_ERROR_INVALID , BSON_VALIDATE_DOLLAR_KEYS , ""invalidkeywithinDBRefsubdocument:\\""extra\\"""" ) ; bson_destroy ( b ) ; # undef VALIDATE_TEST } "," ""corruptBSON"" ) ; VALIDATE_TEST ( ""test59.bson"" , BSON_VALIDATE_NONE , 9 , BSON_VALIDATE_NONE , ""corruptBSON"" ) ; ",mongodb@mongo-c-driver/0d9a4d98bfdf4acd2c0138d4aaeb4e2e0934bd84,CVE-2018-16790,https://github.com/mongodb/mongo-c-driver/commit/0d9a4d98bfdf4acd2c0138d4aaeb4e2e0934bd84,2018-09-10T05:29Z 1638,CWE-20,"CWE-20 __init int intel_pmu_init ( void ) { union cpuid10_edx edx ; union cpuid10_eax eax ; union cpuid10_ebx ebx ; struct event_constraint * c ; unsigned int unused ; int version ; if ( ! cpu_has ( & boot_cpu_data , X86_FEATURE_ARCH_PERFMON ) ) { switch ( boot_cpu_data . x86 ) { case 0x6 : return p6_pmu_init ( ) ; case 0xb : return knc_pmu_init ( ) ; case 0xf : return p4_pmu_init ( ) ; } return - ENODEV ; } cpuid ( 10 , & eax . full , & ebx . full , & unused , & edx . full ) ; if ( eax . split . mask_length < ARCH_PERFMON_EVENTS_COUNT ) return - ENODEV ; version = eax . split . version_id ; if ( version < 2 ) x86_pmu = core_pmu ; else x86_pmu = intel_pmu ; x86_pmu . version = version ; x86_pmu . num_counters = eax . split . num_counters ; x86_pmu . cntval_bits = eax . split . bit_width ; x86_pmu . cntval_mask = ( 1ULL << eax . split . bit_width ) - 1 ; x86_pmu . events_maskl = ebx . full ; x86_pmu . events_mask_len = eax . split . mask_length ; x86_pmu . max_pebs_events = min_t ( unsigned , MAX_PEBS_EVENTS , x86_pmu . num_counters ) ; if ( version > 1 ) x86_pmu . num_counters_fixed = max ( ( int ) edx . split . num_counters_fixed , 3 ) ; if ( version > 1 ) { u64 capabilities ; rdmsrl ( MSR_IA32_PERF_CAPABILITIES , capabilities ) ; x86_pmu . intel_cap . capabilities = capabilities ; } intel_ds_init ( ) ; x86_add_quirk ( intel_arch_events_quirk ) ; switch ( boot_cpu_data . x86_model ) { case 14 : pr_cont ( ""Coreevents,"" ) ; break ; case 15 : x86_add_quirk ( intel_clovertown_quirk ) ; case 22 : case 23 : case 29 : memcpy ( hw_cache_event_ids , core2_hw_cache_event_ids , sizeof ( hw_cache_event_ids ) ) ; intel_pmu_lbr_init_core ( ) ; x86_pmu . event_constraints = intel_core2_event_constraints ; x86_pmu . pebs_constraints = intel_core2_pebs_event_constraints ; pr_cont ( ""Core2events,"" ) ; break ; case 26 : case 30 : case 46 : memcpy ( hw_cache_event_ids , nehalem_hw_cache_event_ids , sizeof ( hw_cache_event_ids ) ) ; memcpy ( hw_cache_extra_regs , nehalem_hw_cache_extra_regs , sizeof ( hw_cache_extra_regs ) ) ; intel_pmu_lbr_init_nhm ( ) ; x86_pmu . event_constraints = intel_nehalem_event_constraints ; x86_pmu . pebs_constraints = intel_nehalem_pebs_event_constraints ; x86_pmu . enable_all = intel_pmu_nhm_enable_all ; x86_pmu . extra_regs = intel_nehalem_extra_regs ; intel_perfmon_event_map [ PERF_COUNT_HW_STALLED_CYCLES_FRONTEND ] = X86_CONFIG ( . event = 0x0e , . umask = 0x01 , . inv = 1 , . cmask = 1 ) ; intel_perfmon_event_map [ PERF_COUNT_HW_STALLED_CYCLES_BACKEND ] = X86_CONFIG ( . event = 0xb1 , . umask = 0x3f , . inv = 1 , . cmask = 1 ) ; x86_add_quirk ( intel_nehalem_quirk ) ; pr_cont ( ""Nehalemevents,"" ) ; break ; case 28 : case 38 : case 39 : case 53 : case 54 : memcpy ( hw_cache_event_ids , atom_hw_cache_event_ids , sizeof ( hw_cache_event_ids ) ) ; intel_pmu_lbr_init_atom ( ) ; x86_pmu . event_constraints = intel_gen_event_constraints ; x86_pmu . pebs_constraints = intel_atom_pebs_event_constraints ; pr_cont ( ""Atomevents,"" ) ; break ; case 37 : case 44 : case 47 : memcpy ( hw_cache_event_ids , westmere_hw_cache_event_ids , sizeof ( hw_cache_event_ids ) ) ; memcpy ( hw_cache_extra_regs , nehalem_hw_cache_extra_regs , sizeof ( hw_cache_extra_regs ) ) ; intel_pmu_lbr_init_nhm ( ) ; x86_pmu . event_constraints = intel_westmere_event_constraints ; x86_pmu . enable_all = intel_pmu_nhm_enable_all ; x86_pmu . pebs_constraints = intel_westmere_pebs_event_constraints ; x86_pmu . extra_regs = intel_westmere_extra_regs ; x86_pmu . er_flags |= ERF_HAS_RSP_1 ; intel_perfmon_event_map [ PERF_COUNT_HW_STALLED_CYCLES_FRONTEND ] = X86_CONFIG ( . event = 0x0e , . umask = 0x01 , . inv = 1 , . cmask = 1 ) ; intel_perfmon_event_map [ PERF_COUNT_HW_STALLED_CYCLES_BACKEND ] = X86_CONFIG ( . event = 0xb1 , . umask = 0x3f , . inv = 1 , . cmask = 1 ) ; pr_cont ( ""Westmereevents,"" ) ; break ; case 42 : case 45 : x86_add_quirk ( intel_sandybridge_quirk ) ; memcpy ( hw_cache_event_ids , snb_hw_cache_event_ids , sizeof ( hw_cache_event_ids ) ) ; memcpy ( hw_cache_extra_regs , snb_hw_cache_extra_regs , sizeof ( hw_cache_extra_regs ) ) ; intel_pmu_lbr_init_snb ( ) ; x86_pmu . event_constraints = intel_snb_event_constraints ; x86_pmu . pebs_constraints = intel_snb_pebs_event_constraints ; x86_pmu . pebs_aliases = intel_pebs_aliases_snb ; x86_pmu . extra_regs = intel_snb_extra_regs ; x86_pmu . er_flags |= ERF_HAS_RSP_1 ; x86_pmu . er_flags |= ERF_NO_HT_SHARING ; intel_perfmon_event_map [ PERF_COUNT_HW_STALLED_CYCLES_FRONTEND ] = X86_CONFIG ( . event = 0x0e , . umask = 0x01 , . inv = 1 , . cmask = 1 ) ; intel_perfmon_event_map [ PERF_COUNT_HW_STALLED_CYCLES_BACKEND ] = X86_CONFIG ( . event = 0xb1 , . umask = 0x01 , . inv = 1 , . cmask = 1 ) ; pr_cont ( ""SandyBridgeevents,"" ) ; break ; case 58 : case 62 : memcpy ( hw_cache_event_ids , snb_hw_cache_event_ids , sizeof ( hw_cache_event_ids ) ) ; memcpy ( hw_cache_extra_regs , snb_hw_cache_extra_regs , sizeof ( hw_cache_extra_regs ) ) ; intel_pmu_lbr_init_snb ( ) ; x86_pmu . event_constraints = intel_ivb_event_constraints ; x86_pmu . pebs_constraints = intel_ivb_pebs_event_constraints ; x86_pmu . pebs_aliases = intel_pebs_aliases_snb ; x86_pmu . extra_regs = intel_snb_extra_regs ; x86_pmu . er_flags |= ERF_HAS_RSP_1 ; x86_pmu . er_flags |= ERF_NO_HT_SHARING ; intel_perfmon_event_map [ PERF_COUNT_HW_STALLED_CYCLES_FRONTEND ] = X86_CONFIG ( . event = 0x0e , . umask = 0x01 , . inv = 1 , . cmask = 1 ) ; pr_cont ( ""IvyBridgeevents,"" ) ; break ; default : switch ( x86_pmu . version ) { case 1 : x86_pmu . event_constraints = intel_v1_event_constraints ; pr_cont ( ""genericarchitectedperfmonv1,"" ) ; break ; default : x86_pmu . event_constraints = intel_gen_event_constraints ; pr_cont ( ""genericarchitectedperfmon,"" ) ; break ; } } if ( x86_pmu . num_counters > INTEL_PMC_MAX_GENERIC ) { WARN ( 1 , KERN_ERR ""hwperfevents%d>max(%d),clipping!"" , x86_pmu . num_counters , INTEL_PMC_MAX_GENERIC ) ; x86_pmu . num_counters = INTEL_PMC_MAX_GENERIC ; } x86_pmu . intel_ctrl = ( 1 << x86_pmu . num_counters ) - 1 ; if ( x86_pmu . num_counters_fixed > INTEL_PMC_MAX_FIXED ) { WARN ( 1 , KERN_ERR ""hwperfeventsfixed%d>max(%d),clipping!"" , x86_pmu . num_counters_fixed , INTEL_PMC_MAX_FIXED ) ; x86_pmu . num_counters_fixed = INTEL_PMC_MAX_FIXED ; } x86_pmu . intel_ctrl |= ( ( 1LL << x86_pmu . num_counters_fixed ) - 1 ) << INTEL_PMC_IDX_FIXED ; if ( x86_pmu . event_constraints ) { for_each_event_constraint ( c , x86_pmu . event_constraints ) { if ( c -> cmask != X86_RAW_EVENT_MASK || c -> idxmsk64 == INTEL_PMC_MSK_FIXED_REF_CYCLES ) { continue ; } c -> idxmsk64 |= ( 1ULL << x86_pmu . num_counters ) - 1 ; c -> weight += x86_pmu . num_counters ; } } return 0 ; } "," = intel_pebs_aliases_snb ; if ( boot_cpu_data . x86_model == 45 ) x86_pmu . extra_regs = intel_snbep_extra_regs ; else = intel_pebs_aliases_snb ; if ( boot_cpu_data . x86_model == 62 ) x86_pmu . extra_regs = intel_snbep_extra_regs ; else ",torvalds@linux/f1923820c447e986a9da0fc6bf60c1dccdf0408e,CVE-2013-2146,https://github.com/torvalds/linux/commit/f1923820c447e986a9da0fc6bf60c1dccdf0408e,2013-06-07T14:03Z 1639,CWE-20,"CWE-20 void ih264d_init_decoder ( void * ps_dec_params ) { dec_struct_t * ps_dec = ( dec_struct_t * ) ps_dec_params ; dec_slice_params_t * ps_cur_slice ; pocstruct_t * ps_prev_poc , * ps_cur_poc ; ih264d_free_dynamic_bufs ( ps_dec ) ; ps_cur_slice = ps_dec -> ps_cur_slice ; ps_dec -> init_done = 0 ; ps_dec -> u4_num_cores = 1 ; ps_dec -> u2_pic_ht = ps_dec -> u2_pic_wd = 0 ; ps_dec -> u1_separate_parse = DEFAULT_SEPARATE_PARSE ; ps_dec -> u4_app_disable_deblk_frm = 0 ; ps_dec -> i4_degrade_type = 0 ; ps_dec -> i4_degrade_pics = 0 ; ps_dec -> i4_app_skip_mode = IVD_SKIP_NONE ; ps_dec -> i4_dec_skip_mode = IVD_SKIP_NONE ; memset ( ps_dec -> ps_pps , 0 , ( ( sizeof ( dec_pic_params_t ) ) * MAX_NUM_PIC_PARAMS ) ) ; memset ( ps_dec -> ps_sps , 0 , ( ( sizeof ( dec_seq_params_t ) ) * MAX_NUM_SEQ_PARAMS ) ) ; ps_dec -> p_DeblockPicture [ 0 ] = ih264d_deblock_picture_non_mbaff ; ps_dec -> p_DeblockPicture [ 1 ] = ih264d_deblock_picture_mbaff ; ps_dec -> s_cab_dec_env . pv_codec_handle = ps_dec ; ps_dec -> u4_num_fld_in_frm = 0 ; ps_dec -> ps_dpb_mgr -> pv_codec_handle = ps_dec ; ps_dec -> ps_sei -> u1_is_valid = 0 ; ps_dec -> ps_cur_pps = NULL ; ps_dec -> ps_cur_sps = NULL ; ps_dec -> u1_init_dec_flag = 0 ; ps_dec -> u1_first_slice_in_stream = 1 ; ps_dec -> u1_first_pb_nal_in_pic = 1 ; ps_dec -> u1_last_pic_not_decoded = 0 ; ps_dec -> u4_app_disp_width = 0 ; ps_dec -> i4_header_decoded = 0 ; ps_dec -> u4_total_frames_decoded = 0 ; ps_dec -> i4_error_code = 0 ; ps_dec -> i4_content_type = - 1 ; ps_dec -> ps_cur_slice -> u1_mbaff_frame_flag = 0 ; ps_dec -> ps_dec_err_status -> u1_err_flag = ACCEPT_ALL_PICS ; ps_dec -> ps_dec_err_status -> u1_cur_pic_type = PIC_TYPE_UNKNOWN ; ps_dec -> ps_dec_err_status -> u4_frm_sei_sync = SYNC_FRM_DEFAULT ; ps_dec -> ps_dec_err_status -> u4_cur_frm = INIT_FRAME ; ps_dec -> ps_dec_err_status -> u1_pic_aud_i = PIC_TYPE_UNKNOWN ; ps_dec -> u1_pr_sl_type = 0xFF ; ps_dec -> u2_mbx = 0xffff ; ps_dec -> u2_mby = 0 ; ps_dec -> u2_total_mbs_coded = 0 ; ps_prev_poc = & ps_dec -> s_prev_pic_poc ; ps_cur_poc = & ps_dec -> s_cur_pic_poc ; ps_prev_poc -> i4_pic_order_cnt_lsb = ps_cur_poc -> i4_pic_order_cnt_lsb = 0 ; ps_prev_poc -> i4_pic_order_cnt_msb = ps_cur_poc -> i4_pic_order_cnt_msb = 0 ; ps_prev_poc -> i4_delta_pic_order_cnt_bottom = ps_cur_poc -> i4_delta_pic_order_cnt_bottom = 0 ; ps_prev_poc -> i4_delta_pic_order_cnt [ 0 ] = ps_cur_poc -> i4_delta_pic_order_cnt [ 0 ] = 0 ; ps_prev_poc -> i4_delta_pic_order_cnt [ 1 ] = ps_cur_poc -> i4_delta_pic_order_cnt [ 1 ] = 0 ; ps_prev_poc -> u1_mmco_equalto5 = ps_cur_poc -> u1_mmco_equalto5 = 0 ; ps_prev_poc -> i4_top_field_order_count = ps_cur_poc -> i4_top_field_order_count = 0 ; ps_prev_poc -> i4_bottom_field_order_count = ps_cur_poc -> i4_bottom_field_order_count = 0 ; ps_prev_poc -> u1_bot_field = ps_cur_poc -> u1_bot_field = 0 ; ps_prev_poc -> u1_mmco_equalto5 = ps_cur_poc -> u1_mmco_equalto5 = 0 ; ps_prev_poc -> i4_prev_frame_num_ofst = ps_cur_poc -> i4_prev_frame_num_ofst = 0 ; ps_cur_slice -> u1_mmco_equalto5 = 0 ; ps_cur_slice -> u2_frame_num = 0 ; ps_dec -> i4_max_poc = 0 ; ps_dec -> i4_prev_max_display_seq = 0 ; ps_dec -> u1_recon_mb_grp = 4 ; ps_dec -> u1_second_field = 0 ; ps_dec -> s_prev_seq_params . u1_eoseq_pending = 0 ; ps_dec -> u2_crop_offset_y = 0 ; ps_dec -> u2_crop_offset_uv = 0 ; ps_dec -> i4_vui_frame_rate = - 1 ; ps_dec -> i4_pic_type = - 1 ; ps_dec -> i4_frametype = - 1 ; ps_dec -> i4_content_type = - 1 ; ps_dec -> u1_res_changed = 0 ; ps_dec -> u1_frame_decoded_flag = 0 ; ps_dec -> u4_skip_frm_mask = SKIP_NONE ; ps_dec -> pf_cavlc_4x4res_block [ 0 ] = ih264d_cavlc_4x4res_block_totalcoeff_1 ; ps_dec -> pf_cavlc_4x4res_block [ 1 ] = ih264d_cavlc_4x4res_block_totalcoeff_2to10 ; ps_dec -> pf_cavlc_4x4res_block [ 2 ] = ih264d_cavlc_4x4res_block_totalcoeff_11to16 ; ps_dec -> pf_cavlc_parse4x4coeff [ 0 ] = ih264d_cavlc_parse4x4coeff_n0to7 ; ps_dec -> pf_cavlc_parse4x4coeff [ 1 ] = ih264d_cavlc_parse4x4coeff_n8 ; ps_dec -> pf_cavlc_parse_8x8block [ 0 ] = ih264d_cavlc_parse_8x8block_none_available ; ps_dec -> pf_cavlc_parse_8x8block [ 1 ] = ih264d_cavlc_parse_8x8block_left_available ; ps_dec -> pf_cavlc_parse_8x8block [ 2 ] = ih264d_cavlc_parse_8x8block_top_available ; ps_dec -> pf_cavlc_parse_8x8block [ 3 ] = ih264d_cavlc_parse_8x8block_both_available ; ps_dec -> pf_fill_bs1 [ 0 ] [ 0 ] = ih264d_fill_bs1_16x16mb_pslice ; ps_dec -> pf_fill_bs1 [ 0 ] [ 1 ] = ih264d_fill_bs1_non16x16mb_pslice ; ps_dec -> pf_fill_bs1 [ 1 ] [ 0 ] = ih264d_fill_bs1_16x16mb_bslice ; ps_dec -> pf_fill_bs1 [ 1 ] [ 1 ] = ih264d_fill_bs1_non16x16mb_bslice ; ps_dec -> pf_fill_bs_xtra_left_edge [ 0 ] = ih264d_fill_bs_xtra_left_edge_cur_frm ; ps_dec -> pf_fill_bs_xtra_left_edge [ 1 ] = ih264d_fill_bs_xtra_left_edge_cur_fld ; ih264d_init_ref_bufs ( ps_dec -> ps_dpb_mgr ) ; ps_dec -> u2_prv_frame_num = 0 ; ps_dec -> u1_top_bottom_decoded = 0 ; ps_dec -> u1_dangling_field = 0 ; ps_dec -> s_cab_dec_env . cabac_table = gau4_ih264d_cabac_table ; ps_dec -> pu1_left_mv_ctxt_inc = ps_dec -> u1_left_mv_ctxt_inc_arr [ 0 ] ; ps_dec -> pi1_left_ref_idx_ctxt_inc = & ps_dec -> i1_left_ref_idx_ctx_inc_arr [ 0 ] [ 0 ] ; ps_dec -> pu1_left_yuv_dc_csbp = & ps_dec -> u1_yuv_dc_csbp_topmb ; ps_dec -> u1_flushfrm = 0 ; { ps_dec -> s_cab_dec_env . pv_codec_handle = ( void * ) ps_dec ; ps_dec -> ps_bitstrm -> pv_codec_handle = ( void * ) ps_dec ; ps_dec -> ps_cur_slice -> pv_codec_handle = ( void * ) ps_dec ; ps_dec -> ps_dpb_mgr -> pv_codec_handle = ( void * ) ps_dec ; } memset ( ps_dec -> disp_bufs , 0 , ( MAX_DISP_BUFS_NEW ) * sizeof ( disp_buf_t ) ) ; memset ( ps_dec -> u4_disp_buf_mapping , 0 , ( MAX_DISP_BUFS_NEW ) * sizeof ( UWORD32 ) ) ; memset ( ps_dec -> u4_disp_buf_to_be_freed , 0 , ( MAX_DISP_BUFS_NEW ) * sizeof ( UWORD32 ) ) ; ih264d_init_arch ( ps_dec ) ; ih264d_init_function_ptr ( ps_dec ) ; ps_dec -> e_frm_out_mode = IVD_DISPLAY_FRAME_OUT ; ps_dec -> init_done = 1 ; } "," , * ps_cur_poc ; WORD32 size ; size = sizeof ( pred_info_t ) * 2 * 32 ; memset ( ps_dec -> ps_pred , 0 , size ) ; size = sizeof ( disp_mgr_t ) ; memset ( ps_dec -> pv_disp_buf_mgr , 0 , size ) ; size = sizeof ( buf_mgr_t ) + ithread_get_mutex_lock_size ( ) ; memset ( ps_dec -> pv_pic_buf_mgr , 0 , size ) ; size = sizeof ( dec_err_status_t ) ; memset ( ps_dec -> ps_dec_err_status , 0 , size ) ; size = sizeof ( sei ) ; memset ( ps_dec -> ps_sei , 0 , size ) ; size = sizeof ( dpb_commands_t ) ; memset ( ps_dec -> ps_dpb_cmds , 0 , size ) ; size = sizeof ( dec_bit_stream_t ) ; memset ( ps_dec -> ps_bitstrm , 0 , size ) ; size = sizeof ( dec_slice_params_t ) ; memset ( ps_dec -> ps_cur_slice , 0 , size ) ; size = MAX ( sizeof ( dec_seq_params_t ) , sizeof ( dec_pic_params_t ) ) ; memset ( ps_dec -> pv_scratch_sps_pps , 0 , size ) ; size = sizeof ( ctxt_inc_mb_info_t ) ; memset ( ps_dec -> ps_left_mb_ctxt_info , 0 , size ) ; size = ( sizeof ( neighbouradd_t ) << 2 ) ; memset ( ps_dec -> ps_left_mvpred_addr , 0 , size ) ; size = sizeof ( buf_mgr_t ) + ithread_get_mutex_lock_size ( ) ; memset ( ps_dec -> pv_mv_buf_mgr , 0 , size ) ",external@libavc/ecf6c7ce6d5a22d52160698aab44fc234c63291a,CVE-2016-3743,https://android.googlesource.com/platform/external/libavc/+/ecf6c7ce6d5a22d52160698aab44fc234c63291a,2016-07-11T01:59Z 1640,CWE-000,"CWE-000 static int userfaultfd_register ( struct userfaultfd_ctx * ctx , unsigned long arg ) { struct mm_struct * mm = ctx -> mm ; struct vm_area_struct * vma , * prev , * cur ; int ret ; struct uffdio_register uffdio_register ; struct uffdio_register __user * user_uffdio_register ; unsigned long vm_flags , new_flags ; bool found ; bool basic_ioctls ; unsigned long start , end , vma_end ; user_uffdio_register = ( struct uffdio_register __user * ) arg ; ret = - EFAULT ; if ( copy_from_user ( & uffdio_register , user_uffdio_register , sizeof ( uffdio_register ) - sizeof ( __u64 ) ) ) goto out ; ret = - EINVAL ; if ( ! uffdio_register . mode ) goto out ; if ( uffdio_register . mode & ~ ( UFFDIO_REGISTER_MODE_MISSING | UFFDIO_REGISTER_MODE_WP ) ) goto out ; vm_flags = 0 ; if ( uffdio_register . mode & UFFDIO_REGISTER_MODE_MISSING ) vm_flags |= VM_UFFD_MISSING ; if ( uffdio_register . mode & UFFDIO_REGISTER_MODE_WP ) { vm_flags |= VM_UFFD_WP ; ret = - EINVAL ; goto out ; } ret = validate_range ( mm , uffdio_register . range . start , uffdio_register . range . len ) ; if ( ret ) goto out ; start = uffdio_register . range . start ; end = start + uffdio_register . range . len ; ret = - ENOMEM ; if ( ! mmget_not_zero ( mm ) ) goto out ; down_write ( & mm -> mmap_sem ) ; vma = find_vma_prev ( mm , start , & prev ) ; if ( ! vma ) goto out_unlock ; ret = - EINVAL ; if ( vma -> vm_start >= end ) goto out_unlock ; if ( is_vm_hugetlb_page ( vma ) ) { unsigned long vma_hpagesize = vma_kernel_pagesize ( vma ) ; if ( start & ( vma_hpagesize - 1 ) ) goto out_unlock ; } found = false ; basic_ioctls = false ; for ( cur = vma ; cur && cur -> vm_start < end ; cur = cur -> vm_next ) { cond_resched ( ) ; BUG_ON ( ! ! cur -> vm_userfaultfd_ctx . ctx ^ ! ! ( cur -> vm_flags & ( VM_UFFD_MISSING | VM_UFFD_WP ) ) ) ; ret = - EINVAL ; if ( ! vma_can_userfault ( cur ) ) goto out_unlock ; if ( is_vm_hugetlb_page ( cur ) && end <= cur -> vm_end && end > cur -> vm_start ) { unsigned long vma_hpagesize = vma_kernel_pagesize ( cur ) ; ret = - EINVAL ; if ( end & ( vma_hpagesize - 1 ) ) goto out_unlock ; } ret = - EBUSY ; if ( cur -> vm_userfaultfd_ctx . ctx && cur -> vm_userfaultfd_ctx . ctx != ctx ) goto out_unlock ; if ( is_vm_hugetlb_page ( cur ) ) basic_ioctls = true ; found = true ; } BUG_ON ( ! found ) ; if ( vma -> vm_start < start ) prev = vma ; ret = 0 ; do { cond_resched ( ) ; BUG_ON ( ! vma_can_userfault ( vma ) ) ; BUG_ON ( vma -> vm_userfaultfd_ctx . ctx && vma -> vm_userfaultfd_ctx . ctx != ctx ) ; if ( vma -> vm_userfaultfd_ctx . ctx == ctx && ( vma -> vm_flags & vm_flags ) == vm_flags ) goto skip ; if ( vma -> vm_start > start ) start = vma -> vm_start ; vma_end = min ( end , vma -> vm_end ) ; new_flags = ( vma -> vm_flags & ~ vm_flags ) | vm_flags ; prev = vma_merge ( mm , prev , start , vma_end , new_flags , vma -> anon_vma , vma -> vm_file , vma -> vm_pgoff , vma_policy ( vma ) , ( ( struct vm_userfaultfd_ctx ) { ctx } ) ) ; if ( prev ) { vma = prev ; goto next ; } if ( vma -> vm_start < start ) { ret = split_vma ( mm , vma , start , 1 ) ; if ( ret ) break ; } if ( vma -> vm_end > end ) { ret = split_vma ( mm , vma , end , 0 ) ; if ( ret ) break ; } next : vma -> vm_flags = new_flags ; vma -> vm_userfaultfd_ctx . ctx = ctx ; skip : prev = vma ; start = vma -> vm_end ; vma = vma -> vm_next ; } while ( vma && vma -> vm_start < end ) ; out_unlock : up_write ( & mm -> mmap_sem ) ; mmput ( mm ) ; if ( ! ret ) { if ( put_user ( basic_ioctls ? UFFD_API_RANGE_IOCTLS_BASIC : UFFD_API_RANGE_IOCTLS , & user_uffdio_register -> ioctls ) ) ret = - EFAULT ; } out : return ret ; } "," goto out_unlock ; ret = - EPERM ; if ( unlikely ( ! ( cur -> vm_flags & VM_MAYWRITE ) ) ) goto out_unlock ; ctx != ctx ) ; WARN_ON ( ! ( vma -> vm_flags & VM_MAYWRITE ) ",torvalds@linux/29ec90660d68bbdd69507c1c8b4e33aa299278b1,CVE-2018-18397,https://github.com/torvalds/linux/commit/29ec90660d68bbdd69507c1c8b4e33aa299278b1,2018-12-12T10:29Z 1641,CWE-000,"CWE-000 static struct berval * * krb5_encode_krbsecretkey ( krb5_key_data * key_data_in , int n_key_data , krb5_kvno mkvno ) { struct berval * * ret = NULL ; int currkvno ; int num_versions = 1 ; int i , j , last ; krb5_error_code err = 0 ; krb5_key_data * key_data ; if ( n_key_data <= 0 ) return NULL ; key_data = k5calloc ( n_key_data , sizeof ( * key_data ) , & err ) ; if ( key_data_in == NULL ) goto cleanup ; memcpy ( key_data , key_data_in , n_key_data * sizeof ( * key_data ) ) ; for ( i = 0 ; i < n_key_data ; i ++ ) { if ( key_data [ i ] . key_data_ver == 1 ) { key_data [ i ] . key_data_ver = 2 ; key_data [ i ] . key_data_type [ 1 ] = KRB5_KDB_SALTTYPE_NORMAL ; key_data [ i ] . key_data_length [ 1 ] = 0 ; key_data [ i ] . key_data_contents [ 1 ] = NULL ; } } for ( i = 0 ; i < n_key_data - 1 ; i ++ ) if ( key_data [ i ] . key_data_kvno != key_data [ i + 1 ] . key_data_kvno ) num_versions ++ ; ret = ( struct berval * * ) calloc ( num_versions + 1 , sizeof ( struct berval * ) ) ; if ( ret == NULL ) { err = ENOMEM ; goto cleanup ; } for ( i = 0 , last = 0 , j = 0 , currkvno = key_data [ 0 ] . key_data_kvno ; i < n_key_data ; i ++ ) { krb5_data * code ; if ( i == n_key_data - 1 || key_data [ i + 1 ] . key_data_kvno != currkvno ) { ret [ j ] = k5alloc ( sizeof ( struct berval ) , & err ) ; if ( ret [ j ] == NULL ) goto cleanup ; err = asn1_encode_sequence_of_keys ( key_data + last , ( krb5_int16 ) i - last + 1 , mkvno , & code ) ; if ( err ) goto cleanup ; ret [ j ] -> bv_len = code -> length ; ret [ j ] -> bv_val = code -> data ; free ( code ) ; j ++ ; last = i + 1 ; if ( i < n_key_data - 1 ) currkvno = key_data [ i + 1 ] . key_data_kvno ; } } ret [ num_versions ] = NULL ; cleanup : free ( key_data ) ; if ( err != 0 ) { if ( ret != NULL ) { for ( i = 0 ; i <= num_versions ; i ++ ) if ( ret [ i ] != NULL ) free ( ret [ i ] ) ; free ( ret ) ; ret = NULL ; } } return ret ; } "," krb5_key_data * key_data = NULL ; if ( n_key_data < 0 ) return ; if ( key_data == NULL ) = 0 ; ret [ i ] != NULL ; i ++ i ++ ) free ( ret ",krb5@krb5/04038bf3633c4b909b5ded3072dc88c8c419bf16,CVE-2014-5354,https://github.com/krb5/krb5/commit/04038bf3633c4b909b5ded3072dc88c8c419bf16,2014-12-16T23:59Z 1642,CWE-284,"CWE-284 static void btu_exec_tap_fd_read ( void * p_param ) { struct pollfd ufd ; int fd = ( int ) p_param ; if ( fd == INVALID_FD || fd != btpan_cb . tap_fd ) return ; for ( int i = 0 ; i < PAN_POOL_MAX && btif_is_enabled ( ) && btpan_cb . flow ; i ++ ) { BT_HDR * buffer = ( BT_HDR * ) GKI_getpoolbuf ( PAN_POOL_ID ) ; if ( ! buffer ) { BTIF_TRACE_WARNING ( ""%sunabletoallocatebufferforpacket."" , __func__ ) ; break ; } buffer -> offset = PAN_MINIMUM_OFFSET ; buffer -> len = GKI_get_buf_size ( buffer ) - sizeof ( BT_HDR ) - buffer -> offset ; UINT8 * packet = ( UINT8 * ) buffer + sizeof ( BT_HDR ) + buffer -> offset ; if ( ! btpan_cb . congest_packet_size ) { ssize_t ret = read ( fd , btpan_cb . congest_packet , sizeof ( btpan_cb . congest_packet ) ) ; switch ( ret ) { case - 1 : BTIF_TRACE_ERROR ( ""%sunabletoreadfromdriver:%s"" , __func__ , strerror ( errno ) ) ; GKI_freebuf ( buffer ) ; btsock_thread_add_fd ( pan_pth , fd , 0 , SOCK_THREAD_FD_RD , 0 ) ; return ; case 0 : BTIF_TRACE_WARNING ( ""%sendoffilereached."" , __func__ ) ; GKI_freebuf ( buffer ) ; btsock_thread_add_fd ( pan_pth , fd , 0 , SOCK_THREAD_FD_RD , 0 ) ; return ; default : btpan_cb . congest_packet_size = ret ; break ; } } memcpy ( packet , btpan_cb . congest_packet , MIN ( btpan_cb . congest_packet_size , buffer -> len ) ) ; buffer -> len = MIN ( btpan_cb . congest_packet_size , buffer -> len ) ; if ( buffer -> len > sizeof ( tETH_HDR ) && should_forward ( ( tETH_HDR * ) packet ) ) { tETH_HDR hdr ; memcpy ( & hdr , packet , sizeof ( tETH_HDR ) ) ; buffer -> len -= sizeof ( tETH_HDR ) ; buffer -> offset += sizeof ( tETH_HDR ) ; if ( forward_bnep ( & hdr , buffer ) != FORWARD_CONGEST ) btpan_cb . congest_packet_size = 0 ; } else { BTIF_TRACE_WARNING ( ""%sdroppingpacketoflength%d"" , __func__ , buffer -> len ) ; btpan_cb . congest_packet_size = 0 ; GKI_freebuf ( buffer ) ; } ufd . fd = fd ; ufd . events = POLLIN ; ufd . revents = 0 ; if ( poll ( & ufd , 1 , 0 ) <= 0 || IS_EXCEPTION ( ufd . revents ) ) break ; } btsock_thread_add_fd ( pan_pth , fd , 0 , SOCK_THREAD_FD_RD , 0 ) ; } "," ssize_t ret = TEMP_FAILURE_RETRY ( btpan_cb . congest_packet ) ; if ( TEMP_FAILURE_RETRY ( 1 , 0 ) ",system@bt/472271b153c5dc53c28beac55480a8d8434b2d5c,CVE-2016-3839,https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c,2016-08-05T20:59Z 1643,CWE-264,"CWE-264 static int __ptrace_may_access ( struct task_struct * task , unsigned int mode ) { const struct cred * cred = current_cred ( ) , * tcred ; int dumpable = 0 ; if ( same_thread_group ( task , current ) ) return 0 ; rcu_read_lock ( ) ; tcred = __task_cred ( task ) ; if ( uid_eq ( cred -> uid , tcred -> euid ) && uid_eq ( cred -> uid , tcred -> suid ) && uid_eq ( cred -> uid , tcred -> uid ) && gid_eq ( cred -> gid , tcred -> egid ) && gid_eq ( cred -> gid , tcred -> sgid ) && gid_eq ( cred -> gid , tcred -> gid ) ) goto ok ; if ( ptrace_has_cap ( tcred -> user_ns , mode ) ) goto ok ; rcu_read_unlock ( ) ; return - EPERM ; ok : rcu_read_unlock ( ) ; smp_rmb ( ) ; if ( task -> mm ) dumpable = get_dumpable ( task -> mm ) ; rcu_read_lock ( ) ; if ( ! dumpable && ! ptrace_has_cap ( __task_cred ( task ) -> user_ns , mode ) ) { rcu_read_unlock ( ) ; return - EPERM ; } rcu_read_unlock ( ) ; return security_ptrace_access_check ( task , mode ) ; } "," ; if ( dumpable != SUID_DUMP_USER && ! ptrace_has_cap ( ",torvalds@linux/d049f74f2dbe71354d43d393ac3a188947811348,CVE-2013-2929,https://github.com/torvalds/linux/commit/d049f74f2dbe71354d43d393ac3a188947811348,2013-12-09T18:55Z 1644,CWE-119,"CWE-119 static int su3000_frontend_attach ( struct dvb_usb_adapter * d ) { u8 obuf [ 3 ] = { 0xe , 0x80 , 0 } ; u8 ibuf [ ] = { 0 } ; if ( dvb_usb_generic_rw ( d -> dev , obuf , 3 , ibuf , 1 , 0 ) < 0 ) err ( ""command0x0etransferfailed."" ) ; obuf [ 0 ] = 0xe ; obuf [ 1 ] = 0x02 ; obuf [ 2 ] = 1 ; if ( dvb_usb_generic_rw ( d -> dev , obuf , 3 , ibuf , 1 , 0 ) < 0 ) err ( ""command0x0etransferfailed."" ) ; msleep ( 300 ) ; obuf [ 0 ] = 0xe ; obuf [ 1 ] = 0x83 ; obuf [ 2 ] = 0 ; if ( dvb_usb_generic_rw ( d -> dev , obuf , 3 , ibuf , 1 , 0 ) < 0 ) err ( ""command0x0etransferfailed."" ) ; obuf [ 0 ] = 0xe ; obuf [ 1 ] = 0x83 ; obuf [ 2 ] = 1 ; if ( dvb_usb_generic_rw ( d -> dev , obuf , 3 , ibuf , 1 , 0 ) < 0 ) err ( ""command0x0etransferfailed."" ) ; obuf [ 0 ] = 0x51 ; if ( dvb_usb_generic_rw ( d -> dev , obuf , 1 , ibuf , 1 , 0 ) < 0 ) err ( ""command0x51transferfailed."" ) ; d -> fe_adap [ 0 ] . fe = dvb_attach ( ds3000_attach , & su3000_ds3000_config , & d -> dev -> i2c_adap ) ; if ( d -> fe_adap [ 0 ] . fe == NULL ) return - EIO ; if ( dvb_attach ( ts2020_attach , d -> fe_adap [ 0 ] . fe , & dw2104_ts2020_config , & d -> dev -> i2c_adap ) ) { info ( ""AttachedDS3000/TS2020!"" ) ; return 0 ; } info ( ""FailedtoattachDS3000/TS2020!"" ) ; return - EIO ; } "," struct dvb_usb_adapter * adap ) { struct dvb_usb_device * d = adap -> dev ; struct dw2102_state * state = d -> priv ; mutex_lock ( & d -> data_mutex ) ; state -> data [ 0 ] = 0xe ; state -> data [ 1 ] = 0x80 ; state -> data [ 2 ] = 0 ; if ( dvb_usb_generic_rw ( d , state -> data , 3 , state -> data , 1 , 0 ) < 0 ) err ( ""command0x0etransferfailed."" ) ; state -> data [ 0 ] = 0xe ; state -> data [ 1 ] = 0x02 ; state -> data [ 2 ] = 1 ; if ( dvb_usb_generic_rw ( d , state -> data , 3 , , 3 , state -> data , 1 , ""command0x0etransferfailed."" ) ; msleep ( 300 ) ; state -> data [ 0 ] = 0xe ; state -> data [ 1 ] = 0x83 ; state -> data [ 2 ] 2 ] = 0 ; if ( dvb_usb_generic_rw ( d , state -> data , 3 , , 3 , state -> data , 1 , ""command0x0etransferfailed."" ) ; state -> data [ 0 ] = 0xe ; state -> data [ 1 ] = 0x83 ; state -> data [ 2 ] 2 ] = 1 ; if ( dvb_usb_generic_rw ( d , state -> data , 3 , , 3 , state -> data , 1 , ""command0x0etransferfailed."" ) ; state -> data [ 0 ] = 0x51 ; if ( dvb_usb_generic_rw ( d , state -> data , 1 , state -> data , 1 , ) err ( ""command0x51transferfailed."" ) ; ""command0x51transferfailed."" ) ; mutex_unlock ( & d -> data_mutex ) ; adap -> fe_adap [ & d -> i2c_adap ) ; ; if ( adap -> fe_adap [ ( ts2020_attach , adap -> fe_adap [ , & d -> i2c_adap ) ",torvalds@linux/606142af57dad981b78707234cfbd15f9f7b7125,CVE-2017-8062,https://github.com/torvalds/linux/commit/606142af57dad981b78707234cfbd15f9f7b7125,2017-04-23T05:59Z 1645,CWE-190,"CWE-190 static int getnum ( const char * * fmt , int df ) { if ( ! isdigit ( * * fmt ) ) return df ; else { int a = 0 ; do { a = a * 10 + * ( ( * fmt ) ++ ) - '0' ; } while ( isdigit ( * * fmt ) ) ; return a ; } } "," int getnum ( lua_State * L , ; do { if ( a > ( INT_MAX / 10 ) || a * 10 > ( INT_MAX - ( * * fmt - '0' ) ) ) luaL_error ( L , ""integralsizeoverflow"" ) ; ",antirez@redis/ef764dde1cca2f25d00686673d1bc89448819571,CVE-2020-14147,https://github.com/antirez/redis/commit/ef764dde1cca2f25d00686673d1bc89448819571,2020-06-15T18:15Z 1646,CWE-125,"CWE-125 static void youngcollection ( lua_State * L , global_State * g ) { GCObject * * psurvival ; lua_assert ( g -> gcstate == GCSpropagate ) ; markold ( g , g -> survival , g -> reallyold ) ; markold ( g , g -> finobj , g -> finobjrold ) ; atomic ( L ) ; psurvival = sweepgen ( L , g , & g -> allgc , g -> survival ) ; sweepgen ( L , g , psurvival , g -> reallyold ) ; g -> reallyold = g -> old ; g -> old = * psurvival ; g -> survival = g -> allgc ; psurvival = sweepgen ( L , g , & g -> finobj , g -> finobjsur ) ; sweepgen ( L , g , psurvival , g -> finobjrold ) ; g -> finobjrold = g -> finobjold ; g -> finobjold = * psurvival ; g -> finobjsur = g -> finobj ; sweepgen ( L , g , & g -> tobefnz , NULL ) ; finishgencycle ( L , g ) ; } "," , g -> allgc , g -> ",lua@lua/127e7a6c8942b362aa3c6627f44d660a4fb75312,CVE-2020-15889,https://github.com/lua/lua/commit/127e7a6c8942b362aa3c6627f44d660a4fb75312,2020-07-21T22:15Z 1647,CWE-401,"CWE-401 static int af9005_identify_state ( struct usb_device * udev , struct dvb_usb_device_properties * props , struct dvb_usb_device_description * * desc , int * cold ) { int ret ; u8 reply , * buf ; buf = kmalloc ( FW_BULKOUT_SIZE + 2 , GFP_KERNEL ) ; if ( ! buf ) return - ENOMEM ; ret = af9005_boot_packet ( udev , FW_CONFIG , & reply , buf , FW_BULKOUT_SIZE + 2 ) ; if ( ret ) goto err ; deb_info ( ""resultofFW_CONFIGinidentifystate%d\\n"" , reply ) ; if ( reply == 0x01 ) * cold = 1 ; else if ( reply == 0x02 ) * cold = 0 ; else return - EIO ; deb_info ( ""Identifystatecold=%d\\n"" , * cold ) ; err : kfree ( buf ) ; return ret ; } "," 0 ; else ret = - EIO ; - EIO ; if ( ! ret ) ",torvalds@linux/2289adbfa559050d2a38bcd9caac1c18b800e928,CVE-2019-18809,https://github.com/torvalds/linux/commit/2289adbfa559050d2a38bcd9caac1c18b800e928,2019-11-07T16:15Z 1648,CWE-295,"CWE-295 NOEXPORT char * pgsql_server ( CLI * c , SERVICE_OPTIONS * opt , const PHASE phase ) { uint8_t buffer [ 8 ] , ssl_ok [ 1 ] = { 'S' } ; ( void ) opt ; if ( phase != PROTOCOL_EARLY ) return NULL ; memset ( buffer , 0 , sizeof buffer ) ; s_read ( c , c -> local_rfd . fd , buffer , sizeof buffer ) ; if ( safe_memcmp ( buffer , ssl_request , sizeof ssl_request ) ) { s_log ( LOG_ERR , ""PostgreSQLclientdidnotrequestTLS,rejecting"" ) ; throw_exception ( c , 1 ) ; } s_write ( c , c -> local_wfd . fd , ssl_ok , sizeof ssl_ok ) ; return NULL ; } "," 'S' } ; static const uint8_t gss_request [ 8 ] = { 0 , 0 , 0 , 8 , 0x04 , 0xd2 , 0x16 , 0x30 } ; static const uint8_t gss_response [ 62 ] = { 'E' , 0 , 0 , 0 , 61 , 'S' , 'E' , 'R' , 'R' , 'O' , 'R' , 0 , 'C' , 'X' , 'X' , '0' , '0' , '0' , 0 , 'M' , 'S' , 'S' , 'L' , '' , 'e' , 'x' , 'p' , 'e' , 'c' , 't' , 'e' , 'd' , '' , 'b' , 'u' , 't' , '' , 'n' , 'o' , 't' , '' , 'r' , 'e' , 'q' , 'u' , 'e' , 's' , 't' , 'e' , 'd' , '' , 'b' , 'y' , '' , 'c' , 'l' , 'i' , 'e' , 'n' , 't' , 0 , 0 } ; ) return NULL ; s_log ( LOG_DEBUG , ""Startedserver-sidepsqlprotcolnegotiation"" ) ; if ( ! ( buffer , gss_request , sizeof gss_request ) ) { { s_log ( LOG_INFO , ""GSSAPIencryptionrequested,rejectinggracefully"" ) ; s_write ( c . fd , gss_response , sizeof gss_response ) ; throw_exception ( c , 2 ) ; } if ( safe_memcmp ( buffer , ssl_request , sizeof ssl_request ) ) { s_log ( LOG_ERR , ""PostgreSQLclientdidnotrequestTLS,rejecting"" ) ; throw_exception ( c , 1 ) ; } s_log ( LOG_DEBUG , ""SSLRequestreceived"" ) ; s_write ( c , c -> local_wfd . fd , ",mtrojnar@stunnel/ebad9ddc4efb2635f37174c9d800d06206f1edf9,CVE-2021-20230,https://github.com/mtrojnar/stunnel/commit/ebad9ddc4efb2635f37174c9d800d06206f1edf9,2021-02-23T17:15Z 1649,CWE-399,"CWE-399 static int cib_tls_signon ( cib_t * cib , struct remote_connection_s * connection ) { int sock ; cib_remote_opaque_t * private = cib -> variant_opaque ; struct sockaddr_in addr ; int rc = 0 ; char * server = private -> server ; int ret_ga ; struct addrinfo * res ; struct addrinfo hints ; xmlNode * answer = NULL ; xmlNode * login = NULL ; static struct mainloop_fd_callbacks cib_fd_callbacks = { . dispatch = cib_remote_dispatch , . destroy = cib_remote_connection_destroy , } ; connection -> socket = 0 ; connection -> session = NULL ; sock = socket ( PF_INET , SOCK_STREAM , IPPROTO_TCP ) ; if ( sock == - 1 ) { crm_perror ( LOG_ERR , ""Socketcreationfailed"" ) ; return - 1 ; } bzero ( & hints , sizeof ( struct addrinfo ) ) ; hints . ai_flags = AI_CANONNAME ; hints . ai_family = AF_INET ; hints . ai_socktype = SOCK_RAW ; if ( hints . ai_family == AF_INET6 ) { hints . ai_protocol = IPPROTO_ICMPV6 ; } else { hints . ai_protocol = IPPROTO_ICMP ; } crm_debug ( ""Lookingup%s"" , server ) ; ret_ga = getaddrinfo ( server , NULL , & hints , & res ) ; if ( ret_ga ) { crm_err ( ""getaddrinfo:%s"" , gai_strerror ( ret_ga ) ) ; close ( sock ) ; return - 1 ; } if ( res -> ai_canonname ) { server = res -> ai_canonname ; } crm_debug ( ""Gotaddress%sfor%s"" , server , private -> server ) ; if ( ! res -> ai_addr ) { fprintf ( stderr , ""getaddrinfofailed"" ) ; crm_exit ( 1 ) ; } # if 1 memcpy ( & addr , res -> ai_addr , res -> ai_addrlen ) ; # else memset ( & addr , 0 , sizeof ( addr ) ) ; addr . sin_family = AF_INET ; addr . sin_addr . s_addr = inet_addr ( server ) ; # endif addr . sin_port = htons ( private -> port ) ; if ( connect ( sock , ( struct sockaddr * ) & addr , sizeof ( addr ) ) == - 1 ) { crm_perror ( LOG_ERR , ""Connectionto%s:%dfailed"" , server , private -> port ) ; close ( sock ) ; return - 1 ; } if ( connection -> encrypted ) { # ifdef HAVE_GNUTLS_GNUTLS_H gnutls_global_init ( ) ; gnutls_anon_allocate_client_credentials ( & anon_cred_c ) ; connection -> session = create_tls_session ( sock , GNUTLS_CLIENT ) ; if ( connection -> session == NULL ) { crm_perror ( LOG_ERR , ""Sessioncreationfor%s:%dfailed"" , server , private -> port ) ; close ( sock ) ; cib_tls_close ( cib ) ; return - 1 ; } # else return - EPROTONOSUPPORT ; # endif } else { connection -> session = GUINT_TO_POINTER ( sock ) ; } login = create_xml_node ( NULL , ""cib_command"" ) ; crm_xml_add ( login , ""op"" , ""authenticate"" ) ; crm_xml_add ( login , ""user"" , private -> user ) ; crm_xml_add ( login , ""password"" , private -> passwd ) ; crm_xml_add ( login , ""hidden"" , ""password"" ) ; crm_send_remote_msg ( connection -> session , login , connection -> encrypted ) ; free_xml ( login ) ; answer = crm_recv_remote_msg ( connection -> session , connection -> encrypted ) ; crm_log_xml_trace ( answer , ""Reply"" ) ; if ( answer == NULL ) { rc = - EPROTO ; } else { const char * msg_type = crm_element_value ( answer , F_CIB_OPERATION ) ; const char * tmp_ticket = crm_element_value ( answer , F_CIB_CLIENTID ) ; if ( safe_str_neq ( msg_type , CRM_OP_REGISTER ) ) { crm_err ( ""Invalidregistrationmessage:%s"" , msg_type ) ; rc = - EPROTO ; } else if ( tmp_ticket == NULL ) { rc = - EPROTO ; } else { connection -> token = strdup ( tmp_ticket ) ; } } if ( rc != 0 ) { cib_tls_close ( cib ) ; } connection -> socket = sock ; connection -> source = mainloop_add_fd ( ""cib-remote"" , G_PRIORITY_HIGH , connection -> socket , cib , & cib_fd_callbacks ) ; return rc ; } "," remote_connection_s * connection , gboolean event_channel -> variant_opaque ; int rc = = 0 ; int disconnected = 0 ; xmlNode * mainloop_fd_callbacks cib_fd_callbacks = { 0 , } ; cib_fd_callbacks . dispatch = . dispatch = event_channel ? cib_remote_callback_dispatch : cib_remote_command_dispatch ; cib_fd_callbacks . destroy = destroy = cib_remote_connection_destroy ; connection -> ; sock = crm_remote_tcp_connect ( private -> server , private -> port ) ; if ( sock <= 0 ) { crm_perror ( LOG_ERR , ""remotetcpconnectionto%s:%dfailed"" , private -> server , private -> port ) ; } connection -> socket = sock ; if ( connection # ifdef HAVE_GNUTLS_GNUTLS_H if ( remote_gnutls_credentials_init == FALSE ) { anon_cred_c ) ; remote_gnutls_credentials_init = TRUE ; } connection -> session = crm_create_anon_tls_session ( sock , sock , GNUTLS_CLIENT , anon_cred_c ) ; if ( crm_initiate_client_tls_handshake ( connection -> session , DEFAULT_CLIENT_HANDSHAKE_TIMEOUT ) != 0 ) { crm_err ( ""Sessioncreationfor%s:%dfailed"" , private -> server , private port ) ; gnutls_deinit ( * connection -> session ) ; gnutls_free ( connection -> session ) ; connection -> session = NULL ; cib_tls_close ( login ) ; crm_recv_remote_msg ( connection -> session , & connection -> recv_buf , connection -> encrypted , - 1 , & disconnected ) ; if ( disconnected ) { rc = - ENOTCONN ; } answer = crm_parse_remote_buffer ( & connection -> recv_buf ; } } free_xml ( answer ) ; answer = NULL ; cib ) ; return rc ; } crm_trace ( ""remoteclientconnectionestablished"" ) ; connection -> ",ClusterLabs@pacemaker/564f7cc2a51dcd2f28ab12a13394f31be5aa3c93,CVE-2013-0281,https://github.com/ClusterLabs/pacemaker/commit/564f7cc2a51dcd2f28ab12a13394f31be5aa3c93,2013-11-23T11:55Z 1650,CWE-119,"CWE-119 struct VP8_COMP * vp8_create_compressor ( VP8_CONFIG * oxcf ) { int i ; VP8_COMP * cpi ; VP8_COMMON * cm ; cpi = vpx_memalign ( 32 , sizeof ( VP8_COMP ) ) ; if ( ! cpi ) return 0 ; cm = & cpi -> common ; vpx_memset ( cpi , 0 , sizeof ( VP8_COMP ) ) ; if ( setjmp ( cm -> error . jmp ) ) { cpi -> common . error . setjmp = 0 ; vp8_remove_compressor ( & cpi ) ; return 0 ; } cpi -> common . error . setjmp = 1 ; CHECK_MEM_ERROR ( cpi -> mb . ss , vpx_calloc ( sizeof ( search_site ) , ( MAX_MVSEARCH_STEPS * 8 ) + 1 ) ) ; vp8_create_common ( & cpi -> common ) ; init_config ( cpi , oxcf ) ; memcpy ( cpi -> base_skip_false_prob , vp8cx_base_skip_false_prob , sizeof ( vp8cx_base_skip_false_prob ) ) ; cpi -> common . current_video_frame = 0 ; cpi -> temporal_pattern_counter = 0 ; cpi -> kf_overspend_bits = 0 ; cpi -> kf_bitrate_adjustment = 0 ; cpi -> frames_till_gf_update_due = 0 ; cpi -> gf_overspend_bits = 0 ; cpi -> non_gf_bitrate_adjustment = 0 ; cpi -> prob_last_coded = 128 ; cpi -> prob_gf_coded = 128 ; cpi -> prob_intra_coded = 63 ; cpi -> recent_ref_frame_usage [ INTRA_FRAME ] = 1 ; cpi -> recent_ref_frame_usage [ LAST_FRAME ] = 1 ; cpi -> recent_ref_frame_usage [ GOLDEN_FRAME ] = 1 ; cpi -> recent_ref_frame_usage [ ALTREF_FRAME ] = 1 ; cpi -> common . ref_frame_sign_bias [ ALTREF_FRAME ] = 1 ; cpi -> twopass . gf_decay_rate = 0 ; cpi -> baseline_gf_interval = DEFAULT_GF_INTERVAL ; cpi -> gold_is_last = 0 ; cpi -> alt_is_last = 0 ; cpi -> gold_is_alt = 0 ; cpi -> active_map_enabled = 0 ; # if 0 if ( cpi -> pass == 0 ) { cpi -> one_pass_frame_index = 0 ; for ( i = 0 ; i < MAX_LAG_BUFFERS ; i ++ ) { cpi -> one_pass_frame_stats [ i ] . frames_so_far = 0 ; cpi -> one_pass_frame_stats [ i ] . frame_intra_error = 0.0 ; cpi -> one_pass_frame_stats [ i ] . frame_coded_error = 0.0 ; cpi -> one_pass_frame_stats [ i ] . frame_pcnt_inter = 0.0 ; cpi -> one_pass_frame_stats [ i ] . frame_pcnt_motion = 0.0 ; cpi -> one_pass_frame_stats [ i ] . frame_mvr = 0.0 ; cpi -> one_pass_frame_stats [ i ] . frame_mvr_abs = 0.0 ; cpi -> one_pass_frame_stats [ i ] . frame_mvc = 0.0 ; cpi -> one_pass_frame_stats [ i ] . frame_mvc_abs = 0.0 ; } } # endif cpi -> cyclic_refresh_mode_enabled = cpi -> oxcf . error_resilient_mode ; cpi -> cyclic_refresh_mode_max_mbs_perframe = ( cpi -> common . mb_rows * cpi -> common . mb_cols ) / 5 ; cpi -> cyclic_refresh_mode_index = 0 ; cpi -> cyclic_refresh_q = 32 ; if ( cpi -> cyclic_refresh_mode_enabled ) { CHECK_MEM_ERROR ( cpi -> cyclic_refresh_map , vpx_calloc ( ( cpi -> common . mb_rows * cpi -> common . mb_cols ) , 1 ) ) ; } else cpi -> cyclic_refresh_map = ( signed char * ) NULL ; # ifdef VP8_ENTROPY_STATS init_context_counters ( ) ; # endif cpi -> activity_avg = 90 << 12 ; cpi -> frames_since_key = 8 ; cpi -> key_frame_frequency = cpi -> oxcf . key_freq ; cpi -> this_key_frame_forced = 0 ; cpi -> next_key_frame_forced = 0 ; cpi -> source_alt_ref_pending = 0 ; cpi -> source_alt_ref_active = 0 ; cpi -> common . refresh_alt_ref_frame = 0 ; cpi -> b_calculate_psnr = CONFIG_INTERNAL_STATS ; # if CONFIG_INTERNAL_STATS cpi -> b_calculate_ssimg = 0 ; cpi -> count = 0 ; cpi -> bytes = 0 ; if ( cpi -> b_calculate_psnr ) { cpi -> total_sq_error = 0.0 ; cpi -> total_sq_error2 = 0.0 ; cpi -> total_y = 0.0 ; cpi -> total_u = 0.0 ; cpi -> total_v = 0.0 ; cpi -> total = 0.0 ; cpi -> totalp_y = 0.0 ; cpi -> totalp_u = 0.0 ; cpi -> totalp_v = 0.0 ; cpi -> totalp = 0.0 ; cpi -> tot_recode_hits = 0 ; cpi -> summed_quality = 0 ; cpi -> summed_weights = 0 ; } if ( cpi -> b_calculate_ssimg ) { cpi -> total_ssimg_y = 0 ; cpi -> total_ssimg_u = 0 ; cpi -> total_ssimg_v = 0 ; cpi -> total_ssimg_all = 0 ; } # endif cpi -> first_time_stamp_ever = 0x7FFFFFFF ; cpi -> frames_till_gf_update_due = 0 ; cpi -> key_frame_count = 1 ; cpi -> ni_av_qi = cpi -> oxcf . worst_allowed_q ; cpi -> ni_tot_qi = 0 ; cpi -> ni_frames = 0 ; cpi -> total_byte_count = 0 ; cpi -> drop_frame = 0 ; cpi -> rate_correction_factor = 1.0 ; cpi -> key_frame_rate_correction_factor = 1.0 ; cpi -> gf_rate_correction_factor = 1.0 ; cpi -> twopass . est_max_qcorrection_factor = 1.0 ; for ( i = 0 ; i < KEY_FRAME_CONTEXT ; i ++ ) { cpi -> prior_key_frame_distance [ i ] = ( int ) cpi -> output_framerate ; } # ifdef OUTPUT_YUV_SRC yuv_file = fopen ( ""bd.yuv"" , ""ab"" ) ; # endif # if 0 framepsnr = fopen ( ""framepsnr.stt"" , ""a"" ) ; kf_list = fopen ( ""kf_list.stt"" , ""w"" ) ; # endif cpi -> output_pkt_list = oxcf -> output_pkt_list ; # if ! ( CONFIG_REALTIME_ONLY ) if ( cpi -> pass == 1 ) { vp8_init_first_pass ( cpi ) ; } else if ( cpi -> pass == 2 ) { size_t packet_sz = sizeof ( FIRSTPASS_STATS ) ; int packets = ( int ) ( oxcf -> two_pass_stats_in . sz / packet_sz ) ; cpi -> twopass . stats_in_start = oxcf -> two_pass_stats_in . buf ; cpi -> twopass . stats_in = cpi -> twopass . stats_in_start ; cpi -> twopass . stats_in_end = ( void * ) ( ( char * ) cpi -> twopass . stats_in + ( packets - 1 ) * packet_sz ) ; vp8_init_second_pass ( cpi ) ; } # endif if ( cpi -> compressor_speed == 2 ) { cpi -> avg_encode_time = 0 ; cpi -> avg_pick_mode_time = 0 ; } vp8_set_speed_features ( cpi ) ; for ( i = 0 ; i < MAX_MODES ; i ++ ) { cpi -> mb . rd_thresh_mult [ i ] = 128 ; } # ifdef VP8_ENTROPY_STATS init_mv_ref_counts ( ) ; # endif # if CONFIG_MULTITHREAD if ( vp8cx_create_encoder_threads ( cpi ) ) { vp8_remove_compressor ( & cpi ) ; return 0 ; } # endif cpi -> fn_ptr [ BLOCK_16X16 ] . sdf = vp8_sad16x16 ; cpi -> fn_ptr [ BLOCK_16X16 ] . vf = vp8_variance16x16 ; cpi -> fn_ptr [ BLOCK_16X16 ] . svf = vp8_sub_pixel_variance16x16 ; cpi -> fn_ptr [ BLOCK_16X16 ] . svf_halfpix_h = vp8_variance_halfpixvar16x16_h ; cpi -> fn_ptr [ BLOCK_16X16 ] . svf_halfpix_v = vp8_variance_halfpixvar16x16_v ; cpi -> fn_ptr [ BLOCK_16X16 ] . svf_halfpix_hv = vp8_variance_halfpixvar16x16_hv ; cpi -> fn_ptr [ BLOCK_16X16 ] . sdx3f = vp8_sad16x16x3 ; cpi -> fn_ptr [ BLOCK_16X16 ] . sdx8f = vp8_sad16x16x8 ; cpi -> fn_ptr [ BLOCK_16X16 ] . sdx4df = vp8_sad16x16x4d ; cpi -> fn_ptr [ BLOCK_16X8 ] . sdf = vp8_sad16x8 ; cpi -> fn_ptr [ BLOCK_16X8 ] . vf = vp8_variance16x8 ; cpi -> fn_ptr [ BLOCK_16X8 ] . svf = vp8_sub_pixel_variance16x8 ; cpi -> fn_ptr [ BLOCK_16X8 ] . svf_halfpix_h = NULL ; cpi -> fn_ptr [ BLOCK_16X8 ] . svf_halfpix_v = NULL ; cpi -> fn_ptr [ BLOCK_16X8 ] . svf_halfpix_hv = NULL ; cpi -> fn_ptr [ BLOCK_16X8 ] . sdx3f = vp8_sad16x8x3 ; cpi -> fn_ptr [ BLOCK_16X8 ] . sdx8f = vp8_sad16x8x8 ; cpi -> fn_ptr [ BLOCK_16X8 ] . sdx4df = vp8_sad16x8x4d ; cpi -> fn_ptr [ BLOCK_8X16 ] . sdf = vp8_sad8x16 ; cpi -> fn_ptr [ BLOCK_8X16 ] . vf = vp8_variance8x16 ; cpi -> fn_ptr [ BLOCK_8X16 ] . svf = vp8_sub_pixel_variance8x16 ; cpi -> fn_ptr [ BLOCK_8X16 ] . svf_halfpix_h = NULL ; cpi -> fn_ptr [ BLOCK_8X16 ] . svf_halfpix_v = NULL ; cpi -> fn_ptr [ BLOCK_8X16 ] . svf_halfpix_hv = NULL ; cpi -> fn_ptr [ BLOCK_8X16 ] . sdx3f = vp8_sad8x16x3 ; cpi -> fn_ptr [ BLOCK_8X16 ] . sdx8f = vp8_sad8x16x8 ; cpi -> fn_ptr [ BLOCK_8X16 ] . sdx4df = vp8_sad8x16x4d ; cpi -> fn_ptr [ BLOCK_8X8 ] . sdf = vp8_sad8x8 ; cpi -> fn_ptr [ BLOCK_8X8 ] . vf = vp8_variance8x8 ; cpi -> fn_ptr [ BLOCK_8X8 ] . svf = vp8_sub_pixel_variance8x8 ; cpi -> fn_ptr [ BLOCK_8X8 ] . svf_halfpix_h = NULL ; cpi -> fn_ptr [ BLOCK_8X8 ] . svf_halfpix_v = NULL ; cpi -> fn_ptr [ BLOCK_8X8 ] . svf_halfpix_hv = NULL ; cpi -> fn_ptr [ BLOCK_8X8 ] . sdx3f = vp8_sad8x8x3 ; cpi -> fn_ptr [ BLOCK_8X8 ] . sdx8f = vp8_sad8x8x8 ; cpi -> fn_ptr [ BLOCK_8X8 ] . sdx4df = vp8_sad8x8x4d ; cpi -> fn_ptr [ BLOCK_4X4 ] . sdf = vp8_sad4x4 ; cpi -> fn_ptr [ BLOCK_4X4 ] . vf = vp8_variance4x4 ; cpi -> fn_ptr [ BLOCK_4X4 ] . svf = vp8_sub_pixel_variance4x4 ; cpi -> fn_ptr [ BLOCK_4X4 ] . svf_halfpix_h = NULL ; cpi -> fn_ptr [ BLOCK_4X4 ] . svf_halfpix_v = NULL ; cpi -> fn_ptr [ BLOCK_4X4 ] . svf_halfpix_hv = NULL ; cpi -> fn_ptr [ BLOCK_4X4 ] . sdx3f = vp8_sad4x4x3 ; cpi -> fn_ptr [ BLOCK_4X4 ] . sdx8f = vp8_sad4x4x8 ; cpi -> fn_ptr [ BLOCK_4X4 ] . sdx4df = vp8_sad4x4x4d ; # if ARCH_X86 || ARCH_X86_64 cpi -> fn_ptr [ BLOCK_16X16 ] . copymem = vp8_copy32xn ; cpi -> fn_ptr [ BLOCK_16X8 ] . copymem = vp8_copy32xn ; cpi -> fn_ptr [ BLOCK_8X16 ] . copymem = vp8_copy32xn ; cpi -> fn_ptr [ BLOCK_8X8 ] . copymem = vp8_copy32xn ; cpi -> fn_ptr [ BLOCK_4X4 ] . copymem = vp8_copy32xn ; # endif cpi -> full_search_sad = vp8_full_search_sad ; cpi -> diamond_search_sad = vp8_diamond_search_sad ; cpi -> refining_search_sad = vp8_refining_search_sad ; cpi -> mb . error_bins [ 0 ] = cpi -> common . MBs ; vp8cx_init_quantizer ( cpi ) ; vp8_loop_filter_init ( cm ) ; cpi -> common . error . setjmp = 0 ; # if CONFIG_MULTI_RES_ENCODING if ( cpi -> oxcf . mr_encoder_id > 0 ) vp8_cal_low_res_mb_cols ( cpi ) ; # endif cpi -> mb . mvcost [ 0 ] = & cpi -> rd_costs . mvcosts [ 0 ] [ mv_max + 1 ] ; cpi -> mb . mvcost [ 1 ] = & cpi -> rd_costs . mvcosts [ 1 ] [ mv_max + 1 ] ; cpi -> mb . mvsadcost [ 0 ] = & cpi -> rd_costs . mvsadcosts [ 0 ] [ mvfp_max + 1 ] ; cpi -> mb . mvsadcost [ 1 ] = & cpi -> rd_costs . mvsadcosts [ 1 ] [ mvfp_max + 1 ] ; cal_mvsadcosts ( cpi -> mb . mvsadcost ) ; cpi -> mb . mbmode_cost = cpi -> rd_costs . mbmode_cost ; cpi -> mb . intra_uv_mode_cost = cpi -> rd_costs . intra_uv_mode_cost ; cpi -> mb . bmode_costs = cpi -> rd_costs . bmode_costs ; cpi -> mb . inter_bmode_costs = cpi -> rd_costs . inter_bmode_costs ; cpi -> mb . token_costs = cpi -> rd_costs . token_costs ; vp8_setup_block_ptrs ( & cpi -> mb ) ; vp8_setup_block_dptrs ( & cpi -> mb . e_mbd ) ; return cpi ; } "," -> common ; memset ( cpi , ; cpi -> temporal_layer_id = - 1 ; cpi -> endif cpi -> mse_source_denoised = 0 ; cpi -> / 5 ; if ( cpi -> oxcf . number_of_layers == 1 ) { cpi -> cyclic_refresh_mode_max_mbs_perframe = ( cpi -> common . mb_rows * cpi -> common . mb_cols ) / 20 ; } else if ( cpi -> oxcf . number_of_layers == 2 ) { cpi -> cyclic_refresh_mode_max_mbs_perframe = ( cpi -> common . mb_rows * cpi -> common . mb_cols ) / 10 ; } ) NULL ; CHECK_MEM_ERROR ( cpi -> consec_zero_last , vpx_calloc ( cm -> mb_rows * cm -> mb_cols , 1 ) ) ; CHECK_MEM_ERROR ( cpi -> consec_zero_last_mvbias , vpx_calloc ( ( cpi -> common . mb_rows * cpi -> common . mb_cols ) , 1 ) ) ; ; cpi -> force_maxqp = 0 ; cpi -> # endif # ifdef OUTPUT_YUV_DENOISED yuv_denoised_file = fopen ( ""denoised.yuv"" , ""ab"" ) ; # endif # . sdf = vpx_sad16x16 ; cpi -> . vf = vpx_variance16x16 ; cpi -> . svf = vpx_sub_pixel_variance16x16 ; cpi -> . svf_halfpix_h = vpx_variance_halfpixvar16x16_h ; cpi -> . svf_halfpix_v = vpx_variance_halfpixvar16x16_v ; cpi -> . svf_halfpix_hv = vpx_variance_halfpixvar16x16_hv ; cpi -> . sdx3f = vpx_sad16x16x3 ; cpi -> . sdx8f = vpx_sad16x16x8 ; cpi -> . sdx4df = vpx_sad16x16x4d ; cpi -> . sdf = vpx_sad16x8 ; cpi -> . vf = vpx_variance16x8 ; cpi -> . svf = vpx_sub_pixel_variance16x8 ; cpi -> . sdx3f = vpx_sad16x8x3 ; cpi -> . sdx8f = vpx_sad16x8x8 ; cpi -> . sdx4df = vpx_sad16x8x4d ; cpi -> . sdf = vpx_sad8x16 ; cpi -> . vf = vpx_variance8x16 ; cpi -> . svf = vpx_sub_pixel_variance8x16 ; cpi -> . sdx3f = vpx_sad8x16x3 ; cpi -> . sdx8f = vpx_sad8x16x8 ; cpi -> . sdx4df = vpx_sad8x16x4d ; cpi -> . sdf = vpx_sad8x8 ; cpi -> . vf = vpx_variance8x8 ; cpi -> . svf = vpx_sub_pixel_variance8x8 ; cpi -> . sdx3f = vpx_sad8x8x3 ; cpi -> . sdx8f = vpx_sad8x8x8 ; cpi -> . sdx4df = vpx_sad8x8x4d ; cpi -> . sdf = vpx_sad4x4 ; cpi -> . vf = vpx_variance4x4 ; cpi -> . svf = vpx_sub_pixel_variance4x4 ; cpi -> . sdx3f = vpx_sad4x4x3 ; cpi -> . sdx8f = vpx_sad4x4x8 ; cpi -> . sdx4df = vpx_sad4x4x4d ; # if ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1651,CWE-20,"CWE-20 static bool dccp_new ( struct nf_conn * ct , const struct sk_buff * skb , unsigned int dataoff , unsigned int * timeouts ) { struct net * net = nf_ct_net ( ct ) ; struct dccp_net * dn ; struct dccp_hdr _dh , * dh ; const char * msg ; u_int8_t state ; dh = skb_header_pointer ( skb , dataoff , sizeof ( _dh ) , & dh ) ; BUG_ON ( dh == NULL ) ; state = dccp_state_table [ CT_DCCP_ROLE_CLIENT ] [ dh -> dccph_type ] [ CT_DCCP_NONE ] ; switch ( state ) { default : dn = dccp_pernet ( net ) ; if ( dn -> dccp_loose == 0 ) { msg = ""nf_ct_dccp:notpickingupexistingconnection"" ; goto out_invalid ; } case CT_DCCP_REQUEST : break ; case CT_DCCP_INVALID : msg = ""nf_ct_dccp:invalidstatetransition"" ; goto out_invalid ; } ct -> proto . dccp . role [ IP_CT_DIR_ORIGINAL ] = CT_DCCP_ROLE_CLIENT ; ct -> proto . dccp . role [ IP_CT_DIR_REPLY ] = CT_DCCP_ROLE_SERVER ; ct -> proto . dccp . state = CT_DCCP_NONE ; ct -> proto . dccp . last_pkt = DCCP_PKT_REQUEST ; ct -> proto . dccp . last_dir = IP_CT_DIR_ORIGINAL ; ct -> proto . dccp . handshake_seq = 0 ; return true ; out_invalid : if ( LOG_INVALID ( net , IPPROTO_DCCP ) ) nf_log_packet ( net , nf_ct_l3num ( ct ) , 0 , skb , NULL , NULL , NULL , ""%s"" , msg ) ; return false ; } "," ) , & _dh ) ; BUG_ON ",torvalds@linux/b22f5126a24b3b2f15448c3f2a254fc10cbc2b92,CVE-2014-2523,https://github.com/torvalds/linux/commit/b22f5126a24b3b2f15448c3f2a254fc10cbc2b92,2014-03-24T16:40Z 1652,CWE-399,"CWE-399 static inline int do_exception ( struct pt_regs * regs , int access , unsigned long trans_exc_code ) { struct task_struct * tsk ; struct mm_struct * mm ; struct vm_area_struct * vma ; unsigned long address ; unsigned int flags ; int fault ; if ( notify_page_fault ( regs ) ) return 0 ; tsk = current ; mm = tsk -> mm ; fault = VM_FAULT_BADCONTEXT ; if ( unlikely ( ! user_space_fault ( trans_exc_code ) || in_atomic ( ) || ! mm ) ) goto out ; address = trans_exc_code & __FAIL_ADDR_MASK ; perf_sw_event ( PERF_COUNT_SW_PAGE_FAULTS , 1 , 0 , regs , address ) ; flags = FAULT_FLAG_ALLOW_RETRY ; if ( access == VM_WRITE || ( trans_exc_code & store_indication ) == 0x400 ) flags |= FAULT_FLAG_WRITE ; retry : down_read ( & mm -> mmap_sem ) ; fault = VM_FAULT_BADMAP ; vma = find_vma ( mm , address ) ; if ( ! vma ) goto out_up ; if ( unlikely ( vma -> vm_start > address ) ) { if ( ! ( vma -> vm_flags & VM_GROWSDOWN ) ) goto out_up ; if ( expand_stack ( vma , address ) ) goto out_up ; } fault = VM_FAULT_BADACCESS ; if ( unlikely ( ! ( vma -> vm_flags & access ) ) ) goto out_up ; if ( is_vm_hugetlb_page ( vma ) ) address &= HPAGE_MASK ; fault = handle_mm_fault ( mm , vma , address , flags ) ; if ( unlikely ( fault & VM_FAULT_ERROR ) ) goto out_up ; if ( flags & FAULT_FLAG_ALLOW_RETRY ) { if ( fault & VM_FAULT_MAJOR ) { tsk -> maj_flt ++ ; perf_sw_event ( PERF_COUNT_SW_PAGE_FAULTS_MAJ , 1 , 0 , regs , address ) ; } else { tsk -> min_flt ++ ; perf_sw_event ( PERF_COUNT_SW_PAGE_FAULTS_MIN , 1 , 0 , regs , address ) ; } if ( fault & VM_FAULT_RETRY ) { flags &= ~ FAULT_FLAG_ALLOW_RETRY ; goto retry ; } } clear_tsk_thread_flag ( tsk , TIF_PER_TRAP ) ; fault = 0 ; out_up : up_read ( & mm -> mmap_sem ) ; out : return fault ; } "," , 1 , regs , address , 1 , regs , address PERF_COUNT_SW_PAGE_FAULTS_MIN , 1 , regs , ",torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,CVE-2011-2918,https://github.com/torvalds/linux/commit/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,2012-05-24T23:55Z 1653,CWE-125,"CWE-125 static void mldv2_query_print ( netdissect_options * ndo , const u_char * bp , u_int len ) { const struct icmp6_hdr * icp = ( const struct icmp6_hdr * ) bp ; u_int mrc ; int mrt , qqi ; u_int nsrcs ; register u_int i ; if ( len < 28 ) { ND_PRINT ( ( ndo , ""[invalidlen%d]"" , len ) ) ; return ; } ND_TCHECK ( icp -> icmp6_data16 [ 0 ] ) ; mrc = EXTRACT_16BITS ( & icp -> icmp6_data16 [ 0 ] ) ; if ( mrc < 32768 ) { mrt = mrc ; } else { mrt = ( ( mrc & 0x0fff ) | 0x1000 ) << ( ( ( mrc & 0x7000 ) >> 12 ) + 3 ) ; } if ( ndo -> ndo_vflag ) { ND_PRINT ( ( ndo , ""[maxrespdelay=%d]"" , mrt ) ) ; } ND_TCHECK2 ( bp [ 8 ] , sizeof ( struct in6_addr ) ) ; ND_PRINT ( ( ndo , ""[gaddr%s"" , ip6addr_string ( ndo , & bp [ 8 ] ) ) ) ; if ( ndo -> ndo_vflag ) { ND_TCHECK ( bp [ 25 ] ) ; if ( bp [ 24 ] & 0x08 ) { ND_PRINT ( ( ndo , ""sflag"" ) ) ; } if ( bp [ 24 ] & 0x07 ) { ND_PRINT ( ( ndo , ""robustness=%d"" , bp [ 24 ] & 0x07 ) ) ; } if ( bp [ 25 ] < 128 ) { qqi = bp [ 25 ] ; } else { qqi = ( ( bp [ 25 ] & 0x0f ) | 0x10 ) << ( ( ( bp [ 25 ] & 0x70 ) >> 4 ) + 3 ) ; } ND_PRINT ( ( ndo , ""qqi=%d"" , qqi ) ) ; } ND_TCHECK2 ( bp [ 26 ] , 2 ) ; nsrcs = EXTRACT_16BITS ( & bp [ 26 ] ) ; if ( nsrcs > 0 ) { if ( len < 28 + nsrcs * sizeof ( struct in6_addr ) ) ND_PRINT ( ( ndo , ""[invalidnumberofsources]"" ) ) ; else if ( ndo -> ndo_vflag > 1 ) { ND_PRINT ( ( ndo , ""{"" ) ) ; for ( i = 0 ; i < nsrcs ; i ++ ) { ND_TCHECK2 ( bp [ 28 + i * sizeof ( struct in6_addr ) ] , sizeof ( struct in6_addr ) ) ; ND_PRINT ( ( ndo , ""%s"" , ip6addr_string ( ndo , & bp [ 28 + i * sizeof ( struct in6_addr ) ] ) ) ) ; } ND_PRINT ( ( ndo , ""}"" ) ) ; } else ND_PRINT ( ( ndo , "",%dsource(s)"" , nsrcs ) ) ; } ND_PRINT ( ( ndo , ""]"" ) ) ; return ; trunc : ND_PRINT ( ( ndo , ""[|icmp6]"" ) ) ; return ; } "," ( ndo , ""%s"" , mldv2_tstr ) ) ; ",the-tcpdump-group@tcpdump/d7505276842e85bfd067fa21cdb32b8a2dc3c5e4,CVE-2018-14882,https://github.com/the-tcpdump-group/tcpdump/commit/d7505276842e85bfd067fa21cdb32b8a2dc3c5e4,2019-10-03T16:15Z 1654,CWE-400,"CWE-400 bool ExprResolveBoolean ( struct xkb_context * ctx , const ExprDef * expr , bool * set_rtrn ) { bool ok = false ; const char * ident ; switch ( expr -> expr . op ) { case EXPR_VALUE : if ( expr -> expr . value_type != EXPR_TYPE_BOOLEAN ) { log_err ( ctx , ""Foundconstantoftype%swherebooleanwasexpected\\n"" , expr_value_type_to_string ( expr -> expr . value_type ) ) ; return false ; } * set_rtrn = expr -> boolean . set ; return true ; case EXPR_IDENT : ident = xkb_atom_text ( ctx , expr -> ident . ident ) ; if ( ident ) { if ( istreq ( ident , ""true"" ) || istreq ( ident , ""yes"" ) || istreq ( ident , ""on"" ) ) { * set_rtrn = true ; return true ; } else if ( istreq ( ident , ""false"" ) || istreq ( ident , ""no"" ) || istreq ( ident , ""off"" ) ) { * set_rtrn = false ; return true ; } } log_err ( ctx , ""Identifier\\""%s\\""oftypebooleanisunknown\\n"" , ident ) ; return false ; case EXPR_FIELD_REF : log_err ( ctx , ""Default\\""%s.%s\\""oftypebooleanisunknown\\n"" , xkb_atom_text ( ctx , expr -> field_ref . element ) , xkb_atom_text ( ctx , expr -> field_ref . field ) ) ; return false ; case EXPR_INVERT : case EXPR_NOT : ok = ExprResolveBoolean ( ctx , expr , set_rtrn ) ; if ( ok ) * set_rtrn = ! * set_rtrn ; return ok ; case EXPR_ADD : case EXPR_SUBTRACT : case EXPR_MULTIPLY : case EXPR_DIVIDE : case EXPR_ASSIGN : case EXPR_NEGATE : case EXPR_UNARY_PLUS : log_err ( ctx , ""%sofbooleanvaluesnotpermitted\\n"" , expr_op_type_to_string ( expr -> expr . op ) ) ; break ; default : log_wsgo ( ctx , ""Unknownoperator%dinResolveBoolean\\n"" , expr -> expr . op ) ; break ; } return false ; } "," ctx , expr -> unary . child ",xkbcommon@libxkbcommon/1f9d1248c07cda8aaff762429c0dce146de8632a,CVE-2018-15853,https://github.com/xkbcommon/libxkbcommon/commit/1f9d1248c07cda8aaff762429c0dce146de8632a,2018-08-25T21:29Z 1655,CWE-835,"CWE-835 static Image * ReadHDRImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { char format [ MaxTextExtent ] , keyword [ MaxTextExtent ] , tag [ MaxTextExtent ] , value [ MaxTextExtent ] ; double gamma ; Image * image ; int c ; MagickBooleanType status , value_expected ; register Quantum * q ; register ssize_t i , x ; register unsigned char * p ; ssize_t count , y ; unsigned char * end , pixel [ 4 ] , * pixels ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image -> columns = 0 ; image -> rows = 0 ; * format = '\\0' ; c = ReadBlobByte ( image ) ; if ( c == EOF ) { image = DestroyImage ( image ) ; return ( ( Image * ) NULL ) ; } while ( isgraph ( c ) && ( image -> columns == 0 ) && ( image -> rows == 0 ) ) { if ( c == ( int ) '#' ) { char * comment ; register char * p ; size_t length ; length = MaxTextExtent ; comment = AcquireString ( ( char * ) NULL ) ; for ( p = comment ; comment != ( char * ) NULL ; p ++ ) { c = ReadBlobByte ( image ) ; if ( ( c == EOF ) || ( c == ( int ) '\\n' ) ) break ; if ( ( size_t ) ( p - comment + 1 ) >= length ) { * p = '\\0' ; length <<= 1 ; comment = ( char * ) ResizeQuantumMemory ( comment , length + MaxTextExtent , sizeof ( * comment ) ) ; if ( comment == ( char * ) NULL ) break ; p = comment + strlen ( comment ) ; } * p = ( char ) c ; } if ( comment == ( char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; * p = '\\0' ; ( void ) SetImageProperty ( image , ""comment"" , comment , exception ) ; comment = DestroyString ( comment ) ; c = ReadBlobByte ( image ) ; } else if ( isalnum ( c ) == MagickFalse ) c = ReadBlobByte ( image ) ; else { register char * p ; p = keyword ; do { if ( ( size_t ) ( p - keyword ) < ( MaxTextExtent - 1 ) ) * p ++ = c ; c = ReadBlobByte ( image ) ; } while ( isalnum ( c ) || ( c == '_' ) ) ; * p = '\\0' ; value_expected = MagickFalse ; while ( ( isspace ( ( int ) ( ( unsigned char ) c ) ) != 0 ) || ( c == '=' ) ) { if ( c == '=' ) value_expected = MagickTrue ; c = ReadBlobByte ( image ) ; } if ( LocaleCompare ( keyword , ""Y"" ) == 0 ) value_expected = MagickTrue ; if ( value_expected == MagickFalse ) continue ; p = value ; while ( ( c != '\\n' ) && ( c != '\\0' ) ) { if ( ( size_t ) ( p - value ) < ( MaxTextExtent - 1 ) ) * p ++ = c ; c = ReadBlobByte ( image ) ; } * p = '\\0' ; switch ( * keyword ) { case 'F' : case 'f' : { if ( LocaleCompare ( keyword , ""format"" ) == 0 ) { ( void ) CopyMagickString ( format , value , MaxTextExtent ) ; break ; } ( void ) FormatLocaleString ( tag , MaxTextExtent , ""hdr:%s"" , keyword ) ; ( void ) SetImageProperty ( image , tag , value , exception ) ; break ; } case 'G' : case 'g' : { if ( LocaleCompare ( keyword , ""gamma"" ) == 0 ) { image -> gamma = StringToDouble ( value , ( char * * ) NULL ) ; break ; } ( void ) FormatLocaleString ( tag , MaxTextExtent , ""hdr:%s"" , keyword ) ; ( void ) SetImageProperty ( image , tag , value , exception ) ; break ; } case 'P' : case 'p' : { if ( LocaleCompare ( keyword , ""primaries"" ) == 0 ) { float chromaticity [ 6 ] , white_point [ 2 ] ; ( void ) sscanf ( value , ""%g%g%g%g%g%g%g%g"" , & chromaticity [ 0 ] , & chromaticity [ 1 ] , & chromaticity [ 2 ] , & chromaticity [ 3 ] , & chromaticity [ 4 ] , & chromaticity [ 5 ] , & white_point [ 0 ] , & white_point [ 1 ] ) ; image -> chromaticity . red_primary . x = chromaticity [ 0 ] ; image -> chromaticity . red_primary . y = chromaticity [ 1 ] ; image -> chromaticity . green_primary . x = chromaticity [ 2 ] ; image -> chromaticity . green_primary . y = chromaticity [ 3 ] ; image -> chromaticity . blue_primary . x = chromaticity [ 4 ] ; image -> chromaticity . blue_primary . y = chromaticity [ 5 ] ; image -> chromaticity . white_point . x = white_point [ 0 ] , image -> chromaticity . white_point . y = white_point [ 1 ] ; break ; } ( void ) FormatLocaleString ( tag , MaxTextExtent , ""hdr:%s"" , keyword ) ; ( void ) SetImageProperty ( image , tag , value , exception ) ; break ; } case 'Y' : case 'y' : { char target [ ] = ""Y"" ; if ( strcmp ( keyword , target ) == 0 ) { int height , width ; ( void ) sscanf ( value , ""%d+X%d"" , & height , & width ) ; image -> columns = ( size_t ) width ; image -> rows = ( size_t ) height ; break ; } ( void ) FormatLocaleString ( tag , MaxTextExtent , ""hdr:%s"" , keyword ) ; ( void ) SetImageProperty ( image , tag , value , exception ) ; break ; } default : { ( void ) FormatLocaleString ( tag , MaxTextExtent , ""hdr:%s"" , keyword ) ; ( void ) SetImageProperty ( image , tag , value , exception ) ; break ; } } } if ( ( image -> columns == 0 ) && ( image -> rows == 0 ) ) while ( isspace ( ( int ) ( ( unsigned char ) c ) ) != 0 ) c = ReadBlobByte ( image ) ; } if ( ( LocaleCompare ( format , ""32-bit_rle_rgbe"" ) != 0 ) && ( LocaleCompare ( format , ""32-bit_rle_xyze"" ) != 0 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( ( image -> columns == 0 ) || ( image -> rows == 0 ) ) ThrowReaderException ( CorruptImageError , ""NegativeOrZeroImageSize"" ) ; ( void ) SetImageColorspace ( image , RGBColorspace , exception ) ; if ( LocaleCompare ( format , ""32-bit_rle_xyze"" ) == 0 ) ( void ) SetImageColorspace ( image , XYZColorspace , exception ) ; image -> compression = ( image -> columns < 8 ) || ( image -> columns > 0x7ffff ) ? NoCompression : RLECompression ; if ( image_info -> ping != MagickFalse ) { ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; pixels = ( unsigned char * ) AcquireQuantumMemory ( image -> columns , 4 * sizeof ( * pixels ) ) ; if ( pixels == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { if ( image -> compression != RLECompression ) { count = ReadBlob ( image , 4 * image -> columns * sizeof ( * pixels ) , pixels ) ; if ( count != ( ssize_t ) ( 4 * image -> columns * sizeof ( * pixels ) ) ) break ; } else { count = ReadBlob ( image , 4 * sizeof ( * pixel ) , pixel ) ; if ( count != 4 ) break ; if ( ( size_t ) ( ( ( ( size_t ) pixel [ 2 ] ) << 8 ) | pixel [ 3 ] ) != image -> columns ) { ( void ) memcpy ( pixels , pixel , 4 * sizeof ( * pixel ) ) ; count = ReadBlob ( image , 4 * ( image -> columns - 1 ) * sizeof ( * pixels ) , pixels + 4 ) ; image -> compression = NoCompression ; } else { p = pixels ; for ( i = 0 ; i < 4 ; i ++ ) { end = & pixels [ ( i + 1 ) * image -> columns ] ; while ( p < end ) { count = ReadBlob ( image , 2 * sizeof ( * pixel ) , pixel ) ; if ( count < 1 ) break ; if ( pixel [ 0 ] > 128 ) { count = ( ssize_t ) pixel [ 0 ] - 128 ; if ( ( count == 0 ) || ( count > ( ssize_t ) ( end - p ) ) ) break ; while ( count -- > 0 ) * p ++ = pixel [ 1 ] ; } else { count = ( ssize_t ) pixel [ 0 ] ; if ( ( count == 0 ) || ( count > ( ssize_t ) ( end - p ) ) ) break ; * p ++ = pixel [ 1 ] ; if ( -- count > 0 ) { count = ReadBlob ( image , ( size_t ) count * sizeof ( * p ) , p ) ; if ( count < 1 ) break ; p += count ; } } } } } } q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; i = 0 ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { if ( image -> compression == RLECompression ) { pixel [ 0 ] = pixels [ x ] ; pixel [ 1 ] = pixels [ x + image -> columns ] ; pixel [ 2 ] = pixels [ x + 2 * image -> columns ] ; pixel [ 3 ] = pixels [ x + 3 * image -> columns ] ; } else { pixel [ 0 ] = pixels [ i ++ ] ; pixel [ 1 ] = pixels [ i ++ ] ; pixel [ 2 ] = pixels [ i ++ ] ; pixel [ 3 ] = pixels [ i ++ ] ; } SetPixelRed ( image , 0 , q ) ; SetPixelGreen ( image , 0 , q ) ; SetPixelBlue ( image , 0 , q ) ; if ( pixel [ 3 ] != 0 ) { gamma = pow ( 2.0 , pixel [ 3 ] - ( 128.0 + 8.0 ) ) ; SetPixelRed ( image , ClampToQuantum ( QuantumRange * gamma * pixel [ 0 ] ) , q ) ; SetPixelGreen ( image , ClampToQuantum ( QuantumRange * gamma * pixel [ 1 ] ) , q ) ; SetPixelBlue ( image , ClampToQuantum ( QuantumRange * gamma * pixel [ 2 ] ) , q ) ; } q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } pixels = ( unsigned char * ) RelinquishMagickMemory ( pixels ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," != '\\0' ) && ( c != EOF ) 2 ] ; if ( sscanf ( value 1 ] ) == 8 ) { image -> chromaticity 1 ] ; } , width ; if ( sscanf ( value & width ) == 2 ) { image -> columns ) height ; } ",ImageMagick@ImageMagick/97aa7d7cfd2027f6ba7ce42caf8b798541b9cdc6,CVE-2015-8900,https://github.com/ImageMagick/ImageMagick/commit/97aa7d7cfd2027f6ba7ce42caf8b798541b9cdc6,2017-02-27T22:59Z 1656,CWE-362,"CWE-362 static int mptctl_mpt_command ( unsigned long arg ) { struct mpt_ioctl_command __user * uarg = ( void __user * ) arg ; struct mpt_ioctl_command karg ; MPT_ADAPTER * ioc ; int iocnum ; int rc ; if ( copy_from_user ( & karg , uarg , sizeof ( struct mpt_ioctl_command ) ) ) { printk ( KERN_ERR MYNAM ""%s@%d::mptctl_mpt_command-"" ""Unabletoreadinmpt_ioctl_commandstruct@%p\\n"" , __FILE__ , __LINE__ , uarg ) ; return - EFAULT ; } if ( ( ( iocnum = mpt_verify_adapter ( karg . hdr . iocnum , & ioc ) ) < 0 ) || ( ioc == NULL ) ) { printk ( KERN_DEBUG MYNAM ""%s::mptctl_mpt_command()@%d-ioc%dnotfound!\\n"" , __FILE__ , __LINE__ , iocnum ) ; return - ENODEV ; } rc = mptctl_do_mpt_command ( karg , & uarg -> MF ) ; return rc ; } "," int mptctl_mpt_command ( MPT_ADAPTER * ioc , struct mpt_ioctl_command karg ; int rc EFAULT ; } rc = mptctl_do_mpt_command = mptctl_do_mpt_command ( ioc , ",torvalds@linux/28d76df18f0ad5bcf5fa48510b225f0ed262a99b,CVE-2020-12652,https://github.com/torvalds/linux/commit/28d76df18f0ad5bcf5fa48510b225f0ed262a99b,2020-05-05T05:15Z 1657,CWE-834,"CWE-834 static Image * ReadXBMImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { char buffer [ MaxTextExtent ] , name [ MaxTextExtent ] ; Image * image ; MagickBooleanType status ; register IndexPacket * indexes ; register ssize_t i , x ; register PixelPacket * q ; register unsigned char * p ; short int hex_digits [ 256 ] ; ssize_t y ; unsigned char * data ; unsigned int bit , byte , bytes_per_line , height , length , padding , value , version , width ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } width = 0 ; height = 0 ; while ( ReadBlobString ( image , buffer ) != ( char * ) NULL ) if ( sscanf ( buffer , ""#define%32s%u"" , name , & width ) == 2 ) if ( ( strlen ( name ) >= 6 ) && ( LocaleCompare ( name + strlen ( name ) - 6 , ""_width"" ) == 0 ) ) break ; while ( ReadBlobString ( image , buffer ) != ( char * ) NULL ) if ( sscanf ( buffer , ""#define%32s%u"" , name , & height ) == 2 ) if ( ( strlen ( name ) >= 7 ) && ( LocaleCompare ( name + strlen ( name ) - 7 , ""_height"" ) == 0 ) ) break ; image -> columns = width ; image -> rows = height ; image -> depth = 8 ; image -> storage_class = PseudoClass ; image -> colors = 2 ; version = 11 ; while ( ReadBlobString ( image , buffer ) != ( char * ) NULL ) { if ( sscanf ( buffer , ""staticshort%32s={"" , name ) == 1 ) version = 10 ; else if ( sscanf ( buffer , ""staticunsignedchar%s={"" , name ) == 1 ) version = 11 ; else if ( sscanf ( buffer , ""staticchar%32s={"" , name ) == 1 ) version = 11 ; else continue ; p = ( unsigned char * ) strrchr ( name , '_' ) ; if ( p == ( unsigned char * ) NULL ) p = ( unsigned char * ) name ; else p ++ ; if ( LocaleCompare ( ""bits[]"" , ( char * ) p ) == 0 ) break ; } if ( ( image -> columns == 0 ) || ( image -> rows == 0 ) || ( EOFBlob ( image ) != MagickFalse ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( AcquireImageColormap ( image , image -> colors ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; image -> colormap [ 0 ] . red = QuantumRange ; image -> colormap [ 0 ] . green = QuantumRange ; image -> colormap [ 0 ] . blue = QuantumRange ; image -> colormap [ 1 ] . red = ( Quantum ) 0 ; image -> colormap [ 1 ] . green = ( Quantum ) 0 ; image -> colormap [ 1 ] . blue = ( Quantum ) 0 ; if ( image_info -> ping != MagickFalse ) { ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; } hex_digits [ ( int ) '0' ] = 0 ; hex_digits [ ( int ) '1' ] = 1 ; hex_digits [ ( int ) '2' ] = 2 ; hex_digits [ ( int ) '3' ] = 3 ; hex_digits [ ( int ) '4' ] = 4 ; hex_digits [ ( int ) '5' ] = 5 ; hex_digits [ ( int ) '6' ] = 6 ; hex_digits [ ( int ) '7' ] = 7 ; hex_digits [ ( int ) '8' ] = 8 ; hex_digits [ ( int ) '9' ] = 9 ; hex_digits [ ( int ) 'A' ] = 10 ; hex_digits [ ( int ) 'B' ] = 11 ; hex_digits [ ( int ) 'C' ] = 12 ; hex_digits [ ( int ) 'D' ] = 13 ; hex_digits [ ( int ) 'E' ] = 14 ; hex_digits [ ( int ) 'F' ] = 15 ; hex_digits [ ( int ) 'a' ] = 10 ; hex_digits [ ( int ) 'b' ] = 11 ; hex_digits [ ( int ) 'c' ] = 12 ; hex_digits [ ( int ) 'd' ] = 13 ; hex_digits [ ( int ) 'e' ] = 14 ; hex_digits [ ( int ) 'f' ] = 15 ; hex_digits [ ( int ) 'x' ] = 0 ; hex_digits [ ( int ) '' ] = ( - 1 ) ; hex_digits [ ( int ) ',' ] = ( - 1 ) ; hex_digits [ ( int ) '}' ] = ( - 1 ) ; hex_digits [ ( int ) '\\n' ] = ( - 1 ) ; hex_digits [ ( int ) '\\t' ] = ( - 1 ) ; padding = 0 ; if ( ( ( image -> columns % 16 ) != 0 ) && ( ( image -> columns % 16 ) < 9 ) && ( version == 10 ) ) padding = 1 ; bytes_per_line = ( unsigned int ) ( image -> columns + 7 ) / 8 + padding ; length = ( unsigned int ) image -> rows ; data = ( unsigned char * ) AcquireQuantumMemory ( length , bytes_per_line * sizeof ( * data ) ) ; if ( data == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; p = data ; if ( version == 10 ) for ( i = 0 ; i < ( ssize_t ) ( bytes_per_line * image -> rows ) ; ( i += 2 ) ) { value = XBMInteger ( image , hex_digits ) ; * p ++ = ( unsigned char ) value ; if ( ( padding == 0 ) || ( ( ( i + 2 ) % bytes_per_line ) != 0 ) ) * p ++ = ( unsigned char ) ( value >> 8 ) ; } else for ( i = 0 ; i < ( ssize_t ) ( bytes_per_line * image -> rows ) ; i ++ ) { value = XBMInteger ( image , hex_digits ) ; * p ++ = ( unsigned char ) value ; } p = data ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; indexes = GetAuthenticIndexQueue ( image ) ; bit = 0 ; byte = 0 ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { if ( bit == 0 ) byte = ( size_t ) ( * p ++ ) ; SetPixelIndex ( indexes + x , ( byte & 0x01 ) != 0 ? 0x01 : 0x00 ) ; bit ++ ; byte >>= 1 ; if ( bit == 8 ) bit = 0 ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } data = ( unsigned char * ) RelinquishMagickMemory ( data ) ; ( void ) SyncImage ( image ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," Image * image ; int c length , padding , version , ) ) { c = XBMInteger ( , hex_digits ) ; if ( c < 0 ) break unsigned char ) c ; if ( char ) ( c >> 8 ) hex_digits ) ; if ( c < 0 ) break ; unsigned char ) c ; } if ( EOFBlob ( image ) != MagickFalse ) { data = ( unsigned char * ) RelinquishMagickMemory ( data ) ; ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; } p byte = ( unsigned int ) ( * ",ImageMagick@ImageMagick/b8c63b156bf26b52e710b1a0643c846a6cd01e56,CVE-2017-14175,https://github.com/ImageMagick/ImageMagick/commit/b8c63b156bf26b52e710b1a0643c846a6cd01e56,2017-09-07T06:29Z 1658,CWE-190,"CWE-190 static int jpc_enc_encodemainhdr ( jpc_enc_t * enc ) { jpc_siz_t * siz ; jpc_cod_t * cod ; jpc_qcd_t * qcd ; int i ; long startoff ; long mainhdrlen ; jpc_enc_cp_t * cp ; jpc_qcc_t * qcc ; jpc_enc_tccp_t * tccp ; uint_fast16_t cmptno ; jpc_tsfb_band_t bandinfos [ JPC_MAXBANDS ] ; jpc_fix_t mctsynweight ; jpc_enc_tcp_t * tcp ; jpc_tsfb_t * tsfb ; jpc_tsfb_band_t * bandinfo ; uint_fast16_t numbands ; uint_fast16_t bandno ; uint_fast16_t rlvlno ; uint_fast16_t analgain ; jpc_fix_t absstepsize ; char buf [ 1024 ] ; jpc_com_t * com ; cp = enc -> cp ; startoff = jas_stream_getrwcount ( enc -> out ) ; if ( ! ( enc -> mrk = jpc_ms_create ( JPC_MS_SOC ) ) ) { return - 1 ; } if ( jpc_putms ( enc -> out , enc -> cstate , enc -> mrk ) ) { jas_eprintf ( ""cannotwriteSOCmarker\\n"" ) ; return - 1 ; } jpc_ms_destroy ( enc -> mrk ) ; enc -> mrk = 0 ; if ( ! ( enc -> mrk = jpc_ms_create ( JPC_MS_SIZ ) ) ) { return - 1 ; } siz = & enc -> mrk -> parms . siz ; siz -> caps = 0 ; siz -> xoff = cp -> imgareatlx ; siz -> yoff = cp -> imgareatly ; siz -> width = cp -> refgrdwidth ; siz -> height = cp -> refgrdheight ; siz -> tilexoff = cp -> tilegrdoffx ; siz -> tileyoff = cp -> tilegrdoffy ; siz -> tilewidth = cp -> tilewidth ; siz -> tileheight = cp -> tileheight ; siz -> numcomps = cp -> numcmpts ; siz -> comps = jas_alloc2 ( siz -> numcomps , sizeof ( jpc_sizcomp_t ) ) ; assert ( siz -> comps ) ; for ( i = 0 ; i < JAS_CAST ( int , cp -> numcmpts ) ; ++ i ) { siz -> comps [ i ] . prec = cp -> ccps [ i ] . prec ; siz -> comps [ i ] . sgnd = cp -> ccps [ i ] . sgnd ; siz -> comps [ i ] . hsamp = cp -> ccps [ i ] . sampgrdstepx ; siz -> comps [ i ] . vsamp = cp -> ccps [ i ] . sampgrdstepy ; } if ( jpc_putms ( enc -> out , enc -> cstate , enc -> mrk ) ) { jas_eprintf ( ""cannotwriteSIZmarker\\n"" ) ; return - 1 ; } jpc_ms_destroy ( enc -> mrk ) ; enc -> mrk = 0 ; if ( ! ( enc -> mrk = jpc_ms_create ( JPC_MS_COM ) ) ) { return - 1 ; } sprintf ( buf , ""Creator:JasPerVersion%s"" , jas_getversion ( ) ) ; com = & enc -> mrk -> parms . com ; com -> len = JAS_CAST ( uint_fast16_t , strlen ( buf ) ) ; com -> regid = JPC_COM_LATIN ; if ( ! ( com -> data = JAS_CAST ( uchar * , jas_strdup ( buf ) ) ) ) { abort ( ) ; } if ( jpc_putms ( enc -> out , enc -> cstate , enc -> mrk ) ) { jas_eprintf ( ""cannotwriteCOMmarker\\n"" ) ; return - 1 ; } jpc_ms_destroy ( enc -> mrk ) ; enc -> mrk = 0 ; # if 0 if ( ! ( enc -> mrk = jpc_ms_create ( JPC_MS_CRG ) ) ) { return - 1 ; } crg = & enc -> mrk -> parms . crg ; crg -> comps = jas_alloc2 ( crg -> numcomps , sizeof ( jpc_crgcomp_t ) ) ; if ( jpc_putms ( enc -> out , enc -> cstate , enc -> mrk ) ) { jas_eprintf ( ""cannotwriteCRGmarker\\n"" ) ; return - 1 ; } jpc_ms_destroy ( enc -> mrk ) ; enc -> mrk = 0 ; # endif tcp = & cp -> tcp ; tccp = & cp -> tccp ; for ( cmptno = 0 ; cmptno < cp -> numcmpts ; ++ cmptno ) { tsfb = jpc_cod_gettsfb ( tccp -> qmfbid , tccp -> maxrlvls - 1 ) ; jpc_tsfb_getbands ( tsfb , 0 , 0 , 1 << tccp -> maxrlvls , 1 << tccp -> maxrlvls , bandinfos ) ; jpc_tsfb_destroy ( tsfb ) ; mctsynweight = jpc_mct_getsynweight ( tcp -> mctid , cmptno ) ; numbands = 3 * tccp -> maxrlvls - 2 ; for ( bandno = 0 , bandinfo = bandinfos ; bandno < numbands ; ++ bandno , ++ bandinfo ) { rlvlno = ( bandno ) ? ( ( bandno - 1 ) / 3 + 1 ) : 0 ; analgain = JPC_NOMINALGAIN ( tccp -> qmfbid , tccp -> maxrlvls , rlvlno , bandinfo -> orient ) ; if ( ! tcp -> intmode ) { absstepsize = jpc_fix_div ( jpc_inttofix ( 1 << ( analgain + 1 ) ) , bandinfo -> synenergywt ) ; } else { absstepsize = jpc_inttofix ( 1 ) ; } cp -> ccps [ cmptno ] . stepsizes [ bandno ] = jpc_abstorelstepsize ( absstepsize , cp -> ccps [ cmptno ] . prec + analgain ) ; } cp -> ccps [ cmptno ] . numstepsizes = numbands ; } if ( ! ( enc -> mrk = jpc_ms_create ( JPC_MS_COD ) ) ) { return - 1 ; } cod = & enc -> mrk -> parms . cod ; cod -> csty = cp -> tccp . csty | cp -> tcp . csty ; cod -> compparms . csty = cp -> tccp . csty | cp -> tcp . csty ; cod -> compparms . numdlvls = cp -> tccp . maxrlvls - 1 ; cod -> compparms . numrlvls = cp -> tccp . maxrlvls ; cod -> prg = cp -> tcp . prg ; cod -> numlyrs = cp -> tcp . numlyrs ; cod -> compparms . cblkwidthval = JPC_COX_CBLKSIZEEXPN ( cp -> tccp . cblkwidthexpn ) ; cod -> compparms . cblkheightval = JPC_COX_CBLKSIZEEXPN ( cp -> tccp . cblkheightexpn ) ; cod -> compparms . cblksty = cp -> tccp . cblksty ; cod -> compparms . qmfbid = cp -> tccp . qmfbid ; cod -> mctrans = ( cp -> tcp . mctid != JPC_MCT_NONE ) ; if ( tccp -> csty & JPC_COX_PRT ) { for ( rlvlno = 0 ; rlvlno < tccp -> maxrlvls ; ++ rlvlno ) { cod -> compparms . rlvls [ rlvlno ] . parwidthval = tccp -> prcwidthexpns [ rlvlno ] ; cod -> compparms . rlvls [ rlvlno ] . parheightval = tccp -> prcheightexpns [ rlvlno ] ; } } if ( jpc_putms ( enc -> out , enc -> cstate , enc -> mrk ) ) { jas_eprintf ( ""cannotwriteCODmarker\\n"" ) ; return - 1 ; } jpc_ms_destroy ( enc -> mrk ) ; enc -> mrk = 0 ; if ( ! ( enc -> mrk = jpc_ms_create ( JPC_MS_QCD ) ) ) { return - 1 ; } qcd = & enc -> mrk -> parms . qcd ; qcd -> compparms . qntsty = ( tccp -> qmfbid == JPC_COX_INS ) ? JPC_QCX_SEQNT : JPC_QCX_NOQNT ; qcd -> compparms . numstepsizes = cp -> ccps [ 0 ] . numstepsizes ; qcd -> compparms . numguard = cp -> tccp . numgbits ; qcd -> compparms . stepsizes = cp -> ccps [ 0 ] . stepsizes ; if ( jpc_putms ( enc -> out , enc -> cstate , enc -> mrk ) ) { return - 1 ; } qcd -> compparms . stepsizes = 0 ; jpc_ms_destroy ( enc -> mrk ) ; enc -> mrk = 0 ; tccp = & cp -> tccp ; for ( cmptno = 1 ; cmptno < cp -> numcmpts ; ++ cmptno ) { if ( ! ( enc -> mrk = jpc_ms_create ( JPC_MS_QCC ) ) ) { return - 1 ; } qcc = & enc -> mrk -> parms . qcc ; qcc -> compno = cmptno ; qcc -> compparms . qntsty = ( tccp -> qmfbid == JPC_COX_INS ) ? JPC_QCX_SEQNT : JPC_QCX_NOQNT ; qcc -> compparms . numstepsizes = cp -> ccps [ cmptno ] . numstepsizes ; qcc -> compparms . numguard = cp -> tccp . numgbits ; qcc -> compparms . stepsizes = cp -> ccps [ cmptno ] . stepsizes ; if ( jpc_putms ( enc -> out , enc -> cstate , enc -> mrk ) ) { return - 1 ; } qcc -> compparms . stepsizes = 0 ; jpc_ms_destroy ( enc -> mrk ) ; enc -> mrk = 0 ; } # define MAINTLRLEN 2 mainhdrlen = jas_stream_getrwcount ( enc -> out ) - startoff ; enc -> len += mainhdrlen ; if ( enc -> cp -> totalsize != UINT_FAST32_MAX ) { uint_fast32_t overhead ; overhead = mainhdrlen + MAINTLRLEN ; enc -> mainbodysize = ( enc -> cp -> totalsize >= overhead ) ? ( enc -> cp -> totalsize - overhead ) : 0 ; } else { enc -> mainbodysize = UINT_FAST32_MAX ; } return 0 ; } "," = JAS_CAST ( jas_uchar * , jas_strdup ",mdadams@jasper/d42b2388f7f8e0332c846675133acea151fc557a,CVE-2016-9557,https://github.com/mdadams/jasper/commit/d42b2388f7f8e0332c846675133acea151fc557a,2017-03-23T18:59Z 1659,CWE-120,"CWE-120 void irc_mode_channel_update ( struct t_irc_server * server , struct t_irc_channel * channel , char set_flag , char chanmode , const char * argument ) { char * pos_args , * str_modes , * * argv , * pos , * ptr_arg ; char * new_modes , * new_args , str_mode [ 2 ] , * str_temp ; int argc , current_arg , chanmode_found , length ; if ( ! channel -> modes ) channel -> modes = strdup ( ""+"" ) ; if ( ! channel -> modes ) return ; argc = 0 ; argv = NULL ; pos_args = strchr ( channel -> modes , '' ) ; if ( pos_args ) { str_modes = weechat_strndup ( channel -> modes , pos_args - channel -> modes ) ; if ( ! str_modes ) return ; pos_args ++ ; while ( pos_args [ 0 ] == '' ) pos_args ++ ; argv = weechat_string_split ( pos_args , """" , NULL , WEECHAT_STRING_SPLIT_STRIP_LEFT | WEECHAT_STRING_SPLIT_STRIP_RIGHT | WEECHAT_STRING_SPLIT_COLLAPSE_SEPS , 0 , & argc ) ; } else { str_modes = strdup ( channel -> modes ) ; if ( ! str_modes ) return ; } new_modes = malloc ( strlen ( channel -> modes ) + 1 + 1 ) ; new_args = malloc ( ( ( pos_args ) ? strlen ( pos_args ) : 0 ) + ( ( argument ) ? 1 + strlen ( argument ) : 0 ) + 1 ) ; if ( new_modes && new_args ) { new_modes [ 0 ] = '\\0' ; new_args [ 0 ] = '\\0' ; current_arg = 0 ; chanmode_found = 0 ; pos = str_modes ; while ( pos && pos [ 0 ] ) { if ( ( pos [ 0 ] == '+' ) || ( pos [ 0 ] == '-' ) ) { str_mode [ 0 ] = pos [ 0 ] ; str_mode [ 1 ] = '\\0' ; strcat ( new_modes , str_mode ) ; } else { ptr_arg = NULL ; switch ( irc_mode_get_chanmode_type ( server , pos [ 0 ] ) ) { case 'A' : case 'B' : case 'C' : ptr_arg = ( current_arg < argc ) ? argv [ current_arg ] : NULL ; break ; case 'D' : break ; } if ( ptr_arg ) current_arg ++ ; if ( pos [ 0 ] == chanmode ) { chanmode_found = 1 ; if ( set_flag == '+' ) { str_mode [ 0 ] = pos [ 0 ] ; str_mode [ 1 ] = '\\0' ; strcat ( new_modes , str_mode ) ; if ( argument ) { if ( new_args [ 0 ] ) strcat ( new_args , """" ) ; strcat ( new_args , argument ) ; } } } else { str_mode [ 0 ] = pos [ 0 ] ; str_mode [ 1 ] = '\\0' ; strcat ( new_modes , str_mode ) ; if ( ptr_arg ) { if ( new_args [ 0 ] ) strcat ( new_args , """" ) ; strcat ( new_args , ptr_arg ) ; } } } pos ++ ; } if ( ! chanmode_found ) { if ( set_flag == '+' ) { if ( argument ) { str_mode [ 0 ] = chanmode ; str_mode [ 1 ] = '\\0' ; strcat ( new_modes , str_mode ) ; if ( new_args [ 0 ] ) strcat ( new_args , """" ) ; strcat ( new_args , argument ) ; } else { pos = new_modes ; while ( pos [ 0 ] == '+' ) pos ++ ; memmove ( pos + 1 , pos , strlen ( pos ) + 1 ) ; pos [ 0 ] = chanmode ; } } } if ( new_args [ 0 ] ) { length = strlen ( new_modes ) + 1 + strlen ( new_args ) + 1 ; str_temp = malloc ( length ) ; if ( str_temp ) { snprintf ( str_temp , length , ""%s%s"" , new_modes , new_args ) ; if ( channel -> modes ) free ( channel -> modes ) ; channel -> modes = str_temp ; } } else { if ( channel -> modes ) free ( channel -> modes ) ; channel -> modes = strdup ( new_modes ) ; } } if ( new_modes ) free ( new_modes ) ; if ( new_args ) free ( new_args ) ; if ( str_modes ) free ( str_modes ) ; if ( argv ) weechat_string_free_split ( argv ) ; } "," chanmode ) { if ( ! chanmode_found ) { } } } } ",weechat@weechat/6f4f147d8e86adf9ad34a8ffd7e7f1f23a7e74da,CVE-2020-8955,https://github.com/weechat/weechat/commit/6f4f147d8e86adf9ad34a8ffd7e7f1f23a7e74da,2020-02-12T22:15Z 1660,CWE-119,"CWE-119 static int decode_uniform ( vp9_reader * r ) { const int l = 8 ; const int m = ( 1 << l ) - 191 ; const int v = vp9_read_literal ( r , l - 1 ) ; return v < m ? v : ( v << 1 ) - m + vp9_read_bit ( r ) ; } "," int decode_uniform ( vpx_reader * r ) int v = vpx_read_literal ( r , - m + vpx_read_bit ( r ) ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1661,CWE-284,"CWE-284 static int http_connect ( http_subtransport * t ) { int error ; if ( t -> connected && http_should_keep_alive ( & t -> parser ) && t -> parse_finished ) return 0 ; if ( t -> io ) { git_stream_close ( t -> io ) ; git_stream_free ( t -> io ) ; t -> io = NULL ; t -> connected = 0 ; } if ( t -> connection_data . use_ssl ) { error = git_tls_stream_new ( & t -> io , t -> connection_data . host , t -> connection_data . port ) ; } else { # ifdef GIT_CURL error = git_curl_stream_new ( & t -> io , t -> connection_data . host , t -> connection_data . port ) ; # else error = git_socket_stream_new ( & t -> io , t -> connection_data . host , t -> connection_data . port ) ; # endif } if ( error < 0 ) return error ; GITERR_CHECK_VERSION ( t -> io , GIT_STREAM_VERSION , ""git_stream"" ) ; apply_proxy_config ( t ) ; error = git_stream_connect ( t -> io ) ; if ( ( ! error || error == GIT_ECERTIFICATE ) && t -> owner -> certificate_check_cb != NULL && git_stream_is_encrypted ( t -> io ) ) { git_cert * cert ; int is_valid ; if ( ( error = git_stream_certificate ( & cert , t -> io ) ) < 0 ) return error ; giterr_clear ( ) ; is_valid = error != GIT_ECERTIFICATE ; error = t -> owner -> certificate_check_cb ( cert , is_valid , t -> connection_data . host , t -> owner -> message_cb_payload ) ; if ( error < 0 ) { if ( ! giterr_last ( ) ) giterr_set ( GITERR_NET , ""usercancelledcertificatecheck"" ) ; return error ; } } if ( error < 0 ) return error ; t -> connected = 1 ; return 0 ; } "," ; int is_valid = ( error == GIT_OK ) giterr_clear ( ) ; error = ",libgit2@libgit2/9a64e62f0f20c9cf9b2e1609f037060eb2d8eb22,CVE-2016-10130,https://github.com/libgit2/libgit2/commit/9a64e62f0f20c9cf9b2e1609f037060eb2d8eb22,2017-03-24T15:59Z 1662,CWE-119,"CWE-119 void vp9_cost_tokens_skip ( int * costs , const vp9_prob * probs , vp9_tree tree ) { assert ( tree [ 0 ] <= 0 && tree [ 1 ] > 0 ) ; costs [ - tree [ 0 ] ] = vp9_cost_bit ( probs [ 0 ] , 0 ) ; cost ( costs , tree , probs , 2 , 0 ) ; } "," costs , const vpx_prob * probs , * probs , vpx_tree tree ) { ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1663,CWE-119,"CWE-119 static REFERENCE_MODE read_block_reference_mode ( VP9_COMMON * cm , const MACROBLOCKD * xd , vp9_reader * r ) { if ( cm -> reference_mode == REFERENCE_MODE_SELECT ) { const int ctx = vp9_get_reference_mode_context ( cm , xd ) ; const REFERENCE_MODE mode = ( REFERENCE_MODE ) vp9_read ( r , cm -> fc . comp_inter_prob [ ctx ] ) ; if ( ! cm -> frame_parallel_decoding_mode ) ++ cm -> counts . comp_inter [ ctx ] [ mode ] ; return mode ; } else { return cm -> reference_mode ; } } "," * xd , vpx_reader * r ) ( REFERENCE_MODE ) vpx_read ( r , cm -> fc -> comp_inter_prob [ ctx ] ) ; FRAME_COUNTS * counts = xd -> counts ; if ( counts ) ++ counts -> comp_inter [ ctx ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1664,CWE-787,"CWE-787 static int _server_handle_vCont ( libgdbr_t * g , int ( * cmd_cb ) ( void * , const char * , char * , size_t ) , void * core_ptr ) { char * action = NULL ; if ( send_ack ( g ) < 0 ) { return - 1 ; } g -> data [ g -> data_len ] = '\\0' ; if ( g -> data [ 5 ] == '?' ) { return send_msg ( g , ""vCont;c;s"" ) ; } if ( ! ( action = strtok ( g -> data , "";"" ) ) ) { return send_msg ( g , ""E01"" ) ; } while ( action = strtok ( NULL , "";"" ) ) { eprintf ( ""action:%s\\n"" , action ) ; switch ( action [ 0 ] ) { case 's' : if ( cmd_cb ( core_ptr , ""ds"" , NULL , 0 ) < 0 ) { send_msg ( g , ""E01"" ) ; return - 1 ; } return send_msg ( g , ""OK"" ) ; case 'c' : if ( cmd_cb ( core_ptr , ""dc"" , NULL , 0 ) < 0 ) { send_msg ( g , ""E01"" ) ; return - 1 ; } return send_msg ( g , ""OK"" ) ; default : return send_msg ( g , ""E01"" ) ; } } } "," ; } } return - 1 ; ",radare@radare2/796dd28aaa6b9fa76d99c42c4d5ff8b257cc2191,CVE-2017-9949,https://github.com/radare/radare2/commit/796dd28aaa6b9fa76d99c42c4d5ff8b257cc2191,2017-06-26T20:29Z 1665,CWE-119,"CWE-119 static struct stream_state * new_stream ( struct VpxEncoderConfig * global , struct stream_state * prev ) { struct stream_state * stream ; stream = calloc ( 1 , sizeof ( * stream ) ) ; if ( ! stream ) fatal ( ""Failedtoallocatenewstream."" ) ; if ( prev ) { memcpy ( stream , prev , sizeof ( * stream ) ) ; stream -> index ++ ; prev -> next = stream ; } else { vpx_codec_err_t res ; res = vpx_codec_enc_config_default ( global -> codec -> interface ( ) , & stream -> config . cfg , global -> usage ) ; if ( res ) fatal ( ""Failedtogetconfig:%s\\n"" , vpx_codec_err_to_string ( res ) ) ; stream -> config . cfg . g_timebase . den = 1000 ; stream -> config . cfg . g_w = 0 ; stream -> config . cfg . g_h = 0 ; stream -> config . stereo_fmt = STEREO_FORMAT_MONO ; stream -> config . write_webm = 1 ; # if CONFIG_WEBM_IO stream -> ebml . last_pts_ms = - 1 ; # endif stream -> ebml . debug = global -> debug ; if ( global -> deadline == VPX_DL_REALTIME ) stream -> config . cfg . g_lag_in_frames = 0 ; } stream -> config . out_fn = NULL ; stream -> next = NULL ; return stream ; } "," ; if ( stream == NULL ) { fatal ( ""Failedtoallocatenewstream."" ""Failedtoallocatenewstream."" ) ; } -> codec -> codec_interface ( ) , -> config . write_webm = 1 ; # if CONFIG_WEBM_IO stream -> config . ; stream -> ebml . last_pts_ns = - 1 = - 1 ; stream -> ebml . writer = NULL ; stream -> ebml . segment = NULL ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1666,CWE-125,"CWE-125 static void icmp6_opt_print ( netdissect_options * ndo , const u_char * bp , int resid ) { const struct nd_opt_hdr * op ; const struct nd_opt_prefix_info * opp ; const struct nd_opt_mtu * opm ; const struct nd_opt_rdnss * oprd ; const struct nd_opt_dnssl * opds ; const struct nd_opt_advinterval * opa ; const struct nd_opt_homeagent_info * oph ; const struct nd_opt_route_info * opri ; const u_char * cp , * ep , * domp ; struct in6_addr in6 ; const struct in6_addr * in6p ; size_t l ; u_int i ; # define ECHECK ( var ) if ( ( const u_char * ) & ( var ) > ep - sizeof ( var ) ) return cp = bp ; ep = ndo -> ndo_snapend ; while ( cp < ep ) { op = ( const struct nd_opt_hdr * ) cp ; ECHECK ( op -> nd_opt_len ) ; if ( resid <= 0 ) return ; if ( op -> nd_opt_len == 0 ) goto trunc ; if ( cp + ( op -> nd_opt_len << 3 ) > ep ) goto trunc ; ND_PRINT ( ( ndo , ""\\n\\t%soption(%u),length%u(%u):"" , tok2str ( icmp6_opt_values , ""unknown"" , op -> nd_opt_type ) , op -> nd_opt_type , op -> nd_opt_len << 3 , op -> nd_opt_len ) ) ; switch ( op -> nd_opt_type ) { case ND_OPT_SOURCE_LINKADDR : l = ( op -> nd_opt_len << 3 ) - 2 ; print_lladdr ( ndo , cp + 2 , l ) ; break ; case ND_OPT_TARGET_LINKADDR : l = ( op -> nd_opt_len << 3 ) - 2 ; print_lladdr ( ndo , cp + 2 , l ) ; break ; case ND_OPT_PREFIX_INFORMATION : opp = ( const struct nd_opt_prefix_info * ) op ; ND_TCHECK ( opp -> nd_opt_pi_prefix ) ; ND_PRINT ( ( ndo , ""%s/%u%s,Flags[%s],validtime%s"" , ip6addr_string ( ndo , & opp -> nd_opt_pi_prefix ) , opp -> nd_opt_pi_prefix_len , ( op -> nd_opt_len != 4 ) ? ""badlen"" : """" , bittok2str ( icmp6_opt_pi_flag_values , ""none"" , opp -> nd_opt_pi_flags_reserved ) , get_lifetime ( EXTRACT_32BITS ( & opp -> nd_opt_pi_valid_time ) ) ) ) ; ND_PRINT ( ( ndo , "",pref.time%s"" , get_lifetime ( EXTRACT_32BITS ( & opp -> nd_opt_pi_preferred_time ) ) ) ) ; break ; case ND_OPT_REDIRECTED_HEADER : print_unknown_data ( ndo , bp , ""\\n\\t"" , op -> nd_opt_len << 3 ) ; break ; case ND_OPT_MTU : opm = ( const struct nd_opt_mtu * ) op ; ND_TCHECK ( opm -> nd_opt_mtu_mtu ) ; ND_PRINT ( ( ndo , ""%u%s"" , EXTRACT_32BITS ( & opm -> nd_opt_mtu_mtu ) , ( op -> nd_opt_len != 1 ) ? ""badoptionlength"" : """" ) ) ; break ; case ND_OPT_RDNSS : oprd = ( const struct nd_opt_rdnss * ) op ; l = ( op -> nd_opt_len - 1 ) / 2 ; ND_PRINT ( ( ndo , ""lifetime%us,"" , EXTRACT_32BITS ( & oprd -> nd_opt_rdnss_lifetime ) ) ) ; for ( i = 0 ; i < l ; i ++ ) { ND_TCHECK ( oprd -> nd_opt_rdnss_addr [ i ] ) ; ND_PRINT ( ( ndo , ""addr:%s"" , ip6addr_string ( ndo , & oprd -> nd_opt_rdnss_addr [ i ] ) ) ) ; } break ; case ND_OPT_DNSSL : opds = ( const struct nd_opt_dnssl * ) op ; ND_PRINT ( ( ndo , ""lifetime%us,domain(s):"" , EXTRACT_32BITS ( & opds -> nd_opt_dnssl_lifetime ) ) ) ; domp = cp + 8 ; while ( domp < cp + ( op -> nd_opt_len << 3 ) && * domp != '\\0' ) { ND_PRINT ( ( ndo , """" ) ) ; if ( ( domp = ns_nprint ( ndo , domp , bp ) ) == NULL ) goto trunc ; } break ; case ND_OPT_ADVINTERVAL : opa = ( const struct nd_opt_advinterval * ) op ; ND_TCHECK ( opa -> nd_opt_adv_interval ) ; ND_PRINT ( ( ndo , ""%ums"" , EXTRACT_32BITS ( & opa -> nd_opt_adv_interval ) ) ) ; break ; case ND_OPT_HOMEAGENT_INFO : oph = ( const struct nd_opt_homeagent_info * ) op ; ND_TCHECK ( oph -> nd_opt_hai_lifetime ) ; ND_PRINT ( ( ndo , ""preference%u,lifetime%u"" , EXTRACT_16BITS ( & oph -> nd_opt_hai_preference ) , EXTRACT_16BITS ( & oph -> nd_opt_hai_lifetime ) ) ) ; break ; case ND_OPT_ROUTE_INFO : opri = ( const struct nd_opt_route_info * ) op ; ND_TCHECK ( opri -> nd_opt_rti_lifetime ) ; memset ( & in6 , 0 , sizeof ( in6 ) ) ; in6p = ( const struct in6_addr * ) ( opri + 1 ) ; switch ( op -> nd_opt_len ) { case 1 : break ; case 2 : ND_TCHECK2 ( * in6p , 8 ) ; memcpy ( & in6 , opri + 1 , 8 ) ; break ; case 3 : ND_TCHECK ( * in6p ) ; memcpy ( & in6 , opri + 1 , sizeof ( in6 ) ) ; break ; default : goto trunc ; } ND_PRINT ( ( ndo , ""%s/%u"" , ip6addr_string ( ndo , & in6 ) , opri -> nd_opt_rti_prefixlen ) ) ; ND_PRINT ( ( ndo , "",pref=%s"" , get_rtpref ( opri -> nd_opt_rti_flags ) ) ) ; ND_PRINT ( ( ndo , "",lifetime=%s"" , get_lifetime ( EXTRACT_32BITS ( & opri -> nd_opt_rti_lifetime ) ) ) ) ; break ; default : if ( ndo -> ndo_vflag <= 1 ) { print_unknown_data ( ndo , cp + 2 , ""\\n\\t"" , ( op -> nd_opt_len << 3 ) - 2 ) ; return ; } break ; } if ( ndo -> ndo_vflag > 1 ) print_unknown_data ( ndo , cp + 2 , ""\\n\\t"" , ( op -> nd_opt_len << 3 ) - 2 ) ; cp += op -> nd_opt_len << 3 ; resid -= op -> nd_opt_len << 3 ; } return ; trunc : ND_PRINT ( ( ndo , ""[ndpopt]"" ) ) ; return ; # undef ECHECK } "," ( ndo , ""%s"" , icmp6_tstr ) ) ; ",the-tcpdump-group@tcpdump/d7505276842e85bfd067fa21cdb32b8a2dc3c5e4,CVE-2018-14882,https://github.com/the-tcpdump-group/tcpdump/commit/d7505276842e85bfd067fa21cdb32b8a2dc3c5e4,2019-10-03T16:15Z 1667,CWE-674,"CWE-674 int yr_re_ast_create ( RE_AST * * re_ast ) { * re_ast = ( RE_AST * ) yr_malloc ( sizeof ( RE_AST ) ) ; if ( * re_ast == NULL ) return ERROR_INSUFFICIENT_MEMORY ; ( * re_ast ) -> flags = 0 ; ( * re_ast ) -> root_node = NULL ; return ERROR_SUCCESS ; } "," re_ast ) -> levels = 0 ; ( * re_ast ) -> ",VirusTotal@yara/925bcf3c3b0a28b5b78e25d9efda5c0bf27ae699,CVE-2017-9304,https://github.com/VirusTotal/yara/commit/925bcf3c3b0a28b5b78e25d9efda5c0bf27ae699,2017-05-31T04:29Z 1668,CWE-000,"CWE-000 static unsigned int unix_dgram_poll ( struct file * file , struct socket * sock , poll_table * wait ) { struct sock * sk = sock -> sk , * other ; unsigned int mask , writable ; sock_poll_wait ( file , sk_sleep ( sk ) , wait ) ; mask = 0 ; if ( sk -> sk_err || ! skb_queue_empty ( & sk -> sk_error_queue ) ) mask |= POLLERR | ( sock_flag ( sk , SOCK_SELECT_ERR_QUEUE ) ? POLLPRI : 0 ) ; if ( sk -> sk_shutdown & RCV_SHUTDOWN ) mask |= POLLRDHUP | POLLIN | POLLRDNORM ; if ( sk -> sk_shutdown == SHUTDOWN_MASK ) mask |= POLLHUP ; if ( ! skb_queue_empty ( & sk -> sk_receive_queue ) ) mask |= POLLIN | POLLRDNORM ; if ( sk -> sk_type == SOCK_SEQPACKET ) { if ( sk -> sk_state == TCP_CLOSE ) mask |= POLLHUP ; if ( sk -> sk_state == TCP_SYN_SENT ) return mask ; } if ( ! ( poll_requested_events ( wait ) & ( POLLWRBAND | POLLWRNORM | POLLOUT ) ) ) return mask ; writable = unix_writable ( sk ) ; other = unix_peer_get ( sk ) ; if ( other ) { if ( unix_peer ( other ) != sk ) { sock_poll_wait ( file , & unix_sk ( other ) -> peer_wait , wait ) ; if ( unix_recvq_full ( other ) ) writable = 0 ; } sock_put ( other ) ; } if ( writable ) mask |= POLLOUT | POLLWRNORM | POLLWRBAND ; else set_bit ( SOCK_ASYNC_NOSPACE , & sk -> sk_socket -> flags ) ; return mask ; } "," sk ) ; if ( writable ) { unix_state_lock ( sk ) ; other = unix_peer ( sk ) ; if ( other && unix_peer ( other ) != ) != sk && unix_recvq_full ( other ( other ) && unix_dgram_peer_wake_me ( sk , other ) = 0 ; unix_state_unlock ( sk ) ; } ",torvalds@linux/7d267278a9ece963d77eefec61630223fce08c6c,CVE-2013-7446,https://github.com/torvalds/linux/commit/7d267278a9ece963d77eefec61630223fce08c6c,2015-12-28T11:59Z 1669,CWE-20,"CWE-20 static int db_dict_iter_lookup_key_values ( struct db_dict_value_iter * iter ) { struct db_dict_iter_key * key ; string_t * path ; const char * error ; int ret ; array_sort ( & iter -> keys , db_dict_iter_key_cmp ) ; path = t_str_new ( 128 ) ; str_append ( path , DICT_PATH_SHARED ) ; array_foreach_modifiable ( & iter -> keys , key ) { if ( ! key -> used ) continue ; str_truncate ( path , strlen ( DICT_PATH_SHARED ) ) ; ret = var_expand ( path , key -> key -> key , iter -> var_expand_table , & error ) ; if ( ret <= 0 ) { auth_request_log_error ( iter -> auth_request , AUTH_SUBSYS_DB , ""Failedtoexpandkey%s:%s"" , key -> key -> key , error ) ; return - 1 ; } ret = dict_lookup ( iter -> conn -> dict , iter -> pool , str_c ( path ) , & key -> value , & error ) ; if ( ret > 0 ) { auth_request_log_debug ( iter -> auth_request , AUTH_SUBSYS_DB , ""Lookup:%s=%s"" , str_c ( path ) , key -> value ) ; } else if ( ret < 0 ) { auth_request_log_error ( iter -> auth_request , AUTH_SUBSYS_DB , ""Failedtolookupkey%s:%s"" , str_c ( path ) , error ) ; return - 1 ; } else if ( key -> key -> default_value != NULL ) { auth_request_log_debug ( iter -> auth_request , AUTH_SUBSYS_DB , ""Lookup:%snotfound,usingdefaultvalue%s"" , str_c ( path ) , key -> key -> default_value ) ; key -> value = key -> key -> default_value ; } else { return 0 ; } } return 1 ; } "," ) ) ; str_append ( path , key -> key -> key ) ; ret = dict_lookup ( iter -> conn -> dict , iter -> pool , str_c ( path ) , & key -> value , & error if ( ret > 0 ) { 0 ) { auth_request_log_debug ( iter -> auth_request , AUTH_SUBSYS_DB , ""Lookup:%s=%s"" , str_c ( path ) , key -> value ) ; } else if ( ret < 0 ) { , AUTH_SUBSYS_DB , ""Failedtolookupkey%s:%s"" , str_c ( path ) , error ) 1 ; } else if ( ",dovecot@core/000030feb7a30f193197f1aab8a7b04a26b42735,CVE-2017-2669,https://github.com/dovecot/core/commit/000030feb7a30f193197f1aab8a7b04a26b42735,2018-06-21T13:29Z 1670,CWE-189,"CWE-189 static u64 __skb_get_nlattr_nest ( u64 ctx , u64 A , u64 X , u64 r4 , u64 r5 ) { struct sk_buff * skb = ( struct sk_buff * ) ( long ) ctx ; struct nlattr * nla ; if ( skb_is_nonlinear ( skb ) ) return 0 ; if ( A > skb -> len - sizeof ( struct nlattr ) ) return 0 ; nla = ( struct nlattr * ) & skb -> data [ A ] ; if ( nla -> nla_len > A - skb -> len ) return 0 ; nla = nla_find_nested ( nla , X ) ; if ( nla ) return ( void * ) nla - ( void * ) skb -> data ; return 0 ; } "," ; if ( skb -> len < sizeof ( struct nlattr ) ) return 0 ; if ( -> nla_len > skb -> len skb -> len - A ",torvalds@linux/05ab8f2647e4221cbdb3856dd7d32bd5407316b3,CVE-2014-3145,https://github.com/torvalds/linux/commit/05ab8f2647e4221cbdb3856dd7d32bd5407316b3,2014-05-11T21:55Z 1671,CWE-189,"CWE-189 static Image * ReadICONImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { IconFile icon_file ; IconInfo icon_info ; Image * image ; MagickBooleanType status ; register ssize_t i , x ; register Quantum * q ; register unsigned char * p ; size_t bit , byte , bytes_per_line , one , scanline_pad ; ssize_t count , offset , y ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info , exception ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } icon_file . reserved = ( short ) ReadBlobLSBShort ( image ) ; icon_file . resource_type = ( short ) ReadBlobLSBShort ( image ) ; icon_file . count = ( short ) ReadBlobLSBShort ( image ) ; if ( ( icon_file . reserved != 0 ) || ( ( icon_file . resource_type != 1 ) && ( icon_file . resource_type != 2 ) ) || ( icon_file . count > MaxIcons ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; for ( i = 0 ; i < icon_file . count ; i ++ ) { icon_file . directory [ i ] . width = ( unsigned char ) ReadBlobByte ( image ) ; icon_file . directory [ i ] . height = ( unsigned char ) ReadBlobByte ( image ) ; icon_file . directory [ i ] . colors = ( unsigned char ) ReadBlobByte ( image ) ; icon_file . directory [ i ] . reserved = ( unsigned char ) ReadBlobByte ( image ) ; icon_file . directory [ i ] . planes = ( unsigned short ) ReadBlobLSBShort ( image ) ; icon_file . directory [ i ] . bits_per_pixel = ( unsigned short ) ReadBlobLSBShort ( image ) ; icon_file . directory [ i ] . size = ReadBlobLSBLong ( image ) ; icon_file . directory [ i ] . offset = ReadBlobLSBLong ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } } one = 1 ; for ( i = 0 ; i < icon_file . count ; i ++ ) { offset = ( ssize_t ) SeekBlob ( image , ( MagickOffsetType ) icon_file . directory [ i ] . offset , SEEK_SET ) ; if ( offset < 0 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; icon_info . size = ReadBlobLSBLong ( image ) ; icon_info . width = ( unsigned char ) ( ( int ) ReadBlobLSBLong ( image ) ) ; icon_info . height = ( unsigned char ) ( ( int ) ReadBlobLSBLong ( image ) / 2 ) ; icon_info . planes = ReadBlobLSBShort ( image ) ; icon_info . bits_per_pixel = ReadBlobLSBShort ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } if ( ( ( icon_info . planes == 18505 ) && ( icon_info . bits_per_pixel == 21060 ) ) || ( icon_info . size == 0x474e5089 ) ) { Image * icon_image ; ImageInfo * read_info ; size_t length ; unsigned char * png ; length = icon_file . directory [ i ] . size ; png = ( unsigned char * ) AcquireQuantumMemory ( length + 16 , sizeof ( * png ) ) ; if ( png == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; ( void ) CopyMagickMemory ( png , ""\\211PNG\\r\\n\\032\\n\\000\\000\\000\\015"" , 12 ) ; png [ 12 ] = ( unsigned char ) icon_info . planes ; png [ 13 ] = ( unsigned char ) ( icon_info . planes >> 8 ) ; png [ 14 ] = ( unsigned char ) icon_info . bits_per_pixel ; png [ 15 ] = ( unsigned char ) ( icon_info . bits_per_pixel >> 8 ) ; count = ReadBlob ( image , length - 16 , png + 16 ) ; icon_image = ( Image * ) NULL ; if ( count > 0 ) { read_info = CloneImageInfo ( image_info ) ; ( void ) CopyMagickString ( read_info -> magick , ""PNG"" , MagickPathExtent ) ; icon_image = BlobToImage ( read_info , png , length + 16 , exception ) ; read_info = DestroyImageInfo ( read_info ) ; } png = ( unsigned char * ) RelinquishMagickMemory ( png ) ; if ( icon_image == ( Image * ) NULL ) { if ( count != ( ssize_t ) ( length - 16 ) ) ThrowReaderException ( CorruptImageError , ""InsufficientImageDataInFile"" ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } DestroyBlob ( icon_image ) ; icon_image -> blob = ReferenceBlob ( image -> blob ) ; ReplaceImageInList ( & image , icon_image ) ; } else { if ( icon_info . bits_per_pixel > 32 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; icon_info . compression = ReadBlobLSBLong ( image ) ; icon_info . image_size = ReadBlobLSBLong ( image ) ; icon_info . x_pixels = ReadBlobLSBLong ( image ) ; icon_info . y_pixels = ReadBlobLSBLong ( image ) ; icon_info . number_colors = ReadBlobLSBLong ( image ) ; icon_info . colors_important = ReadBlobLSBLong ( image ) ; image -> alpha_trait = BlendPixelTrait ; image -> columns = ( size_t ) icon_file . directory [ i ] . width ; if ( ( ssize_t ) image -> columns > icon_info . width ) image -> columns = ( size_t ) icon_info . width ; if ( image -> columns == 0 ) image -> columns = 256 ; image -> rows = ( size_t ) icon_file . directory [ i ] . height ; if ( ( ssize_t ) image -> rows > icon_info . height ) image -> rows = ( size_t ) icon_info . height ; if ( image -> rows == 0 ) image -> rows = 256 ; image -> depth = icon_info . bits_per_pixel ; if ( image -> debug != MagickFalse ) { ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""scene=%.20g"" , ( double ) i ) ; ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""size=%.20g"" , ( double ) icon_info . size ) ; ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""width=%.20g"" , ( double ) icon_file . directory [ i ] . width ) ; ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""height=%.20g"" , ( double ) icon_file . directory [ i ] . height ) ; ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""colors=%.20g"" , ( double ) icon_info . number_colors ) ; ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""planes=%.20g"" , ( double ) icon_info . planes ) ; ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""bpp=%.20g"" , ( double ) icon_info . bits_per_pixel ) ; } if ( ( icon_info . number_colors != 0 ) || ( icon_info . bits_per_pixel <= 16U ) ) { image -> storage_class = PseudoClass ; image -> colors = icon_info . number_colors ; if ( image -> colors == 0 ) image -> colors = one << icon_info . bits_per_pixel ; } if ( image -> storage_class == PseudoClass ) { register ssize_t i ; unsigned char * icon_colormap ; if ( AcquireImageColormap ( image , image -> colors , exception ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; icon_colormap = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) image -> colors , 4UL * sizeof ( * icon_colormap ) ) ; if ( icon_colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; count = ReadBlob ( image , ( size_t ) ( 4 * image -> colors ) , icon_colormap ) ; if ( count != ( ssize_t ) ( 4 * image -> colors ) ) ThrowReaderException ( CorruptImageError , ""InsufficientImageDataInFile"" ) ; p = icon_colormap ; for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { image -> colormap [ i ] . blue = ( Quantum ) ScaleCharToQuantum ( * p ++ ) ; image -> colormap [ i ] . green = ( Quantum ) ScaleCharToQuantum ( * p ++ ) ; image -> colormap [ i ] . red = ( Quantum ) ScaleCharToQuantum ( * p ++ ) ; p ++ ; } icon_colormap = ( unsigned char * ) RelinquishMagickMemory ( icon_colormap ) ; } if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; bytes_per_line = ( ( ( image -> columns * icon_info . bits_per_pixel ) + 31 ) & ~ 31 ) >> 3 ; ( void ) bytes_per_line ; scanline_pad = ( ( ( ( image -> columns * icon_info . bits_per_pixel ) + 31 ) & ~ 31 ) - ( image -> columns * icon_info . bits_per_pixel ) ) >> 3 ; switch ( icon_info . bits_per_pixel ) { case 1 : { for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) ( image -> columns - 7 ) ; x += 8 ) { byte = ( size_t ) ReadBlobByte ( image ) ; for ( bit = 0 ; bit < 8 ; bit ++ ) { SetPixelIndex ( image , ( ( byte & ( 0x80 >> bit ) ) != 0 ? 0x01 : 0x00 ) , q ) ; q += GetPixelChannels ( image ) ; } } if ( ( image -> columns % 8 ) != 0 ) { byte = ( size_t ) ReadBlobByte ( image ) ; for ( bit = 0 ; bit < ( image -> columns % 8 ) ; bit ++ ) { SetPixelIndex ( image , ( ( byte & ( 0x80 >> bit ) ) != 0 ? 0x01 : 0x00 ) , q ) ; q += GetPixelChannels ( image ) ; } } for ( x = 0 ; x < ( ssize_t ) scanline_pad ; x ++ ) ( void ) ReadBlobByte ( image ) ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , image -> rows - y - 1 , image -> rows ) ; if ( status == MagickFalse ) break ; } } break ; } case 4 : { for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ( ssize_t ) image -> columns - 1 ) ; x += 2 ) { byte = ( size_t ) ReadBlobByte ( image ) ; SetPixelIndex ( image , ( ( byte >> 4 ) & 0xf ) , q ) ; q += GetPixelChannels ( image ) ; SetPixelIndex ( image , ( ( byte ) & 0xf ) , q ) ; q += GetPixelChannels ( image ) ; } if ( ( image -> columns % 2 ) != 0 ) { byte = ( size_t ) ReadBlobByte ( image ) ; SetPixelIndex ( image , ( ( byte >> 4 ) & 0xf ) , q ) ; q += GetPixelChannels ( image ) ; } for ( x = 0 ; x < ( ssize_t ) scanline_pad ; x ++ ) ( void ) ReadBlobByte ( image ) ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , image -> rows - y - 1 , image -> rows ) ; if ( status == MagickFalse ) break ; } } break ; } case 8 : { for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { byte = ( size_t ) ReadBlobByte ( image ) ; SetPixelIndex ( image , byte , q ) ; q += GetPixelChannels ( image ) ; } for ( x = 0 ; x < ( ssize_t ) scanline_pad ; x ++ ) ( void ) ReadBlobByte ( image ) ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , image -> rows - y - 1 , image -> rows ) ; if ( status == MagickFalse ) break ; } } break ; } case 16 : { for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { byte = ( size_t ) ReadBlobByte ( image ) ; byte |= ( size_t ) ( ReadBlobByte ( image ) << 8 ) ; SetPixelIndex ( image , byte , q ) ; q += GetPixelChannels ( image ) ; } for ( x = 0 ; x < ( ssize_t ) scanline_pad ; x ++ ) ( void ) ReadBlobByte ( image ) ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , image -> rows - y - 1 , image -> rows ) ; if ( status == MagickFalse ) break ; } } break ; } case 24 : case 32 : { for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelBlue ( image , ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) , q ) ; SetPixelGreen ( image , ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) , q ) ; SetPixelRed ( image , ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) , q ) ; if ( icon_info . bits_per_pixel == 32 ) SetPixelAlpha ( image , ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) , q ) ; q += GetPixelChannels ( image ) ; } if ( icon_info . bits_per_pixel == 24 ) for ( x = 0 ; x < ( ssize_t ) scanline_pad ; x ++ ) ( void ) ReadBlobByte ( image ) ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , image -> rows - y - 1 , image -> rows ) ; if ( status == MagickFalse ) break ; } } break ; } default : ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; } if ( image_info -> ping == MagickFalse ) ( void ) SyncImage ( image , exception ) ; if ( icon_info . bits_per_pixel != 32 ) { image -> storage_class = DirectClass ; for ( y = ( ssize_t ) image -> rows - 1 ; y >= 0 ; y -- ) { q = GetAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; for ( x = 0 ; x < ( ( ssize_t ) image -> columns - 7 ) ; x += 8 ) { byte = ( size_t ) ReadBlobByte ( image ) ; for ( bit = 0 ; bit < 8 ; bit ++ ) { SetPixelAlpha ( image , ( ( ( byte & ( 0x80 >> bit ) ) != 0 ) ? TransparentAlpha : OpaqueAlpha ) , q ) ; q += GetPixelChannels ( image ) ; } } if ( ( image -> columns % 8 ) != 0 ) { byte = ( size_t ) ReadBlobByte ( image ) ; for ( bit = 0 ; bit < ( image -> columns % 8 ) ; bit ++ ) { SetPixelAlpha ( image , ( ( ( byte & ( 0x80 >> bit ) ) != 0 ) ? TransparentAlpha : OpaqueAlpha ) , q ) ; q += GetPixelChannels ( image ) ; } } if ( ( image -> columns % 32 ) != 0 ) for ( x = 0 ; x < ( ssize_t ) ( ( 32 - ( image -> columns % 32 ) ) / 8 ) ; x ++ ) ( void ) ReadBlobByte ( image ) ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } } if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; if ( i < ( ssize_t ) ( icon_file . count - 1 ) ) { AcquireNextImage ( image_info , image , exception ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," ] . size ; if ( ~ length < 16 ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ",ImageMagick@ImageMagick/0f6fc2d5bf8f500820c3dbcf0d23ee14f2d9f734,CVE-2015-8896,https://github.com/ImageMagick/ImageMagick/commit/0f6fc2d5bf8f500820c3dbcf0d23ee14f2d9f734,2017-03-15T19:59Z 1672,CWE-20,"CWE-20 void receive_carbon ( void * * state ) { prof_input ( ""/carbonson"" ) ; prof_connect ( ) ; assert_true ( stbbr_received ( ""id=\'*\'type=\'set\'>xmlns=\'urn:xmpp:carbons:2\'/>"" ) ) ; stbbr_send ( ""to=\'stabber@localhost\'from=\'buddy1@localhost/mobile\'>"" ""10"" ""Onmymobile"" """" ) ; assert_true ( prof_output_exact ( ""Buddy1(mobile)isonline,\\""Onmymobile\\"""" ) ) ; prof_input ( ""/msgBuddy1"" ) ; assert_true ( prof_output_exact ( ""unencrypted"" ) ) ; stbbr_send ( ""type=\'chat\'to=\'stabber@localhost/profanity\'from=\'buddy1@localhost\'>"" ""xmlns=\'urn:xmpp:carbons:2\'>"" ""xmlns=\'urn:xmpp:forward:0\'>"" ""id=\'prof_msg_7\'xmlns=\'jabber:client\'type=\'chat\'lang=\'en\'to=\'stabber@localhost/profanity\'from=\'buddy1@localhost/mobile\'>"" ""testcarbonfromrecipient"" """" """" """" """" ) ; assert_true ( prof_output_regex ( ""Buddy1/mobile:.+testcarbonfromrecipient"" ) ) ; } "," ; stbbr_send ( ""type=\'chat\'to=\'stabber@localhost/profanity\'from=\'stabber@localhost\'>"" ""xmlns=\'urn:xmpp:carbons:2\'>"" ""xmlns=\'urn:xmpp:forward:0\'>"" ""id=\'prof_msg_7\'xmlns=\'jabber:client\'type=\'chat\'lang=\'en\'to=\'stabber@localhost/profanity\'from=\'buddy1@localhost/mobile\'>"" ",boothj5@profanity/8e75437a7e43d4c55e861691f74892e666e29b0b,CVE-2017-5592,https://github.com/boothj5/profanity/commit/8e75437a7e43d4c55e861691f74892e666e29b0b,2017-02-09T20:59Z 1673,CWE-415,"CWE-415 static int cac_get_serial_nr_from_CUID ( sc_card_t * card , sc_serial_number_t * serial ) { cac_private_data_t * priv = CAC_DATA ( card ) ; SC_FUNC_CALLED ( card -> ctx , SC_LOG_DEBUG_NORMAL ) ; if ( card -> serialnr . len ) { * serial = card -> serialnr ; SC_FUNC_RETURN ( card -> ctx , SC_LOG_DEBUG_NORMAL , SC_SUCCESS ) ; } if ( priv -> cac_id_len ) { serial -> len = MIN ( priv -> cac_id_len , SC_MAX_SERIALNR ) ; memcpy ( serial -> value , priv -> cac_id , priv -> cac_id_len ) ; SC_FUNC_RETURN ( card -> ctx , SC_LOG_DEBUG_NORMAL , SC_SUCCESS ) ; } SC_FUNC_RETURN ( card -> ctx , SC_LOG_DEBUG_NORMAL , SC_ERROR_FILE_NOT_FOUND ) ; } "," -> cac_id , serial -> len ) ; SC_FUNC_RETURN ",OpenSC@OpenSC/360e95d45ac4123255a4c796db96337f332160ad,CVE-2018-16425,https://github.com/OpenSC/OpenSC/commit/360e95d45ac4123255a4c796db96337f332160ad,2018-09-04T00:29Z 1674,CWE-125,"CWE-125 static struct tok_state * tok_new ( void ) { struct tok_state * tok = ( struct tok_state * ) PyMem_MALLOC ( sizeof ( struct tok_state ) ) ; if ( tok == NULL ) return NULL ; tok -> buf = tok -> cur = tok -> end = tok -> inp = tok -> start = NULL ; tok -> done = E_OK ; tok -> fp = NULL ; tok -> input = NULL ; tok -> tabsize = TABSIZE ; tok -> indent = 0 ; tok -> indstack [ 0 ] = 0 ; tok -> atbol = 1 ; tok -> pendin = 0 ; tok -> prompt = tok -> nextprompt = NULL ; tok -> lineno = 0 ; tok -> level = 0 ; tok -> altwarning = 1 ; tok -> alterror = 1 ; tok -> alttabsize = 1 ; tok -> altindstack [ 0 ] = 0 ; tok -> decoding_state = STATE_INIT ; tok -> decoding_erred = 0 ; tok -> read_coding_spec = 0 ; tok -> enc = NULL ; tok -> encoding = NULL ; tok -> cont_line = 0 ; # ifndef PGEN tok -> filename = NULL ; tok -> decoding_readline = NULL ; tok -> decoding_buffer = NULL ; # endif tok -> async_def = 0 ; tok -> async_def_indent = 0 ; tok -> async_def_nl = 0 ; return tok ; } "," level = 0 ; tok -> = 0 ; tok -> async_always = 0 ; ",python@typed_ast/156afcb26c198e162504a57caddfe0acd9ed7dce,CVE-2019-19275,https://github.com/python/typed_ast/commit/156afcb26c198e162504a57caddfe0acd9ed7dce,2019-11-26T15:15Z 1675,CWE-476,"CWE-476 void AV1_RewriteESDescriptorEx ( GF_MPEGVisualSampleEntryBox * av1 , GF_MediaBox * mdia ) { GF_BitRateBox * btrt = gf_isom_sample_entry_get_bitrate ( ( GF_SampleEntryBox * ) av1 , GF_FALSE ) ; if ( av1 -> emul_esd ) gf_odf_desc_del ( ( GF_Descriptor * ) av1 -> emul_esd ) ; av1 -> emul_esd = gf_odf_desc_esd_new ( 2 ) ; av1 -> emul_esd -> decoderConfig -> streamType = GF_STREAM_VISUAL ; av1 -> emul_esd -> decoderConfig -> objectTypeIndication = GF_CODECID_AV1 ; if ( btrt ) { av1 -> emul_esd -> decoderConfig -> bufferSizeDB = btrt -> bufferSizeDB ; av1 -> emul_esd -> decoderConfig -> avgBitrate = btrt -> avgBitrate ; av1 -> emul_esd -> decoderConfig -> maxBitrate = btrt -> maxBitrate ; } if ( av1 -> av1_config ) { GF_AV1Config * av1_cfg = AV1_DuplicateConfig ( av1 -> av1_config -> config ) ; if ( av1_cfg ) { gf_odf_av1_cfg_write ( av1_cfg , & av1 -> emul_esd -> decoderConfig -> decoderSpecificInfo -> data , & av1 -> emul_esd -> decoderConfig -> decoderSpecificInfo -> dataLength ) ; gf_odf_av1_cfg_del ( av1_cfg ) ; } } } "," av1 -> av1_config && av1 -> av1_config -> config ",gpac@gpac/b2eab95e07cb5819375a50358d4806a8813b6e50,CVE-2021-31262,https://github.com/gpac/gpac/commit/b2eab95e07cb5819375a50358d4806a8813b6e50,2021-04-19T19:15Z 1676,CWE-400,"CWE-400 GF_Err dinf_Read ( GF_Box * s , GF_BitStream * bs ) { GF_Err e = gf_isom_box_array_read ( s , bs , dinf_AddBox ) ; if ( e ) { return e ; } if ( ! ( ( GF_DataInformationBox * ) s ) -> dref ) { GF_LOG ( GF_LOG_ERROR , GF_LOG_CONTAINER , ( ""[isofile]Missingdrefboxindinf\\n"" ) ) ; ( ( GF_DataInformationBox * ) s ) -> dref = ( GF_DataReferenceBox * ) gf_isom_box_new ( GF_ISOM_BOX_TYPE_DREF ) ; } return GF_OK ; } "," dref ) { GF_Box * dref ; ( ""[isofile]Missingdrefboxindinf\\n"" ) ) ; dref = gf_isom_box_new ( GF_ISOM_BOX_TYPE_DREF GF_DataReferenceBox * ) dref ; gf_isom_box_add_for_dump_mode ( s , dref ) ; } ",gpac@gpac/d2371b4b204f0a3c0af51ad4e9b491144dd1225c,CVE-2018-21017,https://github.com/gpac/gpac/commit/d2371b4b204f0a3c0af51ad4e9b491144dd1225c,2019-09-16T13:15Z 1677,CWE-415,"CWE-415 static int sc_pkcs15emu_esteid_init ( sc_pkcs15_card_t * p15card ) { sc_card_t * card = p15card -> card ; unsigned char buff [ 128 ] ; int r , i ; size_t field_length = 0 , modulus_length = 0 ; sc_path_t tmppath ; set_string ( & p15card -> tokeninfo -> label , ""ID-kaart"" ) ; set_string ( & p15card -> tokeninfo -> manufacturer_id , ""ASSertifitseerimiskeskus"" ) ; sc_format_path ( ""3f00eeee5044"" , & tmppath ) ; r = sc_select_file ( card , & tmppath , NULL ) ; SC_TEST_RET ( card -> ctx , SC_LOG_DEBUG_NORMAL , r , ""selectesteidPDfailed"" ) ; r = sc_read_record ( card , SC_ESTEID_PD_DOCUMENT_NR , buff , sizeof ( buff ) , SC_RECORD_BY_REC_NR ) ; SC_TEST_RET ( card -> ctx , SC_LOG_DEBUG_NORMAL , r , ""readdocumentnumberfailed"" ) ; buff [ r ] = '\\0' ; set_string ( & p15card -> tokeninfo -> serial_number , ( const char * ) buff ) ; p15card -> tokeninfo -> flags = SC_PKCS15_TOKEN_PRN_GENERATION | SC_PKCS15_TOKEN_EID_COMPLIANT | SC_PKCS15_TOKEN_READONLY ; for ( i = 0 ; i < 2 ; i ++ ) { static const char * esteid_cert_names [ 2 ] = { ""Isikutuvastus"" , ""Allkirjastamine"" } ; static char const * esteid_cert_paths [ 2 ] = { ""3f00eeeeaace"" , ""3f00eeeeddce"" } ; static int esteid_cert_ids [ 2 ] = { 1 , 2 } ; struct sc_pkcs15_cert_info cert_info ; struct sc_pkcs15_object cert_obj ; memset ( & cert_info , 0 , sizeof ( cert_info ) ) ; memset ( & cert_obj , 0 , sizeof ( cert_obj ) ) ; cert_info . id . value [ 0 ] = esteid_cert_ids [ i ] ; cert_info . id . len = 1 ; sc_format_path ( esteid_cert_paths [ i ] , & cert_info . path ) ; strlcpy ( cert_obj . label , esteid_cert_names [ i ] , sizeof ( cert_obj . label ) ) ; r = sc_pkcs15emu_add_x509_cert ( p15card , & cert_obj , & cert_info ) ; if ( r < 0 ) return SC_ERROR_INTERNAL ; if ( i == 0 ) { sc_pkcs15_cert_t * cert = NULL ; r = sc_pkcs15_read_certificate ( p15card , & cert_info , & cert ) ; if ( r < 0 ) return SC_ERROR_INTERNAL ; if ( cert -> key -> algorithm == SC_ALGORITHM_EC ) field_length = cert -> key -> u . ec . params . field_length ; else modulus_length = cert -> key -> u . rsa . modulus . len * 8 ; if ( r == SC_SUCCESS ) { static const struct sc_object_id cn_oid = { { 2 , 5 , 4 , 3 , - 1 } } ; u8 * cn_name = NULL ; size_t cn_len = 0 ; sc_pkcs15_get_name_from_dn ( card -> ctx , cert -> subject , cert -> subject_len , & cn_oid , & cn_name , & cn_len ) ; if ( cn_len > 0 ) { char * token_name = malloc ( cn_len + 1 ) ; if ( token_name ) { memcpy ( token_name , cn_name , cn_len ) ; token_name [ cn_len ] = '\\0' ; set_string ( & p15card -> tokeninfo -> label , ( const char * ) token_name ) ; free ( token_name ) ; } } free ( cn_name ) ; sc_pkcs15_free_certificate ( cert ) ; } } } sc_format_path ( ""3f000016"" , & tmppath ) ; r = sc_select_file ( card , & tmppath , NULL ) ; if ( r < 0 ) return SC_ERROR_INTERNAL ; for ( i = 0 ; i < 3 ; i ++ ) { unsigned char tries_left ; static const char * esteid_pin_names [ 3 ] = { ""PIN1"" , ""PIN2"" , ""PUK"" } ; static const int esteid_pin_min [ 3 ] = { 4 , 5 , 8 } ; static const int esteid_pin_ref [ 3 ] = { 1 , 2 , 0 } ; static const int esteid_pin_authid [ 3 ] = { 1 , 2 , 3 } ; static const int esteid_pin_flags [ 3 ] = { 0 , 0 , SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN } ; struct sc_pkcs15_auth_info pin_info ; struct sc_pkcs15_object pin_obj ; memset ( & pin_info , 0 , sizeof ( pin_info ) ) ; memset ( & pin_obj , 0 , sizeof ( pin_obj ) ) ; r = sc_read_record ( card , i + 1 , buff , sizeof ( buff ) , SC_RECORD_BY_REC_NR ) ; if ( r < 0 ) return SC_ERROR_INTERNAL ; tries_left = buff [ 5 ] ; pin_info . auth_id . len = 1 ; pin_info . auth_id . value [ 0 ] = esteid_pin_authid [ i ] ; pin_info . auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN ; pin_info . attrs . pin . reference = esteid_pin_ref [ i ] ; pin_info . attrs . pin . flags = esteid_pin_flags [ i ] ; pin_info . attrs . pin . type = SC_PKCS15_PIN_TYPE_ASCII_NUMERIC ; pin_info . attrs . pin . min_length = esteid_pin_min [ i ] ; pin_info . attrs . pin . stored_length = 12 ; pin_info . attrs . pin . max_length = 12 ; pin_info . attrs . pin . pad_char = '\\0' ; pin_info . tries_left = ( int ) tries_left ; pin_info . max_tries = 3 ; strlcpy ( pin_obj . label , esteid_pin_names [ i ] , sizeof ( pin_obj . label ) ) ; pin_obj . flags = esteid_pin_flags [ i ] ; if ( i < 2 ) { pin_obj . auth_id . len = 1 ; pin_obj . auth_id . value [ 0 ] = 3 ; } r = sc_pkcs15emu_add_pin_obj ( p15card , & pin_obj , & pin_info ) ; if ( r < 0 ) return SC_ERROR_INTERNAL ; } for ( i = 0 ; i < 2 ; i ++ ) { static int prkey_pin [ 2 ] = { 1 , 2 } ; static const char * prkey_name [ 2 ] = { ""Isikutuvastus"" , ""Allkirjastamine"" } ; struct sc_pkcs15_prkey_info prkey_info ; struct sc_pkcs15_object prkey_obj ; memset ( & prkey_info , 0 , sizeof ( prkey_info ) ) ; memset ( & prkey_obj , 0 , sizeof ( prkey_obj ) ) ; prkey_info . id . len = 1 ; prkey_info . id . value [ 0 ] = prkey_pin [ i ] ; prkey_info . native = 1 ; prkey_info . key_reference = i + 1 ; prkey_info . field_length = field_length ; prkey_info . modulus_length = modulus_length ; if ( i == 1 ) prkey_info . usage = SC_PKCS15_PRKEY_USAGE_NONREPUDIATION ; else if ( field_length > 0 ) prkey_info . usage = SC_PKCS15_PRKEY_USAGE_SIGN | SC_PKCS15_PRKEY_USAGE_DERIVE ; else prkey_info . usage = SC_PKCS15_PRKEY_USAGE_SIGN | SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_DECRYPT ; strlcpy ( prkey_obj . label , prkey_name [ i ] , sizeof ( prkey_obj . label ) ) ; prkey_obj . auth_id . len = 1 ; prkey_obj . auth_id . value [ 0 ] = prkey_pin [ i ] ; prkey_obj . user_consent = 0 ; prkey_obj . flags = SC_PKCS15_CO_FLAG_PRIVATE ; if ( field_length > 0 ) r = sc_pkcs15emu_add_ec_prkey ( p15card , & prkey_obj , & prkey_info ) ; else r = sc_pkcs15emu_add_rsa_prkey ( p15card , & prkey_obj , & prkey_info ) ; if ( r < 0 ) return SC_ERROR_INTERNAL ; } return SC_SUCCESS ; } "," ; buff [ MIN ( ( size_t ) r , ( sizeof buff ) - 1 ) ] = '\\0' ",OpenSC@OpenSC/360e95d45ac4123255a4c796db96337f332160ad,CVE-2018-16425,https://github.com/OpenSC/OpenSC/commit/360e95d45ac4123255a4c796db96337f332160ad,2018-09-04T00:29Z 1678,CWE-119,"CWE-119 u32 h264bsdInitDpb ( dpbStorage_t * dpb , u32 picSizeInMbs , u32 dpbSize , u32 maxRefFrames , u32 maxFrameNum , u32 noReordering ) { u32 i ; ASSERT ( picSizeInMbs ) ; ASSERT ( maxRefFrames <= MAX_NUM_REF_PICS ) ; ASSERT ( maxRefFrames <= dpbSize ) ; ASSERT ( maxFrameNum ) ; ASSERT ( dpbSize ) ; dpb -> maxLongTermFrameIdx = NO_LONG_TERM_FRAME_INDICES ; dpb -> maxRefFrames = MAX ( maxRefFrames , 1 ) ; if ( noReordering ) dpb -> dpbSize = dpb -> maxRefFrames ; else dpb -> dpbSize = dpbSize ; dpb -> maxFrameNum = maxFrameNum ; dpb -> noReordering = noReordering ; dpb -> fullness = 0 ; dpb -> numRefFrames = 0 ; dpb -> prevRefFrameNum = 0 ; ALLOCATE ( dpb -> buffer , MAX_NUM_REF_IDX_L0_ACTIVE + 1 , dpbPicture_t ) ; if ( dpb -> buffer == NULL ) return ( MEMORY_ALLOCATION_ERROR ) ; H264SwDecMemset ( dpb -> buffer , 0 , ( MAX_NUM_REF_IDX_L0_ACTIVE + 1 ) * sizeof ( dpbPicture_t ) ) ; for ( i = 0 ; i < dpb -> dpbSize + 1 ; i ++ ) { ALLOCATE ( dpb -> buffer [ i ] . pAllocatedData , ( picSizeInMbs * 384 + 32 + 15 ) , u8 ) ; if ( dpb -> buffer [ i ] . pAllocatedData == NULL ) return ( MEMORY_ALLOCATION_ERROR ) ; dpb -> buffer [ i ] . data = ALIGN ( dpb -> buffer [ i ] . pAllocatedData , 16 ) ; } ALLOCATE ( dpb -> list , MAX_NUM_REF_IDX_L0_ACTIVE + 1 , dpbPicture_t * ) ; ALLOCATE ( dpb -> outBuf , dpb -> dpbSize + 1 , dpbOutPicture_t ) ; if ( dpb -> list == NULL || dpb -> outBuf == NULL ) return ( MEMORY_ALLOCATION_ERROR ) ; H264SwDecMemset ( dpb -> list , 0 , ( ( MAX_NUM_REF_IDX_L0_ACTIVE + 1 ) * sizeof ( dpbPicture_t * ) ) ) ; dpb -> numOut = dpb -> outIndex = 0 ; return ( HANTRO_OK ) ; } "," dpbSize ) ; if ( picSizeInMbs > ( UINT32_MAX - 32 - 15 ) / 384 ) { ALOGE ( ""b/28533562"" ) ; android_errorWriteLog ( 0x534e4554 , ""28533562"" ) ; return ( MEMORY_ALLOCATION_ERROR ) ; } ",frameworks@av/590d1729883f700ab905cdc9ad850f3ddd7e1f56,CVE-2016-3819,https://android.googlesource.com/platform/frameworks/av/+/590d1729883f700ab905cdc9ad850f3ddd7e1f56,2016-08-05T20:59Z 1679,CWE-552,"CWE-552 static int _hostsock_getpeername ( oe_fd_t * sock_ , struct oe_sockaddr * addr , oe_socklen_t * addrlen ) { int ret = - 1 ; sock_t * sock = _cast_sock ( sock_ ) ; oe_socklen_t addrlen_in = 0 ; oe_errno = 0 ; if ( ! sock ) OE_RAISE_ERRNO ( OE_EINVAL ) ; if ( addrlen ) addrlen_in = * addrlen ; if ( oe_syscall_getpeername_ocall ( & ret , sock -> host_fd , ( struct oe_sockaddr * ) addr , addrlen_in , addrlen ) != OE_OK ) { OE_RAISE_ERRNO ( OE_EINVAL ) ; } done : return ret ; } "," = 0 ; oe_socklen_t addrlen_out = 0 ; ( ! sock || ! addr || ! addrlen OE_EINVAL ) ; addrlen_in = * = * addrlen ; if ( addrlen_in < 0 ) OE_RAISE_ERRNO ( OE_EINVAL ) , addrlen_in , & addrlen_out ) != OE_OK ) ; } if ( addrlen_out > sizeof ( struct oe_sockaddr_storage ) ) OE_RAISE_ERRNO ( OE_EINVAL ) ; * addrlen = addrlen_out ; ",openenclave@openenclave/bcac8e7acb514429fee9e0b5d0c7a0308fd4d76b,CVE-2020-15224,https://github.com/openenclave/openenclave/commit/bcac8e7acb514429fee9e0b5d0c7a0308fd4d76b,2020-10-14T19:15Z 1680,CWE-119,"CWE-119 static cJSON * cJSON_New_Item ( void ) { cJSON * node = ( cJSON * ) cJSON_malloc ( sizeof ( cJSON ) ) ; if ( node ) memset ( node , 0 , sizeof ( cJSON ) ) ; return node ; } "," ",esnet@iperf/91f2fa59e8ed80dfbf400add0164ee0e508e412a,CVE-2016-4303,https://github.com/esnet/iperf/commit/91f2fa59e8ed80dfbf400add0164ee0e508e412a,2016-09-26T14:59Z 1681,CWE-125,"CWE-125 BOOL nego_read_request ( rdpNego * nego , wStream * s ) { BYTE li ; BYTE type ; UINT16 length ; if ( ! tpkt_read_header ( s , & length ) ) return FALSE ; if ( ! tpdu_read_connection_request ( s , & li , length ) ) return FALSE ; if ( li != Stream_GetRemainingLength ( s ) + 6 ) { WLog_ERR ( TAG , ""IncorrectTPDUlengthindicator."" ) ; return FALSE ; } if ( ! nego_read_request_token_or_cookie ( nego , s ) ) { WLog_ERR ( TAG , ""Failedtoparseroutingtokenorcookie."" ) ; return FALSE ; } if ( Stream_GetRemainingLength ( s ) >= 8 ) { Stream_Read_UINT8 ( s , type ) ; if ( type != TYPE_RDP_NEG_REQ ) { WLog_ERR ( TAG , ""Incorrectnegotiationrequesttype%"" PRIu8 """" , type ) ; return FALSE ; } nego_process_negotiation_request ( nego , s ) ; } return tpkt_ensure_stream_consumed ( s , length ) ; } "," FALSE ; } if ( ! , s ) ) return FALSE ",FreeRDP@FreeRDP/6b485b146a1b9d6ce72dfd7b5f36456c166e7a16,CVE-2020-11089,https://github.com/FreeRDP/FreeRDP/commit/6b485b146a1b9d6ce72dfd7b5f36456c166e7a16,2020-05-29T20:15Z 1682,CWE-264,"CWE-264 static int l2tp_ip6_sendmsg ( struct sock * sk , struct msghdr * msg , size_t len ) { struct ipv6_txoptions opt_space ; DECLARE_SOCKADDR ( struct sockaddr_l2tpip6 * , lsa , msg -> msg_name ) ; struct in6_addr * daddr , * final_p , final ; struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct ipv6_txoptions * opt = NULL ; struct ip6_flowlabel * flowlabel = NULL ; struct dst_entry * dst = NULL ; struct flowi6 fl6 ; int addr_len = msg -> msg_namelen ; int hlimit = - 1 ; int tclass = - 1 ; int dontfrag = - 1 ; int transhdrlen = 4 ; int ulen = len + transhdrlen ; int err ; if ( len > INT_MAX ) return - EMSGSIZE ; if ( msg -> msg_flags & MSG_OOB ) return - EOPNOTSUPP ; memset ( & fl6 , 0 , sizeof ( fl6 ) ) ; fl6 . flowi6_mark = sk -> sk_mark ; if ( lsa ) { if ( addr_len < SIN6_LEN_RFC2133 ) return - EINVAL ; if ( lsa -> l2tp_family && lsa -> l2tp_family != AF_INET6 ) return - EAFNOSUPPORT ; daddr = & lsa -> l2tp_addr ; if ( np -> sndflow ) { fl6 . flowlabel = lsa -> l2tp_flowinfo & IPV6_FLOWINFO_MASK ; if ( fl6 . flowlabel & IPV6_FLOWLABEL_MASK ) { flowlabel = fl6_sock_lookup ( sk , fl6 . flowlabel ) ; if ( flowlabel == NULL ) return - EINVAL ; } } if ( sk -> sk_state == TCP_ESTABLISHED && ipv6_addr_equal ( daddr , & sk -> sk_v6_daddr ) ) daddr = & sk -> sk_v6_daddr ; if ( addr_len >= sizeof ( struct sockaddr_in6 ) && lsa -> l2tp_scope_id && ipv6_addr_type ( daddr ) & IPV6_ADDR_LINKLOCAL ) fl6 . flowi6_oif = lsa -> l2tp_scope_id ; } else { if ( sk -> sk_state != TCP_ESTABLISHED ) return - EDESTADDRREQ ; daddr = & sk -> sk_v6_daddr ; fl6 . flowlabel = np -> flow_label ; } if ( fl6 . flowi6_oif == 0 ) fl6 . flowi6_oif = sk -> sk_bound_dev_if ; if ( msg -> msg_controllen ) { opt = & opt_space ; memset ( opt , 0 , sizeof ( struct ipv6_txoptions ) ) ; opt -> tot_len = sizeof ( struct ipv6_txoptions ) ; err = ip6_datagram_send_ctl ( sock_net ( sk ) , sk , msg , & fl6 , opt , & hlimit , & tclass , & dontfrag ) ; if ( err < 0 ) { fl6_sock_release ( flowlabel ) ; return err ; } if ( ( fl6 . flowlabel & IPV6_FLOWLABEL_MASK ) && ! flowlabel ) { flowlabel = fl6_sock_lookup ( sk , fl6 . flowlabel ) ; if ( flowlabel == NULL ) return - EINVAL ; } if ( ! ( opt -> opt_nflen | opt -> opt_flen ) ) opt = NULL ; } if ( opt == NULL ) opt = np -> opt ; if ( flowlabel ) opt = fl6_merge_options ( & opt_space , flowlabel , opt ) ; opt = ipv6_fixup_options ( & opt_space , opt ) ; fl6 . flowi6_proto = sk -> sk_protocol ; if ( ! ipv6_addr_any ( daddr ) ) fl6 . daddr = * daddr ; else fl6 . daddr . s6_addr [ 15 ] = 0x1 ; if ( ipv6_addr_any ( & fl6 . saddr ) && ! ipv6_addr_any ( & np -> saddr ) ) fl6 . saddr = np -> saddr ; final_p = fl6_update_dst ( & fl6 , opt , & final ) ; if ( ! fl6 . flowi6_oif && ipv6_addr_is_multicast ( & fl6 . daddr ) ) fl6 . flowi6_oif = np -> mcast_oif ; else if ( ! fl6 . flowi6_oif ) fl6 . flowi6_oif = np -> ucast_oif ; security_sk_classify_flow ( sk , flowi6_to_flowi ( & fl6 ) ) ; dst = ip6_dst_lookup_flow ( sk , & fl6 , final_p ) ; if ( IS_ERR ( dst ) ) { err = PTR_ERR ( dst ) ; goto out ; } if ( hlimit < 0 ) hlimit = ip6_sk_dst_hoplimit ( np , & fl6 , dst ) ; if ( tclass < 0 ) tclass = np -> tclass ; if ( dontfrag < 0 ) dontfrag = np -> dontfrag ; if ( msg -> msg_flags & MSG_CONFIRM ) goto do_confirm ; back_from_confirm : lock_sock ( sk ) ; err = ip6_append_data ( sk , ip_generic_getfrag , msg , ulen , transhdrlen , hlimit , tclass , opt , & fl6 , ( struct rt6_info * ) dst , msg -> msg_flags , dontfrag ) ; if ( err ) ip6_flush_pending_frames ( sk ) ; else if ( ! ( msg -> msg_flags & MSG_MORE ) ) err = l2tp_ip6_push_pending_frames ( sk ) ; release_sock ( sk ) ; done : dst_release ( dst ) ; out : fl6_sock_release ( flowlabel ) ; return err < 0 ? err : len ; do_confirm : dst_confirm ( dst ) ; if ( ! ( msg -> msg_flags & MSG_PROBE ) || len ) goto back_from_confirm ; err = 0 ; goto done ; } "," ( sk ) ; struct ipv6_txoptions * opt_to_free = NULL } if ( ! opt ) { opt = txopt_get ( np ) ; opt_to_free = opt ; } if ( flowlabel fl6_sock_release ( flowlabel ) ; txopt_put ( opt_to_free ",torvalds@linux/45f6fad84cc305103b28d73482b344d7f5b76f39,CVE-2016-3841,https://github.com/torvalds/linux/commit/45f6fad84cc305103b28d73482b344d7f5b76f39,2016-08-06T20:59Z 1683,CWE-119,"CWE-119 int cli_scanpe ( cli_ctx * ctx ) { uint16_t e_magic ; uint16_t nsections ; uint32_t e_lfanew ; uint32_t ep , vep ; uint8_t polipos = 0 ; time_t timestamp ; struct pe_image_file_hdr file_hdr ; union { struct pe_image_optional_hdr64 opt64 ; struct pe_image_optional_hdr32 opt32 ; } pe_opt ; struct pe_image_section_hdr * section_hdr ; char sname [ 9 ] , epbuff [ 4096 ] , * tempfile ; uint32_t epsize ; ssize_t bytes , at ; unsigned int i , found , upx_success = 0 , min = 0 , max = 0 , err , overlays = 0 ; unsigned int ssize = 0 , dsize = 0 , dll = 0 , pe_plus = 0 , corrupted_cur ; int ( * upxfn ) ( const char * , uint32_t , char * , uint32_t * , uint32_t , uint32_t , uint32_t ) = NULL ; const char * src = NULL ; char * dest = NULL ; int ndesc , ret = CL_CLEAN , upack = 0 , native = 0 ; size_t fsize ; uint32_t valign , falign , hdr_size , j ; struct cli_exe_section * exe_sections ; char timestr [ 32 ] ; struct pe_image_data_dir * dirs ; struct cli_bc_ctx * bc_ctx ; fmap_t * map ; struct cli_pe_hook_data pedata ; # ifdef HAVE__INTERNAL__SHA_COLLECT int sha_collect = ctx -> sha_collect ; # endif const char * archtype = NULL , * subsystem = NULL ; uint32_t viruses_found = 0 ; # if HAVE_JSON int toval = 0 ; struct json_object * pe_json = NULL ; char jsonbuf [ 128 ] ; # endif if ( ! ctx ) { cli_errmsg ( ""cli_scanpe:ctx==NULL\\n"" ) ; return CL_ENULLARG ; } # if HAVE_JSON if ( cli_json_timeout_cycle_check ( ctx , & toval ) != CL_SUCCESS ) { return CL_ETIMEOUT ; } if ( ctx -> options & CL_SCAN_FILE_PROPERTIES ) { pe_json = get_pe_property ( ctx ) ; } # endif map = * ctx -> fmap ; if ( fmap_readn ( map , & e_magic , 0 , sizeof ( e_magic ) ) != sizeof ( e_magic ) ) { cli_dbgmsg ( ""Can\'treadDOSsignature\\n"" ) ; return CL_CLEAN ; } if ( EC16 ( e_magic ) != PE_IMAGE_DOS_SIGNATURE && EC16 ( e_magic ) != PE_IMAGE_DOS_SIGNATURE_OLD ) { cli_dbgmsg ( ""InvalidDOSsignature\\n"" ) ; return CL_CLEAN ; } if ( fmap_readn ( map , & e_lfanew , 58 + sizeof ( e_magic ) , sizeof ( e_lfanew ) ) != sizeof ( e_lfanew ) ) { cli_dbgmsg ( ""Can\'treadnewheaderaddress\\n"" ) ; if ( DETECT_BROKEN_PE ) { cli_append_virus ( ctx , ""Heuristics.Broken.Executable"" ) ; return CL_VIRUS ; } return CL_CLEAN ; } e_lfanew = EC32 ( e_lfanew ) ; cli_dbgmsg ( ""e_lfanew==%d\\n"" , e_lfanew ) ; if ( ! e_lfanew ) { cli_dbgmsg ( ""NotaPEfile\\n"" ) ; return CL_CLEAN ; } if ( fmap_readn ( map , & file_hdr , e_lfanew , sizeof ( struct pe_image_file_hdr ) ) != sizeof ( struct pe_image_file_hdr ) ) { cli_dbgmsg ( ""Can\'treadfileheader\\n"" ) ; return CL_CLEAN ; } if ( EC32 ( file_hdr . Magic ) != PE_IMAGE_NT_SIGNATURE ) { cli_dbgmsg ( ""InvalidPEsignature(probablyNEfile)\\n"" ) ; return CL_CLEAN ; } if ( EC16 ( file_hdr . Characteristics ) & 0x2000 ) { # if HAVE_JSON if ( ( pe_json ) ) cli_jsonstr ( pe_json , ""Type"" , ""DLL"" ) ; # endif cli_dbgmsg ( ""Filetype:DLL\\n"" ) ; dll = 1 ; } else if ( EC16 ( file_hdr . Characteristics ) & 0x01 ) { # if HAVE_JSON if ( ( pe_json ) ) cli_jsonstr ( pe_json , ""Type"" , ""EXE"" ) ; # endif cli_dbgmsg ( ""Filetype:Executable\\n"" ) ; } switch ( EC16 ( file_hdr . Machine ) ) { case 0x0 : archtype = ""Unknown"" ; break ; case 0x14c : archtype = ""80386"" ; break ; case 0x14d : archtype = ""80486"" ; break ; case 0x14e : archtype = ""80586"" ; break ; case 0x160 : archtype = ""R30000(big-endian)"" ; break ; case 0x162 : archtype = ""R3000"" ; break ; case 0x166 : archtype = ""R4000"" ; break ; case 0x168 : archtype = ""R10000"" ; break ; case 0x184 : archtype = ""DECAlphaAXP"" ; break ; case 0x284 : archtype = ""DECAlphaAXP64bit"" ; break ; case 0x1f0 : archtype = ""PowerPC"" ; break ; case 0x200 : archtype = ""IA64"" ; break ; case 0x268 : archtype = ""M68k"" ; break ; case 0x266 : archtype = ""MIPS16"" ; break ; case 0x366 : archtype = ""MIPS+FPU"" ; break ; case 0x466 : archtype = ""MIPS16+FPU"" ; break ; case 0x1a2 : archtype = ""HitachiSH3"" ; break ; case 0x1a3 : archtype = ""HitachiSH3-DSP"" ; break ; case 0x1a4 : archtype = ""HitachiSH3-E"" ; break ; case 0x1a6 : archtype = ""HitachiSH4"" ; break ; case 0x1a8 : archtype = ""HitachiSH5"" ; break ; case 0x1c0 : archtype = ""ARM"" ; break ; case 0x1c2 : archtype = ""THUMB"" ; break ; case 0x1d3 : archtype = ""AM33"" ; break ; case 0x520 : archtype = ""InfineonTriCore"" ; break ; case 0xcef : archtype = ""CEF"" ; break ; case 0xebc : archtype = ""EFIByteCode"" ; break ; case 0x9041 : archtype = ""M32R"" ; break ; case 0xc0ee : archtype = ""CEEE"" ; break ; case 0x8664 : archtype = ""AMD64"" ; break ; default : archtype = ""Unknown"" ; } if ( ( archtype ) ) { cli_dbgmsg ( ""Machinetype:%s\\n"" , archtype ) ; # if HAVE_JSON cli_jsonstr ( pe_json , ""ArchType"" , archtype ) ; # endif } nsections = EC16 ( file_hdr . NumberOfSections ) ; if ( nsections < 1 || nsections > 96 ) { # if HAVE_JSON pe_add_heuristic_property ( ctx , ""BadNumberOfSections"" ) ; # endif if ( DETECT_BROKEN_PE ) { cli_append_virus ( ctx , ""Heuristics.Broken.Executable"" ) ; return CL_VIRUS ; } if ( ! ctx -> corrupted_input ) { if ( nsections ) cli_warnmsg ( ""PEfilecontains%dsections\\n"" , nsections ) ; else cli_warnmsg ( ""PEfilecontainsnosections\\n"" ) ; } return CL_CLEAN ; } cli_dbgmsg ( ""NumberOfSections:%d\\n"" , nsections ) ; timestamp = ( time_t ) EC32 ( file_hdr . TimeDateStamp ) ; cli_dbgmsg ( ""TimeDateStamp:%s"" , cli_ctime ( & timestamp , timestr , sizeof ( timestr ) ) ) ; # if HAVE_JSON cli_jsonstr ( pe_json , ""TimeDateStamp"" , cli_ctime ( & timestamp , timestr , sizeof ( timestr ) ) ) ; # endif cli_dbgmsg ( ""SizeOfOptionalHeader:%x\\n"" , EC16 ( file_hdr . SizeOfOptionalHeader ) ) ; # if HAVE_JSON cli_jsonint ( pe_json , ""SizeOfOptionalHeader"" , EC16 ( file_hdr . SizeOfOptionalHeader ) ) ; # endif if ( EC16 ( file_hdr . SizeOfOptionalHeader ) < sizeof ( struct pe_image_optional_hdr32 ) ) { # if HAVE_JSON pe_add_heuristic_property ( ctx , ""BadOptionalHeaderSize"" ) ; # endif cli_dbgmsg ( ""SizeOfOptionalHeadertoosmall\\n"" ) ; if ( DETECT_BROKEN_PE ) { cli_append_virus ( ctx , ""Heuristics.Broken.Executable"" ) ; return CL_VIRUS ; } return CL_CLEAN ; } at = e_lfanew + sizeof ( struct pe_image_file_hdr ) ; if ( fmap_readn ( map , & optional_hdr32 , at , sizeof ( struct pe_image_optional_hdr32 ) ) != sizeof ( struct pe_image_optional_hdr32 ) ) { cli_dbgmsg ( ""Can\'treadoptionalfileheader\\n"" ) ; if ( DETECT_BROKEN_PE ) { cli_append_virus ( ctx , ""Heuristics.Broken.Executable"" ) ; return CL_VIRUS ; } return CL_CLEAN ; } at += sizeof ( struct pe_image_optional_hdr32 ) ; if ( EC16 ( optional_hdr64 . Magic ) == PE32P_SIGNATURE ) { # if HAVE_JSON pe_add_heuristic_property ( ctx , ""BadOptionalHeaderSizePE32Plus"" ) ; # endif if ( EC16 ( file_hdr . SizeOfOptionalHeader ) != sizeof ( struct pe_image_optional_hdr64 ) ) { cli_dbgmsg ( ""IncorrectSizeOfOptionalHeaderforPE32+\\n"" ) ; if ( DETECT_BROKEN_PE ) { cli_append_virus ( ctx , ""Heuristics.Broken.Executable"" ) ; return CL_VIRUS ; } return CL_CLEAN ; } pe_plus = 1 ; } if ( ! pe_plus ) { if ( EC16 ( file_hdr . SizeOfOptionalHeader ) != sizeof ( struct pe_image_optional_hdr32 ) ) { at += EC16 ( file_hdr . SizeOfOptionalHeader ) - sizeof ( struct pe_image_optional_hdr32 ) ; } if ( DCONF & PE_CONF_UPACK ) upack = ( EC16 ( file_hdr . SizeOfOptionalHeader ) == 0x148 ) ; vep = EC32 ( optional_hdr32 . AddressOfEntryPoint ) ; hdr_size = EC32 ( optional_hdr32 . SizeOfHeaders ) ; cli_dbgmsg ( ""Fileformat:PE\\n"" ) ; cli_dbgmsg ( ""MajorLinkerVersion:%d\\n"" , optional_hdr32 . MajorLinkerVersion ) ; cli_dbgmsg ( ""MinorLinkerVersion:%d\\n"" , optional_hdr32 . MinorLinkerVersion ) ; cli_dbgmsg ( ""SizeOfCode:0x%x\\n"" , EC32 ( optional_hdr32 . SizeOfCode ) ) ; cli_dbgmsg ( ""SizeOfInitializedData:0x%x\\n"" , EC32 ( optional_hdr32 . SizeOfInitializedData ) ) ; cli_dbgmsg ( ""SizeOfUninitializedData:0x%x\\n"" , EC32 ( optional_hdr32 . SizeOfUninitializedData ) ) ; cli_dbgmsg ( ""AddressOfEntryPoint:0x%x\\n"" , vep ) ; cli_dbgmsg ( ""BaseOfCode:0x%x\\n"" , EC32 ( optional_hdr32 . BaseOfCode ) ) ; cli_dbgmsg ( ""SectionAlignment:0x%x\\n"" , EC32 ( optional_hdr32 . SectionAlignment ) ) ; cli_dbgmsg ( ""FileAlignment:0x%x\\n"" , EC32 ( optional_hdr32 . FileAlignment ) ) ; cli_dbgmsg ( ""MajorSubsystemVersion:%d\\n"" , EC16 ( optional_hdr32 . MajorSubsystemVersion ) ) ; cli_dbgmsg ( ""MinorSubsystemVersion:%d\\n"" , EC16 ( optional_hdr32 . MinorSubsystemVersion ) ) ; cli_dbgmsg ( ""SizeOfImage:0x%x\\n"" , EC32 ( optional_hdr32 . SizeOfImage ) ) ; cli_dbgmsg ( ""SizeOfHeaders:0x%x\\n"" , hdr_size ) ; cli_dbgmsg ( ""NumberOfRvaAndSizes:%d\\n"" , EC32 ( optional_hdr32 . NumberOfRvaAndSizes ) ) ; dirs = optional_hdr32 . DataDirectory ; # if HAVE_JSON cli_jsonint ( pe_json , ""MajorLinkerVersion"" , optional_hdr32 . MajorLinkerVersion ) ; cli_jsonint ( pe_json , ""MinorLinkerVersion"" , optional_hdr32 . MinorLinkerVersion ) ; cli_jsonint ( pe_json , ""SizeOfCode"" , EC32 ( optional_hdr32 . SizeOfCode ) ) ; cli_jsonint ( pe_json , ""SizeOfInitializedData"" , EC32 ( optional_hdr32 . SizeOfInitializedData ) ) ; cli_jsonint ( pe_json , ""SizeOfUninitializedData"" , EC32 ( optional_hdr32 . SizeOfUninitializedData ) ) ; cli_jsonint ( pe_json , ""NumberOfRvaAndSizes"" , EC32 ( optional_hdr32 . NumberOfRvaAndSizes ) ) ; cli_jsonint ( pe_json , ""MajorSubsystemVersion"" , EC16 ( optional_hdr32 . MajorSubsystemVersion ) ) ; cli_jsonint ( pe_json , ""MinorSubsystemVersion"" , EC16 ( optional_hdr32 . MinorSubsystemVersion ) ) ; snprintf ( jsonbuf , sizeof ( jsonbuf ) , ""0x%x"" , EC32 ( optional_hdr32 . BaseOfCode ) ) ; cli_jsonstr ( pe_json , ""BaseOfCode"" , jsonbuf ) ; snprintf ( jsonbuf , sizeof ( jsonbuf ) , ""0x%x"" , EC32 ( optional_hdr32 . SectionAlignment ) ) ; cli_jsonstr ( pe_json , ""SectionAlignment"" , jsonbuf ) ; snprintf ( jsonbuf , sizeof ( jsonbuf ) , ""0x%x"" , EC32 ( optional_hdr32 . FileAlignment ) ) ; cli_jsonstr ( pe_json , ""FileAlignment"" , jsonbuf ) ; snprintf ( jsonbuf , sizeof ( jsonbuf ) , ""0x%x"" , EC32 ( optional_hdr32 . SizeOfImage ) ) ; cli_jsonstr ( pe_json , ""SizeOfImage"" , jsonbuf ) ; snprintf ( jsonbuf , sizeof ( jsonbuf ) , ""0x%x"" , hdr_size ) ; cli_jsonstr ( pe_json , ""SizeOfHeaders"" , jsonbuf ) ; # endif } else { if ( fmap_readn ( map , & optional_hdr32 + 1 , at , sizeof ( struct pe_image_optional_hdr64 ) - sizeof ( struct pe_image_optional_hdr32 ) ) != sizeof ( struct pe_image_optional_hdr64 ) - sizeof ( struct pe_image_optional_hdr32 ) ) { cli_dbgmsg ( ""Can\'treadoptionalfileheader\\n"" ) ; if ( DETECT_BROKEN_PE ) { cli_append_virus ( ctx , ""Heuristics.Broken.Executable"" ) ; return CL_VIRUS ; } return CL_CLEAN ; } at += sizeof ( struct pe_image_optional_hdr64 ) - sizeof ( struct pe_image_optional_hdr32 ) ; vep = EC32 ( optional_hdr64 . AddressOfEntryPoint ) ; hdr_size = EC32 ( optional_hdr64 . SizeOfHeaders ) ; cli_dbgmsg ( ""Fileformat:PE32+\\n"" ) ; cli_dbgmsg ( ""MajorLinkerVersion:%d\\n"" , optional_hdr64 . MajorLinkerVersion ) ; cli_dbgmsg ( ""MinorLinkerVersion:%d\\n"" , optional_hdr64 . MinorLinkerVersion ) ; cli_dbgmsg ( ""SizeOfCode:0x%x\\n"" , EC32 ( optional_hdr64 . SizeOfCode ) ) ; cli_dbgmsg ( ""SizeOfInitializedData:0x%x\\n"" , EC32 ( optional_hdr64 . SizeOfInitializedData ) ) ; cli_dbgmsg ( ""SizeOfUninitializedData:0x%x\\n"" , EC32 ( optional_hdr64 . SizeOfUninitializedData ) ) ; cli_dbgmsg ( ""AddressOfEntryPoint:0x%x\\n"" , vep ) ; cli_dbgmsg ( ""BaseOfCode:0x%x\\n"" , EC32 ( optional_hdr64 . BaseOfCode ) ) ; cli_dbgmsg ( ""SectionAlignment:0x%x\\n"" , EC32 ( optional_hdr64 . SectionAlignment ) ) ; cli_dbgmsg ( ""FileAlignment:0x%x\\n"" , EC32 ( optional_hdr64 . FileAlignment ) ) ; cli_dbgmsg ( ""MajorSubsystemVersion:%d\\n"" , EC16 ( optional_hdr64 . MajorSubsystemVersion ) ) ; cli_dbgmsg ( ""MinorSubsystemVersion:%d\\n"" , EC16 ( optional_hdr64 . MinorSubsystemVersion ) ) ; cli_dbgmsg ( ""SizeOfImage:0x%x\\n"" , EC32 ( optional_hdr64 . SizeOfImage ) ) ; cli_dbgmsg ( ""SizeOfHeaders:0x%x\\n"" , hdr_size ) ; cli_dbgmsg ( ""NumberOfRvaAndSizes:%d\\n"" , EC32 ( optional_hdr64 . NumberOfRvaAndSizes ) ) ; dirs = optional_hdr64 . DataDirectory ; # if HAVE_JSON cli_jsonint ( pe_json , ""MajorLinkerVersion"" , optional_hdr64 . MajorLinkerVersion ) ; cli_jsonint ( pe_json , ""MinorLinkerVersion"" , optional_hdr64 . MinorLinkerVersion ) ; cli_jsonint ( pe_json , ""SizeOfCode"" , EC32 ( optional_hdr64 . SizeOfCode ) ) ; cli_jsonint ( pe_json , ""SizeOfInitializedData"" , EC32 ( optional_hdr64 . SizeOfInitializedData ) ) ; cli_jsonint ( pe_json , ""SizeOfUninitializedData"" , EC32 ( optional_hdr64 . SizeOfUninitializedData ) ) ; cli_jsonint ( pe_json , ""NumberOfRvaAndSizes"" , EC32 ( optional_hdr64 . NumberOfRvaAndSizes ) ) ; cli_jsonint ( pe_json , ""MajorSubsystemVersion"" , EC16 ( optional_hdr64 . MajorSubsystemVersion ) ) ; cli_jsonint ( pe_json , ""MinorSubsystemVersion"" , EC16 ( optional_hdr64 . MinorSubsystemVersion ) ) ; snprintf ( jsonbuf , sizeof ( jsonbuf ) , ""0x%x"" , EC32 ( optional_hdr64 . BaseOfCode ) ) ; cli_jsonstr ( pe_json , ""BaseOfCode"" , jsonbuf ) ; snprintf ( jsonbuf , sizeof ( jsonbuf ) , ""0x%x"" , EC32 ( optional_hdr64 . SectionAlignment ) ) ; cli_jsonstr ( pe_json , ""SectionAlignment"" , jsonbuf ) ; snprintf ( jsonbuf , sizeof ( jsonbuf ) , ""0x%x"" , EC32 ( optional_hdr64 . FileAlignment ) ) ; cli_jsonstr ( pe_json , ""FileAlignment"" , jsonbuf ) ; snprintf ( jsonbuf , sizeof ( jsonbuf ) , ""0x%x"" , EC32 ( optional_hdr64 . SizeOfImage ) ) ; cli_jsonstr ( pe_json , ""SizeOfImage"" , jsonbuf ) ; snprintf ( jsonbuf , sizeof ( jsonbuf ) , ""0x%x"" , hdr_size ) ; cli_jsonstr ( pe_json , ""SizeOfHeaders"" , jsonbuf ) ; # endif } # if HAVE_JSON if ( ctx -> options & CL_SCAN_FILE_PROPERTIES ) { snprintf ( jsonbuf , sizeof ( jsonbuf ) , ""0x%x"" , vep ) ; cli_jsonstr ( pe_json , ""EntryPoint"" , jsonbuf ) ; } # endif switch ( pe_plus ? EC16 ( optional_hdr64 . Subsystem ) : EC16 ( optional_hdr32 . Subsystem ) ) { case 0 : subsystem = ""Unknown"" ; break ; case 1 : subsystem = ""Native(svc)"" ; native = 1 ; break ; case 2 : subsystem = ""Win32GUI"" ; break ; case 3 : subsystem = ""Win32console"" ; break ; case 5 : subsystem = ""OS/2console"" ; break ; case 7 : subsystem = ""POSIXconsole"" ; break ; case 8 : subsystem = ""NativeWin9xdriver"" ; break ; case 9 : subsystem = ""WinCEGUI"" ; break ; case 10 : subsystem = ""EFIapplication"" ; break ; case 11 : subsystem = ""EFIdriver"" ; break ; case 12 : subsystem = ""EFIruntimedriver"" ; break ; case 13 : subsystem = ""EFIROMimage"" ; break ; case 14 : subsystem = ""Xbox"" ; break ; case 16 : subsystem = ""Bootapplication"" ; break ; default : subsystem = ""Unknown"" ; } cli_dbgmsg ( ""Subsystem:%s\\n"" , subsystem ) ; # if HAVE_JSON cli_jsonstr ( pe_json , ""Subsystem"" , subsystem ) ; # endif cli_dbgmsg ( ""------------------------------------\\n"" ) ; if ( DETECT_BROKEN_PE && ! native && ( ! ( pe_plus ? EC32 ( optional_hdr64 . SectionAlignment ) : EC32 ( optional_hdr32 . SectionAlignment ) ) || ( pe_plus ? EC32 ( optional_hdr64 . SectionAlignment ) : EC32 ( optional_hdr32 . SectionAlignment ) ) % 0x1000 ) ) { cli_dbgmsg ( ""Badvirtualalignemnt\\n"" ) ; cli_append_virus ( ctx , ""Heuristics.Broken.Executable"" ) ; return CL_VIRUS ; } if ( DETECT_BROKEN_PE && ! native && ( ! ( pe_plus ? EC32 ( optional_hdr64 . FileAlignment ) : EC32 ( optional_hdr32 . FileAlignment ) ) || ( pe_plus ? EC32 ( optional_hdr64 . FileAlignment ) : EC32 ( optional_hdr32 . FileAlignment ) ) % 0x200 ) ) { cli_dbgmsg ( ""Badfilealignemnt\\n"" ) ; cli_append_virus ( ctx , ""Heuristics.Broken.Executable"" ) ; return CL_VIRUS ; } fsize = map -> len ; section_hdr = ( struct pe_image_section_hdr * ) cli_calloc ( nsections , sizeof ( struct pe_image_section_hdr ) ) ; if ( ! section_hdr ) { cli_dbgmsg ( ""Can\'tallocatememoryforsectionheaders\\n"" ) ; return CL_EMEM ; } exe_sections = ( struct cli_exe_section * ) cli_calloc ( nsections , sizeof ( struct cli_exe_section ) ) ; if ( ! exe_sections ) { cli_dbgmsg ( ""Can\'tallocatememoryforsectionheaders\\n"" ) ; free ( section_hdr ) ; return CL_EMEM ; } valign = ( pe_plus ) ? EC32 ( optional_hdr64 . SectionAlignment ) : EC32 ( optional_hdr32 . SectionAlignment ) ; falign = ( pe_plus ) ? EC32 ( optional_hdr64 . FileAlignment ) : EC32 ( optional_hdr32 . FileAlignment ) ; if ( fmap_readn ( map , section_hdr , at , sizeof ( struct pe_image_section_hdr ) * nsections ) != ( int ) ( nsections * sizeof ( struct pe_image_section_hdr ) ) ) { cli_dbgmsg ( ""Can\'treadsectionheader\\n"" ) ; cli_dbgmsg ( ""PossiblybrokenPEfile\\n"" ) ; free ( section_hdr ) ; free ( exe_sections ) ; if ( DETECT_BROKEN_PE ) { cli_append_virus ( ctx , ""Heuristics.Broken.Executable"" ) ; return CL_VIRUS ; } return CL_CLEAN ; } at += sizeof ( struct pe_image_section_hdr ) * nsections ; for ( i = 0 ; falign != 0x200 && i < nsections ; i ++ ) { if ( falign && section_hdr [ i ] . SizeOfRawData && EC32 ( section_hdr [ i ] . PointerToRawData ) % falign && ! ( EC32 ( section_hdr [ i ] . PointerToRawData ) % 0x200 ) ) { cli_dbgmsg ( ""Foundmisalignedsection,using0x200\\n"" ) ; falign = 0x200 ; } } hdr_size = PESALIGN ( hdr_size , valign ) ; # if HAVE_JSON cli_jsonint ( pe_json , ""NumberOfSections"" , nsections ) ; # endif for ( i = 0 ; i < nsections ; i ++ ) { strncpy ( sname , ( char * ) section_hdr [ i ] . Name , 8 ) ; sname [ 8 ] = 0 ; exe_sections [ i ] . rva = PEALIGN ( EC32 ( section_hdr [ i ] . VirtualAddress ) , valign ) ; exe_sections [ i ] . vsz = PESALIGN ( EC32 ( section_hdr [ i ] . VirtualSize ) , valign ) ; exe_sections [ i ] . raw = PEALIGN ( EC32 ( section_hdr [ i ] . PointerToRawData ) , falign ) ; exe_sections [ i ] . rsz = PESALIGN ( EC32 ( section_hdr [ i ] . SizeOfRawData ) , falign ) ; exe_sections [ i ] . chr = EC32 ( section_hdr [ i ] . Characteristics ) ; exe_sections [ i ] . urva = EC32 ( section_hdr [ i ] . VirtualAddress ) ; exe_sections [ i ] . uvsz = EC32 ( section_hdr [ i ] . VirtualSize ) ; exe_sections [ i ] . uraw = EC32 ( section_hdr [ i ] . PointerToRawData ) ; exe_sections [ i ] . ursz = EC32 ( section_hdr [ i ] . SizeOfRawData ) ; # if HAVE_JSON add_section_info ( ctx , & exe_sections [ i ] ) ; if ( cli_json_timeout_cycle_check ( ctx , & toval ) != CL_SUCCESS ) { free ( section_hdr ) ; free ( exe_sections ) ; return CL_ETIMEOUT ; } # endif if ( ! exe_sections [ i ] . vsz && exe_sections [ i ] . rsz ) exe_sections [ i ] . vsz = PESALIGN ( exe_sections [ i ] . ursz , valign ) ; if ( exe_sections [ i ] . rsz && fsize > exe_sections [ i ] . raw && ! CLI_ISCONTAINED ( 0 , ( uint32_t ) fsize , exe_sections [ i ] . raw , exe_sections [ i ] . rsz ) ) exe_sections [ i ] . rsz = fsize - exe_sections [ i ] . raw ; cli_dbgmsg ( ""Section%d\\n"" , i ) ; cli_dbgmsg ( ""Sectionname:%s\\n"" , sname ) ; cli_dbgmsg ( ""Sectiondata(fromheaders-inmemory)\\n"" ) ; cli_dbgmsg ( ""VirtualSize:0x%x0x%x\\n"" , exe_sections [ i ] . uvsz , exe_sections [ i ] . vsz ) ; cli_dbgmsg ( ""VirtualAddress:0x%x0x%x\\n"" , exe_sections [ i ] . urva , exe_sections [ i ] . rva ) ; cli_dbgmsg ( ""SizeOfRawData:0x%x0x%x\\n"" , exe_sections [ i ] . ursz , exe_sections [ i ] . rsz ) ; cli_dbgmsg ( ""PointerToRawData:0x%x0x%x\\n"" , exe_sections [ i ] . uraw , exe_sections [ i ] . raw ) ; if ( exe_sections [ i ] . chr & 0x20 ) { cli_dbgmsg ( ""Sectioncontainsexecutablecode\\n"" ) ; if ( exe_sections [ i ] . vsz < exe_sections [ i ] . rsz ) { cli_dbgmsg ( ""Sectioncontainsfreespace\\n"" ) ; } } if ( exe_sections [ i ] . chr & 0x20000000 ) cli_dbgmsg ( ""Section\'smemoryisexecutable\\n"" ) ; if ( exe_sections [ i ] . chr & 0x80000000 ) cli_dbgmsg ( ""Section\'smemoryiswriteable\\n"" ) ; if ( DETECT_BROKEN_PE && ( ! valign || ( exe_sections [ i ] . urva % valign ) ) ) { cli_dbgmsg ( ""VirtualAddressismisaligned\\n"" ) ; cli_dbgmsg ( ""------------------------------------\\n"" ) ; cli_append_virus ( ctx , ""Heuristics.Broken.Executable"" ) ; free ( section_hdr ) ; free ( exe_sections ) ; return CL_VIRUS ; } if ( exe_sections [ i ] . rsz ) { if ( exe_sections [ i ] . raw >= fsize ) { cli_dbgmsg ( ""BrokenPEfile-Section%dstartsbeyondtheendoffile(Offset@%lu,Totalfilesize%lu)\\n"" , i , ( unsigned long ) exe_sections [ i ] . raw , ( unsigned long ) fsize ) ; cli_dbgmsg ( ""------------------------------------\\n"" ) ; free ( section_hdr ) ; free ( exe_sections ) ; if ( DETECT_BROKEN_PE ) { cli_append_virus ( ctx , ""Heuristics.Broken.Executable"" ) ; return CL_VIRUS ; } return CL_CLEAN ; } if ( SCAN_ALGO && ( DCONF & PE_CONF_POLIPOS ) && ! * sname && exe_sections [ i ] . vsz > 40000 && exe_sections [ i ] . vsz < 70000 && exe_sections [ i ] . chr == 0xe0000060 ) polipos = i ; if ( ( DCONF & PE_CONF_MD5SECT ) && ctx -> engine -> hm_mdb ) { ret = scan_pe_mdb ( ctx , & exe_sections [ i ] ) ; if ( ret != CL_CLEAN ) { if ( ret != CL_VIRUS ) cli_errmsg ( ""scan_pe:scan_pe_mdbfailed:%s!\\n"" , cl_strerror ( ret ) ) ; cli_dbgmsg ( ""------------------------------------\\n"" ) ; free ( section_hdr ) ; free ( exe_sections ) ; return ret ; } } } cli_dbgmsg ( ""------------------------------------\\n"" ) ; if ( exe_sections [ i ] . urva >> 31 || exe_sections [ i ] . uvsz >> 31 || ( exe_sections [ i ] . rsz && exe_sections [ i ] . uraw >> 31 ) || exe_sections [ i ] . ursz >> 31 ) { cli_dbgmsg ( ""FoundPEvalueswithsignbitset\\n"" ) ; free ( section_hdr ) ; free ( exe_sections ) ; if ( DETECT_BROKEN_PE ) { cli_append_virus ( ctx , ""Heuristics.Broken.Executable"" ) ; return CL_VIRUS ; } return CL_CLEAN ; } if ( ! i ) { if ( DETECT_BROKEN_PE && exe_sections [ i ] . urva != hdr_size ) { cli_dbgmsg ( ""Firstsectionisinthewrongplace\\n"" ) ; cli_append_virus ( ctx , ""Heuristics.Broken.Executable"" ) ; free ( section_hdr ) ; free ( exe_sections ) ; return CL_VIRUS ; } min = exe_sections [ i ] . rva ; max = exe_sections [ i ] . rva + exe_sections [ i ] . rsz ; } else { if ( DETECT_BROKEN_PE && exe_sections [ i ] . urva - exe_sections [ i - 1 ] . urva != exe_sections [ i - 1 ] . vsz ) { cli_dbgmsg ( ""Virtuallymisplacedsection(wrongorder,overlapping,noncontiguous)\\n"" ) ; cli_append_virus ( ctx , ""Heuristics.Broken.Executable"" ) ; free ( section_hdr ) ; free ( exe_sections ) ; return CL_VIRUS ; } if ( exe_sections [ i ] . rva < min ) min = exe_sections [ i ] . rva ; if ( exe_sections [ i ] . rva + exe_sections [ i ] . rsz > max ) { max = exe_sections [ i ] . rva + exe_sections [ i ] . rsz ; overlays = exe_sections [ i ] . raw + exe_sections [ i ] . rsz ; } } } free ( section_hdr ) ; if ( ! ( ep = cli_rawaddr ( vep , exe_sections , nsections , & err , fsize , hdr_size ) ) && err ) { cli_dbgmsg ( ""EntryPointoutoffile\\n"" ) ; free ( exe_sections ) ; if ( DETECT_BROKEN_PE ) { cli_append_virus ( ctx , ""Heuristics.Broken.Executable"" ) ; return CL_VIRUS ; } return CL_CLEAN ; } # if HAVE_JSON cli_jsonint ( pe_json , ""EntryPointOffset"" , ep ) ; if ( cli_json_timeout_cycle_check ( ctx , & toval ) != CL_SUCCESS ) { return CL_ETIMEOUT ; } # endif cli_dbgmsg ( ""EntryPointoffset:0x%x(%d)\\n"" , ep , ep ) ; if ( pe_plus ) { free ( exe_sections ) ; return CL_CLEAN ; } epsize = fmap_readn ( map , epbuff , ep , 4096 ) ; if ( overlays ) { int overlays_sz = fsize - overlays ; if ( overlays_sz > 0 ) { ret = cli_scanishield ( ctx , overlays , overlays_sz ) ; if ( ret != CL_CLEAN ) { free ( exe_sections ) ; return ret ; } } } pedata . nsections = nsections ; pedata . ep = ep ; pedata . offset = 0 ; memcpy ( & pedata . file_hdr , & file_hdr , sizeof ( file_hdr ) ) ; memcpy ( & pedata . opt32 , & pe_opt . opt32 , sizeof ( pe_opt . opt32 ) ) ; memcpy ( & pedata . opt64 , & pe_opt . opt64 , sizeof ( pe_opt . opt64 ) ) ; memcpy ( & pedata . dirs , dirs , sizeof ( pedata . dirs ) ) ; pedata . e_lfanew = e_lfanew ; pedata . overlays = overlays ; pedata . overlays_sz = fsize - overlays ; pedata . hdr_size = hdr_size ; bc_ctx = cli_bytecode_context_alloc ( ) ; if ( ! bc_ctx ) { cli_errmsg ( ""cli_scanpe:can\'tallocatememoryforbc_ctx\\n"" ) ; free ( exe_sections ) ; return CL_EMEM ; } cli_bytecode_context_setpe ( bc_ctx , & pedata , exe_sections ) ; cli_bytecode_context_setctx ( bc_ctx , ctx ) ; ret = cli_bytecode_runhook ( ctx , ctx -> engine , bc_ctx , BC_PE_ALL , map ) ; switch ( ret ) { case CL_ENULLARG : cli_warnmsg ( ""cli_scanpe:NULLargumentsupplied\\n"" ) ; break ; case CL_VIRUS : case CL_BREAK : free ( exe_sections ) ; cli_bytecode_context_destroy ( bc_ctx ) ; return ret == CL_VIRUS ? CL_VIRUS : CL_CLEAN ; } cli_bytecode_context_destroy ( bc_ctx ) ; if ( SCAN_ALGO && ( DCONF & PE_CONF_PARITE ) && ! dll && epsize == 4096 && ep == exe_sections [ nsections - 1 ] . raw ) { const char * pt = cli_memstr ( epbuff , 4040 , ""\\x47\\x65\\x74\\x50\\x72\\x6f\\x63\\x41\\x64\\x64\\x72\\x65\\x73\\x73\\x00"" , 15 ) ; if ( pt ) { pt += 15 ; if ( ( ( ( uint32_t ) cli_readint32 ( pt ) ^ ( uint32_t ) cli_readint32 ( pt + 4 ) ) == 0x505a4f ) && ( ( ( uint32_t ) cli_readint32 ( pt + 8 ) ^ ( uint32_t ) cli_readint32 ( pt + 12 ) ) == 0xffffb ) && ( ( ( uint32_t ) cli_readint32 ( pt + 16 ) ^ ( uint32_t ) cli_readint32 ( pt + 20 ) ) == 0xb8 ) ) { cli_append_virus ( ctx , ""Heuristics.W32.Parite.B"" ) ; if ( ! SCAN_ALL ) { free ( exe_sections ) ; return CL_VIRUS ; } viruses_found ++ ; } } } if ( SCAN_ALGO && ( DCONF & PE_CONF_KRIZ ) && epsize >= 200 && CLI_ISCONTAINED ( exe_sections [ nsections - 1 ] . raw , exe_sections [ nsections - 1 ] . rsz , ep , 0x0fd2 ) && epbuff [ 1 ] == '\\x9c' && epbuff [ 2 ] == '\\x60' ) { enum { KZSTRASH , KZSCDELTA , KZSPDELTA , KZSGETSIZE , KZSXORPRFX , KZSXOR , KZSDDELTA , KZSLOOP , KZSTOP } ; uint8_t kzs [ ] = { KZSTRASH , KZSCDELTA , KZSPDELTA , KZSGETSIZE , KZSTRASH , KZSXORPRFX , KZSXOR , KZSTRASH , KZSDDELTA , KZSTRASH , KZSLOOP , KZSTOP } ; uint8_t * kzstate = kzs ; uint8_t * kzcode = ( uint8_t * ) epbuff + 3 ; uint8_t kzdptr = 0xff , kzdsize = 0xff ; int kzlen = 197 , kzinitlen = 0xffff , kzxorlen = - 1 ; cli_dbgmsg ( ""inkriz\\n"" ) ; while ( * kzstate != KZSTOP ) { uint8_t op ; if ( kzlen <= 6 ) break ; op = * kzcode ++ ; kzlen -- ; switch ( * kzstate ) { case KZSTRASH : case KZSGETSIZE : { int opsz = 0 ; switch ( op ) { case 0x81 : kzcode += 5 ; kzlen -= 5 ; break ; case 0xb8 : case 0xb9 : case 0xba : case 0xbb : case 0xbd : case 0xbe : case 0xbf : if ( * kzstate == KZSGETSIZE && cli_readint32 ( kzcode ) == 0x0fd2 ) { kzinitlen = kzlen - 5 ; kzdsize = op - 0xb8 ; kzstate ++ ; op = 4 ; cli_dbgmsg ( ""kriz:using#%dassizecounter\\n"" , kzdsize ) ; } opsz = 4 ; case 0x48 : case 0x49 : case 0x4a : case 0x4b : case 0x4d : case 0x4e : case 0x4f : op &= 7 ; if ( op != kzdptr && op != kzdsize ) { kzcode += opsz ; kzlen -= opsz ; break ; } default : kzcode -- ; kzlen ++ ; kzstate ++ ; } break ; } case KZSCDELTA : if ( op == 0xe8 && ( uint32_t ) cli_readint32 ( kzcode ) < 0xff ) { kzlen -= * kzcode + 4 ; kzcode += * kzcode + 4 ; kzstate ++ ; } else * kzstate = KZSTOP ; break ; case KZSPDELTA : if ( ( op & 0xf8 ) == 0x58 && ( kzdptr = op - 0x58 ) != 4 ) { kzstate ++ ; cli_dbgmsg ( ""kriz:using#%daspointer\\n"" , kzdptr ) ; } else * kzstate = KZSTOP ; break ; case KZSXORPRFX : kzstate ++ ; if ( op == 0x3e ) break ; case KZSXOR : if ( op == 0x80 && * kzcode == kzdptr + 0xb0 ) { kzxorlen = kzlen ; kzcode += + 6 ; kzlen -= + 6 ; kzstate ++ ; } else * kzstate = KZSTOP ; break ; case KZSDDELTA : if ( op == kzdptr + 0x48 ) kzstate ++ ; else * kzstate = KZSTOP ; break ; case KZSLOOP : if ( op == kzdsize + 0x48 && * kzcode == 0x75 && kzlen - ( int8_t ) kzcode [ 1 ] - 3 <= kzinitlen && kzlen - ( int8_t ) kzcode [ 1 ] >= kzxorlen ) { cli_append_virus ( ctx , ""Heuristics.W32.Kriz"" ) ; if ( ! SCAN_ALL ) { free ( exe_sections ) ; return CL_VIRUS ; } viruses_found ++ ; } cli_dbgmsg ( ""kriz:loopoutofbounds,corruptedsample?\\n"" ) ; kzstate ++ ; } } } if ( SCAN_ALGO && ( DCONF & PE_CONF_MAGISTR ) && ! dll && ( nsections > 1 ) && ( exe_sections [ nsections - 1 ] . chr & 0x80000000 ) ) { uint32_t rsize , vsize , dam = 0 ; vsize = exe_sections [ nsections - 1 ] . uvsz ; rsize = exe_sections [ nsections - 1 ] . rsz ; if ( rsize < exe_sections [ nsections - 1 ] . ursz ) { rsize = exe_sections [ nsections - 1 ] . ursz ; dam = 1 ; } if ( vsize >= 0x612c && rsize >= 0x612c && ( ( vsize & 0xff ) == 0xec ) ) { int bw = rsize < 0x7000 ? rsize : 0x7000 ; const char * tbuff ; if ( ( tbuff = fmap_need_off_once ( map , exe_sections [ nsections - 1 ] . raw + rsize - bw , 4096 ) ) ) { if ( cli_memstr ( tbuff , 4091 , ""\\xe8\\x2c\\x61\\x00\\x00"" , 5 ) ) { cli_append_virus ( ctx , dam ? ""Heuristics.W32.Magistr.A.dam"" : ""Heuristics.W32.Magistr.A"" ) ; if ( ! SCAN_ALL ) { free ( exe_sections ) ; return CL_VIRUS ; } viruses_found ++ ; } } } else if ( rsize >= 0x7000 && vsize >= 0x7000 && ( ( vsize & 0xff ) == 0xed ) ) { int bw = rsize < 0x8000 ? rsize : 0x8000 ; const char * tbuff ; if ( ( tbuff = fmap_need_off_once ( map , exe_sections [ nsections - 1 ] . raw + rsize - bw , 4096 ) ) ) { if ( cli_memstr ( tbuff , 4091 , ""\\xe8\\x04\\x72\\x00\\x00"" , 5 ) ) { cli_append_virus ( ctx , dam ? ""Heuristics.W32.Magistr.B.dam"" : ""Heuristics.W32.Magistr.B"" ) ; if ( ! SCAN_ALL ) { free ( exe_sections ) ; return CL_VIRUS ; } viruses_found ++ ; } } } } while ( polipos && ! dll && nsections > 2 && nsections < 13 && e_lfanew <= 0x800 && ( EC16 ( optional_hdr32 . Subsystem ) == 2 || EC16 ( optional_hdr32 . Subsystem ) == 3 ) && EC16 ( file_hdr . Machine ) == 0x14c && optional_hdr32 . SizeOfStackReserve >= 0x80000 ) { uint32_t jump , jold , * jumps = NULL ; const uint8_t * code ; unsigned int xsjs = 0 ; if ( exe_sections [ 0 ] . rsz > CLI_MAX_ALLOCATION ) break ; if ( ! exe_sections [ 0 ] . rsz ) break ; if ( ! ( code = fmap_need_off_once ( map , exe_sections [ 0 ] . raw , exe_sections [ 0 ] . rsz ) ) ) break ; for ( i = 0 ; i < exe_sections [ 0 ] . rsz - 5 ; i ++ ) { if ( ( uint8_t ) ( code [ i ] - 0xe8 ) > 1 ) continue ; jump = cli_rawaddr ( exe_sections [ 0 ] . rva + i + 5 + cli_readint32 ( & code [ i + 1 ] ) , exe_sections , nsections , & err , fsize , hdr_size ) ; if ( err || ! CLI_ISCONTAINED ( exe_sections [ polipos ] . raw , exe_sections [ polipos ] . rsz , jump , 9 ) ) continue ; if ( xsjs % 128 == 0 ) { if ( xsjs == 1280 ) break ; if ( ! ( jumps = ( uint32_t * ) cli_realloc2 ( jumps , ( xsjs + 128 ) * sizeof ( uint32_t ) ) ) ) { free ( exe_sections ) ; return CL_EMEM ; } } j = 0 ; for ( ; j < xsjs ; j ++ ) { if ( jumps [ j ] < jump ) continue ; if ( jumps [ j ] == jump ) { xsjs -- ; break ; } jold = jumps [ j ] ; jumps [ j ] = jump ; jump = jold ; } jumps [ j ] = jump ; xsjs ++ ; } if ( ! xsjs ) break ; cli_dbgmsg ( ""Polipos:Checking%dxsectjump(s)\\n"" , xsjs ) ; for ( i = 0 ; i < xsjs ; i ++ ) { if ( ! ( code = fmap_need_off_once ( map , jumps [ i ] , 9 ) ) ) continue ; if ( ( jump = cli_readint32 ( code ) ) == 0x60ec8b55 || ( code [ 4 ] == 0x0ec && ( ( jump == 0x83ec8b55 && code [ 6 ] == 0x60 ) || ( jump == 0x81ec8b55 && ! code [ 7 ] && ! code [ 8 ] ) ) ) ) { cli_append_virus ( ctx , ""Heuristics.W32.Polipos.A"" ) ; if ( ! SCAN_ALL ) { free ( jumps ) ; free ( exe_sections ) ; return CL_VIRUS ; } viruses_found ++ ; } } free ( jumps ) ; break ; } if ( SCAN_ALGO && ( DCONF & PE_CONF_SWIZZOR ) && nsections > 1 && fsize > 64 * 1024 && fsize < 4 * 1024 * 1024 ) { if ( dirs [ 2 ] . Size ) { struct swizz_stats * stats = cli_calloc ( 1 , sizeof ( * stats ) ) ; unsigned int m = 1000 ; ret = CL_CLEAN ; if ( ! stats ) ret = CL_EMEM ; else { cli_parseres_special ( EC32 ( dirs [ 2 ] . VirtualAddress ) , EC32 ( dirs [ 2 ] . VirtualAddress ) , map , exe_sections , nsections , fsize , hdr_size , 0 , 0 , & m , stats ) ; if ( ( ret = cli_detect_swizz ( stats ) ) == CL_VIRUS ) { cli_append_virus ( ctx , ""Heuristics.Trojan.Swizzor.Gen"" ) ; } free ( stats ) ; } if ( ret != CL_CLEAN ) { if ( ! ( ret == CL_VIRUS && SCAN_ALL ) ) { free ( exe_sections ) ; return ret ; } viruses_found ++ ; } } } corrupted_cur = ctx -> corrupted_input ; ctx -> corrupted_input = 2 ; found = 0 ; if ( DCONF & ( PE_CONF_UPX | PE_CONF_FSG | PE_CONF_MEW ) ) { for ( i = 0 ; i < ( unsigned int ) nsections - 1 ; i ++ ) { if ( ! exe_sections [ i ] . rsz && exe_sections [ i ] . vsz && exe_sections [ i + 1 ] . rsz && exe_sections [ i + 1 ] . vsz ) { found = 1 ; cli_dbgmsg ( ""UPX/FSG/MEW:emptysectionfound-assumingcompression\\n"" ) ; # if HAVE_JSON cli_jsonbool ( pe_json , ""HasEmptySection"" , 1 ) ; # endif break ; } } } if ( found && ( DCONF & PE_CONF_MEW ) && epsize >= 16 && epbuff [ 0 ] == '\\xe9' ) { uint32_t fileoffset ; const char * tbuff ; fileoffset = ( vep + cli_readint32 ( epbuff + 1 ) + 5 ) ; while ( fileoffset == 0x154 || fileoffset == 0x158 ) { char * src ; uint32_t offdiff , uselzma ; cli_dbgmsg ( ""MEW:foundMEWcharacteristics%08X+%08X+5=%08X\\n"" , cli_readint32 ( epbuff + 1 ) , vep , cli_readint32 ( epbuff + 1 ) + vep + 5 ) ; if ( ! ( tbuff = fmap_need_off_once ( map , fileoffset , 0xb0 ) ) ) break ; if ( fileoffset == 0x154 ) cli_dbgmsg ( ""MEW:Win9xcompatibilitywasset!\\n"" ) ; else cli_dbgmsg ( ""MEW:Win9xcompatibilitywasNOTset!\\n"" ) ; if ( ( offdiff = cli_readint32 ( tbuff + 1 ) - EC32 ( optional_hdr32 . ImageBase ) ) <= exe_sections [ i + 1 ] . rva || offdiff >= exe_sections [ i + 1 ] . rva + exe_sections [ i + 1 ] . raw - 4 ) { cli_dbgmsg ( ""MEW:ESIisnotinpropersection\\n"" ) ; break ; } offdiff -= exe_sections [ i + 1 ] . rva ; if ( ! exe_sections [ i + 1 ] . rsz ) { cli_dbgmsg ( ""MEW:mewsectionisempty\\n"" ) ; break ; } ssize = exe_sections [ i + 1 ] . vsz ; dsize = exe_sections [ i ] . vsz ; cli_dbgmsg ( ""MEW:ssize%08xdsize%08xoffdiff:%08x\\n"" , ssize , dsize , offdiff ) ; CLI_UNPSIZELIMITS ( ""MEW"" , MAX ( ssize , dsize ) ) ; CLI_UNPSIZELIMITS ( ""MEW"" , MAX ( ssize + dsize , exe_sections [ i + 1 ] . rsz ) ) ; if ( exe_sections [ i + 1 ] . rsz < offdiff + 12 || exe_sections [ i + 1 ] . rsz > ssize ) { cli_dbgmsg ( ""MEW:Sizemismatch:%08x\\n"" , exe_sections [ i + 1 ] . rsz ) ; break ; } if ( ! ( src = cli_calloc ( ssize + dsize , sizeof ( char ) ) ) ) { free ( exe_sections ) ; return CL_EMEM ; } if ( ( bytes = fmap_readn ( map , src + dsize , exe_sections [ i + 1 ] . raw , exe_sections [ i + 1 ] . rsz ) ) != exe_sections [ i + 1 ] . rsz ) { cli_dbgmsg ( ""MEW:Can\'tread%dbytes[read:%lu]\\n"" , exe_sections [ i + 1 ] . rsz , ( unsigned long ) bytes ) ; free ( exe_sections ) ; free ( src ) ; return CL_EREAD ; } cli_dbgmsg ( ""MEW:%u(%08x)bytesread\\n"" , ( unsigned int ) bytes , ( unsigned int ) bytes ) ; if ( tbuff [ 0x7b ] == '\\xe8' ) { if ( ! CLI_ISCONTAINED ( exe_sections [ 1 ] . rva , exe_sections [ 1 ] . vsz , cli_readint32 ( tbuff + 0x7c ) + fileoffset + 0x80 , 4 ) ) { cli_dbgmsg ( ""MEW:lzmaprocoutofbounds!\\n"" ) ; free ( src ) ; break ; } uselzma = cli_readint32 ( tbuff + 0x7c ) - ( exe_sections [ 0 ] . rva - fileoffset - 0x80 ) ; } else { uselzma = 0 ; } # if HAVE_JSON cli_jsonstr ( pe_json , ""Packer"" , ""MEW"" ) ; # endif CLI_UNPTEMP ( ""MEW"" , ( src , exe_sections , 0 ) ) ; CLI_UNPRESULTS ( ""MEW"" , ( unmew11 ( src , offdiff , ssize , dsize , EC32 ( optional_hdr32 . ImageBase ) , exe_sections [ 0 ] . rva , uselzma , ndesc ) ) , 1 , ( src , 0 ) ) ; break ; } } if ( epsize < 168 ) { free ( exe_sections ) ; return CL_CLEAN ; } if ( found || upack ) { while ( ( ( upack && nsections == 3 ) && ( ( epbuff [ 0 ] == '\\xbe' && cli_readint32 ( epbuff + 1 ) - EC32 ( optional_hdr32 . ImageBase ) > min && epbuff [ 5 ] == '\\xad' && epbuff [ 6 ] == '\\x50' ) || ( epbuff [ 0 ] == '\\xbe' && cli_readint32 ( epbuff + 1 ) - EC32 ( optional_hdr32 . ImageBase ) > min && epbuff [ 5 ] == '\\xff' && epbuff [ 6 ] == '\\x36' ) ) ) || ( ( ! upack && nsections == 2 ) && ( ( epbuff [ 0 ] == '\\x60' && epbuff [ 1 ] == '\\xe8' && cli_readint32 ( epbuff + 2 ) == 0x9 ) || ( epbuff [ 0 ] == '\\xbe' && cli_readint32 ( epbuff + 1 ) - EC32 ( optional_hdr32 . ImageBase ) < min && cli_readint32 ( epbuff + 1 ) - EC32 ( optional_hdr32 . ImageBase ) > 0 && epbuff [ 5 ] == '\\xad' && epbuff [ 6 ] == '\\x8b' && epbuff [ 7 ] == '\\xf8' ) ) ) ) { uint32_t vma , off ; int a , b , c ; cli_dbgmsg ( ""Upackcharacteristicsfound.\\n"" ) ; a = exe_sections [ 0 ] . vsz ; b = exe_sections [ 1 ] . vsz ; if ( upack ) { cli_dbgmsg ( ""Upack:varset\\n"" ) ; c = exe_sections [ 2 ] . vsz ; ssize = exe_sections [ 0 ] . ursz + exe_sections [ 0 ] . uraw ; off = exe_sections [ 0 ] . rva ; vma = EC32 ( optional_hdr32 . ImageBase ) + exe_sections [ 0 ] . rva ; } else { cli_dbgmsg ( ""Upack:varNOTset\\n"" ) ; c = exe_sections [ 1 ] . rva ; ssize = exe_sections [ 1 ] . uraw ; off = 0 ; vma = exe_sections [ 1 ] . rva - exe_sections [ 1 ] . uraw ; } dsize = a + b + c ; CLI_UNPSIZELIMITS ( ""Upack"" , MAX ( MAX ( dsize , ssize ) , exe_sections [ 1 ] . ursz ) ) ; if ( ! CLI_ISCONTAINED ( 0 , dsize , exe_sections [ 1 ] . rva - off , exe_sections [ 1 ] . ursz ) || ( upack && ! CLI_ISCONTAINED ( 0 , dsize , exe_sections [ 2 ] . rva - exe_sections [ 0 ] . rva , ssize ) ) || ssize > dsize ) { cli_dbgmsg ( ""Upack:probablymalformedpe-header,skippingtonextunpacker\\n"" ) ; break ; } if ( ( dest = ( char * ) cli_calloc ( dsize , sizeof ( char ) ) ) == NULL ) { free ( exe_sections ) ; return CL_EMEM ; } if ( ( unsigned int ) fmap_readn ( map , dest , 0 , ssize ) != ssize ) { cli_dbgmsg ( ""Upack:Can\'treadrawdataofsection0\\n"" ) ; free ( dest ) ; break ; } if ( upack ) memmove ( dest + exe_sections [ 2 ] . rva - exe_sections [ 0 ] . rva , dest , ssize ) ; if ( ( unsigned int ) fmap_readn ( map , dest + exe_sections [ 1 ] . rva - off , exe_sections [ 1 ] . uraw , exe_sections [ 1 ] . ursz ) != exe_sections [ 1 ] . ursz ) { cli_dbgmsg ( ""Upack:Can\'treadrawdataofsection1\\n"" ) ; free ( dest ) ; break ; } # if HAVE_JSON cli_jsonstr ( pe_json , ""Packer"" , ""Upack"" ) ; # endif CLI_UNPTEMP ( ""Upack"" , ( dest , exe_sections , 0 ) ) ; CLI_UNPRESULTS ( ""Upack"" , ( unupack ( upack , dest , dsize , epbuff , vma , ep , EC32 ( optional_hdr32 . ImageBase ) , exe_sections [ 0 ] . rva , ndesc ) ) , 1 , ( dest , 0 ) ) ; break ; } } while ( found && ( DCONF & PE_CONF_FSG ) && epbuff [ 0 ] == '\\x87' && epbuff [ 1 ] == '\\x25' ) { const char * dst ; uint32_t newesi , newedi , newebx , newedx ; ssize = exe_sections [ i + 1 ] . rsz ; dsize = exe_sections [ i ] . vsz ; CLI_UNPSIZELIMITS ( ""FSG"" , MAX ( dsize , ssize ) ) ; if ( ssize <= 0x19 || dsize <= ssize ) { cli_dbgmsg ( ""FSG:Sizemismatch(ssize:%d,dsize:%d)\\n"" , ssize , dsize ) ; free ( exe_sections ) ; return CL_CLEAN ; } newedx = cli_readint32 ( epbuff + 2 ) - EC32 ( optional_hdr32 . ImageBase ) ; if ( ! CLI_ISCONTAINED ( exe_sections [ i + 1 ] . rva , exe_sections [ i + 1 ] . rsz , newedx , 4 ) ) { cli_dbgmsg ( ""FSG:xchgoutofbounds(%x),givingup\\n"" , newedx ) ; break ; } if ( ! exe_sections [ i + 1 ] . rsz || ! ( src = fmap_need_off_once ( map , exe_sections [ i + 1 ] . raw , ssize ) ) ) { cli_dbgmsg ( ""Can\'treadrawdataofsection%d\\n"" , i + 1 ) ; free ( exe_sections ) ; return CL_ESEEK ; } dst = src + newedx - exe_sections [ i + 1 ] . rva ; if ( newedx < exe_sections [ i + 1 ] . rva || ! CLI_ISCONTAINED ( src , ssize , dst , 4 ) ) { cli_dbgmsg ( ""FSG:NewESPoutofbounds\\n"" ) ; break ; } newedx = cli_readint32 ( dst ) - EC32 ( optional_hdr32 . ImageBase ) ; if ( ! CLI_ISCONTAINED ( exe_sections [ i + 1 ] . rva , exe_sections [ i + 1 ] . rsz , newedx , 4 ) ) { cli_dbgmsg ( ""FSG:NewESP(%x)iswrong\\n"" , newedx ) ; break ; } dst = src + newedx - exe_sections [ i + 1 ] . rva ; if ( ! CLI_ISCONTAINED ( src , ssize , dst , 32 ) ) { cli_dbgmsg ( ""FSG:Newstackoutofbounds\\n"" ) ; break ; } newedi = cli_readint32 ( dst ) - EC32 ( optional_hdr32 . ImageBase ) ; newesi = cli_readint32 ( dst + 4 ) - EC32 ( optional_hdr32 . ImageBase ) ; newebx = cli_readint32 ( dst + 16 ) - EC32 ( optional_hdr32 . ImageBase ) ; newedx = cli_readint32 ( dst + 20 ) ; if ( newedi != exe_sections [ i ] . rva ) { cli_dbgmsg ( ""FSG:Baddestinationbuffer(ediis%xshouldbe%x)\\n"" , newedi , exe_sections [ i ] . rva ) ; break ; } if ( newesi < exe_sections [ i + 1 ] . rva || newesi - exe_sections [ i + 1 ] . rva >= exe_sections [ i + 1 ] . rsz ) { cli_dbgmsg ( ""FSG:Sourcebufferoutofsectionbounds\\n"" ) ; break ; } if ( ! CLI_ISCONTAINED ( exe_sections [ i + 1 ] . rva , exe_sections [ i + 1 ] . rsz , newebx , 16 ) ) { cli_dbgmsg ( ""FSG:Arrayoffunctionsoutofbounds\\n"" ) ; break ; } newedx = cli_readint32 ( newebx + 12 - exe_sections [ i + 1 ] . rva + src ) - EC32 ( optional_hdr32 . ImageBase ) ; cli_dbgmsg ( ""FSG:foundoldEP@%x\\n"" , newedx ) ; if ( ( dest = ( char * ) cli_calloc ( dsize , sizeof ( char ) ) ) == NULL ) { free ( exe_sections ) ; return CL_EMEM ; } # if HAVE_JSON cli_jsonstr ( pe_json , ""Packer"" , ""FSG"" ) ; # endif CLI_UNPTEMP ( ""FSG"" , ( dest , exe_sections , 0 ) ) ; CLI_UNPRESULTSFSG2 ( ""FSG"" , ( unfsg_200 ( newesi - exe_sections [ i + 1 ] . rva + src , dest , ssize + exe_sections [ i + 1 ] . rva - newesi , dsize , newedi , EC32 ( optional_hdr32 . ImageBase ) , newedx , ndesc ) ) , 1 , ( dest , 0 ) ) ; break ; } while ( found && ( DCONF & PE_CONF_FSG ) && epbuff [ 0 ] == '\\xbe' && cli_readint32 ( epbuff + 1 ) - EC32 ( optional_hdr32 . ImageBase ) < min ) { int sectcnt = 0 ; const char * support ; uint32_t newesi , newedi , oldep , gp , t ; struct cli_exe_section * sections ; ssize = exe_sections [ i + 1 ] . rsz ; dsize = exe_sections [ i ] . vsz ; CLI_UNPSIZELIMITS ( ""FSG"" , MAX ( dsize , ssize ) ) ; if ( ssize <= 0x19 || dsize <= ssize ) { cli_dbgmsg ( ""FSG:Sizemismatch(ssize:%d,dsize:%d)\\n"" , ssize , dsize ) ; free ( exe_sections ) ; return CL_CLEAN ; } if ( ! ( t = cli_rawaddr ( cli_readint32 ( epbuff + 1 ) - EC32 ( optional_hdr32 . ImageBase ) , NULL , 0 , & err , fsize , hdr_size ) ) && err ) { cli_dbgmsg ( ""FSG:Supportdataoutofpaddingarea\\n"" ) ; break ; } gp = exe_sections [ i + 1 ] . raw - t ; CLI_UNPSIZELIMITS ( ""FSG"" , gp ) ; if ( ! ( support = fmap_need_off_once ( map , t , gp ) ) ) { cli_dbgmsg ( ""Can\'tread%dbytesfrompaddingarea\\n"" , gp ) ; free ( exe_sections ) ; return CL_EREAD ; } newedi = cli_readint32 ( support + 4 ) - EC32 ( optional_hdr32 . ImageBase ) ; newesi = cli_readint32 ( support + 8 ) - EC32 ( optional_hdr32 . ImageBase ) ; if ( newesi < exe_sections [ i + 1 ] . rva || newesi - exe_sections [ i + 1 ] . rva >= exe_sections [ i + 1 ] . rsz ) { cli_dbgmsg ( ""FSG:Sourcebufferoutofsectionbounds\\n"" ) ; break ; } if ( newedi != exe_sections [ i ] . rva ) { cli_dbgmsg ( ""FSG:Baddestination(is%xshouldbe%x)\\n"" , newedi , exe_sections [ i ] . rva ) ; break ; } for ( t = 12 ; t < gp - 4 ; t += 4 ) { uint32_t rva = cli_readint32 ( support + t ) ; if ( ! rva ) break ; rva -= EC32 ( optional_hdr32 . ImageBase ) + 1 ; sectcnt ++ ; if ( rva % 0x1000 ) cli_dbgmsg ( ""FSG:Originalsection%dismisaligned\\n"" , sectcnt ) ; if ( rva < exe_sections [ i ] . rva || rva - exe_sections [ i ] . rva >= exe_sections [ i ] . vsz ) { cli_dbgmsg ( ""FSG:Originalsection%disoutofbounds\\n"" , sectcnt ) ; break ; } } if ( t >= gp - 4 || cli_readint32 ( support + t ) ) { break ; } if ( ( sections = ( struct cli_exe_section * ) cli_malloc ( ( sectcnt + 1 ) * sizeof ( struct cli_exe_section ) ) ) == NULL ) { cli_errmsg ( ""FSG:Unabletoallocatememoryforsections%lu\\n"" , ( sectcnt + 1 ) * sizeof ( struct cli_exe_section ) ) ; free ( exe_sections ) ; return CL_EMEM ; } sections [ 0 ] . rva = newedi ; for ( t = 1 ; t <= ( uint32_t ) sectcnt ; t ++ ) sections [ t ] . rva = cli_readint32 ( support + 8 + t * 4 ) - 1 - EC32 ( optional_hdr32 . ImageBase ) ; if ( ! exe_sections [ i + 1 ] . rsz || ! ( src = fmap_need_off_once ( map , exe_sections [ i + 1 ] . raw , ssize ) ) ) { cli_dbgmsg ( ""Can\'treadrawdataofsection%d\\n"" , i ) ; free ( exe_sections ) ; free ( sections ) ; return CL_EREAD ; } if ( ( dest = ( char * ) cli_calloc ( dsize , sizeof ( char ) ) ) == NULL ) { free ( exe_sections ) ; free ( sections ) ; return CL_EMEM ; } oldep = vep + 161 + 6 + cli_readint32 ( epbuff + 163 ) ; cli_dbgmsg ( ""FSG:foundoldEP@%x\\n"" , oldep ) ; # if HAVE_JSON cli_jsonstr ( pe_json , ""Packer"" , ""FSG"" ) ; # endif CLI_UNPTEMP ( ""FSG"" , ( dest , sections , exe_sections , 0 ) ) ; CLI_UNPRESULTSFSG1 ( ""FSG"" , ( unfsg_133 ( src + newesi - exe_sections [ i + 1 ] . rva , dest , ssize + exe_sections [ i + 1 ] . rva - newesi , dsize , sections , sectcnt , EC32 ( optional_hdr32 . ImageBase ) , oldep , ndesc ) ) , 1 , ( dest , sections , 0 ) ) ; break ; } while ( found && ( DCONF & PE_CONF_FSG ) && epbuff [ 0 ] == '\\xbb' && cli_readint32 ( epbuff + 1 ) - EC32 ( optional_hdr32 . ImageBase ) < min && epbuff [ 5 ] == '\\xbf' && epbuff [ 10 ] == '\\xbe' && vep >= exe_sections [ i + 1 ] . rva && vep - exe_sections [ i + 1 ] . rva > exe_sections [ i + 1 ] . rva - 0xe0 ) { int sectcnt = 0 ; uint32_t gp , t = cli_rawaddr ( cli_readint32 ( epbuff + 1 ) - EC32 ( optional_hdr32 . ImageBase ) , NULL , 0 , & err , fsize , hdr_size ) ; const char * support ; uint32_t newesi = cli_readint32 ( epbuff + 11 ) - EC32 ( optional_hdr32 . ImageBase ) ; uint32_t newedi = cli_readint32 ( epbuff + 6 ) - EC32 ( optional_hdr32 . ImageBase ) ; uint32_t oldep = vep - exe_sections [ i + 1 ] . rva ; struct cli_exe_section * sections ; ssize = exe_sections [ i + 1 ] . rsz ; dsize = exe_sections [ i ] . vsz ; if ( err ) { cli_dbgmsg ( ""FSG:Supportdataoutofpaddingarea\\n"" ) ; break ; } if ( newesi < exe_sections [ i + 1 ] . rva || newesi - exe_sections [ i + 1 ] . rva >= exe_sections [ i + 1 ] . raw ) { cli_dbgmsg ( ""FSG:Sourcebufferoutofsectionbounds\\n"" ) ; break ; } if ( newedi != exe_sections [ i ] . rva ) { cli_dbgmsg ( ""FSG:Baddestination(is%xshouldbe%x)\\n"" , newedi , exe_sections [ i ] . rva ) ; break ; } CLI_UNPSIZELIMITS ( ""FSG"" , MAX ( dsize , ssize ) ) ; if ( ssize <= 0x19 || dsize <= ssize ) { cli_dbgmsg ( ""FSG:Sizemismatch(ssize:%d,dsize:%d)\\n"" , ssize , dsize ) ; free ( exe_sections ) ; return CL_CLEAN ; } gp = exe_sections [ i + 1 ] . raw - t ; CLI_UNPSIZELIMITS ( ""FSG"" , gp ) if ( ! ( support = fmap_need_off_once ( map , t , gp ) ) ) { cli_dbgmsg ( ""Can\'tread%dbytesfrompaddingarea\\n"" , gp ) ; free ( exe_sections ) ; return CL_EREAD ; } for ( t = 0 ; t < gp - 2 ; t += 2 ) { uint32_t rva = support [ t ] | ( support [ t + 1 ] << 8 ) ; if ( rva == 2 || rva == 1 ) break ; rva = ( ( rva - 2 ) << 12 ) - EC32 ( optional_hdr32 . ImageBase ) ; sectcnt ++ ; if ( rva < exe_sections [ i ] . rva || rva - exe_sections [ i ] . rva >= exe_sections [ i ] . vsz ) { cli_dbgmsg ( ""FSG:Originalsection%disoutofbounds\\n"" , sectcnt ) ; break ; } } if ( t >= gp - 10 || cli_readint32 ( support + t + 6 ) != 2 ) { break ; } if ( ( sections = ( struct cli_exe_section * ) cli_malloc ( ( sectcnt + 1 ) * sizeof ( struct cli_exe_section ) ) ) == NULL ) { cli_errmsg ( ""FSG:Unabletoallocatememoryforsections%lu\\n"" , ( sectcnt + 1 ) * sizeof ( struct cli_exe_section ) ) ; free ( exe_sections ) ; return CL_EMEM ; } sections [ 0 ] . rva = newedi ; for ( t = 0 ; t <= ( uint32_t ) sectcnt - 1 ; t ++ ) { sections [ t + 1 ] . rva = ( ( ( support [ t * 2 ] | ( support [ t * 2 + 1 ] << 8 ) ) - 2 ) << 12 ) - EC32 ( optional_hdr32 . ImageBase ) ; } if ( ! exe_sections [ i + 1 ] . rsz || ! ( src = fmap_need_off_once ( map , exe_sections [ i + 1 ] . raw , ssize ) ) ) { cli_dbgmsg ( ""FSG:Can\'treadrawdataofsection%d\\n"" , i ) ; free ( exe_sections ) ; free ( sections ) ; return CL_EREAD ; } if ( ( dest = ( char * ) cli_calloc ( dsize , sizeof ( char ) ) ) == NULL ) { free ( exe_sections ) ; free ( sections ) ; return CL_EMEM ; } gp = 0xda + 6 * ( epbuff [ 16 ] == '\\xe8' ) ; oldep = vep + gp + 6 + cli_readint32 ( src + gp + 2 + oldep ) ; cli_dbgmsg ( ""FSG:foundoldEP@%x\\n"" , oldep ) ; # if HAVE_JSON cli_jsonstr ( pe_json , ""Packer"" , ""FSG"" ) ; # endif CLI_UNPTEMP ( ""FSG"" , ( dest , sections , exe_sections , 0 ) ) ; CLI_UNPRESULTSFSG1 ( ""FSG"" , ( unfsg_133 ( src + newesi - exe_sections [ i + 1 ] . rva , dest , ssize + exe_sections [ i + 1 ] . rva - newesi , dsize , sections , sectcnt , EC32 ( optional_hdr32 . ImageBase ) , oldep , ndesc ) ) , 1 , ( dest , sections , 0 ) ) ; break ; } if ( found && ( DCONF & PE_CONF_UPX ) ) { ssize = exe_sections [ i + 1 ] . rsz ; dsize = exe_sections [ i ] . vsz + exe_sections [ i + 1 ] . vsz ; CLI_UNPSIZELIMITS ( ""UPX"" , MAX ( dsize , ssize ) ) ; if ( ssize <= 0x19 || dsize <= ssize || dsize > CLI_MAX_ALLOCATION ) { cli_dbgmsg ( ""UPX:Sizemismatchordsizetoobig(ssize:%d,dsize:%d)\\n"" , ssize , dsize ) ; free ( exe_sections ) ; return CL_CLEAN ; } if ( ! exe_sections [ i + 1 ] . rsz || ! ( src = fmap_need_off_once ( map , exe_sections [ i + 1 ] . raw , ssize ) ) ) { cli_dbgmsg ( ""UPX:Can\'treadrawdataofsection%d\\n"" , i + 1 ) ; free ( exe_sections ) ; return CL_EREAD ; } if ( ( dest = ( char * ) cli_calloc ( dsize + 8192 , sizeof ( char ) ) ) == NULL ) { free ( exe_sections ) ; return CL_EMEM ; } if ( cli_memstr ( UPX_NRV2B , 24 , epbuff + 0x69 , 13 ) || cli_memstr ( UPX_NRV2B , 24 , epbuff + 0x69 + 8 , 13 ) ) { cli_dbgmsg ( ""UPX:LookslikeaNRV2Bdecompressionroutine\\n"" ) ; upxfn = upx_inflate2b ; } else if ( cli_memstr ( UPX_NRV2D , 24 , epbuff + 0x69 , 13 ) || cli_memstr ( UPX_NRV2D , 24 , epbuff + 0x69 + 8 , 13 ) ) { cli_dbgmsg ( ""UPX:LookslikeaNRV2Ddecompressionroutine\\n"" ) ; upxfn = upx_inflate2d ; } else if ( cli_memstr ( UPX_NRV2E , 24 , epbuff + 0x69 , 13 ) || cli_memstr ( UPX_NRV2E , 24 , epbuff + 0x69 + 8 , 13 ) ) { cli_dbgmsg ( ""UPX:LookslikeaNRV2Edecompressionroutine\\n"" ) ; upxfn = upx_inflate2e ; } if ( upxfn ) { int skew = cli_readint32 ( epbuff + 2 ) - EC32 ( optional_hdr32 . ImageBase ) - exe_sections [ i + 1 ] . rva ; if ( epbuff [ 1 ] != '\\xbe' || skew <= 0 || skew > 0xfff ) { skew = 0 ; } else if ( ( unsigned int ) skew > ssize ) { skew = 0 ; } else { cli_dbgmsg ( ""UPX:UPX1seemsskewedby%dbytes\\n"" , skew ) ; } if ( upxfn ( src + skew , ssize - skew , dest , & dsize , exe_sections [ i ] . rva , exe_sections [ i + 1 ] . rva , vep - skew ) >= 0 ) { upx_success = 1 ; } else if ( skew && ( upxfn ( src , ssize , dest , & dsize , exe_sections [ i ] . rva , exe_sections [ i + 1 ] . rva , vep ) >= 0 ) ) { upx_success = 1 ; } if ( upx_success ) cli_dbgmsg ( ""UPX:Successfullydecompressed\\n"" ) ; else cli_dbgmsg ( ""UPX:Preferreddecompressorfailed\\n"" ) ; } if ( ! upx_success && upxfn != upx_inflate2b ) { if ( upx_inflate2b ( src , ssize , dest , & dsize , exe_sections [ i ] . rva , exe_sections [ i + 1 ] . rva , vep ) == - 1 && upx_inflate2b ( src + 0x15 , ssize - 0x15 , dest , & dsize , exe_sections [ i ] . rva , exe_sections [ i + 1 ] . rva , vep - 0x15 ) == - 1 ) { cli_dbgmsg ( ""UPX:NRV2Bdecompressorfailed\\n"" ) ; } else { upx_success = 1 ; cli_dbgmsg ( ""UPX:SuccessfullydecompressedwithNRV2B\\n"" ) ; } } if ( ! upx_success && upxfn != upx_inflate2d ) { if ( upx_inflate2d ( src , ssize , dest , & dsize , exe_sections [ i ] . rva , exe_sections [ i + 1 ] . rva , vep ) == - 1 && upx_inflate2d ( src + 0x15 , ssize - 0x15 , dest , & dsize , exe_sections [ i ] . rva , exe_sections [ i + 1 ] . rva , vep - 0x15 ) == - 1 ) { cli_dbgmsg ( ""UPX:NRV2Ddecompressorfailed\\n"" ) ; } else { upx_success = 1 ; cli_dbgmsg ( ""UPX:SuccessfullydecompressedwithNRV2D\\n"" ) ; } } if ( ! upx_success && upxfn != upx_inflate2e ) { if ( upx_inflate2e ( src , ssize , dest , & dsize , exe_sections [ i ] . rva , exe_sections [ i + 1 ] . rva , vep ) == - 1 && upx_inflate2e ( src + 0x15 , ssize - 0x15 , dest , & dsize , exe_sections [ i ] . rva , exe_sections [ i + 1 ] . rva , vep - 0x15 ) == - 1 ) { cli_dbgmsg ( ""UPX:NRV2Edecompressorfailed\\n"" ) ; } else { upx_success = 1 ; cli_dbgmsg ( ""UPX:SuccessfullydecompressedwithNRV2E\\n"" ) ; } } if ( cli_memstr ( UPX_LZMA2 , 20 , epbuff + 0x2f , 20 ) ) { uint32_t strictdsize = cli_readint32 ( epbuff + 0x21 ) , skew = 0 ; if ( ssize > 0x15 && epbuff [ 0 ] == '\\x60' && epbuff [ 1 ] == '\\xbe' ) { skew = cli_readint32 ( epbuff + 2 ) - exe_sections [ i + 1 ] . rva - optional_hdr32 . ImageBase ; if ( skew != 0x15 ) skew = 0 ; } if ( strictdsize <= dsize ) upx_success = upx_inflatelzma ( src + skew , ssize - skew , dest , & strictdsize , exe_sections [ i ] . rva , exe_sections [ i + 1 ] . rva , vep ) >= 0 ; } else if ( cli_memstr ( UPX_LZMA1 , 20 , epbuff + 0x39 , 20 ) ) { uint32_t strictdsize = cli_readint32 ( epbuff + 0x2b ) , skew = 0 ; if ( ssize > 0x15 && epbuff [ 0 ] == '\\x60' && epbuff [ 1 ] == '\\xbe' ) { skew = cli_readint32 ( epbuff + 2 ) - exe_sections [ i + 1 ] . rva - optional_hdr32 . ImageBase ; if ( skew != 0x15 ) skew = 0 ; } if ( strictdsize <= dsize ) upx_success = upx_inflatelzma ( src + skew , ssize - skew , dest , & strictdsize , exe_sections [ i ] . rva , exe_sections [ i + 1 ] . rva , vep ) >= 0 ; } if ( ! upx_success ) { cli_dbgmsg ( ""UPX:Alldecompressorsfailed\\n"" ) ; free ( dest ) ; } } if ( upx_success ) { free ( exe_sections ) ; CLI_UNPTEMP ( ""UPX/FSG"" , ( dest , 0 ) ) ; # if HAVE_JSON cli_jsonstr ( pe_json , ""Packer"" , ""UPX"" ) ; # endif if ( ( unsigned int ) write ( ndesc , dest , dsize ) != dsize ) { cli_dbgmsg ( ""UPX/FSG:Can\'twrite%dbytes\\n"" , dsize ) ; free ( tempfile ) ; free ( dest ) ; close ( ndesc ) ; return CL_EWRITE ; } free ( dest ) ; if ( lseek ( ndesc , 0 , SEEK_SET ) == - 1 ) { cli_dbgmsg ( ""UPX/FSG:lseek()failed\\n"" ) ; close ( ndesc ) ; CLI_TMPUNLK ( ) ; free ( tempfile ) ; SHA_RESET ; return CL_ESEEK ; } if ( ctx -> engine -> keeptmp ) cli_dbgmsg ( ""UPX/FSG:Decompresseddatasavedin%s\\n"" , tempfile ) ; cli_dbgmsg ( ""*****Scanningdecompressedfile*****\\n"" ) ; SHA_OFF ; if ( ( ret = cli_magic_scandesc ( ndesc , ctx ) ) == CL_VIRUS ) { close ( ndesc ) ; CLI_TMPUNLK ( ) ; free ( tempfile ) ; SHA_RESET ; return CL_VIRUS ; } SHA_RESET ; close ( ndesc ) ; CLI_TMPUNLK ( ) ; free ( tempfile ) ; return ret ; } if ( epsize < 200 ) { free ( exe_sections ) ; return CL_CLEAN ; } found = 2 ; if ( epbuff [ 0 ] != '\\xb8' || ( uint32_t ) cli_readint32 ( epbuff + 1 ) != exe_sections [ nsections - 1 ] . rva + EC32 ( optional_hdr32 . ImageBase ) ) { if ( nsections < 2 || epbuff [ 0 ] != '\\xb8' || ( uint32_t ) cli_readint32 ( epbuff + 1 ) != exe_sections [ nsections - 2 ] . rva + EC32 ( optional_hdr32 . ImageBase ) ) found = 0 ; else found = 1 ; } if ( found && ( DCONF & PE_CONF_PETITE ) ) { cli_dbgmsg ( ""Petite:v2.%dcompressiondetected\\n"" , found ) ; if ( cli_readint32 ( epbuff + 0x80 ) == 0x163c988d ) { cli_dbgmsg ( ""Petite:levelzerocompressionisnotsupportedyet\\n"" ) ; } else { dsize = max - min ; CLI_UNPSIZELIMITS ( ""Petite"" , dsize ) ; if ( ( dest = ( char * ) cli_calloc ( dsize , sizeof ( char ) ) ) == NULL ) { cli_dbgmsg ( ""Petite:Can\'tallocate%dbytes\\n"" , dsize ) ; free ( exe_sections ) ; return CL_EMEM ; } for ( i = 0 ; i < nsections ; i ++ ) { if ( exe_sections [ i ] . raw ) { if ( ! exe_sections [ i ] . rsz || ( unsigned int ) fmap_readn ( map , dest + exe_sections [ i ] . rva - min , exe_sections [ i ] . raw , exe_sections [ i ] . ursz ) != exe_sections [ i ] . ursz ) { free ( exe_sections ) ; free ( dest ) ; return CL_CLEAN ; } } } # if HAVE_JSON cli_jsonstr ( pe_json , ""Packer"" , ""Petite"" ) ; # endif CLI_UNPTEMP ( ""Petite"" , ( dest , exe_sections , 0 ) ) ; CLI_UNPRESULTS ( ""Petite"" , ( petite_inflate2x_1to9 ( dest , min , max - min , exe_sections , nsections - ( found == 1 ? 1 : 0 ) , EC32 ( optional_hdr32 . ImageBase ) , vep , ndesc , found , EC32 ( optional_hdr32 . DataDirectory [ 2 ] . VirtualAddress ) , EC32 ( optional_hdr32 . DataDirectory [ 2 ] . Size ) ) ) , 0 , ( dest , 0 ) ) ; } } if ( ( DCONF & PE_CONF_PESPIN ) && nsections > 1 && vep >= exe_sections [ nsections - 1 ] . rva && vep < exe_sections [ nsections - 1 ] . rva + exe_sections [ nsections - 1 ] . rsz - 0x3217 - 4 && memcmp ( epbuff + 4 , ""\\xe8\\x00\\x00\\x00\\x00\\x8b\\x1c\\x24\\x83\\xc3"" , 10 ) == 0 ) { char * spinned ; CLI_UNPSIZELIMITS ( ""PEspin"" , fsize ) ; if ( ( spinned = ( char * ) cli_malloc ( fsize ) ) == NULL ) { cli_errmsg ( ""PESping:Unabletoallocatememoryforspinned%lu\\n"" , ( unsigned long ) fsize ) ; free ( exe_sections ) ; return CL_EMEM ; } if ( ( size_t ) fmap_readn ( map , spinned , 0 , fsize ) != fsize ) { cli_dbgmsg ( ""PESpin:Can\'tread%lubytes\\n"" , ( unsigned long ) fsize ) ; free ( spinned ) ; free ( exe_sections ) ; return CL_EREAD ; } # if HAVE_JSON cli_jsonstr ( pe_json , ""Packer"" , ""PEspin"" ) ; # endif CLI_UNPTEMP ( ""PESpin"" , ( spinned , exe_sections , 0 ) ) ; CLI_UNPRESULTS_ ( ""PEspin"" , SPINCASE ( ) , ( unspin ( spinned , fsize , exe_sections , nsections - 1 , vep , ndesc , ctx ) ) , 0 , ( spinned , 0 ) ) ; } if ( ( DCONF & PE_CONF_YC ) && nsections > 1 && ( EC32 ( optional_hdr32 . AddressOfEntryPoint ) == exe_sections [ nsections - 1 ] . rva + 0x60 ) ) { uint32_t ecx = 0 ; int16_t offset ; if ( ! memcmp ( epbuff , ""\\x55\\x8B\\xEC\\x53\\x56\\x57\\x60\\xE8\\x00\\x00\\x00\\x00\\x5D\\x81\\xED"" , 15 ) && ! memcmp ( epbuff + 0x26 , ""\\x8D\\x3A\\x8B\\xF7\\x33\\xC0\\xEB\\x04\\x90\\xEB\\x01\\xC2\\xAC"" , 13 ) && ( ( uint8_t ) epbuff [ 0x13 ] == 0xB9 ) && ( ( uint16_t ) ( cli_readint16 ( epbuff + 0x18 ) ) == 0xE981 ) && ! memcmp ( epbuff + 0x1e , ""\\x8B\\xD5\\x81\\xC2"" , 4 ) ) { offset = 0 ; if ( 0x6c - cli_readint32 ( epbuff + 0xf ) + cli_readint32 ( epbuff + 0x22 ) == 0xC6 ) ecx = cli_readint32 ( epbuff + 0x14 ) - cli_readint32 ( epbuff + 0x1a ) ; } if ( ! ecx && ! memcmp ( epbuff , ""\\x55\\x8B\\xEC\\x83\\xEC\\x40\\x53\\x56\\x57"" , 9 ) && ! memcmp ( epbuff + 0x17 , ""\\xe8\\x00\\x00\\x00\\x00\\x5d\\x81\\xed"" , 8 ) && ( ( uint8_t ) epbuff [ 0x23 ] == 0xB9 ) ) { offset = 0x10 ; if ( 0x6c - cli_readint32 ( epbuff + 0x1f ) + cli_readint32 ( epbuff + 0x32 ) == 0xC6 ) ecx = cli_readint32 ( epbuff + 0x24 ) - cli_readint32 ( epbuff + 0x2a ) ; } if ( ! ecx && ! memcmp ( epbuff , ""\\x60\\xe8\\x00\\x00\\x00\\x00\\x5d\\x81\\xed"" , 9 ) && ( ( uint8_t ) epbuff [ 0xd ] == 0xb9 ) && ( ( uint16_t ) cli_readint16 ( epbuff + 0x12 ) == 0xbd8d ) && ! memcmp ( epbuff + 0x18 , ""\\x8b\\xf7\\xac"" , 3 ) ) { offset = - 0x18 ; if ( 0x66 - cli_readint32 ( epbuff + 0x9 ) + cli_readint32 ( epbuff + 0x14 ) == 0xae ) ecx = cli_readint32 ( epbuff + 0xe ) ; } if ( ecx > 0x800 && ecx < 0x2000 && ! memcmp ( epbuff + 0x63 + offset , ""\\xaa\\xe2\\xcc"" , 3 ) && ( fsize >= exe_sections [ nsections - 1 ] . raw + 0xC6 + ecx + offset ) ) { char * spinned ; if ( ( spinned = ( char * ) cli_malloc ( fsize ) ) == NULL ) { cli_errmsg ( ""yC:Unabletoallocatememoryforspinned%lu\\n"" , ( unsigned long ) fsize ) ; free ( exe_sections ) ; return CL_EMEM ; } if ( ( size_t ) fmap_readn ( map , spinned , 0 , fsize ) != fsize ) { cli_dbgmsg ( ""yC:Can\'tread%lubytes\\n"" , ( unsigned long ) fsize ) ; free ( spinned ) ; free ( exe_sections ) ; return CL_EREAD ; } # if HAVE_JSON cli_jsonstr ( pe_json , ""Packer"" , ""yC"" ) ; # endif cli_dbgmsg ( ""%d,%d,%d,%d\\n"" , nsections - 1 , e_lfanew , ecx , offset ) ; CLI_UNPTEMP ( ""yC"" , ( spinned , exe_sections , 0 ) ) ; CLI_UNPRESULTS ( ""yC"" , ( yc_decrypt ( spinned , fsize , exe_sections , nsections - 1 , e_lfanew , ndesc , ecx , offset ) ) , 0 , ( spinned , 0 ) ) ; } } while ( ( DCONF & PE_CONF_WWPACK ) && nsections > 1 && vep == exe_sections [ nsections - 1 ] . rva && memcmp ( epbuff , ""\\x53\\x55\\x8b\\xe8\\x33\\xdb\\xeb"" , 7 ) == 0 && memcmp ( epbuff + 0x68 , ""\\xe8\\x00\\x00\\x00\\x00\\x58\\x2d\\x6d\\x00\\x00\\x00\\x50\\x60\\x33\\xc9\\x50\\x58\\x50\\x50"" , 19 ) == 0 ) { uint32_t head = exe_sections [ nsections - 1 ] . raw ; uint8_t * packer ; char * src ; ssize = 0 ; for ( i = 0 ; ; i ++ ) { if ( exe_sections [ i ] . raw < head ) head = exe_sections [ i ] . raw ; if ( i + 1 == nsections ) break ; if ( ssize < exe_sections [ i ] . rva + exe_sections [ i ] . vsz ) ssize = exe_sections [ i ] . rva + exe_sections [ i ] . vsz ; } if ( ! head || ! ssize || head > ssize ) break ; CLI_UNPSIZELIMITS ( ""WWPack"" , ssize ) ; if ( ! ( src = ( char * ) cli_calloc ( ssize , sizeof ( char ) ) ) ) { free ( exe_sections ) ; return CL_EMEM ; } if ( ( size_t ) fmap_readn ( map , src , 0 , head ) != head ) { cli_dbgmsg ( ""WWPack:Can\'tread%dbytesfromheaders\\n"" , head ) ; free ( src ) ; free ( exe_sections ) ; return CL_EREAD ; } for ( i = 0 ; i < ( unsigned int ) nsections - 1 ; i ++ ) { if ( ! exe_sections [ i ] . rsz ) continue ; if ( ! CLI_ISCONTAINED ( src , ssize , src + exe_sections [ i ] . rva , exe_sections [ i ] . rsz ) ) break ; if ( ( unsigned int ) fmap_readn ( map , src + exe_sections [ i ] . rva , exe_sections [ i ] . raw , exe_sections [ i ] . rsz ) != exe_sections [ i ] . rsz ) break ; } if ( i + 1 != nsections ) { cli_dbgmsg ( ""WWpack:Probablyhacked/damagedfile.\\n"" ) ; free ( src ) ; break ; } if ( ( packer = ( uint8_t * ) cli_calloc ( exe_sections [ nsections - 1 ] . rsz , sizeof ( char ) ) ) == NULL ) { free ( src ) ; free ( exe_sections ) ; return CL_EMEM ; } if ( ! exe_sections [ nsections - 1 ] . rsz || ( size_t ) fmap_readn ( map , packer , exe_sections [ nsections - 1 ] . raw , exe_sections [ nsections - 1 ] . rsz ) != exe_sections [ nsections - 1 ] . rsz ) { cli_dbgmsg ( ""WWPack:Can\'tread%dbytesfromwwpacksect\\n"" , exe_sections [ nsections - 1 ] . rsz ) ; free ( src ) ; free ( packer ) ; free ( exe_sections ) ; return CL_EREAD ; } # if HAVE_JSON cli_jsonstr ( pe_json , ""Packer"" , ""WWPack"" ) ; # endif CLI_UNPTEMP ( ""WWPack"" , ( src , packer , exe_sections , 0 ) ) ; CLI_UNPRESULTS ( ""WWPack"" , ( wwunpack ( ( uint8_t * ) src , ssize , packer , exe_sections , nsections - 1 , e_lfanew , ndesc ) ) , 0 , ( src , packer , 0 ) ) ; break ; } while ( ( DCONF & PE_CONF_ASPACK ) && ep + 58 + 0x70e < fsize && ! memcmp ( epbuff , ""\\x60\\xe8\\x03\\x00\\x00\\x00\\xe9\\xeb"" , 8 ) ) { char * src ; if ( epsize < 0x3bf || memcmp ( epbuff + 0x3b9 , ""\\x68\\x00\\x00\\x00\\x00\\xc3"" , 6 ) ) break ; ssize = 0 ; for ( i = 0 ; i < nsections ; i ++ ) if ( ssize < exe_sections [ i ] . rva + exe_sections [ i ] . vsz ) ssize = exe_sections [ i ] . rva + exe_sections [ i ] . vsz ; if ( ! ssize ) break ; CLI_UNPSIZELIMITS ( ""Aspack"" , ssize ) ; if ( ! ( src = ( char * ) cli_calloc ( ssize , sizeof ( char ) ) ) ) { free ( exe_sections ) ; return CL_EMEM ; } for ( i = 0 ; i < ( unsigned int ) nsections ; i ++ ) { if ( ! exe_sections [ i ] . rsz ) continue ; if ( ! CLI_ISCONTAINED ( src , ssize , src + exe_sections [ i ] . rva , exe_sections [ i ] . rsz ) ) break ; if ( ( unsigned int ) fmap_readn ( map , src + exe_sections [ i ] . rva , exe_sections [ i ] . raw , exe_sections [ i ] . rsz ) != exe_sections [ i ] . rsz ) break ; } if ( i != nsections ) { cli_dbgmsg ( ""Aspack:Probablyhacked/damagedAspackfile.\\n"" ) ; free ( src ) ; break ; } # if HAVE_JSON cli_jsonstr ( pe_json , ""Packer"" , ""Aspack"" ) ; # endif CLI_UNPTEMP ( ""Aspack"" , ( src , exe_sections , 0 ) ) ; CLI_UNPRESULTS ( ""Aspack"" , ( unaspack212 ( ( uint8_t * ) src , ssize , exe_sections , nsections , vep - 1 , EC32 ( optional_hdr32 . ImageBase ) , ndesc ) ) , 1 , ( src , 0 ) ) ; break ; } while ( DCONF & PE_CONF_NSPACK ) { uint32_t eprva = vep ; uint32_t start_of_stuff , rep = ep ; unsigned int nowinldr ; const char * nbuff ; src = epbuff ; if ( * epbuff == '\\xe9' ) { eprva = cli_readint32 ( epbuff + 1 ) + vep + 5 ; if ( ! ( rep = cli_rawaddr ( eprva , exe_sections , nsections , & err , fsize , hdr_size ) ) && err ) break ; if ( ! ( nbuff = fmap_need_off_once ( map , rep , 24 ) ) ) break ; src = nbuff ; } if ( memcmp ( src , ""\\x9c\\x60\\xe8\\x00\\x00\\x00\\x00\\x5d\\xb8\\x07\\x00\\x00\\x00"" , 13 ) ) break ; nowinldr = 0x54 - cli_readint32 ( src + 17 ) ; cli_dbgmsg ( ""NsPack:Found*start_of_stuff@delta-%x\\n"" , nowinldr ) ; if ( ! ( nbuff = fmap_need_off_once ( map , rep - nowinldr , 4 ) ) ) break ; start_of_stuff = rep + cli_readint32 ( nbuff ) ; if ( ! ( nbuff = fmap_need_off_once ( map , start_of_stuff , 20 ) ) ) break ; src = nbuff ; if ( ! cli_readint32 ( nbuff ) ) { start_of_stuff += 4 ; src += 4 ; } ssize = cli_readint32 ( src + 5 ) | 0xff ; dsize = cli_readint32 ( src + 9 ) ; CLI_UNPSIZELIMITS ( ""NsPack"" , MAX ( ssize , dsize ) ) ; if ( ! ssize || ! dsize || dsize != exe_sections [ 0 ] . vsz ) break ; if ( ! ( dest = cli_malloc ( dsize ) ) ) { cli_errmsg ( ""NsPack:Unabletoallocatememoryfordest%u\\n"" , dsize ) ; break ; } if ( ! ( src = fmap_need_off ( map , start_of_stuff , ssize ) ) ) { free ( dest ) ; break ; } eprva += 0x27a ; if ( ! ( rep = cli_rawaddr ( eprva , exe_sections , nsections , & err , fsize , hdr_size ) ) && err ) { free ( dest ) ; break ; } if ( ! ( nbuff = fmap_need_off_once ( map , rep , 5 ) ) ) { free ( dest ) ; break ; } fmap_unneed_off ( map , start_of_stuff , ssize ) ; eprva = eprva + 5 + cli_readint32 ( nbuff + 1 ) ; cli_dbgmsg ( ""NsPack:OEP=%08x\\n"" , eprva ) ; # if HAVE_JSON cli_jsonstr ( pe_json , ""Packer"" , ""NsPack"" ) ; # endif CLI_UNPTEMP ( ""NsPack"" , ( dest , exe_sections , 0 ) ) ; CLI_UNPRESULTS ( ""NsPack"" , ( unspack ( src , dest , ctx , exe_sections [ 0 ] . rva , EC32 ( optional_hdr32 . ImageBase ) , eprva , ndesc ) ) , 0 , ( dest , 0 ) ) ; break ; } ctx -> corrupted_input = corrupted_cur ; bc_ctx = cli_bytecode_context_alloc ( ) ; if ( ! bc_ctx ) { cli_errmsg ( ""cli_scanpe:can\'tallocatememoryforbc_ctx\\n"" ) ; return CL_EMEM ; } cli_bytecode_context_setpe ( bc_ctx , & pedata , exe_sections ) ; cli_bytecode_context_setctx ( bc_ctx , ctx ) ; ret = cli_bytecode_runhook ( ctx , ctx -> engine , bc_ctx , BC_PE_UNPACKER , map ) ; switch ( ret ) { case CL_VIRUS : free ( exe_sections ) ; cli_bytecode_context_destroy ( bc_ctx ) ; return CL_VIRUS ; case CL_SUCCESS : ndesc = cli_bytecode_context_getresult_file ( bc_ctx , & tempfile ) ; cli_bytecode_context_destroy ( bc_ctx ) ; if ( ndesc != - 1 && tempfile ) { CLI_UNPRESULTS ( ""bytecodePEhook"" , 1 , 1 , ( 0 ) ) ; } break ; default : cli_bytecode_context_destroy ( bc_ctx ) ; } free ( exe_sections ) ; # if HAVE_JSON if ( cli_json_timeout_cycle_check ( ctx , & toval ) != CL_SUCCESS ) { return CL_ETIMEOUT ; } # endif if ( SCAN_ALL && viruses_found ) return CL_VIRUS ; return CL_CLEAN ; } "," int i , j , overlays = 0 , rescan = 1 falign , hdr_size ; struct cli_exe_section ; # endif while ( rescan == 1 ) { rescan = 0 ; ++ ) { exe_sections [ i ] . rva = PEALIGN ( EC32 ( section_hdr [ i ] . VirtualAddress ) , valign ) ; exe_sections [ i ] . vsz = PESALIGN ( EC32 ( section_hdr [ i ] . VirtualSize ) , valign ) ; exe_sections [ i ] . raw = PEALIGN ( EC32 ( section_hdr [ i ] . PointerToRawData ) , falign ) ; exe_sections [ i ] . rsz = PESALIGN ( EC32 ( section_hdr [ i ] . SizeOfRawData ) , falign ) ; exe_sections [ i ] . chr = EC32 ( section_hdr [ i ] . Characteristics ) ; exe_sections [ i ] . urva = EC32 ( section_hdr [ i ] . VirtualAddress ) ; exe_sections [ i ] . uvsz = EC32 ( section_hdr [ i ] . VirtualSize ) ; exe_sections [ i ] . uraw = EC32 ( section_hdr [ i ] . PointerToRawData ) ; exe_sections [ i ] . ursz = EC32 ( section_hdr [ i ] . SizeOfRawData ) ; if ( exe_sections [ i ] . rsz ) { if ( ! CLI_ISCONTAINED ( 0 , fsize , exe_sections [ i ] . uraw , exe_sections [ i ] . ursz ) || exe_sections [ i ] . raw >= fsize ) { cli_dbgmsg ( ""BrokenPEfile-Section%dstartsorexistsbeyondtheendoffile(Offset@%lu,Totalfilesize%lu)\\n"" , i , ( unsigned long ) exe_sections [ i ] . raw , ( unsigned long ) fsize ) ; if ( nsections == 1 ) { free ( section_hdr ) ; free ( exe_sections ) ; if ( DETECT_BROKEN_PE ) { cli_append_virus ( ctx , ""Heuristics.Broken.Executable"" ) ; return CL_VIRUS ; } return CL_CLEAN ; } for ( j = i ; j < nsections - 1 ; j ++ ) memcpy ( & exe_sections [ j ] , & exe_sections [ j + 1 ] , sizeof ( struct cli_exe_section ) ) ; for ( j = i ; j < nsections - 1 ; j ++ ) memcpy ( & section_hdr [ j ] , & section_hdr [ j + 1 ] , sizeof ( struct pe_image_section_hdr ) ) ; nsections -- ; rescan = 1 ; break ; } } } } for ( i = 0 ; i < nsections ; i ++ ) { ] = 0 ; # if rsz ) { if ( SCAN_ALGO ",vrtadmin@clamav-devel/fc3794a54d2affe5770c1f876484a871c783e91e,CVE-2014-9050,https://github.com/vrtadmin/clamav-devel/commit/fc3794a54d2affe5770c1f876484a871c783e91e,2014-12-01T15:59Z 1684,CWE-20,"CWE-20 uint16_t dm9000ReadPhyReg ( uint8_t address ) { dm9000WriteReg ( DM9000_REG_EPAR , 0x40 | address ) ; dm9000WriteReg ( DM9000_REG_EPCR , EPCR_EPOS | EPCR_ERPRR ) ; while ( ( dm9000ReadReg ( DM9000_REG_EPCR ) & EPCR_ERRE ) != 0 ) { } dm9000WriteReg ( DM9000_REG_EPCR , EPCR_EPOS ) ; usleep ( 5 ) ; return ( dm9000ReadReg ( DM9000_REG_EPDRH ) << 8 ) | dm9000ReadReg ( DM9000_REG_EPDRL ) ; } "," { dm9000WriteReg ( DM9000_EPAR , 0x40 | ; dm9000WriteReg ( DM9000_EPCR , DM9000_EPCR_EPOS | DM9000_EPCR_ERPRR ) ; while ( dm9000ReadReg ( DM9000_EPCR ) & DM9000_EPCR_ERRE ) != 0 } dm9000WriteReg ( DM9000_EPCR , DM9000_EPCR_EPOS ) ; usleep ( dm9000ReadReg ( DM9000_EPDRH ) << 8 | dm9000ReadReg ( DM9000_EPDRL ) ; } ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 1685,CWE-787,"CWE-787 tsize_t t2p_readwrite_pdf_image ( T2P * t2p , TIFF * input , TIFF * output ) { tsize_t written = 0 ; unsigned char * buffer = NULL ; unsigned char * samplebuffer = NULL ; tsize_t bufferoffset = 0 ; tsize_t samplebufferoffset = 0 ; tsize_t read = 0 ; tstrip_t i = 0 ; tstrip_t j = 0 ; tstrip_t stripcount = 0 ; tsize_t stripsize = 0 ; tsize_t sepstripcount = 0 ; tsize_t sepstripsize = 0 ; # ifdef OJPEG_SUPPORT toff_t inputoffset = 0 ; uint16 h_samp = 1 ; uint16 v_samp = 1 ; uint16 ri = 1 ; uint32 rows = 0 ; # endif # ifdef JPEG_SUPPORT unsigned char * jpt ; float * xfloatp ; uint64 * sbc ; unsigned char * stripbuffer ; tsize_t striplength = 0 ; uint32 max_striplength = 0 ; # endif if ( t2p -> t2p_error != T2P_ERR_OK ) return ( 0 ) ; if ( t2p -> pdf_transcode == T2P_TRANSCODE_RAW ) { # ifdef CCITT_SUPPORT if ( t2p -> pdf_compression == T2P_COMPRESS_G4 ) { buffer = ( unsigned char * ) _TIFFmalloc ( t2p -> tiff_datasize ) ; if ( buffer == NULL ) { TIFFError ( TIFF2PDF_MODULE , ""Can\'tallocate%lubytesofmemoryfor"" ""t2p_readwrite_pdf_image,%s"" , ( unsigned long ) t2p -> tiff_datasize , TIFFFileName ( input ) ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } TIFFReadRawStrip ( input , 0 , ( tdata_t ) buffer , t2p -> tiff_datasize ) ; if ( t2p -> tiff_fillorder == FILLORDER_LSB2MSB ) { TIFFReverseBits ( buffer , t2p -> tiff_datasize ) ; } t2pWriteFile ( output , ( tdata_t ) buffer , t2p -> tiff_datasize ) ; _TIFFfree ( buffer ) ; return ( t2p -> tiff_datasize ) ; } # endif # ifdef ZIP_SUPPORT if ( t2p -> pdf_compression == T2P_COMPRESS_ZIP ) { buffer = ( unsigned char * ) _TIFFmalloc ( t2p -> tiff_datasize ) ; if ( buffer == NULL ) { TIFFError ( TIFF2PDF_MODULE , ""Can\'tallocate%lubytesofmemoryfort2p_readwrite_pdf_image,%s"" , ( unsigned long ) t2p -> tiff_datasize , TIFFFileName ( input ) ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } memset ( buffer , 0 , t2p -> tiff_datasize ) ; TIFFReadRawStrip ( input , 0 , ( tdata_t ) buffer , t2p -> tiff_datasize ) ; if ( t2p -> tiff_fillorder == FILLORDER_LSB2MSB ) { TIFFReverseBits ( buffer , t2p -> tiff_datasize ) ; } t2pWriteFile ( output , ( tdata_t ) buffer , t2p -> tiff_datasize ) ; _TIFFfree ( buffer ) ; return ( t2p -> tiff_datasize ) ; } # endif # ifdef OJPEG_SUPPORT if ( t2p -> tiff_compression == COMPRESSION_OJPEG ) { if ( t2p -> tiff_dataoffset != 0 ) { buffer = ( unsigned char * ) _TIFFmalloc ( t2p -> tiff_datasize ) ; if ( buffer == NULL ) { TIFFError ( TIFF2PDF_MODULE , ""Can\'tallocate%lubytesofmemoryfort2p_readwrite_pdf_image,%s"" , ( unsigned long ) t2p -> tiff_datasize , TIFFFileName ( input ) ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } memset ( buffer , 0 , t2p -> tiff_datasize ) ; if ( t2p -> pdf_ojpegiflength == 0 ) { inputoffset = t2pSeekFile ( input , 0 , SEEK_CUR ) ; t2pSeekFile ( input , t2p -> tiff_dataoffset , SEEK_SET ) ; t2pReadFile ( input , ( tdata_t ) buffer , t2p -> tiff_datasize ) ; t2pSeekFile ( input , inputoffset , SEEK_SET ) ; t2pWriteFile ( output , ( tdata_t ) buffer , t2p -> tiff_datasize ) ; _TIFFfree ( buffer ) ; return ( t2p -> tiff_datasize ) ; } else { inputoffset = t2pSeekFile ( input , 0 , SEEK_CUR ) ; t2pSeekFile ( input , t2p -> tiff_dataoffset , SEEK_SET ) ; bufferoffset = t2pReadFile ( input , ( tdata_t ) buffer , t2p -> pdf_ojpegiflength ) ; t2p -> pdf_ojpegiflength = 0 ; t2pSeekFile ( input , inputoffset , SEEK_SET ) ; TIFFGetField ( input , TIFFTAG_YCBCRSUBSAMPLING , & h_samp , & v_samp ) ; buffer [ bufferoffset ++ ] = 0xff ; buffer [ bufferoffset ++ ] = 0xdd ; buffer [ bufferoffset ++ ] = 0x00 ; buffer [ bufferoffset ++ ] = 0x04 ; h_samp *= 8 ; v_samp *= 8 ; ri = ( t2p -> tiff_width + h_samp - 1 ) / h_samp ; TIFFGetField ( input , TIFFTAG_ROWSPERSTRIP , & rows ) ; ri *= ( rows + v_samp - 1 ) / v_samp ; buffer [ bufferoffset ++ ] = ( ri >> 8 ) & 0xff ; buffer [ bufferoffset ++ ] = ri & 0xff ; stripcount = TIFFNumberOfStrips ( input ) ; for ( i = 0 ; i < stripcount ; i ++ ) { if ( i != 0 ) { buffer [ bufferoffset ++ ] = 0xff ; buffer [ bufferoffset ++ ] = ( 0xd0 | ( ( i - 1 ) % 8 ) ) ; } bufferoffset += TIFFReadRawStrip ( input , i , ( tdata_t ) & ( ( ( unsigned char * ) buffer ) [ bufferoffset ] ) , - 1 ) ; } t2pWriteFile ( output , ( tdata_t ) buffer , bufferoffset ) ; _TIFFfree ( buffer ) ; return ( bufferoffset ) ; } } else { if ( ! t2p -> pdf_ojpegdata ) { TIFFError ( TIFF2PDF_MODULE , ""NosupportforOJPEGimage%swithbadtables"" , TIFFFileName ( input ) ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } buffer = ( unsigned char * ) _TIFFmalloc ( t2p -> tiff_datasize ) ; if ( buffer == NULL ) { TIFFError ( TIFF2PDF_MODULE , ""Can\'tallocate%lubytesofmemoryfort2p_readwrite_pdf_image,%s"" , ( unsigned long ) t2p -> tiff_datasize , TIFFFileName ( input ) ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } memset ( buffer , 0 , t2p -> tiff_datasize ) ; _TIFFmemcpy ( buffer , t2p -> pdf_ojpegdata , t2p -> pdf_ojpegdatalength ) ; bufferoffset = t2p -> pdf_ojpegdatalength ; stripcount = TIFFNumberOfStrips ( input ) ; for ( i = 0 ; i < stripcount ; i ++ ) { if ( i != 0 ) { buffer [ bufferoffset ++ ] = 0xff ; buffer [ bufferoffset ++ ] = ( 0xd0 | ( ( i - 1 ) % 8 ) ) ; } bufferoffset += TIFFReadRawStrip ( input , i , ( tdata_t ) & ( ( ( unsigned char * ) buffer ) [ bufferoffset ] ) , - 1 ) ; } if ( ! ( ( buffer [ bufferoffset - 1 ] == 0xd9 ) && ( buffer [ bufferoffset - 2 ] == 0xff ) ) ) { buffer [ bufferoffset ++ ] = 0xff ; buffer [ bufferoffset ++ ] = 0xd9 ; } t2pWriteFile ( output , ( tdata_t ) buffer , bufferoffset ) ; _TIFFfree ( buffer ) ; return ( bufferoffset ) ; # if 0 TIFFError ( TIFF2PDF_MODULE , ""NosupportforOJPEGimage%swithnoJPEGFileInterchangeoffset"" , TIFFFileName ( input ) ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; # endif } } # endif # ifdef JPEG_SUPPORT if ( t2p -> tiff_compression == COMPRESSION_JPEG ) { uint32 count = 0 ; buffer = ( unsigned char * ) _TIFFmalloc ( t2p -> tiff_datasize ) ; if ( buffer == NULL ) { TIFFError ( TIFF2PDF_MODULE , ""Can\'tallocate%lubytesofmemoryfort2p_readwrite_pdf_image,%s"" , ( unsigned long ) t2p -> tiff_datasize , TIFFFileName ( input ) ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } memset ( buffer , 0 , t2p -> tiff_datasize ) ; if ( TIFFGetField ( input , TIFFTAG_JPEGTABLES , & count , & jpt ) != 0 ) { if ( count > 4 ) { _TIFFmemcpy ( buffer , jpt , count ) ; bufferoffset += count - 2 ; } } stripcount = TIFFNumberOfStrips ( input ) ; TIFFGetField ( input , TIFFTAG_STRIPBYTECOUNTS , & sbc ) ; for ( i = 0 ; i < stripcount ; i ++ ) { if ( sbc [ i ] > max_striplength ) max_striplength = sbc [ i ] ; } stripbuffer = ( unsigned char * ) _TIFFmalloc ( max_striplength ) ; if ( stripbuffer == NULL ) { TIFFError ( TIFF2PDF_MODULE , ""Can\'tallocate%ubytesofmemoryfort2p_readwrite_pdf_image,%s"" , max_striplength , TIFFFileName ( input ) ) ; _TIFFfree ( buffer ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } for ( i = 0 ; i < stripcount ; i ++ ) { striplength = TIFFReadRawStrip ( input , i , ( tdata_t ) stripbuffer , - 1 ) ; if ( ! t2p_process_jpeg_strip ( stripbuffer , & striplength , buffer , & bufferoffset , i , t2p -> tiff_length ) ) { TIFFError ( TIFF2PDF_MODULE , ""Can\'tprocessJPEGdataininputfile%s"" , TIFFFileName ( input ) ) ; _TIFFfree ( samplebuffer ) ; _TIFFfree ( buffer ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } } buffer [ bufferoffset ++ ] = 0xff ; buffer [ bufferoffset ++ ] = 0xd9 ; t2pWriteFile ( output , ( tdata_t ) buffer , bufferoffset ) ; _TIFFfree ( stripbuffer ) ; _TIFFfree ( buffer ) ; return ( bufferoffset ) ; } # endif ( void ) 0 ; } if ( t2p -> pdf_sample == T2P_SAMPLE_NOTHING ) { buffer = ( unsigned char * ) _TIFFmalloc ( t2p -> tiff_datasize ) ; if ( buffer == NULL ) { TIFFError ( TIFF2PDF_MODULE , ""Can\'tallocate%lubytesofmemoryfort2p_readwrite_pdf_image,%s"" , ( unsigned long ) t2p -> tiff_datasize , TIFFFileName ( input ) ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } memset ( buffer , 0 , t2p -> tiff_datasize ) ; stripsize = TIFFStripSize ( input ) ; stripcount = TIFFNumberOfStrips ( input ) ; for ( i = 0 ; i < stripcount ; i ++ ) { read = TIFFReadEncodedStrip ( input , i , ( tdata_t ) & buffer [ bufferoffset ] , TIFFmin ( stripsize , t2p -> tiff_datasize - bufferoffset ) ) ; if ( read == - 1 ) { TIFFError ( TIFF2PDF_MODULE , ""Errorondecodingstrip%uof%s"" , i , TIFFFileName ( input ) ) ; _TIFFfree ( buffer ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } bufferoffset += read ; } } else { if ( t2p -> pdf_sample & T2P_SAMPLE_PLANAR_SEPARATE_TO_CONTIG ) { sepstripsize = TIFFStripSize ( input ) ; sepstripcount = TIFFNumberOfStrips ( input ) ; stripsize = sepstripsize * t2p -> tiff_samplesperpixel ; stripcount = sepstripcount / t2p -> tiff_samplesperpixel ; buffer = ( unsigned char * ) _TIFFmalloc ( t2p -> tiff_datasize ) ; if ( buffer == NULL ) { TIFFError ( TIFF2PDF_MODULE , ""Can\'tallocate%lubytesofmemoryfort2p_readwrite_pdf_image,%s"" , ( unsigned long ) t2p -> tiff_datasize , TIFFFileName ( input ) ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } memset ( buffer , 0 , t2p -> tiff_datasize ) ; samplebuffer = ( unsigned char * ) _TIFFmalloc ( stripsize ) ; if ( samplebuffer == NULL ) { TIFFError ( TIFF2PDF_MODULE , ""Can\'tallocate%lubytesofmemoryfort2p_readwrite_pdf_image,%s"" , ( unsigned long ) t2p -> tiff_datasize , TIFFFileName ( input ) ) ; t2p -> t2p_error = T2P_ERR_ERROR ; _TIFFfree ( buffer ) ; return ( 0 ) ; } for ( i = 0 ; i < stripcount ; i ++ ) { samplebufferoffset = 0 ; for ( j = 0 ; j < t2p -> tiff_samplesperpixel ; j ++ ) { read = TIFFReadEncodedStrip ( input , i + j * stripcount , ( tdata_t ) & ( samplebuffer [ samplebufferoffset ] ) , TIFFmin ( sepstripsize , stripsize - samplebufferoffset ) ) ; if ( read == - 1 ) { TIFFError ( TIFF2PDF_MODULE , ""Errorondecodingstrip%uof%s"" , i + j * stripcount , TIFFFileName ( input ) ) ; _TIFFfree ( buffer ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } samplebufferoffset += read ; } t2p_sample_planar_separate_to_contig ( t2p , & ( buffer [ bufferoffset ] ) , samplebuffer , samplebufferoffset ) ; bufferoffset += samplebufferoffset ; } _TIFFfree ( samplebuffer ) ; goto dataready ; } buffer = ( unsigned char * ) _TIFFmalloc ( t2p -> tiff_datasize ) ; if ( buffer == NULL ) { TIFFError ( TIFF2PDF_MODULE , ""Can\'tallocate%lubytesofmemoryfort2p_readwrite_pdf_image,%s"" , ( unsigned long ) t2p -> tiff_datasize , TIFFFileName ( input ) ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } memset ( buffer , 0 , t2p -> tiff_datasize ) ; stripsize = TIFFStripSize ( input ) ; stripcount = TIFFNumberOfStrips ( input ) ; for ( i = 0 ; i < stripcount ; i ++ ) { read = TIFFReadEncodedStrip ( input , i , ( tdata_t ) & buffer [ bufferoffset ] , TIFFmin ( stripsize , t2p -> tiff_datasize - bufferoffset ) ) ; if ( read == - 1 ) { TIFFError ( TIFF2PDF_MODULE , ""Errorondecodingstrip%uof%s"" , i , TIFFFileName ( input ) ) ; _TIFFfree ( samplebuffer ) ; _TIFFfree ( buffer ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } bufferoffset += read ; } if ( t2p -> pdf_sample & T2P_SAMPLE_REALIZE_PALETTE ) { samplebuffer = ( unsigned char * ) _TIFFrealloc ( ( tdata_t ) buffer , t2p -> tiff_datasize * t2p -> tiff_samplesperpixel ) ; if ( samplebuffer == NULL ) { TIFFError ( TIFF2PDF_MODULE , ""Can\'tallocate%lubytesofmemoryfort2p_readwrite_pdf_image,%s"" , ( unsigned long ) t2p -> tiff_datasize , TIFFFileName ( input ) ) ; t2p -> t2p_error = T2P_ERR_ERROR ; _TIFFfree ( buffer ) ; return ( 0 ) ; } else { buffer = samplebuffer ; t2p -> tiff_datasize *= t2p -> tiff_samplesperpixel ; } t2p_sample_realize_palette ( t2p , buffer ) ; } if ( t2p -> pdf_sample & T2P_SAMPLE_RGBA_TO_RGB ) { t2p -> tiff_datasize = t2p_sample_rgba_to_rgb ( ( tdata_t ) buffer , t2p -> tiff_width * t2p -> tiff_length ) ; } if ( t2p -> pdf_sample & T2P_SAMPLE_RGBAA_TO_RGB ) { t2p -> tiff_datasize = t2p_sample_rgbaa_to_rgb ( ( tdata_t ) buffer , t2p -> tiff_width * t2p -> tiff_length ) ; } if ( t2p -> pdf_sample & T2P_SAMPLE_YCBCR_TO_RGB ) { samplebuffer = ( unsigned char * ) _TIFFrealloc ( ( tdata_t ) buffer , t2p -> tiff_width * t2p -> tiff_length * 4 ) ; if ( samplebuffer == NULL ) { TIFFError ( TIFF2PDF_MODULE , ""Can\'tallocate%lubytesofmemoryfort2p_readwrite_pdf_image,%s"" , ( unsigned long ) t2p -> tiff_datasize , TIFFFileName ( input ) ) ; t2p -> t2p_error = T2P_ERR_ERROR ; _TIFFfree ( buffer ) ; return ( 0 ) ; } else { buffer = samplebuffer ; } if ( ! TIFFReadRGBAImageOriented ( input , t2p -> tiff_width , t2p -> tiff_length , ( uint32 * ) buffer , ORIENTATION_TOPLEFT , 0 ) ) { TIFFError ( TIFF2PDF_MODULE , ""Can\'tuseTIFFReadRGBAImageOrientedtoextractRGBimagefrom%s"" , TIFFFileName ( input ) ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } t2p -> tiff_datasize = t2p_sample_abgr_to_rgb ( ( tdata_t ) buffer , t2p -> tiff_width * t2p -> tiff_length ) ; } if ( t2p -> pdf_sample & T2P_SAMPLE_LAB_SIGNED_TO_UNSIGNED ) { t2p -> tiff_datasize = t2p_sample_lab_signed_to_unsigned ( ( tdata_t ) buffer , t2p -> tiff_width * t2p -> tiff_length ) ; } } dataready : t2p_disable ( output ) ; TIFFSetField ( output , TIFFTAG_PHOTOMETRIC , t2p -> tiff_photometric ) ; TIFFSetField ( output , TIFFTAG_BITSPERSAMPLE , t2p -> tiff_bitspersample ) ; TIFFSetField ( output , TIFFTAG_SAMPLESPERPIXEL , t2p -> tiff_samplesperpixel ) ; TIFFSetField ( output , TIFFTAG_IMAGEWIDTH , t2p -> tiff_width ) ; TIFFSetField ( output , TIFFTAG_IMAGELENGTH , t2p -> tiff_length ) ; TIFFSetField ( output , TIFFTAG_ROWSPERSTRIP , t2p -> tiff_length ) ; TIFFSetField ( output , TIFFTAG_PLANARCONFIG , PLANARCONFIG_CONTIG ) ; TIFFSetField ( output , TIFFTAG_FILLORDER , FILLORDER_MSB2LSB ) ; switch ( t2p -> pdf_compression ) { case T2P_COMPRESS_NONE : TIFFSetField ( output , TIFFTAG_COMPRESSION , COMPRESSION_NONE ) ; break ; # ifdef CCITT_SUPPORT case T2P_COMPRESS_G4 : TIFFSetField ( output , TIFFTAG_COMPRESSION , COMPRESSION_CCITTFAX4 ) ; break ; # endif # ifdef JPEG_SUPPORT case T2P_COMPRESS_JPEG : if ( t2p -> tiff_photometric == PHOTOMETRIC_YCBCR ) { uint16 hor = 0 , ver = 0 ; if ( TIFFGetField ( input , TIFFTAG_YCBCRSUBSAMPLING , & hor , & ver ) != 0 ) { if ( hor != 0 && ver != 0 ) { TIFFSetField ( output , TIFFTAG_YCBCRSUBSAMPLING , hor , ver ) ; } } if ( TIFFGetField ( input , TIFFTAG_REFERENCEBLACKWHITE , & xfloatp ) != 0 ) { TIFFSetField ( output , TIFFTAG_REFERENCEBLACKWHITE , xfloatp ) ; } } if ( TIFFSetField ( output , TIFFTAG_COMPRESSION , COMPRESSION_JPEG ) == 0 ) { TIFFError ( TIFF2PDF_MODULE , ""UnabletouseJPEGcompressionforinput%sandoutput%s"" , TIFFFileName ( input ) , TIFFFileName ( output ) ) ; _TIFFfree ( buffer ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } TIFFSetField ( output , TIFFTAG_JPEGTABLESMODE , 0 ) ; if ( t2p -> pdf_colorspace & ( T2P_CS_RGB | T2P_CS_LAB ) ) { TIFFSetField ( output , TIFFTAG_PHOTOMETRIC , PHOTOMETRIC_YCBCR ) ; if ( t2p -> tiff_photometric != PHOTOMETRIC_YCBCR ) { TIFFSetField ( output , TIFFTAG_JPEGCOLORMODE , JPEGCOLORMODE_RGB ) ; } else { TIFFSetField ( output , TIFFTAG_JPEGCOLORMODE , JPEGCOLORMODE_RAW ) ; } } if ( t2p -> pdf_colorspace & T2P_CS_GRAY ) { ( void ) 0 ; } if ( t2p -> pdf_colorspace & T2P_CS_CMYK ) { ( void ) 0 ; } if ( t2p -> pdf_defaultcompressionquality != 0 ) { TIFFSetField ( output , TIFFTAG_JPEGQUALITY , t2p -> pdf_defaultcompressionquality ) ; } break ; # endif # ifdef ZIP_SUPPORT case T2P_COMPRESS_ZIP : TIFFSetField ( output , TIFFTAG_COMPRESSION , COMPRESSION_DEFLATE ) ; if ( t2p -> pdf_defaultcompressionquality % 100 != 0 ) { TIFFSetField ( output , TIFFTAG_PREDICTOR , t2p -> pdf_defaultcompressionquality % 100 ) ; } if ( t2p -> pdf_defaultcompressionquality / 100 != 0 ) { TIFFSetField ( output , TIFFTAG_ZIPQUALITY , ( t2p -> pdf_defaultcompressionquality / 100 ) ) ; } break ; # endif default : break ; } t2p_enable ( output ) ; t2p -> outputwritten = 0 ; # ifdef JPEG_SUPPORT if ( t2p -> pdf_compression == T2P_COMPRESS_JPEG && t2p -> tiff_photometric == PHOTOMETRIC_YCBCR ) { bufferoffset = TIFFWriteEncodedStrip ( output , ( tstrip_t ) 0 , buffer , stripsize * stripcount ) ; } else # endif { bufferoffset = TIFFWriteEncodedStrip ( output , ( tstrip_t ) 0 , buffer , t2p -> tiff_datasize ) ; } if ( buffer != NULL ) { _TIFFfree ( buffer ) ; buffer = NULL ; } if ( bufferoffset == ( tsize_t ) - 1 ) { TIFFError ( TIFF2PDF_MODULE , ""ErrorwritingencodedstriptooutputPDF%s"" , TIFFFileName ( output ) ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } written = t2p -> outputwritten ; return ( written ) ; } "," , buffer , t2p -> tiff_datasize , ",vadz@libtiff/83a4b92815ea04969d494416eaae3d4c6b338e4a,CVE-2016-9533,https://github.com/vadz/libtiff/commit/83a4b92815ea04969d494416eaae3d4c6b338e4a#diff-bdc795f6afeb9558c1012b3cfae729ef,2016-11-22T19:59Z 1686,CWE-264,"CWE-264 int inode_change_ok ( const struct inode * inode , struct iattr * attr ) { unsigned int ia_valid = attr -> ia_valid ; if ( ia_valid & ATTR_SIZE ) { int error = inode_newsize_ok ( inode , attr -> ia_size ) ; if ( error ) return error ; } if ( ia_valid & ATTR_FORCE ) return 0 ; if ( ( ia_valid & ATTR_UID ) && ( ! uid_eq ( current_fsuid ( ) , inode -> i_uid ) || ! uid_eq ( attr -> ia_uid , inode -> i_uid ) ) && ! inode_capable ( inode , CAP_CHOWN ) ) return - EPERM ; if ( ( ia_valid & ATTR_GID ) && ( ! uid_eq ( current_fsuid ( ) , inode -> i_uid ) || ( ! in_group_p ( attr -> ia_gid ) && ! gid_eq ( attr -> ia_gid , inode -> i_gid ) ) ) && ! inode_capable ( inode , CAP_CHOWN ) ) return - EPERM ; if ( ia_valid & ATTR_MODE ) { if ( ! inode_owner_or_capable ( inode ) ) return - EPERM ; if ( ! in_group_p ( ( ia_valid & ATTR_GID ) ? attr -> ia_gid : inode -> i_gid ) && ! inode_capable ( inode , CAP_FSETID ) ) attr -> ia_mode &= ~ S_ISGID ; } if ( ia_valid & ( ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_TIMES_SET ) ) { if ( ! inode_owner_or_capable ( inode ) ) return - EPERM ; } return 0 ; } "," ) && ! capable_wrt_inode_uidgid ( inode , ) && ! capable_wrt_inode_uidgid ( inode , ) && ! capable_wrt_inode_uidgid ( inode , ",torvalds@linux/23adbe12ef7d3d4195e80800ab36b37bee28cd03,CVE-2014-4014,https://github.com/torvalds/linux/commit/23adbe12ef7d3d4195e80800ab36b37bee28cd03,2014-06-23T11:21Z 1687,CWE-787,"CWE-787 static void nsc_encode_argb_to_aycocg ( NSC_CONTEXT * context , const BYTE * data , UINT32 scanline ) { UINT16 x ; UINT16 y ; UINT16 rw ; BYTE ccl ; const BYTE * src ; BYTE * yplane = NULL ; BYTE * coplane = NULL ; BYTE * cgplane = NULL ; BYTE * aplane = NULL ; INT16 r_val ; INT16 g_val ; INT16 b_val ; BYTE a_val ; UINT32 tempWidth ; tempWidth = ROUND_UP_TO ( context -> width , 8 ) ; rw = ( context -> ChromaSubsamplingLevel ? tempWidth : context -> width ) ; ccl = context -> ColorLossLevel ; for ( y = 0 ; y < context -> height ; y ++ ) { src = data + ( context -> height - 1 - y ) * scanline ; yplane = context -> priv -> PlaneBuffers [ 0 ] + y * rw ; coplane = context -> priv -> PlaneBuffers [ 1 ] + y * rw ; cgplane = context -> priv -> PlaneBuffers [ 2 ] + y * rw ; aplane = context -> priv -> PlaneBuffers [ 3 ] + y * context -> width ; for ( x = 0 ; x < context -> width ; x ++ ) { switch ( context -> format ) { case PIXEL_FORMAT_BGRX32 : b_val = * src ++ ; g_val = * src ++ ; r_val = * src ++ ; src ++ ; a_val = 0xFF ; break ; case PIXEL_FORMAT_BGRA32 : b_val = * src ++ ; g_val = * src ++ ; r_val = * src ++ ; a_val = * src ++ ; break ; case PIXEL_FORMAT_RGBX32 : r_val = * src ++ ; g_val = * src ++ ; b_val = * src ++ ; src ++ ; a_val = 0xFF ; break ; case PIXEL_FORMAT_RGBA32 : r_val = * src ++ ; g_val = * src ++ ; b_val = * src ++ ; a_val = * src ++ ; break ; case PIXEL_FORMAT_BGR24 : b_val = * src ++ ; g_val = * src ++ ; r_val = * src ++ ; a_val = 0xFF ; break ; case PIXEL_FORMAT_RGB24 : r_val = * src ++ ; g_val = * src ++ ; b_val = * src ++ ; a_val = 0xFF ; break ; case PIXEL_FORMAT_BGR16 : b_val = ( INT16 ) ( ( ( * ( src + 1 ) ) & 0xF8 ) | ( ( * ( src + 1 ) ) >> 5 ) ) ; g_val = ( INT16 ) ( ( ( ( * ( src + 1 ) ) & 0x07 ) << 5 ) | ( ( ( * src ) & 0xE0 ) >> 3 ) ) ; r_val = ( INT16 ) ( ( ( ( * src ) & 0x1F ) << 3 ) | ( ( ( * src ) >> 2 ) & 0x07 ) ) ; a_val = 0xFF ; src += 2 ; break ; case PIXEL_FORMAT_RGB16 : r_val = ( INT16 ) ( ( ( * ( src + 1 ) ) & 0xF8 ) | ( ( * ( src + 1 ) ) >> 5 ) ) ; g_val = ( INT16 ) ( ( ( ( * ( src + 1 ) ) & 0x07 ) << 5 ) | ( ( ( * src ) & 0xE0 ) >> 3 ) ) ; b_val = ( INT16 ) ( ( ( ( * src ) & 0x1F ) << 3 ) | ( ( ( * src ) >> 2 ) & 0x07 ) ) ; a_val = 0xFF ; src += 2 ; break ; case PIXEL_FORMAT_A4 : { int shift ; BYTE idx ; shift = ( 7 - ( x % 8 ) ) ; idx = ( ( * src ) >> shift ) & 1 ; idx |= ( ( ( * ( src + 1 ) ) >> shift ) & 1 ) << 1 ; idx |= ( ( ( * ( src + 2 ) ) >> shift ) & 1 ) << 2 ; idx |= ( ( ( * ( src + 3 ) ) >> shift ) & 1 ) << 3 ; idx *= 3 ; r_val = ( INT16 ) context -> palette [ idx ] ; g_val = ( INT16 ) context -> palette [ idx + 1 ] ; b_val = ( INT16 ) context -> palette [ idx + 2 ] ; if ( shift == 0 ) src += 4 ; } a_val = 0xFF ; break ; case PIXEL_FORMAT_RGB8 : { int idx = ( * src ) * 3 ; r_val = ( INT16 ) context -> palette [ idx ] ; g_val = ( INT16 ) context -> palette [ idx + 1 ] ; b_val = ( INT16 ) context -> palette [ idx + 2 ] ; src ++ ; } a_val = 0xFF ; break ; default : r_val = g_val = b_val = a_val = 0 ; break ; } * yplane ++ = ( BYTE ) ( ( r_val >> 2 ) + ( g_val >> 1 ) + ( b_val >> 2 ) ) ; * coplane ++ = ( BYTE ) ( ( r_val - b_val ) >> ccl ) ; * cgplane ++ = ( BYTE ) ( ( - ( r_val >> 1 ) + g_val - ( b_val >> 1 ) ) >> ccl ) ; * aplane ++ = a_val ; } if ( context -> ChromaSubsamplingLevel && ( x % 2 ) == 1 ) { * yplane = * ( yplane - 1 ) ; * coplane = * ( coplane - 1 ) ; * cgplane = * ( cgplane - 1 ) ; } } if ( context -> ChromaSubsamplingLevel && ( y % 2 ) == 1 ) { yplane = context -> priv -> PlaneBuffers [ 0 ] + y * rw ; coplane = context -> priv -> PlaneBuffers [ 1 ] + y * rw ; cgplane = context -> priv -> PlaneBuffers [ 2 ] + y * rw ; CopyMemory ( yplane , yplane - rw , rw ) ; CopyMemory ( coplane , coplane - rw , rw ) ; CopyMemory ( cgplane , cgplane - rw , rw ) ; } } "," static BOOL nsc_encode_argb_to_aycocg ( NSC_CONTEXT ; UINT32 tempWidth ; if ( ! context || data || ( scanline == 0 ) ) return FALSE -> ColorLossLevel ; if ( context -> priv -> PlaneBuffersLength < rw * scanline ) return FALSE ; if ( rw < scanline * 2 ) return FALSE ; ) ; } return TRUE ; ",FreeRDP@FreeRDP/d1112c279bd1a327e8e4d0b5f371458bf2579659,CVE-2018-8788,https://github.com/FreeRDP/FreeRDP/commit/d1112c279bd1a327e8e4d0b5f371458bf2579659,2018-11-29T18:29Z 1688,CWE-20,"CWE-20 static int isofs_read_inode ( struct inode * inode ) { struct super_block * sb = inode -> i_sb ; struct isofs_sb_info * sbi = ISOFS_SB ( sb ) ; unsigned long bufsize = ISOFS_BUFFER_SIZE ( inode ) ; unsigned long block ; int high_sierra = sbi -> s_high_sierra ; struct buffer_head * bh = NULL ; struct iso_directory_record * de ; struct iso_directory_record * tmpde = NULL ; unsigned int de_len ; unsigned long offset ; struct iso_inode_info * ei = ISOFS_I ( inode ) ; int ret = - EIO ; block = ei -> i_iget5_block ; bh = sb_bread ( inode -> i_sb , block ) ; if ( ! bh ) goto out_badread ; offset = ei -> i_iget5_offset ; de = ( struct iso_directory_record * ) ( bh -> b_data + offset ) ; de_len = * ( unsigned char * ) de ; if ( offset + de_len > bufsize ) { int frag1 = bufsize - offset ; tmpde = kmalloc ( de_len , GFP_KERNEL ) ; if ( tmpde == NULL ) { printk ( KERN_INFO ""%s:outofmemory\\n"" , __func__ ) ; ret = - ENOMEM ; goto fail ; } memcpy ( tmpde , bh -> b_data + offset , frag1 ) ; brelse ( bh ) ; bh = sb_bread ( inode -> i_sb , ++ block ) ; if ( ! bh ) goto out_badread ; memcpy ( ( char * ) tmpde + frag1 , bh -> b_data , de_len - frag1 ) ; de = tmpde ; } inode -> i_ino = isofs_get_ino ( ei -> i_iget5_block , ei -> i_iget5_offset , ISOFS_BUFFER_BITS ( inode ) ) ; ei -> i_file_format = isofs_file_normal ; if ( de -> flags [ - high_sierra ] & 2 ) { if ( sbi -> s_dmode != ISOFS_INVALID_MODE ) inode -> i_mode = S_IFDIR | sbi -> s_dmode ; else inode -> i_mode = S_IFDIR | S_IRUGO | S_IXUGO ; set_nlink ( inode , 1 ) ; } else { if ( sbi -> s_fmode != ISOFS_INVALID_MODE ) { inode -> i_mode = S_IFREG | sbi -> s_fmode ; } else { inode -> i_mode = S_IFREG | S_IRUGO | S_IXUGO ; } set_nlink ( inode , 1 ) ; } inode -> i_uid = sbi -> s_uid ; inode -> i_gid = sbi -> s_gid ; inode -> i_blocks = 0 ; ei -> i_format_parm [ 0 ] = 0 ; ei -> i_format_parm [ 1 ] = 0 ; ei -> i_format_parm [ 2 ] = 0 ; ei -> i_section_size = isonum_733 ( de -> size ) ; if ( de -> flags [ - high_sierra ] & 0x80 ) { ret = isofs_read_level3_size ( inode ) ; if ( ret < 0 ) goto fail ; ret = - EIO ; } else { ei -> i_next_section_block = 0 ; ei -> i_next_section_offset = 0 ; inode -> i_size = isonum_733 ( de -> size ) ; } if ( sbi -> s_cruft ) inode -> i_size &= 0x00ffffff ; if ( de -> interleave [ 0 ] ) { printk ( KERN_DEBUG ""ISOFS:Interleavedfilesnot(yet)supported.\\n"" ) ; inode -> i_size = 0 ; } if ( de -> file_unit_size [ 0 ] != 0 ) { printk ( KERN_DEBUG ""ISOFS:Fileunitsize!=0forISOfile(%ld).\\n"" , inode -> i_ino ) ; } # ifdef DEBUG if ( ( de -> flags [ - high_sierra ] & ~ 2 ) != 0 ) { printk ( KERN_DEBUG ""ISOFS:UnusualflagsettingsforISOfile"" ""(%ld%x).\\n"" , inode -> i_ino , de -> flags [ - high_sierra ] ) ; } # endif inode -> i_mtime . tv_sec = inode -> i_atime . tv_sec = inode -> i_ctime . tv_sec = iso_date ( de -> date , high_sierra ) ; inode -> i_mtime . tv_nsec = inode -> i_atime . tv_nsec = inode -> i_ctime . tv_nsec = 0 ; ei -> i_first_extent = ( isonum_733 ( de -> extent ) + isonum_711 ( de -> ext_attr_length ) ) ; inode -> i_blocks = ( inode -> i_size + 511 ) >> 9 ; if ( ! high_sierra ) { parse_rock_ridge_inode ( de , inode ) ; if ( sbi -> s_uid_set ) inode -> i_uid = sbi -> s_uid ; if ( sbi -> s_gid_set ) inode -> i_gid = sbi -> s_gid ; } if ( S_ISDIR ( inode -> i_mode ) && sbi -> s_overriderockperm && sbi -> s_dmode != ISOFS_INVALID_MODE ) inode -> i_mode = S_IFDIR | sbi -> s_dmode ; if ( S_ISREG ( inode -> i_mode ) && sbi -> s_overriderockperm && sbi -> s_fmode != ISOFS_INVALID_MODE ) inode -> i_mode = S_IFREG | sbi -> s_fmode ; if ( S_ISREG ( inode -> i_mode ) ) { inode -> i_fop = & generic_ro_fops ; switch ( ei -> i_file_format ) { # ifdef CONFIG_ZISOFS case isofs_file_compressed : inode -> i_data . a_ops = & zisofs_aops ; break ; # endif default : inode -> i_data . a_ops = & isofs_aops ; break ; } } else if ( S_ISDIR ( inode -> i_mode ) ) { inode -> i_op = & isofs_dir_inode_operations ; inode -> i_fop = & isofs_dir_operations ; } else if ( S_ISLNK ( inode -> i_mode ) ) { inode -> i_op = & page_symlink_inode_operations ; inode -> i_data . a_ops = & isofs_symlink_aops ; } else init_special_inode ( inode , inode -> i_mode , inode -> i_rdev ) ; ret = 0 ; out : kfree ( tmpde ) ; if ( bh ) brelse ( bh ) ; return ret ; out_badread : printk ( KERN_WARNING ""ISOFS:unabletoreadi-nodeblock\\n"" ) ; fail : goto out ; } "," inode * inode , int relocated de , inode , relocated ",torvalds@linux/410dd3cf4c9b36f27ed4542ee18b1af5e68645a4,CVE-2014-5472,https://github.com/torvalds/linux/commit/410dd3cf4c9b36f27ed4542ee18b1af5e68645a4,2014-09-01T01:55Z 1689,CWE-269,"CWE-269 static void ptrace_link ( struct task_struct * child , struct task_struct * new_parent ) { rcu_read_lock ( ) ; __ptrace_link ( child , new_parent , __task_cred ( new_parent ) ) ; rcu_read_unlock ( ) ; } "," new_parent ) { __ptrace_link ( child , new_parent , current_cred ( ) ) ; } ",torvalds@linux/6994eefb0053799d2e07cd140df6c2ea106c41ee,CVE-2019-13272,https://github.com/torvalds/linux/commit/6994eefb0053799d2e07cd140df6c2ea106c41ee,2019-07-17T13:15Z 1690,CWE-674,"CWE-674 int yr_re_ast_create ( RE_AST * * re_ast ) { * re_ast = ( RE_AST * ) yr_malloc ( sizeof ( RE_AST ) ) ; if ( * re_ast == NULL ) return ERROR_INSUFFICIENT_MEMORY ; ( * re_ast ) -> flags = 0 ; ( * re_ast ) -> root_node = NULL ; return ERROR_SUCCESS ; } "," re_ast ) -> levels = 0 ; ( * re_ast ) -> ",VirusTotal@yara/925bcf3c3b0a28b5b78e25d9efda5c0bf27ae699,CVE-2017-9304,https://github.com/VirusTotal/yara/commit/925bcf3c3b0a28b5b78e25d9efda5c0bf27ae699,2017-05-31T04:29Z 1691,CWE-399,"CWE-399 int cib_remote_signon ( cib_t * cib , const char * name , enum cib_conn_type type ) { int rc = pcmk_ok ; cib_remote_opaque_t * private = cib -> variant_opaque ; if ( private -> passwd == NULL ) { struct termios settings ; int rc ; rc = tcgetattr ( 0 , & settings ) ; settings . c_lflag &= ~ ECHO ; rc = tcsetattr ( 0 , TCSANOW , & settings ) ; fprintf ( stderr , ""Password:"" ) ; private -> passwd = calloc ( 1 , 1024 ) ; rc = scanf ( ""%s"" , private -> passwd ) ; fprintf ( stdout , ""\\n"" ) ; if ( rc < 1 ) { private -> passwd = NULL ; } settings . c_lflag |= ECHO ; rc = tcsetattr ( 0 , TCSANOW , & settings ) ; } if ( private -> server == NULL || private -> user == NULL ) { rc = - EINVAL ; } if ( rc == pcmk_ok ) { rc = cib_tls_signon ( cib , & ( private -> command ) ) ; } if ( rc == pcmk_ok ) { rc = cib_tls_signon ( cib , & ( private -> callback ) ) ; } if ( rc == pcmk_ok ) { xmlNode * hello = cib_create_op ( 0 , private -> callback . token , CRM_OP_REGISTER , NULL , NULL , NULL , 0 , NULL ) ; crm_xml_add ( hello , F_CIB_CLIENTNAME , name ) ; crm_send_remote_msg ( private -> command . session , hello , private -> command . encrypted ) ; free_xml ( hello ) ; } if ( rc == pcmk_ok ) { fprintf ( stderr , ""%s:Openedconnectionto%s:%d\\n"" , name , private -> server , private -> port ) ; cib -> state = cib_connected_command ; cib -> type = cib_command ; } else { fprintf ( stderr , ""%s:Connectionto%s:%dfailed:%s\\n"" , name , private -> server , private -> port , pcmk_strerror ( rc ) ) ; } return rc ; } "," -> command ) , FALSE -> callback ) , TRUE ",ClusterLabs@pacemaker/564f7cc2a51dcd2f28ab12a13394f31be5aa3c93,CVE-2013-0281,https://github.com/ClusterLabs/pacemaker/commit/564f7cc2a51dcd2f28ab12a13394f31be5aa3c93,2013-11-23T11:55Z 1692,CWE-20,"CWE-20 SYSCALL_DEFINE6 ( recvfrom , int , fd , void __user * , ubuf , size_t , size , unsigned int , flags , struct sockaddr __user * , addr , int __user * , addr_len ) { struct socket * sock ; struct iovec iov ; struct msghdr msg ; struct sockaddr_storage address ; int err , err2 ; int fput_needed ; if ( size > INT_MAX ) size = INT_MAX ; sock = sockfd_lookup_light ( fd , & err , & fput_needed ) ; if ( ! sock ) goto out ; msg . msg_control = NULL ; msg . msg_controllen = 0 ; msg . msg_iovlen = 1 ; msg . msg_iov = & iov ; iov . iov_len = size ; iov . iov_base = ubuf ; msg . msg_name = ( struct sockaddr * ) & address ; msg . msg_namelen = sizeof ( address ) ; if ( sock -> file -> f_flags & O_NONBLOCK ) flags |= MSG_DONTWAIT ; err = sock_recvmsg ( sock , & msg , size , flags ) ; if ( err >= 0 && addr != NULL ) { err2 = move_addr_to_user ( & address , msg . msg_namelen , addr , addr_len ) ; if ( err2 < 0 ) err = err2 ; } fput_light ( sock -> file , fput_needed ) ; out : return err ; } "," . msg_name = addr ? ) & address : NULL . msg_namelen = 0 ; if ( ",torvalds@linux/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,CVE-2013-7271,https://github.com/torvalds/linux/commit/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,2014-01-06T16:55Z 1693,CWE-119,"CWE-119 static void first_pass_motion_search ( VP9_COMP * cpi , MACROBLOCK * x , const MV * ref_mv , MV * best_mv , int * best_motion_err ) { MACROBLOCKD * const xd = & x -> e_mbd ; MV tmp_mv = { 0 , 0 } ; MV ref_mv_full = { ref_mv -> row >> 3 , ref_mv -> col >> 3 } ; int num00 , tmp_err , n , sr = 0 ; int step_param = 3 ; int further_steps = ( MAX_MVSEARCH_STEPS - 1 ) - step_param ; const BLOCK_SIZE bsize = xd -> mi [ 0 ] -> mbmi . sb_type ; vp9_variance_fn_ptr_t v_fn_ptr = cpi -> fn_ptr [ bsize ] ; int new_mv_mode_penalty = 256 ; const int quart_frm = MIN ( cpi -> common . width , cpi -> common . height ) ; while ( ( quart_frm << sr ) < MAX_FULL_PEL_VAL ) ++ sr ; step_param += sr ; further_steps -= sr ; v_fn_ptr . vf = get_block_variance_fn ( bsize ) ; tmp_err = cpi -> diamond_search_sad ( x , & ref_mv_full , & tmp_mv , step_param , x -> sadperbit16 , & num00 , & v_fn_ptr , x -> nmvjointcost , x -> mvcost , ref_mv ) ; if ( tmp_err < INT_MAX ) tmp_err = vp9_get_mvpred_var ( x , & tmp_mv , ref_mv , & v_fn_ptr , 1 ) ; if ( tmp_err < INT_MAX - new_mv_mode_penalty ) tmp_err += new_mv_mode_penalty ; if ( tmp_err < * best_motion_err ) { * best_motion_err = tmp_err ; best_mv -> row = tmp_mv . row ; best_mv -> col = tmp_mv . col ; } n = num00 ; num00 = 0 ; while ( n < further_steps ) { ++ n ; if ( num00 ) { -- num00 ; } else { tmp_err = cpi -> diamond_search_sad ( x , & ref_mv_full , & tmp_mv , step_param + n , x -> sadperbit16 , & num00 , & v_fn_ptr , x -> nmvjointcost , x -> mvcost , ref_mv ) ; if ( tmp_err < INT_MAX ) tmp_err = vp9_get_mvpred_var ( x , & tmp_mv , ref_mv , & v_fn_ptr , 1 ) ; if ( tmp_err < INT_MAX - new_mv_mode_penalty ) tmp_err += new_mv_mode_penalty ; if ( tmp_err < * best_motion_err ) { * best_motion_err = tmp_err ; best_mv -> row = tmp_mv . row ; best_mv -> col = tmp_mv . col ; } } } } "," tmp_err , n ; const BLOCK_SIZE bsize ] ; const int new_mv_mode_penalty = NEW_MV_MODE_PENALTY ; int step_param = 3 ; int further_steps = ( MAX_MVSEARCH_STEPS - 1 ) - step_param ; const int ; const int sr = get_search_range ( cpi ) ; step_param += bsize ) ; # if CONFIG_VP9_HIGHBITDEPTH if ( xd -> cur_buf -> flags & YV12_FLAG_HIGHBITDEPTH ) { v_fn_ptr . vf = highbd_get_block_variance_fn ( bsize , xd -> bd ) ; } # endif x , & cpi -> ss_cfg , & , & v_fn_ptr , ref_mv ) = tmp_err ; * best_mv = tmp_mv ; } n diamond_search_sad ( x , & cpi -> ss_cfg & v_fn_ptr , ref_mv ) ; = tmp_err ; * best_mv = tmp_mv ; } } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1694,CWE-119,"CWE-119 hive_h * hivex_open ( const char * filename , int flags ) { hive_h * h = NULL ; assert ( sizeof ( struct ntreg_header ) == 0x1000 ) ; assert ( offsetof ( struct ntreg_header , csum ) == 0x1fc ) ; h = calloc ( 1 , sizeof * h ) ; if ( h == NULL ) goto error ; h -> msglvl = flags & HIVEX_OPEN_MSGLVL_MASK ; const char * debug = getenv ( ""HIVEX_DEBUG"" ) ; if ( debug && STREQ ( debug , ""1"" ) ) h -> msglvl = 2 ; DEBUG ( 2 , ""createdhandle%p"" , h ) ; h -> writable = ! ! ( flags & HIVEX_OPEN_WRITE ) ; h -> filename = strdup ( filename ) ; if ( h -> filename == NULL ) goto error ; # ifdef O_CLOEXEC h -> fd = open ( filename , O_RDONLY | O_CLOEXEC | O_BINARY ) ; # else h -> fd = open ( filename , O_RDONLY | O_BINARY ) ; # endif if ( h -> fd == - 1 ) goto error ; # ifndef O_CLOEXEC fcntl ( h -> fd , F_SETFD , FD_CLOEXEC ) ; # endif struct stat statbuf ; if ( fstat ( h -> fd , & statbuf ) == - 1 ) goto error ; h -> size = statbuf . st_size ; if ( h -> size < 0x2000 ) { SET_ERRNO ( EINVAL , ""%s:fileistoosmalltobeaWindowsNTRegistryhivefile"" , filename ) ; goto error ; } if ( ! h -> writable ) { h -> addr = mmap ( NULL , h -> size , PROT_READ , MAP_SHARED , h -> fd , 0 ) ; if ( h -> addr == MAP_FAILED ) goto error ; DEBUG ( 2 , ""mappedfileat%p"" , h -> addr ) ; } else { h -> addr = malloc ( h -> size ) ; if ( h -> addr == NULL ) goto error ; if ( full_read ( h -> fd , h -> addr , h -> size ) < h -> size ) goto error ; if ( close ( h -> fd ) == - 1 ) goto error ; h -> fd = - 1 ; } if ( h -> hdr -> magic [ 0 ] != 'r' || h -> hdr -> magic [ 1 ] != 'e' || h -> hdr -> magic [ 2 ] != 'g' || h -> hdr -> magic [ 3 ] != 'f' ) { SET_ERRNO ( ENOTSUP , ""%s:notaWindowsNTRegistryhivefile"" , filename ) ; goto error ; } uint32_t major_ver = le32toh ( h -> hdr -> major_ver ) ; if ( major_ver != 1 ) { SET_ERRNO ( ENOTSUP , ""%s:hivefilemajorversion%"" PRIu32 ""(expected1)"" , filename , major_ver ) ; goto error ; } h -> bitmap = calloc ( 1 + h -> size / 32 , 1 ) ; if ( h -> bitmap == NULL ) goto error ; uint32_t sum = header_checksum ( h ) ; if ( sum != le32toh ( h -> hdr -> csum ) ) { SET_ERRNO ( EINVAL , ""%s:badchecksuminhiveheader"" , filename ) ; goto error ; } h -> last_modified = le64toh ( ( int64_t ) h -> hdr -> last_modified ) ; if ( h -> msglvl >= 2 ) { char * name = _hivex_windows_utf16_to_utf8 ( h -> hdr -> name , 64 ) ; fprintf ( stderr , ""hivex_open:headerfields:\\n"" ""fileversion%"" PRIu32 "".%"" PRIu32 ""\\n"" ""sequencenos%"" PRIu32 ""%"" PRIu32 ""\\n"" ""(sequencesnosshouldmatchifhivewassynchedatshutdown)\\n"" ""lastmodified%"" PRIu64 ""\\n"" ""(Windowsfiletime,x100nssince1601-01-01)\\n"" ""originalfilename%s\\n"" ""(only32charsarestored,nameisprobablytruncated)\\n"" ""rootoffset0x%x+0x1000\\n"" ""endoflastpage0x%x+0x1000(totalfilesize0x%zx)\\n"" ""checksum0x%x(calculated0x%x)\\n"" , major_ver , le32toh ( h -> hdr -> minor_ver ) , le32toh ( h -> hdr -> sequence1 ) , le32toh ( h -> hdr -> sequence2 ) , h -> last_modified , name ? name : ""(conversionfailed)"" , le32toh ( h -> hdr -> offset ) , le32toh ( h -> hdr -> blocks ) , h -> size , le32toh ( h -> hdr -> csum ) , sum ) ; free ( name ) ; } h -> rootoffs = le32toh ( h -> hdr -> offset ) + 0x1000 ; h -> endpages = le32toh ( h -> hdr -> blocks ) + 0x1000 ; DEBUG ( 2 , ""rootoffset=0x%zx"" , h -> rootoffs ) ; int seen_root_block = 0 , bad_root_block = 0 ; size_t pages = 0 ; size_t smallest_page = SIZE_MAX , largest_page = 0 ; size_t blocks = 0 ; size_t smallest_block = SIZE_MAX , largest_block = 0 , blocks_bytes = 0 ; size_t used_blocks = 0 ; size_t used_size = 0 ; size_t off ; struct ntreg_hbin_page * page ; for ( off = 0x1000 ; off < h -> size ; off += le32toh ( page -> page_size ) ) { if ( off >= h -> endpages ) break ; page = ( struct ntreg_hbin_page * ) ( ( char * ) h -> addr + off ) ; if ( page -> magic [ 0 ] != 'h' || page -> magic [ 1 ] != 'b' || page -> magic [ 2 ] != 'i' || page -> magic [ 3 ] != 'n' ) { SET_ERRNO ( ENOTSUP , ""%s:trailinggarbageatendoffile"" ""(at0x%zx,after%zupages)"" , filename , off , pages ) ; goto error ; } size_t page_size = le32toh ( page -> page_size ) ; DEBUG ( 2 , ""pageat0x%zx,size%zu"" , off , page_size ) ; pages ++ ; if ( page_size < smallest_page ) smallest_page = page_size ; if ( page_size > largest_page ) largest_page = page_size ; if ( page_size <= sizeof ( struct ntreg_hbin_page ) || ( page_size & 0x0fff ) != 0 ) { SET_ERRNO ( ENOTSUP , ""%s:pagesize%zuat0x%zx,badregistry"" , filename , page_size , off ) ; goto error ; } size_t blkoff ; struct ntreg_hbin_block * block ; size_t seg_len ; for ( blkoff = off + 0x20 ; blkoff < off + page_size ; blkoff += seg_len ) { blocks ++ ; int is_root = blkoff == h -> rootoffs ; if ( is_root ) seen_root_block = 1 ; block = ( struct ntreg_hbin_block * ) ( ( char * ) h -> addr + blkoff ) ; int used ; seg_len = block_len ( h , blkoff , & used ) ; if ( seg_len <= 4 || ( seg_len & 3 ) != 0 ) { SET_ERRNO ( ENOTSUP , ""%s:blocksize%"" PRIu32 ""at0x%zx,badregistry"" , filename , le32toh ( block -> seg_len ) , blkoff ) ; goto error ; } if ( h -> msglvl >= 2 ) { unsigned char * id = ( unsigned char * ) block -> id ; int id0 = id [ 0 ] , id1 = id [ 1 ] ; fprintf ( stderr , ""%s:%s:"" ""%sblockid%d,%d(%c%c)at0x%zxsize%zu%s\\n"" , ""hivex"" , __func__ , used ? ""used"" : ""free"" , id0 , id1 , c_isprint ( id0 ) ? id0 : '.' , c_isprint ( id1 ) ? id1 : '.' , blkoff , seg_len , is_root ? ""(root)"" : """" ) ; } blocks_bytes += seg_len ; if ( seg_len < smallest_block ) smallest_block = seg_len ; if ( seg_len > largest_block ) largest_block = seg_len ; if ( is_root && ! used ) bad_root_block = 1 ; if ( used ) { used_blocks ++ ; used_size += seg_len ; if ( is_root && ( block -> id [ 0 ] != 'n' || block -> id [ 1 ] != 'k' ) ) bad_root_block = 1 ; BITMAP_SET ( h -> bitmap , blkoff ) ; } } } if ( ! seen_root_block ) { SET_ERRNO ( ENOTSUP , ""%s:norootblockfound"" , filename ) ; goto error ; } if ( bad_root_block ) { SET_ERRNO ( ENOTSUP , ""%s:badrootblock(freeornotnk)"" , filename ) ; goto error ; } DEBUG ( 1 , ""successfullyreadWindowsRegistryhivefile:\\n"" ""pages:%zu[sml:%zu,lge:%zu]\\n"" ""blocks:%zu[sml:%zu,avg:%zu,lge:%zu]\\n"" ""blocksused:%zu\\n"" ""bytesused:%zu"" , pages , smallest_page , largest_page , blocks , smallest_block , blocks_bytes / blocks , largest_block , used_blocks , used_size ) ; return h ; error : ; int err = errno ; if ( h ) { free ( h -> bitmap ) ; if ( h -> addr && h -> size && h -> addr != MAP_FAILED ) { if ( ! h -> writable ) munmap ( h -> addr , h -> size ) ; else free ( h -> addr ) ; } if ( h -> fd >= 0 ) close ( h -> fd ) ; free ( h -> filename ) ; free ( h ) ; } errno = err ; return NULL ; } "," ENOTSUP , ""%s:pagesize%zuat0x%zx,badregistry"" , filename , page_size , off ) ; goto error ; } if ( off + page_size > h -> size ) { SET_ERRNO ( ENOTSUP , ""%s:pagesize%zuat0x%zxextendsbeyondendoffile,badregistry"" ",libguestfs@hivex/4bbdf555f88baeae0fa804a369a81a83908bd705,CVE-2014-9273,https://github.com/libguestfs/hivex/commit/4bbdf555f88baeae0fa804a369a81a83908bd705,2014-12-08T16:59Z 1695,CWE-611,"CWE-611 void * merge_directory_configs ( apr_pool_t * mp , void * _parent , void * _child ) { directory_config * parent = ( directory_config * ) _parent ; directory_config * child = ( directory_config * ) _child ; directory_config * merged = create_directory_config ( mp , NULL ) ; # ifdef DEBUG_CONF ap_log_perror ( APLOG_MARK , APLOG_STARTUP | APLOG_NOERRNO , 0 , mp , ""Mergeparent%ppchild%ppRESULT%pp"" , _parent , _child , merged ) ; # endif if ( merged == NULL ) return NULL ; merged -> is_enabled = ( child -> is_enabled == NOT_SET ? parent -> is_enabled : child -> is_enabled ) ; merged -> reqbody_access = ( child -> reqbody_access == NOT_SET ? parent -> reqbody_access : child -> reqbody_access ) ; merged -> reqbody_buffering = ( child -> reqbody_buffering == NOT_SET ? parent -> reqbody_buffering : child -> reqbody_buffering ) ; merged -> reqbody_inmemory_limit = ( child -> reqbody_inmemory_limit == NOT_SET ? parent -> reqbody_inmemory_limit : child -> reqbody_inmemory_limit ) ; merged -> reqbody_limit = ( child -> reqbody_limit == NOT_SET ? parent -> reqbody_limit : child -> reqbody_limit ) ; merged -> reqbody_no_files_limit = ( child -> reqbody_no_files_limit == NOT_SET ? parent -> reqbody_no_files_limit : child -> reqbody_no_files_limit ) ; merged -> resbody_access = ( child -> resbody_access == NOT_SET ? parent -> resbody_access : child -> resbody_access ) ; merged -> of_limit = ( child -> of_limit == NOT_SET ? parent -> of_limit : child -> of_limit ) ; merged -> if_limit_action = ( child -> if_limit_action == NOT_SET ? parent -> if_limit_action : child -> if_limit_action ) ; merged -> of_limit_action = ( child -> of_limit_action == NOT_SET ? parent -> of_limit_action : child -> of_limit_action ) ; merged -> reqintercept_oe = ( child -> reqintercept_oe == NOT_SET ? parent -> reqintercept_oe : child -> reqintercept_oe ) ; if ( child -> of_mime_types != NOT_SET_P ) { if ( child -> of_mime_types_cleared == 1 ) { merged -> of_mime_types = child -> of_mime_types ; merged -> of_mime_types_cleared = 1 ; } else { if ( parent -> of_mime_types == NOT_SET_P ) { merged -> of_mime_types = child -> of_mime_types ; merged -> of_mime_types_cleared = NOT_SET ; } else { merged -> of_mime_types = apr_table_overlay ( mp , parent -> of_mime_types , child -> of_mime_types ) ; if ( merged -> of_mime_types == NULL ) return NULL ; } } } else { if ( child -> of_mime_types_cleared == 1 ) { merged -> of_mime_types_cleared = 1 ; } else { merged -> of_mime_types = parent -> of_mime_types ; merged -> of_mime_types_cleared = parent -> of_mime_types_cleared ; } } if ( child -> debuglog_fd == NOT_SET_P ) { merged -> debuglog_name = parent -> debuglog_name ; merged -> debuglog_fd = parent -> debuglog_fd ; } else { merged -> debuglog_name = child -> debuglog_name ; merged -> debuglog_fd = child -> debuglog_fd ; } merged -> debuglog_level = ( child -> debuglog_level == NOT_SET ? parent -> debuglog_level : child -> debuglog_level ) ; merged -> cookie_format = ( child -> cookie_format == NOT_SET ? parent -> cookie_format : child -> cookie_format ) ; merged -> argument_separator = ( child -> argument_separator == NOT_SET ? parent -> argument_separator : child -> argument_separator ) ; merged -> cookiev0_separator = ( child -> cookiev0_separator == NOT_SET_P ? parent -> cookiev0_separator : child -> cookiev0_separator ) ; if ( ( child -> rule_inheritance == NOT_SET ) || ( child -> rule_inheritance == 1 ) ) { merged -> rule_inheritance = parent -> rule_inheritance ; if ( ( child -> ruleset == NULL ) && ( parent -> ruleset == NULL ) ) { # ifdef DEBUG_CONF ap_log_perror ( APLOG_MARK , APLOG_STARTUP | APLOG_NOERRNO , 0 , mp , ""Norulesinthiscontext."" ) ; # endif } else if ( child -> ruleset == NULL ) { # ifdef DEBUG_CONF ap_log_perror ( APLOG_MARK , APLOG_STARTUP | APLOG_NOERRNO , 0 , mp , ""Usingparentrulesinthiscontext."" ) ; # endif merged -> ruleset = msre_ruleset_create ( parent -> ruleset -> engine , mp ) ; copy_rules ( mp , parent -> ruleset , merged -> ruleset , child -> rule_exceptions ) ; } else if ( parent -> ruleset == NULL ) { # ifdef DEBUG_CONF ap_log_perror ( APLOG_MARK , APLOG_STARTUP | APLOG_NOERRNO , 0 , mp , ""Usingchildrulesinthiscontext."" ) ; # endif merged -> ruleset = msre_ruleset_create ( child -> ruleset -> engine , mp ) ; merged -> ruleset -> phase_request_headers = apr_array_copy ( mp , child -> ruleset -> phase_request_headers ) ; merged -> ruleset -> phase_request_body = apr_array_copy ( mp , child -> ruleset -> phase_request_body ) ; merged -> ruleset -> phase_response_headers = apr_array_copy ( mp , child -> ruleset -> phase_response_headers ) ; merged -> ruleset -> phase_response_body = apr_array_copy ( mp , child -> ruleset -> phase_response_body ) ; merged -> ruleset -> phase_logging = apr_array_copy ( mp , child -> ruleset -> phase_logging ) ; } else { # ifdef DEBUG_CONF ap_log_perror ( APLOG_MARK , APLOG_STARTUP | APLOG_NOERRNO , 0 , mp , ""Usingparentthenchildrulesinthiscontext."" ) ; # endif merged -> ruleset = msre_ruleset_create ( parent -> ruleset -> engine , mp ) ; copy_rules ( mp , parent -> ruleset , merged -> ruleset , child -> rule_exceptions ) ; apr_array_cat ( merged -> ruleset -> phase_request_headers , child -> ruleset -> phase_request_headers ) ; apr_array_cat ( merged -> ruleset -> phase_request_body , child -> ruleset -> phase_request_body ) ; apr_array_cat ( merged -> ruleset -> phase_response_headers , child -> ruleset -> phase_response_headers ) ; apr_array_cat ( merged -> ruleset -> phase_response_body , child -> ruleset -> phase_response_body ) ; apr_array_cat ( merged -> ruleset -> phase_logging , child -> ruleset -> phase_logging ) ; } } else { merged -> rule_inheritance = 0 ; if ( child -> ruleset != NULL ) { merged -> ruleset = msre_ruleset_create ( child -> ruleset -> engine , mp ) ; merged -> ruleset -> phase_request_headers = apr_array_copy ( mp , child -> ruleset -> phase_request_headers ) ; merged -> ruleset -> phase_request_body = apr_array_copy ( mp , child -> ruleset -> phase_request_body ) ; merged -> ruleset -> phase_response_headers = apr_array_copy ( mp , child -> ruleset -> phase_response_headers ) ; merged -> ruleset -> phase_response_body = apr_array_copy ( mp , child -> ruleset -> phase_response_body ) ; merged -> ruleset -> phase_logging = apr_array_copy ( mp , child -> ruleset -> phase_logging ) ; } } merged -> rule_exceptions = apr_array_append ( mp , parent -> rule_exceptions , child -> rule_exceptions ) ; merged -> hash_method = apr_array_append ( mp , parent -> hash_method , child -> hash_method ) ; merged -> auditlog_flag = ( child -> auditlog_flag == NOT_SET ? parent -> auditlog_flag : child -> auditlog_flag ) ; merged -> auditlog_type = ( child -> auditlog_type == NOT_SET ? parent -> auditlog_type : child -> auditlog_type ) ; merged -> max_rule_time = ( child -> max_rule_time == NOT_SET ? parent -> max_rule_time : child -> max_rule_time ) ; merged -> auditlog_dirperms = ( child -> auditlog_dirperms == NOT_SET ? parent -> auditlog_dirperms : child -> auditlog_dirperms ) ; merged -> auditlog_fileperms = ( child -> auditlog_fileperms == NOT_SET ? parent -> auditlog_fileperms : child -> auditlog_fileperms ) ; if ( child -> auditlog_fd != NOT_SET_P ) { merged -> auditlog_fd = child -> auditlog_fd ; merged -> auditlog_name = child -> auditlog_name ; } else { merged -> auditlog_fd = parent -> auditlog_fd ; merged -> auditlog_name = parent -> auditlog_name ; } if ( child -> auditlog2_fd != NOT_SET_P ) { merged -> auditlog2_fd = child -> auditlog2_fd ; merged -> auditlog2_name = child -> auditlog2_name ; } else { merged -> auditlog2_fd = parent -> auditlog2_fd ; merged -> auditlog2_name = parent -> auditlog2_name ; } merged -> auditlog_storage_dir = ( child -> auditlog_storage_dir == NOT_SET_P ? parent -> auditlog_storage_dir : child -> auditlog_storage_dir ) ; merged -> auditlog_parts = ( child -> auditlog_parts == NOT_SET_P ? parent -> auditlog_parts : child -> auditlog_parts ) ; merged -> auditlog_relevant_regex = ( child -> auditlog_relevant_regex == NOT_SET_P ? parent -> auditlog_relevant_regex : child -> auditlog_relevant_regex ) ; merged -> tmp_dir = ( child -> tmp_dir == NOT_SET_P ? parent -> tmp_dir : child -> tmp_dir ) ; merged -> upload_dir = ( child -> upload_dir == NOT_SET_P ? parent -> upload_dir : child -> upload_dir ) ; merged -> upload_keep_files = ( child -> upload_keep_files == NOT_SET ? parent -> upload_keep_files : child -> upload_keep_files ) ; merged -> upload_validates_files = ( child -> upload_validates_files == NOT_SET ? parent -> upload_validates_files : child -> upload_validates_files ) ; merged -> upload_filemode = ( child -> upload_filemode == NOT_SET ? parent -> upload_filemode : child -> upload_filemode ) ; merged -> upload_file_limit = ( child -> upload_file_limit == NOT_SET ? parent -> upload_file_limit : child -> upload_file_limit ) ; merged -> data_dir = ( child -> data_dir == NOT_SET_P ? parent -> data_dir : child -> data_dir ) ; merged -> webappid = ( child -> webappid == NOT_SET_P ? parent -> webappid : child -> webappid ) ; merged -> sensor_id = ( child -> sensor_id == NOT_SET_P ? parent -> sensor_id : child -> sensor_id ) ; merged -> httpBlkey = ( child -> httpBlkey == NOT_SET_P ? parent -> httpBlkey : child -> httpBlkey ) ; merged -> content_injection_enabled = ( child -> content_injection_enabled == NOT_SET ? parent -> content_injection_enabled : child -> content_injection_enabled ) ; merged -> stream_inbody_inspection = ( child -> stream_inbody_inspection == NOT_SET ? parent -> stream_inbody_inspection : child -> stream_inbody_inspection ) ; merged -> stream_outbody_inspection = ( child -> stream_outbody_inspection == NOT_SET ? parent -> stream_outbody_inspection : child -> stream_outbody_inspection ) ; merged -> geo = ( child -> geo == NOT_SET_P ? parent -> geo : child -> geo ) ; merged -> gsb = ( child -> gsb == NOT_SET_P ? parent -> gsb : child -> gsb ) ; merged -> u_map = ( child -> u_map == NOT_SET_P ? parent -> u_map : child -> u_map ) ; merged -> cache_trans = ( child -> cache_trans == NOT_SET ? parent -> cache_trans : child -> cache_trans ) ; merged -> cache_trans_incremental = ( child -> cache_trans_incremental == NOT_SET ? parent -> cache_trans_incremental : child -> cache_trans_incremental ) ; merged -> cache_trans_min = ( child -> cache_trans_min == ( apr_size_t ) NOT_SET ? parent -> cache_trans_min : child -> cache_trans_min ) ; merged -> cache_trans_max = ( child -> cache_trans_max == ( apr_size_t ) NOT_SET ? parent -> cache_trans_max : child -> cache_trans_max ) ; merged -> cache_trans_maxitems = ( child -> cache_trans_maxitems == ( apr_size_t ) NOT_SET ? parent -> cache_trans_maxitems : child -> cache_trans_maxitems ) ; merged -> component_signatures = apr_array_append ( mp , parent -> component_signatures , child -> component_signatures ) ; merged -> request_encoding = ( child -> request_encoding == NOT_SET_P ? parent -> request_encoding : child -> request_encoding ) ; merged -> disable_backend_compression = ( child -> disable_backend_compression == NOT_SET ? parent -> disable_backend_compression : child -> disable_backend_compression ) ; merged -> col_timeout = ( child -> col_timeout == NOT_SET ? parent -> col_timeout : child -> col_timeout ) ; merged -> crypto_key = ( child -> crypto_key == NOT_SET_P ? parent -> crypto_key : child -> crypto_key ) ; merged -> crypto_key_len = ( child -> crypto_key_len == NOT_SET ? parent -> crypto_key_len : child -> crypto_key_len ) ; merged -> crypto_key_add = ( child -> crypto_key_add == NOT_SET ? parent -> crypto_key_add : child -> crypto_key_add ) ; merged -> crypto_param_name = ( child -> crypto_param_name == NOT_SET_P ? parent -> crypto_param_name : child -> crypto_param_name ) ; merged -> hash_is_enabled = ( child -> hash_is_enabled == NOT_SET ? parent -> hash_is_enabled : child -> hash_is_enabled ) ; merged -> hash_enforcement = ( child -> hash_enforcement == NOT_SET ? parent -> hash_enforcement : child -> hash_enforcement ) ; merged -> crypto_hash_href_rx = ( child -> crypto_hash_href_rx == NOT_SET ? parent -> crypto_hash_href_rx : child -> crypto_hash_href_rx ) ; merged -> crypto_hash_faction_rx = ( child -> crypto_hash_faction_rx == NOT_SET ? parent -> crypto_hash_faction_rx : child -> crypto_hash_faction_rx ) ; merged -> crypto_hash_location_rx = ( child -> crypto_hash_location_rx == NOT_SET ? parent -> crypto_hash_location_rx : child -> crypto_hash_location_rx ) ; merged -> crypto_hash_iframesrc_rx = ( child -> crypto_hash_iframesrc_rx == NOT_SET ? parent -> crypto_hash_iframesrc_rx : child -> crypto_hash_iframesrc_rx ) ; merged -> crypto_hash_framesrc_rx = ( child -> crypto_hash_framesrc_rx == NOT_SET ? parent -> crypto_hash_framesrc_rx : child -> crypto_hash_framesrc_rx ) ; merged -> crypto_hash_href_pm = ( child -> crypto_hash_href_pm == NOT_SET ? parent -> crypto_hash_href_pm : child -> crypto_hash_href_pm ) ; merged -> crypto_hash_faction_pm = ( child -> crypto_hash_faction_pm == NOT_SET ? parent -> crypto_hash_faction_pm : child -> crypto_hash_faction_pm ) ; merged -> crypto_hash_location_pm = ( child -> crypto_hash_location_pm == NOT_SET ? parent -> crypto_hash_location_pm : child -> crypto_hash_location_pm ) ; merged -> crypto_hash_iframesrc_pm = ( child -> crypto_hash_iframesrc_pm == NOT_SET ? parent -> crypto_hash_iframesrc_pm : child -> crypto_hash_iframesrc_pm ) ; merged -> crypto_hash_framesrc_pm = ( child -> crypto_hash_framesrc_pm == NOT_SET ? parent -> crypto_hash_framesrc_pm : child -> crypto_hash_framesrc_pm ) ; return merged ; } "," crypto_hash_framesrc_pm ) ; merged -> xml_external_entity = ( child -> xml_external_entity == NOT_SET ? parent -> xml_external_entity : child -> xml_external_entity ) ; ",SpiderLabs@ModSecurity/d4d80b38aa85eccb26e3c61b04d16e8ca5de76fe,CVE-2013-1915,https://github.com/SpiderLabs/ModSecurity/commit/d4d80b38aa85eccb26e3c61b04d16e8ca5de76fe,2013-04-25T23:55Z 1696,CWE-476,"CWE-476 static int __sys_sendmsg ( struct socket * sock , struct msghdr __user * msg , struct msghdr * msg_sys , unsigned flags , struct used_address * used_address ) { struct compat_msghdr __user * msg_compat = ( struct compat_msghdr __user * ) msg ; struct sockaddr_storage address ; struct iovec iovstack [ UIO_FASTIOV ] , * iov = iovstack ; unsigned char ctl [ sizeof ( struct cmsghdr ) + 20 ] __attribute__ ( ( aligned ( sizeof ( __kernel_size_t ) ) ) ) ; unsigned char * ctl_buf = ctl ; int err , ctl_len , iov_size , total_len ; err = - EFAULT ; if ( MSG_CMSG_COMPAT & flags ) { if ( get_compat_msghdr ( msg_sys , msg_compat ) ) return - EFAULT ; } else if ( copy_from_user ( msg_sys , msg , sizeof ( struct msghdr ) ) ) return - EFAULT ; err = - EMSGSIZE ; if ( msg_sys -> msg_iovlen > UIO_MAXIOV ) goto out ; err = - ENOMEM ; iov_size = msg_sys -> msg_iovlen * sizeof ( struct iovec ) ; if ( msg_sys -> msg_iovlen > UIO_FASTIOV ) { iov = sock_kmalloc ( sock -> sk , iov_size , GFP_KERNEL ) ; if ( ! iov ) goto out ; } if ( MSG_CMSG_COMPAT & flags ) { err = verify_compat_iovec ( msg_sys , iov , ( struct sockaddr * ) & address , VERIFY_READ ) ; } else err = verify_iovec ( msg_sys , iov , ( struct sockaddr * ) & address , VERIFY_READ ) ; if ( err < 0 ) goto out_freeiov ; total_len = err ; err = - ENOBUFS ; if ( msg_sys -> msg_controllen > INT_MAX ) goto out_freeiov ; ctl_len = msg_sys -> msg_controllen ; if ( ( MSG_CMSG_COMPAT & flags ) && ctl_len ) { err = cmsghdr_from_user_compat_to_kern ( msg_sys , sock -> sk , ctl , sizeof ( ctl ) ) ; if ( err ) goto out_freeiov ; ctl_buf = msg_sys -> msg_control ; ctl_len = msg_sys -> msg_controllen ; } else if ( ctl_len ) { if ( ctl_len > sizeof ( ctl ) ) { ctl_buf = sock_kmalloc ( sock -> sk , ctl_len , GFP_KERNEL ) ; if ( ctl_buf == NULL ) goto out_freeiov ; } err = - EFAULT ; if ( copy_from_user ( ctl_buf , ( void __user __force * ) msg_sys -> msg_control , ctl_len ) ) goto out_freectl ; msg_sys -> msg_control = ctl_buf ; } msg_sys -> msg_flags = flags ; if ( sock -> file -> f_flags & O_NONBLOCK ) msg_sys -> msg_flags |= MSG_DONTWAIT ; if ( used_address && used_address -> name_len == msg_sys -> msg_namelen && ! memcmp ( & used_address -> name , msg -> msg_name , used_address -> name_len ) ) { err = sock_sendmsg_nosec ( sock , msg_sys , total_len ) ; goto out_freectl ; } err = sock_sendmsg ( sock , msg_sys , total_len ) ; if ( used_address && err >= 0 ) { used_address -> name_len = msg_sys -> msg_namelen ; memcpy ( & used_address -> name , msg -> msg_name , used_address -> name_len ) ; } out_freectl : if ( ctl_buf != ctl ) sock_kfree_s ( sock -> sk , ctl_buf , ctl_len ) ; out_freeiov : if ( iov != iovstack ) sock_kfree_s ( sock -> sk , iov , iov_size ) ; out : return err ; } "," ( used_address && msg_sys -> msg_name && -> name , msg_sys -> msg_name , -> msg_namelen ; if ( msg_sys -> msg_name ) -> name , msg_sys -> msg_name , ",torvalds@linux/bc909d9ddbf7778371e36a651d6e4194b1cc7d4c,CVE-2011-4594,https://github.com/torvalds/linux/commit/bc909d9ddbf7778371e36a651d6e4194b1cc7d4c,2012-05-17T11:00Z 1697,CWE-20,"CWE-20 static int skcipher_recvmsg ( struct kiocb * unused , struct socket * sock , struct msghdr * msg , size_t ignored , int flags ) { struct sock * sk = sock -> sk ; struct alg_sock * ask = alg_sk ( sk ) ; struct skcipher_ctx * ctx = ask -> private ; unsigned bs = crypto_ablkcipher_blocksize ( crypto_ablkcipher_reqtfm ( & ctx -> req ) ) ; struct skcipher_sg_list * sgl ; struct scatterlist * sg ; unsigned long iovlen ; struct iovec * iov ; int err = - EAGAIN ; int used ; long copied = 0 ; lock_sock ( sk ) ; msg -> msg_namelen = 0 ; for ( iov = msg -> msg_iov , iovlen = msg -> msg_iovlen ; iovlen > 0 ; iovlen -- , iov ++ ) { unsigned long seglen = iov -> iov_len ; char __user * from = iov -> iov_base ; while ( seglen ) { sgl = list_first_entry ( & ctx -> tsgl , struct skcipher_sg_list , list ) ; sg = sgl -> sg ; while ( ! sg -> length ) sg ++ ; used = ctx -> used ; if ( ! used ) { err = skcipher_wait_for_data ( sk , flags ) ; if ( err ) goto unlock ; } used = min_t ( unsigned long , used , seglen ) ; used = af_alg_make_sg ( & ctx -> rsgl , from , used , 1 ) ; err = used ; if ( err < 0 ) goto unlock ; if ( ctx -> more || used < ctx -> used ) used -= used % bs ; err = - EINVAL ; if ( ! used ) goto free ; ablkcipher_request_set_crypt ( & ctx -> req , sg , ctx -> rsgl . sg , used , ctx -> iv ) ; err = af_alg_wait_for_completion ( ctx -> enc ? crypto_ablkcipher_encrypt ( & ctx -> req ) : crypto_ablkcipher_decrypt ( & ctx -> req ) , & ctx -> completion ) ; free : af_alg_free_sg ( & ctx -> rsgl ) ; if ( err ) goto unlock ; copied += used ; from += used ; seglen -= used ; skcipher_pull_sgl ( sk , used ) ; } } err = 0 ; unlock : skcipher_wmem_wakeup ( sk ) ; release_sock ( sk ) ; return copied ? : err ; } "," ( sk ) ; for ( ",torvalds@linux/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,CVE-2013-7271,https://github.com/torvalds/linux/commit/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,2014-01-06T16:55Z 1698,CWE-119,"CWE-119 static Image * ReadRLEImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define SkipLinesOp 0x01 # define SetColorOp 0x02 # define SkipPixelsOp 0x03 # define ByteDataOp 0x05 # define RunDataOp 0x06 # define EOFOp 0x07 char magick [ 12 ] ; Image * image ; IndexPacket index ; int opcode , operand , status ; MagickStatusType flags ; MagickSizeType number_pixels ; MemoryInfo * pixel_info ; register IndexPacket * indexes ; register ssize_t x ; register PixelPacket * q ; register ssize_t i ; register unsigned char * p ; size_t bits_per_pixel , map_length , number_colormaps , number_planes , number_planes_filled , one , offset , pixel_info_length ; ssize_t count , y ; unsigned char background_color [ 256 ] , * colormap , pixel , plane , * pixels ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , ""%s"" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; count = ReadBlob ( image , 2 , ( unsigned char * ) magick ) ; if ( ( count != 2 ) || ( memcmp ( magick , ""\\122\\314"" , 2 ) != 0 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; do { image -> page . x = ReadBlobLSBShort ( image ) ; image -> page . y = ReadBlobLSBShort ( image ) ; image -> columns = ReadBlobLSBShort ( image ) ; image -> rows = ReadBlobLSBShort ( image ) ; flags = ( MagickStatusType ) ReadBlobByte ( image ) ; image -> matte = flags & 0x04 ? MagickTrue : MagickFalse ; number_planes = ( size_t ) ReadBlobByte ( image ) ; bits_per_pixel = ( size_t ) ReadBlobByte ( image ) ; number_colormaps = ( size_t ) ReadBlobByte ( image ) ; map_length = ( unsigned char ) ReadBlobByte ( image ) ; if ( map_length >= 32 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; one = 1 ; map_length = one << map_length ; if ( ( number_planes == 0 ) || ( number_planes == 2 ) || ( ( flags & 0x04 ) && ( number_colormaps > 254 ) ) || ( bits_per_pixel != 8 ) || ( image -> columns == 0 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( flags & 0x02 ) { for ( i = 0 ; i < ( ssize_t ) number_planes ; i ++ ) background_color [ i ] = 0 ; ( void ) ReadBlobByte ( image ) ; } else { p = background_color ; for ( i = 0 ; i < ( ssize_t ) number_planes ; i ++ ) * p ++ = ( unsigned char ) ReadBlobByte ( image ) ; } if ( ( number_planes & 0x01 ) == 0 ) ( void ) ReadBlobByte ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } colormap = ( unsigned char * ) NULL ; if ( number_colormaps != 0 ) { colormap = ( unsigned char * ) AcquireQuantumMemory ( number_colormaps , 3 * map_length * sizeof ( * colormap ) ) ; if ( colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; p = colormap ; for ( i = 0 ; i < ( ssize_t ) number_colormaps ; i ++ ) for ( x = 0 ; x < ( ssize_t ) map_length ; x ++ ) * p ++ = ( unsigned char ) ScaleShortToQuantum ( ReadBlobLSBShort ( image ) ) ; } if ( ( flags & 0x08 ) != 0 ) { char * comment ; size_t length ; length = ReadBlobLSBShort ( image ) ; if ( length != 0 ) { comment = ( char * ) AcquireQuantumMemory ( length , sizeof ( * comment ) ) ; if ( comment == ( char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; ( void ) ReadBlob ( image , length - 1 , ( unsigned char * ) comment ) ; comment [ length - 1 ] = '\\0' ; ( void ) SetImageProperty ( image , ""comment"" , comment ) ; comment = DestroyString ( comment ) ; if ( ( length & 0x01 ) == 0 ) ( void ) ReadBlobByte ( image ) ; } } if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; } if ( image -> matte != MagickFalse ) number_planes ++ ; number_pixels = ( MagickSizeType ) image -> columns * image -> rows ; number_planes_filled = ( number_planes % 2 == 0 ) ? number_planes : number_planes + 1 ; if ( ( number_pixels * number_planes_filled ) != ( size_t ) ( number_pixels * number_planes_filled ) ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; pixel_info = AcquireVirtualMemory ( image -> columns , image -> rows * MagickMax ( number_planes_filled , 4 ) * sizeof ( * pixels ) ) ; if ( pixel_info == ( MemoryInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; pixel_info_length = image -> columns * image -> rows * MagickMax ( number_planes_filled , 4 ) ; pixels = ( unsigned char * ) GetVirtualMemoryBlob ( pixel_info ) ; if ( ( flags & 0x01 ) && ! ( flags & 0x02 ) ) { ssize_t j ; p = pixels ; for ( i = 0 ; i < ( ssize_t ) number_pixels ; i ++ ) { if ( image -> matte == MagickFalse ) for ( j = 0 ; j < ( ssize_t ) number_planes ; j ++ ) * p ++ = background_color [ j ] ; else { for ( j = 0 ; j < ( ssize_t ) ( number_planes - 1 ) ; j ++ ) * p ++ = background_color [ j ] ; * p ++ = 0 ; } } } plane = 0 ; x = 0 ; y = 0 ; opcode = ReadBlobByte ( image ) ; do { switch ( opcode & 0x3f ) { case SkipLinesOp : { operand = ReadBlobByte ( image ) ; if ( opcode & 0x40 ) operand = ReadBlobLSBSignedShort ( image ) ; x = 0 ; y += operand ; break ; } case SetColorOp : { operand = ReadBlobByte ( image ) ; plane = ( unsigned char ) operand ; if ( plane == 255 ) plane = ( unsigned char ) ( number_planes - 1 ) ; x = 0 ; break ; } case SkipPixelsOp : { operand = ReadBlobByte ( image ) ; if ( opcode & 0x40 ) operand = ReadBlobLSBSignedShort ( image ) ; x += operand ; break ; } case ByteDataOp : { operand = ReadBlobByte ( image ) ; if ( opcode & 0x40 ) operand = ReadBlobLSBSignedShort ( image ) ; offset = ( ( image -> rows - y - 1 ) * image -> columns * number_planes ) + x * number_planes + plane ; operand ++ ; if ( offset + ( ( size_t ) operand * number_planes ) > pixel_info_length ) { if ( number_colormaps != 0 ) colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; } p = pixels + offset ; for ( i = 0 ; i < ( ssize_t ) operand ; i ++ ) { pixel = ( unsigned char ) ReadBlobByte ( image ) ; if ( ( y < ( ssize_t ) image -> rows ) && ( ( x + i ) < ( ssize_t ) image -> columns ) ) * p = pixel ; p += number_planes ; } if ( operand & 0x01 ) ( void ) ReadBlobByte ( image ) ; x += operand ; break ; } case RunDataOp : { operand = ReadBlobByte ( image ) ; if ( opcode & 0x40 ) operand = ReadBlobLSBSignedShort ( image ) ; pixel = ( unsigned char ) ReadBlobByte ( image ) ; ( void ) ReadBlobByte ( image ) ; operand ++ ; offset = ( ( image -> rows - y - 1 ) * image -> columns * number_planes ) + x * number_planes + plane ; p = pixels + offset ; if ( offset + ( ( size_t ) operand * number_planes ) > pixel_info_length ) { if ( number_colormaps != 0 ) colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; } for ( i = 0 ; i < ( ssize_t ) operand ; i ++ ) { if ( ( y < ( ssize_t ) image -> rows ) && ( ( x + i ) < ( ssize_t ) image -> columns ) ) * p = pixel ; p += number_planes ; } x += operand ; break ; } default : break ; } opcode = ReadBlobByte ( image ) ; } while ( ( ( opcode & 0x3f ) != EOFOp ) && ( opcode != EOF ) ) ; if ( number_colormaps != 0 ) { MagickStatusType mask ; mask = ( MagickStatusType ) ( map_length - 1 ) ; p = pixels ; x = ( ssize_t ) number_planes ; if ( number_colormaps == 1 ) for ( i = 0 ; i < ( ssize_t ) number_pixels ; i ++ ) { if ( IsValidColormapIndex ( image , * p & mask , & index , exception ) == MagickFalse ) break ; * p = colormap [ ( ssize_t ) index ] ; p ++ ; } else if ( ( number_planes >= 3 ) && ( number_colormaps >= 3 ) ) for ( i = 0 ; i < ( ssize_t ) number_pixels ; i ++ ) for ( x = 0 ; x < ( ssize_t ) number_planes ; x ++ ) { if ( IsValidColormapIndex ( image , ( size_t ) ( x * map_length + ( * p & mask ) ) , & index , exception ) == MagickFalse ) break ; * p = colormap [ ( ssize_t ) index ] ; p ++ ; } if ( ( i < ( ssize_t ) number_pixels ) || ( x < ( ssize_t ) number_planes ) ) { colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; } } if ( number_planes >= 3 ) { p = pixels ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( q , ScaleCharToQuantum ( * p ++ ) ) ; SetPixelGreen ( q , ScaleCharToQuantum ( * p ++ ) ) ; SetPixelBlue ( q , ScaleCharToQuantum ( * p ++ ) ) ; if ( image -> matte != MagickFalse ) SetPixelAlpha ( q , ScaleCharToQuantum ( * p ++ ) ) ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } } else { if ( number_colormaps == 0 ) map_length = 256 ; if ( AcquireImageColormap ( image , map_length ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; p = colormap ; if ( number_colormaps == 1 ) for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( ( unsigned char ) i ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( ( unsigned char ) i ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( ( unsigned char ) i ) ; } else if ( number_colormaps > 1 ) for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( * p ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( * ( p + map_length ) ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( * ( p + map_length * 2 ) ) ; p ++ ; } p = pixels ; if ( image -> matte == MagickFalse ) { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; indexes = GetAuthenticIndexQueue ( image ) ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) SetPixelIndex ( indexes + x , * p ++ ) ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } ( void ) SyncImage ( image ) ; } else { for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { if ( IsValidColormapIndex ( image , * p ++ , & index , exception ) == MagickFalse ) break ; SetPixelRed ( q , image -> colormap [ ( ssize_t ) index ] . red ) ; if ( IsValidColormapIndex ( image , * p ++ , & index , exception ) == MagickFalse ) break ; SetPixelGreen ( q , image -> colormap [ ( ssize_t ) index ] . green ) ; if ( IsValidColormapIndex ( image , * p ++ , & index , exception ) == MagickFalse ) break ; SetPixelBlue ( q , image -> colormap [ ( ssize_t ) index ] . blue ) ; SetPixelAlpha ( q , ScaleCharToQuantum ( * p ++ ) ) ; q ++ ; } if ( x < ( ssize_t ) image -> columns ) break ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } image -> colormap = ( PixelPacket * ) RelinquishMagickMemory ( image -> colormap ) ; image -> storage_class = DirectClass ; image -> colors = 0 ; } } if ( number_colormaps != 0 ) colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; pixel_info = RelinquishVirtualMemory ( pixel_info ) ; if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } if ( image_info -> number_scenes != 0 ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; ( void ) ReadBlobByte ( image ) ; count = ReadBlob ( image , 2 , ( unsigned char * ) magick ) ; if ( ( count != 0 ) && ( memcmp ( magick , ""\\122\\314"" , 2 ) == 0 ) ) { AcquireNextImage ( image_info , image ) ; if ( GetNextImageInList ( image ) == ( Image * ) NULL ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } image = SyncNextImageInList ( image ) ; status = SetImageProgress ( image , LoadImagesTag , TellBlob ( image ) , GetBlobSize ( image ) ) ; if ( status == MagickFalse ) break ; } } while ( ( count != 0 ) && ( memcmp ( magick , ""\\122\\314"" , 2 ) == 0 ) ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," , one , pixel_info_length ; ssize_t count , offset , y ; ; if ( ( offset < 0 ) || ( ) > pixel_info_length ) + plane ; if ( ( offset < 0 ) || ( offset + ( ( size_t ) operand * number_planes ) > pixel_info_length ) ) { if ( number_colormaps != 0 ) colormap = ( unsigned char * ) RelinquishMagickMemory ( colormap ) ; pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; } + offset ; for ( i ",ImageMagick@ImageMagick/73fb0aac5b958521e1511e179ecc0ad49f70ebaf,CVE-2016-10050,https://github.com/ImageMagick/ImageMagick/commit/73fb0aac5b958521e1511e179ecc0ad49f70ebaf,2017-03-23T17:59Z 1699,CWE-119,"CWE-119 static int newkeys_to_blob ( struct sshbuf * m , struct ssh * ssh , int mode ) { struct sshbuf * b ; struct sshcipher_ctx * cc ; struct sshcomp * comp ; struct sshenc * enc ; struct sshmac * mac ; struct newkeys * newkey ; int r ; if ( ( newkey = ssh -> state -> newkeys [ mode ] ) == NULL ) return SSH_ERR_INTERNAL_ERROR ; enc = & newkey -> enc ; mac = & newkey -> mac ; comp = & newkey -> comp ; cc = ( mode == MODE_OUT ) ? ssh -> state -> send_context : ssh -> state -> receive_context ; if ( ( r = cipher_get_keyiv ( cc , enc -> iv , enc -> iv_len ) ) != 0 ) return r ; if ( ( b = sshbuf_new ( ) ) == NULL ) return SSH_ERR_ALLOC_FAIL ; if ( ( r = sshbuf_put_cstring ( b , enc -> name ) ) != 0 || ( r = sshbuf_put ( b , & enc -> cipher , sizeof ( enc -> cipher ) ) ) != 0 || ( r = sshbuf_put_u32 ( b , enc -> enabled ) ) != 0 || ( r = sshbuf_put_u32 ( b , enc -> block_size ) ) != 0 || ( r = sshbuf_put_string ( b , enc -> key , enc -> key_len ) ) != 0 || ( r = sshbuf_put_string ( b , enc -> iv , enc -> iv_len ) ) != 0 ) goto out ; if ( cipher_authlen ( enc -> cipher ) == 0 ) { if ( ( r = sshbuf_put_cstring ( b , mac -> name ) ) != 0 || ( r = sshbuf_put_u32 ( b , mac -> enabled ) ) != 0 || ( r = sshbuf_put_string ( b , mac -> key , mac -> key_len ) ) != 0 ) goto out ; } if ( ( r = sshbuf_put_u32 ( b , comp -> type ) ) != 0 || ( r = sshbuf_put_u32 ( b , comp -> enabled ) ) != 0 || ( r = sshbuf_put_cstring ( b , comp -> name ) ) != 0 ) goto out ; r = sshbuf_put_stringb ( m , b ) ; out : sshbuf_free ( b ) ; return r ; } "," ( r = sshbuf_put_cstring ( b ",openbsd@src/3095060f479b86288e31c79ecbc5131a66bcd2f9,CVE-2016-10012,https://github.com/openbsd/src/commit/3095060f479b86288e31c79ecbc5131a66bcd2f9,2017-01-05T02:59Z 1700,CWE-000,"CWE-000 static int traceDirective ( MaState * state , cchar * key , cchar * value ) { HttpRoute * route ; char * option , * ovalue , * tok ; route = state -> route ; route -> trace = httpCreateTrace ( route -> trace ) ; for ( option = stok ( sclone ( value ) , ""\\t"" , & tok ) ; option ; option = stok ( 0 , ""\\t"" , & tok ) ) { option = stok ( option , ""=\\t,"" , & ovalue ) ; ovalue = strim ( ovalue , ""\\""\'"" , MPR_TRIM_BOTH ) ; if ( smatch ( option , ""content"" ) ) { httpSetTraceContentSize ( route -> trace , ( ssize ) getnum ( ovalue ) ) ; } else { httpSetTraceEventLevel ( route -> trace , option , atoi ( ovalue ) ) ; } } return 0 ; } "," { option = ssplit ( option , ",embedthis@appweb/7e6a925f5e86a19a7934a94bbd6959101d0b84eb,CVE-2014-9708,https://github.com/embedthis/appweb/commit/7e6a925f5e86a19a7934a94bbd6959101d0b84eb,2015-03-31T14:59Z 1701,CWE-399,"CWE-399 void cib_remote_connection_destroy ( gpointer user_data ) { cib_client_t * client = user_data ; if ( client == NULL ) { return ; } crm_trace ( ""Cleaningupafterclientdisconnect:%s/%s"" , crm_str ( client -> name ) , client -> id ) ; if ( client -> id != NULL ) { if ( ! g_hash_table_remove ( client_list , client -> id ) ) { crm_err ( ""Client%snotfoundinthehashtable"" , client -> name ) ; } } crm_trace ( ""Destroying%s(%p)"" , client -> name , user_data ) ; num_clients -- ; crm_trace ( ""Numunfree\'dclients:%d"" , num_clients ) ; free ( client -> name ) ; free ( client -> callback_id ) ; free ( client -> id ) ; free ( client -> user ) ; free ( client ) ; crm_trace ( ""Freedthecibclient"" ) ; if ( cib_shutdown_flag ) { cib_shutdown ( 0 ) ; } return ; } "," client = user_data ; int csock = 0 num_clients ) ; if ( client -> remote_auth_timeout ) { g_source_remove ( client -> remote_auth_timeout ) ; } if ( client -> encrypted ) { # ifdef HAVE_GNUTLS_GNUTLS_H if ( client -> session ) { void * sock_ptr = gnutls_transport_get_ptr ( * client -> session ) ; csock = GPOINTER_TO_INT ( sock_ptr ) ; if ( client -> handshake_complete ) { gnutls_bye ( * client -> session , GNUTLS_SHUT_WR ) ; } gnutls_deinit ( * client -> session ) ; gnutls_free ( client -> session ) ; } # endif } else { csock = GPOINTER_TO_INT ( client -> session ) ; } client -> session = NULL ; if ( csock > 0 ) { close ( csock ) ; } free ( client -> recv_buf ) ; free ( client ",ClusterLabs@pacemaker/564f7cc2a51dcd2f28ab12a13394f31be5aa3c93,CVE-2013-0281,https://github.com/ClusterLabs/pacemaker/commit/564f7cc2a51dcd2f28ab12a13394f31be5aa3c93,2013-11-23T11:55Z 1702,CWE-763,"CWE-763 static int remarkupvals ( global_State * g ) { lua_State * thread ; lua_State * * p = & g -> twups ; int work = 0 ; while ( ( thread = * p ) != NULL ) { work ++ ; lua_assert ( ! isblack ( thread ) ) ; if ( isgray ( thread ) && thread -> openupval != NULL ) p = & thread -> twups ; else { UpVal * uv ; * p = thread -> twups ; thread -> twups = thread ; for ( uv = thread -> openupval ; uv != NULL ; uv = uv -> u . open . next ) { work ++ ; if ( ! iswhite ( uv ) ) markvalue ( g , uv -> v ) ; } } } return work ; } "," * uv ; lua_assert ( ! isold ( thread ) || thread -> openupval == NULL ) ; next ) { lua_assert ( getage ( uv ) <= getage ( thread ) ) ; ",lua@lua/a6da1472c0c5e05ff249325f979531ad51533110,CVE-2020-24371,https://github.com/lua/lua/commit/a6da1472c0c5e05ff249325f979531ad51533110,2020-08-17T17:15Z 1703,CWE-476,"CWE-476 static gboolean prplcb_xfer_new_send_cb ( gpointer data , gint fd , b_input_condition cond ) { PurpleXfer * xfer = data ; struct im_connection * ic = purple_ic_by_pa ( xfer -> account ) ; struct prpl_xfer_data * px = xfer -> ui_data ; PurpleBuddy * buddy ; const char * who ; buddy = purple_find_buddy ( xfer -> account , xfer -> who ) ; who = buddy ? purple_buddy_get_name ( buddy ) : xfer -> who ; px -> ft = imcb_file_send_start ( ic , ( char * ) who , xfer -> filename , xfer -> size ) ; px -> ft -> data = px ; px -> ft -> accept = prpl_xfer_accept ; px -> ft -> canceled = prpl_xfer_canceled ; px -> ft -> free = prpl_xfer_free ; px -> ft -> write_request = prpl_xfer_write_request ; return FALSE ; } "," size ) ; if ( ! px -> ft ) { return FALSE ; } ",bitlbee@bitlbee/30d598ce7cd3f136ee9d7097f39fa9818a272441,CVE-2017-5668,https://github.com/bitlbee/bitlbee/commit/30d598ce7cd3f136ee9d7097f39fa9818a272441,2017-03-14T14:59Z 1704,CWE-476,"CWE-476 BOOL transport_connect_nla ( rdpTransport * transport ) { freerdp * instance ; rdpSettings * settings ; if ( transport -> layer == TRANSPORT_LAYER_TSG ) return TRUE ; if ( ! transport_connect_tls ( transport ) ) return FALSE ; if ( transport -> settings -> Authentication != TRUE ) return TRUE ; settings = transport -> settings ; instance = ( freerdp * ) settings -> instance ; if ( transport -> credssp == NULL ) transport -> credssp = credssp_new ( instance , transport , settings ) ; if ( credssp_authenticate ( transport -> credssp ) < 0 ) { if ( ! connectErrorCode ) connectErrorCode = AUTHENTICATIONERROR ; fprintf ( stderr , ""Authenticationfailure,checkcredentials.\\n"" ""Ifcredentialsarevalid,theNTLMSSPimplementationmaybetoblame.\\n"" ) ; credssp_free ( transport -> credssp ) ; return FALSE ; } credssp_free ( transport -> credssp ) ; return TRUE ; } "," credssp ) ; transport -> credssp = NULL ; ",FreeRDP@FreeRDP/0773bb9303d24473fe1185d85a424dfe159aff53,CVE-2013-4119,https://github.com/FreeRDP/FreeRDP/commit/0773bb9303d24473fe1185d85a424dfe159aff53,2016-10-03T21:59Z 1705,CWE-20,"CWE-20 static int ovl_rename2 ( struct inode * olddir , struct dentry * old , struct inode * newdir , struct dentry * new , unsigned int flags ) { int err ; enum ovl_path_type old_type ; enum ovl_path_type new_type ; struct dentry * old_upperdir ; struct dentry * new_upperdir ; struct dentry * olddentry ; struct dentry * newdentry ; struct dentry * trap ; bool old_opaque ; bool new_opaque ; bool new_create = false ; bool cleanup_whiteout = false ; bool overwrite = ! ( flags & RENAME_EXCHANGE ) ; bool is_dir = d_is_dir ( old ) ; bool new_is_dir = false ; struct dentry * opaquedir = NULL ; const struct cred * old_cred = NULL ; struct cred * override_cred = NULL ; err = - EINVAL ; if ( flags & ~ ( RENAME_EXCHANGE | RENAME_NOREPLACE ) ) goto out ; flags &= ~ RENAME_NOREPLACE ; err = ovl_check_sticky ( old ) ; if ( err ) goto out ; old_type = ovl_path_type ( old ) ; err = - EXDEV ; if ( OVL_TYPE_MERGE_OR_LOWER ( old_type ) && is_dir ) goto out ; if ( new -> d_inode ) { err = ovl_check_sticky ( new ) ; if ( err ) goto out ; if ( d_is_dir ( new ) ) new_is_dir = true ; new_type = ovl_path_type ( new ) ; err = - EXDEV ; if ( ! overwrite && OVL_TYPE_MERGE_OR_LOWER ( new_type ) && new_is_dir ) goto out ; err = 0 ; if ( ! OVL_TYPE_UPPER ( new_type ) && ! OVL_TYPE_UPPER ( old_type ) ) { if ( ovl_dentry_lower ( old ) -> d_inode == ovl_dentry_lower ( new ) -> d_inode ) goto out ; } if ( OVL_TYPE_UPPER ( new_type ) && OVL_TYPE_UPPER ( old_type ) ) { if ( ovl_dentry_upper ( old ) -> d_inode == ovl_dentry_upper ( new ) -> d_inode ) goto out ; } } else { if ( ovl_dentry_is_opaque ( new ) ) new_type = __OVL_PATH_UPPER ; else new_type = __OVL_PATH_UPPER | __OVL_PATH_PURE ; } err = ovl_want_write ( old ) ; if ( err ) goto out ; err = ovl_copy_up ( old ) ; if ( err ) goto out_drop_write ; err = ovl_copy_up ( new -> d_parent ) ; if ( err ) goto out_drop_write ; if ( ! overwrite ) { err = ovl_copy_up ( new ) ; if ( err ) goto out_drop_write ; } old_opaque = ! OVL_TYPE_PURE_UPPER ( old_type ) ; new_opaque = ! OVL_TYPE_PURE_UPPER ( new_type ) ; if ( old_opaque || new_opaque ) { err = - ENOMEM ; override_cred = prepare_creds ( ) ; if ( ! override_cred ) goto out_drop_write ; cap_raise ( override_cred -> cap_effective , CAP_SYS_ADMIN ) ; cap_raise ( override_cred -> cap_effective , CAP_DAC_OVERRIDE ) ; cap_raise ( override_cred -> cap_effective , CAP_FOWNER ) ; cap_raise ( override_cred -> cap_effective , CAP_FSETID ) ; cap_raise ( override_cred -> cap_effective , CAP_CHOWN ) ; old_cred = override_creds ( override_cred ) ; } if ( overwrite && OVL_TYPE_MERGE_OR_LOWER ( new_type ) && new_is_dir ) { opaquedir = ovl_check_empty_and_clear ( new ) ; err = PTR_ERR ( opaquedir ) ; if ( IS_ERR ( opaquedir ) ) { opaquedir = NULL ; goto out_revert_creds ; } } if ( overwrite ) { if ( old_opaque ) { if ( new -> d_inode || ! new_opaque ) { flags |= RENAME_WHITEOUT ; } else { flags |= RENAME_EXCHANGE ; } } else if ( is_dir && ! new -> d_inode && new_opaque ) { flags |= RENAME_EXCHANGE ; cleanup_whiteout = true ; } } old_upperdir = ovl_dentry_upper ( old -> d_parent ) ; new_upperdir = ovl_dentry_upper ( new -> d_parent ) ; trap = lock_rename ( new_upperdir , old_upperdir ) ; olddentry = ovl_dentry_upper ( old ) ; newdentry = ovl_dentry_upper ( new ) ; if ( newdentry ) { if ( opaquedir ) { newdentry = opaquedir ; opaquedir = NULL ; } else { dget ( newdentry ) ; } } else { new_create = true ; newdentry = lookup_one_len ( new -> d_name . name , new_upperdir , new -> d_name . len ) ; err = PTR_ERR ( newdentry ) ; if ( IS_ERR ( newdentry ) ) goto out_unlock ; } err = - ESTALE ; if ( olddentry -> d_parent != old_upperdir ) goto out_dput ; if ( newdentry -> d_parent != new_upperdir ) goto out_dput ; if ( olddentry == trap ) goto out_dput ; if ( newdentry == trap ) goto out_dput ; if ( is_dir && ! old_opaque && new_opaque ) { err = ovl_set_opaque ( olddentry ) ; if ( err ) goto out_dput ; } if ( ! overwrite && new_is_dir && old_opaque && ! new_opaque ) { err = ovl_set_opaque ( newdentry ) ; if ( err ) goto out_dput ; } if ( old_opaque || new_opaque ) { err = ovl_do_rename ( old_upperdir -> d_inode , olddentry , new_upperdir -> d_inode , newdentry , flags ) ; } else { BUG_ON ( flags & ~ RENAME_EXCHANGE ) ; err = vfs_rename ( old_upperdir -> d_inode , olddentry , new_upperdir -> d_inode , newdentry , NULL , flags ) ; } if ( err ) { if ( is_dir && ! old_opaque && new_opaque ) ovl_remove_opaque ( olddentry ) ; if ( ! overwrite && new_is_dir && old_opaque && ! new_opaque ) ovl_remove_opaque ( newdentry ) ; goto out_dput ; } if ( is_dir && old_opaque && ! new_opaque ) ovl_remove_opaque ( olddentry ) ; if ( ! overwrite && new_is_dir && ! old_opaque && new_opaque ) ovl_remove_opaque ( newdentry ) ; if ( old_opaque != new_opaque ) { ovl_dentry_set_opaque ( old , new_opaque ) ; if ( ! overwrite ) ovl_dentry_set_opaque ( new , old_opaque ) ; } if ( cleanup_whiteout ) ovl_cleanup ( old_upperdir -> d_inode , newdentry ) ; ovl_dentry_version_inc ( old -> d_parent ) ; ovl_dentry_version_inc ( new -> d_parent ) ; out_dput : dput ( newdentry ) ; out_unlock : unlock_rename ( new_upperdir , old_upperdir ) ; out_revert_creds : if ( old_opaque || new_opaque ) { revert_creds ( old_cred ) ; put_cred ( override_cred ) ; } out_drop_write : ovl_drop_write ( old ) ; out : dput ( opaquedir ) ; return err ; } "," ; olddentry = lookup_one_len ( old -> d_name . . name , old_upperdir , old -> d_name . = PTR_ERR ( olddentry ) ; if ( IS_ERR ( olddentry ) ) goto goto out_unlock ; err = - if ( olddentry != ovl_dentry_upper ( old ) ) goto out_dput_old ; newdentry = lookup_one_len ( new -> d_name . name , new_upperdir , new -> d_name . len ) ; err = PTR_ERR ( newdentry ) ; if ( IS_ERR ( newdentry ) ) goto out_dput_old ; err = - ESTALE ; if ( ovl_dentry_upper ( new ) ) { if ( opaquedir ) { if ( newdentry != opaquedir ) goto out_dput goto out_dput ; } else { if ( newdentry != ovl_dentry_upper ( new ) ) goto out_dput goto out_dput ; } } else { new_create = true ; if ( ! d_is_negative ( newdentry ) && ( ! new_opaque || ! ovl_is_whiteout ( newdentry ) ) ) goto out_dput ; } newdentry ) ; out_dput_old : dput ( olddentry ) ; ",torvalds@linux/11f3710417d026ea2f4fcf362d866342c5274185,CVE-2016-6197,https://github.com/torvalds/linux/commit/11f3710417d026ea2f4fcf362d866342c5274185,2016-08-06T20:59Z