,cwe_id,source,target,project_and_commit_id,cve_id,original_address,time 0,CWE-119,"CWE-119 void vp8_cal_sad ( VP8_COMP * cpi , MACROBLOCKD * xd , MACROBLOCK * x , int recon_yoffset , int near_sadidx [ ] ) { int near_sad [ 8 ] = { 0 } ; BLOCK * b = & x -> block [ 0 ] ; unsigned char * src_y_ptr = * ( b -> base_src ) ; if ( xd -> mb_to_top_edge == 0 && xd -> mb_to_left_edge == 0 ) { near_sad [ 0 ] = near_sad [ 1 ] = near_sad [ 2 ] = INT_MAX ; } else if ( xd -> mb_to_top_edge == 0 ) { near_sad [ 0 ] = near_sad [ 2 ] = INT_MAX ; near_sad [ 1 ] = cpi -> fn_ptr [ BLOCK_16X16 ] . sdf ( src_y_ptr , b -> src_stride , xd -> dst . y_buffer - 16 , xd -> dst . y_stride , UINT_MAX ) ; } else if ( xd -> mb_to_left_edge == 0 ) { near_sad [ 1 ] = near_sad [ 2 ] = INT_MAX ; near_sad [ 0 ] = cpi -> fn_ptr [ BLOCK_16X16 ] . sdf ( src_y_ptr , b -> src_stride , xd -> dst . y_buffer - xd -> dst . y_stride * 16 , xd -> dst . y_stride , UINT_MAX ) ; } else { near_sad [ 0 ] = cpi -> fn_ptr [ BLOCK_16X16 ] . sdf ( src_y_ptr , b -> src_stride , xd -> dst . y_buffer - xd -> dst . y_stride * 16 , xd -> dst . y_stride , UINT_MAX ) ; near_sad [ 1 ] = cpi -> fn_ptr [ BLOCK_16X16 ] . sdf ( src_y_ptr , b -> src_stride , xd -> dst . y_buffer - 16 , xd -> dst . y_stride , UINT_MAX ) ; near_sad [ 2 ] = cpi -> fn_ptr [ BLOCK_16X16 ] . sdf ( src_y_ptr , b -> src_stride , xd -> dst . y_buffer - xd -> dst . y_stride * 16 - 16 , xd -> dst . y_stride , UINT_MAX ) ; } if ( cpi -> common . last_frame_type != KEY_FRAME ) { unsigned char * pre_y_buffer = cpi -> common . yv12_fb [ cpi -> common . lst_fb_idx ] . y_buffer + recon_yoffset ; int pre_y_stride = cpi -> common . yv12_fb [ cpi -> common . lst_fb_idx ] . y_stride ; if ( xd -> mb_to_top_edge == 0 ) near_sad [ 4 ] = INT_MAX ; if ( xd -> mb_to_left_edge == 0 ) near_sad [ 5 ] = INT_MAX ; if ( xd -> mb_to_right_edge == 0 ) near_sad [ 6 ] = INT_MAX ; if ( xd -> mb_to_bottom_edge == 0 ) near_sad [ 7 ] = INT_MAX ; if ( near_sad [ 4 ] != INT_MAX ) near_sad [ 4 ] = cpi -> fn_ptr [ BLOCK_16X16 ] . sdf ( src_y_ptr , b -> src_stride , pre_y_buffer - pre_y_stride * 16 , pre_y_stride , UINT_MAX ) ; if ( near_sad [ 5 ] != INT_MAX ) near_sad [ 5 ] = cpi -> fn_ptr [ BLOCK_16X16 ] . sdf ( src_y_ptr , b -> src_stride , pre_y_buffer - 16 , pre_y_stride , UINT_MAX ) ; near_sad [ 3 ] = cpi -> fn_ptr [ BLOCK_16X16 ] . sdf ( src_y_ptr , b -> src_stride , pre_y_buffer , pre_y_stride , UINT_MAX ) ; if ( near_sad [ 6 ] != INT_MAX ) near_sad [ 6 ] = cpi -> fn_ptr [ BLOCK_16X16 ] . sdf ( src_y_ptr , b -> src_stride , pre_y_buffer + 16 , pre_y_stride , UINT_MAX ) ; if ( near_sad [ 7 ] != INT_MAX ) near_sad [ 7 ] = cpi -> fn_ptr [ BLOCK_16X16 ] . sdf ( src_y_ptr , b -> src_stride , pre_y_buffer + pre_y_stride * 16 , pre_y_stride , UINT_MAX ) ; } if ( cpi -> common . last_frame_type != KEY_FRAME ) { insertsortsad ( near_sad , near_sadidx , 8 ) ; } else { insertsortsad ( near_sad , near_sadidx , 3 ) ; } } "," dst . y_stride ) ; } dst . y_stride ) ; } dst . y_stride ) ; near_sad dst . y_stride ) ; near_sad dst . y_stride ) ; } 16 , pre_y_stride ) ; if 16 , pre_y_stride ) ; near_sad pre_y_buffer , pre_y_stride ) ; if 16 , pre_y_stride ) ; if 16 , pre_y_stride ) ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1,CWE-399,"CWE-399 int xfs_setattr_nonsize ( struct xfs_inode * ip , struct iattr * iattr , int flags ) { xfs_mount_t * mp = ip -> i_mount ; struct inode * inode = VFS_I ( ip ) ; int mask = iattr -> ia_valid ; xfs_trans_t * tp ; int error ; kuid_t uid = GLOBAL_ROOT_UID , iuid = GLOBAL_ROOT_UID ; kgid_t gid = GLOBAL_ROOT_GID , igid = GLOBAL_ROOT_GID ; struct xfs_dquot * udqp = NULL , * gdqp = NULL ; struct xfs_dquot * olddquot1 = NULL , * olddquot2 = NULL ; ASSERT ( ( mask & ATTR_SIZE ) == 0 ) ; if ( XFS_IS_QUOTA_ON ( mp ) && ( mask & ( ATTR_UID | ATTR_GID ) ) ) { uint qflags = 0 ; if ( ( mask & ATTR_UID ) && XFS_IS_UQUOTA_ON ( mp ) ) { uid = iattr -> ia_uid ; qflags |= XFS_QMOPT_UQUOTA ; } else { uid = inode -> i_uid ; } if ( ( mask & ATTR_GID ) && XFS_IS_GQUOTA_ON ( mp ) ) { gid = iattr -> ia_gid ; qflags |= XFS_QMOPT_GQUOTA ; } else { gid = inode -> i_gid ; } ASSERT ( udqp == NULL ) ; ASSERT ( gdqp == NULL ) ; error = xfs_qm_vop_dqalloc ( ip , xfs_kuid_to_uid ( uid ) , xfs_kgid_to_gid ( gid ) , xfs_get_projid ( ip ) , qflags , & udqp , & gdqp , NULL ) ; if ( error ) return error ; } error = xfs_trans_alloc ( mp , & M_RES ( mp ) -> tr_ichange , 0 , 0 , 0 , & tp ) ; if ( error ) goto out_dqrele ; xfs_ilock ( ip , XFS_ILOCK_EXCL ) ; xfs_trans_ijoin ( tp , ip , 0 ) ; if ( mask & ( ATTR_UID | ATTR_GID ) ) { iuid = inode -> i_uid ; igid = inode -> i_gid ; gid = ( mask & ATTR_GID ) ? iattr -> ia_gid : igid ; uid = ( mask & ATTR_UID ) ? iattr -> ia_uid : iuid ; if ( XFS_IS_QUOTA_RUNNING ( mp ) && ( ( XFS_IS_UQUOTA_ON ( mp ) && ! uid_eq ( iuid , uid ) ) || ( XFS_IS_GQUOTA_ON ( mp ) && ! gid_eq ( igid , gid ) ) ) ) { ASSERT ( tp ) ; error = xfs_qm_vop_chown_reserve ( tp , ip , udqp , gdqp , NULL , capable ( CAP_FOWNER ) ? XFS_QMOPT_FORCE_RES : 0 ) ; if ( error ) goto out_cancel ; } } if ( mask & ( ATTR_UID | ATTR_GID ) ) { if ( ( inode -> i_mode & ( S_ISUID | S_ISGID ) ) && ! capable ( CAP_FSETID ) ) inode -> i_mode &= ~ ( S_ISUID | S_ISGID ) ; if ( ! uid_eq ( iuid , uid ) ) { if ( XFS_IS_QUOTA_RUNNING ( mp ) && XFS_IS_UQUOTA_ON ( mp ) ) { ASSERT ( mask & ATTR_UID ) ; ASSERT ( udqp ) ; olddquot1 = xfs_qm_vop_chown ( tp , ip , & ip -> i_udquot , udqp ) ; } ip -> i_d . di_uid = xfs_kuid_to_uid ( uid ) ; inode -> i_uid = uid ; } if ( ! gid_eq ( igid , gid ) ) { if ( XFS_IS_QUOTA_RUNNING ( mp ) && XFS_IS_GQUOTA_ON ( mp ) ) { ASSERT ( xfs_sb_version_has_pquotino ( & mp -> m_sb ) || ! XFS_IS_PQUOTA_ON ( mp ) ) ; ASSERT ( mask & ATTR_GID ) ; ASSERT ( gdqp ) ; olddquot2 = xfs_qm_vop_chown ( tp , ip , & ip -> i_gdquot , gdqp ) ; } ip -> i_d . di_gid = xfs_kgid_to_gid ( gid ) ; inode -> i_gid = gid ; } } if ( mask & ATTR_MODE ) xfs_setattr_mode ( ip , iattr ) ; if ( mask & ( ATTR_ATIME | ATTR_CTIME | ATTR_MTIME ) ) xfs_setattr_time ( ip , iattr ) ; xfs_trans_log_inode ( tp , ip , XFS_ILOG_CORE ) ; XFS_STATS_INC ( mp , xs_ig_attrchg ) ; if ( mp -> m_flags & XFS_MOUNT_WSYNC ) xfs_trans_set_sync ( tp ) ; error = xfs_trans_commit ( tp ) ; xfs_iunlock ( ip , XFS_ILOCK_EXCL ) ; xfs_qm_dqrele ( olddquot1 ) ; xfs_qm_dqrele ( olddquot2 ) ; xfs_qm_dqrele ( udqp ) ; xfs_qm_dqrele ( gdqp ) ; if ( error ) return error ; if ( ( mask & ATTR_MODE ) && ! ( flags & XFS_ATTR_NOACL ) ) { error = posix_acl_chmod ( inode , inode -> i_mode ) ; if ( error ) return error ; } return 0 ; out_cancel : xfs_trans_cancel ( tp ) ; out_dqrele : xfs_qm_dqrele ( udqp ) ; xfs_qm_dqrele ( gdqp ) ; return error ; } "," tp ) ; xfs_iunlock ( ip , XFS_ILOCK_EXCL ) ; ",torvalds@linux/1fb254aa983bf190cfd685d40c64a480a9bafaee,CVE-2019-15538,https://github.com/torvalds/linux/commit/1fb254aa983bf190cfd685d40c64a480a9bafaee,2019-08-25T16:15Z 2,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 3,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 4,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 5,CWE-000,"CWE-000 static void parse_input ( h2o_http2_conn_t * conn ) { size_t http2_max_concurrent_requests_per_connection = conn -> super . ctx -> globalconf -> http2 . max_concurrent_requests_per_connection ; int perform_early_exit = 0 ; if ( conn -> num_streams . pull . half_closed + conn -> num_streams . push . half_closed != http2_max_concurrent_requests_per_connection ) perform_early_exit = 1 ; while ( conn -> state < H2O_HTTP2_CONN_STATE_IS_CLOSING && conn -> sock -> input -> size != 0 ) { if ( perform_early_exit == 1 && conn -> num_streams . pull . half_closed + conn -> num_streams . push . half_closed == http2_max_concurrent_requests_per_connection ) goto EarlyExit ; const char * err_desc = NULL ; ssize_t ret = conn -> _read_expect ( conn , ( uint8_t * ) conn -> sock -> input -> bytes , conn -> sock -> input -> size , & err_desc ) ; if ( ret == H2O_HTTP2_ERROR_INCOMPLETE ) { break ; } else if ( ret < 0 ) { if ( ret != H2O_HTTP2_ERROR_PROTOCOL_CLOSE_IMMEDIATELY ) { enqueue_goaway ( conn , ( int ) ret , err_desc != NULL ? ( h2o_iovec_t ) { ( char * ) err_desc , strlen ( err_desc ) } : ( h2o_iovec_t ) { } ) ; } close_connection ( conn ) ; return ; } h2o_buffer_consume ( & conn -> sock -> input , ret ) ; } if ( ! h2o_socket_is_reading ( conn -> sock ) ) h2o_socket_read_start ( conn -> sock , on_read ) ; return ; EarlyExit : if ( h2o_socket_is_reading ( conn -> sock ) ) h2o_socket_read_stop ( conn -> sock ) ; } "," static int parse_input ( h2o_http2_conn_t ) ; } return ( conn ) ; } h2o_buffer_consume ) ; return 0 sock ) ; return 0 ; ",h2o@h2o/1c0808d580da09fdec5a9a74ff09e103ea058dd4,CVE-2016-4817,https://github.com/h2o/h2o/commit/1c0808d580da09fdec5a9a74ff09e103ea058dd4,2016-06-19T01:59Z 6,CWE-125,"CWE-125 int _yr_scan_verify_re_match ( YR_SCAN_CONTEXT * context , YR_AC_MATCH * ac_match , uint8_t * data , size_t data_size , size_t data_base , size_t offset ) { CALLBACK_ARGS callback_args ; RE_EXEC_FUNC exec ; int forward_matches = - 1 ; int backward_matches = - 1 ; int flags = 0 ; if ( STRING_IS_GREEDY_REGEXP ( ac_match -> string ) ) flags |= RE_FLAGS_GREEDY ; if ( STRING_IS_NO_CASE ( ac_match -> string ) ) flags |= RE_FLAGS_NO_CASE ; if ( STRING_IS_DOT_ALL ( ac_match -> string ) ) flags |= RE_FLAGS_DOT_ALL ; if ( STRING_IS_FAST_REGEXP ( ac_match -> string ) ) exec = yr_re_fast_exec ; else exec = yr_re_exec ; if ( STRING_IS_ASCII ( ac_match -> string ) ) { forward_matches = exec ( ac_match -> forward_code , data + offset , data_size - offset , offset > 0 ? flags | RE_FLAGS_NOT_AT_START : flags , NULL , NULL ) ; } if ( STRING_IS_WIDE ( ac_match -> string ) && forward_matches == - 1 ) { flags |= RE_FLAGS_WIDE ; forward_matches = exec ( ac_match -> forward_code , data + offset , data_size - offset , offset > 0 ? flags | RE_FLAGS_NOT_AT_START : flags , NULL , NULL ) ; } switch ( forward_matches ) { case - 1 : return ERROR_SUCCESS ; case - 2 : return ERROR_INSUFFICIENT_MEMORY ; case - 3 : return ERROR_TOO_MANY_MATCHES ; case - 4 : return ERROR_TOO_MANY_RE_FIBERS ; case - 5 : return ERROR_INTERNAL_FATAL_ERROR ; } if ( forward_matches == 0 && ac_match -> backward_code == NULL ) return ERROR_SUCCESS ; callback_args . string = ac_match -> string ; callback_args . context = context ; callback_args . data = data ; callback_args . data_size = data_size ; callback_args . data_base = data_base ; callback_args . forward_matches = forward_matches ; callback_args . full_word = STRING_IS_FULL_WORD ( ac_match -> string ) ; if ( ac_match -> backward_code != NULL ) { backward_matches = exec ( ac_match -> backward_code , data + offset , offset , flags | RE_FLAGS_BACKWARDS | RE_FLAGS_EXHAUSTIVE , _yr_scan_match_callback , ( void * ) & callback_args ) ; switch ( backward_matches ) { case - 2 : return ERROR_INSUFFICIENT_MEMORY ; case - 3 : return ERROR_TOO_MANY_MATCHES ; case - 4 : return ERROR_TOO_MANY_RE_FIBERS ; case - 5 : return ERROR_INTERNAL_FATAL_ERROR ; } } else { FAIL_ON_ERROR ( _yr_scan_match_callback ( data + offset , 0 , flags , & callback_args ) ) ; } return ERROR_SUCCESS ; } "," offset , offset , flags , NULL offset , offset , flags , NULL , data + offset , data_size - ",VirusTotal@yara/83d799804648c2a0895d40a19835d9b757c6fa4e,CVE-2017-8294,https://github.com/VirusTotal/yara/commit/83d799804648c2a0895d40a19835d9b757c6fa4e,2017-04-27T14:59Z 7,CWE-200,"CWE-200 static int open_url ( AVFormatContext * s , AVIOContext * * pb , const char * url , AVDictionary * opts , AVDictionary * opts2 , int * is_http ) { HLSContext * c = s -> priv_data ; AVDictionary * tmp = NULL ; const char * proto_name = NULL ; int ret ; av_dict_copy ( & tmp , opts , 0 ) ; av_dict_copy ( & tmp , opts2 , 0 ) ; if ( av_strstart ( url , ""crypto"" , NULL ) ) { if ( url [ 6 ] == '+' || url [ 6 ] == ':' ) proto_name = avio_find_protocol_name ( url + 7 ) ; } if ( ! proto_name ) proto_name = avio_find_protocol_name ( url ) ; if ( ! proto_name ) return AVERROR_INVALIDDATA ; if ( ! av_strstart ( proto_name , ""http"" , NULL ) && ! av_strstart ( proto_name , ""file"" , NULL ) ) return AVERROR_INVALIDDATA ; if ( ! strncmp ( proto_name , url , strlen ( proto_name ) ) && url [ strlen ( proto_name ) ] == ':' ) ; else if ( av_strstart ( url , ""crypto"" , NULL ) && ! strncmp ( proto_name , url + 7 , strlen ( proto_name ) ) && url [ 7 + strlen ( proto_name ) ] == ':' ) ; else if ( strcmp ( proto_name , ""file"" ) || ! strncmp ( url , ""file,"" , 5 ) ) return AVERROR_INVALIDDATA ; ret = s -> io_open ( s , pb , url , AVIO_FLAG_READ , & tmp ) ; if ( ret >= 0 ) { char * new_cookies = NULL ; if ( ! ( s -> flags & AVFMT_FLAG_CUSTOM_IO ) ) av_opt_get ( * pb , ""cookies"" , AV_OPT_SEARCH_CHILDREN , ( uint8_t * * ) & new_cookies ) ; if ( new_cookies ) { av_free ( c -> cookies ) ; c -> cookies = new_cookies ; } av_dict_set ( & opts , ""cookies"" , c -> cookies , 0 ) ; } av_dict_free ( & tmp ) ; if ( is_http ) * is_http = av_strstart ( proto_name , ""http"" , NULL ) ; return ret ; } "," ; if ( av_strstart ( proto_name ( proto_name , ""file"" , NULL ) ) { if ( strcmp ( c -> allowed_extensions , ""ALL"" ) && ! av_match_ext ( url , c -> allowed_extensions ) ) { av_log ( s , AV_LOG_ERROR , ""Filenameextensionof\\\'%s\\\'isnotacommonmultimediaextension,blockedforsecurityreasons.\\n"" ""Ifyouwishtooverridethisadjustallowed_extensions,youcansetitto\\\'ALL\\\'toallowall\\n"" , url ) ; return AVERROR_INVALIDDATA ; } } else if ( av_strstart ( proto_name , , NULL ) ) { ; } else return AVERROR_INVALIDDATA ; ",FFmpeg@FFmpeg/189ff4219644532bdfa7bab28dfedaee4d6d4021,CVE-2017-9993,https://github.com/FFmpeg/FFmpeg/commit/189ff4219644532bdfa7bab28dfedaee4d6d4021,2017-06-28T06:29Z 8,CWE-125,"CWE-125 static const struct usb_cdc_union_desc * ims_pcu_get_cdc_union_desc ( struct usb_interface * intf ) { const void * buf = intf -> altsetting -> extra ; size_t buflen = intf -> altsetting -> extralen ; struct usb_cdc_union_desc * union_desc ; if ( ! buf ) { dev_err ( & intf -> dev , ""Missingdescriptordata\\n"" ) ; return NULL ; } if ( ! buflen ) { dev_err ( & intf -> dev , ""Zerolengthdescriptor\\n"" ) ; return NULL ; } while ( buflen > 0 ) { union_desc = ( struct usb_cdc_union_desc * ) buf ; if ( union_desc -> bDescriptorType == USB_DT_CS_INTERFACE && union_desc -> bDescriptorSubType == USB_CDC_UNION_TYPE ) { dev_dbg ( & intf -> dev , ""Foundunionheader\\n"" ) ; return union_desc ; } buflen -= union_desc -> bLength ; buf += union_desc -> bLength ; } dev_err ( & intf -> dev , ""MissingCDCuniondescriptor\\n"" ) ; return NULL ; } "," while ( buflen >= sizeof ( * union_desc ) ) { union_desc = ( struct usb_cdc_union_desc * ) buf ; if ( union_desc -> bLength > buflen ) { dev_err ( & intf -> dev , ""Toolargedescriptor\\n"" ) ; return NULL ; } if ( union_desc ""Foundunionheader\\n"" ) ; if ( union_desc -> bLength >= sizeof ( * union_desc ) ) return union_desc ; dev_err ( & intf -> dev , ""Uniondescriptortoshort(%dvs%zd\\n)"" , union_desc -> bLength , sizeof ( * union_desc ) ) ; return NULL ; } buflen ",torvalds@linux/ea04efee7635c9120d015dcdeeeb6988130cb67a,CVE-2017-16645,https://github.com/torvalds/linux/commit/ea04efee7635c9120d015dcdeeeb6988130cb67a,2017-11-07T23:29Z 9,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 ; 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 += 2 ; break ; case STAR : if ( i + 1 >= NCH ( n ) || ( i + 2 == NCH ( n ) && TYPE ( CHILD ( n , i + 1 ) ) == COMMA ) ) { ast_error ( c , CHILD ( n , i ) , ""namedargumentsmustfollowbare*"" ) ; return NULL ; } ch = CHILD ( n , i + 1 ) ; if ( TYPE ( ch ) == COMMA ) { int res = 0 ; i += 2 ; 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 += 3 ; 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 += 3 ; 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 ) ; } "," ; i += 1 ; if ( i < NCH ( n ) && TYPE ( CHILD ( n , i ) ) == COMMA ) i += 1 ; break ; n ) && ( ) == COMMA || TYPE ( CHILD ( n , i + 1 ) ) == TYPE_COMMENT ) += 2 ; if ( i < NCH ( n ) && TYPE ( CHILD ( n , i ) ) == TYPE_COMMENT ) { ast_error ( c , CHILD ( n , i ) , ""bare*hasassociatedtypecomment"" ) ; 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 ; 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 ; ",python@typed_ast/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,CVE-2019-19275,https://github.com/python/typed_ast/commit/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,2019-11-26T15:15Z 10,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 11,CWE-358,"CWE-358 int udpv6_recvmsg ( struct sock * sk , struct msghdr * msg , size_t len , int noblock , int flags , int * addr_len ) { struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct inet_sock * inet = inet_sk ( sk ) ; struct sk_buff * skb ; unsigned int ulen , copied ; int peeked , off = 0 ; int err ; int is_udplite = IS_UDPLITE ( sk ) ; int is_udp4 ; bool slow ; if ( flags & MSG_ERRQUEUE ) return ipv6_recv_error ( sk , msg , len , addr_len ) ; if ( np -> rxpmtu && np -> rxopt . bits . rxpmtu ) return ipv6_recv_rxpmtu ( sk , msg , len , addr_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 ; is_udp4 = ( skb -> protocol == htons ( ETH_P_IP ) ) ; 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_msg ( skb , sizeof ( struct udphdr ) , msg , copied ) ; else { err = skb_copy_and_csum_datagram_msg ( skb , sizeof ( struct udphdr ) , msg ) ; if ( err == - EINVAL ) goto csum_copy_err ; } if ( unlikely ( err ) ) { trace_kfree_skb ( skb , udpv6_recvmsg ) ; if ( ! peeked ) { atomic_inc ( & sk -> sk_drops ) ; if ( is_udp4 ) UDP_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INERRORS , is_udplite ) ; else UDP6_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INERRORS , is_udplite ) ; } goto out_free ; } if ( ! peeked ) { if ( is_udp4 ) UDP_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INDATAGRAMS , is_udplite ) ; else UDP6_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INDATAGRAMS , is_udplite ) ; } sock_recv_ts_and_drops ( msg , sk , skb ) ; if ( msg -> msg_name ) { DECLARE_SOCKADDR ( struct sockaddr_in6 * , sin6 , msg -> msg_name ) ; sin6 -> sin6_family = AF_INET6 ; sin6 -> sin6_port = udp_hdr ( skb ) -> source ; sin6 -> sin6_flowinfo = 0 ; if ( is_udp4 ) { ipv6_addr_set_v4mapped ( ip_hdr ( skb ) -> saddr , & sin6 -> sin6_addr ) ; sin6 -> sin6_scope_id = 0 ; } else { sin6 -> sin6_addr = ipv6_hdr ( skb ) -> saddr ; sin6 -> sin6_scope_id = ipv6_iface_scope_id ( & sin6 -> sin6_addr , inet6_iif ( skb ) ) ; } * addr_len = sizeof ( * sin6 ) ; } if ( np -> rxopt . all ) ip6_datagram_recv_common_ctl ( sk , msg , skb ) ; if ( is_udp4 ) { if ( inet -> cmsg_flags ) ip_cmsg_recv ( msg , skb ) ; } else { if ( np -> rxopt . all ) ip6_datagram_recv_specific_ctl ( sk , 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 ) ) { if ( is_udp4 ) { UDP_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_CSUMERRORS , is_udplite ) ; UDP_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INERRORS , is_udplite ) ; } else { UDP6_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_CSUMERRORS , is_udplite ) ; UDP6_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INERRORS , is_udplite ) ; } } unlock_sock_fast ( sk , slow ) ; cond_resched ( ) ; msg -> msg_flags &= ~ MSG_TRUNC ; goto try_again ; } "," ( sk ) ; bool checksum_valid = false partial_cov ) { checksum_valid = ! udp_lib_checksum_complete ( skb ( skb ) ; if ( ! checksum_valid } if ( checksum_valid || ",torvalds@linux/197c949e7798fbf28cfadc69d9ca0c2abbf93191,CVE-2016-10229,https://github.com/torvalds/linux/commit/197c949e7798fbf28cfadc69d9ca0c2abbf93191,2017-04-04T05:59Z 12,CWE-787,"CWE-787 int TIFFFlushData1 ( TIFF * tif ) { if ( tif -> tif_rawcc > 0 && tif -> tif_flags & TIFF_BUF4WRITE ) { if ( ! isFillOrder ( tif , tif -> tif_dir . td_fillorder ) && ( tif -> tif_flags & TIFF_NOBITREV ) == 0 ) TIFFReverseBits ( ( uint8 * ) tif -> tif_rawdata , tif -> tif_rawcc ) ; if ( ! TIFFAppendToStrip ( tif , isTiled ( tif ) ? tif -> tif_curtile : tif -> tif_curstrip , tif -> tif_rawdata , tif -> tif_rawcc ) ) return ( 0 ) ; tif -> tif_rawcc = 0 ; tif -> tif_rawcp = tif -> tif_rawdata ; } return ( 1 ) ; } "," tif_rawcc ) ) { tif -> tif_rawcc = 0 ; tif -> tif_rawcp = tif -> tif_rawdata ; 0 ) ; } ",vadz@libtiff/83a4b92815ea04969d494416eaae3d4c6b338e4a,CVE-2016-9533,https://github.com/vadz/libtiff/commit/83a4b92815ea04969d494416eaae3d4c6b338e4a#diff-bdc795f6afeb9558c1012b3cfae729ef,2016-11-22T19:59Z 13,CWE-20,"CWE-20 static unsigned long ioapic_read_indirect ( struct kvm_ioapic * ioapic , unsigned long addr , unsigned long length ) { unsigned long result = 0 ; switch ( ioapic -> ioregsel ) { case IOAPIC_REG_VERSION : result = ( ( ( ( IOAPIC_NUM_PINS - 1 ) & 0xff ) << 16 ) | ( IOAPIC_VERSION_ID & 0xff ) ) ; break ; case IOAPIC_REG_APIC_ID : case IOAPIC_REG_ARB_ID : result = ( ( ioapic -> id & 0xf ) << 24 ) ; break ; default : { u32 redir_index = ( ioapic -> ioregsel - 0x10 ) >> 1 ; u64 redir_content ; ASSERT ( redir_index < IOAPIC_NUM_PINS ) ; redir_content = ioapic -> redirtbl [ redir_index ] . bits ; result = ( ioapic -> ioregsel & 0x1 ) ? ( redir_content >> 32 ) & 0xffffffff : redir_content & 0xffffffff ; break ; } } return result ; } "," u64 redir_content ; if ( redir_index < < IOAPIC_NUM_PINS ) redir_content = ioapic ] . bits ; else redir_content = ~ 0ULL ",torvalds@linux/a2c118bfab8bc6b8bb213abfc35201e441693d55,CVE-2013-1798,https://github.com/torvalds/linux/commit/a2c118bfab8bc6b8bb213abfc35201e441693d55,2013-03-22T11:59Z 14,CWE-119,"CWE-119 static void update_golden_frame_stats ( VP8_COMP * cpi ) { VP8_COMMON * cm = & cpi -> common ; if ( cm -> refresh_golden_frame ) { if ( ! cpi -> auto_gold ) cpi -> frames_till_gf_update_due = DEFAULT_GF_INTERVAL ; if ( ( cpi -> pass != 2 ) && ( cpi -> frames_till_gf_update_due > 0 ) ) { cpi -> current_gf_interval = cpi -> frames_till_gf_update_due ; if ( ( cm -> frame_type != KEY_FRAME ) && ! cpi -> source_alt_ref_active ) { cpi -> gf_overspend_bits += ( cpi -> projected_frame_size - cpi -> inter_frame_target ) ; } 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 ; cm -> refresh_golden_frame = 0 ; cpi -> frames_since_golden = 0 ; 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 ; if ( cpi -> oxcf . fixed_q >= 0 && cpi -> oxcf . play_alternate && ! cpi -> common . refresh_alt_ref_frame ) { cpi -> source_alt_ref_pending = 1 ; cpi -> frames_till_gf_update_due = cpi -> baseline_gf_interval ; } if ( ! cpi -> source_alt_ref_pending ) cpi -> source_alt_ref_active = 0 ; if ( cpi -> frames_till_gf_update_due > 0 ) cpi -> frames_till_gf_update_due -- ; } else if ( ! cpi -> common . refresh_alt_ref_frame ) { if ( cpi -> frames_till_gf_update_due > 0 ) cpi -> frames_till_gf_update_due -- ; if ( cpi -> frames_till_alt_ref_frame ) cpi -> frames_till_alt_ref_frame -- ; cpi -> frames_since_golden ++ ; if ( cpi -> frames_since_golden > 1 ) { cpi -> recent_ref_frame_usage [ INTRA_FRAME ] += cpi -> mb . count_mb_ref_frame_usage [ INTRA_FRAME ] ; cpi -> recent_ref_frame_usage [ LAST_FRAME ] += cpi -> mb . count_mb_ref_frame_usage [ LAST_FRAME ] ; cpi -> recent_ref_frame_usage [ GOLDEN_FRAME ] += cpi -> mb . count_mb_ref_frame_usage [ GOLDEN_FRAME ] ; cpi -> recent_ref_frame_usage [ ALTREF_FRAME ] += cpi -> mb . count_mb_ref_frame_usage [ ALTREF_FRAME ] ; } } } "," 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 15,CWE-190,"CWE-190 SPL_METHOD ( SplFileObject , fread ) { spl_filesystem_object * intern = ( spl_filesystem_object * ) zend_object_store_get_object ( getThis ( ) TSRMLS_CC ) ; long length = 0 ; if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) TSRMLS_CC , ""l"" , & length ) == FAILURE ) { return ; } if ( length <= 0 ) { php_error_docref ( NULL TSRMLS_CC , E_WARNING , ""Lengthparametermustbegreaterthan0"" ) ; RETURN_FALSE ; } Z_STRVAL_P ( return_value ) = emalloc ( length + 1 ) ; Z_STRLEN_P ( return_value ) = php_stream_read ( intern -> u . file . stream , Z_STRVAL_P ( return_value ) , length ) ; Z_STRVAL_P ( return_value ) [ Z_STRLEN_P ( return_value ) ] = 0 ; Z_TYPE_P ( return_value ) = IS_STRING ; } "," RETURN_FALSE ; } if ( length > INT_MAX ) { php_error_docref ( NULL TSRMLS_CC , E_WARNING , ""Lengthparametermustbenomorethan%d"" , INT_MAX ) ; RETURN_FALSE ; } ",php@php-src/7245bff300d3fa8bacbef7897ff080a6f1c23eba,CVE-2016-5770,https://github.com/php/php-src/commit/7245bff300d3fa8bacbef7897ff080a6f1c23eba,2016-08-07T10:59Z 16,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 17,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 18,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 19,CWE-200,"CWE-200 int vcc_getsockopt ( struct socket * sock , int level , int optname , char __user * optval , int __user * optlen ) { struct atm_vcc * vcc ; int len ; if ( get_user ( len , optlen ) ) return - EFAULT ; if ( __SO_LEVEL_MATCH ( optname , level ) && len != __SO_SIZE ( optname ) ) return - EINVAL ; vcc = ATM_SD ( sock ) ; switch ( optname ) { case SO_ATMQOS : if ( ! test_bit ( ATM_VF_HASQOS , & vcc -> flags ) ) return - EINVAL ; return copy_to_user ( optval , & vcc -> qos , sizeof ( vcc -> qos ) ) ? - EFAULT : 0 ; case SO_SETCLP : return put_user ( vcc -> atm_options & ATM_ATMOPT_CLP ? 1 : 0 , ( unsigned long __user * ) optval ) ? - EFAULT : 0 ; case SO_ATMPVC : { struct sockaddr_atmpvc pvc ; if ( ! vcc -> dev || ! test_bit ( ATM_VF_ADDR , & vcc -> flags ) ) return - ENOTCONN ; pvc . sap_family = AF_ATMPVC ; pvc . sap_addr . itf = vcc -> dev -> number ; pvc . sap_addr . vpi = vcc -> vpi ; pvc . sap_addr . vci = vcc -> vci ; return copy_to_user ( optval , & pvc , sizeof ( pvc ) ) ? - EFAULT : 0 ; } default : if ( level == SOL_SOCKET ) return - EINVAL ; break ; } if ( ! vcc -> dev || ! vcc -> dev -> ops -> getsockopt ) return - EINVAL ; return vcc -> dev -> ops -> getsockopt ( vcc , level , optname , optval , len ) ; } "," - ENOTCONN ; memset ( & pvc , 0 , sizeof ( pvc ) ) ; ",torvalds@linux/e862f1a9b7df4e8196ebec45ac62295138aa3fc2,CVE-2012-6546,https://github.com/torvalds/linux/commit/e862f1a9b7df4e8196ebec45ac62295138aa3fc2,2013-03-15T20:55Z 20,CWE-404,"CWE-404 static void lockd_down_net ( struct svc_serv * serv , struct net * net ) { struct lockd_net * ln = net_generic ( net , lockd_net_id ) ; if ( ln -> nlmsvc_users ) { if ( -- ln -> nlmsvc_users == 0 ) { nlm_shutdown_hosts_net ( net ) ; cancel_delayed_work_sync ( & ln -> grace_period_end ) ; locks_end_grace ( & ln -> lockd_manager ) ; svc_shutdown_net ( serv , net ) ; dprintk ( ""lockd_down_net:per-netdatadestroyed;net=%p\\n"" , net ) ; } } else { printk ( KERN_ERR ""lockd_down_net:nousers!task=%p,net=%p\\n"" , nlmsvc_task , net ) ; BUG ( ) ; } } "," net ) ; svc_shutdown_net ( serv ",torvalds@linux/c70422f760c120480fee4de6c38804c72aa26bc1,CVE-2017-9059,https://github.com/torvalds/linux/commit/c70422f760c120480fee4de6c38804c72aa26bc1,2017-05-18T06:29Z 21,CWE-404,"CWE-404 static int cp2112_gpio_get_all ( struct gpio_chip * chip ) { struct cp2112_device * dev = gpiochip_get_data ( chip ) ; struct hid_device * hdev = dev -> hdev ; u8 * buf = dev -> in_out_buffer ; unsigned long flags ; int ret ; spin_lock_irqsave ( & dev -> lock , flags ) ; ret = hid_hw_raw_request ( hdev , CP2112_GPIO_GET , buf , CP2112_GPIO_GET_LENGTH , HID_FEATURE_REPORT , HID_REQ_GET_REPORT ) ; if ( ret != CP2112_GPIO_GET_LENGTH ) { hid_err ( hdev , ""errorrequestingGPIOvalues:%d\\n"" , ret ) ; ret = ret < 0 ? ret : - EIO ; goto exit ; } ret = buf [ 1 ] ; exit : spin_unlock_irqrestore ( & dev -> lock , flags ) ; return ret ; } "," -> in_out_buffer ; int ret ; int ret ; mutex_lock ( & dev dev -> lock ) ; ret ; exit : mutex_unlock ( & dev dev -> lock ) ; return ",torvalds@linux/7a7b5df84b6b4e5d599c7289526eed96541a0654,CVE-2017-8071,https://github.com/torvalds/linux/commit/7a7b5df84b6b4e5d599c7289526eed96541a0654,2017-04-23T05:59Z 22,CWE-772,"CWE-772 int sas_smp_get_phy_events ( struct sas_phy * phy ) { int res ; u8 * req ; u8 * resp ; struct sas_rphy * rphy = dev_to_rphy ( phy -> dev . parent ) ; struct domain_device * dev = sas_find_dev_by_rphy ( rphy ) ; req = alloc_smp_req ( RPEL_REQ_SIZE ) ; if ( ! req ) return - ENOMEM ; resp = alloc_smp_resp ( RPEL_RESP_SIZE ) ; if ( ! resp ) { kfree ( req ) ; return - ENOMEM ; } req [ 1 ] = SMP_REPORT_PHY_ERR_LOG ; req [ 9 ] = phy -> number ; res = smp_execute_task ( dev , req , RPEL_REQ_SIZE , resp , RPEL_RESP_SIZE ) ; if ( ! res ) goto out ; phy -> invalid_dword_count = scsi_to_u32 ( & resp [ 12 ] ) ; phy -> running_disparity_error_count = scsi_to_u32 ( & resp [ 16 ] ) ; phy -> loss_of_dword_sync_count = scsi_to_u32 ( & resp [ 20 ] ) ; phy -> phy_reset_problem_count = scsi_to_u32 ( & resp [ 24 ] ) ; out : kfree ( resp ) ; return res ; } "," : kfree ( req ) ; kfree ( ",torvalds@linux/4a491b1ab11ca0556d2fda1ff1301e862a2d44c4,CVE-2018-7757,https://github.com/torvalds/linux/commit/4a491b1ab11ca0556d2fda1ff1301e862a2d44c4,2018-03-08T14:29Z 23,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 24,CWE-20,"CWE-20 static int netbk_count_requests ( struct xenvif * vif , struct xen_netif_tx_request * first , struct xen_netif_tx_request * txp , int work_to_do ) { RING_IDX cons = vif -> tx . req_cons ; int frags = 0 ; if ( ! ( first -> flags & XEN_NETTXF_more_data ) ) return 0 ; do { if ( frags >= work_to_do ) { netdev_dbg ( vif -> dev , ""Needmorefrags\\n"" ) ; return - frags ; } if ( unlikely ( frags >= MAX_SKB_FRAGS ) ) { netdev_dbg ( vif -> dev , ""Toomanyfrags\\n"" ) ; return - frags ; } memcpy ( txp , RING_GET_REQUEST ( & vif -> tx , cons + frags ) , sizeof ( * txp ) ) ; if ( txp -> size > first -> size ) { netdev_dbg ( vif -> dev , ""Fragsgalore\\n"" ) ; return - frags ; } first -> size -= txp -> size ; frags ++ ; if ( unlikely ( ( txp -> offset + txp -> size ) > PAGE_SIZE ) ) { netdev_dbg ( vif -> dev , ""txp->offset:%x,size:%u\\n"" , txp -> offset , txp -> size ) ; return - frags ; } } while ( ( txp ++ ) -> flags & XEN_NETTXF_more_data ) ; return frags ; } "," work_to_do ) { netdev_err ( vif -> dev , ""Needmorefrags\\n"" ) ; netbk_fatal_tx_err ( vif ) ) { netdev_err ( vif -> dev , ""Toomanyfrags\\n"" ) ; netbk_fatal_tx_err ( vif size ) { netdev_err ( vif -> dev , ""Fragisbiggerthanframe.\\n"" ) ; netbk_fatal_tx_err ( vif ) ; return ) ) { netdev_err ( vif -> txp -> size ) ; netbk_fatal_tx_err ( vif ",torvalds@linux/48856286b64e4b66ec62b94e504d0b29c1ade664,CVE-2013-0216,https://github.com/torvalds/linux/commit/48856286b64e4b66ec62b94e504d0b29c1ade664,2013-02-18T04:41Z 25,CWE-125,"CWE-125 static void aodv_extension ( netdissect_options * ndo , const struct aodv_ext * ep , u_int length ) { const struct aodv_hello * ah ; switch ( ep -> type ) { case AODV_EXT_HELLO : ah = ( const struct aodv_hello * ) ( const void * ) ep ; ND_TCHECK ( * ah ) ; if ( length < sizeof ( struct aodv_hello ) ) goto trunc ; ND_PRINT ( ( ndo , ""\\n\\textHELLO%ldms"" , ( unsigned long ) EXTRACT_32BITS ( & ah -> interval ) ) ) ; break ; default : ND_PRINT ( ( ndo , ""\\n\\text%u%u"" , ep -> type , ep -> length ) ) ; break ; } return ; trunc : ND_PRINT ( ( ndo , ""[|hello]"" ) ) ; } "," aodv_hello * ah ; ND_TCHECK ( * ep ) goto trunc ; if ( ep -> length < 4 ) { ND_PRINT ( ( ndo , ""\\n\\textHELLO-badlength%u"" , ep -> length ) ) ; break ; } ",the-tcpdump-group@tcpdump/cbddb98484ea8ec1deece351abd56e063d775b38,CVE-2017-13002,https://github.com/the-tcpdump-group/tcpdump/commit/cbddb98484ea8ec1deece351abd56e063d775b38,2017-09-14T06:29Z 26,CWE-667,"CWE-667 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 ; ret = - EPERM ; if ( unlikely ( ! ( cur -> vm_flags & VM_MAYWRITE ) ) ) 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 ) ; WARN_ON ( ! ( vma -> vm_flags & VM_MAYWRITE ) ) ; 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 ; } "," -> 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 27,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 28,CWE-399,"CWE-399 void mono_gc_cleanup ( void ) { # ifdef DEBUG g_message ( ""%s:cleaningupfinalizer"" , __func__ ) ; # endif if ( ! gc_disabled ) { ResetEvent ( shutdown_event ) ; finished = TRUE ; if ( mono_thread_internal_current ( ) != gc_thread ) { mono_gc_finalize_notify ( ) ; if ( WaitForSingleObjectEx ( shutdown_event , 2000 , FALSE ) == WAIT_TIMEOUT ) { int ret ; suspend_finalizers = TRUE ; mono_thread_internal_stop ( gc_thread ) ; ret = WaitForSingleObjectEx ( gc_thread -> handle , 100 , TRUE ) ; if ( ret == WAIT_TIMEOUT ) { g_warning ( ""Shuttingdownfinalizerthreadtimedout."" ) ; } else { Sleep ( 100 ) ; } } } gc_thread = NULL ; # ifdef HAVE_BOEHM_GC GC_finalizer_notifier = NULL ; # endif } DeleteCriticalSection ( & handle_section ) ; DeleteCriticalSection ( & allocator_section ) ; DeleteCriticalSection ( & finalizer_mutex ) ; } "," finalizer_mutex ) ; DeleteCriticalSection ( & reference_queue_mutex ) ; ",mono@mono/8eb1189099e02372fd45ca1c67230eccf1edddc0,CVE-2011-0991,https://github.com/mono/mono/commit/8eb1189099e02372fd45ca1c67230eccf1edddc0,2011-04-13T21:55Z 29,CWE-404,"CWE-404 static int install_process_keyring ( void ) { struct cred * new ; int ret ; new = prepare_creds ( ) ; if ( ! new ) return - ENOMEM ; ret = install_process_keyring_to_cred ( new ) ; if ( ret < 0 ) { abort_creds ( new ) ; return ret != - EEXIST ? ret : 0 ; } return commit_creds ( new ) ; } "," ; return ret ; } return ",torvalds@linux/c9f838d104fed6f2f61d68164712e3204bf5271b,CVE-2017-7472,https://github.com/torvalds/linux/commit/c9f838d104fed6f2f61d68164712e3204bf5271b,2017-05-11T19:29Z 30,CWE-400,"CWE-400 static zend_bool add_post_var ( zval * arr , post_var_data_t * var , zend_bool eof ) { char * ksep , * vsep , * val ; size_t klen , vlen ; size_t new_vlen ; if ( var -> ptr >= var -> end ) { return 0 ; } vsep = memchr ( var -> ptr , '&' , var -> end - var -> ptr ) ; if ( ! vsep ) { if ( ! eof ) { return 0 ; } else { vsep = var -> end ; } } ksep = memchr ( var -> ptr , '=' , vsep - var -> ptr ) ; if ( ksep ) { * ksep = '\\0' ; klen = ksep - var -> ptr ; vlen = vsep - ++ ksep ; } else { ksep = """" ; klen = vsep - var -> ptr ; vlen = 0 ; } php_url_decode ( var -> ptr , klen ) ; val = estrndup ( ksep , vlen ) ; if ( vlen ) { vlen = php_url_decode ( val , vlen ) ; } if ( sapi_module . input_filter ( PARSE_POST , var -> ptr , & val , vlen , & new_vlen ) ) { php_register_variable_safe ( var -> ptr , val , new_vlen , arr ) ; } efree ( val ) ; var -> ptr = vsep + ( vsep != var -> end ) ; return 1 ; } "," { char * start , * 0 ; } start = var -> ptr + var -> already_scanned ; = memchr ( start , '&' , -> end - start ) ; if eof ) { var -> already_scanned = var -> end - var -> ptr ; end ) ; var -> already_scanned = 0 ; ",php@php-src/a15bffd105ac28fd0dd9b596632dbf035238fda3,CVE-2017-11142,https://github.com/php/php-src/commit/a15bffd105ac28fd0dd9b596632dbf035238fda3,2017-07-10T14:29Z 31,CWE-119,"CWE-119 void set_cfg_option ( char * opt_string ) { char * sep , * sep2 , szSec [ 1024 ] , szKey [ 1024 ] , szVal [ 1024 ] ; sep = strchr ( opt_string , ':' ) ; if ( ! sep ) { fprintf ( stderr , ""Badlyformattedoption%s-expectedSection:Name=Value\\n"" , opt_string ) ; return ; } { const size_t sepIdx = sep - opt_string ; strncpy ( szSec , opt_string , sepIdx ) ; szSec [ sepIdx ] = 0 ; } sep ++ ; sep2 = strchr ( sep , '=' ) ; if ( ! sep2 ) { fprintf ( stderr , ""Badlyformattedoption%s-expectedSection:Name=Value\\n"" , opt_string ) ; return ; } { const size_t sepIdx = sep2 - sep ; strncpy ( szKey , sep , sepIdx ) ; szKey [ sepIdx ] = 0 ; strcpy ( szVal , sep2 + 1 ) ; } if ( ! stricmp ( szKey , ""*"" ) ) { if ( stricmp ( szVal , ""null"" ) ) { fprintf ( stderr , ""Badlyformattedoption%s-expectedSection:*=null\\n"" , opt_string ) ; return ; } gf_cfg_del_section ( cfg_file , szSec ) ; return ; } if ( ! stricmp ( szVal , ""null"" ) ) { szVal [ 0 ] = 0 ; } gf_cfg_set_key ( cfg_file , szSec , szKey , szVal [ 0 ] ? szVal : NULL ) ; } "," - opt_string ; if ( sepIdx >= sizeof ( szSec ) ) { fprintf ( stderr , ""Badlyformattedoption%s-Sectionnameistoolong\\n"" , opt_string ) ; return ; } - sep ; if ( sepIdx >= sizeof ( szKey ) ) { fprintf ( stderr , ""Badlyformattedoption%s-keynameistoolong\\n"" , opt_string ) ; return ; } = 0 ; if ( strlen ( sep2 + 1 + 1 ) >= sizeof ( szVal ) ) { fprintf ( stderr , ""Badlyformattedoption%s-valueistoolong\\n"" , opt_string ) ; return ; } strcpy ( szVal , sep2 + 1 ) ",gpac@gpac/35ab4475a7df9b2a4bcab235e379c0c3ec543658,CVE-2018-20762,https://github.com/gpac/gpac/commit/35ab4475a7df9b2a4bcab235e379c0c3ec543658,2019-02-06T23:29Z 32,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 33,CWE-20,"CWE-20 error_t udpReceiveDatagram ( 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 ) ; } udpUpdateEvents ( 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 34,CWE-416,"CWE-416 int hns_nic_net_xmit_hw ( struct net_device * ndev , struct sk_buff * skb , struct hns_nic_ring_data * ring_data ) { struct hns_nic_priv * priv = netdev_priv ( ndev ) ; struct hnae_ring * ring = ring_data -> ring ; struct device * dev = ring_to_dev ( ring ) ; struct netdev_queue * dev_queue ; struct skb_frag_struct * frag ; int buf_num ; int seg_num ; dma_addr_t dma ; int size , next_to_use ; int i ; switch ( priv -> ops . maybe_stop_tx ( & skb , & buf_num , ring ) ) { case - EBUSY : ring -> stats . tx_busy ++ ; goto out_net_tx_busy ; case - ENOMEM : ring -> stats . sw_err_cnt ++ ; netdev_err ( ndev , ""nomemorytoxmit!\\n"" ) ; goto out_err_tx_ok ; default : break ; } seg_num = skb_shinfo ( skb ) -> nr_frags + 1 ; next_to_use = ring -> next_to_use ; size = skb_headlen ( skb ) ; dma = dma_map_single ( dev , skb -> data , size , DMA_TO_DEVICE ) ; if ( dma_mapping_error ( dev , dma ) ) { netdev_err ( ndev , ""TXheadDMAmapfailed\\n"" ) ; ring -> stats . sw_err_cnt ++ ; goto out_err_tx_ok ; } priv -> ops . fill_desc ( ring , skb , size , dma , seg_num == 1 ? 1 : 0 , buf_num , DESC_TYPE_SKB , ndev -> mtu ) ; for ( i = 1 ; i < seg_num ; i ++ ) { frag = & skb_shinfo ( skb ) -> frags [ i - 1 ] ; size = skb_frag_size ( frag ) ; dma = skb_frag_dma_map ( dev , frag , 0 , size , DMA_TO_DEVICE ) ; if ( dma_mapping_error ( dev , dma ) ) { netdev_err ( ndev , ""TXfrag(%d)DMAmapfailed\\n"" , i ) ; ring -> stats . sw_err_cnt ++ ; goto out_map_frag_fail ; } priv -> ops . fill_desc ( ring , skb_frag_page ( frag ) , size , dma , seg_num - 1 == i ? 1 : 0 , buf_num , DESC_TYPE_PAGE , ndev -> mtu ) ; } dev_queue = netdev_get_tx_queue ( ndev , skb -> queue_mapping ) ; netdev_tx_sent_queue ( dev_queue , skb -> len ) ; wmb ( ) ; assert ( skb -> queue_mapping < priv -> ae_handle -> q_num ) ; hnae_queue_xmit ( priv -> ae_handle -> qs [ skb -> queue_mapping ] , buf_num ) ; ring -> stats . tx_pkts ++ ; ring -> stats . tx_bytes += skb -> len ; return NETDEV_TX_OK ; out_map_frag_fail : while ( ring -> next_to_use != next_to_use ) { unfill_desc ( ring ) ; if ( ring -> next_to_use != next_to_use ) dma_unmap_page ( dev , ring -> desc_cb [ ring -> next_to_use ] . dma , ring -> desc_cb [ ring -> next_to_use ] . length , DMA_TO_DEVICE ) ; else dma_unmap_single ( dev , ring -> desc_cb [ next_to_use ] . dma , ring -> desc_cb [ next_to_use ] . length , DMA_TO_DEVICE ) ; } out_err_tx_ok : dev_kfree_skb_any ( skb ) ; return NETDEV_TX_OK ; out_net_tx_busy : netif_stop_subqueue ( ndev , skb -> queue_mapping ) ; smp_mb ( ) ; return NETDEV_TX_BUSY ; } "," netdev_tx_t hns_nic_net_xmit_hw ( struct len ) ; netif_trans_update ( ndev ) ; ndev -> stats . tx_bytes += skb -> len ; ndev -> stats . tx_packets ++ ; ",torvalds@linux/27463ad99f738ed93c7c8b3e2e5bc8c4853a2ff2,CVE-2017-18218,https://github.com/torvalds/linux/commit/27463ad99f738ed93c7c8b3e2e5bc8c4853a2ff2,2018-03-05T20:29Z 35,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 36,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 37,CWE-20,"CWE-20 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 38,CWE-552,"CWE-552 static ssize_t _hostsock_readv ( oe_fd_t * desc , const struct oe_iovec * iov , int iovcnt ) { ssize_t ret = - 1 ; sock_t * sock = _cast_sock ( desc ) ; void * buf = NULL ; size_t buf_size = 0 ; if ( ! sock || ( ! iov && iovcnt ) || iovcnt < 0 || iovcnt > OE_IOV_MAX ) OE_RAISE_ERRNO ( OE_EINVAL ) ; if ( oe_iov_pack ( iov , iovcnt , & buf , & buf_size ) != 0 ) OE_RAISE_ERRNO ( OE_ENOMEM ) ; if ( oe_syscall_recvv_ocall ( & ret , sock -> host_fd , buf , iovcnt , buf_size ) != OE_OK ) { OE_RAISE_ERRNO ( OE_EINVAL ) ; } if ( ret > 0 ) { if ( oe_iov_sync ( iov , iovcnt , buf , buf_size ) != 0 ) OE_RAISE_ERRNO ( OE_EINVAL ) ; } done : if ( buf ) oe_free ( buf ) ; return ret ; } "," = 0 ; size_t data_size = 0 ; , & buf_size , & data_size OE_RAISE_ERRNO ( OE_ENOMEM ) ; if ( data_size > OE_SSIZE_MAX ) OE_RAISE_ERRNO ( OE_EINVAL ( ret > ( ssize_t ) ( data_size ) ) { ret = - 1 ; OE_RAISE_ERRNO ( OE_EINVAL ) ; } if ( ret > ",openenclave@openenclave/bcac8e7acb514429fee9e0b5d0c7a0308fd4d76b,CVE-2020-15224,https://github.com/openenclave/openenclave/commit/bcac8e7acb514429fee9e0b5d0c7a0308fd4d76b,2020-10-14T19:15Z 39,CWE-200,"CWE-200 void send_ldap_result_ext ( Slapi_PBlock * pb , int err , char * matched , char * text , int nentries , struct berval * * urls , BerElement * ber ) { Slapi_Operation * operation ; passwdPolicy * pwpolicy = NULL ; Connection * conn = NULL ; Slapi_DN * sdn = NULL ; const char * dn = NULL ; ber_tag_t tag ; int flush_ber_element = 1 ; ber_tag_t bind_method = 0 ; int internal_op ; int i , rc , logit = 0 ; char * pbtext ; slapi_pblock_get ( pb , SLAPI_BIND_METHOD , & bind_method ) ; slapi_pblock_get ( pb , SLAPI_OPERATION , & operation ) ; slapi_pblock_get ( pb , SLAPI_CONNECTION , & conn ) ; if ( text ) { pbtext = text ; } else { slapi_pblock_get ( pb , SLAPI_PB_RESULT_TEXT , & pbtext ) ; } if ( operation == NULL ) { slapi_log_err ( SLAPI_LOG_ERR , ""send_ldap_result_ext"" , ""Nooperationfound:slapi_search_internal_set_pbwasincomplete(invalid\'base\'?)\\n"" ) ; return ; } if ( operation -> o_status == SLAPI_OP_STATUS_RESULT_SENT ) { return ; } if ( ber != NULL ) { flush_ber_element = 0 ; } if ( err != LDAP_SUCCESS ) { if ( err == LDAP_INVALID_CREDENTIALS || err == LDAP_INAPPROPRIATE_AUTH || err == LDAP_AUTH_METHOD_NOT_SUPPORTED || err == LDAP_STRONG_AUTH_NOT_SUPPORTED || err == LDAP_STRONG_AUTH_REQUIRED || err == LDAP_CONFIDENTIALITY_REQUIRED || err == LDAP_INSUFFICIENT_ACCESS || err == LDAP_AUTH_UNKNOWN ) { slapi_counter_increment ( g_get_global_snmp_vars ( ) -> ops_tbl . dsSecurityErrors ) ; } else if ( err != LDAP_REFERRAL && err != LDAP_OPT_REFERRALS && err != LDAP_PARTIAL_RESULTS ) { slapi_counter_increment ( g_get_global_snmp_vars ( ) -> ops_tbl . dsErrors ) ; } } slapi_log_err ( SLAPI_LOG_TRACE , ""send_ldap_result_ext"" , ""=>%d:%s:%s\\n"" , err , matched ? matched : """" , text ? text : """" ) ; switch ( operation -> o_tag ) { case LBER_DEFAULT : tag = LBER_SEQUENCE ; break ; case LDAP_REQ_SEARCH : tag = LDAP_RES_SEARCH_RESULT ; break ; case LDAP_REQ_DELETE : tag = LDAP_RES_DELETE ; break ; case LDAP_REFERRAL : if ( conn && conn -> c_ldapversion > LDAP_VERSION2 ) { tag = LDAP_TAG_REFERRAL ; break ; } default : tag = operation -> o_tag + 1 ; break ; } internal_op = operation_is_flag_set ( operation , OP_FLAG_INTERNAL ) ; if ( ( conn == NULL ) || ( internal_op ) ) { if ( operation -> o_result_handler != NULL ) { operation -> o_result_handler ( conn , operation , err , matched , text , nentries , urls ) ; logit = 1 ; } goto log_and_return ; } if ( ( err == LDAP_INVALID_CREDENTIALS ) && ( bind_method != LDAP_AUTH_SASL ) ) { slapi_pblock_get ( pb , SLAPI_TARGET_SDN , & sdn ) ; dn = slapi_sdn_get_dn ( sdn ) ; pwpolicy = new_passwdPolicy ( pb , dn ) ; if ( pwpolicy && ( pwpolicy -> pw_lockout == 1 ) ) { if ( update_pw_retry ( pb ) == LDAP_CONSTRAINT_VIOLATION && ! pwpolicy -> pw_is_legacy ) { err = LDAP_CONSTRAINT_VIOLATION ; text = ""Invalidcredentials,younowhaveexceededthepasswordretrylimit."" ; } } } if ( ber == NULL ) { if ( ( ber = der_alloc ( ) ) == NULL ) { slapi_log_err ( SLAPI_LOG_ERR , ""send_ldap_result_ext"" , ""ber_allocfailed\\n"" ) ; goto log_and_return ; } } if ( err == LDAP_ADMINLIMIT_EXCEEDED && conn -> c_ldapversion < LDAP_VERSION3 ) { err = LDAP_SIZELIMIT_EXCEEDED ; } if ( conn -> c_ldapversion < LDAP_VERSION3 || urls == NULL ) { char * save , * buf = NULL ; if ( urls != NULL ) { int len ; slapi_counter_increment ( g_get_global_snmp_vars ( ) -> ops_tbl . dsReferrals ) ; len = 10 ; for ( i = 0 ; urls [ i ] != NULL ; i ++ ) { len += urls [ i ] -> bv_len + 1 ; } if ( text != NULL ) { len += strlen ( text ) + 1 ; } buf = slapi_ch_malloc ( len ) ; * buf = '\\0' ; if ( text != NULL ) { strcpy ( buf , text ) ; strcat ( buf , ""\\n"" ) ; } strcat ( buf , ""Referral:"" ) ; for ( i = 0 ; urls [ i ] != NULL ; i ++ ) { strcat ( buf , ""\\n"" ) ; strcat ( buf , urls [ i ] -> bv_val ) ; } save = text ; text = buf ; } if ( ( conn -> c_ldapversion < LDAP_VERSION3 && err == LDAP_REFERRAL ) || urls != NULL ) { err = LDAP_PARTIAL_RESULTS ; } rc = ber_printf ( ber , ""{it{ess"" , operation -> o_msgid , tag , err , matched ? matched : """" , pbtext ? pbtext : """" ) ; if ( rc != LBER_ERROR ) { rc = check_and_send_extended_result ( pb , tag , ber ) ; } if ( rc != LBER_ERROR ) { rc = check_and_send_SASL_response ( pb , tag , ber , conn ) ; } if ( rc != LBER_ERROR ) { rc = ber_printf ( ber , ""}"" ) ; } if ( buf != NULL ) { text = save ; slapi_ch_free ( ( void * * ) & buf ) ; } } else { if ( ! config_check_referral_mode ( ) ) slapi_counter_increment ( g_get_global_snmp_vars ( ) -> ops_tbl . dsReferrals ) ; rc = ber_printf ( ber , ""{it{esst{s"" , operation -> o_msgid , tag , err , matched ? matched : """" , text ? text : """" , LDAP_TAG_REFERRAL , urls [ 0 ] -> bv_val ) ; for ( i = 1 ; urls [ i ] != NULL && rc != LBER_ERROR ; i ++ ) { rc = ber_printf ( ber , ""s"" , urls [ i ] -> bv_val ) ; } if ( rc != LBER_ERROR ) { rc = ber_printf ( ber , ""}"" ) ; } if ( rc != LBER_ERROR ) { rc = check_and_send_extended_result ( pb , tag , ber ) ; } if ( rc != LBER_ERROR ) { rc = check_and_send_SASL_response ( pb , tag , ber , conn ) ; } if ( rc != LBER_ERROR ) { rc = ber_printf ( ber , ""}"" ) ; } } if ( err == LDAP_SUCCESS ) { if ( process_read_entry_controls ( pb , LDAP_CONTROL_PRE_READ_ENTRY ) ) { err = LDAP_UNAVAILABLE_CRITICAL_EXTENSION ; goto log_and_return ; } if ( process_read_entry_controls ( pb , LDAP_CONTROL_POST_READ_ENTRY ) ) { err = LDAP_UNAVAILABLE_CRITICAL_EXTENSION ; goto log_and_return ; } } if ( operation -> o_results . result_controls != NULL && conn -> c_ldapversion >= LDAP_VERSION3 && write_controls ( ber , operation -> o_results . result_controls ) != 0 ) { rc = ( int ) LBER_ERROR ; } if ( rc != LBER_ERROR ) { rc = ber_put_seq ( ber ) ; } if ( rc == LBER_ERROR ) { slapi_log_err ( SLAPI_LOG_ERR , ""send_ldap_result_ext"" , ""ber_printffailed1\\n"" ) ; if ( flush_ber_element == 1 ) { ber_free ( ber , 1 ) ; } goto log_and_return ; } if ( flush_ber_element ) { if ( flush_ber ( pb , conn , operation , ber , _LDAP_SEND_RESULT ) == 0 ) { logit = 1 ; } } log_and_return : operation -> o_status = SLAPI_OP_STATUS_RESULT_SENT ; if ( logit && ( operation_is_flag_set ( operation , OP_FLAG_ACTION_LOG_ACCESS ) || ( internal_op && config_get_plugin_logging ( ) ) ) ) { log_result ( pb , operation , err , tag , nentries ) ; } slapi_log_err ( SLAPI_LOG_TRACE , ""send_ldap_result_ext"" , ""<=%d\\n"" , err ) ; } "," ( pb , SLAPI_RESULT_TEXT , & pbtext ",389ds@389-ds-base/cc0f69283abc082488824702dae485b8eae938bc,CVE-2020-35518,https://github.com/389ds/389-ds-base/commit/cc0f69283abc082488824702dae485b8eae938bc,2021-03-26T17:15Z 40,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 41,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 42,CWE-119,"CWE-119 static void update_state ( VP9_COMP * cpi , PICK_MODE_CONTEXT * ctx , int mi_row , int mi_col , BLOCK_SIZE bsize , int output_enabled ) { int i , x_idx , y ; VP9_COMMON * const cm = & cpi -> common ; MACROBLOCK * const x = & cpi -> mb ; MACROBLOCKD * const xd = & x -> e_mbd ; struct macroblock_plane * const p = x -> plane ; struct macroblockd_plane * const pd = xd -> plane ; MODE_INFO * mi = & ctx -> mic ; MB_MODE_INFO * const mbmi = & xd -> mi [ 0 ] -> mbmi ; MODE_INFO * mi_addr = xd -> mi [ 0 ] ; const struct segmentation * const seg = & cm -> seg ; 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 ] ; int max_plane ; assert ( mi -> mbmi . sb_type == bsize ) ; * mi_addr = * mi ; if ( seg -> enabled && output_enabled ) { if ( cpi -> oxcf . aq_mode == COMPLEXITY_AQ ) { const uint8_t * const map = seg -> update_map ? cpi -> segmentation_map : cm -> last_frame_seg_map ; mi_addr -> mbmi . segment_id = vp9_get_segment_id ( cm , map , bsize , mi_row , mi_col ) ; } else if ( cpi -> oxcf . aq_mode == CYCLIC_REFRESH_AQ ) { vp9_cyclic_refresh_update_segment ( cpi , & xd -> mi [ 0 ] -> mbmi , mi_row , mi_col , bsize , 1 ) ; vp9_init_plane_quantizers ( cpi , x ) ; } } max_plane = is_inter_block ( mbmi ) ? MAX_MB_PLANE : 1 ; for ( i = 0 ; i < max_plane ; ++ i ) { p [ i ] . coeff = ctx -> coeff_pbuf [ i ] [ 1 ] ; p [ i ] . qcoeff = ctx -> qcoeff_pbuf [ i ] [ 1 ] ; pd [ i ] . dqcoeff = ctx -> dqcoeff_pbuf [ i ] [ 1 ] ; p [ i ] . eobs = ctx -> eobs_pbuf [ i ] [ 1 ] ; } for ( i = max_plane ; i < MAX_MB_PLANE ; ++ i ) { p [ i ] . coeff = ctx -> coeff_pbuf [ i ] [ 2 ] ; p [ i ] . qcoeff = ctx -> qcoeff_pbuf [ i ] [ 2 ] ; pd [ i ] . dqcoeff = ctx -> dqcoeff_pbuf [ i ] [ 2 ] ; p [ i ] . eobs = ctx -> eobs_pbuf [ i ] [ 2 ] ; } for ( y = 0 ; y < mi_height ; y ++ ) for ( x_idx = 0 ; x_idx < mi_width ; x_idx ++ ) if ( ( xd -> mb_to_right_edge >> ( 3 + MI_SIZE_LOG2 ) ) + mi_width > x_idx && ( xd -> mb_to_bottom_edge >> ( 3 + MI_SIZE_LOG2 ) ) + mi_height > y ) { xd -> mi [ x_idx + y * mis ] = mi_addr ; } if ( cpi -> oxcf . aq_mode ) vp9_init_plane_quantizers ( cpi , x ) ; if ( bsize < BLOCK_32X32 ) { if ( bsize < BLOCK_16X16 ) ctx -> tx_rd_diff [ ALLOW_16X16 ] = ctx -> tx_rd_diff [ ALLOW_8X8 ] ; ctx -> tx_rd_diff [ ALLOW_32X32 ] = ctx -> tx_rd_diff [ ALLOW_16X16 ] ; } if ( is_inter_block ( mbmi ) && mbmi -> sb_type < BLOCK_8X8 ) { mbmi -> mv [ 0 ] . as_int = mi -> bmi [ 3 ] . as_mv [ 0 ] . as_int ; mbmi -> mv [ 1 ] . as_int = mi -> bmi [ 3 ] . as_mv [ 1 ] . as_int ; } x -> skip = ctx -> skip ; vpx_memcpy ( x -> zcoeff_blk [ mbmi -> tx_size ] , ctx -> zcoeff_blk , sizeof ( uint8_t ) * ctx -> num_4x4_blk ) ; if ( ! output_enabled ) return ; if ( ! vp9_segfeature_active ( & cm -> seg , mbmi -> segment_id , SEG_LVL_SKIP ) ) { for ( i = 0 ; i < TX_MODES ; i ++ ) cpi -> rd_tx_select_diff [ i ] += ctx -> tx_rd_diff [ i ] ; } # if CONFIG_INTERNAL_STATS if ( frame_is_intra_only ( cm ) ) { static const int kf_mode_index [ ] = { THR_DC , THR_V_PRED , THR_H_PRED , THR_D45_PRED , THR_D135_PRED , THR_D117_PRED , THR_D153_PRED , THR_D207_PRED , THR_D63_PRED , THR_TM , } ; ++ cpi -> mode_chosen_counts [ kf_mode_index [ mbmi -> mode ] ] ; } else { ++ cpi -> mode_chosen_counts [ ctx -> best_mode_index ] ; } # endif if ( ! frame_is_intra_only ( cm ) ) { if ( is_inter_block ( mbmi ) ) { vp9_update_mv_count ( cm , xd ) ; if ( cm -> interp_filter == SWITCHABLE ) { const int ctx = vp9_get_pred_context_switchable_interp ( xd ) ; ++ cm -> counts . switchable_interp [ ctx ] [ mbmi -> interp_filter ] ; } } cpi -> rd_comp_pred_diff [ SINGLE_REFERENCE ] += ctx -> single_pred_diff ; cpi -> rd_comp_pred_diff [ COMPOUND_REFERENCE ] += ctx -> comp_pred_diff ; cpi -> rd_comp_pred_diff [ REFERENCE_MODE_SELECT ] += ctx -> hybrid_pred_diff ; for ( i = 0 ; i < SWITCHABLE_FILTER_CONTEXTS ; ++ i ) cpi -> rd_filter_diff [ i ] += ctx -> best_filter_diff [ i ] ; } } "," * cpi , ThreadData * td , -> common ; RD_COUNTS * const rdc = & td -> rd_counts ; x = & td -> mb ; cm -> seg ; const int bw = num_8x8_blocks_wide_lookup [ mi -> mbmi . sb_type ] ; const int bh = num_8x8_blocks_high_lookup [ mi -> mbmi . sb_type ] ; const int x_mis = MIN ( bw , cm -> mi_cols - mi_col ) ; const int y_mis = MIN ( bh , cm -> mi_rows - mi_row ) ; MV_REF * const frame_mvs = cm -> cur_frame -> mvs + mi_row * cm -> mi_cols + mi_col ; int w , h * mi ; * x -> mbmi_ext = ctx -> mbmi_ext ; seg -> enabled ) { if . segment_id = get_segment_id ( cm , ) ; } if ( cpi , bsize , ctx -> rate , ctx -> dist , x -> skip ) ; } ; if ( is_inter_block ( mbmi -> skip ; memcpy ( x -> , sizeof ( ctx -> zcoeff_blk [ 0 ] ) * ctx ) return ; # if CONFIG_INTERNAL_STATS { vp9_update_mv_count ( td ) ; if ) ; ++ td -> counts -> switchable_interp [ ctx ; } } rdc -> comp_pred_diff [ SINGLE_REFERENCE ] -> single_pred_diff ; rdc -> comp_pred_diff [ COMPOUND_REFERENCE ] -> comp_pred_diff ; rdc -> comp_pred_diff [ REFERENCE_MODE_SELECT ] ++ i ) rdc -> filter_diff [ i ] ] ; } for ( h = 0 ; h < y_mis ; ++ h ) { MV_REF * const frame_mv = frame_mvs + h * cm -> mi_cols ; for ( w = 0 ; w < x_mis ; ++ w ) { MV_REF * const mv = frame_mv + w ; mv -> ref_frame [ 0 ] = mi -> mbmi . ref_frame [ 0 ] ; mv -> ref_frame [ 1 ] = mi -> mbmi . ref_frame [ 1 ] ; mv -> mv [ 0 ] . as_int = mi -> mbmi . mv [ 0 ] . as_int ; mv -> mv [ 1 ] . as_int = mi -> mbmi . mv [ 1 ] . as_int ; } } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 43,CWE-415,"CWE-415 void gdImageWBMPCtx ( gdImagePtr image , int fg , gdIOCtx * out ) { int x , y , pos ; Wbmp * wbmp ; if ( ( wbmp = createwbmp ( gdImageSX ( image ) , gdImageSY ( image ) , WBMP_WHITE ) ) == NULL ) { gd_error ( ""CouldnotcreateWBMP"" ) ; return ; } pos = 0 ; for ( y = 0 ; y < gdImageSY ( image ) ; y ++ ) { for ( x = 0 ; x < gdImageSX ( image ) ; x ++ ) { if ( gdImageGetPixel ( image , x , y ) == fg ) { wbmp -> bitmap [ pos ] = WBMP_BLACK ; } pos ++ ; } } if ( writewbmp ( wbmp , & gd_putout , out ) ) { gd_error ( ""CouldnotsaveWBMP"" ) ; } freewbmp ( wbmp ) ; } "," out ) { _gdImageWBMPCtx ( image , ( image , fg , out ) ; } ",php@php-src/089f7c0bc28d399b0420aa6ef058e4c1c120b2ae,CVE-2019-6978,https://github.com/php/php-src/commit/089f7c0bc28d399b0420aa6ef058e4c1c120b2ae,2019-01-28T08:29Z 44,CWE-601,"CWE-601 static int oidc_handle_logout ( request_rec * r , oidc_cfg * c , oidc_session_t * session ) { oidc_provider_t * provider = NULL ; char * url = NULL ; oidc_util_get_request_parameter ( r , OIDC_REDIRECT_URI_REQUEST_LOGOUT , & url ) ; oidc_debug ( r , ""enter(url=%s)"" , url ) ; if ( oidc_is_front_channel_logout ( url ) ) { return oidc_handle_logout_request ( r , c , session , url ) ; } else if ( oidc_is_back_channel_logout ( url ) ) { return oidc_handle_logout_backchannel ( r , c ) ; } if ( ( url == NULL ) || ( apr_strnatcmp ( url , """" ) == 0 ) ) { url = c -> default_slo_url ; } else { const char * error_description = NULL ; apr_uri_t uri ; if ( apr_uri_parse ( r -> pool , url , & uri ) != APR_SUCCESS ) { const char * error_description = apr_psprintf ( r -> pool , ""LogoutURLmalformed:%s"" , url ) ; oidc_error ( r , ""%s"" , error_description ) ; return oidc_util_html_send_error ( r , c -> error_template , ""MalformedURL"" , error_description , HTTP_INTERNAL_SERVER_ERROR ) ; } const char * c_host = oidc_get_current_url_host ( r ) ; if ( ( uri . hostname != NULL ) && ( ( strstr ( c_host , uri . hostname ) == NULL ) || ( strstr ( uri . hostname , c_host ) == NULL ) ) ) { error_description = apr_psprintf ( r -> pool , ""logoutvalue\\""%s\\""doesnotmatchthehostnameofthecurrentrequest\\""%s\\"""" , apr_uri_unparse ( r -> pool , & uri , 0 ) , c_host ) ; oidc_error ( r , ""%s"" , error_description ) ; return oidc_util_html_send_error ( r , c -> error_template , ""InvalidRequest"" , error_description , HTTP_INTERNAL_SERVER_ERROR ) ; } if ( ( ( strstr ( url , ""\\n"" ) != NULL ) || strstr ( url , ""\\r"" ) != NULL ) ) { error_description = apr_psprintf ( r -> pool , ""logoutvalue\\""%s\\""containsillegal\\""\\n\\""or\\""\\r\\""character(s)"" , url ) ; oidc_error ( r , ""%s"" , error_description ) ; return oidc_util_html_send_error ( r , c -> error_template , ""InvalidRequest"" , error_description , HTTP_INTERNAL_SERVER_ERROR ) ; } } oidc_get_provider_from_session ( r , c , session , & provider ) ; if ( ( provider != NULL ) && ( provider -> end_session_endpoint != NULL ) ) { const char * id_token_hint = oidc_session_get_idtoken ( r , session ) ; char * logout_request = apr_pstrdup ( r -> pool , provider -> end_session_endpoint ) ; if ( id_token_hint != NULL ) { logout_request = apr_psprintf ( r -> pool , ""%s%sid_token_hint=%s"" , logout_request , strchr ( logout_request ? logout_request : """" , OIDC_CHAR_QUERY ) != NULL ? OIDC_STR_AMP : OIDC_STR_QUERY , oidc_util_escape_string ( r , id_token_hint ) ) ; } if ( url != NULL ) { logout_request = apr_psprintf ( r -> pool , ""%s%spost_logout_redirect_uri=%s"" , logout_request , strchr ( logout_request ? logout_request : """" , OIDC_CHAR_QUERY ) != NULL ? OIDC_STR_AMP : OIDC_STR_QUERY , oidc_util_escape_string ( r , url ) ) ; } url = logout_request ; } return oidc_handle_logout_request ( r , c , session , url ) ; } "," = NULL ; char * error_str = NULL ; char * error_description = NULL ; } else { if ( oidc_validate_post_logout_url ( r , url , & error_str , & error_description ) == FALSE ) { return oidc_util_html_send_error ( -> error_template , error_str , error_description , HTTP_BAD_REQUEST ) ; } ",zmartzone@mod_auth_openidc/5c15dfb08106c2451c2c44ce7ace6813c216ba75,CVE-2019-14857,https://github.com/zmartzone/mod_auth_openidc/commit/5c15dfb08106c2451c2c44ce7ace6813c216ba75,2019-11-26T12:15Z 45,CWE-119,"CWE-119 static int tiffcp ( TIFF * in , TIFF * out ) { uint16 bitspersample , samplesperpixel = 1 ; uint16 input_compression , input_photometric = PHOTOMETRIC_MINISBLACK ; 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 ) ; } "," { uint16 bitspersample = 1 ",vadz@libtiff/5c080298d59efa53264d7248bbe3a04660db6ef7,CVE-2017-5225,https://github.com/vadz/libtiff/commit/5c080298d59efa53264d7248bbe3a04660db6ef7,2017-01-12T11:59Z 46,CWE-617,"CWE-617 static int pci_emul_dinit ( struct vmctx * ctx , struct pci_vdev * dev , char * opts ) { int error ; struct pci_emul_dummy * dummy ; dummy = calloc ( 1 , sizeof ( struct pci_emul_dummy ) ) ; dev -> arg = dummy ; pci_set_cfgdata16 ( dev , PCIR_DEVICE , 0x0001 ) ; pci_set_cfgdata16 ( dev , PCIR_VENDOR , 0x10DD ) ; pci_set_cfgdata8 ( dev , PCIR_CLASS , 0x02 ) ; error = pci_emul_add_msicap ( dev , PCI_EMUL_MSI_MSGS ) ; assert ( error == 0 ) ; error = pci_emul_alloc_bar ( dev , 0 , PCIBAR_IO , DIOSZ ) ; assert ( error == 0 ) ; error = pci_emul_alloc_bar ( dev , 1 , PCIBAR_MEM32 , DMEMSZ ) ; assert ( error == 0 ) ; error = pci_emul_alloc_bar ( dev , 2 , PCIBAR_MEM32 , DMEMSZ ) ; assert ( error == 0 ) ; return 0 ; } "," opts ) { struct pci_emul_dummy * 0x02 ) ; return pci_emul_add_msicap ( dev , PCI_EMUL_MSI_MSGS ) || pci_emul_alloc_bar ( dev , DIOSZ ) || pci_emul_alloc_bar ( dev , DMEMSZ ) || pci_emul_alloc_bar ( dev DMEMSZ ) ; } ",projectacrn@acrn-hypervisor/2b3dedfb9ba13f15887f22b935d373f36c9a59fa,CVE-2019-18844,https://github.com/projectacrn/acrn-hypervisor/commit/2b3dedfb9ba13f15887f22b935d373f36c9a59fa,2019-11-13T20:15Z 47,CWE-310,"CWE-310 int ASN1_item_verify ( const ASN1_ITEM * it , X509_ALGOR * a , ASN1_BIT_STRING * signature , void * asn , EVP_PKEY * pkey ) { EVP_MD_CTX ctx ; unsigned char * buf_in = NULL ; int ret = - 1 , inl ; int mdnid , pknid ; if ( ! pkey ) { ASN1err ( ASN1_F_ASN1_ITEM_VERIFY , ERR_R_PASSED_NULL_PARAMETER ) ; return - 1 ; } if ( signature -> type == V_ASN1_BIT_STRING && signature -> flags & 0x7 ) { ASN1err ( ASN1_F_ASN1_VERIFY , ASN1_R_INVALID_BIT_STRING_BITS_LEFT ) ; return - 1 ; } EVP_MD_CTX_init ( & ctx ) ; if ( ! OBJ_find_sigid_algs ( OBJ_obj2nid ( a -> algorithm ) , & mdnid , & pknid ) ) { ASN1err ( ASN1_F_ASN1_ITEM_VERIFY , ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM ) ; goto err ; } if ( mdnid == NID_undef ) { if ( ! pkey -> ameth || ! pkey -> ameth -> item_verify ) { ASN1err ( ASN1_F_ASN1_ITEM_VERIFY , ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM ) ; goto err ; } ret = pkey -> ameth -> item_verify ( & ctx , it , asn , a , signature , pkey ) ; if ( ret != 2 ) goto err ; ret = - 1 ; } else { const EVP_MD * type ; type = EVP_get_digestbynid ( mdnid ) ; if ( type == NULL ) { ASN1err ( ASN1_F_ASN1_ITEM_VERIFY , ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM ) ; goto err ; } if ( EVP_PKEY_type ( pknid ) != pkey -> ameth -> pkey_id ) { ASN1err ( ASN1_F_ASN1_ITEM_VERIFY , ASN1_R_WRONG_PUBLIC_KEY_TYPE ) ; goto err ; } if ( ! EVP_DigestVerifyInit ( & ctx , NULL , type , NULL , pkey ) ) { ASN1err ( ASN1_F_ASN1_ITEM_VERIFY , ERR_R_EVP_LIB ) ; ret = 0 ; goto err ; } } inl = ASN1_item_i2d ( asn , & buf_in , it ) ; if ( buf_in == NULL ) { ASN1err ( ASN1_F_ASN1_ITEM_VERIFY , ERR_R_MALLOC_FAILURE ) ; goto err ; } ret = EVP_DigestVerifyUpdate ( & ctx , buf_in , inl ) ; OPENSSL_cleanse ( buf_in , ( unsigned int ) inl ) ; OPENSSL_free ( buf_in ) ; if ( ! ret ) { ASN1err ( ASN1_F_ASN1_ITEM_VERIFY , ERR_R_EVP_LIB ) ; goto err ; } ret = - 1 ; if ( EVP_DigestVerifyFinal ( & ctx , signature -> data , ( size_t ) signature -> length ) <= 0 ) { ASN1err ( ASN1_F_ASN1_ITEM_VERIFY , ERR_R_EVP_LIB ) ; ret = 0 ; goto err ; } ret = 1 ; err : EVP_MD_CTX_cleanup ( & ctx ) ; return ( ret ) ; } "," { ASN1err ( ASN1_F_ASN1_ITEM_VERIFY , ASN1_R_INVALID_BIT_STRING_BITS_LEFT ) ",openssl@openssl/cb62ab4b17818fe66d2fed0a7fe71969131c811b,CVE-2014-8275,https://github.com/openssl/openssl/commit/cb62ab4b17818fe66d2fed0a7fe71969131c811b,2015-01-09T02:59Z 48,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 49,CWE-125,"CWE-125 static void print_attr_string ( netdissect_options * ndo , register const u_char * data , u_int length , u_short attr_code ) { register u_int i ; ND_TCHECK2 ( data [ 0 ] , length ) ; switch ( attr_code ) { case TUNNEL_PASS : if ( length < 3 ) { ND_PRINT ( ( ndo , ""%s"" , tstr ) ) ; return ; } if ( * data && ( * data <= 0x1F ) ) ND_PRINT ( ( ndo , ""Tag[%u]"" , * data ) ) ; else ND_PRINT ( ( ndo , ""Tag[Unused]"" ) ) ; data ++ ; length -- ; ND_PRINT ( ( ndo , ""Salt%u"" , EXTRACT_16BITS ( data ) ) ) ; data += 2 ; length -= 2 ; break ; case TUNNEL_CLIENT_END : case TUNNEL_SERVER_END : case TUNNEL_PRIV_GROUP : case TUNNEL_ASSIGN_ID : case TUNNEL_CLIENT_AUTH : case TUNNEL_SERVER_AUTH : if ( * data <= 0x1F ) { if ( length < 1 ) { ND_PRINT ( ( ndo , ""%s"" , tstr ) ) ; return ; } if ( * data ) ND_PRINT ( ( ndo , ""Tag[%u]"" , * data ) ) ; else ND_PRINT ( ( ndo , ""Tag[Unused]"" ) ) ; data ++ ; length -- ; } break ; case EGRESS_VLAN_NAME : ND_PRINT ( ( ndo , ""%s(0x%02x)"" , tok2str ( rfc4675_tagged , ""Unknowntag"" , * data ) , * data ) ) ; data ++ ; length -- ; break ; } for ( i = 0 ; * data && i < length ; i ++ , data ++ ) ND_PRINT ( ( ndo , ""%c"" , ( * data < 32 || * data > 126 ) ? '.' : * data ) ) ; return ; trunc : ND_PRINT ( ( ndo , ""%s"" , tstr ) ) ; } "," < 3 ) goto trunc ; if ( * < 1 ) goto trunc ; if ( * data ) ND_PRINT ( ( ndo , ""Tag[%u]"" , * data ) ) ; else ND_PRINT ( ( ndo , ""Tag[Unused]"" ) ) ; data ++ ; length -- ; } break ; case case EGRESS_VLAN_NAME : if ( length < 1 ) goto trunc ; = 0 ; i < length && * data ; i ++ ",the-tcpdump-group@tcpdump/1bc78d795cd5cad5525498658f414a11ea0a7e9c,CVE-2017-13032,https://github.com/the-tcpdump-group/tcpdump/commit/1bc78d795cd5cad5525498658f414a11ea0a7e9c,2017-09-14T06:29Z 50,CWE-787,"CWE-787 static int strncat_from_utf8_libarchive2 ( struct archive_string * as , const void * _p , size_t len , struct archive_string_conv * sc ) { const char * s ; int n ; char * p ; char * end ; uint32_t unicode ; # if HAVE_WCRTOMB mbstate_t shift_state ; memset ( & shift_state , 0 , sizeof ( shift_state ) ) ; # else wctomb ( NULL , L'\\0' ) ; # endif ( void ) sc ; if ( archive_string_ensure ( as , as -> length + len + 1 ) == NULL ) return ( - 1 ) ; s = ( const char * ) _p ; p = as -> s + as -> length ; end = as -> s + as -> buffer_length - MB_CUR_MAX - 1 ; while ( ( n = _utf8_to_unicode ( & unicode , s , len ) ) != 0 ) { wchar_t wc ; if ( p >= end ) { as -> length = p - as -> s ; if ( archive_string_ensure ( as , as -> length + len * 2 + 1 ) == NULL ) return ( - 1 ) ; p = as -> s + as -> length ; end = as -> s + as -> buffer_length - MB_CUR_MAX - 1 ; } if ( n < 0 ) { n *= - 1 ; wc = L'?' ; } else wc = ( wchar_t ) unicode ; s += n ; len -= n ; # if HAVE_WCRTOMB n = ( int ) wcrtomb ( p , wc , & shift_state ) ; # else n = ( int ) wctomb ( p , wc ) ; # endif if ( n == - 1 ) return ( - 1 ) ; p += n ; } as -> length = p - as -> s ; as -> s [ as -> length ] = '\\0' ; return ( 0 ) ; } "," -> length + max ( len * 2 , ( size_t ) MB_CUR_MAX ) ",libarchive@libarchive/4f085eea879e2be745f4d9bf57e8513ae48157f4,CVE-2020-21674,https://github.com/libarchive/libarchive/commit/4f085eea879e2be745f4d9bf57e8513ae48157f4,2020-10-15T15:15Z 51,CWE-119,"CWE-119 interval * PGTYPESinterval_from_asc ( char * str , char * * endptr ) { interval * result = NULL ; fsec_t fsec ; struct tm tt , * tm = & tt ; int dtype ; int nf ; char * field [ MAXDATEFIELDS ] ; int ftype [ MAXDATEFIELDS ] ; char lowstr [ MAXDATELEN + MAXDATEFIELDS ] ; char * realptr ; char * * ptr = ( endptr != NULL ) ? endptr : & realptr ; tm -> tm_year = 0 ; tm -> tm_mon = 0 ; tm -> tm_mday = 0 ; tm -> tm_hour = 0 ; tm -> tm_min = 0 ; tm -> tm_sec = 0 ; fsec = 0 ; if ( strlen ( str ) >= sizeof ( lowstr ) ) { errno = PGTYPES_INTVL_BAD_INTERVAL ; return NULL ; } if ( ParseDateTime ( str , lowstr , field , ftype , & nf , ptr ) != 0 || ( DecodeInterval ( field , ftype , nf , & dtype , tm , & fsec ) != 0 && DecodeISO8601Interval ( str , & dtype , tm , & fsec ) != 0 ) ) { errno = PGTYPES_INTVL_BAD_INTERVAL ; return NULL ; } result = ( interval * ) pgtypes_alloc ( sizeof ( interval ) ) ; if ( ! result ) return NULL ; if ( dtype != DTK_DELTA ) { errno = PGTYPES_INTVL_BAD_INTERVAL ; free ( result ) ; return NULL ; } if ( tm2interval ( tm , fsec , result ) != 0 ) { errno = PGTYPES_INTVL_BAD_INTERVAL ; free ( result ) ; return NULL ; } errno = 0 ; return result ; } "," ( str ) > MAXDATELEN ) { errno = PGTYPES_INTVL_BAD_INTERVAL ; return NULL ; } if ( ParseDateTime ( str , lowstr , field , ftype , & nf , ptr ) != 0 || ( DecodeInterval ( field , ftype , nf , & dtype , tm , & fsec ) != 0 && DecodeISO8601Interval ( str , & dtype , tm , & fsec ) != 0 ) ) { errno = PGTYPES_INTVL_BAD_INTERVAL ; return NULL ; } result = ( interval * ) pgtypes_alloc ( sizeof ( interval ) ) ; if ( ! result ) return NULL ; if ( dtype != DTK_DELTA ) { errno = PGTYPES_INTVL_BAD_INTERVAL ; free ( result ) ; return NULL ; } if ( tm2interval ( tm , fsec , result ) != 0 ) { errno = PGTYPES_INTVL_BAD_INTERVAL ; free ( result NULL ; } errno = 0 ",postgres@postgres/4318daecc959886d001a6e79c6ea853e8b1dfb4b,CVE-2014-0063,https://github.com/postgres/postgres/commit/4318daecc959886d001a6e79c6ea853e8b1dfb4b,2014-03-31T14:58Z 52,CWE-000,"CWE-000 static void sas_unregister_devs_sas_addr ( struct domain_device * parent , int phy_id , bool last ) { struct expander_device * ex_dev = & parent -> ex_dev ; struct ex_phy * phy = & ex_dev -> ex_phy [ phy_id ] ; struct domain_device * child , * n , * found = NULL ; if ( last ) { list_for_each_entry_safe ( child , n , & ex_dev -> children , siblings ) { if ( SAS_ADDR ( child -> sas_addr ) == SAS_ADDR ( phy -> attached_sas_addr ) ) { set_bit ( SAS_DEV_GONE , & child -> state ) ; if ( child -> dev_type == SAS_EDGE_EXPANDER_DEVICE || child -> dev_type == SAS_FANOUT_EXPANDER_DEVICE ) sas_unregister_ex_tree ( parent -> port , child ) ; else sas_unregister_dev ( parent -> port , child ) ; found = child ; break ; } } sas_disable_routing ( parent , phy -> attached_sas_addr ) ; } memset ( phy -> attached_sas_addr , 0 , SAS_ADDR_SIZE ) ; if ( phy -> port ) { sas_port_delete_phy ( phy -> port , phy -> phy ) ; sas_device_set_phy ( found , phy -> port ) ; if ( phy -> port -> num_phys == 0 ) sas_port_delete ( phy -> port ) ; phy -> port = NULL ; } } "," == 0 ) list_add_tail ( & phy -> port -> del_list , & parent -> port -> sas_port_del_list ) ; phy ",torvalds@linux/0558f33c06bb910e2879e355192227a8e8f0219d,CVE-2017-18232,https://github.com/torvalds/linux/commit/0558f33c06bb910e2879e355192227a8e8f0219d,2018-03-15T04:29Z 53,CWE-476,"CWE-476 bool CompileKeymap ( XkbFile * file , struct xkb_keymap * keymap , enum merge_mode merge ) { bool ok ; XkbFile * files [ LAST_KEYMAP_FILE_TYPE + 1 ] = { NULL } ; enum xkb_file_type type ; struct xkb_context * ctx = keymap -> ctx ; for ( file = ( XkbFile * ) file -> defs ; file ; file = ( XkbFile * ) file -> common . next ) { if ( file -> file_type < FIRST_KEYMAP_FILE_TYPE || file -> file_type > LAST_KEYMAP_FILE_TYPE ) { log_err ( ctx , ""Cannotdefine%sinakeymapfile\\n"" , xkb_file_type_to_string ( file -> file_type ) ) ; continue ; } if ( files [ file -> file_type ] ) { log_err ( ctx , ""Morethanone%ssectioninkeymapfile;"" ""Allsectionsafterthefirstignored\\n"" , xkb_file_type_to_string ( file -> file_type ) ) ; continue ; } files [ file -> file_type ] = file ; } ok = true ; for ( type = FIRST_KEYMAP_FILE_TYPE ; type <= LAST_KEYMAP_FILE_TYPE ; type ++ ) { if ( files [ type ] == NULL ) { log_err ( ctx , ""Requiredsection%smissingfromkeymap\\n"" , xkb_file_type_to_string ( type ) ) ; ok = false ; } } if ( ! ok ) return false ; for ( type = FIRST_KEYMAP_FILE_TYPE ; type <= LAST_KEYMAP_FILE_TYPE ; type ++ ) { log_dbg ( ctx , ""Compiling%s\\""%s\\""\\n"" , xkb_file_type_to_string ( type ) , files [ type ] -> name ) ; ok = compile_file_fns [ type ] ( files [ type ] , keymap , merge ) ; if ( ! ok ) { log_err ( ctx , ""Failedtocompile%s\\n"" , xkb_file_type_to_string ( type ) ) ; return false ; } } return UpdateDerivedKeymapFields ( keymap ) ; } "," LAST_KEYMAP_FILE_TYPE ) { if ( file -> file_type == FILE_TYPE_GEOMETRY ) { log_vrb ( ctx , 1 , ""Geometrysectionsarenotsupported;ignoring\\n"" ) ; } else { ) ) ; } ",xkbcommon@libxkbcommon/917636b1d0d70205a13f89062b95e3a0fc31d4ff,CVE-2018-15855,https://github.com/xkbcommon/libxkbcommon/commit/917636b1d0d70205a13f89062b95e3a0fc31d4ff,2018-08-25T21:29Z 54,CWE-119,"CWE-119 void vp9_rtcd ( ) { vpx_scale_rtcd ( ) ; once ( setup_rtcd_internal ) ; } "," ( ) { once ( setup_rtcd_internal ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 55,CWE-611,"CWE-611 static VALUE from_document ( VALUE klass , VALUE document ) { xmlDocPtr doc ; xmlSchemaParserCtxtPtr ctx ; xmlSchemaPtr schema ; VALUE errors ; VALUE rb_schema ; Data_Get_Struct ( document , xmlDoc , doc ) ; doc = doc -> doc ; if ( has_blank_nodes_p ( DOC_NODE_CACHE ( doc ) ) ) { rb_raise ( rb_eArgError , ""CreatingaschemafromadocumentthathasblanknodesexposedtoRubyisdangerous"" ) ; } ctx = xmlSchemaNewDocParserCtxt ( doc ) ; 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 ; return Qnil ; } "," VALUE from_document ( int argc , VALUE * argv , VALUE klass ) { VALUE document ; VALUE parse_options ; int parse_options_int ; xmlDocPtr doc ; VALUE rb_schema ; int scanned_args = 0 ; scanned_args = rb_scan_args ( argc , argv , ""11"" , & document , & parse_options ) ; doc -> doc ; 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 ) ) 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 56,CWE-190,"CWE-190 TfLiteIntArray * TfLiteIntArrayCreate ( int size ) { TfLiteIntArray * ret = ( TfLiteIntArray * ) malloc ( TfLiteIntArrayGetSizeInBytes ( size ) ) ; ret -> size = size ; return ret ; } "," size ) { int alloc_size = TfLiteIntArrayGetSizeInBytes ( size ) ; if ( alloc_size <= 0 ) return NULL ; ) malloc ( alloc_size ) ; if ( ! ret ) return ret ; ret -> ",tensorflow@tensorflow/7c8cc4ec69cd348e44ad6a2699057ca88faad3e5,CVE-2021-29605,https://github.com/tensorflow/tensorflow/commit/7c8cc4ec69cd348e44ad6a2699057ca88faad3e5,2021-05-14T20:15Z 57,CWE-401,"CWE-401 static int gs_can_open ( struct net_device * netdev ) { struct gs_can * dev = netdev_priv ( netdev ) ; struct gs_usb * parent = dev -> parent ; int rc , i ; struct gs_device_mode * dm ; u32 ctrlmode ; rc = open_candev ( netdev ) ; if ( rc ) return rc ; if ( atomic_add_return ( 1 , & parent -> active_channels ) == 1 ) { for ( i = 0 ; i < GS_MAX_RX_URBS ; i ++ ) { struct urb * urb ; u8 * buf ; urb = usb_alloc_urb ( 0 , GFP_KERNEL ) ; if ( ! urb ) return - ENOMEM ; buf = usb_alloc_coherent ( dev -> udev , sizeof ( struct gs_host_frame ) , GFP_KERNEL , & urb -> transfer_dma ) ; if ( ! buf ) { netdev_err ( netdev , ""NomemoryleftforUSBbuffer\\n"" ) ; usb_free_urb ( urb ) ; return - ENOMEM ; } usb_fill_bulk_urb ( urb , dev -> udev , usb_rcvbulkpipe ( dev -> udev , GSUSB_ENDPOINT_IN ) , buf , sizeof ( struct gs_host_frame ) , gs_usb_receive_bulk_callback , parent ) ; urb -> transfer_flags |= URB_NO_TRANSFER_DMA_MAP ; usb_anchor_urb ( urb , & parent -> rx_submitted ) ; rc = usb_submit_urb ( urb , GFP_KERNEL ) ; if ( rc ) { if ( rc == - ENODEV ) netif_device_detach ( dev -> netdev ) ; netdev_err ( netdev , ""usb_submitfailed(err=%d)\\n"" , rc ) ; usb_unanchor_urb ( urb ) ; break ; } usb_free_urb ( urb ) ; } } dm = kmalloc ( sizeof ( * dm ) , GFP_KERNEL ) ; if ( ! dm ) return - ENOMEM ; ctrlmode = dev -> can . ctrlmode ; dm -> flags = 0 ; if ( ctrlmode & CAN_CTRLMODE_LOOPBACK ) dm -> flags |= GS_CAN_MODE_LOOP_BACK ; else if ( ctrlmode & CAN_CTRLMODE_LISTENONLY ) dm -> flags |= GS_CAN_MODE_LISTEN_ONLY ; if ( ctrlmode & CAN_CTRLMODE_ONE_SHOT ) dm -> flags |= GS_CAN_MODE_ONE_SHOT ; if ( ctrlmode & CAN_CTRLMODE_3_SAMPLES ) dm -> flags |= GS_CAN_MODE_TRIPLE_SAMPLE ; dm -> mode = GS_CAN_MODE_START ; rc = usb_control_msg ( interface_to_usbdev ( dev -> iface ) , usb_sndctrlpipe ( interface_to_usbdev ( dev -> iface ) , 0 ) , GS_USB_BREQ_MODE , USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE , dev -> channel , 0 , dm , sizeof ( * dm ) , 1000 ) ; if ( rc < 0 ) { netdev_err ( netdev , ""Couldn\'tstartdevice(err=%d)\\n"" , rc ) ; kfree ( dm ) ; return rc ; } kfree ( dm ) ; dev -> can . state = CAN_STATE_ERROR_ACTIVE ; if ( ! ( dev -> can . ctrlmode & CAN_CTRLMODE_LISTENONLY ) ) netif_start_queue ( netdev ) ; return 0 ; } "," ) ; usb_unanchor_urb ( urb ) ; usb_free_urb ",torvalds@linux/fb5be6a7b4863ecc44963bb80ca614584b6c7817,CVE-2019-19052,https://github.com/torvalds/linux/commit/fb5be6a7b4863ecc44963bb80ca614584b6c7817,2019-11-18T06:15Z 58,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 59,CWE-284,"CWE-284 socket_t * socket_accept ( const socket_t * socket ) { assert ( socket != NULL ) ; int fd = accept ( socket -> fd , NULL , NULL ) ; if ( fd == INVALID_FD ) { LOG_ERROR ( ""%sunabletoacceptsocket:%s"" , __func__ , strerror ( errno ) ) ; return NULL ; } socket_t * ret = ( socket_t * ) osi_calloc ( sizeof ( socket_t ) ) ; if ( ! ret ) { close ( fd ) ; LOG_ERROR ( ""%sunabletoallocatememoryforsocket."" , __func__ ) ; return NULL ; } ret -> fd = fd ; return ret ; } "," int fd = TEMP_FAILURE_RETRY ( NULL , NULL ) ",system@bt/472271b153c5dc53c28beac55480a8d8434b2d5c,CVE-2016-3839,https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c,2016-08-05T20:59Z 60,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 61,CWE-264,"CWE-264 int perf_event_task_enable ( void ) { struct perf_event * event ; mutex_lock ( & current -> perf_event_mutex ) ; list_for_each_entry ( event , & current -> perf_event_list , owner_entry ) perf_event_for_each_child ( event , perf_event_enable ) ; mutex_unlock ( & current -> perf_event_mutex ) ; return 0 ; } "," void ) { struct perf_event_context * ctx ; , owner_entry ) { ctx = perf_event_ctx_lock ( event ) ; ( event , _perf_event_enable ) ; perf_event_ctx_unlock ( event , ctx ) ; } mutex_unlock ( & ",torvalds@linux/f63a8daa5812afef4f06c962351687e1ff9ccb2b,CVE-2016-6787,https://github.com/torvalds/linux/commit/f63a8daa5812afef4f06c962351687e1ff9ccb2b,2016-12-28T07:59Z 62,CWE-119,"CWE-119 static int gs_usb_probe ( struct usb_interface * intf , const struct usb_device_id * id ) { struct gs_usb * dev ; int rc = - ENOMEM ; unsigned int icount , i ; struct gs_host_config hconf = { . byte_order = 0x0000beef , } ; struct gs_device_config dconf ; rc = usb_control_msg ( interface_to_usbdev ( intf ) , usb_sndctrlpipe ( interface_to_usbdev ( intf ) , 0 ) , GS_USB_BREQ_HOST_FORMAT , USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE , 1 , intf -> altsetting [ 0 ] . desc . bInterfaceNumber , & hconf , sizeof ( hconf ) , 1000 ) ; if ( rc < 0 ) { dev_err ( & intf -> dev , ""Couldn\'tsenddataformat(err=%d)\\n"" , rc ) ; return rc ; } rc = usb_control_msg ( interface_to_usbdev ( intf ) , usb_rcvctrlpipe ( interface_to_usbdev ( intf ) , 0 ) , GS_USB_BREQ_DEVICE_CONFIG , USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE , 1 , intf -> altsetting [ 0 ] . desc . bInterfaceNumber , & dconf , sizeof ( dconf ) , 1000 ) ; if ( rc < 0 ) { dev_err ( & intf -> dev , ""Couldn\'tgetdeviceconfig:(err=%d)\\n"" , rc ) ; return rc ; } icount = dconf . icount + 1 ; dev_info ( & intf -> dev , ""Configuringfor%dinterfaces\\n"" , icount ) ; if ( icount > GS_MAX_INTF ) { dev_err ( & intf -> dev , ""Drivercannothandlemorethat%dCANinterfaces\\n"" , GS_MAX_INTF ) ; return - EINVAL ; } dev = kzalloc ( sizeof ( * dev ) , GFP_KERNEL ) ; if ( ! dev ) return - ENOMEM ; init_usb_anchor ( & dev -> rx_submitted ) ; atomic_set ( & dev -> active_channels , 0 ) ; usb_set_intfdata ( intf , dev ) ; dev -> udev = interface_to_usbdev ( intf ) ; for ( i = 0 ; i < icount ; i ++ ) { dev -> canch [ i ] = gs_make_candev ( i , intf , & dconf ) ; if ( IS_ERR_OR_NULL ( dev -> canch [ i ] ) ) { rc = PTR_ERR ( dev -> canch [ i ] ) ; icount = i ; for ( i = 0 ; i < icount ; i ++ ) gs_destroy_candev ( dev -> canch [ i ] ) ; usb_kill_anchored_urbs ( & dev -> rx_submitted ) ; kfree ( dev ) ; return rc ; } dev -> canch [ i ] -> parent = dev ; } return 0 ; } "," ; struct gs_host_config * hconf ; struct gs_device_config ; struct gs_device_config * dconf ; hconf = kmalloc ( sizeof ( * hconf ) , GFP_KERNEL ) ; if ( ! hconf ) return - ENOMEM ; hconf -> byte_order = 0x0000beef ; rc = . bInterfaceNumber , hconf , sizeof , sizeof ( * 1000 ) ; kfree ( hconf ) ; rc ; } dconf = kmalloc ( sizeof ( * dconf ) , GFP_KERNEL ) ; if ( ! dconf ) return - ENOMEM ; . bInterfaceNumber , dconf , sizeof , sizeof ( * rc ) ; kfree ( dconf ) ; return rc ; } icount = dconf -> icount + 1 GS_MAX_INTF ) ; kfree ( dconf ) ; ! dev ) { kfree ( dconf ) ; - ENOMEM ; } , intf , dconf ) ; ; kfree ( dconf ) ; kfree ( dev ; } kfree ( dconf ) ; ",torvalds@linux/c919a3069c775c1c876bec55e00b2305d5125caa,CVE-2017-8066,https://github.com/torvalds/linux/commit/c919a3069c775c1c876bec55e00b2305d5125caa,2017-04-23T05:59Z 63,CWE-20,"CWE-20 static int rose_parse_ccitt ( unsigned char * p , struct rose_facilities_struct * facilities , int len ) { unsigned char l , n = 0 ; char callsign [ 11 ] ; do { switch ( * p & 0xC0 ) { case 0x00 : p += 2 ; n += 2 ; len -= 2 ; break ; case 0x40 : p += 3 ; n += 3 ; len -= 3 ; break ; case 0x80 : p += 4 ; n += 4 ; len -= 4 ; break ; case 0xC0 : l = p [ 1 ] ; if ( l < 10 || l > 20 ) return - 1 ; if ( * p == FAC_CCITT_DEST_NSAP ) { memcpy ( & facilities -> source_addr , p + 7 , ROSE_ADDR_LEN ) ; memcpy ( callsign , p + 12 , l - 10 ) ; callsign [ l - 10 ] = '\\0' ; asc2ax ( & facilities -> source_call , callsign ) ; } if ( * p == FAC_CCITT_SRC_NSAP ) { memcpy ( & facilities -> dest_addr , p + 7 , ROSE_ADDR_LEN ) ; memcpy ( callsign , p + 12 , l - 10 ) ; callsign [ l - 10 ] = '\\0' ; asc2ax ( & facilities -> dest_call , callsign ) ; } p += l + 2 ; n += l + 2 ; len -= l + 2 ; break ; } } while ( * p != 0x00 && len > 0 ) ; return n ; } "," case 0x00 : if ( len < 2 ) return - 1 ; case 0x40 : if ( len < 3 ) return - 1 ; case 0x80 : if ( len < 4 ) return - 1 ; case 0xC0 : if ( len < 2 ) return - 1 ; ",torvalds@linux/e0bccd315db0c2f919e7fcf9cb60db21d9986f52,CVE-2011-4914,https://github.com/torvalds/linux/commit/e0bccd315db0c2f919e7fcf9cb60db21d9986f52,2012-06-21T23:55Z 64,CWE-362,"CWE-362 unsigned long insn_get_seg_base ( struct pt_regs * regs , int seg_reg_idx ) { struct desc_struct * desc ; short sel ; sel = get_segment_selector ( regs , seg_reg_idx ) ; if ( sel < 0 ) return - 1L ; if ( v8086_mode ( regs ) ) return ( unsigned long ) ( sel << 4 ) ; if ( user_64bit_mode ( regs ) ) { unsigned long base ; if ( seg_reg_idx == INAT_SEG_REG_FS ) rdmsrl ( MSR_FS_BASE , base ) ; else if ( seg_reg_idx == INAT_SEG_REG_GS ) rdmsrl ( MSR_KERNEL_GS_BASE , base ) ; else base = 0 ; return base ; } if ( ! sel ) return - 1L ; desc = get_desc ( sel ) ; if ( ! desc ) return - 1L ; return get_desc_base ( desc ) ; } "," { struct desc_struct desc ; short - 1L ; if ( ! if ( ! get_desc ( & desc , sel ) ) return - return get_desc_base ( & ",torvalds@linux/de9f869616dd95e95c00bdd6b0fcd3421e8a4323,CVE-2019-13233,https://github.com/torvalds/linux/commit/de9f869616dd95e95c00bdd6b0fcd3421e8a4323,2019-07-04T13:15Z 65,CWE-863,"CWE-863 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 66,CWE-20,"CWE-20 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 ; 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 ( - 1 ) ; } fd = socket ( AF_NETLINK , SOCK_DGRAM , NETLINK_CONNECTOR ) ; if ( fd < 0 ) { syslog ( LOG_ERR , ""netlinksocketcreationfailed;error:%d"" , fd ) ; exit ( - 1 ) ; } 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 ( - 1 ) ; } 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_REGISTER ; 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 ( - 1 ) ; } pfd . fd = fd ; while ( 1 ) { pfd . events = POLLIN ; pfd . revents = 0 ; poll ( & pfd , 1 , - 1 ) ; len = recv ( fd , kvp_recv_buffer , sizeof ( kvp_recv_buffer ) , 0 ) ; if ( len < 0 ) { syslog ( LOG_ERR , ""recvfailed;error:%d"" , len ) ; 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 ; switch ( hv_msg -> kvp_hdr . operation ) { case KVP_OP_REGISTER : 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 ; case KVP_OP_SET : if ( kvp_key_add_or_modify ( hv_msg -> kvp_hdr . 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 ) ) strcpy ( hv_msg -> body . kvp_set . data . key , """" ) ; break ; case KVP_OP_GET : if ( kvp_get_value ( hv_msg -> kvp_hdr . 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 ) ) strcpy ( hv_msg -> body . kvp_set . data . key , """" ) ; break ; case KVP_OP_DELETE : if ( kvp_key_delete ( hv_msg -> kvp_hdr . pool , hv_msg -> body . kvp_delete . key , hv_msg -> body . kvp_delete . key_size ) ) strcpy ( hv_msg -> body . kvp_delete . key , """" ) ; break ; default : break ; } if ( hv_msg -> kvp_hdr . operation != KVP_OP_ENUMERATE ) goto kvp_done ; if ( hv_msg -> kvp_hdr . pool != KVP_POOL_AUTO ) { kvp_pool_enumerate ( hv_msg -> kvp_hdr . 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 ) ; 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_address ( AF_INET , key_value , HV_KVP_EXCHANGE_MAX_VALUE_SIZE ) ; strcpy ( key_name , ""NetworkAddressIPv4"" ) ; break ; case NetworkAddressIPv6 : kvp_get_ip_address ( AF_INET6 , 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_build ) ; strcpy ( key_name , ""OSVersion"" ) ; break ; case ProcessorArchitecture : strcpy ( key_value , processor_arch ) ; strcpy ( key_name , ""ProcessorArchitecture"" ) ; break ; default : strcpy ( key_value , ""UnknownKey"" ) ; strcpy ( key_name , """" ) ; 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 ( - 1 ) ; } } } "," 1 ) { struct sockaddr * addr_p = ( struct sockaddr * ) & addr ; socklen_t addr_l = sizeof ( addr ) ; ; len = recvfrom ( fd , ) , 0 , addr_p , & addr_l len < 0 || addr . nl_pid ( LOG_ERR , ""recvfromfailed;pid:%uerror:%d%s"" , addr . nl_pid , errno , strerror ( errno ) ) ; close ",torvalds@linux/bcc2c9c3fff859e0eb019fe6fec26f9b8eba795c,CVE-2012-2669,https://github.com/torvalds/linux/commit/bcc2c9c3fff859e0eb019fe6fec26f9b8eba795c,2012-12-27T11:47Z 67,CWE-772,"CWE-772 generic_ret * purgekeys_2_svc ( purgekeys_arg * arg , struct svc_req * rqstp ) { static generic_ret ret ; char * prime_arg , * funcname ; gss_buffer_desc client_name , service_name ; OM_uint32 minor_stat ; kadm5_server_handle_t handle ; const char * errmsg = NULL ; xdr_free ( xdr_generic_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 ; funcname = ""kadm5_purgekeys"" ; 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_MODIFY , arg -> princ , NULL ) ) ) { ret . code = KADM5_AUTH_MODIFY ; log_unauth ( funcname , prime_arg , & client_name , & service_name , rqstp ) ; } else { ret . code = kadm5_purgekeys ( ( void * ) handle , arg -> princ , arg -> keepkvno ) ; if ( ret . code != 0 ) errmsg = krb5_get_error_message ( handle -> context , ret . code ) ; log_done ( funcname , 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 68,CWE-119,"CWE-119 void oz_usb_rx ( struct oz_pd * pd , struct oz_elt * elt ) { struct oz_usb_hdr * usb_hdr = ( struct oz_usb_hdr * ) ( elt + 1 ) ; struct oz_usb_ctx * usb_ctx ; spin_lock_bh ( & pd -> app_lock [ OZ_APPID_USB ] ) ; usb_ctx = ( struct oz_usb_ctx * ) pd -> app_ctx [ OZ_APPID_USB ] ; if ( usb_ctx ) oz_usb_get ( usb_ctx ) ; spin_unlock_bh ( & pd -> app_lock [ OZ_APPID_USB ] ) ; if ( usb_ctx == NULL ) return ; if ( usb_ctx -> stopped ) goto done ; if ( usb_hdr -> elt_seq_num != 0 ) { if ( ( ( usb_ctx -> rx_seq_num - usb_hdr -> elt_seq_num ) & 0x80 ) == 0 ) goto done ; } usb_ctx -> rx_seq_num = usb_hdr -> elt_seq_num ; switch ( usb_hdr -> type ) { case OZ_GET_DESC_RSP : { struct oz_get_desc_rsp * body = ( struct oz_get_desc_rsp * ) usb_hdr ; int data_len = elt -> length - sizeof ( struct oz_get_desc_rsp ) + 1 ; u16 offs = le16_to_cpu ( get_unaligned ( & body -> offset ) ) ; u16 total_size = le16_to_cpu ( get_unaligned ( & body -> total_size ) ) ; oz_dbg ( ON , ""USB_REQ_GET_DESCRIPTOR-cnf\\n"" ) ; oz_hcd_get_desc_cnf ( usb_ctx -> hport , body -> req_id , body -> rcode , body -> data , data_len , offs , total_size ) ; } break ; case OZ_SET_CONFIG_RSP : { struct oz_set_config_rsp * body = ( struct oz_set_config_rsp * ) usb_hdr ; oz_hcd_control_cnf ( usb_ctx -> hport , body -> req_id , body -> rcode , NULL , 0 ) ; } break ; case OZ_SET_INTERFACE_RSP : { struct oz_set_interface_rsp * body = ( struct oz_set_interface_rsp * ) usb_hdr ; oz_hcd_control_cnf ( usb_ctx -> hport , body -> req_id , body -> rcode , NULL , 0 ) ; } break ; case OZ_VENDOR_CLASS_RSP : { struct oz_vendor_class_rsp * body = ( struct oz_vendor_class_rsp * ) usb_hdr ; oz_hcd_control_cnf ( usb_ctx -> hport , body -> req_id , body -> rcode , body -> data , elt -> length - sizeof ( struct oz_vendor_class_rsp ) + 1 ) ; } break ; case OZ_USB_ENDPOINT_DATA : oz_usb_handle_ep_data ( usb_ctx , usb_hdr , elt -> length ) ; break ; } done : oz_usb_put ( usb_ctx ) ; } "," ) usb_hdr ; u16 offs , total_size ; u8 data_len ; if ( elt -> length < sizeof ( struct oz_get_desc_rsp ) - 1 ) break ; data_len = elt -> length - ( ( struct oz_get_desc_rsp ) - 1 ) ; offs = le16_to_cpu ( get_unaligned ( & body -> offset ) ) ; total_size = le16_to_cpu ( get_unaligned ( & body -> total_size ) ) ; oz_dbg ( ON , ""USB_REQ_GET_DESCRIPTOR-cnf\\n"" ) ; oz_hcd_get_desc_cnf ( usb_ctx -> hport , body -> req_id , body -> rcode , body -> data , data_len , offs , total_size ) ; } break ; case OZ_SET_CONFIG_RSP : { struct oz_set_config_rsp * body = ( struct oz_set_config_rsp * ) usb_hdr ; oz_hcd_control_cnf ( usb_ctx -> hport , body -> req_id , body -> rcode , NULL , 0 ) ; } break ; case OZ_SET_INTERFACE_RSP : { struct oz_set_interface_rsp * body = ( struct oz_set_interface_rsp * ) usb_hdr ; oz_hcd_control_cnf ( usb_ctx -> hport , body -> req_id , body -> rcode , NULL , 0 ) ; } break ; case OZ_VENDOR_CLASS_RSP : { struct oz_vendor_class_rsp * body = ( struct oz_vendor_class_rsp * ) usb_hdr ; oz_hcd_control_cnf ( usb_ctx -> hport , body -> req_id , body -> rcode , body -> data , elt -> length - sizeof ( struct oz_vendor_class_rsp ) + 1 ) ; } ",torvalds@linux/d114b9fe78c8d6fc6e70808c2092aa307c36dc8e,CVE-2015-4002,https://github.com/torvalds/linux/commit/d114b9fe78c8d6fc6e70808c2092aa307c36dc8e,2015-06-07T23:59Z 69,CWE-000,"CWE-000 static struct nfs4_opendata * nfs4_opendata_alloc ( struct path * path , struct nfs4_state_owner * sp , int flags , const struct iattr * attrs ) { struct dentry * parent = dget_parent ( path -> dentry ) ; struct inode * dir = parent -> d_inode ; struct nfs_server * server = NFS_SERVER ( dir ) ; struct nfs4_opendata * p ; p = kzalloc ( sizeof ( * p ) , GFP_KERNEL ) ; if ( p == NULL ) goto err ; p -> o_arg . seqid = nfs_alloc_seqid ( & sp -> so_seqid ) ; if ( p -> o_arg . seqid == NULL ) goto err_free ; p -> path . mnt = mntget ( path -> mnt ) ; p -> path . dentry = dget ( path -> dentry ) ; p -> dir = parent ; p -> owner = sp ; atomic_inc ( & sp -> so_count ) ; p -> o_arg . fh = NFS_FH ( dir ) ; p -> o_arg . open_flags = flags , p -> o_arg . clientid = server -> nfs_client -> cl_clientid ; p -> o_arg . id = sp -> so_owner_id . id ; p -> o_arg . name = & p -> path . dentry -> d_name ; p -> o_arg . server = server ; p -> o_arg . bitmask = server -> attr_bitmask ; p -> o_arg . claim = NFS4_OPEN_CLAIM_NULL ; if ( flags & O_EXCL ) { u32 * s = ( u32 * ) p -> o_arg . u . verifier . data ; s [ 0 ] = jiffies ; s [ 1 ] = current -> pid ; } else if ( flags & O_CREAT ) { p -> o_arg . u . attrs = & p -> attrs ; memcpy ( & p -> attrs , attrs , sizeof ( p -> attrs ) ) ; } p -> c_arg . fh = & p -> o_res . fh ; p -> c_arg . stateid = & p -> o_res . stateid ; p -> c_arg . seqid = p -> o_arg . seqid ; nfs4_init_opendata_res ( p ) ; kref_init ( & p -> kref ) ; return p ; err_free : kfree ( p ) ; err : dput ( parent ) ; return NULL ; } "," nfs4_state_owner * sp , fmode_t fmode open_flags = flags ; p -> o_arg . fmode = fmode & ( FMODE_READ | FMODE_WRITE ) ; p -> o_arg ",torvalds@linux/dc0b027dfadfcb8a5504f7d8052754bf8d501ab9,CVE-2011-4324,https://github.com/torvalds/linux/commit/dc0b027dfadfcb8a5504f7d8052754bf8d501ab9,2012-06-21T23:55Z 70,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 71,CWE-189,"CWE-189 static ssize_t __nfs4_get_acl_uncached ( struct inode * inode , void * buf , size_t buflen ) { struct page * pages [ NFS4ACL_MAXPAGES ] ; struct nfs_getaclargs args = { . fh = NFS_FH ( inode ) , . acl_pages = pages , . acl_len = buflen , } ; struct nfs_getaclres res = { . acl_len = buflen , } ; void * resp_buf ; struct rpc_message msg = { . rpc_proc = & nfs4_procedures [ NFSPROC4_CLNT_GETACL ] , . rpc_argp = & args , . rpc_resp = & res , } ; struct page * localpage = NULL ; int ret ; if ( buflen < PAGE_SIZE ) { localpage = alloc_page ( GFP_KERNEL ) ; resp_buf = page_address ( localpage ) ; if ( localpage == NULL ) return - ENOMEM ; args . acl_pages [ 0 ] = localpage ; args . acl_pgbase = 0 ; args . acl_len = PAGE_SIZE ; } else { resp_buf = buf ; buf_to_pages ( buf , buflen , args . acl_pages , & args . acl_pgbase ) ; } ret = nfs4_call_sync ( NFS_SERVER ( inode ) -> client , NFS_SERVER ( inode ) , & msg , & args . seq_args , & res . seq_res , 0 ) ; if ( ret ) goto out_free ; if ( res . acl_len > args . acl_len ) nfs4_write_cached_acl ( inode , NULL , res . acl_len ) ; else nfs4_write_cached_acl ( inode , resp_buf , res . acl_len ) ; if ( buf ) { ret = - ERANGE ; if ( res . acl_len > buflen ) goto out_free ; if ( localpage ) memcpy ( buf , resp_buf , res . acl_len ) ; } ret = res . acl_len ; out_free : if ( localpage ) __free_page ( localpage ) ; return ret ; } "," [ NFS4ACL_MAXPAGES ] = { NULL , } , } ; int ret = - ENOMEM , npages , i , acl_len = 0 ; npages = ( buflen + PAGE_SIZE - 1 ) >> PAGE_SHIFT ; if ( npages == 0 ) npages = 1 ; for ( i = 0 ; i < npages ; i ++ ) { pages [ i ] = alloc_page ( GFP_KERNEL ) ; if ( ! pages [ i ] ) goto out_free ; } if ( npages > 1 ) { args . acl_scratch = alloc_page ( GFP_KERNEL ) ; if ( ! args . acl_scratch ) goto out_free ; } args . acl_len = npages * PAGE_SIZE ; args . acl_pgbase = 0 ; if ( buf == NULL ) == NULL ) res . acl_flags |= NFS4_ACL_LEN_REQUEST ; resp_buf = page_address ( pages [ 0 ] ) ; dprintk ( ""%sbuf%pbuflen%ldnpages%dargs.acl_len%ld\\n"" , __func__ , buf , buflen , npages , args . acl_len ) ; ret = nfs4_call_sync goto out_free ; acl_len = res . acl_len - res . acl_data_offset ; if ( acl_len > args , NULL , acl_len ) ; inode , resp_buf + res . acl_data_offset , acl_len ) ; ; if ( acl_len > buflen goto out_free ; _copy_from_pages ( buf , ( buf , pages , res . acl_data_offset , res . acl_len ) ; } ret = acl_len ; out_free ; out_free : for ( i = 0 ; i < npages ; i ++ ) if ( pages [ i ] ) __free_page ( ) __free_page ( pages [ i ] ) ; if ( args . acl_scratch ) __free_page ( args . acl_scratch ) ; return ",torvalds@linux/bf118a342f10dafe44b14451a1392c3254629a1f,CVE-2011-4131,https://github.com/torvalds/linux/commit/bf118a342f10dafe44b14451a1392c3254629a1f,2012-05-17T11:00Z 72,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 73,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 74,CWE-362,"CWE-362 int cipso_v4_sock_getattr ( struct sock * sk , struct netlbl_lsm_secattr * secattr ) { struct ip_options * opt ; opt = inet_sk ( sk ) -> opt ; if ( opt == NULL || opt -> cipso == 0 ) return - ENOMSG ; return cipso_v4_getattr ( opt -> __data + opt -> cipso - sizeof ( struct iphdr ) , secattr ) ; } "," ) { struct ip_options_rcu * opt ; * opt ; int res = - ENOMSG ; rcu_read_lock ( ) ; opt = rcu_dereference ( inet_sk ( sk sk ) -> inet_opt ) ; if ( if ( opt && opt -> opt . cipso ) res = cipso_v4_getattr ( opt ( opt -> opt . + opt -> opt . secattr ) ; rcu_read_unlock ( ) ; return res ; ",torvalds@linux/f6d8bd051c391c1c0458a30b2a7abcd939329259,CVE-2012-3552,https://github.com/torvalds/linux/commit/f6d8bd051c391c1c0458a30b2a7abcd939329259,2012-10-03T11:02Z 75,CWE-119,"CWE-119 static Image * ReadDIBImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { DIBInfo dib_info ; Image * image ; IndexPacket index ; ssize_t bit , y ; MagickBooleanType status ; MemoryInfo * pixel_info ; register IndexPacket * indexes ; register ssize_t x ; register PixelPacket * q ; register ssize_t i ; register unsigned char * p ; size_t bytes_per_line , length ; ssize_t count ; 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 ) ; } ( void ) ResetMagickMemory ( & dib_info , 0 , sizeof ( dib_info ) ) ; dib_info . size = ReadBlobLSBLong ( image ) ; if ( dib_info . size != 40 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; dib_info . width = ( short ) ReadBlobLSBLong ( image ) ; dib_info . height = ( short ) ReadBlobLSBLong ( image ) ; dib_info . planes = ReadBlobLSBShort ( image ) ; dib_info . bits_per_pixel = ReadBlobLSBShort ( image ) ; dib_info . compression = ReadBlobLSBLong ( image ) ; dib_info . image_size = ReadBlobLSBLong ( image ) ; dib_info . x_pixels = ReadBlobLSBLong ( image ) ; dib_info . y_pixels = ReadBlobLSBLong ( image ) ; dib_info . number_colors = ReadBlobLSBLong ( image ) ; dib_info . colors_important = ReadBlobLSBLong ( image ) ; if ( ( dib_info . compression == BI_BITFIELDS ) && ( ( dib_info . bits_per_pixel == 16 ) || ( dib_info . bits_per_pixel == 32 ) ) ) { dib_info . red_mask = ReadBlobLSBLong ( image ) ; dib_info . green_mask = ReadBlobLSBLong ( image ) ; dib_info . blue_mask = ReadBlobLSBLong ( image ) ; } image -> matte = dib_info . bits_per_pixel == 32 ? MagickTrue : MagickFalse ; image -> columns = ( size_t ) MagickAbsoluteValue ( dib_info . width ) ; image -> rows = ( size_t ) MagickAbsoluteValue ( dib_info . height ) ; image -> depth = 8 ; if ( ( dib_info . number_colors != 0 ) || ( dib_info . bits_per_pixel < 16 ) ) { size_t one ; image -> storage_class = PseudoClass ; image -> colors = dib_info . number_colors ; one = 1 ; if ( image -> colors == 0 ) image -> colors = one << dib_info . bits_per_pixel ; } if ( image_info -> size ) { RectangleInfo geometry ; MagickStatusType flags ; flags = ParseAbsoluteGeometry ( image_info -> size , & geometry ) ; if ( flags & WidthValue ) if ( ( geometry . width != 0 ) && ( geometry . width < image -> columns ) ) image -> columns = geometry . width ; if ( flags & HeightValue ) if ( ( geometry . height != 0 ) && ( geometry . height < image -> rows ) ) image -> rows = geometry . height ; } if ( image -> storage_class == PseudoClass ) { size_t length , packet_size ; unsigned char * dib_colormap ; if ( AcquireImageColormap ( image , image -> colors ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; length = ( size_t ) image -> colors ; dib_colormap = ( unsigned char * ) AcquireQuantumMemory ( length , 4 * sizeof ( * dib_colormap ) ) ; if ( dib_colormap == ( unsigned char * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; packet_size = 4 ; count = ReadBlob ( image , packet_size * image -> colors , dib_colormap ) ; if ( count != ( ssize_t ) ( packet_size * image -> colors ) ) ThrowReaderException ( CorruptImageError , ""InsufficientImageDataInFile"" ) ; p = dib_colormap ; for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { image -> colormap [ i ] . blue = ScaleCharToQuantum ( * p ++ ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( * p ++ ) ; image -> colormap [ i ] . red = ScaleCharToQuantum ( * p ++ ) ; if ( packet_size == 4 ) p ++ ; } dib_colormap = ( unsigned char * ) RelinquishMagickMemory ( dib_colormap ) ; } if ( dib_info . compression == BI_RLE4 ) dib_info . bits_per_pixel <<= 1 ; bytes_per_line = 4 * ( ( image -> columns * dib_info . bits_per_pixel + 31 ) / 32 ) ; length = bytes_per_line * image -> rows ; pixel_info = AcquireVirtualMemory ( ( size_t ) 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 ( ( dib_info . compression == BI_RGB ) || ( dib_info . compression == BI_BITFIELDS ) ) { count = ReadBlob ( image , length , pixels ) ; if ( count != ( ssize_t ) ( length ) ) ThrowReaderException ( CorruptImageError , ""InsufficientImageDataInFile"" ) ; } else { status = DecodeImage ( image , dib_info . compression ? MagickTrue : MagickFalse , pixels ) ; if ( status == MagickFalse ) ThrowReaderException ( CorruptImageError , ""UnableToRunlengthDecodeImage"" ) ; } image -> units = PixelsPerCentimeterResolution ; image -> x_resolution = ( double ) dib_info . x_pixels / 100.0 ; image -> y_resolution = ( double ) dib_info . y_pixels / 100.0 ; switch ( dib_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 == ( PixelPacket * ) NULL ) break ; indexes = GetAuthenticIndexQueue ( image ) ; for ( x = 0 ; x < ( ( ssize_t ) image -> columns - 7 ) ; x += 8 ) { for ( bit = 0 ; bit < 8 ; bit ++ ) { index = ( IndexPacket ) ( ( * p ) & ( 0x80 >> bit ) ? 0x01 : 0x00 ) ; SetPixelIndex ( indexes + x + bit , index ) ; } p ++ ; } if ( ( image -> columns % 8 ) != 0 ) { for ( bit = 0 ; bit < ( ssize_t ) ( image -> columns % 8 ) ; bit ++ ) { index = ( IndexPacket ) ( ( * p ) & ( 0x80 >> bit ) ? 0x01 : 0x00 ) ; SetPixelIndex ( indexes + x + bit , index ) ; } p ++ ; } 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 ; } } ( void ) SyncImage ( image ) ; 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 == ( PixelPacket * ) NULL ) break ; indexes = GetAuthenticIndexQueue ( image ) ; for ( x = 0 ; x < ( ( ssize_t ) image -> columns - 1 ) ; x += 2 ) { index = ConstrainColormapIndex ( image , ( * p >> 4 ) & 0xf ) ; SetPixelIndex ( indexes + x , index ) ; index = ConstrainColormapIndex ( image , * p & 0xf ) ; SetPixelIndex ( indexes + x + 1 , index ) ; p ++ ; } if ( ( image -> columns % 2 ) != 0 ) { index = ConstrainColormapIndex ( image , ( * p >> 4 ) & 0xf ) ; SetPixelIndex ( indexes + x , index ) ; p ++ ; } 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 ; } } ( void ) SyncImage ( image ) ; break ; } case 8 : { if ( ( dib_info . compression == BI_RLE8 ) || ( dib_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 == ( PixelPacket * ) NULL ) break ; indexes = GetAuthenticIndexQueue ( image ) ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { index = ConstrainColormapIndex ( image , * p ) ; SetPixelIndex ( indexes + x , index ) ; p ++ ; q ++ ; } 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 ; } } ( void ) SyncImage ( image ) ; break ; } case 16 : { unsigned short word ; image -> storage_class = DirectClass ; if ( dib_info . compression == BI_RLE8 ) bytes_per_line = 2 * 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 == ( PixelPacket * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { word = ( * p ++ ) ; word |= ( * p ++ << 8 ) ; if ( dib_info . red_mask == 0 ) { SetPixelRed ( q , ScaleCharToQuantum ( ScaleColor5to8 ( ( unsigned char ) ( ( word >> 10 ) & 0x1f ) ) ) ) ; SetPixelGreen ( q , ScaleCharToQuantum ( ScaleColor5to8 ( ( unsigned char ) ( ( word >> 5 ) & 0x1f ) ) ) ) ; SetPixelBlue ( q , ScaleCharToQuantum ( ScaleColor5to8 ( ( unsigned char ) ( word & 0x1f ) ) ) ) ; } else { SetPixelRed ( q , ScaleCharToQuantum ( ScaleColor5to8 ( ( unsigned char ) ( ( word >> 11 ) & 0x1f ) ) ) ) ; SetPixelGreen ( q , ScaleCharToQuantum ( ScaleColor6to8 ( ( unsigned char ) ( ( word >> 5 ) & 0x3f ) ) ) ) ; SetPixelBlue ( q , ScaleCharToQuantum ( ScaleColor5to8 ( ( unsigned char ) ( word & 0x1f ) ) ) ) ; } q ++ ; } 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 -- ) { p = pixels + ( image -> rows - y - 1 ) * bytes_per_line ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelBlue ( q , ScaleCharToQuantum ( * p ++ ) ) ; SetPixelGreen ( q , ScaleCharToQuantum ( * p ++ ) ) ; SetPixelRed ( q , ScaleCharToQuantum ( * p ++ ) ) ; if ( image -> matte != MagickFalse ) SetPixelOpacity ( q , ScaleCharToQuantum ( * p ++ ) ) ; q ++ ; } 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"" ) ; } pixel_info = RelinquishVirtualMemory ( pixel_info ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; if ( dib_info . height < 0 ) { Image * flipped_image ; flipped_image = FlipImage ( image , exception ) ; if ( flipped_image != ( Image * ) NULL ) { DuplicateBlob ( flipped_image , image ) ; image = DestroyImage ( image ) ; image = flipped_image ; } } ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," height ; } 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 76,CWE-189,"CWE-189 static void nfs4_xdr_enc_getacl ( struct rpc_rqst * req , struct xdr_stream * xdr , struct nfs_getaclargs * args ) { struct compound_hdr hdr = { . minorversion = nfs4_xdr_minorversion ( & args -> seq_args ) , } ; uint32_t replen ; encode_compound_hdr ( xdr , req , & hdr ) ; encode_sequence ( xdr , & args -> seq_args , & hdr ) ; encode_putfh ( xdr , args -> fh , & hdr ) ; replen = hdr . replen + op_decode_hdr_maxsz + nfs4_fattr_bitmap_maxsz + 1 ; encode_getattr_two ( xdr , FATTR4_WORD0_ACL , 0 , & hdr ) ; xdr_inline_pages ( & req -> rq_rcv_buf , replen << 2 , args -> acl_pages , args -> acl_pgbase , args -> acl_len ) ; encode_nops ( & hdr ) ; } "," + op_decode_hdr_maxsz + 1 ; encode_getattr_two acl_len ) ; xdr_set_scratch_buffer ( xdr , page_address ( args -> acl_scratch ) , PAGE_SIZE ) ; ",torvalds@linux/bf118a342f10dafe44b14451a1392c3254629a1f,CVE-2011-4131,https://github.com/torvalds/linux/commit/bf118a342f10dafe44b14451a1392c3254629a1f,2012-05-17T11:00Z 77,CWE-295,"CWE-295 static int ssl_verify_cert ( struct tunnel * tunnel ) { int ret = - 1 ; int cert_valid = 0 ; unsigned char digest [ SHA256LEN ] ; unsigned int len ; struct x509_digest * elem ; char digest_str [ SHA256STRLEN ] , * subject , * issuer ; char * line ; int i ; X509_NAME * subj ; SSL_set_verify ( tunnel -> ssl_handle , SSL_VERIFY_PEER , NULL ) ; X509 * cert = SSL_get_peer_certificate ( tunnel -> ssl_handle ) ; if ( cert == NULL ) { log_error ( ""Unabletogetgatewaycertificate.\\n"" ) ; return 1 ; } subj = X509_get_subject_name ( cert ) ; # ifdef HAVE_X509_CHECK_HOST if ( X509_check_host ( cert , tunnel -> config -> gateway_host , 0 , 0 , NULL ) == 1 ) cert_valid = 1 ; # else char common_name [ FIELD_SIZE + 1 ] ; if ( subj && X509_NAME_get_text_by_NID ( subj , NID_commonName , common_name , FIELD_SIZE ) > 0 && strncasecmp ( common_name , tunnel -> config -> gateway_host , FIELD_SIZE ) == 0 ) cert_valid = 1 ; # endif if ( cert_valid && SSL_get_verify_result ( tunnel -> ssl_handle ) == X509_V_OK ) { log_debug ( ""Gatewaycertificatevalidationsucceeded.\\n"" ) ; ret = 0 ; goto free_cert ; } log_debug ( ""Gatewaycertificatevalidationfailed.\\n"" ) ; if ( X509_digest ( cert , EVP_sha256 ( ) , digest , & len ) <= 0 || len != SHA256LEN ) { log_error ( ""Couldnotcomputecertificatesha256digest.\\n"" ) ; goto free_cert ; } for ( i = 0 ; i < SHA256LEN ; i ++ ) sprintf ( & digest_str [ 2 * i ] , ""%02x"" , digest [ i ] ) ; digest_str [ SHA256STRLEN - 1 ] = '\\0' ; for ( elem = tunnel -> config -> cert_whitelist ; elem != NULL ; elem = elem -> next ) if ( memcmp ( digest_str , elem -> data , SHA256STRLEN - 1 ) == 0 ) break ; if ( elem != NULL ) { log_debug ( ""Gatewaycertificatedigestfoundinwhitelist.\\n"" ) ; ret = 0 ; goto free_cert ; } subject = X509_NAME_oneline ( subj , NULL , 0 ) ; issuer = X509_NAME_oneline ( X509_get_issuer_name ( cert ) , NULL , 0 ) ; log_error ( ""Gatewaycertificatevalidationfailed,andthecertificatedigestinnotinthelocalwhitelist.Ifyoutrustit,rerunwith:\\n"" ) ; log_error ( ""--trusted-cert%s\\n"" , digest_str ) ; log_error ( ""oraddthislinetoyourconfigfile:\\n"" ) ; log_error ( ""trusted-cert=%s\\n"" , digest_str ) ; log_error ( ""Gatewaycertificate:\\n"" ) ; log_error ( ""subject:\\n"" ) ; for ( line = strtok ( subject , ""/"" ) ; line != NULL ; line = strtok ( NULL , ""/"" ) ) log_error ( ""%s\\n"" , line ) ; log_error ( ""issuer:\\n"" ) ; for ( line = strtok ( issuer , ""/"" ) ; line != NULL ; line = strtok ( NULL , ""/"" ) ) log_error ( ""%s\\n"" , line ) ; log_error ( ""sha256digest:\\n"" ) ; log_error ( ""%s\\n"" , digest_str ) ; free_cert : X509_free ( cert ) ; return ret ; } "," ; # else if ( validate_hostname ( tunnel -> config -> gateway_host , cert ) == MatchFound ) cert_valid = ",adrienverge@openfortivpn/6328a070ddaab16faaf008cb9a8a62439c30f2a8,CVE-2020-7043,https://github.com/adrienverge/openfortivpn/commit/6328a070ddaab16faaf008cb9a8a62439c30f2a8,2020-02-27T18:15Z 78,CWE-400,"CWE-400 static void rpc_init_task ( struct rpc_task * task , const struct rpc_task_setup * task_setup_data ) { memset ( task , 0 , sizeof ( * task ) ) ; atomic_set ( & task -> tk_count , 1 ) ; task -> tk_flags = task_setup_data -> flags ; task -> tk_ops = task_setup_data -> callback_ops ; task -> tk_calldata = task_setup_data -> callback_data ; INIT_LIST_HEAD ( & task -> tk_task ) ; task -> tk_garb_retry = 2 ; task -> tk_cred_retry = 2 ; task -> tk_priority = task_setup_data -> priority - RPC_PRIORITY_LOW ; task -> tk_owner = current -> tgid ; task -> tk_workqueue = task_setup_data -> workqueue ; if ( task -> tk_ops -> rpc_call_prepare != NULL ) task -> tk_action = rpc_prepare_task ; task -> tk_start = ktime_get ( ) ; dprintk ( ""RPC:newtaskinitialized,procpid%u\\n"" , task_pid_nr ( current ) ) ; } "," ; task -> tk_rebind_retry = 2 ; task -> ",torvalds@linux/0b760113a3a155269a3fba93a409c640031dd68f,CVE-2011-2491,https://github.com/torvalds/linux/commit/0b760113a3a155269a3fba93a409c640031dd68f,2013-03-01T12:37Z 79,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 80,CWE-476,"CWE-476 void build_ntlmssp_negotiate_blob ( unsigned char * pbuffer , struct cifs_ses * ses ) { NEGOTIATE_MESSAGE * sec_blob = ( NEGOTIATE_MESSAGE * ) pbuffer ; __u32 flags ; memset ( pbuffer , 0 , sizeof ( NEGOTIATE_MESSAGE ) ) ; memcpy ( sec_blob -> Signature , NTLMSSP_SIGNATURE , 8 ) ; sec_blob -> MessageType = NtLmNegotiate ; flags = NTLMSSP_NEGOTIATE_56 | NTLMSSP_REQUEST_TARGET | 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 ; } sec_blob -> NegotiateFlags = cpu_to_le32 ( flags ) ; sec_blob -> WorkstationName . BufferOffset = 0 ; sec_blob -> WorkstationName . Length = 0 ; sec_blob -> WorkstationName . MaximumLength = 0 ; sec_blob -> DomainName . BufferOffset = 0 ; sec_blob -> DomainName . Length = 0 ; sec_blob -> DomainName . MaximumLength = 0 ; } "," NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_EXTENDED_SEC | NTLMSSP_NEGOTIATE_SEAL -> sign ) flags |= NTLMSSP_NEGOTIATE_SIGN |= NTLMSSP_NEGOTIATE_KEY_XCH ; sec_blob -> NegotiateFlags ",torvalds@linux/cabfb3680f78981d26c078a26e5c748531257ebb,CVE-2018-1066,https://github.com/torvalds/linux/commit/cabfb3680f78981d26c078a26e5c748531257ebb,2018-03-02T08:29Z 81,CWE-119,"CWE-119 static int vp8_rd_pick_best_mbsegmentation ( VP8_COMP * cpi , MACROBLOCK * x , int_mv * best_ref_mv , int best_rd , int * mdcounts , int * returntotrate , int * returnyrate , int * returndistortion , int mvthresh ) { int i ; BEST_SEG_INFO bsi ; vpx_memset ( & bsi , 0 , sizeof ( bsi ) ) ; bsi . segment_rd = best_rd ; bsi . ref_mv = best_ref_mv ; bsi . mvp . as_int = best_ref_mv -> as_int ; bsi . mvthresh = mvthresh ; bsi . mdcounts = mdcounts ; for ( i = 0 ; i < 16 ; i ++ ) { bsi . modes [ i ] = ZERO4X4 ; } if ( cpi -> compressor_speed == 0 ) { rd_check_segment ( cpi , x , & bsi , BLOCK_16X8 ) ; rd_check_segment ( cpi , x , & bsi , BLOCK_8X16 ) ; rd_check_segment ( cpi , x , & bsi , BLOCK_8X8 ) ; rd_check_segment ( cpi , x , & bsi , BLOCK_4X4 ) ; } else { int sr ; rd_check_segment ( cpi , x , & bsi , BLOCK_8X8 ) ; if ( bsi . segment_rd < best_rd ) { 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 ( 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 ; bsi . sv_mvp [ 0 ] . as_int = bsi . mvs [ 0 ] . as_int ; bsi . sv_mvp [ 1 ] . as_int = bsi . mvs [ 2 ] . as_int ; bsi . sv_mvp [ 2 ] . as_int = bsi . mvs [ 8 ] . as_int ; bsi . sv_mvp [ 3 ] . as_int = bsi . mvs [ 10 ] . as_int ; { sr = MAXF ( ( abs ( bsi . sv_mvp [ 0 ] . as_mv . row - bsi . sv_mvp [ 2 ] . as_mv . row ) ) >> 3 , ( abs ( bsi . sv_mvp [ 0 ] . as_mv . col - bsi . sv_mvp [ 2 ] . as_mv . col ) ) >> 3 ) ; vp8_cal_step_param ( sr , & bsi . sv_istep [ 0 ] ) ; sr = MAXF ( ( abs ( bsi . sv_mvp [ 1 ] . as_mv . row - bsi . sv_mvp [ 3 ] . as_mv . row ) ) >> 3 , ( abs ( bsi . sv_mvp [ 1 ] . as_mv . col - bsi . sv_mvp [ 3 ] . as_mv . col ) ) >> 3 ) ; vp8_cal_step_param ( sr , & bsi . sv_istep [ 1 ] ) ; rd_check_segment ( cpi , x , & bsi , BLOCK_8X16 ) ; } { sr = MAXF ( ( abs ( bsi . sv_mvp [ 0 ] . as_mv . row - bsi . sv_mvp [ 1 ] . as_mv . row ) ) >> 3 , ( abs ( bsi . sv_mvp [ 0 ] . as_mv . col - bsi . sv_mvp [ 1 ] . as_mv . col ) ) >> 3 ) ; vp8_cal_step_param ( sr , & bsi . sv_istep [ 0 ] ) ; sr = MAXF ( ( abs ( bsi . sv_mvp [ 2 ] . as_mv . row - bsi . sv_mvp [ 3 ] . as_mv . row ) ) >> 3 , ( abs ( bsi . sv_mvp [ 2 ] . as_mv . col - bsi . sv_mvp [ 3 ] . as_mv . col ) ) >> 3 ) ; vp8_cal_step_param ( sr , & bsi . sv_istep [ 1 ] ) ; rd_check_segment ( cpi , x , & bsi , BLOCK_16X8 ) ; } if ( cpi -> sf . no_skip_block4x4_search || bsi . segment_num == BLOCK_8X8 ) { bsi . mvp . as_int = bsi . sv_mvp [ 0 ] . as_int ; rd_check_segment ( cpi , x , & bsi , BLOCK_4X4 ) ; } 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 ; } } for ( i = 0 ; i < 16 ; i ++ ) { BLOCKD * bd = & x -> e_mbd . block [ i ] ; bd -> bmi . mv . as_int = bsi . mvs [ i ] . as_int ; * bd -> eob = bsi . eobs [ i ] ; } * returntotrate = bsi . r ; * returndistortion = bsi . d ; * returnyrate = bsi . segment_yrate ; x -> e_mbd . mode_info_context -> mbmi . partitioning = bsi . segment_num ; x -> partition_info -> count = vp8_mbsplit_count [ bsi . segment_num ] ; for ( i = 0 ; i < x -> partition_info -> count ; i ++ ) { int j ; j = vp8_mbsplit_offset [ bsi . segment_num ] [ i ] ; x -> partition_info -> bmi [ i ] . mode = bsi . modes [ j ] ; x -> partition_info -> bmi [ i ] . mv . as_mv = bsi . mvs [ j ] . as_mv ; } x -> partition_info -> bmi [ 15 ] . mv . as_int = bsi . mvs [ 15 ] . as_int ; return bsi . segment_rd ; } "," BEST_SEG_INFO bsi ; memset ( & bsi ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 82,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 83,CWE-399,"CWE-399 static long vhost_net_set_backend ( struct vhost_net * n , unsigned index , int fd ) { struct socket * sock , * oldsock ; struct vhost_virtqueue * vq ; struct vhost_net_virtqueue * nvq ; struct vhost_net_ubuf_ref * ubufs , * oldubufs = NULL ; int r ; mutex_lock ( & n -> dev . mutex ) ; r = vhost_dev_check_owner ( & n -> dev ) ; if ( r ) goto err ; if ( index >= VHOST_NET_VQ_MAX ) { r = - ENOBUFS ; goto err ; } vq = & n -> vqs [ index ] . vq ; nvq = & n -> vqs [ index ] ; mutex_lock ( & vq -> mutex ) ; if ( ! vhost_vq_access_ok ( vq ) ) { r = - EFAULT ; goto err_vq ; } sock = get_socket ( fd ) ; if ( IS_ERR ( sock ) ) { r = PTR_ERR ( sock ) ; goto err_vq ; } oldsock = rcu_dereference_protected ( vq -> private_data , lockdep_is_held ( & vq -> mutex ) ) ; if ( sock != oldsock ) { ubufs = vhost_net_ubuf_alloc ( vq , sock && vhost_sock_zcopy ( sock ) ) ; if ( IS_ERR ( ubufs ) ) { r = PTR_ERR ( ubufs ) ; goto err_ubufs ; } vhost_net_disable_vq ( n , vq ) ; rcu_assign_pointer ( vq -> private_data , sock ) ; r = vhost_init_used ( vq ) ; if ( r ) goto err_used ; r = vhost_net_enable_vq ( n , vq ) ; if ( r ) goto err_used ; oldubufs = nvq -> ubufs ; nvq -> ubufs = ubufs ; n -> tx_packets = 0 ; n -> tx_zcopy_err = 0 ; n -> tx_flush = false ; } mutex_unlock ( & vq -> mutex ) ; if ( oldubufs ) { vhost_net_ubuf_put_and_wait ( oldubufs ) ; mutex_lock ( & vq -> mutex ) ; vhost_zerocopy_signal_used ( n , vq ) ; mutex_unlock ( & vq -> mutex ) ; } if ( oldsock ) { vhost_net_flush_vq ( n , index ) ; fput ( oldsock -> file ) ; } mutex_unlock ( & n -> dev . mutex ) ; return 0 ; err_used : rcu_assign_pointer ( vq -> private_data , oldsock ) ; vhost_net_enable_vq ( n , vq ) ; if ( ubufs ) vhost_net_ubuf_put_and_wait ( ubufs ) ; err_ubufs : fput ( sock -> file ) ; err_vq : mutex_unlock ( & vq -> mutex ) ; err : mutex_unlock ( & n -> dev . mutex ) ; return r ; } "," oldubufs ) { vhost_net_ubuf_put_wait_and_free ( oldubufs ) ( ubufs ) vhost_net_ubuf_put_wait_and_free ( ubufs ) ",torvalds@linux/dd7633ecd553a5e304d349aa6f8eb8a0417098c5,CVE-2013-4127,https://github.com/torvalds/linux/commit/dd7633ecd553a5e304d349aa6f8eb8a0417098c5,2013-07-29T13:59Z 84,CWE-119,"CWE-119 int kvm_set_msr_common ( struct kvm_vcpu * vcpu , struct msr_data * msr_info ) { bool pr = false ; u32 msr = msr_info -> index ; u64 data = msr_info -> data ; switch ( msr ) { case MSR_AMD64_NB_CFG : case MSR_IA32_UCODE_REV : case MSR_IA32_UCODE_WRITE : case MSR_VM_HSAVE_PA : case MSR_AMD64_PATCH_LOADER : case MSR_AMD64_BU_CFG2 : break ; case MSR_EFER : return set_efer ( vcpu , data ) ; case MSR_K7_HWCR : data &= ~ ( u64 ) 0x40 ; data &= ~ ( u64 ) 0x100 ; data &= ~ ( u64 ) 0x8 ; if ( data != 0 ) { vcpu_unimpl ( vcpu , ""unimplementedHWCRwrmsr:0x%llx\\n"" , data ) ; return 1 ; } break ; case MSR_FAM10H_MMIO_CONF_BASE : if ( data != 0 ) { vcpu_unimpl ( vcpu , ""unimplementedMMIO_CONF_BASEwrmsr:"" ""0x%llx\\n"" , data ) ; return 1 ; } break ; case MSR_IA32_DEBUGCTLMSR : if ( ! data ) { break ; } else if ( data & ~ ( DEBUGCTLMSR_LBR | DEBUGCTLMSR_BTF ) ) { return 1 ; } vcpu_unimpl ( vcpu , ""%s:MSR_IA32_DEBUGCTLMSR0x%llx,nop\\n"" , __func__ , data ) ; break ; case 0x200 ... 0x2ff : return set_msr_mtrr ( vcpu , msr , data ) ; case MSR_IA32_APICBASE : kvm_set_apic_base ( vcpu , data ) ; break ; case APIC_BASE_MSR ... APIC_BASE_MSR + 0x3ff : return kvm_x2apic_msr_write ( vcpu , msr , data ) ; case MSR_IA32_TSCDEADLINE : kvm_set_lapic_tscdeadline_msr ( vcpu , data ) ; break ; case MSR_IA32_TSC_ADJUST : if ( guest_cpuid_has_tsc_adjust ( vcpu ) ) { if ( ! msr_info -> host_initiated ) { u64 adj = data - vcpu -> arch . ia32_tsc_adjust_msr ; kvm_x86_ops -> adjust_tsc_offset ( vcpu , adj , true ) ; } vcpu -> arch . ia32_tsc_adjust_msr = data ; } break ; case MSR_IA32_MISC_ENABLE : vcpu -> arch . ia32_misc_enable_msr = data ; break ; case MSR_KVM_WALL_CLOCK_NEW : case MSR_KVM_WALL_CLOCK : vcpu -> kvm -> arch . wall_clock = data ; kvm_write_wall_clock ( vcpu -> kvm , data ) ; break ; case MSR_KVM_SYSTEM_TIME_NEW : case MSR_KVM_SYSTEM_TIME : { kvmclock_reset ( vcpu ) ; vcpu -> arch . time = data ; kvm_make_request ( KVM_REQ_CLOCK_UPDATE , vcpu ) ; if ( ! ( data & 1 ) ) break ; vcpu -> arch . time_offset = data & ~ ( PAGE_MASK | 1 ) ; vcpu -> arch . time_page = gfn_to_page ( vcpu -> kvm , data >> PAGE_SHIFT ) ; if ( is_error_page ( vcpu -> arch . time_page ) ) vcpu -> arch . time_page = NULL ; break ; } case MSR_KVM_ASYNC_PF_EN : if ( kvm_pv_enable_async_pf ( vcpu , data ) ) return 1 ; break ; case MSR_KVM_STEAL_TIME : if ( unlikely ( ! sched_info_on ( ) ) ) return 1 ; if ( data & KVM_STEAL_RESERVED_MASK ) return 1 ; if ( kvm_gfn_to_hva_cache_init ( vcpu -> kvm , & vcpu -> arch . st . stime , data & KVM_STEAL_VALID_BITS ) ) return 1 ; vcpu -> arch . st . msr_val = data ; if ( ! ( data & KVM_MSR_ENABLED ) ) break ; vcpu -> arch . st . last_steal = current -> sched_info . run_delay ; preempt_disable ( ) ; accumulate_steal_time ( vcpu ) ; preempt_enable ( ) ; kvm_make_request ( KVM_REQ_STEAL_UPDATE , vcpu ) ; break ; case MSR_KVM_PV_EOI_EN : if ( kvm_lapic_enable_pv_eoi ( vcpu , data ) ) return 1 ; break ; case MSR_IA32_MCG_CTL : case MSR_IA32_MCG_STATUS : case MSR_IA32_MC0_CTL ... MSR_IA32_MC0_CTL + 4 * KVM_MAX_MCE_BANKS - 1 : return set_msr_mce ( vcpu , msr , data ) ; case MSR_K7_EVNTSEL0 : case MSR_K7_EVNTSEL1 : case MSR_K7_EVNTSEL2 : case MSR_K7_EVNTSEL3 : if ( data != 0 ) vcpu_unimpl ( vcpu , ""unimplementedperfctrwrmsr:"" ""0x%xdata0x%llx\\n"" , msr , data ) ; break ; case MSR_K7_PERFCTR0 : case MSR_K7_PERFCTR1 : case MSR_K7_PERFCTR2 : case MSR_K7_PERFCTR3 : vcpu_unimpl ( vcpu , ""unimplementedperfctrwrmsr:"" ""0x%xdata0x%llx\\n"" , msr , data ) ; break ; case MSR_P6_PERFCTR0 : case MSR_P6_PERFCTR1 : pr = true ; case MSR_P6_EVNTSEL0 : case MSR_P6_EVNTSEL1 : if ( kvm_pmu_msr ( vcpu , msr ) ) return kvm_pmu_set_msr ( vcpu , msr , data ) ; if ( pr || data != 0 ) vcpu_unimpl ( vcpu , ""disabledperfctrwrmsr:"" ""0x%xdata0x%llx\\n"" , msr , data ) ; break ; case MSR_K7_CLK_CTL : break ; case HV_X64_MSR_GUEST_OS_ID ... HV_X64_MSR_SINT15 : if ( kvm_hv_msr_partition_wide ( msr ) ) { int r ; mutex_lock ( & vcpu -> kvm -> lock ) ; r = set_msr_hyperv_pw ( vcpu , msr , data ) ; mutex_unlock ( & vcpu -> kvm -> lock ) ; return r ; } else return set_msr_hyperv ( vcpu , msr , data ) ; break ; case MSR_IA32_BBL_CR_CTL3 : vcpu_unimpl ( vcpu , ""ignoredwrmsr:0x%xdata%llx\\n"" , msr , data ) ; break ; case MSR_AMD64_OSVW_ID_LENGTH : if ( ! guest_cpuid_has_osvw ( vcpu ) ) return 1 ; vcpu -> arch . osvw . length = data ; break ; case MSR_AMD64_OSVW_STATUS : if ( ! guest_cpuid_has_osvw ( vcpu ) ) return 1 ; vcpu -> arch . osvw . status = data ; break ; default : if ( msr && ( msr == vcpu -> kvm -> arch . xen_hvm_config . msr ) ) return xen_hvm_config ( vcpu , data ) ; if ( kvm_pmu_msr ( vcpu , msr ) ) return kvm_pmu_set_msr ( vcpu , msr , data ) ; if ( ! ignore_msrs ) { vcpu_unimpl ( vcpu , ""unhandledwrmsr:0x%xdata%llx\\n"" , msr , data ) ; return 1 ; } else { vcpu_unimpl ( vcpu , ""ignoredwrmsr:0x%xdata%llx\\n"" , msr , data ) ; break ; } } return 0 ; } "," | 1 ) ; if ( vcpu -> arch . time_offset & ( sizeof ( struct pvclock_vcpu_time_info ) - 1 ) ) break ",torvalds@linux/c300aa64ddf57d9c5d9c898a64b36877345dd4a9,CVE-2013-1796,https://github.com/torvalds/linux/commit/c300aa64ddf57d9c5d9c898a64b36877345dd4a9,2013-03-22T11:59Z 85,CWE-119,"CWE-119 void vp8_alloc_compressor_data ( VP8_COMP * cpi ) { VP8_COMMON * cm = & cpi -> common ; int width = cm -> Width ; int height = cm -> Height ; if ( vp8_alloc_frame_buffers ( cm , width , height ) ) vpx_internal_error ( & cpi -> common . error , VPX_CODEC_MEM_ERROR , ""Failedtoallocateframebuffers"" ) ; if ( vp8_alloc_partition_data ( cpi ) ) vpx_internal_error ( & cpi -> common . error , VPX_CODEC_MEM_ERROR , ""Failedtoallocatepartitiondata"" ) ; if ( ( width & 0xf ) != 0 ) width += 16 - ( width & 0xf ) ; if ( ( height & 0xf ) != 0 ) height += 16 - ( height & 0xf ) ; if ( vp8_yv12_alloc_frame_buffer ( & cpi -> pick_lf_lvl_frame , width , height , VP8BORDERINPIXELS ) ) vpx_internal_error ( & cpi -> common . error , VPX_CODEC_MEM_ERROR , ""Failedtoallocatelastframebuffer"" ) ; if ( vp8_yv12_alloc_frame_buffer ( & cpi -> scaled_source , width , height , VP8BORDERINPIXELS ) ) vpx_internal_error ( & cpi -> common . error , VPX_CODEC_MEM_ERROR , ""Failedtoallocatescaledsourcebuffer"" ) ; vpx_free ( cpi -> tok ) ; { # if CONFIG_REALTIME_ONLY & CONFIG_ONTHEFLY_BITPACKING unsigned int tokens = 8 * 24 * 16 ; # else unsigned int tokens = cm -> mb_rows * cm -> mb_cols * 24 * 16 ; # endif CHECK_MEM_ERROR ( cpi -> tok , vpx_calloc ( tokens , sizeof ( * cpi -> tok ) ) ) ; } cpi -> zeromv_count = 0 ; vpx_free ( cpi -> gf_active_flags ) ; CHECK_MEM_ERROR ( cpi -> gf_active_flags , vpx_calloc ( sizeof ( * cpi -> gf_active_flags ) , cm -> mb_rows * cm -> mb_cols ) ) ; cpi -> gf_active_count = cm -> mb_rows * cm -> mb_cols ; vpx_free ( cpi -> mb_activity_map ) ; CHECK_MEM_ERROR ( cpi -> mb_activity_map , vpx_calloc ( sizeof ( * cpi -> mb_activity_map ) , cm -> mb_rows * cm -> mb_cols ) ) ; vpx_free ( cpi -> lfmv ) ; CHECK_MEM_ERROR ( cpi -> lfmv , vpx_calloc ( ( cm -> mb_rows + 2 ) * ( cm -> mb_cols + 2 ) , sizeof ( * cpi -> lfmv ) ) ) ; vpx_free ( cpi -> lf_ref_frame_sign_bias ) ; CHECK_MEM_ERROR ( cpi -> lf_ref_frame_sign_bias , vpx_calloc ( ( cm -> mb_rows + 2 ) * ( cm -> mb_cols + 2 ) , sizeof ( * cpi -> lf_ref_frame_sign_bias ) ) ) ; vpx_free ( cpi -> lf_ref_frame ) ; CHECK_MEM_ERROR ( cpi -> lf_ref_frame , vpx_calloc ( ( cm -> mb_rows + 2 ) * ( cm -> mb_cols + 2 ) , sizeof ( * cpi -> lf_ref_frame ) ) ) ; vpx_free ( cpi -> segmentation_map ) ; CHECK_MEM_ERROR ( cpi -> segmentation_map , vpx_calloc ( cm -> mb_rows * cm -> mb_cols , sizeof ( * cpi -> segmentation_map ) ) ) ; cpi -> cyclic_refresh_mode_index = 0 ; vpx_free ( cpi -> active_map ) ; CHECK_MEM_ERROR ( cpi -> active_map , vpx_calloc ( cm -> mb_rows * cm -> mb_cols , sizeof ( * cpi -> active_map ) ) ) ; vpx_memset ( cpi -> active_map , 1 , ( cm -> mb_rows * cm -> mb_cols ) ) ; # if CONFIG_MULTITHREAD if ( width < 640 ) cpi -> mt_sync_range = 1 ; else if ( width <= 1280 ) cpi -> mt_sync_range = 4 ; else if ( width <= 2560 ) cpi -> mt_sync_range = 8 ; else cpi -> mt_sync_range = 16 ; if ( cpi -> oxcf . multi_threaded > 1 ) { vpx_free ( cpi -> mt_current_mb_col ) ; CHECK_MEM_ERROR ( cpi -> mt_current_mb_col , vpx_malloc ( sizeof ( * cpi -> mt_current_mb_col ) * cm -> mb_rows ) ) ; } # endif vpx_free ( cpi -> tplist ) ; CHECK_MEM_ERROR ( cpi -> tplist , vpx_malloc ( sizeof ( TOKENLIST ) * cm -> mb_rows ) ) ; } "," ) ) ; memset ( cpi -> ) ) ; # if CONFIG_TEMPORAL_DENOISING if ( cpi -> oxcf . noise_sensitivity > 0 ) { vp8_denoiser_free ( & cpi -> denoiser ) ; vp8_denoiser_allocate ( & cpi -> denoiser , width , height , cm -> mb_rows , cm -> mb_cols , cpi -> oxcf . noise_sensitivity ) ; } # endif ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 86,CWE-000,"CWE-000 static int jpc_dec_tiledecode ( jpc_dec_t * dec , jpc_dec_tile_t * tile ) { int i ; int j ; jpc_dec_tcomp_t * tcomp ; jpc_dec_rlvl_t * rlvl ; jpc_dec_band_t * band ; int compno ; int rlvlno ; int bandno ; int adjust ; int v ; jpc_dec_ccp_t * ccp ; jpc_dec_cmpt_t * cmpt ; if ( jpc_dec_decodecblks ( dec , tile ) ) { jas_eprintf ( ""jpc_dec_decodecblksfailed\\n"" ) ; return - 1 ; } for ( compno = 0 , tcomp = tile -> tcomps ; compno < dec -> numcomps ; ++ compno , ++ tcomp ) { ccp = & tile -> cp -> ccps [ compno ] ; for ( rlvlno = 0 , rlvl = tcomp -> rlvls ; rlvlno < tcomp -> numrlvls ; ++ rlvlno , ++ rlvl ) { if ( ! rlvl -> bands ) { continue ; } for ( bandno = 0 , band = rlvl -> bands ; bandno < rlvl -> numbands ; ++ bandno , ++ band ) { if ( ! band -> data ) { continue ; } jpc_undo_roi ( band -> data , band -> roishift , ccp -> roishift - band -> roishift , band -> numbps ) ; if ( tile -> realmode ) { jas_matrix_asl ( band -> data , JPC_FIX_FRACBITS ) ; jpc_dequantize ( band -> data , band -> absstepsize ) ; } } } } for ( compno = 0 , tcomp = tile -> tcomps ; compno < dec -> numcomps ; ++ compno , ++ tcomp ) { ccp = & tile -> cp -> ccps [ compno ] ; jpc_tsfb_synthesize ( tcomp -> tsfb , tcomp -> data ) ; } switch ( tile -> cp -> mctid ) { case JPC_MCT_RCT : if ( dec -> numcomps < 3 ) { jas_eprintf ( ""RCTrequiresatleastthreecomponents\\n"" ) ; return - 1 ; } jpc_irct ( tile -> tcomps [ 0 ] . data , tile -> tcomps [ 1 ] . data , tile -> tcomps [ 2 ] . data ) ; break ; case JPC_MCT_ICT : if ( dec -> numcomps < 3 ) { jas_eprintf ( ""ICTrequiresatleastthreecomponents\\n"" ) ; return - 1 ; } jpc_iict ( tile -> tcomps [ 0 ] . data , tile -> tcomps [ 1 ] . data , tile -> tcomps [ 2 ] . data ) ; break ; } if ( tile -> realmode ) { for ( compno = 0 , tcomp = tile -> tcomps ; compno < dec -> numcomps ; ++ compno , ++ tcomp ) { for ( i = 0 ; i < jas_matrix_numrows ( tcomp -> data ) ; ++ i ) { for ( j = 0 ; j < jas_matrix_numcols ( tcomp -> data ) ; ++ j ) { v = jas_matrix_get ( tcomp -> data , i , j ) ; v = jpc_fix_round ( v ) ; jas_matrix_set ( tcomp -> data , i , j , jpc_fixtoint ( v ) ) ; } } } } for ( compno = 0 , tcomp = tile -> tcomps , cmpt = dec -> cmpts ; compno < dec -> numcomps ; ++ compno , ++ tcomp , ++ cmpt ) { adjust = cmpt -> sgnd ? 0 : ( 1 << ( cmpt -> prec - 1 ) ) ; for ( i = 0 ; i < jas_matrix_numrows ( tcomp -> data ) ; ++ i ) { for ( j = 0 ; j < jas_matrix_numcols ( tcomp -> data ) ; ++ j ) { * jas_matrix_getref ( tcomp -> data , i , j ) += adjust ; } } } for ( compno = 0 , tcomp = tile -> tcomps , cmpt = dec -> cmpts ; compno < dec -> numcomps ; ++ compno , ++ tcomp , ++ cmpt ) { jpc_fix_t mn ; jpc_fix_t mx ; mn = cmpt -> sgnd ? ( - ( 1 << ( cmpt -> prec - 1 ) ) ) : ( 0 ) ; mx = cmpt -> sgnd ? ( ( 1 << ( cmpt -> prec - 1 ) ) - 1 ) : ( ( 1 << cmpt -> prec ) - 1 ) ; jas_matrix_clip ( tcomp -> data , mn , mx ) ; } for ( compno = 0 , tcomp = tile -> tcomps , cmpt = dec -> cmpts ; compno < dec -> numcomps ; ++ compno , ++ tcomp , ++ cmpt ) { if ( jas_image_writecmpt ( dec -> image , compno , tcomp -> xstart - JPC_CEILDIV ( dec -> xstart , cmpt -> hstep ) , tcomp -> ystart - JPC_CEILDIV ( dec -> ystart , cmpt -> vstep ) , jas_matrix_numcols ( tcomp -> data ) , jas_matrix_numrows ( tcomp -> data ) , tcomp -> data ) ) { jas_eprintf ( ""writecomponentfailed\\n"" ) ; return - 1 ; } } return 0 ; } "," jas_eprintf ( ""RCTrequiresatleastthreecomponents\\n"" ) ; return - 1 ; } if ( ! jas_image_cmpt_domains_same ( dec -> image ) ) { jas_eprintf ( ""RCTrequiresallcomponentshavethesamedomain\\n"" 1 ; } if ( ! jas_image_cmpt_domains_same ( dec -> image ) ) { jas_eprintf ( ""RCTrequiresallcomponentshavethesamedomain\\n"" ) ; return - 1 ; } ",mdadams@jasper/dee11ec440d7908d1daf69f40a3324b27cf213ba,CVE-2016-9389,https://github.com/mdadams/jasper/commit/dee11ec440d7908d1daf69f40a3324b27cf213ba,2017-03-23T18:59Z 87,CWE-20,"CWE-20 void Bezier ( double x1 , double y1 , double x2 , double y2 , double x3 , double y3 ) { outpos += sprintf ( outpos , ""\\n%12.3f%12.3f%12.3f%12.3f%12.3f%12.3fc"" , x1 , y1 , x2 , y2 , x3 , y3 ) ; } "," y3 ) { sprintf ( outputbuffer , ""\\n%12.3f%12.3f%12.3f%12.3f%12.3f%12.3fc"" , y3 ) ; sendClean ( outputbuffer ) ; ",TeX-Live@texlive-source/9216833a3888a4105a18e8c349f65b045ddb1079,CVE-2019-18604,https://github.com/TeX-Live/texlive-source/commit/9216833a3888a4105a18e8c349f65b045ddb1079,2019-10-29T19:15Z 88,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 89,CWE-125,"CWE-125 static const char * parse_string ( cJSON * item , const char * str , const char * * ep ) { const char * ptr = str + 1 , * end_ptr = str + 1 ; char * ptr2 ; char * out ; int len = 0 ; unsigned uc , uc2 ; if ( * str != \'\\""\' ) { * ep = str ; return 0 ; } while ( * end_ptr != \'\\""\' && * end_ptr && ++ len ) if ( * end_ptr ++ == '\\\\' ) end_ptr ++ ; out = ( char * ) cJSON_malloc ( len + 1 ) ; if ( ! out ) return 0 ; item -> valuestring = out ; item -> type = cJSON_String ; ptr = str + 1 ; ptr2 = out ; while ( ptr < end_ptr ) { if ( * ptr != '\\\\' ) * ptr2 ++ = * ptr ++ ; else { ptr ++ ; switch ( * ptr ) { case 'b' : * ptr2 ++ = '\\b' ; break ; case 'f' : * ptr2 ++ = '\\f' ; break ; case 'n' : * ptr2 ++ = '\\n' ; break ; case 'r' : * ptr2 ++ = '\\r' ; break ; case 't' : * ptr2 ++ = '\\t' ; break ; case 'u' : uc = parse_hex4 ( ptr + 1 ) ; ptr += 4 ; if ( ptr >= end_ptr ) { * ep = str ; return 0 ; } if ( ( uc >= 0xDC00 && uc <= 0xDFFF ) || uc == 0 ) { * ep = str ; return 0 ; } if ( uc >= 0xD800 && uc <= 0xDBFF ) { if ( ptr + 6 > end_ptr ) { * ep = str ; return 0 ; } if ( ptr [ 1 ] != '\\\\' || ptr [ 2 ] != 'u' ) { * ep = str ; return 0 ; } uc2 = parse_hex4 ( ptr + 3 ) ; ptr += 6 ; if ( uc2 < 0xDC00 || uc2 > 0xDFFF ) { * ep = str ; return 0 ; } uc = 0x10000 + ( ( ( uc & 0x3FF ) << 10 ) | ( uc2 & 0x3FF ) ) ; } len = 4 ; if ( uc < 0x80 ) len = 1 ; else if ( uc < 0x800 ) len = 2 ; else if ( uc < 0x10000 ) len = 3 ; ptr2 += len ; switch ( len ) { case 4 : * -- ptr2 = ( ( uc | 0x80 ) & 0xBF ) ; uc >>= 6 ; case 3 : * -- ptr2 = ( ( uc | 0x80 ) & 0xBF ) ; uc >>= 6 ; case 2 : * -- ptr2 = ( ( uc | 0x80 ) & 0xBF ) ; uc >>= 6 ; case 1 : * -- ptr2 = ( uc | firstByteMark [ len ] ) ; } ptr2 += len ; break ; default : * ptr2 ++ = * ptr ; break ; } ptr ++ ; } } * ptr2 = 0 ; if ( * ptr == \'\\""\' ) ptr ++ ; return ptr ; } "," ++ len ) { == '\\\\' ) { if ( * end_ptr == '\\0' ) { return 0 ; } end_ptr ++ ; } } out = ( ",DaveGamble@cJSON/94df772485c92866ca417d92137747b2e3b0a917,CVE-2016-10749,https://github.com/DaveGamble/cJSON/commit/94df772485c92866ca417d92137747b2e3b0a917,2019-04-29T14:29Z 90,CWE-835,"CWE-835 ssize_t tcp_splice_read ( struct socket * sock , loff_t * ppos , struct pipe_inode_info * pipe , size_t len , unsigned int flags ) { struct sock * sk = sock -> sk ; struct tcp_splice_state tss = { . pipe = pipe , . len = len , . flags = flags , } ; long timeo ; ssize_t spliced ; int ret ; sock_rps_record_flow ( sk ) ; if ( unlikely ( * ppos ) ) return - ESPIPE ; ret = spliced = 0 ; lock_sock ( sk ) ; timeo = sock_rcvtimeo ( sk , sock -> file -> f_flags & O_NONBLOCK ) ; while ( tss . len ) { ret = __tcp_splice_read ( sk , & tss ) ; if ( ret < 0 ) break ; else if ( ! ret ) { if ( spliced ) break ; if ( sock_flag ( sk , SOCK_DONE ) ) break ; if ( sk -> sk_err ) { ret = sock_error ( sk ) ; break ; } if ( sk -> sk_shutdown & RCV_SHUTDOWN ) break ; if ( sk -> sk_state == TCP_CLOSE ) { if ( ! sock_flag ( sk , SOCK_DONE ) ) ret = - ENOTCONN ; break ; } if ( ! timeo ) { ret = - EAGAIN ; break ; } sk_wait_data ( sk , & timeo , NULL ) ; if ( signal_pending ( current ) ) { ret = sock_intr_errno ( timeo ) ; break ; } continue ; } tss . len -= ret ; spliced += ret ; if ( ! timeo ) break ; release_sock ( sk ) ; lock_sock ( sk ) ; if ( sk -> sk_err || sk -> sk_state == TCP_CLOSE || ( sk -> sk_shutdown & RCV_SHUTDOWN ) || signal_pending ( current ) ) break ; } release_sock ( sk ) ; if ( spliced ) return spliced ; return ret ; } "," break ; } if ( ! skb_queue_empty ( & sk -> sk_receive_queue ) ) break ; ",torvalds@linux/ccf7abb93af09ad0868ae9033d1ca8108bdaec82,CVE-2017-6214,https://github.com/torvalds/linux/commit/ccf7abb93af09ad0868ae9033d1ca8108bdaec82,2017-02-23T17:59Z 91,CWE-264,"CWE-264 bool inode_owner_or_capable ( const struct inode * inode ) { if ( uid_eq ( current_fsuid ( ) , inode -> i_uid ) ) return true ; if ( inode_capable ( inode , CAP_FOWNER ) ) return true ; return false ; } "," inode ) { struct user_namespace * ns ; return true ; ns = current_user_ns ( ) ; if ( ns_capable ( ns , CAP_FOWNER ) && kuid_has_mapping ( ns , inode -> i_uid ) ) return ",torvalds@linux/23adbe12ef7d3d4195e80800ab36b37bee28cd03,CVE-2014-4014,https://github.com/torvalds/linux/commit/23adbe12ef7d3d4195e80800ab36b37bee28cd03,2014-06-23T11:21Z 92,CWE-269,"CWE-269 long FS_FOpenFileRead ( const char * filename , fileHandle_t * file , qboolean uniqueFILE ) { searchpath_t * search ; long len ; if ( ! fs_searchpaths ) Com_Error ( ERR_FATAL , ""Filesystemcallmadewithoutinitialization"" ) ; for ( search = fs_searchpaths ; search ; search = search -> next ) { len = FS_FOpenFileReadDir ( filename , search , file , uniqueFILE , qfalse ) ; if ( file == NULL ) { if ( len > 0 ) return len ; } else { if ( len >= 0 && * file ) return len ; } } # ifdef FS_MISSING if ( missingFiles ) fprintf ( missingFiles , ""%s\\n"" , filename ) ; # endif if ( file ) { * file = 0 ; return - 1 ; } else { return 0 ; } } "," long len ; qboolean isLocalConfig ; ""Filesystemcallmadewithoutinitialization"" ) ; isLocalConfig = ! strcmp ( filename , ""autoexec.cfg"" ) || ! strcmp ( filename , Q3CONFIG_CFG ) ; next ) { if ( isLocalConfig && search -> pack ) continue ; ",ioquake@ioq3/376267d534476a875d8b9228149c4ee18b74a4fd,CVE-2017-6903,https://github.com/ioquake/ioq3/commit/376267d534476a875d8b9228149c4ee18b74a4fd,2017-03-14T22:59Z 93,CWE-119,"CWE-119 static void write_profile ( BITSTREAM_PROFILE profile , struct vp9_write_bit_buffer * wb ) { assert ( profile < MAX_PROFILES ) ; vp9_wb_write_bit ( wb , profile & 1 ) ; vp9_wb_write_bit ( wb , profile >> 1 ) ; } "," profile , struct vpx_write_bit_buffer * wb ) wb ) { switch ( profile ) { case PROFILE_0 : vpx_wb_write_literal ( wb , 0 , 2 ) ; break ; case PROFILE_1 : vpx_wb_write_literal ( wb , ( wb , 2 , 2 ) ; break ; case PROFILE_2 : vpx_wb_write_literal ( wb , ( wb , 1 , 2 ) ; break ; case PROFILE_3 : vpx_wb_write_literal ( wb , 6 , 3 ) ; break ; default : assert ( 0 ) ; } ) ; } } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 94,CWE-119,"CWE-119 static bool check_underflow ( const struct arpt_entry * e ) { const struct xt_entry_target * t ; unsigned int verdict ; if ( ! unconditional ( & e -> arp ) ) return false ; t = arpt_get_target_c ( e ) ; if ( strcmp ( t -> u . user . name , XT_STANDARD_TARGET ) != 0 ) return false ; verdict = ( ( struct xt_standard_target * ) t ) -> verdict ; verdict = - verdict - 1 ; return verdict == NF_DROP || verdict == NF_ACCEPT ; } "," ! unconditional ( e ) ) return ",torvalds@linux/54d83fc74aa9ec72794373cb47432c5f7fb1a309,CVE-2016-3134,https://github.com/torvalds/linux/commit/54d83fc74aa9ec72794373cb47432c5f7fb1a309,2016-04-27T17:59Z 95,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 96,CWE-119,"CWE-119 void IGDstartelt ( void * d , const char * name , int l ) { struct IGDdatas * datas = ( struct IGDdatas * ) d ; memcpy ( datas -> cureltname , name , l ) ; datas -> cureltname [ l ] = '\\0' ; datas -> level ++ ; if ( ( l == 7 ) && ! memcmp ( name , ""service"" , l ) ) { datas -> tmp . controlurl [ 0 ] = '\\0' ; datas -> tmp . eventsuburl [ 0 ] = '\\0' ; datas -> tmp . scpdurl [ 0 ] = '\\0' ; datas -> tmp . servicetype [ 0 ] = '\\0' ; } } "," * ) d ; if ( l >= MINIUPNPC_URL_MAXSIZE ) l = MINIUPNPC_URL_MAXSIZE - 1 ",miniupnp@miniupnp/79cca974a4c2ab1199786732a67ff6d898051b78,CVE-2015-6031,https://github.com/miniupnp/miniupnp/commit/79cca974a4c2ab1199786732a67ff6d898051b78,2015-11-02T19:59Z 97,CWE-125,"CWE-125 PyMODINIT_FUNC PyInit__ast ( void ) { PyObject * m , * d ; if ( ! init_types ( ) ) return NULL ; m = PyModule_Create ( & _astmodule ) ; if ( ! m ) return NULL ; d = PyModule_GetDict ( m ) ; if ( PyDict_SetItemString ( d , ""AST"" , ( PyObject * ) & AST_type ) < 0 ) return NULL ; if ( PyModule_AddIntMacro ( m , PyCF_ONLY_AST ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""mod"" , ( PyObject * ) mod_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Module"" , ( PyObject * ) Module_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Interactive"" , ( PyObject * ) Interactive_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Expression"" , ( PyObject * ) Expression_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Suite"" , ( PyObject * ) Suite_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""stmt"" , ( PyObject * ) stmt_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""FunctionDef"" , ( PyObject * ) FunctionDef_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""AsyncFunctionDef"" , ( PyObject * ) AsyncFunctionDef_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""ClassDef"" , ( PyObject * ) ClassDef_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Return"" , ( PyObject * ) Return_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Delete"" , ( PyObject * ) Delete_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Assign"" , ( PyObject * ) Assign_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""AugAssign"" , ( PyObject * ) AugAssign_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""AnnAssign"" , ( PyObject * ) AnnAssign_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""For"" , ( PyObject * ) For_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""AsyncFor"" , ( PyObject * ) AsyncFor_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""While"" , ( PyObject * ) While_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""If"" , ( PyObject * ) If_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""With"" , ( PyObject * ) With_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""AsyncWith"" , ( PyObject * ) AsyncWith_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Raise"" , ( PyObject * ) Raise_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Try"" , ( PyObject * ) Try_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Assert"" , ( PyObject * ) Assert_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Import"" , ( PyObject * ) Import_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""ImportFrom"" , ( PyObject * ) ImportFrom_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Global"" , ( PyObject * ) Global_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Nonlocal"" , ( PyObject * ) Nonlocal_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Expr"" , ( PyObject * ) Expr_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Pass"" , ( PyObject * ) Pass_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Break"" , ( PyObject * ) Break_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Continue"" , ( PyObject * ) Continue_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""expr"" , ( PyObject * ) expr_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""BoolOp"" , ( PyObject * ) BoolOp_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""NamedExpr"" , ( PyObject * ) NamedExpr_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""BinOp"" , ( PyObject * ) BinOp_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""UnaryOp"" , ( PyObject * ) UnaryOp_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Lambda"" , ( PyObject * ) Lambda_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""IfExp"" , ( PyObject * ) IfExp_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Dict"" , ( PyObject * ) Dict_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Set"" , ( PyObject * ) Set_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""ListComp"" , ( PyObject * ) ListComp_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""SetComp"" , ( PyObject * ) SetComp_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""DictComp"" , ( PyObject * ) DictComp_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""GeneratorExp"" , ( PyObject * ) GeneratorExp_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Await"" , ( PyObject * ) Await_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Yield"" , ( PyObject * ) Yield_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""YieldFrom"" , ( PyObject * ) YieldFrom_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Compare"" , ( PyObject * ) Compare_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Call"" , ( PyObject * ) Call_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""FormattedValue"" , ( PyObject * ) FormattedValue_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""JoinedStr"" , ( PyObject * ) JoinedStr_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Constant"" , ( PyObject * ) Constant_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Attribute"" , ( PyObject * ) Attribute_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Subscript"" , ( PyObject * ) Subscript_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Starred"" , ( PyObject * ) Starred_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Name"" , ( PyObject * ) Name_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""List"" , ( PyObject * ) List_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Tuple"" , ( PyObject * ) Tuple_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""expr_context"" , ( PyObject * ) expr_context_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Load"" , ( PyObject * ) Load_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Store"" , ( PyObject * ) Store_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Del"" , ( PyObject * ) Del_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""AugLoad"" , ( PyObject * ) AugLoad_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""AugStore"" , ( PyObject * ) AugStore_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Param"" , ( PyObject * ) Param_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""NamedStore"" , ( PyObject * ) NamedStore_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""slice"" , ( PyObject * ) slice_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Slice"" , ( PyObject * ) Slice_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""ExtSlice"" , ( PyObject * ) ExtSlice_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Index"" , ( PyObject * ) Index_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""boolop"" , ( PyObject * ) boolop_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""And"" , ( PyObject * ) And_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Or"" , ( PyObject * ) Or_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""operator"" , ( PyObject * ) operator_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Add"" , ( PyObject * ) Add_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Sub"" , ( PyObject * ) Sub_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Mult"" , ( PyObject * ) Mult_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""MatMult"" , ( PyObject * ) MatMult_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Div"" , ( PyObject * ) Div_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Mod"" , ( PyObject * ) Mod_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Pow"" , ( PyObject * ) Pow_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""LShift"" , ( PyObject * ) LShift_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""RShift"" , ( PyObject * ) RShift_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""BitOr"" , ( PyObject * ) BitOr_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""BitXor"" , ( PyObject * ) BitXor_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""BitAnd"" , ( PyObject * ) BitAnd_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""FloorDiv"" , ( PyObject * ) FloorDiv_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""unaryop"" , ( PyObject * ) unaryop_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Invert"" , ( PyObject * ) Invert_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Not"" , ( PyObject * ) Not_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""UAdd"" , ( PyObject * ) UAdd_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""USub"" , ( PyObject * ) USub_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""cmpop"" , ( PyObject * ) cmpop_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Eq"" , ( PyObject * ) Eq_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""NotEq"" , ( PyObject * ) NotEq_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Lt"" , ( PyObject * ) Lt_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""LtE"" , ( PyObject * ) LtE_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Gt"" , ( PyObject * ) Gt_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""GtE"" , ( PyObject * ) GtE_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Is"" , ( PyObject * ) Is_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""IsNot"" , ( PyObject * ) IsNot_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""In"" , ( PyObject * ) In_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""NotIn"" , ( PyObject * ) NotIn_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""comprehension"" , ( PyObject * ) comprehension_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""excepthandler"" , ( PyObject * ) excepthandler_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""ExceptHandler"" , ( PyObject * ) ExceptHandler_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""arguments"" , ( PyObject * ) arguments_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""arg"" , ( PyObject * ) arg_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""keyword"" , ( PyObject * ) keyword_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""alias"" , ( PyObject * ) alias_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""withitem"" , ( PyObject * ) withitem_type ) < 0 ) return NULL ; return m ; } "," ; if ( PyModule_AddIntMacro ( m , PyCF_TYPE_COMMENTS ) < 0 ) return NULL ; if ( ( d , ""FunctionType"" , ( PyObject * ) FunctionType_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , * ) withitem_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""type_ignore"" , ( PyObject * ) type_ignore_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""TypeIgnore"" , ( PyObject * ) TypeIgnore_type ",python@typed_ast/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,CVE-2019-19275,https://github.com/python/typed_ast/commit/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,2019-11-26T15:15Z 98,CWE-416,"CWE-416 static OPJ_BOOL opj_j2k_write_mco ( opj_j2k_t * p_j2k , struct opj_stream_private * p_stream , struct opj_event_mgr * p_manager ) { OPJ_BYTE * l_current_data = 00 ; OPJ_UINT32 l_mco_size ; opj_tcp_t * l_tcp = 00 ; opj_simple_mcc_decorrelation_data_t * l_mcc_record ; OPJ_UINT32 i ; assert ( p_j2k != 00 ) ; assert ( p_manager != 00 ) ; assert ( p_stream != 00 ) ; l_tcp = & ( p_j2k -> m_cp . tcps [ p_j2k -> m_current_tile_number ] ) ; l_current_data = p_j2k -> m_specific_param . m_encoder . m_header_tile_data ; l_mco_size = 5 + l_tcp -> m_nb_mcc_records ; if ( l_mco_size > p_j2k -> m_specific_param . m_encoder . m_header_tile_data_size ) { OPJ_BYTE * new_header_tile_data = ( OPJ_BYTE * ) opj_realloc ( p_j2k -> m_specific_param . m_encoder . m_header_tile_data , l_mco_size ) ; if ( ! new_header_tile_data ) { opj_free ( p_j2k -> m_specific_param . m_encoder . m_header_tile_data ) ; p_j2k -> m_specific_param . m_encoder . m_header_tile_data = NULL ; p_j2k -> m_specific_param . m_encoder . m_header_tile_data_size = 0 ; opj_event_msg ( p_manager , EVT_ERROR , ""NotenoughmemorytowriteMCOmarker\\n"" ) ; return OPJ_FALSE ; } p_j2k -> m_specific_param . m_encoder . m_header_tile_data = new_header_tile_data ; p_j2k -> m_specific_param . m_encoder . m_header_tile_data_size = l_mco_size ; } opj_write_bytes ( l_current_data , J2K_MS_MCO , 2 ) ; l_current_data += 2 ; opj_write_bytes ( l_current_data , l_mco_size - 2 , 2 ) ; l_current_data += 2 ; opj_write_bytes ( l_current_data , l_tcp -> m_nb_mcc_records , 1 ) ; ++ l_current_data ; l_mcc_record = l_tcp -> m_mcc_records ; for ( i = 0 ; i < l_tcp -> m_nb_mcc_records ; ++ i ) { opj_write_bytes ( l_current_data , l_mcc_record -> m_index , 1 ) ; ++ l_current_data ; ++ l_mcc_record ; } if ( opj_stream_write_data ( p_stream , p_j2k -> m_specific_param . m_encoder . m_header_tile_data , l_mco_size , p_manager ) != l_mco_size ) { return OPJ_FALSE ; } return OPJ_TRUE ; } "," ] ) ; l_mco_size = 5 l_mco_size ; } l_current_data = p_j2k -> m_specific_param . m_encoder . m_header_tile_data ; ",uclouvain@openjpeg/940100c28ae28931722290794889cf84a92c5f6f,CVE-2015-8871,https://github.com/uclouvain/openjpeg/commit/940100c28ae28931722290794889cf84a92c5f6f,2016-09-21T14:25Z 99,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 100,CWE-119,"CWE-119 struct lookahead_ctx * vp9_lookahead_init ( unsigned int width , unsigned int height , unsigned int subsampling_x , unsigned int subsampling_y , unsigned int depth ) { struct lookahead_ctx * ctx = NULL ; depth = clamp ( depth , 1 , MAX_LAG_BUFFERS ) ; depth += MAX_PRE_FRAMES ; ctx = calloc ( 1 , sizeof ( * ctx ) ) ; if ( ctx ) { unsigned int i ; ctx -> max_sz = depth ; ctx -> buf = calloc ( depth , sizeof ( * ctx -> buf ) ) ; if ( ! ctx -> buf ) goto bail ; for ( i = 0 ; i < depth ; i ++ ) if ( vp9_alloc_frame_buffer ( & ctx -> buf [ i ] . img , width , height , subsampling_x , subsampling_y , VP9_ENC_BORDER_IN_PIXELS ) ) goto bail ; } return ctx ; bail : vp9_lookahead_destroy ( ctx ) ; return NULL ; } "," int subsampling_y , # if CONFIG_VP9_HIGHBITDEPTH int use_highbitdepth , # endif ctx ) { const int legacy_byte_alignment = 0 ; ) if ( vpx_alloc_frame_buffer ( & ctx , subsampling_y , # if CONFIG_VP9_HIGHBITDEPTH use_highbitdepth , # endif VP9_ENC_BORDER_IN_PIXELS , legacy_byte_alignment ) ) goto ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 101,CWE-401,"CWE-401 static int mlx5_fpga_conn_create_cq ( struct mlx5_fpga_conn * conn , int cq_size ) { struct mlx5_fpga_device * fdev = conn -> fdev ; struct mlx5_core_dev * mdev = fdev -> mdev ; u32 temp_cqc [ MLX5_ST_SZ_DW ( cqc ) ] = { 0 } ; u32 out [ MLX5_ST_SZ_DW ( create_cq_out ) ] ; struct mlx5_wq_param wqp ; struct mlx5_cqe64 * cqe ; int inlen , err , eqn ; unsigned int irqn ; void * cqc , * in ; __be64 * pas ; u32 i ; cq_size = roundup_pow_of_two ( cq_size ) ; MLX5_SET ( cqc , temp_cqc , log_cq_size , ilog2 ( cq_size ) ) ; wqp . buf_numa_node = mdev -> priv . numa_node ; wqp . db_numa_node = mdev -> priv . numa_node ; err = mlx5_cqwq_create ( mdev , & wqp , temp_cqc , & conn -> cq . wq , & conn -> cq . wq_ctrl ) ; if ( err ) return err ; for ( i = 0 ; i < mlx5_cqwq_get_size ( & conn -> cq . wq ) ; i ++ ) { cqe = mlx5_cqwq_get_wqe ( & conn -> cq . wq , i ) ; cqe -> op_own = MLX5_CQE_INVALID << 4 | MLX5_CQE_OWNER_MASK ; } inlen = MLX5_ST_SZ_BYTES ( create_cq_in ) + sizeof ( u64 ) * conn -> cq . wq_ctrl . buf . npages ; in = kvzalloc ( inlen , GFP_KERNEL ) ; if ( ! in ) { err = - ENOMEM ; goto err_cqwq ; } err = mlx5_vector2eqn ( mdev , smp_processor_id ( ) , & eqn , & irqn ) ; if ( err ) goto err_cqwq ; cqc = MLX5_ADDR_OF ( create_cq_in , in , cq_context ) ; MLX5_SET ( cqc , cqc , log_cq_size , ilog2 ( cq_size ) ) ; MLX5_SET ( cqc , cqc , c_eqn , eqn ) ; MLX5_SET ( cqc , cqc , uar_page , fdev -> conn_res . uar -> index ) ; MLX5_SET ( cqc , cqc , log_page_size , conn -> cq . wq_ctrl . buf . page_shift - MLX5_ADAPTER_PAGE_SHIFT ) ; MLX5_SET64 ( cqc , cqc , dbr_addr , conn -> cq . wq_ctrl . db . dma ) ; pas = ( __be64 * ) MLX5_ADDR_OF ( create_cq_in , in , pas ) ; mlx5_fill_page_frag_array ( & conn -> cq . wq_ctrl . buf , pas ) ; err = mlx5_core_create_cq ( mdev , & conn -> cq . mcq , in , inlen , out , sizeof ( out ) ) ; kvfree ( in ) ; if ( err ) goto err_cqwq ; conn -> cq . mcq . cqe_sz = 64 ; conn -> cq . mcq . set_ci_db = conn -> cq . wq_ctrl . db . db ; conn -> cq . mcq . arm_db = conn -> cq . wq_ctrl . db . db + 1 ; * conn -> cq . mcq . set_ci_db = 0 ; * conn -> cq . mcq . arm_db = 0 ; conn -> cq . mcq . vector = 0 ; conn -> cq . mcq . comp = mlx5_fpga_conn_cq_complete ; conn -> cq . mcq . event = mlx5_fpga_conn_cq_event ; conn -> cq . mcq . irqn = irqn ; conn -> cq . mcq . uar = fdev -> conn_res . uar ; tasklet_init ( & conn -> cq . tasklet , mlx5_fpga_conn_cq_tasklet , ( unsigned long ) conn ) ; mlx5_fpga_dbg ( fdev , ""CreatedCQ#0x%x\\n"" , conn -> cq . mcq . cqn ) ; goto out ; err_cqwq : mlx5_wq_destroy ( & conn -> cq . wq_ctrl ) ; out : return err ; } "," ( err ) { kvfree ( in ) ; goto err_cqwq ; } ",torvalds@linux/c8c2a057fdc7de1cd16f4baa51425b932a42eb39,CVE-2019-19045,https://github.com/torvalds/linux/commit/c8c2a057fdc7de1cd16f4baa51425b932a42eb39,2019-11-18T06:15Z 102,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 103,CWE-20,"CWE-20 static int __br_mdb_del ( struct net_bridge * br , struct br_mdb_entry * entry ) { struct net_bridge_mdb_htable * mdb ; struct net_bridge_mdb_entry * mp ; struct net_bridge_port_group * p ; struct net_bridge_port_group __rcu * * pp ; struct br_ip ip ; int err = - EINVAL ; if ( ! netif_running ( br -> dev ) || br -> multicast_disabled ) return - EINVAL ; if ( timer_pending ( & br -> multicast_querier_timer ) ) return - EBUSY ; ip . proto = entry -> addr . proto ; if ( ip . proto == htons ( ETH_P_IP ) ) ip . u . ip4 = entry -> addr . u . ip4 ; # if IS_ENABLED ( CONFIG_IPV6 ) else ip . u . ip6 = entry -> addr . u . ip6 ; # endif spin_lock_bh ( & br -> multicast_lock ) ; mdb = mlock_dereference ( br -> mdb , br ) ; mp = br_mdb_ip_get ( mdb , & ip ) ; if ( ! mp ) goto unlock ; for ( pp = & mp -> ports ; ( p = mlock_dereference ( * pp , br ) ) != NULL ; pp = & p -> next ) { if ( ! p -> port || p -> port -> dev -> ifindex != entry -> ifindex ) continue ; if ( p -> port -> state == BR_STATE_DISABLED ) goto unlock ; rcu_assign_pointer ( * pp , p -> next ) ; hlist_del_init ( & p -> mglist ) ; del_timer ( & p -> timer ) ; call_rcu_bh ( & p -> rcu , br_multicast_free_pg ) ; err = 0 ; if ( ! mp -> ports && ! mp -> mglist && netif_running ( br -> dev ) ) mod_timer ( & mp -> timer , jiffies ) ; break ; } unlock : spin_unlock_bh ( & br -> multicast_lock ) ; return err ; } "," -> mglist && mp -> timer_armed && ",torvalds@linux/c7e8e8a8f7a70b343ca1e0f90a31e35ab2d16de1,CVE-2013-4129,https://github.com/torvalds/linux/commit/c7e8e8a8f7a70b343ca1e0f90a31e35ab2d16de1,2013-07-29T13:59Z 104,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 105,CWE-125,"CWE-125 static int serdes_probe ( struct platform_device * pdev ) { struct phy_provider * provider ; struct serdes_ctrl * ctrl ; unsigned int i ; int ret ; ctrl = devm_kzalloc ( & pdev -> dev , sizeof ( * ctrl ) , GFP_KERNEL ) ; if ( ! ctrl ) return - ENOMEM ; ctrl -> dev = & pdev -> dev ; ctrl -> regs = syscon_node_to_regmap ( pdev -> dev . parent -> of_node ) ; if ( IS_ERR ( ctrl -> regs ) ) return PTR_ERR ( ctrl -> regs ) ; for ( i = 0 ; i <= SERDES_MAX ; i ++ ) { ret = serdes_phy_create ( ctrl , i , & ctrl -> phys [ i ] ) ; if ( ret ) return ret ; } dev_set_drvdata ( & pdev -> dev , ctrl ) ; provider = devm_of_phy_provider_register ( ctrl -> dev , serdes_simple_xlate ) ; return PTR_ERR_OR_ZERO ( provider ) ; } "," 0 ; i < SERDES_MAX ; i ",torvalds@linux/6acb47d1a318e5b3b7115354ebc4ea060c59d3a1,CVE-2018-20854,https://github.com/torvalds/linux/commit/6acb47d1a318e5b3b7115354ebc4ea060c59d3a1,2019-07-26T05:15Z 106,CWE-000,"CWE-000 static ext4_io_end_t * ext4_init_io_end ( struct inode * inode ) { ext4_io_end_t * io = NULL ; io = kmalloc ( sizeof ( * io ) , GFP_NOFS ) ; if ( io ) { igrab ( inode ) ; io -> inode = inode ; io -> flag = 0 ; io -> offset = 0 ; io -> size = 0 ; io -> error = 0 ; INIT_WORK ( & io -> work , ext4_end_io_work ) ; INIT_LIST_HEAD ( & io -> list ) ; } return io ; } "," inode * inode , gfp_t flags io ) , flags ) ; if ; io -> page = NULL ; INIT_WORK ( ",torvalds@linux/744692dc059845b2a3022119871846e74d4f6e11,CVE-2015-8324,https://github.com/torvalds/linux/commit/744692dc059845b2a3022119871846e74d4f6e11,2016-05-02T10:59Z 107,CWE-787,"CWE-787 static int gtStripContig ( TIFFRGBAImage * img , uint32 * raster , uint32 w , uint32 h ) { TIFF * tif = img -> tif ; tileContigRoutine put = img -> put . contig ; uint32 row , y , nrow , nrowsub , rowstoread ; tmsize_t pos ; unsigned char * buf = NULL ; uint32 rowsperstrip ; uint16 subsamplinghor , subsamplingver ; uint32 imagewidth = img -> width ; tmsize_t scanline ; int32 fromskew , toskew ; int ret = 1 , flip ; tmsize_t maxstripsize ; TIFFGetFieldDefaulted ( tif , TIFFTAG_YCBCRSUBSAMPLING , & subsamplinghor , & subsamplingver ) ; if ( subsamplingver == 0 ) { TIFFErrorExt ( tif -> tif_clientdata , TIFFFileName ( tif ) , ""InvalidverticalYCbCrsubsampling"" ) ; return ( 0 ) ; } maxstripsize = TIFFStripSize ( tif ) ; flip = setorientation ( img ) ; if ( flip & FLIP_VERTICALLY ) { y = h - 1 ; toskew = - ( int32 ) ( w + w ) ; } else { y = 0 ; toskew = - ( int32 ) ( w - w ) ; } 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 ) ; nrowsub = nrow ; if ( ( nrowsub % subsamplingver ) != 0 ) nrowsub += subsamplingver - nrowsub % subsamplingver ; if ( _TIFFReadEncodedStripAndAllocBuffer ( tif , TIFFComputeStrip ( tif , row + img -> row_offset , 0 ) , ( void * * ) ( & buf ) , maxstripsize , ( ( row + img -> row_offset ) % rowsperstrip + nrowsub ) * scanline ) == ( tmsize_t ) ( - 1 ) && ( buf == NULL || 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 , buf + pos ) ; 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 ; % subsamplingver ; temp = ( row + img -> row_offset ) % rowsperstrip + nrowsub ; if ( scanline > 0 && temp > ( size_t ) ( TIFF_TMSIZE_T_MAX / scanline ) ) { TIFFErrorExt ( tif -> tif_clientdata , TIFFFileName ( tif ) , ""IntegeroverflowingtStripContig"" ) ; return 0 ; } , maxstripsize , temp * scanline ) ",OSGeo@gdal/21674033ee246f698887604c7af7ba1962a40ddf,CVE-2019-17546,https://github.com/OSGeo/gdal/commit/21674033ee246f698887604c7af7ba1962a40ddf,2019-10-14T02:15Z 108,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 109,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 110,CWE-189,"CWE-189 tsize_t t2p_readwrite_pdf_image_tile ( T2P * t2p , TIFF * input , TIFF * output , ttile_t tile ) { uint16 edge = 0 ; tsize_t written = 0 ; unsigned char * buffer = NULL ; tsize_t bufferoffset = 0 ; unsigned char * samplebuffer = NULL ; tsize_t samplebufferoffset = 0 ; tsize_t read = 0 ; uint16 i = 0 ; ttile_t tilecount = 0 ; ttile_t septilecount = 0 ; tsize_t septilesize = 0 ; # ifdef JPEG_SUPPORT unsigned char * jpt ; float * xfloatp ; uint32 xuint32 = 0 ; # endif if ( t2p -> t2p_error != T2P_ERR_OK ) return ( 0 ) ; edge |= t2p_tile_is_right_edge ( t2p -> tiff_tiles [ t2p -> pdf_page ] , tile ) ; edge |= t2p_tile_is_bottom_edge ( t2p -> tiff_tiles [ t2p -> pdf_page ] , tile ) ; if ( ( t2p -> pdf_transcode == T2P_TRANSCODE_RAW ) && ( ( edge == 0 ) # if defined ( JPEG_SUPPORT ) || defined ( OJPEG_SUPPORT ) || ( t2p -> pdf_compression == T2P_COMPRESS_JPEG ) # endif ) ) { # 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%lubytesofmemory"" ""fort2p_readwrite_pdf_image_tile,%s"" , ( unsigned long ) t2p -> tiff_datasize , TIFFFileName ( input ) ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } TIFFReadRawTile ( input , tile , ( 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%lubytesofmemory"" ""fort2p_readwrite_pdf_image_tile,%s"" , ( unsigned long ) t2p -> tiff_datasize , TIFFFileName ( input ) ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } TIFFReadRawTile ( input , tile , ( 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 -> pdf_ojpegdata ) { TIFFError ( TIFF2PDF_MODULE , ""NosupportforOJPEGimage%swith"" ""badtables"" , 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%lubytesofmemory"" ""fort2p_readwrite_pdf_image,%s"" , ( unsigned long ) t2p -> tiff_datasize , TIFFFileName ( input ) ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } _TIFFmemcpy ( buffer , t2p -> pdf_ojpegdata , t2p -> pdf_ojpegdatalength ) ; if ( edge != 0 ) { if ( t2p_tile_is_bottom_edge ( t2p -> tiff_tiles [ t2p -> pdf_page ] , tile ) ) { buffer [ 7 ] = ( t2p -> tiff_tiles [ t2p -> pdf_page ] . tiles_edgetilelength >> 8 ) & 0xff ; buffer [ 8 ] = ( t2p -> tiff_tiles [ t2p -> pdf_page ] . tiles_edgetilelength ) & 0xff ; } if ( t2p_tile_is_right_edge ( t2p -> tiff_tiles [ t2p -> pdf_page ] , tile ) ) { buffer [ 9 ] = ( t2p -> tiff_tiles [ t2p -> pdf_page ] . tiles_edgetilewidth >> 8 ) & 0xff ; buffer [ 10 ] = ( t2p -> tiff_tiles [ t2p -> pdf_page ] . tiles_edgetilewidth ) & 0xff ; } } bufferoffset = t2p -> pdf_ojpegdatalength ; bufferoffset += TIFFReadRawTile ( input , tile , ( tdata_t ) & ( ( ( unsigned char * ) buffer ) [ bufferoffset ] ) , - 1 ) ; ( ( unsigned char * ) buffer ) [ bufferoffset ++ ] = 0xff ; ( ( unsigned char * ) buffer ) [ bufferoffset ++ ] = 0xd9 ; t2pWriteFile ( output , ( tdata_t ) buffer , bufferoffset ) ; _TIFFfree ( buffer ) ; return ( bufferoffset ) ; } # endif # ifdef JPEG_SUPPORT if ( t2p -> tiff_compression == COMPRESSION_JPEG ) { unsigned char table_end [ 2 ] ; uint32 count = 0 ; buffer = ( unsigned char * ) _TIFFmalloc ( t2p -> tiff_datasize ) ; if ( buffer == NULL ) { TIFFError ( TIFF2PDF_MODULE , ""Can\'tallocate"" TIFF_SIZE_FORMAT ""bytesofmemory"" ""fort2p_readwrite_pdf_image_tile,%s"" , ( TIFF_SIZE_T ) t2p -> tiff_datasize , TIFFFileName ( input ) ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } if ( TIFFGetField ( input , TIFFTAG_JPEGTABLES , & count , & jpt ) != 0 ) { if ( count >= 4 ) { int retTIFFReadRawTile ; _TIFFmemcpy ( buffer , jpt , count - 2 ) ; bufferoffset += count - 2 ; table_end [ 0 ] = buffer [ bufferoffset - 2 ] ; table_end [ 1 ] = buffer [ bufferoffset - 1 ] ; xuint32 = bufferoffset ; bufferoffset -= 2 ; retTIFFReadRawTile = TIFFReadRawTile ( input , tile , ( tdata_t ) & ( ( ( unsigned char * ) buffer ) [ bufferoffset ] ) , - 1 ) ; if ( retTIFFReadRawTile < 0 ) { _TIFFfree ( buffer ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } bufferoffset += retTIFFReadRawTile ; buffer [ xuint32 - 2 ] = table_end [ 0 ] ; buffer [ xuint32 - 1 ] = table_end [ 1 ] ; } } t2pWriteFile ( output , ( tdata_t ) buffer , bufferoffset ) ; _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%lubytesofmemoryfor"" ""t2p_readwrite_pdf_image_tile,%s"" , ( unsigned long ) t2p -> tiff_datasize , TIFFFileName ( input ) ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } read = TIFFReadEncodedTile ( input , tile , ( tdata_t ) & buffer [ bufferoffset ] , t2p -> tiff_datasize ) ; if ( read == - 1 ) { TIFFError ( TIFF2PDF_MODULE , ""Errorondecodingtile%uof%s"" , tile , TIFFFileName ( input ) ) ; _TIFFfree ( buffer ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } } else { if ( t2p -> pdf_sample == T2P_SAMPLE_PLANAR_SEPARATE_TO_CONTIG ) { septilesize = TIFFTileSize ( input ) ; septilecount = TIFFNumberOfTiles ( input ) ; tilecount = septilecount / t2p -> tiff_samplesperpixel ; buffer = ( unsigned char * ) _TIFFmalloc ( t2p -> tiff_datasize ) ; if ( buffer == NULL ) { TIFFError ( TIFF2PDF_MODULE , ""Can\'tallocate%lubytesofmemory"" ""fort2p_readwrite_pdf_image_tile,%s"" , ( unsigned long ) t2p -> tiff_datasize , TIFFFileName ( input ) ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } samplebuffer = ( unsigned char * ) _TIFFmalloc ( t2p -> tiff_datasize ) ; if ( samplebuffer == NULL ) { TIFFError ( TIFF2PDF_MODULE , ""Can\'tallocate%lubytesofmemory"" ""fort2p_readwrite_pdf_image_tile,%s"" , ( unsigned long ) t2p -> tiff_datasize , TIFFFileName ( input ) ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } samplebufferoffset = 0 ; for ( i = 0 ; i < t2p -> tiff_samplesperpixel ; i ++ ) { read = TIFFReadEncodedTile ( input , tile + i * tilecount , ( tdata_t ) & ( samplebuffer [ samplebufferoffset ] ) , septilesize ) ; if ( read == - 1 ) { TIFFError ( TIFF2PDF_MODULE , ""Errorondecodingtile%uof%s"" , tile + i * tilecount , TIFFFileName ( input ) ) ; _TIFFfree ( samplebuffer ) ; _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 ) ; } if ( buffer == NULL ) { buffer = ( unsigned char * ) _TIFFmalloc ( t2p -> tiff_datasize ) ; if ( buffer == NULL ) { TIFFError ( TIFF2PDF_MODULE , ""Can\'tallocate%lubytesofmemory"" ""fort2p_readwrite_pdf_image_tile,%s"" , ( unsigned long ) t2p -> tiff_datasize , TIFFFileName ( input ) ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } read = TIFFReadEncodedTile ( input , tile , ( tdata_t ) & buffer [ bufferoffset ] , t2p -> tiff_datasize ) ; if ( read == - 1 ) { TIFFError ( TIFF2PDF_MODULE , ""Errorondecodingtile%uof%s"" , tile , TIFFFileName ( input ) ) ; _TIFFfree ( buffer ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } } if ( t2p -> pdf_sample & T2P_SAMPLE_RGBA_TO_RGB ) { t2p -> tiff_datasize = t2p_sample_rgba_to_rgb ( ( tdata_t ) buffer , t2p -> tiff_tiles [ t2p -> pdf_page ] . tiles_tilewidth * t2p -> tiff_tiles [ t2p -> pdf_page ] . tiles_tilelength ) ; } if ( t2p -> pdf_sample & T2P_SAMPLE_RGBAA_TO_RGB ) { t2p -> tiff_datasize = t2p_sample_rgbaa_to_rgb ( ( tdata_t ) buffer , t2p -> tiff_tiles [ t2p -> pdf_page ] . tiles_tilewidth * t2p -> tiff_tiles [ t2p -> pdf_page ] . tiles_tilelength ) ; } if ( t2p -> pdf_sample & T2P_SAMPLE_YCBCR_TO_RGB ) { TIFFError ( TIFF2PDF_MODULE , ""NosupportforYCbCrtoRGBintilefor%s"" , TIFFFileName ( input ) ) ; _TIFFfree ( buffer ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } if ( t2p -> pdf_sample & T2P_SAMPLE_LAB_SIGNED_TO_UNSIGNED ) { t2p -> tiff_datasize = t2p_sample_lab_signed_to_unsigned ( ( tdata_t ) buffer , t2p -> tiff_tiles [ t2p -> pdf_page ] . tiles_tilewidth * t2p -> tiff_tiles [ t2p -> pdf_page ] . tiles_tilelength ) ; } } if ( t2p_tile_is_right_edge ( t2p -> tiff_tiles [ t2p -> pdf_page ] , tile ) != 0 ) { t2p_tile_collapse_left ( buffer , TIFFTileRowSize ( input ) , t2p -> tiff_tiles [ t2p -> pdf_page ] . tiles_tilewidth , t2p -> tiff_tiles [ t2p -> pdf_page ] . tiles_edgetilewidth , t2p -> tiff_tiles [ t2p -> pdf_page ] . tiles_tilelength ) ; } t2p_disable ( output ) ; TIFFSetField ( output , TIFFTAG_PHOTOMETRIC , t2p -> tiff_photometric ) ; TIFFSetField ( output , TIFFTAG_BITSPERSAMPLE , t2p -> tiff_bitspersample ) ; TIFFSetField ( output , TIFFTAG_SAMPLESPERPIXEL , t2p -> tiff_samplesperpixel ) ; if ( t2p_tile_is_right_edge ( t2p -> tiff_tiles [ t2p -> pdf_page ] , tile ) == 0 ) { TIFFSetField ( output , TIFFTAG_IMAGEWIDTH , t2p -> tiff_tiles [ t2p -> pdf_page ] . tiles_tilewidth ) ; } else { TIFFSetField ( output , TIFFTAG_IMAGEWIDTH , t2p -> tiff_tiles [ t2p -> pdf_page ] . tiles_edgetilewidth ) ; } if ( t2p_tile_is_bottom_edge ( t2p -> tiff_tiles [ t2p -> pdf_page ] , tile ) == 0 ) { TIFFSetField ( output , TIFFTAG_IMAGELENGTH , t2p -> tiff_tiles [ t2p -> pdf_page ] . tiles_tilelength ) ; TIFFSetField ( output , TIFFTAG_ROWSPERSTRIP , t2p -> tiff_tiles [ t2p -> pdf_page ] . tiles_tilelength ) ; } else { TIFFSetField ( output , TIFFTAG_IMAGELENGTH , t2p -> tiff_tiles [ t2p -> pdf_page ] . tiles_edgetilelength ) ; TIFFSetField ( output , TIFFTAG_ROWSPERSTRIP , t2p -> tiff_tiles [ t2p -> pdf_page ] . tiles_edgetilelength ) ; } 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 ) ; } } TIFFSetField ( output , TIFFTAG_COMPRESSION , COMPRESSION_JPEG ) ; 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 ; bufferoffset = TIFFWriteEncodedStrip ( output , ( tstrip_t ) 0 , buffer , TIFFStripSize ( output ) ) ; if ( buffer != NULL ) { _TIFFfree ( buffer ) ; buffer = NULL ; } if ( bufferoffset == - 1 ) { TIFFError ( TIFF2PDF_MODULE , ""ErrorwritingencodedtiletooutputPDF%s"" , TIFFFileName ( output ) ) ; t2p -> t2p_error = T2P_ERR_ERROR ; return ( 0 ) ; } written = t2p -> outputwritten ; return ( written ) ; } "," if ( count > 4 ) { ",vadz@libtiff/c7153361a4041260719b340f73f2f76b0969235c,CVE-2016-10094,https://github.com/vadz/libtiff/commit/c7153361a4041260719b340f73f2f76,2017-03-01T15:59Z 111,CWE-119,"CWE-119 static void joint_motion_search ( VP9_COMP * cpi , MACROBLOCK * x , BLOCK_SIZE bsize , int_mv * frame_mv , int mi_row , int mi_col , int_mv single_newmv [ MAX_REF_FRAMES ] , int * rate_mv ) { const int pw = 4 * num_4x4_blocks_wide_lookup [ bsize ] ; const int ph = 4 * num_4x4_blocks_high_lookup [ bsize ] ; MACROBLOCKD * xd = & x -> e_mbd ; MB_MODE_INFO * mbmi = & xd -> mi [ 0 ] -> mbmi ; const int refs [ 2 ] = { mbmi -> ref_frame [ 0 ] , mbmi -> ref_frame [ 1 ] < 0 ? 0 : mbmi -> ref_frame [ 1 ] } ; int_mv ref_mv [ 2 ] ; int ite , ref ; uint8_t * second_pred = vpx_memalign ( 16 , pw * ph * sizeof ( uint8_t ) ) ; const InterpKernel * kernel = vp9_get_interp_kernel ( mbmi -> interp_filter ) ; struct buf_2d backup_yv12 [ 2 ] [ MAX_MB_PLANE ] ; struct buf_2d scaled_first_yv12 = xd -> plane [ 0 ] . pre [ 0 ] ; int last_besterr [ 2 ] = { INT_MAX , INT_MAX } ; const YV12_BUFFER_CONFIG * const scaled_ref_frame [ 2 ] = { vp9_get_scaled_ref_frame ( cpi , mbmi -> ref_frame [ 0 ] ) , vp9_get_scaled_ref_frame ( cpi , mbmi -> ref_frame [ 1 ] ) } ; for ( ref = 0 ; ref < 2 ; ++ ref ) { ref_mv [ ref ] = mbmi -> ref_mvs [ refs [ ref ] ] [ 0 ] ; if ( scaled_ref_frame [ ref ] ) { int i ; for ( i = 0 ; i < MAX_MB_PLANE ; i ++ ) backup_yv12 [ ref ] [ i ] = xd -> plane [ i ] . pre [ ref ] ; vp9_setup_pre_planes ( xd , ref , scaled_ref_frame [ ref ] , mi_row , mi_col , NULL ) ; } frame_mv [ refs [ ref ] ] . as_int = single_newmv [ refs [ ref ] ] . as_int ; } for ( ite = 0 ; ite < 4 ; ite ++ ) { struct buf_2d ref_yv12 [ 2 ] ; int bestsme = INT_MAX ; int sadpb = x -> sadperbit16 ; int_mv tmp_mv ; int search_range = 3 ; 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 ; int id = ite % 2 ; ref_yv12 [ 0 ] = xd -> plane [ 0 ] . pre [ 0 ] ; ref_yv12 [ 1 ] = xd -> plane [ 0 ] . pre [ 1 ] ; vp9_build_inter_predictor ( ref_yv12 [ ! id ] . buf , ref_yv12 [ ! id ] . stride , second_pred , pw , & frame_mv [ refs [ ! id ] ] . as_mv , & xd -> block_refs [ ! id ] -> sf , pw , ph , 0 , kernel , MV_PRECISION_Q3 , mi_col * MI_SIZE , mi_row * MI_SIZE ) ; if ( id ) xd -> plane [ 0 ] . pre [ 0 ] = ref_yv12 [ id ] ; vp9_set_mv_search_range ( x , & ref_mv [ id ] . as_mv ) ; tmp_mv . as_int = frame_mv [ refs [ id ] ] . as_int ; tmp_mv . as_mv . col >>= 3 ; tmp_mv . as_mv . row >>= 3 ; bestsme = vp9_refining_search_8p_c ( x , & tmp_mv . as_mv , sadpb , search_range , & cpi -> fn_ptr [ bsize ] , x -> nmvjointcost , x -> mvcost , & ref_mv [ id ] . as_mv , second_pred , pw , ph ) ; if ( bestsme < INT_MAX ) bestsme = vp9_get_mvpred_av_var ( x , & tmp_mv . as_mv , & ref_mv [ id ] . as_mv , second_pred , & cpi -> fn_ptr [ bsize ] , 1 ) ; 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 ; bestsme = cpi -> find_fractional_mv_step_comp ( x , & tmp_mv . as_mv , & ref_mv [ id ] . as_mv , cpi -> common . allow_high_precision_mv , x -> errorperbit , & cpi -> fn_ptr [ bsize ] , 0 , cpi -> sf . subpel_iters_per_step , x -> nmvjointcost , x -> mvcost , & dis , & sse , second_pred , pw , ph ) ; } if ( id ) xd -> plane [ 0 ] . pre [ 0 ] = scaled_first_yv12 ; if ( bestsme < last_besterr [ id ] ) { frame_mv [ refs [ id ] ] . as_int = tmp_mv . as_int ; last_besterr [ id ] = bestsme ; } else { break ; } } * rate_mv = 0 ; for ( ref = 0 ; ref < 2 ; ++ ref ) { if ( scaled_ref_frame [ ref ] ) { int i ; for ( i = 0 ; i < MAX_MB_PLANE ; i ++ ) xd -> plane [ i ] . pre [ ref ] = backup_yv12 [ ref ] [ i ] ; } * rate_mv += vp9_mv_bit_cost ( & frame_mv [ refs [ ref ] ] . as_mv , & mbmi -> ref_mvs [ refs [ ref ] ] [ 0 ] . as_mv , x -> nmvjointcost , x -> mvcost , MV_COST_WEIGHT ) ; } vpx_free ( second_pred ) ; } "," ) { const VP9_COMMON * const cm = & cpi -> common ; const , ref ; const InterpKernel * * kernel = vp9_filter_kernels [ mbmi -> interp_filter mbmi -> interp_filter ] ; struct scale_factors sf ; struct buf_2d MAX_MB_PLANE ] ; int last_besterr [ ) } ; # if CONFIG_VP9_HIGHBITDEPTH DECLARE_ALIGNED ( 16 , uint16_t , second_pred_alloc_16 [ 64 * 64 ] ) ; uint8_t * second_pred ; # else DECLARE_ALIGNED ( 16 , uint8_t , second_pred [ 64 * 64 ] ) ; # endif ref ] = x -> mbmi_ext -> ref_mvs [ as_int ; } # if CONFIG_VP9_HIGHBITDEPTH vp9_setup_scale_factors_for_frame ( & sf , cm -> width , cm -> height , cm -> width , cm -> height , cm -> use_highbitdepth ) ; # else vp9_setup_scale_factors_for_frame ( & sf , cm -> width , cm -> height , cm -> width , cm -> height ) ; # endif -> sadperbit16 ; MV tmp_mv ; int 1 ] ; # if CONFIG_VP9_HIGHBITDEPTH if ( xd -> cur_buf -> flags & YV12_FLAG_HIGHBITDEPTH ) { second_pred = CONVERT_TO_BYTEPTR ( second_pred_alloc_16 ) ; vp9_highbd_build_inter_predictor ( ref_yv12 [ ! id ] . buf , ref_yv12 [ ! id ] . stride , second_pred , pw , & frame_mv [ refs [ ! id ] ] . as_mv , & sf , pw , ph , 0 , kernel , MV_PRECISION_Q3 , mi_col * MI_SIZE , mi_row * MI_SIZE , xd -> bd ) ; } else { second_pred = ( uint8_t * ) second_pred_alloc_16 ; as_mv , & sf , pw , ph , 0 , kernel , MV_PRECISION_Q3 , mi_col * MI_SIZE , mi_row * MI_SIZE ) ; } # else vp9_build_inter_predictor ( ref_yv12 [ ! id ] . buf , ref_yv12 [ ! id ] . stride , second_pred , pw , & frame_mv [ refs [ ! id ] ] . as_mv , & sf , pw , ph , 0 , kernel , MV_PRECISION_Q3 , mi_col * MI_SIZE , mi_row * MI_SIZE ) ; # endif if ( id ) xd -> plane [ 0 ) ; tmp_mv = frame_mv [ ] ] . as_mv ; tmp_mv . col >>= ; tmp_mv . row >>= 3 , & tmp_mv , sadpb , search_range , & cpi -> fn_ptr [ bsize ] , & ref_mv [ id ] . as_mv , second_pred ) ; if , & tmp_mv , & ref_mv = cpi -> find_fractional_mv_step ( x , , & tmp_mv , & ref_mv [ id ] . as_mv , cpi -> common -> sf . mv . subpel_iters_per_step , NULL , x -> nmvjointcost 0 ] = ref_yv12 [ 0 ] ; if ( ] ] . as_mv = tmp_mv ; last_besterr [ as_mv , & x -> mbmi_ext -> ref_mvs [ ) ; } } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 112,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 113,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 114,CWE-119,"CWE-119 static void fill_variance ( int64_t s2 , int64_t s , int c , var * v ) { v -> sum_square_error = s2 ; v -> sum_error = s ; v -> count = c ; if ( c > 0 ) v -> variance = ( int ) ( 256 * ( v -> sum_square_error - v -> sum_error * v -> sum_error / v -> count ) / v -> count ) ; else v -> variance = 0 ; } "," ; v -> log2_count = c ; = c ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 115,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 116,CWE-787,"CWE-787 static OPJ_BOOL opj_j2k_write_all_tile_parts ( opj_j2k_t * p_j2k , OPJ_BYTE * p_data , OPJ_UINT32 * p_data_written , OPJ_UINT32 p_total_data_size , opj_stream_private_t * p_stream , struct opj_event_mgr * p_manager ) { OPJ_UINT32 tilepartno = 0 ; OPJ_UINT32 l_nb_bytes_written = 0 ; OPJ_UINT32 l_current_nb_bytes_written ; OPJ_UINT32 l_part_tile_size ; OPJ_UINT32 tot_num_tp ; OPJ_UINT32 pino ; OPJ_BYTE * l_begin_data ; opj_tcp_t * l_tcp = 00 ; opj_tcd_t * l_tcd = 00 ; opj_cp_t * l_cp = 00 ; l_tcd = p_j2k -> m_tcd ; l_cp = & ( p_j2k -> m_cp ) ; l_tcp = l_cp -> tcps + p_j2k -> m_current_tile_number ; tot_num_tp = opj_j2k_get_num_tp ( l_cp , 0 , p_j2k -> m_current_tile_number ) ; ++ p_j2k -> m_specific_param . m_encoder . m_current_tile_part_number ; for ( tilepartno = 1 ; tilepartno < tot_num_tp ; ++ tilepartno ) { p_j2k -> m_specific_param . m_encoder . m_current_poc_tile_part_number = tilepartno ; l_current_nb_bytes_written = 0 ; l_part_tile_size = 0 ; l_begin_data = p_data ; if ( ! opj_j2k_write_sot ( p_j2k , p_data , & l_current_nb_bytes_written , p_stream , p_manager ) ) { return OPJ_FALSE ; } l_nb_bytes_written += l_current_nb_bytes_written ; p_data += l_current_nb_bytes_written ; p_total_data_size -= l_current_nb_bytes_written ; l_part_tile_size += l_current_nb_bytes_written ; l_current_nb_bytes_written = 0 ; if ( ! opj_j2k_write_sod ( p_j2k , l_tcd , p_data , & l_current_nb_bytes_written , p_total_data_size , p_stream , p_manager ) ) { return OPJ_FALSE ; } p_data += l_current_nb_bytes_written ; l_nb_bytes_written += l_current_nb_bytes_written ; p_total_data_size -= l_current_nb_bytes_written ; l_part_tile_size += l_current_nb_bytes_written ; opj_write_bytes ( l_begin_data + 6 , l_part_tile_size , 4 ) ; if ( OPJ_IS_CINEMA ( l_cp -> rsiz ) ) { opj_j2k_update_tlm ( p_j2k , l_part_tile_size ) ; } ++ p_j2k -> m_specific_param . m_encoder . m_current_tile_part_number ; } for ( pino = 1 ; pino <= l_tcp -> numpocs ; ++ pino ) { l_tcd -> cur_pino = pino ; tot_num_tp = opj_j2k_get_num_tp ( l_cp , pino , p_j2k -> m_current_tile_number ) ; for ( tilepartno = 0 ; tilepartno < tot_num_tp ; ++ tilepartno ) { p_j2k -> m_specific_param . m_encoder . m_current_poc_tile_part_number = tilepartno ; l_current_nb_bytes_written = 0 ; l_part_tile_size = 0 ; l_begin_data = p_data ; if ( ! opj_j2k_write_sot ( p_j2k , p_data , & l_current_nb_bytes_written , p_stream , p_manager ) ) { return OPJ_FALSE ; } l_nb_bytes_written += l_current_nb_bytes_written ; p_data += l_current_nb_bytes_written ; p_total_data_size -= l_current_nb_bytes_written ; l_part_tile_size += l_current_nb_bytes_written ; l_current_nb_bytes_written = 0 ; if ( ! opj_j2k_write_sod ( p_j2k , l_tcd , p_data , & l_current_nb_bytes_written , p_total_data_size , p_stream , p_manager ) ) { return OPJ_FALSE ; } l_nb_bytes_written += l_current_nb_bytes_written ; p_data += l_current_nb_bytes_written ; p_total_data_size -= l_current_nb_bytes_written ; l_part_tile_size += l_current_nb_bytes_written ; opj_write_bytes ( l_begin_data + 6 , l_part_tile_size , 4 ) ; if ( OPJ_IS_CINEMA ( l_cp -> rsiz ) ) { opj_j2k_update_tlm ( p_j2k , l_part_tile_size ) ; } ++ p_j2k -> m_specific_param . m_encoder . m_current_tile_part_number ; } } * p_data_written = l_nb_bytes_written ; return OPJ_TRUE ; } "," , p_data , p_total_data_size , , p_data , p_total_data_size , ",uclouvain@openjpeg/dcac91b8c72f743bda7dbfa9032356bc8110098a,CVE-2017-14164,https://github.com/uclouvain/openjpeg/commit/dcac91b8c72f743bda7dbfa9032356bc8110098a,2017-09-06T18:29Z 117,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 118,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 119,CWE-189,"CWE-189 static void ecryptfs_decode_from_filename ( unsigned char * dst , size_t * dst_size , const unsigned char * src , size_t src_size ) { u8 current_bit_offset = 0 ; size_t src_byte_offset = 0 ; size_t dst_byte_offset = 0 ; if ( dst == NULL ) { ( * dst_size ) = ecryptfs_max_decoded_size ( src_size ) ; goto out ; } while ( src_byte_offset < src_size ) { unsigned char src_byte = filename_rev_map [ ( int ) src [ src_byte_offset ] ] ; switch ( current_bit_offset ) { case 0 : dst [ dst_byte_offset ] = ( src_byte << 2 ) ; current_bit_offset = 6 ; break ; case 6 : dst [ dst_byte_offset ++ ] |= ( src_byte >> 4 ) ; dst [ dst_byte_offset ] = ( ( src_byte & 0xF ) << 4 ) ; current_bit_offset = 4 ; break ; case 4 : dst [ dst_byte_offset ++ ] |= ( src_byte >> 2 ) ; dst [ dst_byte_offset ] = ( src_byte << 6 ) ; current_bit_offset = 2 ; break ; case 2 : dst [ dst_byte_offset ++ ] |= ( src_byte ) ; dst [ dst_byte_offset ] = 0 ; current_bit_offset = 0 ; break ; } src_byte_offset ++ ; } ( * dst_size ) = dst_byte_offset ; out : return ; } "," src_byte ) ; current_bit_offset = 0 ",torvalds@linux/942080643bce061c3dd9d5718d3b745dcb39a8bc,CVE-2014-9683,https://github.com/torvalds/linux/commit/942080643bce061c3dd9d5718d3b745dcb39a8bc,2015-03-03T11:59Z 120,CWE-20,"CWE-20 static void icmp6_send ( struct sk_buff * skb , u8 type , u8 code , __u32 info , const struct in6_addr * force_saddr ) { struct net * net = dev_net ( skb -> dev ) ; struct inet6_dev * idev = NULL ; struct ipv6hdr * hdr = ipv6_hdr ( skb ) ; struct sock * sk ; struct ipv6_pinfo * np ; const struct in6_addr * saddr = NULL ; struct dst_entry * dst ; struct icmp6hdr tmp_hdr ; struct flowi6 fl6 ; struct icmpv6_msg msg ; struct sockcm_cookie sockc_unused = { 0 } ; struct ipcm6_cookie ipc6 ; int iif = 0 ; int addr_type = 0 ; int len ; int err = 0 ; u32 mark = IP6_REPLY_MARK ( net , skb -> mark ) ; if ( ( u8 * ) hdr < skb -> head || ( skb_network_header ( skb ) + sizeof ( * hdr ) ) > skb_tail_pointer ( skb ) ) return ; addr_type = ipv6_addr_type ( & hdr -> daddr ) ; if ( ipv6_chk_addr ( net , & hdr -> daddr , skb -> dev , 0 ) || ipv6_chk_acast_addr_src ( net , skb -> dev , & hdr -> daddr ) ) saddr = & hdr -> daddr ; if ( addr_type & IPV6_ADDR_MULTICAST || skb -> pkt_type != PACKET_HOST ) { if ( type != ICMPV6_PKT_TOOBIG && ! ( type == ICMPV6_PARAMPROB && code == ICMPV6_UNK_OPTION && ( opt_unrec ( skb , info ) ) ) ) return ; saddr = NULL ; } addr_type = ipv6_addr_type ( & hdr -> saddr ) ; if ( __ipv6_addr_needs_scope_id ( addr_type ) ) iif = skb -> dev -> ifindex ; else iif = l3mdev_master_ifindex ( skb_dst ( skb ) -> dev ) ; if ( ( addr_type == IPV6_ADDR_ANY ) || ( addr_type & IPV6_ADDR_MULTICAST ) ) { net_dbg_ratelimited ( ""icmp6_send:addr_any/mcastsource[%pI6c>%pI6c]\\n"" , & hdr -> saddr , & hdr -> daddr ) ; return ; } if ( is_ineligible ( skb ) ) { net_dbg_ratelimited ( ""icmp6_send:noreplytoicmperror[%pI6c>%pI6c]\\n"" , & hdr -> saddr , & hdr -> daddr ) ; return ; } mip6_addr_swap ( skb ) ; memset ( & fl6 , 0 , sizeof ( fl6 ) ) ; fl6 . flowi6_proto = IPPROTO_ICMPV6 ; fl6 . daddr = hdr -> saddr ; if ( force_saddr ) saddr = force_saddr ; if ( saddr ) fl6 . saddr = * saddr ; fl6 . flowi6_mark = mark ; fl6 . flowi6_oif = iif ; fl6 . fl6_icmp_type = type ; fl6 . fl6_icmp_code = code ; security_skb_classify_flow ( skb , flowi6_to_flowi ( & fl6 ) ) ; sk = icmpv6_xmit_lock ( net ) ; if ( ! sk ) return ; sk -> sk_mark = mark ; np = inet6_sk ( sk ) ; if ( ! icmpv6_xrlim_allow ( sk , type , & fl6 ) ) goto out ; tmp_hdr . icmp6_type = type ; tmp_hdr . icmp6_code = code ; tmp_hdr . icmp6_cksum = 0 ; tmp_hdr . icmp6_pointer = htonl ( info ) ; 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 ; ipc6 . tclass = np -> tclass ; fl6 . flowlabel = ip6_make_flowinfo ( ipc6 . tclass , fl6 . flowlabel ) ; dst = icmpv6_route_lookup ( net , skb , sk , & fl6 ) ; if ( IS_ERR ( dst ) ) goto out ; ipc6 . hlimit = ip6_sk_dst_hoplimit ( np , & fl6 , dst ) ; ipc6 . dontfrag = np -> dontfrag ; ipc6 . opt = NULL ; msg . skb = skb ; msg . offset = skb_network_offset ( skb ) ; msg . type = type ; len = skb -> len - msg . offset ; len = min_t ( unsigned int , len , IPV6_MIN_MTU - sizeof ( struct ipv6hdr ) - sizeof ( struct icmp6hdr ) ) ; if ( len < 0 ) { net_dbg_ratelimited ( ""icmp:lenproblem[%pI6c>%pI6c]\\n"" , & hdr -> saddr , & hdr -> daddr ) ; goto out_dst_release ; } rcu_read_lock ( ) ; idev = __in6_dev_get ( skb -> dev ) ; err = ip6_append_data ( sk , icmpv6_getfrag , & msg , len + sizeof ( struct icmp6hdr ) , sizeof ( struct icmp6hdr ) , & ipc6 , & fl6 , ( struct rt6_info * ) dst , MSG_DONTWAIT , & sockc_unused ) ; if ( err ) { ICMP6_INC_STATS ( net , idev , ICMP6_MIB_OUTERRORS ) ; ip6_flush_pending_frames ( sk ) ; } else { err = icmpv6_push_pending_frames ( sk , & fl6 , & tmp_hdr , len + sizeof ( struct icmp6hdr ) ) ; } rcu_read_unlock ( ) ; out_dst_release : dst_release ( dst ) ; out : icmpv6_xmit_unlock ( sk ) ; } "," ifindex ; else { dst = skb_dst ( skb ) ; = l3mdev_master_ifindex ( dst ? dst -> dev : skb -> dev ) ; } if ( ( ",torvalds@linux/79dc7e3f1cd323be4c81aa1a94faa1b3ed987fb2,CVE-2016-9919,https://github.com/torvalds/linux/commit/79dc7e3f1cd323be4c81aa1a94faa1b3ed987fb2,2016-12-08T17:59Z 121,CWE-200,"CWE-200 static int sched_read_attr ( struct sched_attr __user * uattr , struct sched_attr * attr , unsigned int usize ) { int ret ; if ( ! access_ok ( VERIFY_WRITE , uattr , usize ) ) return - EFAULT ; if ( usize < sizeof ( * attr ) ) { unsigned char * addr ; unsigned char * end ; addr = ( void * ) attr + usize ; end = ( void * ) attr + sizeof ( * attr ) ; for ( ; addr < end ; addr ++ ) { if ( * addr ) goto err_size ; } attr -> size = usize ; } ret = copy_to_user ( uattr , attr , usize ) ; if ( ret ) return - EFAULT ; out : return ret ; err_size : ret = - E2BIG ; goto out ; } "," , attr , attr -> size ) ; if ",torvalds@linux/4efbc454ba68def5ef285b26ebfcfdb605b52755,CVE-2014-9903,https://github.com/torvalds/linux/commit/4efbc454ba68def5ef285b26ebfcfdb605b52755,2016-06-27T10:59Z 122,CWE-190,"CWE-190 static int putint ( jas_stream_t * out , int sgnd , int prec , long val ) { int n ; int c ; bool s ; ulong tmp ; assert ( ( ! sgnd && prec >= 1 ) || ( sgnd && prec >= 2 ) ) ; if ( sgnd ) { val = encode_twos_comp ( val , prec ) ; } assert ( val >= 0 ) ; val &= ( 1 << prec ) - 1 ; n = ( prec + 7 ) / 8 ; while ( -- n >= 0 ) { c = ( val >> ( n * 8 ) ) & 0xff ; if ( jas_stream_putc ( out , c ) != c ) return - 1 ; } return 0 ; } "," bool s ; jas_ulong tmp ; assert ",mdadams@jasper/d42b2388f7f8e0332c846675133acea151fc557a,CVE-2016-9557,https://github.com/mdadams/jasper/commit/d42b2388f7f8e0332c846675133acea151fc557a,2017-03-23T18:59Z 123,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 124,CWE-617,"CWE-617 int init_pci ( struct vmctx * ctx ) { struct mem_range mr ; struct pci_vdev_ops * ops ; struct businfo * bi ; struct slotinfo * si ; struct funcinfo * fi ; size_t lowmem ; int bus , slot , func ; int success_cnt = 0 ; int error ; pci_emul_iobase = PCI_EMUL_IOBASE ; pci_emul_membase32 = vm_get_lowmem_limit ( ctx ) ; pci_emul_membase64 = PCI_EMUL_MEMBASE64 ; create_gsi_sharing_groups ( ) ; for ( bus = 0 ; bus < MAXBUSES ; bus ++ ) { bi = pci_businfo [ bus ] ; if ( bi == NULL ) continue ; bi -> iobase = pci_emul_iobase ; bi -> membase32 = pci_emul_membase32 ; bi -> membase64 = pci_emul_membase64 ; for ( slot = 0 ; slot < MAXSLOTS ; slot ++ ) { si = & bi -> slotinfo [ slot ] ; for ( func = 0 ; func < MAXFUNCS ; func ++ ) { fi = & si -> si_funcs [ func ] ; if ( fi -> fi_name == NULL ) continue ; ops = pci_emul_finddev ( fi -> fi_name ) ; assert ( ops != NULL ) ; pr_notice ( ""pciinit%s\\r\\n"" , fi -> fi_name ) ; error = pci_emul_init ( ctx , ops , bus , slot , func , fi ) ; if ( error ) { pr_err ( ""pci%sinitfailed\\n"" , fi -> fi_name ) ; goto pci_emul_init_fail ; } success_cnt ++ ; } } pci_emul_iobase += BUSIO_ROUNDUP ; pci_emul_iobase = roundup2 ( pci_emul_iobase , BUSIO_ROUNDUP ) ; bi -> iolimit = pci_emul_iobase ; pci_emul_membase32 += BUSMEM_ROUNDUP ; pci_emul_membase32 = roundup2 ( pci_emul_membase32 , BUSMEM_ROUNDUP ) ; bi -> memlimit32 = pci_emul_membase32 ; pci_emul_membase64 += BUSMEM_ROUNDUP ; pci_emul_membase64 = roundup2 ( pci_emul_membase64 , BUSMEM_ROUNDUP ) ; bi -> memlimit64 = pci_emul_membase64 ; } error = check_gsi_sharing_violation ( ) ; if ( error < 0 ) goto pci_emul_init_fail ; for ( bus = 0 ; bus < MAXBUSES ; bus ++ ) { bi = pci_businfo [ bus ] ; if ( bi == NULL ) continue ; for ( slot = 0 ; slot < MAXSLOTS ; slot ++ ) { si = & bi -> slotinfo [ slot ] ; for ( func = 0 ; func < MAXFUNCS ; func ++ ) { fi = & si -> si_funcs [ func ] ; if ( fi -> fi_devi == NULL ) continue ; pci_lintr_route ( fi -> fi_devi ) ; ops = fi -> fi_devi -> dev_ops ; if ( ops && ops -> vdev_phys_access ) ops -> vdev_phys_access ( ctx , fi -> fi_devi ) ; } } } lpc_pirq_routed ( ) ; lowmem = vm_get_lowmem_size ( ctx ) ; bzero ( & mr , sizeof ( struct mem_range ) ) ; mr . name = ""PCIhole(32-bit)"" ; mr . flags = MEM_F_RW ; mr . base = lowmem ; mr . size = ( 4ULL * 1024 * 1024 * 1024 ) - lowmem ; mr . handler = pci_emul_fallback_handler ; error = register_mem_fallback ( & mr ) ; assert ( error == 0 ) ; bzero ( & mr , sizeof ( struct mem_range ) ) ; mr . name = ""PCIhole(64-bit)"" ; mr . flags = MEM_F_RW ; mr . base = PCI_EMUL_MEMBASE64 ; mr . size = PCI_EMUL_MEMLIMIT64 - PCI_EMUL_MEMBASE64 ; mr . handler = pci_emul_fallback_handler ; error = register_mem_fallback ( & mr ) ; assert ( error == 0 ) ; bzero ( & mr , sizeof ( struct mem_range ) ) ; mr . name = ""PCIECFG"" ; mr . flags = MEM_F_RW ; mr . base = PCI_EMUL_ECFG_BASE ; mr . size = PCI_EMUL_ECFG_SIZE ; mr . handler = pci_emul_ecfg_handler ; error = register_mem ( & mr ) ; assert ( error == 0 ) ; return 0 ; pci_emul_init_fail : for ( bus = 0 ; bus < MAXBUSES && success_cnt > 0 ; bus ++ ) { bi = pci_businfo [ bus ] ; if ( bi == NULL ) continue ; for ( slot = 0 ; slot < MAXSLOTS && success_cnt > 0 ; slot ++ ) { si = & bi -> slotinfo [ slot ] ; for ( func = 0 ; func < MAXFUNCS ; func ++ ) { fi = & si -> si_funcs [ func ] ; if ( fi -> fi_name == NULL ) continue ; if ( success_cnt -- <= 0 ) break ; ops = pci_emul_finddev ( fi -> fi_name ) ; assert ( ops != NULL ) ; pci_emul_deinit ( ctx , ops , bus , slot , func , fi ) ; } } } return error ; } "," fi_name ) ; if ( ! ops ) { pr_warn ( ""Nodriverfordevice[%s]\\n"" , fi -> fi_name ) ; continue ; } pr_notice ( ""pciinit%s\\r\\n"" mr ) ; if ( error != 0 ) goto pci_emul_init_fail ; bzero ( mr ) ; if ( error != 0 ) goto pci_emul_init_fail ; bzero ( mr ) ; if ( error != 0 ) goto pci_emul_init_fail ; return 0 fi_name ) ; if ( ! ops ) { pr_warn ( ""Nodriverfordevice[%s]\\n"" , fi -> fi_name ) ; continue ; } pci_emul_deinit ( ctx ",projectacrn@acrn-hypervisor/2b3dedfb9ba13f15887f22b935d373f36c9a59fa,CVE-2019-18844,https://github.com/projectacrn/acrn-hypervisor/commit/2b3dedfb9ba13f15887f22b935d373f36c9a59fa,2019-11-13T20:15Z 125,CWE-310,"CWE-310 void bn_mul_comba4 ( BN_ULONG * r , BN_ULONG * a , BN_ULONG * b ) { BN_ULONG t1 , t2 ; BN_ULONG c1 , c2 , c3 ; c1 = 0 ; c2 = 0 ; c3 = 0 ; mul_add_c ( a [ 0 ] , b [ 0 ] , c1 , c2 , c3 ) ; r [ 0 ] = c1 ; c1 = 0 ; mul_add_c ( a [ 0 ] , b [ 1 ] , c2 , c3 , c1 ) ; mul_add_c ( a [ 1 ] , b [ 0 ] , c2 , c3 , c1 ) ; r [ 1 ] = c2 ; c2 = 0 ; mul_add_c ( a [ 2 ] , b [ 0 ] , c3 , c1 , c2 ) ; mul_add_c ( a [ 1 ] , b [ 1 ] , c3 , c1 , c2 ) ; mul_add_c ( a [ 0 ] , b [ 2 ] , c3 , c1 , c2 ) ; r [ 2 ] = c3 ; c3 = 0 ; mul_add_c ( a [ 0 ] , b [ 3 ] , c1 , c2 , c3 ) ; mul_add_c ( a [ 1 ] , b [ 2 ] , c1 , c2 , c3 ) ; mul_add_c ( a [ 2 ] , b [ 1 ] , c1 , c2 , c3 ) ; mul_add_c ( a [ 3 ] , b [ 0 ] , c1 , c2 , c3 ) ; r [ 3 ] = c1 ; c1 = 0 ; mul_add_c ( a [ 3 ] , b [ 1 ] , c2 , c3 , c1 ) ; mul_add_c ( a [ 2 ] , b [ 2 ] , c2 , c3 , c1 ) ; mul_add_c ( a [ 1 ] , b [ 3 ] , c2 , c3 , c1 ) ; r [ 4 ] = c2 ; c2 = 0 ; mul_add_c ( a [ 2 ] , b [ 3 ] , c3 , c1 , c2 ) ; mul_add_c ( a [ 3 ] , b [ 2 ] , c3 , c1 , c2 ) ; r [ 5 ] = c3 ; c3 = 0 ; mul_add_c ( a [ 3 ] , b [ 3 ] , c1 , c2 , c3 ) ; r [ 6 ] = c1 ; r [ 7 ] = c2 ; } "," ) { BN_ULONG c1 , c2 ",openssl@openssl/a7a44ba55cb4f884c6bc9ceac90072dea38e66d0,CVE-2014-3570,https://github.com/openssl/openssl/commit/a7a44ba55cb4f884c6bc9ceac90072dea38e66d0,2015-01-09T02:59Z 126,CWE-834,"CWE-834 static int ivr_read_header ( AVFormatContext * s ) { unsigned tag , type , len , tlen , value ; int i , j , n , count , nb_streams = 0 , ret ; uint8_t key [ 256 ] , val [ 256 ] ; AVIOContext * pb = s -> pb ; AVStream * st ; int64_t pos , offset , temp ; pos = avio_tell ( pb ) ; tag = avio_rl32 ( pb ) ; if ( tag == MKTAG ( '.' , 'R' , '1' , 'M' ) ) { if ( avio_rb16 ( pb ) != 1 ) return AVERROR_INVALIDDATA ; if ( avio_r8 ( pb ) != 1 ) return AVERROR_INVALIDDATA ; len = avio_rb32 ( pb ) ; avio_skip ( pb , len ) ; avio_skip ( pb , 5 ) ; temp = avio_rb64 ( pb ) ; while ( ! avio_feof ( pb ) && temp ) { offset = temp ; temp = avio_rb64 ( pb ) ; } avio_skip ( pb , offset - avio_tell ( pb ) ) ; if ( avio_r8 ( pb ) != 1 ) return AVERROR_INVALIDDATA ; len = avio_rb32 ( pb ) ; avio_skip ( pb , len ) ; if ( avio_r8 ( pb ) != 2 ) return AVERROR_INVALIDDATA ; avio_skip ( pb , 16 ) ; pos = avio_tell ( pb ) ; tag = avio_rl32 ( pb ) ; } if ( tag != MKTAG ( '.' , 'R' , 'E' , 'C' ) ) return AVERROR_INVALIDDATA ; if ( avio_r8 ( pb ) != 0 ) return AVERROR_INVALIDDATA ; count = avio_rb32 ( pb ) ; for ( i = 0 ; i < count ; i ++ ) { if ( avio_feof ( pb ) ) return AVERROR_INVALIDDATA ; type = avio_r8 ( pb ) ; tlen = avio_rb32 ( pb ) ; avio_get_str ( pb , tlen , key , sizeof ( key ) ) ; len = avio_rb32 ( pb ) ; if ( type == 5 ) { avio_get_str ( pb , len , val , sizeof ( val ) ) ; av_log ( s , AV_LOG_DEBUG , ""%s=\'%s\'\\n"" , key , val ) ; } else if ( type == 4 ) { av_log ( s , AV_LOG_DEBUG , ""%s=\'0x"" , key ) ; for ( j = 0 ; j < len ; j ++ ) av_log ( s , AV_LOG_DEBUG , ""%X"" , avio_r8 ( pb ) ) ; av_log ( s , AV_LOG_DEBUG , ""\'\\n"" ) ; } else if ( len == 4 && type == 3 && ! strncmp ( key , ""StreamCount"" , tlen ) ) { nb_streams = value = avio_rb32 ( pb ) ; } else if ( len == 4 && type == 3 ) { value = avio_rb32 ( pb ) ; av_log ( s , AV_LOG_DEBUG , ""%s=%d\\n"" , key , value ) ; } else { av_log ( s , AV_LOG_DEBUG , ""Skippingunsupportedkey:%s\\n"" , key ) ; avio_skip ( pb , len ) ; } } for ( n = 0 ; n < nb_streams ; n ++ ) { st = avformat_new_stream ( s , NULL ) ; if ( ! st ) return AVERROR ( ENOMEM ) ; st -> priv_data = ff_rm_alloc_rmstream ( ) ; if ( ! st -> priv_data ) return AVERROR ( ENOMEM ) ; if ( avio_r8 ( pb ) != 1 ) return AVERROR_INVALIDDATA ; count = avio_rb32 ( pb ) ; for ( i = 0 ; i < count ; i ++ ) { if ( avio_feof ( pb ) ) return AVERROR_INVALIDDATA ; type = avio_r8 ( pb ) ; tlen = avio_rb32 ( pb ) ; avio_get_str ( pb , tlen , key , sizeof ( key ) ) ; len = avio_rb32 ( pb ) ; if ( type == 5 ) { avio_get_str ( pb , len , val , sizeof ( val ) ) ; av_log ( s , AV_LOG_DEBUG , ""%s=\'%s\'\\n"" , key , val ) ; } else if ( type == 4 && ! strncmp ( key , ""OpaqueData"" , tlen ) ) { ret = ffio_ensure_seekback ( pb , 4 ) ; if ( ret < 0 ) return ret ; if ( avio_rb32 ( pb ) == MKBETAG ( 'M' , 'L' , 'T' , 'I' ) ) { ret = rm_read_multi ( s , pb , st , NULL ) ; } else { avio_seek ( pb , - 4 , SEEK_CUR ) ; ret = ff_rm_read_mdpr_codecdata ( s , pb , st , st -> priv_data , len , NULL ) ; } if ( ret < 0 ) return ret ; } else if ( type == 4 ) { int j ; av_log ( s , AV_LOG_DEBUG , ""%s=\'0x"" , key ) ; for ( j = 0 ; j < len ; j ++ ) av_log ( s , AV_LOG_DEBUG , ""%X"" , avio_r8 ( pb ) ) ; av_log ( s , AV_LOG_DEBUG , ""\'\\n"" ) ; } else if ( len == 4 && type == 3 && ! strncmp ( key , ""Duration"" , tlen ) ) { st -> duration = avio_rb32 ( pb ) ; } else if ( len == 4 && type == 3 ) { value = avio_rb32 ( pb ) ; av_log ( s , AV_LOG_DEBUG , ""%s=%d\\n"" , key , value ) ; } else { av_log ( s , AV_LOG_DEBUG , ""Skippingunsupportedkey:%s\\n"" , key ) ; avio_skip ( pb , len ) ; } } } if ( avio_r8 ( pb ) != 6 ) return AVERROR_INVALIDDATA ; avio_skip ( pb , 12 ) ; avio_skip ( pb , avio_rb64 ( pb ) + pos - avio_tell ( s -> pb ) ) ; if ( avio_r8 ( pb ) != 8 ) return AVERROR_INVALIDDATA ; avio_skip ( pb , 8 ) ; return 0 ; } "," j ++ ) { if ( avio_feof ( pb ) ) return AVERROR_INVALIDDATA ; ) ) ; } ",FFmpeg@FFmpeg/124eb202e70678539544f6268efc98131f19fa49,CVE-2017-14054,https://github.com/FFmpeg/FFmpeg/commit/124eb202e70678539544f6268efc98131f19fa49,2017-08-31T15:29Z 127,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 128,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 129,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 130,CWE-119,"CWE-119 void vp9_cyclic_refresh_setup ( VP9_COMP * const cpi ) { VP9_COMMON * const cm = & cpi -> common ; const RATE_CONTROL * const rc = & cpi -> rc ; CYCLIC_REFRESH * const cr = cpi -> cyclic_refresh ; struct segmentation * const seg = & cm -> seg ; unsigned char * const seg_map = cpi -> segmentation_map ; const int apply_cyclic_refresh = apply_cyclic_refresh_bitrate ( cm , rc ) ; if ( ! apply_cyclic_refresh || ( cm -> frame_type == KEY_FRAME ) || ( cpi -> svc . temporal_layer_id > 0 ) ) { vpx_memset ( seg_map , 0 , cm -> mi_rows * cm -> mi_cols ) ; vp9_disable_segmentation ( & cm -> seg ) ; if ( cm -> frame_type == KEY_FRAME ) cr -> sb_index = 0 ; return ; } else { int qindex_delta = 0 ; int i , block_count , bl_index , sb_rows , sb_cols , sbs_in_frame ; int xmis , ymis , x , y , qindex2 ; const float rate_ratio_qdelta = 2.0 ; vp9_clear_system_state ( ) ; cr -> max_sbs_perframe = 10 ; cr -> max_qdelta_perc = 50 ; cr -> min_block_size = BLOCK_8X8 ; cr -> time_for_refresh = 1 ; cr -> thresh_rate_sb = ( rc -> sb64_target_rate * 256 ) >> 2 ; cr -> thresh_dist_sb = 8 * ( int ) ( vp9_convert_qindex_to_q ( cm -> base_qindex ) * vp9_convert_qindex_to_q ( cm -> base_qindex ) ) ; if ( cpi -> sf . use_nonrd_pick_mode ) { cr -> thresh_rate_sb = ( rc -> sb64_target_rate * 256 ) >> 3 ; cr -> thresh_dist_sb = 4 * ( int ) ( vp9_convert_qindex_to_q ( cm -> base_qindex ) * vp9_convert_qindex_to_q ( cm -> base_qindex ) ) ; } cr -> num_seg_blocks = 0 ; vpx_memset ( seg_map , 0 , cm -> mi_rows * cm -> mi_cols ) ; vp9_enable_segmentation ( & cm -> seg ) ; vp9_clearall_segfeatures ( seg ) ; seg -> abs_delta = SEGMENT_DELTADATA ; vp9_disable_segfeature ( seg , 0 , SEG_LVL_ALT_Q ) ; vp9_enable_segfeature ( seg , 1 , SEG_LVL_ALT_Q ) ; qindex_delta = vp9_compute_qdelta_by_rate ( rc , cm -> frame_type , cm -> base_qindex , rate_ratio_qdelta ) ; if ( - qindex_delta > cr -> max_qdelta_perc * cm -> base_qindex / 100 ) qindex_delta = - cr -> max_qdelta_perc * cm -> base_qindex / 100 ; qindex2 = clamp ( cm -> base_qindex + cm -> y_dc_delta_q + qindex_delta , 0 , MAXQ ) ; cr -> rdmult = vp9_compute_rd_mult ( cpi , qindex2 ) ; vp9_set_segdata ( seg , 1 , SEG_LVL_ALT_Q , qindex_delta ) ; sb_cols = ( cm -> mi_cols + MI_BLOCK_SIZE - 1 ) / MI_BLOCK_SIZE ; sb_rows = ( cm -> mi_rows + MI_BLOCK_SIZE - 1 ) / MI_BLOCK_SIZE ; sbs_in_frame = sb_cols * sb_rows ; block_count = cr -> max_sbs_perframe * sbs_in_frame / 100 ; assert ( cr -> sb_index < sbs_in_frame ) ; i = cr -> sb_index ; do { int sum_map = 0 ; int sb_row_index = ( i / sb_cols ) ; int sb_col_index = i - sb_row_index * sb_cols ; int mi_row = sb_row_index * MI_BLOCK_SIZE ; int mi_col = sb_col_index * MI_BLOCK_SIZE ; assert ( mi_row >= 0 && mi_row < cm -> mi_rows ) ; assert ( mi_col >= 0 && mi_col < cm -> mi_cols ) ; bl_index = mi_row * cm -> mi_cols + mi_col ; xmis = MIN ( cm -> mi_cols - mi_col , num_8x8_blocks_wide_lookup [ BLOCK_64X64 ] ) ; ymis = MIN ( cm -> mi_rows - mi_row , num_8x8_blocks_high_lookup [ BLOCK_64X64 ] ) ; for ( y = 0 ; y < ymis ; y ++ ) { for ( x = 0 ; x < xmis ; x ++ ) { const int bl_index2 = bl_index + y * cm -> mi_cols + x ; if ( cr -> map [ bl_index2 ] == 0 ) { seg_map [ bl_index2 ] = 1 ; sum_map ++ ; } else if ( cr -> map [ bl_index2 ] < 0 ) { cr -> map [ bl_index2 ] ++ ; } } } if ( sum_map > 0 && sum_map < xmis * ymis ) { const int new_value = ( sum_map >= xmis * ymis / 2 ) ; for ( y = 0 ; y < ymis ; y ++ ) for ( x = 0 ; x < xmis ; x ++ ) seg_map [ bl_index + y * cm -> mi_cols + x ] = new_value ; } i ++ ; if ( i == sbs_in_frame ) { i = 0 ; } if ( sum_map >= xmis * ymis / 2 ) block_count -- ; } while ( block_count && i != cr -> sb_index ) ; cr -> sb_index = i ; } } "," -> seg ; const int apply_cyclic_refresh , rc ) ; if ( cm -> current_video_frame == 0 ) cr -> low_content_avg = 0.0 > 0 ) || ( cpi -> svc . spatial_layer_id > 0 ) ) { unsigned char * const seg_map = cpi -> segmentation_map ; memset ( seg_map , == KEY_FRAME ) { memset ( cr -> last_coded_q_map , MAXQ , cm -> mi_rows * cm -> mi_cols * sizeof ( * cr -> last_coded_q_map ) ) ; = 0 ; } 0 ; int qindex2 ; const qindex2 ; const double q = vp9_convert_qindex_to_q ( cm -> base_qindex , cm -> bit_depth ) ; vpx_clear_system_state ( ) ; cr -> thresh_rate_sb = ( ( int64_t ) ( rc -> sb64_target_rate ) << 8 ) << 2 ; cr -> thresh_dist_sb = ( ( int64_t ) ( q * q ) ) << 2 ; vp9_enable_segmentation ( & cm -> seg ) ; vp9_clearall_segfeatures ( seg ) ; seg -> abs_delta = SEGMENT_DELTADATA ; vp9_disable_segfeature ( seg , CR_SEGMENT_ID_BASE , SEG_LVL_ALT_Q ) ; vp9_enable_segfeature ( seg , CR_SEGMENT_ID_BOOST1 , SEG_LVL_ALT_Q ) ; vp9_enable_segfeature ( seg , CR_SEGMENT_ID_BOOST2 , SEG_LVL_ALT_Q ) ; qindex_delta = compute_deltaq ( cpi , cm -> base_qindex , cr -> rate_ratio_qdelta ) ; cr -> qindex_delta [ 1 ] = qindex_delta ; qindex2 = ( seg , CR_SEGMENT_ID_BOOST1 , SEG_LVL_ALT_Q , qindex_delta ) ; qindex_delta = compute_deltaq ( cpi , cm -> base_qindex , MIN ( CR_MAX_RATE_TARGET_RATIO , 0.1 * cr -> rate_boost_fac * cr -> rate_ratio_qdelta ) ) ; cr -> qindex_delta [ 2 ] = qindex_delta ; vp9_set_segdata ( seg , CR_SEGMENT_ID_BOOST2 , SEG_LVL_ALT_Q , qindex_delta ) ; cyclic_refresh_update_map ( cpi ) ; } } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 131,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 132,CWE-125,"CWE-125 static void rtc_irq_eoi_tracking_reset ( struct kvm_ioapic * ioapic ) { ioapic -> rtc_status . pending_eoi = 0 ; bitmap_zero ( ioapic -> rtc_status . dest_map . map , KVM_MAX_VCPUS ) ; } "," . map , KVM_MAX_VCPU_ID ) ; } ",torvalds@linux/81cdb259fb6d8c1c4ecfeea389ff5a73c07f5755,CVE-2016-9777,https://github.com/torvalds/linux/commit/81cdb259fb6d8c1c4ecfeea389ff5a73c07f5755,2016-12-28T07:59Z 133,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 134,CWE-772,"CWE-772 static Image * ReadMATImageV4 ( const ImageInfo * image_info , Image * image , ExceptionInfo * exception ) { typedef struct { unsigned char Type [ 4 ] ; unsigned int nRows ; unsigned int nCols ; unsigned int imagf ; unsigned int nameLen ; } MAT4_HDR ; long ldblk ; EndianType endian ; Image * rotate_image ; MagickBooleanType status ; MAT4_HDR HDR ; QuantumInfo * quantum_info ; QuantumFormatType format_type ; register ssize_t i ; ssize_t count , y ; unsigned char * pixels ; unsigned int depth ; ( void ) SeekBlob ( image , 0 , SEEK_SET ) ; while ( EOFBlob ( image ) != MagickFalse ) { ldblk = ReadBlobLSBLong ( image ) ; if ( ( ldblk > 9999 ) || ( ldblk < 0 ) ) break ; HDR . Type [ 3 ] = ldblk % 10 ; ldblk /= 10 ; HDR . Type [ 2 ] = ldblk % 10 ; ldblk /= 10 ; HDR . Type [ 1 ] = ldblk % 10 ; ldblk /= 10 ; HDR . Type [ 0 ] = ldblk ; if ( HDR . Type [ 3 ] != 0 ) break ; if ( HDR . Type [ 2 ] != 0 ) break ; if ( HDR . Type [ 0 ] == 0 ) { HDR . nRows = ReadBlobLSBLong ( image ) ; HDR . nCols = ReadBlobLSBLong ( image ) ; HDR . imagf = ReadBlobLSBLong ( image ) ; HDR . nameLen = ReadBlobLSBLong ( image ) ; endian = LSBEndian ; } else { HDR . nRows = ReadBlobMSBLong ( image ) ; HDR . nCols = ReadBlobMSBLong ( image ) ; HDR . imagf = ReadBlobMSBLong ( image ) ; HDR . nameLen = ReadBlobMSBLong ( image ) ; endian = MSBEndian ; } if ( ( HDR . imagf != 0 ) && ( HDR . imagf != 1 ) ) break ; if ( HDR . nameLen > 0xFFFF ) return ( ( Image * ) NULL ) ; for ( i = 0 ; i < ( ssize_t ) HDR . nameLen ; i ++ ) { int byte ; byte = ReadBlobByte ( image ) ; if ( byte == EOF ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } } image -> columns = ( size_t ) HDR . nRows ; image -> rows = ( size_t ) HDR . nCols ; SetImageColorspace ( image , GRAYColorspace , exception ) ; if ( image_info -> ping != MagickFalse ) { Swap ( image -> columns , image -> rows ) ; return ( image ) ; } status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( ( Image * ) NULL ) ; quantum_info = AcquireQuantumInfo ( image_info , image ) ; if ( quantum_info == ( QuantumInfo * ) NULL ) return ( ( Image * ) NULL ) ; switch ( HDR . Type [ 1 ] ) { case 0 : format_type = FloatingPointQuantumFormat ; depth = 64 ; break ; case 1 : format_type = FloatingPointQuantumFormat ; depth = 32 ; break ; case 2 : format_type = UnsignedQuantumFormat ; depth = 16 ; break ; case 3 : format_type = SignedQuantumFormat ; depth = 16 ; break ; case 4 : format_type = UnsignedQuantumFormat ; depth = 8 ; break ; default : format_type = UnsignedQuantumFormat ; depth = 8 ; break ; } image -> depth = depth ; if ( HDR . Type [ 0 ] != 0 ) SetQuantumEndian ( image , quantum_info , MSBEndian ) ; status = SetQuantumFormat ( image , quantum_info , format_type ) ; status = SetQuantumDepth ( image , quantum_info , depth ) ; status = SetQuantumEndian ( image , quantum_info , endian ) ; SetQuantumScale ( quantum_info , 1.0 ) ; pixels = ( unsigned char * ) GetQuantumPixels ( quantum_info ) ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { int status ; register Quantum * magick_restrict q ; count = ReadBlob ( image , depth / 8 * image -> columns , ( char * ) pixels ) ; if ( count == - 1 ) break ; q = QueueAuthenticPixels ( image , 0 , image -> rows - y - 1 , image -> columns , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) break ; ( void ) ImportQuantumPixels ( image , ( CacheView * ) NULL , quantum_info , GrayQuantum , pixels , exception ) ; if ( ( HDR . Type [ 1 ] == 2 ) || ( HDR . Type [ 1 ] == 3 ) ) FixSignedValues ( image , q , ( int ) image -> columns ) ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } if ( HDR . imagf == 1 ) for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { count = ReadBlob ( image , depth / 8 * image -> columns , ( char * ) pixels ) ; if ( count == - 1 ) break ; if ( HDR . Type [ 1 ] == 0 ) InsertComplexDoubleRow ( image , ( double * ) pixels , y , 0 , 0 , exception ) ; else InsertComplexFloatRow ( image , ( float * ) pixels , y , 0 , 0 , exception ) ; } quantum_info = DestroyQuantumInfo ( quantum_info ) ; rotate_image = RotateImage ( image , 90.0 , exception ) ; if ( rotate_image != ( Image * ) NULL ) { image = DestroyImage ( image ) ; image = rotate_image ; } 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 ; 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 ) ) ; } "," int depth ; quantum_info = ( QuantumInfo * ) NULL ; ) ; } if ( quantum_info != ( QuantumInfo * ) NULL ) ",ImageMagick@ImageMagick/79e5dbcdd1fc2f714f9bae548bc55d5073f3ed20,CVE-2017-13146,https://github.com/ImageMagick/ImageMagick/commit/79e5dbcdd1fc2f714f9bae548bc55d5073f3ed20,2017-08-23T06:29Z 135,CWE-000,"CWE-000 static int powermate_probe ( struct usb_interface * intf , const struct usb_device_id * id ) { struct usb_device * udev = interface_to_usbdev ( intf ) ; struct usb_host_interface * interface ; struct usb_endpoint_descriptor * endpoint ; struct powermate_device * pm ; struct input_dev * input_dev ; int pipe , maxp ; int error = - ENOMEM ; interface = intf -> cur_altsetting ; endpoint = & interface -> endpoint [ 0 ] . desc ; if ( ! usb_endpoint_is_int_in ( endpoint ) ) return - EIO ; usb_control_msg ( udev , usb_sndctrlpipe ( udev , 0 ) , 0x0a , USB_TYPE_CLASS | USB_RECIP_INTERFACE , 0 , interface -> desc . bInterfaceNumber , NULL , 0 , USB_CTRL_SET_TIMEOUT ) ; pm = kzalloc ( sizeof ( struct powermate_device ) , GFP_KERNEL ) ; input_dev = input_allocate_device ( ) ; if ( ! pm || ! input_dev ) goto fail1 ; if ( powermate_alloc_buffers ( udev , pm ) ) goto fail2 ; pm -> irq = usb_alloc_urb ( 0 , GFP_KERNEL ) ; if ( ! pm -> irq ) goto fail2 ; pm -> config = usb_alloc_urb ( 0 , GFP_KERNEL ) ; if ( ! pm -> config ) goto fail3 ; pm -> udev = udev ; pm -> intf = intf ; pm -> input = input_dev ; usb_make_path ( udev , pm -> phys , sizeof ( pm -> phys ) ) ; strlcat ( pm -> phys , ""/input0"" , sizeof ( pm -> phys ) ) ; spin_lock_init ( & pm -> lock ) ; switch ( le16_to_cpu ( udev -> descriptor . idProduct ) ) { case POWERMATE_PRODUCT_NEW : input_dev -> name = pm_name_powermate ; break ; case POWERMATE_PRODUCT_OLD : input_dev -> name = pm_name_soundknob ; break ; default : input_dev -> name = pm_name_soundknob ; printk ( KERN_WARNING ""powermate:unknownproductid%04x\\n"" , le16_to_cpu ( udev -> descriptor . idProduct ) ) ; } input_dev -> phys = pm -> phys ; usb_to_input_id ( udev , & input_dev -> id ) ; input_dev -> dev . parent = & intf -> dev ; input_set_drvdata ( input_dev , pm ) ; input_dev -> event = powermate_input_event ; input_dev -> evbit [ 0 ] = BIT_MASK ( EV_KEY ) | BIT_MASK ( EV_REL ) | BIT_MASK ( EV_MSC ) ; input_dev -> keybit [ BIT_WORD ( BTN_0 ) ] = BIT_MASK ( BTN_0 ) ; input_dev -> relbit [ BIT_WORD ( REL_DIAL ) ] = BIT_MASK ( REL_DIAL ) ; input_dev -> mscbit [ BIT_WORD ( MSC_PULSELED ) ] = BIT_MASK ( MSC_PULSELED ) ; pipe = usb_rcvintpipe ( udev , endpoint -> bEndpointAddress ) ; maxp = usb_maxpacket ( udev , pipe , usb_pipeout ( pipe ) ) ; if ( maxp < POWERMATE_PAYLOAD_SIZE_MIN || maxp > POWERMATE_PAYLOAD_SIZE_MAX ) { printk ( KERN_WARNING ""powermate:Expectedpayloadof%d--%dbytes,found%dbytes!\\n"" , POWERMATE_PAYLOAD_SIZE_MIN , POWERMATE_PAYLOAD_SIZE_MAX , maxp ) ; maxp = POWERMATE_PAYLOAD_SIZE_MAX ; } usb_fill_int_urb ( pm -> irq , udev , pipe , pm -> data , maxp , powermate_irq , pm , endpoint -> bInterval ) ; pm -> irq -> transfer_dma = pm -> data_dma ; pm -> irq -> transfer_flags |= URB_NO_TRANSFER_DMA_MAP ; if ( usb_submit_urb ( pm -> irq , GFP_KERNEL ) ) { error = - EIO ; goto fail4 ; } error = input_register_device ( pm -> input ) ; if ( error ) goto fail5 ; pm -> requires_update = UPDATE_PULSE_ASLEEP | UPDATE_PULSE_AWAKE | UPDATE_PULSE_MODE | UPDATE_STATIC_BRIGHTNESS ; powermate_pulse_led ( pm , 0x80 , 255 , 0 , 1 , 0 ) ; usb_set_intfdata ( intf , pm ) ; return 0 ; fail5 : usb_kill_urb ( pm -> irq ) ; fail4 : usb_free_urb ( pm -> config ) ; fail3 : usb_free_urb ( pm -> irq ) ; fail2 : powermate_free_buffers ( udev , pm ) ; fail1 : input_free_device ( input_dev ) ; kfree ( pm ) ; return error ; } "," intf -> cur_altsetting ; if ( interface -> desc . bNumEndpoints < 1 ) return - EINVAL ",torvalds@linux/9c6ba456711687b794dcf285856fc14e2c76074f,CVE-2016-2186,https://github.com/torvalds/linux/commit/9c6ba456711687b794dcf285856fc14e2c76074f,2016-05-02T10:59Z 136,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 137,CWE-400,"CWE-400 static int simulate_llsc ( struct pt_regs * regs , unsigned int opcode ) { if ( ( opcode & OPCODE ) == LL ) { perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , 0 ) ; return simulate_ll ( regs , opcode ) ; } if ( ( opcode & OPCODE ) == SC ) { perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , 0 ) ; return simulate_sc ( regs , opcode ) ; } return - 1 ; } "," PERF_COUNT_SW_EMULATION_FAULTS , 1 , regs , , 1 , regs , 0 ",torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,CVE-2011-2918,https://github.com/torvalds/linux/commit/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,2012-05-24T23:55Z 138,CWE-20,"CWE-20 int main ( int argc , char * * argv ) { mode_t old_umask ; cleanup_free char * base_path = NULL ; int clone_flags ; char * old_cwd = NULL ; pid_t pid ; int event_fd = - 1 ; int child_wait_fd = - 1 ; int setup_finished_pipe [ ] = { - 1 , - 1 } ; const char * new_cwd ; uid_t ns_uid ; gid_t ns_gid ; struct stat sbuf ; uint64_t val ; int res UNUSED ; cleanup_free char * seccomp_data = NULL ; size_t seccomp_len ; struct sock_fprog seccomp_prog ; cleanup_free char * args_data = NULL ; if ( argc == 2 && ( strcmp ( argv [ 1 ] , ""--version"" ) == 0 ) ) print_version_and_exit ( ) ; real_uid = getuid ( ) ; real_gid = getgid ( ) ; acquire_privs ( ) ; if ( prctl ( PR_SET_NO_NEW_PRIVS , 1 , 0 , 0 , 0 ) < 0 ) die_with_error ( ""prctl(PR_SET_NO_NEW_CAPS)failed"" ) ; read_overflowids ( ) ; argv0 = argv [ 0 ] ; if ( isatty ( 1 ) ) host_tty_dev = ttyname ( 1 ) ; argv ++ ; argc -- ; if ( argc == 0 ) usage ( EXIT_FAILURE , stderr ) ; parse_args ( & argc , ( const char * * * ) & argv ) ; args_data = opt_args_data ; opt_args_data = NULL ; if ( ( requested_caps [ 0 ] || requested_caps [ 1 ] ) && is_privileged ) die ( ""--cap-addinsetuidmodecanbeusedonlybyroot"" ) ; if ( opt_userns_block_fd != - 1 && ! opt_unshare_user ) die ( ""--userns-block-fdrequires--unshare-user"" ) ; if ( opt_userns_block_fd != - 1 && opt_info_fd == - 1 ) die ( ""--userns-block-fdrequires--info-fd"" ) ; if ( ! is_privileged && getuid ( ) != 0 ) opt_unshare_user = TRUE ; # ifdef ENABLE_REQUIRE_USERNS if ( is_privileged && getuid ( ) != 0 ) opt_unshare_user = TRUE ; # endif if ( opt_unshare_user_try && stat ( ""/proc/self/ns/user"" , & sbuf ) == 0 ) { bool disabled = FALSE ; if ( stat ( ""/sys/module/user_namespace/parameters/enable"" , & sbuf ) == 0 ) { cleanup_free char * enable = NULL ; enable = load_file_at ( AT_FDCWD , ""/sys/module/user_namespace/parameters/enable"" ) ; if ( enable != NULL && enable [ 0 ] == 'N' ) disabled = TRUE ; } if ( stat ( ""/proc/sys/user/max_user_namespaces"" , & sbuf ) == 0 ) { cleanup_free char * max_user_ns = NULL ; max_user_ns = load_file_at ( AT_FDCWD , ""/proc/sys/user/max_user_namespaces"" ) ; if ( max_user_ns != NULL && strcmp ( max_user_ns , ""0\\n"" ) == 0 ) disabled = TRUE ; } if ( ! disabled ) opt_unshare_user = TRUE ; } if ( argc == 0 ) usage ( EXIT_FAILURE , stderr ) ; __debug__ ( ( ""Creatingrootmountpoint\\n"" ) ) ; if ( opt_sandbox_uid == - 1 ) opt_sandbox_uid = real_uid ; if ( opt_sandbox_gid == - 1 ) opt_sandbox_gid = real_gid ; if ( ! opt_unshare_user && opt_sandbox_uid != real_uid ) die ( ""Specifying--uidrequires--unshare-user"" ) ; if ( ! opt_unshare_user && opt_sandbox_gid != real_gid ) die ( ""Specifying--gidrequires--unshare-user"" ) ; if ( ! opt_unshare_uts && opt_sandbox_hostname != NULL ) die ( ""Specifying--hostnamerequires--unshare-uts"" ) ; if ( opt_as_pid_1 && ! opt_unshare_pid ) die ( ""Specifying--as-pid-1requires--unshare-pid"" ) ; if ( opt_as_pid_1 && lock_files != NULL ) die ( ""Specifying--as-pid-1and--lock-fileisnotpermitted"" ) ; proc_fd = open ( ""/proc"" , O_PATH ) ; if ( proc_fd == - 1 ) die_with_error ( ""Can\'topen/proc"" ) ; base_path = xasprintf ( ""/run/user/%d/.bubblewrap"" , real_uid ) ; if ( ensure_dir ( base_path , 0755 ) ) { free ( base_path ) ; base_path = xasprintf ( ""/tmp/.bubblewrap-%d"" , real_uid ) ; if ( ensure_dir ( base_path , 0755 ) ) die_with_error ( ""Creatingrootmountpointfailed"" ) ; } __debug__ ( ( ""creatingnewnamespace\\n"" ) ) ; if ( opt_unshare_pid && ! opt_as_pid_1 ) { event_fd = eventfd ( 0 , EFD_CLOEXEC | EFD_NONBLOCK ) ; if ( event_fd == - 1 ) die_with_error ( ""eventfd()"" ) ; } block_sigchild ( ) ; clone_flags = SIGCHLD | CLONE_NEWNS ; if ( opt_unshare_user ) clone_flags |= CLONE_NEWUSER ; if ( opt_unshare_pid ) clone_flags |= CLONE_NEWPID ; if ( opt_unshare_net ) clone_flags |= CLONE_NEWNET ; if ( opt_unshare_ipc ) clone_flags |= CLONE_NEWIPC ; if ( opt_unshare_uts ) clone_flags |= CLONE_NEWUTS ; if ( opt_unshare_cgroup ) { if ( stat ( ""/proc/self/ns/cgroup"" , & sbuf ) ) { if ( errno == ENOENT ) die ( ""Cannotcreatenewcgroupnamespacebecausethekerneldoesnotsupportit"" ) ; else die_with_error ( ""staton/proc/self/ns/cgroupfailed"" ) ; } clone_flags |= CLONE_NEWCGROUP ; } if ( opt_unshare_cgroup_try ) if ( ! stat ( ""/proc/self/ns/cgroup"" , & sbuf ) ) clone_flags |= CLONE_NEWCGROUP ; child_wait_fd = eventfd ( 0 , EFD_CLOEXEC ) ; if ( child_wait_fd == - 1 ) die_with_error ( ""eventfd()"" ) ; if ( opt_json_status_fd != - 1 ) { int ret ; ret = pipe2 ( setup_finished_pipe , O_CLOEXEC ) ; if ( ret == - 1 ) die_with_error ( ""pipe2()"" ) ; } pid = raw_clone ( clone_flags , NULL ) ; if ( pid == - 1 ) { if ( opt_unshare_user ) { if ( errno == EINVAL ) die ( ""Creatingnewnamespacefailed,likelybecausethekerneldoesnotsupportusernamespaces.bwrapmustbeinstalledsetuidonsuchsystems."" ) ; else if ( errno == EPERM && ! is_privileged ) die ( ""Nopermissionstocreatingnewnamespace,likelybecausethekerneldoesnotallownon-privilegedusernamespaces.One.g.debianthiscanbeenabledwith\'sysctlkernel.unprivileged_userns_clone=1\'."" ) ; } die_with_error ( ""Creatingnewnamespacefailed"" ) ; } ns_uid = opt_sandbox_uid ; ns_gid = opt_sandbox_gid ; if ( pid != 0 ) { if ( is_privileged && opt_unshare_user && opt_userns_block_fd == - 1 ) { write_uid_gid_map ( ns_uid , real_uid , ns_gid , real_gid , pid , TRUE , opt_needs_devpts ) ; } drop_privs ( FALSE ) ; handle_die_with_parent ( ) ; if ( opt_info_fd != - 1 ) { cleanup_free char * output = xasprintf ( ""{\\n\\""child-pid\\"":%i\\n}\\n"" , pid ) ; dump_info ( opt_info_fd , output , TRUE ) ; close ( opt_info_fd ) ; } if ( opt_json_status_fd != - 1 ) { cleanup_free char * output = xasprintf ( ""{\\""child-pid\\"":%i}\\n"" , pid ) ; dump_info ( opt_json_status_fd , output , TRUE ) ; } if ( opt_userns_block_fd != - 1 ) { char b [ 1 ] ; ( void ) TEMP_FAILURE_RETRY ( read ( opt_userns_block_fd , b , 1 ) ) ; close ( opt_userns_block_fd ) ; } val = 1 ; res = write ( child_wait_fd , & val , 8 ) ; close ( child_wait_fd ) ; return monitor_child ( event_fd , pid , setup_finished_pipe [ 0 ] ) ; } if ( opt_info_fd != - 1 ) close ( opt_info_fd ) ; if ( opt_json_status_fd != - 1 ) close ( opt_json_status_fd ) ; res = read ( child_wait_fd , & val , 8 ) ; close ( child_wait_fd ) ; switch_to_user_with_privs ( ) ; if ( opt_unshare_net ) loopback_setup ( ) ; ns_uid = opt_sandbox_uid ; ns_gid = opt_sandbox_gid ; if ( ! is_privileged && opt_unshare_user && opt_userns_block_fd == - 1 ) { if ( opt_needs_devpts ) { ns_uid = 0 ; ns_gid = 0 ; } write_uid_gid_map ( ns_uid , real_uid , ns_gid , real_gid , - 1 , TRUE , FALSE ) ; } old_umask = umask ( 0 ) ; resolve_symlinks_in_ops ( ) ; if ( mount ( NULL , ""/"" , NULL , MS_SLAVE | MS_REC , NULL ) < 0 ) die_with_error ( ""Failedtomake/slave"" ) ; if ( mount ( ""tmpfs"" , base_path , ""tmpfs"" , MS_NODEV | MS_NOSUID , NULL ) != 0 ) die_with_error ( ""Failedtomounttmpfs"" ) ; old_cwd = get_current_dir_name ( ) ; if ( chdir ( base_path ) != 0 ) die_with_error ( ""chdirbase_path"" ) ; if ( mkdir ( ""newroot"" , 0755 ) ) die_with_error ( ""Creatingnewrootfailed"" ) ; if ( mount ( ""newroot"" , ""newroot"" , NULL , MS_MGC_VAL | MS_BIND | MS_REC , NULL ) < 0 ) die_with_error ( ""settingupnewrootbind"" ) ; if ( mkdir ( ""oldroot"" , 0755 ) ) die_with_error ( ""Creatingoldrootfailed"" ) ; if ( pivot_root ( base_path , ""oldroot"" ) ) die_with_error ( ""pivot_root"" ) ; if ( chdir ( ""/"" ) != 0 ) die_with_error ( ""chdir/(basepath)"" ) ; if ( is_privileged ) { pid_t child ; int privsep_sockets [ 2 ] ; if ( socketpair ( AF_UNIX , SOCK_SEQPACKET | SOCK_CLOEXEC , 0 , privsep_sockets ) != 0 ) die_with_error ( ""Can\'tcreateprivsepsocket"" ) ; child = fork ( ) ; if ( child == - 1 ) die_with_error ( ""Can\'tforkunprivilegedhelper"" ) ; if ( child == 0 ) { drop_privs ( FALSE ) ; close ( privsep_sockets [ 0 ] ) ; setup_newroot ( opt_unshare_pid , privsep_sockets [ 1 ] ) ; exit ( 0 ) ; } else { int status ; uint32_t buffer [ 2048 ] ; uint32_t op , flags ; const char * arg1 , * arg2 ; cleanup_fd int unpriv_socket = - 1 ; unpriv_socket = privsep_sockets [ 0 ] ; close ( privsep_sockets [ 1 ] ) ; do { op = read_priv_sec_op ( unpriv_socket , buffer , sizeof ( buffer ) , & flags , & arg1 , & arg2 ) ; privileged_op ( - 1 , op , flags , arg1 , arg2 ) ; if ( write ( unpriv_socket , buffer , 1 ) != 1 ) die ( ""Can\'twritetoop_socket"" ) ; } while ( op != PRIV_SEP_OP_DONE ) ; waitpid ( child , & status , 0 ) ; } } else { setup_newroot ( opt_unshare_pid , - 1 ) ; } close_ops_fd ( ) ; if ( mount ( ""oldroot"" , ""oldroot"" , NULL , MS_REC | MS_PRIVATE , NULL ) != 0 ) die_with_error ( ""Failedtomakeoldrootrprivate"" ) ; if ( umount2 ( ""oldroot"" , MNT_DETACH ) ) die_with_error ( ""unmountoldroot"" ) ; { cleanup_fd int oldrootfd = open ( ""/"" , O_DIRECTORY | O_RDONLY ) ; if ( oldrootfd < 0 ) die_with_error ( ""can\'topen/"" ) ; if ( chdir ( ""/newroot"" ) != 0 ) die_with_error ( ""chdir/newroot"" ) ; if ( pivot_root ( ""."" , ""."" ) != 0 ) die_with_error ( ""pivot_root(/newroot)"" ) ; if ( fchdir ( oldrootfd ) < 0 ) die_with_error ( ""fchdirtooldroot"" ) ; if ( umount2 ( ""."" , MNT_DETACH ) < 0 ) die_with_error ( ""umountoldroot"" ) ; if ( chdir ( ""/"" ) != 0 ) die_with_error ( ""chdir/"" ) ; } if ( opt_unshare_user && ( ns_uid != opt_sandbox_uid || ns_gid != opt_sandbox_gid ) && opt_userns_block_fd == - 1 ) { if ( unshare ( CLONE_NEWUSER ) ) die_with_error ( ""unshareuserns"" ) ; write_uid_gid_map ( opt_sandbox_uid , ns_uid , opt_sandbox_gid , ns_gid , - 1 , FALSE , FALSE ) ; } drop_privs ( ! is_privileged ) ; if ( opt_block_fd != - 1 ) { char b [ 1 ] ; ( void ) TEMP_FAILURE_RETRY ( read ( opt_block_fd , b , 1 ) ) ; close ( opt_block_fd ) ; } if ( opt_seccomp_fd != - 1 ) { seccomp_data = load_file_data ( opt_seccomp_fd , & seccomp_len ) ; if ( seccomp_data == NULL ) die_with_error ( ""Can\'treadseccompdata"" ) ; if ( seccomp_len % 8 != 0 ) die ( ""Invalidseccompdata,mustbemultipleof8"" ) ; seccomp_prog . len = seccomp_len / 8 ; seccomp_prog . filter = ( struct sock_filter * ) seccomp_data ; close ( opt_seccomp_fd ) ; } umask ( old_umask ) ; new_cwd = ""/"" ; if ( opt_chdir_path ) { if ( chdir ( opt_chdir_path ) ) die_with_error ( ""Can\'tchdirto%s"" , opt_chdir_path ) ; new_cwd = opt_chdir_path ; } else if ( chdir ( old_cwd ) == 0 ) { new_cwd = old_cwd ; } else { const char * home = getenv ( ""HOME"" ) ; if ( home != NULL && chdir ( home ) == 0 ) new_cwd = home ; } xsetenv ( ""PWD"" , new_cwd , 1 ) ; free ( old_cwd ) ; if ( opt_new_session && setsid ( ) == ( pid_t ) - 1 ) die_with_error ( ""setsid"" ) ; if ( label_exec ( opt_exec_label ) == - 1 ) die_with_error ( ""label_exec%s"" , argv [ 0 ] ) ; __debug__ ( ( ""forkingforchild\\n"" ) ) ; if ( ! opt_as_pid_1 && ( opt_unshare_pid || lock_files != NULL || opt_sync_fd != - 1 ) ) { pid = fork ( ) ; if ( pid == - 1 ) die_with_error ( ""Can\'tforkforpid1"" ) ; if ( pid != 0 ) { drop_all_caps ( FALSE ) ; { int dont_close [ 3 ] ; int j = 0 ; if ( event_fd != - 1 ) dont_close [ j ++ ] = event_fd ; if ( opt_sync_fd != - 1 ) dont_close [ j ++ ] = opt_sync_fd ; dont_close [ j ++ ] = - 1 ; fdwalk ( proc_fd , close_extra_fds , dont_close ) ; } return do_init ( event_fd , pid , seccomp_data != NULL ? & seccomp_prog : NULL ) ; } } __debug__ ( ( ""launchexecutable%s\\n"" , argv [ 0 ] ) ) ; if ( proc_fd != - 1 ) close ( proc_fd ) ; if ( ! opt_as_pid_1 ) { if ( opt_sync_fd != - 1 ) close ( opt_sync_fd ) ; } unblock_sigchild ( ) ; handle_die_with_parent ( ) ; if ( ! is_privileged ) set_ambient_capabilities ( ) ; if ( seccomp_data != NULL && prctl ( PR_SET_SECCOMP , SECCOMP_MODE_FILTER , & seccomp_prog ) != 0 ) die_with_error ( ""prctl(PR_SET_SECCOMP)"" ) ; if ( setup_finished_pipe [ 1 ] != - 1 ) { char data = 0 ; res = write_to_fd ( setup_finished_pipe [ 1 ] , & data , 1 ) ; } if ( execvp ( argv [ 0 ] , argv ) == - 1 ) { if ( setup_finished_pipe [ 1 ] != - 1 ) { int saved_errno = errno ; char data = 0 ; res = write_to_fd ( setup_finished_pipe [ 1 ] , & data , 1 ) ; errno = saved_errno ; } die_with_error ( ""execvp%s"" , argv [ 0 ] ) ; } return 0 ; } "," mode_t old_umask ; const char * base_path ; base_path = ""/tmp"" ; __debug__ ( ( ",projectatomic@bubblewrap/efc89e3b939b4bde42c10f065f6b7b02958ed50e,CVE-2019-12439,https://github.com/projectatomic/bubblewrap/commit/efc89e3b939b4bde42c10f065f6b7b02958ed50e,2019-05-29T15:29Z 139,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 140,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 141,CWE-404,"CWE-404 void nlmsvc_grant_reply ( struct nlm_cookie * cookie , __be32 status ) { struct nlm_block * block ; dprintk ( ""grant_reply:lookingforcookie%x,s=%d\\n"" , * ( unsigned int * ) ( cookie -> data ) , status ) ; if ( ! ( block = nlmsvc_find_block ( cookie ) ) ) return ; if ( block ) { if ( status == nlm_lck_denied_grace_period ) { nlmsvc_insert_block ( block , 10 * HZ ) ; } else { nlmsvc_unlink_block ( block ) ; } } nlmsvc_release_block ( block ) ; } "," ; if ( status == nlm_lck_denied_grace_period ) ; } nlmsvc_release_block ( block ",torvalds@linux/c70422f760c120480fee4de6c38804c72aa26bc1,CVE-2017-9059,https://github.com/torvalds/linux/commit/c70422f760c120480fee4de6c38804c72aa26bc1,2017-05-18T06:29Z 142,CWE-264,"CWE-264 static int hfsplus_readdir ( struct file * filp , void * dirent , filldir_t filldir ) { struct inode * inode = filp -> f_path . dentry -> d_inode ; struct super_block * sb = inode -> i_sb ; int len , err ; char strbuf [ HFSPLUS_MAX_STRLEN + 1 ] ; hfsplus_cat_entry entry ; struct hfs_find_data fd ; struct hfsplus_readdir_data * rd ; u16 type ; if ( filp -> f_pos >= inode -> i_size ) return 0 ; err = hfs_find_init ( HFSPLUS_SB ( sb ) -> cat_tree , & fd ) ; if ( err ) return err ; hfsplus_cat_build_key ( sb , fd . search_key , inode -> i_ino , NULL ) ; err = hfs_brec_find ( & fd ) ; if ( err ) goto out ; switch ( ( u32 ) filp -> f_pos ) { case 0 : if ( filldir ( dirent , ""."" , 1 , 0 , inode -> i_ino , DT_DIR ) ) goto out ; filp -> f_pos ++ ; case 1 : hfs_bnode_read ( fd . bnode , & entry , fd . entryoffset , fd . entrylength ) ; if ( be16_to_cpu ( entry . type ) != HFSPLUS_FOLDER_THREAD ) { printk ( KERN_ERR ""hfs:badcatalogfolderthread\\n"" ) ; err = - EIO ; goto out ; } if ( fd . entrylength < HFSPLUS_MIN_THREAD_SZ ) { printk ( KERN_ERR ""hfs:truncatedcatalogthread\\n"" ) ; err = - EIO ; goto out ; } if ( filldir ( dirent , "".."" , 2 , 1 , be32_to_cpu ( entry . thread . parentID ) , DT_DIR ) ) goto out ; filp -> f_pos ++ ; default : if ( filp -> f_pos >= inode -> i_size ) goto out ; err = hfs_brec_goto ( & fd , filp -> f_pos - 1 ) ; if ( err ) goto out ; } for ( ; ; ) { if ( be32_to_cpu ( fd . key -> cat . parent ) != inode -> i_ino ) { printk ( KERN_ERR ""hfs:walkedpastendofdir\\n"" ) ; err = - EIO ; goto out ; } hfs_bnode_read ( fd . bnode , & entry , fd . entryoffset , fd . entrylength ) ; type = be16_to_cpu ( entry . type ) ; len = HFSPLUS_MAX_STRLEN ; err = hfsplus_uni2asc ( sb , & fd . key -> cat . name , strbuf , & len ) ; if ( err ) goto out ; if ( type == HFSPLUS_FOLDER ) { if ( fd . entrylength < sizeof ( struct hfsplus_cat_folder ) ) { printk ( KERN_ERR ""hfs:smalldirentry\\n"" ) ; err = - EIO ; goto out ; } if ( HFSPLUS_SB ( sb ) -> hidden_dir && HFSPLUS_SB ( sb ) -> hidden_dir -> i_ino == be32_to_cpu ( entry . folder . id ) ) goto next ; if ( filldir ( dirent , strbuf , len , filp -> f_pos , be32_to_cpu ( entry . folder . id ) , DT_DIR ) ) break ; } else if ( type == HFSPLUS_FILE ) { if ( fd . entrylength < sizeof ( struct hfsplus_cat_file ) ) { printk ( KERN_ERR ""hfs:smallfileentry\\n"" ) ; err = - EIO ; goto out ; } if ( filldir ( dirent , strbuf , len , filp -> f_pos , be32_to_cpu ( entry . file . id ) , DT_REG ) ) break ; } else { printk ( KERN_ERR ""hfs:badcatalogentrytype\\n"" ) ; err = - EIO ; goto out ; } next : filp -> f_pos ++ ; if ( filp -> f_pos >= inode -> i_size ) goto out ; err = hfs_brec_goto ( & fd , 1 ) ; if ( err ) goto out ; } rd = filp -> private_data ; if ( ! rd ) { rd = kmalloc ( sizeof ( struct hfsplus_readdir_data ) , GFP_KERNEL ) ; if ( ! rd ) { err = - ENOMEM ; goto out ; } filp -> private_data = rd ; rd -> file = filp ; list_add ( & rd -> list , & HFSPLUS_I ( inode ) -> open_dir_list ) ; } memcpy ( & rd -> key , fd . key , sizeof ( struct hfsplus_cat_key ) ) ; out : hfs_find_exit ( & fd ) ; return err ; } "," case 1 : if ( fd . entrylength > sizeof ( entry ) || fd . entrylength < 0 ) { err = - EIO ; goto out ; } out ; } if ( fd . entrylength > sizeof ( entry ) || fd . entrylength < 0 ) { err = - EIO ; goto out ; } ",torvalds@linux/6f24f892871acc47b40dd594c63606a17c714f77,CVE-2012-2319,https://github.com/torvalds/linux/commit/6f24f892871acc47b40dd594c63606a17c714f77,2012-05-17T11:00Z 143,CWE-190,"CWE-190 static int jpc_dec_process_siz ( jpc_dec_t * dec , jpc_ms_t * ms ) { jpc_siz_t * siz = & ms -> parms . siz ; int compno ; int tileno ; jpc_dec_tile_t * tile ; jpc_dec_tcomp_t * tcomp ; int htileno ; int vtileno ; jpc_dec_cmpt_t * cmpt ; dec -> xstart = siz -> xoff ; dec -> ystart = siz -> yoff ; dec -> xend = siz -> width ; dec -> yend = siz -> height ; dec -> tilewidth = siz -> tilewidth ; dec -> tileheight = siz -> tileheight ; dec -> tilexoff = siz -> tilexoff ; dec -> tileyoff = siz -> tileyoff ; dec -> numcomps = siz -> numcomps ; if ( ! ( dec -> cp = jpc_dec_cp_create ( dec -> numcomps ) ) ) { return - 1 ; } if ( ! ( dec -> cmpts = jas_alloc2 ( dec -> numcomps , sizeof ( jpc_dec_cmpt_t ) ) ) ) { return - 1 ; } for ( compno = 0 , cmpt = dec -> cmpts ; compno < dec -> numcomps ; ++ compno , ++ cmpt ) { cmpt -> prec = siz -> comps [ compno ] . prec ; cmpt -> sgnd = siz -> comps [ compno ] . sgnd ; cmpt -> hstep = siz -> comps [ compno ] . hsamp ; cmpt -> vstep = siz -> comps [ compno ] . vsamp ; cmpt -> width = JPC_CEILDIV ( dec -> xend , cmpt -> hstep ) - JPC_CEILDIV ( dec -> xstart , cmpt -> hstep ) ; cmpt -> height = JPC_CEILDIV ( dec -> yend , cmpt -> vstep ) - JPC_CEILDIV ( dec -> ystart , cmpt -> vstep ) ; cmpt -> hsubstep = 0 ; cmpt -> vsubstep = 0 ; } dec -> image = 0 ; dec -> numhtiles = JPC_CEILDIV ( dec -> xend - dec -> tilexoff , dec -> tilewidth ) ; dec -> numvtiles = JPC_CEILDIV ( dec -> yend - dec -> tileyoff , dec -> tileheight ) ; dec -> numtiles = dec -> numhtiles * dec -> numvtiles ; JAS_DBGLOG ( 10 , ( ""numtiles=%d;numhtiles=%d;numvtiles=%d;\\n"" , dec -> numtiles , dec -> numhtiles , dec -> numvtiles ) ) ; if ( ! ( dec -> tiles = jas_alloc2 ( dec -> numtiles , sizeof ( jpc_dec_tile_t ) ) ) ) { return - 1 ; } for ( tileno = 0 , tile = dec -> tiles ; tileno < dec -> numtiles ; ++ tileno , ++ tile ) { htileno = tileno % dec -> numhtiles ; vtileno = tileno / dec -> numhtiles ; tile -> realmode = 0 ; tile -> state = JPC_TILE_INIT ; tile -> xstart = JAS_MAX ( dec -> tilexoff + htileno * dec -> tilewidth , dec -> xstart ) ; tile -> ystart = JAS_MAX ( dec -> tileyoff + vtileno * dec -> tileheight , dec -> ystart ) ; tile -> xend = JAS_MIN ( dec -> tilexoff + ( htileno + 1 ) * dec -> tilewidth , dec -> xend ) ; tile -> yend = JAS_MIN ( dec -> tileyoff + ( vtileno + 1 ) * dec -> tileheight , dec -> yend ) ; tile -> numparts = 0 ; tile -> partno = 0 ; tile -> pkthdrstream = 0 ; tile -> pkthdrstreampos = 0 ; tile -> pptstab = 0 ; tile -> cp = 0 ; tile -> pi = 0 ; if ( ! ( tile -> tcomps = jas_alloc2 ( dec -> numcomps , sizeof ( jpc_dec_tcomp_t ) ) ) ) { return - 1 ; } for ( compno = 0 , cmpt = dec -> cmpts , tcomp = tile -> tcomps ; compno < dec -> numcomps ; ++ compno , ++ cmpt , ++ tcomp ) { tcomp -> rlvls = 0 ; tcomp -> numrlvls = 0 ; tcomp -> data = 0 ; tcomp -> xstart = JPC_CEILDIV ( tile -> xstart , cmpt -> hstep ) ; tcomp -> ystart = JPC_CEILDIV ( tile -> ystart , cmpt -> vstep ) ; tcomp -> xend = JPC_CEILDIV ( tile -> xend , cmpt -> hstep ) ; tcomp -> yend = JPC_CEILDIV ( tile -> yend , cmpt -> vstep ) ; tcomp -> tsfb = 0 ; } } dec -> pkthdrstreams = 0 ; dec -> state = JPC_MH ; return 0 ; } "," * cmpt ; size_t size ; tileheight ) ; if ( ! jas_safe_size_mul ( dec -> numhtiles dec -> numhtiles , dec -> numvtiles dec -> numvtiles , & size ) ) { 1 ; } dec -> numtiles = size ; JAS_DBGLOG ( 10 , ( ""numtiles=%d;numhtiles=%d;numvtiles=%d;\\n"" , dec -> numtiles , dec -> numhtiles , dec -> numvtiles ) ) ; if ( ! ( dec -> tiles = jas_alloc2 ( dec -> numtiles , sizeof ( jpc_dec_tile_t ) ) ) ) { return - 1 ; } ",mdadams@jasper/d91198abd00fc435a397fe6bad906a4c1748e9cf,CVE-2016-9387,https://github.com/mdadams/jasper/commit/d91198abd00fc435a397fe6bad906a4c1748e9cf,2017-03-23T18:59Z 144,CWE-200,"CWE-200 static int ccid3_hc_tx_getsockopt ( struct sock * sk , const int optname , int len , u32 __user * optval , int __user * optlen ) { const struct ccid3_hc_tx_sock * hc = ccid3_hc_tx_sk ( sk ) ; struct tfrc_tx_info tfrc ; const void * val ; switch ( optname ) { case DCCP_SOCKOPT_CCID_TX_INFO : if ( len < sizeof ( tfrc ) ) return - EINVAL ; tfrc . tfrctx_x = hc -> tx_x ; tfrc . tfrctx_x_recv = hc -> tx_x_recv ; tfrc . tfrctx_x_calc = hc -> tx_x_calc ; tfrc . tfrctx_rtt = hc -> tx_rtt ; tfrc . tfrctx_p = hc -> tx_p ; tfrc . tfrctx_rto = hc -> tx_t_rto ; tfrc . tfrctx_ipi = hc -> tx_t_ipi ; len = sizeof ( tfrc ) ; val = & tfrc ; break ; default : return - ENOPROTOOPT ; } if ( put_user ( len , optlen ) || copy_to_user ( optval , val , len ) ) return - EFAULT ; return 0 ; } "," - EINVAL ; memset ( & tfrc , 0 , sizeof ( tfrc ) ) ; ",torvalds@linux/7b07f8eb75aa3097cdfd4f6eac3da49db787381d,CVE-2012-6541,https://github.com/torvalds/linux/commit/7b07f8eb75aa3097cdfd4f6eac3da49db787381d,2013-03-15T20:55Z 145,CWE-617,"CWE-617 struct lldpd_mgmt * lldpd_alloc_mgmt ( int family , void * addrptr , size_t addrsize , u_int32_t iface ) { struct lldpd_mgmt * mgmt ; log_debug ( ""alloc"" , ""allocateanewmanagementaddress(family:%d)"" , family ) ; if ( family <= LLDPD_AF_UNSPEC || family >= LLDPD_AF_LAST ) { errno = EAFNOSUPPORT ; return NULL ; } if ( addrsize > LLDPD_MGMT_MAXADDRSIZE ) { errno = EOVERFLOW ; return NULL ; } mgmt = calloc ( 1 , sizeof ( struct lldpd_mgmt ) ) ; if ( mgmt == NULL ) { errno = ENOMEM ; return NULL ; } mgmt -> m_family = family ; assert ( addrsize <= LLDPD_MGMT_MAXADDRSIZE ) ; memcpy ( & mgmt -> m_addr , addrptr , addrsize ) ; mgmt -> m_addrsize = addrsize ; mgmt -> m_iface = iface ; return mgmt ; } "," = family ; memcpy ( & ",vincentbernat@lldpd/793526f8884455f43daecd0a2c46772388417a00,CVE-2015-8012,https://github.com/vincentbernat/lldpd/commit/793526f8884455f43daecd0a2c46772388417a00,2020-01-28T19:15Z 146,CWE-476,"CWE-476 static int jp2_pclr_getdata ( jp2_box_t * box , jas_stream_t * in ) { jp2_pclr_t * pclr = & box -> data . pclr ; int lutsize ; unsigned int i ; unsigned int j ; int_fast32_t x ; pclr -> lutdata = 0 ; if ( jp2_getuint16 ( in , & pclr -> numlutents ) || jp2_getuint8 ( in , & pclr -> numchans ) ) { return - 1 ; } lutsize = pclr -> numlutents * pclr -> numchans ; if ( ! ( pclr -> lutdata = jas_alloc2 ( lutsize , sizeof ( int_fast32_t ) ) ) ) { return - 1 ; } if ( ! ( pclr -> bpc = jas_alloc2 ( pclr -> numchans , sizeof ( uint_fast8_t ) ) ) ) { return - 1 ; } for ( i = 0 ; i < pclr -> numchans ; ++ i ) { if ( jp2_getuint8 ( in , & pclr -> bpc [ i ] ) ) { return - 1 ; } } for ( i = 0 ; i < pclr -> numlutents ; ++ i ) { for ( j = 0 ; j < pclr -> numchans ; ++ j ) { if ( jp2_getint ( in , ( pclr -> bpc [ j ] & 0x80 ) != 0 , ( pclr -> bpc [ j ] & 0x7f ) + 1 , & x ) ) { return - 1 ; } pclr -> lutdata [ i * pclr -> numchans + j ] = x ; } } return 0 ; } "," = 0 ; pclr -> bpc = 0 ; ",mdadams@jasper/e96fc4fdd525fa0ede28074a7e2b1caf94b58b0d,CVE-2017-6850,https://github.com/mdadams/jasper/commit/e96fc4fdd525fa0ede28074a7e2b1caf94b58b0d,2017-03-15T14:59Z 147,CWE-119,"CWE-119 void vp9_fht4x4_c ( const int16_t * input , int16_t * output , int stride , int tx_type ) { if ( tx_type == DCT_DCT ) { vp9_fdct4x4_c ( input , output , stride ) ; } else { int16_t out [ 4 * 4 ] ; int16_t * outptr = & out [ 0 ] ; int i , j ; int16_t temp_in [ 4 ] , temp_out [ 4 ] ; const transform_2d ht = FHT_4 [ tx_type ] ; for ( i = 0 ; i < 4 ; ++ i ) { for ( j = 0 ; j < 4 ; ++ j ) temp_in [ j ] = input [ j * stride + i ] * 16 ; if ( i == 0 && temp_in [ 0 ] ) temp_in [ 0 ] += 1 ; ht . cols ( temp_in , temp_out ) ; for ( j = 0 ; j < 4 ; ++ j ) outptr [ j * 4 + i ] = temp_out [ j ] ; } for ( i = 0 ; i < 4 ; ++ i ) { for ( j = 0 ; j < 4 ; ++ j ) temp_in [ j ] = out [ j + i * 4 ] ; ht . rows ( temp_in , temp_out ) ; for ( j = 0 ; j < 4 ; ++ j ) output [ j + i * 4 ] = ( temp_out [ j ] + 1 ) >> 2 ; } } } "," * input , tran_low_t * output , DCT_DCT ) { vpx_fdct4x4_c ( input , } else { tran_low_t out [ 4 4 ] ; int i , , j ; tran_low_t temp_in [ 4 ++ j ) out [ j * ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 148,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 149,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 150,CWE-20,"CWE-20 static int mxf_read_primer_pack ( void * arg , AVIOContext * pb , int tag , int size , UID uid , int64_t klv_offset ) { MXFContext * mxf = arg ; int item_num = avio_rb32 ( pb ) ; int item_len = avio_rb32 ( pb ) ; if ( item_len != 18 ) { avpriv_request_sample ( pb , ""Primerpackitemlength%d"" , item_len ) ; return AVERROR_PATCHWELCOME ; } if ( item_num > 65536 ) { av_log ( mxf -> fc , AV_LOG_ERROR , ""item_num%distoolarge\\n"" , item_num ) ; return AVERROR_INVALIDDATA ; } if ( mxf -> local_tags ) av_log ( mxf -> fc , AV_LOG_VERBOSE , ""Multipleprimerpacks\\n"" ) ; av_free ( mxf -> local_tags ) ; mxf -> local_tags_count = 0 ; mxf -> local_tags = av_calloc ( item_num , item_len ) ; if ( ! mxf -> local_tags ) return AVERROR ( ENOMEM ) ; mxf -> local_tags_count = item_num ; avio_read ( pb , mxf -> local_tags , item_num * item_len ) ; return 0 ; } "," item_num > 65536 || item_num < 0 ",FFmpeg@FFmpeg/9d00fb9d70ee8c0cc7002b89318c5be00f1bbdad,CVE-2017-14169,https://github.com/FFmpeg/FFmpeg/commit/9d00fb9d70ee8c0cc7002b89318c5be00f1bbdad,2017-09-07T06:29Z 151,CWE-787,"CWE-787 l_int32 gplotMakeOutput ( GPLOT * gplot ) { char buf [ L_BUF_SIZE ] ; char * cmdname ; l_int32 ignore ; PROCNAME ( ""gplotMakeOutput"" ) ; if ( ! gplot ) return ERROR_INT ( ""gplotnotdefined"" , procName , 1 ) ; gplotGenCommandFile ( gplot ) ; gplotGenDataFiles ( gplot ) ; cmdname = genPathname ( gplot -> cmdname , NULL ) ; # ifndef _WIN32 snprintf ( buf , L_BUF_SIZE , ""gnuplot%s"" , cmdname ) ; # else snprintf ( buf , L_BUF_SIZE , ""wgnuplot%s"" , cmdname ) ; # endif # ifndef OS_IOS ignore = system ( buf ) ; # endif LEPT_FREE ( cmdname ) ; return 0 ; } "," char buf [ L_BUFSIZE ] ; char ( buf , L_BUFSIZE , ""gnuplot%s"" , ( buf , L_BUFSIZE , ""wgnuplot%s"" , ",DanBloomberg@leptonica/ee301cb2029db8a6289c5295daa42bba7715e99a,CVE-2018-7186,https://github.com/DanBloomberg/leptonica/commit/ee301cb2029db8a6289c5295daa42bba7715e99a,2018-02-16T16:29Z 152,CWE-119,"CWE-119 static void videobuf_vm_close ( struct vm_area_struct * vma ) { struct videobuf_mapping * map = vma -> vm_private_data ; struct videobuf_queue * q = map -> q ; int i ; dprintk ( 2 , ""vm_close%p[count=%d,vma=%08lx-%08lx]\\n"" , map , map -> count , vma -> vm_start , vma -> vm_end ) ; map -> count -- ; if ( 0 == map -> count ) { dprintk ( 1 , ""munmap%pq=%p\\n"" , map , q ) ; mutex_lock ( & q -> lock ) ; for ( i = 0 ; i < VIDEO_MAX_FRAME ; i ++ ) { if ( NULL == q -> bufs [ i ] ) continue ; if ( q -> bufs [ i ] -> map != map ) continue ; q -> ops -> buf_release ( q , q -> bufs [ i ] ) ; q -> bufs [ i ] -> map = NULL ; q -> bufs [ i ] -> baddr = 0 ; } mutex_unlock ( & q -> lock ) ; kfree ( map ) ; } return ; } "," ( 2 , ""vm_close%p[count=%u,vma=%08lx-%08lx]\\n"" , map , ",torvalds@linux/0b29669c065f60501e7289e1950fa2a618962358,CVE-2007-6761,https://github.com/torvalds/linux/commit/0b29669c065f60501e7289e1950fa2a618962358,2017-04-24T06:59Z 153,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 154,CWE-119,"CWE-119 static const char * parse_array ( cJSON * item , const char * value ) { cJSON * child ; if ( * value != '[' ) { ep = value ; return 0 ; } item -> type = cJSON_Array ; value = skip ( value + 1 ) ; if ( * value == ']' ) return value + 1 ; if ( ! ( item -> child = child = cJSON_New_Item ( ) ) ) return 0 ; if ( ! ( value = skip ( parse_value ( child , skip ( value ) ) ) ) ) return 0 ; while ( * value == ',' ) { cJSON * new_item ; if ( ! ( new_item = cJSON_New_Item ( ) ) ) return 0 ; child -> next = new_item ; new_item -> prev = child ; child = new_item ; if ( ! ( value = skip ( parse_value ( child , skip ( value + 1 ) ) ) ) ) return 0 ; } if ( * value == ']' ) return value + 1 ; ep = value ; return 0 ; } "," char * value , const char * * ep '[' ) { * ep = value ; return 0 ; } item -> == ']' ) return value + 1 ; item -> child cJSON_New_Item ( ) ; if ( ! item -> child ) return 0 ; value = skip ( value ) , ep ) ) ; if ( ! value ) return 0 ; = child ; child = new_item ; value = skip + 1 ) , ep ) ) ; if ( ! value ) return 0 ; == ']' ) return value + 1 ; * ep = value ; return 0 ; ",esnet@iperf/91f2fa59e8ed80dfbf400add0164ee0e508e412a,CVE-2016-4303,https://github.com/esnet/iperf/commit/91f2fa59e8ed80dfbf400add0164ee0e508e412a,2016-09-26T14:59Z 155,CWE-77,"CWE-77 int run_cmd ( int fd , ... ) { pid_t pid ; sigset_t sigm , sigm_old ; sigemptyset ( & sigm ) ; sigaddset ( & sigm , SIGTERM ) ; sigprocmask ( SIG_BLOCK , & sigm , & sigm_old ) ; pid = fork ( ) ; if ( pid < 0 ) { sigprocmask ( SIG_SETMASK , & sigm_old , NULL ) ; fd_printf ( STO , ""***cannotfork:%s***\\r\\n"" , strerror ( errno ) ) ; return - 1 ; } else if ( pid ) { int status , r ; sigprocmask ( SIG_SETMASK , & sigm_old , NULL ) ; do { r = waitpid ( pid , & status , 0 ) ; } while ( r < 0 && errno == EINTR ) ; term_apply ( STI ) ; if ( WIFEXITED ( status ) ) { fd_printf ( STO , ""\\r\\n***exitstatus:%d***\\r\\n"" , WEXITSTATUS ( status ) ) ; return WEXITSTATUS ( status ) ; } else if ( WIFSIGNALED ( status ) ) { fd_printf ( STO , ""\\r\\n***killedbysignal:%d***\\r\\n"" , WTERMSIG ( status ) ) ; return - 1 ; } else { fd_printf ( STO , ""\\r\\n***abnormaltermination:0x%x***\\r\\n"" , r ) ; return - 1 ; } } else { long fl ; char cmd [ 512 ] ; term_remove ( STI ) ; term_erase ( fd ) ; fl = fcntl ( fd , F_GETFL ) ; fl &= ~ O_NONBLOCK ; fcntl ( fd , F_SETFL , fl ) ; close ( STI ) ; close ( STO ) ; dup2 ( fd , STI ) ; dup2 ( fd , STO ) ; { char * c , * ce ; const char * s ; int n ; va_list vls ; strcpy ( cmd , EXEC ) ; c = & cmd [ sizeof ( EXEC ) - 1 ] ; ce = cmd + sizeof ( cmd ) - 1 ; va_start ( vls , fd ) ; while ( ( s = va_arg ( vls , const char * ) ) ) { n = strlen ( s ) ; if ( c + n + 1 >= ce ) break ; memcpy ( c , s , n ) ; c += n ; * c ++ = '' ; } va_end ( vls ) ; * c = '\\0' ; } fd_printf ( STDERR_FILENO , ""%s\\n"" , & cmd [ sizeof ( EXEC ) - 1 ] ) ; establish_child_signal_handlers ( ) ; sigprocmask ( SIG_SETMASK , & sigm_old , NULL ) ; execl ( ""/bin/sh"" , ""sh"" , ""-c"" , cmd , NULL ) ; exit ( 42 ) ; } } "," int fd , const char * cmd , const char * args_extra ) { pid_t long fl ; int argc ; char * argv [ RUNCMD_ARGS_MAX + 1 ] ; int r ; term_remove ( STO ) ; argc = 0 ; r = split_quoted ( cmd , ( cmd , & argc , argv , RUNCMD_ARGS_MAX ) ; if ( r < 0 ) { fd_printf ( STDERR_FILENO , ""Cannotparsecommand\\n"" ) ; exit ( RUNCMD_EXEC_FAIL ) ; } r = split_quoted ( args_extra , & argc , argv , RUNCMD_ARGS_MAX ) ; if ( r < 0 ) { fd_printf ( STDERR_FILENO , ""Cannotparseextraargs\\n"" ) ; exit ( RUNCMD_EXEC_FAIL ) ; } if ( argc < 1 ) { fd_printf ( STDERR_FILENO , ""Nocommandgiven\\n"" ) ; exit ( RUNCMD_EXEC_FAIL ) ; } argv [ argc ] = NULL ; fd_printf ( STDERR_FILENO , ""$%s%s\\n"" , cmd , args_extra ) ; establish_child_signal_handlers ( ) ; sigprocmask ( SIG_SETMASK , & sigm_old , NULL ) ; execvp ( argv [ 0 ] , argv ) ; fd_printf ( STDERR_FILENO ( STDERR_FILENO , ""exec:%s\\n"" , strerror ( errno ) ) ; exit ; exit ( RUNCMD_EXEC_FAIL ) ; } ",npat-efault@picocom/1ebc60b20fbe9a02436d5cbbf8951714e749ddb1,CVE-2015-9059,https://github.com/npat-efault/picocom/commit/1ebc60b20fbe9a02436d5cbbf8951714e749ddb1,2017-05-28T00:29Z 156,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 157,CWE-399,"CWE-399 static struct kioctx * ioctx_alloc ( unsigned nr_events ) { struct mm_struct * mm = current -> mm ; struct kioctx * ctx ; int err = - ENOMEM ; nr_events = max ( nr_events , num_possible_cpus ( ) * 4 ) ; nr_events *= 2 ; if ( ( nr_events > ( 0x10000000U / sizeof ( struct io_event ) ) ) || ( nr_events > ( 0x10000000U / sizeof ( struct kiocb ) ) ) ) { pr_debug ( ""ENOMEM:nr_eventstoohigh\\n"" ) ; return ERR_PTR ( - EINVAL ) ; } if ( ! nr_events || ( unsigned long ) nr_events > ( aio_max_nr * 2UL ) ) return ERR_PTR ( - EAGAIN ) ; ctx = kmem_cache_zalloc ( kioctx_cachep , GFP_KERNEL ) ; if ( ! ctx ) return ERR_PTR ( - ENOMEM ) ; ctx -> max_reqs = nr_events ; if ( percpu_ref_init ( & ctx -> users , free_ioctx_users ) ) goto err ; if ( percpu_ref_init ( & ctx -> reqs , free_ioctx_reqs ) ) goto err ; spin_lock_init ( & ctx -> ctx_lock ) ; spin_lock_init ( & ctx -> completion_lock ) ; mutex_init ( & ctx -> ring_lock ) ; init_waitqueue_head ( & ctx -> wait ) ; INIT_LIST_HEAD ( & ctx -> active_reqs ) ; ctx -> cpu = alloc_percpu ( struct kioctx_cpu ) ; if ( ! ctx -> cpu ) goto err ; if ( aio_setup_ring ( ctx ) < 0 ) goto err ; atomic_set ( & ctx -> reqs_available , ctx -> nr_events - 1 ) ; ctx -> req_batch = ( ctx -> nr_events - 1 ) / ( num_possible_cpus ( ) * 4 ) ; if ( ctx -> req_batch < 1 ) ctx -> req_batch = 1 ; spin_lock ( & aio_nr_lock ) ; if ( aio_nr + nr_events > ( aio_max_nr * 2UL ) || aio_nr + nr_events < aio_nr ) { spin_unlock ( & aio_nr_lock ) ; err = - EAGAIN ; goto err ; } aio_nr += ctx -> max_reqs ; spin_unlock ( & aio_nr_lock ) ; percpu_ref_get ( & ctx -> users ) ; err = ioctx_add_table ( ctx , mm ) ; if ( err ) goto err_cleanup ; pr_debug ( ""allocatedioctx%p[%ld]:mm=%pmask=0x%x\\n"" , ctx , ctx -> user_id , mm , ctx -> nr_events ) ; return ctx ; err_cleanup : aio_nr_sub ( ctx -> max_reqs ) ; err : aio_free_ring ( ctx ) ; free_percpu ( ctx -> cpu ) ; free_percpu ( ctx -> reqs . pcpu_count ) ; free_percpu ( ctx -> users . pcpu_count ) ; kmem_cache_free ( kioctx_cachep , ctx ) ; pr_debug ( ""errorallocatingioctx%d\\n"" , err ) ; return ERR_PTR ( err ) ; } "," ; err : free_percpu ( ctx ",torvalds@linux/d558023207e008a4476a3b7bb8706b2a2bf5d84f,CVE-2013-7348,https://github.com/torvalds/linux/commit/d558023207e008a4476a3b7bb8706b2a2bf5d84f,2014-04-01T06:35Z 158,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 -> 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 ; } "," } if ( siz -> tilexoff >= siz -> width || siz -> tileyoff >= siz -> height ) { jas_eprintf ( ""alltilesareoutsidetheimagearea\\n"" ) ; return - 1 ; } if ( ",mdadams@jasper/ba2b9d000660313af7b692542afbd374c5685865,CVE-2016-9390,https://github.com/mdadams/jasper/commit/ba2b9d000660313af7b692542afbd374c5685865,2017-03-23T18:59Z 159,CWE-362,"CWE-362 static ssize_t driver_override_store ( struct device * dev , struct device_attribute * attr , const char * buf , size_t count ) { struct platform_device * pdev = to_platform_device ( dev ) ; char * driver_override , * old = pdev -> driver_override , * cp ; if ( count > PATH_MAX ) return - EINVAL ; driver_override = kstrndup ( buf , count , GFP_KERNEL ) ; if ( ! driver_override ) return - ENOMEM ; cp = strchr ( driver_override , '\\n' ) ; if ( cp ) * cp = '\\0' ; if ( strlen ( driver_override ) ) { pdev -> driver_override = driver_override ; } else { kfree ( driver_override ) ; pdev -> driver_override = NULL ; } kfree ( old ) ; return count ; } "," , * old , * cp = '\\0' ; device_lock ( dev ) ; old = pdev -> driver_override ; NULL ; } device_unlock ( dev ) ; ",torvalds@linux/6265539776a0810b7ce6398c27866ddb9c6bd154,CVE-2017-12146,https://github.com/torvalds/linux/commit/6265539776a0810b7ce6398c27866ddb9c6bd154,2017-09-08T19:29Z 160,CWE-119,"CWE-119 static gboolean parse_cosine_packet ( FILE_T fh , struct wtap_pkthdr * phdr , Buffer * buf , char * line , int * err , gchar * * err_info ) { union wtap_pseudo_header * pseudo_header = & phdr -> pseudo_header ; int num_items_scanned ; int yy , mm , dd , hr , min , sec , csec ; guint pkt_len ; int pro , off , pri , rm , error ; guint code1 , code2 ; char if_name [ COSINE_MAX_IF_NAME_LEN ] = """" , direction [ 6 ] = """" ; struct tm tm ; guint8 * pd ; int i , hex_lines , n , caplen = 0 ; if ( sscanf ( line , ""%4d-%2d-%2d,%2d:%2d:%2d.%9d:"" , & yy , & mm , & dd , & hr , & min , & sec , & csec ) == 7 ) { num_items_scanned = sscanf ( line , ""%4d-%2d-%2d,%2d:%2d:%2d.%9d:%5s(%127[A-Za-z0-9/:]),Length:%9u,Pro:%9d,Off:%9d,Pri:%9d,RM:%9d,Err:%9d[%8x,%8x]"" , & yy , & mm , & dd , & hr , & min , & sec , & csec , direction , if_name , & pkt_len , & pro , & off , & pri , & rm , & error , & code1 , & code2 ) ; if ( num_items_scanned != 17 ) { * err = WTAP_ERR_BAD_FILE ; * err_info = g_strdup ( ""cosine:purportedcontrolbladelinedoesn\'thavecodevalues"" ) ; return FALSE ; } } else { num_items_scanned = sscanf ( line , ""%5s(%127[A-Za-z0-9/:]),Length:%9u,Pro:%9d,Off:%9d,Pri:%9d,RM:%9d,Err:%9d[%8x,%8x]"" , direction , if_name , & pkt_len , & pro , & off , & pri , & rm , & error , & code1 , & code2 ) ; if ( num_items_scanned != 10 ) { * err = WTAP_ERR_BAD_FILE ; * err_info = g_strdup ( ""cosine:headerlineisneithercontrolbladenorPEoutput"" ) ; return FALSE ; } yy = mm = dd = hr = min = sec = csec = 0 ; } if ( pkt_len > WTAP_MAX_PACKET_SIZE ) { * err = WTAP_ERR_BAD_FILE ; * err_info = g_strdup_printf ( ""cosine: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 ; tm . tm_year = yy - 1900 ; tm . tm_mon = mm - 1 ; tm . tm_mday = dd ; tm . tm_hour = hr ; tm . tm_min = min ; tm . tm_sec = sec ; tm . tm_isdst = - 1 ; phdr -> ts . secs = mktime ( & tm ) ; phdr -> ts . nsecs = csec * 10000000 ; phdr -> len = pkt_len ; if ( strncmp ( if_name , ""TEST:"" , 5 ) == 0 ) { pseudo_header -> cosine . encap = COSINE_ENCAP_TEST ; } else if ( strncmp ( if_name , ""PPoATM:"" , 7 ) == 0 ) { pseudo_header -> cosine . encap = COSINE_ENCAP_PPoATM ; } else if ( strncmp ( if_name , ""PPoFR:"" , 6 ) == 0 ) { pseudo_header -> cosine . encap = COSINE_ENCAP_PPoFR ; } else if ( strncmp ( if_name , ""ATM:"" , 4 ) == 0 ) { pseudo_header -> cosine . encap = COSINE_ENCAP_ATM ; } else if ( strncmp ( if_name , ""FR:"" , 3 ) == 0 ) { pseudo_header -> cosine . encap = COSINE_ENCAP_FR ; } else if ( strncmp ( if_name , ""HDLC:"" , 5 ) == 0 ) { pseudo_header -> cosine . encap = COSINE_ENCAP_HDLC ; } else if ( strncmp ( if_name , ""PPP:"" , 4 ) == 0 ) { pseudo_header -> cosine . encap = COSINE_ENCAP_PPP ; } else if ( strncmp ( if_name , ""ETH:"" , 4 ) == 0 ) { pseudo_header -> cosine . encap = COSINE_ENCAP_ETH ; } else { pseudo_header -> cosine . encap = COSINE_ENCAP_UNKNOWN ; } if ( strncmp ( direction , ""l2-tx"" , 5 ) == 0 ) { pseudo_header -> cosine . direction = COSINE_DIR_TX ; } else if ( strncmp ( direction , ""l2-rx"" , 5 ) == 0 ) { pseudo_header -> cosine . direction = COSINE_DIR_RX ; } g_strlcpy ( pseudo_header -> cosine . if_name , if_name , COSINE_MAX_IF_NAME_LEN ) ; pseudo_header -> cosine . pro = pro ; pseudo_header -> cosine . off = off ; pseudo_header -> cosine . pri = pri ; pseudo_header -> cosine . rm = rm ; pseudo_header -> cosine . err = error ; 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 , COSINE_LINE_LENGTH , fh ) == NULL ) { * err = file_error ( fh , err_info ) ; if ( * err == 0 ) { * err = WTAP_ERR_SHORT_READ ; } return FALSE ; } if ( empty_line ( line ) ) { break ; } if ( ( n = parse_single_hex_dump_line ( line , pd , i * 16 ) ) == - 1 ) { * err = WTAP_ERR_BAD_FILE ; * err_info = g_strdup ( ""cosine:hexdumplinedoesn\'thave16numbers"" ) ; return FALSE ; } caplen += n ; } phdr -> caplen = caplen ; return TRUE ; } "," sec , csec , pkt_len ; int ( line , ""%4d-%2d-%2d,%2d:%2d:%2d.%9d:%5s(%127[A-Za-z0-9/:]),Length:%9d,Pro:%9d,Off:%9d,Pri:%9d,RM:%9d,Err:%9d[%8x,%8x]"" , & yy ( line , ""%5s(%127[A-Za-z0-9/:]),Length:%9d,Pro:%9d,Off:%9d,Pri:%9d,RM:%9d,Err:%9d[%8x,%8x]"" , direction , csec = 0 ; } if ( pkt_len < 0 ) { * err = WTAP_ERR_BAD_FILE ; * err_info = g_strdup ( ""cosine:packetheaderhasanegativepacketlength"" ) ; return FALSE ",wireshark@wireshark/a66628e425db725df1ac52a3c573a03357060ddd,CVE-2016-5356,https://github.com/wireshark/wireshark/commit/a66628e425db725df1ac52a3c573a03357060ddd,2016-08-07T16:59Z 161,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 162,CWE-59,"CWE-59 int main ( int argc , char * * argv ) { setlocale ( LC_ALL , """" ) ; # if ENABLE_NLS bindtextdomain ( PACKAGE , LOCALEDIR ) ; textdomain ( PACKAGE ) ; # endif abrt_init ( argv ) ; const char * program_usage_string = _ ( ""&[-y][-iBUILD_IDS_FILE|-i-][-ePATH[:PATH]...]\\n"" ""\\t[-rREPO]\\n"" ""\\n"" ""Installsdebuginfopackagesforallbuild-idslistedinBUILD_IDS_FILEto\\n"" ""ABRTsystemcache."" ) ; enum { OPT_v = 1 << 0 , OPT_y = 1 << 1 , OPT_i = 1 << 2 , OPT_e = 1 << 3 , OPT_r = 1 << 4 , OPT_s = 1 << 5 , } ; const char * build_ids = ""build_ids"" ; const char * exact = NULL ; const char * repo = NULL ; const char * size_mb = NULL ; struct options program_options [ ] = { OPT__VERBOSE ( & g_verbose ) , OPT_BOOL ( 'y' , ""yes"" , NULL , _ ( ""Noninteractive,assume\'Yes\'toallquestions"" ) ) , OPT_STRING ( 'i' , ""ids"" , & build_ids , ""BUILD_IDS_FILE"" , _ ( ""-meansSTDIN,default:build_ids"" ) ) , OPT_STRING ( 'e' , ""exact"" , & exact , ""EXACT"" , _ ( ""Downloadonlyspecifiedfiles"" ) ) , OPT_STRING ( 'r' , ""repo"" , & repo , ""REPO"" , _ ( ""Patterntousewhensearchingforrepos,default:*debug*"" ) ) , OPT_STRING ( 's' , ""size_mb"" , & size_mb , ""SIZE_MB"" , _ ( ""Ignoredoption"" ) ) , OPT_END ( ) } ; const unsigned opts = parse_opts ( argc , argv , program_options , program_usage_string ) ; const gid_t egid = getegid ( ) ; const gid_t rgid = getgid ( ) ; const uid_t euid = geteuid ( ) ; const gid_t ruid = getuid ( ) ; char * build_ids_self_fd = NULL ; if ( strcmp ( ""-"" , build_ids ) != 0 ) { if ( setregid ( egid , rgid ) < 0 ) perror_msg_and_die ( ""setregid(egid,rgid)"" ) ; if ( setreuid ( euid , ruid ) < 0 ) perror_msg_and_die ( ""setreuid(euid,ruid)"" ) ; const int build_ids_fd = open ( build_ids , O_RDONLY ) ; if ( setregid ( rgid , egid ) < 0 ) perror_msg_and_die ( ""setregid(rgid,egid)"" ) ; if ( setreuid ( ruid , euid ) < 0 ) perror_msg_and_die ( ""setreuid(ruid,euid)"" ) ; if ( build_ids_fd < 0 ) perror_msg_and_die ( ""Failedtoopenfile\'%s\'"" , build_ids ) ; build_ids_self_fd = xasprintf ( ""/proc/self/fd/%d"" , build_ids_fd ) ; } const char * args [ 11 ] ; { const char * verbs [ ] = { """" , ""-v"" , ""-vv"" , ""-vvv"" } ; unsigned i = 0 ; args [ i ++ ] = EXECUTABLE ; args [ i ++ ] = ""--ids"" ; args [ i ++ ] = ( build_ids_self_fd != NULL ) ? build_ids_self_fd : ""-"" ; if ( g_verbose > 0 ) args [ i ++ ] = verbs [ g_verbose <= 3 ? g_verbose : 3 ] ; if ( ( opts & OPT_y ) ) args [ i ++ ] = ""-y"" ; if ( ( opts & OPT_e ) ) { args [ i ++ ] = ""--exact"" ; args [ i ++ ] = exact ; } if ( ( opts & OPT_r ) ) { args [ i ++ ] = ""--repo"" ; args [ i ++ ] = repo ; } args [ i ++ ] = ""--"" ; args [ i ] = NULL ; } if ( egid != rgid ) IGNORE_RESULT ( setregid ( egid , egid ) ) ; if ( euid != ruid ) { IGNORE_RESULT ( setreuid ( euid , euid ) ) ; # if 1 static const char * whitelist [ ] = { ""REPORT_CLIENT_SLAVE"" , ""LANG"" , } ; const size_t wlsize = sizeof ( whitelist ) / sizeof ( char * ) ; char * setlist [ sizeof ( whitelist ) / sizeof ( char * ) ] = { 0 } ; char * p = NULL ; for ( size_t i = 0 ; i < wlsize ; i ++ ) if ( ( p = getenv ( whitelist [ i ] ) ) != NULL ) setlist [ i ] = xstrdup ( p ) ; clearenv ( ) ; for ( size_t i = 0 ; i < wlsize ; i ++ ) if ( setlist [ i ] != NULL ) { xsetenv ( whitelist [ i ] , setlist [ i ] ) ; free ( setlist [ i ] ) ; } # else static const char forbid [ ] = ""LD_LIBRARY_PATH"" ""\\0"" ""LD_PRELOAD"" ""\\0"" ""LD_TRACE_LOADED_OBJECTS"" ""\\0"" ""LD_BIND_NOW"" ""\\0"" ""LD_AOUT_LIBRARY_PATH"" ""\\0"" ""LD_AOUT_PRELOAD"" ""\\0"" ""LD_NOWARN"" ""\\0"" ""LD_KEEPDIR"" ""\\0"" ; const char * p = forbid ; do { unsetenv ( p ) ; p += strlen ( p ) + 1 ; } while ( * p ) ; # endif char path_env [ ] = ""PATH=/usr/sbin:/sbin:/usr/bin:/bin:"" BIN_DIR "":"" SBIN_DIR ; if ( euid != 0 ) strcpy ( path_env , ""PATH=/usr/bin:/bin:"" BIN_DIR ) ; putenv ( path_env ) ; umask ( 0022 ) ; } execvp ( EXECUTABLE , ( char * * ) args ) ; error_msg_and_die ( ""Can\'texecute%s"" , EXECUTABLE ) ; } "," ) ; } char tmp_directory [ ] = LARGE_DATA_TMP_DIR ""/abrt-tmp-debuginfo.XXXXXX"" ; if ( mkdtemp ( tmp_directory ) == NULL ) perror_msg_and_die ( ""Failedtocreateworkingdirectory"" ) ; log_info ( ""Createdworkingdirectory:%s"" , tmp_directory ) ; const char * args [ 13 ] ; { ++ ] = ""--tmpdir"" ; args [ i ++ ] = tmp_directory ; args [ i ++ ] = ) ; } pid_t pid = fork ( ) ; if ( pid < 0 ) perror_msg_and_die ( ""fork"" ) ; if ( pid == 0 ) { ) ; } int status ; if ( safe_waitpid ( pid , & status , 0 ) < 0 ) perror_msg_and_die ( ""waitpid"" ) ; if ( rmdir ( tmp_directory ) >= 0 ) log_info ( ""Removedworkingdirectory:%s"" , tmp_directory ) ; else if ( errno != ENOENT ) perror_msg ( ""Failedtoremoveworkingdirectory"" ) ; if ( WIFEXITED ( status ) ) return WEXITSTATUS ( status ) ; if ( WIFSIGNALED ( status ) ) error_msg_and_die ( ""Childterminatedwithsignal%d"" , WTERMSIG ( status ) ) ; error_msg_and_die ( ""Childexitfailed"" ) ; } ",abrt@abrt/50ee8130fb4cd4ef1af7682a2c85dd99cb99424e,CVE-2015-5273,https://github.com/abrt/abrt/commit/50ee8130fb4cd4ef1af7682a2c85dd99cb99424e,2015-12-07T18:59Z 163,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 164,CWE-284,"CWE-284 static int ndp_sock_recv ( struct ndp * ndp ) { struct ndp_msg * msg ; enum ndp_msg_type msg_type ; size_t len ; int err ; msg = ndp_msg_alloc ( ) ; if ( ! msg ) return - ENOMEM ; len = ndp_msg_payload_maxlen ( msg ) ; err = myrecvfrom6 ( ndp -> sock , msg -> buf , & len , 0 , & msg -> addrto , & msg -> ifindex ) ; if ( err ) { err ( ndp , ""Failedtoreceivemessage"" ) ; goto free_msg ; } dbg ( ndp , ""rcvdfrom:%s,ifindex:%u"" , str_in6_addr ( & msg -> addrto ) , msg -> ifindex ) ; if ( len < sizeof ( * msg -> icmp6_hdr ) ) { warn ( ndp , ""rcvdicmp6packettooshort(%luB)"" , len ) ; err = 0 ; goto free_msg ; } err = ndp_msg_type_by_raw_type ( & msg_type , msg -> icmp6_hdr -> icmp6_type ) ; if ( err ) { err = 0 ; goto free_msg ; } ndp_msg_init ( msg , msg_type ) ; ndp_msg_payload_len_set ( msg , len ) ; if ( ! ndp_msg_check_valid ( msg ) ) { warn ( ndp , ""rcvdinvalidNDmessage"" ) ; err = 0 ; goto free_msg ; } dbg ( ndp , ""rcvd%s,len:%zuB"" , ndp_msg_type_info ( msg_type ) -> strabbr , len ) ; if ( ! ndp_msg_check_opts ( msg ) ) { err = 0 ; goto free_msg ; } err = ndp_call_handlers ( ndp , msg ) ; ; free_msg : ndp_msg_destroy ( msg ) ; return err ; } "," msg -> ifindex , & msg -> hoplimit ( ndp , ""rcvdfrom:%s,ifindex:%u,hoplimit:%d"" , str_in6_addr ( msg -> ifindex , msg -> hoplimit ) ; if ( msg -> hoplimit != 255 ) { warn ( ndp , ""ignoringpacketwithbadhoplimit(%d)"" , msg -> hoplimit ) ; err = 0 ; goto free_msg ; } if ( len ",jpirko@libndp/a4892df306e0532487f1634ba6d4c6d4bb381c7f,CVE-2016-3698,https://github.com/jpirko/libndp/commit/a4892df306e0532487f1634ba6d4c6d4bb381c7f,2016-06-13T19:59Z 165,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 166,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 167,CWE-119,"CWE-119 static MB_PREDICTION_MODE read_intra_mode ( vp9_reader * r , const vp9_prob * p ) { return ( MB_PREDICTION_MODE ) vp9_read_tree ( r , vp9_intra_mode_tree , p ) ; } "," static PREDICTION_MODE read_intra_mode ( vpx_reader * r , r , const vpx_prob * p ) { return ( PREDICTION_MODE ) vpx_read_tree ( r , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 168,CWE-119,"CWE-119 static int create_qp_common ( struct mlx5_ib_dev * dev , struct ib_pd * pd , struct ib_qp_init_attr * init_attr , struct ib_udata * udata , struct mlx5_ib_qp * qp ) { struct mlx5_ib_resources * devr = & dev -> devr ; int inlen = MLX5_ST_SZ_BYTES ( create_qp_in ) ; struct mlx5_core_dev * mdev = dev -> mdev ; struct mlx5_ib_create_qp_resp resp ; struct mlx5_ib_cq * send_cq ; struct mlx5_ib_cq * recv_cq ; unsigned long flags ; u32 uidx = MLX5_IB_DEFAULT_UIDX ; struct mlx5_ib_create_qp ucmd ; struct mlx5_ib_qp_base * base ; int mlx5_st ; void * qpc ; u32 * in ; int err ; mutex_init ( & qp -> mutex ) ; spin_lock_init ( & qp -> sq . lock ) ; spin_lock_init ( & qp -> rq . lock ) ; mlx5_st = to_mlx5_st ( init_attr -> qp_type ) ; if ( mlx5_st < 0 ) return - EINVAL ; if ( init_attr -> rwq_ind_tbl ) { if ( ! udata ) return - ENOSYS ; err = create_rss_raw_qp_tir ( dev , qp , pd , init_attr , udata ) ; return err ; } if ( init_attr -> create_flags & IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK ) { if ( ! MLX5_CAP_GEN ( mdev , block_lb_mc ) ) { mlx5_ib_dbg ( dev , ""blockmulticastloopbackisn\'tsupported\\n"" ) ; return - EINVAL ; } else { qp -> flags |= MLX5_IB_QP_BLOCK_MULTICAST_LOOPBACK ; } } if ( init_attr -> create_flags & ( IB_QP_CREATE_CROSS_CHANNEL | IB_QP_CREATE_MANAGED_SEND | IB_QP_CREATE_MANAGED_RECV ) ) { if ( ! MLX5_CAP_GEN ( mdev , cd ) ) { mlx5_ib_dbg ( dev , ""cross-channelisn\'tsupported\\n"" ) ; return - EINVAL ; } if ( init_attr -> create_flags & IB_QP_CREATE_CROSS_CHANNEL ) qp -> flags |= MLX5_IB_QP_CROSS_CHANNEL ; if ( init_attr -> create_flags & IB_QP_CREATE_MANAGED_SEND ) qp -> flags |= MLX5_IB_QP_MANAGED_SEND ; if ( init_attr -> create_flags & IB_QP_CREATE_MANAGED_RECV ) qp -> flags |= MLX5_IB_QP_MANAGED_RECV ; } if ( init_attr -> qp_type == IB_QPT_UD && ( init_attr -> create_flags & IB_QP_CREATE_IPOIB_UD_LSO ) ) if ( ! MLX5_CAP_GEN ( mdev , ipoib_basic_offloads ) ) { mlx5_ib_dbg ( dev , ""ipoibUDlsoqpisn\'tsupported\\n"" ) ; return - EOPNOTSUPP ; } if ( init_attr -> create_flags & IB_QP_CREATE_SCATTER_FCS ) { if ( init_attr -> qp_type != IB_QPT_RAW_PACKET ) { mlx5_ib_dbg ( dev , ""ScatterFCSissupportedonlyforRawPacketQPs"" ) ; return - EOPNOTSUPP ; } if ( ! MLX5_CAP_GEN ( dev -> mdev , eth_net_offloads ) || ! MLX5_CAP_ETH ( dev -> mdev , scatter_fcs ) ) { mlx5_ib_dbg ( dev , ""ScatterFCSisn\'tsupported\\n"" ) ; return - EOPNOTSUPP ; } qp -> flags |= MLX5_IB_QP_CAP_SCATTER_FCS ; } if ( init_attr -> sq_sig_type == IB_SIGNAL_ALL_WR ) qp -> sq_signal_bits = MLX5_WQE_CTRL_CQ_UPDATE ; if ( init_attr -> create_flags & IB_QP_CREATE_CVLAN_STRIPPING ) { if ( ! ( MLX5_CAP_GEN ( dev -> mdev , eth_net_offloads ) && MLX5_CAP_ETH ( dev -> mdev , vlan_cap ) ) || ( init_attr -> qp_type != IB_QPT_RAW_PACKET ) ) return - EOPNOTSUPP ; qp -> flags |= MLX5_IB_QP_CVLAN_STRIPPING ; } if ( pd && pd -> uobject ) { if ( ib_copy_from_udata ( & ucmd , udata , sizeof ( ucmd ) ) ) { mlx5_ib_dbg ( dev , ""copyfailed\\n"" ) ; return - EFAULT ; } err = get_qp_user_index ( to_mucontext ( pd -> uobject -> context ) , & ucmd , udata -> inlen , & uidx ) ; if ( err ) return err ; qp -> wq_sig = ! ! ( ucmd . flags & MLX5_QP_FLAG_SIGNATURE ) ; qp -> scat_cqe = ! ! ( ucmd . flags & MLX5_QP_FLAG_SCATTER_CQE ) ; if ( ucmd . flags & MLX5_QP_FLAG_TUNNEL_OFFLOADS ) { if ( init_attr -> qp_type != IB_QPT_RAW_PACKET || ! tunnel_offload_supported ( mdev ) ) { mlx5_ib_dbg ( dev , ""Tunneloffloadisn\'tsupported\\n"" ) ; return - EOPNOTSUPP ; } qp -> tunnel_offload_en = true ; } if ( init_attr -> create_flags & IB_QP_CREATE_SOURCE_QPN ) { if ( init_attr -> qp_type != IB_QPT_UD || ( MLX5_CAP_GEN ( dev -> mdev , port_type ) != MLX5_CAP_PORT_TYPE_IB ) || ! mlx5_get_flow_namespace ( dev -> mdev , MLX5_FLOW_NAMESPACE_BYPASS ) ) { mlx5_ib_dbg ( dev , ""SourceQPoptionisn\'tsupported\\n"" ) ; return - EOPNOTSUPP ; } qp -> flags |= MLX5_IB_QP_UNDERLAY ; qp -> underlay_qpn = init_attr -> source_qpn ; } } else { qp -> wq_sig = ! ! wq_signature ; } base = ( init_attr -> qp_type == IB_QPT_RAW_PACKET || qp -> flags & MLX5_IB_QP_UNDERLAY ) ? & qp -> raw_packet_qp . rq . base : & qp -> trans_qp . base ; qp -> has_rq = qp_has_rq ( init_attr ) ; err = set_rq_size ( dev , & init_attr -> cap , qp -> has_rq , qp , ( pd && pd -> uobject ) ? & ucmd : NULL ) ; if ( err ) { mlx5_ib_dbg ( dev , ""err%d\\n"" , err ) ; return err ; } if ( pd ) { if ( pd -> uobject ) { __u32 max_wqes = 1 << MLX5_CAP_GEN ( mdev , log_max_qp_sz ) ; mlx5_ib_dbg ( dev , ""requestedsq_wqe_count(%d)\\n"" , ucmd . sq_wqe_count ) ; if ( ucmd . rq_wqe_shift != qp -> rq . wqe_shift || ucmd . rq_wqe_count != qp -> rq . wqe_cnt ) { mlx5_ib_dbg ( dev , ""invalidrqparams\\n"" ) ; return - EINVAL ; } if ( ucmd . sq_wqe_count > max_wqes ) { mlx5_ib_dbg ( dev , ""requestedsq_wqe_count(%d)>maxallowed(%d)\\n"" , ucmd . sq_wqe_count , max_wqes ) ; return - EINVAL ; } if ( init_attr -> create_flags & mlx5_ib_create_qp_sqpn_qp1 ( ) ) { mlx5_ib_dbg ( dev , ""user-spaceisnotallowedtocreateUDQPsspoofingasQP1\\n"" ) ; return - EINVAL ; } err = create_user_qp ( dev , pd , qp , udata , init_attr , & in , & resp , & inlen , base ) ; if ( err ) mlx5_ib_dbg ( dev , ""err%d\\n"" , err ) ; } else { err = create_kernel_qp ( dev , init_attr , qp , & in , & inlen , base ) ; if ( err ) mlx5_ib_dbg ( dev , ""err%d\\n"" , err ) ; } if ( err ) return err ; } else { in = kvzalloc ( inlen , GFP_KERNEL ) ; if ( ! in ) return - ENOMEM ; qp -> create_type = MLX5_QP_EMPTY ; } if ( is_sqp ( init_attr -> qp_type ) ) qp -> port = init_attr -> port_num ; qpc = MLX5_ADDR_OF ( create_qp_in , in , qpc ) ; MLX5_SET ( qpc , qpc , st , mlx5_st ) ; MLX5_SET ( qpc , qpc , pm_state , MLX5_QP_PM_MIGRATED ) ; if ( init_attr -> qp_type != MLX5_IB_QPT_REG_UMR ) MLX5_SET ( qpc , qpc , pd , to_mpd ( pd ? pd : devr -> p0 ) -> pdn ) ; else MLX5_SET ( qpc , qpc , latency_sensitive , 1 ) ; if ( qp -> wq_sig ) MLX5_SET ( qpc , qpc , wq_signature , 1 ) ; if ( qp -> flags & MLX5_IB_QP_BLOCK_MULTICAST_LOOPBACK ) MLX5_SET ( qpc , qpc , block_lb_mc , 1 ) ; if ( qp -> flags & MLX5_IB_QP_CROSS_CHANNEL ) MLX5_SET ( qpc , qpc , cd_master , 1 ) ; if ( qp -> flags & MLX5_IB_QP_MANAGED_SEND ) MLX5_SET ( qpc , qpc , cd_slave_send , 1 ) ; if ( qp -> flags & MLX5_IB_QP_MANAGED_RECV ) MLX5_SET ( qpc , qpc , cd_slave_receive , 1 ) ; if ( qp -> scat_cqe && is_connected ( init_attr -> qp_type ) ) { int rcqe_sz ; int scqe_sz ; rcqe_sz = mlx5_ib_get_cqe_size ( dev , init_attr -> recv_cq ) ; scqe_sz = mlx5_ib_get_cqe_size ( dev , init_attr -> send_cq ) ; if ( rcqe_sz == 128 ) MLX5_SET ( qpc , qpc , cs_res , MLX5_RES_SCAT_DATA64_CQE ) ; else MLX5_SET ( qpc , qpc , cs_res , MLX5_RES_SCAT_DATA32_CQE ) ; if ( init_attr -> sq_sig_type == IB_SIGNAL_ALL_WR ) { if ( scqe_sz == 128 ) MLX5_SET ( qpc , qpc , cs_req , MLX5_REQ_SCAT_DATA64_CQE ) ; else MLX5_SET ( qpc , qpc , cs_req , MLX5_REQ_SCAT_DATA32_CQE ) ; } } if ( qp -> rq . wqe_cnt ) { MLX5_SET ( qpc , qpc , log_rq_stride , qp -> rq . wqe_shift - 4 ) ; MLX5_SET ( qpc , qpc , log_rq_size , ilog2 ( qp -> rq . wqe_cnt ) ) ; } MLX5_SET ( qpc , qpc , rq_type , get_rx_type ( qp , init_attr ) ) ; if ( qp -> sq . wqe_cnt ) { MLX5_SET ( qpc , qpc , log_sq_size , ilog2 ( qp -> sq . wqe_cnt ) ) ; } else { MLX5_SET ( qpc , qpc , no_sq , 1 ) ; if ( init_attr -> srq && init_attr -> srq -> srq_type == IB_SRQT_TM ) MLX5_SET ( qpc , qpc , offload_type , MLX5_QPC_OFFLOAD_TYPE_RNDV ) ; } switch ( init_attr -> qp_type ) { case IB_QPT_XRC_TGT : MLX5_SET ( qpc , qpc , cqn_rcv , to_mcq ( devr -> c0 ) -> mcq . cqn ) ; MLX5_SET ( qpc , qpc , cqn_snd , to_mcq ( devr -> c0 ) -> mcq . cqn ) ; MLX5_SET ( qpc , qpc , srqn_rmpn_xrqn , to_msrq ( devr -> s0 ) -> msrq . srqn ) ; MLX5_SET ( qpc , qpc , xrcd , to_mxrcd ( init_attr -> xrcd ) -> xrcdn ) ; break ; case IB_QPT_XRC_INI : MLX5_SET ( qpc , qpc , cqn_rcv , to_mcq ( devr -> c0 ) -> mcq . cqn ) ; MLX5_SET ( qpc , qpc , xrcd , to_mxrcd ( devr -> x1 ) -> xrcdn ) ; MLX5_SET ( qpc , qpc , srqn_rmpn_xrqn , to_msrq ( devr -> s0 ) -> msrq . srqn ) ; break ; default : if ( init_attr -> srq ) { MLX5_SET ( qpc , qpc , xrcd , to_mxrcd ( devr -> x0 ) -> xrcdn ) ; MLX5_SET ( qpc , qpc , srqn_rmpn_xrqn , to_msrq ( init_attr -> srq ) -> msrq . srqn ) ; } else { MLX5_SET ( qpc , qpc , xrcd , to_mxrcd ( devr -> x1 ) -> xrcdn ) ; MLX5_SET ( qpc , qpc , srqn_rmpn_xrqn , to_msrq ( devr -> s1 ) -> msrq . srqn ) ; } } if ( init_attr -> send_cq ) MLX5_SET ( qpc , qpc , cqn_snd , to_mcq ( init_attr -> send_cq ) -> mcq . cqn ) ; if ( init_attr -> recv_cq ) MLX5_SET ( qpc , qpc , cqn_rcv , to_mcq ( init_attr -> recv_cq ) -> mcq . cqn ) ; MLX5_SET64 ( qpc , qpc , dbr_addr , qp -> db . dma ) ; if ( MLX5_CAP_GEN ( mdev , cqe_version ) == MLX5_CQE_VERSION_V1 ) MLX5_SET ( qpc , qpc , user_index , uidx ) ; if ( init_attr -> qp_type == IB_QPT_UD && ( init_attr -> create_flags & IB_QP_CREATE_IPOIB_UD_LSO ) ) { MLX5_SET ( qpc , qpc , ulp_stateless_offload_mode , 1 ) ; qp -> flags |= MLX5_IB_QP_LSO ; } if ( init_attr -> create_flags & IB_QP_CREATE_PCI_WRITE_END_PADDING ) { if ( ! MLX5_CAP_GEN ( dev -> mdev , end_pad ) ) { mlx5_ib_dbg ( dev , ""scatterendpaddingisnotsupported\\n"" ) ; err = - EOPNOTSUPP ; goto err ; } else if ( init_attr -> qp_type != IB_QPT_RAW_PACKET ) { MLX5_SET ( qpc , qpc , end_padding_mode , MLX5_WQ_END_PAD_MODE_ALIGN ) ; } else { qp -> flags |= MLX5_IB_QP_PCI_WRITE_END_PADDING ; } } if ( inlen < 0 ) { err = - EINVAL ; goto err ; } if ( init_attr -> qp_type == IB_QPT_RAW_PACKET || qp -> flags & MLX5_IB_QP_UNDERLAY ) { qp -> raw_packet_qp . sq . ubuffer . buf_addr = ucmd . sq_buf_addr ; raw_packet_qp_copy_info ( qp , & qp -> raw_packet_qp ) ; err = create_raw_packet_qp ( dev , qp , in , inlen , pd ) ; } else { err = mlx5_core_create_qp ( dev -> mdev , & base -> mqp , in , inlen ) ; } if ( err ) { mlx5_ib_dbg ( dev , ""createqpfailed\\n"" ) ; goto err_create ; } kvfree ( in ) ; base -> container_mibqp = qp ; base -> mqp . event = mlx5_ib_qp_event ; get_cqs ( init_attr -> qp_type , init_attr -> send_cq , init_attr -> recv_cq , & send_cq , & recv_cq ) ; spin_lock_irqsave ( & dev -> reset_flow_resource_lock , flags ) ; mlx5_ib_lock_cqs ( send_cq , recv_cq ) ; list_add_tail ( & qp -> qps_list , & dev -> qp_list ) ; if ( send_cq ) list_add_tail ( & qp -> cq_send_list , & send_cq -> list_send_qp ) ; if ( recv_cq ) list_add_tail ( & qp -> cq_recv_list , & recv_cq -> list_recv_qp ) ; mlx5_ib_unlock_cqs ( send_cq , recv_cq ) ; spin_unlock_irqrestore ( & dev -> reset_flow_resource_lock , flags ) ; return 0 ; err_create : if ( qp -> create_type == MLX5_QP_USER ) destroy_qp_user ( dev , pd , qp , base ) ; else if ( qp -> create_type == MLX5_QP_KERNEL ) destroy_qp_kernel ( dev , qp ) ; err : kvfree ( in ) ; return err ; } "," struct mlx5_ib_create_qp_resp resp = { } ",torvalds@linux/0625b4ba1a5d4703c7fb01c497bd6c156908af00,CVE-2018-20855,https://github.com/torvalds/linux/commit/0625b4ba1a5d4703c7fb01c497bd6c156908af00,2019-07-26T05:15Z 169,CWE-119,"CWE-119 void vp8_init_mbmode_probs ( VP8_COMMON * x ) { vpx_memcpy ( x -> fc . ymode_prob , vp8_ymode_prob , sizeof ( vp8_ymode_prob ) ) ; vpx_memcpy ( x -> fc . uv_mode_prob , vp8_uv_mode_prob , sizeof ( vp8_uv_mode_prob ) ) ; vpx_memcpy ( x -> fc . sub_mv_ref_prob , sub_mv_ref_prob , sizeof ( sub_mv_ref_prob ) ) ; } "," x ) { memcpy ( x -> ) ) ; memcpy ( x -> ) ) ; memcpy ( x -> ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 170,CWE-399,"CWE-399 static int br_multicast_add_group ( struct net_bridge * br , struct net_bridge_port * port , struct br_ip * group ) { struct net_bridge_mdb_entry * mp ; struct net_bridge_port_group * p ; struct net_bridge_port_group __rcu * * pp ; unsigned long now = jiffies ; int err ; spin_lock ( & br -> multicast_lock ) ; if ( ! netif_running ( br -> dev ) || ( port && port -> state == BR_STATE_DISABLED ) ) goto out ; mp = br_multicast_new_group ( br , port , group ) ; err = PTR_ERR ( mp ) ; if ( IS_ERR ( mp ) ) goto err ; if ( ! port ) { hlist_add_head ( & mp -> mglist , & br -> mglist ) ; mod_timer ( & mp -> timer , now + br -> multicast_membership_interval ) ; goto out ; } for ( pp = & mp -> ports ; ( p = mlock_dereference ( * pp , br ) ) != NULL ; pp = & p -> next ) { if ( p -> port == port ) goto found ; if ( ( unsigned long ) p -> port < ( unsigned long ) port ) break ; } p = kzalloc ( sizeof ( * p ) , GFP_ATOMIC ) ; err = - ENOMEM ; if ( unlikely ( ! p ) ) goto err ; p -> addr = * group ; p -> port = port ; p -> next = * pp ; hlist_add_head ( & p -> mglist , & port -> mglist ) ; setup_timer ( & p -> timer , br_multicast_port_group_expired , ( unsigned long ) p ) ; setup_timer ( & p -> query_timer , br_multicast_port_group_query_expired , ( unsigned long ) p ) ; rcu_assign_pointer ( * pp , p ) ; found : mod_timer ( & p -> timer , now + br -> multicast_membership_interval ) ; out : err = 0 ; err : spin_unlock ( & br -> multicast_lock ) ; return err ; } "," port ) { if ( hlist_unhashed ( & mp -> mglist ) ) ",torvalds@linux/6b0d6a9b4296fa16a28d10d416db7a770fc03287,CVE-2011-0716,https://github.com/torvalds/linux/commit/6b0d6a9b4296fa16a28d10d416db7a770fc03287,2012-06-21T23:55Z 171,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 172,CWE-129,"CWE-129 static av_cold int vqa_decode_init ( AVCodecContext * avctx ) { VqaContext * s = avctx -> priv_data ; int i , j , codebook_index , ret ; s -> avctx = avctx ; avctx -> pix_fmt = AV_PIX_FMT_PAL8 ; if ( s -> avctx -> extradata_size != VQA_HEADER_SIZE ) { av_log ( s -> avctx , AV_LOG_ERROR , ""expectedextradatasizeof%d\\n"" , VQA_HEADER_SIZE ) ; return AVERROR ( EINVAL ) ; } s -> vqa_version = s -> avctx -> extradata [ 0 ] ; switch ( s -> vqa_version ) { case 1 : case 2 : break ; case 3 : avpriv_report_missing_feature ( avctx , ""VQAVersion%d"" , s -> vqa_version ) ; return AVERROR_PATCHWELCOME ; default : avpriv_request_sample ( avctx , ""VQAVersion%i"" , s -> vqa_version ) ; return AVERROR_PATCHWELCOME ; } s -> width = AV_RL16 ( & s -> avctx -> extradata [ 6 ] ) ; s -> height = AV_RL16 ( & s -> avctx -> extradata [ 8 ] ) ; if ( ( ret = av_image_check_size ( s -> width , s -> height , 0 , avctx ) ) < 0 ) { s -> width = s -> height = 0 ; return ret ; } s -> vector_width = s -> avctx -> extradata [ 10 ] ; s -> vector_height = s -> avctx -> extradata [ 11 ] ; s -> partial_count = s -> partial_countdown = s -> avctx -> extradata [ 13 ] ; if ( ( s -> vector_width != 4 ) || ( ( s -> vector_height != 2 ) && ( s -> vector_height != 4 ) ) ) { return AVERROR_INVALIDDATA ; } if ( s -> width % s -> vector_width || s -> height % s -> vector_height ) { av_log ( avctx , AV_LOG_ERROR , ""Imagesizenotmultipleofblocksize\\n"" ) ; return AVERROR_INVALIDDATA ; } s -> codebook_size = MAX_CODEBOOK_SIZE ; s -> codebook = av_malloc ( s -> codebook_size ) ; if ( ! s -> codebook ) goto fail ; s -> next_codebook_buffer = av_malloc ( s -> codebook_size ) ; if ( ! s -> next_codebook_buffer ) goto fail ; s -> decode_buffer_size = ( s -> width / s -> vector_width ) * ( s -> height / s -> vector_height ) * 2 ; s -> decode_buffer = av_mallocz ( s -> decode_buffer_size ) ; if ( ! s -> decode_buffer ) goto fail ; if ( s -> vector_height == 4 ) { codebook_index = 0xFF00 * 16 ; for ( i = 0 ; i < 256 ; i ++ ) for ( j = 0 ; j < 16 ; j ++ ) s -> codebook [ codebook_index ++ ] = i ; } else { codebook_index = 0xF00 * 8 ; for ( i = 0 ; i < 256 ; i ++ ) for ( j = 0 ; j < 8 ; j ++ ) s -> codebook [ codebook_index ++ ] = i ; } s -> next_codebook_buffer_index = 0 ; return 0 ; fail : av_freep ( & s -> codebook ) ; av_freep ( & s -> next_codebook_buffer ) ; av_freep ( & s -> decode_buffer ) ; return AVERROR ( ENOMEM ) ; } "," ( ret = ff_set_dimensions ( avctx , s -> width s -> height ) ) < ",FFmpeg@FFmpeg/02f909dc24b1f05cfbba75077c7707b905e63cd2,CVE-2019-17542,https://github.com/FFmpeg/FFmpeg/commit/02f909dc24b1f05cfbba75077c7707b905e63cd2,2019-10-14T02:15Z 173,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 174,CWE-362,"CWE-362 static struct page * follow_page_pte ( struct vm_area_struct * vma , unsigned long address , pmd_t * pmd , unsigned int flags ) { struct mm_struct * mm = vma -> vm_mm ; struct dev_pagemap * pgmap = NULL ; struct page * page ; spinlock_t * ptl ; pte_t * ptep , pte ; retry : if ( unlikely ( pmd_bad ( * pmd ) ) ) return no_page_table ( vma , flags ) ; ptep = pte_offset_map_lock ( mm , pmd , address , & ptl ) ; pte = * ptep ; if ( ! pte_present ( pte ) ) { swp_entry_t entry ; if ( likely ( ! ( flags & FOLL_MIGRATION ) ) ) goto no_page ; if ( pte_none ( pte ) ) goto no_page ; entry = pte_to_swp_entry ( pte ) ; if ( ! is_migration_entry ( entry ) ) goto no_page ; pte_unmap_unlock ( ptep , ptl ) ; migration_entry_wait ( mm , pmd , address ) ; goto retry ; } if ( ( flags & FOLL_NUMA ) && pte_protnone ( pte ) ) goto no_page ; if ( ( flags & FOLL_WRITE ) && ! pte_write ( pte ) ) { pte_unmap_unlock ( ptep , ptl ) ; return NULL ; } page = vm_normal_page ( vma , address , pte ) ; if ( ! page && pte_devmap ( pte ) && ( flags & FOLL_GET ) ) { pgmap = get_dev_pagemap ( pte_pfn ( pte ) , NULL ) ; if ( pgmap ) page = pte_page ( pte ) ; else goto no_page ; } else if ( unlikely ( ! page ) ) { if ( flags & FOLL_DUMP ) { page = ERR_PTR ( - EFAULT ) ; goto out ; } if ( is_zero_pfn ( pte_pfn ( pte ) ) ) { page = pte_page ( pte ) ; } else { int ret ; ret = follow_pfn_pte ( vma , address , ptep , flags ) ; page = ERR_PTR ( ret ) ; goto out ; } } if ( flags & FOLL_SPLIT && PageTransCompound ( page ) ) { int ret ; get_page ( page ) ; pte_unmap_unlock ( ptep , ptl ) ; lock_page ( page ) ; ret = split_huge_page ( page ) ; unlock_page ( page ) ; put_page ( page ) ; if ( ret ) return ERR_PTR ( ret ) ; goto retry ; } if ( flags & FOLL_GET ) { get_page ( page ) ; if ( pgmap ) { put_dev_pagemap ( pgmap ) ; pgmap = NULL ; } } if ( flags & FOLL_TOUCH ) { if ( ( flags & FOLL_WRITE ) && ! pte_dirty ( pte ) && ! PageDirty ( page ) ) set_page_dirty ( page ) ; mark_page_accessed ( page ) ; } if ( ( flags & FOLL_MLOCK ) && ( vma -> vm_flags & VM_LOCKED ) ) { if ( PageTransCompound ( page ) ) goto out ; if ( page -> mapping && trylock_page ( page ) ) { lru_add_drain ( ) ; mlock_vma_page ( page ) ; unlock_page ( page ) ; } } out : pte_unmap_unlock ( ptep , ptl ) ; return page ; no_page : pte_unmap_unlock ( ptep , ptl ) ; if ( ! pte_none ( pte ) ) return NULL ; return no_page_table ( vma , flags ) ; } "," ) && ! can_follow_write_pte ( pte , flags ) ) { ",torvalds@linux/19be0eaffa3ac7d8eb6784ad9bdbc7d67ed8e619,CVE-2016-5195,https://github.com/torvalds/linux/commit/19be0eaffa3ac7d8eb6784ad9bdbc7d67ed8e619,2016-11-10T21:59Z 175,CWE-399,"CWE-399 static void vhost_net_ubuf_put_and_wait ( struct vhost_net_ubuf_ref * ubufs ) { kref_put ( & ubufs -> kref , vhost_net_zerocopy_done_signal ) ; wait_event ( ubufs -> wait , ! atomic_read ( & ubufs -> kref . refcount ) ) ; kfree ( ubufs ) ; } "," ) ) ; } ",torvalds@linux/dd7633ecd553a5e304d349aa6f8eb8a0417098c5,CVE-2013-4127,https://github.com/torvalds/linux/commit/dd7633ecd553a5e304d349aa6f8eb8a0417098c5,2013-07-29T13:59Z 176,CWE-20,"CWE-20 int verify_compat_iovec ( struct msghdr * kern_msg , struct iovec * kern_iov , struct sockaddr_storage * kern_address , int mode ) { int tot_len ; if ( kern_msg -> msg_namelen ) { if ( mode == VERIFY_READ ) { int err = move_addr_to_kernel ( kern_msg -> msg_name , kern_msg -> msg_namelen , kern_address ) ; if ( err < 0 ) return err ; } kern_msg -> msg_name = kern_address ; } else kern_msg -> msg_name = NULL ; tot_len = iov_from_user_compat_to_kern ( kern_iov , ( struct compat_iovec __user * ) kern_msg -> msg_iov , kern_msg -> msg_iovlen ) ; if ( tot_len >= 0 ) kern_msg -> msg_iov = kern_iov ; return tot_len ; } "," err ; } if ( kern_msg -> msg_name ) ",torvalds@linux/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,CVE-2013-7271,https://github.com/torvalds/linux/commit/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,2014-01-06T16:55Z 177,CWE-119,"CWE-119 static int read_intra_segment_id ( VP9_COMMON * const cm , MACROBLOCKD * const xd , int mi_row , int mi_col , vp9_reader * r ) { struct segmentation * const seg = & cm -> seg ; const BLOCK_SIZE bsize = xd -> mi [ 0 ] -> mbmi . sb_type ; int segment_id ; if ( ! seg -> enabled ) return 0 ; if ( ! seg -> update_map ) return 0 ; segment_id = read_segment_id ( r , seg ) ; set_segment_id ( cm , bsize , mi_row , mi_col , segment_id ) ; return segment_id ; } "," const cm , int mi_offset , int x_mis , int y_mis , vpx_reader * r ) cm -> seg ; int segment_id -> update_map ) { copy_segment_id ( cm , cm -> last_frame_seg_map , cm -> current_frame_seg_map , mi_offset , x_mis , y_mis ) ; return 0 ; } ( cm , mi_offset , x_mis , y_mis , segment_id ) ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 178,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 179,CWE-310,"CWE-310 void Init_ossl_cipher ( void ) { # if 0 mOSSL = rb_define_module ( ""OpenSSL"" ) ; eOSSLError = rb_define_class_under ( mOSSL , ""OpenSSLError"" , rb_eStandardError ) ; # endif cCipher = rb_define_class_under ( mOSSL , ""Cipher"" , rb_cObject ) ; eCipherError = rb_define_class_under ( cCipher , ""CipherError"" , eOSSLError ) ; rb_define_alloc_func ( cCipher , ossl_cipher_alloc ) ; rb_define_copy_func ( cCipher , ossl_cipher_copy ) ; rb_define_module_function ( cCipher , ""ciphers"" , ossl_s_ciphers , 0 ) ; rb_define_method ( cCipher , ""initialize"" , ossl_cipher_initialize , 1 ) ; rb_define_method ( cCipher , ""reset"" , ossl_cipher_reset , 0 ) ; rb_define_method ( cCipher , ""encrypt"" , ossl_cipher_encrypt , - 1 ) ; rb_define_method ( cCipher , ""decrypt"" , ossl_cipher_decrypt , - 1 ) ; rb_define_method ( cCipher , ""pkcs5_keyivgen"" , ossl_cipher_pkcs5_keyivgen , - 1 ) ; rb_define_method ( cCipher , ""update"" , ossl_cipher_update , - 1 ) ; rb_define_method ( cCipher , ""final"" , ossl_cipher_final , 0 ) ; rb_define_method ( cCipher , ""name"" , ossl_cipher_name , 0 ) ; rb_define_method ( cCipher , ""key="" , ossl_cipher_set_key , 1 ) ; rb_define_method ( cCipher , ""auth_data="" , ossl_cipher_set_auth_data , 1 ) ; rb_define_method ( cCipher , ""auth_tag="" , ossl_cipher_set_auth_tag , 1 ) ; rb_define_method ( cCipher , ""auth_tag"" , ossl_cipher_get_auth_tag , - 1 ) ; rb_define_method ( cCipher , ""auth_tag_len="" , ossl_cipher_set_auth_tag_len , 1 ) ; rb_define_method ( cCipher , ""authenticated?"" , ossl_cipher_is_authenticated , 0 ) ; rb_define_method ( cCipher , ""key_len="" , ossl_cipher_set_key_length , 1 ) ; rb_define_method ( cCipher , ""key_len"" , ossl_cipher_key_length , 0 ) ; rb_define_method ( cCipher , ""iv="" , ossl_cipher_set_iv , 1 ) ; rb_define_method ( cCipher , ""iv_len="" , ossl_cipher_set_iv_length , 1 ) ; rb_define_method ( cCipher , ""iv_len"" , ossl_cipher_iv_length , 0 ) ; rb_define_method ( cCipher , ""block_size"" , ossl_cipher_block_size , 0 ) ; rb_define_method ( cCipher , ""padding="" , ossl_cipher_set_padding , 1 ) ; id_auth_tag_len = rb_intern_const ( ""auth_tag_len"" ) ; } "," ""auth_tag_len"" ) ; id_key_set = rb_intern_const ( ""key_set"" ) ; ",ruby@openssl/8108e0a6db133f3375608303fdd2083eb5115062,CVE-2016-7798,https://github.com/ruby/openssl/commit/8108e0a6db133f3375608303fdd2083eb5115062,2017-01-30T22:59Z 180,CWE-19,"CWE-19 static int ext2_xattr_cache_insert ( struct buffer_head * bh ) { __u32 hash = le32_to_cpu ( HDR ( bh ) -> h_hash ) ; struct mb_cache_entry * ce ; int error ; ce = mb_cache_entry_alloc ( ext2_xattr_cache , GFP_NOFS ) ; if ( ! ce ) return - ENOMEM ; 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(%dcacheentries)"" , atomic_read ( & ext2_xattr_cache -> c_entry_count ) ) ; error = 0 ; } } else { ea_bdebug ( bh , ""inserting[%x](%dcacheentries)"" , ( int ) hash , atomic_read ( & ext2_xattr_cache -> c_entry_count ) ) ; mb_cache_entry_release ( ce ) ; } return error ; } "," int ext2_xattr_cache_insert ( struct mb2_cache * cache , h_hash ) ; int error ; int error ; error = mb2_cache_entry_create ( cache , GFP_NOFS , hash , bh -> bh -> b_blocknr ) ; if error ) { if ( error } } else ea_bdebug ( bh ( bh , ""inserting[%x]"" , ( int int ) hash ) ; return error ; ",torvalds@linux/be0726d33cb8f411945884664924bed3cb8c70ee,CVE-2015-8952,https://github.com/torvalds/linux/commit/be0726d33cb8f411945884664924bed3cb8c70ee,2016-10-16T21:59Z 181,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 182,CWE-000,"CWE-000 static int treo_attach ( struct usb_serial * serial ) { struct usb_serial_port * swap_port ; if ( ! ( ( le16_to_cpu ( serial -> dev -> descriptor . idVendor ) == HANDSPRING_VENDOR_ID ) || ( le16_to_cpu ( serial -> dev -> descriptor . idVendor ) == KYOCERA_VENDOR_ID ) ) || ( serial -> num_interrupt_in == 0 ) ) return 0 ; # define COPY_PORT ( dest , src ) do { int i ; for ( i = 0 ; i < ARRAY_SIZE ( src -> read_urbs ) ; ++ i ) { dest -> read_urbs [ i ] = src -> read_urbs [ i ] ; dest -> read_urbs [ i ] -> context = dest ; dest -> bulk_in_buffers [ i ] = src -> bulk_in_buffers [ i ] ; } dest -> read_urb = src -> read_urb ; dest -> bulk_in_endpointAddress = src -> bulk_in_endpointAddress ; dest -> bulk_in_buffer = src -> bulk_in_buffer ; dest -> bulk_in_size = src -> bulk_in_size ; dest -> interrupt_in_urb = src -> interrupt_in_urb ; dest -> interrupt_in_urb -> context = dest ; dest -> interrupt_in_endpointAddress = src -> interrupt_in_endpointAddress ; dest -> interrupt_in_buffer = src -> interrupt_in_buffer ; } while ( 0 ) ; swap_port = kmalloc ( sizeof ( * swap_port ) , GFP_KERNEL ) ; if ( ! swap_port ) return - ENOMEM ; COPY_PORT ( swap_port , serial -> port [ 0 ] ) ; COPY_PORT ( serial -> port [ 0 ] , serial -> port [ 1 ] ) ; COPY_PORT ( serial -> port [ 1 ] , swap_port ) ; kfree ( swap_port ) ; return 0 ; } "," return 0 ; if ( serial -> num_bulk_in < 2 || serial -> num_interrupt_in < 2 ) { dev_err ( & serial -> interface -> dev , ""missingendpoints\\n"" ) ; return - ENODEV ; } ",torvalds@linux/cac9b50b0d75a1d50d6c056ff65c005f3224c8e0,CVE-2016-2782,https://github.com/torvalds/linux/commit/cac9b50b0d75a1d50d6c056ff65c005f3224c8e0,2016-04-27T17:59Z 183,CWE-119,"CWE-119 void vp9_decoder_remove ( VP9Decoder * pbi ) { VP9_COMMON * const cm = & pbi -> common ; int i ; vp9_remove_common ( cm ) ; vp9_worker_end ( & pbi -> lf_worker ) ; vpx_free ( pbi -> lf_worker . data1 ) ; for ( i = 0 ; i < pbi -> num_tile_workers ; ++ i ) { VP9Worker * const worker = & pbi -> tile_workers [ i ] ; vp9_worker_end ( worker ) ; vpx_free ( worker -> data1 ) ; vpx_free ( worker -> data2 ) ; } vpx_free ( pbi -> tile_workers ) ; if ( pbi -> num_tile_workers ) { const int sb_rows = mi_cols_aligned_to_sb ( cm -> mi_rows ) >> MI_BLOCK_SIZE_LOG2 ; vp9_loop_filter_dealloc ( & pbi -> lf_row_sync , sb_rows ) ; } vpx_free ( pbi ) ; } "," pbi ) { int i ; int i ; vpx_get_worker_interface ( ) -> end ( & pbi lf_worker . data1 ) ; vpx_free ( pbi -> tile_data i ) { VPxWorker * const worker i ] ; vpx_get_worker_interface ( ) -> end ( worker ) worker ) ; } vpx_free ( pbi -> tile_worker_data ) ; vpx_free ; vpx_free ( pbi -> tile_worker_info ) ; vpx_free ( pbi pbi -> num_tile_workers > 0 ) { vp9_loop_filter_dealloc ( & pbi -> lf_row_sync ) ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 184,CWE-22,"CWE-22 void wiki_handle_http_request ( HttpRequest * req ) { HttpResponse * res = http_response_new ( req ) ; char * page = http_request_get_path_info ( req ) ; char * command = http_request_get_query_string ( req ) ; char * wikitext = """" ; util_dehttpize ( page ) ; if ( ! strcmp ( page , ""/"" ) ) { if ( access ( ""WikiHome"" , R_OK ) != 0 ) wiki_redirect ( res , ""/WikiHome?create"" ) ; page = ""/WikiHome"" ; } if ( ! strcmp ( page , ""/styles.css"" ) ) { http_response_set_content_type ( res , ""text/css"" ) ; http_response_printf ( res , ""%s"" , CssData ) ; http_response_send ( res ) ; exit ( 0 ) ; } if ( ! strcmp ( page , ""/favicon.ico"" ) ) { http_response_set_content_type ( res , ""image/ico"" ) ; http_response_set_data ( res , FaviconData , FaviconDataLen ) ; http_response_send ( res ) ; exit ( 0 ) ; } page = page + 1 ; if ( ! strncmp ( page , ""api/"" , 4 ) ) { char * p ; page += 4 ; for ( p = page ; * p != '\\0' ; p ++ ) if ( * p == '?' ) { * p = '\\0' ; break ; } wiki_handle_rest_call ( req , res , page ) ; exit ( 0 ) ; } if ( strchr ( page , '/' ) ) { http_response_set_status ( res , 404 , ""NotFound"" ) ; http_response_printf ( res , ""404NotFound\\n"" ) ; http_response_send ( res ) ; exit ( 0 ) ; } if ( ! strcmp ( page , ""Changes"" ) ) { wiki_show_changes_page ( res ) ; } else if ( ! strcmp ( page , ""ChangesRss"" ) ) { wiki_show_changes_page_rss ( res ) ; } else if ( ! strcmp ( page , ""Search"" ) ) { wiki_show_search_results_page ( res , http_request_param_get ( req , ""expr"" ) ) ; } else if ( ! strcmp ( page , ""Create"" ) ) { if ( ( wikitext = http_request_param_get ( req , ""title"" ) ) != NULL ) { wiki_redirect ( res , http_request_param_get ( req , ""title"" ) ) ; } else { wiki_show_create_page ( res ) ; } } else { if ( ( wikitext = http_request_param_get ( req , ""wikitext"" ) ) != NULL ) { file_write ( page , wikitext ) ; } if ( access ( page , R_OK ) == 0 ) { wikitext = file_read ( page ) ; if ( ! strcmp ( command , ""edit"" ) ) { wiki_show_edit_page ( res , wikitext , page ) ; } else { wiki_show_page ( res , wikitext , page ) ; } } else { if ( ! strcmp ( command , ""create"" ) ) { wiki_show_edit_page ( res , NULL , page ) ; } else { char buf [ 1024 ] ; snprintf ( buf , 1024 , ""%s?create"" , page ) ; wiki_redirect ( res , buf ) ; } } } } "," } if ( ! page_name_is_good ( page ) ) { ",yarolig@didiwiki/5e5c796617e1712905dc5462b94bd5e6c08d15ea,CVE-2013-7448,https://github.com/yarolig/didiwiki/commit/5e5c796617e1712905dc5462b94bd5e6c08d15ea,2016-02-23T19:59Z 185,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 186,CWE-125,"CWE-125 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 187,CWE-190,"CWE-190 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 ( ""gotboxtype%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_CAST ( jas_uint , jas_image_numcmpts ( < JAS_CAST ( jas_uint , jas_image_numcmpts ( != JAS_CAST ( jas_uint , jas_image_numcmpts ( < JAS_CAST ( jas_uint , jas_image_numcmpts ( : JAS_CAST ( jas_uint , jas_image_numcmpts ( >= JAS_CAST ( jas_uint , jas_image_numcmpts ( < JAS_CAST ( jas_uint , jas_image_numcmpts ( ",mdadams@jasper/d42b2388f7f8e0332c846675133acea151fc557a,CVE-2016-9557,https://github.com/mdadams/jasper/commit/d42b2388f7f8e0332c846675133acea151fc557a,2017-03-23T18:59Z 188,CWE-476,"CWE-476 int jpc_tsfb_synthesize ( jpc_tsfb_t * tsfb , jas_seq2d_t * a ) { return ( tsfb -> numlvls > 0 ) ? jpc_tsfb_synthesize2 ( tsfb , jas_seq2d_getref ( a , jas_seq2d_xstart ( a ) , jas_seq2d_ystart ( a ) ) , jas_seq2d_xstart ( a ) , jas_seq2d_ystart ( a ) , jas_seq2d_width ( a ) , jas_seq2d_height ( a ) , jas_seq2d_rowstep ( a ) , tsfb -> numlvls - 1 ) : 0 ; } "," numlvls > 0 && jas_seq2d_size ( a ) ",mdadams@jasper/2e82fa00466ae525339754bb3ab0a0474a31d4bd,CVE-2016-10248,https://github.com/mdadams/jasper/commit/2e82fa00466ae525339754bb3ab0a0474a31d4bd,2017-03-15T14:59Z 189,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 190,CWE-000,"CWE-000 static void sas_init_port ( struct asd_sas_port * port , struct sas_ha_struct * sas_ha , int i ) { memset ( port , 0 , sizeof ( * port ) ) ; port -> id = i ; INIT_LIST_HEAD ( & port -> dev_list ) ; INIT_LIST_HEAD ( & port -> disco_list ) ; INIT_LIST_HEAD ( & port -> destroy_list ) ; spin_lock_init ( & port -> phy_list_lock ) ; INIT_LIST_HEAD ( & port -> phy_list ) ; port -> ha = sas_ha ; spin_lock_init ( & port -> dev_list_lock ) ; } "," destroy_list ) ; INIT_LIST_HEAD ( & port -> sas_port_del_list ) ; ",torvalds@linux/0558f33c06bb910e2879e355192227a8e8f0219d,CVE-2017-18232,https://github.com/torvalds/linux/commit/0558f33c06bb910e2879e355192227a8e8f0219d,2018-03-15T04:29Z 191,CWE-476,"CWE-476 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 192,CWE-20,"CWE-20 static int dccp_error ( struct net * net , struct nf_conn * tmpl , struct sk_buff * skb , unsigned int dataoff , enum ip_conntrack_info * ctinfo , u_int8_t pf , unsigned int hooknum ) { struct dccp_hdr _dh , * dh ; unsigned int dccp_len = skb -> len - dataoff ; unsigned int cscov ; const char * msg ; dh = skb_header_pointer ( skb , dataoff , sizeof ( _dh ) , & dh ) ; if ( dh == NULL ) { msg = ""nf_ct_dccp:shortpacket"" ; goto out_invalid ; } if ( dh -> dccph_doff * 4 < sizeof ( struct dccp_hdr ) || dh -> dccph_doff * 4 > dccp_len ) { msg = ""nf_ct_dccp:truncated/malformedpacket"" ; goto out_invalid ; } cscov = dccp_len ; if ( dh -> dccph_cscov ) { cscov = ( dh -> dccph_cscov - 1 ) * 4 ; if ( cscov > dccp_len ) { msg = ""nf_ct_dccp:badchecksumcoverage"" ; goto out_invalid ; } } if ( net -> ct . sysctl_checksum && hooknum == NF_INET_PRE_ROUTING && nf_checksum_partial ( skb , hooknum , dataoff , cscov , IPPROTO_DCCP , pf ) ) { msg = ""nf_ct_dccp:badchecksum"" ; goto out_invalid ; } if ( dh -> dccph_type >= DCCP_PKT_INVALID ) { msg = ""nf_ct_dccp:reservedpackettype"" ; goto out_invalid ; } return NF_ACCEPT ; out_invalid : if ( LOG_INVALID ( net , IPPROTO_DCCP ) ) nf_log_packet ( net , pf , 0 , skb , NULL , NULL , NULL , ""%s"" , msg ) ; return - NF_ACCEPT ; } "," ) , & _dh ) ; if ",torvalds@linux/b22f5126a24b3b2f15448c3f2a254fc10cbc2b92,CVE-2014-2523,https://github.com/torvalds/linux/commit/b22f5126a24b3b2f15448c3f2a254fc10cbc2b92,2014-03-24T16:40Z 193,CWE-787,"CWE-787 int mp_pack ( lua_State * L ) { int nargs = lua_gettop ( L ) ; int i ; mp_buf * buf ; if ( nargs == 0 ) return luaL_argerror ( L , 0 , ""MessagePackpackneedsinput."" ) ; if ( ! lua_checkstack ( L , nargs ) ) return luaL_argerror ( L , 0 , ""ToomanyargumentsforMessagePackpack."" ) ; buf = mp_buf_new ( L ) ; for ( i = 1 ; i <= nargs ; i ++ ) { lua_pushvalue ( L , i ) ; mp_encode_lua_type ( L , buf , 0 ) ; lua_pushlstring ( L , ( char * ) buf -> b , buf -> len ) ; buf -> free += buf -> len ; buf -> len = 0 ; } mp_buf_free ( L , buf ) ; lua_concat ( L , nargs ) ; return 1 ; } "," ++ ) { luaL_checkstack ( L , 1 , ""infunctionmp_check"" ) ; ",antirez@redis/5ccb6f7a791bf3490357b00a898885759d98bab0,CVE-2018-11218,https://github.com/antirez/redis/commit/5ccb6f7a791bf3490357b00a898885759d98bab0,2018-06-17T17:29Z 194,CWE-264,"CWE-264 static inline int check_pmd_range ( struct vm_area_struct * vma , pud_t * pud , unsigned long addr , unsigned long end , const nodemask_t * nodes , unsigned long flags , void * private ) { pmd_t * pmd ; unsigned long next ; pmd = pmd_offset ( pud , addr ) ; do { next = pmd_addr_end ( addr , end ) ; split_huge_page_pmd ( vma -> vm_mm , pmd ) ; if ( pmd_none_or_clear_bad ( pmd ) ) continue ; if ( check_pte_range ( vma , pmd , addr , next , nodes , flags , private ) ) return - EIO ; } 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 195,CWE-20,"CWE-20 static int __vcpu_run ( struct kvm_vcpu * vcpu ) { int r ; struct kvm * kvm = vcpu -> kvm ; vcpu -> srcu_idx = srcu_read_lock ( & kvm -> srcu ) ; r = vapic_enter ( vcpu ) ; if ( r ) { srcu_read_unlock ( & kvm -> srcu , vcpu -> srcu_idx ) ; return r ; } r = 1 ; while ( r > 0 ) { if ( vcpu -> arch . mp_state == KVM_MP_STATE_RUNNABLE && ! vcpu -> arch . apf . halted ) r = vcpu_enter_guest ( vcpu ) ; else { srcu_read_unlock ( & kvm -> srcu , vcpu -> srcu_idx ) ; kvm_vcpu_block ( vcpu ) ; vcpu -> srcu_idx = srcu_read_lock ( & kvm -> srcu ) ; if ( kvm_check_request ( KVM_REQ_UNHALT , vcpu ) ) { kvm_apic_accept_events ( vcpu ) ; switch ( vcpu -> arch . mp_state ) { case KVM_MP_STATE_HALTED : vcpu -> arch . pv . pv_unhalted = false ; vcpu -> arch . mp_state = KVM_MP_STATE_RUNNABLE ; case KVM_MP_STATE_RUNNABLE : vcpu -> arch . apf . halted = false ; break ; case KVM_MP_STATE_INIT_RECEIVED : break ; default : r = - EINTR ; break ; } } } if ( r <= 0 ) break ; clear_bit ( KVM_REQ_PENDING_TIMER , & vcpu -> requests ) ; if ( kvm_cpu_has_pending_timer ( vcpu ) ) kvm_inject_pending_timer_irqs ( vcpu ) ; if ( dm_request_for_irq_injection ( vcpu ) ) { r = - EINTR ; vcpu -> run -> exit_reason = KVM_EXIT_INTR ; ++ vcpu -> stat . request_irq_exits ; } kvm_check_async_pf_completion ( vcpu ) ; if ( signal_pending ( current ) ) { r = - EINTR ; vcpu -> run -> exit_reason = KVM_EXIT_INTR ; ++ vcpu -> stat . signal_exits ; } if ( need_resched ( ) ) { srcu_read_unlock ( & kvm -> srcu , vcpu -> srcu_idx ) ; kvm_resched ( vcpu ) ; vcpu -> srcu_idx = srcu_read_lock ( & kvm -> srcu ) ; } } srcu_read_unlock ( & kvm -> srcu , vcpu -> srcu_idx ) ; vapic_exit ( vcpu ) ; return r ; } "," srcu ) ; r = 1 srcu_idx ) ; return r ; ",torvalds@linux/fda4e2e85589191b123d31cdc21fd33ee70f50fd,CVE-2013-6368,https://github.com/torvalds/linux/commit/fda4e2e85589191b123d31cdc21fd33ee70f50fd,2013-12-14T18:08Z 196,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 197,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 198,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 199,CWE-399,"CWE-399 static long pipe_set_size ( struct pipe_inode_info * pipe , unsigned long nr_pages ) { struct pipe_buffer * bufs ; if ( nr_pages < pipe -> nrbufs ) return - EBUSY ; bufs = kcalloc ( nr_pages , sizeof ( * bufs ) , GFP_KERNEL | __GFP_NOWARN ) ; if ( unlikely ( ! bufs ) ) return - ENOMEM ; if ( pipe -> nrbufs ) { unsigned int tail ; unsigned int head ; tail = pipe -> curbuf + pipe -> nrbufs ; if ( tail < pipe -> buffers ) tail = 0 ; else tail &= ( pipe -> buffers - 1 ) ; head = pipe -> nrbufs - tail ; if ( head ) memcpy ( bufs , pipe -> bufs + pipe -> curbuf , head * sizeof ( struct pipe_buffer ) ) ; if ( tail ) memcpy ( bufs + head , pipe -> bufs , tail * sizeof ( struct pipe_buffer ) ) ; } pipe -> curbuf = 0 ; kfree ( pipe -> bufs ) ; pipe -> bufs = bufs ; pipe -> buffers = nr_pages ; return nr_pages * PAGE_SIZE ; } "," ) ; } account_pipe_buffers ( pipe , pipe -> buffers , nr_pages ) ; ",torvalds@linux/759c01142a5d0f364a462346168a56de28a80f52,CVE-2016-2847,https://github.com/torvalds/linux/commit/759c01142a5d0f364a462346168a56de28a80f52,2016-04-27T17:59Z 200,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 201,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 202,CWE-399,"CWE-399 static void call_bind_status ( struct rpc_task * task ) { int status = - EIO ; if ( task -> tk_status >= 0 ) { dprint_status ( task ) ; task -> tk_status = 0 ; task -> tk_action = call_connect ; return ; } switch ( task -> tk_status ) { case - ENOMEM : dprintk ( ""RPC:%5urpcbindoutofmemory\\n"" , task -> tk_pid ) ; rpc_delay ( task , HZ >> 2 ) ; goto retry_timeout ; case - EACCES : dprintk ( ""RPC:%5uremoterpcbind:RPCprogram/version"" ""unavailable\\n"" , task -> tk_pid ) ; if ( task -> tk_msg . rpc_proc -> p_proc == 0 ) { status = - EOPNOTSUPP ; break ; } rpc_delay ( task , 3 * HZ ) ; goto retry_timeout ; case - ETIMEDOUT : dprintk ( ""RPC:%5urpcbindrequesttimedout\\n"" , task -> tk_pid ) ; goto retry_timeout ; case - EPFNOSUPPORT : dprintk ( ""RPC:%5uunrecognizedremoterpcbindservice\\n"" , task -> tk_pid ) ; break ; case - EPROTONOSUPPORT : dprintk ( ""RPC:%5uremoterpcbindversionunavailable,retrying\\n"" , task -> tk_pid ) ; task -> tk_status = 0 ; task -> tk_action = call_bind ; return ; case - ECONNREFUSED : case - ECONNRESET : case - ENOTCONN : case - EHOSTDOWN : case - EHOSTUNREACH : case - ENETUNREACH : case - EPIPE : dprintk ( ""RPC:%5uremoterpcbindunreachable:%d\\n"" , task -> tk_pid , task -> tk_status ) ; if ( ! RPC_IS_SOFTCONN ( task ) ) { rpc_delay ( task , 5 * HZ ) ; goto retry_timeout ; } status = task -> tk_status ; break ; default : dprintk ( ""RPC:%5uunrecognizedrpcbinderror(%d)\\n"" , task -> tk_pid , - task -> tk_status ) ; } rpc_exit ( task , status ) ; return ; retry_timeout : task -> tk_action = call_timeout ; } "," break ; } if ( task -> tk_rebind_retry == 0 ) break ; task -> tk_rebind_retry -- ; ",torvalds@linux/0b760113a3a155269a3fba93a409c640031dd68f,CVE-2011-2491,https://github.com/torvalds/linux/commit/0b760113a3a155269a3fba93a409c640031dd68f,2013-03-01T12:37Z 203,CWE-200,"CWE-200 static int mincore_pte_range ( pmd_t * pmd , unsigned long addr , unsigned long end , struct mm_walk * walk ) { spinlock_t * ptl ; struct vm_area_struct * vma = walk -> vma ; pte_t * ptep ; unsigned char * vec = walk -> private ; int nr = ( end - addr ) >> PAGE_SHIFT ; ptl = pmd_trans_huge_lock ( pmd , vma ) ; if ( ptl ) { memset ( vec , 1 , nr ) ; spin_unlock ( ptl ) ; goto out ; } if ( pmd_trans_unstable ( pmd ) ) { __mincore_unmapped_range ( addr , end , vma , vec ) ; goto out ; } ptep = pte_offset_map_lock ( walk -> mm , pmd , addr , & ptl ) ; for ( ; addr != end ; ptep ++ , addr += PAGE_SIZE ) { pte_t pte = * ptep ; if ( pte_none ( pte ) ) __mincore_unmapped_range ( addr , addr + PAGE_SIZE , vma , vec ) ; else if ( pte_present ( pte ) ) * vec = 1 ; else { swp_entry_t entry = pte_to_swp_entry ( pte ) ; if ( non_swap_entry ( entry ) ) { * vec = 1 ; } else { # ifdef CONFIG_SWAP * vec = mincore_page ( swap_address_space ( entry ) , swp_offset ( entry ) ) ; # else WARN_ON ( 1 ) ; * vec = 1 ; # endif } } vec ++ ; } pte_unmap_unlock ( ptep - 1 , ptl ) ; out : walk -> private += nr ; cond_resched ( ) ; return 0 ; } "," ) ) { memset ( vec , 1 , nr ) ; goto pte ) ) * vec = 0 ; else if pte ) ; * vec = ! ! non_swap_entry ( entry ( entry ) ; } vec ++ ",torvalds@linux/574823bfab82d9d8fa47f422778043fbb4b4f50e,CVE-2019-5489,https://github.com/torvalds/linux/commit/574823bfab82d9d8fa47f422778043fbb4b4f50e,2019-01-07T17:29Z 204,CWE-476,"CWE-476 static int peer_recv_callback ( rdpTransport * transport , wStream * s , void * extra ) { freerdp_peer * client = ( freerdp_peer * ) extra ; rdpRdp * rdp = client -> context -> rdp ; switch ( rdp -> state ) { case CONNECTION_STATE_INITIAL : if ( ! rdp_server_accept_nego ( rdp , s ) ) return - 1 ; if ( rdp -> nego -> selected_protocol & PROTOCOL_NLA ) { sspi_CopyAuthIdentity ( & client -> identity , & ( rdp -> nego -> transport -> credssp -> identity ) ) ; IFCALLRET ( client -> Logon , client -> authenticated , client , & client -> identity , TRUE ) ; credssp_free ( rdp -> nego -> transport -> credssp ) ; } else { IFCALLRET ( client -> Logon , client -> authenticated , client , & client -> identity , FALSE ) ; } break ; case CONNECTION_STATE_NEGO : if ( ! rdp_server_accept_mcs_connect_initial ( rdp , s ) ) return - 1 ; break ; case CONNECTION_STATE_MCS_CONNECT : if ( ! rdp_server_accept_mcs_erect_domain_request ( rdp , s ) ) return - 1 ; break ; case CONNECTION_STATE_MCS_ERECT_DOMAIN : if ( ! rdp_server_accept_mcs_attach_user_request ( rdp , s ) ) return - 1 ; break ; case CONNECTION_STATE_MCS_ATTACH_USER : if ( ! rdp_server_accept_mcs_channel_join_request ( rdp , s ) ) return - 1 ; break ; case CONNECTION_STATE_MCS_CHANNEL_JOIN : if ( rdp -> settings -> DisableEncryption ) { if ( ! rdp_server_accept_client_keys ( rdp , s ) ) return - 1 ; break ; } rdp -> state = CONNECTION_STATE_ESTABLISH_KEYS ; case CONNECTION_STATE_ESTABLISH_KEYS : if ( ! rdp_server_accept_client_info ( rdp , s ) ) return - 1 ; IFCALL ( client -> Capabilities , client ) ; if ( ! rdp_send_demand_active ( rdp ) ) return - 1 ; break ; case CONNECTION_STATE_LICENSE : if ( ! rdp_server_accept_confirm_active ( rdp , s ) ) { Stream_SetPosition ( s , 0 ) ; return peer_recv_pdu ( client , s ) ; } break ; case CONNECTION_STATE_ACTIVE : if ( peer_recv_pdu ( client , s ) < 0 ) return - 1 ; break ; default : fprintf ( stderr , ""Invalidstate%d\\n"" , rdp -> state ) ; return - 1 ; } return 0 ; } "," credssp ) ; rdp -> nego -> transport -> credssp = NULL ; ",FreeRDP@FreeRDP/0773bb9303d24473fe1185d85a424dfe159aff53,CVE-2013-4119,https://github.com/FreeRDP/FreeRDP/commit/0773bb9303d24473fe1185d85a424dfe159aff53,2016-10-03T21:59Z 205,CWE-119,"CWE-119 int exfat_mount ( struct exfat * ef , const char * spec , const char * options ) { int rc ; enum exfat_mode mode ; exfat_tzset ( ) ; memset ( ef , 0 , sizeof ( struct exfat ) ) ; parse_options ( ef , options ) ; if ( match_option ( options , ""ro"" ) ) mode = EXFAT_MODE_RO ; else if ( match_option ( options , ""ro_fallback"" ) ) mode = EXFAT_MODE_ANY ; else mode = EXFAT_MODE_RW ; ef -> dev = exfat_open ( spec , mode ) ; if ( ef -> dev == NULL ) return - EIO ; if ( exfat_get_mode ( ef -> dev ) == EXFAT_MODE_RO ) { if ( mode == EXFAT_MODE_ANY ) ef -> ro = - 1 ; else ef -> ro = 1 ; } ef -> sb = malloc ( sizeof ( struct exfat_super_block ) ) ; if ( ef -> sb == NULL ) { exfat_close ( ef -> dev ) ; exfat_error ( ""failedtoallocatememoryforthesuperblock"" ) ; return - ENOMEM ; } memset ( ef -> sb , 0 , sizeof ( struct exfat_super_block ) ) ; if ( exfat_pread ( ef -> dev , ef -> sb , sizeof ( struct exfat_super_block ) , 0 ) < 0 ) { exfat_close ( ef -> dev ) ; free ( ef -> sb ) ; exfat_error ( ""failedtoreadbootsector"" ) ; return - EIO ; } if ( memcmp ( ef -> sb -> oem_name , ""EXFAT"" , 8 ) != 0 ) { exfat_close ( ef -> dev ) ; free ( ef -> sb ) ; exfat_error ( ""exFATfilesystemisnotfound"" ) ; return - EIO ; } ef -> zero_cluster = malloc ( CLUSTER_SIZE ( * ef -> sb ) ) ; if ( ef -> zero_cluster == NULL ) { exfat_close ( ef -> dev ) ; free ( ef -> sb ) ; exfat_error ( ""failedtoallocatezerosector"" ) ; return - ENOMEM ; } if ( ! verify_vbr_checksum ( ef -> dev , ef -> zero_cluster , SECTOR_SIZE ( * ef -> sb ) ) ) { free ( ef -> zero_cluster ) ; exfat_close ( ef -> dev ) ; free ( ef -> sb ) ; return - EIO ; } memset ( ef -> zero_cluster , 0 , CLUSTER_SIZE ( * ef -> sb ) ) ; if ( ef -> sb -> version . major != 1 || ef -> sb -> version . minor != 0 ) { free ( ef -> zero_cluster ) ; exfat_close ( ef -> dev ) ; exfat_error ( ""unsupportedexFATversion:%hhu.%hhu"" , ef -> sb -> version . major , ef -> sb -> version . minor ) ; free ( ef -> sb ) ; return - EIO ; } if ( ef -> sb -> fat_count != 1 ) { free ( ef -> zero_cluster ) ; exfat_close ( ef -> dev ) ; exfat_error ( ""unsupportedFATcount:%hhu"" , ef -> sb -> fat_count ) ; free ( ef -> sb ) ; return - EIO ; } if ( ( int ) ef -> sb -> sector_bits + ( int ) ef -> sb -> spc_bits > 25 ) { free ( ef -> zero_cluster ) ; exfat_close ( ef -> dev ) ; exfat_error ( ""toobigclustersize:2^%d"" , ( int ) ef -> sb -> sector_bits + ( int ) ef -> sb -> spc_bits ) ; free ( ef -> sb ) ; return - EIO ; } if ( le64_to_cpu ( ef -> sb -> sector_count ) * SECTOR_SIZE ( * ef -> sb ) > exfat_get_size ( ef -> dev ) ) { exfat_warn ( ""filesystemislargerthanunderlyingdevice:"" ""%"" PRIu64 "">%"" PRIu64 , le64_to_cpu ( ef -> sb -> sector_count ) * SECTOR_SIZE ( * ef -> sb ) , exfat_get_size ( ef -> dev ) ) ; } ef -> root = malloc ( sizeof ( struct exfat_node ) ) ; if ( ef -> root == NULL ) { free ( ef -> zero_cluster ) ; exfat_close ( ef -> dev ) ; free ( ef -> sb ) ; exfat_error ( ""failedtoallocaterootnode"" ) ; return - ENOMEM ; } memset ( ef -> root , 0 , sizeof ( struct exfat_node ) ) ; ef -> root -> flags = EXFAT_ATTRIB_DIR ; ef -> root -> start_cluster = le32_to_cpu ( ef -> sb -> rootdir_cluster ) ; ef -> root -> fptr_cluster = ef -> root -> start_cluster ; ef -> root -> name [ 0 ] = cpu_to_le16 ( '\\0' ) ; ef -> root -> size = rootdir_size ( ef ) ; if ( ef -> root -> size == 0 ) { free ( ef -> root ) ; free ( ef -> zero_cluster ) ; exfat_close ( ef -> dev ) ; free ( ef -> sb ) ; return - EIO ; } ef -> root -> mtime = 0 ; ef -> root -> atime = 0 ; exfat_get_node ( ef -> root ) ; rc = exfat_cache_directory ( ef , ef -> root ) ; if ( rc != 0 ) goto error ; if ( ef -> upcase == NULL ) { exfat_error ( ""upcasetableisnotfound"" ) ; goto error ; } if ( ef -> cmap . chunk == NULL ) { exfat_error ( ""clustersbitmapisnotfound"" ) ; goto error ; } if ( prepare_super_block ( ef ) != 0 ) goto error ; return 0 ; error : exfat_put_node ( ef , ef -> root ) ; exfat_reset_cache ( ef ) ; free ( ef -> root ) ; free ( ef -> zero_cluster ) ; exfat_close ( ef -> dev ) ; free ( ef -> sb ) ; return - EIO ; } "," exfat_error ( ""exFATfilesystemisnotfound"" ) ; return - EIO ; } if ( ef -> sb -> sector_bits < 9 ) { exfat_close ( ef -> dev ) ; exfat_error ( ""toosmallsectorsize:2^%hhd"" , ef -> sb -> sector_bits ) ; free ( ef -> sb ) ; return - EIO ; } if ( ( int ) ef -> sb -> sector_bits + ( int ) ef -> sb -> spc_bits > 25 ) { exfat_close ( ef -> dev ) ; exfat_error ( ""toobigclustersize:2^(%hhd+%hhd)"" , ef -> sb -> sector_bits , ef -> sb -> spc_bits ) ; free ( ef -> sb } if ( le64_to_cpu ( ef ",relan@exfat/2e86ae5f81da11f11673d0546efb525af02b7786,CVE-2015-8026,https://github.com/relan/exfat/commit/2e86ae5f81da11f11673d0546efb525af02b7786,2017-03-27T15:59Z 206,CWE-134,"CWE-134 static void thunar_transfer_job_copy_node ( ThunarTransferJob * job , ThunarTransferNode * node , GFile * target_file , GFile * target_parent_file , GList * * target_file_list_return , GError * * error ) { ThunarThumbnailCache * thumbnail_cache ; ThunarApplication * application ; ThunarJobResponse response ; GFileInfo * info ; GError * err = NULL ; GFile * real_target_file = NULL ; gchar * base_name ; _thunar_return_if_fail ( THUNAR_IS_TRANSFER_JOB ( job ) ) ; _thunar_return_if_fail ( node != NULL && G_IS_FILE ( node -> source_file ) ) ; _thunar_return_if_fail ( target_file == NULL || node -> next == NULL ) ; _thunar_return_if_fail ( ( target_file == NULL && target_parent_file != NULL ) || ( target_file != NULL && target_parent_file == NULL ) ) ; _thunar_return_if_fail ( error == NULL || * error == NULL ) ; application = thunar_application_get ( ) ; thumbnail_cache = thunar_application_get_thumbnail_cache ( application ) ; g_object_unref ( application ) ; for ( ; err == NULL && node != NULL ; node = node -> next ) { if ( G_LIKELY ( target_file == NULL ) ) { base_name = g_file_get_basename ( node -> source_file ) ; target_file = g_file_get_child ( target_parent_file , base_name ) ; g_free ( base_name ) ; } else target_file = g_object_ref ( target_file ) ; info = g_file_query_info ( node -> source_file , G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME , G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS , exo_job_get_cancellable ( EXO_JOB ( job ) ) , & err ) ; if ( info == NULL ) { g_object_unref ( target_file ) ; break ; } exo_job_info_message ( EXO_JOB ( job ) , g_file_info_get_display_name ( info ) ) ; retry_copy : real_target_file = thunar_transfer_job_copy_file ( job , node -> source_file , target_file , & err ) ; if ( G_LIKELY ( real_target_file != NULL ) ) { if ( G_LIKELY ( node -> source_file != real_target_file ) ) { thunar_thumbnail_cache_copy_file ( thumbnail_cache , node -> source_file , real_target_file ) ; if ( node -> children != NULL ) { thunar_transfer_job_copy_node ( job , node -> children , NULL , real_target_file , NULL , & err ) ; thunar_transfer_node_free ( node -> children ) ; node -> children = NULL ; } if ( G_UNLIKELY ( err != NULL ) ) { g_object_unref ( real_target_file ) ; g_object_unref ( target_file ) ; break ; } if ( G_LIKELY ( target_file_list_return != NULL ) ) { * target_file_list_return = thunar_g_file_list_prepend ( * target_file_list_return , real_target_file ) ; } retry_remove : if ( job -> type == THUNAR_TRANSFER_JOB_MOVE ) { if ( g_file_delete ( node -> source_file , exo_job_get_cancellable ( EXO_JOB ( job ) ) , & err ) ) { thunar_thumbnail_cache_delete_file ( thumbnail_cache , node -> source_file ) ; } else { response = thunar_job_ask_skip ( THUNAR_JOB ( job ) , ""%s"" , err -> message ) ; g_clear_error ( & err ) ; if ( G_UNLIKELY ( response == THUNAR_JOB_RESPONSE_RETRY ) ) goto retry_remove ; } } } g_object_unref ( real_target_file ) ; } else if ( err != NULL ) { if ( err -> domain != G_IO_ERROR || err -> code != G_IO_ERROR_NO_SPACE ) { response = thunar_job_ask_skip ( THUNAR_JOB ( job ) , ""%s"" , err -> message ) ; g_clear_error ( & err ) ; if ( G_UNLIKELY ( response == THUNAR_JOB_RESPONSE_RETRY ) ) goto retry_copy ; } } g_object_unref ( target_file ) ; target_file = NULL ; g_object_unref ( info ) ; } g_object_unref ( thumbnail_cache ) ; if ( G_UNLIKELY ( err != NULL ) ) g_propagate_error ( error , err ) ; } "," job ) , ""%s"" , ",xfce-mirror@thunar/03dd312e157d4fa8a11d5fa402706ae5b05806fa,CVE-2011-1588,https://github.com/xfce-mirror/thunar/commit/03dd312e157d4fa8a11d5fa402706ae5b05806fa,2019-11-14T02:15Z 207,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 208,CWE-362,"CWE-362 SYSCALL_DEFINE3 ( shmctl , int , shmid , int , cmd , struct shmid_ds __user * , buf ) { struct shmid_kernel * shp ; int err , version ; struct ipc_namespace * ns ; if ( cmd < 0 || shmid < 0 ) return - EINVAL ; version = ipc_parse_version ( & cmd ) ; ns = current -> nsproxy -> ipc_ns ; switch ( cmd ) { case IPC_INFO : case SHM_INFO : case SHM_STAT : case IPC_STAT : return shmctl_nolock ( ns , shmid , cmd , version , buf ) ; case IPC_RMID : case IPC_SET : return shmctl_down ( ns , shmid , cmd , buf , version ) ; case SHM_LOCK : case SHM_UNLOCK : { struct file * shm_file ; rcu_read_lock ( ) ; shp = shm_obtain_object_check ( ns , shmid ) ; if ( IS_ERR ( shp ) ) { err = PTR_ERR ( shp ) ; goto out_unlock1 ; } audit_ipc_obj ( & ( shp -> shm_perm ) ) ; err = security_shm_shmctl ( shp , cmd ) ; if ( err ) goto out_unlock1 ; ipc_lock_object ( & shp -> shm_perm ) ; if ( ! ns_capable ( ns -> user_ns , CAP_IPC_LOCK ) ) { kuid_t euid = current_euid ( ) ; err = - EPERM ; if ( ! uid_eq ( euid , shp -> shm_perm . uid ) && ! uid_eq ( euid , shp -> shm_perm . cuid ) ) goto out_unlock0 ; if ( cmd == SHM_LOCK && ! rlimit ( RLIMIT_MEMLOCK ) ) goto out_unlock0 ; } shm_file = shp -> shm_file ; if ( is_file_hugepages ( shm_file ) ) goto out_unlock0 ; if ( cmd == SHM_LOCK ) { struct user_struct * user = current_user ( ) ; err = shmem_lock ( shm_file , 1 , user ) ; if ( ! err && ! ( shp -> shm_perm . mode & SHM_LOCKED ) ) { shp -> shm_perm . mode |= SHM_LOCKED ; shp -> mlock_user = user ; } goto out_unlock0 ; } if ( ! ( shp -> shm_perm . mode & SHM_LOCKED ) ) goto out_unlock0 ; shmem_lock ( shm_file , 0 , shp -> mlock_user ) ; shp -> shm_perm . mode &= ~ SHM_LOCKED ; shp -> mlock_user = NULL ; get_file ( shm_file ) ; ipc_unlock_object ( & shp -> shm_perm ) ; rcu_read_unlock ( ) ; shmem_unlock_mapping ( shm_file -> f_mapping ) ; fput ( shm_file ) ; return err ; } default : return - EINVAL ; } out_unlock0 : ipc_unlock_object ( & shp -> shm_perm ) ; out_unlock1 : rcu_read_unlock ( ) ; return err ; } "," ; if ( shm_file == NULL ) { err = - EIDRM ; goto out_unlock0 ; } if ( ",torvalds@linux/a399b29dfbaaaf91162b2dc5a5875dd51bbfa2a1,CVE-2013-7026,https://github.com/torvalds/linux/commit/a399b29dfbaaaf91162b2dc5a5875dd51bbfa2a1,2013-12-09T18:55Z 209,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 210,CWE-000,"CWE-000 void macvlan_common_setup ( struct net_device * dev ) { ether_setup ( dev ) ; dev -> priv_flags &= ~ IFF_XMIT_DST_RELEASE ; dev -> netdev_ops = & macvlan_netdev_ops ; dev -> destructor = free_netdev ; dev -> header_ops = & macvlan_hard_header_ops , dev -> ethtool_ops = & macvlan_ethtool_ops ; } "," priv_flags &= ~ ( IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING ) ; dev -> ",torvalds@linux/550fd08c2cebad61c548def135f67aba284c6162,CVE-2011-4112,https://github.com/torvalds/linux/commit/550fd08c2cebad61c548def135f67aba284c6162,2012-05-17T11:00Z 211,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 212,CWE-125,"CWE-125 static int mp_join_print ( netdissect_options * ndo , const u_char * opt , u_int opt_len , u_char flags ) { const struct mp_join * mpj = ( const struct mp_join * ) opt ; if ( ! ( opt_len == 12 && flags & TH_SYN ) && ! ( opt_len == 16 && ( flags & ( TH_SYN | TH_ACK ) ) == ( TH_SYN | TH_ACK ) ) && ! ( opt_len == 24 && flags & TH_ACK ) ) return 0 ; if ( opt_len != 24 ) { if ( mpj -> sub_b & MP_JOIN_B ) ND_PRINT ( ( ndo , ""backup"" ) ) ; ND_PRINT ( ( ndo , ""id%u"" , mpj -> addr_id ) ) ; } switch ( opt_len ) { case 12 : ND_PRINT ( ( ndo , ""token0x%x"" ""nonce0x%x"" , EXTRACT_32BITS ( mpj -> u . syn . token ) , EXTRACT_32BITS ( mpj -> u . syn . nonce ) ) ) ; break ; case 16 : ND_PRINT ( ( ndo , ""hmac0x%"" PRIx64 ""nonce0x%x"" , EXTRACT_64BITS ( mpj -> u . synack . mac ) , EXTRACT_32BITS ( mpj -> u . synack . nonce ) ) ) ; break ; case 24 : { size_t i ; ND_PRINT ( ( ndo , ""hmac0x"" ) ) ; for ( i = 0 ; i < sizeof ( mpj -> u . ack . mac ) ; ++ i ) ND_PRINT ( ( ndo , ""%02x"" , mpj -> u . ack . mac [ i ] ) ) ; } default : break ; } return 1 ; } "," == 12 && ( & TH_SYN ) ) == 24 && ( flags & TH_ACK ) ",the-tcpdump-group@tcpdump/4c3aee4bb0294c232d56b6d34e9eeb74f630fe8c,CVE-2017-13040,https://github.com/the-tcpdump-group/tcpdump/commit/4c3aee4bb0294c232d56b6d34e9eeb74f630fe8c,2017-09-14T06:29Z 213,CWE-125,"CWE-125 void ndpi_search_oracle ( struct ndpi_detection_module_struct * ndpi_struct , struct ndpi_flow_struct * flow ) { struct ndpi_packet_struct * packet = & flow -> packet ; u_int16_t dport = 0 , sport = 0 ; NDPI_LOG_DBG ( ndpi_struct , ""searchORACLE\\n"" ) ; if ( packet -> tcp != NULL ) { sport = ntohs ( packet -> tcp -> source ) , dport = ntohs ( packet -> tcp -> dest ) ; NDPI_LOG_DBG2 ( ndpi_struct , ""calculatingORACLEovertcp\\n"" ) ; if ( ( dport == 1521 || sport == 1521 ) && ( ( ( packet -> payload [ 0 ] == 0x07 ) && ( packet -> payload [ 1 ] == 0xff ) && ( packet -> payload [ 2 ] == 0x00 ) ) || ( ( packet -> payload_packet_len >= 232 ) && ( ( packet -> payload [ 0 ] == 0x00 ) || ( packet -> payload [ 0 ] == 0x01 ) ) && ( packet -> payload [ 1 ] != 0x00 ) && ( packet -> payload [ 2 ] == 0x00 ) && ( packet -> payload [ 3 ] == 0x00 ) ) ) ) { NDPI_LOG_INFO ( ndpi_struct , ""foundoracle\\n"" ) ; ndpi_int_oracle_add_connection ( ndpi_struct , flow ) ; } else if ( packet -> payload_packet_len == 213 && packet -> payload [ 0 ] == 0x00 && packet -> payload [ 1 ] == 0xd5 && packet -> payload [ 2 ] == 0x00 && packet -> payload [ 3 ] == 0x00 ) { NDPI_LOG_INFO ( ndpi_struct , ""foundoracle\\n"" ) ; ndpi_int_oracle_add_connection ( ndpi_struct , flow ) ; } } else { NDPI_EXCLUDE_PROTO ( ndpi_struct , flow ) ; } } "," ( packet -> payload_packet_len >= 3 && packet -> ",ntop@nDPI/b69177be2fbe01c2442239a61832c44e40136c05,CVE-2020-15476,https://github.com/ntop/nDPI/commit/b69177be2fbe01c2442239a61832c44e40136c05,2020-07-01T11:15Z 214,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 215,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 216,CWE-119,"CWE-119 PHP_FUNCTION ( radius_get_vendor_attr ) { int res ; const void * data ; int len ; u_int32_t vendor ; if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) TSRMLS_CC , ""s"" , & data , & len ) == FAILURE ) { return ; } res = rad_get_vendor_attr ( & vendor , & data , ( size_t * ) & len ) ; if ( res == - 1 ) { RETURN_FALSE ; } else { array_init ( return_value ) ; add_assoc_long ( return_value , ""attr"" , res ) ; add_assoc_long ( return_value , ""vendor"" , vendor ) ; add_assoc_stringl ( return_value , ""data"" , ( char * ) data , len , 1 ) ; return ; } } "," radius_get_vendor_attr ) { const void * void * data , * raw ; u_int32_t vendor ; unsigned char type ; size_t data_len ""s"" , & raw , & len return ; } if ( rad_get_vendor_attr ( & vendor , & type , & data , & data_len , raw , len ) == - 1 , ""attr"" , type ) ; add_assoc_long ) data , data_len , 1 ) ",LawnGnome@php-radius/13c149b051f82b709e8d7cc32111e84b49d57234,CVE-2013-2220,https://github.com/LawnGnome/php-radius/commit/13c149b051f82b709e8d7cc32111e84b49d57234,2013-07-31T13:20Z 217,CWE-000,"CWE-000 static void sas_resume_port ( struct asd_sas_phy * phy ) { struct domain_device * dev ; struct asd_sas_port * port = phy -> port ; struct sas_ha_struct * sas_ha = phy -> ha ; struct sas_internal * si = to_sas_internal ( sas_ha -> core . shost -> transportt ) ; if ( si -> dft -> lldd_port_formed ) si -> dft -> lldd_port_formed ( phy ) ; if ( port -> suspended ) port -> suspended = 0 ; else { return ; } list_for_each_entry ( dev , & port -> dev_list , dev_list_node ) { int i , rc ; rc = sas_notify_lldd_dev_found ( dev ) ; if ( rc ) { sas_unregister_dev ( port , dev ) ; continue ; } if ( dev -> dev_type == SAS_EDGE_EXPANDER_DEVICE || dev -> dev_type == SAS_FANOUT_EXPANDER_DEVICE ) { dev -> ex_dev . ex_change_count = - 1 ; for ( i = 0 ; i < dev -> ex_dev . num_phys ; i ++ ) { struct ex_phy * phy = & dev -> ex_dev . ex_phy [ i ] ; phy -> phy_change_count = - 1 ; } } } sas_discover_event ( port , DISCE_RESUME ) ; } "," port , dev ) ; sas_destruct_devices ( port ",torvalds@linux/0558f33c06bb910e2879e355192227a8e8f0219d,CVE-2017-18232,https://github.com/torvalds/linux/commit/0558f33c06bb910e2879e355192227a8e8f0219d,2018-03-15T04:29Z 218,CWE-20,"CWE-20 int key_update ( key_ref_t key_ref , const void * payload , size_t plen ) { struct key_preparsed_payload prep ; struct key * key = key_ref_to_ptr ( key_ref ) ; int ret ; key_check ( key ) ; ret = key_permission ( key_ref , KEY_NEED_WRITE ) ; if ( ret < 0 ) return ret ; if ( ! key -> type -> update ) return - EOPNOTSUPP ; memset ( & prep , 0 , sizeof ( prep ) ) ; prep . data = payload ; prep . datalen = plen ; prep . quotalen = key -> type -> def_datalen ; prep . expiry = TIME_T_MAX ; if ( key -> type -> preparse ) { ret = key -> type -> preparse ( & prep ) ; if ( ret < 0 ) 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 ) ; error : if ( key -> type -> preparse ) key -> type -> free_preparse ( & prep ) ; return ret ; } "," == 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 219,CWE-119,"CWE-119 static void rd_pick_partition ( VP9_COMP * cpi , const TileInfo * const tile , TOKENEXTRA * * tp , int mi_row , int mi_col , BLOCK_SIZE bsize , int * rate , int64_t * dist , int do_recon , int64_t best_rd ) { VP9_COMMON * const cm = & cpi -> common ; MACROBLOCK * const x = & cpi -> mb ; MACROBLOCKD * const xd = & x -> e_mbd ; const int mi_step = num_8x8_blocks_wide_lookup [ bsize ] / 2 ; ENTROPY_CONTEXT l [ 16 * MAX_MB_PLANE ] , a [ 16 * MAX_MB_PLANE ] ; PARTITION_CONTEXT sl [ 8 ] , sa [ 8 ] ; TOKENEXTRA * tp_orig = * tp ; PICK_MODE_CONTEXT * ctx = get_block_context ( x , bsize ) ; int i , pl ; BLOCK_SIZE subsize ; int this_rate , sum_rate = 0 , best_rate = INT_MAX ; int64_t this_dist , sum_dist = 0 , best_dist = INT64_MAX ; int64_t sum_rd = 0 ; int do_split = bsize >= BLOCK_8X8 ; int do_rect = 1 ; const int force_horz_split = ( mi_row + mi_step >= cm -> mi_rows ) ; const int force_vert_split = ( mi_col + mi_step >= cm -> mi_cols ) ; const int xss = x -> e_mbd . plane [ 1 ] . subsampling_x ; const int yss = x -> e_mbd . plane [ 1 ] . subsampling_y ; int partition_none_allowed = ! force_horz_split && ! force_vert_split ; int partition_horz_allowed = ! force_vert_split && yss <= xss && bsize >= BLOCK_8X8 ; int partition_vert_allowed = ! force_horz_split && xss <= yss && bsize >= BLOCK_8X8 ; ( void ) * tp_orig ; if ( bsize < BLOCK_8X8 ) { if ( x -> ab_index != 0 ) { * rate = 0 ; * dist = 0 ; return ; } } assert ( num_8x8_blocks_wide_lookup [ bsize ] == num_8x8_blocks_high_lookup [ bsize ] ) ; if ( bsize == BLOCK_16X16 ) { set_offsets ( cpi , tile , mi_row , mi_col , bsize ) ; x -> mb_energy = vp9_block_energy ( cpi , x , bsize ) ; } else { x -> in_active_map = check_active_map ( cpi , x , mi_row , mi_col , bsize ) ; } if ( cpi -> sf . auto_min_max_partition_size ) { partition_none_allowed &= ( bsize <= cpi -> sf . max_partition_size && bsize >= cpi -> sf . min_partition_size ) ; partition_horz_allowed &= ( ( bsize <= cpi -> sf . max_partition_size && bsize > cpi -> sf . min_partition_size ) || force_horz_split ) ; partition_vert_allowed &= ( ( bsize <= cpi -> sf . max_partition_size && bsize > cpi -> sf . min_partition_size ) || force_vert_split ) ; do_split &= bsize > cpi -> sf . min_partition_size ; } if ( cpi -> sf . use_square_partition_only ) { partition_horz_allowed &= force_horz_split ; partition_vert_allowed &= force_vert_split ; } save_context ( cpi , mi_row , mi_col , a , l , sa , sl , bsize ) ; if ( cpi -> sf . disable_split_var_thresh && partition_none_allowed ) { unsigned int source_variancey ; vp9_setup_src_planes ( x , cpi -> Source , mi_row , mi_col ) ; source_variancey = get_sby_perpixel_variance ( cpi , x , bsize ) ; if ( source_variancey < cpi -> sf . disable_split_var_thresh ) { do_split = 0 ; if ( source_variancey < cpi -> sf . disable_split_var_thresh / 2 ) do_rect = 0 ; } } if ( ! x -> in_active_map && ( partition_horz_allowed || partition_vert_allowed ) ) do_split = 0 ; if ( partition_none_allowed ) { rd_pick_sb_modes ( cpi , tile , mi_row , mi_col , & this_rate , & this_dist , bsize , ctx , best_rd ) ; if ( this_rate != INT_MAX ) { if ( bsize >= BLOCK_8X8 ) { pl = partition_plane_context ( xd , mi_row , mi_col , bsize ) ; this_rate += x -> partition_cost [ pl ] [ PARTITION_NONE ] ; } sum_rd = RDCOST ( x -> rdmult , x -> rddiv , this_rate , this_dist ) ; if ( sum_rd < best_rd ) { int64_t stop_thresh = 4096 ; int64_t stop_thresh_rd ; best_rate = this_rate ; best_dist = this_dist ; best_rd = sum_rd ; if ( bsize >= BLOCK_8X8 ) * ( get_sb_partitioning ( x , bsize ) ) = bsize ; stop_thresh >>= 8 - ( b_width_log2_lookup [ bsize ] + b_height_log2_lookup [ bsize ] ) ; stop_thresh_rd = RDCOST ( x -> rdmult , x -> rddiv , 0 , stop_thresh ) ; if ( ! x -> e_mbd . lossless && best_rd < stop_thresh_rd ) { do_split = 0 ; do_rect = 0 ; } } } if ( ! x -> in_active_map ) { do_split = 0 ; do_rect = 0 ; } restore_context ( cpi , mi_row , mi_col , a , l , sa , sl , bsize ) ; } if ( cpi -> sf . adaptive_motion_search ) store_pred_mv ( x , ctx ) ; sum_rd = 0 ; if ( do_split ) { subsize = get_subsize ( bsize , PARTITION_SPLIT ) ; for ( i = 0 ; i < 4 && sum_rd < best_rd ; ++ i ) { const int x_idx = ( i & 1 ) * mi_step ; const int y_idx = ( i >> 1 ) * mi_step ; if ( mi_row + y_idx >= cm -> mi_rows || mi_col + x_idx >= cm -> mi_cols ) continue ; * get_sb_index ( x , subsize ) = i ; if ( cpi -> sf . adaptive_motion_search ) load_pred_mv ( x , ctx ) ; if ( cpi -> sf . adaptive_pred_interp_filter && bsize == BLOCK_8X8 && partition_none_allowed ) get_block_context ( x , subsize ) -> pred_interp_filter = ctx -> mic . mbmi . interp_filter ; rd_pick_partition ( cpi , tile , tp , mi_row + y_idx , mi_col + x_idx , subsize , & this_rate , & this_dist , i != 3 , best_rd - sum_rd ) ; if ( this_rate == INT_MAX ) { sum_rd = INT64_MAX ; } else { sum_rate += this_rate ; sum_dist += this_dist ; sum_rd = RDCOST ( x -> rdmult , x -> rddiv , sum_rate , sum_dist ) ; } } if ( sum_rd < best_rd && i == 4 ) { pl = partition_plane_context ( xd , mi_row , mi_col , bsize ) ; sum_rate += x -> partition_cost [ pl ] [ PARTITION_SPLIT ] ; sum_rd = RDCOST ( x -> rdmult , x -> rddiv , sum_rate , sum_dist ) ; if ( sum_rd < best_rd ) { best_rate = sum_rate ; best_dist = sum_dist ; best_rd = sum_rd ; * ( get_sb_partitioning ( x , bsize ) ) = subsize ; } } else { if ( cpi -> sf . less_rectangular_check ) do_rect &= ! partition_none_allowed ; } restore_context ( cpi , mi_row , mi_col , a , l , sa , sl , bsize ) ; } if ( partition_horz_allowed && do_rect ) { subsize = get_subsize ( bsize , PARTITION_HORZ ) ; * get_sb_index ( x , subsize ) = 0 ; if ( cpi -> sf . adaptive_motion_search ) load_pred_mv ( x , ctx ) ; if ( cpi -> sf . adaptive_pred_interp_filter && bsize == BLOCK_8X8 && partition_none_allowed ) get_block_context ( x , subsize ) -> pred_interp_filter = ctx -> mic . mbmi . interp_filter ; rd_pick_sb_modes ( cpi , tile , mi_row , mi_col , & sum_rate , & sum_dist , subsize , get_block_context ( x , subsize ) , best_rd ) ; sum_rd = RDCOST ( x -> rdmult , x -> rddiv , sum_rate , sum_dist ) ; if ( sum_rd < best_rd && mi_row + mi_step < cm -> mi_rows ) { update_state ( cpi , get_block_context ( x , subsize ) , mi_row , mi_col , subsize , 0 ) ; encode_superblock ( cpi , tp , 0 , mi_row , mi_col , subsize ) ; * get_sb_index ( x , subsize ) = 1 ; if ( cpi -> sf . adaptive_motion_search ) load_pred_mv ( x , ctx ) ; if ( cpi -> sf . adaptive_pred_interp_filter && bsize == BLOCK_8X8 && partition_none_allowed ) get_block_context ( x , subsize ) -> pred_interp_filter = ctx -> mic . mbmi . interp_filter ; rd_pick_sb_modes ( cpi , tile , mi_row + mi_step , mi_col , & this_rate , & this_dist , subsize , get_block_context ( x , subsize ) , best_rd - sum_rd ) ; if ( this_rate == INT_MAX ) { sum_rd = INT64_MAX ; } else { sum_rate += this_rate ; sum_dist += this_dist ; sum_rd = RDCOST ( x -> rdmult , x -> rddiv , sum_rate , sum_dist ) ; } } if ( sum_rd < best_rd ) { pl = partition_plane_context ( xd , mi_row , mi_col , bsize ) ; sum_rate += x -> partition_cost [ pl ] [ PARTITION_HORZ ] ; sum_rd = RDCOST ( x -> rdmult , x -> rddiv , sum_rate , sum_dist ) ; if ( sum_rd < best_rd ) { best_rd = sum_rd ; best_rate = sum_rate ; best_dist = sum_dist ; * ( get_sb_partitioning ( x , bsize ) ) = subsize ; } } restore_context ( cpi , mi_row , mi_col , a , l , sa , sl , bsize ) ; } if ( partition_vert_allowed && do_rect ) { subsize = get_subsize ( bsize , PARTITION_VERT ) ; * get_sb_index ( x , subsize ) = 0 ; if ( cpi -> sf . adaptive_motion_search ) load_pred_mv ( x , ctx ) ; if ( cpi -> sf . adaptive_pred_interp_filter && bsize == BLOCK_8X8 && partition_none_allowed ) get_block_context ( x , subsize ) -> pred_interp_filter = ctx -> mic . mbmi . interp_filter ; rd_pick_sb_modes ( cpi , tile , mi_row , mi_col , & sum_rate , & sum_dist , subsize , get_block_context ( x , subsize ) , best_rd ) ; sum_rd = RDCOST ( x -> rdmult , x -> rddiv , sum_rate , sum_dist ) ; if ( sum_rd < best_rd && mi_col + mi_step < cm -> mi_cols ) { update_state ( cpi , get_block_context ( x , subsize ) , mi_row , mi_col , subsize , 0 ) ; encode_superblock ( cpi , tp , 0 , mi_row , mi_col , subsize ) ; * get_sb_index ( x , subsize ) = 1 ; if ( cpi -> sf . adaptive_motion_search ) load_pred_mv ( x , ctx ) ; if ( cpi -> sf . adaptive_pred_interp_filter && bsize == BLOCK_8X8 && partition_none_allowed ) get_block_context ( x , subsize ) -> pred_interp_filter = ctx -> mic . mbmi . interp_filter ; rd_pick_sb_modes ( cpi , tile , mi_row , mi_col + mi_step , & this_rate , & this_dist , subsize , get_block_context ( x , subsize ) , best_rd - sum_rd ) ; if ( this_rate == INT_MAX ) { sum_rd = INT64_MAX ; } else { sum_rate += this_rate ; sum_dist += this_dist ; sum_rd = RDCOST ( x -> rdmult , x -> rddiv , sum_rate , sum_dist ) ; } } if ( sum_rd < best_rd ) { pl = partition_plane_context ( xd , mi_row , mi_col , bsize ) ; sum_rate += x -> partition_cost [ pl ] [ PARTITION_VERT ] ; sum_rd = RDCOST ( x -> rdmult , x -> rddiv , sum_rate , sum_dist ) ; if ( sum_rd < best_rd ) { best_rate = sum_rate ; best_dist = sum_dist ; best_rd = sum_rd ; * ( get_sb_partitioning ( x , bsize ) ) = subsize ; } } restore_context ( cpi , mi_row , mi_col , a , l , sa , sl , bsize ) ; } ( void ) best_rd ; * rate = best_rate ; * dist = best_dist ; if ( best_rate < INT_MAX && best_dist < INT64_MAX && do_recon ) { int output_enabled = ( bsize == BLOCK_64X64 ) ; if ( ( cpi -> oxcf . aq_mode == COMPLEXITY_AQ ) && cm -> seg . update_map ) { vp9_select_in_frame_q_segment ( cpi , mi_row , mi_col , output_enabled , best_rate ) ; } if ( cpi -> oxcf . aq_mode == CYCLIC_REFRESH_AQ ) vp9_cyclic_refresh_set_rate_and_dist_sb ( cpi -> cyclic_refresh , best_rate , best_dist ) ; encode_sb ( cpi , tile , tp , mi_row , mi_col , output_enabled , bsize ) ; } if ( bsize == BLOCK_64X64 ) { assert ( tp_orig < * tp ) ; assert ( best_rate < INT_MAX ) ; assert ( best_dist < INT64_MAX ) ; } else { assert ( tp_orig == * tp ) ; } } "," * cpi , ThreadData * td , TileDataEnc * tile_data , TOKENEXTRA * int mi_row , int mi_col , BLOCK_SIZE bsize , BLOCK_SIZE bsize , RD_COST * rd_cost , int64_t best_rd , PC_TREE * pc_tree ) { VP9_COMMON -> common ; TileInfo * const tile_info = & tile_data -> tile_info ; x = & td -> mb ; * ctx = & pc_tree -> none ; int i BLOCK_SIZE subsize ; RD_COST this_rdc , sum_rdc , best_rdc ; int do_split . subsampling_y ; BLOCK_SIZE min_size = x -> min_partition_size ; BLOCK_SIZE max_size = x -> max_partition_size ; # if CONFIG_FP_MB_STATS unsigned int src_diff_var = UINT_MAX ; int none_complexity = 0 ; # endif * tp_orig ; assert ( num_8x8_blocks_wide_lookup [ bsize ] ) ; vp9_rd_cost_init ( & this_rdc ) ; vp9_rd_cost_init ( & sum_rdc ) ; vp9_rd_cost_reset ( & best_rdc ) ; best_rdc . rdcost = best_rd ; set_offsets ( cpi , tile_info , x , mi_row , mi_col , bsize bsize == BLOCK_16X16 && cpi -> oxcf . aq_mode ) x -> mb_energy bsize ) ; if ( cpi -> sf . cb_partition_search && bsize == BLOCK_16X16 ) { int cb_partition_search_ctrl = ( ( pc_tree -> index == 0 || pc_tree -> index == 3 ) + get_chessboard_index ( cm -> current_video_frame ) ) & 0x1 ; if ( cb_partition_search_ctrl && bsize > min_size && bsize < max_size ) set_partition_range ( cm , xd , mi_row , mi_col , bsize , & min_size , & max_size ) ; } ( bsize <= max_size && bsize >= min_size ) ; partition_horz_allowed ( bsize <= max_size && bsize > min_size ) || force_horz_split ( bsize <= max_size && bsize > min_size ) || force_vert_split &= bsize > min_size ; } if } save_context ( x , mi_row , bsize ) ; # if CONFIG_FP_MB_STATS if ( cpi -> use_fp_mb_stats ) { set_offsets ( cpi , tile_info , x , mi_row , mi_col , bsize ) ; src_diff_var = get_sby_perpixel_diff_variance ( cpi , & x -> plane [ 0 ] . src , mi_row , mi_col , bsize ) ; } # endif # if CONFIG_FP_MB_STATS if ( cpi -> use_fp_mb_stats && bsize >= BLOCK_32X32 && do_split && partition_none_allowed && src_diff_var > 4 && cm -> base_qindex < qindex_split_threshold_lookup [ bsize ] ) { int mb_row = mi_row >> 1 ; int mb_col = mi_col >> 1 ; int mb_row_end = MIN ( mb_row + num_16x16_blocks_high_lookup [ bsize ] , cm -> mb_rows ) ; int mb_col_end = MIN ( mb_col + num_16x16_blocks_wide_lookup [ bsize ] , cm -> mb_cols ) ; int r , c ; for ( r = mb_row ; r < mb_row_end ; r ++ ) { for ( c = mb_col ; c < mb_col_end ; c ++ ) { const int mb_index = r * cm -> mb_cols + c ; MOTION_DIRECTION this_mv ; MOTION_DIRECTION right_mv ; MOTION_DIRECTION bottom_mv ; this_mv = get_motion_direction_fp ( cpi -> twopass . this_frame_mb_stats [ mb_index ] ) ; if ( c != mb_col_end - 1 ) { right_mv = get_motion_direction_fp ( cpi -> twopass . this_frame_mb_stats [ mb_index + 1 ] ) ; none_complexity += get_motion_inconsistency ( this_mv , right_mv ) ; } if ( r != mb_row_end - 1 ) { bottom_mv = get_motion_direction_fp ( cpi -> twopass . this_frame_mb_stats [ mb_index + cm -> mb_cols ] ) ; none_complexity += get_motion_inconsistency ( this_mv , bottom_mv ) ; } } } if ( none_complexity > complexity_16x16_blocks_threshold [ bsize ] ) { partition_none_allowed = 0 ; = 0 ; } } # endif if ( partition_none_allowed ( cpi , tile_data , x , mi_row , mi_col , & this_rdc , bsize , ctx , best_rdc . rdcost ) ; if ( this_rdc . rate != INT_MAX ) bsize ) ; this_rdc . rate += cpi -> partition_cost [ PARTITION_NONE ] ; this_rdc . rdcost = RDCOST ( -> rddiv , this_rdc . rate , this_rdc . dist ) ; } if ( this_rdc . rdcost < best_rdc . rdcost ) { int64_t ) { int64_t dist_breakout_thr = cpi -> sf . partition_search_breakout_dist_thr ; int rate_breakout_thr = cpi -> sf . partition_search_breakout_rate_thr ; best_rdc = this_rdc ; if ( >= BLOCK_8X8 ) pc_tree -> partitioning = PARTITION_NONE ; dist_breakout_thr >>= 8 - ] ) ; rate_breakout_thr *= num_pels_log2_lookup [ bsize ] ; if ( ! x -> e_mbd . lossless && ( ctx -> skippable && best_rdc . dist < dist_breakout_thr && best_rdc . rate < rate_breakout_thr ) ) { do_split = 0 ; do_rect = 0 ; } # if CONFIG_FP_MB_STATS if ( cpi -> use_fp_mb_stats && do_split != 0 && cm -> base_qindex > qindex_skip_threshold_lookup [ bsize ] ) { int mb_row = mi_row >> 1 ; int mb_col = mi_col >> 1 ; int mb_row_end = MIN ( mb_row + num_16x16_blocks_high_lookup [ bsize ] , cm -> mb_rows ) ; int mb_col_end = MIN ( mb_col + num_16x16_blocks_wide_lookup [ bsize ] , cm -> mb_cols ) ; int r , c ; int skip = 1 ; for ( r = mb_row ; r < mb_row_end ; r ++ ) { for ( c = mb_col ; c < mb_col_end ; c ++ ) { const int mb_index = r * cm -> mb_cols + c ; if ( if ( ! ( cpi -> twopass . this_frame_mb_stats [ mb_index ] & FPMB_MOTION_ZERO_MASK ) || ! ( cpi -> twopass . this_frame_mb_stats [ mb_index ] & FPMB_ERROR_SMALL_MASK ) ) { skip = 0 ; break ; } } if ( skip == 0 ) { break ; } } if ( skip ) { if ( src_diff_var == UINT_MAX ) { set_offsets ( cpi , tile_info , x , mi_row , mi_col , bsize ) ; src_diff_var = get_sby_perpixel_diff_variance ( cpi , & x -> plane [ 0 ] . src , mi_row , mi_col , bsize ) ; } if ( src_diff_var < 8 ) { do_split } } } # endif } } restore_context ( x , mi_row , mi_col , a , l , sa , sl , bsize ) ; } if ( cpi -> sf . adaptive_motion_search ) store_pred_mv ( x , ctx ) ; if ( do_split ) { subsize = get_subsize ( bsize , PARTITION_SPLIT ) ; if ( bsize == BLOCK_8X8 ) { i = 4 ; if ( cpi -> sf . adaptive_pred_interp_filter && partition_none_allowed ) pc_tree -> leaf_split [ 0 ] -> pred_interp_filter = ctx -> mic . mbmi . interp_filter ; rd_pick_sb_modes ( cpi , tile_data , x , mi_row , mi_col , & sum_rdc , subsize , pc_tree -> leaf_split [ 0 ] , best_rdc . rdcost ) ; if ( sum_rdc . rate == INT_MAX ) sum_rdc . rdcost = INT64_MAX ; } else { for ( i < 4 && sum_rdc . rdcost < best_rdc . rdcost ; ++ i ) continue ; if ( cpi -> sf . adaptive_motion_search ) load_pred_mv ( x , ctx ) ; pc_tree -> split [ i ] -> index = i ; rd_pick_partition ( ( cpi , td , tile_data , tp , subsize , & this_rdc , best_rdc . rdcost - sum_rdc . rdcost , pc_tree -> split [ i ] ) ; if ( this_rdc . rate == INT_MAX ) INT_MAX ) { sum_rdc . rdcost = INT64_MAX ; = INT64_MAX ; break ; } else { sum_rdc . rate += this_rdc . rate ; sum_rdc . dist += this_rdc . dist ; sum_rdc . rdcost += this_rdc . rdcost ; } } } if ( sum_rdc . rdcost < best_rdc . rdcost && i == bsize ) ; sum_rdc . rate += cpi -> partition_cost [ PARTITION_SPLIT ] ; sum_rdc . rdcost = RDCOST ( -> rddiv , sum_rdc . rate , sum_rdc . dist ) ; if ( sum_rdc . rdcost < best_rdc . rdcost ) { best_rdc = sum_rdc ; pc_tree -> partitioning = PARTITION_SPLIT ; } } } restore_context ( x , mi_row , ( partition_horz_allowed && ( do_rect || vp9_active_h_edge ( cpi , mi_row , mi_step ) ) ) { subsize , PARTITION_HORZ ) ; if ( && partition_none_allowed ) pc_tree -> horizontal [ 0 ] . pred_interp_filter = ctx -> mic . mbmi . interp_filter ; rd_pick_sb_modes ( cpi , tile_data , x , mi_row , mi_col , & sum_rdc , subsize , & pc_tree -> horizontal [ 0 ] , best_rdc . rdcost ) ; if ( sum_rdc . rdcost < best_rdc . rdcost && mi_row + cm -> mi_rows && bsize > BLOCK_8X8 ) { PICK_MODE_CONTEXT * ctx = & pc_tree -> horizontal [ 0 ] ; update_state ( cpi ( cpi , td , ctx , mi_row , mi_col , subsize , 0 ) ; encode_superblock ( cpi , td , tp , 0 , mi_row , mi_col , subsize , ctx ) ; if ( && partition_none_allowed ) pc_tree -> horizontal [ 1 ] . pred_interp_filter = ctx ( cpi , tile_data , x , mi_row + mi_col , & this_rdc , subsize , & pc_tree -> horizontal [ 1 ] , best_rdc . rdcost - sum_rdc . rdcost ) ; if ( this_rdc . rate == INT_MAX ) INT_MAX ) { sum_rdc . rdcost = INT64_MAX ; } else { sum_rdc . rate += this_rdc . rate ; sum_rdc . dist += this_rdc . dist ; sum_rdc . rdcost += this_rdc . rdcost ; } } if ( sum_rdc . rdcost < best_rdc . rdcost ) { pl = partition_plane_context ( xd , mi_row , mi_col , bsize ) ; sum_rdc . rate += cpi -> partition_cost [ pl ] [ PARTITION_HORZ ] ; sum_rdc . rdcost = RDCOST ( -> rddiv , sum_rdc . rate , sum_rdc . dist ) ; if ( sum_rdc . rdcost < best_rdc . rdcost ) { best_rdc = sum_rdc ; pc_tree -> partitioning = PARTITION_HORZ ; } } restore_context ( x , mi_row , mi_col , a , l , sa , sl , bsize ) ; } if ( partition_vert_allowed && ( do_rect || vp9_active_v_edge ( cpi , mi_col , mi_step ) ) ) { subsize = get_subsize ( , PARTITION_VERT ) ; if ( && partition_none_allowed ) pc_tree -> vertical [ 0 ] . pred_interp_filter = ctx -> mic . mbmi . interp_filter ; rd_pick_sb_modes ( cpi , tile_data , x , mi_row , mi_col , & sum_rdc , subsize , & pc_tree -> vertical [ 0 ] , best_rdc . rdcost ) ; if ( sum_rdc . rdcost < best_rdc . rdcost && mi_col + cm -> mi_cols && bsize > BLOCK_8X8 ( cpi , td , & pc_tree -> vertical [ 0 ] , mi_row , mi_col , subsize , 0 ) ; encode_superblock ( cpi , td , tp , 0 , mi_row , mi_col , subsize , & pc_tree -> vertical [ 0 ] ) ; if ( && partition_none_allowed ) pc_tree -> vertical [ 1 ] . pred_interp_filter = ctx ( cpi , tile_data , x , mi_row , mi_step , & this_rdc , subsize , & pc_tree -> vertical [ 1 ] , best_rdc . rdcost - sum_rdc . rdcost ) ; if ( this_rdc . rate == INT_MAX ) INT_MAX ) { sum_rdc . rdcost = INT64_MAX ; } else { sum_rdc . rate += this_rdc . rate ; sum_rdc . dist += this_rdc . dist ; sum_rdc . rdcost += this_rdc . rdcost ; } } if ( sum_rdc . rdcost < best_rdc . rdcost ) { pl = partition_plane_context ( xd , mi_row , mi_col , bsize ) ; sum_rdc . rate += cpi -> partition_cost [ pl ] [ PARTITION_VERT ] ; sum_rdc . rdcost = RDCOST ( -> rddiv , sum_rdc . rate , sum_rdc . dist ) ; if ( sum_rdc . rdcost < best_rdc . rdcost ) { best_rdc = sum_rdc ; pc_tree -> partitioning = PARTITION_VERT ; } } restore_context ( x , mi_row , mi_col , a , l , sa , sl , bsize ) ; } ( void ) best_rd ; * rd_cost = best_rdc ; if ( best_rdc . rate < INT_MAX && < INT_MAX && best_rdc . dist < INT64_MAX && < INT64_MAX && pc_tree -> index != 3 ) { int BLOCK_64X64 ) ; encode_sb ( cpi , td , tile_info , tp , mi_row , , output_enabled , bsize , pc_tree ) ; } ; assert ( best_rdc . rate < INT_MAX ) ; assert ( best_rdc . dist < INT64_MAX ) ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 220,CWE-20,"CWE-20 static void * etm_setup_aux ( int event_cpu , void * * pages , int nr_pages , bool overwrite ) { int cpu ; cpumask_t * mask ; struct coresight_device * sink ; struct etm_event_data * event_data = NULL ; event_data = alloc_event_data ( event_cpu ) ; if ( ! event_data ) return NULL ; sink = coresight_get_enabled_sink ( true ) ; if ( ! sink ) goto err ; INIT_WORK ( & event_data -> work , free_event_data ) ; mask = & event_data -> mask ; for_each_cpu ( cpu , mask ) { struct coresight_device * csdev ; csdev = per_cpu ( csdev_src , cpu ) ; if ( ! csdev ) goto err ; event_data -> path [ cpu ] = coresight_build_path ( csdev , sink ) ; if ( IS_ERR ( event_data -> path [ cpu ] ) ) goto err ; } if ( ! sink_ops ( sink ) -> alloc_buffer ) goto err ; event_data -> snk_config = sink_ops ( sink ) -> alloc_buffer ( sink , cpu , pages , nr_pages , overwrite ) ; if ( ! event_data -> snk_config ) goto err ; out : return event_data ; err : etm_free_aux ( event_data ) ; event_data = NULL ; goto out ; } "," goto err ; cpu = cpumask_first ( mask ) ; ",torvalds@linux/f09444639099584bc4784dfcd85ada67c6f33e0f,CVE-2018-11232,https://github.com/torvalds/linux/commit/f09444639099584bc4784dfcd85ada67c6f33e0f,2018-05-18T04:29Z 221,CWE-787,"CWE-787 static pdf_creator_t * new_creator ( int * n_elements ) { pdf_creator_t * daddy ; static const pdf_creator_t creator_template [ ] = { { ""Title"" , """" } , { ""Author"" , """" } , { ""Subject"" , """" } , { ""Keywords"" , """" } , { ""Creator"" , """" } , { ""Producer"" , """" } , { ""CreationDate"" , """" } , { ""ModDate"" , """" } , { ""Trapped"" , """" } , } ; daddy = malloc ( sizeof ( creator_template ) ) ; memcpy ( daddy , creator_template , sizeof ( creator_template ) ) ; if ( n_elements ) * n_elements = sizeof ( creator_template ) / sizeof ( creator_template [ 0 ] ) ; return daddy ; } "," ; daddy = safe_calloc ( sizeof ( ",enferex@pdfresurrect/0c4120fffa3dffe97b95c486a120eded82afe8a6,CVE-2019-14934,https://github.com/enferex/pdfresurrect/commit/0c4120fffa3dffe97b95c486a120eded82afe8a6,2019-08-11T22:15Z 222,CWE-119,"CWE-119 static grub_err_t find_file ( const char * currpath , grub_fshelp_node_t currroot , grub_fshelp_node_t * currfound , struct grub_fshelp_find_file_closure * c ) { # ifndef _MSC_VER char fpath [ grub_strlen ( currpath ) + 1 ] ; # else char * fpath = grub_malloc ( grub_strlen ( currpath ) + 1 ) ; # endif char * name = fpath ; char * next ; enum grub_fshelp_filetype type = GRUB_FSHELP_DIR ; grub_fshelp_node_t currnode = currroot ; grub_fshelp_node_t oldnode = currroot ; c -> currroot = currroot ; grub_strncpy ( fpath , currpath , grub_strlen ( currpath ) + 1 ) ; while ( * name == '/' ) name ++ ; if ( ! * name ) { * currfound = currnode ; return 0 ; } for ( ; ; ) { int found ; struct find_file_closure cc ; next = grub_strchr ( name , '/' ) ; if ( next ) { while ( * next == '/' ) * ( next ++ ) = '\\0' ; } if ( type != GRUB_FSHELP_DIR ) { free_node ( currnode , c ) ; return grub_error ( GRUB_ERR_BAD_FILE_TYPE , ""notadirectory"" ) ; } cc . name = name ; cc . type = & type ; cc . oldnode = & oldnode ; cc . currnode = & currnode ; found = c -> iterate_dir ( currnode , iterate , & cc ) ; if ( ! found ) { if ( grub_errno ) return grub_errno ; break ; } if ( type == GRUB_FSHELP_SYMLINK ) { char * symlink ; if ( ++ ( c -> symlinknest ) == 8 ) { free_node ( currnode , c ) ; free_node ( oldnode , c ) ; return grub_error ( GRUB_ERR_SYMLINK_LOOP , ""toodeepnestingofsymlinks"" ) ; } symlink = c -> read_symlink ( currnode ) ; free_node ( currnode , c ) ; if ( ! symlink ) { free_node ( oldnode , c ) ; return grub_errno ; } if ( symlink [ 0 ] == '/' ) { free_node ( oldnode , c ) ; oldnode = c -> rootnode ; } find_file ( symlink , oldnode , & currnode , c ) ; type = c -> foundtype ; grub_free ( symlink ) ; if ( grub_errno ) { free_node ( oldnode , c ) ; return grub_errno ; } } free_node ( oldnode , c ) ; if ( ! next || * next == '\\0' ) { * currfound = currnode ; c -> foundtype = type ; return 0 ; } name = next ; } return grub_error ( GRUB_ERR_FILE_NOT_FOUND , ""filenotfound"" ) ; } "," c ) { char * fpath = grub_malloc ( grub_strlen ( currpath ) + 1 ) ; char * name = fpath ; char * next ; enum grub_fshelp_filetype type = GRUB_FSHELP_DIR ; grub_fshelp_node_t currnode = currroot ; grub_fshelp_node_t oldnode = currroot ; c -> currroot = currroot ; grub_strncpy ( fpath , currpath , grub_strlen ( currpath 1 ) ; while ( * currfound = currnode ; free ( fpath ) c ) ; free ( fpath ) ; ( grub_errno ) { free ( fpath ) ; return grub_errno ; } c ) ; free ( fpath ) ; oldnode , c ) ; free ( fpath c ) ; free ( fpath ) ; = type ; free ( fpath ) ; next ; } free ( fpath ) ; ",radare@radare2/65000a7fd9eea62359e6d6714f17b94a99a82edd,CVE-2017-9763,https://github.com/radare/radare2/commit/65000a7fd9eea62359e6d6714f17b94a99a82edd,2017-06-19T16:29Z 223,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 224,CWE-416,"CWE-416 int wwunpack ( uint8_t * exe , uint32_t exesz , uint8_t * wwsect , struct cli_exe_section * sects , uint16_t scount , uint32_t pe , int desc ) { uint8_t * structs = wwsect + 0x2a1 , * compd , * ccur , * unpd , * ucur , bc ; uint32_t src , srcend , szd , bt , bits ; int error = 0 , i ; cli_dbgmsg ( ""inwwunpack\\n"" ) ; while ( 1 ) { if ( ! CLI_ISCONTAINED ( wwsect , sects [ scount ] . rsz , structs , 17 ) ) { cli_dbgmsg ( ""WWPack:Arrayofstructsoutofsection\\n"" ) ; break ; } src = sects [ scount ] . rva - cli_readint32 ( structs ) ; structs += 8 ; szd = cli_readint32 ( structs ) * 4 ; structs += 4 ; srcend = cli_readint32 ( structs ) ; structs += 4 ; unpd = ucur = exe + src + srcend + 4 - szd ; if ( ! szd || ! CLI_ISCONTAINED ( exe , exesz , unpd , szd ) ) { cli_dbgmsg ( ""WWPack:Compresseddataoutoffile\\n"" ) ; break ; } cli_dbgmsg ( ""WWP:src:%x,szd:%x,srcend:%x-%x\\n"" , src , szd , srcend , srcend + 4 - szd ) ; if ( ! ( compd = cli_malloc ( szd ) ) ) { cli_dbgmsg ( ""WWPack:Unabletoallocatememoryforcompd\\n"" ) ; break ; } memcpy ( compd , unpd , szd ) ; memset ( unpd , - 1 , szd ) ; ccur = compd ; RESEED ; while ( ! error ) { uint32_t backbytes , backsize ; uint8_t saved ; BIT ; if ( ! bits ) { if ( ccur - compd >= szd || ! CLI_ISCONTAINED ( exe , exesz , ucur , 1 ) ) error = 1 ; else * ucur ++ = * ccur ++ ; continue ; } BITS ( 2 ) ; if ( bits == 3 ) { uint8_t shifted , subbed = 31 ; BITS ( 2 ) ; shifted = bits + 5 ; if ( bits >= 2 ) { shifted ++ ; subbed += 0x80 ; } backbytes = ( 1 << shifted ) - subbed ; BITS ( shifted ) ; if ( error || bits == 0x1ff ) break ; backbytes += bits ; if ( ! CLI_ISCONTAINED ( exe , exesz , ucur , 2 ) || ! CLI_ISCONTAINED ( exe , exesz , ucur - backbytes , 2 ) ) { error = 1 ; } else { ucur [ 0 ] = * ( ucur - backbytes ) ; ucur [ 1 ] = * ( ucur - backbytes + 1 ) ; ucur += 2 ; } continue ; } saved = bits ; BITS ( 3 ) ; if ( bits < 6 ) { backbytes = bits ; switch ( bits ) { case 4 : backbytes ++ ; case 3 : BIT ; backbytes += bits ; case 0 : case 1 : case 2 : backbytes += 5 ; break ; case 5 : backbytes = 12 ; break ; } BITS ( backbytes ) ; bits += ( 1 << backbytes ) - 31 ; } else if ( bits == 6 ) { BITS ( 0x0e ) ; bits += 0x1fe1 ; } else { BITS ( 0x0f ) ; bits += 0x5fe1 ; } backbytes = bits ; if ( ! saved ) { BIT ; if ( ! bits ) { BIT ; bits += 5 ; } else { BITS ( 3 ) ; if ( bits ) { bits += 6 ; } else { BITS ( 4 ) ; if ( bits ) { bits += 13 ; } else { uint8_t cnt = 4 ; uint16_t shifted = 0x0d ; do { if ( cnt == 7 ) { cnt = 0x0e ; shifted = 0 ; break ; } shifted = ( ( shifted + 2 ) << 1 ) - 1 ; BIT ; cnt ++ ; } while ( ! bits ) ; BITS ( cnt ) ; bits += shifted ; } } } backsize = bits ; } else { backsize = saved + 2 ; } if ( ! CLI_ISCONTAINED ( exe , exesz , ucur , backsize ) || ! CLI_ISCONTAINED ( exe , exesz , ucur - backbytes , backsize ) ) error = 1 ; else while ( backsize -- ) { * ucur = * ( ucur - backbytes ) ; ucur ++ ; } } free ( compd ) ; if ( error ) { cli_dbgmsg ( ""WWPack:decompressionerror\\n"" ) ; break ; } if ( error || ! * structs ++ ) break ; } if ( ! error ) { if ( pe + 6 > exesz || pe + 7 > exesz || pe + 0x28 > exesz || pe + 0x50 > exesz || pe + 0x14 > exesz ) return CL_EFORMAT ; exe [ pe + 6 ] = ( uint8_t ) scount ; exe [ pe + 7 ] = ( uint8_t ) ( scount >> 8 ) ; cli_writeint32 ( & exe [ pe + 0x28 ] , cli_readint32 ( wwsect + 0x295 ) + sects [ scount ] . rva + 0x299 ) ; cli_writeint32 ( & exe [ pe + 0x50 ] , cli_readint32 ( & exe [ pe + 0x50 ] ) - sects [ scount ] . vsz ) ; structs = & exe [ ( 0xffff & cli_readint32 ( & exe [ pe + 0x14 ] ) ) + pe + 0x18 ] ; for ( i = 0 ; i < scount ; i ++ ) { if ( ! CLI_ISCONTAINED ( exe , exesz , structs , 0x28 ) ) { cli_dbgmsg ( ""WWPack:structspointeroutofbounds\\n"" ) ; return CL_EFORMAT ; } cli_writeint32 ( structs + 8 , sects [ i ] . vsz ) ; cli_writeint32 ( structs + 12 , sects [ i ] . rva ) ; cli_writeint32 ( structs + 16 , sects [ i ] . vsz ) ; cli_writeint32 ( structs + 20 , sects [ i ] . rva ) ; structs += 0x28 ; } if ( ! CLI_ISCONTAINED ( exe , exesz , structs , 0x28 ) ) { cli_dbgmsg ( ""WWPack:structspointeroutofbounds\\n"" ) ; return CL_EFORMAT ; } memset ( structs , 0 , 0x28 ) ; error = ( uint32_t ) cli_writen ( desc , exe , exesz ) != exesz ; } return error ; } "," 8 ) ; if ( ! CLI_ISCONTAINED ( wwsect , sects [ scount ] . rsz , wwsect + 0x295 , 4 ) || ! CLI_ISCONTAINED ( wwsect , sects [ scount ] . rsz , wwsect + 0x295 + sects [ scount ] . rva , 4 ) || ! CLI_ISCONTAINED ( wwsect , sects [ scount ] . rsz , wwsect + 0x295 + sects [ scount ] . rva + 0x299 , 4 ) ) { cli_dbgmsg ( ""WWPack:unpackmemoryaddressoutofbounds.\\n"" ) ; return CL_EFORMAT ; } ",vrtadmin@clamav-devel/dfc00cd3301a42b571454b51a6102eecf58407bc,CVE-2017-6420,https://github.com/vrtadmin/clamav-devel/commit/dfc00cd3301a42b571454b51a6102eecf58407bc,2017-08-07T03:29Z 225,CWE-416,"CWE-416 static int __ext4_expand_extra_isize ( struct inode * inode , unsigned int new_extra_isize , struct ext4_iloc * iloc , handle_t * handle , int * no_expand ) { struct ext4_inode * raw_inode ; struct ext4_xattr_ibody_header * header ; int error ; raw_inode = ext4_raw_inode ( iloc ) ; header = IHDR ( inode , raw_inode ) ; if ( ! ext4_test_inode_state ( inode , EXT4_STATE_XATTR ) || header -> h_magic != cpu_to_le32 ( EXT4_XATTR_MAGIC ) ) { memset ( ( void * ) raw_inode + EXT4_GOOD_OLD_INODE_SIZE + EXT4_I ( inode ) -> i_extra_isize , 0 , new_extra_isize - EXT4_I ( inode ) -> i_extra_isize ) ; EXT4_I ( inode ) -> i_extra_isize = new_extra_isize ; return 0 ; } error = ext4_expand_extra_isize_ea ( inode , new_extra_isize , raw_inode , handle ) ; if ( error ) { * no_expand = 1 ; } return error ; } "," * header ; unsigned int inode_size = EXT4_INODE_SIZE ( inode -> i_sb ) ; struct ext4_inode_info * ei = EXT4_I ( inode ) ; int error ; if ( ( EXT4_GOOD_OLD_INODE_SIZE + ei -> i_extra_isize > inode_size ) || ( ei -> i_extra_isize & 3 ) ) { EXT4_ERROR_INODE ( inode , ""badextra_isize%u(inodesize%u)"" , ei -> i_extra_isize , EXT4_INODE_SIZE ( inode -> i_sb ) ) ; return - EFSCORRUPTED ; } if ( ( new_extra_isize < ei -> i_extra_isize ) || ( new_extra_isize < 4 ) || ( new_extra_isize > inode_size - EXT4_GOOD_OLD_INODE_SIZE ) ) return - EINVAL ; raw_inode = ",torvalds@linux/4ea99936a1630f51fc3a2d61a58ec4a1c4b7d55a,CVE-2019-19767,https://github.com/torvalds/linux/commit/4ea99936a1630f51fc3a2d61a58ec4a1c4b7d55a,2019-12-12T20:15Z 226,CWE-369,"CWE-369 static int mov_write_audio_tag ( AVFormatContext * s , AVIOContext * pb , MOVMuxContext * mov , MOVTrack * track ) { int64_t pos = avio_tell ( pb ) ; int version = 0 ; uint32_t tag = track -> tag ; if ( track -> mode == MODE_MOV ) { if ( track -> timescale > UINT16_MAX ) { if ( mov_get_lpcm_flags ( track -> par -> codec_id ) ) tag = AV_RL32 ( ""lpcm"" ) ; version = 2 ; } else if ( track -> audio_vbr || mov_pcm_le_gt16 ( track -> par -> codec_id ) || mov_pcm_be_gt16 ( track -> par -> codec_id ) || track -> par -> codec_id == AV_CODEC_ID_ADPCM_MS || track -> par -> codec_id == AV_CODEC_ID_ADPCM_IMA_WAV || track -> par -> codec_id == AV_CODEC_ID_QDM2 ) { version = 1 ; } } avio_wb32 ( pb , 0 ) ; if ( mov -> encryption_scheme != MOV_ENC_NONE ) { ffio_wfourcc ( pb , ""enca"" ) ; } else { avio_wl32 ( pb , tag ) ; } avio_wb32 ( pb , 0 ) ; avio_wb16 ( pb , 0 ) ; avio_wb16 ( pb , 1 ) ; avio_wb16 ( pb , version ) ; avio_wb16 ( pb , 0 ) ; avio_wb32 ( pb , 0 ) ; if ( version == 2 ) { avio_wb16 ( pb , 3 ) ; avio_wb16 ( pb , 16 ) ; avio_wb16 ( pb , 0xfffe ) ; avio_wb16 ( pb , 0 ) ; avio_wb32 ( pb , 0x00010000 ) ; avio_wb32 ( pb , 72 ) ; avio_wb64 ( pb , av_double2int ( track -> par -> sample_rate ) ) ; avio_wb32 ( pb , track -> par -> channels ) ; avio_wb32 ( pb , 0x7F000000 ) ; avio_wb32 ( pb , av_get_bits_per_sample ( track -> par -> codec_id ) ) ; avio_wb32 ( pb , mov_get_lpcm_flags ( track -> par -> codec_id ) ) ; avio_wb32 ( pb , track -> sample_size ) ; avio_wb32 ( pb , get_samples_per_packet ( track ) ) ; } else { if ( track -> mode == MODE_MOV ) { avio_wb16 ( pb , track -> par -> channels ) ; if ( track -> par -> codec_id == AV_CODEC_ID_PCM_U8 || track -> par -> codec_id == AV_CODEC_ID_PCM_S8 ) avio_wb16 ( pb , 8 ) ; else if ( track -> par -> codec_id == AV_CODEC_ID_ADPCM_G726 ) avio_wb16 ( pb , track -> par -> bits_per_coded_sample ) ; else avio_wb16 ( pb , 16 ) ; avio_wb16 ( pb , track -> audio_vbr ? - 2 : 0 ) ; } else { if ( track -> par -> codec_id == AV_CODEC_ID_FLAC || track -> par -> codec_id == AV_CODEC_ID_OPUS ) { avio_wb16 ( pb , track -> par -> channels ) ; } else { avio_wb16 ( pb , 2 ) ; } if ( track -> par -> codec_id == AV_CODEC_ID_FLAC ) { avio_wb16 ( pb , track -> par -> bits_per_raw_sample ) ; } else { avio_wb16 ( pb , 16 ) ; } avio_wb16 ( pb , 0 ) ; } avio_wb16 ( pb , 0 ) ; if ( track -> par -> codec_id == AV_CODEC_ID_OPUS ) avio_wb16 ( pb , 48000 ) ; else avio_wb16 ( pb , track -> par -> sample_rate <= UINT16_MAX ? track -> par -> sample_rate : 0 ) ; avio_wb16 ( pb , 0 ) ; } if ( version == 1 ) { if ( mov_pcm_le_gt16 ( track -> par -> codec_id ) || mov_pcm_be_gt16 ( track -> par -> codec_id ) ) avio_wb32 ( pb , 1 ) ; else avio_wb32 ( pb , track -> par -> frame_size ) ; avio_wb32 ( pb , track -> sample_size / track -> par -> channels ) ; avio_wb32 ( pb , track -> sample_size ) ; avio_wb32 ( pb , 2 ) ; } if ( track -> mode == MODE_MOV && ( track -> par -> codec_id == AV_CODEC_ID_AAC || track -> par -> codec_id == AV_CODEC_ID_AC3 || track -> par -> codec_id == AV_CODEC_ID_EAC3 || track -> par -> codec_id == AV_CODEC_ID_AMR_NB || track -> par -> codec_id == AV_CODEC_ID_ALAC || track -> par -> codec_id == AV_CODEC_ID_ADPCM_MS || track -> par -> codec_id == AV_CODEC_ID_ADPCM_IMA_WAV || track -> par -> codec_id == AV_CODEC_ID_QDM2 || ( mov_pcm_le_gt16 ( track -> par -> codec_id ) && version == 1 ) || ( mov_pcm_be_gt16 ( track -> par -> codec_id ) && version == 1 ) ) ) mov_write_wave_tag ( s , pb , track ) ; else if ( track -> tag == MKTAG ( 'm' , 'p' , '4' , 'a' ) ) mov_write_esds_tag ( pb , track ) ; else if ( track -> par -> codec_id == AV_CODEC_ID_AMR_NB ) mov_write_amr_tag ( pb , track ) ; else if ( track -> par -> codec_id == AV_CODEC_ID_AC3 ) mov_write_ac3_tag ( pb , track ) ; else if ( track -> par -> codec_id == AV_CODEC_ID_EAC3 ) mov_write_eac3_tag ( pb , track ) ; else if ( track -> par -> codec_id == AV_CODEC_ID_ALAC ) mov_write_extradata_tag ( pb , track ) ; else if ( track -> par -> codec_id == AV_CODEC_ID_WMAPRO ) mov_write_wfex_tag ( s , pb , track ) ; else if ( track -> par -> codec_id == AV_CODEC_ID_FLAC ) mov_write_dfla_tag ( pb , track ) ; else if ( track -> par -> codec_id == AV_CODEC_ID_OPUS ) mov_write_dops_tag ( pb , track ) ; else if ( track -> vos_len > 0 ) mov_write_glbl_tag ( pb , track ) ; if ( track -> mode == MODE_MOV && track -> par -> codec_type == AVMEDIA_TYPE_AUDIO ) mov_write_chan_tag ( s , pb , track ) ; if ( mov -> encryption_scheme != MOV_ENC_NONE ) { ff_mov_cenc_write_sinf_tag ( track , pb , mov -> encryption_kid ) ; } return update_size ( pb , pos ) ; } "," timescale > UINT16_MAX || ! track -> par -> channels ",FFmpeg@FFmpeg/fa19fbcf712a6a6cc5a5cfdc3254a97b9bce6582,CVE-2018-14395,https://github.com/FFmpeg/FFmpeg/commit/fa19fbcf712a6a6cc5a5cfdc3254a97b9bce6582,2018-07-19T05:29Z 227,CWE-552,"CWE-552 static long _syscall ( long num , long arg1 , long arg2 , long arg3 , long arg4 , long arg5 , long arg6 ) { long ret = - 1 ; oe_errno = 0 ; switch ( num ) { # if defined ( OE_SYS_creat ) case OE_SYS_creat : { const char * pathname = ( const char * ) arg1 ; oe_mode_t mode = ( oe_mode_t ) arg2 ; int flags = ( OE_O_CREAT | OE_O_WRONLY | OE_O_TRUNC ) ; ret = oe_open ( pathname , flags , mode ) ; if ( oe_errno == OE_ENOENT ) { oe_errno = OE_ENOSYS ; goto done ; } goto done ; } # endif # if defined ( OE_SYS_open ) case OE_SYS_open : { const char * pathname = ( const char * ) arg1 ; int flags = ( int ) arg2 ; uint32_t mode = ( uint32_t ) arg3 ; ret = oe_open ( pathname , flags , mode ) ; if ( ret < 0 && oe_errno == OE_ENOENT ) goto done ; goto done ; } # endif case OE_SYS_openat : { int dirfd = ( int ) arg1 ; const char * pathname = ( const char * ) arg2 ; int flags = ( int ) arg3 ; uint32_t mode = ( uint32_t ) arg4 ; if ( dirfd != OE_AT_FDCWD ) { oe_errno = OE_EBADF ; goto done ; } ret = oe_open ( pathname , flags , mode ) ; if ( ret < 0 && oe_errno == OE_ENOENT ) goto done ; goto done ; } case OE_SYS_lseek : { int fd = ( int ) arg1 ; ssize_t off = ( ssize_t ) arg2 ; int whence = ( int ) arg3 ; ret = oe_lseek ( fd , off , whence ) ; goto done ; } case OE_SYS_pread64 : { const int fd = ( int ) arg1 ; void * const buf = ( void * ) arg2 ; const size_t count = ( size_t ) arg3 ; const oe_off_t offset = ( oe_off_t ) arg4 ; ret = oe_pread ( fd , buf , count , offset ) ; goto done ; } case OE_SYS_pwrite64 : { const int fd = ( int ) arg1 ; const void * const buf = ( void * ) arg2 ; const size_t count = ( size_t ) arg3 ; const oe_off_t offset = ( oe_off_t ) arg4 ; ret = oe_pwrite ( fd , buf , count , offset ) ; goto done ; } case OE_SYS_readv : { int fd = ( int ) arg1 ; const struct oe_iovec * iov = ( const struct oe_iovec * ) arg2 ; int iovcnt = ( int ) arg3 ; ret = oe_readv ( fd , iov , iovcnt ) ; goto done ; } case OE_SYS_writev : { int fd = ( int ) arg1 ; const struct oe_iovec * iov = ( const struct oe_iovec * ) arg2 ; int iovcnt = ( int ) arg3 ; ret = oe_writev ( fd , iov , iovcnt ) ; goto done ; } case OE_SYS_read : { int fd = ( int ) arg1 ; void * buf = ( void * ) arg2 ; size_t count = ( size_t ) arg3 ; ret = oe_read ( fd , buf , count ) ; goto done ; } case OE_SYS_write : { int fd = ( int ) arg1 ; const void * buf = ( void * ) arg2 ; size_t count = ( size_t ) arg3 ; ret = oe_write ( fd , buf , count ) ; goto done ; } case OE_SYS_close : { int fd = ( int ) arg1 ; ret = oe_close ( fd ) ; goto done ; } case OE_SYS_dup : { int fd = ( int ) arg1 ; ret = oe_dup ( fd ) ; goto done ; } case OE_SYS_flock : { int fd = ( int ) arg1 ; int operation = ( int ) arg2 ; ret = oe_flock ( fd , operation ) ; goto done ; } case OE_SYS_fsync : { const int fd = ( int ) arg1 ; ret = oe_fsync ( fd ) ; goto done ; } case OE_SYS_fdatasync : { const int fd = ( int ) arg1 ; ret = oe_fdatasync ( fd ) ; goto done ; } # if defined ( OE_SYS_dup2 ) case OE_SYS_dup2 : { int oldfd = ( int ) arg1 ; int newfd = ( int ) arg2 ; ret = oe_dup2 ( oldfd , newfd ) ; goto done ; } # endif case OE_SYS_dup3 : { int oldfd = ( int ) arg1 ; int newfd = ( int ) arg2 ; int flags = ( int ) arg3 ; if ( flags != 0 ) { oe_errno = OE_EINVAL ; goto done ; } ret = oe_dup2 ( oldfd , newfd ) ; goto done ; } # if defined ( OE_SYS_stat ) case OE_SYS_stat : { const char * pathname = ( const char * ) arg1 ; struct oe_stat_t * buf = ( struct oe_stat_t * ) arg2 ; ret = oe_stat ( pathname , buf ) ; goto done ; } # endif case OE_SYS_newfstatat : { int dirfd = ( int ) arg1 ; const char * pathname = ( const char * ) arg2 ; struct oe_stat_t * buf = ( struct oe_stat_t * ) arg3 ; int flags = ( int ) arg4 ; if ( dirfd != OE_AT_FDCWD ) { oe_errno = OE_EBADF ; goto done ; } if ( flags != 0 ) { oe_errno = OE_EINVAL ; goto done ; } ret = oe_stat ( pathname , buf ) ; goto done ; } case OE_SYS_fstat : { const int fd = ( int ) arg1 ; struct oe_stat_t * const buf = ( struct oe_stat_t * ) arg2 ; ret = oe_fstat ( fd , buf ) ; goto done ; } # if defined ( OE_SYS_link ) case OE_SYS_link : { const char * oldpath = ( const char * ) arg1 ; const char * newpath = ( const char * ) arg2 ; ret = oe_link ( oldpath , newpath ) ; goto done ; } # endif case OE_SYS_linkat : { int olddirfd = ( int ) arg1 ; const char * oldpath = ( const char * ) arg2 ; int newdirfd = ( int ) arg3 ; const char * newpath = ( const char * ) arg4 ; int flags = ( int ) arg5 ; if ( olddirfd != OE_AT_FDCWD ) { oe_errno = OE_EBADF ; goto done ; } if ( newdirfd != OE_AT_FDCWD ) { oe_errno = OE_EBADF ; goto done ; } if ( flags != 0 ) { oe_errno = OE_EINVAL ; goto done ; } ret = oe_link ( oldpath , newpath ) ; goto done ; } # if defined ( OE_SYS_unlink ) case OE_SYS_unlink : { const char * pathname = ( const char * ) arg1 ; ret = oe_unlink ( pathname ) ; goto done ; } # endif case OE_SYS_unlinkat : { int dirfd = ( int ) arg1 ; const char * pathname = ( const char * ) arg2 ; int flags = ( int ) arg3 ; if ( dirfd != OE_AT_FDCWD ) { oe_errno = OE_EBADF ; goto done ; } if ( flags != OE_AT_REMOVEDIR && flags != 0 ) { oe_errno = OE_EINVAL ; goto done ; } if ( flags == OE_AT_REMOVEDIR ) ret = oe_rmdir ( pathname ) ; else ret = oe_unlink ( pathname ) ; goto done ; } # if defined ( OE_SYS_rename ) case OE_SYS_rename : { const char * oldpath = ( const char * ) arg1 ; const char * newpath = ( const char * ) arg2 ; ret = oe_rename ( oldpath , newpath ) ; goto done ; } # endif case OE_SYS_renameat : { int olddirfd = ( int ) arg1 ; const char * oldpath = ( const char * ) arg2 ; int newdirfd = ( int ) arg3 ; const char * newpath = ( const char * ) arg4 ; int flags = ( int ) arg5 ; if ( olddirfd != OE_AT_FDCWD ) { oe_errno = OE_EBADF ; goto done ; } if ( newdirfd != OE_AT_FDCWD ) { oe_errno = OE_EBADF ; goto done ; } if ( flags != 0 ) { oe_errno = OE_EINVAL ; goto done ; } ret = oe_rename ( oldpath , newpath ) ; goto done ; } case OE_SYS_truncate : { const char * path = ( const char * ) arg1 ; ssize_t length = ( ssize_t ) arg2 ; ret = oe_truncate ( path , length ) ; goto done ; } # if defined ( OE_SYS_mkdir ) case OE_SYS_mkdir : { const char * pathname = ( const char * ) arg1 ; uint32_t mode = ( uint32_t ) arg2 ; ret = oe_mkdir ( pathname , mode ) ; goto done ; } # endif case OE_SYS_mkdirat : { int dirfd = ( int ) arg1 ; const char * pathname = ( const char * ) arg2 ; uint32_t mode = ( uint32_t ) arg3 ; if ( dirfd != OE_AT_FDCWD ) { oe_errno = OE_EBADF ; goto done ; } ret = oe_mkdir ( pathname , mode ) ; goto done ; } # if defined ( OE_SYS_rmdir ) case OE_SYS_rmdir : { const char * pathname = ( const char * ) arg1 ; ret = oe_rmdir ( pathname ) ; goto done ; } # endif # if defined ( OE_SYS_access ) case OE_SYS_access : { const char * pathname = ( const char * ) arg1 ; int mode = ( int ) arg2 ; ret = oe_access ( pathname , mode ) ; goto done ; } # endif case OE_SYS_faccessat : { int dirfd = ( int ) arg1 ; const char * pathname = ( const char * ) arg2 ; int mode = ( int ) arg3 ; int flags = ( int ) arg4 ; if ( dirfd != OE_AT_FDCWD ) { oe_errno = OE_EBADF ; goto done ; } if ( flags != 0 ) { oe_errno = OE_EINVAL ; goto done ; } ret = oe_access ( pathname , mode ) ; goto done ; } case OE_SYS_getdents64 : { unsigned int fd = ( unsigned int ) arg1 ; struct oe_dirent * ent = ( struct oe_dirent * ) arg2 ; unsigned int count = ( unsigned int ) arg3 ; ret = oe_getdents64 ( fd , ent , count ) ; goto done ; } case OE_SYS_ioctl : { int fd = ( int ) arg1 ; unsigned long request = ( unsigned long ) arg2 ; long p1 = arg3 ; long p2 = arg4 ; long p3 = arg5 ; long p4 = arg6 ; ret = oe_ioctl ( fd , request , p1 , p2 , p3 , p4 ) ; goto done ; } case OE_SYS_fcntl : { int fd = ( int ) arg1 ; int cmd = ( int ) arg2 ; uint64_t arg = ( uint64_t ) arg3 ; ret = oe_fcntl ( fd , cmd , arg ) ; goto done ; } case OE_SYS_mount : { const char * source = ( const char * ) arg1 ; const char * target = ( const char * ) arg2 ; const char * fstype = ( const char * ) arg3 ; unsigned long flags = ( unsigned long ) arg4 ; void * data = ( void * ) arg5 ; ret = oe_mount ( source , target , fstype , flags , data ) ; goto done ; } case OE_SYS_umount2 : { const char * target = ( const char * ) arg1 ; int flags = ( int ) arg2 ; ( void ) flags ; ret = oe_umount ( target ) ; goto done ; } case OE_SYS_getcwd : { char * buf = ( char * ) arg1 ; size_t size = ( size_t ) arg2 ; if ( ! oe_getcwd ( buf , size ) ) { ret = - 1 ; } else { ret = ( long ) size ; } goto done ; } case OE_SYS_chdir : { char * path = ( char * ) arg1 ; ret = oe_chdir ( path ) ; goto done ; } case OE_SYS_socket : { int domain = ( int ) arg1 ; int type = ( int ) arg2 ; int protocol = ( int ) arg3 ; ret = oe_socket ( domain , type , protocol ) ; goto done ; } case OE_SYS_connect : { int sd = ( int ) arg1 ; const struct oe_sockaddr * addr = ( const struct oe_sockaddr * ) arg2 ; oe_socklen_t addrlen = ( oe_socklen_t ) arg3 ; ret = oe_connect ( sd , addr , addrlen ) ; goto done ; } case OE_SYS_setsockopt : { int sockfd = ( int ) arg1 ; int level = ( int ) arg2 ; int optname = ( int ) arg3 ; void * optval = ( void * ) arg4 ; oe_socklen_t optlen = ( oe_socklen_t ) arg5 ; ret = oe_setsockopt ( sockfd , level , optname , optval , optlen ) ; goto done ; } case OE_SYS_getsockopt : { int sockfd = ( int ) arg1 ; int level = ( int ) arg2 ; int optname = ( int ) arg3 ; void * optval = ( void * ) arg4 ; oe_socklen_t * optlen = ( oe_socklen_t * ) arg5 ; ret = oe_getsockopt ( sockfd , level , optname , optval , optlen ) ; goto done ; } case OE_SYS_getpeername : { int sockfd = ( int ) arg1 ; struct sockaddr * addr = ( struct sockaddr * ) arg2 ; oe_socklen_t * addrlen = ( oe_socklen_t * ) arg3 ; ret = oe_getpeername ( sockfd , ( struct oe_sockaddr * ) addr , addrlen ) ; goto done ; } case OE_SYS_getsockname : { int sockfd = ( int ) arg1 ; struct sockaddr * addr = ( struct sockaddr * ) arg2 ; oe_socklen_t * addrlen = ( oe_socklen_t * ) arg3 ; ret = oe_getsockname ( sockfd , ( struct oe_sockaddr * ) addr , addrlen ) ; goto done ; } case OE_SYS_bind : { int sockfd = ( int ) arg1 ; struct oe_sockaddr * addr = ( struct oe_sockaddr * ) arg2 ; oe_socklen_t addrlen = ( oe_socklen_t ) arg3 ; ret = oe_bind ( sockfd , addr , addrlen ) ; goto done ; } case OE_SYS_listen : { int sockfd = ( int ) arg1 ; int backlog = ( int ) arg2 ; ret = oe_listen ( sockfd , backlog ) ; goto done ; } case OE_SYS_accept : { int sockfd = ( int ) arg1 ; struct oe_sockaddr * addr = ( struct oe_sockaddr * ) arg2 ; oe_socklen_t * addrlen = ( oe_socklen_t * ) arg3 ; ret = oe_accept ( sockfd , addr , addrlen ) ; goto done ; } case OE_SYS_sendto : { int sockfd = ( int ) arg1 ; const void * buf = ( void * ) arg2 ; size_t len = ( size_t ) arg3 ; int flags = ( int ) arg4 ; const struct oe_sockaddr * dest_add = ( const struct oe_sockaddr * ) arg5 ; oe_socklen_t addrlen = ( oe_socklen_t ) arg6 ; ret = oe_sendto ( sockfd , buf , len , flags , dest_add , addrlen ) ; goto done ; } case OE_SYS_recvfrom : { int sockfd = ( int ) arg1 ; void * buf = ( void * ) arg2 ; size_t len = ( size_t ) arg3 ; int flags = ( int ) arg4 ; const struct oe_sockaddr * dest_add = ( const struct oe_sockaddr * ) arg5 ; oe_socklen_t * addrlen = ( oe_socklen_t * ) arg6 ; ret = oe_recvfrom ( sockfd , buf , len , flags , dest_add , addrlen ) ; goto done ; } case OE_SYS_sendmsg : { int sockfd = ( int ) arg1 ; struct msghdr * buf = ( struct msghdr * ) arg2 ; int flags = ( int ) arg3 ; ret = oe_sendmsg ( sockfd , ( struct oe_msghdr * ) buf , flags ) ; goto done ; } case OE_SYS_recvmsg : { int sockfd = ( int ) arg1 ; struct msghdr * buf = ( struct msghdr * ) arg2 ; int flags = ( int ) arg3 ; ret = oe_recvmsg ( sockfd , ( struct oe_msghdr * ) buf , flags ) ; goto done ; } case OE_SYS_socketpair : { int domain = ( int ) arg1 ; int type = ( int ) arg2 ; int protocol = ( int ) arg3 ; int * sv = ( int * ) arg4 ; ret = oe_socketpair ( domain , type , protocol , sv ) ; goto done ; } case OE_SYS_shutdown : { int sockfd = ( int ) arg1 ; int how = ( int ) arg2 ; ret = oe_shutdown ( sockfd , how ) ; goto done ; } case OE_SYS_uname : { struct oe_utsname * buf = ( struct oe_utsname * ) arg1 ; ret = oe_uname ( buf ) ; goto done ; } # if defined ( OE_SYS_select ) case OE_SYS_select : { int nfds = ( int ) arg1 ; oe_fd_set * readfds = ( oe_fd_set * ) arg2 ; oe_fd_set * writefds = ( oe_fd_set * ) arg3 ; oe_fd_set * efds = ( oe_fd_set * ) arg4 ; struct oe_timeval * timeout = ( struct oe_timeval * ) arg5 ; ret = oe_select ( nfds , readfds , writefds , efds , timeout ) ; goto done ; } # endif case OE_SYS_pselect6 : { int nfds = ( int ) arg1 ; oe_fd_set * readfds = ( oe_fd_set * ) arg2 ; oe_fd_set * writefds = ( oe_fd_set * ) arg3 ; oe_fd_set * exceptfds = ( oe_fd_set * ) arg4 ; struct oe_timespec * ts = ( struct oe_timespec * ) arg5 ; struct oe_timeval buf ; struct oe_timeval * tv = NULL ; if ( ts ) { tv = & buf ; tv -> tv_sec = ts -> tv_sec ; tv -> tv_usec = ts -> tv_nsec / 1000 ; } ret = oe_select ( nfds , readfds , writefds , exceptfds , tv ) ; goto done ; } # if defined ( OE_SYS_poll ) case OE_SYS_poll : { struct oe_pollfd * fds = ( struct oe_pollfd * ) arg1 ; oe_nfds_t nfds = ( oe_nfds_t ) arg2 ; int millis = ( int ) arg3 ; ret = oe_poll ( fds , nfds , millis ) ; goto done ; } # endif case OE_SYS_ppoll : { struct oe_pollfd * fds = ( struct oe_pollfd * ) arg1 ; oe_nfds_t nfds = ( oe_nfds_t ) arg2 ; struct oe_timespec * ts = ( struct oe_timespec * ) arg3 ; void * sigmask = ( void * ) arg4 ; int timeout = - 1 ; if ( sigmask != NULL ) { oe_errno = OE_EINVAL ; goto done ; } if ( ts ) { int64_t mul ; int64_t div ; int64_t sum ; if ( oe_safe_mul_s64 ( ts -> tv_sec , 1000 , & mul ) != OE_OK ) { oe_errno = OE_EINVAL ; goto done ; } div = ts -> tv_nsec / 1000000 ; if ( oe_safe_add_s64 ( mul , div , & sum ) != OE_OK ) { oe_errno = OE_EINVAL ; goto done ; } if ( sum < OE_INT_MIN || sum > OE_INT_MAX ) { oe_errno = OE_EINVAL ; goto done ; } timeout = ( int ) sum ; } ret = oe_poll ( fds , nfds , timeout ) ; goto done ; } # if defined ( OE_SYS_epoll_create ) case OE_SYS_epoll_create : { int size = ( int ) arg1 ; ret = oe_epoll_create ( size ) ; goto done ; } # endif case OE_SYS_epoll_create1 : { int flags = ( int ) arg1 ; ret = oe_epoll_create1 ( flags ) ; goto done ; } # if defined ( OE_SYS_epoll_wait ) case OE_SYS_epoll_wait : { int epfd = ( int ) arg1 ; struct oe_epoll_event * events = ( struct oe_epoll_event * ) arg2 ; int maxevents = ( int ) arg3 ; int timeout = ( int ) arg4 ; ret = oe_epoll_wait ( epfd , events , maxevents , timeout ) ; goto done ; } # endif case OE_SYS_epoll_pwait : { int epfd = ( int ) arg1 ; struct oe_epoll_event * events = ( struct oe_epoll_event * ) arg2 ; int maxevents = ( int ) arg3 ; int timeout = ( int ) arg4 ; const oe_sigset_t * sigmask = ( const oe_sigset_t * ) arg5 ; ret = oe_epoll_pwait ( epfd , events , maxevents , timeout , sigmask ) ; goto done ; } case OE_SYS_epoll_ctl : { int epfd = ( int ) arg1 ; int op = ( int ) arg2 ; int fd = ( int ) arg3 ; struct oe_epoll_event * event = ( struct oe_epoll_event * ) arg4 ; ret = oe_epoll_ctl ( epfd , op , fd , event ) ; goto done ; } case OE_SYS_exit_group : { ret = 0 ; goto done ; } case OE_SYS_exit : { int status = ( int ) arg1 ; oe_exit ( status ) ; goto done ; } case OE_SYS_getpid : { ret = ( long ) oe_getpid ( ) ; goto done ; } case OE_SYS_getuid : { ret = ( long ) oe_getuid ( ) ; goto done ; } case OE_SYS_geteuid : { ret = ( long ) oe_geteuid ( ) ; goto done ; } case OE_SYS_getgid : { ret = ( long ) oe_getgid ( ) ; goto done ; } case OE_SYS_getpgid : { int pid = ( int ) arg1 ; ret = ( long ) oe_getpgid ( pid ) ; goto done ; } case OE_SYS_getgroups : { int size = ( int ) arg1 ; oe_gid_t * list = ( oe_gid_t * ) arg2 ; ret = ( long ) oe_getgroups ( size , list ) ; goto done ; } case OE_SYS_getegid : { ret = ( long ) oe_getegid ( ) ; goto done ; } case OE_SYS_getppid : { ret = ( long ) oe_getppid ( ) ; goto done ; } # if defined ( OE_SYS_getpgrp ) case OE_SYS_getpgrp : { ret = ( long ) oe_getpgrp ( ) ; goto done ; } # endif case OE_SYS_nanosleep : { struct oe_timespec * req = ( struct oe_timespec * ) arg1 ; struct oe_timespec * rem = ( struct oe_timespec * ) arg2 ; ret = ( long ) oe_nanosleep ( req , rem ) ; goto done ; } default : { oe_errno = OE_ENOSYS ; OE_TRACE_WARNING ( ""syscallnum=%ldnothandled"" , num ) ; goto done ; } } done : return ret ; } "," ) arg4 ; struct oe_sockaddr * * dest_add = ( struct oe_sockaddr * ",openenclave@openenclave/bcac8e7acb514429fee9e0b5d0c7a0308fd4d76b,CVE-2020-15224,https://github.com/openenclave/openenclave/commit/bcac8e7acb514429fee9e0b5d0c7a0308fd4d76b,2020-10-14T19:15Z 228,CWE-772,"CWE-772 generic_ret * delete_policy_2_svc ( dpol_arg * arg , struct svc_req * rqstp ) { static generic_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_generic_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 ; } prime_arg = arg -> name ; if ( CHANGEPW_SERVICE ( rqstp ) || ! kadm5int_acl_check ( handle -> context , rqst2name ( rqstp ) , ACL_DELETE , NULL , NULL ) ) { log_unauth ( ""kadm5_delete_policy"" , prime_arg , & client_name , & service_name , rqstp ) ; ret . code = KADM5_AUTH_DELETE ; } else { ret . code = kadm5_delete_policy ( ( void * ) handle , arg -> name ) ; if ( ret . code != 0 ) errmsg = krb5_get_error_message ( handle -> context , ret . code ) ; log_done ( ""kadm5_delete_policy"" , ( ( prime_arg == NULL ) ? ""(null)"" : prime_arg ) , 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 ) ; } exit_func : gss_release_buffer ( & minor_stat , & client_name ) ; gss_release_buffer ( & minor_stat , & service_name ) ; free_server_handle ( handle ",krb5@krb5/83ed75feba32e46f736fcce0d96a0445f29b96c2,CVE-2015-8631,https://github.com/krb5/krb5/commit/83ed75feba32e46f736fcce0d96a0445f29b96c2,2016-02-13T02:59Z 229,CWE-20,"CWE-20 static void ikev2_parent_outI1_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 ( ""ikev2parentoutI1:calculatedke+nonce,sendingI1"" ) ) ; 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_outI1_tail ( pcrc , r ) ; if ( ke -> md != NULL ) { complete_v2_state_transition ( & ke -> md , e ) ; if ( ke -> md ) release_md ( ke -> md ) ; } reset_cur_state ( ) ; reset_globals ( ) ; passert ( GLOBALS_ARE_RESET ( ) ) ; } "," ( ) ; } ",libreswan@libreswan/2899351224fe2940aec37d7656e1e392c0fe07f0,CVE-2013-7294,https://github.com/libreswan/libreswan/commit/2899351224fe2940aec37d7656e1e392c0fe07f0,2014-01-16T05:05Z 230,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 231,CWE-20,"CWE-20 int mk_request_error ( int http_status , struct client_session * cs , struct session_request * sr ) { int ret , fd ; mk_ptr_t message , * page = 0 ; struct error_page * entry ; struct mk_list * head ; struct file_info finfo ; mk_header_set_http_status ( sr , http_status ) ; if ( http_status != MK_CLIENT_LENGTH_REQUIRED && http_status != MK_CLIENT_BAD_REQUEST && http_status != MK_CLIENT_REQUEST_ENTITY_TOO_LARGE ) { mk_list_foreach ( head , & sr -> host_conf -> error_pages ) { entry = mk_list_entry ( head , struct error_page , _head ) ; if ( entry -> status != http_status ) { continue ; } ret = mk_file_get_info ( entry -> real_path , & finfo ) ; if ( ret == - 1 ) { break ; } fd = open ( entry -> real_path , config -> open_flags ) ; if ( fd == - 1 ) { break ; } sr -> fd_file = fd ; sr -> bytes_to_send = finfo . size ; sr -> headers . content_length = finfo . size ; sr -> headers . real_length = finfo . size ; memcpy ( & sr -> file_info , & finfo , sizeof ( struct file_info ) ) ; mk_header_send ( cs -> socket , cs , sr ) ; return mk_http_send_file ( cs , sr ) ; } } mk_ptr_reset ( & message ) ; switch ( http_status ) { case MK_CLIENT_BAD_REQUEST : page = mk_request_set_default_page ( ""BadRequest"" , sr -> uri , sr -> host_conf -> host_signature ) ; break ; case MK_CLIENT_FORBIDDEN : page = mk_request_set_default_page ( ""Forbidden"" , sr -> uri , sr -> host_conf -> host_signature ) ; break ; case MK_CLIENT_NOT_FOUND : mk_string_build ( & message . data , & message . len , ""TherequestedURLwasnotfoundonthisserver."" ) ; page = mk_request_set_default_page ( ""NotFound"" , message , sr -> host_conf -> host_signature ) ; mk_ptr_free ( & message ) ; break ; case MK_CLIENT_REQUEST_ENTITY_TOO_LARGE : mk_string_build ( & message . data , & message . len , ""Therequestentityistoolarge."" ) ; page = mk_request_set_default_page ( ""Entitytoolarge"" , message , sr -> host_conf -> host_signature ) ; mk_ptr_free ( & message ) ; break ; case MK_CLIENT_METHOD_NOT_ALLOWED : page = mk_request_set_default_page ( ""MethodNotAllowed"" , sr -> uri , sr -> host_conf -> host_signature ) ; break ; case MK_CLIENT_REQUEST_TIMEOUT : case MK_CLIENT_LENGTH_REQUIRED : break ; case MK_SERVER_NOT_IMPLEMENTED : page = mk_request_set_default_page ( ""MethodNotImplemented"" , sr -> uri , sr -> host_conf -> host_signature ) ; break ; case MK_SERVER_INTERNAL_ERROR : page = mk_request_set_default_page ( ""InternalServerError"" , sr -> uri , sr -> host_conf -> host_signature ) ; break ; case MK_SERVER_HTTP_VERSION_UNSUP : mk_ptr_reset ( & message ) ; page = mk_request_set_default_page ( ""HTTPVersionNotSupported"" , message , sr -> host_conf -> host_signature ) ; break ; } if ( page ) { sr -> headers . content_length = page -> len ; } sr -> headers . location = NULL ; sr -> headers . cgi = SH_NOCGI ; sr -> headers . pconnections_left = 0 ; sr -> headers . last_modified = - 1 ; if ( ! page ) { mk_ptr_reset ( & sr -> headers . content_type ) ; } else { mk_ptr_set ( & sr -> headers . content_type , ""text/html\\r\\n"" ) ; } mk_header_send ( cs -> socket , cs , sr ) ; if ( page ) { if ( sr -> method != MK_HTTP_METHOD_HEAD ) mk_socket_send ( cs -> socket , page -> data , page -> len ) ; mk_ptr_free ( page ) ; mk_mem_free ( page ) ; } mk_server_cork_flag ( cs -> socket , TCP_CORK_OFF ) ; return EXIT_ERROR ; } "," ; sr -> fd_is_fdt = MK_FALSE ; sr -> ",monkey@monkey/b2d0e6f92310bb14a15aa2f8e96e1fb5379776dd,CVE-2014-5336,https://github.com/monkey/monkey/commit/b2d0e6f92310bb14a15aa2f8e96e1fb5379776dd,2014-08-26T14:55Z 232,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_len = ( sizeof ( struct sadb_msg ) / sizeof ( uint64_t ) ) ; pfkey_broadcast ( skb_out , GFP_ATOMIC , BROADCAST_ALL , NULL , c -> net ) ; return 0 ; } "," ; hdr -> sadb_msg_satype = SADB_SATYPE_UNSPEC ; hdr -> ",torvalds@linux/85dfb745ee40232876663ae206cba35f24ab2a40,CVE-2013-2237,https://github.com/torvalds/linux/commit/85dfb745ee40232876663ae206cba35f24ab2a40,2013-07-04T21:55Z 233,CWE-119,"CWE-119 void uwbd_stop ( struct uwb_rc * rc ) { kthread_stop ( rc -> uwbd . task ) ; uwbd_flush ( rc ) ; } "," rc ) { if ( rc -> uwbd . task ) ",torvalds@linux/bbf26183b7a6236ba602f4d6a2f7cade35bba043,CVE-2017-16526,https://github.com/torvalds/linux/commit/bbf26183b7a6236ba602f4d6a2f7cade35bba043,2017-11-04T01:29Z 234,CWE-189,"CWE-189 static int sgi_clock_set ( clockid_t clockid , struct timespec * tp ) { u64 nsec ; u64 rem ; nsec = rtc_time ( ) * sgi_clock_period ; sgi_clock_offset . tv_sec = tp -> tv_sec - div_long_long_rem ( nsec , NSEC_PER_SEC , & rem ) ; if ( rem <= tp -> tv_nsec ) sgi_clock_offset . tv_nsec = tp -> tv_sec - rem ; else { sgi_clock_offset . tv_nsec = tp -> tv_sec + NSEC_PER_SEC - rem ; sgi_clock_offset . tv_sec -- ; } return 0 ; } "," u64 nsec ; u32 rem ; nsec -> tv_sec - div_u64_rem ( nsec , ",torvalds@linux/f8bd2258e2d520dff28c855658bd24bdafb5102d,CVE-2011-3209,https://github.com/torvalds/linux/commit/f8bd2258e2d520dff28c855658bd24bdafb5102d,2012-10-03T11:02Z 235,CWE-119,"CWE-119 static int check_best_zero_mv ( const VP9_COMP * cpi , const uint8_t mode_context [ MAX_REF_FRAMES ] , int_mv frame_mv [ MB_MODE_COUNT ] [ MAX_REF_FRAMES ] , int disable_inter_mode_mask , int this_mode , int ref_frame , int second_ref_frame ) { if ( ! ( disable_inter_mode_mask & ( 1 << INTER_OFFSET ( ZEROMV ) ) ) && ( this_mode == NEARMV || this_mode == NEARESTMV || this_mode == ZEROMV ) && frame_mv [ this_mode ] [ ref_frame ] . as_int == 0 && ( second_ref_frame == NONE || frame_mv [ this_mode ] [ second_ref_frame ] . as_int == 0 ) ) { int rfc = mode_context [ ref_frame ] ; int c1 = cost_mv_ref ( cpi , NEARMV , rfc ) ; int c2 = cost_mv_ref ( cpi , NEARESTMV , rfc ) ; int c3 = cost_mv_ref ( cpi , ZEROMV , rfc ) ; if ( this_mode == NEARMV ) { if ( c1 > c3 ) return 0 ; } else if ( this_mode == NEARESTMV ) { if ( c2 > c3 ) return 0 ; } else { assert ( this_mode == ZEROMV ) ; if ( second_ref_frame == NONE ) { if ( ( c3 >= c2 && frame_mv [ NEARESTMV ] [ ref_frame ] . as_int == 0 ) || ( c3 >= c1 && frame_mv [ NEARMV ] [ ref_frame ] . as_int == 0 ) ) return 0 ; } else { if ( ( c3 >= c2 && frame_mv [ NEARESTMV ] [ ref_frame ] . as_int == 0 && frame_mv [ NEARESTMV ] [ second_ref_frame ] . as_int == 0 ) || ( c3 >= c1 && frame_mv [ NEARMV ] [ ref_frame ] . as_int == 0 && frame_mv [ NEARMV ] [ second_ref_frame ] . as_int == 0 ) ) return 0 ; } } } return 1 ; } "," MAX_REF_FRAMES ] , int this_mode , const MV_REFERENCE_FRAME ref_frames [ 2 ] ) { if ( ( this_mode == NEARMV || this_mode == NEARESTMV || this_mode == ZEROMV ) && frame_mv [ this_mode ] [ ref_frames [ 0 ] ] . as_int == 0 && ( ref_frames [ 1 ] == NONE || this_mode ] [ ref_frames [ 1 ] ] . as_int = mode_context [ ref_frames [ 0 ] ] ; int ; if ( ref_frames [ 1 ] == NONE ) NEARESTMV ] [ ref_frames [ 0 ] ] . as_int NEARMV ] [ ref_frames [ 0 ] ] . as_int NEARESTMV ] [ ref_frames [ 0 ] ] . as_int == 0 && frame_mv [ NEARESTMV ] [ ref_frames [ 1 ] ] . as_int NEARMV ] [ ref_frames [ 0 ] ] . as_int == 0 && frame_mv [ NEARMV ] [ ref_frames [ 1 ] ] . as_int ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 236,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 237,CWE-200,"CWE-200 dictionary * iniparser_load ( const char * ininame ) { FILE * in ; char line [ ASCIILINESZ + 1 ] ; char section [ ASCIILINESZ + 1 ] ; char key [ ASCIILINESZ + 1 ] ; char tmp [ ( ASCIILINESZ * 2 ) + 1 ] ; char val [ ASCIILINESZ + 1 ] ; int last = 0 ; int len ; int lineno = 0 ; int errs = 0 ; dictionary * dict ; if ( ( in = fopen ( ininame , ""r"" ) ) == NULL ) { fprintf ( stderr , ""iniparser:cannotopen%s\\n"" , ininame ) ; return NULL ; } dict = dictionary_new ( 0 ) ; if ( ! dict ) { fclose ( in ) ; return NULL ; } memset ( line , 0 , ASCIILINESZ ) ; memset ( section , 0 , ASCIILINESZ ) ; memset ( key , 0 , ASCIILINESZ ) ; memset ( val , 0 , ASCIILINESZ ) ; last = 0 ; while ( fgets ( line + last , ASCIILINESZ - last , in ) != NULL ) { lineno ++ ; len = ( int ) strlen ( line ) - 1 ; if ( len == 0 ) continue ; if ( line [ len ] != '\\n' && ! feof ( in ) ) { fprintf ( stderr , ""iniparser:inputlinetoolongin%s(%d)\\n"" , ininame , lineno ) ; dictionary_del ( dict ) ; fclose ( in ) ; return NULL ; } while ( ( len >= 0 ) && ( ( line [ len ] == '\\n' ) || ( isspace ( line [ len ] ) ) ) ) { line [ len ] = 0 ; len -- ; } if ( len < 0 ) { len = 0 ; } if ( line [ len ] == '\\\\' ) { last = len ; continue ; } else { last = 0 ; } switch ( iniparser_line ( line , section , key , val ) ) { case LINE_EMPTY : case LINE_COMMENT : break ; case LINE_SECTION : errs = dictionary_set ( dict , section , NULL ) ; break ; case LINE_VALUE : sprintf ( tmp , ""%s:%s"" , section , key ) ; errs = dictionary_set ( dict , tmp , val ) ; break ; case LINE_ERROR : fprintf ( stderr , ""iniparser:syntaxerrorin%s(%d):\\n"" , ininame , lineno ) ; fprintf ( stderr , ""->%s\\n"" , line ) ; errs ++ ; break ; default : break ; } memset ( line , 0 , ASCIILINESZ ) ; last = 0 ; if ( errs < 0 ) { fprintf ( stderr , ""iniparser:memoryallocationfailure\\n"" ) ; break ; } } if ( errs ) { dictionary_del ( dict ) ; dict = NULL ; } fclose ( in ) ; return dict ; } "," char * ininame , load_options options case LINE_ERROR : if ( options & HIDE_ERRORED_LINE_CONTENT ) { ( stderr , ""iniparser:syntaxerrorin%s(%d)\\n"" , ininame , lineno ) ; } else { fprintf ( stderr , line ) ; } ",GNS3@ubridge/2eb0d1dab6a6de76cf3556130a2d52af101077db,CVE-2020-14976,https://github.com/GNS3/ubridge/commit/2eb0d1dab6a6de76cf3556130a2d52af101077db,2020-06-23T20:15Z 238,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 239,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 240,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-2315,https://github.com/git/git/commit/de1e67d0703894cb6ea782e36abb63976ab07e60,2016-04-08T14:59Z 241,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_TCHECK_16BITS ( & bp [ i + 2 ] ) ; 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_TCHECK_16BITS ( & bp [ i + 2 ] ) ; ND_TCHECK_16BITS ( & bp [ i + 4 ] ) ; 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_128BITS ( & bp [ i + 2 ] ) ; ",the-tcpdump-group@tcpdump/5338aac7b8b880b0c5e0c15e27dadc44c5559284,CVE-2017-13025,https://github.com/the-tcpdump-group/tcpdump/commit/5338aac7b8b880b0c5e0c15e27dadc44c5559284,2017-09-14T06:29Z 242,CWE-200,"CWE-200 static int copy_to_user_tmpl ( struct xfrm_policy * xp , struct sk_buff * skb ) { struct xfrm_user_tmpl vec [ XFRM_MAX_DEPTH ] ; int i ; if ( xp -> xfrm_nr == 0 ) return 0 ; for ( i = 0 ; i < xp -> xfrm_nr ; i ++ ) { struct xfrm_user_tmpl * up = & vec [ i ] ; struct xfrm_tmpl * kp = & xp -> xfrm_vec [ i ] ; memcpy ( & up -> id , & kp -> id , sizeof ( up -> id ) ) ; up -> family = kp -> encap_family ; memcpy ( & up -> saddr , & kp -> saddr , sizeof ( up -> saddr ) ) ; up -> reqid = kp -> reqid ; up -> mode = kp -> mode ; up -> share = kp -> share ; up -> optional = kp -> optional ; up -> aalgos = kp -> aalgos ; up -> ealgos = kp -> ealgos ; up -> calgos = kp -> calgos ; } return nla_put ( skb , XFRMA_TMPL , sizeof ( struct xfrm_user_tmpl ) * xp -> xfrm_nr , vec ) ; } "," i ] ; memset ( up , 0 , sizeof ( * up ) ) ; ",torvalds@linux/1f86840f897717f86d523a13e99a447e6a5d2fa5,CVE-2012-6537,https://github.com/torvalds/linux/commit/1f86840f897717f86d523a13e99a447e6a5d2fa5,2013-03-15T20:55Z 243,CWE-522,"CWE-522 static void credential_write_item ( FILE * fp , const char * key , const char * value ) { if ( ! value ) return ; fprintf ( fp , ""%s=%s\\n"" , key , value ) ; } "," ) return ; if ( strchr ( value , '\\n' ) ) die ( ""credentialvaluefor%scontainsnewline"" , key ) ; ",git@git/9a6bbee8006c24b46a85d29e7b38cfa79e9ab21b,CVE-2020-5260,https://github.com/git/git/commit/9a6bbee8006c24b46a85d29e7b38cfa79e9ab21b,2020-04-14T23:15Z 244,CWE-77,"CWE-77 static int parse_token ( char * * name , char * * value , char * * cp ) { char * end ; if ( ! name || ! value || ! cp ) return - BLKID_ERR_PARAM ; if ( ! ( * value = strchr ( * cp , '=' ) ) ) return 0 ; * * value = '\\0' ; * name = strip_line ( * cp ) ; * value = skip_over_blank ( * value + 1 ) ; if ( * * value == \'""\' ) { end = strchr ( * value + 1 , \'""\' ) ; if ( ! end ) { DBG ( READ , ul_debug ( ""unbalancedquotesat:%s"" , * value ) ) ; * cp = * value ; return - BLKID_ERR_CACHE ; } ( * value ) ++ ; * end = '\\0' ; end ++ ; } else { end = skip_over_word ( * value ) ; if ( * end ) { * end = '\\0' ; end ++ ; } } * cp = end ; return 1 ; } "," \'""\' ) { char * p = end = * value + value + 1 ; while ( * p ) { if ( * p == '\\\\' ) { p ++ ; * end = * p ; } else { * end = * p ; if ( * p == \'""\' ) break ; } p ++ ; end ++ ; } if ( * end != \'""\' ) { DBG '\\0' ; end = ++ p ; } else ",karelzak@util-linux/89e90ae7b2826110ea28c1c0eb8e7c56c3907bdc,CVE-2014-9114,https://github.com/karelzak/util-linux/commit/89e90ae7b2826110ea28c1c0eb8e7c56c3907bdc,2017-03-31T16:59Z 245,CWE-119,"CWE-119 static const char * parse_string ( cJSON * item , const char * str ) { const char * ptr = str + 1 ; char * ptr2 ; char * out ; int len = 0 ; unsigned uc , uc2 ; if ( * str != \'\\""\' ) { ep = str ; return 0 ; } while ( * ptr != \'\\""\' && * ptr && ++ len ) if ( * ptr ++ == '\\\\' ) ptr ++ ; if ( ! ( out = ( char * ) cJSON_malloc ( len + 1 ) ) ) return 0 ; ptr = str + 1 ; ptr2 = out ; while ( * ptr != \'\\""\' && * ptr ) { if ( * ptr != '\\\\' ) * ptr2 ++ = * ptr ++ ; else { ptr ++ ; switch ( * ptr ) { case 'b' : * ptr2 ++ = '\\b' ; break ; case 'f' : * ptr2 ++ = '\\f' ; break ; case 'n' : * ptr2 ++ = '\\n' ; break ; case 'r' : * ptr2 ++ = '\\r' ; break ; case 't' : * ptr2 ++ = '\\t' ; break ; case 'u' : sscanf ( ptr + 1 , ""%4x"" , & uc ) ; ptr += 4 ; if ( ( uc >= 0xDC00 && uc <= 0xDFFF ) || uc == 0 ) break ; if ( uc >= 0xD800 && uc <= 0xDBFF ) { if ( ptr [ 1 ] != '\\\\' || ptr [ 2 ] != 'u' ) break ; sscanf ( ptr + 3 , ""%4x"" , & uc2 ) ; ptr += 6 ; if ( uc2 < 0xDC00 || uc2 > 0xDFFF ) break ; uc = 0x10000 | ( ( uc & 0x3FF ) << 10 ) | ( uc2 & 0x3FF ) ; } len = 4 ; if ( uc < 0x80 ) len = 1 ; else if ( uc < 0x800 ) len = 2 ; else if ( uc < 0x10000 ) len = 3 ; ptr2 += len ; switch ( len ) { case 4 : * -- ptr2 = ( ( uc | 0x80 ) & 0xBF ) ; uc >>= 6 ; case 3 : * -- ptr2 = ( ( uc | 0x80 ) & 0xBF ) ; uc >>= 6 ; case 2 : * -- ptr2 = ( ( uc | 0x80 ) & 0xBF ) ; uc >>= 6 ; case 1 : * -- ptr2 = ( uc | firstByteMark [ len ] ) ; } ptr2 += len ; break ; default : * ptr2 ++ = * ptr ; break ; } ++ ptr ; } } * ptr2 = 0 ; if ( * ptr == \'\\""\' ) ++ ptr ; item -> valuestring = out ; item -> type = cJSON_String ; return ptr ; } "," char * str , const char * const char * * ep ) { const char * ptr = str + 1 , * end_ptr = str + 1 ; char * ptr2 ; char * out ; int \'\\""\' ) { * = str ; return 0 ; } while ( while ( * end_ptr != \'\\""\' && \'\\""\' && * end_ptr && ++ len ++ len ) if ( * end_ptr ++ == '\\\\' == '\\\\' ) end_ptr ++ ; out = ( char * ) cJSON_malloc ( len + 1 ) ; if ( if ( ! out ) return 0 ; item -> valuestring = out ; = out ; item -> type = cJSON_String ; ptr = str + 1 ; ptr2 = out ; while ( ptr < end_ptr ) { if ( case 'u' : uc = parse_hex4 ( ptr + 1 ) ; ptr += 4 += 4 ; if ( ptr >= end_ptr ) { * ep = str ; return 0 ; } == 0 ) { * ep = str ; return 0 ; } if ( uc <= 0xDBFF ) { if ( ptr + 6 > end_ptr ) { * ep = str ; return 0 ; } if ( ptr != 'u' ) { * ep = str ; return 0 ; } uc2 = parse_hex4 ( ptr + ptr + 3 ) ; ptr += 6 > 0xDFFF ) { * ep = str ; return 0 ; } uc = 0x10000 uc = 0x10000 + ( ( ( uc & 0x3FF ) ) < 0x80 ) len = 1 ; else if ( break ; } ptr ++ ; } } == \'\\""\' ) ptr ++ ; return ptr ",esnet@iperf/91f2fa59e8ed80dfbf400add0164ee0e508e412a,CVE-2016-4303,https://github.com/esnet/iperf/commit/91f2fa59e8ed80dfbf400add0164ee0e508e412a,2016-09-26T14:59Z 246,CWE-119,"CWE-119 int vp8_diamond_search_sadx4 ( MACROBLOCK * x , BLOCK * b , BLOCKD * d , int_mv * ref_mv , int_mv * best_mv , int search_param , int sad_per_bit , int * num00 , vp8_variance_fn_ptr_t * fn_ptr , int * mvcost [ 2 ] , int_mv * center_mv ) { int i , j , step ; 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 ; unsigned char * best_address ; int tot_steps ; int_mv this_mv ; unsigned int bestsad ; unsigned int thissad ; int best_site = 0 ; int last_site = 0 ; int ref_row ; int ref_col ; int this_row_offset ; int this_col_offset ; search_site * ss ; unsigned char * check_here ; 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 ; vp8_clamp_mv ( ref_mv , x -> mv_col_min , x -> mv_col_max , x -> mv_row_min , x -> mv_row_max ) ; ref_row = ref_mv -> as_mv . row ; ref_col = ref_mv -> as_mv . col ; * num00 = 0 ; best_mv -> as_mv . row = ref_row ; best_mv -> as_mv . col = ref_col ; in_what = ( unsigned char * ) ( base_pre + d -> offset + ( ref_row * pre_stride ) + ref_col ) ; best_address = in_what ; bestsad = fn_ptr -> sdf ( what , what_stride , in_what , in_what_stride , UINT_MAX ) + mvsad_err_cost ( best_mv , & fcenter_mv , mvsadcost , sad_per_bit ) ; ss = & x -> ss [ search_param * x -> searches_per_step ] ; tot_steps = ( x -> ss_count / x -> searches_per_step ) - search_param ; i = 1 ; for ( step = 0 ; step < tot_steps ; step ++ ) { int all_in = 1 , t ; all_in &= ( ( best_mv -> as_mv . row + ss [ i ] . mv . row ) > x -> mv_row_min ) ; all_in &= ( ( best_mv -> as_mv . row + ss [ i + 1 ] . mv . row ) < x -> mv_row_max ) ; all_in &= ( ( best_mv -> as_mv . col + ss [ i + 2 ] . mv . col ) > x -> mv_col_min ) ; all_in &= ( ( best_mv -> as_mv . col + ss [ i + 3 ] . mv . col ) < x -> mv_col_max ) ; if ( all_in ) { unsigned int sad_array [ 4 ] ; for ( j = 0 ; j < x -> searches_per_step ; j += 4 ) { const unsigned char * block_offset [ 4 ] ; for ( t = 0 ; t < 4 ; t ++ ) block_offset [ t ] = ss [ i + t ] . offset + best_address ; fn_ptr -> sdx4df ( what , what_stride , block_offset , in_what_stride , sad_array ) ; for ( t = 0 ; t < 4 ; t ++ , i ++ ) { if ( sad_array [ t ] < bestsad ) { this_mv . as_mv . row = best_mv -> as_mv . row + ss [ i ] . mv . row ; this_mv . as_mv . col = best_mv -> as_mv . col + ss [ i ] . mv . col ; sad_array [ t ] += mvsad_err_cost ( & this_mv , & fcenter_mv , mvsadcost , sad_per_bit ) ; if ( sad_array [ t ] < bestsad ) { bestsad = sad_array [ t ] ; best_site = i ; } } } } } else { for ( j = 0 ; j < x -> searches_per_step ; j ++ ) { this_row_offset = best_mv -> as_mv . row + ss [ i ] . mv . row ; this_col_offset = best_mv -> as_mv . col + ss [ i ] . mv . col ; if ( ( this_col_offset > x -> mv_col_min ) && ( this_col_offset < x -> mv_col_max ) && ( this_row_offset > x -> mv_row_min ) && ( this_row_offset < x -> mv_row_max ) ) { check_here = ss [ i ] . offset + best_address ; thissad = fn_ptr -> sdf ( what , what_stride , check_here , in_what_stride , bestsad ) ; if ( thissad < bestsad ) { this_mv . as_mv . row = this_row_offset ; this_mv . as_mv . col = this_col_offset ; thissad += mvsad_err_cost ( & this_mv , & fcenter_mv , mvsadcost , sad_per_bit ) ; if ( thissad < bestsad ) { bestsad = thissad ; best_site = i ; } } } i ++ ; } } if ( best_site != last_site ) { best_mv -> as_mv . row += ss [ best_site ] . mv . row ; best_mv -> as_mv . col += ss [ best_site ] . mv . col ; best_address += ss [ best_site ] . offset ; last_site = best_site ; } else if ( best_address == in_what ) ( * num00 ) ++ ; } this_mv . as_mv . row = best_mv -> as_mv . row * 8 ; this_mv . as_mv . col = best_mv -> as_mv . col * 8 ; return fn_ptr -> vf ( what , what_stride , best_address , in_what_stride , & thissad ) + mv_err_cost ( & this_mv , center_mv , mvcost , x -> errorperbit ) ; } "," in_what , 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 247,CWE-189,"CWE-189 static int adjust_ptr_min_max_vals ( struct bpf_verifier_env * env , struct bpf_insn * insn , const struct bpf_reg_state * ptr_reg , const struct bpf_reg_state * off_reg ) { struct bpf_verifier_state * vstate = env -> cur_state ; struct bpf_func_state * state = vstate -> frame [ vstate -> curframe ] ; struct bpf_reg_state * regs = state -> regs , * dst_reg ; bool known = tnum_is_const ( off_reg -> var_off ) ; s64 smin_val = off_reg -> smin_value , smax_val = off_reg -> smax_value , smin_ptr = ptr_reg -> smin_value , smax_ptr = ptr_reg -> smax_value ; u64 umin_val = off_reg -> umin_value , umax_val = off_reg -> umax_value , umin_ptr = ptr_reg -> umin_value , umax_ptr = ptr_reg -> umax_value ; u32 dst = insn -> dst_reg , src = insn -> src_reg ; u8 opcode = BPF_OP ( insn -> code ) ; dst_reg = & regs [ dst ] ; if ( ( known && ( smin_val != smax_val || umin_val != umax_val ) ) || smin_val > smax_val || umin_val > umax_val ) { __mark_reg_unknown ( dst_reg ) ; return 0 ; } if ( BPF_CLASS ( insn -> code ) != BPF_ALU64 ) { verbose ( env , ""R%d32-bitpointerarithmeticprohibited\\n"" , dst ) ; return - EACCES ; } switch ( ptr_reg -> type ) { case PTR_TO_MAP_VALUE_OR_NULL : verbose ( env , ""R%dpointerarithmeticon%sprohibited,null-checkitfirst\\n"" , dst , reg_type_str [ ptr_reg -> type ] ) ; return - EACCES ; case CONST_PTR_TO_MAP : case PTR_TO_PACKET_END : case PTR_TO_SOCKET : case PTR_TO_SOCKET_OR_NULL : verbose ( env , ""R%dpointerarithmeticon%sprohibited\\n"" , dst , reg_type_str [ ptr_reg -> type ] ) ; return - EACCES ; case PTR_TO_MAP_VALUE : if ( ! env -> allow_ptr_leaks && ! known && ( smin_val < 0 ) != ( smax_val < 0 ) ) { verbose ( env , ""R%dhasunknownscalarwithmixedsignedbounds,pointerarithmeticwithitprohibitedfor!root\\n"" , off_reg == dst_reg ? dst : src ) ; return - EACCES ; } default : break ; } dst_reg -> type = ptr_reg -> type ; dst_reg -> id = ptr_reg -> id ; if ( ! check_reg_sane_offset ( env , off_reg , ptr_reg -> type ) || ! check_reg_sane_offset ( env , ptr_reg , ptr_reg -> type ) ) return - EINVAL ; switch ( opcode ) { case BPF_ADD : if ( known && ( ptr_reg -> off + smin_val == ( s64 ) ( s32 ) ( ptr_reg -> off + smin_val ) ) ) { dst_reg -> smin_value = smin_ptr ; dst_reg -> smax_value = smax_ptr ; dst_reg -> umin_value = umin_ptr ; dst_reg -> umax_value = umax_ptr ; dst_reg -> var_off = ptr_reg -> var_off ; dst_reg -> off = ptr_reg -> off + smin_val ; dst_reg -> raw = ptr_reg -> raw ; break ; } if ( signed_add_overflows ( smin_ptr , smin_val ) || signed_add_overflows ( smax_ptr , smax_val ) ) { dst_reg -> smin_value = S64_MIN ; dst_reg -> smax_value = S64_MAX ; } else { dst_reg -> smin_value = smin_ptr + smin_val ; dst_reg -> smax_value = smax_ptr + smax_val ; } if ( umin_ptr + umin_val < umin_ptr || umax_ptr + umax_val < umax_ptr ) { dst_reg -> umin_value = 0 ; dst_reg -> umax_value = U64_MAX ; } else { dst_reg -> umin_value = umin_ptr + umin_val ; dst_reg -> umax_value = umax_ptr + umax_val ; } dst_reg -> var_off = tnum_add ( ptr_reg -> var_off , off_reg -> var_off ) ; dst_reg -> off = ptr_reg -> off ; dst_reg -> raw = ptr_reg -> raw ; if ( reg_is_pkt_pointer ( ptr_reg ) ) { dst_reg -> id = ++ env -> id_gen ; dst_reg -> raw = 0 ; } break ; case BPF_SUB : if ( dst_reg == off_reg ) { verbose ( env , ""R%dtriedtosubtractpointerfromscalar\\n"" , dst ) ; return - EACCES ; } if ( ptr_reg -> type == PTR_TO_STACK ) { verbose ( env , ""R%dsubtractionfromstackpointerprohibited\\n"" , dst ) ; return - EACCES ; } if ( known && ( ptr_reg -> off - smin_val == ( s64 ) ( s32 ) ( ptr_reg -> off - smin_val ) ) ) { dst_reg -> smin_value = smin_ptr ; dst_reg -> smax_value = smax_ptr ; dst_reg -> umin_value = umin_ptr ; dst_reg -> umax_value = umax_ptr ; dst_reg -> var_off = ptr_reg -> var_off ; dst_reg -> id = ptr_reg -> id ; dst_reg -> off = ptr_reg -> off - smin_val ; dst_reg -> raw = ptr_reg -> raw ; break ; } if ( signed_sub_overflows ( smin_ptr , smax_val ) || signed_sub_overflows ( smax_ptr , smin_val ) ) { dst_reg -> smin_value = S64_MIN ; dst_reg -> smax_value = S64_MAX ; } else { dst_reg -> smin_value = smin_ptr - smax_val ; dst_reg -> smax_value = smax_ptr - smin_val ; } if ( umin_ptr < umax_val ) { dst_reg -> umin_value = 0 ; dst_reg -> umax_value = U64_MAX ; } else { dst_reg -> umin_value = umin_ptr - umax_val ; dst_reg -> umax_value = umax_ptr - umin_val ; } dst_reg -> var_off = tnum_sub ( ptr_reg -> var_off , off_reg -> var_off ) ; dst_reg -> off = ptr_reg -> off ; dst_reg -> raw = ptr_reg -> raw ; if ( reg_is_pkt_pointer ( ptr_reg ) ) { dst_reg -> id = ++ env -> id_gen ; if ( smin_val < 0 ) dst_reg -> raw = 0 ; } break ; case BPF_AND : case BPF_OR : case BPF_XOR : verbose ( env , ""R%dbitwiseoperator%sonpointerprohibited\\n"" , dst , bpf_alu_string [ opcode >> 4 ] ) ; return - EACCES ; default : verbose ( env , ""R%dpointerarithmeticwith%soperatorprohibited\\n"" , dst , bpf_alu_string [ opcode >> 4 ] ) ; return - EACCES ; } if ( ! check_reg_sane_offset ( env , dst_reg , ptr_reg -> type ) ) return - EINVAL ; __update_reg_bounds ( dst_reg ) ; __reg_deduce_bounds ( dst_reg ) ; __reg_bound_offset ( dst_reg ) ; if ( ! env -> allow_ptr_leaks ) { if ( dst_reg -> type == PTR_TO_MAP_VALUE && check_map_access ( env , dst , dst_reg -> off , 1 , false ) ) { verbose ( env , ""R%dpointerarithmeticofmapvaluegoesoutofrange,"" ""prohibitedfor!root\\n"" , dst ) ; return - EACCES ; } else if ( dst_reg -> type == PTR_TO_STACK && check_stack_access ( env , dst_reg , dst_reg -> off + dst_reg -> var_off . value , 1 ) ) { verbose ( env , ""R%dstackpointerarithmeticgoesoutofrange,"" ""prohibitedfor!root\\n"" , dst ) ; return - EACCES ; } } return 0 ; } "," -> code ) ; int ret case BPF_ADD : ret = sanitize_ptr_alu ( env , insn , ptr_reg , dst_reg , smin_val < 0 ) ; if ( ret < 0 ) { verbose ( env , ""R%dtriedtoaddfromdifferentmapsorpaths\\n"" , dst ) ; return ret ; } case BPF_SUB : ret = sanitize_ptr_alu ( env , insn , ptr_reg , dst_reg , smin_val < 0 ) ; if ( ret < 0 ) { verbose ( env , ""R%dtriedtosubfromdifferentmapsorpaths\\n"" , dst ) ; return ret ; } ",torvalds@linux/979d63d50c0c0f7bc537bf821e056cc9fe5abd38,CVE-2019-7308,https://github.com/torvalds/linux/commit/979d63d50c0c0f7bc537bf821e056cc9fe5abd38,2019-02-01T22:29Z 248,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 249,CWE-763,"CWE-763 static void youngcollection ( lua_State * L , global_State * g ) { GCObject * * psurvival ; lua_assert ( g -> gcstate == GCSpropagate ) ; markold ( g , g -> allgc , 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 ) ; } "," L ) ; g -> gcstate = GCSswpallgc ; ",lua@lua/a6da1472c0c5e05ff249325f979531ad51533110,CVE-2020-24371,https://github.com/lua/lua/commit/a6da1472c0c5e05ff249325f979531ad51533110,2020-08-17T17:15Z 250,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 251,CWE-119,"CWE-119 void vp8_yv12_copy_frame_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 ; # if 0 assert ( src_ybc -> y_width == dst_ybc -> y_width ) ; assert ( src_ybc -> y_height == dst_ybc -> y_height ) ; # endif 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 ; } src = src_ybc -> u_buffer ; dst = dst_ybc -> u_buffer ; for ( row = 0 ; row < src_ybc -> uv_height ; ++ row ) { vpx_memcpy ( dst , src , src_ybc -> uv_width ) ; src += src_ybc -> uv_stride ; dst += dst_ybc -> uv_stride ; } src = src_ybc -> v_buffer ; dst = dst_ybc -> v_buffer ; for ( row = 0 ; row < src_ybc -> uv_height ; ++ row ) { vpx_memcpy ( dst , src , src_ybc -> uv_width ) ; src += src_ybc -> uv_stride ; dst += dst_ybc -> uv_stride ; } vp8_yv12_extend_frame_borders_c ( dst_ybc ) ; } "," ; # endif # if CONFIG_VP9_HIGHBITDEPTH if ( src_ybc -> flags & YV12_FLAG_HIGHBITDEPTH ) { assert ( dst_ybc -> flags & YV12_FLAG_HIGHBITDEPTH ) ; row ) { memcpy_short_addr ( dst , row ) { memcpy_short_addr ( dst , row ) { memcpy_short_addr ( dst , dst_ybc ) ; return ; } else { assert ( ! ( dst_ybc -> flags & YV12_FLAG_HIGHBITDEPTH ) ) ; } # endif for ( row = 0 ; row < src_ybc -> y_height ; ++ row ) { memcpy ( dst , src , src_ybc -> y_width ) ; src += src_ybc -> y_stride ; dst += dst_ybc -> y_stride ; } src = src_ybc -> u_buffer ; dst = dst_ybc -> u_buffer ; for ( row = 0 ; row < src_ybc -> uv_height ; ++ row ) { memcpy ( dst , src , src_ybc -> uv_width ) ; src += src_ybc -> uv_stride ; dst += dst_ybc -> uv_stride ; } src = src_ybc -> v_buffer ; dst = dst_ybc -> v_buffer ; for ( row = 0 ; row < src_ybc -> uv_height ; ++ row ) { memcpy ( dst , src , src_ybc -> uv_width ) ; src += src_ybc -> uv_stride ; dst += dst_ybc -> uv_stride ; } vp8_yv12_extend_frame_borders_c ( dst_ybc ) ; ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 252,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 253,CWE-119,"CWE-119 static vpx_codec_err_t ctrl_set_roi_map ( vpx_codec_alg_priv_t * ctx , int ctr_id , va_list args ) { return VPX_CODEC_INVALID_PARAM ; } "," * ctx , va_list args ) args ) { ( void ) ctx ; ( void ) args ; ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 254,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 ; 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 : 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 : 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 ; } "," -> header_len ; ND_TCHECK ( p [ 0 ] ) ; case LS_COOKIE_ID : ND_TCHECK2 ( p [ 0 ] , 2 ) ; case LS_COOKIE_ID : ND_TCHECK2 ( p [ 0 ] , 2 ) ; ",the-tcpdump-group@tcpdump/b534e304568585707c4a92422aeca25cf908ff02,CVE-2017-12993,https://github.com/the-tcpdump-group/tcpdump/commit/b534e304568585707c4a92422aeca25cf908ff02,2017-09-14T06:29Z 255,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 256,CWE-000,"CWE-000 static int decode_slice_header ( H264Context * h , H264Context * h0 ) { unsigned int first_mb_in_slice ; unsigned int pps_id ; int ret ; unsigned int slice_type , tmp , i , j ; int last_pic_structure , last_pic_droppable ; int must_reinit ; int needs_reinit = 0 ; int field_pic_flag , bottom_field_flag ; h -> me . qpel_put = h -> h264qpel . put_h264_qpel_pixels_tab ; h -> me . qpel_avg = h -> h264qpel . avg_h264_qpel_pixels_tab ; first_mb_in_slice = get_ue_golomb_long ( & h -> gb ) ; if ( first_mb_in_slice == 0 ) { if ( h0 -> current_slice && FIELD_PICTURE ( h ) ) { field_end ( h , 1 ) ; } h0 -> current_slice = 0 ; if ( ! h0 -> first_field ) { if ( h -> cur_pic_ptr && ! h -> droppable ) { ff_thread_report_progress ( & h -> cur_pic_ptr -> tf , INT_MAX , h -> picture_structure == PICT_BOTTOM_FIELD ) ; } h -> cur_pic_ptr = NULL ; } } slice_type = get_ue_golomb_31 ( & h -> gb ) ; if ( slice_type > 9 ) { av_log ( h -> avctx , AV_LOG_ERROR , ""slicetypetoolarge(%d)at%d%d\\n"" , slice_type , h -> mb_x , h -> mb_y ) ; return AVERROR_INVALIDDATA ; } if ( slice_type > 4 ) { slice_type -= 5 ; h -> slice_type_fixed = 1 ; } else h -> slice_type_fixed = 0 ; slice_type = golomb_to_pict_type [ slice_type ] ; h -> slice_type = slice_type ; h -> slice_type_nos = slice_type & 3 ; h -> pict_type = h -> slice_type ; pps_id = get_ue_golomb ( & h -> gb ) ; if ( pps_id >= MAX_PPS_COUNT ) { av_log ( h -> avctx , AV_LOG_ERROR , ""pps_id%doutofrange\\n"" , pps_id ) ; return AVERROR_INVALIDDATA ; } if ( ! h0 -> pps_buffers [ pps_id ] ) { av_log ( h -> avctx , AV_LOG_ERROR , ""non-existingPPS%ureferenced\\n"" , pps_id ) ; return AVERROR_INVALIDDATA ; } h -> pps = * h0 -> pps_buffers [ pps_id ] ; if ( ! h0 -> sps_buffers [ h -> pps . sps_id ] ) { av_log ( h -> avctx , AV_LOG_ERROR , ""non-existingSPS%ureferenced\\n"" , h -> pps . sps_id ) ; return AVERROR_INVALIDDATA ; } if ( h -> pps . sps_id != h -> current_sps_id || h0 -> sps_buffers [ h -> pps . sps_id ] -> new ) { h0 -> sps_buffers [ h -> pps . sps_id ] -> new = 0 ; h -> current_sps_id = h -> pps . sps_id ; h -> sps = * h0 -> sps_buffers [ h -> pps . sps_id ] ; if ( h -> mb_width != h -> sps . mb_width || h -> mb_height != h -> sps . mb_height * ( 2 - h -> sps . frame_mbs_only_flag ) || h -> avctx -> bits_per_raw_sample != h -> sps . bit_depth_luma || h -> cur_chroma_format_idc != h -> sps . chroma_format_idc ) needs_reinit = 1 ; if ( h -> bit_depth_luma != h -> sps . bit_depth_luma || h -> chroma_format_idc != h -> sps . chroma_format_idc ) { h -> bit_depth_luma = h -> sps . bit_depth_luma ; h -> chroma_format_idc = h -> sps . chroma_format_idc ; needs_reinit = 1 ; } if ( ( ret = h264_set_parameter_from_sps ( h ) ) < 0 ) return ret ; } h -> avctx -> profile = ff_h264_get_profile ( & h -> sps ) ; h -> avctx -> level = h -> sps . level_idc ; h -> avctx -> refs = h -> sps . ref_frame_count ; must_reinit = ( h -> context_initialized && ( 16 * h -> sps . mb_width != h -> avctx -> coded_width || 16 * h -> sps . mb_height * ( 2 - h -> sps . frame_mbs_only_flag ) != h -> avctx -> coded_height || h -> avctx -> bits_per_raw_sample != h -> sps . bit_depth_luma || h -> cur_chroma_format_idc != h -> sps . chroma_format_idc || av_cmp_q ( h -> sps . sar , h -> avctx -> sample_aspect_ratio ) || h -> mb_width != h -> sps . mb_width || h -> mb_height != h -> sps . mb_height * ( 2 - h -> sps . frame_mbs_only_flag ) ) ) ; if ( h0 -> avctx -> pix_fmt != get_pixel_format ( h0 , 0 ) ) must_reinit = 1 ; h -> mb_width = h -> sps . mb_width ; h -> mb_height = h -> sps . mb_height * ( 2 - h -> sps . frame_mbs_only_flag ) ; h -> mb_num = h -> mb_width * h -> mb_height ; h -> mb_stride = h -> mb_width + 1 ; h -> b_stride = h -> mb_width * 4 ; h -> chroma_y_shift = h -> sps . chroma_format_idc <= 1 ; h -> width = 16 * h -> mb_width ; h -> height = 16 * h -> mb_height ; ret = init_dimensions ( h ) ; if ( ret < 0 ) return ret ; if ( h -> sps . video_signal_type_present_flag ) { h -> avctx -> color_range = h -> sps . full_range > 0 ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG ; if ( h -> sps . colour_description_present_flag ) { if ( h -> avctx -> colorspace != h -> sps . colorspace ) needs_reinit = 1 ; h -> avctx -> color_primaries = h -> sps . color_primaries ; h -> avctx -> color_trc = h -> sps . color_trc ; h -> avctx -> colorspace = h -> sps . colorspace ; } } if ( h -> context_initialized && ( h -> width != h -> avctx -> coded_width || h -> height != h -> avctx -> coded_height || must_reinit || needs_reinit ) ) { if ( h != h0 ) { av_log ( h -> avctx , AV_LOG_ERROR , ""changingwidth/heighton"" ""slice%d\\n"" , h0 -> current_slice + 1 ) ; return AVERROR_INVALIDDATA ; } flush_change ( h ) ; if ( ( ret = get_pixel_format ( h , 1 ) ) < 0 ) return ret ; h -> avctx -> pix_fmt = ret ; av_log ( h -> avctx , AV_LOG_INFO , ""Reinitcontextto%dx%d,"" ""pix_fmt:%s\\n"" , h -> width , h -> height , av_get_pix_fmt_name ( h -> avctx -> pix_fmt ) ) ; if ( ( ret = h264_slice_header_init ( h , 1 ) ) < 0 ) { av_log ( h -> avctx , AV_LOG_ERROR , ""h264_slice_header_init()failed\\n"" ) ; return ret ; } } if ( ! h -> context_initialized ) { if ( h != h0 ) { av_log ( h -> avctx , AV_LOG_ERROR , ""Cannot(re-)initializecontextduringparalleldecoding.\\n"" ) ; return AVERROR_PATCHWELCOME ; } if ( ( ret = get_pixel_format ( h , 1 ) ) < 0 ) return ret ; h -> avctx -> pix_fmt = ret ; if ( ( ret = h264_slice_header_init ( h , 0 ) ) < 0 ) { av_log ( h -> avctx , AV_LOG_ERROR , ""h264_slice_header_init()failed\\n"" ) ; return ret ; } } if ( h == h0 && h -> dequant_coeff_pps != pps_id ) { h -> dequant_coeff_pps = pps_id ; init_dequant_tables ( h ) ; } h -> frame_num = get_bits ( & h -> gb , h -> sps . log2_max_frame_num ) ; h -> mb_mbaff = 0 ; h -> mb_aff_frame = 0 ; last_pic_structure = h0 -> picture_structure ; last_pic_droppable = h0 -> droppable ; h -> droppable = h -> nal_ref_idc == 0 ; if ( h -> sps . frame_mbs_only_flag ) { h -> picture_structure = PICT_FRAME ; } else { if ( ! h -> sps . direct_8x8_inference_flag && slice_type == AV_PICTURE_TYPE_B ) { av_log ( h -> avctx , AV_LOG_ERROR , ""Thisstreamwasgeneratedbyabrokenencoder,invalid8x8inference\\n"" ) ; return - 1 ; } field_pic_flag = get_bits1 ( & h -> gb ) ; if ( field_pic_flag ) { bottom_field_flag = get_bits1 ( & h -> gb ) ; h -> picture_structure = PICT_TOP_FIELD + bottom_field_flag ; } else { h -> picture_structure = PICT_FRAME ; h -> mb_aff_frame = h -> sps . mb_aff ; } } h -> mb_field_decoding_flag = h -> picture_structure != PICT_FRAME ; if ( h0 -> current_slice != 0 ) { if ( last_pic_structure != h -> picture_structure || last_pic_droppable != h -> droppable ) { av_log ( h -> avctx , AV_LOG_ERROR , ""Changingfieldmode(%d->%d)betweenslicesisnotallowed\\n"" , last_pic_structure , h -> picture_structure ) ; h -> picture_structure = last_pic_structure ; h -> droppable = last_pic_droppable ; return AVERROR_INVALIDDATA ; } else if ( ! h0 -> cur_pic_ptr ) { av_log ( h -> avctx , AV_LOG_ERROR , ""unsetcur_pic_ptron%d.slice\\n"" , h0 -> current_slice + 1 ) ; return AVERROR_INVALIDDATA ; } } else { if ( h -> frame_num != h -> prev_frame_num && h -> prev_frame_num >= 0 ) { int unwrap_prev_frame_num = h -> prev_frame_num ; int max_frame_num = 1 << h -> sps . log2_max_frame_num ; if ( unwrap_prev_frame_num > h -> frame_num ) unwrap_prev_frame_num -= max_frame_num ; if ( ( h -> frame_num - unwrap_prev_frame_num ) > h -> sps . ref_frame_count ) { unwrap_prev_frame_num = ( h -> frame_num - h -> sps . ref_frame_count ) - 1 ; if ( unwrap_prev_frame_num < 0 ) unwrap_prev_frame_num += max_frame_num ; h -> prev_frame_num = unwrap_prev_frame_num ; } } if ( h0 -> first_field ) { assert ( h0 -> cur_pic_ptr ) ; assert ( h0 -> cur_pic_ptr -> f . data [ 0 ] ) ; assert ( h0 -> cur_pic_ptr -> reference != DELAYED_PIC_REF ) ; if ( ! last_pic_droppable && h0 -> cur_pic_ptr -> tf . owner == h0 -> avctx ) { ff_thread_report_progress ( & h0 -> cur_pic_ptr -> tf , INT_MAX , last_pic_structure == PICT_BOTTOM_FIELD ) ; } if ( ! FIELD_PICTURE ( h ) || h -> picture_structure == last_pic_structure ) { if ( ! last_pic_droppable && last_pic_structure != PICT_FRAME ) { ff_thread_report_progress ( & h0 -> cur_pic_ptr -> tf , INT_MAX , last_pic_structure == PICT_TOP_FIELD ) ; } } else { if ( h0 -> cur_pic_ptr -> frame_num != h -> frame_num ) { if ( ! last_pic_droppable && last_pic_structure != PICT_FRAME ) { ff_thread_report_progress ( & h0 -> cur_pic_ptr -> tf , INT_MAX , last_pic_structure == PICT_TOP_FIELD ) ; } } else { if ( ! ( ( last_pic_structure == PICT_TOP_FIELD && h -> picture_structure == PICT_BOTTOM_FIELD ) || ( last_pic_structure == PICT_BOTTOM_FIELD && h -> picture_structure == PICT_TOP_FIELD ) ) ) { av_log ( h -> avctx , AV_LOG_ERROR , ""Invalidfieldmodecombination%d/%d\\n"" , last_pic_structure , h -> picture_structure ) ; h -> picture_structure = last_pic_structure ; h -> droppable = last_pic_droppable ; return AVERROR_INVALIDDATA ; } else if ( last_pic_droppable != h -> droppable ) { avpriv_request_sample ( h -> avctx , ""Foundreferenceandnon-referencefieldsinthesameframe,which"" ) ; h -> picture_structure = last_pic_structure ; h -> droppable = last_pic_droppable ; return AVERROR_PATCHWELCOME ; } } } } while ( h -> frame_num != h -> prev_frame_num && h -> prev_frame_num >= 0 && ! h0 -> first_field && h -> frame_num != ( h -> prev_frame_num + 1 ) % ( 1 << h -> sps . log2_max_frame_num ) ) { Picture * prev = h -> short_ref_count ? h -> short_ref [ 0 ] : NULL ; av_log ( h -> avctx , AV_LOG_DEBUG , ""Framenumgap%d%d\\n"" , h -> frame_num , h -> prev_frame_num ) ; if ( ! h -> sps . gaps_in_frame_num_allowed_flag ) for ( i = 0 ; i < FF_ARRAY_ELEMS ( h -> last_pocs ) ; i ++ ) h -> last_pocs [ i ] = INT_MIN ; ret = h264_frame_start ( h ) ; if ( ret < 0 ) return ret ; h -> prev_frame_num ++ ; h -> prev_frame_num %= 1 << h -> sps . log2_max_frame_num ; h -> cur_pic_ptr -> frame_num = h -> prev_frame_num ; ff_thread_report_progress ( & h -> cur_pic_ptr -> tf , INT_MAX , 0 ) ; ff_thread_report_progress ( & h -> cur_pic_ptr -> tf , INT_MAX , 1 ) ; ret = ff_generate_sliding_window_mmcos ( h , 1 ) ; if ( ret < 0 && ( h -> avctx -> err_recognition & AV_EF_EXPLODE ) ) return ret ; ret = ff_h264_execute_ref_pic_marking ( h , h -> mmco , h -> mmco_index ) ; if ( ret < 0 && ( h -> avctx -> err_recognition & AV_EF_EXPLODE ) ) return ret ; if ( h -> short_ref_count ) { if ( prev ) { av_image_copy ( h -> short_ref [ 0 ] -> f . data , h -> short_ref [ 0 ] -> f . linesize , ( const uint8_t * * ) prev -> f . data , prev -> f . linesize , h -> avctx -> pix_fmt , h -> mb_width * 16 , h -> mb_height * 16 ) ; h -> short_ref [ 0 ] -> poc = prev -> poc + 2 ; } h -> short_ref [ 0 ] -> frame_num = h -> prev_frame_num ; } } if ( h0 -> first_field ) { assert ( h0 -> cur_pic_ptr ) ; assert ( h0 -> cur_pic_ptr -> f . data [ 0 ] ) ; assert ( h0 -> cur_pic_ptr -> reference != DELAYED_PIC_REF ) ; if ( ! FIELD_PICTURE ( h ) || h -> picture_structure == last_pic_structure ) { h0 -> cur_pic_ptr = NULL ; h0 -> first_field = FIELD_PICTURE ( h ) ; } else { if ( h0 -> cur_pic_ptr -> frame_num != h -> frame_num ) { ff_thread_report_progress ( & h0 -> cur_pic_ptr -> tf , INT_MAX , h0 -> picture_structure == PICT_BOTTOM_FIELD ) ; h0 -> first_field = 1 ; h0 -> cur_pic_ptr = NULL ; } else { h0 -> first_field = 0 ; } } } else { h0 -> first_field = FIELD_PICTURE ( h ) ; } if ( ! FIELD_PICTURE ( h ) || h0 -> first_field ) { if ( h264_frame_start ( h ) < 0 ) { h0 -> first_field = 0 ; return AVERROR_INVALIDDATA ; } } else { release_unused_pictures ( h , 0 ) ; } if ( FIELD_PICTURE ( h ) ) { for ( i = ( h -> picture_structure == PICT_BOTTOM_FIELD ) ; i < h -> mb_height ; i ++ ) memset ( h -> slice_table + i * h -> mb_stride , - 1 , ( h -> mb_stride - ( i + 1 == h -> mb_height ) ) * sizeof ( * h -> slice_table ) ) ; } else { memset ( h -> slice_table , - 1 , ( h -> mb_height * h -> mb_stride - 1 ) * sizeof ( * h -> slice_table ) ) ; } h0 -> last_slice_type = - 1 ; } if ( h != h0 && ( ret = clone_slice ( h , h0 ) ) < 0 ) return ret ; for ( i = 0 ; i < h -> slice_context_count ; i ++ ) if ( h -> thread_context [ i ] ) { ret = alloc_scratch_buffers ( h -> thread_context [ i ] , h -> linesize ) ; if ( ret < 0 ) return ret ; } h -> cur_pic_ptr -> frame_num = h -> frame_num ; av_assert1 ( h -> mb_num == h -> mb_width * h -> mb_height ) ; if ( first_mb_in_slice << FIELD_OR_MBAFF_PICTURE ( h ) >= h -> mb_num || first_mb_in_slice >= h -> mb_num ) { av_log ( h -> avctx , AV_LOG_ERROR , ""first_mb_in_sliceoverflow\\n"" ) ; return AVERROR_INVALIDDATA ; } h -> resync_mb_x = h -> mb_x = first_mb_in_slice % h -> mb_width ; h -> resync_mb_y = h -> mb_y = ( first_mb_in_slice / h -> mb_width ) << FIELD_OR_MBAFF_PICTURE ( h ) ; if ( h -> picture_structure == PICT_BOTTOM_FIELD ) h -> resync_mb_y = h -> mb_y = h -> mb_y + 1 ; av_assert1 ( h -> mb_y < h -> mb_height ) ; if ( h -> picture_structure == PICT_FRAME ) { h -> curr_pic_num = h -> frame_num ; h -> max_pic_num = 1 << h -> sps . log2_max_frame_num ; } else { h -> curr_pic_num = 2 * h -> frame_num + 1 ; h -> max_pic_num = 1 << ( h -> sps . log2_max_frame_num + 1 ) ; } if ( h -> nal_unit_type == NAL_IDR_SLICE ) get_ue_golomb ( & h -> gb ) ; if ( h -> sps . poc_type == 0 ) { h -> poc_lsb = get_bits ( & h -> gb , h -> sps . log2_max_poc_lsb ) ; if ( h -> pps . pic_order_present == 1 && h -> picture_structure == PICT_FRAME ) h -> delta_poc_bottom = get_se_golomb ( & h -> gb ) ; } if ( h -> sps . poc_type == 1 && ! h -> sps . delta_pic_order_always_zero_flag ) { h -> delta_poc [ 0 ] = get_se_golomb ( & h -> gb ) ; if ( h -> pps . pic_order_present == 1 && h -> picture_structure == PICT_FRAME ) h -> delta_poc [ 1 ] = get_se_golomb ( & h -> gb ) ; } ff_init_poc ( h , h -> cur_pic_ptr -> field_poc , & h -> cur_pic_ptr -> poc ) ; if ( h -> pps . redundant_pic_cnt_present ) h -> redundant_pic_count = get_ue_golomb ( & h -> gb ) ; ret = ff_set_ref_count ( h ) ; if ( ret < 0 ) return ret ; if ( slice_type != AV_PICTURE_TYPE_I && ( h0 -> current_slice == 0 || slice_type != h0 -> last_slice_type || memcmp ( h0 -> last_ref_count , h0 -> ref_count , sizeof ( h0 -> ref_count ) ) ) ) { ff_h264_fill_default_ref_list ( h ) ; } if ( h -> slice_type_nos != AV_PICTURE_TYPE_I ) { ret = ff_h264_decode_ref_pic_list_reordering ( h ) ; if ( ret < 0 ) { h -> ref_count [ 1 ] = h -> ref_count [ 0 ] = 0 ; return ret ; } } if ( ( h -> pps . weighted_pred && h -> slice_type_nos == AV_PICTURE_TYPE_P ) || ( h -> pps . weighted_bipred_idc == 1 && h -> slice_type_nos == AV_PICTURE_TYPE_B ) ) ff_pred_weight_table ( h ) ; else if ( h -> pps . weighted_bipred_idc == 2 && h -> slice_type_nos == AV_PICTURE_TYPE_B ) { implicit_weight_table ( h , - 1 ) ; } else { h -> use_weight = 0 ; for ( i = 0 ; i < 2 ; i ++ ) { h -> luma_weight_flag [ i ] = 0 ; h -> chroma_weight_flag [ i ] = 0 ; } } if ( h -> nal_ref_idc ) { ret = ff_h264_decode_ref_pic_marking ( h0 , & h -> gb , ! ( h -> avctx -> active_thread_type & FF_THREAD_FRAME ) || h0 -> current_slice == 0 ) ; if ( ret < 0 && ( h -> avctx -> err_recognition & AV_EF_EXPLODE ) ) return AVERROR_INVALIDDATA ; } if ( FRAME_MBAFF ( h ) ) { ff_h264_fill_mbaff_ref_list ( h ) ; if ( h -> pps . weighted_bipred_idc == 2 && h -> slice_type_nos == AV_PICTURE_TYPE_B ) { implicit_weight_table ( h , 0 ) ; implicit_weight_table ( h , 1 ) ; } } if ( h -> slice_type_nos == AV_PICTURE_TYPE_B && ! h -> direct_spatial_mv_pred ) ff_h264_direct_dist_scale_factor ( h ) ; ff_h264_direct_ref_list_init ( h ) ; if ( h -> slice_type_nos != AV_PICTURE_TYPE_I && h -> pps . cabac ) { tmp = get_ue_golomb_31 ( & h -> gb ) ; if ( tmp > 2 ) { av_log ( h -> avctx , AV_LOG_ERROR , ""cabac_init_idcoverflow\\n"" ) ; return AVERROR_INVALIDDATA ; } h -> cabac_init_idc = tmp ; } h -> last_qscale_diff = 0 ; tmp = h -> pps . init_qp + get_se_golomb ( & h -> gb ) ; if ( tmp > 51 + 6 * ( h -> sps . bit_depth_luma - 8 ) ) { av_log ( h -> avctx , AV_LOG_ERROR , ""QP%uoutofrange\\n"" , tmp ) ; return AVERROR_INVALIDDATA ; } h -> qscale = tmp ; h -> chroma_qp [ 0 ] = get_chroma_qp ( h , 0 , h -> qscale ) ; h -> chroma_qp [ 1 ] = get_chroma_qp ( h , 1 , h -> qscale ) ; if ( h -> slice_type == AV_PICTURE_TYPE_SP ) get_bits1 ( & h -> gb ) ; if ( h -> slice_type == AV_PICTURE_TYPE_SP || h -> slice_type == AV_PICTURE_TYPE_SI ) get_se_golomb ( & h -> gb ) ; h -> deblocking_filter = 1 ; h -> slice_alpha_c0_offset = 52 ; h -> slice_beta_offset = 52 ; if ( h -> pps . deblocking_filter_parameters_present ) { tmp = get_ue_golomb_31 ( & h -> gb ) ; if ( tmp > 2 ) { av_log ( h -> avctx , AV_LOG_ERROR , ""deblocking_filter_idc%uoutofrange\\n"" , tmp ) ; return AVERROR_INVALIDDATA ; } h -> deblocking_filter = tmp ; if ( h -> deblocking_filter < 2 ) h -> deblocking_filter ^= 1 ; if ( h -> deblocking_filter ) { h -> slice_alpha_c0_offset += get_se_golomb ( & h -> gb ) << 1 ; h -> slice_beta_offset += get_se_golomb ( & h -> gb ) << 1 ; if ( h -> slice_alpha_c0_offset > 104U || h -> slice_beta_offset > 104U ) { av_log ( h -> avctx , AV_LOG_ERROR , ""deblockingfilterparameters%d%doutofrange\\n"" , h -> slice_alpha_c0_offset , h -> slice_beta_offset ) ; return AVERROR_INVALIDDATA ; } } } if ( h -> avctx -> skip_loop_filter >= AVDISCARD_ALL || ( h -> avctx -> skip_loop_filter >= AVDISCARD_NONKEY && h -> slice_type_nos != AV_PICTURE_TYPE_I ) || ( h -> avctx -> skip_loop_filter >= AVDISCARD_BIDIR && h -> slice_type_nos == AV_PICTURE_TYPE_B ) || ( h -> avctx -> skip_loop_filter >= AVDISCARD_NONREF && h -> nal_ref_idc == 0 ) ) h -> deblocking_filter = 0 ; if ( h -> deblocking_filter == 1 && h0 -> max_contexts > 1 ) { if ( h -> avctx -> flags2 & CODEC_FLAG2_FAST ) { h -> deblocking_filter = 2 ; } else { h0 -> max_contexts = 1 ; if ( ! h0 -> single_decode_warning ) { av_log ( h -> avctx , AV_LOG_INFO , ""Cannotparallelizedeblockingtype1,decodingsuchframesinsequentialorder\\n"" ) ; h0 -> single_decode_warning = 1 ; } if ( h != h0 ) { av_log ( h -> avctx , AV_LOG_ERROR , ""Deblockingswitchedinsideframe.\\n"" ) ; return 1 ; } } } h -> qp_thresh = 15 + 52 - FFMIN ( h -> slice_alpha_c0_offset , h -> slice_beta_offset ) - FFMAX3 ( 0 , h -> pps . chroma_qp_index_offset [ 0 ] , h -> pps . chroma_qp_index_offset [ 1 ] ) + 6 * ( h -> sps . bit_depth_luma - 8 ) ; h0 -> last_slice_type = slice_type ; memcpy ( h0 -> last_ref_count , h0 -> ref_count , sizeof ( h0 -> last_ref_count ) ) ; h -> slice_num = ++ h0 -> current_slice ; if ( h -> slice_num ) h0 -> slice_row [ ( h -> slice_num - 1 ) & ( MAX_SLICES - 1 ) ] = h -> resync_mb_y ; if ( h0 -> slice_row [ h -> slice_num & ( MAX_SLICES - 1 ) ] + 3 >= h -> resync_mb_y && h0 -> slice_row [ h -> slice_num & ( MAX_SLICES - 1 ) ] <= h -> resync_mb_y && h -> slice_num >= MAX_SLICES ) { av_log ( h -> avctx , AV_LOG_WARNING , ""Possiblytoomanyslices(%d>=%d),increaseMAX_SLICESandrecompileifthereareartifacts\\n"" , h -> slice_num , MAX_SLICES ) ; } for ( j = 0 ; j < 2 ; j ++ ) { int id_list [ 16 ] ; int * ref2frm = h -> ref2frm [ h -> slice_num & ( MAX_SLICES - 1 ) ] [ j ] ; for ( i = 0 ; i < 16 ; i ++ ) { id_list [ i ] = 60 ; if ( j < h -> list_count && i < h -> ref_count [ j ] && h -> ref_list [ j ] [ i ] . f . buf [ 0 ] ) { int k ; AVBuffer * buf = h -> ref_list [ j ] [ i ] . f . buf [ 0 ] -> buffer ; for ( k = 0 ; k < h -> short_ref_count ; k ++ ) if ( h -> short_ref [ k ] -> f . buf [ 0 ] -> buffer == buf ) { id_list [ i ] = k ; break ; } for ( k = 0 ; k < h -> long_ref_count ; k ++ ) if ( h -> long_ref [ k ] && h -> long_ref [ k ] -> f . buf [ 0 ] -> buffer == buf ) { id_list [ i ] = h -> short_ref_count + k ; break ; } } } ref2frm [ 0 ] = ref2frm [ 1 ] = - 1 ; for ( i = 0 ; i < 16 ; i ++ ) ref2frm [ i + 2 ] = 4 * id_list [ i ] + ( h -> ref_list [ j ] [ i ] . reference & 3 ) ; ref2frm [ 18 + 0 ] = ref2frm [ 18 + 1 ] = - 1 ; for ( i = 16 ; i < 48 ; i ++ ) ref2frm [ i + 4 ] = 4 * id_list [ ( i - 16 ) >> 1 ] + ( h -> ref_list [ j ] [ i ] . reference & 3 ) ; } if ( h -> ref_count [ 0 ] ) h -> er . last_pic = & h -> ref_list [ 0 ] [ 0 ] ; if ( h -> ref_count [ 1 ] ) h -> er . next_pic = & h -> ref_list [ 1 ] [ 0 ] ; h -> er . ref_count = h -> ref_count [ 0 ] ; if ( h -> avctx -> debug & FF_DEBUG_PICT_INFO ) { av_log ( h -> avctx , AV_LOG_DEBUG , ""slice:%d%smb:%d%c%s%spps:%uframe:%dpoc:%d/%dref:%d/%dqp:%dloop:%d:%d:%dweight:%d%s%s\\n"" , h -> slice_num , ( h -> picture_structure == PICT_FRAME ? ""F"" : h -> picture_structure == PICT_TOP_FIELD ? ""T"" : ""B"" ) , first_mb_in_slice , av_get_picture_type_char ( h -> slice_type ) , h -> slice_type_fixed ? ""fix"" : """" , h -> nal_unit_type == NAL_IDR_SLICE ? ""IDR"" : """" , pps_id , h -> frame_num , h -> cur_pic_ptr -> field_poc [ 0 ] , h -> cur_pic_ptr -> field_poc [ 1 ] , h -> ref_count [ 0 ] , h -> ref_count [ 1 ] , h -> qscale , h -> deblocking_filter , h -> slice_alpha_c0_offset / 2 - 26 , h -> slice_beta_offset / 2 - 26 , h -> use_weight , h -> use_weight == 1 && h -> use_weight_chroma ? ""c"" : """" , h -> slice_type == AV_PICTURE_TYPE_B ? ( h -> direct_spatial_mv_pred ? ""SPAT"" : ""TEMP"" ) : """" ) ; } return 0 ; } "," ; if ( h0 -> cur_pic_ptr { if ( last_pic_structure != PICT_FRAME { if ( last_pic_structure != PICT_FRAME ",FFmpeg@FFmpeg/29ffeef5e73b8f41ff3a3f2242d356759c66f91f,CVE-2013-7008,https://github.com/FFmpeg/FFmpeg/commit/29ffeef5e73b8f41ff3a3f2242d356759c66f91f,2013-12-09T16:36Z 257,CWE-119,"CWE-119 static int cmd_info ( void * data , const char * input ) { RCore * core = ( RCore * ) data ; bool newline = r_config_get_i ( core -> config , ""scr.interactive"" ) ; RBinObject * o = r_bin_cur_object ( core -> bin ) ; RCoreFile * cf = core -> file ; int i , va = core -> io -> va || core -> io -> debug ; int mode = 0 ; int is_array = 0 ; Sdb * db ; for ( i = 0 ; input [ i ] && input [ i ] != '' ; i ++ ) ; if ( i > 0 ) { switch ( input [ i - 1 ] ) { case '*' : mode = R_CORE_BIN_RADARE ; break ; case 'j' : mode = R_CORE_BIN_JSON ; break ; case 'q' : mode = R_CORE_BIN_SIMPLE ; break ; } } if ( mode == R_CORE_BIN_JSON ) { if ( strlen ( input + 1 ) > 1 ) { is_array = 1 ; } } if ( is_array ) { r_cons_printf ( ""{"" ) ; } if ( ! * input ) { cmd_info_bin ( core , va , mode ) ; } if ( ! strcmp ( input , ""*"" ) ) { input = ""I*"" ; } RBinObject * obj = r_bin_cur_object ( core -> bin ) ; while ( * input ) { switch ( * input ) { case 'b' : { ut64 baddr = r_config_get_i ( core -> config , ""bin.baddr"" ) ; if ( input [ 1 ] == '' ) { baddr = r_num_math ( core -> num , input + 1 ) ; } r_core_bin_reload ( core , NULL , baddr ) ; r_core_block_read ( core ) ; newline = false ; } break ; case 'k' : db = o ? o -> kv : NULL ; switch ( input [ 1 ] ) { case 'v' : if ( db ) { char * o = sdb_querys ( db , NULL , 0 , input + 3 ) ; if ( o && * o ) { r_cons_print ( o ) ; } free ( o ) ; } break ; case '*' : r_core_bin_export_info_rad ( core ) ; break ; case '.' : case '' : if ( db ) { char * o = sdb_querys ( db , NULL , 0 , input + 2 ) ; if ( o && * o ) { r_cons_print ( o ) ; } free ( o ) ; } break ; case '\\0' : if ( db ) { char * o = sdb_querys ( db , NULL , 0 , ""*"" ) ; if ( o && * o ) { r_cons_print ( o ) ; } free ( o ) ; } break ; case '?' : default : eprintf ( ""Usage:ik[sdb-query]\\n"" ) ; eprintf ( ""Usage:ik*#loadallheaderinformation\\n"" ) ; } goto done ; break ; case 'o' : { if ( ! cf ) { eprintf ( ""Corefilenotopen\\n"" ) ; return 0 ; } const char * fn = input [ 1 ] == '' ? input + 2 : cf -> desc -> name ; ut64 baddr = r_config_get_i ( core -> config , ""bin.baddr"" ) ; r_core_bin_load ( core , fn , baddr ) ; } break ; # define RBININFO ( n , x , y , z ) if ( is_array ) { if ( is_array == 1 ) { is_array ++ ; } else { r_cons_printf ( "","" ) ; } r_cons_printf ( ""\\""%s\\"":"" , n ) ; } if ( z ) { playMsg ( core , n , z ) ; } r_core_bin_info ( core , x , mode , va , NULL , y ) ; case 'A' : newline = false ; if ( input [ 1 ] == 'j' ) { r_cons_printf ( ""{"" ) ; r_bin_list_archs ( core -> bin , 'j' ) ; r_cons_printf ( ""}\\n"" ) ; } else { r_bin_list_archs ( core -> bin , 1 ) ; } break ; case 'E' : RBININFO ( ""exports"" , R_CORE_BIN_ACC_EXPORTS , NULL , 0 ) ; break ; case 'Z' : RBININFO ( ""size"" , R_CORE_BIN_ACC_SIZE , NULL , 0 ) ; break ; case 'S' : if ( ( input [ 1 ] == 'm' && input [ 2 ] == 'z' ) || ! input [ 1 ] ) { RBININFO ( ""sections"" , R_CORE_BIN_ACC_SECTIONS , NULL , 0 ) ; } else { RBinObject * obj = r_bin_cur_object ( core -> bin ) ; if ( mode == R_CORE_BIN_RADARE || mode == R_CORE_BIN_JSON || mode == R_CORE_BIN_SIMPLE ) { RBININFO ( ""sections"" , R_CORE_BIN_ACC_SECTIONS , input + 2 , obj ? r_list_length ( obj -> sections ) : 0 ) ; } else { RBININFO ( ""sections"" , R_CORE_BIN_ACC_SECTIONS , input + 1 , obj ? r_list_length ( obj -> sections ) : 0 ) ; } while ( * ( ++ input ) ) ; input -- ; } break ; case 'H' : if ( input [ 1 ] == 'H' ) { RBININFO ( ""header"" , R_CORE_BIN_ACC_HEADER , NULL , - 1 ) ; break ; } case 'h' : RBININFO ( ""fields"" , R_CORE_BIN_ACC_FIELDS , NULL , 0 ) ; break ; case 'l' : RBININFO ( ""libs"" , R_CORE_BIN_ACC_LIBS , NULL , obj ? r_list_length ( obj -> libs ) : 0 ) ; break ; case 'L' : { char * ptr = strchr ( input , '' ) ; int json = input [ 1 ] == 'j' ? 'j' : 0 ; if ( ptr && ptr [ 1 ] ) { const char * plugin_name = ptr + 1 ; if ( is_array ) { r_cons_printf ( ""\\""plugin\\"":"" ) ; } r_bin_list_plugin ( core -> bin , plugin_name , json ) ; } else { r_bin_list ( core -> bin , json ) ; } newline = false ; goto done ; } break ; case 's' : if ( input [ 1 ] == '.' ) { ut64 addr = core -> offset + ( core -> print -> cur_enabled ? core -> print -> cur : 0 ) ; RFlagItem * f = r_flag_get_at ( core -> flags , addr , false ) ; if ( f ) { if ( f -> offset == addr || ! f -> offset ) { r_cons_printf ( ""%s"" , f -> name ) ; } else { r_cons_printf ( ""%s+%d"" , f -> name , ( int ) ( addr - f -> offset ) ) ; } } input ++ ; break ; } else { RBinObject * obj = r_bin_cur_object ( core -> bin ) ; RBININFO ( ""symbols"" , R_CORE_BIN_ACC_SYMBOLS , NULL , obj ? r_list_length ( obj -> symbols ) : 0 ) ; break ; } case 'R' : if ( input [ 1 ] == '*' ) { mode = R_CORE_BIN_RADARE ; } else if ( input [ 1 ] == 'j' ) { mode = R_CORE_BIN_JSON ; } RBININFO ( ""resources"" , R_CORE_BIN_ACC_RESOURCES , NULL , 0 ) ; break ; case 'r' : RBININFO ( ""relocs"" , R_CORE_BIN_ACC_RELOCS , NULL , 0 ) ; break ; case 'd' : RBININFO ( ""dwarf"" , R_CORE_BIN_ACC_DWARF , NULL , - 1 ) ; break ; case 'i' : RBININFO ( ""imports"" , R_CORE_BIN_ACC_IMPORTS , NULL , obj ? r_list_length ( obj -> imports ) : 0 ) ; break ; case 'I' : RBININFO ( ""info"" , R_CORE_BIN_ACC_INFO , NULL , 0 ) ; break ; case 'e' : RBININFO ( ""entries"" , R_CORE_BIN_ACC_ENTRIES , NULL , 0 ) ; break ; case 'M' : RBININFO ( ""main"" , R_CORE_BIN_ACC_MAIN , NULL , 0 ) ; break ; case 'm' : RBININFO ( ""memory"" , R_CORE_BIN_ACC_MEM , NULL , 0 ) ; break ; case 'V' : RBININFO ( ""versioninfo"" , R_CORE_BIN_ACC_VERSIONINFO , NULL , 0 ) ; break ; case 'C' : RBININFO ( ""signature"" , R_CORE_BIN_ACC_SIGNATURE , NULL , 0 ) ; break ; case 'z' : if ( input [ 1 ] == 'z' ) { switch ( input [ 2 ] ) { case '*' : mode = R_CORE_BIN_RADARE ; break ; case 'j' : mode = R_CORE_BIN_JSON ; break ; case 'q' : if ( input [ 3 ] == 'q' ) { mode = R_CORE_BIN_SIMPLEST ; input ++ ; } else { mode = R_CORE_BIN_SIMPLE ; } break ; default : mode = R_CORE_BIN_PRINT ; break ; } input ++ ; RBININFO ( ""strings"" , R_CORE_BIN_ACC_RAW_STRINGS , NULL , 0 ) ; } else { RBinObject * obj = r_bin_cur_object ( core -> bin ) ; if ( input [ 1 ] == 'q' ) { mode = ( input [ 2 ] == 'q' ) ? R_CORE_BIN_SIMPLEST : R_CORE_BIN_SIMPLE ; input ++ ; } if ( obj ) { RBININFO ( ""strings"" , R_CORE_BIN_ACC_STRINGS , NULL , obj ? r_list_length ( obj -> strings ) : 0 ) ; } } break ; case 'c' : if ( input [ 1 ] == '?' ) { eprintf ( ""Usage:ic[ljq*][class-indexorname]\\n"" ) ; } else if ( input [ 1 ] == '' || input [ 1 ] == 'q' || input [ 1 ] == 'j' || input [ 1 ] == 'l' ) { RBinClass * cls ; RBinSymbol * sym ; RListIter * iter , * iter2 ; RBinObject * obj = r_bin_cur_object ( core -> bin ) ; if ( obj ) { if ( input [ 2 ] ) { int idx = - 1 ; const char * cls_name = NULL ; if ( r_num_is_valid_input ( core -> num , input + 2 ) ) { idx = r_num_math ( core -> num , input + 2 ) ; } else { const char * first_char = input + ( ( input [ 1 ] == '' ) ? 1 : 2 ) ; int not_space = strspn ( first_char , """" ) ; if ( first_char [ not_space ] ) { cls_name = first_char + not_space ; } } int count = 0 ; r_list_foreach ( obj -> classes , iter , cls ) { if ( ( idx >= 0 && idx != count ++ ) || ( cls_name && strcmp ( cls_name , cls -> name ) != 0 ) ) { continue ; } switch ( input [ 1 ] ) { case '*' : r_list_foreach ( cls -> methods , iter2 , sym ) { r_cons_printf ( ""fsym.%s@0x%"" PFMT64x ""\\n"" , sym -> name , sym -> vaddr ) ; } input ++ ; break ; case 'l' : r_list_foreach ( cls -> methods , iter2 , sym ) { const char * comma = iter2 -> p ? """" : """" ; r_cons_printf ( ""%s0x%"" PFMT64d , comma , sym -> vaddr ) ; } r_cons_newline ( ) ; input ++ ; break ; case 'j' : input ++ ; r_cons_printf ( ""\\""class\\"":\\""%s\\"""" , cls -> name ) ; r_cons_printf ( "",\\""methods\\"":["" ) ; r_list_foreach ( cls -> methods , iter2 , sym ) { const char * comma = iter2 -> p ? "","" : """" ; if ( sym -> method_flags ) { char * flags = r_core_bin_method_flags_str ( sym , R_CORE_BIN_JSON ) ; r_cons_printf ( ""%s{\\""name\\"":\\""%s\\"",\\""flags\\"":%s,\\""vaddr\\"":%"" PFMT64d ""}"" , comma , sym -> name , flags , sym -> vaddr ) ; R_FREE ( flags ) ; } else { r_cons_printf ( ""%s{\\""name\\"":\\""%s\\"",\\""vaddr\\"":%"" PFMT64d ""}"" , comma , sym -> name , sym -> vaddr ) ; } } r_cons_printf ( ""]"" ) ; break ; default : r_cons_printf ( ""class%s\\n"" , cls -> name ) ; r_list_foreach ( cls -> methods , iter2 , sym ) { char * flags = r_core_bin_method_flags_str ( sym , 0 ) ; r_cons_printf ( ""0x%08"" PFMT64x ""method%s%s%s\\n"" , sym -> vaddr , cls -> name , flags , sym -> name ) ; R_FREE ( flags ) ; } break ; } goto done ; } goto done ; } else { playMsg ( core , ""classes"" , r_list_length ( obj -> classes ) ) ; if ( input [ 1 ] == 'l' && obj ) { r_list_foreach ( obj -> classes , iter , cls ) { r_list_foreach ( cls -> methods , iter2 , sym ) { const char * comma = iter2 -> p ? """" : """" ; r_cons_printf ( ""%s0x%"" PFMT64d , comma , sym -> vaddr ) ; } if ( ! r_list_empty ( cls -> methods ) ) { r_cons_newline ( ) ; } } } else { RBININFO ( ""classes"" , R_CORE_BIN_ACC_CLASSES , NULL , r_list_length ( obj -> classes ) ) ; } } } } else { RBinObject * obj = r_bin_cur_object ( core -> bin ) ; int len = obj ? r_list_length ( obj -> classes ) : 0 ; RBININFO ( ""classes"" , R_CORE_BIN_ACC_CLASSES , NULL , len ) ; } break ; case 'D' : if ( input [ 1 ] != '' || ! demangle ( core , input + 2 ) ) { eprintf ( ""|Usage:iDlangsymbolname\\n"" ) ; } return 0 ; case 'a' : switch ( mode ) { case R_CORE_BIN_RADARE : cmd_info ( core , ""iIiecsSmz*"" ) ; break ; case R_CORE_BIN_JSON : cmd_info ( core , ""iIiecsSmzj"" ) ; break ; case R_CORE_BIN_SIMPLE : cmd_info ( core , ""iIiecsSmzq"" ) ; break ; default : cmd_info ( core , ""IiEecsSmz"" ) ; break ; } break ; case '?' : { const char * help_message [ ] = { ""Usage:i"" , """" , ""Getinfofromopenedfile(seerabin2\'smanpage)"" , ""Outputmode:"" , """" , """" , ""\'*\'"" , """" , ""Outputinradarecommands"" , ""\'j\'"" , """" , ""Outputinjson"" , ""\'q\'"" , """" , ""Simplequietoutput"" , ""Actions:"" , """" , """" , ""i|ij"" , """" , ""Showinfoofcurrentfile(inJSON)"" , ""iA"" , """" , ""Listarchs"" , ""ia"" , """" , ""Showallinfo(imports,exports,sections..)"" , ""ib"" , """" , ""Reloadthecurrentbufferforsettingofthebin(useonceonly)"" , ""ic"" , """" , ""Listclasses,methodsandfields"" , ""iC"" , """" , ""Showsignatureinfo(entitlements,...)"" , ""id"" , """" , ""Debuginformation(sourcelines)"" , ""iD"" , ""langsym"" , ""demanglesymbolnameforgivenlanguage"" , ""ie"" , """" , ""Entrypoint"" , ""iE"" , """" , ""Exports(globalsymbols)"" , ""ih"" , """" , ""Headers(aliasforiH)"" , ""iHH"" , """" , ""VerboseHeadersinrawtext"" , ""ii"" , """" , ""Imports"" , ""iI"" , """" , ""Binaryinfo"" , ""ik"" , ""[query]"" , ""Key-valuedatabasefromRBinObject"" , ""il"" , """" , ""Libraries"" , ""iL"" , ""[plugin]"" , ""ListallRBinpluginsloadedorplugindetails"" , ""im"" , """" , ""Showinfoaboutpredefinedmemoryallocation"" , ""iM"" , """" , ""Showmainaddress"" , ""io"" , ""[file]"" , ""Loadinfofromfile(orlastopened)usebin.baddr"" , ""ir"" , """" , ""Relocs"" , ""iR"" , """" , ""Resources"" , ""is"" , """" , ""Symbols"" , ""iS"" , ""[entropy,sha1]"" , ""Sections(choosewhichhashalgorithmtouse)"" , ""iV"" , """" , ""Displayfileversioninfo"" , ""iz|izj"" , """" , ""Stringsindatasections(inJSON/Base64)"" , ""izz"" , """" , ""SearchforStringsinthewholebinary"" , ""iZ"" , """" , ""Guesssizeofbinaryprogram"" , NULL } ; r_core_cmd_help ( core , help_message ) ; } goto done ; case '*' : mode = R_CORE_BIN_RADARE ; goto done ; case 'q' : mode = R_CORE_BIN_SIMPLE ; cmd_info_bin ( core , va , mode ) ; goto done ; case 'j' : mode = R_CORE_BIN_JSON ; if ( is_array > 1 ) { mode |= R_CORE_BIN_ARRAY ; } cmd_info_bin ( core , va , mode ) ; goto done ; default : cmd_info_bin ( core , va , mode ) ; break ; } input ++ ; if ( ( * input == 'j' || * input == 'q' ) && ! input [ 1 ] ) { break ; } } done : if ( is_array ) { r_cons_printf ( ""}\\n"" ) ; } if ( newline ) { r_cons_newline ( ) ; } return 0 ; } "," case 'l' : { RBinObject * obj = r_bin_cur_object ( core -> bin ) ; 0 ) ; } case 'i' : { RBinObject * obj = r_bin_cur_object ( core -> bin ) ; 0 ) ; } ",radare@radare2/00e8f205475332d7842d0f0d1481eeab4e83017c,CVE-2017-9761,https://github.com/radare/radare2/commit/00e8f205475332d7842d0f0d1481eeab4e83017c,2017-06-19T16:29Z 258,CWE-119,"CWE-119 static int read_inter_segment_id ( VP9_COMMON * const cm , MACROBLOCKD * const xd , int mi_row , int mi_col , vp9_reader * r ) { struct segmentation * const seg = & cm -> seg ; MB_MODE_INFO * const mbmi = & xd -> mi [ 0 ] -> mbmi ; const BLOCK_SIZE bsize = mbmi -> sb_type ; int predicted_segment_id , segment_id ; if ( ! seg -> enabled ) return 0 ; predicted_segment_id = vp9_get_segment_id ( cm , cm -> last_frame_seg_map , bsize , mi_row , mi_col ) ; if ( ! seg -> update_map ) return predicted_segment_id ; if ( seg -> temporal_update ) { const vp9_prob pred_prob = vp9_get_pred_prob_seg_id ( seg , xd ) ; mbmi -> seg_id_predicted = vp9_read ( r , pred_prob ) ; segment_id = mbmi -> seg_id_predicted ? predicted_segment_id : read_segment_id ( r , seg ) ; } else { segment_id = read_segment_id ( r , seg ) ; } set_segment_id ( cm , bsize , mi_row , mi_col , segment_id ) ; return segment_id ; } "," int mi_col , vpx_reader * r ) -> mbmi ; int predicted_segment_id , segment_id ; const int mi_offset = mi_row * cm -> mi_cols + mi_col ; const int bw = xd -> plane [ 0 ] . n4_w >> 1 ; const int bh = xd -> plane [ 0 ] . n4_h >> 1 ; const int x_mis = MIN ( cm -> mi_cols - mi_col , bw ) ; const int y_mis = MIN ( cm -> mi_rows - mi_row , bh ) ; if ( ; predicted_segment_id = cm -> last_frame_seg_map cm -> last_frame_seg_map ? dec_get_segment_id ( cm , cm -> last_frame_seg_map , mi_offset , x_mis , y_mis ) : 0 ; if ( -> update_map ) { copy_segment_id ( cm , cm -> last_frame_seg_map , cm -> current_frame_seg_map , mi_offset , x_mis , y_mis ) ; return predicted_segment_id ; } ) { const vpx_prob pred_prob = vp9_get_pred_prob_seg_id -> seg_id_predicted = vpx_read ( r , ( cm , mi_offset , x_mis , y_mis , segment_id ) ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 259,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 260,CWE-119,"CWE-119 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 ) { 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_size < 1 || shdr -> sh_size > SIZE_MAX ",radare@radare2/0b973e28166636e0ff1fad80baa0385c9c09c53a,CVE-2017-16357,https://github.com/radare/radare2/commit/0b973e28166636e0ff1fad80baa0385c9c09c53a,2017-11-01T17:29Z 261,CWE-190,"CWE-190 jpc_ms_t * jpc_getms ( jas_stream_t * in , jpc_cstate_t * cstate ) { jpc_ms_t * ms ; jpc_mstabent_t * mstabent ; jas_stream_t * tmpstream ; if ( ! ( ms = jpc_ms_create ( 0 ) ) ) { return 0 ; } if ( jpc_getuint16 ( in , & ms -> id ) || ms -> id < JPC_MS_MIN || ms -> id > JPC_MS_MAX ) { jpc_ms_destroy ( ms ) ; return 0 ; } mstabent = jpc_mstab_lookup ( ms -> id ) ; ms -> ops = & mstabent -> ops ; if ( JPC_MS_HASPARMS ( ms -> id ) ) { if ( jpc_getuint16 ( in , & ms -> len ) || ms -> len < 3 ) { jpc_ms_destroy ( ms ) ; return 0 ; } ms -> len -= 2 ; if ( ! ( tmpstream = jas_stream_memopen ( 0 , 0 ) ) ) { jpc_ms_destroy ( ms ) ; return 0 ; } if ( jas_stream_copy ( tmpstream , in , ms -> len ) || jas_stream_seek ( tmpstream , 0 , SEEK_SET ) < 0 ) { jas_stream_close ( tmpstream ) ; jpc_ms_destroy ( ms ) ; return 0 ; } if ( ( * ms -> ops -> getparms ) ( ms , cstate , tmpstream ) ) { ms -> ops = 0 ; jpc_ms_destroy ( ms ) ; jas_stream_close ( tmpstream ) ; return 0 ; } if ( jas_getdbglevel ( ) > 0 ) { jpc_ms_dump ( ms , stderr ) ; } if ( JAS_CAST ( ulong , jas_stream_tell ( tmpstream ) ) != ms -> len ) { jas_eprintf ( ""warning:trailinggarbageinmarkersegment(%ldbytes)\\n"" , ms -> len - jas_stream_tell ( tmpstream ) ) ; } jas_stream_close ( tmpstream ) ; } else { ms -> len = 0 ; if ( jas_getdbglevel ( ) > 0 ) { jpc_ms_dump ( ms , stderr ) ; } } if ( ms -> id == JPC_MS_SIZ ) { cstate -> numcomps = ms -> parms . siz . numcomps ; } return ms ; } "," ( JAS_CAST ( jas_ulong , jas_stream_tell ( ",mdadams@jasper/d42b2388f7f8e0332c846675133acea151fc557a,CVE-2016-9557,https://github.com/mdadams/jasper/commit/d42b2388f7f8e0332c846675133acea151fc557a,2017-03-23T18:59Z 262,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 263,CWE-399,"CWE-399 void free_pipe_info ( struct pipe_inode_info * pipe ) { int i ; for ( i = 0 ; i < pipe -> buffers ; i ++ ) { struct pipe_buffer * buf = pipe -> bufs + i ; if ( buf -> ops ) buf -> ops -> release ( pipe , buf ) ; } if ( pipe -> tmp_page ) __free_page ( pipe -> tmp_page ) ; kfree ( pipe -> bufs ) ; kfree ( pipe ) ; } "," { int i ; account_pipe_buffers ( pipe , pipe -> buffers , 0 ) ; free_uid ( pipe -> user ) ",torvalds@linux/759c01142a5d0f364a462346168a56de28a80f52,CVE-2016-2847,https://github.com/torvalds/linux/commit/759c01142a5d0f364a462346168a56de28a80f52,2016-04-27T17:59Z 264,CWE-59,"CWE-59 int main ( int argc , char * * argv ) { int fd = xopen ( ""/dev/null"" , O_RDWR ) ; while ( fd < 2 ) fd = xdup ( fd ) ; if ( fd > 2 ) close ( fd ) ; if ( argc < 8 ) { error_msg_and_die ( ""Usage:%sSIGNOCORE_SIZE_LIMITPIDUIDGIDTIMEBINARY_NAME[HOSTNAME]"" , argv [ 0 ] ) ; } if ( strchr ( argv [ 1 ] , '' ) ) { int i ; for ( i = 1 ; argv [ i ] ; i ++ ) { strchrnul ( argv [ i ] , '' ) [ 0 ] = '\\0' ; } } logmode = LOGMODE_JOURNAL ; load_abrt_conf ( ) ; bool setting_MakeCompatCore ; bool setting_SaveBinaryImage ; { map_string_t * settings = new_map_string ( ) ; load_abrt_plugin_conf_file ( ""CCpp.conf"" , settings ) ; const char * value ; value = get_map_string_item_or_NULL ( settings , ""MakeCompatCore"" ) ; setting_MakeCompatCore = value && string_to_bool ( value ) ; value = get_map_string_item_or_NULL ( settings , ""SaveBinaryImage"" ) ; setting_SaveBinaryImage = value && string_to_bool ( value ) ; value = get_map_string_item_or_NULL ( settings , ""VerboseLog"" ) ; if ( value ) g_verbose = xatoi_positive ( value ) ; free_map_string ( settings ) ; } errno = 0 ; const char * signal_str = argv [ 1 ] ; int signal_no = xatoi_positive ( signal_str ) ; off_t ulimit_c = strtoull ( argv [ 2 ] , NULL , 10 ) ; if ( ulimit_c < 0 ) { ulimit_c = ~ ( ( off_t ) 1 << ( sizeof ( off_t ) * 8 - 1 ) ) ; } const char * pid_str = argv [ 3 ] ; pid_t pid = xatoi_positive ( argv [ 3 ] ) ; uid_t uid = xatoi_positive ( argv [ 4 ] ) ; if ( errno || pid <= 0 ) { perror_msg_and_die ( ""PID\'%s\'orlimit\'%s\'isbogus"" , argv [ 3 ] , argv [ 2 ] ) ; } { char * s = xmalloc_fopen_fgetline_fclose ( VAR_RUN ""/abrt/saved_core_pattern"" ) ; if ( s && s [ 0 ] != '|' ) core_basename = s ; else free ( s ) ; } struct utsname uts ; if ( ! argv [ 8 ] ) { uname ( & uts ) ; argv [ 8 ] = uts . nodename ; } char path [ PATH_MAX ] ; int src_fd_binary = - 1 ; char * executable = get_executable ( pid , setting_SaveBinaryImage ? & src_fd_binary : NULL ) ; if ( executable && strstr ( executable , ""/abrt-hook-ccpp"" ) ) { error_msg_and_die ( ""PID%luis\'%s\',notdumpingittoavoidrecursion"" , ( long ) pid , executable ) ; } user_pwd = get_cwd ( pid ) ; log_notice ( ""user_pwd:\'%s\'"" , user_pwd ) ; sprintf ( path , ""/proc/%lu/status"" , ( long ) pid ) ; proc_pid_status = xmalloc_xopen_read_close ( path , NULL ) ; uid_t fsuid = uid ; uid_t tmp_fsuid = get_fsuid ( ) ; int suid_policy = dump_suid_policy ( ) ; if ( tmp_fsuid != uid ) { fsuid = 0 ; if ( suid_policy == DUMP_SUID_UNSAFE ) { fsuid = tmp_fsuid ; } } if ( setting_MakeCompatCore && ulimit_c != 0 ) user_core_fd = open_user_core ( uid , fsuid , pid , & argv [ 1 ] ) ; if ( executable == NULL ) { error_msg ( ""Can\'tread/proc/%lu/exelink"" , ( long ) pid ) ; goto create_user_core ; } const char * signame = NULL ; switch ( signal_no ) { case SIGILL : signame = ""ILL"" ; break ; case SIGFPE : signame = ""FPE"" ; break ; case SIGSEGV : signame = ""SEGV"" ; break ; case SIGBUS : signame = ""BUS"" ; break ; case SIGABRT : signame = ""ABRT"" ; break ; case SIGTRAP : signame = ""TRAP"" ; break ; default : goto create_user_core ; } if ( ! daemon_is_ok ( ) ) { log ( ""abrtdisnotrunning.Ifitcrashed,"" ""/proc/sys/kernel/core_patterncontainsastalevalue,"" ""considerresettingitto\'core\'"" ) ; goto create_user_core ; } if ( g_settings_nMaxCrashReportsSize > 0 ) { if ( low_free_space ( g_settings_nMaxCrashReportsSize , g_settings_dump_location ) ) goto create_user_core ; } snprintf ( path , sizeof ( path ) , ""%s/last-ccpp"" , g_settings_dump_location ) ; if ( check_recent_crash_file ( path , executable ) ) { goto create_user_core ; } const char * last_slash = strrchr ( executable , '/' ) ; if ( last_slash && strncmp ( ++ last_slash , ""abrt"" , 4 ) == 0 ) { snprintf ( path , sizeof ( path ) , ""%s/%s-coredump"" , g_settings_dump_location , last_slash ) ; int abrt_core_fd = xopen3 ( path , O_WRONLY | O_CREAT | O_TRUNC , 0600 ) ; off_t core_size = copyfd_eof ( STDIN_FILENO , abrt_core_fd , COPYFD_SPARSE ) ; if ( core_size < 0 || fsync ( abrt_core_fd ) != 0 ) { unlink ( path ) ; error_msg_and_die ( ""Errorsaving\'%s\'"" , path ) ; } log ( ""Savedcoredumpofpid%lu(%s)to%s(%llubytes)"" , ( long ) pid , executable , path , ( long long ) core_size ) ; return 0 ; } unsigned path_len = snprintf ( path , sizeof ( path ) , ""%s/ccpp-%s-%lu.new"" , g_settings_dump_location , iso_date_string ( NULL ) , ( long ) pid ) ; if ( path_len >= ( sizeof ( path ) - sizeof ( ""/"" FILENAME_COREDUMP ) ) ) { goto create_user_core ; } dd = dd_create ( path , fsuid , DEFAULT_DUMP_DIR_MODE ) ; if ( dd ) { char * rootdir = get_rootdir ( pid ) ; dd_create_basic_files ( dd , fsuid , ( rootdir && strcmp ( rootdir , ""/"" ) != 0 ) ? rootdir : NULL ) ; char source_filename [ sizeof ( ""/proc/%lu/somewhat_long_name"" ) + sizeof ( long ) * 3 ] ; int source_base_ofs = sprintf ( source_filename , ""/proc/%lu/smaps"" , ( long ) pid ) ; source_base_ofs -= strlen ( ""smaps"" ) ; char * dest_filename = concat_path_file ( dd -> dd_dirname , ""also_somewhat_longish_name"" ) ; char * dest_base = strrchr ( dest_filename , '/' ) + 1 ; strcpy ( source_filename + source_base_ofs , ""maps"" ) ; strcpy ( dest_base , FILENAME_MAPS ) ; copy_file_ext ( source_filename , dest_filename , 0640 , dd -> dd_uid , dd -> dd_gid , O_RDONLY , O_WRONLY | O_CREAT | O_TRUNC | O_EXCL ) ; strcpy ( source_filename + source_base_ofs , ""limits"" ) ; strcpy ( dest_base , FILENAME_LIMITS ) ; copy_file_ext ( source_filename , dest_filename , 0640 , dd -> dd_uid , dd -> dd_gid , O_RDONLY , O_WRONLY | O_CREAT | O_TRUNC | O_EXCL ) ; strcpy ( source_filename + source_base_ofs , ""cgroup"" ) ; strcpy ( dest_base , FILENAME_CGROUP ) ; copy_file_ext ( source_filename , dest_filename , 0640 , dd -> dd_uid , dd -> dd_gid , O_RDONLY , O_WRONLY | O_CREAT | O_TRUNC | O_EXCL ) ; strcpy ( dest_base , FILENAME_OPEN_FDS ) ; dump_fd_info ( dest_filename , source_filename , source_base_ofs , dd -> dd_uid , dd -> dd_gid ) ; free ( dest_filename ) ; dd_save_text ( dd , FILENAME_ANALYZER , ""CCpp"" ) ; dd_save_text ( dd , FILENAME_TYPE , ""CCpp"" ) ; dd_save_text ( dd , FILENAME_EXECUTABLE , executable ) ; dd_save_text ( dd , FILENAME_PID , pid_str ) ; dd_save_text ( dd , FILENAME_PROC_PID_STATUS , proc_pid_status ) ; if ( user_pwd ) dd_save_text ( dd , FILENAME_PWD , user_pwd ) ; if ( rootdir ) { if ( strcmp ( rootdir , ""/"" ) != 0 ) dd_save_text ( dd , FILENAME_ROOTDIR , rootdir ) ; } char * reason = xasprintf ( ""%skilledbySIG%s"" , last_slash , signame ? signame : signal_str ) ; dd_save_text ( dd , FILENAME_REASON , reason ) ; free ( reason ) ; char * cmdline = get_cmdline ( pid ) ; dd_save_text ( dd , FILENAME_CMDLINE , cmdline ? : """" ) ; free ( cmdline ) ; char * environ = get_environ ( pid ) ; dd_save_text ( dd , FILENAME_ENVIRON , environ ? : """" ) ; free ( environ ) ; char * fips_enabled = xmalloc_fopen_fgetline_fclose ( ""/proc/sys/crypto/fips_enabled"" ) ; if ( fips_enabled ) { if ( strcmp ( fips_enabled , ""0"" ) != 0 ) dd_save_text ( dd , ""fips_enabled"" , fips_enabled ) ; free ( fips_enabled ) ; } dd_save_text ( dd , FILENAME_ABRT_VERSION , VERSION ) ; if ( src_fd_binary > 0 ) { strcpy ( path + path_len , ""/"" FILENAME_BINARY ) ; int dst_fd = create_or_die ( path ) ; off_t sz = copyfd_eof ( src_fd_binary , dst_fd , COPYFD_SPARSE ) ; if ( fsync ( dst_fd ) != 0 || close ( dst_fd ) != 0 || sz < 0 ) { dd_delete ( dd ) ; error_msg_and_die ( ""Errorsaving\'%s\'"" , path ) ; } close ( src_fd_binary ) ; } strcpy ( path + path_len , ""/"" FILENAME_COREDUMP ) ; int abrt_core_fd = create_or_die ( path ) ; off_t core_size = copyfd_sparse ( STDIN_FILENO , abrt_core_fd , user_core_fd , ulimit_c ) ; if ( fsync ( abrt_core_fd ) != 0 || close ( abrt_core_fd ) != 0 || core_size < 0 ) { unlink ( path ) ; dd_delete ( dd ) ; if ( user_core_fd >= 0 ) { xchdir ( user_pwd ) ; unlink ( core_basename ) ; } error_msg_and_die ( ""Errorwriting\'%s\'"" , path ) ; } if ( user_core_fd >= 0 && ( fsync ( user_core_fd ) != 0 || close ( user_core_fd ) != 0 || ( ulimit_c == 0 || core_size > ulimit_c ) ) ) { xchdir ( user_pwd ) ; unlink ( core_basename ) ; } # if 0 { char * java_log = xasprintf ( ""/tmp/jvm-%lu/hs_error.log"" , ( long ) pid ) ; int src_fd = open ( java_log , O_RDONLY ) ; free ( java_log ) ; if ( src_fd < 0 ) { java_log = xasprintf ( ""%s/hs_err_pid%lu.log"" , user_pwd , ( long ) pid ) ; src_fd = open ( java_log , O_RDONLY ) ; free ( java_log ) ; } if ( src_fd >= 0 ) { strcpy ( path + path_len , ""/hs_err.log"" ) ; int dst_fd = create_or_die ( path ) ; off_t sz = copyfd_eof ( src_fd , dst_fd , COPYFD_SPARSE ) ; if ( close ( dst_fd ) != 0 || sz < 0 ) { dd_delete ( dd ) ; error_msg_and_die ( ""Errorsaving\'%s\'"" , path ) ; } close ( src_fd ) ; } } # endif dd_close ( dd ) ; path [ path_len ] = '\\0' ; char * newpath = xstrndup ( path , path_len - ( sizeof ( "".new"" ) - 1 ) ) ; if ( rename ( path , newpath ) == 0 ) strcpy ( path , newpath ) ; free ( newpath ) ; log ( ""Savedcoredumpofpid%lu(%s)to%s(%llubytes)"" , ( long ) pid , executable , path , ( long long ) core_size ) ; notify_new_path ( path ) ; if ( g_settings_nMaxCrashReportsSize > 0 ) { unsigned maxsize = g_settings_nMaxCrashReportsSize + g_settings_nMaxCrashReportsSize / 4 ; maxsize |= 63 ; trim_problem_dirs ( g_settings_dump_location , maxsize * ( double ) ( 1024 * 1024 ) , path ) ; } free ( rootdir ) ; return 0 ; } create_user_core : if ( user_core_fd >= 0 ) { off_t core_size = copyfd_size ( STDIN_FILENO , user_core_fd , ulimit_c , COPYFD_SPARSE ) ; if ( fsync ( user_core_fd ) != 0 || close ( user_core_fd ) != 0 || core_size < 0 ) { perror_msg ( ""Errorwriting\'%s\'"" , full_core_basename ) ; xchdir ( user_pwd ) ; unlink ( core_basename ) ; return 1 ; } if ( ulimit_c == 0 || core_size > ulimit_c ) { xchdir ( user_pwd ) ; unlink ( core_basename ) ; return 1 ; } log ( ""Savedcoredumpofpid%luto%s(%llubytes)"" , ( long ) pid , full_core_basename , ( long long ) core_size ) ; } return 0 ; } "," , fsuid , NULL ) ; ",abrt@abrt/4f2c1ddd3e3b81d2d5146b883115371f1cada9f9,CVE-2015-3315,https://github.com/abrt/abrt/commit/4f2c1ddd3e3b81d2d5146b883115371f1cada9f9,2017-06-26T15:29Z 265,CWE-787,"CWE-787 double GetGPMFSampleRate ( size_t handle , uint32_t fourcc , uint32_t flags ) { mp4object * mp4 = ( mp4object * ) handle ; if ( mp4 == NULL ) return 0.0 ; GPMF_stream metadata_stream , * ms = & metadata_stream ; uint32_t teststart = 0 ; uint32_t testend = mp4 -> indexcount ; double rate = 0.0 ; if ( mp4 -> indexcount < 1 ) return 0.0 ; if ( mp4 -> indexcount > 3 ) { teststart ++ ; testend -- ; } uint32_t * payload = GetPayload ( handle , NULL , teststart ) ; uint32_t payloadsize = GetPayloadSize ( handle , teststart ) ; int32_t ret = GPMF_Init ( ms , payload , payloadsize ) ; if ( ret != GPMF_OK ) goto cleanup ; { uint32_t startsamples = 0 ; uint32_t endsamples = 0 ; uint32_t missing_samples = 0 ; while ( ret == GPMF_OK && GPMF_OK != GPMF_FindNext ( ms , fourcc , GPMF_RECURSE_LEVELS ) ) { missing_samples = 1 ; teststart ++ ; payload = GetPayload ( handle , payload , teststart ) ; payloadsize = GetPayloadSize ( handle , teststart ) ; ret = GPMF_Init ( ms , payload , payloadsize ) ; } if ( missing_samples ) { teststart ++ ; payload = GetPayload ( handle , payload , teststart ) ; payloadsize = GetPayloadSize ( handle , teststart ) ; ret = GPMF_Init ( ms , payload , payloadsize ) ; } if ( ret == GPMF_OK ) { uint32_t samples = GPMF_Repeat ( ms ) ; GPMF_stream find_stream ; GPMF_CopyState ( ms , & find_stream ) ; if ( ! ( flags & GPMF_SAMPLE_RATE_PRECISE ) && GPMF_OK == GPMF_FindPrev ( & find_stream , GPMF_KEY_TOTAL_SAMPLES , GPMF_CURRENT_LEVEL ) ) { startsamples = BYTESWAP32 ( * ( uint32_t * ) GPMF_RawData ( & find_stream ) ) - samples ; payload = GetPayload ( handle , payload , testend ) ; payloadsize = GetPayloadSize ( handle , testend ) ; ret = GPMF_Init ( ms , payload , payloadsize ) ; if ( ret != GPMF_OK ) goto cleanup ; if ( GPMF_OK == GPMF_FindNext ( ms , fourcc , GPMF_RECURSE_LEVELS ) ) { GPMF_CopyState ( ms , & find_stream ) ; if ( GPMF_OK == GPMF_FindPrev ( & find_stream , GPMF_KEY_TOTAL_SAMPLES , GPMF_CURRENT_LEVEL ) ) { endsamples = BYTESWAP32 ( * ( uint32_t * ) GPMF_RawData ( & find_stream ) ) ; rate = ( double ) ( endsamples - startsamples ) / ( mp4 -> metadatalength * ( ( double ) ( testend - teststart + 1 ) ) / ( double ) mp4 -> indexcount ) ; goto cleanup ; } } rate = ( double ) ( samples ) / ( mp4 -> metadatalength * ( ( double ) ( testend - teststart + 1 ) ) / ( double ) mp4 -> indexcount ) ; } else { uint32_t payloadpos = 0 , payloadcount = 0 ; double slope , top = 0.0 , bot = 0.0 , meanX = 0 , meanY = 0 ; uint32_t * repeatarray = malloc ( mp4 -> indexcount * 4 + 4 ) ; memset ( repeatarray , 0 , mp4 -> indexcount * 4 + 4 ) ; samples = 0 ; for ( payloadpos = teststart ; payloadpos < testend ; payloadcount ++ , payloadpos ++ ) { payload = GetPayload ( handle , payload , payloadpos ) ; payloadsize = GetPayloadSize ( handle , payloadpos ) ; ret = GPMF_Init ( ms , payload , payloadsize ) ; if ( ret != GPMF_OK ) goto cleanup ; if ( GPMF_OK == GPMF_FindNext ( ms , fourcc , GPMF_RECURSE_LEVELS ) ) { GPMF_stream find_stream2 ; GPMF_CopyState ( ms , & find_stream2 ) ; if ( GPMF_OK == GPMF_FindNext ( & find_stream2 , fourcc , GPMF_CURRENT_LEVEL ) ) { if ( repeatarray ) { float in , out ; do { samples ++ ; } while ( GPMF_OK == GPMF_FindNext ( ms , fourcc , GPMF_CURRENT_LEVEL ) ) ; repeatarray [ payloadpos ] = samples ; meanY += ( double ) samples ; GetPayloadTime ( handle , payloadpos , & in , & out ) ; meanX += out ; } } else { uint32_t repeat = GPMF_Repeat ( ms ) ; samples += repeat ; if ( repeatarray ) { float in , out ; repeatarray [ payloadpos ] = samples ; meanY += ( double ) samples ; GetPayloadTime ( handle , payloadpos , & in , & out ) ; meanX += out ; } } } } if ( repeatarray ) { meanY /= ( double ) payloadcount ; meanX /= ( double ) payloadcount ; for ( payloadpos = teststart ; payloadpos < testend ; payloadpos ++ ) { float in , out ; GetPayloadTime ( handle , payloadpos , & in , & out ) ; top += ( ( double ) out - meanX ) * ( ( double ) repeatarray [ payloadpos ] - meanY ) ; bot += ( ( double ) out - meanX ) * ( ( double ) out - meanX ) ; } slope = top / bot ; # if 0 { double intercept ; intercept = meanY - slope * meanX ; printf ( ""%c%c%c%cstartoffset=%f(%.3fms)\\n"" , PRINTF_4CC ( fourcc ) , intercept , 1000.0 * intercept / slope ) ; } # endif rate = slope ; } else { rate = ( double ) ( samples ) / ( mp4 -> metadatalength * ( ( double ) ( testend - teststart + 1 ) ) / ( double ) mp4 -> indexcount ) ; } free ( repeatarray ) ; goto cleanup ; } } } cleanup : if ( payload ) { FreePayload ( payload ) ; payload = NULL ; } return rate ; } "," , uint32_t flags , double * firstsampletime , double * lastsampletime rate = 0.0 ; uint32_t * payload ; uint32_t payloadsize ; int32_t ret return 0.0 ; payload = GetPayload ( handle , NULL , teststart ) ; payloadsize = GetPayloadSize ( handle , teststart ) ; ret = GPMF_Init ( ms , payload , payloadsize ) ; if ( ret != GPMF_OK ) goto cleanup ; { uint64_t minimumtimestamp = 0 ; uint64_t starttimestamp = 0 ; uint64_t endtimestamp = 0 ; uint32_t startsamples = 0 ; uint32_t endsamples = 0 ; double intercept = 0.0 ; while ( teststart < mp4 -> indexcount mp4 -> indexcount && ret == GPMF_OK && GPMF_OK != GPMF_FindNext ( ms , fourcc , GPMF_RECURSE_LEVELS ) ) { teststart teststart ++ ; payload = GetPayload ( handle , payload , teststart ) ; payloadsize = GetPayloadSize ( handle , teststart ) ; ret = GPMF_Init ( ms , payload , payloadsize ) ; } if ( ret == GPMF_OK && payload ) { uint32_t samples = GPMF_PayloadSampleCount ( ms ) ; GPMF_stream find_stream ; GPMF_CopyState ( ms , & find_stream ) ; if ( GPMF_OK == GPMF_FindPrev ( & find_stream , GPMF_KEY_TOTAL_SAMPLES , GPMF_CURRENT_LEVEL ) ) startsamples = BYTESWAP32 ( * ( uint32_t * ) GPMF_RawData ( & find_stream ) ) - samples ; GPMF_CopyState ( ms , & find_stream ) ; if ( GPMF_OK == GPMF_FindPrev ( & find_stream , GPMF_KEY_TIME_STAMP , GPMF_CURRENT_LEVEL ) ) starttimestamp = BYTESWAP64 ( * ( uint64_t * ) GPMF_RawData ( & find_stream ) ) ; if ( starttimestamp ) { GPMF_stream any_stream ; GPMF_Init ( & any_stream , payload , payloadsize ) ; minimumtimestamp = starttimestamp ; while ( GPMF_OK == GPMF_FindNext ( & any_stream , GPMF_KEY_TIME_STAMP , GPMF_RECURSE_LEVELS ) ) { uint64_t timestamp = BYTESWAP64 ( * ( uint64_t * ) GPMF_RawData ( & any_stream ) ) ; if ( timestamp < minimumtimestamp ) minimumtimestamp = timestamp ; } } testend = mp4 -> indexcount ; do { testend -- ; payload = GetPayload ( handle , payload , testend ) ; payloadsize = GetPayloadSize ( handle , testend ) ; ret = GPMF_Init payloadsize ) ; } while ( testend > 0 && GPMF_OK != GPMF_RECURSE_LEVELS ) ) ; GPMF_CopyState ( ms , & find_stream ) ; if ( GPMF_OK == GPMF_FindPrev ( & find_stream , GPMF_KEY_TOTAL_SAMPLES , GPMF_CURRENT_LEVEL ) ) endsamples = BYTESWAP32 ( * ( uint32_t * ) GPMF_RawData ( & find_stream ) ) ; else { uint32_t i ; for ( i = teststart ; i <= testend ; i ++ ) { payload = GetPayload , payload , i ) ; payloadsize ( handle , i ) ; if ( GPMF_OK == GPMF_Init ( ms , payloadsize ) ) if ( GPMF_OK == GPMF_FindNext ( ms , fourcc , GPMF_RECURSE_LEVELS ) ) endsamples += GPMF_PayloadSampleCount ( ms ) ; } } if ( starttimestamp != 0 ) { uint32_t ) { uint32_t last_samples = GPMF_PayloadSampleCount ( ms ) ; uint32_t totaltimestamped_samples = endsamples - last_samples - startsamples ; double time_stamp_scale = 1000000000.0 ; GPMF_CopyState ( ms , & find_stream ) ; if ( GPMF_OK == GPMF_FindPrev ( & find_stream , GPMF_KEY_TIME_STAMP , GPMF_CURRENT_LEVEL ) ) endtimestamp = BYTESWAP64 ( * ( uint64_t * ) GPMF_RawData ( & find_stream ( & find_stream ) ) ; if ( endtimestamp ) { double approxrate = 0.0 ; if ( endsamples > startsamples ) approxrate = ( double indexcount ) ; if ( approxrate == 0.0 ) approxrate = ( double indexcount ) ; while ( time_stamp_scale >= 1 ) { rate = ( double ) ( totaltimestamped_samples ) / ( ( double ) ( endtimestamp - starttimestamp ) / time_stamp_scale ) ; if ( rate * 0.9 < approxrate && approxrate < rate * 1.1 ) break ; time_stamp_scale *= 0.1 ; } if ( time_stamp_scale < 1.0 ) rate = 0.0 ; intercept = ( ( ( double ) minimumtimestamp - ( double ) starttimestamp ) / time_stamp_scale ) * rate ; } } if ( rate == 0.0 ) { if ( ! ( flags & GPMF_SAMPLE_RATE_PRECISE ) ) { if ( endsamples > startsamples ) rate = ( double ) ( endsamples - startsamples ) / ( mp4 -> metadatalength * ( ( double ) ( testend - teststart + 1 ) ) / ( double ) mp4 -> indexcount mp4 -> indexcount ) ; if ( rate == 0.0 ) rate = ( double ) ( samples ) / ( mp4 -> metadatalength * ( ( double ) ( testend - teststart + 1 ) ) / ( double ) mp4 -> indexcount ) ; double in , out ; if ( GPMF_OK == GetPayloadTime ( handle , teststart , & in , & out ) ) intercept = ( double ) - in * rate ; } else { uint32_t payloadpos = 0 , payloadcount = 0 ; double slope , top = 0.0 , bot = 0.0 , meanX = 0 , meanY = 0 ; uint32_t * repeatarray = malloc ( mp4 -> indexcount teststart ; payloadpos <= testend ; payloadpos ++ ) { payload = GetPayload ( handle , payload , payloadpos ) ; payloadsize = GetPayloadSize ( handle , payloadpos ) ; ret = GPMF_Init ( ms , payload , payloadsize ) ; if ( ret != GPMF_OK ) goto cleanup ; if ( GPMF_OK == GPMF_FindNext ( ms , fourcc , GPMF_RECURSE_LEVELS ) ) { GPMF_stream find_stream2 ; GPMF_CopyState ( ms , & find_stream2 ) ; payloadcount ++ ; if ( == GPMF_FindNext ( & find_stream2 , fourcc , , fourcc , GPMF_CURRENT_LEVEL ) ) repeatarray ) { double in , out ) samples ; if ( GPMF_OK == & out ) ) meanX += out uint32_t repeat = GPMF_PayloadSampleCount ( ms ) repeatarray ) { double in , out ) samples ; if ( GPMF_OK == & out ) ) meanX += out } } } else { repeatarray [ payloadpos [ payloadpos ] = 0 ; } } if ( repeatarray ) { meanY /= ( double ) payloadcount ; meanX /= ( double ) payloadcount ; for ( payloadpos = teststart ; payloadpos <= testend ; payloadpos ++ ) { double in , out ; if ( repeatarray [ payloadpos ] && GPMF_OK == GetPayloadTime ( handle , payloadpos , & in , & out ) ) { top += ( ( double ) out - meanX ) * ( ( double ) repeatarray [ payloadpos ] meanX ) ; } / bot ; rate = slope ; intercept = meanY - slope * meanX ; # if 0 printf ( ""%c%c%c%cstartoffset=%f(%.3fms)rate=%f\\n"" , PRINTF_4CC ( intercept / slope , rate ) ; printf ( ""%c%c%c%cfirstsampleattime%.3fms\\n"" , PRINTF_4CC ( fourcc ) , - 1000.0 * intercept / slope ) ; # endif } else { repeatarray ) ; } } if ( firstsampletime && lastsampletime ) { uint32_t endpayload = mp4 -> indexcount ; do { endpayload -- ; payload = GetPayload ( handle , payload , endpayload ) ; payloadsize = GetPayloadSize ( handle , endpayload ) ; ret = GPMF_Init ( ms , payload , payloadsize ) ; } while ( endpayload > 0 && GPMF_OK != GPMF_FindNext ( ms , fourcc , GPMF_RECURSE_LEVELS ) ) ; if ( endpayload > 0 && ret == GPMF_OK ) { uint32_t totalsamples = endsamples - startsamples ; float timo = 0.0 ; GPMF_CopyState ( ms , & find_stream ) ; if ( GPMF_OK == GPMF_FindPrev ( & find_stream , GPMF_KEY_TIME_OFFSET , GPMF_CURRENT_LEVEL ) ) GPMF_FormattedData ( & find_stream , & timo , 4 , 0 , 1 ) ; double first , last ; first = - intercept / rate - timo ; last = first + ( double ) totalsamples / rate ; if ( firstsampletime ) * firstsampletime = first ; if ( lastsampletime ) * lastsampletime = last ; } } } } ( payload ) FreePayload ( payload = NULL ; return rate ; ",gopro@gpmf-parser/341f12cd5b97ab419e53853ca00176457c9f1681,CVE-2019-15148,https://github.com/gopro/gpmf-parser/commit/341f12cd5b97ab419e53853ca00176457c9f1681,2019-08-18T19:15Z 266,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 267,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 268,CWE-119,"CWE-119 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 ) { 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 ; } 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 ; } "," ip6t_entry ) >= limit || ( unsigned char * ) e + e -> next_offset > ",torvalds@linux/6e94e0cfb0887e4013b3b930fa6ab1fe6bb6ba91,CVE-2016-4998,https://github.com/torvalds/linux/commit/6e94e0cfb0887e4013b3b930fa6ab1fe6bb6ba91,2016-07-03T21:59Z 269,CWE-190,"CWE-190 static void * zend_mm_realloc_heap ( zend_mm_heap * heap , void * ptr , size_t size , size_t copy_size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC ) { size_t page_offset ; size_t old_size ; size_t new_size ; void * ret ; # if ZEND_DEBUG size_t real_size ; zend_mm_debug_info * dbg ; # endif page_offset = ZEND_MM_ALIGNED_OFFSET ( ptr , ZEND_MM_CHUNK_SIZE ) ; if ( UNEXPECTED ( page_offset == 0 ) ) { if ( UNEXPECTED ( ptr == NULL ) ) { return zend_mm_alloc_heap ( heap , size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC ) ; } old_size = zend_mm_get_huge_block_size ( heap , ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC ) ; # if ZEND_DEBUG real_size = size ; size = ZEND_MM_ALIGNED_SIZE ( size ) + ZEND_MM_ALIGNED_SIZE ( sizeof ( zend_mm_debug_info ) ) ; # endif if ( size > ZEND_MM_MAX_LARGE_SIZE ) { # if ZEND_DEBUG size = real_size ; # endif # ifdef ZEND_WIN32 new_size = ZEND_MM_ALIGNED_SIZE_EX ( size , MAX ( REAL_PAGE_SIZE , ZEND_MM_CHUNK_SIZE ) ) ; # else new_size = ZEND_MM_ALIGNED_SIZE_EX ( size , REAL_PAGE_SIZE ) ; # endif if ( new_size == old_size ) { # if ZEND_DEBUG zend_mm_change_huge_block_size ( heap , ptr , new_size , real_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC ) ; # else zend_mm_change_huge_block_size ( heap , ptr , new_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC ) ; # endif return ptr ; } else if ( new_size < old_size ) { if ( zend_mm_chunk_truncate ( heap , ptr , old_size , new_size ) ) { # if ZEND_MM_STAT || ZEND_MM_LIMIT heap -> real_size -= old_size - new_size ; # endif # if ZEND_MM_STAT heap -> size -= old_size - new_size ; # endif # if ZEND_DEBUG zend_mm_change_huge_block_size ( heap , ptr , new_size , real_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC ) ; # else zend_mm_change_huge_block_size ( heap , ptr , new_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC ) ; # endif return ptr ; } } else { # if ZEND_MM_LIMIT if ( UNEXPECTED ( heap -> real_size + ( new_size - old_size ) > heap -> limit ) ) { if ( zend_mm_gc ( heap ) && heap -> real_size + ( new_size - old_size ) <= heap -> limit ) { } else if ( heap -> overflow == 0 ) { # if ZEND_DEBUG zend_mm_safe_error ( heap , ""Allowedmemorysizeof%zubytesexhaustedat%s:%d(triedtoallocate%zubytes)"" , heap -> limit , __zend_filename , __zend_lineno , size ) ; # else zend_mm_safe_error ( heap , ""Allowedmemorysizeof%zubytesexhausted(triedtoallocate%zubytes)"" , heap -> limit , size ) ; # endif return NULL ; } } # endif if ( zend_mm_chunk_extend ( heap , ptr , old_size , new_size ) ) { # if ZEND_MM_STAT || ZEND_MM_LIMIT heap -> real_size += new_size - old_size ; # endif # if ZEND_MM_STAT heap -> real_peak = MAX ( heap -> real_peak , heap -> real_size ) ; heap -> size += new_size - old_size ; heap -> peak = MAX ( heap -> peak , heap -> size ) ; # endif # if ZEND_DEBUG zend_mm_change_huge_block_size ( heap , ptr , new_size , real_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC ) ; # else zend_mm_change_huge_block_size ( heap , ptr , new_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC ) ; # endif return ptr ; } } } } else { zend_mm_chunk * chunk = ( zend_mm_chunk * ) ZEND_MM_ALIGNED_BASE ( ptr , ZEND_MM_CHUNK_SIZE ) ; int page_num = ( int ) ( page_offset / ZEND_MM_PAGE_SIZE ) ; zend_mm_page_info info = chunk -> map [ page_num ] ; # if ZEND_DEBUG size_t real_size = size ; size = ZEND_MM_ALIGNED_SIZE ( size ) + ZEND_MM_ALIGNED_SIZE ( sizeof ( zend_mm_debug_info ) ) ; # endif ZEND_MM_CHECK ( chunk -> heap == heap , ""zend_mm_heapcorrupted"" ) ; if ( info & ZEND_MM_IS_SRUN ) { int old_bin_num , bin_num ; old_bin_num = ZEND_MM_SRUN_BIN_NUM ( info ) ; old_size = bin_data_size [ old_bin_num ] ; bin_num = ZEND_MM_SMALL_SIZE_TO_BIN ( size ) ; if ( old_bin_num == bin_num ) { # if ZEND_DEBUG dbg = zend_mm_get_debug_info ( heap , ptr ) ; dbg -> size = real_size ; dbg -> filename = __zend_filename ; dbg -> orig_filename = __zend_orig_filename ; dbg -> lineno = __zend_lineno ; dbg -> orig_lineno = __zend_orig_lineno ; # endif return ptr ; } } else { ZEND_MM_CHECK ( ZEND_MM_ALIGNED_OFFSET ( page_offset , ZEND_MM_PAGE_SIZE ) == 0 , ""zend_mm_heapcorrupted"" ) ; old_size = ZEND_MM_LRUN_PAGES ( info ) * ZEND_MM_PAGE_SIZE ; if ( size > ZEND_MM_MAX_SMALL_SIZE && size <= ZEND_MM_MAX_LARGE_SIZE ) { new_size = ZEND_MM_ALIGNED_SIZE_EX ( size , ZEND_MM_PAGE_SIZE ) ; if ( new_size == old_size ) { # if ZEND_DEBUG dbg = zend_mm_get_debug_info ( heap , ptr ) ; dbg -> size = real_size ; dbg -> filename = __zend_filename ; dbg -> orig_filename = __zend_orig_filename ; dbg -> lineno = __zend_lineno ; dbg -> orig_lineno = __zend_orig_lineno ; # endif return ptr ; } else if ( new_size < old_size ) { int new_pages_count = ( int ) ( new_size / ZEND_MM_PAGE_SIZE ) ; int rest_pages_count = ( int ) ( ( old_size - new_size ) / ZEND_MM_PAGE_SIZE ) ; # if ZEND_MM_STAT heap -> size -= rest_pages_count * ZEND_MM_PAGE_SIZE ; # endif chunk -> map [ page_num ] = ZEND_MM_LRUN ( new_pages_count ) ; chunk -> free_pages += rest_pages_count ; zend_mm_bitset_reset_range ( chunk -> free_map , page_num + new_pages_count , rest_pages_count ) ; # if ZEND_DEBUG dbg = zend_mm_get_debug_info ( heap , ptr ) ; dbg -> size = real_size ; dbg -> filename = __zend_filename ; dbg -> orig_filename = __zend_orig_filename ; dbg -> lineno = __zend_lineno ; dbg -> orig_lineno = __zend_orig_lineno ; # endif return ptr ; } else { int new_pages_count = ( int ) ( new_size / ZEND_MM_PAGE_SIZE ) ; int old_pages_count = ( int ) ( old_size / ZEND_MM_PAGE_SIZE ) ; if ( page_num + new_pages_count <= ZEND_MM_PAGES && zend_mm_bitset_is_free_range ( chunk -> free_map , page_num + old_pages_count , new_pages_count - old_pages_count ) ) { # if ZEND_MM_STAT do { size_t size = heap -> size + ( new_size - old_size ) ; size_t peak = MAX ( heap -> peak , size ) ; heap -> size = size ; heap -> peak = peak ; } while ( 0 ) ; # endif chunk -> free_pages -= new_pages_count - old_pages_count ; zend_mm_bitset_set_range ( chunk -> free_map , page_num + old_pages_count , new_pages_count - old_pages_count ) ; chunk -> map [ page_num ] = ZEND_MM_LRUN ( new_pages_count ) ; # if ZEND_DEBUG dbg = zend_mm_get_debug_info ( heap , ptr ) ; dbg -> size = real_size ; dbg -> filename = __zend_filename ; dbg -> orig_filename = __zend_orig_filename ; dbg -> lineno = __zend_lineno ; dbg -> orig_lineno = __zend_orig_lineno ; # endif return ptr ; } } } } # if ZEND_DEBUG size = real_size ; # endif } # if ZEND_MM_STAT do { size_t orig_peak = heap -> peak ; size_t orig_real_peak = heap -> real_peak ; # endif ret = zend_mm_alloc_heap ( heap , size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC ) ; memcpy ( ret , ptr , MIN ( old_size , copy_size ) ) ; zend_mm_free_heap ( heap , ptr ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC ) ; # if ZEND_MM_STAT heap -> peak = MAX ( orig_peak , heap -> size ) ; heap -> real_peak = MAX ( orig_real_peak , heap -> real_size ) ; } while ( 0 ) ; # endif return ret ; } "," { int old_bin_num = ZEND_MM_SRUN_BIN_NUM ( old_bin_num ] ; if ( size <= ZEND_MM_MAX_SMALL_SIZE ) { int return ptr ; } ",php@php-src/c2a13ced4272f2e65d2773e2ea6ca11c1ce4a911,CVE-2016-7133,https://github.com/php/php-src/commit/c2a13ced4272f2e65d2773e2ea6ca11c1ce4a911,2016-09-12T01:59Z 270,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 271,CWE-264,"CWE-264 static int em_ret_far ( struct x86_emulate_ctxt * ctxt ) { int rc ; unsigned long cs ; int cpl = ctxt -> ops -> cpl ( ctxt ) ; rc = emulate_pop ( ctxt , & ctxt -> _eip , ctxt -> op_bytes ) ; if ( rc != X86EMUL_CONTINUE ) return rc ; if ( ctxt -> op_bytes == 4 ) ctxt -> _eip = ( u32 ) ctxt -> _eip ; rc = emulate_pop ( ctxt , & cs , ctxt -> op_bytes ) ; if ( rc != X86EMUL_CONTINUE ) return rc ; if ( ctxt -> mode >= X86EMUL_MODE_PROT16 && ( cs & 3 ) > cpl ) return X86EMUL_UNHANDLEABLE ; rc = load_segment_descriptor ( ctxt , ( u16 ) cs , VCPU_SREG_CS ) ; return rc ; } "," ; unsigned long eip , cs ; u16 old_cs ; int cpl ctxt ) ; struct desc_struct old_desc , new_desc ; const struct x86_emulate_ops * ops = ctxt -> ops ; if ( ctxt -> mode == X86EMUL_MODE_PROT64 ) ops -> get_segment ( ctxt , & old_cs , & old_desc , NULL , VCPU_SREG_CS ) ; ctxt , & eip , ctxt -> ) return rc ; rc = ; rc = __load_segment_descriptor ( ctxt , cs , VCPU_SREG_CS , 0 , false , & new_desc ) ; if ( rc != X86EMUL_CONTINUE ) return rc ; rc = assign_eip_far ( ctxt , eip , new_desc . l ) ; if ( rc != X86EMUL_CONTINUE ) { WARN_ON ( ! ctxt -> mode != X86EMUL_MODE_PROT64 ) ; 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 272,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 273,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 274,CWE-200,"CWE-200 static int pptp_bind ( struct socket * sock , struct sockaddr * uservaddr , int sockaddr_len ) { 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 ; int error = 0 ; lock_sock ( sk ) ; opt -> src_addr = sp -> sa_addr . pptp ; if ( add_chan ( po ) ) error = - EBUSY ; release_sock ( sk ) ; return error ; } "," = 0 ; if ( sockaddr_len < sizeof ( struct sockaddr_pppox ) ) return - EINVAL ; ",torvalds@linux/09ccfd238e5a0e670d8178cf50180ea81ae09ae1,CVE-2015-8569,https://github.com/torvalds/linux/commit/09ccfd238e5a0e670d8178cf50180ea81ae09ae1,2015-12-28T11:59Z 275,CWE-772,"CWE-772 generic_ret * setv4key_principal_2_svc ( setv4key_arg * arg , struct svc_req * rqstp ) { static generic_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_generic_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 ( ! ( CHANGEPW_SERVICE ( rqstp ) ) && kadm5int_acl_check ( handle -> context , rqst2name ( rqstp ) , ACL_SETKEY , arg -> princ , NULL ) ) { ret . code = kadm5_setv4key_principal ( ( void * ) handle , arg -> princ , arg -> keyblock ) ; } else { log_unauth ( ""kadm5_setv4key_principal"" , prime_arg , & client_name , & service_name , rqstp ) ; ret . code = KADM5_AUTH_SETKEY ; } if ( ret . code != KADM5_AUTH_SETKEY ) { if ( ret . code != 0 ) errmsg = krb5_get_error_message ( handle -> context , ret . code ) ; log_done ( ""kadm5_setv4key_principal"" , 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 276,CWE-119,"CWE-119 static int psf_close ( SF_PRIVATE * psf ) { uint32_t k ; int error = 0 ; if ( psf -> codec_close ) { error = psf -> codec_close ( psf ) ; psf -> codec_close = NULL ; } ; if ( psf -> container_close ) error = psf -> container_close ( psf ) ; error = psf_fclose ( psf ) ; psf_close_rsrc ( psf ) ; free ( psf -> container_data ) ; free ( psf -> codec_data ) ; free ( psf -> interleave ) ; free ( psf -> dither ) ; free ( psf -> peak_info ) ; free ( psf -> broadcast_16k ) ; free ( psf -> loop_info ) ; free ( psf -> instrument ) ; free ( psf -> cues ) ; free ( psf -> channel_map ) ; free ( psf -> format_desc ) ; free ( psf -> strings . storage ) ; if ( psf -> wchunks . chunks ) for ( k = 0 ; k < psf -> wchunks . used ; k ++ ) free ( psf -> wchunks . chunks [ k ] . data ) ; free ( psf -> rchunks . chunks ) ; free ( psf -> wchunks . chunks ) ; free ( psf -> iterator ) ; free ( psf -> cart_16k ) ; memset ( psf , 0 , sizeof ( SF_PRIVATE ) ) ; free ( psf ) ; return error ; } "," psf_close_rsrc ( psf ) ; free ( psf -> header . ptr ",erikd@libsndfile/708e996c87c5fae77b104ccfeb8f6db784c32074,CVE-2017-7586,https://github.com/erikd/libsndfile/commit/708e996c87c5fae77b104ccfeb8f6db784c32074,2017-04-07T20:59Z 277,CWE-284,"CWE-284 static int http_connect ( http_subtransport * t ) { int error ; char * proxy_url ; 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"" ) ; if ( git_stream_supports_proxy ( t -> io ) && ! git_remote__get_http_proxy ( t -> owner -> owner , ! ! t -> connection_data . use_ssl , & proxy_url ) ) { error = git_stream_set_proxy ( t -> io , proxy_url ) ; git__free ( proxy_url ) ; if ( error < 0 ) return error ; } error = git_stream_connect ( t -> io ) ; # if defined ( GIT_OPENSSL ) || defined ( GIT_SECURE_TRANSPORT ) || defined ( GIT_CURL ) 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 ; } } # endif if ( error < 0 ) return error ; t -> connected = 1 ; return 0 ; } "," ; int is_valid = ( error == GIT_OK ) giterr_clear ( ) ; error = ",libgit2@libgit2/b5c6a1b407b7f8b952bded2789593b68b1876211,CVE-2016-10130,https://github.com/libgit2/libgit2/commit/b5c6a1b407b7f8b952bded2789593b68b1876211,2017-03-24T15:59Z 278,CWE-125,"CWE-125 struct _mdi * _WM_ParseNewHmp ( uint8_t * hmp_data , uint32_t hmp_size ) { uint8_t is_hmp2 = 0 ; uint32_t zero_cnt = 0 ; uint32_t i = 0 ; uint32_t hmp_file_length = 0 ; uint32_t hmp_chunks = 0 ; uint32_t hmp_divisions = 0 ; uint32_t hmp_unknown = 0 ; uint32_t hmp_bpm = 0 ; uint32_t hmp_song_time = 0 ; struct _mdi * hmp_mdi ; uint8_t * * hmp_chunk ; uint32_t * chunk_length ; uint32_t * chunk_ofs ; uint32_t * chunk_delta ; uint8_t * chunk_end ; uint32_t chunk_num = 0 ; uint32_t hmp_track = 0 ; uint32_t smallest_delta = 0 ; uint32_t subtract_delta = 0 ; uint32_t end_of_chunks = 0 ; uint32_t var_len_shift = 0 ; float tempo_f = 500000.0 ; float samples_per_delta_f = 0.0 ; uint32_t sample_count = 0 ; float sample_count_f = 0 ; float sample_remainder = 0 ; if ( memcmp ( hmp_data , ""HMIMIDIP"" , 8 ) ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_NOT_HMP , NULL , 0 ) ; return NULL ; } hmp_data += 8 ; hmp_size -= 8 ; if ( ! memcmp ( hmp_data , ""013195"" , 6 ) ) { hmp_data += 6 ; hmp_size -= 6 ; is_hmp2 = 1 ; } if ( is_hmp2 ) { zero_cnt = 18 ; } else { zero_cnt = 24 ; } for ( i = 0 ; i < zero_cnt ; i ++ ) { if ( hmp_data [ i ] != 0 ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_NOT_HMP , NULL , 0 ) ; return NULL ; } } hmp_data += zero_cnt ; hmp_size -= zero_cnt ; hmp_file_length = * hmp_data ++ ; hmp_file_length += ( * hmp_data ++ << 8 ) ; hmp_file_length += ( * hmp_data ++ << 16 ) ; hmp_file_length += ( * hmp_data ++ << 24 ) ; hmp_size -= 4 ; UNUSED ( hmp_file_length ) ; hmp_data += 12 ; hmp_size -= 12 ; hmp_chunks = * hmp_data ++ ; hmp_chunks += ( * hmp_data ++ << 8 ) ; hmp_chunks += ( * hmp_data ++ << 16 ) ; hmp_chunks += ( * hmp_data ++ << 24 ) ; hmp_size -= 4 ; hmp_unknown = * hmp_data ++ ; hmp_unknown += ( * hmp_data ++ << 8 ) ; hmp_unknown += ( * hmp_data ++ << 16 ) ; hmp_unknown += ( * hmp_data ++ << 24 ) ; hmp_size -= 4 ; UNUSED ( hmp_unknown ) ; hmp_divisions = 60 ; hmp_bpm = * hmp_data ++ ; hmp_bpm += ( * hmp_data ++ << 8 ) ; hmp_bpm += ( * hmp_data ++ << 16 ) ; hmp_bpm += ( * hmp_data ++ << 24 ) ; hmp_size -= 4 ; if ( ( _WM_MixerOptions & WM_MO_ROUNDTEMPO ) ) { tempo_f = ( float ) ( 60000000 / hmp_bpm ) + 0.5f ; } else { tempo_f = ( float ) ( 60000000 / hmp_bpm ) ; } samples_per_delta_f = _WM_GetSamplesPerTick ( hmp_divisions , tempo_f ) ; hmp_song_time = * hmp_data ++ ; hmp_song_time += ( * hmp_data ++ << 8 ) ; hmp_song_time += ( * hmp_data ++ << 16 ) ; hmp_song_time += ( * hmp_data ++ << 24 ) ; hmp_size -= 4 ; UNUSED ( hmp_song_time ) ; if ( is_hmp2 ) { hmp_data += 840 ; hmp_size -= 840 ; } else { hmp_data += 712 ; hmp_size -= 712 ; } hmp_mdi = _WM_initMDI ( ) ; _WM_midi_setup_divisions ( hmp_mdi , hmp_divisions ) ; _WM_midi_setup_tempo ( hmp_mdi , ( uint32_t ) tempo_f ) ; hmp_chunk = malloc ( sizeof ( uint8_t * ) * hmp_chunks ) ; chunk_length = malloc ( sizeof ( uint32_t ) * hmp_chunks ) ; chunk_delta = malloc ( sizeof ( uint32_t ) * hmp_chunks ) ; chunk_ofs = malloc ( sizeof ( uint32_t ) * hmp_chunks ) ; chunk_end = malloc ( sizeof ( uint8_t ) * hmp_chunks ) ; smallest_delta = 0xffffffff ; for ( i = 0 ; i < hmp_chunks ; i ++ ) { hmp_chunk [ i ] = hmp_data ; chunk_ofs [ i ] = 0 ; chunk_num = * hmp_data ++ ; chunk_num += ( * hmp_data ++ << 8 ) ; chunk_num += ( * hmp_data ++ << 16 ) ; chunk_num += ( * hmp_data ++ << 24 ) ; chunk_ofs [ i ] += 4 ; UNUSED ( chunk_num ) ; chunk_length [ i ] = * hmp_data ++ ; chunk_length [ i ] += ( * hmp_data ++ << 8 ) ; chunk_length [ i ] += ( * hmp_data ++ << 16 ) ; chunk_length [ i ] += ( * hmp_data ++ << 24 ) ; chunk_ofs [ i ] += 4 ; if ( chunk_length [ i ] > hmp_size ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_NOT_HMP , ""filetooshort"" , 0 ) ; goto _hmp_end ; } hmp_size -= chunk_length [ i ] ; hmp_track = * hmp_data ++ ; hmp_track += ( * hmp_data ++ << 8 ) ; hmp_track += ( * hmp_data ++ << 16 ) ; hmp_track += ( * hmp_data ++ << 24 ) ; chunk_ofs [ i ] += 4 ; UNUSED ( hmp_track ) ; chunk_delta [ i ] = 0 ; var_len_shift = 0 ; if ( * hmp_data < 0x80 ) { do { chunk_delta [ i ] = chunk_delta [ i ] | ( ( * hmp_data ++ & 0x7F ) << var_len_shift ) ; var_len_shift += 7 ; chunk_ofs [ i ] ++ ; } while ( * hmp_data < 0x80 ) ; } chunk_delta [ i ] = chunk_delta [ i ] | ( ( * hmp_data ++ & 0x7F ) << var_len_shift ) ; chunk_ofs [ i ] ++ ; if ( chunk_delta [ i ] < smallest_delta ) { smallest_delta = chunk_delta [ i ] ; } hmp_data = hmp_chunk [ i ] + chunk_length [ i ] ; hmp_chunk [ i ] += chunk_ofs [ i ] ++ ; chunk_end [ i ] = 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 ; hmp_mdi -> events [ hmp_mdi -> event_count - 1 ] . samples_to_next += sample_count ; hmp_mdi -> extra_info . approx_total_samples += sample_count ; while ( end_of_chunks < hmp_chunks ) { smallest_delta = 0 ; for ( i = 0 ; i < hmp_chunks ; i ++ ) { if ( chunk_end [ i ] ) continue ; if ( chunk_delta [ i ] ) { chunk_delta [ i ] -= subtract_delta ; if ( chunk_delta [ i ] ) { if ( ( ! smallest_delta ) || ( smallest_delta > chunk_delta [ i ] ) ) { smallest_delta = chunk_delta [ i ] ; } continue ; } } do { if ( ( ( hmp_chunk [ i ] [ 0 ] & 0xf0 ) == 0xb0 ) && ( ( hmp_chunk [ i ] [ 1 ] == 110 ) || ( hmp_chunk [ i ] [ 1 ] == 111 ) ) && ( hmp_chunk [ i ] [ 2 ] > 0x7f ) ) { hmp_chunk [ i ] += 3 ; } else { uint32_t setup_ret = 0 ; if ( ( setup_ret = _WM_SetupMidiEvent ( hmp_mdi , hmp_chunk [ i ] , 0 ) ) == 0 ) { goto _hmp_end ; } if ( ( hmp_chunk [ i ] [ 0 ] == 0xff ) && ( hmp_chunk [ i ] [ 1 ] == 0x2f ) && ( hmp_chunk [ i ] [ 2 ] == 0x00 ) ) { end_of_chunks ++ ; chunk_end [ i ] = 1 ; hmp_chunk [ i ] += 3 ; goto NEXT_CHUNK ; } else if ( ( hmp_chunk [ i ] [ 0 ] == 0xff ) && ( hmp_chunk [ i ] [ 1 ] == 0x51 ) && ( hmp_chunk [ i ] [ 2 ] == 0x03 ) ) { tempo_f = ( float ) ( ( hmp_chunk [ i ] [ 3 ] << 16 ) + ( hmp_chunk [ i ] [ 4 ] << 8 ) + hmp_chunk [ i ] [ 5 ] ) ; if ( tempo_f == 0.0 ) tempo_f = 500000.0 ; fprintf ( stderr , ""DEBUG:Tempochange%f\\r\\n"" , tempo_f ) ; } hmp_chunk [ i ] += setup_ret ; } var_len_shift = 0 ; chunk_delta [ i ] = 0 ; if ( * hmp_chunk [ i ] < 0x80 ) { do { chunk_delta [ i ] = chunk_delta [ i ] + ( ( * hmp_chunk [ i ] & 0x7F ) << var_len_shift ) ; var_len_shift += 7 ; hmp_chunk [ i ] ++ ; } while ( * hmp_chunk [ i ] < 0x80 ) ; } chunk_delta [ i ] = chunk_delta [ i ] + ( ( * hmp_chunk [ i ] & 0x7F ) << var_len_shift ) ; hmp_chunk [ i ] ++ ; } while ( ! chunk_delta [ i ] ) ; if ( ( ! smallest_delta ) || ( smallest_delta > chunk_delta [ i ] ) ) { smallest_delta = chunk_delta [ i ] ; } NEXT_CHUNK : 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 ; hmp_mdi -> events [ hmp_mdi -> event_count - 1 ] . samples_to_next += sample_count ; hmp_mdi -> extra_info . approx_total_samples += sample_count ; } if ( ( hmp_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 _hmp_end ; } hmp_mdi -> extra_info . current_sample = 0 ; hmp_mdi -> current_event = & hmp_mdi -> events [ 0 ] ; hmp_mdi -> samples_to_mix = 0 ; hmp_mdi -> note = NULL ; _WM_ResetToStart ( hmp_mdi ) ; _hmp_end : free ( hmp_chunk ) ; free ( chunk_length ) ; free ( chunk_delta ) ; free ( chunk_ofs ) ; free ( chunk_end ) ; if ( hmp_mdi -> reverb ) return ( hmp_mdi ) ; _WM_freeMDI ( hmp_mdi ) ; return NULL ; } "," ] + chunk_length [ i ] ; chunk_length [ i ] -= chunk_ofs += 3 ; chunk_length [ i ] -= 3 ; hmp_mdi , hmp_chunk [ i ] , chunk_length ] = 1 ; chunk_length [ i ] -= 3 += setup_ret ; chunk_length [ i ] -= setup_ret ; ; if ( chunk_length [ i ] && { do { if ( ! chunk_length [ i ] ) break ; ] ++ ; chunk_length [ i ] -- ; ) ; } if ( ! chunk_length [ i ] ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_NOT_HMP , ""filetooshort"" , 0 ) ; goto _hmp_end ; } i ] ++ ; chunk_length [ i ] -- ",Mindwerks@wildmidi/ad6d7cf88d6673167ca1f517248af9409a9f1be1,CVE-2017-11664,https://github.com/Mindwerks/wildmidi/commit/ad6d7cf88d6673167ca1f517248af9409a9f1be1,2017-08-17T16:29Z 279,CWE-20,"CWE-20 static fp_info * fp_set_per_packet_inf_from_conv ( umts_fp_conversation_info_t * p_conv_data , tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree _U_ ) { fp_info * fpi ; guint8 tfi , c_t ; int offset = 0 , i = 0 , j = 0 , num_tbs , chan , tb_size , tb_bit_off ; gboolean is_control_frame ; umts_mac_info * macinf ; rlc_info * rlcinf ; guint8 fake_lchid = 0 ; gint * cur_val = NULL ; fpi = wmem_new0 ( wmem_file_scope ( ) , fp_info ) ; p_add_proto_data ( wmem_file_scope ( ) , pinfo , proto_fp , 0 , fpi ) ; fpi -> iface_type = p_conv_data -> iface_type ; fpi -> division = p_conv_data -> division ; fpi -> release = 7 ; fpi -> release_year = 2006 ; fpi -> release_month = 12 ; fpi -> channel = p_conv_data -> channel ; fpi -> dch_crc_present = p_conv_data -> dch_crc_present ; fpi -> link_type = FP_Link_Ethernet ; # if 0 if ( ! pinfo -> fd -> flags . visited && p_conv_data -> reset_frag ) { fpi -> reset_frag = p_conv_data -> reset_frag ; p_conv_data -> reset_frag = FALSE ; } # endif fpi -> srcport = pinfo -> srcport ; fpi -> destport = pinfo -> destport ; fpi -> com_context_id = p_conv_data -> com_context_id ; if ( pinfo -> link_dir == P2P_DIR_UL ) { fpi -> is_uplink = TRUE ; } else { fpi -> is_uplink = FALSE ; } is_control_frame = tvb_get_guint8 ( tvb , offset ) & 0x01 ; switch ( fpi -> channel ) { case CHANNEL_HSDSCH : fpi -> hsdsch_entity = p_conv_data -> hsdsch_entity ; macinf = wmem_new0 ( wmem_file_scope ( ) , umts_mac_info ) ; fpi -> hsdsch_macflowd_id = p_conv_data -> hsdsch_macdflow_id ; macinf -> content [ 0 ] = hsdsch_macdflow_id_mac_content_map [ p_conv_data -> hsdsch_macdflow_id ] ; macinf -> lchid [ 0 ] = p_conv_data -> hsdsch_macdflow_id ; p_add_proto_data ( wmem_file_scope ( ) , pinfo , proto_umts_mac , 0 , macinf ) ; rlcinf = wmem_new0 ( wmem_file_scope ( ) , rlc_info ) ; rlcinf -> mode [ 0 ] = hsdsch_macdflow_id_rlc_map [ p_conv_data -> hsdsch_macdflow_id ] ; if ( fpi -> hsdsch_entity == hs ) { for ( i = 0 ; i < MAX_NUM_HSDHSCH_MACDFLOW ; i ++ ) { if ( ( cur_val = ( gint * ) g_tree_lookup ( hsdsch_muxed_flows , GINT_TO_POINTER ( ( gint ) p_conv_data -> hrnti ) ) ) != NULL ) { j = 1 << i ; fpi -> hsdhsch_macfdlow_is_mux [ i ] = j & * cur_val ; } else { fpi -> hsdhsch_macfdlow_is_mux [ i ] = FALSE ; } } } rlcinf -> urnti [ 0 ] = fpi -> com_context_id ; rlcinf -> li_size [ 0 ] = RLC_LI_7BITS ; rlcinf -> ciphered [ 0 ] = FALSE ; rlcinf -> deciphered [ 0 ] = FALSE ; p_add_proto_data ( wmem_file_scope ( ) , pinfo , proto_rlc , 0 , rlcinf ) ; return fpi ; case CHANNEL_EDCH : macinf = wmem_new0 ( wmem_file_scope ( ) , umts_mac_info ) ; rlcinf = wmem_new0 ( wmem_file_scope ( ) , rlc_info ) ; fpi -> no_ddi_entries = p_conv_data -> no_ddi_entries ; for ( i = 0 ; i < fpi -> no_ddi_entries ; i ++ ) { fpi -> edch_ddi [ i ] = p_conv_data -> edch_ddi [ i ] ; fpi -> edch_macd_pdu_size [ i ] = p_conv_data -> edch_macd_pdu_size [ i ] ; fpi -> edch_lchId [ i ] = p_conv_data -> edch_lchId [ i ] ; } fpi -> edch_type = p_conv_data -> edch_type ; p_add_proto_data ( wmem_file_scope ( ) , pinfo , proto_umts_mac , 0 , macinf ) ; rlcinf -> urnti [ 0 ] = fpi -> com_context_id ; rlcinf -> li_size [ 0 ] = RLC_LI_7BITS ; rlcinf -> ciphered [ 0 ] = FALSE ; rlcinf -> deciphered [ 0 ] = FALSE ; p_add_proto_data ( wmem_file_scope ( ) , pinfo , proto_rlc , 0 , rlcinf ) ; return fpi ; case CHANNEL_PCH : fpi -> paging_indications = p_conv_data -> paging_indications ; fpi -> num_chans = p_conv_data -> num_dch_in_flow ; if ( is_control_frame ) { return fpi ; } offset = 3 ; break ; case CHANNEL_DCH : fpi -> num_chans = p_conv_data -> num_dch_in_flow ; if ( is_control_frame ) { return fpi ; } rlcinf = wmem_new0 ( wmem_file_scope ( ) , rlc_info ) ; macinf = wmem_new0 ( wmem_file_scope ( ) , umts_mac_info ) ; offset = 2 ; fakes = 5 ; for ( chan = 0 ; chan < fpi -> num_chans ; chan ++ ) { tfi = tvb_get_bits8 ( tvb , 3 + offset * 8 , 5 ) ; num_tbs = ( fpi -> is_uplink ) ? p_conv_data -> fp_dch_channel_info [ chan ] . ul_chan_num_tbs [ tfi ] : p_conv_data -> fp_dch_channel_info [ chan ] . dl_chan_num_tbs [ tfi ] ; tb_size = ( fpi -> is_uplink ) ? p_conv_data -> fp_dch_channel_info [ i ] . ul_chan_tf_size [ tfi ] : p_conv_data -> fp_dch_channel_info [ i ] . dl_chan_tf_size [ tfi ] ; if ( p_conv_data -> dchs_in_flow_list [ chan ] != 31 && ( p_conv_data -> dchs_in_flow_list [ chan ] == 24 && tb_size != 340 ) ) { fake_lchid = make_fake_lchid ( pinfo , p_conv_data -> dchs_in_flow_list [ chan ] ) ; } tb_bit_off = ( 2 + p_conv_data -> num_dch_in_flow ) * 8 ; for ( j = 0 ; j < num_tbs && j + chan < MAX_MAC_FRAMES ; j ++ ) { macinf -> trchid [ j + chan ] = p_conv_data -> dchs_in_flow_list [ chan ] ; if ( p_conv_data -> dchs_in_flow_list [ chan ] == 31 || p_conv_data -> dchs_in_flow_list [ chan ] == 24 ) { if ( 0 ) { macinf -> ctmux [ j + chan ] = FALSE ; macinf -> lchid [ j + chan ] = 1 ; macinf -> content [ j + chan ] = lchId_type_table [ 1 ] ; rlcinf -> mode [ j + chan ] = lchId_rlc_map [ 1 ] ; } else if ( p_conv_data -> dchs_in_flow_list [ chan ] == 24 && tb_size != 340 ) { macinf -> ctmux [ j + chan ] = FALSE ; macinf -> lchid [ j + chan ] = fake_lchid ; macinf -> fake_chid [ j + chan ] = TRUE ; macinf -> content [ j + chan ] = MAC_CONTENT_PS_DTCH ; rlcinf -> mode [ j + chan ] = RLC_AM ; } else { macinf -> ctmux [ j + chan ] = TRUE ; c_t = tvb_get_bits8 ( tvb , tb_bit_off , 4 ) ; macinf -> lchid [ j + chan ] = c_t + 1 ; macinf -> content [ j + chan ] = lchId_type_table [ c_t + 1 ] ; rlcinf -> mode [ j + chan ] = lchId_rlc_map [ c_t + 1 ] ; } } else { fake_lchid = make_fake_lchid ( pinfo , p_conv_data -> dchs_in_flow_list [ chan ] ) ; macinf -> ctmux [ j + chan ] = FALSE ; macinf -> content [ j + chan ] = lchId_type_table [ fake_lchid ] ; rlcinf -> mode [ j + chan ] = lchId_rlc_map [ fake_lchid ] ; macinf -> fake_chid [ j + chan ] = TRUE ; macinf -> lchid [ j + chan ] = fake_lchid ; } rlcinf -> urnti [ j + chan ] = p_conv_data -> com_context_id ; rlcinf -> li_size [ j + chan ] = RLC_LI_7BITS ; # if 0 if ( rrc_ciph_inf && g_tree_lookup ( rrc_ciph_inf , GINT_TO_POINTER ( ( gint ) p_conv_data -> com_context_id ) ) != NULL ) { rlcinf -> ciphered [ j + chan ] = TRUE ; } else { rlcinf -> ciphered [ j + chan ] = FALSE ; } # endif rlcinf -> ciphered [ j + chan ] = FALSE ; rlcinf -> deciphered [ j + chan ] = FALSE ; rlcinf -> rbid [ j + chan ] = macinf -> lchid [ j + chan ] ; tb_bit_off += tb_size + 4 ; } offset ++ ; } p_add_proto_data ( wmem_file_scope ( ) , pinfo , proto_umts_mac , 0 , macinf ) ; p_add_proto_data ( wmem_file_scope ( ) , pinfo , proto_rlc , 0 , rlcinf ) ; offset = 2 ; break ; case CHANNEL_FACH_FDD : fpi -> num_chans = p_conv_data -> num_dch_in_flow ; if ( is_control_frame ) { return fpi ; } offset = 2 ; macinf = wmem_new0 ( wmem_file_scope ( ) , umts_mac_info ) ; macinf -> ctmux [ 0 ] = 1 ; macinf -> content [ 0 ] = MAC_CONTENT_DCCH ; p_add_proto_data ( wmem_file_scope ( ) , pinfo , proto_umts_mac , 0 , macinf ) ; rlcinf = wmem_new0 ( wmem_file_scope ( ) , rlc_info ) ; rlcinf -> urnti [ 0 ] = fpi -> channel ; rlcinf -> mode [ 0 ] = RLC_AM ; rlcinf -> li_size [ 0 ] = RLC_LI_7BITS ; rlcinf -> ciphered [ 0 ] = FALSE ; rlcinf -> deciphered [ 0 ] = FALSE ; p_add_proto_data ( wmem_file_scope ( ) , pinfo , proto_rlc , 0 , rlcinf ) ; break ; case CHANNEL_RACH_FDD : fpi -> num_chans = p_conv_data -> num_dch_in_flow ; if ( is_control_frame ) { return fpi ; } offset = 2 ; macinf = wmem_new0 ( wmem_file_scope ( ) , umts_mac_info ) ; rlcinf = wmem_new0 ( wmem_file_scope ( ) , rlc_info ) ; for ( chan = 0 ; chan < fpi -> num_chans ; chan ++ ) { macinf -> ctmux [ chan ] = 1 ; macinf -> content [ chan ] = MAC_CONTENT_DCCH ; rlcinf -> urnti [ chan ] = fpi -> com_context_id ; } p_add_proto_data ( wmem_file_scope ( ) , pinfo , proto_umts_mac , 0 , macinf ) ; p_add_proto_data ( wmem_file_scope ( ) , pinfo , proto_rlc , 0 , rlcinf ) ; break ; case CHANNEL_HSDSCH_COMMON : rlcinf = wmem_new0 ( wmem_file_scope ( ) , rlc_info ) ; macinf = wmem_new0 ( wmem_file_scope ( ) , umts_mac_info ) ; p_add_proto_data ( wmem_file_scope ( ) , pinfo , proto_umts_mac , 0 , macinf ) ; p_add_proto_data ( wmem_file_scope ( ) , pinfo , proto_rlc , 0 , rlcinf ) ; break ; default : expert_add_info ( pinfo , NULL , & ei_fp_transport_channel_type_unknown ) ; return NULL ; } for ( i = 0 ; i < fpi -> num_chans ; i ++ ) { tfi = tvb_get_guint8 ( tvb , offset ) ; if ( pinfo -> link_dir == P2P_DIR_UL ) { fpi -> chan_tf_size [ i ] = p_conv_data -> fp_dch_channel_info [ i ] . ul_chan_tf_size [ tfi ] ; fpi -> chan_num_tbs [ i ] = p_conv_data -> fp_dch_channel_info [ i ] . ul_chan_num_tbs [ tfi ] ; } else { fpi -> chan_tf_size [ i ] = p_conv_data -> fp_dch_channel_info [ i ] . dl_chan_tf_size [ tfi ] ; fpi -> chan_num_tbs [ i ] = p_conv_data -> fp_dch_channel_info [ i ] . dl_chan_num_tbs [ tfi ] ; } offset ++ ; } return fpi ; } "," ; c_t = ( , 4 ) + 1 ) % 0xf ] = c_t ; macinf -> lchId_type_table [ c_t ] ; rlcinf lchId_rlc_map [ c_t ] ; } ",wireshark@wireshark/7d7190695ce2ff269fdffb04e87139995cde21f4,CVE-2016-5353,https://github.com/wireshark/wireshark/commit/7d7190695ce2ff269fdffb04e87139995cde21f4,2016-08-07T16:59Z 280,CWE-310,"CWE-310 int ECDSA_verify ( int type , const unsigned char * dgst , int dgst_len , const unsigned char * sigbuf , int sig_len , EC_KEY * eckey ) { ECDSA_SIG * s ; int ret = - 1 ; s = ECDSA_SIG_new ( ) ; if ( s == NULL ) return ( ret ) ; if ( d2i_ECDSA_SIG ( & s , & sigbuf , sig_len ) == NULL ) goto err ; ret = ECDSA_do_verify ( dgst , dgst_len , s , eckey ) ; err : ECDSA_SIG_free ( s ) ; return ( ret ) ; } "," * s ; const unsigned char * p = sigbuf ; unsigned char * der = NULL ; int derlen = - 1 ; s , & p , sig_len ) == NULL ) goto err ; derlen = i2d_ECDSA_SIG ( s , & der ) ; if ( derlen != sig_len || 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 281,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 282,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 283,CWE-787,"CWE-787 static char * get_header ( FILE * fp ) { long start ; char * header ; header = calloc ( 1 , 1024 ) ; start = ftell ( fp ) ; fseek ( fp , 0 , SEEK_SET ) ; SAFE_E ( fread ( header , 1 , 1023 , fp ) , 1023 , ""FailedtoloadPDFheader.\\n"" ) ; fseek ( fp , start , SEEK_SET ) ; return header ; } "," fp ) { char * header char * header = safe_calloc ( 1024 ) ; 1024 ) ; long ",enferex@pdfresurrect/0c4120fffa3dffe97b95c486a120eded82afe8a6,CVE-2019-14934,https://github.com/enferex/pdfresurrect/commit/0c4120fffa3dffe97b95c486a120eded82afe8a6,2019-08-11T22:15Z 284,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 * number_planes_filled * sizeof ( * pixels ) ) ; if ( pixel_info == ( MemoryInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; pixel_info_length = image -> columns * image -> rows * number_planes_filled ; 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 ) ) ; } "," -> rows * MagickMax ( number_planes_filled , 4 ) * sizeof ( -> rows * MagickMax ( number_planes_filled , 4 ) ; pixels = ",ImageMagick@ImageMagick/3e9165285eda6e1bb71172031d3048b51bb443a4,CVE-2016-10049,https://github.com/ImageMagick/ImageMagick/commit/3e9165285eda6e1bb71172031d3048b51bb443a4,2017-03-23T17:59Z 285,CWE-125,"CWE-125 static const u_char * ikev1_id_print ( netdissect_options * ndo , u_char tpay _U_ , const struct isakmp_gen * ext , u_int item_len , const u_char * ep _U_ , uint32_t phase , uint32_t doi _U_ , uint32_t proto _U_ , int depth _U_ ) { # define USE_IPSECDOI_IN_PHASE1 1 const struct ikev1_pl_id * p ; struct ikev1_pl_id id ; static const char * idtypestr [ ] = { ""IPv4"" , ""IPv4net"" , ""IPv6"" , ""IPv6net"" , } ; static const char * ipsecidtypestr [ ] = { NULL , ""IPv4"" , ""FQDN"" , ""userFQDN"" , ""IPv4net"" , ""IPv6"" , ""IPv6net"" , ""IPv4range"" , ""IPv6range"" , ""ASN1DN"" , ""ASN1GN"" , ""keyid"" , } ; int len ; const u_char * data ; ND_PRINT ( ( ndo , ""%s:"" , NPSTR ( ISAKMP_NPTYPE_ID ) ) ) ; p = ( const struct ikev1_pl_id * ) ext ; ND_TCHECK ( * p ) ; UNALIGNED_MEMCPY ( & id , ext , sizeof ( id ) ) ; if ( sizeof ( * p ) < item_len ) { data = ( const u_char * ) ( p + 1 ) ; len = item_len - sizeof ( * p ) ; } else { data = NULL ; len = 0 ; } # if 0 ND_PRINT ( ( ndo , ""[phase=%ddoi=%dproto=%d]"" , phase , doi , proto ) ) ; # endif switch ( phase ) { # ifndef USE_IPSECDOI_IN_PHASE1 case 1 : # endif default : ND_PRINT ( ( ndo , ""idtype=%s"" , STR_OR_ID ( id . d . id_type , idtypestr ) ) ) ; ND_PRINT ( ( ndo , ""doi_data=%u"" , ( uint32_t ) ( ntohl ( id . d . doi_data ) & 0xffffff ) ) ) ; break ; # ifdef USE_IPSECDOI_IN_PHASE1 case 1 : # endif case 2 : { const struct ipsecdoi_id * doi_p ; struct ipsecdoi_id doi_id ; const char * p_name ; doi_p = ( const struct ipsecdoi_id * ) ext ; ND_TCHECK ( * doi_p ) ; UNALIGNED_MEMCPY ( & doi_id , ext , sizeof ( doi_id ) ) ; ND_PRINT ( ( ndo , ""idtype=%s"" , STR_OR_ID ( doi_id . type , ipsecidtypestr ) ) ) ; if ( ! ndo -> ndo_nflag && doi_id . proto_id && ( p_name = netdb_protoname ( doi_id . proto_id ) ) != NULL ) ND_PRINT ( ( ndo , ""protoid=%s"" , p_name ) ) ; else ND_PRINT ( ( ndo , ""protoid=%u"" , doi_id . proto_id ) ) ; ND_PRINT ( ( ndo , ""port=%d"" , ntohs ( doi_id . port ) ) ) ; if ( ! len ) break ; if ( data == NULL ) goto trunc ; ND_TCHECK2 ( * data , len ) ; switch ( doi_id . type ) { case IPSECDOI_ID_IPV4_ADDR : if ( len < 4 ) ND_PRINT ( ( ndo , ""len=%d[bad:<4]"" , len ) ) ; else ND_PRINT ( ( ndo , ""len=%d%s"" , len , ipaddr_string ( ndo , data ) ) ) ; len = 0 ; break ; case IPSECDOI_ID_FQDN : case IPSECDOI_ID_USER_FQDN : { int i ; ND_PRINT ( ( ndo , ""len=%d"" , len ) ) ; for ( i = 0 ; i < len ; i ++ ) safeputchar ( ndo , data [ i ] ) ; len = 0 ; break ; } case IPSECDOI_ID_IPV4_ADDR_SUBNET : { const u_char * mask ; if ( len < 8 ) ND_PRINT ( ( ndo , ""len=%d[bad:<8]"" , len ) ) ; else { mask = data + sizeof ( struct in_addr ) ; ND_PRINT ( ( ndo , ""len=%d%s/%u.%u.%u.%u"" , len , ipaddr_string ( ndo , data ) , mask [ 0 ] , mask [ 1 ] , mask [ 2 ] , mask [ 3 ] ) ) ; } len = 0 ; break ; } case IPSECDOI_ID_IPV6_ADDR : if ( len < 16 ) ND_PRINT ( ( ndo , ""len=%d[bad:<16]"" , len ) ) ; else ND_PRINT ( ( ndo , ""len=%d%s"" , len , ip6addr_string ( ndo , data ) ) ) ; len = 0 ; break ; case IPSECDOI_ID_IPV6_ADDR_SUBNET : { const u_char * mask ; if ( len < 20 ) ND_PRINT ( ( ndo , ""len=%d[bad:<20]"" , len ) ) ; else { mask = ( const u_char * ) ( data + sizeof ( struct in6_addr ) ) ; ND_PRINT ( ( ndo , ""len=%d%s/0x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"" , len , ip6addr_string ( ndo , data ) , mask [ 0 ] , mask [ 1 ] , mask [ 2 ] , mask [ 3 ] , mask [ 4 ] , mask [ 5 ] , mask [ 6 ] , mask [ 7 ] , mask [ 8 ] , mask [ 9 ] , mask [ 10 ] , mask [ 11 ] , mask [ 12 ] , mask [ 13 ] , mask [ 14 ] , mask [ 15 ] ) ) ; } len = 0 ; break ; } case IPSECDOI_ID_IPV4_ADDR_RANGE : if ( len < 8 ) ND_PRINT ( ( ndo , ""len=%d[bad:<8]"" , len ) ) ; else { ND_PRINT ( ( ndo , ""len=%d%s-%s"" , len , ipaddr_string ( ndo , data ) , ipaddr_string ( ndo , data + sizeof ( struct in_addr ) ) ) ) ; } len = 0 ; break ; case IPSECDOI_ID_IPV6_ADDR_RANGE : if ( len < 32 ) ND_PRINT ( ( ndo , ""len=%d[bad:<32]"" , len ) ) ; else { ND_PRINT ( ( ndo , ""len=%d%s-%s"" , len , ip6addr_string ( ndo , data ) , ip6addr_string ( ndo , data + sizeof ( struct in6_addr ) ) ) ) ; } len = 0 ; break ; case IPSECDOI_ID_DER_ASN1_DN : case IPSECDOI_ID_DER_ASN1_GN : case IPSECDOI_ID_KEY_ID : break ; } break ; } } if ( data && len ) { ND_PRINT ( ( ndo , ""len=%d"" , len ) ) ; if ( 2 < ndo -> ndo_vflag ) { ND_PRINT ( ( ndo , """" ) ) ; if ( ! rawprint ( ndo , ( const uint8_t * ) data , len ) ) goto trunc ; } } return ( const u_char * ) ext + item_len ; trunc : ND_PRINT ( ( ndo , ""[|%s]"" , NPSTR ( ISAKMP_NPTYPE_ID ) ) ) ; return NULL ; } "," ( len < 32 ) ND_PRINT ( ( ndo , ""len=%d[bad:<32]"" , len ) ",the-tcpdump-group@tcpdump/061e7371a944588f231cb1b66d6fb070b646e376,CVE-2017-13689,https://github.com/the-tcpdump-group/tcpdump/commit/061e7371a944588f231cb1b66d6fb070b646e376,2017-09-14T06:29Z 286,CWE-416,"CWE-416 CURLcode Curl_close ( struct Curl_easy * data ) { struct Curl_multi * m ; if ( ! data ) return CURLE_OK ; Curl_expire_clear ( data ) ; m = data -> multi ; if ( m ) curl_multi_remove_handle ( data -> multi , data ) ; if ( data -> multi_easy ) curl_multi_cleanup ( data -> multi_easy ) ; Curl_llist_destroy ( & data -> state . timeoutlist , NULL ) ; data -> magic = 0 ; if ( data -> state . rangestringalloc ) free ( data -> state . range ) ; Curl_free_request_state ( data ) ; Curl_ssl_close_all ( data ) ; Curl_safefree ( data -> state . first_host ) ; Curl_safefree ( data -> state . scratch ) ; Curl_ssl_free_certinfo ( data ) ; free ( data -> req . newurl ) ; data -> req . newurl = NULL ; if ( data -> change . referer_alloc ) { Curl_safefree ( data -> change . referer ) ; data -> change . referer_alloc = FALSE ; } data -> change . referer = NULL ; Curl_up_free ( data ) ; Curl_safefree ( data -> state . buffer ) ; Curl_safefree ( data -> state . headerbuff ) ; Curl_safefree ( data -> state . ulbuf ) ; Curl_flush_cookies ( data , 1 ) ; Curl_digest_cleanup ( data ) ; Curl_safefree ( data -> info . contenttype ) ; Curl_safefree ( data -> info . wouldredirect ) ; Curl_resolver_cleanup ( data -> state . resolver ) ; Curl_http2_cleanup_dependencies ( data ) ; Curl_convert_close ( data ) ; if ( data -> share ) { Curl_share_lock ( data , CURL_LOCK_DATA_SHARE , CURL_LOCK_ACCESS_SINGLE ) ; data -> share -> dirty -- ; Curl_share_unlock ( data , CURL_LOCK_DATA_SHARE ) ; } Curl_wildcard_dtor ( & data -> wildcard ) ; Curl_freeset ( data ) ; free ( data ) ; return CURLE_OK ; } "," -> multi_easy ) { multi_easy ) ; data -> multi_easy = NULL ; } ",curl@curl/81d135d67155c5295b1033679c606165d4e28f3f,CVE-2018-16840,https://github.com/curl/curl/commit/81d135d67155c5295b1033679c606165d4e28f3f,2018-10-31T18:29Z 287,CWE-119,"CWE-119 static int search_old_relocation ( struct reloc_struct_t * reloc_table , ut32 addr_to_patch , int n_reloc ) { int i ; for ( i = 0 ; i < n_reloc ; i ++ ) { if ( addr_to_patch == reloc_table [ i ] . data_offset ) { return i ; } } return - 1 ; } "," ",radare@radare2/72794dc3523bbd5bb370de3c5857cb736c387e18,CVE-2017-6194,https://github.com/radare/radare2/commit/72794dc3523bbd5bb370de3c5857cb736c387e18,2017-04-03T05:59Z 288,CWE-264,"CWE-264 int inet6_csk_xmit ( struct sock * sk , struct sk_buff * skb , struct flowi * fl_unused ) { struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct flowi6 fl6 ; struct dst_entry * dst ; int res ; dst = inet6_csk_route_socket ( sk , & fl6 ) ; if ( IS_ERR ( dst ) ) { sk -> sk_err_soft = - PTR_ERR ( dst ) ; sk -> sk_route_caps = 0 ; kfree_skb ( skb ) ; return PTR_ERR ( dst ) ; } rcu_read_lock ( ) ; skb_dst_set_noref ( skb , dst ) ; fl6 . daddr = sk -> sk_v6_daddr ; res = ip6_xmit ( sk , skb , & fl6 , np -> opt , np -> tclass ) ; rcu_read_unlock ( ) ; return res ; } "," & fl6 , rcu_dereference ( np -> opt ) ",torvalds@linux/45f6fad84cc305103b28d73482b344d7f5b76f39,CVE-2016-3841,https://github.com/torvalds/linux/commit/45f6fad84cc305103b28d73482b344d7f5b76f39,2016-08-06T20:59Z 289,CWE-401,"CWE-401 static struct clock_source * dce120_clock_source_create ( struct dc_context * ctx , struct dc_bios * bios , enum clock_source_id id , const struct dce110_clk_src_regs * regs , bool dp_clk_src ) { struct dce110_clk_src * clk_src = kzalloc ( sizeof ( * clk_src ) , GFP_KERNEL ) ; if ( ! clk_src ) return NULL ; if ( dce112_clk_src_construct ( clk_src , ctx , bios , id , regs , & cs_shift , & cs_mask ) ) { clk_src -> base . dp_clk_src = dp_clk_src ; return & clk_src -> base ; } BREAK_TO_DEBUGGER ( ) ; return NULL ; } "," base ; } kfree ( clk_src ) ; ",torvalds@linux/055e547478a11a6360c7ce05e2afc3e366968a12,CVE-2019-19083,https://github.com/torvalds/linux/commit/055e547478a11a6360c7ce05e2afc3e366968a12,2019-11-18T06:15Z 290,CWE-119,"CWE-119 void vp8_build_intra_predictors_mbuv_s_c ( MACROBLOCKD * x , unsigned char * uabove_row , unsigned char * vabove_row , unsigned char * uleft , unsigned char * vleft , int left_stride , unsigned char * upred_ptr , unsigned char * vpred_ptr , int pred_stride ) { unsigned char uleft_col [ 8 ] ; unsigned char utop_left = uabove_row [ - 1 ] ; unsigned char vleft_col [ 8 ] ; unsigned char vtop_left = vabove_row [ - 1 ] ; int i , j ; for ( i = 0 ; i < 8 ; i ++ ) { uleft_col [ i ] = uleft [ i * left_stride ] ; vleft_col [ i ] = vleft [ i * left_stride ] ; } switch ( x -> mode_info_context -> mbmi . uv_mode ) { case DC_PRED : { int expected_udc ; int expected_vdc ; int shift ; int Uaverage = 0 ; int Vaverage = 0 ; if ( x -> up_available ) { for ( i = 0 ; i < 8 ; i ++ ) { Uaverage += uabove_row [ i ] ; Vaverage += vabove_row [ i ] ; } } if ( x -> left_available ) { for ( i = 0 ; i < 8 ; i ++ ) { Uaverage += uleft_col [ i ] ; Vaverage += vleft_col [ i ] ; } } if ( ! x -> up_available && ! x -> left_available ) { expected_udc = 128 ; expected_vdc = 128 ; } else { shift = 2 + x -> up_available + x -> left_available ; expected_udc = ( Uaverage + ( 1 << ( shift - 1 ) ) ) >> shift ; expected_vdc = ( Vaverage + ( 1 << ( shift - 1 ) ) ) >> shift ; } for ( i = 0 ; i < 8 ; i ++ ) { vpx_memset ( upred_ptr , expected_udc , 8 ) ; vpx_memset ( vpred_ptr , expected_vdc , 8 ) ; upred_ptr += pred_stride ; vpred_ptr += pred_stride ; } } break ; case V_PRED : { for ( i = 0 ; i < 8 ; i ++ ) { vpx_memcpy ( upred_ptr , uabove_row , 8 ) ; vpx_memcpy ( vpred_ptr , vabove_row , 8 ) ; upred_ptr += pred_stride ; vpred_ptr += pred_stride ; } } break ; case H_PRED : { for ( i = 0 ; i < 8 ; i ++ ) { vpx_memset ( upred_ptr , uleft_col [ i ] , 8 ) ; vpx_memset ( vpred_ptr , vleft_col [ i ] , 8 ) ; upred_ptr += pred_stride ; vpred_ptr += pred_stride ; } } break ; case TM_PRED : { for ( i = 0 ; i < 8 ; i ++ ) { for ( j = 0 ; j < 8 ; j ++ ) { int predu = uleft_col [ i ] + uabove_row [ j ] - utop_left ; int predv = vleft_col [ i ] + vabove_row [ j ] - vtop_left ; if ( predu < 0 ) predu = 0 ; if ( predu > 255 ) predu = 255 ; if ( predv < 0 ) predv = 0 ; if ( predv > 255 ) predv = 255 ; upred_ptr [ j ] = predu ; vpred_ptr [ j ] = predv ; } upred_ptr += pred_stride ; vpred_ptr += pred_stride ; } } break ; case B_PRED : case NEARESTMV : case NEARMV : case ZEROMV : case NEWMV : case SPLITMV : case MB_MODE_COUNT : break ; } } "," ++ ) { memset ( upred_ptr , 8 ) ; memset ( vpred_ptr , ++ ) { memcpy ( upred_ptr , 8 ) ; memcpy ( vpred_ptr , ++ ) { memset ( upred_ptr , 8 ) ; memset ( vpred_ptr , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 291,CWE-476,"CWE-476 BOOL rdp_decrypt ( rdpRdp * rdp , STREAM * s , int length , UINT16 securityFlags ) { BYTE cmac [ 8 ] ; BYTE wmac [ 8 ] ; if ( rdp -> settings -> EncryptionMethods == ENCRYPTION_METHOD_FIPS ) { UINT16 len ; BYTE version , pad ; BYTE * sig ; if ( stream_get_left ( s ) < 12 ) return FALSE ; stream_read_UINT16 ( s , len ) ; stream_read_BYTE ( s , version ) ; stream_read_BYTE ( s , pad ) ; sig = s -> p ; stream_seek ( s , 8 ) ; length -= 12 ; if ( ! security_fips_decrypt ( s -> p , length , rdp ) ) { printf ( ""FATAL:cannotdecrypt\\n"" ) ; return FALSE ; } if ( ! security_fips_check_signature ( s -> p , length - pad , sig , rdp ) ) { printf ( ""FATAL:invalidpacketsignature\\n"" ) ; return FALSE ; } s -> size -= pad ; return TRUE ; } if ( stream_get_left ( s ) < 8 ) return FALSE ; stream_read ( s , wmac , sizeof ( wmac ) ) ; length -= sizeof ( wmac ) ; security_decrypt ( s -> p , length , rdp ) ; if ( securityFlags & SEC_SECURE_CHECKSUM ) security_salted_mac_signature ( rdp , s -> p , length , FALSE , cmac ) ; else security_mac_signature ( rdp , s -> p , length , cmac ) ; if ( memcmp ( wmac , cmac , sizeof ( wmac ) ) != 0 ) { printf ( ""WARNING:invalidpacketsignature\\n"" ) ; } return TRUE ; } "," wmac ) ; if ( ! , rdp ) ) return FALSE ",FreeRDP@FreeRDP/7d58aac24fe20ffaad7bd9b40c9ddf457c1b06e7,CVE-2013-4118,https://github.com/FreeRDP/FreeRDP/commit/7d58aac24fe20ffaad7bd9b40c9ddf457c1b06e7,2016-10-03T21:59Z 292,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 293,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 ++ ) { 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 ) ; 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 ; } "," 1 ) ; if ( nelements == 0 ) { DPRINTF ( ( ""CDF_VECTORwithnelements==0\\n"" ) ) ; goto out ; } j < nelements && i < sh . sh_properties ; j ++ , ",file@file/f97486ef5dc3e8735440edc4fc8808c63e1a3ef0,CVE-2014-0238,https://github.com/file/file/commit/f97486ef5dc3e8735440edc4fc8808c63e1a3ef0,2014-06-01T04:29Z 294,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 295,CWE-125,"CWE-125 static int jpc_pi_nextrpcl ( 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 r ; uint_fast32_t rpx ; uint_fast32_t rpy ; uint_fast32_t trx0 ; uint_fast32_t try0 ; 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 -> rlvlno = pchg -> rlvlnostart ; pi -> rlvlno < pchg -> rlvlnoend && pi -> rlvlno < pi -> maxrlvls ; ++ pi -> rlvlno ) { 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 < JAS_CAST ( int , pchg -> compnoend ) && pi -> compno < pi -> numcomps ; ++ pi -> compno , ++ pi -> picomp ) { if ( pi -> rlvlno >= pi -> picomp -> numrlvls ) { continue ; } pi -> pirlvl = & pi -> picomp -> pirlvls [ pi -> rlvlno ] ; if ( pi -> pirlvl -> numprcs == 0 ) { continue ; } r = pi -> picomp -> numrlvls - 1 - pi -> rlvlno ; rpx = r + pi -> pirlvl -> prcwidthexpn ; rpy = r + pi -> pirlvl -> prcheightexpn ; trx0 = JPC_CEILDIV ( pi -> xstart , pi -> picomp -> hsamp << r ) ; try0 = JPC_CEILDIV ( pi -> ystart , pi -> picomp -> vsamp << r ) ; if ( ( ( pi -> x == pi -> xstart && ( ( trx0 << r ) % ( 1 << rpx ) ) ) || ! ( pi -> x % ( 1 << rpx ) ) ) && ( ( pi -> y == pi -> ystart && ( ( try0 << r ) % ( 1 << rpy ) ) ) || ! ( pi -> y % ( 1 << 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 ) x % ( JAS_CAST ( uint_fast32_t , 1 ) << rpx ) ) % ( JAS_CAST ( uint_fast32_t , 1 ) << rpy ) y % ( JAS_CAST ( uint_fast32_t , 1 ) << rpy ) ",mdadams@jasper/aa0b0f79ade5eef8b0e7a214c03f5af54b36ba7d,CVE-2016-9583,https://github.com/mdadams/jasper/commit/aa0b0f79ade5eef8b0e7a214c03f5af54b36ba7d,2018-08-01T17:29Z 296,CWE-119,"CWE-119 void l2tp_packet_print ( const struct l2tp_packet_t * pack , void ( * print ) ( const char * fmt , ... ) ) { const struct l2tp_attr_t * attr ; const struct l2tp_dict_value_t * val ; if ( pack -> hdr . ver == 2 ) { print ( ""[L2TPtid=%usid=%u"" , ntohs ( pack -> hdr . tid ) , ntohs ( pack -> hdr . sid ) ) ; log_ppp_debug ( ""Ns=%uNr=%u"" , ntohs ( pack -> hdr . Ns ) , ntohs ( pack -> hdr . Nr ) ) ; } else { print ( ""[L2TPcid=%u"" , pack -> hdr . cid ) ; log_ppp_debug ( ""Ns=%uNr=%u"" , ntohs ( pack -> hdr . Ns ) , ntohs ( pack -> hdr . Nr ) ) ; } list_for_each_entry ( attr , & pack -> attrs , entry ) { print ( ""<%s"" , attr -> attr -> name ) ; val = l2tp_dict_find_value ( attr -> attr , attr -> val ) ; if ( val ) print ( ""%s"" , val -> name ) ; else if ( attr -> H ) print ( ""(hidden,%hubytes)"" , attr -> length ) ; else { switch ( attr -> attr -> type ) { case ATTR_TYPE_INT16 : print ( ""%i"" , attr -> val . int16 ) ; break ; case ATTR_TYPE_INT32 : print ( ""%i"" , attr -> val . int32 ) ; break ; case ATTR_TYPE_STRING : print ( ""%s"" , attr -> val . string ) ; break ; } } print ( "">"" ) ; } print ( ""]\\n"" ) ; } "," * val ; switch ( pack -> hdr . flags & L2TP_VER_MASK ) { case 2 : print ( ""[L2TPtid=%usid=%u"" ) ) ; break ; case 3 : print ( ""[L2TPcid=%u"" Nr ) ) ; break ; default : print ( ""[L2TPunknownversion]\\n"" ) ; return ",accel-ppp@accel-ppp/2324bcd5ba12cf28f47357a8f03cd41b7c04c52b,CVE-2020-15173,https://github.com/accel-ppp/accel-ppp/commit/2324bcd5ba12cf28f47357a8f03cd41b7c04c52b,2020-09-09T23:15Z 297,CWE-000,"CWE-000 krb5_error_code krb5_ldap_put_principal ( krb5_context context , krb5_db_entry * entry , char * * db_args ) { int l = 0 , kerberos_principal_object_type = 0 ; unsigned int ntrees = 0 , tre = 0 ; krb5_error_code st = 0 , tempst = 0 ; LDAP * ld = NULL ; LDAPMessage * result = NULL , * ent = NULL ; char * * subtreelist = NULL ; char * user = NULL , * subtree = NULL , * principal_dn = NULL ; char * * values = NULL , * strval [ 10 ] = { NULL } , errbuf [ 1024 ] ; char * filtuser = NULL ; struct berval * * bersecretkey = NULL ; LDAPMod * * mods = NULL ; krb5_boolean create_standalone_prinicipal = FALSE ; krb5_boolean krb_identity_exists = FALSE , establish_links = FALSE ; char * standalone_principal_dn = NULL ; krb5_tl_data * tl_data = NULL ; krb5_key_data * * keys = NULL ; kdb5_dal_handle * dal_handle = NULL ; krb5_ldap_context * ldap_context = NULL ; krb5_ldap_server_handle * ldap_server_handle = NULL ; osa_princ_ent_rec princ_ent = { 0 } ; xargs_t xargs = { 0 } ; char * polname = NULL ; OPERATION optype ; krb5_boolean found_entry = FALSE ; krb5_clear_error_message ( context ) ; SETUP_CONTEXT ( ) ; if ( ldap_context -> lrparams == NULL || ldap_context -> container_dn == NULL ) return EINVAL ; GET_HANDLE ( ) ; if ( ! is_principal_in_realm ( ldap_context , entry -> princ ) ) { st = EINVAL ; k5_setmsg ( context , st , _ ( ""Principaldoesnotbelongtothedefaultrealm"" ) ) ; goto cleanup ; } if ( ( ( st = krb5_unparse_name ( context , entry -> princ , & user ) ) != 0 ) || ( ( st = krb5_ldap_unparse_principal_name ( user ) ) != 0 ) ) goto cleanup ; filtuser = ldap_filter_correct ( user ) ; if ( filtuser == NULL ) { st = ENOMEM ; goto cleanup ; } if ( entry -> mask & KADM5_PRINCIPAL ) optype = ADD_PRINCIPAL ; else optype = MODIFY_PRINCIPAL ; if ( ( ( st = krb5_get_princ_type ( context , entry , & kerberos_principal_object_type ) ) != 0 ) || ( ( st = krb5_get_userdn ( context , entry , & principal_dn ) ) != 0 ) ) goto cleanup ; if ( ( st = process_db_args ( context , db_args , & xargs , optype ) ) != 0 ) goto cleanup ; if ( entry -> mask & KADM5_LOAD ) { unsigned int tree = 0 ; int numlentries = 0 ; char * filter = NULL ; if ( asprintf ( & filter , FILTER ""%s))"" , filtuser ) < 0 ) { filter = NULL ; st = ENOMEM ; goto cleanup ; } if ( ( st = krb5_get_subtree_info ( ldap_context , & subtreelist , & ntrees ) ) != 0 ) goto cleanup ; found_entry = FALSE ; for ( tree = 0 ; found_entry == FALSE && tree < ntrees ; ++ tree ) { if ( principal_dn == NULL ) { LDAP_SEARCH_1 ( subtreelist [ tree ] , ldap_context -> lrparams -> search_scope , filter , principal_attributes , IGNORE_STATUS ) ; } else { LDAP_SEARCH_1 ( principal_dn , LDAP_SCOPE_BASE , filter , principal_attributes , IGNORE_STATUS ) ; } if ( st == LDAP_SUCCESS ) { numlentries = ldap_count_entries ( ld , result ) ; if ( numlentries > 1 ) { free ( filter ) ; st = EINVAL ; k5_setmsg ( context , st , _ ( ""operationcannotcontinue,morethanone"" ""entrywithprincipalname\\""%s\\""found"" ) , user ) ; goto cleanup ; } else if ( numlentries == 1 ) { found_entry = TRUE ; if ( principal_dn == NULL ) { ent = ldap_first_entry ( ld , result ) ; if ( ent != NULL ) { if ( ( principal_dn = ldap_get_dn ( ld , ent ) ) == NULL ) { ldap_get_option ( ld , LDAP_OPT_RESULT_CODE , & st ) ; st = set_ldap_error ( context , st , 0 ) ; free ( filter ) ; goto cleanup ; } } } } } else if ( st != LDAP_NO_SUCH_OBJECT ) { st = set_ldap_error ( context , st , 0 ) ; free ( filter ) ; goto cleanup ; } ldap_msgfree ( result ) ; result = NULL ; } free ( filter ) ; if ( found_entry == FALSE && principal_dn != NULL ) { create_standalone_prinicipal = TRUE ; standalone_principal_dn = strdup ( principal_dn ) ; CHECK_NULL ( standalone_principal_dn ) ; } } if ( principal_dn == NULL && xargs . dn == NULL ) { if ( entry -> princ -> length == 2 && entry -> princ -> data [ 0 ] . length == strlen ( ""krbtgt"" ) && strncmp ( entry -> princ -> data [ 0 ] . data , ""krbtgt"" , entry -> princ -> data [ 0 ] . length ) == 0 ) { subtree = strdup ( ldap_context -> lrparams -> realmdn ) ; } else if ( xargs . containerdn ) { if ( ( st = checkattributevalue ( ld , xargs . containerdn , NULL , NULL , NULL ) ) != 0 ) { if ( st == KRB5_KDB_NOENTRY || st == KRB5_KDB_CONSTRAINT_VIOLATION ) { int ost = st ; st = EINVAL ; k5_prependmsg ( context , ost , st , _ ( ""\'%s\'notfound"" ) , xargs . containerdn ) ; } goto cleanup ; } subtree = strdup ( xargs . containerdn ) ; } else if ( ldap_context -> lrparams -> containerref && strlen ( ldap_context -> lrparams -> containerref ) != 0 ) { subtree = strdup ( ldap_context -> lrparams -> containerref ) ; } else { subtree = strdup ( ldap_context -> lrparams -> realmdn ) ; } CHECK_NULL ( subtree ) ; if ( asprintf ( & standalone_principal_dn , ""krbprincipalname=%s,%s"" , filtuser , subtree ) < 0 ) standalone_principal_dn = NULL ; CHECK_NULL ( standalone_principal_dn ) ; create_standalone_prinicipal = TRUE ; free ( subtree ) ; subtree = NULL ; } if ( xargs . dn_from_kbd == TRUE ) { int dnlen = 0 , subtreelen = 0 ; char * dn = NULL ; krb5_boolean outofsubtree = TRUE ; if ( xargs . dn != NULL ) { dn = xargs . dn ; } else if ( xargs . linkdn != NULL ) { dn = xargs . linkdn ; } else if ( standalone_principal_dn != NULL ) { dn = standalone_principal_dn ; } if ( subtreelist == NULL ) { st = krb5_get_subtree_info ( ldap_context , & subtreelist , & ntrees ) ; if ( st ) goto cleanup ; } for ( tre = 0 ; tre < ntrees ; ++ tre ) { if ( subtreelist [ tre ] == NULL || strlen ( subtreelist [ tre ] ) == 0 ) { outofsubtree = FALSE ; break ; } else { dnlen = strlen ( dn ) ; subtreelen = strlen ( subtreelist [ tre ] ) ; if ( ( dnlen >= subtreelen ) && ( strcasecmp ( ( dn + dnlen - subtreelen ) , subtreelist [ tre ] ) == 0 ) ) { outofsubtree = FALSE ; break ; } } } if ( outofsubtree == TRUE ) { st = EINVAL ; k5_setmsg ( context , st , _ ( ""DNisoutoftherealmsubtree"" ) ) ; goto cleanup ; } if ( standalone_principal_dn == NULL ) { char * attributes [ ] = { ""krbticketpolicyreference"" , ""krbprincipalname"" , NULL } ; ldap_msgfree ( result ) ; result = NULL ; LDAP_SEARCH_1 ( dn , LDAP_SCOPE_BASE , 0 , attributes , IGNORE_STATUS ) ; if ( st == LDAP_SUCCESS ) { ent = ldap_first_entry ( ld , result ) ; if ( ent != NULL ) { if ( ( values = ldap_get_values ( ld , ent , ""krbticketpolicyreference"" ) ) != NULL ) { ldap_value_free ( values ) ; } if ( ( values = ldap_get_values ( ld , ent , ""krbprincipalname"" ) ) != NULL ) { krb_identity_exists = TRUE ; ldap_value_free ( values ) ; } } } else { st = set_ldap_error ( context , st , OP_SEARCH ) ; goto cleanup ; } } } if ( xargs . dn != NULL && krb_identity_exists == TRUE ) { st = EINVAL ; snprintf ( errbuf , sizeof ( errbuf ) , _ ( ""ldapobjectisalreadykerberized"" ) ) ; k5_setmsg ( context , st , ""%s"" , errbuf ) ; goto cleanup ; } if ( xargs . linkdn != NULL ) { if ( optype == MODIFY_PRINCIPAL && kerberos_principal_object_type != KDB_STANDALONE_PRINCIPAL_OBJECT ) { st = EINVAL ; snprintf ( errbuf , sizeof ( errbuf ) , _ ( ""linkinformationcannotbeset/updatedasthe"" ""kerberosprincipalbelongstoanldapobject"" ) ) ; k5_setmsg ( context , st , ""%s"" , errbuf ) ; goto cleanup ; } { char * * linkdns = NULL ; int j = 0 ; if ( ( st = krb5_get_linkdn ( context , entry , & linkdns ) ) != 0 ) { snprintf ( errbuf , sizeof ( errbuf ) , _ ( ""Failedgettingobjectreferences"" ) ) ; k5_setmsg ( context , st , ""%s"" , errbuf ) ; goto cleanup ; } if ( linkdns != NULL ) { st = EINVAL ; snprintf ( errbuf , sizeof ( errbuf ) , _ ( ""kerberosprincipalisalreadylinkedtoaldap"" ""object"" ) ) ; k5_setmsg ( context , st , ""%s"" , errbuf ) ; for ( j = 0 ; linkdns [ j ] != NULL ; ++ j ) free ( linkdns [ j ] ) ; free ( linkdns ) ; goto cleanup ; } } establish_links = TRUE ; } if ( entry -> mask & KADM5_LAST_SUCCESS ) { memset ( strval , 0 , sizeof ( strval ) ) ; if ( ( strval [ 0 ] = getstringtime ( entry -> last_success ) ) == NULL ) goto cleanup ; if ( ( st = krb5_add_str_mem_ldap_mod ( & mods , ""krbLastSuccessfulAuth"" , LDAP_MOD_REPLACE , strval ) ) != 0 ) { free ( strval [ 0 ] ) ; goto cleanup ; } free ( strval [ 0 ] ) ; } if ( entry -> mask & KADM5_LAST_FAILED ) { memset ( strval , 0 , sizeof ( strval ) ) ; if ( ( strval [ 0 ] = getstringtime ( entry -> last_failed ) ) == NULL ) goto cleanup ; if ( ( st = krb5_add_str_mem_ldap_mod ( & mods , ""krbLastFailedAuth"" , LDAP_MOD_REPLACE , strval ) ) != 0 ) { free ( strval [ 0 ] ) ; goto cleanup ; } free ( strval [ 0 ] ) ; } if ( entry -> mask & KADM5_FAIL_AUTH_COUNT ) { krb5_kvno fail_auth_count ; fail_auth_count = entry -> fail_auth_count ; if ( entry -> mask & KADM5_FAIL_AUTH_COUNT_INCREMENT ) fail_auth_count ++ ; st = krb5_add_int_mem_ldap_mod ( & mods , ""krbLoginFailedCount"" , LDAP_MOD_REPLACE , fail_auth_count ) ; if ( st != 0 ) goto cleanup ; } else if ( entry -> mask & KADM5_FAIL_AUTH_COUNT_INCREMENT ) { int attr_mask = 0 ; krb5_boolean has_fail_count ; st = krb5_get_attributes_mask ( context , entry , & attr_mask ) ; if ( st != 0 ) goto cleanup ; has_fail_count = ( ( attr_mask & KDB_FAIL_AUTH_COUNT_ATTR ) != 0 ) ; # ifdef LDAP_MOD_INCREMENT if ( ldap_server_handle -> server_info -> modify_increment && has_fail_count ) { st = krb5_add_int_mem_ldap_mod ( & mods , ""krbLoginFailedCount"" , LDAP_MOD_INCREMENT , 1 ) ; if ( st != 0 ) goto cleanup ; } else { # endif if ( has_fail_count ) { st = krb5_add_int_mem_ldap_mod ( & mods , ""krbLoginFailedCount"" , LDAP_MOD_DELETE , entry -> fail_auth_count ) ; if ( st != 0 ) goto cleanup ; } st = krb5_add_int_mem_ldap_mod ( & mods , ""krbLoginFailedCount"" , LDAP_MOD_ADD , entry -> fail_auth_count + 1 ) ; if ( st != 0 ) goto cleanup ; # ifdef LDAP_MOD_INCREMENT } # endif } else if ( optype == ADD_PRINCIPAL ) { st = krb5_add_int_mem_ldap_mod ( & mods , ""krbLoginFailedCount"" , LDAP_MOD_ADD , 0 ) ; } if ( entry -> mask & KADM5_MAX_LIFE ) { if ( ( st = krb5_add_int_mem_ldap_mod ( & mods , ""krbmaxticketlife"" , LDAP_MOD_REPLACE , entry -> max_life ) ) != 0 ) goto cleanup ; } if ( entry -> mask & KADM5_MAX_RLIFE ) { if ( ( st = krb5_add_int_mem_ldap_mod ( & mods , ""krbmaxrenewableage"" , LDAP_MOD_REPLACE , entry -> max_renewable_life ) ) != 0 ) goto cleanup ; } if ( entry -> mask & KADM5_ATTRIBUTES ) { if ( ( st = krb5_add_int_mem_ldap_mod ( & mods , ""krbticketflags"" , LDAP_MOD_REPLACE , entry -> attributes ) ) != 0 ) goto cleanup ; } if ( entry -> mask & KADM5_PRINCIPAL ) { memset ( strval , 0 , sizeof ( strval ) ) ; strval [ 0 ] = user ; if ( ( st = krb5_add_str_mem_ldap_mod ( & mods , ""krbprincipalname"" , LDAP_MOD_REPLACE , strval ) ) != 0 ) goto cleanup ; } if ( entry -> mask & KADM5_PRINC_EXPIRE_TIME ) { memset ( strval , 0 , sizeof ( strval ) ) ; if ( ( strval [ 0 ] = getstringtime ( entry -> expiration ) ) == NULL ) goto cleanup ; if ( ( st = krb5_add_str_mem_ldap_mod ( & mods , ""krbprincipalexpiration"" , LDAP_MOD_REPLACE , strval ) ) != 0 ) { free ( strval [ 0 ] ) ; goto cleanup ; } free ( strval [ 0 ] ) ; } if ( entry -> mask & KADM5_PW_EXPIRATION ) { memset ( strval , 0 , sizeof ( strval ) ) ; if ( ( strval [ 0 ] = getstringtime ( entry -> pw_expiration ) ) == NULL ) goto cleanup ; if ( ( st = krb5_add_str_mem_ldap_mod ( & mods , ""krbpasswordexpiration"" , LDAP_MOD_REPLACE , strval ) ) != 0 ) { free ( strval [ 0 ] ) ; goto cleanup ; } free ( strval [ 0 ] ) ; } if ( entry -> mask & KADM5_POLICY ) { memset ( & princ_ent , 0 , sizeof ( princ_ent ) ) ; for ( tl_data = entry -> tl_data ; tl_data ; tl_data = tl_data -> tl_data_next ) { if ( tl_data -> tl_data_type == KRB5_TL_KADM_DATA ) { if ( ( st = krb5_lookup_tl_kadm_data ( tl_data , & princ_ent ) ) != 0 ) { goto cleanup ; } break ; } } if ( princ_ent . aux_attributes & KADM5_POLICY ) { memset ( strval , 0 , sizeof ( strval ) ) ; if ( ( st = krb5_ldap_name_to_policydn ( context , princ_ent . policy , & polname ) ) != 0 ) goto cleanup ; strval [ 0 ] = polname ; if ( ( st = krb5_add_str_mem_ldap_mod ( & mods , ""krbpwdpolicyreference"" , LDAP_MOD_REPLACE , strval ) ) != 0 ) goto cleanup ; } else { st = EINVAL ; k5_setmsg ( context , st , ""Passwordpolicyvaluenull"" ) ; goto cleanup ; } } else if ( entry -> mask & KADM5_LOAD && found_entry == TRUE ) { if ( ( st = krb5_add_str_mem_ldap_mod ( & mods , ""krbpwdpolicyreference"" , LDAP_MOD_REPLACE , NULL ) ) != 0 ) goto cleanup ; } if ( entry -> mask & KADM5_POLICY_CLR ) { if ( ( st = krb5_add_str_mem_ldap_mod ( & mods , ""krbpwdpolicyreference"" , LDAP_MOD_DELETE , NULL ) ) != 0 ) goto cleanup ; } if ( entry -> mask & KADM5_KEY_DATA || entry -> mask & KADM5_KVNO ) { krb5_kvno mkvno ; if ( ( st = krb5_dbe_lookup_mkvno ( context , entry , & mkvno ) ) != 0 ) goto cleanup ; bersecretkey = krb5_encode_krbsecretkey ( entry -> key_data , entry -> n_key_data , mkvno ) ; if ( ( st = krb5_add_ber_mem_ldap_mod ( & mods , ""krbprincipalkey"" , LDAP_MOD_REPLACE | LDAP_MOD_BVALUES , bersecretkey ) ) != 0 ) goto cleanup ; if ( ! ( entry -> mask & KADM5_PRINCIPAL ) ) { memset ( strval , 0 , sizeof ( strval ) ) ; if ( ( strval [ 0 ] = getstringtime ( entry -> pw_expiration ) ) == NULL ) goto cleanup ; if ( ( st = krb5_add_str_mem_ldap_mod ( & mods , ""krbpasswordexpiration"" , LDAP_MOD_REPLACE , strval ) ) != 0 ) { free ( strval [ 0 ] ) ; goto cleanup ; } free ( strval [ 0 ] ) ; } { krb5_timestamp last_pw_changed ; if ( ( st = krb5_dbe_lookup_last_pwd_change ( context , entry , & last_pw_changed ) ) != 0 ) goto cleanup ; memset ( strval , 0 , sizeof ( strval ) ) ; if ( ( strval [ 0 ] = getstringtime ( last_pw_changed ) ) == NULL ) goto cleanup ; if ( ( st = krb5_add_str_mem_ldap_mod ( & mods , ""krbLastPwdChange"" , LDAP_MOD_REPLACE , strval ) ) != 0 ) { free ( strval [ 0 ] ) ; goto cleanup ; } free ( strval [ 0 ] ) ; } } if ( entry -> tl_data != NULL ) { int count = 0 ; struct berval * * ber_tl_data = NULL ; krb5_tl_data * ptr ; krb5_timestamp unlock_time ; for ( ptr = entry -> tl_data ; ptr != NULL ; ptr = ptr -> tl_data_next ) { if ( ptr -> tl_data_type == KRB5_TL_LAST_PWD_CHANGE # ifdef SECURID || ptr -> tl_data_type == KRB5_TL_DB_ARGS # endif || ptr -> tl_data_type == KRB5_TL_KADM_DATA || ptr -> tl_data_type == KDB_TL_USER_INFO || ptr -> tl_data_type == KRB5_TL_CONSTRAINED_DELEGATION_ACL || ptr -> tl_data_type == KRB5_TL_LAST_ADMIN_UNLOCK ) continue ; count ++ ; } if ( count != 0 ) { int j ; ber_tl_data = ( struct berval * * ) calloc ( count + 1 , sizeof ( struct berval * ) ) ; if ( ber_tl_data == NULL ) { st = ENOMEM ; goto cleanup ; } for ( j = 0 , ptr = entry -> tl_data ; ptr != NULL ; ptr = ptr -> tl_data_next ) { if ( ptr -> tl_data_type == KRB5_TL_LAST_PWD_CHANGE # ifdef SECURID || ptr -> tl_data_type == KRB5_TL_DB_ARGS # endif || ptr -> tl_data_type == KRB5_TL_KADM_DATA || ptr -> tl_data_type == KDB_TL_USER_INFO || ptr -> tl_data_type == KRB5_TL_CONSTRAINED_DELEGATION_ACL || ptr -> tl_data_type == KRB5_TL_LAST_ADMIN_UNLOCK ) continue ; if ( ( st = tl_data2berval ( ptr , & ber_tl_data [ j ] ) ) != 0 ) break ; j ++ ; } if ( st == 0 ) { ber_tl_data [ count ] = NULL ; st = krb5_add_ber_mem_ldap_mod ( & mods , ""krbExtraData"" , LDAP_MOD_REPLACE | LDAP_MOD_BVALUES , ber_tl_data ) ; } for ( j = 0 ; ber_tl_data [ j ] != NULL ; j ++ ) { free ( ber_tl_data [ j ] -> bv_val ) ; free ( ber_tl_data [ j ] ) ; } free ( ber_tl_data ) ; if ( st != 0 ) goto cleanup ; } if ( ( st = krb5_dbe_lookup_last_admin_unlock ( context , entry , & unlock_time ) ) != 0 ) goto cleanup ; if ( unlock_time != 0 ) { memset ( strval , 0 , sizeof ( strval ) ) ; if ( ( strval [ 0 ] = getstringtime ( unlock_time ) ) == NULL ) goto cleanup ; if ( ( st = krb5_add_str_mem_ldap_mod ( & mods , ""krbLastAdminUnlock"" , LDAP_MOD_REPLACE , strval ) ) != 0 ) { free ( strval [ 0 ] ) ; goto cleanup ; } free ( strval [ 0 ] ) ; } } if ( xargs . tktpolicydn != NULL ) { int tmask = 0 ; if ( strlen ( xargs . tktpolicydn ) != 0 ) { st = checkattributevalue ( ld , xargs . tktpolicydn , ""objectclass"" , policyclass , & tmask ) ; CHECK_CLASS_VALIDITY ( st , tmask , _ ( ""ticketpolicyobjectvalue:"" ) ) ; strval [ 0 ] = xargs . tktpolicydn ; strval [ 1 ] = NULL ; if ( ( st = krb5_add_str_mem_ldap_mod ( & mods , ""krbticketpolicyreference"" , LDAP_MOD_REPLACE , strval ) ) != 0 ) goto cleanup ; } else { if ( ( st = krb5_add_str_mem_ldap_mod ( & mods , ""krbticketpolicyreference"" , LDAP_MOD_DELETE , NULL ) ) != 0 ) goto cleanup ; } } if ( establish_links == TRUE ) { memset ( strval , 0 , sizeof ( strval ) ) ; strval [ 0 ] = xargs . linkdn ; if ( ( st = krb5_add_str_mem_ldap_mod ( & mods , ""krbObjectReferences"" , LDAP_MOD_REPLACE , strval ) ) != 0 ) goto cleanup ; } if ( mods == NULL ) goto cleanup ; if ( create_standalone_prinicipal == TRUE ) { memset ( strval , 0 , sizeof ( strval ) ) ; strval [ 0 ] = ""krbprincipal"" ; strval [ 1 ] = ""krbprincipalaux"" ; strval [ 2 ] = ""krbTicketPolicyAux"" ; if ( ( st = krb5_add_str_mem_ldap_mod ( & mods , ""objectclass"" , LDAP_MOD_ADD , strval ) ) != 0 ) goto cleanup ; st = ldap_add_ext_s ( ld , standalone_principal_dn , mods , NULL , NULL ) ; if ( st == LDAP_ALREADY_EXISTS && entry -> mask & KADM5_LOAD ) { st = ldap_delete_ext_s ( ld , standalone_principal_dn , NULL , NULL ) ; if ( st != LDAP_SUCCESS ) { snprintf ( errbuf , sizeof ( errbuf ) , _ ( ""Principaldeletefailed(tryingtoreplace"" ""entry):%s"" ) , ldap_err2string ( st ) ) ; st = translate_ldap_error ( st , OP_ADD ) ; k5_setmsg ( context , st , ""%s"" , errbuf ) ; goto cleanup ; } else { st = ldap_add_ext_s ( ld , standalone_principal_dn , mods , NULL , NULL ) ; } } if ( st != LDAP_SUCCESS ) { snprintf ( errbuf , sizeof ( errbuf ) , _ ( ""Principaladdfailed:%s"" ) , ldap_err2string ( st ) ) ; st = translate_ldap_error ( st , OP_ADD ) ; k5_setmsg ( context , st , ""%s"" , errbuf ) ; goto cleanup ; } } else { { char * attrvalues [ ] = { ""krbprincipalaux"" , ""krbTicketPolicyAux"" , NULL } ; int p , q , r = 0 , amask = 0 ; if ( ( st = checkattributevalue ( ld , ( xargs . dn ) ? xargs . dn : principal_dn , ""objectclass"" , attrvalues , & amask ) ) != 0 ) goto cleanup ; memset ( strval , 0 , sizeof ( strval ) ) ; for ( p = 1 , q = 0 ; p <= 2 ; p <<= 1 , ++ q ) { if ( ( p & amask ) == 0 ) strval [ r ++ ] = attrvalues [ q ] ; } if ( r != 0 ) { if ( ( st = krb5_add_str_mem_ldap_mod ( & mods , ""objectclass"" , LDAP_MOD_ADD , strval ) ) != 0 ) goto cleanup ; } } if ( xargs . dn != NULL ) st = ldap_modify_ext_s ( ld , xargs . dn , mods , NULL , NULL ) ; else st = ldap_modify_ext_s ( ld , principal_dn , mods , NULL , NULL ) ; if ( st != LDAP_SUCCESS ) { snprintf ( errbuf , sizeof ( errbuf ) , _ ( ""Usermodificationfailed:%s"" ) , ldap_err2string ( st ) ) ; st = translate_ldap_error ( st , OP_MOD ) ; k5_setmsg ( context , st , ""%s"" , errbuf ) ; goto cleanup ; } if ( entry -> mask & KADM5_FAIL_AUTH_COUNT_INCREMENT ) entry -> fail_auth_count ++ ; } cleanup : if ( user ) free ( user ) ; if ( filtuser ) free ( filtuser ) ; free_xargs ( xargs ) ; if ( standalone_principal_dn ) free ( standalone_principal_dn ) ; if ( principal_dn ) free ( principal_dn ) ; if ( polname != NULL ) free ( polname ) ; for ( tre = 0 ; tre < ntrees ; tre ++ ) free ( subtreelist [ tre ] ) ; free ( subtreelist ) ; if ( subtree ) free ( subtree ) ; if ( bersecretkey ) { for ( l = 0 ; bersecretkey [ l ] ; ++ l ) { if ( bersecretkey [ l ] -> bv_val ) free ( bersecretkey [ l ] -> bv_val ) ; free ( bersecretkey [ l ] ) ; } free ( bersecretkey ) ; } if ( keys ) free ( keys ) ; ldap_mods_free ( mods , 1 ) ; ldap_osa_free_princ_ent ( & princ_ent ) ; ldap_msgfree ( result ) ; krb5_ldap_put_handle_to_pool ( ldap_context , ldap_server_handle ) ; return ( st ) ; } "," ; if ( bersecretkey == NULL ) { st = ENOMEM ; goto cleanup ; } if ( bersecretkey [ 0 ] != NULL || ! create_standalone_prinicipal ) { st = krb5_add_ber_mem_ldap_mod , bersecretkey ) ; if ( st != 0 ) goto cleanup ; } if ( ! ",krb5@krb5/04038bf3633c4b909b5ded3072dc88c8c419bf16,CVE-2014-5354,https://github.com/krb5/krb5/commit/04038bf3633c4b909b5ded3072dc88c8c419bf16,2014-12-16T23:59Z 298,CWE-000,"CWE-000 static void usage ( void ) { PRINT_VERSION ; puts ( ""Copyright(c)2011,Oracleand/oritsaffiliates."" ""Allrightsreserved.\\n"" ) ; puts ( ""Enableordisableplugins."" ) ; printf ( ""\\nUsage:%s[options]ENABLE|DISABLE\\n\\nOptions:\\n"" , my_progname ) ; my_print_help ( my_long_options ) ; puts ( ""\\n"" ) ; } "," ; puts ( ""Copyright(c)2011,2015,Oracleand/oritsaffiliates."" ""Allrightsreserved.\\n"" ) ; ",mysql@mysql-server/0dbd5a8797ed4bd18e8b883988fb62177eb0f73f,CVE-2016-0546,https://github.com/mysql/mysql-server/commit/0dbd5a8797ed4bd18e8b883988fb62177eb0f73f,2016-01-21T03:01Z 299,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 300,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 301,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 302,CWE-787,"CWE-787 static OPJ_BOOL opj_j2k_write_sot ( opj_j2k_t * p_j2k , OPJ_BYTE * p_data , OPJ_UINT32 * p_data_written , const opj_stream_private_t * p_stream , opj_event_mgr_t * p_manager ) { assert ( p_j2k != 00 ) ; assert ( p_manager != 00 ) ; assert ( p_stream != 00 ) ; OPJ_UNUSED ( p_stream ) ; OPJ_UNUSED ( p_manager ) ; opj_write_bytes ( p_data , J2K_MS_SOT , 2 ) ; p_data += 2 ; opj_write_bytes ( p_data , 10 , 2 ) ; p_data += 2 ; opj_write_bytes ( p_data , p_j2k -> m_current_tile_number , 2 ) ; p_data += 2 ; p_data += 4 ; opj_write_bytes ( p_data , p_j2k -> m_specific_param . m_encoder . m_current_tile_part_number , 1 ) ; ++ p_data ; opj_write_bytes ( p_data , p_j2k -> m_cp . tcps [ p_j2k -> m_current_tile_number ] . m_nb_tile_parts , 1 ) ; ++ p_data ; # ifdef USE_JPWL assert ( 0 && ""TODO"" ) ; # endif * p_data_written = 12 ; return OPJ_TRUE ; } "," p_data , OPJ_UINT32 p_total_data_size , OPJ_UINT32 p_manager ) ; if ( p_total_data_size < 12 ) { opj_event_msg ( p_manager , EVT_ERROR , ""NotenoughbytesinoutputbuffertowriteSOTmarker\\n"" ) ; return OPJ_FALSE ; } ",uclouvain@openjpeg/dcac91b8c72f743bda7dbfa9032356bc8110098a,CVE-2017-14164,https://github.com/uclouvain/openjpeg/commit/dcac91b8c72f743bda7dbfa9032356bc8110098a,2017-09-06T18:29Z 303,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 304,CWE-000,"CWE-000 static int kvm_vm_ioctl_set_pit ( struct kvm * kvm , struct kvm_pit_state * ps ) { mutex_lock ( & kvm -> arch . vpit -> pit_state . lock ) ; memcpy ( & kvm -> arch . vpit -> pit_state , ps , sizeof ( struct kvm_pit_state ) ) ; kvm_pit_load_count ( kvm , 0 , ps -> channels [ 0 ] . count , 0 ) ; mutex_unlock ( & kvm -> arch . vpit -> pit_state . lock ) ; return 0 ; } "," ps ) { int i ; ) ) ; for ( i = 0 ; i < 3 ; i ++ ) ( kvm , i , ps -> -> channels [ i ] . count ",torvalds@linux/0185604c2d82c560dab2f2933a18f797e74ab5a8,CVE-2015-7513,https://github.com/torvalds/linux/commit/0185604c2d82c560dab2f2933a18f797e74ab5a8,2016-02-08T03:59Z 305,CWE-20,"CWE-20 void sink ( int argc , char * * argv , const char * src ) { static BUF buffer ; struct stat stb ; 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 , wrerr ; 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 = 0 ; 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 ) { if ( atomicio ( vwrite , ofd , bp -> buf , count ) != count ) { note_err ( ""%s:%s"" , np , strerror ( errno ) ) ; wrerr = 1 ; } } count = 0 ; cp = bp -> buf ; } } unset_nonblock ( remin ) ; if ( count != 0 && ! wrerr && atomicio ( vwrite , ofd , bp -> buf , count ) != count ) { note_err ( ""%s:%s"" , np , strerror ( errno ) ) ; wrerr = 1 ; } if ( ! wrerr && ( ! exists || S_ISREG ( stb . st_mode ) ) && ftruncate ( ofd , size ) != 0 ) note_err ( ""%s:truncate:%s"" , np , strerror ( errno ) ) ; if ( pflag ) { if ( exists || omode != mode ) # ifdef HAVE_FCHMOD if ( fchmod ( ofd , omode ) ) { # else if ( chmod ( np , omode ) ) { # endif note_err ( ""%s:setmode:%s"" , np , strerror ( errno ) ) ; } } else { if ( ! exists && omode != mode ) # ifdef HAVE_FCHMOD if ( fchmod ( ofd , omode & ~ mask ) ) { # else if ( chmod ( np , omode & ~ mask ) ) { # endif note_err ( ""%s:setmode:%s"" , np , strerror ( errno ) ) ; } } if ( close ( ofd ) == - 1 ) note_err ( np , ""%s:close:%s"" , np , strerror ( errno ) ) ; ( void ) response ( ) ; if ( showprogress ) stop_progress_meter ( ) ; if ( setimes && ! wrerr ) { setimes = 0 ; if ( utimes ( np , tv ) == - 1 ) { note_err ( ""%s:settimes:%s"" , np , strerror ( errno ) ) ; } } if ( note_err ( NULL ) == 0 ) ( void ) atomicio ( vwrite , remout , """" , 1 ) ; } 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 ) ; } "," = 0 ; ( void ) utimes ( vect ] , tv ) ; } ",openssh@openssh-portable/955854cafca88e0cdcd3d09ca1ad4ada465364a1,CVE-2020-12062,https://github.com/openssh/openssh-portable/commit/955854cafca88e0cdcd3d09ca1ad4ada465364a1,2020-06-01T16:15Z 306,CWE-200,"CWE-200 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 ; } 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 ; } m -> msg_namelen = 0 ; ",torvalds@linux/60085c3d009b0df252547adb336d1ccca5ce52ec,CVE-2013-3235,https://github.com/torvalds/linux/commit/60085c3d009b0df252547adb336d1ccca5ce52ec,2013-04-22T11:41Z 307,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 308,CWE-119,"CWE-119 static void do_ssh2_kex ( void ) { char * myproposal [ PROPOSAL_MAX ] = { KEX_SERVER } ; struct kex * kex ; int r ; myproposal [ PROPOSAL_KEX_ALGS ] = compat_kex_proposal ( options . kex_algorithms ) ; myproposal [ PROPOSAL_ENC_ALGS_CTOS ] = compat_cipher_proposal ( options . ciphers ) ; myproposal [ PROPOSAL_ENC_ALGS_STOC ] = compat_cipher_proposal ( options . ciphers ) ; myproposal [ PROPOSAL_MAC_ALGS_CTOS ] = myproposal [ PROPOSAL_MAC_ALGS_STOC ] = options . macs ; if ( options . compression == COMP_NONE ) { myproposal [ PROPOSAL_COMP_ALGS_CTOS ] = myproposal [ PROPOSAL_COMP_ALGS_STOC ] = ""none"" ; } else if ( options . compression == COMP_DELAYED ) { myproposal [ PROPOSAL_COMP_ALGS_CTOS ] = myproposal [ PROPOSAL_COMP_ALGS_STOC ] = ""none,zlib@openssh.com"" ; } if ( options . rekey_limit || options . rekey_interval ) packet_set_rekey_limits ( options . rekey_limit , ( time_t ) options . rekey_interval ) ; myproposal [ PROPOSAL_SERVER_HOST_KEY_ALGS ] = compat_pkalg_proposal ( list_hostkey_types ( ) ) ; if ( ( r = kex_setup ( active_state , myproposal ) ) != 0 ) fatal ( ""kex_setup:%s"" , ssh_err ( r ) ) ; kex = active_state -> kex ; # ifdef WITH_OPENSSL kex -> kex [ KEX_DH_GRP1_SHA1 ] = kexdh_server ; kex -> kex [ KEX_DH_GRP14_SHA1 ] = kexdh_server ; kex -> kex [ KEX_DH_GRP14_SHA256 ] = kexdh_server ; kex -> kex [ KEX_DH_GRP16_SHA512 ] = kexdh_server ; kex -> kex [ KEX_DH_GRP18_SHA512 ] = kexdh_server ; kex -> kex [ KEX_DH_GEX_SHA1 ] = kexgex_server ; kex -> kex [ KEX_DH_GEX_SHA256 ] = kexgex_server ; kex -> kex [ KEX_ECDH_SHA2 ] = kexecdh_server ; # endif kex -> kex [ KEX_C25519_SHA256 ] = kexc25519_server ; kex -> server = 1 ; kex -> client_version_string = client_version_string ; kex -> server_version_string = server_version_string ; kex -> load_host_public_key = & get_hostkey_public_by_type ; kex -> load_host_private_key = & get_hostkey_private_by_type ; kex -> host_key_index = & get_hostkey_index ; kex -> sign = sshd_hostkey_sign ; dispatch_run ( DISPATCH_BLOCK , & kex -> done , active_state ) ; session_id2 = kex -> session_id ; session_id2_len = kex -> session_id_len ; # ifdef DEBUG_KEXDH packet_start ( SSH2_MSG_IGNORE ) ; packet_put_cstring ( ""markus"" ) ; packet_send ( ) ; packet_write_wait ( ) ; # endif debug ( ""KEXdone"" ) ; } "," ""none"" ; } if ( options ",openbsd@src/3095060f479b86288e31c79ecbc5131a66bcd2f9,CVE-2016-10012,https://github.com/openbsd/src/commit/3095060f479b86288e31c79ecbc5131a66bcd2f9,2017-01-05T02:59Z 309,CWE-416,"CWE-416 void ip4_datagram_release_cb ( struct sock * sk ) { const struct inet_sock * inet = inet_sk ( sk ) ; const struct ip_options_rcu * inet_opt ; __be32 daddr = inet -> inet_daddr ; struct flowi4 fl4 ; struct rtable * rt ; if ( ! __sk_dst_get ( sk ) || __sk_dst_check ( sk , 0 ) ) return ; rcu_read_lock ( ) ; inet_opt = rcu_dereference ( inet -> inet_opt ) ; if ( inet_opt && inet_opt -> opt . srr ) daddr = inet_opt -> opt . faddr ; rt = ip_route_output_ports ( sock_net ( sk ) , & fl4 , 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 ) ) __sk_dst_set ( sk , & rt -> dst ) ; rcu_read_unlock ( ) ; } "," inet_daddr ; struct dst_entry * dst ; struct * rt ; rcu_read_lock ( ) ; dst = __sk_dst_get ( sk ) ; if ( ! dst || ! dst -> obsolete || dst -> ops -> check ( dst , 0 ) 0 ) ) { rcu_read_unlock ( ) ; return ; } inet_opt = rcu_dereference sk_bound_dev_if ) ; dst = ! IS_ERR ( ( rt ) ? & rt -> & rt -> dst : NULL ; sk_dst_set ( sk , ",torvalds@linux/9709674e68646cee5a24e3000b3558d25412203a,CVE-2014-9914,https://github.com/torvalds/linux/commit/9709674e68646cee5a24e3000b3558d25412203a,2017-02-07T07:59Z 310,CWE-416,"CWE-416 struct snd_seq_client_port * snd_seq_create_port ( struct snd_seq_client * client , int port ) { unsigned long flags ; struct snd_seq_client_port * new_port , * p ; int num = - 1 ; if ( snd_BUG_ON ( ! client ) ) return NULL ; if ( client -> num_ports >= SNDRV_SEQ_MAX_PORTS ) { pr_warn ( ""ALSA:seq:toomanyportsforclient%d\\n"" , client -> number ) ; return NULL ; } new_port = kzalloc ( sizeof ( * new_port ) , GFP_KERNEL ) ; if ( ! new_port ) return NULL ; new_port -> addr . client = client -> number ; new_port -> addr . port = - 1 ; new_port -> owner = THIS_MODULE ; sprintf ( new_port -> name , ""port-%d"" , num ) ; snd_use_lock_init ( & new_port -> use_lock ) ; port_subs_info_init ( & new_port -> c_src ) ; port_subs_info_init ( & new_port -> c_dest ) ; num = port >= 0 ? port : 0 ; mutex_lock ( & client -> ports_mutex ) ; write_lock_irqsave ( & client -> ports_lock , flags ) ; list_for_each_entry ( p , & client -> ports_list_head , list ) { if ( p -> addr . port > num ) break ; if ( port < 0 ) num = p -> addr . port + 1 ; } list_add_tail ( & new_port -> list , & p -> list ) ; client -> num_ports ++ ; new_port -> addr . port = num ; write_unlock_irqrestore ( & client -> ports_lock , flags ) ; mutex_unlock ( & client -> ports_mutex ) ; sprintf ( new_port -> name , ""port-%d"" , num ) ; return new_port ; } "," c_dest ) ; snd_use_lock_use ( & new_port -> use_lock ) ; = num ; sprintf ( new_port -> name , ""port-%d"" , num ) ; client -> ports_mutex ) ; return ",torvalds@linux/71105998845fb012937332fe2e806d443c09e026,CVE-2017-15265,https://github.com/torvalds/linux/commit/71105998845fb012937332fe2e806d443c09e026,2017-10-16T18:29Z 311,CWE-119,"CWE-119 static int get_registers ( rtl8150_t * dev , u16 indx , u16 size , void * data ) { return usb_control_msg ( dev -> udev , usb_rcvctrlpipe ( dev -> udev , 0 ) , RTL8150_REQ_GET_REGS , RTL8150_REQT_READ , indx , 0 , data , size , 500 ) ; } "," data ) { void * buf ; int ret ; buf = kmalloc ( size , GFP_NOIO ) ; if ( ! buf ) return - ENOMEM ; ret = usb_control_msg ( dev , 0 , buf , size , 500 ) ; if ( ret > 0 && ret <= size ) memcpy ( data , buf , ret ) ; kfree ( buf ) ; return ret ; ",torvalds@linux/7926aff5c57b577ab0f43364ff0c59d968f6a414,CVE-2017-8069,https://github.com/torvalds/linux/commit/7926aff5c57b577ab0f43364ff0c59d968f6a414,2017-04-23T05:59Z 312,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 313,CWE-362,"CWE-362 int cipso_v4_sock_setattr ( struct sock * sk , const struct cipso_v4_doi * doi_def , const struct netlbl_lsm_secattr * secattr ) { int ret_val = - EPERM ; unsigned char * buf = NULL ; u32 buf_len ; u32 opt_len ; struct ip_options * opt = NULL ; struct inet_sock * sk_inet ; struct inet_connection_sock * sk_conn ; if ( sk == NULL ) return 0 ; buf_len = CIPSO_V4_OPT_LEN_MAX ; buf = kmalloc ( buf_len , GFP_ATOMIC ) ; if ( buf == NULL ) { ret_val = - ENOMEM ; goto socket_setattr_failure ; } ret_val = cipso_v4_genopt ( buf , buf_len , doi_def , secattr ) ; if ( ret_val < 0 ) goto socket_setattr_failure ; buf_len = ret_val ; opt_len = ( buf_len + 3 ) & ~ 3 ; opt = kzalloc ( sizeof ( * opt ) + opt_len , GFP_ATOMIC ) ; if ( opt == NULL ) { ret_val = - ENOMEM ; goto socket_setattr_failure ; } memcpy ( opt -> __data , buf , buf_len ) ; opt -> optlen = opt_len ; opt -> cipso = sizeof ( struct iphdr ) ; kfree ( buf ) ; buf = NULL ; sk_inet = inet_sk ( sk ) ; if ( sk_inet -> is_icsk ) { sk_conn = inet_csk ( sk ) ; if ( sk_inet -> opt ) sk_conn -> icsk_ext_hdr_len -= sk_inet -> opt -> optlen ; sk_conn -> icsk_ext_hdr_len += opt -> optlen ; sk_conn -> icsk_sync_mss ( sk , sk_conn -> icsk_pmtu_cookie ) ; } opt = xchg ( & sk_inet -> opt , opt ) ; kfree ( opt ) ; return 0 ; socket_setattr_failure : kfree ( buf ) ; kfree ( opt ) ; return ret_val ; } "," opt_len ; struct ip_options_rcu * old , * opt = ( opt -> opt . ; opt -> opt . ; opt -> opt . sk ) ; old = rcu_dereference_protected ( sk_inet -> inet_opt , sock_owned_by_user ( sk ) ) ; ; if ( old ) sk_conn -> -> icsk_ext_hdr_len -= old -> opt . optlen ; sk_conn += opt -> opt . ) ; } rcu_assign_pointer ( sk_inet -> inet_opt , opt ) ; if ( old ) call_rcu ( & old -> rcu , opt_kfree_rcu ) ; return ",torvalds@linux/f6d8bd051c391c1c0458a30b2a7abcd939329259,CVE-2012-3552,https://github.com/torvalds/linux/commit/f6d8bd051c391c1c0458a30b2a7abcd939329259,2012-10-03T11:02Z 314,CWE-119,"CWE-119 static int decode_bit_string ( const u8 * inbuf , size_t inlen , void * outbuf , size_t outlen , int invert ) { const u8 * in = inbuf ; u8 * out = ( u8 * ) outbuf ; int zero_bits = * in & 0x07 ; size_t octets_left = inlen - 1 ; int i , count = 0 ; memset ( outbuf , 0 , outlen ) ; in ++ ; if ( outlen < octets_left ) return SC_ERROR_BUFFER_TOO_SMALL ; if ( inlen < 1 ) return SC_ERROR_INVALID_ASN1_OBJECT ; while ( octets_left ) { int bits_to_go ; * out = 0 ; if ( octets_left == 1 ) bits_to_go = 8 - zero_bits ; else bits_to_go = 8 ; if ( invert ) for ( i = 0 ; i < bits_to_go ; i ++ ) { * out |= ( ( * in >> ( 7 - i ) ) & 1 ) << i ; } else { * out = * in ; } out ++ ; in ++ ; octets_left -- ; count ++ ; } return ( count * 8 ) - zero_bits ; } "," outbuf ; int i , count = 0 ; int zero_bits ; size_t octets_left ; if ( outlen < octets_left ) return SC_ERROR_BUFFER_TOO_SMALL ; if ( inlen < 1 ) return SC_ERROR_INVALID_ASN1_OBJECT ; & 0x07 ; octets_left = inlen - 1 ; in ++ ; memset ( outbuf , 0 , outlen ) ; while ( octets_left ) { int bits_to_go ; * out = 0 ; if ( octets_left == 1 ) bits_to_go = 8 - zero_bits ; else bits_to_go = 8 ; if ( invert ) for ( i = 0 ; i < bits_to_go ; i ++ ) { * out |= ( ( * in >> ( 7 - i ) ) & 1 ) << i ; } else { * out = * in ; } out ++ ; in ++ ; octets_left -- ; count ++ ; } return ( count * 8 ) - zero_bits ",OpenSC@OpenSC/412a6142c27a5973c61ba540e33cdc22d5608e68,CVE-2019-15945,https://github.com/OpenSC/OpenSC/commit/412a6142c27a5973c61ba540e33cdc22d5608e68,2019-09-05T17:15Z 315,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 316,CWE-119,"CWE-119 static int key_verify ( pam_handle_t * pamh , int flags , PKCS11_KEY * authkey ) { int ok = 0 ; unsigned char challenge [ 30 ] ; unsigned char signature [ 256 ] ; unsigned int siglen = sizeof signature ; const EVP_MD * md = EVP_sha1 ( ) ; EVP_MD_CTX * md_ctx = EVP_MD_CTX_new ( ) ; EVP_PKEY * privkey = PKCS11_get_private_key ( authkey ) ; EVP_PKEY * pubkey = PKCS11_get_public_key ( authkey ) ; if ( 1 != randomize ( pamh , challenge , sizeof challenge ) ) { goto err ; } if ( NULL == pubkey || NULL == privkey || NULL == md_ctx || NULL == md || ! EVP_SignInit ( md_ctx , md ) || ! EVP_SignUpdate ( md_ctx , challenge , sizeof challenge ) || ! EVP_SignFinal ( md_ctx , signature , & siglen , privkey ) || ! EVP_MD_CTX_reset ( md_ctx ) || ! EVP_VerifyInit ( md_ctx , md ) || ! EVP_VerifyUpdate ( md_ctx , challenge , sizeof challenge ) || 1 != EVP_VerifyFinal ( md_ctx , signature , siglen , pubkey ) ) { pam_syslog ( pamh , LOG_DEBUG , ""Errorverifyingkey:%s\\n"" , ERR_reason_error_string ( ERR_get_error ( ) ) ) ; prompt ( flags , pamh , PAM_ERROR_MSG , NULL , _ ( ""Errorverifyingkey"" ) ) ; goto err ; } ok = 1 ; err : if ( NULL != pubkey ) EVP_PKEY_free ( pubkey ) ; if ( NULL != privkey ) EVP_PKEY_free ( privkey ) ; if ( NULL != md_ctx ) { EVP_MD_CTX_free ( md_ctx ) ; } return ok ; } "," ; unsigned char * signature = NULL ; unsigned int unsigned int siglen ; const EVP_MD ; if ( NULL == privkey ) goto err ; siglen = EVP_PKEY_size ( privkey ) ; if ( siglen <= 0 ) goto err ; signature = malloc ( siglen ) ; if ( NULL == signature ) goto err ; if ( ; err : free ( signature ) ; ",OpenSC@pam_p11/d150b60e1e14c261b113f55681419ad1dfa8a76c,CVE-2019-16058,https://github.com/OpenSC/pam_p11/commit/d150b60e1e14c261b113f55681419ad1dfa8a76c,2019-09-06T18:15Z 317,CWE-416,"CWE-416 static int try_smi_init ( struct smi_info * new_smi ) { int rv = 0 ; int i ; char * init_name = NULL ; pr_info ( ""Trying%s-specified%sstatemachineat%saddress0x%lx,slaveaddress0x%x,irq%d\\n"" , ipmi_addr_src_to_str ( new_smi -> io . addr_source ) , si_to_str [ new_smi -> io . si_type ] , addr_space_to_str [ new_smi -> io . addr_type ] , new_smi -> io . addr_data , new_smi -> io . slave_addr , new_smi -> io . irq ) ; switch ( new_smi -> io . si_type ) { case SI_KCS : new_smi -> handlers = & kcs_smi_handlers ; break ; case SI_SMIC : new_smi -> handlers = & smic_smi_handlers ; break ; case SI_BT : new_smi -> handlers = & bt_smi_handlers ; break ; default : rv = - EIO ; goto out_err ; } new_smi -> si_num = smi_num ; if ( ! new_smi -> io . dev ) { init_name = kasprintf ( GFP_KERNEL , ""ipmi_si.%d"" , new_smi -> si_num ) ; new_smi -> pdev = platform_device_alloc ( ""ipmi_si"" , new_smi -> si_num ) ; if ( ! new_smi -> pdev ) { pr_err ( ""Unabletoallocateplatformdevice\\n"" ) ; rv = - ENOMEM ; goto out_err ; } new_smi -> io . dev = & new_smi -> pdev -> dev ; new_smi -> io . dev -> driver = & ipmi_platform_driver . driver ; new_smi -> io . dev -> init_name = init_name ; } new_smi -> si_sm = kmalloc ( new_smi -> handlers -> size ( ) , GFP_KERNEL ) ; if ( ! new_smi -> si_sm ) { rv = - ENOMEM ; goto out_err ; } new_smi -> io . io_size = new_smi -> handlers -> init_data ( new_smi -> si_sm , & new_smi -> io ) ; rv = new_smi -> io . io_setup ( & new_smi -> io ) ; if ( rv ) { dev_err ( new_smi -> io . dev , ""CouldnotsetupI/Ospace\\n"" ) ; goto out_err ; } if ( new_smi -> handlers -> detect ( new_smi -> si_sm ) ) { if ( new_smi -> io . addr_source ) dev_err ( new_smi -> io . dev , ""Interfacedetectionfailed\\n"" ) ; rv = - ENODEV ; goto out_err ; } rv = try_get_dev_id ( new_smi ) ; if ( rv ) { if ( new_smi -> io . addr_source ) dev_err ( new_smi -> io . dev , ""ThereappearstobenoBMCatthislocation\\n"" ) ; goto out_err ; } setup_oem_data_handler ( new_smi ) ; setup_xaction_handlers ( new_smi ) ; check_for_broken_irqs ( new_smi ) ; new_smi -> waiting_msg = NULL ; new_smi -> curr_msg = NULL ; atomic_set ( & new_smi -> req_events , 0 ) ; new_smi -> run_to_completion = false ; for ( i = 0 ; i < SI_NUM_STATS ; i ++ ) atomic_set ( & new_smi -> stats [ i ] , 0 ) ; new_smi -> interrupt_disabled = true ; atomic_set ( & new_smi -> need_watch , 0 ) ; rv = try_enable_event_buffer ( new_smi ) ; if ( rv == 0 ) new_smi -> has_event_buffer = true ; start_clear_flags ( new_smi ) ; if ( new_smi -> io . irq ) { new_smi -> interrupt_disabled = false ; atomic_set ( & new_smi -> req_events , 1 ) ; } if ( new_smi -> pdev && ! new_smi -> pdev_registered ) { rv = platform_device_add ( new_smi -> pdev ) ; if ( rv ) { dev_err ( new_smi -> io . dev , ""Unabletoregistersysteminterfacedevice:%d\\n"" , rv ) ; goto out_err ; } new_smi -> pdev_registered = true ; } dev_set_drvdata ( new_smi -> io . dev , new_smi ) ; rv = device_add_group ( new_smi -> io . dev , & ipmi_si_dev_attr_group ) ; if ( rv ) { dev_err ( new_smi -> io . dev , ""Unabletoadddeviceattributes:error%d\\n"" , rv ) ; goto out_err ; } new_smi -> dev_group_added = true ; rv = ipmi_register_smi ( & handlers , new_smi , new_smi -> io . dev , new_smi -> io . slave_addr ) ; if ( rv ) { dev_err ( new_smi -> io . dev , ""Unabletoregisterdevice:error%d\\n"" , rv ) ; goto out_err ; } smi_num ++ ; dev_info ( new_smi -> io . dev , ""IPMI%sinterfaceinitialized\\n"" , si_to_str [ new_smi -> io . si_type ] ) ; WARN_ON ( new_smi -> io . dev -> init_name != NULL ) ; out_err : kfree ( init_name ) ; return rv ; } "," ; out_err : if ( rv && new_smi -> io . io_cleanup ) { new_smi -> io . io_cleanup ( & new_smi -> io ) ; new_smi -> io . io_cleanup = NULL ; } ",torvalds@linux/401e7e88d4ef80188ffa07095ac00456f901b8c4,CVE-2019-11811,https://github.com/torvalds/linux/commit/401e7e88d4ef80188ffa07095ac00456f901b8c4,2019-05-07T14:29Z 318,CWE-119,"CWE-119 static void encode_loopfilter ( struct loopfilter * lf , struct vp9_write_bit_buffer * wb ) { int i ; vp9_wb_write_literal ( wb , lf -> filter_level , 6 ) ; vp9_wb_write_literal ( wb , lf -> sharpness_level , 3 ) ; vp9_wb_write_bit ( wb , lf -> mode_ref_delta_enabled ) ; if ( lf -> mode_ref_delta_enabled ) { vp9_wb_write_bit ( wb , lf -> mode_ref_delta_update ) ; if ( lf -> mode_ref_delta_update ) { for ( i = 0 ; i < MAX_REF_LF_DELTAS ; i ++ ) { const int delta = lf -> ref_deltas [ i ] ; const int changed = delta != lf -> last_ref_deltas [ i ] ; vp9_wb_write_bit ( wb , changed ) ; if ( changed ) { lf -> last_ref_deltas [ i ] = delta ; vp9_wb_write_literal ( wb , abs ( delta ) & 0x3F , 6 ) ; vp9_wb_write_bit ( wb , delta < 0 ) ; } } for ( i = 0 ; i < MAX_MODE_LF_DELTAS ; i ++ ) { const int delta = lf -> mode_deltas [ i ] ; const int changed = delta != lf -> last_mode_deltas [ i ] ; vp9_wb_write_bit ( wb , changed ) ; if ( changed ) { lf -> last_mode_deltas [ i ] = delta ; vp9_wb_write_literal ( wb , abs ( delta ) & 0x3F , 6 ) ; vp9_wb_write_bit ( wb , delta < 0 ) ; } } } } } "," lf , struct vpx_write_bit_buffer * wb ) int i ; vpx_wb_write_literal ( wb , 6 ) ; vpx_wb_write_literal ( wb , 3 ) ; vpx_wb_write_bit ( wb , mode_ref_delta_enabled ) { vpx_wb_write_bit ( wb , i ] ; vpx_wb_write_bit ( wb , = delta ; vpx_wb_write_literal ( wb , 6 ) ; vpx_wb_write_bit ( wb , i ] ; vpx_wb_write_bit ( wb , = delta ; vpx_wb_write_literal ( wb , 6 ) ; vpx_wb_write_bit ( wb , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 319,CWE-787,"CWE-787 void pdf_get_version ( FILE * fp , pdf_t * pdf ) { char * header , * c ; header = get_header ( fp ) ; if ( ( c = strstr ( header , ""%PDF-"" ) ) && ( c + strlen ( ""%PDF-M.m"" ) + 2 ) ) { pdf -> pdf_major_version = atoi ( c + strlen ( ""%PDF-"" ) ) ; pdf -> pdf_minor_version = atoi ( c + strlen ( ""%PDF-M."" ) ) ; } free ( header ) ; } "," char * header = get_header ( ( fp ) ; const char * c ) && ( ( c + 6 ) [ 0 ] == '.' ) && isdigit ( ( c + 5 ) [ 0 ] ) && isdigit ( ( c + 7 ) [ 0 ] ) ) { ",enferex@pdfresurrect/1b422459f07353adce2878806d5247d9e91fb397,CVE-2020-20740,https://github.com/enferex/pdfresurrect/commit/1b422459f07353adce2878806d5247d9e91fb397,2020-11-20T19:15Z 320,CWE-416,"CWE-416 static int dccp_v6_connect ( struct sock * sk , struct sockaddr * uaddr , int addr_len ) { struct sockaddr_in6 * usin = ( struct sockaddr_in6 * ) uaddr ; struct inet_connection_sock * icsk = inet_csk ( sk ) ; struct inet_sock * inet = inet_sk ( sk ) ; struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct dccp_sock * dp = dccp_sk ( sk ) ; struct in6_addr * saddr = NULL , * final_p , final ; struct flowi6 fl6 ; struct dst_entry * dst ; int addr_type ; int err ; dp -> dccps_role = DCCP_ROLE_CLIENT ; if ( addr_len < SIN6_LEN_RFC2133 ) return - EINVAL ; if ( usin -> sin6_family != AF_INET6 ) return - EAFNOSUPPORT ; memset ( & fl6 , 0 , sizeof ( fl6 ) ) ; if ( np -> sndflow ) { fl6 . flowlabel = usin -> sin6_flowinfo & IPV6_FLOWINFO_MASK ; IP6_ECN_flow_init ( fl6 . flowlabel ) ; if ( fl6 . flowlabel & IPV6_FLOWLABEL_MASK ) { struct ip6_flowlabel * flowlabel ; flowlabel = fl6_sock_lookup ( sk , fl6 . flowlabel ) ; if ( flowlabel == NULL ) return - EINVAL ; fl6_sock_release ( flowlabel ) ; } } if ( ipv6_addr_any ( & usin -> sin6_addr ) ) usin -> sin6_addr . s6_addr [ 15 ] = 1 ; addr_type = ipv6_addr_type ( & usin -> sin6_addr ) ; if ( addr_type & IPV6_ADDR_MULTICAST ) return - ENETUNREACH ; if ( addr_type & IPV6_ADDR_LINKLOCAL ) { if ( addr_len >= sizeof ( struct sockaddr_in6 ) && usin -> sin6_scope_id ) { if ( sk -> sk_bound_dev_if && sk -> sk_bound_dev_if != usin -> sin6_scope_id ) return - EINVAL ; sk -> sk_bound_dev_if = usin -> sin6_scope_id ; } if ( ! sk -> sk_bound_dev_if ) return - EINVAL ; } sk -> sk_v6_daddr = usin -> sin6_addr ; np -> flow_label = fl6 . flowlabel ; if ( addr_type == IPV6_ADDR_MAPPED ) { u32 exthdrlen = icsk -> icsk_ext_hdr_len ; struct sockaddr_in sin ; SOCK_DEBUG ( sk , ""connect:ipv4mapped\\n"" ) ; if ( __ipv6_only_sock ( sk ) ) return - ENETUNREACH ; sin . sin_family = AF_INET ; sin . sin_port = usin -> sin6_port ; sin . sin_addr . s_addr = usin -> sin6_addr . s6_addr32 [ 3 ] ; icsk -> icsk_af_ops = & dccp_ipv6_mapped ; sk -> sk_backlog_rcv = dccp_v4_do_rcv ; err = dccp_v4_connect ( sk , ( struct sockaddr * ) & sin , sizeof ( sin ) ) ; if ( err ) { icsk -> icsk_ext_hdr_len = exthdrlen ; icsk -> icsk_af_ops = & dccp_ipv6_af_ops ; sk -> sk_backlog_rcv = dccp_v6_do_rcv ; goto failure ; } np -> saddr = sk -> sk_v6_rcv_saddr ; return err ; } if ( ! ipv6_addr_any ( & sk -> sk_v6_rcv_saddr ) ) saddr = & sk -> sk_v6_rcv_saddr ; fl6 . flowi6_proto = IPPROTO_DCCP ; fl6 . daddr = sk -> sk_v6_daddr ; fl6 . saddr = saddr ? * saddr : np -> saddr ; fl6 . flowi6_oif = sk -> sk_bound_dev_if ; fl6 . fl6_dport = usin -> sin6_port ; fl6 . fl6_sport = inet -> inet_sport ; security_sk_classify_flow ( sk , flowi6_to_flowi ( & fl6 ) ) ; final_p = fl6_update_dst ( & fl6 , np -> opt , & final ) ; dst = ip6_dst_lookup_flow ( sk , & fl6 , final_p ) ; if ( IS_ERR ( dst ) ) { err = PTR_ERR ( dst ) ; goto failure ; } if ( saddr == NULL ) { saddr = & fl6 . saddr ; sk -> sk_v6_rcv_saddr = * saddr ; } np -> saddr = * saddr ; inet -> inet_rcv_saddr = LOOPBACK4_IPV6 ; __ip6_dst_store ( sk , dst , NULL , NULL ) ; icsk -> icsk_ext_hdr_len = 0 ; if ( np -> opt != NULL ) icsk -> icsk_ext_hdr_len = ( np -> opt -> opt_flen + np -> opt -> opt_nflen ) ; inet -> inet_dport = usin -> sin6_port ; dccp_set_state ( sk , DCCP_REQUESTING ) ; err = inet6_hash_connect ( & dccp_death_row , sk ) ; if ( err ) goto late_failure ; dp -> dccps_iss = secure_dccpv6_sequence_number ( np -> saddr . s6_addr32 , sk -> sk_v6_daddr . s6_addr32 , inet -> inet_sport , inet -> inet_dport ) ; err = dccp_connect ( sk ) ; if ( err ) goto late_failure ; return 0 ; late_failure : dccp_set_state ( sk , DCCP_CLOSED ) ; __sk_dst_reset ( sk ) ; failure : inet -> inet_dport = 0 ; sk -> sk_route_caps = 0 ; return err ; } "," final_p , final ; struct ipv6_txoptions * opt ) ) ; opt = rcu_dereference_protected ( np -> opt , sock_owned_by_user ( sk ) ) ; & fl6 , opt , & ; if ( opt ) icsk -> -> icsk_ext_hdr_len = opt -> opt_flen -> opt_flen + opt -> opt_nflen opt -> opt_nflen ; inet -> ",torvalds@linux/45f6fad84cc305103b28d73482b344d7f5b76f39,CVE-2016-3841,https://github.com/torvalds/linux/commit/45f6fad84cc305103b28d73482b344d7f5b76f39,2016-08-06T20:59Z 321,CWE-125,"CWE-125 void mpls_print ( netdissect_options * ndo , const u_char * bp , u_int length ) { const u_char * p ; uint32_t label_entry ; uint16_t label_stack_depth = 0 ; enum mpls_packet_type pt = PT_UNKNOWN ; p = bp ; ND_PRINT ( ( ndo , ""MPLS"" ) ) ; do { ND_TCHECK2 ( * p , sizeof ( label_entry ) ) ; if ( length < sizeof ( label_entry ) ) { ND_PRINT ( ( ndo , ""[|MPLS],length%u"" , length ) ) ; return ; } label_entry = EXTRACT_32BITS ( p ) ; ND_PRINT ( ( ndo , ""%s(label%u"" , ( label_stack_depth && ndo -> ndo_vflag ) ? ""\\n\\t"" : """" , MPLS_LABEL ( label_entry ) ) ) ; label_stack_depth ++ ; if ( ndo -> ndo_vflag && MPLS_LABEL ( label_entry ) < sizeof ( mpls_labelname ) / sizeof ( mpls_labelname [ 0 ] ) ) ND_PRINT ( ( ndo , ""(%s)"" , mpls_labelname [ MPLS_LABEL ( label_entry ) ] ) ) ; ND_PRINT ( ( ndo , "",exp%u"" , MPLS_EXP ( label_entry ) ) ) ; if ( MPLS_STACK ( label_entry ) ) ND_PRINT ( ( ndo , "",[S]"" ) ) ; ND_PRINT ( ( ndo , "",ttl%u)"" , MPLS_TTL ( label_entry ) ) ) ; p += sizeof ( label_entry ) ; length -= sizeof ( label_entry ) ; } while ( ! MPLS_STACK ( label_entry ) ) ; switch ( MPLS_LABEL ( label_entry ) ) { case 0 : case 3 : pt = PT_IPV4 ; break ; case 2 : pt = PT_IPV6 ; break ; default : ND_TCHECK ( * p ) ; if ( length < 1 ) { return ; } switch ( * p ) { case 0x45 : case 0x46 : case 0x47 : case 0x48 : case 0x49 : case 0x4a : case 0x4b : case 0x4c : case 0x4d : case 0x4e : case 0x4f : pt = PT_IPV4 ; break ; case 0x60 : case 0x61 : case 0x62 : case 0x63 : case 0x64 : case 0x65 : case 0x66 : case 0x67 : case 0x68 : case 0x69 : case 0x6a : case 0x6b : case 0x6c : case 0x6d : case 0x6e : case 0x6f : pt = PT_IPV6 ; break ; case 0x81 : case 0x82 : case 0x83 : pt = PT_OSI ; break ; default : break ; } } if ( pt == PT_UNKNOWN ) { if ( ! ndo -> ndo_suppress_default_print ) ND_DEFAULTPRINT ( p , length ) ; return ; } ND_PRINT ( ( ndo , ndo -> ndo_vflag ? ""\\n\\t"" : """" ) ) ; switch ( pt ) { case PT_IPV4 : ip_print ( ndo , p , length ) ; break ; case PT_IPV6 : ip6_print ( ndo , p , length ) ; break ; case PT_OSI : isoclns_print ( ndo , p , length , length ) ; break ; default : break ; } return ; trunc : ND_PRINT ( ( ndo , ""[|MPLS]"" ) ) ; } "," p , length ) ; break ",the-tcpdump-group@tcpdump/1dcd10aceabbc03bf571ea32b892c522cbe923de,CVE-2017-12897,https://github.com/the-tcpdump-group/tcpdump/commit/1dcd10aceabbc03bf571ea32b892c522cbe923de,2017-09-14T06:29Z 322,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#diff-d52750c7ba4e594410438569d8e2963aL24,2018-02-26T14:29Z 323,CWE-000,"CWE-000 static int requireDirective ( MaState * state , cchar * key , cchar * value ) { char * age , * type , * rest , * option , * ovalue , * tok ; int domains ; if ( ! maTokenize ( state , value , ""%S?*"" , & type , & rest ) ) { return MPR_ERR_BAD_SYNTAX ; } if ( scaselesscmp ( type , ""ability"" ) == 0 ) { httpSetAuthRequiredAbilities ( state -> auth , rest ) ; } else if ( scaselesscmp ( type , ""group"" ) == 0 || scaselesscmp ( type , ""role"" ) == 0 ) { httpSetAuthRequiredAbilities ( state -> auth , rest ) ; } else if ( scaselesscmp ( type , ""secure"" ) == 0 ) { domains = 0 ; age = 0 ; for ( option = stok ( sclone ( rest ) , ""\\t"" , & tok ) ; option ; option = stok ( 0 , ""\\t"" , & tok ) ) { option = stok ( option , ""=\\t,"" , & ovalue ) ; ovalue = strim ( ovalue , ""\\""\'"" , MPR_TRIM_BOTH ) ; if ( smatch ( option , ""age"" ) ) { age = sfmt ( ""%lld"" , ( int64 ) httpGetTicks ( ovalue ) ) ; } else if ( smatch ( option , ""domains"" ) ) { domains = 1 ; } } if ( age ) { if ( domains ) { age = sjoin ( ""-1"" , age , NULL ) ; } } addCondition ( state , ""secure"" , age , HTTP_ROUTE_STRICT_TLS ) ; } else if ( scaselesscmp ( type , ""user"" ) == 0 ) { httpSetAuthPermittedUsers ( state -> auth , rest ) ; } else if ( scaselesscmp ( type , ""valid-user"" ) == 0 ) { httpSetAuthAnyValidUser ( state -> auth ) ; } else { return configError ( state , key ) ; } return 0 ; } "," { option = ssplit ( option , ",embedthis@appweb/7e6a925f5e86a19a7934a94bbd6959101d0b84eb,CVE-2014-9708,https://github.com/embedthis/appweb/commit/7e6a925f5e86a19a7934a94bbd6959101d0b84eb,2015-03-31T14:59Z 324,CWE-119,"CWE-119 static void ppp_hdlc ( netdissect_options * ndo , const u_char * p , int length ) { u_char * b , * s , * t , c ; int i , proto ; const void * se ; if ( length <= 0 ) return ; b = ( uint8_t * ) malloc ( length ) ; if ( b == NULL ) return ; for ( s = ( u_char * ) p , t = b , i = length ; i > 0 ; i -- ) { c = * s ++ ; if ( c == 0x7d ) { if ( i > 1 ) { i -- ; c = * s ++ ^ 0x20 ; } else continue ; } * t ++ = c ; } se = ndo -> ndo_snapend ; ndo -> ndo_snapend = t ; length = t - b ; if ( length < 1 ) goto trunc ; proto = * b ; switch ( proto ) { case PPP_IP : ip_print ( ndo , b + 1 , length - 1 ) ; goto cleanup ; case PPP_IPV6 : ip6_print ( ndo , b + 1 , length - 1 ) ; goto cleanup ; default : break ; } if ( length < 2 ) goto trunc ; proto = EXTRACT_16BITS ( b ) ; switch ( proto ) { case ( PPP_ADDRESS << 8 | PPP_CONTROL ) : if ( length < 4 ) goto trunc ; proto = EXTRACT_16BITS ( b + 2 ) ; handle_ppp ( ndo , proto , b + 4 , length - 4 ) ; break ; default : handle_ppp ( ndo , proto , b + 2 , length - 2 ) ; break ; } cleanup : ndo -> ndo_snapend = se ; free ( b ) ; return ; trunc : ndo -> ndo_snapend = se ; free ( b ) ; ND_PRINT ( ( ndo , ""[|ppp]"" ) ) ; } "," b , * t , c t , c ; const u_char * s b = ( u_char * ) malloc ( s = p , t i > 0 && ND_TTEST ( * s ) if ( i <= 1 || ! ND_TTEST ( * s ) ) break ; i -- ; ++ ^ 0x20 ; } * ",the-tcpdump-group@tcpdump/0f95d441e4b5d7512cc5c326c8668a120e048eda,CVE-2014-9140,https://github.com/the-tcpdump-group/tcpdump/commit/0f95d441e4b5d7512cc5c326c8668a120e048eda,2014-12-05T16:59Z 325,CWE-119,"CWE-119 void ih264d_rest_of_residual_cav_chroma_dc_block ( UWORD32 u4_total_coeff_trail_one , dec_bit_stream_t * ps_bitstrm ) { UWORD32 u4_total_zeroes ; WORD16 i ; UWORD32 * pu4_bitstrm_buf = ps_bitstrm -> pu4_buffer ; UWORD32 u4_bitstream_offset = ps_bitstrm -> u4_ofst ; UWORD32 u4_trailing_ones = u4_total_coeff_trail_one & 0xFFFF ; UWORD32 u4_total_coeff = u4_total_coeff_trail_one >> 16 ; WORD16 i2_level_arr [ 4 ] ; tu_sblk4x4_coeff_data_t * ps_tu_4x4 ; WORD16 * pi2_coeff_data ; dec_struct_t * ps_dec = ( dec_struct_t * ) ps_bitstrm -> pv_codec_handle ; ps_tu_4x4 = ( tu_sblk4x4_coeff_data_t * ) ps_dec -> pv_parse_tu_coeff_data ; ps_tu_4x4 -> u2_sig_coeff_map = 0 ; pi2_coeff_data = & ps_tu_4x4 -> ai2_level [ 0 ] ; i = u4_total_coeff - 1 ; if ( u4_trailing_ones ) { UWORD32 u4_signs , u4_cnt = u4_trailing_ones ; WORD16 ( * ppi2_trlone_lkup ) [ 3 ] = ( WORD16 ( * ) [ 3 ] ) gai2_ih264d_trailing_one_level ; WORD16 * pi2_trlone_lkup ; GETBITS ( u4_signs , u4_bitstream_offset , pu4_bitstrm_buf , u4_cnt ) ; pi2_trlone_lkup = ppi2_trlone_lkup [ ( 1 << u4_cnt ) - 2 + u4_signs ] ; while ( u4_cnt -- ) i2_level_arr [ i -- ] = * pi2_trlone_lkup ++ ; } if ( i >= 0 ) { UWORD32 u4_lev_suffix , u4_suffix_len , u4_lev_suffix_size ; UWORD16 u2_lev_code , u2_abs_value ; UWORD32 u4_lev_prefix ; FIND_ONE_IN_STREAM_32 ( u4_lev_prefix , u4_bitstream_offset , pu4_bitstrm_buf ) ; u2_lev_code = MIN ( 15 , u4_lev_prefix ) ; u2_lev_code += ( 3 == u4_trailing_ones ) ? 0 : ( 2 ) ; if ( 14 == u4_lev_prefix ) u4_lev_suffix_size = 4 ; else if ( 15 <= u4_lev_prefix ) { u2_lev_code += 15 ; u4_lev_suffix_size = u4_lev_prefix - 3 ; } else u4_lev_suffix_size = 0 ; if ( 16 <= u4_lev_prefix ) { u2_lev_code += ( ( 1 << ( u4_lev_prefix - 3 ) ) - 4096 ) ; } if ( u4_lev_suffix_size ) { GETBITS ( u4_lev_suffix , u4_bitstream_offset , pu4_bitstrm_buf , u4_lev_suffix_size ) ; u2_lev_code += u4_lev_suffix ; } u2_abs_value = ( u2_lev_code + 2 ) >> 1 ; i2_level_arr [ i -- ] = ( u2_lev_code & 1 ) ? - u2_abs_value : u2_abs_value ; u4_suffix_len = ( u2_abs_value > 3 ) ? 2 : 1 ; while ( i >= 0 ) { FIND_ONE_IN_STREAM_32 ( u4_lev_prefix , u4_bitstream_offset , pu4_bitstrm_buf ) ; u4_lev_suffix_size = ( 15 <= u4_lev_prefix ) ? ( u4_lev_prefix - 3 ) : u4_suffix_len ; GETBITS ( u4_lev_suffix , u4_bitstream_offset , pu4_bitstrm_buf , u4_lev_suffix_size ) ; u2_lev_code = ( MIN ( u4_lev_prefix , 15 ) << u4_suffix_len ) + u4_lev_suffix ; if ( 16 <= u4_lev_prefix ) { u2_lev_code += ( ( 1 << ( u4_lev_prefix - 3 ) ) - 4096 ) ; } u2_abs_value = ( u2_lev_code + 2 ) >> 1 ; i2_level_arr [ i -- ] = ( u2_lev_code & 1 ) ? - u2_abs_value : u2_abs_value ; u4_suffix_len += ( u2_abs_value > ( 3 << ( u4_suffix_len - 1 ) ) ) ; } } if ( u4_total_coeff < 4 ) { UWORD32 u4_max_ldz = ( 4 - u4_total_coeff ) ; FIND_ONE_IN_STREAM_LEN ( u4_total_zeroes , u4_bitstream_offset , pu4_bitstrm_buf , u4_max_ldz ) ; } else u4_total_zeroes = 0 ; { const UWORD8 * pu1_table_runbefore ; UWORD32 u4_run ; UWORD32 u4_scan_pos = ( u4_total_coeff + u4_total_zeroes - 1 ) ; UWORD32 u4_zeroes_left = u4_total_zeroes ; i = u4_total_coeff - 1 ; pu1_table_runbefore = ( UWORD8 * ) gau1_ih264d_table_run_before ; while ( u4_zeroes_left && i ) { UWORD32 u4_code ; NEXTBITS ( u4_code , u4_bitstream_offset , pu4_bitstrm_buf , 3 ) ; u4_code = pu1_table_runbefore [ u4_code + ( u4_zeroes_left << 3 ) ] ; u4_run = u4_code >> 2 ; FLUSHBITS ( u4_bitstream_offset , ( u4_code & 0x03 ) ) ; SET_BIT ( ps_tu_4x4 -> u2_sig_coeff_map , u4_scan_pos ) ; * pi2_coeff_data ++ = i2_level_arr [ i -- ] ; u4_zeroes_left -= u4_run ; u4_scan_pos -= ( u4_run + 1 ) ; } while ( i >= 0 ) { SET_BIT ( ps_tu_4x4 -> u2_sig_coeff_map , u4_scan_pos ) ; * pi2_coeff_data ++ = i2_level_arr [ i -- ] ; u4_scan_pos -- ; } } { WORD32 offset ; offset = ( UWORD8 * ) pi2_coeff_data - ( UWORD8 * ) ps_tu_4x4 ; offset = ALIGN4 ( offset ) ; ps_dec -> pv_parse_tu_coeff_data = ( void * ) ( ( UWORD8 * ) ps_dec -> pv_parse_tu_coeff_data + offset ) ; } ps_bitstrm -> u4_ofst = u4_bitstream_offset ; } "," 16 ; WORD16 ai2_level_arr [ 7 ] ; WORD16 * i2_level_arr = & ai2_level_arr [ 3 ] ; tu_sblk4x4_coeff_data_t ",external@libavc/c57fc3703ae2e0d41b1f6580c50015937f2d23c1,CVE-2016-0840,https://android.googlesource.com/platform/external/libavc/+/c57fc3703ae2e0d41b1f6580c50015937f2d23c1,2016-04-18T00:59Z 326,CWE-400,"CWE-400 static enum gro_result dev_gro_receive ( struct napi_struct * napi , struct sk_buff * skb ) { struct sk_buff * * pp = NULL ; struct packet_offload * ptype ; __be16 type = skb -> protocol ; struct list_head * head = & offload_base ; int same_flow ; enum gro_result ret ; int grow ; if ( ! ( skb -> dev -> features & NETIF_F_GRO ) ) goto normal ; if ( skb_is_gso ( skb ) || skb_has_frag_list ( skb ) || skb -> csum_bad ) goto normal ; gro_list_prepare ( napi , skb ) ; rcu_read_lock ( ) ; list_for_each_entry_rcu ( ptype , head , list ) { if ( ptype -> type != type || ! ptype -> callbacks . gro_receive ) continue ; skb_set_network_header ( skb , skb_gro_offset ( skb ) ) ; skb_reset_mac_len ( skb ) ; NAPI_GRO_CB ( skb ) -> same_flow = 0 ; NAPI_GRO_CB ( skb ) -> flush = 0 ; NAPI_GRO_CB ( skb ) -> free = 0 ; NAPI_GRO_CB ( skb ) -> udp_mark = 0 ; NAPI_GRO_CB ( skb ) -> gro_remcsum_start = 0 ; switch ( skb -> ip_summed ) { case CHECKSUM_COMPLETE : NAPI_GRO_CB ( skb ) -> csum = skb -> csum ; NAPI_GRO_CB ( skb ) -> csum_valid = 1 ; NAPI_GRO_CB ( skb ) -> csum_cnt = 0 ; break ; case CHECKSUM_UNNECESSARY : NAPI_GRO_CB ( skb ) -> csum_cnt = skb -> csum_level + 1 ; NAPI_GRO_CB ( skb ) -> csum_valid = 0 ; break ; default : NAPI_GRO_CB ( skb ) -> csum_cnt = 0 ; NAPI_GRO_CB ( skb ) -> csum_valid = 0 ; } pp = ptype -> callbacks . gro_receive ( & napi -> gro_list , skb ) ; break ; } rcu_read_unlock ( ) ; if ( & ptype -> list == head ) goto normal ; same_flow = NAPI_GRO_CB ( skb ) -> same_flow ; ret = NAPI_GRO_CB ( skb ) -> free ? GRO_MERGED_FREE : GRO_MERGED ; if ( pp ) { struct sk_buff * nskb = * pp ; * pp = nskb -> next ; nskb -> next = NULL ; napi_gro_complete ( nskb ) ; napi -> gro_count -- ; } if ( same_flow ) goto ok ; if ( NAPI_GRO_CB ( skb ) -> flush ) goto normal ; if ( unlikely ( napi -> gro_count >= MAX_GRO_SKBS ) ) { struct sk_buff * nskb = napi -> gro_list ; while ( nskb -> next ) { pp = & nskb -> next ; nskb = * pp ; } * pp = NULL ; nskb -> next = NULL ; napi_gro_complete ( nskb ) ; } else { napi -> gro_count ++ ; } NAPI_GRO_CB ( skb ) -> count = 1 ; NAPI_GRO_CB ( skb ) -> age = jiffies ; NAPI_GRO_CB ( skb ) -> last = skb ; skb_shinfo ( skb ) -> gso_size = skb_gro_len ( skb ) ; skb -> next = napi -> gro_list ; napi -> gro_list = skb ; ret = GRO_HELD ; pull : grow = skb_gro_offset ( skb ) - skb_headlen ( skb ) ; if ( grow > 0 ) gro_pull_from_frag0 ( skb , grow ) ; ok : return ret ; normal : ret = GRO_NORMAL ; goto pull ; } "," skb ) -> encap_mark = 0 ; ",torvalds@linux/fac8e0f579695a3ecbc4d3cac369139d7f819971,CVE-2016-8666,https://github.com/torvalds/linux/commit/fac8e0f579695a3ecbc4d3cac369139d7f819971,2016-10-16T21:59Z 327,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 328,CWE-119,"CWE-119 void cJSON_AddItemToObject ( cJSON * object , const char * string , cJSON * item ) { if ( ! item ) return ; if ( item -> string ) cJSON_free ( item -> string ) ; item -> string = cJSON_strdup ( string ) ; cJSON_AddItemToArray ( object , item ) ; } "," ",esnet@iperf/91f2fa59e8ed80dfbf400add0164ee0e508e412a,CVE-2016-4303,https://github.com/esnet/iperf/commit/91f2fa59e8ed80dfbf400add0164ee0e508e412a,2016-09-26T14:59Z 329,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 330,CWE-264,"CWE-264 void perf_pmu_migrate_context ( struct pmu * pmu , int src_cpu , int dst_cpu ) { struct perf_event_context * src_ctx ; struct perf_event_context * dst_ctx ; struct perf_event * event , * tmp ; LIST_HEAD ( events ) ; src_ctx = & per_cpu_ptr ( pmu -> pmu_cpu_context , src_cpu ) -> ctx ; dst_ctx = & per_cpu_ptr ( pmu -> pmu_cpu_context , dst_cpu ) -> ctx ; mutex_lock ( & src_ctx -> mutex ) ; list_for_each_entry_safe ( event , tmp , & src_ctx -> event_list , event_entry ) { perf_remove_from_context ( event , false ) ; unaccount_event_cpu ( event , src_cpu ) ; put_ctx ( src_ctx ) ; list_add ( & event -> migrate_entry , & events ) ; } mutex_unlock ( & src_ctx -> mutex ) ; synchronize_rcu ( ) ; mutex_lock ( & dst_ctx -> mutex ) ; list_for_each_entry_safe ( event , tmp , & events , migrate_entry ) { list_del ( & event -> migrate_entry ) ; if ( event -> state >= PERF_EVENT_STATE_OFF ) event -> state = PERF_EVENT_STATE_INACTIVE ; account_event_cpu ( event , dst_cpu ) ; perf_install_in_context ( dst_ctx , event , dst_cpu ) ; get_ctx ( dst_ctx ) ; } mutex_unlock ( & dst_ctx -> mutex ) ; } "," -> ctx ; mutex_lock_double ( & src_ctx -> mutex , & dst_ctx -> mutex ) ) ; } synchronize_rcu ( ) ; list_for_each_entry_safe mutex ) ; mutex_unlock ( & src_ctx -> mutex ) ; ",torvalds@linux/f63a8daa5812afef4f06c962351687e1ff9ccb2b,CVE-2016-6787,https://github.com/torvalds/linux/commit/f63a8daa5812afef4f06c962351687e1ff9ccb2b,2016-12-28T07:59Z 331,CWE-000,"CWE-000 struct bpf_prog * bpf_prog_get ( u32 ufd ) { struct fd f = fdget ( ufd ) ; struct bpf_prog * prog ; prog = __bpf_prog_get ( f ) ; if ( IS_ERR ( prog ) ) return prog ; atomic_inc ( & prog -> aux -> refcnt ) ; fdput ( f ) ; return prog ; } "," return prog ; prog = bpf_prog_inc ( prog ) ; fdput ",torvalds@linux/92117d8443bc5afacc8d5ba82e541946310f106e,CVE-2016-4558,https://github.com/torvalds/linux/commit/92117d8443bc5afacc8d5ba82e541946310f106e,2016-05-23T10:59Z 332,CWE-119,"CWE-119 static INLINE void write_buffer_8x8 ( int16_t * output , __m128i * res , int stride ) { _mm_store_si128 ( ( __m128i * ) ( output + 0 * stride ) , res [ 0 ] ) ; _mm_store_si128 ( ( __m128i * ) ( output + 1 * stride ) , res [ 1 ] ) ; _mm_store_si128 ( ( __m128i * ) ( output + 2 * stride ) , res [ 2 ] ) ; _mm_store_si128 ( ( __m128i * ) ( output + 3 * stride ) , res [ 3 ] ) ; _mm_store_si128 ( ( __m128i * ) ( output + 4 * stride ) , res [ 4 ] ) ; _mm_store_si128 ( ( __m128i * ) ( output + 5 * stride ) , res [ 5 ] ) ; _mm_store_si128 ( ( __m128i * ) ( output + 6 * stride ) , res [ 6 ] ) ; _mm_store_si128 ( ( __m128i * ) ( output + 7 * stride ) , res [ 7 ] ) ; } "," void write_buffer_8x8 ( tran_low_t * output , stride ) { store_output ( & res [ 0 ] , ( output + * stride ) ) ; store_output ( & res [ 1 ] , ( output + * stride ) ) ; store_output ( & res [ 2 ] , ( output + * stride ) ) ; store_output ( & res [ 3 ] , ( output + * stride ) ) ; store_output ( & res [ 4 ] , ( output + * stride ) ) ; store_output ( & res [ 5 ] , ( output + * stride ) ) ; store_output ( & res [ 6 ] , ( output + * stride ) ) ; store_output ( & res [ 7 ] , ( output + * stride ) ) ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 333,CWE-416,"CWE-416 long follow_hugetlb_page ( struct mm_struct * mm , struct vm_area_struct * vma , struct page * * pages , struct vm_area_struct * * vmas , unsigned long * position , unsigned long * nr_pages , long i , unsigned int flags , int * nonblocking ) { unsigned long pfn_offset ; unsigned long vaddr = * position ; unsigned long remainder = * nr_pages ; struct hstate * h = hstate_vma ( vma ) ; int err = - EFAULT ; while ( vaddr < vma -> vm_end && remainder ) { pte_t * pte ; spinlock_t * ptl = NULL ; int absent ; struct page * page ; if ( fatal_signal_pending ( current ) ) { remainder = 0 ; break ; } pte = huge_pte_offset ( mm , vaddr & huge_page_mask ( h ) , huge_page_size ( h ) ) ; if ( pte ) ptl = huge_pte_lock ( h , mm , pte ) ; absent = ! pte || huge_pte_none ( huge_ptep_get ( pte ) ) ; if ( absent && ( flags & FOLL_DUMP ) && ! hugetlbfs_pagecache_present ( h , vma , vaddr ) ) { if ( pte ) spin_unlock ( ptl ) ; remainder = 0 ; break ; } if ( absent || is_swap_pte ( huge_ptep_get ( pte ) ) || ( ( flags & FOLL_WRITE ) && ! huge_pte_write ( huge_ptep_get ( pte ) ) ) ) { vm_fault_t ret ; unsigned int fault_flags = 0 ; if ( pte ) spin_unlock ( ptl ) ; if ( flags & FOLL_WRITE ) fault_flags |= FAULT_FLAG_WRITE ; if ( nonblocking ) fault_flags |= FAULT_FLAG_ALLOW_RETRY ; if ( flags & FOLL_NOWAIT ) fault_flags |= FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_RETRY_NOWAIT ; if ( flags & FOLL_TRIED ) { VM_WARN_ON_ONCE ( fault_flags & FAULT_FLAG_ALLOW_RETRY ) ; fault_flags |= FAULT_FLAG_TRIED ; } ret = hugetlb_fault ( mm , vma , vaddr , fault_flags ) ; if ( ret & VM_FAULT_ERROR ) { err = vm_fault_to_errno ( ret , flags ) ; remainder = 0 ; break ; } if ( ret & VM_FAULT_RETRY ) { if ( nonblocking && ! ( fault_flags & FAULT_FLAG_RETRY_NOWAIT ) ) * nonblocking = 0 ; * nr_pages = 0 ; return i ; } continue ; } pfn_offset = ( vaddr & ~ huge_page_mask ( h ) ) >> PAGE_SHIFT ; page = pte_page ( huge_ptep_get ( pte ) ) ; same_page : if ( pages ) { pages [ i ] = mem_map_offset ( page , pfn_offset ) ; get_page ( pages [ i ] ) ; } if ( vmas ) vmas [ i ] = vma ; vaddr += PAGE_SIZE ; ++ pfn_offset ; -- remainder ; ++ i ; if ( vaddr < vma -> vm_end && remainder && pfn_offset < pages_per_huge_page ( h ) ) { goto same_page ; } spin_unlock ( ptl ) ; } * nr_pages = remainder ; * position = vaddr ; return i ? i : err ; } "," ) ) ; if ( unlikely ( page_count ( page ) <= 0 ) ) { if ( pages ) { spin_unlock ( ptl ) ; remainder = 0 ; err = - ENOMEM ; break ; } } ",torvalds@linux/6b3a707736301c2128ca85ce85fb13f60b5e350a,CVE-2019-11487,https://github.com/torvalds/linux/commit/6b3a707736301c2128ca85ce85fb13f60b5e350a,2019-04-23T22:29Z 334,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 335,CWE-190,"CWE-190 int rpc_pack ( rpc_pkg * pkg , void * * data , uint32_t * size ) { static void * send_buf ; static size_t send_buf_size ; uint32_t pkg_size = RPC_PKG_HEAD_SIZE + pkg -> ext_size + pkg -> body_size ; if ( send_buf_size < pkg_size ) { if ( send_buf ) free ( send_buf ) ; send_buf_size = pkg_size * 2 ; send_buf = malloc ( send_buf_size ) ; assert ( send_buf != NULL ) ; } memcpy ( send_buf , pkg , RPC_PKG_HEAD_SIZE ) ; if ( pkg -> ext_size ) memcpy ( send_buf + RPC_PKG_HEAD_SIZE , pkg -> ext , pkg -> ext_size ) ; if ( pkg -> body_size ) memcpy ( send_buf + RPC_PKG_HEAD_SIZE + pkg -> ext_size , pkg -> body , pkg -> body_size ) ; pkg = send_buf ; pkg -> magic = htole32 ( RPC_PKG_MAGIC ) ; pkg -> command = htole32 ( pkg -> command ) ; pkg -> pkg_type = htole16 ( pkg -> pkg_type ) ; pkg -> result = htole32 ( pkg -> result ) ; pkg -> sequence = htole32 ( pkg -> sequence ) ; pkg -> req_id = htole64 ( pkg -> req_id ) ; pkg -> body_size = htole32 ( pkg -> body_size ) ; pkg -> ext_size = htole16 ( pkg -> ext_size ) ; pkg -> crc32 = 0 ; pkg -> crc32 = htole32 ( generate_crc32c ( send_buf , pkg_size ) ) ; * data = send_buf ; * size = pkg_size ; return 0 ; } "," ; uint32_t pkg_size ; if ( pkg -> body_size > RPC_PKG_MAX_BODY_SIZE ) { return - 1 ; } pkg_size send_buf_size ) ; if ( send_buf == NULL ) { return - 1 ; } } memcpy ( ",viabtc@viabtc_exchange_server/4a7c27bfe98f409623d4d857894d017ff0672cc9,CVE-2018-17568,https://github.com/viabtc/viabtc_exchange_server/commit/4a7c27bfe98f409623d4d857894d017ff0672cc9#diff-0c23effa84a7b85053bac7981a8580c8,2018-09-26T22:29Z 336,CWE-119,"CWE-119 BOOL update_recv ( rdpUpdate * update , wStream * s ) { BOOL rc = FALSE ; UINT16 updateType ; rdpContext * context = update -> context ; if ( Stream_GetRemainingLength ( s ) < 2 ) { WLog_ERR ( TAG , ""Stream_GetRemainingLength(s)<2"" ) ; return FALSE ; } Stream_Read_UINT16 ( s , updateType ) ; WLog_Print ( update -> log , WLOG_TRACE , ""%sUpdateDataPDU"" , UPDATE_TYPE_STRINGS [ updateType ] ) ; if ( ! update_begin_paint ( update ) ) goto fail ; switch ( updateType ) { case UPDATE_TYPE_ORDERS : rc = update_recv_orders ( update , s ) ; break ; case UPDATE_TYPE_BITMAP : { BITMAP_UPDATE * bitmap_update = update_read_bitmap_update ( update , s ) ; if ( ! bitmap_update ) { WLog_ERR ( TAG , ""UPDATE_TYPE_BITMAP-update_read_bitmap_update()failed"" ) ; goto fail ; } rc = IFCALLRESULT ( FALSE , update -> BitmapUpdate , context , bitmap_update ) ; free_bitmap_update ( update -> context , bitmap_update ) ; } break ; case UPDATE_TYPE_PALETTE : { PALETTE_UPDATE * palette_update = update_read_palette ( update , s ) ; if ( ! palette_update ) { WLog_ERR ( TAG , ""UPDATE_TYPE_PALETTE-update_read_palette()failed"" ) ; goto fail ; } rc = IFCALLRESULT ( FALSE , update -> Palette , context , palette_update ) ; free_palette_update ( context , palette_update ) ; } break ; case UPDATE_TYPE_SYNCHRONIZE : update_read_synchronize ( update , s ) ; rc = IFCALLRESULT ( TRUE , update -> Synchronize , context ) ; break ; default : break ; } fail : if ( ! update_end_paint ( update ) ) rc = FALSE ; if ( ! rc ) { WLog_ERR ( TAG , ""UPDATE_TYPE%s[%"" PRIu16 ""]failed"" , update_type_to_string ( updateType ) , updateType ) ; return FALSE ; } return TRUE ; } "," case UPDATE_TYPE_SYNCHRONIZE : if ( ! , s ) ) goto fail ",FreeRDP@FreeRDP/ed53cd148f43cbab905eaa0f5308c2bf3c48cc37,CVE-2020-11046,https://github.com/FreeRDP/FreeRDP/commit/ed53cd148f43cbab905eaa0f5308c2bf3c48cc37,2020-05-07T19:15Z 337,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 338,CWE-19,"CWE-19 static int ext4_xattr_block_set ( handle_t * handle , struct inode * inode , struct ext4_xattr_info * i , struct ext4_xattr_block_find * bs ) { struct super_block * sb = inode -> i_sb ; struct buffer_head * new_bh = NULL ; struct ext4_xattr_search * s = & bs -> s ; struct mb_cache_entry * ce = NULL ; int error = 0 ; struct mb_cache * ext4_mb_cache = EXT4_GET_MB_CACHE ( inode ) ; # define header ( x ) ( ( struct ext4_xattr_header * ) ( x ) ) if ( i -> value && i -> value_len > sb -> s_blocksize ) return - ENOSPC ; if ( s -> base ) { ce = mb_cache_entry_get ( ext4_mb_cache , bs -> bh -> b_bdev , bs -> bh -> b_blocknr ) ; BUFFER_TRACE ( bs -> bh , ""get_write_access"" ) ; error = ext4_journal_get_write_access ( handle , bs -> bh ) ; if ( error ) goto cleanup ; lock_buffer ( bs -> bh ) ; if ( header ( s -> base ) -> h_refcount == cpu_to_le32 ( 1 ) ) { if ( ce ) { mb_cache_entry_free ( ce ) ; ce = NULL ; } ea_bdebug ( bs -> bh , ""modifyingin-place"" ) ; error = ext4_xattr_set_entry ( i , s ) ; if ( ! error ) { if ( ! IS_LAST_ENTRY ( s -> first ) ) ext4_xattr_rehash ( header ( s -> base ) , s -> here ) ; ext4_xattr_cache_insert ( ext4_mb_cache , bs -> bh ) ; } unlock_buffer ( bs -> bh ) ; if ( error == - EFSCORRUPTED ) goto bad_block ; if ( ! error ) error = ext4_handle_dirty_xattr_block ( handle , inode , bs -> bh ) ; if ( error ) goto cleanup ; goto inserted ; } else { int offset = ( char * ) s -> here - bs -> bh -> b_data ; unlock_buffer ( bs -> bh ) ; if ( ce ) { mb_cache_entry_release ( ce ) ; ce = NULL ; } ea_bdebug ( bs -> bh , ""cloning"" ) ; s -> base = kmalloc ( bs -> bh -> b_size , GFP_NOFS ) ; error = - ENOMEM ; if ( s -> base == NULL ) goto cleanup ; memcpy ( s -> base , BHDR ( bs -> bh ) , bs -> bh -> b_size ) ; s -> first = ENTRY ( header ( s -> base ) + 1 ) ; header ( s -> base ) -> h_refcount = cpu_to_le32 ( 1 ) ; s -> here = ENTRY ( s -> base + offset ) ; s -> end = s -> base + bs -> bh -> b_size ; } } else { s -> base = kzalloc ( sb -> s_blocksize , GFP_NOFS ) ; error = - ENOMEM ; if ( s -> base == NULL ) goto cleanup ; header ( s -> base ) -> h_magic = cpu_to_le32 ( EXT4_XATTR_MAGIC ) ; header ( s -> base ) -> h_blocks = cpu_to_le32 ( 1 ) ; header ( s -> base ) -> h_refcount = cpu_to_le32 ( 1 ) ; s -> first = ENTRY ( header ( s -> base ) + 1 ) ; s -> here = ENTRY ( header ( s -> base ) + 1 ) ; s -> end = s -> base + sb -> s_blocksize ; } error = ext4_xattr_set_entry ( i , s ) ; if ( error == - EFSCORRUPTED ) goto bad_block ; if ( error ) goto cleanup ; if ( ! IS_LAST_ENTRY ( s -> first ) ) ext4_xattr_rehash ( header ( s -> base ) , s -> here ) ; inserted : if ( ! IS_LAST_ENTRY ( s -> first ) ) { new_bh = ext4_xattr_cache_find ( inode , header ( s -> base ) , & ce ) ; if ( new_bh ) { if ( new_bh == bs -> bh ) ea_bdebug ( new_bh , ""keeping"" ) ; else { error = dquot_alloc_block ( inode , EXT4_C2B ( EXT4_SB ( sb ) , 1 ) ) ; if ( error ) goto cleanup ; BUFFER_TRACE ( new_bh , ""get_write_access"" ) ; error = ext4_journal_get_write_access ( handle , new_bh ) ; if ( error ) goto cleanup_dquot ; lock_buffer ( new_bh ) ; le32_add_cpu ( & BHDR ( new_bh ) -> h_refcount , 1 ) ; ea_bdebug ( new_bh , ""reusing;refcountnow=%d"" , le32_to_cpu ( BHDR ( new_bh ) -> h_refcount ) ) ; unlock_buffer ( new_bh ) ; error = ext4_handle_dirty_xattr_block ( handle , inode , new_bh ) ; if ( error ) goto cleanup_dquot ; } mb_cache_entry_release ( ce ) ; ce = NULL ; } else if ( bs -> bh && s -> base == bs -> bh -> b_data ) { ea_bdebug ( bs -> bh , ""keepingthisblock"" ) ; new_bh = bs -> bh ; get_bh ( new_bh ) ; } else { ext4_fsblk_t goal , block ; goal = ext4_group_first_block_no ( sb , EXT4_I ( inode ) -> i_block_group ) ; if ( ! ( ext4_test_inode_flag ( inode , EXT4_INODE_EXTENTS ) ) ) goal = goal & EXT4_MAX_BLOCK_FILE_PHYS ; block = ext4_new_meta_blocks ( handle , inode , goal , 0 , NULL , & error ) ; if ( error ) goto cleanup ; if ( ! ( ext4_test_inode_flag ( inode , EXT4_INODE_EXTENTS ) ) ) BUG_ON ( block > EXT4_MAX_BLOCK_FILE_PHYS ) ; ea_idebug ( inode , ""creatingblock%llu"" , ( unsigned long long ) block ) ; new_bh = sb_getblk ( sb , block ) ; if ( unlikely ( ! new_bh ) ) { error = - ENOMEM ; getblk_failed : ext4_free_blocks ( handle , inode , NULL , block , 1 , EXT4_FREE_BLOCKS_METADATA ) ; goto cleanup ; } lock_buffer ( new_bh ) ; error = ext4_journal_get_create_access ( handle , new_bh ) ; if ( error ) { unlock_buffer ( new_bh ) ; error = - EIO ; goto getblk_failed ; } memcpy ( new_bh -> b_data , s -> base , new_bh -> b_size ) ; set_buffer_uptodate ( new_bh ) ; unlock_buffer ( new_bh ) ; ext4_xattr_cache_insert ( ext4_mb_cache , new_bh ) ; error = ext4_handle_dirty_xattr_block ( handle , inode , new_bh ) ; if ( error ) goto cleanup ; } } EXT4_I ( inode ) -> i_file_acl = new_bh ? new_bh -> b_blocknr : 0 ; if ( bs -> bh && bs -> bh != new_bh ) ext4_xattr_release_block ( handle , inode , bs -> bh ) ; error = 0 ; cleanup : if ( ce ) mb_cache_entry_release ( ce ) ; brelse ( new_bh ) ; if ( ! ( bs -> bh && s -> base == bs -> bh -> b_data ) ) kfree ( s -> base ) ; return error ; cleanup_dquot : dquot_free_block ( inode , EXT4_C2B ( EXT4_SB ( sb ) , 1 ) ) ; goto cleanup ; bad_block : EXT4_ERROR_INODE ( inode , ""badblock%llu"" , EXT4_I ( inode ) -> i_file_acl ) ; goto cleanup ; # undef header } "," s ; struct mb2_cache_entry * ce = 0 ; struct mb2_cache * ext4_mb_cache = base ) { BUFFER_TRACE ( bs ) ) { __u32 hash = le32_to_cpu ( BHDR ( bs -> bh ) -> h_hash ) ; mb2_cache_entry_delete_block ( ext4_mb_cache , hash , bs -> bh -> b_blocknr ) ; ea_bdebug ( bs bh ) ; ea_bdebug ( bs new_bh ) ; if ( hlist_bl_unhashed ( & ce -> e_hash_list ) ) { unlock_buffer ( new_bh ) ; dquot_free_block ( inode , EXT4_C2B ( EXT4_SB ( sb ) , 1 ) ) ; brelse ( new_bh ) ; mb2_cache_entry_put ( ext4_mb_cache , ce ) ; ce = NULL ; new_bh = NULL ; goto inserted ; } cleanup_dquot ; } mb2_cache_entry_touch ( ext4_mb_cache , ce ) ; mb2_cache_entry_put ( ext4_mb_cache , ce ) ; ( ce ) mb2_cache_entry_put ( ext4_mb_cache , ce ) ; ",torvalds@linux/82939d7999dfc1f1998c4b1c12e2f19edbdff272,CVE-2015-8952,https://github.com/torvalds/linux/commit/82939d7999dfc1f1998c4b1c12e2f19edbdff272,2016-10-16T21:59Z 339,CWE-000,"CWE-000 int dtls1_get_record ( SSL * s ) { int ssl_major , ssl_minor ; int i , n ; SSL3_RECORD * rr ; unsigned char * p = NULL ; unsigned short version ; DTLS1_BITMAP * bitmap ; unsigned int is_next_epoch ; rr = & ( s -> s3 -> rrec ) ; dtls1_process_buffered_records ( s ) ; if ( dtls1_get_processed_record ( s ) ) return 1 ; again : if ( ( s -> rstate != SSL_ST_READ_BODY ) || ( s -> packet_length < DTLS1_RT_HEADER_LENGTH ) ) { n = ssl3_read_n ( s , DTLS1_RT_HEADER_LENGTH , s -> s3 -> rbuf . len , 0 ) ; if ( n <= 0 ) return ( n ) ; if ( s -> packet_length != DTLS1_RT_HEADER_LENGTH ) { s -> packet_length = 0 ; goto again ; } s -> rstate = SSL_ST_READ_BODY ; p = s -> packet ; if ( s -> msg_callback ) s -> msg_callback ( 0 , 0 , SSL3_RT_HEADER , p , DTLS1_RT_HEADER_LENGTH , s , s -> msg_callback_arg ) ; rr -> type = * ( p ++ ) ; ssl_major = * ( p ++ ) ; ssl_minor = * ( p ++ ) ; version = ( ssl_major << 8 ) | ssl_minor ; n2s ( p , rr -> epoch ) ; memcpy ( & ( s -> s3 -> read_sequence [ 2 ] ) , p , 6 ) ; p += 6 ; n2s ( p , rr -> length ) ; if ( ! s -> first_packet ) { if ( version != s -> version ) { rr -> length = 0 ; s -> packet_length = 0 ; goto again ; } } if ( ( version & 0xff00 ) != ( s -> version & 0xff00 ) ) { rr -> length = 0 ; s -> packet_length = 0 ; goto again ; } if ( rr -> length > SSL3_RT_MAX_ENCRYPTED_LENGTH ) { rr -> length = 0 ; s -> packet_length = 0 ; goto again ; } } if ( rr -> length > s -> packet_length - DTLS1_RT_HEADER_LENGTH ) { i = rr -> length ; n = ssl3_read_n ( s , i , i , 1 ) ; if ( n != i ) { rr -> length = 0 ; s -> packet_length = 0 ; goto again ; } } s -> rstate = SSL_ST_READ_HEADER ; bitmap = dtls1_get_bitmap ( s , rr , & is_next_epoch ) ; if ( bitmap == NULL ) { rr -> length = 0 ; s -> packet_length = 0 ; goto again ; } # ifndef OPENSSL_NO_SCTP if ( ! BIO_dgram_is_sctp ( SSL_get_rbio ( s ) ) ) { # endif if ( ! ( s -> d1 -> listen && rr -> type == SSL3_RT_HANDSHAKE && * p == SSL3_MT_CLIENT_HELLO ) && ! dtls1_record_replay_check ( s , bitmap ) ) { rr -> length = 0 ; s -> packet_length = 0 ; goto again ; } # ifndef OPENSSL_NO_SCTP } # endif if ( rr -> length == 0 ) goto again ; if ( is_next_epoch ) { if ( ( SSL_in_init ( s ) || s -> in_handshake ) && ! s -> d1 -> listen ) { dtls1_buffer_record ( s , & ( s -> d1 -> unprocessed_rcds ) , rr -> seq_num ) ; } rr -> length = 0 ; s -> packet_length = 0 ; goto again ; } if ( ! dtls1_process_record ( s ) ) { rr -> length = 0 ; s -> packet_length = 0 ; goto again ; } return ( 1 ) ; } "," == SSL3_RT_HANDSHAKE && s -> packet_length > DTLS1_RT_HEADER_LENGTH && s -> packet [ DTLS1_RT_HEADER_LENGTH ] == SSL3_MT_CLIENT_HELLO ) ",openssl@openssl/248385c606620b29ecc96ca9d3603463f879652b,CVE-2014-3571,https://github.com/openssl/openssl/commit/248385c606620b29ecc96ca9d3603463f879652b,2015-01-09T02:59Z 340,CWE-125,"CWE-125 static int decode_rt_routing_info ( netdissect_options * ndo , const u_char * pptr , char * buf , u_int buflen ) { uint8_t route_target [ 8 ] ; u_int plen ; ND_TCHECK ( pptr [ 0 ] ) ; plen = pptr [ 0 ] ; if ( 0 == plen ) { snprintf ( buf , buflen , ""defaultroutetarget"" ) ; return 1 ; } if ( 32 > plen ) return - 1 ; plen -= 32 ; if ( 64 < plen ) return - 1 ; memset ( & route_target , 0 , sizeof ( route_target ) ) ; ND_TCHECK2 ( pptr [ 1 ] , ( plen + 7 ) / 8 ) ; memcpy ( & route_target , & pptr [ 1 ] , ( plen + 7 ) / 8 ) ; if ( plen % 8 ) { ( ( u_char * ) & route_target ) [ ( plen + 7 ) / 8 - 1 ] &= ( ( 0xff00 >> ( plen % 8 ) ) & 0xff ) ; } snprintf ( buf , buflen , ""originAS:%s,routetarget%s"" , as_printf ( ndo , astostr , sizeof ( astostr ) , EXTRACT_32BITS ( pptr + 1 ) ) , bgp_vpn_rd_print ( ndo , ( u_char * ) & route_target ) ) ; return 5 + ( plen + 7 ) / 8 ; trunc : return - 2 ; } "," u_int plen ; char asbuf [ sizeof ( astostr ) ] ; - 1 ; ND_TCHECK_32BITS ( pptr + 1 ) ; as_printf ( ndo , asbuf , sizeof ( asbuf ) , EXTRACT_32BITS ( pptr + 1 ) ) ; ( pptr [ 5 ] , ( & pptr [ 5 ] , ( , ""originAS:%s,routetarget%s"" , asbuf , bgp_vpn_rd_print ( ",the-tcpdump-group@tcpdump/bd4e697ebd6c8457efa8f28f6831fc929b88a014,CVE-2017-13053,https://github.com/the-tcpdump-group/tcpdump/commit/bd4e697ebd6c8457efa8f28f6831fc929b88a014,2017-09-14T06:29Z 341,CWE-400,"CWE-400 static void consume_one_event ( unsigned cpu , struct evtchn_fifo_control_block * control_block , unsigned priority , unsigned long * ready , bool drop ) { struct evtchn_fifo_queue * q = & per_cpu ( cpu_queue , cpu ) ; uint32_t head ; evtchn_port_t port ; event_word_t * word ; head = q -> head [ priority ] ; if ( head == 0 ) { virt_rmb ( ) ; head = control_block -> head [ priority ] ; } port = head ; word = event_word_from_port ( port ) ; head = clear_linked ( word ) ; if ( head == 0 ) clear_bit ( priority , ready ) ; if ( evtchn_fifo_is_pending ( port ) && ! evtchn_fifo_is_masked ( port ) ) { if ( unlikely ( drop ) ) pr_warn ( ""Droppingpendingeventforport%u\\n"" , port ) ; else handle_irq_for_port ( port ) ; } q -> head [ priority ] = head ; } "," ( unsigned cpu , struct evtchn_loop_ctrl * ctrl long * ready ) { struct ( unlikely ( ! ctrl ) ) pr_warn handle_irq_for_port ( port , ctrl ",torvalds@linux/e99502f76271d6bc4e374fe368c50c67a1fd3070,CVE-2020-27673,https://github.com/torvalds/linux/commit/e99502f76271d6bc4e374fe368c50c67a1fd3070,2020-10-22T21:15Z 342,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 343,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 344,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 345,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 346,CWE-399,"CWE-399 struct sctp_chunk * sctp_inq_pop ( struct sctp_inq * queue ) { struct sctp_chunk * chunk ; sctp_chunkhdr_t * ch = NULL ; if ( ( chunk = queue -> in_progress ) ) { if ( chunk -> singleton || chunk -> end_of_packet || chunk -> pdiscard ) { sctp_chunk_free ( chunk ) ; chunk = queue -> in_progress = NULL ; } else { ch = ( sctp_chunkhdr_t * ) chunk -> chunk_end ; skb_pull ( chunk -> skb , chunk -> chunk_end - chunk -> skb -> data ) ; if ( skb_headlen ( chunk -> skb ) < sizeof ( sctp_chunkhdr_t ) ) { sctp_chunk_free ( chunk ) ; chunk = queue -> in_progress = NULL ; } } } if ( ! chunk ) { struct list_head * entry ; if ( list_empty ( & queue -> in_chunk_list ) ) return NULL ; entry = queue -> in_chunk_list . next ; chunk = queue -> in_progress = list_entry ( entry , struct sctp_chunk , list ) ; list_del_init ( entry ) ; chunk -> singleton = 1 ; ch = ( sctp_chunkhdr_t * ) chunk -> skb -> data ; chunk -> data_accepted = 0 ; } chunk -> chunk_hdr = ch ; chunk -> chunk_end = ( ( __u8 * ) ch ) + WORD_ROUND ( ntohs ( ch -> length ) ) ; if ( unlikely ( skb_is_nonlinear ( chunk -> skb ) ) ) { if ( chunk -> chunk_end > skb_tail_pointer ( chunk -> skb ) ) chunk -> chunk_end = skb_tail_pointer ( chunk -> skb ) ; } skb_pull ( chunk -> skb , sizeof ( sctp_chunkhdr_t ) ) ; chunk -> subh . v = NULL ; if ( chunk -> chunk_end < skb_tail_pointer ( chunk -> skb ) ) { chunk -> singleton = 0 ; } else if ( chunk -> chunk_end > skb_tail_pointer ( chunk -> skb ) ) { sctp_chunk_free ( chunk ) ; chunk = queue -> in_progress = NULL ; return NULL ; } else { chunk -> end_of_packet = 1 ; } pr_debug ( ""+++sctp_inq_pop+++chunk:%p[%s],length:%d,skb->len:%d\\n"" , chunk , sctp_cname ( SCTP_ST_CHUNK ( chunk -> chunk_hdr -> type ) ) , ntohs ( chunk -> chunk_hdr -> length ) , chunk -> skb -> len ) ; return chunk ; } "," data ) ; } } if chunk -> chunk_end + sizeof ( sctp_chunkhdr_t ) ) ) { chunk -> pdiscard = 1 ; chunk -> chunk_end = skb_tail_pointer ( chunk -> skb ) ; } else { chunk -> end_of_packet = 1 ; } pr_debug ( ""+++sctp_inq_pop+++chunk:%p[%s],length:%d,skb->len:%d\\n"" , chunk , sctp_cname ( SCTP_ST_CHUNK ( chunk -> chunk_hdr -> type ) ) , ntohs ( chunk -> chunk_hdr -> length ) , chunk -> skb -> len ) ; return chunk ; } ",torvalds@linux/26b87c7881006311828bb0ab271a551a62dcceb4,CVE-2014-3688,https://github.com/torvalds/linux/commit/26b87c7881006311828bb0ab271a551a62dcceb4,2014-11-30T01:59Z 347,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 348,CWE-119,"CWE-119 int squidclamav_check_preview_handler ( char * preview_data , int preview_data_len , ci_request_t * req ) { ci_headers_list_t * req_header ; struct http_info httpinf ; av_req_data_t * data = ci_service_data ( req ) ; char * clientip ; struct hostent * clientname ; unsigned long ip ; char * username ; char * content_type ; ci_off_t content_length ; char * chain_ret = NULL ; char * ret = NULL ; int chkipdone = 0 ; ci_debug_printf ( 1 , ""DEBUGsquidclamav_check_preview_handler:processingpreviewheader.\\n"" ) ; if ( preview_data_len ) ci_debug_printf ( 1 , ""DEBUGsquidclamav_check_preview_handler:previewdatasizeis%d\\n"" , preview_data_len ) ; if ( ( req_header = ci_http_request_headers ( req ) ) == NULL ) { ci_debug_printf ( 0 , ""ERRORsquidclamav_check_preview_handler:badhttpheader,aborting.\\n"" ) ; return CI_ERROR ; } if ( ( username = ci_headers_value ( req -> request_header , ""X-Authenticated-User"" ) ) != NULL ) { ci_debug_printf ( 2 , ""DEBUGsquidclamav_check_preview_handler:X-Authenticated-User:%s\\n"" , username ) ; if ( simple_pattern_compare ( username , TRUSTUSER ) == 1 ) { ci_debug_printf ( 1 , ""DEBUGsquidclamav_check_preview_handler:Nosquidguardandantivircheck(TRUSTUSERmatch)foruser:%s\\n"" , username ) ; return CI_MOD_ALLOW204 ; } } else { username = ( char * ) malloc ( sizeof ( char ) * 2 ) ; strcpy ( username , ""-"" ) ; } if ( ( clientip = ci_headers_value ( req -> request_header , ""X-Client-IP"" ) ) != NULL ) { ci_debug_printf ( 2 , ""DEBUGsquidclamav_check_preview_handler:X-Client-IP:%s\\n"" , clientip ) ; ip = inet_addr ( clientip ) ; chkipdone = 0 ; if ( dnslookup == 1 ) { if ( ( clientname = gethostbyaddr ( ( char * ) & ip , sizeof ( ip ) , AF_INET ) ) != NULL ) { if ( clientname -> h_name != NULL ) { if ( client_pattern_compare ( clientip , clientname -> h_name ) > 0 ) { ci_debug_printf ( 1 , ""DEBUGsquidclamav_check_preview_handler:Nosquidguardandantivircheck(TRUSTCLIENTmatch)forclient:%s(%s)\\n"" , clientname -> h_name , clientip ) ; return CI_MOD_ALLOW204 ; } chkipdone = 1 ; } } } if ( chkipdone == 0 ) { if ( client_pattern_compare ( clientip , NULL ) > 0 ) { ci_debug_printf ( 1 , ""DEBUGsquidclamav_check_preview_handler:Nosquidguardandantivircheck(TRUSTCLIENTmatch)forclient:%s\\n"" , clientip ) ; return CI_MOD_ALLOW204 ; } } } else { clientip = ( char * ) malloc ( sizeof ( char ) * 2 ) ; strcpy ( clientip , ""-"" ) ; } if ( ! extract_http_info ( req , req_header , & httpinf ) ) { ci_debug_printf ( 1 , ""DEBUGsquidclamav_check_preview_handler:badhttpheader,aborting.\\n"" ) ; return CI_MOD_ALLOW204 ; } ci_debug_printf ( 2 , ""DEBUGsquidclamav_check_preview_handler:URLrequested:%s\\n"" , httpinf . url ) ; if ( simple_pattern_compare ( httpinf . url , WHITELIST ) == 1 ) { ci_debug_printf ( 1 , ""DEBUGsquidclamav_check_preview_handler:Nosquidguardandantivircheck(WHITELISTmatch)forurl:%s\\n"" , httpinf . url ) ; return CI_MOD_ALLOW204 ; } if ( usepipe == 1 ) { ci_debug_printf ( 2 , ""DEBUGsquidclamav_check_preview_handler:Sendingrequesttochainedprogram:%s\\n"" , squidguard ) ; ci_debug_printf ( 2 , ""DEBUGsquidclamav_check_preview_handler:Request:%s%s%s%s\\n"" , httpinf . url , clientip , username , httpinf . method ) ; fprintf ( sgfpw , ""%s%s%s%s\\n"" , httpinf . url , clientip , username , httpinf . method ) ; fflush ( sgfpw ) ; chain_ret = ( char * ) malloc ( sizeof ( char ) * MAX_URL_SIZE ) ; if ( chain_ret != NULL ) { ret = fgets ( chain_ret , MAX_URL_SIZE , sgfpr ) ; if ( ( ret != NULL ) && ( strlen ( chain_ret ) > 1 ) ) { ci_debug_printf ( 1 , ""DEBUGsquidclamav_check_preview_handler:Chainedprogramredirectionreceived:%s\\n"" , chain_ret ) ; if ( logredir ) ci_debug_printf ( 0 , ""INFOChainedprogramredirectionreceived:%s\\n"" , chain_ret ) ; data -> blocked = 1 ; generate_redirect_page ( strtok ( chain_ret , """" ) , req , data ) ; xfree ( chain_ret ) ; chain_ret = NULL ; return CI_MOD_CONTINUE ; } xfree ( chain_ret ) ; chain_ret = NULL ; } } if ( strcmp ( httpinf . method , ""CONNECT"" ) == 0 ) { ci_debug_printf ( 2 , ""DEBUGsquidclamav_check_preview_handler:method%scan\'tbescanned.\\n"" , httpinf . method ) ; return CI_MOD_ALLOW204 ; } if ( simple_pattern_compare ( httpinf . url , ABORT ) == 1 ) { ci_debug_printf ( 1 , ""DEBUGsquidclamav_check_preview_handler:Noantivircheck(ABORTmatch)forurl:%s\\n"" , httpinf . url ) ; return CI_MOD_ALLOW204 ; } content_length = ci_http_content_length ( req ) ; ci_debug_printf ( 2 , ""DEBUGsquidclamav_check_preview_handler:Content-Length:%d\\n"" , ( int ) content_length ) ; if ( ( content_length > 0 ) && ( maxsize > 0 ) && ( content_length >= maxsize ) ) { ci_debug_printf ( 2 , ""DEBUGsquidclamav_check_preview_handler:Noantivircheck,content-lengthupperthanmaxsize(%d>%d)\\n"" , content_length , ( int ) maxsize ) ; return CI_MOD_ALLOW204 ; } if ( ( content_type = http_content_type ( req ) ) != NULL ) { ci_debug_printf ( 2 , ""DEBUGsquidclamav_check_preview_handler:Content-Type:%s\\n"" , content_type ) ; if ( simple_pattern_compare ( content_type , ABORTCONTENT ) ) { ci_debug_printf ( 1 , ""DEBUGsquidclamav_check_preview_handler:Noantivircheck(ABORTCONTENTmatch)forcontent-type:%s\\n"" , content_type ) ; return CI_MOD_ALLOW204 ; } } if ( ! data || ! ci_req_hasbody ( req ) ) { ci_debug_printf ( 1 , ""DEBUGsquidclamav_check_preview_handler:Nobodydata,allow204\\n"" ) ; return CI_MOD_ALLOW204 ; } if ( preview_data_len == 0 ) { ci_debug_printf ( 1 , ""DEBUGsquidclamav_check_preview_handler:cannotbegintoscanurl:Nopreviewdata.\\n"" ) ; return CI_MOD_ALLOW204 ; } data -> url = ci_buffer_alloc ( strlen ( httpinf . url ) + 1 ) ; strcpy ( data -> url , httpinf . url ) ; if ( username != NULL ) { data -> user = ci_buffer_alloc ( strlen ( username ) + 1 ) ; strcpy ( data -> user , username ) ; } else { data -> user = NULL ; } if ( clientip != NULL ) { data -> clientip = ci_buffer_alloc ( strlen ( clientip ) + 1 ) ; strcpy ( data -> clientip , clientip ) ; } else { ci_debug_printf ( 0 , ""ERRORsquidclamav_check_preview_handler:clientipisnull,youmustset\'icap_send_client_ipon\'intosquid.conf\\n"" ) ; data -> clientip = NULL ; } data -> body = ci_simple_file_new ( 0 ) ; if ( ( SEND_PERCENT_BYTES >= 0 ) && ( START_SEND_AFTER == 0 ) ) { ci_req_unlock_data ( req ) ; ci_simple_file_lock_all ( data -> body ) ; } if ( ! data -> body ) return CI_ERROR ; if ( preview_data_len ) { if ( ci_simple_file_write ( data -> body , preview_data , preview_data_len , ci_req_hasalldata ( req ) ) == CI_ERROR ) return CI_ERROR ; } return CI_MOD_CONTINUE ; } "," 1 ) { char * rbuff = NULL ; method ) ; rbuff = replace ( httpinf . url , ""%"" , ""%25"" ) ; , ""%s%s%s%s\\n"" , rbuff , clientip , fflush ( sgfpw ) ; xfree ( rbuff ",darold@squidclamav/80f74451f628264d1d9a1f1c0bbcebc932ba5e00,CVE-2012-3501,https://github.com/darold/squidclamav/commit/80f74451f628264d1d9a1f1c0bbcebc932ba5e00,2012-08-25T10:29Z 349,CWE-125,"CWE-125 static void r_bin_dwarf_dump_debug_info ( FILE * f , const RBinDwarfDebugInfo * inf ) { size_t i , j , k ; RBinDwarfDIE * dies ; RBinDwarfAttrValue * values ; if ( ! inf || ! f ) { return ; } for ( i = 0 ; i < inf -> length ; i ++ ) { fprintf ( f , ""CompilationUnit@offset0x%"" PFMT64x "":\\n"" , inf -> comp_units [ i ] . offset ) ; fprintf ( f , ""Length:0x%x\\n"" , inf -> comp_units [ i ] . hdr . length ) ; fprintf ( f , ""Version:%d\\n"" , inf -> comp_units [ i ] . hdr . version ) ; fprintf ( f , ""AbbrevOffset:0x%x\\n"" , inf -> comp_units [ i ] . hdr . abbrev_offset ) ; fprintf ( f , ""PointerSize:%d\\n"" , inf -> comp_units [ i ] . hdr . pointer_size ) ; dies = inf -> comp_units [ i ] . dies ; for ( j = 0 ; j < inf -> comp_units [ i ] . length ; j ++ ) { fprintf ( f , ""AbbrevNumber:%"" PFMT64u """" , dies [ j ] . abbrev_code ) ; if ( dies [ j ] . tag && dies [ j ] . tag <= DW_TAG_volatile_type && dwarf_tag_name_encodings [ dies [ j ] . tag ] ) { fprintf ( f , ""(%s)\\n"" , dwarf_tag_name_encodings [ dies [ j ] . tag ] ) ; } else { fprintf ( f , ""(Unknownabbrevtag)\\n"" ) ; } if ( ! dies [ j ] . abbrev_code ) { continue ; } values = dies [ j ] . attr_values ; for ( k = 0 ; k < dies [ j ] . length ; k ++ ) { if ( ! values [ k ] . name ) continue ; if ( values [ k ] . name < DW_AT_vtable_elem_location && dwarf_attr_encodings [ values [ k ] . name ] ) { fprintf ( f , ""%-18s:"" , dwarf_attr_encodings [ values [ k ] . name ] ) ; } else { fprintf ( f , ""TODO\\t"" ) ; } r_bin_dwarf_dump_attr_value ( & values [ k ] , f ) ; fprintf ( f , ""\\n"" ) ; } } } } "," . name ) { continue ; } if ( values ",radare@radare2/2ca9ab45891b6ae8e32b6c28c81eebca059cbe5d,CVE-2017-16805,https://github.com/radare/radare2/commit/2ca9ab45891b6ae8e32b6c28c81eebca059cbe5d,2017-11-13T21:29Z 350,CWE-20,"CWE-20 static int irda_recvmsg_stream ( struct kiocb * iocb , struct socket * sock , struct msghdr * msg , size_t size , int flags ) { struct sock * sk = sock -> sk ; struct irda_sock * self = irda_sk ( sk ) ; int noblock = flags & MSG_DONTWAIT ; size_t copied = 0 ; int target , err ; long timeo ; IRDA_DEBUG ( 3 , ""%s()\\n"" , __func__ ) ; if ( ( err = sock_error ( sk ) ) < 0 ) return err ; if ( sock -> flags & __SO_ACCEPTCON ) return - EINVAL ; err = - EOPNOTSUPP ; if ( flags & MSG_OOB ) return - EOPNOTSUPP ; err = 0 ; target = sock_rcvlowat ( sk , flags & MSG_WAITALL , size ) ; timeo = sock_rcvtimeo ( sk , noblock ) ; msg -> msg_namelen = 0 ; do { int chunk ; struct sk_buff * skb = skb_dequeue ( & sk -> sk_receive_queue ) ; if ( skb == NULL ) { DEFINE_WAIT ( wait ) ; err = 0 ; if ( copied >= target ) break ; prepare_to_wait_exclusive ( sk_sleep ( sk ) , & wait , TASK_INTERRUPTIBLE ) ; err = sock_error ( sk ) ; if ( err ) ; else if ( sk -> sk_shutdown & RCV_SHUTDOWN ) ; else if ( noblock ) err = - EAGAIN ; else if ( signal_pending ( current ) ) err = sock_intr_errno ( timeo ) ; else if ( sk -> sk_state != TCP_ESTABLISHED ) err = - ENOTCONN ; else if ( skb_peek ( & sk -> sk_receive_queue ) == NULL ) schedule ( ) ; finish_wait ( sk_sleep ( sk ) , & wait ) ; if ( err ) return err ; if ( sk -> sk_shutdown & RCV_SHUTDOWN ) break ; continue ; } 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 ) { IRDA_DEBUG ( 1 , ""%s(),backonq!\\n"" , __func__ ) ; skb_queue_head ( & sk -> sk_receive_queue , skb ) ; break ; } kfree_skb ( skb ) ; } else { IRDA_DEBUG ( 0 , ""%s()questionable!?\\n"" , __func__ ) ; skb_queue_head ( & sk -> sk_receive_queue , skb ) ; break ; } } while ( size ) ; if ( self -> rx_flow == FLOW_STOP ) { if ( ( atomic_read ( & sk -> sk_rmem_alloc ) << 2 ) <= sk -> sk_rcvbuf ) { IRDA_DEBUG ( 2 , ""%s(),StartingIrTTP\\n"" , __func__ ) ; self -> rx_flow = FLOW_START ; irttp_flow_request ( self -> tsap , FLOW_START ) ; } } return copied ; } "," noblock ) ; do { int ",torvalds@linux/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,CVE-2013-7271,https://github.com/torvalds/linux/commit/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,2014-01-06T16:55Z 351,CWE-310,"CWE-310 static unsigned int do_encrypt ( const RIJNDAEL_context * ctx , unsigned char * bx , const unsigned char * ax ) { # ifdef USE_AMD64_ASM return _gcry_aes_amd64_encrypt_block ( ctx -> keyschenc , bx , ax , ctx -> rounds , encT ) ; # elif defined ( USE_ARM_ASM ) return _gcry_aes_arm_encrypt_block ( ctx -> keyschenc , bx , ax , ctx -> rounds , encT ) ; # else return do_encrypt_fn ( ctx , bx , ax ) ; # endif } "," -> rounds , enc_tables . T ) ; # -> rounds , enc_tables . T ) ; # ",gpg@libgcrypt/daedbbb5541cd8ecda1459d3b843ea4d92788762,CVE-2019-12904,https://github.com/gpg/libgcrypt/commit/daedbbb5541cd8ecda1459d3b843ea4d92788762,2019-06-20T00:15Z 352,CWE-189,"CWE-189 PHP_FUNCTION ( imagecrop ) { zval * IM ; gdImagePtr im ; gdImagePtr im_crop ; gdRect rect ; zval * z_rect ; zval * * tmp ; if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) TSRMLS_CC , ""ra"" , & IM , & z_rect ) == FAILURE ) { return ; } ZEND_FETCH_RESOURCE ( im , gdImagePtr , & IM , - 1 , ""Image"" , le_gd ) ; if ( zend_hash_find ( HASH_OF ( z_rect ) , ""x"" , sizeof ( ""x"" ) , ( void * * ) & tmp ) != FAILURE ) { 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 ) { 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 ) { 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 ) { rect . height = Z_LVAL_PP ( tmp ) ; } else { php_error_docref ( NULL TSRMLS_CC , E_WARNING , ""Missingheight"" ) ; RETURN_FALSE ; } im_crop = gdImageCrop ( im , & rect ) ; if ( im_crop == NULL ) { RETURN_FALSE ; } else { ZEND_REGISTER_RESOURCE ( return_value , im_crop , le_gd ) ; } } "," FAILURE ) { if ( Z_TYPE_PP ( tmp ) != IS_LONG ) { zval lval ; lval = * * tmp ; zval_copy_ctor ( & lval ) ; convert_to_long ( & lval ) ; . x = Z_LVAL ( lval ) ; } else { rect . x = tmp ) ; } FAILURE ) { if ( Z_TYPE_PP ( tmp ) != IS_LONG ) { zval lval ; lval = * * tmp ; zval_copy_ctor ( & lval ) ; convert_to_long ( & lval ) ; . y = Z_LVAL ( lval ) ; } else { rect . y = tmp ) ; } FAILURE ) { if ( Z_TYPE_PP ( tmp ) != IS_LONG ) { zval lval ; lval = * * tmp ; zval_copy_ctor ( & lval ) ; convert_to_long ( & lval ) ; . width = Z_LVAL ( lval ) ; } else { rect . width = tmp ) ; } FAILURE ) { if ( Z_TYPE_PP ( tmp ) != IS_LONG ) { zval lval ; lval = * * tmp ; zval_copy_ctor ( & lval ) ; convert_to_long ( & lval ) ; . 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 353,CWE-787,"CWE-787 static int decode_frame ( AVCodecContext * avctx , void * data , int * got_frame , AVPacket * avpkt ) { PicContext * s = avctx -> priv_data ; AVFrame * frame = data ; uint32_t * palette ; int bits_per_plane , bpp , etype , esize , npal , pos_after_pal ; int i , x , y , plane , tmp , ret , val ; bytestream2_init ( & s -> g , avpkt -> data , avpkt -> size ) ; if ( bytestream2_get_bytes_left ( & s -> g ) < 11 ) return AVERROR_INVALIDDATA ; if ( bytestream2_get_le16u ( & s -> g ) != 0x1234 ) return AVERROR_INVALIDDATA ; s -> width = bytestream2_get_le16u ( & s -> g ) ; s -> height = bytestream2_get_le16u ( & s -> g ) ; bytestream2_skip ( & s -> g , 4 ) ; tmp = bytestream2_get_byteu ( & s -> g ) ; bits_per_plane = tmp & 0xF ; s -> nb_planes = ( tmp >> 4 ) + 1 ; bpp = bits_per_plane * s -> nb_planes ; if ( bits_per_plane > 8 || bpp < 1 || bpp > 32 ) { avpriv_request_sample ( avctx , ""Unsupportedbitdepth"" ) ; return AVERROR_PATCHWELCOME ; } if ( bytestream2_peek_byte ( & s -> g ) == 0xFF || bpp == 1 || bpp == 4 || bpp == 8 ) { bytestream2_skip ( & s -> g , 2 ) ; etype = bytestream2_get_le16 ( & s -> g ) ; esize = bytestream2_get_le16 ( & s -> g ) ; if ( bytestream2_get_bytes_left ( & s -> g ) < esize ) return AVERROR_INVALIDDATA ; } else { etype = - 1 ; esize = 0 ; } avctx -> pix_fmt = AV_PIX_FMT_PAL8 ; if ( av_image_check_size ( s -> width , s -> height , 0 , avctx ) < 0 ) return - 1 ; if ( s -> width != avctx -> width && s -> height != avctx -> height ) { ret = ff_set_dimensions ( avctx , s -> width , s -> height ) ; if ( ret < 0 ) return ret ; } if ( ( ret = ff_get_buffer ( avctx , frame , 0 ) ) < 0 ) return ret ; memset ( frame -> data [ 0 ] , 0 , s -> height * frame -> linesize [ 0 ] ) ; frame -> pict_type = AV_PICTURE_TYPE_I ; frame -> palette_has_changed = 1 ; pos_after_pal = bytestream2_tell ( & s -> g ) + esize ; palette = ( uint32_t * ) frame -> data [ 1 ] ; if ( etype == 1 && esize > 1 && bytestream2_peek_byte ( & s -> g ) < 6 ) { int idx = bytestream2_get_byte ( & s -> g ) ; npal = 4 ; for ( i = 0 ; i < npal ; i ++ ) palette [ i ] = ff_cga_palette [ cga_mode45_index [ idx ] [ i ] ] ; } else if ( etype == 2 ) { npal = FFMIN ( esize , 16 ) ; for ( i = 0 ; i < npal ; i ++ ) { int pal_idx = bytestream2_get_byte ( & s -> g ) ; palette [ i ] = ff_cga_palette [ FFMIN ( pal_idx , 15 ) ] ; } } else if ( etype == 3 ) { npal = FFMIN ( esize , 16 ) ; for ( i = 0 ; i < npal ; i ++ ) { int pal_idx = bytestream2_get_byte ( & s -> g ) ; palette [ i ] = ff_ega_palette [ FFMIN ( pal_idx , 63 ) ] ; } } else if ( etype == 4 || etype == 5 ) { npal = FFMIN ( esize / 3 , 256 ) ; for ( i = 0 ; i < npal ; i ++ ) { palette [ i ] = bytestream2_get_be24 ( & s -> g ) << 2 ; palette [ i ] |= 0xFFU << 24 | palette [ i ] >> 6 & 0x30303 ; } } else { if ( bpp == 1 ) { npal = 2 ; palette [ 0 ] = 0xFF000000 ; palette [ 1 ] = 0xFFFFFFFF ; } else if ( bpp == 2 ) { npal = 4 ; for ( i = 0 ; i < npal ; i ++ ) palette [ i ] = ff_cga_palette [ cga_mode45_index [ 0 ] [ i ] ] ; } else { npal = 16 ; memcpy ( palette , ff_cga_palette , npal * 4 ) ; } } memset ( palette + npal , 0 , AVPALETTE_SIZE - npal * 4 ) ; bytestream2_seek ( & s -> g , pos_after_pal , SEEK_SET ) ; val = 0 ; y = s -> height - 1 ; if ( bytestream2_get_le16 ( & s -> g ) ) { x = 0 ; plane = 0 ; while ( bytestream2_get_bytes_left ( & s -> g ) >= 6 ) { int stop_size , marker , t1 , t2 ; t1 = bytestream2_get_bytes_left ( & s -> g ) ; t2 = bytestream2_get_le16 ( & s -> g ) ; stop_size = t1 - FFMIN ( t1 , t2 ) ; bytestream2_skip ( & s -> g , 2 ) ; marker = bytestream2_get_byte ( & s -> g ) ; while ( plane < s -> nb_planes && bytestream2_get_bytes_left ( & s -> g ) > stop_size ) { int run = 1 ; val = bytestream2_get_byte ( & s -> g ) ; if ( val == marker ) { run = bytestream2_get_byte ( & s -> g ) ; if ( run == 0 ) run = bytestream2_get_le16 ( & s -> g ) ; val = bytestream2_get_byte ( & s -> g ) ; } if ( ! bytestream2_get_bytes_left ( & s -> g ) ) break ; if ( bits_per_plane == 8 ) { picmemset_8bpp ( s , frame , val , run , & x , & y ) ; if ( y < 0 ) goto finish ; } else { picmemset ( s , frame , val , run , & x , & y , & plane , bits_per_plane ) ; } } } if ( x < avctx -> width ) { int run = ( y + 1 ) * avctx -> width - x ; if ( bits_per_plane == 8 ) picmemset_8bpp ( s , frame , val , run , & x , & y ) ; else picmemset ( s , frame , val , run / ( 8 / bits_per_plane ) , & x , & y , & plane , bits_per_plane ) ; } } else { while ( y >= 0 && bytestream2_get_bytes_left ( & s -> g ) > 0 ) { memcpy ( frame -> data [ 0 ] + y * frame -> linesize [ 0 ] , s -> g . buffer , FFMIN ( avctx -> width , bytestream2_get_bytes_left ( & s -> g ) ) ) ; bytestream2_skip ( & s -> g , avctx -> width ) ; y -- ; } } finish : * got_frame = 1 ; return avpkt -> size ; } "," avctx -> width || s -> height ",FFmpeg@FFmpeg/8c2ea3030af7b40a3c4275696fb5c76cdb80950a,CVE-2017-7862,https://github.com/FFmpeg/FFmpeg/commit/8c2ea3030af7b40a3c4275696fb5c76cdb80950a,2017-04-14T04:59Z 354,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 355,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 356,CWE-125,"CWE-125 void isakmp_rfc3948_print ( netdissect_options * ndo , const u_char * bp , u_int length , const u_char * bp2 ) { if ( length == 1 && bp [ 0 ] == 0xff ) { ND_PRINT ( ( ndo , ""isakmp-nat-keep-alive"" ) ) ; return ; } if ( length < 4 ) { goto trunc ; } if ( bp [ 0 ] == 0 && bp [ 1 ] == 0 && bp [ 2 ] == 0 && bp [ 3 ] == 0 ) { ND_PRINT ( ( ndo , ""NONESP-encap:"" ) ) ; isakmp_print ( ndo , bp + 4 , length - 4 , bp2 ) ; return ; } { int nh , enh , padlen ; int advance ; ND_PRINT ( ( ndo , ""UDP-encap:"" ) ) ; advance = esp_print ( ndo , bp , length , bp2 , & enh , & padlen ) ; if ( advance <= 0 ) return ; bp += advance ; length -= advance + padlen ; nh = enh & 0xff ; ip_print_inner ( ndo , bp , length , nh , bp2 ) ; return ; } trunc : ND_PRINT ( ( ndo , ""[|isakmp]"" ) ) ; return ; } "," bp2 ) { ND_TCHECK ( bp [ 0 ] ) ; trunc ; } ND_TCHECK ( bp [ 3 ] ) ; ",the-tcpdump-group@tcpdump/f76e7feb41a4327d2b0978449bbdafe98d4a3771,CVE-2017-12896,https://github.com/the-tcpdump-group/tcpdump/commit/f76e7feb41a4327d2b0978449bbdafe98d4a3771,2017-09-14T06:29Z 357,CWE-444,"CWE-444 static void add_header_value ( VALUE hh , const char * key , int klen , const char * val , int vlen ) { if ( sizeof ( content_type ) - 1 == klen && 0 == strncasecmp ( key , content_type , sizeof ( content_type ) - 1 ) ) { rb_hash_aset ( hh , content_type_val , rb_str_new ( val , vlen ) ) ; } else if ( sizeof ( content_length ) - 1 == klen && 0 == strncasecmp ( key , content_length , sizeof ( content_length ) - 1 ) ) { rb_hash_aset ( hh , content_length_val , rb_str_new ( val , vlen ) ) ; } else { char hkey [ 1024 ] ; char * k = hkey ; volatile VALUE sval = rb_str_new ( val , vlen ) ; strcpy ( hkey , ""HTTP_"" ) ; k = hkey + 5 ; if ( ( int ) ( sizeof ( hkey ) - 5 ) <= klen ) { klen = sizeof ( hkey ) - 6 ; } strncpy ( k , key , klen ) ; hkey [ klen + 5 ] = '\\0' ; for ( k = hkey + 5 ; '\\0' != * k ; k ++ ) { if ( '-' == * k ) { * k = '_' ; } else { * k = toupper ( * k ) ; } } rb_hash_aset ( hh , rb_str_new ( hkey , klen + 5 ) , sval ) ; } } "," vlen ) { VALUE v ; ) ) { if ( Qnil == ( v = rb_hash_lookup2 ( hh , content_type_val , Qnil ) ) ) { ) ) ; } else { volatile VALUE a = rb_ary_new ( ) ; rb_ary_push ( a , v ) ; rb_ary_push ( a , rb_str_new ( val , vlen ) ) ; rb_hash_aset ( hh , content_type_val , a ) ; } ) ) { if ( Qnil == ( v = rb_hash_lookup2 ( hh , content_length_val , Qnil ) ) ) { ) ) ; } else { rb_raise ( rb_eArgError , ""MultipleContent-Lengthheaders."" ) ; } vlen ) ; volatile VALUE kval ; ; } } kval = rb_str_new ( hkey + 5 ) ; if ( Qnil == ( v = rb_hash_lookup2 ( hh , kval , Qnil ) ) ) { rb_hash_aset ( hh , kval ) ; } else { volatile VALUE a = rb_ary_new ( ) ; rb_ary_push ( a , v ) ; rb_ary_push ( a , sval ) ; rb_hash_aset ( hh , kval , a ) ; } } ",ohler55@agoo/23d03535cf7b50d679a60a953a0cae9519a4a130,CVE-2020-7670,https://github.com/ohler55/agoo/commit/23d03535cf7b50d679a60a953a0cae9519a4a130,2020-06-10T16:15Z 358,CWE-908,"CWE-908 static Image * ReadCUTImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define ThrowCUTReaderException ( severity , tag ) { if ( palette != NULL ) palette = DestroyImage ( palette ) ; if ( clone_info != NULL ) clone_info = DestroyImageInfo ( clone_info ) ; ThrowReaderException ( severity , tag ) ; } Image * image , * palette ; ImageInfo * clone_info ; MagickBooleanType status ; MagickOffsetType offset ; size_t EncodedByte ; unsigned char RunCount , RunValue , RunCountMasked ; CUTHeader Header ; CUTPalHeader PalHeader ; ssize_t depth ; ssize_t i , j ; ssize_t ldblk ; unsigned char * BImgBuff = NULL , * ptrB ; PixelPacket * q ; 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 ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } palette = NULL ; clone_info = NULL ; Header . Width = ReadBlobLSBShort ( image ) ; Header . Height = ReadBlobLSBShort ( image ) ; Header . Reserved = ReadBlobLSBShort ( image ) ; if ( Header . Width == 0 || Header . Height == 0 || Header . Reserved != 0 ) CUT_KO : ThrowCUTReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; EncodedByte = ReadBlobLSBShort ( image ) ; RunCount = ( unsigned char ) ReadBlobByte ( image ) ; RunCountMasked = RunCount & 0x7F ; ldblk = 0 ; while ( ( int ) RunCountMasked != 0 ) { i = 1 ; if ( ( int ) RunCount < 0x80 ) i = ( ssize_t ) RunCountMasked ; offset = SeekBlob ( image , TellBlob ( image ) + i , SEEK_SET ) ; if ( offset < 0 ) ThrowCUTReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( EOFBlob ( image ) != MagickFalse ) goto CUT_KO ; EncodedByte -= i + 1 ; ldblk += ( ssize_t ) RunCountMasked ; RunCount = ( unsigned char ) ReadBlobByte ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) goto CUT_KO ; RunCountMasked = RunCount & 0x7F ; } if ( EncodedByte != 1 ) goto CUT_KO ; i = 0 ; if ( ldblk == ( int ) Header . Width ) i = 8 ; if ( 2 * ldblk == ( int ) Header . Width ) i = 4 ; if ( 8 * ldblk == ( int ) Header . Width ) i = 1 ; if ( i == 0 ) goto CUT_KO ; depth = i ; image -> columns = Header . Width ; image -> rows = Header . Height ; image -> depth = 8 ; image -> colors = ( size_t ) ( GetQuantumRange ( 1UL * i ) + 1 ) ; if ( image_info -> ping != MagickFalse ) goto Finish ; status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; } if ( ( clone_info = CloneImageInfo ( image_info ) ) == NULL ) goto NoPalette ; i = ( ssize_t ) strlen ( clone_info -> filename ) ; j = i ; while ( -- i > 0 ) { if ( clone_info -> filename [ i ] == '.' ) { break ; } if ( clone_info -> filename [ i ] == '/' || clone_info -> filename [ i ] == '\\\\' || clone_info -> filename [ i ] == ':' ) { i = j ; break ; } } ( void ) CopyMagickString ( clone_info -> filename + i , "".PAL"" , ( size_t ) ( MaxTextExtent - i ) ) ; if ( ( clone_info -> file = fopen_utf8 ( clone_info -> filename , ""rb"" ) ) == NULL ) { ( void ) CopyMagickString ( clone_info -> filename + i , "".pal"" , ( size_t ) ( MaxTextExtent - i ) ) ; if ( ( clone_info -> file = fopen_utf8 ( clone_info -> filename , ""rb"" ) ) == NULL ) { clone_info -> filename [ i ] = '\\0' ; if ( ( clone_info -> file = fopen_utf8 ( clone_info -> filename , ""rb"" ) ) == NULL ) { clone_info = DestroyImageInfo ( clone_info ) ; clone_info = NULL ; goto NoPalette ; } } } if ( ( palette = AcquireImage ( clone_info ) ) == NULL ) goto NoPalette ; status = OpenBlob ( clone_info , palette , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { ErasePalette : palette = DestroyImage ( palette ) ; palette = NULL ; goto NoPalette ; } if ( palette != NULL ) { ( void ) ReadBlob ( palette , 2 , ( unsigned char * ) PalHeader . FileId ) ; if ( strncmp ( PalHeader . FileId , ""AH"" , 2 ) != 0 ) goto ErasePalette ; PalHeader . Version = ReadBlobLSBShort ( palette ) ; PalHeader . Size = ReadBlobLSBShort ( palette ) ; PalHeader . FileType = ( char ) ReadBlobByte ( palette ) ; PalHeader . SubType = ( char ) ReadBlobByte ( palette ) ; PalHeader . BoardID = ReadBlobLSBShort ( palette ) ; PalHeader . GraphicsMode = ReadBlobLSBShort ( palette ) ; PalHeader . MaxIndex = ReadBlobLSBShort ( palette ) ; PalHeader . MaxRed = ReadBlobLSBShort ( palette ) ; PalHeader . MaxGreen = ReadBlobLSBShort ( palette ) ; PalHeader . MaxBlue = ReadBlobLSBShort ( palette ) ; ( void ) ReadBlob ( palette , 20 , ( unsigned char * ) PalHeader . PaletteId ) ; if ( EOFBlob ( image ) ) ThrowCUTReaderException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; if ( PalHeader . MaxIndex < 1 ) goto ErasePalette ; image -> colors = PalHeader . MaxIndex + 1 ; if ( AcquireImageColormap ( image , image -> colors ) == MagickFalse ) goto NoMemory ; if ( PalHeader . MaxRed == 0 ) PalHeader . MaxRed = ( unsigned int ) QuantumRange ; if ( PalHeader . MaxGreen == 0 ) PalHeader . MaxGreen = ( unsigned int ) QuantumRange ; if ( PalHeader . MaxBlue == 0 ) PalHeader . MaxBlue = ( unsigned int ) QuantumRange ; for ( i = 0 ; i <= ( int ) PalHeader . MaxIndex ; i ++ ) { j = ( ssize_t ) TellBlob ( palette ) ; if ( ( j % 512 ) > 512 - 6 ) { j = ( ( j / 512 ) + 1 ) * 512 ; offset = SeekBlob ( palette , j , SEEK_SET ) ; if ( offset < 0 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; } image -> colormap [ i ] . red = ( Quantum ) ReadBlobLSBShort ( palette ) ; if ( QuantumRange != ( Quantum ) PalHeader . MaxRed ) { image -> colormap [ i ] . red = ClampToQuantum ( ( ( double ) image -> colormap [ i ] . red * QuantumRange + ( PalHeader . MaxRed >> 1 ) ) / PalHeader . MaxRed ) ; } image -> colormap [ i ] . green = ( Quantum ) ReadBlobLSBShort ( palette ) ; if ( QuantumRange != ( Quantum ) PalHeader . MaxGreen ) { image -> colormap [ i ] . green = ClampToQuantum ( ( ( double ) image -> colormap [ i ] . green * QuantumRange + ( PalHeader . MaxGreen >> 1 ) ) / PalHeader . MaxGreen ) ; } image -> colormap [ i ] . blue = ( Quantum ) ReadBlobLSBShort ( palette ) ; if ( QuantumRange != ( Quantum ) PalHeader . MaxBlue ) { image -> colormap [ i ] . blue = ClampToQuantum ( ( ( double ) image -> colormap [ i ] . blue * QuantumRange + ( PalHeader . MaxBlue >> 1 ) ) / PalHeader . MaxBlue ) ; } } if ( EOFBlob ( image ) ) ThrowCUTReaderException ( CorruptImageError , ""UnexpectedEndOfFile"" ) ; } NoPalette : if ( palette == NULL ) { image -> colors = 256 ; if ( AcquireImageColormap ( image , image -> colors ) == MagickFalse ) { NoMemory : ThrowCUTReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; } 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 ) ; } } BImgBuff = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) ldblk , sizeof ( * BImgBuff ) ) ; if ( BImgBuff == NULL ) goto NoMemory ; offset = SeekBlob ( image , 6 , SEEK_SET ) ; if ( offset < 0 ) { if ( palette != NULL ) palette = DestroyImage ( palette ) ; if ( clone_info != NULL ) clone_info = DestroyImageInfo ( clone_info ) ; BImgBuff = ( unsigned char * ) RelinquishMagickMemory ( BImgBuff ) ; ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; } for ( i = 0 ; i < ( int ) Header . Height ; i ++ ) { EncodedByte = ReadBlobLSBShort ( image ) ; ptrB = BImgBuff ; j = ldblk ; RunCount = ( unsigned char ) ReadBlobByte ( image ) ; RunCountMasked = RunCount & 0x7F ; while ( ( int ) RunCountMasked != 0 ) { if ( ( ssize_t ) RunCountMasked > j ) { RunCountMasked = ( unsigned char ) j ; if ( j == 0 ) { break ; } } if ( ( int ) RunCount > 0x80 ) { RunValue = ( unsigned char ) ReadBlobByte ( image ) ; ( void ) memset ( ptrB , ( int ) RunValue , ( size_t ) RunCountMasked ) ; } else { ( void ) ReadBlob ( image , ( size_t ) RunCountMasked , ptrB ) ; } ptrB += ( int ) RunCountMasked ; j -= ( int ) RunCountMasked ; if ( EOFBlob ( image ) != MagickFalse ) goto Finish ; RunCount = ( unsigned char ) ReadBlobByte ( image ) ; RunCountMasked = RunCount & 0x7F ; } InsertRow ( depth , BImgBuff , i , image ) ; } ( void ) SyncImage ( image ) ; if ( palette == NULL ) { if ( ( image -> storage_class == PseudoClass ) && ( SetImageGray ( image , & image -> exception ) != MagickFalse ) ) { if ( GetCutColors ( image ) == 2 ) { for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { register Quantum sample ; sample = ScaleCharToQuantum ( ( unsigned char ) i ) ; if ( image -> colormap [ i ] . red != sample ) goto Finish ; if ( image -> colormap [ i ] . green != sample ) goto Finish ; if ( image -> colormap [ i ] . blue != sample ) goto Finish ; } image -> colormap [ 1 ] . red = image -> colormap [ 1 ] . green = image -> colormap [ 1 ] . blue = QuantumRange ; for ( i = 0 ; i < ( ssize_t ) image -> rows ; i ++ ) { q = QueueAuthenticPixels ( image , 0 , i , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; for ( j = 0 ; j < ( ssize_t ) image -> columns ; j ++ ) { if ( GetPixelRed ( q ) == ScaleCharToQuantum ( 1 ) ) { SetPixelRed ( q , QuantumRange ) ; SetPixelGreen ( q , QuantumRange ) ; SetPixelBlue ( q , QuantumRange ) ; } q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) goto Finish ; } } } } Finish : if ( BImgBuff != NULL ) BImgBuff = ( unsigned char * ) RelinquishMagickMemory ( BImgBuff ) ; if ( palette != NULL ) palette = DestroyImage ( palette ) ; if ( clone_info != NULL ) clone_info = DestroyImageInfo ( clone_info ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," , tag ) \\\n{ if ( palette tag ) ; \\\n} Image * image goto NoMemory ; ( void ) memset ( BImgBuff , 0 , ( size_t ) ldblk * sizeof ( * BImgBuff ) ) ; ",ImageMagick@ImageMagick/1e59b29e520d2beab73e8c78aacd5f1c0d76196d,CVE-2019-13135,https://github.com/ImageMagick/ImageMagick/commit/1e59b29e520d2beab73e8c78aacd5f1c0d76196d,2019-07-01T20:15Z 359,CWE-189,"CWE-189 static ssize_t _archive_write_data ( struct archive * _a , const void * buff , size_t s ) { struct archive_write * a = ( struct archive_write * ) _a ; archive_check_magic ( & a -> archive , ARCHIVE_WRITE_MAGIC , ARCHIVE_STATE_DATA , ""archive_write_data"" ) ; archive_clear_error ( & a -> archive ) ; return ( ( a -> format_write_data ) ( a , buff , s ) ) ; } "," ) _a ; const size_t max_write = INT_MAX ; , ""archive_write_data"" ) ; if ( s > max_write ) s = max_write ",libarchive@libarchive/22531545514043e04633e1c015c7540b9de9dbe4,CVE-2013-0211,https://github.com/libarchive/libarchive/commit/22531545514043e04633e1c015c7540b9de9dbe4,2013-09-30T22:55Z 360,CWE-787,"CWE-787 IMPEG2D_ERROR_CODES_T impeg2d_dec_seq_hdr ( dec_state_t * ps_dec ) { stream_t * ps_stream ; ps_stream = & ps_dec -> s_bit_stream ; UWORD16 u2_height ; UWORD16 u2_width ; if ( impeg2d_bit_stream_nxt ( ps_stream , START_CODE_LEN ) != SEQUENCE_HEADER_CODE ) { impeg2d_bit_stream_flush ( ps_stream , START_CODE_LEN ) ; return IMPEG2D_FRM_HDR_START_CODE_NOT_FOUND ; } impeg2d_bit_stream_flush ( ps_stream , START_CODE_LEN ) ; u2_width = impeg2d_bit_stream_get ( ps_stream , 12 ) ; u2_height = impeg2d_bit_stream_get ( ps_stream , 12 ) ; if ( 0 == u2_width || 0 == u2_height ) { IMPEG2D_ERROR_CODES_T e_error = IMPEG2D_FRM_HDR_DECODE_ERR ; return e_error ; } if ( ( u2_width != ps_dec -> u2_horizontal_size ) || ( u2_height != ps_dec -> u2_vertical_size ) ) { if ( 0 == ps_dec -> u2_header_done ) { ps_dec -> u2_horizontal_size = u2_width ; ps_dec -> u2_vertical_size = u2_height ; if ( 0 == ps_dec -> u4_frm_buf_stride ) { ps_dec -> u4_frm_buf_stride = ( UWORD32 ) ( u2_width ) ; } } else { if ( 0 == ps_dec -> i4_pic_count ) { return ( IMPEG2D_ERROR_CODES_T ) IMPEG2D_FRM_HDR_DECODE_ERR ; } else if ( ( u2_width > ps_dec -> u2_create_max_width ) || ( u2_height > ps_dec -> u2_create_max_height ) ) { IMPEG2D_ERROR_CODES_T e_error = IMPEG2D_UNSUPPORTED_DIMENSIONS ; ps_dec -> u2_reinit_max_height = u2_height ; ps_dec -> u2_reinit_max_width = u2_width ; return e_error ; } else { return ( IMPEG2D_ERROR_CODES_T ) IVD_RES_CHANGED ; } } } if ( ( ps_dec -> u2_horizontal_size > ps_dec -> u2_create_max_width ) || ( ps_dec -> u2_vertical_size > ps_dec -> u2_create_max_height ) ) { IMPEG2D_ERROR_CODES_T e_error = IMPEG2D_UNSUPPORTED_DIMENSIONS ; ps_dec -> u2_reinit_max_height = ps_dec -> u2_vertical_size ; ps_dec -> u2_reinit_max_width = ps_dec -> u2_horizontal_size ; return e_error ; } ps_dec -> u2_aspect_ratio_info = impeg2d_bit_stream_get ( ps_stream , 4 ) ; ps_dec -> u2_frame_rate_code = impeg2d_bit_stream_get ( ps_stream , 4 ) ; if ( ps_dec -> u2_frame_rate_code > MPEG2_MAX_FRAME_RATE_CODE ) { return IMPEG2D_FRM_HDR_DECODE_ERR ; } impeg2d_bit_stream_flush ( ps_stream , 18 ) ; GET_MARKER_BIT ( ps_dec , ps_stream ) ; impeg2d_bit_stream_flush ( ps_stream , 11 ) ; if ( impeg2d_bit_stream_get_bit ( ps_stream ) == 1 ) { UWORD16 i ; for ( i = 0 ; i < NUM_PELS_IN_BLOCK ; i ++ ) { ps_dec -> au1_intra_quant_matrix [ gau1_impeg2_inv_scan_zig_zag [ i ] ] = ( UWORD8 ) impeg2d_bit_stream_get ( ps_stream , 8 ) ; } } else { memcpy ( ps_dec -> au1_intra_quant_matrix , gau1_impeg2_intra_quant_matrix_default , NUM_PELS_IN_BLOCK ) ; } if ( impeg2d_bit_stream_get_bit ( ps_stream ) == 1 ) { UWORD16 i ; for ( i = 0 ; i < NUM_PELS_IN_BLOCK ; i ++ ) { ps_dec -> au1_inter_quant_matrix [ gau1_impeg2_inv_scan_zig_zag [ i ] ] = ( UWORD8 ) impeg2d_bit_stream_get ( ps_stream , 8 ) ; } } else { memcpy ( ps_dec -> au1_inter_quant_matrix , gau1_impeg2_inter_quant_matrix_default , NUM_PELS_IN_BLOCK ) ; } impeg2d_next_start_code ( ps_dec ) ; return ( IMPEG2D_ERROR_CODES_T ) IVD_ERROR_NONE ; } "," = u2_height ; } else { == ps_dec -> i4_pic_count ) { return ( IMPEG2D_ERROR_CODES_T ) IMPEG2D_FRM_HDR_DECODE_ERR ; } else if ( ( u2_width > ps_dec -> u2_create_max_width ) || ( u2_height > ps_dec -> u2_create_max_height ) ) { IMPEG2D_ERROR_CODES_T e_error = IMPEG2D_UNSUPPORTED_DIMENSIONS ; ps_dec -> u2_reinit_max_height = u2_height ; ps_dec -> u2_reinit_max_width = u2_width ; return e_error ; } else if ( ( ps_dec -> u2_horizontal_size < MIN_WIDTH ) || ( ) || ( ps_dec -> u2_vertical_size < MIN_HEIGHT ) ) { return IMPEG2D_UNSUPPORTED_DIMENSIONS ; } else ; return e_error ; } if ( ( ps_dec -> u2_horizontal_size < MIN_WIDTH ) || ( ps_dec -> u2_vertical_size < MIN_HEIGHT ) ) { return IMPEG2D_UNSUPPORTED_DIMENSIONS ",external@libmpeg2/bef16671c891e16f25a7b174bc528eea109357be,CVE-2018-9497,https://android.googlesource.com/platform/external/libmpeg2/+/bef16671c891e16f25a7b174bc528eea109357be,2018-10-02T19:29Z 361,CWE-000,"CWE-000 static int StreamTcpPacketStateSynSent ( ThreadVars * tv , Packet * p , StreamTcpThread * stt , TcpSession * ssn , PacketQueue * pq ) { if ( ssn == NULL ) return - 1 ; SCLogDebug ( ""ssn%p:pktreceived:%s"" , ssn , PKT_IS_TOCLIENT ( p ) ? ""toclient"" : ""toserver"" ) ; if ( p -> tcph -> th_flags & TH_RST ) { if ( ! StreamTcpValidateRst ( ssn , p ) ) return - 1 ; if ( PKT_IS_TOSERVER ( p ) ) { if ( SEQ_EQ ( TCP_GET_SEQ ( p ) , ssn -> client . isn ) && SEQ_EQ ( TCP_GET_WINDOW ( p ) , 0 ) && SEQ_EQ ( TCP_GET_ACK ( p ) , ( ssn -> client . isn + 1 ) ) ) { SCLogDebug ( ""ssn->server.flags|=STREAMTCP_STREAM_FLAG_RST_RECV"" ) ; ssn -> server . flags |= STREAMTCP_STREAM_FLAG_RST_RECV ; StreamTcpPacketSetState ( p , ssn , TCP_CLOSED ) ; SCLogDebug ( ""ssn%p:Resetreceivedandstatechangedto"" ""TCP_CLOSED"" , ssn ) ; } } else { ssn -> client . flags |= STREAMTCP_STREAM_FLAG_RST_RECV ; SCLogDebug ( ""ssn->client.flags|=STREAMTCP_STREAM_FLAG_RST_RECV"" ) ; StreamTcpPacketSetState ( p , ssn , TCP_CLOSED ) ; SCLogDebug ( ""ssn%p:Resetreceivedandstatechangedto"" ""TCP_CLOSED"" , ssn ) ; } } else if ( p -> tcph -> th_flags & TH_FIN ) { } else if ( ( p -> tcph -> th_flags & ( TH_SYN | TH_ACK ) ) == ( TH_SYN | TH_ACK ) ) { if ( ( ssn -> flags & STREAMTCP_FLAG_4WHS ) && PKT_IS_TOSERVER ( p ) ) { SCLogDebug ( ""ssn%p:SYN/ACKreceivedon4WHSsession"" , ssn ) ; if ( ! ( SEQ_EQ ( TCP_GET_ACK ( p ) , ssn -> server . isn + 1 ) ) ) { StreamTcpSetEvent ( p , STREAM_4WHS_SYNACK_WITH_WRONG_ACK ) ; SCLogDebug ( ""ssn%p:4WHSACKmismatch,packetACK%"" PRIu32 """" ""!=%"" PRIu32 ""fromstream"" , ssn , TCP_GET_ACK ( p ) , ssn -> server . isn + 1 ) ; return - 1 ; } if ( ! ( SEQ_EQ ( TCP_GET_SEQ ( p ) , ssn -> client . isn ) ) ) { StreamTcpSetEvent ( p , STREAM_4WHS_SYNACK_WITH_WRONG_SYN ) ; SCLogDebug ( ""ssn%p:4WHSSEQmismatch,packetSEQ%"" PRIu32 """" ""!=%"" PRIu32 ""from*first*SYNpkt"" , ssn , TCP_GET_SEQ ( p ) , ssn -> client . isn ) ; return - 1 ; } StreamTcpPacketSetState ( p , ssn , TCP_SYN_RECV ) ; SCLogDebug ( ""ssn%p:=~4WHSssnstateisnowTCP_SYN_RECV"" , ssn ) ; ssn -> client . isn = TCP_GET_SEQ ( p ) ; STREAMTCP_SET_RA_BASE_SEQ ( & ssn -> client , ssn -> client . isn ) ; ssn -> client . next_seq = ssn -> client . isn + 1 ; ssn -> server . window = TCP_GET_WINDOW ( p ) ; SCLogDebug ( ""ssn%p:4WHSwindow%"" PRIu32 """" , ssn , ssn -> client . window ) ; if ( ( TCP_HAS_TS ( p ) ) && ( ssn -> server . flags & STREAMTCP_STREAM_FLAG_TIMESTAMP ) ) { ssn -> client . last_ts = TCP_GET_TSVAL ( p ) ; SCLogDebug ( ""ssn%p:4WHSssn->client.last_ts%"" PRIu32 """" ""ssn->server.last_ts%"" PRIu32 """" , ssn , ssn -> client . last_ts , ssn -> server . last_ts ) ; ssn -> flags |= STREAMTCP_FLAG_TIMESTAMP ; ssn -> client . last_pkt_ts = p -> ts . tv_sec ; if ( ssn -> client . last_ts == 0 ) ssn -> client . flags |= STREAMTCP_STREAM_FLAG_ZERO_TIMESTAMP ; } else { ssn -> server . last_ts = 0 ; ssn -> client . last_ts = 0 ; ssn -> server . flags &= ~ STREAMTCP_STREAM_FLAG_ZERO_TIMESTAMP ; } ssn -> server . last_ack = TCP_GET_ACK ( p ) ; ssn -> client . last_ack = ssn -> client . isn + 1 ; if ( ( ssn -> flags & STREAMTCP_FLAG_SERVER_WSCALE ) && ( TCP_HAS_WSCALE ( p ) ) ) { ssn -> server . wscale = TCP_GET_WSCALE ( p ) ; } else { ssn -> server . wscale = 0 ; } if ( ( ssn -> flags & STREAMTCP_FLAG_CLIENT_SACKOK ) && TCP_GET_SACKOK ( p ) == 1 ) { ssn -> flags |= STREAMTCP_FLAG_SACKOK ; SCLogDebug ( ""ssn%p:SACKpermittedfor4WHSsession"" , ssn ) ; } ssn -> client . next_win = ssn -> client . last_ack + ssn -> client . window ; ssn -> server . next_win = ssn -> server . last_ack + ssn -> server . window ; SCLogDebug ( ""ssn%p:4WHSssn->client.next_win%"" PRIu32 """" , ssn , ssn -> client . next_win ) ; SCLogDebug ( ""ssn%p:4WHSssn->server.next_win%"" PRIu32 """" , ssn , ssn -> server . next_win ) ; SCLogDebug ( ""ssn%p:4WHSssn->client.isn%"" PRIu32 "","" ""ssn->client.next_seq%"" PRIu32 "","" ""ssn->client.last_ack%"" PRIu32 """" ""(ssn->server.last_ack%"" PRIu32 "")"" , ssn , ssn -> client . isn , ssn -> client . next_seq , ssn -> client . last_ack , ssn -> server . last_ack ) ; return 0 ; } if ( PKT_IS_TOSERVER ( p ) ) { StreamTcpSetEvent ( p , STREAM_3WHS_SYNACK_IN_WRONG_DIRECTION ) ; SCLogDebug ( ""ssn%p:SYN/ACKreceivedinthewrongdirection"" , ssn ) ; return - 1 ; } if ( ! ( TCP_HAS_TFO ( p ) || ( ssn -> flags & STREAMTCP_FLAG_TCP_FAST_OPEN ) ) ) { if ( ! ( SEQ_EQ ( TCP_GET_ACK ( p ) , ssn -> client . isn + 1 ) ) ) { StreamTcpSetEvent ( p , STREAM_3WHS_SYNACK_WITH_WRONG_ACK ) ; SCLogDebug ( ""ssn%p:ACKmismatch,packetACK%"" PRIu32 ""!="" ""%"" PRIu32 ""fromstream"" , ssn , TCP_GET_ACK ( p ) , ssn -> client . isn + 1 ) ; return - 1 ; } } else { if ( ! ( SEQ_EQ ( TCP_GET_ACK ( p ) , ssn -> client . next_seq ) ) ) { StreamTcpSetEvent ( p , STREAM_3WHS_SYNACK_WITH_WRONG_ACK ) ; SCLogDebug ( ""ssn%p:(TFO)ACKmismatch,packetACK%"" PRIu32 ""!="" ""%"" PRIu32 ""fromstream"" , ssn , TCP_GET_ACK ( p ) , ssn -> client . next_seq ) ; return - 1 ; } SCLogDebug ( ""ssn%p:(TFO)ACKmatch,packetACK%"" PRIu32 ""=="" ""%"" PRIu32 ""fromstream"" , ssn , TCP_GET_ACK ( p ) , ssn -> client . next_seq ) ; ssn -> flags |= STREAMTCP_FLAG_TCP_FAST_OPEN ; StreamTcpPacketSetState ( p , ssn , TCP_ESTABLISHED ) ; } StreamTcp3whsSynAckUpdate ( ssn , p , NULL ) ; } else if ( p -> tcph -> th_flags & TH_SYN ) { SCLogDebug ( ""ssn%p:SYNpacketonstateSYN_SENT...resent"" , ssn ) ; if ( ssn -> flags & STREAMTCP_FLAG_4WHS ) { SCLogDebug ( ""ssn%p:SYNpacketonstateSYN_SENT...resentof"" ""4WHSSYN"" , ssn ) ; } if ( PKT_IS_TOCLIENT ( p ) ) { ssn -> flags |= STREAMTCP_FLAG_4WHS ; SCLogDebug ( ""ssn%p:STREAMTCP_FLAG_4WHSflagset"" , ssn ) ; ssn -> server . isn = TCP_GET_SEQ ( p ) ; STREAMTCP_SET_RA_BASE_SEQ ( & ssn -> server , ssn -> server . isn ) ; ssn -> server . next_seq = ssn -> server . isn + 1 ; if ( TCP_HAS_TS ( p ) ) { ssn -> server . last_ts = TCP_GET_TSVAL ( p ) ; SCLogDebug ( ""ssn%p:%02x"" , ssn , ssn -> server . last_ts ) ; if ( ssn -> server . last_ts == 0 ) ssn -> server . flags |= STREAMTCP_STREAM_FLAG_ZERO_TIMESTAMP ; ssn -> server . last_pkt_ts = p -> ts . tv_sec ; ssn -> server . flags |= STREAMTCP_STREAM_FLAG_TIMESTAMP ; } ssn -> server . window = TCP_GET_WINDOW ( p ) ; if ( TCP_HAS_WSCALE ( p ) ) { ssn -> flags |= STREAMTCP_FLAG_SERVER_WSCALE ; ssn -> server . wscale = TCP_GET_WSCALE ( p ) ; } else { ssn -> flags &= ~ STREAMTCP_FLAG_SERVER_WSCALE ; ssn -> server . wscale = 0 ; } if ( TCP_GET_SACKOK ( p ) == 1 ) { ssn -> flags |= STREAMTCP_FLAG_CLIENT_SACKOK ; } else { ssn -> flags &= ~ STREAMTCP_FLAG_CLIENT_SACKOK ; } SCLogDebug ( ""ssn%p:4WHSssn->server.isn%"" PRIu32 "","" ""ssn->server.next_seq%"" PRIu32 "","" ""ssn->server.last_ack%"" PRIu32 """" , ssn , ssn -> server . isn , ssn -> server . next_seq , ssn -> server . last_ack ) ; SCLogDebug ( ""ssn%p:4WHSssn->client.isn%"" PRIu32 "","" ""ssn->client.next_seq%"" PRIu32 "","" ""ssn->client.last_ack%"" PRIu32 """" , ssn , ssn -> client . isn , ssn -> client . next_seq , ssn -> client . last_ack ) ; } } else if ( p -> tcph -> th_flags & TH_ACK ) { if ( stream_config . async_oneside == FALSE ) return 0 ; if ( ! ( SEQ_EQ ( TCP_GET_SEQ ( p ) , ssn -> client . next_seq ) ) ) { StreamTcpSetEvent ( p , STREAM_3WHS_ASYNC_WRONG_SEQ ) ; SCLogDebug ( ""ssn%p:SEQmismatch,packetSEQ%"" PRIu32 ""!="" ""%"" PRIu32 ""fromstream"" , ssn , TCP_GET_SEQ ( p ) , ssn -> client . next_seq ) ; return - 1 ; } ssn -> flags |= STREAMTCP_FLAG_ASYNC ; StreamTcpPacketSetState ( p , ssn , TCP_ESTABLISHED ) ; SCLogDebug ( ""ssn%p:=~ssnstateisnowTCP_ESTABLISHED"" , ssn ) ; ssn -> client . window = TCP_GET_WINDOW ( p ) ; ssn -> client . last_ack = TCP_GET_SEQ ( p ) ; ssn -> client . next_win = ssn -> client . last_ack + ssn -> client . window ; ssn -> server . isn = TCP_GET_ACK ( p ) - 1 ; STREAMTCP_SET_RA_BASE_SEQ ( & ssn -> server , ssn -> server . isn ) ; ssn -> server . next_seq = ssn -> server . isn + 1 ; ssn -> server . last_ack = ssn -> server . next_seq ; ssn -> server . next_win = ssn -> server . last_ack ; SCLogDebug ( ""ssn%p:synsent=>Asynchronousstream,packetSEQ"" ""%"" PRIu32 "",payloadsize%"" PRIu32 ""(%"" PRIu32 ""),"" ""ssn->client.next_seq%"" PRIu32 """" , ssn , TCP_GET_SEQ ( p ) , p -> payload_len , TCP_GET_SEQ ( p ) + p -> payload_len , ssn -> client . next_seq ) ; if ( ssn -> flags & STREAMTCP_FLAG_SERVER_WSCALE ) { ssn -> client . wscale = TCP_WSCALE_MAX ; } if ( TCP_HAS_TS ( p ) && ( ssn -> client . flags & STREAMTCP_STREAM_FLAG_TIMESTAMP ) ) { ssn -> flags |= STREAMTCP_FLAG_TIMESTAMP ; ssn -> client . flags &= ~ STREAMTCP_STREAM_FLAG_TIMESTAMP ; ssn -> client . last_pkt_ts = p -> ts . tv_sec ; } else { ssn -> client . last_ts = 0 ; ssn -> client . flags &= ~ STREAMTCP_STREAM_FLAG_ZERO_TIMESTAMP ; } if ( ssn -> flags & STREAMTCP_FLAG_CLIENT_SACKOK ) { ssn -> flags |= STREAMTCP_FLAG_SACKOK ; } StreamTcpReassembleHandleSegment ( tv , stt -> ra_ctx , ssn , & ssn -> client , p , pq ) ; } else { SCLogDebug ( ""ssn%p:defaultcase"" , ssn ) ; } return 0 ; } "," ; if ( StateSynSentValidateTimestamp ( ssn , p ) == false ) return - 1 ; if ( ",OISF@suricata/9f0294fadca3dcc18c919424242a41e01f3e8318,CVE-2019-18625,https://github.com/OISF/suricata/commit/9f0294fadca3dcc18c919424242a41e01f3e8318,2020-01-06T21:15Z 362,CWE-120,"CWE-120 static int pad_basic ( bn_t m , int * p_len , int m_len , int k_len , int operation ) { uint8_t pad = 0 ; int result = RLC_OK ; bn_t t ; RLC_TRY { bn_null ( t ) ; bn_new ( t ) ; switch ( operation ) { case RSA_ENC : case RSA_SIG : case RSA_SIG_HASH : bn_zero ( m ) ; bn_lsh ( m , m , 8 ) ; bn_add_dig ( m , m , RSA_PAD ) ; bn_lsh ( m , m , m_len * 8 ) ; break ; case RSA_DEC : case RSA_VER : case RSA_VER_HASH : m_len = k_len - 1 ; bn_rsh ( t , m , 8 * m_len ) ; if ( ! bn_is_zero ( t ) ) { result = RLC_ERR ; } * p_len = 1 ; do { ( * p_len ) ++ ; m_len -- ; bn_rsh ( t , m , 8 * m_len ) ; pad = ( uint8_t ) t -> dp [ 0 ] ; } while ( pad == 0 && m_len > 0 ) ; if ( pad != RSA_PAD ) { result = RLC_ERR ; } bn_mod_2b ( m , m , ( k_len - * p_len ) * 8 ) ; break ; } } RLC_CATCH_ANY { result = RLC_ERR ; } RLC_FINALLY { bn_free ( t ) ; } return result ; } "," int result = RLC_ERR ; bn_t t ; RLC_TRY { bn_null ( t ) ; bn_new ( t ) ; switch ( operation ) { case RSA_ENC : case RSA_SIG : case RSA_SIG_HASH : bn_zero ( m ) ; bn_lsh ( m , m , 8 ) ; bn_add_dig ( m , m , RSA_PAD ) ; bn_lsh ( m , m , m_len * 8 ) ; result = RLC_OK ; break ; ; if ( bn_is_zero ( t ) ) { * p_len = if ( pad == RSA_PAD ) { { result = RLC_OK ; } bn_mod_2b 8 ) ; } ",relic-toolkit@relic/76c9a1fdf19d9e92e566a77376673e522aae9f80,CVE-2020-36316,https://github.com/relic-toolkit/relic/commit/76c9a1fdf19d9e92e566a77376673e522aae9f80,2021-04-07T21:15Z 363,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 364,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 365,CWE-000,"CWE-000 static rfbBool rfbSetClientColourMapBGR233 ( rfbClientPtr cl ) { char buf [ sz_rfbSetColourMapEntriesMsg + 256 * 3 * 2 ] ; rfbSetColourMapEntriesMsg * scme = ( rfbSetColourMapEntriesMsg * ) buf ; uint16_t * rgb = ( uint16_t * ) ( & buf [ sz_rfbSetColourMapEntriesMsg ] ) ; int i , len ; int r , g , b ; if ( cl -> format . bitsPerPixel != 8 ) { rfbErr ( ""%s:clientnot8bitsperpixel\\n"" , ""rfbSetClientColourMapBGR233"" ) ; rfbCloseClient ( cl ) ; return FALSE ; } scme -> type = rfbSetColourMapEntries ; scme -> firstColour = Swap16IfLE ( 0 ) ; scme -> nColours = Swap16IfLE ( 256 ) ; len = sz_rfbSetColourMapEntriesMsg ; i = 0 ; for ( b = 0 ; b < 4 ; b ++ ) { for ( g = 0 ; g < 8 ; g ++ ) { for ( r = 0 ; r < 8 ; r ++ ) { rgb [ i ++ ] = Swap16IfLE ( r * 65535 / 7 ) ; rgb [ i ++ ] = Swap16IfLE ( g * 65535 / 7 ) ; rgb [ i ++ ] = Swap16IfLE ( b * 65535 / 3 ) ; } } } len += 256 * 3 * 2 ; if ( rfbWriteExact ( cl , buf , len ) < 0 ) { rfbLogPerror ( ""rfbSetClientColourMapBGR233:write"" ) ; rfbCloseClient ( cl ) ; return FALSE ; } return TRUE ; } "," cl ) { union { char bytes [ sz_rfbSetColourMapEntriesMsg + ] ; rfbSetColourMapEntriesMsg msg ; } buf ; rfbSetColourMapEntriesMsg * scme = & buf . msg ; uint16_t * ( & buf . bytes cl , buf . bytes ",LibVNC@libvncserver/53073c8d7e232151ea2ecd8a1243124121e10e2d,CVE-2020-14400,https://github.com/LibVNC/libvncserver/commit/53073c8d7e232151ea2ecd8a1243124121e10e2d,2020-06-17T16:15Z 366,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 367,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 368,CWE-119,"CWE-119 static ssize_t oz_cdev_write ( struct file * filp , const char __user * buf , size_t count , loff_t * fpos ) { struct oz_pd * pd ; struct oz_elt_buf * eb ; struct oz_elt_info * ei ; struct oz_elt * elt ; struct oz_app_hdr * app_hdr ; struct oz_serial_ctx * ctx ; spin_lock_bh ( & g_cdev . lock ) ; pd = g_cdev . active_pd ; if ( pd ) oz_pd_get ( pd ) ; spin_unlock_bh ( & g_cdev . lock ) ; if ( pd == NULL ) return - ENXIO ; if ( ! ( pd -> state & OZ_PD_S_CONNECTED ) ) return - EAGAIN ; eb = & pd -> elt_buff ; ei = oz_elt_info_alloc ( eb ) ; if ( ei == NULL ) { count = 0 ; goto out ; } elt = ( struct oz_elt * ) ei -> data ; app_hdr = ( struct oz_app_hdr * ) ( elt + 1 ) ; elt -> length = sizeof ( struct oz_app_hdr ) + count ; elt -> type = OZ_ELT_APP_DATA ; ei -> app_id = OZ_APPID_SERIAL ; ei -> length = elt -> length + sizeof ( struct oz_elt ) ; app_hdr -> app_id = OZ_APPID_SERIAL ; if ( copy_from_user ( app_hdr + 1 , buf , count ) ) goto out ; spin_lock_bh ( & pd -> app_lock [ OZ_APPID_USB - 1 ] ) ; ctx = ( struct oz_serial_ctx * ) pd -> app_ctx [ OZ_APPID_SERIAL - 1 ] ; if ( ctx ) { app_hdr -> elt_seq_num = ctx -> tx_seq_num ++ ; if ( ctx -> tx_seq_num == 0 ) ctx -> tx_seq_num = 1 ; spin_lock ( & eb -> lock ) ; if ( oz_queue_elt_info ( eb , 0 , 0 , ei ) == 0 ) ei = NULL ; spin_unlock ( & eb -> lock ) ; } spin_unlock_bh ( & pd -> app_lock [ OZ_APPID_USB - 1 ] ) ; out : if ( ei ) { count = 0 ; spin_lock_bh ( & eb -> lock ) ; oz_elt_info_free ( eb , ei ) ; spin_unlock_bh ( & eb -> lock ) ; } oz_pd_put ( pd ) ; return count ; } "," * ctx ; if ( count > sizeof ( ei -> data ) - sizeof ( * elt ) - sizeof ( * app_hdr ) ) return - EINVAL ; ",torvalds@linux/c2c65cd2e14ada6de44cb527e7f1990bede24e15,CVE-2013-4513,https://github.com/torvalds/linux/commit/c2c65cd2e14ada6de44cb527e7f1990bede24e15,2013-11-12T14:35Z 369,CWE-415,"CWE-415 static int f_midi_set_alt ( struct usb_function * f , unsigned intf , unsigned alt ) { struct f_midi * midi = func_to_midi ( f ) ; unsigned i ; int err ; if ( intf != midi -> ms_id ) return 0 ; err = f_midi_start_ep ( midi , f , midi -> in_ep ) ; if ( err ) return err ; err = f_midi_start_ep ( midi , f , midi -> out_ep ) ; if ( err ) return err ; while ( kfifo_avail ( & midi -> in_req_fifo ) ) { struct usb_request * req = midi_alloc_ep_req ( midi -> in_ep , midi -> buflen ) ; if ( req == NULL ) return - ENOMEM ; req -> length = 0 ; req -> complete = f_midi_complete ; kfifo_put ( & midi -> in_req_fifo , req ) ; } for ( i = 0 ; i < midi -> qlen && err == 0 ; i ++ ) { struct usb_request * req = midi_alloc_ep_req ( midi -> out_ep , midi -> buflen ) ; if ( req == NULL ) return - ENOMEM ; req -> complete = f_midi_complete ; err = usb_ep_queue ( midi -> out_ep , req , GFP_ATOMIC ) ; if ( err ) { ERROR ( midi , ""%s:couldn\'tenqueuerequest:%d\\n"" , midi -> out_ep -> name , err ) ; free_ep_req ( midi -> out_ep , req ) ; return err ; } } return 0 ; } "," err ) ; if ( req -> buf != NULL ) ",torvalds@linux/7fafcfdf6377b18b2a726ea554d6e593ba44349f,CVE-2018-20961,https://github.com/torvalds/linux/commit/7fafcfdf6377b18b2a726ea554d6e593ba44349f,2019-08-07T15:15Z 370,CWE-20,"CWE-20 static void server_real_connect ( SERVER_REC * server , IPADDR * ip , const char * unix_socket ) { GIOChannel * handle ; IPADDR * own_ip = NULL ; const char * errmsg ; char * errmsg2 ; char ipaddr [ MAX_IP_LEN ] ; int port ; g_return_if_fail ( ip != NULL || unix_socket != NULL ) ; signal_emit ( ""serverconnecting"" , 2 , server , ip ) ; if ( server -> connrec -> no_connect ) return ; if ( ip != NULL ) { own_ip = ip == NULL ? NULL : ( IPADDR_IS_V6 ( ip ) ? server -> connrec -> own_ip6 : server -> connrec -> own_ip4 ) ; port = server -> connrec -> proxy != NULL ? server -> connrec -> proxy_port : server -> connrec -> port ; handle = server -> connrec -> use_ssl ? net_connect_ip_ssl ( ip , port , own_ip , server -> connrec -> ssl_cert , server -> connrec -> ssl_pkey , server -> connrec -> ssl_cafile , server -> connrec -> ssl_capath , server -> connrec -> ssl_verify ) : net_connect_ip ( ip , port , own_ip ) ; } else { handle = net_connect_unix ( unix_socket ) ; } if ( handle == NULL ) { errmsg = g_strerror ( errno ) ; errmsg2 = NULL ; if ( errno == EADDRNOTAVAIL ) { if ( own_ip != NULL ) { net_ip2host ( own_ip , ipaddr ) ; errmsg2 = g_strconcat ( errmsg , "":"" , ipaddr , NULL ) ; } server -> no_reconnect = TRUE ; } if ( server -> connrec -> use_ssl && errno == ENOSYS ) server -> no_reconnect = TRUE ; server -> connection_lost = TRUE ; server_connect_failed ( server , errmsg2 ? errmsg2 : errmsg ) ; g_free ( errmsg2 ) ; } else { server -> handle = net_sendbuffer_create ( handle , 0 ) ; # ifdef HAVE_OPENSSL if ( server -> connrec -> use_ssl ) server_connect_callback_init_ssl ( server , handle ) ; else # endif server -> connect_tag = g_input_add ( handle , G_INPUT_WRITE | G_INPUT_READ , ( GInputFunction ) server_connect_callback_init , server ) ; } } "," , port , server -> connrec -> address , ",ensc@irssi-proxy/85bbc05b21678e80423815d2ef1dfe26208491ab,CVE-2010-1155,https://github.com/ensc/irssi-proxy/commit/85bbc05b21678e80423815d2ef1dfe26208491ab,2010-04-16T19:30Z 371,CWE-119,"CWE-119 static int rc_pick_q_and_bounds_one_pass_cbr ( const VP9_COMP * cpi , int * bottom_index , int * top_index ) { const VP9_COMMON * const cm = & cpi -> common ; const RATE_CONTROL * const rc = & cpi -> rc ; int active_best_quality ; int active_worst_quality = calc_active_worst_quality_one_pass_cbr ( cpi ) ; int q ; if ( frame_is_intra_only ( cm ) ) { active_best_quality = rc -> best_quality ; if ( rc -> this_key_frame_forced ) { int qindex = rc -> last_boosted_qindex ; double last_boosted_q = vp9_convert_qindex_to_q ( qindex ) ; int delta_qindex = vp9_compute_qdelta ( rc , last_boosted_q , ( last_boosted_q * 0.75 ) ) ; active_best_quality = MAX ( qindex + delta_qindex , rc -> best_quality ) ; } else if ( cm -> current_video_frame > 0 ) { double q_adj_factor = 1.0 ; double q_val ; active_best_quality = get_active_quality ( rc -> avg_frame_qindex [ KEY_FRAME ] , rc -> kf_boost , kf_low , kf_high , kf_low_motion_minq , kf_high_motion_minq ) ; if ( ( cm -> width * cm -> height ) <= ( 352 * 288 ) ) { q_adj_factor -= 0.25 ; } q_val = vp9_convert_qindex_to_q ( active_best_quality ) ; active_best_quality += vp9_compute_qdelta ( rc , q_val , q_val * q_adj_factor ) ; } } else if ( ! rc -> is_src_frame_alt_ref && ! cpi -> use_svc && ( cpi -> refresh_golden_frame || cpi -> refresh_alt_ref_frame ) ) { if ( rc -> frames_since_key > 1 && rc -> avg_frame_qindex [ INTER_FRAME ] < active_worst_quality ) { q = rc -> avg_frame_qindex [ INTER_FRAME ] ; } else { q = active_worst_quality ; } active_best_quality = get_active_quality ( q , rc -> gfu_boost , gf_low , gf_high , gf_low_motion_minq , gf_high_motion_minq ) ; } else { if ( cm -> current_video_frame > 1 ) { if ( rc -> avg_frame_qindex [ INTER_FRAME ] < active_worst_quality ) active_best_quality = inter_minq [ rc -> avg_frame_qindex [ INTER_FRAME ] ] ; else active_best_quality = inter_minq [ active_worst_quality ] ; } else { if ( rc -> avg_frame_qindex [ KEY_FRAME ] < active_worst_quality ) active_best_quality = inter_minq [ rc -> avg_frame_qindex [ KEY_FRAME ] ] ; else active_best_quality = inter_minq [ active_worst_quality ] ; } } active_best_quality = clamp ( active_best_quality , rc -> best_quality , rc -> worst_quality ) ; active_worst_quality = clamp ( active_worst_quality , active_best_quality , rc -> worst_quality ) ; * top_index = active_worst_quality ; * bottom_index = active_best_quality ; # if LIMIT_QRANGE_FOR_ALTREF_AND_KEY if ( cm -> frame_type == KEY_FRAME && ! rc -> this_key_frame_forced ) { if ( ! ( cm -> current_video_frame == 0 ) ) * top_index = ( active_worst_quality + active_best_quality * 3 ) / 4 ; } # endif if ( cm -> frame_type == KEY_FRAME && rc -> this_key_frame_forced ) { q = rc -> last_boosted_qindex ; } else { q = vp9_rc_regulate_q ( cpi , rc -> this_frame_target , active_best_quality , active_worst_quality ) ; if ( q > * top_index ) { if ( rc -> this_frame_target >= rc -> max_frame_bandwidth ) * top_index = q ; else q = * top_index ; } } assert ( * top_index <= rc -> worst_quality && * top_index >= rc -> best_quality ) ; assert ( * bottom_index <= rc -> worst_quality && * bottom_index >= rc -> best_quality ) ; assert ( q <= rc -> worst_quality && q >= rc -> best_quality ) ; return q ; } "," int q ; int * rtc_minq ; ASSIGN_MINQ_TABLE ( cm -> bit_depth , rtc_minq ) ; vp9_convert_qindex_to_q ( qindex , cm -> bit_depth * 0.75 ) , cm -> bit_depth ; active_best_quality = get_kf_active_quality ( rc , rc -> avg_frame_qindex KEY_FRAME ] , cm -> bit_depth ) ; if vp9_convert_qindex_to_q ( active_best_quality , cm -> bit_depth q_val * q_adj_factor , cm -> bit_depth } active_best_quality = get_gf_active_quality ( rc , q , cm -> bit_depth ) ; } ) active_best_quality = rtc_minq [ rc -> else active_best_quality = rtc_minq [ active_worst_quality ] ) active_best_quality = rtc_minq [ rc -> else active_best_quality = rtc_minq [ active_worst_quality ] rc -> this_key_frame_forced && ! ( cm 0 ) ) { int qdelta = 0 ; vpx_clear_system_state ( ) ; qdelta = vp9_compute_qdelta_by_rate ( & cpi -> rc , cm -> frame_type , active_worst_quality , 2.0 , cm -> bit_depth ) ; * top_index = active_worst_quality + qdelta ; * top_index = ( * top_index > * bottom_index ) ? * top_index : * bottom_index ; } # ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 372,CWE-787,"CWE-787 TEE_Result tee_mmu_check_access_rights ( const struct user_ta_ctx * utc , uint32_t flags , uaddr_t uaddr , size_t len ) { uaddr_t a ; size_t addr_incr = MIN ( CORE_MMU_USER_CODE_SIZE , CORE_MMU_USER_PARAM_SIZE ) ; if ( ADD_OVERFLOW ( uaddr , len , & a ) ) return TEE_ERROR_ACCESS_DENIED ; if ( ( flags & TEE_MEMORY_ACCESS_NONSECURE ) && ( flags & TEE_MEMORY_ACCESS_SECURE ) ) return TEE_ERROR_ACCESS_DENIED ; if ( ! ( flags & TEE_MEMORY_ACCESS_ANY_OWNER ) && ! tee_mmu_is_vbuf_inside_ta_private ( utc , ( void * ) uaddr , len ) ) return TEE_ERROR_ACCESS_DENIED ; for ( a = uaddr ; a < ( uaddr + len ) ; a += addr_incr ) { uint32_t attr ; TEE_Result res ; res = tee_mmu_user_va2pa_attr ( utc , ( void * ) a , NULL , & attr ) ; if ( res != TEE_SUCCESS ) return res ; if ( ( flags & TEE_MEMORY_ACCESS_NONSECURE ) && ( attr & TEE_MATTR_SECURE ) ) return TEE_ERROR_ACCESS_DENIED ; if ( ( flags & TEE_MEMORY_ACCESS_SECURE ) && ! ( attr & TEE_MATTR_SECURE ) ) return TEE_ERROR_ACCESS_DENIED ; if ( ( flags & TEE_MEMORY_ACCESS_WRITE ) && ! ( attr & TEE_MATTR_UW ) ) return TEE_ERROR_ACCESS_DENIED ; if ( ( flags & TEE_MEMORY_ACCESS_READ ) && ! ( attr & TEE_MATTR_UR ) ) return TEE_ERROR_ACCESS_DENIED ; } return TEE_SUCCESS ; } "," uaddr_t a ; uaddr_t end_addr = 0 ; len , & end_addr ) ) return ( a = ROUNDDOWN ( uaddr , addr_incr ) ; a < ; a < end_addr ; a += ",OP-TEE@optee_os/95f36d661f2b75887772ea28baaad904bde96970,CVE-2019-1010293,https://github.com/OP-TEE/optee_os/commit/95f36d661f2b75887772ea28baaad904bde96970,2019-07-15T18:15Z 373,CWE-125,"CWE-125 PyObject * ast2obj_slice ( void * _o ) { slice_ty o = ( slice_ty ) _o ; PyObject * result = NULL , * value = NULL ; if ( ! o ) { Py_INCREF ( Py_None ) ; return Py_None ; } switch ( o -> kind ) { case Slice_kind : result = PyType_GenericNew ( Slice_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . Slice . lower ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_lower , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . Slice . upper ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_upper , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . Slice . step ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_step , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case ExtSlice_kind : result = PyType_GenericNew ( ExtSlice_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_list ( o -> v . ExtSlice . dims , ast2obj_slice ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_dims , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Index_kind : result = PyType_GenericNew ( Index_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . Index . value ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_value , 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 374,CWE-264,"CWE-264 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 375,CWE-119,"CWE-119 BITMAP_UPDATE * update_read_bitmap_update ( rdpUpdate * update , wStream * s ) { UINT32 i ; BITMAP_UPDATE * bitmapUpdate = calloc ( 1 , sizeof ( BITMAP_UPDATE ) ) ; if ( ! bitmapUpdate ) goto fail ; if ( Stream_GetRemainingLength ( s ) < 2 ) goto fail ; Stream_Read_UINT16 ( s , bitmapUpdate -> number ) ; WLog_Print ( update -> log , WLOG_TRACE , ""BitmapUpdate:%"" PRIu32 """" , bitmapUpdate -> number ) ; if ( bitmapUpdate -> number > bitmapUpdate -> count ) { UINT16 count ; BITMAP_DATA * newdata ; count = bitmapUpdate -> number * 2 ; newdata = ( BITMAP_DATA * ) realloc ( bitmapUpdate -> rectangles , sizeof ( BITMAP_DATA ) * count ) ; if ( ! newdata ) goto fail ; bitmapUpdate -> rectangles = newdata ; ZeroMemory ( & bitmapUpdate -> rectangles [ bitmapUpdate -> count ] , sizeof ( BITMAP_DATA ) * ( count - bitmapUpdate -> count ) ) ; bitmapUpdate -> count = count ; } for ( i = 0 ; i < bitmapUpdate -> number ; i ++ ) { if ( ! update_read_bitmap_data ( update , s , & bitmapUpdate -> rectangles [ i ] ) ) goto fail ; } return bitmapUpdate ; fail : free_bitmap_update ( update -> context , bitmapUpdate ) ; return NULL ; } "," count ) { UINT32 count = bitmapUpdate * 2 ; BITMAP_DATA * ",FreeRDP@FreeRDP/445a5a42c500ceb80f8fa7f2c11f3682538033f3,CVE-2018-8786,https://github.com/FreeRDP/FreeRDP/commit/445a5a42c500ceb80f8fa7f2c11f3682538033f3,2018-11-29T18:29Z 376,CWE-119,"CWE-119 grub_err_t grub_disk_read ( grub_disk_t disk , grub_disk_addr_t sector , grub_off_t offset , grub_size_t size , void * buf ) { char * tmp_buf ; unsigned real_offset ; if ( grub_disk_adjust_range ( disk , & sector , & offset , size ) != GRUB_ERR_NONE ) { grub_error_push ( ) ; grub_dprintf ( ""disk"" , ""Readoutofrange:sector0x%llx(%s).\\n"" , ( unsigned long long ) sector , grub_errmsg ) ; grub_error_pop ( ) ; return grub_errno ; } real_offset = offset ; tmp_buf = grub_malloc ( GRUB_DISK_SECTOR_SIZE << GRUB_DISK_CACHE_BITS ) ; if ( ! tmp_buf ) return grub_errno ; while ( size ) { char * data ; grub_disk_addr_t start_sector ; grub_size_t len ; grub_size_t pos ; start_sector = sector & ~ ( GRUB_DISK_CACHE_SIZE - 1 ) ; pos = ( sector - start_sector ) << GRUB_DISK_SECTOR_BITS ; len = ( ( GRUB_DISK_SECTOR_SIZE << GRUB_DISK_CACHE_BITS ) - pos - real_offset ) ; if ( len > size ) len = size ; data = grub_disk_cache_fetch ( disk -> dev -> id , disk -> id , start_sector ) ; if ( data ) { if ( buf ) grub_memcpy ( buf , data + pos + real_offset , len ) ; grub_disk_cache_unlock ( disk -> dev -> id , disk -> id , start_sector ) ; } else { if ( start_sector + GRUB_DISK_CACHE_SIZE > disk -> total_sectors || ( disk -> dev -> read ) ( disk , start_sector , GRUB_DISK_CACHE_SIZE , tmp_buf ) != GRUB_ERR_NONE ) { unsigned num ; char * p ; grub_errno = GRUB_ERR_NONE ; num = ( ( size + real_offset + GRUB_DISK_SECTOR_SIZE - 1 ) >> GRUB_DISK_SECTOR_BITS ) ; p = grub_realloc ( tmp_buf , num << GRUB_DISK_SECTOR_BITS ) ; if ( ! p ) goto finish ; tmp_buf = p ; if ( ( disk -> dev -> read ) ( disk , sector , num , tmp_buf ) ) { grub_error_push ( ) ; grub_dprintf ( ""disk"" , ""%sreadfailed\\n"" , disk -> name ) ; grub_error_pop ( ) ; goto finish ; } if ( buf ) grub_memcpy ( buf , tmp_buf + real_offset , size ) ; if ( disk -> read_hook ) while ( size ) { grub_size_t to_read ; to_read = size ; if ( real_offset + to_read > GRUB_DISK_SECTOR_SIZE ) to_read = GRUB_DISK_SECTOR_SIZE - real_offset ; ( disk -> read_hook ) ( sector , real_offset , to_read , disk -> closure ) ; if ( grub_errno != GRUB_ERR_NONE ) goto finish ; sector ++ ; size -= to_read ; real_offset = 0 ; } goto finish ; } if ( buf ) grub_memcpy ( buf , tmp_buf + pos + real_offset , len ) ; grub_disk_cache_store ( disk -> dev -> id , disk -> id , start_sector , tmp_buf ) ; } if ( disk -> read_hook ) { grub_disk_addr_t s = sector ; grub_size_t l = len ; while ( l ) { ( disk -> read_hook ) ( s , real_offset , ( ( l > GRUB_DISK_SECTOR_SIZE ) ? GRUB_DISK_SECTOR_SIZE : l ) , disk -> closure ) ; if ( l < GRUB_DISK_SECTOR_SIZE - real_offset ) break ; s ++ ; l -= GRUB_DISK_SECTOR_SIZE - real_offset ; real_offset = 0 ; } } sector = start_sector + GRUB_DISK_CACHE_SIZE ; if ( buf ) buf = ( char * ) buf + len ; size -= len ; real_offset = 0 ; } finish : grub_free ( tmp_buf ) ; return grub_errno ; } "," ( buf ) { if ( pos + real_offset + len >= size ) { grub_errno = GRUB_ERR_BAD_FS ; return grub_errno ; } len ) ; } ",radare@radare2/c57997e76ec70862174a1b3b3aeb62a6f8570e85,CVE-2017-10929,https://github.com/radare/radare2/commit/c57997e76ec70862174a1b3b3aeb62a6f8570e85,2017-07-05T12:29Z 377,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 378,CWE-119,"CWE-119 TpktState CotpConnection_readToTpktBuffer ( CotpConnection * self ) { uint8_t * buffer = self -> readBuffer -> buffer ; int bufferSize = self -> readBuffer -> maxSize ; int bufPos = self -> readBuffer -> size ; assert ( bufferSize > 4 ) ; int readBytes ; if ( bufPos < 4 ) { readBytes = readFromSocket ( self , buffer + bufPos , 4 - bufPos ) ; if ( readBytes < 0 ) goto exit_closed ; if ( DEBUG_COTP ) { if ( readBytes > 0 ) printf ( ""TPKT:read%ibytesfromsocket\\n"" , readBytes ) ; } bufPos += readBytes ; if ( bufPos == 4 ) { if ( ( buffer [ 0 ] == 3 ) && ( buffer [ 1 ] == 0 ) ) { self -> packetSize = ( buffer [ 2 ] * 0x100 ) + buffer [ 3 ] ; if ( DEBUG_COTP ) printf ( ""TPKT:headercomplete(msgsize=%i)\\n"" , self -> packetSize ) ; if ( self -> packetSize > bufferSize ) { if ( DEBUG_COTP ) printf ( ""TPKT:packettoolarge\\n"" ) ; goto exit_error ; } } else { if ( DEBUG_COTP ) printf ( ""TPKT:failedtodecodeTPKTheader.\\n"" ) ; goto exit_error ; } } else goto exit_waiting ; } readBytes = readFromSocket ( self , buffer + bufPos , self -> packetSize - bufPos ) ; if ( readBytes < 0 ) goto exit_closed ; bufPos += readBytes ; if ( bufPos < self -> packetSize ) goto exit_waiting ; if ( DEBUG_COTP ) printf ( ""TPKT:messagecomplete(size=%i)\\n"" , self -> packetSize ) ; self -> readBuffer -> size = bufPos ; return TPKT_PACKET_COMPLETE ; exit_closed : if ( DEBUG_COTP ) printf ( ""TPKT:socketclosedorsocketerror\\n"" ) ; return TPKT_ERROR ; exit_error : if ( DEBUG_COTP ) printf ( ""TPKT:Errorparsingmessage\\n"" ) ; return TPKT_ERROR ; exit_waiting : if ( DEBUG_COTP ) if ( bufPos != 0 ) printf ( ""TPKT:waiting(read%iof%i)\\n"" , bufPos , self -> packetSize ) ; self -> readBuffer -> size = bufPos ; return TPKT_WAITING ; } "," exit_waiting ; } if ( self -> packetSize <= bufPos ) goto exit_error ; ",mz-automation@libiec61850/033ab5b6488250c8c3b838f25a7cbc3e099230bb,CVE-2020-15158,https://github.com/mz-automation/libiec61850/commit/033ab5b6488250c8c3b838f25a7cbc3e099230bb,2020-08-26T18:15Z 379,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/376267d534476a875d8b9228149c4ee18b74a4fd,CVE-2017-6903,https://github.com/JACoders/OpenJK/commit/376267d534476a875d8b9228149c4ee18b74a4fd,2017-03-14T22:59Z 380,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 381,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 382,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 383,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 384,CWE-667,"CWE-667 struct vm_area_struct * find_extend_vma ( struct mm_struct * mm , unsigned long addr ) { struct vm_area_struct * vma ; unsigned long start ; addr &= PAGE_MASK ; vma = find_vma ( mm , addr ) ; if ( ! vma ) return NULL ; if ( vma -> vm_start <= addr ) return vma ; if ( ! ( vma -> vm_flags & VM_GROWSDOWN ) ) return NULL ; start = vma -> vm_start ; if ( expand_stack ( vma , addr ) ) return NULL ; if ( vma -> vm_flags & VM_LOCKED ) populate_vma_page_range ( vma , addr , start , NULL ) ; return vma ; } "," return NULL ; if ( ! mmget_still_valid ( mm ) ) return NULL ; ",torvalds@linux/04f5866e41fb70690e28397487d8bd8eea7d712a,CVE-2019-11599,https://github.com/torvalds/linux/commit/04f5866e41fb70690e28397487d8bd8eea7d712a,2019-04-29T18:29Z 385,CWE-399,"CWE-399 static int unix_attach_fds ( struct scm_cookie * scm , struct sk_buff * skb ) { int i ; unsigned char max_level = 0 ; int unix_sock_count = 0 ; if ( too_many_unix_fds ( current ) ) return - ETOOMANYREFS ; for ( i = scm -> fp -> count - 1 ; i >= 0 ; i -- ) { struct sock * sk = unix_get_socket ( scm -> fp -> fp [ i ] ) ; if ( sk ) { unix_sock_count ++ ; max_level = max ( max_level , unix_sk ( sk ) -> recursion_level ) ; } } if ( unlikely ( max_level > MAX_RECURSION_LEVEL ) ) return - ETOOMANYREFS ; UNIXCB ( skb ) . fp = scm_fp_dup ( scm -> fp ) ; if ( ! UNIXCB ( skb ) . fp ) return - ENOMEM ; for ( i = scm -> fp -> count - 1 ; i >= 0 ; i -- ) unix_inflight ( scm -> fp -> fp [ i ] ) ; return max_level ; } "," -> fp -> user , scm -> fp -> ",torvalds@linux/415e3d3e90ce9e18727e8843ae343eda5a58fad6,CVE-2016-2550,https://github.com/torvalds/linux/commit/415e3d3e90ce9e18727e8843ae343eda5a58fad6,2016-04-27T17:59Z 386,CWE-125,"CWE-125 int obj2ast_arg ( PyObject * obj , arg_ty * out , PyArena * arena ) { PyObject * tmp = NULL ; identifier arg ; expr_ty annotation ; string type_comment ; int lineno ; int col_offset ; if ( _PyObject_HasAttrId ( obj , & PyId_arg ) ) { int res ; tmp = _PyObject_GetAttrId ( obj , & PyId_arg ) ; if ( tmp == NULL ) goto failed ; res = obj2ast_identifier ( tmp , & arg , arena ) ; if ( res != 0 ) goto failed ; Py_CLEAR ( tmp ) ; } else { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""arg\\""missingfromarg"" ) ; return 1 ; } if ( exists_not_none ( obj , & PyId_annotation ) ) { int res ; tmp = _PyObject_GetAttrId ( obj , & PyId_annotation ) ; if ( tmp == NULL ) goto failed ; res = obj2ast_expr ( tmp , & annotation , arena ) ; if ( res != 0 ) goto failed ; Py_CLEAR ( tmp ) ; } else { annotation = NULL ; } if ( exists_not_none ( obj , & PyId_type_comment ) ) { int res ; tmp = _PyObject_GetAttrId ( obj , & PyId_type_comment ) ; if ( tmp == NULL ) goto failed ; res = obj2ast_string ( tmp , & type_comment , arena ) ; if ( res != 0 ) goto failed ; Py_CLEAR ( tmp ) ; } else { type_comment = NULL ; } if ( _PyObject_HasAttrId ( obj , & PyId_lineno ) ) { int res ; tmp = _PyObject_GetAttrId ( obj , & PyId_lineno ) ; if ( tmp == NULL ) goto failed ; res = obj2ast_int ( tmp , & lineno , arena ) ; if ( res != 0 ) goto failed ; Py_CLEAR ( tmp ) ; } else { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""lineno\\""missingfromarg"" ) ; return 1 ; } if ( _PyObject_HasAttrId ( obj , & PyId_col_offset ) ) { int res ; tmp = _PyObject_GetAttrId ( obj , & PyId_col_offset ) ; if ( tmp == NULL ) goto failed ; res = obj2ast_int ( tmp , & col_offset , arena ) ; if ( res != 0 ) goto failed ; Py_CLEAR ( tmp ) ; } else { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""col_offset\\""missingfromarg"" ) ; return 1 ; } * out = arg ( arg , annotation , type_comment , lineno , col_offset , arena ) ; return 0 ; failed : Py_XDECREF ( tmp ) ; return 1 ; } "," ; if ( lookup_attr_id ( obj , , & PyId_arg , & tmp ) < 0 ) { return 1 ; } if ( tmp == NULL ) { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""arg\\""missingfromarg"" ) ; return 1 ; } else { int res ; res = obj2ast_identifier ( tmp , & arg , arena ) ; if ( res != 0 ) goto failed goto failed ; Py_CLEAR ( tmp ) ; } if ( lookup_attr_id ( obj , & PyId_annotation , & tmp ) < 0 ) { return 1 ; } if ( tmp == NULL || tmp == Py_None ) { Py_CLEAR ( tmp ) ; annotation = NULL ; } else { int res ; res = obj2ast_expr ( tmp , & annotation , arena ) ) ; } if ( lookup_attr_id ( obj , & PyId_type_comment , & tmp ) < 0 ) { return 1 ; } if ( tmp == NULL || tmp == Py_None ) { Py_CLEAR ( tmp ) ; type_comment = NULL ; } else { int res ; res = obj2ast_string ( tmp , & type_comment , arena ) ; if ( res != 0 ) goto failed goto failed ; Py_CLEAR ( tmp ) ; } if ( lookup_attr_id ( obj , & PyId_lineno , & tmp ) < 0 ) { return 1 ; } if ( tmp == NULL ) { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""lineno\\""missingfromarg"" ) ; return 1 ; } else { int res ; res = obj2ast_int ( tmp , & lineno , arena ) ) ; } if ( lookup_attr_id ( obj , & PyId_col_offset , & tmp ) < 0 ) { return 1 ; } if ( tmp == NULL ) { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""col_offset\\""missingfromarg"" ) ; return 1 ; } else { int res ; res = obj2ast_int ( tmp , & col_offset , arena ) ; if ( res != 0 ) goto failed goto failed ; Py_CLEAR ( tmp ) ; } * ",python@typed_ast/156afcb26c198e162504a57caddfe0acd9ed7dce,CVE-2019-19275,https://github.com/python/typed_ast/commit/156afcb26c198e162504a57caddfe0acd9ed7dce,2019-11-26T15:15Z 387,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 388,CWE-189,"CWE-189 STATIC struct posix_acl * xfs_acl_from_disk ( struct xfs_acl * aclp ) { struct posix_acl_entry * acl_e ; struct posix_acl * acl ; struct xfs_acl_entry * ace ; int count , i ; count = be32_to_cpu ( aclp -> acl_cnt ) ; if ( count > XFS_ACL_MAX_ENTRIES ) return ERR_PTR ( - EFSCORRUPTED ) ; acl = posix_acl_alloc ( count , GFP_KERNEL ) ; if ( ! acl ) return ERR_PTR ( - ENOMEM ) ; for ( i = 0 ; i < count ; i ++ ) { acl_e = & acl -> a_entries [ i ] ; ace = & aclp -> acl_entry [ i ] ; acl_e -> e_tag = be32_to_cpu ( ace -> ae_tag ) ; acl_e -> e_perm = be16_to_cpu ( ace -> ae_perm ) ; switch ( acl_e -> e_tag ) { case ACL_USER : case ACL_GROUP : acl_e -> e_id = be32_to_cpu ( ace -> ae_id ) ; break ; case ACL_USER_OBJ : case ACL_GROUP_OBJ : case ACL_MASK : case ACL_OTHER : acl_e -> e_id = ACL_UNDEFINED_ID ; break ; default : goto fail ; } } return acl ; fail : posix_acl_release ( acl ) ; return ERR_PTR ( - EINVAL ) ; } "," * ace ; unsigned ",torvalds@linux/093019cf1b18dd31b2c3b77acce4e000e2cbc9ce,CVE-2012-0038,https://github.com/torvalds/linux/commit/093019cf1b18dd31b2c3b77acce4e000e2cbc9ce,2012-05-17T11:00Z 389,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 390,CWE-125,"CWE-125 int main ( int argc , char * argv [ ] ) { FILE * iplist = NULL ; plist_t root_node = NULL ; char * plist_out = NULL ; uint32_t size = 0 ; int read_size = 0 ; char * plist_entire = NULL ; struct stat filestats ; options_t * options = parse_arguments ( argc , argv ) ; if ( ! options ) { print_usage ( argc , argv ) ; return 0 ; } iplist = fopen ( options -> in_file , ""rb"" ) ; if ( ! iplist ) { free ( options ) ; return 1 ; } stat ( options -> in_file , & filestats ) ; plist_entire = ( char * ) malloc ( sizeof ( char ) * ( filestats . st_size + 1 ) ) ; read_size = fread ( plist_entire , sizeof ( char ) , filestats . st_size , iplist ) ; fclose ( iplist ) ; if ( memcmp ( plist_entire , ""bplist00"" , 8 ) == 0 ) { plist_from_bin ( plist_entire , read_size , & root_node ) ; plist_to_xml ( root_node , & plist_out , & size ) ; } else { plist_from_xml ( plist_entire , read_size , & root_node ) ; plist_to_bin ( root_node , & plist_out , & size ) ; } plist_free ( root_node ) ; free ( plist_entire ) ; if ( plist_out ) { if ( options -> out_file != NULL ) { FILE * oplist = fopen ( options -> out_file , ""wb"" ) ; if ( ! oplist ) { free ( options ) ; return 1 ; } fwrite ( plist_out , size , sizeof ( char ) , oplist ) ; fclose ( oplist ) ; } else fwrite ( plist_out , size , sizeof ( char ) , stdout ) ; free ( plist_out ) ; } else printf ( ""ERROR:Failedtoconvertinputfile.\\n"" ) ; free ( options ) ; return 0 ; } "," filestats ) ; if ( filestats . st_size < 8 ) { printf ( ""ERROR:Inputfileistoosmalltocontainvalidplistdata.\\n"" ) ; return - 1 ; } ",libimobiledevice@libplist/7391a506352c009fe044dead7baad9e22dd279ee,CVE-2017-5545,https://github.com/libimobiledevice/libplist/commit/7391a506352c009fe044dead7baad9e22dd279ee,2017-01-21T01:59Z 391,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 392,CWE-416,"CWE-416 void luaT_getvarargs ( lua_State * L , CallInfo * ci , StkId where , int wanted ) { int i ; int nextra = ci -> u . l . nextraargs ; if ( wanted < 0 ) { wanted = nextra ; checkstackp ( L , nextra , where ) ; L -> top = where + nextra ; } for ( i = 0 ; i < wanted && i < nextra ; i ++ ) setobjs2s ( L , where + i , ci -> func - nextra + i ) ; for ( ; i < wanted ; i ++ ) setnilvalue ( s2v ( where + i ) ) ; } "," = nextra ; checkstackGCp ( L , ",lua@lua/eb41999461b6f428186c55abd95f4ce1a76217d5,CVE-2020-15888,https://github.com/lua/lua/commit/eb41999461b6f428186c55abd95f4ce1a76217d5,2020-07-21T22:15Z 393,CWE-119,"CWE-119 static int64_t rd_pick_intra_sub_8x8_y_mode ( VP9_COMP * cpi , MACROBLOCK * mb , int * rate , int * rate_y , int64_t * distortion , int64_t best_rd ) { int i , j ; const MACROBLOCKD * const xd = & mb -> e_mbd ; MODE_INFO * const mic = xd -> mi [ 0 ] ; const MODE_INFO * above_mi = xd -> mi [ - xd -> mi_stride ] ; const MODE_INFO * left_mi = xd -> left_available ? xd -> mi [ - 1 ] : NULL ; const BLOCK_SIZE bsize = xd -> mi [ 0 ] -> mbmi . sb_type ; const int num_4x4_blocks_wide = num_4x4_blocks_wide_lookup [ bsize ] ; const int num_4x4_blocks_high = num_4x4_blocks_high_lookup [ bsize ] ; int idx , idy ; int cost = 0 ; int64_t total_distortion = 0 ; int tot_rate_y = 0 ; int64_t total_rd = 0 ; ENTROPY_CONTEXT t_above [ 4 ] , t_left [ 4 ] ; const int * bmode_costs = mb -> mbmode_cost ; vpx_memcpy ( t_above , xd -> plane [ 0 ] . above_context , sizeof ( t_above ) ) ; vpx_memcpy ( t_left , xd -> plane [ 0 ] . left_context , sizeof ( t_left ) ) ; for ( idy = 0 ; idy < 2 ; idy += num_4x4_blocks_high ) { for ( idx = 0 ; idx < 2 ; idx += num_4x4_blocks_wide ) { MB_PREDICTION_MODE best_mode = DC_PRED ; int r = INT_MAX , ry = INT_MAX ; int64_t d = INT64_MAX , this_rd = INT64_MAX ; i = idy * 2 + idx ; if ( cpi -> common . frame_type == KEY_FRAME ) { const MB_PREDICTION_MODE A = vp9_above_block_mode ( mic , above_mi , i ) ; const MB_PREDICTION_MODE L = vp9_left_block_mode ( mic , left_mi , i ) ; bmode_costs = mb -> y_mode_costs [ A ] [ L ] ; } this_rd = rd_pick_intra4x4block ( cpi , mb , i , & best_mode , bmode_costs , t_above + idx , t_left + idy , & r , & ry , & d , bsize , best_rd - total_rd ) ; if ( this_rd >= best_rd - total_rd ) return INT64_MAX ; total_rd += this_rd ; cost += r ; total_distortion += d ; tot_rate_y += ry ; mic -> bmi [ i ] . as_mode = best_mode ; for ( j = 1 ; j < num_4x4_blocks_high ; ++ j ) mic -> bmi [ i + j * 2 ] . as_mode = best_mode ; for ( j = 1 ; j < num_4x4_blocks_wide ; ++ j ) mic -> bmi [ i + j ] . as_mode = best_mode ; if ( total_rd >= best_rd ) return INT64_MAX ; } } * rate = cost ; * rate_y = tot_rate_y ; * distortion = total_distortion ; mic -> mbmi . mode = mic -> bmi [ 3 ] . as_mode ; return RDCOST ( mb -> rdmult , mb -> rddiv , cost , total_distortion ) ; } "," = xd -> above_mi ; const MODE_INFO = xd -> left_mi ; const BLOCK_SIZE * bmode_costs = cpi -> mbmode_cost ; -> mbmode_cost ; memcpy ( t_above , ) ) ; memcpy ( t_left , num_4x4_blocks_wide ) { PREDICTION_MODE best_mode = DC_PRED ) { const PREDICTION_MODE A = vp9_above_block_mode ) ; const PREDICTION_MODE L = vp9_left_block_mode ; bmode_costs = cpi -> y_mode_costs [ A ] [ L ] ; } this_rd = rd_pick_intra4x4block ( cpi , mb , idy , idx , & best_mode ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 394,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 ) { 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 + 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 ; } "," } if ( ptr - c -> rcurr > 100 || ( strncmp ( ptr , ""get"" , 4 ) && strncmp ( ptr , ptr , ""gets"" , 5 ) ",memcached@memcached/d9cd01ede97f4145af9781d448c62a3318952719,CVE-2010-1152,https://github.com/memcached/memcached/commit/d9cd01ede97f4145af9781d448c62a3318952719,2010-04-12T18:30Z 395,CWE-400,"CWE-400 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 396,CWE-399,"CWE-399 static int udp_push_pending_frames ( struct sock * sk ) { struct udp_sock * up = udp_sk ( sk ) ; struct inet_sock * inet = inet_sk ( sk ) ; struct flowi4 * fl4 = & inet -> cork . fl . u . ip4 ; struct sk_buff * skb ; int err = 0 ; skb = ip_finish_skb ( sk , fl4 ) ; if ( ! skb ) goto out ; err = udp_send_skb ( skb , fl4 ) ; out : up -> len = 0 ; up -> pending = 0 ; return err ; } "," int udp_push_pending_frames ( ",torvalds@linux/8822b64a0fa64a5dd1dfcf837c5b0be83f8c05d1,CVE-2013-4162,https://github.com/torvalds/linux/commit/8822b64a0fa64a5dd1dfcf837c5b0be83f8c05d1,2013-07-29T13:59Z 397,CWE-17,"CWE-17 void bpf_int_jit_compile ( struct bpf_prog * prog ) { struct bpf_binary_header * header = NULL ; int proglen , oldproglen = 0 ; struct jit_context ctx = { } ; u8 * image = NULL ; int * addrs ; int pass ; int i ; if ( ! bpf_jit_enable ) return ; if ( ! prog || ! prog -> len ) return ; addrs = kmalloc ( prog -> len * sizeof ( * addrs ) , GFP_KERNEL ) ; if ( ! addrs ) return ; for ( proglen = 0 , i = 0 ; i < prog -> len ; i ++ ) { proglen += 64 ; addrs [ i ] = proglen ; } ctx . cleanup_addr = proglen ; for ( pass = 0 ; pass < 10 ; pass ++ ) { proglen = do_jit ( prog , addrs , image , oldproglen , & ctx ) ; if ( proglen <= 0 ) { image = NULL ; if ( header ) bpf_jit_binary_free ( header ) ; goto out ; } if ( image ) { if ( proglen != oldproglen ) { pr_err ( ""bpf_jit:proglen=%d!=oldproglen=%d\\n"" , proglen , oldproglen ) ; goto out ; } break ; } if ( proglen == oldproglen ) { header = bpf_jit_binary_alloc ( proglen , & image , 1 , jit_fill_hole ) ; if ( ! header ) goto out ; } oldproglen = proglen ; } if ( bpf_jit_enable > 1 ) bpf_jit_dump ( prog -> len , proglen , 0 , image ) ; if ( image ) { bpf_flush_icache ( header , image + proglen ) ; set_memory_ro ( ( unsigned long ) header , header -> pages ) ; prog -> bpf_func = ( void * ) image ; prog -> jited = true ; } out : kfree ( addrs ) ; } "," pass < 10 || image ",torvalds@linux/3f7352bf21f8fd7ba3e2fcef9488756f188e12be,CVE-2015-4700,https://github.com/torvalds/linux/commit/3f7352bf21f8fd7ba3e2fcef9488756f188e12be,2015-08-31T10:59Z 398,CWE-284,"CWE-284 int vfs_rename ( struct inode * old_dir , struct dentry * old_dentry , struct inode * new_dir , struct dentry * new_dentry , struct inode * * delegated_inode , unsigned int flags ) { int error ; bool is_dir = d_is_dir ( old_dentry ) ; const unsigned char * old_name ; struct inode * source = old_dentry -> d_inode ; struct inode * target = new_dentry -> d_inode ; bool new_is_dir = false ; unsigned max_links = new_dir -> i_sb -> s_max_links ; if ( source == target ) return 0 ; error = may_delete ( old_dir , old_dentry , is_dir ) ; if ( error ) return error ; if ( ! target ) { error = may_create ( new_dir , new_dentry ) ; } else { new_is_dir = d_is_dir ( new_dentry ) ; if ( ! ( flags & RENAME_EXCHANGE ) ) error = may_delete ( new_dir , new_dentry , is_dir ) ; else error = may_delete ( new_dir , new_dentry , new_is_dir ) ; } if ( error ) return error ; if ( ! old_dir -> i_op -> rename && ! old_dir -> i_op -> rename2 ) return - EPERM ; if ( flags && ! old_dir -> i_op -> rename2 ) return - EINVAL ; if ( new_dir != old_dir ) { if ( is_dir ) { error = inode_permission ( source , MAY_WRITE ) ; if ( error ) return error ; } if ( ( flags & RENAME_EXCHANGE ) && new_is_dir ) { error = inode_permission ( target , MAY_WRITE ) ; if ( error ) return error ; } } error = security_inode_rename ( old_dir , old_dentry , new_dir , new_dentry , flags ) ; if ( error ) return error ; old_name = fsnotify_oldname_init ( old_dentry -> d_name . name ) ; dget ( new_dentry ) ; if ( ! is_dir || ( flags & RENAME_EXCHANGE ) ) lock_two_nondirectories ( source , target ) ; else if ( target ) inode_lock ( target ) ; error = - EBUSY ; if ( is_local_mountpoint ( old_dentry ) || is_local_mountpoint ( new_dentry ) ) goto out ; if ( max_links && new_dir != old_dir ) { error = - EMLINK ; if ( is_dir && ! new_is_dir && new_dir -> i_nlink >= max_links ) goto out ; if ( ( flags & RENAME_EXCHANGE ) && ! is_dir && new_is_dir && old_dir -> i_nlink >= max_links ) goto out ; } if ( is_dir && ! ( flags & RENAME_EXCHANGE ) && target ) shrink_dcache_parent ( new_dentry ) ; if ( ! is_dir ) { error = try_break_deleg ( source , delegated_inode ) ; if ( error ) goto out ; } if ( target && ! new_is_dir ) { error = try_break_deleg ( target , delegated_inode ) ; if ( error ) goto out ; } if ( ! old_dir -> i_op -> rename2 ) { error = old_dir -> i_op -> rename ( old_dir , old_dentry , new_dir , new_dentry ) ; } else { WARN_ON ( old_dir -> i_op -> rename != NULL ) ; error = old_dir -> i_op -> rename2 ( old_dir , old_dentry , new_dir , new_dentry , flags ) ; } if ( error ) goto out ; if ( ! ( flags & RENAME_EXCHANGE ) && target ) { if ( is_dir ) target -> i_flags |= S_DEAD ; dont_mount ( new_dentry ) ; detach_mounts ( new_dentry ) ; } if ( ! ( old_dir -> i_sb -> s_type -> fs_flags & FS_RENAME_DOES_D_MOVE ) ) { if ( ! ( flags & RENAME_EXCHANGE ) ) d_move ( old_dentry , new_dentry ) ; else d_exchange ( old_dentry , new_dentry ) ; } out : if ( ! is_dir || ( flags & RENAME_EXCHANGE ) ) unlock_two_nondirectories ( source , target ) ; else if ( target ) inode_unlock ( target ) ; dput ( new_dentry ) ; if ( ! error ) { fsnotify_move ( old_dir , new_dir , old_name , is_dir , ! ( flags & RENAME_EXCHANGE ) ? target : NULL , old_dentry ) ; if ( flags & RENAME_EXCHANGE ) { fsnotify_move ( new_dir , old_dir , old_dentry -> d_name . name , new_is_dir , NULL , new_dentry ) ; } } fsnotify_oldname_free ( old_name ) ; return error ; } "," ; if ( vfs_select_inode ( old_dentry , 0 ) == vfs_select_inode ( new_dentry , 0 ) ) return 0 ",torvalds@linux/9409e22acdfc9153f88d9b1ed2bd2a5b34d2d3ca,CVE-2016-6198,https://github.com/torvalds/linux/commit/9409e22acdfc9153f88d9b1ed2bd2a5b34d2d3ca,2016-08-06T20:59Z 399,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 400,CWE-416,"CWE-416 static void mark_context_stack ( mrb_state * mrb , struct mrb_context * c ) { size_t i ; size_t e ; if ( c -> stack == NULL ) return ; e = c -> stack - c -> stbase ; if ( c -> ci ) e += c -> ci -> nregs ; if ( c -> stbase + e > c -> stend ) e = c -> stend - c -> stbase ; for ( i = 0 ; i < e ; i ++ ) { mrb_value v = c -> stbase [ i ] ; if ( ! mrb_immediate_p ( v ) ) { if ( mrb_basic_ptr ( v ) -> tt == MRB_TT_FREE ) { c -> stbase [ i ] = mrb_nil_value ( ) ; } else { mrb_gc_mark ( mrb , mrb_basic_ptr ( v ) ) ; } } } } "," ; size_t e ; mrb_value nil ) ) { mrb_gc_mark ( mrb ; } } e = c -> stend - c -> stbase ; nil = mrb_nil_value ( ) ; for ( ; i < e ; i ++ ) { c -> stbase [ i ] = nil ; ",mruby@mruby/5c114c91d4ff31859fcd84cf8bf349b737b90d99,CVE-2017-9527,https://github.com/mruby/mruby/commit/5c114c91d4ff31859fcd84cf8bf349b737b90d99,2017-06-11T17:29Z 401,CWE-125,"CWE-125 void __skb_tstamp_tx ( struct sk_buff * orig_skb , struct skb_shared_hwtstamps * hwtstamps , struct sock * sk , int tstype ) { struct sk_buff * skb ; bool tsonly ; if ( ! sk ) return ; tsonly = sk -> sk_tsflags & SOF_TIMESTAMPING_OPT_TSONLY ; if ( ! skb_may_tx_timestamp ( sk , tsonly ) ) return ; if ( tsonly ) { # ifdef CONFIG_INET if ( ( sk -> sk_tsflags & SOF_TIMESTAMPING_OPT_STATS ) && sk -> sk_protocol == IPPROTO_TCP && sk -> sk_type == SOCK_STREAM ) skb = tcp_get_timestamping_opt_stats ( sk ) ; else # endif skb = alloc_skb ( 0 , GFP_ATOMIC ) ; } else { skb = skb_clone ( orig_skb , GFP_ATOMIC ) ; } if ( ! skb ) return ; if ( tsonly ) { skb_shinfo ( skb ) -> tx_flags = skb_shinfo ( orig_skb ) -> tx_flags ; skb_shinfo ( skb ) -> tskey = skb_shinfo ( orig_skb ) -> tskey ; } if ( hwtstamps ) * skb_hwtstamps ( skb ) = * hwtstamps ; else skb -> tstamp = ktime_get_real ( ) ; __skb_complete_tx_timestamp ( skb , sk , tstype ) ; } "," ; bool tsonly , opt_stats = false == SOCK_STREAM ) { sk ) ; opt_stats = true ; } sk , tstype , opt_stats ",torvalds@linux/4ef1b2869447411ad3ef91ad7d4891a83c1a509a,CVE-2017-7277,https://github.com/torvalds/linux/commit/4ef1b2869447411ad3ef91ad7d4891a83c1a509a,2017-03-28T06:59Z 402,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 ) ; if ( ( cc0 % rowsize ) != 0 ) { TIFFErrorExt ( tif -> tif_clientdata , ""PredictorEncodeTile"" , ""%s"" , ""(cc0%rowsize)!=0"" ) ; return 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 ; } "," ""(cc0%rowsize)!=0"" ) ; _TIFFfree ( working_copy ) ; ",vadz@libtiff/6a984bf7905c6621281588431f384e79d11a2e33,CVE-2016-9535,https://github.com/vadz/libtiff/commit/6a984bf7905c6621281588431f384e79d11a2e33,2016-11-22T19:59Z 403,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 404,CWE-416,"CWE-416 static void lo_release ( struct gendisk * disk , fmode_t mode ) { struct loop_device * lo = disk -> private_data ; int err ; if ( atomic_dec_return ( & lo -> lo_refcnt ) ) return ; mutex_lock ( & lo -> lo_ctl_mutex ) ; if ( lo -> lo_flags & LO_FLAGS_AUTOCLEAR ) { err = loop_clr_fd ( lo ) ; if ( ! err ) return ; } else if ( lo -> lo_state == Lo_bound ) { blk_mq_freeze_queue ( lo -> lo_queue ) ; blk_mq_unfreeze_queue ( lo -> lo_queue ) ; } mutex_unlock ( & lo -> lo_ctl_mutex ) ; } "," mode ) { mutex_lock ( & loop_index_mutex ) ; __lo_release ( disk -> private_data disk -> private_data ) ; mutex_unlock ( & mutex_unlock ( & loop_index_mutex ) ; } ",torvalds@linux/ae6650163c66a7eff1acd6eb8b0f752dcfa8eba5,CVE-2018-5344,https://github.com/torvalds/linux/commit/ae6650163c66a7eff1acd6eb8b0f752dcfa8eba5,2018-01-12T09:29Z 405,CWE-436,"CWE-436 bgp_attr_parse_ret_t bgp_attr_parse ( struct peer * peer , struct attr * attr , bgp_size_t size , struct bgp_nlri * mp_update , struct bgp_nlri * mp_withdraw ) { bgp_attr_parse_ret_t ret ; uint8_t flag = 0 ; uint8_t type = 0 ; bgp_size_t length ; uint8_t * startp , * endp ; uint8_t * attr_endp ; uint8_t seen [ BGP_ATTR_BITMAP_SIZE ] ; struct aspath * as4_path = NULL ; as_t as4_aggregator = 0 ; struct in_addr as4_aggregator_addr = { . s_addr = 0 } ; memset ( seen , 0 , BGP_ATTR_BITMAP_SIZE ) ; endp = BGP_INPUT_PNT ( peer ) + size ; while ( BGP_INPUT_PNT ( peer ) < endp ) { if ( endp - BGP_INPUT_PNT ( peer ) < BGP_ATTR_MIN_LEN ) { flog_warn ( EC_BGP_ATTRIBUTE_TOO_SMALL , ""%s:errorBGPattributelength%luissmallerthanminlen"" , peer -> host , ( unsigned long ) ( endp - stream_pnt ( BGP_INPUT ( peer ) ) ) ) ; bgp_notify_send ( peer , BGP_NOTIFY_UPDATE_ERR , BGP_NOTIFY_UPDATE_ATTR_LENG_ERR ) ; return BGP_ATTR_PARSE_ERROR ; } startp = BGP_INPUT_PNT ( peer ) ; flag = 0xF0 & stream_getc ( BGP_INPUT ( peer ) ) ; type = stream_getc ( BGP_INPUT ( peer ) ) ; if ( CHECK_FLAG ( flag , BGP_ATTR_FLAG_EXTLEN ) && ( ( endp - startp ) < ( BGP_ATTR_MIN_LEN + 1 ) ) ) { flog_warn ( EC_BGP_EXT_ATTRIBUTE_TOO_SMALL , ""%s:Extendedlengthset,butjust%lubytesofattrheader"" , peer -> host , ( unsigned long ) ( endp - stream_pnt ( BGP_INPUT ( peer ) ) ) ) ; bgp_notify_send ( peer , BGP_NOTIFY_UPDATE_ERR , BGP_NOTIFY_UPDATE_ATTR_LENG_ERR ) ; return BGP_ATTR_PARSE_ERROR ; } if ( CHECK_FLAG ( flag , BGP_ATTR_FLAG_EXTLEN ) ) length = stream_getw ( BGP_INPUT ( peer ) ) ; else length = stream_getc ( BGP_INPUT ( peer ) ) ; if ( CHECK_BITMAP ( seen , type ) ) { flog_warn ( EC_BGP_ATTRIBUTE_REPEATED , ""%s:errorBGPattributetype%dappearstwiceinamessage"" , peer -> host , type ) ; bgp_notify_send ( peer , BGP_NOTIFY_UPDATE_ERR , BGP_NOTIFY_UPDATE_MAL_ATTR ) ; return BGP_ATTR_PARSE_ERROR ; } SET_BITMAP ( seen , type ) ; attr_endp = BGP_INPUT_PNT ( peer ) + length ; if ( attr_endp > endp ) { flog_warn ( EC_BGP_ATTRIBUTE_TOO_LARGE , ""%s:BGPtype%dlength%distoolarge,attributetotallengthis%d.attr_endpis%p.endpis%p"" , peer -> host , type , length , size , attr_endp , endp ) ; unsigned char ndata [ BGP_MAX_PACKET_SIZE ] ; memset ( ndata , 0x00 , sizeof ( ndata ) ) ; size_t lfl = CHECK_FLAG ( flag , BGP_ATTR_FLAG_EXTLEN ) ? 2 : 1 ; stream_forward_getp ( BGP_INPUT ( peer ) , - ( 1 + lfl ) ) ; stream_get ( & ndata [ 0 ] , BGP_INPUT ( peer ) , 1 ) ; stream_get ( & ndata [ 1 ] , BGP_INPUT ( peer ) , lfl ) ; size_t atl = attr_endp - startp ; size_t ndl = MIN ( atl , STREAM_READABLE ( BGP_INPUT ( peer ) ) ) ; stream_get ( & ndata [ lfl + 1 ] , BGP_INPUT ( peer ) , ndl ) ; bgp_notify_send_with_data ( peer , BGP_NOTIFY_UPDATE_ERR , BGP_NOTIFY_UPDATE_ATTR_LENG_ERR , ndata , ndl + lfl + 1 ) ; return BGP_ATTR_PARSE_ERROR ; } struct bgp_attr_parser_args attr_args = { . peer = peer , . length = length , . attr = attr , . type = type , . flags = flag , . startp = startp , . total = attr_endp - startp , } ; if ( bgp_attr_flag_invalid ( & attr_args ) ) { ret = bgp_attr_malformed ( & attr_args , BGP_NOTIFY_UPDATE_ATTR_FLAG_ERR , attr_args . total ) ; if ( ret == BGP_ATTR_PARSE_PROCEED ) continue ; return ret ; } switch ( type ) { case BGP_ATTR_ORIGIN : ret = bgp_attr_origin ( & attr_args ) ; break ; case BGP_ATTR_AS_PATH : ret = bgp_attr_aspath ( & attr_args ) ; break ; case BGP_ATTR_AS4_PATH : ret = bgp_attr_as4_path ( & attr_args , & as4_path ) ; break ; case BGP_ATTR_NEXT_HOP : ret = bgp_attr_nexthop ( & attr_args ) ; break ; case BGP_ATTR_MULTI_EXIT_DISC : ret = bgp_attr_med ( & attr_args ) ; break ; case BGP_ATTR_LOCAL_PREF : ret = bgp_attr_local_pref ( & attr_args ) ; break ; case BGP_ATTR_ATOMIC_AGGREGATE : ret = bgp_attr_atomic ( & attr_args ) ; break ; case BGP_ATTR_AGGREGATOR : ret = bgp_attr_aggregator ( & attr_args ) ; break ; case BGP_ATTR_AS4_AGGREGATOR : ret = bgp_attr_as4_aggregator ( & attr_args , & as4_aggregator , & as4_aggregator_addr ) ; break ; case BGP_ATTR_COMMUNITIES : ret = bgp_attr_community ( & attr_args ) ; break ; case BGP_ATTR_LARGE_COMMUNITIES : ret = bgp_attr_large_community ( & attr_args ) ; break ; case BGP_ATTR_ORIGINATOR_ID : ret = bgp_attr_originator_id ( & attr_args ) ; break ; case BGP_ATTR_CLUSTER_LIST : ret = bgp_attr_cluster_list ( & attr_args ) ; break ; case BGP_ATTR_MP_REACH_NLRI : ret = bgp_mp_reach_parse ( & attr_args , mp_update ) ; break ; case BGP_ATTR_MP_UNREACH_NLRI : ret = bgp_mp_unreach_parse ( & attr_args , mp_withdraw ) ; break ; case BGP_ATTR_EXT_COMMUNITIES : ret = bgp_attr_ext_communities ( & attr_args ) ; break ; # if ENABLE_BGP_VNC case BGP_ATTR_VNC : # endif case BGP_ATTR_ENCAP : ret = bgp_attr_encap ( type , peer , length , attr , flag , startp ) ; break ; case BGP_ATTR_PREFIX_SID : ret = bgp_attr_prefix_sid ( length , & attr_args , mp_update ) ; break ; case BGP_ATTR_PMSI_TUNNEL : ret = bgp_attr_pmsi_tunnel ( & attr_args ) ; break ; default : ret = bgp_attr_unknown ( & attr_args ) ; break ; } if ( ret == BGP_ATTR_PARSE_ERROR_NOTIFYPLS ) { bgp_notify_send ( peer , BGP_NOTIFY_UPDATE_ERR , BGP_NOTIFY_UPDATE_MAL_ATTR ) ; ret = BGP_ATTR_PARSE_ERROR ; } if ( ret == BGP_ATTR_PARSE_EOR ) { if ( as4_path ) aspath_unintern ( & as4_path ) ; return ret ; } if ( ret == BGP_ATTR_PARSE_ERROR ) { flog_warn ( EC_BGP_ATTRIBUTE_PARSE_ERROR , ""%s:Attribute%s,parseerror"" , peer -> host , lookup_msg ( attr_str , type , NULL ) ) ; if ( as4_path ) aspath_unintern ( & as4_path ) ; return ret ; } if ( ret == BGP_ATTR_PARSE_WITHDRAW ) { flog_warn ( EC_BGP_ATTRIBUTE_PARSE_WITHDRAW , ""%s:Attribute%s,parseerror-treatingaswithdrawal"" , peer -> host , lookup_msg ( attr_str , type , NULL ) ) ; if ( as4_path ) aspath_unintern ( & as4_path ) ; return ret ; } if ( BGP_INPUT_PNT ( peer ) != attr_endp ) { flog_warn ( EC_BGP_ATTRIBUTE_FETCH_ERROR , ""%s:BGPattribute%s,fetcherror"" , peer -> host , lookup_msg ( attr_str , type , NULL ) ) ; bgp_notify_send ( peer , BGP_NOTIFY_UPDATE_ERR , BGP_NOTIFY_UPDATE_ATTR_LENG_ERR ) ; if ( as4_path ) aspath_unintern ( & as4_path ) ; return BGP_ATTR_PARSE_ERROR ; } } if ( BGP_INPUT_PNT ( peer ) != endp ) { flog_warn ( EC_BGP_ATTRIBUTES_MISMATCH , ""%s:BGPattribute%s,lengthmismatch"" , peer -> host , lookup_msg ( attr_str , type , NULL ) ) ; bgp_notify_send ( peer , BGP_NOTIFY_UPDATE_ERR , BGP_NOTIFY_UPDATE_ATTR_LENG_ERR ) ; if ( as4_path ) aspath_unintern ( & as4_path ) ; return BGP_ATTR_PARSE_ERROR ; } if ( ( ret = bgp_attr_check ( peer , attr ) ) < 0 ) { if ( as4_path ) aspath_unintern ( & as4_path ) ; return ret ; } if ( CHECK_FLAG ( attr -> flag , ATTR_FLAG_BIT ( BGP_ATTR_AS_PATH ) ) && bgp_attr_munge_as4_attrs ( peer , attr , as4_path , as4_aggregator , & as4_aggregator_addr ) ) { bgp_notify_send ( peer , BGP_NOTIFY_UPDATE_ERR , BGP_NOTIFY_UPDATE_MAL_ATTR ) ; if ( as4_path ) aspath_unintern ( & as4_path ) ; return BGP_ATTR_PARSE_ERROR ; } if ( as4_path ) { aspath_unintern ( & as4_path ) ; } if ( attr -> flag & ( ATTR_FLAG_BIT ( BGP_ATTR_AS_PATH ) ) ) { ret = bgp_attr_aspath_check ( peer , attr ) ; if ( ret != BGP_ATTR_PARSE_PROCEED ) return ret ; } if ( attr -> transit ) attr -> transit = transit_intern ( attr -> transit ) ; if ( attr -> encap_subtlvs ) attr -> encap_subtlvs = encap_intern ( attr -> encap_subtlvs , ENCAP_SUBTLV_TYPE ) ; # if ENABLE_BGP_VNC if ( attr -> vnc_subtlvs ) attr -> vnc_subtlvs = encap_intern ( attr -> vnc_subtlvs , VNC_SUBTLV_TYPE ) ; # endif return BGP_ATTR_PARSE_PROCEED ; } "," ; # if ENABLE_BGP_VNC_ATTR case BGP_ATTR_VNC : ",FRRouting@frr/943d595a018e69b550db08cccba1d0778a86705a,CVE-2019-5892,https://github.com/FRRouting/frr/commit/943d595a018e69b550db08cccba1d0778a86705a,2019-01-10T17:29Z 406,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 407,CWE-20,"CWE-20 static int encrypted_update ( struct key * key , struct key_preparsed_payload * prep ) { struct encrypted_key_payload * epayload = key -> payload . data [ 0 ] ; struct encrypted_key_payload * new_epayload ; char * buf ; char * new_master_desc = NULL ; const char * format = NULL ; size_t datalen = prep -> datalen ; int ret = 0 ; if ( test_bit ( KEY_FLAG_NEGATIVE , & key -> flags ) ) return - ENOKEY ; if ( datalen <= 0 || datalen > 32767 || ! prep -> data ) return - EINVAL ; buf = kmalloc ( datalen + 1 , GFP_KERNEL ) ; if ( ! buf ) return - ENOMEM ; buf [ datalen ] = 0 ; memcpy ( buf , prep -> data , datalen ) ; ret = datablob_parse ( buf , & format , & new_master_desc , NULL , NULL ) ; if ( ret < 0 ) goto out ; ret = valid_master_desc ( new_master_desc , epayload -> master_desc ) ; if ( ret < 0 ) goto out ; new_epayload = encrypted_key_alloc ( key , epayload -> format , new_master_desc , epayload -> datalen ) ; if ( IS_ERR ( new_epayload ) ) { ret = PTR_ERR ( new_epayload ) ; goto out ; } __ekey_init ( new_epayload , epayload -> format , new_master_desc , epayload -> datalen ) ; memcpy ( new_epayload -> iv , epayload -> iv , ivsize ) ; memcpy ( new_epayload -> payload_data , epayload -> payload_data , epayload -> payload_datalen ) ; rcu_assign_keypointer ( key , new_epayload ) ; call_rcu ( & epayload -> rcu , encrypted_rcu_free ) ; out : kzfree ( buf ) ; 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 408,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 409,CWE-119,"CWE-119 static int filter_frame ( AVFilterLink * inlink , AVFrame * inpic ) { KerndeintContext * kerndeint = inlink -> dst -> priv ; AVFilterLink * outlink = inlink -> dst -> outputs [ 0 ] ; AVFrame * outpic ; const uint8_t * prvp ; const uint8_t * prvpp ; const uint8_t * prvpn ; const uint8_t * prvppp ; const uint8_t * prvpnn ; const uint8_t * prvp4p ; const uint8_t * prvp4n ; const uint8_t * srcp ; const uint8_t * srcpp ; const uint8_t * srcpn ; const uint8_t * srcppp ; const uint8_t * srcpnn ; const uint8_t * srcp3p ; const uint8_t * srcp3n ; const uint8_t * srcp4p ; const uint8_t * srcp4n ; uint8_t * dstp , * dstp_saved ; const uint8_t * srcp_saved ; int src_linesize , psrc_linesize , dst_linesize , bwidth ; int x , y , plane , val , hi , lo , g , h , n = kerndeint -> frame ++ ; double valf ; const int thresh = kerndeint -> thresh ; const int order = kerndeint -> order ; const int map = kerndeint -> map ; const int sharp = kerndeint -> sharp ; const int twoway = kerndeint -> twoway ; const int is_packed_rgb = kerndeint -> is_packed_rgb ; outpic = ff_get_video_buffer ( outlink , outlink -> w , outlink -> h ) ; if ( ! outpic ) { av_frame_free ( & inpic ) ; return AVERROR ( ENOMEM ) ; } av_frame_copy_props ( outpic , inpic ) ; outpic -> interlaced_frame = 0 ; for ( plane = 0 ; inpic -> data [ plane ] && plane < 4 ; plane ++ ) { h = plane == 0 ? inlink -> h : FF_CEIL_RSHIFT ( inlink -> h , kerndeint -> vsub ) ; bwidth = kerndeint -> tmp_bwidth [ plane ] ; srcp = srcp_saved = inpic -> data [ plane ] ; src_linesize = inpic -> linesize [ plane ] ; psrc_linesize = kerndeint -> tmp_linesize [ plane ] ; dstp = dstp_saved = outpic -> data [ plane ] ; dst_linesize = outpic -> linesize [ plane ] ; srcp = srcp_saved + ( 1 - order ) * src_linesize ; dstp = dstp_saved + ( 1 - order ) * dst_linesize ; for ( y = 0 ; y < h ; y += 2 ) { memcpy ( dstp , srcp , bwidth ) ; srcp += 2 * src_linesize ; dstp += 2 * dst_linesize ; } memcpy ( dstp_saved + order * dst_linesize , srcp_saved + ( 1 - order ) * src_linesize , bwidth ) ; memcpy ( dstp_saved + ( 2 + order ) * dst_linesize , srcp_saved + ( 3 - order ) * src_linesize , bwidth ) ; memcpy ( dstp_saved + ( h - 2 + order ) * dst_linesize , srcp_saved + ( h - 1 - order ) * src_linesize , bwidth ) ; memcpy ( dstp_saved + ( h - 4 + order ) * dst_linesize , srcp_saved + ( h - 3 - order ) * src_linesize , bwidth ) ; prvp = kerndeint -> tmp_data [ plane ] + 5 * psrc_linesize - ( 1 - order ) * psrc_linesize ; prvpp = prvp - psrc_linesize ; prvppp = prvp - 2 * psrc_linesize ; prvp4p = prvp - 4 * psrc_linesize ; prvpn = prvp + psrc_linesize ; prvpnn = prvp + 2 * psrc_linesize ; prvp4n = prvp + 4 * psrc_linesize ; srcp = srcp_saved + 5 * src_linesize - ( 1 - order ) * src_linesize ; srcpp = srcp - src_linesize ; srcppp = srcp - 2 * src_linesize ; srcp3p = srcp - 3 * src_linesize ; srcp4p = srcp - 4 * src_linesize ; srcpn = srcp + src_linesize ; srcpnn = srcp + 2 * src_linesize ; srcp3n = srcp + 3 * src_linesize ; srcp4n = srcp + 4 * src_linesize ; dstp = dstp_saved + 5 * dst_linesize - ( 1 - order ) * dst_linesize ; for ( y = 5 - ( 1 - order ) ; y <= h - 5 - ( 1 - order ) ; y += 2 ) { for ( x = 0 ; x < bwidth ; x ++ ) { if ( thresh == 0 || n == 0 || ( abs ( ( int ) prvp [ x ] - ( int ) srcp [ x ] ) > thresh ) || ( abs ( ( int ) prvpp [ x ] - ( int ) srcpp [ x ] ) > thresh ) || ( abs ( ( int ) prvpn [ x ] - ( int ) srcpn [ x ] ) > thresh ) ) { if ( map ) { g = x & ~ 3 ; if ( is_packed_rgb ) { AV_WB32 ( dstp + g , 0xffffffff ) ; x = g + 3 ; } else if ( inlink -> format == AV_PIX_FMT_YUYV422 ) { AV_WB32 ( dstp + g , 0xeb80eb80 ) ; x = g + 3 ; } else { dstp [ x ] = plane == 0 ? 235 : 128 ; } } else { if ( is_packed_rgb ) { hi = 255 ; lo = 0 ; } else if ( inlink -> format == AV_PIX_FMT_YUYV422 ) { hi = x & 1 ? 240 : 235 ; lo = 16 ; } else { hi = plane == 0 ? 235 : 240 ; lo = 16 ; } if ( sharp ) { if ( twoway ) { valf = + 0.526 * ( ( int ) srcpp [ x ] + ( int ) srcpn [ x ] ) + 0.170 * ( ( int ) srcp [ x ] + ( int ) prvp [ x ] ) - 0.116 * ( ( int ) srcppp [ x ] + ( int ) srcpnn [ x ] + ( int ) prvppp [ x ] + ( int ) prvpnn [ x ] ) - 0.026 * ( ( int ) srcp3p [ x ] + ( int ) srcp3n [ x ] ) + 0.031 * ( ( int ) srcp4p [ x ] + ( int ) srcp4n [ x ] + ( int ) prvp4p [ x ] + ( int ) prvp4n [ x ] ) ; } else { valf = + 0.526 * ( ( int ) srcpp [ x ] + ( int ) srcpn [ x ] ) + 0.170 * ( ( int ) prvp [ x ] ) - 0.116 * ( ( int ) prvppp [ x ] + ( int ) prvpnn [ x ] ) - 0.026 * ( ( int ) srcp3p [ x ] + ( int ) srcp3n [ x ] ) + 0.031 * ( ( int ) prvp4p [ x ] + ( int ) prvp4p [ x ] ) ; } dstp [ x ] = av_clip ( valf , lo , hi ) ; } else { if ( twoway ) { val = ( 8 * ( ( int ) srcpp [ x ] + ( int ) srcpn [ x ] ) + 2 * ( ( int ) srcp [ x ] + ( int ) prvp [ x ] ) - ( int ) ( srcppp [ x ] ) - ( int ) ( srcpnn [ x ] ) - ( int ) ( prvppp [ x ] ) - ( int ) ( prvpnn [ x ] ) ) >> 4 ; } else { val = ( 8 * ( ( int ) srcpp [ x ] + ( int ) srcpn [ x ] ) + 2 * ( ( int ) prvp [ x ] ) - ( int ) ( prvppp [ x ] ) - ( int ) ( prvpnn [ x ] ) ) >> 4 ; } dstp [ x ] = av_clip ( val , lo , hi ) ; } } } else { dstp [ x ] = srcp [ x ] ; } } prvp += 2 * psrc_linesize ; prvpp += 2 * psrc_linesize ; prvppp += 2 * psrc_linesize ; prvpn += 2 * psrc_linesize ; prvpnn += 2 * psrc_linesize ; prvp4p += 2 * psrc_linesize ; prvp4n += 2 * psrc_linesize ; srcp += 2 * src_linesize ; srcpp += 2 * src_linesize ; srcppp += 2 * src_linesize ; srcp3p += 2 * src_linesize ; srcp4p += 2 * src_linesize ; srcpn += 2 * src_linesize ; srcpnn += 2 * src_linesize ; srcp3n += 2 * src_linesize ; srcp4n += 2 * src_linesize ; dstp += 2 * dst_linesize ; } srcp = inpic -> data [ plane ] ; dstp = kerndeint -> tmp_data [ plane ] ; av_image_copy_plane ( dstp , psrc_linesize , srcp , src_linesize , bwidth , h ) ; } av_frame_free ( & inpic ) ; return ff_filter_frame ( outlink , outpic ) ; } "," = 0 ; plane < 4 plane < 4 && inpic -> data [ plane ] && inpic -> linesize [ plane ] ",FFmpeg@FFmpeg/e43a0a232dbf6d3c161823c2e07c52e76227a1bc,CVE-2013-4263,https://github.com/FFmpeg/FFmpeg/commit/e43a0a232dbf6d3c161823c2e07c52e76227a1bc,2013-11-23T17:55Z 410,CWE-125,"CWE-125 int yr_re_match ( RE * re , const char * target ) { return yr_re_exec ( re -> code , ( uint8_t * ) target , strlen ( target ) , re -> flags | RE_FLAGS_SCAN , NULL , NULL ) ; } "," target ) , 0 , ",VirusTotal@yara/83d799804648c2a0895d40a19835d9b757c6fa4e,CVE-2017-8294,https://github.com/VirusTotal/yara/commit/83d799804648c2a0895d40a19835d9b757c6fa4e,2017-04-27T14:59Z 411,CWE-125,"CWE-125 static const u_char * ikev1_attr_print ( netdissect_options * ndo , const u_char * p , const u_char * ep ) { int totlen ; uint32_t t ; if ( p [ 0 ] & 0x80 ) totlen = 4 ; else totlen = 4 + EXTRACT_16BITS ( & p [ 2 ] ) ; if ( ep < p + totlen ) { ND_PRINT ( ( ndo , ""[|attr]"" ) ) ; return ep + 1 ; } ND_PRINT ( ( ndo , ""("" ) ) ; t = EXTRACT_16BITS ( & p [ 0 ] ) & 0x7fff ; ND_PRINT ( ( ndo , ""type=#%d"" , t ) ) ; if ( p [ 0 ] & 0x80 ) { ND_PRINT ( ( ndo , ""value="" ) ) ; t = p [ 2 ] ; rawprint ( ndo , ( const uint8_t * ) & p [ 2 ] , 2 ) ; } else { ND_PRINT ( ( ndo , ""len=%dvalue="" , EXTRACT_16BITS ( & p [ 2 ] ) ) ) ; rawprint ( ndo , ( const uint8_t * ) & p [ 4 ] , EXTRACT_16BITS ( & p [ 2 ] ) ) ; } ND_PRINT ( ( ndo , "")"" ) ) ; return p + totlen ; } "," const u_char * ep2 ) { int uint32_t t ; ND_TCHECK ( p [ 0 ] ) ; 4 ; else { ND_TCHECK_16BITS ( & p [ 2 ] ) ; ] ) ; } if ( ep2 < p + ) ; return ep2 + 1 ; 1 ; } ND_TCHECK_16BITS ( & p [ 0 ] ) ; 2 ] ; if ( ! , 2 ) ) { ND_PRINT ( ( ndo , "")"" ) ) ; goto trunc ; } } else { , ""len=%dvalue="" , totlen - 4 ) ) ; if ( ! rawprint ( ndo 4 ] , totlen - 4 ) ) { ND_PRINT ( ( ) ) ; goto trunc ; } } ND_PRINT ( ( ndo , "")"" ) ) ; + totlen ; trunc : return NULL ; ",the-tcpdump-group@tcpdump/e0a5a02b0fc1900a69d6c37ed0aab36fb8494e6d,CVE-2017-13039,https://github.com/the-tcpdump-group/tcpdump/commit/e0a5a02b0fc1900a69d6c37ed0aab36fb8494e6d,2017-09-14T06:29Z 412,CWE-119,"CWE-119 static int PredictorDecodeRow ( TIFF * tif , uint8 * op0 , tmsize_t occ0 , uint16 s ) { TIFFPredictorState * sp = PredictorState ( tif ) ; assert ( sp != NULL ) ; assert ( sp -> decoderow != NULL ) ; assert ( sp -> decodepfunc != NULL ) ; if ( ( * sp -> decoderow ) ( tif , op0 , occ0 , s ) ) { ( * sp -> decodepfunc ) ( tif , op0 , occ0 ) ; return 1 ; } else return 0 ; } "," ) ) { return occ0 ) ; } else return ",vadz@libtiff/3ca657a8793dd011bf869695d72ad31c779c3cc1,CVE-2016-9535,https://github.com/vadz/libtiff/commit/3ca657a8793dd011bf869695d72ad31c779c3cc1,2016-11-22T19:59Z 413,CWE-310,"CWE-310 int ASN1_verify ( i2d_of_void * i2d , X509_ALGOR * a , ASN1_BIT_STRING * signature , char * data , EVP_PKEY * pkey ) { EVP_MD_CTX ctx ; const EVP_MD * type ; unsigned char * p , * buf_in = NULL ; int ret = - 1 , i , inl ; EVP_MD_CTX_init ( & ctx ) ; i = OBJ_obj2nid ( a -> algorithm ) ; type = EVP_get_digestbyname ( OBJ_nid2sn ( i ) ) ; if ( type == NULL ) { ASN1err ( ASN1_F_ASN1_VERIFY , ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM ) ; goto err ; } inl = i2d ( data , NULL ) ; buf_in = OPENSSL_malloc ( ( unsigned int ) inl ) ; if ( buf_in == NULL ) { ASN1err ( ASN1_F_ASN1_VERIFY , ERR_R_MALLOC_FAILURE ) ; goto err ; } p = buf_in ; i2d ( data , & p ) ; ret = EVP_VerifyInit_ex ( & ctx , type , NULL ) && EVP_VerifyUpdate ( & ctx , ( unsigned char * ) buf_in , inl ) ; OPENSSL_cleanse ( buf_in , ( unsigned int ) inl ) ; OPENSSL_free ( buf_in ) ; if ( ! ret ) { ASN1err ( ASN1_F_ASN1_VERIFY , ERR_R_EVP_LIB ) ; goto err ; } ret = - 1 ; if ( EVP_VerifyFinal ( & ctx , ( unsigned char * ) signature -> data , ( unsigned int ) signature -> length , pkey ) <= 0 ) { ASN1err ( ASN1_F_ASN1_VERIFY , ERR_R_EVP_LIB ) ; ret = 0 ; goto err ; } ret = 1 ; err : EVP_MD_CTX_cleanup ( & ctx ) ; return ( ret ) ; } "," err ; } if ( signature -> type == V_ASN1_BIT_STRING && signature -> flags & 0x7 ) { ASN1err ( ASN1_F_ASN1_VERIFY , ASN1_R_INVALID_BIT_STRING_BITS_LEFT ) ; goto err ; } ",openssl@openssl/684400ce192dac51df3d3e92b61830a6ef90be3e,CVE-2014-8275,https://github.com/openssl/openssl/commit/684400ce192dac51df3d3e92b61830a6ef90be3e,2015-01-09T02:59Z 414,CWE-476,"CWE-476 key_ref_t keyring_search ( key_ref_t keyring , struct key_type * type , const char * description ) { 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 , . flags = KEYRING_SEARCH_DO_STATE_CHECK , } ; key_ref_t key ; int ret ; if ( ! ctx . match_data . cmp ) return ERR_PTR ( - ENOKEY ) ; if ( type -> match_preparse ) { ret = type -> match_preparse ( & ctx . match_data ) ; if ( ret < 0 ) return ERR_PTR ( ret ) ; } key = keyring_search_aux ( keyring , & ctx ) ; if ( type -> match_free ) type -> match_free ( & ctx . match_data ) ; return key ; } "," . cmp = key_default_cmp , . match_data ; int ret ; if ( ",torvalds@linux/c06cfb08b88dfbe13be44a69ae2fdc3a7c902d81,CVE-2017-2647,https://github.com/torvalds/linux/commit/c06cfb08b88dfbe13be44a69ae2fdc3a7c902d81,2017-03-31T04:59Z 415,CWE-119,"CWE-119 int ff_combine_frame ( ParseContext * pc , int next , const uint8_t * * buf , int * buf_size ) { if ( pc -> overread ) { av_dlog ( NULL , ""overread%d,state:%Xnext:%dindex:%do_index:%d\\n"" , pc -> overread , pc -> state , next , pc -> index , pc -> overread_index ) ; av_dlog ( NULL , ""%X%X%X%X\\n"" , ( * buf ) [ 0 ] , ( * buf ) [ 1 ] , ( * buf ) [ 2 ] , ( * buf ) [ 3 ] ) ; } for ( ; pc -> overread > 0 ; pc -> overread -- ) { pc -> buffer [ pc -> index ++ ] = pc -> buffer [ pc -> overread_index ++ ] ; } if ( ! * buf_size && next == END_NOT_FOUND ) { next = 0 ; } pc -> last_index = pc -> index ; if ( next == END_NOT_FOUND ) { void * new_buffer = av_fast_realloc ( pc -> buffer , & pc -> buffer_size , ( * buf_size ) + pc -> index + FF_INPUT_BUFFER_PADDING_SIZE ) ; if ( ! new_buffer ) return AVERROR ( ENOMEM ) ; pc -> buffer = new_buffer ; memcpy ( & pc -> buffer [ pc -> index ] , * buf , * buf_size ) ; pc -> index += * buf_size ; return - 1 ; } * buf_size = pc -> overread_index = pc -> index + next ; if ( pc -> index ) { void * new_buffer = av_fast_realloc ( pc -> buffer , & pc -> buffer_size , next + pc -> index + FF_INPUT_BUFFER_PADDING_SIZE ) ; if ( ! new_buffer ) return AVERROR ( ENOMEM ) ; pc -> buffer = new_buffer ; if ( next > - FF_INPUT_BUFFER_PADDING_SIZE ) memcpy ( & pc -> buffer [ pc -> index ] , * buf , next + FF_INPUT_BUFFER_PADDING_SIZE ) ; pc -> index = 0 ; * buf = pc -> buffer ; } for ( ; next < 0 ; next ++ ) { pc -> state = ( pc -> state << 8 ) | pc -> buffer [ pc -> last_index + next ] ; pc -> state64 = ( pc -> state64 << 8 ) | pc -> buffer [ pc -> last_index + next ] ; pc -> overread ++ ; } if ( pc -> overread ) { av_dlog ( NULL , ""overread%d,state:%Xnext:%dindex:%do_index:%d\\n"" , pc -> overread , pc -> state , next , pc -> index , pc -> overread_index ) ; av_dlog ( NULL , ""%X%X%X%X\\n"" , ( * buf ) [ 0 ] , ( * buf ) [ 1 ] , ( * buf ) [ 2 ] , ( * buf ) [ 3 ] ) ; } return 0 ; } "," ! new_buffer ) { pc -> index = 0 ; ENOMEM ) ; } ! new_buffer ) { pc -> overread_index = pc -> index = 0 ; ENOMEM ) ; } ",FFmpeg@FFmpeg/f31011e9abfb2ae75bb32bc44e2c34194c8dc40a,CVE-2013-7023,https://github.com/FFmpeg/FFmpeg/commit/f31011e9abfb2ae75bb32bc44e2c34194c8dc40a,2013-12-09T16:36Z 416,CWE-189,"CWE-189 static int fixup_bpf_calls ( struct bpf_verifier_env * env ) { struct bpf_prog * prog = env -> prog ; struct bpf_insn * insn = prog -> insnsi ; const struct bpf_func_proto * fn ; const int insn_cnt = prog -> len ; const struct bpf_map_ops * ops ; struct bpf_insn_aux_data * aux ; struct bpf_insn insn_buf [ 16 ] ; struct bpf_prog * new_prog ; struct bpf_map * map_ptr ; int i , cnt , delta = 0 ; for ( i = 0 ; i < insn_cnt ; i ++ , insn ++ ) { if ( insn -> code == ( BPF_ALU64 | BPF_MOD | BPF_X ) || insn -> code == ( BPF_ALU64 | BPF_DIV | BPF_X ) || insn -> code == ( BPF_ALU | BPF_MOD | BPF_X ) || insn -> code == ( BPF_ALU | BPF_DIV | BPF_X ) ) { bool is64 = BPF_CLASS ( insn -> code ) == BPF_ALU64 ; struct bpf_insn mask_and_div [ ] = { BPF_MOV32_REG ( insn -> src_reg , insn -> src_reg ) , BPF_JMP_IMM ( BPF_JNE , insn -> src_reg , 0 , 2 ) , BPF_ALU32_REG ( BPF_XOR , insn -> dst_reg , insn -> dst_reg ) , BPF_JMP_IMM ( BPF_JA , 0 , 0 , 1 ) , * insn , } ; struct bpf_insn mask_and_mod [ ] = { BPF_MOV32_REG ( insn -> src_reg , insn -> src_reg ) , BPF_JMP_IMM ( BPF_JEQ , insn -> src_reg , 0 , 1 ) , * insn , } ; struct bpf_insn * patchlet ; if ( insn -> code == ( BPF_ALU64 | BPF_DIV | BPF_X ) || insn -> code == ( BPF_ALU | BPF_DIV | BPF_X ) ) { patchlet = mask_and_div + ( is64 ? 1 : 0 ) ; cnt = ARRAY_SIZE ( mask_and_div ) - ( is64 ? 1 : 0 ) ; } else { patchlet = mask_and_mod + ( is64 ? 1 : 0 ) ; cnt = ARRAY_SIZE ( mask_and_mod ) - ( is64 ? 1 : 0 ) ; } new_prog = bpf_patch_insn_data ( env , i + delta , patchlet , cnt ) ; if ( ! new_prog ) return - ENOMEM ; delta += cnt - 1 ; env -> prog = prog = new_prog ; insn = new_prog -> insnsi + i + delta ; continue ; } if ( BPF_CLASS ( insn -> code ) == BPF_LD && ( BPF_MODE ( insn -> code ) == BPF_ABS || BPF_MODE ( insn -> code ) == BPF_IND ) ) { cnt = env -> ops -> gen_ld_abs ( insn , insn_buf ) ; if ( cnt == 0 || cnt >= ARRAY_SIZE ( insn_buf ) ) { verbose ( env , ""bpfverifierismisconfigured\\n"" ) ; return - EINVAL ; } new_prog = bpf_patch_insn_data ( env , i + delta , insn_buf , cnt ) ; if ( ! new_prog ) return - ENOMEM ; delta += cnt - 1 ; env -> prog = prog = new_prog ; insn = new_prog -> insnsi + i + delta ; continue ; } if ( insn -> code != ( BPF_JMP | BPF_CALL ) ) continue ; if ( insn -> src_reg == BPF_PSEUDO_CALL ) continue ; if ( insn -> imm == BPF_FUNC_get_route_realm ) prog -> dst_needed = 1 ; if ( insn -> imm == BPF_FUNC_get_prandom_u32 ) bpf_user_rnd_init_once ( ) ; if ( insn -> imm == BPF_FUNC_override_return ) prog -> kprobe_override = 1 ; if ( insn -> imm == BPF_FUNC_tail_call ) { prog -> cb_access = 1 ; env -> prog -> aux -> stack_depth = MAX_BPF_STACK ; env -> prog -> aux -> max_pkt_offset = MAX_PACKET_OFF ; insn -> imm = 0 ; insn -> code = BPF_JMP | BPF_TAIL_CALL ; aux = & env -> insn_aux_data [ i + delta ] ; if ( ! bpf_map_ptr_unpriv ( aux ) ) continue ; if ( bpf_map_ptr_poisoned ( aux ) ) { verbose ( env , ""tail_callabusingmap_ptr\\n"" ) ; return - EINVAL ; } map_ptr = BPF_MAP_PTR ( aux -> map_state ) ; insn_buf [ 0 ] = BPF_JMP_IMM ( BPF_JGE , BPF_REG_3 , map_ptr -> max_entries , 2 ) ; insn_buf [ 1 ] = BPF_ALU32_IMM ( BPF_AND , BPF_REG_3 , container_of ( map_ptr , struct bpf_array , map ) -> index_mask ) ; insn_buf [ 2 ] = * insn ; cnt = 3 ; new_prog = bpf_patch_insn_data ( env , i + delta , insn_buf , cnt ) ; if ( ! new_prog ) return - ENOMEM ; delta += cnt - 1 ; env -> prog = prog = new_prog ; insn = new_prog -> insnsi + i + delta ; continue ; } if ( prog -> jit_requested && BITS_PER_LONG == 64 && ( insn -> imm == BPF_FUNC_map_lookup_elem || insn -> imm == BPF_FUNC_map_update_elem || insn -> imm == BPF_FUNC_map_delete_elem || insn -> imm == BPF_FUNC_map_push_elem || insn -> imm == BPF_FUNC_map_pop_elem || insn -> imm == BPF_FUNC_map_peek_elem ) ) { aux = & env -> insn_aux_data [ i + delta ] ; if ( bpf_map_ptr_poisoned ( aux ) ) goto patch_call_imm ; map_ptr = BPF_MAP_PTR ( aux -> map_state ) ; ops = map_ptr -> ops ; if ( insn -> imm == BPF_FUNC_map_lookup_elem && ops -> map_gen_lookup ) { cnt = ops -> map_gen_lookup ( map_ptr , insn_buf ) ; if ( cnt == 0 || cnt >= ARRAY_SIZE ( insn_buf ) ) { verbose ( env , ""bpfverifierismisconfigured\\n"" ) ; return - EINVAL ; } new_prog = bpf_patch_insn_data ( env , i + delta , insn_buf , cnt ) ; if ( ! new_prog ) return - ENOMEM ; delta += cnt - 1 ; env -> prog = prog = new_prog ; insn = new_prog -> insnsi + i + delta ; continue ; } BUILD_BUG_ON ( ! __same_type ( ops -> map_lookup_elem , ( void * ( * ) ( struct bpf_map * map , void * key ) ) NULL ) ) ; BUILD_BUG_ON ( ! __same_type ( ops -> map_delete_elem , ( int ( * ) ( struct bpf_map * map , void * key ) ) NULL ) ) ; BUILD_BUG_ON ( ! __same_type ( ops -> map_update_elem , ( int ( * ) ( struct bpf_map * map , void * key , void * value , u64 flags ) ) NULL ) ) ; BUILD_BUG_ON ( ! __same_type ( ops -> map_push_elem , ( int ( * ) ( struct bpf_map * map , void * value , u64 flags ) ) NULL ) ) ; BUILD_BUG_ON ( ! __same_type ( ops -> map_pop_elem , ( int ( * ) ( struct bpf_map * map , void * value ) ) NULL ) ) ; BUILD_BUG_ON ( ! __same_type ( ops -> map_peek_elem , ( int ( * ) ( struct bpf_map * map , void * value ) ) NULL ) ) ; switch ( insn -> imm ) { case BPF_FUNC_map_lookup_elem : insn -> imm = BPF_CAST_CALL ( ops -> map_lookup_elem ) - __bpf_call_base ; continue ; case BPF_FUNC_map_update_elem : insn -> imm = BPF_CAST_CALL ( ops -> map_update_elem ) - __bpf_call_base ; continue ; case BPF_FUNC_map_delete_elem : insn -> imm = BPF_CAST_CALL ( ops -> map_delete_elem ) - __bpf_call_base ; continue ; case BPF_FUNC_map_push_elem : insn -> imm = BPF_CAST_CALL ( ops -> map_push_elem ) - __bpf_call_base ; continue ; case BPF_FUNC_map_pop_elem : insn -> imm = BPF_CAST_CALL ( ops -> map_pop_elem ) - __bpf_call_base ; continue ; case BPF_FUNC_map_peek_elem : insn -> imm = BPF_CAST_CALL ( ops -> map_peek_elem ) - __bpf_call_base ; continue ; } goto patch_call_imm ; } patch_call_imm : fn = env -> ops -> get_func_proto ( insn -> imm , env -> prog ) ; if ( ! fn -> func ) { verbose ( env , ""kernelsubsystemmisconfiguredfunc%s#%d\\n"" , func_id_name ( insn -> imm ) , insn -> imm ) ; return - EFAULT ; } insn -> imm = fn -> func - __bpf_call_base ; } return 0 ; } "," insn -> code == ( BPF_ALU64 | BPF_ADD | BPF_X ) || insn -> code == ( BPF_ALU64 | BPF_SUB | BPF_X ) ) { const u8 code_add = BPF_ALU64 | BPF_ADD | BPF_X ; const u8 code_sub = BPF_ALU64 | BPF_SUB | BPF_X ; struct bpf_insn insn_buf [ 16 ] ; struct bpf_insn * patch = & insn_buf [ 0 ] ; bool issrc , isneg ; u32 off_reg ; aux = if ( ! aux -> alu_state ) continue ; ) continue ; isneg = aux -> alu_state & BPF_ALU_NEG_VALUE ; issrc = ( aux -> alu_state & BPF_ALU_SANITIZE ) == BPF_ALU_SANITIZE_SRC ; off_reg = issrc ? insn -> src_reg : insn -> dst_reg ; if ( isneg ) * patch ++ = BPF_ALU64_IMM ( BPF_MUL , off_reg , - 1 ) ; * patch ++ = BPF_MOV32_IMM ( BPF_REG_AX , aux -> alu_limit - 1 ) ; * patch ++ = BPF_ALU64_REG ( BPF_SUB , BPF_REG_AX , off_reg ) ; * patch ++ = BPF_ALU64_REG ( BPF_OR , BPF_REG_AX , off_reg ) ; * patch ++ = BPF_ALU64_IMM ( BPF_NEG , BPF_REG_AX , 0 ) ; * patch ++ = BPF_ALU64_IMM ( BPF_ARSH , BPF_REG_AX , 63 ) ; if ( issrc ) { * patch ++ = BPF_ALU64_REG ( BPF_AND , BPF_REG_AX , off_reg ) ; insn -> src_reg = BPF_REG_AX ; } else { * patch ++ = BPF_ALU64_REG ( BPF_AND , off_reg , BPF_REG_AX ) ; } if ( isneg ) insn -> code = insn -> code == code_add ? code_sub : code_add ; * patch ++ = * insn ; if ( issrc && isneg ) * patch ++ = BPF_ALU64_IMM ( BPF_MUL , off_reg , - 1 ) ; cnt = patch - insn_buf ; new_prog = } if ( insn -> code != ( BPF_JMP | BPF_CALL ) ) continue ; if ( insn -> src_reg == BPF_PSEUDO_CALL ) continue ; if ( insn -> imm == BPF_FUNC_get_route_realm ) prog -> dst_needed = 1 ; if ( insn -> imm == BPF_FUNC_get_prandom_u32 ) bpf_user_rnd_init_once ( ) ; if ( insn -> imm == BPF_FUNC_override_return ) prog -> kprobe_override = 1 ; if ( insn -> imm == BPF_FUNC_tail_call ) { prog -> cb_access = 1 ; env -> prog -> aux -> stack_depth = MAX_BPF_STACK ; env -> prog -> aux -> max_pkt_offset = MAX_PACKET_OFF ; insn -> imm = 0 ; insn -> code = BPF_JMP | BPF_TAIL_CALL ; aux = & ; if ( ! bpf_map_ptr_unpriv ( aux ) ) continue ; if ( aux ) ) { verbose ( env , ""tail_callabusingmap_ptr\\n"" ) ; return - EINVAL ; } map_ptr = BPF_MAP_PTR map_state ) ; insn_buf [ 0 ] = BPF_JMP_IMM ( BPF_JGE , BPF_REG_3 , map_ptr -> max_entries , 2 ) ; insn_buf [ 1 ] = BPF_ALU32_IMM ( BPF_AND , BPF_REG_3 , container_of ( map_ptr , ( map_ptr , struct bpf_array , map ) -> index_mask ) ; insn_buf [ 2 ] = * insn ; cnt = 3 ; new_prog = bpf_patch_insn_data continue ; } if ( prog -> jit_requested && BITS_PER_LONG == 64 && ( insn -> imm == BPF_FUNC_map_lookup_elem || insn -> imm == BPF_FUNC_map_update_elem || insn -> imm == BPF_FUNC_map_delete_elem || insn -> imm == BPF_FUNC_map_push_elem || insn -> imm == BPF_FUNC_map_pop_elem || insn -> imm == BPF_FUNC_map_peek_elem ) ) { aux = & env -> insn_aux_data [ i + delta ] ; if ( bpf_map_ptr_poisoned ( aux ) ) goto patch_call_imm ; map_ptr = BPF_MAP_PTR ( aux -> map_state ) ; ops = map_ptr -> ops ; if ( insn -> imm == BPF_FUNC_map_lookup_elem && ops -> map_gen_lookup ) { cnt = ops -> map_gen_lookup ( map_ptr , insn_buf ) ; if ( cnt == 0 || cnt >= ARRAY_SIZE ( insn_buf ) ) { verbose ( env , ""bpfverifierismisconfigured\\n"" ) ; return - EINVAL ; } new_prog = bpf_patch_insn_data ( env , i + delta , insn_buf , cnt ) ; if ( ! new_prog ) return - ENOMEM ; delta += cnt - 1 ; env -> prog = prog = new_prog ; insn = new_prog -> insnsi + i + delta ; continue ; } ",torvalds@linux/979d63d50c0c0f7bc537bf821e056cc9fe5abd38,CVE-2019-7308,https://github.com/torvalds/linux/commit/979d63d50c0c0f7bc537bf821e056cc9fe5abd38,2019-02-01T22:29Z 417,CWE-665,"CWE-665 void rfbSendServerCutText ( rfbScreenInfoPtr rfbScreen , char * str , int len ) { rfbClientPtr cl ; rfbServerCutTextMsg sct ; rfbClientIteratorPtr iterator ; iterator = rfbGetClientIterator ( rfbScreen ) ; while ( ( cl = rfbClientIteratorNext ( iterator ) ) != NULL ) { sct . type = rfbServerCutText ; sct . length = Swap32IfLE ( len ) ; LOCK ( cl -> sendMutex ) ; if ( rfbWriteExact ( cl , ( char * ) & sct , sz_rfbServerCutTextMsg ) < 0 ) { rfbLogPerror ( ""rfbSendServerCutText:write"" ) ; rfbCloseClient ( cl ) ; UNLOCK ( cl -> sendMutex ) ; continue ; } if ( rfbWriteExact ( cl , str , len ) < 0 ) { rfbLogPerror ( ""rfbSendServerCutText:write"" ) ; rfbCloseClient ( cl ) ; } UNLOCK ( cl -> sendMutex ) ; rfbStatRecordMessageSent ( cl , rfbServerCutText , sz_rfbServerCutTextMsg + len , sz_rfbServerCutTextMsg + len ) ; } rfbReleaseClientIterator ( iterator ) ; } "," rfbClientIteratorPtr iterator ; memset ( ( char * ) & sct , 0 , sizeof ( sct ) ) ; ",LibVNC@libvncserver/d01e1bb4246323ba6fcee3b82ef1faa9b1dac82a,CVE-2019-15681,https://github.com/LibVNC/libvncserver/commit/d01e1bb4246323ba6fcee3b82ef1faa9b1dac82a,2019-10-29T19:15Z 418,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 419,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 420,CWE-125,"CWE-125 BOOL rdp_read_share_control_header ( wStream * s , UINT16 * length , UINT16 * type , UINT16 * channel_id ) { if ( Stream_GetRemainingLength ( s ) < 2 ) return FALSE ; Stream_Read_UINT16 ( s , * length ) ; if ( * length == 0x8000 ) { rdp_read_flow_control_pdu ( s , type ) ; * channel_id = 0 ; * length = 8 ; return TRUE ; } if ( ( ( size_t ) * length - 2 ) > Stream_GetRemainingLength ( s ) ) return FALSE ; Stream_Read_UINT16 ( s , * type ) ; * type &= 0x0F ; if ( * length > 4 ) Stream_Read_UINT16 ( s , * channel_id ) ; else * channel_id = 0 ; return TRUE ; } "," channel_id ) { UINT16 len ; ( s , len ) ; * length = len ; if ( ; if ( len == 0x8000 ) 0x8000 ) { if ( ! , type ) ) return FALSE if ( ( len < 4 ) || ( ( len - 2 ) Stream_GetRemainingLength ( s ) ; if ( len > 4 ) ",FreeRDP@FreeRDP/9301bfe730c66180263248b74353daa99f5a969b,CVE-2020-11048,https://github.com/FreeRDP/FreeRDP/commit/9301bfe730c66180263248b74353daa99f5a969b,2020-05-07T20:15Z 421,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 422,CWE-284,"CWE-284 static int tap_if_up ( const char * devname , const bt_bdaddr_t * addr ) { struct ifreq ifr ; int sk , err ; sk = socket ( AF_INET , SOCK_DGRAM , 0 ) ; if ( sk < 0 ) return - 1 ; memset ( & ifr , 0 , sizeof ( ifr ) ) ; strncpy ( ifr . ifr_name , devname , IFNAMSIZ - 1 ) ; err = ioctl ( sk , SIOCGIFHWADDR , & ifr ) ; if ( err < 0 ) { BTIF_TRACE_ERROR ( ""Couldnotgetnetworkhardwareforinterface:%s,errno:%s"" , devname , strerror ( errno ) ) ; close ( sk ) ; return - 1 ; } strncpy ( ifr . ifr_name , devname , IFNAMSIZ - 1 ) ; memcpy ( ifr . ifr_hwaddr . sa_data , addr -> address , 6 ) ; if ( ifr . ifr_hwaddr . sa_data [ 0 ] & 0x01 ) { BTIF_TRACE_WARNING ( ""NotaunicastMACaddress,forcemulticastbitflipping"" ) ; ifr . ifr_hwaddr . sa_data [ 0 ] &= ~ 0x01 ; } err = ioctl ( sk , SIOCSIFHWADDR , ( caddr_t ) & ifr ) ; if ( err < 0 ) { BTIF_TRACE_ERROR ( ""Couldnotsetbtaddressforinterface:%s,errno:%s"" , devname , strerror ( errno ) ) ; close ( sk ) ; return - 1 ; } memset ( & ifr , 0 , sizeof ( ifr ) ) ; strncpy ( ifr . ifr_name , devname , IF_NAMESIZE - 1 ) ; ifr . ifr_flags |= IFF_UP ; ifr . ifr_flags |= IFF_MULTICAST ; err = ioctl ( sk , SIOCSIFFLAGS , ( caddr_t ) & ifr ) ; if ( err < 0 ) { BTIF_TRACE_ERROR ( ""Couldnotbringupnetworkinterface:%s,errno:%d"" , devname , errno ) ; close ( sk ) ; return - 1 ; } close ( sk ) ; BTIF_TRACE_DEBUG ( ""networkinterface:%sisup"" , devname ) ; return 0 ; } "," ; err = TEMP_FAILURE_RETRY ( , & ifr ) } err = TEMP_FAILURE_RETRY ( ) & ifr ) ; err = TEMP_FAILURE_RETRY ( & ifr ) ) ",system@bt/472271b153c5dc53c28beac55480a8d8434b2d5c,CVE-2016-3839,https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c,2016-08-05T20:59Z 423,CWE-119,"CWE-119 int get_down2_steps ( int in_length , int out_length ) { int steps = 0 ; int proj_in_length ; while ( ( proj_in_length = get_down2_length ( in_length , 1 ) ) >= out_length ) { ++ steps ; in_length = proj_in_length ; } return steps ; } "," static ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 424,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 425,CWE-125,"CWE-125 static void parse_hid_report_descriptor ( struct gtco * device , char * report , int length ) { struct device * ddev = & device -> intf -> dev ; int x , i = 0 ; __u8 prefix ; __u8 size ; __u8 tag ; __u8 type ; __u8 data = 0 ; __u16 data16 = 0 ; __u32 data32 = 0 ; int inputnum = 0 ; __u32 usage = 0 ; __u32 globalval [ TAG_GLOB_MAX ] ; __u32 oldval [ TAG_GLOB_MAX ] ; char maintype = 'x' ; char globtype [ 12 ] ; int indent = 0 ; char indentstr [ 10 ] = """" ; dev_dbg ( ddev , ""======>>>>>>PARSE<<<<<<======\\n"" ) ; while ( i < length ) { prefix = report [ i ] ; i ++ ; size = PREF_SIZE ( prefix ) ; switch ( size ) { case 1 : data = report [ i ] ; break ; case 2 : data16 = get_unaligned_le16 ( & report [ i ] ) ; break ; case 3 : size = 4 ; data32 = get_unaligned_le32 ( & report [ i ] ) ; break ; } i += size ; tag = PREF_TAG ( prefix ) ; type = PREF_TYPE ( prefix ) ; switch ( type ) { case TYPE_MAIN : strcpy ( globtype , """" ) ; switch ( tag ) { case TAG_MAIN_INPUT : maintype = 'I' ; if ( data == 2 ) strcpy ( globtype , ""Variable"" ) ; else if ( data == 3 ) strcpy ( globtype , ""Var|Const"" ) ; dev_dbg ( ddev , "":::::SavingReport:%dinput#%dMax:0x%X(%d)Min:0x%X(%d)of%dbits\\n"" , globalval [ TAG_GLOB_REPORT_ID ] , inputnum , globalval [ TAG_GLOB_LOG_MAX ] , globalval [ TAG_GLOB_LOG_MAX ] , globalval [ TAG_GLOB_LOG_MIN ] , globalval [ TAG_GLOB_LOG_MIN ] , globalval [ TAG_GLOB_REPORT_SZ ] * globalval [ TAG_GLOB_REPORT_CNT ] ) ; switch ( inputnum ) { case 0 : dev_dbg ( ddev , ""GER:XUsage:0x%x\\n"" , usage ) ; if ( device -> max_X == 0 ) { device -> max_X = globalval [ TAG_GLOB_LOG_MAX ] ; device -> min_X = globalval [ TAG_GLOB_LOG_MIN ] ; } break ; case 1 : dev_dbg ( ddev , ""GER:YUsage:0x%x\\n"" , usage ) ; if ( device -> max_Y == 0 ) { device -> max_Y = globalval [ TAG_GLOB_LOG_MAX ] ; device -> min_Y = globalval [ TAG_GLOB_LOG_MIN ] ; } break ; default : if ( usage == DIGITIZER_USAGE_TILT_X ) { if ( device -> maxtilt_X == 0 ) { device -> maxtilt_X = globalval [ TAG_GLOB_LOG_MAX ] ; device -> mintilt_X = globalval [ TAG_GLOB_LOG_MIN ] ; } } if ( usage == DIGITIZER_USAGE_TILT_Y ) { if ( device -> maxtilt_Y == 0 ) { device -> maxtilt_Y = globalval [ TAG_GLOB_LOG_MAX ] ; device -> mintilt_Y = globalval [ TAG_GLOB_LOG_MIN ] ; } } if ( usage == DIGITIZER_USAGE_TIP_PRESSURE ) { if ( device -> maxpressure == 0 ) { device -> maxpressure = globalval [ TAG_GLOB_LOG_MAX ] ; device -> minpressure = globalval [ TAG_GLOB_LOG_MIN ] ; } } break ; } inputnum ++ ; break ; case TAG_MAIN_OUTPUT : maintype = 'O' ; break ; case TAG_MAIN_FEATURE : maintype = 'F' ; break ; case TAG_MAIN_COL_START : maintype = 'S' ; if ( data == 0 ) { dev_dbg ( ddev , ""======>>>>>>Physical\\n"" ) ; strcpy ( globtype , ""Physical"" ) ; } else dev_dbg ( ddev , ""======>>>>>>\\n"" ) ; indent ++ ; for ( x = 0 ; x < indent ; x ++ ) indentstr [ x ] = '-' ; indentstr [ x ] = 0 ; for ( x = 0 ; x < TAG_GLOB_MAX ; x ++ ) oldval [ x ] = globalval [ x ] ; break ; case TAG_MAIN_COL_END : dev_dbg ( ddev , ""<<<<<<======\\n"" ) ; maintype = 'E' ; indent -- ; for ( x = 0 ; x < indent ; x ++ ) indentstr [ x ] = '-' ; indentstr [ x ] = 0 ; for ( x = 0 ; x < TAG_GLOB_MAX ; x ++ ) globalval [ x ] = oldval [ x ] ; break ; } switch ( size ) { case 1 : dev_dbg ( ddev , ""%sMAINTAG:(%d)%cSIZE:%dData:%s0x%x\\n"" , indentstr , tag , maintype , size , globtype , data ) ; break ; case 2 : dev_dbg ( ddev , ""%sMAINTAG:(%d)%cSIZE:%dData:%s0x%x\\n"" , indentstr , tag , maintype , size , globtype , data16 ) ; break ; case 4 : dev_dbg ( ddev , ""%sMAINTAG:(%d)%cSIZE:%dData:%s0x%x\\n"" , indentstr , tag , maintype , size , globtype , data32 ) ; break ; } break ; case TYPE_GLOBAL : switch ( tag ) { case TAG_GLOB_USAGE : if ( device -> usage == 0 ) device -> usage = data ; strcpy ( globtype , ""USAGE"" ) ; break ; case TAG_GLOB_LOG_MIN : strcpy ( globtype , ""LOG_MIN"" ) ; break ; case TAG_GLOB_LOG_MAX : strcpy ( globtype , ""LOG_MAX"" ) ; break ; case TAG_GLOB_PHYS_MIN : strcpy ( globtype , ""PHYS_MIN"" ) ; break ; case TAG_GLOB_PHYS_MAX : strcpy ( globtype , ""PHYS_MAX"" ) ; break ; case TAG_GLOB_UNIT_EXP : strcpy ( globtype , ""EXP"" ) ; break ; case TAG_GLOB_UNIT : strcpy ( globtype , ""UNIT"" ) ; break ; case TAG_GLOB_REPORT_SZ : strcpy ( globtype , ""REPORT_SZ"" ) ; break ; case TAG_GLOB_REPORT_ID : strcpy ( globtype , ""REPORT_ID"" ) ; inputnum = 0 ; break ; case TAG_GLOB_REPORT_CNT : strcpy ( globtype , ""REPORT_CNT"" ) ; break ; case TAG_GLOB_PUSH : strcpy ( globtype , ""PUSH"" ) ; break ; case TAG_GLOB_POP : strcpy ( globtype , ""POP"" ) ; break ; } if ( tag < TAG_GLOB_MAX ) { switch ( size ) { case 1 : dev_dbg ( ddev , ""%sGLOBALTAG:%s(%d)SIZE:%dData:0x%x\\n"" , indentstr , globtype , tag , size , data ) ; globalval [ tag ] = data ; break ; case 2 : dev_dbg ( ddev , ""%sGLOBALTAG:%s(%d)SIZE:%dData:0x%x\\n"" , indentstr , globtype , tag , size , data16 ) ; globalval [ tag ] = data16 ; break ; case 4 : dev_dbg ( ddev , ""%sGLOBALTAG:%s(%d)SIZE:%dData:0x%x\\n"" , indentstr , globtype , tag , size , data32 ) ; globalval [ tag ] = data32 ; break ; } } else { dev_dbg ( ddev , ""%sGLOBALTAG:ILLEGALTAG:%dSIZE:%d\\n"" , indentstr , tag , size ) ; } break ; case TYPE_LOCAL : switch ( tag ) { case TAG_GLOB_USAGE : strcpy ( globtype , ""USAGE"" ) ; usage = data ; break ; case TAG_GLOB_LOG_MIN : strcpy ( globtype , ""MIN"" ) ; break ; case TAG_GLOB_LOG_MAX : strcpy ( globtype , ""MAX"" ) ; break ; default : strcpy ( globtype , ""UNKNOWN"" ) ; break ; } switch ( size ) { case 1 : dev_dbg ( ddev , ""%sLOCALTAG:(%d)%sSIZE:%dData:0x%x\\n"" , indentstr , tag , globtype , size , data ) ; break ; case 2 : dev_dbg ( ddev , ""%sLOCALTAG:(%d)%sSIZE:%dData:0x%x\\n"" , indentstr , tag , globtype , size , data16 ) ; break ; case 4 : dev_dbg ( ddev , ""%sLOCALTAG:(%d)%sSIZE:%dData:0x%x\\n"" , indentstr , tag , globtype , size , data32 ) ; break ; } break ; } } } "," report [ i ++ ] ; size = ( 1U << PREF_SIZE ( prefix ) ) >> 1 ; if ( i + size > length ) { dev_err ( ddev , ""Notenoughdata(need%d,have%d)\\n"" , i + size , length ) ; break ; } switch ( size break ; case 4 : data32 = get_unaligned_le32 ",torvalds@linux/a50829479f58416a013a4ccca791336af3c584c7,CVE-2017-16643,https://github.com/torvalds/linux/commit/a50829479f58416a013a4ccca791336af3c584c7,2017-11-07T23:29Z 426,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 427,CWE-125,"CWE-125 node * PyParser_ParseStringObject ( const char * s , PyObject * filename , grammar * g , int start , perrdetail * err_ret , int * flags ) { struct tok_state * tok ; int exec_input = start == file_input ; if ( initerr ( err_ret , filename ) < 0 ) return NULL ; if ( * flags & PyPARSE_IGNORE_COOKIE ) tok = PyTokenizer_FromUTF8 ( s , exec_input ) ; else tok = PyTokenizer_FromString ( s , exec_input ) ; if ( tok == NULL ) { err_ret -> error = PyErr_Occurred ( ) ? E_DECODE : E_NOMEM ; return NULL ; } # ifndef PGEN Py_INCREF ( err_ret -> filename ) ; tok -> filename = err_ret -> filename ; # endif return parsetok ( tok , g , start , err_ret , flags ) ; } "," NULL ; } if ( * flags & PyPARSE_TYPE_COMMENTS ) { tok -> type_comments = 1 ; } ",python@typed_ast/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,CVE-2019-19275,https://github.com/python/typed_ast/commit/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,2019-11-26T15:15Z 428,CWE-119,"CWE-119 static void set_segment_id ( VP9_COMMON * cm , BLOCK_SIZE bsize , int mi_row , int mi_col , int segment_id ) { const int mi_offset = mi_row * cm -> mi_cols + mi_col ; const int bw = num_8x8_blocks_wide_lookup [ bsize ] ; const int bh = num_8x8_blocks_high_lookup [ bsize ] ; const int xmis = MIN ( cm -> mi_cols - mi_col , bw ) ; const int ymis = MIN ( cm -> mi_rows - mi_row , bh ) ; int x , y ; assert ( segment_id >= 0 && segment_id < MAX_SEGMENTS ) ; for ( y = 0 ; y < ymis ; y ++ ) for ( x = 0 ; x < xmis ; x ++ ) cm -> last_frame_seg_map [ mi_offset + y * cm -> mi_cols + x ] = segment_id ; } "," * cm , int mi_offset , int x_mis , int y_mis , int segment_id segment_id ) { int x , ; y < y_mis ; y ++ ; x < x_mis ; x ++ ) cm -> current_frame_seg_map [ mi_offset + ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 429,CWE-20,"CWE-20 int key_reject_and_link ( struct key * key , unsigned timeout , unsigned error , struct key * keyring , struct key * authkey ) { struct assoc_array_edit * edit ; struct timespec now ; int ret , awaken , link_ret = 0 ; key_check ( key ) ; key_check ( keyring ) ; awaken = 0 ; ret = - EBUSY ; if ( keyring ) { if ( keyring -> restrict_link ) return - EPERM ; link_ret = __key_link_begin ( keyring , & key -> index_key , & edit ) ; } mutex_lock ( & key_construction_mutex ) ; if ( ! test_bit ( KEY_FLAG_INSTANTIATED , & key -> flags ) ) { atomic_inc ( & key -> user -> nikeys ) ; key -> reject_error = - error ; smp_wmb ( ) ; set_bit ( KEY_FLAG_NEGATIVE , & key -> flags ) ; set_bit ( KEY_FLAG_INSTANTIATED , & key -> flags ) ; now = current_kernel_time ( ) ; key -> expiry = now . tv_sec + timeout ; key_schedule_gc ( key -> expiry + key_gc_delay ) ; if ( test_and_clear_bit ( KEY_FLAG_USER_CONSTRUCT , & key -> flags ) ) awaken = 1 ; ret = 0 ; if ( keyring && link_ret == 0 ) __key_link ( key , & edit ) ; if ( authkey ) key_revoke ( authkey ) ; } mutex_unlock ( & key_construction_mutex ) ; if ( keyring && link_ret == 0 ) __key_link_end ( keyring , & key -> index_key , edit ) ; if ( awaken ) wake_up_bit ( & key -> flags , KEY_FLAG_USER_CONSTRUCT ) ; return ret == 0 ? link_ret : ret ; } "," ; if ( key -> state == KEY_IS_UNINSTANTIATED ) { atomic_inc nikeys ) ; mark_key_instantiated ( key , - error ) ; now ",torvalds@linux/363b02dab09b3226f3bd1420dad9c72b79a42a76,CVE-2017-15951,https://github.com/torvalds/linux/commit/363b02dab09b3226f3bd1420dad9c72b79a42a76,2017-10-28T02:29Z 430,CWE-399,"CWE-399 int cdf_unpack_summary_info ( const cdf_stream_t * sst , const cdf_header_t * h , cdf_summary_info_header_t * ssi , cdf_property_info_t * * info , size_t * count ) { size_t i , maxcount ; const cdf_summary_info_header_t * si = CAST ( const cdf_summary_info_header_t * , sst -> sst_tab ) ; const cdf_section_declaration_t * sd = CAST ( const cdf_section_declaration_t * , ( const void * ) ( ( const char * ) sst -> sst_tab + CDF_SECTION_DECLARATION_OFFSET ) ) ; if ( cdf_check_stream_offset ( sst , h , si , sizeof ( * si ) , __LINE__ ) == - 1 || cdf_check_stream_offset ( sst , h , sd , sizeof ( * sd ) , __LINE__ ) == - 1 ) return - 1 ; ssi -> si_byte_order = CDF_TOLE2 ( si -> si_byte_order ) ; ssi -> si_os_version = CDF_TOLE2 ( si -> si_os_version ) ; ssi -> si_os = CDF_TOLE2 ( si -> si_os ) ; ssi -> si_class = si -> si_class ; cdf_swap_class ( & ssi -> si_class ) ; ssi -> si_count = CDF_TOLE2 ( si -> si_count ) ; * count = 0 ; maxcount = 0 ; * info = NULL ; for ( i = 0 ; i < CDF_TOLE4 ( si -> si_count ) ; i ++ ) { if ( i >= CDF_LOOP_LIMIT ) { DPRINTF ( ( ""Unpacksummaryinfolooplimit"" ) ) ; errno = EFTYPE ; return - 1 ; } if ( cdf_read_property_info ( sst , h , CDF_TOLE4 ( sd -> sd_offset ) , info , count , & maxcount ) == - 1 ) { return - 1 ; } } return 0 ; } "," ) { size_t maxcount ; const -> si_count = CDF_TOLE4 ( si -> = NULL ; if ( cdf_read_property_info ( sst , h , CDF_TOLE4 ( sd -> sd_offset - 1 ) return - 1 - 1 ; return 0 ; ",file@file/b8acc83781d5a24cc5101e525d15efe0482c280d,CVE-2014-0237,https://github.com/file/file/commit/b8acc83781d5a24cc5101e525d15efe0482c280d,2014-06-01T04:29Z 431,CWE-119,"CWE-119 static inline void header_put_byte ( SF_PRIVATE * psf , char x ) { if ( psf -> headindex < SIGNED_SIZEOF ( psf -> header ) - 1 ) psf -> header [ psf -> headindex ++ ] = x ; } "," x ) { psf -> header psf -> header . ptr [ psf -> header psf -> header . indx ++ ] = ",erikd@libsndfile/708e996c87c5fae77b104ccfeb8f6db784c32074,CVE-2017-7586,https://github.com/erikd/libsndfile/commit/708e996c87c5fae77b104ccfeb8f6db784c32074,2017-04-07T20:59Z 432,CWE-119,"CWE-119 static char * cJSON_strdup ( const char * str ) { size_t len ; char * copy ; len = strlen ( str ) + 1 ; if ( ! ( copy = ( char * ) cJSON_malloc ( len ) ) ) return 0 ; memcpy ( copy , str , len ) ; return copy ; } "," ",esnet@iperf/91f2fa59e8ed80dfbf400add0164ee0e508e412a,CVE-2016-4303,https://github.com/esnet/iperf/commit/91f2fa59e8ed80dfbf400add0164ee0e508e412a,2016-09-26T14:59Z 433,CWE-119,"CWE-119 static int calc_partial_ssl_err ( YV12_BUFFER_CONFIG * source , YV12_BUFFER_CONFIG * dest ) { int i , j ; int Total = 0 ; int srcoffset , dstoffset ; unsigned char * src = source -> y_buffer ; unsigned char * dst = dest -> y_buffer ; int linestocopy ; linestocopy = ( source -> y_height >> 4 ) / PARTIAL_FRAME_FRACTION ; linestocopy = linestocopy ? linestocopy << 4 : 16 ; srcoffset = source -> y_stride * ( ( dest -> y_height >> 5 ) * 16 ) ; dstoffset = dest -> y_stride * ( ( dest -> y_height >> 5 ) * 16 ) ; src += srcoffset ; dst += dstoffset ; for ( i = 0 ; i < linestocopy ; i += 16 ) { for ( j = 0 ; j < source -> y_width ; j += 16 ) { unsigned int sse ; Total += vp8_mse16x16 ( src + j , source -> y_stride , dst + j , dest -> y_stride , & sse ) ; } src += 16 * source -> y_stride ; dst += 16 * dest -> y_stride ; } return Total ; } "," ; Total += vpx_mse16x16 ( src + ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 434,CWE-000,"CWE-000 int nfs4_do_close ( struct path * path , struct nfs4_state * state , int wait ) { struct nfs_server * server = NFS_SERVER ( state -> inode ) ; struct nfs4_closedata * calldata ; struct nfs4_state_owner * sp = state -> owner ; struct rpc_task * task ; struct rpc_message msg = { . rpc_proc = & nfs4_procedures [ NFSPROC4_CLNT_CLOSE ] , . rpc_cred = state -> owner -> so_cred , } ; struct rpc_task_setup task_setup_data = { . rpc_client = server -> client , . rpc_message = & msg , . callback_ops = & nfs4_close_ops , . workqueue = nfsiod_workqueue , . flags = RPC_TASK_ASYNC , } ; int status = - ENOMEM ; calldata = kmalloc ( sizeof ( * calldata ) , GFP_KERNEL ) ; if ( calldata == NULL ) goto out ; calldata -> inode = state -> inode ; calldata -> state = state ; calldata -> arg . fh = NFS_FH ( state -> inode ) ; calldata -> arg . stateid = & state -> open_stateid ; calldata -> arg . seqid = nfs_alloc_seqid ( & state -> owner -> so_seqid ) ; if ( calldata -> arg . seqid == NULL ) goto out_free_calldata ; calldata -> arg . open_flags = 0 ; calldata -> arg . bitmask = server -> attr_bitmask ; calldata -> res . fattr = & calldata -> fattr ; calldata -> res . seqid = calldata -> arg . seqid ; calldata -> res . server = server ; calldata -> path . mnt = mntget ( path -> mnt ) ; calldata -> path . dentry = dget ( path -> dentry ) ; msg . rpc_argp = & calldata -> arg , msg . rpc_resp = & calldata -> res , task_setup_data . callback_data = calldata ; task = rpc_run_task ( & task_setup_data ) ; if ( IS_ERR ( task ) ) return PTR_ERR ( task ) ; status = 0 ; if ( wait ) status = rpc_wait_for_completion_task ( task ) ; rpc_put_task ( task ) ; return status ; out_free_calldata : kfree ( calldata ) ; out : nfs4_put_open_state ( state ) ; nfs4_put_state_owner ( sp ) ; return status ; } "," -> arg . fmode = 0 ; ",torvalds@linux/dc0b027dfadfcb8a5504f7d8052754bf8d501ab9,CVE-2011-4324,https://github.com/torvalds/linux/commit/dc0b027dfadfcb8a5504f7d8052754bf8d501ab9,2012-06-21T23:55Z 435,CWE-000,"CWE-000 int flush_completed_IO ( struct inode * inode ) { ext4_io_end_t * io ; int ret = 0 ; int ret2 = 0 ; if ( list_empty ( & EXT4_I ( inode ) -> i_completed_io_list ) ) return ret ; dump_completed_IO ( inode ) ; while ( ! list_empty ( & EXT4_I ( inode ) -> i_completed_io_list ) ) { io = list_entry ( EXT4_I ( inode ) -> i_completed_io_list . next , ext4_io_end_t , list ) ; ret = ext4_end_io_nolock ( io ) ; if ( ret < 0 ) ret2 = ret ; else list_del_init ( & io -> list ) ; } return ( ret2 < 0 ) ? ret2 : 0 ; } "," ext4_io_end_t * io ; struct ext4_inode_info * ei = EXT4_I ( inode ) ; unsigned long flags list_empty ( & ei -> i_completed_io_list ) inode ) ; spin_lock_irqsave ( & ei -> i_completed_io_lock , flags ) ; list_empty ( & ei -> i_completed_io_list ) = list_entry ( ei -> i_completed_io_list . list ) ; spin_unlock_irqrestore ( & ei -> i_completed_io_lock , flags ) ; ext4_end_io_nolock ( io ) ; spin_lock_irqsave ( & ei -> i_completed_io_lock , flags ) ; } spin_unlock_irqrestore ( & ei -> i_completed_io_lock , flags ) ; ",torvalds@linux/744692dc059845b2a3022119871846e74d4f6e11,CVE-2015-8324,https://github.com/torvalds/linux/commit/744692dc059845b2a3022119871846e74d4f6e11,2016-05-02T10:59Z 436,CWE-400,"CWE-400 int __usb_get_extra_descriptor ( char * buffer , unsigned size , unsigned char type , void * * ptr ) { struct usb_descriptor_header * header ; while ( size >= sizeof ( struct usb_descriptor_header ) ) { header = ( struct usb_descriptor_header * ) buffer ; if ( header -> bLength < 2 ) { printk ( KERN_ERR ""%s:bogusdescriptor,type%dlength%d\\n"" , usbcore_name , header -> bDescriptorType , header -> bLength ) ; return - 1 ; } if ( header -> bDescriptorType == type ) { * ptr = header ; return 0 ; } buffer += header -> bLength ; size -= header -> bLength ; } return - 1 ; } "," * * ptr , size_t minsize bLength < 2 || header -> bLength > size bDescriptorType == type && header -> bLength >= minsize ",torvalds@linux/704620afc70cf47abb9d6a1a57f3825d2bca49cf,CVE-2018-20169,https://github.com/torvalds/linux/commit/704620afc70cf47abb9d6a1a57f3825d2bca49cf,2018-12-17T07:29Z 437,CWE-119,"CWE-119 int main ( int argc , char * argv [ ] ) { opj_dinfo_t * dinfo ; opj_event_mgr_t event_mgr ; int tnum ; unsigned int snum ; opj_mj2_t * movie ; mj2_tk_t * track ; mj2_sample_t * sample ; unsigned char * frame_codestream ; FILE * file , * outfile ; char outfilename [ 50 ] ; mj2_dparameters_t parameters ; if ( argc != 3 ) { printf ( ""Usage:%smj2filenameoutput_location\\n"" , argv [ 0 ] ) ; printf ( ""Example:%sforeman.mj2output/foreman\\n"" , argv [ 0 ] ) ; return 1 ; } file = fopen ( argv [ 1 ] , ""rb"" ) ; if ( ! file ) { fprintf ( stderr , ""failedtoopen%sforreading\\n"" , argv [ 1 ] ) ; return 1 ; } memset ( & event_mgr , 0 , sizeof ( opj_event_mgr_t ) ) ; event_mgr . error_handler = error_callback ; event_mgr . warning_handler = warning_callback ; event_mgr . info_handler = info_callback ; dinfo = mj2_create_decompress ( ) ; opj_set_event_mgr ( ( opj_common_ptr ) dinfo , & event_mgr , stderr ) ; memset ( & parameters , 0 , sizeof ( mj2_dparameters_t ) ) ; movie = ( opj_mj2_t * ) dinfo -> mj2_handle ; mj2_setup_decoder ( movie , & parameters ) ; if ( mj2_read_struct ( file , movie ) ) { return 1 ; } tnum = 0 ; while ( movie -> tk [ tnum ] . track_type != 0 ) { tnum ++ ; } track = & movie -> tk [ tnum ] ; fprintf ( stdout , ""Extracting%dframesfromfile...\\n"" , track -> num_samples ) ; for ( snum = 0 ; snum < track -> num_samples ; snum ++ ) { sample = & track -> sample [ snum ] ; frame_codestream = ( unsigned char * ) malloc ( sample -> sample_size - 8 ) ; fseek ( file , sample -> offset + 8 , SEEK_SET ) ; fread ( frame_codestream , sample -> sample_size - 8 , 1 , file ) ; sprintf ( outfilename , ""%s_%05d.j2k"" , argv [ 2 ] , snum ) ; outfile = fopen ( outfilename , ""wb"" ) ; if ( ! outfile ) { fprintf ( stderr , ""failedtoopen%sforwriting\\n"" , outfilename ) ; return 1 ; } fwrite ( frame_codestream , sample -> sample_size - 8 , 1 , outfile ) ; fclose ( outfile ) ; free ( frame_codestream ) ; } fclose ( file ) ; fprintf ( stdout , ""%dframescorrectlyextracted\\n"" , snum ) ; if ( dinfo ) { mj2_destroy_decompress ( ( opj_mj2_t * ) dinfo -> mj2_handle ) ; } return 0 ; } "," file ) ; { int num = snprintf ( outfilename , ( outfilename , sizeof ( outfilename ) , 2 ] , snum ) ; if ( num >= sizeof ( outfilename ) ) { fprintf ( stderr , ""maximumlengthofoutputprefixexceeded\\n"" ) ; free ( frame_codestream ) ; return 1 ; } } outfile = fopen ""failedtoopen%sforwriting\\n"" , outfilename ) ; free ( frame_codestream ",uclouvain@openjpeg/cc3824767bde397fedb8a1ae4786a222ba860c8d,CVE-2018-7648,https://github.com/uclouvain/openjpeg/commit/cc3824767bde397fedb8a1ae4786a222ba860c8d,2018-03-02T16:29Z 438,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 439,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 440,CWE-125,"CWE-125 void beep_print ( netdissect_options * ndo , const u_char * bp , u_int length ) { if ( l_strnstart ( ""MSG"" , 4 , ( const char * ) bp , length ) ) ND_PRINT ( ( ndo , ""BEEPMSG"" ) ) ; else if ( l_strnstart ( ""RPY"" , 4 , ( const char * ) bp , length ) ) ND_PRINT ( ( ndo , ""BEEPRPY"" ) ) ; else if ( l_strnstart ( ""ERR"" , 4 , ( const char * ) bp , length ) ) ND_PRINT ( ( ndo , ""BEEPERR"" ) ) ; else if ( l_strnstart ( ""ANS"" , 4 , ( const char * ) bp , length ) ) ND_PRINT ( ( ndo , ""BEEPANS"" ) ) ; else if ( l_strnstart ( ""NUL"" , 4 , ( const char * ) bp , length ) ) ND_PRINT ( ( ndo , ""BEEPNUL"" ) ) ; else if ( l_strnstart ( ""SEQ"" , 4 , ( const char * ) bp , length ) ) ND_PRINT ( ( ndo , ""BEEPSEQ"" ) ) ; else if ( l_strnstart ( ""END"" , 4 , ( const char * ) bp , length ) ) ND_PRINT ( ( ndo , ""BEEPEND"" ) ) ; else ND_PRINT ( ( ndo , ""BEEP(payloadorundecoded)"" ) ) ; } "," ( l_strnstart ( ndo , ( l_strnstart ( ndo , ( l_strnstart ( ndo , ( l_strnstart ( ndo , ( l_strnstart ( ndo , ( l_strnstart ( ndo , ( l_strnstart ( ndo , ",the-tcpdump-group@tcpdump/877b66b398518d9501513e0860c9f3a8acc70892,CVE-2017-13010,https://github.com/the-tcpdump-group/tcpdump/commit/877b66b398518d9501513e0860c9f3a8acc70892,2017-09-14T06:29Z 441,CWE-787,"CWE-787 opj_image_t * tgatoimage ( const char * filename , opj_cparameters_t * parameters ) { FILE * f ; opj_image_t * image ; unsigned int image_width , image_height , pixel_bit_depth ; unsigned int x , y ; int flip_image = 0 ; opj_image_cmptparm_t cmptparm [ 4 ] ; int numcomps ; OPJ_COLOR_SPACE color_space ; OPJ_BOOL mono ; OPJ_BOOL save_alpha ; int subsampling_dx , subsampling_dy ; int i ; f = fopen ( filename , ""rb"" ) ; if ( ! f ) { fprintf ( stderr , ""Failedtoopen%sforreading!!\\n"" , filename ) ; return 0 ; } if ( ! tga_readheader ( f , & pixel_bit_depth , & image_width , & image_height , & flip_image ) ) { fclose ( f ) ; return NULL ; } if ( ! ( ( pixel_bit_depth == 24 ) || ( pixel_bit_depth == 32 ) ) ) { fclose ( f ) ; return NULL ; } memset ( & cmptparm [ 0 ] , 0 , 4 * sizeof ( opj_image_cmptparm_t ) ) ; mono = ( pixel_bit_depth == 8 ) || ( pixel_bit_depth == 16 ) ; save_alpha = ( pixel_bit_depth == 16 ) || ( pixel_bit_depth == 32 ) ; if ( mono ) { color_space = OPJ_CLRSPC_GRAY ; numcomps = save_alpha ? 2 : 1 ; } else { numcomps = save_alpha ? 4 : 3 ; color_space = OPJ_CLRSPC_SRGB ; } subsampling_dx = parameters -> subsampling_dx ; subsampling_dy = parameters -> subsampling_dy ; for ( i = 0 ; i < numcomps ; i ++ ) { cmptparm [ i ] . prec = 8 ; cmptparm [ i ] . bpp = 8 ; cmptparm [ i ] . sgnd = 0 ; cmptparm [ i ] . dx = ( OPJ_UINT32 ) subsampling_dx ; cmptparm [ i ] . dy = ( OPJ_UINT32 ) subsampling_dy ; cmptparm [ i ] . w = image_width ; cmptparm [ i ] . h = image_height ; } image = opj_image_create ( ( OPJ_UINT32 ) numcomps , & cmptparm [ 0 ] , color_space ) ; if ( ! image ) { fclose ( f ) ; return NULL ; } image -> x0 = ( OPJ_UINT32 ) parameters -> image_offset_x0 ; image -> y0 = ( OPJ_UINT32 ) parameters -> image_offset_y0 ; image -> x1 = ! image -> x0 ? ( OPJ_UINT32 ) ( image_width - 1 ) * ( OPJ_UINT32 ) subsampling_dx + 1 : image -> x0 + ( OPJ_UINT32 ) ( image_width - 1 ) * ( OPJ_UINT32 ) subsampling_dx + 1 ; image -> y1 = ! image -> y0 ? ( OPJ_UINT32 ) ( image_height - 1 ) * ( OPJ_UINT32 ) subsampling_dy + 1 : image -> y0 + ( OPJ_UINT32 ) ( image_height - 1 ) * ( OPJ_UINT32 ) subsampling_dy + 1 ; for ( y = 0 ; y < image_height ; y ++ ) { int index ; if ( flip_image ) { index = ( int ) ( ( image_height - y - 1 ) * image_width ) ; } else { index = ( int ) ( y * image_width ) ; } if ( numcomps == 3 ) { for ( x = 0 ; x < image_width ; x ++ ) { unsigned char r , g , b ; if ( ! fread ( & b , 1 , 1 , f ) ) { fprintf ( stderr , ""\\nError:freadreturnanumberofelementdifferentfromtheexpected.\\n"" ) ; opj_image_destroy ( image ) ; fclose ( f ) ; return NULL ; } if ( ! fread ( & g , 1 , 1 , f ) ) { fprintf ( stderr , ""\\nError:freadreturnanumberofelementdifferentfromtheexpected.\\n"" ) ; opj_image_destroy ( image ) ; fclose ( f ) ; return NULL ; } if ( ! fread ( & r , 1 , 1 , f ) ) { fprintf ( stderr , ""\\nError:freadreturnanumberofelementdifferentfromtheexpected.\\n"" ) ; opj_image_destroy ( image ) ; fclose ( f ) ; return NULL ; } image -> comps [ 0 ] . data [ index ] = r ; image -> comps [ 1 ] . data [ index ] = g ; image -> comps [ 2 ] . data [ index ] = b ; index ++ ; } } else if ( numcomps == 4 ) { for ( x = 0 ; x < image_width ; x ++ ) { unsigned char r , g , b , a ; if ( ! fread ( & b , 1 , 1 , f ) ) { fprintf ( stderr , ""\\nError:freadreturnanumberofelementdifferentfromtheexpected.\\n"" ) ; opj_image_destroy ( image ) ; fclose ( f ) ; return NULL ; } if ( ! fread ( & g , 1 , 1 , f ) ) { fprintf ( stderr , ""\\nError:freadreturnanumberofelementdifferentfromtheexpected.\\n"" ) ; opj_image_destroy ( image ) ; fclose ( f ) ; return NULL ; } if ( ! fread ( & r , 1 , 1 , f ) ) { fprintf ( stderr , ""\\nError:freadreturnanumberofelementdifferentfromtheexpected.\\n"" ) ; opj_image_destroy ( image ) ; fclose ( f ) ; return NULL ; } if ( ! fread ( & a , 1 , 1 , f ) ) { fprintf ( stderr , ""\\nError:freadreturnanumberofelementdifferentfromtheexpected.\\n"" ) ; opj_image_destroy ( image ) ; fclose ( f ) ; return NULL ; } image -> comps [ 0 ] . data [ index ] = r ; image -> comps [ 1 ] . data [ index ] = g ; image -> comps [ 2 ] . data [ index ] = b ; image -> comps [ 3 ] . data [ index ] = a ; index ++ ; } } else { fprintf ( stderr , ""Currentlyunsupportedbitdepth:%s\\n"" , filename ) ; } } fclose ( f ) ; return image ; } "," OPJ_CLRSPC_SRGB ; } if ( image_height != 0 && image_width > 10000000 / image_height / numcomps ) { char ch ; OPJ_UINT64 expected_file_size = ( OPJ_UINT64 ) image_width * image_height * numcomps ; long curpos = ftell ( f ) ; if ( expected_file_size > ( OPJ_UINT64 ) INT_MAX ) { expected_file_size = ( OPJ_UINT64 ) INT_MAX ; } fseek ( f , ( long ) expected_file_size - 1 , SEEK_SET ) ; if ( fread ( & ch , 1 , 1 , f ) != 1 ) { fclose ( f ) ; return NULL ; } fseek ( f , curpos , SEEK_SET ) ; } ",uclouvain@openjpeg/2cd30c2b06ce332dede81cccad8b334cde997281,CVE-2017-14040,https://github.com/uclouvain/openjpeg/commit/2cd30c2b06ce332dede81cccad8b334cde997281,2017-08-30T22:29Z 442,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 443,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 444,CWE-404,"CWE-404 static void cp2112_gpio_set ( struct gpio_chip * chip , unsigned offset , int value ) { struct cp2112_device * dev = gpiochip_get_data ( chip ) ; struct hid_device * hdev = dev -> hdev ; u8 * buf = dev -> in_out_buffer ; unsigned long flags ; int ret ; spin_lock_irqsave ( & dev -> lock , flags ) ; buf [ 0 ] = CP2112_GPIO_SET ; buf [ 1 ] = value ? 0xff : 0 ; buf [ 2 ] = 1 << offset ; ret = hid_hw_raw_request ( hdev , CP2112_GPIO_SET , buf , CP2112_GPIO_SET_LENGTH , HID_FEATURE_REPORT , HID_REQ_SET_REPORT ) ; if ( ret < 0 ) hid_err ( hdev , ""errorsettingGPIOvalues:%d\\n"" , ret ) ; spin_unlock_irqrestore ( & dev -> lock , flags ) ; } "," -> in_out_buffer ; int ret ; int ret ; mutex_lock ( & dev dev -> lock ) ; buf ret ) ; mutex_unlock ( & dev dev -> lock ) ; } ",torvalds@linux/7a7b5df84b6b4e5d599c7289526eed96541a0654,CVE-2017-8071,https://github.com/torvalds/linux/commit/7a7b5df84b6b4e5d599c7289526eed96541a0654,2017-04-23T05:59Z 445,CWE-119,"CWE-119 static int evaluate_inter_mode_rd ( int mdcounts [ 4 ] , RATE_DISTORTION * rd , int * disable_skip , VP8_COMP * cpi , MACROBLOCK * x ) { MB_PREDICTION_MODE this_mode = x -> e_mbd . mode_info_context -> mbmi . mode ; BLOCK * b = & x -> block [ 0 ] ; MACROBLOCKD * xd = & x -> e_mbd ; int distortion ; vp8_build_inter16x16_predictors_mby ( & x -> e_mbd , x -> e_mbd . predictor , 16 ) ; if ( cpi -> active_map_enabled && x -> active_ptr [ 0 ] == 0 ) { x -> skip = 1 ; } else if ( x -> encode_breakout ) { unsigned int sse ; unsigned int var ; unsigned int threshold = ( xd -> block [ 0 ] . dequant [ 1 ] * xd -> block [ 0 ] . dequant [ 1 ] >> 4 ) ; if ( threshold < x -> encode_breakout ) threshold = x -> encode_breakout ; var = vp8_variance16x16 ( * ( b -> base_src ) , b -> src_stride , x -> e_mbd . predictor , 16 , & sse ) ; if ( sse < threshold ) { unsigned int q2dc = xd -> block [ 24 ] . dequant [ 0 ] ; if ( ( sse - var < q2dc * q2dc >> 4 ) || ( sse / 2 > var && sse - var < 64 ) ) { unsigned int sse2 = VP8_UVSSE ( x ) ; if ( sse2 * 2 < threshold ) { x -> skip = 1 ; rd -> distortion2 = sse + sse2 ; rd -> rate2 = 500 ; rd -> rate_uv = 0 ; rd -> distortion_uv = sse2 ; * disable_skip = 1 ; return RDCOST ( x -> rdmult , x -> rddiv , rd -> rate2 , rd -> distortion2 ) ; } } } } rd -> rate2 += vp8_cost_mv_ref ( this_mode , mdcounts ) ; macro_block_yrd ( x , & rd -> rate_y , & distortion ) ; rd -> rate2 += rd -> rate_y ; rd -> distortion2 += distortion ; rd_inter16x16_uv ( cpi , x , & rd -> rate_uv , & rd -> distortion_uv , cpi -> common . full_pixel ) ; rd -> rate2 += rd -> rate_uv ; rd -> distortion2 += rd -> distortion_uv ; return INT_MAX ; } "," ; var = vpx_variance16x16 ( * ( ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 446,CWE-125,"CWE-125 static int parseOperand ( RAsm * a , const char * str , Operand * op , bool isrepop ) { size_t pos , nextpos = 0 ; x86newTokenType last_type ; int size_token = 1 ; bool explicit_size = false ; int reg_index = 0 ; op -> type = 0 ; while ( size_token ) { pos = nextpos ; last_type = getToken ( str , & pos , & nextpos ) ; if ( ! r_str_ncasecmp ( str + pos , ""ptr"" , 3 ) ) { continue ; } else if ( ! r_str_ncasecmp ( str + pos , ""byte"" , 4 ) ) { op -> type |= OT_MEMORY | OT_BYTE ; op -> dest_size = OT_BYTE ; explicit_size = true ; } else if ( ! r_str_ncasecmp ( str + pos , ""word"" , 4 ) ) { op -> type |= OT_MEMORY | OT_WORD ; op -> dest_size = OT_WORD ; explicit_size = true ; } else if ( ! r_str_ncasecmp ( str + pos , ""dword"" , 5 ) ) { op -> type |= OT_MEMORY | OT_DWORD ; op -> dest_size = OT_DWORD ; explicit_size = true ; } else if ( ! r_str_ncasecmp ( str + pos , ""qword"" , 5 ) ) { op -> type |= OT_MEMORY | OT_QWORD ; op -> dest_size = OT_QWORD ; explicit_size = true ; } else if ( ! r_str_ncasecmp ( str + pos , ""oword"" , 5 ) ) { op -> type |= OT_MEMORY | OT_OWORD ; op -> dest_size = OT_OWORD ; explicit_size = true ; } else if ( ! r_str_ncasecmp ( str + pos , ""tbyte"" , 5 ) ) { op -> type |= OT_MEMORY | OT_TBYTE ; op -> dest_size = OT_TBYTE ; explicit_size = true ; } else { size_token = 0 ; } } if ( str [ pos ] == '[' ) { if ( ! op -> type ) { op -> type = OT_MEMORY ; } op -> offset = op -> scale [ 0 ] = op -> scale [ 1 ] = 0 ; ut64 temp = 1 ; Register reg = X86R_UNDEFINED ; bool first_reg = true ; while ( str [ pos ] != ']' ) { if ( pos > nextpos ) { break ; } pos = nextpos ; if ( ! str [ pos ] ) { break ; } last_type = getToken ( str , & pos , & nextpos ) ; if ( last_type == TT_SPECIAL ) { if ( str [ pos ] == '+' || str [ pos ] == '-' || str [ pos ] == ']' ) { if ( reg != X86R_UNDEFINED ) { op -> regs [ reg_index ] = reg ; op -> scale [ reg_index ] = temp ; ++ reg_index ; } else { op -> offset += temp ; op -> regs [ reg_index ] = X86R_UNDEFINED ; } temp = 1 ; reg = X86R_UNDEFINED ; } else if ( str [ pos ] == '*' ) { } } else if ( last_type == TT_WORD ) { ut32 reg_type = 0 ; if ( reg != X86R_UNDEFINED ) { op -> type = 0 ; } nextpos = pos ; reg = parseReg ( a , str , & nextpos , & reg_type ) ; if ( first_reg ) { op -> extended = false ; if ( reg > 8 ) { op -> extended = true ; op -> reg = reg - 9 ; } first_reg = false ; } else if ( reg > 8 ) { op -> reg = reg - 9 ; } if ( reg_type & OT_REGTYPE & OT_SEGMENTREG ) { op -> reg = reg ; op -> type = reg_type ; parse_segment_offset ( a , str , & nextpos , op , reg_index ) ; return nextpos ; } if ( ! explicit_size ) { op -> type |= reg_type ; } op -> reg_size = reg_type ; op -> explicit_size = explicit_size ; if ( ! ( reg_type & OT_GPREG ) ) { op -> type = 0 ; } } else { char * p = strchr ( str , '+' ) ; op -> offset_sign = 1 ; if ( ! p ) { p = strchr ( str , '-' ) ; if ( p ) { op -> offset_sign = - 1 ; } } char * plus = strchr ( str , '+' ) ; char * minus = strchr ( str , '-' ) ; char * closeB = strchr ( str , ']' ) ; if ( plus && minus && plus < closeB && minus < closeB ) { op -> offset_sign = - 1 ; } char * tmp ; tmp = malloc ( strlen ( str + pos ) + 1 ) ; strcpy ( tmp , str + pos ) ; strtok ( tmp , ""+-"" ) ; st64 read = getnum ( a , tmp ) ; free ( tmp ) ; temp *= read ; } } } else if ( last_type == TT_WORD ) { nextpos = pos ; RFlagItem * flag ; if ( isrepop ) { op -> is_good_flag = false ; strncpy ( op -> rep_op , str , MAX_REPOP_LENGTH - 1 ) ; op -> rep_op [ MAX_REPOP_LENGTH - 1 ] = '\\0' ; return nextpos ; } op -> reg = parseReg ( a , str , & nextpos , & op -> type ) ; op -> extended = false ; if ( op -> reg > 8 ) { op -> extended = true ; op -> reg -= 9 ; } if ( op -> type & OT_REGTYPE & OT_SEGMENTREG ) { parse_segment_offset ( a , str , & nextpos , op , reg_index ) ; return nextpos ; } if ( op -> reg == X86R_UNDEFINED ) { op -> is_good_flag = false ; if ( a -> num && a -> num -> value == 0 ) { return nextpos ; } op -> type = OT_CONSTANT ; RCore * core = a -> num ? ( RCore * ) ( a -> num -> userptr ) : NULL ; if ( core && ( flag = r_flag_get ( core -> flags , str ) ) ) { op -> is_good_flag = true ; } char * p = strchr ( str , '-' ) ; if ( p ) { op -> sign = - 1 ; str = ++ p ; } op -> immediate = getnum ( a , str ) ; } else if ( op -> reg < X86R_UNDEFINED ) { strncpy ( op -> rep_op , str , MAX_REPOP_LENGTH - 1 ) ; op -> rep_op [ MAX_REPOP_LENGTH - 1 ] = '\\0' ; } } else { op -> type = OT_CONSTANT ; op -> sign = 1 ; char * p = strchr ( str , '-' ) ; if ( p ) { op -> sign = - 1 ; str = ++ p ; } op -> immediate = getnum ( a , str ) ; } return nextpos ; } "," X86R_UNDEFINED ) { if ( reg_index < 2 ) { = temp ; } += temp ; if ( reg_index < 2 ) { = X86R_UNDEFINED ; } ",radare@radare2/9b46d38dd3c4de6048a488b655c7319f845af185,CVE-2018-20456,https://github.com/radare/radare2/commit/9b46d38dd3c4de6048a488b655c7319f845af185,2018-12-25T19:29Z 447,CWE-190,"CWE-190 int mongo_env_read_socket ( mongo * conn , void * buf , int len ) { char * cbuf = buf ; while ( len ) { int sent = recv ( conn -> sock , cbuf , len , 0 ) ; if ( sent == 0 || sent == - 1 ) { __mongo_set_error ( conn , MONGO_IO_ERROR , strerror ( errno ) , errno ) ; return MONGO_ERROR ; } cbuf += sent ; len -= sent ; } return MONGO_OK ; } "," * buf , size_t len ) { len ) { size_t sent = recv ",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 448,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 449,CWE-416,"CWE-416 void comps_mrtree_unite ( COMPS_MRTree * rt1 , COMPS_MRTree * rt2 ) { COMPS_HSList * tmplist , * tmp_subnodes ; COMPS_HSListItem * it , * it2 ; struct Pair { COMPS_HSList * subnodes ; char * key ; char added ; } * pair , * parent_pair ; pair = malloc ( sizeof ( struct Pair ) ) ; pair -> subnodes = rt2 -> subnodes ; pair -> key = NULL ; tmplist = comps_hslist_create ( ) ; comps_hslist_init ( tmplist , NULL , NULL , & free ) ; comps_hslist_append ( tmplist , pair , 0 ) ; while ( tmplist -> first != NULL ) { it = tmplist -> first ; comps_hslist_remove ( tmplist , tmplist -> first ) ; tmp_subnodes = ( ( struct Pair * ) it -> data ) -> subnodes ; parent_pair = ( struct Pair * ) it -> data ; free ( it ) ; pair -> added = 0 ; for ( it = tmp_subnodes -> first ; it != NULL ; it = it -> next ) { pair = malloc ( sizeof ( struct Pair ) ) ; pair -> subnodes = ( ( COMPS_MRTreeData * ) it -> data ) -> subnodes ; if ( parent_pair -> key != NULL ) { pair -> key = malloc ( sizeof ( char ) * ( strlen ( ( ( COMPS_MRTreeData * ) it -> data ) -> key ) + strlen ( parent_pair -> key ) + 1 ) ) ; memcpy ( pair -> key , parent_pair -> key , sizeof ( char ) * strlen ( parent_pair -> key ) ) ; memcpy ( pair -> key + strlen ( parent_pair -> key ) , ( ( COMPS_MRTreeData * ) it -> data ) -> key , sizeof ( char ) * ( strlen ( ( ( COMPS_MRTreeData * ) it -> data ) -> key ) + 1 ) ) ; } else { pair -> key = malloc ( sizeof ( char ) * ( strlen ( ( ( COMPS_MRTreeData * ) it -> data ) -> key ) + 1 ) ) ; memcpy ( pair -> key , ( ( COMPS_MRTreeData * ) it -> data ) -> key , sizeof ( char ) * ( strlen ( ( ( COMPS_MRTreeData * ) it -> data ) -> key ) + 1 ) ) ; } if ( ( ( COMPS_MRTreeData * ) it -> data ) -> data -> first != NULL ) { for ( it2 = ( ( COMPS_MRTreeData * ) it -> data ) -> data -> first ; it2 != NULL ; it2 = it2 -> next ) { comps_mrtree_set ( rt1 , pair -> key , it2 -> data ) ; } if ( ( ( COMPS_MRTreeData * ) it -> data ) -> subnodes -> first ) { comps_hslist_append ( tmplist , pair , 0 ) ; } else { free ( pair -> key ) ; free ( pair ) ; } } else { if ( ( ( COMPS_MRTreeData * ) it -> data ) -> subnodes -> first ) { comps_hslist_append ( tmplist , pair , 0 ) ; } else { free ( pair -> key ) ; free ( pair ) ; } } } free ( parent_pair -> key ) ; free ( parent_pair ) ; } comps_hslist_destroy ( & tmplist ) ; } "," * key ; } * pair it ) ; for ( it ",rpm-software-management@libcomps/e3a5d056633677959ad924a51758876d415e7046,CVE-2019-3817,https://github.com/rpm-software-management/libcomps/commit/e3a5d056633677959ad924a51758876d415e7046,2019-03-27T13:29Z 450,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 451,CWE-119,"CWE-119 void vp9_cyclic_refresh_free ( CYCLIC_REFRESH * cr ) { vpx_free ( cr -> map ) ; vpx_free ( cr ) ; } "," vpx_free ( cr -> last_coded_q_map ) ; vpx_free ( cr ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 452,CWE-119,"CWE-119 SQLWCHAR * _single_string_alloc_and_expand ( LPCSTR in ) { SQLWCHAR * chr ; int len = 0 ; if ( ! in ) { return in ; } while ( in [ len ] != 0 ) { len ++ ; } chr = malloc ( sizeof ( SQLWCHAR ) * ( len + 1 ) ) ; len = 0 ; while ( in [ len ] != 0 ) { chr [ len ] = in [ len ] ; len ++ ; } chr [ len ++ ] = 0 ; return chr ; } "," ) { return NULL ; } while ",lurcher@unixODBC/45ef78e037f578b15fc58938a3a3251655e71d6f,CVE-2018-7485,https://github.com/lurcher/unixODBC/commit/45ef78e037f578b15fc58938a3a3251655e71d6f#diff-d52750c7ba4e594410438569d8e2963aL24,2018-02-26T14:29Z 453,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 454,CWE-415,"CWE-415 static int amd_gpio_probe ( struct platform_device * pdev ) { int ret = 0 ; int irq_base ; struct resource * res ; struct amd_gpio * gpio_dev ; gpio_dev = devm_kzalloc ( & pdev -> dev , sizeof ( struct amd_gpio ) , GFP_KERNEL ) ; if ( ! gpio_dev ) return - ENOMEM ; spin_lock_init ( & gpio_dev -> lock ) ; res = platform_get_resource ( pdev , IORESOURCE_MEM , 0 ) ; if ( ! res ) { dev_err ( & pdev -> dev , ""Failedtogetgpioioresource.\\n"" ) ; return - EINVAL ; } gpio_dev -> base = devm_ioremap_nocache ( & pdev -> dev , res -> start , resource_size ( res ) ) ; if ( ! gpio_dev -> base ) return - ENOMEM ; irq_base = platform_get_irq ( pdev , 0 ) ; if ( irq_base < 0 ) { dev_err ( & pdev -> dev , ""FailedtogetgpioIRQ.\\n"" ) ; return - EINVAL ; } gpio_dev -> pdev = pdev ; gpio_dev -> gc . direction_input = amd_gpio_direction_input ; gpio_dev -> gc . direction_output = amd_gpio_direction_output ; gpio_dev -> gc . get = amd_gpio_get_value ; gpio_dev -> gc . set = amd_gpio_set_value ; gpio_dev -> gc . set_debounce = amd_gpio_set_debounce ; gpio_dev -> gc . dbg_show = amd_gpio_dbg_show ; gpio_dev -> gc . base = 0 ; gpio_dev -> gc . label = pdev -> name ; gpio_dev -> gc . owner = THIS_MODULE ; gpio_dev -> gc . parent = & pdev -> dev ; gpio_dev -> gc . ngpio = TOTAL_NUMBER_OF_PINS ; # if defined ( CONFIG_OF_GPIO ) gpio_dev -> gc . of_node = pdev -> dev . of_node ; # endif gpio_dev -> groups = kerncz_groups ; gpio_dev -> ngroups = ARRAY_SIZE ( kerncz_groups ) ; amd_pinctrl_desc . name = dev_name ( & pdev -> dev ) ; gpio_dev -> pctrl = pinctrl_register ( & amd_pinctrl_desc , & pdev -> dev , gpio_dev ) ; if ( IS_ERR ( gpio_dev -> pctrl ) ) { dev_err ( & pdev -> dev , ""Couldn\'tregisterpinctrldriver\\n"" ) ; return PTR_ERR ( gpio_dev -> pctrl ) ; } ret = gpiochip_add_data ( & gpio_dev -> gc , gpio_dev ) ; if ( ret ) goto out1 ; ret = gpiochip_add_pin_range ( & gpio_dev -> gc , dev_name ( & pdev -> dev ) , 0 , 0 , TOTAL_NUMBER_OF_PINS ) ; if ( ret ) { dev_err ( & pdev -> dev , ""Failedtoaddpinrange\\n"" ) ; goto out2 ; } ret = gpiochip_irqchip_add ( & gpio_dev -> gc , & amd_gpio_irqchip , 0 , handle_simple_irq , IRQ_TYPE_NONE ) ; if ( ret ) { dev_err ( & pdev -> dev , ""couldnotaddirqchip\\n"" ) ; ret = - ENODEV ; goto out2 ; } gpiochip_set_chained_irqchip ( & gpio_dev -> gc , & amd_gpio_irqchip , irq_base , amd_gpio_irq_handler ) ; platform_set_drvdata ( pdev , gpio_dev ) ; dev_dbg ( & pdev -> dev , ""amdgpiodriverloaded\\n"" ) ; return ret ; out2 : gpiochip_remove ( & gpio_dev -> gc ) ; out1 : pinctrl_unregister ( gpio_dev -> pctrl ) ; return ret ; } "," -> pctrl = devm_pinctrl_register ( & pdev -> dev , & amd_pinctrl_desc , & amd_pinctrl_desc , gpio_dev ) ; ( ret ) return ret ; ret = gc ) ; return ret ; ",torvalds@linux/251e22abde21833b3d29577e4d8c7aaccd650eee,CVE-2017-18174,https://github.com/torvalds/linux/commit/251e22abde21833b3d29577e4d8c7aaccd650eee,2018-02-11T18:29Z 455,CWE-119,"CWE-119 void read_sequence_header ( decoder_info_t * decoder_info , stream_t * stream ) { decoder_info -> width = get_flc ( 16 , stream ) ; decoder_info -> height = get_flc ( 16 , stream ) ; decoder_info -> log2_sb_size = get_flc ( 3 , stream ) ; decoder_info -> pb_split = get_flc ( 1 , stream ) ; decoder_info -> tb_split_enable = get_flc ( 1 , stream ) ; decoder_info -> max_num_ref = get_flc ( 2 , stream ) + 1 ; decoder_info -> interp_ref = get_flc ( 2 , stream ) ; decoder_info -> max_delta_qp = get_flc ( 1 , stream ) ; decoder_info -> deblocking = get_flc ( 1 , stream ) ; decoder_info -> clpf = get_flc ( 1 , stream ) ; decoder_info -> use_block_contexts = get_flc ( 1 , stream ) ; decoder_info -> bipred = get_flc ( 2 , stream ) ; decoder_info -> qmtx = get_flc ( 1 , stream ) ; if ( decoder_info -> qmtx ) { decoder_info -> qmtx_offset = get_flc ( 6 , stream ) - 32 ; } decoder_info -> subsample = get_flc ( 2 , stream ) ; decoder_info -> subsample = ( decoder_info -> subsample & 1 ) * 20 + ( decoder_info -> subsample & 2 ) * 22 + ( ( decoder_info -> subsample & 3 ) == 3 ) * 2 + 400 ; decoder_info -> num_reorder_pics = get_flc ( 4 , stream ) ; if ( decoder_info -> subsample != 400 ) { decoder_info -> cfl_intra = get_flc ( 1 , stream ) ; decoder_info -> cfl_inter = get_flc ( 1 , stream ) ; } decoder_info -> bitdepth = get_flc ( 1 , stream ) ? 10 : 8 ; if ( decoder_info -> bitdepth == 10 ) decoder_info -> bitdepth += 2 * get_flc ( 1 , stream ) ; decoder_info -> input_bitdepth = get_flc ( 1 , stream ) ? 10 : 8 ; if ( decoder_info -> input_bitdepth == 10 ) decoder_info -> input_bitdepth += 2 * get_flc ( 1 , stream ) ; } "," 3 , stream ) ; decoder_info -> log2_sb_size = clip ( decoder_info -> log2_sb_size , log2i ( MIN_BLOCK_SIZE ) , log2i ( MAX_SB_SIZE ) ",cisco@thor/18de8f9f0762c3a542b1122589edb8af859d9813,CVE-2018-0429,https://github.com/cisco/thor/commit/18de8f9f0762c3a542b1122589edb8af859d9813,2018-08-09T20:29Z 456,CWE-787,"CWE-787 static void InsertRow ( Image * image , unsigned char * p , ssize_t y , int bpp , ExceptionInfo * exception ) { int bit ; Quantum index ; register Quantum * q ; ssize_t x ; switch ( bpp ) { 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 = ( ( * p ) & ( 0x80 >> bit ) ? 0x01 : 0x00 ) ; SetPixelIndex ( image , index , q ) ; SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) index , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } if ( ( image -> columns % 8 ) != 0 ) { for ( bit = 0 ; bit < ( ssize_t ) ( image -> columns % 8 ) ; bit ++ ) { index = ( ( * p ) & ( 0x80 >> bit ) ? 0x01 : 0x00 ) ; SetPixelIndex ( image , index , q ) ; SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) index , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } if ( ! SyncAuthenticPixels ( image , exception ) ) break ; 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 ) ; SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) index , q ) ; q += GetPixelChannels ( image ) ; index = ConstrainColormapIndex ( image , ( * p >> 4 ) & 0x3 , exception ) ; SetPixelIndex ( image , index , q ) ; SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) index , q ) ; q += GetPixelChannels ( image ) ; index = ConstrainColormapIndex ( image , ( * p >> 2 ) & 0x3 , exception ) ; SetPixelIndex ( image , index , q ) ; SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) index , q ) ; q += GetPixelChannels ( image ) ; index = ConstrainColormapIndex ( image , ( * p ) & 0x3 , exception ) ; SetPixelIndex ( image , index , q ) ; SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) index , q ) ; p ++ ; q += GetPixelChannels ( image ) ; } if ( ( image -> columns % 4 ) != 0 ) { index = ConstrainColormapIndex ( image , ( * p >> 6 ) & 0x3 , exception ) ; SetPixelIndex ( image , index , q ) ; SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) index , q ) ; q += GetPixelChannels ( image ) ; if ( ( image -> columns % 4 ) >= 1 ) { index = ConstrainColormapIndex ( image , ( * p >> 4 ) & 0x3 , exception ) ; SetPixelIndex ( image , index , q ) ; 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 ) ; SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) index , q ) ; q += GetPixelChannels ( image ) ; } } p ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; 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 ) & 0x0f , exception ) ; SetPixelIndex ( image , index , q ) ; SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) index , q ) ; q += GetPixelChannels ( image ) ; index = ConstrainColormapIndex ( image , ( * p ) & 0x0f , exception ) ; SetPixelIndex ( image , index , q ) ; SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) index , q ) ; p ++ ; q += GetPixelChannels ( image ) ; } if ( ( image -> columns % 2 ) != 0 ) { index = ConstrainColormapIndex ( image , ( * p >> 4 ) & 0x0f , exception ) ; SetPixelIndex ( image , index , q ) ; SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) index , q ) ; p ++ ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; 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 ) ; SetPixelViaPixelInfo ( image , image -> colormap + ( ssize_t ) index , q ) ; p ++ ; q += GetPixelChannels ( image ) ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } break ; case 24 : 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 ) ; q += GetPixelChannels ( image ) ; } if ( ! SyncAuthenticPixels ( image , exception ) ) break ; break ; } } "," ; x += 4 ) { index ",ImageMagick@ImageMagick/b60d1ed0af37c50b91a40937825b4c61e8458095,CVE-2016-7526,https://github.com/ImageMagick/ImageMagick/commit/b60d1ed0af37c50b91a40937825b4c61e8458095,2017-04-20T18:59Z 457,CWE-264,"CWE-264 SYSCALL_DEFINE5 ( osf_getsysinfo , unsigned long , op , void __user * , buffer , unsigned long , nbytes , int __user * , start , void __user * , arg ) { unsigned long w ; struct percpu_struct * cpu ; switch ( op ) { case GSI_IEEE_FP_CONTROL : w = current_thread_info ( ) -> ieee_state & IEEE_SW_MASK ; w = swcr_update_status ( w , rdfpcr ( ) ) ; if ( put_user ( w , ( unsigned long __user * ) buffer ) ) return - EFAULT ; return 0 ; case GSI_IEEE_STATE_AT_SIGNAL : break ; case GSI_UACPROC : if ( nbytes < sizeof ( unsigned int ) ) return - EINVAL ; w = ( current_thread_info ( ) -> flags >> UAC_SHIFT ) & UAC_BITMASK ; if ( put_user ( w , ( unsigned int __user * ) buffer ) ) return - EFAULT ; return 1 ; case GSI_PROC_TYPE : if ( nbytes < sizeof ( unsigned long ) ) return - EINVAL ; cpu = ( struct percpu_struct * ) ( ( char * ) hwrpb + hwrpb -> processor_offset ) ; w = cpu -> type ; if ( put_user ( w , ( unsigned long __user * ) buffer ) ) return - EFAULT ; return 1 ; case GSI_GET_HWRPB : if ( nbytes < sizeof ( * hwrpb ) ) return - EINVAL ; if ( copy_to_user ( buffer , hwrpb , nbytes ) != 0 ) return - EFAULT ; return 1 ; default : break ; } return - EOPNOTSUPP ; } "," if ( nbytes > sizeof ( * ",torvalds@linux/21c5977a836e399fc710ff2c5367845ed5c2527f,CVE-2011-2211,https://github.com/torvalds/linux/commit/21c5977a836e399fc710ff2c5367845ed5c2527f,2012-06-13T10:24Z 458,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 459,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 460,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 ( test_bit ( KEY_FLAG_INSTANTIATED , & key -> flags ) && ! test_bit ( KEY_FLAG_NEGATIVE , & key -> flags ) && 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 ) ; memzero_explicit ( key , sizeof ( * key ) ) ; kmem_cache_free ( key_jar , key ) ; } } "," graveyard_link ) ; short state = key -> state ; ; if ( state == KEY_IS_POSITIVE && key -> type ; if ( state != KEY_IS_UNINSTANTIATED ) atomic_dec ( ",torvalds@linux/363b02dab09b3226f3bd1420dad9c72b79a42a76,CVE-2017-15951,https://github.com/torvalds/linux/commit/363b02dab09b3226f3bd1420dad9c72b79a42a76,2017-10-28T02:29Z 461,CWE-401,"CWE-401 static int mwifiex_pcie_alloc_cmdrsp_buf ( struct mwifiex_adapter * adapter ) { struct pcie_service_card * card = adapter -> card ; struct sk_buff * skb ; skb = dev_alloc_skb ( MWIFIEX_UPLD_SIZE ) ; if ( ! skb ) { mwifiex_dbg ( adapter , ERROR , ""Unabletoallocateskbforcommandresponsedata.\\n"" ) ; return - ENOMEM ; } skb_put ( skb , MWIFIEX_UPLD_SIZE ) ; if ( mwifiex_map_pci_memory ( adapter , skb , MWIFIEX_UPLD_SIZE , PCI_DMA_FROMDEVICE ) ) return - 1 ; card -> cmdrsp_buf = skb ; return 0 ; } "," PCI_DMA_FROMDEVICE ) ) { kfree_skb ( skb ) ; - 1 ; } ",torvalds@linux/db8fd2cde93227e566a412cf53173ffa227998bc,CVE-2019-19056,https://github.com/torvalds/linux/commit/db8fd2cde93227e566a412cf53173ffa227998bc,2019-11-18T06:15Z 462,CWE-617,"CWE-617 void pci_lintr_request ( struct pci_vdev * dev ) { struct businfo * bi ; struct slotinfo * si ; int bestpin , bestcount , pin ; bi = pci_businfo [ dev -> bus ] ; assert ( bi != NULL ) ; si = & bi -> slotinfo [ dev -> slot ] ; bestpin = 0 ; bestcount = si -> si_intpins [ 0 ] . ii_count ; for ( pin = 1 ; pin < 4 ; pin ++ ) { if ( si -> si_intpins [ pin ] . ii_count < bestcount ) { bestpin = pin ; bestcount = si -> si_intpins [ pin ] . ii_count ; } } si -> si_intpins [ bestpin ] . ii_count ++ ; dev -> lintr . pin = bestpin + 1 ; pci_set_cfgdata8 ( dev , PCIR_INTPIN , bestpin + 1 ) ; } "," 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 463,CWE-59,"CWE-59 static int setup_dev_console ( const struct lxc_rootfs * rootfs , const struct lxc_console * console ) { char path [ MAXPATHLEN ] ; struct stat s ; int ret ; ret = snprintf ( path , sizeof ( path ) , ""%s/dev/console"" , rootfs -> mount ) ; if ( ret >= sizeof ( path ) ) { ERROR ( ""consolepathtoolong"" ) ; return - 1 ; } if ( access ( path , F_OK ) ) { WARN ( ""rootfsspecifiedbutnoconsolefoundat\'%s\'"" , path ) ; return 0 ; } if ( console -> master < 0 ) { INFO ( ""noconsole"" ) ; return 0 ; } if ( stat ( path , & s ) ) { SYSERROR ( ""failedtostat\'%s\'"" , path ) ; return - 1 ; } if ( chmod ( console -> name , s . st_mode ) ) { SYSERROR ( ""failedtosetmode\'0%o\'to\'%s\'"" , s . st_mode , console -> name ) ; return - 1 ; } if ( mount ( console -> name , path , ""none"" , MS_BIND , 0 ) ) { ERROR ( ""failedtomount\'%s\'on\'%s\'"" , console -> name , path ) ; return - 1 ; } INFO ( ""consolehasbeensetup"" ) ; return 0 ; } "," } if ( safe_mount ( console -> name , path , ""none"" , MS_BIND , 0 , rootfs -> mount ) ) { ",lxc@lxc/592fd47a6245508b79fe6ac819fe6d3b2c1289be,CVE-2015-1335,https://github.com/lxc/lxc/commit/592fd47a6245508b79fe6ac819fe6d3b2c1289be,2015-10-01T20:59Z 464,CWE-400,"CWE-400 int fpm_stdio_init_child ( struct fpm_worker_pool_s * wp ) { # ifdef HAVE_SYSLOG_H if ( fpm_globals . error_log_fd == ZLOG_SYSLOG ) { closelog ( ) ; } else # endif if ( fpm_globals . error_log_fd > 0 ) { close ( fpm_globals . error_log_fd ) ; } fpm_globals . error_log_fd = - 1 ; zlog_set_fd ( - 1 ) ; if ( wp -> listening_socket != STDIN_FILENO ) { if ( 0 > dup2 ( wp -> listening_socket , STDIN_FILENO ) ) { zlog ( ZLOG_SYSERROR , ""failedtoinitchildstdio:dup2()"" ) ; return - 1 ; } } return 0 ; } "," 1 ) ; return 0 ; ",php@php-src/69dee5c732fe982c82edb17d0dbc3e79a47748d8,CVE-2015-9253,https://github.com/php/php-src/commit/69dee5c732fe982c82edb17d0dbc3e79a47748d8,2018-02-19T19:29Z 465,CWE-119,"CWE-119 CURLcode Curl_smtp_escape_eob ( struct connectdata * conn , const ssize_t nread ) { ssize_t i ; ssize_t si ; struct Curl_easy * data = conn -> data ; struct SMTP * smtp = data -> req . protop ; char * scratch = data -> state . scratch ; char * newscratch = NULL ; char * oldscratch = NULL ; size_t eob_sent ; if ( ! scratch || data -> set . crlf ) { oldscratch = scratch ; scratch = newscratch = malloc ( 2 * data -> set . buffer_size ) ; if ( ! newscratch ) { failf ( data , ""Failedtoallocscratchbuffer!"" ) ; return CURLE_OUT_OF_MEMORY ; } } eob_sent = smtp -> eob ; for ( i = 0 , si = 0 ; i < nread ; i ++ ) { if ( SMTP_EOB [ smtp -> eob ] == data -> req . upload_fromhere [ i ] ) { smtp -> eob ++ ; if ( 2 == smtp -> eob || SMTP_EOB_LEN == smtp -> eob ) smtp -> trailing_crlf = TRUE ; else smtp -> trailing_crlf = FALSE ; } else if ( smtp -> eob ) { memcpy ( & scratch [ si ] , & SMTP_EOB [ eob_sent ] , smtp -> eob - eob_sent ) ; si += smtp -> eob - eob_sent ; if ( SMTP_EOB [ 0 ] == data -> req . upload_fromhere [ i ] ) smtp -> eob = 1 ; else smtp -> eob = 0 ; eob_sent = 0 ; smtp -> trailing_crlf = FALSE ; } if ( SMTP_EOB_FIND_LEN == smtp -> eob ) { memcpy ( & scratch [ si ] , & SMTP_EOB_REPL [ eob_sent ] , SMTP_EOB_REPL_LEN - eob_sent ) ; si += SMTP_EOB_REPL_LEN - eob_sent ; smtp -> eob = 0 ; eob_sent = 0 ; } else if ( ! smtp -> eob ) scratch [ si ++ ] = data -> req . upload_fromhere [ i ] ; } if ( smtp -> eob - eob_sent ) { memcpy ( & scratch [ si ] , & SMTP_EOB [ eob_sent ] , smtp -> eob - eob_sent ) ; si += smtp -> eob - eob_sent ; } if ( si != nread ) { data -> req . upload_fromhere = scratch ; data -> state . scratch = scratch ; free ( oldscratch ) ; data -> req . upload_present = si ; } else free ( newscratch ) ; return CURLE_OK ; } "," ( 2 * UPLOAD_BUFSIZE ) ; if ; } } DEBUGASSERT ( UPLOAD_BUFSIZE >= nread ) ; ",curl@curl/ba1dbd78e5f1ed67c1b8d37ac89d90e5e330b628,CVE-2018-0500,https://github.com/curl/curl/commit/ba1dbd78e5f1ed67c1b8d37ac89d90e5e330b628,2018-07-11T13:29Z 466,CWE-119,"CWE-119 static void test_decode ( struct stream_state * stream , enum TestDecodeFatality fatal , const VpxInterface * codec ) { vpx_image_t enc_img , dec_img ; if ( stream -> mismatch_seen ) return ; if ( strcmp ( codec -> name , ""vp8"" ) == 0 ) { struct vpx_ref_frame ref_enc , ref_dec ; int width , height ; width = ( stream -> config . cfg . g_w + 15 ) & ~ 15 ; height = ( stream -> config . cfg . g_h + 15 ) & ~ 15 ; vpx_img_alloc ( & ref_enc . img , VPX_IMG_FMT_I420 , width , height , 1 ) ; enc_img = ref_enc . img ; vpx_img_alloc ( & ref_dec . img , VPX_IMG_FMT_I420 , width , height , 1 ) ; dec_img = ref_dec . img ; ref_enc . frame_type = VP8_LAST_FRAME ; ref_dec . frame_type = VP8_LAST_FRAME ; vpx_codec_control ( & stream -> encoder , VP8_COPY_REFERENCE , & ref_enc ) ; vpx_codec_control ( & stream -> decoder , VP8_COPY_REFERENCE , & ref_dec ) ; } else { struct vp9_ref_frame ref ; ref . idx = 0 ; vpx_codec_control ( & stream -> encoder , VP9_GET_REFERENCE , & ref ) ; enc_img = ref . img ; vpx_codec_control ( & stream -> decoder , VP9_GET_REFERENCE , & ref ) ; dec_img = ref . img ; } ctx_exit_on_error ( & stream -> encoder , ""Failedtogetencoderreferenceframe"" ) ; ctx_exit_on_error ( & stream -> decoder , ""Failedtogetdecoderreferenceframe"" ) ; if ( ! compare_img ( & enc_img , & dec_img ) ) { int y [ 4 ] , u [ 4 ] , v [ 4 ] ; find_mismatch ( & enc_img , & dec_img , y , u , v ) ; stream -> decoder . err = 1 ; warn_or_exit_on_error ( & stream -> decoder , fatal == TEST_DECODE_FATAL , ""Stream%d:Encode/decodemismatchonframe%dat"" ""Y[%d,%d]{%d/%d},"" ""U[%d,%d]{%d/%d},"" ""V[%d,%d]{%d/%d}"" , stream -> index , stream -> frames_out , y [ 0 ] , y [ 1 ] , y [ 2 ] , y [ 3 ] , u [ 0 ] , u [ 1 ] , u [ 2 ] , u [ 3 ] , v [ 0 ] , v [ 1 ] , v [ 2 ] , v [ 3 ] ) ; stream -> mismatch_seen = stream -> frames_out ; } vpx_img_free ( & enc_img ) ; vpx_img_free ( & dec_img ) ; } "," { struct vp9_ref_frame ref_enc , ref_dec ; ref_enc . idx = = 0 ; ref_dec . idx = 0 ; VP9_GET_REFERENCE , & ref_enc ) ; enc_img = ref_enc . img ; VP9_GET_REFERENCE , & ref_dec ) ; dec_img = ref_dec . img ; # if CONFIG_VP9_HIGHBITDEPTH if ( ( enc_img . fmt & VPX_IMG_FMT_HIGHBITDEPTH ) != ( dec_img . fmt & VPX_IMG_FMT_HIGHBITDEPTH ) ) { if ( enc_img . fmt & VPX_IMG_FMT_HIGHBITDEPTH ) { vpx_img_alloc ( & enc_img , enc_img . fmt - VPX_IMG_FMT_HIGHBITDEPTH , enc_img . d_w , enc_img . d_h , 16 ) ; vpx_img_truncate_16_to_8 ( & enc_img , & ref_enc . img ) ; } if ( dec_img . fmt & VPX_IMG_FMT_HIGHBITDEPTH ) { vpx_img_alloc ( & dec_img , dec_img . fmt - VPX_IMG_FMT_HIGHBITDEPTH , dec_img . d_w , dec_img . d_h , 16 ) ; vpx_img_truncate_16_to_8 ( & dec_img , & ref_dec . img ) ; } } # endif } ctx_exit_on_error ( 4 ] ; # if CONFIG_VP9_HIGHBITDEPTH if ( enc_img . fmt & VPX_IMG_FMT_HIGHBITDEPTH ) { find_mismatch_high ( & enc_img , & dec_img , y , u , v ) ; } else { v ) ; } # else find_mismatch ( & enc_img , & dec_img , y , u , v ) ; # endif ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 467,CWE-119,"CWE-119 static MagickPixelPacket * * AcquirePixelThreadSet ( const Image * image ) { MagickPixelPacket * * pixels ; register ssize_t i , j ; size_t number_threads ; number_threads = ( size_t ) GetMagickResourceLimit ( ThreadResource ) ; pixels = ( MagickPixelPacket * * ) AcquireQuantumMemory ( number_threads , sizeof ( * pixels ) ) ; if ( pixels == ( MagickPixelPacket * * ) NULL ) return ( ( MagickPixelPacket * * ) NULL ) ; ( void ) memset ( pixels , 0 , number_threads * sizeof ( * pixels ) ) ; for ( i = 0 ; i < ( ssize_t ) number_threads ; i ++ ) { pixels [ i ] = ( MagickPixelPacket * ) AcquireQuantumMemory ( image -> columns , sizeof ( * * pixels ) ) ; if ( pixels [ i ] == ( MagickPixelPacket * ) NULL ) return ( DestroyPixelThreadSet ( pixels ) ) ; for ( j = 0 ; j < ( ssize_t ) image -> columns ; j ++ ) GetMagickPixelPacket ( image , & pixels [ i ] [ j ] ) ; } return ( pixels ) ; } "," const Image * images ) { const Image * next ; MagickPixelPacket * * j ; size_t columns , ) ) ; columns = images -> columns ; for ( next = images ; next != ( Image * ) NULL ; next = next -> next ) columns = MagickMax ( next -> columns , columns ) ; for ( i = 0 ) AcquireQuantumMemory ( columns , sizeof ( ssize_t ) columns ; j ) GetMagickPixelPacket ( images , & pixels ",ImageMagick@ImageMagick6/5e409ae7a389cdf2ed17469303be3f3f21cec450,CVE-2019-13300,https://github.com/ImageMagick/ImageMagick6/commit/5e409ae7a389cdf2ed17469303be3f3f21cec450,2019-07-05T01:15Z 468,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 469,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 470,CWE-20,"CWE-20 static int snd_hrtimer_stop ( struct snd_timer * t ) { struct snd_hrtimer * stime = t -> private_data ; atomic_set ( & stime -> running , 0 ) ; return 0 ; } "," 0 ) ; hrtimer_try_to_cancel ( & stime -> hrt ) ; ",torvalds@linux/2ba1fe7a06d3624f9a7586d672b55f08f7c670f3,CVE-2016-2549,https://github.com/torvalds/linux/commit/2ba1fe7a06d3624f9a7586d672b55f08f7c670f3,2016-04-27T17:59Z 471,CWE-119,"CWE-119 static bool ldm_frag_add ( const u8 * data , int size , struct list_head * frags ) { struct frag * f ; struct list_head * item ; int rec , num , group ; BUG_ON ( ! data || ! frags ) ; if ( size < 2 * VBLK_SIZE_HEAD ) { ldm_error ( ""Valueofsizeistosmall."" ) ; return false ; } group = get_unaligned_be32 ( data + 0x08 ) ; rec = get_unaligned_be16 ( data + 0x0C ) ; num = get_unaligned_be16 ( data + 0x0E ) ; if ( ( num < 1 ) || ( num > 4 ) ) { ldm_error ( ""AVBLKclaimstohave%dparts."" , num ) ; return false ; } if ( rec >= num ) { ldm_error ( ""RECvalue(%d)exceedsNUMvalue(%d)"" , rec , num ) ; return false ; } list_for_each ( item , frags ) { f = list_entry ( item , struct frag , list ) ; if ( f -> group == group ) goto found ; } f = kmalloc ( sizeof ( * f ) + size * num , GFP_KERNEL ) ; if ( ! f ) { ldm_crit ( ""Outofmemory."" ) ; return false ; } f -> group = group ; f -> num = num ; f -> rec = rec ; f -> map = 0xFF << num ; list_add_tail ( & f -> list , frags ) ; found : if ( f -> map & ( 1 << rec ) ) { ldm_error ( ""DuplicateVBLK,part%d."" , rec ) ; f -> map &= 0x7F ; return false ; } f -> map |= ( 1 << rec ) ; data += VBLK_SIZE_HEAD ; size -= VBLK_SIZE_HEAD ; memcpy ( f -> data + rec * ( size - VBLK_SIZE_HEAD ) + VBLK_SIZE_HEAD , data , size ) ; return true ; } "," : if ( rec >= f -> num ) { ldm_error ( ""RECvalue(%d)exceedsNUMvalue(%d)"" , rec , f -> num ) ; return false ; } if ( ",torvalds@linux/cae13fe4cc3f24820ffb990c09110626837e85d4,CVE-2011-2182,https://github.com/torvalds/linux/commit/cae13fe4cc3f24820ffb990c09110626837e85d4,2012-06-13T10:24Z 472,CWE-119,"CWE-119 static void estimate_ref_frame_costs ( VP9_COMP * cpi , int segment_id , unsigned int * ref_costs_single , unsigned int * ref_costs_comp , vp9_prob * comp_mode_p ) { VP9_COMMON * const cm = & cpi -> common ; MACROBLOCKD * const xd = & cpi -> mb . e_mbd ; int seg_ref_active = vp9_segfeature_active ( & cm -> seg , segment_id , SEG_LVL_REF_FRAME ) ; if ( seg_ref_active ) { vpx_memset ( ref_costs_single , 0 , MAX_REF_FRAMES * sizeof ( * ref_costs_single ) ) ; vpx_memset ( ref_costs_comp , 0 , MAX_REF_FRAMES * sizeof ( * ref_costs_comp ) ) ; * comp_mode_p = 128 ; } else { vp9_prob intra_inter_p = vp9_get_intra_inter_prob ( cm , xd ) ; vp9_prob comp_inter_p = 128 ; if ( cm -> reference_mode == REFERENCE_MODE_SELECT ) { comp_inter_p = vp9_get_reference_mode_prob ( cm , xd ) ; * comp_mode_p = comp_inter_p ; } else { * comp_mode_p = 128 ; } ref_costs_single [ INTRA_FRAME ] = vp9_cost_bit ( intra_inter_p , 0 ) ; if ( cm -> reference_mode != COMPOUND_REFERENCE ) { vp9_prob ref_single_p1 = vp9_get_pred_prob_single_ref_p1 ( cm , xd ) ; vp9_prob ref_single_p2 = vp9_get_pred_prob_single_ref_p2 ( cm , xd ) ; unsigned int base_cost = vp9_cost_bit ( intra_inter_p , 1 ) ; if ( cm -> reference_mode == REFERENCE_MODE_SELECT ) base_cost += vp9_cost_bit ( comp_inter_p , 0 ) ; ref_costs_single [ LAST_FRAME ] = ref_costs_single [ GOLDEN_FRAME ] = ref_costs_single [ ALTREF_FRAME ] = base_cost ; ref_costs_single [ LAST_FRAME ] += vp9_cost_bit ( ref_single_p1 , 0 ) ; ref_costs_single [ GOLDEN_FRAME ] += vp9_cost_bit ( ref_single_p1 , 1 ) ; ref_costs_single [ ALTREF_FRAME ] += vp9_cost_bit ( ref_single_p1 , 1 ) ; ref_costs_single [ GOLDEN_FRAME ] += vp9_cost_bit ( ref_single_p2 , 0 ) ; ref_costs_single [ ALTREF_FRAME ] += vp9_cost_bit ( ref_single_p2 , 1 ) ; } else { ref_costs_single [ LAST_FRAME ] = 512 ; ref_costs_single [ GOLDEN_FRAME ] = 512 ; ref_costs_single [ ALTREF_FRAME ] = 512 ; } if ( cm -> reference_mode != SINGLE_REFERENCE ) { vp9_prob ref_comp_p = vp9_get_pred_prob_comp_ref_p ( cm , xd ) ; unsigned int base_cost = vp9_cost_bit ( intra_inter_p , 1 ) ; if ( cm -> reference_mode == REFERENCE_MODE_SELECT ) base_cost += vp9_cost_bit ( comp_inter_p , 1 ) ; ref_costs_comp [ LAST_FRAME ] = base_cost + vp9_cost_bit ( ref_comp_p , 0 ) ; ref_costs_comp [ GOLDEN_FRAME ] = base_cost + vp9_cost_bit ( ref_comp_p , 1 ) ; } else { ref_costs_comp [ LAST_FRAME ] = 512 ; ref_costs_comp [ GOLDEN_FRAME ] = 512 ; } } } "," void estimate_ref_frame_costs ( const VP9_COMMON * cm , const MACROBLOCKD * xd , int segment_id , * ref_costs_comp , vpx_prob * comp_mode_p ) comp_mode_p ) { int seg_ref_active = segfeature_active ( & cm -> seg , segment_id , SEG_LVL_REF_FRAME ) ; if ( seg_ref_active ) { memset ( ref_costs_single , ) ) ; memset ( ref_costs_comp , } else { vpx_prob intra_inter_p = vp9_get_intra_inter_prob xd ) ; vpx_prob comp_inter_p = 128 COMPOUND_REFERENCE ) { vpx_prob ref_single_p1 = vp9_get_pred_prob_single_ref_p1 xd ) ; vpx_prob ref_single_p2 = vp9_get_pred_prob_single_ref_p2 SINGLE_REFERENCE ) { vpx_prob ref_comp_p = vp9_get_pred_prob_comp_ref_p ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 473,CWE-119,"CWE-119 static int write_superframe_index ( vpx_codec_alg_priv_t * ctx ) { uint8_t marker = 0xc0 ; unsigned int mask ; int mag , index_sz ; assert ( ctx -> pending_frame_count ) ; assert ( ctx -> pending_frame_count <= 8 ) ; marker |= ctx -> pending_frame_count - 1 ; for ( mag = 0 , mask = 0xff ; mag < 4 ; mag ++ ) { if ( ctx -> pending_frame_magnitude < mask ) break ; mask <<= 8 ; mask |= 0xff ; } marker |= mag << 3 ; index_sz = 2 + ( mag + 1 ) * ctx -> pending_frame_count ; if ( ctx -> pending_cx_data_sz + index_sz < ctx -> cx_data_sz ) { uint8_t * x = ctx -> pending_cx_data + ctx -> pending_cx_data_sz ; int i , j ; * x ++ = marker ; for ( i = 0 ; i < ctx -> pending_frame_count ; i ++ ) { unsigned int this_sz = ( unsigned int ) ctx -> pending_frame_sizes [ i ] ; for ( j = 0 ; j <= mag ; j ++ ) { * x ++ = this_sz & 0xff ; this_sz >>= 8 ; } } * x ++ = marker ; ctx -> pending_cx_data_sz += index_sz ; } return index_sz ; } "," , j ; # ifdef TEST_SUPPLEMENTAL_SUPERFRAME_DATA uint8_t marker_test = 0xc0 ; int mag_test = 2 ; int frames_test = 4 ; int index_sz_test = 2 + mag_test * frames_test ; marker_test |= frames_test - 1 ; marker_test |= ( mag_test - 1 ) << 3 ; * x ++ = marker_test ; for ( i = 0 ; i < mag_test * frames_test ; ++ i ) * x ++ = 0 ; * x ++ = marker_test ; ctx -> pending_cx_data_sz += index_sz_test ; printf ( ""Addedsupplementalsuperframedata\\n"" ) ; # endif += index_sz ; # ifdef TEST_SUPPLEMENTAL_SUPERFRAME_DATA index_sz += index_sz_test ; # endif ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 474,CWE-119,"CWE-119 static int http_receive_data ( HTTPContext * c ) { HTTPContext * c1 ; int len , loop_run = 0 ; while ( c -> chunked_encoding && ! c -> chunk_size && c -> buffer_end > c -> buffer_ptr ) { len = recv ( c -> fd , c -> buffer_ptr , 1 , 0 ) ; if ( len < 0 ) { if ( ff_neterrno ( ) != AVERROR ( EAGAIN ) && ff_neterrno ( ) != AVERROR ( EINTR ) ) goto fail ; return 0 ; } else if ( len == 0 ) { goto fail ; } else if ( c -> buffer_ptr - c -> buffer >= 2 && ! memcmp ( c -> buffer_ptr - 1 , ""\\r\\n"" , 2 ) ) { c -> chunk_size = strtol ( c -> buffer , 0 , 16 ) ; if ( c -> chunk_size == 0 ) goto fail ; c -> buffer_ptr = c -> buffer ; break ; } else if ( ++ loop_run > 10 ) goto fail ; else c -> buffer_ptr ++ ; } if ( c -> buffer_end > c -> buffer_ptr ) { len = recv ( c -> fd , c -> buffer_ptr , FFMIN ( c -> chunk_size , c -> buffer_end - c -> buffer_ptr ) , 0 ) ; if ( len < 0 ) { if ( ff_neterrno ( ) != AVERROR ( EAGAIN ) && ff_neterrno ( ) != AVERROR ( EINTR ) ) goto fail ; } else if ( len == 0 ) goto fail ; else { c -> chunk_size -= len ; c -> buffer_ptr += len ; c -> data_count += len ; update_datarate ( & c -> datarate , c -> data_count ) ; } } if ( c -> buffer_ptr - c -> buffer >= 2 && c -> data_count > FFM_PACKET_SIZE ) { if ( c -> buffer [ 0 ] != 'f' || c -> buffer [ 1 ] != 'm' ) { http_log ( ""Feedstreamhasbecomedesynchronized--disconnecting\\n"" ) ; goto fail ; } } if ( c -> buffer_ptr >= c -> buffer_end ) { FFServerStream * feed = c -> stream ; if ( c -> data_count > FFM_PACKET_SIZE ) { if ( lseek ( c -> feed_fd , feed -> feed_write_index , SEEK_SET ) == - 1 ) http_log ( ""Seekto%"" PRId64 ""failed\\n"" , feed -> feed_write_index ) ; if ( write ( c -> feed_fd , c -> buffer , FFM_PACKET_SIZE ) < 0 ) { http_log ( ""Errorwritingtofeedfile:%s\\n"" , strerror ( errno ) ) ; goto fail ; } feed -> feed_write_index += FFM_PACKET_SIZE ; if ( feed -> feed_write_index > c -> stream -> feed_size ) feed -> feed_size = feed -> feed_write_index ; if ( c -> stream -> feed_max_size && feed -> feed_write_index >= c -> stream -> feed_max_size ) feed -> feed_write_index = FFM_PACKET_SIZE ; if ( ffm_write_write_index ( c -> feed_fd , feed -> feed_write_index ) < 0 ) { http_log ( ""Errorwritingindextofeedfile:%s\\n"" , strerror ( errno ) ) ; goto fail ; } for ( c1 = first_http_ctx ; c1 ; c1 = c1 -> next ) { if ( c1 -> state == HTTPSTATE_WAIT_FEED && c1 -> stream -> feed == c -> stream -> feed ) c1 -> state = HTTPSTATE_SEND_DATA ; } } else { AVFormatContext * s = avformat_alloc_context ( ) ; AVIOContext * pb ; AVInputFormat * fmt_in ; int i ; if ( ! s ) goto fail ; fmt_in = av_find_input_format ( feed -> fmt -> name ) ; if ( ! fmt_in ) goto fail ; pb = avio_alloc_context ( c -> buffer , c -> buffer_end - c -> buffer , 0 , NULL , NULL , NULL , NULL ) ; if ( ! pb ) goto fail ; pb -> seekable = 0 ; s -> pb = pb ; if ( avformat_open_input ( & s , c -> stream -> feed_filename , fmt_in , NULL ) < 0 ) { av_freep ( & pb ) ; goto fail ; } if ( s -> nb_streams != feed -> nb_streams ) { avformat_close_input ( & s ) ; av_freep ( & pb ) ; http_log ( ""Feed\'%s\'streamnumberdoesnotmatchregisteredfeed\\n"" , c -> stream -> feed_filename ) ; goto fail ; } for ( i = 0 ; i < s -> nb_streams ; i ++ ) { LayeredAVStream * fst = feed -> streams [ i ] ; AVStream * st = s -> streams [ i ] ; avcodec_parameters_to_context ( fst -> codec , st -> codecpar ) ; avcodec_parameters_from_context ( fst -> codecpar , fst -> codec ) ; } avformat_close_input ( & s ) ; av_freep ( & pb ) ; } c -> buffer_ptr = c -> buffer ; } return 0 ; fail : c -> stream -> feed_opened = 0 ; close ( c -> feed_fd ) ; for ( c1 = first_http_ctx ; c1 ; c1 = c1 -> next ) { if ( c1 -> state == HTTPSTATE_WAIT_FEED && c1 -> stream -> feed == c -> stream -> feed ) c1 -> state = HTTPSTATE_SEND_DATA_TRAILER ; } return - 1 ; } "," c -> chunk_size <= 0 ) { c -> chunk_size = 0 ; goto fail ; } c -> buffer_ptr ; else { av_assert0 ( len <= c -> chunk_size ) ; ",FFmpeg@FFmpeg/a5d25faa3f4b18dac737fdb35d0dd68eb0dc2156,CVE-2016-10192,https://github.com/FFmpeg/FFmpeg/commit/a5d25faa3f4b18dac737fdb35d0dd68eb0dc2156,2017-02-09T15:59Z 475,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 476,CWE-119,"CWE-119 bool f2fs_init_extent_tree ( struct inode * inode , struct f2fs_extent * i_ext ) { struct f2fs_sb_info * sbi = F2FS_I_SB ( inode ) ; struct extent_tree * et ; struct extent_node * en ; struct extent_info ei ; if ( ! f2fs_may_extent_tree ( inode ) ) { if ( i_ext && i_ext -> len ) { i_ext -> len = 0 ; return true ; } return false ; } et = __grab_extent_tree ( inode ) ; if ( ! i_ext || ! i_ext -> len ) return false ; get_extent_info ( & ei , i_ext ) ; write_lock ( & et -> lock ) ; if ( atomic_read ( & et -> node_cnt ) ) goto out ; en = __init_extent_tree ( sbi , et , & ei ) ; if ( en ) { spin_lock ( & sbi -> extent_lock ) ; list_add_tail ( & en -> list , & sbi -> extent_list ) ; spin_unlock ( & sbi -> extent_lock ) ; } out : write_unlock ( & et -> lock ) ; return false ; } "," i_ext ) { bool ret = __f2fs_init_extent_tree ( inode , i_ext ) ; if if ( ! F2FS_I ( inode ) -> extent_tree ) set_inode_flag ( inode , FI_NO_EXTENT ) ; return ) ; return ret ; } ",torvalds@linux/dad48e73127ba10279ea33e6dbc8d3905c4d31c0,CVE-2017-18193,https://github.com/torvalds/linux/commit/dad48e73127ba10279ea33e6dbc8d3905c4d31c0,2018-02-22T15:29Z 477,CWE-399,"CWE-399 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 478,CWE-119,"CWE-119 static void write_image_file ( const vpx_image_t * img , const int planes [ 3 ] , FILE * file ) { int i , y ; for ( i = 0 ; i < 3 ; ++ i ) { const int plane = planes [ i ] ; const 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 ) ; for ( y = 0 ; y < h ; ++ y ) { fwrite ( buf , 1 , w , file ) ; buf += stride ; } } } "," , y ; # if CONFIG_VP9_HIGHBITDEPTH const int bytes_per_sample = ( ( img -> fmt & VPX_IMG_FMT_HIGHBITDEPTH ) ? 2 : 1 ) ; # else const int bytes_per_sample = 1 ; # endif ( buf , bytes_per_sample , w , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 479,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 480,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 481,CWE-358,"CWE-358 int udp_recvmsg ( struct sock * sk , struct msghdr * msg , size_t len , int noblock , int flags , int * addr_len ) { struct inet_sock * inet = inet_sk ( sk ) ; DECLARE_SOCKADDR ( struct sockaddr_in * , sin , 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 ( flags & MSG_ERRQUEUE ) return ip_recv_error ( sk , msg , len , addr_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_msg ( skb , sizeof ( struct udphdr ) , msg , copied ) ; else { err = skb_copy_and_csum_datagram_msg ( skb , sizeof ( struct udphdr ) , msg ) ; 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 ) ) ; * addr_len = sizeof ( * sin ) ; } if ( inet -> cmsg_flags ) ip_cmsg_recv_offset ( msg , skb , sizeof ( struct udphdr ) ) ; 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 ) ; cond_resched ( ) ; msg -> msg_flags &= ~ MSG_TRUNC ; goto try_again ; } "," ( sk ) ; bool checksum_valid = false partial_cov ) { checksum_valid = ! udp_lib_checksum_complete ( skb ( skb ) ; if ( ! checksum_valid } if ( checksum_valid || ",torvalds@linux/197c949e7798fbf28cfadc69d9ca0c2abbf93191,CVE-2016-10229,https://github.com/torvalds/linux/commit/197c949e7798fbf28cfadc69d9ca0c2abbf93191,2017-04-04T05:59Z 482,CWE-119,"CWE-119 static vpx_codec_err_t decoder_peek_si_internal ( const uint8_t * data , unsigned int data_sz , vpx_codec_stream_info_t * si , int * is_intra_only , vpx_decrypt_cb decrypt_cb , void * decrypt_state ) { int intra_only_flag = 0 ; uint8_t clear_buffer [ 9 ] ; if ( data + data_sz <= data ) return VPX_CODEC_INVALID_PARAM ; si -> is_kf = 0 ; si -> w = si -> h = 0 ; if ( decrypt_cb ) { data_sz = VPXMIN ( sizeof ( clear_buffer ) , data_sz ) ; decrypt_cb ( decrypt_state , data , clear_buffer , data_sz ) ; data = clear_buffer ; } { int show_frame ; int error_resilient ; struct vpx_read_bit_buffer rb = { data , data + data_sz , 0 , NULL , NULL } ; const int frame_marker = vpx_rb_read_literal ( & rb , 2 ) ; const BITSTREAM_PROFILE profile = vp9_read_profile ( & rb ) ; if ( frame_marker != VP9_FRAME_MARKER ) return VPX_CODEC_UNSUP_BITSTREAM ; if ( profile >= MAX_PROFILES ) return VPX_CODEC_UNSUP_BITSTREAM ; if ( ( profile >= 2 && data_sz <= 1 ) || data_sz < 1 ) return VPX_CODEC_UNSUP_BITSTREAM ; if ( vpx_rb_read_bit ( & rb ) ) { vpx_rb_read_literal ( & rb , 3 ) ; return VPX_CODEC_OK ; } if ( data_sz <= 8 ) return VPX_CODEC_UNSUP_BITSTREAM ; si -> is_kf = ! vpx_rb_read_bit ( & rb ) ; show_frame = vpx_rb_read_bit ( & rb ) ; error_resilient = vpx_rb_read_bit ( & rb ) ; if ( si -> is_kf ) { if ( ! vp9_read_sync_code ( & rb ) ) return VPX_CODEC_UNSUP_BITSTREAM ; if ( ! parse_bitdepth_colorspace_sampling ( profile , & rb ) ) return VPX_CODEC_UNSUP_BITSTREAM ; vp9_read_frame_size ( & rb , ( int * ) & si -> w , ( int * ) & si -> h ) ; } else { intra_only_flag = show_frame ? 0 : vpx_rb_read_bit ( & rb ) ; rb . bit_offset += error_resilient ? 0 : 2 ; if ( intra_only_flag ) { if ( ! vp9_read_sync_code ( & rb ) ) return VPX_CODEC_UNSUP_BITSTREAM ; if ( profile > PROFILE_0 ) { if ( ! parse_bitdepth_colorspace_sampling ( profile , & rb ) ) return VPX_CODEC_UNSUP_BITSTREAM ; } rb . bit_offset += REF_FRAMES ; vp9_read_frame_size ( & rb , ( int * ) & si -> w , ( int * ) & si -> h ) ; } } } if ( is_intra_only != NULL ) * is_intra_only = intra_only_flag ; return VPX_CODEC_OK ; } "," uint8_t clear_buffer [ 10 ] ; if clear_buffer ; } if ( data_sz < 1 ) return VPX_CODEC_UNSUP_BITSTREAM ; ; if ( vpx_rb_read_bit ( & rb ) ) { if ( profile > 2 && data_sz 2 && data_sz < 2 ) return VPX_CODEC_UNSUP_BITSTREAM ; vpx_rb_read_literal ( & if ( data_sz < 10 ) return VPX_CODEC_UNSUP_BITSTREAM ",external@libvpx/4974dcbd0289a2530df2ee2a25b5f92775df80da,CVE-2016-3881,https://android.googlesource.com/platform/external/libvpx/+/4974dcbd0289a2530df2ee2a25b5f92775df80da,2016-09-11T21:59Z 483,CWE-200,"CWE-200 int keepalived_main ( int argc , char * * argv ) { bool report_stopped = true ; struct utsname uname_buf ; char * end ; set_time_now ( ) ; save_cmd_line_options ( argc , argv ) ; debug = 0 ; # ifndef _DEBUG_ prog_type = PROG_TYPE_PARENT ; # endif # 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 openlog ( PACKAGE_NAME , LOG_PID , log_facility ) ; # ifdef _MEM_CHECK_ mem_log_init ( PACKAGE_NAME , ""Parentprocess"" ) ; # endif if ( uname ( & uname_buf ) ) log_message ( LOG_INFO , ""Unabletogetuname()information-error%d"" , errno ) ; else { os_major = ( unsigned ) strtoul ( uname_buf . release , & end , 10 ) ; if ( * end != '.' ) os_major = 0 ; else { os_minor = ( unsigned ) strtoul ( end + 1 , & end , 10 ) ; if ( * end != '.' ) os_major = 0 ; else { if ( ! isdigit ( end [ 1 ] ) ) os_major = 0 ; else os_release = ( unsigned ) strtoul ( end + 1 , & end , 10 ) ; } } if ( ! os_major ) log_message ( LOG_INFO , ""Unabletoparsekernelversion%s"" , uname_buf . release ) ; if ( ! config_id ) { end = strchrnul ( uname_buf . nodename , '.' ) ; config_id = MALLOC ( ( size_t ) ( end - uname_buf . nodename ) + 1 ) ; strncpy ( config_id , uname_buf . nodename , ( size_t ) ( end - uname_buf . nodename ) ) ; config_id [ end - uname_buf . nodename ] = '\\0' ; } } if ( parse_cmdline ( argc , argv ) ) { closelog ( ) ; if ( ! __test_bit ( NO_SYSLOG_BIT , & debug ) ) openlog ( PACKAGE_NAME , LOG_PID | ( ( __test_bit ( LOG_CONSOLE_BIT , & debug ) ) ? LOG_CONS : 0 ) , log_facility ) ; } if ( __test_bit ( LOG_CONSOLE_BIT , & debug ) ) enable_console_log ( ) ; # ifdef GIT_COMMIT log_message ( LOG_INFO , ""Starting%s,gitcommit%s"" , version_string , GIT_COMMIT ) ; # else log_message ( LOG_INFO , ""Starting%s"" , version_string ) ; # endif core_dump_init ( ) ; if ( os_major ) { if ( KERNEL_VERSION ( os_major , os_minor , os_release ) < LINUX_VERSION_CODE ) { log_message ( LOG_INFO , ""WARNING-keepalivedwasbuildfornewerLinux%d.%d.%d,runningon%s%s%s"" , ( LINUX_VERSION_CODE >> 16 ) & 0xff , ( LINUX_VERSION_CODE >> 8 ) & 0xff , ( LINUX_VERSION_CODE ) & 0xff , uname_buf . sysname , uname_buf . release , uname_buf . version ) ; } else { log_message ( LOG_INFO , ""Runningon%s%s%s(builtforLinux%d.%d.%d)"" , uname_buf . sysname , uname_buf . release , uname_buf . version , ( LINUX_VERSION_CODE >> 16 ) & 0xff , ( LINUX_VERSION_CODE >> 8 ) & 0xff , ( LINUX_VERSION_CODE ) & 0xff ) ; } } # ifndef _DEBUG_ log_command_line ( 0 ) ; # endif if ( ! check_conf_file ( conf_file ) ) { if ( __test_bit ( CONFIG_TEST_BIT , & debug ) ) config_test_exit ( ) ; goto end ; } global_data = alloc_global_data ( ) ; read_config_file ( ) ; init_global_data ( global_data , NULL ) ; # if HAVE_DECL_CLONE_NEWNET if ( override_namespace ) { if ( global_data -> network_namespace ) { log_message ( LOG_INFO , ""Overridingconfignet_namespace\'%s\'withcommandlinenamespace\'%s\'"" , global_data -> network_namespace , override_namespace ) ; FREE ( global_data -> network_namespace ) ; } global_data -> network_namespace = override_namespace ; override_namespace = NULL ; } # endif if ( ! __test_bit ( CONFIG_TEST_BIT , & debug ) && ( global_data -> instance_name # if HAVE_DECL_CLONE_NEWNET || global_data -> network_namespace # endif ) ) { if ( ( syslog_ident = make_syslog_ident ( PACKAGE_NAME ) ) ) { log_message ( LOG_INFO , ""Changingsyslogidentto%s"" , syslog_ident ) ; closelog ( ) ; openlog ( syslog_ident , LOG_PID | ( ( __test_bit ( LOG_CONSOLE_BIT , & debug ) ) ? LOG_CONS : 0 ) , log_facility ) ; } else log_message ( LOG_INFO , ""Unabletochangesyslogident"" ) ; use_pid_dir = true ; open_log_file ( log_file_name , NULL , # if HAVE_DECL_CLONE_NEWNET global_data -> network_namespace , # else NULL , # endif global_data -> instance_name ) ; } set_child_finder_name ( find_keepalived_child_name ) ; if ( ! __test_bit ( CONFIG_TEST_BIT , & debug ) ) { if ( use_pid_dir ) { create_pid_dir ( ) ; } } # if HAVE_DECL_CLONE_NEWNET if ( global_data -> network_namespace ) { if ( global_data -> network_namespace && ! set_namespaces ( global_data -> network_namespace ) ) { log_message ( LOG_ERR , ""Unabletosetnetworknamespace%s-exiting"" , global_data -> network_namespace ) ; goto end ; } } # endif if ( ! __test_bit ( CONFIG_TEST_BIT , & debug ) ) { if ( global_data -> instance_name ) { if ( ! main_pidfile && ( main_pidfile = make_pidfile_name ( KEEPALIVED_PID_DIR KEEPALIVED_PID_FILE , global_data -> instance_name , PID_EXTENSION ) ) ) free_main_pidfile = true ; # ifdef _WITH_LVS_ if ( ! checkers_pidfile && ( checkers_pidfile = make_pidfile_name ( KEEPALIVED_PID_DIR CHECKERS_PID_FILE , global_data -> instance_name , PID_EXTENSION ) ) ) free_checkers_pidfile = true ; # endif # ifdef _WITH_VRRP_ if ( ! vrrp_pidfile && ( vrrp_pidfile = make_pidfile_name ( KEEPALIVED_PID_DIR VRRP_PID_FILE , global_data -> instance_name , PID_EXTENSION ) ) ) free_vrrp_pidfile = true ; # endif # ifdef _WITH_BFD_ if ( ! bfd_pidfile && ( bfd_pidfile = make_pidfile_name ( KEEPALIVED_PID_DIR VRRP_PID_FILE , global_data -> instance_name , PID_EXTENSION ) ) ) free_bfd_pidfile = true ; # endif } if ( use_pid_dir ) { if ( ! main_pidfile ) main_pidfile = KEEPALIVED_PID_DIR KEEPALIVED_PID_FILE PID_EXTENSION ; # ifdef _WITH_LVS_ if ( ! checkers_pidfile ) checkers_pidfile = KEEPALIVED_PID_DIR CHECKERS_PID_FILE PID_EXTENSION ; # endif # ifdef _WITH_VRRP_ if ( ! vrrp_pidfile ) vrrp_pidfile = KEEPALIVED_PID_DIR VRRP_PID_FILE PID_EXTENSION ; # endif # ifdef _WITH_BFD_ if ( ! bfd_pidfile ) bfd_pidfile = KEEPALIVED_PID_DIR BFD_PID_FILE PID_EXTENSION ; # endif } else { if ( ! main_pidfile ) main_pidfile = PID_DIR KEEPALIVED_PID_FILE PID_EXTENSION ; # ifdef _WITH_LVS_ if ( ! checkers_pidfile ) checkers_pidfile = PID_DIR CHECKERS_PID_FILE PID_EXTENSION ; # endif # ifdef _WITH_VRRP_ if ( ! vrrp_pidfile ) vrrp_pidfile = PID_DIR VRRP_PID_FILE PID_EXTENSION ; # endif # ifdef _WITH_BFD_ if ( ! bfd_pidfile ) bfd_pidfile = PID_DIR BFD_PID_FILE PID_EXTENSION ; # endif } if ( keepalived_running ( daemon_mode ) ) { log_message ( LOG_INFO , ""daemonisalreadyrunning"" ) ; report_stopped = false ; goto end ; } } if ( ! __test_bit ( DONT_FORK_BIT , & debug ) && xdaemon ( false , false , true ) > 0 ) { closelog ( ) ; FREE_PTR ( config_id ) ; FREE_PTR ( orig_core_dump_pattern ) ; close_std_fd ( ) ; exit ( 0 ) ; } umask ( 0 ) ; # ifdef _MEM_CHECK_ enable_mem_log_termination ( ) ; # endif if ( __test_bit ( CONFIG_TEST_BIT , & debug ) ) { validate_config ( ) ; config_test_exit ( ) ; } if ( ! pidfile_write ( main_pidfile , getpid ( ) ) ) goto end ; master = thread_make_master ( ) ; signal_init ( ) ; if ( ! start_keepalived ( ) ) log_message ( LOG_INFO , ""Warning-keepalivedhasnoconfigurationtorun"" ) ; initialise_debug_options ( ) ; # ifdef THREAD_DUMP register_parent_thread_addresses ( ) ; # endif launch_thread_scheduler ( master ) ; stop_keepalived ( ) ; # ifdef THREAD_DUMP deregister_thread_addresses ( ) ; # endif end : if ( report_stopped ) { # ifdef GIT_COMMIT log_message ( LOG_INFO , ""Stopped%s,gitcommit%s"" , version_string , GIT_COMMIT ) ; # else log_message ( LOG_INFO , ""Stopped%s"" , version_string ) ; # endif } # if HAVE_DECL_CLONE_NEWNET if ( global_data && global_data -> network_namespace ) clear_namespaces ( ) ; # endif if ( use_pid_dir ) remove_pid_dir ( ) ; if ( orig_core_dump_pattern ) update_core_dump_pattern ( orig_core_dump_pattern ) ; free_parent_mallocs_startup ( false ) ; free_parent_mallocs_exit ( ) ; free_global_data ( global_data ) ; closelog ( ) ; # ifndef _MEM_CHECK_LOG_ FREE_PTR ( syslog_ident ) ; # else if ( syslog_ident ) free ( syslog_ident ) ; # endif close_std_fd ( ) ; exit ( KEEPALIVED_EXIT_OK ) ; } "," ; # endif umask ( 022 ) ; ( ) ; global_data -> umask = umask_val ; ) ; } # ifdef _MEM_CHECK_ ",acassen@keepalived/c6247a9ef2c7b33244ab1d3aa5d629ec49f0a067,CVE-2018-19045,https://github.com/acassen/keepalived/commit/c6247a9ef2c7b33244ab1d3aa5d629ec49f0a067,2018-11-08T20:29Z 484,CWE-125,"CWE-125 static bool r_bin_mdmp_init_directory ( struct r_bin_mdmp_obj * obj ) { int i ; ut8 * directory_base ; struct minidump_directory * entry ; directory_base = obj -> b -> buf + obj -> hdr -> stream_directory_rva ; sdb_num_set ( obj -> kv , ""mdmp_directory.offset"" , obj -> hdr -> stream_directory_rva , 0 ) ; sdb_set ( obj -> kv , ""mdmp_directory.format"" , ""[4]E?"" ""(mdmp_stream_type)StreamType"" ""(mdmp_location_descriptor)Location"" , 0 ) ; for ( i = 0 ; i < ( int ) obj -> hdr -> number_of_streams ; i ++ ) { entry = ( struct minidump_directory * ) ( directory_base + ( i * sizeof ( struct minidump_directory ) ) ) ; r_bin_mdmp_init_directory_entry ( obj , entry ) ; } return true ; } "," int i ; struct minidump_directory entry ; sdb_num_set ( 0 ) ; ut64 rvadir = obj -> hdr -> stream_directory_rva ; ++ ) { ut32 delta = i * sizeof struct minidump_directory ) ; int r = r_buf_read_at ( obj -> b , rvadir + delta , ( ut8 * ) & entry , sizeof ( struct minidump_directory ) ) ; if ( r ) { ( obj , & entry ) ; } ",radareorg@radare2/eb7deb281df54771fb8ecf5890dc325a7d22d3e2,CVE-2018-14016,https://github.com/radareorg/radare2/commit/eb7deb281df54771fb8ecf5890dc325a7d22d3e2,2018-07-12T20:29Z 485,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"" ",iortcw@iortcw/11a83410153756ae350a82ed41b08d128ff7f998,CVE-2017-6903,https://github.com/iortcw/iortcw/commit/11a83410153756ae350a82ed41b08d128ff7f998,2017-03-14T22:59Z 486,CWE-89,"CWE-89 int msPostGISLayerSetTimeFilter ( layerObj * lp , const char * timestring , const char * timefield ) { char * * atimes , * * aranges = NULL ; int numtimes = 0 , i = 0 , numranges = 0 ; size_t buffer_size = 512 ; char buffer [ 512 ] , bufferTmp [ 512 ] ; buffer [ 0 ] = '\\0' ; bufferTmp [ 0 ] = '\\0' ; if ( ! lp || ! timestring || ! timefield ) return MS_FALSE ; if ( strstr ( timestring , "","" ) == NULL && strstr ( timestring , ""/"" ) == NULL ) { createPostgresTimeCompareSimple ( timefield , timestring , buffer , buffer_size ) ; } else { atimes = msStringSplit ( timestring , ',' , & numtimes ) ; if ( atimes == NULL || numtimes < 1 ) return MS_FALSE ; strlcat ( buffer , ""("" , buffer_size ) ; for ( i = 0 ; i < numtimes ; i ++ ) { if ( i != 0 ) { strlcat ( buffer , ""OR"" , buffer_size ) ; } strlcat ( buffer , ""("" , buffer_size ) ; aranges = msStringSplit ( atimes [ i ] , '/' , & numranges ) ; if ( ! aranges ) return MS_FALSE ; if ( numranges == 1 ) { createPostgresTimeCompareSimple ( timefield , atimes [ i ] , bufferTmp , buffer_size ) ; strlcat ( buffer , bufferTmp , buffer_size ) ; } else if ( numranges == 2 ) { createPostgresTimeCompareRange ( timefield , aranges [ 0 ] , aranges [ 1 ] , bufferTmp , buffer_size ) ; strlcat ( buffer , bufferTmp , buffer_size ) ; } else { return MS_FALSE ; } msFreeCharArray ( aranges , numranges ) ; strlcat ( buffer , "")"" , buffer_size ) ; } strlcat ( buffer , "")"" , buffer_size ) ; msFreeCharArray ( atimes , numtimes ) ; } if ( ! * buffer ) { return MS_FALSE ; } if ( lp -> filteritem ) free ( lp -> filteritem ) ; lp -> filteritem = msStrdup ( timefield ) ; if ( & lp -> filter ) { if ( lp -> filter . type == MS_EXPRESSION ) { snprintf ( bufferTmp , buffer_size , ""(%s)and%s"" , lp -> filter . string , buffer ) ; loadExpressionString ( & lp -> filter , bufferTmp ) ; } else { freeExpression ( & lp -> filter ) ; loadExpressionString ( & lp -> filter , buffer ) ; } } return MS_TRUE ; } "," return MS_FALSE ; if ( strchr ( timestring , '\\'' ) || strchr ( timestring , '\\\\' ) ) { msSetError ( MS_MISCERR , ""Invalidtimefilter."" , ""msPostGISLayerSetTimeFilter()"" ) ; return MS_FALSE ; } ",mapserver@mapserver/3a10f6b829297dae63492a8c63385044bc6953ed,CVE-2013-7262,https://github.com/mapserver/mapserver/commit/3a10f6b829297dae63492a8c63385044bc6953ed,2014-01-05T20:55Z 487,CWE-20,"CWE-20 void kvm_lapic_sync_to_vapic ( struct kvm_vcpu * vcpu ) { u32 data , tpr ; int max_irr , max_isr ; struct kvm_lapic * apic = vcpu -> arch . apic ; void * vapic ; apic_sync_pv_eoi_to_guest ( vcpu , apic ) ; if ( ! test_bit ( KVM_APIC_CHECK_VAPIC , & vcpu -> arch . apic_attention ) ) return ; tpr = kvm_apic_get_reg ( apic , APIC_TASKPRI ) & 0xff ; max_irr = apic_find_highest_irr ( apic ) ; if ( max_irr < 0 ) max_irr = 0 ; max_isr = apic_find_highest_isr ( apic ) ; if ( max_isr < 0 ) max_isr = 0 ; data = ( tpr & 0xff ) | ( ( max_isr & 0xf0 ) << 8 ) | ( max_irr << 24 ) ; vapic = kmap_atomic ( vcpu -> arch . apic -> vapic_page ) ; * ( u32 * ) ( vapic + offset_in_page ( vcpu -> arch . apic -> vapic_addr ) ) = data ; kunmap_atomic ( vapic ) ; } "," arch . apic ; apic_sync_pv_eoi_to_guest ( 24 ) ; kvm_write_guest_cached ( vcpu -> kvm , & vcpu -> arch . apic -> vapic_cache , & data , sizeof ( u32 ) ) ; } ",torvalds@linux/fda4e2e85589191b123d31cdc21fd33ee70f50fd,CVE-2013-6368,https://github.com/torvalds/linux/commit/fda4e2e85589191b123d31cdc21fd33ee70f50fd,2013-12-14T18:08Z 488,CWE-369,"CWE-369 static void box_blur_line ( gint box_width , gint even_offset , guchar * src , guchar * dest , gint len , gint bpp ) { gint i ; gint lead ; gint output ; gint trail ; gint * ac ; ac = g_new0 ( gint , bpp ) ; lead = 0 ; if ( box_width % 2 != 0 ) { output = lead - ( box_width - 1 ) / 2 ; trail = lead - box_width ; } else { if ( even_offset == 1 ) { output = lead + 1 - box_width / 2 ; trail = lead - box_width ; } else if ( even_offset == - 1 ) { output = lead - box_width / 2 ; trail = lead - box_width ; } else { g_assert_not_reached ( ) ; } } for ( i = 0 ; i < bpp ; i ++ ) ac [ i ] = 0 ; while ( output < len ) { guint coverage = ( lead < len ? lead : len - 1 ) - ( trail >= 0 ? trail : - 1 ) ; # ifdef READABLE_BOXBLUR_CODE for ( i = 0 ; i < bpp ; i ++ ) { if ( lead < len ) ac [ i ] += src [ bpp * lead + i ] ; if ( trail >= 0 ) ac [ i ] -= src [ bpp * trail + i ] ; if ( output >= 0 ) dest [ bpp * output + i ] = ( ac [ i ] + ( coverage >> 1 ) ) / coverage ; } # endif if ( lead < len ) { if ( trail >= 0 ) { for ( i = 0 ; i < bpp ; i ++ ) { ac [ i ] += src [ bpp * lead + i ] ; ac [ i ] -= src [ bpp * trail + i ] ; dest [ bpp * output + i ] = ( ac [ i ] + ( coverage >> 1 ) ) / coverage ; } } else if ( output >= 0 ) { for ( i = 0 ; i < bpp ; i ++ ) { ac [ i ] += src [ bpp * lead + i ] ; dest [ bpp * output + i ] = ( ac [ i ] + ( coverage >> 1 ) ) / coverage ; } } else { for ( i = 0 ; i < bpp ; i ++ ) ac [ i ] += src [ bpp * lead + i ] ; } } else if ( trail >= 0 ) { for ( i = 0 ; i < bpp ; i ++ ) { ac [ i ] -= src [ bpp * trail + i ] ; dest [ bpp * output + i ] = ( ac [ i ] + ( coverage >> 1 ) ) / coverage ; } } else if ( output >= 0 ) { for ( i = 0 ; i < bpp ; i ++ ) dest [ bpp * output + i ] = ( ac [ i ] + ( coverage >> 1 ) ) / coverage ; } lead ++ ; output ++ ; trail ++ ; } g_free ( ac ) ; } "," gint * ac ; g_assert ( box_width > 0 ) ",GNOME@librsvg/ecf9267a24b2c3c0cd211dbdfa9ef2232511972a,CVE-2017-11464,https://github.com/GNOME/librsvg/commit/ecf9267a24b2c3c0cd211dbdfa9ef2232511972a,2017-07-19T21:29Z 489,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 490,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 491,CWE-264,"CWE-264 static void start_daemon ( ) { struct usb_sock_t * usb_sock ; if ( g_options . noprinter_mode == 0 ) { usb_sock = usb_open ( ) ; if ( usb_sock == NULL ) goto cleanup_usb ; } else usb_sock = NULL ; uint16_t desired_port = g_options . desired_port ; struct tcp_sock_t * tcp_socket ; while ( ( tcp_socket = tcp_open ( desired_port ) ) == NULL && g_options . only_desired_port == 0 ) { desired_port ++ ; if ( desired_port == 1 || desired_port == 0 ) desired_port = 49152 ; } if ( tcp_socket == NULL ) goto cleanup_tcp ; uint16_t real_port = tcp_port_number_get ( tcp_socket ) ; if ( desired_port != 0 && g_options . only_desired_port == 1 && desired_port != real_port ) { ERR ( ""Receivedportnumberdidnotmatchrequestedportnumber."" ""Therequestedportnumbermaybetoohigh."" ) ; goto cleanup_tcp ; } printf ( ""%u|"" , real_port ) ; fflush ( stdout ) ; uint16_t pid ; if ( ! g_options . nofork_mode && ( pid = fork ( ) ) > 0 ) { printf ( ""%u|"" , pid ) ; exit ( 0 ) ; } if ( usb_can_callback ( usb_sock ) ) usb_register_callback ( usb_sock ) ; for ( ; ; ) { struct service_thread_param * args = calloc ( 1 , sizeof ( * args ) ) ; if ( args == NULL ) { ERR ( ""Failedtoallocspaceforthreadargs"" ) ; goto cleanup_thread ; } args -> usb_sock = usb_sock ; args -> tcp = tcp_conn_accept ( tcp_socket ) ; if ( args -> tcp == NULL ) { ERR ( ""Failedtoopentcpconnection"" ) ; goto cleanup_thread ; } int status = pthread_create ( & args -> thread_handle , NULL , & service_connection , args ) ; if ( status ) { ERR ( ""Failedtospawnthread,error%d"" , status ) ; goto cleanup_thread ; } continue ; cleanup_thread : if ( args != NULL ) { if ( args -> tcp != NULL ) tcp_conn_close ( args -> tcp ) ; free ( args ) ; } break ; } cleanup_tcp : if ( tcp_socket != NULL ) tcp_close ( tcp_socket ) ; cleanup_usb : if ( usb_sock != NULL ) usb_close ( usb_sock ) ; return ; } "," tcp_sock_t * tcp_socket = NULL , * tcp6_socket = NULL ; for ( ; ; ) { tcp_socket = tcp_open ( desired_port ) ; tcp6_socket = tcp6_open ( desired_port ) ; if ( tcp_socket || tcp6_socket || g_options . only_desired_port g_options . only_desired_port ) break ; desired_port ++ ; = 49152 ; NOTE ( ""Accesstodesiredportfailed,tryingalternativeport%d"" , desired_port ) ; } if ( tcp_socket == NULL && tcp6_socket == NULL ) ; uint16_t real_port ; if ( tcp_socket ) real_port tcp_port_number_get ( tcp_socket ) ; else real_port = tcp_port_number_get ( tcp6_socket stdout ) ; NOTE ( ""Port:%d,IPv4%savailable,IPv6%savailable"" , real_port , tcp_socket ? """" : ""not"" , tcp6_socket ? """" : ""not"" ) ; -> tcp = tcp_conn_select ( tcp_socket , tcp6_socket ) ; if tcp_socket ) ; if ( tcp6_socket != NULL ) tcp_close ( tcp6_socket ) ; ",tillkamppeter@ippusbxd/46844402bca7a38fc224483ba6f0a93c4613203f,CVE-2015-6520,https://github.com/tillkamppeter/ippusbxd/commit/46844402bca7a38fc224483ba6f0a93c4613203f,2015-09-01T14:59Z 492,CWE-252,"CWE-252 static void init_syntax_once ( ) { register int c ; static int done ; if ( done ) return ; bzero ( re_syntax_table , sizeof re_syntax_table ) ; for ( c = 'a' ; c <= 'z' ; c ++ ) re_syntax_table [ c ] = Sword ; for ( c = 'A' ; c <= 'Z' ; c ++ ) re_syntax_table [ c ] = Sword ; for ( c = '0' ; c <= '9' ; c ++ ) re_syntax_table [ c ] = Sword ; re_syntax_table [ '_' ] = Sword ; done = 1 ; } "," static int done = 0 ( c = 0 ; c < CHAR_SET_SIZE ; ++ c ) if ( ISALNUM ( c ) ) re_syntax_table [ ",bminor@glibc/2864e767053317538feafa815046fff89e5a16be,CVE-1999-0199,https://github.com/bminor/glibc/commit/2864e767053317538feafa815046fff89e5a16be,2020-10-06T13:15Z 493,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 494,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 495,CWE-119,"CWE-119 void vp9_update_mbgraph_stats ( VP9_COMP * cpi ) { VP9_COMMON * const cm = & cpi -> common ; int i , n_frames = vp9_lookahead_depth ( cpi -> lookahead ) ; YV12_BUFFER_CONFIG * golden_ref = get_ref_frame_buffer ( cpi , GOLDEN_FRAME ) ; if ( n_frames <= cpi -> rc . frames_till_gf_update_due ) return ; if ( n_frames > MAX_LAG_BUFFERS ) n_frames = MAX_LAG_BUFFERS ; cpi -> mbgraph_n_frames = n_frames ; for ( i = 0 ; i < n_frames ; i ++ ) { MBGRAPH_FRAME_STATS * frame_stats = & cpi -> mbgraph_stats [ i ] ; vpx_memset ( frame_stats -> mb_stats , 0 , cm -> mb_rows * cm -> mb_cols * sizeof ( * cpi -> mbgraph_stats [ i ] . mb_stats ) ) ; } for ( i = 0 ; i < n_frames ; i ++ ) { MBGRAPH_FRAME_STATS * frame_stats = & cpi -> mbgraph_stats [ i ] ; struct lookahead_entry * q_cur = vp9_lookahead_peek ( cpi -> lookahead , i ) ; assert ( q_cur != NULL ) ; update_mbgraph_frame_stats ( cpi , frame_stats , & q_cur -> img , golden_ref , cpi -> Source ) ; } vp9_clear_system_state ( ) ; separate_arf_mbs ( cpi ) ; } "," cpi , GOLDEN_FRAME ) ; assert ( golden_ref != NULL i ] ; memset ( frame_stats -> ) ; } vpx_clear_system_state ( ) ; ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 496,CWE-000,"CWE-000 static int iowarrior_probe ( struct usb_interface * interface , const struct usb_device_id * id ) { struct usb_device * udev = interface_to_usbdev ( interface ) ; struct iowarrior * dev = NULL ; struct usb_host_interface * iface_desc ; struct usb_endpoint_descriptor * endpoint ; int i ; int retval = - ENOMEM ; dev = kzalloc ( sizeof ( struct iowarrior ) , GFP_KERNEL ) ; if ( dev == NULL ) { dev_err ( & interface -> dev , ""Outofmemory\\n"" ) ; return retval ; } mutex_init ( & dev -> mutex ) ; atomic_set ( & dev -> intr_idx , 0 ) ; atomic_set ( & dev -> read_idx , 0 ) ; spin_lock_init ( & dev -> intr_idx_lock ) ; atomic_set ( & dev -> overflow_flag , 0 ) ; init_waitqueue_head ( & dev -> read_wait ) ; atomic_set ( & dev -> write_busy , 0 ) ; init_waitqueue_head ( & dev -> write_wait ) ; dev -> udev = udev ; dev -> interface = interface ; iface_desc = interface -> cur_altsetting ; dev -> product_id = le16_to_cpu ( udev -> descriptor . idProduct ) ; for ( i = 0 ; i < iface_desc -> desc . bNumEndpoints ; ++ i ) { endpoint = & iface_desc -> endpoint [ i ] . desc ; if ( usb_endpoint_is_int_in ( endpoint ) ) dev -> int_in_endpoint = endpoint ; if ( usb_endpoint_is_int_out ( endpoint ) ) dev -> int_out_endpoint = endpoint ; } dev -> report_size = usb_endpoint_maxp ( dev -> int_in_endpoint ) ; if ( ( dev -> interface -> cur_altsetting -> desc . bInterfaceNumber == 0 ) && ( dev -> product_id == USB_DEVICE_ID_CODEMERCS_IOW56 ) ) dev -> report_size = 7 ; dev -> int_in_urb = usb_alloc_urb ( 0 , GFP_KERNEL ) ; if ( ! dev -> int_in_urb ) { dev_err ( & interface -> dev , ""Couldn\'tallocateinterrupt_in_urb\\n"" ) ; goto error ; } dev -> int_in_buffer = kmalloc ( dev -> report_size , GFP_KERNEL ) ; if ( ! dev -> int_in_buffer ) { dev_err ( & interface -> dev , ""Couldn\'tallocateint_in_buffer\\n"" ) ; goto error ; } usb_fill_int_urb ( dev -> int_in_urb , dev -> udev , usb_rcvintpipe ( dev -> udev , dev -> int_in_endpoint -> bEndpointAddress ) , dev -> int_in_buffer , dev -> report_size , iowarrior_callback , dev , dev -> int_in_endpoint -> bInterval ) ; dev -> read_queue = kmalloc ( ( ( dev -> report_size + 1 ) * MAX_INTERRUPT_BUFFER ) , GFP_KERNEL ) ; if ( ! dev -> read_queue ) { dev_err ( & interface -> dev , ""Couldn\'tallocateread_queue\\n"" ) ; goto error ; } memset ( dev -> chip_serial , 0x00 , sizeof ( dev -> chip_serial ) ) ; usb_string ( udev , udev -> descriptor . iSerialNumber , dev -> chip_serial , sizeof ( dev -> chip_serial ) ) ; if ( strlen ( dev -> chip_serial ) != 8 ) memset ( dev -> chip_serial , 0x00 , sizeof ( dev -> chip_serial ) ) ; if ( dev -> interface -> cur_altsetting -> desc . bInterfaceNumber == 0 ) { usb_control_msg ( udev , usb_sndctrlpipe ( udev , 0 ) , 0x0A , USB_TYPE_CLASS | USB_RECIP_INTERFACE , 0 , 0 , NULL , 0 , USB_CTRL_SET_TIMEOUT ) ; } dev -> present = 1 ; usb_set_intfdata ( interface , dev ) ; retval = usb_register_dev ( interface , & iowarrior_class ) ; if ( retval ) { dev_err ( & interface -> dev , ""Notabletogetaminorforthisdevice.\\n"" ) ; usb_set_intfdata ( interface , NULL ) ; goto error ; } dev -> minor = interface -> minor ; dev_info ( & interface -> dev , ""IOWarriorproduct=0x%x,serial=%sinterface=%d"" ""nowattachedtoiowarrior%d\\n"" , dev -> product_id , dev -> chip_serial , iface_desc -> desc . bInterfaceNumber , dev -> minor - IOWARRIOR_MINOR_BASE ) ; return retval ; error : iowarrior_delete ( dev ) ; return retval ; } "," idProduct ) ; if ( iface_desc -> desc . bNumEndpoints < 1 ) { dev_err ( & interface -> dev , ""Invalidnumberofendpoints\\n"" ) ; retval = - EINVAL ; goto error ; } ",torvalds@linux/4ec0ef3a82125efc36173062a50624550a900ae0,CVE-2016-2188,https://github.com/torvalds/linux/commit/4ec0ef3a82125efc36173062a50624550a900ae0,2016-05-02T10:59Z 497,CWE-125,"CWE-125 static int rsvp_obj_print ( netdissect_options * ndo , const u_char * pptr , u_int plen , const u_char * tptr , const char * ident , u_int tlen , const struct rsvp_common_header * rsvp_com_header ) { const struct rsvp_object_header * rsvp_obj_header ; const u_char * obj_tptr ; union { const struct rsvp_obj_integrity_t * rsvp_obj_integrity ; const struct rsvp_obj_frr_t * rsvp_obj_frr ; } obj_ptr ; u_short rsvp_obj_len , rsvp_obj_ctype , obj_tlen , intserv_serv_tlen ; int hexdump , processed , padbytes , error_code , error_value , i , sigcheck ; union { float f ; uint32_t i ; } bw ; uint8_t namelen ; u_int action , subchannel ; while ( tlen >= sizeof ( struct rsvp_object_header ) ) { ND_TCHECK2 ( * tptr , sizeof ( struct rsvp_object_header ) ) ; rsvp_obj_header = ( const struct rsvp_object_header * ) tptr ; rsvp_obj_len = EXTRACT_16BITS ( rsvp_obj_header -> length ) ; rsvp_obj_ctype = rsvp_obj_header -> ctype ; if ( rsvp_obj_len % 4 ) { ND_PRINT ( ( ndo , ""%sERROR:objectheadersize%unotamultipleof4"" , ident , rsvp_obj_len ) ) ; return - 1 ; } if ( rsvp_obj_len < sizeof ( struct rsvp_object_header ) ) { ND_PRINT ( ( ndo , ""%sERROR:objectheadertooshort%u<%lu"" , ident , rsvp_obj_len , ( unsigned long ) sizeof ( const struct rsvp_object_header ) ) ) ; return - 1 ; } ND_PRINT ( ( ndo , ""%s%sObject(%u)Flags:[%s"" , ident , tok2str ( rsvp_obj_values , ""Unknown"" , rsvp_obj_header -> class_num ) , rsvp_obj_header -> class_num , ( ( rsvp_obj_header -> class_num ) & 0x80 ) ? ""ignore"" : ""reject"" ) ) ; if ( rsvp_obj_header -> class_num > 128 ) ND_PRINT ( ( ndo , ""%s"" , ( ( rsvp_obj_header -> class_num ) & 0x40 ) ? ""andforward"" : ""silently"" ) ) ; ND_PRINT ( ( ndo , ""ifunknown],Class-Type:%s(%u),length:%u"" , tok2str ( rsvp_ctype_values , ""Unknown"" , ( ( rsvp_obj_header -> class_num ) << 8 ) + rsvp_obj_ctype ) , rsvp_obj_ctype , rsvp_obj_len ) ) ; if ( tlen < rsvp_obj_len ) { ND_PRINT ( ( ndo , ""%sERROR:objectgoespastendofobjectsTLV"" , ident ) ) ; return - 1 ; } obj_tptr = tptr + sizeof ( struct rsvp_object_header ) ; obj_tlen = rsvp_obj_len - sizeof ( struct rsvp_object_header ) ; if ( ! ND_TTEST2 ( * tptr , rsvp_obj_len ) ) return - 1 ; hexdump = FALSE ; switch ( rsvp_obj_header -> class_num ) { case RSVP_OBJ_SESSION : switch ( rsvp_obj_ctype ) { case RSVP_CTYPE_IPV4 : if ( obj_tlen < 8 ) return - 1 ; ND_PRINT ( ( ndo , ""%sIPv4DestAddress:%s,ProtocolID:0x%02x"" , ident , ipaddr_string ( ndo , obj_tptr ) , * ( obj_tptr + sizeof ( struct in_addr ) ) ) ) ; ND_PRINT ( ( ndo , ""%sFlags:[0x%02x],DestPort%u"" , ident , * ( obj_tptr + 5 ) , EXTRACT_16BITS ( obj_tptr + 6 ) ) ) ; obj_tlen -= 8 ; obj_tptr += 8 ; break ; case RSVP_CTYPE_IPV6 : if ( obj_tlen < 20 ) return - 1 ; ND_PRINT ( ( ndo , ""%sIPv6DestAddress:%s,ProtocolID:0x%02x"" , ident , ip6addr_string ( ndo , obj_tptr ) , * ( obj_tptr + sizeof ( struct in6_addr ) ) ) ) ; ND_PRINT ( ( ndo , ""%sFlags:[0x%02x],DestPort%u"" , ident , * ( obj_tptr + sizeof ( struct in6_addr ) + 1 ) , EXTRACT_16BITS ( obj_tptr + sizeof ( struct in6_addr ) + 2 ) ) ) ; obj_tlen -= 20 ; obj_tptr += 20 ; break ; case RSVP_CTYPE_TUNNEL_IPV6 : if ( obj_tlen < 36 ) return - 1 ; ND_PRINT ( ( ndo , ""%sIPv6TunnelEndPoint:%s,TunnelID:0x%04x,ExtendedTunnelID:%s"" , ident , ip6addr_string ( ndo , obj_tptr ) , EXTRACT_16BITS ( obj_tptr + 18 ) , ip6addr_string ( ndo , obj_tptr + 20 ) ) ) ; obj_tlen -= 36 ; obj_tptr += 36 ; break ; case RSVP_CTYPE_14 : if ( obj_tlen < 26 ) return - 1 ; ND_PRINT ( ( ndo , ""%sIPv6P2MPLSPID:0x%08x,TunnelID:0x%04x,ExtendedTunnelID:%s"" , ident , EXTRACT_32BITS ( obj_tptr ) , EXTRACT_16BITS ( obj_tptr + 6 ) , ip6addr_string ( ndo , obj_tptr + 8 ) ) ) ; obj_tlen -= 26 ; obj_tptr += 26 ; break ; case RSVP_CTYPE_13 : if ( obj_tlen < 12 ) return - 1 ; ND_PRINT ( ( ndo , ""%sIPv4P2MPLSPID:%s,TunnelID:0x%04x,ExtendedTunnelID:%s"" , ident , ipaddr_string ( ndo , obj_tptr ) , EXTRACT_16BITS ( obj_tptr + 6 ) , ipaddr_string ( ndo , obj_tptr + 8 ) ) ) ; obj_tlen -= 12 ; obj_tptr += 12 ; break ; case RSVP_CTYPE_TUNNEL_IPV4 : case RSVP_CTYPE_UNI_IPV4 : if ( obj_tlen < 12 ) return - 1 ; ND_PRINT ( ( ndo , ""%sIPv4TunnelEndPoint:%s,TunnelID:0x%04x,ExtendedTunnelID:%s"" , ident , ipaddr_string ( ndo , obj_tptr ) , EXTRACT_16BITS ( obj_tptr + 6 ) , ipaddr_string ( ndo , obj_tptr + 8 ) ) ) ; obj_tlen -= 12 ; obj_tptr += 12 ; break ; default : hexdump = TRUE ; } break ; case RSVP_OBJ_CONFIRM : switch ( rsvp_obj_ctype ) { case RSVP_CTYPE_IPV4 : if ( obj_tlen < sizeof ( struct in_addr ) ) return - 1 ; ND_PRINT ( ( ndo , ""%sIPv4ReceiverAddress:%s"" , ident , ipaddr_string ( ndo , obj_tptr ) ) ) ; obj_tlen -= sizeof ( struct in_addr ) ; obj_tptr += sizeof ( struct in_addr ) ; break ; case RSVP_CTYPE_IPV6 : if ( obj_tlen < sizeof ( struct in6_addr ) ) return - 1 ; ND_PRINT ( ( ndo , ""%sIPv6ReceiverAddress:%s"" , ident , ip6addr_string ( ndo , obj_tptr ) ) ) ; obj_tlen -= sizeof ( struct in6_addr ) ; obj_tptr += sizeof ( struct in6_addr ) ; break ; default : hexdump = TRUE ; } break ; case RSVP_OBJ_NOTIFY_REQ : switch ( rsvp_obj_ctype ) { case RSVP_CTYPE_IPV4 : if ( obj_tlen < sizeof ( struct in_addr ) ) return - 1 ; ND_PRINT ( ( ndo , ""%sIPv4NotifyNodeAddress:%s"" , ident , ipaddr_string ( ndo , obj_tptr ) ) ) ; obj_tlen -= sizeof ( struct in_addr ) ; obj_tptr += sizeof ( struct in_addr ) ; break ; case RSVP_CTYPE_IPV6 : if ( obj_tlen < sizeof ( struct in6_addr ) ) return - 1 ; ND_PRINT ( ( ndo , ""%sIPv6NotifyNodeAddress:%s"" , ident , ip6addr_string ( ndo , obj_tptr ) ) ) ; obj_tlen -= sizeof ( struct in6_addr ) ; obj_tptr += sizeof ( struct in6_addr ) ; break ; default : hexdump = TRUE ; } break ; case RSVP_OBJ_SUGGESTED_LABEL : case RSVP_OBJ_UPSTREAM_LABEL : case RSVP_OBJ_RECOVERY_LABEL : case RSVP_OBJ_LABEL : switch ( rsvp_obj_ctype ) { case RSVP_CTYPE_1 : while ( obj_tlen >= 4 ) { ND_PRINT ( ( ndo , ""%sLabel:%u"" , ident , EXTRACT_32BITS ( obj_tptr ) ) ) ; obj_tlen -= 4 ; obj_tptr += 4 ; } break ; case RSVP_CTYPE_2 : if ( obj_tlen < 4 ) return - 1 ; ND_PRINT ( ( ndo , ""%sGeneralizedLabel:%u"" , ident , EXTRACT_32BITS ( obj_tptr ) ) ) ; obj_tlen -= 4 ; obj_tptr += 4 ; break ; case RSVP_CTYPE_3 : if ( obj_tlen < 12 ) return - 1 ; ND_PRINT ( ( ndo , ""%sWavebandID:%u%sStartLabel:%u,StopLabel:%u"" , ident , EXTRACT_32BITS ( obj_tptr ) , ident , EXTRACT_32BITS ( obj_tptr + 4 ) , EXTRACT_32BITS ( obj_tptr + 8 ) ) ) ; obj_tlen -= 12 ; obj_tptr += 12 ; break ; default : hexdump = TRUE ; } break ; case RSVP_OBJ_STYLE : switch ( rsvp_obj_ctype ) { case RSVP_CTYPE_1 : if ( obj_tlen < 4 ) return - 1 ; ND_PRINT ( ( ndo , ""%sReservationStyle:%s,Flags:[0x%02x]"" , ident , tok2str ( rsvp_resstyle_values , ""Unknown"" , EXTRACT_24BITS ( obj_tptr + 1 ) ) , * ( obj_tptr ) ) ) ; obj_tlen -= 4 ; obj_tptr += 4 ; break ; default : hexdump = TRUE ; } break ; case RSVP_OBJ_SENDER_TEMPLATE : switch ( rsvp_obj_ctype ) { case RSVP_CTYPE_IPV4 : if ( obj_tlen < 8 ) return - 1 ; ND_PRINT ( ( ndo , ""%sSourceAddress:%s,SourcePort:%u"" , ident , ipaddr_string ( ndo , obj_tptr ) , EXTRACT_16BITS ( obj_tptr + 6 ) ) ) ; obj_tlen -= 8 ; obj_tptr += 8 ; break ; case RSVP_CTYPE_IPV6 : if ( obj_tlen < 20 ) return - 1 ; ND_PRINT ( ( ndo , ""%sSourceAddress:%s,SourcePort:%u"" , ident , ip6addr_string ( ndo , obj_tptr ) , EXTRACT_16BITS ( obj_tptr + 18 ) ) ) ; obj_tlen -= 20 ; obj_tptr += 20 ; break ; case RSVP_CTYPE_13 : if ( obj_tlen < 40 ) return - 1 ; ND_PRINT ( ( ndo , ""%sIPv6TunnelSenderAddress:%s,LSPID:0x%04x"" ""%sSub-GroupOriginatorID:%s,Sub-GroupID:0x%04x"" , ident , ip6addr_string ( ndo , obj_tptr ) , EXTRACT_16BITS ( obj_tptr + 18 ) , ident , ip6addr_string ( ndo , obj_tptr + 20 ) , EXTRACT_16BITS ( obj_tptr + 38 ) ) ) ; obj_tlen -= 40 ; obj_tptr += 40 ; break ; case RSVP_CTYPE_TUNNEL_IPV4 : if ( obj_tlen < 8 ) return - 1 ; ND_PRINT ( ( ndo , ""%sIPv4TunnelSenderAddress:%s,LSP-ID:0x%04x"" , ident , ipaddr_string ( ndo , obj_tptr ) , EXTRACT_16BITS ( obj_tptr + 6 ) ) ) ; obj_tlen -= 8 ; obj_tptr += 8 ; break ; case RSVP_CTYPE_12 : if ( obj_tlen < 16 ) return - 1 ; ND_PRINT ( ( ndo , ""%sIPv4TunnelSenderAddress:%s,LSPID:0x%04x"" ""%sSub-GroupOriginatorID:%s,Sub-GroupID:0x%04x"" , ident , ipaddr_string ( ndo , obj_tptr ) , EXTRACT_16BITS ( obj_tptr + 6 ) , ident , ipaddr_string ( ndo , obj_tptr + 8 ) , EXTRACT_16BITS ( obj_tptr + 12 ) ) ) ; obj_tlen -= 16 ; obj_tptr += 16 ; break ; default : hexdump = TRUE ; } break ; case RSVP_OBJ_LABEL_REQ : switch ( rsvp_obj_ctype ) { case RSVP_CTYPE_1 : while ( obj_tlen >= 4 ) { ND_PRINT ( ( ndo , ""%sL3ProtocolID:%s"" , ident , tok2str ( ethertype_values , ""UnknownProtocol(0x%04x)"" , EXTRACT_16BITS ( obj_tptr + 2 ) ) ) ) ; obj_tlen -= 4 ; obj_tptr += 4 ; } break ; case RSVP_CTYPE_2 : if ( obj_tlen < 12 ) return - 1 ; ND_PRINT ( ( ndo , ""%sL3ProtocolID:%s"" , ident , tok2str ( ethertype_values , ""UnknownProtocol(0x%04x)"" , EXTRACT_16BITS ( obj_tptr + 2 ) ) ) ) ; ND_PRINT ( ( ndo , "",%smergecapability"" , ( ( * ( obj_tptr + 4 ) ) & 0x80 ) ? ""no"" : """" ) ) ; ND_PRINT ( ( ndo , ""%sMinimumVPI/VCI:%u/%u"" , ident , ( EXTRACT_16BITS ( obj_tptr + 4 ) ) & 0xfff , ( EXTRACT_16BITS ( obj_tptr + 6 ) ) & 0xfff ) ) ; ND_PRINT ( ( ndo , ""%sMaximumVPI/VCI:%u/%u"" , ident , ( EXTRACT_16BITS ( obj_tptr + 8 ) ) & 0xfff , ( EXTRACT_16BITS ( obj_tptr + 10 ) ) & 0xfff ) ) ; obj_tlen -= 12 ; obj_tptr += 12 ; break ; case RSVP_CTYPE_3 : if ( obj_tlen < 12 ) return - 1 ; ND_PRINT ( ( ndo , ""%sL3ProtocolID:%s"" , ident , tok2str ( ethertype_values , ""UnknownProtocol(0x%04x)"" , EXTRACT_16BITS ( obj_tptr + 2 ) ) ) ) ; ND_PRINT ( ( ndo , ""%sMinimum/MaximumDLCI:%u/%u,%s%sbitDLCI"" , ident , ( EXTRACT_32BITS ( obj_tptr + 4 ) ) & 0x7fffff , ( EXTRACT_32BITS ( obj_tptr + 8 ) ) & 0x7fffff , ( ( ( EXTRACT_16BITS ( obj_tptr + 4 ) >> 7 ) & 3 ) == 0 ) ? ""10"" : """" , ( ( ( EXTRACT_16BITS ( obj_tptr + 4 ) >> 7 ) & 3 ) == 2 ) ? ""23"" : """" ) ) ; obj_tlen -= 12 ; obj_tptr += 12 ; break ; case RSVP_CTYPE_4 : if ( obj_tlen < 4 ) return - 1 ; ND_PRINT ( ( ndo , ""%sLSPEncodingType:%s(%u)"" , ident , tok2str ( gmpls_encoding_values , ""Unknown"" , * obj_tptr ) , * obj_tptr ) ) ; ND_PRINT ( ( ndo , ""%sSwitchingType:%s(%u),PayloadID:%s(0x%04x)"" , ident , tok2str ( gmpls_switch_cap_values , ""Unknown"" , * ( obj_tptr + 1 ) ) , * ( obj_tptr + 1 ) , tok2str ( gmpls_payload_values , ""Unknown"" , EXTRACT_16BITS ( obj_tptr + 2 ) ) , EXTRACT_16BITS ( obj_tptr + 2 ) ) ) ; obj_tlen -= 4 ; obj_tptr += 4 ; break ; default : hexdump = TRUE ; } break ; case RSVP_OBJ_RRO : case RSVP_OBJ_ERO : switch ( rsvp_obj_ctype ) { case RSVP_CTYPE_IPV4 : while ( obj_tlen >= 4 ) { u_char length ; ND_TCHECK2 ( * obj_tptr , 4 ) ; length = * ( obj_tptr + 1 ) ; ND_PRINT ( ( ndo , ""%sSubobjectType:%s,length%u"" , ident , tok2str ( rsvp_obj_xro_values , ""Unknown%u"" , RSVP_OBJ_XRO_MASK_SUBOBJ ( * obj_tptr ) ) , length ) ) ; if ( length == 0 ) { ND_PRINT ( ( ndo , ""%sERROR:zerolengthEROsubtype"" , ident ) ) ; break ; } switch ( RSVP_OBJ_XRO_MASK_SUBOBJ ( * obj_tptr ) ) { u_char prefix_length ; case RSVP_OBJ_XRO_IPV4 : if ( length != 8 ) { ND_PRINT ( ( ndo , ""ERROR:length!=8"" ) ) ; goto invalid ; } ND_TCHECK2 ( * obj_tptr , 8 ) ; prefix_length = * ( obj_tptr + 6 ) ; if ( prefix_length != 32 ) { ND_PRINT ( ( ndo , ""ERROR:Prefixlength%u!=32"" , prefix_length ) ) ; goto invalid ; } ND_PRINT ( ( ndo , "",%s,%s/%u,Flags:[%s]"" , RSVP_OBJ_XRO_MASK_LOOSE ( * obj_tptr ) ? ""Loose"" : ""Strict"" , ipaddr_string ( ndo , obj_tptr + 2 ) , * ( obj_tptr + 6 ) , bittok2str ( rsvp_obj_rro_flag_values , ""none"" , * ( obj_tptr + 7 ) ) ) ) ; break ; case RSVP_OBJ_XRO_LABEL : if ( length != 8 ) { ND_PRINT ( ( ndo , ""ERROR:length!=8"" ) ) ; goto invalid ; } ND_TCHECK2 ( * obj_tptr , 8 ) ; ND_PRINT ( ( ndo , "",Flags:[%s](%#x),Class-Type:%s(%u),%u"" , bittok2str ( rsvp_obj_rro_label_flag_values , ""none"" , * ( obj_tptr + 2 ) ) , * ( obj_tptr + 2 ) , tok2str ( rsvp_ctype_values , ""Unknown"" , * ( obj_tptr + 3 ) + 256 * RSVP_OBJ_RRO ) , * ( obj_tptr + 3 ) , EXTRACT_32BITS ( obj_tptr + 4 ) ) ) ; } obj_tlen -= * ( obj_tptr + 1 ) ; obj_tptr += * ( obj_tptr + 1 ) ; } break ; default : hexdump = TRUE ; } break ; case RSVP_OBJ_HELLO : switch ( rsvp_obj_ctype ) { case RSVP_CTYPE_1 : case RSVP_CTYPE_2 : if ( obj_tlen < 8 ) return - 1 ; ND_PRINT ( ( ndo , ""%sSourceInstance:0x%08x,DestinationInstance:0x%08x"" , ident , EXTRACT_32BITS ( obj_tptr ) , EXTRACT_32BITS ( obj_tptr + 4 ) ) ) ; obj_tlen -= 8 ; obj_tptr += 8 ; break ; default : hexdump = TRUE ; } break ; case RSVP_OBJ_RESTART_CAPABILITY : switch ( rsvp_obj_ctype ) { case RSVP_CTYPE_1 : if ( obj_tlen < 8 ) return - 1 ; ND_PRINT ( ( ndo , ""%sRestartTime:%ums,RecoveryTime:%ums"" , ident , EXTRACT_32BITS ( obj_tptr ) , EXTRACT_32BITS ( obj_tptr + 4 ) ) ) ; obj_tlen -= 8 ; obj_tptr += 8 ; break ; default : hexdump = TRUE ; } break ; case RSVP_OBJ_SESSION_ATTRIBUTE : switch ( rsvp_obj_ctype ) { case RSVP_CTYPE_TUNNEL_IPV4 : if ( obj_tlen < 4 ) return - 1 ; namelen = * ( obj_tptr + 3 ) ; if ( obj_tlen < 4 + namelen ) return - 1 ; ND_PRINT ( ( ndo , ""%sSessionName:"" , ident ) ) ; for ( i = 0 ; i < namelen ; i ++ ) safeputchar ( ndo , * ( obj_tptr + 4 + i ) ) ; ND_PRINT ( ( ndo , ""%sSetupPriority:%u,HoldingPriority:%u,Flags:[%s](%#x)"" , ident , ( int ) * obj_tptr , ( int ) * ( obj_tptr + 1 ) , bittok2str ( rsvp_session_attribute_flag_values , ""none"" , * ( obj_tptr + 2 ) ) , * ( obj_tptr + 2 ) ) ) ; obj_tlen -= 4 + * ( obj_tptr + 3 ) ; obj_tptr += 4 + * ( obj_tptr + 3 ) ; break ; default : hexdump = TRUE ; } break ; case RSVP_OBJ_GENERALIZED_UNI : switch ( rsvp_obj_ctype ) { int subobj_type , af , subobj_len , total_subobj_len ; case RSVP_CTYPE_1 : if ( obj_tlen < 4 ) return - 1 ; total_subobj_len = obj_tlen ; while ( total_subobj_len > 0 ) { subobj_len = EXTRACT_16BITS ( obj_tptr ) ; subobj_type = ( EXTRACT_16BITS ( obj_tptr + 2 ) ) >> 8 ; af = ( EXTRACT_16BITS ( obj_tptr + 2 ) ) & 0x00FF ; ND_PRINT ( ( ndo , ""%sSubobjectType:%s(%u),AF:%s(%u),length:%u"" , ident , tok2str ( rsvp_obj_generalized_uni_values , ""Unknown"" , subobj_type ) , subobj_type , tok2str ( af_values , ""Unknown"" , af ) , af , subobj_len ) ) ; if ( subobj_len == 0 ) goto invalid ; switch ( subobj_type ) { case RSVP_GEN_UNI_SUBOBJ_SOURCE_TNA_ADDRESS : case RSVP_GEN_UNI_SUBOBJ_DESTINATION_TNA_ADDRESS : switch ( af ) { case AFNUM_INET : if ( subobj_len < 8 ) return - 1 ; ND_PRINT ( ( ndo , ""%sUNIIPv4TNAaddress:%s"" , ident , ipaddr_string ( ndo , obj_tptr + 4 ) ) ) ; break ; case AFNUM_INET6 : if ( subobj_len < 20 ) return - 1 ; ND_PRINT ( ( ndo , ""%sUNIIPv6TNAaddress:%s"" , ident , ip6addr_string ( ndo , obj_tptr + 4 ) ) ) ; break ; case AFNUM_NSAP : if ( subobj_len ) { hexdump = TRUE ; } break ; } break ; case RSVP_GEN_UNI_SUBOBJ_DIVERSITY : if ( subobj_len ) { hexdump = TRUE ; } break ; case RSVP_GEN_UNI_SUBOBJ_EGRESS_LABEL : if ( subobj_len < 16 ) { return - 1 ; } ND_PRINT ( ( ndo , ""%sU-bit:%x,Labeltype:%u,Logicalportid:%u,Label:%u"" , ident , ( ( EXTRACT_32BITS ( obj_tptr + 4 ) ) >> 31 ) , ( ( EXTRACT_32BITS ( obj_tptr + 4 ) ) & 0xFF ) , EXTRACT_32BITS ( obj_tptr + 8 ) , EXTRACT_32BITS ( obj_tptr + 12 ) ) ) ; break ; case RSVP_GEN_UNI_SUBOBJ_SERVICE_LEVEL : if ( subobj_len < 8 ) { return - 1 ; } ND_PRINT ( ( ndo , ""%sServicelevel:%u"" , ident , ( EXTRACT_32BITS ( obj_tptr + 4 ) ) >> 24 ) ) ; break ; default : hexdump = TRUE ; break ; } total_subobj_len -= subobj_len ; obj_tptr += subobj_len ; obj_tlen += subobj_len ; } if ( total_subobj_len ) { hexdump = TRUE ; } break ; default : hexdump = TRUE ; } break ; case RSVP_OBJ_RSVP_HOP : switch ( rsvp_obj_ctype ) { case RSVP_CTYPE_3 : case RSVP_CTYPE_IPV4 : if ( obj_tlen < 8 ) return - 1 ; ND_PRINT ( ( ndo , ""%sPrevious/NextInterface:%s,LogicalInterfaceHandle:0x%08x"" , ident , ipaddr_string ( ndo , obj_tptr ) , EXTRACT_32BITS ( obj_tptr + 4 ) ) ) ; obj_tlen -= 8 ; obj_tptr += 8 ; if ( obj_tlen ) hexdump = TRUE ; break ; case RSVP_CTYPE_4 : case RSVP_CTYPE_IPV6 : if ( obj_tlen < 20 ) return - 1 ; ND_PRINT ( ( ndo , ""%sPrevious/NextInterface:%s,LogicalInterfaceHandle:0x%08x"" , ident , ip6addr_string ( ndo , obj_tptr ) , EXTRACT_32BITS ( obj_tptr + 16 ) ) ) ; obj_tlen -= 20 ; obj_tptr += 20 ; hexdump = TRUE ; break ; default : hexdump = TRUE ; } break ; case RSVP_OBJ_TIME_VALUES : switch ( rsvp_obj_ctype ) { case RSVP_CTYPE_1 : if ( obj_tlen < 4 ) return - 1 ; ND_PRINT ( ( ndo , ""%sRefreshPeriod:%ums"" , ident , EXTRACT_32BITS ( obj_tptr ) ) ) ; obj_tlen -= 4 ; obj_tptr += 4 ; break ; default : hexdump = TRUE ; } break ; case RSVP_OBJ_SENDER_TSPEC : case RSVP_OBJ_ADSPEC : case RSVP_OBJ_FLOWSPEC : switch ( rsvp_obj_ctype ) { case RSVP_CTYPE_2 : if ( obj_tlen < 4 ) return - 1 ; ND_PRINT ( ( ndo , ""%sMsg-Version:%u,length:%u"" , ident , ( * obj_tptr & 0xf0 ) >> 4 , EXTRACT_16BITS ( obj_tptr + 2 ) << 2 ) ) ; obj_tptr += 4 ; obj_tlen -= 4 ; while ( obj_tlen >= 4 ) { intserv_serv_tlen = EXTRACT_16BITS ( obj_tptr + 2 ) << 2 ; ND_PRINT ( ( ndo , ""%sServiceType:%s(%u),breakbit%sset,Servicelength:%u"" , ident , tok2str ( rsvp_intserv_service_type_values , ""unknown"" , * ( obj_tptr ) ) , * ( obj_tptr ) , ( * ( obj_tptr + 1 ) & 0x80 ) ? """" : ""not"" , intserv_serv_tlen ) ) ; obj_tptr += 4 ; obj_tlen -= 4 ; while ( intserv_serv_tlen >= 4 ) { processed = rsvp_intserv_print ( ndo , obj_tptr , obj_tlen ) ; if ( processed == 0 ) break ; obj_tlen -= processed ; intserv_serv_tlen -= processed ; obj_tptr += processed ; } } break ; default : hexdump = TRUE ; } break ; case RSVP_OBJ_FILTERSPEC : switch ( rsvp_obj_ctype ) { case RSVP_CTYPE_IPV4 : if ( obj_tlen < 8 ) return - 1 ; ND_PRINT ( ( ndo , ""%sSourceAddress:%s,SourcePort:%u"" , ident , ipaddr_string ( ndo , obj_tptr ) , EXTRACT_16BITS ( obj_tptr + 6 ) ) ) ; obj_tlen -= 8 ; obj_tptr += 8 ; break ; case RSVP_CTYPE_IPV6 : if ( obj_tlen < 20 ) return - 1 ; ND_PRINT ( ( ndo , ""%sSourceAddress:%s,SourcePort:%u"" , ident , ip6addr_string ( ndo , obj_tptr ) , EXTRACT_16BITS ( obj_tptr + 18 ) ) ) ; obj_tlen -= 20 ; obj_tptr += 20 ; break ; case RSVP_CTYPE_3 : if ( obj_tlen < 20 ) return - 1 ; ND_PRINT ( ( ndo , ""%sSourceAddress:%s,FlowLabel:%u"" , ident , ip6addr_string ( ndo , obj_tptr ) , EXTRACT_24BITS ( obj_tptr + 17 ) ) ) ; obj_tlen -= 20 ; obj_tptr += 20 ; break ; case RSVP_CTYPE_TUNNEL_IPV6 : if ( obj_tlen < 20 ) return - 1 ; ND_PRINT ( ( ndo , ""%sSourceAddress:%s,LSP-ID:0x%04x"" , ident , ipaddr_string ( ndo , obj_tptr ) , EXTRACT_16BITS ( obj_tptr + 18 ) ) ) ; obj_tlen -= 20 ; obj_tptr += 20 ; break ; case RSVP_CTYPE_13 : if ( obj_tlen < 40 ) return - 1 ; ND_PRINT ( ( ndo , ""%sIPv6TunnelSenderAddress:%s,LSPID:0x%04x"" ""%sSub-GroupOriginatorID:%s,Sub-GroupID:0x%04x"" , ident , ip6addr_string ( ndo , obj_tptr ) , EXTRACT_16BITS ( obj_tptr + 18 ) , ident , ip6addr_string ( ndo , obj_tptr + 20 ) , EXTRACT_16BITS ( obj_tptr + 38 ) ) ) ; obj_tlen -= 40 ; obj_tptr += 40 ; break ; case RSVP_CTYPE_TUNNEL_IPV4 : if ( obj_tlen < 8 ) return - 1 ; ND_PRINT ( ( ndo , ""%sSourceAddress:%s,LSP-ID:0x%04x"" , ident , ipaddr_string ( ndo , obj_tptr ) , EXTRACT_16BITS ( obj_tptr + 6 ) ) ) ; obj_tlen -= 8 ; obj_tptr += 8 ; break ; case RSVP_CTYPE_12 : if ( obj_tlen < 16 ) return - 1 ; ND_PRINT ( ( ndo , ""%sIPv4TunnelSenderAddress:%s,LSPID:0x%04x"" ""%sSub-GroupOriginatorID:%s,Sub-GroupID:0x%04x"" , ident , ipaddr_string ( ndo , obj_tptr ) , EXTRACT_16BITS ( obj_tptr + 6 ) , ident , ipaddr_string ( ndo , obj_tptr + 8 ) , EXTRACT_16BITS ( obj_tptr + 12 ) ) ) ; obj_tlen -= 16 ; obj_tptr += 16 ; break ; default : hexdump = TRUE ; } break ; case RSVP_OBJ_FASTREROUTE : obj_ptr . rsvp_obj_frr = ( const struct rsvp_obj_frr_t * ) obj_tptr ; bw . i = EXTRACT_32BITS ( obj_ptr . rsvp_obj_frr -> bandwidth ) ; switch ( rsvp_obj_ctype ) { case RSVP_CTYPE_1 : if ( obj_tlen < sizeof ( struct rsvp_obj_frr_t ) ) return - 1 ; ND_PRINT ( ( ndo , ""%sSetupPriority:%u,HoldingPriority:%u,Hop-limit:%u,Bandwidth:%.10gMbps"" , ident , ( int ) obj_ptr . rsvp_obj_frr -> setup_prio , ( int ) obj_ptr . rsvp_obj_frr -> hold_prio , ( int ) obj_ptr . rsvp_obj_frr -> hop_limit , bw . f * 8 / 1000000 ) ) ; ND_PRINT ( ( ndo , ""%sInclude-any:0x%08x,Exclude-any:0x%08x,Include-all:0x%08x"" , ident , EXTRACT_32BITS ( obj_ptr . rsvp_obj_frr -> include_any ) , EXTRACT_32BITS ( obj_ptr . rsvp_obj_frr -> exclude_any ) , EXTRACT_32BITS ( obj_ptr . rsvp_obj_frr -> include_all ) ) ) ; obj_tlen -= sizeof ( struct rsvp_obj_frr_t ) ; obj_tptr += sizeof ( struct rsvp_obj_frr_t ) ; break ; case RSVP_CTYPE_TUNNEL_IPV4 : if ( obj_tlen < 16 ) return - 1 ; ND_PRINT ( ( ndo , ""%sSetupPriority:%u,HoldingPriority:%u,Hop-limit:%u,Bandwidth:%.10gMbps"" , ident , ( int ) obj_ptr . rsvp_obj_frr -> setup_prio , ( int ) obj_ptr . rsvp_obj_frr -> hold_prio , ( int ) obj_ptr . rsvp_obj_frr -> hop_limit , bw . f * 8 / 1000000 ) ) ; ND_PRINT ( ( ndo , ""%sIncludeColors:0x%08x,ExcludeColors:0x%08x"" , ident , EXTRACT_32BITS ( obj_ptr . rsvp_obj_frr -> include_any ) , EXTRACT_32BITS ( obj_ptr . rsvp_obj_frr -> exclude_any ) ) ) ; obj_tlen -= 16 ; obj_tptr += 16 ; break ; default : hexdump = TRUE ; } break ; case RSVP_OBJ_DETOUR : switch ( rsvp_obj_ctype ) { case RSVP_CTYPE_TUNNEL_IPV4 : while ( obj_tlen >= 8 ) { ND_PRINT ( ( ndo , ""%sPLR-ID:%s,Avoid-Node-ID:%s"" , ident , ipaddr_string ( ndo , obj_tptr ) , ipaddr_string ( ndo , obj_tptr + 4 ) ) ) ; obj_tlen -= 8 ; obj_tptr += 8 ; } break ; default : hexdump = TRUE ; } break ; case RSVP_OBJ_CLASSTYPE : case RSVP_OBJ_CLASSTYPE_OLD : switch ( rsvp_obj_ctype ) { case RSVP_CTYPE_1 : ND_PRINT ( ( ndo , ""%sCT:%u"" , ident , EXTRACT_32BITS ( obj_tptr ) & 0x7 ) ) ; obj_tlen -= 4 ; obj_tptr += 4 ; break ; default : hexdump = TRUE ; } break ; case RSVP_OBJ_ERROR_SPEC : switch ( rsvp_obj_ctype ) { case RSVP_CTYPE_3 : case RSVP_CTYPE_IPV4 : if ( obj_tlen < 8 ) return - 1 ; error_code = * ( obj_tptr + 5 ) ; error_value = EXTRACT_16BITS ( obj_tptr + 6 ) ; ND_PRINT ( ( ndo , ""%sErrorNodeAddress:%s,Flags:[0x%02x]%sErrorCode:%s(%u)"" , ident , ipaddr_string ( ndo , obj_tptr ) , * ( obj_tptr + 4 ) , ident , tok2str ( rsvp_obj_error_code_values , ""unknown"" , error_code ) , error_code ) ) ; switch ( error_code ) { case RSVP_OBJ_ERROR_SPEC_CODE_ROUTING : ND_PRINT ( ( ndo , "",ErrorValue:%s(%u)"" , tok2str ( rsvp_obj_error_code_routing_values , ""unknown"" , error_value ) , error_value ) ) ; break ; case RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE : case RSVP_OBJ_ERROR_SPEC_CODE_DIFFSERV_TE_OLD : ND_PRINT ( ( ndo , "",ErrorValue:%s(%u)"" , tok2str ( rsvp_obj_error_code_diffserv_te_values , ""unknown"" , error_value ) , error_value ) ) ; break ; default : ND_PRINT ( ( ndo , "",UnknownErrorValue(%u)"" , error_value ) ) ; break ; } obj_tlen -= 8 ; obj_tptr += 8 ; break ; case RSVP_CTYPE_4 : case RSVP_CTYPE_IPV6 : if ( obj_tlen < 20 ) return - 1 ; error_code = * ( obj_tptr + 17 ) ; error_value = EXTRACT_16BITS ( obj_tptr + 18 ) ; ND_PRINT ( ( ndo , ""%sErrorNodeAddress:%s,Flags:[0x%02x]%sErrorCode:%s(%u)"" , ident , ip6addr_string ( ndo , obj_tptr ) , * ( obj_tptr + 16 ) , ident , tok2str ( rsvp_obj_error_code_values , ""unknown"" , error_code ) , error_code ) ) ; switch ( error_code ) { case RSVP_OBJ_ERROR_SPEC_CODE_ROUTING : ND_PRINT ( ( ndo , "",ErrorValue:%s(%u)"" , tok2str ( rsvp_obj_error_code_routing_values , ""unknown"" , error_value ) , error_value ) ) ; break ; default : break ; } obj_tlen -= 20 ; obj_tptr += 20 ; break ; default : hexdump = TRUE ; } break ; case RSVP_OBJ_PROPERTIES : switch ( rsvp_obj_ctype ) { case RSVP_CTYPE_1 : if ( obj_tlen < 4 ) return - 1 ; padbytes = EXTRACT_16BITS ( obj_tptr + 2 ) ; ND_PRINT ( ( ndo , ""%sTLVcount:%u,paddingbytes:%u"" , ident , EXTRACT_16BITS ( obj_tptr ) , padbytes ) ) ; obj_tlen -= 4 ; obj_tptr += 4 ; while ( obj_tlen >= 2 + padbytes ) { ND_PRINT ( ( ndo , ""%s%sTLV(0x%02x),length:%u"" , ident , tok2str ( rsvp_obj_prop_tlv_values , ""unknown"" , * obj_tptr ) , * obj_tptr , * ( obj_tptr + 1 ) ) ) ; if ( obj_tlen < * ( obj_tptr + 1 ) ) return - 1 ; if ( * ( obj_tptr + 1 ) < 2 ) return - 1 ; print_unknown_data ( ndo , obj_tptr + 2 , ""\\n\\t\\t"" , * ( obj_tptr + 1 ) - 2 ) ; obj_tlen -= * ( obj_tptr + 1 ) ; obj_tptr += * ( obj_tptr + 1 ) ; } break ; default : hexdump = TRUE ; } break ; case RSVP_OBJ_MESSAGE_ID : case RSVP_OBJ_MESSAGE_ID_ACK : case RSVP_OBJ_MESSAGE_ID_LIST : switch ( rsvp_obj_ctype ) { case RSVP_CTYPE_1 : case RSVP_CTYPE_2 : if ( obj_tlen < 8 ) return - 1 ; ND_PRINT ( ( ndo , ""%sFlags[0x%02x],epoch:%u"" , ident , * obj_tptr , EXTRACT_24BITS ( obj_tptr + 1 ) ) ) ; obj_tlen -= 4 ; obj_tptr += 4 ; while ( obj_tlen >= 4 ) { ND_PRINT ( ( ndo , ""%sMessage-ID0x%08x(%u)"" , ident , EXTRACT_32BITS ( obj_tptr ) , EXTRACT_32BITS ( obj_tptr ) ) ) ; obj_tlen -= 4 ; obj_tptr += 4 ; } break ; default : hexdump = TRUE ; } break ; case RSVP_OBJ_INTEGRITY : switch ( rsvp_obj_ctype ) { case RSVP_CTYPE_1 : if ( obj_tlen < sizeof ( struct rsvp_obj_integrity_t ) ) return - 1 ; obj_ptr . rsvp_obj_integrity = ( const struct rsvp_obj_integrity_t * ) obj_tptr ; ND_PRINT ( ( ndo , ""%sKey-ID0x%04x%08x,Sequence0x%08x%08x,Flags[%s]"" , ident , EXTRACT_16BITS ( obj_ptr . rsvp_obj_integrity -> key_id ) , EXTRACT_32BITS ( obj_ptr . rsvp_obj_integrity -> key_id + 2 ) , EXTRACT_32BITS ( obj_ptr . rsvp_obj_integrity -> sequence ) , EXTRACT_32BITS ( obj_ptr . rsvp_obj_integrity -> sequence + 4 ) , bittok2str ( rsvp_obj_integrity_flag_values , ""none"" , obj_ptr . rsvp_obj_integrity -> flags ) ) ) ; ND_PRINT ( ( ndo , ""%sMD5-sum0x%08x%08x%08x%08x"" , ident , EXTRACT_32BITS ( obj_ptr . rsvp_obj_integrity -> digest ) , EXTRACT_32BITS ( obj_ptr . rsvp_obj_integrity -> digest + 4 ) , EXTRACT_32BITS ( obj_ptr . rsvp_obj_integrity -> digest + 8 ) , EXTRACT_32BITS ( obj_ptr . rsvp_obj_integrity -> digest + 12 ) ) ) ; sigcheck = signature_verify ( ndo , pptr , plen , obj_ptr . rsvp_obj_integrity -> digest , rsvp_clear_checksum , rsvp_com_header ) ; ND_PRINT ( ( ndo , ""(%s)"" , tok2str ( signature_check_values , ""Unknown"" , sigcheck ) ) ) ; obj_tlen += sizeof ( struct rsvp_obj_integrity_t ) ; obj_tptr += sizeof ( struct rsvp_obj_integrity_t ) ; break ; default : hexdump = TRUE ; } break ; case RSVP_OBJ_ADMIN_STATUS : switch ( rsvp_obj_ctype ) { case RSVP_CTYPE_1 : if ( obj_tlen < 4 ) return - 1 ; ND_PRINT ( ( ndo , ""%sFlags[%s]"" , ident , bittok2str ( rsvp_obj_admin_status_flag_values , ""none"" , EXTRACT_32BITS ( obj_tptr ) ) ) ) ; obj_tlen -= 4 ; obj_tptr += 4 ; break ; default : hexdump = TRUE ; } break ; case RSVP_OBJ_LABEL_SET : switch ( rsvp_obj_ctype ) { case RSVP_CTYPE_1 : if ( obj_tlen < 4 ) return - 1 ; action = ( EXTRACT_16BITS ( obj_tptr ) >> 8 ) ; ND_PRINT ( ( ndo , ""%sAction:%s(%u),Labeltype:%u"" , ident , tok2str ( rsvp_obj_label_set_action_values , ""Unknown"" , action ) , action , ( ( EXTRACT_32BITS ( obj_tptr ) & 0x7F ) ) ) ) ; switch ( action ) { case LABEL_SET_INCLUSIVE_RANGE : case LABEL_SET_EXCLUSIVE_RANGE : if ( obj_tlen < 12 ) return - 1 ; ND_PRINT ( ( ndo , ""%sStartrange:%u,Endrange:%u"" , ident , EXTRACT_32BITS ( obj_tptr + 4 ) , EXTRACT_32BITS ( obj_tptr + 8 ) ) ) ; obj_tlen -= 12 ; obj_tptr += 12 ; break ; default : obj_tlen -= 4 ; obj_tptr += 4 ; subchannel = 1 ; while ( obj_tlen >= 4 ) { ND_PRINT ( ( ndo , ""%sSubchannel#%u:%u"" , ident , subchannel , EXTRACT_32BITS ( obj_tptr ) ) ) ; obj_tptr += 4 ; obj_tlen -= 4 ; subchannel ++ ; } break ; } break ; default : hexdump = TRUE ; } break ; case RSVP_OBJ_S2L : switch ( rsvp_obj_ctype ) { case RSVP_CTYPE_IPV4 : if ( obj_tlen < 4 ) return - 1 ; ND_PRINT ( ( ndo , ""%sSub-LSPdestinationaddress:%s"" , ident , ipaddr_string ( ndo , obj_tptr ) ) ) ; obj_tlen -= 4 ; obj_tptr += 4 ; break ; case RSVP_CTYPE_IPV6 : if ( obj_tlen < 16 ) return - 1 ; ND_PRINT ( ( ndo , ""%sSub-LSPdestinationaddress:%s"" , ident , ip6addr_string ( ndo , obj_tptr ) ) ) ; obj_tlen -= 16 ; obj_tptr += 16 ; break ; default : hexdump = TRUE ; } break ; case RSVP_OBJ_SCOPE : case RSVP_OBJ_POLICY_DATA : case RSVP_OBJ_ACCEPT_LABEL_SET : case RSVP_OBJ_PROTECTION : 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 rsvp_object_header ) , ""\\n\\t"" , rsvp_obj_len - sizeof ( struct rsvp_object_header ) ) ; tptr += rsvp_obj_len ; tlen -= rsvp_obj_len ; } return 0 ; invalid : ND_PRINT ( ( ndo , ""%s"" , istr ) ) ; return - 1 ; trunc : ND_PRINT ( ( ndo , ""\\n\\t\\t"" ) ) ; ND_PRINT ( ( ndo , ""%s"" , tstr ) ) ; return - 1 ; } "," ) obj_tptr ; switch ( rsvp_obj_ctype ) { case RSVP_CTYPE_1 : if ( obj_tlen < sizeof ( struct rsvp_obj_frr_t ) ) return - 1 ; bandwidth ) ; ND_PRINT ( ( - 1 ; bw . i = EXTRACT_32BITS ( obj_ptr . rsvp_obj_frr -> bandwidth ) ; ",the-tcpdump-group@tcpdump/3c8a2b0e91d8d8947e89384dacf6b54673083e71,CVE-2017-13048,https://github.com/the-tcpdump-group/tcpdump/commit/3c8a2b0e91d8d8947e89384dacf6b54673083e71,2017-09-14T06:29Z 498,CWE-20,"CWE-20 static int mISDN_sock_recvmsg ( struct kiocb * iocb , struct socket * sock , struct msghdr * msg , size_t len , int flags ) { struct sk_buff * skb ; struct sock * sk = sock -> sk ; struct sockaddr_mISDN * maddr ; int copied , err ; if ( * debug & DEBUG_SOCKET ) printk ( KERN_DEBUG ""%s:len%d,flags%xch.nr%d,proto%x\\n"" , __func__ , ( int ) len , flags , _pms ( sk ) -> ch . nr , sk -> sk_protocol ) ; if ( flags & ( MSG_OOB ) ) return - EOPNOTSUPP ; if ( sk -> sk_state == MISDN_CLOSED ) return 0 ; skb = skb_recv_datagram ( sk , flags , flags & MSG_DONTWAIT , & err ) ; if ( ! skb ) return err ; if ( msg -> msg_namelen >= sizeof ( struct sockaddr_mISDN ) ) { msg -> msg_namelen = sizeof ( struct sockaddr_mISDN ) ; maddr = ( struct sockaddr_mISDN * ) msg -> msg_name ; maddr -> family = AF_ISDN ; maddr -> dev = _pms ( sk ) -> dev -> id ; if ( ( sk -> sk_protocol == ISDN_P_LAPD_TE ) || ( sk -> sk_protocol == ISDN_P_LAPD_NT ) ) { maddr -> channel = ( mISDN_HEAD_ID ( skb ) >> 16 ) & 0xff ; maddr -> tei = ( mISDN_HEAD_ID ( skb ) >> 8 ) & 0xff ; maddr -> sapi = mISDN_HEAD_ID ( skb ) & 0xff ; } else { maddr -> channel = _pms ( sk ) -> ch . nr ; maddr -> sapi = _pms ( sk ) -> ch . addr & 0xFF ; maddr -> tei = ( _pms ( sk ) -> ch . addr >> 8 ) & 0xFF ; } } else { if ( msg -> msg_namelen ) printk ( KERN_WARNING ""%s:toosmallnamelen%d\\n"" , __func__ , msg -> msg_namelen ) ; msg -> msg_namelen = 0 ; } copied = skb -> len + MISDN_HEADER_LEN ; if ( len < copied ) { if ( flags & MSG_PEEK ) atomic_dec ( & skb -> users ) ; else skb_queue_head ( & sk -> sk_receive_queue , skb ) ; return - ENOSPC ; } memcpy ( skb_push ( skb , MISDN_HEADER_LEN ) , mISDN_HEAD_P ( skb ) , MISDN_HEADER_LEN ) ; err = skb_copy_datagram_iovec ( skb , 0 , msg -> msg_iov , copied ) ; mISDN_sock_cmsg ( sk , msg , skb ) ; skb_free_datagram ( sk , skb ) ; return err ? : copied ; } "," sock -> sk ; int copied ( msg -> msg_name ) { struct sockaddr_mISDN * maddr = msg -> msg_name 0xFF ; } msg -> msg_namelen msg -> msg_namelen = sizeof ( * maddr ) ; } copied ",torvalds@linux/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,CVE-2013-7271,https://github.com/torvalds/linux/commit/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,2014-01-06T16:55Z 499,CWE-189,"CWE-189 Datum poly_in ( PG_FUNCTION_ARGS ) { char * str = PG_GETARG_CSTRING ( 0 ) ; POLYGON * poly ; int npts ; int size ; int isopen ; char * s ; if ( ( npts = pair_count ( str , ',' ) ) <= 0 ) ereport ( ERROR , ( errcode ( ERRCODE_INVALID_TEXT_REPRESENTATION ) , errmsg ( ""invalidinputsyntaxfortypepolygon:\\""%s\\"""" , str ) ) ) ; size = offsetof ( POLYGON , p [ 0 ] ) + sizeof ( poly -> p [ 0 ] ) * npts ; poly = ( POLYGON * ) palloc0 ( size ) ; SET_VARSIZE ( poly , size ) ; poly -> npts = npts ; if ( ( ! path_decode ( FALSE , npts , str , & isopen , & s , & ( poly -> p [ 0 ] ) ) ) || ( * s != '\\0' ) ) ereport ( ERROR , ( errcode ( ERRCODE_INVALID_TEXT_REPRESENTATION ) , errmsg ( ""invalidinputsyntaxfortypepolygon:\\""%s\\"""" , str ) ) ) ; make_bound_box ( poly ) ; PG_RETURN_POLYGON_P ( poly ) ; } "," size ; int base_size ; int ) ) ; base_size = sizeof ( poly -> p [ 0 ] ) * npts ; ] ) + base_size ; if ( base_size / npts != 0 ] ) || size <= base_size ) ereport ( ERROR , ( errcode ( ERRCODE_PROGRAM_LIMIT_EXCEEDED ) , errmsg ( ""toomanypointsrequested"" ) ) ) ; poly = ",postgres@postgres/31400a673325147e1205326008e32135a78b4d8a,CVE-2014-2669,https://github.com/postgres/postgres/commit/31400a673325147e1205326008e32135a78b4d8a,2014-03-31T14:58Z 500,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 501,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 502,CWE-264,"CWE-264 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 503,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 504,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 505,CWE-119,"CWE-119 static void update_alt_ref_frame_stats ( VP9_COMP * cpi ) { RATE_CONTROL * const rc = & cpi -> rc ; rc -> frames_since_golden = 0 ; # if CONFIG_MULTIPLE_ARF if ( ! cpi -> multi_arf_enabled ) # endif rc -> source_alt_ref_pending = 0 ; rc -> source_alt_ref_active = 1 ; } "," = 0 ; rc -> source_alt_ref_pending ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 506,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 507,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 508,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 509,CWE-000,"CWE-000 static int translate_desc ( struct vhost_dev * dev , u64 addr , u32 len , struct iovec iov [ ] , int iov_size ) { const struct vhost_memory_region * reg ; struct vhost_memory * mem ; struct iovec * _iov ; u64 s = 0 ; int ret = 0 ; rcu_read_lock ( ) ; mem = rcu_dereference ( dev -> memory ) ; while ( ( u64 ) len > s ) { u64 size ; if ( unlikely ( ret >= iov_size ) ) { ret = - ENOBUFS ; break ; } reg = find_region ( mem , addr , len ) ; if ( unlikely ( ! reg ) ) { ret = - EFAULT ; break ; } _iov = iov + ret ; size = reg -> memory_size - addr + reg -> guest_phys_addr ; _iov -> iov_len = min ( ( u64 ) len , size ) ; _iov -> iov_base = ( void __user * ) ( unsigned long ) ( reg -> userspace_addr + addr - reg -> guest_phys_addr ) ; s += size ; addr += size ; ++ ret ; } rcu_read_unlock ( ) ; return ret ; } "," u64 ) len - s ",torvalds@linux/bd97120fc3d1a11f3124c7c9ba1d91f51829eb85,CVE-2013-0311,https://github.com/torvalds/linux/commit/bd97120fc3d1a11f3124c7c9ba1d91f51829eb85,2013-02-22T00:55Z 510,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 511,CWE-20,"CWE-20 static int zip_read_mac_metadata ( struct archive_read * a , struct archive_entry * entry , struct zip_entry * rsrc ) { struct zip * zip = ( struct zip * ) a -> format -> data ; unsigned char * metadata , * mp ; int64_t offset = archive_filter_bytes ( & a -> archive , 0 ) ; size_t remaining_bytes , metadata_bytes ; ssize_t hsize ; int ret = ARCHIVE_OK , eof ; switch ( rsrc -> compression ) { case 0 : # ifdef HAVE_ZLIB_H case 8 : # endif break ; default : archive_set_error ( & a -> archive , ARCHIVE_ERRNO_FILE_FORMAT , ""UnsupportedZIPcompressionmethod(%s)"" , compression_name ( rsrc -> compression ) ) ; return ( ARCHIVE_WARN ) ; } if ( rsrc -> uncompressed_size > ( 4 * 1024 * 1024 ) ) { archive_set_error ( & a -> archive , ARCHIVE_ERRNO_FILE_FORMAT , ""Macmetadataistoolarge:%jd>4Mbytes"" , ( intmax_t ) rsrc -> uncompressed_size ) ; return ( ARCHIVE_WARN ) ; } metadata = malloc ( ( size_t ) rsrc -> uncompressed_size ) ; if ( metadata == NULL ) { archive_set_error ( & a -> archive , ENOMEM , ""Can\'tallocatememoryforMacmetadata"" ) ; return ( ARCHIVE_FATAL ) ; } if ( offset < rsrc -> local_header_offset ) __archive_read_consume ( a , rsrc -> local_header_offset - offset ) ; else if ( offset != rsrc -> local_header_offset ) { __archive_read_seek ( a , rsrc -> local_header_offset , SEEK_SET ) ; } hsize = zip_get_local_file_header_size ( a , 0 ) ; __archive_read_consume ( a , hsize ) ; remaining_bytes = ( size_t ) rsrc -> compressed_size ; metadata_bytes = ( size_t ) rsrc -> uncompressed_size ; mp = metadata ; eof = 0 ; while ( ! eof && remaining_bytes ) { const unsigned char * p ; ssize_t bytes_avail ; size_t bytes_used ; p = __archive_read_ahead ( a , 1 , & bytes_avail ) ; if ( p == NULL ) { archive_set_error ( & a -> archive , ARCHIVE_ERRNO_FILE_FORMAT , ""TruncatedZIPfileheader"" ) ; ret = ARCHIVE_WARN ; goto exit_mac_metadata ; } if ( ( size_t ) bytes_avail > remaining_bytes ) bytes_avail = remaining_bytes ; switch ( rsrc -> compression ) { case 0 : memcpy ( mp , p , bytes_avail ) ; bytes_used = ( size_t ) bytes_avail ; metadata_bytes -= bytes_used ; mp += bytes_used ; if ( metadata_bytes == 0 ) eof = 1 ; break ; # ifdef HAVE_ZLIB_H case 8 : { int r ; ret = zip_deflate_init ( a , zip ) ; if ( ret != ARCHIVE_OK ) goto exit_mac_metadata ; zip -> stream . next_in = ( Bytef * ) ( uintptr_t ) ( const void * ) p ; zip -> stream . avail_in = ( uInt ) bytes_avail ; zip -> stream . total_in = 0 ; zip -> stream . next_out = mp ; zip -> stream . avail_out = ( uInt ) metadata_bytes ; zip -> stream . total_out = 0 ; r = inflate ( & zip -> stream , 0 ) ; switch ( r ) { case Z_OK : break ; case Z_STREAM_END : eof = 1 ; break ; case Z_MEM_ERROR : archive_set_error ( & a -> archive , ENOMEM , ""OutofmemoryforZIPdecompression"" ) ; ret = ARCHIVE_FATAL ; goto exit_mac_metadata ; default : archive_set_error ( & a -> archive , ARCHIVE_ERRNO_MISC , ""ZIPdecompressionfailed(%d)"" , r ) ; ret = ARCHIVE_FATAL ; goto exit_mac_metadata ; } bytes_used = zip -> stream . total_in ; metadata_bytes -= zip -> stream . total_out ; mp += zip -> stream . total_out ; break ; } # endif default : bytes_used = 0 ; break ; } __archive_read_consume ( a , bytes_used ) ; remaining_bytes -= bytes_used ; } archive_entry_copy_mac_metadata ( entry , metadata , ( size_t ) rsrc -> uncompressed_size - metadata_bytes ) ; exit_mac_metadata : __archive_read_seek ( a , offset , SEEK_SET ) ; zip -> decompress_init = 0 ; free ( metadata ) ; return ( ret ) ; } "," case 0 : if ( rsrc -> uncompressed_size != rsrc -> compressed_size ) { archive_set_error ( & a -> archive , ARCHIVE_ERRNO_FILE_FORMAT , ""MalformedOSXmetadataentry:inconsistentsize"" ) ; return ( ARCHIVE_FATAL ) ; } rsrc -> uncompressed_size ) ; return ( ARCHIVE_WARN ) ; } if ( rsrc -> compressed_size > ( 4 * 1024 * 1024 ) ) { archive_set_error ( & a -> archive , ARCHIVE_ERRNO_FILE_FORMAT , ""Macmetadataistoolarge:%jd>4Mbytes"" , ( intmax_t ) rsrc -> compressed_size case 0 : if ( ( size_t ) bytes_avail > metadata_bytes ) bytes_avail = metadata_bytes ; ",libarchive@libarchive/d0331e8e5b05b475f20b1f3101fe1ad772d7e7e7,CVE-2016-1541,https://github.com/libarchive/libarchive/commit/d0331e8e5b05b475f20b1f3101fe1ad772d7e7e7,2016-05-07T10:59Z 512,CWE-119,"CWE-119 static void update_layer_contexts ( VP8_COMP * cpi ) { VP8_CONFIG * oxcf = & cpi -> oxcf ; if ( oxcf -> number_of_layers > 1 ) { unsigned int i ; double prev_layer_framerate = 0 ; assert ( oxcf -> number_of_layers <= VPX_TS_MAX_LAYERS ) ; for ( i = 0 ; i < oxcf -> number_of_layers ; i ++ ) { LAYER_CONTEXT * lc = & cpi -> layer_context [ i ] ; lc -> framerate = cpi -> ref_framerate / oxcf -> rate_decimator [ i ] ; lc -> target_bandwidth = oxcf -> target_bitrate [ i ] * 1000 ; lc -> starting_buffer_level = rescale ( ( int ) oxcf -> starting_buffer_level_in_ms , lc -> target_bandwidth , 1000 ) ; if ( oxcf -> optimal_buffer_level == 0 ) lc -> optimal_buffer_level = lc -> target_bandwidth / 8 ; else lc -> optimal_buffer_level = rescale ( ( int ) oxcf -> optimal_buffer_level_in_ms , lc -> target_bandwidth , 1000 ) ; if ( oxcf -> maximum_buffer_size == 0 ) lc -> maximum_buffer_size = lc -> target_bandwidth / 8 ; else lc -> maximum_buffer_size = rescale ( ( int ) oxcf -> maximum_buffer_size_in_ms , lc -> target_bandwidth , 1000 ) ; if ( i > 0 ) lc -> avg_frame_size_for_layer = ( int ) ( ( oxcf -> target_bitrate [ i ] - oxcf -> target_bitrate [ i - 1 ] ) * 1000 / ( lc -> framerate - prev_layer_framerate ) ) ; prev_layer_framerate = lc -> framerate ; } } } "," oxcf -> number_of_layers && i < VPX_TS_MAX_LAYERS ; ++ i ) { LAYER_CONTEXT ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 513,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 514,CWE-362,"CWE-362 static unsigned long get_seg_limit ( struct pt_regs * regs , int seg_reg_idx ) { struct desc_struct * desc ; unsigned long limit ; short sel ; sel = get_segment_selector ( regs , seg_reg_idx ) ; if ( sel < 0 ) return 0 ; if ( user_64bit_mode ( regs ) || v8086_mode ( regs ) ) return - 1L ; if ( ! sel ) return 0 ; desc = get_desc ( sel ) ; if ( ! desc ) return 0 ; limit = get_desc_limit ( desc ) ; if ( desc -> g ) limit = ( limit << 12 ) + 0xfff ; return limit ; } "," { struct desc_struct desc ; unsigned return 0 ; if ( ! if ( ! get_desc ( & desc , sel ) ) return 0 = get_desc_limit ( & if ( desc . g ) limit ",torvalds@linux/de9f869616dd95e95c00bdd6b0fcd3421e8a4323,CVE-2019-13233,https://github.com/torvalds/linux/commit/de9f869616dd95e95c00bdd6b0fcd3421e8a4323,2019-07-04T13:15Z 515,CWE-125,"CWE-125 static int lldp_private_8023_print ( netdissect_options * ndo , const u_char * tptr , u_int tlv_len ) { int subtype , hexdump = FALSE ; if ( tlv_len < 4 ) { return hexdump ; } subtype = * ( tptr + 3 ) ; ND_PRINT ( ( ndo , ""\\n\\t%sSubtype(%u)"" , tok2str ( lldp_8023_subtype_values , ""unknown"" , subtype ) , subtype ) ) ; switch ( subtype ) { case LLDP_PRIVATE_8023_SUBTYPE_MACPHY : if ( tlv_len < 9 ) { return hexdump ; } ND_PRINT ( ( ndo , ""\\n\\tautonegotiation[%s](0x%02x)"" , bittok2str ( lldp_8023_autonegotiation_values , ""none"" , * ( tptr + 4 ) ) , * ( tptr + 4 ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\tPMDautonegcapability[%s](0x%04x)"" , bittok2str ( lldp_pmd_capability_values , ""unknown"" , EXTRACT_16BITS ( tptr + 5 ) ) , EXTRACT_16BITS ( tptr + 5 ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\tMAUtype%s(0x%04x)"" , tok2str ( lldp_mau_types_values , ""unknown"" , EXTRACT_16BITS ( tptr + 7 ) ) , EXTRACT_16BITS ( tptr + 7 ) ) ) ; break ; case LLDP_PRIVATE_8023_SUBTYPE_MDIPOWER : if ( tlv_len < 7 ) { return hexdump ; } ND_PRINT ( ( ndo , ""\\n\\tMDIpowersupport[%s],powerpair%s,powerclass%s"" , bittok2str ( lldp_mdi_values , ""none"" , * ( tptr + 4 ) ) , tok2str ( lldp_mdi_power_pairs_values , ""unknown"" , * ( tptr + 5 ) ) , tok2str ( lldp_mdi_power_class_values , ""unknown"" , * ( tptr + 6 ) ) ) ) ; break ; case LLDP_PRIVATE_8023_SUBTYPE_LINKAGGR : if ( tlv_len < 9 ) { return hexdump ; } ND_PRINT ( ( ndo , ""\\n\\taggregationstatus[%s],aggregationportID%u"" , bittok2str ( lldp_aggregation_values , ""none"" , * ( tptr + 4 ) ) , EXTRACT_32BITS ( tptr + 5 ) ) ) ; break ; case LLDP_PRIVATE_8023_SUBTYPE_MTU : ND_PRINT ( ( ndo , ""\\n\\tMTUsize%u"" , EXTRACT_16BITS ( tptr + 4 ) ) ) ; break ; default : hexdump = TRUE ; break ; } return hexdump ; } "," case LLDP_PRIVATE_8023_SUBTYPE_MTU : if ( tlv_len < 6 ) { return hexdump ; } ",the-tcpdump-group@tcpdump/e6511cc1a950fe1566b2236329d6b4bd0826cc7a,CVE-2017-13054,https://github.com/the-tcpdump-group/tcpdump/commit/e6511cc1a950fe1566b2236329d6b4bd0826cc7a,2017-09-14T06:29Z 516,CWE-119,"CWE-119 vpx_codec_err_t vpx_codec_set_frame_buffer_functions ( vpx_codec_ctx_t * ctx , vpx_get_frame_buffer_cb_fn_t cb_get , vpx_release_frame_buffer_cb_fn_t cb_release , void * cb_priv ) { vpx_codec_err_t res ; if ( ! ctx || ! cb_get || ! cb_release ) { res = VPX_CODEC_INVALID_PARAM ; } else if ( ! ctx -> iface || ! ctx -> priv || ! ( ctx -> iface -> caps & VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER ) ) { res = VPX_CODEC_ERROR ; } else { res = ctx -> iface -> dec . set_fb_fn ( ctx -> priv -> alg_priv , cb_get , cb_release , cb_priv ) ; } return SAVE_STATUS ( ctx , res ) ; } "," . set_fb_fn ( get_alg_priv ( ctx ) , cb_get , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 517,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 518,CWE-20,"CWE-20 static int futex_wait_requeue_pi ( u32 __user * uaddr , unsigned int flags , u32 val , ktime_t * abs_time , u32 bitset , u32 __user * uaddr2 ) { struct hrtimer_sleeper timeout , * to = NULL ; struct rt_mutex_waiter rt_waiter ; struct rt_mutex * pi_mutex = NULL ; struct futex_hash_bucket * hb ; union futex_key key2 = FUTEX_KEY_INIT ; struct futex_q q = futex_q_init ; int res , ret ; if ( ! bitset ) return - EINVAL ; if ( abs_time ) { to = & timeout ; hrtimer_init_on_stack ( & to -> timer , ( flags & FLAGS_CLOCKRT ) ? CLOCK_REALTIME : CLOCK_MONOTONIC , HRTIMER_MODE_ABS ) ; hrtimer_init_sleeper ( to , current ) ; hrtimer_set_expires_range_ns ( & to -> timer , * abs_time , current -> timer_slack_ns ) ; } debug_rt_mutex_init_waiter ( & rt_waiter ) ; rt_waiter . task = NULL ; ret = get_futex_key ( uaddr2 , flags & FLAGS_SHARED , & key2 , VERIFY_WRITE ) ; if ( unlikely ( ret != 0 ) ) goto out ; q . bitset = bitset ; q . rt_waiter = & rt_waiter ; q . requeue_pi_key = & key2 ; ret = futex_wait_setup ( uaddr , val , flags , & q , & hb ) ; if ( ret ) goto out_key2 ; futex_wait_queue_me ( hb , & q , to ) ; spin_lock ( & hb -> lock ) ; ret = handle_early_requeue_pi_wakeup ( hb , & q , & key2 , to ) ; spin_unlock ( & hb -> lock ) ; if ( ret ) goto out_put_keys ; if ( ! q . rt_waiter ) { if ( q . pi_state && ( q . pi_state -> owner != current ) ) { spin_lock ( q . lock_ptr ) ; ret = fixup_pi_state_owner ( uaddr2 , & q , current ) ; spin_unlock ( q . lock_ptr ) ; } } else { WARN_ON ( ! q . pi_state ) ; pi_mutex = & q . pi_state -> pi_mutex ; ret = rt_mutex_finish_proxy_lock ( pi_mutex , to , & rt_waiter , 1 ) ; debug_rt_mutex_free_waiter ( & rt_waiter ) ; spin_lock ( q . lock_ptr ) ; res = fixup_owner ( uaddr2 , & q , ! ret ) ; if ( res ) ret = ( res < 0 ) ? res : 0 ; unqueue_me_pi ( & q ) ; } if ( ret == - EFAULT ) { if ( pi_mutex && rt_mutex_owner ( pi_mutex ) == current ) rt_mutex_unlock ( pi_mutex ) ; } else if ( ret == - EINTR ) { ret = - EWOULDBLOCK ; } out_put_keys : put_futex_key ( & q . key ) ; out_key2 : put_futex_key ( & key2 ) ; out : if ( to ) { hrtimer_cancel ( & to -> timer ) ; destroy_hrtimer_on_stack ( & to -> timer ) ; } return ret ; } "," res , ret ; if ( uaddr == uaddr2 ) return - EINVAL ",torvalds@linux/6f7b0a2a5c0fb03be7c25bd1745baa50582348ef,CVE-2012-6647,https://github.com/torvalds/linux/commit/6f7b0a2a5c0fb03be7c25bd1745baa50582348ef,2014-05-26T22:55Z 519,CWE-200,"CWE-200 static void tty_set_termios_ldisc ( struct tty_struct * tty , int num ) { down_write ( & tty -> termios_rwsem ) ; tty -> termios . c_line = num ; up_write ( & tty -> termios_rwsem ) ; } "," termios_rwsem ) ; tty -> disc_data = NULL ; tty -> receive_room = 0 ; ",torvalds@linux/dd42bf1197144ede075a9d4793123f7689e164bc,CVE-2015-8964,https://github.com/torvalds/linux/commit/dd42bf1197144ede075a9d4793123f7689e164bc,2016-11-16T05:59Z 520,CWE-000,"CWE-000 int dtls1_get_record ( SSL * s ) { int ssl_major , ssl_minor ; int i , n ; SSL3_RECORD * rr ; unsigned char * p = NULL ; unsigned short version ; DTLS1_BITMAP * bitmap ; unsigned int is_next_epoch ; rr = & ( s -> s3 -> rrec ) ; dtls1_process_buffered_records ( s ) ; if ( dtls1_get_processed_record ( s ) ) return 1 ; again : if ( ( s -> rstate != SSL_ST_READ_BODY ) || ( s -> packet_length < DTLS1_RT_HEADER_LENGTH ) ) { n = ssl3_read_n ( s , DTLS1_RT_HEADER_LENGTH , s -> s3 -> rbuf . len , 0 ) ; if ( n <= 0 ) return ( n ) ; if ( s -> packet_length != DTLS1_RT_HEADER_LENGTH ) { s -> packet_length = 0 ; goto again ; } s -> rstate = SSL_ST_READ_BODY ; p = s -> packet ; if ( s -> msg_callback ) s -> msg_callback ( 0 , 0 , SSL3_RT_HEADER , p , DTLS1_RT_HEADER_LENGTH , s , s -> msg_callback_arg ) ; rr -> type = * ( p ++ ) ; ssl_major = * ( p ++ ) ; ssl_minor = * ( p ++ ) ; version = ( ssl_major << 8 ) | ssl_minor ; n2s ( p , rr -> epoch ) ; memcpy ( & ( s -> s3 -> read_sequence [ 2 ] ) , p , 6 ) ; p += 6 ; n2s ( p , rr -> length ) ; if ( ! s -> first_packet ) { if ( version != s -> version ) { rr -> length = 0 ; s -> packet_length = 0 ; goto again ; } } if ( ( version & 0xff00 ) != ( s -> version & 0xff00 ) ) { rr -> length = 0 ; s -> packet_length = 0 ; goto again ; } if ( rr -> length > SSL3_RT_MAX_ENCRYPTED_LENGTH ) { rr -> length = 0 ; s -> packet_length = 0 ; goto again ; } } if ( rr -> length > s -> packet_length - DTLS1_RT_HEADER_LENGTH ) { i = rr -> length ; n = ssl3_read_n ( s , i , i , 1 ) ; if ( n <= 0 ) return ( n ) ; if ( n != i ) { rr -> length = 0 ; s -> packet_length = 0 ; goto again ; } } s -> rstate = SSL_ST_READ_HEADER ; bitmap = dtls1_get_bitmap ( s , rr , & is_next_epoch ) ; if ( bitmap == NULL ) { rr -> length = 0 ; s -> packet_length = 0 ; goto again ; } # ifndef OPENSSL_NO_SCTP if ( ! BIO_dgram_is_sctp ( SSL_get_rbio ( s ) ) ) { # endif if ( ! ( s -> d1 -> listen && rr -> type == SSL3_RT_HANDSHAKE && * p == SSL3_MT_CLIENT_HELLO ) && ! dtls1_record_replay_check ( s , bitmap ) ) { rr -> length = 0 ; s -> packet_length = 0 ; goto again ; } # ifndef OPENSSL_NO_SCTP } # endif if ( rr -> length == 0 ) goto again ; if ( is_next_epoch ) { if ( ( SSL_in_init ( s ) || s -> in_handshake ) && ! s -> d1 -> listen ) { dtls1_buffer_record ( s , & ( s -> d1 -> unprocessed_rcds ) , rr -> seq_num ) ; } rr -> length = 0 ; s -> packet_length = 0 ; goto again ; } if ( ! dtls1_process_record ( s ) ) { rr -> length = 0 ; s -> packet_length = 0 ; goto again ; } return ( 1 ) ; } "," if ( n != i ) ",openssl@openssl/feba02f3919495e1b960c33ba849e10e77d0785d,CVE-2014-3571,https://github.com/openssl/openssl/commit/feba02f3919495e1b960c33ba849e10e77d0785d,2015-01-09T02:59Z 521,CWE-415,"CWE-415 struct sock * inet_csk_clone_lock ( const struct sock * sk , const struct request_sock * req , const gfp_t priority ) { struct sock * newsk = sk_clone_lock ( sk , priority ) ; if ( newsk ) { struct inet_connection_sock * newicsk = inet_csk ( newsk ) ; newsk -> sk_state = TCP_SYN_RECV ; newicsk -> icsk_bind_hash = NULL ; inet_sk ( newsk ) -> inet_dport = inet_rsk ( req ) -> ir_rmt_port ; inet_sk ( newsk ) -> inet_num = inet_rsk ( req ) -> ir_num ; inet_sk ( newsk ) -> inet_sport = htons ( inet_rsk ( req ) -> ir_num ) ; newsk -> sk_write_space = sk_stream_write_space ; sock_reset_flag ( newsk , SOCK_RCU_FREE ) ; newsk -> sk_mark = inet_rsk ( req ) -> ir_mark ; atomic64_set ( & newsk -> sk_cookie , atomic64_read ( & inet_rsk ( req ) -> ir_cookie ) ) ; newicsk -> icsk_retransmits = 0 ; newicsk -> icsk_backoff = 0 ; newicsk -> icsk_probes_out = 0 ; memset ( & newicsk -> icsk_accept_queue , 0 , sizeof ( newicsk -> icsk_accept_queue ) ) ; security_inet_csk_clone ( newsk , req ) ; } return newsk ; } "," SOCK_RCU_FREE ) ; inet_sk ( newsk ) -> mc_list = NULL ; ",torvalds@linux/657831ffc38e30092a2d5f03d385d710eb88b09a,CVE-2017-8890,https://github.com/torvalds/linux/commit/657831ffc38e30092a2d5f03d385d710eb88b09a,2017-05-10T16:29Z 522,CWE-362,"CWE-362 static int sctp_wait_for_sndbuf ( struct sctp_association * asoc , long * timeo_p , size_t msg_len ) { struct sock * sk = asoc -> base . sk ; int err = 0 ; long current_timeo = * timeo_p ; DEFINE_WAIT ( wait ) ; pr_debug ( ""%s:asoc:%p,timeo:%ld,msg_len:%zu\\n"" , __func__ , asoc , * timeo_p , msg_len ) ; sctp_association_hold ( asoc ) ; for ( ; ; ) { prepare_to_wait_exclusive ( & asoc -> wait , & wait , TASK_INTERRUPTIBLE ) ; if ( ! * timeo_p ) goto do_nonblock ; if ( sk -> sk_err || asoc -> state >= SCTP_STATE_SHUTDOWN_PENDING || asoc -> base . dead ) goto do_error ; if ( signal_pending ( current ) ) goto do_interrupted ; if ( msg_len <= sctp_wspace ( asoc ) ) break ; release_sock ( sk ) ; current_timeo = schedule_timeout ( current_timeo ) ; BUG_ON ( sk != asoc -> base . sk ) ; lock_sock ( sk ) ; * timeo_p = current_timeo ; } out : finish_wait ( & asoc -> wait , & wait ) ; sctp_association_put ( asoc ) ; return err ; do_error : err = - EPIPE ; goto out ; do_interrupted : err = sock_intr_errno ( * timeo_p ) ; goto out ; do_nonblock : err = - EAGAIN ; goto out ; } "," current_timeo ) ; if ( sk != . sk ) goto do_error ",torvalds@linux/2dcab598484185dea7ec22219c76dcdd59e3cb90,CVE-2017-5986,https://github.com/torvalds/linux/commit/2dcab598484185dea7ec22219c76dcdd59e3cb90,2017-02-18T21:59Z 523,CWE-119,"CWE-119 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 ) ) { if ( dlen < 2 ) break ; dlen -= 2 ; * pt ++ = '\\\\' ; * pt ++ = * s ; } else { * pt ++ = * s ; dlen -- ; } } * pt ++ = \'""\' ; * pt = '\\0' ; } "," ; dlen -= 3 ; for ( ",neomutt@neomutt/e27b65b3bf8defa34db58919496056caf3850cd4,CVE-2018-14352,https://github.com/neomutt/neomutt/commit/e27b65b3bf8defa34db58919496056caf3850cd4,2018-07-17T17:29Z 524,CWE-125,"CWE-125 static const u_char * ikev1_n_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 doi0 _U_ , uint32_t proto0 _U_ , int depth _U_ ) { const struct ikev1_pl_n * p ; struct ikev1_pl_n n ; const u_char * cp ; const u_char * ep2 ; uint32_t doi ; uint32_t proto ; static const char * notify_error_str [ ] = { NULL , ""INVALID-PAYLOAD-TYPE"" , ""DOI-NOT-SUPPORTED"" , ""SITUATION-NOT-SUPPORTED"" , ""INVALID-COOKIE"" , ""INVALID-MAJOR-VERSION"" , ""INVALID-MINOR-VERSION"" , ""INVALID-EXCHANGE-TYPE"" , ""INVALID-FLAGS"" , ""INVALID-MESSAGE-ID"" , ""INVALID-PROTOCOL-ID"" , ""INVALID-SPI"" , ""INVALID-TRANSFORM-ID"" , ""ATTRIBUTES-NOT-SUPPORTED"" , ""NO-PROPOSAL-CHOSEN"" , ""BAD-PROPOSAL-SYNTAX"" , ""PAYLOAD-MALFORMED"" , ""INVALID-KEY-INFORMATION"" , ""INVALID-ID-INFORMATION"" , ""INVALID-CERT-ENCODING"" , ""INVALID-CERTIFICATE"" , ""CERT-TYPE-UNSUPPORTED"" , ""INVALID-CERT-AUTHORITY"" , ""INVALID-HASH-INFORMATION"" , ""AUTHENTICATION-FAILED"" , ""INVALID-SIGNATURE"" , ""ADDRESS-NOTIFICATION"" , ""NOTIFY-SA-LIFETIME"" , ""CERTIFICATE-UNAVAILABLE"" , ""UNSUPPORTED-EXCHANGE-TYPE"" , ""UNEQUAL-PAYLOAD-LENGTHS"" , } ; static const char * ipsec_notify_error_str [ ] = { ""RESERVED"" , } ; static const char * notify_status_str [ ] = { ""CONNECTED"" , } ; static const char * ipsec_notify_status_str [ ] = { ""RESPONDER-LIFETIME"" , ""REPLAY-STATUS"" , ""INITIAL-CONTACT"" , } ; # define NOTIFY_ERROR_STR ( x ) STR_OR_ID ( ( x ) , notify_error_str ) # define IPSEC_NOTIFY_ERROR_STR ( x ) STR_OR_ID ( ( u_int ) ( ( x ) - 8192 ) , ipsec_notify_error_str ) # define NOTIFY_STATUS_STR ( x ) STR_OR_ID ( ( u_int ) ( ( x ) - 16384 ) , notify_status_str ) # define IPSEC_NOTIFY_STATUS_STR ( x ) STR_OR_ID ( ( u_int ) ( ( x ) - 24576 ) , ipsec_notify_status_str ) ND_PRINT ( ( ndo , ""%s:"" , NPSTR ( ISAKMP_NPTYPE_N ) ) ) ; p = ( const struct ikev1_pl_n * ) ext ; ND_TCHECK ( * p ) ; UNALIGNED_MEMCPY ( & n , ext , sizeof ( n ) ) ; doi = ntohl ( n . doi ) ; proto = n . prot_id ; if ( doi != 1 ) { ND_PRINT ( ( ndo , ""doi=%d"" , doi ) ) ; ND_PRINT ( ( ndo , ""proto=%d"" , proto ) ) ; if ( ntohs ( n . type ) < 8192 ) ND_PRINT ( ( ndo , ""type=%s"" , NOTIFY_ERROR_STR ( ntohs ( n . type ) ) ) ) ; else if ( ntohs ( n . type ) < 16384 ) ND_PRINT ( ( ndo , ""type=%s"" , numstr ( ntohs ( n . type ) ) ) ) ; else if ( ntohs ( n . type ) < 24576 ) ND_PRINT ( ( ndo , ""type=%s"" , NOTIFY_STATUS_STR ( ntohs ( n . type ) ) ) ) ; else ND_PRINT ( ( ndo , ""type=%s"" , numstr ( ntohs ( n . type ) ) ) ) ; if ( n . spi_size ) { ND_PRINT ( ( ndo , ""spi="" ) ) ; if ( ! rawprint ( ndo , ( const uint8_t * ) ( p + 1 ) , n . spi_size ) ) goto trunc ; } return ( const u_char * ) ( p + 1 ) + n . spi_size ; } ND_PRINT ( ( ndo , ""doi=ipsec"" ) ) ; ND_PRINT ( ( ndo , ""proto=%s"" , PROTOIDSTR ( proto ) ) ) ; if ( ntohs ( n . type ) < 8192 ) ND_PRINT ( ( ndo , ""type=%s"" , NOTIFY_ERROR_STR ( ntohs ( n . type ) ) ) ) ; else if ( ntohs ( n . type ) < 16384 ) ND_PRINT ( ( ndo , ""type=%s"" , IPSEC_NOTIFY_ERROR_STR ( ntohs ( n . type ) ) ) ) ; else if ( ntohs ( n . type ) < 24576 ) ND_PRINT ( ( ndo , ""type=%s"" , NOTIFY_STATUS_STR ( ntohs ( n . type ) ) ) ) ; else if ( ntohs ( n . type ) < 32768 ) ND_PRINT ( ( ndo , ""type=%s"" , IPSEC_NOTIFY_STATUS_STR ( ntohs ( n . type ) ) ) ) ; else ND_PRINT ( ( ndo , ""type=%s"" , numstr ( ntohs ( n . type ) ) ) ) ; if ( n . spi_size ) { ND_PRINT ( ( ndo , ""spi="" ) ) ; if ( ! rawprint ( ndo , ( const uint8_t * ) ( p + 1 ) , n . spi_size ) ) goto trunc ; } cp = ( const u_char * ) ( p + 1 ) + n . spi_size ; ep2 = ( const u_char * ) p + item_len ; if ( cp < ep ) { switch ( ntohs ( n . type ) ) { case IPSECDOI_NTYPE_RESPONDER_LIFETIME : { const struct attrmap * map = oakley_t_map ; size_t nmap = sizeof ( oakley_t_map ) / sizeof ( oakley_t_map [ 0 ] ) ; ND_PRINT ( ( ndo , ""attrs=("" ) ) ; while ( cp < ep && cp < ep2 ) { cp = ikev1_attrmap_print ( ndo , cp , ( ep < ep2 ) ? ep : ep2 , map , nmap ) ; } ND_PRINT ( ( ndo , "")"" ) ) ; break ; } case IPSECDOI_NTYPE_REPLAY_STATUS : ND_PRINT ( ( ndo , ""status=("" ) ) ; ND_PRINT ( ( ndo , ""replaydetection%sabled"" , EXTRACT_32BITS ( cp ) ? ""en"" : ""dis"" ) ) ; ND_PRINT ( ( ndo , "")"" ) ) ; break ; default : if ( ndo -> ndo_vflag > 3 ) { ND_PRINT ( ( ndo , ""data=("" ) ) ; if ( ! rawprint ( ndo , ( const uint8_t * ) ( cp ) , ep - cp ) ) goto trunc ; ND_PRINT ( ( ndo , "")"" ) ) ; } else { if ( ! ike_show_somedata ( ndo , cp , ep ) ) goto trunc ; } break ; } } return ( const u_char * ) ext + item_len ; trunc : ND_PRINT ( ( ndo , ""[|%s]"" , NPSTR ( ISAKMP_NPTYPE_N ) ) ) ; return NULL ; } "," , cp , ep2 , map , nmap ) ; if ( cp == NULL ) { ND_PRINT ( ( ndo , "")"" ) ) ; goto trunc ; } ",the-tcpdump-group@tcpdump/e0a5a02b0fc1900a69d6c37ed0aab36fb8494e6d,CVE-2017-13039,https://github.com/the-tcpdump-group/tcpdump/commit/e0a5a02b0fc1900a69d6c37ed0aab36fb8494e6d,2017-09-14T06:29Z 525,CWE-119,"CWE-119 static void fdct8 ( const int16_t * input , int16_t * output ) { 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 = x2 * cospi_24_64 + x3 * cospi_8_64 ; t3 = - x2 * cospi_8_64 + x3 * cospi_24_64 ; output [ 0 ] = fdct_round_shift ( t0 ) ; output [ 2 ] = fdct_round_shift ( t2 ) ; output [ 4 ] = fdct_round_shift ( t1 ) ; output [ 6 ] = 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 ; output [ 1 ] = fdct_round_shift ( t0 ) ; output [ 3 ] = fdct_round_shift ( t2 ) ; output [ 5 ] = fdct_round_shift ( t1 ) ; output [ 7 ] = fdct_round_shift ( t3 ) ; } "," fdct8 ( const tran_low_t * input , tran_low_t * output ) output ) { tran_high_t s0 , s1 , s7 ; tran_high_t t0 , t1 , t2 , t3 ; tran_high_t x0 , x1 0 ] = ( tran_low_t ) 2 ] = ( tran_low_t ) 4 ] = ( tran_low_t ) 6 ] = ( tran_low_t ) ; t2 = ( tran_low_t ) fdct_round_shift ( t0 ) ; t3 = ( tran_low_t ) fdct_round_shift ( t1 1 ] = ( tran_low_t ) 3 ] = ( tran_low_t ) 5 ] = ( tran_low_t ) 7 ] = ( tran_low_t ) ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 526,CWE-416,"CWE-416 static int rm_read_multi ( AVFormatContext * s , AVIOContext * pb , AVStream * st , char * mime ) { int number_of_streams = avio_rb16 ( pb ) ; int number_of_mdpr ; int i , ret ; unsigned size2 ; for ( i = 0 ; i < number_of_streams ; i ++ ) avio_rb16 ( pb ) ; number_of_mdpr = avio_rb16 ( pb ) ; if ( number_of_mdpr != 1 ) { avpriv_request_sample ( s , ""MLTIwithmultiple(%d)MDPR"" , number_of_mdpr ) ; } for ( i = 0 ; i < number_of_mdpr ; i ++ ) { AVStream * st2 ; if ( i > 0 ) { st2 = avformat_new_stream ( s , NULL ) ; if ( ! st2 ) { ret = AVERROR ( ENOMEM ) ; return ret ; } st2 -> id = st -> id + ( i << 16 ) ; st2 -> codecpar -> bit_rate = st -> codecpar -> bit_rate ; st2 -> start_time = st -> start_time ; st2 -> duration = st -> duration ; st2 -> codecpar -> codec_type = AVMEDIA_TYPE_DATA ; st2 -> priv_data = ff_rm_alloc_rmstream ( ) ; if ( ! st2 -> priv_data ) return AVERROR ( ENOMEM ) ; } else st2 = st ; size2 = avio_rb32 ( pb ) ; ret = ff_rm_read_mdpr_codecdata ( s , s -> pb , st2 , st2 -> priv_data , size2 , mime ) ; if ( ret < 0 ) return ret ; } return 0 ; } "," , size2 , NULL ) ; if ",FFmpeg@FFmpeg/a7e032a277452366771951e29fd0bf2bd5c029f0,CVE-2018-1999013,https://github.com/FFmpeg/FFmpeg/commit/a7e032a277452366771951e29fd0bf2bd5c029f0,2018-07-23T15:29Z 527,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 528,CWE-19,"CWE-19 int xfs_attr3_leaf_flipflags ( struct xfs_da_args * args ) { struct xfs_attr_leafblock * leaf1 ; struct xfs_attr_leafblock * leaf2 ; struct xfs_attr_leaf_entry * entry1 ; struct xfs_attr_leaf_entry * entry2 ; struct xfs_attr_leaf_name_remote * name_rmt ; struct xfs_buf * bp1 ; struct xfs_buf * bp2 ; int error ; # ifdef DEBUG struct xfs_attr3_icleaf_hdr ichdr1 ; struct xfs_attr3_icleaf_hdr ichdr2 ; xfs_attr_leaf_name_local_t * name_loc ; int namelen1 , namelen2 ; char * name1 , * name2 ; # endif trace_xfs_attr_leaf_flipflags ( args ) ; error = xfs_attr3_leaf_read ( args -> trans , args -> dp , args -> blkno , - 1 , & bp1 ) ; if ( error ) return error ; if ( args -> blkno2 != args -> blkno ) { error = xfs_attr3_leaf_read ( args -> trans , args -> dp , args -> blkno2 , - 1 , & bp2 ) ; if ( error ) return error ; } else { bp2 = bp1 ; } leaf1 = bp1 -> b_addr ; entry1 = & xfs_attr3_leaf_entryp ( leaf1 ) [ args -> index ] ; leaf2 = bp2 -> b_addr ; entry2 = & xfs_attr3_leaf_entryp ( leaf2 ) [ args -> index2 ] ; # ifdef DEBUG xfs_attr3_leaf_hdr_from_disk ( & ichdr1 , leaf1 ) ; ASSERT ( args -> index < ichdr1 . count ) ; ASSERT ( args -> index >= 0 ) ; xfs_attr3_leaf_hdr_from_disk ( & ichdr2 , leaf2 ) ; ASSERT ( args -> index2 < ichdr2 . count ) ; ASSERT ( args -> index2 >= 0 ) ; if ( entry1 -> flags & XFS_ATTR_LOCAL ) { name_loc = xfs_attr3_leaf_name_local ( leaf1 , args -> index ) ; namelen1 = name_loc -> namelen ; name1 = ( char * ) name_loc -> nameval ; } else { name_rmt = xfs_attr3_leaf_name_remote ( leaf1 , args -> index ) ; namelen1 = name_rmt -> namelen ; name1 = ( char * ) name_rmt -> name ; } if ( entry2 -> flags & XFS_ATTR_LOCAL ) { name_loc = xfs_attr3_leaf_name_local ( leaf2 , args -> index2 ) ; namelen2 = name_loc -> namelen ; name2 = ( char * ) name_loc -> nameval ; } else { name_rmt = xfs_attr3_leaf_name_remote ( leaf2 , args -> index2 ) ; namelen2 = name_rmt -> namelen ; name2 = ( char * ) name_rmt -> name ; } ASSERT ( be32_to_cpu ( entry1 -> hashval ) == be32_to_cpu ( entry2 -> hashval ) ) ; ASSERT ( namelen1 == namelen2 ) ; ASSERT ( memcmp ( name1 , name2 , namelen1 ) == 0 ) ; # endif ASSERT ( entry1 -> flags & XFS_ATTR_INCOMPLETE ) ; ASSERT ( ( entry2 -> flags & XFS_ATTR_INCOMPLETE ) == 0 ) ; entry1 -> flags &= ~ XFS_ATTR_INCOMPLETE ; xfs_trans_log_buf ( args -> trans , bp1 , XFS_DA_LOGRANGE ( leaf1 , entry1 , sizeof ( * entry1 ) ) ) ; if ( args -> rmtblkno ) { ASSERT ( ( entry1 -> flags & XFS_ATTR_LOCAL ) == 0 ) ; name_rmt = xfs_attr3_leaf_name_remote ( leaf1 , args -> index ) ; name_rmt -> valueblk = cpu_to_be32 ( args -> rmtblkno ) ; name_rmt -> valuelen = cpu_to_be32 ( args -> valuelen ) ; xfs_trans_log_buf ( args -> trans , bp1 , XFS_DA_LOGRANGE ( leaf1 , name_rmt , sizeof ( * name_rmt ) ) ) ; } entry2 -> flags |= XFS_ATTR_INCOMPLETE ; xfs_trans_log_buf ( args -> trans , bp2 , XFS_DA_LOGRANGE ( leaf2 , entry2 , sizeof ( * entry2 ) ) ) ; if ( ( entry2 -> flags & XFS_ATTR_LOCAL ) == 0 ) { name_rmt = xfs_attr3_leaf_name_remote ( leaf2 , args -> index2 ) ; name_rmt -> valueblk = 0 ; name_rmt -> valuelen = 0 ; xfs_trans_log_buf ( args -> trans , bp2 , XFS_DA_LOGRANGE ( leaf2 , name_rmt , sizeof ( * name_rmt ) ) ) ; } error = xfs_trans_roll ( & args -> trans , args -> dp ) ; return error ; } "," ( args -> rmtvaluelen ) ; xfs_trans_log_buf ",torvalds@linux/8275cdd0e7ac550dcce2b3ef6d2fb3b808c1ae59,CVE-2015-0274,https://github.com/torvalds/linux/commit/8275cdd0e7ac550dcce2b3ef6d2fb3b808c1ae59,2015-03-16T10:59Z 529,CWE-119,"CWE-119 static void read_intra_frame_mode_info ( VP9_COMMON * const cm , MACROBLOCKD * const xd , int mi_row , int mi_col , vp9_reader * r ) { MODE_INFO * const mi = xd -> mi [ 0 ] ; MB_MODE_INFO * const mbmi = & mi -> mbmi ; const MODE_INFO * above_mi = xd -> mi [ - cm -> mi_stride ] ; const MODE_INFO * left_mi = xd -> left_available ? xd -> mi [ - 1 ] : NULL ; const BLOCK_SIZE bsize = mbmi -> sb_type ; int i ; mbmi -> segment_id = read_intra_segment_id ( cm , xd , mi_row , mi_col , r ) ; mbmi -> skip = read_skip ( cm , xd , mbmi -> segment_id , r ) ; mbmi -> tx_size = read_tx_size ( cm , xd , cm -> tx_mode , bsize , 1 , r ) ; mbmi -> ref_frame [ 0 ] = INTRA_FRAME ; mbmi -> ref_frame [ 1 ] = NONE ; switch ( bsize ) { case BLOCK_4X4 : for ( i = 0 ; i < 4 ; ++ i ) mi -> bmi [ i ] . as_mode = read_intra_mode ( r , get_y_mode_probs ( mi , above_mi , left_mi , i ) ) ; mbmi -> mode = mi -> bmi [ 3 ] . as_mode ; break ; case BLOCK_4X8 : mi -> bmi [ 0 ] . as_mode = mi -> bmi [ 2 ] . as_mode = read_intra_mode ( r , get_y_mode_probs ( mi , above_mi , left_mi , 0 ) ) ; mi -> bmi [ 1 ] . as_mode = mi -> bmi [ 3 ] . as_mode = mbmi -> mode = read_intra_mode ( r , get_y_mode_probs ( mi , above_mi , left_mi , 1 ) ) ; break ; case BLOCK_8X4 : mi -> bmi [ 0 ] . as_mode = mi -> bmi [ 1 ] . as_mode = read_intra_mode ( r , get_y_mode_probs ( mi , above_mi , left_mi , 0 ) ) ; mi -> bmi [ 2 ] . as_mode = mi -> bmi [ 3 ] . as_mode = mbmi -> mode = read_intra_mode ( r , get_y_mode_probs ( mi , above_mi , left_mi , 2 ) ) ; break ; default : mbmi -> mode = read_intra_mode ( r , get_y_mode_probs ( mi , above_mi , left_mi , 0 ) ) ; } mbmi -> uv_mode = read_intra_mode ( r , vp9_kf_uv_mode_prob [ mbmi -> mode ] ) ; } "," int mi_col , vpx_reader * r ) = xd -> above_mi ; const MODE_INFO = xd -> left_mi ; const BLOCK_SIZE int i ; const int mi_offset = mi_row * cm -> mi_cols + mi_col ; const int bw = xd -> plane [ 0 ] . n4_w >> 1 ; const int bh = xd -> plane [ 0 ] . n4_h >> 1 ; const int x_mis = MIN ( cm -> mi_cols - mi_col , bw ) ; const int y_mis = MIN ( cm -> mi_rows - mi_row , bh ) ; ( cm , mi_offset , x_mis , y_mis , r ) cm , xd , 1 , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 530,CWE-119,"CWE-119 cJSON * cJSON_CreateFalse ( void ) { cJSON * item = cJSON_New_Item ( ) ; if ( item ) item -> type = cJSON_False ; return item ; } "," ",esnet@iperf/91f2fa59e8ed80dfbf400add0164ee0e508e412a,CVE-2016-4303,https://github.com/esnet/iperf/commit/91f2fa59e8ed80dfbf400add0164ee0e508e412a,2016-09-26T14:59Z 531,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 532,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 ) && ( ( 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"" ) ; 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 + 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 , ""UnableToReadImageData"" ) ; height = sun_info ""MemoryAllocationFailed"" ) ; if ( sun_info . type == RT_ENCODED ) sun_data ) ; p = sun_pixels ",ImageMagick@ImageMagick/1aa0c6dab6dcef4d9bc3571866ae1c1ddbec7d8f,CVE-2015-8958,https://github.com/ImageMagick/ImageMagick/commit/1aa0c6dab6dcef4d9bc3571866ae1c1ddbec7d8f,2017-04-20T18:59Z 533,CWE-264,"CWE-264 int regset_tls_set ( struct task_struct * target , const struct user_regset * regset , unsigned int pos , unsigned int count , const void * kbuf , const void __user * ubuf ) { struct user_desc infobuf [ GDT_ENTRY_TLS_ENTRIES ] ; const struct user_desc * info ; if ( pos >= GDT_ENTRY_TLS_ENTRIES * sizeof ( struct user_desc ) || ( pos % sizeof ( struct user_desc ) ) != 0 || ( count % sizeof ( struct user_desc ) ) != 0 ) return - EINVAL ; if ( kbuf ) info = kbuf ; else if ( __copy_from_user ( infobuf , ubuf , count ) ) return - EFAULT ; else info = infobuf ; set_tls_desc ( target , GDT_ENTRY_TLS_MIN + ( pos / sizeof ( struct user_desc ) ) , info , count / sizeof ( struct user_desc ) ) ; return 0 ; } "," * info ; int i ; = infobuf ; for ( i = 0 ; i < count / sizeof ( struct user_desc ) ; i ++ ) if ( ! tls_desc_okay ( info + i ) ) return - EINVAL ; ",torvalds@linux/41bdc78544b8a93a9c6814b8bbbfef966272abbe,CVE-2014-8133,https://github.com/torvalds/linux/commit/41bdc78544b8a93a9c6814b8bbbfef966272abbe,2014-12-17T11:59Z 534,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 535,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_exception_intercept ( svm , AC_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 , AC_VECTOR ) ; set_exception_intercept ( svm , DB_VECTOR ",torvalds@linux/cbdb967af3d54993f5814f1cee0ed311a055377d,CVE-2015-8104,https://github.com/torvalds/linux/commit/cbdb967af3d54993f5814f1cee0ed311a055377d,2015-11-16T11:59Z 536,CWE-20,"CWE-20 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 ; UWORD16 pic_ht ; UWORD32 num_mbs ; 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 -> 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 ; } 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 += 2 ; ps_dec -> ps_top_mb_row = ps_dec -> ps_nbr_mb_row ; ps_dec -> ps_top_mb_row += ( ( ps_dec -> u2_frm_wd_in_mbs + 2 ) << ( 1 - ps_dec -> ps_cur_sps -> u1_frame_mbs_only_flag ) ) ; ps_dec -> ps_top_mb_row += 2 ; 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 -> 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 = 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 ; { 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 ; H264_MUTEX_UNLOCK ( & ps_dec -> process_disp_mutex ) ; return OK ; } "," = 0 ; ps_dec -> pu4_wt_ofsts = ps_dec -> pu4_wts_ofsts_mat ; ",external@libavc/e629194c62a9a129ce378e08cb1059a8a53f1795,CVE-2016-3741,https://android.googlesource.com/platform/external/libavc/+/e629194c62a9a129ce378e08cb1059a8a53f1795,2016-07-11T01:59Z 537,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 538,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 539,CWE-189,"CWE-189 static bool states_equal ( struct bpf_verifier_env * env , struct bpf_verifier_state * old , struct bpf_verifier_state * cur ) { int i ; if ( old -> curframe != cur -> curframe ) return false ; for ( i = 0 ; i <= old -> curframe ; i ++ ) { if ( old -> frame [ i ] -> callsite != cur -> frame [ i ] -> callsite ) return false ; if ( ! func_states_equal ( old -> frame [ i ] , cur -> frame [ i ] ) ) return false ; } return true ; } "," cur -> curframe ) return false ; if ( old -> speculative && ! cur -> speculative ",torvalds@linux/979d63d50c0c0f7bc537bf821e056cc9fe5abd38,CVE-2019-7308,https://github.com/torvalds/linux/commit/979d63d50c0c0f7bc537bf821e056cc9fe5abd38,2019-02-01T22:29Z 540,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 [ MagickPathExtent ] ; 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 ) ; pwp_image = AcquireImage ( image_info , exception ) ; 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 , MagickPathExtent , ""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/548701354191a3dda5cffc6d415374b35b01d0b9,CVE-2016-10051,https://github.com/ImageMagick/ImageMagick/commit/548701354191a3dda5cffc6d415374b35b01d0b9,2017-03-23T17:59Z 541,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 542,CWE-119,"CWE-119 SPL_METHOD ( SplObjectStorage , unserialize ) { spl_SplObjectStorage * intern = Z_SPLOBJSTORAGE_P ( getThis ( ) ) ; char * buf ; size_t buf_len ; const unsigned char * p , * s ; php_unserialize_data_t var_hash ; zval entry , inf ; zval * pcount , * pmembers ; spl_SplObjectStorageElement * element ; zend_long count ; if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , ""s"" , & buf , & buf_len ) == FAILURE ) { return ; } if ( buf_len == 0 ) { return ; } s = p = ( const unsigned char * ) buf ; PHP_VAR_UNSERIALIZE_INIT ( var_hash ) ; if ( * p != 'x' || * ++ p != ':' ) { goto outexcept ; } ++ p ; pcount = var_tmp_var ( & var_hash ) ; if ( ! php_var_unserialize ( pcount , & p , s + buf_len , & var_hash ) || Z_TYPE_P ( pcount ) != IS_LONG ) { goto outexcept ; } -- p ; count = Z_LVAL_P ( pcount ) ; while ( count -- > 0 ) { spl_SplObjectStorageElement * pelement ; zend_string * hash ; if ( * p != ';' ) { goto outexcept ; } ++ p ; if ( * p != 'O' && * p != 'C' && * p != 'r' ) { goto outexcept ; } if ( ! php_var_unserialize ( & entry , & p , s + buf_len , & var_hash ) ) { goto outexcept ; } if ( Z_TYPE ( entry ) != IS_OBJECT ) { zval_ptr_dtor ( & entry ) ; goto outexcept ; } if ( * p == ',' ) { ++ p ; if ( ! php_var_unserialize ( & inf , & p , s + buf_len , & var_hash ) ) { zval_ptr_dtor ( & entry ) ; goto outexcept ; } } else { ZVAL_UNDEF ( & inf ) ; } hash = spl_object_storage_get_hash ( intern , getThis ( ) , & entry ) ; if ( ! hash ) { zval_ptr_dtor ( & entry ) ; zval_ptr_dtor ( & inf ) ; goto outexcept ; } pelement = spl_object_storage_get ( intern , hash ) ; spl_object_storage_free_hash ( intern , hash ) ; if ( pelement ) { if ( ! Z_ISUNDEF ( pelement -> inf ) ) { var_push_dtor ( & var_hash , & pelement -> inf ) ; } if ( ! Z_ISUNDEF ( pelement -> obj ) ) { var_push_dtor ( & var_hash , & pelement -> obj ) ; } } element = spl_object_storage_attach ( intern , getThis ( ) , & entry , Z_ISUNDEF ( inf ) ? NULL : & inf ) ; var_replace ( & var_hash , & entry , & element -> obj ) ; var_replace ( & var_hash , & inf , & element -> inf ) ; zval_ptr_dtor ( & entry ) ; ZVAL_UNDEF ( & entry ) ; zval_ptr_dtor ( & inf ) ; ZVAL_UNDEF ( & inf ) ; } if ( * p != ';' ) { goto outexcept ; } ++ p ; if ( * p != 'm' || * ++ p != ':' ) { goto outexcept ; } ++ p ; pmembers = var_tmp_var ( & var_hash ) ; if ( ! php_var_unserialize ( pmembers , & p , s + buf_len , & var_hash ) || Z_TYPE_P ( pmembers ) != IS_ARRAY ) { goto outexcept ; } object_properties_load ( & intern -> std , Z_ARRVAL_P ( pmembers ) ) ; PHP_VAR_UNSERIALIZE_DESTROY ( var_hash ) ; return ; outexcept : PHP_VAR_UNSERIALIZE_DESTROY ( var_hash ) ; zend_throw_exception_ex ( spl_ce_UnexpectedValueException , 0 , ""Erroratoffset%pdof%dbytes"" , ( zend_long ) ( ( char * ) p - buf ) , buf_len ) ; return ; } "," Z_LVAL_P ( pcount ) ; ZVAL_UNDEF ( & entry ) ; ZVAL_UNDEF ( & inf } if ( * p == ; } } if ( Z_TYPE ( entry ) != IS_OBJECT ) { zval_ptr_dtor ( & entry ) ; zval_ptr_dtor ( & inf ) ; goto outexcept ; } hash ",php@php-src/61cdd1255d5b9c8453be71aacbbf682796ac77d4,CVE-2016-7480,https://github.com/php/php-src/commit/61cdd1255d5b9c8453be71aacbbf682796ac77d4,2017-01-11T07:59Z 543,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 544,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 545,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 546,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 ) ; 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 547,CWE-119,"CWE-119 void vpx_free ( void * memblk ) { if ( memblk ) { void * addr = ( void * ) ( ( ( size_t * ) memblk ) [ - 1 ] ) ; # if CONFIG_MEM_MANAGER hmm_free ( & hmm_d , addr ) ; # else VPX_FREE_L ( addr ) ; # endif } } "," ] ) ; free ( addr ) addr ) ; } } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 548,CWE-345,"CWE-345 static void headerMergeLegacySigs ( Header h , Header sigh ) { HeaderIterator hi ; struct rpmtd_s td ; hi = headerInitIterator ( sigh ) ; for ( ; headerNext ( hi , & td ) ; rpmtdFreeData ( & td ) ) { switch ( td . tag ) { case RPMSIGTAG_SIZE : td . tag = RPMTAG_SIGSIZE ; break ; case RPMSIGTAG_PGP : td . tag = RPMTAG_SIGPGP ; break ; case RPMSIGTAG_MD5 : td . tag = RPMTAG_SIGMD5 ; break ; case RPMSIGTAG_GPG : td . tag = RPMTAG_SIGGPG ; break ; case RPMSIGTAG_PGP5 : td . tag = RPMTAG_SIGPGP5 ; break ; case RPMSIGTAG_PAYLOADSIZE : td . tag = RPMTAG_ARCHIVESIZE ; break ; case RPMSIGTAG_FILESIGNATURES : td . tag = RPMTAG_FILESIGNATURES ; break ; case RPMSIGTAG_FILESIGNATURELENGTH : td . tag = RPMTAG_FILESIGNATURELENGTH ; break ; case RPMSIGTAG_VERITYSIGNATURES : case RPMSIGTAG_VERITYSIGNATUREALGO : case RPMSIGTAG_SHA1 : case RPMSIGTAG_SHA256 : case RPMSIGTAG_DSA : case RPMSIGTAG_RSA : default : if ( ! ( td . tag >= HEADER_SIGBASE && td . tag < HEADER_TAGBASE ) ) continue ; break ; } if ( ! headerIsEntry ( h , td . tag ) ) { switch ( td . type ) { case RPM_NULL_TYPE : continue ; break ; case RPM_CHAR_TYPE : case RPM_INT8_TYPE : case RPM_INT16_TYPE : case RPM_INT32_TYPE : case RPM_INT64_TYPE : if ( td . count != 1 ) continue ; break ; case RPM_STRING_TYPE : case RPM_STRING_ARRAY_TYPE : case RPM_BIN_TYPE : if ( td . count >= 16 * 1024 ) continue ; break ; case RPM_I18NSTRING_TYPE : continue ; break ; } ( void ) headerPut ( h , & td , HEADERPUT_DEFAULT ) ; } } headerFreeIterator ( hi ) ; } "," static rpmTagVal headerMergeLegacySigs ( Header , Header sigh , char * * msg ) { const struct taglate_s * xl ; struct rpmtd_s rpmtd_s td ; rpmtdReset ( & td ) ; for ( xl = xlateTags ; xl -> stag ; xl ++ ) { if ( headerIsEntry ( h , xl -> xtag ) ) break ; if ( headerGet ( sigh , xl -> stag , & td , HEADERGET_RAW | HEADERGET_MINMEM ) ) { if ( xl -> stag != xl -> xtag ) td . tag . tag = xl -> xtag ; if ( td . type != rpmTagGetTagType ( td . tag td . tag ) ) break ; if ( td . count < 1 || td . count > 16 * 1024 * 1024 ) break ; if ( xl -> count && td . count != xl -> count ) break ; if ( ! if ( ! headerPut ( h , ( h , & td , , HEADERPUT_DEFAULT ) ) break ; rpmtdFreeData ( & td ) ; } } rpmtdFreeData ( & td ) ; if ( xl -> stag ) { rasprintf ( msg , ""invalidsignaturetag%s(%d)"" , rpmTagGetName ( xl -> xtag ) , xl -> xtag ) ; } return xl -> stag ; } ",rpm-software-management@rpm/d6a86b5e69e46cc283b1e06c92343319beb42e21,CVE-2021-20271,https://github.com/rpm-software-management/rpm/commit/d6a86b5e69e46cc283b1e06c92343319beb42e21,2021-03-26T17:15Z 549,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 550,CWE-20,"CWE-20 static cupsd_job_t * add_job ( cupsd_client_t * con , cupsd_printer_t * printer , mime_type_t * filetype ) { http_status_t status ; ipp_attribute_t * attr , * auth_info ; const char * mandatory ; const char * val ; int priority ; cupsd_job_t * job ; char job_uri [ HTTP_MAX_URI ] ; int kbytes ; int i ; int lowerpagerange ; int exact ; ipp_attribute_t * media_col , * media_margin ; ipp_t * unsup_col ; static const char * const readonly [ ] = { ""date-time-at-completed"" , ""date-time-at-creation"" , ""date-time-at-processing"" , ""job-detailed-status-messages"" , ""job-document-access-errors"" , ""job-id"" , ""job-impressions-completed"" , ""job-k-octets-completed"" , ""job-media-sheets-completed"" , ""job-pages-completed"" , ""job-printer-up-time"" , ""job-printer-uri"" , ""job-state"" , ""job-state-message"" , ""job-state-reasons"" , ""job-uri"" , ""number-of-documents"" , ""number-of-intervening-jobs"" , ""output-device-assigned"" , ""time-at-completed"" , ""time-at-creation"" , ""time-at-processing"" } ; cupsdLogMessage ( CUPSD_LOG_DEBUG2 , ""add_job(%p[%d],%p(%s),%p(%s/%s))"" , con , con -> number , printer , printer -> name , filetype , filetype ? filetype -> super : ""none"" , filetype ? filetype -> type : ""none"" ) ; if ( ! printer -> shared && _cups_strcasecmp ( con -> http -> hostname , ""localhost"" ) && _cups_strcasecmp ( con -> http -> hostname , ServerName ) ) { send_ipp_status ( con , IPP_NOT_AUTHORIZED , _ ( ""Theprinterorclassisnotshared."" ) ) ; return ( NULL ) ; } auth_info = ippFindAttribute ( con -> request , ""auth-info"" , IPP_TAG_TEXT ) ; if ( ( status = cupsdCheckPolicy ( printer -> op_policy_ptr , con , NULL ) ) != HTTP_OK ) { send_http_error ( con , status , printer ) ; return ( NULL ) ; } else if ( printer -> num_auth_info_required == 1 && ! strcmp ( printer -> auth_info_required [ 0 ] , ""negotiate"" ) && ! con -> username [ 0 ] ) { send_http_error ( con , HTTP_UNAUTHORIZED , printer ) ; return ( NULL ) ; } # ifdef HAVE_SSL else if ( auth_info && ! con -> http -> tls && ! httpAddrLocalhost ( con -> http -> hostaddr ) ) { send_http_error ( con , HTTP_UPGRADE_REQUIRED , printer ) ; return ( NULL ) ; } # endif if ( ! printer -> accepting ) { send_ipp_status ( con , IPP_NOT_ACCEPTING , _ ( ""Destination\\""%s\\""isnotacceptingjobs."" ) , printer -> name ) ; return ( NULL ) ; } for ( i = 0 ; i < ( int ) ( sizeof ( readonly ) / sizeof ( readonly [ 0 ] ) ) ; i ++ ) { if ( ( attr = ippFindAttribute ( con -> request , readonly [ i ] , IPP_TAG_ZERO ) ) != NULL ) { ippDeleteAttribute ( con -> request , attr ) ; if ( StrictConformance ) { send_ipp_status ( con , IPP_BAD_REQUEST , _ ( ""The\'%s\'JobStatusattributecannotbesuppliedinajobcreationrequest."" ) , readonly [ i ] ) ; return ( NULL ) ; } cupsdLogMessage ( CUPSD_LOG_INFO , ""Unexpected\'%s\'JobStatusattributeinajobcreationrequest."" , readonly [ i ] ) ; } } if ( printer -> pc ) { for ( mandatory = ( char * ) cupsArrayFirst ( printer -> pc -> mandatory ) ; mandatory ; mandatory = ( char * ) cupsArrayNext ( printer -> pc -> mandatory ) ) { if ( ! ippFindAttribute ( con -> request , mandatory , IPP_TAG_ZERO ) ) { send_ipp_status ( con , IPP_CONFLICT , _ ( ""The\\""%s\\""attributeisrequiredforprintjobs."" ) , mandatory ) ; return ( NULL ) ; } } } if ( filetype && printer -> filetypes && ! cupsArrayFind ( printer -> filetypes , filetype ) ) { char mimetype [ MIME_MAX_SUPER + MIME_MAX_TYPE + 2 ] ; snprintf ( mimetype , sizeof ( mimetype ) , ""%s/%s"" , filetype -> super , filetype -> type ) ; send_ipp_status ( con , IPP_DOCUMENT_FORMAT , _ ( ""Unsupportedformat\\""%s\\""."" ) , mimetype ) ; ippAddString ( con -> response , IPP_TAG_UNSUPPORTED_GROUP , IPP_TAG_MIMETYPE , ""document-format"" , NULL , mimetype ) ; return ( NULL ) ; } if ( ( attr = ippFindAttribute ( con -> request , ""copies"" , IPP_TAG_INTEGER ) ) != NULL ) { if ( attr -> values [ 0 ] . integer < 1 || attr -> values [ 0 ] . integer > MaxCopies ) { send_ipp_status ( con , IPP_ATTRIBUTES , _ ( ""Badcopiesvalue%d."" ) , attr -> values [ 0 ] . integer ) ; ippAddInteger ( con -> response , IPP_TAG_UNSUPPORTED_GROUP , IPP_TAG_INTEGER , ""copies"" , attr -> values [ 0 ] . integer ) ; return ( NULL ) ; } } if ( ( attr = ippFindAttribute ( con -> request , ""job-sheets"" , IPP_TAG_ZERO ) ) != NULL ) { if ( attr -> value_tag != IPP_TAG_KEYWORD && attr -> value_tag != IPP_TAG_NAME ) { send_ipp_status ( con , IPP_BAD_REQUEST , _ ( ""Badjob-sheetsvaluetype."" ) ) ; return ( NULL ) ; } if ( attr -> num_values > 2 ) { send_ipp_status ( con , IPP_BAD_REQUEST , _ ( ""Toomanyjob-sheetsvalues(%d>2)."" ) , attr -> num_values ) ; return ( NULL ) ; } for ( i = 0 ; i < attr -> num_values ; i ++ ) if ( strcmp ( attr -> values [ i ] . string . text , ""none"" ) && ! cupsdFindBanner ( attr -> values [ i ] . string . text ) ) { send_ipp_status ( con , IPP_BAD_REQUEST , _ ( ""Badjob-sheetsvalue\\""%s\\""."" ) , attr -> values [ i ] . string . text ) ; return ( NULL ) ; } } if ( ( attr = ippFindAttribute ( con -> request , ""number-up"" , IPP_TAG_INTEGER ) ) != NULL ) { if ( attr -> values [ 0 ] . integer != 1 && attr -> values [ 0 ] . integer != 2 && attr -> values [ 0 ] . integer != 4 && attr -> values [ 0 ] . integer != 6 && attr -> values [ 0 ] . integer != 9 && attr -> values [ 0 ] . integer != 16 ) { send_ipp_status ( con , IPP_ATTRIBUTES , _ ( ""Badnumber-upvalue%d."" ) , attr -> values [ 0 ] . integer ) ; ippAddInteger ( con -> response , IPP_TAG_UNSUPPORTED_GROUP , IPP_TAG_INTEGER , ""number-up"" , attr -> values [ 0 ] . integer ) ; return ( NULL ) ; } } if ( ( attr = ippFindAttribute ( con -> request , ""page-ranges"" , IPP_TAG_RANGE ) ) != NULL ) { for ( i = 0 , lowerpagerange = 1 ; i < attr -> num_values ; i ++ ) { if ( attr -> values [ i ] . range . lower < lowerpagerange || attr -> values [ i ] . range . lower > attr -> values [ i ] . range . upper ) { send_ipp_status ( con , IPP_BAD_REQUEST , _ ( ""Badpage-rangesvalues%d-%d."" ) , attr -> values [ i ] . range . lower , attr -> values [ i ] . range . upper ) ; return ( NULL ) ; } lowerpagerange = attr -> values [ i ] . range . upper + 1 ; } } if ( ! ippFindAttribute ( con -> request , ""PageRegion"" , IPP_TAG_ZERO ) && ! ippFindAttribute ( con -> request , ""PageSize"" , IPP_TAG_ZERO ) && _ppdCacheGetPageSize ( printer -> pc , con -> request , NULL , & exact ) ) { if ( ! exact && ( media_col = ippFindAttribute ( con -> request , ""media-col"" , IPP_TAG_BEGIN_COLLECTION ) ) != NULL ) { send_ipp_status ( con , IPP_OK_SUBST , _ ( ""Unsupportedmargins."" ) ) ; unsup_col = ippNew ( ) ; if ( ( media_margin = ippFindAttribute ( media_col -> values [ 0 ] . collection , ""media-bottom-margin"" , IPP_TAG_INTEGER ) ) != NULL ) ippAddInteger ( unsup_col , IPP_TAG_ZERO , IPP_TAG_INTEGER , ""media-bottom-margin"" , media_margin -> values [ 0 ] . integer ) ; if ( ( media_margin = ippFindAttribute ( media_col -> values [ 0 ] . collection , ""media-left-margin"" , IPP_TAG_INTEGER ) ) != NULL ) ippAddInteger ( unsup_col , IPP_TAG_ZERO , IPP_TAG_INTEGER , ""media-left-margin"" , media_margin -> values [ 0 ] . integer ) ; if ( ( media_margin = ippFindAttribute ( media_col -> values [ 0 ] . collection , ""media-right-margin"" , IPP_TAG_INTEGER ) ) != NULL ) ippAddInteger ( unsup_col , IPP_TAG_ZERO , IPP_TAG_INTEGER , ""media-right-margin"" , media_margin -> values [ 0 ] . integer ) ; if ( ( media_margin = ippFindAttribute ( media_col -> values [ 0 ] . collection , ""media-top-margin"" , IPP_TAG_INTEGER ) ) != NULL ) ippAddInteger ( unsup_col , IPP_TAG_ZERO , IPP_TAG_INTEGER , ""media-top-margin"" , media_margin -> values [ 0 ] . integer ) ; ippAddCollection ( con -> response , IPP_TAG_UNSUPPORTED_GROUP , ""media-col"" , unsup_col ) ; ippDelete ( unsup_col ) ; } } if ( MaxJobs && cupsArrayCount ( Jobs ) >= MaxJobs ) cupsdCleanJobs ( ) ; if ( MaxJobs && cupsArrayCount ( Jobs ) >= MaxJobs ) { send_ipp_status ( con , IPP_NOT_POSSIBLE , _ ( ""Toomanyactivejobs."" ) ) ; return ( NULL ) ; } if ( ( i = check_quotas ( con , printer ) ) < 0 ) { send_ipp_status ( con , IPP_NOT_POSSIBLE , _ ( ""Quotalimitreached."" ) ) ; return ( NULL ) ; } else if ( i == 0 ) { send_ipp_status ( con , IPP_NOT_AUTHORIZED , _ ( ""Notallowedtoprint."" ) ) ; return ( NULL ) ; } if ( ( attr = ippFindAttribute ( con -> request , ""job-priority"" , IPP_TAG_INTEGER ) ) != NULL ) priority = attr -> values [ 0 ] . integer ; else { if ( ( val = cupsGetOption ( ""job-priority"" , printer -> num_options , printer -> options ) ) != NULL ) priority = atoi ( val ) ; else priority = 50 ; ippAddInteger ( con -> request , IPP_TAG_JOB , IPP_TAG_INTEGER , ""job-priority"" , priority ) ; } if ( ( attr = ippFindAttribute ( con -> request , ""job-name"" , IPP_TAG_ZERO ) ) == NULL ) ippAddString ( con -> request , IPP_TAG_JOB , IPP_TAG_NAME , ""job-name"" , NULL , ""Untitled"" ) ; else if ( ( attr -> value_tag != IPP_TAG_NAME && attr -> value_tag != IPP_TAG_NAMELANG ) || attr -> num_values != 1 ) { send_ipp_status ( con , IPP_ATTRIBUTES , _ ( ""Badjob-namevalue:Wrongtypeorcount."" ) ) ; if ( ( attr = ippCopyAttribute ( con -> response , attr , 0 ) ) != NULL ) attr -> group_tag = IPP_TAG_UNSUPPORTED_GROUP ; return ( NULL ) ; } else if ( ! ippValidateAttribute ( attr ) ) { send_ipp_status ( con , IPP_ATTRIBUTES , _ ( ""Badjob-namevalue:%s"" ) , cupsLastErrorString ( ) ) ; if ( ( attr = ippCopyAttribute ( con -> response , attr , 0 ) ) != NULL ) attr -> group_tag = IPP_TAG_UNSUPPORTED_GROUP ; return ( NULL ) ; } if ( ( job = cupsdAddJob ( priority , printer -> name ) ) == NULL ) { send_ipp_status ( con , IPP_INTERNAL_ERROR , _ ( ""Unabletoaddjobfordestination\\""%s\\""."" ) , printer -> name ) ; return ( NULL ) ; } job -> dtype = printer -> type & ( CUPS_PRINTER_CLASS | CUPS_PRINTER_REMOTE ) ; job -> attrs = con -> request ; job -> dirty = 1 ; con -> request = ippNewRequest ( job -> attrs -> request . op . operation_id ) ; cupsdMarkDirty ( CUPSD_DIRTY_JOBS ) ; add_job_uuid ( job ) ; apply_printer_defaults ( printer , job ) ; attr = ippFindAttribute ( job -> attrs , ""requesting-user-name"" , IPP_TAG_NAME ) ; if ( con -> username [ 0 ] ) { cupsdSetString ( & job -> username , con -> username ) ; if ( attr ) ippSetString ( job -> attrs , & attr , 0 , con -> username ) ; } else if ( attr ) { cupsdLogMessage ( CUPSD_LOG_DEBUG , ""add_job:requesting-user-name=\\""%s\\"""" , attr -> values [ 0 ] . string . text ) ; cupsdSetString ( & job -> username , attr -> values [ 0 ] . string . text ) ; } else cupsdSetString ( & job -> username , ""anonymous"" ) ; if ( ! attr ) ippAddString ( job -> attrs , IPP_TAG_JOB , IPP_TAG_NAME , ""job-originating-user-name"" , NULL , job -> username ) ; else { ippSetGroupTag ( job -> attrs , & attr , IPP_TAG_JOB ) ; ippSetName ( job -> attrs , & attr , ""job-originating-user-name"" ) ; } if ( con -> username [ 0 ] || auth_info ) { save_auth_info ( con , job , auth_info ) ; if ( auth_info ) ippDeleteAttribute ( job -> attrs , auth_info ) ; } if ( ( attr = ippFindAttribute ( con -> request , ""job-name"" , IPP_TAG_NAME ) ) != NULL ) cupsdSetString ( & ( job -> name ) , attr -> values [ 0 ] . string . text ) ; if ( ( attr = ippFindAttribute ( job -> attrs , ""job-originating-host-name"" , IPP_TAG_ZERO ) ) != NULL ) { if ( attr -> value_tag != IPP_TAG_NAME || attr -> num_values != 1 || strcmp ( con -> http -> hostname , ""localhost"" ) ) { ippDeleteAttribute ( job -> attrs , attr ) ; ippAddString ( job -> attrs , IPP_TAG_JOB , IPP_TAG_NAME , ""job-originating-host-name"" , NULL , con -> http -> hostname ) ; } else ippSetGroupTag ( job -> attrs , & attr , IPP_TAG_JOB ) ; } else { ippAddString ( job -> attrs , IPP_TAG_JOB , IPP_TAG_NAME , ""job-originating-host-name"" , NULL , con -> http -> hostname ) ; } ippAddOutOfBand ( job -> attrs , IPP_TAG_JOB , IPP_TAG_NOVALUE , ""date-time-at-completed"" ) ; ippAddDate ( job -> attrs , IPP_TAG_JOB , ""date-time-at-creation"" , ippTimeToDate ( time ( NULL ) ) ) ; ippAddOutOfBand ( job -> attrs , IPP_TAG_JOB , IPP_TAG_NOVALUE , ""date-time-at-processing"" ) ; ippAddOutOfBand ( job -> attrs , IPP_TAG_JOB , IPP_TAG_NOVALUE , ""time-at-completed"" ) ; ippAddInteger ( job -> attrs , IPP_TAG_JOB , IPP_TAG_INTEGER , ""time-at-creation"" , time ( NULL ) ) ; ippAddOutOfBand ( job -> attrs , IPP_TAG_JOB , IPP_TAG_NOVALUE , ""time-at-processing"" ) ; ippAddInteger ( job -> attrs , IPP_TAG_JOB , IPP_TAG_INTEGER , ""job-id"" , job -> id ) ; job -> state = ippAddInteger ( job -> attrs , IPP_TAG_JOB , IPP_TAG_ENUM , ""job-state"" , IPP_JOB_STOPPED ) ; job -> state_value = ( ipp_jstate_t ) job -> state -> values [ 0 ] . integer ; job -> reasons = ippAddString ( job -> attrs , IPP_TAG_JOB , IPP_TAG_KEYWORD , ""job-state-reasons"" , NULL , ""job-incoming"" ) ; job -> impressions = ippAddInteger ( job -> attrs , IPP_TAG_JOB , IPP_TAG_INTEGER , ""job-impressions-completed"" , 0 ) ; job -> sheets = ippAddInteger ( job -> attrs , IPP_TAG_JOB , IPP_TAG_INTEGER , ""job-media-sheets-completed"" , 0 ) ; ippAddString ( job -> attrs , IPP_TAG_JOB , IPP_TAG_URI , ""job-printer-uri"" , NULL , printer -> uri ) ; if ( ( attr = ippFindAttribute ( job -> attrs , ""job-k-octets"" , IPP_TAG_INTEGER ) ) != NULL ) attr -> values [ 0 ] . integer = 0 ; else ippAddInteger ( job -> attrs , IPP_TAG_JOB , IPP_TAG_INTEGER , ""job-k-octets"" , 0 ) ; if ( ( attr = ippFindAttribute ( job -> attrs , ""job-hold-until"" , IPP_TAG_KEYWORD ) ) == NULL ) attr = ippFindAttribute ( job -> attrs , ""job-hold-until"" , IPP_TAG_NAME ) ; if ( ! attr ) { if ( ( val = cupsGetOption ( ""job-hold-until"" , printer -> num_options , printer -> options ) ) == NULL ) val = ""no-hold"" ; attr = ippAddString ( job -> attrs , IPP_TAG_JOB , IPP_TAG_KEYWORD , ""job-hold-until"" , NULL , val ) ; } if ( printer -> holding_new_jobs ) { if ( attr && strcmp ( attr -> values [ 0 ] . string . text , ""no-hold"" ) ) cupsdSetJobHoldUntil ( job , ippGetString ( attr , 0 , NULL ) , 0 ) ; else cupsdSetJobHoldUntil ( job , ""indefinite"" , 0 ) ; job -> state -> values [ 0 ] . integer = IPP_JOB_HELD ; job -> state_value = IPP_JOB_HELD ; ippSetString ( job -> attrs , & job -> reasons , 0 , ""job-held-on-create"" ) ; } else if ( attr && strcmp ( attr -> values [ 0 ] . string . text , ""no-hold"" ) ) { cupsdSetJobHoldUntil ( job , attr -> values [ 0 ] . string . text , 0 ) ; job -> state -> values [ 0 ] . integer = IPP_JOB_HELD ; job -> state_value = IPP_JOB_HELD ; ippSetString ( job -> attrs , & job -> reasons , 0 , ""job-hold-until-specified"" ) ; } else if ( job -> attrs -> request . op . operation_id == IPP_CREATE_JOB ) { job -> hold_until = time ( NULL ) + MultipleOperationTimeout ; job -> state -> values [ 0 ] . integer = IPP_JOB_HELD ; job -> state_value = IPP_JOB_HELD ; } else { job -> state -> values [ 0 ] . integer = IPP_JOB_PENDING ; job -> state_value = IPP_JOB_PENDING ; ippSetString ( job -> attrs , & job -> reasons , 0 , ""none"" ) ; } if ( ! ( printer -> type & CUPS_PRINTER_REMOTE ) || Classification ) { if ( ( attr = ippFindAttribute ( job -> attrs , ""job-sheets"" , IPP_TAG_ZERO ) ) == NULL ) { cupsdLogMessage ( CUPSD_LOG_DEBUG , ""Addingdefaultjob-sheetsvalues\\""%s,%s\\""..."" , printer -> job_sheets [ 0 ] , printer -> job_sheets [ 1 ] ) ; attr = ippAddStrings ( job -> attrs , IPP_TAG_JOB , IPP_TAG_NAME , ""job-sheets"" , 2 , NULL , NULL ) ; ippSetString ( job -> attrs , & attr , 0 , printer -> job_sheets [ 0 ] ) ; ippSetString ( job -> attrs , & attr , 1 , printer -> job_sheets [ 1 ] ) ; } job -> job_sheets = attr ; if ( Classification ) { cupsdLogMessage ( CUPSD_LOG_INFO , ""Classification=\\""%s\\"",ClassifyOverride=%d"" , Classification ? Classification : ""(null)"" , ClassifyOverride ) ; if ( ClassifyOverride ) { if ( ! strcmp ( attr -> values [ 0 ] . string . text , ""none"" ) && ( attr -> num_values == 1 || ! strcmp ( attr -> values [ 1 ] . string . text , ""none"" ) ) ) { ippSetString ( job -> attrs , & attr , 0 , Classification ) ; cupsdLogJob ( job , CUPSD_LOG_NOTICE , ""CLASSIFICATIONFORCED"" ""job-sheets=\\""%s,none\\"","" ""job-originating-user-name=\\""%s\\"""" , Classification , job -> username ) ; } else if ( attr -> num_values == 2 && strcmp ( attr -> values [ 0 ] . string . text , attr -> values [ 1 ] . string . text ) && strcmp ( attr -> values [ 0 ] . string . text , ""none"" ) && strcmp ( attr -> values [ 1 ] . string . text , ""none"" ) ) { ippSetString ( job -> attrs , & attr , 1 , attr -> values [ 0 ] . string . text ) ; cupsdLogJob ( job , CUPSD_LOG_NOTICE , ""CLASSIFICATIONFORCED"" ""job-sheets=\\""%s,%s\\"","" ""job-originating-user-name=\\""%s\\"""" , attr -> values [ 0 ] . string . text , attr -> values [ 1 ] . string . text , job -> username ) ; } else if ( strcmp ( attr -> values [ 0 ] . string . text , Classification ) && strcmp ( attr -> values [ 0 ] . string . text , ""none"" ) && ( attr -> num_values == 1 || ( strcmp ( attr -> values [ 1 ] . string . text , Classification ) && strcmp ( attr -> values [ 1 ] . string . text , ""none"" ) ) ) ) { if ( attr -> num_values == 1 ) cupsdLogJob ( job , CUPSD_LOG_NOTICE , ""CLASSIFICATIONOVERRIDDEN"" ""job-sheets=\\""%s\\"","" ""job-originating-user-name=\\""%s\\"""" , attr -> values [ 0 ] . string . text , job -> username ) ; else cupsdLogJob ( job , CUPSD_LOG_NOTICE , ""CLASSIFICATIONOVERRIDDEN"" ""job-sheets=\\""%s,%s\\"",fffff"" ""job-originating-user-name=\\""%s\\"""" , attr -> values [ 0 ] . string . text , attr -> values [ 1 ] . string . text , job -> username ) ; } } else if ( strcmp ( attr -> values [ 0 ] . string . text , Classification ) && ( attr -> num_values == 1 || strcmp ( attr -> values [ 1 ] . string . text , Classification ) ) ) { if ( attr -> num_values > 1 && ! strcmp ( attr -> values [ 0 ] . string . text , attr -> values [ 1 ] . string . text ) ) { ippSetString ( job -> attrs , & attr , 0 , Classification ) ; ippSetString ( job -> attrs , & attr , 1 , Classification ) ; } else { if ( attr -> num_values == 1 || strcmp ( attr -> values [ 0 ] . string . text , ""none"" ) ) ippSetString ( job -> attrs , & attr , 0 , Classification ) ; if ( attr -> num_values > 1 && strcmp ( attr -> values [ 1 ] . string . text , ""none"" ) ) ippSetString ( job -> attrs , & attr , 1 , Classification ) ; } if ( attr -> num_values > 1 ) cupsdLogJob ( job , CUPSD_LOG_NOTICE , ""CLASSIFICATIONFORCED"" ""job-sheets=\\""%s,%s\\"","" ""job-originating-user-name=\\""%s\\"""" , attr -> values [ 0 ] . string . text , attr -> values [ 1 ] . string . text , job -> username ) ; else cupsdLogJob ( job , CUPSD_LOG_NOTICE , ""CLASSIFICATIONFORCED"" ""job-sheets=\\""%s\\"","" ""job-originating-user-name=\\""%s\\"""" , Classification , job -> username ) ; } } if ( ! ( printer -> type & CUPS_PRINTER_REMOTE ) ) { cupsdLogJob ( job , CUPSD_LOG_INFO , ""Addingstartbannerpage\\""%s\\""."" , attr -> values [ 0 ] . string . text ) ; if ( ( kbytes = copy_banner ( con , job , attr -> values [ 0 ] . string . text ) ) < 0 ) { cupsdSetJobState ( job , IPP_JOB_ABORTED , CUPSD_JOB_PURGE , ""Abortingjobbecausethestartbannercouldnotbe"" ""copied."" ) ; return ( NULL ) ; } cupsdUpdateQuota ( printer , job -> username , 0 , kbytes ) ; } } else if ( ( attr = ippFindAttribute ( job -> attrs , ""job-sheets"" , IPP_TAG_ZERO ) ) != NULL ) job -> job_sheets = attr ; httpAssembleURIf ( HTTP_URI_CODING_ALL , job_uri , sizeof ( job_uri ) , ""ipp"" , NULL , con -> clientname , con -> clientport , ""/jobs/%d"" , job -> id ) ; ippAddString ( con -> response , IPP_TAG_JOB , IPP_TAG_URI , ""job-uri"" , NULL , job_uri ) ; ippAddInteger ( con -> response , IPP_TAG_JOB , IPP_TAG_INTEGER , ""job-id"" , job -> id ) ; ippAddInteger ( con -> response , IPP_TAG_JOB , IPP_TAG_ENUM , ""job-state"" , job -> state_value ) ; ippAddString ( con -> response , IPP_TAG_JOB , IPP_TAG_TEXT , ""job-state-message"" , NULL , """" ) ; ippAddString ( con -> response , IPP_TAG_JOB , IPP_TAG_KEYWORD , ""job-state-reasons"" , NULL , job -> reasons -> values [ 0 ] . string . text ) ; con -> response -> request . status . status_code = IPP_OK ; add_job_subscriptions ( con , job ) ; for ( attr = job -> attrs -> attrs -> next -> next ; attr ; attr = attr -> next ) attr -> group_tag = IPP_TAG_JOB ; cupsdAddEvent ( CUPSD_EVENT_JOB_CREATED , printer , job , ""Jobcreated."" ) ; return ( job ) ; } "," ) ; } attr = ippFindAttribute ( con -> request , ""requesting-user-name"" , IPP_TAG_NAME ) ; if ( attr && ! ippValidateAttribute ( attr ) ) { send_ipp_status ( con , IPP_ATTRIBUTES , _ ( ""Badrequesting-user-namevalue:%s"" ) , cupsLastErrorString ( ) ) ; if ( ( attr = ippCopyAttribute ( con -> response , attr , 0 ) ) != NULL ) attr -> group_tag = IPP_TAG_UNSUPPORTED_GROUP ; return ( NULL ) ; } printer , job ) ; if ",apple@cups/49fa4983f25b64ec29d548ffa3b9782426007df3,CVE-2017-18248,https://github.com/apple/cups/commit/49fa4983f25b64ec29d548ffa3b9782426007df3,2018-03-26T17:29Z 551,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 552,CWE-787,"CWE-787 rfbBool InitialiseRFBConnection ( rfbClient * client ) { rfbProtocolVersionMsg pv ; int major , minor ; uint32_t authScheme ; uint32_t subAuthScheme ; rfbClientInitMsg ci ; if ( client -> listenSpecified ) errorMessageOnReadFailure = FALSE ; if ( ! ReadFromRFBServer ( client , pv , sz_rfbProtocolVersionMsg ) ) return FALSE ; pv [ sz_rfbProtocolVersionMsg ] = 0 ; errorMessageOnReadFailure = TRUE ; pv [ sz_rfbProtocolVersionMsg ] = 0 ; if ( sscanf ( pv , rfbProtocolVersionFormat , & major , & minor ) != 2 ) { rfbClientLog ( ""NotavalidVNCserver(%s)\\n"" , pv ) ; return FALSE ; } DefaultSupportedMessages ( client ) ; client -> major = major ; client -> minor = minor ; if ( ( major == rfbProtocolMajorVersion ) && ( minor > rfbProtocolMinorVersion ) ) client -> minor = rfbProtocolMinorVersion ; if ( major == 3 && ( minor == 4 || minor == 6 ) ) { rfbClientLog ( ""UltraVNCserverdetected,enablingUltraVNCspecificmessages\\n"" , pv ) ; DefaultSupportedMessagesUltraVNC ( client ) ; } if ( major == 3 && ( minor == 14 || minor == 16 ) ) { minor = minor - 10 ; client -> minor = minor ; rfbClientLog ( ""UltraVNCSingleClickserverdetected,enablingUltraVNCspecificmessages\\n"" , pv ) ; DefaultSupportedMessagesUltraVNC ( client ) ; } if ( major == 3 && minor == 5 ) { rfbClientLog ( ""TightVNCserverdetected,enablingTightVNCspecificmessages\\n"" , pv ) ; DefaultSupportedMessagesTightVNC ( client ) ; } if ( ( major == 3 && minor > 8 ) || major > 3 ) { client -> major = 3 ; client -> minor = 8 ; } rfbClientLog ( ""VNCserversupportsprotocolversion%d.%d(viewer%d.%d)\\n"" , major , minor , rfbProtocolMajorVersion , rfbProtocolMinorVersion ) ; sprintf ( pv , rfbProtocolVersionFormat , client -> major , client -> minor ) ; if ( ! WriteToRFBServer ( client , pv , sz_rfbProtocolVersionMsg ) ) return FALSE ; if ( client -> major == 3 && client -> minor > 6 ) { if ( ! ReadSupportedSecurityType ( client , & authScheme , FALSE ) ) return FALSE ; } else { if ( ! ReadFromRFBServer ( client , ( char * ) & authScheme , 4 ) ) return FALSE ; authScheme = rfbClientSwap32IfLE ( authScheme ) ; } rfbClientLog ( ""SelectedSecurityScheme%d\\n"" , authScheme ) ; client -> authScheme = authScheme ; switch ( authScheme ) { case rfbConnFailed : ReadReason ( client ) ; return FALSE ; case rfbNoAuth : rfbClientLog ( ""Noauthenticationneeded\\n"" ) ; if ( ( client -> major == 3 && client -> minor > 7 ) || client -> major > 3 ) if ( ! rfbHandleAuthResult ( client ) ) return FALSE ; break ; case rfbVncAuth : if ( ! HandleVncAuth ( client ) ) return FALSE ; break ; # ifdef LIBVNCSERVER_HAVE_SASL case rfbSASL : if ( ! HandleSASLAuth ( client ) ) return FALSE ; break ; # endif case rfbMSLogon : if ( ! HandleMSLogonAuth ( client ) ) return FALSE ; break ; case rfbARD : # ifndef LIBVNCSERVER_WITH_CLIENT_GCRYPT rfbClientLog ( ""GCryptsupportwasnotcompiledin\\n"" ) ; return FALSE ; # else if ( ! HandleARDAuth ( client ) ) return FALSE ; # endif break ; case rfbTLS : if ( ! HandleAnonTLSAuth ( client ) ) return FALSE ; if ( ! ReadSupportedSecurityType ( client , & subAuthScheme , TRUE ) ) return FALSE ; client -> subAuthScheme = subAuthScheme ; switch ( subAuthScheme ) { case rfbConnFailed : ReadReason ( client ) ; return FALSE ; case rfbNoAuth : rfbClientLog ( ""Nosubauthenticationneeded\\n"" ) ; if ( ( client -> major == 3 && client -> minor > 7 ) || client -> major > 3 ) if ( ! rfbHandleAuthResult ( client ) ) return FALSE ; break ; case rfbVncAuth : if ( ! HandleVncAuth ( client ) ) return FALSE ; break ; # ifdef LIBVNCSERVER_HAVE_SASL case rfbSASL : if ( ! HandleSASLAuth ( client ) ) return FALSE ; break ; # endif default : rfbClientLog ( ""UnknownsubauthenticationschemefromVNCserver:%d\\n"" , ( int ) subAuthScheme ) ; return FALSE ; } break ; case rfbVeNCrypt : if ( ! HandleVeNCryptAuth ( client ) ) return FALSE ; switch ( client -> subAuthScheme ) { case rfbVeNCryptTLSNone : case rfbVeNCryptX509None : rfbClientLog ( ""Nosubauthenticationneeded\\n"" ) ; if ( ! rfbHandleAuthResult ( client ) ) return FALSE ; break ; case rfbVeNCryptTLSVNC : case rfbVeNCryptX509VNC : if ( ! HandleVncAuth ( client ) ) return FALSE ; break ; case rfbVeNCryptTLSPlain : case rfbVeNCryptX509Plain : if ( ! HandlePlainAuth ( client ) ) return FALSE ; break ; # ifdef LIBVNCSERVER_HAVE_SASL case rfbVeNCryptX509SASL : case rfbVeNCryptTLSSASL : if ( ! HandleSASLAuth ( client ) ) return FALSE ; break ; # endif default : rfbClientLog ( ""UnknownsubauthenticationschemefromVNCserver:%d\\n"" , client -> subAuthScheme ) ; return FALSE ; } break ; default : { rfbBool authHandled = FALSE ; rfbClientProtocolExtension * e ; for ( e = rfbClientExtensions ; e ; e = e -> next ) { uint32_t const * secType ; if ( ! e -> handleAuthentication ) continue ; for ( secType = e -> securityTypes ; secType && * secType ; secType ++ ) { if ( authScheme == * secType ) { if ( ! e -> handleAuthentication ( client , authScheme ) ) return FALSE ; if ( ! rfbHandleAuthResult ( client ) ) return FALSE ; authHandled = TRUE ; } } } if ( authHandled ) break ; } rfbClientLog ( ""UnknownauthenticationschemefromVNCserver:%d\\n"" , ( int ) authScheme ) ; return FALSE ; } ci . shared = ( client -> appData . shareDesktop ? 1 : 0 ) ; if ( ! WriteToRFBServer ( client , ( char * ) & ci , sz_rfbClientInitMsg ) ) return FALSE ; if ( ! ReadFromRFBServer ( client , ( char * ) & client -> si , sz_rfbServerInitMsg ) ) return FALSE ; client -> si . framebufferWidth = rfbClientSwap16IfLE ( client -> si . framebufferWidth ) ; client -> si . framebufferHeight = rfbClientSwap16IfLE ( client -> si . framebufferHeight ) ; client -> si . format . redMax = rfbClientSwap16IfLE ( client -> si . format . redMax ) ; client -> si . format . greenMax = rfbClientSwap16IfLE ( client -> si . format . greenMax ) ; client -> si . format . blueMax = rfbClientSwap16IfLE ( client -> si . format . blueMax ) ; client -> si . nameLength = rfbClientSwap32IfLE ( client -> si . nameLength ) ; client -> desktopName = malloc ( ( uint64_t ) client -> si . nameLength + 1 ) ; if ( ! client -> desktopName ) { rfbClientLog ( ""Errorallocatingmemoryfordesktopname,%lubytes\\n"" , ( unsigned long ) client -> si . nameLength ) ; return FALSE ; } if ( ! ReadFromRFBServer ( client , client -> desktopName , client -> si . nameLength ) ) return FALSE ; client -> desktopName [ client -> si . nameLength ] = 0 ; rfbClientLog ( ""Desktopname\\""%s\\""\\n"" , client -> desktopName ) ; rfbClientLog ( ""ConnectedtoVNCserver,usingprotocolversion%d.%d\\n"" , client -> major , client -> minor ) ; rfbClientLog ( ""VNCserverdefaultformat:\\n"" ) ; PrintPixelFormat ( & client -> si . format ) ; return TRUE ; } "," nameLength ) ; if ( client -> si . nameLength > 1 << 20 ) { rfbClientErr ( ""Toobigdesktopnamelengthsentbyserver:%uB>1MB\\n"" , ( unsigned int ) client -> si . nameLength ) ; return FALSE ; } = malloc ( client -> si ",LibVNC@libvncserver/c2c4b81e6cb3b485fb1ec7ba9e7defeb889f6ba7,CVE-2018-20748,https://github.com/LibVNC/libvncserver/commit/c2c4b81e6cb3b485fb1ec7ba9e7defeb889f6ba7,2019-01-30T18:29Z 553,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 554,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 555,CWE-20,"CWE-20 int ext4_orphan_add ( handle_t * handle , struct inode * inode ) { struct super_block * sb = inode -> i_sb ; struct ext4_iloc iloc ; int err = 0 , rc ; if ( ! ext4_handle_valid ( handle ) ) return 0 ; mutex_lock ( & EXT4_SB ( sb ) -> s_orphan_lock ) ; if ( ! list_empty ( & EXT4_I ( inode ) -> i_orphan ) ) goto out_unlock ; J_ASSERT ( ( S_ISREG ( inode -> i_mode ) || S_ISDIR ( inode -> i_mode ) || S_ISLNK ( inode -> i_mode ) ) || inode -> i_nlink == 0 ) ; BUFFER_TRACE ( EXT4_SB ( sb ) -> s_sbh , ""get_write_access"" ) ; err = ext4_journal_get_write_access ( handle , EXT4_SB ( sb ) -> s_sbh ) ; if ( err ) goto out_unlock ; err = ext4_reserve_inode_write ( handle , inode , & iloc ) ; if ( err ) goto out_unlock ; if ( NEXT_ORPHAN ( inode ) && NEXT_ORPHAN ( inode ) <= ( le32_to_cpu ( EXT4_SB ( sb ) -> s_es -> s_inodes_count ) ) ) goto mem_insert ; NEXT_ORPHAN ( inode ) = le32_to_cpu ( EXT4_SB ( sb ) -> s_es -> s_last_orphan ) ; EXT4_SB ( sb ) -> s_es -> s_last_orphan = cpu_to_le32 ( inode -> i_ino ) ; err = ext4_handle_dirty_super ( handle , sb ) ; rc = ext4_mark_iloc_dirty ( handle , inode , & iloc ) ; if ( ! err ) err = rc ; mem_insert : if ( ! err ) list_add ( & EXT4_I ( inode ) -> i_orphan , & EXT4_SB ( sb ) -> s_orphan ) ; jbd_debug ( 4 , ""superblockwillpointto%lu\\n"" , inode -> i_ino ) ; jbd_debug ( 4 , ""orphaninode%luwillpointto%d\\n"" , inode -> i_ino , NEXT_ORPHAN ( inode ) ) ; out_unlock : mutex_unlock ( & EXT4_SB ( sb ) -> s_orphan_lock ) ; ext4_std_error ( inode -> i_sb , err ) ; return err ; } "," if ( ! EXT4_SB ( sb ) -> s_journal ) return 0 ",torvalds@linux/c9b92530a723ac5ef8e352885a1862b18f31b2f5,CVE-2015-7509,https://github.com/torvalds/linux/commit/c9b92530a723ac5ef8e352885a1862b18f31b2f5,2015-12-28T11:59Z 556,CWE-399,"CWE-399 static ssize_t fuse_fill_write_pages ( struct fuse_req * req , struct address_space * mapping , struct iov_iter * ii , loff_t pos ) { struct fuse_conn * fc = get_fuse_conn ( mapping -> host ) ; unsigned offset = pos & ( PAGE_CACHE_SIZE - 1 ) ; size_t count = 0 ; int err ; req -> in . argpages = 1 ; req -> page_descs [ 0 ] . offset = offset ; do { size_t tmp ; struct page * page ; pgoff_t index = pos >> PAGE_CACHE_SHIFT ; size_t bytes = min_t ( size_t , PAGE_CACHE_SIZE - offset , iov_iter_count ( ii ) ) ; bytes = min_t ( size_t , bytes , fc -> max_write - count ) ; again : err = - EFAULT ; if ( iov_iter_fault_in_readable ( ii , bytes ) ) break ; err = - ENOMEM ; page = grab_cache_page_write_begin ( mapping , index , 0 ) ; if ( ! page ) break ; if ( mapping_writably_mapped ( mapping ) ) flush_dcache_page ( page ) ; tmp = iov_iter_copy_from_user_atomic ( page , ii , offset , bytes ) ; flush_dcache_page ( page ) ; if ( ! tmp ) { unlock_page ( page ) ; page_cache_release ( page ) ; bytes = min ( bytes , iov_iter_single_seg_count ( ii ) ) ; goto again ; } err = 0 ; req -> pages [ req -> num_pages ] = page ; req -> page_descs [ req -> num_pages ] . length = tmp ; req -> num_pages ++ ; iov_iter_advance ( ii , tmp ) ; count += tmp ; pos += tmp ; offset += tmp ; if ( offset == PAGE_CACHE_SIZE ) offset = 0 ; if ( ! fc -> big_writes ) break ; } while ( iov_iter_count ( ii ) && count < fc -> max_write && req -> num_pages < req -> max_pages && offset == 0 ) ; return count > 0 ? count : err ; } "," flush_dcache_page ( page ) ; iov_iter_advance ( ii , tmp num_pages ++ ; count += tmp ",torvalds@linux/3ca8138f014a913f98e6ef40e939868e1e9ea876,CVE-2015-8785,https://github.com/torvalds/linux/commit/3ca8138f014a913f98e6ef40e939868e1e9ea876,2016-02-08T03:59Z 557,CWE-125,"CWE-125 static const u_char * ikev2_auth_print ( netdissect_options * ndo , u_char tpay , const struct isakmp_gen * ext , u_int item_len _U_ , const u_char * ep , uint32_t phase _U_ , uint32_t doi _U_ , uint32_t proto _U_ , int depth _U_ ) { struct ikev2_auth a ; const char * v2_auth [ ] = { ""invalid"" , ""rsasig"" , ""shared-secret"" , ""dsssig"" } ; const u_char * authdata = ( const u_char * ) ext + sizeof ( a ) ; unsigned int len ; ND_TCHECK ( * ext ) ; UNALIGNED_MEMCPY ( & a , ext , sizeof ( a ) ) ; ikev2_pay_print ( ndo , NPSTR ( tpay ) , a . h . critical ) ; len = ntohs ( a . h . len ) ; ND_PRINT ( ( ndo , ""len=%umethod=%s"" , len - 4 , STR_OR_ID ( a . auth_method , v2_auth ) ) ) ; if ( len > 4 ) { if ( ndo -> ndo_vflag > 1 ) { ND_PRINT ( ( ndo , ""authdata=("" ) ) ; if ( ! rawprint ( ndo , ( const uint8_t * ) authdata , len - sizeof ( a ) ) ) goto trunc ; ND_PRINT ( ( ndo , "")"" ) ) ; } else if ( ndo -> ndo_vflag ) { if ( ! ike_show_somedata ( ndo , authdata , ep ) ) goto trunc ; } } return ( const u_char * ) ext + len ; trunc : ND_PRINT ( ( ndo , ""[|%s]"" , NPSTR ( tpay ) ) ) ; return NULL ; } "," int len ; ND_TCHECK2 ( * ext , sizeof ( a ) ) ; UNALIGNED_MEMCPY ",the-tcpdump-group@tcpdump/8dca25d26c7ca2caf6138267f6f17111212c156e,CVE-2017-13690,https://github.com/the-tcpdump-group/tcpdump/commit/8dca25d26c7ca2caf6138267f6f17111212c156e,2017-09-14T06:29Z 558,CWE-264,"CWE-264 SYSCALL_DEFINE2 ( osf_getdomainname , char __user * , name , int , namelen ) { unsigned len ; int i ; if ( ! access_ok ( VERIFY_WRITE , name , namelen ) ) return - EFAULT ; len = namelen ; if ( namelen > 32 ) len = 32 ; down_read ( & uts_sem ) ; for ( i = 0 ; i < len ; ++ i ) { __put_user ( utsname ( ) -> domainname [ i ] , name + i ) ; if ( utsname ( ) -> domainname [ i ] == '\\0' ) break ; } up_read ( & uts_sem ) ; return 0 ; } "," ; if ( len > 32 ) ",torvalds@linux/21c5977a836e399fc710ff2c5367845ed5c2527f,CVE-2011-2211,https://github.com/torvalds/linux/commit/21c5977a836e399fc710ff2c5367845ed5c2527f,2012-06-13T10:24Z 559,CWE-399,"CWE-399 static int dcbnl_getperm_hwaddr ( struct net_device * netdev , struct nlmsghdr * nlh , u32 seq , struct nlattr * * tb , struct sk_buff * skb ) { u8 perm_addr [ MAX_ADDR_LEN ] ; if ( ! netdev -> dcbnl_ops -> getpermhwaddr ) return - EOPNOTSUPP ; netdev -> dcbnl_ops -> getpermhwaddr ( netdev , perm_addr ) ; return nla_put ( skb , DCB_ATTR_PERM_HWADDR , sizeof ( perm_addr ) , perm_addr ) ; } "," - EOPNOTSUPP ; memset ( perm_addr , 0 , sizeof ( perm_addr ) ) ; ",torvalds@linux/29cd8ae0e1a39e239a3a7b67da1986add1199fc0,CVE-2013-2634,https://github.com/torvalds/linux/commit/29cd8ae0e1a39e239a3a7b67da1986add1199fc0,2013-03-22T11:59Z 560,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 561,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 562,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 563,CWE-119,"CWE-119 static int Downmix_Command ( effect_handle_t self , uint32_t cmdCode , uint32_t cmdSize , void * pCmdData , uint32_t * replySize , void * pReplyData ) { downmix_module_t * pDwmModule = ( downmix_module_t * ) self ; downmix_object_t * pDownmixer ; int retsize ; if ( pDwmModule == NULL || pDwmModule -> context . state == DOWNMIX_STATE_UNINITIALIZED ) { return - EINVAL ; } pDownmixer = ( downmix_object_t * ) & pDwmModule -> context ; ALOGV ( ""Downmix_Commandcommand%"" PRIu32 ""cmdSize%"" PRIu32 , cmdCode , cmdSize ) ; switch ( cmdCode ) { case EFFECT_CMD_INIT : if ( pReplyData == NULL || * replySize != sizeof ( int ) ) { return - EINVAL ; } * ( int * ) pReplyData = Downmix_Init ( pDwmModule ) ; break ; case EFFECT_CMD_SET_CONFIG : if ( pCmdData == NULL || cmdSize != sizeof ( effect_config_t ) || pReplyData == NULL || * replySize != sizeof ( int ) ) { return - EINVAL ; } * ( int * ) pReplyData = Downmix_Configure ( pDwmModule , ( effect_config_t * ) pCmdData , false ) ; break ; case EFFECT_CMD_RESET : Downmix_Reset ( pDownmixer , false ) ; break ; case EFFECT_CMD_GET_PARAM : ALOGV ( ""Downmix_CommandEFFECT_CMD_GET_PARAMpCmdData%p,*replySize%"" PRIu32 "",pReplyData:%p"" , pCmdData , * replySize , pReplyData ) ; if ( pCmdData == NULL || cmdSize < ( int ) ( sizeof ( effect_param_t ) + sizeof ( int32_t ) ) || pReplyData == NULL || * replySize < ( int ) sizeof ( effect_param_t ) + 2 * sizeof ( int32_t ) ) { return - EINVAL ; } effect_param_t * rep = ( effect_param_t * ) pReplyData ; memcpy ( pReplyData , pCmdData , sizeof ( effect_param_t ) + sizeof ( int32_t ) ) ; ALOGV ( ""Downmix_CommandEFFECT_CMD_GET_PARAMparam%"" PRId32 "",replySize%"" PRIu32 , * ( int32_t * ) rep -> data , rep -> vsize ) ; rep -> status = Downmix_getParameter ( pDownmixer , * ( int32_t * ) rep -> data , & rep -> vsize , rep -> data + sizeof ( int32_t ) ) ; * replySize = sizeof ( effect_param_t ) + sizeof ( int32_t ) + rep -> vsize ; break ; case EFFECT_CMD_SET_PARAM : ALOGV ( ""Downmix_CommandEFFECT_CMD_SET_PARAMcmdSize%dpCmdData%p,*replySize%"" PRIu32 "",pReplyData%p"" , cmdSize , pCmdData , * replySize , pReplyData ) ; if ( pCmdData == NULL || ( cmdSize < ( int ) ( sizeof ( effect_param_t ) + sizeof ( int32_t ) ) ) || pReplyData == NULL || * replySize != ( int ) sizeof ( int32_t ) ) { return - EINVAL ; } effect_param_t * cmd = ( effect_param_t * ) pCmdData ; * ( int * ) pReplyData = Downmix_setParameter ( pDownmixer , * ( int32_t * ) cmd -> data , cmd -> vsize , cmd -> data + sizeof ( int32_t ) ) ; break ; case EFFECT_CMD_SET_PARAM_DEFERRED : ALOGW ( ""Downmix_CommandcommandEFFECT_CMD_SET_PARAM_DEFERREDnotsupported,FIXME"" ) ; break ; case EFFECT_CMD_SET_PARAM_COMMIT : ALOGW ( ""Downmix_CommandcommandEFFECT_CMD_SET_PARAM_COMMITnotsupported,FIXME"" ) ; break ; case EFFECT_CMD_ENABLE : if ( pReplyData == NULL || * replySize != sizeof ( int ) ) { return - EINVAL ; } if ( pDownmixer -> state != DOWNMIX_STATE_INITIALIZED ) { return - ENOSYS ; } pDownmixer -> state = DOWNMIX_STATE_ACTIVE ; ALOGV ( ""EFFECT_CMD_ENABLE()OK"" ) ; * ( int * ) pReplyData = 0 ; break ; case EFFECT_CMD_DISABLE : if ( pReplyData == NULL || * replySize != sizeof ( int ) ) { return - EINVAL ; } if ( pDownmixer -> state != DOWNMIX_STATE_ACTIVE ) { return - ENOSYS ; } pDownmixer -> state = DOWNMIX_STATE_INITIALIZED ; ALOGV ( ""EFFECT_CMD_DISABLE()OK"" ) ; * ( int * ) pReplyData = 0 ; break ; case EFFECT_CMD_SET_DEVICE : if ( pCmdData == NULL || cmdSize != ( int ) sizeof ( uint32_t ) ) { return - EINVAL ; } ALOGV ( ""Downmix_CommandEFFECT_CMD_SET_DEVICE:0x%08"" PRIx32 , * ( uint32_t * ) pCmdData ) ; break ; case EFFECT_CMD_SET_VOLUME : { if ( pCmdData == NULL || cmdSize != ( int ) sizeof ( uint32_t ) * 2 ) { return - EINVAL ; } ALOGW ( ""Downmix_CommandcommandEFFECT_CMD_SET_VOLUMEnotsupported,FIXME"" ) ; float left = ( float ) ( * ( uint32_t * ) pCmdData ) / ( 1 << 24 ) ; float right = ( float ) ( * ( ( uint32_t * ) pCmdData + 1 ) ) / ( 1 << 24 ) ; ALOGV ( ""Downmix_CommandEFFECT_CMD_SET_VOLUME:left%f,right%f"" , left , right ) ; break ; } case EFFECT_CMD_SET_AUDIO_MODE : if ( pCmdData == NULL || cmdSize != ( int ) sizeof ( uint32_t ) ) { return - EINVAL ; } ALOGV ( ""Downmix_CommandEFFECT_CMD_SET_AUDIO_MODE:%"" PRIu32 , * ( uint32_t * ) pCmdData ) ; break ; case EFFECT_CMD_SET_CONFIG_REVERSE : case EFFECT_CMD_SET_INPUT_DEVICE : break ; default : ALOGW ( ""Downmix_Commandinvalidcommand%"" PRIu32 , cmdCode ) ; return - EINVAL ; } return 0 ; } "," == NULL || replySize == NULL || ) || pReplyData == NULL || replySize ) || pReplyData == NULL || replySize == NULL || replySize == NULL || == NULL || replySize == NULL || if ( pReplyData == NULL || replySize ",frameworks@av/aeea52da00d210587fb3ed895de3d5f2e0264c88,CVE-2015-3842,https://android.googlesource.com/platform/frameworks/av/+/aeea52da00d210587fb3ed895de3d5f2e0264c88,2015-10-01T00:59Z 564,CWE-20,"CWE-20 static int pfkey_recvmsg ( struct kiocb * kiocb , struct socket * sock , struct msghdr * msg , size_t len , int flags ) { struct sock * sk = sock -> sk ; struct pfkey_sock * pfk = pfkey_sk ( sk ) ; struct sk_buff * skb ; int copied , err ; err = - EINVAL ; if ( flags & ~ ( MSG_PEEK | MSG_DONTWAIT | MSG_TRUNC | MSG_CMSG_COMPAT ) ) goto out ; msg -> msg_namelen = 0 ; skb = skb_recv_datagram ( sk , flags , flags & MSG_DONTWAIT , & err ) ; if ( skb == NULL ) goto out ; copied = skb -> len ; if ( copied > len ) { msg -> msg_flags |= MSG_TRUNC ; copied = len ; } skb_reset_transport_header ( skb ) ; err = skb_copy_datagram_iovec ( skb , 0 , msg -> msg_iov , copied ) ; if ( err ) goto out_free ; sock_recv_ts_and_drops ( msg , sk , skb ) ; err = ( flags & MSG_TRUNC ) ? skb -> len : copied ; if ( pfk -> dump . dump != NULL && 3 * atomic_read ( & sk -> sk_rmem_alloc ) <= sk -> sk_rcvbuf ) pfkey_do_dump ( pfk ) ; out_free : skb_free_datagram ( sk , skb ) ; out : return err ; } "," goto out ; skb = skb_recv_datagram ",torvalds@linux/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,CVE-2013-7271,https://github.com/torvalds/linux/commit/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,2014-01-06T16:55Z 565,CWE-119,"CWE-119 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 566,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 567,CWE-20,"CWE-20 static int nfs_can_extend_write ( struct file * file , struct page * page , struct inode * inode ) { if ( file -> f_flags & O_DSYNC ) return 0 ; if ( NFS_PROTO ( inode ) -> have_delegation ( inode , FMODE_WRITE ) ) return 1 ; if ( nfs_write_pageuptodate ( page , inode ) && ( inode -> i_flock == NULL || ( inode -> i_flock -> fl_start == 0 && inode -> i_flock -> fl_end == OFFSET_MAX && inode -> i_flock -> fl_type != F_RDLCK ) ) ) return 1 ; return 0 ; } "," ; if ( ! nfs_write_pageuptodate ( page , inode ) ) return 0 ; if ( ; if ( inode -> i_flock F_RDLCK ) ) return 1 ; ",torvalds@linux/263b4509ec4d47e0da3e753f85a39ea12d1eff24,CVE-2014-2038,https://github.com/torvalds/linux/commit/263b4509ec4d47e0da3e753f85a39ea12d1eff24,2014-02-28T06:18Z 568,CWE-119,"CWE-119 static int parse_video_info ( AVIOContext * pb , AVStream * st ) { uint16_t size_asf ; uint32_t size_bmp ; unsigned int tag ; st -> codecpar -> width = avio_rl32 ( pb ) ; st -> codecpar -> height = avio_rl32 ( pb ) ; avio_skip ( pb , 1 ) ; size_asf = avio_rl16 ( pb ) ; tag = ff_get_bmp_header ( pb , st , & size_bmp ) ; st -> codecpar -> codec_tag = tag ; st -> codecpar -> codec_id = ff_codec_get_id ( ff_codec_bmp_tags , tag ) ; size_bmp = FFMAX ( size_asf , size_bmp ) ; if ( size_bmp > BMP_HEADER_SIZE ) { int ret ; st -> codecpar -> extradata_size = size_bmp - BMP_HEADER_SIZE ; if ( ! ( st -> codecpar -> extradata = av_malloc ( st -> codecpar -> extradata_size + AV_INPUT_BUFFER_PADDING_SIZE ) ) ) { st -> codecpar -> extradata_size = 0 ; return AVERROR ( ENOMEM ) ; } memset ( st -> codecpar -> extradata + st -> codecpar -> extradata_size , 0 , AV_INPUT_BUFFER_PADDING_SIZE ) ; if ( ( ret = avio_read ( pb , st -> codecpar -> extradata , st -> codecpar -> extradata_size ) ) < 0 ) return ret ; } return 0 ; } "," size_bmp > BMP_HEADER_SIZE && size_bmp < INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE ",FFmpeg@FFmpeg/2b46ebdbff1d8dec7a3d8ea280a612b91a582869,CVE-2018-1999011,https://github.com/FFmpeg/FFmpeg/commit/2b46ebdbff1d8dec7a3d8ea280a612b91a582869,2018-07-23T15:29Z 569,CWE-119,"CWE-119 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-9728,https://github.com/torvalds/linux/commit/e237ec37ec154564f8690c5bd1795339955eeef9,2015-08-31T10:59Z 570,CWE-269,"CWE-269 static int futex_requeue ( u32 __user * uaddr1 , unsigned int flags , u32 __user * uaddr2 , int nr_wake , int nr_requeue , u32 * cmpval , int requeue_pi ) { union futex_key key1 = FUTEX_KEY_INIT , key2 = FUTEX_KEY_INIT ; int drop_count = 0 , task_count = 0 , ret ; struct futex_pi_state * pi_state = NULL ; struct futex_hash_bucket * hb1 , * hb2 ; struct futex_q * this , * next ; if ( requeue_pi ) { if ( refill_pi_state_cache ( ) ) return - ENOMEM ; if ( nr_wake != 1 ) return - EINVAL ; } retry : if ( pi_state != NULL ) { free_pi_state ( pi_state ) ; pi_state = NULL ; } ret = get_futex_key ( uaddr1 , flags & FLAGS_SHARED , & key1 , VERIFY_READ ) ; if ( unlikely ( ret != 0 ) ) goto out ; ret = get_futex_key ( uaddr2 , flags & FLAGS_SHARED , & key2 , requeue_pi ? VERIFY_WRITE : VERIFY_READ ) ; if ( unlikely ( ret != 0 ) ) goto out_put_key1 ; hb1 = hash_futex ( & key1 ) ; hb2 = hash_futex ( & key2 ) ; retry_private : hb_waiters_inc ( hb2 ) ; double_lock_hb ( hb1 , hb2 ) ; if ( likely ( cmpval != NULL ) ) { u32 curval ; ret = get_futex_value_locked ( & curval , uaddr1 ) ; if ( unlikely ( ret ) ) { double_unlock_hb ( hb1 , hb2 ) ; hb_waiters_dec ( hb2 ) ; ret = get_user ( curval , uaddr1 ) ; if ( ret ) goto out_put_keys ; if ( ! ( flags & FLAGS_SHARED ) ) goto retry_private ; put_futex_key ( & key2 ) ; put_futex_key ( & key1 ) ; goto retry ; } if ( curval != * cmpval ) { ret = - EAGAIN ; goto out_unlock ; } } if ( requeue_pi && ( task_count - nr_wake < nr_requeue ) ) { ret = futex_proxy_trylock_atomic ( uaddr2 , hb1 , hb2 , & key1 , & key2 , & pi_state , nr_requeue ) ; if ( ret > 0 ) { WARN_ON ( pi_state ) ; drop_count ++ ; task_count ++ ; ret = lookup_pi_state ( ret , hb2 , & key2 , & pi_state , NULL ) ; } switch ( ret ) { case 0 : break ; case - EFAULT : double_unlock_hb ( hb1 , hb2 ) ; hb_waiters_dec ( hb2 ) ; put_futex_key ( & key2 ) ; put_futex_key ( & key1 ) ; ret = fault_in_user_writeable ( uaddr2 ) ; if ( ! ret ) goto retry ; goto out ; case - EAGAIN : double_unlock_hb ( hb1 , hb2 ) ; hb_waiters_dec ( hb2 ) ; put_futex_key ( & key2 ) ; put_futex_key ( & key1 ) ; cond_resched ( ) ; goto retry ; default : goto out_unlock ; } } plist_for_each_entry_safe ( this , next , & hb1 -> chain , list ) { if ( task_count - nr_wake >= nr_requeue ) break ; if ( ! match_futex ( & this -> key , & key1 ) ) continue ; if ( ( requeue_pi && ! this -> rt_waiter ) || ( ! requeue_pi && this -> rt_waiter ) || this -> pi_state ) { ret = - EINVAL ; break ; } if ( ++ task_count <= nr_wake && ! requeue_pi ) { wake_futex ( this ) ; continue ; } if ( requeue_pi && ! match_futex ( this -> requeue_pi_key , & key2 ) ) { ret = - EINVAL ; break ; } if ( requeue_pi ) { atomic_inc ( & pi_state -> refcount ) ; this -> pi_state = pi_state ; ret = rt_mutex_start_proxy_lock ( & pi_state -> pi_mutex , this -> rt_waiter , this -> task , 1 ) ; if ( ret == 1 ) { requeue_pi_wake_futex ( this , & key2 , hb2 ) ; drop_count ++ ; continue ; } else if ( ret ) { this -> pi_state = NULL ; free_pi_state ( pi_state ) ; goto out_unlock ; } } requeue_futex ( this , hb1 , hb2 , & key2 ) ; drop_count ++ ; } out_unlock : double_unlock_hb ( hb1 , hb2 ) ; hb_waiters_dec ( hb2 ) ; while ( -- drop_count >= 0 ) drop_futex_key_refs ( & key1 ) ; out_put_keys : put_futex_key ( & key2 ) ; out_put_key1 : put_futex_key ( & key1 ) ; out : if ( pi_state != NULL ) free_pi_state ( pi_state ) ; return ret ? ret : task_count ; } "," { if ( uaddr1 == uaddr2 ) return - EINVAL ; if ( goto out_put_key1 ; if ( requeue_pi && match_futex ( & key1 , & key2 ) ) { ret = - EINVAL ; goto out_put_keys ; } ",torvalds@linux/e9c243a5a6de0be8e584c604d353412584b592f8,CVE-2014-3153,https://github.com/torvalds/linux/commit/e9c243a5a6de0be8e584c604d353412584b592f8,2014-06-07T14:55Z 571,CWE-20,"CWE-20 static void keyring_describe ( const struct key * keyring , struct seq_file * m ) { if ( keyring -> description ) seq_puts ( m , keyring -> description ) ; else seq_puts ( m , ""[anon]"" ) ; if ( key_is_instantiated ( keyring ) ) { if ( keyring -> keys . nr_leaves_on_tree != 0 ) seq_printf ( m , "":%lu"" , keyring -> keys . nr_leaves_on_tree ) ; else seq_puts ( m , "":empty"" ) ; } } "," ; if ( key_is_positive ( keyring ) ",torvalds@linux/363b02dab09b3226f3bd1420dad9c72b79a42a76,CVE-2017-15951,https://github.com/torvalds/linux/commit/363b02dab09b3226f3bd1420dad9c72b79a42a76,2017-10-28T02:29Z 572,CWE-189,"CWE-189 Datum hstore_from_record ( PG_FUNCTION_ARGS ) { HeapTupleHeader rec ; int32 buflen ; HStore * out ; Pairs * pairs ; Oid tupType ; int32 tupTypmod ; TupleDesc tupdesc ; HeapTupleData tuple ; RecordIOData * my_extra ; int ncolumns ; int i , j ; Datum * values ; bool * nulls ; if ( PG_ARGISNULL ( 0 ) ) { Oid argtype = get_fn_expr_argtype ( fcinfo -> flinfo , 0 ) ; tupType = argtype ; tupTypmod = - 1 ; rec = NULL ; } else { rec = PG_GETARG_HEAPTUPLEHEADER ( 0 ) ; tupType = HeapTupleHeaderGetTypeId ( rec ) ; tupTypmod = HeapTupleHeaderGetTypMod ( rec ) ; } tupdesc = lookup_rowtype_tupdesc ( tupType , tupTypmod ) ; ncolumns = tupdesc -> natts ; my_extra = ( RecordIOData * ) fcinfo -> flinfo -> fn_extra ; if ( my_extra == NULL || my_extra -> ncolumns != ncolumns ) { fcinfo -> flinfo -> fn_extra = MemoryContextAlloc ( fcinfo -> flinfo -> fn_mcxt , sizeof ( RecordIOData ) - sizeof ( ColumnIOData ) + ncolumns * sizeof ( ColumnIOData ) ) ; my_extra = ( RecordIOData * ) fcinfo -> flinfo -> fn_extra ; my_extra -> record_type = InvalidOid ; my_extra -> record_typmod = 0 ; } if ( my_extra -> record_type != tupType || my_extra -> record_typmod != tupTypmod ) { MemSet ( my_extra , 0 , sizeof ( RecordIOData ) - sizeof ( ColumnIOData ) + ncolumns * sizeof ( ColumnIOData ) ) ; my_extra -> record_type = tupType ; my_extra -> record_typmod = tupTypmod ; my_extra -> ncolumns = ncolumns ; } pairs = palloc ( ncolumns * sizeof ( Pairs ) ) ; if ( rec ) { tuple . t_len = HeapTupleHeaderGetDatumLength ( rec ) ; ItemPointerSetInvalid ( & ( tuple . t_self ) ) ; tuple . t_tableOid = InvalidOid ; tuple . t_data = rec ; values = ( Datum * ) palloc ( ncolumns * sizeof ( Datum ) ) ; nulls = ( bool * ) palloc ( ncolumns * sizeof ( bool ) ) ; heap_deform_tuple ( & tuple , tupdesc , values , nulls ) ; } else { values = NULL ; nulls = NULL ; } for ( i = 0 , j = 0 ; i < ncolumns ; ++ i ) { ColumnIOData * column_info = & my_extra -> columns [ i ] ; Oid column_type = tupdesc -> attrs [ i ] -> atttypid ; char * value ; if ( tupdesc -> attrs [ i ] -> attisdropped ) continue ; pairs [ j ] . key = NameStr ( tupdesc -> attrs [ i ] -> attname ) ; pairs [ j ] . keylen = hstoreCheckKeyLen ( strlen ( NameStr ( tupdesc -> attrs [ i ] -> attname ) ) ) ; if ( ! nulls || nulls [ i ] ) { pairs [ j ] . val = NULL ; pairs [ j ] . vallen = 4 ; pairs [ j ] . isnull = true ; pairs [ j ] . needfree = false ; ++ j ; continue ; } if ( column_info -> column_type != column_type ) { bool typIsVarlena ; getTypeOutputInfo ( column_type , & column_info -> typiofunc , & typIsVarlena ) ; fmgr_info_cxt ( column_info -> typiofunc , & column_info -> proc , fcinfo -> flinfo -> fn_mcxt ) ; column_info -> column_type = column_type ; } value = OutputFunctionCall ( & column_info -> proc , values [ i ] ) ; pairs [ j ] . val = value ; pairs [ j ] . vallen = hstoreCheckValLen ( strlen ( value ) ) ; pairs [ j ] . isnull = false ; pairs [ j ] . needfree = false ; ++ j ; } ncolumns = hstoreUniquePairs ( pairs , j , & buflen ) ; out = hstorePairs ( pairs , ncolumns , buflen ) ; ReleaseTupleDesc ( tupdesc ) ; PG_RETURN_POINTER ( out ) ; } "," ncolumns ; } Assert ( ncolumns <= MaxTupleAttributeNumber ) ; ",postgres@postgres/31400a673325147e1205326008e32135a78b4d8a,CVE-2014-2669,https://github.com/postgres/postgres/commit/31400a673325147e1205326008e32135a78b4d8a,2014-03-31T14:58Z 573,CWE-20,"CWE-20 error_t enc28j60ReceivePacket ( NetInterface * interface ) { error_t error ; uint16_t n ; uint16_t status ; Enc28j60Context * context ; context = ( Enc28j60Context * ) interface -> nicContext ; if ( enc28j60ReadReg ( interface , ENC28J60_REG_EPKTCNT ) ) { enc28j60WriteReg ( interface , ENC28J60_REG_ERDPTL , LSB ( context -> nextPacket ) ) ; enc28j60WriteReg ( interface , ENC28J60_REG_ERDPTH , MSB ( context -> nextPacket ) ) ; enc28j60ReadBuffer ( interface , ( uint8_t * ) & context -> nextPacket , sizeof ( uint16_t ) ) ; enc28j60ReadBuffer ( interface , ( uint8_t * ) & n , sizeof ( uint16_t ) ) ; enc28j60ReadBuffer ( interface , ( uint8_t * ) & status , sizeof ( uint16_t ) ) ; if ( ( status & RSV_RECEIVED_OK ) != 0 ) { n = MIN ( n , ETH_MAX_FRAME_SIZE ) ; enc28j60ReadBuffer ( interface , context -> rxBuffer , n ) ; error = NO_ERROR ; } else { error = ERROR_INVALID_PACKET ; } if ( context -> nextPacket == ENC28J60_RX_BUFFER_START ) { enc28j60WriteReg ( interface , ENC28J60_REG_ERXRDPTL , LSB ( ENC28J60_RX_BUFFER_STOP ) ) ; enc28j60WriteReg ( interface , ENC28J60_REG_ERXRDPTH , MSB ( ENC28J60_RX_BUFFER_STOP ) ) ; } else { enc28j60WriteReg ( interface , ENC28J60_REG_ERXRDPTL , LSB ( context -> nextPacket - 1 ) ) ; enc28j60WriteReg ( interface , ENC28J60_REG_ERXRDPTH , MSB ( context -> nextPacket - 1 ) ) ; } enc28j60SetBit ( interface , ENC28J60_REG_ECON2 , ECON2_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 ; uint16_t status uint16_t status ; uint8_t header [ 6 ] ; ( interface , ENC28J60_EPKTCNT ) != 0 ) { enc28j60WriteReg ( interface , ENC28J60_ERDPTL , LSB ( ( interface , ENC28J60_ERDPTH , MSB ( ( interface , header , sizeof ( , sizeof ( header ) ) ; context -> nextPacket = LOAD16LE ( header ) ; length = LOAD16LE ( header + 2 ) ; status = LOAD16LE ( header + 4 ) ; if ( status & ENC28J60_RSV_RECEIVED_OK ) != 0 0 ) { length = MIN ( = MIN ( length , ETH_MAX_FRAME_SIZE ) -> rxBuffer , length ) ; error ( interface , ENC28J60_ERXRDPTL , LSB ( ( interface , ENC28J60_ERXRDPTH , MSB ( ( interface , ENC28J60_ERXRDPTL , LSB ( ( interface , ENC28J60_ERXRDPTH , MSB ( ( interface , ENC28J60_ECON2 , ENC28J60_ECON2_PKTDEC ) ; } -> rxBuffer , length , & ancillary ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 574,CWE-617,"CWE-617 static int connection_edge_process_relay_cell ( cell_t * cell , circuit_t * circ , edge_connection_t * conn , crypt_path_t * layer_hint ) { static int num_seen = 0 ; relay_header_t rh ; unsigned domain = layer_hint ? LD_APP : LD_EXIT ; int reason ; int optimistic_data = 0 ; tor_assert ( cell ) ; tor_assert ( circ ) ; relay_header_unpack ( & rh , cell -> payload ) ; num_seen ++ ; log_debug ( domain , ""Nowseen%drelaycellshere(command%d,stream%d)."" , num_seen , rh . command , rh . stream_id ) ; if ( rh . length > RELAY_PAYLOAD_SIZE ) { log_fn ( LOG_PROTOCOL_WARN , LD_PROTOCOL , ""Relaycelllengthfieldtoolong.Closingcircuit."" ) ; return - END_CIRC_REASON_TORPROTOCOL ; } if ( rh . stream_id == 0 ) { switch ( rh . command ) { case RELAY_COMMAND_BEGIN : case RELAY_COMMAND_CONNECTED : case RELAY_COMMAND_DATA : case RELAY_COMMAND_END : case RELAY_COMMAND_RESOLVE : case RELAY_COMMAND_RESOLVED : case RELAY_COMMAND_BEGIN_DIR : log_fn ( LOG_PROTOCOL_WARN , LD_PROTOCOL , ""Relaycommand%dwithzero"" ""stream_id.Dropping."" , ( int ) rh . command ) ; return 0 ; default : ; } } if ( conn && ! connection_state_is_open ( TO_CONN ( conn ) ) ) { if ( conn -> base_ . type == CONN_TYPE_EXIT && ( conn -> base_ . state == EXIT_CONN_STATE_CONNECTING || conn -> base_ . state == EXIT_CONN_STATE_RESOLVING ) && rh . command == RELAY_COMMAND_DATA ) { optimistic_data = 1 ; } else { return connection_edge_process_relay_cell_not_open ( & rh , cell , circ , conn , layer_hint ) ; } } switch ( rh . command ) { case RELAY_COMMAND_DROP : return 0 ; case RELAY_COMMAND_BEGIN : case RELAY_COMMAND_BEGIN_DIR : if ( layer_hint && circ -> purpose != CIRCUIT_PURPOSE_S_REND_JOINED ) { log_fn ( LOG_PROTOCOL_WARN , LD_APP , ""RelaybeginrequestunsupportedatAP.Dropping."" ) ; return 0 ; } if ( circ -> purpose == CIRCUIT_PURPOSE_S_REND_JOINED && layer_hint != TO_ORIGIN_CIRCUIT ( circ ) -> cpath -> prev ) { log_fn ( LOG_PROTOCOL_WARN , LD_APP , ""RelaybeginrequesttoHiddenService"" ""fromintermediarynode.Dropping."" ) ; return 0 ; } if ( conn ) { log_fn ( LOG_PROTOCOL_WARN , domain , ""Begincellforknownstream.Dropping."" ) ; return 0 ; } if ( rh . command == RELAY_COMMAND_BEGIN_DIR ) { static uint64_t next_id = 0 ; circ -> dirreq_id = ++ next_id ; TO_OR_CIRCUIT ( circ ) -> p_chan -> dirreq_id = circ -> dirreq_id ; } return connection_exit_begin_conn ( cell , circ ) ; case RELAY_COMMAND_DATA : ++ stats_n_data_cells_received ; if ( ( layer_hint && -- layer_hint -> deliver_window < 0 ) || ( ! layer_hint && -- circ -> deliver_window < 0 ) ) { log_fn ( LOG_PROTOCOL_WARN , LD_PROTOCOL , ""(relaydata)circdeliver_windowbelow0.Killing."" ) ; if ( conn ) { connection_edge_end ( conn , END_STREAM_REASON_TORPROTOCOL ) ; connection_mark_for_close ( TO_CONN ( conn ) ) ; } return - END_CIRC_REASON_TORPROTOCOL ; } log_debug ( domain , ""circdeliver_windownow%d."" , layer_hint ? layer_hint -> deliver_window : circ -> deliver_window ) ; circuit_consider_sending_sendme ( circ , layer_hint ) ; if ( ! conn ) { log_info ( domain , ""datacelldropped,unknownstream(streamid%d)."" , rh . stream_id ) ; return 0 ; } if ( -- conn -> deliver_window < 0 ) { log_fn ( LOG_PROTOCOL_WARN , LD_PROTOCOL , ""(relaydata)conndeliver_windowbelow0.Killing."" ) ; return - END_CIRC_REASON_TORPROTOCOL ; } stats_n_data_bytes_received += rh . length ; connection_write_to_buf ( ( char * ) ( cell -> payload + RELAY_HEADER_SIZE ) , rh . length , TO_CONN ( conn ) ) ; if ( ! optimistic_data ) { connection_edge_consider_sending_sendme ( conn ) ; } return 0 ; case RELAY_COMMAND_END : reason = rh . length > 0 ? get_uint8 ( cell -> payload + RELAY_HEADER_SIZE ) : END_STREAM_REASON_MISC ; if ( ! conn ) { log_info ( domain , ""endcell(%s)dropped,unknownstream."" , stream_end_reason_to_string ( reason ) ) ; return 0 ; } log_info ( domain , TOR_SOCKET_T_FORMAT "":endcell(%s)forstream%d."" ""Removingstream."" , conn -> base_ . s , stream_end_reason_to_string ( reason ) , conn -> stream_id ) ; if ( conn -> base_ . type == CONN_TYPE_AP ) { entry_connection_t * entry_conn = EDGE_TO_ENTRY_CONN ( conn ) ; if ( entry_conn -> socks_request && ! entry_conn -> socks_request -> has_finished ) log_warn ( LD_BUG , ""openstreamhasn\'tsentsocksansweryet?Closing."" ) ; } conn -> edge_has_sent_end = 1 ; if ( ! conn -> end_reason ) conn -> end_reason = reason | END_STREAM_REASON_FLAG_REMOTE ; if ( ! conn -> base_ . marked_for_close ) { connection_mark_and_flush ( TO_CONN ( conn ) ) ; } return 0 ; case RELAY_COMMAND_EXTEND : case RELAY_COMMAND_EXTEND2 : { static uint64_t total_n_extend = 0 , total_nonearly = 0 ; total_n_extend ++ ; if ( rh . stream_id ) { log_fn ( LOG_PROTOCOL_WARN , domain , ""\'extend\'cellreceivedfornon-zerostream.Dropping."" ) ; return 0 ; } if ( cell -> command != CELL_RELAY_EARLY && ! networkstatus_get_param ( NULL , ""AllowNonearlyExtend"" , 0 , 0 , 1 ) ) { # define EARLY_WARNING_INTERVAL 3600 static ratelim_t early_warning_limit = RATELIM_INIT ( EARLY_WARNING_INTERVAL ) ; char * m ; if ( cell -> command == CELL_RELAY ) { ++ total_nonearly ; if ( ( m = rate_limit_log ( & early_warning_limit , approx_time ( ) ) ) ) { double percentage = ( ( double ) total_nonearly ) / total_n_extend ; percentage *= 100 ; log_fn ( LOG_PROTOCOL_WARN , domain , ""EXTENDcellreceived,"" ""butnotviaRELAY_EARLY.Dropping.%s"" , m ) ; log_fn ( LOG_PROTOCOL_WARN , domain , ""(Wehavedropped%.02f%%of"" ""allEXTENDcellsforthisreason)"" , percentage ) ; tor_free ( m ) ; } } else { log_fn ( LOG_WARN , domain , ""EXTENDcellreceived,inacellwithtype%d!Dropping."" , cell -> command ) ; } return 0 ; } return circuit_extend ( cell , circ ) ; } case RELAY_COMMAND_EXTENDED : case RELAY_COMMAND_EXTENDED2 : if ( ! layer_hint ) { log_fn ( LOG_PROTOCOL_WARN , LD_PROTOCOL , ""\'extended\'unsupportedatnon-origin.Dropping."" ) ; return 0 ; } log_debug ( domain , ""Gotanextendedcell!Yay."" ) ; { extended_cell_t extended_cell ; if ( extended_cell_parse ( & extended_cell , rh . command , ( const uint8_t * ) cell -> payload + RELAY_HEADER_SIZE , rh . length ) < 0 ) { log_warn ( LD_PROTOCOL , ""Can\'tparseEXTENDEDcell;killingcircuit."" ) ; return - END_CIRC_REASON_TORPROTOCOL ; } if ( ( reason = circuit_finish_handshake ( TO_ORIGIN_CIRCUIT ( circ ) , & extended_cell . created_cell ) ) < 0 ) { log_warn ( domain , ""circuit_finish_handshakefailed."" ) ; return reason ; } } if ( ( reason = circuit_send_next_onion_skin ( TO_ORIGIN_CIRCUIT ( circ ) ) ) < 0 ) { log_info ( domain , ""circuit_send_next_onion_skin()failed."" ) ; return reason ; } return 0 ; case RELAY_COMMAND_TRUNCATE : if ( layer_hint ) { log_fn ( LOG_PROTOCOL_WARN , LD_APP , ""\'truncate\'unsupportedatorigin.Dropping."" ) ; return 0 ; } if ( circ -> n_hop ) { if ( circ -> n_chan ) log_warn ( LD_BUG , ""n_chanandn_hopsetonthesamecircuit!"" ) ; extend_info_free ( circ -> n_hop ) ; circ -> n_hop = NULL ; tor_free ( circ -> n_chan_create_cell ) ; circuit_set_state ( circ , CIRCUIT_STATE_OPEN ) ; } if ( circ -> n_chan ) { uint8_t trunc_reason = get_uint8 ( cell -> payload + RELAY_HEADER_SIZE ) ; circuit_clear_cell_queue ( circ , circ -> n_chan ) ; channel_send_destroy ( circ -> n_circ_id , circ -> n_chan , trunc_reason ) ; circuit_set_n_circid_chan ( circ , 0 , NULL ) ; } log_debug ( LD_EXIT , ""Processed\'truncate\',replying."" ) ; { char payload [ 1 ] ; payload [ 0 ] = ( char ) END_CIRC_REASON_REQUESTED ; relay_send_command_from_edge ( 0 , circ , RELAY_COMMAND_TRUNCATED , payload , sizeof ( payload ) , NULL ) ; } return 0 ; case RELAY_COMMAND_TRUNCATED : if ( ! layer_hint ) { log_fn ( LOG_PROTOCOL_WARN , LD_EXIT , ""\'truncated\'unsupportedatnon-origin.Dropping."" ) ; return 0 ; } circuit_truncated ( TO_ORIGIN_CIRCUIT ( circ ) , layer_hint , get_uint8 ( cell -> payload + RELAY_HEADER_SIZE ) ) ; return 0 ; case RELAY_COMMAND_CONNECTED : if ( conn ) { log_fn ( LOG_PROTOCOL_WARN , LD_PROTOCOL , ""\'connected\'unsupportedwhileopen.Closingcirc."" ) ; return - END_CIRC_REASON_TORPROTOCOL ; } log_info ( domain , ""\'connected\'received,noconnattachedanymore.Ignoring."" ) ; return 0 ; case RELAY_COMMAND_SENDME : if ( ! rh . stream_id ) { if ( layer_hint ) { if ( layer_hint -> package_window + CIRCWINDOW_INCREMENT > CIRCWINDOW_START_MAX ) { log_fn ( LOG_PROTOCOL_WARN , LD_PROTOCOL , ""Unexpectedsendmecellfromexitrelay."" ""Closingcirc."" ) ; return - END_CIRC_REASON_TORPROTOCOL ; } layer_hint -> package_window += CIRCWINDOW_INCREMENT ; log_debug ( LD_APP , ""circ-levelsendmeatorigin,packagewindow%d."" , layer_hint -> package_window ) ; circuit_resume_edge_reading ( circ , layer_hint ) ; } else { if ( circ -> package_window + CIRCWINDOW_INCREMENT > CIRCWINDOW_START_MAX ) { log_fn ( LOG_PROTOCOL_WARN , LD_PROTOCOL , ""Unexpectedsendmecellfromclient."" ""Closingcirc(window%d)."" , circ -> package_window ) ; return - END_CIRC_REASON_TORPROTOCOL ; } circ -> package_window += CIRCWINDOW_INCREMENT ; log_debug ( LD_APP , ""circ-levelsendmeatnon-origin,packagewindow%d."" , circ -> package_window ) ; circuit_resume_edge_reading ( circ , layer_hint ) ; } return 0 ; } if ( ! conn ) { log_info ( domain , ""sendmecelldropped,unknownstream(streamid%d)."" , rh . stream_id ) ; return 0 ; } conn -> package_window += STREAMWINDOW_INCREMENT ; log_debug ( domain , ""stream-levelsendme,packagewindownow%d."" , conn -> package_window ) ; if ( circuit_queue_streams_are_blocked ( circ ) ) { return 0 ; } connection_start_reading ( TO_CONN ( conn ) ) ; if ( connection_edge_package_raw_inbuf ( conn , 1 , NULL ) < 0 ) { connection_mark_for_close ( TO_CONN ( conn ) ) ; return 0 ; } return 0 ; case RELAY_COMMAND_RESOLVE : if ( layer_hint ) { log_fn ( LOG_PROTOCOL_WARN , LD_APP , ""resolverequestunsupportedatAP;dropping."" ) ; return 0 ; } else if ( conn ) { log_fn ( LOG_PROTOCOL_WARN , domain , ""resolverequestforknownstream;dropping."" ) ; return 0 ; } else if ( circ -> purpose != CIRCUIT_PURPOSE_OR ) { log_fn ( LOG_PROTOCOL_WARN , domain , ""resolverequestoncircwithpurpose%d;dropping"" , circ -> purpose ) ; return 0 ; } connection_exit_begin_resolve ( cell , TO_OR_CIRCUIT ( circ ) ) ; return 0 ; case RELAY_COMMAND_RESOLVED : if ( conn ) { log_fn ( LOG_PROTOCOL_WARN , domain , ""\'resolved\'unsupportedwhileopen.Closingcirc."" ) ; return - END_CIRC_REASON_TORPROTOCOL ; } log_info ( domain , ""\'resolved\'received,noconnattachedanymore.Ignoring."" ) ; return 0 ; case RELAY_COMMAND_ESTABLISH_INTRO : case RELAY_COMMAND_ESTABLISH_RENDEZVOUS : case RELAY_COMMAND_INTRODUCE1 : case RELAY_COMMAND_INTRODUCE2 : case RELAY_COMMAND_INTRODUCE_ACK : case RELAY_COMMAND_RENDEZVOUS1 : case RELAY_COMMAND_RENDEZVOUS2 : case RELAY_COMMAND_INTRO_ESTABLISHED : case RELAY_COMMAND_RENDEZVOUS_ESTABLISHED : rend_process_relay_cell ( circ , layer_hint , rh . command , rh . length , cell -> payload + RELAY_HEADER_SIZE ) ; return 0 ; } log_fn ( LOG_PROTOCOL_WARN , LD_PROTOCOL , ""Receivedunknownrelaycommand%d.Perhapstheothersideisusing"" ""anewerversionofTor?Dropping."" , rh . command ) ; return 0 ; } "," command == RELAY_COMMAND_BEGIN_DIR && circ -> purpose != CIRCUIT_PURPOSE_S_REND_JOINED ",torproject@tor/56a7c5bc15e0447203a491c1ee37de9939ad1dcd,CVE-2017-0376,https://github.com/torproject/tor/commit/56a7c5bc15e0447203a491c1ee37de9939ad1dcd,2017-06-09T17:29Z 575,CWE-834,"CWE-834 static int asf_read_marker ( AVFormatContext * s , int64_t size ) { AVIOContext * pb = s -> pb ; ASFContext * asf = s -> priv_data ; int i , count , name_len , ret ; char name [ 1024 ] ; avio_rl64 ( pb ) ; avio_rl64 ( pb ) ; count = avio_rl32 ( pb ) ; avio_rl16 ( pb ) ; name_len = avio_rl16 ( pb ) ; for ( i = 0 ; i < name_len ; i ++ ) avio_r8 ( pb ) ; for ( i = 0 ; i < count ; i ++ ) { int64_t pres_time ; int name_len ; avio_rl64 ( pb ) ; pres_time = avio_rl64 ( pb ) ; pres_time -= asf -> hdr . preroll * 10000 ; avio_rl16 ( pb ) ; avio_rl32 ( pb ) ; avio_rl32 ( pb ) ; name_len = avio_rl32 ( pb ) ; if ( ( ret = avio_get_str16le ( pb , name_len * 2 , name , sizeof ( name ) ) ) < name_len ) avio_skip ( pb , name_len - ret ) ; avpriv_new_chapter ( s , i , ( AVRational ) { 1 , 10000000 } , pres_time , AV_NOPTS_VALUE , name ) ; } return 0 ; } "," pb ) ; avio_skip ( pb , name_len ) ; for ; int name_len ; if ( avio_feof ( pb ) ) return AVERROR_INVALIDDATA ",FFmpeg@FFmpeg/7f9ec5593e04827249e7aeb466da06a98a0d7329,CVE-2017-14057,https://github.com/FFmpeg/FFmpeg/commit/7f9ec5593e04827249e7aeb466da06a98a0d7329,2017-08-31T15:29Z 576,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 577,CWE-362,"CWE-362 static int ext4_convert_unwritten_extents_endio ( handle_t * handle , struct inode * inode , struct ext4_ext_path * path ) { struct ext4_extent * ex ; int depth ; int err = 0 ; depth = ext_depth ( inode ) ; ex = path [ depth ] . p_ext ; ext_debug ( ""ext4_convert_unwritten_extents_endio:inode%lu,logical"" ""block%llu,max_blocks%u\\n"" , inode -> i_ino , ( unsigned long long ) le32_to_cpu ( ex -> ee_block ) , ext4_ext_get_actual_len ( ex ) ) ; err = ext4_ext_get_access ( handle , inode , path + depth ) ; if ( err ) goto out ; ext4_ext_mark_initialized ( ex ) ; ext4_ext_try_to_merge ( handle , inode , path , ex ) ; err = ext4_ext_dirty ( handle , inode , path + path -> p_depth ) ; out : ext4_ext_show_leaf ( inode , path ) ; return err ; } "," inode , struct ext4_map_blocks * map , struct ext4_extent * ex ; ext4_lblk_t ee_block ; unsigned int ee_len . p_ext ; ee_block = le32_to_cpu ( ex -> ee_block ) ; ee_len = ext4_ext_get_actual_len ( ex ) ; long long ) ee_block , ee_len ) ; if ( ee_block != map -> m_lblk || ee_len > map -> m_len ) { err = ext4_split_unwritten_extents ( handle , inode , map , path , EXT4_GET_BLOCKS_CONVERT ) ; if ( err < 0 ) goto out ; ext4_ext_drop_refs ( path ) ; path = ext4_ext_find_extent ( inode , map -> m_lblk , path ) ; if ( IS_ERR ( path ) ) { err = PTR_ERR ( path ) ; goto out ; } depth = ext_depth ( inode ) ; ex = path [ depth ] . p_ext ; } err = ext4_ext_get_access ",torvalds@linux/dee1f973ca341c266229faa5a1a5bb268bed3531,CVE-2012-4508,https://github.com/torvalds/linux/commit/dee1f973ca341c266229faa5a1a5bb268bed3531,2012-12-21T11:47Z 578,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/2fdef641fd0dd2828bd948234ae86de75221a11a,CVE-2016-10129,https://github.com/libgit2/libgit2/commit/2fdef641fd0dd2828bd948234ae86de75221a11a,2017-03-24T15:59Z 579,CWE-264,"CWE-264 int xmkstemp ( char * * tmpname , char * dir ) { char * localtmp ; char * tmpenv ; mode_t old_mode ; int fd , rc ; if ( dir != NULL ) tmpenv = dir ; else tmpenv = getenv ( ""TMPDIR"" ) ; if ( tmpenv ) rc = asprintf ( & localtmp , ""%s/%s.XXXXXX"" , tmpenv , program_invocation_short_name ) ; else rc = asprintf ( & localtmp , ""%s/%s.XXXXXX"" , _PATH_TMP , program_invocation_short_name ) ; if ( rc < 0 ) return - 1 ; old_mode = umask ( 077 ) ; fd = mkostemp ( localtmp , O_RDWR | O_CREAT | O_EXCL | O_CLOEXEC ) ; umask ( old_mode ) ; if ( fd == - 1 ) { free ( localtmp ) ; localtmp = NULL ; } * tmpname = localtmp ; return fd ; } "," * tmpname , const char * dir , const char * prefix * localtmp ; const , rc ; tmpenv = dir tmpenv = dir ? dir : getenv ( ""TMPDIR"" ; if ( ! tmpenv ) tmpenv = _PATH_TMP ; rc = asprintf , tmpenv , prefix ) ; if ",karelzak@util-linux/bde91c85bdc77975155058276f99d2e0f5eab5a9,CVE-2015-5224,https://github.com/karelzak/util-linux/commit/bde91c85bdc77975155058276f99d2e0f5eab5a9,2017-08-23T15:29Z 580,CWE-20,"CWE-20 void dhcpClientProcessMessage ( NetInterface * interface , const IpPseudoHeader * pseudoHeader , const UdpHeader * udpHeader , const NetBuffer * buffer , size_t offset , const NetRxAncillary * ancillary , void * param ) { size_t length ; DhcpClientContext * context ; DhcpMessage * message ; DhcpOption * option ; context = ( DhcpClientContext * ) param ; length = netBufferGetLength ( buffer ) - offset ; if ( length < sizeof ( DhcpMessage ) ) return ; if ( length > DHCP_MAX_MSG_SIZE ) return ; message = netBufferAt ( buffer , offset ) ; if ( message == NULL ) return ; TRACE_DEBUG ( ""\\r\\n%s:DHCPmessagereceived(%"" PRIuSIZE ""bytes)...\\r\\n"" , formatSystemTime ( osGetSystemTime ( ) , NULL ) , length ) ; dhcpDumpMessage ( message , length ) ; if ( message -> op != DHCP_OPCODE_BOOTREPLY ) return ; if ( message -> htype != DHCP_HARDWARE_TYPE_ETH ) return ; if ( message -> hlen != sizeof ( MacAddr ) ) return ; if ( message -> magicCookie != HTONL ( DHCP_MAGIC_COOKIE ) ) return ; option = dhcpGetOption ( message , length , DHCP_OPT_DHCP_MESSAGE_TYPE ) ; if ( option == NULL || option -> length != 1 ) return ; switch ( option -> value [ 0 ] ) { case DHCP_MESSAGE_TYPE_OFFER : dhcpClientParseOffer ( context , message , length ) ; break ; case DHCP_MESSAGE_TYPE_ACK : dhcpClientParseAck ( context , message , length ) ; break ; case DHCP_MESSAGE_TYPE_NAK : dhcpClientParseNak ( context , message , length ) ; break ; default : break ; } } "," ( DhcpMessage ) || length > DHCP_MAX_MSG_SIZE ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 581,CWE-119,"CWE-119 static void process_blob ( struct rev_info * revs , struct blob * blob , show_object_fn show , struct strbuf * path , const char * name , void * cb_data ) { struct object * obj = & blob -> object ; if ( ! revs -> blob_objects ) return ; if ( ! obj ) die ( ""badblobobject"" ) ; if ( obj -> flags & ( UNINTERESTING | SEEN ) ) return ; obj -> flags |= SEEN ; show ( obj , path , name , cb_data ) ; } "," -> object ; size_t pathlen ; |= SEEN ; pathlen = path -> len ; strbuf_addstr ( path , name ) ; obj , path -> buf , cb_data ) cb_data ) ; strbuf_setlen ( path , pathlen ) ; ",git@git/de1e67d0703894cb6ea782e36abb63976ab07e60,CVE-2016-2324,https://github.com/git/git/commit/de1e67d0703894cb6ea782e36abb63976ab07e60,2016-04-08T14:59Z 582,CWE-119,"CWE-119 int mainloop ( CLIENT * client ) { struct nbd_request request ; struct nbd_reply reply ; gboolean go_on = TRUE ; # ifdef DODBG int i = 0 ; # endif negotiate ( client -> net , client , NULL ) ; DEBUG ( ""Enteringrequestloop!\\n"" ) ; reply . magic = htonl ( NBD_REPLY_MAGIC ) ; reply . error = 0 ; while ( go_on ) { char buf [ BUFSIZE ] ; size_t len ; # ifdef DODBG i ++ ; printf ( ""%d:"" , i ) ; # endif readit ( client -> net , & request , sizeof ( request ) ) ; request . from = ntohll ( request . from ) ; request . type = ntohl ( request . type ) ; if ( request . type == NBD_CMD_DISC ) { msg2 ( LOG_INFO , ""Disconnectrequestreceived."" ) ; if ( client -> server -> flags & F_COPYONWRITE ) { if ( client -> difmap ) g_free ( client -> difmap ) ; close ( client -> difffile ) ; unlink ( client -> difffilename ) ; free ( client -> difffilename ) ; } go_on = FALSE ; continue ; } len = ntohl ( request . len ) ; if ( request . magic != htonl ( NBD_REQUEST_MAGIC ) ) err ( ""Notenoughmagic."" ) ; if ( len > BUFSIZE + sizeof ( struct nbd_reply ) ) err ( ""Requesttoobig!"" ) ; # ifdef DODBG printf ( ""%sfrom%llu(%llu)len%d,"" , request . type ? ""WRITE"" : ""READ"" , ( unsigned long long ) request . from , ( unsigned long long ) request . from / 512 , len ) ; # endif memcpy ( reply . handle , request . handle , sizeof ( reply . handle ) ) ; if ( ( request . from + len ) > ( OFFT_MAX ) ) { DEBUG ( ""[Numbertoolarge!]"" ) ; ERROR ( client , reply , EINVAL ) ; continue ; } if ( ( ( ssize_t ) ( ( off_t ) request . from + len ) > client -> exportsize ) ) { DEBUG ( ""[RANGE!]"" ) ; ERROR ( client , reply , EINVAL ) ; continue ; } if ( request . type == NBD_CMD_WRITE ) { DEBUG ( ""wr:net->buf,"" ) ; readit ( client -> net , buf , len ) ; DEBUG ( ""buf->exp,"" ) ; if ( ( client -> server -> flags & F_READONLY ) || ( client -> server -> flags & F_AUTOREADONLY ) ) { DEBUG ( ""[WRITEtoREADONLY!]"" ) ; ERROR ( client , reply , EPERM ) ; continue ; } if ( expwrite ( request . from , buf , len , client ) ) { DEBUG ( ""Writefailed:%m"" ) ; ERROR ( client , reply , errno ) ; continue ; } SEND ( client -> net , reply ) ; DEBUG ( ""OK!\\n"" ) ; continue ; } DEBUG ( ""exp->buf,"" ) ; if ( expread ( request . from , buf + sizeof ( struct nbd_reply ) , len , client ) ) { DEBUG ( ""Readfailed:%m"" ) ; ERROR ( client , reply , errno ) ; continue ; } DEBUG ( ""buf->net,"" ) ; memcpy ( buf , & reply , sizeof ( struct nbd_reply ) ) ; writeit ( client -> net , buf , len + sizeof ( struct nbd_reply ) ) ; DEBUG ( ""OK!\\n"" ) ; } return 0 ; } "," len > BUFSIZE - sizeof ( struct ",yoe@nbd/3ef52043861ab16352d49af89e048ba6339d6df8,CVE-2011-0530,https://github.com/yoe/nbd/commit/3ef52043861ab16352d49af89e048ba6339d6df8,2011-02-22T19:00Z 583,CWE-000,"CWE-000 static void __nfs4_close ( struct path * path , struct nfs4_state * state , mode_t mode , int wait ) { struct nfs4_state_owner * owner = state -> owner ; int call_close = 0 ; int newstate ; atomic_inc ( & owner -> so_count ) ; spin_lock ( & owner -> so_lock ) ; switch ( mode & ( FMODE_READ | FMODE_WRITE ) ) { case FMODE_READ : state -> n_rdonly -- ; break ; case FMODE_WRITE : state -> n_wronly -- ; break ; case FMODE_READ | FMODE_WRITE : state -> n_rdwr -- ; } newstate = FMODE_READ | FMODE_WRITE ; if ( state -> n_rdwr == 0 ) { if ( state -> n_rdonly == 0 ) { newstate &= ~ FMODE_READ ; call_close |= test_bit ( NFS_O_RDONLY_STATE , & state -> flags ) ; call_close |= test_bit ( NFS_O_RDWR_STATE , & state -> flags ) ; } if ( state -> n_wronly == 0 ) { newstate &= ~ FMODE_WRITE ; call_close |= test_bit ( NFS_O_WRONLY_STATE , & state -> flags ) ; call_close |= test_bit ( NFS_O_RDWR_STATE , & state -> flags ) ; } if ( newstate == 0 ) clear_bit ( NFS_DELEGATED_STATE , & state -> flags ) ; } nfs4_state_set_mode_locked ( state , newstate ) ; spin_unlock ( & owner -> so_lock ) ; if ( ! call_close ) { nfs4_put_open_state ( state ) ; nfs4_put_state_owner ( owner ) ; } else nfs4_do_close ( path , state , wait ) ; } "," * state , fmode_t fmode , int wait = 0 ; fmode_t newstate ; atomic_inc ; switch ( fmode & ( FMODE_READ ",torvalds@linux/dc0b027dfadfcb8a5504f7d8052754bf8d501ab9,CVE-2011-4324,https://github.com/torvalds/linux/commit/dc0b027dfadfcb8a5504f7d8052754bf8d501ab9,2012-06-21T23:55Z 584,CWE-119,"CWE-119 static int host_start ( struct ci13xxx * ci ) { struct usb_hcd * hcd ; struct ehci_hcd * ehci ; int ret ; if ( usb_disabled ( ) ) return - ENODEV ; hcd = usb_create_hcd ( & ci_ehci_hc_driver , ci -> dev , dev_name ( ci -> dev ) ) ; if ( ! hcd ) return - ENOMEM ; dev_set_drvdata ( ci -> dev , ci ) ; hcd -> rsrc_start = ci -> hw_bank . phys ; hcd -> rsrc_len = ci -> hw_bank . size ; hcd -> regs = ci -> hw_bank . abs ; hcd -> has_tt = 1 ; hcd -> power_budget = ci -> platdata -> power_budget ; hcd -> phy = ci -> transceiver ; ehci = hcd_to_ehci ( hcd ) ; ehci -> caps = ci -> hw_bank . cap ; ehci -> has_hostpc = ci -> hw_bank . lpm ; ret = usb_add_hcd ( hcd , 0 , 0 ) ; if ( ret ) usb_put_hcd ( hcd ) ; else ci -> hcd = hcd ; return ret ; } "," = hcd ; if ( ci -> platdata -> flags & CI13XXX_DISABLE_STREAMING ) hw_write ( ci , OP_USBMODE , USBMODE_CI_SDIS , USBMODE_CI_SDIS ) ; ",torvalds@linux/929473ea05db455ad88cdc081f2adc556b8dc48f,CVE-2013-2058,https://github.com/torvalds/linux/commit/929473ea05db455ad88cdc081f2adc556b8dc48f,2013-11-04T15:55Z 585,CWE-200,"CWE-200 static int snd_timer_user_params ( struct file * file , struct snd_timer_params __user * _params ) { struct snd_timer_user * tu ; struct snd_timer_params params ; struct snd_timer * t ; struct snd_timer_read * tr ; struct snd_timer_tread * ttr ; int err ; tu = file -> private_data ; if ( ! tu -> timeri ) return - EBADFD ; t = tu -> timeri -> timer ; if ( ! t ) return - EBADFD ; if ( copy_from_user ( & params , _params , sizeof ( params ) ) ) return - EFAULT ; if ( ! ( t -> hw . flags & SNDRV_TIMER_HW_SLAVE ) && params . ticks < 1 ) { err = - EINVAL ; goto _end ; } if ( params . queue_size > 0 && ( params . queue_size < 32 || params . queue_size > 1024 ) ) { err = - EINVAL ; goto _end ; } if ( params . filter & ~ ( ( 1 << SNDRV_TIMER_EVENT_RESOLUTION ) | ( 1 << SNDRV_TIMER_EVENT_TICK ) | ( 1 << SNDRV_TIMER_EVENT_START ) | ( 1 << SNDRV_TIMER_EVENT_STOP ) | ( 1 << SNDRV_TIMER_EVENT_CONTINUE ) | ( 1 << SNDRV_TIMER_EVENT_PAUSE ) | ( 1 << SNDRV_TIMER_EVENT_SUSPEND ) | ( 1 << SNDRV_TIMER_EVENT_RESUME ) | ( 1 << SNDRV_TIMER_EVENT_MSTART ) | ( 1 << SNDRV_TIMER_EVENT_MSTOP ) | ( 1 << SNDRV_TIMER_EVENT_MCONTINUE ) | ( 1 << SNDRV_TIMER_EVENT_MPAUSE ) | ( 1 << SNDRV_TIMER_EVENT_MSUSPEND ) | ( 1 << SNDRV_TIMER_EVENT_MRESUME ) ) ) { err = - EINVAL ; goto _end ; } snd_timer_stop ( tu -> timeri ) ; spin_lock_irq ( & t -> lock ) ; tu -> timeri -> flags &= ~ ( SNDRV_TIMER_IFLG_AUTO | SNDRV_TIMER_IFLG_EXCLUSIVE | SNDRV_TIMER_IFLG_EARLY_EVENT ) ; if ( params . flags & SNDRV_TIMER_PSFLG_AUTO ) tu -> timeri -> flags |= SNDRV_TIMER_IFLG_AUTO ; if ( params . flags & SNDRV_TIMER_PSFLG_EXCLUSIVE ) tu -> timeri -> flags |= SNDRV_TIMER_IFLG_EXCLUSIVE ; if ( params . flags & SNDRV_TIMER_PSFLG_EARLY_EVENT ) tu -> timeri -> flags |= SNDRV_TIMER_IFLG_EARLY_EVENT ; spin_unlock_irq ( & t -> lock ) ; if ( params . queue_size > 0 && ( unsigned int ) tu -> queue_size != params . queue_size ) { if ( tu -> tread ) { ttr = kmalloc ( params . queue_size * sizeof ( * ttr ) , GFP_KERNEL ) ; if ( ttr ) { kfree ( tu -> tqueue ) ; tu -> queue_size = params . queue_size ; tu -> tqueue = ttr ; } } else { tr = kmalloc ( params . queue_size * sizeof ( * tr ) , GFP_KERNEL ) ; if ( tr ) { kfree ( tu -> queue ) ; tu -> queue_size = params . queue_size ; tu -> queue = tr ; } } } tu -> qhead = tu -> qtail = tu -> qused = 0 ; if ( tu -> timeri -> flags & SNDRV_TIMER_IFLG_EARLY_EVENT ) { if ( tu -> tread ) { struct snd_timer_tread tread ; tread . event = SNDRV_TIMER_EVENT_EARLY ; tread . tstamp . tv_sec = 0 ; tread . tstamp . tv_nsec = 0 ; tread . val = 0 ; snd_timer_user_append_to_tqueue ( tu , & tread ) ; } else { struct snd_timer_read * r = & tu -> queue [ 0 ] ; r -> resolution = 0 ; r -> ticks = 0 ; tu -> qused ++ ; tu -> qtail ++ ; } } tu -> filter = params . filter ; tu -> ticks = params . ticks ; err = 0 ; _end : if ( copy_to_user ( _params , & params , sizeof ( params ) ) ) return - EFAULT ; return err ; } "," snd_timer_tread tread ; memset ( & tread , 0 , sizeof ( tread ) ) ; ",torvalds@linux/cec8f96e49d9be372fdb0c3836dcf31ec71e457e,CVE-2016-4569,https://github.com/torvalds/linux/commit/cec8f96e49d9be372fdb0c3836dcf31ec71e457e,2016-05-23T10:59Z 586,CWE-362,"CWE-362 int sctp_rcv ( struct sk_buff * skb ) { struct sock * sk ; struct sctp_association * asoc ; struct sctp_endpoint * ep = NULL ; struct sctp_ep_common * rcvr ; struct sctp_transport * transport = NULL ; struct sctp_chunk * chunk ; struct sctphdr * sh ; union sctp_addr src ; union sctp_addr dest ; int family ; struct sctp_af * af ; if ( skb -> pkt_type != PACKET_HOST ) goto discard_it ; SCTP_INC_STATS_BH ( SCTP_MIB_INSCTPPACKS ) ; if ( skb_linearize ( skb ) ) goto discard_it ; sh = sctp_hdr ( skb ) ; __skb_pull ( skb , skb_transport_offset ( skb ) ) ; if ( skb -> len < sizeof ( struct sctphdr ) ) goto discard_it ; if ( ! skb_csum_unnecessary ( skb ) && sctp_rcv_checksum ( skb ) < 0 ) goto discard_it ; skb_pull ( skb , sizeof ( struct sctphdr ) ) ; if ( skb -> len < sizeof ( struct sctp_chunkhdr ) ) goto discard_it ; family = ipver2af ( ip_hdr ( skb ) -> version ) ; af = sctp_get_af_specific ( family ) ; if ( unlikely ( ! af ) ) goto discard_it ; af -> from_skb ( & src , skb , 1 ) ; af -> from_skb ( & dest , skb , 0 ) ; if ( ! af -> addr_valid ( & src , NULL , skb ) || ! af -> addr_valid ( & dest , NULL , skb ) ) goto discard_it ; asoc = __sctp_rcv_lookup ( skb , & src , & dest , & transport ) ; if ( ! asoc ) ep = __sctp_rcv_lookup_endpoint ( & dest ) ; rcvr = asoc ? & asoc -> base : & ep -> base ; sk = rcvr -> sk ; if ( sk -> sk_bound_dev_if && ( sk -> sk_bound_dev_if != af -> skb_iif ( skb ) ) ) { if ( asoc ) { sctp_association_put ( asoc ) ; asoc = NULL ; } else { sctp_endpoint_put ( ep ) ; ep = NULL ; } sk = sctp_get_ctl_sock ( ) ; ep = sctp_sk ( sk ) -> ep ; sctp_endpoint_hold ( ep ) ; rcvr = & ep -> base ; } if ( ! asoc ) { if ( sctp_rcv_ootb ( skb ) ) { SCTP_INC_STATS_BH ( SCTP_MIB_OUTOFBLUES ) ; goto discard_release ; } } if ( ! xfrm_policy_check ( sk , XFRM_POLICY_IN , skb , family ) ) goto discard_release ; nf_reset ( skb ) ; if ( sk_filter ( sk , skb ) ) goto discard_release ; chunk = sctp_chunkify ( skb , asoc , sk ) ; if ( ! chunk ) goto discard_release ; SCTP_INPUT_CB ( skb ) -> chunk = chunk ; chunk -> rcvr = rcvr ; chunk -> sctp_hdr = sh ; sctp_init_addrs ( chunk , & src , & dest ) ; chunk -> transport = transport ; sctp_bh_lock_sock ( sk ) ; if ( sock_owned_by_user ( sk ) ) { SCTP_INC_STATS_BH ( SCTP_MIB_IN_PKT_BACKLOG ) ; sctp_add_backlog ( sk , skb ) ; } else { SCTP_INC_STATS_BH ( SCTP_MIB_IN_PKT_SOFTIRQ ) ; sctp_inq_push ( & chunk -> rcvr -> inqueue , chunk ) ; } sctp_bh_unlock_sock ( sk ) ; if ( asoc ) sctp_association_put ( asoc ) ; else sctp_endpoint_put ( ep ) ; return 0 ; discard_it : SCTP_INC_STATS_BH ( SCTP_MIB_IN_PKT_DISCARDS ) ; kfree_skb ( skb ) ; return 0 ; discard_release : if ( asoc ) sctp_association_put ( asoc ) ; else sctp_endpoint_put ( ep ) ; goto discard_it ; } "," ; if ( sk != rcvr -> sk ) { sctp_bh_unlock_sock ( sk ) ; sk = rcvr -> sk ; sctp_bh_lock_sock ( sk ) ; } if ( ",torvalds@linux/ae53b5bd77719fed58086c5be60ce4f22bffe1c6,CVE-2011-4348,https://github.com/torvalds/linux/commit/ae53b5bd77719fed58086c5be60ce4f22bffe1c6,2013-06-08T13:05Z 587,CWE-125,"CWE-125 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 ] ) ) ) ; 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 ( EXTRACT_32BITS ( tptr + BGP_VPN_RD_LEN ) == 0x47000601 ) ND_PRINT ( ( ndo , ""=%s"" , ipaddr_string ( ndo , tptr + BGP_VPN_RD_LEN + 4 ) ) ) ; else if ( 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 ( len - ( tptr - pptr ) > 0 ) { 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 ( len - ( tptr - pptr ) > 0 ) { 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 ; tunnel_type = * ( tptr + 1 ) ; flags = * tptr ; tlen = len ; ND_TCHECK2 ( tptr [ 0 ] , 5 ) ; 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 ; ND_TCHECK2 ( tptr [ 0 ] , 3 ) ; tlen = len ; while ( tlen >= 3 ) { type = * tptr ; length = EXTRACT_16BITS ( tptr + 1 ) ; ND_PRINT ( ( ndo , ""\\n\\t%sTLV(%u),length%u"" , tok2str ( bgp_aigp_values , ""Unknown"" , type ) , type , length ) ) ; ND_TCHECK2 ( tptr [ 3 ] , length - 3 ) ; switch ( type ) { case BGP_AIGP_TLV : ND_TCHECK2 ( tptr [ 3 ] , 8 ) ; ND_PRINT ( ( ndo , "",metric%"" PRIu64 , EXTRACT_64BITS ( tptr + 3 ) ) ) ; break ; default : if ( ndo -> ndo_vflag <= 1 ) { print_unknown_data ( ndo , tptr + 3 , ""\\n\\t"" , length - 3 ) ; } } 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 ; } "," ] ) ) ) ; ND_TCHECK ( tptr [ 1 ] ",the-tcpdump-group@tcpdump/50a44b6b8e4f7c127440dbd4239cf571945cc1e7,CVE-2017-12991,https://github.com/the-tcpdump-group/tcpdump/commit/50a44b6b8e4f7c127440dbd4239cf571945cc1e7,2017-09-14T06:29Z 588,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 589,CWE-000,"CWE-000 char * guestfs___first_line_of_file ( guestfs_h * g , const char * filename ) { CLEANUP_FREE char * * lines = NULL ; int64_t size ; char * ret ; size = guestfs_filesize ( g , filename ) ; if ( size == - 1 ) return NULL ; if ( size > MAX_SMALL_FILE_SIZE ) { error ( g , _ ( ""sizeof%sisunreasonablylarge(%"" PRIi64 ""bytes)"" ) , filename , size ) ; return NULL ; } lines = guestfs_head_n ( g , 1 , filename ) ; if ( lines == NULL ) return NULL ; if ( lines [ 0 ] == NULL ) { guestfs___free_string_list ( lines ) ; return safe_strdup ( g , """" ) ; } ret = lines [ 0 ] ; return ret ; } "," filename ) { char * * 0 ] ; free ( lines ) ; ",libguestfs@libguestfs/fa6a76050d82894365dfe32916903ef7fee3ffcd,CVE-2013-2124,https://github.com/libguestfs/libguestfs/commit/fa6a76050d82894365dfe32916903ef7fee3ffcd,2014-05-27T14:55Z 590,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 591,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 592,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 593,CWE-362,"CWE-362 int get_evtchn_to_irq ( evtchn_port_t evtchn ) { if ( evtchn >= xen_evtchn_max_channels ( ) ) return - 1 ; if ( evtchn_to_irq [ EVTCHN_ROW ( evtchn ) ] == NULL ) return - 1 ; return evtchn_to_irq [ EVTCHN_ROW ( evtchn ) ] [ EVTCHN_COL ( evtchn ) ] ; } "," 1 ; return READ_ONCE ( evtchn ) ] ) ",torvalds@linux/073d0552ead5bfc7a3a9c01de590e924f11b5dd2,CVE-2020-27675,https://github.com/torvalds/linux/commit/073d0552ead5bfc7a3a9c01de590e924f11b5dd2,2020-10-22T21:15Z 594,CWE-119,"CWE-119 static int do_16x16_motion_search ( VP9_COMP * cpi , const int_mv * ref_mv , int_mv * dst_mv , int mb_row , int mb_col ) { MACROBLOCK * const x = & cpi -> mb ; MACROBLOCKD * const xd = & x -> e_mbd ; unsigned int err , tmp_err ; int_mv tmp_mv ; err = vp9_sad16x16 ( x -> plane [ 0 ] . src . buf , x -> plane [ 0 ] . src . stride , xd -> plane [ 0 ] . pre [ 0 ] . buf , xd -> plane [ 0 ] . pre [ 0 ] . stride , INT_MAX ) ; dst_mv -> as_int = 0 ; tmp_err = do_16x16_motion_iteration ( cpi , & ref_mv -> as_mv , & tmp_mv . as_mv , mb_row , mb_col ) ; if ( tmp_err < err ) { err = tmp_err ; dst_mv -> as_int = tmp_mv . as_int ; } if ( ref_mv -> as_int ) { unsigned int tmp_err ; int_mv zero_ref_mv , tmp_mv ; zero_ref_mv . as_int = 0 ; tmp_err = do_16x16_motion_iteration ( cpi , & zero_ref_mv . as_mv , & tmp_mv . as_mv , mb_row , mb_col ) ; if ( tmp_err < err ) { dst_mv -> as_int = tmp_mv . as_int ; err = tmp_err ; } } return err ; } "," cpi , const MV * ref_mv , int_mv * dst_mv , int & cpi -> td . , tmp_err ; MV tmp_mv ; err = vpx_sad16x16 ( x -> ] . stride ) ; dst_mv ( cpi , ref_mv , & tmp_mv , mb_row , mb_col ) ; if ( tmp_err < err ) { err = tmp_err ; dst_mv -> as_mv = tmp_mv ; } if ( ref_mv -> row != 0 || ref_mv -> col != 0 ) { unsigned int tmp_err ; MV zero_ref_mv = { 0 , 0 } , tmp_mv ; tmp_err = do_16x16_motion_iteration ( cpi , & zero_ref_mv , & tmp_mv , mb_row , mb_col ) ; if ( tmp_err < err ) { dst_mv -> as_mv = tmp_mv ; err = ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 595,CWE-20,"CWE-20 error_t tcpSendResetSegment ( NetInterface * interface , IpPseudoHeader * pseudoHeader , TcpHeader * segment , size_t length ) { error_t error ; size_t offset ; uint8_t flags ; uint32_t seqNum ; uint32_t ackNum ; NetBuffer * buffer ; TcpHeader * segment2 ; IpPseudoHeader pseudoHeader2 ; NetTxAncillary ancillary ; if ( segment -> flags & TCP_FLAG_ACK ) { flags = TCP_FLAG_RST ; seqNum = segment -> ackNum ; ackNum = 0 ; } else { flags = TCP_FLAG_RST | TCP_FLAG_ACK ; seqNum = 0 ; ackNum = segment -> seqNum + length ; if ( segment -> flags & TCP_FLAG_SYN ) ackNum ++ ; if ( segment -> flags & TCP_FLAG_FIN ) ackNum ++ ; } buffer = ipAllocBuffer ( sizeof ( TcpHeader ) , & offset ) ; if ( buffer == NULL ) return ERROR_OUT_OF_MEMORY ; segment2 = netBufferAt ( buffer , offset ) ; segment2 -> srcPort = htons ( segment -> destPort ) ; segment2 -> destPort = htons ( segment -> srcPort ) ; segment2 -> seqNum = htonl ( seqNum ) ; segment2 -> ackNum = htonl ( ackNum ) ; segment2 -> reserved1 = 0 ; segment2 -> dataOffset = 5 ; segment2 -> flags = flags ; segment2 -> reserved2 = 0 ; segment2 -> window = 0 ; segment2 -> checksum = 0 ; segment2 -> urgentPointer = 0 ; # if ( IPV4_SUPPORT == ENABLED ) if ( pseudoHeader -> length == sizeof ( Ipv4PseudoHeader ) ) { pseudoHeader2 . length = sizeof ( Ipv4PseudoHeader ) ; pseudoHeader2 . ipv4Data . srcAddr = pseudoHeader -> ipv4Data . destAddr ; pseudoHeader2 . ipv4Data . destAddr = pseudoHeader -> ipv4Data . srcAddr ; pseudoHeader2 . ipv4Data . reserved = 0 ; pseudoHeader2 . ipv4Data . protocol = IPV4_PROTOCOL_TCP ; pseudoHeader2 . ipv4Data . length = HTONS ( sizeof ( TcpHeader ) ) ; segment2 -> checksum = ipCalcUpperLayerChecksumEx ( & pseudoHeader2 . ipv4Data , sizeof ( Ipv4PseudoHeader ) , buffer , offset , sizeof ( TcpHeader ) ) ; } else # endif # if ( IPV6_SUPPORT == ENABLED ) if ( pseudoHeader -> length == sizeof ( Ipv6PseudoHeader ) ) { pseudoHeader2 . length = sizeof ( Ipv6PseudoHeader ) ; pseudoHeader2 . ipv6Data . srcAddr = pseudoHeader -> ipv6Data . destAddr ; pseudoHeader2 . ipv6Data . destAddr = pseudoHeader -> ipv6Data . srcAddr ; pseudoHeader2 . ipv6Data . length = HTONL ( sizeof ( TcpHeader ) ) ; pseudoHeader2 . ipv6Data . reserved [ 0 ] = 0 ; pseudoHeader2 . ipv6Data . reserved [ 1 ] = 0 ; pseudoHeader2 . ipv6Data . reserved [ 2 ] = 0 ; pseudoHeader2 . ipv6Data . nextHeader = IPV6_TCP_HEADER ; segment2 -> checksum = ipCalcUpperLayerChecksumEx ( & pseudoHeader2 . ipv6Data , sizeof ( Ipv6PseudoHeader ) , buffer , offset , sizeof ( TcpHeader ) ) ; } else # endif { netBufferFree ( buffer ) ; return ERROR_INVALID_ADDRESS ; } MIB2_INC_COUNTER32 ( tcpGroup . tcpOutSegs , 1 ) ; TCP_MIB_INC_COUNTER32 ( tcpOutSegs , 1 ) ; TCP_MIB_INC_COUNTER64 ( tcpHCOutSegs , 1 ) ; MIB2_INC_COUNTER32 ( tcpGroup . tcpOutRsts , 1 ) ; TCP_MIB_INC_COUNTER32 ( tcpOutRsts , 1 ) ; TRACE_DEBUG ( ""%s:SendingTCPresetsegment...\\r\\n"" , formatSystemTime ( osGetSystemTime ( ) , NULL ) ) ; tcpDumpHeader ( segment2 , length , 0 , 0 ) ; ancillary = NET_DEFAULT_TX_ANCILLARY ; error = ipSendDatagram ( interface , & pseudoHeader2 , buffer , offset , & ancillary ) ; netBufferFree ( buffer ) ; return error ; } "," & TCP_FLAG_SYN ) { ackNum ++ ; } & TCP_FLAG_FIN ) { ackNum ++ ; } ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 596,CWE-362,"CWE-362 static long snd_timer_user_ioctl ( struct file * file , unsigned int cmd , unsigned long arg ) { struct snd_timer_user * tu ; void __user * argp = ( void __user * ) arg ; int __user * p = argp ; tu = file -> private_data ; switch ( cmd ) { case SNDRV_TIMER_IOCTL_PVERSION : return put_user ( SNDRV_TIMER_VERSION , p ) ? - EFAULT : 0 ; case SNDRV_TIMER_IOCTL_NEXT_DEVICE : return snd_timer_user_next_device ( argp ) ; case SNDRV_TIMER_IOCTL_TREAD : { int xarg ; mutex_lock ( & tu -> tread_sem ) ; if ( tu -> timeri ) { mutex_unlock ( & tu -> tread_sem ) ; return - EBUSY ; } if ( get_user ( xarg , p ) ) { mutex_unlock ( & tu -> tread_sem ) ; return - EFAULT ; } tu -> tread = xarg ? 1 : 0 ; mutex_unlock ( & tu -> tread_sem ) ; return 0 ; } case SNDRV_TIMER_IOCTL_GINFO : return snd_timer_user_ginfo ( file , argp ) ; case SNDRV_TIMER_IOCTL_GPARAMS : return snd_timer_user_gparams ( file , argp ) ; case SNDRV_TIMER_IOCTL_GSTATUS : return snd_timer_user_gstatus ( file , argp ) ; case SNDRV_TIMER_IOCTL_SELECT : return snd_timer_user_tselect ( file , argp ) ; case SNDRV_TIMER_IOCTL_INFO : return snd_timer_user_info ( file , argp ) ; case SNDRV_TIMER_IOCTL_PARAMS : return snd_timer_user_params ( file , argp ) ; case SNDRV_TIMER_IOCTL_STATUS : return snd_timer_user_status ( file , argp ) ; case SNDRV_TIMER_IOCTL_START : case SNDRV_TIMER_IOCTL_START_OLD : return snd_timer_user_start ( file ) ; case SNDRV_TIMER_IOCTL_STOP : case SNDRV_TIMER_IOCTL_STOP_OLD : return snd_timer_user_stop ( file ) ; case SNDRV_TIMER_IOCTL_CONTINUE : case SNDRV_TIMER_IOCTL_CONTINUE_OLD : return snd_timer_user_continue ( file ) ; case SNDRV_TIMER_IOCTL_PAUSE : case SNDRV_TIMER_IOCTL_PAUSE_OLD : return snd_timer_user_pause ( file ) ; } return - ENOTTY ; } "," snd_timer_user * tu = file -> -> private_data ; long ret ; mutex_lock ( & tu -> ioctl_lock ) ; ret = __snd_timer_user_ioctl ( file , cmd , arg ) ; mutex_unlock ( & tu -> ioctl_lock ) ; return ) ; return ret ; } ",torvalds@linux/af368027a49a751d6ff4ee9e3f9961f35bb4fede,CVE-2016-2546,https://github.com/torvalds/linux/commit/af368027a49a751d6ff4ee9e3f9961f35bb4fede,2016-04-27T17:59Z 597,CWE-119,"CWE-119 void monitor_apply_keystate ( struct monitor * pmonitor ) { struct ssh * ssh = active_state ; struct kex * kex ; int r ; debug3 ( ""%s:packet_set_state"" , __func__ ) ; if ( ( r = ssh_packet_set_state ( ssh , child_state ) ) != 0 ) fatal ( ""%s:packet_set_state:%s"" , __func__ , ssh_err ( r ) ) ; sshbuf_free ( child_state ) ; child_state = NULL ; if ( ( kex = ssh -> kex ) != NULL ) { # ifdef WITH_OPENSSL kex -> kex [ KEX_DH_GRP1_SHA1 ] = kexdh_server ; kex -> kex [ KEX_DH_GRP14_SHA1 ] = kexdh_server ; kex -> kex [ KEX_DH_GRP14_SHA256 ] = kexdh_server ; kex -> kex [ KEX_DH_GRP16_SHA512 ] = kexdh_server ; kex -> kex [ KEX_DH_GRP18_SHA512 ] = kexdh_server ; kex -> kex [ KEX_DH_GEX_SHA1 ] = kexgex_server ; kex -> kex [ KEX_DH_GEX_SHA256 ] = kexgex_server ; kex -> kex [ KEX_ECDH_SHA2 ] = kexecdh_server ; # endif kex -> kex [ KEX_C25519_SHA256 ] = kexc25519_server ; kex -> load_host_public_key = & get_hostkey_public_by_type ; kex -> load_host_private_key = & get_hostkey_private_by_type ; kex -> host_key_index = & get_hostkey_index ; kex -> sign = sshd_hostkey_sign ; } if ( options . compression ) { ssh_packet_set_compress_hooks ( ssh , pmonitor -> m_zlib , ( ssh_packet_comp_alloc_func * ) mm_zalloc , ( ssh_packet_comp_free_func * ) mm_zfree ) ; } } "," sshd_hostkey_sign ; } } ",openbsd@src/3095060f479b86288e31c79ecbc5131a66bcd2f9,CVE-2016-10012,https://github.com/openbsd/src/commit/3095060f479b86288e31c79ecbc5131a66bcd2f9,2017-01-05T02:59Z 598,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 599,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 600,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 601,CWE-476,"CWE-476 static int nfc_genl_deactivate_target ( struct sk_buff * skb , struct genl_info * info ) { struct nfc_dev * dev ; u32 device_idx , target_idx ; int rc ; if ( ! info -> attrs [ NFC_ATTR_DEVICE_INDEX ] ) return - EINVAL ; device_idx = nla_get_u32 ( info -> attrs [ NFC_ATTR_DEVICE_INDEX ] ) ; dev = nfc_get_device ( device_idx ) ; if ( ! dev ) return - ENODEV ; target_idx = nla_get_u32 ( info -> attrs [ NFC_ATTR_TARGET_INDEX ] ) ; rc = nfc_deactivate_target ( dev , target_idx , NFC_TARGET_MODE_SLEEP ) ; nfc_put_device ( dev ) ; return rc ; } "," attrs [ NFC_ATTR_DEVICE_INDEX ] || ! info -> attrs [ NFC_ATTR_TARGET_INDEX ",torvalds@linux/385097a3675749cbc9e97c085c0e5dfe4269ca51,CVE-2019-12984,https://github.com/torvalds/linux/commit/385097a3675749cbc9e97c085c0e5dfe4269ca51,2019-06-26T18:15Z 602,CWE-362,"CWE-362 static void sctp_generate_timeout_event ( struct sctp_association * asoc , sctp_event_timeout_t timeout_type ) { struct net * net = sock_net ( asoc -> base . sk ) ; int error = 0 ; bh_lock_sock ( asoc -> base . sk ) ; if ( sock_owned_by_user ( asoc -> base . sk ) ) { pr_debug ( ""%s:sockisbusy:timer%d\\n"" , __func__ , timeout_type ) ; if ( ! mod_timer ( & asoc -> timers [ timeout_type ] , jiffies + ( HZ / 20 ) ) ) sctp_association_hold ( asoc ) ; goto out_unlock ; } if ( asoc -> base . dead ) goto out_unlock ; error = sctp_do_sm ( net , SCTP_EVENT_T_TIMEOUT , SCTP_ST_TIMEOUT ( timeout_type ) , asoc -> state , asoc -> ep , asoc , ( void * ) timeout_type , GFP_ATOMIC ) ; if ( error ) asoc -> base . sk -> sk_err = - error ; out_unlock : bh_unlock_sock ( asoc -> base . sk ) ; sctp_association_put ( 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 603,CWE-190,"CWE-190 void * xmalloc ( size_t size ) { void * ptr = malloc ( size ) ; if ( ! ptr && ( size != 0 ) ) { perror ( ""xmalloc:Memoryallocationfailure"" ) ; abort ( ) ; } return ptr ; } "," xmalloc ( size_t num , size_t size ) { size_t res ; if ( check_mul_overflow ( num , size , & res ) ) abort ( ) ; = malloc ( res ) ; if ",verdammelt@tnef/c5044689e50039635e7700fe2472fd632ac77176,CVE-2017-6308,https://github.com/verdammelt/tnef/commit/c5044689e50039635e7700fe2472fd632ac77176,2017-02-24T04:59Z 604,CWE-119,"CWE-119 void lzxd_free ( struct lzxd_stream * lzx ) { struct mspack_system * sys ; if ( lzx ) { sys = lzx -> sys ; sys -> free ( lzx -> inbuf ) ; sys -> free ( lzx -> window ) ; sys -> free ( lzx ) ; } } "," -> sys ; if ( lzx -> inbuf ) inbuf ) ; if ( lzx -> window ) ",vrtadmin@clamav-devel/a83773682e856ad6529ba6db8d1792e6d515d7f1,CVE-2017-6419,https://github.com/vrtadmin/clamav-devel/commit/a83773682e856ad6529ba6db8d1792e6d515d7f1,2017-08-07T03:29Z 605,CWE-400,"CWE-400 struct sk_buff * * udp_gro_receive ( struct sk_buff * * head , struct sk_buff * skb , struct udphdr * uh ) { struct udp_offload_priv * uo_priv ; struct sk_buff * p , * * pp = NULL ; struct udphdr * uh2 ; unsigned int off = skb_gro_offset ( skb ) ; int flush = 1 ; if ( NAPI_GRO_CB ( skb ) -> udp_mark || ( skb -> ip_summed != CHECKSUM_PARTIAL && NAPI_GRO_CB ( skb ) -> csum_cnt == 0 && ! NAPI_GRO_CB ( skb ) -> csum_valid ) ) goto out ; NAPI_GRO_CB ( skb ) -> udp_mark = 1 ; rcu_read_lock ( ) ; uo_priv = rcu_dereference ( udp_offload_base ) ; for ( ; uo_priv != NULL ; uo_priv = rcu_dereference ( uo_priv -> next ) ) { if ( net_eq ( read_pnet ( & uo_priv -> net ) , dev_net ( skb -> dev ) ) && uo_priv -> offload -> port == uh -> dest && uo_priv -> offload -> callbacks . gro_receive ) goto unflush ; } goto out_unlock ; unflush : flush = 0 ; for ( p = * head ; p ; p = p -> next ) { if ( ! NAPI_GRO_CB ( p ) -> same_flow ) continue ; uh2 = ( struct udphdr * ) ( p -> data + off ) ; if ( ( * ( u32 * ) & uh -> source != * ( u32 * ) & uh2 -> source ) || ( ! uh -> check ^ ! uh2 -> check ) ) { NAPI_GRO_CB ( p ) -> same_flow = 0 ; continue ; } } skb_gro_pull ( skb , sizeof ( struct udphdr ) ) ; skb_gro_postpull_rcsum ( skb , uh , sizeof ( struct udphdr ) ) ; NAPI_GRO_CB ( skb ) -> proto = uo_priv -> offload -> ipproto ; pp = uo_priv -> offload -> callbacks . gro_receive ( head , skb , uo_priv -> offload ) ; out_unlock : rcu_read_unlock ( ) ; out : NAPI_GRO_CB ( skb ) -> flush |= flush ; return pp ; } "," skb ) -> encap_mark || ( skb skb ) -> encap_mark = 1 ; ",torvalds@linux/fac8e0f579695a3ecbc4d3cac369139d7f819971,CVE-2016-8666,https://github.com/torvalds/linux/commit/fac8e0f579695a3ecbc4d3cac369139d7f819971,2016-10-16T21:59Z 606,CWE-119,"CWE-119 static int64_t rd_pick_intra_sbuv_mode ( VP9_COMP * cpi , MACROBLOCK * x , PICK_MODE_CONTEXT * ctx , int * rate , int * rate_tokenonly , int64_t * distortion , int * skippable , BLOCK_SIZE bsize , TX_SIZE max_tx_size ) { MACROBLOCKD * xd = & x -> e_mbd ; MB_PREDICTION_MODE mode ; MB_PREDICTION_MODE mode_selected = DC_PRED ; int64_t best_rd = INT64_MAX , this_rd ; int this_rate_tokenonly , this_rate , s ; int64_t this_distortion , this_sse ; for ( mode = DC_PRED ; mode <= TM_PRED ; ++ mode ) { if ( ! ( cpi -> sf . intra_uv_mode_mask [ max_tx_size ] & ( 1 << mode ) ) ) continue ; xd -> mi [ 0 ] -> mbmi . uv_mode = mode ; super_block_uvrd ( cpi , x , & this_rate_tokenonly , & this_distortion , & s , & this_sse , bsize , best_rd ) ; if ( this_rate_tokenonly == INT_MAX ) continue ; this_rate = this_rate_tokenonly + x -> intra_uv_mode_cost [ cpi -> common . frame_type ] [ mode ] ; this_rd = RDCOST ( x -> rdmult , x -> rddiv , this_rate , this_distortion ) ; if ( this_rd < best_rd ) { mode_selected = mode ; best_rd = this_rd ; * rate = this_rate ; * rate_tokenonly = this_rate_tokenonly ; * distortion = this_distortion ; * skippable = s ; if ( ! x -> select_txfm_size ) { int i ; struct macroblock_plane * const p = x -> plane ; struct macroblockd_plane * const pd = xd -> plane ; for ( i = 1 ; i < MAX_MB_PLANE ; ++ i ) { p [ i ] . coeff = ctx -> coeff_pbuf [ i ] [ 2 ] ; p [ i ] . qcoeff = ctx -> qcoeff_pbuf [ i ] [ 2 ] ; pd [ i ] . dqcoeff = ctx -> dqcoeff_pbuf [ i ] [ 2 ] ; p [ i ] . eobs = ctx -> eobs_pbuf [ i ] [ 2 ] ; ctx -> coeff_pbuf [ i ] [ 2 ] = ctx -> coeff_pbuf [ i ] [ 0 ] ; ctx -> qcoeff_pbuf [ i ] [ 2 ] = ctx -> qcoeff_pbuf [ i ] [ 0 ] ; ctx -> dqcoeff_pbuf [ i ] [ 2 ] = ctx -> dqcoeff_pbuf [ i ] [ 0 ] ; ctx -> eobs_pbuf [ i ] [ 2 ] = ctx -> eobs_pbuf [ i ] [ 0 ] ; ctx -> coeff_pbuf [ i ] [ 0 ] = p [ i ] . coeff ; ctx -> qcoeff_pbuf [ i ] [ 0 ] = p [ i ] . qcoeff ; ctx -> dqcoeff_pbuf [ i ] [ 0 ] = pd [ i ] . dqcoeff ; ctx -> eobs_pbuf [ i ] [ 0 ] = p [ i ] . eobs ; } } } } xd -> mi [ 0 ] -> mbmi . uv_mode = mode_selected ; return best_rd ; } "," -> e_mbd ; PREDICTION_MODE mode ; PREDICTION_MODE mode_selected = DC_PRED this_distortion , this_sse ; memset ( x -> skip_txfm , SKIP_TXFM_NONE , sizeof ( x -> skip_txfm ) ) = mode ; if ( ! , best_rd ) ) continue ; = this_rate_tokenonly + cpi -> intra_uv_mode_cost [ ! x -> select_tx_size ) swap_block_ptr ( x , ctx , 2 , 0 , 1 , MAX_MB_PLANE ) ; } } xd ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 607,CWE-125,"CWE-125 int obj2ast_keyword ( PyObject * obj , keyword_ty * out , PyArena * arena ) { PyObject * tmp = NULL ; identifier arg ; expr_ty value ; if ( exists_not_none ( obj , & PyId_arg ) ) { int res ; tmp = _PyObject_GetAttrId ( obj , & PyId_arg ) ; if ( tmp == NULL ) goto failed ; res = obj2ast_identifier ( tmp , & arg , arena ) ; if ( res != 0 ) goto failed ; Py_CLEAR ( tmp ) ; } else { arg = NULL ; } 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\\""missingfromkeyword"" ) ; return 1 ; } * out = keyword ( arg , value , arena ) ; return 0 ; failed : Py_XDECREF ( tmp ) ; return 1 ; } "," ; if ( lookup_attr_id ( obj , , & PyId_arg , & tmp ) < 0 ) { return 1 ; } if ( tmp == NULL || tmp == Py_None ) { Py_CLEAR ( tmp ) ; arg = NULL ; } else { int res int res ; res = obj2ast_identifier ( tmp , & arg , arena ) ; if ( res != 0 ) goto failed goto failed ; Py_CLEAR ( tmp ) ; } if ( lookup_attr_id ( obj , & PyId_value , & tmp ) < 0 ) { return 1 ; } if ( tmp == NULL ) { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""value\\""missingfromkeyword"" ) ; return 1 ; } else { int res ; res = obj2ast_expr ( tmp , & value , arena ) ) ; } * out = ",python@typed_ast/156afcb26c198e162504a57caddfe0acd9ed7dce,CVE-2019-19275,https://github.com/python/typed_ast/commit/156afcb26c198e162504a57caddfe0acd9ed7dce,2019-11-26T15:15Z 608,CWE-416,"CWE-416 static void sunkbd_enable ( struct sunkbd * sunkbd , bool enable ) { serio_pause_rx ( sunkbd -> serio ) ; sunkbd -> enabled = enable ; serio_continue_rx ( sunkbd -> serio ) ; } "," serio ) ; if ( ! enable ) { wake_up_interruptible ( & sunkbd -> wait ) ; cancel_work_sync ( & sunkbd -> tq ) ; } ",torvalds@linux/77e70d351db7de07a46ac49b87a6c3c7a60fca7e,CVE-2020-25669,https://github.com/torvalds/linux/commit/77e70d351db7de07a46ac49b87a6c3c7a60fca7e,2021-05-26T12:15Z 609,CWE-20,"CWE-20 static int read_fragment_table ( long long * directory_table_end ) { int res , i ; int bytes = SQUASHFS_FRAGMENT_BYTES ( sBlk . s . fragments ) ; int indexes = SQUASHFS_FRAGMENT_INDEXES ( sBlk . s . fragments ) ; long long fragment_table_index [ indexes ] ; TRACE ( ""read_fragment_table:%dfragments,reading%dfragmentindexes"" ""from0x%llx\\n"" , sBlk . s . fragments , indexes , sBlk . s . fragment_table_start ) ; if ( sBlk . s . fragments == 0 ) { * directory_table_end = sBlk . s . fragment_table_start ; return TRUE ; } fragment_table = malloc ( bytes ) ; if ( fragment_table == NULL ) EXIT_UNSQUASH ( ""read_fragment_table:failedtoallocate"" ""fragmenttable\\n"" ) ; res = read_fs_bytes ( fd , sBlk . s . fragment_table_start , SQUASHFS_FRAGMENT_INDEX_BYTES ( sBlk . s . fragments ) , fragment_table_index ) ; if ( res == FALSE ) { ERROR ( ""read_fragment_table:failedtoreadfragmenttable"" ""index\\n"" ) ; return FALSE ; } SQUASHFS_INSWAP_FRAGMENT_INDEXES ( fragment_table_index , indexes ) ; for ( i = 0 ; i < indexes ; i ++ ) { int expected = ( i + 1 ) != indexes ? SQUASHFS_METADATA_SIZE : bytes & ( SQUASHFS_METADATA_SIZE - 1 ) ; int length = read_block ( fd , fragment_table_index [ i ] , NULL , expected , ( ( char * ) fragment_table ) + ( i * SQUASHFS_METADATA_SIZE ) ) ; TRACE ( ""Readfragmenttableblock%d,from0x%llx,length%d\\n"" , i , fragment_table_index [ i ] , length ) ; if ( length == FALSE ) { ERROR ( ""read_fragment_table:failedtoreadfragment"" ""tableindex\\n"" ) ; return FALSE ; } } for ( i = 0 ; i < sBlk . s . fragments ; i ++ ) SQUASHFS_INSWAP_FRAGMENT_ENTRY ( & fragment_table [ i ] ) ; * directory_table_end = fragment_table_index [ 0 ] ; return TRUE ; } "," long long * table_start ) { int , i ; long long bytes = SQUASHFS_FRAGMENT_BYTES = SQUASHFS_FRAGMENT_BYTES ( ( long long ) = SQUASHFS_FRAGMENT_INDEXES ( ( long long ) sBlk . s . fragments ) ; int length = SQUASHFS_FRAGMENT_INDEX_BYTES ( ( long long ) sBlk . s . fragments ) ; long long * fragment_table_index ; if ( length != ( * table_start - sBlk . s . fragment_table_start ) ) { ERROR ( ""read_fragment_table:Badfragmentcountinsuperblock\\n"" ) ; return FALSE ; } TRACE ( ""read_fragment_table:%dfragments,reading%dfragmentindexes"" fragment_table_start ) ; fragment_table_index = alloc_index_table ( indexes ) ; fragment_table = malloc . fragment_table_start , length , fragment_table_index ) ) ; * table_start = fragment_table_index [ ",plougher@squashfs-tools/f95864afe8833fe3ad782d714b41378e860977b1,CVE-2015-4646,https://github.com/plougher/squashfs-tools/commit/f95864afe8833fe3ad782d714b41378e860977b1,2017-04-13T17:59Z 610,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 611,CWE-000,"CWE-000 static int efind ( name ) char * name ; { static char efbuf [ 100 ] ; my_regex_t re ; sprintf ( efbuf , ""REG_%s"" , name ) ; assert ( strlen ( efbuf ) < sizeof ( efbuf ) ) ; re . re_endp = efbuf ; ( void ) my_regerror ( REG_ATOI , & re , efbuf , sizeof ( efbuf ) ) ; return ( atoi ( efbuf ) ) ; } "," my_regex_t re ; snprintf ( efbuf , sizeof ( efbuf ) , ""REG_%s"" , ",mysql@mysql-server/0dbd5a8797ed4bd18e8b883988fb62177eb0f73f,CVE-2016-0546,https://github.com/mysql/mysql-server/commit/0dbd5a8797ed4bd18e8b883988fb62177eb0f73f,2016-01-21T03:01Z 612,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 613,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 614,CWE-399,"CWE-399 int udpv6_recvmsg ( struct sock * sk , struct msghdr * msg , size_t len , int noblock , int flags , int * addr_len ) { struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct inet_sock * inet = inet_sk ( sk ) ; struct sk_buff * skb ; unsigned int ulen , copied ; int peeked , off = 0 ; int err ; int is_udplite = IS_UDPLITE ( sk ) ; int is_udp4 ; bool slow ; if ( flags & MSG_ERRQUEUE ) return ipv6_recv_error ( sk , msg , len , addr_len ) ; if ( np -> rxpmtu && np -> rxopt . bits . rxpmtu ) return ipv6_recv_rxpmtu ( sk , msg , len , addr_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 ; is_udp4 = ( skb -> protocol == htons ( ETH_P_IP ) ) ; 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_msg ( skb , sizeof ( struct udphdr ) , msg , copied ) ; else { err = skb_copy_and_csum_datagram_msg ( skb , sizeof ( struct udphdr ) , msg ) ; if ( err == - EINVAL ) goto csum_copy_err ; } if ( unlikely ( err ) ) { trace_kfree_skb ( skb , udpv6_recvmsg ) ; if ( ! peeked ) { atomic_inc ( & sk -> sk_drops ) ; if ( is_udp4 ) UDP_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INERRORS , is_udplite ) ; else UDP6_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INERRORS , is_udplite ) ; } goto out_free ; } if ( ! peeked ) { if ( is_udp4 ) UDP_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INDATAGRAMS , is_udplite ) ; else UDP6_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INDATAGRAMS , is_udplite ) ; } sock_recv_ts_and_drops ( msg , sk , skb ) ; if ( msg -> msg_name ) { DECLARE_SOCKADDR ( struct sockaddr_in6 * , sin6 , msg -> msg_name ) ; sin6 -> sin6_family = AF_INET6 ; sin6 -> sin6_port = udp_hdr ( skb ) -> source ; sin6 -> sin6_flowinfo = 0 ; if ( is_udp4 ) { ipv6_addr_set_v4mapped ( ip_hdr ( skb ) -> saddr , & sin6 -> sin6_addr ) ; sin6 -> sin6_scope_id = 0 ; } else { sin6 -> sin6_addr = ipv6_hdr ( skb ) -> saddr ; sin6 -> sin6_scope_id = ipv6_iface_scope_id ( & sin6 -> sin6_addr , inet6_iif ( skb ) ) ; } * addr_len = sizeof ( * sin6 ) ; } if ( np -> rxopt . all ) ip6_datagram_recv_common_ctl ( sk , msg , skb ) ; if ( is_udp4 ) { if ( inet -> cmsg_flags ) ip_cmsg_recv ( msg , skb ) ; } else { if ( np -> rxopt . all ) ip6_datagram_recv_specific_ctl ( sk , 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 ) ) { if ( is_udp4 ) { UDP_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_CSUMERRORS , is_udplite ) ; UDP_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_INERRORS , is_udplite ) ; } else { UDP6_INC_STATS_USER ( sock_net ( sk ) , UDP_MIB_CSUMERRORS , is_udplite ) ; UDP6_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 ; } "," slow ) ; cond_resched ( ) ; msg -> ",torvalds@linux/beb39db59d14990e401e235faf66a6b9b31240b0,CVE-2015-5366,https://github.com/torvalds/linux/commit/beb39db59d14990e401e235faf66a6b9b31240b0,2015-08-31T10:59Z 615,CWE-119,"CWE-119 static __u8 * nci_extract_rf_params_nfcb_passive_poll ( struct nci_dev * ndev , struct rf_tech_specific_params_nfcb_poll * nfcb_poll , __u8 * data ) { nfcb_poll -> sensb_res_len = * data ++ ; pr_debug ( ""sensb_res_len%d\\n"" , nfcb_poll -> sensb_res_len ) ; memcpy ( nfcb_poll -> sensb_res , data , nfcb_poll -> sensb_res_len ) ; data += nfcb_poll -> sensb_res_len ; return data ; } "," -> sensb_res_len = min_t ( __u8 , * data ++ , NFC_SENSB_RES_MAXSIZE ) ",torvalds@linux/67de956ff5dc1d4f321e16cfbd63f5be3b691b43,CVE-2012-3364,https://github.com/torvalds/linux/commit/67de956ff5dc1d4f321e16cfbd63f5be3b691b43,2013-01-22T23:55Z 616,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 617,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 618,CWE-399,"CWE-399 int ip6_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 transhdrlen , int hlimit , int tclass , struct ipv6_txoptions * opt , struct flowi6 * fl6 , struct rt6_info * rt , unsigned int flags , int dontfrag ) { struct inet_sock * inet = inet_sk ( sk ) ; struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct inet_cork * cork ; struct sk_buff * skb , * skb_prev = NULL ; unsigned int maxfraglen , fragheaderlen ; int exthdrlen ; int dst_exthdrlen ; int hh_len ; int mtu ; int copy ; int err ; int offset = 0 ; __u8 tx_flags = 0 ; if ( flags & MSG_PROBE ) return 0 ; cork = & inet -> cork . base ; if ( skb_queue_empty ( & sk -> sk_write_queue ) ) { if ( opt ) { if ( WARN_ON ( np -> cork . opt ) ) return - EINVAL ; np -> cork . opt = kzalloc ( opt -> tot_len , sk -> sk_allocation ) ; if ( unlikely ( np -> cork . opt == NULL ) ) return - ENOBUFS ; np -> cork . opt -> tot_len = opt -> tot_len ; np -> cork . opt -> opt_flen = opt -> opt_flen ; np -> cork . opt -> opt_nflen = opt -> opt_nflen ; np -> cork . opt -> dst0opt = ip6_opt_dup ( opt -> dst0opt , sk -> sk_allocation ) ; if ( opt -> dst0opt && ! np -> cork . opt -> dst0opt ) return - ENOBUFS ; np -> cork . opt -> dst1opt = ip6_opt_dup ( opt -> dst1opt , sk -> sk_allocation ) ; if ( opt -> dst1opt && ! np -> cork . opt -> dst1opt ) return - ENOBUFS ; np -> cork . opt -> hopopt = ip6_opt_dup ( opt -> hopopt , sk -> sk_allocation ) ; if ( opt -> hopopt && ! np -> cork . opt -> hopopt ) return - ENOBUFS ; np -> cork . opt -> srcrt = ip6_rthdr_dup ( opt -> srcrt , sk -> sk_allocation ) ; if ( opt -> srcrt && ! np -> cork . opt -> srcrt ) return - ENOBUFS ; } dst_hold ( & rt -> dst ) ; cork -> dst = & rt -> dst ; inet -> cork . fl . u . ip6 = * fl6 ; np -> cork . hop_limit = hlimit ; np -> cork . tclass = tclass ; if ( rt -> dst . flags & DST_XFRM_TUNNEL ) mtu = np -> pmtudisc == IPV6_PMTUDISC_PROBE ? rt -> dst . dev -> mtu : dst_mtu ( & rt -> dst ) ; else mtu = np -> pmtudisc == IPV6_PMTUDISC_PROBE ? rt -> dst . dev -> mtu : dst_mtu ( rt -> dst . path ) ; if ( np -> frag_size < mtu ) { if ( np -> frag_size ) mtu = np -> frag_size ; } cork -> fragsize = mtu ; if ( dst_allfrag ( rt -> dst . path ) ) cork -> flags |= IPCORK_ALLFRAG ; cork -> length = 0 ; exthdrlen = ( opt ? opt -> opt_flen : 0 ) ; length += exthdrlen ; transhdrlen += exthdrlen ; dst_exthdrlen = rt -> dst . header_len - rt -> rt6i_nfheader_len ; } else { rt = ( struct rt6_info * ) cork -> dst ; fl6 = & inet -> cork . fl . u . ip6 ; opt = np -> cork . opt ; transhdrlen = 0 ; exthdrlen = 0 ; dst_exthdrlen = 0 ; mtu = cork -> fragsize ; } hh_len = LL_RESERVED_SPACE ( rt -> dst . dev ) ; fragheaderlen = sizeof ( struct ipv6hdr ) + rt -> rt6i_nfheader_len + ( opt ? opt -> opt_nflen : 0 ) ; maxfraglen = ( ( mtu - fragheaderlen ) & ~ 7 ) + fragheaderlen - sizeof ( struct frag_hdr ) ; if ( mtu <= sizeof ( struct ipv6hdr ) + IPV6_MAXPLEN ) { if ( cork -> length + length > sizeof ( struct ipv6hdr ) + IPV6_MAXPLEN - fragheaderlen ) { ipv6_local_error ( sk , EMSGSIZE , fl6 , mtu - exthdrlen ) ; return - EMSGSIZE ; } } if ( sk -> sk_type == SOCK_DGRAM ) sock_tx_timestamp ( sk , & tx_flags ) ; cork -> length += length ; if ( length > mtu ) { int proto = sk -> sk_protocol ; if ( dontfrag && ( proto == IPPROTO_UDP || proto == IPPROTO_RAW ) ) { ipv6_local_rxpmtu ( sk , fl6 , mtu - exthdrlen ) ; return - EMSGSIZE ; } if ( proto == IPPROTO_UDP && ( rt -> dst . dev -> features & NETIF_F_UFO ) ) { err = ip6_ufo_append_data ( sk , getfrag , from , length , hh_len , fragheaderlen , transhdrlen , mtu , flags , rt ) ; if ( err ) goto error ; return 0 ; } } if ( ( skb = skb_peek_tail ( & sk -> sk_write_queue ) ) == NULL ) goto alloc_new_skb ; while ( length > 0 ) { copy = ( cork -> length <= mtu && ! ( cork -> flags & IPCORK_ALLFRAG ) ? mtu : maxfraglen ) - skb -> len ; if ( copy < length ) copy = maxfraglen - skb -> len ; if ( copy <= 0 ) { char * data ; unsigned int datalen ; unsigned int fraglen ; unsigned int fraggap ; unsigned int alloclen ; alloc_new_skb : if ( skb ) fraggap = skb -> len - maxfraglen ; else fraggap = 0 ; if ( skb == NULL || skb_prev == NULL ) ip6_append_data_mtu ( & mtu , & maxfraglen , fragheaderlen , skb , rt ) ; skb_prev = skb ; datalen = length + fraggap ; if ( datalen > ( cork -> length <= mtu && ! ( cork -> flags & IPCORK_ALLFRAG ) ? mtu : maxfraglen ) - fragheaderlen ) datalen = maxfraglen - fragheaderlen - rt -> dst . trailer_len ; if ( ( flags & MSG_MORE ) && ! ( rt -> dst . dev -> features & NETIF_F_SG ) ) alloclen = mtu ; else alloclen = datalen + fragheaderlen ; alloclen += dst_exthdrlen ; if ( datalen != length + fraggap ) { datalen += rt -> dst . trailer_len ; } alloclen += rt -> dst . trailer_len ; fraglen = datalen + fragheaderlen ; alloclen += sizeof ( struct frag_hdr ) ; if ( transhdrlen ) { skb = sock_alloc_send_skb ( sk , alloclen + hh_len , ( flags & MSG_DONTWAIT ) , & err ) ; } else { skb = NULL ; if ( atomic_read ( & sk -> sk_wmem_alloc ) <= 2 * sk -> sk_sndbuf ) skb = sock_wmalloc ( sk , alloclen + hh_len , 1 , sk -> sk_allocation ) ; if ( unlikely ( skb == NULL ) ) err = - ENOBUFS ; else { tx_flags = 0 ; } } if ( skb == NULL ) goto error ; skb -> ip_summed = CHECKSUM_NONE ; skb -> csum = 0 ; skb_reserve ( skb , hh_len + sizeof ( struct frag_hdr ) + dst_exthdrlen ) ; if ( sk -> sk_type == SOCK_DGRAM ) skb_shinfo ( skb ) -> tx_flags = tx_flags ; data = skb_put ( skb , fraglen ) ; skb_set_network_header ( skb , exthdrlen ) ; data += fragheaderlen ; skb -> transport_header = ( skb -> network_header + fragheaderlen ) ; if ( fraggap ) { skb -> csum = skb_copy_and_csum_bits ( skb_prev , maxfraglen , data + transhdrlen , fraggap , 0 ) ; skb_prev -> csum = csum_sub ( skb_prev -> csum , skb -> csum ) ; data += fraggap ; pskb_trim_unique ( skb_prev , maxfraglen ) ; } copy = datalen - transhdrlen - fraggap ; if ( copy < 0 ) { err = - EINVAL ; kfree_skb ( skb ) ; goto error ; } else if ( copy > 0 && getfrag ( from , data + transhdrlen , offset , copy , fraggap , skb ) < 0 ) { err = - EFAULT ; kfree_skb ( skb ) ; goto error ; } offset += copy ; length -= datalen - fraggap ; transhdrlen = 0 ; exthdrlen = 0 ; dst_exthdrlen = 0 ; __skb_queue_tail ( & sk -> sk_write_queue , skb ) ; continue ; } if ( copy > length ) copy = length ; if ( ! ( rt -> dst . dev -> features & NETIF_F_SG ) ) { unsigned int off ; off = skb -> len ; if ( getfrag ( from , skb_put ( skb , copy ) , offset , copy , off , skb ) < 0 ) { __skb_trim ( skb , off ) ; err = - EFAULT ; goto error ; } } else { int i = skb_shinfo ( skb ) -> nr_frags ; struct page_frag * pfrag = sk_page_frag ( sk ) ; err = - ENOMEM ; if ( ! sk_page_frag_refill ( sk , pfrag ) ) goto error ; if ( ! skb_can_coalesce ( skb , i , pfrag -> page , pfrag -> offset ) ) { err = - EMSGSIZE ; if ( i == MAX_SKB_FRAGS ) goto error ; __skb_fill_page_desc ( skb , i , pfrag -> page , pfrag -> offset , 0 ) ; skb_shinfo ( skb ) -> nr_frags = ++ i ; get_page ( pfrag -> page ) ; } copy = min_t ( int , copy , pfrag -> size - pfrag -> offset ) ; if ( getfrag ( from , page_address ( pfrag -> page ) + pfrag -> offset , offset , copy , skb -> len , skb ) < 0 ) goto error_efault ; pfrag -> offset += copy ; skb_frag_size_add ( & skb_shinfo ( skb ) -> frags [ i - 1 ] , copy ) ; skb -> len += copy ; skb -> data_len += copy ; skb -> truesize += copy ; atomic_add ( copy , & sk -> sk_wmem_alloc ) ; } offset += copy ; length -= copy ; } return 0 ; error_efault : err = - EFAULT ; error : cork -> length -= length ; IP6_INC_STATS ( sock_net ( sk ) , rt -> rt6i_idev , IPSTATS_MIB_OUTDISCARDS ) ; return err ; } "," maxfraglen , fragheaderlen , mtu ; int hh_len ; int copy skb , rt , np -> pmtudisc == IPV6_PMTUDISC_PROBE ",torvalds@linux/75a493e60ac4bbe2e977e7129d6d8cbb0dd236be,CVE-2013-4163,https://github.com/torvalds/linux/commit/75a493e60ac4bbe2e977e7129d6d8cbb0dd236be,2013-07-29T13:59Z 619,CWE-665,"CWE-665 int ParseCaffHeaderConfig ( FILE * infile , char * infilename , char * fourcc , WavpackContext * wpc , WavpackConfig * config ) { uint32_t chan_chunk = 0 , channel_layout = 0 , bcount ; unsigned char * channel_identities = NULL ; unsigned char * channel_reorder = NULL ; int64_t total_samples = 0 , infilesize ; CAFFileHeader caf_file_header ; CAFChunkHeader caf_chunk_header ; CAFAudioFormat caf_audio_format ; int i ; infilesize = DoGetFileSize ( infile ) ; memcpy ( & caf_file_header , fourcc , 4 ) ; if ( ( ! DoReadFile ( infile , ( ( char * ) & caf_file_header ) + 4 , sizeof ( CAFFileHeader ) - 4 , & bcount ) || bcount != sizeof ( CAFFileHeader ) - 4 ) ) { error_line ( ""%sisnotavalid.CAFfile!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & caf_file_header , sizeof ( CAFFileHeader ) ) ) { error_line ( ""%s"" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } WavpackBigEndianToNative ( & caf_file_header , CAFFileHeaderFormat ) ; if ( caf_file_header . mFileVersion != 1 ) { error_line ( ""%s:can\'thandleversion%d.CAFfiles!"" , infilename , caf_file_header . mFileVersion ) ; return WAVPACK_SOFT_ERROR ; } while ( 1 ) { if ( ! DoReadFile ( infile , & caf_chunk_header , sizeof ( CAFChunkHeader ) , & bcount ) || bcount != sizeof ( CAFChunkHeader ) ) { error_line ( ""%sisnotavalid.CAFfile!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & caf_chunk_header , sizeof ( CAFChunkHeader ) ) ) { error_line ( ""%s"" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } WavpackBigEndianToNative ( & caf_chunk_header , CAFChunkHeaderFormat ) ; if ( ! strncmp ( caf_chunk_header . mChunkType , ""desc"" , 4 ) ) { int supported = TRUE ; if ( caf_chunk_header . mChunkSize != sizeof ( CAFAudioFormat ) || ! DoReadFile ( infile , & caf_audio_format , ( uint32_t ) caf_chunk_header . mChunkSize , & bcount ) || bcount != caf_chunk_header . mChunkSize ) { error_line ( ""%sisnotavalid.CAFfile!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & caf_audio_format , ( uint32_t ) caf_chunk_header . mChunkSize ) ) { error_line ( ""%s"" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } WavpackBigEndianToNative ( & caf_audio_format , CAFAudioFormatFormat ) ; if ( debug_logging_mode ) { char formatstr [ 5 ] ; memcpy ( formatstr , caf_audio_format . mFormatID , 4 ) ; formatstr [ 4 ] = 0 ; error_line ( ""format=%s,flags=%x,samplingrate=%g"" , formatstr , caf_audio_format . mFormatFlags , caf_audio_format . mSampleRate ) ; error_line ( ""packet=%dbytesand%dframes"" , caf_audio_format . mBytesPerPacket , caf_audio_format . mFramesPerPacket ) ; error_line ( ""channelsperframe=%d,bitsperchannel=%d"" , caf_audio_format . mChannelsPerFrame , caf_audio_format . mBitsPerChannel ) ; } if ( strncmp ( caf_audio_format . mFormatID , ""lpcm"" , 4 ) || ( caf_audio_format . mFormatFlags & ~ 3 ) ) supported = FALSE ; else if ( caf_audio_format . mSampleRate < 1.0 || caf_audio_format . mSampleRate > 16777215.0 || caf_audio_format . mSampleRate != floor ( caf_audio_format . mSampleRate ) ) supported = FALSE ; else if ( ! caf_audio_format . mChannelsPerFrame || caf_audio_format . mChannelsPerFrame > 256 ) supported = FALSE ; else if ( caf_audio_format . mBitsPerChannel < 1 || caf_audio_format . mBitsPerChannel > 32 || ( ( caf_audio_format . mFormatFlags & CAF_FORMAT_FLOAT ) && caf_audio_format . mBitsPerChannel != 32 ) ) supported = FALSE ; else if ( caf_audio_format . mFramesPerPacket != 1 || caf_audio_format . mBytesPerPacket / caf_audio_format . mChannelsPerFrame < ( caf_audio_format . mBitsPerChannel + 7 ) / 8 || caf_audio_format . mBytesPerPacket / caf_audio_format . mChannelsPerFrame > 4 || caf_audio_format . mBytesPerPacket % caf_audio_format . mChannelsPerFrame ) supported = FALSE ; if ( ! supported ) { error_line ( ""%sisanunsupported.CAFformat!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } config -> bytes_per_sample = caf_audio_format . mBytesPerPacket / caf_audio_format . mChannelsPerFrame ; config -> float_norm_exp = ( caf_audio_format . mFormatFlags & CAF_FORMAT_FLOAT ) ? 127 : 0 ; config -> bits_per_sample = caf_audio_format . mBitsPerChannel ; config -> num_channels = caf_audio_format . mChannelsPerFrame ; config -> sample_rate = ( int ) caf_audio_format . mSampleRate ; if ( ! ( caf_audio_format . mFormatFlags & CAF_FORMAT_LITTLE_ENDIAN ) && config -> bytes_per_sample > 1 ) config -> qmode |= QMODE_BIG_ENDIAN ; if ( config -> bytes_per_sample == 1 ) config -> qmode |= QMODE_SIGNED_BYTES ; if ( debug_logging_mode ) { if ( config -> float_norm_exp == 127 ) error_line ( ""dataformat:32-bit%s-endianfloatingpoint"" , ( config -> qmode & QMODE_BIG_ENDIAN ) ? ""big"" : ""little"" ) ; else error_line ( ""dataformat:%d-bit%s-endianintegersstoredin%dbyte(s)"" , config -> bits_per_sample , ( config -> qmode & QMODE_BIG_ENDIAN ) ? ""big"" : ""little"" , config -> bytes_per_sample ) ; } } else if ( ! strncmp ( caf_chunk_header . mChunkType , ""chan"" , 4 ) ) { CAFChannelLayout * caf_channel_layout ; if ( caf_chunk_header . mChunkSize < 0 || caf_chunk_header . mChunkSize > 1024 || caf_chunk_header . mChunkSize < sizeof ( CAFChannelLayout ) ) { error_line ( ""this.CAFfilehasaninvalid\'chan\'chunk!"" ) ; return WAVPACK_SOFT_ERROR ; } if ( debug_logging_mode ) error_line ( ""\'chan\'chunkis%dbytes"" , ( int ) caf_chunk_header . mChunkSize ) ; caf_channel_layout = malloc ( ( size_t ) caf_chunk_header . mChunkSize ) ; if ( ! DoReadFile ( infile , caf_channel_layout , ( uint32_t ) caf_chunk_header . mChunkSize , & bcount ) || bcount != caf_chunk_header . mChunkSize ) { error_line ( ""%sisnotavalid.CAFfile!"" , infilename ) ; free ( caf_channel_layout ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , caf_channel_layout , ( uint32_t ) caf_chunk_header . mChunkSize ) ) { error_line ( ""%s"" , WavpackGetErrorMessage ( wpc ) ) ; free ( caf_channel_layout ) ; return WAVPACK_SOFT_ERROR ; } WavpackBigEndianToNative ( caf_channel_layout , CAFChannelLayoutFormat ) ; chan_chunk = 1 ; if ( config -> channel_mask || ( config -> qmode & QMODE_CHANS_UNASSIGNED ) ) { error_line ( ""thisCAFfilealreadyhaschannelorderinformation!"" ) ; free ( caf_channel_layout ) ; return WAVPACK_SOFT_ERROR ; } switch ( caf_channel_layout -> mChannelLayoutTag ) { case kCAFChannelLayoutTag_UseChannelDescriptions : { CAFChannelDescription * descriptions = ( CAFChannelDescription * ) ( caf_channel_layout + 1 ) ; int num_descriptions = caf_channel_layout -> mNumberChannelDescriptions ; int label , cindex = 0 , idents = 0 ; if ( caf_chunk_header . mChunkSize != sizeof ( CAFChannelLayout ) + sizeof ( CAFChannelDescription ) * num_descriptions || num_descriptions != config -> num_channels ) { error_line ( ""channeldescriptionsin\'chan\'chunkarethewrongsize!"" ) ; free ( caf_channel_layout ) ; return WAVPACK_SOFT_ERROR ; } if ( num_descriptions >= 256 ) { error_line ( ""%dchanneldescriptionsismorethanwecanhandle...ignoring!"" ) ; break ; } channel_reorder = malloc ( num_descriptions ) ; memset ( channel_reorder , - 1 , num_descriptions ) ; channel_identities = malloc ( num_descriptions + 1 ) ; for ( i = 0 ; i < num_descriptions ; ++ i ) { WavpackBigEndianToNative ( descriptions + i , CAFChannelDescriptionFormat ) ; if ( debug_logging_mode ) error_line ( ""chan%d-->%d"" , i + 1 , descriptions [ i ] . mChannelLabel ) ; } for ( label = 1 ; label <= 18 ; ++ label ) for ( i = 0 ; i < num_descriptions ; ++ i ) if ( descriptions [ i ] . mChannelLabel == label ) { config -> channel_mask |= 1 << ( label - 1 ) ; channel_reorder [ i ] = cindex ++ ; break ; } for ( i = 0 ; i < num_descriptions ; ++ i ) if ( channel_reorder [ i ] == ( unsigned char ) - 1 ) { uint32_t clabel = descriptions [ i ] . mChannelLabel ; if ( clabel == 0 || clabel == 0xffffffff || clabel == 100 ) channel_identities [ idents ++ ] = 0xff ; else if ( ( clabel >= 33 && clabel <= 44 ) || ( clabel >= 200 && clabel <= 207 ) || ( clabel >= 301 && clabel <= 305 ) ) channel_identities [ idents ++ ] = clabel >= 301 ? clabel - 80 : clabel ; else { error_line ( ""warning:unknownchanneldescriptionslabel:%d"" , clabel ) ; channel_identities [ idents ++ ] = 0xff ; } channel_reorder [ i ] = cindex ++ ; } for ( i = 0 ; i < num_descriptions ; ++ i ) if ( channel_reorder [ i ] != i ) break ; if ( i == num_descriptions ) { free ( channel_reorder ) ; channel_reorder = NULL ; } else { config -> qmode |= QMODE_REORDERED_CHANS ; channel_layout = num_descriptions ; } if ( ! idents ) { free ( channel_identities ) ; channel_identities = NULL ; } else channel_identities [ idents ] = 0 ; if ( debug_logging_mode ) { error_line ( ""layout_tag=0x%08x,sogeneratedbitmapof0x%08xfrom%ddescriptions,%dnon-MS"" , caf_channel_layout -> mChannelLayoutTag , config -> channel_mask , caf_channel_layout -> mNumberChannelDescriptions , idents ) ; if ( channel_reorder && num_descriptions <= 8 ) { char reorder_string [ ] = ""12345678"" ; for ( i = 0 ; i < num_descriptions ; ++ i ) reorder_string [ i ] = channel_reorder [ i ] + '1' ; reorder_string [ i ] = 0 ; error_line ( ""reorderingstring=\\""%s\\""\\n"" , reorder_string ) ; } } } break ; case kCAFChannelLayoutTag_UseChannelBitmap : config -> channel_mask = caf_channel_layout -> mChannelBitmap ; if ( debug_logging_mode ) error_line ( ""layout_tag=0x%08x,sousingsuppliedbitmapof0x%08x"" , caf_channel_layout -> mChannelLayoutTag , caf_channel_layout -> mChannelBitmap ) ; break ; default : for ( i = 0 ; i < NUM_LAYOUTS ; ++ i ) if ( caf_channel_layout -> mChannelLayoutTag == layouts [ i ] . mChannelLayoutTag ) { config -> channel_mask = layouts [ i ] . mChannelBitmap ; channel_layout = layouts [ i ] . mChannelLayoutTag ; if ( layouts [ i ] . mChannelReorder ) { channel_reorder = ( unsigned char * ) strdup ( layouts [ i ] . mChannelReorder ) ; config -> qmode |= QMODE_REORDERED_CHANS ; } if ( layouts [ i ] . mChannelIdentities ) channel_identities = ( unsigned char * ) strdup ( layouts [ i ] . mChannelIdentities ) ; if ( debug_logging_mode ) error_line ( ""layout_tag0x%08xfoundintable,bitmap=0x%08x,reorder=%s,identities=%s"" , channel_layout , config -> channel_mask , channel_reorder ? ""yes"" : ""no"" , channel_identities ? ""yes"" : ""no"" ) ; break ; } if ( i == NUM_LAYOUTS && debug_logging_mode ) error_line ( ""layout_tag0x%08xnotfoundintable...allchannelsunassigned"" , caf_channel_layout -> mChannelLayoutTag ) ; break ; } free ( caf_channel_layout ) ; } else if ( ! strncmp ( caf_chunk_header . mChunkType , ""data"" , 4 ) ) { uint32_t mEditCount ; if ( ! DoReadFile ( infile , & mEditCount , sizeof ( mEditCount ) , & bcount ) || bcount != sizeof ( mEditCount ) ) { error_line ( ""%sisnotavalid.CAFfile!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & mEditCount , sizeof ( mEditCount ) ) ) { error_line ( ""%s"" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } if ( ( config -> qmode & QMODE_IGNORE_LENGTH ) || caf_chunk_header . mChunkSize == - 1 ) { config -> qmode |= QMODE_IGNORE_LENGTH ; if ( infilesize && DoGetFilePosition ( infile ) != - 1 ) total_samples = ( infilesize - DoGetFilePosition ( infile ) ) / caf_audio_format . mBytesPerPacket ; else total_samples = - 1 ; } else { if ( infilesize && infilesize - caf_chunk_header . mChunkSize > 16777216 ) { error_line ( "".CAFfile%shasover16MBofextraCAFFdata,probablyiscorrupt!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } if ( ( caf_chunk_header . mChunkSize - 4 ) % caf_audio_format . mBytesPerPacket ) { error_line ( "".CAFfile%shasaninvaliddatachunksize,probablyiscorrupt!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } total_samples = ( caf_chunk_header . mChunkSize - 4 ) / caf_audio_format . mBytesPerPacket ; if ( ! total_samples ) { error_line ( ""this.CAFfilehasnoaudiosamples,probablyiscorrupt!"" ) ; return WAVPACK_SOFT_ERROR ; } if ( total_samples > MAX_WAVPACK_SAMPLES ) { error_line ( ""%shastoomanysamplesforWavPack!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } } break ; } else { uint32_t bytes_to_copy = ( uint32_t ) caf_chunk_header . mChunkSize ; char * buff ; if ( caf_chunk_header . mChunkSize < 0 || caf_chunk_header . mChunkSize > 1048576 ) { error_line ( ""%sisnotavalid.CAFfile!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } buff = malloc ( bytes_to_copy ) ; if ( debug_logging_mode ) error_line ( ""extraunknownchunk\\""%c%c%c%c\\""of%dbytes"" , caf_chunk_header . mChunkType [ 0 ] , caf_chunk_header . mChunkType [ 1 ] , caf_chunk_header . mChunkType [ 2 ] , caf_chunk_header . mChunkType [ 3 ] , caf_chunk_header . mChunkSize ) ; 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 ( ! chan_chunk && ! config -> channel_mask && config -> num_channels <= 2 && ! ( config -> qmode & QMODE_CHANS_UNASSIGNED ) ) config -> channel_mask = 0x5 - config -> num_channels ; if ( ! WavpackSetConfiguration64 ( wpc , config , total_samples , channel_identities ) ) { error_line ( ""%s"" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } if ( channel_identities ) free ( channel_identities ) ; if ( channel_layout || channel_reorder ) { if ( ! WavpackSetChannelLayout ( wpc , channel_layout , channel_reorder ) ) { error_line ( ""problemwithsettingchannellayout(shouldnothappen)"" ) ; return WAVPACK_SOFT_ERROR ; } if ( channel_reorder ) free ( channel_reorder ) ; } return WAVPACK_NO_ERROR ; } "," { uint32_t chan_chunk = 0 , desc_chunk , CAFAudioFormatFormat ) ; desc_chunk = 1 if ( ! desc_chunk || ! ",dbry@WavPack/f68a9555b548306c5b1ee45199ccdc4a16a6101b,CVE-2019-1010317,https://github.com/dbry/WavPack/commit/f68a9555b548306c5b1ee45199ccdc4a16a6101b,2019-07-11T20:15Z 620,CWE-119,"CWE-119 static int cost_segmap ( int * segcounts , vp9_prob * probs ) { const int c01 = segcounts [ 0 ] + segcounts [ 1 ] ; const int c23 = segcounts [ 2 ] + segcounts [ 3 ] ; const int c45 = segcounts [ 4 ] + segcounts [ 5 ] ; const int c67 = segcounts [ 6 ] + segcounts [ 7 ] ; const int c0123 = c01 + c23 ; const int c4567 = c45 + c67 ; int cost = c0123 * vp9_cost_zero ( probs [ 0 ] ) + c4567 * vp9_cost_one ( probs [ 0 ] ) ; if ( c0123 > 0 ) { cost += c01 * vp9_cost_zero ( probs [ 1 ] ) + c23 * vp9_cost_one ( probs [ 1 ] ) ; if ( c01 > 0 ) cost += segcounts [ 0 ] * vp9_cost_zero ( probs [ 3 ] ) + segcounts [ 1 ] * vp9_cost_one ( probs [ 3 ] ) ; if ( c23 > 0 ) cost += segcounts [ 2 ] * vp9_cost_zero ( probs [ 4 ] ) + segcounts [ 3 ] * vp9_cost_one ( probs [ 4 ] ) ; } if ( c4567 > 0 ) { cost += c45 * vp9_cost_zero ( probs [ 2 ] ) + c67 * vp9_cost_one ( probs [ 2 ] ) ; if ( c45 > 0 ) cost += segcounts [ 4 ] * vp9_cost_zero ( probs [ 5 ] ) + segcounts [ 5 ] * vp9_cost_one ( probs [ 5 ] ) ; if ( c67 > 0 ) cost += segcounts [ 6 ] * vp9_cost_zero ( probs [ 6 ] ) + segcounts [ 7 ] * vp9_cost_one ( probs [ 6 ] ) ; } return cost ; } "," * segcounts , vpx_prob * probs ) ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 621,CWE-119,"CWE-119 static void accumulate_frame_motion_stats ( VP8_COMP * cpi , FIRSTPASS_STATS * this_frame , double * this_frame_mv_in_out , double * mv_in_out_accumulator , double * abs_mv_in_out_accumulator , double * mv_ratio_accumulator ) { double this_frame_mvr_ratio ; double this_frame_mvc_ratio ; double motion_pct ; motion_pct = this_frame -> pcnt_motion ; * this_frame_mv_in_out = this_frame -> mv_in_out_count * motion_pct ; * mv_in_out_accumulator += this_frame -> mv_in_out_count * motion_pct ; * abs_mv_in_out_accumulator += fabs ( this_frame -> mv_in_out_count * motion_pct ) ; if ( motion_pct > 0.05 ) { this_frame_mvr_ratio = fabs ( this_frame -> mvr_abs ) / DOUBLE_DIVIDE_CHECK ( fabs ( this_frame -> MVr ) ) ; this_frame_mvc_ratio = fabs ( this_frame -> mvc_abs ) / DOUBLE_DIVIDE_CHECK ( fabs ( this_frame -> MVc ) ) ; * mv_ratio_accumulator += ( this_frame_mvr_ratio < this_frame -> mvr_abs ) ? ( this_frame_mvr_ratio * motion_pct ) : this_frame -> mvr_abs * motion_pct ; * mv_ratio_accumulator += ( this_frame_mvc_ratio < this_frame -> mvc_abs ) ? ( this_frame_mvc_ratio * motion_pct ) : this_frame -> mvc_abs * motion_pct ; } } "," double motion_pct ; ( void ) cpi ; ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 622,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 623,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 624,CWE-59,"CWE-59 static void fifo_open ( notify_fifo_t * fifo , int ( * script_exit ) ( thread_t * ) , const char * type ) { int ret ; int sav_errno ; if ( fifo -> name ) { sav_errno = 0 ; if ( ! ( ret = mkfifo ( fifo -> name , S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH ) ) ) fifo -> created_fifo = true ; else { sav_errno = errno ; if ( sav_errno != EEXIST ) log_message ( LOG_INFO , ""Unabletocreate%snotifyfifo%s"" , type , fifo -> name ) ; } if ( ! sav_errno || sav_errno == EEXIST ) { if ( fifo -> script ) notify_fifo_exec ( master , script_exit , fifo , fifo -> script ) ; if ( ( fifo -> fd = open ( fifo -> name , O_RDWR | O_CLOEXEC | O_NONBLOCK ) ) == - 1 ) { log_message ( LOG_INFO , ""Unabletoopen%snotifyfifo%s-errno%d"" , type , fifo -> name , errno ) ; if ( fifo -> created_fifo ) { unlink ( fifo -> name ) ; fifo -> created_fifo = false ; } } } if ( fifo -> fd == - 1 ) { FREE ( fifo -> name ) ; fifo -> name = NULL ; } } } "," O_CLOEXEC | O_NONBLOCK | O_NOFOLLOW ",acassen@keepalived/04f2d32871bb3b11d7dc024039952f2fe2750306,CVE-2018-19044,https://github.com/acassen/keepalived/commit/04f2d32871bb3b11d7dc024039952f2fe2750306,2018-11-08T20:29Z 625,CWE-120,"CWE-120 static int try_read_command_binary ( conn * c ) { if ( c -> rbytes < sizeof ( c -> binary_header ) ) { return 0 ; } else { memcpy ( & c -> binary_header , c -> rcurr , sizeof ( c -> binary_header ) ) ; protocol_binary_request_header * req ; req = & c -> binary_header ; 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 ; } uint8_t extlen = c -> binary_header . request . extlen ; uint16_t keylen = c -> binary_header . request . keylen ; if ( c -> rbytes < keylen + extlen + sizeof ( c -> binary_header ) ) { return 0 ; } if ( ! resp_start ( c ) ) { conn_set_state ( c , conn_closing ) ; return - 1 ; } c -> cmd = c -> binary_header . request . opcode ; c -> keylen = c -> binary_header . request . keylen ; c -> opaque = c -> binary_header . request . opaque ; c -> cas = 0 ; c -> last_cmd_time = current_time ; char extbuf [ sizeof ( c -> binary_header ) + BIN_MAX_EXTLEN ] ; memcpy ( extbuf + sizeof ( c -> binary_header ) , c -> rcurr + sizeof ( c -> binary_header ) , extlen ) ; c -> rbytes -= sizeof ( c -> binary_header ) + extlen + keylen ; c -> rcurr += sizeof ( c -> binary_header ) + extlen + keylen ; dispatch_bin_command ( c , extbuf ) ; } return 1 ; } "," ) + BIN_MAX_EXTLEN + 1 binary_header ) , extlen > BIN_MAX_EXTLEN ? BIN_MAX_EXTLEN : ",memcached@memcached/02c6a2b62ddcb6fa4569a591d3461a156a636305,CVE-2020-10931,https://github.com/memcached/memcached/commit/02c6a2b62ddcb6fa4569a591d3461a156a636305,2020-03-24T15:15Z 626,CWE-189,"CWE-189 static void add_bytes_c ( uint8_t * dst , uint8_t * src , int w ) { long i ; for ( i = 0 ; i <= w - sizeof ( long ) ; i += sizeof ( long ) ) { long a = * ( long * ) ( src + i ) ; long b = * ( long * ) ( dst + i ) ; * ( long * ) ( dst + i ) = ( ( a & pb_7f ) + ( b & pb_7f ) ) ^ ( ( a ^ b ) & pb_80 ) ; } for ( ; i < w ; i ++ ) dst [ i + 0 ] += src [ i + 0 ] ; } "," <= w - ( int ) ",FFmpeg@FFmpeg/454a11a1c9c686c78aa97954306fb63453299760,CVE-2013-7010,https://github.com/FFmpeg/FFmpeg/commit/454a11a1c9c686c78aa97954306fb63453299760,2013-12-09T16:36Z 627,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 628,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 629,CWE-125,"CWE-125 static RList * r_bin_wasm_get_element_entries ( RBinWasmObj * bin , RBinWasmSection * sec ) { RList * ret = NULL ; RBinWasmElementEntry * ptr = NULL ; if ( ! ( ret = r_list_newf ( ( RListFree ) free ) ) ) { return NULL ; } ut8 * buf = bin -> buf -> buf + ( ut32 ) sec -> payload_data ; ut32 len = sec -> payload_len ; ut32 count = sec -> count ; ut32 i = 0 , r = 0 ; while ( i < len && r < count ) { if ( ! ( ptr = R_NEW0 ( RBinWasmElementEntry ) ) ) { return ret ; } if ( ! ( consume_u32 ( buf + i , buf + len , & ptr -> index , & i ) ) ) { free ( ptr ) ; return ret ; } if ( ! ( consume_init_expr ( buf + i , buf + len , R_BIN_WASM_END_OF_CODE , NULL , & i ) ) ) { free ( ptr ) ; return ret ; } if ( ! ( consume_u32 ( buf + i , buf + len , & ptr -> num_elem , & i ) ) ) { free ( ptr ) ; return ret ; } ut32 j = 0 ; while ( i < len && j < ptr -> num_elem ) { ut32 e ; if ( ! ( consume_u32 ( buf + i , buf + len , & e , & i ) ) ) { free ( ptr ) ; return ret ; } } r_list_append ( ret , ptr ) ; r += 1 ; } return ret ; } "," -> payload_data ; int buflen = bin -> buf -> length - ( ut32 ) sec -> payload_data ; i < len && len < buflen ) ) { goto beach ; } if ) ) { goto beach ; } if ) ) { goto beach ; } ut32 return ret ; beach : free ( ptr ) ; return ret ; ",radare@radare2/d2632f6483a3ceb5d8e0a5fb11142c51c43978b4,CVE-2017-7854,https://github.com/radare/radare2/commit/d2632f6483a3ceb5d8e0a5fb11142c51c43978b4,2017-04-13T16:59Z 630,CWE-399,"CWE-399 public int magic_setparam ( struct magic_set * ms , int param , const void * val ) { switch ( param ) { case MAGIC_PARAM_INDIR_MAX : ms -> indir_max = * ( const size_t * ) val ; return 0 ; case MAGIC_PARAM_NAME_MAX : ms -> name_max = * ( const size_t * ) val ; return 0 ; case MAGIC_PARAM_ELF_PHNUM_MAX : ms -> elf_phnum_max = * ( const size_t * ) val ; return 0 ; case MAGIC_PARAM_ELF_SHNUM_MAX : ms -> elf_shnum_max = * ( const size_t * ) val ; return 0 ; default : errno = EINVAL ; return - 1 ; } } "," return 0 ; case MAGIC_PARAM_ELF_NOTES_MAX : ms -> elf_notes_max = * ( const size_t * ) val ; return 0 ; ",file@file/ce90e05774dd77d86cfc8dfa6da57b32816841c4,CVE-2014-9620,https://github.com/file/file/commit/ce90e05774dd77d86cfc8dfa6da57b32816841c4,2015-01-21T18:59Z 631,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 632,CWE-416,"CWE-416 static void nodeConstruct ( struct SaveNode * node , tr_variant const * v , bool sort_dicts ) { node -> isVisited = false ; node -> childIndex = 0 ; if ( sort_dicts && tr_variantIsDict ( v ) ) { size_t const n = v -> val . l . count ; struct KeyIndex * tmp = tr_new ( struct KeyIndex , n ) ; for ( size_t i = 0 ; i < n ; i ++ ) { tmp [ i ] . val = v -> val . l . vals + i ; tmp [ i ] . keystr = tr_quark_get_string ( tmp [ i ] . val -> key , NULL ) ; } qsort ( tmp , n , sizeof ( struct KeyIndex ) , compareKeyIndex ) ; tr_variantInitDict ( & node -> sorted , n ) ; for ( size_t i = 0 ; i < n ; ++ i ) { node -> sorted . val . l . vals [ i ] = * tmp [ i ] . val ; } node -> sorted . val . l . count = n ; tr_free ( tmp ) ; node -> v = & node -> sorted ; } else { node -> v = v ; } } "," compareKeyIndex ) ; node -> sorted = tr_new ( tr_variant , 1 ) ; tr_variantInitDict ( node -> sorted node -> sorted -> val . l node -> sorted -> val . l tmp ) ; v = node -> sorted { node -> sorted = NULL ; } node -> v = v ; } ",transmission@transmission/2123adf8e5e1c2b48791f9d22fc8c747e974180e,CVE-2018-10756,https://github.com/transmission/transmission/commit/2123adf8e5e1c2b48791f9d22fc8c747e974180e,2020-05-15T16:15Z 633,CWE-125,"CWE-125 PyObject * ast2obj_arg ( void * _o ) { arg_ty o = ( arg_ty ) _o ; PyObject * result = NULL , * value = NULL ; if ( ! o ) { Py_INCREF ( Py_None ) ; return Py_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_string ( o -> type_comment ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_type_comment , 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 ) ; 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 634,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 635,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 636,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 637,CWE-264,"CWE-264 static void otp_verify ( krb5_context context , krb5_data * req_pkt , krb5_kdc_req * request , krb5_enc_tkt_part * enc_tkt_reply , krb5_pa_data * pa , krb5_kdcpreauth_callbacks cb , krb5_kdcpreauth_rock rock , krb5_kdcpreauth_moddata moddata , krb5_kdcpreauth_verify_respond_fn respond , void * arg ) { krb5_keyblock * armor_key = NULL ; krb5_pa_otp_req * req = NULL ; struct request_state * rs ; krb5_error_code retval ; krb5_data d , plaintext ; char * config ; enc_tkt_reply -> flags |= TKT_FLG_PRE_AUTH ; armor_key = cb -> fast_armor ( context , rock ) ; if ( armor_key == NULL ) { retval = KRB5KDC_ERR_PREAUTH_FAILED ; com_err ( ""otp"" , retval , ""Noarmorkeyfoundwhenverifyingpadata"" ) ; goto error ; } d = make_data ( pa -> contents , pa -> length ) ; retval = decode_krb5_pa_otp_req ( & d , & req ) ; if ( retval != 0 ) { com_err ( ""otp"" , retval , ""UnabletodecodeOTPrequest"" ) ; goto error ; } retval = decrypt_encdata ( context , armor_key , req , & plaintext ) ; if ( retval != 0 ) { com_err ( ""otp"" , retval , ""Unabletodecryptnonce"" ) ; goto error ; } retval = nonce_verify ( context , armor_key , & plaintext ) ; if ( retval != 0 ) retval = timestamp_verify ( context , & plaintext ) ; krb5_free_data_contents ( context , & plaintext ) ; if ( retval != 0 ) { com_err ( ""otp"" , retval , ""Unabletoverifynonceortimestamp"" ) ; goto error ; } rs = k5alloc ( sizeof ( struct request_state ) , & retval ) ; if ( rs == NULL ) goto error ; rs -> arg = arg ; rs -> respond = respond ; retval = cb -> get_string ( context , rock , ""otp"" , & config ) ; if ( retval == 0 && config == NULL ) retval = KRB5_PREAUTH_FAILED ; if ( retval != 0 ) { free ( rs ) ; goto error ; } otp_state_verify ( ( otp_state * ) moddata , cb -> event_context ( context , rock ) , request -> client , config , req , on_response , rs ) ; cb -> free_string ( context , rock , config ) ; k5_free_pa_otp_req ( context , req ) ; return ; error : k5_free_pa_otp_req ( context , req ) ; ( * respond ) ( arg , retval , NULL , NULL , NULL ) ; } "," * config ; armor_key = cb respond = respond ; rs -> enc_tkt_reply = enc_tkt_reply ",krb5@krb5/e3b5a5e5267818c97750b266df50b6a3d4649604,CVE-2015-2694,https://github.com/krb5/krb5/commit/e3b5a5e5267818c97750b266df50b6a3d4649604,2015-05-25T19:59Z 638,CWE-476,"CWE-476 int create_flush_cmd_control ( struct f2fs_sb_info * sbi ) { dev_t dev = sbi -> sb -> s_bdev -> bd_dev ; struct flush_cmd_control * fcc ; int err = 0 ; if ( SM_I ( sbi ) -> fcc_info ) { fcc = SM_I ( sbi ) -> fcc_info ; goto init_thread ; } fcc = kzalloc ( sizeof ( struct flush_cmd_control ) , GFP_KERNEL ) ; if ( ! fcc ) return - ENOMEM ; atomic_set ( & fcc -> issued_flush , 0 ) ; atomic_set ( & fcc -> issing_flush , 0 ) ; init_waitqueue_head ( & fcc -> flush_wait_queue ) ; init_llist_head ( & fcc -> issue_list ) ; SM_I ( sbi ) -> fcc_info = fcc ; init_thread : fcc -> f2fs_issue_flush = kthread_run ( issue_flush_thread , sbi , ""f2fs_flush-%u:%u"" , MAJOR ( dev ) , MINOR ( dev ) ) ; if ( IS_ERR ( fcc -> f2fs_issue_flush ) ) { err = PTR_ERR ( fcc -> f2fs_issue_flush ) ; kfree ( fcc ) ; SM_I ( sbi ) -> fcc_info = NULL ; return err ; } return err ; } "," = fcc ; if ( ! test_opt ( sbi , FLUSH_MERGE ) ) return err ; ",torvalds@linux/d4fdf8ba0e5808ba9ad6b44337783bd9935e0982,CVE-2017-18241,https://github.com/torvalds/linux/commit/d4fdf8ba0e5808ba9ad6b44337783bd9935e0982,2018-03-21T16:29Z 639,CWE-119,"CWE-119 void byteSwap ( UWORD32 * buf , unsigned words ) { md5byte * p ; int i = 1 ; if ( * ( char * ) & i == 1 ) return ; p = ( md5byte * ) buf ; do { * buf ++ = ( UWORD32 ) ( ( unsigned ) p [ 3 ] << 8 | p [ 2 ] ) << 16 | ( ( unsigned ) p [ 1 ] << 8 | p [ 0 ] ) ; p += 4 ; } while ( -- words ) ; } "," static ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 640,CWE-120,"CWE-120 uint8_t ethereum_extractThorchainData ( const EthereumSignTx * msg , char * buffer ) { uint16_t offset = 4 + ( 5 * 32 ) ; int16_t len = msg -> data_length - offset ; if ( msg -> has_data_length && len > 0 ) { memcpy ( buffer , msg -> data_initial_chunk . bytes + offset , len ) ; return len < 256 ? ( uint8_t ) len : 0 ; } return 0 ; } "," len > 0 && len < 256 ) ; return ( uint8_t ) uint8_t ) len ; } return ",keepkey@keepkey-firmware/e49d45594002d4d3fbc1f03488e6dfc0a0a65836,CVE-2021-31616,https://github.com/keepkey/keepkey-firmware/commit/e49d45594002d4d3fbc1f03488e6dfc0a0a65836,2021-05-06T13:15Z 641,CWE-284,"CWE-284 static MYSQL * db_connect ( char * host , char * database , char * user , char * passwd ) { MYSQL * mysql ; if ( verbose ) fprintf ( stdout , ""Connectingto%s\\n"" , host ? host : ""localhost"" ) ; if ( ! ( mysql = mysql_init ( NULL ) ) ) return 0 ; if ( opt_compress ) mysql_options ( mysql , MYSQL_OPT_COMPRESS , NullS ) ; if ( opt_local_file ) mysql_options ( mysql , MYSQL_OPT_LOCAL_INFILE , ( char * ) & opt_local_file ) ; # ifdef HAVE_OPENSSL if ( opt_use_ssl ) { mysql_ssl_set ( mysql , opt_ssl_key , opt_ssl_cert , opt_ssl_ca , opt_ssl_capath , opt_ssl_cipher ) ; mysql_options ( mysql , MYSQL_OPT_SSL_CRL , opt_ssl_crl ) ; mysql_options ( mysql , MYSQL_OPT_SSL_CRLPATH , opt_ssl_crlpath ) ; } mysql_options ( mysql , MYSQL_OPT_SSL_VERIFY_SERVER_CERT , ( char * ) & opt_ssl_verify_server_cert ) ; # endif if ( opt_protocol ) mysql_options ( mysql , MYSQL_OPT_PROTOCOL , ( char * ) & opt_protocol ) ; if ( opt_bind_addr ) mysql_options ( mysql , MYSQL_OPT_BIND , opt_bind_addr ) ; # if defined ( _WIN32 ) && ! defined ( EMBEDDED_LIBRARY ) if ( shared_memory_base_name ) mysql_options ( mysql , MYSQL_SHARED_MEMORY_BASE_NAME , shared_memory_base_name ) ; # endif if ( opt_plugin_dir && * opt_plugin_dir ) mysql_options ( mysql , MYSQL_PLUGIN_DIR , opt_plugin_dir ) ; if ( opt_default_auth && * opt_default_auth ) mysql_options ( mysql , MYSQL_DEFAULT_AUTH , opt_default_auth ) ; mysql_options ( mysql , MYSQL_SET_CHARSET_NAME , default_charset ) ; mysql_options ( mysql , MYSQL_OPT_CONNECT_ATTR_RESET , 0 ) ; mysql_options4 ( mysql , MYSQL_OPT_CONNECT_ATTR_ADD , ""program_name"" , ""mysqlimport"" ) ; if ( ! ( mysql_real_connect ( mysql , host , user , passwd , database , opt_mysql_port , opt_mysql_unix_port , 0 ) ) ) { ignore_errors = 0 ; db_error ( mysql ) ; } mysql -> reconnect = 0 ; if ( verbose ) fprintf ( stdout , ""Selectingdatabase%s\\n"" , database ) ; if ( mysql_select_db ( mysql , database ) ) { ignore_errors = 0 ; db_error ( mysql ) ; } return mysql ; } "," opt_local_file ) ; SSL_SET_OPTIONS ( mysql ) ; if ( opt_protocol ",mysql@mysql-server/3bd5589e1a5a93f9c224badf983cd65c45215390,CVE-2015-3152,https://github.com/mysql/mysql-server/commit/3bd5589e1a5a93f9c224badf983cd65c45215390,2016-05-16T10:59Z 642,CWE-190,"CWE-190 static int isoent_gen_joliet_identifier ( struct archive_write * a , struct isoent * isoent , struct idr * idr ) { struct iso9660 * iso9660 ; struct isoent * np ; unsigned char * p ; size_t l ; int r ; int ffmax , parent_len ; static const struct archive_rb_tree_ops rb_ops = { isoent_cmp_node_joliet , isoent_cmp_key_joliet } ; if ( isoent -> children . cnt == 0 ) return ( 0 ) ; iso9660 = a -> format_data ; if ( iso9660 -> opt . joliet == OPT_JOLIET_LONGNAME ) ffmax = 206 ; else ffmax = 128 ; r = idr_start ( a , idr , isoent -> children . cnt , ffmax , 6 , 2 , & rb_ops ) ; if ( r < 0 ) return ( r ) ; parent_len = 1 ; for ( np = isoent ; np -> parent != np ; np = np -> parent ) parent_len += np -> mb_len + 1 ; for ( np = isoent -> children . first ; np != NULL ; np = np -> chnext ) { unsigned char * dot ; int ext_off , noff , weight ; size_t lt ; if ( ( int ) ( l = np -> file -> basename_utf16 . length ) > ffmax ) l = ffmax ; p = malloc ( ( l + 1 ) * 2 ) ; if ( p == NULL ) { archive_set_error ( & a -> archive , ENOMEM , ""Can\'tallocatememory"" ) ; return ( ARCHIVE_FATAL ) ; } memcpy ( p , np -> file -> basename_utf16 . s , l ) ; p [ l ] = 0 ; p [ l + 1 ] = 0 ; np -> identifier = ( char * ) p ; lt = l ; dot = p + l ; weight = 0 ; while ( lt > 0 ) { if ( ! joliet_allowed_char ( p [ 0 ] , p [ 1 ] ) ) archive_be16enc ( p , 0x005F ) ; else if ( p [ 0 ] == 0 && p [ 1 ] == 0x2E ) dot = p ; p += 2 ; lt -= 2 ; } ext_off = ( int ) ( dot - ( unsigned char * ) np -> identifier ) ; np -> ext_off = ext_off ; np -> ext_len = ( int ) l - ext_off ; np -> id_len = ( int ) l ; if ( ( int ) np -> file -> basename_utf16 . length > ffmax ) { if ( archive_strncpy_l ( & iso9660 -> mbs , ( const char * ) np -> identifier , l , iso9660 -> sconv_from_utf16be ) != 0 && errno == ENOMEM ) { archive_set_error ( & a -> archive , errno , ""Nomemory"" ) ; return ( ARCHIVE_FATAL ) ; } np -> mb_len = ( int ) iso9660 -> mbs . length ; if ( np -> mb_len != ( int ) np -> file -> basename . length ) weight = np -> mb_len ; } else np -> mb_len = ( int ) np -> file -> basename . length ; if ( parent_len + np -> mb_len > 240 ) { archive_set_error ( & a -> archive , ARCHIVE_ERRNO_MISC , ""TheregulationofJolietextensions;"" ""Alengthofafull-pathnameof`%s\'is"" ""longerthan240bytes,(p=%d,b=%d)"" , archive_entry_pathname ( np -> file -> entry ) , ( int ) parent_len , ( int ) np -> mb_len ) ; return ( ARCHIVE_FATAL ) ; } if ( ( int ) l == ffmax ) noff = ext_off - 6 ; else if ( ( int ) l == ffmax - 2 ) noff = ext_off - 4 ; else if ( ( int ) l == ffmax - 4 ) noff = ext_off - 2 ; else noff = ext_off ; idr_register ( idr , np , weight , noff ) ; } idr_resolve ( idr , idr_set_num_beutf16 ) ; return ( ARCHIVE_OK ) ; } "," int r ; size_t ffmax , parent_len . cnt , ( int ) if ( ( l = np ; if ( np -> file if ( parent_len > 240 || np -> mb_len mb_len > 240 || parent_len + np -> mb_len > 240 } if ( l == ffmax else if ( l == ffmax else if ( l == ffmax ",libarchive@libarchive/3014e19820ea53c15c90f9d447ca3e668a0b76c6,CVE-2016-6250,https://github.com/libarchive/libarchive/commit/3014e198,2016-09-21T14:25Z 643,CWE-119,"CWE-119 int vp8_set_active_map ( VP8_COMP * cpi , unsigned char * map , unsigned int rows , unsigned int cols ) { if ( rows == cpi -> common . mb_rows && cols == cpi -> common . mb_cols ) { if ( map ) { vpx_memcpy ( cpi -> active_map , map , rows * cols ) ; cpi -> active_map_enabled = 1 ; } else cpi -> active_map_enabled = 0 ; return 0 ; } else { return - 1 ; } } "," map ) { memcpy ( cpi -> ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 644,CWE-264,"CWE-264 void ion_free ( struct ion_client * client , struct ion_handle * handle ) { bool valid_handle ; BUG_ON ( client != handle -> client ) ; mutex_lock ( & client -> lock ) ; valid_handle = ion_handle_validate ( client , handle ) ; if ( ! valid_handle ) { WARN ( 1 , ""%s:invalidhandlepassedtofree.\\n"" , __func__ ) ; mutex_unlock ( & client -> lock ) ; return ; } mutex_unlock ( & client -> lock ) ; ion_handle_put ( handle ) ; } "," handle ) { BUG_ON ( client lock ) ; ion_free_nolock ( client , client , handle ) ; mutex_unlock lock ) ; } ",torvalds@linux/9590232bb4f4cc824f3425a6e1349afbe6d6d2b7,CVE-2016-9120,https://github.com/torvalds/linux/commit/9590232bb4f4cc824f3425a6e1349afbe6d6d2b7,2016-12-08T21:59Z 645,CWE-400,"CWE-400 static void umount_tree ( struct mount * mnt , enum umount_tree_flags how ) { LIST_HEAD ( tmp_list ) ; struct mount * p ; if ( how & UMOUNT_PROPAGATE ) propagate_mount_unlock ( mnt ) ; for ( p = mnt ; p ; p = next_mnt ( p , mnt ) ) { p -> mnt . mnt_flags |= MNT_UMOUNT ; list_move ( & p -> mnt_list , & tmp_list ) ; } list_for_each_entry ( p , & tmp_list , mnt_list ) { list_del_init ( & p -> mnt_child ) ; } if ( how & UMOUNT_PROPAGATE ) propagate_umount ( & tmp_list ) ; while ( ! list_empty ( & tmp_list ) ) { bool disconnect ; p = list_first_entry ( & tmp_list , struct mount , mnt_list ) ; list_del_init ( & p -> mnt_expire ) ; list_del_init ( & p -> mnt_list ) ; __touch_mnt_namespace ( p -> mnt_ns ) ; p -> mnt_ns = NULL ; if ( how & UMOUNT_SYNC ) p -> mnt . mnt_flags |= MNT_SYNC_UMOUNT ; disconnect = disconnect_mount ( p , how ) ; pin_insert_group ( & p -> mnt_umount , & p -> mnt_parent -> mnt , disconnect ? & unmounted : NULL ) ; if ( mnt_has_parent ( p ) ) { mnt_add_count ( p -> mnt_parent , - 1 ) ; if ( ! disconnect ) { list_add_tail ( & p -> mnt_child , & p -> mnt_parent -> mnt_mounts ) ; } else { umount_mnt ( p ) ; } } change_mnt_propagation ( p , MS_PRIVATE ) ; } } "," ) ) { struct mnt_namespace * ns ; mnt_list ) ; ns = p -> mnt_ns ; if ( ns ) { ns -> mounts -- ; __touch_mnt_namespace ( ns ) ; } p -> mnt_ns ",torvalds@linux/d29216842a85c7970c536108e093963f02714498,CVE-2016-6213,https://github.com/torvalds/linux/commit/d29216842a85c7970c536108e093963f02714498,2016-12-28T07:59Z 646,CWE-119,"CWE-119 static void show_object ( struct object * object , struct strbuf * path , const char * last , void * data ) { struct bitmap * base = data ; bitmap_set ( base , find_object_pos ( object -> oid . hash ) ) ; mark_as_seen ( object ) ; } "," * object , const char * const char * name , void * ",git@git/de1e67d0703894cb6ea782e36abb63976ab07e60,CVE-2016-2324,https://github.com/git/git/commit/de1e67d0703894cb6ea782e36abb63976ab07e60,2016-04-08T14:59Z 647,CWE-119,"CWE-119 static void tree_to_node ( void * data , BLOCK_SIZE bsize , variance_node * node ) { int i ; switch ( bsize ) { case BLOCK_64X64 : { v64x64 * vt = ( v64x64 * ) data ; node -> part_variances = & vt -> part_variances ; for ( i = 0 ; i < 4 ; i ++ ) node -> split [ i ] = & vt -> split [ i ] . part_variances . none ; break ; } case BLOCK_32X32 : { v32x32 * vt = ( v32x32 * ) data ; node -> part_variances = & vt -> part_variances ; for ( i = 0 ; i < 4 ; i ++ ) node -> split [ i ] = & vt -> split [ i ] . part_variances . none ; break ; } case BLOCK_16X16 : { v16x16 * vt = ( v16x16 * ) data ; node -> part_variances = & vt -> part_variances ; for ( i = 0 ; i < 4 ; i ++ ) node -> split [ i ] = & vt -> split [ i ] . part_variances . none ; break ; } case BLOCK_8X8 : { v8x8 * vt = ( v8x8 * ) data ; node -> part_variances = & vt -> part_variances ; for ( i = 0 ; i < 4 ; i ++ ) node -> split [ i ] = & vt -> split [ i ] ; break ; } default : { assert ( 0 ) ; } } } "," int i ; node -> part_variances = NULL ; [ i ] . part_variances . none ; break ; } case BLOCK_4X4 : { v4x4 * vt = ( v4x4 * ) data ; node -> part_variances = & vt -> part_variances ; for ( i = 0 ; i < 4 ; i ++ ) node -> split [ i ] = & vt -> split [ i ] 0 ) ; break ; ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 648,CWE-119,"CWE-119 static void copy_and_extend_plane ( const uint8_t * src , int src_pitch , uint8_t * dst , int dst_pitch , int w , int h , int extend_top , int extend_left , int extend_bottom , int extend_right ) { int i , linesize ; const uint8_t * src_ptr1 = src ; const uint8_t * src_ptr2 = src + w - 1 ; uint8_t * dst_ptr1 = dst - extend_left ; uint8_t * dst_ptr2 = dst + w ; for ( i = 0 ; i < h ; i ++ ) { vpx_memset ( dst_ptr1 , src_ptr1 [ 0 ] , extend_left ) ; vpx_memcpy ( dst_ptr1 + extend_left , src_ptr1 , w ) ; vpx_memset ( dst_ptr2 , src_ptr2 [ 0 ] , extend_right ) ; src_ptr1 += src_pitch ; src_ptr2 += src_pitch ; dst_ptr1 += dst_pitch ; dst_ptr2 += dst_pitch ; } src_ptr1 = dst - extend_left ; src_ptr2 = dst + dst_pitch * ( h - 1 ) - extend_left ; dst_ptr1 = dst + dst_pitch * ( - extend_top ) - extend_left ; dst_ptr2 = dst + dst_pitch * ( h ) - extend_left ; linesize = extend_left + extend_right + w ; for ( i = 0 ; i < extend_top ; i ++ ) { vpx_memcpy ( dst_ptr1 , src_ptr1 , linesize ) ; dst_ptr1 += dst_pitch ; } for ( i = 0 ; i < extend_bottom ; i ++ ) { vpx_memcpy ( dst_ptr2 , src_ptr2 , linesize ) ; dst_ptr2 += dst_pitch ; } } "," ++ ) { memset ( dst_ptr1 , extend_left ) ; memcpy ( dst_ptr1 + extend_left , src_ptr1 , w ) ; memset ( dst_ptr2 , ++ ) { memcpy ( dst_ptr1 , ++ ) { memcpy ( dst_ptr2 , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 649,CWE-476,"CWE-476 RCMS * r_pkcs7_parse_cms ( const ut8 * buffer , ut32 length ) { RASN1Object * object ; RCMS * container ; if ( ! buffer || ! length ) { return NULL ; } container = R_NEW0 ( RCMS ) ; if ( ! container ) { return NULL ; } object = r_asn1_create_object ( buffer , length ) ; if ( ! object || object -> list . length != 2 || ! object -> list . objects [ 0 ] || object -> list . objects [ 1 ] -> list . length != 1 ) { r_asn1_free_object ( object ) ; free ( container ) ; return NULL ; } container -> contentType = r_asn1_stringify_oid ( object -> list . objects [ 0 ] -> sector , object -> list . objects [ 0 ] -> length ) ; r_pkcs7_parse_signeddata ( & container -> signedData , object -> list . objects [ 1 ] -> list . objects [ 0 ] ) ; r_asn1_free_object ( object ) ; return container ; } "," list . objects || ! object -> list . objects [ 0 ] || ! object -> list . objects [ 1 ] || object -> list ",radare@radare2/7ab66cca5bbdf6cb2d69339ef4f513d95e532dbf,CVE-2017-7274,https://github.com/radare/radare2/commit/7ab66cca5bbdf6cb2d69339ef4f513d95e532dbf,2017-03-27T17:59Z 650,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 651,CWE-20,"CWE-20 error_t dm9000ReceivePacket ( NetInterface * interface ) { error_t error ; size_t i ; size_t n ; size_t length ; volatile uint8_t status ; volatile uint16_t data ; Dm9000Context * context ; context = ( Dm9000Context * ) interface -> nicContext ; data = dm9000ReadReg ( DM9000_REG_MRCMDX ) ; DM9000_INDEX_REG = DM9000_REG_MRCMDX1 ; status = LSB ( DM9000_DATA_REG ) ; if ( status == 0x01 ) { DM9000_INDEX_REG = DM9000_REG_MRCMD ; status = MSB ( DM9000_DATA_REG ) ; length = DM9000_DATA_REG ; n = MIN ( length , ETH_MAX_FRAME_SIZE ) ; i = 0 ; if ( ( status & ( RSR_LCS | RSR_RWTO | RSR_PLE | RSR_AE | RSR_CE | RSR_FOE ) ) == 0 ) { while ( ( i + 1 ) < n ) { data = DM9000_DATA_REG ; context -> rxBuffer [ i ++ ] = LSB ( data ) ; context -> rxBuffer [ i ++ ] = MSB ( data ) ; } if ( ( i + 1 ) == n ) { data = DM9000_DATA_REG ; context -> rxBuffer [ i ] = LSB ( data ) ; i += 2 ; } error = NO_ERROR ; } else { error = ERROR_INVALID_PACKET ; } while ( i < length ) { data = DM9000_DATA_REG ; i += 2 ; } } else { error = ERROR_BUFFER_EMPTY ; } if ( ! error ) { NetRxAncillary ancillary ; ancillary = NET_DEFAULT_RX_ANCILLARY ; nicProcessPacket ( interface , context -> rxBuffer , n , & ancillary ) ; } return error ; } "," = dm9000ReadReg ( DM9000_MRCMDX ) ; DM9000_INDEX_REG ; DM9000_INDEX_REG = DM9000_MRCMDX1 ; status = { DM9000_INDEX_REG = DM9000_MRCMD ; status = status & ( DM9000_RSR_LCS | DM9000_RSR_RWTO | DM9000_RSR_PLE | DM9000_RSR_AE | DM9000_RSR_CE | DM9000_RSR_FOE ) ) == ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 652,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 ; 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 ? _Ta3_asdl_seq_new ( nposargs , c -> c_arena ) : NULL ) ; if ( ! posargs && nposargs ) return NULL ; kwonlyargs = ( nkwonlyargs ? _Ta3_asdl_seq_new ( nkwonlyargs , c -> c_arena ) : NULL ) ; if ( ! kwonlyargs && nkwonlyargs ) return NULL ; posdefaults = ( nposdefaults ? _Ta3_asdl_seq_new ( nposdefaults , c -> c_arena ) : NULL ) ; if ( ! posdefaults && nposdefaults ) return NULL ; kwdefaults = ( nkwonlyargs ? _Ta3_asdl_seq_new ( nkwonlyargs , c -> c_arena ) : NULL ) ; if ( ! kwdefaults && nkwonlyargs ) return NULL ; if ( nposargs + nkwonlyargs > 255 ) { ast_error ( c , n , ""morethan255arguments"" ) ; 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 ) ) ; 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 ( i < NCH ( n ) && TYPE ( CHILD ( n , i ) ) == COMMA ) i += 1 ; break ; case TYPE_COMMENT : assert ( i ) ; if ( kwarg ) arg = kwarg ; arg -> type_comment = NEW_TYPE_COMMENT ( ch ) ; 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 ) ; } "," return NULL ; i = 0 ; if ( TYPE ( CHILD ; if ( TYPE ( CHILD ; if ( TYPE ( CHILD ; if ( TYPE ( CHILD ; if ( TYPE ( CHILD ",python@typed_ast/156afcb26c198e162504a57caddfe0acd9ed7dce,CVE-2019-19275,https://github.com/python/typed_ast/commit/156afcb26c198e162504a57caddfe0acd9ed7dce,2019-11-26T15:15Z 653,CWE-200,"CWE-200 void __detach_mounts ( struct dentry * dentry ) { struct mountpoint * mp ; struct mount * mnt ; namespace_lock ( ) ; mp = lookup_mountpoint ( dentry ) ; if ( IS_ERR_OR_NULL ( mp ) ) goto out_unlock ; lock_mount_hash ( ) ; while ( ! hlist_empty ( & mp -> m_list ) ) { mnt = hlist_entry ( mp -> m_list . first , struct mount , mnt_mp_list ) ; if ( mnt -> mnt . mnt_flags & MNT_UMOUNT ) { struct mount * p , * tmp ; list_for_each_entry_safe ( p , tmp , & mnt -> mnt_mounts , mnt_child ) { hlist_add_head ( & p -> mnt_umount . s_list , & unmounted ) ; umount_mnt ( p ) ; } } else umount_tree ( mnt , 0 ) ; } unlock_mount_hash ( ) ; put_mountpoint ( mp ) ; out_unlock : namespace_unlock ( ) ; } "," ( mnt , UMOUNT_CONNECTED ) ; } ",torvalds@linux/e0c9c0afd2fc958ffa34b697972721d81df8a56f,CVE-2015-4176,https://github.com/torvalds/linux/commit/e0c9c0afd2fc958ffa34b697972721d81df8a56f,2016-05-02T10:59Z 654,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 655,CWE-125,"CWE-125 static void nfnetlink_rcv_batch ( struct sk_buff * skb , struct nlmsghdr * nlh , u_int16_t subsys_id ) { struct sk_buff * oskb = skb ; struct net * net = sock_net ( skb -> sk ) ; const struct nfnetlink_subsystem * ss ; const struct nfnl_callback * nc ; static LIST_HEAD ( err_list ) ; u32 status ; int err ; if ( subsys_id >= NFNL_SUBSYS_COUNT ) return netlink_ack ( skb , nlh , - EINVAL ) ; replay : status = 0 ; skb = netlink_skb_clone ( oskb , GFP_KERNEL ) ; if ( ! skb ) return netlink_ack ( oskb , nlh , - ENOMEM ) ; nfnl_lock ( subsys_id ) ; ss = nfnl_dereference_protected ( subsys_id ) ; if ( ! ss ) { # ifdef CONFIG_MODULES nfnl_unlock ( subsys_id ) ; request_module ( ""nfnetlink-subsys-%d"" , subsys_id ) ; nfnl_lock ( subsys_id ) ; ss = nfnl_dereference_protected ( subsys_id ) ; if ( ! ss ) # endif { nfnl_unlock ( subsys_id ) ; netlink_ack ( oskb , nlh , - EOPNOTSUPP ) ; return kfree_skb ( skb ) ; } } if ( ! ss -> commit || ! ss -> abort ) { nfnl_unlock ( subsys_id ) ; netlink_ack ( oskb , nlh , - EOPNOTSUPP ) ; return kfree_skb ( skb ) ; } while ( skb -> len >= nlmsg_total_size ( 0 ) ) { int msglen , type ; nlh = nlmsg_hdr ( skb ) ; err = 0 ; if ( nlmsg_len ( nlh ) < sizeof ( struct nfgenmsg ) || skb -> len < nlh -> nlmsg_len ) { err = - EINVAL ; goto ack ; } if ( ! ( nlh -> nlmsg_flags & NLM_F_REQUEST ) ) { err = - EINVAL ; goto ack ; } type = nlh -> nlmsg_type ; if ( type == NFNL_MSG_BATCH_BEGIN ) { nfnl_err_reset ( & err_list ) ; status |= NFNL_BATCH_FAILURE ; goto done ; } else if ( type == NFNL_MSG_BATCH_END ) { status |= NFNL_BATCH_DONE ; goto done ; } else if ( type < NLMSG_MIN_TYPE ) { err = - EINVAL ; goto ack ; } if ( NFNL_SUBSYS_ID ( type ) != subsys_id ) { err = - EINVAL ; goto ack ; } nc = nfnetlink_find_client ( type , ss ) ; if ( ! nc ) { err = - EINVAL ; goto ack ; } { int min_len = nlmsg_total_size ( sizeof ( struct nfgenmsg ) ) ; u_int8_t cb_id = NFNL_MSG_TYPE ( nlh -> nlmsg_type ) ; struct nlattr * cda [ ss -> cb [ cb_id ] . attr_count + 1 ] ; struct nlattr * attr = ( void * ) nlh + min_len ; int attrlen = nlh -> nlmsg_len - min_len ; err = nla_parse ( cda , ss -> cb [ cb_id ] . attr_count , attr , attrlen , ss -> cb [ cb_id ] . policy ) ; if ( err < 0 ) goto ack ; if ( nc -> call_batch ) { err = nc -> call_batch ( net , net -> nfnl , skb , nlh , ( const struct nlattr * * ) cda ) ; } if ( err == - EAGAIN ) { status |= NFNL_BATCH_REPLAY ; goto next ; } } ack : if ( nlh -> nlmsg_flags & NLM_F_ACK || err ) { if ( nfnl_err_add ( & err_list , nlh , err ) < 0 ) { nfnl_err_reset ( & err_list ) ; netlink_ack ( oskb , nlmsg_hdr ( oskb ) , - ENOMEM ) ; status |= NFNL_BATCH_FAILURE ; goto done ; } if ( err ) status |= NFNL_BATCH_FAILURE ; } next : msglen = NLMSG_ALIGN ( nlh -> nlmsg_len ) ; if ( msglen > skb -> len ) msglen = skb -> len ; skb_pull ( skb , msglen ) ; } done : if ( status & NFNL_BATCH_REPLAY ) { ss -> abort ( net , oskb ) ; nfnl_err_reset ( & err_list ) ; nfnl_unlock ( subsys_id ) ; kfree_skb ( skb ) ; goto replay ; } else if ( status == NFNL_BATCH_DONE ) { ss -> commit ( net , oskb ) ; } else { ss -> abort ( net , oskb ) ; } nfnl_err_deliver ( & err_list , oskb ) ; nfnl_unlock ( subsys_id ) ; kfree_skb ( skb ) ; } "," ; if ( nlh -> nlmsg_len < NLMSG_HDRLEN || skb -> len < nlh -> nlmsg_len || struct nfgenmsg ) ) { nfnl_err_reset ( & err_list ) ; status |= NFNL_BATCH_FAILURE ; goto done ; } if ",torvalds@linux/c58d6c93680f28ac58984af61d0a7ebf4319c241,CVE-2016-7917,https://github.com/torvalds/linux/commit/c58d6c93680f28ac58984af61d0a7ebf4319c241,2016-11-16T05:59Z 656,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 657,CWE-399,"CWE-399 static int ape_read_header ( AVFormatContext * s , AVFormatParameters * ap ) { AVIOContext * pb = s -> pb ; APEContext * ape = s -> priv_data ; AVStream * st ; uint32_t tag ; int i ; int total_blocks ; int64_t pts ; ape -> junklength = 0 ; tag = avio_rl32 ( pb ) ; if ( tag != MKTAG ( 'M' , 'A' , 'C' , '' ) ) return - 1 ; ape -> fileversion = avio_rl16 ( pb ) ; if ( ape -> fileversion < APE_MIN_VERSION || ape -> fileversion > APE_MAX_VERSION ) { av_log ( s , AV_LOG_ERROR , ""Unsupportedfileversion-%d.%02d\\n"" , ape -> fileversion / 1000 , ( ape -> fileversion % 1000 ) / 10 ) ; return - 1 ; } if ( ape -> fileversion >= 3980 ) { ape -> padding1 = avio_rl16 ( pb ) ; ape -> descriptorlength = avio_rl32 ( pb ) ; ape -> headerlength = avio_rl32 ( pb ) ; ape -> seektablelength = avio_rl32 ( pb ) ; ape -> wavheaderlength = avio_rl32 ( pb ) ; ape -> audiodatalength = avio_rl32 ( pb ) ; ape -> audiodatalength_high = avio_rl32 ( pb ) ; ape -> wavtaillength = avio_rl32 ( pb ) ; avio_read ( pb , ape -> md5 , 16 ) ; if ( ape -> descriptorlength > 52 ) avio_seek ( pb , ape -> descriptorlength - 52 , SEEK_CUR ) ; ape -> compressiontype = avio_rl16 ( pb ) ; ape -> formatflags = avio_rl16 ( pb ) ; ape -> blocksperframe = avio_rl32 ( pb ) ; ape -> finalframeblocks = avio_rl32 ( pb ) ; ape -> totalframes = avio_rl32 ( pb ) ; ape -> bps = avio_rl16 ( pb ) ; ape -> channels = avio_rl16 ( pb ) ; ape -> samplerate = avio_rl32 ( pb ) ; } else { ape -> descriptorlength = 0 ; ape -> headerlength = 32 ; ape -> compressiontype = avio_rl16 ( pb ) ; ape -> formatflags = avio_rl16 ( pb ) ; ape -> channels = avio_rl16 ( pb ) ; ape -> samplerate = avio_rl32 ( pb ) ; ape -> wavheaderlength = avio_rl32 ( pb ) ; ape -> wavtaillength = avio_rl32 ( pb ) ; ape -> totalframes = avio_rl32 ( pb ) ; ape -> finalframeblocks = avio_rl32 ( pb ) ; if ( ape -> formatflags & MAC_FORMAT_FLAG_HAS_PEAK_LEVEL ) { avio_seek ( pb , 4 , SEEK_CUR ) ; ape -> headerlength += 4 ; } if ( ape -> formatflags & MAC_FORMAT_FLAG_HAS_SEEK_ELEMENTS ) { ape -> seektablelength = avio_rl32 ( pb ) ; ape -> headerlength += 4 ; ape -> seektablelength *= sizeof ( int32_t ) ; } else ape -> seektablelength = ape -> totalframes * sizeof ( int32_t ) ; if ( ape -> formatflags & MAC_FORMAT_FLAG_8_BIT ) ape -> bps = 8 ; else if ( ape -> formatflags & MAC_FORMAT_FLAG_24_BIT ) ape -> bps = 24 ; else ape -> bps = 16 ; if ( ape -> fileversion >= 3950 ) ape -> blocksperframe = 73728 * 4 ; else if ( ape -> fileversion >= 3900 || ( ape -> fileversion >= 3800 && ape -> compressiontype >= 4000 ) ) ape -> blocksperframe = 73728 ; else ape -> blocksperframe = 9216 ; if ( ! ( ape -> formatflags & MAC_FORMAT_FLAG_CREATE_WAV_HEADER ) ) avio_seek ( pb , ape -> wavheaderlength , SEEK_CUR ) ; } if ( ape -> totalframes > UINT_MAX / sizeof ( APEFrame ) ) { av_log ( s , AV_LOG_ERROR , ""Toomanyframes:%d\\n"" , ape -> totalframes ) ; return - 1 ; } ape -> frames = av_malloc ( ape -> totalframes * sizeof ( APEFrame ) ) ; if ( ! ape -> frames ) return AVERROR ( ENOMEM ) ; ape -> firstframe = ape -> junklength + ape -> descriptorlength + ape -> headerlength + ape -> seektablelength + ape -> wavheaderlength ; ape -> currentframe = 0 ; ape -> totalsamples = ape -> finalframeblocks ; if ( ape -> totalframes > 1 ) ape -> totalsamples += ape -> blocksperframe * ( ape -> totalframes - 1 ) ; if ( ape -> seektablelength > 0 ) { ape -> seektable = av_malloc ( ape -> seektablelength ) ; for ( i = 0 ; i < ape -> seektablelength / sizeof ( uint32_t ) ; i ++ ) ape -> seektable [ i ] = avio_rl32 ( pb ) ; } ape -> frames [ 0 ] . pos = ape -> firstframe ; ape -> frames [ 0 ] . nblocks = ape -> blocksperframe ; ape -> frames [ 0 ] . skip = 0 ; for ( i = 1 ; i < ape -> totalframes ; i ++ ) { ape -> frames [ i ] . pos = ape -> seektable [ i ] ; ape -> frames [ i ] . nblocks = ape -> blocksperframe ; ape -> frames [ i - 1 ] . size = ape -> frames [ i ] . pos - ape -> frames [ i - 1 ] . pos ; ape -> frames [ i ] . skip = ( ape -> frames [ i ] . pos - ape -> frames [ 0 ] . pos ) & 3 ; } ape -> frames [ ape -> totalframes - 1 ] . size = ape -> finalframeblocks * 4 ; ape -> frames [ ape -> totalframes - 1 ] . nblocks = ape -> finalframeblocks ; for ( i = 0 ; i < ape -> totalframes ; i ++ ) { if ( ape -> frames [ i ] . skip ) { ape -> frames [ i ] . pos -= ape -> frames [ i ] . skip ; ape -> frames [ i ] . size += ape -> frames [ i ] . skip ; } ape -> frames [ i ] . size = ( ape -> frames [ i ] . size + 3 ) & ~ 3 ; } ape_dumpinfo ( s , ape ) ; if ( ! url_is_streamed ( pb ) ) { ff_ape_parse_tag ( s ) ; avio_seek ( pb , 0 , SEEK_SET ) ; } av_log ( s , AV_LOG_DEBUG , ""Decodingfile-v%d.%02d,compressionlevel%d\\n"" , ape -> fileversion / 1000 , ( ape -> fileversion % 1000 ) / 10 , ape -> compressiontype ) ; st = av_new_stream ( s , 0 ) ; if ( ! st ) return - 1 ; total_blocks = ( ape -> totalframes == 0 ) ? 0 : ( ( ape -> totalframes - 1 ) * ape -> blocksperframe ) + ape -> finalframeblocks ; st -> codec -> codec_type = AVMEDIA_TYPE_AUDIO ; st -> codec -> codec_id = CODEC_ID_APE ; st -> codec -> codec_tag = MKTAG ( 'A' , 'P' , 'E' , '' ) ; st -> codec -> channels = ape -> channels ; st -> codec -> sample_rate = ape -> samplerate ; st -> codec -> bits_per_coded_sample = ape -> bps ; st -> codec -> frame_size = MAC_SUBFRAME_SIZE ; st -> nb_frames = ape -> totalframes ; st -> start_time = 0 ; st -> duration = total_blocks / MAC_SUBFRAME_SIZE ; av_set_pts_info ( st , 64 , MAC_SUBFRAME_SIZE , ape -> samplerate ) ; st -> codec -> extradata = av_malloc ( APE_EXTRADATA_SIZE ) ; st -> codec -> extradata_size = APE_EXTRADATA_SIZE ; AV_WL16 ( st -> codec -> extradata + 0 , ape -> fileversion ) ; AV_WL16 ( st -> codec -> extradata + 2 , ape -> compressiontype ) ; AV_WL16 ( st -> codec -> extradata + 4 , ape -> formatflags ) ; pts = 0 ; for ( i = 0 ; i < ape -> totalframes ; i ++ ) { ape -> frames [ i ] . pts = pts ; av_add_index_entry ( st , ape -> frames [ i ] . pos , ape -> frames [ i ] . pts , 0 , 0 , AVINDEX_KEYFRAME ) ; pts += ape -> blocksperframe / MAC_SUBFRAME_SIZE ; } return 0 ; } "," } if ( ! ape -> totalframes ) { av_log ( s , AV_LOG_ERROR , ""Noframesinthefile!\\n"" ) ; return AVERROR ( EINVAL ) ; } if ( ",FFmpeg@FFmpeg/8312e3fc9041027a33c8bc667bb99740fdf41dd5,CVE-2011-2161,https://github.com/FFmpeg/FFmpeg/commit/8312e3fc9041027a33c8bc667bb99740fdf41dd5,2011-05-20T22:55Z 658,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 659,CWE-119,"CWE-119 static int prob_diff_update_cost ( vp9_prob newp , vp9_prob oldp ) { int delp = remap_prob ( newp , oldp ) ; return update_bits [ delp ] * 256 ; } "," int prob_diff_update_cost ( vpx_prob newp , vpx_prob oldp ) { ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 660,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 661,CWE-000,"CWE-000 static int parseFileInner ( MaState * state , cchar * path ) { MaDirective * directive ; char * tok , * key , * line , * value ; assert ( state ) ; assert ( path && * path ) ; if ( openConfig ( state , path ) < 0 ) { return MPR_ERR_CANT_OPEN ; } for ( state -> lineNumber = 1 ; state -> file && ( line = mprReadLine ( state -> file , 0 , NULL ) ) != 0 ; state -> lineNumber ++ ) { for ( tok = line ; isspace ( ( uchar ) * tok ) ; tok ++ ) ; if ( * tok == '\\0' || * tok == '#' ) { continue ; } state -> key = 0 ; key = getDirective ( line , & value ) ; if ( ! state -> enabled ) { if ( key [ 0 ] != '<' ) { continue ; } } if ( ( directive = mprLookupKey ( directives , key ) ) == 0 ) { mprLog ( ""errorappwebconfig"" , 0 , ""Unknowndirective\\""%s\\"".Atline%din%s"" , key , state -> lineNumber , state -> filename ) ; return MPR_ERR_BAD_SYNTAX ; } state -> key = key ; mprPauseGC ( ) ; if ( ( * directive ) ( state , key , value ) < 0 ) { mprResumeGC ( ) ; mprLog ( ""errorappwebconfig"" , 0 , ""Errorwithdirective\\""%s\\"".Atline%din%s"" , state -> key , state -> lineNumber , state -> filename ) ; return MPR_ERR_BAD_SYNTAX ; } mprResumeGC ( ) ; mprYield ( 0 ) ; state = state -> top -> current ; } if ( state -> prev && state -> file == state -> prev -> file ) { mprLog ( ""errorappwebconfig"" , 0 , ""Uncloseddirectivesin%s"" , state -> filename ) ; while ( state -> prev && state -> file == state -> prev -> file ) { state = state -> prev ; } } mprCloseFile ( state -> file ) ; return 0 ; } "," = 0 ; if ( ( & value ) ) == 0 ) { continue ; } if ( ! ",embedthis@appweb/7e6a925f5e86a19a7934a94bbd6959101d0b84eb,CVE-2014-9708,https://github.com/embedthis/appweb/commit/7e6a925f5e86a19a7934a94bbd6959101d0b84eb,2015-03-31T14:59Z 662,CWE-119,"CWE-119 static vpx_codec_err_t decoder_set_fb_fn ( vpx_codec_alg_priv_t * ctx , vpx_get_frame_buffer_cb_fn_t cb_get , vpx_release_frame_buffer_cb_fn_t cb_release , void * cb_priv ) { if ( cb_get == NULL || cb_release == NULL ) { return VPX_CODEC_INVALID_PARAM ; } else if ( ctx -> pbi == NULL ) { ctx -> get_ext_fb_cb = cb_get ; ctx -> release_ext_fb_cb = cb_release ; ctx -> ext_priv = cb_priv ; return VPX_CODEC_OK ; } return VPX_CODEC_ERROR ; } "," ( ctx -> frame_workers == NULL ) ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 663,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 664,CWE-000,"CWE-000 static int replace_map_fd_with_map_ptr ( struct verifier_env * env ) { struct bpf_insn * insn = env -> prog -> insnsi ; int insn_cnt = env -> prog -> len ; int i , j ; for ( i = 0 ; i < insn_cnt ; i ++ , insn ++ ) { if ( BPF_CLASS ( insn -> code ) == BPF_LDX && ( BPF_MODE ( insn -> code ) != BPF_MEM || insn -> imm != 0 ) ) { verbose ( ""BPF_LDXusesreservedfields\\n"" ) ; return - EINVAL ; } if ( BPF_CLASS ( insn -> code ) == BPF_STX && ( ( BPF_MODE ( insn -> code ) != BPF_MEM && BPF_MODE ( insn -> code ) != BPF_XADD ) || insn -> imm != 0 ) ) { verbose ( ""BPF_STXusesreservedfields\\n"" ) ; return - EINVAL ; } if ( insn [ 0 ] . code == ( BPF_LD | BPF_IMM | BPF_DW ) ) { struct bpf_map * map ; struct fd f ; if ( i == insn_cnt - 1 || insn [ 1 ] . code != 0 || insn [ 1 ] . dst_reg != 0 || insn [ 1 ] . src_reg != 0 || insn [ 1 ] . off != 0 ) { verbose ( ""invalidbpf_ld_imm64insn\\n"" ) ; return - EINVAL ; } if ( insn -> src_reg == 0 ) goto next_insn ; if ( insn -> src_reg != BPF_PSEUDO_MAP_FD ) { verbose ( ""unrecognizedbpf_ld_imm64insn\\n"" ) ; return - EINVAL ; } f = fdget ( insn -> imm ) ; map = __bpf_map_get ( f ) ; if ( IS_ERR ( map ) ) { verbose ( ""fd%disnotpointingtovalidbpf_map\\n"" , insn -> imm ) ; return PTR_ERR ( map ) ; } insn [ 0 ] . imm = ( u32 ) ( unsigned long ) map ; insn [ 1 ] . imm = ( ( u64 ) ( unsigned long ) map ) >> 32 ; for ( j = 0 ; j < env -> used_map_cnt ; j ++ ) if ( env -> used_maps [ j ] == map ) { fdput ( f ) ; goto next_insn ; } if ( env -> used_map_cnt >= MAX_USED_MAPS ) { fdput ( f ) ; return - E2BIG ; } env -> used_maps [ env -> used_map_cnt ++ ] = map ; bpf_map_inc ( map , false ) ; fdput ( f ) ; next_insn : insn ++ ; i ++ ; } } return 0 ; } "," E2BIG ; } map = bpf_map_inc ( map , false ) ; if ( IS_ERR ( map ) ) { fdput ( f ) ; return PTR_ERR ( map ) ; } = map ; fdput ( f ",torvalds@linux/92117d8443bc5afacc8d5ba82e541946310f106e,CVE-2016-4558,https://github.com/torvalds/linux/commit/92117d8443bc5afacc8d5ba82e541946310f106e,2016-05-23T10:59Z 665,CWE-476,"CWE-476 key_ref_t key_create_or_update ( key_ref_t keyring_ref , const char * type , const char * description , const void * payload , size_t plen , key_perm_t perm , unsigned long flags ) { struct keyring_index_key index_key = { . description = description , } ; struct key_preparsed_payload prep ; struct assoc_array_edit * edit ; const struct cred * cred = current_cred ( ) ; struct key * keyring , * key = NULL ; key_ref_t key_ref ; int ret ; index_key . type = key_type_lookup ( type ) ; if ( IS_ERR ( index_key . type ) ) { key_ref = ERR_PTR ( - ENODEV ) ; goto error ; } key_ref = ERR_PTR ( - EINVAL ) ; if ( ! index_key . type -> match || ! index_key . type -> instantiate || ( ! index_key . description && ! index_key . type -> preparse ) ) goto error_put_type ; keyring = key_ref_to_ptr ( keyring_ref ) ; key_check ( keyring ) ; key_ref = ERR_PTR ( - ENOTDIR ) ; if ( keyring -> type != & key_type_keyring ) goto error_put_type ; memset ( & prep , 0 , sizeof ( prep ) ) ; prep . data = payload ; prep . datalen = plen ; prep . quotalen = index_key . type -> def_datalen ; prep . trusted = flags & KEY_ALLOC_TRUSTED ; prep . expiry = TIME_T_MAX ; if ( index_key . type -> preparse ) { ret = index_key . type -> preparse ( & prep ) ; if ( ret < 0 ) { key_ref = ERR_PTR ( ret ) ; goto error_free_prep ; } if ( ! index_key . description ) index_key . description = prep . description ; key_ref = ERR_PTR ( - EINVAL ) ; if ( ! index_key . description ) goto error_free_prep ; } index_key . desc_len = strlen ( index_key . description ) ; key_ref = ERR_PTR ( - EPERM ) ; if ( ! prep . trusted && test_bit ( KEY_FLAG_TRUSTED_ONLY , & keyring -> flags ) ) goto error_free_prep ; flags |= prep . trusted ? KEY_ALLOC_TRUSTED : 0 ; ret = __key_link_begin ( keyring , & index_key , & edit ) ; if ( ret < 0 ) { key_ref = ERR_PTR ( ret ) ; goto error_free_prep ; } ret = key_permission ( keyring_ref , KEY_NEED_WRITE ) ; if ( ret < 0 ) { key_ref = ERR_PTR ( ret ) ; goto error_link_end ; } if ( index_key . type -> update ) { key_ref = find_key_to_update ( keyring_ref , & index_key ) ; if ( key_ref ) goto found_matching_key ; } if ( perm == KEY_PERM_UNDEF ) { perm = KEY_POS_VIEW | KEY_POS_SEARCH | KEY_POS_LINK | KEY_POS_SETATTR ; perm |= KEY_USR_VIEW ; if ( index_key . type -> read ) perm |= KEY_POS_READ ; if ( index_key . type == & key_type_keyring || index_key . type -> update ) perm |= KEY_POS_WRITE ; } key = key_alloc ( index_key . type , index_key . description , cred -> fsuid , cred -> fsgid , cred , perm , flags ) ; if ( IS_ERR ( key ) ) { key_ref = ERR_CAST ( key ) ; goto error_link_end ; } ret = __key_instantiate_and_link ( key , & prep , keyring , NULL , & edit ) ; if ( ret < 0 ) { key_put ( key ) ; key_ref = ERR_PTR ( ret ) ; goto error_link_end ; } key_ref = make_key_ref ( key , is_key_possessed ( keyring_ref ) ) ; error_link_end : __key_link_end ( keyring , & index_key , edit ) ; error_free_prep : if ( index_key . type -> preparse ) index_key . type -> free_preparse ( & prep ) ; error_put_type : key_type_put ( index_key . type ) ; error : return key_ref ; found_matching_key : __key_link_end ( keyring , & index_key , edit ) ; key_ref = __key_update ( key_ref , & prep ) ; goto error_free_prep ; } "," ; if ( ! index_key . ",torvalds@linux/c06cfb08b88dfbe13be44a69ae2fdc3a7c902d81,CVE-2017-2647,https://github.com/torvalds/linux/commit/c06cfb08b88dfbe13be44a69ae2fdc3a7c902d81,2017-03-31T04:59Z 666,CWE-125,"CWE-125 static int telnet_parse ( netdissect_options * ndo , const u_char * sp , u_int length , int print ) { int i , x ; u_int c ; const u_char * osp , * p ; # define FETCH ( c , sp , length ) do { if ( length < 1 ) goto pktend ; ND_TCHECK ( * sp ) ; c = * sp ++ ; length -- ; } while ( 0 ) osp = sp ; FETCH ( c , sp , length ) ; if ( c != IAC ) goto pktend ; FETCH ( c , sp , length ) ; if ( c == IAC ) { if ( print ) ND_PRINT ( ( ndo , ""IACIAC"" ) ) ; goto done ; } i = c - TELCMD_FIRST ; if ( i < 0 || i > IAC - TELCMD_FIRST ) goto pktend ; switch ( c ) { case DONT : case DO : case WONT : case WILL : case SB : FETCH ( x , sp , length ) ; if ( x >= 0 && x < NTELOPTS ) { if ( print ) ND_PRINT ( ( ndo , ""%s%s"" , telcmds [ i ] , telopts [ x ] ) ) ; } else { if ( print ) ND_PRINT ( ( ndo , ""%s%#x"" , telcmds [ i ] , x ) ) ; } if ( c != SB ) break ; p = sp ; while ( length > ( u_int ) ( p + 1 - sp ) ) { ND_TCHECK2 ( * p , 2 ) ; if ( p [ 0 ] == IAC && p [ 1 ] == SE ) break ; p ++ ; } if ( * p != IAC ) goto pktend ; switch ( x ) { case TELOPT_AUTHENTICATION : if ( p <= sp ) break ; FETCH ( c , sp , length ) ; if ( print ) ND_PRINT ( ( ndo , ""%s"" , STR_OR_ID ( c , authcmd ) ) ) ; if ( p <= sp ) break ; FETCH ( c , sp , length ) ; if ( print ) ND_PRINT ( ( ndo , ""%s"" , STR_OR_ID ( c , authtype ) ) ) ; break ; case TELOPT_ENCRYPT : if ( p <= sp ) break ; FETCH ( c , sp , length ) ; if ( print ) ND_PRINT ( ( ndo , ""%s"" , STR_OR_ID ( c , enccmd ) ) ) ; if ( p <= sp ) break ; FETCH ( c , sp , length ) ; if ( print ) ND_PRINT ( ( ndo , ""%s"" , STR_OR_ID ( c , enctype ) ) ) ; break ; default : if ( p <= sp ) break ; FETCH ( c , sp , length ) ; if ( print ) ND_PRINT ( ( ndo , ""%s"" , STR_OR_ID ( c , cmds ) ) ) ; break ; } while ( p > sp ) { FETCH ( x , sp , length ) ; if ( print ) ND_PRINT ( ( ndo , ""%#x"" , x ) ) ; } if ( print ) ND_PRINT ( ( ndo , ""SE"" ) ) ; sp += 2 ; break ; default : if ( print ) ND_PRINT ( ( ndo , ""%s"" , telcmds [ i ] ) ) ; goto done ; } done : return sp - osp ; trunc : ND_PRINT ( ( ndo , ""%s"" , tstr ) ) ; pktend : return - 1 ; # undef FETCH } "," ++ ; } ND_TCHECK ( * p ) ; ",the-tcpdump-group@tcpdump/8934a7d6307267d301182f19ed162563717e29e3,CVE-2017-12988,https://github.com/the-tcpdump-group/tcpdump/commit/8934a7d6307267d301182f19ed162563717e29e3,2017-09-14T06:29Z 667,CWE-125,"CWE-125 static int decode_studio_vop_header ( Mpeg4DecContext * ctx , GetBitContext * gb ) { MpegEncContext * s = & ctx -> m ; if ( get_bits_left ( gb ) <= 32 ) return 0 ; s -> partitioned_frame = 0 ; s -> decode_mb = mpeg4_decode_studio_mb ; decode_smpte_tc ( ctx , gb ) ; skip_bits ( gb , 10 ) ; skip_bits ( gb , 2 ) ; s -> pict_type = get_bits ( gb , 2 ) + AV_PICTURE_TYPE_I ; if ( get_bits1 ( gb ) ) { skip_bits1 ( gb ) ; skip_bits1 ( gb ) ; s -> progressive_frame = get_bits1 ( gb ) ^ 1 ; } if ( s -> pict_type == AV_PICTURE_TYPE_I ) { if ( get_bits1 ( gb ) ) reset_studio_dc_predictors ( s ) ; } if ( ctx -> shape != BIN_ONLY_SHAPE ) { s -> alternate_scan = get_bits1 ( gb ) ; s -> frame_pred_frame_dct = get_bits1 ( gb ) ; s -> dct_precision = get_bits ( gb , 2 ) ; s -> intra_dc_precision = get_bits ( gb , 2 ) ; s -> q_scale_type = get_bits1 ( gb ) ; } if ( s -> alternate_scan ) { ff_init_scantable ( s -> idsp . idct_permutation , & s -> inter_scantable , ff_alternate_vertical_scan ) ; ff_init_scantable ( s -> idsp . idct_permutation , & s -> intra_scantable , ff_alternate_vertical_scan ) ; ff_init_scantable ( s -> idsp . idct_permutation , & s -> intra_h_scantable , ff_alternate_vertical_scan ) ; ff_init_scantable ( s -> idsp . idct_permutation , & s -> intra_v_scantable , ff_alternate_vertical_scan ) ; } else { ff_init_scantable ( s -> idsp . idct_permutation , & s -> inter_scantable , ff_zigzag_direct ) ; ff_init_scantable ( s -> idsp . idct_permutation , & s -> intra_scantable , ff_zigzag_direct ) ; ff_init_scantable ( s -> idsp . idct_permutation , & s -> intra_h_scantable , ff_alternate_horizontal_scan ) ; ff_init_scantable ( s -> idsp . idct_permutation , & s -> intra_v_scantable , ff_alternate_vertical_scan ) ; } mpeg4_load_default_matrices ( s ) ; next_start_code_studio ( gb ) ; extension_and_user_data ( s , gb , 4 ) ; return 0 ; } "," ; s -> interlaced_dct = 0 ; s -> ",FFmpeg@FFmpeg/1f686d023b95219db933394a7704ad9aa5f01cbb,CVE-2019-11339,https://github.com/FFmpeg/FFmpeg/commit/1f686d023b95219db933394a7704ad9aa5f01cbb,2019-04-19T00:29Z 668,CWE-125,"CWE-125 static PyObject * builtin_compile_impl ( PyObject * module , PyObject * source , PyObject * filename , const char * mode , int flags , int dont_inherit , int optimize ) { PyObject * source_copy ; const char * str ; int compile_mode = - 1 ; int is_ast ; PyCompilerFlags cf ; int start [ ] = { Py_file_input , Py_eval_input , Py_single_input } ; PyObject * result ; cf . cf_flags = flags | PyCF_SOURCE_IS_UTF8 ; if ( flags & ~ ( PyCF_MASK | PyCF_MASK_OBSOLETE | PyCF_DONT_IMPLY_DEDENT | PyCF_ONLY_AST ) ) { PyErr_SetString ( PyExc_ValueError , ""compile():unrecognisedflags"" ) ; goto error ; } if ( optimize < - 1 || optimize > 2 ) { PyErr_SetString ( PyExc_ValueError , ""compile():invalidoptimizevalue"" ) ; goto error ; } if ( ! dont_inherit ) { PyEval_MergeCompilerFlags ( & cf ) ; } if ( strcmp ( mode , ""exec"" ) == 0 ) compile_mode = 0 ; else if ( strcmp ( mode , ""eval"" ) == 0 ) compile_mode = 1 ; else if ( strcmp ( mode , ""single"" ) == 0 ) compile_mode = 2 ; else { PyErr_SetString ( PyExc_ValueError , ""compile()modemustbe\'exec\',\'eval\'or\'single\'"" ) ; goto error ; } is_ast = PyAST_Check ( source ) ; if ( is_ast == - 1 ) goto error ; if ( is_ast ) { if ( flags & PyCF_ONLY_AST ) { Py_INCREF ( source ) ; result = source ; } else { PyArena * arena ; mod_ty mod ; arena = PyArena_New ( ) ; if ( arena == NULL ) goto error ; mod = PyAST_obj2mod ( source , arena , compile_mode ) ; if ( mod == NULL ) { PyArena_Free ( arena ) ; goto error ; } if ( ! PyAST_Validate ( mod ) ) { PyArena_Free ( arena ) ; goto error ; } result = ( PyObject * ) PyAST_CompileObject ( mod , filename , & cf , optimize , arena ) ; PyArena_Free ( arena ) ; } goto finally ; } str = source_as_string ( source , ""compile"" , ""string,bytesorAST"" , & cf , & source_copy ) ; if ( str == NULL ) goto error ; result = Py_CompileStringObject ( str , filename , start [ compile_mode ] , & cf , optimize ) ; Py_XDECREF ( source_copy ) ; goto finally ; error : result = NULL ; finally : Py_DECREF ( filename ) ; return result ; } "," Py_eval_input , Py_single_input , Py_func_type_input PyCF_DONT_IMPLY_DEDENT | PyCF_ONLY_AST | PyCF_TYPE_COMMENTS 2 ; else if ( strcmp ( mode , ""func_type"" ) == 0 ) { if ( ! ( flags & PyCF_ONLY_AST ) ) ( PyExc_ValueError , ""compile()mode\'func_type\'requiresflagPyCF_ONLY_AST"" ) ; goto error ; } compile_mode = 3 ; } else { const char * msg ; if ( flags & PyCF_ONLY_AST ) msg = ""compile()modemustbe\'exec\',\'eval\',\'single\'or\'func_type\'"" ; else msg = ""compile()modemustbe\'exec\',\'eval\'or\'single\'"" ; PyErr_SetString ( PyExc_ValueError , msg ) ; goto ",python@typed_ast/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,CVE-2019-19275,https://github.com/python/typed_ast/commit/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,2019-11-26T15:15Z 669,CWE-22,"CWE-22 int main ( int argc , char * argv [ ] ) { struct mschm_decompressor * chmd ; struct mschmd_header * chm ; struct mschmd_file * file , * * f ; unsigned int numf , i ; setbuf ( stdout , NULL ) ; setbuf ( stderr , NULL ) ; user_umask = umask ( 0 ) ; umask ( user_umask ) ; MSPACK_SYS_SELFTEST ( i ) ; if ( i ) return 0 ; if ( ( chmd = mspack_create_chm_decompressor ( NULL ) ) ) { for ( argv ++ ; * argv ; argv ++ ) { printf ( ""%s\\n"" , * argv ) ; if ( ( chm = chmd -> open ( chmd , * argv ) ) ) { for ( numf = 0 , file = chm -> files ; file ; file = file -> next ) numf ++ ; if ( ( f = ( struct mschmd_file * * ) calloc ( numf , sizeof ( struct mschmd_file * ) ) ) ) { for ( i = 0 , file = chm -> files ; file ; file = file -> next ) f [ i ++ ] = file ; qsort ( f , numf , sizeof ( struct mschmd_file * ) , & sortfunc ) ; for ( i = 0 ; i < numf ; i ++ ) { char * outname = create_output_name ( ( unsigned char * ) f [ i ] -> filename , NULL , 0 , 1 , 0 ) ; printf ( ""Extracting%s\\n"" , outname ) ; ensure_filepath ( outname ) ; if ( chmd -> extract ( chmd , f [ i ] , outname ) ) { printf ( ""%s:extracterroron\\""%s\\"":%s\\n"" , * argv , f [ i ] -> filename , ERROR ( chmd ) ) ; } free ( outname ) ; } free ( f ) ; } chmd -> close ( chmd , chm ) ; } else { printf ( ""%s:can\'topen--%s\\n"" , * argv , ERROR ( chmd ) ) ; } } mspack_destroy_chm_decompressor ( chmd ) ; } return 0 ; } "," = create_output_name ( f [ i ] -> filename ) ; printf ",kyz@libmspack/7cadd489698be117c47efcadd742651594429e6d,CVE-2018-18586,https://github.com/kyz/libmspack/commit/7cadd489698be117c47efcadd742651594429e6d,2018-10-23T02:29Z 670,CWE-119,"CWE-119 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 671,CWE-787,"CWE-787 char * selaGetCombName ( SELA * sela , l_int32 size , l_int32 direction ) { char * selname ; char combname [ L_BUF_SIZE ] ; l_int32 i , nsels , sx , sy , found ; SEL * sel ; PROCNAME ( ""selaGetCombName"" ) ; if ( ! sela ) return ( char * ) ERROR_PTR ( ""selanotdefined"" , procName , NULL ) ; if ( direction != L_HORIZ && direction != L_VERT ) return ( char * ) ERROR_PTR ( ""invaliddirection"" , procName , NULL ) ; if ( direction == L_HORIZ ) snprintf ( combname , L_BUF_SIZE , ""sel_comb_%dh"" , size ) ; else snprintf ( combname , L_BUF_SIZE , ""sel_comb_%dv"" , size ) ; found = FALSE ; nsels = selaGetCount ( sela ) ; for ( i = 0 ; i < nsels ; i ++ ) { sel = selaGetSel ( sela , i ) ; selGetParameters ( sel , & sy , & sx , NULL , NULL ) ; if ( sy != 1 && sx != 1 ) continue ; selname = selGetName ( sel ) ; if ( ! strcmp ( selname , combname ) ) { found = TRUE ; break ; } } if ( found ) return stringNew ( selname ) ; else return ( char * ) ERROR_PTR ( ""selnotfound"" , procName , NULL ) ; } "," char combname [ L_BUFSIZE ] ; l_int32 ( combname , L_BUFSIZE , ""sel_comb_%dh"" , ( combname , L_BUFSIZE , ""sel_comb_%dv"" , ",DanBloomberg@leptonica/ee301cb2029db8a6289c5295daa42bba7715e99a,CVE-2018-7186,https://github.com/DanBloomberg/leptonica/commit/ee301cb2029db8a6289c5295daa42bba7715e99a,2018-02-16T16:29Z 672,CWE-119,"CWE-119 static void update_switchable_interp_probs ( VP9_COMMON * cm , vp9_writer * w ) { int j ; for ( j = 0 ; j < SWITCHABLE_FILTER_CONTEXTS ; ++ j ) prob_diff_update ( vp9_switchable_interp_tree , cm -> fc . switchable_interp_prob [ j ] , cm -> counts . switchable_interp [ j ] , SWITCHABLE_FILTERS , w ) ; } "," * cm , vpx_writer * w , FRAME_COUNTS * counts ) { int cm -> fc -> switchable_interp_prob [ j j ] , counts -> switchable_interp [ j ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 673,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 674,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 675,CWE-362,"CWE-362 int ext4_insert_range ( struct inode * inode , loff_t offset , loff_t len ) { struct super_block * sb = inode -> i_sb ; handle_t * handle ; struct ext4_ext_path * path ; struct ext4_extent * extent ; ext4_lblk_t offset_lblk , len_lblk , ee_start_lblk = 0 ; unsigned int credits , ee_len ; int ret = 0 , depth , split_flag = 0 ; loff_t ioffset ; 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 - EOPNOTSUPP ; trace_ext4_insert_range ( inode , offset , len ) ; offset_lblk = offset >> EXT4_BLOCK_SIZE_BITS ( sb ) ; len_lblk = 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 ( ! ext4_test_inode_flag ( inode , EXT4_INODE_EXTENTS ) ) { ret = - EOPNOTSUPP ; goto out_mutex ; } if ( inode -> i_size + len > inode -> i_sb -> s_maxbytes ) { ret = - EFBIG ; goto out_mutex ; } if ( offset >= i_size_read ( inode ) ) { ret = - EINVAL ; 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 ; } inode -> i_size += len ; EXT4_I ( inode ) -> i_disksize += len ; inode -> i_mtime = inode -> i_ctime = ext4_current_time ( inode ) ; ret = ext4_mark_inode_dirty ( handle , inode ) ; if ( ret ) goto out_stop ; down_write ( & EXT4_I ( inode ) -> i_data_sem ) ; ext4_discard_preallocations ( inode ) ; path = ext4_find_extent ( inode , offset_lblk , NULL , 0 ) ; if ( IS_ERR ( path ) ) { up_write ( & EXT4_I ( inode ) -> i_data_sem ) ; goto out_stop ; } depth = ext_depth ( inode ) ; extent = path [ depth ] . p_ext ; if ( extent ) { ee_start_lblk = le32_to_cpu ( extent -> ee_block ) ; ee_len = ext4_ext_get_actual_len ( extent ) ; if ( ( offset_lblk > ee_start_lblk ) && ( offset_lblk < ( ee_start_lblk + ee_len ) ) ) { if ( ext4_ext_is_unwritten ( extent ) ) split_flag = EXT4_EXT_MARK_UNWRIT1 | EXT4_EXT_MARK_UNWRIT2 ; ret = ext4_split_extent_at ( handle , inode , & path , offset_lblk , split_flag , EXT4_EX_NOCACHE | EXT4_GET_BLOCKS_PRE_IO | EXT4_GET_BLOCKS_METADATA_NOFAIL ) ; } ext4_ext_drop_refs ( path ) ; kfree ( path ) ; if ( ret < 0 ) { up_write ( & EXT4_I ( inode ) -> i_data_sem ) ; goto out_stop ; } } ret = ext4_es_remove_extent ( inode , offset_lblk , EXT_MAX_BLOCKS - offset_lblk ) ; if ( ret ) { up_write ( & EXT4_I ( inode ) -> i_data_sem ) ; goto out_stop ; } ret = ext4_ext_shift_extents ( inode , handle , ee_start_lblk > offset_lblk ? ee_start_lblk : offset_lblk , len_lblk , SHIFT_RIGHT ) ; up_write ( & EXT4_I ( inode ) -> i_data_sem ) ; if ( IS_SYNC ( inode ) ) ext4_handle_sync ( handle ) ; 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 ; } inode 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 676,CWE-120,"CWE-120 static int fuse_notify_inval_entry ( struct fuse_conn * fc , unsigned int size , struct fuse_copy_state * cs ) { struct fuse_notify_inval_entry_out outarg ; int err = - ENOMEM ; char * buf ; struct qstr name ; buf = kzalloc ( FUSE_NAME_MAX + 1 , GFP_KERNEL ) ; if ( ! buf ) goto err ; err = - EINVAL ; if ( size < sizeof ( outarg ) ) goto err ; err = fuse_copy_one ( cs , & outarg , sizeof ( outarg ) ) ; if ( err ) goto err ; err = - ENAMETOOLONG ; if ( outarg . namelen > FUSE_NAME_MAX ) goto err ; name . name = buf ; name . len = outarg . namelen ; err = fuse_copy_one ( cs , buf , outarg . namelen + 1 ) ; if ( err ) goto err ; fuse_copy_finish ( cs ) ; buf [ outarg . namelen ] = 0 ; name . hash = full_name_hash ( name . name , name . len ) ; down_read ( & fc -> killsb ) ; err = - ENOENT ; if ( fc -> sb ) err = fuse_reverse_inval_entry ( fc -> sb , outarg . parent , & name ) ; up_read ( & fc -> killsb ) ; kfree ( buf ) ; return err ; err : kfree ( buf ) ; fuse_copy_finish ( cs ) ; return err ; } "," goto err ; err = - EINVAL ; if ( size != sizeof ( outarg ) + outarg . namelen + 1 ) goto err ; name . name = buf ; name . len = outarg . namelen ; err = fuse_copy_one ( cs , buf , outarg . namelen + 1 ) ",torvalds@linux/c2183d1e9b3f313dd8ba2b1b0197c8d9fb86a7ae,CVE-2011-3353,https://github.com/torvalds/linux/commit/c2183d1e9b3f313dd8ba2b1b0197c8d9fb86a7ae,2012-05-24T23:55Z 677,CWE-200,"CWE-200 static int cdrom_ioctl_select_disc ( struct cdrom_device_info * cdi , unsigned long arg ) { cd_dbg ( CD_DO_IOCTL , ""enteringCDROM_SELECT_DISC\\n"" ) ; if ( ! CDROM_CAN ( CDC_SELECT_DISC ) ) return - ENOSYS ; if ( arg != CDSL_CURRENT && arg != CDSL_NONE ) { if ( ( int ) arg >= cdi -> capacity ) return - EINVAL ; } if ( cdi -> ops -> select_disc ) return cdi -> ops -> select_disc ( cdi , arg ) ; cd_dbg ( CD_CHANGER , ""Usinggenericcdrom_select_disc()\\n"" ) ; return cdrom_select_disc ( cdi , arg ) ; } "," { if ( arg >= cdi ",torvalds@linux/e4f3aa2e1e67bb48dfbaaf1cad59013d5a5bc276,CVE-2018-18710,https://github.com/torvalds/linux/commit/e4f3aa2e1e67bb48dfbaaf1cad59013d5a5bc276,2018-10-29T12:29Z 678,CWE-119,"CWE-119 static int nci_extract_activation_params_iso_dep ( struct nci_dev * ndev , struct nci_rf_intf_activated_ntf * ntf , __u8 * data ) { struct activation_params_nfca_poll_iso_dep * nfca_poll ; struct activation_params_nfcb_poll_iso_dep * nfcb_poll ; switch ( ntf -> activation_rf_tech_and_mode ) { case NCI_NFC_A_PASSIVE_POLL_MODE : nfca_poll = & ntf -> activation_params . nfca_poll_iso_dep ; nfca_poll -> rats_res_len = * data ++ ; pr_debug ( ""rats_res_len%d\\n"" , nfca_poll -> rats_res_len ) ; if ( nfca_poll -> rats_res_len > 0 ) { memcpy ( nfca_poll -> rats_res , data , nfca_poll -> rats_res_len ) ; } break ; case NCI_NFC_B_PASSIVE_POLL_MODE : nfcb_poll = & ntf -> activation_params . nfcb_poll_iso_dep ; nfcb_poll -> attrib_res_len = * data ++ ; pr_debug ( ""attrib_res_len%d\\n"" , nfcb_poll -> attrib_res_len ) ; if ( nfcb_poll -> attrib_res_len > 0 ) { memcpy ( nfcb_poll -> attrib_res , data , nfcb_poll -> attrib_res_len ) ; } break ; default : pr_err ( ""unsupportedactivation_rf_tech_and_mode0x%x\\n"" , ntf -> activation_rf_tech_and_mode ) ; return NCI_STATUS_RF_PROTOCOL_ERROR ; } return NCI_STATUS_OK ; } "," -> rats_res_len = min_t ( __u8 , * data ++ , 20 ) -> attrib_res_len = min_t ( __u8 , * data ++ , 50 ) ",torvalds@linux/67de956ff5dc1d4f321e16cfbd63f5be3b691b43,CVE-2012-3364,https://github.com/torvalds/linux/commit/67de956ff5dc1d4f321e16cfbd63f5be3b691b43,2013-01-22T23:55Z 679,CWE-200,"CWE-200 static void snd_timer_user_tinterrupt ( struct snd_timer_instance * timeri , unsigned long resolution , unsigned long ticks ) { struct snd_timer_user * tu = timeri -> callback_data ; struct snd_timer_tread * r , r1 ; struct timespec tstamp ; int prev , append = 0 ; memset ( & tstamp , 0 , sizeof ( tstamp ) ) ; spin_lock ( & tu -> qlock ) ; if ( ( tu -> filter & ( ( 1 << SNDRV_TIMER_EVENT_RESOLUTION ) | ( 1 << SNDRV_TIMER_EVENT_TICK ) ) ) == 0 ) { spin_unlock ( & tu -> qlock ) ; return ; } if ( tu -> last_resolution != resolution || ticks > 0 ) { if ( timer_tstamp_monotonic ) ktime_get_ts ( & tstamp ) ; else getnstimeofday ( & tstamp ) ; } if ( ( tu -> filter & ( 1 << SNDRV_TIMER_EVENT_RESOLUTION ) ) && tu -> last_resolution != resolution ) { r1 . event = SNDRV_TIMER_EVENT_RESOLUTION ; r1 . tstamp = tstamp ; r1 . val = resolution ; snd_timer_user_append_to_tqueue ( tu , & r1 ) ; tu -> last_resolution = resolution ; append ++ ; } if ( ( tu -> filter & ( 1 << SNDRV_TIMER_EVENT_TICK ) ) == 0 ) goto __wake ; if ( ticks == 0 ) goto __wake ; if ( tu -> qused > 0 ) { prev = tu -> qtail == 0 ? tu -> queue_size - 1 : tu -> qtail - 1 ; r = & tu -> tqueue [ prev ] ; if ( r -> event == SNDRV_TIMER_EVENT_TICK ) { r -> tstamp = tstamp ; r -> val += ticks ; append ++ ; goto __wake ; } } r1 . event = SNDRV_TIMER_EVENT_TICK ; r1 . tstamp = tstamp ; r1 . val = ticks ; snd_timer_user_append_to_tqueue ( tu , & r1 ) ; append ++ ; __wake : spin_unlock ( & tu -> qlock ) ; if ( append == 0 ) return ; kill_fasync ( & tu -> fasync , SIGIO , POLL_IN ) ; wake_up ( & tu -> qchange_sleep ) ; } "," resolution ) { memset ( & r1 , 0 , sizeof ( r1 ) ) ; ",torvalds@linux/e4ec8cc8039a7063e24204299b462bd1383184a5,CVE-2016-4578,https://github.com/torvalds/linux/commit/e4ec8cc8039a7063e24204299b462bd1383184a5,2016-05-23T10:59Z 680,CWE-416,"CWE-416 static int hci_uart_set_proto ( struct hci_uart * hu , int id ) { const struct hci_uart_proto * p ; int err ; p = hci_uart_get_proto ( id ) ; if ( ! p ) return - EPROTONOSUPPORT ; hu -> proto = p ; set_bit ( HCI_UART_PROTO_READY , & hu -> flags ) ; err = hci_uart_register_dev ( hu ) ; if ( err ) { clear_bit ( HCI_UART_PROTO_READY , & hu -> flags ) ; return err ; } return 0 ; } "," = p ; err = hci_uart_register_dev err ) { return err ; } set_bit ( HCI_UART_PROTO_READY , ) ; return 0 ; } ",torvalds@linux/56897b217a1d0a91c9920cb418d6b3fe922f590a,CVE-2019-15917,https://github.com/torvalds/linux/commit/56897b217a1d0a91c9920cb418d6b3fe922f590a,2019-09-04T19:15Z 681,CWE-119,"CWE-119 static void mt_decode_mb_rows ( VP8D_COMP * pbi , MACROBLOCKD * xd , int start_mb_row ) { volatile const int * last_row_current_mb_col ; volatile int * current_mb_col ; int mb_row ; VP8_COMMON * pc = & pbi -> common ; const int nsync = pbi -> sync_range ; const int first_row_no_sync_above = pc -> mb_cols + nsync ; int num_part = 1 << pbi -> common . multi_token_partition ; int last_mb_row = start_mb_row ; YV12_BUFFER_CONFIG * yv12_fb_new = pbi -> dec_fb_ref [ INTRA_FRAME ] ; YV12_BUFFER_CONFIG * yv12_fb_lst = pbi -> dec_fb_ref [ LAST_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 ] ; 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 ; } dst_buffer [ 0 ] = yv12_fb_new -> y_buffer ; dst_buffer [ 1 ] = yv12_fb_new -> u_buffer ; dst_buffer [ 2 ] = yv12_fb_new -> v_buffer ; xd -> up_available = ( start_mb_row != 0 ) ; for ( mb_row = start_mb_row ; mb_row < pc -> mb_rows ; mb_row += ( pbi -> decoding_thread_count + 1 ) ) { int recon_yoffset , recon_uvoffset ; int mb_col ; int filter_level ; loop_filter_info_n * lfi_n = & pc -> lf_info ; last_mb_row = mb_row ; xd -> current_bc = & pbi -> mbc [ mb_row % num_part ] ; if ( mb_row > 0 ) last_row_current_mb_col = & pbi -> mt_current_mb_col [ mb_row - 1 ] ; else last_row_current_mb_col = & first_row_no_sync_above ; current_mb_col = & pbi -> mt_current_mb_col [ mb_row ] ; 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 ; if ( pbi -> common . filter_level ) { xd -> recon_above [ 0 ] = pbi -> mt_yabove_row [ mb_row ] + 0 * 16 + 32 ; xd -> recon_above [ 1 ] = pbi -> mt_uabove_row [ mb_row ] + 0 * 8 + 16 ; xd -> recon_above [ 2 ] = pbi -> mt_vabove_row [ mb_row ] + 0 * 8 + 16 ; xd -> recon_left [ 0 ] = pbi -> mt_yleft_col [ mb_row ] ; xd -> recon_left [ 1 ] = pbi -> mt_uleft_col [ mb_row ] ; xd -> recon_left [ 2 ] = pbi -> mt_vleft_col [ mb_row ] ; xd -> recon_left_stride [ 0 ] = 1 ; xd -> recon_left_stride [ 1 ] = 1 ; } else { 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 ++ ) { * 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 ) ; } } 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 ] ; mt_decode_macroblock ( pbi , xd , 0 ) ; 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 ; if ( ! pbi -> common . filter_level ) { xd -> recon_left [ 0 ] += 16 ; xd -> recon_left [ 1 ] += 8 ; xd -> recon_left [ 2 ] += 8 ; } if ( pbi -> common . filter_level ) { int skip_lf = ( xd -> mode_info_context -> mbmi . mode != B_PRED && xd -> mode_info_context -> mbmi . mode != SPLITMV && xd -> mode_info_context -> mbmi . mb_skip_coeff ) ; const int mode_index = lfi_n -> mode_lf_lut [ xd -> mode_info_context -> mbmi . mode ] ; const int seg = xd -> mode_info_context -> mbmi . segment_id ; const int ref_frame = xd -> mode_info_context -> mbmi . ref_frame ; filter_level = lfi_n -> lvl [ seg ] [ ref_frame ] [ mode_index ] ; if ( mb_row != pc -> mb_rows - 1 ) { vpx_memcpy ( ( pbi -> mt_yabove_row [ mb_row + 1 ] + 32 + mb_col * 16 ) , ( xd -> dst . y_buffer + 15 * recon_y_stride ) , 16 ) ; vpx_memcpy ( ( pbi -> mt_uabove_row [ mb_row + 1 ] + 16 + mb_col * 8 ) , ( xd -> dst . u_buffer + 7 * recon_uv_stride ) , 8 ) ; vpx_memcpy ( ( pbi -> mt_vabove_row [ mb_row + 1 ] + 16 + mb_col * 8 ) , ( xd -> dst . v_buffer + 7 * recon_uv_stride ) , 8 ) ; } if ( mb_col != pc -> mb_cols - 1 ) { MODE_INFO * next = xd -> mode_info_context + 1 ; if ( next -> mbmi . ref_frame == INTRA_FRAME ) { for ( i = 0 ; i < 16 ; i ++ ) pbi -> mt_yleft_col [ mb_row ] [ i ] = xd -> dst . y_buffer [ i * recon_y_stride + 15 ] ; for ( i = 0 ; i < 8 ; i ++ ) { pbi -> mt_uleft_col [ mb_row ] [ i ] = xd -> dst . u_buffer [ i * recon_uv_stride + 7 ] ; pbi -> mt_vleft_col [ mb_row ] [ i ] = xd -> dst . v_buffer [ i * recon_uv_stride + 7 ] ; } } } if ( filter_level ) { if ( pc -> filter_type == NORMAL_LOOPFILTER ) { loop_filter_info lfi ; FRAME_TYPE frame_type = pc -> frame_type ; const int hev_index = lfi_n -> hev_thr_lut [ frame_type ] [ filter_level ] ; lfi . mblim = lfi_n -> mblim [ filter_level ] ; lfi . blim = lfi_n -> blim [ filter_level ] ; lfi . lim = lfi_n -> lim [ filter_level ] ; lfi . hev_thr = lfi_n -> hev_thr [ hev_index ] ; if ( mb_col > 0 ) vp8_loop_filter_mbv ( xd -> dst . y_buffer , xd -> dst . u_buffer , xd -> dst . v_buffer , recon_y_stride , recon_uv_stride , & lfi ) ; if ( ! skip_lf ) vp8_loop_filter_bv ( xd -> dst . y_buffer , xd -> dst . u_buffer , xd -> dst . v_buffer , recon_y_stride , recon_uv_stride , & lfi ) ; if ( mb_row > 0 ) vp8_loop_filter_mbh ( xd -> dst . y_buffer , xd -> dst . u_buffer , xd -> dst . v_buffer , recon_y_stride , recon_uv_stride , & lfi ) ; if ( ! skip_lf ) vp8_loop_filter_bh ( xd -> dst . y_buffer , xd -> dst . u_buffer , xd -> dst . v_buffer , recon_y_stride , recon_uv_stride , & lfi ) ; } else { if ( mb_col > 0 ) vp8_loop_filter_simple_mbv ( xd -> dst . y_buffer , recon_y_stride , lfi_n -> mblim [ filter_level ] ) ; if ( ! skip_lf ) vp8_loop_filter_simple_bv ( xd -> dst . y_buffer , recon_y_stride , lfi_n -> blim [ filter_level ] ) ; if ( mb_row > 0 ) vp8_loop_filter_simple_mbh ( xd -> dst . y_buffer , recon_y_stride , lfi_n -> mblim [ filter_level ] ) ; if ( ! skip_lf ) vp8_loop_filter_simple_bh ( xd -> dst . y_buffer , recon_y_stride , lfi_n -> blim [ filter_level ] ) ; } } } recon_yoffset += 16 ; recon_uvoffset += 8 ; ++ xd -> mode_info_context ; xd -> above_context ++ ; } if ( pbi -> common . filter_level ) { if ( mb_row != pc -> mb_rows - 1 ) { int lasty = yv12_fb_lst -> y_width + VP8BORDERINPIXELS ; int lastuv = ( yv12_fb_lst -> y_width >> 1 ) + ( VP8BORDERINPIXELS >> 1 ) ; for ( i = 0 ; i < 4 ; i ++ ) { pbi -> mt_yabove_row [ mb_row + 1 ] [ lasty + i ] = pbi -> mt_yabove_row [ mb_row + 1 ] [ lasty - 1 ] ; pbi -> mt_uabove_row [ mb_row + 1 ] [ lastuv + i ] = pbi -> mt_uabove_row [ mb_row + 1 ] [ lastuv - 1 ] ; pbi -> mt_vabove_row [ mb_row + 1 ] [ lastuv + i ] = pbi -> mt_vabove_row [ mb_row + 1 ] [ lastuv - 1 ] ; } } } else vp8_extend_mb_row ( yv12_fb_new , xd -> dst . y_buffer + 16 , xd -> dst . u_buffer + 8 , xd -> dst . v_buffer + 8 ) ; * current_mb_col = mb_col + nsync ; ++ xd -> mode_info_context ; xd -> up_available = 1 ; xd -> mode_info_context += xd -> mode_info_stride * pbi -> decoding_thread_count ; } if ( last_mb_row == ( pc -> mb_rows - 1 ) ) sem_post ( & pbi -> h_event_end_decoding ) ; } "," -> above_context ; memset ( xd -> 1 ) { memcpy ( ( pbi 16 ) ; memcpy ( ( pbi 8 ) ; memcpy ( ( pbi ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 682,CWE-125,"CWE-125 static PyTypeObject * make_type ( char * type , PyTypeObject * base , char * * fields , int num_fields ) { PyObject * fnames , * result ; int i ; fnames = PyTuple_New ( num_fields ) ; if ( ! fnames ) return NULL ; for ( i = 0 ; i < num_fields ; i ++ ) { PyObject * field = PyUnicode_FromString ( fields [ i ] ) ; if ( ! field ) { Py_DECREF ( fnames ) ; return NULL ; } PyTuple_SET_ITEM ( fnames , i , field ) ; } result = PyObject_CallFunction ( ( PyObject * ) & PyType_Type , ""s(O){sOss}"" , type , base , ""_fields"" , fnames , ""__module__"" , ""_ast3"" ) ; Py_DECREF ( fnames ) ; return ( PyTypeObject * ) result ; } "," num_fields ) { _Py_IDENTIFIER ( __module__ ) ; _Py_IDENTIFIER ( _ast3 ) ; & PyType_Type , ""s(O){OOOO}"" , type , , base , _PyUnicode_FromId ( & PyId__fields ) , fnames , , fnames , _PyUnicode_FromId ( & PyId___module__ ) , _PyUnicode_FromId ( & PyId__ast3 ) ) ; Py_DECREF ",python@typed_ast/156afcb26c198e162504a57caddfe0acd9ed7dce,CVE-2019-19275,https://github.com/python/typed_ast/commit/156afcb26c198e162504a57caddfe0acd9ed7dce,2019-11-26T15:15Z 683,CWE-189,"CWE-189 STATIC struct posix_acl * xfs_acl_from_disk ( struct xfs_acl * aclp ) { struct posix_acl_entry * acl_e ; struct posix_acl * acl ; struct xfs_acl_entry * ace ; int count , i ; count = be32_to_cpu ( aclp -> acl_cnt ) ; acl = posix_acl_alloc ( count , GFP_KERNEL ) ; if ( ! acl ) return ERR_PTR ( - ENOMEM ) ; for ( i = 0 ; i < count ; i ++ ) { acl_e = & acl -> a_entries [ i ] ; ace = & aclp -> acl_entry [ i ] ; acl_e -> e_tag = be32_to_cpu ( ace -> ae_tag ) ; acl_e -> e_perm = be16_to_cpu ( ace -> ae_perm ) ; switch ( acl_e -> e_tag ) { case ACL_USER : case ACL_GROUP : acl_e -> e_id = be32_to_cpu ( ace -> ae_id ) ; break ; case ACL_USER_OBJ : case ACL_GROUP_OBJ : case ACL_MASK : case ACL_OTHER : acl_e -> e_id = ACL_UNDEFINED_ID ; break ; default : goto fail ; } } return acl ; fail : posix_acl_release ( acl ) ; return ERR_PTR ( - EINVAL ) ; } "," aclp -> acl_cnt ) ; if ( count > XFS_ACL_MAX_ENTRIES ) return ERR_PTR ( - EFSCORRUPTED ",torvalds@linux/fa8b18edd752a8b4e9d1ee2cd615b82c93cf8bba,CVE-2012-0038,https://github.com/torvalds/linux/commit/fa8b18edd752a8b4e9d1ee2cd615b82c93cf8bba,2012-05-17T11:00Z 684,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 685,CWE-119,"CWE-119 static int xlate_to_uni ( const unsigned char * name , int len , unsigned char * outname , int * longlen , int * outlen , int escape , int utf8 , struct nls_table * nls ) { const unsigned char * ip ; unsigned char nc ; unsigned char * op ; unsigned int ec ; int i , k , fill ; int charlen ; if ( utf8 ) { * outlen = utf8s_to_utf16s ( name , len , ( wchar_t * ) outname ) ; if ( * outlen < 0 ) return * outlen ; else if ( * outlen > FAT_LFN_LEN ) return - ENAMETOOLONG ; op = & outname [ * outlen * sizeof ( wchar_t ) ] ; } else { if ( nls ) { for ( i = 0 , ip = name , op = outname , * outlen = 0 ; i < len && * outlen <= FAT_LFN_LEN ; * outlen += 1 ) { if ( escape && ( * ip == ':' ) ) { if ( i > len - 5 ) return - EINVAL ; ec = 0 ; for ( k = 1 ; k < 5 ; k ++ ) { nc = ip [ k ] ; ec <<= 4 ; if ( nc >= '0' && nc <= '9' ) { ec |= nc - '0' ; continue ; } if ( nc >= 'a' && nc <= 'f' ) { ec |= nc - ( 'a' - 10 ) ; continue ; } if ( nc >= 'A' && nc <= 'F' ) { ec |= nc - ( 'A' - 10 ) ; continue ; } return - EINVAL ; } * op ++ = ec & 0xFF ; * op ++ = ec >> 8 ; ip += 5 ; i += 5 ; } else { if ( ( charlen = nls -> char2uni ( ip , len - i , ( wchar_t * ) op ) ) < 0 ) return - EINVAL ; ip += charlen ; i += charlen ; op += 2 ; } } if ( i < len ) return - ENAMETOOLONG ; } else { for ( i = 0 , ip = name , op = outname , * outlen = 0 ; i < len && * outlen <= FAT_LFN_LEN ; i ++ , * outlen += 1 ) { * op ++ = * ip ++ ; * op ++ = 0 ; } if ( i < len ) return - ENAMETOOLONG ; } } * longlen = * outlen ; if ( * outlen % 13 ) { * op ++ = 0 ; * op ++ = 0 ; * outlen += 1 ; if ( * outlen % 13 ) { fill = 13 - ( * outlen % 13 ) ; for ( i = 0 ; i < fill ; i ++ ) { * op ++ = 0xff ; * op ++ = 0xff ; } * outlen += fill ; } } return 0 ; } "," , len , UTF16_HOST_ENDIAN , * ) outname , FAT_LFN_LEN + 2 ",torvalds@linux/0720a06a7518c9d0c0125bd5d1f3b6264c55c3dd,CVE-2013-1773,https://github.com/torvalds/linux/commit/0720a06a7518c9d0c0125bd5d1f3b6264c55c3dd,2013-02-28T19:55Z 686,CWE-000,"CWE-000 int evm_update_evmxattr ( struct dentry * dentry , const char * xattr_name , const char * xattr_value , size_t xattr_value_len ) { struct inode * inode = dentry -> d_inode ; struct evm_ima_xattr_data xattr_data ; int rc = 0 ; rc = evm_calc_hmac ( dentry , xattr_name , xattr_value , xattr_value_len , xattr_data . digest ) ; if ( rc == 0 ) { xattr_data . type = EVM_XATTR_HMAC ; rc = __vfs_setxattr_noperm ( dentry , XATTR_NAME_EVM , & xattr_data , sizeof ( xattr_data ) , 0 ) ; } else if ( rc == - ENODATA ) rc = inode -> i_op -> removexattr ( dentry , XATTR_NAME_EVM ) ; return rc ; } "," == - ENODATA && inode -> i_op -> removexattr ) { rc = inode XATTR_NAME_EVM ) ; } ",torvalds@linux/a67adb997419fb53540d4a4f79c6471c60bc69b6,CVE-2013-0313,https://github.com/torvalds/linux/commit/a67adb997419fb53540d4a4f79c6471c60bc69b6,2013-02-22T00:55Z 687,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 688,CWE-119,"CWE-119 static int tile_worker_hook ( void * arg1 , void * arg2 ) { TileWorkerData * const tile_data = ( TileWorkerData * ) arg1 ; const TileInfo * const tile = ( TileInfo * ) arg2 ; int mi_row , mi_col ; for ( mi_row = tile -> mi_row_start ; mi_row < tile -> mi_row_end ; mi_row += MI_BLOCK_SIZE ) { 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 ( tile_data -> cm , & tile_data -> xd , tile , mi_row , mi_col , & tile_data -> bit_reader , BLOCK_64X64 ) ; } } return ! tile_data -> xd . corrupted ; } "," int tile_worker_hook ( TileWorkerData * const * const tile_data , const TileInfo * * const tile ) { int mi_row , mi_row , mi_col ; if ( setjmp ( tile_data -> error_info . jmp ) ) { tile_data -> error_info . setjmp = 0 ; tile_data -> xd . corrupted = 1 ; return 0 ; } tile_data -> error_info . setjmp = 1 ; tile_data -> xd . error_info = & tile_data -> error_info ( tile_data -> pbi , & tile_data tile_data -> xd , mi_row , bit_reader , BLOCK_64X64 , 4 ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 689,CWE-119,"CWE-119 static void subtract_stats ( FIRSTPASS_STATS * section , const FIRSTPASS_STATS * frame ) { section -> frame -= frame -> frame ; section -> intra_error -= frame -> intra_error ; section -> coded_error -= frame -> coded_error ; section -> sr_coded_error -= frame -> sr_coded_error ; section -> ssim_weighted_pred_err -= frame -> ssim_weighted_pred_err ; section -> pcnt_inter -= frame -> pcnt_inter ; section -> pcnt_motion -= frame -> pcnt_motion ; section -> pcnt_second_ref -= frame -> pcnt_second_ref ; section -> pcnt_neutral -= frame -> pcnt_neutral ; section -> MVr -= frame -> MVr ; section -> mvr_abs -= frame -> mvr_abs ; section -> MVc -= frame -> MVc ; section -> mvc_abs -= frame -> mvc_abs ; section -> MVrv -= frame -> MVrv ; section -> MVcv -= frame -> MVcv ; section -> mv_in_out_count -= frame -> mv_in_out_count ; section -> new_mv_count -= frame -> new_mv_count ; section -> count -= frame -> count ; section -> duration -= frame -> duration ; } "," ; section -> weight -= frame -> weight ; section -> ; section -> pcnt_inter -= frame frame -> pcnt_neutral ; section -> intra_skip_pct -= frame -> intra_skip_pct ; section -> inactive_zone_rows -= frame -> inactive_zone_rows ; section -> inactive_zone_cols -= frame -> inactive_zone_cols ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 690,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 691,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 692,CWE-362,"CWE-362 static int newseg ( struct ipc_namespace * ns , struct ipc_params * params ) { key_t key = params -> key ; int shmflg = params -> flg ; size_t size = params -> u . size ; int error ; struct shmid_kernel * shp ; size_t numpages = ( size + PAGE_SIZE - 1 ) >> PAGE_SHIFT ; struct file * file ; char name [ 13 ] ; int id ; vm_flags_t acctflag = 0 ; if ( size < SHMMIN || size > ns -> shm_ctlmax ) return - EINVAL ; if ( numpages << PAGE_SHIFT < size ) return - ENOSPC ; if ( ns -> shm_tot + numpages < ns -> shm_tot || ns -> shm_tot + numpages > ns -> shm_ctlall ) return - ENOSPC ; shp = ipc_rcu_alloc ( sizeof ( * shp ) ) ; if ( ! shp ) return - ENOMEM ; shp -> shm_perm . key = key ; shp -> shm_perm . mode = ( shmflg & S_IRWXUGO ) ; shp -> mlock_user = NULL ; shp -> shm_perm . security = NULL ; error = security_shm_alloc ( shp ) ; if ( error ) { ipc_rcu_putref ( shp , ipc_rcu_free ) ; return error ; } sprintf ( name , ""SYSV%08x"" , key ) ; if ( shmflg & SHM_HUGETLB ) { struct hstate * hs ; size_t hugesize ; hs = hstate_sizelog ( ( shmflg >> SHM_HUGE_SHIFT ) & SHM_HUGE_MASK ) ; if ( ! hs ) { error = - EINVAL ; goto no_file ; } hugesize = ALIGN ( size , huge_page_size ( hs ) ) ; if ( shmflg & SHM_NORESERVE ) acctflag = VM_NORESERVE ; file = hugetlb_file_setup ( name , hugesize , acctflag , & shp -> mlock_user , HUGETLB_SHMFS_INODE , ( shmflg >> SHM_HUGE_SHIFT ) & SHM_HUGE_MASK ) ; } else { if ( ( shmflg & SHM_NORESERVE ) && sysctl_overcommit_memory != OVERCOMMIT_NEVER ) acctflag = VM_NORESERVE ; file = shmem_kernel_file_setup ( name , size , acctflag ) ; } error = PTR_ERR ( file ) ; if ( IS_ERR ( file ) ) goto no_file ; id = ipc_addid ( & shm_ids ( ns ) , & shp -> shm_perm , ns -> shm_ctlmni ) ; if ( id < 0 ) { error = id ; goto no_id ; } shp -> shm_cprid = task_tgid_vnr ( current ) ; shp -> shm_lprid = 0 ; shp -> shm_atim = shp -> shm_dtim = 0 ; shp -> shm_ctim = get_seconds ( ) ; shp -> shm_segsz = size ; shp -> shm_nattch = 0 ; shp -> shm_file = file ; shp -> shm_creator = current ; list_add ( & shp -> shm_clist , & current -> sysvshm . shm_clist ) ; file_inode ( file ) -> i_ino = shp -> shm_perm . id ; ns -> shm_tot += numpages ; error = shp -> shm_perm . id ; ipc_unlock_object ( & shp -> shm_perm ) ; rcu_read_unlock ( ) ; return error ; no_id : if ( is_file_hugepages ( file ) && shp -> mlock_user ) user_shm_unlock ( size , shp -> mlock_user ) ; fput ( file ) ; no_file : ipc_rcu_putref ( shp , shm_rcu_free ) ; return error ; } "," goto no_file ; shp -> shm_cprid = task_tgid_vnr ( current ) ; shp -> shm_lprid = 0 ; shp -> shm_atim = shp -> shm_dtim = 0 ; shp -> shm_ctim = get_seconds ( ) ; shp -> shm_segsz = size ; shp -> shm_nattch = 0 ; shp -> shm_file = file ; shp -> shm_creator = current ; no_id ; } list_add ( & ",torvalds@linux/b9a532277938798b53178d5a66af6e2915cb27cf,CVE-2015-7613,https://github.com/torvalds/linux/commit/b9a532277938798b53178d5a66af6e2915cb27cf,2015-10-19T10:59Z 693,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 694,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 695,CWE-617,"CWE-617 int pci_bus_configured ( int bus ) { assert ( bus >= 0 && bus < MAXBUSES ) ; return ( pci_businfo [ bus ] != NULL ) ; } "," bus ) { return ( pci_businfo ",projectacrn@acrn-hypervisor/2b3dedfb9ba13f15887f22b935d373f36c9a59fa,CVE-2019-18844,https://github.com/projectacrn/acrn-hypervisor/commit/2b3dedfb9ba13f15887f22b935d373f36c9a59fa,2019-11-13T20:15Z 696,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 697,CWE-125,"CWE-125 void sctp_auth_get_cookie_params ( struct sctp_tcb * stcb , struct mbuf * m , uint32_t offset , uint32_t length ) { struct sctp_paramhdr * phdr , tmp_param ; uint16_t plen , ptype ; uint8_t random_store [ SCTP_PARAM_BUFFER_SIZE ] ; struct sctp_auth_random * p_random = NULL ; uint16_t random_len = 0 ; uint8_t hmacs_store [ SCTP_PARAM_BUFFER_SIZE ] ; struct sctp_auth_hmac_algo * hmacs = NULL ; uint16_t hmacs_len = 0 ; uint8_t chunks_store [ SCTP_PARAM_BUFFER_SIZE ] ; struct sctp_auth_chunk_list * chunks = NULL ; uint16_t num_chunks = 0 ; sctp_key_t * new_key ; uint32_t keylen ; length += offset ; phdr = ( struct sctp_paramhdr * ) sctp_m_getptr ( m , offset , sizeof ( struct sctp_paramhdr ) , ( uint8_t * ) & tmp_param ) ; while ( phdr != NULL ) { ptype = ntohs ( phdr -> param_type ) ; plen = ntohs ( phdr -> param_length ) ; if ( ( plen == 0 ) || ( offset + plen > length ) ) break ; if ( ptype == SCTP_RANDOM ) { if ( plen > sizeof ( random_store ) ) break ; phdr = sctp_get_next_param ( m , offset , ( struct sctp_paramhdr * ) random_store , plen ) ; if ( phdr == NULL ) return ; p_random = ( struct sctp_auth_random * ) phdr ; random_len = plen - sizeof ( * p_random ) ; } else if ( ptype == SCTP_HMAC_LIST ) { uint16_t num_hmacs ; uint16_t i ; if ( plen > sizeof ( hmacs_store ) ) break ; phdr = sctp_get_next_param ( m , offset , ( struct sctp_paramhdr * ) hmacs_store , plen ) ; if ( phdr == NULL ) return ; hmacs = ( struct sctp_auth_hmac_algo * ) phdr ; hmacs_len = plen - sizeof ( * hmacs ) ; num_hmacs = hmacs_len / sizeof ( hmacs -> hmac_ids [ 0 ] ) ; if ( stcb -> asoc . local_hmacs != NULL ) sctp_free_hmaclist ( stcb -> asoc . local_hmacs ) ; stcb -> asoc . local_hmacs = sctp_alloc_hmaclist ( num_hmacs ) ; if ( stcb -> asoc . local_hmacs != NULL ) { for ( i = 0 ; i < num_hmacs ; i ++ ) { ( void ) sctp_auth_add_hmacid ( stcb -> asoc . local_hmacs , ntohs ( hmacs -> hmac_ids [ i ] ) ) ; } } } else if ( ptype == SCTP_CHUNK_LIST ) { int i ; if ( plen > sizeof ( chunks_store ) ) break ; phdr = sctp_get_next_param ( m , offset , ( struct sctp_paramhdr * ) chunks_store , plen ) ; if ( phdr == NULL ) return ; chunks = ( struct sctp_auth_chunk_list * ) phdr ; num_chunks = plen - sizeof ( * chunks ) ; if ( stcb -> asoc . local_auth_chunks != NULL ) sctp_clear_chunklist ( stcb -> asoc . local_auth_chunks ) ; else stcb -> asoc . local_auth_chunks = sctp_alloc_chunklist ( ) ; for ( i = 0 ; i < num_chunks ; i ++ ) { ( void ) sctp_auth_add_chunk ( chunks -> chunk_types [ i ] , stcb -> asoc . local_auth_chunks ) ; } } offset += SCTP_SIZE32 ( plen ) ; if ( offset + sizeof ( struct sctp_paramhdr ) > length ) break ; phdr = ( struct sctp_paramhdr * ) sctp_m_getptr ( m , offset , sizeof ( struct sctp_paramhdr ) , ( uint8_t * ) & tmp_param ) ; } keylen = sizeof ( * p_random ) + random_len + sizeof ( * hmacs ) + hmacs_len ; if ( chunks != NULL ) { keylen += sizeof ( * chunks ) + num_chunks ; } new_key = sctp_alloc_key ( keylen ) ; if ( new_key != NULL ) { if ( p_random != NULL ) { keylen = sizeof ( * p_random ) + random_len ; memcpy ( new_key -> key , p_random , keylen ) ; } else { keylen = 0 ; } if ( chunks != NULL ) { memcpy ( new_key -> key + keylen , chunks , sizeof ( * chunks ) + num_chunks ) ; keylen += sizeof ( * chunks ) + num_chunks ; } if ( hmacs != NULL ) { memcpy ( new_key -> key + keylen , hmacs , sizeof ( * hmacs ) + hmacs_len ) ; } } if ( stcb -> asoc . authinfo . random != NULL ) sctp_free_key ( stcb -> asoc . authinfo . random ) ; stcb -> asoc . authinfo . random = new_key ; stcb -> asoc . authinfo . random_len = random_len ; sctp_clear_cachedkeys ( stcb , stcb -> asoc . authinfo . assoc_keyid ) ; sctp_clear_cachedkeys ( stcb , stcb -> asoc . authinfo . recv_keyid ) ; stcb -> asoc . peer_hmac_id = sctp_negotiate_hmacid ( stcb -> asoc . peer_hmacs , stcb -> asoc . local_hmacs ) ; stcb -> asoc . authinfo . active_keyid = stcb -> sctp_ep -> sctp_ep . default_keyid ; ( void ) sctp_copy_skeylist ( & stcb -> sctp_ep -> sctp_ep . shared_keys , & stcb -> asoc . shared_keys ) ; } "," ( ( plen < sizeof ( struct sctp_paramhdr ) ) || ( ",sctplab@usrsctp/790a7a2555aefb392a5a69923f1e9d17b4968467,CVE-2019-20503,https://github.com/sctplab/usrsctp/commit/790a7a2555aefb392a5a69923f1e9d17b4968467,2020-03-06T20:15Z 698,CWE-269,"CWE-269 uint32_t virtio_config_readl ( VirtIODevice * vdev , uint32_t addr ) { VirtioDeviceClass * k = VIRTIO_DEVICE_GET_CLASS ( vdev ) ; uint32_t val ; k -> get_config ( vdev , vdev -> config ) ; if ( addr > ( vdev -> config_len - sizeof ( val ) ) ) return ( uint32_t ) - 1 ; val = ldl_p ( vdev -> config + addr ) ; return val ; } "," uint32_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 699,CWE-119,"CWE-119 static void encode_frame ( vpx_codec_ctx_t * ctx , const vpx_image_t * img , vpx_codec_pts_t pts , unsigned int duration , vpx_enc_frame_flags_t flags , unsigned int deadline , VpxVideoWriter * writer ) { vpx_codec_iter_t iter = NULL ; const vpx_codec_cx_pkt_t * pkt = NULL ; const vpx_codec_err_t res = vpx_codec_encode ( ctx , img , pts , duration , flags , deadline ) ; if ( res != VPX_CODEC_OK ) die_codec ( ctx , ""Failedtoencodeframe."" ) ; while ( ( pkt = vpx_codec_get_cx_data ( ctx , & iter ) ) != NULL ) { if ( pkt -> kind == VPX_CODEC_CX_FRAME_PKT ) { const int keyframe = ( pkt -> data . frame . flags & VPX_FRAME_IS_KEY ) != 0 ; if ( ! vpx_video_writer_write_frame ( writer , pkt -> data . frame . buf , pkt -> data . frame . sz , pkt -> data . frame . pts ) ) die_codec ( ctx , ""Failedtowritecompressedframe."" ) ; printf ( keyframe ? ""K"" : ""."" ) ; fflush ( stdout ) ; } } } "," static int encode_frame ( vpx_codec_ctx_t writer ) { int got_pkts = 0 ; NULL ) { got_pkts = 1 ; ; } } return got_pkts ; ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 700,CWE-200,"CWE-200 enum auth_stat gssrpc__svcauth_gss ( struct svc_req * rqst , struct rpc_msg * msg , bool_t * no_dispatch ) { enum auth_stat retstat ; XDR xdrs ; SVCAUTH * auth ; struct svc_rpc_gss_data * gd ; struct rpc_gss_cred * gc ; struct rpc_gss_init_res gr ; int call_stat , offset ; OM_uint32 min_stat ; log_debug ( ""insvcauth_gss()"" ) ; rqst -> rq_xprt -> xp_verf = gssrpc__null_auth ; if ( rqst -> rq_xprt -> xp_auth == NULL || rqst -> rq_xprt -> xp_auth == & svc_auth_none ) { if ( ( auth = calloc ( sizeof ( * auth ) , 1 ) ) == NULL ) { fprintf ( stderr , ""svcauth_gss:out_of_memory\\n"" ) ; return ( AUTH_FAILED ) ; } if ( ( gd = calloc ( sizeof ( * gd ) , 1 ) ) == NULL ) { fprintf ( stderr , ""svcauth_gss:out_of_memory\\n"" ) ; return ( AUTH_FAILED ) ; } auth -> svc_ah_ops = & svc_auth_gss_ops ; SVCAUTH_PRIVATE ( auth ) = gd ; rqst -> rq_xprt -> xp_auth = auth ; } else gd = SVCAUTH_PRIVATE ( rqst -> rq_xprt -> xp_auth ) ; log_debug ( ""xp_auth=%p,gd=%p"" , rqst -> rq_xprt -> xp_auth , gd ) ; if ( rqst -> rq_cred . oa_length <= 0 ) return ( AUTH_BADCRED ) ; gc = ( struct rpc_gss_cred * ) rqst -> rq_clntcred ; memset ( gc , 0 , sizeof ( * gc ) ) ; log_debug ( ""callingxdrmem_create()"" ) ; log_debug ( ""oa_base=%p,oa_length=%u"" , rqst -> rq_cred . oa_base , rqst -> rq_cred . oa_length ) ; xdrmem_create ( & xdrs , rqst -> rq_cred . oa_base , rqst -> rq_cred . oa_length , XDR_DECODE ) ; log_debug ( ""xdrmem_create()returned"" ) ; if ( ! xdr_rpc_gss_cred ( & xdrs , gc ) ) { log_debug ( ""xdr_rpc_gss_cred()failed"" ) ; XDR_DESTROY ( & xdrs ) ; return ( AUTH_BADCRED ) ; } XDR_DESTROY ( & xdrs ) ; retstat = AUTH_FAILED ; # define ret_freegc ( code ) do { retstat = code ; goto freegc ; } while ( 0 ) if ( gc -> gc_v != RPCSEC_GSS_VERSION ) ret_freegc ( AUTH_BADCRED ) ; if ( gc -> gc_svc != RPCSEC_GSS_SVC_NONE && gc -> gc_svc != RPCSEC_GSS_SVC_INTEGRITY && gc -> gc_svc != RPCSEC_GSS_SVC_PRIVACY ) ret_freegc ( AUTH_BADCRED ) ; if ( gd -> established ) { if ( gc -> gc_seq > MAXSEQ ) ret_freegc ( RPCSEC_GSS_CTXPROBLEM ) ; if ( ( offset = gd -> seqlast - gc -> gc_seq ) < 0 ) { gd -> seqlast = gc -> gc_seq ; offset = 0 - offset ; gd -> seqmask <<= offset ; offset = 0 ; } else if ( ( u_int ) offset >= gd -> win || ( gd -> seqmask & ( 1 << offset ) ) ) { * no_dispatch = 1 ; ret_freegc ( RPCSEC_GSS_CTXPROBLEM ) ; } gd -> seq = gc -> gc_seq ; gd -> seqmask |= ( 1 << offset ) ; } if ( gd -> established ) { rqst -> rq_clntname = ( char * ) gd -> client_name ; rqst -> rq_svccred = ( char * ) gd -> ctx ; } switch ( gc -> gc_proc ) { case RPCSEC_GSS_INIT : case RPCSEC_GSS_CONTINUE_INIT : if ( rqst -> rq_proc != NULLPROC ) ret_freegc ( AUTH_FAILED ) ; if ( ! svcauth_gss_acquire_cred ( ) ) ret_freegc ( AUTH_FAILED ) ; if ( ! svcauth_gss_accept_sec_context ( rqst , & gr ) ) ret_freegc ( AUTH_REJECTEDCRED ) ; if ( ! svcauth_gss_nextverf ( rqst , htonl ( gr . gr_win ) ) ) { gss_release_buffer ( & min_stat , & gr . gr_token ) ; mem_free ( gr . gr_ctx . value , sizeof ( gss_union_ctx_id_desc ) ) ; ret_freegc ( AUTH_FAILED ) ; } * no_dispatch = TRUE ; call_stat = svc_sendreply ( rqst -> rq_xprt , xdr_rpc_gss_init_res , ( caddr_t ) & gr ) ; gss_release_buffer ( & min_stat , & gr . gr_token ) ; gss_release_buffer ( & min_stat , & gd -> checksum ) ; mem_free ( gr . gr_ctx . value , sizeof ( gss_union_ctx_id_desc ) ) ; if ( ! call_stat ) ret_freegc ( AUTH_FAILED ) ; if ( gr . gr_major == GSS_S_COMPLETE ) gd -> established = TRUE ; break ; case RPCSEC_GSS_DATA : if ( ! svcauth_gss_validate ( rqst , gd , msg ) ) ret_freegc ( RPCSEC_GSS_CREDPROBLEM ) ; if ( ! svcauth_gss_nextverf ( rqst , htonl ( gc -> gc_seq ) ) ) ret_freegc ( AUTH_FAILED ) ; break ; case RPCSEC_GSS_DESTROY : if ( rqst -> rq_proc != NULLPROC ) ret_freegc ( AUTH_FAILED ) ; if ( ! svcauth_gss_validate ( rqst , gd , msg ) ) ret_freegc ( RPCSEC_GSS_CREDPROBLEM ) ; if ( ! svcauth_gss_nextverf ( rqst , htonl ( gc -> gc_seq ) ) ) ret_freegc ( AUTH_FAILED ) ; * no_dispatch = TRUE ; call_stat = svc_sendreply ( rqst -> rq_xprt , xdr_void , ( caddr_t ) NULL ) ; log_debug ( ""sendreplyindestroy:%d"" , call_stat ) ; if ( ! svcauth_gss_release_cred ( ) ) ret_freegc ( AUTH_FAILED ) ; SVCAUTH_DESTROY ( rqst -> rq_xprt -> xp_auth ) ; rqst -> rq_xprt -> xp_auth = & svc_auth_none ; break ; default : ret_freegc ( AUTH_REJECTEDCRED ) ; break ; } retstat = AUTH_OK ; freegc : xdr_free ( xdr_rpc_gss_cred , gc ) ; log_debug ( ""returning%dfromsvcauth_gss()"" , retstat ) ; return ( retstat ) ; } "," gr_token ) ; ret_freegc ( AUTH_FAILED gd -> checksum ) ; if ",krb5@krb5/5bb8a6b9c9eb8dd22bc9526751610aaa255ead9c,CVE-2014-9423,https://github.com/krb5/krb5/commit/5bb8a6b9c9eb8dd22bc9526751610aaa255ead9c,2015-02-19T11:59Z 701,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 702,CWE-119,"CWE-119 static double calc_frame_boost ( VP9_COMP * cpi , FIRSTPASS_STATS * this_frame , double this_frame_mv_in_out ) { double frame_boost ; if ( this_frame -> intra_error > cpi -> twopass . gf_intra_err_min ) frame_boost = ( IIFACTOR * this_frame -> intra_error / DOUBLE_DIVIDE_CHECK ( this_frame -> coded_error ) ) ; else frame_boost = ( IIFACTOR * cpi -> twopass . gf_intra_err_min / DOUBLE_DIVIDE_CHECK ( this_frame -> coded_error ) ) ; if ( this_frame_mv_in_out > 0.0 ) frame_boost += frame_boost * ( this_frame_mv_in_out * 2.0 ) ; else frame_boost += frame_boost * ( this_frame_mv_in_out / 2.0 ) ; return MIN ( frame_boost , GF_RMAX ) ; } "," * cpi , const , double this_frame_mv_in_out , double max_boost double frame_boost ; const double lq = vp9_convert_qindex_to_q ( cpi -> rc . avg_frame_qindex [ INTER_FRAME ] , cpi -> common . bit_depth ) ; const double boost_q_correction = MIN ( ( 0.5 + ( lq * 0.015 ) ) , 1.5 ) ; int num_mbs = ( cpi -> oxcf . resize_mode != RESIZE_NONE ) ? cpi -> initial_mbs : cpi -> common . MBs ; num_mbs = ( int ) MAX ( 1 , num_mbs * calculate_active_area ( cpi , this_frame ) ) ; frame_boost = ( frame_boost = ( BASELINE_ERR_PER_MB * num_mbs ) / DOUBLE_DIVIDE_CHECK ( -> coded_error ) ; frame_boost = frame_boost * BOOST_FACTOR * boost_q_correction ; if ( ( frame_boost , max_boost * boost_q_correction ) ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 703,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 704,CWE-19,"CWE-19 struct mb_cache * ext4_xattr_create_cache ( char * name ) { return mb_cache_create ( name , HASH_BUCKET_BITS ) ; } "," struct mb2_cache * ext4_xattr_create_cache ( * ext4_xattr_create_cache ( void ) { return ) { return mb2_cache_create ( HASH_BUCKET_BITS ) ; ",torvalds@linux/82939d7999dfc1f1998c4b1c12e2f19edbdff272,CVE-2015-8952,https://github.com/torvalds/linux/commit/82939d7999dfc1f1998c4b1c12e2f19edbdff272,2016-10-16T21:59Z 705,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 706,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 707,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 708,CWE-119,"CWE-119 static long gfs2_fallocate ( struct file * file , int mode , loff_t offset , loff_t len ) { struct inode * inode = file -> f_path . dentry -> d_inode ; struct gfs2_sbd * sdp = GFS2_SB ( inode ) ; struct gfs2_inode * ip = GFS2_I ( inode ) ; unsigned int data_blocks = 0 , ind_blocks = 0 , rblocks ; loff_t bytes , max_bytes ; struct gfs2_alloc * al ; int error ; loff_t bsize_mask = ~ ( ( loff_t ) sdp -> sd_sb . sb_bsize - 1 ) ; loff_t next = ( offset + len - 1 ) >> sdp -> sd_sb . sb_bsize_shift ; next = ( next + 1 ) << sdp -> sd_sb . sb_bsize_shift ; if ( mode & ~ FALLOC_FL_KEEP_SIZE ) return - EOPNOTSUPP ; offset &= bsize_mask ; len = next - offset ; bytes = sdp -> sd_max_rg_data * sdp -> sd_sb . sb_bsize / 2 ; if ( ! bytes ) bytes = UINT_MAX ; bytes &= bsize_mask ; if ( bytes == 0 ) bytes = sdp -> sd_sb . sb_bsize ; gfs2_holder_init ( ip -> i_gl , LM_ST_EXCLUSIVE , 0 , & ip -> i_gh ) ; error = gfs2_glock_nq ( & ip -> i_gh ) ; if ( unlikely ( error ) ) goto out_uninit ; if ( ! gfs2_write_alloc_required ( ip , offset , len ) ) goto out_unlock ; while ( len > 0 ) { if ( len < bytes ) bytes = len ; al = gfs2_alloc_get ( ip ) ; if ( ! al ) { error = - ENOMEM ; goto out_unlock ; } error = gfs2_quota_lock_check ( ip ) ; if ( error ) goto out_alloc_put ; retry : gfs2_write_calc_reserv ( ip , bytes , & data_blocks , & ind_blocks ) ; al -> al_requested = data_blocks + ind_blocks ; error = gfs2_inplace_reserve ( ip ) ; if ( error ) { if ( error == - ENOSPC && bytes > sdp -> sd_sb . sb_bsize ) { bytes >>= 1 ; bytes &= bsize_mask ; if ( bytes == 0 ) bytes = sdp -> sd_sb . sb_bsize ; goto retry ; } goto out_qunlock ; } max_bytes = bytes ; calc_max_reserv ( ip , len , & max_bytes , & data_blocks , & ind_blocks ) ; al -> al_requested = data_blocks + ind_blocks ; rblocks = RES_DINODE + ind_blocks + RES_STATFS + RES_QUOTA + RES_RG_HDR + gfs2_rg_blocks ( ip ) ; if ( gfs2_is_jdata ( ip ) ) rblocks += data_blocks ? data_blocks : 1 ; error = gfs2_trans_begin ( sdp , rblocks , PAGE_CACHE_SIZE / sdp -> sd_sb . sb_bsize ) ; if ( error ) goto out_trans_fail ; error = fallocate_chunk ( inode , offset , max_bytes , mode ) ; gfs2_trans_end ( sdp ) ; if ( error ) goto out_trans_fail ; len -= max_bytes ; offset += max_bytes ; gfs2_inplace_release ( ip ) ; gfs2_quota_unlock ( ip ) ; gfs2_alloc_put ( ip ) ; } goto out_unlock ; out_trans_fail : gfs2_inplace_release ( ip ) ; out_qunlock : gfs2_quota_unlock ( ip ) ; out_alloc_put : gfs2_alloc_put ( ip ) ; out_unlock : gfs2_glock_dq ( & ip -> i_gh ) ; out_uninit : gfs2_holder_uninit ( & ip -> i_gh ) ; return error ; } "," . sb_bsize_shift ; loff_t max_chunk_size = UINT_MAX & bsize_mask ; ( ip , ( len > max_chunk_size ) ? max_chunk_size : len , & max_bytes , ",torvalds@linux/64dd153c83743af81f20924c6343652d731eeecb,CVE-2011-4098,https://github.com/torvalds/linux/commit/64dd153c83743af81f20924c6343652d731eeecb,2013-06-08T13:05Z 709,CWE-125,"CWE-125 static int dccp_print_option ( netdissect_options * ndo , const u_char * option , u_int hlen ) { uint8_t optlen , i ; ND_TCHECK ( * option ) ; if ( * option >= 32 ) { ND_TCHECK ( * ( option + 1 ) ) ; optlen = * ( option + 1 ) ; if ( optlen < 2 ) { if ( * option >= 128 ) ND_PRINT ( ( ndo , ""CCIDoption%uoptlentooshort"" , * option ) ) ; else ND_PRINT ( ( ndo , ""%soptlentooshort"" , tok2str ( dccp_option_values , ""Option%u"" , * option ) ) ) ; return 0 ; } } else optlen = 1 ; if ( hlen < optlen ) { if ( * option >= 128 ) ND_PRINT ( ( ndo , ""CCIDoption%uoptlengoespastheaderlength"" , * option ) ) ; else ND_PRINT ( ( ndo , ""%soptlengoespastheaderlength"" , tok2str ( dccp_option_values , ""Option%u"" , * option ) ) ) ; return 0 ; } ND_TCHECK2 ( * option , optlen ) ; if ( * option >= 128 ) { ND_PRINT ( ( ndo , ""CCIDoption%d"" , * option ) ) ; switch ( optlen ) { case 4 : ND_PRINT ( ( ndo , ""%u"" , EXTRACT_16BITS ( option + 2 ) ) ) ; break ; case 6 : ND_PRINT ( ( ndo , ""%u"" , EXTRACT_32BITS ( option + 2 ) ) ) ; break ; default : break ; } } else { ND_PRINT ( ( ndo , ""%s"" , tok2str ( dccp_option_values , ""Option%u"" , * option ) ) ) ; switch ( * option ) { case 32 : case 33 : case 34 : case 35 : if ( optlen < 3 ) { ND_PRINT ( ( ndo , ""optlentooshort"" ) ) ; return optlen ; } if ( * ( option + 2 ) < 10 ) { ND_PRINT ( ( ndo , ""%s"" , dccp_feature_nums [ * ( option + 2 ) ] ) ) ; for ( i = 0 ; i < optlen - 3 ; i ++ ) ND_PRINT ( ( ndo , ""%d"" , * ( option + 3 + i ) ) ) ; } break ; case 36 : if ( optlen > 2 ) { ND_PRINT ( ( ndo , ""0x"" ) ) ; for ( i = 0 ; i < optlen - 2 ; i ++ ) ND_PRINT ( ( ndo , ""%02x"" , * ( option + 2 + i ) ) ) ; } break ; case 37 : for ( i = 0 ; i < optlen - 2 ; i ++ ) ND_PRINT ( ( ndo , ""%d"" , * ( option + 2 + i ) ) ) ; break ; case 38 : if ( optlen > 2 ) { ND_PRINT ( ( ndo , ""0x"" ) ) ; for ( i = 0 ; i < optlen - 2 ; i ++ ) ND_PRINT ( ( ndo , ""%02x"" , * ( option + 2 + i ) ) ) ; } break ; case 39 : if ( optlen > 2 ) { ND_PRINT ( ( ndo , ""0x"" ) ) ; for ( i = 0 ; i < optlen - 2 ; i ++ ) ND_PRINT ( ( ndo , ""%02x"" , * ( option + 2 + i ) ) ) ; } break ; case 40 : if ( optlen > 2 ) { ND_PRINT ( ( ndo , ""0x"" ) ) ; for ( i = 0 ; i < optlen - 2 ; i ++ ) ND_PRINT ( ( ndo , ""%02x"" , * ( option + 2 + i ) ) ) ; } break ; case 41 : if ( optlen == 4 ) ND_PRINT ( ( ndo , ""%u"" , EXTRACT_32BITS ( option + 2 ) ) ) ; else ND_PRINT ( ( ndo , ""optlen!=4"" ) ) ; break ; case 42 : if ( optlen == 4 ) ND_PRINT ( ( ndo , ""%u"" , EXTRACT_32BITS ( option + 2 ) ) ) ; else ND_PRINT ( ( ndo , ""optlen!=4"" ) ) ; break ; case 43 : if ( optlen == 6 ) ND_PRINT ( ( ndo , ""%u"" , EXTRACT_32BITS ( option + 2 ) ) ) ; else if ( optlen == 4 ) ND_PRINT ( ( ndo , ""%u"" , EXTRACT_16BITS ( option + 2 ) ) ) ; else ND_PRINT ( ( ndo , ""optlen!=4or6"" ) ) ; break ; case 44 : if ( optlen > 2 ) { ND_PRINT ( ( ndo , """" ) ) ; for ( i = 0 ; i < optlen - 2 ; i ++ ) ND_PRINT ( ( ndo , ""%02x"" , * ( option + 2 + i ) ) ) ; } break ; } } return optlen ; trunc : ND_PRINT ( ( ndo , ""%s"" , tstr ) ) ; return 0 ; } "," ( optlen == 6 ) ND_PRINT ( ( ndo , ""[optlen!=6]"" ) ) ; case 42 : switch ( optlen ) { case 6 : ND_PRINT ( ( ndo , ""%u"" , EXTRACT_32BITS ( option + 2 ) ) ) ; break ; case 8 : ND_PRINT ( ( ndo , ""%u"" , EXTRACT_32BITS ( option + 2 ) ) ) ; ND_PRINT ( ( ndo , ""(elapsedtime%u)"" , EXTRACT_16BITS ( option + 6 ) ) ) ; break ; case 10 : ND_PRINT ( ( ndo , ""%u"" , EXTRACT_32BITS ( option + 2 ) ) ) ; ND_PRINT ( ( ndo , ""(elapsedtime%u)"" , EXTRACT_32BITS ( option + 6 ) ) ) ; break ; default : ND_PRINT ( ( ndo , ""[optlen!=6or8or10]"" ) ) ; break ; } break ; case 43 : if ( optlen == 6 ) ND_PRINT ( ( ndo , ""%u"" , EXTRACT_32BITS ( option + 2 ) ) ) ; else , ""%u"" , EXTRACT_16BITS ( option + ( ndo , ""[optlen!=4or6]"" ) ) ; ",the-tcpdump-group@tcpdump/211124b972e74f0da66bc8b16f181f78793e2f66,CVE-2018-16229,https://github.com/the-tcpdump-group/tcpdump/commit/211124b972e74f0da66bc8b16f181f78793e2f66,2019-10-03T16:15Z 710,CWE-125,"CWE-125 void pgm_print ( netdissect_options * ndo , register const u_char * bp , register u_int length , register const u_char * bp2 ) { register const struct pgm_header * pgm ; register const struct ip * ip ; register char ch ; uint16_t sport , dport ; u_int nla_afnum ; char nla_buf [ INET6_ADDRSTRLEN ] ; register const struct ip6_hdr * ip6 ; uint8_t opt_type , opt_len ; uint32_t seq , opts_len , len , offset ; pgm = ( const struct pgm_header * ) bp ; ip = ( const struct ip * ) bp2 ; if ( IP_V ( ip ) == 6 ) ip6 = ( const struct ip6_hdr * ) bp2 ; else ip6 = NULL ; ch = '\\0' ; if ( ! ND_TTEST ( pgm -> pgm_dport ) ) { if ( ip6 ) { ND_PRINT ( ( ndo , ""%s>%s:[|pgm]"" , ip6addr_string ( ndo , & ip6 -> ip6_src ) , ip6addr_string ( ndo , & ip6 -> ip6_dst ) ) ) ; return ; } else { ND_PRINT ( ( ndo , ""%s>%s:[|pgm]"" , ipaddr_string ( ndo , & ip -> ip_src ) , ipaddr_string ( ndo , & ip -> ip_dst ) ) ) ; return ; } } sport = EXTRACT_16BITS ( & pgm -> pgm_sport ) ; dport = EXTRACT_16BITS ( & pgm -> pgm_dport ) ; if ( ip6 ) { if ( ip6 -> ip6_nxt == IPPROTO_PGM ) { ND_PRINT ( ( ndo , ""%s.%s>%s.%s:"" , ip6addr_string ( ndo , & ip6 -> ip6_src ) , tcpport_string ( ndo , sport ) , ip6addr_string ( ndo , & ip6 -> ip6_dst ) , tcpport_string ( ndo , dport ) ) ) ; } else { ND_PRINT ( ( ndo , ""%s>%s:"" , tcpport_string ( ndo , sport ) , tcpport_string ( ndo , dport ) ) ) ; } } else { if ( ip -> ip_p == IPPROTO_PGM ) { ND_PRINT ( ( ndo , ""%s.%s>%s.%s:"" , ipaddr_string ( ndo , & ip -> ip_src ) , tcpport_string ( ndo , sport ) , ipaddr_string ( ndo , & ip -> ip_dst ) , tcpport_string ( ndo , dport ) ) ) ; } else { ND_PRINT ( ( ndo , ""%s>%s:"" , tcpport_string ( ndo , sport ) , tcpport_string ( ndo , dport ) ) ) ; } } ND_TCHECK ( * pgm ) ; ND_PRINT ( ( ndo , ""PGM,length%u"" , EXTRACT_16BITS ( & pgm -> pgm_length ) ) ) ; if ( ! ndo -> ndo_vflag ) return ; ND_PRINT ( ( ndo , ""0x%02x%02x%02x%02x%02x%02x"" , pgm -> pgm_gsid [ 0 ] , pgm -> pgm_gsid [ 1 ] , pgm -> pgm_gsid [ 2 ] , pgm -> pgm_gsid [ 3 ] , pgm -> pgm_gsid [ 4 ] , pgm -> pgm_gsid [ 5 ] ) ) ; switch ( pgm -> pgm_type ) { case PGM_SPM : { const struct pgm_spm * spm ; spm = ( const struct pgm_spm * ) ( pgm + 1 ) ; ND_TCHECK ( * spm ) ; bp = ( const u_char * ) ( spm + 1 ) ; switch ( EXTRACT_16BITS ( & spm -> pgms_nla_afi ) ) { case AFNUM_INET : ND_TCHECK2 ( * bp , sizeof ( struct in_addr ) ) ; addrtostr ( bp , nla_buf , sizeof ( nla_buf ) ) ; bp += sizeof ( struct in_addr ) ; break ; case AFNUM_INET6 : ND_TCHECK2 ( * bp , sizeof ( struct in6_addr ) ) ; addrtostr6 ( bp , nla_buf , sizeof ( nla_buf ) ) ; bp += sizeof ( struct in6_addr ) ; break ; default : goto trunc ; break ; } ND_PRINT ( ( ndo , ""SPMseq%utrail%ulead%unla%s"" , EXTRACT_32BITS ( & spm -> pgms_seq ) , EXTRACT_32BITS ( & spm -> pgms_trailseq ) , EXTRACT_32BITS ( & spm -> pgms_leadseq ) , nla_buf ) ) ; break ; } case PGM_POLL : { const struct pgm_poll * poll_msg ; poll_msg = ( const struct pgm_poll * ) ( pgm + 1 ) ; ND_TCHECK ( * poll_msg ) ; ND_PRINT ( ( ndo , ""POLLseq%uround%u"" , EXTRACT_32BITS ( & poll_msg -> pgmp_seq ) , EXTRACT_16BITS ( & poll_msg -> pgmp_round ) ) ) ; bp = ( const u_char * ) ( poll_msg + 1 ) ; break ; } case PGM_POLR : { const struct pgm_polr * polr ; uint32_t ivl , rnd , mask ; polr = ( const struct pgm_polr * ) ( pgm + 1 ) ; ND_TCHECK ( * polr ) ; bp = ( const u_char * ) ( polr + 1 ) ; switch ( EXTRACT_16BITS ( & polr -> pgmp_nla_afi ) ) { case AFNUM_INET : ND_TCHECK2 ( * bp , sizeof ( struct in_addr ) ) ; addrtostr ( bp , nla_buf , sizeof ( nla_buf ) ) ; bp += sizeof ( struct in_addr ) ; break ; case AFNUM_INET6 : ND_TCHECK2 ( * bp , sizeof ( struct in6_addr ) ) ; addrtostr6 ( bp , nla_buf , sizeof ( nla_buf ) ) ; bp += sizeof ( struct in6_addr ) ; break ; default : goto trunc ; break ; } ND_TCHECK2 ( * bp , sizeof ( uint32_t ) ) ; ivl = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; ND_TCHECK2 ( * bp , sizeof ( uint32_t ) ) ; rnd = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; ND_TCHECK2 ( * bp , sizeof ( uint32_t ) ) ; mask = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; ND_PRINT ( ( ndo , ""POLRseq%uround%unla%sivl%urnd0x%08x"" ""mask0x%08x"" , EXTRACT_32BITS ( & polr -> pgmp_seq ) , EXTRACT_16BITS ( & polr -> pgmp_round ) , nla_buf , ivl , rnd , mask ) ) ; break ; } case PGM_ODATA : { const struct pgm_data * odata ; odata = ( const struct pgm_data * ) ( pgm + 1 ) ; ND_TCHECK ( * odata ) ; ND_PRINT ( ( ndo , ""ODATAtrail%useq%u"" , EXTRACT_32BITS ( & odata -> pgmd_trailseq ) , EXTRACT_32BITS ( & odata -> pgmd_seq ) ) ) ; bp = ( const u_char * ) ( odata + 1 ) ; break ; } case PGM_RDATA : { const struct pgm_data * rdata ; rdata = ( const struct pgm_data * ) ( pgm + 1 ) ; ND_TCHECK ( * rdata ) ; ND_PRINT ( ( ndo , ""RDATAtrail%useq%u"" , EXTRACT_32BITS ( & rdata -> pgmd_trailseq ) , EXTRACT_32BITS ( & rdata -> pgmd_seq ) ) ) ; bp = ( const u_char * ) ( rdata + 1 ) ; break ; } case PGM_NAK : case PGM_NULLNAK : case PGM_NCF : { const struct pgm_nak * nak ; char source_buf [ INET6_ADDRSTRLEN ] , group_buf [ INET6_ADDRSTRLEN ] ; nak = ( const struct pgm_nak * ) ( pgm + 1 ) ; ND_TCHECK ( * nak ) ; bp = ( const u_char * ) ( nak + 1 ) ; switch ( EXTRACT_16BITS ( & nak -> pgmn_source_afi ) ) { case AFNUM_INET : ND_TCHECK2 ( * bp , sizeof ( struct in_addr ) ) ; addrtostr ( bp , source_buf , sizeof ( source_buf ) ) ; bp += sizeof ( struct in_addr ) ; break ; case AFNUM_INET6 : ND_TCHECK2 ( * bp , sizeof ( struct in6_addr ) ) ; addrtostr6 ( bp , source_buf , sizeof ( source_buf ) ) ; bp += sizeof ( struct in6_addr ) ; break ; default : goto trunc ; break ; } bp += ( 2 * sizeof ( uint16_t ) ) ; switch ( EXTRACT_16BITS ( bp ) ) { case AFNUM_INET : ND_TCHECK2 ( * bp , sizeof ( struct in_addr ) ) ; addrtostr ( bp , group_buf , sizeof ( group_buf ) ) ; bp += sizeof ( struct in_addr ) ; break ; case AFNUM_INET6 : ND_TCHECK2 ( * bp , sizeof ( struct in6_addr ) ) ; addrtostr6 ( bp , group_buf , sizeof ( group_buf ) ) ; bp += sizeof ( struct in6_addr ) ; break ; default : goto trunc ; break ; } switch ( pgm -> pgm_type ) { case PGM_NAK : ND_PRINT ( ( ndo , ""NAK"" ) ) ; break ; case PGM_NULLNAK : ND_PRINT ( ( ndo , ""NNAK"" ) ) ; break ; case PGM_NCF : ND_PRINT ( ( ndo , ""NCF"" ) ) ; break ; default : break ; } ND_PRINT ( ( ndo , ""(%s->%s),seq%u"" , source_buf , group_buf , EXTRACT_32BITS ( & nak -> pgmn_seq ) ) ) ; break ; } case PGM_ACK : { const struct pgm_ack * ack ; ack = ( const struct pgm_ack * ) ( pgm + 1 ) ; ND_TCHECK ( * ack ) ; ND_PRINT ( ( ndo , ""ACKseq%u"" , EXTRACT_32BITS ( & ack -> pgma_rx_max_seq ) ) ) ; bp = ( const u_char * ) ( ack + 1 ) ; break ; } case PGM_SPMR : ND_PRINT ( ( ndo , ""SPMR"" ) ) ; break ; default : ND_PRINT ( ( ndo , ""UNKNOWNtype0x%02x"" , pgm -> pgm_type ) ) ; break ; } if ( pgm -> pgm_options & PGM_OPT_BIT_PRESENT ) { if ( ! ND_TTEST2 ( * bp , PGM_MIN_OPT_LEN ) ) { ND_PRINT ( ( ndo , ""[|OPT]"" ) ) ; return ; } opt_type = * bp ++ ; if ( ( opt_type & PGM_OPT_MASK ) != PGM_OPT_LENGTH ) { ND_PRINT ( ( ndo , ""[Firstoptionbad,shouldbePGM_OPT_LENGTH,is%u]"" , opt_type & PGM_OPT_MASK ) ) ; return ; } opt_len = * bp ++ ; if ( opt_len != 4 ) { ND_PRINT ( ( ndo , ""[BadOPT_LENGTHoption,length%u!=4]"" , opt_len ) ) ; return ; } opts_len = EXTRACT_16BITS ( bp ) ; if ( opts_len < 4 ) { ND_PRINT ( ( ndo , ""[Badtotaloptionlength%u<4]"" , opts_len ) ) ; return ; } bp += sizeof ( uint16_t ) ; ND_PRINT ( ( ndo , ""OPTSLEN%d"" , opts_len ) ) ; opts_len -= 4 ; while ( opts_len ) { if ( opts_len < PGM_MIN_OPT_LEN ) { ND_PRINT ( ( ndo , ""[Totaloptionlengthleavesnoroomforfinaloption]"" ) ) ; return ; } if ( ! ND_TTEST2 ( * bp , 2 ) ) { ND_PRINT ( ( ndo , ""[|OPT]"" ) ) ; return ; } opt_type = * bp ++ ; opt_len = * bp ++ ; if ( opt_len < PGM_MIN_OPT_LEN ) { ND_PRINT ( ( ndo , ""[Badoption,length%u<%u]"" , opt_len , PGM_MIN_OPT_LEN ) ) ; break ; } if ( opts_len < opt_len ) { ND_PRINT ( ( ndo , ""[Totaloptionlengthleavesnoroomforfinaloption]"" ) ) ; return ; } if ( ! ND_TTEST2 ( * bp , opt_len - 2 ) ) { ND_PRINT ( ( ndo , ""[|OPT]"" ) ) ; return ; } switch ( opt_type & PGM_OPT_MASK ) { case PGM_OPT_LENGTH : if ( opt_len != 4 ) { ND_PRINT ( ( ndo , ""[BadOPT_LENGTHoption,length%u!=4]"" , opt_len ) ) ; return ; } ND_PRINT ( ( ndo , ""OPTSLEN(extra?)%d"" , EXTRACT_16BITS ( bp ) ) ) ; bp += sizeof ( uint16_t ) ; opts_len -= 4 ; break ; case PGM_OPT_FRAGMENT : if ( opt_len != 16 ) { ND_PRINT ( ( ndo , ""[BadOPT_FRAGMENToption,length%u!=16]"" , opt_len ) ) ; return ; } bp += 2 ; seq = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; offset = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; len = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; ND_PRINT ( ( ndo , ""FRAGseq%uoff%ulen%u"" , seq , offset , len ) ) ; opts_len -= 16 ; break ; case PGM_OPT_NAK_LIST : bp += 2 ; opt_len -= sizeof ( uint32_t ) ; ND_PRINT ( ( ndo , ""NAKLIST"" ) ) ; while ( opt_len ) { if ( opt_len < sizeof ( uint32_t ) ) { ND_PRINT ( ( ndo , ""[Optionlengthnotamultipleof4]"" ) ) ; return ; } ND_TCHECK2 ( * bp , sizeof ( uint32_t ) ) ; ND_PRINT ( ( ndo , ""%u"" , EXTRACT_32BITS ( bp ) ) ) ; bp += sizeof ( uint32_t ) ; opt_len -= sizeof ( uint32_t ) ; opts_len -= sizeof ( uint32_t ) ; } break ; case PGM_OPT_JOIN : if ( opt_len != 8 ) { ND_PRINT ( ( ndo , ""[BadOPT_JOINoption,length%u!=8]"" , opt_len ) ) ; return ; } bp += 2 ; seq = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; ND_PRINT ( ( ndo , ""JOIN%u"" , seq ) ) ; opts_len -= 8 ; break ; case PGM_OPT_NAK_BO_IVL : if ( opt_len != 12 ) { ND_PRINT ( ( ndo , ""[BadOPT_NAK_BO_IVLoption,length%u!=12]"" , opt_len ) ) ; return ; } bp += 2 ; offset = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; seq = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; ND_PRINT ( ( ndo , ""BACKOFFivl%uivlseq%u"" , offset , seq ) ) ; opts_len -= 12 ; break ; case PGM_OPT_NAK_BO_RNG : if ( opt_len != 12 ) { ND_PRINT ( ( ndo , ""[BadOPT_NAK_BO_RNGoption,length%u!=12]"" , opt_len ) ) ; return ; } bp += 2 ; offset = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; seq = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; ND_PRINT ( ( ndo , ""BACKOFFmax%umin%u"" , offset , seq ) ) ; opts_len -= 12 ; break ; case PGM_OPT_REDIRECT : bp += 2 ; nla_afnum = EXTRACT_16BITS ( bp ) ; bp += ( 2 * sizeof ( uint16_t ) ) ; switch ( nla_afnum ) { case AFNUM_INET : if ( opt_len != 4 + sizeof ( struct in_addr ) ) { ND_PRINT ( ( ndo , ""[BadOPT_REDIRECToption,length%u!=4+addresssize]"" , opt_len ) ) ; return ; } ND_TCHECK2 ( * bp , sizeof ( struct in_addr ) ) ; addrtostr ( bp , nla_buf , sizeof ( nla_buf ) ) ; bp += sizeof ( struct in_addr ) ; opts_len -= 4 + sizeof ( struct in_addr ) ; break ; case AFNUM_INET6 : if ( opt_len != 4 + sizeof ( struct in6_addr ) ) { ND_PRINT ( ( ndo , ""[BadOPT_REDIRECToption,length%u!=4+addresssize]"" , opt_len ) ) ; return ; } ND_TCHECK2 ( * bp , sizeof ( struct in6_addr ) ) ; addrtostr6 ( bp , nla_buf , sizeof ( nla_buf ) ) ; bp += sizeof ( struct in6_addr ) ; opts_len -= 4 + sizeof ( struct in6_addr ) ; break ; default : goto trunc ; break ; } ND_PRINT ( ( ndo , ""REDIRECT%s"" , nla_buf ) ) ; break ; case PGM_OPT_PARITY_PRM : if ( opt_len != 8 ) { ND_PRINT ( ( ndo , ""[BadOPT_PARITY_PRMoption,length%u!=8]"" , opt_len ) ) ; return ; } bp += 2 ; len = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; ND_PRINT ( ( ndo , ""PARITYMAXTGS%u"" , len ) ) ; opts_len -= 8 ; break ; case PGM_OPT_PARITY_GRP : if ( opt_len != 8 ) { ND_PRINT ( ( ndo , ""[BadOPT_PARITY_GRPoption,length%u!=8]"" , opt_len ) ) ; return ; } bp += 2 ; seq = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; ND_PRINT ( ( ndo , ""PARITYGROUP%u"" , seq ) ) ; opts_len -= 8 ; break ; case PGM_OPT_CURR_TGSIZE : if ( opt_len != 8 ) { ND_PRINT ( ( ndo , ""[BadOPT_CURR_TGSIZEoption,length%u!=8]"" , opt_len ) ) ; return ; } bp += 2 ; len = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; ND_PRINT ( ( ndo , ""PARITYATGS%u"" , len ) ) ; opts_len -= 8 ; break ; case PGM_OPT_NBR_UNREACH : if ( opt_len != 4 ) { ND_PRINT ( ( ndo , ""[BadOPT_NBR_UNREACHoption,length%u!=4]"" , opt_len ) ) ; return ; } bp += 2 ; ND_PRINT ( ( ndo , ""NBR_UNREACH"" ) ) ; opts_len -= 4 ; break ; case PGM_OPT_PATH_NLA : ND_PRINT ( ( ndo , ""PATH_NLA[%d]"" , opt_len ) ) ; bp += opt_len ; opts_len -= opt_len ; break ; case PGM_OPT_SYN : if ( opt_len != 4 ) { ND_PRINT ( ( ndo , ""[BadOPT_SYNoption,length%u!=4]"" , opt_len ) ) ; return ; } bp += 2 ; ND_PRINT ( ( ndo , ""SYN"" ) ) ; opts_len -= 4 ; break ; case PGM_OPT_FIN : if ( opt_len != 4 ) { ND_PRINT ( ( ndo , ""[BadOPT_FINoption,length%u!=4]"" , opt_len ) ) ; return ; } bp += 2 ; ND_PRINT ( ( ndo , ""FIN"" ) ) ; opts_len -= 4 ; break ; case PGM_OPT_RST : if ( opt_len != 4 ) { ND_PRINT ( ( ndo , ""[BadOPT_RSToption,length%u!=4]"" , opt_len ) ) ; return ; } bp += 2 ; ND_PRINT ( ( ndo , ""RST"" ) ) ; opts_len -= 4 ; break ; case PGM_OPT_CR : ND_PRINT ( ( ndo , ""CR"" ) ) ; bp += opt_len ; opts_len -= opt_len ; break ; case PGM_OPT_CRQST : if ( opt_len != 4 ) { ND_PRINT ( ( ndo , ""[BadOPT_CRQSToption,length%u!=4]"" , opt_len ) ) ; return ; } bp += 2 ; ND_PRINT ( ( ndo , ""CRQST"" ) ) ; opts_len -= 4 ; break ; case PGM_OPT_PGMCC_DATA : bp += 2 ; offset = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; nla_afnum = EXTRACT_16BITS ( bp ) ; bp += ( 2 * sizeof ( uint16_t ) ) ; switch ( nla_afnum ) { case AFNUM_INET : if ( opt_len != 12 + sizeof ( struct in_addr ) ) { ND_PRINT ( ( ndo , ""[BadOPT_PGMCC_DATAoption,length%u!=12+addresssize]"" , opt_len ) ) ; return ; } ND_TCHECK2 ( * bp , sizeof ( struct in_addr ) ) ; addrtostr ( bp , nla_buf , sizeof ( nla_buf ) ) ; bp += sizeof ( struct in_addr ) ; opts_len -= 12 + sizeof ( struct in_addr ) ; break ; case AFNUM_INET6 : if ( opt_len != 12 + sizeof ( struct in6_addr ) ) { ND_PRINT ( ( ndo , ""[BadOPT_PGMCC_DATAoption,length%u!=12+addresssize]"" , opt_len ) ) ; return ; } ND_TCHECK2 ( * bp , sizeof ( struct in6_addr ) ) ; addrtostr6 ( bp , nla_buf , sizeof ( nla_buf ) ) ; bp += sizeof ( struct in6_addr ) ; opts_len -= 12 + sizeof ( struct in6_addr ) ; break ; default : goto trunc ; break ; } ND_PRINT ( ( ndo , ""PGMCCDATA%u%s"" , offset , nla_buf ) ) ; break ; case PGM_OPT_PGMCC_FEEDBACK : bp += 2 ; offset = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; nla_afnum = EXTRACT_16BITS ( bp ) ; bp += ( 2 * sizeof ( uint16_t ) ) ; switch ( nla_afnum ) { case AFNUM_INET : if ( opt_len != 12 + sizeof ( struct in_addr ) ) { ND_PRINT ( ( ndo , ""[BadOPT_PGMCC_DATAoption,length%u!=12+addresssize]"" , opt_len ) ) ; return ; } ND_TCHECK2 ( * bp , sizeof ( struct in_addr ) ) ; addrtostr ( bp , nla_buf , sizeof ( nla_buf ) ) ; bp += sizeof ( struct in_addr ) ; opts_len -= 12 + sizeof ( struct in_addr ) ; break ; case AFNUM_INET6 : if ( opt_len != 12 + sizeof ( struct in6_addr ) ) { ND_PRINT ( ( ndo , ""[BadOPT_PGMCC_DATAoption,length%u!=12+addresssize]"" , opt_len ) ) ; return ; } ND_TCHECK2 ( * bp , sizeof ( struct in6_addr ) ) ; addrtostr6 ( bp , nla_buf , sizeof ( nla_buf ) ) ; bp += sizeof ( struct in6_addr ) ; opts_len -= 12 + sizeof ( struct in6_addr ) ; break ; default : goto trunc ; break ; } ND_PRINT ( ( ndo , ""PGMCCFEEDBACK%u%s"" , offset , nla_buf ) ) ; break ; default : ND_PRINT ( ( ndo , ""OPT_%02X[%d]"" , opt_type , opt_len ) ) ; bp += opt_len ; opts_len -= opt_len ; break ; } if ( opt_type & PGM_OPT_END ) break ; } } ND_PRINT ( ( ndo , ""[%u]"" , length ) ) ; if ( ndo -> ndo_packettype == PT_PGM_ZMTP1 && ( pgm -> pgm_type == PGM_ODATA || pgm -> pgm_type == PGM_RDATA ) ) zmtp1_print_datagram ( ndo , bp , EXTRACT_16BITS ( & pgm -> pgm_length ) ) ; return ; trunc : ND_PRINT ( ( ndo , ""[|pgm]"" ) ) ; if ( ch != '\\0' ) ND_PRINT ( ( ndo , "">"" ) ) ; } "," case PGM_OPT_LENGTH : # define PGM_OPT_LENGTH_LEN ( 2 + 2 ) ( opt_len != PGM_OPT_LENGTH_LEN ) { ND_PRINT ( ( ndo , ""[BadOPT_LENGTHoption,length%u!=%u]"" , opt_len , PGM_OPT_LENGTH_LEN ) ) ; return ; } ND_PRINT ( ( ndo , ""OPTSLEN(extra?)%d"" , EXTRACT_16BITS ( bp ) ) ) ; bp += 2 ; opts_len -= PGM_OPT_LENGTH_LEN ; break ; case PGM_OPT_FRAGMENT : # define PGM_OPT_FRAGMENT_LEN ( 2 + 2 + 4 + 4 + 4 ) if ( opt_len != PGM_OPT_FRAGMENT_LEN ) { ND_PRINT ( ( ndo , ""[BadOPT_FRAGMENToption,length%u!=%u]"" , opt_len , PGM_OPT_FRAGMENT_LEN ) ) ; return ; } bp += 2 ; seq = EXTRACT_32BITS ( bp ) ; bp += 4 ; offset = EXTRACT_32BITS ( bp ) ; bp += 4 ; len = EXTRACT_32BITS ( bp ) ; bp += 4 ; ND_PRINT ( ( ndo , ""FRAGseq%uoff%ulen%u"" , seq , offset , len ) ) ; opts_len -= PGM_OPT_FRAGMENT_LEN ; break ; case PGM_OPT_NAK_LIST : bp += 2 ; opt_len -= 4 ; ND_PRINT ( ( ndo , ""NAKLIST"" ) ) ; while ( opt_len ) { if ( opt_len < 4 ) { ND_PRINT ( ( ndo , ""[Optionlengthnotamultipleof4]"" ) ) ; return ; } ND_TCHECK2 ( * bp , 4 ) ; ND_PRINT ( ( ndo , ""%u"" , EXTRACT_32BITS ( bp ) ) ) ; bp += 4 ; opt_len -= 4 ; opts_len -= -= 4 ; } break ; case PGM_OPT_JOIN : # define PGM_OPT_JOIN_LEN ( 2 + 2 + 4 ) if ( opt_len ( opt_len != PGM_OPT_JOIN_LEN ) { ND_PRINT ( ( ndo , ""[BadOPT_JOINoption,length%u!=%u]"" , opt_len , PGM_OPT_JOIN_LEN ) ) ; ; bp += 4 ; ND_PRINT ( ( ndo , ""JOIN%u"" , seq ) ) ; ; opts_len -= PGM_OPT_JOIN_LEN ; break ; case PGM_OPT_NAK_BO_IVL : # define PGM_OPT_NAK_BO_IVL_LEN ( 2 + 2 + 4 + 4 ) if ( opt_len if ( opt_len != PGM_OPT_NAK_BO_IVL_LEN ) { ND_PRINT ( ( ndo , ""[BadOPT_NAK_BO_IVLoption,length%u!=%u]"" , opt_len , PGM_OPT_NAK_BO_IVL_LEN ) ) ; return ; } bp += 2 ; offset = EXTRACT_32BITS ( bp ( bp ) ; bp += 4 ; seq = EXTRACT_32BITS ( bp ) ; bp += 4 ; ND_PRINT ( ( ndo , ""BACKOFFivl%uivlseq%u"" , offset , seq ) ) ; opts_len ; opts_len -= PGM_OPT_NAK_BO_IVL_LEN ; break ; case PGM_OPT_NAK_BO_RNG : # define PGM_OPT_NAK_BO_RNG_LEN ( 2 + 2 + 4 + 4 ) if ( opt_len ( opt_len != PGM_OPT_NAK_BO_RNG_LEN ) { ND_PRINT ( ( ndo , ""[BadOPT_NAK_BO_RNGoption,length%u!=%u]"" , opt_len , PGM_OPT_NAK_BO_RNG_LEN ) ) ; += 2 ; offset = EXTRACT_32BITS ( bp ) ; bp += 4 ; ; bp += 4 ; ND_PRINT ( ( ndo , ""BACKOFFmax%umin%u"" , offset , seq ) ; opts_len -= PGM_OPT_NAK_BO_RNG_LEN ; break ; case PGM_OPT_REDIRECT : # define PGM_OPT_REDIRECT_FIXED_LEN ( 2 + 2 + 2 + 2 ) if ( opt_len if ( opt_len < PGM_OPT_REDIRECT_FIXED_LEN ) { ND_PRINT ( ( ndo , ""[BadOPT_REDIRECToption,length%u<%u]"" , opt_len , PGM_OPT_REDIRECT_FIXED_LEN ) ) ; return ; } bp += 2 ; nla_afnum = EXTRACT_16BITS ( bp ) ; bp += 2 + 2 ; switch ( nla_afnum ) { case AFNUM_INET : if ( opt_len != PGM_OPT_REDIRECT_FIXED_LEN + sizeof ( struct in_addr ) ) { ND_PRINT ( ( ndo , ""[BadOPT_REDIRECToption,length%u!=%u+addresssize]"" , opt_len , PGM_OPT_REDIRECT_FIXED_LEN ) ) ; return ; } ND_TCHECK2 ( * bp , sizeof ( struct in_addr ) ) ; addrtostr ( bp , nla_buf , sizeof ( nla_buf ) ) ; bp += sizeof ( struct in_addr ) ; opts_len ; opts_len -= PGM_OPT_REDIRECT_FIXED_LEN + sizeof ( struct in_addr ) ; break ; case AFNUM_INET6 : if ( ( opt_len != PGM_OPT_REDIRECT_FIXED_LEN + sizeof ( struct in6_addr ) ) { ND_PRINT ( ( ndo , ""[BadOPT_REDIRECToption,length%u!=%u+addresssize]"" , PGM_OPT_REDIRECT_FIXED_LEN , opt_len ) return ; } ND_TCHECK2 ( * bp , sizeof ( struct in6_addr ) ) ; addrtostr6 ( bp , nla_buf , sizeof ( nla_buf ) ) ; bp += sizeof ( struct in6_addr ) ; opts_len ; opts_len -= PGM_OPT_REDIRECT_FIXED_LEN + sizeof ( struct in6_addr ) ; break ; default : goto trunc ; break ; } ND_PRINT ( ( ndo , ""REDIRECT%s"" , nla_buf ) ) ; break ; case PGM_OPT_PARITY_PRM : # define PGM_OPT_PARITY_PRM_LEN ( 2 + 2 + 4 ) if ( opt_len ( opt_len != PGM_OPT_PARITY_PRM_LEN ) { ND_PRINT ( ( ndo , ""[BadOPT_PARITY_PRMoption,length%u!=%u]"" , opt_len , PGM_OPT_PARITY_PRM_LEN ) ) ; return ; } bp += 2 ; len = EXTRACT_32BITS ( bp ) ; bp += 4 ; ND_PRINT ( ( ndo , ""PARITYMAXTGS%u"" , len ) ) ; opts_len ; opts_len -= PGM_OPT_PARITY_PRM_LEN ; break ; case PGM_OPT_PARITY_GRP : # define PGM_OPT_PARITY_GRP_LEN ( 2 + 2 + 4 ) if ( opt_len ( opt_len != PGM_OPT_PARITY_GRP_LEN ) { ND_PRINT ( ( ndo , ""[BadOPT_PARITY_GRPoption,length%u!=%u]"" , opt_len , PGM_OPT_PARITY_GRP_LEN ) ) ; return ; } bp += 2 ; seq = EXTRACT_32BITS ( bp ) ; bp += 4 ; ND_PRINT ( ( ndo , ""PARITYGROUP%u"" , seq ) ) ; opts_len ; opts_len -= PGM_OPT_PARITY_GRP_LEN ; break ; case PGM_OPT_CURR_TGSIZE : # define PGM_OPT_CURR_TGSIZE_LEN ( 2 + 2 + 4 ) if ( opt_len != PGM_OPT_CURR_TGSIZE_LEN ) { ND_PRINT ( ( ndo , ""[BadOPT_CURR_TGSIZEoption,length%u!=%u]"" , opt_len , PGM_OPT_CURR_TGSIZE_LEN ) ) ; return ; } bp += 2 ; len = EXTRACT_32BITS ( bp ) ; bp += 4 ; ND_PRINT ( ( ndo , ""PARITYATGS%u"" , len ) ) ; opts_len -= PGM_OPT_CURR_TGSIZE_LEN ; break ; case PGM_OPT_NBR_UNREACH : # define PGM_OPT_NBR_UNREACH_LEN ( 2 + 2 ) if ( opt_len != PGM_OPT_NBR_UNREACH_LEN ) { ND_PRINT ( ( ndo , ""[BadOPT_NBR_UNREACHoption,length%u!=%u]"" , opt_len , PGM_OPT_NBR_UNREACH_LEN ) ) ; return ; } bp += 2 ; ND_PRINT ( ( ndo , ""NBR_UNREACH"" ) ) ; opts_len -= PGM_OPT_NBR_UNREACH_LEN ; break ; case PGM_OPT_PATH_NLA : ND_PRINT ( ( ndo , ""PATH_NLA[%d]"" , opt_len ) ) ; bp += opt_len ; opts_len -= opt_len ; break ; case PGM_OPT_SYN : # define PGM_OPT_SYN_LEN ( 2 + 2 ) if ( opt_len != PGM_OPT_SYN_LEN ) { ND_PRINT ( ( ndo , ""[BadOPT_SYNoption,length%u!=%u]"" , opt_len , PGM_OPT_SYN_LEN ) ) ; return ; } bp += 2 ; ND_PRINT ( ( ndo , ""SYN"" ) ) ; opts_len -= PGM_OPT_SYN_LEN ; break ; case PGM_OPT_FIN : # define PGM_OPT_FIN_LEN ( 2 + 2 ) if ( opt_len != PGM_OPT_FIN_LEN ) { ND_PRINT ( ( ndo , ""[BadOPT_FINoption,length%u!=%u]"" , opt_len , PGM_OPT_FIN_LEN ) ) ; return ; } bp += 2 ; ND_PRINT ( ( ndo , ""FIN"" ) ) ; opts_len -= PGM_OPT_FIN_LEN ; break ; case PGM_OPT_RST : # define PGM_OPT_RST_LEN ( 2 + 2 ) if ( opt_len != PGM_OPT_RST_LEN ) { ND_PRINT ( ( ndo , ""[BadOPT_RSToption,length%u!=%u]"" , opt_len , PGM_OPT_RST_LEN ) ) ; return ; } bp += 2 ; ND_PRINT ( ( ndo , ""RST"" ) ) ; opts_len -= PGM_OPT_RST_LEN ; break ; case PGM_OPT_CR : ND_PRINT ( ( ndo , ""CR"" ) ) ; bp += opt_len ; opts_len -= opt_len ; break ; case PGM_OPT_CRQST : # define PGM_OPT_CRQST_LEN ( 2 + 2 ) if ( opt_len != PGM_OPT_CRQST_LEN ) { ND_PRINT ( ( ndo , ""[BadOPT_CRQSToption,length%u!=%u]"" , opt_len , PGM_OPT_CRQST_LEN ) ) ; return ; } bp += 2 ; ND_PRINT ( ( ndo , ""CRQST"" ) ) ; opts_len -= PGM_OPT_CRQST_LEN ; break ; case PGM_OPT_PGMCC_DATA : # define PGM_OPT_PGMCC_DATA_FIXED_LEN ( 2 + 2 + 4 + 2 + 2 ) if ( opt_len < PGM_OPT_PGMCC_DATA_FIXED_LEN ) { ND_PRINT ( ( ndo , ""[BadOPT_PGMCC_DATAoption,length%u<%u]"" , opt_len , PGM_OPT_PGMCC_DATA_FIXED_LEN ) ) ; return ; } bp += 2 ; offset = EXTRACT_32BITS ( bp ) ; bp += 4 ; nla_afnum = EXTRACT_16BITS ( bp ) ; bp += 2 + 2 ; switch ( nla_afnum ) { case AFNUM_INET : if ( opt_len != PGM_OPT_PGMCC_DATA_FIXED_LEN + sizeof ( struct in_addr ) ) { ND_PRINT ( ( ndo , ""[BadOPT_PGMCC_DATAoption,length%u!=%u+addresssize]"" , opt_len , PGM_OPT_PGMCC_DATA_FIXED_LEN ) ) ; return ; } ND_TCHECK2 ( * bp , sizeof ( struct in_addr ) ) ; addrtostr ( bp , nla_buf , sizeof ( nla_buf ) ) ; bp += sizeof ( struct in_addr ) ; opts_len -= PGM_OPT_PGMCC_DATA_FIXED_LEN + sizeof ( struct in_addr ) ; break ; case AFNUM_INET6 : if ( opt_len != PGM_OPT_PGMCC_DATA_FIXED_LEN + sizeof ( struct in6_addr ) ) { ND_PRINT ( ( ndo , ""[BadOPT_PGMCC_DATAoption,length%u!=%u+addresssize]"" , opt_len , PGM_OPT_PGMCC_DATA_FIXED_LEN ) ) ; return ; } ND_TCHECK2 ( * bp , sizeof ( struct in6_addr ) ) ; addrtostr6 ( bp , nla_buf , sizeof ( nla_buf ) ) ; bp += sizeof ( struct in6_addr ) ; opts_len -= PGM_OPT_PGMCC_DATA_FIXED_LEN + sizeof ( ( ndo , ""PGMCCDATA%u%s"" , offset , nla_buf ) break ; case PGM_OPT_PGMCC_FEEDBACK : # define PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN ( 2 + 2 + 4 + 2 + 2 ) if ( opt_len if ( opt_len < PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN ) { ND_PRINT ( ( ndo , ""[BadPGM_OPT_PGMCC_FEEDBACKoption,length%u<%u]"" , opt_len , PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN ) ) ; return ; } bp += 2 ; offset = EXTRACT_32BITS ( bp ) ; bp += 4 ; nla_afnum = EXTRACT_16BITS ( bp ) ; bp += 2 + 2 ; switch ( nla_afnum ) { case AFNUM_INET : if ( opt_len != PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN + sizeof ( struct in_addr ) ) { ND_PRINT ( ( ndo , ""[BadOPT_PGMCC_FEEDBACKoption,length%u!=%u+addresssize]"" , opt_len , PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN ) ) ; return ; } ND_TCHECK2 ( * bp , sizeof ( struct in_addr ) ) ; addrtostr ( bp , nla_buf , sizeof ( nla_buf ) ) ; bp += sizeof ( struct in_addr ) ; opts_len ; opts_len -= PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN + sizeof ( struct in_addr ) ; break ; case AFNUM_INET6 : if ( ( opt_len != PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN + sizeof ( struct in6_addr ) ) { ND_PRINT ( ( ndo , ""[BadOPT_PGMCC_FEEDBACKoption,length%u!=%u+addresssize]"" , opt_len , PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN ) ) ; return ; } ND_TCHECK2 ( * bp , sizeof ( struct in6_addr ) ) ; addrtostr6 ( bp , nla_buf , sizeof ( nla_buf ) ) ; bp += sizeof ( struct in6_addr ) ; opts_len ; opts_len -= PGM_OPT_PGMCC_FEEDBACK_FIXED_LEN + sizeof ( ",the-tcpdump-group@tcpdump/4601c685e7fd19c3724d5e499c69b8d3ec49933e,CVE-2017-13019,https://github.com/the-tcpdump-group/tcpdump/commit/4601c685e7fd19c3724d5e499c69b8d3ec49933e,2017-09-14T06:29Z 711,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 712,CWE-415,"CWE-415 static void cancel_att_send_op ( struct att_send_op * op ) { if ( op -> destroy ) op -> destroy ( op -> user_data ) ; op -> user_data = NULL ; op -> callback = NULL ; op -> destroy = NULL ; } "," void cancel_att_send_op ( void * data ) { att_send_op * op = data ; if ( op ",bluez@bluez/1cd644db8c23a2f530ddb93cebed7dacc5f5721a,CVE-2020-27153,https://github.com/bluez/bluez/commit/1cd644db8c23a2f530ddb93cebed7dacc5f5721a,2020-10-15T03:15Z 713,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 714,CWE-190,"CWE-190 void nw_cache_free ( nw_cache * cache , void * obj ) { if ( cache -> free < cache -> free_total ) { cache -> free_arr [ cache -> free ++ ] = obj ; } else { uint32_t new_free_total = cache -> free_total * 2 ; void * new_arr = realloc ( cache -> free_arr , new_free_total * sizeof ( void * ) ) ; if ( new_arr ) { cache -> free_total = new_free_total ; cache -> free_arr = new_arr ; cache -> free_arr [ cache -> free ++ ] = obj ; } else { free ( obj ) ; } } } "," ; } else if ( cache -> free_total < NW_CACHE_MAX_SIZE ) ; } } else { free ( obj ) ; } ",viabtc@viabtc_exchange_server/4a7c27bfe98f409623d4d857894d017ff0672cc9,CVE-2018-17568,https://github.com/viabtc/viabtc_exchange_server/commit/4a7c27bfe98f409623d4d857894d017ff0672cc9#diff-0c23effa84a7b85053bac7981a8580c8,2018-09-26T22:29Z 715,CWE-787,"CWE-787 static int jpc_dec_tileinit ( jpc_dec_t * dec , jpc_dec_tile_t * tile ) { jpc_dec_tcomp_t * tcomp ; int compno ; int rlvlno ; jpc_dec_rlvl_t * rlvl ; jpc_dec_band_t * band ; jpc_dec_prc_t * prc ; int bndno ; jpc_tsfb_band_t * bnd ; int bandno ; jpc_dec_ccp_t * ccp ; int prccnt ; jpc_dec_cblk_t * cblk ; int cblkcnt ; uint_fast32_t tlprcxstart ; uint_fast32_t tlprcystart ; uint_fast32_t brprcxend ; uint_fast32_t brprcyend ; uint_fast32_t tlcbgxstart ; uint_fast32_t tlcbgystart ; uint_fast32_t brcbgxend ; uint_fast32_t brcbgyend ; uint_fast32_t cbgxstart ; uint_fast32_t cbgystart ; uint_fast32_t cbgxend ; uint_fast32_t cbgyend ; uint_fast32_t tlcblkxstart ; uint_fast32_t tlcblkystart ; uint_fast32_t brcblkxend ; uint_fast32_t brcblkyend ; uint_fast32_t cblkxstart ; uint_fast32_t cblkystart ; uint_fast32_t cblkxend ; uint_fast32_t cblkyend ; uint_fast32_t tmpxstart ; uint_fast32_t tmpystart ; uint_fast32_t tmpxend ; uint_fast32_t tmpyend ; jpc_dec_cp_t * cp ; jpc_tsfb_band_t bnds [ 64 ] ; jpc_pchg_t * pchg ; int pchgno ; jpc_dec_cmpt_t * cmpt ; cp = tile -> cp ; tile -> realmode = 0 ; if ( cp -> mctid == JPC_MCT_ICT ) { tile -> realmode = 1 ; } for ( compno = 0 , tcomp = tile -> tcomps , cmpt = dec -> cmpts ; compno < dec -> numcomps ; ++ compno , ++ tcomp , ++ cmpt ) { ccp = & tile -> cp -> ccps [ compno ] ; if ( ccp -> qmfbid == JPC_COX_INS ) { tile -> realmode = 1 ; } tcomp -> numrlvls = ccp -> numrlvls ; if ( ! ( tcomp -> rlvls = jas_alloc2 ( tcomp -> numrlvls , sizeof ( jpc_dec_rlvl_t ) ) ) ) { return - 1 ; } if ( ! ( tcomp -> data = jas_seq2d_create ( JPC_CEILDIV ( tile -> xstart , cmpt -> hstep ) , JPC_CEILDIV ( tile -> ystart , cmpt -> vstep ) , JPC_CEILDIV ( tile -> xend , cmpt -> hstep ) , JPC_CEILDIV ( tile -> yend , cmpt -> vstep ) ) ) ) { return - 1 ; } if ( ! ( tcomp -> tsfb = jpc_cod_gettsfb ( ccp -> qmfbid , tcomp -> numrlvls - 1 ) ) ) { return - 1 ; } { jpc_tsfb_getbands ( tcomp -> tsfb , jas_seq2d_xstart ( tcomp -> data ) , jas_seq2d_ystart ( tcomp -> data ) , jas_seq2d_xend ( tcomp -> data ) , jas_seq2d_yend ( tcomp -> data ) , bnds ) ; } for ( rlvlno = 0 , rlvl = tcomp -> rlvls ; rlvlno < tcomp -> numrlvls ; ++ rlvlno , ++ rlvl ) { rlvl -> bands = 0 ; rlvl -> xstart = JPC_CEILDIVPOW2 ( tcomp -> xstart , tcomp -> numrlvls - 1 - rlvlno ) ; rlvl -> ystart = JPC_CEILDIVPOW2 ( tcomp -> ystart , tcomp -> numrlvls - 1 - rlvlno ) ; rlvl -> xend = JPC_CEILDIVPOW2 ( tcomp -> xend , tcomp -> numrlvls - 1 - rlvlno ) ; rlvl -> yend = JPC_CEILDIVPOW2 ( tcomp -> yend , tcomp -> numrlvls - 1 - rlvlno ) ; rlvl -> prcwidthexpn = ccp -> prcwidthexpns [ rlvlno ] ; rlvl -> prcheightexpn = ccp -> prcheightexpns [ rlvlno ] ; tlprcxstart = JPC_FLOORDIVPOW2 ( rlvl -> xstart , rlvl -> prcwidthexpn ) << rlvl -> prcwidthexpn ; tlprcystart = JPC_FLOORDIVPOW2 ( rlvl -> ystart , rlvl -> prcheightexpn ) << rlvl -> prcheightexpn ; brprcxend = JPC_CEILDIVPOW2 ( rlvl -> xend , rlvl -> prcwidthexpn ) << rlvl -> prcwidthexpn ; brprcyend = JPC_CEILDIVPOW2 ( rlvl -> yend , rlvl -> prcheightexpn ) << rlvl -> prcheightexpn ; rlvl -> numhprcs = ( brprcxend - tlprcxstart ) >> rlvl -> prcwidthexpn ; rlvl -> numvprcs = ( brprcyend - tlprcystart ) >> rlvl -> prcheightexpn ; rlvl -> numprcs = rlvl -> numhprcs * rlvl -> numvprcs ; if ( rlvl -> xstart >= rlvl -> xend || rlvl -> ystart >= rlvl -> yend ) { rlvl -> bands = 0 ; rlvl -> numprcs = 0 ; rlvl -> numhprcs = 0 ; rlvl -> numvprcs = 0 ; continue ; } if ( ! rlvlno ) { tlcbgxstart = tlprcxstart ; tlcbgystart = tlprcystart ; brcbgxend = brprcxend ; brcbgyend = brprcyend ; rlvl -> cbgwidthexpn = rlvl -> prcwidthexpn ; rlvl -> cbgheightexpn = rlvl -> prcheightexpn ; } else { tlcbgxstart = JPC_CEILDIVPOW2 ( tlprcxstart , 1 ) ; tlcbgystart = JPC_CEILDIVPOW2 ( tlprcystart , 1 ) ; brcbgxend = JPC_CEILDIVPOW2 ( brprcxend , 1 ) ; brcbgyend = JPC_CEILDIVPOW2 ( brprcyend , 1 ) ; rlvl -> cbgwidthexpn = rlvl -> prcwidthexpn - 1 ; rlvl -> cbgheightexpn = rlvl -> prcheightexpn - 1 ; } rlvl -> cblkwidthexpn = JAS_MIN ( ccp -> cblkwidthexpn , rlvl -> cbgwidthexpn ) ; rlvl -> cblkheightexpn = JAS_MIN ( ccp -> cblkheightexpn , rlvl -> cbgheightexpn ) ; rlvl -> numbands = ( ! rlvlno ) ? 1 : 3 ; if ( ! ( rlvl -> bands = jas_alloc2 ( rlvl -> numbands , sizeof ( jpc_dec_band_t ) ) ) ) { return - 1 ; } for ( bandno = 0 , band = rlvl -> bands ; bandno < rlvl -> numbands ; ++ bandno , ++ band ) { bndno = ( ! rlvlno ) ? 0 : ( 3 * ( rlvlno - 1 ) + bandno + 1 ) ; bnd = & bnds [ bndno ] ; band -> orient = bnd -> orient ; band -> stepsize = ccp -> stepsizes [ bndno ] ; band -> analgain = JPC_NOMINALGAIN ( ccp -> qmfbid , tcomp -> numrlvls - 1 , rlvlno , band -> orient ) ; band -> absstepsize = jpc_calcabsstepsize ( band -> stepsize , cmpt -> prec + band -> analgain ) ; band -> numbps = ccp -> numguardbits + JPC_QCX_GETEXPN ( band -> stepsize ) - 1 ; band -> roishift = ( ccp -> roishift + band -> numbps >= JPC_PREC ) ? ( JPC_PREC - 1 - band -> numbps ) : ccp -> roishift ; band -> data = 0 ; band -> prcs = 0 ; if ( bnd -> xstart == bnd -> xend || bnd -> ystart == bnd -> yend ) { continue ; } if ( ! ( band -> data = jas_seq2d_create ( 0 , 0 , 0 , 0 ) ) ) { return - 1 ; } jas_seq2d_bindsub ( band -> data , tcomp -> data , bnd -> locxstart , bnd -> locystart , bnd -> locxend , bnd -> locyend ) ; jas_seq2d_setshift ( band -> data , bnd -> xstart , bnd -> ystart ) ; assert ( rlvl -> numprcs ) ; if ( ! ( band -> prcs = jas_alloc2 ( rlvl -> numprcs , sizeof ( jpc_dec_prc_t ) ) ) ) { return - 1 ; } cbgxstart = tlcbgxstart ; cbgystart = tlcbgystart ; for ( prccnt = rlvl -> numprcs , prc = band -> prcs ; prccnt > 0 ; -- prccnt , ++ prc ) { cbgxend = cbgxstart + ( 1 << rlvl -> cbgwidthexpn ) ; cbgyend = cbgystart + ( 1 << rlvl -> cbgheightexpn ) ; prc -> xstart = JAS_MAX ( cbgxstart , JAS_CAST ( uint_fast32_t , jas_seq2d_xstart ( band -> data ) ) ) ; prc -> ystart = JAS_MAX ( cbgystart , JAS_CAST ( uint_fast32_t , jas_seq2d_ystart ( band -> data ) ) ) ; prc -> xend = JAS_MIN ( cbgxend , JAS_CAST ( uint_fast32_t , jas_seq2d_xend ( band -> data ) ) ) ; prc -> yend = JAS_MIN ( cbgyend , JAS_CAST ( uint_fast32_t , jas_seq2d_yend ( band -> data ) ) ) ; if ( prc -> xend > prc -> xstart && prc -> yend > prc -> ystart ) { tlcblkxstart = JPC_FLOORDIVPOW2 ( prc -> xstart , rlvl -> cblkwidthexpn ) << rlvl -> cblkwidthexpn ; tlcblkystart = JPC_FLOORDIVPOW2 ( prc -> ystart , rlvl -> cblkheightexpn ) << rlvl -> cblkheightexpn ; brcblkxend = JPC_CEILDIVPOW2 ( prc -> xend , rlvl -> cblkwidthexpn ) << rlvl -> cblkwidthexpn ; brcblkyend = JPC_CEILDIVPOW2 ( prc -> yend , rlvl -> cblkheightexpn ) << rlvl -> cblkheightexpn ; prc -> numhcblks = ( brcblkxend - tlcblkxstart ) >> rlvl -> cblkwidthexpn ; prc -> numvcblks = ( brcblkyend - tlcblkystart ) >> rlvl -> cblkheightexpn ; prc -> numcblks = prc -> numhcblks * prc -> numvcblks ; assert ( prc -> numcblks > 0 ) ; if ( ! ( prc -> incltagtree = jpc_tagtree_create ( prc -> numhcblks , prc -> numvcblks ) ) ) { return - 1 ; } if ( ! ( prc -> numimsbstagtree = jpc_tagtree_create ( prc -> numhcblks , prc -> numvcblks ) ) ) { return - 1 ; } if ( ! ( prc -> cblks = jas_alloc2 ( prc -> numcblks , sizeof ( jpc_dec_cblk_t ) ) ) ) { return - 1 ; } cblkxstart = cbgxstart ; cblkystart = cbgystart ; for ( cblkcnt = prc -> numcblks , cblk = prc -> cblks ; cblkcnt > 0 ; ) { cblkxend = cblkxstart + ( 1 << rlvl -> cblkwidthexpn ) ; cblkyend = cblkystart + ( 1 << rlvl -> cblkheightexpn ) ; tmpxstart = JAS_MAX ( cblkxstart , prc -> xstart ) ; tmpystart = JAS_MAX ( cblkystart , prc -> ystart ) ; tmpxend = JAS_MIN ( cblkxend , prc -> xend ) ; tmpyend = JAS_MIN ( cblkyend , prc -> yend ) ; if ( tmpxend > tmpxstart && tmpyend > tmpystart ) { cblk -> firstpassno = - 1 ; cblk -> mqdec = 0 ; cblk -> nulldec = 0 ; cblk -> flags = 0 ; cblk -> numpasses = 0 ; cblk -> segs . head = 0 ; cblk -> segs . tail = 0 ; cblk -> curseg = 0 ; cblk -> numimsbs = 0 ; cblk -> numlenbits = 3 ; cblk -> flags = 0 ; if ( ! ( cblk -> data = jas_seq2d_create ( 0 , 0 , 0 , 0 ) ) ) { return - 1 ; } jas_seq2d_bindsub ( cblk -> data , band -> data , tmpxstart , tmpystart , tmpxend , tmpyend ) ; ++ cblk ; -- cblkcnt ; } cblkxstart += 1 << rlvl -> cblkwidthexpn ; if ( cblkxstart >= cbgxend ) { cblkxstart = cbgxstart ; cblkystart += 1 << rlvl -> cblkheightexpn ; } } } else { prc -> cblks = 0 ; prc -> incltagtree = 0 ; prc -> numimsbstagtree = 0 ; } cbgxstart += 1 << rlvl -> cbgwidthexpn ; if ( cbgxstart >= brcbgxend ) { cbgxstart = tlcbgxstart ; cbgystart += 1 << rlvl -> cbgheightexpn ; } } } } } if ( ! ( tile -> pi = jpc_dec_pi_create ( dec , tile ) ) ) { return - 1 ; } for ( pchgno = 0 ; pchgno < jpc_pchglist_numpchgs ( tile -> cp -> pchglist ) ; ++ pchgno ) { pchg = jpc_pchg_copy ( jpc_pchglist_get ( tile -> cp -> pchglist , pchgno ) ) ; assert ( pchg ) ; jpc_pi_addpchg ( tile -> pi , pchg ) ; } jpc_pi_init ( tile -> pi ) ; return 0 ; } "," jpc_tsfb_band_t bnds [ JPC_MAXBANDS ] ; jpc_pchg_t ",mdadams@jasper/1abc2e5a401a4bf1d5ca4df91358ce5df111f495,CVE-2016-9560,https://github.com/mdadams/jasper/commit/1abc2e5a401a4bf1d5ca4df91358ce5df111f495,2017-02-15T19:59Z 716,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 717,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 718,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 719,CWE-399,"CWE-399 static void xen_netbk_fill_frags ( struct xen_netbk * netbk , struct sk_buff * skb ) { struct skb_shared_info * shinfo = skb_shinfo ( skb ) ; int nr_frags = shinfo -> nr_frags ; int i ; for ( i = 0 ; i < nr_frags ; i ++ ) { skb_frag_t * frag = shinfo -> frags + i ; struct xen_netif_tx_request * txp ; struct page * page ; u16 pending_idx ; pending_idx = frag_get_pending_idx ( frag ) ; txp = & netbk -> pending_tx_info [ pending_idx ] . req ; page = virt_to_page ( idx_to_kaddr ( netbk , pending_idx ) ) ; __skb_fill_page_desc ( skb , i , page , txp -> offset , txp -> size ) ; skb -> len += txp -> size ; skb -> data_len += txp -> size ; skb -> truesize += txp -> size ; get_page ( netbk -> mmap_pages [ pending_idx ] ) ; xen_netbk_idx_release ( netbk , pending_idx ) ; } } "," netbk , pending_idx , XEN_NETIF_RSP_OKAY ",torvalds@linux/7d5145d8eb2b9791533ffe4dc003b129b9696c48,CVE-2013-0217,https://github.com/torvalds/linux/commit/7d5145d8eb2b9791533ffe4dc003b129b9696c48,2013-02-18T04:41Z 720,CWE-000,"CWE-000 static void __update_open_stateid ( struct nfs4_state * state , nfs4_stateid * open_stateid , const nfs4_stateid * deleg_stateid , int open_flags ) { write_seqlock ( & state -> seqlock ) ; if ( deleg_stateid != NULL ) { memcpy ( state -> stateid . data , deleg_stateid -> data , sizeof ( state -> stateid . data ) ) ; set_bit ( NFS_DELEGATED_STATE , & state -> flags ) ; } if ( open_stateid != NULL ) nfs_set_open_stateid_locked ( state , open_stateid , open_flags ) ; write_sequnlock ( & state -> seqlock ) ; spin_lock ( & state -> owner -> so_lock ) ; update_open_stateflags ( state , open_flags ) ; spin_unlock ( & state -> owner -> so_lock ) ; } "," * deleg_stateid , fmode_t fmode ) { write_seqlock , open_stateid , fmode ) ; write_sequnlock ( state , fmode ) ; spin_unlock ",torvalds@linux/dc0b027dfadfcb8a5504f7d8052754bf8d501ab9,CVE-2011-4324,https://github.com/torvalds/linux/commit/dc0b027dfadfcb8a5504f7d8052754bf8d501ab9,2012-06-21T23:55Z 721,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 722,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 723,CWE-476,"CWE-476 int jp2_box_put ( jp2_box_t * box , jas_stream_t * out ) { jas_stream_t * tmpstream ; bool extlen ; bool dataflag ; tmpstream = 0 ; dataflag = ! ( box -> info -> flags & ( JP2_BOX_SUPER | JP2_BOX_NODATA ) ) ; if ( dataflag ) { if ( ! ( tmpstream = jas_stream_memopen ( 0 , 0 ) ) ) { goto error ; } if ( box -> ops -> putdata ) { if ( ( * box -> ops -> putdata ) ( box , tmpstream ) ) { goto error ; } } box -> len = jas_stream_tell ( tmpstream ) + JP2_BOX_HDRLEN ( false ) ; jas_stream_rewind ( tmpstream ) ; } extlen = ( box -> len >= ( ( ( uint_fast64_t ) 1 ) << 32 ) ) != 0 ; if ( jp2_putuint32 ( out , extlen ? 1 : box -> len ) ) { goto error ; } if ( jp2_putuint32 ( out , box -> type ) ) { goto error ; } if ( extlen ) { if ( jp2_putuint64 ( out , box -> len ) ) { goto error ; } } if ( dataflag ) { if ( jas_stream_copy ( out , tmpstream , box -> len - JP2_BOX_HDRLEN ( false ) ) ) { goto error ; } jas_stream_close ( tmpstream ) ; } return 0 ; error : if ( tmpstream ) { jas_stream_close ( tmpstream ) ; } return - 1 ; } "," ) ) { jas_eprintf ( ""cannotcopyboxdata\\n"" ) ; ",mdadams@jasper/e96fc4fdd525fa0ede28074a7e2b1caf94b58b0d,CVE-2017-6850,https://github.com/mdadams/jasper/commit/e96fc4fdd525fa0ede28074a7e2b1caf94b58b0d,2017-03-15T14:59Z 724,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 725,CWE-119,"CWE-119 int vp8dx_receive_compressed_data ( VP8D_COMP * pbi , size_t size , const uint8_t * source , int64_t time_stamp ) { # if HAVE_NEON int64_t dx_store_reg [ 8 ] ; # endif VP8_COMMON * cm = & pbi -> common ; int retcode = - 1 ; pbi -> common . error . error_code = VPX_CODEC_OK ; retcode = check_fragments_for_errors ( pbi ) ; if ( retcode <= 0 ) return retcode ; # if HAVE_NEON # if CONFIG_RUNTIME_CPU_DETECT if ( cm -> cpu_caps & HAS_NEON ) # endif { vp8_push_neon ( dx_store_reg ) ; } # endif cm -> new_fb_idx = get_free_fb ( cm ) ; pbi -> dec_fb_ref [ INTRA_FRAME ] = & cm -> yv12_fb [ cm -> new_fb_idx ] ; pbi -> dec_fb_ref [ LAST_FRAME ] = & cm -> yv12_fb [ cm -> lst_fb_idx ] ; pbi -> dec_fb_ref [ GOLDEN_FRAME ] = & cm -> yv12_fb [ cm -> gld_fb_idx ] ; pbi -> dec_fb_ref [ ALTREF_FRAME ] = & cm -> yv12_fb [ cm -> alt_fb_idx ] ; if ( setjmp ( pbi -> common . error . jmp ) ) { cm -> yv12_fb [ cm -> lst_fb_idx ] . corrupted = 1 ; if ( cm -> fb_idx_ref_cnt [ cm -> new_fb_idx ] > 0 ) cm -> fb_idx_ref_cnt [ cm -> new_fb_idx ] -- ; goto decode_exit ; } pbi -> common . error . setjmp = 1 ; retcode = vp8_decode_frame ( pbi ) ; if ( retcode < 0 ) { if ( cm -> fb_idx_ref_cnt [ cm -> new_fb_idx ] > 0 ) cm -> fb_idx_ref_cnt [ cm -> new_fb_idx ] -- ; pbi -> common . error . error_code = VPX_CODEC_ERROR ; goto decode_exit ; } if ( swap_frame_buffers ( cm ) ) { pbi -> common . error . error_code = VPX_CODEC_ERROR ; goto decode_exit ; } vp8_clear_system_state ( ) ; if ( cm -> show_frame ) { cm -> current_video_frame ++ ; cm -> show_frame_mi = cm -> mi ; } # if CONFIG_ERROR_CONCEALMENT if ( pbi -> ec_enabled && pbi -> common . prev_mi ) { MODE_INFO * tmp = pbi -> common . prev_mi ; int row , col ; pbi -> common . prev_mi = pbi -> common . mi ; pbi -> common . mi = tmp ; for ( row = 0 ; row < pbi -> common . mb_rows ; ++ row ) { for ( col = 0 ; col < pbi -> common . mb_cols ; ++ col ) { const int i = row * pbi -> common . mode_info_stride + col ; pbi -> common . mi [ i ] . mbmi . segment_id = pbi -> common . prev_mi [ i ] . mbmi . segment_id ; } } } # endif pbi -> ready_for_new_data = 0 ; pbi -> last_time_stamp = time_stamp ; decode_exit : # if HAVE_NEON # if CONFIG_RUNTIME_CPU_DETECT if ( cm -> cpu_caps & HAS_NEON ) # endif { vp8_pop_neon ( dx_store_reg ) ; } # endif pbi -> common . error . setjmp = 0 ; return retcode ; } "," time_stamp ) { VP8_COMMON * cm - 1 ; ( void ) size ; ( void ) source ; return retcode ; cm -> new_fb_idx ; decode_exit : pbi -> common = 0 ; vp8_clear_system_state ( ) ; ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 726,CWE-755,"CWE-755 void AcpiNsTerminate ( void ) { ACPI_STATUS Status ; ACPI_FUNCTION_TRACE ( NsTerminate ) ; # ifdef ACPI_EXEC_APP { ACPI_OPERAND_OBJECT * Prev ; ACPI_OPERAND_OBJECT * Next ; Next = AcpiGbl_ModuleCodeList ; while ( Next ) { Prev = Next ; Next = Next -> Method . Mutex ; Prev -> Method . Mutex = NULL ; AcpiUtRemoveReference ( Prev ) ; } } # endif AcpiNsDeleteNamespaceSubtree ( AcpiGbl_RootNode ) ; Status = AcpiUtAcquireMutex ( ACPI_MTX_NAMESPACE ) ; if ( ACPI_FAILURE ( Status ) ) { return_VOID ; } AcpiNsDeleteNode ( AcpiGbl_RootNode ) ; ( void ) AcpiUtReleaseMutex ( ACPI_MTX_NAMESPACE ) ; ACPI_DEBUG_PRINT ( ( ACPI_DB_INFO , ""Namespacefreed\\n"" ) ) ; return_VOID ; } "," ACPI_STATUS Status ; ACPI_OPERAND_OBJECT * Prev ACPI_OPERAND_OBJECT * Next ; ACPI_FUNCTION_TRACE ( NsTerminate ) ) ; } AcpiNsDeleteNamespaceSubtree ( AcpiGbl_RootNode ",torvalds@linux/a23325b2e583556eae88ed3f764e457786bf4df6,CVE-2017-11472,https://github.com/torvalds/linux/commit/a23325b2e583556eae88ed3f764e457786bf4df6,2017-07-20T04:29Z 727,CWE-125,"CWE-125 PyObject * ast2obj_withitem ( void * _o ) { withitem_ty o = ( withitem_ty ) _o ; PyObject * result = NULL , * value = NULL ; if ( ! o ) { Py_INCREF ( Py_None ) ; return Py_None ; } result = PyType_GenericNew ( withitem_type , NULL , NULL ) ; if ( ! result ) return NULL ; value = ast2obj_expr ( o -> context_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_context_expr , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> optional_vars ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_optional_vars , 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 728,CWE-20,"CWE-20 void LineTo ( double x1 , double y1 ) { outpos += sprintf ( outpos , ""\\n%12.3f%12.3fl"" , x1 , y1 ) ; } "," y1 ) { sprintf ( outputbuffer , ""\\n%12.3f%12.3fl"" , y1 ) ; sendClean ( outputbuffer ) ; ",TeX-Live@texlive-source/9216833a3888a4105a18e8c349f65b045ddb1079,CVE-2019-18604,https://github.com/TeX-Live/texlive-source/commit/9216833a3888a4105a18e8c349f65b045ddb1079,2019-10-29T19:15Z 729,CWE-20,"CWE-20 error_t dm9000UpdateMacAddrFilter ( NetInterface * interface ) { uint_t i ; uint_t k ; uint32_t crc ; uint8_t hashTable [ 8 ] ; MacFilterEntry * entry ; TRACE_DEBUG ( ""UpdatingMACfilter...\\r\\n"" ) ; osMemset ( hashTable , 0 , sizeof ( hashTable ) ) ; hashTable [ 7 ] = 0x80 ; for ( i = 0 ; i < MAC_ADDR_FILTER_SIZE ; i ++ ) { entry = & interface -> macAddrFilter [ i ] ; if ( entry -> refCount > 0 ) { crc = dm9000CalcCrc ( & entry -> addr , sizeof ( MacAddr ) ) ; k = crc & 0x3F ; hashTable [ k / 8 ] |= ( 1 << ( k % 8 ) ) ; } } for ( i = 0 ; i < 8 ; i ++ ) { dm9000WriteReg ( DM9000_REG_MAR0 + i , hashTable [ i ] ) ; } TRACE_DEBUG ( ""MAR=%02"" PRIX8 ""%02"" PRIX8 ""%02"" PRIX8 ""%02"" PRIX8 """" ""%02"" PRIX8 ""%02"" PRIX8 ""%02"" PRIX8 ""%02"" PRIX8 ""\\r\\n"" , dm9000ReadReg ( DM9000_REG_MAR0 ) , dm9000ReadReg ( DM9000_REG_MAR1 ) , dm9000ReadReg ( DM9000_REG_MAR2 ) , dm9000ReadReg ( DM9000_REG_MAR3 ) , dm9000ReadReg ( DM9000_REG_MAR4 ) , dm9000ReadReg ( DM9000_REG_MAR5 ) , dm9000ReadReg ( DM9000_REG_MAR6 ) , dm9000ReadReg ( DM9000_REG_MAR7 ) ) ; return NO_ERROR ; } "," { dm9000WriteReg ( DM9000_MAR0 + i , , dm9000ReadReg ( DM9000_MAR0 ) , dm9000ReadReg ( DM9000_MAR1 ) , dm9000ReadReg ( DM9000_MAR2 ) , dm9000ReadReg ( DM9000_MAR3 ) , dm9000ReadReg ( DM9000_MAR4 ) , dm9000ReadReg ( DM9000_MAR5 ) , dm9000ReadReg ( DM9000_MAR6 ) , dm9000ReadReg ( DM9000_MAR7 ) ) ; ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 730,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 731,CWE-125,"CWE-125 static const char * parse_field ( netdissect_options * ndo , const char * * pptr , int * len ) { const char * s ; if ( * len <= 0 || ! pptr || ! * pptr ) return NULL ; if ( * pptr > ( const char * ) ndo -> ndo_snapend ) return NULL ; s = * pptr ; while ( * pptr <= ( const char * ) ndo -> ndo_snapend && * len >= 0 && * * pptr ) { ( * pptr ) ++ ; ( * len ) -- ; } ( * pptr ) ++ ; ( * len ) -- ; if ( * len < 0 || * pptr > ( const char * ) ndo -> ndo_snapend ) return NULL ; return s ; } "," int * len , int * truncated * s ; s = * * pptr ; for ( ; ; ) { if ( * len == 0 ) { return NULL ; } if ( ! ND_TTEST ( * * pptr * pptr ) ) { * truncated = 1 ; return NULL ; } if ( * * pptr == '\\0' ) { break ; } ( * pptr ) -- ; return s ; ",the-tcpdump-group@tcpdump/d17507ffa3e9742199b02a66aa940e79ababfa30,CVE-2017-12902,https://github.com/the-tcpdump-group/tcpdump/commit/d17507ffa3e9742199b02a66aa940e79ababfa30,2017-09-14T06:29Z 732,CWE-20,"CWE-20 TEE_Result tee_mmu_check_access_rights ( const struct user_ta_ctx * utc , uint32_t flags , uaddr_t uaddr , size_t len ) { uaddr_t a ; size_t addr_incr = MIN ( CORE_MMU_USER_CODE_SIZE , CORE_MMU_USER_PARAM_SIZE ) ; if ( ADD_OVERFLOW ( uaddr , len , & a ) ) return TEE_ERROR_ACCESS_DENIED ; if ( ( flags & TEE_MEMORY_ACCESS_NONSECURE ) && ( flags & TEE_MEMORY_ACCESS_SECURE ) ) return TEE_ERROR_ACCESS_DENIED ; if ( ! ( flags & TEE_MEMORY_ACCESS_ANY_OWNER ) && ! tee_mmu_is_vbuf_inside_ta_private ( utc , ( void * ) uaddr , len ) ) return TEE_ERROR_ACCESS_DENIED ; for ( a = uaddr ; a < ( uaddr + len ) ; a += addr_incr ) { uint32_t attr ; TEE_Result res ; res = tee_mmu_user_va2pa_attr ( utc , ( void * ) a , NULL , & attr ) ; if ( res != TEE_SUCCESS ) return res ; if ( ( flags & TEE_MEMORY_ACCESS_NONSECURE ) && ( attr & TEE_MATTR_SECURE ) ) return TEE_ERROR_ACCESS_DENIED ; if ( ( flags & TEE_MEMORY_ACCESS_SECURE ) && ! ( attr & TEE_MATTR_SECURE ) ) return TEE_ERROR_ACCESS_DENIED ; if ( ( flags & TEE_MEMORY_ACCESS_WRITE ) && ! ( attr & TEE_MATTR_UW ) ) return TEE_ERROR_ACCESS_DENIED ; if ( ( flags & TEE_MEMORY_ACCESS_READ ) && ! ( attr & TEE_MATTR_UR ) ) return TEE_ERROR_ACCESS_DENIED ; } return TEE_SUCCESS ; } "," uaddr_t a ; uaddr_t end_addr = 0 ; len , & end_addr ) ) return ( a = ROUNDDOWN ( uaddr , addr_incr ) ; a < ; a < end_addr ; a += ",OP-TEE@optee_os/95f36d661f2b75887772ea28baaad904bde96970,CVE-2019-1010293,https://github.com/OP-TEE/optee_os/commit/95f36d661f2b75887772ea28baaad904bde96970,2019-07-15T18:15Z 733,CWE-119,"CWE-119 int validate_camera_metadata_structure ( const camera_metadata_t * metadata , const size_t * expected_size ) { if ( metadata == NULL ) { ALOGE ( ""%s:metadataisnull!"" , __FUNCTION__ ) ; return ERROR ; } { static const struct { const char * name ; size_t alignment ; } alignments [ ] = { { . name = ""camera_metadata"" , . alignment = METADATA_ALIGNMENT } , { . name = ""camera_metadata_buffer_entry"" , . alignment = ENTRY_ALIGNMENT } , { . name = ""camera_metadata_data"" , . alignment = DATA_ALIGNMENT } , } ; for ( size_t i = 0 ; i < sizeof ( alignments ) / sizeof ( alignments [ 0 ] ) ; ++ i ) { uintptr_t aligned_ptr = ALIGN_TO ( metadata , alignments [ i ] . alignment ) ; if ( ( uintptr_t ) metadata != aligned_ptr ) { ALOGE ( ""%s:Metadatapointerisnotaligned(actual%p,"" ""expected%p)totype%s"" , __FUNCTION__ , metadata , ( void * ) aligned_ptr , alignments [ i ] . name ) ; return ERROR ; } } } if ( expected_size != NULL && metadata -> size > * expected_size ) { ALOGE ( ""%s:Metadatasize(%"" PRIu32 "")shouldbe<=expectedsize(%zu)"" , __FUNCTION__ , metadata -> size , * expected_size ) ; return ERROR ; } if ( metadata -> entry_count > metadata -> entry_capacity ) { ALOGE ( ""%s:Entrycount(%"" PRIu32 "")shouldbe<=entrycapacity"" ""(%"" PRIu32 "")"" , __FUNCTION__ , metadata -> entry_count , metadata -> entry_capacity ) ; return ERROR ; } const metadata_uptrdiff_t entries_end = metadata -> entries_start + metadata -> entry_capacity ; if ( entries_end < metadata -> entries_start || entries_end > metadata -> data_start ) { ALOGE ( ""%s:Entrystart+capacity(%"" PRIu32 "")shouldbe<=datastart"" ""(%"" PRIu32 "")"" , __FUNCTION__ , ( metadata -> entries_start + metadata -> entry_capacity ) , metadata -> data_start ) ; return ERROR ; } const metadata_uptrdiff_t data_end = metadata -> data_start + metadata -> data_capacity ; if ( data_end < metadata -> data_start || data_end > metadata -> size ) { ALOGE ( ""%s:Datastart+capacity(%"" PRIu32 "")shouldbe<=totalsize"" ""(%"" PRIu32 "")"" , __FUNCTION__ , ( metadata -> data_start + metadata -> data_capacity ) , metadata -> size ) ; return ERROR ; } const metadata_size_t entry_count = metadata -> entry_count ; camera_metadata_buffer_entry_t * entries = get_entries ( metadata ) ; for ( size_t i = 0 ; i < entry_count ; ++ i ) { if ( ( uintptr_t ) & entries [ i ] != ALIGN_TO ( & entries [ i ] , ENTRY_ALIGNMENT ) ) { ALOGE ( ""%s:Entryindex%zuhadbadalignment(address%p),"" ""expectedalignment%zu"" , __FUNCTION__ , i , & entries [ i ] , ENTRY_ALIGNMENT ) ; return ERROR ; } camera_metadata_buffer_entry_t entry = entries [ i ] ; if ( entry . type >= NUM_TYPES ) { ALOGE ( ""%s:Entryindex%zuhadabadtype%d"" , __FUNCTION__ , i , entry . type ) ; return ERROR ; } uint32_t tag_section = entry . tag >> 16 ; int tag_type = get_camera_metadata_tag_type ( entry . tag ) ; if ( tag_type != ( int ) entry . type && tag_section < VENDOR_SECTION ) { ALOGE ( ""%s:Entryindex%zuhadtagtype%d,butthetypewas%d"" , __FUNCTION__ , i , tag_type , entry . type ) ; return ERROR ; } size_t data_size = calculate_camera_metadata_entry_data_size ( entry . type , entry . count ) ; if ( data_size != 0 ) { camera_metadata_data_t * data = ( camera_metadata_data_t * ) ( get_data ( metadata ) + entry . data . offset ) ; if ( ( uintptr_t ) data != ALIGN_TO ( data , DATA_ALIGNMENT ) ) { ALOGE ( ""%s:Entryindex%zuhadbaddataalignment(address%p),"" ""expectedalign%zu,(tagname%s,datasize%zu)"" , __FUNCTION__ , i , data , DATA_ALIGNMENT , get_camera_metadata_tag_name ( entry . tag ) ? : ""unknown"" , data_size ) ; return ERROR ; } size_t data_entry_end = entry . data . offset + data_size ; if ( data_entry_end < entry . data . offset || data_entry_end > metadata -> data_capacity ) { ALOGE ( ""%s:Entryindex%zudataends(%zu)beyondthecapacity"" ""%"" PRIu32 , __FUNCTION__ , i , data_entry_end , metadata -> data_capacity ) ; return ERROR ; } } else if ( entry . count == 0 ) { if ( entry . data . offset != 0 ) { ALOGE ( ""%s:Entryindex%zuhad0items,butoffsetwasnon-0"" ""(%"" PRIu32 ""),tagname:%s"" , __FUNCTION__ , i , entry . data . offset , get_camera_metadata_tag_name ( entry . tag ) ? : ""unknown"" ) ; return ERROR ; } } } return OK ; } "," } size_t data_size ; if ( validate_and_calculate_camera_metadata_entry_data_size ( & data_size , entry . type . count ) != OK ) { ALOGE ( ""%s:Entrydatasizeisinvalid.type:%ucount:%u"" , __FUNCTION__ , entry . type , entry . count ) ; return ERROR ; } if ( data_size ",system@media/8e7a2b4d13bff03973dbad2bfb88a04296140433,CVE-2016-3916,https://android.googlesource.com/platform/system/media/+/8e7a2b4d13bff03973dbad2bfb88a04296140433,2016-10-10T10:59Z 734,CWE-125,"CWE-125 static void ubik_print ( netdissect_options * ndo , register const u_char * bp ) { int ubik_op ; int32_t temp ; ubik_op = EXTRACT_32BITS ( bp + sizeof ( struct rx_header ) ) ; ND_PRINT ( ( ndo , ""ubikcall%s"" , tok2str ( ubik_req , ""op#%d"" , ubik_op ) ) ) ; bp += sizeof ( struct rx_header ) + 4 ; switch ( ubik_op ) { case 10000 : ND_TCHECK2 ( bp [ 0 ] , 4 ) ; temp = EXTRACT_32BITS ( bp ) ; bp += sizeof ( int32_t ) ; ND_PRINT ( ( ndo , ""syncsite%s"" , temp ? ""yes"" : ""no"" ) ) ; ND_PRINT ( ( ndo , ""votestart"" ) ) ; DATEOUT ( ) ; ND_PRINT ( ( ndo , ""dbversion"" ) ) ; UBIK_VERSIONOUT ( ) ; ND_PRINT ( ( ndo , ""tid"" ) ) ; UBIK_VERSIONOUT ( ) ; break ; case 10003 : ND_PRINT ( ( ndo , ""site"" ) ) ; UINTOUT ( ) ; break ; case 20000 : case 20001 : case 20007 : case 20008 : case 20010 : ND_PRINT ( ( ndo , ""tid"" ) ) ; UBIK_VERSIONOUT ( ) ; break ; case 20002 : ND_PRINT ( ( ndo , ""tid"" ) ) ; UBIK_VERSIONOUT ( ) ; ND_PRINT ( ( ndo , ""file"" ) ) ; INTOUT ( ) ; ND_PRINT ( ( ndo , ""pos"" ) ) ; INTOUT ( ) ; ND_PRINT ( ( ndo , ""length"" ) ) ; INTOUT ( ) ; temp = EXTRACT_32BITS ( bp ) ; bp += sizeof ( int32_t ) ; tok2str ( ubik_lock_types , ""type%d"" , temp ) ; break ; case 20003 : ND_PRINT ( ( ndo , ""tid"" ) ) ; UBIK_VERSIONOUT ( ) ; ND_PRINT ( ( ndo , ""file"" ) ) ; INTOUT ( ) ; ND_PRINT ( ( ndo , ""pos"" ) ) ; INTOUT ( ) ; break ; case 20005 : ND_PRINT ( ( ndo , ""file"" ) ) ; INTOUT ( ) ; break ; case 20006 : ND_PRINT ( ( ndo , ""file"" ) ) ; INTOUT ( ) ; ND_PRINT ( ( ndo , ""length"" ) ) ; INTOUT ( ) ; ND_PRINT ( ( ndo , ""dbversion"" ) ) ; UBIK_VERSIONOUT ( ) ; break ; case 20009 : ND_PRINT ( ( ndo , ""tid"" ) ) ; UBIK_VERSIONOUT ( ) ; ND_PRINT ( ( ndo , ""file"" ) ) ; INTOUT ( ) ; ND_PRINT ( ( ndo , ""length"" ) ) ; INTOUT ( ) ; break ; case 20012 : ND_PRINT ( ( ndo , ""tid"" ) ) ; UBIK_VERSIONOUT ( ) ; ND_PRINT ( ( ndo , ""oldversion"" ) ) ; UBIK_VERSIONOUT ( ) ; ND_PRINT ( ( ndo , ""newversion"" ) ) ; UBIK_VERSIONOUT ( ) ; break ; default : ; } return ; trunc : ND_PRINT ( ( ndo , ""[|ubik]"" ) ) ; } "," ( ) ; ND_TCHECK_32BITS ( bp ) ; ",the-tcpdump-group@tcpdump/aa0858100096a3490edf93034a80e66a4d61aad5,CVE-2017-13049,https://github.com/the-tcpdump-group/tcpdump/commit/aa0858100096a3490edf93034a80e66a4d61aad5,2017-09-14T06:29Z 735,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 736,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 737,CWE-190,"CWE-190 static char * mongo_data_append ( char * start , const void * data , int len ) { memcpy ( start , data , len ) ; return start + len ; } "," * data , size_t len ) { ",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 738,CWE-416,"CWE-416 static struct mm_struct * mm_init ( struct mm_struct * mm , struct task_struct * p , struct user_namespace * user_ns ) { mm -> mmap = NULL ; mm -> mm_rb = RB_ROOT ; mm -> vmacache_seqnum = 0 ; atomic_set ( & mm -> mm_users , 1 ) ; atomic_set ( & mm -> mm_count , 1 ) ; init_rwsem ( & mm -> mmap_sem ) ; INIT_LIST_HEAD ( & mm -> mmlist ) ; mm -> core_state = NULL ; atomic_long_set ( & mm -> nr_ptes , 0 ) ; mm_nr_pmds_init ( mm ) ; mm -> map_count = 0 ; mm -> locked_vm = 0 ; mm -> pinned_vm = 0 ; memset ( & mm -> rss_stat , 0 , sizeof ( mm -> rss_stat ) ) ; spin_lock_init ( & mm -> page_table_lock ) ; mm_init_cpumask ( mm ) ; mm_init_aio ( mm ) ; mm_init_owner ( mm , p ) ; mmu_notifier_mm_init ( mm ) ; init_tlb_flush_pending ( mm ) ; # if defined ( CONFIG_TRANSPARENT_HUGEPAGE ) && ! USE_SPLIT_PMD_PTLOCKS mm -> pmd_huge_pte = NULL ; # endif if ( current -> mm ) { mm -> flags = current -> mm -> flags & MMF_INIT_MASK ; mm -> def_flags = current -> mm -> def_flags & VM_INIT_DEF_MASK ; } else { mm -> flags = default_dump_filter ; mm -> def_flags = 0 ; } if ( mm_alloc_pgd ( mm ) ) goto fail_nopgd ; if ( init_new_context ( p , mm ) ) goto fail_nocontext ; mm -> user_ns = get_user_ns ( user_ns ) ; return mm ; fail_nocontext : mm_free_pgd ( mm ) ; fail_nopgd : free_mm ( mm ) ; return NULL ; } "," p ) ; RCU_INIT_POINTER ( mm -> exe_file , NULL ) ; ",torvalds@linux/2b7e8665b4ff51c034c55df3cff76518d1a9ee3a,CVE-2017-17052,https://github.com/torvalds/linux/commit/2b7e8665b4ff51c034c55df3cff76518d1a9ee3a,2017-11-29T03:29Z 739,CWE-787,"CWE-787 SEL * selReadStream ( FILE * fp ) { char * selname ; char linebuf [ L_BUF_SIZE ] ; l_int32 sy , sx , cy , cx , i , j , version , ignore ; SEL * sel ; PROCNAME ( ""selReadStream"" ) ; if ( ! fp ) return ( SEL * ) ERROR_PTR ( ""streamnotdefined"" , procName , NULL ) ; if ( fscanf ( fp , ""SelVersion%d\\n"" , & version ) != 1 ) return ( SEL * ) ERROR_PTR ( ""notaselfile"" , procName , NULL ) ; if ( version != SEL_VERSION_NUMBER ) return ( SEL * ) ERROR_PTR ( ""invalidselversion"" , procName , NULL ) ; if ( fgets ( linebuf , L_BUF_SIZE , fp ) == NULL ) return ( SEL * ) ERROR_PTR ( ""errorreadingintolinebuf"" , procName , NULL ) ; selname = stringNew ( linebuf ) ; sscanf ( linebuf , ""------%s------"" , selname ) ; if ( fscanf ( fp , ""sy=%d,sx=%d,cy=%d,cx=%d\\n"" , & sy , & sx , & cy , & cx ) != 4 ) { LEPT_FREE ( selname ) ; return ( SEL * ) ERROR_PTR ( ""dimensionsnotread"" , procName , NULL ) ; } if ( ( sel = selCreate ( sy , sx , selname ) ) == NULL ) { LEPT_FREE ( selname ) ; return ( SEL * ) ERROR_PTR ( ""selnotmade"" , procName , NULL ) ; } selSetOrigin ( sel , cy , cx ) ; for ( i = 0 ; i < sy ; i ++ ) { ignore = fscanf ( fp , """" ) ; for ( j = 0 ; j < sx ; j ++ ) ignore = fscanf ( fp , ""%1d"" , & sel -> data [ i ] [ j ] ) ; ignore = fscanf ( fp , ""\\n"" ) ; } ignore = fscanf ( fp , ""\\n"" ) ; LEPT_FREE ( selname ) ; return sel ; } "," char linebuf [ L_BUFSIZE ] ; l_int32 ( linebuf , L_BUFSIZE , fp ) ( linebuf , ""------%200s------"" , selname ) ",DanBloomberg@leptonica/ee301cb2029db8a6289c5295daa42bba7715e99a,CVE-2018-7186,https://github.com/DanBloomberg/leptonica/commit/ee301cb2029db8a6289c5295daa42bba7715e99a,2018-02-16T16:29Z 740,CWE-20,"CWE-20 void xenvif_disconnect ( struct xenvif * vif ) { struct net_device * dev = vif -> dev ; if ( netif_carrier_ok ( dev ) ) { rtnl_lock ( ) ; netif_carrier_off ( dev ) ; if ( netif_running ( dev ) ) xenvif_down ( vif ) ; rtnl_unlock ( ) ; xenvif_put ( vif ) ; } atomic_dec ( & vif -> refcnt ) ; wait_event ( vif -> waiting_to_free , atomic_read ( & vif -> refcnt ) == 0 ) ; del_timer_sync ( & vif -> credit_timeout ) ; if ( vif -> irq ) unbind_from_irqhandler ( vif -> irq , vif ) ; unregister_netdev ( vif -> dev ) ; xen_netbk_unmap_frontend_rings ( vif ) ; free_netdev ( vif -> dev ) ; } "," vif ) { if ( netif_carrier_ok ( netif_carrier_ok ( vif -> dev ) ) dev ) ) xenvif_carrier_off ( vif ) vif ) ; atomic_dec ( & ",torvalds@linux/48856286b64e4b66ec62b94e504d0b29c1ade664,CVE-2013-0216,https://github.com/torvalds/linux/commit/48856286b64e4b66ec62b94e504d0b29c1ade664,2013-02-18T04:41Z 741,CWE-326,"CWE-326 static u32 __ipv6_select_ident ( struct net * net , u32 hashrnd , const struct in6_addr * dst , const struct in6_addr * src ) { u32 hash , id ; hash = __ipv6_addr_jhash ( dst , hashrnd ) ; hash = __ipv6_addr_jhash ( src , hash ) ; hash ^= net_hash_mix ( net ) ; id = ip_idents_reserve ( hash , 1 ) ; if ( unlikely ( ! id ) ) id = 1 << 31 ; return id ; } "," net * net , const struct src ) { const struct { struct in6_addr dst ; struct in6_addr src ; } __aligned ( SIPHASH_ALIGNMENT ) combined = { . dst = * dst , . src = * src , } ; , id ; if ( unlikely ( siphash_key_is_zero ( & net -> ipv4 . ip_id_key ) ) ) get_random_bytes ( & net -> ipv4 . ip_id_key , sizeof ( net -> ipv4 . ip_id_key ) ) ; hash ; hash = siphash ( & combined , sizeof ( combined ) , & net -> ipv4 . ip_id_key ) ; id ",torvalds@linux/df453700e8d81b1bdafdf684365ee2b9431fb702,CVE-2019-10638,https://github.com/torvalds/linux/commit/df453700e8d81b1bdafdf684365ee2b9431fb702,2019-07-05T23:15Z 742,CWE-119,"CWE-119 vpx_codec_err_t vpx_svc_init ( SvcContext * svc_ctx , vpx_codec_ctx_t * codec_ctx , vpx_codec_iface_t * iface , vpx_codec_enc_cfg_t * enc_cfg ) { int max_intra_size_pct ; vpx_codec_err_t res ; SvcInternal * const si = get_svc_internal ( svc_ctx ) ; if ( svc_ctx == NULL || codec_ctx == NULL || iface == NULL || enc_cfg == NULL ) { return VPX_CODEC_INVALID_PARAM ; } if ( si == NULL ) return VPX_CODEC_MEM_ERROR ; si -> codec_ctx = codec_ctx ; si -> width = enc_cfg -> g_w ; si -> height = enc_cfg -> g_h ; if ( enc_cfg -> kf_max_dist < 2 ) { svc_log ( svc_ctx , SVC_LOG_ERROR , ""keyframedistancetoosmall:%d\\n"" , enc_cfg -> kf_max_dist ) ; return VPX_CODEC_INVALID_PARAM ; } si -> kf_dist = enc_cfg -> kf_max_dist ; if ( svc_ctx -> spatial_layers == 0 ) svc_ctx -> spatial_layers = VPX_SS_DEFAULT_LAYERS ; if ( svc_ctx -> spatial_layers < 1 || svc_ctx -> spatial_layers > VPX_SS_MAX_LAYERS ) { svc_log ( svc_ctx , SVC_LOG_ERROR , ""spatiallayers:invalidvalue:%d\\n"" , svc_ctx -> spatial_layers ) ; return VPX_CODEC_INVALID_PARAM ; } res = parse_quantizer_values ( svc_ctx , si -> quantizers , 0 ) ; if ( res != VPX_CODEC_OK ) return res ; res = parse_quantizer_values ( svc_ctx , si -> quantizers_keyframe , 1 ) ; if ( res != VPX_CODEC_OK ) memcpy ( si -> quantizer_keyframe , si -> quantizer , sizeof ( si -> quantizer ) ) ; res = parse_scale_factors ( svc_ctx , si -> scale_factors ) ; if ( res != VPX_CODEC_OK ) return res ; res = parse_options ( svc_ctx , si -> options ) ; if ( res != VPX_CODEC_OK ) return res ; si -> layers = svc_ctx -> spatial_layers ; if ( si -> layers > 1 ) { int i ; float total = 0 ; float alloc_ratio [ VPX_SS_MAX_LAYERS ] = { 0 } ; assert ( si -> layers <= VPX_SS_MAX_LAYERS ) ; for ( i = 0 ; i < si -> layers ; ++ i ) { int pos = i + VPX_SS_MAX_LAYERS - svc_ctx -> spatial_layers ; if ( pos < VPX_SS_MAX_LAYERS && si -> scaling_factor_den [ pos ] > 0 ) { alloc_ratio [ i ] = ( float ) ( si -> scaling_factor_num [ pos ] * 1.0 / si -> scaling_factor_den [ pos ] ) ; alloc_ratio [ i ] *= alloc_ratio [ i ] ; total += alloc_ratio [ i ] ; } } for ( i = 0 ; i < si -> layers ; ++ i ) { if ( total > 0 ) { enc_cfg -> ss_target_bitrate [ i ] = ( unsigned int ) ( enc_cfg -> rc_target_bitrate * alloc_ratio [ i ] / total ) ; } } } enc_cfg -> ss_number_layers = si -> layers ; enc_cfg -> ts_number_layers = 1 ; enc_cfg -> kf_mode = VPX_KF_DISABLED ; enc_cfg -> g_lag_in_frames = 0 ; enc_cfg -> rc_dropframe_thresh = 0 ; enc_cfg -> rc_end_usage = VPX_CBR ; enc_cfg -> rc_resize_allowed = 0 ; if ( enc_cfg -> g_pass == VPX_RC_ONE_PASS ) { enc_cfg -> rc_min_quantizer = 33 ; enc_cfg -> rc_max_quantizer = 33 ; } enc_cfg -> rc_undershoot_pct = 100 ; enc_cfg -> rc_overshoot_pct = 15 ; enc_cfg -> rc_buf_initial_sz = 500 ; enc_cfg -> rc_buf_optimal_sz = 600 ; enc_cfg -> rc_buf_sz = 1000 ; enc_cfg -> g_error_resilient = 1 ; res = vpx_codec_enc_init ( codec_ctx , iface , enc_cfg , VPX_CODEC_USE_PSNR ) ; if ( res != VPX_CODEC_OK ) { svc_log ( svc_ctx , SVC_LOG_ERROR , ""svc_enc_initerror\\n"" ) ; return res ; } vpx_codec_control ( codec_ctx , VP9E_SET_SVC , 1 ) ; vpx_codec_control ( codec_ctx , VP8E_SET_CPUUSED , 1 ) ; vpx_codec_control ( codec_ctx , VP8E_SET_STATIC_THRESHOLD , 1 ) ; vpx_codec_control ( codec_ctx , VP8E_SET_NOISE_SENSITIVITY , 1 ) ; vpx_codec_control ( codec_ctx , VP8E_SET_TOKEN_PARTITIONS , 1 ) ; max_intra_size_pct = ( int ) ( ( ( double ) enc_cfg -> rc_buf_optimal_sz * 0.5 ) * ( ( double ) enc_cfg -> g_timebase . den / enc_cfg -> g_timebase . num ) / 10.0 ) ; vpx_codec_control ( codec_ctx , VP8E_SET_MAX_INTRA_BITRATE_PCT , max_intra_size_pct ) ; return VPX_CODEC_OK ; } "," enc_cfg ) { vpx_codec_err_t res ; vpx_codec_err_t res ; int i ; SvcInternal_t * const si VPX_CODEC_INVALID_PARAM ; } if ( svc_ctx -> temporal_layering_mode == 3 ) { svc_ctx -> temporal_layers = 3 ; } else if ( svc_ctx -> temporal_layering_mode == 2 ) { svc_ctx -> temporal_layers = 2 ; } for ( i = 0 ; i < VPX_SS_MAX_LAYERS ; ++ i ) { si -> svc_params . max_quantizers [ i ] = MAX_QUANTIZER ; si -> svc_params . min_quantizers [ i ] = 0 ; si -> svc_params . scaling_factor_num [ i ] = DEFAULT_SCALE_FACTORS_NUM [ i ] ; si -> svc_params . scaling_factor_den [ i ] = DEFAULT_SCALE_FACTORS_DEN [ i ] ; } res = parse_options ( svc_ctx , si -> options ) ; if return res ; if ( svc_ctx -> spatial_layers < 1 ) svc_ctx -> spatial_layers = 1 ; if ( svc_ctx -> spatial_layers > VPX_SS_MAX_LAYERS ) svc_ctx -> spatial_layers = VPX_SS_MAX_LAYERS ; if ( svc_ctx -> temporal_layers < 1 ) svc_ctx -> temporal_layers = 1 ; if ( svc_ctx -> temporal_layers > VPX_TS_MAX_LAYERS ) svc_ctx -> temporal_layers = VPX_TS_MAX_LAYERS ; if ( svc_ctx -> temporal_layers * svc_ctx -> spatial_layers > VPX_MAX_LAYERS ) { svc_log ( svc_ctx , SVC_LOG_ERROR , ""spatiallayers*temporallayersexceedsthemaximumnumberof"" ""allowedlayersof%d\\n"" , svc_ctx -> spatial_layers * svc_ctx -> temporal_layers , ( int ) VPX_MAX_LAYERS ) ; return VPX_CODEC_INVALID_PARAM ; } assign_layer_bitrates ( svc_ctx , enc_cfg ) ; # if CONFIG_SPATIAL_SVC for ( i = 0 ; i < svc_ctx -> spatial_layers ; ++ i ) enc_cfg -> ss_enable_auto_alt_ref [ i ] = si -> enable_auto_alt_ref [ i ] ; # endif if ( svc_ctx -> temporal_layers > 1 ) { int i ; for ( i = 0 ; i < svc_ctx -> temporal_layers ; ++ i ) { enc_cfg -> ts_target_bitrate [ i ] = enc_cfg -> rc_target_bitrate / svc_ctx -> temporal_layers ; enc_cfg -> ts_rate_decimator [ i ] = 1 << ( svc_ctx -> temporal_layers - 1 - i ) ; } } if ( svc_ctx -> threads ) enc_cfg -> g_threads = svc_ctx -> threads ; enc_cfg -> ss_number_layers = svc_ctx -> spatial_layers ; enc_cfg -> ts_number_layers = svc_ctx -> temporal_layers ; if ( enc_cfg -> rc_end_usage == VPX_CBR ) { enc_cfg -> rc_resize_allowed = 0 ; enc_cfg -> rc_min_quantizer = 2 ; enc_cfg -> rc_max_quantizer = 63 ; enc_cfg -> rc_undershoot_pct = 50 ; enc_cfg -> rc_overshoot_pct = 50 ; enc_cfg -> rc_buf_initial_sz = 20 ; enc_cfg -> rc_buf_optimal_sz = 600 ; enc_cfg -> rc_buf_sz = 1000 ; } if ( enc_cfg -> g_error_resilient == 0 && si -> use_multiple_frame_contexts == 0 ) enc_cfg -> g_error_resilient = 1 ; res = vpx_codec_enc_init ( codec_ctx , iface , enc_cfg , VPX_CODEC_USE_PSNR ) ; if != VPX_CODEC_OK ) { svc_log ( svc_ctx , SVC_LOG_ERROR , ""svc_enc_initerror\\n"" ) ; return res ; return res ; } vpx_codec_control ( codec_ctx , ( codec_ctx , VP9E_SET_SVC , 1 ) ; vpx_codec_control ( codec_ctx ( codec_ctx , VP9E_SET_SVC_PARAMETERS , & si -> svc_params ) ; return ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 743,CWE-125,"CWE-125 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 , 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 ) ; } "," size_t ) ldblk + 1 ",ImageMagick@ImageMagick/bef1e4f637d8f665bc133a9c6d30df08d983bc3a,CVE-2016-7533,https://github.com/ImageMagick/ImageMagick/commit/bef1e4f637d8f665bc133a9c6d30df08d983bc3a,2017-04-19T14:59Z 744,CWE-264,"CWE-264 int _mkp_stage_30 ( struct plugin * p , struct client_session * cs , struct session_request * sr ) { mk_ptr_t referer ; ( void ) p ; ( void ) cs ; PLUGIN_TRACE ( ""[FD%i]MandrilvalidatingURL"" , cs -> socket ) ; if ( mk_security_check_url ( sr -> uri ) < 0 ) { PLUGIN_TRACE ( ""[FD%i]Closeconnection,blockedURL"" , cs -> socket ) ; mk_api -> header_set_http_status ( sr , MK_CLIENT_FORBIDDEN ) ; return MK_PLUGIN_RET_CLOSE_CONX ; } PLUGIN_TRACE ( ""[FD%d]Mandrilvalidatinghotlinking"" , cs -> socket ) ; referer = mk_api -> header_get ( & sr -> headers_toc , ""Referer"" , strlen ( ""Referer"" ) ) ; if ( mk_security_check_hotlink ( sr -> uri_processed , sr -> host , referer ) < 0 ) { PLUGIN_TRACE ( ""[FD%i]Closeconnection,denyhotlinking."" , cs -> socket ) ; mk_api -> header_set_http_status ( sr , MK_CLIENT_FORBIDDEN ) ; return MK_PLUGIN_RET_CLOSE_CONX ; } return MK_PLUGIN_RET_NOT_ME ; } "," ( sr -> uri_processed ) < 0 ",monkey@monkey/15f72c1ee5e0afad20232bdf0fcecab8d62a5d89,CVE-2013-2182,https://github.com/monkey/monkey/commit/15f72c1ee5e0afad20232bdf0fcecab8d62a5d89,2014-06-13T14:55Z 745,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 746,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 747,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 748,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 749,CWE-000,"CWE-000 void pin_remove ( struct fs_pin * pin ) { spin_lock ( & pin_lock ) ; hlist_del ( & pin -> m_list ) ; hlist_del ( & pin -> s_list ) ; spin_unlock ( & pin_lock ) ; spin_lock_irq ( & pin -> wait . lock ) ; pin -> done = 1 ; wake_up_locked ( & pin -> wait ) ; spin_unlock_irq ( & pin -> wait . lock ) ; } "," pin_lock ) ; hlist_del_init ( & pin m_list ) ; hlist_del_init ( & pin ",torvalds@linux/820f9f147dcce2602eefd9b575bbbd9ea14f0953,CVE-2015-4178,https://github.com/torvalds/linux/commit/820f9f147dcce2602eefd9b575bbbd9ea14f0953,2016-05-02T10:59Z 750,CWE-119,"CWE-119 static int temporal_filter_find_matching_mb_c ( VP9_COMP * cpi , uint8_t * arf_frame_buf , uint8_t * frame_ptr_buf , int stride ) { MACROBLOCK * x = & cpi -> mb ; MACROBLOCKD * const xd = & x -> e_mbd ; int step_param ; int sadpb = x -> sadperbit16 ; int bestsme = INT_MAX ; MV best_ref_mv1 = { 0 , 0 } ; MV best_ref_mv1_full ; MV * ref_mv = & x -> e_mbd . mi [ 0 ] -> bmi [ 0 ] . as_mv [ 0 ] . as_mv ; struct buf_2d src = x -> plane [ 0 ] . src ; struct buf_2d pre = xd -> plane [ 0 ] . pre [ 0 ] ; best_ref_mv1_full . col = best_ref_mv1 . col >> 3 ; best_ref_mv1_full . row = best_ref_mv1 . row >> 3 ; x -> plane [ 0 ] . src . buf = arf_frame_buf ; x -> plane [ 0 ] . src . stride = stride ; xd -> plane [ 0 ] . pre [ 0 ] . buf = frame_ptr_buf ; xd -> plane [ 0 ] . pre [ 0 ] . stride = stride ; if ( cpi -> speed < 8 ) step_param = cpi -> sf . reduce_first_step_size + ( ( cpi -> speed > 5 ) ? 1 : 0 ) ; else step_param = cpi -> sf . reduce_first_step_size + 2 ; step_param = MIN ( step_param , ( cpi -> sf . max_step_search_steps - 2 ) ) ; vp9_hex_search ( x , & best_ref_mv1_full , step_param , sadpb , 1 , & cpi -> fn_ptr [ BLOCK_16X16 ] , 0 , & best_ref_mv1 , ref_mv ) ; { int distortion ; unsigned int sse ; bestsme = cpi -> find_fractional_mv_step ( x , ref_mv , & best_ref_mv1 , cpi -> common . allow_high_precision_mv , x -> errorperbit , & cpi -> fn_ptr [ BLOCK_16X16 ] , 0 , cpi -> sf . subpel_iters_per_step , NULL , NULL , & distortion , & sse ) ; } x -> plane [ 0 ] . src = src ; xd -> plane [ 0 ] . pre [ 0 ] = pre ; return bestsme ; } "," { MACROBLOCK * const x = & cpi -> td . mb ; MACROBLOCKD -> e_mbd ; const MV_SPEED_FEATURES * const mv_sf = & cpi -> sf . mv ; bestsme = INT_MAX ; int distortion ; unsigned int sse ; int cost_list [ 5 ] = stride ; step_param = mv_sf -> reduce_first_step_size ; step_param = MIN ( step_param , MAX_MVSEARCH_STEPS - 2 ) - 2 ) ; vp9_hex_search ( , 1 , cond_cost_list ( cpi , cost_list ) , ref_mv ) ; bestsme = cpi -> find_fractional_mv_step ( x , ref_mv , & best_ref_mv1 , cpi -> common . allow_high_precision_mv , x -> errorperbit , & cpi -> fn_ptr [ BLOCK_16X16 ] , 0 , mv_sf -> subpel_iters_per_step , cond_cost_list ( cpi , cost_list ) , NULL , NULL , & distortion , & sse , NULL , 0 , 0 ) ; x -> plane ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 751,CWE-190,"CWE-190 static int uvesafb_setcmap ( struct fb_cmap * cmap , struct fb_info * info ) { struct uvesafb_pal_entry * entries ; int shift = 16 - dac_width ; int i , err = 0 ; if ( info -> var . bits_per_pixel == 8 ) { if ( cmap -> start + cmap -> len > info -> cmap . start + info -> cmap . len || cmap -> start < info -> cmap . start ) return - EINVAL ; entries = kmalloc ( sizeof ( * entries ) * cmap -> len , GFP_KERNEL ) ; if ( ! entries ) return - ENOMEM ; for ( i = 0 ; i < cmap -> len ; i ++ ) { entries [ i ] . red = cmap -> red [ i ] >> shift ; entries [ i ] . green = cmap -> green [ i ] >> shift ; entries [ i ] . blue = cmap -> blue [ i ] >> shift ; entries [ i ] . pad = 0 ; } err = uvesafb_setpalette ( entries , cmap -> len , cmap -> start , info ) ; kfree ( entries ) ; } else { for ( i = 0 ; i < cmap -> len ; i ++ ) { err |= uvesafb_setcolreg ( cmap -> start + i , cmap -> red [ i ] , cmap -> green [ i ] , cmap -> blue [ i ] , 0 , info ) ; } } return err ; } "," ; entries = kmalloc_array ( cmap -> len , sizeof ( * * entries ) , GFP_KERNEL ) ; ",torvalds@linux/9f645bcc566a1e9f921bdae7528a01ced5bc3713,CVE-2018-13406,https://github.com/torvalds/linux/commit/9f645bcc566a1e9f921bdae7528a01ced5bc3713,2018-07-06T14:29Z 752,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 753,CWE-119,"CWE-119 const char * vpx_svc_get_message ( const SvcContext * svc_ctx ) { const SvcInternal * const si = get_const_svc_internal ( svc_ctx ) ; if ( svc_ctx == NULL || si == NULL ) return NULL ; return si -> message_buffer ; } "," ) { const SvcInternal_t * const si ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 754,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 755,CWE-119,"CWE-119 int64_t vp9_pick_inter_mode ( VP9_COMP * cpi , MACROBLOCK * x , const TileInfo * const tile , int mi_row , int mi_col , int * returnrate , int64_t * returndistortion , BLOCK_SIZE bsize ) { MACROBLOCKD * xd = & x -> e_mbd ; MB_MODE_INFO * mbmi = & xd -> mi [ 0 ] -> mbmi ; struct macroblock_plane * const p = & x -> plane [ 0 ] ; struct macroblockd_plane * const pd = & xd -> plane [ 0 ] ; MB_PREDICTION_MODE this_mode , best_mode = ZEROMV ; MV_REFERENCE_FRAME ref_frame , best_ref_frame = LAST_FRAME ; INTERP_FILTER best_pred_filter = EIGHTTAP ; int_mv frame_mv [ MB_MODE_COUNT ] [ MAX_REF_FRAMES ] ; struct buf_2d yv12_mb [ 4 ] [ MAX_MB_PLANE ] ; static const int flag_list [ 4 ] = { 0 , VP9_LAST_FLAG , VP9_GOLD_FLAG , VP9_ALT_FLAG } ; int64_t best_rd = INT64_MAX ; int64_t this_rd = INT64_MAX ; int rate = INT_MAX ; int64_t dist = INT64_MAX ; VP9_COMMON * cm = & cpi -> common ; int intra_cost_penalty = 20 * vp9_dc_quant ( cm -> base_qindex , cm -> y_dc_delta_q ) ; const int64_t inter_mode_thresh = RDCOST ( x -> rdmult , x -> rddiv , intra_cost_penalty , 0 ) ; const int64_t intra_mode_cost = 50 ; unsigned char segment_id = mbmi -> segment_id ; const int * const rd_threshes = cpi -> rd_threshes [ segment_id ] [ bsize ] ; const int * const rd_thresh_freq_fact = cpi -> rd_thresh_freq_fact [ bsize ] ; int mode_idx [ MB_MODE_COUNT ] = { 0 } ; INTERP_FILTER filter_ref = SWITCHABLE ; x -> skip_encode = cpi -> sf . skip_encode_frame && x -> q_index < QIDX_SKIP_THRESH ; x -> skip = 0 ; if ( ! x -> in_active_map ) x -> skip = 1 ; * returnrate = INT_MAX ; * returndistortion = INT64_MAX ; vpx_memset ( mbmi , 0 , sizeof ( MB_MODE_INFO ) ) ; mbmi -> sb_type = bsize ; mbmi -> ref_frame [ 0 ] = NONE ; mbmi -> ref_frame [ 1 ] = NONE ; mbmi -> tx_size = MIN ( max_txsize_lookup [ bsize ] , tx_mode_to_biggest_tx_size [ cpi -> common . tx_mode ] ) ; mbmi -> interp_filter = cpi -> common . interp_filter == SWITCHABLE ? EIGHTTAP : cpi -> common . interp_filter ; mbmi -> skip = 0 ; mbmi -> segment_id = segment_id ; for ( ref_frame = LAST_FRAME ; ref_frame <= LAST_FRAME ; ++ ref_frame ) { x -> pred_mv_sad [ ref_frame ] = INT_MAX ; if ( cpi -> ref_frame_flags & flag_list [ ref_frame ] ) { vp9_setup_buffer_inter ( cpi , x , tile , ref_frame , bsize , mi_row , mi_col , frame_mv [ NEARESTMV ] , frame_mv [ NEARMV ] , yv12_mb ) ; } frame_mv [ NEWMV ] [ ref_frame ] . as_int = INVALID_MV ; frame_mv [ ZEROMV ] [ ref_frame ] . as_int = 0 ; } if ( xd -> up_available ) filter_ref = xd -> mi [ - xd -> mi_stride ] -> mbmi . interp_filter ; else if ( xd -> left_available ) filter_ref = xd -> mi [ - 1 ] -> mbmi . interp_filter ; for ( ref_frame = LAST_FRAME ; ref_frame <= LAST_FRAME ; ++ ref_frame ) { if ( ! ( cpi -> ref_frame_flags & flag_list [ ref_frame ] ) ) continue ; xd -> plane [ 0 ] . pre [ 0 ] = yv12_mb [ ref_frame ] [ 0 ] ; clamp_mv2 ( & frame_mv [ NEARESTMV ] [ ref_frame ] . as_mv , xd ) ; clamp_mv2 ( & frame_mv [ NEARMV ] [ ref_frame ] . as_mv , xd ) ; mbmi -> ref_frame [ 0 ] = ref_frame ; if ( ref_frame == LAST_FRAME ) { mode_idx [ NEARESTMV ] = THR_NEARESTMV ; mode_idx [ NEARMV ] = THR_NEARMV ; mode_idx [ ZEROMV ] = THR_ZEROMV ; mode_idx [ NEWMV ] = THR_NEWMV ; } for ( this_mode = NEARESTMV ; this_mode <= NEWMV ; ++ this_mode ) { int rate_mv = 0 ; if ( cpi -> sf . disable_inter_mode_mask [ bsize ] & ( 1 << INTER_OFFSET ( this_mode ) ) ) continue ; if ( best_rd < ( ( int64_t ) rd_threshes [ mode_idx [ this_mode ] ] * rd_thresh_freq_fact [ this_mode ] >> 5 ) || rd_threshes [ mode_idx [ this_mode ] ] == INT_MAX ) continue ; if ( this_mode == NEWMV ) { int rate_mode = 0 ; if ( this_rd < ( int64_t ) ( 1 << num_pels_log2_lookup [ bsize ] ) ) continue ; full_pixel_motion_search ( cpi , x , tile , bsize , mi_row , mi_col , & frame_mv [ NEWMV ] [ ref_frame ] , & rate_mv ) ; if ( frame_mv [ NEWMV ] [ ref_frame ] . as_int == INVALID_MV ) continue ; rate_mode = x -> inter_mode_cost [ mbmi -> mode_context [ ref_frame ] ] [ INTER_OFFSET ( this_mode ) ] ; if ( RDCOST ( x -> rdmult , x -> rddiv , rate_mv + rate_mode , 0 ) > best_rd ) continue ; sub_pixel_motion_search ( cpi , x , tile , bsize , mi_row , mi_col , & frame_mv [ NEWMV ] [ ref_frame ] . as_mv ) ; } if ( this_mode != NEARESTMV ) if ( frame_mv [ this_mode ] [ ref_frame ] . as_int == frame_mv [ NEARESTMV ] [ ref_frame ] . as_int ) continue ; mbmi -> mode = this_mode ; mbmi -> mv [ 0 ] . as_int = frame_mv [ this_mode ] [ ref_frame ] . as_int ; if ( ( this_mode == NEWMV || filter_ref == SWITCHABLE ) && ( ( mbmi -> mv [ 0 ] . as_mv . row & 0x07 ) != 0 || ( mbmi -> mv [ 0 ] . as_mv . col & 0x07 ) != 0 ) ) { int64_t tmp_rdcost1 = INT64_MAX ; int64_t tmp_rdcost2 = INT64_MAX ; int64_t tmp_rdcost3 = INT64_MAX ; int pf_rate [ 3 ] ; int64_t pf_dist [ 3 ] ; mbmi -> interp_filter = EIGHTTAP ; vp9_build_inter_predictors_sby ( xd , mi_row , mi_col , bsize ) ; model_rd_for_sb_y ( cpi , bsize , x , xd , & pf_rate [ EIGHTTAP ] , & pf_dist [ EIGHTTAP ] ) ; tmp_rdcost1 = RDCOST ( x -> rdmult , x -> rddiv , vp9_get_switchable_rate ( x ) + pf_rate [ EIGHTTAP ] , pf_dist [ EIGHTTAP ] ) ; mbmi -> interp_filter = EIGHTTAP_SHARP ; vp9_build_inter_predictors_sby ( xd , mi_row , mi_col , bsize ) ; model_rd_for_sb_y ( cpi , bsize , x , xd , & pf_rate [ EIGHTTAP_SHARP ] , & pf_dist [ EIGHTTAP_SHARP ] ) ; tmp_rdcost2 = RDCOST ( x -> rdmult , x -> rddiv , vp9_get_switchable_rate ( x ) + pf_rate [ EIGHTTAP_SHARP ] , pf_dist [ EIGHTTAP_SHARP ] ) ; mbmi -> interp_filter = EIGHTTAP_SMOOTH ; vp9_build_inter_predictors_sby ( xd , mi_row , mi_col , bsize ) ; model_rd_for_sb_y ( cpi , bsize , x , xd , & pf_rate [ EIGHTTAP_SMOOTH ] , & pf_dist [ EIGHTTAP_SMOOTH ] ) ; tmp_rdcost3 = RDCOST ( x -> rdmult , x -> rddiv , vp9_get_switchable_rate ( x ) + pf_rate [ EIGHTTAP_SMOOTH ] , pf_dist [ EIGHTTAP_SMOOTH ] ) ; if ( tmp_rdcost2 < tmp_rdcost1 ) { if ( tmp_rdcost2 < tmp_rdcost3 ) mbmi -> interp_filter = EIGHTTAP_SHARP ; else mbmi -> interp_filter = EIGHTTAP_SMOOTH ; } else { if ( tmp_rdcost1 < tmp_rdcost3 ) mbmi -> interp_filter = EIGHTTAP ; else mbmi -> interp_filter = EIGHTTAP_SMOOTH ; } rate = pf_rate [ mbmi -> interp_filter ] ; dist = pf_dist [ mbmi -> interp_filter ] ; } else { mbmi -> interp_filter = ( filter_ref == SWITCHABLE ) ? EIGHTTAP : filter_ref ; vp9_build_inter_predictors_sby ( xd , mi_row , mi_col , bsize ) ; model_rd_for_sb_y ( cpi , bsize , x , xd , & rate , & dist ) ; } rate += rate_mv ; rate += x -> inter_mode_cost [ mbmi -> mode_context [ ref_frame ] ] [ INTER_OFFSET ( this_mode ) ] ; this_rd = RDCOST ( x -> rdmult , x -> rddiv , rate , dist ) ; if ( this_rd < best_rd ) { best_rd = this_rd ; * returnrate = rate ; * returndistortion = dist ; best_mode = this_mode ; best_pred_filter = mbmi -> interp_filter ; best_ref_frame = ref_frame ; } } } mbmi -> mode = best_mode ; mbmi -> interp_filter = best_pred_filter ; mbmi -> ref_frame [ 0 ] = best_ref_frame ; mbmi -> mv [ 0 ] . as_int = frame_mv [ best_mode ] [ best_ref_frame ] . as_int ; xd -> mi [ 0 ] -> bmi [ 0 ] . as_mv [ 0 ] . as_int = mbmi -> mv [ 0 ] . as_int ; if ( best_rd > inter_mode_thresh ) { for ( this_mode = DC_PRED ; this_mode <= DC_PRED ; ++ this_mode ) { vp9_predict_intra_block ( xd , 0 , b_width_log2 ( bsize ) , mbmi -> tx_size , this_mode , & p -> src . buf [ 0 ] , p -> src . stride , & pd -> dst . buf [ 0 ] , pd -> dst . stride , 0 , 0 , 0 ) ; model_rd_for_sb_y ( cpi , bsize , x , xd , & rate , & dist ) ; rate += x -> mbmode_cost [ this_mode ] ; rate += intra_cost_penalty ; this_rd = RDCOST ( x -> rdmult , x -> rddiv , rate , dist ) ; if ( this_rd + intra_mode_cost < best_rd ) { best_rd = this_rd ; * returnrate = rate ; * returndistortion = dist ; mbmi -> mode = this_mode ; mbmi -> ref_frame [ 0 ] = INTRA_FRAME ; mbmi -> uv_mode = this_mode ; mbmi -> mv [ 0 ] . as_int = INVALID_MV ; } } } return INT64_MAX ; } "," void vp9_pick_inter_mode ( VP9_COMP * x , TileDataEnc * tile_data , int mi_row , int mi_col , RD_COST * rd_cost , BLOCK_SIZE bsize , PICK_MODE_CONTEXT * ctx ) { VP9_COMMON * const cm = & cpi -> common ; SPEED_FEATURES * const sf = & cpi -> sf ; TileInfo * const TileInfo * const tile_info = & tile_data -> tile_info ; MACROBLOCKD * const xd = & ; MB_MODE_INFO * const ] -> mbmi ; struct macroblockd_plane 0 ] ; PREDICTION_MODE best_mode = ZEROMV best_ref_frame = LAST_FRAME ; MV_REFERENCE_FRAME usable_ref_frame ; TX_SIZE best_tx_size = TX_SIZES VP9_ALT_FLAG } ; RD_COST this_rdc , best_rdc ; uint8_t skip_txfm = SKIP_TXFM_NONE , best_mode_skip_txfm = SKIP_TXFM_NONE ; unsigned int var_y = UINT_MAX ; unsigned int sse_y = UINT_MAX ; const int reduction_fac = ( bsize <= BLOCK_16X16 ) ? ( ( bsize <= BLOCK_8X8 ) ? 4 : 2 ) : 0 ; const int intra_cost_penalty = int intra_cost_penalty = vp9_get_intra_cost_penalty ( cm -> base_qindex cm -> y_dc_delta_q , cm -> bit_depth ) >> reduction_fac ; const int64_t , 0 ) ; const int = cpi -> rd . threshes [ mbmi -> segment_id ] [ const rd_thresh_freq_fact = tile_data -> thresh_freq_fact [ bsize ] [ bsize ] ; INTERP_FILTER filter_ref ; INTERP_FILTER filter_ref ; const int bsl = mi_width_log2_lookup [ bsize ] ; const int pred_filter_search = cm -> interp_filter == SWITCHABLE == SWITCHABLE ? ( ( ( mi_row + mi_col ) >> bsl ) + get_chessboard_index ( cm -> current_video_frame ) ) & 0x1 : 0 ; int const_motion [ MAX_REF_FRAMES ] = { 0 } ; const int bh = num_4x4_blocks_high_lookup [ bsize ] << 2 ; const int bw = num_4x4_blocks_wide_lookup [ bsize ] << 2 ; PRED_BUFFER tmp [ 4 ] ; DECLARE_ALIGNED ( 16 , uint8_t , pred_buf [ 3 * 64 * 64 ] ) ; # if CONFIG_VP9_HIGHBITDEPTH DECLARE_ALIGNED ( 16 , uint16_t , pred_buf_16 [ 3 * 64 * 64 ] ) ; # endif struct buf_2d orig_dst = pd -> dst ; PRED_BUFFER * best_pred = NULL ; PRED_BUFFER * this_mode_pred = NULL ; const int pixels_in_block = bh * bw ; int reuse_inter_pred = cpi -> sf . reuse_inter_pred_sby && ctx -> pred_pixel_ready ; int ref_frame_skip_mask = 0 ; int idx ; int best_pred_sad = INT_MAX ; int best_early_term = 0 ; int ref_frame_cost [ MAX_REF_FRAMES ] ; init_ref_frame_cost ( cm , xd , ref_frame_cost ) ; if ( reuse_inter_pred ) { int i ; for ( i = 0 ; i < 3 ; i ++ ) { # if CONFIG_VP9_HIGHBITDEPTH if ( cm -> use_highbitdepth ) tmp [ i ] . data = CONVERT_TO_BYTEPTR ( & pred_buf_16 [ pixels_in_block * i ] ) ; else tmp [ i ] . data = & pred_buf [ pixels_in_block * i ] ; # else tmp [ i ] . data = & pred_buf [ pixels_in_block * i ] ; # endif tmp [ i ] . stride = bw ; tmp [ i ] . in_use = 0 ; } tmp [ 3 ] . data = pd -> dst . buf ; tmp [ 3 ] . stride = pd -> dst . stride ; tmp [ 3 ] . in_use = 0 ; } x -> skip_encode = cpi -> sf . skip_encode_frame && x -> q_index < QIDX_SKIP_THRESH ; x -> skip = = 0 ; if ( xd . interp_filter ; else filter_ref = cm -> interp_filter ; vp9_rd_cost_reset ( & best_rdc ) ; vp9_rd_cost_reset ( rd_cost ) ; mbmi -> sb_type = bsize ; mbmi -> ref_frame [ 0 ] = NONE ; mbmi -> ref_frame [ 1 ] = NONE ; mbmi -> tx_size = MIN ( max_txsize_lookup [ bsize ] , tx_mode_to_biggest_tx_size [ cm -> tx_mode ] ) ; # if CONFIG_VP9_TEMPORAL_DENOISING vp9_denoiser_reset_frame_stats ( ctx ) ; # endif if ( cpi -> rc . frames_since_golden == 0 && ! cpi -> use_svc ) { usable_ref_frame = LAST_FRAME ; } else { usable_ref_frame = GOLDEN_FRAME ; } ; ref_frame <= usable_ref_frame ; ++ ref_frame ref_frame ) { const YV12_BUFFER_CONFIG * yv12 = get_ref_frame_buffer ( cpi , ref_frame ) ; x -> pred_mv_sad [ ref_frame ] = INT_MAX ; frame_mv [ NEWMV ] [ ref_frame ] . as_int = INVALID_MV ; frame_mv [ ZEROMV ] [ ref_frame ] . as_int = 0 ; if ( ( cpi -> ref_frame_flags & flag_list [ ref_frame ] ) && ( yv12 != NULL ) ) { int_mv * const candidates = x -> mbmi_ext -> ref_mvs [ ref_frame ] ; const struct scale_factors * const sf = & cm -> frame_refs [ ref_frame - 1 ] . sf ; vp9_setup_pred_block ( xd , yv12_mb [ ref_frame ] , yv12 , mi_row , mi_col , sf , sf ) ; if ( cm -> use_prev_frame_mvs ) vp9_find_mv_refs ( cm , xd , xd -> mi [ 0 ] , ref_frame , candidates , mi_row , mi_col , NULL , NULL , x -> mbmi_ext -> mode_context ) ; else const_motion [ ref_frame ] = mv_refs_rt ( cm , x , xd , tile_info , xd -> mi [ 0 ] , ref_frame , candidates , mi_row , mi_col ) ; vp9_find_best_ref_mvs ( xd , cm -> allow_high_precision_mv , candidates , & frame_mv [ NEARESTMV ] [ ref_frame ] , & frame_mv [ NEARMV ] [ ref_frame ] ) ; if ( ! vp9_is_scaled ( sf ) && bsize >= BLOCK_8X8 ) vp9_mv_pred ( cpi , x , yv12_mb [ ref_frame ] [ 0 ] . buf , yv12 -> y_stride , ref_frame , bsize ) ; } else { ref_frame_skip_mask |= ( 1 << ref_frame ) ; } } for ( idx = 0 ; idx < RT_INTER_MODES ; ++ idx ) { int rate_mv = 0 ; int mode_rd_thresh ; int mode_index ; int i ; int64_t this_sse ; int is_skippable ; int this_early_term = 0 ; PREDICTION_MODE this_mode = ref_mode_set [ idx ] . pred_mode ; if ( cpi -> use_svc ) this_mode = ref_mode_set_svc [ idx ] . pred_mode ; if ( ! ( cpi -> sf . inter_mode_mask [ bsize ] & ( 1 << this_mode ) ) ) continue ; ref_frame = ref_mode_set [ idx ] . ref_frame ; if ( cpi -> use_svc ) ref_frame = ref_mode_set_svc [ idx ] . ref_frame ; if ( ! ) continue ; if ( const_motion [ ref_frame ] && this_mode == NEARMV ) continue ; i = ( ref_frame == == LAST_FRAME ) ? GOLDEN_FRAME : LAST_FRAME ; if ( ( cpi -> ref_frame_flags & flag_list [ i ] ) && sf -> reference_masking ) if ( x -> pred_mv_sad [ ref_frame ] > ( x -> pred_mv_sad [ i ] << 1 ) ) ref_frame_skip_mask |= ( 1 << ( 1 << ref_frame ) ; if ( ref_frame_skip_mask & ( 1 << ref_frame ) ) continue ; for ( i = 0 ; i < MAX_MB_PLANE ; i ++ ) xd -> plane [ i ] . pre [ 0 ] = yv12_mb [ ref_frame ] [ i ] ; mbmi -> ref_frame [ 0 ] = ref_frame ; set_ref_ptrs ( cm , xd , ref_frame , NONE ) ; mode_index = mode_idx [ ref_frame ] [ ( this_mode ) ] ; mode_rd_thresh = best_mode_skip_txfm ? rd_threshes [ mode_index ] << 1 : rd_threshes [ mode_index ] ; if ( rd_less_than_thresh ( best_rdc . rdcost , mode_rd_thresh , rd_thresh_freq_fact [ mode_index ] ) ) continue ; NEWMV ) { if ( ref_frame > LAST_FRAME && ! cpi -> use_svc ) { int tmp_sad ; int dis , cost_list [ 5 ] ; if ( bsize < BLOCK_16X16 ) continue ; tmp_sad = vp9_int_pro_motion_estimation ( cpi , x , bsize , mi_row , mi_col ) ; if ( tmp_sad > x -> pred_mv_sad [ LAST_FRAME ] ) continue ; if ( tmp_sad + ( num_pels_log2_lookup [ bsize ] << 4 ) > best_pred_sad ) continue ; frame_mv [ NEWMV ] [ ref_frame ] . as_int = mbmi -> mv [ 0 ] . as_int ; rate_mv = vp9_mv_bit_cost ( & frame_mv [ NEWMV ] [ ref_frame ] . as_mv , & x -> mbmi_ext -> ref_mvs [ ref_frame ] [ 0 ] . as_mv , x -> nmvjointcost , x -> mvcost , MV_COST_WEIGHT ) ; frame_mv [ NEWMV ] [ ref_frame ] . as_mv . row >>= 3 ; frame_mv [ NEWMV ] [ ref_frame ] . as_mv . col >>= 3 ; cpi -> find_fractional_mv_step ( x , & frame_mv [ NEWMV ] [ ref_frame ] . as_mv , & x -> mbmi_ext -> ref_mvs [ ref_frame ] [ 0 ] . as_mv , cpi -> common . allow_high_precision_mv , x -> errorperbit , & cpi -> fn_ptr [ bsize ] [ bsize ] , cpi -> sf . mv . subpel_force_stop , cpi -> sf . mv . subpel_iters_per_step , cond_cost_list ( cpi , cost_list ) , x -> nmvjointcost , x -> mvcost , & dis , & x -> pred_sse [ ref_frame ] , NULL , 0 , 0 ) ; } else if ( ! combined_motion_search ( cpi , x , bsize , mi_row , mi_col , & frame_mv [ NEWMV ] [ ref_frame ] , & rate_mv , best_rdc . rdcost ) ) { continue ; } } if ( this_mode == NEWMV && ref_frame == LAST_FRAME && frame_mv [ NEWMV ] [ LAST_FRAME ] . as_int != INVALID_MV ) { const int pre_stride = xd -> plane [ 0 ] . pre [ 0 ] . stride ; const uint8_t * const pre_buf = xd -> plane [ 0 ] . pre [ 0 ] . buf + ( frame_mv [ NEWMV ] [ LAST_FRAME ] . as_mv . row >> 3 ) * pre_stride + ( frame_mv [ NEWMV ] [ LAST_FRAME ] . as_mv . col >> 3 ) ; best_pred_sad = cpi -> fn_ptr [ bsize ] . sdf ( x -> plane [ 0 ] . src . buf , x -> plane [ 0 ] . src . stride , pre_buf , pre_stride ) ; x -> pred_mv_sad [ LAST_FRAME ] = best_pred_sad ; } if ( cpi -> use_svc ) { if ( this_mode == NEWMV && ref_frame == GOLDEN_FRAME && frame_mv [ NEWMV NEWMV ] [ GOLDEN_FRAME ] . as_int != INVALID_MV ) { const int pre_stride = xd -> plane [ 0 ] . pre [ 0 ] . stride ; const uint8_t * const pre_buf = xd -> plane [ 0 ] . pre [ 0 ] . buf + ( frame_mv [ NEWMV ] [ GOLDEN_FRAME ] . as_mv . row >> 3 ) * pre_stride + ( frame_mv [ NEWMV ] [ GOLDEN_FRAME ] . as_mv . col >> 3 ) ; best_pred_sad = cpi -> fn_ptr [ bsize ] . sdf ( x -> plane [ 0 ] . src . buf , x -> plane [ 0 ] . src . stride , pre_buf , pre_stride ) ; x -> pred_mv_sad [ GOLDEN_FRAME ] = best_pred_sad ; } } if ( this_mode != NEARESTMV && frame_mv [ this_mode . as_int ; if ( reuse_inter_pred ) { if ( ! this_mode_pred ) { this_mode_pred = & tmp [ 3 ] ; } else { this_mode_pred = & tmp [ get_pred_buffer ( tmp , 3 ) ] ; pd -> dst . buf = this_mode_pred -> data ; pd -> dst . stride = bw ; } } SWITCHABLE ) && pred_filter_search && ( ref_frame == LAST_FRAME || ( ref_frame == GOLDEN_FRAME && cpi -> use_svc ) ) && ( as_mv . row | mbmi -> mv [ 0 ] . as_mv . col ) ) != 0 ) ) { int pf_rate [ 3 ] ; unsigned int pf_var [ 3 ] ; unsigned int pf_sse [ 3 ] ; TX_SIZE pf_tx_size [ 3 ] ; int64_t best_cost = INT64_MAX ; INTERP_FILTER best_filter = SWITCHABLE , filter ; PRED_BUFFER * current_pred = this_mode_pred ; for ( filter = EIGHTTAP ; filter <= EIGHTTAP_SMOOTH ; ++ filter ) { int64_t cost ; -> interp_filter = filter ; vp9_build_inter_predictors_sby ( & pf_rate [ filter ] , & pf_dist [ & pf_dist [ filter ] , & pf_var [ filter ] , & pf_sse [ filter ] ) ; pf_rate [ filter ] += vp9_get_switchable_rate ( cpi , xd ) ; cost = RDCOST ( -> rddiv , pf_rate [ filter ] , pf_dist [ filter ] ) ; pf_tx_size [ filter ] = mbmi -> tx_size ; if ( cost < best_cost ) { best_filter = filter ; best_cost = cost ; skip_txfm = x -> skip_txfm [ 0 ] ; if ( reuse_inter_pred ) { if ( this_mode_pred != current_pred ) { free_pred_buffer ( this_mode_pred ) ; this_mode_pred = current_pred ; } if ( filter < EIGHTTAP_SHARP ) { current_pred = & tmp [ get_pred_buffer ( tmp , 3 ) ] ; pd -> dst . buf = current_pred -> data ; pd -> dst . stride = bw ; } } } } if ( reuse_inter_pred && this_mode_pred != current_pred ) free_pred_buffer ( current_pred ) ; mbmi -> interp_filter = best_filter ; mbmi -> tx_size = pf_tx_size [ best_filter ] ; this_rdc . rate = pf_rate [ best_filter ] ; this_rdc . dist = pf_dist [ best_filter ] ; var_y = pf_var [ best_filter ] ; sse_y = pf_sse [ best_filter ] ; x -> skip_txfm [ 0 ] = skip_txfm ; if ( reuse_inter_pred ) { pd -> dst . buf = this_mode_pred -> data ; pd -> dst . stride = this_mode_pred -> stride ; } } else { bsize ) ; if ( bsize > BLOCK_32X32 && ! cyclic_refresh_segment_id_boosted ( xd -> mi [ 0 ] -> mbmi . segment_id ) && cm -> base_qindex ) { model_rd_for_sb_y_large ( cpi , bsize , x , xd , & this_rdc . rate , & this_rdc . dist , & var_y , & sse_y , mi_row , mi_col , & this_early_term ) ; } else { xd , & this_rdc . rate , & this_rdc . dist , & var_y , & sse_y ) ; } } if ( ! this_early_term ) { this_sse = ( int64_t ) sse_y ; block_yrd ( cpi , x , & this_rdc . rate , & this_rdc . dist , & is_skippable , & this_sse , 0 , bsize , MIN ( mbmi -> tx_size , TX_16X16 ) ) ; x -> skip_txfm [ 0 ] = is_skippable ; if ( is_skippable ) { this_rdc . rate = vp9_cost_bit ( vp9_get_skip_prob ( cm , xd ) , 1 ) ; } else { if ( RDCOST ( x -> rdmult , x -> rddiv , this_rdc . rate , this_rdc . dist ) < RDCOST ( x -> rdmult , x -> rddiv , 0 , this_sse ) ) { this_rdc . rate += vp9_cost_bit ( vp9_get_skip_prob ( cm , xd ) , 0 ) ; } else { this_rdc . rate = vp9_cost_bit ( vp9_get_skip_prob ( cm , xd ) , 1 ) ; this_rdc . dist = this_sse ; x -> skip_txfm [ 0 ] = SKIP_TXFM_AC_DC ; } } if ( cm -> interp_filter == SWITCHABLE ) { if ( ( mbmi -> mv [ 0 ] . as_mv . row | mbmi -> mv [ 0 ] . as_mv . col ) & 0x07 ) this_rdc . rate += vp9_get_switchable_rate ( cpi , xd ) ; } } else { this_rdc . rate += cm -> interp_filter == SWITCHABLE ? vp9_get_switchable_rate ( cpi , xd ) : 0 ; this_rdc . rate += vp9_cost_bit ( vp9_get_skip_prob ( cm , xd ) , 1 ) ; } if ( x -> color_sensitivity [ 0 ] || x -> color_sensitivity [ 1 ] ) { int uv_rate = 0 ; int64_t uv_dist = 0 ; if ( x -> color_sensitivity [ 0 ] ) vp9_build_inter_predictors_sbp ( xd , mi_row , mi_col , bsize , 1 ) ; if ( x -> color_sensitivity [ 1 ] ) vp9_build_inter_predictors_sbp ( xd , mi_row , mi_col , bsize , 2 ) ; model_rd_for_sb_uv ( cpi , bsize , x , xd , & uv_rate , & uv_dist , & var_y , & sse_y ) ; this_rdc . rate += uv_rate ; this_rdc . dist += uv_dist ; } this_rdc . rate += rate_mv += rate_mv ; this_rdc . rate += cpi -> inter_mode_cost [ -> inter_mode_cost [ x -> mbmi_ext -> mode_context [ ref_frame ] ] [ INTER_OFFSET ( this_mode ) ] ; this_rdc . rate += ref_frame_cost [ ref_frame ] ; this_rdc . rdcost = RDCOST ( x -> rdmult , x -> rddiv , this_rdc . rate , this_rdc . dist ) ; if ( cpi -> allow_encode_breakout ) { encode_breakout_test ( cpi , x , bsize , mi_row , mi_col , ref_frame , this_mode , var_y , sse_y , yv12_mb , & this_rdc . rate , & this_rdc . dist ) ; if ( x -> skip ) { this_rdc . rate += rate_mv ; this_rdc . rdcost = RDCOST ( x -> rdmult , x -> rddiv , this_rdc . rate , this_rdc . dist ) ; } } # if CONFIG_VP9_TEMPORAL_DENOISING if ( cpi -> oxcf . noise_sensitivity > 0 ) vp9_denoiser_update_frame_stats ( mbmi , sse_y , this_mode , ctx ) ; # else ( void ) ctx ; # endif if ( this_rdc . rdcost < best_rdc . rdcost || x -> skip ) { best_rdc = this_rdc ; best_mode = -> interp_filter ; best_tx_size = mbmi -> tx_size ; = ref_frame ; best_mode_skip_txfm = x -> skip_txfm [ 0 ] ; best_early_term = this_early_term ; if ( reuse_inter_pred ) { free_pred_buffer ( best_pred ) ; best_pred = this_mode_pred ; } } else { if ( reuse_inter_pred ) free_pred_buffer ( this_mode_pred ) ; } if ( x -> skip ) break ; if ( best_early_term && idx > 0 ) { x -> skip = 1 ; break ; } } mbmi ; mbmi -> tx_size = best_tx_size ; mbmi -> . as_int ; x -> skip_txfm [ 0 ] = best_mode_skip_txfm ; if ( best_rdc . rdcost == INT64_MAX || ( ! x -> skip && best_rdc . rdcost > inter_mode_thresh && bsize <= cpi -> sf . max_intra_bsize ) ) { struct estimate_block_intra_args args = { cpi , x , DC_PRED , 0 , 0 } ; const TX_SIZE intra_tx_size = MIN ( max_txsize_lookup [ bsize ] , tx_mode_to_biggest_tx_size [ cpi -> common . tx_mode ] ) ; int i ; TX_SIZE best_intra_tx_size = TX_SIZES ; if ( reuse_inter_pred && best_pred != NULL ) { if ( best_pred -> data == orig_dst . buf ) { this_mode_pred = & tmp [ get_pred_buffer ( tmp , 3 ) ] ; # if CONFIG_VP9_HIGHBITDEPTH if ( cm -> use_highbitdepth ) vpx_highbd_convolve_copy ( best_pred -> data , best_pred -> stride , this_mode_pred -> data , this_mode_pred -> stride , NULL , 0 , NULL , 0 , bw , bh , xd -> bd ) ; else vpx_convolve_copy ( best_pred -> data , best_pred -> stride , this_mode_pred -> data , this_mode_pred -> stride , NULL , 0 , NULL , 0 , bw , bh ) ; # else vpx_convolve_copy ( best_pred -> data , best_pred -> stride , this_mode_pred -> data , this_mode_pred -> stride , NULL , 0 , NULL , 0 , bw , bh ) ; # endif best_pred = this_mode_pred ; } } pd -> dst = orig_dst ; for ( i = 0 ; i < 4 ; ++ i ) { const PREDICTION_MODE this_mode = intra_mode_list [ i ] ; THR_MODES mode_index = mode_idx [ INTRA_FRAME ] [ mode_offset ( this_mode ) ] ; int mode_rd_thresh = rd_threshes [ mode_index ] ; if ( ! ( ( 1 << this_mode ) & cpi -> sf . intra_y_mode_bsize_mask [ bsize ] ) ) continue ; if ( rd_less_than_thresh ( best_rdc . rdcost , mode_rd_thresh , rd_thresh_freq_fact [ mode_index ] ) ) continue ; mbmi -> mode = this_mode ; mbmi -> ref_frame [ 0 ] = INTRA_FRAME ; args . mode = this_mode ; args . rate = 0 ; args . dist = 0 ; mbmi -> tx_size = intra_tx_size ; vp9_foreach_transformed_block_in_plane ( xd , ( xd , bsize , 0 , estimate_block_intra , & args ) ; this_rdc . rate = args . rate ; this_rdc . dist = args . dist ; this_rdc . rate += cpi -> mbmode_cost [ this_mode ] ; this_rdc . rate += ref_frame_cost [ INTRA_FRAME ] ; this_rdc . += intra_cost_penalty ; this_rdc . rdcost = RDCOST ( -> rddiv , this_rdc . rate , this_rdc . dist ) ; ; if ( this_rdc . rdcost < best_rdc . rdcost ) { best_rdc = this_rdc ; best_mode = this_mode ; best_intra_tx_size = mbmi -> tx_size ; best_ref_frame = INTRA_FRAME ; mbmi -> uv_mode = this_mode ; mbmi -> mv [ 0 ] . as_int = INVALID_MV ; best_mode_skip_txfm = x -> skip_txfm [ 0 ] ; } } if ( best_ref_frame != INTRA_FRAME ) { mbmi -> tx_size = best_tx_size ; } else { mbmi -> tx_size = best_intra_tx_size ; } } pd -> dst = orig_dst ; mbmi -> mode = best_mode ; mbmi -> ref_frame [ 0 ] = best_ref_frame ; x -> skip_txfm [ 0 ] = best_mode_skip_txfm ; if ( reuse_inter_pred && best_pred != NULL ) { if ( best_pred -> data != orig_dst . buf && is_inter_mode ( mbmi -> mode ) ) { # if CONFIG_VP9_HIGHBITDEPTH if ( cm -> use_highbitdepth ) vpx_highbd_convolve_copy ( best_pred -> data , best_pred -> stride , pd -> dst . buf , pd -> dst . stride , NULL , 0 , NULL , 0 , bw , bh , xd -> bd ) ; else vpx_convolve_copy ( best_pred -> data , best_pred -> stride , pd -> dst . buf , pd -> dst . stride , NULL , 0 , NULL , 0 , bw , bh ) ; # else vpx_convolve_copy ( best_pred -> data , best_pred -> stride , pd -> dst . buf , pd -> dst . stride , NULL , 0 , NULL , 0 , bw , bh ) ; # endif } } if ( cpi -> sf . adaptive_rd_thresh ) { THR_MODES best_mode_idx = mode_idx [ best_ref_frame ] [ mode_offset ( mbmi -> mode ) ] ; if ( best_ref_frame == INTRA_FRAME ) { int intra_modes = sizeof ( intra_mode_list ) / sizeof ( PREDICTION_MODE ) ; int i ; for ( i = 0 ; i < intra_modes ; i ++ ) { update_thresh_freq_fact ( cpi , tile_data , bsize , INTRA_FRAME , best_mode_idx , intra_mode_list [ i ] ) ; } } else { for ( ref_frame = LAST_FRAME ; ref_frame <= GOLDEN_FRAME ; ++ ref_frame ) { PREDICTION_MODE this_mode ; if ( best_ref_frame != ref_frame ) continue ; for ( this_mode = NEARESTMV ; this_mode <= NEWMV ; ++ this_mode ) { update_thresh_freq_fact ( cpi , tile_data , bsize , ref_frame , best_mode_idx , this_mode ) ; } } } } * rd_cost = best_rdc ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 756,CWE-476,"CWE-476 static int stv06xx_start ( struct gspca_dev * gspca_dev ) { struct sd * sd = ( struct sd * ) gspca_dev ; struct usb_host_interface * alt ; struct usb_interface * intf ; int err , packet_size ; intf = usb_ifnum_to_if ( sd -> gspca_dev . dev , sd -> gspca_dev . iface ) ; alt = usb_altnum_to_altsetting ( intf , sd -> gspca_dev . alt ) ; if ( ! alt ) { gspca_err ( gspca_dev , ""Couldn\'tgetaltsetting\\n"" ) ; return - EIO ; } packet_size = le16_to_cpu ( alt -> endpoint [ 0 ] . desc . wMaxPacketSize ) ; err = stv06xx_write_bridge ( sd , STV_ISO_SIZE_L , packet_size ) ; if ( err < 0 ) return err ; err = sd -> sensor -> start ( sd ) ; if ( err < 0 ) goto out ; err = stv06xx_write_bridge ( sd , STV_ISO_ENABLE , 1 ) ; out : if ( err < 0 ) gspca_dbg ( gspca_dev , D_STREAM , ""Startingstreamfailed\\n"" ) ; else gspca_dbg ( gspca_dev , D_STREAM , ""Startedstreaming\\n"" ) ; return ( err < 0 ) ? err : 0 ; } "," EIO ; } if ( alt -> desc . bNumEndpoints < 1 ) return - ENODEV ; ",torvalds@linux/485b06aadb933190f4bc44e006076bc27a23f205,CVE-2020-11609,https://github.com/torvalds/linux/commit/485b06aadb933190f4bc44e006076bc27a23f205,2020-04-07T17:15Z 757,CWE-264,"CWE-264 static struct cifsSesInfo * cifs_get_smb_ses ( struct TCP_Server_Info * server , struct smb_vol * volume_info ) { int rc = - ENOMEM , xid ; struct cifsSesInfo * ses ; xid = GetXid ( ) ; ses = cifs_find_smb_ses ( server , volume_info -> username ) ; if ( ses ) { cFYI ( 1 , ""Existingsmbsessfound(status=%d)"" , ses -> status ) ; cifs_put_tcp_session ( server ) ; mutex_lock ( & ses -> session_mutex ) ; rc = cifs_negotiate_protocol ( xid , ses ) ; if ( rc ) { mutex_unlock ( & ses -> session_mutex ) ; cifs_put_smb_ses ( ses ) ; FreeXid ( xid ) ; return ERR_PTR ( rc ) ; } if ( ses -> need_reconnect ) { cFYI ( 1 , ""Sessionneedsreconnect"" ) ; rc = cifs_setup_session ( xid , ses , volume_info -> local_nls ) ; if ( rc ) { mutex_unlock ( & ses -> session_mutex ) ; cifs_put_smb_ses ( ses ) ; FreeXid ( xid ) ; return ERR_PTR ( rc ) ; } } mutex_unlock ( & ses -> session_mutex ) ; FreeXid ( xid ) ; return ses ; } cFYI ( 1 , ""Existingsmbsessnotfound"" ) ; ses = sesInfoAlloc ( ) ; if ( ses == NULL ) goto get_ses_fail ; ses -> server = server ; if ( server -> addr . sockAddr6 . sin6_family == AF_INET6 ) sprintf ( ses -> serverName , ""%pI6"" , & server -> addr . sockAddr6 . sin6_addr ) ; else sprintf ( ses -> serverName , ""%pI4"" , & server -> addr . sockAddr . sin_addr . s_addr ) ; if ( volume_info -> username ) strncpy ( ses -> userName , volume_info -> username , MAX_USERNAME_SIZE ) ; if ( volume_info -> password ) { ses -> password = kstrdup ( volume_info -> password , GFP_KERNEL ) ; if ( ! ses -> password ) goto get_ses_fail ; } if ( volume_info -> domainname ) { int len = strlen ( volume_info -> domainname ) ; ses -> domainName = kmalloc ( len + 1 , GFP_KERNEL ) ; if ( ses -> domainName ) strcpy ( ses -> domainName , volume_info -> domainname ) ; } ses -> linux_uid = volume_info -> linux_uid ; ses -> overrideSecFlg = volume_info -> secFlg ; mutex_lock ( & ses -> session_mutex ) ; rc = cifs_negotiate_protocol ( xid , ses ) ; if ( ! rc ) rc = cifs_setup_session ( xid , ses , volume_info -> local_nls ) ; mutex_unlock ( & ses -> session_mutex ) ; if ( rc ) goto get_ses_fail ; write_lock ( & cifs_tcp_ses_lock ) ; list_add ( & ses -> smb_ses_list , & server -> smb_ses_list ) ; write_unlock ( & cifs_tcp_ses_lock ) ; FreeXid ( xid ) ; return ses ; get_ses_fail : sesInfoFree ( ses ) ; FreeXid ( xid ) ; return ERR_PTR ( rc ) ; } "," server , volume_info ) ; if ",torvalds@linux/4ff67b720c02c36e54d55b88c2931879b7db1cd2,CVE-2011-1585,https://github.com/torvalds/linux/commit/4ff67b720c02c36e54d55b88c2931879b7db1cd2,2013-06-08T13:05Z 758,CWE-320,"CWE-320 int sshkey_load_file ( int fd , struct sshbuf * blob ) { u_char buf [ 1024 ] ; size_t len ; struct stat st ; int r ; if ( fstat ( fd , & st ) < 0 ) return SSH_ERR_SYSTEM_ERROR ; if ( ( st . st_mode & ( S_IFSOCK | S_IFCHR | S_IFIFO ) ) == 0 && st . st_size > MAX_KEY_FILE_SIZE ) return SSH_ERR_INVALID_FORMAT ; for ( ; ; ) { if ( ( len = atomicio ( read , fd , buf , sizeof ( buf ) ) ) == 0 ) { if ( errno == EPIPE ) break ; r = SSH_ERR_SYSTEM_ERROR ; goto out ; } if ( ( r = sshbuf_put ( blob , buf , len ) ) != 0 ) goto out ; if ( sshbuf_len ( blob ) > MAX_KEY_FILE_SIZE ) { r = SSH_ERR_INVALID_FORMAT ; goto out ; } } if ( ( st . st_mode & ( S_IFSOCK | S_IFCHR | S_IFIFO ) ) == 0 && st . st_size != ( off_t ) sshbuf_len ( blob ) ) { r = SSH_ERR_FILE_CHANGED ; goto out ; } r = 0 ; out : explicit_bzero ( buf , sizeof ( buf ) ) ; if ( r != 0 ) sshbuf_reset ( blob ) ; return r ; } "," ; int r , dontmax = 0 return SSH_ERR_INVALID_FORMAT ; if ( ( st . st_mode & S_IFREG ) == 0 || st . st_size <= 0 ) { st . st_size = 64 * 1024 ; dontmax = 1 ; } if ( ( r = sshbuf_allocate ( blob , st . st_size ) ) != 0 || ( dontmax && ( r = sshbuf_set_max_size ( blob , st . st_size ) ) != 0 ) ) return r ; ",openbsd@src/ac8147a06ed2e2403fb6b9a0c03e618a9333c0e9,CVE-2016-10011,https://github.com/openbsd/src/commit/ac8147a06ed2e2403fb6b9a0c03e618a9333c0e9,2017-01-05T02:59Z 759,CWE-190,"CWE-190 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_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 += ( int ) 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 ) ; } } "," -> it_overrun += kc -> timer_forward ",torvalds@linux/78c9c4dfbf8c04883941445a195276bb4bb92c76,CVE-2018-12896,https://github.com/torvalds/linux/commit/78c9c4dfbf8c04883941445a195276bb4bb92c76,2018-07-02T17:29Z 760,CWE-254,"CWE-254 void impeg2d_flush_ext_and_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 == EXTENSION_START_CODE || 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 ( ( u4_start_code == USER_DATA_START_CODE ) && ( ps_stream -> u4_offset < ps_stream -> u4_max_offset ) ) != 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 761,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 762,CWE-200,"CWE-200 static void copy_to_user_state ( struct xfrm_state * x , struct xfrm_usersa_info * p ) { memcpy ( & p -> id , & x -> id , sizeof ( p -> id ) ) ; memcpy ( & p -> sel , & x -> sel , sizeof ( p -> sel ) ) ; memcpy ( & p -> lft , & x -> lft , sizeof ( p -> lft ) ) ; memcpy ( & p -> curlft , & x -> curlft , sizeof ( p -> curlft ) ) ; memcpy ( & p -> stats , & x -> stats , sizeof ( p -> stats ) ) ; memcpy ( & p -> saddr , & x -> props . saddr , sizeof ( p -> saddr ) ) ; p -> mode = x -> props . mode ; p -> replay_window = x -> props . replay_window ; p -> reqid = x -> props . reqid ; p -> family = x -> props . family ; p -> flags = x -> props . flags ; p -> seq = x -> km . seq ; } "," p ) { memset ( p , 0 , sizeof ( * p ) ) ; ",torvalds@linux/f778a636713a435d3a922c60b1622a91136560c1,CVE-2012-6537,https://github.com/torvalds/linux/commit/f778a636713a435d3a922c60b1622a91136560c1,2013-03-15T20:55Z 763,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 764,CWE-119,"CWE-119 int vp8_yv12_realloc_frame_buffer ( YV12_BUFFER_CONFIG * ybf , int width , int height , int border ) { if ( ybf ) { int aligned_width = ( width + 15 ) & ~ 15 ; int aligned_height = ( height + 15 ) & ~ 15 ; int y_stride = ( ( aligned_width + 2 * border ) + 31 ) & ~ 31 ; int yplane_size = ( aligned_height + 2 * border ) * y_stride ; int uv_width = aligned_width >> 1 ; int uv_height = aligned_height >> 1 ; int uv_stride = y_stride >> 1 ; int uvplane_size = ( uv_height + border ) * uv_stride ; const int frame_size = yplane_size + 2 * uvplane_size ; if ( ! ybf -> buffer_alloc ) { ybf -> buffer_alloc = ( uint8_t * ) vpx_memalign ( 32 , frame_size ) ; ybf -> buffer_alloc_sz = frame_size ; } if ( ! ybf -> buffer_alloc || ybf -> buffer_alloc_sz < frame_size ) return - 1 ; if ( border & 0x1f ) return - 3 ; ybf -> y_crop_width = width ; ybf -> y_crop_height = height ; ybf -> y_width = aligned_width ; ybf -> y_height = aligned_height ; ybf -> y_stride = y_stride ; ybf -> uv_width = uv_width ; ybf -> uv_height = uv_height ; ybf -> uv_stride = uv_stride ; ybf -> alpha_width = 0 ; ybf -> alpha_height = 0 ; ybf -> alpha_stride = 0 ; ybf -> border = border ; ybf -> frame_size = frame_size ; ybf -> y_buffer = ybf -> buffer_alloc + ( border * y_stride ) + border ; ybf -> u_buffer = ybf -> buffer_alloc + yplane_size + ( border / 2 * uv_stride ) + border / 2 ; ybf -> v_buffer = ybf -> buffer_alloc + yplane_size + uvplane_size + ( border / 2 * uv_stride ) + border / 2 ; ybf -> alpha_buffer = NULL ; ybf -> corrupted = 0 ; return 0 ; } return - 2 ; } "," ; ybf -> uv_crop_width = ( width + 1 ) / 2 ; ybf -> uv_crop_height = ( height + 1 ) / 2 ; ybf -> ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 765,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 766,CWE-287,"CWE-287 CMD_FUNC ( m_authenticate ) { aClient * agent_p = NULL ; if ( ! SASL_SERVER || ! MyConnect ( sptr ) || BadPtr ( parv [ 1 ] ) || ! CHECKPROTO ( sptr , PROTO_SASL ) ) return 0 ; if ( sptr -> local -> sasl_complete ) { sendto_one ( sptr , err_str ( ERR_SASLALREADY ) , me . name , BadPtr ( sptr -> name ) ? ""*"" : sptr -> name ) ; return 0 ; } if ( strlen ( parv [ 1 ] ) > 400 ) { sendto_one ( sptr , err_str ( ERR_SASLTOOLONG ) , me . name , BadPtr ( sptr -> name ) ? ""*"" : sptr -> name ) ; return 0 ; } if ( * sptr -> local -> sasl_agent ) agent_p = find_client ( sptr -> local -> sasl_agent , NULL ) ; if ( agent_p == NULL ) { char * addr = BadPtr ( sptr -> ip ) ? ""0"" : sptr -> ip ; char * certfp = moddata_client_get ( sptr , ""certfp"" ) ; sendto_server ( NULL , 0 , 0 , "":%sSASL%s%sH%s%s"" , me . name , SASL_SERVER , encode_puid ( sptr ) , addr , addr ) ; if ( certfp ) sendto_server ( NULL , 0 , 0 , "":%sSASL%s%sS%s%s"" , me . name , SASL_SERVER , encode_puid ( sptr ) , parv [ 1 ] , certfp ) ; else sendto_server ( NULL , 0 , 0 , "":%sSASL%s%sS%s"" , me . name , SASL_SERVER , encode_puid ( sptr ) , parv [ 1 ] ) ; } else sendto_server ( NULL , 0 , 0 , "":%sSASL%s%sC%s"" , me . name , AGENT_SID ( agent_p ) , encode_puid ( sptr ) , parv [ 1 ] ) ; sptr -> local -> sasl_out ++ ; return 0 ; } "," } if ( ( parv [ 1 ] [ 0 ] == ':' ) || strchr ( parv [ 1 ] , '' ) ) { sendto_one ( sptr , err_str ( ERR_CANNOTDOCOMMAND ) , me . name , ""*"" , ""AUTHENTICATE"" , ""Invalidparameter"" ) ; return 0 ; } if ( ",unrealircd@unrealircd/f473e355e1dc422c4f019dbf86bc50ba1a34a766,CVE-2016-7144,https://github.com/unrealircd/unrealircd/commit/f473e355e1dc422c4f019dbf86bc50ba1a34a766,2017-01-18T17:59Z 767,CWE-399,"CWE-399 void ptrace_triggered ( struct perf_event * bp , int nmi , struct perf_sample_data * data , struct pt_regs * regs ) { struct perf_event_attr attr ; attr = bp -> attr ; attr . disabled = true ; modify_user_hw_breakpoint ( bp , & attr ) ; } "," perf_event * bp , struct perf_sample_data ",torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,CVE-2011-2918,https://github.com/torvalds/linux/commit/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,2012-05-24T23:55Z 768,CWE-74,"CWE-74 gboolean flatpak_run_add_environment_args ( FlatpakBwrap * bwrap , const char * app_info_path , FlatpakRunFlags flags , const char * app_id , FlatpakContext * context , GFile * app_id_dir , GPtrArray * previous_app_id_dirs , FlatpakExports * * exports_out , GCancellable * cancellable , GError * * error ) { g_autoptr ( GError ) my_error = NULL ; g_autoptr ( FlatpakExports ) exports = NULL ; g_autoptr ( FlatpakBwrap ) proxy_arg_bwrap = flatpak_bwrap_new ( flatpak_bwrap_empty_env ) ; gboolean has_wayland = FALSE ; gboolean allow_x11 = FALSE ; if ( ( context -> shares & FLATPAK_CONTEXT_SHARED_IPC ) == 0 ) { g_debug ( ""Disallowingipcaccess"" ) ; flatpak_bwrap_add_args ( bwrap , ""--unshare-ipc"" , NULL ) ; } if ( ( context -> shares & FLATPAK_CONTEXT_SHARED_NETWORK ) == 0 ) { g_debug ( ""Disallowingnetworkaccess"" ) ; flatpak_bwrap_add_args ( bwrap , ""--unshare-net"" , NULL ) ; } if ( context -> devices & FLATPAK_CONTEXT_DEVICE_ALL ) { flatpak_bwrap_add_args ( bwrap , ""--dev-bind"" , ""/dev"" , ""/dev"" , NULL ) ; if ( g_file_test ( ""/dev/shm"" , G_FILE_TEST_IS_DIR ) ) { if ( ( context -> devices & FLATPAK_CONTEXT_DEVICE_SHM ) == 0 ) flatpak_bwrap_add_args ( bwrap , ""--tmpfs"" , ""/dev/shm"" , NULL ) ; } else if ( g_file_test ( ""/dev/shm"" , G_FILE_TEST_IS_SYMLINK ) ) { g_autofree char * link = flatpak_readlink ( ""/dev/shm"" , NULL ) ; if ( g_strcmp0 ( link , ""/run/shm"" ) == 0 ) { if ( context -> devices & FLATPAK_CONTEXT_DEVICE_SHM && g_file_test ( ""/run/shm"" , G_FILE_TEST_IS_DIR ) ) flatpak_bwrap_add_args ( bwrap , ""--bind"" , ""/run/shm"" , ""/run/shm"" , NULL ) ; else flatpak_bwrap_add_args ( bwrap , ""--dir"" , ""/run/shm"" , NULL ) ; } else g_warning ( ""Unexpected/dev/shmsymlink%s"" , link ) ; } } else { flatpak_bwrap_add_args ( bwrap , ""--dev"" , ""/dev"" , NULL ) ; if ( context -> devices & FLATPAK_CONTEXT_DEVICE_DRI ) { g_debug ( ""Allowingdriaccess"" ) ; int i ; char * dri_devices [ ] = { ""/dev/dri"" , ""/dev/mali"" , ""/dev/mali0"" , ""/dev/umplock"" , ""/dev/nvidiactl"" , ""/dev/nvidia-modeset"" , ""/dev/nvidia-uvm"" , ""/dev/nvidia-uvm-tools"" , } ; for ( i = 0 ; i < G_N_ELEMENTS ( dri_devices ) ; i ++ ) { if ( g_file_test ( dri_devices [ i ] , G_FILE_TEST_EXISTS ) ) flatpak_bwrap_add_args ( bwrap , ""--dev-bind"" , dri_devices [ i ] , dri_devices [ i ] , NULL ) ; } char nvidia_dev [ 14 ] ; for ( i = 0 ; i < 20 ; i ++ ) { g_snprintf ( nvidia_dev , sizeof ( nvidia_dev ) , ""/dev/nvidia%d"" , i ) ; if ( g_file_test ( nvidia_dev , G_FILE_TEST_EXISTS ) ) flatpak_bwrap_add_args ( bwrap , ""--dev-bind"" , nvidia_dev , nvidia_dev , NULL ) ; } } if ( context -> devices & FLATPAK_CONTEXT_DEVICE_KVM ) { g_debug ( ""Allowingkvmaccess"" ) ; if ( g_file_test ( ""/dev/kvm"" , G_FILE_TEST_EXISTS ) ) flatpak_bwrap_add_args ( bwrap , ""--dev-bind"" , ""/dev/kvm"" , ""/dev/kvm"" , NULL ) ; } if ( context -> devices & FLATPAK_CONTEXT_DEVICE_SHM ) { g_autofree char * real_dev_shm = realpath ( ""/dev/shm"" , NULL ) ; g_debug ( ""Allowing/dev/shmaccess(as%s)"" , real_dev_shm ) ; if ( real_dev_shm != NULL ) flatpak_bwrap_add_args ( bwrap , ""--bind"" , real_dev_shm , ""/dev/shm"" , NULL ) ; } } flatpak_context_append_bwrap_filesystem ( context , bwrap , app_id , app_id_dir , previous_app_id_dirs , & exports ) ; if ( context -> sockets & FLATPAK_CONTEXT_SOCKET_WAYLAND ) { g_debug ( ""Allowingwaylandaccess"" ) ; has_wayland = flatpak_run_add_wayland_args ( bwrap ) ; } if ( ( context -> sockets & FLATPAK_CONTEXT_SOCKET_FALLBACK_X11 ) != 0 ) allow_x11 = ! has_wayland ; else allow_x11 = ( context -> sockets & FLATPAK_CONTEXT_SOCKET_X11 ) != 0 ; flatpak_run_add_x11_args ( bwrap , allow_x11 ) ; if ( context -> sockets & FLATPAK_CONTEXT_SOCKET_SSH_AUTH ) { flatpak_run_add_ssh_args ( bwrap ) ; } if ( context -> sockets & FLATPAK_CONTEXT_SOCKET_PULSEAUDIO ) { g_debug ( ""Allowingpulseaudioaccess"" ) ; flatpak_run_add_pulseaudio_args ( bwrap ) ; } if ( context -> sockets & FLATPAK_CONTEXT_SOCKET_PCSC ) { flatpak_run_add_pcsc_args ( bwrap ) ; } if ( context -> sockets & FLATPAK_CONTEXT_SOCKET_CUPS ) { flatpak_run_add_cups_args ( bwrap ) ; } flatpak_run_add_session_dbus_args ( bwrap , proxy_arg_bwrap , context , flags , app_id ) ; flatpak_run_add_system_dbus_args ( bwrap , proxy_arg_bwrap , context , flags ) ; flatpak_run_add_a11y_dbus_args ( bwrap , proxy_arg_bwrap , context , flags ) ; if ( g_environ_getenv ( bwrap -> envp , ""LD_LIBRARY_PATH"" ) != NULL ) { flatpak_bwrap_add_args ( bwrap , ""--setenv"" , ""LD_LIBRARY_PATH"" , g_environ_getenv ( bwrap -> envp , ""LD_LIBRARY_PATH"" ) , NULL ) ; flatpak_bwrap_unset_env ( bwrap , ""LD_LIBRARY_PATH"" ) ; } if ( g_environ_getenv ( bwrap -> envp , ""TMPDIR"" ) != NULL ) { flatpak_bwrap_add_args ( bwrap , ""--setenv"" , ""TMPDIR"" , g_environ_getenv ( bwrap -> envp , ""TMPDIR"" ) , NULL ) ; flatpak_bwrap_unset_env ( bwrap , ""TMPDIR"" ) ; } if ( ! flatpak_run_in_transient_unit ( app_id , & my_error ) ) { g_debug ( ""Failedtorunintransientscope:%s"" , my_error -> message ) ; g_clear_error ( & my_error ) ; } if ( ! flatpak_bwrap_is_empty ( proxy_arg_bwrap ) && ! start_dbus_proxy ( bwrap , proxy_arg_bwrap , app_info_path , error ) ) return FALSE ; if ( exports_out ) * exports_out = g_steal_pointer ( & exports ) ; return TRUE ; } "," ; if ( ! flatpak_run_in_transient_unit ( ",flatpak@flatpak/6d1773d2a54dde9b099043f07a2094a4f1c2f486,CVE-2021-21261,https://github.com/flatpak/flatpak/commit/6d1773d2a54dde9b099043f07a2094a4f1c2f486,2021-01-14T20:15Z 769,CWE-200,"CWE-200 static mode_t set_umask ( const char * optarg ) { long umask_long ; mode_t umask_val ; char * endptr ; umask_long = strtoll ( optarg , & endptr , 0 ) ; if ( * endptr || umask_long < 0 || umask_long & ~ 0777L ) { fprintf ( stderr , ""Invalid--umaskoption%s"" , optarg ) ; return ; } umask_val = umask_long & 0777 ; umask ( umask_val ) ; umask_cmdline = true ; return umask_val ; } "," ) ; return 0 ",acassen@keepalived/5241e4d7b177d0b6f073cfc9ed5444bf51ec89d6,CVE-2018-19045,https://github.com/acassen/keepalived/commit/5241e4d7b177d0b6f073cfc9ed5444bf51ec89d6,2018-11-08T20:29Z 770,CWE-617,"CWE-617 krb5_error_code kdc_process_s4u2self_req ( kdc_realm_t * kdc_active_realm , krb5_kdc_req * request , krb5_const_principal client_princ , krb5_const_principal header_srv_princ , krb5_boolean issuing_referral , const krb5_db_entry * server , krb5_keyblock * tgs_subkey , krb5_keyblock * tgs_session , krb5_timestamp kdc_time , krb5_pa_s4u_x509_user * * s4u_x509_user , krb5_db_entry * * princ_ptr , const char * * status ) { krb5_error_code code ; krb5_boolean is_local_tgt ; krb5_pa_data * pa_data ; int flags ; krb5_db_entry * princ ; * princ_ptr = NULL ; pa_data = krb5int_find_pa_data ( kdc_context , request -> padata , KRB5_PADATA_S4U_X509_USER ) ; if ( pa_data != NULL ) { code = kdc_process_s4u_x509_user ( kdc_context , request , pa_data , tgs_subkey , tgs_session , s4u_x509_user , status ) ; if ( code != 0 ) return code ; } else { pa_data = krb5int_find_pa_data ( kdc_context , request -> padata , KRB5_PADATA_FOR_USER ) ; if ( pa_data != NULL ) { code = kdc_process_for_user ( kdc_active_realm , pa_data , tgs_session , s4u_x509_user , status ) ; if ( code != 0 ) return code ; } else return 0 ; } flags = 0 ; switch ( krb5_princ_type ( kdc_context , request -> server ) ) { case KRB5_NT_SRV_HST : if ( krb5_princ_size ( kdc_context , request -> server ) == 2 ) flags |= KRB5_PRINCIPAL_COMPARE_IGNORE_REALM ; break ; case KRB5_NT_ENTERPRISE_PRINCIPAL : flags |= KRB5_PRINCIPAL_COMPARE_ENTERPRISE ; break ; default : break ; } if ( ! krb5_principal_compare_flags ( kdc_context , request -> server , client_princ , flags ) ) { * status = ""INVALID_S4U2SELF_REQUEST"" ; return KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN ; } if ( request -> kdc_options & AS_INVALID_OPTIONS ) { * status = ""INVALIDASOPTIONS"" ; return KRB5KDC_ERR_BADOPTION ; } is_local_tgt = ! is_cross_tgs_principal ( header_srv_princ ) ; if ( is_local_tgt && issuing_referral ) { * status = ""LOOKING_UP_SERVER"" ; return KRB5KDC_ERR_S_PRINCIPAL_UNKNOWN ; } if ( is_local_principal ( kdc_active_realm , ( * s4u_x509_user ) -> user_id . user ) ) { krb5_db_entry no_server ; krb5_pa_data * * e_data = NULL ; if ( ! is_local_tgt && ! issuing_referral ) { * status = ""NOT_CROSS_REALM_REQUEST"" ; return KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN ; } code = krb5_db_get_principal ( kdc_context , ( * s4u_x509_user ) -> user_id . user , KRB5_KDB_FLAG_INCLUDE_PAC , & princ ) ; if ( code == KRB5_KDB_NOENTRY ) { * status = ""UNKNOWN_S4U2SELF_PRINCIPAL"" ; return KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN ; } else if ( code ) { * status = ""LOOKING_UP_S4U2SELF_PRINCIPAL"" ; return code ; } memset ( & no_server , 0 , sizeof ( no_server ) ) ; code = validate_as_request ( kdc_active_realm , request , * princ , no_server , kdc_time , status , & e_data ) ; if ( code ) { krb5_db_free_principal ( kdc_context , princ ) ; krb5_free_pa_data ( kdc_context , e_data ) ; return code ; } * princ_ptr = princ ; } else if ( is_local_tgt ) { * status = ""S4U2SELF_CLIENT_NOT_OURS"" ; return KRB5KDC_ERR_POLICY ; } return 0 ; } "," ) ) ; princ -> pw_expiration = 0 ; clear ( princ -> attributes , KRB5_KDB_REQUIRES_PWCHANGE ) ; ",krb5@krb5/5e6d1796106df8ba6bc1973ee0917c170d929086,CVE-2018-20217,https://github.com/krb5/krb5/commit/5e6d1796106df8ba6bc1973ee0917c170d929086,2018-12-26T21:29Z 771,CWE-20,"CWE-20 static void f2fs_put_super ( struct super_block * sb ) { struct f2fs_sb_info * sbi = F2FS_SB ( sb ) ; int i ; f2fs_quota_off_umount ( sb ) ; mutex_lock ( & sbi -> umount_mutex ) ; if ( is_sbi_flag_set ( sbi , SBI_IS_DIRTY ) || ! is_set_ckpt_flags ( sbi , CP_UMOUNT_FLAG ) ) { struct cp_control cpc = { . reason = CP_UMOUNT , } ; write_checkpoint ( sbi , & cpc ) ; } f2fs_wait_discard_bios ( sbi ) ; if ( f2fs_discard_en ( sbi ) && ! sbi -> discard_blks ) { struct cp_control cpc = { . reason = CP_UMOUNT | CP_TRIMMED , } ; write_checkpoint ( sbi , & cpc ) ; } f2fs_destroy_stats ( sbi ) ; release_ino_entry ( sbi , true ) ; f2fs_leave_shrinker ( sbi ) ; mutex_unlock ( & sbi -> umount_mutex ) ; f2fs_flush_merged_writes ( sbi ) ; iput ( sbi -> node_inode ) ; iput ( sbi -> meta_inode ) ; destroy_node_manager ( sbi ) ; destroy_segment_manager ( sbi ) ; kfree ( sbi -> ckpt ) ; f2fs_unregister_sysfs ( sbi ) ; sb -> s_fs_info = NULL ; if ( sbi -> s_chksum_driver ) crypto_free_shash ( sbi -> s_chksum_driver ) ; kfree ( sbi -> raw_super ) ; destroy_device_list ( sbi ) ; mempool_destroy ( sbi -> write_io_dummy ) ; # ifdef CONFIG_QUOTA for ( i = 0 ; i < MAXQUOTAS ; i ++ ) kfree ( sbi -> s_qf_names [ i ] ) ; # endif destroy_percpu_info ( sbi ) ; for ( i = 0 ; i < NR_PAGE_TYPE ; i ++ ) kfree ( sbi -> write_io [ i ] ) ; kfree ( sbi ) ; } "," f2fs_wait_discard_bios ( sbi , true ",torvalds@linux/638164a2718f337ea224b747cf5977ef143166a4,CVE-2017-18200,https://github.com/torvalds/linux/commit/638164a2718f337ea224b747cf5977ef143166a4,2018-02-26T03:29Z 772,CWE-119,"CWE-119 static void read_frame_reference_mode_probs ( VP9_COMMON * cm , vp9_reader * r ) { FRAME_CONTEXT * const fc = & cm -> fc ; int i ; if ( cm -> reference_mode == REFERENCE_MODE_SELECT ) for ( i = 0 ; i < COMP_INTER_CONTEXTS ; ++ i ) vp9_diff_update_prob ( r , & fc -> comp_inter_prob [ i ] ) ; if ( cm -> reference_mode != COMPOUND_REFERENCE ) for ( i = 0 ; i < REF_CONTEXTS ; ++ i ) { vp9_diff_update_prob ( r , & fc -> single_ref_prob [ i ] [ 0 ] ) ; vp9_diff_update_prob ( r , & fc -> single_ref_prob [ i ] [ 1 ] ) ; } if ( cm -> reference_mode != SINGLE_REFERENCE ) for ( i = 0 ; i < REF_CONTEXTS ; ++ i ) vp9_diff_update_prob ( r , & fc -> comp_ref_prob [ i ] ) ; } "," * cm , vpx_reader * r ) const fc = cm -> fc ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 773,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 774,CWE-476,"CWE-476 static int rfcomm_sock_bind ( struct socket * sock , struct sockaddr * addr , int addr_len ) { struct sockaddr_rc * sa = ( struct sockaddr_rc * ) addr ; struct sock * sk = sock -> sk ; int chan = sa -> rc_channel ; int err = 0 ; BT_DBG ( ""sk%p%pMR"" , sk , & sa -> rc_bdaddr ) ; if ( ! addr || addr -> sa_family != AF_BLUETOOTH ) return - EINVAL ; lock_sock ( sk ) ; if ( sk -> sk_state != BT_OPEN ) { err = - EBADFD ; goto done ; } if ( sk -> sk_type != SOCK_STREAM ) { err = - EINVAL ; goto done ; } write_lock ( & rfcomm_sk_list . lock ) ; if ( chan && __rfcomm_get_listen_sock_by_addr ( chan , & sa -> rc_bdaddr ) ) { err = - EADDRINUSE ; } else { bacpy ( & rfcomm_pi ( sk ) -> src , & sa -> rc_bdaddr ) ; rfcomm_pi ( sk ) -> channel = chan ; sk -> sk_state = BT_BOUND ; } write_unlock ( & rfcomm_sk_list . lock ) ; done : release_sock ( sk ) ; return err ; } "," { struct sockaddr_rc sa ; struct sock sk ; int len , err = 0 err = 0 ; if ( - EINVAL ; memset ( & sa , 0 , sizeof ( sa ) ) ; len = min_t ( unsigned int , sizeof ( sa ) , addr_len ) ; memcpy ( & sa , addr , len ) ; BT_DBG ( ""sk%p%pMR"" , sk , & sa . rc_bdaddr ) ; ; if ( sa . rc_channel && __rfcomm_get_listen_sock_by_addr ( && __rfcomm_get_listen_sock_by_addr ( sa . rc_channel , & sa . rc_bdaddr ) ) , & sa . rc_bdaddr ) ; -> channel = sa . rc_channel ; sk -> ",torvalds@linux/951b6a0717db97ce420547222647bcc40bf1eacd,CVE-2015-8956,https://github.com/torvalds/linux/commit/951b6a0717db97ce420547222647bcc40bf1eacd,2016-10-10T10:59Z 775,CWE-125,"CWE-125 static int dnxhd_decode_header ( DNXHDContext * ctx , AVFrame * frame , const uint8_t * buf , int buf_size , int first_field ) { int i , cid , ret ; int old_bit_depth = ctx -> bit_depth , bitdepth ; uint64_t header_prefix ; if ( buf_size < 0x280 ) { av_log ( ctx -> avctx , AV_LOG_ERROR , ""buffertoosmall(%d<640).\\n"" , buf_size ) ; return AVERROR_INVALIDDATA ; } header_prefix = ff_dnxhd_parse_header_prefix ( buf ) ; if ( header_prefix == 0 ) { av_log ( ctx -> avctx , AV_LOG_ERROR , ""unknownheader0x%02X0x%02X0x%02X0x%02X0x%02X\\n"" , buf [ 0 ] , buf [ 1 ] , buf [ 2 ] , buf [ 3 ] , buf [ 4 ] ) ; return AVERROR_INVALIDDATA ; } if ( buf [ 5 ] & 2 ) { ctx -> cur_field = buf [ 5 ] & 1 ; frame -> interlaced_frame = 1 ; frame -> top_field_first = first_field ^ ctx -> cur_field ; av_log ( ctx -> avctx , AV_LOG_DEBUG , ""interlaced%d,curfield%d\\n"" , buf [ 5 ] & 3 , ctx -> cur_field ) ; } else { ctx -> cur_field = 0 ; } ctx -> mbaff = ( buf [ 0x6 ] >> 5 ) & 1 ; ctx -> height = AV_RB16 ( buf + 0x18 ) ; ctx -> width = AV_RB16 ( buf + 0x1a ) ; switch ( buf [ 0x21 ] >> 5 ) { case 1 : bitdepth = 8 ; break ; case 2 : bitdepth = 10 ; break ; case 3 : bitdepth = 12 ; break ; default : av_log ( ctx -> avctx , AV_LOG_ERROR , ""Unknownbitdepthindicator(%d)\\n"" , buf [ 0x21 ] >> 5 ) ; return AVERROR_INVALIDDATA ; } cid = AV_RB32 ( buf + 0x28 ) ; ctx -> avctx -> profile = dnxhd_get_profile ( cid ) ; if ( ( ret = dnxhd_init_vlc ( ctx , cid , bitdepth ) ) < 0 ) return ret ; if ( ctx -> mbaff && ctx -> cid_table -> cid != 1260 ) av_log ( ctx -> avctx , AV_LOG_WARNING , ""AdaptiveMBinterlaceflaginanunsupportedprofile.\\n"" ) ; ctx -> act = buf [ 0x2C ] & 7 ; if ( ctx -> act && ctx -> cid_table -> cid != 1256 && ctx -> cid_table -> cid != 1270 ) av_log ( ctx -> avctx , AV_LOG_WARNING , ""Adaptivecolortransforminanunsupportedprofile.\\n"" ) ; ctx -> is_444 = ( buf [ 0x2C ] >> 6 ) & 1 ; if ( ctx -> is_444 ) { if ( bitdepth == 8 ) { avpriv_request_sample ( ctx -> avctx , ""4:4:48bits"" ) ; return AVERROR_INVALIDDATA ; } else if ( bitdepth == 10 ) { ctx -> decode_dct_block = dnxhd_decode_dct_block_10_444 ; ctx -> pix_fmt = ctx -> act ? AV_PIX_FMT_YUV444P10 : AV_PIX_FMT_GBRP10 ; } else { ctx -> decode_dct_block = dnxhd_decode_dct_block_12_444 ; ctx -> pix_fmt = ctx -> act ? AV_PIX_FMT_YUV444P12 : AV_PIX_FMT_GBRP12 ; } } else if ( bitdepth == 12 ) { ctx -> decode_dct_block = dnxhd_decode_dct_block_12 ; ctx -> pix_fmt = AV_PIX_FMT_YUV422P12 ; } else if ( bitdepth == 10 ) { if ( ctx -> avctx -> profile == FF_PROFILE_DNXHR_HQX ) ctx -> decode_dct_block = dnxhd_decode_dct_block_10_444 ; else ctx -> decode_dct_block = dnxhd_decode_dct_block_10 ; ctx -> pix_fmt = AV_PIX_FMT_YUV422P10 ; } else { ctx -> decode_dct_block = dnxhd_decode_dct_block_8 ; ctx -> pix_fmt = AV_PIX_FMT_YUV422P ; } ctx -> avctx -> bits_per_raw_sample = ctx -> bit_depth = bitdepth ; if ( ctx -> bit_depth != old_bit_depth ) { ff_blockdsp_init ( & ctx -> bdsp , ctx -> avctx ) ; ff_idctdsp_init ( & ctx -> idsp , ctx -> avctx ) ; ff_init_scantable ( ctx -> idsp . idct_permutation , & ctx -> scantable , ff_zigzag_direct ) ; } if ( ctx -> width != ctx -> cid_table -> width && ctx -> cid_table -> width != DNXHD_VARIABLE ) { av_reduce ( & ctx -> avctx -> sample_aspect_ratio . num , & ctx -> avctx -> sample_aspect_ratio . den , ctx -> width , ctx -> cid_table -> width , 255 ) ; ctx -> width = ctx -> cid_table -> width ; } if ( buf_size < ctx -> cid_table -> coding_unit_size ) { av_log ( ctx -> avctx , AV_LOG_ERROR , ""incorrectframesize(%d<%u).\\n"" , buf_size , ctx -> cid_table -> coding_unit_size ) ; return AVERROR_INVALIDDATA ; } ctx -> mb_width = ( ctx -> width + 15 ) >> 4 ; ctx -> mb_height = AV_RB16 ( buf + 0x16c ) ; if ( ( ctx -> height + 15 ) >> 4 == ctx -> mb_height && frame -> interlaced_frame ) ctx -> height <<= 1 ; av_log ( ctx -> avctx , AV_LOG_VERBOSE , ""%dx%d,4:%s%dbits,MBAFF=%dACT=%d\\n"" , ctx -> width , ctx -> height , ctx -> is_444 ? ""4:4"" : ""2:2"" , ctx -> bit_depth , ctx -> mbaff , ctx -> act ) ; if ( ctx -> mb_height > 68 && ff_dnxhd_check_header_prefix_hr ( header_prefix ) ) { ctx -> data_offset = 0x170 + ( ctx -> mb_height << 2 ) ; } else { if ( ctx -> mb_height > 68 || ( ctx -> mb_height << frame -> interlaced_frame ) > ( ctx -> height + 15 ) >> 4 ) { av_log ( ctx -> avctx , AV_LOG_ERROR , ""mbheighttoobig:%d\\n"" , ctx -> mb_height ) ; return AVERROR_INVALIDDATA ; } ctx -> data_offset = 0x280 ; } if ( buf_size < ctx -> data_offset ) { av_log ( ctx -> avctx , AV_LOG_ERROR , ""buffertoosmall(%d<%d).\\n"" , buf_size , ctx -> data_offset ) ; return AVERROR_INVALIDDATA ; } if ( ctx -> mb_height > FF_ARRAY_ELEMS ( ctx -> mb_scan_index ) ) { av_log ( ctx -> avctx , AV_LOG_ERROR , ""mb_heighttoobig(%d>%"" SIZE_SPECIFIER "").\\n"" , ctx -> mb_height , FF_ARRAY_ELEMS ( ctx -> mb_scan_index ) ) ; return AVERROR_INVALIDDATA ; } for ( i = 0 ; i < ctx -> mb_height ; i ++ ) { ctx -> mb_scan_index [ i ] = AV_RB32 ( buf + 0x170 + ( i << 2 ) ) ; ff_dlog ( ctx -> avctx , ""mbscanindex%d,pos%d:%"" PRIu32 ""\\n"" , i , 0x170 + ( i << 2 ) , ctx -> mb_scan_index [ i ] ) ; if ( buf_size - ctx -> data_offset < ctx -> mb_scan_index [ i ] ) { av_log ( ctx -> avctx , AV_LOG_ERROR , ""invalidmbscanindex(%"" PRIu32 ""vs%u).\\n"" , ctx -> mb_scan_index [ i ] , buf_size - ctx -> data_offset ) ; return AVERROR_INVALIDDATA ; } } return 0 ; } "," mb_height > 68 ) { av_log ( ctx -> avctx , AV_LOG_ERROR , ""mbheighttoobig:%d\\n"" , ctx -> mb_height ) ; return AVERROR_INVALIDDATA ; } ctx -> data_offset = 0x280 ; } if ( ( ctx -> AVERROR_INVALIDDATA ; } if ( buf_size ",FFmpeg@FFmpeg/296debd213bd6dce7647cedd34eb64e5b94cdc92,CVE-2017-11719,https://github.com/FFmpeg/FFmpeg/commit/296debd213bd6dce7647cedd34eb64e5b94cdc92,2017-07-28T05:29Z 776,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 777,CWE-284,"CWE-284 static void ImportGrayQuantum ( const Image * image , QuantumInfo * quantum_info , const MagickSizeType number_pixels , const unsigned char * magick_restrict p , Quantum * magick_restrict q , ExceptionInfo * exception ) { QuantumAny range ; register ssize_t x ; ssize_t bit ; unsigned int pixel ; assert ( image != ( Image * ) NULL ) ; assert ( image -> signature == MagickCoreSignature ) ; switch ( quantum_info -> depth ) { case 1 : { register Quantum black , white ; black = 0 ; white = QuantumRange ; if ( quantum_info -> min_is_white != MagickFalse ) { black = QuantumRange ; white = 0 ; } for ( x = 0 ; x < ( ( ssize_t ) number_pixels - 7 ) ; x += 8 ) { for ( bit = 0 ; bit < 8 ; bit ++ ) { SetPixelGray ( image , ( ( * p ) & ( 1 << ( 7 - bit ) ) ) == 0 ? black : white , q ) ; q += GetPixelChannels ( image ) ; } p ++ ; } for ( bit = 0 ; bit < ( ssize_t ) ( number_pixels % 8 ) ; bit ++ ) { SetPixelGray ( image , ( ( * p ) & ( 0x01 << ( 7 - bit ) ) ) == 0 ? black : white , q ) ; q += GetPixelChannels ( image ) ; } if ( bit != 0 ) p ++ ; break ; } case 4 : { register unsigned char pixel ; range = GetQuantumRange ( quantum_info -> depth ) ; for ( x = 0 ; x < ( ( ssize_t ) number_pixels - 1 ) ; x += 2 ) { pixel = ( unsigned char ) ( ( * p >> 4 ) & 0xf ) ; SetPixelGray ( image , ScaleAnyToQuantum ( pixel , range ) , q ) ; q += GetPixelChannels ( image ) ; pixel = ( unsigned char ) ( ( * p ) & 0xf ) ; SetPixelGray ( image , ScaleAnyToQuantum ( pixel , range ) , q ) ; p ++ ; q += GetPixelChannels ( image ) ; } for ( bit = 0 ; bit < ( ssize_t ) ( number_pixels % 2 ) ; bit ++ ) { pixel = ( unsigned char ) ( * p ++ >> 4 ) ; SetPixelGray ( image , ScaleAnyToQuantum ( pixel , range ) , q ) ; q += GetPixelChannels ( image ) ; } break ; } case 8 : { unsigned char pixel ; if ( quantum_info -> min_is_white != MagickFalse ) { for ( x = 0 ; x < ( ssize_t ) number_pixels ; x ++ ) { p = PushCharPixel ( p , & pixel ) ; SetPixelGray ( image , ScaleCharToQuantum ( pixel ) , q ) ; SetPixelAlpha ( image , OpaqueAlpha , q ) ; p += quantum_info -> pad ; q += GetPixelChannels ( image ) ; } break ; } for ( x = 0 ; x < ( ssize_t ) number_pixels ; x ++ ) { p = PushCharPixel ( p , & pixel ) ; SetPixelGray ( image , ScaleCharToQuantum ( pixel ) , q ) ; SetPixelAlpha ( image , OpaqueAlpha , q ) ; p += quantum_info -> pad ; q += GetPixelChannels ( image ) ; } break ; } case 10 : { range = GetQuantumRange ( quantum_info -> depth ) ; if ( quantum_info -> pack == MagickFalse ) { if ( image -> endian == LSBEndian ) { for ( x = 0 ; x < ( ssize_t ) ( number_pixels - 2 ) ; x += 3 ) { p = PushLongPixel ( quantum_info -> endian , p , & pixel ) ; SetPixelGray ( image , ScaleAnyToQuantum ( ( pixel >> 22 ) & 0x3ff , range ) , q ) ; q += GetPixelChannels ( image ) ; SetPixelGray ( image , ScaleAnyToQuantum ( ( pixel >> 12 ) & 0x3ff , range ) , q ) ; q += GetPixelChannels ( image ) ; SetPixelGray ( image , ScaleAnyToQuantum ( ( pixel >> 2 ) & 0x3ff , range ) , q ) ; p += quantum_info -> pad ; q += GetPixelChannels ( image ) ; } p = PushLongPixel ( quantum_info -> endian , p , & pixel ) ; if ( x ++ < ( ssize_t ) ( number_pixels - 1 ) ) { SetPixelGray ( image , ScaleAnyToQuantum ( ( pixel >> 22 ) & 0x3ff , range ) , q ) ; q += GetPixelChannels ( image ) ; } if ( x ++ < ( ssize_t ) number_pixels ) { SetPixelGray ( image , ScaleAnyToQuantum ( ( pixel >> 12 ) & 0x3ff , range ) , q ) ; q += GetPixelChannels ( image ) ; } break ; } for ( x = 0 ; x < ( ssize_t ) ( number_pixels - 2 ) ; x += 3 ) { p = PushLongPixel ( quantum_info -> endian , p , & pixel ) ; SetPixelGray ( image , ScaleAnyToQuantum ( ( pixel >> 2 ) & 0x3ff , range ) , q ) ; q += GetPixelChannels ( image ) ; SetPixelGray ( image , ScaleAnyToQuantum ( ( pixel >> 12 ) & 0x3ff , range ) , q ) ; q += GetPixelChannels ( image ) ; SetPixelGray ( image , ScaleAnyToQuantum ( ( pixel >> 22 ) & 0x3ff , range ) , q ) ; p += quantum_info -> pad ; q += GetPixelChannels ( image ) ; } p = PushLongPixel ( quantum_info -> endian , p , & pixel ) ; if ( x ++ < ( ssize_t ) ( number_pixels - 1 ) ) { SetPixelGray ( image , ScaleAnyToQuantum ( ( pixel >> 2 ) & 0x3ff , range ) , q ) ; q += GetPixelChannels ( image ) ; } if ( x ++ < ( ssize_t ) number_pixels ) { SetPixelGray ( image , ScaleAnyToQuantum ( ( pixel >> 12 ) & 0x3ff , range ) , q ) ; q += GetPixelChannels ( image ) ; } break ; } for ( x = 0 ; x < ( ssize_t ) number_pixels ; x ++ ) { p = PushQuantumPixel ( quantum_info , p , & pixel ) ; SetPixelGray ( image , ScaleAnyToQuantum ( pixel , range ) , q ) ; p += quantum_info -> pad ; q += GetPixelChannels ( image ) ; } break ; } case 12 : { range = GetQuantumRange ( quantum_info -> depth ) ; if ( quantum_info -> pack == MagickFalse ) { unsigned short pixel ; for ( x = 0 ; x < ( ssize_t ) ( number_pixels - 1 ) ; x += 2 ) { p = PushShortPixel ( quantum_info -> endian , p , & pixel ) ; SetPixelGray ( image , ScaleAnyToQuantum ( ( QuantumAny ) ( pixel >> 4 ) , range ) , q ) ; q += GetPixelChannels ( image ) ; p = PushShortPixel ( quantum_info -> endian , p , & pixel ) ; SetPixelGray ( image , ScaleAnyToQuantum ( ( QuantumAny ) ( pixel >> 4 ) , range ) , q ) ; p += quantum_info -> pad ; q += GetPixelChannels ( image ) ; } for ( bit = 0 ; bit < ( ssize_t ) ( number_pixels % 2 ) ; bit ++ ) { p = PushShortPixel ( quantum_info -> endian , p , & pixel ) ; SetPixelGray ( image , ScaleAnyToQuantum ( ( QuantumAny ) ( pixel >> 4 ) , range ) , q ) ; p += quantum_info -> pad ; q += GetPixelChannels ( image ) ; } if ( bit != 0 ) p ++ ; break ; } for ( x = 0 ; x < ( ssize_t ) number_pixels ; x ++ ) { p = PushQuantumPixel ( quantum_info , p , & pixel ) ; SetPixelGray ( image , ScaleAnyToQuantum ( pixel , range ) , q ) ; p += quantum_info -> pad ; q += GetPixelChannels ( image ) ; } break ; } case 16 : { unsigned short pixel ; if ( quantum_info -> min_is_white != MagickFalse ) { for ( x = 0 ; x < ( ssize_t ) number_pixels ; x ++ ) { p = PushShortPixel ( quantum_info -> endian , p , & pixel ) ; SetPixelGray ( image , ScaleShortToQuantum ( pixel ) , q ) ; p += quantum_info -> pad ; q += GetPixelChannels ( image ) ; } break ; } if ( quantum_info -> format == FloatingPointQuantumFormat ) { for ( x = 0 ; x < ( ssize_t ) number_pixels ; x ++ ) { p = PushShortPixel ( quantum_info -> endian , p , & pixel ) ; SetPixelGray ( image , ClampToQuantum ( QuantumRange * HalfToSinglePrecision ( pixel ) ) , q ) ; p += quantum_info -> pad ; q += GetPixelChannels ( image ) ; } break ; } for ( x = 0 ; x < ( ssize_t ) number_pixels ; x ++ ) { p = PushShortPixel ( quantum_info -> endian , p , & pixel ) ; SetPixelGray ( image , ScaleShortToQuantum ( pixel ) , q ) ; p += quantum_info -> pad ; q += GetPixelChannels ( image ) ; } break ; } case 32 : { unsigned int pixel ; if ( quantum_info -> format == FloatingPointQuantumFormat ) { float pixel ; for ( x = 0 ; x < ( ssize_t ) number_pixels ; x ++ ) { p = PushFloatPixel ( quantum_info , p , & pixel ) ; SetPixelGray ( image , ClampToQuantum ( pixel ) , q ) ; p += quantum_info -> pad ; q += GetPixelChannels ( image ) ; } break ; } for ( x = 0 ; x < ( ssize_t ) number_pixels ; x ++ ) { p = PushLongPixel ( quantum_info -> endian , p , & pixel ) ; SetPixelGray ( image , ScaleLongToQuantum ( pixel ) , q ) ; p += quantum_info -> pad ; q += GetPixelChannels ( image ) ; } break ; } case 64 : { if ( quantum_info -> format == FloatingPointQuantumFormat ) { double pixel ; for ( x = 0 ; x < ( ssize_t ) number_pixels ; x ++ ) { p = PushDoublePixel ( quantum_info , p , & pixel ) ; SetPixelGray ( image , ClampToQuantum ( pixel ) , q ) ; p += quantum_info -> pad ; q += GetPixelChannels ( image ) ; } break ; } } default : { range = GetQuantumRange ( quantum_info -> depth ) ; for ( x = 0 ; x < ( ssize_t ) number_pixels ; x ++ ) { p = PushQuantumPixel ( quantum_info , p , & pixel ) ; SetPixelGray ( image , ScaleAnyToQuantum ( pixel , range ) , q ) ; p += quantum_info -> pad ; q += GetPixelChannels ( image ) ; } break ; } } } "," MagickCoreSignature ) ; pixel = 0 ; ",ImageMagick@ImageMagick/134463b926fa965571aa4febd61b810be5e7da05,CVE-2016-10065,https://github.com/ImageMagick/ImageMagick/commit/134463b926fa965571aa4febd61b810be5e7da05,2017-03-03T17:59Z 778,CWE-20,"CWE-20 key_ref_t lookup_user_key ( key_serial_t id , unsigned long lflags , key_perm_t perm ) { struct keyring_search_context ctx = { . match_data . cmp = lookup_user_key_possessed , . match_data . lookup_type = KEYRING_SEARCH_LOOKUP_DIRECT , . flags = KEYRING_SEARCH_NO_STATE_CHECK , } ; struct request_key_auth * rka ; struct key * key ; key_ref_t key_ref , skey_ref ; int ret ; try_again : ctx . cred = get_current_cred ( ) ; key_ref = ERR_PTR ( - ENOKEY ) ; switch ( id ) { case KEY_SPEC_THREAD_KEYRING : if ( ! ctx . cred -> thread_keyring ) { if ( ! ( lflags & KEY_LOOKUP_CREATE ) ) goto error ; ret = install_thread_keyring ( ) ; if ( ret < 0 ) { key_ref = ERR_PTR ( ret ) ; goto error ; } goto reget_creds ; } key = ctx . cred -> thread_keyring ; __key_get ( key ) ; key_ref = make_key_ref ( key , 1 ) ; break ; case KEY_SPEC_PROCESS_KEYRING : if ( ! ctx . cred -> process_keyring ) { if ( ! ( lflags & KEY_LOOKUP_CREATE ) ) goto error ; ret = install_process_keyring ( ) ; if ( ret < 0 ) { key_ref = ERR_PTR ( ret ) ; goto error ; } goto reget_creds ; } key = ctx . cred -> process_keyring ; __key_get ( key ) ; key_ref = make_key_ref ( key , 1 ) ; break ; case KEY_SPEC_SESSION_KEYRING : if ( ! ctx . cred -> session_keyring ) { ret = install_user_keyrings ( ) ; if ( ret < 0 ) goto error ; if ( lflags & KEY_LOOKUP_CREATE ) ret = join_session_keyring ( NULL ) ; else ret = install_session_keyring ( ctx . cred -> user -> session_keyring ) ; if ( ret < 0 ) goto error ; goto reget_creds ; } else if ( ctx . cred -> session_keyring == ctx . cred -> user -> session_keyring && lflags & KEY_LOOKUP_CREATE ) { ret = join_session_keyring ( NULL ) ; if ( ret < 0 ) goto error ; goto reget_creds ; } rcu_read_lock ( ) ; key = rcu_dereference ( ctx . cred -> session_keyring ) ; __key_get ( key ) ; rcu_read_unlock ( ) ; key_ref = make_key_ref ( key , 1 ) ; break ; case KEY_SPEC_USER_KEYRING : if ( ! ctx . cred -> user -> uid_keyring ) { ret = install_user_keyrings ( ) ; if ( ret < 0 ) goto error ; } key = ctx . cred -> user -> uid_keyring ; __key_get ( key ) ; key_ref = make_key_ref ( key , 1 ) ; break ; case KEY_SPEC_USER_SESSION_KEYRING : if ( ! ctx . cred -> user -> session_keyring ) { ret = install_user_keyrings ( ) ; if ( ret < 0 ) goto error ; } key = ctx . cred -> user -> session_keyring ; __key_get ( key ) ; key_ref = make_key_ref ( key , 1 ) ; break ; case KEY_SPEC_GROUP_KEYRING : key_ref = ERR_PTR ( - EINVAL ) ; goto error ; case KEY_SPEC_REQKEY_AUTH_KEY : key = ctx . cred -> request_key_auth ; if ( ! key ) goto error ; __key_get ( key ) ; key_ref = make_key_ref ( key , 1 ) ; break ; case KEY_SPEC_REQUESTOR_KEYRING : if ( ! ctx . cred -> request_key_auth ) goto error ; down_read ( & ctx . cred -> request_key_auth -> sem ) ; if ( test_bit ( KEY_FLAG_REVOKED , & ctx . cred -> request_key_auth -> flags ) ) { key_ref = ERR_PTR ( - EKEYREVOKED ) ; key = NULL ; } else { rka = ctx . cred -> request_key_auth -> payload . data [ 0 ] ; key = rka -> dest_keyring ; __key_get ( key ) ; } up_read ( & ctx . cred -> request_key_auth -> sem ) ; if ( ! key ) goto error ; key_ref = make_key_ref ( key , 1 ) ; break ; default : key_ref = ERR_PTR ( - EINVAL ) ; if ( id < 1 ) goto error ; key = key_lookup ( id ) ; if ( IS_ERR ( key ) ) { key_ref = ERR_CAST ( key ) ; goto error ; } key_ref = make_key_ref ( key , 0 ) ; ctx . index_key . type = key -> type ; ctx . index_key . description = key -> description ; ctx . index_key . desc_len = strlen ( key -> description ) ; ctx . match_data . raw_data = key ; kdebug ( ""checkpossessed"" ) ; skey_ref = search_process_keyrings ( & ctx ) ; kdebug ( ""possessed=%p"" , skey_ref ) ; if ( ! IS_ERR ( skey_ref ) ) { key_put ( key ) ; key_ref = skey_ref ; } break ; } if ( lflags & KEY_LOOKUP_FOR_UNLINK ) { ret = 0 ; goto error ; } if ( ! ( lflags & KEY_LOOKUP_PARTIAL ) ) { ret = wait_for_key_construction ( key , true ) ; switch ( ret ) { case - ERESTARTSYS : goto invalid_key ; default : if ( perm ) goto invalid_key ; case 0 : break ; } } else if ( perm ) { ret = key_validate ( key ) ; if ( ret < 0 ) goto invalid_key ; } ret = - EIO ; if ( ! ( lflags & KEY_LOOKUP_PARTIAL ) && ! test_bit ( KEY_FLAG_INSTANTIATED , & key -> flags ) ) goto invalid_key ; ret = key_task_permission ( key_ref , ctx . cred , perm ) ; if ( ret < 0 ) goto invalid_key ; key -> last_used_at = current_kernel_time ( ) . tv_sec ; error : put_cred ( ctx . cred ) ; return key_ref ; invalid_key : key_ref_put ( key_ref ) ; key_ref = ERR_PTR ( ret ) ; goto error ; reget_creds : put_cred ( ctx . cred ) ; goto try_again ; } "," KEY_LOOKUP_PARTIAL ) && key_read_state ( key ) == KEY_IS_UNINSTANTIATED ) goto invalid_key ",torvalds@linux/363b02dab09b3226f3bd1420dad9c72b79a42a76,CVE-2017-15951,https://github.com/torvalds/linux/commit/363b02dab09b3226f3bd1420dad9c72b79a42a76,2017-10-28T02:29Z 779,CWE-125,"CWE-125 PyObject * ast2obj_expr ( void * _o ) { expr_ty o = ( expr_ty ) _o ; PyObject * result = NULL , * value = NULL ; if ( ! o ) { Py_INCREF ( Py_None ) ; return Py_None ; } switch ( o -> kind ) { case BoolOp_kind : result = PyType_GenericNew ( BoolOp_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_boolop ( o -> v . BoolOp . op ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_op , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . BoolOp . values , ast2obj_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_values , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case BinOp_kind : result = PyType_GenericNew ( BinOp_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . BinOp . left ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_left , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_operator ( o -> v . BinOp . op ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_op , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . BinOp . right ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_right , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case UnaryOp_kind : result = PyType_GenericNew ( UnaryOp_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_unaryop ( o -> v . UnaryOp . op ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_op , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . UnaryOp . operand ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_operand , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Lambda_kind : result = PyType_GenericNew ( Lambda_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_arguments ( o -> v . Lambda . args ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_args , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . Lambda . body ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_body , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case IfExp_kind : result = PyType_GenericNew ( IfExp_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . IfExp . test ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_test , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . IfExp . body ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_body , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . IfExp . orelse ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_orelse , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Dict_kind : result = PyType_GenericNew ( Dict_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_list ( o -> v . Dict . keys , ast2obj_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_keys , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . Dict . values , ast2obj_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_values , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Set_kind : result = PyType_GenericNew ( Set_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_list ( o -> v . Set . elts , ast2obj_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_elts , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case ListComp_kind : result = PyType_GenericNew ( ListComp_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . ListComp . elt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_elt , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . ListComp . generators , ast2obj_comprehension ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_generators , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case SetComp_kind : result = PyType_GenericNew ( SetComp_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . SetComp . elt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_elt , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . SetComp . generators , ast2obj_comprehension ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_generators , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case DictComp_kind : result = PyType_GenericNew ( DictComp_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . DictComp . key ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_key , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . DictComp . value ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_value , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . DictComp . generators , ast2obj_comprehension ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_generators , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case GeneratorExp_kind : result = PyType_GenericNew ( GeneratorExp_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . GeneratorExp . elt ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_elt , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . GeneratorExp . generators , ast2obj_comprehension ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_generators , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Await_kind : result = PyType_GenericNew ( Await_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . Await . value ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_value , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Yield_kind : result = PyType_GenericNew ( Yield_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . Yield . value ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_value , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case YieldFrom_kind : result = PyType_GenericNew ( YieldFrom_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . YieldFrom . value ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_value , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Compare_kind : result = PyType_GenericNew ( Compare_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . Compare . left ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_left , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; { Py_ssize_t i , n = asdl_seq_LEN ( o -> v . Compare . ops ) ; value = PyList_New ( n ) ; if ( ! value ) goto failed ; for ( i = 0 ; i < n ; i ++ ) PyList_SET_ITEM ( value , i , ast2obj_cmpop ( ( cmpop_ty ) asdl_seq_GET ( o -> v . Compare . ops , i ) ) ) ; } if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_ops , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . Compare . comparators , ast2obj_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_comparators , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Call_kind : result = PyType_GenericNew ( Call_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . Call . func ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_func , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . Call . args , ast2obj_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_args , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_list ( o -> v . Call . keywords , ast2obj_keyword ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_keywords , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Num_kind : result = PyType_GenericNew ( Num_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_object ( o -> v . Num . n ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_n , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Str_kind : result = PyType_GenericNew ( Str_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_string ( o -> v . Str . s ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_s , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_string ( o -> v . Str . kind ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_kind , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case FormattedValue_kind : result = PyType_GenericNew ( FormattedValue_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . FormattedValue . value ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_value , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_int ( o -> v . FormattedValue . conversion ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_conversion , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr ( o -> v . FormattedValue . format_spec ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_format_spec , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case JoinedStr_kind : result = PyType_GenericNew ( JoinedStr_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_list ( o -> v . JoinedStr . values , ast2obj_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_values , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Bytes_kind : result = PyType_GenericNew ( Bytes_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_bytes ( o -> v . Bytes . s ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_s , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case NameConstant_kind : result = PyType_GenericNew ( NameConstant_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_singleton ( o -> v . NameConstant . value ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_value , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Ellipsis_kind : result = PyType_GenericNew ( Ellipsis_type , NULL , NULL ) ; if ( ! result ) goto failed ; break ; case Constant_kind : result = PyType_GenericNew ( Constant_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_constant ( o -> v . Constant . value ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_value , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Attribute_kind : result = PyType_GenericNew ( Attribute_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . Attribute . value ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_value , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_identifier ( o -> v . Attribute . attr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_attr , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr_context ( o -> v . Attribute . ctx ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_ctx , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Subscript_kind : result = PyType_GenericNew ( Subscript_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . Subscript . value ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_value , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_slice ( o -> v . Subscript . slice ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_slice , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr_context ( o -> v . Subscript . ctx ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_ctx , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Starred_kind : result = PyType_GenericNew ( Starred_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_expr ( o -> v . Starred . value ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_value , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr_context ( o -> v . Starred . ctx ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_ctx , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Name_kind : result = PyType_GenericNew ( Name_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_identifier ( o -> v . Name . id ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_id , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr_context ( o -> v . Name . ctx ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_ctx , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case List_kind : result = PyType_GenericNew ( List_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_list ( o -> v . List . elts , ast2obj_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_elts , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr_context ( o -> v . List . ctx ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_ctx , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; break ; case Tuple_kind : result = PyType_GenericNew ( Tuple_type , NULL , NULL ) ; if ( ! result ) goto failed ; value = ast2obj_list ( o -> v . Tuple . elts , ast2obj_expr ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_elts , value ) == - 1 ) goto failed ; Py_DECREF ( value ) ; value = ast2obj_expr_context ( o -> v . Tuple . ctx ) ; if ( ! value ) goto failed ; if ( _PyObject_SetAttrId ( result , & PyId_ctx , 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 780,CWE-119,"CWE-119 static vpx_codec_err_t vp8_decode ( vpx_codec_alg_priv_t * ctx , const uint8_t * data , unsigned int data_sz , void * user_priv , long deadline ) { vpx_codec_err_t res = VPX_CODEC_OK ; unsigned int resolution_change = 0 ; unsigned int w , h ; if ( update_fragments ( ctx , data , data_sz , & res ) <= 0 ) return res ; w = ctx -> si . w ; h = ctx -> si . h ; res = vp8_peek_si_internal ( ctx -> fragments . ptrs [ 0 ] , ctx -> fragments . sizes [ 0 ] , & ctx -> si , ctx -> decrypt_cb , ctx -> decrypt_state ) ; if ( ( res == VPX_CODEC_UNSUP_BITSTREAM ) && ! ctx -> si . is_kf ) { res = VPX_CODEC_OK ; } if ( ! ctx -> decoder_init && ! ctx -> si . is_kf ) res = VPX_CODEC_UNSUP_BITSTREAM ; if ( ( ctx -> si . h != h ) || ( ctx -> si . w != w ) ) resolution_change = 1 ; if ( ! res && ctx -> defer_alloc ) { int i ; for ( i = 1 ; ! res && i < NELEMENTS ( ctx -> mmaps ) ; i ++ ) { vpx_codec_dec_cfg_t cfg ; cfg . w = ctx -> si . w ; cfg . h = ctx -> si . h ; ctx -> mmaps [ i ] . id = vp8_mem_req_segs [ i ] . id ; ctx -> mmaps [ i ] . sz = vp8_mem_req_segs [ i ] . sz ; ctx -> mmaps [ i ] . align = vp8_mem_req_segs [ i ] . align ; ctx -> mmaps [ i ] . flags = vp8_mem_req_segs [ i ] . flags ; if ( ! ctx -> mmaps [ i ] . sz ) ctx -> mmaps [ i ] . sz = vp8_mem_req_segs [ i ] . calc_sz ( & cfg , ctx -> base . init_flags ) ; res = vpx_mmap_alloc ( & ctx -> mmaps [ i ] ) ; } if ( ! res ) vp8_finalize_mmaps ( ctx ) ; ctx -> defer_alloc = 0 ; } if ( ! res && ! ctx -> decoder_init ) { res = vpx_validate_mmaps ( & ctx -> si , ctx -> mmaps , vp8_mem_req_segs , NELEMENTS ( vp8_mem_req_segs ) , ctx -> base . init_flags ) ; if ( ! res ) { VP8D_CONFIG oxcf ; oxcf . Width = ctx -> si . w ; oxcf . Height = ctx -> si . h ; oxcf . Version = 9 ; oxcf . postprocess = 0 ; oxcf . max_threads = ctx -> cfg . threads ; oxcf . error_concealment = ( ctx -> base . init_flags & VPX_CODEC_USE_ERROR_CONCEALMENT ) ; if ( ! ctx -> postproc_cfg_set && ( ctx -> base . init_flags & VPX_CODEC_USE_POSTPROC ) ) { ctx -> postproc_cfg . post_proc_flag = VP8_DEBLOCK | VP8_DEMACROBLOCK | VP8_MFQE ; ctx -> postproc_cfg . deblocking_level = 4 ; ctx -> postproc_cfg . noise_level = 0 ; } res = vp8_create_decoder_instances ( & ctx -> yv12_frame_buffers , & oxcf ) ; ctx -> yv12_frame_buffers . pbi [ 0 ] -> decrypt_cb = ctx -> decrypt_cb ; ctx -> yv12_frame_buffers . pbi [ 0 ] -> decrypt_state = ctx -> decrypt_state ; } ctx -> decoder_init = 1 ; } if ( ! res ) { VP8D_COMP * pbi = ctx -> yv12_frame_buffers . pbi [ 0 ] ; if ( resolution_change ) { VP8_COMMON * const pc = & pbi -> common ; MACROBLOCKD * const xd = & pbi -> mb ; # if CONFIG_MULTITHREAD int i ; # endif pc -> Width = ctx -> si . w ; pc -> Height = ctx -> si . h ; { int prev_mb_rows = pc -> mb_rows ; if ( setjmp ( pbi -> common . error . jmp ) ) { pbi -> common . error . setjmp = 0 ; return - 1 ; } pbi -> common . error . setjmp = 1 ; if ( pc -> Width <= 0 ) { pc -> Width = w ; vpx_internal_error ( & pc -> error , VPX_CODEC_CORRUPT_FRAME , ""Invalidframewidth"" ) ; } if ( pc -> Height <= 0 ) { pc -> Height = h ; vpx_internal_error ( & pc -> error , VPX_CODEC_CORRUPT_FRAME , ""Invalidframeheight"" ) ; } if ( vp8_alloc_frame_buffers ( pc , pc -> Width , pc -> Height ) ) vpx_internal_error ( & pc -> error , VPX_CODEC_MEM_ERROR , ""Failedtoallocateframebuffers"" ) ; xd -> pre = pc -> yv12_fb [ pc -> lst_fb_idx ] ; xd -> dst = pc -> yv12_fb [ pc -> new_fb_idx ] ; # if CONFIG_MULTITHREAD for ( i = 0 ; i < pbi -> allocated_decoding_thread_count ; i ++ ) { pbi -> mb_row_di [ i ] . mbd . dst = pc -> yv12_fb [ pc -> new_fb_idx ] ; vp8_build_block_doffsets ( & pbi -> mb_row_di [ i ] . mbd ) ; } # endif vp8_build_block_doffsets ( & pbi -> mb ) ; # if CONFIG_ERROR_CONCEALMENT if ( pbi -> ec_enabled ) { pc -> prev_mip = vpx_calloc ( ( pc -> mb_cols + 1 ) * ( pc -> mb_rows + 1 ) , sizeof ( MODE_INFO ) ) ; if ( ! pc -> prev_mip ) { vp8_de_alloc_frame_buffers ( pc ) ; vpx_internal_error ( & pc -> error , VPX_CODEC_MEM_ERROR , ""Failedtoallocate"" ""lastframeMODE_INFOarray"" ) ; } pc -> prev_mi = pc -> prev_mip + pc -> mode_info_stride + 1 ; if ( vp8_alloc_overlap_lists ( pbi ) ) vpx_internal_error ( & pc -> error , VPX_CODEC_MEM_ERROR , ""Failedtoallocateoverlaplists"" ""forerrorconcealment"" ) ; } # endif # if CONFIG_MULTITHREAD if ( pbi -> b_multithreaded_rd ) vp8mt_alloc_temp_buffers ( pbi , pc -> Width , prev_mb_rows ) ; # else ( void ) prev_mb_rows ; # endif } pbi -> common . error . setjmp = 0 ; pbi -> common . fb_idx_ref_cnt [ 0 ] = 0 ; } pbi -> fragments = ctx -> fragments ; ctx -> user_priv = user_priv ; if ( vp8dx_receive_compressed_data ( pbi , data_sz , data , deadline ) ) { res = update_error_state ( ctx , & pbi -> common . error ) ; } ctx -> fragments . count = 0 ; } return res ; } "," ; if ( ! ctx -> fragments . enabled && ( data == NULL && data_sz == 0 ) ) { return 0 ; } if ( ! res && ! ctx -> decoder_init ctx -> decoder_init ) { VP8D_CONFIG ; ctx -> decoder_init = 1 ; } if ( ctx -> decoder_init ) { ctx -> ctx -> decrypt_state ; } if = 0 ; vp8_clear_system_state ( ) ; ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 781,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 782,CWE-287,"CWE-287 static void start_auth_request ( PgSocket * client , const char * username ) { int res ; PktBuf * buf ; client -> auth_user = client -> db -> auth_user ; client -> pool = get_pool ( client -> db , client -> db -> auth_user ) ; if ( ! find_server ( client ) ) { client -> wait_for_user_conn = true ; return ; } slog_noise ( client , ""Doingauth_connquery"" ) ; client -> wait_for_user_conn = false ; client -> wait_for_user = true ; if ( ! sbuf_pause ( & client -> sbuf ) ) { release_server ( client -> link ) ; disconnect_client ( client , true , ""pausefailed"" ) ; return ; } client -> link -> ready = 0 ; res = 0 ; buf = pktbuf_dynamic ( 512 ) ; if ( buf ) { pktbuf_write_ExtQuery ( buf , cf_auth_query , 1 , username ) ; res = pktbuf_send_immediate ( buf , client -> link ) ; pktbuf_free ( buf ) ; } if ( ! res ) disconnect_server ( client -> link , false , ""unabletosendloginquery"" ) ; } "," ; client -> pool = get_pool ",pgbouncer@pgbouncer/7ca3e5279d05fceb1e8a043c6f5b6f58dea3ed38,CVE-2015-6817,https://github.com/pgbouncer/pgbouncer/commit/7ca3e5279d05fceb1e8a043c6f5b6f58dea3ed38,2017-05-23T04:29Z 783,CWE-119,"CWE-119 int vp8_refining_search_sad_c ( MACROBLOCK * x , BLOCK * b , BLOCKD * d , int_mv * ref_mv , int error_per_bit , int search_range , vp8_variance_fn_ptr_t * fn_ptr , int * mvcost [ 2 ] , int_mv * center_mv ) { MV neighbors [ 4 ] = { { - 1 , 0 } , { 0 , - 1 } , { 0 , 1 } , { 1 , 0 } } ; int i , j ; short this_row_offset , this_col_offset ; int what_stride = b -> src_stride ; 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 ; unsigned char * what = ( * ( b -> base_src ) + b -> src ) ; unsigned char * best_address = ( unsigned char * ) ( base_pre + d -> offset + ( ref_mv -> as_mv . row * pre_stride ) + ref_mv -> as_mv . col ) ; unsigned char * check_here ; int_mv this_mv ; unsigned int bestsad ; unsigned int thissad ; 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 ; bestsad = fn_ptr -> sdf ( what , what_stride , best_address , in_what_stride , UINT_MAX ) + mvsad_err_cost ( ref_mv , & fcenter_mv , mvsadcost , error_per_bit ) ; for ( i = 0 ; i < search_range ; i ++ ) { int best_site = - 1 ; for ( j = 0 ; j < 4 ; j ++ ) { this_row_offset = ref_mv -> as_mv . row + neighbors [ j ] . row ; this_col_offset = ref_mv -> as_mv . col + neighbors [ j ] . col ; if ( ( this_col_offset > x -> mv_col_min ) && ( this_col_offset < x -> mv_col_max ) && ( this_row_offset > x -> mv_row_min ) && ( this_row_offset < x -> mv_row_max ) ) { check_here = ( neighbors [ j ] . row ) * in_what_stride + neighbors [ j ] . col + best_address ; thissad = fn_ptr -> sdf ( what , what_stride , check_here , in_what_stride , bestsad ) ; if ( thissad < bestsad ) { this_mv . as_mv . row = this_row_offset ; this_mv . as_mv . col = this_col_offset ; thissad += mvsad_err_cost ( & this_mv , & fcenter_mv , mvsadcost , error_per_bit ) ; if ( thissad < bestsad ) { bestsad = thissad ; best_site = j ; } } } } if ( best_site == - 1 ) break ; else { ref_mv -> as_mv . row += neighbors [ best_site ] . row ; ref_mv -> as_mv . col += neighbors [ best_site ] . col ; best_address += ( neighbors [ best_site ] . row ) * in_what_stride + neighbors [ best_site ] . col ; } } this_mv . as_mv . row = ref_mv -> as_mv . row << 3 ; this_mv . as_mv . col = ref_mv -> as_mv . col << 3 ; return fn_ptr -> vf ( what , what_stride , best_address , in_what_stride , & thissad ) + mv_err_cost ( & this_mv , center_mv , mvcost , x -> errorperbit ) ; } "," best_address , 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 784,CWE-20,"CWE-20 error_t enc28j60Init ( NetInterface * interface ) { uint8_t revisionId ; Enc28j60Context * context ; TRACE_INFO ( ""InitializingENC28J60Ethernetcontroller...\\r\\n"" ) ; interface -> spiDriver -> init ( ) ; interface -> extIntDriver -> init ( ) ; enc28j60SoftReset ( interface ) ; sleep ( 10 ) ; context = ( Enc28j60Context * ) interface -> nicContext ; context -> currentBank = UINT16_MAX ; context -> nextPacket = ENC28J60_RX_BUFFER_START ; context -> rxBuffer = memPoolAlloc ( ETH_MAX_FRAME_SIZE ) ; if ( context -> rxBuffer == NULL ) { return ERROR_OUT_OF_MEMORY ; } revisionId = enc28j60ReadReg ( interface , ENC28J60_REG_EREVID ) ; TRACE_INFO ( ""ENC28J60revisionID:0x%02X\\r\\n"" , revisionId ) ; enc28j60WriteReg ( interface , ENC28J60_REG_ECOCON , 0x00 ) ; enc28j60WriteReg ( interface , ENC28J60_REG_MAADR1 , interface -> macAddr . b [ 0 ] ) ; enc28j60WriteReg ( interface , ENC28J60_REG_MAADR2 , interface -> macAddr . b [ 1 ] ) ; enc28j60WriteReg ( interface , ENC28J60_REG_MAADR3 , interface -> macAddr . b [ 2 ] ) ; enc28j60WriteReg ( interface , ENC28J60_REG_MAADR4 , interface -> macAddr . b [ 3 ] ) ; enc28j60WriteReg ( interface , ENC28J60_REG_MAADR5 , interface -> macAddr . b [ 4 ] ) ; enc28j60WriteReg ( interface , ENC28J60_REG_MAADR6 , interface -> macAddr . b [ 5 ] ) ; enc28j60WriteReg ( interface , ENC28J60_REG_ERXSTL , LSB ( ENC28J60_RX_BUFFER_START ) ) ; enc28j60WriteReg ( interface , ENC28J60_REG_ERXSTH , MSB ( ENC28J60_RX_BUFFER_START ) ) ; enc28j60WriteReg ( interface , ENC28J60_REG_ERXNDL , LSB ( ENC28J60_RX_BUFFER_STOP ) ) ; enc28j60WriteReg ( interface , ENC28J60_REG_ERXNDH , MSB ( ENC28J60_RX_BUFFER_STOP ) ) ; enc28j60WriteReg ( interface , ENC28J60_REG_ERXRDPTL , LSB ( ENC28J60_RX_BUFFER_STOP ) ) ; enc28j60WriteReg ( interface , ENC28J60_REG_ERXRDPTH , MSB ( ENC28J60_RX_BUFFER_STOP ) ) ; enc28j60WriteReg ( interface , ENC28J60_REG_ERXFCON , ERXFCON_UCEN | ERXFCON_CRCEN | ERXFCON_HTEN | ERXFCON_BCEN ) ; enc28j60WriteReg ( interface , ENC28J60_REG_EHT0 , 0x00 ) ; enc28j60WriteReg ( interface , ENC28J60_REG_EHT1 , 0x00 ) ; enc28j60WriteReg ( interface , ENC28J60_REG_EHT2 , 0x00 ) ; enc28j60WriteReg ( interface , ENC28J60_REG_EHT3 , 0x00 ) ; enc28j60WriteReg ( interface , ENC28J60_REG_EHT4 , 0x00 ) ; enc28j60WriteReg ( interface , ENC28J60_REG_EHT5 , 0x00 ) ; enc28j60WriteReg ( interface , ENC28J60_REG_EHT6 , 0x00 ) ; enc28j60WriteReg ( interface , ENC28J60_REG_EHT7 , 0x00 ) ; enc28j60WriteReg ( interface , ENC28J60_REG_MACON2 , 0x00 ) ; enc28j60WriteReg ( interface , ENC28J60_REG_MACON1 , MACON1_TXPAUS | MACON1_RXPAUS | MACON1_MARXEN ) ; # if ( ENC28J60_FULL_DUPLEX_SUPPORT == ENABLED ) enc28j60WriteReg ( interface , ENC28J60_REG_MACON3 , MACON3_PADCFG ( 1 ) | MACON3_TXCRCEN | MACON3_FRMLNEN | MACON3_FULDPX ) ; # else enc28j60WriteReg ( interface , ENC28J60_REG_MACON3 , MACON3_PADCFG ( 1 ) | MACON3_TXCRCEN | MACON3_FRMLNEN ) ; # endif enc28j60WriteReg ( interface , ENC28J60_REG_MACON4 , MACON4_DEFER ) ; enc28j60WriteReg ( interface , ENC28J60_REG_MAMXFLL , LSB ( ETH_MAX_FRAME_SIZE ) ) ; enc28j60WriteReg ( interface , ENC28J60_REG_MAMXFLH , MSB ( ETH_MAX_FRAME_SIZE ) ) ; # if ( ENC28J60_FULL_DUPLEX_SUPPORT == ENABLED ) enc28j60WriteReg ( interface , ENC28J60_REG_MABBIPG , 0x15 ) ; # else enc28j60WriteReg ( interface , ENC28J60_REG_MABBIPG , 0x12 ) ; # endif enc28j60WriteReg ( interface , ENC28J60_REG_MAIPGL , 0x12 ) ; enc28j60WriteReg ( interface , ENC28J60_REG_MAIPGH , 0x0C ) ; enc28j60WriteReg ( interface , ENC28J60_REG_MACLCON2 , 63 ) ; # if ( ENC28J60_FULL_DUPLEX_SUPPORT == ENABLED ) enc28j60WritePhyReg ( interface , ENC28J60_PHY_REG_PHCON1 , PHCON1_PDPXMD ) ; # else enc28j60WritePhyReg ( interface , ENC28J60_PHY_REG_PHCON1 , 0x0000 ) ; # endif enc28j60WritePhyReg ( interface , ENC28J60_PHY_REG_PHCON2 , PHCON2_HDLDIS ) ; enc28j60WritePhyReg ( interface , ENC28J60_PHY_REG_PHLCON , PHLCON_LACFG ( 4 ) | PHLCON_LBCFG ( 7 ) | PHLCON_LFRQ ( 0 ) | PHLCON_STRCH ) ; enc28j60WriteReg ( interface , ENC28J60_REG_EIR , 0x00 ) ; enc28j60WriteReg ( interface , ENC28J60_REG_EIE , EIE_INTIE | EIE_PKTIE | EIE_LINKIE | EIE_TXIE | EIE_TXERIE ) ; enc28j60WritePhyReg ( interface , ENC28J60_PHY_REG_PHIE , PHIE_PLNKIE | PHIE_PGEIE ) ; enc28j60SetBit ( interface , ENC28J60_REG_ECON1 , ECON1_RXEN ) ; enc28j60DumpReg ( interface ) ; enc28j60DumpPhyReg ( interface ) ; osSetEvent ( & interface -> nicTxEvent ) ; interface -> nicEvent = TRUE ; osSetEvent ( & netEvent ) ; return NO_ERROR ; } "," ( interface , ENC28J60_EREVID ) ; TRACE_INFO ( interface , ENC28J60_ECOCON , ENC28J60_ECOCON_COCON_DISABLED ) ; enc28j60WriteReg ( interface , ENC28J60_MAADR5 , interface -> ( interface , ENC28J60_MAADR4 , interface -> ( interface , ENC28J60_MAADR3 , interface -> ( interface , ENC28J60_MAADR2 , interface -> ( interface , ENC28J60_MAADR1 , interface -> ( interface , ENC28J60_MAADR0 , interface -> ( interface , ENC28J60_ERXSTL , LSB ( ( interface , ENC28J60_ERXSTH , MSB ( ( interface , ENC28J60_ERXNDL , LSB ( ( interface , ENC28J60_ERXNDH , MSB ( ( interface , ENC28J60_ERXRDPTL , LSB ( ( interface , ENC28J60_ERXRDPTH , MSB ( ( interface , ENC28J60_ERXFCON , ENC28J60_ERXFCON_UCEN | ENC28J60_ERXFCON_CRCEN | ENC28J60_ERXFCON_HTEN | ENC28J60_ERXFCON_BCEN ) ; enc28j60WriteReg ( interface , ENC28J60_EHT0 , 0x00 ) ; enc28j60WriteReg ( interface , ENC28J60_EHT1 , 0x00 ) ; enc28j60WriteReg ( interface , ENC28J60_EHT2 , 0x00 ) ; enc28j60WriteReg ( interface , ENC28J60_EHT3 , 0x00 ) ; enc28j60WriteReg ( interface , ENC28J60_EHT4 , 0x00 ) ; enc28j60WriteReg ( interface , ENC28J60_EHT5 , 0x00 ) ; enc28j60WriteReg ( interface , ENC28J60_EHT6 , 0x00 ) ; enc28j60WriteReg ( interface , ENC28J60_EHT7 , 0x00 ) ; enc28j60WriteReg ( interface , ENC28J60_MACON2 , 0x00 ) ; enc28j60WriteReg ( interface , ENC28J60_MACON1 , ENC28J60_MACON1_TXPAUS | ENC28J60_MACON1_RXPAUS | ENC28J60_MACON1_MARXEN ) ; # ( interface , ENC28J60_MACON3 , ENC28J60_MACON3_PADCFG_AUTO | ENC28J60_MACON3_TXCRCEN | ENC28J60_MACON3_FRMLNEN | ENC28J60_MACON3_FULDPX ) ; # ( interface , ENC28J60_MACON3 , ENC28J60_MACON3_PADCFG_AUTO | ENC28J60_MACON3_TXCRCEN | ENC28J60_MACON3_FRMLNEN ) ; # ( interface , ENC28J60_MACON4 , ENC28J60_MACON4_DEFER ) ; enc28j60WriteReg ( interface , ENC28J60_MAMXFLL , LSB ( ( interface , ENC28J60_MAMXFLH , MSB ( ( interface , ENC28J60_MABBIPG , ENC28J60_MABBIPG_DEFAULT_FD ) ; # ( interface , ENC28J60_MABBIPG , ENC28J60_MABBIPG_DEFAULT_HD ) ; # ( interface , ENC28J60_MAIPGL , ENC28J60_MAIPGL_DEFAULT ) ; enc28j60WriteReg ( interface , ENC28J60_MAIPGH , ENC28J60_MAIPGH_DEFAULT ) ; enc28j60WriteReg ( interface , ENC28J60_MACLCON2 , ENC28J60_MACLCON2_COLWIN_DEFAULT ) ; # ( interface , ENC28J60_PHCON1 , ENC28J60_PHCON1_PDPXMD ) ; # ( interface , ENC28J60_PHCON1 , 0x0000 ) ( interface , ENC28J60_PHCON2 , ENC28J60_PHCON2_HDLDIS ) ; enc28j60WritePhyReg ( interface , ENC28J60_PHLCON , ENC28J60_PHLCON_LACFG_LINK | ENC28J60_PHLCON_LBCFG_TX_RX | ENC28J60_PHLCON_LFRQ_40_MS | ENC28J60_PHLCON_STRCH ) ; enc28j60WriteReg ( interface , ENC28J60_EIR , 0x00 ) ; enc28j60WriteReg ( interface , ENC28J60_EIE , ENC28J60_EIE_INTIE | ENC28J60_EIE_PKTIE | ENC28J60_EIE_LINKIE | ENC28J60_EIE_TXIE | ENC28J60_EIE_TXERIE ) ; enc28j60WritePhyReg ( interface , ENC28J60_PHIE , ENC28J60_PHIE_PLNKIE | ENC28J60_PHIE_PGEIE ) ; enc28j60SetBit ( interface , ENC28J60_ECON1 , ENC28J60_ECON1_RXEN ) ; enc28j60DumpReg ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 785,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%uport%uunreachable"" , 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-#%u"" , dp -> icmp_code ) ; break ; } break ; case ICMP_PARAMPROB : if ( dp -> icmp_code ) ( void ) snprintf ( buf , sizeof ( buf ) , ""parameterproblem-code%u"" , dp -> icmp_code ) ; else { ND_TCHECK ( dp -> icmp_pptr ) ; ( void ) snprintf ( buf , sizeof ( buf ) , ""parameterproblem-octet%u"" , 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 ) { if ( ND_TTEST2 ( * bp , plen ) ) { uint16_t sum ; vec [ 0 ] . ptr = ( const uint8_t * ) ( const void * ) dp ; vec [ 0 ] . len = plen ; sum = in_cksum ( vec , 1 ) ; if ( sum != 0 ) { uint16_t 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 ; ndo -> ndo_snaplen = ndo -> ndo_snapend - bp ; snapend_save = ndo -> ndo_snapend ; ND_TCHECK_16BITS ( & ip -> ip_len ) ; 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]"" ) ) ; } "," 0 ) { ND_TCHECK_16BITS ( & dp -> icmp_cksum ) ; ",the-tcpdump-group@tcpdump/1a1bce0526a77b62e41531b00f8bb5e21fd4f3a3,CVE-2018-14462,https://github.com/the-tcpdump-group/tcpdump/commit/1a1bce0526a77b62e41531b00f8bb5e21fd4f3a3,2019-10-03T16:15Z 786,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 787,CWE-20,"CWE-20 void sctp_association_free ( struct sctp_association * asoc ) { struct sock * sk = asoc -> base . sk ; struct sctp_transport * transport ; struct list_head * pos , * temp ; int i ; if ( ! asoc -> temp ) { list_del ( & asoc -> asocs ) ; if ( sctp_style ( sk , TCP ) && sctp_sstate ( sk , LISTENING ) ) sk -> sk_ack_backlog -- ; } asoc -> base . dead = true ; sctp_outq_free ( & asoc -> outqueue ) ; sctp_ulpq_free ( & asoc -> ulpq ) ; sctp_inq_free ( & asoc -> base . inqueue ) ; sctp_tsnmap_free ( & asoc -> peer . tsn_map ) ; sctp_ssnmap_free ( asoc -> ssnmap ) ; sctp_bind_addr_free ( & asoc -> base . bind_addr ) ; for ( i = SCTP_EVENT_TIMEOUT_NONE ; i < SCTP_NUM_TIMEOUT_TYPES ; ++ i ) { if ( del_timer ( & asoc -> timers [ i ] ) ) sctp_association_put ( asoc ) ; } kfree ( asoc -> peer . cookie ) ; kfree ( asoc -> peer . peer_random ) ; kfree ( asoc -> peer . peer_chunks ) ; kfree ( asoc -> peer . peer_hmacs ) ; list_for_each_safe ( pos , temp , & asoc -> peer . transport_addr_list ) { transport = list_entry ( pos , struct sctp_transport , transports ) ; list_del_rcu ( pos ) ; sctp_transport_free ( transport ) ; } asoc -> peer . transport_count = 0 ; sctp_asconf_queue_teardown ( asoc ) ; if ( asoc -> asconf_addr_del_pending != NULL ) kfree ( asoc -> asconf_addr_del_pending ) ; sctp_auth_destroy_keys ( & asoc -> endpoint_shared_keys ) ; sctp_auth_key_put ( asoc -> asoc_shared_key ) ; sctp_association_put ( asoc ) ; } "," if ( ! list_empty ( & asoc -> asocs ) ) { list_del ",torvalds@linux/d3217b15a19a4779c39b212358a5c71d725822ee,CVE-2014-4667,https://github.com/torvalds/linux/commit/d3217b15a19a4779c39b212358a5c71d725822ee,2014-07-03T04:22Z 788,CWE-000,"CWE-000 static int load_state_from_tss32 ( struct x86_emulate_ctxt * ctxt , struct tss_segment_32 * tss ) { int ret ; u8 cpl ; if ( ctxt -> ops -> set_cr ( ctxt , 3 , tss -> cr3 ) ) return emulate_gp ( ctxt , 0 ) ; ctxt -> _eip = tss -> eip ; ctxt -> eflags = tss -> eflags | 2 ; * reg_write ( ctxt , VCPU_REGS_RAX ) = tss -> eax ; * reg_write ( ctxt , VCPU_REGS_RCX ) = tss -> ecx ; * reg_write ( ctxt , VCPU_REGS_RDX ) = tss -> edx ; * reg_write ( ctxt , VCPU_REGS_RBX ) = tss -> ebx ; * reg_write ( ctxt , VCPU_REGS_RSP ) = tss -> esp ; * reg_write ( ctxt , VCPU_REGS_RBP ) = tss -> ebp ; * reg_write ( ctxt , VCPU_REGS_RSI ) = tss -> esi ; * reg_write ( ctxt , VCPU_REGS_RDI ) = tss -> edi ; set_segment_selector ( ctxt , tss -> ldt_selector , VCPU_SREG_LDTR ) ; set_segment_selector ( ctxt , tss -> es , VCPU_SREG_ES ) ; set_segment_selector ( ctxt , tss -> cs , VCPU_SREG_CS ) ; set_segment_selector ( ctxt , tss -> ss , VCPU_SREG_SS ) ; set_segment_selector ( ctxt , tss -> ds , VCPU_SREG_DS ) ; set_segment_selector ( ctxt , tss -> fs , VCPU_SREG_FS ) ; set_segment_selector ( ctxt , tss -> gs , VCPU_SREG_GS ) ; if ( ctxt -> eflags & X86_EFLAGS_VM ) { ctxt -> mode = X86EMUL_MODE_VM86 ; cpl = 3 ; } else { ctxt -> mode = X86EMUL_MODE_PROT32 ; cpl = tss -> cs & 3 ; } ret = __load_segment_descriptor ( ctxt , tss -> ldt_selector , VCPU_SREG_LDTR , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; ret = __load_segment_descriptor ( ctxt , tss -> es , VCPU_SREG_ES , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; ret = __load_segment_descriptor ( ctxt , tss -> cs , VCPU_SREG_CS , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; ret = __load_segment_descriptor ( ctxt , tss -> ss , VCPU_SREG_SS , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; ret = __load_segment_descriptor ( ctxt , tss -> ds , VCPU_SREG_DS , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; ret = __load_segment_descriptor ( ctxt , tss -> fs , VCPU_SREG_FS , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; ret = __load_segment_descriptor ( ctxt , tss -> gs , VCPU_SREG_GS , cpl , true ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; return X86EMUL_CONTINUE ; } "," , VCPU_SREG_LDTR , cpl , true , NULL ) ; if , cpl , true , NULL ) ; if , cpl , true , NULL ) ; if , cpl , true , NULL ) ; if , cpl , true , NULL ) ; if , cpl , true , NULL ) ; if , cpl , true , NULL ) ; if ",torvalds@linux/d1442d85cc30ea75f7d399474ca738e0bc96f715,CVE-2014-3647,https://github.com/torvalds/linux/commit/d1442d85cc30ea75f7d399474ca738e0bc96f715,2014-11-10T11:55Z 789,CWE-125,"CWE-125 static int dhcpv4_print ( netdissect_options * ndo , const u_char * cp , u_int length , int indent ) { u_int i , t ; const u_char * tlv , * value ; uint8_t type , optlen ; i = 0 ; while ( i < length ) { tlv = cp + i ; type = ( uint8_t ) tlv [ 0 ] ; optlen = ( uint8_t ) tlv [ 1 ] ; value = tlv + 2 ; ND_PRINT ( ( ndo , ""\\n"" ) ) ; for ( t = indent ; t > 0 ; t -- ) ND_PRINT ( ( ndo , ""\\t"" ) ) ; ND_PRINT ( ( ndo , ""%s"" , tok2str ( dh4opt_str , ""Unknown"" , type ) ) ) ; ND_PRINT ( ( ndo , ""(%u)"" , optlen + 2 ) ) ; switch ( type ) { case DH4OPT_DNS_SERVERS : case DH4OPT_NTP_SERVERS : { if ( optlen < 4 || optlen % 4 != 0 ) { return - 1 ; } for ( t = 0 ; t < optlen ; t += 4 ) ND_PRINT ( ( ndo , ""%s"" , ipaddr_string ( ndo , value + t ) ) ) ; } break ; case DH4OPT_DOMAIN_SEARCH : { const u_char * tp = value ; while ( tp < value + optlen ) { ND_PRINT ( ( ndo , """" ) ) ; if ( ( tp = ns_nprint ( ndo , tp , value + optlen ) ) == NULL ) return - 1 ; } } break ; } i += 2 + optlen ; } return 0 ; } "," length ) { if ( i + 2 > length ) return - 1 ; 2 ) ) ; if ( i + 2 + optlen > length ) return - 1 ",the-tcpdump-group@tcpdump/c2f6833dddecf2d5fb89c9c898eee9981da342ed,CVE-2017-13044,https://github.com/the-tcpdump-group/tcpdump/commit/c2f6833dddecf2d5fb89c9c898eee9981da342ed,2017-09-14T06:29Z 790,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 791,CWE-19,"CWE-19 static int ext4_xattr_block_list ( struct dentry * dentry , char * buffer , size_t buffer_size ) { struct inode * inode = d_inode ( dentry ) ; struct buffer_head * bh = NULL ; int error ; struct mb_cache * ext4_mb_cache = EXT4_GET_MB_CACHE ( inode ) ; ea_idebug ( inode , ""buffer=%p,buffer_size=%ld"" , buffer , ( long ) buffer_size ) ; error = 0 ; if ( ! EXT4_I ( inode ) -> i_file_acl ) goto cleanup ; ea_idebug ( inode , ""readingblock%llu"" , ( unsigned long long ) EXT4_I ( inode ) -> i_file_acl ) ; bh = sb_bread ( inode -> i_sb , EXT4_I ( inode ) -> i_file_acl ) ; error = - EIO ; if ( ! bh ) goto cleanup ; ea_bdebug ( bh , ""b_count=%d,refcount=%d"" , atomic_read ( & ( bh -> b_count ) ) , le32_to_cpu ( BHDR ( bh ) -> h_refcount ) ) ; if ( ext4_xattr_check_block ( inode , bh ) ) { EXT4_ERROR_INODE ( inode , ""badblock%llu"" , EXT4_I ( inode ) -> i_file_acl ) ; error = - EFSCORRUPTED ; goto cleanup ; } ext4_xattr_cache_insert ( ext4_mb_cache , bh ) ; error = ext4_xattr_list_entries ( dentry , BFIRST ( bh ) , buffer , buffer_size ) ; cleanup : brelse ( bh ) ; return error ; } "," error ; struct mb2_cache * ext4_mb_cache = ",torvalds@linux/82939d7999dfc1f1998c4b1c12e2f19edbdff272,CVE-2015-8952,https://github.com/torvalds/linux/commit/82939d7999dfc1f1998c4b1c12e2f19edbdff272,2016-10-16T21:59Z 792,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 793,CWE-125,"CWE-125 static inline signed int ReadPropertySignedLong ( const EndianType endian , const unsigned char * buffer ) { union { unsigned int unsigned_value ; signed int signed_value ; } quantum ; unsigned int value ; if ( endian == LSBEndian ) { value = ( unsigned int ) ( ( buffer [ 3 ] << 24 ) | ( buffer [ 2 ] << 16 ) | ( buffer [ 1 ] << 8 ) | ( buffer [ 0 ] ) ) ; quantum . unsigned_value = ( value & 0xffffffff ) ; return ( quantum . signed_value ) ; } value = ( unsigned int ) ( ( buffer [ 0 ] << 24 ) | ( buffer [ 1 ] << 16 ) | ( buffer [ 2 ] << 8 ) | buffer [ 3 ] ) ; quantum . unsigned_value = ( value & 0xffffffff ) ; return ( quantum . signed_value ) ; } "," unsigned int ) buffer [ 3 ] << 24 ; value |= ( unsigned int ) buffer [ 2 ] << 16 ; value |= ( unsigned int ) buffer [ 1 ] << 8 ; value |= ( unsigned int ) buffer [ 0 [ 0 ] ; quantum . . unsigned_value = value & 0xffffffff value & 0xffffffff ; return ( unsigned int ) buffer [ 0 ] << 24 ; value |= ( unsigned int ) buffer [ 1 ] << 16 ; value |= ( unsigned int ) buffer [ 2 ] << 8 ; value |= ( unsigned int ) buffer [ 3 [ 3 ] ; quantum . . unsigned_value = value & 0xffffffff value & 0xffffffff ; return ( ",ImageMagick@ImageMagick/d8ab7f046587f2e9f734b687ba7e6e10147c294b,CVE-2016-5842,https://github.com/ImageMagick/ImageMagick/commit/d8ab7f046587f2e9f734b687ba7e6e10147c294b,2016-12-13T15:59Z 794,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 795,CWE-125,"CWE-125 static int ast_type_init ( PyObject * self , PyObject * args , PyObject * kw ) { _Py_IDENTIFIER ( _fields ) ; Py_ssize_t i , numfields = 0 ; int res = - 1 ; PyObject * key , * value , * fields ; fields = _PyObject_GetAttrId ( ( PyObject * ) Py_TYPE ( self ) , & PyId__fields ) ; if ( ! fields ) PyErr_Clear ( ) ; if ( fields ) { numfields = PySequence_Size ( fields ) ; if ( numfields == - 1 ) goto cleanup ; } res = 0 ; if ( PyTuple_GET_SIZE ( args ) > 0 ) { if ( numfields != PyTuple_GET_SIZE ( args ) ) { PyErr_Format ( PyExc_TypeError , ""%.400sconstructortakes%s"" ""%zdpositionalargument%s"" , Py_TYPE ( self ) -> tp_name , numfields == 0 ? """" : ""either0or"" , numfields , numfields == 1 ? """" : ""s"" ) ; res = - 1 ; goto cleanup ; } for ( i = 0 ; i < PyTuple_GET_SIZE ( args ) ; i ++ ) { PyObject * name = PySequence_GetItem ( fields , i ) ; if ( ! name ) { res = - 1 ; goto cleanup ; } res = PyObject_SetAttr ( self , name , PyTuple_GET_ITEM ( args , i ) ) ; Py_DECREF ( name ) ; if ( res < 0 ) goto cleanup ; } } if ( kw ) { i = 0 ; while ( PyDict_Next ( kw , & i , & key , & value ) ) { res = PyObject_SetAttr ( self , key , value ) ; if ( res < 0 ) goto cleanup ; } } cleanup : Py_XDECREF ( fields ) ; return res ; } "," kw ) { Py_ssize_t i , * fields ; if ( lookup_attr_id ( ( PyObject , & PyId__fields , & fields ) < 0 ) { goto cleanup ; } if ( fields ; if ( numfields < ( args ) ) { PyErr_Format ( PyExc_TypeError , ""%.400sconstructortakesatmost"" ""%zdpositionalargument%s"" , Py_TYPE ) -> tp_name , numfields , cleanup ; } if ( kw ",python@typed_ast/156afcb26c198e162504a57caddfe0acd9ed7dce,CVE-2019-19275,https://github.com/python/typed_ast/commit/156afcb26c198e162504a57caddfe0acd9ed7dce,2019-11-26T15:15Z 796,CWE-119,"CWE-119 static void encode_frame ( vpx_codec_ctx_t * codec , vpx_image_t * img , int frame_index , VpxVideoWriter * writer ) { vpx_codec_iter_t iter = NULL ; const vpx_codec_cx_pkt_t * pkt = NULL ; const vpx_codec_err_t res = vpx_codec_encode ( codec , img , frame_index , 1 , 0 , VPX_DL_GOOD_QUALITY ) ; if ( res != VPX_CODEC_OK ) die_codec ( codec , ""Failedtoencodeframe"" ) ; while ( ( pkt = vpx_codec_get_cx_data ( codec , & iter ) ) != NULL ) { if ( pkt -> kind == VPX_CODEC_CX_FRAME_PKT ) { const int keyframe = ( pkt -> data . frame . flags & VPX_FRAME_IS_KEY ) != 0 ; if ( ! vpx_video_writer_write_frame ( writer , pkt -> data . frame . buf , pkt -> data . frame . sz , pkt -> data . frame . pts ) ) { die_codec ( codec , ""Failedtowritecompressedframe"" ) ; } printf ( keyframe ? ""K"" : ""."" ) ; fflush ( stdout ) ; } } } "," static int encode_frame ( vpx_codec_ctx_t writer ) { int got_pkts = 0 ; NULL ) { got_pkts = 1 ; ; } } return got_pkts ; ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 797,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 798,CWE-20,"CWE-20 int mpi_powm ( MPI res , MPI base , MPI exp , MPI mod ) { mpi_ptr_t mp_marker = NULL , bp_marker = NULL , ep_marker = NULL ; mpi_ptr_t xp_marker = NULL ; mpi_ptr_t tspace = NULL ; mpi_ptr_t rp , ep , mp , bp ; mpi_size_t esize , msize , bsize , rsize ; int esign , msign , bsign , rsign ; mpi_size_t size ; int mod_shift_cnt ; int negative_result ; int assign_rp = 0 ; mpi_size_t tsize = 0 ; int rc = - ENOMEM ; esize = exp -> nlimbs ; msize = mod -> nlimbs ; size = 2 * msize ; esign = exp -> sign ; msign = mod -> sign ; rp = res -> d ; ep = exp -> d ; if ( ! msize ) return - EINVAL ; if ( ! esize ) { rp [ 0 ] = 1 ; res -> nlimbs = ( msize == 1 && mod -> d [ 0 ] == 1 ) ? 0 : 1 ; res -> sign = 0 ; goto leave ; } mp = mp_marker = mpi_alloc_limb_space ( msize ) ; if ( ! mp ) goto enomem ; mod_shift_cnt = count_leading_zeros ( mod -> d [ msize - 1 ] ) ; if ( mod_shift_cnt ) mpihelp_lshift ( mp , mod -> d , msize , mod_shift_cnt ) ; else MPN_COPY ( mp , mod -> d , msize ) ; bsize = base -> nlimbs ; bsign = base -> sign ; if ( bsize > msize ) { bp = bp_marker = mpi_alloc_limb_space ( bsize + 1 ) ; if ( ! bp ) goto enomem ; MPN_COPY ( bp , base -> d , bsize ) ; mpihelp_divrem ( bp + msize , 0 , bp , bsize , mp , msize ) ; bsize = msize ; MPN_NORMALIZE ( bp , bsize ) ; } else bp = base -> d ; if ( ! bsize ) { res -> nlimbs = 0 ; res -> sign = 0 ; goto leave ; } if ( res -> alloced < size ) { if ( rp == ep || rp == mp || rp == bp ) { rp = mpi_alloc_limb_space ( size ) ; if ( ! rp ) goto enomem ; assign_rp = 1 ; } else { if ( mpi_resize ( res , size ) < 0 ) goto enomem ; rp = res -> d ; } } else { if ( rp == bp ) { BUG_ON ( bp_marker ) ; bp = bp_marker = mpi_alloc_limb_space ( bsize ) ; if ( ! bp ) goto enomem ; MPN_COPY ( bp , rp , bsize ) ; } if ( rp == ep ) { ep = ep_marker = mpi_alloc_limb_space ( esize ) ; if ( ! ep ) goto enomem ; MPN_COPY ( ep , rp , esize ) ; } if ( rp == mp ) { BUG_ON ( mp_marker ) ; mp = mp_marker = mpi_alloc_limb_space ( msize ) ; if ( ! mp ) goto enomem ; MPN_COPY ( mp , rp , msize ) ; } } MPN_COPY ( rp , bp , bsize ) ; rsize = bsize ; rsign = bsign ; { mpi_size_t i ; mpi_ptr_t xp ; int c ; mpi_limb_t e ; mpi_limb_t carry_limb ; struct karatsuba_ctx karactx ; xp = xp_marker = mpi_alloc_limb_space ( 2 * ( msize + 1 ) ) ; if ( ! xp ) goto enomem ; memset ( & karactx , 0 , sizeof karactx ) ; negative_result = ( ep [ 0 ] & 1 ) && base -> sign ; i = esize - 1 ; e = ep [ i ] ; c = count_leading_zeros ( e ) ; e = ( e << c ) << 1 ; c = BITS_PER_MPI_LIMB - 1 - c ; for ( ; ; ) { while ( c ) { mpi_ptr_t tp ; mpi_size_t xsize ; if ( rsize < KARATSUBA_THRESHOLD ) mpih_sqr_n_basecase ( xp , rp , rsize ) ; else { if ( ! tspace ) { tsize = 2 * rsize ; tspace = mpi_alloc_limb_space ( tsize ) ; if ( ! tspace ) goto enomem ; } else if ( tsize < ( 2 * rsize ) ) { mpi_free_limb_space ( tspace ) ; tsize = 2 * rsize ; tspace = mpi_alloc_limb_space ( tsize ) ; if ( ! tspace ) goto enomem ; } mpih_sqr_n ( xp , rp , rsize , tspace ) ; } xsize = 2 * rsize ; if ( xsize > msize ) { mpihelp_divrem ( xp + msize , 0 , xp , xsize , mp , msize ) ; xsize = msize ; } tp = rp ; rp = xp ; xp = tp ; rsize = xsize ; if ( ( mpi_limb_signed_t ) e < 0 ) { if ( bsize < KARATSUBA_THRESHOLD ) { mpi_limb_t tmp ; if ( mpihelp_mul ( xp , rp , rsize , bp , bsize , & tmp ) < 0 ) goto enomem ; } else { if ( mpihelp_mul_karatsuba_case ( xp , rp , rsize , bp , bsize , & karactx ) < 0 ) goto enomem ; } xsize = rsize + bsize ; if ( xsize > msize ) { mpihelp_divrem ( xp + msize , 0 , xp , xsize , mp , msize ) ; xsize = msize ; } tp = rp ; rp = xp ; xp = tp ; rsize = xsize ; } e <<= 1 ; c -- ; } i -- ; if ( i < 0 ) break ; e = ep [ i ] ; c = BITS_PER_MPI_LIMB ; } if ( mod_shift_cnt ) { carry_limb = mpihelp_lshift ( res -> d , rp , rsize , mod_shift_cnt ) ; rp = res -> d ; if ( carry_limb ) { rp [ rsize ] = carry_limb ; rsize ++ ; } } else { MPN_COPY ( res -> d , rp , rsize ) ; rp = res -> d ; } if ( rsize >= msize ) { mpihelp_divrem ( rp + msize , 0 , rp , rsize , mp , msize ) ; rsize = msize ; } if ( mod_shift_cnt ) mpihelp_rshift ( rp , rp , rsize , mod_shift_cnt ) ; MPN_NORMALIZE ( rp , rsize ) ; mpihelp_release_karatsuba_ctx ( & karactx ) ; } if ( negative_result && rsize ) { if ( mod_shift_cnt ) mpihelp_rshift ( mp , mp , msize , mod_shift_cnt ) ; mpihelp_sub ( rp , mp , msize , rp , rsize ) ; rsize = msize ; rsign = msign ; MPN_NORMALIZE ( rp , rsize ) ; } res -> nlimbs = rsize ; res -> sign = rsign ; leave : rc = 0 ; enomem : if ( assign_rp ) mpi_assign_limb_space ( res , rp , size ) ; if ( mp_marker ) mpi_free_limb_space ( mp_marker ) ; if ( bp_marker ) mpi_free_limb_space ( bp_marker ) ; if ( ep_marker ) mpi_free_limb_space ( ep_marker ) ; if ( xp_marker ) mpi_free_limb_space ( xp_marker ) ; if ( tspace ) mpi_free_limb_space ( tspace ) ; return rc ; } "," esize ) { res -> nlimbs : 1 ; if ( res -> nlimbs ) { if ( mpi_resize ( res , 1 ) < 0 ) goto enomem ; rp = res -> d ; rp [ 0 ] = 1 ; } ",torvalds@linux/f5527fffff3f002b0a6b376163613b82f69de073,CVE-2016-8650,https://github.com/torvalds/linux/commit/f5527fffff3f002b0a6b376163613b82f69de073,2016-11-28T03:59Z 799,CWE-119,"CWE-119 int DecodeTime ( char * str , int * tmask , struct tm * tm , fsec_t * fsec ) { char * cp ; * tmask = DTK_TIME_M ; tm -> tm_hour = strtol ( str , & cp , 10 ) ; if ( * cp != ':' ) return - 1 ; str = cp + 1 ; tm -> tm_min = strtol ( str , & cp , 10 ) ; if ( * cp == '\\0' ) { tm -> tm_sec = 0 ; * fsec = 0 ; } else if ( * cp != ':' ) return - 1 ; else { str = cp + 1 ; tm -> tm_sec = strtol ( str , & cp , 10 ) ; if ( * cp == '\\0' ) * fsec = 0 ; else if ( * cp == '.' ) { # ifdef HAVE_INT64_TIMESTAMP char fstr [ MAXDATELEN + 1 ] ; strncpy ( fstr , ( cp + 1 ) , 7 ) ; strcpy ( fstr + strlen ( fstr ) , ""000000"" ) ; * ( fstr + 6 ) = '\\0' ; * fsec = strtol ( fstr , & cp , 10 ) ; # else str = cp ; * fsec = strtod ( str , & cp ) ; # endif if ( * cp != '\\0' ) return - 1 ; } else return - 1 ; } # ifdef HAVE_INT64_TIMESTAMP if ( tm -> tm_hour < 0 || tm -> tm_min < 0 || tm -> tm_min > 59 || tm -> tm_sec < 0 || tm -> tm_sec > 59 || * fsec >= USECS_PER_SEC ) return - 1 ; # else if ( tm -> tm_hour < 0 || tm -> tm_min < 0 || tm -> tm_min > 59 || tm -> tm_sec < 0 || tm -> tm_sec > 59 || * fsec >= 1 ) return - 1 ; # endif return 0 ; } "," char fstr [ 7 ] ; int i ; cp ++ ; for ( i = 0 ; i < 6 ; i ++ ) fstr [ i ] = * cp != '\\0' ? * cp ++ : '0' ; fstr [ i ] = '\\0' ; ",postgres@postgres/4318daecc959886d001a6e79c6ea853e8b1dfb4b,CVE-2014-0063,https://github.com/postgres/postgres/commit/4318daecc959886d001a6e79c6ea853e8b1dfb4b,2014-03-31T14:58Z 800,CWE-264,"CWE-264 static int em_ret ( struct x86_emulate_ctxt * ctxt ) { ctxt -> dst . type = OP_REG ; ctxt -> dst . addr . reg = & ctxt -> _eip ; ctxt -> dst . bytes = ctxt -> op_bytes ; return em_pop ( ctxt ) ; } "," ctxt ) { int rc ; unsigned long eip ; rc = emulate_pop ( ctxt , & eip , ctxt -> op_bytes ctxt -> op_bytes ) ; if ( rc != X86EMUL_CONTINUE ) return rc ; return assign_eip_near ( ctxt , eip ) ; } ",torvalds@linux/234f3ce485d54017f15cf5e0699cff4100121601,CVE-2014-3647,https://github.com/torvalds/linux/commit/234f3ce485d54017f15cf5e0699cff4100121601,2014-11-10T11:55Z 801,CWE-88,"CWE-88 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 ) ; 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 ) ; free ( name ) ; return 0 ; } "," value ) ; if ( ! strcmp ( key , ""path"" ) && value && looks_like_command_line_option ( value ) ) data -> ret |= report ( data -> options , data -> obj , FSCK_MSG_GITMODULES_PATH , ""disallowedsubmodulepath:%s"" , value ) ; ",git@git/1a7fd1fb2998002da6e9ff2ee46e1bdd25ee8404,CVE-2018-17456,https://github.com/git/git/commit/1a7fd1fb2998002da6e9ff2ee46e1bdd25ee8404,2018-10-06T14:29Z 802,CWE-190,"CWE-190 SQLITE_PRIVATE ExprList * sqlite3ExprListAppend ( Parse * pParse , ExprList * pList , Expr * pExpr ) { struct ExprList_item * pItem ; sqlite3 * db = pParse -> db ; assert ( db != 0 ) ; if ( pList == 0 ) { pList = sqlite3DbMallocRawNN ( db , sizeof ( ExprList ) ) ; if ( pList == 0 ) { goto no_mem ; } pList -> nExpr = 0 ; } else if ( ( pList -> nExpr & ( pList -> nExpr - 1 ) ) == 0 ) { ExprList * pNew ; pNew = sqlite3DbRealloc ( db , pList , sizeof ( * pList ) + ( 2 * pList -> nExpr - 1 ) * sizeof ( pList -> a [ 0 ] ) ) ; if ( pNew == 0 ) { goto no_mem ; } pList = pNew ; } pItem = & pList -> a [ pList -> nExpr ++ ] ; assert ( offsetof ( struct ExprList_item , zName ) == sizeof ( pItem -> pExpr ) ) ; assert ( offsetof ( struct ExprList_item , pExpr ) == 0 ) ; memset ( & pItem -> zName , 0 , sizeof ( * pItem ) - offsetof ( struct ExprList_item , zName ) ) ; pItem -> pExpr = pExpr ; return pList ; no_mem : sqlite3ExprDelete ( db , pExpr ) ; sqlite3ExprListDelete ( db , pList ) ; return 0 ; } "," ( 2 * ( sqlite3_int64 ) ",chromium@chromium/517ac71c9ee27f856f9becde8abea7d1604af9d4,CVE-2019-5827,https://github.com/chromium/chromium/commit/517ac71c9ee27f856f9becde8abea7d1604af9d4,2019-06-27T17:15Z 803,CWE-119,"CWE-119 static int rd_pick_intra4x4mby_modes ( MACROBLOCK * mb , int * Rate , int * rate_y , int * Distortion , int best_rd ) { MACROBLOCKD * const xd = & mb -> e_mbd ; int i ; int cost = mb -> mbmode_cost [ xd -> frame_type ] [ B_PRED ] ; int distortion = 0 ; int tot_rate_y = 0 ; int64_t total_rd = 0 ; ENTROPY_CONTEXT_PLANES t_above , t_left ; ENTROPY_CONTEXT * ta ; ENTROPY_CONTEXT * tl ; const int * bmode_costs ; vpx_memcpy ( & t_above , mb -> e_mbd . above_context , sizeof ( ENTROPY_CONTEXT_PLANES ) ) ; vpx_memcpy ( & t_left , mb -> e_mbd . left_context , sizeof ( ENTROPY_CONTEXT_PLANES ) ) ; ta = ( ENTROPY_CONTEXT * ) & t_above ; tl = ( ENTROPY_CONTEXT * ) & t_left ; intra_prediction_down_copy ( xd , xd -> dst . y_buffer - xd -> dst . y_stride + 16 ) ; bmode_costs = mb -> inter_bmode_costs ; for ( i = 0 ; i < 16 ; i ++ ) { MODE_INFO * const mic = xd -> mode_info_context ; const int mis = xd -> mode_info_stride ; B_PREDICTION_MODE UNINITIALIZED_IS_SAFE ( best_mode ) ; int UNINITIALIZED_IS_SAFE ( r ) , UNINITIALIZED_IS_SAFE ( ry ) , UNINITIALIZED_IS_SAFE ( d ) ; if ( mb -> e_mbd . frame_type == KEY_FRAME ) { const B_PREDICTION_MODE A = above_block_mode ( mic , i , mis ) ; const B_PREDICTION_MODE L = left_block_mode ( mic , i ) ; bmode_costs = mb -> bmode_costs [ A ] [ L ] ; } total_rd += rd_pick_intra4x4block ( mb , mb -> block + i , xd -> block + i , & best_mode , bmode_costs , ta + vp8_block2above [ i ] , tl + vp8_block2left [ i ] , & r , & ry , & d ) ; cost += r ; distortion += d ; tot_rate_y += ry ; mic -> bmi [ i ] . as_mode = best_mode ; if ( total_rd >= ( int64_t ) best_rd ) break ; } if ( total_rd >= ( int64_t ) best_rd ) return INT_MAX ; * Rate = cost ; * rate_y = tot_rate_y ; * Distortion = distortion ; return RDCOST ( mb -> rdmult , mb -> rddiv , cost , distortion ) ; } "," * bmode_costs ; memcpy ( & t_above ) ) ; memcpy ( & t_left ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 804,CWE-416,"CWE-416 static struct ucma_multicast * ucma_alloc_multicast ( struct ucma_context * ctx ) { struct ucma_multicast * mc ; mc = kzalloc ( sizeof ( * mc ) , GFP_KERNEL ) ; if ( ! mc ) return NULL ; mutex_lock ( & mut ) ; mc -> id = idr_alloc ( & multicast_idr , mc , 0 , 0 , GFP_KERNEL ) ; mutex_unlock ( & mut ) ; if ( mc -> id < 0 ) goto error ; mc -> ctx = ctx ; list_add_tail ( & mc -> list , & ctx -> mc_list ) ; return mc ; error : kfree ( mc ) ; return NULL ; } "," & multicast_idr , NULL , 0 , ",torvalds@linux/cb2595c1393b4a5211534e6f0a0fbad369e21ad8,CVE-2018-14734,https://github.com/torvalds/linux/commit/cb2595c1393b4a5211534e6f0a0fbad369e21ad8,2018-07-29T23:29Z 805,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 806,CWE-000,"CWE-000 static void nfs4_close_done ( struct rpc_task * task , void * data ) { struct nfs4_closedata * calldata = data ; struct nfs4_state * state = calldata -> state ; struct nfs_server * server = NFS_SERVER ( calldata -> inode ) ; if ( RPC_ASSASSINATED ( task ) ) return ; switch ( task -> tk_status ) { case 0 : nfs_set_open_stateid ( state , & calldata -> res . stateid , 0 ) ; renew_lease ( server , calldata -> timestamp ) ; break ; case - NFS4ERR_STALE_STATEID : case - NFS4ERR_OLD_STATEID : case - NFS4ERR_BAD_STATEID : case - NFS4ERR_EXPIRED : if ( calldata -> arg . open_flags == 0 ) break ; default : if ( nfs4_async_handle_error ( task , server , state ) == - EAGAIN ) { rpc_restart_call ( task ) ; return ; } } nfs_refresh_inode ( calldata -> inode , calldata -> res . fattr ) ; } "," -> arg . fmode == 0 ) ",torvalds@linux/dc0b027dfadfcb8a5504f7d8052754bf8d501ab9,CVE-2011-4324,https://github.com/torvalds/linux/commit/dc0b027dfadfcb8a5504f7d8052754bf8d501ab9,2012-06-21T23:55Z 807,CWE-119,"CWE-119 void vp9_cond_prob_diff_update ( vp9_writer * w , vp9_prob * oldp , const unsigned int ct [ 2 ] ) { const vp9_prob upd = DIFF_UPDATE_PROB ; vp9_prob newp = get_binary_prob ( ct [ 0 ] , ct [ 1 ] ) ; const int savings = vp9_prob_diff_update_savings_search ( ct , * oldp , & newp , upd ) ; assert ( newp >= 1 ) ; if ( savings > 0 ) { vp9_write ( w , 1 , upd ) ; vp9_write_prob_diff_update ( w , newp , * oldp ) ; * oldp = newp ; } else { vp9_write ( w , 0 , upd ) ; } } "," void vp9_cond_prob_diff_update ( vpx_writer * w , * w , vpx_prob * oldp , ) { const vpx_prob upd = DIFF_UPDATE_PROB = DIFF_UPDATE_PROB ; vpx_prob newp = get_binary_prob 0 ) { vpx_write ( w , } else { vpx_write ( w , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 808,CWE-326,"CWE-326 __be32 ipv6_proxy_select_ident ( struct net * net , struct sk_buff * skb ) { static u32 ip6_proxy_idents_hashrnd __read_mostly ; struct in6_addr buf [ 2 ] ; struct in6_addr * addrs ; u32 id ; addrs = skb_header_pointer ( skb , skb_network_offset ( skb ) + offsetof ( struct ipv6hdr , saddr ) , sizeof ( buf ) , buf ) ; if ( ! addrs ) return 0 ; net_get_random_once ( & ip6_proxy_idents_hashrnd , sizeof ( ip6_proxy_idents_hashrnd ) ) ; id = __ipv6_select_ident ( net , ip6_proxy_idents_hashrnd , & addrs [ 1 ] , & addrs [ 0 ] ) ; return htonl ( id ) ; } "," skb ) { struct in6_addr buf return 0 ; id = __ipv6_select_ident ( net , & addrs [ ",torvalds@linux/df453700e8d81b1bdafdf684365ee2b9431fb702,CVE-2019-10638,https://github.com/torvalds/linux/commit/df453700e8d81b1bdafdf684365ee2b9431fb702,2019-07-05T23:15Z 809,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 810,CWE-264,"CWE-264 const char * string_of_NPPVariable ( int variable ) { const char * str ; switch ( variable ) { # define _ ( VAL ) case VAL : str = # VAL ; break ; _ ( NPPVpluginNameString ) ; _ ( NPPVpluginDescriptionString ) ; _ ( NPPVpluginWindowBool ) ; _ ( NPPVpluginTransparentBool ) ; _ ( NPPVjavaClass ) ; _ ( NPPVpluginWindowSize ) ; _ ( NPPVpluginTimerInterval ) ; _ ( NPPVpluginScriptableInstance ) ; _ ( NPPVpluginScriptableIID ) ; _ ( NPPVjavascriptPushCallerBool ) ; _ ( NPPVpluginKeepLibraryInMemory ) ; _ ( NPPVpluginNeedsXEmbed ) ; _ ( NPPVpluginScriptableNPObject ) ; _ ( NPPVformValue ) ; # undef _ default : switch ( variable & 0xff ) { # define _ ( VAL , VAR ) case VAL : str = # VAR ; break _ ( 10 , NPPVpluginScriptableInstance ) ; # undef _ default : str = ""variable>"" ; break ; } break ; } return str ; } "," NPPVformValue ) ; _ ( NPPVpluginUrlRequestsDisplayedBool ) ; _ ( NPPVpluginWantsAllNetworkStreams ) ; _ ( NPPVpluginNativeAccessibleAtkPlugId ) ; _ ( NPPVpluginCancelSrcStream ) ; _ ( NPPVSupportsAdvancedKeyHandling ) ; ",davidben@nspluginwrapper/7e4ab8e1189846041f955e6c83f72bc1624e7a98,CVE-2011-2486,https://github.com/davidben/nspluginwrapper/commit/7e4ab8e1189846041f955e6c83f72bc1624e7a98,2012-11-19T12:10Z 811,CWE-119,"CWE-119 static MV_REFERENCE_FRAME get_frame_type ( const VP9_COMP * cpi ) { if ( frame_is_intra_only ( & cpi -> common ) ) return INTRA_FRAME ; else if ( cpi -> rc . is_src_frame_alt_ref && cpi -> refresh_golden_frame ) return ALTREF_FRAME ; else if ( cpi -> refresh_golden_frame || cpi -> refresh_alt_ref_frame ) return LAST_FRAME ; else return GOLDEN_FRAME ; } "," refresh_alt_ref_frame ) return GOLDEN_FRAME ; else return ; else return LAST_FRAME ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 812,CWE-134,"CWE-134 static void zend_throw_or_error ( int fetch_type , zend_class_entry * exception_ce , const char * format , ... ) { va_list va ; char * message = NULL ; va_start ( va , format ) ; zend_vspprintf ( & message , 0 , format , va ) ; if ( fetch_type & ZEND_FETCH_CLASS_EXCEPTION ) { zend_throw_error ( exception_ce , message ) ; } else { zend_error ( E_ERROR , ""%s"" , message ) ; } efree ( message ) ; va_end ( va ) ; } "," ( exception_ce , ""%s"" , ",php@php-src/b101a6bbd4f2181c360bd38e7683df4a03cba83e,CVE-2015-8617,https://github.com/php/php-src/commit/b101a6bbd4f2181c360bd38e7683df4a03cba83e,2016-01-19T05:59Z 813,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 814,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 815,CWE-125,"CWE-125 PHPAPI int php_var_unserialize ( UNSERIALIZE_PARAMETER ) { const unsigned char * cursor , * limit , * marker , * start ; zval * * rval_ref ; limit = max ; cursor = * p ; if ( YYCURSOR >= YYLIMIT ) { return 0 ; } if ( var_hash && cursor [ 0 ] != 'R' ) { var_push ( var_hash , rval ) ; } start = cursor ; # line 496 ""ext/standard/var_unserializer.c"" { YYCTYPE yych ; static const unsigned char yybm [ ] = { 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 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 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 , 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 , 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 , 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 , 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 , 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 , 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 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , } ; if ( ( YYLIMIT - YYCURSOR ) < 7 ) YYFILL ( 7 ) ; yych = * YYCURSOR ; switch ( yych ) { case 'C' : case 'O' : goto yy13 ; case 'N' : goto yy5 ; case 'R' : goto yy2 ; case 'S' : goto yy10 ; case 'a' : goto yy11 ; case 'b' : goto yy6 ; case 'd' : goto yy8 ; case 'i' : goto yy7 ; case 'o' : goto yy12 ; case 'r' : goto yy4 ; case 's' : goto yy9 ; case '}' : goto yy14 ; default : goto yy16 ; } yy2 : yych = * ( YYMARKER = ++ YYCURSOR ) ; if ( yych == ':' ) goto yy95 ; yy3 : # line 861 ""ext/standard/var_unserializer.re"" { return 0 ; } # line 558 ""ext/standard/var_unserializer.c"" yy4 : yych = * ( YYMARKER = ++ YYCURSOR ) ; if ( yych == ':' ) goto yy89 ; goto yy3 ; yy5 : yych = * ++ YYCURSOR ; if ( yych == ';' ) goto yy87 ; goto yy3 ; yy6 : yych = * ( YYMARKER = ++ YYCURSOR ) ; if ( yych == ':' ) goto yy83 ; goto yy3 ; yy7 : yych = * ( YYMARKER = ++ YYCURSOR ) ; if ( yych == ':' ) goto yy77 ; goto yy3 ; yy8 : yych = * ( YYMARKER = ++ YYCURSOR ) ; if ( yych == ':' ) goto yy53 ; goto yy3 ; yy9 : yych = * ( YYMARKER = ++ YYCURSOR ) ; if ( yych == ':' ) goto yy46 ; goto yy3 ; yy10 : yych = * ( YYMARKER = ++ YYCURSOR ) ; if ( yych == ':' ) goto yy39 ; goto yy3 ; yy11 : yych = * ( YYMARKER = ++ YYCURSOR ) ; if ( yych == ':' ) goto yy32 ; goto yy3 ; yy12 : yych = * ( YYMARKER = ++ YYCURSOR ) ; if ( yych == ':' ) goto yy25 ; goto yy3 ; yy13 : yych = * ( YYMARKER = ++ YYCURSOR ) ; if ( yych == ':' ) goto yy17 ; goto yy3 ; yy14 : ++ YYCURSOR ; # line 855 ""ext/standard/var_unserializer.re"" { php_error_docref ( NULL TSRMLS_CC , E_NOTICE , ""Unexpectedendofserializeddata"" ) ; return 0 ; } # line 607 ""ext/standard/var_unserializer.c"" yy16 : yych = * ++ YYCURSOR ; goto yy3 ; yy17 : yych = * ++ YYCURSOR ; if ( yybm [ 0 + yych ] & 128 ) { goto yy20 ; } if ( yych == '+' ) goto yy19 ; yy18 : YYCURSOR = YYMARKER ; goto yy3 ; yy19 : yych = * ++ YYCURSOR ; if ( yybm [ 0 + yych ] & 128 ) { goto yy20 ; } goto yy18 ; yy20 : ++ YYCURSOR ; if ( ( YYLIMIT - YYCURSOR ) < 2 ) YYFILL ( 2 ) ; yych = * YYCURSOR ; if ( yybm [ 0 + yych ] & 128 ) { goto yy20 ; } if ( yych <= '/' ) goto yy18 ; if ( yych >= ';' ) goto yy18 ; yych = * ++ YYCURSOR ; if ( yych != \'""\' ) goto yy18 ; ++ YYCURSOR ; # line 708 ""ext/standard/var_unserializer.re"" { size_t len , len2 , len3 , maxlen ; long elements ; char * class_name ; zend_class_entry * ce ; zend_class_entry * * pce ; int incomplete_class = 0 ; int custom_object = 0 ; zval * user_func ; zval * retval_ptr ; zval * * args [ 1 ] ; zval * arg_func_name ; if ( ! var_hash ) return 0 ; if ( * start == 'C' ) { custom_object = 1 ; } INIT_PZVAL ( * rval ) ; len2 = len = parse_uiv ( start + 2 ) ; maxlen = max - YYCURSOR ; if ( maxlen < len || len == 0 ) { * p = start + 2 ; return 0 ; } class_name = ( char * ) YYCURSOR ; YYCURSOR += len ; if ( * ( YYCURSOR ) != \'""\' ) { * p = YYCURSOR ; return 0 ; } if ( * ( YYCURSOR + 1 ) != ':' ) { * p = YYCURSOR + 1 ; return 0 ; } len3 = strspn ( class_name , ""0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\\177\\200\\201\\202\\203\\204\\205\\206\\207\\210\\211\\212\\213\\214\\215\\216\\217\\220\\221\\222\\223\\224\\225\\226\\227\\230\\231\\232\\233\\234\\235\\236\\237\\240\\241\\242\\243\\244\\245\\246\\247\\250\\251\\252\\253\\254\\255\\256\\257\\260\\261\\262\\263\\264\\265\\266\\267\\270\\271\\272\\273\\274\\275\\276\\277\\300\\301\\302\\303\\304\\305\\306\\307\\310\\311\\312\\313\\314\\315\\316\\317\\320\\321\\322\\323\\324\\325\\326\\327\\330\\331\\332\\333\\334\\335\\336\\337\\340\\341\\342\\343\\344\\345\\346\\347\\350\\351\\352\\353\\354\\355\\356\\357\\360\\361\\362\\363\\364\\365\\366\\367\\370\\371\\372\\373\\374\\375\\376\\377\\\\"" ) ; if ( len3 != len ) { * p = YYCURSOR + len3 - len ; return 0 ; } class_name = estrndup ( class_name , len ) ; do { BG ( serialize_lock ) ++ ; if ( zend_lookup_class ( class_name , len2 , & pce TSRMLS_CC ) == SUCCESS ) { BG ( serialize_lock ) -- ; if ( EG ( exception ) ) { efree ( class_name ) ; return 0 ; } ce = * pce ; break ; } BG ( serialize_lock ) -- ; if ( EG ( exception ) ) { efree ( class_name ) ; return 0 ; } if ( ( PG ( unserialize_callback_func ) == NULL ) || ( PG ( unserialize_callback_func ) [ 0 ] == '\\0' ) ) { incomplete_class = 1 ; ce = PHP_IC_ENTRY ; break ; } MAKE_STD_ZVAL ( user_func ) ; ZVAL_STRING ( user_func , PG ( unserialize_callback_func ) , 1 ) ; args [ 0 ] = & arg_func_name ; MAKE_STD_ZVAL ( arg_func_name ) ; ZVAL_STRING ( arg_func_name , class_name , 1 ) ; BG ( serialize_lock ) ++ ; if ( call_user_function_ex ( CG ( function_table ) , NULL , user_func , & retval_ptr , 1 , args , 0 , NULL TSRMLS_CC ) != SUCCESS ) { BG ( serialize_lock ) -- ; if ( EG ( exception ) ) { efree ( class_name ) ; zval_ptr_dtor ( & user_func ) ; zval_ptr_dtor ( & arg_func_name ) ; return 0 ; } php_error_docref ( NULL TSRMLS_CC , E_WARNING , ""defined(%s)butnotfound"" , user_func -> value . str . val ) ; incomplete_class = 1 ; ce = PHP_IC_ENTRY ; zval_ptr_dtor ( & user_func ) ; zval_ptr_dtor ( & arg_func_name ) ; break ; } BG ( serialize_lock ) -- ; if ( retval_ptr ) { zval_ptr_dtor ( & retval_ptr ) ; } if ( EG ( exception ) ) { efree ( class_name ) ; zval_ptr_dtor ( & user_func ) ; zval_ptr_dtor ( & arg_func_name ) ; return 0 ; } if ( zend_lookup_class ( class_name , len2 , & pce TSRMLS_CC ) == SUCCESS ) { ce = * pce ; } else { php_error_docref ( NULL TSRMLS_CC , E_WARNING , ""Function%s()hasn\'tdefinedtheclassitwascalledfor"" , user_func -> value . str . val ) ; incomplete_class = 1 ; ce = PHP_IC_ENTRY ; } zval_ptr_dtor ( & user_func ) ; zval_ptr_dtor ( & arg_func_name ) ; break ; } while ( 1 ) ; * p = YYCURSOR ; if ( custom_object ) { int ret ; ret = object_custom ( UNSERIALIZE_PASSTHRU , ce ) ; if ( ret && incomplete_class ) { php_store_class_name ( * rval , class_name , len2 ) ; } efree ( class_name ) ; return ret ; } elements = object_common1 ( UNSERIALIZE_PASSTHRU , ce ) ; if ( incomplete_class ) { php_store_class_name ( * rval , class_name , len2 ) ; } efree ( class_name ) ; return object_common2 ( UNSERIALIZE_PASSTHRU , elements ) ; } # line 785 ""ext/standard/var_unserializer.c"" yy25 : yych = * ++ YYCURSOR ; if ( yych <= ',' ) { if ( yych != '+' ) goto yy18 ; } else { if ( yych <= '-' ) goto yy26 ; if ( yych <= '/' ) goto yy18 ; if ( yych <= '9' ) goto yy27 ; goto yy18 ; } yy26 : yych = * ++ YYCURSOR ; if ( yych <= '/' ) goto yy18 ; if ( yych >= ':' ) goto yy18 ; yy27 : ++ YYCURSOR ; if ( ( YYLIMIT - YYCURSOR ) < 2 ) YYFILL ( 2 ) ; yych = * YYCURSOR ; if ( yych <= '/' ) goto yy18 ; if ( yych <= '9' ) goto yy27 ; if ( yych >= ';' ) goto yy18 ; yych = * ++ YYCURSOR ; if ( yych != \'""\' ) goto yy18 ; ++ YYCURSOR ; # line 699 ""ext/standard/var_unserializer.re"" { if ( ! var_hash ) return 0 ; INIT_PZVAL ( * rval ) ; return object_common2 ( UNSERIALIZE_PASSTHRU , object_common1 ( UNSERIALIZE_PASSTHRU , ZEND_STANDARD_CLASS_DEF_PTR ) ) ; } # line 819 ""ext/standard/var_unserializer.c"" yy32 : yych = * ++ YYCURSOR ; if ( yych == '+' ) goto yy33 ; if ( yych <= '/' ) goto yy18 ; if ( yych <= '9' ) goto yy34 ; goto yy18 ; yy33 : yych = * ++ YYCURSOR ; if ( yych <= '/' ) goto yy18 ; if ( yych >= ':' ) goto yy18 ; yy34 : ++ YYCURSOR ; if ( ( YYLIMIT - YYCURSOR ) < 2 ) YYFILL ( 2 ) ; yych = * YYCURSOR ; if ( yych <= '/' ) goto yy18 ; if ( yych <= '9' ) goto yy34 ; if ( yych >= ';' ) goto yy18 ; yych = * ++ YYCURSOR ; if ( yych != '{' ) goto yy18 ; ++ YYCURSOR ; # line 678 ""ext/standard/var_unserializer.re"" { long elements = parse_iv ( start + 2 ) ; * p = YYCURSOR ; if ( ! var_hash ) return 0 ; if ( elements < 0 ) { return 0 ; } INIT_PZVAL ( * rval ) ; array_init_size ( * rval , elements ) ; if ( ! process_nested_data ( UNSERIALIZE_PASSTHRU , Z_ARRVAL_PP ( rval ) , elements , 0 ) ) { return 0 ; } return finish_nested_data ( UNSERIALIZE_PASSTHRU ) ; } # line 861 ""ext/standard/var_unserializer.c"" yy39 : yych = * ++ YYCURSOR ; if ( yych == '+' ) goto yy40 ; if ( yych <= '/' ) goto yy18 ; if ( yych <= '9' ) goto yy41 ; goto yy18 ; yy40 : yych = * ++ YYCURSOR ; if ( yych <= '/' ) goto yy18 ; if ( yych >= ':' ) goto yy18 ; yy41 : ++ YYCURSOR ; if ( ( YYLIMIT - YYCURSOR ) < 2 ) YYFILL ( 2 ) ; yych = * YYCURSOR ; if ( yych <= '/' ) goto yy18 ; if ( yych <= '9' ) goto yy41 ; if ( yych >= ';' ) goto yy18 ; yych = * ++ YYCURSOR ; if ( yych != \'""\' ) goto yy18 ; ++ YYCURSOR ; # line 643 ""ext/standard/var_unserializer.re"" { size_t len , maxlen ; char * str ; len = parse_uiv ( start + 2 ) ; maxlen = max - YYCURSOR ; if ( maxlen < len ) { * p = start + 2 ; return 0 ; } if ( ( str = unserialize_str ( & YYCURSOR , & len , maxlen ) ) == NULL ) { return 0 ; } if ( * ( YYCURSOR ) != \'""\' ) { efree ( str ) ; * p = YYCURSOR ; return 0 ; } if ( * ( YYCURSOR + 1 ) != ';' ) { efree ( str ) ; * p = YYCURSOR + 1 ; return 0 ; } YYCURSOR += 2 ; * p = YYCURSOR ; INIT_PZVAL ( * rval ) ; ZVAL_STRINGL ( * rval , str , len , 0 ) ; return 1 ; } # line 917 ""ext/standard/var_unserializer.c"" yy46 : yych = * ++ YYCURSOR ; if ( yych == '+' ) goto yy47 ; if ( yych <= '/' ) goto yy18 ; if ( yych <= '9' ) goto yy48 ; goto yy18 ; yy47 : yych = * ++ YYCURSOR ; if ( yych <= '/' ) goto yy18 ; if ( yych >= ':' ) goto yy18 ; yy48 : ++ YYCURSOR ; if ( ( YYLIMIT - YYCURSOR ) < 2 ) YYFILL ( 2 ) ; yych = * YYCURSOR ; if ( yych <= '/' ) goto yy18 ; if ( yych <= '9' ) goto yy48 ; if ( yych >= ';' ) goto yy18 ; yych = * ++ YYCURSOR ; if ( yych != \'""\' ) goto yy18 ; ++ YYCURSOR ; # line 610 ""ext/standard/var_unserializer.re"" { size_t len , maxlen ; char * str ; len = parse_uiv ( start + 2 ) ; maxlen = max - YYCURSOR ; if ( maxlen < len ) { * p = start + 2 ; return 0 ; } str = ( char * ) YYCURSOR ; YYCURSOR += len ; if ( * ( YYCURSOR ) != \'""\' ) { * p = YYCURSOR ; return 0 ; } if ( * ( YYCURSOR + 1 ) != ';' ) { * p = YYCURSOR + 1 ; return 0 ; } YYCURSOR += 2 ; * p = YYCURSOR ; INIT_PZVAL ( * rval ) ; ZVAL_STRINGL ( * rval , str , len , 1 ) ; return 1 ; } # line 971 ""ext/standard/var_unserializer.c"" yy53 : yych = * ++ YYCURSOR ; if ( yych <= '/' ) { if ( yych <= ',' ) { if ( yych == '+' ) goto yy57 ; goto yy18 ; } else { if ( yych <= '-' ) goto yy55 ; if ( yych <= '.' ) goto yy60 ; goto yy18 ; } } else { if ( yych <= 'I' ) { if ( yych <= '9' ) goto yy58 ; if ( yych <= 'H' ) goto yy18 ; goto yy56 ; } else { if ( yych != 'N' ) goto yy18 ; } } yych = * ++ YYCURSOR ; if ( yych == 'A' ) goto yy76 ; goto yy18 ; yy55 : yych = * ++ YYCURSOR ; if ( yych <= '/' ) { if ( yych == '.' ) goto yy60 ; goto yy18 ; } else { if ( yych <= '9' ) goto yy58 ; if ( yych != 'I' ) goto yy18 ; } yy56 : yych = * ++ YYCURSOR ; if ( yych == 'N' ) goto yy72 ; goto yy18 ; yy57 : yych = * ++ YYCURSOR ; if ( yych == '.' ) goto yy60 ; if ( yych <= '/' ) goto yy18 ; if ( yych >= ':' ) goto yy18 ; yy58 : ++ YYCURSOR ; if ( ( YYLIMIT - YYCURSOR ) < 4 ) YYFILL ( 4 ) ; yych = * YYCURSOR ; if ( yych <= ':' ) { if ( yych <= '.' ) { if ( yych <= '-' ) goto yy18 ; goto yy70 ; } else { if ( yych <= '/' ) goto yy18 ; if ( yych <= '9' ) goto yy58 ; goto yy18 ; } } else { if ( yych <= 'E' ) { if ( yych <= ';' ) goto yy63 ; if ( yych <= 'D' ) goto yy18 ; goto yy65 ; } else { if ( yych == 'e' ) goto yy65 ; goto yy18 ; } } yy60 : yych = * ++ YYCURSOR ; if ( yych <= '/' ) goto yy18 ; if ( yych >= ':' ) goto yy18 ; yy61 : ++ YYCURSOR ; if ( ( YYLIMIT - YYCURSOR ) < 4 ) YYFILL ( 4 ) ; yych = * YYCURSOR ; if ( yych <= ';' ) { if ( yych <= '/' ) goto yy18 ; if ( yych <= '9' ) goto yy61 ; if ( yych <= ':' ) goto yy18 ; } else { if ( yych <= 'E' ) { if ( yych <= 'D' ) goto yy18 ; goto yy65 ; } else { if ( yych == 'e' ) goto yy65 ; goto yy18 ; } } yy63 : ++ YYCURSOR ; # line 600 ""ext/standard/var_unserializer.re"" { # if SIZEOF_LONG == 4 use_double : # endif * p = YYCURSOR ; INIT_PZVAL ( * rval ) ; ZVAL_DOUBLE ( * rval , zend_strtod ( ( const char * ) start + 2 , NULL ) ) ; return 1 ; } # line 1069 ""ext/standard/var_unserializer.c"" yy65 : yych = * ++ YYCURSOR ; if ( yych <= ',' ) { if ( yych != '+' ) goto yy18 ; } else { if ( yych <= '-' ) goto yy66 ; if ( yych <= '/' ) goto yy18 ; if ( yych <= '9' ) goto yy67 ; goto yy18 ; } yy66 : yych = * ++ YYCURSOR ; if ( yych <= ',' ) { if ( yych == '+' ) goto yy69 ; goto yy18 ; } else { if ( yych <= '-' ) goto yy69 ; if ( yych <= '/' ) goto yy18 ; if ( yych >= ':' ) goto yy18 ; } yy67 : ++ YYCURSOR ; if ( YYLIMIT <= YYCURSOR ) YYFILL ( 1 ) ; yych = * YYCURSOR ; if ( yych <= '/' ) goto yy18 ; if ( yych <= '9' ) goto yy67 ; if ( yych == ';' ) goto yy63 ; goto yy18 ; yy69 : yych = * ++ YYCURSOR ; if ( yych <= '/' ) goto yy18 ; if ( yych <= '9' ) goto yy67 ; goto yy18 ; yy70 : ++ YYCURSOR ; if ( ( YYLIMIT - YYCURSOR ) < 4 ) YYFILL ( 4 ) ; yych = * YYCURSOR ; if ( yych <= ';' ) { if ( yych <= '/' ) goto yy18 ; if ( yych <= '9' ) goto yy70 ; if ( yych <= ':' ) goto yy18 ; goto yy63 ; } else { if ( yych <= 'E' ) { if ( yych <= 'D' ) goto yy18 ; goto yy65 ; } else { if ( yych == 'e' ) goto yy65 ; goto yy18 ; } } yy72 : yych = * ++ YYCURSOR ; if ( yych != 'F' ) goto yy18 ; yy73 : yych = * ++ YYCURSOR ; if ( yych != ';' ) goto yy18 ; ++ YYCURSOR ; # line 585 ""ext/standard/var_unserializer.re"" { * p = YYCURSOR ; INIT_PZVAL ( * rval ) ; if ( ! strncmp ( start + 2 , ""NAN"" , 3 ) ) { ZVAL_DOUBLE ( * rval , php_get_nan ( ) ) ; } else if ( ! strncmp ( start + 2 , ""INF"" , 3 ) ) { ZVAL_DOUBLE ( * rval , php_get_inf ( ) ) ; } else if ( ! strncmp ( start + 2 , ""-INF"" , 4 ) ) { ZVAL_DOUBLE ( * rval , - php_get_inf ( ) ) ; } return 1 ; } # line 1143 ""ext/standard/var_unserializer.c"" yy76 : yych = * ++ YYCURSOR ; if ( yych == 'N' ) goto yy73 ; goto yy18 ; yy77 : yych = * ++ YYCURSOR ; if ( yych <= ',' ) { if ( yych != '+' ) goto yy18 ; } else { if ( yych <= '-' ) goto yy78 ; if ( yych <= '/' ) goto yy18 ; if ( yych <= '9' ) goto yy79 ; goto yy18 ; } yy78 : yych = * ++ YYCURSOR ; if ( yych <= '/' ) goto yy18 ; if ( yych >= ':' ) goto yy18 ; yy79 : ++ YYCURSOR ; if ( YYLIMIT <= YYCURSOR ) YYFILL ( 1 ) ; yych = * YYCURSOR ; if ( yych <= '/' ) goto yy18 ; if ( yych <= '9' ) goto yy79 ; if ( yych != ';' ) goto yy18 ; ++ YYCURSOR ; # line 558 ""ext/standard/var_unserializer.re"" { # if SIZEOF_LONG == 4 int digits = YYCURSOR - start - 3 ; if ( start [ 2 ] == '-' || start [ 2 ] == '+' ) { digits -- ; } if ( digits >= MAX_LENGTH_OF_LONG - 1 ) { if ( digits == MAX_LENGTH_OF_LONG - 1 ) { int cmp = strncmp ( YYCURSOR - MAX_LENGTH_OF_LONG , long_min_digits , MAX_LENGTH_OF_LONG - 1 ) ; if ( ! ( cmp < 0 || ( cmp == 0 && start [ 2 ] == '-' ) ) ) { goto use_double ; } } else { goto use_double ; } } # endif * p = YYCURSOR ; INIT_PZVAL ( * rval ) ; ZVAL_LONG ( * rval , parse_iv ( start + 2 ) ) ; return 1 ; } # line 1197 ""ext/standard/var_unserializer.c"" yy83 : yych = * ++ YYCURSOR ; if ( yych <= '/' ) goto yy18 ; if ( yych >= '2' ) goto yy18 ; yych = * ++ YYCURSOR ; if ( yych != ';' ) goto yy18 ; ++ YYCURSOR ; # line 551 ""ext/standard/var_unserializer.re"" { * p = YYCURSOR ; INIT_PZVAL ( * rval ) ; ZVAL_BOOL ( * rval , parse_iv ( start + 2 ) ) ; return 1 ; } # line 1212 ""ext/standard/var_unserializer.c"" yy87 : ++ YYCURSOR ; # line 544 ""ext/standard/var_unserializer.re"" { * p = YYCURSOR ; INIT_PZVAL ( * rval ) ; ZVAL_NULL ( * rval ) ; return 1 ; } # line 1222 ""ext/standard/var_unserializer.c"" yy89 : yych = * ++ YYCURSOR ; if ( yych <= ',' ) { if ( yych != '+' ) goto yy18 ; } else { if ( yych <= '-' ) goto yy90 ; if ( yych <= '/' ) goto yy18 ; if ( yych <= '9' ) goto yy91 ; goto yy18 ; } yy90 : yych = * ++ YYCURSOR ; if ( yych <= '/' ) goto yy18 ; if ( yych >= ':' ) goto yy18 ; yy91 : ++ YYCURSOR ; if ( YYLIMIT <= YYCURSOR ) YYFILL ( 1 ) ; yych = * YYCURSOR ; if ( yych <= '/' ) goto yy18 ; if ( yych <= '9' ) goto yy91 ; if ( yych != ';' ) goto yy18 ; ++ YYCURSOR ; # line 521 ""ext/standard/var_unserializer.re"" { long id ; * p = YYCURSOR ; if ( ! var_hash ) return 0 ; id = parse_iv ( start + 2 ) - 1 ; if ( id == - 1 || var_access ( var_hash , id , & rval_ref ) != SUCCESS ) { return 0 ; } if ( * rval == * rval_ref ) return 0 ; if ( * rval != NULL ) { var_push_dtor_no_addref ( var_hash , rval ) ; } * rval = * rval_ref ; Z_ADDREF_PP ( rval ) ; Z_UNSET_ISREF_PP ( rval ) ; return 1 ; } # line 1268 ""ext/standard/var_unserializer.c"" yy95 : yych = * ++ YYCURSOR ; if ( yych <= ',' ) { if ( yych != '+' ) goto yy18 ; } else { if ( yych <= '-' ) goto yy96 ; if ( yych <= '/' ) goto yy18 ; if ( yych <= '9' ) goto yy97 ; goto yy18 ; } yy96 : yych = * ++ YYCURSOR ; if ( yych <= '/' ) goto yy18 ; if ( yych >= ':' ) goto yy18 ; yy97 : ++ YYCURSOR ; if ( YYLIMIT <= YYCURSOR ) YYFILL ( 1 ) ; yych = * YYCURSOR ; if ( yych <= '/' ) goto yy18 ; if ( yych <= '9' ) goto yy97 ; if ( yych != ';' ) goto yy18 ; ++ YYCURSOR ; # line 500 ""ext/standard/var_unserializer.re"" { long id ; * p = YYCURSOR ; if ( ! var_hash ) return 0 ; id = parse_iv ( start + 2 ) - 1 ; if ( id == - 1 || var_access ( var_hash , id , & rval_ref ) != SUCCESS ) { return 0 ; } if ( * rval != NULL ) { var_push_dtor_no_addref ( var_hash , rval ) ; } * rval = * rval_ref ; Z_ADDREF_PP ( rval ) ; Z_SET_ISREF_PP ( rval ) ; return 1 ; } # line 1312 ""ext/standard/var_unserializer.c"" } # line 863 ""ext/standard/var_unserializer.re"" return 0 ; } "," ; # line 501 ""ext/standard/var_unserializer.c"" { YYCTYPE : # line 875 ""ext/standard/var_unserializer.re"" { return } # line 563 ""ext/standard/var_unserializer.c"" yy4 : ; # line 869 ""ext/standard/var_unserializer.re"" { php_error_docref } # line 612 ""ext/standard/var_unserializer.c"" yy16 : ; # line 717 ""ext/standard/var_unserializer.re"" { size_t ; if ( elements < 0 ) { efree ( class_name ) ; return 0 ; } if ( } # line 795 ""ext/standard/var_unserializer.c"" yy25 : ; # line 704 ""ext/standard/var_unserializer.re"" { long elements ; if ( ! rval ) ; elements = object_common1 ( UNSERIALIZE_PASSTHRU , ZEND_STANDARD_CLASS_DEF_PTR ) ; if ( elements < 0 ) { return 0 ; } ( UNSERIALIZE_PASSTHRU , elements ) ; } } # line 833 ""ext/standard/var_unserializer.c"" yy32 : ; # line 683 ""ext/standard/var_unserializer.re"" { long } # line 875 ""ext/standard/var_unserializer.c"" yy39 : ; # line 648 ""ext/standard/var_unserializer.re"" { size_t } # line 931 ""ext/standard/var_unserializer.c"" yy46 : ; # line 615 ""ext/standard/var_unserializer.re"" { size_t } # line 985 ""ext/standard/var_unserializer.c"" yy53 : ; # line 605 ""ext/standard/var_unserializer.re"" { # } # line 1083 ""ext/standard/var_unserializer.c"" yy65 : ; # line 590 ""ext/standard/var_unserializer.re"" { * } # line 1157 ""ext/standard/var_unserializer.c"" yy76 : ; # line 563 ""ext/standard/var_unserializer.re"" { # } # line 1211 ""ext/standard/var_unserializer.c"" yy83 : ; # line 556 ""ext/standard/var_unserializer.re"" { * } # line 1226 ""ext/standard/var_unserializer.c"" yy87 : ; # line 549 ""ext/standard/var_unserializer.re"" { * } # line 1236 ""ext/standard/var_unserializer.c"" yy89 : ; # line 526 ""ext/standard/var_unserializer.re"" { long } # line 1282 ""ext/standard/var_unserializer.c"" yy95 : ; # line 505 ""ext/standard/var_unserializer.re"" { long } # line 1326 ""ext/standard/var_unserializer.c"" } # } # line 877 ""ext/standard/var_unserializer.re"" return 0 ",php@php-src/16b3003ffc6393e250f069aa28a78dc5a2c064b2,CVE-2016-10161,https://github.com/php/php-src/commit/16b3003ffc6393e250f069aa28a78dc5a2c064b2,2017-01-24T21:59Z 816,CWE-787,"CWE-787 static void Np_toString ( js_State * J ) { char buf [ 32 ] ; js_Object * self = js_toobject ( J , 0 ) ; int radix = js_isundefined ( J , 1 ) ? 10 : js_tointeger ( J , 1 ) ; if ( self -> type != JS_CNUMBER ) js_typeerror ( J , ""notanumber"" ) ; if ( radix == 10 ) { js_pushstring ( J , jsV_numbertostring ( J , buf , self -> u . number ) ) ; return ; } if ( radix < 2 || radix > 36 ) js_rangeerror ( J , ""invalidradix"" ) ; { static const char digits [ ] = ""0123456789abcdefghijklmnopqrstuvwxyz"" ; char buf [ 100 ] ; double number = self -> u . number ; int sign = self -> u . number < 0 ; js_Buffer * sb = NULL ; uint64_t u , limit = ( ( uint64_t ) 1 << 52 ) ; int ndigits , exp , point ; if ( number == 0 ) { js_pushstring ( J , ""0"" ) ; return ; } if ( isnan ( number ) ) { js_pushstring ( J , ""NaN"" ) ; return ; } if ( isinf ( number ) ) { js_pushstring ( J , sign ? ""-Infinity"" : ""Infinity"" ) ; return ; } if ( sign ) number = - number ; exp = 0 ; while ( number * pow ( radix , exp ) > limit ) -- exp ; while ( number * pow ( radix , exp + 1 ) < limit ) ++ exp ; u = number * pow ( radix , exp ) + 0.5 ; while ( u > 0 && ( u % radix ) == 0 ) { u /= radix ; -- exp ; } ndigits = 0 ; while ( u > 0 ) { buf [ ndigits ++ ] = digits [ u % radix ] ; u /= radix ; } point = ndigits - exp ; if ( js_try ( J ) ) { js_free ( J , sb ) ; js_throw ( J ) ; } if ( sign ) js_putc ( J , & sb , '-' ) ; if ( point <= 0 ) { js_putc ( J , & sb , '0' ) ; js_putc ( J , & sb , '.' ) ; while ( point ++ < 0 ) js_putc ( J , & sb , '0' ) ; while ( ndigits -- > 0 ) js_putc ( J , & sb , buf [ ndigits ] ) ; } else { while ( ndigits -- > 0 ) { js_putc ( J , & sb , buf [ ndigits ] ) ; if ( -- point == 0 && ndigits > 0 ) js_putc ( J , & sb , '.' ) ; } while ( point -- > 0 ) js_putc ( J , & sb , '0' ) ; } js_putc ( J , & sb , 0 ) ; js_pushstring ( J , sb -> s ) ; js_endtry ( J ) ; js_free ( J , sb ) ; } } "," char buf [ 100 ] ; js_Object = ""0123456789abcdefghijklmnopqrstuvwxyz"" ; double number = ",ccxvii@mujs/da632ca08f240590d2dec786722ed08486ce1be6,CVE-2019-11411,https://github.com/ccxvii/mujs/commit/da632ca08f240590d2dec786722ed08486ce1be6,2019-04-22T11:29Z 817,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 818,CWE-189,"CWE-189 int lzxd_decompress ( struct lzxd_stream * lzx , off_t out_bytes ) { register unsigned int bit_buffer ; register int bits_left , i = 0 ; unsigned char * i_ptr , * i_end ; register unsigned short sym ; int match_length , length_footer , extra , verbatim_bits , bytes_todo ; int this_run , main_element , aligned_bits , j ; unsigned char * window , * runsrc , * rundest , buf [ 12 ] ; unsigned int frame_size = 0 , end_frame , match_offset , window_posn ; unsigned int R0 , R1 , R2 ; if ( ! lzx || ( out_bytes < 0 ) ) return MSPACK_ERR_ARGS ; if ( lzx -> error ) return lzx -> error ; i = lzx -> o_end - lzx -> o_ptr ; if ( ( off_t ) i > out_bytes ) i = ( int ) out_bytes ; if ( i ) { if ( lzx -> sys -> write ( lzx -> output , lzx -> o_ptr , i ) != i ) { return lzx -> error = MSPACK_ERR_WRITE ; } lzx -> o_ptr += i ; lzx -> offset += i ; out_bytes -= i ; } if ( out_bytes == 0 ) return MSPACK_ERR_OK ; RESTORE_BITS ; window = lzx -> window ; window_posn = lzx -> window_posn ; R0 = lzx -> R0 ; R1 = lzx -> R1 ; R2 = lzx -> R2 ; end_frame = ( unsigned int ) ( ( lzx -> offset + out_bytes ) / LZX_FRAME_SIZE ) + 1 ; while ( lzx -> frame < end_frame ) { if ( lzx -> reset_interval && ( ( lzx -> frame % lzx -> reset_interval ) == 0 ) ) { if ( lzx -> block_remaining ) { D ( ( ""%dbytesremainingatresetinterval"" , lzx -> block_remaining ) ) return lzx -> error = MSPACK_ERR_DECRUNCH ; } lzxd_reset_state ( lzx ) ; R0 = lzx -> R0 ; R1 = lzx -> R1 ; R2 = lzx -> R2 ; } if ( lzx -> is_delta ) { ENSURE_BITS ( 16 ) ; REMOVE_BITS ( 16 ) ; } if ( ! lzx -> header_read ) { j = 0 ; READ_BITS ( i , 1 ) ; if ( i ) { READ_BITS ( i , 16 ) ; READ_BITS ( j , 16 ) ; } lzx -> intel_filesize = ( i << 16 ) | j ; lzx -> header_read = 1 ; } frame_size = LZX_FRAME_SIZE ; if ( lzx -> length && ( lzx -> length - lzx -> offset ) < ( off_t ) frame_size ) { frame_size = lzx -> length - lzx -> offset ; } bytes_todo = lzx -> frame_posn + frame_size - window_posn ; while ( bytes_todo > 0 ) { if ( lzx -> block_remaining == 0 ) { if ( ( lzx -> block_type == LZX_BLOCKTYPE_UNCOMPRESSED ) && ( lzx -> block_length & 1 ) ) { READ_IF_NEEDED ; i_ptr ++ ; } READ_BITS ( lzx -> block_type , 3 ) ; READ_BITS ( i , 16 ) ; READ_BITS ( j , 8 ) ; lzx -> block_remaining = lzx -> block_length = ( i << 8 ) | j ; switch ( lzx -> block_type ) { case LZX_BLOCKTYPE_ALIGNED : for ( i = 0 ; i < 8 ; i ++ ) { READ_BITS ( j , 3 ) ; lzx -> ALIGNED_len [ i ] = j ; } BUILD_TABLE ( ALIGNED ) ; case LZX_BLOCKTYPE_VERBATIM : READ_LENGTHS ( MAINTREE , 0 , 256 ) ; READ_LENGTHS ( MAINTREE , 256 , LZX_NUM_CHARS + lzx -> num_offsets ) ; BUILD_TABLE ( MAINTREE ) ; if ( lzx -> MAINTREE_len [ 0xE8 ] != 0 ) lzx -> intel_started = 1 ; READ_LENGTHS ( LENGTH , 0 , LZX_NUM_SECONDARY_LENGTHS ) ; BUILD_TABLE_MAYBE_EMPTY ( LENGTH ) ; break ; case LZX_BLOCKTYPE_UNCOMPRESSED : lzx -> intel_started = 1 ; ENSURE_BITS ( 16 ) ; if ( bits_left > 16 ) i_ptr -= 2 ; bits_left = 0 ; bit_buffer = 0 ; for ( rundest = & buf [ 0 ] , i = 0 ; i < 12 ; i ++ ) { READ_IF_NEEDED ; * rundest ++ = * i_ptr ++ ; } R0 = buf [ 0 ] | ( buf [ 1 ] << 8 ) | ( buf [ 2 ] << 16 ) | ( buf [ 3 ] << 24 ) ; R1 = buf [ 4 ] | ( buf [ 5 ] << 8 ) | ( buf [ 6 ] << 16 ) | ( buf [ 7 ] << 24 ) ; R2 = buf [ 8 ] | ( buf [ 9 ] << 8 ) | ( buf [ 10 ] << 16 ) | ( buf [ 11 ] << 24 ) ; break ; default : D ( ( ""badblocktype"" ) ) return lzx -> error = MSPACK_ERR_DECRUNCH ; } } this_run = lzx -> block_remaining ; if ( this_run > bytes_todo ) this_run = bytes_todo ; bytes_todo -= this_run ; lzx -> block_remaining -= this_run ; switch ( lzx -> block_type ) { case LZX_BLOCKTYPE_VERBATIM : while ( this_run > 0 ) { READ_HUFFSYM ( MAINTREE , main_element ) ; if ( main_element < LZX_NUM_CHARS ) { window [ window_posn ++ ] = main_element ; this_run -- ; } else { main_element -= LZX_NUM_CHARS ; match_length = main_element & LZX_NUM_PRIMARY_LENGTHS ; if ( match_length == LZX_NUM_PRIMARY_LENGTHS ) { if ( lzx -> LENGTH_empty ) { D ( ( ""LENGTHsymbolneededbuttreeisempty"" ) ) return lzx -> error = MSPACK_ERR_DECRUNCH ; } READ_HUFFSYM ( LENGTH , length_footer ) ; match_length += length_footer ; } match_length += LZX_MIN_MATCH ; switch ( ( match_offset = ( main_element >> 3 ) ) ) { case 0 : match_offset = R0 ; break ; case 1 : match_offset = R1 ; R1 = R0 ; R0 = match_offset ; break ; case 2 : match_offset = R2 ; R2 = R0 ; R0 = match_offset ; break ; case 3 : match_offset = 1 ; R2 = R1 ; R1 = R0 ; R0 = match_offset ; break ; default : extra = ( match_offset >= 36 ) ? 17 : extra_bits [ match_offset ] ; READ_BITS ( verbatim_bits , extra ) ; match_offset = position_base [ match_offset ] - 2 + verbatim_bits ; R2 = R1 ; R1 = R0 ; R0 = match_offset ; } if ( match_length == LZX_MAX_MATCH && lzx -> is_delta ) { int extra_len = 0 ; ENSURE_BITS ( 3 ) ; if ( PEEK_BITS ( 1 ) == 0 ) { REMOVE_BITS ( 1 ) ; READ_BITS ( extra_len , 8 ) ; } else if ( PEEK_BITS ( 2 ) == 2 ) { REMOVE_BITS ( 2 ) ; READ_BITS ( extra_len , 10 ) ; extra_len += 0x100 ; } else if ( PEEK_BITS ( 3 ) == 6 ) { REMOVE_BITS ( 3 ) ; READ_BITS ( extra_len , 12 ) ; extra_len += 0x500 ; } else { REMOVE_BITS ( 3 ) ; READ_BITS ( extra_len , 15 ) ; } match_length += extra_len ; } if ( ( window_posn + match_length ) > lzx -> window_size ) { D ( ( ""matchranoverwindowwrap"" ) ) return lzx -> error = MSPACK_ERR_DECRUNCH ; } rundest = & window [ window_posn ] ; i = match_length ; if ( match_offset > window_posn ) { if ( match_offset > lzx -> offset && ( match_offset - window_posn ) > lzx -> ref_data_size ) { D ( ( ""matchoffsetbeyondLZXstream"" ) ) return lzx -> error = MSPACK_ERR_DECRUNCH ; } j = match_offset - window_posn ; if ( j > ( int ) lzx -> window_size ) { D ( ( ""matchoffsetbeyondwindowboundaries"" ) ) return lzx -> error = MSPACK_ERR_DECRUNCH ; } runsrc = & window [ lzx -> window_size - j ] ; if ( j < i ) { i -= j ; while ( j -- > 0 ) * rundest ++ = * runsrc ++ ; runsrc = window ; } while ( i -- > 0 ) * rundest ++ = * runsrc ++ ; } else { runsrc = rundest - match_offset ; while ( i -- > 0 ) * rundest ++ = * runsrc ++ ; } this_run -= match_length ; window_posn += match_length ; } } break ; case LZX_BLOCKTYPE_ALIGNED : while ( this_run > 0 ) { READ_HUFFSYM ( MAINTREE , main_element ) ; if ( main_element < LZX_NUM_CHARS ) { window [ window_posn ++ ] = main_element ; this_run -- ; } else { main_element -= LZX_NUM_CHARS ; match_length = main_element & LZX_NUM_PRIMARY_LENGTHS ; if ( match_length == LZX_NUM_PRIMARY_LENGTHS ) { if ( lzx -> LENGTH_empty ) { D ( ( ""LENGTHsymbolneededbuttreeisempty"" ) ) return lzx -> error = MSPACK_ERR_DECRUNCH ; } READ_HUFFSYM ( LENGTH , length_footer ) ; match_length += length_footer ; } match_length += LZX_MIN_MATCH ; switch ( ( match_offset = ( main_element >> 3 ) ) ) { case 0 : match_offset = R0 ; break ; case 1 : match_offset = R1 ; R1 = R0 ; R0 = match_offset ; break ; case 2 : match_offset = R2 ; R2 = R0 ; R0 = match_offset ; break ; default : extra = ( match_offset >= 36 ) ? 17 : extra_bits [ match_offset ] ; match_offset = position_base [ match_offset ] - 2 ; if ( extra > 3 ) { extra -= 3 ; READ_BITS ( verbatim_bits , extra ) ; match_offset += ( verbatim_bits << 3 ) ; READ_HUFFSYM ( ALIGNED , aligned_bits ) ; match_offset += aligned_bits ; } else if ( extra == 3 ) { READ_HUFFSYM ( ALIGNED , aligned_bits ) ; match_offset += aligned_bits ; } else if ( extra > 0 ) { READ_BITS ( verbatim_bits , extra ) ; match_offset += verbatim_bits ; } else { match_offset = 1 ; } R2 = R1 ; R1 = R0 ; R0 = match_offset ; } if ( match_length == LZX_MAX_MATCH && lzx -> is_delta ) { int extra_len = 0 ; ENSURE_BITS ( 3 ) ; if ( PEEK_BITS ( 1 ) == 0 ) { REMOVE_BITS ( 1 ) ; READ_BITS ( extra_len , 8 ) ; } else if ( PEEK_BITS ( 2 ) == 2 ) { REMOVE_BITS ( 2 ) ; READ_BITS ( extra_len , 10 ) ; extra_len += 0x100 ; } else if ( PEEK_BITS ( 3 ) == 6 ) { REMOVE_BITS ( 3 ) ; READ_BITS ( extra_len , 12 ) ; extra_len += 0x500 ; } else { REMOVE_BITS ( 3 ) ; READ_BITS ( extra_len , 15 ) ; } match_length += extra_len ; } if ( ( window_posn + match_length ) > lzx -> window_size ) { D ( ( ""matchranoverwindowwrap"" ) ) return lzx -> error = MSPACK_ERR_DECRUNCH ; } rundest = & window [ window_posn ] ; i = match_length ; if ( match_offset > window_posn ) { if ( match_offset > lzx -> offset && ( match_offset - window_posn ) > lzx -> ref_data_size ) { D ( ( ""matchoffsetbeyondLZXstream"" ) ) return lzx -> error = MSPACK_ERR_DECRUNCH ; } j = match_offset - window_posn ; if ( j > ( int ) lzx -> window_size ) { D ( ( ""matchoffsetbeyondwindowboundaries"" ) ) return lzx -> error = MSPACK_ERR_DECRUNCH ; } runsrc = & window [ lzx -> window_size - j ] ; if ( j < i ) { i -= j ; while ( j -- > 0 ) * rundest ++ = * runsrc ++ ; runsrc = window ; } while ( i -- > 0 ) * rundest ++ = * runsrc ++ ; } else { runsrc = rundest - match_offset ; while ( i -- > 0 ) * rundest ++ = * runsrc ++ ; } this_run -= match_length ; window_posn += match_length ; } } break ; case LZX_BLOCKTYPE_UNCOMPRESSED : rundest = & window [ window_posn ] ; window_posn += this_run ; while ( this_run > 0 ) { if ( ( i = i_end - i_ptr ) == 0 ) { READ_IF_NEEDED ; } else { if ( i > this_run ) i = this_run ; lzx -> sys -> copy ( i_ptr , rundest , ( size_t ) i ) ; rundest += i ; i_ptr += i ; this_run -= i ; } } break ; default : return lzx -> error = MSPACK_ERR_DECRUNCH ; } if ( this_run < 0 ) { if ( ( unsigned int ) ( - this_run ) > lzx -> block_remaining ) { D ( ( ""overrunwentpastendofblockby%d(%dremaining)"" , - this_run , lzx -> block_remaining ) ) return lzx -> error = MSPACK_ERR_DECRUNCH ; } lzx -> block_remaining -= - this_run ; } } if ( ( window_posn - lzx -> frame_posn ) != frame_size ) { D ( ( ""decodebeyondoutputframelimits!%d!=%d"" , window_posn - lzx -> frame_posn , frame_size ) ) return lzx -> error = MSPACK_ERR_DECRUNCH ; } if ( bits_left > 0 ) ENSURE_BITS ( 16 ) ; if ( bits_left & 15 ) REMOVE_BITS ( bits_left & 15 ) ; if ( lzx -> o_ptr != lzx -> o_end ) { D ( ( ""%ldavailbytes,new%dframe"" , ( long ) ( lzx -> o_end - lzx -> o_ptr ) , frame_size ) ) return lzx -> error = MSPACK_ERR_DECRUNCH ; } if ( lzx -> intel_started && lzx -> intel_filesize && ( lzx -> frame <= 32768 ) && ( frame_size > 10 ) ) { unsigned char * data = & lzx -> e8_buf [ 0 ] ; unsigned char * dataend = & lzx -> e8_buf [ frame_size - 10 ] ; signed int curpos = lzx -> intel_curpos ; signed int filesize = lzx -> intel_filesize ; signed int abs_off , rel_off ; lzx -> o_ptr = data ; lzx -> sys -> copy ( & lzx -> window [ lzx -> frame_posn ] , data , frame_size ) ; while ( data < dataend ) { if ( * data ++ != 0xE8 ) { curpos ++ ; continue ; } abs_off = data [ 0 ] | ( data [ 1 ] << 8 ) | ( data [ 2 ] << 16 ) | ( data [ 3 ] << 24 ) ; if ( ( abs_off >= - curpos ) && ( abs_off < filesize ) ) { rel_off = ( abs_off >= 0 ) ? abs_off - curpos : abs_off + filesize ; data [ 0 ] = ( unsigned char ) rel_off ; data [ 1 ] = ( unsigned char ) ( rel_off >> 8 ) ; data [ 2 ] = ( unsigned char ) ( rel_off >> 16 ) ; data [ 3 ] = ( unsigned char ) ( rel_off >> 24 ) ; } data += 4 ; curpos += 5 ; } lzx -> intel_curpos += frame_size ; } else { lzx -> o_ptr = & lzx -> window [ lzx -> frame_posn ] ; if ( lzx -> intel_filesize ) lzx -> intel_curpos += frame_size ; } lzx -> o_end = & lzx -> o_ptr [ frame_size ] ; i = ( out_bytes < ( off_t ) frame_size ) ? ( unsigned int ) out_bytes : frame_size ; if ( lzx -> sys -> write ( lzx -> output , lzx -> o_ptr , i ) != i ) { return lzx -> error = MSPACK_ERR_WRITE ; } lzx -> o_ptr += i ; lzx -> offset += i ; out_bytes -= i ; lzx -> frame_posn += frame_size ; lzx -> frame ++ ; if ( window_posn == lzx -> window_size ) window_posn = 0 ; if ( lzx -> frame_posn == lzx -> window_size ) lzx -> frame_posn = 0 ; } if ( out_bytes ) { D ( ( ""byteslefttooutput"" ) ) return lzx -> error = MSPACK_ERR_DECRUNCH ; } STORE_BITS ; lzx -> window_posn = window_posn ; lzx -> R0 = R0 ; lzx -> R1 = R1 ; lzx -> R2 = R2 ; return MSPACK_ERR_OK ; } "," = 1 ; if ( bits_left == 0 ) ( 16 ) ; bits_left = ",kyz@libmspack/18b6a2cc0b87536015bedd4f7763e6b02d5aa4f3,CVE-2015-4471,https://github.com/kyz/libmspack/commit/18b6a2cc0b87536015bedd4f7763e6b02d5aa4f3,2015-06-11T14:59Z 819,CWE-20,"CWE-20 error_t httpCheckCharset ( const char_t * s , size_t length , uint_t charset ) { error_t error ; size_t i ; uint8_t c ; uint_t m ; error = NO_ERROR ; for ( i = 0 ; i < length ; i ++ ) { c = ( uint8_t ) s [ i ] ; m = HTTP_CHARSET_OCTET ; if ( iscntrl ( c ) ) m |= HTTP_CHARSET_CTL ; if ( isprint ( c ) && c <= 126 ) m |= HTTP_CHARSET_TEXT | HTTP_CHARSET_VCHAR ; if ( c == '' || c == '\\t' ) m |= HTTP_CHARSET_TEXT | HTTP_CHARSET_LWS ; if ( isalpha ( c ) ) m |= HTTP_CHARSET_TCHAR | HTTP_CHARSET_ALPHA ; if ( osIsdigit ( c ) ) m |= HTTP_CHARSET_TCHAR | HTTP_CHARSET_DIGIT ; if ( isxdigit ( c ) ) m |= HTTP_CHARSET_HEX ; if ( c >= 128 ) m |= HTTP_CHARSET_TEXT | HTTP_CHARSET_OBS_TEXT ; if ( strchr ( ""!#$%&\'*+-.^_`|~"" , c ) ) m |= HTTP_CHARSET_TCHAR ; if ( ( m & charset ) == 0 ) error = ERROR_INVALID_SYNTAX ; } return error ; } "," ; if ( osStrchr ( ""!#$%&\'*+-.^_`|~"" , ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 820,CWE-190,"CWE-190 static int __get_data_block ( struct inode * inode , sector_t iblock , struct buffer_head * bh , int create , int flag , pgoff_t * next_pgofs ) { struct f2fs_map_blocks map ; int err ; map . m_lblk = iblock ; map . m_len = bh -> b_size >> inode -> i_blkbits ; map . m_next_pgofs = next_pgofs ; err = f2fs_map_blocks ( inode , & map , create , flag ) ; if ( ! err ) { map_bh ( bh , inode -> i_sb , map . m_pblk ) ; bh -> b_state = ( bh -> b_state & ~ F2FS_MAP_FLAGS ) | map . m_flags ; bh -> b_size = map . m_len << inode -> i_blkbits ; } return err ; } "," -> b_size = ( u64 ) ",torvalds@linux/b86e33075ed1909d8002745b56ecf73b833db143,CVE-2017-18257,https://github.com/torvalds/linux/commit/b86e33075ed1909d8002745b56ecf73b833db143,2018-04-04T17:29Z 821,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 822,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 823,CWE-20,"CWE-20 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 -> 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 ) { mpeg4_decode_profile_level ( s , gb ) ; if ( s -> avctx -> profile == FF_PROFILE_MPEG4_SIMPLE_STUDIO && ( s -> avctx -> level > 0 && s -> avctx -> level < 9 ) ) { s -> studio_profile = 1 ; next_start_code_studio ( gb ) ; extension_and_user_data ( s , gb , 0 ) ; } } 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 ) { 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 ) ; } "," ( gb ) ; if ( ! s -> studio_profile && s -> avctx -> bits_per_raw_sample != 8 ) s -> avctx -> bits_per_raw_sample = 0 ",FFmpeg@FFmpeg/2fc108f60f98cd00813418a8754a46476b404a3c,CVE-2018-12459,https://github.com/FFmpeg/FFmpeg/commit/2fc108f60f98cd00813418a8754a46476b404a3c,2018-06-15T15:29Z 824,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 825,CWE-125,"CWE-125 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 ; } "," ",radare@radare2/2ca9ab45891b6ae8e32b6c28c81eebca059cbe5d,CVE-2017-16805,https://github.com/radare/radare2/commit/2ca9ab45891b6ae8e32b6c28c81eebca059cbe5d,2017-11-13T21:29Z 826,CWE-119,"CWE-119 int vp8_calc_ss_err ( YV12_BUFFER_CONFIG * source , YV12_BUFFER_CONFIG * dest ) { int i , j ; int Total = 0 ; unsigned char * src = source -> y_buffer ; unsigned char * dst = dest -> y_buffer ; for ( i = 0 ; i < source -> y_height ; i += 16 ) { for ( j = 0 ; j < source -> y_width ; j += 16 ) { unsigned int sse ; Total += vp8_mse16x16 ( src + j , source -> y_stride , dst + j , dest -> y_stride , & sse ) ; } src += 16 * source -> y_stride ; dst += 16 * dest -> y_stride ; } return Total ; } "," ; Total += vpx_mse16x16 ( src + ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 827,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 828,CWE-119,"CWE-119 static int sd_e_h ( GWindow gw , GEvent * event ) { struct sd_data * sd = GDrawGetUserData ( gw ) ; if ( sd == NULL ) return ( true ) ; if ( event -> type == et_close ) { SD_DoCancel ( sd ) ; } else if ( event -> type == et_char ) { if ( event -> u . chr . keysym == GK_F1 || event -> u . chr . keysym == GK_Help ) { help ( ""scripting.html"" ) ; return ( true ) ; } return ( false ) ; } else if ( event -> type == et_map ) GDrawRaise ( gw ) ; else if ( event -> type == et_resize ) GDrawRequestExpose ( gw , NULL , false ) ; return ( true ) ; } "," -> type == et_controlevent && event -> u . control . subtype == et_textchanged ) { sd -> fv -> script_unsaved = ! GTextFieldIsEmpty ( GWidgetGetControl ( sd -> gw , CID_Script ) ) ; } else if ( event -> type == et_controlevent && event -> u . control . subtype == et_save ) { sd -> fv -> script_unsaved = false ; } else if ( event -> type == ",fontforge@fontforge/626f751752875a0ddd74b9e217b6f4828713573c,CVE-2019-15785,https://github.com/fontforge/fontforge/commit/626f751752875a0ddd74b9e217b6f4828713573c,2019-08-29T13:15Z 829,CWE-119,"CWE-119 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_first_pb_nal_in_pic = 1 ; 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 ; header_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 ) || ( ret == ERROR_INV_SPS_PPS_T ) ) { ps_dec -> u4_slice_start_code_found = 0 ; 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 ; WORD32 ht_in_mbs ; ht_in_mbs = ps_dec -> u2_pic_ht >> ( 4 + ps_dec -> ps_cur_slice -> u1_field_pic_flag ) ; num_mb_skipped = ( 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 ; if ( ps_dec -> u4_first_slice_in_pic && ( ps_dec -> u2_total_mbs_coded == 0 ) ) prev_slice_err = 1 ; 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 ) || ( ret1 == ERROR_INV_SPS_PPS_T ) ) { ret = ret1 ; } } if ( ( ret == IVD_RES_CHANGED ) || ( ret == IVD_MEM_ALLOC_FAILED ) || ( ret == ERROR_UNAVAIL_PICBUF_T ) || ( ret == ERROR_UNAVAIL_MVBUF_T ) || ( ret == ERROR_INV_SPS_PPS_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 ) && ( ps_dec -> u4_pic_buf_got == 1 ) ) { 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 ; } "," buflen , buf_size - 8 ",external@libavc/33ef7de9ddc8ea7eb9cbc440d1cf89957a0c267b,CVE-2017-0542,https://android.googlesource.com/platform/external/libavc/+/33ef7de9ddc8ea7eb9cbc440d1cf89957a0c267b,2017-04-07T22:59Z 830,CWE-000,"CWE-000 static int crossOriginDirective ( MaState * state , cchar * key , cchar * value ) { HttpRoute * route ; char * option , * ovalue , * tok ; route = state -> route ; tok = sclone ( value ) ; while ( ( option = maGetNextArg ( tok , & tok ) ) != 0 ) { option = stok ( option , ""=\\t,"" , & ovalue ) ; ovalue = strim ( ovalue , ""\\""\'"" , MPR_TRIM_BOTH ) ; if ( scaselessmatch ( option , ""origin"" ) ) { route -> corsOrigin = sclone ( ovalue ) ; } else if ( scaselessmatch ( option , ""credentials"" ) ) { route -> corsCredentials = httpGetBoolToken ( ovalue ) ; } else if ( scaselessmatch ( option , ""headers"" ) ) { route -> corsHeaders = sclone ( ovalue ) ; } else if ( scaselessmatch ( option , ""age"" ) ) { route -> corsAge = atoi ( ovalue ) ; } else { mprLog ( ""errorappwebconfig"" , 0 , ""UnknownCrossOriginoption%s"" , option ) ; return MPR_ERR_BAD_SYNTAX ; } } # if KEEP if ( smatch ( route -> corsOrigin , ""*"" ) && route -> corsCredentials ) { mprLog ( ""errorappwebconfig"" , 0 , ""CrossOrigin:CannotusewildcardOriginifallowingcredentials"" ) ; return MPR_ERR_BAD_STATE ; } # endif httpAddRouteMethods ( route , ""OPTIONS"" ) ; route -> flags |= HTTP_ROUTE_CORS ; return 0 ; } "," { option = ssplit ( option , ",embedthis@appweb/7e6a925f5e86a19a7934a94bbd6959101d0b84eb,CVE-2014-9708,https://github.com/embedthis/appweb/commit/7e6a925f5e86a19a7934a94bbd6959101d0b84eb,2015-03-31T14:59Z 831,CWE-369,"CWE-369 tmsize_t TIFFReadEncodedStrip ( TIFF * tif , uint32 strip , void * buf , tmsize_t size ) { static const char module [ ] = ""TIFFReadEncodedStrip"" ; TIFFDirectory * td = & tif -> tif_dir ; uint32 rowsperstrip ; uint32 stripsperplane ; uint32 stripinplane ; uint16 plane ; uint32 rows ; tmsize_t stripsize ; if ( ! TIFFCheckRead ( tif , 0 ) ) return ( ( tmsize_t ) ( - 1 ) ) ; if ( strip >= td -> td_nstrips ) { TIFFErrorExt ( tif -> tif_clientdata , module , ""%lu:Stripoutofrange,max%lu"" , ( unsigned long ) strip , ( unsigned long ) td -> td_nstrips ) ; return ( ( tmsize_t ) ( - 1 ) ) ; } rowsperstrip = td -> td_rowsperstrip ; if ( rowsperstrip > td -> td_imagelength ) rowsperstrip = td -> td_imagelength ; stripsperplane = ( ( td -> td_imagelength + rowsperstrip - 1 ) / rowsperstrip ) ; stripinplane = ( strip % stripsperplane ) ; plane = ( uint16 ) ( strip / stripsperplane ) ; rows = td -> td_imagelength - stripinplane * rowsperstrip ; if ( rows > rowsperstrip ) rows = rowsperstrip ; stripsize = TIFFVStripSize ( tif , rows ) ; if ( stripsize == 0 ) return ( ( tmsize_t ) ( - 1 ) ) ; if ( td -> td_compression == COMPRESSION_NONE && size != ( tmsize_t ) ( - 1 ) && size >= stripsize && ! isMapped ( tif ) && ( ( tif -> tif_flags & TIFF_NOREADRAW ) == 0 ) ) { if ( TIFFReadRawStrip1 ( tif , strip , buf , stripsize , module ) != stripsize ) return ( ( tmsize_t ) ( - 1 ) ) ; if ( ! isFillOrder ( tif , td -> td_fillorder ) && ( tif -> tif_flags & TIFF_NOBITREV ) == 0 ) TIFFReverseBits ( buf , stripsize ) ; ( * tif -> tif_postdecode ) ( tif , buf , stripsize ) ; return ( stripsize ) ; } if ( ( size != ( tmsize_t ) ( - 1 ) ) && ( size < stripsize ) ) stripsize = size ; if ( ! TIFFFillStrip ( tif , strip ) ) return ( ( tmsize_t ) ( - 1 ) ) ; if ( ( * tif -> tif_decodestrip ) ( tif , buf , stripsize , plane ) <= 0 ) return ( ( tmsize_t ) ( - 1 ) ) ; ( * tif -> tif_postdecode ) ( tif , buf , stripsize ) ; return ( stripsize ) ; } "," ; stripsperplane = TIFFhowmany_32_maxuint_compat ( td -> td -> td_imagelength , rowsperstrip ) ; ",vadz@libtiff/438274f938e046d33cb0e1230b41da32ffe223e1,CVE-2016-10266,https://github.com/vadz/libtiff/commit/438274f938e046d33cb0e1230b41da32ffe223e1,2017-03-24T19:59Z 832,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 833,CWE-399,"CWE-399 static int hugetlbfs_statfs ( struct dentry * dentry , struct kstatfs * buf ) { struct hugetlbfs_sb_info * sbinfo = HUGETLBFS_SB ( dentry -> d_sb ) ; struct hstate * h = hstate_inode ( dentry -> d_inode ) ; buf -> f_type = HUGETLBFS_MAGIC ; buf -> f_bsize = huge_page_size ( h ) ; if ( sbinfo ) { spin_lock ( & sbinfo -> stat_lock ) ; if ( sbinfo -> max_blocks >= 0 ) { buf -> f_blocks = sbinfo -> max_blocks ; buf -> f_bavail = buf -> f_bfree = sbinfo -> free_blocks ; buf -> f_files = sbinfo -> max_inodes ; buf -> f_ffree = sbinfo -> free_inodes ; } spin_unlock ( & sbinfo -> stat_lock ) ; } buf -> f_namelen = NAME_MAX ; return 0 ; } "," ( sbinfo -> spool ) { long free_pages ; spin_lock ( & sbinfo -> spool -> lock ) ; buf -> f_blocks = sbinfo -> spool -> max_hpages ; free_pages = sbinfo -> spool -> max_hpages - sbinfo -> spool -> used_hpages ; buf -> -> f_bfree = free_pages ; spin_unlock ( & sbinfo -> spool -> lock ) ; buf -> ",torvalds@linux/90481622d75715bfcb68501280a917dbfe516029,CVE-2012-2133,https://github.com/torvalds/linux/commit/90481622d75715bfcb68501280a917dbfe516029,2012-07-03T16:40Z 834,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 835,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 836,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 837,CWE-119,"CWE-119 static unsigned int help ( struct sk_buff * skb , enum ip_conntrack_info ctinfo , unsigned int protoff , unsigned int matchoff , unsigned int matchlen , struct nf_conntrack_expect * exp ) { char buffer [ sizeof ( ""429496729665635"" ) ] ; u_int16_t port ; unsigned int ret ; exp -> saved_proto . tcp . port = exp -> tuple . dst . u . tcp . port ; exp -> dir = IP_CT_DIR_REPLY ; exp -> expectfn = nf_nat_follow_master ; for ( port = ntohs ( exp -> saved_proto . tcp . port ) ; port != 0 ; port ++ ) { int ret ; exp -> tuple . dst . u . tcp . port = htons ( port ) ; ret = nf_ct_expect_related ( exp ) ; if ( ret == 0 ) break ; else if ( ret != - EBUSY ) { port = 0 ; break ; } } if ( port == 0 ) { nf_ct_helper_log ( skb , exp -> master , ""allportsinuse"" ) ; return NF_DROP ; } ret = nf_nat_mangle_tcp_packet ( skb , exp -> master , ctinfo , protoff , matchoff , matchlen , buffer , strlen ( buffer ) ) ; if ( ret != NF_ACCEPT ) { nf_ct_helper_log ( skb , exp -> master , ""cannotmanglepacket"" ) ; nf_ct_unexpect_related ( exp ) ; } return ret ; } "," ) ] ; struct nf_conn * ct = exp -> master ; union nf_inet_addr newaddr ; unsigned int ret ; newaddr = ct -> tuplehash [ IP_CT_DIR_REPLY ] . tuple . dst . u3 ( skb , ct , ""allportsinuse"" ) NF_DROP ; } snprintf ( buffer , sizeof ( buffer ) , ""%u%u"" , ntohl ( newaddr . ip ) , port ) ; pr_debug ( ""nf_nat_irc:inserting\'%s\'==%pI4,port%u\\n"" , buffer , & newaddr . ip , port ) ; ( skb , ct , ctinfo , ( skb , ct , ""cannotmanglepacket"" ) ",torvalds@linux/2690d97ade05c5325cbf7c72b94b90d265659886,CVE-2014-1690,https://github.com/torvalds/linux/commit/2690d97ade05c5325cbf7c72b94b90d265659886,2014-02-28T06:18Z 838,CWE-404,"CWE-404 int nfs3svc_decode_readargs ( struct svc_rqst * rqstp , __be32 * p , struct nfsd3_readargs * args ) { unsigned int len ; int v ; u32 max_blocksize = svc_max_payload ( rqstp ) ; p = decode_fh ( p , & args -> fh ) ; if ( ! p ) return 0 ; p = xdr_decode_hyper ( p , & args -> offset ) ; args -> count = ntohl ( * p ++ ) ; len = min ( args -> count , max_blocksize ) ; v = 0 ; while ( len > 0 ) { struct page * p = * ( rqstp -> rq_next_page ++ ) ; rqstp -> rq_vec [ v ] . iov_base = page_address ( p ) ; rqstp -> rq_vec [ v ] . iov_len = min_t ( unsigned int , len , PAGE_SIZE ) ; len -= rqstp -> rq_vec [ v ] . iov_len ; v ++ ; } args -> vlen = v ; return xdr_argsize_check ( rqstp , p ) ; } "," p ++ ) ; if ( ! xdr_argsize_check ( rqstp , p ) ) return 0 v ; return 1 ; } ",torvalds@linux/c70422f760c120480fee4de6c38804c72aa26bc1,CVE-2017-9059,https://github.com/torvalds/linux/commit/c70422f760c120480fee4de6c38804c72aa26bc1,2017-05-18T06:29Z 839,CWE-125,"CWE-125 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 ++ ; } if ( operand >= MAX_OPERANDS ) { eprintf ( ""Toomanyoperands\\n"" ) ; return false ; } 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 ; } "," } if ( strlen ( token ) > 4 && ",devnexen@radare2/88a8adf080a9f8ed5a4250a2507752e133ba54dd,CVE-2018-20459,https://github.com/devnexen/radare2/commit/88a8adf080a9f8ed5a4250a2507752e133ba54dd,2018-12-25T19:29Z 840,CWE-400,"CWE-400 static void perf_swevent_overflow ( struct perf_event * event , u64 overflow , int nmi , struct perf_sample_data * data , struct pt_regs * regs ) { struct hw_perf_event * hwc = & event -> hw ; int throttle = 0 ; data -> period = event -> hw . last_period ; if ( ! overflow ) overflow = perf_swevent_set_period ( event ) ; if ( hwc -> interrupts == MAX_INTERRUPTS ) return ; for ( ; overflow ; overflow -- ) { if ( __perf_event_overflow ( event , nmi , throttle , data , regs ) ) { break ; } throttle = 1 ; } } "," u64 overflow , struct perf_sample_data * ( event , throttle , data ",torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,CVE-2011-2918,https://github.com/torvalds/linux/commit/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,2012-05-24T23:55Z 841,CWE-119,"CWE-119 static INLINE void write_buffer_4x4 ( int16_t * output , __m128i * res ) { const __m128i kOne = _mm_set1_epi16 ( 1 ) ; __m128i in01 = _mm_unpacklo_epi64 ( res [ 0 ] , res [ 1 ] ) ; __m128i in23 = _mm_unpacklo_epi64 ( res [ 2 ] , res [ 3 ] ) ; __m128i out01 = _mm_add_epi16 ( in01 , kOne ) ; __m128i out23 = _mm_add_epi16 ( in23 , kOne ) ; out01 = _mm_srai_epi16 ( out01 , 2 ) ; out23 = _mm_srai_epi16 ( out23 , 2 ) ; _mm_store_si128 ( ( __m128i * ) ( output + 0 * 8 ) , out01 ) ; _mm_store_si128 ( ( __m128i * ) ( output + 1 * 8 ) , out23 ) ; } "," void write_buffer_4x4 ( tran_low_t * output , 2 ) ; store_output ( & out01 , ( output + * 8 ) ) ; store_output ( & out23 , ( output + * 8 ) ) ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 842,CWE-119,"CWE-119 void color_cmyk_to_rgb ( opj_image_t * image ) { float C , M , Y , K ; float sC , sM , sY , sK ; unsigned int w , h , max , i ; w = image -> comps [ 0 ] . w ; h = image -> comps [ 0 ] . h ; if ( image -> numcomps < 4 ) return ; max = w * h ; sC = 1.0F / ( float ) ( ( 1 << image -> comps [ 0 ] . prec ) - 1 ) ; sM = 1.0F / ( float ) ( ( 1 << image -> comps [ 1 ] . prec ) - 1 ) ; sY = 1.0F / ( float ) ( ( 1 << image -> comps [ 2 ] . prec ) - 1 ) ; sK = 1.0F / ( float ) ( ( 1 << image -> comps [ 3 ] . prec ) - 1 ) ; for ( i = 0 ; i < max ; ++ i ) { C = ( float ) ( image -> comps [ 0 ] . data [ i ] ) * sC ; M = ( float ) ( image -> comps [ 1 ] . data [ i ] ) * sM ; Y = ( float ) ( image -> comps [ 2 ] . data [ i ] ) * sY ; K = ( float ) ( image -> comps [ 3 ] . data [ i ] ) * sK ; C = 1.0F - C ; M = 1.0F - M ; Y = 1.0F - Y ; K = 1.0F - K ; image -> comps [ 0 ] . data [ i ] = ( int ) ( 255.0F * C * K ) ; image -> comps [ 1 ] . data [ i ] = ( int ) ( 255.0F * M * K ) ; image -> comps [ 2 ] . data [ i ] = ( int ) ( 255.0F * Y * K ) ; } free ( image -> comps [ 3 ] . data ) ; image -> comps [ 3 ] . data = NULL ; image -> comps [ 0 ] . prec = 8 ; image -> comps [ 1 ] . prec = 8 ; image -> comps [ 2 ] . prec = 8 ; image -> numcomps -= 1 ; image -> color_space = OPJ_CLRSPC_SRGB ; for ( i = 3 ; i < image -> numcomps ; ++ i ) { memcpy ( & ( image -> comps [ i ] ) , & ( image -> comps [ i + 1 ] ) , sizeof ( image -> comps [ i ] ) ) ; } } "," ; if ( ( < 4 ) || ( image -> comps [ 0 ] . dx != image -> comps [ 1 ] . dx ) || ( image -> comps [ 0 ] . dx != image -> comps [ 2 ] . dx ) || ( image -> comps [ 0 ] . dx != image -> comps [ 3 ] . dx ) || ( image -> comps [ 0 ] . dy != image -> comps [ 1 ] . dy ) || ( image -> comps [ 0 ] . dy != image -> comps [ 2 ] . dy ) || ( image -> comps [ 0 ] . dy != image -> comps [ 3 ] . dy ) ) { fprintf ( stderr , ""%s:%d:color_cmyk_to_rgb\\n\\tCANNOTCONVERT\\n"" , __FILE__ , __LINE__ ) ; return ; } max = w ",uclouvain@openjpeg/162f6199c0cd3ec1c6c6dc65e41b2faab92b2d91,CVE-2016-4796,https://github.com/uclouvain/openjpeg/commit/162f6199c0cd3ec1c6c6dc65e41b2faab92b2d91,2017-02-03T16:59Z 843,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 844,CWE-494,"CWE-494 LONG ValidateSignature ( HWND hDlg , const char * path ) { LONG r ; WINTRUST_DATA trust_data = { 0 } ; WINTRUST_FILE_INFO trust_file = { 0 } ; GUID guid_generic_verify = { 0xaac56b , 0xcd44 , 0x11d0 , { 0x8c , 0xc2 , 0x0 , 0xc0 , 0x4f , 0xc2 , 0x95 , 0xee } } ; char * signature_name ; size_t i , len ; signature_name = GetSignatureName ( path ) ; if ( signature_name == NULL ) { uprintf ( ""PKI:Couldnotgetsignaturename"" ) ; MessageBoxExU ( hDlg , lmprintf ( MSG_284 ) , lmprintf ( MSG_283 ) , MB_OK | MB_ICONERROR | MB_IS_RTL , selected_langid ) ; return TRUST_E_NOSIGNATURE ; } for ( i = 0 ; i < ARRAYSIZE ( cert_name ) ; i ++ ) { len = strlen ( cert_name [ i ] ) ; if ( strncmp ( signature_name , cert_name [ i ] , len ) == 0 ) { if ( ( len >= strlen ( signature_name ) ) || isspace ( signature_name [ len ] ) ) break ; } } if ( i >= ARRAYSIZE ( cert_name ) ) { uprintf ( ""PKI:Signature\'%s\'isunexpected..."" , signature_name ) ; if ( MessageBoxExU ( hDlg , lmprintf ( MSG_285 , signature_name ) , lmprintf ( MSG_283 ) , MB_YESNO | MB_ICONWARNING | MB_IS_RTL , selected_langid ) != IDYES ) return TRUST_E_EXPLICIT_DISTRUST ; } trust_file . cbStruct = sizeof ( trust_file ) ; trust_file . pcwszFilePath = utf8_to_wchar ( path ) ; if ( trust_file . pcwszFilePath == NULL ) { uprintf ( ""PKI:Unabletoconvert\'%s\'toUTF16"" , path ) ; return ERROR_SEVERITY_ERROR | FAC ( FACILITY_CERT ) | ERROR_NOT_ENOUGH_MEMORY ; } trust_data . cbStruct = sizeof ( trust_data ) ; trust_data . dwUIChoice = WTD_UI_ALL ; trust_data . fdwRevocationChecks = WTD_REVOKE_WHOLECHAIN ; trust_data . dwProvFlags = WTD_REVOCATION_CHECK_CHAIN | 0x400 ; trust_data . dwUnionChoice = WTD_CHOICE_FILE ; trust_data . pFile = & trust_file ; r = WinVerifyTrust ( NULL , & guid_generic_verify , & trust_data ) ; safe_free ( trust_file . pcwszFilePath ) ; return r ; } "," . dwUIChoice = WTD_UI_NONE ; trust_data . pcwszFilePath ) ; switch ( r ) { case ERROR_SUCCESS : break ; case TRUST_E_NOSIGNATURE : uprintf ( ""PKI:Filedoesnotappeartobesigned:%s"" , WinPKIErrorString ( ) ) ; MessageBoxExU ( hDlg , lmprintf ( MSG_284 ) , lmprintf ( MSG_283 ) , MB_OK | MB_ICONERROR | MB_IS_RTL , selected_langid ) ; break ; default : uprintf ( ""PKI:Failedtovalidatesignature:%s"" , WinPKIErrorString ( ) ) ; MessageBoxExU ( hDlg , lmprintf ( MSG_240 ) , lmprintf ( MSG_283 ) , MB_OK | MB_ICONERROR | MB_IS_RTL , selected_langid ) ; break ; } ",pbatard@rufus/c3c39f7f8a11f612c4ebf7affce25ec6928eb1cb,CVE-2017-13083,https://github.com/pbatard/rufus/commit/c3c39f7f8a11f612c4ebf7affce25ec6928eb1cb,2017-10-18T13:29Z 845,CWE-787,"CWE-787 DECLAREreadFunc ( readContigTilesIntoBuffer ) { int status = 1 ; tsize_t tilesize = TIFFTileSize ( in ) ; tdata_t tilebuf ; uint32 imagew = TIFFScanlineSize ( in ) ; uint32 tilew = TIFFTileRowSize ( in ) ; int iskew = imagew - tilew ; uint8 * bufp = ( uint8 * ) buf ; uint32 tw , tl ; uint32 row ; ( void ) spp ; tilebuf = _TIFFmalloc ( tilesize ) ; if ( tilebuf == 0 ) return 0 ; _TIFFmemset ( tilebuf , 0 , tilesize ) ; ( void ) TIFFGetField ( in , TIFFTAG_TILEWIDTH , & tw ) ; ( void ) TIFFGetField ( in , TIFFTAG_TILELENGTH , & tl ) ; for ( row = 0 ; row < imagelength ; row += tl ) { uint32 nrow = ( row + tl > imagelength ) ? imagelength - row : tl ; uint32 colb = 0 ; uint32 col ; for ( col = 0 ; col < imagewidth ; col += tw ) { if ( TIFFReadTile ( in , tilebuf , col , row , 0 , 0 ) < 0 && ! ignore ) { TIFFError ( TIFFFileName ( in ) , ""Error,can\'treadtileat%lu%lu"" , ( unsigned long ) col , ( unsigned long ) row ) ; status = 0 ; goto done ; } if ( colb + tilew > imagew ) { uint32 width = imagew - colb ; uint32 oskew = tilew - width ; cpStripToTile ( bufp + colb , tilebuf , nrow , width , oskew + iskew , oskew ) ; } else cpStripToTile ( bufp + colb , tilebuf , nrow , tilew , iskew , 0 ) ; colb += tilew ; } bufp += imagew * nrow ; } done : _TIFFfree ( tilebuf ) ; return status ; } "," col < imagewidth && colb < imagew ",vadz@libtiff/5ad9d8016fbb60109302d558f7edb2cb2a3bb8e3,CVE-2016-9540,https://github.com/vadz/libtiff/commit/5ad9d8016fbb60109302d558f7edb2cb2a3bb8e3,2016-11-22T19:59Z 846,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 847,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 848,CWE-20,"CWE-20 WORD32 ih264d_parse_decode_slice ( UWORD8 u1_is_idr_slice , UWORD8 u1_nal_ref_idc , dec_struct_t * ps_dec ) { dec_bit_stream_t * ps_bitstrm = ps_dec -> ps_bitstrm ; dec_pic_params_t * ps_pps ; dec_seq_params_t * ps_seq ; dec_slice_params_t * ps_cur_slice = ps_dec -> ps_cur_slice ; pocstruct_t s_tmp_poc ; WORD32 i_delta_poc [ 2 ] ; WORD32 i4_poc = 0 ; UWORD16 u2_first_mb_in_slice , u2_frame_num ; UWORD8 u1_field_pic_flag , u1_redundant_pic_cnt = 0 , u1_slice_type ; UWORD32 u4_idr_pic_id = 0 ; UWORD8 u1_bottom_field_flag , u1_pic_order_cnt_type ; UWORD8 u1_nal_unit_type ; UWORD32 * pu4_bitstrm_buf = ps_bitstrm -> pu4_buffer ; UWORD32 * pu4_bitstrm_ofst = & ps_bitstrm -> u4_ofst ; WORD8 i1_is_end_of_poc ; WORD32 ret , end_of_frame ; WORD32 prev_slice_err , num_mb_skipped ; UWORD8 u1_mbaff ; pocstruct_t * ps_cur_poc ; UWORD32 u4_temp ; WORD32 i_temp ; UWORD32 u4_call_end_of_pic = 0 ; ps_dec -> ps_dpb_cmds -> u1_dpb_commands_read_slc = 0 ; u2_first_mb_in_slice = ih264d_uev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; if ( u2_first_mb_in_slice > ( ps_dec -> u2_frm_ht_in_mbs * ps_dec -> u2_frm_wd_in_mbs ) ) { return ERROR_CORRUPTED_SLICE ; } if ( ( ( u2_first_mb_in_slice << ps_cur_slice -> u1_mbaff_frame_flag ) <= ps_dec -> u2_cur_mb_addr ) && ( ps_dec -> u2_cur_mb_addr != 0 ) && ( ps_dec -> u4_first_slice_in_pic != 0 ) ) { return ERROR_CORRUPTED_SLICE ; } COPYTHECONTEXT ( ""SH:first_mb_in_slice"" , u2_first_mb_in_slice ) ; u4_temp = ih264d_uev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; if ( u4_temp > 9 ) return ERROR_INV_SLC_TYPE_T ; u1_slice_type = u4_temp ; COPYTHECONTEXT ( ""SH:slice_type"" , ( u1_slice_type ) ) ; ps_dec -> u1_sl_typ_5_9 = 0 ; if ( u1_slice_type > 4 ) { u1_slice_type -= 5 ; ps_dec -> u1_sl_typ_5_9 = 1 ; } { UWORD32 skip ; if ( ( ps_dec -> i4_app_skip_mode == IVD_SKIP_PB ) || ( ps_dec -> i4_dec_skip_mode == IVD_SKIP_PB ) ) { UWORD32 u4_bit_stream_offset = 0 ; if ( ps_dec -> u1_nal_unit_type == IDR_SLICE_NAL ) { skip = 0 ; ps_dec -> i4_dec_skip_mode = IVD_SKIP_NONE ; } else if ( ( I_SLICE == u1_slice_type ) && ( 1 >= ps_dec -> ps_cur_sps -> u1_num_ref_frames ) ) { skip = 0 ; ps_dec -> i4_dec_skip_mode = IVD_SKIP_NONE ; } else { skip = 1 ; } if ( ( 0 == u2_first_mb_in_slice ) && ( 1 == ps_dec -> u4_prev_nal_skipped ) ) { skip = 0 ; } if ( skip ) { ps_dec -> u4_prev_nal_skipped = 1 ; ps_dec -> i4_dec_skip_mode = IVD_SKIP_PB ; return 0 ; } else { if ( 1 == ps_dec -> u4_prev_nal_skipped ) { ps_dec -> u4_return_to_app = 1 ; return 0 ; } } } } u4_temp = ih264d_uev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; if ( u4_temp & MASK_ERR_PIC_SET_ID ) return ERROR_INV_SPS_PPS_T ; COPYTHECONTEXT ( ""SH:pic_parameter_set_id"" , u4_temp ) ; ps_pps = & ps_dec -> ps_pps [ u4_temp ] ; if ( FALSE == ps_pps -> u1_is_valid ) { return ERROR_INV_SPS_PPS_T ; } ps_seq = ps_pps -> ps_sps ; if ( ! ps_seq ) return ERROR_INV_SPS_PPS_T ; if ( FALSE == ps_seq -> u1_is_valid ) return ERROR_INV_SPS_PPS_T ; u2_frame_num = ih264d_get_bits_h264 ( ps_bitstrm , ps_seq -> u1_bits_in_frm_num ) ; COPYTHECONTEXT ( ""SH:frame_num"" , u2_frame_num ) ; if ( ! ps_seq -> u1_frame_mbs_only_flag ) { u1_field_pic_flag = ih264d_get_bit_h264 ( ps_bitstrm ) ; COPYTHECONTEXT ( ""SH:field_pic_flag"" , u1_field_pic_flag ) ; u1_bottom_field_flag = 0 ; if ( u1_field_pic_flag ) { ps_dec -> pu1_inv_scan = ( UWORD8 * ) gau1_ih264d_inv_scan_fld ; u1_bottom_field_flag = ih264d_get_bit_h264 ( ps_bitstrm ) ; COPYTHECONTEXT ( ""SH:bottom_field_flag"" , u1_bottom_field_flag ) ; } else { ps_dec -> pu1_inv_scan = ( UWORD8 * ) gau1_ih264d_inv_scan ; } } else { u1_field_pic_flag = 0 ; u1_bottom_field_flag = 0 ; ps_dec -> pu1_inv_scan = ( UWORD8 * ) gau1_ih264d_inv_scan ; } u1_nal_unit_type = SLICE_NAL ; if ( u1_is_idr_slice ) { if ( 0 == u1_field_pic_flag ) { ps_dec -> u1_top_bottom_decoded = TOP_FIELD_ONLY | BOT_FIELD_ONLY ; } u1_nal_unit_type = IDR_SLICE_NAL ; u4_idr_pic_id = ih264d_uev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; if ( u4_idr_pic_id > 65535 ) return ERROR_INV_SPS_PPS_T ; COPYTHECONTEXT ( ""SH:"" , u4_idr_pic_id ) ; } i_delta_poc [ 0 ] = i_delta_poc [ 1 ] = 0 ; s_tmp_poc . i4_pic_order_cnt_lsb = 0 ; s_tmp_poc . i4_delta_pic_order_cnt_bottom = 0 ; u1_pic_order_cnt_type = ps_seq -> u1_pic_order_cnt_type ; if ( u1_pic_order_cnt_type == 0 ) { i_temp = ih264d_get_bits_h264 ( ps_bitstrm , ps_seq -> u1_log2_max_pic_order_cnt_lsb_minus ) ; if ( i_temp < 0 || i_temp >= ps_seq -> i4_max_pic_order_cntLsb ) return ERROR_INV_SPS_PPS_T ; s_tmp_poc . i4_pic_order_cnt_lsb = i_temp ; COPYTHECONTEXT ( ""SH:pic_order_cnt_lsb"" , s_tmp_poc . i4_pic_order_cnt_lsb ) ; if ( ( ps_pps -> u1_pic_order_present_flag == 1 ) && ( ! u1_field_pic_flag ) ) { s_tmp_poc . i4_delta_pic_order_cnt_bottom = ih264d_sev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; COPYTHECONTEXT ( ""SH:delta_pic_order_cnt_bottom"" , s_tmp_poc . i4_delta_pic_order_cnt_bottom ) ; } } s_tmp_poc . i4_delta_pic_order_cnt [ 0 ] = 0 ; s_tmp_poc . i4_delta_pic_order_cnt [ 1 ] = 0 ; if ( u1_pic_order_cnt_type == 1 && ( ! ps_seq -> u1_delta_pic_order_always_zero_flag ) ) { s_tmp_poc . i4_delta_pic_order_cnt [ 0 ] = ih264d_sev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; COPYTHECONTEXT ( ""SH:delta_pic_order_cnt[0]"" , s_tmp_poc . i4_delta_pic_order_cnt [ 0 ] ) ; if ( ps_pps -> u1_pic_order_present_flag && ! u1_field_pic_flag ) { s_tmp_poc . i4_delta_pic_order_cnt [ 1 ] = ih264d_sev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; COPYTHECONTEXT ( ""SH:delta_pic_order_cnt[1]"" , s_tmp_poc . i4_delta_pic_order_cnt [ 1 ] ) ; } } if ( ps_pps -> u1_redundant_pic_cnt_present_flag ) { u4_temp = ih264d_uev ( pu4_bitstrm_ofst , pu4_bitstrm_buf ) ; if ( u4_temp > MAX_REDUNDANT_PIC_CNT ) return ERROR_INV_SPS_PPS_T ; u1_redundant_pic_cnt = u4_temp ; COPYTHECONTEXT ( ""SH:redundant_pic_cnt"" , u1_redundant_pic_cnt ) ; } i1_is_end_of_poc = 0 ; if ( ! ps_dec -> u1_first_slice_in_stream ) { i1_is_end_of_poc = ih264d_is_end_of_pic ( u2_frame_num , u1_nal_ref_idc , & s_tmp_poc , & ps_dec -> s_cur_pic_poc , ps_cur_slice , u1_pic_order_cnt_type , u1_nal_unit_type , u4_idr_pic_id , u1_field_pic_flag , u1_bottom_field_flag ) ; if ( ( ps_dec -> u4_first_slice_in_pic == 2 ) && ( i1_is_end_of_poc == 0 ) ) { ps_dec -> ps_dec_err_status -> u1_err_flag |= REJECT_CUR_PIC ; i1_is_end_of_poc = 1 ; } else { ps_dec -> ps_dec_err_status -> u1_err_flag &= MASK_REJECT_CUR_PIC ; } } u1_mbaff = ps_seq -> u1_mb_aff_flag && ( ! u1_field_pic_flag ) ; prev_slice_err = 0 ; if ( i1_is_end_of_poc || ps_dec -> u1_first_slice_in_stream ) { if ( u2_frame_num != ps_dec -> u2_prv_frame_num && ps_dec -> u1_top_bottom_decoded != 0 && ps_dec -> u1_top_bottom_decoded != ( TOP_FIELD_ONLY | BOT_FIELD_ONLY ) ) { ps_dec -> u1_dangling_field = 1 ; if ( ps_dec -> u4_first_slice_in_pic ) { prev_slice_err = 1 ; } else { prev_slice_err = 2 ; } if ( ps_dec -> u1_top_bottom_decoded == TOP_FIELD_ONLY ) ps_cur_slice -> u1_bottom_field_flag = 1 ; else ps_cur_slice -> u1_bottom_field_flag = 0 ; num_mb_skipped = ( ps_dec -> u2_frm_ht_in_mbs * ps_dec -> u2_frm_wd_in_mbs ) - ps_dec -> u2_total_mbs_coded ; ps_cur_poc = & ps_dec -> s_cur_pic_poc ; u1_is_idr_slice = ps_cur_slice -> u1_nal_unit_type == IDR_SLICE_NAL ; } else if ( ps_dec -> u4_first_slice_in_pic == 2 ) { if ( u2_first_mb_in_slice > 0 ) { prev_slice_err = 1 ; num_mb_skipped = u2_first_mb_in_slice << u1_mbaff ; ps_cur_poc = & s_tmp_poc ; ps_cur_slice -> u4_idr_pic_id = u4_idr_pic_id ; ps_cur_slice -> u1_field_pic_flag = u1_field_pic_flag ; ps_cur_slice -> u1_bottom_field_flag = u1_bottom_field_flag ; ps_cur_slice -> i4_pic_order_cnt_lsb = s_tmp_poc . i4_pic_order_cnt_lsb ; ps_cur_slice -> u1_nal_unit_type = u1_nal_unit_type ; ps_cur_slice -> u1_redundant_pic_cnt = u1_redundant_pic_cnt ; ps_cur_slice -> u1_nal_ref_idc = u1_nal_ref_idc ; ps_cur_slice -> u1_pic_order_cnt_type = u1_pic_order_cnt_type ; } } else { if ( ps_dec -> u4_first_slice_in_pic ) { prev_slice_err = 1 ; num_mb_skipped = u2_first_mb_in_slice << u1_mbaff ; } else { prev_slice_err = 2 ; num_mb_skipped = ( ps_dec -> u2_frm_ht_in_mbs * ps_dec -> u2_frm_wd_in_mbs ) - ps_dec -> u2_total_mbs_coded ; } ps_cur_poc = & s_tmp_poc ; } } else { if ( ( u2_first_mb_in_slice << u1_mbaff ) > ps_dec -> u2_total_mbs_coded ) { prev_slice_err = 2 ; num_mb_skipped = ( u2_first_mb_in_slice << u1_mbaff ) - ps_dec -> u2_total_mbs_coded ; ps_cur_poc = & s_tmp_poc ; } else if ( ( u2_first_mb_in_slice << u1_mbaff ) < ps_dec -> u2_total_mbs_coded ) { return ERROR_CORRUPTED_SLICE ; } } if ( prev_slice_err ) { ret = ih264d_mark_err_slice_skip ( ps_dec , num_mb_skipped , u1_is_idr_slice , u2_frame_num , ps_cur_poc , prev_slice_err ) ; if ( ps_dec -> u1_dangling_field == 1 ) { ps_dec -> u1_second_field = 1 - ps_dec -> u1_second_field ; ps_cur_slice -> u1_bottom_field_flag = u1_bottom_field_flag ; ps_dec -> u2_prv_frame_num = u2_frame_num ; ps_dec -> u1_first_slice_in_stream = 0 ; return ERROR_DANGLING_FIELD_IN_PIC ; } if ( prev_slice_err == 2 ) { ps_dec -> u1_first_slice_in_stream = 0 ; return ERROR_INCOMPLETE_FRAME ; } if ( ps_dec -> u2_total_mbs_coded >= ps_dec -> u2_frm_ht_in_mbs * ps_dec -> u2_frm_wd_in_mbs ) { ps_dec -> u1_first_slice_in_stream = 0 ; return ERROR_IN_LAST_SLICE_OF_PIC ; } if ( ps_dec -> ps_dec_err_status -> u1_err_flag & REJECT_CUR_PIC ) { ih264d_err_pic_dispbuf_mgr ( ps_dec ) ; return ERROR_NEW_FRAME_EXPECTED ; } if ( ret != OK ) return ret ; i1_is_end_of_poc = 0 ; } if ( ps_dec -> u4_first_slice_in_pic == 0 ) ps_dec -> ps_parse_cur_slice ++ ; ps_dec -> u1_slice_header_done = 0 ; if ( ! ps_dec -> u1_first_slice_in_stream ) { UWORD8 uc_mbs_exceed = 0 ; if ( ps_dec -> u2_total_mbs_coded == ( ps_dec -> ps_cur_sps -> u2_max_mb_addr + 1 ) ) { if ( ps_dec -> u4_first_slice_in_pic == 0 ) uc_mbs_exceed = 1 ; } if ( i1_is_end_of_poc || uc_mbs_exceed ) { if ( 1 == ps_dec -> u1_last_pic_not_decoded ) { ret = ih264d_end_of_pic_dispbuf_mgr ( ps_dec ) ; if ( ret != OK ) return ret ; ret = ih264d_end_of_pic ( ps_dec , u1_is_idr_slice , u2_frame_num ) ; if ( ret != OK ) return ret ; # if WIN32 H264_DEC_DEBUG_PRINT ( ""------PICSKIPPED------\\n"" ) ; # endif return RET_LAST_SKIP ; } else { ret = ih264d_end_of_pic ( ps_dec , u1_is_idr_slice , u2_frame_num ) ; if ( ret != OK ) return ret ; } } } if ( u1_field_pic_flag ) { ps_dec -> u2_prv_frame_num = u2_frame_num ; } if ( ps_cur_slice -> u1_mmco_equalto5 ) { WORD32 i4_temp_poc ; WORD32 i4_top_field_order_poc , i4_bot_field_order_poc ; if ( ! ps_cur_slice -> u1_field_pic_flag ) { 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 ) ; } else if ( ! ps_cur_slice -> u1_bottom_field_flag ) i4_temp_poc = ps_dec -> ps_cur_pic -> i4_top_field_order_cnt ; else i4_temp_poc = ps_dec -> ps_cur_pic -> i4_bottom_field_order_cnt ; ps_dec -> ps_cur_pic -> i4_top_field_order_cnt = i4_temp_poc - ps_dec -> ps_cur_pic -> i4_top_field_order_cnt ; ps_dec -> ps_cur_pic -> i4_bottom_field_order_cnt = i4_temp_poc - ps_dec -> ps_cur_pic -> i4_bottom_field_order_cnt ; ps_dec -> ps_cur_pic -> i4_poc = i4_temp_poc ; ps_dec -> ps_cur_pic -> i4_avg_poc = i4_temp_poc ; } if ( ps_dec -> u4_first_slice_in_pic == 2 ) { ret = ih264d_decode_pic_order_cnt ( u1_is_idr_slice , u2_frame_num , & ps_dec -> s_prev_pic_poc , & s_tmp_poc , ps_cur_slice , ps_pps , u1_nal_ref_idc , u1_bottom_field_flag , u1_field_pic_flag , & i4_poc ) ; if ( ret != OK ) return ret ; if ( i4_poc >= ps_dec -> i4_max_poc ) ps_dec -> i4_max_poc = i4_poc ; if ( i4_poc == 0 ) { ps_dec -> i4_prev_max_display_seq = ps_dec -> i4_prev_max_display_seq + ps_dec -> i4_max_poc + ps_dec -> u1_max_dec_frame_buffering + 1 ; ps_dec -> i4_max_poc = 0 ; } } ps_cur_slice -> i4_delta_pic_order_cnt [ 0 ] = i_delta_poc [ 0 ] ; ps_cur_slice -> i4_delta_pic_order_cnt [ 1 ] = i_delta_poc [ 1 ] ; ps_cur_slice -> u4_idr_pic_id = u4_idr_pic_id ; ps_cur_slice -> u2_first_mb_in_slice = u2_first_mb_in_slice ; ps_cur_slice -> u1_field_pic_flag = u1_field_pic_flag ; ps_cur_slice -> u1_bottom_field_flag = u1_bottom_field_flag ; ps_cur_slice -> u1_slice_type = u1_slice_type ; ps_cur_slice -> i4_pic_order_cnt_lsb = s_tmp_poc . i4_pic_order_cnt_lsb ; ps_cur_slice -> u1_nal_unit_type = u1_nal_unit_type ; ps_cur_slice -> u1_redundant_pic_cnt = u1_redundant_pic_cnt ; ps_cur_slice -> u1_nal_ref_idc = u1_nal_ref_idc ; ps_cur_slice -> u1_pic_order_cnt_type = u1_pic_order_cnt_type ; if ( ps_seq -> u1_frame_mbs_only_flag ) ps_cur_slice -> u1_direct_8x8_inference_flag = ps_seq -> u1_direct_8x8_inference_flag ; else ps_cur_slice -> u1_direct_8x8_inference_flag = 1 ; if ( u1_slice_type == B_SLICE ) { ps_cur_slice -> u1_direct_spatial_mv_pred_flag = ih264d_get_bit_h264 ( ps_bitstrm ) ; COPYTHECONTEXT ( ""SH:direct_spatial_mv_pred_flag"" , ps_cur_slice -> u1_direct_spatial_mv_pred_flag ) ; if ( ps_cur_slice -> u1_direct_spatial_mv_pred_flag ) ps_cur_slice -> pf_decodeDirect = ih264d_decode_spatial_direct ; else ps_cur_slice -> pf_decodeDirect = ih264d_decode_temporal_direct ; if ( ! ( ( ps_pps -> ps_sps -> u1_mb_aff_flag ) && ( ! u1_field_pic_flag ) ) ) ps_dec -> pf_mvpred = ih264d_mvpred_nonmbaffB ; } else { if ( ! ( ( ps_pps -> ps_sps -> u1_mb_aff_flag ) && ( ! u1_field_pic_flag ) ) ) ps_dec -> pf_mvpred = ih264d_mvpred_nonmbaff ; } if ( ps_dec -> u4_first_slice_in_pic == 2 ) { if ( u2_first_mb_in_slice == 0 ) { ret = ih264d_start_of_pic ( ps_dec , i4_poc , & s_tmp_poc , u2_frame_num , ps_pps ) ; if ( ret != OK ) return ret ; } 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 ; } } } { UWORD8 uc_nofield_nombaff ; uc_nofield_nombaff = ( ( ps_dec -> ps_cur_slice -> u1_field_pic_flag == 0 ) && ( ps_dec -> ps_cur_slice -> u1_mbaff_frame_flag == 0 ) && ( u1_slice_type != B_SLICE ) && ( ps_dec -> ps_cur_pps -> u1_wted_pred_flag == 0 ) ) ; if ( uc_nofield_nombaff ) { ps_dec -> p_form_mb_part_info = ih264d_form_mb_part_info_bp ; ps_dec -> p_motion_compensate = ih264d_motion_compensate_bp ; } else { ps_dec -> p_form_mb_part_info = ih264d_form_mb_part_info_mp ; ps_dec -> p_motion_compensate = ih264d_motion_compensate_mp ; } } { dec_err_status_t * ps_err = ps_dec -> ps_dec_err_status ; if ( ps_err -> u4_frm_sei_sync == u2_frame_num ) { ps_err -> u1_err_flag = ACCEPT_ALL_PICS ; ps_err -> u4_frm_sei_sync = SYNC_FRM_DEFAULT ; } ps_err -> u4_cur_frm = u2_frame_num ; } { WORD32 i4_skip_b_pic , i4_skip_p_pic ; i4_skip_b_pic = ( ps_dec -> u4_skip_frm_mask & B_SLC_BIT ) && ( B_SLICE == u1_slice_type ) && ( 0 == u1_nal_ref_idc ) ; i4_skip_p_pic = ( ps_dec -> u4_skip_frm_mask & P_SLC_BIT ) && ( P_SLICE == u1_slice_type ) && ( 0 == u1_nal_ref_idc ) ; if ( i4_skip_b_pic ) { ps_dec -> ps_cur_pic -> u4_pack_slc_typ |= B_SLC_BIT ; ps_dec -> u1_last_pic_not_decoded = 1 ; return OK ; } if ( i4_skip_p_pic ) { ps_dec -> ps_cur_pic -> u4_pack_slc_typ |= P_SLC_BIT ; ps_dec -> u1_last_pic_not_decoded = 1 ; return OK ; } } { UWORD16 u2_mb_x , u2_mb_y ; ps_dec -> i4_submb_ofst = ( ( u2_first_mb_in_slice << ps_cur_slice -> u1_mbaff_frame_flag ) * SUB_BLK_SIZE ) - SUB_BLK_SIZE ; if ( u2_first_mb_in_slice ) { UWORD8 u1_mb_aff ; UWORD8 u1_field_pic ; UWORD16 u2_frm_wd_in_mbs ; u2_frm_wd_in_mbs = ps_seq -> u2_frm_wd_in_mbs ; u1_mb_aff = ps_cur_slice -> u1_mbaff_frame_flag ; u1_field_pic = ps_cur_slice -> u1_field_pic_flag ; { UWORD32 x_offset ; UWORD32 y_offset ; UWORD32 u4_frame_stride ; tfr_ctxt_t * ps_trns_addr ; if ( ps_dec -> u1_separate_parse ) { ps_trns_addr = & ps_dec -> s_tran_addrecon_parse ; } else { ps_trns_addr = & ps_dec -> s_tran_addrecon ; } u2_mb_x = MOD ( u2_first_mb_in_slice , u2_frm_wd_in_mbs ) ; u2_mb_y = DIV ( u2_first_mb_in_slice , u2_frm_wd_in_mbs ) ; u2_mb_y <<= u1_mb_aff ; if ( ( u2_mb_x > u2_frm_wd_in_mbs - 1 ) || ( u2_mb_y > ps_dec -> u2_frm_ht_in_mbs - 1 ) ) { return ERROR_CORRUPTED_SLICE ; } u4_frame_stride = ps_dec -> u2_frm_wd_y << u1_field_pic ; x_offset = u2_mb_x << 4 ; y_offset = ( u2_mb_y * u4_frame_stride ) << 4 ; ps_trns_addr -> pu1_dest_y = ps_dec -> s_cur_pic . pu1_buf1 + x_offset + y_offset ; u4_frame_stride = ps_dec -> u2_frm_wd_uv << u1_field_pic ; x_offset >>= 1 ; y_offset = ( u2_mb_y * u4_frame_stride ) << 3 ; x_offset *= YUV420SP_FACTOR ; ps_trns_addr -> pu1_dest_u = ps_dec -> s_cur_pic . pu1_buf2 + x_offset + y_offset ; ps_trns_addr -> pu1_dest_v = ps_dec -> s_cur_pic . pu1_buf3 + x_offset + y_offset ; ps_trns_addr -> pu1_mb_y = ps_trns_addr -> pu1_dest_y ; ps_trns_addr -> pu1_mb_u = ps_trns_addr -> pu1_dest_u ; ps_trns_addr -> pu1_mb_v = ps_trns_addr -> pu1_dest_v ; if ( ps_dec -> u1_separate_parse == 1 ) { ps_dec -> ps_deblk_mbn = ps_dec -> ps_deblk_pic + ( u2_first_mb_in_slice << u1_mb_aff ) ; } else { ps_dec -> ps_deblk_mbn = ps_dec -> ps_deblk_pic + ( u2_first_mb_in_slice << u1_mb_aff ) ; } ps_dec -> u2_cur_mb_addr = ( u2_first_mb_in_slice << u1_mb_aff ) ; ps_dec -> ps_mv_cur = ps_dec -> s_cur_pic . ps_mv + ( ( u2_first_mb_in_slice << u1_mb_aff ) << 4 ) ; } } else { tfr_ctxt_t * ps_trns_addr ; if ( ps_dec -> u1_separate_parse ) { ps_trns_addr = & ps_dec -> s_tran_addrecon_parse ; } else { ps_trns_addr = & ps_dec -> s_tran_addrecon ; } u2_mb_x = 0xffff ; u2_mb_y = 0 ; ps_dec -> u2_cur_mb_addr = 0 ; ps_dec -> ps_deblk_mbn = ps_dec -> ps_deblk_pic ; ps_dec -> ps_mv_cur = ps_dec -> s_cur_pic . ps_mv ; ps_trns_addr -> pu1_dest_y = ps_dec -> s_cur_pic . pu1_buf1 ; ps_trns_addr -> pu1_dest_u = ps_dec -> s_cur_pic . pu1_buf2 ; ps_trns_addr -> pu1_dest_v = ps_dec -> s_cur_pic . pu1_buf3 ; ps_trns_addr -> pu1_mb_y = ps_trns_addr -> pu1_dest_y ; ps_trns_addr -> pu1_mb_u = ps_trns_addr -> pu1_dest_u ; ps_trns_addr -> pu1_mb_v = ps_trns_addr -> pu1_dest_v ; } ps_dec -> ps_part = ps_dec -> ps_parse_part_params ; ps_dec -> u2_mbx = ( MOD ( u2_first_mb_in_slice - 1 , ps_seq -> u2_frm_wd_in_mbs ) ) ; ps_dec -> u2_mby = ( DIV ( u2_first_mb_in_slice - 1 , ps_seq -> u2_frm_wd_in_mbs ) ) ; ps_dec -> u2_mby <<= ps_cur_slice -> u1_mbaff_frame_flag ; ps_dec -> i2_prev_slice_mbx = ps_dec -> u2_mbx ; ps_dec -> i2_prev_slice_mby = ps_dec -> u2_mby ; } ps_bitstrm -> u4_max_ofst += ps_dec -> ps_cur_pps -> u1_entropy_coding_mode ; ps_dec -> u1_B = ( u1_slice_type == B_SLICE ) ; ps_dec -> u4_next_mb_skip = 0 ; ps_dec -> ps_parse_cur_slice -> u4_first_mb_in_slice = ps_dec -> ps_cur_slice -> u2_first_mb_in_slice ; ps_dec -> ps_parse_cur_slice -> slice_type = ps_dec -> ps_cur_slice -> u1_slice_type ; ps_dec -> u4_start_recon_deblk = 1 ; { 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 = ( void * ) pu1_buf ; } 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 ; } ps_dec -> pu4_wt_ofsts = ps_dec -> pu4_wts_ofsts_mat ; if ( u1_slice_type == I_SLICE ) { ps_dec -> ps_cur_pic -> u4_pack_slc_typ |= I_SLC_BIT ; ret = ih264d_parse_islice ( ps_dec , u2_first_mb_in_slice ) ; if ( ps_dec -> i4_pic_type != B_SLICE && ps_dec -> i4_pic_type != P_SLICE ) ps_dec -> i4_pic_type = I_SLICE ; } else if ( u1_slice_type == P_SLICE ) { ps_dec -> ps_cur_pic -> u4_pack_slc_typ |= P_SLC_BIT ; ret = ih264d_parse_pslice ( ps_dec , u2_first_mb_in_slice ) ; ps_dec -> u1_pr_sl_type = u1_slice_type ; if ( ps_dec -> i4_pic_type != B_SLICE ) ps_dec -> i4_pic_type = P_SLICE ; } else if ( u1_slice_type == B_SLICE ) { ps_dec -> ps_cur_pic -> u4_pack_slc_typ |= B_SLC_BIT ; ret = ih264d_parse_bslice ( ps_dec , u2_first_mb_in_slice ) ; ps_dec -> u1_pr_sl_type = u1_slice_type ; ps_dec -> i4_pic_type = B_SLICE ; } else return ERROR_INV_SLC_TYPE_T ; if ( ps_dec -> u1_slice_header_done ) { ps_dec -> u4_first_slice_in_pic = 0 ; ps_dec -> u1_first_slice_in_stream = 0 ; } if ( ret != OK ) return ret ; 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 ; if ( ps_dec -> u2_total_mbs_coded >= ( ps_seq -> u2_max_mb_addr + 1 ) ) { ps_dec -> u1_pic_decode_done = 1 ; } { dec_err_status_t * ps_err = ps_dec -> ps_dec_err_status ; if ( ( ps_err -> u1_err_flag & REJECT_PB_PICS ) && ( ps_err -> u1_cur_pic_type == PIC_TYPE_I ) ) { ps_err -> u1_err_flag = ACCEPT_ALL_PICS ; } } PRINT_BIN_BIT_RATIO ( ps_dec ) return ret ; } "," pv_parse_tu_coeff_data ; } if ( u1_slice_type ",external@libavc/e629194c62a9a129ce378e08cb1059a8a53f1795,CVE-2016-3741,https://android.googlesource.com/platform/external/libavc/+/e629194c62a9a129ce378e08cb1059a8a53f1795,2016-07-11T01:59Z 849,CWE-119,"CWE-119 static int mov_read_dref ( MOVContext * c , AVIOContext * pb , MOVAtom atom ) { AVStream * st ; MOVStreamContext * sc ; int entries , i , j ; if ( c -> fc -> nb_streams < 1 ) return 0 ; st = c -> fc -> streams [ c -> fc -> nb_streams - 1 ] ; sc = st -> priv_data ; avio_rb32 ( pb ) ; entries = avio_rb32 ( pb ) ; if ( entries >= UINT_MAX / sizeof ( * sc -> drefs ) ) return AVERROR_INVALIDDATA ; av_free ( sc -> drefs ) ; sc -> drefs = av_mallocz ( entries * sizeof ( * sc -> drefs ) ) ; if ( ! sc -> drefs ) return AVERROR ( ENOMEM ) ; sc -> drefs_count = entries ; for ( i = 0 ; i < sc -> drefs_count ; i ++ ) { MOVDref * dref = & sc -> drefs [ i ] ; uint32_t size = avio_rb32 ( pb ) ; int64_t next = avio_tell ( pb ) + size - 4 ; if ( size < 12 ) return AVERROR_INVALIDDATA ; dref -> type = avio_rl32 ( pb ) ; avio_rb32 ( pb ) ; av_dlog ( c -> fc , ""type%.4ssize%d\\n"" , ( char * ) & dref -> type , size ) ; if ( dref -> type == MKTAG ( 'a' , 'l' , 'i' , 's' ) && size > 150 ) { uint16_t volume_len , len ; int16_t type ; avio_skip ( pb , 10 ) ; volume_len = avio_r8 ( pb ) ; volume_len = FFMIN ( volume_len , 27 ) ; avio_read ( pb , dref -> volume , 27 ) ; dref -> volume [ volume_len ] = 0 ; av_log ( c -> fc , AV_LOG_DEBUG , ""volume%s,len%d\\n"" , dref -> volume , volume_len ) ; avio_skip ( pb , 12 ) ; len = avio_r8 ( pb ) ; len = FFMIN ( len , 63 ) ; avio_read ( pb , dref -> filename , 63 ) ; dref -> filename [ len ] = 0 ; av_log ( c -> fc , AV_LOG_DEBUG , ""filename%s,len%d\\n"" , dref -> filename , len ) ; avio_skip ( pb , 16 ) ; dref -> nlvl_from = avio_rb16 ( pb ) ; dref -> nlvl_to = avio_rb16 ( pb ) ; av_log ( c -> fc , AV_LOG_DEBUG , ""nlvlfrom%d,nlvlto%d\\n"" , dref -> nlvl_from , dref -> nlvl_to ) ; avio_skip ( pb , 16 ) ; for ( type = 0 ; type != - 1 && avio_tell ( pb ) < next ; ) { if ( url_feof ( pb ) ) return AVERROR_EOF ; type = avio_rb16 ( pb ) ; len = avio_rb16 ( pb ) ; av_log ( c -> fc , AV_LOG_DEBUG , ""type%d,len%d\\n"" , type , len ) ; if ( len & 1 ) len += 1 ; if ( type == 2 ) { av_free ( dref -> path ) ; dref -> path = av_mallocz ( len + 1 ) ; if ( ! dref -> path ) return AVERROR ( ENOMEM ) ; avio_read ( pb , dref -> path , len ) ; if ( len > volume_len && ! strncmp ( dref -> path , dref -> volume , volume_len ) ) { len -= volume_len ; memmove ( dref -> path , dref -> path + volume_len , len ) ; dref -> path [ len ] = 0 ; } for ( j = 0 ; j < len ; j ++ ) if ( dref -> path [ j ] == ':' ) dref -> path [ j ] = '/' ; av_log ( c -> fc , AV_LOG_DEBUG , ""path%s\\n"" , dref -> path ) ; } else if ( type == 0 ) { av_free ( dref -> dir ) ; dref -> dir = av_malloc ( len + 1 ) ; if ( ! dref -> dir ) return AVERROR ( ENOMEM ) ; avio_read ( pb , dref -> dir , len ) ; dref -> dir [ len ] = 0 ; for ( j = 0 ; j < len ; j ++ ) if ( dref -> dir [ j ] == ':' ) dref -> dir [ j ] = '/' ; av_log ( c -> fc , AV_LOG_DEBUG , ""dir%s\\n"" , dref -> dir ) ; } else avio_skip ( pb , len ) ; } } avio_seek ( pb , next , SEEK_SET ) ; } return 0 ; } "," ; sc -> drefs_count = 0 ; sc -> ",FFmpeg@FFmpeg/689e59b7ffed34eba6159dcc78e87133862e3746,CVE-2016-3062,https://github.com/FFmpeg/FFmpeg/commit/689e59b7ffed34eba6159dcc78e87133862e3746,2016-06-16T18:59Z 850,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 851,CWE-119,"CWE-119 void vp8mt_decode_mb_rows ( VP8D_COMP * pbi , MACROBLOCKD * xd ) { VP8_COMMON * pc = & pbi -> common ; unsigned int i ; int j ; int filter_level = pc -> filter_level ; YV12_BUFFER_CONFIG * yv12_fb_new = pbi -> dec_fb_ref [ INTRA_FRAME ] ; if ( filter_level ) { vpx_memset ( pbi -> mt_yabove_row [ 0 ] + VP8BORDERINPIXELS - 1 , 127 , yv12_fb_new -> y_width + 5 ) ; vpx_memset ( pbi -> mt_uabove_row [ 0 ] + ( VP8BORDERINPIXELS >> 1 ) - 1 , 127 , ( yv12_fb_new -> y_width >> 1 ) + 5 ) ; vpx_memset ( pbi -> mt_vabove_row [ 0 ] + ( VP8BORDERINPIXELS >> 1 ) - 1 , 127 , ( yv12_fb_new -> y_width >> 1 ) + 5 ) ; for ( j = 1 ; j < pc -> mb_rows ; j ++ ) { vpx_memset ( pbi -> mt_yabove_row [ j ] + VP8BORDERINPIXELS - 1 , ( unsigned char ) 129 , 1 ) ; vpx_memset ( pbi -> mt_uabove_row [ j ] + ( VP8BORDERINPIXELS >> 1 ) - 1 , ( unsigned char ) 129 , 1 ) ; vpx_memset ( pbi -> mt_vabove_row [ j ] + ( VP8BORDERINPIXELS >> 1 ) - 1 , ( unsigned char ) 129 , 1 ) ; } for ( j = 0 ; j < pc -> mb_rows ; j ++ ) { vpx_memset ( pbi -> mt_yleft_col [ j ] , ( unsigned char ) 129 , 16 ) ; vpx_memset ( pbi -> mt_uleft_col [ j ] , ( unsigned char ) 129 , 8 ) ; vpx_memset ( pbi -> mt_vleft_col [ j ] , ( unsigned char ) 129 , 8 ) ; } vp8_loop_filter_frame_init ( pc , & pbi -> mb , filter_level ) ; } else vp8_setup_intra_recon_top_line ( yv12_fb_new ) ; setup_decoding_thread_data ( pbi , xd , pbi -> mb_row_di , pbi -> decoding_thread_count ) ; for ( i = 0 ; i < pbi -> decoding_thread_count ; i ++ ) sem_post ( & pbi -> h_event_start_decoding [ i ] ) ; mt_decode_mb_rows ( pbi , xd , 0 ) ; sem_wait ( & pbi -> h_event_end_decoding ) ; } "," filter_level ) { memset ( pbi -> 5 ) ; memset ( pbi -> 5 ) ; memset ( pbi -> ++ ) { memset ( pbi -> 1 ) ; memset ( pbi -> 1 ) ; memset ( pbi -> ++ ) { memset ( pbi -> 16 ) ; memset ( pbi -> 8 ) ; memset ( pbi -> ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 852,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 853,CWE-119,"CWE-119 static inline int object_common2 ( UNSERIALIZE_PARAMETER , long elements ) { zval * retval_ptr = NULL ; zval fname ; if ( Z_TYPE_PP ( rval ) != IS_OBJECT ) { return 0 ; } if ( ! process_nested_data ( UNSERIALIZE_PASSTHRU , Z_OBJPROP_PP ( rval ) , elements , 1 ) ) { if ( Z_TYPE_PP ( rval ) == IS_OBJECT ) { zend_hash_clean ( Z_OBJPROP_PP ( rval ) ) ; } ZVAL_NULL ( * rval ) ; return 0 ; } if ( Z_TYPE_PP ( rval ) != IS_OBJECT ) { return 0 ; } if ( Z_OBJCE_PP ( rval ) != PHP_IC_ENTRY && zend_hash_exists ( & Z_OBJCE_PP ( rval ) -> function_table , ""__wakeup"" , sizeof ( ""__wakeup"" ) ) ) { INIT_PZVAL ( & fname ) ; ZVAL_STRINGL ( & fname , ""__wakeup"" , sizeof ( ""__wakeup"" ) - 1 , 0 ) ; BG ( serialize_lock ) ++ ; call_user_function_ex ( CG ( function_table ) , rval , & fname , & retval_ptr , 0 , 0 , 1 , NULL TSRMLS_CC ) ; BG ( serialize_lock ) -- ; } if ( retval_ptr ) { zval_ptr_dtor ( & retval_ptr ) ; } if ( EG ( exception ) ) { return 0 ; } return finish_nested_data ( UNSERIALIZE_PASSTHRU ) ; } "," ) ) ; zend_object_store_ctor_failed ( * rval TSRMLS_CC ) ; ",php@php-src/6a7cc8ff85827fa9ac715b3a83c2d9147f33cd43,CVE-2016-7411,https://github.com/php/php-src/commit/6a7cc8ff85827fa9ac715b3a83c2d9147f33cd43?w=1,2016-09-17T21:59Z 854,CWE-125,"CWE-125 int yyparse ( void * yyscanner , YR_COMPILER * compiler ) { 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 , compiler ) ; } 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 8 : # line 230 ""grammar.y"" { int result = yr_parser_reduce_import ( yyscanner , ( yyvsp [ 0 ] . sized_string ) ) ; yr_free ( ( yyvsp [ 0 ] . sized_string ) ) ; ERROR_IF ( result != ERROR_SUCCESS ) ; } # line 1661 ""grammar.c"" break ; case 9 : # line 242 ""grammar.y"" { YR_RULE * rule = yr_parser_reduce_rule_declaration_phase_1 ( yyscanner , ( int32_t ) ( yyvsp [ - 2 ] . integer ) , ( yyvsp [ 0 ] . c_string ) ) ; ERROR_IF ( rule == NULL ) ; ( yyval . rule ) = rule ; } # line 1674 ""grammar.c"" break ; case 10 : # line 251 ""grammar.y"" { YR_RULE * rule = ( yyvsp [ - 4 ] . rule ) ; rule -> tags = ( yyvsp [ - 3 ] . c_string ) ; rule -> metas = ( yyvsp [ - 1 ] . meta ) ; rule -> strings = ( yyvsp [ 0 ] . string ) ; } # line 1686 ""grammar.c"" break ; case 11 : # line 259 ""grammar.y"" { YR_RULE * rule = ( yyvsp [ - 7 ] . rule ) ; compiler -> last_result = yr_parser_reduce_rule_declaration_phase_2 ( yyscanner , rule ) ; yr_free ( ( yyvsp [ - 8 ] . c_string ) ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; } # line 1701 ""grammar.c"" break ; case 12 : # line 274 ""grammar.y"" { ( yyval . meta ) = NULL ; } # line 1709 ""grammar.c"" break ; case 13 : # line 278 ""grammar.y"" { YR_META null_meta ; memset ( & null_meta , 0xFF , sizeof ( YR_META ) ) ; null_meta . type = META_TYPE_NULL ; compiler -> last_result = yr_arena_write_data ( compiler -> metas_arena , & null_meta , sizeof ( YR_META ) , NULL ) ; ( yyval . meta ) = ( yyvsp [ 0 ] . meta ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; } # line 1736 ""grammar.c"" break ; case 14 : # line 305 ""grammar.y"" { ( yyval . string ) = NULL ; } # line 1744 ""grammar.c"" break ; case 15 : # line 309 ""grammar.y"" { YR_STRING null_string ; memset ( & null_string , 0xFF , sizeof ( YR_STRING ) ) ; null_string . g_flags = STRING_GFLAGS_NULL ; compiler -> last_result = yr_arena_write_data ( compiler -> strings_arena , & null_string , sizeof ( YR_STRING ) , NULL ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; ( yyval . string ) = ( yyvsp [ 0 ] . string ) ; } # line 1771 ""grammar.c"" break ; case 17 : # line 340 ""grammar.y"" { ( yyval . integer ) = 0 ; } # line 1777 ""grammar.c"" break ; case 18 : # line 341 ""grammar.y"" { ( yyval . integer ) = ( yyvsp [ - 1 ] . integer ) | ( yyvsp [ 0 ] . integer ) ; } # line 1783 ""grammar.c"" break ; case 19 : # line 346 ""grammar.y"" { ( yyval . integer ) = RULE_GFLAGS_PRIVATE ; } # line 1789 ""grammar.c"" break ; case 20 : # line 347 ""grammar.y"" { ( yyval . integer ) = RULE_GFLAGS_GLOBAL ; } # line 1795 ""grammar.c"" break ; case 21 : # line 353 ""grammar.y"" { ( yyval . c_string ) = NULL ; } # line 1803 ""grammar.c"" break ; case 22 : # line 357 ""grammar.y"" { compiler -> last_result = yr_arena_write_string ( yyget_extra ( yyscanner ) -> sz_arena , """" , NULL ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; ( yyval . c_string ) = ( yyvsp [ 0 ] . c_string ) ; } # line 1821 ""grammar.c"" break ; case 23 : # line 375 ""grammar.y"" { char * identifier ; compiler -> last_result = yr_arena_write_string ( yyget_extra ( yyscanner ) -> sz_arena , ( yyvsp [ 0 ] . c_string ) , & identifier ) ; yr_free ( ( yyvsp [ 0 ] . c_string ) ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; ( yyval . c_string ) = identifier ; } # line 1838 ""grammar.c"" break ; case 24 : # line 388 ""grammar.y"" { char * tag_name = ( yyvsp [ - 1 ] . c_string ) ; size_t tag_length = tag_name != NULL ? strlen ( tag_name ) : 0 ; while ( tag_length > 0 ) { if ( strcmp ( tag_name , ( yyvsp [ 0 ] . c_string ) ) == 0 ) { yr_compiler_set_error_extra_info ( compiler , tag_name ) ; compiler -> last_result = ERROR_DUPLICATED_TAG_IDENTIFIER ; break ; } tag_name = ( char * ) yr_arena_next_address ( yyget_extra ( yyscanner ) -> sz_arena , tag_name , tag_length + 1 ) ; tag_length = tag_name != NULL ? strlen ( tag_name ) : 0 ; } if ( compiler -> last_result == ERROR_SUCCESS ) compiler -> last_result = yr_arena_write_string ( yyget_extra ( yyscanner ) -> sz_arena , ( yyvsp [ 0 ] . c_string ) , NULL ) ; yr_free ( ( yyvsp [ 0 ] . c_string ) ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; ( yyval . c_string ) = ( yyvsp [ - 1 ] . c_string ) ; } # line 1874 ""grammar.c"" break ; case 25 : # line 424 ""grammar.y"" { ( yyval . meta ) = ( yyvsp [ 0 ] . meta ) ; } # line 1880 ""grammar.c"" break ; case 26 : # line 425 ""grammar.y"" { ( yyval . meta ) = ( yyvsp [ - 1 ] . meta ) ; } # line 1886 ""grammar.c"" break ; case 27 : # line 431 ""grammar.y"" { SIZED_STRING * sized_string = ( yyvsp [ 0 ] . sized_string ) ; ( yyval . meta ) = yr_parser_reduce_meta_declaration ( yyscanner , META_TYPE_STRING , ( yyvsp [ - 2 ] . c_string ) , sized_string -> c_string , 0 ) ; yr_free ( ( yyvsp [ - 2 ] . c_string ) ) ; yr_free ( ( yyvsp [ 0 ] . sized_string ) ) ; ERROR_IF ( ( yyval . meta ) == NULL ) ; } # line 1906 ""grammar.c"" break ; case 28 : # line 447 ""grammar.y"" { ( yyval . meta ) = yr_parser_reduce_meta_declaration ( yyscanner , META_TYPE_INTEGER , ( yyvsp [ - 2 ] . c_string ) , NULL , ( yyvsp [ 0 ] . integer ) ) ; yr_free ( ( yyvsp [ - 2 ] . c_string ) ) ; ERROR_IF ( ( yyval . meta ) == NULL ) ; } # line 1923 ""grammar.c"" break ; case 29 : # line 460 ""grammar.y"" { ( yyval . meta ) = yr_parser_reduce_meta_declaration ( yyscanner , META_TYPE_INTEGER , ( yyvsp [ - 3 ] . c_string ) , NULL , - ( yyvsp [ 0 ] . integer ) ) ; yr_free ( ( yyvsp [ - 3 ] . c_string ) ) ; ERROR_IF ( ( yyval . meta ) == NULL ) ; } # line 1940 ""grammar.c"" break ; case 30 : # line 473 ""grammar.y"" { ( yyval . meta ) = yr_parser_reduce_meta_declaration ( yyscanner , META_TYPE_BOOLEAN , ( yyvsp [ - 2 ] . c_string ) , NULL , TRUE ) ; yr_free ( ( yyvsp [ - 2 ] . c_string ) ) ; ERROR_IF ( ( yyval . meta ) == NULL ) ; } # line 1957 ""grammar.c"" break ; case 31 : # line 486 ""grammar.y"" { ( yyval . meta ) = yr_parser_reduce_meta_declaration ( yyscanner , META_TYPE_BOOLEAN , ( yyvsp [ - 2 ] . c_string ) , NULL , FALSE ) ; yr_free ( ( yyvsp [ - 2 ] . c_string ) ) ; ERROR_IF ( ( yyval . meta ) == NULL ) ; } # line 1974 ""grammar.c"" break ; case 32 : # line 502 ""grammar.y"" { ( yyval . string ) = ( yyvsp [ 0 ] . string ) ; } # line 1980 ""grammar.c"" break ; case 33 : # line 503 ""grammar.y"" { ( yyval . string ) = ( yyvsp [ - 1 ] . string ) ; } # line 1986 ""grammar.c"" break ; case 34 : # line 509 ""grammar.y"" { compiler -> error_line = yyget_lineno ( yyscanner ) ; } # line 1994 ""grammar.c"" break ; case 35 : # line 513 ""grammar.y"" { ( yyval . string ) = yr_parser_reduce_string_declaration ( yyscanner , ( int32_t ) ( yyvsp [ 0 ] . integer ) , ( yyvsp [ - 4 ] . c_string ) , ( yyvsp [ - 1 ] . sized_string ) ) ; yr_free ( ( yyvsp [ - 4 ] . c_string ) ) ; yr_free ( ( yyvsp [ - 1 ] . sized_string ) ) ; ERROR_IF ( ( yyval . string ) == NULL ) ; compiler -> error_line = 0 ; } # line 2009 ""grammar.c"" break ; case 36 : # line 524 ""grammar.y"" { compiler -> error_line = yyget_lineno ( yyscanner ) ; } # line 2017 ""grammar.c"" break ; case 37 : # line 528 ""grammar.y"" { ( yyval . string ) = yr_parser_reduce_string_declaration ( yyscanner , ( int32_t ) ( yyvsp [ 0 ] . integer ) | STRING_GFLAGS_REGEXP , ( yyvsp [ - 4 ] . c_string ) , ( yyvsp [ - 1 ] . sized_string ) ) ; yr_free ( ( yyvsp [ - 4 ] . c_string ) ) ; yr_free ( ( yyvsp [ - 1 ] . sized_string ) ) ; ERROR_IF ( ( yyval . string ) == NULL ) ; compiler -> error_line = 0 ; } # line 2033 ""grammar.c"" break ; case 38 : # line 540 ""grammar.y"" { ( yyval . string ) = yr_parser_reduce_string_declaration ( yyscanner , STRING_GFLAGS_HEXADECIMAL , ( yyvsp [ - 2 ] . c_string ) , ( yyvsp [ 0 ] . sized_string ) ) ; yr_free ( ( yyvsp [ - 2 ] . c_string ) ) ; yr_free ( ( yyvsp [ 0 ] . sized_string ) ) ; ERROR_IF ( ( yyval . string ) == NULL ) ; } # line 2047 ""grammar.c"" break ; case 39 : # line 553 ""grammar.y"" { ( yyval . integer ) = 0 ; } # line 2053 ""grammar.c"" break ; case 40 : # line 554 ""grammar.y"" { ( yyval . integer ) = ( yyvsp [ - 1 ] . integer ) | ( yyvsp [ 0 ] . integer ) ; } # line 2059 ""grammar.c"" break ; case 41 : # line 559 ""grammar.y"" { ( yyval . integer ) = STRING_GFLAGS_WIDE ; } # line 2065 ""grammar.c"" break ; case 42 : # line 560 ""grammar.y"" { ( yyval . integer ) = STRING_GFLAGS_ASCII ; } # line 2071 ""grammar.c"" break ; case 43 : # line 561 ""grammar.y"" { ( yyval . integer ) = STRING_GFLAGS_NO_CASE ; } # line 2077 ""grammar.c"" break ; case 44 : # line 562 ""grammar.y"" { ( yyval . integer ) = STRING_GFLAGS_FULL_WORD ; } # line 2083 ""grammar.c"" break ; case 45 : # line 568 ""grammar.y"" { int var_index = yr_parser_lookup_loop_variable ( yyscanner , ( yyvsp [ 0 ] . c_string ) ) ; if ( var_index >= 0 ) { compiler -> last_result = yr_parser_emit_with_arg ( yyscanner , OP_PUSH_M , LOOP_LOCAL_VARS * var_index , NULL , NULL ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_INTEGER ; ( yyval . expression ) . value . integer = UNDEFINED ; ( yyval . expression ) . identifier = compiler -> loop_identifier [ var_index ] ; } else { YR_OBJECT * object = ( YR_OBJECT * ) yr_hash_table_lookup ( compiler -> objects_table , ( yyvsp [ 0 ] . c_string ) , NULL ) ; if ( object == NULL ) { char * ns = compiler -> current_namespace -> name ; object = ( YR_OBJECT * ) yr_hash_table_lookup ( compiler -> objects_table , ( yyvsp [ 0 ] . c_string ) , ns ) ; } if ( object != NULL ) { char * id ; compiler -> last_result = yr_arena_write_string ( compiler -> sz_arena , ( yyvsp [ 0 ] . c_string ) , & id ) ; if ( compiler -> last_result == ERROR_SUCCESS ) compiler -> last_result = yr_parser_emit_with_arg_reloc ( yyscanner , OP_OBJ_LOAD , id , NULL , NULL ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_OBJECT ; ( yyval . expression ) . value . object = object ; ( yyval . expression ) . identifier = object -> identifier ; } else { YR_RULE * rule = ( YR_RULE * ) yr_hash_table_lookup ( compiler -> rules_table , ( yyvsp [ 0 ] . c_string ) , compiler -> current_namespace -> name ) ; if ( rule != NULL ) { compiler -> last_result = yr_parser_emit_with_arg_reloc ( yyscanner , OP_PUSH_RULE , rule , NULL , NULL ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_BOOLEAN ; ( yyval . expression ) . value . integer = UNDEFINED ; ( yyval . expression ) . identifier = rule -> identifier ; } else { yr_compiler_set_error_extra_info ( compiler , ( yyvsp [ 0 ] . c_string ) ) ; compiler -> last_result = ERROR_UNDEFINED_IDENTIFIER ; } } } yr_free ( ( yyvsp [ 0 ] . c_string ) ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; } # line 2172 ""grammar.c"" break ; case 46 : # line 653 ""grammar.y"" { YR_OBJECT * field = NULL ; if ( ( yyvsp [ - 2 ] . expression ) . type == EXPRESSION_TYPE_OBJECT && ( yyvsp [ - 2 ] . expression ) . value . object -> type == OBJECT_TYPE_STRUCTURE ) { field = yr_object_lookup_field ( ( yyvsp [ - 2 ] . expression ) . value . object , ( yyvsp [ 0 ] . c_string ) ) ; if ( field != NULL ) { char * ident ; compiler -> last_result = yr_arena_write_string ( compiler -> sz_arena , ( yyvsp [ 0 ] . c_string ) , & ident ) ; if ( compiler -> last_result == ERROR_SUCCESS ) compiler -> last_result = yr_parser_emit_with_arg_reloc ( yyscanner , OP_OBJ_FIELD , ident , NULL , NULL ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_OBJECT ; ( yyval . expression ) . value . object = field ; ( yyval . expression ) . identifier = field -> identifier ; } else { yr_compiler_set_error_extra_info ( compiler , ( yyvsp [ 0 ] . c_string ) ) ; compiler -> last_result = ERROR_INVALID_FIELD_NAME ; } } else { yr_compiler_set_error_extra_info ( compiler , ( yyvsp [ - 2 ] . expression ) . identifier ) ; compiler -> last_result = ERROR_NOT_A_STRUCTURE ; } yr_free ( ( yyvsp [ 0 ] . c_string ) ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; } # line 2222 ""grammar.c"" break ; case 47 : # line 699 ""grammar.y"" { YR_OBJECT_ARRAY * array ; YR_OBJECT_DICTIONARY * dict ; if ( ( yyvsp [ - 3 ] . expression ) . type == EXPRESSION_TYPE_OBJECT && ( yyvsp [ - 3 ] . expression ) . value . object -> type == OBJECT_TYPE_ARRAY ) { if ( ( yyvsp [ - 1 ] . expression ) . type != EXPRESSION_TYPE_INTEGER ) { yr_compiler_set_error_extra_info ( compiler , ""arrayindexesmustbeofintegertype"" ) ; compiler -> last_result = ERROR_WRONG_TYPE ; } ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; compiler -> last_result = yr_parser_emit ( yyscanner , OP_INDEX_ARRAY , NULL ) ; array = ( YR_OBJECT_ARRAY * ) ( yyvsp [ - 3 ] . expression ) . value . object ; ( yyval . expression ) . type = EXPRESSION_TYPE_OBJECT ; ( yyval . expression ) . value . object = array -> prototype_item ; ( yyval . expression ) . identifier = array -> identifier ; } else if ( ( yyvsp [ - 3 ] . expression ) . type == EXPRESSION_TYPE_OBJECT && ( yyvsp [ - 3 ] . expression ) . value . object -> type == OBJECT_TYPE_DICTIONARY ) { if ( ( yyvsp [ - 1 ] . expression ) . type != EXPRESSION_TYPE_STRING ) { yr_compiler_set_error_extra_info ( compiler , ""dictionarykeysmustbeofstringtype"" ) ; compiler -> last_result = ERROR_WRONG_TYPE ; } ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; compiler -> last_result = yr_parser_emit ( yyscanner , OP_LOOKUP_DICT , NULL ) ; dict = ( YR_OBJECT_DICTIONARY * ) ( yyvsp [ - 3 ] . expression ) . value . object ; ( yyval . expression ) . type = EXPRESSION_TYPE_OBJECT ; ( yyval . expression ) . value . object = dict -> prototype_item ; ( yyval . expression ) . identifier = dict -> identifier ; } else { yr_compiler_set_error_extra_info ( compiler , ( yyvsp [ - 3 ] . expression ) . identifier ) ; compiler -> last_result = ERROR_NOT_INDEXABLE ; } ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; } # line 2283 ""grammar.c"" break ; case 48 : # line 757 ""grammar.y"" { YR_OBJECT_FUNCTION * function ; char * args_fmt ; if ( ( yyvsp [ - 3 ] . expression ) . type == EXPRESSION_TYPE_OBJECT && ( yyvsp [ - 3 ] . expression ) . value . object -> type == OBJECT_TYPE_FUNCTION ) { compiler -> last_result = yr_parser_check_types ( compiler , ( YR_OBJECT_FUNCTION * ) ( yyvsp [ - 3 ] . expression ) . value . object , ( yyvsp [ - 1 ] . c_string ) ) ; if ( compiler -> last_result == ERROR_SUCCESS ) compiler -> last_result = yr_arena_write_string ( compiler -> sz_arena , ( yyvsp [ - 1 ] . c_string ) , & args_fmt ) ; if ( compiler -> last_result == ERROR_SUCCESS ) compiler -> last_result = yr_parser_emit_with_arg_reloc ( yyscanner , OP_CALL , args_fmt , NULL , NULL ) ; function = ( YR_OBJECT_FUNCTION * ) ( yyvsp [ - 3 ] . expression ) . value . object ; ( yyval . expression ) . type = EXPRESSION_TYPE_OBJECT ; ( yyval . expression ) . value . object = function -> return_obj ; ( yyval . expression ) . identifier = function -> identifier ; } else { yr_compiler_set_error_extra_info ( compiler , ( yyvsp [ - 3 ] . expression ) . identifier ) ; compiler -> last_result = ERROR_NOT_A_FUNCTION ; } yr_free ( ( yyvsp [ - 1 ] . c_string ) ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; } # line 2328 ""grammar.c"" break ; case 49 : # line 801 ""grammar.y"" { ( yyval . c_string ) = yr_strdup ( """" ) ; } # line 2334 ""grammar.c"" break ; case 50 : # line 802 ""grammar.y"" { ( yyval . c_string ) = ( yyvsp [ 0 ] . c_string ) ; } # line 2340 ""grammar.c"" break ; case 51 : # line 807 ""grammar.y"" { ( yyval . c_string ) = ( char * ) yr_malloc ( MAX_FUNCTION_ARGS + 1 ) ; switch ( ( yyvsp [ 0 ] . expression ) . type ) { case EXPRESSION_TYPE_INTEGER : strlcpy ( ( yyval . c_string ) , ""i"" , MAX_FUNCTION_ARGS ) ; break ; case EXPRESSION_TYPE_FLOAT : strlcpy ( ( yyval . c_string ) , ""f"" , MAX_FUNCTION_ARGS ) ; break ; case EXPRESSION_TYPE_BOOLEAN : strlcpy ( ( yyval . c_string ) , ""b"" , MAX_FUNCTION_ARGS ) ; break ; case EXPRESSION_TYPE_STRING : strlcpy ( ( yyval . c_string ) , ""s"" , MAX_FUNCTION_ARGS ) ; break ; case EXPRESSION_TYPE_REGEXP : strlcpy ( ( yyval . c_string ) , ""r"" , MAX_FUNCTION_ARGS ) ; break ; } ERROR_IF ( ( yyval . c_string ) == NULL ) ; } # line 2369 ""grammar.c"" break ; case 52 : # line 832 ""grammar.y"" { if ( strlen ( ( yyvsp [ - 2 ] . c_string ) ) == MAX_FUNCTION_ARGS ) { compiler -> last_result = ERROR_TOO_MANY_ARGUMENTS ; } else { switch ( ( yyvsp [ 0 ] . expression ) . type ) { case EXPRESSION_TYPE_INTEGER : strlcat ( ( yyvsp [ - 2 ] . c_string ) , ""i"" , MAX_FUNCTION_ARGS ) ; break ; case EXPRESSION_TYPE_FLOAT : strlcat ( ( yyvsp [ - 2 ] . c_string ) , ""f"" , MAX_FUNCTION_ARGS ) ; break ; case EXPRESSION_TYPE_BOOLEAN : strlcat ( ( yyvsp [ - 2 ] . c_string ) , ""b"" , MAX_FUNCTION_ARGS ) ; break ; case EXPRESSION_TYPE_STRING : strlcat ( ( yyvsp [ - 2 ] . c_string ) , ""s"" , MAX_FUNCTION_ARGS ) ; break ; case EXPRESSION_TYPE_REGEXP : strlcat ( ( yyvsp [ - 2 ] . c_string ) , ""r"" , MAX_FUNCTION_ARGS ) ; break ; } } ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; ( yyval . c_string ) = ( yyvsp [ - 2 ] . c_string ) ; } # line 2405 ""grammar.c"" break ; case 53 : # line 868 ""grammar.y"" { SIZED_STRING * sized_string = ( yyvsp [ 0 ] . sized_string ) ; RE * re ; RE_ERROR error ; int re_flags = 0 ; if ( sized_string -> flags & SIZED_STRING_FLAGS_NO_CASE ) re_flags |= RE_FLAGS_NO_CASE ; if ( sized_string -> flags & SIZED_STRING_FLAGS_DOT_ALL ) re_flags |= RE_FLAGS_DOT_ALL ; compiler -> last_result = yr_re_compile ( sized_string -> c_string , re_flags , compiler -> re_code_arena , & re , & error ) ; yr_free ( ( yyvsp [ 0 ] . sized_string ) ) ; if ( compiler -> last_result == ERROR_INVALID_REGULAR_EXPRESSION ) yr_compiler_set_error_extra_info ( compiler , error . message ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; if ( compiler -> last_result == ERROR_SUCCESS ) compiler -> last_result = yr_parser_emit_with_arg_reloc ( yyscanner , OP_PUSH , re -> root_node -> forward_code , NULL , NULL ) ; yr_re_destroy ( re ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_REGEXP ; } # line 2451 ""grammar.c"" break ; case 54 : # line 914 ""grammar.y"" { if ( ( yyvsp [ 0 ] . expression ) . type == EXPRESSION_TYPE_STRING ) { if ( ( yyvsp [ 0 ] . expression ) . value . sized_string != NULL ) { yywarning ( yyscanner , ""Usingliteralstring\\""%s\\""inabooleanoperation."" , ( yyvsp [ 0 ] . expression ) . value . sized_string -> c_string ) ; } compiler -> last_result = yr_parser_emit ( yyscanner , OP_STR_TO_BOOL , NULL ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; } ( yyval . expression ) . type = EXPRESSION_TYPE_BOOLEAN ; } # line 2474 ""grammar.c"" break ; case 55 : # line 936 ""grammar.y"" { compiler -> last_result = yr_parser_emit_with_arg ( yyscanner , OP_PUSH , 1 , NULL , NULL ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_BOOLEAN ; } # line 2487 ""grammar.c"" break ; case 56 : # line 945 ""grammar.y"" { compiler -> last_result = yr_parser_emit_with_arg ( yyscanner , OP_PUSH , 0 , NULL , NULL ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_BOOLEAN ; } # line 2500 ""grammar.c"" break ; case 57 : # line 954 ""grammar.y"" { CHECK_TYPE ( ( yyvsp [ - 2 ] . expression ) , EXPRESSION_TYPE_STRING , ""matches"" ) ; CHECK_TYPE ( ( yyvsp [ 0 ] . expression ) , EXPRESSION_TYPE_REGEXP , ""matches"" ) ; if ( compiler -> last_result == ERROR_SUCCESS ) compiler -> last_result = yr_parser_emit ( yyscanner , OP_MATCHES , NULL ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_BOOLEAN ; } # line 2519 ""grammar.c"" break ; case 58 : # line 969 ""grammar.y"" { CHECK_TYPE ( ( yyvsp [ - 2 ] . expression ) , EXPRESSION_TYPE_STRING , ""contains"" ) ; CHECK_TYPE ( ( yyvsp [ 0 ] . expression ) , EXPRESSION_TYPE_STRING , ""contains"" ) ; compiler -> last_result = yr_parser_emit ( yyscanner , OP_CONTAINS , NULL ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_BOOLEAN ; } # line 2535 ""grammar.c"" break ; case 59 : # line 981 ""grammar.y"" { int result = yr_parser_reduce_string_identifier ( yyscanner , ( yyvsp [ 0 ] . c_string ) , OP_FOUND , UNDEFINED ) ; yr_free ( ( yyvsp [ 0 ] . c_string ) ) ; ERROR_IF ( result != ERROR_SUCCESS ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_BOOLEAN ; } # line 2553 ""grammar.c"" break ; case 60 : # line 995 ""grammar.y"" { CHECK_TYPE ( ( yyvsp [ 0 ] . expression ) , EXPRESSION_TYPE_INTEGER , ""at"" ) ; compiler -> last_result = yr_parser_reduce_string_identifier ( yyscanner , ( yyvsp [ - 2 ] . c_string ) , OP_FOUND_AT , ( yyvsp [ 0 ] . expression ) . value . integer ) ; yr_free ( ( yyvsp [ - 2 ] . c_string ) ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_BOOLEAN ; } # line 2570 ""grammar.c"" break ; case 61 : # line 1008 ""grammar.y"" { compiler -> last_result = yr_parser_reduce_string_identifier ( yyscanner , ( yyvsp [ - 2 ] . c_string ) , OP_FOUND_IN , UNDEFINED ) ; yr_free ( ( yyvsp [ - 2 ] . c_string ) ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_BOOLEAN ; } # line 2585 ""grammar.c"" break ; case 62 : # line 1019 ""grammar.y"" { if ( compiler -> loop_depth > 0 ) { compiler -> loop_depth -- ; compiler -> loop_identifier [ compiler -> loop_depth ] = NULL ; } } # line 2597 ""grammar.c"" break ; case 63 : # line 1027 ""grammar.y"" { int var_index ; if ( compiler -> loop_depth == MAX_LOOP_NESTING ) compiler -> last_result = ERROR_LOOP_NESTING_LIMIT_EXCEEDED ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; var_index = yr_parser_lookup_loop_variable ( yyscanner , ( yyvsp [ - 1 ] . c_string ) ) ; if ( var_index >= 0 ) { yr_compiler_set_error_extra_info ( compiler , ( yyvsp [ - 1 ] . c_string ) ) ; compiler -> last_result = ERROR_DUPLICATED_LOOP_IDENTIFIER ; } ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; compiler -> last_result = yr_parser_emit_with_arg ( yyscanner , OP_PUSH , UNDEFINED , NULL , NULL ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; } # line 2631 ""grammar.c"" break ; case 64 : # line 1057 ""grammar.y"" { int mem_offset = LOOP_LOCAL_VARS * compiler -> loop_depth ; uint8_t * addr ; yr_parser_emit_with_arg ( yyscanner , OP_CLEAR_M , mem_offset + 1 , NULL , NULL ) ; yr_parser_emit_with_arg ( yyscanner , OP_CLEAR_M , mem_offset + 2 , NULL , NULL ) ; if ( ( yyvsp [ - 1 ] . integer ) == INTEGER_SET_ENUMERATION ) { yr_parser_emit_with_arg ( yyscanner , OP_POP_M , mem_offset , & addr , NULL ) ; } else { yr_parser_emit_with_arg ( yyscanner , OP_POP_M , mem_offset + 3 , & addr , NULL ) ; yr_parser_emit_with_arg ( yyscanner , OP_POP_M , mem_offset , NULL , NULL ) ; } compiler -> loop_address [ compiler -> loop_depth ] = addr ; compiler -> loop_identifier [ compiler -> loop_depth ] = ( yyvsp [ - 4 ] . c_string ) ; compiler -> loop_depth ++ ; } # line 2670 ""grammar.c"" break ; case 65 : # line 1092 ""grammar.y"" { int mem_offset ; compiler -> loop_depth -- ; mem_offset = LOOP_LOCAL_VARS * compiler -> loop_depth ; yr_parser_emit_with_arg ( yyscanner , OP_ADD_M , mem_offset + 1 , NULL , NULL ) ; yr_parser_emit_with_arg ( yyscanner , OP_INCR_M , mem_offset + 2 , NULL , NULL ) ; if ( ( yyvsp [ - 5 ] . integer ) == INTEGER_SET_ENUMERATION ) { yr_parser_emit_with_arg_reloc ( yyscanner , OP_JNUNDEF , compiler -> loop_address [ compiler -> loop_depth ] , NULL , NULL ) ; } else { yr_parser_emit_with_arg ( yyscanner , OP_INCR_M , mem_offset , NULL , NULL ) ; yr_parser_emit_with_arg ( yyscanner , OP_PUSH_M , mem_offset , NULL , NULL ) ; yr_parser_emit_with_arg ( yyscanner , OP_PUSH_M , mem_offset + 3 , NULL , NULL ) ; yr_parser_emit_with_arg_reloc ( yyscanner , OP_JLE , compiler -> loop_address [ compiler -> loop_depth ] , NULL , NULL ) ; yr_parser_emit ( yyscanner , OP_POP , NULL ) ; yr_parser_emit ( yyscanner , OP_POP , NULL ) ; } yr_parser_emit ( yyscanner , OP_POP , NULL ) ; yr_parser_emit_with_arg ( yyscanner , OP_SWAPUNDEF , mem_offset + 2 , NULL , NULL ) ; yr_parser_emit_with_arg ( yyscanner , OP_PUSH_M , mem_offset + 1 , NULL , NULL ) ; yr_parser_emit ( yyscanner , OP_INT_LE , NULL ) ; compiler -> loop_identifier [ compiler -> loop_depth ] = NULL ; yr_free ( ( yyvsp [ - 8 ] . c_string ) ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_BOOLEAN ; } # line 2753 ""grammar.c"" break ; case 66 : # line 1171 ""grammar.y"" { int mem_offset = LOOP_LOCAL_VARS * compiler -> loop_depth ; uint8_t * addr ; if ( compiler -> loop_depth == MAX_LOOP_NESTING ) compiler -> last_result = ERROR_LOOP_NESTING_LIMIT_EXCEEDED ; if ( compiler -> loop_for_of_mem_offset != - 1 ) compiler -> last_result = ERROR_NESTED_FOR_OF_LOOP ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; yr_parser_emit_with_arg ( yyscanner , OP_CLEAR_M , mem_offset + 1 , NULL , NULL ) ; yr_parser_emit_with_arg ( yyscanner , OP_CLEAR_M , mem_offset + 2 , NULL , NULL ) ; yr_parser_emit_with_arg ( yyscanner , OP_POP_M , mem_offset , & addr , NULL ) ; compiler -> loop_for_of_mem_offset = mem_offset ; compiler -> loop_address [ compiler -> loop_depth ] = addr ; compiler -> loop_identifier [ compiler -> loop_depth ] = NULL ; compiler -> loop_depth ++ ; } # line 2787 ""grammar.c"" break ; case 67 : # line 1201 ""grammar.y"" { int mem_offset ; compiler -> loop_depth -- ; compiler -> loop_for_of_mem_offset = - 1 ; mem_offset = LOOP_LOCAL_VARS * compiler -> loop_depth ; yr_parser_emit_with_arg ( yyscanner , OP_ADD_M , mem_offset + 1 , NULL , NULL ) ; yr_parser_emit_with_arg ( yyscanner , OP_INCR_M , mem_offset + 2 , NULL , NULL ) ; yr_parser_emit_with_arg_reloc ( yyscanner , OP_JNUNDEF , compiler -> loop_address [ compiler -> loop_depth ] , NULL , NULL ) ; yr_parser_emit ( yyscanner , OP_POP , NULL ) ; yr_parser_emit_with_arg ( yyscanner , OP_SWAPUNDEF , mem_offset + 2 , NULL , NULL ) ; yr_parser_emit_with_arg ( yyscanner , OP_PUSH_M , mem_offset + 1 , NULL , NULL ) ; yr_parser_emit ( yyscanner , OP_INT_LE , NULL ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_BOOLEAN ; } # line 2840 ""grammar.c"" break ; case 68 : # line 1250 ""grammar.y"" { yr_parser_emit ( yyscanner , OP_OF , NULL ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_BOOLEAN ; } # line 2850 ""grammar.c"" break ; case 69 : # line 1256 ""grammar.y"" { yr_parser_emit ( yyscanner , OP_NOT , NULL ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_BOOLEAN ; } # line 2860 ""grammar.c"" break ; case 70 : # line 1262 ""grammar.y"" { YR_FIXUP * fixup ; void * jmp_destination_addr ; compiler -> last_result = yr_parser_emit_with_arg_reloc ( yyscanner , OP_JFALSE , 0 , NULL , & jmp_destination_addr ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; fixup = ( YR_FIXUP * ) yr_malloc ( sizeof ( YR_FIXUP ) ) ; if ( fixup == NULL ) compiler -> last_error = ERROR_INSUFFICIENT_MEMORY ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; fixup -> address = jmp_destination_addr ; fixup -> next = compiler -> fixup_stack_head ; compiler -> fixup_stack_head = fixup ; } # line 2890 ""grammar.c"" break ; case 71 : # line 1288 ""grammar.y"" { YR_FIXUP * fixup ; uint8_t * and_addr ; compiler -> last_result = yr_arena_reserve_memory ( compiler -> code_arena , 2 ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; compiler -> last_result = yr_parser_emit ( yyscanner , OP_AND , & and_addr ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; fixup = compiler -> fixup_stack_head ; * ( void * * ) ( fixup -> address ) = ( void * ) ( and_addr + 1 ) ; compiler -> fixup_stack_head = fixup -> next ; yr_free ( fixup ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_BOOLEAN ; } # line 2930 ""grammar.c"" break ; case 72 : # line 1324 ""grammar.y"" { YR_FIXUP * fixup ; void * jmp_destination_addr ; compiler -> last_result = yr_parser_emit_with_arg_reloc ( yyscanner , OP_JTRUE , 0 , NULL , & jmp_destination_addr ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; fixup = ( YR_FIXUP * ) yr_malloc ( sizeof ( YR_FIXUP ) ) ; if ( fixup == NULL ) compiler -> last_error = ERROR_INSUFFICIENT_MEMORY ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; fixup -> address = jmp_destination_addr ; fixup -> next = compiler -> fixup_stack_head ; compiler -> fixup_stack_head = fixup ; } # line 2959 ""grammar.c"" break ; case 73 : # line 1349 ""grammar.y"" { YR_FIXUP * fixup ; uint8_t * or_addr ; compiler -> last_result = yr_arena_reserve_memory ( compiler -> code_arena , 2 ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; compiler -> last_result = yr_parser_emit ( yyscanner , OP_OR , & or_addr ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; fixup = compiler -> fixup_stack_head ; * ( void * * ) ( fixup -> address ) = ( void * ) ( or_addr + 1 ) ; compiler -> fixup_stack_head = fixup -> next ; yr_free ( fixup ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_BOOLEAN ; } # line 2999 ""grammar.c"" break ; case 74 : # line 1385 ""grammar.y"" { compiler -> last_result = yr_parser_reduce_operation ( yyscanner , ""<"" , ( yyvsp [ - 2 ] . expression ) , ( yyvsp [ 0 ] . expression ) ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_BOOLEAN ; } # line 3012 ""grammar.c"" break ; case 75 : # line 1394 ""grammar.y"" { compiler -> last_result = yr_parser_reduce_operation ( yyscanner , "">"" , ( yyvsp [ - 2 ] . expression ) , ( yyvsp [ 0 ] . expression ) ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_BOOLEAN ; } # line 3025 ""grammar.c"" break ; case 76 : # line 1403 ""grammar.y"" { compiler -> last_result = yr_parser_reduce_operation ( yyscanner , ""<="" , ( yyvsp [ - 2 ] . expression ) , ( yyvsp [ 0 ] . expression ) ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_BOOLEAN ; } # line 3038 ""grammar.c"" break ; case 77 : # line 1412 ""grammar.y"" { compiler -> last_result = yr_parser_reduce_operation ( yyscanner , "">="" , ( yyvsp [ - 2 ] . expression ) , ( yyvsp [ 0 ] . expression ) ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_BOOLEAN ; } # line 3051 ""grammar.c"" break ; case 78 : # line 1421 ""grammar.y"" { compiler -> last_result = yr_parser_reduce_operation ( yyscanner , ""=="" , ( yyvsp [ - 2 ] . expression ) , ( yyvsp [ 0 ] . expression ) ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_BOOLEAN ; } # line 3064 ""grammar.c"" break ; case 79 : # line 1430 ""grammar.y"" { compiler -> last_result = yr_parser_reduce_operation ( yyscanner , ""!="" , ( yyvsp [ - 2 ] . expression ) , ( yyvsp [ 0 ] . expression ) ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_BOOLEAN ; } # line 3077 ""grammar.c"" break ; case 80 : # line 1439 ""grammar.y"" { ( yyval . expression ) = ( yyvsp [ 0 ] . expression ) ; } # line 3085 ""grammar.c"" break ; case 81 : # line 1443 ""grammar.y"" { ( yyval . expression ) = ( yyvsp [ - 1 ] . expression ) ; } # line 3093 ""grammar.c"" break ; case 82 : # line 1450 ""grammar.y"" { ( yyval . integer ) = INTEGER_SET_ENUMERATION ; } # line 3099 ""grammar.c"" break ; case 83 : # line 1451 ""grammar.y"" { ( yyval . integer ) = INTEGER_SET_RANGE ; } # line 3105 ""grammar.c"" break ; case 84 : # line 1457 ""grammar.y"" { if ( ( yyvsp [ - 3 ] . expression ) . type != EXPRESSION_TYPE_INTEGER ) { yr_compiler_set_error_extra_info ( compiler , ""wrongtypeforrange\'slowerbound"" ) ; compiler -> last_result = ERROR_WRONG_TYPE ; } if ( ( yyvsp [ - 1 ] . expression ) . type != EXPRESSION_TYPE_INTEGER ) { yr_compiler_set_error_extra_info ( compiler , ""wrongtypeforrange\'supperbound"" ) ; compiler -> last_result = ERROR_WRONG_TYPE ; } ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; } # line 3127 ""grammar.c"" break ; case 85 : # line 1479 ""grammar.y"" { if ( ( yyvsp [ 0 ] . expression ) . type != EXPRESSION_TYPE_INTEGER ) { yr_compiler_set_error_extra_info ( compiler , ""wrongtypeforenumerationitem"" ) ; compiler -> last_result = ERROR_WRONG_TYPE ; } ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; } # line 3143 ""grammar.c"" break ; case 86 : # line 1491 ""grammar.y"" { if ( ( yyvsp [ 0 ] . expression ) . type != EXPRESSION_TYPE_INTEGER ) { yr_compiler_set_error_extra_info ( compiler , ""wrongtypeforenumerationitem"" ) ; compiler -> last_result = ERROR_WRONG_TYPE ; } ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; } # line 3158 ""grammar.c"" break ; case 87 : # line 1506 ""grammar.y"" { yr_parser_emit_with_arg ( yyscanner , OP_PUSH , UNDEFINED , NULL , NULL ) ; } # line 3167 ""grammar.c"" break ; case 89 : # line 1512 ""grammar.y"" { yr_parser_emit_with_arg ( yyscanner , OP_PUSH , UNDEFINED , NULL , NULL ) ; yr_parser_emit_pushes_for_strings ( yyscanner , ""$*"" ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; } # line 3178 ""grammar.c"" break ; case 92 : # line 1529 ""grammar.y"" { yr_parser_emit_pushes_for_strings ( yyscanner , ( yyvsp [ 0 ] . c_string ) ) ; yr_free ( ( yyvsp [ 0 ] . c_string ) ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; } # line 3189 ""grammar.c"" break ; case 93 : # line 1536 ""grammar.y"" { yr_parser_emit_pushes_for_strings ( yyscanner , ( yyvsp [ 0 ] . c_string ) ) ; yr_free ( ( yyvsp [ 0 ] . c_string ) ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; } # line 3200 ""grammar.c"" break ; case 95 : # line 1548 ""grammar.y"" { yr_parser_emit_with_arg ( yyscanner , OP_PUSH , UNDEFINED , NULL , NULL ) ; } # line 3208 ""grammar.c"" break ; case 96 : # line 1552 ""grammar.y"" { yr_parser_emit_with_arg ( yyscanner , OP_PUSH , 1 , NULL , NULL ) ; } # line 3216 ""grammar.c"" break ; case 97 : # line 1560 ""grammar.y"" { ( yyval . expression ) = ( yyvsp [ - 1 ] . expression ) ; } # line 3224 ""grammar.c"" break ; case 98 : # line 1564 ""grammar.y"" { compiler -> last_result = yr_parser_emit ( yyscanner , OP_FILESIZE , NULL ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_INTEGER ; ( yyval . expression ) . value . integer = UNDEFINED ; } # line 3238 ""grammar.c"" break ; case 99 : # line 1574 ""grammar.y"" { yywarning ( yyscanner , ""Usingdeprecated\\""entrypoint\\""keyword.Usethe\\""entry_point\\"""" ""functionfromPEmoduleinstead."" ) ; compiler -> last_result = yr_parser_emit ( yyscanner , OP_ENTRYPOINT , NULL ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_INTEGER ; ( yyval . expression ) . value . integer = UNDEFINED ; } # line 3256 ""grammar.c"" break ; case 100 : # line 1588 ""grammar.y"" { CHECK_TYPE ( ( yyvsp [ - 1 ] . expression ) , EXPRESSION_TYPE_INTEGER , ""intXXXXoruintXXXX"" ) ; compiler -> last_result = yr_parser_emit ( yyscanner , ( uint8_t ) ( OP_READ_INT + ( yyvsp [ - 3 ] . integer ) ) , NULL ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_INTEGER ; ( yyval . expression ) . value . integer = UNDEFINED ; } # line 3276 ""grammar.c"" break ; case 101 : # line 1604 ""grammar.y"" { compiler -> last_result = yr_parser_emit_with_arg ( yyscanner , OP_PUSH , ( yyvsp [ 0 ] . integer ) , NULL , NULL ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_INTEGER ; ( yyval . expression ) . value . integer = ( yyvsp [ 0 ] . integer ) ; } # line 3290 ""grammar.c"" break ; case 102 : # line 1614 ""grammar.y"" { compiler -> last_result = yr_parser_emit_with_arg_double ( yyscanner , OP_PUSH , ( yyvsp [ 0 ] . double_ ) , NULL , NULL ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_FLOAT ; } # line 3303 ""grammar.c"" break ; case 103 : # line 1623 ""grammar.y"" { SIZED_STRING * sized_string ; compiler -> last_result = yr_arena_write_data ( compiler -> sz_arena , ( yyvsp [ 0 ] . sized_string ) , ( yyvsp [ 0 ] . sized_string ) -> length + sizeof ( SIZED_STRING ) , ( void * * ) & sized_string ) ; yr_free ( ( yyvsp [ 0 ] . sized_string ) ) ; if ( compiler -> last_result == ERROR_SUCCESS ) compiler -> last_result = yr_parser_emit_with_arg_reloc ( yyscanner , OP_PUSH , sized_string , NULL , NULL ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_STRING ; ( yyval . expression ) . value . sized_string = sized_string ; } # line 3332 ""grammar.c"" break ; case 104 : # line 1648 ""grammar.y"" { compiler -> last_result = yr_parser_reduce_string_identifier ( yyscanner , ( yyvsp [ 0 ] . c_string ) , OP_COUNT , UNDEFINED ) ; yr_free ( ( yyvsp [ 0 ] . c_string ) ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_INTEGER ; ( yyval . expression ) . value . integer = UNDEFINED ; } # line 3348 ""grammar.c"" break ; case 105 : # line 1660 ""grammar.y"" { compiler -> last_result = yr_parser_reduce_string_identifier ( yyscanner , ( yyvsp [ - 3 ] . c_string ) , OP_OFFSET , UNDEFINED ) ; yr_free ( ( yyvsp [ - 3 ] . c_string ) ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_INTEGER ; ( yyval . expression ) . value . integer = UNDEFINED ; } # line 3364 ""grammar.c"" break ; case 106 : # line 1672 ""grammar.y"" { compiler -> last_result = yr_parser_emit_with_arg ( yyscanner , OP_PUSH , 1 , NULL , NULL ) ; if ( compiler -> last_result == ERROR_SUCCESS ) compiler -> last_result = yr_parser_reduce_string_identifier ( yyscanner , ( yyvsp [ 0 ] . c_string ) , OP_OFFSET , UNDEFINED ) ; yr_free ( ( yyvsp [ 0 ] . c_string ) ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_INTEGER ; ( yyval . expression ) . value . integer = UNDEFINED ; } # line 3384 ""grammar.c"" break ; case 107 : # line 1688 ""grammar.y"" { compiler -> last_result = yr_parser_reduce_string_identifier ( yyscanner , ( yyvsp [ - 3 ] . c_string ) , OP_LENGTH , UNDEFINED ) ; yr_free ( ( yyvsp [ - 3 ] . c_string ) ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_INTEGER ; ( yyval . expression ) . value . integer = UNDEFINED ; } # line 3400 ""grammar.c"" break ; case 108 : # line 1700 ""grammar.y"" { compiler -> last_result = yr_parser_emit_with_arg ( yyscanner , OP_PUSH , 1 , NULL , NULL ) ; if ( compiler -> last_result == ERROR_SUCCESS ) compiler -> last_result = yr_parser_reduce_string_identifier ( yyscanner , ( yyvsp [ 0 ] . c_string ) , OP_LENGTH , UNDEFINED ) ; yr_free ( ( yyvsp [ 0 ] . c_string ) ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_INTEGER ; ( yyval . expression ) . value . integer = UNDEFINED ; } # line 3420 ""grammar.c"" break ; case 109 : # line 1716 ""grammar.y"" { if ( ( yyvsp [ 0 ] . expression ) . type == EXPRESSION_TYPE_INTEGER ) { ( yyval . expression ) . type = EXPRESSION_TYPE_INTEGER ; ( yyval . expression ) . value . integer = UNDEFINED ; } else if ( ( yyvsp [ 0 ] . expression ) . type == EXPRESSION_TYPE_BOOLEAN ) { ( yyval . expression ) . type = EXPRESSION_TYPE_BOOLEAN ; ( yyval . expression ) . value . integer = UNDEFINED ; } else if ( ( yyvsp [ 0 ] . expression ) . type == EXPRESSION_TYPE_OBJECT ) { compiler -> last_result = yr_parser_emit ( yyscanner , OP_OBJ_VALUE , NULL ) ; switch ( ( yyvsp [ 0 ] . expression ) . value . object -> type ) { case OBJECT_TYPE_INTEGER : ( yyval . expression ) . type = EXPRESSION_TYPE_INTEGER ; ( yyval . expression ) . value . integer = UNDEFINED ; break ; case OBJECT_TYPE_FLOAT : ( yyval . expression ) . type = EXPRESSION_TYPE_FLOAT ; break ; case OBJECT_TYPE_STRING : ( yyval . expression ) . type = EXPRESSION_TYPE_STRING ; ( yyval . expression ) . value . sized_string = NULL ; break ; default : yr_compiler_set_error_extra_info_fmt ( compiler , ""wrongusageofidentifier\\""%s\\"""" , ( yyvsp [ 0 ] . expression ) . identifier ) ; compiler -> last_result = ERROR_WRONG_TYPE ; } } else { assert ( FALSE ) ; } ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; } # line 3469 ""grammar.c"" break ; case 110 : # line 1761 ""grammar.y"" { CHECK_TYPE ( ( yyvsp [ 0 ] . expression ) , EXPRESSION_TYPE_INTEGER | EXPRESSION_TYPE_FLOAT , ""-"" ) ; if ( ( yyvsp [ 0 ] . expression ) . type == EXPRESSION_TYPE_INTEGER ) { ( yyval . expression ) . type = EXPRESSION_TYPE_INTEGER ; ( yyval . expression ) . value . integer = ( ( yyvsp [ 0 ] . expression ) . value . integer == UNDEFINED ) ? UNDEFINED : - ( ( yyvsp [ 0 ] . expression ) . value . integer ) ; compiler -> last_result = yr_parser_emit ( yyscanner , OP_INT_MINUS , NULL ) ; } else if ( ( yyvsp [ 0 ] . expression ) . type == EXPRESSION_TYPE_FLOAT ) { ( yyval . expression ) . type = EXPRESSION_TYPE_FLOAT ; compiler -> last_result = yr_parser_emit ( yyscanner , OP_DBL_MINUS , NULL ) ; } ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; } # line 3492 ""grammar.c"" break ; case 111 : # line 1780 ""grammar.y"" { compiler -> last_result = yr_parser_reduce_operation ( yyscanner , ""+"" , ( yyvsp [ - 2 ] . expression ) , ( yyvsp [ 0 ] . expression ) ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; if ( ( yyvsp [ - 2 ] . expression ) . type == EXPRESSION_TYPE_INTEGER && ( yyvsp [ 0 ] . expression ) . type == EXPRESSION_TYPE_INTEGER ) { ( yyval . expression ) . value . integer = OPERATION ( + , ( yyvsp [ - 2 ] . expression ) . value . integer , ( yyvsp [ 0 ] . expression ) . value . integer ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_INTEGER ; } else { ( yyval . expression ) . type = EXPRESSION_TYPE_FLOAT ; } } # line 3514 ""grammar.c"" break ; case 112 : # line 1798 ""grammar.y"" { compiler -> last_result = yr_parser_reduce_operation ( yyscanner , ""-"" , ( yyvsp [ - 2 ] . expression ) , ( yyvsp [ 0 ] . expression ) ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; if ( ( yyvsp [ - 2 ] . expression ) . type == EXPRESSION_TYPE_INTEGER && ( yyvsp [ 0 ] . expression ) . type == EXPRESSION_TYPE_INTEGER ) { ( yyval . expression ) . value . integer = OPERATION ( - , ( yyvsp [ - 2 ] . expression ) . value . integer , ( yyvsp [ 0 ] . expression ) . value . integer ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_INTEGER ; } else { ( yyval . expression ) . type = EXPRESSION_TYPE_FLOAT ; } } # line 3536 ""grammar.c"" break ; case 113 : # line 1816 ""grammar.y"" { compiler -> last_result = yr_parser_reduce_operation ( yyscanner , ""*"" , ( yyvsp [ - 2 ] . expression ) , ( yyvsp [ 0 ] . expression ) ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; if ( ( yyvsp [ - 2 ] . expression ) . type == EXPRESSION_TYPE_INTEGER && ( yyvsp [ 0 ] . expression ) . type == EXPRESSION_TYPE_INTEGER ) { ( yyval . expression ) . value . integer = OPERATION ( * , ( yyvsp [ - 2 ] . expression ) . value . integer , ( yyvsp [ 0 ] . expression ) . value . integer ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_INTEGER ; } else { ( yyval . expression ) . type = EXPRESSION_TYPE_FLOAT ; } } # line 3558 ""grammar.c"" break ; case 114 : # line 1834 ""grammar.y"" { compiler -> last_result = yr_parser_reduce_operation ( yyscanner , ""\\\\"" , ( yyvsp [ - 2 ] . expression ) , ( yyvsp [ 0 ] . expression ) ) ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; if ( ( yyvsp [ - 2 ] . expression ) . type == EXPRESSION_TYPE_INTEGER && ( yyvsp [ 0 ] . expression ) . type == EXPRESSION_TYPE_INTEGER ) { if ( ( yyvsp [ 0 ] . expression ) . value . integer != 0 ) { ( yyval . expression ) . value . integer = OPERATION ( / , ( yyvsp [ - 2 ] . expression ) . value . integer , ( yyvsp [ 0 ] . expression ) . value . integer ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_INTEGER ; } else { compiler -> last_result = ERROR_DIVISION_BY_ZERO ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; } } else { ( yyval . expression ) . type = EXPRESSION_TYPE_FLOAT ; } } # line 3588 ""grammar.c"" break ; case 115 : # line 1860 ""grammar.y"" { CHECK_TYPE ( ( yyvsp [ - 2 ] . expression ) , EXPRESSION_TYPE_INTEGER , ""%"" ) ; CHECK_TYPE ( ( yyvsp [ 0 ] . expression ) , EXPRESSION_TYPE_INTEGER , ""%"" ) ; yr_parser_emit ( yyscanner , OP_MOD , NULL ) ; if ( ( yyvsp [ 0 ] . expression ) . value . integer != 0 ) { ( yyval . expression ) . value . integer = OPERATION ( % , ( yyvsp [ - 2 ] . expression ) . value . integer , ( yyvsp [ 0 ] . expression ) . value . integer ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_INTEGER ; } else { compiler -> last_result = ERROR_DIVISION_BY_ZERO ; ERROR_IF ( compiler -> last_result != ERROR_SUCCESS ) ; } } # line 3610 ""grammar.c"" break ; case 116 : # line 1878 ""grammar.y"" { CHECK_TYPE ( ( yyvsp [ - 2 ] . expression ) , EXPRESSION_TYPE_INTEGER , ""^"" ) ; CHECK_TYPE ( ( yyvsp [ 0 ] . expression ) , EXPRESSION_TYPE_INTEGER , ""^"" ) ; yr_parser_emit ( yyscanner , OP_BITWISE_XOR , NULL ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_INTEGER ; ( yyval . expression ) . value . integer = OPERATION ( ^ , ( yyvsp [ - 2 ] . expression ) . value . integer , ( yyvsp [ 0 ] . expression ) . value . integer ) ; } # line 3624 ""grammar.c"" break ; case 117 : # line 1888 ""grammar.y"" { CHECK_TYPE ( ( yyvsp [ - 2 ] . expression ) , EXPRESSION_TYPE_INTEGER , ""^"" ) ; CHECK_TYPE ( ( yyvsp [ 0 ] . expression ) , EXPRESSION_TYPE_INTEGER , ""^"" ) ; yr_parser_emit ( yyscanner , OP_BITWISE_AND , NULL ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_INTEGER ; ( yyval . expression ) . value . integer = OPERATION ( & , ( yyvsp [ - 2 ] . expression ) . value . integer , ( yyvsp [ 0 ] . expression ) . value . integer ) ; } # line 3638 ""grammar.c"" break ; case 118 : # line 1898 ""grammar.y"" { CHECK_TYPE ( ( yyvsp [ - 2 ] . expression ) , EXPRESSION_TYPE_INTEGER , ""|"" ) ; CHECK_TYPE ( ( yyvsp [ 0 ] . expression ) , EXPRESSION_TYPE_INTEGER , ""|"" ) ; yr_parser_emit ( yyscanner , OP_BITWISE_OR , NULL ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_INTEGER ; ( yyval . expression ) . value . integer = OPERATION ( | , ( yyvsp [ - 2 ] . expression ) . value . integer , ( yyvsp [ 0 ] . expression ) . value . integer ) ; } # line 3652 ""grammar.c"" break ; case 119 : # line 1908 ""grammar.y"" { CHECK_TYPE ( ( yyvsp [ 0 ] . expression ) , EXPRESSION_TYPE_INTEGER , ""~"" ) ; yr_parser_emit ( yyscanner , OP_BITWISE_NOT , NULL ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_INTEGER ; ( yyval . expression ) . value . integer = ( ( yyvsp [ 0 ] . expression ) . value . integer == UNDEFINED ) ? UNDEFINED : ~ ( ( yyvsp [ 0 ] . expression ) . value . integer ) ; } # line 3666 ""grammar.c"" break ; case 120 : # line 1918 ""grammar.y"" { CHECK_TYPE ( ( yyvsp [ - 2 ] . expression ) , EXPRESSION_TYPE_INTEGER , ""<<"" ) ; CHECK_TYPE ( ( yyvsp [ 0 ] . expression ) , EXPRESSION_TYPE_INTEGER , ""<<"" ) ; yr_parser_emit ( yyscanner , OP_SHL , NULL ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_INTEGER ; ( yyval . expression ) . value . integer = OPERATION ( << , ( yyvsp [ - 2 ] . expression ) . value . integer , ( yyvsp [ 0 ] . expression ) . value . integer ) ; } # line 3680 ""grammar.c"" break ; case 121 : # line 1928 ""grammar.y"" { CHECK_TYPE ( ( yyvsp [ - 2 ] . expression ) , EXPRESSION_TYPE_INTEGER , "">>"" ) ; CHECK_TYPE ( ( yyvsp [ 0 ] . expression ) , EXPRESSION_TYPE_INTEGER , "">>"" ) ; yr_parser_emit ( yyscanner , OP_SHR , NULL ) ; ( yyval . expression ) . type = EXPRESSION_TYPE_INTEGER ; ( yyval . expression ) . value . integer = OPERATION ( >> , ( yyvsp [ - 2 ] . expression ) . value . integer , ( yyvsp [ 0 ] . expression ) . value . integer ) ; } # line 3694 ""grammar.c"" break ; case 122 : # line 1938 ""grammar.y"" { ( yyval . expression ) = ( yyvsp [ 0 ] . expression ) ; } # line 3702 ""grammar.c"" break ; # line 3706 ""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 , compiler , 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 , compiler , 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 , compiler ) ; 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 , compiler ) ; 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 , compiler , YY_ ( ""memoryexhausted"" ) ) ; yyresult = 2 ; # endif yyreturn : if ( yychar != YYEMPTY ) { yytoken = YYTRANSLATE ( yychar ) ; yydestruct ( ""Cleanup:discardinglookahead"" , yytoken , & yylval , yyscanner , compiler ) ; } YYPOPSTACK ( yylen ) ; YY_STACK_PRINT ( yyss , yyssp ) ; while ( yyssp != yyss ) { yydestruct ( ""Cleanup:popping"" , yystos [ * yyssp ] , yyvsp , yyscanner , compiler ) ; YYPOPSTACK ( 1 ) ; } # ifndef yyoverflow if ( yyss != yyssa ) YYSTACK_FREE ( yyss ) ; # endif # if YYERROR_VERBOSE if ( yymsg != yymsgbuf ) YYSTACK_FREE ( yymsg ) ; # endif return yyresult ; } "," ; break ; default : assert ( FALSE ) ; } # line 2371 ""grammar.c"" break ; : # line 834 ""grammar.y"" { if ; break ; default : assert ( FALSE ) ; } # line 2409 ""grammar.c"" break ; : # line 872 ""grammar.y"" { SIZED_STRING } # line 2455 ""grammar.c"" break ; : # line 918 ""grammar.y"" { if } # line 2478 ""grammar.c"" break ; : # line 940 ""grammar.y"" { compiler } # line 2491 ""grammar.c"" break ; : # line 949 ""grammar.y"" { compiler } # line 2504 ""grammar.c"" break ; : # line 958 ""grammar.y"" { CHECK_TYPE } # line 2523 ""grammar.c"" break ; : # line 973 ""grammar.y"" { CHECK_TYPE } # line 2539 ""grammar.c"" break ; : # line 985 ""grammar.y"" { int } # line 2557 ""grammar.c"" break ; : # line 999 ""grammar.y"" { CHECK_TYPE } # line 2574 ""grammar.c"" break ; : # line 1012 ""grammar.y"" { compiler } # line 2589 ""grammar.c"" break ; : # line 1023 ""grammar.y"" { if NULL ; } YYERROR ; } # line 2603 ""grammar.c"" break ; : # line 1033 ""grammar.y"" { int } # line 2637 ""grammar.c"" break ; : # line 1063 ""grammar.y"" { int } # line 2676 ""grammar.c"" break ; : # line 1098 ""grammar.y"" { int } # line 2759 ""grammar.c"" break ; : # line 1177 ""grammar.y"" { int } # line 2793 ""grammar.c"" break ; : # line 1207 ""grammar.y"" { int } # line 2846 ""grammar.c"" break ; : # line 1256 ""grammar.y"" { yr_parser_emit } # line 2856 ""grammar.c"" break ; : # line 1262 ""grammar.y"" { yr_parser_emit } # line 2866 ""grammar.c"" break ; : # line 1268 ""grammar.y"" { YR_FIXUP } # line 2896 ""grammar.c"" break ; : # line 1294 ""grammar.y"" { YR_FIXUP } # line 2936 ""grammar.c"" break ; : # line 1330 ""grammar.y"" { YR_FIXUP } # line 2965 ""grammar.c"" break ; : # line 1355 ""grammar.y"" { YR_FIXUP } # line 3005 ""grammar.c"" break ; : # line 1391 ""grammar.y"" { compiler } # line 3018 ""grammar.c"" break ; : # line 1400 ""grammar.y"" { compiler } # line 3031 ""grammar.c"" break ; : # line 1409 ""grammar.y"" { compiler } # line 3044 ""grammar.c"" break ; : # line 1418 ""grammar.y"" { compiler } # line 3057 ""grammar.c"" break ; : # line 1427 ""grammar.y"" { compiler } # line 3070 ""grammar.c"" break ; : # line 1436 ""grammar.y"" { compiler } # line 3083 ""grammar.c"" break ; : # line 1445 ""grammar.y"" { ( } # line 3091 ""grammar.c"" break ; : # line 1449 ""grammar.y"" { ( } # line 3099 ""grammar.c"" break ; : # line 1456 ""grammar.y"" { ( } # line 3105 ""grammar.c"" break ; : # line 1457 ""grammar.y"" { ( } # line 3111 ""grammar.c"" break ; : # line 1463 ""grammar.y"" { if } # line 3133 ""grammar.c"" break ; : # line 1485 ""grammar.y"" { if } # line 3149 ""grammar.c"" break ; : # line 1497 ""grammar.y"" { if } # line 3164 ""grammar.c"" break ; : # line 1512 ""grammar.y"" { yr_parser_emit_with_arg } # line 3173 ""grammar.c"" break ; : # line 1518 ""grammar.y"" { yr_parser_emit_with_arg } # line 3184 ""grammar.c"" break ; : # line 1535 ""grammar.y"" { yr_parser_emit_pushes_for_strings } # line 3195 ""grammar.c"" break ; : # line 1542 ""grammar.y"" { yr_parser_emit_pushes_for_strings } # line 3206 ""grammar.c"" break ; : # line 1554 ""grammar.y"" { yr_parser_emit_with_arg } # line 3214 ""grammar.c"" break ; : # line 1558 ""grammar.y"" { yr_parser_emit_with_arg } # line 3222 ""grammar.c"" break ; : # line 1566 ""grammar.y"" { ( } # line 3230 ""grammar.c"" break ; : # line 1570 ""grammar.y"" { compiler } # line 3244 ""grammar.c"" break ; : # line 1580 ""grammar.y"" { yywarning } # line 3262 ""grammar.c"" break ; : # line 1594 ""grammar.y"" { CHECK_TYPE } # line 3282 ""grammar.c"" break ; : # line 1610 ""grammar.y"" { compiler } # line 3296 ""grammar.c"" break ; : # line 1620 ""grammar.y"" { compiler } # line 3309 ""grammar.c"" break ; : # line 1629 ""grammar.y"" { SIZED_STRING } # line 3338 ""grammar.c"" break ; : # line 1654 ""grammar.y"" { compiler } # line 3354 ""grammar.c"" break ; : # line 1666 ""grammar.y"" { compiler } # line 3370 ""grammar.c"" break ; : # line 1678 ""grammar.y"" { compiler } # line 3390 ""grammar.c"" break ; : # line 1694 ""grammar.y"" { compiler } # line 3406 ""grammar.c"" break ; : # line 1706 ""grammar.y"" { compiler } # line 3426 ""grammar.c"" break ; : # line 1722 ""grammar.y"" { if } # line 3475 ""grammar.c"" break ; : # line 1767 ""grammar.y"" { CHECK_TYPE } # line 3498 ""grammar.c"" break ; : # line 1786 ""grammar.y"" { compiler } # line 3520 ""grammar.c"" break ; : # line 1804 ""grammar.y"" { compiler } # line 3542 ""grammar.c"" break ; : # line 1822 ""grammar.y"" { compiler } # line 3564 ""grammar.c"" break ; : # line 1840 ""grammar.y"" { compiler } # line 3594 ""grammar.c"" break ; : # line 1866 ""grammar.y"" { CHECK_TYPE } # line 3616 ""grammar.c"" break ; : # line 1884 ""grammar.y"" { CHECK_TYPE } # line 3630 ""grammar.c"" break ; : # line 1894 ""grammar.y"" { CHECK_TYPE } # line 3644 ""grammar.c"" break ; : # line 1904 ""grammar.y"" { CHECK_TYPE } # line 3658 ""grammar.c"" break ; : # line 1914 ""grammar.y"" { CHECK_TYPE } # line 3672 ""grammar.c"" break ; : # line 1924 ""grammar.y"" { CHECK_TYPE } # line 3686 ""grammar.c"" break ; : # line 1934 ""grammar.y"" { CHECK_TYPE } # line 3700 ""grammar.c"" break ; : # line 1944 ""grammar.y"" { ( } # line 3708 ""grammar.c"" break ; ; # line 3712 ""grammar.c"" default : ",VirusTotal@yara/ab906da53ff2a68c6fd6d1fa73f2b7c7bf0bc636,CVE-2017-5923,https://github.com/VirusTotal/yara/commit/ab906da53ff2a68c6fd6d1fa73f2b7c7bf0bc636,2017-04-03T05:59Z 855,CWE-835,"CWE-835 static Image * ReadTXTImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { char colorspace [ MagickPathExtent ] , text [ MagickPathExtent ] ; Image * image ; long x_offset , y_offset ; PixelInfo pixel ; MagickBooleanType status ; QuantumAny range ; register ssize_t i , x ; register Quantum * q ; ssize_t count , type , y ; unsigned long depth , height , max_value , width ; 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 ) ResetMagickMemory ( text , 0 , sizeof ( text ) ) ; ( void ) ReadBlobString ( image , text ) ; if ( LocaleNCompare ( ( char * ) text , MagickID , strlen ( MagickID ) ) != 0 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; do { width = 0 ; height = 0 ; max_value = 0 ; * colorspace = '\\0' ; count = ( ssize_t ) sscanf ( text + 32 , ""%lu,%lu,%lu,%s"" , & width , & height , & max_value , colorspace ) ; if ( ( count != 4 ) || ( width == 0 ) || ( height == 0 ) || ( max_value == 0 ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; image -> columns = width ; image -> rows = height ; for ( depth = 1 ; ( GetQuantumRange ( depth ) + 1 ) < max_value ; depth ++ ) ; image -> depth = depth ; status = SetImageExtent ( image , image -> columns , image -> rows , exception ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; LocaleLower ( colorspace ) ; i = ( ssize_t ) strlen ( colorspace ) - 1 ; image -> alpha_trait = UndefinedPixelTrait ; if ( ( i > 0 ) && ( colorspace [ i ] == 'a' ) ) { colorspace [ i ] = '\\0' ; image -> alpha_trait = BlendPixelTrait ; } type = ParseCommandOption ( MagickColorspaceOptions , MagickFalse , colorspace ) ; if ( type < 0 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; ( void ) SetImageBackgroundColor ( image , exception ) ; ( void ) SetImageColorspace ( image , ( ColorspaceType ) type , exception ) ; GetPixelInfo ( image , & pixel ) ; range = GetQuantumRange ( image -> depth ) ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { double alpha , black , blue , green , red ; red = 0.0 ; green = 0.0 ; blue = 0.0 ; black = 0.0 ; alpha = 0.0 ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { if ( ReadBlobString ( image , text ) == ( char * ) NULL ) break ; switch ( image -> colorspace ) { case GRAYColorspace : { if ( image -> alpha_trait != UndefinedPixelTrait ) { count = ( ssize_t ) sscanf ( text , ""%ld,%ld:(%lf%*[%,]%lf%*[%,]"" , & x_offset , & y_offset , & red , & alpha ) ; green = red ; blue = red ; break ; } count = ( ssize_t ) sscanf ( text , ""%ld,%ld:(%lf%*[%,]"" , & x_offset , & y_offset , & red ) ; green = red ; blue = red ; break ; } case CMYKColorspace : { if ( image -> alpha_trait != UndefinedPixelTrait ) { count = ( ssize_t ) sscanf ( text , ""%ld,%ld:(%lf%*[%,]%lf%*[%,]%lf%*[%,]%lf%*[%,]%lf%*[%,]"" , & x_offset , & y_offset , & red , & green , & blue , & black , & alpha ) ; break ; } count = ( ssize_t ) sscanf ( text , ""%ld,%ld:(%lf%*[%,]%lf%*[%,]%lf%*[%,]%lf%*[%,]"" , & x_offset , & y_offset , & red , & green , & blue , & black ) ; break ; } default : { if ( image -> alpha_trait != UndefinedPixelTrait ) { count = ( ssize_t ) sscanf ( text , ""%ld,%ld:(%lf%*[%,]%lf%*[%,]%lf%*[%,]%lf%*[%,]"" , & x_offset , & y_offset , & red , & green , & blue , & alpha ) ; break ; } count = ( ssize_t ) sscanf ( text , ""%ld,%ld:(%lf%*[%,]%lf%*[%,]%lf%*[%,]"" , & x_offset , & y_offset , & red , & green , & blue ) ; break ; } } if ( strchr ( text , '%' ) != ( char * ) NULL ) { red *= 0.01 * range ; green *= 0.01 * range ; blue *= 0.01 * range ; black *= 0.01 * range ; alpha *= 0.01 * range ; } if ( image -> colorspace == LabColorspace ) { green += ( range + 1 ) / 2.0 ; blue += ( range + 1 ) / 2.0 ; } pixel . red = ( MagickRealType ) ScaleAnyToQuantum ( ( QuantumAny ) ( red + 0.5 ) , range ) ; pixel . green = ( MagickRealType ) ScaleAnyToQuantum ( ( QuantumAny ) ( green + 0.5 ) , range ) ; pixel . blue = ( MagickRealType ) ScaleAnyToQuantum ( ( QuantumAny ) ( blue + 0.5 ) , range ) ; pixel . black = ( MagickRealType ) ScaleAnyToQuantum ( ( QuantumAny ) ( black + 0.5 ) , range ) ; pixel . alpha = ( MagickRealType ) ScaleAnyToQuantum ( ( QuantumAny ) ( alpha + 0.5 ) , range ) ; q = GetAuthenticPixels ( image , ( ssize_t ) x_offset , ( ssize_t ) y_offset , 1 , 1 , exception ) ; if ( q == ( Quantum * ) NULL ) continue ; SetPixelViaPixelInfo ( image , & pixel , q ) ; if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } } ( void ) ReadBlobString ( image , text ) ; if ( LocaleNCompare ( ( char * ) text , MagickID , strlen ( MagickID ) ) == 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 ( LocaleNCompare ( ( char * ) text , MagickID , strlen ( MagickID ) ) == 0 ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," ; } } if ( EOFBlob ( image ) != MagickFalse ) { ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; break ; } ",ImageMagick@ImageMagick/83e0f8ffd7eeb7661b0ff83257da23d24ca7f078,CVE-2017-11523,https://github.com/ImageMagick/ImageMagick/commit/83e0f8ffd7eeb7661b0ff83257da23d24ca7f078,2017-07-22T21:29Z 856,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 857,CWE-119,"CWE-119 void vp9_init_mv_probs ( VP9_COMMON * cm ) { cm -> fc . nmvc = default_nmv_context ; } "," cm -> fc -> nmvc = default_nmv_context ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 858,CWE-476,"CWE-476 static bool check_client_passwd ( PgSocket * client , const char * passwd ) { char md5 [ MD5_PASSWD_LEN + 1 ] ; const char * correct ; PgUser * user = client -> auth_user ; if ( ! * passwd || ! * user -> passwd ) return false ; switch ( cf_auth_type ) { case AUTH_PLAIN : return strcmp ( user -> passwd , passwd ) == 0 ; case AUTH_CRYPT : correct = crypt ( user -> passwd , ( char * ) client -> tmp_login_salt ) ; return correct && strcmp ( correct , passwd ) == 0 ; case AUTH_MD5 : if ( strlen ( passwd ) != MD5_PASSWD_LEN ) return false ; if ( ! isMD5 ( user -> passwd ) ) pg_md5_encrypt ( user -> passwd , user -> name , strlen ( user -> name ) , user -> passwd ) ; pg_md5_encrypt ( user -> passwd + 3 , ( char * ) client -> tmp_login_salt , 4 , md5 ) ; return strcmp ( md5 , passwd ) == 0 ; } return false ; } "," if ( ! user ) { slog_error ( client , ""Passwordpacketbeforeauthpacket?"" ) ; return false ; } if ( ! ",pgbouncer@pgbouncer/edab5be6665b9e8de66c25ba527509b229468573,CVE-2015-4054,https://github.com/pgbouncer/pgbouncer/commit/edab5be6665b9e8de66c25ba527509b229468573,2017-05-23T04:29Z 859,CWE-20,"CWE-20 static bool parse_notify ( struct pool * pool , json_t * val ) { char * job_id , * prev_hash , * coinbase1 , * coinbase2 , * bbversion , * nbit , * ntime , * header ; size_t cb1_len , cb2_len , alloc_len ; unsigned char * cb1 , * cb2 ; 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 ( prev_hash ) free ( prev_hash ) ; if ( coinbase1 ) free ( coinbase1 ) ; if ( coinbase2 ) free ( coinbase2 ) ; if ( bbversion ) free ( bbversion ) ; if ( nbit ) free ( nbit ) ; if ( ntime ) free ( ntime ) ; goto out ; } cg_wlock ( & pool -> data_lock ) ; free ( pool -> swork . job_id ) ; free ( pool -> swork . prev_hash ) ; free ( pool -> swork . bbversion ) ; free ( pool -> swork . nbit ) ; free ( pool -> swork . ntime ) ; pool -> swork . job_id = job_id ; pool -> swork . prev_hash = prev_hash ; cb1_len = strlen ( coinbase1 ) / 2 ; cb2_len = strlen ( coinbase2 ) / 2 ; pool -> swork . bbversion = bbversion ; pool -> swork . nbit = nbit ; pool -> swork . ntime = ntime ; pool -> swork . clean = clean ; alloc_len = pool -> swork . cb_len = cb1_len + pool -> n1_len + pool -> n2size + cb2_len ; pool -> nonce2_offset = cb1_len + pool -> n1_len ; for ( i = 0 ; i < pool -> swork . merkles ; i ++ ) free ( pool -> swork . merkle_bin [ i ] ) ; if ( merkles ) { pool -> swork . merkle_bin = ( unsigned char * * ) 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 ] = ( unsigned char * ) malloc ( 32 ) ; if ( unlikely ( ! pool -> swork . merkle_bin [ i ] ) ) quit ( 1 , ""Failedtomallocpoolsworkmerkle_bin"" ) ; hex2bin ( pool -> swork . merkle_bin [ i ] , merkle , 32 ) ; free ( merkle ) ; } } pool -> swork . merkles = merkles ; if ( clean ) pool -> nonce2 = 0 ; pool -> merkle_offset = strlen ( pool -> swork . bbversion ) + strlen ( pool -> swork . prev_hash ) ; pool -> swork . header_len = pool -> merkle_offset + 32 + strlen ( pool -> swork . ntime ) + strlen ( pool -> swork . nbit ) + 8 + 96 ; pool -> merkle_offset /= 2 ; pool -> swork . header_len = pool -> swork . header_len * 2 + 1 ; align_len ( & pool -> swork . header_len ) ; header = ( char * ) alloca ( pool -> swork . header_len ) ; snprintf ( header , pool -> swork . header_len , ""%s%s%s%s%s%s%s"" , pool -> swork . bbversion , pool -> swork . prev_hash , blank_merkel , pool -> swork . ntime , pool -> swork . nbit , ""00000000"" , workpadding ) ; if ( unlikely ( ! hex2bin ( pool -> header_bin , header , 128 ) ) ) quit ( 1 , ""Failedtoconvertheadertoheader_bininparse_notify"" ) ; cb1 = ( unsigned char * ) calloc ( cb1_len , 1 ) ; if ( unlikely ( ! cb1 ) ) quithere ( 1 , ""Failedtocalloccb1inparse_notify"" ) ; hex2bin ( cb1 , coinbase1 , cb1_len ) ; cb2 = ( unsigned char * ) calloc ( cb2_len , 1 ) ; if ( unlikely ( ! cb2 ) ) quithere ( 1 , ""Failedtocalloccb2inparse_notify"" ) ; hex2bin ( cb2 , coinbase2 , cb2_len ) ; free ( pool -> coinbase ) ; align_len ( & alloc_len ) ; pool -> coinbase = ( unsigned char * ) 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 ) ; 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 ) ; free ( cb1 ) ; free ( cb2 ) ; pool -> getwork_requested ++ ; total_getworks ++ ; ret = true ; if ( pool == current_pool ( ) ) opt_work_update = true ; out : return ret ; } "," ) ) ) { applog ( LOG_WARNING , ""%s:Failedtoconvertheadertoheader_bin,got%s"" , __func__ , header ) ; pool_failed ( pool ) ; return false ; } cb1 = ( ",sgminer-dev@sgminer/910c36089940e81fb85c65b8e63dcd2fac71470c,CVE-2014-4503,https://github.com/sgminer-dev/sgminer/commit/910c36089940e81fb85c65b8e63dcd2fac71470c,2014-07-23T14:55Z 860,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 861,CWE-476,"CWE-476 static void jpc_undo_roi ( jas_matrix_t * x , int roishift , int bgshift , int numbps ) { int i ; int j ; int thresh ; jpc_fix_t val ; jpc_fix_t mag ; bool warn ; uint_fast32_t mask ; if ( roishift == 0 && bgshift == 0 ) { return ; } thresh = 1 << roishift ; warn = false ; for ( i = 0 ; i < jas_matrix_numrows ( x ) ; ++ i ) { for ( j = 0 ; j < jas_matrix_numcols ( x ) ; ++ j ) { val = jas_matrix_get ( x , i , j ) ; mag = JAS_ABS ( val ) ; if ( mag >= thresh ) { mag >>= roishift ; val = ( val < 0 ) ? ( - mag ) : mag ; jas_matrix_set ( x , i , j , val ) ; } else { mag <<= bgshift ; mask = ( 1 << numbps ) - 1 ; if ( mag & ( ~ mask ) ) { if ( ! warn ) { jas_eprintf ( ""warning:possiblycorruptcodestream\\n"" ) ; warn = true ; } mag &= mask ; } val = ( val < 0 ) ? ( - mag ) : mag ; jas_matrix_set ( x , i , j , val ) ; } } } } "," if ( roishift < 0 ) { jas_eprintf ( ""warning:forcingnegativeROIshifttozero"" ""(bitstreamisprobablycorrupt)\\n"" ) ; roishift = 0 ; } if ( roishift mask = ( JAS_CAST ( uint_fast32_t , 1 ) << numbps ) ",mdadams@jasper/2e82fa00466ae525339754bb3ab0a0474a31d4bd,CVE-2016-10248,https://github.com/mdadams/jasper/commit/2e82fa00466ae525339754bb3ab0a0474a31d4bd,2017-03-15T14:59Z 862,CWE-354,"CWE-354 void next_character ( void ) { strlcpy ( cipher , english_alphabet , ENGLISH_ALPHABET_BUF ) ; random_permute_char ( cipher , strlen ( cipher ) ) ; static char CONFIDENTIAL current_word [ CURRENT_WORD_BUF ] ; get_current_word ( current_word ) ; if ( strlen ( current_word ) > 4 ) { memzero ( current_word , sizeof ( current_word ) ) ; recovery_abort ( ) ; fsm_sendFailure ( FailureType_Failure_SyntaxError , ""Wordswerenotenteredcorrectly.Makesureyouareusingthesubstitioncipher."" ) ; layoutHome ( ) ; return ; } CharacterRequest resp ; memset ( & resp , 0 , sizeof ( CharacterRequest ) ) ; resp . word_pos = get_current_word_pos ( ) ; resp . character_pos = strlen ( current_word ) ; msg_write ( MessageType_MessageType_CharacterRequest , & resp ) ; bool auto_completed = false ; if ( strlen ( current_word ) >= 3 ) { auto_completed = attempt_auto_complete ( current_word ) ; } # if DEBUG_LINK if ( auto_completed ) { strlcpy ( auto_completed_word , current_word , CURRENT_WORD_BUF ) ; } else { auto_completed_word [ 0 ] = '\\0' ; } # endif format_current_word ( current_word , auto_completed ) ; layout_cipher ( current_word , cipher ) ; memzero ( current_word , sizeof ( current_word ) ) ; } "," 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 863,CWE-125,"CWE-125 struct _mdi * _WM_ParseNewMus ( uint8_t * mus_data , uint32_t mus_size ) { uint8_t mus_hdr [ ] = { 'M' , 'U' , 'S' , 0x1A } ; uint32_t mus_song_ofs = 0 ; uint32_t mus_song_len = 0 ; uint16_t mus_ch_cnt1 = 0 ; uint16_t mus_ch_cnt2 = 0 ; uint16_t mus_no_instr = 0 ; uint32_t mus_data_ofs = 0 ; uint16_t * mus_mid_instr = NULL ; uint16_t mus_instr_cnt = 0 ; struct _mdi * mus_mdi ; uint32_t mus_divisions = 60 ; float tempo_f = 0.0 ; uint16_t mus_freq = 0 ; float samples_per_tick_f = 0.0 ; uint8_t mus_event [ ] = { 0 , 0 , 0 , 0 } ; uint8_t mus_event_size = 0 ; uint8_t mus_prev_vol [ ] = { 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 } ; uint32_t setup_ret = 0 ; uint32_t mus_ticks = 0 ; uint32_t sample_count = 0 ; float sample_count_f = 0.0 ; float sample_remainder = 0.0 ; uint16_t pitchbend_tmp = 0 ; if ( mus_size < 17 ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_NOT_MUS , ""Filetooshort"" , 0 ) ; return NULL ; } if ( memcmp ( mus_data , mus_hdr , 4 ) ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_NOT_MUS , NULL , 0 ) ; return NULL ; } mus_song_len = ( mus_data [ 5 ] << 8 ) | mus_data [ 4 ] ; mus_song_ofs = ( mus_data [ 7 ] << 8 ) | mus_data [ 6 ] ; mus_ch_cnt1 = ( mus_data [ 9 ] << 8 ) | mus_data [ 8 ] ; mus_ch_cnt2 = ( mus_data [ 11 ] << 8 ) | mus_data [ 10 ] ; UNUSED ( mus_ch_cnt1 ) ; UNUSED ( mus_ch_cnt2 ) ; mus_no_instr = ( mus_data [ 13 ] << 8 ) | mus_data [ 12 ] ; mus_data_ofs = 16 ; if ( mus_size < ( mus_data_ofs + ( mus_no_instr << 1 ) + mus_song_len ) ) { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_NOT_MUS , ""Filetooshort"" , 0 ) ; return NULL ; } mus_mid_instr = malloc ( mus_no_instr * sizeof ( uint16_t ) ) ; for ( mus_instr_cnt = 0 ; mus_instr_cnt < mus_no_instr ; mus_instr_cnt ++ ) { mus_mid_instr [ mus_instr_cnt ] = ( mus_data [ mus_data_ofs + 1 ] << 8 ) | mus_data [ mus_data_ofs ] ; mus_data_ofs += 2 ; } mus_data_ofs = mus_song_ofs ; mus_freq = _cvt_get_option ( WM_CO_FREQUENCY ) ; if ( mus_freq == 0 ) mus_freq = 140 ; if ( ( _WM_MixerOptions & WM_MO_ROUNDTEMPO ) ) { tempo_f = ( float ) ( 60000000 / mus_freq ) + 0.5f ; } else { tempo_f = ( float ) ( 60000000 / mus_freq ) ; } samples_per_tick_f = _WM_GetSamplesPerTick ( mus_divisions , ( uint32_t ) tempo_f ) ; mus_mdi = _WM_initMDI ( ) ; _WM_midi_setup_divisions ( mus_mdi , mus_divisions ) ; _WM_midi_setup_tempo ( mus_mdi , ( uint32_t ) tempo_f ) ; do { _mus_build_event : # if 1 MUS_EVENT_DEBUG ( ""Before"" , mus_data [ mus_data_ofs ] , 0 ) ; if ( ( mus_data [ mus_data_ofs ] & 0x0f ) == 0x0f ) { mus_data [ mus_data_ofs ] = ( mus_data [ mus_data_ofs ] & 0xf0 ) | 0x09 ; } else if ( ( mus_data [ mus_data_ofs ] & 0x0f ) == 0x09 ) { mus_data [ mus_data_ofs ] = ( mus_data [ mus_data_ofs ] & 0xf0 ) | 0x0f ; } MUS_EVENT_DEBUG ( ""After"" , mus_data [ mus_data_ofs ] , 0 ) ; # endif switch ( ( mus_data [ mus_data_ofs ] >> 4 ) & 0x07 ) { case 0 : mus_event_size = 2 ; mus_event [ 0 ] = 0x80 | ( mus_data [ mus_data_ofs ] & 0x0f ) ; mus_event [ 1 ] = mus_data [ mus_data_ofs + 1 ] ; mus_event [ 2 ] = 0 ; mus_event [ 3 ] = 0 ; break ; case 1 : if ( mus_data [ mus_data_ofs + 1 ] & 0x80 ) { mus_event_size = 3 ; mus_event [ 0 ] = 0x90 | ( mus_data [ mus_data_ofs ] & 0x0f ) ; mus_event [ 1 ] = mus_data [ mus_data_ofs + 1 ] & 0x7f ; mus_event [ 2 ] = mus_data [ mus_data_ofs + 2 ] ; mus_event [ 3 ] = 0 ; mus_prev_vol [ mus_data [ mus_data_ofs ] & 0x0f ] = mus_event [ 2 ] ; } else { mus_event_size = 2 ; mus_event [ 0 ] = 0x90 | ( mus_data [ mus_data_ofs ] & 0x0f ) ; mus_event [ 1 ] = mus_data [ mus_data_ofs + 1 ] ; mus_event [ 2 ] = mus_prev_vol [ mus_data [ mus_data_ofs ] & 0x0f ] ; mus_event [ 3 ] = 0 ; } break ; case 2 : mus_event_size = 2 ; mus_event [ 0 ] = 0xe0 | ( mus_data [ mus_data_ofs ] & 0x0f ) ; pitchbend_tmp = mus_data [ mus_data_ofs + 1 ] << 6 ; mus_event [ 1 ] = pitchbend_tmp & 0x7f ; mus_event [ 2 ] = ( pitchbend_tmp >> 7 ) & 0x7f ; mus_event [ 3 ] = 0 ; break ; case 3 : mus_event_size = 2 ; switch ( mus_data [ mus_data_ofs + 1 ] ) { case 10 : mus_event [ 0 ] = 0xb0 | ( mus_data [ mus_data_ofs ] & 0x0f ) ; mus_event [ 1 ] = 120 ; mus_event [ 2 ] = 0 ; mus_event [ 3 ] = 0 ; break ; case 11 : mus_event [ 0 ] = 0xb0 | ( mus_data [ mus_data_ofs ] & 0x0f ) ; mus_event [ 1 ] = 123 ; mus_event [ 2 ] = 0 ; mus_event [ 3 ] = 0 ; break ; case 12 : mus_event [ 0 ] = 0xb0 | ( mus_data [ mus_data_ofs ] & 0x0f ) ; mus_event [ 1 ] = 126 ; mus_event [ 2 ] = 0 ; mus_event [ 3 ] = 0 ; break ; case 13 : mus_event [ 0 ] = 0xb0 | ( mus_data [ mus_data_ofs ] & 0x0f ) ; mus_event [ 1 ] = 127 ; mus_event [ 2 ] = 0 ; mus_event [ 3 ] = 0 ; break ; case 14 : mus_event [ 0 ] = 0xb0 | ( mus_data [ mus_data_ofs ] & 0x0f ) ; mus_event [ 1 ] = 121 ; mus_event [ 2 ] = 0 ; mus_event [ 3 ] = 0 ; break ; default : goto _mus_next_data ; } break ; case 4 : mus_event_size = 3 ; switch ( mus_data [ mus_data_ofs + 1 ] ) { case 0 : mus_event [ 0 ] = 0xc0 | ( mus_data [ mus_data_ofs ] & 0x0f ) ; mus_event [ 1 ] = mus_data [ mus_data_ofs + 2 ] ; mus_event [ 2 ] = 0 ; mus_event [ 3 ] = 0 ; break ; case 1 : mus_event [ 0 ] = 0xb0 | ( mus_data [ mus_data_ofs ] & 0x0f ) ; mus_event [ 1 ] = 0 ; mus_event [ 2 ] = mus_data [ mus_data_ofs + 2 ] ; mus_event [ 3 ] = 0 ; break ; case 2 : mus_event [ 0 ] = 0xb0 | ( mus_data [ mus_data_ofs ] & 0x0f ) ; mus_event [ 1 ] = 1 ; mus_event [ 2 ] = mus_data [ mus_data_ofs + 2 ] ; mus_event [ 3 ] = 0 ; break ; case 3 : mus_event [ 0 ] = 0xb0 | ( mus_data [ mus_data_ofs ] & 0x0f ) ; mus_event [ 1 ] = 7 ; mus_event [ 2 ] = mus_data [ mus_data_ofs + 2 ] ; mus_event [ 3 ] = 0 ; break ; case 4 : mus_event [ 0 ] = 0xb0 | ( mus_data [ mus_data_ofs ] & 0x0f ) ; mus_event [ 1 ] = 10 ; mus_event [ 2 ] = mus_data [ mus_data_ofs + 2 ] ; mus_event [ 3 ] = 0 ; break ; case 5 : mus_event [ 0 ] = 0xb0 | ( mus_data [ mus_data_ofs ] & 0x0f ) ; mus_event [ 1 ] = 11 ; mus_event [ 2 ] = mus_data [ mus_data_ofs + 2 ] ; mus_event [ 3 ] = 0 ; break ; case 6 : mus_event [ 0 ] = 0xb0 | ( mus_data [ mus_data_ofs ] & 0x0f ) ; mus_event [ 1 ] = 91 ; mus_event [ 2 ] = mus_data [ mus_data_ofs + 2 ] ; mus_event [ 3 ] = 0 ; break ; case 7 : mus_event [ 0 ] = 0xb0 | ( mus_data [ mus_data_ofs ] & 0x0f ) ; mus_event [ 1 ] = 93 ; mus_event [ 2 ] = mus_data [ mus_data_ofs + 2 ] ; mus_event [ 3 ] = 0 ; break ; case 8 : mus_event [ 0 ] = 0xb0 | ( mus_data [ mus_data_ofs ] & 0x0f ) ; mus_event [ 1 ] = 64 ; mus_event [ 2 ] = mus_data [ mus_data_ofs + 2 ] ; mus_event [ 3 ] = 0 ; break ; case 9 : mus_event [ 0 ] = 0xb0 | ( mus_data [ mus_data_ofs ] & 0x0f ) ; mus_event [ 1 ] = 67 ; mus_event [ 2 ] = mus_data [ mus_data_ofs + 2 ] ; mus_event [ 3 ] = 0 ; break ; default : goto _mus_next_data ; } break ; case 5 : mus_event_size = 1 ; goto _mus_next_data ; break ; case 6 : goto _mus_end_of_song ; break ; case 7 : mus_event_size = 1 ; goto _mus_next_data ; break ; } setup_ret = _WM_SetupMidiEvent ( mus_mdi , ( uint8_t * ) mus_event , 0 ) ; if ( setup_ret == 0 ) { goto _mus_end ; } _mus_next_data : if ( ! ( mus_data [ mus_data_ofs ] & 0x80 ) ) { mus_data_ofs += mus_event_size ; goto _mus_build_event ; } mus_data_ofs += mus_event_size ; mus_ticks = 0 ; do { mus_ticks = ( mus_ticks << 7 ) | ( mus_data [ mus_data_ofs ++ ] & 0x7f ) ; } while ( mus_data [ mus_data_ofs - 1 ] & 0x80 ) ; sample_count_f = ( ( float ) mus_ticks * samples_per_tick_f ) + sample_remainder ; sample_count = ( uint32_t ) sample_count_f ; sample_remainder = sample_count_f - ( float ) sample_count ; mus_mdi -> events [ mus_mdi -> event_count - 1 ] . samples_to_next = sample_count ; mus_mdi -> extra_info . approx_total_samples += sample_count ; } while ( mus_data_ofs < mus_size ) ; _mus_end_of_song : if ( ( mus_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 _mus_end ; } _WM_midi_setup_endoftrack ( mus_mdi ) ; mus_mdi -> extra_info . current_sample = 0 ; mus_mdi -> current_event = & mus_mdi -> events [ 0 ] ; mus_mdi -> samples_to_mix = 0 ; mus_mdi -> note = NULL ; _WM_ResetToStart ( mus_mdi ) ; _mus_end : free ( mus_mid_instr ) ; if ( mus_mdi -> reverb ) return ( mus_mdi ) ; _WM_freeMDI ( mus_mdi ) ; return NULL ; } "," = 0.0 ; # define MUS_SZ 4 uint8_t mus_event [ MUS_SZ * ) mus_event , MUS_SZ ",Mindwerks@wildmidi/660b513d99bced8783a4a5984ac2f742c74ebbdd,CVE-2017-11664,https://github.com/Mindwerks/wildmidi/commit/660b513d99bced8783a4a5984ac2f742c74ebbdd,2017-08-17T16:29Z 864,CWE-269,"CWE-269 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 ; } ",iortcw@iortcw/b6ff2bcb1e4e6976d61e316175c6d7c99860fe20,CVE-2017-6903,https://github.com/iortcw/iortcw/commit/b6ff2bcb1e4e6976d61e316175c6d7c99860fe20,2017-03-14T22:59Z 865,CWE-476,"CWE-476 static int f2fs_set_data_page_dirty ( struct page * page ) { struct address_space * mapping = page -> mapping ; struct inode * inode = mapping -> host ; trace_f2fs_set_page_dirty ( page , DATA ) ; if ( ! PageUptodate ( page ) ) SetPageUptodate ( page ) ; if ( f2fs_is_atomic_file ( inode ) && ! f2fs_is_commit_atomic_write ( inode ) ) { if ( ! IS_ATOMIC_WRITTEN_PAGE ( page ) ) { f2fs_register_inmem_page ( inode , page ) ; return 1 ; } return 0 ; } if ( ! PageDirty ( page ) ) { __set_page_dirty_nobuffers ( page ) ; f2fs_update_dirty_page ( inode , page ) ; return 1 ; } return 0 ; } "," ) { struct inode * inode * inode = page_file_mapping ( page ) -> host ; ) ) SetPageUptodate ( page ) ; if ( PageSwapCache ( page ) ) return __set_page_dirty_nobuffers ",torvalds@linux/4969c06a0d83c9c3dc50b8efcdc8eeedfce896f6,CVE-2019-19815,https://github.com/torvalds/linux/commit/4969c06a0d83c9c3dc50b8efcdc8eeedfce896f6,2019-12-17T07:15Z 866,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 867,CWE-119,"CWE-119 static void get_frame_stats ( vpx_codec_ctx_t * ctx , const vpx_image_t * img , vpx_codec_pts_t pts , unsigned int duration , vpx_enc_frame_flags_t flags , unsigned int deadline , vpx_fixed_buf_t * stats ) { vpx_codec_iter_t iter = NULL ; const vpx_codec_cx_pkt_t * pkt = NULL ; const vpx_codec_err_t res = vpx_codec_encode ( ctx , img , pts , duration , flags , deadline ) ; if ( res != VPX_CODEC_OK ) die_codec ( ctx , ""Failedtogetframestats."" ) ; while ( ( pkt = vpx_codec_get_cx_data ( ctx , & iter ) ) != NULL ) { if ( pkt -> kind == VPX_CODEC_STATS_PKT ) { const uint8_t * const pkt_buf = pkt -> data . twopass_stats . buf ; const size_t pkt_size = pkt -> data . twopass_stats . sz ; stats -> buf = realloc ( stats -> buf , stats -> sz + pkt_size ) ; memcpy ( ( uint8_t * ) stats -> buf + stats -> sz , pkt_buf , pkt_size ) ; stats -> sz += pkt_size ; } } } "," static int get_frame_stats ( vpx_codec_ctx_t stats ) { int got_pkts = 0 ; NULL ) { got_pkts = 1 ; ; } } return got_pkts ; ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 868,CWE-119,"CWE-119 static int logi_dj_ll_raw_request ( struct hid_device * hid , unsigned char reportnum , __u8 * buf , size_t count , unsigned char report_type , int reqtype ) { struct dj_device * djdev = hid -> driver_data ; struct dj_receiver_dev * djrcv_dev = djdev -> dj_receiver_dev ; u8 * out_buf ; int ret ; if ( buf [ 0 ] != REPORT_TYPE_LEDS ) return - EINVAL ; out_buf = kzalloc ( DJREPORT_SHORT_LENGTH , GFP_ATOMIC ) ; if ( ! out_buf ) return - ENOMEM ; if ( count < DJREPORT_SHORT_LENGTH - 2 ) count = DJREPORT_SHORT_LENGTH - 2 ; out_buf [ 0 ] = REPORT_ID_DJ_SHORT ; out_buf [ 1 ] = djdev -> device_index ; memcpy ( out_buf + 2 , buf , count ) ; ret = hid_hw_raw_request ( djrcv_dev -> hdev , out_buf [ 0 ] , out_buf , DJREPORT_SHORT_LENGTH , report_type , reqtype ) ; kfree ( out_buf ) ; return ret ; } "," if ( count > DJREPORT_SHORT_LENGTH - 2 ",torvalds@linux/51217e69697fba92a06e07e16f55c9a52d8e8945,CVE-2014-3183,https://github.com/torvalds/linux/commit/51217e69697fba92a06e07e16f55c9a52d8e8945,2014-09-28T10:55Z 869,CWE-119,"CWE-119 int vp9_loop_filter_worker ( void * arg1 , void * arg2 ) { LFWorkerData * const lf_data = ( LFWorkerData * ) arg1 ; ( void ) arg2 ; vp9_loop_filter_rows ( lf_data -> frame_buffer , lf_data -> cm , & lf_data -> xd , lf_data -> start , lf_data -> stop , lf_data -> y_only ) ; return 1 ; } "," int vp9_loop_filter_worker ( LFWorkerData * const * const lf_data , void * unused ) { ( void ) ( void ) unused ; vp9_loop_filter_rows ( -> cm , lf_data -> planes , lf_data -> ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 870,CWE-119,"CWE-119 static int do_ip_vs_set_ctl ( struct sock * sk , int cmd , void __user * user , unsigned int len ) { int ret ; unsigned char arg [ MAX_ARG_LEN ] ; struct ip_vs_service_user * usvc_compat ; struct ip_vs_service_user_kern usvc ; struct ip_vs_service * svc ; struct ip_vs_dest_user * udest_compat ; struct ip_vs_dest_user_kern udest ; if ( ! capable ( CAP_NET_ADMIN ) ) return - EPERM ; if ( len != set_arglen [ SET_CMDID ( cmd ) ] ) { pr_err ( ""set_ctl:len%u!=%u\\n"" , len , set_arglen [ SET_CMDID ( cmd ) ] ) ; return - EINVAL ; } if ( copy_from_user ( arg , user , len ) != 0 ) return - EFAULT ; ip_vs_use_count_inc ( ) ; if ( mutex_lock_interruptible ( & __ip_vs_mutex ) ) { ret = - ERESTARTSYS ; goto out_dec ; } if ( cmd == IP_VS_SO_SET_FLUSH ) { ret = ip_vs_flush ( ) ; goto out_unlock ; } else if ( cmd == IP_VS_SO_SET_TIMEOUT ) { ret = ip_vs_set_timeout ( ( struct ip_vs_timeout_user * ) arg ) ; goto out_unlock ; } else if ( cmd == IP_VS_SO_SET_STARTDAEMON ) { struct ip_vs_daemon_user * dm = ( struct ip_vs_daemon_user * ) arg ; ret = start_sync_thread ( dm -> state , dm -> mcast_ifn , dm -> syncid ) ; goto out_unlock ; } else if ( cmd == IP_VS_SO_SET_STOPDAEMON ) { struct ip_vs_daemon_user * dm = ( struct ip_vs_daemon_user * ) arg ; ret = stop_sync_thread ( dm -> state ) ; goto out_unlock ; } usvc_compat = ( struct ip_vs_service_user * ) arg ; udest_compat = ( struct ip_vs_dest_user * ) ( usvc_compat + 1 ) ; ip_vs_copy_usvc_compat ( & usvc , usvc_compat ) ; ip_vs_copy_udest_compat ( & udest , udest_compat ) ; if ( cmd == IP_VS_SO_SET_ZERO ) { if ( ! usvc . fwmark && ! usvc . addr . ip && ! usvc . port ) { ret = ip_vs_zero_all ( ) ; goto out_unlock ; } } if ( usvc . protocol != IPPROTO_TCP && usvc . protocol != IPPROTO_UDP ) { pr_err ( ""set_ctl:invalidprotocol:%d%pI4:%d%s\\n"" , usvc . protocol , & usvc . addr . ip , ntohs ( usvc . port ) , usvc . sched_name ) ; ret = - EFAULT ; goto out_unlock ; } if ( usvc . fwmark == 0 ) svc = __ip_vs_service_get ( usvc . af , usvc . protocol , & usvc . addr , usvc . port ) ; else svc = __ip_vs_svc_fwm_get ( usvc . af , usvc . fwmark ) ; if ( cmd != IP_VS_SO_SET_ADD && ( svc == NULL || svc -> protocol != usvc . protocol ) ) { ret = - ESRCH ; goto out_unlock ; } switch ( cmd ) { case IP_VS_SO_SET_ADD : if ( svc != NULL ) ret = - EEXIST ; else ret = ip_vs_add_service ( & usvc , & svc ) ; break ; case IP_VS_SO_SET_EDIT : ret = ip_vs_edit_service ( svc , & usvc ) ; break ; case IP_VS_SO_SET_DEL : ret = ip_vs_del_service ( svc ) ; if ( ! ret ) goto out_unlock ; break ; case IP_VS_SO_SET_ZERO : ret = ip_vs_zero_service ( svc ) ; break ; case IP_VS_SO_SET_ADDDEST : ret = ip_vs_add_dest ( svc , & udest ) ; break ; case IP_VS_SO_SET_EDITDEST : ret = ip_vs_edit_dest ( svc , & udest ) ; break ; case IP_VS_SO_SET_DELDEST : ret = ip_vs_del_dest ( svc , & udest ) ; break ; default : ret = - EINVAL ; } if ( svc ) ip_vs_service_put ( svc ) ; out_unlock : mutex_unlock ( & __ip_vs_mutex ) ; out_dec : ip_vs_use_count_dec ( ) ; return ret ; } "," ; if ( cmd < IP_VS_BASE_CTL || cmd > IP_VS_SO_SET_MAX ) return - EINVAL ; if ( len < 0 || len > MAX_ARG_LEN ) return - EINVAL ; if ( ",torvalds@linux/04bcef2a83f40c6db24222b27a52892cba39dffb,CVE-2013-4588,https://github.com/torvalds/linux/commit/04bcef2a83f40c6db24222b27a52892cba39dffb,2013-11-20T13:19Z 871,CWE-189,"CWE-189 static int32 makepol ( QPRS_STATE * state ) { int32 val = 0 , type ; int32 lenval = 0 ; char * strval = NULL ; int32 stack [ STACKDEPTH ] ; int32 lenstack = 0 ; uint16 flag = 0 ; while ( ( type = gettoken_query ( state , & val , & lenval , & strval , & flag ) ) != END ) { switch ( type ) { case VAL : pushval_asis ( state , VAL , strval , lenval , flag ) ; while ( lenstack && ( stack [ lenstack - 1 ] == ( int32 ) '&' || stack [ lenstack - 1 ] == ( int32 ) '!' ) ) { lenstack -- ; pushquery ( state , OPR , stack [ lenstack ] , 0 , 0 , 0 ) ; } break ; case OPR : if ( lenstack && val == ( int32 ) '|' ) pushquery ( state , OPR , val , 0 , 0 , 0 ) ; else { if ( lenstack == STACKDEPTH ) elog ( ERROR , ""stacktooshort"" ) ; stack [ lenstack ] = val ; lenstack ++ ; } break ; case OPEN : if ( makepol ( state ) == ERR ) return ERR ; while ( lenstack && ( stack [ lenstack - 1 ] == ( int32 ) '&' || stack [ lenstack - 1 ] == ( int32 ) '!' ) ) { lenstack -- ; pushquery ( state , OPR , stack [ lenstack ] , 0 , 0 , 0 ) ; } break ; case CLOSE : while ( lenstack ) { lenstack -- ; pushquery ( state , OPR , stack [ lenstack ] , 0 , 0 , 0 ) ; } ; return END ; break ; case ERR : default : ereport ( ERROR , ( errcode ( ERRCODE_SYNTAX_ERROR ) , errmsg ( ""syntaxerror"" ) ) ) ; return ERR ; } } while ( lenstack ) { lenstack -- ; pushquery ( state , OPR , stack [ lenstack ] , 0 , 0 , 0 ) ; } ; return END ; } "," = 0 ; check_stack_depth ( ) ; ",postgres@postgres/31400a673325147e1205326008e32135a78b4d8a,CVE-2014-2669,https://github.com/postgres/postgres/commit/31400a673325147e1205326008e32135a78b4d8a,2014-03-31T14:58Z 872,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 873,CWE-125,"CWE-125 static expr_ty ast_for_call ( struct compiling * c , const node * n , expr_ty func ) { int i , nargs , nkeywords , ngens ; asdl_seq * args ; asdl_seq * keywords ; expr_ty vararg = NULL , kwarg = NULL ; REQ ( n , arglist ) ; nargs = 0 ; nkeywords = 0 ; ngens = 0 ; for ( i = 0 ; i < NCH ( n ) ; i ++ ) { node * ch = CHILD ( n , i ) ; if ( TYPE ( ch ) == argument ) { if ( NCH ( ch ) == 1 ) nargs ++ ; else if ( TYPE ( CHILD ( ch , 1 ) ) == comp_for ) ngens ++ ; else nkeywords ++ ; } } if ( ngens > 1 || ( ngens && ( nargs || nkeywords ) ) ) { ast_error ( n , ""Generatorexpressionmustbeparenthesized"" ""ifnotsoleargument"" ) ; return NULL ; } if ( nargs + nkeywords + ngens > 255 ) { ast_error ( n , ""morethan255arguments"" ) ; return NULL ; } args = asdl_seq_new ( nargs + ngens , c -> c_arena ) ; if ( ! args ) return NULL ; keywords = asdl_seq_new ( nkeywords , c -> c_arena ) ; if ( ! keywords ) return NULL ; nargs = 0 ; nkeywords = 0 ; for ( i = 0 ; i < NCH ( n ) ; i ++ ) { node * ch = CHILD ( n , i ) ; if ( TYPE ( ch ) == argument ) { expr_ty e ; if ( NCH ( ch ) == 1 ) { if ( nkeywords ) { ast_error ( CHILD ( ch , 0 ) , ""non-keywordargafterkeywordarg"" ) ; return NULL ; } if ( vararg ) { ast_error ( CHILD ( ch , 0 ) , ""onlynamedargumentsmayfollow*expression"" ) ; return NULL ; } e = ast_for_expr ( c , CHILD ( ch , 0 ) ) ; if ( ! e ) return NULL ; asdl_seq_SET ( args , nargs ++ , e ) ; } else if ( TYPE ( CHILD ( ch , 1 ) ) == comp_for ) { e = ast_for_genexp ( c , ch ) ; if ( ! e ) return NULL ; asdl_seq_SET ( args , nargs ++ , e ) ; } else { keyword_ty kw ; identifier key ; int k ; char * tmp ; e = ast_for_expr ( c , CHILD ( ch , 0 ) ) ; if ( ! e ) return NULL ; if ( e -> kind == Lambda_kind ) { ast_error ( CHILD ( ch , 0 ) , ""lambdacannotcontainassignment"" ) ; return NULL ; } else if ( e -> kind != Name_kind ) { ast_error ( CHILD ( ch , 0 ) , ""keywordcan\'tbeanexpression"" ) ; return NULL ; } key = e -> v . Name . id ; if ( ! forbidden_check ( c , CHILD ( ch , 0 ) , PyUnicode_AsUTF8 ( key ) ) ) return NULL ; for ( k = 0 ; k < nkeywords ; k ++ ) { tmp = _PyUnicode_AsString ( ( ( keyword_ty ) asdl_seq_GET ( keywords , k ) ) -> arg ) ; if ( ! strcmp ( tmp , _PyUnicode_AsString ( key ) ) ) { ast_error ( CHILD ( ch , 0 ) , ""keywordargumentrepeated"" ) ; return NULL ; } } e = ast_for_expr ( c , CHILD ( ch , 2 ) ) ; if ( ! e ) return NULL ; kw = keyword ( key , e , c -> c_arena ) ; if ( ! kw ) return NULL ; asdl_seq_SET ( keywords , nkeywords ++ , kw ) ; } } else if ( TYPE ( ch ) == STAR ) { vararg = ast_for_expr ( c , CHILD ( n , i + 1 ) ) ; if ( ! vararg ) return NULL ; i ++ ; } else if ( TYPE ( ch ) == DOUBLESTAR ) { kwarg = ast_for_expr ( c , CHILD ( n , i + 1 ) ) ; if ( ! kwarg ) return NULL ; i ++ ; } } return Call ( func , args , keywords , vararg , kwarg , func -> lineno , func -> col_offset , c -> c_arena ) ; } "," int k ; const ",python@typed_ast/156afcb26c198e162504a57caddfe0acd9ed7dce,CVE-2019-19275,https://github.com/python/typed_ast/commit/156afcb26c198e162504a57caddfe0acd9ed7dce,2019-11-26T15:15Z 874,CWE-119,"CWE-119 static void de_dotdot ( char * file ) { char * cp ; char * cp2 ; int l ; while ( ( cp = strstr ( file , ""//"" ) ) != ( char * ) 0 ) { for ( cp2 = cp + 2 ; * cp2 == '/' ; ++ cp2 ) continue ; ( void ) strcpy ( cp + 1 , cp2 ) ; } while ( strncmp ( file , ""./"" , 2 ) == 0 ) ( void ) memmove ( file , file + 2 , strlen ( file ) - 1 ) ; while ( ( cp = strstr ( file , ""/./"" ) ) != ( char * ) 0 ) ( void ) memmove ( cp , cp + 2 , strlen ( file ) - 1 ) ; for ( ; ; ) { while ( strncmp ( file , ""../"" , 3 ) == 0 ) ( void ) memmove ( file , file + 3 , strlen ( file ) - 2 ) ; cp = strstr ( file , ""/../"" ) ; if ( cp == ( char * ) 0 ) break ; for ( cp2 = cp - 1 ; cp2 >= file && * cp2 != '/' ; -- cp2 ) continue ; ( void ) strcpy ( cp2 + 1 , cp + 4 ) ; } while ( ( l = strlen ( file ) ) > 3 && strcmp ( ( cp = file + l - 3 ) , ""/.."" ) == 0 ) { for ( cp2 = cp - 1 ; cp2 >= file && * cp2 != '/' ; -- cp2 ) continue ; if ( cp2 < file ) break ; * cp2 = '\\0' ; } } "," , strlen ( cp ) - 1 ",blueness@sthttpd/c0dc63a49d8605649f1d8e4a96c9b468b0bff660,CVE-2017-10671,https://github.com/blueness/sthttpd/commit/c0dc63a49d8605649f1d8e4a96c9b468b0bff660,2017-06-29T08:29Z 875,CWE-20,"CWE-20 SPL_METHOD ( Array , unserialize ) { spl_array_object * intern = ( spl_array_object * ) zend_object_store_get_object ( getThis ( ) TSRMLS_CC ) ; char * buf ; int buf_len ; const unsigned char * p , * s ; php_unserialize_data_t var_hash ; zval * pmembers , * pflags = NULL ; HashTable * aht ; long flags ; if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) TSRMLS_CC , ""s"" , & buf , & buf_len ) == FAILURE ) { return ; } if ( buf_len == 0 ) { return ; } aht = spl_array_get_hash_table ( intern , 0 TSRMLS_CC ) ; if ( aht -> nApplyCount > 0 ) { zend_error ( E_WARNING , ""ModificationofArrayObjectduringsortingisprohibited"" ) ; return ; } s = p = ( const unsigned char * ) buf ; PHP_VAR_UNSERIALIZE_INIT ( var_hash ) ; if ( * p != 'x' || * ++ p != ':' ) { goto outexcept ; } ++ p ; ALLOC_INIT_ZVAL ( pflags ) ; if ( ! php_var_unserialize ( & pflags , & p , s + buf_len , & var_hash TSRMLS_CC ) || Z_TYPE_P ( pflags ) != IS_LONG ) { goto outexcept ; } var_push_dtor ( & var_hash , & pflags ) ; -- p ; flags = Z_LVAL_P ( pflags ) ; if ( * p != ';' ) { goto outexcept ; } ++ p ; if ( * p != 'm' ) { if ( * p != 'a' && * p != 'O' && * p != 'C' && * p != 'r' ) { goto outexcept ; } intern -> ar_flags &= ~ SPL_ARRAY_CLONE_MASK ; intern -> ar_flags |= flags & SPL_ARRAY_CLONE_MASK ; zval_ptr_dtor ( & intern -> array ) ; ALLOC_INIT_ZVAL ( intern -> array ) ; if ( ! php_var_unserialize ( & intern -> array , & p , s + buf_len , & var_hash TSRMLS_CC ) ) { goto outexcept ; } var_push_dtor ( & var_hash , & intern -> array ) ; } if ( * p != ';' ) { goto outexcept ; } ++ p ; if ( * p != 'm' || * ++ p != ':' ) { goto outexcept ; } ++ p ; ALLOC_INIT_ZVAL ( pmembers ) ; if ( ! php_var_unserialize ( & pmembers , & p , s + buf_len , & var_hash TSRMLS_CC ) || Z_TYPE_P ( pmembers ) != IS_ARRAY ) { zval_ptr_dtor ( & pmembers ) ; goto outexcept ; } var_push_dtor ( & var_hash , & pmembers ) ; if ( ! intern -> std . properties ) { rebuild_object_properties ( & intern -> std ) ; } zend_hash_copy ( intern -> std . properties , Z_ARRVAL_P ( pmembers ) , ( copy_ctor_func_t ) zval_add_ref , ( void * ) NULL , sizeof ( zval * ) ) ; zval_ptr_dtor ( & pmembers ) ; PHP_VAR_UNSERIALIZE_DESTROY ( var_hash ) ; if ( pflags ) { zval_ptr_dtor ( & pflags ) ; } return ; outexcept : PHP_VAR_UNSERIALIZE_DESTROY ( var_hash ) ; if ( pflags ) { zval_ptr_dtor ( & pflags ) ; } zend_throw_exception_ex ( spl_ce_UnexpectedValueException , 0 TSRMLS_CC , ""Erroratoffset%ldof%dbytes"" , ( long ) ( ( char * ) p - buf ) , buf_len ) ; return ; } "," var_hash TSRMLS_CC ) || ( Z_TYPE_P ( intern -> array ) != IS_ARRAY && Z_TYPE_P ( intern -> array ) != IS_OBJECT ) ) { zval_ptr_dtor ( & intern -> array ) ; goto outexcept ; ",php@php-src/ecb7f58a069be0dec4a6131b6351a761f808f22e,CVE-2016-7417,https://github.com/php/php-src/commit/ecb7f58a069be0dec4a6131b6351a761f808f22e?w=1,2016-09-17T21:59Z 876,CWE-617,"CWE-617 int pci_emul_alloc_pbar ( struct pci_vdev * pdi , int idx , uint64_t hostbase , enum pcibar_type type , uint64_t size ) { int error ; uint64_t * baseptr , limit , addr , mask , lobits , bar ; assert ( idx >= 0 && idx <= PCI_BARMAX ) ; if ( ( size & ( size - 1 ) ) != 0 ) size = 1UL << flsl ( size ) ; if ( type == PCIBAR_IO ) { if ( size < 4 ) size = 4 ; } else { if ( size < 16 ) size = 16 ; } switch ( type ) { case PCIBAR_NONE : baseptr = NULL ; addr = mask = lobits = 0 ; break ; case PCIBAR_IO : baseptr = & pci_emul_iobase ; limit = PCI_EMUL_IOLIMIT ; mask = PCIM_BAR_IO_BASE ; lobits = PCIM_BAR_IO_SPACE ; break ; case PCIBAR_MEM64 : if ( ! skip_pci_mem64bar_workaround && ( size <= 32 * 1024 * 1024 ) ) { baseptr = & pci_emul_membase32 ; limit = PCI_EMUL_MEMLIMIT32 ; mask = PCIM_BAR_MEM_BASE ; lobits = PCIM_BAR_MEM_SPACE | PCIM_BAR_MEM_64 ; break ; } if ( size == 0x100000000UL ) baseptr = & hostbase ; else baseptr = & pci_emul_membase64 ; limit = PCI_EMUL_MEMLIMIT64 ; mask = PCIM_BAR_MEM_BASE ; lobits = PCIM_BAR_MEM_SPACE | PCIM_BAR_MEM_64 | PCIM_BAR_MEM_PREFETCH ; break ; case PCIBAR_MEM32 : baseptr = & pci_emul_membase32 ; limit = PCI_EMUL_MEMLIMIT32 ; mask = PCIM_BAR_MEM_BASE ; lobits = PCIM_BAR_MEM_SPACE | PCIM_BAR_MEM_32 ; break ; default : printf ( ""%s:invalidbartype%d\\n"" , __func__ , type ) ; assert ( 0 ) ; } if ( baseptr != NULL ) { error = pci_emul_alloc_resource ( baseptr , limit , size , & addr ) ; if ( error != 0 ) return error ; } pdi -> bar [ idx ] . type = type ; pdi -> bar [ idx ] . addr = addr ; pdi -> bar [ idx ] . size = size ; bar = ( addr & mask ) | lobits ; pci_set_cfgdata32 ( pdi , PCIR_BAR ( idx ) , bar ) ; if ( type == PCIBAR_MEM64 ) { assert ( idx + 1 <= PCI_BARMAX ) ; pdi -> bar [ idx + 1 ] . type = PCIBAR_MEMHI64 ; pci_set_cfgdata32 ( pdi , PCIR_BAR ( idx + 1 ) , bar >> 32 ) ; } register_bar ( pdi , idx ) ; return 0 ; } "," , bar ; if ( ( case PCIBAR_MEM64 : if ( idx + 1 > PCI_BARMAX ) { pr_err ( ""%s:invalidbarnumber%dforMEM64type\\n"" , __func__ , idx ) ; return - 1 ; } ; default : pr_err ( ""%s:invalidbartype%d\\n"" , type ) ; return - 1 ; } if PCIBAR_MEM64 ) { pdi -> bar ",projectacrn@acrn-hypervisor/2b3dedfb9ba13f15887f22b935d373f36c9a59fa,CVE-2019-18844,https://github.com/projectacrn/acrn-hypervisor/commit/2b3dedfb9ba13f15887f22b935d373f36c9a59fa,2019-11-13T20:15Z 877,CWE-667,"CWE-667 static void * gp_worker_main ( void * pvt ) { struct gp_thread * t = ( struct gp_thread * ) pvt ; struct gp_query * q = NULL ; char dummy = 0 ; int ret ; while ( ! t -> pool -> shutdown ) { gp_debug_set_conn_id ( 0 ) ; pthread_mutex_lock ( & t -> cond_mutex ) ; while ( t -> query == NULL ) { pthread_cond_wait ( & t -> cond_wakeup , & t -> cond_mutex ) ; if ( t -> pool -> shutdown ) { pthread_exit ( NULL ) ; } } q = t -> query ; t -> query = NULL ; pthread_mutex_unlock ( & t -> cond_mutex ) ; gp_debug_set_conn_id ( gp_conn_get_cid ( q -> conn ) ) ; GPDEBUGN ( 3 , ""[status]Handlingqueryinput:%p(%zu)\\n"" , q -> buffer , q -> buflen ) ; gp_handle_query ( t -> pool , q ) ; GPDEBUGN ( 3 , ""[status]Handlingqueryoutput:%p(%zu)\\n"" , q -> buffer , q -> buflen ) ; pthread_mutex_lock ( & t -> pool -> lock ) ; q -> next = t -> pool -> reply_list ; t -> pool -> reply_list = q ; if ( ! t -> pool -> shutdown ) { LIST_DEL ( t -> pool -> busy_list , t ) ; LIST_ADD ( t -> pool -> free_list , t ) ; } pthread_mutex_unlock ( & t -> pool -> lock ) ; ret = write ( t -> pool -> sig_pipe [ 1 ] , & dummy , 1 ) ; if ( ret == - 1 ) { GPERROR ( ""Failedtosignaldispatcher!"" ) ; } } pthread_exit ( NULL ) ; } "," shutdown ) { pthread_mutex_unlock ( & t -> cond_mutex ) ; ",gssapi@gssproxy/cb761412e299ef907f22cd7c4146d50c8a792003,CVE-2020-12658,https://github.com/gssapi/gssproxy/commit/cb761412e299ef907f22cd7c4146d50c8a792003,2020-12-31T01:15Z 878,CWE-119,"CWE-119 int usbip_recv_xbuff ( struct usbip_device * ud , struct urb * urb ) { int ret ; int size ; if ( ud -> side == USBIP_STUB ) { if ( usb_pipein ( urb -> pipe ) ) return 0 ; size = urb -> transfer_buffer_length ; } else { if ( usb_pipeout ( urb -> pipe ) ) return 0 ; size = urb -> actual_length ; } if ( ! ( size > 0 ) ) return 0 ; ret = usbip_recv ( ud -> tcp_socket , urb -> transfer_buffer , size ) ; if ( ret != size ) { dev_err ( & urb -> dev -> dev , ""recvxbuf,%d\\n"" , ret ) ; if ( ud -> side == USBIP_STUB ) { usbip_event_add ( ud , SDEV_EVENT_ERROR_TCP ) ; } else { usbip_event_add ( ud , VDEV_EVENT_ERROR_TCP ) ; return - EPIPE ; } } return ret ; } "," return 0 ; if ( size > urb -> transfer_buffer_length ) { if ( ud SDEV_EVENT_ERROR_TCP ) ; return 0 ; ; } } ret = usbip_recv ( ud -> tcp_socket , urb -> transfer_buffer , size ) ; if ( ret != size ) { dev_err ( & urb -> dev -> dev , ""recvxbuf,%d\\n"" , ret ) ; if ( ud -> side == USBIP_STUB ) { usbip_event_add ( ud , SDEV_EVENT_ERROR_TCP ) ; } else { usbip_event_add ( ud , VDEV_EVENT_ERROR_TCP ) ; return - EPIPE ; } } ",torvalds@linux/b348d7dddb6c4fbfc810b7a0626e8ec9e29f7cbb,CVE-2016-3955,https://github.com/torvalds/linux/commit/b348d7dddb6c4fbfc810b7a0626e8ec9e29f7cbb,2016-07-03T21:59Z 879,CWE-362,"CWE-362 static int ext4_ext_handle_uninitialized_extents ( handle_t * handle , struct inode * inode , struct ext4_map_blocks * map , struct ext4_ext_path * path , int flags , unsigned int allocated , ext4_fsblk_t newblock ) { int ret = 0 ; int err = 0 ; ext4_io_end_t * io = ext4_inode_aio ( inode ) ; ext_debug ( ""ext4_ext_handle_uninitialized_extents:inode%lu,logical"" ""block%llu,max_blocks%u,flags%x,allocated%u\\n"" , inode -> i_ino , ( unsigned long long ) map -> m_lblk , map -> m_len , flags , allocated ) ; ext4_ext_show_leaf ( inode , path ) ; trace_ext4_ext_handle_uninitialized_extents ( inode , map , allocated , newblock ) ; if ( ( flags & EXT4_GET_BLOCKS_PRE_IO ) ) { ret = ext4_split_unwritten_extents ( handle , inode , map , path , flags ) ; if ( ret <= 0 ) goto out ; if ( io ) ext4_set_io_unwritten_flag ( inode , io ) ; else ext4_set_inode_state ( inode , EXT4_STATE_DIO_UNWRITTEN ) ; if ( ext4_should_dioread_nolock ( inode ) ) map -> m_flags |= EXT4_MAP_UNINIT ; 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 ) ; err = check_eofblocks_fl ( handle , inode , map -> m_lblk , path , map -> m_len ) ; } else err = ret ; goto out2 ; } if ( flags & EXT4_GET_BLOCKS_UNINIT_EXT ) goto map_out ; if ( ( flags & EXT4_GET_BLOCKS_CREATE ) == 0 ) { map -> m_flags |= EXT4_MAP_UNWRITTEN ; goto out1 ; } ret = ext4_ext_convert_to_initialized ( handle , inode , map , path ) ; if ( ret >= 0 ) ext4_update_inode_fsync_trans ( handle , inode , 1 ) ; out : if ( ret <= 0 ) { err = ret ; goto out2 ; } else allocated = ret ; map -> m_flags |= EXT4_MAP_NEW ; if ( allocated > map -> m_len ) { unmap_underlying_metadata_blocks ( inode -> i_sb -> s_bdev , newblock + map -> m_len , allocated - map -> m_len ) ; allocated = map -> m_len ; } if ( flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE ) { unsigned int reserved_clusters ; reserved_clusters = get_reserved_cluster_alloc ( inode , map -> m_lblk , map -> m_len ) ; if ( reserved_clusters ) ext4_da_update_reserve_space ( inode , reserved_clusters , 0 ) ; } map_out : map -> m_flags |= EXT4_MAP_MAPPED ; if ( ( flags & EXT4_GET_BLOCKS_KEEP_SIZE ) == 0 ) { err = check_eofblocks_fl ( handle , inode , map -> m_lblk , path , map -> m_len ) ; if ( err < 0 ) goto out2 ; } out1 : if ( allocated > map -> m_len ) allocated = map -> m_len ; ext4_ext_show_leaf ( inode , path ) ; map -> m_pblk = newblock ; map -> m_len = allocated ; out2 : if ( path ) { ext4_ext_drop_refs ( path ) ; kfree ( path ) ; } return err ? err : allocated ; } "," , inode , map , ",torvalds@linux/dee1f973ca341c266229faa5a1a5bb268bed3531,CVE-2012-4508,https://github.com/torvalds/linux/commit/dee1f973ca341c266229faa5a1a5bb268bed3531,2012-12-21T11:47Z 880,CWE-476,"CWE-476 av_cold void ff_mpv_idct_init ( MpegEncContext * s ) { ff_idctdsp_init ( & s -> idsp , s -> avctx ) ; if ( s -> alternate_scan ) { ff_init_scantable ( s -> idsp . idct_permutation , & s -> inter_scantable , ff_alternate_vertical_scan ) ; ff_init_scantable ( s -> idsp . idct_permutation , & s -> intra_scantable , ff_alternate_vertical_scan ) ; } else { ff_init_scantable ( s -> idsp . idct_permutation , & s -> inter_scantable , ff_zigzag_direct ) ; ff_init_scantable ( s -> idsp . idct_permutation , & s -> intra_scantable , ff_zigzag_direct ) ; } ff_init_scantable ( s -> idsp . idct_permutation , & s -> intra_h_scantable , ff_alternate_horizontal_scan ) ; ff_init_scantable ( s -> idsp . idct_permutation , & s -> intra_v_scantable , ff_alternate_vertical_scan ) ; } "," s ) { if ( s -> codec_id == AV_CODEC_ID_MPEG4 ) s -> idsp . mpeg4_studio_profile = s -> studio_profile ; ",FFmpeg@FFmpeg/b3332a182f8ba33a34542e4a0370f38b914ccf7d,CVE-2018-12460,https://github.com/FFmpeg/FFmpeg/commit/b3332a182f8ba33a34542e4a0370f38b914ccf7d,2018-06-15T15:29Z 881,CWE-399,"CWE-399 static void handle_associated_event ( struct cpu_hw_events * cpuc , int idx , struct perf_sample_data * data , struct pt_regs * regs ) { struct perf_event * event = cpuc -> events [ idx ] ; struct hw_perf_event * hwc = & event -> hw ; mipspmu_event_update ( event , hwc , idx ) ; data -> period = event -> hw . last_period ; if ( ! mipspmu_event_set_period ( event , hwc , idx ) ) return ; if ( perf_event_overflow ( event , 0 , data , regs ) ) mipspmu -> disable_event ( idx ) ; } "," ( event , data , regs ",torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,CVE-2011-2918,https://github.com/torvalds/linux/commit/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,2012-05-24T23:55Z 882,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 883,CWE-000,"CWE-000 OM_uint32 gss_krb5int_export_lucid_sec_context ( OM_uint32 * minor_status , const gss_ctx_id_t context_handle , const gss_OID desired_object , gss_buffer_set_t * data_set ) { krb5_error_code kret = 0 ; OM_uint32 retval ; krb5_gss_ctx_id_t ctx = ( krb5_gss_ctx_id_t ) context_handle ; void * lctx = NULL ; int version = 0 ; gss_buffer_desc rep ; retval = GSS_S_FAILURE ; * minor_status = 0 ; * data_set = GSS_C_NO_BUFFER_SET ; retval = generic_gss_oid_decompose ( minor_status , GSS_KRB5_EXPORT_LUCID_SEC_CONTEXT_OID , GSS_KRB5_EXPORT_LUCID_SEC_CONTEXT_OID_LENGTH , desired_object , & version ) ; if ( GSS_ERROR ( retval ) ) return retval ; switch ( version ) { case 1 : kret = make_external_lucid_ctx_v1 ( ( krb5_pointer ) ctx , version , & lctx ) ; break ; default : kret = ( OM_uint32 ) KG_LUCID_VERSION ; break ; } if ( kret ) goto error_out ; rep . value = & lctx ; rep . length = sizeof ( lctx ) ; retval = generic_gss_add_buffer_set_member ( minor_status , & rep , data_set ) ; if ( GSS_ERROR ( retval ) ) goto error_out ; error_out : if ( * minor_status == 0 ) * minor_status = ( OM_uint32 ) kret ; return ( retval ) ; } "," = GSS_C_NO_BUFFER_SET ; if ( ctx -> terminated || ! ctx -> established ) { * minor_status = KG_CTX_INCOMPLETE ; return GSS_S_NO_CONTEXT ; } ",krb5@krb5/82dc33da50338ac84c7b4102dc6513d897d0506a,CVE-2014-5352,https://github.com/krb5/krb5/commit/82dc33da50338ac84c7b4102dc6513d897d0506a,2015-02-19T11:59Z 884,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 885,CWE-476,"CWE-476 static int mailimf_group_parse ( const char * message , size_t length , size_t * indx , struct mailimf_group * * result ) { size_t cur_token ; char * display_name ; struct mailimf_mailbox_list * mailbox_list ; struct mailimf_group * group ; int r ; int res ; cur_token = * indx ; mailbox_list = NULL ; r = mailimf_display_name_parse ( message , length , & cur_token , & display_name ) ; if ( r != MAILIMF_NO_ERROR ) { res = r ; goto err ; } r = mailimf_colon_parse ( message , length , & cur_token ) ; if ( r != MAILIMF_NO_ERROR ) { res = r ; goto free_display_name ; } r = mailimf_mailbox_list_parse ( message , length , & cur_token , & mailbox_list ) ; switch ( r ) { case MAILIMF_NO_ERROR : break ; case MAILIMF_ERROR_PARSE : r = mailimf_cfws_parse ( message , length , & cur_token ) ; if ( ( r != MAILIMF_NO_ERROR ) && ( r != MAILIMF_ERROR_PARSE ) ) { res = r ; goto free_display_name ; } break ; default : res = r ; goto free_display_name ; } r = mailimf_semi_colon_parse ( message , length , & cur_token ) ; if ( r != MAILIMF_NO_ERROR ) { res = r ; goto free_mailbox_list ; } group = mailimf_group_new ( display_name , mailbox_list ) ; if ( group == NULL ) { res = MAILIMF_ERROR_MEMORY ; goto free_mailbox_list ; } * indx = cur_token ; * result = group ; return MAILIMF_NO_ERROR ; free_mailbox_list : if ( mailbox_list != NULL ) { mailimf_mailbox_list_free ( mailbox_list ) ; } free_display_name : mailimf_display_name_free ( display_name ) ; err : return res ; } "," int res ; clist * list ; res = r ; goto free_display_name ; } list = clist_new ( ) ; if ( list == NULL ) { res = MAILIMF_ERROR_MEMORY ; goto free_display_name ; } mailbox_list = mailimf_mailbox_list_new ( list ) ; if ( mailbox_list == NULL ) { res = MAILIMF_ERROR_MEMORY ; clist_free ( list ) ",dinhviethoa@libetpan/1fe8fbc032ccda1db9af66d93016b49c16c1f22d,CVE-2017-8825,https://github.com/dinhviethoa/libetpan/commit/1fe8fbc032ccda1db9af66d93016b49c16c1f22d,2017-05-08T16:29Z 886,CWE-400,"CWE-400 void handle_ld_nf ( u32 insn , struct pt_regs * regs ) { int rd = ( ( insn >> 25 ) & 0x1f ) ; int from_kernel = ( regs -> tstate & TSTATE_PRIV ) != 0 ; unsigned long * reg ; perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , 0 ) ; maybe_flush_windows ( 0 , 0 , rd , from_kernel ) ; reg = fetch_reg_addr ( rd , regs ) ; if ( from_kernel || rd < 16 ) { reg [ 0 ] = 0 ; if ( ( insn & 0x780000 ) == 0x180000 ) reg [ 1 ] = 0 ; } else if ( test_thread_flag ( TIF_32BIT ) ) { put_user ( 0 , ( int __user * ) reg ) ; if ( ( insn & 0x780000 ) == 0x180000 ) put_user ( 0 , ( ( int __user * ) reg ) + 1 ) ; } else { put_user ( 0 , ( unsigned long __user * ) reg ) ; if ( ( insn & 0x780000 ) == 0x180000 ) put_user ( 0 , ( unsigned long __user * ) reg + 1 ) ; } advance ( regs ) ; } "," , 1 , regs , 0 ",torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,CVE-2011-2918,https://github.com/torvalds/linux/commit/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,2012-05-24T23:55Z 887,CWE-000,"CWE-000 void ff_h264_free_tables ( H264Context * h , int free_rbsp ) { int i ; H264Context * hx ; av_freep ( & h -> intra4x4_pred_mode ) ; av_freep ( & h -> chroma_pred_mode_table ) ; av_freep ( & h -> cbp_table ) ; av_freep ( & h -> mvd_table [ 0 ] ) ; av_freep ( & h -> mvd_table [ 1 ] ) ; av_freep ( & h -> direct_table ) ; av_freep ( & h -> non_zero_count ) ; av_freep ( & h -> slice_table_base ) ; h -> slice_table = NULL ; av_freep ( & h -> list_counts ) ; av_freep ( & h -> mb2b_xy ) ; av_freep ( & h -> mb2br_xy ) ; av_buffer_pool_uninit ( & h -> qscale_table_pool ) ; av_buffer_pool_uninit ( & h -> mb_type_pool ) ; av_buffer_pool_uninit ( & h -> motion_val_pool ) ; av_buffer_pool_uninit ( & h -> ref_index_pool ) ; if ( free_rbsp && h -> DPB ) { for ( i = 0 ; i < H264_MAX_PICTURE_COUNT ; i ++ ) ff_h264_unref_picture ( h , & h -> DPB [ i ] ) ; av_freep ( & h -> DPB ) ; } else if ( h -> DPB ) { for ( i = 0 ; i < H264_MAX_PICTURE_COUNT ; i ++ ) h -> DPB [ i ] . needs_realloc = 1 ; } h -> cur_pic_ptr = NULL ; for ( i = 0 ; i < H264_MAX_THREADS ; i ++ ) { hx = h -> thread_context [ i ] ; if ( ! hx ) continue ; av_freep ( & hx -> top_borders [ 1 ] ) ; av_freep ( & hx -> top_borders [ 0 ] ) ; av_freep ( & hx -> bipred_scratchpad ) ; av_freep ( & hx -> edge_emu_buffer ) ; av_freep ( & hx -> dc_val_base ) ; av_freep ( & hx -> er . mb_index2xy ) ; av_freep ( & hx -> er . error_status_table ) ; av_freep ( & hx -> er . er_temp_buffer ) ; av_freep ( & hx -> er . mbintra_table ) ; av_freep ( & hx -> er . mbskip_table ) ; if ( free_rbsp ) { av_freep ( & hx -> rbsp_buffer [ 1 ] ) ; av_freep ( & hx -> rbsp_buffer [ 0 ] ) ; hx -> rbsp_buffer_size [ 0 ] = 0 ; hx -> rbsp_buffer_size [ 1 ] = 0 ; } if ( i ) av_freep ( & h -> thread_context [ i ] ) ; } } "," ] ) ; memset ( h -> delayed_pic , 0 , sizeof ( h -> delayed_pic ) ) ; ",FFmpeg@FFmpeg/e8714f6f93d1a32f4e4655209960afcf4c185214,CVE-2015-3417,https://github.com/FFmpeg/FFmpeg/commit/e8714f6f93d1a32f4e4655209960afcf4c185214,2015-04-24T17:59Z 888,CWE-000,"CWE-000 static int load_segment_descriptor ( struct x86_emulate_ctxt * ctxt , u16 selector , int seg ) { u8 cpl = ctxt -> ops -> cpl ( ctxt ) ; return __load_segment_descriptor ( ctxt , selector , seg , cpl , false ) ; } "," cpl , false , NULL ",torvalds@linux/d1442d85cc30ea75f7d399474ca738e0bc96f715,CVE-2014-3647,https://github.com/torvalds/linux/commit/d1442d85cc30ea75f7d399474ca738e0bc96f715,2014-11-10T11:55Z 889,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 890,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-2324,https://github.com/git/git/commit/de1e67d0703894cb6ea782e36abb63976ab07e60,2016-04-08T14:59Z 891,CWE-400,"CWE-400 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 892,CWE-264,"CWE-264 static struct dst_entry * inet6_csk_route_socket ( struct sock * sk , struct flowi6 * fl6 ) { struct inet_sock * inet = inet_sk ( sk ) ; struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct in6_addr * final_p , final ; struct dst_entry * dst ; 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 ; IP6_ECN_flow_xmit ( sk , fl6 -> flowlabel ) ; fl6 -> flowi6_oif = sk -> sk_bound_dev_if ; fl6 -> flowi6_mark = sk -> sk_mark ; fl6 -> fl6_sport = inet -> inet_sport ; fl6 -> fl6_dport = inet -> inet_dport ; security_sk_classify_flow ( sk , flowi6_to_flowi ( fl6 ) ) ; final_p = fl6_update_dst ( fl6 , np -> opt , & final ) ; dst = __inet6_csk_dst_check ( sk , np -> dst_cookie ) ; if ( ! dst ) { dst = ip6_dst_lookup_flow ( sk , fl6 , final_p ) ; if ( ! IS_ERR ( dst ) ) __inet6_csk_dst_store ( sk , dst , NULL , NULL ) ; } return dst ; } "," ) ) ; rcu_read_lock ( ) ; ( fl6 , rcu_dereference ( np -> opt ) final ) ; rcu_read_unlock ( ) ; ",torvalds@linux/45f6fad84cc305103b28d73482b344d7f5b76f39,CVE-2016-3841,https://github.com/torvalds/linux/commit/45f6fad84cc305103b28d73482b344d7f5b76f39,2016-08-06T20:59Z 893,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 894,CWE-125,"CWE-125 static int indenterror ( struct tok_state * tok ) { if ( tok -> alterror ) { tok -> done = E_TABSPACE ; tok -> cur = tok -> inp ; return 1 ; } if ( tok -> altwarning ) { # ifdef PGEN PySys_WriteStderr ( ""inconsistentuseoftabsandspaces"" ""inindentation\\n"" ) ; # else PySys_FormatStderr ( ""%U:inconsistentuseoftabsandspaces"" ""inindentation\\n"" , tok -> filename ) ; # endif tok -> altwarning = 0 ; } return 0 ; } "," * tok ) { tok -> inp ; return ERRORTOKEN ; } ",python@typed_ast/156afcb26c198e162504a57caddfe0acd9ed7dce,CVE-2019-19275,https://github.com/python/typed_ast/commit/156afcb26c198e162504a57caddfe0acd9ed7dce,2019-11-26T15:15Z 895,CWE-287,"CWE-287 static int netlink_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 netlink_sock * nlk = nlk_sk ( sk ) ; struct sockaddr_nl * addr = msg -> msg_name ; u32 dst_pid ; u32 dst_group ; struct sk_buff * skb ; int err ; struct scm_cookie scm ; if ( msg -> msg_flags & MSG_OOB ) return - EOPNOTSUPP ; if ( NULL == siocb -> scm ) siocb -> scm = & scm ; err = scm_send ( sock , msg , siocb -> scm ) ; if ( err < 0 ) return err ; if ( msg -> msg_namelen ) { err = - EINVAL ; if ( addr -> nl_family != AF_NETLINK ) goto out ; dst_pid = addr -> nl_pid ; dst_group = ffs ( addr -> nl_groups ) ; err = - EPERM ; if ( dst_group && ! netlink_capable ( sock , NL_NONROOT_SEND ) ) goto out ; } else { dst_pid = nlk -> dst_pid ; dst_group = nlk -> dst_group ; } if ( ! nlk -> pid ) { err = netlink_autobind ( sock ) ; if ( err ) goto out ; } err = - EMSGSIZE ; if ( len > sk -> sk_sndbuf - 32 ) goto out ; err = - ENOBUFS ; skb = alloc_skb ( len , GFP_KERNEL ) ; if ( skb == NULL ) goto out ; NETLINK_CB ( skb ) . pid = nlk -> pid ; NETLINK_CB ( skb ) . dst_group = dst_group ; memcpy ( NETLINK_CREDS ( skb ) , & siocb -> scm -> creds , sizeof ( struct ucred ) ) ; err = - EFAULT ; if ( memcpy_fromiovec ( skb_put ( skb , len ) , msg -> msg_iov , len ) ) { kfree_skb ( skb ) ; goto out ; } err = security_netlink_send ( sk , skb ) ; if ( err ) { kfree_skb ( skb ) ; goto out ; } if ( dst_group ) { atomic_inc ( & skb -> users ) ; netlink_broadcast ( sk , skb , dst_pid , dst_group , GFP_KERNEL ) ; } err = netlink_unicast ( sk , skb , dst_pid , msg -> msg_flags & MSG_DONTWAIT ) ; out : scm_destroy ( siocb -> scm ) ; return err ; } "," siocb -> scm , true ",torvalds@linux/e0e3cea46d31d23dc40df0a49a7a2c04fe8edfea,CVE-2012-3520,https://github.com/torvalds/linux/commit/e0e3cea46d31d23dc40df0a49a7a2c04fe8edfea,2012-10-03T11:02Z 896,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 897,CWE-310,"CWE-310 int ssl3_get_cert_verify ( SSL * s ) { EVP_PKEY * pkey = NULL ; unsigned char * p ; int al , ok , ret = 0 ; long n ; int type = 0 , i , j ; X509 * peer ; const EVP_MD * md = NULL ; EVP_MD_CTX mctx ; EVP_MD_CTX_init ( & mctx ) ; n = s -> method -> ssl_get_message ( s , SSL3_ST_SR_CERT_VRFY_A , SSL3_ST_SR_CERT_VRFY_B , - 1 , SSL3_RT_MAX_PLAIN_LENGTH , & ok ) ; if ( ! ok ) return ( ( int ) n ) ; if ( s -> session -> peer != NULL ) { peer = s -> session -> peer ; pkey = X509_get_pubkey ( peer ) ; type = X509_certificate_type ( peer , pkey ) ; } else { peer = NULL ; pkey = NULL ; } if ( s -> s3 -> tmp . message_type != SSL3_MT_CERTIFICATE_VERIFY ) { s -> s3 -> tmp . reuse_message = 1 ; if ( ( peer != NULL ) && ( type & EVP_PKT_SIGN ) ) { al = SSL_AD_UNEXPECTED_MESSAGE ; SSLerr ( SSL_F_SSL3_GET_CERT_VERIFY , SSL_R_MISSING_VERIFY_MESSAGE ) ; goto f_err ; } ret = 1 ; goto end ; } if ( peer == NULL ) { SSLerr ( SSL_F_SSL3_GET_CERT_VERIFY , SSL_R_NO_CLIENT_CERT_RECEIVED ) ; al = SSL_AD_UNEXPECTED_MESSAGE ; goto f_err ; } if ( ! ( type & EVP_PKT_SIGN ) ) { SSLerr ( SSL_F_SSL3_GET_CERT_VERIFY , SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE ) ; al = SSL_AD_ILLEGAL_PARAMETER ; goto f_err ; } if ( s -> s3 -> change_cipher_spec ) { SSLerr ( SSL_F_SSL3_GET_CERT_VERIFY , SSL_R_CCS_RECEIVED_EARLY ) ; al = SSL_AD_UNEXPECTED_MESSAGE ; goto f_err ; } p = ( unsigned char * ) s -> init_msg ; if ( n == 64 && ( pkey -> type == NID_id_GostR3410_94 || pkey -> type == NID_id_GostR3410_2001 ) ) { i = 64 ; } else { if ( SSL_USE_SIGALGS ( s ) ) { int rv = tls12_check_peer_sigalg ( & md , s , p , pkey ) ; if ( rv == - 1 ) { al = SSL_AD_INTERNAL_ERROR ; goto f_err ; } else if ( rv == 0 ) { al = SSL_AD_DECODE_ERROR ; goto f_err ; } # ifdef SSL_DEBUG fprintf ( stderr , ""USINGTLSv1.2HASH%s\\n"" , EVP_MD_name ( md ) ) ; # endif p += 2 ; n -= 2 ; } n2s ( p , i ) ; n -= 2 ; if ( i > n ) { SSLerr ( SSL_F_SSL3_GET_CERT_VERIFY , SSL_R_LENGTH_MISMATCH ) ; al = SSL_AD_DECODE_ERROR ; goto f_err ; } } j = EVP_PKEY_size ( pkey ) ; if ( ( i > j ) || ( n > j ) || ( n <= 0 ) ) { SSLerr ( SSL_F_SSL3_GET_CERT_VERIFY , SSL_R_WRONG_SIGNATURE_SIZE ) ; al = SSL_AD_DECODE_ERROR ; goto f_err ; } if ( SSL_USE_SIGALGS ( s ) ) { long hdatalen = 0 ; void * hdata ; hdatalen = BIO_get_mem_data ( s -> s3 -> handshake_buffer , & hdata ) ; if ( hdatalen <= 0 ) { SSLerr ( SSL_F_SSL3_GET_CERT_VERIFY , ERR_R_INTERNAL_ERROR ) ; al = SSL_AD_INTERNAL_ERROR ; goto f_err ; } # ifdef SSL_DEBUG fprintf ( stderr , ""UsingTLS1.2withclientverifyalg%s\\n"" , EVP_MD_name ( md ) ) ; # endif if ( ! EVP_VerifyInit_ex ( & mctx , md , NULL ) || ! EVP_VerifyUpdate ( & mctx , hdata , hdatalen ) ) { SSLerr ( SSL_F_SSL3_GET_CERT_VERIFY , ERR_R_EVP_LIB ) ; al = SSL_AD_INTERNAL_ERROR ; goto f_err ; } if ( EVP_VerifyFinal ( & mctx , p , i , pkey ) <= 0 ) { al = SSL_AD_DECRYPT_ERROR ; SSLerr ( SSL_F_SSL3_GET_CERT_VERIFY , SSL_R_BAD_SIGNATURE ) ; goto f_err ; } } else # ifndef OPENSSL_NO_RSA if ( pkey -> type == EVP_PKEY_RSA ) { i = RSA_verify ( NID_md5_sha1 , s -> s3 -> tmp . cert_verify_md , MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH , p , i , pkey -> pkey . rsa ) ; if ( i < 0 ) { al = SSL_AD_DECRYPT_ERROR ; SSLerr ( SSL_F_SSL3_GET_CERT_VERIFY , SSL_R_BAD_RSA_DECRYPT ) ; goto f_err ; } if ( i == 0 ) { al = SSL_AD_DECRYPT_ERROR ; SSLerr ( SSL_F_SSL3_GET_CERT_VERIFY , SSL_R_BAD_RSA_SIGNATURE ) ; goto f_err ; } } else # endif # ifndef OPENSSL_NO_DSA if ( pkey -> type == EVP_PKEY_DSA ) { j = DSA_verify ( pkey -> save_type , & ( s -> s3 -> tmp . cert_verify_md [ MD5_DIGEST_LENGTH ] ) , SHA_DIGEST_LENGTH , p , i , pkey -> pkey . dsa ) ; if ( j <= 0 ) { al = SSL_AD_DECRYPT_ERROR ; SSLerr ( SSL_F_SSL3_GET_CERT_VERIFY , SSL_R_BAD_DSA_SIGNATURE ) ; goto f_err ; } } else # endif # ifndef OPENSSL_NO_ECDSA if ( pkey -> type == EVP_PKEY_EC ) { j = ECDSA_verify ( pkey -> save_type , & ( s -> s3 -> tmp . cert_verify_md [ MD5_DIGEST_LENGTH ] ) , SHA_DIGEST_LENGTH , p , i , pkey -> pkey . ec ) ; if ( j <= 0 ) { al = SSL_AD_DECRYPT_ERROR ; SSLerr ( SSL_F_SSL3_GET_CERT_VERIFY , SSL_R_BAD_ECDSA_SIGNATURE ) ; goto f_err ; } } else # endif if ( pkey -> type == NID_id_GostR3410_94 || pkey -> type == NID_id_GostR3410_2001 ) { unsigned char signature [ 64 ] ; int idx ; EVP_PKEY_CTX * pctx = EVP_PKEY_CTX_new ( pkey , NULL ) ; EVP_PKEY_verify_init ( pctx ) ; if ( i != 64 ) { fprintf ( stderr , ""GOSTsignaturelengthis%d"" , i ) ; } for ( idx = 0 ; idx < 64 ; idx ++ ) { signature [ 63 - idx ] = p [ idx ] ; } j = EVP_PKEY_verify ( pctx , signature , 64 , s -> s3 -> tmp . cert_verify_md , 32 ) ; EVP_PKEY_CTX_free ( pctx ) ; if ( j <= 0 ) { al = SSL_AD_DECRYPT_ERROR ; SSLerr ( SSL_F_SSL3_GET_CERT_VERIFY , SSL_R_BAD_ECDSA_SIGNATURE ) ; goto f_err ; } } else { SSLerr ( SSL_F_SSL3_GET_CERT_VERIFY , ERR_R_INTERNAL_ERROR ) ; al = SSL_AD_UNSUPPORTED_CERTIFICATE ; goto f_err ; } ret = 1 ; if ( 0 ) { f_err : ssl3_send_alert ( s , SSL3_AL_FATAL , al ) ; } end : if ( s -> s3 -> handshake_buffer ) { BIO_free ( s -> s3 -> handshake_buffer ) ; s -> s3 -> handshake_buffer = NULL ; s -> s3 -> flags &= ~ TLS1_FLAGS_KEEP_HANDSHAKE ; } EVP_MD_CTX_cleanup ( & mctx ) ; EVP_PKEY_free ( pkey ) ; return ( ret ) ; } "," ; if ( peer != NULL peer != NULL ) { al ",openssl@openssl/1421e0c584ae9120ca1b88098f13d6d2e90b83a3,CVE-2015-0205,https://github.com/openssl/openssl/commit/1421e0c584ae9120ca1b88098f13d6d2e90b83a3,2015-01-09T02:59Z 898,CWE-79,"CWE-79 static int php_handler ( request_rec * r ) { php_struct * volatile ctx ; void * conf ; apr_bucket_brigade * volatile brigade ; apr_bucket * bucket ; apr_status_t rv ; request_rec * volatile parent_req = NULL ; TSRMLS_FETCH ( ) ; # define PHPAP_INI_OFF php_apache_ini_dtor ( r , parent_req TSRMLS_CC ) ; conf = ap_get_module_config ( r -> per_dir_config , & php5_module ) ; ctx = SG ( server_context ) ; if ( ctx == NULL || ( ctx && ctx -> request_processed && ! strcmp ( r -> protocol , ""INCLUDED"" ) ) ) { normal : ctx = SG ( server_context ) = apr_pcalloc ( r -> pool , sizeof ( * ctx ) ) ; apr_pool_cleanup_register ( r -> pool , ( void * ) & SG ( server_context ) , php_server_context_cleanup , apr_pool_cleanup_null ) ; ctx -> r = r ; ctx = NULL ; } else { parent_req = ctx -> r ; ctx -> r = r ; } apply_config ( conf ) ; if ( strcmp ( r -> handler , PHP_MAGIC_TYPE ) && strcmp ( r -> handler , PHP_SOURCE_MAGIC_TYPE ) && strcmp ( r -> handler , PHP_SCRIPT ) ) { if ( ! AP2 ( xbithack ) || strcmp ( r -> handler , ""text/html"" ) || ! ( r -> finfo . protection & APR_UEXECUTE ) ) { PHPAP_INI_OFF ; return DECLINED ; } } if ( r -> used_path_info == AP_REQ_REJECT_PATH_INFO && r -> path_info && r -> path_info [ 0 ] ) { PHPAP_INI_OFF ; return HTTP_NOT_FOUND ; } if ( ! AP2 ( engine ) ) { PHPAP_INI_OFF ; return DECLINED ; } if ( r -> finfo . filetype == 0 ) { php_apache_sapi_log_message_ex ( ""script\'%s\'notfoundorunabletostat"" , r TSRMLS_CC ) ; PHPAP_INI_OFF ; return HTTP_NOT_FOUND ; } if ( r -> finfo . filetype == APR_DIR ) { php_apache_sapi_log_message_ex ( ""attempttoinvokedirectory\'%s\'asscript"" , r TSRMLS_CC ) ; PHPAP_INI_OFF ; return HTTP_FORBIDDEN ; } if ( r -> main == NULL || r -> subprocess_env != r -> main -> subprocess_env ) { ap_add_common_vars ( r ) ; ap_add_cgi_vars ( r ) ; } zend_first_try { if ( ctx == NULL ) { brigade = apr_brigade_create ( r -> pool , r -> connection -> bucket_alloc ) ; ctx = SG ( server_context ) ; ctx -> brigade = brigade ; if ( php_apache_request_ctor ( r , ctx TSRMLS_CC ) != SUCCESS ) { zend_bailout ( ) ; } } else { if ( ! parent_req ) { parent_req = ctx -> r ; } if ( parent_req && parent_req -> handler && strcmp ( parent_req -> handler , PHP_MAGIC_TYPE ) && strcmp ( parent_req -> handler , PHP_SOURCE_MAGIC_TYPE ) && strcmp ( parent_req -> handler , PHP_SCRIPT ) ) { if ( php_apache_request_ctor ( r , ctx TSRMLS_CC ) != SUCCESS ) { zend_bailout ( ) ; } } if ( parent_req && parent_req -> status != HTTP_OK && parent_req -> status != 413 && strcmp ( r -> protocol , ""INCLUDED"" ) ) { parent_req = NULL ; goto normal ; } ctx -> r = r ; brigade = ctx -> brigade ; } if ( AP2 ( last_modified ) ) { ap_update_mtime ( r , r -> finfo . mtime ) ; ap_set_last_modified ( r ) ; } if ( strncmp ( r -> handler , PHP_SOURCE_MAGIC_TYPE , sizeof ( PHP_SOURCE_MAGIC_TYPE ) - 1 ) == 0 ) { zend_syntax_highlighter_ini syntax_highlighter_ini ; php_get_highlight_struct ( & syntax_highlighter_ini ) ; highlight_file ( ( char * ) r -> filename , & syntax_highlighter_ini TSRMLS_CC ) ; } else { zend_file_handle zfd ; zfd . type = ZEND_HANDLE_FILENAME ; zfd . filename = ( char * ) r -> filename ; zfd . free_filename = 0 ; zfd . opened_path = NULL ; if ( ! parent_req ) { php_execute_script ( & zfd TSRMLS_CC ) ; } else { zend_execute_scripts ( ZEND_INCLUDE TSRMLS_CC , NULL , 1 , & zfd ) ; } apr_table_set ( r -> notes , ""mod_php_memory_usage"" , apr_psprintf ( ctx -> r -> pool , ""%"" APR_SIZE_T_FMT , zend_memory_peak_usage ( 1 TSRMLS_CC ) ) ) ; } } zend_end_try ( ) ; if ( ! parent_req ) { php_apache_request_dtor ( r TSRMLS_CC ) ; ctx -> request_processed = 1 ; bucket = apr_bucket_eos_create ( r -> connection -> bucket_alloc ) ; APR_BRIGADE_INSERT_TAIL ( brigade , bucket ) ; rv = ap_pass_brigade ( r -> output_filters , brigade ) ; if ( rv != APR_SUCCESS || r -> connection -> aborted ) { zend_first_try { php_handle_aborted_connection ( ) ; } zend_end_try ( ) ; } apr_brigade_cleanup ( brigade ) ; apr_pool_cleanup_run ( r -> pool , ( void * ) & SG ( server_context ) , php_server_context_cleanup ) ; } else { ctx -> r = parent_req ; } return OK ; } "," = 1 ; apr_brigade_cleanup ( brigade ) ; ",php@php-src/23b057742e3cf199612fa8050ae86cae675e214e,CVE-2018-17082,https://github.com/php/php-src/commit/23b057742e3cf199612fa8050ae86cae675e214e,2018-09-16T15:29Z 899,CWE-200,"CWE-200 int raptor_turtle_writer_set_option ( raptor_turtle_writer * turtle_writer , raptor_option option , int value ) { if ( value < 0 || ! raptor_option_is_valid_for_area ( option , RAPTOR_OPTION_AREA_TURTLE_WRITER ) ) return 1 ; switch ( option ) { case RAPTOR_OPTION_WRITER_AUTO_INDENT : if ( value ) turtle_writer -> flags |= TURTLE_WRITER_AUTO_INDENT ; else turtle_writer -> flags &= ~ TURTLE_WRITER_AUTO_INDENT ; break ; case RAPTOR_OPTION_WRITER_INDENT_WIDTH : turtle_writer -> indent = value ; break ; case RAPTOR_OPTION_WRITER_AUTO_EMPTY : case RAPTOR_OPTION_WRITER_XML_VERSION : case RAPTOR_OPTION_WRITER_XML_DECLARATION : break ; case RAPTOR_OPTION_SCANNING : case RAPTOR_OPTION_ALLOW_NON_NS_ATTRIBUTES : case RAPTOR_OPTION_ALLOW_OTHER_PARSETYPES : case RAPTOR_OPTION_ALLOW_BAGID : case RAPTOR_OPTION_ALLOW_RDF_TYPE_RDF_LIST : case RAPTOR_OPTION_NORMALIZE_LANGUAGE : case RAPTOR_OPTION_NON_NFC_FATAL : case RAPTOR_OPTION_WARN_OTHER_PARSETYPES : case RAPTOR_OPTION_CHECK_RDF_ID : case RAPTOR_OPTION_HTML_TAG_SOUP : case RAPTOR_OPTION_MICROFORMATS : case RAPTOR_OPTION_HTML_LINK : case RAPTOR_OPTION_WWW_TIMEOUT : case RAPTOR_OPTION_STRICT : case RAPTOR_OPTION_NO_NET : case RAPTOR_OPTION_NO_FILE : case RAPTOR_OPTION_RELATIVE_URIS : case RAPTOR_OPTION_RESOURCE_BORDER : case RAPTOR_OPTION_LITERAL_BORDER : case RAPTOR_OPTION_BNODE_BORDER : case RAPTOR_OPTION_RESOURCE_FILL : case RAPTOR_OPTION_LITERAL_FILL : case RAPTOR_OPTION_BNODE_FILL : case RAPTOR_OPTION_JSON_CALLBACK : case RAPTOR_OPTION_JSON_EXTRA_DATA : case RAPTOR_OPTION_RSS_TRIPLES : case RAPTOR_OPTION_ATOM_ENTRY_URI : case RAPTOR_OPTION_PREFIX_ELEMENTS : case RAPTOR_OPTION_WRITE_BASE_URI : case RAPTOR_OPTION_WWW_HTTP_CACHE_CONTROL : case RAPTOR_OPTION_WWW_HTTP_USER_AGENT : case RAPTOR_OPTION_WWW_CERT_FILENAME : case RAPTOR_OPTION_WWW_CERT_TYPE : case RAPTOR_OPTION_WWW_CERT_PASSPHRASE : case RAPTOR_OPTION_WWW_SSL_VERIFY_PEER : case RAPTOR_OPTION_WWW_SSL_VERIFY_HOST : default : return - 1 ; break ; } return 0 ; } "," RAPTOR_OPTION_NO_FILE : case RAPTOR_OPTION_LOAD_EXTERNAL_ENTITIES : case ",dajobe@raptor/a676f235309a59d4aa78eeffd2574ae5d341fcb0,CVE-2012-0037,https://github.com/dajobe/raptor/commit/a676f235309a59d4aa78eeffd2574ae5d341fcb0,2012-06-17T03:41Z 900,CWE-200,"CWE-200 static void nfnetlink_rcv_batch ( struct sk_buff * skb , struct nlmsghdr * nlh , u_int16_t subsys_id ) { struct sk_buff * oskb = skb ; struct net * net = sock_net ( skb -> sk ) ; const struct nfnetlink_subsystem * ss ; const struct nfnl_callback * nc ; static LIST_HEAD ( err_list ) ; u32 status ; int err ; if ( subsys_id >= NFNL_SUBSYS_COUNT ) return netlink_ack ( skb , nlh , - EINVAL ) ; replay : status = 0 ; skb = netlink_skb_clone ( oskb , GFP_KERNEL ) ; if ( ! skb ) return netlink_ack ( oskb , nlh , - ENOMEM ) ; nfnl_lock ( subsys_id ) ; ss = nfnl_dereference_protected ( subsys_id ) ; if ( ! ss ) { # ifdef CONFIG_MODULES nfnl_unlock ( subsys_id ) ; request_module ( ""nfnetlink-subsys-%d"" , subsys_id ) ; nfnl_lock ( subsys_id ) ; ss = nfnl_dereference_protected ( subsys_id ) ; if ( ! ss ) # endif { nfnl_unlock ( subsys_id ) ; netlink_ack ( oskb , nlh , - EOPNOTSUPP ) ; return kfree_skb ( skb ) ; } } if ( ! ss -> commit || ! ss -> abort ) { nfnl_unlock ( subsys_id ) ; netlink_ack ( oskb , nlh , - EOPNOTSUPP ) ; return kfree_skb ( skb ) ; } while ( skb -> len >= nlmsg_total_size ( 0 ) ) { int msglen , type ; nlh = nlmsg_hdr ( skb ) ; err = 0 ; if ( nlmsg_len ( nlh ) < sizeof ( struct nfgenmsg ) || skb -> len < nlh -> nlmsg_len ) { err = - EINVAL ; goto ack ; } if ( ! ( nlh -> nlmsg_flags & NLM_F_REQUEST ) ) { err = - EINVAL ; goto ack ; } type = nlh -> nlmsg_type ; if ( type == NFNL_MSG_BATCH_BEGIN ) { nfnl_err_reset ( & err_list ) ; status |= NFNL_BATCH_FAILURE ; goto done ; } else if ( type == NFNL_MSG_BATCH_END ) { status |= NFNL_BATCH_DONE ; goto done ; } else if ( type < NLMSG_MIN_TYPE ) { err = - EINVAL ; goto ack ; } if ( NFNL_SUBSYS_ID ( type ) != subsys_id ) { err = - EINVAL ; goto ack ; } nc = nfnetlink_find_client ( type , ss ) ; if ( ! nc ) { err = - EINVAL ; goto ack ; } { int min_len = nlmsg_total_size ( sizeof ( struct nfgenmsg ) ) ; u_int8_t cb_id = NFNL_MSG_TYPE ( nlh -> nlmsg_type ) ; struct nlattr * cda [ ss -> cb [ cb_id ] . attr_count + 1 ] ; struct nlattr * attr = ( void * ) nlh + min_len ; int attrlen = nlh -> nlmsg_len - min_len ; err = nla_parse ( cda , ss -> cb [ cb_id ] . attr_count , attr , attrlen , ss -> cb [ cb_id ] . policy ) ; if ( err < 0 ) goto ack ; if ( nc -> call_batch ) { err = nc -> call_batch ( net , net -> nfnl , skb , nlh , ( const struct nlattr * * ) cda ) ; } if ( err == - EAGAIN ) { status |= NFNL_BATCH_REPLAY ; goto next ; } } ack : if ( nlh -> nlmsg_flags & NLM_F_ACK || err ) { if ( nfnl_err_add ( & err_list , nlh , err ) < 0 ) { nfnl_err_reset ( & err_list ) ; netlink_ack ( oskb , nlmsg_hdr ( oskb ) , - ENOMEM ) ; status |= NFNL_BATCH_FAILURE ; goto done ; } if ( err ) status |= NFNL_BATCH_FAILURE ; } next : msglen = NLMSG_ALIGN ( nlh -> nlmsg_len ) ; if ( msglen > skb -> len ) msglen = skb -> len ; skb_pull ( skb , msglen ) ; } done : if ( status & NFNL_BATCH_REPLAY ) { ss -> abort ( net , oskb ) ; nfnl_err_reset ( & err_list ) ; nfnl_unlock ( subsys_id ) ; kfree_skb ( skb ) ; goto replay ; } else if ( status == NFNL_BATCH_DONE ) { ss -> commit ( net , oskb ) ; } else { ss -> abort ( net , oskb ) ; } nfnl_err_deliver ( & err_list , oskb ) ; nfnl_unlock ( subsys_id ) ; kfree_skb ( skb ) ; } "," ; if ( nlh -> nlmsg_len < NLMSG_HDRLEN || skb -> len < nlh -> nlmsg_len || struct nfgenmsg ) ) { nfnl_err_reset ( & err_list ) ; status |= NFNL_BATCH_FAILURE ; goto done ; } if ",torvalds@linux/c58d6c93680f28ac58984af61d0a7ebf4319c241,CVE-2016-7917,https://github.com/torvalds/linux/commit/c58d6c93680f28ac58984af61d0a7ebf4319c241,2016-11-16T05:59Z 901,CWE-20,"CWE-20 error_t ssiProcessExecCommand ( HttpConnection * connection , const char_t * tag , size_t length ) { char_t * separator ; char_t * attribute ; char_t * value ; if ( connection -> settings -> cgiCallback == NULL ) return ERROR_INVALID_TAG ; if ( length < 4 || length >= HTTP_SERVER_BUFFER_SIZE ) return ERROR_INVALID_TAG ; osMemcpy ( connection -> buffer , tag + 4 , length - 4 ) ; connection -> buffer [ length - 4 ] = '\\0' ; separator = strchr ( connection -> buffer , '=' ) ; if ( ! separator ) return ERROR_INVALID_TAG ; * separator = '\\0' ; attribute = strTrimWhitespace ( connection -> buffer ) ; value = strTrimWhitespace ( separator + 1 ) ; if ( value [ 0 ] == '\\'' || value [ 0 ] == \'\\""\' ) value ++ ; length = osStrlen ( value ) ; if ( length > 0 ) { if ( value [ length - 1 ] == '\\'' || value [ length - 1 ] == \'\\""\' ) value [ length - 1 ] = '\\0' ; } if ( osStrcasecmp ( attribute , ""cgi"" ) && osStrcasecmp ( attribute , ""cmd"" ) && osStrcasecmp ( attribute , ""cmd_argument"" ) ) return ERROR_INVALID_TAG ; if ( osStrlen ( value ) > HTTP_SERVER_CGI_PARAM_MAX_LEN ) return ERROR_INVALID_TAG ; osStrcpy ( connection -> cgiParam , value ) ; return connection -> settings -> cgiCallback ( connection , connection -> cgiParam ) ; } "," ; separator = osStrchr ( connection -> ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 902,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 903,CWE-119,"CWE-119 static void encode_segmentation ( VP9_COMP * cpi , struct vp9_write_bit_buffer * wb ) { int i , j ; struct segmentation * seg = & cpi -> common . seg ; vp9_wb_write_bit ( wb , seg -> enabled ) ; if ( ! seg -> enabled ) return ; vp9_wb_write_bit ( wb , seg -> update_map ) ; if ( seg -> update_map ) { vp9_choose_segmap_coding_method ( cpi ) ; for ( i = 0 ; i < SEG_TREE_PROBS ; i ++ ) { const int prob = seg -> tree_probs [ i ] ; const int update = prob != MAX_PROB ; vp9_wb_write_bit ( wb , update ) ; if ( update ) vp9_wb_write_literal ( wb , prob , 8 ) ; } vp9_wb_write_bit ( wb , seg -> temporal_update ) ; if ( seg -> temporal_update ) { for ( i = 0 ; i < PREDICTION_PROBS ; i ++ ) { const int prob = seg -> pred_probs [ i ] ; const int update = prob != MAX_PROB ; vp9_wb_write_bit ( wb , update ) ; if ( update ) vp9_wb_write_literal ( wb , prob , 8 ) ; } } } vp9_wb_write_bit ( wb , seg -> update_data ) ; if ( seg -> update_data ) { vp9_wb_write_bit ( wb , seg -> abs_delta ) ; for ( i = 0 ; i < MAX_SEGMENTS ; i ++ ) { for ( j = 0 ; j < SEG_LVL_MAX ; j ++ ) { const int active = vp9_segfeature_active ( seg , i , j ) ; vp9_wb_write_bit ( wb , active ) ; if ( active ) { const int data = vp9_get_segdata ( seg , i , j ) ; const int data_max = vp9_seg_feature_data_max ( j ) ; if ( vp9_is_segfeature_signed ( j ) ) { encode_unsigned_max ( wb , abs ( data ) , data_max ) ; vp9_wb_write_bit ( wb , data < 0 ) ; } else { encode_unsigned_max ( wb , data , data_max ) ; } } } } } } "," void encode_segmentation ( VP9_COMMON * cm , MACROBLOCKD * xd , struct vpx_write_bit_buffer * wb ) , j ; const seg = & cm -> seg ; vpx_wb_write_bit ( wb , ) return ; vpx_wb_write_bit ( wb , { vp9_choose_segmap_coding_method ( cm , xd ) ; for != MAX_PROB ; vpx_wb_write_bit ( wb , update ) ; if ( update ) vpx_wb_write_literal ( wb , ) ; } vpx_wb_write_bit ( wb , != MAX_PROB ; vpx_wb_write_bit ( wb , update ) ; if ( update ) vpx_wb_write_literal ( wb , } } } vpx_wb_write_bit ( wb , update_data ) { vpx_wb_write_bit ( wb , int active = segfeature_active ( seg , i , j ) ; vpx_wb_write_bit ( wb , int data = get_segdata ( seg , data_max ) ; vpx_wb_write_bit ( wb , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 904,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 ) ; } "," 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 905,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 906,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 907,CWE-119,"CWE-119 static void rd_check_segment ( VP8_COMP * cpi , MACROBLOCK * x , BEST_SEG_INFO * bsi , unsigned int segmentation ) { int i ; int const * labels ; int br = 0 ; int bd = 0 ; B_PREDICTION_MODE this_mode ; int label_count ; int this_segment_rd = 0 ; int label_mv_thresh ; int rate = 0 ; int sbr = 0 ; int sbd = 0 ; int segmentyrate = 0 ; vp8_variance_fn_ptr_t * v_fn_ptr ; ENTROPY_CONTEXT_PLANES t_above , t_left ; ENTROPY_CONTEXT * ta ; ENTROPY_CONTEXT * tl ; ENTROPY_CONTEXT_PLANES t_above_b , t_left_b ; ENTROPY_CONTEXT * ta_b ; ENTROPY_CONTEXT * tl_b ; 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 ; ta_b = ( ENTROPY_CONTEXT * ) & t_above_b ; tl_b = ( ENTROPY_CONTEXT * ) & t_left_b ; br = 0 ; bd = 0 ; v_fn_ptr = & cpi -> fn_ptr [ segmentation ] ; labels = vp8_mbsplits [ segmentation ] ; label_count = vp8_mbsplit_count [ segmentation ] ; label_mv_thresh = 1 * bsi -> mvthresh / label_count ; rate = vp8_cost_token ( vp8_mbsplit_tree , vp8_mbsplit_probs , vp8_mbsplit_encodings + segmentation ) ; rate += vp8_cost_mv_ref ( SPLITMV , bsi -> mdcounts ) ; this_segment_rd += RDCOST ( x -> rdmult , x -> rddiv , rate , 0 ) ; br += rate ; for ( i = 0 ; i < label_count ; i ++ ) { int_mv mode_mv [ B_MODE_COUNT ] ; int best_label_rd = INT_MAX ; B_PREDICTION_MODE mode_selected = ZERO4X4 ; int bestlabelyrate = 0 ; for ( this_mode = LEFT4X4 ; this_mode <= NEW4X4 ; this_mode ++ ) { int this_rd ; int distortion ; int labelyrate ; ENTROPY_CONTEXT_PLANES t_above_s , t_left_s ; ENTROPY_CONTEXT * ta_s ; ENTROPY_CONTEXT * tl_s ; vpx_memcpy ( & t_above_s , & t_above , sizeof ( ENTROPY_CONTEXT_PLANES ) ) ; vpx_memcpy ( & t_left_s , & t_left , sizeof ( ENTROPY_CONTEXT_PLANES ) ) ; ta_s = ( ENTROPY_CONTEXT * ) & t_above_s ; tl_s = ( ENTROPY_CONTEXT * ) & t_left_s ; if ( this_mode == NEW4X4 ) { int sseshift ; int num00 ; int step_param = 0 ; int further_steps ; int n ; int thissme ; int bestsme = INT_MAX ; int_mv temp_mv ; BLOCK * c ; BLOCKD * e ; if ( best_label_rd < label_mv_thresh ) break ; if ( cpi -> compressor_speed ) { if ( segmentation == BLOCK_8X16 || segmentation == BLOCK_16X8 ) { bsi -> mvp . as_int = bsi -> sv_mvp [ i ] . as_int ; if ( i == 1 && segmentation == BLOCK_16X8 ) bsi -> mvp . as_int = bsi -> sv_mvp [ 2 ] . as_int ; step_param = bsi -> sv_istep [ i ] ; } if ( segmentation == BLOCK_4X4 && i > 0 ) { bsi -> mvp . as_int = x -> e_mbd . block [ i - 1 ] . bmi . mv . as_int ; if ( i == 4 || i == 8 || i == 12 ) bsi -> mvp . as_int = x -> e_mbd . block [ i - 4 ] . bmi . mv . as_int ; step_param = 2 ; } } further_steps = ( MAX_MVSEARCH_STEPS - 1 ) - step_param ; { int sadpb = x -> sadperbit4 ; int_mv mvp_full ; mvp_full . as_mv . row = bsi -> mvp . as_mv . row >> 3 ; mvp_full . as_mv . col = bsi -> mvp . as_mv . col >> 3 ; n = vp8_mbsplit_offset [ segmentation ] [ i ] ; c = & x -> block [ n ] ; e = & x -> e_mbd . block [ n ] ; { bestsme = cpi -> diamond_search_sad ( x , c , e , & mvp_full , & mode_mv [ NEW4X4 ] , step_param , sadpb , & num00 , v_fn_ptr , x -> mvcost , bsi -> ref_mv ) ; n = num00 ; num00 = 0 ; while ( n < further_steps ) { n ++ ; if ( num00 ) num00 -- ; else { thissme = cpi -> diamond_search_sad ( x , c , e , & mvp_full , & temp_mv , step_param + n , sadpb , & num00 , v_fn_ptr , x -> mvcost , bsi -> ref_mv ) ; if ( thissme < bestsme ) { bestsme = thissme ; mode_mv [ NEW4X4 ] . as_int = temp_mv . as_int ; } } } } sseshift = segmentation_to_sseshift [ segmentation ] ; if ( ( cpi -> compressor_speed == 0 ) && ( bestsme >> sseshift ) > 4000 ) { vp8_clamp_mv ( & mvp_full , x -> mv_col_min , x -> mv_col_max , x -> mv_row_min , x -> mv_row_max ) ; thissme = cpi -> full_search_sad ( x , c , e , & mvp_full , sadpb , 16 , v_fn_ptr , x -> mvcost , bsi -> ref_mv ) ; if ( thissme < bestsme ) { bestsme = thissme ; mode_mv [ NEW4X4 ] . as_int = e -> bmi . mv . as_int ; } else { e -> bmi . mv . as_int = mode_mv [ NEW4X4 ] . as_int ; } } } if ( bestsme < INT_MAX ) { int disto ; unsigned int sse ; cpi -> find_fractional_mv_step ( x , c , e , & mode_mv [ NEW4X4 ] , bsi -> ref_mv , x -> errorperbit , v_fn_ptr , x -> mvcost , & disto , & sse ) ; } } rate = labels2mode ( x , labels , i , this_mode , & mode_mv [ this_mode ] , bsi -> ref_mv , x -> mvcost ) ; 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 ; } distortion = vp8_encode_inter_mb_segment ( x , labels , i ) / 4 ; labelyrate = rdcost_mbsegment_y ( x , labels , i , ta_s , tl_s ) ; rate += labelyrate ; this_rd = RDCOST ( x -> rdmult , x -> rddiv , rate , distortion ) ; if ( this_rd < best_label_rd ) { sbr = rate ; sbd = distortion ; bestlabelyrate = labelyrate ; mode_selected = this_mode ; best_label_rd = this_rd ; vpx_memcpy ( ta_b , ta_s , sizeof ( ENTROPY_CONTEXT_PLANES ) ) ; vpx_memcpy ( tl_b , tl_s , sizeof ( ENTROPY_CONTEXT_PLANES ) ) ; } } vpx_memcpy ( ta , ta_b , sizeof ( ENTROPY_CONTEXT_PLANES ) ) ; vpx_memcpy ( tl , tl_b , sizeof ( ENTROPY_CONTEXT_PLANES ) ) ; labels2mode ( x , labels , i , mode_selected , & mode_mv [ mode_selected ] , bsi -> ref_mv , x -> mvcost ) ; br += sbr ; bd += sbd ; segmentyrate += bestlabelyrate ; this_segment_rd += best_label_rd ; if ( this_segment_rd >= bsi -> segment_rd ) break ; } if ( this_segment_rd < bsi -> segment_rd ) { bsi -> r = br ; bsi -> d = bd ; bsi -> segment_yrate = segmentyrate ; bsi -> segment_rd = this_segment_rd ; bsi -> segment_num = segmentation ; for ( i = 0 ; i < 16 ; i ++ ) { bsi -> mvs [ i ] . as_mv = x -> partition_info -> bmi [ i ] . mv . as_mv ; bsi -> modes [ i ] = x -> partition_info -> bmi [ i ] . mode ; bsi -> eobs [ i ] = x -> e_mbd . eobs [ i ] ; } } } "," * tl_b ; memcpy ( & t_above ) ) ; memcpy ( & t_left * tl_s ; memcpy ( & t_above_s ) ) ; memcpy ( & t_left_s = this_rd ; memcpy ( ta_b , ) ) ; memcpy ( tl_b , ; } } memcpy ( ta , ) ) ; memcpy ( tl , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 908,CWE-189,"CWE-189 static int perf_swevent_init ( struct perf_event * event ) { int event_id = event -> attr . config ; if ( event -> attr . type != PERF_TYPE_SOFTWARE ) return - ENOENT ; if ( has_branch_stack ( event ) ) return - EOPNOTSUPP ; switch ( event_id ) { case PERF_COUNT_SW_CPU_CLOCK : case PERF_COUNT_SW_TASK_CLOCK : return - ENOENT ; default : break ; } if ( event_id >= PERF_COUNT_SW_MAX ) return - ENOENT ; if ( ! event -> parent ) { int err ; err = swevent_hlist_get ( event ) ; if ( err ) return err ; static_key_slow_inc ( & perf_swevent_enabled [ event_id ] ) ; event -> destroy = sw_perf_event_destroy ; } return 0 ; } "," event ) { u64 event_id = event ",torvalds@linux/8176cced706b5e5d15887584150764894e94e02f,CVE-2013-2094,https://github.com/torvalds/linux/commit/8176cced706b5e5d15887584150764894e94e02f,2013-05-14T20:55Z 909,CWE-269,"CWE-269 static int em_sysenter ( struct x86_emulate_ctxt * ctxt ) { const struct x86_emulate_ops * ops = ctxt -> ops ; struct desc_struct cs , ss ; u64 msr_data ; u16 cs_sel , ss_sel ; u64 efer = 0 ; ops -> get_msr ( ctxt , MSR_EFER , & efer ) ; if ( ctxt -> mode == X86EMUL_MODE_REAL ) return emulate_gp ( ctxt , 0 ) ; if ( ( ctxt -> mode == X86EMUL_MODE_PROT32 ) && ( efer & EFER_LMA ) && ! vendor_intel ( ctxt ) ) return emulate_ud ( ctxt ) ; if ( ctxt -> mode == X86EMUL_MODE_PROT64 ) return X86EMUL_UNHANDLEABLE ; setup_syscalls_segments ( ctxt , & cs , & ss ) ; ops -> get_msr ( ctxt , MSR_IA32_SYSENTER_CS , & msr_data ) ; switch ( ctxt -> mode ) { case X86EMUL_MODE_PROT32 : if ( ( msr_data & 0xfffc ) == 0x0 ) return emulate_gp ( ctxt , 0 ) ; break ; case X86EMUL_MODE_PROT64 : if ( msr_data == 0x0 ) return emulate_gp ( ctxt , 0 ) ; break ; default : break ; } ctxt -> eflags &= ~ ( EFLG_VM | EFLG_IF ) ; cs_sel = ( u16 ) msr_data ; cs_sel &= ~ SELECTOR_RPL_MASK ; ss_sel = cs_sel + 8 ; ss_sel &= ~ SELECTOR_RPL_MASK ; if ( ctxt -> mode == X86EMUL_MODE_PROT64 || ( 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 ) ; ops -> get_msr ( ctxt , MSR_IA32_SYSENTER_EIP , & msr_data ) ; ctxt -> _eip = msr_data ; ops -> get_msr ( ctxt , MSR_IA32_SYSENTER_ESP , & msr_data ) ; * reg_write ( ctxt , VCPU_REGS_RSP ) = msr_data ; return X86EMUL_CONTINUE ; } "," ctxt -> mode != X86EMUL_MODE_PROT64 ) && ( msr_data ) ; if ( ( 0 ) ; ctxt -> eflags u16 ) msr_data & ~ SELECTOR_RPL_MASK ; + 8 ; if ( efer & efer & EFER_LMA ) { cs -> _eip = ( efer & EFER_LMA ) ? msr_data : ( u32 ) VCPU_REGS_RSP ) = ( efer & EFER_LMA ) ? msr_data : ( u32 ) ",torvalds@linux/f3747379accba8e95d70cec0eae0582c8c182050,CVE-2015-0239,https://github.com/torvalds/linux/commit/f3747379accba8e95d70cec0eae0582c8c182050,2015-03-02T11:59Z 910,CWE-310,"CWE-310 json_t * json_object ( void ) { json_object_t * object = jsonp_malloc ( sizeof ( json_object_t ) ) ; if ( ! object ) return NULL ; json_init ( & object -> json , JSON_OBJECT ) ; if ( hashtable_init ( & object -> hashtable ) ) { jsonp_free ( object ) ; return NULL ; } object -> serial = 0 ; object -> visited = 0 ; return & object -> json ; } "," return NULL ; if ( ! hashtable_seed ) { json_object_seed ( 0 ) ; } ",akheron@jansson/8f80c2d83808150724d31793e6ade92749b1faa4,CVE-2013-6401,https://github.com/akheron/jansson/commit/8f80c2d83808150724d31793e6ade92749b1faa4,2014-03-21T01:04Z 911,CWE-119,"CWE-119 static void record_recent_object ( struct object * obj , struct strbuf * path , const char * last , void * data ) { sha1_array_append ( & recent_objects , obj -> oid . hash ) ; } "," * obj , const char * const char * name , void * ",git@git/de1e67d0703894cb6ea782e36abb63976ab07e60,CVE-2016-2315,https://github.com/git/git/commit/de1e67d0703894cb6ea782e36abb63976ab07e60,2016-04-08T14:59Z 912,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 913,CWE-17,"CWE-17 static int udf_readdir ( struct file * file , struct dir_context * ctx ) { struct inode * dir = file_inode ( file ) ; struct udf_inode_info * iinfo = UDF_I ( dir ) ; struct udf_fileident_bh fibh = { . sbh = NULL , . ebh = NULL } ; struct fileIdentDesc * fi = NULL ; struct fileIdentDesc cfi ; int block , iblock ; loff_t nf_pos ; int flen ; unsigned char * fname = NULL ; unsigned char * nameptr ; uint16_t liu ; uint8_t lfi ; loff_t size = udf_ext0_offset ( dir ) + dir -> i_size ; struct buffer_head * tmp , * bha [ 16 ] ; struct kernel_lb_addr eloc ; uint32_t elen ; sector_t offset ; int i , num , ret = 0 ; struct extent_position epos = { NULL , 0 , { 0 , 0 } } ; if ( ctx -> pos == 0 ) { if ( ! dir_emit_dot ( file , ctx ) ) return 0 ; ctx -> pos = 1 ; } nf_pos = ( ctx -> pos - 1 ) << 2 ; if ( nf_pos >= size ) goto out ; fname = kmalloc ( UDF_NAME_LEN , GFP_NOFS ) ; if ( ! fname ) { ret = - ENOMEM ; goto out ; } if ( nf_pos == 0 ) nf_pos = udf_ext0_offset ( dir ) ; fibh . soffset = fibh . eoffset = nf_pos & ( dir -> i_sb -> s_blocksize - 1 ) ; if ( iinfo -> i_alloc_type != ICBTAG_FLAG_AD_IN_ICB ) { if ( inode_bmap ( dir , nf_pos >> dir -> i_sb -> s_blocksize_bits , & epos , & eloc , & elen , & offset ) != ( EXT_RECORDED_ALLOCATED >> 30 ) ) { ret = - ENOENT ; goto out ; } block = udf_get_lb_pblock ( dir -> i_sb , & eloc , offset ) ; if ( ( ++ offset << dir -> i_sb -> s_blocksize_bits ) < elen ) { if ( iinfo -> i_alloc_type == ICBTAG_FLAG_AD_SHORT ) epos . offset -= sizeof ( struct short_ad ) ; else if ( iinfo -> i_alloc_type == ICBTAG_FLAG_AD_LONG ) epos . offset -= sizeof ( struct long_ad ) ; } else { offset = 0 ; } if ( ! ( fibh . sbh = fibh . ebh = udf_tread ( dir -> i_sb , block ) ) ) { ret = - EIO ; goto out ; } if ( ! ( offset & ( ( 16 >> ( dir -> i_sb -> s_blocksize_bits - 9 ) ) - 1 ) ) ) { i = 16 >> ( dir -> i_sb -> s_blocksize_bits - 9 ) ; if ( i + offset > ( elen >> dir -> i_sb -> s_blocksize_bits ) ) i = ( elen >> dir -> i_sb -> s_blocksize_bits ) - offset ; for ( num = 0 ; i > 0 ; i -- ) { block = udf_get_lb_pblock ( dir -> i_sb , & eloc , offset + i ) ; tmp = udf_tgetblk ( dir -> i_sb , block ) ; if ( tmp && ! buffer_uptodate ( tmp ) && ! buffer_locked ( tmp ) ) bha [ num ++ ] = tmp ; else brelse ( tmp ) ; } if ( num ) { ll_rw_block ( READA , num , bha ) ; for ( i = 0 ; i < num ; i ++ ) brelse ( bha [ i ] ) ; } } } while ( nf_pos < size ) { struct kernel_lb_addr tloc ; ctx -> pos = ( nf_pos >> 2 ) + 1 ; fi = udf_fileident_read ( dir , & nf_pos , & fibh , & cfi , & epos , & eloc , & elen , & offset ) ; if ( ! fi ) goto out ; 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 = ( char * ) ( 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 ) { if ( ! dir_emit_dotdot ( file , ctx ) ) goto out ; continue ; } flen = udf_get_filename ( dir -> i_sb , nameptr , fname , lfi ) ; if ( ! flen ) continue ; tloc = lelb_to_cpu ( cfi . icb . extLocation ) ; iblock = udf_get_lb_pblock ( dir -> i_sb , & tloc , 0 ) ; if ( ! dir_emit ( ctx , fname , flen , iblock , DT_UNKNOWN ) ) goto out ; } ctx -> pos = ( nf_pos >> 2 ) + 1 ; out : if ( fibh . sbh != fibh . ebh ) brelse ( fibh . ebh ) ; brelse ( fibh . sbh ) ; brelse ( epos . bh ) ; kfree ( fname ) ; return ret ; } "," , nameptr , lfi , fname , UDF_NAME_LEN ) ; if ",torvalds@linux/0e5cc9a40ada6046e6bc3bdfcd0c0d7e4b706b14,CVE-2014-9731,https://github.com/torvalds/linux/commit/0e5cc9a40ada6046e6bc3bdfcd0c0d7e4b706b14,2015-08-31T10:59Z 914,CWE-119,"CWE-119 void vp8_dequant_idct_add_uv_block_mmx ( short * q , short * dq , unsigned char * dstu , unsigned char * dstv , int stride , char * eobs ) { int i ; for ( i = 0 ; i < 2 ; i ++ ) { if ( eobs [ 0 ] > 1 ) vp8_dequant_idct_add_mmx ( q , dq , dstu , stride ) ; else if ( eobs [ 0 ] == 1 ) { vp8_dc_only_idct_add_mmx ( q [ 0 ] * dq [ 0 ] , dstu , stride , dstu , stride ) ; vpx_memset ( q , 0 , 2 * sizeof ( q [ 0 ] ) ) ; } if ( eobs [ 1 ] > 1 ) vp8_dequant_idct_add_mmx ( q + 16 , dq , dstu + 4 , stride ) ; else if ( eobs [ 1 ] == 1 ) { vp8_dc_only_idct_add_mmx ( q [ 16 ] * dq [ 0 ] , dstu + 4 , stride , dstu + 4 , stride ) ; vpx_memset ( q + 16 , 0 , 2 * sizeof ( q [ 0 ] ) ) ; } q += 32 ; dstu += 4 * stride ; eobs += 2 ; } for ( i = 0 ; i < 2 ; i ++ ) { if ( eobs [ 0 ] > 1 ) vp8_dequant_idct_add_mmx ( q , dq , dstv , stride ) ; else if ( eobs [ 0 ] == 1 ) { vp8_dc_only_idct_add_mmx ( q [ 0 ] * dq [ 0 ] , dstv , stride , dstv , stride ) ; vpx_memset ( q , 0 , 2 * sizeof ( q [ 0 ] ) ) ; } if ( eobs [ 1 ] > 1 ) vp8_dequant_idct_add_mmx ( q + 16 , dq , dstv + 4 , stride ) ; else if ( eobs [ 1 ] == 1 ) { vp8_dc_only_idct_add_mmx ( q [ 16 ] * dq [ 0 ] , dstv + 4 , stride , dstv + 4 , stride ) ; vpx_memset ( q + 16 , 0 , 2 * sizeof ( q [ 0 ] ) ) ; } q += 32 ; dstv += 4 * stride ; eobs += 2 ; } } "," stride ) ; memset ( q , stride ) ; memset ( q + stride ) ; memset ( q , stride ) ; memset ( q + ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 915,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 916,CWE-125,"CWE-125 int main ( int argc , char * * argv ) { const char command0 [ ] = { 0x00 , 0x00 } ; char command1 [ ] = ""\\x01\\x00urn:schemas-upnp-org:device:InternetGatewayDevice"" ; char command2 [ ] = ""\\x02\\x00uuid:fc4ec57e-b051-11db-88f8-0060085db3f6::upnp:rootdevice"" ; const char command3 [ ] = { 0x03 , 0x00 } ; char command3compat [ ] = ""\\x03\\x00ssdp:all"" ; char command4 [ ] = ""\\x04\\x00test:test:test"" ; const char bad_command [ ] = { 0xff , 0xff } ; const char overflow [ ] = { 0x01 , 0xff , 0xff , 0xff , 0xff , 0xff , 0xff , 0xff } ; const char command5 [ ] = { 0x05 , 0x00 } ; int s ; int i ; void * tmp ; unsigned char * resp = NULL ; size_t respsize = 0 ; unsigned char buf [ 4096 ] ; ssize_t n ; int total = 0 ; const char * sockpath = ""/var/run/minissdpd.sock"" ; for ( i = 0 ; i < argc - 1 ; i ++ ) { if ( 0 == strcmp ( argv [ i ] , ""-s"" ) ) sockpath = argv [ ++ i ] ; } command1 [ 1 ] = sizeof ( command1 ) - 3 ; command2 [ 1 ] = sizeof ( command2 ) - 3 ; command3compat [ 1 ] = sizeof ( command3compat ) - 3 ; command4 [ 1 ] = sizeof ( command4 ) - 3 ; s = connect_unix_socket ( sockpath ) ; n = SENDCOMMAND ( command0 , sizeof ( command0 ) ) ; n = read ( s , buf , sizeof ( buf ) ) ; printf ( ""Responsereceived%dbytes\\n"" , ( int ) n ) ; if ( n > 0 ) { printversion ( buf , n ) ; } else { printf ( ""Command0(getversion)notsupported\\n"" ) ; close ( s ) ; s = connect_unix_socket ( sockpath ) ; } n = SENDCOMMAND ( command1 , sizeof ( command1 ) - 1 ) ; n = read ( s , buf , sizeof ( buf ) ) ; printf ( ""Responsereceived%dbytes\\n"" , ( int ) n ) ; printresponse ( buf , n ) ; if ( n == 0 ) { close ( s ) ; s = connect_unix_socket ( sockpath ) ; } n = SENDCOMMAND ( command2 , sizeof ( command2 ) - 1 ) ; n = read ( s , buf , sizeof ( buf ) ) ; printf ( ""Responsereceived%dbytes\\n"" , ( int ) n ) ; printresponse ( buf , n ) ; if ( n == 0 ) { close ( s ) ; s = connect_unix_socket ( sockpath ) ; } buf [ 0 ] = 0 ; n = SENDCOMMAND ( command3 , sizeof ( command3 ) ) ; n = read ( s , buf , sizeof ( buf ) ) ; if ( n == 0 ) { printf ( ""command3failed,testingcompatibleone\\n"" ) ; close ( s ) ; s = connect_unix_socket ( sockpath ) ; n = SENDCOMMAND ( command3compat , sizeof ( command3compat ) - 1 ) ; n = read ( s , buf , sizeof ( buf ) ) ; } printf ( ""Responsereceived%dbytes\\n"" , ( int ) n ) ; printf ( ""Numberofdevices%d\\n"" , ( int ) buf [ 0 ] ) ; while ( n > 0 ) { tmp = realloc ( resp , respsize + n ) ; if ( tmp == NULL ) { fprintf ( stderr , ""memoryallocationerror\\n"" ) ; break ; } resp = tmp ; respsize += n ; if ( n > 0 ) { memcpy ( resp + total , buf , n ) ; total += n ; } if ( n < ( ssize_t ) sizeof ( buf ) ) { break ; } n = read ( s , buf , sizeof ( buf ) ) ; printf ( ""responsereceived%dbytes\\n"" , ( int ) n ) ; } if ( resp != NULL ) { printresponse ( resp , total ) ; free ( resp ) ; resp = NULL ; } if ( n == 0 ) { close ( s ) ; s = connect_unix_socket ( sockpath ) ; } n = SENDCOMMAND ( command4 , sizeof ( command4 ) ) ; n = SENDCOMMAND ( bad_command , sizeof ( bad_command ) ) ; n = read ( s , buf , sizeof ( buf ) ) ; printf ( ""Responsereceived%dbytes\\n"" , ( int ) n ) ; printresponse ( buf , n ) ; if ( n == 0 ) { close ( s ) ; s = connect_unix_socket ( sockpath ) ; } n = SENDCOMMAND ( overflow , sizeof ( overflow ) ) ; n = read ( s , buf , sizeof ( buf ) ) ; printf ( ""Responsereceived%dbytes\\n"" , ( int ) n ) ; printresponse ( buf , n ) ; if ( n == 0 ) { close ( s ) ; s = connect_unix_socket ( sockpath ) ; } n = SENDCOMMAND ( command5 , sizeof ( command5 ) ) ; n = read ( s , buf , sizeof ( buf ) ) ; printf ( ""Responsereceived%dbytes\\n"" , ( int ) n ) ; printresponse ( buf , n ) ; close ( s ) ; return 0 ; } "," 0x05 , 0x00 } ; const char bad_command4 [ ] = { 0x04 , 0x01 , 0x60 , 0x8f , 0xff , 0xff , 0xff , 0x7f n ) ; if ( n == 0 ) { s ) ; s = connect_unix_socket ( sockpath ) ; } n = SENDCOMMAND ( bad_command4 , sizeof ( bad_command4 ) ) ; n = read ( s , buf , sizeof ( buf ) ) ; printf ( ""Responsereceived%dbytes\\n"" , ( int ) n ) ; printresponse ( buf , n ) ; close ( s ) ; ",miniupnp@miniupnp/b238cade9a173c6f751a34acf8ccff838a62aa47,CVE-2016-3178,https://github.com/miniupnp/miniupnp/commit/b238cade9a173c6f751a34acf8ccff838a62aa47,2017-03-24T15:59Z 917,CWE-200,"CWE-200 void * vips_malloc ( VipsObject * object , size_t size ) { void * buf ; buf = g_malloc ( size ) ; if ( object ) { g_signal_connect ( object , ""postclose"" , G_CALLBACK ( vips_malloc_cb ) , buf ) ; object -> local_memory += size ; } return ( buf ) ; } "," ; buf = g_malloc0 ( size ) ",libvips@libvips/00622428bda8d7521db8d74260b519fa41d69d0a,CVE-2019-6976,https://github.com/libvips/libvips/commit/00622428bda8d7521db8d74260b519fa41d69d0a,2019-01-26T23:29Z 918,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-2315,https://github.com/git/git/commit/de1e67d0703894cb6ea782e36abb63976ab07e60,2016-04-08T14:59Z 919,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 920,CWE-200,"CWE-200 void update_process_times ( int user_tick ) { struct task_struct * p = current ; account_process_tick ( p , user_tick ) ; run_local_timers ( ) ; rcu_sched_clock_irq ( user_tick ) ; # ifdef CONFIG_IRQ_WORK if ( in_irq ( ) ) irq_work_tick ( ) ; # endif scheduler_tick ( ) ; if ( IS_ENABLED ( CONFIG_POSIX_TIMERS ) ) run_posix_cpu_timers ( ) ; } "," ( ) ; this_cpu_add ( net_rand_state . s1 , rol32 ( jiffies , 24 ) + user_tick ) ; ",torvalds@linux/f227e3ec3b5cad859ad15666874405e8c1bbc1d4,CVE-2020-16166,https://github.com/torvalds/linux/commit/f227e3ec3b5cad859ad15666874405e8c1bbc1d4,2020-07-30T21:15Z 921,CWE-119,"CWE-119 int vp8_skip_fractional_mv_step ( MACROBLOCK * mb , BLOCK * b , BLOCKD * d , int_mv * bestmv , int_mv * ref_mv , int error_per_bit , const vp8_variance_fn_ptr_t * vfp , int * mvcost [ 2 ] , int * distortion , unsigned int * sse ) { ( void ) b ; ( void ) d ; ( void ) ref_mv ; ( void ) error_per_bit ; ( void ) vfp ; ( void ) mvcost ; ( void ) distortion ; ( void ) sse ; bestmv -> as_mv . row <<= 3 ; bestmv -> as_mv . col <<= 3 ; return 0 ; } "," ( void ) mb ; ( void ) ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 922,CWE-119,"CWE-119 static future_t * init ( void ) { pthread_mutex_init ( & lock , NULL ) ; config = config_new ( CONFIG_FILE_PATH ) ; if ( ! config ) { LOG_WARN ( LOG_TAG , ""%sunabletoloadconfigfile;attemptingtotranscodelegacyfile."" , __func__ ) ; config = btif_config_transcode ( LEGACY_CONFIG_FILE_PATH ) ; if ( ! config ) { LOG_WARN ( LOG_TAG , ""%sunabletotranscodelegacyfile,startingunconfigured."" , __func__ ) ; config = config_new_empty ( ) ; if ( ! config ) { LOG_ERROR ( LOG_TAG , ""%sunabletoallocateaconfigobject."" , __func__ ) ; goto error ; } } if ( config_save ( config , CONFIG_FILE_PATH ) ) unlink ( LEGACY_CONFIG_FILE_PATH ) ; } alarm_timer = alarm_new ( ) ; if ( ! alarm_timer ) { LOG_ERROR ( LOG_TAG , ""%sunabletocreatealarm."" , __func__ ) ; goto error ; } return future_new_immediate ( FUTURE_SUCCESS ) ; error : ; alarm_free ( alarm_timer ) ; config_free ( config ) ; pthread_mutex_destroy ( & lock ) ; alarm_timer = NULL ; config = NULL ; return future_new_immediate ( FUTURE_FAIL ) ; } "," ) ; } btif_config_devcache_cleanup ( ) ; ",system@bt/d77f1999ecece56c1cbb333f4ddc26f0b5bac2c5,CVE-2016-0830,https://android.googlesource.com/platform/system/bt/+/d77f1999ecece56c1cbb333f4ddc26f0b5bac2c5,2016-03-12T21:59Z 923,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 924,CWE-119,"CWE-119 static int32_t scsi_send_command ( SCSIRequest * req , uint8_t * buf ) { SCSIDiskReq * r = DO_UPCAST ( SCSIDiskReq , req , req ) ; SCSIDiskState * s = DO_UPCAST ( SCSIDiskState , qdev , req -> dev ) ; int32_t len ; uint8_t command ; uint8_t * outbuf ; int rc ; command = buf [ 0 ] ; outbuf = ( uint8_t * ) r -> iov . iov_base ; DPRINTF ( ""Command:lun=%dtag=0x%xdata=0x%02x"" , req -> lun , req -> tag , buf [ 0 ] ) ; # ifdef DEBUG_SCSI { int i ; for ( i = 1 ; i < r -> req . cmd . len ; i ++ ) { printf ( ""0x%02x"" , buf [ i ] ) ; } printf ( ""\\n"" ) ; } # endif switch ( command ) { case TEST_UNIT_READY : case INQUIRY : case MODE_SENSE : case MODE_SENSE_10 : case RESERVE : case RESERVE_10 : case RELEASE : case RELEASE_10 : case START_STOP : case ALLOW_MEDIUM_REMOVAL : case READ_CAPACITY_10 : case READ_TOC : case GET_CONFIGURATION : case SERVICE_ACTION_IN_16 : case VERIFY_10 : rc = scsi_disk_emulate_command ( r , outbuf ) ; if ( rc < 0 ) { return 0 ; } r -> iov . iov_len = rc ; break ; case SYNCHRONIZE_CACHE : bdrv_acct_start ( s -> bs , & r -> acct , 0 , BDRV_ACCT_FLUSH ) ; r -> req . aiocb = bdrv_aio_flush ( s -> bs , scsi_flush_complete , r ) ; if ( r -> req . aiocb == NULL ) { scsi_flush_complete ( r , - EIO ) ; } return 0 ; case READ_6 : case READ_10 : case READ_12 : case READ_16 : len = r -> req . cmd . xfer / s -> qdev . blocksize ; DPRINTF ( ""Read(sector%"" PRId64 "",count%d)\\n"" , r -> req . cmd . lba , len ) ; if ( r -> req . cmd . lba > s -> max_lba ) goto illegal_lba ; r -> sector = r -> req . cmd . lba * s -> cluster_size ; r -> sector_count = len * s -> cluster_size ; break ; case WRITE_6 : case WRITE_10 : case WRITE_12 : case WRITE_16 : case WRITE_VERIFY_10 : case WRITE_VERIFY_12 : case WRITE_VERIFY_16 : len = r -> req . cmd . xfer / s -> qdev . blocksize ; DPRINTF ( ""Write%s(sector%"" PRId64 "",count%d)\\n"" , ( command & 0xe ) == 0xe ? ""AndVerify"" : """" , r -> req . cmd . lba , len ) ; if ( r -> req . cmd . lba > s -> max_lba ) goto illegal_lba ; r -> sector = r -> req . cmd . lba * s -> cluster_size ; r -> sector_count = len * s -> cluster_size ; break ; case MODE_SELECT : DPRINTF ( ""ModeSelect(6)(len%lu)\\n"" , ( long ) r -> req . cmd . xfer ) ; if ( r -> req . cmd . xfer > 12 ) { goto fail ; } break ; case MODE_SELECT_10 : DPRINTF ( ""ModeSelect(10)(len%lu)\\n"" , ( long ) r -> req . cmd . xfer ) ; if ( r -> req . cmd . xfer > 16 ) { goto fail ; } break ; case SEEK_6 : case SEEK_10 : DPRINTF ( ""Seek(%d)(sector%"" PRId64 "")\\n"" , command == SEEK_6 ? 6 : 10 , r -> req . cmd . lba ) ; if ( r -> req . cmd . lba > s -> max_lba ) { goto illegal_lba ; } break ; case WRITE_SAME_16 : len = r -> req . cmd . xfer / s -> qdev . blocksize ; DPRINTF ( ""WRITESAME(16)(sector%"" PRId64 "",count%d)\\n"" , r -> req . cmd . lba , len ) ; if ( r -> req . cmd . lba > s -> max_lba ) { goto illegal_lba ; } if ( ! ( buf [ 1 ] & 0x8 ) ) { goto fail ; } rc = bdrv_discard ( s -> bs , r -> req . cmd . lba * s -> cluster_size , len * s -> cluster_size ) ; if ( rc < 0 ) { goto fail ; } break ; case REQUEST_SENSE : abort ( ) ; default : DPRINTF ( ""UnknownSCSIcommand(%2.2x)\\n"" , buf [ 0 ] ) ; scsi_check_condition ( r , SENSE_CODE ( INVALID_OPCODE ) ) ; return 0 ; fail : scsi_check_condition ( r , SENSE_CODE ( INVALID_FIELD ) ) ; return 0 ; illegal_lba : scsi_check_condition ( r , SENSE_CODE ( LBA_OUT_OF_RANGE ) ) ; return 0 ; } if ( r -> sector_count == 0 && r -> iov . iov_len == 0 ) { scsi_req_complete ( & r -> req , GOOD ) ; } len = r -> sector_count * 512 + r -> iov . iov_len ; if ( r -> req . cmd . mode == SCSI_XFER_TO_DEV ) { return - len ; } else { if ( ! r -> sector_count ) r -> sector_count = - 1 ; return len ; } } "," uint8_t command ; int rc ; [ 0 ] ; DPRINTF ( scsi_disk_emulate_command ( r ) ; if ",bonzini@qemu/7285477ab11831b1cf56e45878a89170dd06d9b9,CVE-2011-3346,https://github.com/bonzini/qemu/commit/7285477ab11831b1cf56e45878a89170dd06d9b9,2014-04-01T06:35Z 925,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 926,CWE-125,"CWE-125 static int matchCurrentInput ( const InString * input , int pos , const widechar * passInstructions , int passIC ) { int k ; int kk = pos ; for ( k = passIC + 2 ; k < passIC + 2 + passInstructions [ passIC + 1 ] ; k ++ ) if ( input -> chars [ kk ] == ENDSEGMENT || passInstructions [ k ] != input -> chars [ kk ++ ] ) return 0 ; return 1 ; } "," + 2 ; ( ( + 1 ] ) && ( kk < input -> length ) ) ",liblouis@liblouis/5e4089659bb49b3095fa541fa6387b4c40d7396e,CVE-2018-17294,https://github.com/liblouis/liblouis/commit/5e4089659bb49b3095fa541fa6387b4c40d7396e,2018-09-21T07:29Z 927,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 ; int tlen , lmp_obj_len , lmp_obj_ctype , obj_tlen ; int hexdump ; int offset , subobj_type , subobj_len , total_subobj_len ; 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 ) ) ; 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 ; if ( lmp_obj_len % 4 || lmp_obj_len < 4 ) return ; 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 ) ) ; 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 : 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 : 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 : 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 : 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 : ND_PRINT ( ( ndo , ""\\n\\tMessageID:%u(0x%08x)"" , EXTRACT_32BITS ( obj_tptr ) , EXTRACT_32BITS ( obj_tptr ) ) ) ; break ; case LMP_CTYPE_2 : 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 : 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 : 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 : 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 : ND_PRINT ( ( ndo , ""\\n\\tFlags:[%s]"" , bittok2str ( lmp_obj_te_link_flag_values , ""none"" , EXTRACT_16BITS ( obj_tptr ) >> 8 ) ) ) ; switch ( lmp_obj_ctype ) { case LMP_CTYPE_IPV4 : 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 : case LMP_CTYPE_UNMD : default : hexdump = TRUE ; } break ; case LMP_OBJ_DATA_LINK : ND_PRINT ( ( ndo , ""\\n\\tFlags:[%s]"" , bittok2str ( lmp_obj_data_link_flag_values , ""none"" , EXTRACT_16BITS ( obj_tptr ) >> 8 ) ) ) ; switch ( lmp_obj_ctype ) { case LMP_CTYPE_IPV4 : case LMP_CTYPE_UNMD : 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 ) ) ) ; total_subobj_len = lmp_obj_len - 16 ; offset = 12 ; while ( total_subobj_len > 0 && hexdump == FALSE ) { subobj_type = EXTRACT_16BITS ( obj_tptr + offset ) >> 8 ; subobj_len = EXTRACT_16BITS ( obj_tptr + offset ) & 0x00FF ; ND_PRINT ( ( ndo , ""\\n\\tSubobject,Type:%s(%u),Length:%u"" , tok2str ( lmp_data_link_subobj , ""Unknown"" , subobj_type ) , subobj_type , subobj_len ) ) ; switch ( subobj_type ) { case INT_SWITCHING_TYPE_SUBOBJ : ND_PRINT ( ( ndo , ""\\n\\tSwitchingType:%s(%u)"" , tok2str ( gmpls_switch_cap_values , ""Unknown"" , EXTRACT_16BITS ( obj_tptr + offset + 2 ) >> 8 ) , EXTRACT_16BITS ( obj_tptr + offset + 2 ) >> 8 ) ) ; ND_PRINT ( ( ndo , ""\\n\\tEncodingType:%s(%u)"" , tok2str ( gmpls_encoding_values , ""Unknown"" , EXTRACT_16BITS ( obj_tptr + offset + 2 ) & 0x00FF ) , EXTRACT_16BITS ( obj_tptr + offset + 2 ) & 0x00FF ) ) ; bw . i = EXTRACT_32BITS ( obj_tptr + offset + 4 ) ; ND_PRINT ( ( ndo , ""\\n\\tMinReservableBandwidth:%.3fMbps"" , bw . f * 8 / 1000000 ) ) ; bw . i = EXTRACT_32BITS ( obj_tptr + offset + 8 ) ; ND_PRINT ( ( ndo , ""\\n\\tMaxReservableBandwidth:%.3fMbps"" , bw . f * 8 / 1000000 ) ) ; break ; case WAVELENGTH_SUBOBJ : ND_PRINT ( ( ndo , ""\\n\\tWavelength:%u"" , EXTRACT_32BITS ( obj_tptr + offset + 4 ) ) ) ; break ; default : hexdump = TRUE ; break ; } total_subobj_len -= subobj_len ; offset += subobj_len ; } break ; case LMP_CTYPE_IPV6 : default : hexdump = TRUE ; } break ; case LMP_OBJ_VERIFY_BEGIN : switch ( lmp_obj_ctype ) { case LMP_CTYPE_1 : 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 : 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 : 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 : case LMP_CTYPE_UNMD : offset = 0 ; while ( offset < ( lmp_obj_len - ( int ) sizeof ( struct lmp_object_header ) ) ) { 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 : default : hexdump = TRUE ; } break ; case LMP_OBJ_CHANNEL_STATUS_REQ : switch ( lmp_obj_ctype ) { case LMP_CTYPE_IPV4 : case LMP_CTYPE_UNMD : offset = 0 ; while ( offset < ( lmp_obj_len - ( int ) sizeof ( struct lmp_object_header ) ) ) { 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 : default : hexdump = TRUE ; } break ; case LMP_OBJ_ERROR_CODE : switch ( lmp_obj_ctype ) { case LMP_CTYPE_BEGIN_VERIFY_ERROR : 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 : 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 : ND_PRINT ( ( ndo , ""\\n\\tFlags:%s"" , bittok2str ( lmp_obj_service_config_sp_flag_values , ""none"" , EXTRACT_16BITS ( obj_tptr ) >> 8 ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\tUNIVersion:%u"" , EXTRACT_16BITS ( obj_tptr ) & 0x00FF ) ) ; break ; case LMP_CTYPE_SERVICE_CONFIG_CPSA : link_type = EXTRACT_16BITS ( obj_tptr ) >> 8 ; ND_PRINT ( ( ndo , ""\\n\\tLinkType:%s(%u)"" , tok2str ( lmp_sd_service_config_cpsa_link_type_values , ""Unknown"" , link_type ) , link_type ) ) ; if ( link_type == 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_16BITS ( obj_tptr ) & 0x00FF ) , EXTRACT_16BITS ( obj_tptr ) & 0x00FF ) ) ; } if ( link_type == 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_16BITS ( obj_tptr ) & 0x00FF ) , EXTRACT_16BITS ( obj_tptr ) & 0x00FF ) ) ; } ND_PRINT ( ( ndo , ""\\n\\tTransparency:%s"" , bittok2str ( lmp_obj_service_config_cpsa_tp_flag_values , ""none"" , EXTRACT_16BITS ( obj_tptr + 2 ) >> 8 ) ) ) ; ND_PRINT ( ( ndo , ""\\n\\tContiguousConcatenationTypes:%s"" , bittok2str ( lmp_obj_service_config_cpsa_cct_flag_values , ""none"" , EXTRACT_16BITS ( obj_tptr + 2 ) >> 8 & 0x00FF ) ) ) ; 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 : 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_16BITS ( obj_tptr + 6 ) & 0x00FF ) ) ) ; break ; case LMP_CTYPE_SERVICE_CONFIG_NETWORK_DIVERSITY : ND_PRINT ( ( ndo , ""\\n\\tDiversity:Flags:%s"" , bittok2str ( lmp_obj_service_config_nsa_network_diversity_flag_values , ""none"" , EXTRACT_16BITS ( obj_tptr + 2 ) & 0x00FF ) ) ) ; 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"" ) ) ; } "," * obj_tptr ; u_int tlen , lmp_obj_len int hexdump ; u_int offset ; u_int link_type ; union ) ) ; if ( tlen < sizeof ( const struct lmp_common_header ) ) { ND_PRINT ( ( ndo , ""(tooshort)"" ) ) ; return ; } if ( tlen > len ) { ND_PRINT ( ( ndo , ""(toolong)"" ) ) ; tlen = len ; } & 0x7f ; ND_PRINT ( ( ) ) ; if ( lmp_obj_len < 4 ) { ND_PRINT ( ( ndo , ""(tooshort)"" ) ) ; return ; } if ( ( lmp_obj_len % 4 ) != 0 ) { ND_PRINT ( ( ndo , ""(notamultipleof4)"" ) ) ; return ; } case LMP_CTYPE_RMT : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } case LMP_CTYPE_IPV4_RMT : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } case LMP_CTYPE_IPV6_RMT : if ( obj_tlen != 16 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } case LMP_CTYPE_UNMD_RMT : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } case LMP_CTYPE_1 : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } case LMP_CTYPE_2 : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } case LMP_CTYPE_RMT : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } case LMP_CTYPE_HELLO_CONFIG : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } case LMP_CTYPE_HELLO : if ( obj_tlen != 8 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } case LMP_OBJ_TE_LINK : switch ( lmp_obj_ctype ) { case LMP_CTYPE_IPV4 : if ( obj_tlen != 12 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } , ""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 ( ( ""\\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 ; break ; default : hexdump case LMP_OBJ_DATA_LINK : switch ( lmp_obj_ctype ) { case LMP_CTYPE_IPV4 : if ( obj_tlen < 12 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } , ""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"" , ( 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 ( obj_tptr + 10 ) , EXTRACT_16BITS ( obj_tptr ( obj_tptr + 10 ) , EXTRACT_16BITS ( obj_tptr + 10 ) & 8000 ? ""(Payloadtestmessagescapable)"" : """" ) ) ; ( obj_tptr + 12 ) ; ND_PRINT ( ( ndo , ""\\n\\tTransmissionRate:%.3fMbps"" , bw . f ) ) ; ND_PRINT ( ( ndo , ""\\n\\tWavelength:%u"" , EXTRACT_32BITS ( obj_tptr + 16 ) ) ) = 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 break ; case LMP_OBJ_VERIFY_ID : switch ( case LMP_CTYPE_1 : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } ND_PRINT ( ( ndo , ""\\n\\tVerifyID:%u"" , EXTRACT_32BITS ( obj_tptr ) ) ) break ; case LMP_OBJ_CHANNEL_STATUS : switch ( ) { 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 break ; case LMP_OBJ_CHANNEL_STATUS_REQ : switch ( ) { 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 break ; case LMP_OBJ_ERROR_CODE : switch ( ) { 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 break ; case LMP_OBJ_SERVICE_CONFIG : switch ( ) { case LMP_CTYPE_SERVICE_CONFIG_SP : if ( obj_tlen != 4 ) { ND_PRINT ( ( ndo , ""(notcorrectforobject)"" ) ) ; break ; } ND_PRINT ( ( ndo , ""\\n\\tFlags:%s"" , bittok2str ( , bittok2str ( lmp_obj_service_config_sp_flag_values , ""none"" , , ""none"" , EXTRACT_8BITS ( obj_tptr ) ) ) ) , ""\\n\\tUNIVersion:%u"" , EXTRACT_8BITS ( obj_tptr + 1 ) ) ) ; 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 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 ( , bittok2str ( lmp_obj_service_config_nsa_network_diversity_flag_values , ""none"" , , ""none"" , EXTRACT_8BITS ( obj_tptr + 3 ) ) ) ) ",the-tcpdump-group@tcpdump/a25211918f2e790c67d859d20ccf8dbb81da1598,CVE-2017-13003,https://github.com/the-tcpdump-group/tcpdump/commit/a25211918f2e790c67d859d20ccf8dbb81da1598,2017-09-14T06:29Z 928,CWE-189,"CWE-189 static void findoprnd ( ITEM * ptr , int32 * pos ) { if ( ptr [ * pos ] . type == VAL || ptr [ * pos ] . type == VALTRUE ) { ptr [ * pos ] . left = 0 ; ( * pos ) ++ ; } else if ( ptr [ * pos ] . val == ( int32 ) '!' ) { ptr [ * pos ] . left = 1 ; ( * pos ) ++ ; findoprnd ( ptr , pos ) ; } else { ITEM * curitem = & ptr [ * pos ] ; int32 tmp = * pos ; ( * pos ) ++ ; findoprnd ( ptr , pos ) ; curitem -> left = * pos - tmp ; findoprnd ( ptr , pos ) ; } } "," pos ) { check_stack_depth ( ) ; ",postgres@postgres/31400a673325147e1205326008e32135a78b4d8a,CVE-2014-2669,https://github.com/postgres/postgres/commit/31400a673325147e1205326008e32135a78b4d8a,2014-03-31T14:58Z 929,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,2016-09-17T21:59Z 930,CWE-000,"CWE-000 static int mct_u232_port_probe ( struct usb_serial_port * port ) { struct mct_u232_private * priv ; priv = kzalloc ( sizeof ( * priv ) , GFP_KERNEL ) ; if ( ! priv ) return - ENOMEM ; priv -> read_urb = port -> serial -> port [ 1 ] -> interrupt_in_urb ; priv -> read_urb -> context = port ; spin_lock_init ( & priv -> lock ) ; usb_set_serial_port_data ( port , priv ) ; return 0 ; } "," ) { struct usb_serial * serial = port -> serial ; struct * priv ; if ( ! serial -> port [ 1 ] || ! serial -> port [ 1 ] -> interrupt_in_urb ) { dev_err ( & port -> dev , ""expectedendpointmissing\\n"" ) ; return - ENODEV ; } -> read_urb = serial -> port ",torvalds@linux/4e9a0b05257f29cf4b75f3209243ed71614d062e,CVE-2016-3136,https://github.com/torvalds/linux/commit/4e9a0b05257f29cf4b75f3209243ed71614d062e,2016-05-02T10:59Z 931,CWE-399,"CWE-399 static netdev_tx_t veth_xmit ( struct sk_buff * skb , struct net_device * dev ) { struct net_device * rcv = NULL ; struct veth_priv * priv , * rcv_priv ; struct veth_net_stats * stats , * rcv_stats ; int length ; priv = netdev_priv ( dev ) ; rcv = priv -> peer ; rcv_priv = netdev_priv ( rcv ) ; stats = this_cpu_ptr ( priv -> stats ) ; rcv_stats = this_cpu_ptr ( rcv_priv -> stats ) ; if ( ! ( rcv -> flags & IFF_UP ) ) goto tx_drop ; if ( dev -> features & NETIF_F_NO_CSUM ) skb -> ip_summed = rcv_priv -> ip_summed ; length = skb -> len + ETH_HLEN ; if ( dev_forward_skb ( rcv , skb ) != NET_RX_SUCCESS ) goto rx_drop ; stats -> tx_bytes += length ; stats -> tx_packets ++ ; rcv_stats -> rx_bytes += length ; rcv_stats -> rx_packets ++ ; return NETDEV_TX_OK ; tx_drop : kfree_skb ( skb ) ; stats -> tx_dropped ++ ; return NETDEV_TX_OK ; rx_drop : kfree_skb ( skb ) ; rcv_stats -> rx_dropped ++ ; return NETDEV_TX_OK ; } "," ; rx_drop : rcv_stats -> rx_dropped ",torvalds@linux/6ec82562ffc6f297d0de36d65776cff8e5704867,CVE-2013-2017,https://github.com/torvalds/linux/commit/6ec82562ffc6f297d0de36d65776cff8e5704867,2013-05-03T11:57Z 932,CWE-119,"CWE-119 int ParseRiffHeaderConfig ( FILE * infile , char * infilename , char * fourcc , WavpackContext * wpc , WavpackConfig * config ) { int is_rf64 = ! strncmp ( fourcc , ""RF64"" , 4 ) , got_ds64 = 0 ; int64_t total_samples = 0 , infilesize ; RiffChunkHeader riff_chunk_header ; ChunkHeader chunk_header ; WaveHeader WaveHeader ; DS64Chunk ds64_chunk ; uint32_t bcount ; CLEAR ( WaveHeader ) ; CLEAR ( ds64_chunk ) ; infilesize = DoGetFileSize ( infile ) ; if ( ! is_rf64 && infilesize >= 4294967296LL && ! ( config -> qmode & QMODE_IGNORE_LENGTH ) ) { error_line ( ""can\'thandle.WAVfileslargerthan4GB(non-standard)!"" ) ; return WAVPACK_SOFT_ERROR ; } memcpy ( & riff_chunk_header , fourcc , 4 ) ; if ( ( ! DoReadFile ( infile , ( ( char * ) & riff_chunk_header ) + 4 , sizeof ( RiffChunkHeader ) - 4 , & bcount ) || bcount != sizeof ( RiffChunkHeader ) - 4 || strncmp ( riff_chunk_header . formType , ""WAVE"" , 4 ) ) ) { error_line ( ""%sisnotavalid.WAVfile!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & riff_chunk_header , sizeof ( RiffChunkHeader ) ) ) { error_line ( ""%s"" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } while ( 1 ) { if ( ! DoReadFile ( infile , & chunk_header , sizeof ( ChunkHeader ) , & bcount ) || bcount != sizeof ( ChunkHeader ) ) { error_line ( ""%sisnotavalid.WAVfile!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & chunk_header , sizeof ( ChunkHeader ) ) ) { error_line ( ""%s"" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } WavpackLittleEndianToNative ( & chunk_header , ChunkHeaderFormat ) ; if ( ! strncmp ( chunk_header . ckID , ""ds64"" , 4 ) ) { if ( chunk_header . ckSize < sizeof ( DS64Chunk ) || ! DoReadFile ( infile , & ds64_chunk , sizeof ( DS64Chunk ) , & bcount ) || bcount != sizeof ( DS64Chunk ) ) { error_line ( ""%sisnotavalid.WAVfile!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & ds64_chunk , sizeof ( DS64Chunk ) ) ) { error_line ( ""%s"" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } got_ds64 = 1 ; WavpackLittleEndianToNative ( & ds64_chunk , DS64ChunkFormat ) ; if ( debug_logging_mode ) error_line ( ""DS64:riffSize=%lld,dataSize=%lld,sampleCount=%lld,table_length=%d"" , ( long long ) ds64_chunk . riffSize64 , ( long long ) ds64_chunk . dataSize64 , ( long long ) ds64_chunk . sampleCount64 , ds64_chunk . tableLength ) ; if ( ds64_chunk . tableLength * sizeof ( CS64Chunk ) != chunk_header . ckSize - sizeof ( DS64Chunk ) ) { error_line ( ""%sisnotavalid.WAVfile!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } while ( ds64_chunk . tableLength -- ) { CS64Chunk cs64_chunk ; if ( ! DoReadFile ( infile , & cs64_chunk , sizeof ( CS64Chunk ) , & bcount ) || bcount != sizeof ( CS64Chunk ) || ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & cs64_chunk , sizeof ( CS64Chunk ) ) ) ) { error_line ( ""%s"" , WavpackGetErrorMessage ( wpc ) ) ; return WAVPACK_SOFT_ERROR ; } } } else if ( ! strncmp ( chunk_header . ckID , ""fmt"" , 4 ) ) { int supported = TRUE , format ; if ( chunk_header . ckSize < 16 || chunk_header . ckSize > sizeof ( WaveHeader ) || ! DoReadFile ( infile , & WaveHeader , chunk_header . ckSize , & bcount ) || bcount != chunk_header . ckSize ) { error_line ( ""%sisnotavalid.WAVfile!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } else if ( ! ( config -> qmode & QMODE_NO_STORE_WRAPPER ) && ! WavpackAddWrapper ( wpc , & WaveHeader , 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.WAVformat!"" , 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 ( ""thisWAVfilealreadyhaschannelorderinformation!"" ) ; 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 if ( config -> float_norm_exp ) error_line ( ""dataformat:32-bitfloatingpoint(Audition%d:%dfloattype1)"" , config -> float_norm_exp - 126 , 150 - config -> float_norm_exp ) ; else error_line ( ""dataformat:%d-bitintegersstoredin%dbyte(s)"" , config -> bits_per_sample , WaveHeader . BlockAlign / WaveHeader . NumChannels ) ; } } else if ( ! strncmp ( chunk_header . ckID , ""data"" , 4 ) ) { int64_t data_chunk_size = ( got_ds64 && chunk_header . ckSize == ( uint32_t ) - 1 ) ? ds64_chunk . dataSize64 : chunk_header . ckSize ; if ( ! WaveHeader . NumChannels || ( is_rf64 && ! got_ds64 ) ) { error_line ( ""%sisnotavalid.WAVfile!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } if ( infilesize && ! ( config -> qmode & QMODE_IGNORE_LENGTH ) && infilesize - data_chunk_size > 16777216 ) { error_line ( ""this.WAVfilehasover16MBofextraRIFFdata,probablyiscorrupt!"" ) ; return WAVPACK_SOFT_ERROR ; } if ( config -> qmode & QMODE_IGNORE_LENGTH ) { if ( infilesize && DoGetFilePosition ( infile ) != - 1 ) total_samples = ( infilesize - DoGetFilePosition ( infile ) ) / WaveHeader . BlockAlign ; else total_samples = - 1 ; } else { total_samples = data_chunk_size / WaveHeader . BlockAlign ; if ( got_ds64 && total_samples != ds64_chunk . sampleCount64 ) { error_line ( ""%sisnotavalid.WAVfile!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } if ( ! total_samples ) { error_line ( ""this.WAVfilehasnoaudiosamples,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 + 1 ) & ~ 1L ; char * buff ; if ( bytes_to_copy < 0 || bytes_to_copy > 4194304 ) { error_line ( ""%sisnotavalid.WAVfile!"" , 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 ; } "," ) , got_ds64 = 0 , format_chunk , format ; if ( format_chunk ++ ) { error_line ( ""%sisnotavalid.WAVfile!"" , infilename ) ; return WAVPACK_SOFT_ERROR ; } ",dbry@WavPack/26cb47f99d481ad9b93eeff80d26e6b63bbd7e15,CVE-2018-10537,https://github.com/dbry/WavPack/commit/26cb47f99d481ad9b93eeff80d26e6b63bbd7e15,2018-04-29T15:29Z 933,CWE-264,"CWE-264 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 934,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 935,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 936,CWE-190,"CWE-190 static int setupLookaside ( sqlite3 * db , void * pBuf , int sz , int cnt ) { # ifndef SQLITE_OMIT_LOOKASIDE void * pStart ; if ( sqlite3LookasideUsed ( db , 0 ) > 0 ) { return SQLITE_BUSY ; } if ( db -> lookaside . bMalloced ) { sqlite3_free ( db -> lookaside . pStart ) ; } sz = ROUNDDOWN8 ( sz ) ; if ( sz <= ( int ) sizeof ( LookasideSlot * ) ) sz = 0 ; if ( cnt < 0 ) cnt = 0 ; if ( sz == 0 || cnt == 0 ) { sz = 0 ; pStart = 0 ; } else if ( pBuf == 0 ) { sqlite3BeginBenignMalloc ( ) ; pStart = sqlite3Malloc ( sz * cnt ) ; sqlite3EndBenignMalloc ( ) ; if ( pStart ) cnt = sqlite3MallocSize ( pStart ) / sz ; } else { pStart = pBuf ; } db -> lookaside . pStart = pStart ; db -> lookaside . pInit = 0 ; db -> lookaside . pFree = 0 ; db -> lookaside . sz = ( u16 ) sz ; if ( pStart ) { int i ; LookasideSlot * p ; assert ( sz > ( int ) sizeof ( LookasideSlot * ) ) ; db -> lookaside . nSlot = cnt ; p = ( LookasideSlot * ) pStart ; for ( i = cnt - 1 ; i >= 0 ; i -- ) { p -> pNext = db -> lookaside . pInit ; db -> lookaside . pInit = p ; p = ( LookasideSlot * ) & ( ( u8 * ) p ) [ sz ] ; } db -> lookaside . pEnd = p ; db -> lookaside . bDisable = 0 ; db -> lookaside . bMalloced = pBuf == 0 ? 1 : 0 ; } else { db -> lookaside . pStart = db ; db -> lookaside . pEnd = db ; db -> lookaside . bDisable = 1 ; db -> lookaside . bMalloced = 0 ; db -> lookaside . nSlot = 0 ; } # endif return SQLITE_OK ; } "," ( sz * ( sqlite3_int64 ) ",chromium@chromium/517ac71c9ee27f856f9becde8abea7d1604af9d4,CVE-2019-5827,https://github.com/chromium/chromium/commit/517ac71c9ee27f856f9becde8abea7d1604af9d4,2019-06-27T17:15Z 937,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 938,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 939,CWE-416,"CWE-416 static int ipxitf_ioctl ( unsigned int cmd , void __user * arg ) { int rc = - EINVAL ; struct ifreq ifr ; int val ; switch ( cmd ) { case SIOCSIFADDR : { struct sockaddr_ipx * sipx ; struct ipx_interface_definition f ; rc = - EFAULT ; if ( copy_from_user ( & ifr , arg , sizeof ( ifr ) ) ) break ; sipx = ( struct sockaddr_ipx * ) & ifr . ifr_addr ; rc = - EINVAL ; if ( sipx -> sipx_family != AF_IPX ) break ; f . ipx_network = sipx -> sipx_network ; memcpy ( f . ipx_device , ifr . ifr_name , sizeof ( f . ipx_device ) ) ; memcpy ( f . ipx_node , sipx -> sipx_node , IPX_NODE_LEN ) ; f . ipx_dlink_type = sipx -> sipx_type ; f . ipx_special = sipx -> sipx_special ; if ( sipx -> sipx_action == IPX_DLTITF ) rc = ipxitf_delete ( & f ) ; else rc = ipxitf_create ( & f ) ; break ; } case SIOCGIFADDR : { struct sockaddr_ipx * sipx ; struct ipx_interface * ipxif ; struct net_device * dev ; rc = - EFAULT ; if ( copy_from_user ( & ifr , arg , sizeof ( ifr ) ) ) break ; sipx = ( struct sockaddr_ipx * ) & ifr . ifr_addr ; dev = __dev_get_by_name ( & init_net , ifr . ifr_name ) ; rc = - ENODEV ; if ( ! dev ) break ; ipxif = ipxitf_find_using_phys ( dev , ipx_map_frame_type ( sipx -> sipx_type ) ) ; rc = - EADDRNOTAVAIL ; if ( ! ipxif ) break ; sipx -> sipx_family = AF_IPX ; sipx -> sipx_network = ipxif -> if_netnum ; memcpy ( sipx -> sipx_node , ipxif -> if_node , sizeof ( sipx -> sipx_node ) ) ; rc = - EFAULT ; if ( copy_to_user ( arg , & ifr , sizeof ( ifr ) ) ) break ; ipxitf_put ( ipxif ) ; rc = 0 ; break ; } case SIOCAIPXITFCRT : rc = - EFAULT ; if ( get_user ( val , ( unsigned char __user * ) arg ) ) break ; rc = 0 ; ipxcfg_auto_create_interfaces = val ; break ; case SIOCAIPXPRISLT : rc = - EFAULT ; if ( get_user ( val , ( unsigned char __user * ) arg ) ) break ; rc = 0 ; ipxcfg_set_auto_select ( val ) ; break ; } return rc ; } "," ; rc = 0 ; if ( copy_to_user ( arg , & ifr , sizeof ( ifr ) ) ) rc = - EFAULT ; ipxitf_put ( ipxif ( ipxif ) ; break ; ",torvalds@linux/ee0d8d8482345ff97a75a7d747efc309f13b0d80,CVE-2017-7487,https://github.com/torvalds/linux/commit/ee0d8d8482345ff97a75a7d747efc309f13b0d80,2017-05-14T22:29Z 940,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 941,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 942,CWE-119,"CWE-119 static int decode_cblk ( Jpeg2000DecoderContext * s , Jpeg2000CodingStyle * codsty , Jpeg2000T1Context * t1 , Jpeg2000Cblk * cblk , int width , int height , int bandpos ) { int passno = cblk -> npasses , pass_t = 2 , bpno = cblk -> nonzerobits - 1 , y ; int clnpass_cnt = 0 ; int bpass_csty_symbol = codsty -> cblk_style & JPEG2000_CBLK_BYPASS ; int vert_causal_ctx_csty_symbol = codsty -> cblk_style & JPEG2000_CBLK_VSC ; for ( y = 0 ; y < height ; y ++ ) memset ( t1 -> data [ y ] , 0 , width * sizeof ( * * t1 -> data ) ) ; if ( ! cblk -> length ) return 0 ; for ( y = 0 ; y < height + 2 ; y ++ ) memset ( t1 -> flags [ y ] , 0 , ( width + 2 ) * sizeof ( * * t1 -> flags ) ) ; cblk -> data [ cblk -> length ] = 0xff ; cblk -> data [ cblk -> length + 1 ] = 0xff ; ff_mqc_initdec ( & t1 -> mqc , cblk -> data ) ; while ( passno -- ) { switch ( pass_t ) { case 0 : decode_sigpass ( t1 , width , height , bpno + 1 , bandpos , bpass_csty_symbol && ( clnpass_cnt >= 4 ) , vert_causal_ctx_csty_symbol ) ; break ; case 1 : decode_refpass ( t1 , width , height , bpno + 1 ) ; if ( bpass_csty_symbol && clnpass_cnt >= 4 ) ff_mqc_initdec ( & t1 -> mqc , cblk -> data ) ; break ; case 2 : decode_clnpass ( s , t1 , width , height , bpno + 1 , bandpos , codsty -> cblk_style & JPEG2000_CBLK_SEGSYM , vert_causal_ctx_csty_symbol ) ; clnpass_cnt = clnpass_cnt + 1 ; if ( bpass_csty_symbol && clnpass_cnt >= 4 ) ff_mqc_initdec ( & t1 -> mqc , cblk -> data ) ; break ; } pass_t ++ ; if ( pass_t == 3 ) { bpno -- ; pass_t = 0 ; } } return 0 ; } "," cblk_style & JPEG2000_CBLK_VSC ; av_assert0 ( width <= JPEG2000_MAX_CBLKW ) ; av_assert0 ( height <= JPEG2000_MAX_CBLKH ) ",FFmpeg@FFmpeg/9a271a9368eaabf99e6c2046103acb33957e63b7,CVE-2013-7018,https://github.com/FFmpeg/FFmpeg/commit/9a271a9368eaabf99e6c2046103acb33957e63b7,2013-12-09T16:36Z 943,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 944,CWE-119,"CWE-119 static __forceinline void draw_line ( float * output , int x0 , int y0 , int x1 , int y1 , int n ) { int dy = y1 - y0 ; int adx = x1 - x0 ; int ady = abs ( dy ) ; int base ; int x = x0 , y = y0 ; int err = 0 ; int sy ; # ifdef STB_VORBIS_DIVIDE_TABLE if ( adx < DIVTAB_DENOM && ady < DIVTAB_NUMER ) { if ( dy < 0 ) { base = - integer_divide_table [ ady ] [ adx ] ; sy = base - 1 ; } else { base = integer_divide_table [ ady ] [ adx ] ; sy = base + 1 ; } } else { base = dy / adx ; if ( dy < 0 ) sy = base - 1 ; else sy = base + 1 ; } # else base = dy / adx ; if ( dy < 0 ) sy = base - 1 ; else sy = base + 1 ; # endif ady -= abs ( base ) * adx ; if ( x1 > n ) x1 = n ; if ( x < x1 ) { LINE_OP ( output [ x ] , inverse_db_table [ y ] ) ; for ( ++ x ; x < x1 ; ++ x ) { err += ady ; if ( err >= adx ) { err -= adx ; y += sy ; } else y += base ; LINE_OP ( output [ x ] , inverse_db_table [ y ] ) ; } } } "," inverse_db_table [ y & 255 inverse_db_table [ y & 255 ",nothings@stb/98fdfc6df88b1e34a736d5e126e6c8139c8de1a6,CVE-2019-13217,https://github.com/nothings/stb/commit/98fdfc6df88b1e34a736d5e126e6c8139c8de1a6,2019-08-15T17:15Z 945,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 946,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 947,CWE-476,"CWE-476 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 ; if ( q >= end ) return 0 ; 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 ; } "," ONIG_INFINITE_DISTANCE ) { if ( p - str < reg -> dmax ) { * low = ( UChar * ) str ; if ( low_prev ) * low_prev = onigenc_get_prev_char_head ( reg -> enc , str , * low ) ; } else { low ) ; } ",kkos@oniguruma/b690371bbf97794b4a1d3f295d4fb9a8b05d402d,CVE-2017-9229,https://github.com/kkos/oniguruma/commit/b690371bbf97794b4a1d3f295d4fb9a8b05d402d,2017-05-24T15:29Z 948,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 949,CWE-190,"CWE-190 int amqp_handle_input ( amqp_connection_state_t state , amqp_bytes_t received_data , amqp_frame_t * decoded_frame ) { size_t bytes_consumed ; void * raw_frame ; decoded_frame -> frame_type = 0 ; if ( received_data . len == 0 ) { return AMQP_STATUS_OK ; } if ( state -> state == CONNECTION_STATE_IDLE ) { state -> state = CONNECTION_STATE_HEADER ; } bytes_consumed = consume_data ( state , & received_data ) ; if ( state -> inbound_offset < state -> target_size ) { return ( int ) bytes_consumed ; } raw_frame = state -> inbound_buffer . bytes ; switch ( state -> state ) { case CONNECTION_STATE_INITIAL : if ( memcmp ( raw_frame , ""AMQP"" , 4 ) == 0 ) { decoded_frame -> frame_type = AMQP_PSEUDOFRAME_PROTOCOL_HEADER ; decoded_frame -> channel = 0 ; decoded_frame -> payload . protocol_header . transport_high = amqp_d8 ( amqp_offset ( raw_frame , 4 ) ) ; decoded_frame -> payload . protocol_header . transport_low = amqp_d8 ( amqp_offset ( raw_frame , 5 ) ) ; decoded_frame -> payload . protocol_header . protocol_version_major = amqp_d8 ( amqp_offset ( raw_frame , 6 ) ) ; decoded_frame -> payload . protocol_header . protocol_version_minor = amqp_d8 ( amqp_offset ( raw_frame , 7 ) ) ; return_to_idle ( state ) ; return ( int ) bytes_consumed ; } case CONNECTION_STATE_HEADER : { amqp_channel_t channel ; amqp_pool_t * channel_pool ; channel = amqp_d16 ( amqp_offset ( raw_frame , 1 ) ) ; state -> target_size = amqp_d32 ( amqp_offset ( raw_frame , 3 ) ) + HEADER_SIZE + FOOTER_SIZE ; if ( ( size_t ) state -> frame_max < state -> target_size ) { return AMQP_STATUS_BAD_AMQP_DATA ; } channel_pool = amqp_get_or_create_channel_pool ( state , channel ) ; if ( NULL == channel_pool ) { return AMQP_STATUS_NO_MEMORY ; } amqp_pool_alloc_bytes ( channel_pool , state -> target_size , & state -> inbound_buffer ) ; if ( NULL == state -> inbound_buffer . bytes ) { return AMQP_STATUS_NO_MEMORY ; } memcpy ( state -> inbound_buffer . bytes , state -> header_buffer , HEADER_SIZE ) ; raw_frame = state -> inbound_buffer . bytes ; state -> state = CONNECTION_STATE_BODY ; bytes_consumed += consume_data ( state , & received_data ) ; if ( state -> inbound_offset < state -> target_size ) { return ( int ) bytes_consumed ; } } case CONNECTION_STATE_BODY : { amqp_bytes_t encoded ; int res ; amqp_pool_t * channel_pool ; if ( amqp_d8 ( amqp_offset ( raw_frame , state -> target_size - 1 ) ) != AMQP_FRAME_END ) { return AMQP_STATUS_BAD_AMQP_DATA ; } decoded_frame -> frame_type = amqp_d8 ( amqp_offset ( raw_frame , 0 ) ) ; decoded_frame -> channel = amqp_d16 ( amqp_offset ( raw_frame , 1 ) ) ; channel_pool = amqp_get_or_create_channel_pool ( state , decoded_frame -> channel ) ; if ( NULL == channel_pool ) { return AMQP_STATUS_NO_MEMORY ; } switch ( decoded_frame -> frame_type ) { case AMQP_FRAME_METHOD : decoded_frame -> payload . method . id = amqp_d32 ( amqp_offset ( raw_frame , HEADER_SIZE ) ) ; encoded . bytes = amqp_offset ( raw_frame , HEADER_SIZE + 4 ) ; encoded . len = state -> target_size - HEADER_SIZE - 4 - FOOTER_SIZE ; res = amqp_decode_method ( decoded_frame -> payload . method . id , channel_pool , encoded , & decoded_frame -> payload . method . decoded ) ; if ( res < 0 ) { return res ; } break ; case AMQP_FRAME_HEADER : decoded_frame -> payload . properties . class_id = amqp_d16 ( amqp_offset ( raw_frame , HEADER_SIZE ) ) ; decoded_frame -> payload . properties . body_size = amqp_d64 ( amqp_offset ( raw_frame , HEADER_SIZE + 4 ) ) ; encoded . bytes = amqp_offset ( raw_frame , HEADER_SIZE + 12 ) ; encoded . len = state -> target_size - HEADER_SIZE - 12 - FOOTER_SIZE ; decoded_frame -> payload . properties . raw = encoded ; res = amqp_decode_properties ( decoded_frame -> payload . properties . class_id , channel_pool , encoded , & decoded_frame -> payload . properties . decoded ) ; if ( res < 0 ) { return res ; } break ; case AMQP_FRAME_BODY : decoded_frame -> payload . body_fragment . len = state -> target_size - HEADER_SIZE - FOOTER_SIZE ; decoded_frame -> payload . body_fragment . bytes = amqp_offset ( raw_frame , HEADER_SIZE ) ; break ; case AMQP_FRAME_HEARTBEAT : break ; default : decoded_frame -> frame_type = 0 ; break ; } return_to_idle ( state ) ; return ( int ) bytes_consumed ; } default : amqp_abort ( ""Internalerror:invalidamqp_connection_state_t->state%d"" , state -> state ) ; } } "," * channel_pool ; uint32_t frame_size ; ) ) ; frame_size = amqp_d32 ( amqp_offset ( raw_frame , 3 ) ) ; if ( frame_size >= INT32_MAX ) { return AMQP_STATUS_BAD_AMQP_DATA ; } -> target_size = frame_size + HEADER_SIZE + ",alanxz@rabbitmq-c/fc85be7123050b91b054e45b91c78d3241a5047a,CVE-2019-18609,https://github.com/alanxz/rabbitmq-c/commit/fc85be7123050b91b054e45b91c78d3241a5047a,2019-12-01T22:15Z 950,CWE-125,"CWE-125 static void file_add_mapi_attrs ( File * file , MAPI_Attr * * attrs ) { int i ; for ( i = 0 ; attrs [ i ] ; i ++ ) { MAPI_Attr * a = attrs [ i ] ; if ( a -> num_values ) { switch ( a -> name ) { case MAPI_ATTACH_LONG_FILENAME : if ( file -> name ) XFREE ( file -> name ) ; file -> name = strdup ( ( char * ) a -> values [ 0 ] . data . buf ) ; break ; case MAPI_ATTACH_DATA_OBJ : file -> len = a -> values [ 0 ] . len ; if ( file -> data ) XFREE ( file -> data ) ; file -> data = CHECKED_XMALLOC ( unsigned char , file -> len ) ; memmove ( file -> data , a -> values [ 0 ] . data . buf , file -> len ) ; break ; case MAPI_ATTACH_MIME_TAG : if ( file -> mime_type ) XFREE ( file -> mime_type ) ; file -> mime_type = CHECKED_XMALLOC ( char , a -> values [ 0 ] . len ) ; memmove ( file -> mime_type , a -> values [ 0 ] . data . buf , a -> values [ 0 ] . len ) ; break ; case MAPI_ATTACH_CONTENT_ID : if ( file -> content_id ) XFREE ( file -> content_id ) ; file -> content_id = CHECKED_XMALLOC ( char , a -> values [ 0 ] . len ) ; memmove ( file -> content_id , a -> values [ 0 ] . data . buf , a -> values [ 0 ] . len ) ; break ; default : break ; } } } } "," case MAPI_ATTACH_LONG_FILENAME : assert ( a -> type == szMAPI_STRING ) ; case MAPI_ATTACH_DATA_OBJ : assert ( ( a -> type == szMAPI_BINARY ) || ( a -> type == szMAPI_OBJECT ) ) ; case MAPI_ATTACH_MIME_TAG : assert ( a -> type == szMAPI_STRING ) ; case MAPI_ATTACH_CONTENT_ID : assert ( a -> type == szMAPI_STRING ) ; ",verdammelt@tnef/8dccf79857ceeb7a6d3e42c1e762e7b865d5344d,CVE-2017-6310,https://github.com/verdammelt/tnef/commit/8dccf79857ceeb7a6d3e42c1e762e7b865d5344d,2017-02-24T04:59Z 951,CWE-476,"CWE-476 static bool LookupModMask ( struct xkb_context * ctx , const void * priv , xkb_atom_t field , enum expr_value_type type , xkb_mod_mask_t * val_rtrn ) { const char * str ; xkb_mod_index_t ndx ; const LookupModMaskPriv * arg = priv ; const struct xkb_mod_set * mods = arg -> mods ; enum mod_type mod_type = arg -> mod_type ; if ( type != EXPR_TYPE_INT ) return false ; str = xkb_atom_text ( ctx , field ) ; if ( istreq ( str , ""all"" ) ) { * val_rtrn = MOD_REAL_MASK_ALL ; return true ; } if ( istreq ( str , ""none"" ) ) { * val_rtrn = 0 ; return true ; } ndx = XkbModNameToIndex ( mods , field , mod_type ) ; if ( ndx == XKB_MOD_INVALID ) return false ; * val_rtrn = ( 1u << ndx ) ; return true ; } "," ; if ( ! str ) return false ; if ( ",xkbcommon@libxkbcommon/4e2ee9c3f6050d773f8bbe05bc0edb17f1ff8371,CVE-2018-15862,https://github.com/xkbcommon/libxkbcommon/commit/4e2ee9c3f6050d773f8bbe05bc0edb17f1ff8371,2018-08-25T21:29Z 952,CWE-770,"CWE-770 WORD32 ihevcd_create ( iv_obj_t * ps_codec_obj , void * pv_api_ip , void * pv_api_op ) { ihevcd_cxa_create_op_t * ps_create_op ; WORD32 ret ; codec_t * ps_codec ; ps_create_op = ( ihevcd_cxa_create_op_t * ) pv_api_op ; ps_create_op -> s_ivd_create_op_t . u4_error_code = 0 ; ret = ihevcd_allocate_static_bufs ( & ps_codec_obj , pv_api_ip , pv_api_op ) ; if ( ( IV_FAIL == ret ) && ( NULL != ps_codec_obj ) ) { ihevcd_free_static_bufs ( ps_codec_obj ) ; ps_create_op -> s_ivd_create_op_t . u4_error_code = IVD_MEM_ALLOC_FAILED ; ps_create_op -> s_ivd_create_op_t . u4_error_code = 1 << IVD_FATALERROR ; return IV_FAIL ; } ps_codec = ( codec_t * ) ps_codec_obj -> pv_codec_handle ; ret = ihevcd_init ( ps_codec ) ; TRACE_INIT ( NULL ) ; STATS_INIT ( ) ; return ret ; } "," pv_api_op ) { ihevcd_cxa_create_ip_t * ps_create_ip ; * ps_codec ; ps_create_ip = ( ihevcd_cxa_create_ip_t * ) pv_api_ip ; = 0 ; ps_codec_obj = NULL ; ) ; if ( IV_FAIL == == ret ) { if ( NULL != != ps_codec_obj ) { if ( ps_codec_obj -> pv_codec_handle ps_codec_obj ) ; } else { void ( * pf_aligned_free ) ( void * pv_mem_ctxt , void * pv_buf ) ; void * pv_mem_ctxt ; pf_aligned_free = ps_create_ip -> s_ivd_create_ip_t . pf_aligned_free ; pv_mem_ctxt = ps_create_ip -> s_ivd_create_ip_t . pv_mem_ctxt ; pf_aligned_free ( pv_mem_ctxt , ps_codec_obj ) ; } } ",external@libhevc/3ed3c6b79a7b9a60c475dd4936ad57b0b92fd600,CVE-2017-13190,https://android.googlesource.com/platform/external/libhevc/+/3ed3c6b79a7b9a60c475dd4936ad57b0b92fd600,2018-01-12T23:29Z 953,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 954,CWE-190,"CWE-190 void * checked_xcalloc ( size_t num , size_t size ) { alloc_limit_assert ( ""checked_xcalloc"" , ( num * size ) ) ; return xcalloc ( num , size ) ; } "," size ) { size_t res ; if ( check_mul_overflow ( num , size , & res ) ) abort ( ) ; ""checked_xcalloc"" , ( res ) ) ; ",verdammelt@tnef/c5044689e50039635e7700fe2472fd632ac77176,CVE-2017-6308,https://github.com/verdammelt/tnef/commit/c5044689e50039635e7700fe2472fd632ac77176,2017-02-24T04:59Z 955,CWE-119,"CWE-119 static int read_public_key ( RSA * rsa ) { int r ; sc_path_t path ; sc_file_t * file ; u8 buf [ 2048 ] , * p = buf ; size_t bufsize , keysize ; r = select_app_df ( ) ; if ( r ) return 1 ; sc_format_path ( ""I1012"" , & path ) ; r = sc_select_file ( card , & path , & file ) ; if ( r ) { fprintf ( stderr , ""Unabletoselectpublickeyfile:%s\\n"" , sc_strerror ( r ) ) ; return 2 ; } bufsize = file -> size ; sc_file_free ( file ) ; r = sc_read_binary ( card , 0 , buf , bufsize , 0 ) ; if ( r < 0 ) { fprintf ( stderr , ""Unabletoreadpublickeyfile:%s\\n"" , sc_strerror ( r ) ) ; return 2 ; } bufsize = r ; do { if ( bufsize < 4 ) return 3 ; keysize = ( p [ 0 ] << 8 ) | p [ 1 ] ; if ( keysize == 0 ) break ; if ( keysize < 3 ) return 3 ; if ( p [ 2 ] == opt_key_num ) break ; p += keysize ; bufsize -= keysize ; } while ( 1 ) ; if ( keysize == 0 ) { printf ( ""Keynumber%dnotfound.\\n"" , opt_key_num ) ; return 2 ; } return parse_public_key ( p , keysize , rsa ) ; } "," } bufsize = MIN ( file -> size , sizeof buf ) ",OpenSC@OpenSC/360e95d45ac4123255a4c796db96337f332160ad,CVE-2018-16391,https://github.com/OpenSC/OpenSC/commit/360e95d45ac4123255a4c796db96337f332160ad#diff-477b7a40136bb418b10ce271c8664536,2018-09-03T14:29Z 956,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 957,CWE-399,"CWE-399 static int simulate_llsc ( struct pt_regs * regs , unsigned int opcode ) { if ( ( opcode & OPCODE ) == LL ) { perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , 0 ) ; return simulate_ll ( regs , opcode ) ; } if ( ( opcode & OPCODE ) == SC ) { perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , 0 ) ; return simulate_sc ( regs , opcode ) ; } return - 1 ; } "," PERF_COUNT_SW_EMULATION_FAULTS , 1 , regs , , 1 , regs , 0 ",torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,CVE-2011-2918,https://github.com/torvalds/linux/commit/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,2012-05-24T23:55Z 958,CWE-863,"CWE-863 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 959,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 960,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 961,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 962,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 963,CWE-000,"CWE-000 int fit_check_format ( const void * fit , ulong size ) { int ret ; ret = fdt_check_header ( fit ) ; if ( ret ) { log_debug ( ""WrongFITformat:notaflatteneddevicetree(err=%d)\\n"" , ret ) ; return - ENOEXEC ; } if ( CONFIG_IS_ENABLED ( FIT_FULL_CHECK ) ) { if ( size == IMAGE_SIZE_INVAL ) size = fdt_totalsize ( fit ) ; ret = fdt_check_full ( fit , size ) ; if ( ret ) { log_debug ( ""FITcheckerror%d\\n"" , ret ) ; return - EINVAL ; } } if ( ! fdt_getprop ( fit , 0 , FIT_DESC_PROP , NULL ) ) { log_debug ( ""WrongFITformat:nodescription\\n"" ) ; return - ENOMSG ; } if ( IMAGE_ENABLE_TIMESTAMP ) { if ( ! fdt_getprop ( fit , 0 , FIT_TIMESTAMP_PROP , NULL ) ) { log_debug ( ""WrongFITformat:notimestamp\\n"" ) ; return - ENODATA ; } } if ( fdt_path_offset ( fit , FIT_IMAGES_PATH ) < 0 ) { log_debug ( ""WrongFITformat:noimagesparentnode\\n"" ) ; return - ENOENT ; } return 0 ; } "," ( ret ) ret = - EINVAL ; if ( ! ret && CONFIG_IS_ENABLED ( FIT_SIGNATURE ) ) { ret = fdt_check_no_at ( fit , 0 ) ; if ( ret ) ) ; return ret ; } } if ( ret ) { log_debug ( ""FITcheckerror%d\\n"" , ret ) ; return ret ; } } ",u-boot@u-boot/3f04db891a353f4b127ed57279279f851c6b4917,CVE-2021-27138,https://github.com/u-boot/u-boot/commit/3f04db891a353f4b127ed57279279f851c6b4917,2021-02-17T23:15Z 964,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 965,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 966,CWE-787,"CWE-787 static int bmpr_read_rle ( struct iwbmprcontext * rctx ) { int retval = 0 ; if ( ! ( rctx -> compression == IWBMP_BI_RLE8 && rctx -> bitcount == 8 ) && ! ( rctx -> compression == IWBMP_BI_RLE4 && rctx -> bitcount == 4 ) ) { iw_set_error ( rctx -> ctx , ""Compressiontypeincompatiblewithimagetype"" ) ; } if ( rctx -> topdown ) { iw_set_error ( rctx -> ctx , ""Compressionnotallowedwithtop-downimages"" ) ; } rctx -> img -> imgtype = IW_IMGTYPE_RGBA ; rctx -> img -> bit_depth = 8 ; rctx -> img -> bpr = iw_calc_bytesperrow ( rctx -> width , 32 ) ; rctx -> img -> pixels = ( iw_byte * ) iw_malloc_large ( rctx -> ctx , rctx -> img -> bpr , rctx -> img -> height ) ; if ( ! rctx -> img -> pixels ) goto done ; if ( ! bmpr_read_rle_internal ( rctx ) ) goto done ; if ( ! bmpr_has_transparency ( rctx -> img ) ) { bmpr_strip_alpha ( rctx -> img ) ; } retval = 1 ; done : return retval ; } "," ""Compressiontypeincompatiblewithimagetype"" ) ; goto done ; , ""Compressionnotallowedwithtop-downimages"" ) ; goto done ",jsummers@imageworsener/a4f247707f08e322f0b41e82c3e06e224240a654,CVE-2017-9203,https://github.com/jsummers/imageworsener/commit/a4f247707f08e322f0b41e82c3e06e224240a654,2017-05-23T04:29Z 967,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 968,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 969,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 970,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 ) ; } } "," ioc ) ; } ) ; } ",torvalds@linux/61cc74fbb87af6aa551a06a370590c9bc07e29d9,CVE-2012-0879,https://github.com/torvalds/linux/commit/61cc74fbb87af6aa551a06a370590c9bc07e29d9,2012-05-17T11:00Z 971,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 972,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 973,CWE-000,"CWE-000 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 ( ps_dec -> ps_cur_slice -> u1_mbaff_frame_flag && ( num_mb_skip & 1 ) ) { num_mb_skip ++ ; } 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 = - 1 ; for ( i = 0 ; i < MAX_NUM_PIC_PARAMS ; i ++ ) { if ( ps_dec -> ps_pps [ i ] . u1_is_valid == TRUE ) { if ( ps_dec -> ps_pps [ i ] . ps_sps -> u1_is_valid == TRUE ) { j = i ; break ; } } } if ( j == - 1 ) { return ERROR_INV_SLICE_HDR_T ; } if ( ps_dec -> u4_pic_buf_got == 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 ; } } } ps_dec -> u4_first_slice_in_pic = 0 ; } 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 ) { if ( ( u1_mbaff ) && ( ps_dec -> u4_num_mbs_cur_nmb & 1 ) ) { ps_dec -> u4_num_mbs_cur_nmb = ps_dec -> u4_num_mbs_cur_nmb - 1 ; ps_dec -> u2_cur_mb_addr -- ; } 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 ; } 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 ; if ( u1_num_mbs ) { 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 ( 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 ; } if ( ps_dec -> ps_parse_cur_slice -> u4_first_mb_in_slice < ( UWORD32 ) ( ps_dec -> u2_total_mbs_coded >> ps_slice -> u1_mbaff_frame_flag ) ) { ps_dec -> i2_prev_slice_mbx = ps_dec -> u2_mbx ; ps_dec -> i2_prev_slice_mby = ps_dec -> u2_mby ; ps_dec -> u2_cur_slice_num ++ ; 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 = MIN ( MAX_FRAMES , ps_dec -> u4_num_ref_frames_at_init ) ; num_entries = 2 * ( ( 2 * num_entries ) + 1 ) ; 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 -> u2_mbx = ( MOD ( ps_dec -> ps_cur_slice -> u2_first_mb_in_slice - 1 , ps_dec -> u2_frm_wd_in_mbs ) ) ; ps_dec -> u2_mby = ( DIV ( ps_dec -> ps_cur_slice -> u2_first_mb_in_slice - 1 , ps_dec -> u2_frm_wd_in_mbs ) ) ; ps_dec -> u2_mby <<= u1_mbaff ; 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 ) ; if ( ps_dec -> u4_first_slice_in_pic != 0 ) { ps_dec -> ps_parse_cur_slice ++ ; 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 ; 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 ; } "," WORD32 ret ; UNUSED ( u1_is_idr_slice ) ; = u2_frame_num ; { WORD32 i ",external@libavc/494561291a503840f385fbcd11d9bc5f4dc502b8,CVE-2017-0551,https://android.googlesource.com/platform/external/libavc/+/494561291a503840f385fbcd11d9bc5f4dc502b8,2017-04-07T22:59Z 974,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 975,CWE-125,"CWE-125 static inline struct enamemem * lookup_bytestring ( netdissect_options * ndo , register const u_char * bs , const unsigned int nlen ) { struct enamemem * tp ; register u_int i , j , k ; if ( nlen >= 6 ) { k = ( bs [ 0 ] << 8 ) | bs [ 1 ] ; j = ( bs [ 2 ] << 8 ) | bs [ 3 ] ; i = ( bs [ 4 ] << 8 ) | bs [ 5 ] ; } else if ( nlen >= 4 ) { k = ( bs [ 0 ] << 8 ) | bs [ 1 ] ; j = ( bs [ 2 ] << 8 ) | bs [ 3 ] ; i = 0 ; } else i = j = k = 0 ; tp = & bytestringtable [ ( i ^ j ) & ( HASHNAMESIZE - 1 ) ] ; while ( tp -> e_nxt ) if ( tp -> e_addr0 == i && tp -> e_addr1 == j && tp -> e_addr2 == k && memcmp ( ( const char * ) bs , ( const char * ) ( tp -> e_bs ) , nlen ) == 0 ) return tp ; else tp = tp -> e_nxt ; tp -> e_addr0 = i ; tp -> e_addr1 = j ; tp -> e_addr2 = k ; tp -> e_bs = ( u_char * ) calloc ( 1 , nlen + 1 ) ; if ( tp -> e_bs == NULL ) ( * ndo -> ndo_error ) ( ndo , ""lookup_bytestring:calloc"" ) ; memcpy ( tp -> e_bs , bs , nlen ) ; tp -> e_nxt = ( struct enamemem * ) calloc ( 1 , sizeof ( * tp ) ) ; if ( tp -> e_nxt == NULL ) ( * ndo -> ndo_error ) ( ndo , ""lookup_bytestring:calloc"" ) ; return tp ; } "," static inline struct bsnamemem * lookup_bytestring ( ) { struct bsnamemem * tp ; ( tp -> bs_nxt ) if ( nlen == tp -> bs_nbytes && tp -> && tp -> bs_addr0 == i && tp -> && tp -> bs_addr1 == j && tp -> bs_addr2 == k && ( tp -> bs_bytes ) , nlen = tp -> bs_nxt ; tp -> bs_addr0 = i ; tp -> bs_addr1 = j ; tp -> bs_addr2 = k ; tp -> bs_bytes = ( u_char ( tp -> bs_bytes == NULL ) ( tp -> bs_bytes , bs , nlen ) ; tp -> bs_nbytes = nlen ; tp -> bs_nxt = ( struct = ( struct bsnamemem * ) calloc ( tp -> bs_nxt == NULL ) ",the-tcpdump-group@tcpdump/730fc35968c5433b9e2a829779057f4f9495dc51,CVE-2017-12894,https://github.com/the-tcpdump-group/tcpdump/commit/730fc35968c5433b9e2a829779057f4f9495dc51,2017-09-14T06:29Z 976,CWE-119,"CWE-119 void vp9_iht4x4_add ( TX_TYPE tx_type , const int16_t * input , uint8_t * dest , int stride , int eob ) { if ( tx_type == DCT_DCT ) vp9_idct4x4_add ( input , dest , stride , eob ) ; else vp9_iht4x4_16_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 977,CWE-787,"CWE-787 char * rfbProcessFileTransferReadBuffer ( rfbClientPtr cl , uint32_t length ) { char * buffer = NULL ; int n = 0 ; FILEXFER_ALLOWED_OR_CLOSE_AND_RETURN ( """" , cl , NULL ) ; if ( length > 0 ) { buffer = malloc ( ( uint64_t ) length + 1 ) ; if ( buffer != NULL ) { if ( ( n = rfbReadExact ( cl , ( char * ) buffer , length ) ) <= 0 ) { if ( n != 0 ) rfbLogPerror ( ""rfbProcessFileTransferReadBuffer:read"" ) ; rfbCloseClient ( cl ) ; if ( buffer != NULL ) free ( buffer ) ; return NULL ; } buffer [ length ] = 0 ; } } return buffer ; } "," if ( length == SIZE_MAX ) { rfbErr ( ""rfbProcessFileTransferReadBuffer:toobigfiletransferlengthrequested:%u"" , ( unsigned int ) length ) ; rfbCloseClient ( cl ) ; return NULL ; } if ( length malloc ( ( size_t ) length + ",LibVNC@libvncserver/15bb719c03cc70f14c36a843dcb16ed69b405707,CVE-2018-20749,https://github.com/LibVNC/libvncserver/commit/15bb719c03cc70f14c36a843dcb16ed69b405707,2019-01-30T18:29Z 978,CWE-362,"CWE-362 static int mptctl_do_reset ( unsigned long arg ) { struct mpt_ioctl_diag_reset __user * urinfo = ( void __user * ) arg ; struct mpt_ioctl_diag_reset krinfo ; MPT_ADAPTER * iocp ; if ( copy_from_user ( & krinfo , urinfo , sizeof ( struct mpt_ioctl_diag_reset ) ) ) { printk ( KERN_ERR MYNAM ""%s@%d::mptctl_do_reset-"" ""Unabletocopympt_ioctl_diag_resetstruct@%p\\n"" , __FILE__ , __LINE__ , urinfo ) ; return - EFAULT ; } if ( mpt_verify_adapter ( krinfo . hdr . iocnum , & iocp ) < 0 ) { printk ( KERN_DEBUG MYNAM ""%s@%d::mptctl_do_reset-ioc%dnotfound!\\n"" , __FILE__ , __LINE__ , krinfo . hdr . iocnum ) ; return - ENODEV ; } dctlprintk ( iocp , printk ( MYIOC_s_DEBUG_FMT ""mptctl_do_resetcalled.\\n"" , iocp -> name ) ) ; if ( mpt_HardResetHandler ( iocp , CAN_SLEEP ) != 0 ) { printk ( MYIOC_s_ERR_FMT ""%s@%d::mptctl_do_reset-resetfailed.\\n"" , iocp -> name , __FILE__ , __LINE__ ) ; return - 1 ; } return 0 ; } "," int mptctl_do_reset ( MPT_ADAPTER * iocp , struct mpt_ioctl_diag_reset krinfo ; if ( return - EFAULT ; } dctlprintk ",torvalds@linux/28d76df18f0ad5bcf5fa48510b225f0ed262a99b,CVE-2020-12652,https://github.com/torvalds/linux/commit/28d76df18f0ad5bcf5fa48510b225f0ed262a99b,2020-05-05T05:15Z 979,CWE-125,"CWE-125 int git_delta_apply ( void * * out , size_t * out_len , const unsigned char * base , size_t base_len , const unsigned char * delta , size_t delta_len ) { const unsigned char * delta_end = delta + delta_len ; size_t base_sz , res_sz , alloc_sz ; unsigned char * res_dp ; * out = NULL ; * out_len = 0 ; if ( ( hdr_sz ( & base_sz , & delta , delta_end ) < 0 ) || ( base_sz != base_len ) ) { giterr_set ( GITERR_INVALID , ""failedtoapplydelta:basesizedoesnotmatchgivendata"" ) ; return - 1 ; } if ( hdr_sz ( & res_sz , & delta , delta_end ) < 0 ) { giterr_set ( GITERR_INVALID , ""failedtoapplydelta:basesizedoesnotmatchgivendata"" ) ; return - 1 ; } GITERR_CHECK_ALLOC_ADD ( & alloc_sz , res_sz , 1 ) ; res_dp = git__malloc ( alloc_sz ) ; GITERR_CHECK_ALLOC ( res_dp ) ; res_dp [ res_sz ] = '\\0' ; * out = res_dp ; * out_len = res_sz ; while ( delta < delta_end ) { unsigned char cmd = * delta ++ ; if ( cmd & 0x80 ) { size_t off = 0 , len = 0 ; # define ADD_DELTA ( o , shift ) { if ( delta < delta_end ) ( o ) |= ( ( unsigned ) * delta ++ << shift ) ; else goto fail ; } if ( cmd & 0x01 ) ADD_DELTA ( off , 0UL ) ; if ( cmd & 0x02 ) ADD_DELTA ( off , 8UL ) ; if ( cmd & 0x04 ) ADD_DELTA ( off , 16UL ) ; if ( cmd & 0x08 ) ADD_DELTA ( off , 24UL ) ; if ( cmd & 0x10 ) ADD_DELTA ( len , 0UL ) ; if ( cmd & 0x20 ) ADD_DELTA ( len , 8UL ) ; if ( cmd & 0x40 ) ADD_DELTA ( len , 16UL ) ; if ( ! len ) len = 0x10000 ; # undef ADD_DELTA if ( base_len < off + len || res_sz < len ) goto fail ; memcpy ( res_dp , base + off , len ) ; res_dp += len ; res_sz -= len ; } else if ( cmd ) { if ( delta_end - delta < cmd || res_sz < cmd ) goto fail ; memcpy ( res_dp , delta , cmd ) ; delta += cmd ; res_dp += cmd ; res_sz -= cmd ; } else { goto fail ; } } if ( delta != delta_end || res_sz ) goto fail ; return 0 ; fail : git__free ( * out ) ; * out = NULL ; * out_len = 0 ; giterr_set ( GITERR_INVALID , ""failedtoapplydelta"" ) ; return - 1 ; } "," len = 0 , end ADD_DELTA if ( GIT_ADD_SIZET_OVERFLOW ( & end , off , len ) || base_len < end || res_sz < ",libgit2@libgit2/c1577110467b701dcbcf9439ac225ea851b47d22,CVE-2018-10887,https://github.com/libgit2/libgit2/commit/c1577110467b701dcbcf9439ac225ea851b47d22,2018-07-10T14:29Z 980,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 981,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 982,CWE-78,"CWE-78 static char * construct_command_line ( struct manager_ctx * manager , struct server * server ) { static char cmd [ BUF_SIZE ] ; char * method = manager -> method ; int i ; build_config ( working_dir , server ) ; if ( server -> method ) method = server -> method ; memset ( cmd , 0 , BUF_SIZE ) ; snprintf ( cmd , BUF_SIZE , ""%s-m%s--manager-address%s-f%s/.shadowsocks_%s.pid-c%s/.shadowsocks_%s.conf"" , executable , method , manager -> manager_address , working_dir , server -> port , working_dir , server -> port ) ; if ( manager -> acl != NULL ) { int len = strlen ( cmd ) ; snprintf ( cmd + len , BUF_SIZE - len , ""--acl%s"" , manager -> acl ) ; } if ( manager -> timeout != NULL ) { int len = strlen ( cmd ) ; snprintf ( cmd + len , BUF_SIZE - len , ""-t%s"" , manager -> timeout ) ; } # ifdef HAVE_SETRLIMIT if ( manager -> nofile ) { int len = strlen ( cmd ) ; snprintf ( cmd + len , BUF_SIZE - len , ""-n%d"" , manager -> nofile ) ; } # endif if ( manager -> user != NULL ) { int len = strlen ( cmd ) ; snprintf ( cmd + len , BUF_SIZE - len , ""-a%s"" , manager -> user ) ; } if ( manager -> verbose ) { int len = strlen ( cmd ) ; snprintf ( cmd + len , BUF_SIZE - len , ""-v"" ) ; } if ( server -> mode == NULL && manager -> mode == UDP_ONLY ) { int len = strlen ( cmd ) ; snprintf ( cmd + len , BUF_SIZE - len , ""-U"" ) ; } if ( server -> mode == NULL && manager -> mode == TCP_AND_UDP ) { int len = strlen ( cmd ) ; snprintf ( cmd + len , BUF_SIZE - len , ""-u"" ) ; } if ( server -> fast_open [ 0 ] == 0 && manager -> fast_open ) { int len = strlen ( cmd ) ; snprintf ( cmd + len , BUF_SIZE - len , ""--fast-open"" ) ; } if ( manager -> ipv6first ) { int len = strlen ( cmd ) ; snprintf ( cmd + len , BUF_SIZE - len , ""-6"" ) ; } if ( manager -> mtu ) { int len = strlen ( cmd ) ; snprintf ( cmd + len , BUF_SIZE - len , ""--mtu%d"" , manager -> mtu ) ; } if ( server -> plugin == NULL && manager -> plugin ) { int len = strlen ( cmd ) ; snprintf ( cmd + len , BUF_SIZE - len , ""--plugin\\""%s\\"""" , manager -> plugin ) ; } if ( server -> plugin_opts == NULL && manager -> plugin_opts ) { int len = strlen ( cmd ) ; snprintf ( cmd + len , BUF_SIZE - len , ""--plugin-opts\\""%s\\"""" , manager -> plugin_opts ) ; } for ( i = 0 ; i < manager -> nameserver_num ; i ++ ) { int len = strlen ( cmd ) ; snprintf ( cmd + len , BUF_SIZE - len , ""-d%s"" , manager -> nameservers [ i ] ) ; } for ( i = 0 ; i < manager -> host_num ; i ++ ) { int len = strlen ( cmd ) ; snprintf ( cmd + len , BUF_SIZE - len , ""-s%s"" , manager -> hosts [ i ] ) ; } { int len = strlen ( cmd ) ; snprintf ( cmd + len , BUF_SIZE - len , ""--reuse-port"" ) ; } if ( verbose ) { LOGI ( ""cmd:%s"" , cmd ) ; } return cmd ; } "," BUF_SIZE ] ; int i ; int port ; port = atoi ( server -> port ) ; build_config ( ( working_dir , manager , server ) ; memset ( , BUF_SIZE , ""%s--manager-address%s-f%s/.shadowsocks_%d.pid-c%s/.shadowsocks_%d.conf"" , executable , , executable , manager -> manager_address , working_dir , port , working_dir , working_dir , port ) ; ",shadowsocks@shadowsocks-libev/c67d275803dc6ea22c558d06b1f7ba9f94cd8de3,CVE-2017-15924,https://github.com/shadowsocks/shadowsocks-libev/commit/c67d275803dc6ea22c558d06b1f7ba9f94cd8de3,2017-10-27T16:29Z 983,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 984,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 985,CWE-000,"CWE-000 static void sas_revalidate_domain ( struct work_struct * work ) { int res = 0 ; struct sas_discovery_event * ev = to_sas_discovery_event ( work ) ; struct asd_sas_port * port = ev -> port ; struct sas_ha_struct * ha = port -> ha ; struct domain_device * ddev = port -> port_dev ; mutex_lock ( & ha -> disco_mutex ) ; if ( test_bit ( SAS_HA_ATA_EH_ACTIVE , & ha -> state ) ) { SAS_DPRINTK ( ""REVALIDATIONDEFERREDonport%d,pid:%d\\n"" , port -> id , task_pid_nr ( current ) ) ; goto out ; } clear_bit ( DISCE_REVALIDATE_DOMAIN , & port -> disc . pending ) ; SAS_DPRINTK ( ""REVALIDATINGDOMAINonport%d,pid:%d\\n"" , port -> id , task_pid_nr ( current ) ) ; if ( ddev && ( ddev -> dev_type == SAS_FANOUT_EXPANDER_DEVICE || ddev -> dev_type == SAS_EDGE_EXPANDER_DEVICE ) ) res = sas_ex_revalidate_domain ( ddev ) ; SAS_DPRINTK ( ""doneREVALIDATINGDOMAINonport%d,pid:%d,res0x%x\\n"" , port -> id , task_pid_nr ( current ) , res ) ; out : mutex_unlock ( & ha -> disco_mutex ) ; } "," disco_mutex ) ; sas_destruct_devices ( port ) ; sas_destruct_ports ( port ) ; sas_probe_devices ( port ) ; ",torvalds@linux/0558f33c06bb910e2879e355192227a8e8f0219d,CVE-2017-18232,https://github.com/torvalds/linux/commit/0558f33c06bb910e2879e355192227a8e8f0219d,2018-03-15T04:29Z 986,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 987,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 988,CWE-119,"CWE-119 void vp8dx_bool_decoder_fill ( BOOL_DECODER * br ) { const unsigned char * bufptr = br -> user_buffer ; VP8_BD_VALUE value = br -> value ; int count = br -> count ; int shift = VP8_BD_VALUE_SIZE - 8 - ( count + 8 ) ; size_t bytes_left = br -> user_buffer_end - bufptr ; size_t bits_left = bytes_left * CHAR_BIT ; int x = ( int ) ( shift + CHAR_BIT - bits_left ) ; int loop_end = 0 ; unsigned char decrypted [ sizeof ( VP8_BD_VALUE ) + 1 ] ; if ( br -> decrypt_cb ) { size_t n = bytes_left > sizeof ( decrypted ) ? sizeof ( decrypted ) : bytes_left ; br -> decrypt_cb ( br -> decrypt_state , bufptr , decrypted , ( int ) n ) ; bufptr = decrypted ; } if ( x >= 0 ) { count += VP8_LOTS_OF_BITS ; loop_end = x ; } if ( x < 0 || bits_left ) { while ( shift >= loop_end ) { count += CHAR_BIT ; value |= ( VP8_BD_VALUE ) * bufptr << shift ; ++ bufptr ; ++ br -> user_buffer ; shift -= CHAR_BIT ; } } br -> value = value ; br -> count = count ; } "," = VP8_BD_VALUE_SIZE - CHAR_BIT - ( count ( count + CHAR_BIT ) ; size_t size_t n = MIN ( sizeof ( decrypted ) , bytes_left ) ; br -> ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 989,CWE-20,"CWE-20 error_t coapClientWriteBody ( CoapClientRequest * request , const void * data , size_t length , size_t * written , bool_t last ) { error_t error ; size_t n ; uint32_t value ; uint32_t blockPos ; uint32_t blockSzx ; size_t payloadLen ; const uint8_t * payload ; CoapMessage * requestMsg ; CoapMessage * responseMsg ; CoapCode responseCode ; error = NO_ERROR ; if ( written != NULL ) * written = 0 ; while ( length > 0 || last ) { requestMsg = coapClientGetRequestMessage ( request ) ; error = coapGetUintOption ( requestMsg , COAP_OPT_BLOCK1 , 0 , & value ) ; if ( ! error ) { blockPos = COAP_GET_BLOCK_POS ( value ) ; blockSzx = COAP_GET_BLOCK_SZX ( value ) ; } else { blockPos = 0 ; blockSzx = request -> txBlockSzx ; } error = coapClientGetPayload ( requestMsg , & payload , & payloadLen ) ; if ( error ) break ; if ( length > 0 && payloadLen < COAP_GET_BLOCK_SIZE ( blockSzx ) ) { n = MIN ( length , COAP_GET_BLOCK_SIZE ( blockSzx ) - payloadLen ) ; error = coapClientWritePayload ( requestMsg , data , n ) ; if ( error ) break ; data = ( uint8_t * ) data + n ; length -= n ; if ( written != NULL ) * written += n ; } else { if ( blockPos > 0 || length > 0 || ! last ) { COAP_SET_BLOCK_NUM ( value , blockPos >> ( blockSzx + 4 ) ) ; if ( length == 0 && last ) COAP_SET_BLOCK_M ( value , 0 ) ; else COAP_SET_BLOCK_M ( value , 1 ) ; COAP_SET_BLOCK_SZX ( value , blockSzx ) ; error = coapClientSetUintOption ( requestMsg , COAP_OPT_BLOCK1 , 0 , value ) ; if ( error ) break ; } if ( length == 0 && last ) { if ( request -> rxBlockSzx < COAP_BLOCK_SIZE_RESERVED ) { COAP_SET_BLOCK_NUM ( value , 0 ) ; COAP_SET_BLOCK_M ( value , 0 ) ; COAP_SET_BLOCK_SZX ( value , request -> rxBlockSzx ) ; error = coapClientSetUintOption ( requestMsg , COAP_OPT_BLOCK2 , 0 , value ) ; if ( error ) break ; } } error = coapClientSendRequest ( request , NULL , NULL ) ; if ( error ) break ; responseMsg = coapClientGetResponseMessage ( request ) ; error = coapClientGetResponseCode ( responseMsg , & responseCode ) ; if ( error ) break ; if ( COAP_GET_CODE_CLASS ( responseCode ) != COAP_CODE_CLASS_SUCCESS ) { error = ERROR_INVALID_STATUS ; break ; } if ( blockPos > 0 || length > 0 || ! last ) { error = coapClientGetUintOption ( responseMsg , COAP_OPT_BLOCK1 , 0 , & value ) ; if ( error ) break ; if ( COAP_GET_BLOCK_SZX ( value ) >= COAP_BLOCK_SIZE_RESERVED ) { error = ERROR_FAILURE ; break ; } if ( COAP_GET_BLOCK_POS ( value ) != blockPos ) { error = ERROR_FAILURE ; break ; } if ( blockSzx > COAP_GET_BLOCK_SZX ( value ) ) blockSzx = COAP_GET_BLOCK_SZX ( value ) ; blockPos += COAP_GET_BLOCK_SIZE ( blockSzx ) ; COAP_SET_BLOCK_NUM ( value , blockPos >> ( blockSzx + 4 ) ) ; COAP_SET_BLOCK_SZX ( value , blockSzx ) ; error = coapClientSetUintOption ( requestMsg , COAP_OPT_BLOCK1 , 0 , value ) ; if ( error ) break ; } error = coapClientSetPayload ( requestMsg , NULL , 0 ) ; if ( error ) break ; if ( length == 0 && last ) { error = coapClientDeleteOption ( requestMsg , COAP_OPT_BLOCK1 , 0 ) ; break ; } } } return error ; } "," && last ) { 0 ) ; } else { COAP_SET_BLOCK_M ( value 1 ) ; } ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 990,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 991,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 992,CWE-476,"CWE-476 static int get_endpoints ( struct usbtest_dev * dev , struct usb_interface * intf ) { int tmp ; struct usb_host_interface * alt ; struct usb_host_endpoint * in , * out ; struct usb_host_endpoint * iso_in , * iso_out ; struct usb_host_endpoint * int_in , * int_out ; struct usb_device * udev ; for ( tmp = 0 ; tmp < intf -> num_altsetting ; tmp ++ ) { unsigned ep ; in = out = NULL ; iso_in = iso_out = NULL ; int_in = int_out = NULL ; alt = intf -> altsetting + tmp ; if ( override_alt >= 0 && override_alt != alt -> desc . bAlternateSetting ) continue ; for ( ep = 0 ; ep < alt -> desc . bNumEndpoints ; ep ++ ) { struct usb_host_endpoint * e ; int edi ; e = alt -> endpoint + ep ; edi = usb_endpoint_dir_in ( & e -> desc ) ; switch ( usb_endpoint_type ( & e -> desc ) ) { case USB_ENDPOINT_XFER_BULK : endpoint_update ( edi , & in , & out , e ) ; continue ; case USB_ENDPOINT_XFER_INT : if ( dev -> info -> intr ) endpoint_update ( edi , & int_in , & int_out , e ) ; continue ; case USB_ENDPOINT_XFER_ISOC : if ( dev -> info -> iso ) endpoint_update ( edi , & iso_in , & iso_out , e ) ; default : continue ; } } if ( ( in && out ) || iso_in || iso_out || int_in || int_out ) goto found ; } return - EINVAL ; found : udev = testdev_to_usbdev ( dev ) ; dev -> info -> alt = alt -> desc . bAlternateSetting ; if ( alt -> desc . bAlternateSetting != 0 ) { tmp = usb_set_interface ( udev , alt -> desc . bInterfaceNumber , alt -> desc . bAlternateSetting ) ; if ( tmp < 0 ) return tmp ; } if ( in ) { dev -> in_pipe = usb_rcvbulkpipe ( udev , in -> desc . bEndpointAddress & USB_ENDPOINT_NUMBER_MASK ) ; dev -> out_pipe = usb_sndbulkpipe ( udev , out -> desc . bEndpointAddress & USB_ENDPOINT_NUMBER_MASK ) ; } if ( iso_in ) { dev -> iso_in = & iso_in -> desc ; dev -> in_iso_pipe = usb_rcvisocpipe ( udev , iso_in -> desc . bEndpointAddress & USB_ENDPOINT_NUMBER_MASK ) ; } if ( iso_out ) { dev -> iso_out = & iso_out -> desc ; dev -> out_iso_pipe = usb_sndisocpipe ( udev , iso_out -> desc . bEndpointAddress & USB_ENDPOINT_NUMBER_MASK ) ; } if ( int_in ) { dev -> int_in = & int_in -> desc ; dev -> in_int_pipe = usb_rcvintpipe ( udev , int_in -> desc . bEndpointAddress & USB_ENDPOINT_NUMBER_MASK ) ; } if ( int_out ) { dev -> int_out = & int_out -> desc ; dev -> out_int_pipe = usb_sndintpipe ( udev , int_out -> desc . bEndpointAddress & USB_ENDPOINT_NUMBER_MASK ) ; } return 0 ; } "," ( in ) dev -> in_pipe USB_ENDPOINT_NUMBER_MASK ) ; if ( out ) USB_ENDPOINT_NUMBER_MASK ) ; if ( iso_in ",torvalds@linux/7c80f9e4a588f1925b07134bb2e3689335f6c6d8,CVE-2017-16532,https://github.com/torvalds/linux/commit/7c80f9e4a588f1925b07134bb2e3689335f6c6d8,2017-11-04T01:29Z 993,CWE-787,"CWE-787 static int decode_frame_common ( AVCodecContext * avctx , PNGDecContext * s , AVFrame * p , AVPacket * avpkt ) { AVDictionary * metadata = NULL ; uint32_t tag , length ; int decode_next_dat = 0 ; int ret ; for ( ; ; ) { length = bytestream2_get_bytes_left ( & s -> gb ) ; if ( length <= 0 ) { if ( avctx -> codec_id == AV_CODEC_ID_PNG && avctx -> skip_frame == AVDISCARD_ALL ) { av_frame_set_metadata ( p , metadata ) ; return 0 ; } if ( CONFIG_APNG_DECODER && avctx -> codec_id == AV_CODEC_ID_APNG && length == 0 ) { if ( ! ( s -> state & PNG_IDAT ) ) return 0 ; else goto exit_loop ; } av_log ( avctx , AV_LOG_ERROR , ""%dbytesleft\\n"" , length ) ; if ( s -> state & PNG_ALLIMAGE && avctx -> strict_std_compliance <= FF_COMPLIANCE_NORMAL ) goto exit_loop ; ret = AVERROR_INVALIDDATA ; goto fail ; } length = bytestream2_get_be32 ( & s -> gb ) ; if ( length > 0x7fffffff || length > bytestream2_get_bytes_left ( & s -> gb ) ) { av_log ( avctx , AV_LOG_ERROR , ""chunktoobig\\n"" ) ; ret = AVERROR_INVALIDDATA ; goto fail ; } tag = bytestream2_get_le32 ( & s -> gb ) ; if ( avctx -> debug & FF_DEBUG_STARTCODE ) av_log ( avctx , AV_LOG_DEBUG , ""png:tag=%c%c%c%clength=%u\\n"" , ( tag & 0xff ) , ( ( tag >> 8 ) & 0xff ) , ( ( tag >> 16 ) & 0xff ) , ( ( tag >> 24 ) & 0xff ) , length ) ; if ( avctx -> codec_id == AV_CODEC_ID_PNG && avctx -> skip_frame == AVDISCARD_ALL ) { switch ( tag ) { case MKTAG ( 'I' , 'H' , 'D' , 'R' ) : case MKTAG ( 'p' , 'H' , 'Y' , 's' ) : case MKTAG ( 't' , 'E' , 'X' , 't' ) : case MKTAG ( 'I' , 'D' , 'A' , 'T' ) : case MKTAG ( 't' , 'R' , 'N' , 'S' ) : break ; default : goto skip_tag ; } } switch ( tag ) { case MKTAG ( 'I' , 'H' , 'D' , 'R' ) : if ( ( ret = decode_ihdr_chunk ( avctx , s , length ) ) < 0 ) goto fail ; break ; case MKTAG ( 'p' , 'H' , 'Y' , 's' ) : if ( ( ret = decode_phys_chunk ( avctx , s ) ) < 0 ) goto fail ; break ; case MKTAG ( 'f' , 'c' , 'T' , 'L' ) : if ( ! CONFIG_APNG_DECODER || avctx -> codec_id != AV_CODEC_ID_APNG ) goto skip_tag ; if ( ( ret = decode_fctl_chunk ( avctx , s , length ) ) < 0 ) goto fail ; decode_next_dat = 1 ; break ; case MKTAG ( 'f' , 'd' , 'A' , 'T' ) : if ( ! CONFIG_APNG_DECODER || avctx -> codec_id != AV_CODEC_ID_APNG ) goto skip_tag ; if ( ! decode_next_dat ) { ret = AVERROR_INVALIDDATA ; goto fail ; } bytestream2_get_be32 ( & s -> gb ) ; length -= 4 ; case MKTAG ( 'I' , 'D' , 'A' , 'T' ) : if ( CONFIG_APNG_DECODER && avctx -> codec_id == AV_CODEC_ID_APNG && ! decode_next_dat ) goto skip_tag ; if ( ( ret = decode_idat_chunk ( avctx , s , length , p ) ) < 0 ) goto fail ; break ; case MKTAG ( 'P' , 'L' , 'T' , 'E' ) : if ( decode_plte_chunk ( avctx , s , length ) < 0 ) goto skip_tag ; break ; case MKTAG ( 't' , 'R' , 'N' , 'S' ) : if ( decode_trns_chunk ( avctx , s , length ) < 0 ) goto skip_tag ; break ; case MKTAG ( 't' , 'E' , 'X' , 't' ) : if ( decode_text_chunk ( s , length , 0 , & metadata ) < 0 ) av_log ( avctx , AV_LOG_WARNING , ""BrokentEXtchunk\\n"" ) ; bytestream2_skip ( & s -> gb , length + 4 ) ; break ; case MKTAG ( 'z' , 'T' , 'X' , 't' ) : if ( decode_text_chunk ( s , length , 1 , & metadata ) < 0 ) av_log ( avctx , AV_LOG_WARNING , ""BrokenzTXtchunk\\n"" ) ; bytestream2_skip ( & s -> gb , length + 4 ) ; break ; case MKTAG ( 's' , 'T' , 'E' , 'R' ) : { int mode = bytestream2_get_byte ( & s -> gb ) ; AVStereo3D * stereo3d = av_stereo3d_create_side_data ( p ) ; if ( ! stereo3d ) goto fail ; if ( mode == 0 || mode == 1 ) { stereo3d -> type = AV_STEREO3D_SIDEBYSIDE ; stereo3d -> flags = mode ? 0 : AV_STEREO3D_FLAG_INVERT ; } else { av_log ( avctx , AV_LOG_WARNING , ""UnknownvalueinsTERchunk(%d)\\n"" , mode ) ; } bytestream2_skip ( & s -> gb , 4 ) ; break ; } case MKTAG ( 'I' , 'E' , 'N' , 'D' ) : if ( ! ( s -> state & PNG_ALLIMAGE ) ) av_log ( avctx , AV_LOG_ERROR , ""IENDwithoutallimage\\n"" ) ; if ( ! ( s -> state & ( PNG_ALLIMAGE | PNG_IDAT ) ) ) { ret = AVERROR_INVALIDDATA ; goto fail ; } bytestream2_skip ( & s -> gb , 4 ) ; goto exit_loop ; default : skip_tag : bytestream2_skip ( & s -> gb , length + 4 ) ; break ; } } exit_loop : if ( avctx -> codec_id == AV_CODEC_ID_PNG && avctx -> skip_frame == AVDISCARD_ALL ) { av_frame_set_metadata ( p , metadata ) ; return 0 ; } if ( s -> bits_per_pixel <= 4 ) handle_small_bpp ( s , p ) ; if ( s -> has_trns && s -> color_type != PNG_COLOR_TYPE_PALETTE ) { size_t byte_depth = s -> bit_depth > 8 ? 2 : 1 ; size_t raw_bpp = s -> bpp - byte_depth ; unsigned x , y ; for ( y = 0 ; y < s -> height ; ++ y ) { uint8_t * row = & s -> image_buf [ s -> image_linesize * y ] ; for ( x = s -> width ; x > 0 ; -- x ) { uint8_t * pixel = & row [ s -> bpp * ( x - 1 ) ] ; memmove ( pixel , & row [ raw_bpp * ( x - 1 ) ] , raw_bpp ) ; if ( ! memcmp ( pixel , s -> transparent_color_be , raw_bpp ) ) { memset ( & pixel [ raw_bpp ] , 0 , byte_depth ) ; } else { memset ( & pixel [ raw_bpp ] , 0xff , byte_depth ) ; } } } } if ( s -> last_picture . f -> data [ 0 ] ) { if ( ! ( avpkt -> flags & AV_PKT_FLAG_KEY ) && avctx -> codec_tag != AV_RL32 ( ""MPNG"" ) && s -> last_picture . f -> width == p -> width && s -> last_picture . f -> height == p -> height && s -> last_picture . f -> format == p -> format ) { if ( CONFIG_PNG_DECODER && avctx -> codec_id != AV_CODEC_ID_APNG ) handle_p_frame_png ( s , p ) ; else if ( CONFIG_APNG_DECODER && avctx -> codec_id == AV_CODEC_ID_APNG && ( ret = handle_p_frame_apng ( avctx , s , p ) ) < 0 ) goto fail ; } } ff_thread_report_progress ( & s -> picture , INT_MAX , 0 ) ; ff_thread_report_progress ( & s -> previous_picture , INT_MAX , 0 ) ; av_frame_set_metadata ( p , metadata ) ; metadata = NULL ; return 0 ; fail : av_dict_free ( & metadata ) ; ff_thread_report_progress ( & s -> picture , INT_MAX , 0 ) ; ff_thread_report_progress ( & s -> previous_picture , INT_MAX , 0 ) ; return ret ; } "," , y ; av_assert0 ( s -> bit_depth > 1 ) ; ",FFmpeg@FFmpeg/e477f09d0b3619f3d29173b2cd593e17e2d1978e,CVE-2017-7863,https://github.com/FFmpeg/FFmpeg/commit/e477f09d0b3619f3d29173b2cd593e17e2d1978e,2017-04-14T04:59Z 994,CWE-264,"CWE-264 int user_update ( struct key * key , struct key_preparsed_payload * prep ) { struct user_key_payload * upayload , * zap ; size_t datalen = prep -> datalen ; int ret ; ret = - EINVAL ; if ( datalen <= 0 || datalen > 32767 || ! prep -> data ) goto error ; ret = - ENOMEM ; upayload = kmalloc ( sizeof ( * upayload ) + datalen , GFP_KERNEL ) ; if ( ! upayload ) goto error ; upayload -> datalen = datalen ; memcpy ( upayload -> data , prep -> data , datalen ) ; zap = upayload ; ret = key_payload_reserve ( key , datalen ) ; if ( ret == 0 ) { zap = key -> payload . data [ 0 ] ; rcu_assign_keypointer ( key , upayload ) ; key -> expiry = 0 ; } if ( zap ) kfree_rcu ( zap , rcu ) ; error : return ret ; } "," 0 ) { if ( ! test_bit ( KEY_FLAG_NEGATIVE , & key -> flags ) ) 0 ] ; else zap = NULL ; ",torvalds@linux/096fe9eaea40a17e125569f9e657e34cdb6d73bd,CVE-2015-8539,https://github.com/torvalds/linux/commit/096fe9eaea40a17e125569f9e657e34cdb6d73bd,2016-02-08T03:59Z 995,CWE-415,"CWE-415 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 ( ! 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 ; } "," return - EINVAL ; if ( waitqueue_active ( & asoc -> wait ) ) return - EBUSY ",torvalds@linux/dfcb9f4f99f1e9a49e43398a7bfbf56927544af1,CVE-2017-6353,https://github.com/torvalds/linux/commit/dfcb9f4f99f1e9a49e43398a7bfbf56927544af1,2017-03-01T20:59Z 996,CWE-617,"CWE-617 static krb5_error_code s4u_identify_user ( krb5_context context , krb5_creds * in_creds , krb5_data * subject_cert , krb5_principal * canon_user ) { krb5_error_code code ; krb5_preauthtype ptypes [ 1 ] = { KRB5_PADATA_S4U_X509_USER } ; krb5_creds creds ; int use_master = 0 ; krb5_get_init_creds_opt * opts = NULL ; krb5_principal_data client ; krb5_s4u_userid userid ; * canon_user = NULL ; if ( in_creds -> client == NULL && subject_cert == NULL ) { return EINVAL ; } if ( in_creds -> client != NULL && in_creds -> client -> type != KRB5_NT_ENTERPRISE_PRINCIPAL ) { int anonymous ; anonymous = krb5_principal_compare ( context , in_creds -> client , krb5_anonymous_principal ( ) ) ; return krb5_copy_principal ( context , anonymous ? in_creds -> server : in_creds -> client , canon_user ) ; } memset ( & creds , 0 , sizeof ( creds ) ) ; memset ( & userid , 0 , sizeof ( userid ) ) ; if ( subject_cert != NULL ) userid . subject_cert = * subject_cert ; code = krb5_get_init_creds_opt_alloc ( context , & opts ) ; if ( code != 0 ) goto cleanup ; krb5_get_init_creds_opt_set_tkt_life ( opts , 15 ) ; krb5_get_init_creds_opt_set_renew_life ( opts , 0 ) ; krb5_get_init_creds_opt_set_forwardable ( opts , 0 ) ; krb5_get_init_creds_opt_set_proxiable ( opts , 0 ) ; krb5_get_init_creds_opt_set_canonicalize ( opts , 1 ) ; krb5_get_init_creds_opt_set_preauth_list ( opts , ptypes , 1 ) ; if ( in_creds -> client != NULL ) { client = * in_creds -> client ; client . realm = in_creds -> server -> realm ; } else { client . magic = KV5M_PRINCIPAL ; client . realm = in_creds -> server -> realm ; client . data = NULL ; client . length = 0 ; client . type = KRB5_NT_ENTERPRISE_PRINCIPAL ; } code = k5_get_init_creds ( context , & creds , & client , NULL , NULL , 0 , NULL , opts , krb5_get_as_key_noop , & userid , & use_master , NULL ) ; if ( code == 0 || code == KRB5_PREAUTH_FAILED ) { * canon_user = userid . user ; userid . user = NULL ; code = 0 ; } cleanup : krb5_free_cred_contents ( context , & creds ) ; if ( opts != NULL ) krb5_get_init_creds_opt_free ( context , opts ) ; if ( userid . user != NULL ) krb5_free_principal ( context , userid . user ) ; return code ; } "," ; if ( ! code || code == code == KRB5_PREAUTH_FAILED || code == KRB5KDC_ERR_KEY_EXP ",krb5@krb5/5e6d1796106df8ba6bc1973ee0917c170d929086,CVE-2018-20217,https://github.com/krb5/krb5/commit/5e6d1796106df8ba6bc1973ee0917c170d929086,2018-12-26T21:29Z 997,CWE-362,"CWE-362 static int snd_ctl_elem_user_get ( struct snd_kcontrol * kcontrol , struct snd_ctl_elem_value * ucontrol ) { struct user_element * ue = kcontrol -> private_data ; memcpy ( & ucontrol -> value , ue -> elem_data , ue -> elem_data_size ) ; return 0 ; } "," -> private_data ; mutex_lock ( & ue -> card -> user_ctl_lock ) ; elem_data_size ) ; mutex_unlock ( & ue -> card -> user_ctl_lock ) ; ",torvalds@linux/07f4d9d74a04aa7c72c5dae0ef97565f28f17b92,CVE-2014-4652,https://github.com/torvalds/linux/commit/07f4d9d74a04aa7c72c5dae0ef97565f28f17b92,2014-07-03T04:22Z 998,CWE-264,"CWE-264 int touch ( const char * path ) { return touch_file ( path , false , USEC_INFINITY , UID_INVALID , GID_INVALID , 0 ) ; } "," , GID_INVALID , MODE_INVALID ) ; } ",systemd@systemd/ee735086f8670be1591fa9593e80dd60163a7a2f,CVE-2016-10156,https://github.com/systemd/systemd/commit/ee735086f8670be1591fa9593e80dd60163a7a2f,2017-01-23T07:59Z 999,CWE-000,"CWE-000 static void nfs4_return_incompatible_delegation ( struct inode * inode , mode_t open_flags ) { struct nfs_delegation * delegation ; rcu_read_lock ( ) ; delegation = rcu_dereference ( NFS_I ( inode ) -> delegation ) ; if ( delegation == NULL || ( delegation -> type & open_flags ) == open_flags ) { rcu_read_unlock ( ) ; return ; } rcu_read_unlock ( ) ; nfs_inode_return_delegation ( inode ) ; } "," * inode , fmode_t fmode ) { struct -> type & fmode ) == fmode ) { rcu_read_unlock ",torvalds@linux/dc0b027dfadfcb8a5504f7d8052754bf8d501ab9,CVE-2011-4324,https://github.com/torvalds/linux/commit/dc0b027dfadfcb8a5504f7d8052754bf8d501ab9,2012-06-21T23:55Z 1000,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 1001,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 1002,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 1003,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 1004,CWE-119,"CWE-119 IMPEG2D_ERROR_CODES_T impeg2d_dec_seq_hdr ( dec_state_t * ps_dec ) { stream_t * ps_stream ; ps_stream = & ps_dec -> s_bit_stream ; UWORD16 u2_height ; UWORD16 u2_width ; if ( impeg2d_bit_stream_nxt ( ps_stream , START_CODE_LEN ) != SEQUENCE_HEADER_CODE ) { impeg2d_bit_stream_flush ( ps_stream , START_CODE_LEN ) ; return IMPEG2D_FRM_HDR_START_CODE_NOT_FOUND ; } impeg2d_bit_stream_flush ( ps_stream , START_CODE_LEN ) ; u2_width = impeg2d_bit_stream_get ( ps_stream , 12 ) ; u2_height = impeg2d_bit_stream_get ( ps_stream , 12 ) ; if ( ( u2_width != ps_dec -> u2_horizontal_size ) || ( u2_height != ps_dec -> u2_vertical_size ) ) { if ( 0 == ps_dec -> u2_header_done ) { ps_dec -> u2_horizontal_size = u2_width ; ps_dec -> u2_vertical_size = u2_height ; if ( 0 == ps_dec -> u4_frm_buf_stride ) { ps_dec -> u4_frm_buf_stride = ( UWORD32 ) ( u2_width ) ; } } else { if ( ( u2_width > ps_dec -> u2_create_max_width ) || ( u2_height > ps_dec -> u2_create_max_height ) ) { IMPEG2D_ERROR_CODES_T e_error = IMPEG2D_UNSUPPORTED_DIMENSIONS ; ps_dec -> u2_reinit_max_height = u2_height ; ps_dec -> u2_reinit_max_width = u2_width ; return e_error ; } else { return ( IMPEG2D_ERROR_CODES_T ) IVD_RES_CHANGED ; } } } if ( ( ps_dec -> u2_horizontal_size > ps_dec -> u2_create_max_width ) || ( ps_dec -> u2_vertical_size > ps_dec -> u2_create_max_height ) ) { IMPEG2D_ERROR_CODES_T e_error = IMPEG2D_UNSUPPORTED_DIMENSIONS ; return SET_IVD_FATAL_ERROR ( e_error ) ; } ps_dec -> u2_aspect_ratio_info = impeg2d_bit_stream_get ( ps_stream , 4 ) ; ps_dec -> u2_frame_rate_code = impeg2d_bit_stream_get ( ps_stream , 4 ) ; if ( ps_dec -> u2_frame_rate_code > MPEG2_MAX_FRAME_RATE_CODE ) { return IMPEG2D_FRM_HDR_DECODE_ERR ; } impeg2d_bit_stream_flush ( ps_stream , 18 ) ; GET_MARKER_BIT ( ps_dec , ps_stream ) ; impeg2d_bit_stream_flush ( ps_stream , 11 ) ; if ( impeg2d_bit_stream_get_bit ( ps_stream ) == 1 ) { UWORD16 i ; for ( i = 0 ; i < NUM_PELS_IN_BLOCK ; i ++ ) { ps_dec -> au1_intra_quant_matrix [ gau1_impeg2_inv_scan_zig_zag [ i ] ] = ( UWORD8 ) impeg2d_bit_stream_get ( ps_stream , 8 ) ; } } else { memcpy ( ps_dec -> au1_intra_quant_matrix , gau1_impeg2_intra_quant_matrix_default , NUM_PELS_IN_BLOCK ) ; } if ( impeg2d_bit_stream_get_bit ( ps_stream ) == 1 ) { UWORD16 i ; for ( i = 0 ; i < NUM_PELS_IN_BLOCK ; i ++ ) { ps_dec -> au1_inter_quant_matrix [ gau1_impeg2_inv_scan_zig_zag [ i ] ] = ( UWORD8 ) impeg2d_bit_stream_get ( ps_stream , 8 ) ; } } else { memcpy ( ps_dec -> au1_inter_quant_matrix , gau1_impeg2_inter_quant_matrix_default , NUM_PELS_IN_BLOCK ) ; } impeg2d_next_start_code ( ps_dec ) ; return ( IMPEG2D_ERROR_CODES_T ) IVD_ERROR_NONE ; } "," = IMPEG2D_UNSUPPORTED_DIMENSIONS ; ps_dec -> u2_reinit_max_height = ps_dec -> u2_vertical_size ; ps_dec -> u2_reinit_max_width = ps_dec -> u2_horizontal_size ; return e_error ; } ps_dec ",external@libmpeg2/a86eb798d077b9b25c8f8c77e3c02c2f287c1ce7,CVE-2017-0587,https://android.googlesource.com/platform/external/libmpeg2/+/a86eb798d077b9b25c8f8c77e3c02c2f287c1ce7,2017-05-12T15:29Z 1005,CWE-20,"CWE-20 static zval * * spl_array_get_dimension_ptr_ptr ( int check_inherited , zval * object , zval * offset , int type TSRMLS_DC ) { spl_array_object * intern = ( spl_array_object * ) zend_object_store_get_object ( object TSRMLS_CC ) ; zval * * retval ; char * key ; uint len ; long index ; HashTable * ht = spl_array_get_hash_table ( intern , 0 TSRMLS_CC ) ; if ( ! offset ) { return & EG ( uninitialized_zval_ptr ) ; } if ( ( type == BP_VAR_W || type == BP_VAR_RW ) && ( ht -> nApplyCount > 0 ) ) { zend_error ( E_WARNING , ""ModificationofArrayObjectduringsortingisprohibited"" ) ; return & EG ( error_zval_ptr ) ; ; } switch ( Z_TYPE_P ( offset ) ) { case IS_STRING : key = Z_STRVAL_P ( offset ) ; len = Z_STRLEN_P ( offset ) + 1 ; string_offest : if ( zend_symtable_find ( ht , key , len , ( void * * ) & retval ) == FAILURE ) { switch ( type ) { case BP_VAR_R : zend_error ( E_NOTICE , ""Undefinedindex:%s"" , key ) ; case BP_VAR_UNSET : case BP_VAR_IS : retval = & EG ( uninitialized_zval_ptr ) ; break ; case BP_VAR_RW : zend_error ( E_NOTICE , ""Undefinedindex:%s"" , key ) ; case BP_VAR_W : { zval * value ; ALLOC_INIT_ZVAL ( value ) ; zend_symtable_update ( ht , key , len , ( void * * ) & value , sizeof ( void * ) , ( void * * ) & retval ) ; } } } return retval ; case IS_NULL : key = """" ; len = 1 ; goto string_offest ; case IS_RESOURCE : zend_error ( E_STRICT , ""ResourceID#%ldusedasoffset,castingtointeger(%ld)"" , Z_LVAL_P ( offset ) , Z_LVAL_P ( offset ) ) ; case IS_DOUBLE : case IS_BOOL : case IS_LONG : if ( offset -> type == IS_DOUBLE ) { index = ( long ) Z_DVAL_P ( offset ) ; } else { index = Z_LVAL_P ( offset ) ; } if ( zend_hash_index_find ( ht , index , ( void * * ) & retval ) == FAILURE ) { switch ( type ) { case BP_VAR_R : zend_error ( E_NOTICE , ""Undefinedoffset:%ld"" , index ) ; case BP_VAR_UNSET : case BP_VAR_IS : retval = & EG ( uninitialized_zval_ptr ) ; break ; case BP_VAR_RW : zend_error ( E_NOTICE , ""Undefinedoffset:%ld"" , index ) ; case BP_VAR_W : { zval * value ; ALLOC_INIT_ZVAL ( value ) ; zend_hash_index_update ( ht , index , ( void * * ) & value , sizeof ( void * ) , ( void * * ) & retval ) ; } } } return retval ; default : zend_error ( E_WARNING , ""Illegaloffsettype"" ) ; return ( type == BP_VAR_W || type == BP_VAR_RW ) ? & EG ( error_zval_ptr ) : & EG ( uninitialized_zval_ptr ) ; } } "," ( ! offset || ! ht ",php@php-src/ecb7f58a069be0dec4a6131b6351a761f808f22e,CVE-2016-7417,https://github.com/php/php-src/commit/ecb7f58a069be0dec4a6131b6351a761f808f22e?w=1,2016-09-17T21:59Z 1006,CWE-772,"CWE-772 generic_ret * create_principal_2_svc ( cprinc_arg * arg , struct svc_req * rqstp ) { static generic_ret ret ; char * prime_arg ; gss_buffer_desc client_name , service_name ; OM_uint32 minor_stat ; kadm5_server_handle_t handle ; restriction_t * rp ; const char * errmsg = NULL ; xdr_free ( xdr_generic_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 -> rec . principal , & prime_arg ) ) { ret . code = KADM5_BAD_PRINCIPAL ; goto exit_func ; } if ( CHANGEPW_SERVICE ( rqstp ) || ! kadm5int_acl_check ( handle -> context , rqst2name ( rqstp ) , ACL_ADD , arg -> rec . principal , & rp ) || kadm5int_acl_impose_restrictions ( handle -> context , & arg -> rec , & arg -> mask , rp ) ) { ret . code = KADM5_AUTH_ADD ; log_unauth ( ""kadm5_create_principal"" , prime_arg , & client_name , & service_name , rqstp ) ; } else { ret . code = kadm5_create_principal ( ( void * ) handle , & arg -> rec , arg -> mask , arg -> passwd ) ; if ( ret . code != 0 ) errmsg = krb5_get_error_message ( handle -> context , ret . code ) ; log_done ( ""kadm5_create_principal"" , 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 : gss_release_buffer ( & minor_stat , & client_name ) ; gss_release_buffer ( & minor_stat , & service_name ) ; free_server_handle ( handle ",krb5@krb5/83ed75feba32e46f736fcce0d96a0445f29b96c2,CVE-2015-8631,https://github.com/krb5/krb5/commit/83ed75feba32e46f736fcce0d96a0445f29b96c2,2016-02-13T02:59Z 1007,CWE-190,"CWE-190 static PHP_NAMED_FUNCTION ( zif_zip_entry_read ) { zval * zip_entry ; zend_long len = 0 ; zip_read_rsrc * zr_rsrc ; zend_string * buffer ; int n = 0 ; if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) , ""r|l"" , & zip_entry , & len ) == FAILURE ) { return ; } if ( ( zr_rsrc = ( zip_read_rsrc * ) zend_fetch_resource ( Z_RES_P ( zip_entry ) , le_zip_entry_name , le_zip_entry ) ) == NULL ) { RETURN_FALSE ; } if ( len <= 0 ) { len = 1024 ; } if ( zr_rsrc -> zf ) { buffer = zend_string_alloc ( len , 0 ) ; n = zip_fread ( zr_rsrc -> zf , ZSTR_VAL ( buffer ) , ZSTR_LEN ( buffer ) ) ; if ( n > 0 ) { ZSTR_VAL ( buffer ) [ n ] = '\\0' ; ZSTR_LEN ( buffer ) = n ; RETURN_NEW_STR ( buffer ) ; } else { zend_string_free ( buffer ) ; RETURN_EMPTY_STRING ( ) } } else { RETURN_FALSE ; } } "," { buffer = zend_string_safe_alloc ( 1 , len , 0 , 0 ) ",php@php-src/3b8d4de300854b3517c7acb239b84f7726c1353c,CVE-2016-3078,https://github.com/php/php-src/commit/3b8d4de300854b3517c7acb239b84f7726c1353c?w=1,2016-08-07T10:59Z 1008,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 1009,CWE-19,"CWE-19 static int ext4_fill_super ( struct super_block * sb , void * data , int silent ) { char * orig_data = kstrdup ( data , GFP_KERNEL ) ; struct buffer_head * bh ; struct ext4_super_block * es = NULL ; struct ext4_sb_info * sbi ; ext4_fsblk_t block ; ext4_fsblk_t sb_block = get_sb_block ( & data ) ; ext4_fsblk_t logical_sb_block ; unsigned long offset = 0 ; unsigned long journal_devnum = 0 ; unsigned long def_mount_opts ; struct inode * root ; const char * descr ; int ret = - ENOMEM ; int blocksize , clustersize ; unsigned int db_count ; unsigned int i ; int needs_recovery , has_huge_files , has_bigalloc ; __u64 blocks_count ; int err = 0 ; unsigned int journal_ioprio = DEFAULT_JOURNAL_IOPRIO ; ext4_group_t first_not_zeroed ; sbi = kzalloc ( sizeof ( * sbi ) , GFP_KERNEL ) ; if ( ! sbi ) goto out_free_orig ; sbi -> s_blockgroup_lock = kzalloc ( sizeof ( struct blockgroup_lock ) , GFP_KERNEL ) ; if ( ! sbi -> s_blockgroup_lock ) { kfree ( sbi ) ; goto out_free_orig ; } sb -> s_fs_info = sbi ; sbi -> s_sb = sb ; sbi -> s_inode_readahead_blks = EXT4_DEF_INODE_READAHEAD_BLKS ; sbi -> s_sb_block = sb_block ; if ( sb -> s_bdev -> bd_part ) sbi -> s_sectors_written_start = part_stat_read ( sb -> s_bdev -> bd_part , sectors [ 1 ] ) ; strreplace ( sb -> s_id , '/' , '!' ) ; ret = - EINVAL ; blocksize = sb_min_blocksize ( sb , EXT4_MIN_BLOCK_SIZE ) ; if ( ! blocksize ) { ext4_msg ( sb , KERN_ERR , ""unabletosetblocksize"" ) ; goto out_fail ; } if ( blocksize != EXT4_MIN_BLOCK_SIZE ) { logical_sb_block = sb_block * EXT4_MIN_BLOCK_SIZE ; offset = do_div ( logical_sb_block , blocksize ) ; } else { logical_sb_block = sb_block ; } if ( ! ( bh = sb_bread_unmovable ( sb , logical_sb_block ) ) ) { ext4_msg ( sb , KERN_ERR , ""unabletoreadsuperblock"" ) ; goto out_fail ; } es = ( struct ext4_super_block * ) ( bh -> b_data + offset ) ; sbi -> s_es = es ; sb -> s_magic = le16_to_cpu ( es -> s_magic ) ; if ( sb -> s_magic != EXT4_SUPER_MAGIC ) goto cantfind_ext4 ; sbi -> s_kbytes_written = le64_to_cpu ( es -> s_kbytes_written ) ; if ( ext4_has_feature_metadata_csum ( sb ) && ext4_has_feature_gdt_csum ( sb ) ) ext4_warning ( sb , ""metadata_csumanduninit_bgare"" ""redundantflags;pleaserunfsck."" ) ; if ( ! ext4_verify_csum_type ( sb , es ) ) { ext4_msg ( sb , KERN_ERR , ""VFS:Foundext4filesystemwith"" ""unknownchecksumalgorithm."" ) ; silent = 1 ; goto cantfind_ext4 ; } if ( ext4_has_feature_metadata_csum ( sb ) ) { sbi -> s_chksum_driver = crypto_alloc_shash ( ""crc32c"" , 0 , 0 ) ; if ( IS_ERR ( sbi -> s_chksum_driver ) ) { ext4_msg ( sb , KERN_ERR , ""Cannotloadcrc32cdriver."" ) ; ret = PTR_ERR ( sbi -> s_chksum_driver ) ; sbi -> s_chksum_driver = NULL ; goto failed_mount ; } } if ( ! ext4_superblock_csum_verify ( sb , es ) ) { ext4_msg ( sb , KERN_ERR , ""VFS:Foundext4filesystemwith"" ""invalidsuperblockchecksum.Rune2fsck?"" ) ; silent = 1 ; ret = - EFSBADCRC ; goto cantfind_ext4 ; } if ( ext4_has_feature_csum_seed ( sb ) ) sbi -> s_csum_seed = le32_to_cpu ( es -> s_checksum_seed ) ; else if ( ext4_has_metadata_csum ( sb ) ) sbi -> s_csum_seed = ext4_chksum ( sbi , ~ 0 , es -> s_uuid , sizeof ( es -> s_uuid ) ) ; def_mount_opts = le32_to_cpu ( es -> s_default_mount_opts ) ; set_opt ( sb , INIT_INODE_TABLE ) ; if ( def_mount_opts & EXT4_DEFM_DEBUG ) set_opt ( sb , DEBUG ) ; if ( def_mount_opts & EXT4_DEFM_BSDGROUPS ) set_opt ( sb , GRPID ) ; if ( def_mount_opts & EXT4_DEFM_UID16 ) set_opt ( sb , NO_UID32 ) ; set_opt ( sb , XATTR_USER ) ; # ifdef CONFIG_EXT4_FS_POSIX_ACL set_opt ( sb , POSIX_ACL ) ; # endif if ( ext4_has_metadata_csum ( sb ) ) set_opt ( sb , JOURNAL_CHECKSUM ) ; if ( ( def_mount_opts & EXT4_DEFM_JMODE ) == EXT4_DEFM_JMODE_DATA ) set_opt ( sb , JOURNAL_DATA ) ; else if ( ( def_mount_opts & EXT4_DEFM_JMODE ) == EXT4_DEFM_JMODE_ORDERED ) set_opt ( sb , ORDERED_DATA ) ; else if ( ( def_mount_opts & EXT4_DEFM_JMODE ) == EXT4_DEFM_JMODE_WBACK ) set_opt ( sb , WRITEBACK_DATA ) ; if ( le16_to_cpu ( sbi -> s_es -> s_errors ) == EXT4_ERRORS_PANIC ) set_opt ( sb , ERRORS_PANIC ) ; else if ( le16_to_cpu ( sbi -> s_es -> s_errors ) == EXT4_ERRORS_CONTINUE ) set_opt ( sb , ERRORS_CONT ) ; else set_opt ( sb , ERRORS_RO ) ; set_opt ( sb , BLOCK_VALIDITY ) ; if ( def_mount_opts & EXT4_DEFM_DISCARD ) set_opt ( sb , DISCARD ) ; 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 ) ) ; sbi -> s_commit_interval = JBD2_DEFAULT_MAX_COMMIT_AGE * HZ ; sbi -> s_min_batch_time = EXT4_DEF_MIN_BATCH_TIME ; sbi -> s_max_batch_time = EXT4_DEF_MAX_BATCH_TIME ; if ( ( def_mount_opts & EXT4_DEFM_NOBARRIER ) == 0 ) set_opt ( sb , BARRIER ) ; if ( ! IS_EXT3_SB ( sb ) && ! IS_EXT2_SB ( sb ) && ( ( def_mount_opts & EXT4_DEFM_NODELALLOC ) == 0 ) ) set_opt ( sb , DELALLOC ) ; sbi -> s_li_wait_mult = EXT4_DEF_LI_WAIT_MULT ; if ( ! parse_options ( ( char * ) sbi -> s_es -> s_mount_opts , sb , & journal_devnum , & journal_ioprio , 0 ) ) { ext4_msg ( sb , KERN_WARNING , ""failedtoparseoptionsinsuperblock:%s"" , sbi -> s_es -> s_mount_opts ) ; } sbi -> s_def_mount_opt = sbi -> s_mount_opt ; if ( ! parse_options ( ( char * ) data , sb , & journal_devnum , & journal_ioprio , 0 ) ) goto failed_mount ; if ( test_opt ( sb , DATA_FLAGS ) == EXT4_MOUNT_JOURNAL_DATA ) { printk_once ( KERN_WARNING ""EXT4-fs:Warning:mounting"" ""withdata=journaldisablesdelayed"" ""allocationandO_DIRECTsupport!\\n"" ) ; if ( test_opt2 ( sb , EXPLICIT_DELALLOC ) ) { ext4_msg ( sb , KERN_ERR , ""can\'tmountwith"" ""bothdata=journalanddelalloc"" ) ; goto failed_mount ; } if ( test_opt ( sb , DIOREAD_NOLOCK ) ) { ext4_msg ( sb , KERN_ERR , ""can\'tmountwith"" ""bothdata=journalanddioread_nolock"" ) ; goto failed_mount ; } if ( test_opt ( sb , DAX ) ) { ext4_msg ( sb , KERN_ERR , ""can\'tmountwith"" ""bothdata=journalanddax"" ) ; goto failed_mount ; } if ( test_opt ( sb , DELALLOC ) ) clear_opt ( sb , DELALLOC ) ; } else { sb -> s_iflags |= SB_I_CGROUPWB ; } sb -> s_flags = ( sb -> s_flags & ~ MS_POSIXACL ) | ( test_opt ( sb , POSIX_ACL ) ? MS_POSIXACL : 0 ) ; if ( le32_to_cpu ( es -> s_rev_level ) == EXT4_GOOD_OLD_REV && ( ext4_has_compat_features ( sb ) || ext4_has_ro_compat_features ( sb ) || ext4_has_incompat_features ( sb ) ) ) ext4_msg ( sb , KERN_WARNING , ""featureflagssetonrev0fs,"" ""runninge2fsckisrecommended"" ) ; if ( es -> s_creator_os == cpu_to_le32 ( EXT4_OS_HURD ) ) { set_opt2 ( sb , HURD_COMPAT ) ; if ( ext4_has_feature_64bit ( sb ) ) { ext4_msg ( sb , KERN_ERR , ""TheHurdcan\'tsupport64-bitfilesystems"" ) ; goto failed_mount ; } } if ( IS_EXT2_SB ( sb ) ) { if ( ext2_feature_set_ok ( sb ) ) ext4_msg ( sb , KERN_INFO , ""mountingext2filesystem"" ""usingtheext4subsystem"" ) ; else { ext4_msg ( sb , KERN_ERR , ""couldn\'tmountasext2due"" ""tofeatureincompatibilities"" ) ; goto failed_mount ; } } if ( IS_EXT3_SB ( sb ) ) { if ( ext3_feature_set_ok ( sb ) ) ext4_msg ( sb , KERN_INFO , ""mountingext3filesystem"" ""usingtheext4subsystem"" ) ; else { ext4_msg ( sb , KERN_ERR , ""couldn\'tmountasext3due"" ""tofeatureincompatibilities"" ) ; goto failed_mount ; } } if ( ! ext4_feature_set_ok ( sb , ( sb -> s_flags & MS_RDONLY ) ) ) goto failed_mount ; blocksize = BLOCK_SIZE << le32_to_cpu ( es -> s_log_block_size ) ; if ( blocksize < EXT4_MIN_BLOCK_SIZE || blocksize > EXT4_MAX_BLOCK_SIZE ) { ext4_msg ( sb , KERN_ERR , ""Unsupportedfilesystemblocksize%d"" , blocksize ) ; goto failed_mount ; } if ( sbi -> s_mount_opt & EXT4_MOUNT_DAX ) { if ( blocksize != PAGE_SIZE ) { ext4_msg ( sb , KERN_ERR , ""error:unsupportedblocksizefordax"" ) ; goto failed_mount ; } if ( ! sb -> s_bdev -> bd_disk -> fops -> direct_access ) { ext4_msg ( sb , KERN_ERR , ""error:devicedoesnotsupportdax"" ) ; goto failed_mount ; } } if ( ext4_has_feature_encrypt ( sb ) && es -> s_encryption_level ) { ext4_msg ( sb , KERN_ERR , ""Unsupportedencryptionlevel%d"" , es -> s_encryption_level ) ; goto failed_mount ; } if ( sb -> s_blocksize != blocksize ) { if ( ! sb_set_blocksize ( sb , blocksize ) ) { ext4_msg ( sb , KERN_ERR , ""badblocksize%d"" , blocksize ) ; goto failed_mount ; } brelse ( bh ) ; logical_sb_block = sb_block * EXT4_MIN_BLOCK_SIZE ; offset = do_div ( logical_sb_block , blocksize ) ; bh = sb_bread_unmovable ( sb , logical_sb_block ) ; if ( ! bh ) { ext4_msg ( sb , KERN_ERR , ""Can\'treadsuperblockon2ndtry"" ) ; goto failed_mount ; } es = ( struct ext4_super_block * ) ( bh -> b_data + offset ) ; sbi -> s_es = es ; if ( es -> s_magic != cpu_to_le16 ( EXT4_SUPER_MAGIC ) ) { ext4_msg ( sb , KERN_ERR , ""Magicmismatch,veryweird!"" ) ; goto failed_mount ; } } has_huge_files = ext4_has_feature_huge_file ( sb ) ; sbi -> s_bitmap_maxbytes = ext4_max_bitmap_size ( sb -> s_blocksize_bits , has_huge_files ) ; sb -> s_maxbytes = ext4_max_size ( sb -> s_blocksize_bits , has_huge_files ) ; if ( le32_to_cpu ( es -> s_rev_level ) == EXT4_GOOD_OLD_REV ) { sbi -> s_inode_size = EXT4_GOOD_OLD_INODE_SIZE ; sbi -> s_first_ino = EXT4_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 < EXT4_GOOD_OLD_INODE_SIZE ) || ( ! is_power_of_2 ( sbi -> s_inode_size ) ) || ( sbi -> s_inode_size > blocksize ) ) { ext4_msg ( sb , KERN_ERR , ""unsupportedinodesize:%d"" , sbi -> s_inode_size ) ; goto failed_mount ; } if ( sbi -> s_inode_size > EXT4_GOOD_OLD_INODE_SIZE ) sb -> s_time_gran = 1 << ( EXT4_EPOCH_BITS - 2 ) ; } sbi -> s_desc_size = le16_to_cpu ( es -> s_desc_size ) ; if ( ext4_has_feature_64bit ( sb ) ) { if ( sbi -> s_desc_size < EXT4_MIN_DESC_SIZE_64BIT || sbi -> s_desc_size > EXT4_MAX_DESC_SIZE || ! is_power_of_2 ( sbi -> s_desc_size ) ) { ext4_msg ( sb , KERN_ERR , ""unsupporteddescriptorsize%lu"" , sbi -> s_desc_size ) ; goto failed_mount ; } } else sbi -> s_desc_size = EXT4_MIN_DESC_SIZE ; sbi -> s_blocks_per_group = le32_to_cpu ( es -> s_blocks_per_group ) ; sbi -> s_inodes_per_group = le32_to_cpu ( es -> s_inodes_per_group ) ; if ( EXT4_INODE_SIZE ( sb ) == 0 || EXT4_INODES_PER_GROUP ( sb ) == 0 ) goto cantfind_ext4 ; sbi -> s_inodes_per_block = blocksize / EXT4_INODE_SIZE ( sb ) ; if ( sbi -> s_inodes_per_block == 0 ) goto cantfind_ext4 ; sbi -> s_itb_per_group = sbi -> s_inodes_per_group / sbi -> s_inodes_per_block ; sbi -> s_desc_per_block = blocksize / EXT4_DESC_SIZE ( sb ) ; sbi -> s_sbh = bh ; sbi -> s_mount_state = le16_to_cpu ( es -> s_state ) ; sbi -> s_addr_per_block_bits = ilog2 ( EXT4_ADDR_PER_BLOCK ( sb ) ) ; sbi -> s_desc_per_block_bits = ilog2 ( EXT4_DESC_PER_BLOCK ( sb ) ) ; for ( i = 0 ; i < 4 ; i ++ ) sbi -> s_hash_seed [ i ] = le32_to_cpu ( es -> s_hash_seed [ i ] ) ; sbi -> s_def_hash_version = es -> s_def_hash_version ; if ( ext4_has_feature_dir_index ( sb ) ) { i = le32_to_cpu ( es -> s_flags ) ; if ( i & EXT2_FLAGS_UNSIGNED_HASH ) sbi -> s_hash_unsigned = 3 ; else if ( ( i & EXT2_FLAGS_SIGNED_HASH ) == 0 ) { # ifdef __CHAR_UNSIGNED__ if ( ! ( sb -> s_flags & MS_RDONLY ) ) es -> s_flags |= cpu_to_le32 ( EXT2_FLAGS_UNSIGNED_HASH ) ; sbi -> s_hash_unsigned = 3 ; # else if ( ! ( sb -> s_flags & MS_RDONLY ) ) es -> s_flags |= cpu_to_le32 ( EXT2_FLAGS_SIGNED_HASH ) ; # endif } } clustersize = BLOCK_SIZE << le32_to_cpu ( es -> s_log_cluster_size ) ; has_bigalloc = ext4_has_feature_bigalloc ( sb ) ; if ( has_bigalloc ) { if ( clustersize < blocksize ) { ext4_msg ( sb , KERN_ERR , ""clustersize(%d)smallerthan"" ""blocksize(%d)"" , clustersize , blocksize ) ; goto failed_mount ; } sbi -> s_cluster_bits = le32_to_cpu ( es -> s_log_cluster_size ) - le32_to_cpu ( es -> s_log_block_size ) ; sbi -> s_clusters_per_group = le32_to_cpu ( es -> s_clusters_per_group ) ; if ( sbi -> s_clusters_per_group > blocksize * 8 ) { ext4_msg ( sb , KERN_ERR , ""#clusterspergrouptoobig:%lu"" , sbi -> s_clusters_per_group ) ; goto failed_mount ; } if ( sbi -> s_blocks_per_group != ( sbi -> s_clusters_per_group * ( clustersize / blocksize ) ) ) { ext4_msg ( sb , KERN_ERR , ""blockspergroup(%lu)and"" ""clusterspergroup(%lu)inconsistent"" , sbi -> s_blocks_per_group , sbi -> s_clusters_per_group ) ; goto failed_mount ; } } else { if ( clustersize != blocksize ) { ext4_warning ( sb , ""fragment/clustersize(%d)!="" ""blocksize(%d)"" , clustersize , blocksize ) ; clustersize = blocksize ; } if ( sbi -> s_blocks_per_group > blocksize * 8 ) { ext4_msg ( sb , KERN_ERR , ""#blockspergrouptoobig:%lu"" , sbi -> s_blocks_per_group ) ; goto failed_mount ; } sbi -> s_clusters_per_group = sbi -> s_blocks_per_group ; sbi -> s_cluster_bits = 0 ; } sbi -> s_cluster_ratio = clustersize / blocksize ; if ( sbi -> s_inodes_per_group > blocksize * 8 ) { ext4_msg ( sb , KERN_ERR , ""#inodespergrouptoobig:%lu"" , sbi -> s_inodes_per_group ) ; goto failed_mount ; } if ( sbi -> s_blocks_per_group == clustersize << 3 ) set_opt2 ( sb , STD_GROUP_SIZE ) ; err = generic_check_addressable ( sb -> s_blocksize_bits , ext4_blocks_count ( es ) ) ; if ( err ) { ext4_msg ( sb , KERN_ERR , ""filesystem"" ""toolargetomountsafelyonthissystem"" ) ; if ( sizeof ( sector_t ) < 8 ) ext4_msg ( sb , KERN_WARNING , ""CONFIG_LBDAFnotenabled"" ) ; goto failed_mount ; } if ( EXT4_BLOCKS_PER_GROUP ( sb ) == 0 ) goto cantfind_ext4 ; blocks_count = sb -> s_bdev -> bd_inode -> i_size >> sb -> s_blocksize_bits ; if ( blocks_count && ext4_blocks_count ( es ) > blocks_count ) { ext4_msg ( sb , KERN_WARNING , ""badgeometry:blockcount%llu"" ""exceedssizeofdevice(%llublocks)"" , ext4_blocks_count ( es ) , blocks_count ) ; goto failed_mount ; } if ( le32_to_cpu ( es -> s_first_data_block ) >= ext4_blocks_count ( es ) ) { ext4_msg ( sb , KERN_WARNING , ""badgeometry:firstdata"" ""block%uisbeyondendoffilesystem(%llu)"" , le32_to_cpu ( es -> s_first_data_block ) , ext4_blocks_count ( es ) ) ; goto failed_mount ; } blocks_count = ( ext4_blocks_count ( es ) - le32_to_cpu ( es -> s_first_data_block ) + EXT4_BLOCKS_PER_GROUP ( sb ) - 1 ) ; do_div ( blocks_count , EXT4_BLOCKS_PER_GROUP ( sb ) ) ; if ( blocks_count > ( ( uint64_t ) 1 << 32 ) - EXT4_DESC_PER_BLOCK ( sb ) ) { ext4_msg ( sb , KERN_WARNING , ""groupscounttoolarge:%u"" ""(blockcount%llu,firstdatablock%u,"" ""blockspergroup%lu)"" , sbi -> s_groups_count , ext4_blocks_count ( es ) , le32_to_cpu ( es -> s_first_data_block ) , EXT4_BLOCKS_PER_GROUP ( sb ) ) ; goto failed_mount ; } sbi -> s_groups_count = blocks_count ; sbi -> s_blockfile_groups = min_t ( ext4_group_t , sbi -> s_groups_count , ( EXT4_MAX_BLOCK_FILE_PHYS / EXT4_BLOCKS_PER_GROUP ( sb ) ) ) ; db_count = ( sbi -> s_groups_count + EXT4_DESC_PER_BLOCK ( sb ) - 1 ) / EXT4_DESC_PER_BLOCK ( sb ) ; sbi -> s_group_desc = ext4_kvmalloc ( db_count * sizeof ( struct buffer_head * ) , GFP_KERNEL ) ; if ( sbi -> s_group_desc == NULL ) { ext4_msg ( sb , KERN_ERR , ""notenoughmemory"" ) ; ret = - ENOMEM ; goto failed_mount ; } bgl_lock_init ( sbi -> s_blockgroup_lock ) ; for ( i = 0 ; i < db_count ; i ++ ) { block = descriptor_loc ( sb , logical_sb_block , i ) ; sbi -> s_group_desc [ i ] = sb_bread_unmovable ( sb , block ) ; if ( ! sbi -> s_group_desc [ i ] ) { ext4_msg ( sb , KERN_ERR , ""can\'treadgroupdescriptor%d"" , i ) ; db_count = i ; goto failed_mount2 ; } } if ( ! ext4_check_descriptors ( sb , & first_not_zeroed ) ) { ext4_msg ( sb , KERN_ERR , ""groupdescriptorscorrupted!"" ) ; ret = - EFSCORRUPTED ; 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 ) ; setup_timer ( & sbi -> s_err_report , print_daily_error_info , ( unsigned long ) sb ) ; if ( ext4_es_register_shrinker ( sbi ) ) goto failed_mount3 ; sbi -> s_stripe = ext4_get_stripe_size ( sbi ) ; sbi -> s_extent_max_zeroout_kb = 32 ; sb -> s_op = & ext4_sops ; sb -> s_export_op = & ext4_export_ops ; sb -> s_xattr = ext4_xattr_handlers ; # ifdef CONFIG_QUOTA sb -> dq_op = & ext4_quota_operations ; if ( ext4_has_feature_quota ( sb ) ) sb -> s_qcop = & dquot_quotactl_sysfile_ops ; else sb -> s_qcop = & ext4_qctl_operations ; sb -> s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP | QTYPE_MASK_PRJ ; # endif memcpy ( sb -> s_uuid , es -> s_uuid , sizeof ( es -> s_uuid ) ) ; INIT_LIST_HEAD ( & sbi -> s_orphan ) ; mutex_init ( & sbi -> s_orphan_lock ) ; sb -> s_root = NULL ; needs_recovery = ( es -> s_last_orphan != 0 || ext4_has_feature_journal_needs_recovery ( sb ) ) ; if ( ext4_has_feature_mmp ( sb ) && ! ( sb -> s_flags & MS_RDONLY ) ) if ( ext4_multi_mount_protect ( sb , le64_to_cpu ( es -> s_mmp_block ) ) ) goto failed_mount3a ; if ( ! test_opt ( sb , NOLOAD ) && ext4_has_feature_journal ( sb ) ) { if ( ext4_load_journal ( sb , es , journal_devnum ) ) goto failed_mount3a ; } else if ( test_opt ( sb , NOLOAD ) && ! ( sb -> s_flags & MS_RDONLY ) && ext4_has_feature_journal_needs_recovery ( sb ) ) { ext4_msg ( sb , KERN_ERR , ""requiredjournalrecovery"" ""suppressedandnotmountedread-only"" ) ; goto failed_mount_wq ; } else { if ( test_opt2 ( sb , EXPLICIT_JOURNAL_CHECKSUM ) ) { ext4_msg ( sb , KERN_ERR , ""can\'tmountwith"" ""journal_checksum,fsmountedw/ojournal"" ) ; goto failed_mount_wq ; } if ( test_opt ( sb , JOURNAL_ASYNC_COMMIT ) ) { ext4_msg ( sb , KERN_ERR , ""can\'tmountwith"" ""journal_async_commit,fsmountedw/ojournal"" ) ; goto failed_mount_wq ; } if ( sbi -> s_commit_interval != JBD2_DEFAULT_MAX_COMMIT_AGE * HZ ) { ext4_msg ( sb , KERN_ERR , ""can\'tmountwith"" ""commit=%lu,fsmountedw/ojournal"" , sbi -> s_commit_interval / HZ ) ; goto failed_mount_wq ; } if ( EXT4_MOUNT_DATA_FLAGS & ( sbi -> s_mount_opt ^ sbi -> s_def_mount_opt ) ) { ext4_msg ( sb , KERN_ERR , ""can\'tmountwith"" ""data=,fsmountedw/ojournal"" ) ; goto failed_mount_wq ; } sbi -> s_def_mount_opt &= EXT4_MOUNT_JOURNAL_CHECKSUM ; clear_opt ( sb , JOURNAL_CHECKSUM ) ; clear_opt ( sb , DATA_FLAGS ) ; sbi -> s_journal = NULL ; needs_recovery = 0 ; goto no_journal ; } if ( ext4_has_feature_64bit ( sb ) && ! jbd2_journal_set_features ( EXT4_SB ( sb ) -> s_journal , 0 , 0 , JBD2_FEATURE_INCOMPAT_64BIT ) ) { ext4_msg ( sb , KERN_ERR , ""Failedtoset64-bitjournalfeature"" ) ; goto failed_mount_wq ; } if ( ! set_journal_csum_feature_set ( sb ) ) { ext4_msg ( sb , KERN_ERR , ""Failedtosetjournalchecksum"" ""featureset"" ) ; goto failed_mount_wq ; } switch ( test_opt ( sb , DATA_FLAGS ) ) { case 0 : if ( jbd2_journal_check_available_features ( sbi -> s_journal , 0 , 0 , JBD2_FEATURE_INCOMPAT_REVOKE ) ) set_opt ( sb , ORDERED_DATA ) ; else set_opt ( sb , JOURNAL_DATA ) ; break ; case EXT4_MOUNT_ORDERED_DATA : case EXT4_MOUNT_WRITEBACK_DATA : if ( ! jbd2_journal_check_available_features ( sbi -> s_journal , 0 , 0 , JBD2_FEATURE_INCOMPAT_REVOKE ) ) { ext4_msg ( sb , KERN_ERR , ""Journaldoesnotsupport"" ""requesteddatajournalingmode"" ) ; goto failed_mount_wq ; } default : break ; } set_task_ioprio ( sbi -> s_journal -> j_task , journal_ioprio ) ; sbi -> s_journal -> j_commit_callback = ext4_journal_commit_callback ; no_journal : if ( ext4_mballoc_ready ) { sbi -> s_mb_cache = ext4_xattr_create_cache ( sb -> s_id ) ; if ( ! sbi -> s_mb_cache ) { ext4_msg ( sb , KERN_ERR , ""Failedtocreateanmb_cache"" ) ; goto failed_mount_wq ; } } if ( ( DUMMY_ENCRYPTION_ENABLED ( sbi ) || ext4_has_feature_encrypt ( sb ) ) && ( blocksize != PAGE_CACHE_SIZE ) ) { ext4_msg ( sb , KERN_ERR , ""Unsupportedblocksizeforfsencryption"" ) ; goto failed_mount_wq ; } if ( DUMMY_ENCRYPTION_ENABLED ( sbi ) && ! ( sb -> s_flags & MS_RDONLY ) && ! ext4_has_feature_encrypt ( sb ) ) { ext4_set_feature_encrypt ( sb ) ; ext4_commit_super ( sb , 1 ) ; } if ( es -> s_overhead_clusters ) sbi -> s_overhead = le32_to_cpu ( es -> s_overhead_clusters ) ; else { err = ext4_calculate_overhead ( sb ) ; if ( err ) goto failed_mount_wq ; } EXT4_SB ( sb ) -> rsv_conversion_wq = alloc_workqueue ( ""ext4-rsv-conversion"" , WQ_MEM_RECLAIM | WQ_UNBOUND , 1 ) ; if ( ! EXT4_SB ( sb ) -> rsv_conversion_wq ) { printk ( KERN_ERR ""EXT4-fs:failedtocreateworkqueue\\n"" ) ; ret = - ENOMEM ; goto failed_mount4 ; } root = ext4_iget ( sb , EXT4_ROOT_INO ) ; if ( IS_ERR ( root ) ) { ext4_msg ( sb , KERN_ERR , ""getrootinodefailed"" ) ; ret = PTR_ERR ( root ) ; root = NULL ; goto failed_mount4 ; } if ( ! S_ISDIR ( root -> i_mode ) || ! root -> i_blocks || ! root -> i_size ) { ext4_msg ( sb , KERN_ERR , ""corruptrootinode,rune2fsck"" ) ; iput ( root ) ; goto failed_mount4 ; } sb -> s_root = d_make_root ( root ) ; if ( ! sb -> s_root ) { ext4_msg ( sb , KERN_ERR , ""getrootdentryfailed"" ) ; ret = - ENOMEM ; goto failed_mount4 ; } if ( ext4_setup_super ( sb , es , sb -> s_flags & MS_RDONLY ) ) sb -> s_flags |= MS_RDONLY ; if ( sbi -> s_inode_size > EXT4_GOOD_OLD_INODE_SIZE ) { sbi -> s_want_extra_isize = sizeof ( struct ext4_inode ) - EXT4_GOOD_OLD_INODE_SIZE ; if ( ext4_has_feature_extra_isize ( sb ) ) { if ( sbi -> s_want_extra_isize < le16_to_cpu ( es -> s_want_extra_isize ) ) sbi -> s_want_extra_isize = le16_to_cpu ( es -> s_want_extra_isize ) ; if ( sbi -> s_want_extra_isize < le16_to_cpu ( es -> s_min_extra_isize ) ) sbi -> s_want_extra_isize = le16_to_cpu ( es -> s_min_extra_isize ) ; } } if ( EXT4_GOOD_OLD_INODE_SIZE + sbi -> s_want_extra_isize > sbi -> s_inode_size ) { sbi -> s_want_extra_isize = sizeof ( struct ext4_inode ) - EXT4_GOOD_OLD_INODE_SIZE ; ext4_msg ( sb , KERN_INFO , ""requiredextrainodespacenot"" ""available"" ) ; } ext4_set_resv_clusters ( sb ) ; err = ext4_setup_system_zone ( sb ) ; if ( err ) { ext4_msg ( sb , KERN_ERR , ""failedtoinitializesystem"" ""zone(%d)"" , err ) ; goto failed_mount4a ; } ext4_ext_init ( sb ) ; err = ext4_mb_init ( sb ) ; if ( err ) { ext4_msg ( sb , KERN_ERR , ""failedtoinitializemballoc(%d)"" , err ) ; goto failed_mount5 ; } block = ext4_count_free_clusters ( sb ) ; ext4_free_blocks_count_set ( sbi -> s_es , EXT4_C2B ( sbi , block ) ) ; err = percpu_counter_init ( & sbi -> s_freeclusters_counter , block , GFP_KERNEL ) ; if ( ! err ) { unsigned long freei = ext4_count_free_inodes ( sb ) ; sbi -> s_es -> s_free_inodes_count = cpu_to_le32 ( freei ) ; err = percpu_counter_init ( & sbi -> s_freeinodes_counter , freei , GFP_KERNEL ) ; } if ( ! err ) err = percpu_counter_init ( & sbi -> s_dirs_counter , ext4_count_dirs ( sb ) , GFP_KERNEL ) ; if ( ! err ) err = percpu_counter_init ( & sbi -> s_dirtyclusters_counter , 0 , GFP_KERNEL ) ; if ( err ) { ext4_msg ( sb , KERN_ERR , ""insufficientmemory"" ) ; goto failed_mount6 ; } if ( ext4_has_feature_flex_bg ( sb ) ) if ( ! ext4_fill_flex_info ( sb ) ) { ext4_msg ( sb , KERN_ERR , ""unabletoinitialize"" ""flex_bgmetainfo!"" ) ; goto failed_mount6 ; } err = ext4_register_li_request ( sb , first_not_zeroed ) ; if ( err ) goto failed_mount6 ; err = ext4_register_sysfs ( sb ) ; if ( err ) goto failed_mount7 ; # ifdef CONFIG_QUOTA if ( ext4_has_feature_quota ( sb ) && ! ( sb -> s_flags & MS_RDONLY ) ) { err = ext4_enable_quotas ( sb ) ; if ( err ) goto failed_mount8 ; } # endif EXT4_SB ( sb ) -> s_mount_state |= EXT4_ORPHAN_FS ; ext4_orphan_cleanup ( sb , es ) ; EXT4_SB ( sb ) -> s_mount_state &= ~ EXT4_ORPHAN_FS ; if ( needs_recovery ) { ext4_msg ( sb , KERN_INFO , ""recoverycomplete"" ) ; ext4_mark_recovery_complete ( sb , es ) ; } if ( EXT4_SB ( sb ) -> s_journal ) { if ( test_opt ( sb , DATA_FLAGS ) == EXT4_MOUNT_JOURNAL_DATA ) descr = ""journalleddatamode"" ; else if ( test_opt ( sb , DATA_FLAGS ) == EXT4_MOUNT_ORDERED_DATA ) descr = ""ordereddatamode"" ; else descr = ""writebackdatamode"" ; } else descr = ""outjournal"" ; if ( test_opt ( sb , DISCARD ) ) { struct request_queue * q = bdev_get_queue ( sb -> s_bdev ) ; if ( ! blk_queue_discard ( q ) ) ext4_msg ( sb , KERN_WARNING , ""mountingwith\\""discard\\""option,but"" ""thedevicedoesnotsupportdiscard"" ) ; } if ( ___ratelimit ( & ext4_mount_msg_ratelimit , ""EXT4-fsmount"" ) ) ext4_msg ( sb , KERN_INFO , ""mountedfilesystemwith%s."" ""Opts:%s%s%s"" , descr , sbi -> s_es -> s_mount_opts , * sbi -> s_es -> s_mount_opts ? "";"" : """" , orig_data ) ; if ( es -> s_error_count ) mod_timer ( & sbi -> s_err_report , jiffies + 300 * HZ ) ; ratelimit_state_init ( & sbi -> s_err_ratelimit_state , 5 * HZ , 10 ) ; ratelimit_state_init ( & sbi -> s_warning_ratelimit_state , 5 * HZ , 10 ) ; ratelimit_state_init ( & sbi -> s_msg_ratelimit_state , 5 * HZ , 10 ) ; kfree ( orig_data ) ; return 0 ; cantfind_ext4 : if ( ! silent ) ext4_msg ( sb , KERN_ERR , ""VFS:Can\'tfindext4filesystem"" ) ; goto failed_mount ; # ifdef CONFIG_QUOTA failed_mount8 : ext4_unregister_sysfs ( sb ) ; # endif failed_mount7 : ext4_unregister_li_request ( sb ) ; failed_mount6 : ext4_mb_release ( sb ) ; if ( sbi -> s_flex_groups ) kvfree ( sbi -> s_flex_groups ) ; percpu_counter_destroy ( & sbi -> s_freeclusters_counter ) ; percpu_counter_destroy ( & sbi -> s_freeinodes_counter ) ; percpu_counter_destroy ( & sbi -> s_dirs_counter ) ; percpu_counter_destroy ( & sbi -> s_dirtyclusters_counter ) ; failed_mount5 : ext4_ext_release ( sb ) ; ext4_release_system_zone ( sb ) ; failed_mount4a : dput ( sb -> s_root ) ; sb -> s_root = NULL ; failed_mount4 : ext4_msg ( sb , KERN_ERR , ""mountfailed"" ) ; if ( EXT4_SB ( sb ) -> rsv_conversion_wq ) destroy_workqueue ( EXT4_SB ( sb ) -> rsv_conversion_wq ) ; failed_mount_wq : if ( sbi -> s_journal ) { jbd2_journal_destroy ( sbi -> s_journal ) ; sbi -> s_journal = NULL ; } failed_mount3a : ext4_es_unregister_shrinker ( sbi ) ; failed_mount3 : del_timer_sync ( & sbi -> s_err_report ) ; if ( sbi -> s_mmp_tsk ) kthread_stop ( sbi -> s_mmp_tsk ) ; failed_mount2 : for ( i = 0 ; i < db_count ; i ++ ) brelse ( sbi -> s_group_desc [ i ] ) ; kvfree ( sbi -> s_group_desc ) ; failed_mount : if ( sbi -> s_chksum_driver ) crypto_free_shash ( sbi -> s_chksum_driver ) ; # ifdef CONFIG_QUOTA for ( i = 0 ; i < EXT4_MAXQUOTAS ; i ++ ) kfree ( sbi -> s_qf_names [ i ] ) ; # endif ext4_blkdev_remove ( sbi ) ; brelse ( bh ) ; out_fail : sb -> s_fs_info = NULL ; kfree ( sbi -> s_blockgroup_lock ) ; kfree ( sbi ) ; out_free_orig : kfree ( orig_data ) ; return err ? err : ret ; } "," = ext4_xattr_create_cache ( ) ; if ; failed_mount_wq : if ( sbi -> s_mb_cache ) { ext4_xattr_destroy_cache ( sbi -> s_mb_cache ) ; sbi -> s_mb_cache = NULL ; } ",torvalds@linux/82939d7999dfc1f1998c4b1c12e2f19edbdff272,CVE-2015-8952,https://github.com/torvalds/linux/commit/82939d7999dfc1f1998c4b1c12e2f19edbdff272,2016-10-16T21:59Z 1010,CWE-200,"CWE-200 static int nr_recvmsg ( struct kiocb * iocb , struct socket * sock , struct msghdr * msg , size_t size , int flags ) { struct sock * sk = sock -> sk ; struct sockaddr_ax25 * sax = ( struct sockaddr_ax25 * ) msg -> msg_name ; size_t copied ; struct sk_buff * skb ; int er ; lock_sock ( sk ) ; if ( sk -> sk_state != TCP_ESTABLISHED ) { release_sock ( sk ) ; return - ENOTCONN ; } if ( ( skb = skb_recv_datagram ( sk , flags & ~ MSG_DONTWAIT , flags & MSG_DONTWAIT , & er ) ) == NULL ) { release_sock ( sk ) ; return er ; } skb_reset_transport_header ( skb ) ; copied = skb -> len ; if ( copied > size ) { copied = size ; msg -> msg_flags |= MSG_TRUNC ; } er = skb_copy_datagram_iovec ( skb , 0 , msg -> msg_iov , copied ) ; if ( er < 0 ) { skb_free_datagram ( sk , skb ) ; release_sock ( sk ) ; return er ; } if ( sax != NULL ) { sax -> sax25_family = AF_NETROM ; skb_copy_from_linear_data_offset ( skb , 7 , sax -> sax25_call . ax25_call , AX25_ADDR_LEN ) ; } msg -> msg_namelen = sizeof ( * sax ) ; skb_free_datagram ( sk , skb ) ; release_sock ( sk ) ; return copied ; } "," NULL ) { memset ( sax , 0 , sizeof ( sax ) ) ; ",torvalds@linux/3ce5efad47b62c57a4f5c54248347085a750ce0e,CVE-2013-3232,https://github.com/torvalds/linux/commit/3ce5efad47b62c57a4f5c54248347085a750ce0e,2013-04-22T11:41Z 1011,CWE-119,"CWE-119 struct l2tp_packet_t * l2tp_packet_alloc ( int ver , int msg_type , const struct sockaddr_in * addr , int H , const char * secret , size_t secret_len ) { struct l2tp_packet_t * pack = mempool_alloc ( pack_pool ) ; if ( ! pack ) return NULL ; memset ( pack , 0 , sizeof ( * pack ) ) ; INIT_LIST_HEAD ( & pack -> attrs ) ; pack -> hdr . ver = ver ; pack -> hdr . T = 1 ; pack -> hdr . L = 1 ; pack -> hdr . S = 1 ; memcpy ( & pack -> addr , addr , sizeof ( * addr ) ) ; pack -> hide_avps = H ; pack -> secret = secret ; pack -> secret_len = secret_len ; if ( msg_type ) { if ( l2tp_packet_add_int16 ( pack , Message_Type , msg_type , 1 ) ) { mempool_free ( pack ) ; return NULL ; } } return pack ; } "," -> hdr . flags = L2TP_FLAG_T | L2TP_FLAG_L | L2TP_FLAG_S | ( ver & L2TP_VER_MASK ) ; memcpy ( ",accel-ppp@accel-ppp/2324bcd5ba12cf28f47357a8f03cd41b7c04c52b,CVE-2020-15173,https://github.com/accel-ppp/accel-ppp/commit/2324bcd5ba12cf28f47357a8f03cd41b7c04c52b,2020-09-09T23:15Z 1012,CWE-476,"CWE-476 static int parse_report ( transport_smart * transport , git_push * push ) { git_pkt * pkt = NULL ; const char * line_end = NULL ; gitno_buffer * buf = & transport -> buffer ; int error , recvd ; git_buf data_pkt_buf = GIT_BUF_INIT ; for ( ; ; ) { if ( buf -> offset > 0 ) error = git_pkt_parse_line ( & pkt , buf -> data , & line_end , buf -> offset ) ; else error = GIT_EBUFS ; if ( error < 0 && error != GIT_EBUFS ) { error = - 1 ; goto done ; } if ( error == GIT_EBUFS ) { if ( ( recvd = gitno_recv ( buf ) ) < 0 ) { error = recvd ; goto done ; } if ( recvd == 0 ) { giterr_set ( GITERR_NET , ""earlyEOF"" ) ; error = GIT_EEOF ; goto done ; } continue ; } gitno_consume ( buf , line_end ) ; error = 0 ; if ( pkt == NULL ) continue ; switch ( pkt -> type ) { case GIT_PKT_DATA : error = add_push_report_sideband_pkt ( push , ( git_pkt_data * ) pkt , & data_pkt_buf ) ; break ; case GIT_PKT_ERR : giterr_set ( GITERR_NET , ""report-status:Errorreported:%s"" , ( ( git_pkt_err * ) pkt ) -> error ) ; error = - 1 ; break ; case GIT_PKT_PROGRESS : if ( transport -> progress_cb ) { git_pkt_progress * p = ( git_pkt_progress * ) pkt ; error = transport -> progress_cb ( p -> data , p -> len , transport -> message_cb_payload ) ; } break ; default : error = add_push_report_pkt ( push , pkt ) ; break ; } git_pkt_free ( pkt ) ; if ( error == GIT_ITEROVER ) { error = 0 ; if ( data_pkt_buf . size > 0 ) { giterr_set ( GITERR_NET , ""Incompletepackdatapkt-line"" ) ; error = GIT_ERROR ; } goto done ; } if ( error < 0 ) { goto done ; } } done : git_buf_free ( & data_pkt_buf ) ; return error ; } "," error = 0 ; switch ( ",libgit2@libgit2/2fdef641fd0dd2828bd948234ae86de75221a11a,CVE-2016-10129,https://github.com/libgit2/libgit2/commit/2fdef641fd0dd2828bd948234ae86de75221a11a,2017-03-24T15:59Z 1013,CWE-000,"CWE-000 kadm5_ret_t kadm5_create_principal_3 ( void * server_handle , kadm5_principal_ent_t entry , long mask , int n_ks_tuple , krb5_key_salt_tuple * ks_tuple , char * password ) { krb5_db_entry * kdb ; osa_princ_ent_rec adb ; kadm5_policy_ent_rec polent ; krb5_boolean have_polent = FALSE ; krb5_int32 now ; krb5_tl_data * tl_data_tail ; unsigned int ret ; 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 ; CHECK_HANDLE ( server_handle ) ; krb5_clear_error_message ( handle -> context ) ; check_1_6_dummy ( entry , mask , n_ks_tuple , ks_tuple , & password ) ; if ( ! ( mask & KADM5_PRINCIPAL ) || ( mask & KADM5_MOD_NAME ) || ( mask & KADM5_MOD_TIME ) || ( mask & KADM5_LAST_PWD_CHANGE ) || ( mask & KADM5_MKVNO ) || ( mask & KADM5_AUX_ATTRIBUTES ) || ( mask & KADM5_LAST_SUCCESS ) || ( mask & KADM5_LAST_FAILED ) || ( mask & KADM5_FAIL_AUTH_COUNT ) ) return KADM5_BAD_MASK ; if ( ( mask & KADM5_KEY_DATA ) && entry -> n_key_data != 0 ) return KADM5_BAD_MASK ; if ( ( mask & KADM5_POLICY ) && ( mask & KADM5_POLICY_CLR ) ) return KADM5_BAD_MASK ; if ( ( mask & ~ ALL_PRINC_MASK ) ) return KADM5_BAD_MASK ; if ( entry == NULL ) return EINVAL ; ret = kdb_get_entry ( handle , entry -> principal , & kdb , & adb ) ; switch ( ret ) { case KADM5_UNK_PRINC : break ; case 0 : kdb_free_entry ( handle , kdb , & adb ) ; return KADM5_DUP ; default : return ret ; } kdb = krb5_db_alloc ( handle -> context , NULL , sizeof ( * kdb ) ) ; if ( kdb == NULL ) return ENOMEM ; memset ( kdb , 0 , sizeof ( * kdb ) ) ; memset ( & adb , 0 , sizeof ( osa_princ_ent_rec ) ) ; if ( ( mask & KADM5_POLICY ) ) { ret = get_policy ( handle , entry -> policy , & polent , & have_polent ) ; if ( ret ) goto cleanup ; } if ( password ) { ret = passwd_check ( handle , password , have_polent ? & polent : NULL , entry -> principal ) ; if ( ret ) goto cleanup ; } if ( ( ret = krb5_timeofday ( handle -> context , & now ) ) ) goto cleanup ; kdb -> magic = KRB5_KDB_MAGIC_NUMBER ; kdb -> len = KRB5_KDB_V1_BASE_LENGTH ; if ( ( mask & KADM5_ATTRIBUTES ) ) kdb -> attributes = entry -> attributes ; else kdb -> attributes = handle -> params . flags ; if ( ( mask & KADM5_MAX_LIFE ) ) kdb -> max_life = entry -> max_life ; else kdb -> max_life = handle -> params . max_life ; if ( mask & KADM5_MAX_RLIFE ) kdb -> max_renewable_life = entry -> max_renewable_life ; else kdb -> max_renewable_life = handle -> params . max_rlife ; if ( ( mask & KADM5_PRINC_EXPIRE_TIME ) ) kdb -> expiration = entry -> princ_expire_time ; else kdb -> expiration = handle -> params . expiration ; kdb -> pw_expiration = 0 ; if ( have_polent ) { if ( polent . pw_max_life ) kdb -> pw_expiration = now + polent . pw_max_life ; else kdb -> pw_expiration = 0 ; } if ( ( mask & KADM5_PW_EXPIRATION ) ) kdb -> pw_expiration = entry -> pw_expiration ; kdb -> last_success = 0 ; kdb -> last_failed = 0 ; kdb -> fail_auth_count = 0 ; if ( ( ret = kadm5_copy_principal ( handle -> context , entry -> principal , & ( kdb -> princ ) ) ) ) goto cleanup ; if ( ( ret = krb5_dbe_update_last_pwd_change ( handle -> context , kdb , now ) ) ) goto cleanup ; if ( mask & KADM5_TL_DATA ) { for ( tl_data_tail = entry -> tl_data ; tl_data_tail ; tl_data_tail = tl_data_tail -> tl_data_next ) { ret = krb5_dbe_update_tl_data ( handle -> context , kdb , tl_data_tail ) ; if ( ret ) goto cleanup ; } } ret = apply_keysalt_policy ( handle , entry -> policy , n_ks_tuple , ks_tuple , & new_n_ks_tuple , & new_ks_tuple ) ; if ( ret ) goto cleanup ; ret = kdb_get_active_mkey ( handle , & act_kvno , & act_mkey ) ; if ( ret ) goto cleanup ; if ( mask & KADM5_KEY_DATA ) { assert ( entry -> n_key_data == 0 ) ; } else if ( password ) { ret = krb5_dbe_cpw ( handle -> context , act_mkey , new_ks_tuple , new_n_ks_tuple , password , ( mask & KADM5_KVNO ) ? entry -> kvno : 1 , FALSE , kdb ) ; } else { ret = krb5_dbe_crk ( handle -> context , & master_keyblock , new_ks_tuple , new_n_ks_tuple , FALSE , kdb ) ; } if ( ret ) goto cleanup ; ret = krb5_dbe_update_mkvno ( handle -> context , kdb , act_kvno ) ; if ( ret ) goto cleanup ; ret = k5_kadm5_hook_create ( handle -> context , handle -> hook_handles , KADM5_HOOK_STAGE_PRECOMMIT , entry , mask , new_n_ks_tuple , new_ks_tuple , password ) ; if ( ret ) goto cleanup ; adb . admin_history_kvno = INITIAL_HIST_KVNO ; if ( mask & KADM5_POLICY ) { adb . aux_attributes = KADM5_POLICY ; adb . policy = entry -> policy ; } kdb -> mask = mask | KADM5_KEY_DATA | KADM5_PRINCIPAL ; ret = kdb_put_entry ( handle , kdb , & adb ) ; ( void ) k5_kadm5_hook_create ( handle -> context , handle -> hook_handles , KADM5_HOOK_STAGE_POSTCOMMIT , entry , mask , new_n_ks_tuple , new_ks_tuple , password ) ; cleanup : free ( new_ks_tuple ) ; krb5_db_free_principal ( handle -> context , kdb ) ; if ( have_polent ) ( void ) kadm5_free_policy_ent ( handle -> lhandle , & polent ) ; return ret ; } "," ; if ( entry == NULL ) return EINVAL ; if ( KADM5_POLICY ) && entry -> policy == NULL ) return KADM5_BAD_MASK ( mask & KADM5_POLICY ) && ( mask & KADM5_POLICY_CLR ) ) return KADM5_BAD_MASK ; if ( ( mask & ) return KADM5_BAD_MASK ; ret = ",krb5@krb5/b863de7fbf080b15e347a736fdda0a82d42f4f6b,CVE-2015-8630,https://github.com/krb5/krb5/commit/b863de7fbf080b15e347a736fdda0a82d42f4f6b,2016-02-13T02:59Z 1014,CWE-000,"CWE-000 struct vfsmount * collect_mounts ( struct path * path ) { struct mount * tree ; namespace_lock ( ) ; tree = copy_tree ( real_mount ( path -> mnt ) , path -> dentry , CL_COPY_ALL | CL_PRIVATE ) ; namespace_unlock ( ) ; if ( IS_ERR ( tree ) ) return ERR_CAST ( tree ) ; return & tree -> mnt ; } "," ( ) ; if ( ! check_mnt ( real_mount ( path -> mnt ) ) ) tree = ERR_PTR ( - EINVAL ) ; else ",torvalds@linux/cd4a40174b71acd021877341684d8bb1dc8ea4ae,CVE-2015-4177,https://github.com/torvalds/linux/commit/cd4a40174b71acd021877341684d8bb1dc8ea4ae,2016-05-02T10:59Z 1015,CWE-119,"CWE-119 static Image * ReadFAXImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { Image * image ; MagickBooleanType status ; 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 -> storage_class = PseudoClass ; if ( image -> columns == 0 ) image -> columns = 2592 ; if ( image -> rows == 0 ) image -> rows = 3508 ; image -> depth = 8 ; if ( AcquireImageColormap ( image , 2 ) == 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 = HuffmanDecodeImage ( image ) ; if ( status == MagickFalse ) ThrowReaderException ( CorruptImageError , ""UnableToReadImageData"" ) ; 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 ) ) ; } status = ",ImageMagick@ImageMagick/f6e9d0d9955e85bdd7540b251cd50d598dacc5e6,CVE-2016-10066,https://github.com/ImageMagick/ImageMagick/commit/f6e9d0d9955e85bdd7540b251cd50d598dacc5e6,2017-03-03T17:59Z 1016,CWE-362,"CWE-362 static int mptctl_hp_hostinfo ( unsigned long arg , unsigned int data_size ) { hp_host_info_t __user * uarg = ( void __user * ) arg ; MPT_ADAPTER * ioc ; struct pci_dev * pdev ; char * pbuf = NULL ; dma_addr_t buf_dma ; hp_host_info_t karg ; CONFIGPARMS cfg ; ConfigPageHeader_t hdr ; int iocnum ; int rc , cim_rev ; ToolboxIstwiReadWriteRequest_t * IstwiRWRequest ; MPT_FRAME_HDR * mf = NULL ; unsigned long timeleft ; int retval ; u32 msgcontext ; if ( data_size == sizeof ( hp_host_info_t ) ) cim_rev = 1 ; else if ( data_size == sizeof ( hp_host_info_rev0_t ) ) cim_rev = 0 ; else return - EFAULT ; if ( copy_from_user ( & karg , uarg , sizeof ( hp_host_info_t ) ) ) { printk ( KERN_ERR MYNAM ""%s@%d::mptctl_hp_host_info-"" ""Unabletoreadinhp_host_infostruct@%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_hp_hostinfo()@%d-ioc%dnotfound!\\n"" , __FILE__ , __LINE__ , iocnum ) ; return - ENODEV ; } dctlprintk ( ioc , printk ( MYIOC_s_DEBUG_FMT "":mptctl_hp_hostinfocalled.\\n"" , ioc -> name ) ) ; pdev = ( struct pci_dev * ) ioc -> pcidev ; karg . vendor = pdev -> vendor ; karg . device = pdev -> device ; karg . subsystem_id = pdev -> subsystem_device ; karg . subsystem_vendor = pdev -> subsystem_vendor ; karg . devfn = pdev -> devfn ; karg . bus = pdev -> bus -> number ; if ( ioc -> sh != NULL ) karg . host_no = ioc -> sh -> host_no ; else karg . host_no = - 1 ; snprintf ( karg . fw_version , sizeof ( karg . fw_version ) , ""%.2hhu.%.2hhu.%.2hhu.%.2hhu"" , ioc -> facts . FWVersion . Struct . Major , ioc -> facts . FWVersion . Struct . Minor , ioc -> facts . FWVersion . Struct . Unit , ioc -> facts . FWVersion . Struct . Dev ) ; hdr . PageVersion = 0 ; hdr . PageLength = 0 ; hdr . PageNumber = 0 ; hdr . PageType = MPI_CONFIG_PAGETYPE_MANUFACTURING ; cfg . cfghdr . hdr = & hdr ; cfg . physAddr = - 1 ; cfg . pageAddr = 0 ; cfg . action = MPI_CONFIG_ACTION_PAGE_HEADER ; cfg . dir = 0 ; cfg . timeout = 10 ; strncpy ( karg . serial_number , """" , 24 ) ; if ( mpt_config ( ioc , & cfg ) == 0 ) { if ( cfg . cfghdr . hdr -> PageLength > 0 ) { cfg . action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT ; pbuf = pci_alloc_consistent ( ioc -> pcidev , hdr . PageLength * 4 , & buf_dma ) ; if ( pbuf ) { cfg . physAddr = buf_dma ; if ( mpt_config ( ioc , & cfg ) == 0 ) { ManufacturingPage0_t * pdata = ( ManufacturingPage0_t * ) pbuf ; if ( strlen ( pdata -> BoardTracerNumber ) > 1 ) { strlcpy ( karg . serial_number , pdata -> BoardTracerNumber , 24 ) ; } } pci_free_consistent ( ioc -> pcidev , hdr . PageLength * 4 , pbuf , buf_dma ) ; pbuf = NULL ; } } } rc = mpt_GetIocState ( ioc , 1 ) ; switch ( rc ) { case MPI_IOC_STATE_OPERATIONAL : karg . ioc_status = HP_STATUS_OK ; break ; case MPI_IOC_STATE_FAULT : karg . ioc_status = HP_STATUS_FAILED ; break ; case MPI_IOC_STATE_RESET : case MPI_IOC_STATE_READY : default : karg . ioc_status = HP_STATUS_OTHER ; break ; } karg . base_io_addr = pci_resource_start ( pdev , 0 ) ; if ( ( ioc -> bus_type == SAS ) || ( ioc -> bus_type == FC ) ) karg . bus_phys_width = HP_BUS_WIDTH_UNK ; else karg . bus_phys_width = HP_BUS_WIDTH_16 ; karg . hard_resets = 0 ; karg . soft_resets = 0 ; karg . timeouts = 0 ; if ( ioc -> sh != NULL ) { MPT_SCSI_HOST * hd = shost_priv ( ioc -> sh ) ; if ( hd && ( cim_rev == 1 ) ) { karg . hard_resets = ioc -> hard_resets ; karg . soft_resets = ioc -> soft_resets ; karg . timeouts = ioc -> timeouts ; } } if ( ( mf = mpt_get_msg_frame ( mptctl_id , ioc ) ) == NULL ) { dfailprintk ( ioc , printk ( MYIOC_s_WARN_FMT ""%s,nomsgframes!!\\n"" , ioc -> name , __func__ ) ) ; goto out ; } IstwiRWRequest = ( ToolboxIstwiReadWriteRequest_t * ) mf ; msgcontext = IstwiRWRequest -> MsgContext ; memset ( IstwiRWRequest , 0 , sizeof ( ToolboxIstwiReadWriteRequest_t ) ) ; IstwiRWRequest -> MsgContext = msgcontext ; IstwiRWRequest -> Function = MPI_FUNCTION_TOOLBOX ; IstwiRWRequest -> Tool = MPI_TOOLBOX_ISTWI_READ_WRITE_TOOL ; IstwiRWRequest -> Flags = MPI_TB_ISTWI_FLAGS_READ ; IstwiRWRequest -> NumAddressBytes = 0x01 ; IstwiRWRequest -> DataLength = cpu_to_le16 ( 0x04 ) ; if ( pdev -> devfn & 1 ) IstwiRWRequest -> DeviceAddr = 0xB2 ; else IstwiRWRequest -> DeviceAddr = 0xB0 ; pbuf = pci_alloc_consistent ( ioc -> pcidev , 4 , & buf_dma ) ; if ( ! pbuf ) goto out ; ioc -> add_sge ( ( char * ) & IstwiRWRequest -> SGL , ( MPT_SGE_FLAGS_SSIMPLE_READ | 4 ) , buf_dma ) ; retval = 0 ; SET_MGMT_MSG_CONTEXT ( ioc -> ioctl_cmds . msg_context , IstwiRWRequest -> MsgContext ) ; INITIALIZE_MGMT_STATUS ( ioc -> ioctl_cmds . status ) mpt_put_msg_frame ( mptctl_id , ioc , mf ) ; retry_wait : timeleft = wait_for_completion_timeout ( & ioc -> ioctl_cmds . done , HZ * MPT_IOCTL_DEFAULT_TIMEOUT ) ; if ( ! ( ioc -> ioctl_cmds . status & MPT_MGMT_STATUS_COMMAND_GOOD ) ) { retval = - ETIME ; printk ( MYIOC_s_WARN_FMT ""%s:failed\\n"" , ioc -> name , __func__ ) ; if ( ioc -> ioctl_cmds . status & MPT_MGMT_STATUS_DID_IOCRESET ) { mpt_free_msg_frame ( ioc , mf ) ; goto out ; } if ( ! timeleft ) { printk ( MYIOC_s_WARN_FMT ""HOSTINFOcommandtimeout,doorbell=0x%08x\\n"" , ioc -> name , mpt_GetIocState ( ioc , 0 ) ) ; mptctl_timeout_expired ( ioc , mf ) ; } else goto retry_wait ; goto out ; } if ( ioc -> ioctl_cmds . status & MPT_MGMT_STATUS_RF_VALID ) karg . rsvd = * ( u32 * ) pbuf ; out : CLEAR_MGMT_STATUS ( ioc -> ioctl_cmds . status ) SET_MGMT_MSG_CONTEXT ( ioc -> ioctl_cmds . msg_context , 0 ) ; if ( pbuf ) pci_free_consistent ( ioc -> pcidev , 4 , pbuf , buf_dma ) ; if ( copy_to_user ( ( char __user * ) arg , & karg , sizeof ( hp_host_info_t ) ) ) { printk ( MYIOC_s_ERR_FMT ""%s@%d::mptctl_hpgethostinfo-"" ""Unabletowriteouthp_host_info@%p\\n"" , ioc -> name , __FILE__ , __LINE__ , uarg ) ; return - EFAULT ; } return 0 ; } "," int mptctl_hp_hostinfo ( MPT_ADAPTER * ioc , ) arg ; struct pci_dev * ; ConfigPageHeader_t hdr ; int rc EFAULT ; } dctlprintk ( ioc ",torvalds@linux/28d76df18f0ad5bcf5fa48510b225f0ed262a99b,CVE-2020-12652,https://github.com/torvalds/linux/commit/28d76df18f0ad5bcf5fa48510b225f0ed262a99b,2020-05-05T05:15Z 1017,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 1018,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 1019,CWE-125,"CWE-125 static int get_debug_info ( struct PE_ ( r_bin_pe_obj_t ) * bin , PE_ ( image_debug_directory_entry ) * dbg_dir_entry , ut8 * dbg_data , int dbg_data_len , SDebugInfo * res ) { # define SIZEOF_FILE_NAME 255 int i = 0 ; const char * basename ; if ( ! dbg_data ) { return 0 ; } switch ( dbg_dir_entry -> Type ) { case IMAGE_DEBUG_TYPE_CODEVIEW : if ( ! strncmp ( ( char * ) dbg_data , ""RSDS"" , 4 ) ) { SCV_RSDS_HEADER rsds_hdr ; init_rsdr_hdr ( & rsds_hdr ) ; if ( ! get_rsds ( dbg_data , dbg_data_len , & rsds_hdr ) ) { bprintf ( ""Warning:CannotreadPEdebuginfo\\n"" ) ; return 0 ; } snprintf ( res -> guidstr , GUIDSTR_LEN , ""%08x%04x%04x%02x%02x%02x%02x%02x%02x%02x%02x%x"" , rsds_hdr . guid . data1 , rsds_hdr . guid . data2 , rsds_hdr . guid . data3 , rsds_hdr . guid . data4 [ 0 ] , rsds_hdr . guid . data4 [ 1 ] , rsds_hdr . guid . data4 [ 2 ] , rsds_hdr . guid . data4 [ 3 ] , rsds_hdr . guid . data4 [ 4 ] , rsds_hdr . guid . data4 [ 5 ] , rsds_hdr . guid . data4 [ 6 ] , rsds_hdr . guid . data4 [ 7 ] , rsds_hdr . age ) ; basename = r_file_basename ( ( char * ) rsds_hdr . file_name ) ; strncpy ( res -> file_name , ( const char * ) basename , sizeof ( res -> file_name ) ) ; res -> file_name [ sizeof ( res -> file_name ) - 1 ] = 0 ; rsds_hdr . free ( ( struct SCV_RSDS_HEADER * ) & rsds_hdr ) ; } else if ( strncmp ( ( const char * ) dbg_data , ""NB10"" , 4 ) == 0 ) { SCV_NB10_HEADER nb10_hdr ; init_cv_nb10_header ( & nb10_hdr ) ; get_nb10 ( dbg_data , & nb10_hdr ) ; snprintf ( res -> guidstr , sizeof ( res -> guidstr ) , ""%x%x"" , nb10_hdr . timestamp , nb10_hdr . age ) ; strncpy ( res -> file_name , ( const char * ) nb10_hdr . file_name , sizeof ( res -> file_name ) - 1 ) ; res -> file_name [ sizeof ( res -> file_name ) - 1 ] = 0 ; nb10_hdr . free ( ( struct SCV_NB10_HEADER * ) & nb10_hdr ) ; } else { bprintf ( ""CodeViewsectionnotNB10orRSDS\\n"" ) ; return 0 ; } break ; default : return 0 ; } while ( i < 33 ) { res -> guidstr [ i ] = toupper ( ( int ) res -> guidstr [ i ] ) ; i ++ ; } return 1 ; } "," 0 ) { if ( dbg_data_len < 20 ) { eprintf ( ""TruncatedNB10entry,notenoughdatatoparse\\n"" ) ; return 0 ; } SCV_NB10_HEADER nb10_hdr = { { 0 } } ; init_cv_nb10_header ( age ) ; res -> file_name [ 0 ] = 0 ; if ( nb10_hdr . file_name ) { 1 ) ; } ",radare@radare2/4e1cf0d3e6f6fe2552a269def0af1cd2403e266c,CVE-2018-11379,https://github.com/radare/radare2/commit/4e1cf0d3e6f6fe2552a269def0af1cd2403e266c,2018-05-22T19:29Z 1020,CWE-399,"CWE-399 static int nlmsg_populate_mdb_fill ( struct sk_buff * skb , struct net_device * dev , struct br_mdb_entry * entry , u32 pid , u32 seq , int type , unsigned int flags ) { struct nlmsghdr * nlh ; struct br_port_msg * bpm ; struct nlattr * nest , * nest2 ; nlh = nlmsg_put ( skb , pid , seq , type , sizeof ( * bpm ) , NLM_F_MULTI ) ; if ( ! nlh ) return - EMSGSIZE ; bpm = nlmsg_data ( nlh ) ; bpm -> family = AF_BRIDGE ; bpm -> ifindex = dev -> ifindex ; nest = nla_nest_start ( skb , MDBA_MDB ) ; if ( nest == NULL ) goto cancel ; nest2 = nla_nest_start ( skb , MDBA_MDB_ENTRY ) ; if ( nest2 == NULL ) goto end ; if ( nla_put ( skb , MDBA_MDB_ENTRY_INFO , sizeof ( * entry ) , entry ) ) goto end ; nla_nest_end ( skb , nest2 ) ; nla_nest_end ( skb , nest ) ; return nlmsg_end ( skb , nlh ) ; end : nla_nest_end ( skb , nest ) ; cancel : nlmsg_cancel ( skb , nlh ) ; return - EMSGSIZE ; } "," nlh ) ; memset ( bpm , 0 , sizeof ( * bpm ) ) ; ",torvalds@linux/c085c49920b2f900ba716b4ca1c1a55ece9872cc,CVE-2013-2636,https://github.com/torvalds/linux/commit/c085c49920b2f900ba716b4ca1c1a55ece9872cc,2013-03-22T11:59Z 1021,CWE-400,"CWE-400 asmlinkage void do_ade ( struct pt_regs * regs ) { unsigned int __user * pc ; mm_segment_t seg ; perf_sw_event ( PERF_COUNT_SW_ALIGNMENT_FAULTS , 1 , 0 , regs , regs -> cp0_badvaddr ) ; if ( ( regs -> cp0_badvaddr == regs -> cp0_epc ) || ( regs -> cp0_epc & 0x1 ) ) goto sigbus ; pc = ( unsigned int __user * ) exception_epc ( regs ) ; if ( user_mode ( regs ) && ! test_thread_flag ( TIF_FIXADE ) ) goto sigbus ; if ( unaligned_action == UNALIGNED_ACTION_SIGNAL ) goto sigbus ; else if ( unaligned_action == UNALIGNED_ACTION_SHOW ) show_registers ( regs ) ; seg = get_fs ( ) ; if ( ! user_mode ( regs ) ) set_fs ( KERNEL_DS ) ; emulate_load_store_insn ( regs , ( void __user * ) regs -> cp0_badvaddr , pc ) ; set_fs ( seg ) ; return ; sigbus : die_if_kernel ( ""Kernelunalignedinstructionaccess"" , regs ) ; force_sig ( SIGBUS , current ) ; } "," PERF_COUNT_SW_ALIGNMENT_FAULTS , 1 , regs , ",torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,CVE-2011-2918,https://github.com/torvalds/linux/commit/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,2012-05-24T23:55Z 1022,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 1023,CWE-119,"CWE-119 static struct VP8D_COMP * create_decompressor ( VP8D_CONFIG * oxcf ) { VP8D_COMP * pbi = vpx_memalign ( 32 , sizeof ( VP8D_COMP ) ) ; if ( ! pbi ) return NULL ; vpx_memset ( pbi , 0 , sizeof ( VP8D_COMP ) ) ; if ( setjmp ( pbi -> common . error . jmp ) ) { pbi -> common . error . setjmp = 0 ; remove_decompressor ( pbi ) ; return 0 ; } pbi -> common . error . setjmp = 1 ; vp8_create_common ( & pbi -> common ) ; pbi -> common . current_video_frame = 0 ; pbi -> ready_for_new_data = 1 ; vp8cx_init_de_quantizer ( pbi ) ; vp8_loop_filter_init ( & pbi -> common ) ; pbi -> common . error . setjmp = 0 ; # if CONFIG_ERROR_CONCEALMENT pbi -> ec_enabled = oxcf -> error_concealment ; pbi -> overlaps = NULL ; # else pbi -> ec_enabled = 0 ; # endif pbi -> ec_active = 0 ; pbi -> decoded_key_frame = 0 ; pbi -> independent_partitions = 0 ; vp8_setup_block_dptrs ( & pbi -> mb ) ; return pbi ; } "," return NULL ; memset ( pbi , ; # else ( void ) oxcf ; ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1024,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 ) { copy_file ( ""/etc/skel/.zshrc"" , fname , u , g , 0644 ) ; fs_logger ( ""clone/etc/skel/.zshrc"" ) ; } else { touch_file_as_user ( fname , u , g , 0644 ) ; 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 ) { copy_file ( ""/etc/skel/.cshrc"" , fname , u , g , 0644 ) ; fs_logger ( ""clone/etc/skel/.cshrc"" ) ; } else { touch_file_as_user ( fname , u , g , 0644 ) ; 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 ) { copy_file ( ""/etc/skel/.bashrc"" , fname , u , g , 0644 ) ; fs_logger ( ""clone/etc/skel/.bashrc"" ) ; } free ( fname ) ; } } "," ; if ( is_link ( fname ) ) { fprintf ( stderr , ""Error:invalid%sfile\\n"" , fname ) ; exit ( 1 ) ; } if ( 0 ) { copy_file_as_user ( ""/etc/skel/.zshrc"" , ; if ( is_link ( fname ) ) { fprintf ( stderr , ""Error:invalid%sfile\\n"" , fname ) ; exit ( 1 ) ; } if ( 0 ) { copy_file_as_user ( ""/etc/skel/.cshrc"" , ; if ( is_link ( fname ) ) { fprintf ( stderr , ""Error:invalid%sfile\\n"" , fname ) ; exit ( 1 ) ; } if ( 0 ) { copy_file_as_user ( ""/etc/skel/.bashrc"" , ",netblue30@firejail/38d418505e9ee2d326557e5639e8da49c298858f,CVE-2017-5940,https://github.com/netblue30/firejail/commit/38d418505e9ee2d326557e5639e8da49c298858f,2017-02-09T18:59Z 1025,CWE-59,"CWE-59 rpmVerifyAttrs rpmfilesVerify ( rpmfiles fi , int ix , rpmVerifyAttrs omitMask ) { rpm_mode_t fmode = rpmfilesFMode ( fi , ix ) ; rpmfileAttrs fileAttrs = rpmfilesFFlags ( fi , ix ) ; rpmVerifyAttrs flags = rpmfilesVFlags ( fi , ix ) ; const char * fn = rpmfilesFN ( fi , ix ) ; struct stat sb ; rpmVerifyAttrs vfy = RPMVERIFY_NONE ; switch ( rpmfilesFState ( fi , ix ) ) { case RPMFILE_STATE_NETSHARED : case RPMFILE_STATE_NOTINSTALLED : goto exit ; break ; case RPMFILE_STATE_REPLACED : flags = RPMVERIFY_LSTATFAIL ; break ; case RPMFILE_STATE_WRONGCOLOR : flags &= ~ ( RPMVERIFY_FILEDIGEST | RPMVERIFY_FILESIZE | RPMVERIFY_MTIME | RPMVERIFY_RDEV ) ; break ; case RPMFILE_STATE_NORMAL : case RPMFILE_STATE_MISSING : break ; } if ( fn == NULL || lstat ( fn , & sb ) != 0 ) { vfy |= RPMVERIFY_LSTATFAIL ; goto exit ; } if ( S_ISDIR ( fmode ) && S_ISLNK ( sb . st_mode ) && stat ( fn , & sb ) != 0 ) { vfy |= RPMVERIFY_LSTATFAIL ; goto exit ; } if ( S_ISLNK ( sb . st_mode ) ) flags &= ~ ( RPMVERIFY_MODE ) ; else flags &= ~ ( RPMVERIFY_LINKTO ) ; if ( ! S_ISREG ( sb . st_mode ) ) flags &= ~ ( RPMVERIFY_FILEDIGEST | RPMVERIFY_FILESIZE | RPMVERIFY_MTIME | RPMVERIFY_CAPS ) ; if ( fileAttrs & RPMFILE_GHOST ) flags &= ~ ( RPMVERIFY_FILEDIGEST | RPMVERIFY_FILESIZE | RPMVERIFY_MTIME | RPMVERIFY_LINKTO ) ; flags &= ~ ( omitMask | RPMVERIFY_FAILURES ) ; if ( flags & RPMVERIFY_FILEDIGEST ) { const unsigned char * digest ; int algo ; size_t diglen ; if ( ( digest = rpmfilesFDigest ( fi , ix , & algo , & diglen ) ) ) { unsigned char fdigest [ diglen ] ; rpm_loff_t fsize ; if ( rpmDoDigest ( algo , fn , 0 , fdigest , & fsize ) ) { vfy |= ( RPMVERIFY_READFAIL | RPMVERIFY_FILEDIGEST ) ; } else { sb . st_size = fsize ; if ( memcmp ( fdigest , digest , diglen ) ) vfy |= RPMVERIFY_FILEDIGEST ; } } else { vfy |= RPMVERIFY_FILEDIGEST ; } } if ( flags & RPMVERIFY_LINKTO ) { char linkto [ 1024 + 1 ] ; int size = 0 ; if ( ( size = readlink ( fn , linkto , sizeof ( linkto ) - 1 ) ) == - 1 ) vfy |= ( RPMVERIFY_READLINKFAIL | RPMVERIFY_LINKTO ) ; else { const char * flink = rpmfilesFLink ( fi , ix ) ; linkto [ size ] = '\\0' ; if ( flink == NULL || ! rstreq ( linkto , flink ) ) vfy |= RPMVERIFY_LINKTO ; } } if ( flags & RPMVERIFY_FILESIZE ) { if ( sb . st_size != rpmfilesFSize ( fi , ix ) ) vfy |= RPMVERIFY_FILESIZE ; } if ( flags & RPMVERIFY_MODE ) { rpm_mode_t metamode = fmode ; rpm_mode_t filemode ; filemode = ( rpm_mode_t ) sb . st_mode ; if ( fileAttrs & RPMFILE_GHOST ) { metamode &= ~ 0xf000 ; filemode &= ~ 0xf000 ; } if ( metamode != filemode ) vfy |= RPMVERIFY_MODE ; # if WITH_ACL acl_t facl = acl_get_file ( fn , ACL_TYPE_ACCESS ) ; if ( facl ) { if ( acl_equiv_mode ( facl , NULL ) == 1 ) { vfy |= RPMVERIFY_MODE ; } acl_free ( facl ) ; } # endif } if ( flags & RPMVERIFY_RDEV ) { if ( S_ISCHR ( fmode ) != S_ISCHR ( sb . st_mode ) || S_ISBLK ( fmode ) != S_ISBLK ( sb . st_mode ) ) { vfy |= RPMVERIFY_RDEV ; } else if ( S_ISDEV ( fmode ) && S_ISDEV ( sb . st_mode ) ) { rpm_rdev_t st_rdev = ( sb . st_rdev & 0xffff ) ; rpm_rdev_t frdev = ( rpmfilesFRdev ( fi , ix ) & 0xffff ) ; if ( st_rdev != frdev ) vfy |= RPMVERIFY_RDEV ; } } # if WITH_CAP if ( flags & RPMVERIFY_CAPS ) { cap_t cap , fcap ; cap = cap_from_text ( rpmfilesFCaps ( fi , ix ) ) ; if ( ! cap ) { cap = cap_from_text ( ""="" ) ; } fcap = cap_get_file ( fn ) ; if ( ! fcap ) { fcap = cap_from_text ( ""="" ) ; } if ( cap_compare ( cap , fcap ) != 0 ) vfy |= RPMVERIFY_CAPS ; cap_free ( fcap ) ; cap_free ( cap ) ; } # endif if ( ( flags & RPMVERIFY_MTIME ) && ( sb . st_mtime != rpmfilesFMtime ( fi , ix ) ) ) { vfy |= RPMVERIFY_MTIME ; } if ( flags & RPMVERIFY_USER ) { const char * name = rpmugUname ( sb . st_uid ) ; const char * fuser = rpmfilesFUser ( fi , ix ) ; uid_t uid ; int namematch = 0 ; int idmatch = 0 ; if ( name && fuser ) namematch = rstreq ( name , fuser ) ; if ( fuser && rpmugUid ( fuser , & uid ) == 0 ) idmatch = ( uid == sb . st_uid ) ; if ( namematch != idmatch ) { rpmlog ( RPMLOG_WARNING , _ ( ""DuplicateusernameorUIDforuser%s\\n"" ) , fuser ) ; } if ( ! ( namematch || idmatch ) ) vfy |= RPMVERIFY_USER ; } if ( flags & RPMVERIFY_GROUP ) { const char * name = rpmugGname ( sb . st_gid ) ; const char * fgroup = rpmfilesFGroup ( fi , ix ) ; gid_t gid ; int namematch = 0 ; int idmatch = 0 ; if ( name && fgroup ) namematch = rstreq ( name , fgroup ) ; if ( fgroup && rpmugGid ( fgroup , & gid ) == 0 ) idmatch = ( gid == sb . st_gid ) ; if ( namematch != idmatch ) { rpmlog ( RPMLOG_WARNING , _ ( ""DuplicategroupnameorGIDforgroup%s\\n"" ) , fgroup ) ; } if ( ! ( namematch || idmatch ) ) vfy |= RPMVERIFY_GROUP ; } exit : return vfy ; } "," . st_mode ) ) { struct stat dsb ; if ( stat ( fn , & dsb ) == 0 && S_ISDIR ( dsb . st_mode ) ) { uid_t fuid ; if ( sb . st_uid == 0 || ( rpmugUid ( rpmfilesFUser ( fi , ix ) , & fuid ) == 0 && sb . st_uid == fuid ) ) { sb = dsb ; } } } if ( ",rpm-software-management@rpm/c815822c8bdb138066ff58c624ae83e3a12ebfa9,CVE-2017-7500,https://github.com/rpm-software-management/rpm/commit/c815822c8bdb138066ff58c624ae83e3a12ebfa9,2018-08-13T17:29Z 1026,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 1027,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 ; if ( _PyObject_LookupAttrId ( 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 len ; Py_ssize_t i ; 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 = _Py_asdl_seq_new ( len , arena ) ; if ( body == NULL ) goto failed ; for ( i = 0 ; i < len ; i ++ ) { stmt_ty val ; res = obj2ast_stmt ( PyList_GET_ITEM ( tmp , i ) , & val , 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 , val ) ; } Py_CLEAR ( tmp ) ; } * out = Module ( body , 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_LookupAttrId ( 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 len ; Py_ssize_t i ; 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 = _Py_asdl_seq_new ( len , arena ) ; if ( body == NULL ) goto failed ; for ( i = 0 ; i < len ; i ++ ) { stmt_ty val ; res = obj2ast_stmt ( PyList_GET_ITEM ( tmp , i ) , & val , 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 , val ) ; } Py_CLEAR ( tmp ) ; } * 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_LookupAttrId ( obj , & PyId_body , & tmp ) < 0 ) { return 1 ; } if ( tmp == NULL ) { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""body\\""missingfromExpression"" ) ; return 1 ; } else { int res ; res = obj2ast_expr ( tmp , & body , arena ) ; if ( res != 0 ) goto failed ; Py_CLEAR ( tmp ) ; } * out = Expression ( body , 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_LookupAttrId ( obj , & PyId_body , & tmp ) < 0 ) { return 1 ; } if ( tmp == NULL ) { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""body\\""missingfromSuite"" ) ; return 1 ; } else { int res ; Py_ssize_t len ; Py_ssize_t i ; 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 = _Py_asdl_seq_new ( len , arena ) ; if ( body == NULL ) goto failed ; for ( i = 0 ; i < len ; i ++ ) { stmt_ty val ; res = obj2ast_stmt ( PyList_GET_ITEM ( tmp , i ) , & val , 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 , val ) ; } Py_CLEAR ( tmp ) ; } * 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 ; } "," asdl_seq * body ; asdl_seq * type_ignores ) ; } if ( _PyObject_LookupAttrId ( obj , ( obj , & PyId_type_ignores , & tmp ( PyExc_TypeError , ""requiredfield\\""type_ignores\\""missingfromModule"" ) ; return ( PyExc_TypeError , ""Modulefield\\""type_ignores\\""mustbealist,nota%.200s"" , tmp -> tmp ) ; type_ignores = _Py_asdl_seq_new ( ; if ( type_ignores == NULL ) ++ ) { type_ignore_ty val ; res ; res = obj2ast_type_ignore ( PyList_GET_ITEM ( ( PyExc_RuntimeError , ""Modulefield\\""type_ignores\\""changedsizeduringiteration"" ) ; goto } asdl_seq_SET ( type_ignores , i , * out = Module ( body , type_ignores , arena ) PyObject * ) Interactive_type ) ; if isinstance ) { asdl_seq * body ; if ( PyExc_TypeError , ""requiredfield\\""body\\""missingfromInteractive"" ) ; return ( PyExc_TypeError , ""Interactivefield\\""body\\""mustbealist,nota%.200s"" , tmp -> ( PyExc_RuntimeError , ""Interactivefield\\""body\\""changedsizeduringiteration"" ) ; goto failed ; } asdl_seq_SET ( body , i , val ) ; } Py_CLEAR ( tmp ) ; } * 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_LookupAttrId ( obj , & PyId_body , & tmp ) < 0 ) { return 1 ; } if ( tmp == NULL ) { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""body\\""missingfromExpression"" ) ; return 1 ; } else { int res ; res = obj2ast_expr ( tmp , & body , arena ) ; if ( res != 0 ) goto failed ; Py_CLEAR ( tmp ) ; } * 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_LookupAttrId ( 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 len ; Py_ssize_t i ; 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 = _Py_asdl_seq_new ( len , arena ) ; if ( argtypes == NULL ) goto failed ; for ( i = 0 ; i < len ; i ++ ) { expr_ty val ; res = obj2ast_expr ( PyList_GET_ITEM ( tmp , i ) , & val , 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 , val ) ; } Py_CLEAR ( tmp ) ; } if ( _PyObject_LookupAttrId ( 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 ( _PyObject_LookupAttrId ( obj , & PyId_body , & tmp ) < 0 ) { return 1 ; } if ( tmp == NULL ) { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""body\\""missingfromSuite"" ) ; return 1 ; } else { int res ; Py_ssize_t len ; Py_ssize_t i ; 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 = _Py_asdl_seq_new ( len , arena ) ; if ( body == NULL ) goto failed ; for ( i = 0 ; i < len ; i ++ ) { stmt_ty val ; res = obj2ast_stmt ( PyList_GET_ITEM ( tmp , i ) , & val , arena ) ; if ( res != 0 ) goto failed ; if ( len != PyList_GET_SIZE ( tmp ) ) { PyErr_SetString ( PyExc_RuntimeError , ",python@typed_ast/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,CVE-2019-19275,https://github.com/python/typed_ast/commit/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,2019-11-26T15:15Z 1028,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 1029,CWE-362,"CWE-362 fm_mgr_config_errno_t fm_mgr_config_init ( OUT p_fm_config_conx_hdlt * p_hdl , IN int instance , OPTIONAL IN char * rem_address , OPTIONAL IN char * community ) { fm_config_conx_hdl * hdl ; fm_mgr_config_errno_t res = FM_CONF_OK ; if ( ( hdl = calloc ( 1 , sizeof ( fm_config_conx_hdl ) ) ) == NULL ) { res = FM_CONF_NO_MEM ; goto cleanup ; } hdl -> instance = instance ; * p_hdl = hdl ; if ( ! rem_address || ( strcmp ( rem_address , ""localhost"" ) == 0 ) ) { if ( fm_mgr_config_mgr_connect ( hdl , FM_MGR_SM ) == FM_CONF_INIT_ERR ) { res = FM_CONF_INIT_ERR ; goto cleanup ; } if ( fm_mgr_config_mgr_connect ( hdl , FM_MGR_PM ) == FM_CONF_INIT_ERR ) { res = FM_CONF_INIT_ERR ; goto cleanup ; } if ( fm_mgr_config_mgr_connect ( hdl , FM_MGR_FE ) == FM_CONF_INIT_ERR ) { res = FM_CONF_INIT_ERR ; goto cleanup ; } } return res ; cleanup : if ( hdl ) { free ( hdl ) ; hdl = NULL ; } return res ; } "," ; } } cleanup : return res ; ",01org@opa-fm/c5759e7b76f5bf844be6c6641cc1b356bbc83869,CVE-2015-5232,https://github.com/01org/opa-fm/commit/c5759e7b76f5bf844be6c6641cc1b356bbc83869,2017-06-07T20:29Z 1030,CWE-190,"CWE-190 static inline void process_get_command ( conn * c , token_t * tokens , size_t ntokens , bool return_cas ) { char * key ; size_t nkey ; int i = 0 ; item * it ; token_t * key_token = & tokens [ KEY_TOKEN ] ; char * suffix ; assert ( c != NULL ) ; do { while ( key_token -> length != 0 ) { key = key_token -> value ; nkey = key_token -> length ; if ( nkey > KEY_MAX_LENGTH ) { out_string ( c , ""CLIENT_ERRORbadcommandlineformat"" ) ; while ( i -- > 0 ) { item_remove ( * ( c -> ilist + i ) ) ; } return ; } it = item_get ( key , nkey , c , DO_UPDATE ) ; if ( settings . detail_enabled ) { stats_prefix_record_get ( key , nkey , NULL != it ) ; } if ( it ) { if ( i >= c -> isize ) { item * * new_list = realloc ( c -> ilist , sizeof ( item * ) * c -> isize * 2 ) ; if ( new_list ) { c -> isize *= 2 ; c -> ilist = new_list ; } else { STATS_LOCK ( ) ; stats . malloc_fails ++ ; STATS_UNLOCK ( ) ; item_remove ( it ) ; break ; } } if ( return_cas || ! settings . inline_ascii_response ) { MEMCACHED_COMMAND_GET ( c -> sfd , ITEM_key ( it ) , it -> nkey , it -> nbytes , ITEM_get_cas ( it ) ) ; if ( i >= c -> suffixsize ) { char * * new_suffix_list = realloc ( c -> suffixlist , sizeof ( char * ) * c -> suffixsize * 2 ) ; if ( new_suffix_list ) { c -> suffixsize *= 2 ; c -> suffixlist = new_suffix_list ; } else { STATS_LOCK ( ) ; stats . malloc_fails ++ ; STATS_UNLOCK ( ) ; item_remove ( it ) ; break ; } } suffix = do_cache_alloc ( c -> thread -> suffix_cache ) ; if ( suffix == NULL ) { STATS_LOCK ( ) ; stats . malloc_fails ++ ; STATS_UNLOCK ( ) ; out_of_memory ( c , ""SERVER_ERRORoutofmemorymakingCASsuffix"" ) ; item_remove ( it ) ; while ( i -- > 0 ) { item_remove ( * ( c -> ilist + i ) ) ; } return ; } * ( c -> suffixlist + i ) = suffix ; int suffix_len = make_ascii_get_suffix ( suffix , it , return_cas ) ; if ( add_iov ( c , ""VALUE"" , 6 ) != 0 || add_iov ( c , ITEM_key ( it ) , it -> nkey ) != 0 || ( settings . inline_ascii_response && add_iov ( c , ITEM_suffix ( it ) , it -> nsuffix - 2 ) != 0 ) || add_iov ( c , suffix , suffix_len ) != 0 ) { item_remove ( it ) ; break ; } if ( ( it -> it_flags & ITEM_CHUNKED ) == 0 ) { add_iov ( c , ITEM_data ( it ) , it -> nbytes ) ; } else if ( add_chunked_item_iovs ( c , it , it -> nbytes ) != 0 ) { item_remove ( it ) ; break ; } } else { MEMCACHED_COMMAND_GET ( c -> sfd , ITEM_key ( it ) , it -> nkey , it -> nbytes , ITEM_get_cas ( it ) ) ; if ( add_iov ( c , ""VALUE"" , 6 ) != 0 || add_iov ( c , ITEM_key ( it ) , it -> nkey ) != 0 ) { item_remove ( it ) ; break ; } if ( ( it -> it_flags & ITEM_CHUNKED ) == 0 ) { if ( add_iov ( c , ITEM_suffix ( it ) , it -> nsuffix + it -> nbytes ) != 0 ) { item_remove ( it ) ; break ; } } else if ( add_iov ( c , ITEM_suffix ( it ) , it -> nsuffix ) != 0 || add_chunked_item_iovs ( c , it , it -> nbytes ) != 0 ) { item_remove ( it ) ; break ; } } if ( settings . verbose > 1 ) { int ii ; fprintf ( stderr , "">%dsendingkey"" , c -> sfd ) ; for ( ii = 0 ; ii < it -> nkey ; ++ ii ) { fprintf ( stderr , ""%c"" , key [ ii ] ) ; } fprintf ( stderr , ""\\n"" ) ; } pthread_mutex_lock ( & c -> thread -> stats . mutex ) ; c -> thread -> stats . slab_stats [ ITEM_clsid ( it ) ] . get_hits ++ ; c -> thread -> stats . get_cmds ++ ; pthread_mutex_unlock ( & c -> thread -> stats . mutex ) ; * ( c -> ilist + i ) = it ; i ++ ; } else { pthread_mutex_lock ( & c -> thread -> stats . mutex ) ; c -> thread -> stats . get_misses ++ ; c -> thread -> stats . get_cmds ++ ; pthread_mutex_unlock ( & c -> thread -> stats . mutex ) ; MEMCACHED_COMMAND_GET ( c -> sfd , key , nkey , - 1 , 0 ) ; } key_token ++ ; } if ( key_token -> value != NULL ) { ntokens = tokenize_command ( key_token -> value , tokens , MAX_TOKENS ) ; key_token = tokens ; } } while ( key_token -> value != NULL ) ; c -> icurr = c -> ilist ; c -> ileft = i ; if ( return_cas || ! settings . inline_ascii_response ) { c -> suffixcurr = c -> suffixlist ; c -> suffixleft = i ; } if ( settings . verbose > 1 ) fprintf ( stderr , "">%dEND\\n"" , c -> sfd ) ; if ( key_token -> value != NULL || add_iov ( c , ""END\\r\\n"" , 5 ) != 0 || ( IS_UDP ( c -> transport ) && build_udp_headers ( c ) != 0 ) ) { out_of_memory ( c , ""SERVER_ERRORoutofmemorywritinggetresponse"" ) ; } else { conn_set_state ( c , conn_mwrite ) ; c -> msgcurr = 0 ; } } "," } it = limited_get ( key , nkey , c ) ; if ",memcached@memcached/a8c4a82787b8b6c256d61bd5c42fb7f92d1bae00,CVE-2018-1000127,https://github.com/memcached/memcached/commit/a8c4a82787b8b6c256d61bd5c42fb7f92d1bae00,2018-03-13T21:29Z 1031,CWE-362,"CWE-362 static long ec_device_ioctl_xcmd ( struct cros_ec_dev * ec , void __user * arg ) { long ret ; struct cros_ec_command u_cmd ; struct cros_ec_command * s_cmd ; if ( copy_from_user ( & u_cmd , arg , sizeof ( u_cmd ) ) ) return - EFAULT ; if ( ( u_cmd . outsize > EC_MAX_MSG_BYTES ) || ( u_cmd . insize > EC_MAX_MSG_BYTES ) ) return - EINVAL ; s_cmd = kmalloc ( sizeof ( * s_cmd ) + max ( u_cmd . outsize , u_cmd . insize ) , GFP_KERNEL ) ; if ( ! s_cmd ) return - ENOMEM ; if ( copy_from_user ( s_cmd , arg , sizeof ( * s_cmd ) + u_cmd . outsize ) ) { ret = - EFAULT ; goto exit ; } s_cmd -> command += ec -> cmd_offset ; ret = cros_ec_cmd_xfer ( ec -> ec_dev , s_cmd ) ; if ( ret < 0 ) goto exit ; if ( copy_to_user ( arg , s_cmd , sizeof ( * s_cmd ) + u_cmd . insize ) ) ret = - EFAULT ; exit : kfree ( s_cmd ) ; return ret ; } "," exit ; } if ( u_cmd . outsize != s_cmd -> outsize || u_cmd . insize != s_cmd -> insize ) { ret = - EINVAL ; goto exit ; } s_cmd ) + s_cmd -> insize ) ) ",torvalds@linux/096cdc6f52225835ff503f987a0d68ef770bb78e,CVE-2016-6156,https://github.com/torvalds/linux/commit/096cdc6f52225835ff503f987a0d68ef770bb78e,2016-08-06T20:59Z 1032,CWE-125,"CWE-125 u_int chdlc_print ( netdissect_options * ndo , register const u_char * p , u_int length ) { u_int proto ; proto = EXTRACT_16BITS ( & p [ 2 ] ) ; if ( ndo -> ndo_eflag ) { ND_PRINT ( ( ndo , ""%s,ethertype%s(0x%04x),length%u:"" , tok2str ( chdlc_cast_values , ""0x%02x"" , p [ 0 ] ) , tok2str ( ethertype_values , ""Unknown"" , proto ) , proto , length ) ) ; } length -= CHDLC_HDRLEN ; p += CHDLC_HDRLEN ; switch ( proto ) { case ETHERTYPE_IP : ip_print ( ndo , p , length ) ; break ; case ETHERTYPE_IPV6 : ip6_print ( ndo , p , length ) ; break ; case CHDLC_TYPE_SLARP : chdlc_slarp_print ( ndo , p , length ) ; break ; # if 0 case CHDLC_TYPE_CDP : chdlc_cdp_print ( p , length ) ; break ; # endif case ETHERTYPE_MPLS : case ETHERTYPE_MPLS_MULTI : mpls_print ( ndo , p , length ) ; break ; case ETHERTYPE_ISO : if ( * ( p + 1 ) == 0x81 || * ( p + 1 ) == 0x82 || * ( p + 1 ) == 0x83 ) isoclns_print ( ndo , p + 1 , length - 1 , ndo -> ndo_snapend - p - 1 ) ; else isoclns_print ( ndo , p , length , ndo -> ndo_snapend - p ) ; break ; default : if ( ! ndo -> ndo_eflag ) ND_PRINT ( ( ndo , ""unknownCHDLCprotocol(0x%04x)"" , proto ) ) ; break ; } return ( CHDLC_HDRLEN ) ; } "," u_int proto ; const u_char * bp = p ; if ( length < CHDLC_HDRLEN ) goto trunc ; ND_TCHECK2 ( * p , CHDLC_HDRLEN ) ; : if ( length < 2 ) goto trunc ; ND_TCHECK_16BITS ( p ) ; if ( CHDLC_HDRLEN ) ; trunc : ND_PRINT ( ( ndo , ""[|chdlc]"" ) ) ; return ndo -> ndo_snapend - bp ; ",the-tcpdump-group@tcpdump/a1eefe986065846b6c69dbc09afd9fa1a02c4a3d,CVE-2017-13687,https://github.com/the-tcpdump-group/tcpdump/commit/a1eefe986065846b6c69dbc09afd9fa1a02c4a3d,2017-09-14T06:29Z 1033,CWE-295,"CWE-295 NOEXPORT char * parse_service_option ( CMD cmd , SERVICE_OPTIONS * * section_ptr , char * opt , char * arg ) { SERVICE_OPTIONS * section ; int endpoints = 0 ; # ifndef USE_WIN32 struct group * gr ; struct passwd * pw ; # endif section = section_ptr ? * section_ptr : NULL ; if ( cmd == CMD_SET_DEFAULTS || cmd == CMD_SET_COPY ) { section -> ref = 1 ; } else if ( cmd == CMD_FREE ) { if ( section == & service_options || section == & new_service_options ) s_log ( LOG_DEBUG , ""Deallocatingsectiondefaults"" ) ; else s_log ( LOG_DEBUG , ""Deallocatingsection[%s]"" , section -> servname ) ; } else if ( cmd == CMD_PRINT_DEFAULTS || cmd == CMD_PRINT_HELP ) { s_log ( LOG_NOTICE , """" ) ; s_log ( LOG_NOTICE , ""Service-leveloptions:"" ) ; } switch ( cmd ) { case CMD_SET_DEFAULTS : addrlist_clear ( & section -> local_addr , 1 ) ; section -> local_fd = NULL ; break ; case CMD_SET_COPY : addrlist_clear ( & section -> local_addr , 1 ) ; section -> local_fd = NULL ; name_list_dup ( & section -> local_addr . names , new_service_options . local_addr . names ) ; break ; case CMD_FREE : name_list_free ( section -> local_addr . names ) ; str_free ( section -> local_addr . addr ) ; str_free ( section -> local_fd ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""accept"" ) ) break ; section -> option . accept = 1 ; name_list_append ( & section -> local_addr . names , arg ) ; return NULL ; case CMD_INITIALIZE : if ( section -> local_addr . names ) { unsigned i ; if ( ! addrlist_resolve ( & section -> local_addr ) ) return ""Cannotresolveaccepttarget"" ; section -> local_fd = str_alloc_detached ( section -> local_addr . num * sizeof ( SOCKET ) ) ; for ( i = 0 ; i < section -> local_addr . num ; ++ i ) section -> local_fd [ i ] = INVALID_SOCKET ; ++ endpoints ; } break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=[host:]portacceptconnectionsonspecifiedhost:port"" , ""accept"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : # if 0 section -> ca_dir = ( char * ) X509_get_default_cert_dir ( ) ; # endif section -> ca_dir = NULL ; break ; case CMD_SET_COPY : section -> ca_dir = str_dup_detached ( new_service_options . ca_dir ) ; break ; case CMD_FREE : str_free ( section -> ca_dir ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""CApath"" ) ) break ; str_free ( section -> ca_dir ) ; if ( arg [ 0 ] ) section -> ca_dir = str_dup_detached ( arg ) ; else section -> ca_dir = NULL ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : # if 0 s_log ( LOG_NOTICE , ""%-22s=%s"" , ""CApath"" , section -> ca_dir ? section -> ca_dir : ""(none)"" ) ; # endif break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=CAcertificatedirectoryfor\'verify\'option"" , ""CApath"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : # if 0 section -> ca_file = ( char * ) X509_get_default_certfile ( ) ; # endif section -> ca_file = NULL ; break ; case CMD_SET_COPY : section -> ca_file = str_dup_detached ( new_service_options . ca_file ) ; break ; case CMD_FREE : str_free ( section -> ca_file ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""CAfile"" ) ) break ; str_free ( section -> ca_file ) ; if ( arg [ 0 ] ) section -> ca_file = str_dup_detached ( arg ) ; else section -> ca_file = NULL ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : # if 0 s_log ( LOG_NOTICE , ""%-22s=%s"" , ""CAfile"" , section -> ca_file ? section -> ca_file : ""(none)"" ) ; # endif break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=CAcertificatefilefor\'verify\'option"" , ""CAfile"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> cert = NULL ; break ; case CMD_SET_COPY : section -> cert = str_dup_detached ( new_service_options . cert ) ; break ; case CMD_FREE : str_free ( section -> cert ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""cert"" ) ) break ; str_free ( section -> cert ) ; section -> cert = str_dup_detached ( arg ) ; return NULL ; case CMD_INITIALIZE : # ifndef OPENSSL_NO_PSK if ( section -> psk_keys ) break ; # endif # ifndef OPENSSL_NO_ENGINE if ( section -> engine ) break ; # endif if ( ! section -> option . client && ! section -> cert ) return ""TLSserverneedsacertificate"" ; break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=certificatechain"" , ""cert"" ) ; break ; } # if OPENSSL_VERSION_NUMBER >= 0x10002000L switch ( cmd ) { case CMD_SET_DEFAULTS : section -> check_email = NULL ; break ; case CMD_SET_COPY : name_list_dup ( & section -> check_email , new_service_options . check_email ) ; break ; case CMD_FREE : name_list_free ( section -> check_email ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""checkEmail"" ) ) break ; name_list_append ( & section -> check_email , arg ) ; return NULL ; case CMD_INITIALIZE : if ( section -> check_email && ! section -> option . verify_chain && ! section -> option . verify_peer ) return ""Either\\""verifyChain\\""or\\""verifyPeer\\""hastobeenabled"" ; break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=peercertificateemailaddress"" , ""checkEmail"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> check_host = NULL ; break ; case CMD_SET_COPY : name_list_dup ( & section -> check_host , new_service_options . check_host ) ; break ; case CMD_FREE : name_list_free ( section -> check_host ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""checkHost"" ) ) break ; name_list_append ( & section -> check_host , arg ) ; return NULL ; case CMD_INITIALIZE : if ( section -> check_host && ! section -> option . verify_chain && ! section -> option . verify_peer ) return ""Either\\""verifyChain\\""or\\""verifyPeer\\""hastobeenabled"" ; break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=peercertificatehostnamepattern"" , ""checkHost"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> check_ip = NULL ; break ; case CMD_SET_COPY : name_list_dup ( & section -> check_ip , new_service_options . check_ip ) ; break ; case CMD_FREE : name_list_free ( section -> check_ip ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""checkIP"" ) ) break ; name_list_append ( & section -> check_ip , arg ) ; return NULL ; case CMD_INITIALIZE : if ( section -> check_ip && ! section -> option . verify_chain && ! section -> option . verify_peer ) return ""Either\\""verifyChain\\""or\\""verifyPeer\\""hastobeenabled"" ; break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=peercertificateIPaddress"" , ""checkIP"" ) ; break ; } # endif switch ( cmd ) { case CMD_SET_DEFAULTS : section -> cipher_list = NULL ; break ; case CMD_SET_COPY : section -> cipher_list = str_dup_detached ( new_service_options . cipher_list ) ; break ; case CMD_FREE : str_free ( section -> cipher_list ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""ciphers"" ) ) break ; str_free ( section -> cipher_list ) ; section -> cipher_list = str_dup_detached ( arg ) ; return NULL ; case CMD_INITIALIZE : if ( ! section -> cipher_list ) { # ifdef USE_FIPS if ( new_global_options . option . fips ) section -> cipher_list = str_dup_detached ( ""FIPS"" ) ; else # endif section -> cipher_list = str_dup_detached ( stunnel_cipher_list ) ; } break ; case CMD_PRINT_DEFAULTS : # ifdef USE_FIPS s_log ( LOG_NOTICE , ""%-22s=%s%s"" , ""ciphers"" , ""FIPS"" , ""(with\\""fips=yes\\"")"" ) ; s_log ( LOG_NOTICE , ""%-22s=%s%s"" , ""ciphers"" , stunnel_cipher_list , ""(with\\""fips=no\\"")"" ) ; # else s_log ( LOG_NOTICE , ""%-22s=%s"" , ""ciphers"" , stunnel_cipher_list ) ; # endif break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=permittedciphersforTLS1.2orolder"" , ""ciphers"" ) ; break ; } # ifndef OPENSSL_NO_TLS1_3 switch ( cmd ) { case CMD_SET_DEFAULTS : section -> ciphersuites = NULL ; break ; case CMD_SET_COPY : section -> ciphersuites = str_dup_detached ( new_service_options . ciphersuites ) ; break ; case CMD_FREE : str_free ( section -> ciphersuites ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""ciphersuites"" ) ) break ; str_free ( section -> ciphersuites ) ; section -> ciphersuites = str_dup_detached ( arg ) ; return NULL ; case CMD_INITIALIZE : if ( ! section -> ciphersuites ) { section -> ciphersuites = str_dup_detached ( stunnel_ciphersuites ) ; } break ; case CMD_PRINT_DEFAULTS : s_log ( LOG_NOTICE , ""%-22s=%s%s"" , ""ciphersuites"" , stunnel_ciphersuites , ""(withTLSv1.3)"" ) ; break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=permittedciphersuitesforTLS1.3"" , ""ciphersuites"" ) ; break ; } # endif switch ( cmd ) { case CMD_SET_DEFAULTS : section -> option . client = 0 ; break ; case CMD_SET_COPY : section -> option . client = new_service_options . option . client ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""client"" ) ) break ; if ( ! strcasecmp ( arg , ""yes"" ) ) section -> option . client = 1 ; else if ( ! strcasecmp ( arg , ""no"" ) ) section -> option . client = 0 ; else return ""Theargumentneedstobeeither\'yes\'or\'no\'"" ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=yes|noclientmode(remoteserviceusesTLS)"" , ""client"" ) ; break ; } # if OPENSSL_VERSION_NUMBER >= 0x10002000L switch ( cmd ) { case CMD_SET_DEFAULTS : section -> config = NULL ; break ; case CMD_SET_COPY : name_list_dup ( & section -> config , new_service_options . config ) ; break ; case CMD_FREE : name_list_free ( section -> config ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""config"" ) ) break ; name_list_append ( & section -> config , arg ) ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=command[:parameter]toexecute"" , ""config"" ) ; break ; } # endif switch ( cmd ) { case CMD_SET_DEFAULTS : addrlist_clear ( & section -> connect_addr , 0 ) ; section -> connect_session = NULL ; break ; case CMD_SET_COPY : addrlist_clear ( & section -> connect_addr , 0 ) ; section -> connect_session = NULL ; name_list_dup ( & section -> connect_addr . names , new_service_options . connect_addr . names ) ; break ; case CMD_FREE : name_list_free ( section -> connect_addr . names ) ; str_free ( section -> connect_addr . addr ) ; str_free ( section -> connect_session ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""connect"" ) ) break ; name_list_append ( & section -> connect_addr . names , arg ) ; return NULL ; case CMD_INITIALIZE : if ( section -> connect_addr . names ) { if ( ! section -> option . delayed_lookup && ! addrlist_resolve ( & section -> connect_addr ) ) { s_log ( LOG_INFO , ""Cannotresolveconnecttarget-delayingDNSlookup"" ) ; section -> connect_addr . num = 0 ; section -> redirect_addr . num = 0 ; section -> option . delayed_lookup = 1 ; } if ( section -> option . client ) section -> connect_session = str_alloc_detached ( section -> connect_addr . num * sizeof ( SSL_SESSION * ) ) ; ++ endpoints ; } break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=[host:]porttoconnect"" , ""connect"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> crl_dir = NULL ; break ; case CMD_SET_COPY : section -> crl_dir = str_dup_detached ( new_service_options . crl_dir ) ; break ; case CMD_FREE : str_free ( section -> crl_dir ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""CRLpath"" ) ) break ; str_free ( section -> crl_dir ) ; if ( arg [ 0 ] ) section -> crl_dir = str_dup_detached ( arg ) ; else section -> crl_dir = NULL ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=CRLdirectory"" , ""CRLpath"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> crl_file = NULL ; break ; case CMD_SET_COPY : section -> crl_file = str_dup_detached ( new_service_options . crl_file ) ; break ; case CMD_FREE : str_free ( section -> crl_file ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""CRLfile"" ) ) break ; str_free ( section -> crl_file ) ; if ( arg [ 0 ] ) section -> crl_file = str_dup_detached ( arg ) ; else section -> crl_file = NULL ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=CRLfile"" , ""CRLfile"" ) ; break ; } # ifndef OPENSSL_NO_ECDH switch ( cmd ) { case CMD_SET_DEFAULTS : section -> curves = str_dup_detached ( DEFAULT_CURVES ) ; break ; case CMD_SET_COPY : section -> curves = str_dup_detached ( new_service_options . curves ) ; break ; case CMD_FREE : str_free ( section -> curves ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""curves"" ) && strcasecmp ( opt , ""curve"" ) ) break ; str_free ( section -> curves ) ; section -> curves = str_dup_detached ( arg ) ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : s_log ( LOG_NOTICE , ""%-22s=%s"" , ""curves"" , DEFAULT_CURVES ) ; break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=ECDHcurvenames"" , ""curves"" ) ; break ; } # endif switch ( cmd ) { case CMD_SET_DEFAULTS : section -> log_level = LOG_NOTICE ; # if ! defined ( USE_WIN32 ) && ! defined ( __vms ) new_global_options . log_facility = LOG_DAEMON ; # endif break ; case CMD_SET_COPY : section -> log_level = new_service_options . log_level ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""debug"" ) ) break ; return parse_debug_level ( arg , section ) ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : # if ! defined ( USE_WIN32 ) && ! defined ( __vms ) s_log ( LOG_NOTICE , ""%-22s=%s"" , ""debug"" , ""daemon.notice"" ) ; # else s_log ( LOG_NOTICE , ""%-22s=%s"" , ""debug"" , ""notice"" ) ; # endif break ; case CMD_PRINT_HELP : # if ! defined ( USE_WIN32 ) && ! defined ( __vms ) s_log ( LOG_NOTICE , ""%-22s=[facility].level(e.g.daemon.info)"" , ""debug"" ) ; # else s_log ( LOG_NOTICE , ""%-22s=level(e.g.info)"" , ""debug"" ) ; # endif break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> option . delayed_lookup = 0 ; break ; case CMD_SET_COPY : section -> option . delayed_lookup = new_service_options . option . delayed_lookup ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""delay"" ) ) break ; if ( ! strcasecmp ( arg , ""yes"" ) ) section -> option . delayed_lookup = 1 ; else if ( ! strcasecmp ( arg , ""no"" ) ) section -> option . delayed_lookup = 0 ; else return ""Theargumentneedstobeeither\'yes\'or\'no\'"" ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=yes|nodelayDNSlookupfor\'connect\'option"" , ""delay"" ) ; break ; } # ifndef OPENSSL_NO_ENGINE switch ( cmd ) { case CMD_SET_DEFAULTS : break ; case CMD_SET_COPY : section -> engine = new_service_options . engine ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""engineId"" ) ) break ; section -> engine = engine_get_by_id ( arg ) ; if ( ! section -> engine ) return ""EngineIDnotfound"" ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=IDofenginetoreadthekeyfrom"" , ""engineId"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : break ; case CMD_SET_COPY : section -> engine = new_service_options . engine ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""engineNum"" ) ) break ; { char * tmp_str ; int tmp_int = ( int ) strtol ( arg , & tmp_str , 10 ) ; if ( tmp_str == arg || * tmp_str ) return ""Illegalenginenumber"" ; section -> engine = engine_get_by_num ( tmp_int - 1 ) ; } if ( ! section -> engine ) return ""Illegalenginenumber"" ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=numberofenginetoreadthekeyfrom"" , ""engineNum"" ) ; break ; } # endif switch ( cmd ) { case CMD_SET_DEFAULTS : section -> exec_name = NULL ; break ; case CMD_SET_COPY : section -> exec_name = str_dup_detached ( new_service_options . exec_name ) ; break ; case CMD_FREE : str_free ( section -> exec_name ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""exec"" ) ) break ; str_free ( section -> exec_name ) ; section -> exec_name = str_dup_detached ( arg ) ; # ifdef USE_WIN32 section -> exec_args = str_dup_detached ( arg ) ; # else if ( ! section -> exec_args ) { section -> exec_args = str_alloc_detached ( 2 * sizeof ( char * ) ) ; section -> exec_args [ 0 ] = str_dup_detached ( section -> exec_name ) ; section -> exec_args [ 1 ] = NULL ; } # endif return NULL ; case CMD_INITIALIZE : if ( section -> exec_name ) ++ endpoints ; break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=fileexecutelocalinetd-typeprogram"" , ""exec"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> exec_args = NULL ; break ; case CMD_SET_COPY : # ifdef USE_WIN32 section -> exec_args = str_dup_detached ( new_service_options . exec_args ) ; # else section -> exec_args = arg_dup ( new_service_options . exec_args ) ; # endif break ; case CMD_FREE : # ifdef USE_WIN32 str_free ( section -> exec_args ) ; # else arg_free ( section -> exec_args ) ; # endif break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""execArgs"" ) ) break ; # ifdef USE_WIN32 str_free ( section -> exec_args ) ; section -> exec_args = str_dup_detached ( arg ) ; # else arg_free ( section -> exec_args ) ; section -> exec_args = arg_alloc ( arg ) ; # endif return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=argumentsfor\'exec\'(including$0)"" , ""execArgs"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> failover = FAILOVER_PRIO ; section -> rr = 0 ; break ; case CMD_SET_COPY : section -> failover = new_service_options . failover ; section -> rr = new_service_options . rr ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""failover"" ) ) break ; if ( ! strcasecmp ( arg , ""rr"" ) ) section -> failover = FAILOVER_RR ; else if ( ! strcasecmp ( arg , ""prio"" ) ) section -> failover = FAILOVER_PRIO ; else return ""Theargumentneedstobeeither\'rr\'or\'prio\'"" ; return NULL ; case CMD_INITIALIZE : if ( section -> option . delayed_lookup ) section -> failover = FAILOVER_PRIO ; break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=rr|priofailoverstrategy"" , ""failover"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> username = NULL ; break ; case CMD_SET_COPY : section -> username = str_dup_detached ( new_service_options . username ) ; break ; case CMD_FREE : str_free ( section -> username ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""ident"" ) ) break ; str_free ( section -> username ) ; section -> username = str_dup_detached ( arg ) ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=usernameforIDENT(RFC1413)checking"" , ""ident"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : break ; case CMD_SET_COPY : break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""include"" ) ) break ; return include_config ( arg , section_ptr ) ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=directorywithconfigurationfilesnippets"" , ""include"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> key = NULL ; break ; case CMD_SET_COPY : section -> key = str_dup_detached ( new_service_options . key ) ; break ; case CMD_FREE : str_free ( section -> key ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""key"" ) ) break ; str_free ( section -> key ) ; section -> key = str_dup_detached ( arg ) ; return NULL ; case CMD_INITIALIZE : if ( section -> cert && ! section -> key ) section -> key = str_dup_detached ( section -> cert ) ; break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=certificateprivatekey"" , ""key"" ) ; break ; } # ifdef USE_LIBWRAP switch ( cmd ) { case CMD_SET_DEFAULTS : section -> option . libwrap = 0 ; break ; case CMD_SET_COPY : section -> option . libwrap = new_service_options . option . libwrap ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""libwrap"" ) ) break ; if ( ! strcasecmp ( arg , ""yes"" ) ) section -> option . libwrap = 1 ; else if ( ! strcasecmp ( arg , ""no"" ) ) section -> option . libwrap = 0 ; else return ""Theargumentneedstobeeither\'yes\'or\'no\'"" ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=yes|nouse/etc/hosts.allowand/etc/hosts.deny"" , ""libwrap"" ) ; break ; } # endif switch ( cmd ) { case CMD_SET_DEFAULTS : section -> option . local = 0 ; break ; case CMD_SET_COPY : section -> option . local = new_service_options . option . local ; memcpy ( & section -> source_addr , & new_service_options . source_addr , sizeof ( SOCKADDR_UNION ) ) ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""local"" ) ) break ; if ( ! hostport2addr ( & section -> source_addr , arg , ""0"" , 1 ) ) return ""Failedtoresolvelocaladdress"" ; section -> option . local = 1 ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=IPaddresstobeusedassourceforremote"" ""connections"" , ""local"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> log_id = LOG_ID_SEQUENTIAL ; break ; case CMD_SET_COPY : section -> log_id = new_service_options . log_id ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""logId"" ) ) break ; if ( ! strcasecmp ( arg , ""sequential"" ) ) section -> log_id = LOG_ID_SEQUENTIAL ; else if ( ! strcasecmp ( arg , ""unique"" ) ) section -> log_id = LOG_ID_UNIQUE ; else if ( ! strcasecmp ( arg , ""thread"" ) ) section -> log_id = LOG_ID_THREAD ; else if ( ! strcasecmp ( arg , ""process"" ) ) section -> log_id = LOG_ID_PROCESS ; else return ""Invalidconnectionidentifiertype"" ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : s_log ( LOG_NOTICE , ""%-22s=%s"" , ""logId"" , ""sequential"" ) ; break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=connectionidentifiertype"" , ""logId"" ) ; break ; } # ifndef OPENSSL_NO_OCSP switch ( cmd ) { case CMD_SET_DEFAULTS : section -> ocsp_url = NULL ; break ; case CMD_SET_COPY : section -> ocsp_url = str_dup_detached ( new_service_options . ocsp_url ) ; break ; case CMD_FREE : str_free ( section -> ocsp_url ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""ocsp"" ) ) break ; str_free ( section -> ocsp_url ) ; section -> ocsp_url = str_dup_detached ( arg ) ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=OCSPresponderURL"" , ""OCSP"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> option . aia = 0 ; break ; case CMD_SET_COPY : section -> option . aia = new_service_options . option . aia ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""OCSPaia"" ) ) break ; if ( ! strcasecmp ( arg , ""yes"" ) ) section -> option . aia = 1 ; else if ( ! strcasecmp ( arg , ""no"" ) ) section -> option . aia = 0 ; else return ""Theargumentneedstobeeither\'yes\'or\'no\'"" ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=yes|nochecktheAIArespondersfromcertificates"" , ""OCSPaia"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> ocsp_flags = 0 ; break ; case CMD_SET_COPY : section -> ocsp_flags = new_service_options . ocsp_flags ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""OCSPflag"" ) ) break ; { unsigned long tmp_ulong = parse_ocsp_flag ( arg ) ; if ( ! tmp_ulong ) return ""IllegalOCSPflag"" ; section -> ocsp_flags |= tmp_ulong ; } return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=OCSPresponderflags"" , ""OCSPflag"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> option . nonce = 0 ; break ; case CMD_SET_COPY : section -> option . nonce = new_service_options . option . nonce ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""OCSPnonce"" ) ) break ; if ( ! strcasecmp ( arg , ""yes"" ) ) section -> option . nonce = 1 ; else if ( ! strcasecmp ( arg , ""no"" ) ) section -> option . nonce = 0 ; else return ""Theargumentneedstobeeither\'yes\'or\'no\'"" ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=yes|nosendandverifytheOCSPnonceextension"" , ""OCSPnonce"" ) ; break ; } # endif switch ( cmd ) { case CMD_SET_DEFAULTS : section -> ssl_options_set = 0 ; # if OPENSSL_VERSION_NUMBER >= 0x009080dfL section -> ssl_options_clear = 0 ; # endif break ; case CMD_SET_COPY : section -> ssl_options_set = new_service_options . ssl_options_set ; # if OPENSSL_VERSION_NUMBER >= 0x009080dfL section -> ssl_options_clear = new_service_options . ssl_options_clear ; # endif break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""options"" ) ) break ; # if OPENSSL_VERSION_NUMBER >= 0x009080dfL if ( * arg == '-' ) { long unsigned tmp = parse_ssl_option ( arg + 1 ) ; if ( tmp == INVALID_SSL_OPTION ) return ""IllegalTLSoption"" ; section -> ssl_options_clear |= tmp ; return NULL ; } # endif { long unsigned tmp = parse_ssl_option ( arg ) ; if ( tmp == INVALID_SSL_OPTION ) return ""IllegalTLSoption"" ; section -> ssl_options_set |= tmp ; } return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : s_log ( LOG_NOTICE , ""%-22s=%s"" , ""options"" , ""NO_SSLv2"" ) ; s_log ( LOG_NOTICE , ""%-22s=%s"" , ""options"" , ""NO_SSLv3"" ) ; break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=TLSoptiontoset/reset"" , ""options"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> protocol = NULL ; break ; case CMD_SET_COPY : section -> protocol = str_dup_detached ( new_service_options . protocol ) ; break ; case CMD_FREE : str_free ( section -> protocol ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""protocol"" ) ) break ; str_free ( section -> protocol ) ; section -> protocol = str_dup_detached ( arg ) ; return NULL ; case CMD_INITIALIZE : { char * tmp_str = protocol ( NULL , section , PROTOCOL_CHECK ) ; if ( tmp_str ) return tmp_str ; } endpoints += section -> option . protocol_endpoint ; break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=protocoltonegotiatebeforeTLSinitialization"" , ""protocol"" ) ; s_log ( LOG_NOTICE , ""%25scurrentlysupported:cifs,connect,imap,"" , """" ) ; s_log ( LOG_NOTICE , ""%25snntp,pgsql,pop3,proxy,smtp,socks"" , """" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> protocol_authentication = str_dup_detached ( ""basic"" ) ; break ; case CMD_SET_COPY : section -> protocol_authentication = str_dup_detached ( new_service_options . protocol_authentication ) ; break ; case CMD_FREE : str_free ( section -> protocol_authentication ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""protocolAuthentication"" ) ) break ; str_free ( section -> protocol_authentication ) ; section -> protocol_authentication = str_dup_detached ( arg ) ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=authenticationtypeforprotocolnegotiations"" , ""protocolAuthentication"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> protocol_domain = NULL ; break ; case CMD_SET_COPY : section -> protocol_domain = str_dup_detached ( new_service_options . protocol_domain ) ; break ; case CMD_FREE : str_free ( section -> protocol_domain ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""protocolDomain"" ) ) break ; str_free ( section -> protocol_domain ) ; section -> protocol_domain = str_dup_detached ( arg ) ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=domainforprotocolnegotiations"" , ""protocolDomain"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> protocol_host = NULL ; break ; case CMD_SET_COPY : section -> protocol_host = str_dup_detached ( new_service_options . protocol_host ) ; break ; case CMD_FREE : str_free ( section -> protocol_host ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""protocolHost"" ) ) break ; str_free ( section -> protocol_host ) ; section -> protocol_host = str_dup_detached ( arg ) ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=host:portforprotocolnegotiations"" , ""protocolHost"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> protocol_password = NULL ; break ; case CMD_SET_COPY : section -> protocol_password = str_dup_detached ( new_service_options . protocol_password ) ; break ; case CMD_FREE : str_free ( section -> protocol_password ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""protocolPassword"" ) ) break ; str_free ( section -> protocol_password ) ; section -> protocol_password = str_dup_detached ( arg ) ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=passwordforprotocolnegotiations"" , ""protocolPassword"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> protocol_username = NULL ; break ; case CMD_SET_COPY : section -> protocol_username = str_dup_detached ( new_service_options . protocol_username ) ; break ; case CMD_FREE : str_free ( section -> protocol_username ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""protocolUsername"" ) ) break ; str_free ( section -> protocol_username ) ; section -> protocol_username = str_dup_detached ( arg ) ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=usernameforprotocolnegotiations"" , ""protocolUsername"" ) ; break ; } # ifndef OPENSSL_NO_PSK switch ( cmd ) { case CMD_SET_DEFAULTS : section -> psk_identity = NULL ; section -> psk_selected = NULL ; section -> psk_sorted . val = NULL ; section -> psk_sorted . num = 0 ; break ; case CMD_SET_COPY : section -> psk_identity = str_dup_detached ( new_service_options . psk_identity ) ; break ; case CMD_FREE : str_free ( section -> psk_identity ) ; str_free ( section -> psk_sorted . val ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""PSKidentity"" ) ) break ; str_free ( section -> psk_identity ) ; section -> psk_identity = str_dup_detached ( arg ) ; return NULL ; case CMD_INITIALIZE : if ( ! section -> psk_keys ) break ; psk_sort ( & section -> psk_sorted , section -> psk_keys ) ; if ( section -> option . client ) { if ( section -> psk_identity ) { section -> psk_selected = psk_find ( & section -> psk_sorted , section -> psk_identity ) ; if ( ! section -> psk_selected ) return ""NokeyfoundforthespecifiedPSKidentity"" ; } else { section -> psk_selected = section -> psk_keys ; } } else { if ( section -> psk_identity ) s_log ( LOG_NOTICE , ""PSKidentityisignoredintheservermode"" ) ; } break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=identityforPSKauthentication"" , ""PSKidentity"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> psk_keys = NULL ; break ; case CMD_SET_COPY : section -> psk_keys = psk_dup ( new_service_options . psk_keys ) ; break ; case CMD_FREE : psk_free ( section -> psk_keys ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""PSKsecrets"" ) ) break ; section -> psk_keys = psk_read ( arg ) ; if ( ! section -> psk_keys ) return ""FailedtoreadPSKsecrets"" ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=secretsforPSKauthentication"" , ""PSKsecrets"" ) ; break ; } # endif # ifndef USE_WIN32 switch ( cmd ) { case CMD_SET_DEFAULTS : section -> option . pty = 0 ; break ; case CMD_SET_COPY : section -> option . pty = new_service_options . option . pty ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""pty"" ) ) break ; if ( ! strcasecmp ( arg , ""yes"" ) ) section -> option . pty = 1 ; else if ( ! strcasecmp ( arg , ""no"" ) ) section -> option . pty = 0 ; else return ""Theargumentneedstobeeither\'yes\'or\'no\'"" ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=yes|noallocatepseudoterminalfor\'exec\'option"" , ""pty"" ) ; break ; } # endif switch ( cmd ) { case CMD_SET_DEFAULTS : addrlist_clear ( & section -> redirect_addr , 0 ) ; break ; case CMD_SET_COPY : addrlist_clear ( & section -> redirect_addr , 0 ) ; name_list_dup ( & section -> redirect_addr . names , new_service_options . redirect_addr . names ) ; break ; case CMD_FREE : name_list_free ( section -> redirect_addr . names ) ; str_free ( section -> redirect_addr . addr ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""redirect"" ) ) break ; name_list_append ( & section -> redirect_addr . names , arg ) ; return NULL ; case CMD_INITIALIZE : if ( section -> redirect_addr . names ) { if ( section -> option . client ) return ""\\""redirect\\""isunsupportedinclientsections"" ; if ( section -> option . connect_before_ssl ) return ""\\""redirect\\""isincompatiblewiththespecifiedprotocolnegotiation"" ; if ( ! section -> option . delayed_lookup && ! addrlist_resolve ( & section -> redirect_addr ) ) { s_log ( LOG_INFO , ""Cannotresolveredirecttarget-delayingDNSlookup"" ) ; section -> connect_addr . num = 0 ; section -> redirect_addr . num = 0 ; section -> option . delayed_lookup = 1 ; } if ( ! section -> option . verify_chain && ! section -> option . verify_peer ) return ""Either\\""verifyChain\\""or\\""verifyPeer\\""hastobeenabledfor\\""redirect\\""towork"" ; } break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=[host:]porttoredirectonauthenticationfailures"" , ""redirect"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> option . renegotiation = 1 ; break ; case CMD_SET_COPY : section -> option . renegotiation = new_service_options . option . renegotiation ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""renegotiation"" ) ) break ; if ( ! strcasecmp ( arg , ""yes"" ) ) section -> option . renegotiation = 1 ; else if ( ! strcasecmp ( arg , ""no"" ) ) section -> option . renegotiation = 0 ; else return ""Theargumentneedstobeeither\'yes\'or\'no\'"" ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=yes|nosupportrenegotiation"" , ""renegotiation"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> option . require_cert = 0 ; break ; case CMD_SET_COPY : section -> option . require_cert = new_service_options . option . require_cert ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""requireCert"" ) ) break ; if ( ! strcasecmp ( arg , ""yes"" ) ) { section -> option . request_cert = 1 ; section -> option . require_cert = 1 ; } else if ( ! strcasecmp ( arg , ""no"" ) ) { section -> option . require_cert = 0 ; } else { return ""Theargumentneedstobeeither\'yes\'or\'no\'"" ; } return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=yes|norequireclientcertificate"" , ""requireCert"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> option . reset = 1 ; break ; case CMD_SET_COPY : section -> option . reset = new_service_options . option . reset ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""reset"" ) ) break ; if ( ! strcasecmp ( arg , ""yes"" ) ) section -> option . reset = 1 ; else if ( ! strcasecmp ( arg , ""no"" ) ) section -> option . reset = 0 ; else return ""Theargumentneedstobeeither\'yes\'or\'no\'"" ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=yes|nosendTCPRSTonerror"" , ""reset"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> option . retry = 0 ; break ; case CMD_SET_COPY : section -> option . retry = new_service_options . option . retry ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""retry"" ) ) break ; if ( ! strcasecmp ( arg , ""yes"" ) ) section -> option . retry = 1 ; else if ( ! strcasecmp ( arg , ""no"" ) ) section -> option . retry = 0 ; else return ""Theargumentneedstobeeither\'yes\'or\'no\'"" ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=yes|noretryconnect+execsection"" , ""retry"" ) ; break ; } # ifndef USE_WIN32 switch ( cmd ) { case CMD_SET_DEFAULTS : section -> servname = str_dup_detached ( ""stunnel"" ) ; break ; case CMD_SET_COPY : break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""service"" ) ) break ; str_free ( section -> servname ) ; section -> servname = str_dup_detached ( arg ) ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=servicename"" , ""service"" ) ; break ; } # endif # ifndef USE_WIN32 switch ( cmd ) { case CMD_SET_DEFAULTS : section -> gid = 0 ; break ; case CMD_SET_COPY : section -> gid = new_service_options . gid ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""setgid"" ) ) break ; gr = getgrnam ( arg ) ; if ( gr ) { section -> gid = gr -> gr_gid ; return NULL ; } { char * tmp_str ; section -> gid = ( gid_t ) strtol ( arg , & tmp_str , 10 ) ; if ( tmp_str == arg || * tmp_str ) return ""IllegalGID"" ; } return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=groupnameforsetgid()"" , ""setgid"" ) ; break ; } # endif # ifndef USE_WIN32 switch ( cmd ) { case CMD_SET_DEFAULTS : section -> uid = 0 ; break ; case CMD_SET_COPY : section -> uid = new_service_options . uid ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""setuid"" ) ) break ; pw = getpwnam ( arg ) ; if ( pw ) { section -> uid = pw -> pw_uid ; return NULL ; } { char * tmp_str ; section -> uid = ( uid_t ) strtol ( arg , & tmp_str , 10 ) ; if ( tmp_str == arg || * tmp_str ) return ""IllegalUID"" ; } return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=usernameforsetuid()"" , ""setuid"" ) ; break ; } # endif switch ( cmd ) { case CMD_SET_DEFAULTS : section -> session_size = 1000L ; break ; case CMD_SET_COPY : section -> session_size = new_service_options . session_size ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""sessionCacheSize"" ) ) break ; { char * tmp_str ; section -> session_size = strtol ( arg , & tmp_str , 10 ) ; if ( tmp_str == arg || * tmp_str ) return ""Illegalsessioncachesize"" ; } return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : s_log ( LOG_NOTICE , ""%-22s=%ld"" , ""sessionCacheSize"" , 1000L ) ; break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=sessioncachesize"" , ""sessionCacheSize"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> session_timeout = 300L ; break ; case CMD_SET_COPY : section -> session_timeout = new_service_options . session_timeout ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""sessionCacheTimeout"" ) && strcasecmp ( opt , ""session"" ) ) break ; { char * tmp_str ; section -> session_timeout = strtol ( arg , & tmp_str , 10 ) ; if ( tmp_str == arg || * tmp_str ) return ""Illegalsessioncachetimeout"" ; } return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : s_log ( LOG_NOTICE , ""%-22s=%ldseconds"" , ""sessionCacheTimeout"" , 300L ) ; break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=sessioncachetimeout(inseconds)"" , ""sessionCacheTimeout"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> option . sessiond = 0 ; memset ( & section -> sessiond_addr , 0 , sizeof ( SOCKADDR_UNION ) ) ; section -> sessiond_addr . in . sin_family = AF_INET ; break ; case CMD_SET_COPY : section -> option . sessiond = new_service_options . option . sessiond ; memcpy ( & section -> sessiond_addr , & new_service_options . sessiond_addr , sizeof ( SOCKADDR_UNION ) ) ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""sessiond"" ) ) break ; section -> option . sessiond = 1 ; # ifdef SSL_OP_NO_TICKET section -> ssl_options_set |= SSL_OP_NO_TICKET ; # endif if ( ! name2addr ( & section -> sessiond_addr , arg , 0 ) ) return ""Failedtoresolvesessiondserveraddress"" ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=[host:]portusesessiondathost:port"" , ""sessiond"" ) ; break ; } # ifndef OPENSSL_NO_TLSEXT switch ( cmd ) { case CMD_SET_DEFAULTS : section -> servername_list_head = NULL ; section -> servername_list_tail = NULL ; break ; case CMD_SET_COPY : section -> sni = str_dup_detached ( new_service_options . sni ) ; break ; case CMD_FREE : str_free ( section -> sni ) ; sni_free ( section ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""sni"" ) ) break ; str_free ( section -> sni ) ; section -> sni = str_dup_detached ( arg ) ; return NULL ; case CMD_INITIALIZE : { char * tmp_str = sni_init ( section ) ; if ( tmp_str ) return tmp_str ; } if ( ! section -> option . client && section -> sni ) ++ endpoints ; break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=master_service:host_nameforanSNIvirtualservice"" , ""sni"" ) ; break ; } # endif switch ( cmd ) { case CMD_SET_DEFAULTS : section -> sock_opts = socket_options_init ( ) ; break ; case CMD_SET_COPY : section -> sock_opts = socket_options_dup ( new_service_options . sock_opts ) ; break ; case CMD_FREE : socket_options_free ( section -> sock_opts ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""socket"" ) ) break ; if ( socket_option_parse ( section -> sock_opts , arg ) ) return ""Illegalsocketoption"" ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=a|l|r:option=value[:value]"" , ""socket"" ) ; s_log ( LOG_NOTICE , ""%25ssetanoptiononaccept/local/remotesocket"" , """" ) ; break ; } # if OPENSSL_VERSION_NUMBER >= 0x10100000L switch ( cmd ) { case CMD_SET_DEFAULTS : break ; case CMD_SET_COPY : break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""sslVersion"" ) ) break ; section -> max_proto_version = section -> min_proto_version = str_to_proto_version ( arg ) ; if ( section -> max_proto_version == - 1 ) return ""Invalidprotocolversion"" ; return NULL ; case CMD_INITIALIZE : if ( section -> max_proto_version && section -> min_proto_version && section -> max_proto_version < section -> min_proto_version ) return ""Invalidprotocolversionrange"" ; break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=all"" ""|SSLv3|TLSv1|TLSv1.1|TLSv1.2"" # ifdef TLS1_3_VERSION ""|TLSv1.3"" # endif ""TLSversion"" , ""sslVersion"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> max_proto_version = 0 ; break ; case CMD_SET_COPY : section -> max_proto_version = new_service_options . max_proto_version ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""sslVersionMax"" ) ) break ; section -> max_proto_version = str_to_proto_version ( arg ) ; if ( section -> max_proto_version == - 1 ) return ""Invalidprotocolversion"" ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=all"" ""|SSLv3|TLSv1|TLSv1.1|TLSv1.2"" # ifdef TLS1_3_VERSION ""|TLSv1.3"" # endif ""TLSversion"" , ""sslVersionMax"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> min_proto_version = TLS1_VERSION ; break ; case CMD_SET_COPY : section -> min_proto_version = new_service_options . min_proto_version ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""sslVersionMin"" ) ) break ; section -> min_proto_version = str_to_proto_version ( arg ) ; if ( section -> min_proto_version == - 1 ) return ""Invalidprotocolversion"" ; return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=all"" ""|SSLv3|TLSv1|TLSv1.1|TLSv1.2"" # ifdef TLS1_3_VERSION ""|TLSv1.3"" # endif ""TLSversion"" , ""sslVersionMin"" ) ; break ; } # else switch ( cmd ) { case CMD_SET_DEFAULTS : tls_methods_set ( section , NULL ) ; break ; case CMD_SET_COPY : section -> client_method = new_service_options . client_method ; section -> server_method = new_service_options . server_method ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""sslVersion"" ) ) break ; return tls_methods_set ( section , arg ) ; case CMD_INITIALIZE : { char * tmp_str = tls_methods_check ( section ) ; if ( tmp_str ) return tmp_str ; } break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=all"" ""|SSLv2|SSLv3|TLSv1"" # if OPENSSL_VERSION_NUMBER >= 0x10001000L ""|TLSv1.1|TLSv1.2"" # endif ""TLSmethod"" , ""sslVersion"" ) ; break ; } # endif # ifndef USE_FORK switch ( cmd ) { case CMD_SET_DEFAULTS : section -> stack_size = DEFAULT_STACK_SIZE ; break ; case CMD_SET_COPY : section -> stack_size = new_service_options . stack_size ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""stack"" ) ) break ; { char * tmp_str ; section -> stack_size = ( size_t ) strtol ( arg , & tmp_str , 10 ) ; if ( tmp_str == arg || * tmp_str ) return ""Illegalthreadstacksize"" ; } return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : s_log ( LOG_NOTICE , ""%-22s=%dbytes"" , ""stack"" , DEFAULT_STACK_SIZE ) ; break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=threadstacksize(inbytes)"" , ""stack"" ) ; break ; } # endif # if OPENSSL_VERSION_NUMBER >= 0x10000000L switch ( cmd ) { case CMD_SET_DEFAULTS : section -> ticket_key = NULL ; break ; case CMD_SET_COPY : section -> ticket_key = key_dup ( new_service_options . ticket_key ) ; break ; case CMD_FREE : key_free ( section -> ticket_key ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""ticketKeySecret"" ) ) break ; section -> ticket_key = key_read ( arg , ""ticketKeySecret"" ) ; if ( ! section -> ticket_key ) return ""FailedtoreadticketKeySecret"" ; return NULL ; case CMD_INITIALIZE : if ( ! section -> ticket_key ) break ; if ( section -> option . client ) { s_log ( LOG_NOTICE , ""ticketKeySecretisignoredintheclientmode"" ) ; break ; } if ( section -> ticket_key && ! section -> ticket_mac ) return ""\\""ticketKeySecret\\""and\\""ticketMacSecret\\""mustbesettogether"" ; break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=secretkeyforencryption/decryptionTLSv1.3tickets"" , ""ticketKeySecret"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> ticket_mac = NULL ; break ; case CMD_SET_COPY : section -> ticket_mac = key_dup ( new_service_options . ticket_mac ) ; break ; case CMD_FREE : key_free ( section -> ticket_mac ) ; break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""ticketMacSecret"" ) ) break ; section -> ticket_mac = key_read ( arg , ""ticketMacSecret"" ) ; if ( ! section -> ticket_mac ) return ""FailedtoreadticketMacSecret"" ; return NULL ; case CMD_INITIALIZE : if ( ! section -> ticket_mac ) break ; if ( section -> option . client ) { s_log ( LOG_NOTICE , ""ticketMacSecretisignoredintheclientmode"" ) ; break ; } if ( section -> ticket_mac && ! section -> ticket_key ) return ""\\""ticketKeySecret\\""and\\""ticketMacSecret\\""mustbesettogether"" ; break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=keyforHMACoperationsonTLSv1.3tickets"" , ""ticketMacSecret"" ) ; break ; } # endif switch ( cmd ) { case CMD_SET_DEFAULTS : section -> timeout_busy = 300 ; break ; case CMD_SET_COPY : section -> timeout_busy = new_service_options . timeout_busy ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""TIMEOUTbusy"" ) ) break ; { char * tmp_str ; section -> timeout_busy = ( int ) strtol ( arg , & tmp_str , 10 ) ; if ( tmp_str == arg || * tmp_str ) return ""Illegalbusytimeout"" ; } return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : s_log ( LOG_NOTICE , ""%-22s=%dseconds"" , ""TIMEOUTbusy"" , 300 ) ; break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=secondstowaitforexpecteddata"" , ""TIMEOUTbusy"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> timeout_close = 60 ; break ; case CMD_SET_COPY : section -> timeout_close = new_service_options . timeout_close ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""TIMEOUTclose"" ) ) break ; { char * tmp_str ; section -> timeout_close = ( int ) strtol ( arg , & tmp_str , 10 ) ; if ( tmp_str == arg || * tmp_str ) return ""Illegalclosetimeout"" ; } return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : s_log ( LOG_NOTICE , ""%-22s=%dseconds"" , ""TIMEOUTclose"" , 60 ) ; break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=secondstowaitforclose_notify"" , ""TIMEOUTclose"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> timeout_connect = 10 ; break ; case CMD_SET_COPY : section -> timeout_connect = new_service_options . timeout_connect ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""TIMEOUTconnect"" ) ) break ; { char * tmp_str ; section -> timeout_connect = ( int ) strtol ( arg , & tmp_str , 10 ) ; if ( tmp_str == arg || * tmp_str ) return ""Illegalconnecttimeout"" ; } return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : s_log ( LOG_NOTICE , ""%-22s=%dseconds"" , ""TIMEOUTconnect"" , 10 ) ; break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=secondstoconnectremotehost"" , ""TIMEOUTconnect"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> timeout_idle = 43200 ; break ; case CMD_SET_COPY : section -> timeout_idle = new_service_options . timeout_idle ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""TIMEOUTidle"" ) ) break ; { char * tmp_str ; section -> timeout_idle = ( int ) strtol ( arg , & tmp_str , 10 ) ; if ( tmp_str == arg || * tmp_str ) return ""Illegalidletimeout"" ; return NULL ; } case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : s_log ( LOG_NOTICE , ""%-22s=%dseconds"" , ""TIMEOUTidle"" , 43200 ) ; break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=secondstokeepanidleconnection"" , ""TIMEOUTidle"" ) ; break ; } # ifndef USE_WIN32 switch ( cmd ) { case CMD_SET_DEFAULTS : section -> option . transparent_src = 0 ; section -> option . transparent_dst = 0 ; break ; case CMD_SET_COPY : section -> option . transparent_src = new_service_options . option . transparent_src ; section -> option . transparent_dst = new_service_options . option . transparent_dst ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""transparent"" ) ) break ; if ( ! strcasecmp ( arg , ""none"" ) || ! strcasecmp ( arg , ""no"" ) ) { section -> option . transparent_src = 0 ; section -> option . transparent_dst = 0 ; } else if ( ! strcasecmp ( arg , ""source"" ) || ! strcasecmp ( arg , ""yes"" ) ) { section -> option . transparent_src = 1 ; section -> option . transparent_dst = 0 ; } else if ( ! strcasecmp ( arg , ""destination"" ) ) { section -> option . transparent_src = 0 ; section -> option . transparent_dst = 1 ; } else if ( ! strcasecmp ( arg , ""both"" ) ) { section -> option . transparent_src = 1 ; section -> option . transparent_dst = 1 ; } else return ""Selectedtransparentproxymodeisnotavailable"" ; return NULL ; case CMD_INITIALIZE : if ( section -> option . transparent_dst ) ++ endpoints ; break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=none|source|destination|bothtransparentproxymode"" , ""transparent"" ) ; break ; } # endif switch ( cmd ) { case CMD_SET_DEFAULTS : section -> option . request_cert = 0 ; break ; case CMD_SET_COPY : section -> option . request_cert = new_service_options . option . request_cert ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""verify"" ) ) break ; { char * tmp_str ; int tmp_int = ( int ) strtol ( arg , & tmp_str , 10 ) ; if ( tmp_str == arg || * tmp_str || tmp_int < 0 || tmp_int > 4 ) return ""Badverifylevel"" ; section -> option . request_cert = 1 ; section -> option . require_cert = ( tmp_int >= 2 ) ; section -> option . verify_chain = ( tmp_int >= 1 && tmp_int <= 3 ) ; section -> option . verify_peer = ( tmp_int >= 3 ) ; } return NULL ; case CMD_INITIALIZE : if ( ( section -> option . verify_chain || section -> option . verify_peer ) && ! section -> ca_file && ! section -> ca_dir ) return ""Either\\""CAfile\\""or\\""CApath\\""hastobeconfigured"" ; break ; case CMD_PRINT_DEFAULTS : s_log ( LOG_NOTICE , ""%-22s=none"" , ""verify"" ) ; break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=levelofpeercertificateverification"" , ""verify"" ) ; s_log ( LOG_NOTICE , ""%25slevel0-requestandignorepeercert"" , """" ) ; s_log ( LOG_NOTICE , ""%25slevel1-onlyvalidatepeercertifpresent"" , """" ) ; s_log ( LOG_NOTICE , ""%25slevel2-alwaysrequireavalidpeercert"" , """" ) ; s_log ( LOG_NOTICE , ""%25slevel3-verifypeerwithlocallyinstalledcert"" , """" ) ; s_log ( LOG_NOTICE , ""%25slevel4-ignoreCAchainandonlyverifypeercert"" , """" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> option . verify_chain = 0 ; break ; case CMD_SET_COPY : section -> option . verify_chain = new_service_options . option . verify_chain ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""verifyChain"" ) ) break ; if ( ! strcasecmp ( arg , ""yes"" ) ) { section -> option . request_cert = 1 ; section -> option . require_cert = 1 ; section -> option . verify_chain = 1 ; } else if ( ! strcasecmp ( arg , ""no"" ) ) { section -> option . verify_chain = 0 ; } else { return ""Theargumentneedstobeeither\'yes\'or\'no\'"" ; } return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=yes|noverifycertificatechain"" , ""verifyChain"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : section -> option . verify_peer = 0 ; break ; case CMD_SET_COPY : section -> option . verify_peer = new_service_options . option . verify_peer ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""verifyPeer"" ) ) break ; if ( ! strcasecmp ( arg , ""yes"" ) ) { section -> option . request_cert = 1 ; section -> option . require_cert = 1 ; section -> option . verify_peer = 1 ; } else if ( ! strcasecmp ( arg , ""no"" ) ) { section -> option . verify_peer = 0 ; } else { return ""Theargumentneedstobeeither\'yes\'or\'no\'"" ; } return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=yes|noverifypeercertificate"" , ""verifyPeer"" ) ; break ; } switch ( cmd ) { case CMD_SET_DEFAULTS : break ; case CMD_SET_COPY : break ; case CMD_FREE : str_free ( section -> chain ) ; if ( section -> session ) SSL_SESSION_free ( section -> session ) ; if ( section -> ctx ) SSL_CTX_free ( section -> ctx ) ; str_free ( section -> servname ) ; if ( section == & service_options ) memset ( section , 0 , sizeof ( SERVICE_OPTIONS ) ) ; else str_free ( section ) ; break ; case CMD_SET_VALUE : return option_not_found ; case CMD_INITIALIZE : if ( section != & new_service_options ) { if ( endpoints != 2 ) return ""Eachservicemustdefinetwoendpoints"" ; } else { if ( section -> option . accept ) return ""\'accept\'optionisonlyallowedina[section]"" ; if ( endpoints != 1 ) return ""Inetdmodemustdefineoneendpoint"" ; } # ifdef SSL_OP_NO_TICKET if ( OpenSSL_version_num ( ) < 0x10101000L && ! section -> option . client && ! section -> option . connect_before_ssl ) section -> ssl_options_set |= SSL_OP_NO_TICKET ; # endif if ( context_init ( section ) ) return ""FailedtoinitializeTLScontext"" ; break ; case CMD_PRINT_DEFAULTS : break ; case CMD_PRINT_HELP : break ; } return NULL ; } "," = 1 ; if ( section == & service_options ) s_log ( LOG_ERR , ""INTERNALERROR:Initializingdeployedsectiondefaults"" ) ; else if ( section == & new_service_options ) s_log ( LOG_INFO , ""Initializinginetdmodeconfiguration"" ) ; else s_log ( LOG_INFO , ""Initializingservice[%s]"" , section -> servname ) ; == & service_options ) s_log ( LOG_DEBUG , ""Deallocatingdeployedsectiondefaults"" ) ; else if ( section == & ( LOG_DEBUG , ""Deallocatingtemporarysectiondefaults"" ) ; else break ; } # if OPENSSL_VERSION_NUMBER >= 0x10100000L switch ( cmd ) { case CMD_SET_DEFAULTS : section -> security_level = - 1 ; break ; case CMD_SET_COPY : section -> security_level = new_service_options . security_level ; break ; case CMD_FREE : break ; case CMD_SET_VALUE : if ( strcasecmp ( opt , ""securityLevel"" ) ) break ; { char * tmp_str ; int tmp_int = ( int ) strtol ( arg , & tmp_str , 10 ) ; if ( tmp_str == arg || * tmp_str || tmp_int < 0 || tmp_int > 5 ) return ""Illegalsecuritylevel"" ; section -> security_level = tmp_int ; } return NULL ; case CMD_INITIALIZE : break ; case CMD_PRINT_DEFAULTS : s_log ( LOG_NOTICE , ""%-22s=%d"" , ""securityLevel"" , DEFAULT_SECURITY_LEVEL ) ; break ; case CMD_PRINT_HELP : s_log ( LOG_NOTICE , ""%-22s=setthesecuritylevel"" , ""securityLevel"" ) ; break ; } # endif ""verify"" ) ; break ; } == & service_options || section == & new_service_options ",mtrojnar@stunnel/ebad9ddc4efb2635f37174c9d800d06206f1edf9,CVE-2021-20230,https://github.com/mtrojnar/stunnel/commit/ebad9ddc4efb2635f37174c9d800d06206f1edf9,2021-02-23T17:15Z 1034,CWE-264,"CWE-264 static int userns_install ( struct nsproxy * nsproxy , void * ns ) { struct user_namespace * user_ns = ns ; struct cred * cred ; if ( user_ns == current_user_ns ( ) ) return - EINVAL ; if ( atomic_read ( & current -> mm -> mm_users ) > 1 ) return - EINVAL ; if ( ! ns_capable ( user_ns , CAP_SYS_ADMIN ) ) return - EPERM ; cred = prepare_creds ( ) ; if ( ! cred ) return - ENOMEM ; put_user_ns ( cred -> user_ns ) ; set_cred_user_ns ( cred , get_user_ns ( user_ns ) ) ; return commit_creds ( cred ) ; } "," mm_users ) > 1 ) return - EINVAL ; if ( current -> fs -> users != ",torvalds@linux/e66eded8309ebf679d3d3c1f5820d1f2ca332c71,CVE-2013-1858,https://github.com/torvalds/linux/commit/e66eded8309ebf679d3d3c1f5820d1f2ca332c71,2013-04-05T21:55Z 1035,CWE-476,"CWE-476 int btrfs_scrub_dev ( struct btrfs_fs_info * fs_info , u64 devid , u64 start , u64 end , struct btrfs_scrub_progress * progress , int readonly , int is_dev_replace ) { struct scrub_ctx * sctx ; int ret ; struct btrfs_device * dev ; unsigned int nofs_flag ; if ( btrfs_fs_closing ( fs_info ) ) return - EINVAL ; if ( fs_info -> nodesize > BTRFS_STRIPE_LEN ) { btrfs_err ( fs_info , ""scrub:sizeassumptionnodesize<=BTRFS_STRIPE_LEN(%d<=%d)fails"" , fs_info -> nodesize , BTRFS_STRIPE_LEN ) ; return - EINVAL ; } if ( fs_info -> sectorsize != PAGE_SIZE ) { btrfs_err_rl ( fs_info , ""scrub:sizeassumptionsectorsize!=PAGE_SIZE(%d!=%lu)fails"" , fs_info -> sectorsize , PAGE_SIZE ) ; return - EINVAL ; } if ( fs_info -> nodesize > PAGE_SIZE * SCRUB_MAX_PAGES_PER_BLOCK || fs_info -> sectorsize > PAGE_SIZE * SCRUB_MAX_PAGES_PER_BLOCK ) { btrfs_err ( fs_info , ""scrub:sizeassumptionnodesizeandsectorsize<=SCRUB_MAX_PAGES_PER_BLOCK(%d<=%d&&%d<=%d)fails"" , fs_info -> nodesize , SCRUB_MAX_PAGES_PER_BLOCK , fs_info -> sectorsize , SCRUB_MAX_PAGES_PER_BLOCK ) ; return - EINVAL ; } sctx = scrub_setup_ctx ( fs_info , is_dev_replace ) ; if ( IS_ERR ( sctx ) ) return PTR_ERR ( sctx ) ; mutex_lock ( & fs_info -> fs_devices -> device_list_mutex ) ; dev = btrfs_find_device ( fs_info -> fs_devices , devid , NULL , NULL ) ; if ( ! dev || ( test_bit ( BTRFS_DEV_STATE_MISSING , & dev -> dev_state ) && ! is_dev_replace ) ) { mutex_unlock ( & fs_info -> fs_devices -> device_list_mutex ) ; ret = - ENODEV ; goto out_free_ctx ; } if ( ! is_dev_replace && ! readonly && ! test_bit ( BTRFS_DEV_STATE_WRITEABLE , & dev -> dev_state ) ) { mutex_unlock ( & fs_info -> fs_devices -> device_list_mutex ) ; btrfs_err_in_rcu ( fs_info , ""scrub:device%sisnotwritable"" , rcu_str_deref ( dev -> name ) ) ; ret = - EROFS ; goto out_free_ctx ; } mutex_lock ( & fs_info -> scrub_lock ) ; if ( ! test_bit ( BTRFS_DEV_STATE_IN_FS_METADATA , & dev -> dev_state ) || test_bit ( BTRFS_DEV_STATE_REPLACE_TGT , & dev -> dev_state ) ) { mutex_unlock ( & fs_info -> scrub_lock ) ; mutex_unlock ( & fs_info -> fs_devices -> device_list_mutex ) ; ret = - EIO ; goto out_free_ctx ; } down_read ( & fs_info -> dev_replace . rwsem ) ; if ( dev -> scrub_ctx || ( ! is_dev_replace && btrfs_dev_replace_is_ongoing ( & fs_info -> dev_replace ) ) ) { up_read ( & fs_info -> dev_replace . rwsem ) ; mutex_unlock ( & fs_info -> scrub_lock ) ; mutex_unlock ( & fs_info -> fs_devices -> device_list_mutex ) ; ret = - EINPROGRESS ; goto out_free_ctx ; } up_read ( & fs_info -> dev_replace . rwsem ) ; ret = scrub_workers_get ( fs_info , is_dev_replace ) ; if ( ret ) { mutex_unlock ( & fs_info -> scrub_lock ) ; mutex_unlock ( & fs_info -> fs_devices -> device_list_mutex ) ; goto out_free_ctx ; } sctx -> readonly = readonly ; dev -> scrub_ctx = sctx ; mutex_unlock ( & fs_info -> fs_devices -> device_list_mutex ) ; __scrub_blocked_if_needed ( fs_info ) ; atomic_inc ( & fs_info -> scrubs_running ) ; mutex_unlock ( & fs_info -> scrub_lock ) ; nofs_flag = memalloc_nofs_save ( ) ; if ( ! is_dev_replace ) { mutex_lock ( & fs_info -> fs_devices -> device_list_mutex ) ; ret = scrub_supers ( sctx , dev ) ; mutex_unlock ( & fs_info -> fs_devices -> device_list_mutex ) ; } if ( ! ret ) ret = scrub_enumerate_chunks ( sctx , dev , start , end ) ; memalloc_nofs_restore ( nofs_flag ) ; wait_event ( sctx -> list_wait , atomic_read ( & sctx -> bios_in_flight ) == 0 ) ; atomic_dec ( & fs_info -> scrubs_running ) ; wake_up ( & fs_info -> scrub_pause_wait ) ; wait_event ( sctx -> list_wait , atomic_read ( & sctx -> workers_pending ) == 0 ) ; if ( progress ) memcpy ( progress , & sctx -> stat , sizeof ( * progress ) ) ; mutex_lock ( & fs_info -> scrub_lock ) ; dev -> scrub_ctx = NULL ; scrub_workers_put ( fs_info ) ; mutex_unlock ( & fs_info -> scrub_lock ) ; scrub_put_ctx ( sctx ) ; return ret ; out_free_ctx : scrub_free_ctx ( sctx ) ; return ret ; } "," NULL , NULL , true ",torvalds@linux/09ba3bc9dd150457c506e4661380a6183af651c1,CVE-2019-18885,https://github.com/torvalds/linux/commit/09ba3bc9dd150457c506e4661380a6183af651c1,2019-11-14T14:15Z 1036,CWE-787,"CWE-787 char * gf_text_get_utf8_line ( char * szLine , u32 lineSize , FILE * txt_in , s32 unicode_type ) { u32 i , j , len ; char * sOK ; char szLineConv [ 1024 ] ; unsigned short * sptr ; memset ( szLine , 0 , sizeof ( char ) * lineSize ) ; sOK = fgets ( szLine , lineSize , txt_in ) ; if ( ! sOK ) return NULL ; if ( unicode_type <= 1 ) { j = 0 ; len = ( u32 ) strlen ( szLine ) ; for ( i = 0 ; i < len ; i ++ ) { if ( ! unicode_type && ( szLine [ i ] & 0x80 ) ) { if ( ( szLine [ i + 1 ] & 0xc0 ) != 0x80 ) { szLineConv [ j ] = 0xc0 | ( ( szLine [ i ] >> 6 ) & 0x3 ) ; j ++ ; szLine [ i ] &= 0xbf ; } else if ( ( szLine [ i ] & 0xe0 ) == 0xc0 ) { szLineConv [ j ] = szLine [ i ] ; i ++ ; j ++ ; } else if ( ( szLine [ i ] & 0xf0 ) == 0xe0 ) { szLineConv [ j ] = szLine [ i ] ; i ++ ; j ++ ; szLineConv [ j ] = szLine [ i ] ; i ++ ; j ++ ; } else if ( ( szLine [ i ] & 0xf8 ) == 0xf0 ) { szLineConv [ j ] = szLine [ i ] ; i ++ ; j ++ ; szLineConv [ j ] = szLine [ i ] ; i ++ ; j ++ ; szLineConv [ j ] = szLine [ i ] ; i ++ ; j ++ ; } else { i += 1 ; continue ; } } szLineConv [ j ] = szLine [ i ] ; j ++ ; } szLineConv [ j ] = 0 ; strcpy ( szLine , szLineConv ) ; return sOK ; } # ifdef GPAC_BIG_ENDIAN if ( unicode_type == 3 ) { # else if ( unicode_type == 2 ) { # endif i = 0 ; while ( 1 ) { char c ; if ( ! szLine [ i ] && ! szLine [ i + 1 ] ) break ; c = szLine [ i + 1 ] ; szLine [ i + 1 ] = szLine [ i ] ; szLine [ i ] = c ; i += 2 ; } } sptr = ( u16 * ) szLine ; i = ( u32 ) gf_utf8_wcstombs ( szLineConv , 1024 , ( const unsigned short * * ) & sptr ) ; if ( i >= ( u32 ) ARRAY_LENGTH ( szLineConv ) ) return NULL ; szLineConv [ i ] = 0 ; strcpy ( szLine , szLineConv ) ; if ( unicode_type == 3 ) fgetc ( txt_in ) ; return sOK ; } "," i < len && j < sizeof ( szLineConv ) - 1 ; i ++ , j ++ ) { 0x80 ) { if ( j + 1 < sizeof ( szLineConv ) - 1 ) { ; } else break ; } else 0xc0 ) { if ( j + 1 < sizeof ( szLineConv ) - 1 && i + 1 < len ) { szLineConv [ j ] = szLine [ i ] ; i ++ ; j ++ ; } else { break ; } } else if 0xe0 ) { if ( j + 2 < sizeof ( szLineConv ) - 1 && i + 2 < len ) { szLineConv [ j ] = szLine [ i ] ; i ++ ; j ++ ; szLineConv [ j ] = szLine [ i ] ; i ++ ; j ++ ; } else { break ; } } else if 0xf0 ) { if ( j + 3 < sizeof ( szLineConv ) - 1 && i + 3 < len ) { szLineConv [ j ] = szLine [ i ] ; i ++ ; j ++ ; szLineConv [ j ] = szLine [ i ] ; i ++ ; j ++ ; szLineConv [ j ] = szLine [ i ] ; i ++ ; j ++ ; } else { break ; } } else { ; } } if ( j < sizeof ( szLineConv ) - 1 && i < len ) szLineConv [ j ] = szLine [ i ] ; } if ( j >= sizeof ( szLineConv ) ) szLineConv [ sizeof ( szLineConv ) - 1 ] = 0 ; else szLineConv [ j ",gpac@gpac/1c449a34fe0b50aaffb881bfb9d7c5ab0bb18cdd,CVE-2018-20763,https://github.com/gpac/gpac/commit/1c449a34fe0b50aaffb881bfb9d7c5ab0bb18cdd,2019-02-06T23:29Z 1037,CWE-000,"CWE-000 static inline int xfrm_replay_verify_len ( struct xfrm_replay_state_esn * replay_esn , struct nlattr * rp ) { struct xfrm_replay_state_esn * up ; int ulen ; if ( ! replay_esn || ! rp ) return 0 ; up = nla_data ( rp ) ; ulen = xfrm_replay_state_esn_len ( up ) ; if ( nla_len ( rp ) < ulen || xfrm_replay_state_esn_len ( replay_esn ) != ulen ) return - EINVAL ; if ( up -> replay_window > up -> bmp_len * sizeof ( __u32 ) * 8 ) return - EINVAL ; return 0 ; } "," ) != ulen || replay_esn -> bmp_len != up -> bmp_len ",torvalds@linux/f843ee6dd019bcece3e74e76ad9df0155655d0df,CVE-2017-7184,https://github.com/torvalds/linux/commit/f843ee6dd019bcece3e74e76ad9df0155655d0df,2017-03-19T18:59Z 1038,CWE-399,"CWE-399 int sctp_verify_asconf ( const struct sctp_association * asoc , struct sctp_paramhdr * param_hdr , void * chunk_end , struct sctp_paramhdr * * errp ) { sctp_addip_param_t * asconf_param ; union sctp_params param ; int length , plen ; param . v = ( sctp_paramhdr_t * ) param_hdr ; while ( param . v <= chunk_end - sizeof ( sctp_paramhdr_t ) ) { length = ntohs ( param . p -> length ) ; * errp = param . p ; if ( param . v > chunk_end - length || length < sizeof ( sctp_paramhdr_t ) ) return 0 ; switch ( param . p -> type ) { case SCTP_PARAM_ADD_IP : case SCTP_PARAM_DEL_IP : case SCTP_PARAM_SET_PRIMARY : asconf_param = ( sctp_addip_param_t * ) param . v ; plen = ntohs ( asconf_param -> param_hdr . length ) ; if ( plen < sizeof ( sctp_addip_param_t ) + sizeof ( sctp_paramhdr_t ) ) return 0 ; break ; case SCTP_PARAM_SUCCESS_REPORT : case SCTP_PARAM_ADAPTATION_LAYER_IND : if ( length != sizeof ( sctp_addip_param_t ) ) return 0 ; break ; default : break ; } param . v += WORD_ROUND ( length ) ; } if ( param . v != chunk_end ) return 0 ; return 1 ; } "," bool sctp_verify_asconf ( const asoc , struct sctp_chunk * chunk , bool addr_param_needed , struct sctp_paramhdr errp ) { sctp_addip_chunk_t * addip = ( sctp_addip_chunk_t * ) chunk -> chunk_hdr ; union sctp_params sctp_params param ; bool addr_param_seen = false ; sctp_walk_params ( param , addip , addip_hdr . params ) { size_t length = ntohs ( param . p -> length ) ; * errp = param . p ; switch ( param . p -> type ) { case SCTP_PARAM_ERR_CAUSE : break ; case SCTP_PARAM_IPV4_ADDRESS : if ( length != sizeof ( sctp_ipv4addr_param_t ) ) return false ; addr_param_seen = true ; break ; case SCTP_PARAM_IPV6_ADDRESS : if ( length != sizeof ( sctp_ipv6addr_param_t ) ) return false ; addr_param_seen = true ; break ; case SCTP_PARAM_ADD_IP : case SCTP_PARAM_DEL_IP : case SCTP_PARAM_SET_PRIMARY : if ( addr_param_needed && ! addr_param_seen ) return false ; length = ntohs ( param . addip -> param_hdr . length ) ; if ( length < sizeof ( sctp_addip_param_t ) + sizeof ( sctp_paramhdr_t ) ) return false ; break ; case SCTP_PARAM_SUCCESS_REPORT : case SCTP_PARAM_ADAPTATION_LAYER_IND : if ( length != sizeof ( sctp_addip_param_t ) ) return false ; break ; default : return false ; } } if ( addr_param_needed && ! addr_param_seen ) return false ; if ( ! addr_param_needed && addr_param_seen ) return false ; if ( param . v param . v != chunk -> chunk_end ) return false ; return true ; } ",torvalds@linux/9de7922bc709eee2f609cd01d98aaedc4cf5ea74,CVE-2014-3673,https://github.com/torvalds/linux/commit/9de7922bc709eee2f609cd01d98aaedc4cf5ea74,2014-11-10T11:55Z 1039,CWE-787,"CWE-787 static void __local_bh_enable ( unsigned int cnt ) { lockdep_assert_irqs_disabled ( ) ; if ( softirq_count ( ) == ( cnt & SOFTIRQ_MASK ) ) trace_softirqs_on ( _RET_IP_ ) ; preempt_count_sub ( cnt ) ; } "," { lockdep_assert_irqs_disabled ( ) ; if ( preempt_count ( ) == cnt ) trace_preempt_on ( CALLER_ADDR0 , get_lock_parent_ip ( ) _RET_IP_ ) ; __preempt_count_sub ( cnt ) ",torvalds@linux/81f9c4e4177d31ced6f52a89bb70e93bfb77ca03,CVE-2018-12714,https://github.com/torvalds/linux/commit/81f9c4e4177d31ced6f52a89bb70e93bfb77ca03,2018-06-24T23:29Z 1040,CWE-362,"CWE-362 hsm_com_errno_t unix_client_connect ( hsm_com_client_hdl_t * hdl ) { int fd , len ; struct sockaddr_un unix_addr ; if ( ( fd = socket ( AF_UNIX , SOCK_STREAM , 0 ) ) < 0 ) { return HSM_COM_ERROR ; } memset ( & unix_addr , 0 , sizeof ( unix_addr ) ) ; unix_addr . sun_family = AF_UNIX ; if ( strlen ( hdl -> c_path ) >= sizeof ( unix_addr . sun_path ) ) { close ( fd ) ; return HSM_COM_PATH_ERR ; } snprintf ( unix_addr . sun_path , sizeof ( unix_addr . sun_path ) , ""%s"" , hdl -> c_path ) ; len = SUN_LEN ( & unix_addr ) ; unlink ( unix_addr . sun_path ) ; if ( bind ( fd , ( struct sockaddr * ) & unix_addr , len ) < 0 ) { unlink ( hdl -> c_path ) ; close ( fd ) ; return HSM_COM_BIND_ERR ; } if ( chmod ( unix_addr . sun_path , S_IRWXU ) < 0 ) { unlink ( hdl -> c_path ) ; close ( fd ) ; return HSM_COM_CHMOD_ERR ; } memset ( & unix_addr , 0 , sizeof ( unix_addr ) ) ; unix_addr . sun_family = AF_UNIX ; strncpy ( unix_addr . sun_path , hdl -> s_path , sizeof ( unix_addr . sun_path ) ) ; unix_addr . sun_path [ sizeof ( unix_addr . sun_path ) - 1 ] = 0 ; len = SUN_LEN ( & unix_addr ) ; if ( connect ( fd , ( struct sockaddr * ) & unix_addr , len ) < 0 ) { unlink ( hdl -> c_path ) ; close ( fd ) ; return HSM_COM_CONX_ERR ; } hdl -> client_fd = fd ; hdl -> client_state = HSM_COM_C_STATE_CT ; if ( unix_sck_send_conn ( hdl , 2 ) != HSM_COM_OK ) { hdl -> client_state = HSM_COM_C_STATE_IN ; return HSM_COM_SEND_ERR ; } return HSM_COM_OK ; } "," sockaddr_un unix_addr ; hsm_com_errno_t res = HSM_COM_OK ; ) ) { res = HSM_COM_PATH_ERR ; goto cleanup ; } snprintf 0 ) { res = HSM_COM_BIND_ERR ; goto cleanup ; } if ( 0 ) { res = HSM_COM_CHMOD_ERR ; goto cleanup ; } memset 0 ) { res = HSM_COM_CONX_ERR ; goto cleanup ; } hdl = HSM_COM_C_STATE_IN ; res = HSM_COM_SEND_ERR ; } return res ; cleanup : close ( fd ) ; return res ; } ",01org@opa-fm/c5759e7b76f5bf844be6c6641cc1b356bbc83869,CVE-2015-5232,https://github.com/01org/opa-fm/commit/c5759e7b76f5bf844be6c6641cc1b356bbc83869,2017-06-07T20:29Z 1041,CWE-000,"CWE-000 int luaG_traceexec ( lua_State * L , const Instruction * pc ) { CallInfo * ci = L -> ci ; lu_byte mask = L -> hookmask ; int counthook ; if ( ! ( mask & ( LUA_MASKLINE | LUA_MASKCOUNT ) ) ) { ci -> u . l . trap = 0 ; return 0 ; } pc ++ ; ci -> u . l . savedpc = pc ; counthook = ( -- L -> hookcount == 0 && ( mask & LUA_MASKCOUNT ) ) ; if ( counthook ) resethookcount ( L ) ; else if ( ! ( mask & LUA_MASKLINE ) ) return 1 ; if ( ci -> callstatus & CIST_HOOKYIELD ) { ci -> callstatus &= ~ CIST_HOOKYIELD ; return 1 ; } if ( ! isIT ( * ( ci -> u . l . savedpc - 1 ) ) ) L -> top = ci -> top ; if ( counthook ) luaD_hook ( L , LUA_HOOKCOUNT , - 1 , 0 , 0 ) ; if ( mask & LUA_MASKLINE ) { const Proto * p = ci_func ( ci ) -> p ; int npci = pcRel ( pc , p ) ; if ( npci == 0 || pc <= L -> oldpc || changedline ( p , pcRel ( L -> oldpc , p ) , npci ) ) { int newline = luaG_getfuncline ( p , npci ) ; luaD_hook ( L , LUA_HOOKLINE , newline , 0 , 0 ) ; } L -> oldpc = pc ; } if ( L -> status == LUA_YIELD ) { if ( counthook ) L -> hookcount = 1 ; ci -> u . l . savedpc -- ; ci -> callstatus |= CIST_HOOKYIELD ; luaD_throw ( L , LUA_YIELD ) ; } return 1 ; } "," -> hookmask ; const Proto * p = ci_func ( ci ) -> p ; int counthook ; int oldpc = ( L -> oldpc < p -> sizecode ) ? L -> oldpc : 0 ; if ( LUA_MASKLINE ) { int npci = || pc <= invpcRel ( oldpc , p ) || changedline ( ( p , oldpc , npci ) -> oldpc = npci ; } if ",lua@lua/a2195644d89812e5b157ce7bac35543e06db05e3,CVE-2020-15945,https://github.com/lua/lua/commit/a2195644d89812e5b157ce7bac35543e06db05e3,2020-07-24T21:15Z 1042,CWE-400,"CWE-400 static void sample_hbp_handler ( struct perf_event * bp , int nmi , struct perf_sample_data * data , struct pt_regs * regs ) { printk ( KERN_INFO ""%svalueischanged\\n"" , ksym_name ) ; dump_stack ( ) ; printk ( KERN_INFO ""Dumpstackfromsample_hbp_handler\\n"" ) ; } "," perf_event * bp , struct perf_sample_data ",torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,CVE-2011-2918,https://github.com/torvalds/linux/commit/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,2012-05-24T23:55Z 1043,CWE-416,"CWE-416 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.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.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/053e67e3ec81cc9268ce30eaf0d6663d8639ed1e,CVE-2017-8929,https://github.com/VirusTotal/yara/commit/053e67e3ec81cc9268ce30eaf0d6663d8639ed1e,2017-05-14T22:29Z 1044,CWE-400,"CWE-400 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 1045,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 1046,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 1047,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 1048,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 1049,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 1050,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 1051,CWE-119,"CWE-119 int vp8_hex_search ( MACROBLOCK * x , BLOCK * b , BLOCKD * d , int_mv * ref_mv , int_mv * best_mv , int search_param , int sad_per_bit , const vp8_variance_fn_ptr_t * vfp , int * mvsadcost [ 2 ] , int * mvcost [ 2 ] , int_mv * center_mv ) { MV hex [ 6 ] = { { - 1 , - 2 } , { 1 , - 2 } , { 2 , 0 } , { 1 , 2 } , { - 1 , 2 } , { - 2 , 0 } } ; MV neighbors [ 4 ] = { { 0 , - 1 } , { - 1 , 0 } , { 1 , 0 } , { 0 , 1 } } ; int i , j ; unsigned char * what = ( * ( b -> base_src ) + b -> src ) ; int what_stride = b -> src_stride ; 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 br , bc ; int_mv this_mv ; unsigned int bestsad ; unsigned int thissad ; unsigned char * base_offset ; unsigned char * this_offset ; int k = - 1 ; int all_in ; int best_site = - 1 ; int hex_range = 127 ; int dia_range = 8 ; int_mv fcenter_mv ; fcenter_mv . as_mv . row = center_mv -> as_mv . row >> 3 ; fcenter_mv . as_mv . col = center_mv -> as_mv . col >> 3 ; vp8_clamp_mv ( ref_mv , x -> mv_col_min , x -> mv_col_max , x -> mv_row_min , x -> mv_row_max ) ; br = ref_mv -> as_mv . row ; bc = ref_mv -> as_mv . col ; base_offset = ( unsigned char * ) ( base_pre + d -> offset ) ; this_offset = base_offset + ( br * ( pre_stride ) ) + bc ; this_mv . as_mv . row = br ; this_mv . as_mv . col = bc ; bestsad = vfp -> sdf ( what , what_stride , this_offset , in_what_stride , UINT_MAX ) + mvsad_err_cost ( & this_mv , & fcenter_mv , mvsadcost , sad_per_bit ) ; # if CONFIG_MULTI_RES_ENCODING if ( search_param >= 6 ) goto cal_neighbors ; else if ( search_param >= 5 ) hex_range = 4 ; else if ( search_param >= 4 ) hex_range = 6 ; else if ( search_param >= 3 ) hex_range = 15 ; else if ( search_param >= 2 ) hex_range = 31 ; else if ( search_param >= 1 ) hex_range = 63 ; dia_range = 8 ; # endif CHECK_BOUNDS ( 2 ) if ( all_in ) { for ( i = 0 ; i < 6 ; i ++ ) { this_mv . as_mv . row = br + hex [ i ] . row ; this_mv . as_mv . col = bc + hex [ i ] . col ; this_offset = base_offset + ( this_mv . as_mv . row * in_what_stride ) + this_mv . as_mv . col ; thissad = vfp -> sdf ( what , what_stride , this_offset , in_what_stride , bestsad ) ; CHECK_BETTER } } else { for ( i = 0 ; i < 6 ; i ++ ) { this_mv . as_mv . row = br + hex [ i ] . row ; this_mv . as_mv . col = bc + hex [ i ] . col ; CHECK_POINT this_offset = base_offset + ( this_mv . as_mv . row * in_what_stride ) + this_mv . as_mv . col ; thissad = vfp -> sdf ( what , what_stride , this_offset , in_what_stride , bestsad ) ; CHECK_BETTER } } if ( best_site == - 1 ) goto cal_neighbors ; else { br += hex [ best_site ] . row ; bc += hex [ best_site ] . col ; k = best_site ; } for ( j = 1 ; j < hex_range ; j ++ ) { best_site = - 1 ; CHECK_BOUNDS ( 2 ) if ( all_in ) { for ( i = 0 ; i < 3 ; i ++ ) { this_mv . as_mv . row = br + next_chkpts [ k ] [ i ] . row ; this_mv . as_mv . col = bc + next_chkpts [ k ] [ i ] . col ; this_offset = base_offset + ( this_mv . as_mv . row * ( in_what_stride ) ) + this_mv . as_mv . col ; thissad = vfp -> sdf ( what , what_stride , this_offset , in_what_stride , bestsad ) ; CHECK_BETTER } } else { for ( i = 0 ; i < 3 ; i ++ ) { this_mv . as_mv . row = br + next_chkpts [ k ] [ i ] . row ; this_mv . as_mv . col = bc + next_chkpts [ k ] [ i ] . col ; CHECK_POINT this_offset = base_offset + ( this_mv . as_mv . row * ( in_what_stride ) ) + this_mv . as_mv . col ; thissad = vfp -> sdf ( what , what_stride , this_offset , in_what_stride , bestsad ) ; CHECK_BETTER } } if ( best_site == - 1 ) break ; else { br += next_chkpts [ k ] [ best_site ] . row ; bc += next_chkpts [ k ] [ best_site ] . col ; k += 5 + best_site ; if ( k >= 12 ) k -= 12 ; else if ( k >= 6 ) k -= 6 ; } } cal_neighbors : for ( j = 0 ; j < dia_range ; j ++ ) { best_site = - 1 ; CHECK_BOUNDS ( 1 ) if ( all_in ) { for ( i = 0 ; i < 4 ; i ++ ) { this_mv . as_mv . row = br + neighbors [ i ] . row ; this_mv . as_mv . col = bc + neighbors [ i ] . col ; this_offset = base_offset + ( this_mv . as_mv . row * ( in_what_stride ) ) + this_mv . as_mv . col ; thissad = vfp -> sdf ( what , what_stride , this_offset , in_what_stride , bestsad ) ; CHECK_BETTER } } else { for ( i = 0 ; i < 4 ; i ++ ) { this_mv . as_mv . row = br + neighbors [ i ] . row ; this_mv . as_mv . col = bc + neighbors [ i ] . col ; CHECK_POINT this_offset = base_offset + ( this_mv . as_mv . row * ( in_what_stride ) ) + this_mv . as_mv . col ; thissad = vfp -> sdf ( what , what_stride , this_offset , in_what_stride , bestsad ) ; CHECK_BETTER } } if ( best_site == - 1 ) break ; else { br += neighbors [ best_site ] . row ; bc += neighbors [ best_site ] . col ; } } best_mv -> as_mv . row = br ; best_mv -> as_mv . col = bc ; return bestsad ; } "," >> 3 ; ( void ) mvcost ; this_offset , in_what_stride ) + mvsad_err_cost 8 ; # else ( void ) search_param ; # this_offset , in_what_stride ) ; CHECK_BETTER this_offset , in_what_stride ) ; CHECK_BETTER this_offset , in_what_stride ) ; CHECK_BETTER this_offset , in_what_stride ) ; CHECK_BETTER this_offset , in_what_stride ) ; CHECK_BETTER this_offset , in_what_stride ) ; CHECK_BETTER ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1052,CWE-416,"CWE-416 static void exif_mnote_data_olympus_load ( ExifMnoteData * en , const unsigned char * buf , unsigned int buf_size ) { ExifMnoteDataOlympus * n = ( ExifMnoteDataOlympus * ) en ; ExifShort c ; size_t i , tcount , o , o2 , datao = 6 , base = 0 ; if ( ! n || ! buf || ! buf_size ) { exif_log ( en -> log , EXIF_LOG_CODE_CORRUPT_DATA , ""ExifMnoteDataOlympus"" , ""ShortMakerNote"" ) ; return ; } o2 = 6 + n -> offset ; if ( CHECKOVERFLOW ( o2 , buf_size , 10 ) ) { exif_log ( en -> log , EXIF_LOG_CODE_CORRUPT_DATA , ""ExifMnoteDataOlympus"" , ""ShortMakerNote"" ) ; return ; } n -> version = exif_mnote_data_olympus_identify_variant ( buf + o2 , buf_size - o2 ) ; switch ( n -> version ) { case olympusV1 : case sanyoV1 : case epsonV1 : exif_log ( en -> log , EXIF_LOG_CODE_DEBUG , ""ExifMnoteDataOlympus"" , ""ParsingOlympus/Sanyo/Epsonmakernotev1..."" ) ; if ( buf [ o2 + 6 ] == 1 ) n -> order = EXIF_BYTE_ORDER_INTEL ; else if ( buf [ o2 + 6 + 1 ] == 1 ) n -> order = EXIF_BYTE_ORDER_MOTOROLA ; o2 += 8 ; c = exif_get_short ( buf + o2 , n -> order ) ; if ( ( ! ( c & 0xFF ) ) && ( c > 0x500 ) ) { if ( n -> order == EXIF_BYTE_ORDER_INTEL ) { n -> order = EXIF_BYTE_ORDER_MOTOROLA ; } else { n -> order = EXIF_BYTE_ORDER_INTEL ; } } break ; case olympusV2 : datao = o2 ; o2 += 8 ; if ( CHECKOVERFLOW ( o2 , buf_size , 4 ) ) return ; exif_log ( en -> log , EXIF_LOG_CODE_DEBUG , ""ExifMnoteDataOlympus"" , ""ParsingOlympusmakernotev2(0x%02x,%02x,%02x,%02x)..."" , buf [ o2 + 0 ] , buf [ o2 + 1 ] , buf [ o2 + 2 ] , buf [ o2 + 3 ] ) ; if ( ( buf [ o2 ] == 'I' ) && ( buf [ o2 + 1 ] == 'I' ) ) n -> order = EXIF_BYTE_ORDER_INTEL ; else if ( ( buf [ o2 ] == 'M' ) && ( buf [ o2 + 1 ] == 'M' ) ) n -> order = EXIF_BYTE_ORDER_MOTOROLA ; o2 += 4 ; break ; case nikonV1 : o2 += 6 ; exif_log ( en -> log , EXIF_LOG_CODE_DEBUG , ""ExifMnoteDataOlympus"" , ""ParsingNikonmakernotev1(0x%02x,%02x,%02x,"" ""%02x)..."" , buf [ o2 + 0 ] , buf [ o2 + 1 ] , buf [ o2 + 2 ] , buf [ o2 + 3 ] ) ; o2 += 1 ; o2 += 1 ; base = MNOTE_NIKON1_TAG_BASE ; c = exif_get_short ( buf + o2 , n -> order ) ; if ( ( ! ( c & 0xFF ) ) && ( c > 0x500 ) ) { if ( n -> order == EXIF_BYTE_ORDER_INTEL ) { n -> order = EXIF_BYTE_ORDER_MOTOROLA ; } else { n -> order = EXIF_BYTE_ORDER_INTEL ; } } break ; case nikonV2 : o2 += 6 ; if ( CHECKOVERFLOW ( o2 , buf_size , 12 ) ) return ; exif_log ( en -> log , EXIF_LOG_CODE_DEBUG , ""ExifMnoteDataOlympus"" , ""ParsingNikonmakernotev2(0x%02x,%02x,%02x,"" ""%02x,%02x,%02x,%02x,%02x)..."" , buf [ o2 + 0 ] , buf [ o2 + 1 ] , buf [ o2 + 2 ] , buf [ o2 + 3 ] , buf [ o2 + 4 ] , buf [ o2 + 5 ] , buf [ o2 + 6 ] , buf [ o2 + 7 ] ) ; o2 += 1 ; o2 += 1 ; o2 += 2 ; datao = o2 ; if ( ! strncmp ( ( char * ) & buf [ o2 ] , ""II"" , 2 ) ) n -> order = EXIF_BYTE_ORDER_INTEL ; else if ( ! strncmp ( ( char * ) & buf [ o2 ] , ""MM"" , 2 ) ) n -> order = EXIF_BYTE_ORDER_MOTOROLA ; else { exif_log ( en -> log , EXIF_LOG_CODE_DEBUG , ""ExifMnoteDataOlympus"" , ""Unknown"" ""byteorder\'%c%c\'"" , buf [ o2 ] , buf [ o2 + 1 ] ) ; return ; } o2 += 2 ; o2 += 2 ; o2 = datao + exif_get_long ( buf + o2 , n -> order ) ; break ; case nikonV0 : exif_log ( en -> log , EXIF_LOG_CODE_DEBUG , ""ExifMnoteDataOlympus"" , ""ParsingNikonmakernotev0(0x%02x,%02x,%02x,"" ""%02x,%02x,%02x,%02x,%02x)..."" , buf [ o2 + 0 ] , buf [ o2 + 1 ] , buf [ o2 + 2 ] , buf [ o2 + 3 ] , buf [ o2 + 4 ] , buf [ o2 + 5 ] , buf [ o2 + 6 ] , buf [ o2 + 7 ] ) ; n -> order = EXIF_BYTE_ORDER_MOTOROLA ; break ; default : exif_log ( en -> log , EXIF_LOG_CODE_DEBUG , ""ExifMnoteDataOlympus"" , ""UnknownOlympusvariant%i."" , n -> version ) ; return ; } if ( CHECKOVERFLOW ( o2 , buf_size , 2 ) ) { exif_log ( en -> log , EXIF_LOG_CODE_CORRUPT_DATA , ""ExifMnoteOlympus"" , ""ShortMakerNote"" ) ; return ; } c = exif_get_short ( buf + o2 , n -> order ) ; o2 += 2 ; exif_mnote_data_olympus_clear ( n ) ; n -> entries = exif_mem_alloc ( en -> mem , sizeof ( MnoteOlympusEntry ) * c ) ; if ( ! n -> entries ) { EXIF_LOG_NO_MEMORY ( en -> log , ""ExifMnoteOlympus"" , sizeof ( MnoteOlympusEntry ) * c ) ; return ; } tcount = 0 ; for ( i = c , o = o2 ; i ; -- i , o += 12 ) { size_t s ; if ( CHECKOVERFLOW ( o , buf_size , 12 ) ) { exif_log ( en -> log , EXIF_LOG_CODE_CORRUPT_DATA , ""ExifMnoteOlympus"" , ""ShortMakerNote"" ) ; break ; } n -> entries [ tcount ] . tag = exif_get_short ( buf + o , n -> order ) + base ; 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 , ""ExifMnoteOlympus"" , ""Loadingentry0x%x(\'%s\')..."" , n -> entries [ tcount ] . tag , mnote_olympus_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 , ""ExifMnoteOlympus"" , ""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 ) + datao ; # ifdef EXIF_OVERCOME_SANYO_OFFSET_BUG if ( dataofs > ( buf_size - s ) && n -> version == sanyoV1 ) { dataofs -= datao + 6 ; exif_log ( en -> log , EXIF_LOG_CODE_DEBUG , ""ExifMnoteOlympus"" , ""Inconsistentthumbnailtagoffset;attemptingtorecover"" ) ; } # endif } if ( CHECKOVERFLOW ( dataofs , buf_size , s ) ) { exif_log ( en -> log , EXIF_LOG_CODE_DEBUG , ""ExifMnoteOlympus"" , ""Tagdatapastendofbuffer(%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 , ""ExifMnoteOlympus"" , s ) ; continue ; } memcpy ( n -> entries [ tcount ] . data , buf + dataofs , s ) ; } ++ tcount ; } n -> count = tcount ; } "," size_t s ; memset ( & n -> entries [ tcount ] , 0 , sizeof ( MnoteOlympusEntry ) ) ; ",libexif@libexif/ec412aa4583ad71ecabb967d3c77162760169d1f,CVE-2020-13113,https://github.com/libexif/libexif/commit/ec412aa4583ad71ecabb967d3c77162760169d1f,2020-05-21T17:15Z 1053,CWE-119,"CWE-119 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-9537,https://github.com/vadz/libtiff/commit/83a4b92815ea04969d494416eaae3d4c6b338e4a,2016-11-22T19:59Z 1054,CWE-119,"CWE-119 static void encode_txfm_probs ( VP9_COMMON * cm , vp9_writer * w ) { vp9_write_literal ( w , MIN ( cm -> tx_mode , ALLOW_32X32 ) , 2 ) ; if ( cm -> tx_mode >= ALLOW_32X32 ) vp9_write_bit ( w , cm -> tx_mode == TX_MODE_SELECT ) ; if ( cm -> tx_mode == TX_MODE_SELECT ) { int i , j ; unsigned int ct_8x8p [ TX_SIZES - 3 ] [ 2 ] ; unsigned int ct_16x16p [ TX_SIZES - 2 ] [ 2 ] ; unsigned int ct_32x32p [ TX_SIZES - 1 ] [ 2 ] ; for ( i = 0 ; i < TX_SIZE_CONTEXTS ; i ++ ) { tx_counts_to_branch_counts_8x8 ( cm -> counts . tx . p8x8 [ i ] , ct_8x8p ) ; for ( j = 0 ; j < TX_SIZES - 3 ; j ++ ) vp9_cond_prob_diff_update ( w , & cm -> fc . tx_probs . p8x8 [ i ] [ j ] , ct_8x8p [ j ] ) ; } for ( i = 0 ; i < TX_SIZE_CONTEXTS ; i ++ ) { tx_counts_to_branch_counts_16x16 ( cm -> counts . tx . p16x16 [ i ] , ct_16x16p ) ; for ( j = 0 ; j < TX_SIZES - 2 ; j ++ ) vp9_cond_prob_diff_update ( w , & cm -> fc . tx_probs . p16x16 [ i ] [ j ] , ct_16x16p [ j ] ) ; } for ( i = 0 ; i < TX_SIZE_CONTEXTS ; i ++ ) { tx_counts_to_branch_counts_32x32 ( cm -> counts . tx . p32x32 [ i ] , ct_32x32p ) ; for ( j = 0 ; j < TX_SIZES - 1 ; j ++ ) vp9_cond_prob_diff_update ( w , & cm -> fc . tx_probs . p32x32 [ i ] [ j ] , ct_32x32p [ j ] ) ; } } } "," * cm , vpx_writer * w , FRAME_COUNTS * counts ) { vpx_write_literal ( w , >= ALLOW_32X32 ) vpx_write_bit ( w , { tx_counts_to_branch_counts_8x8 ( counts -> tx . p8x8 cm -> fc -> tx_probs . p8x8 { tx_counts_to_branch_counts_16x16 ( counts -> tx . p16x16 cm -> fc -> tx_probs . p16x16 { tx_counts_to_branch_counts_32x32 ( counts -> tx . p32x32 cm -> fc -> tx_probs . p32x32 ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1055,CWE-362,"CWE-362 static int netlink_dump ( struct sock * sk ) { struct netlink_sock * nlk = nlk_sk ( sk ) ; struct netlink_callback * cb ; struct sk_buff * skb = NULL ; struct nlmsghdr * nlh ; int len , err = - ENOBUFS ; int alloc_min_size ; int alloc_size ; mutex_lock ( nlk -> cb_mutex ) ; if ( ! nlk -> cb_running ) { err = - EINVAL ; goto errout_skb ; } if ( atomic_read ( & sk -> sk_rmem_alloc ) >= sk -> sk_rcvbuf ) goto errout_skb ; cb = & nlk -> cb ; alloc_min_size = max_t ( int , cb -> min_dump_alloc , NLMSG_GOODSIZE ) ; if ( alloc_min_size < nlk -> max_recvmsg_len ) { alloc_size = nlk -> max_recvmsg_len ; skb = alloc_skb ( alloc_size , GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY ) ; } if ( ! skb ) { alloc_size = alloc_min_size ; skb = alloc_skb ( alloc_size , GFP_KERNEL ) ; } if ( ! skb ) goto errout_skb ; skb_reserve ( skb , skb_tailroom ( skb ) - alloc_size ) ; netlink_skb_set_owner_r ( skb , sk ) ; len = cb -> dump ( skb , cb ) ; if ( len > 0 ) { mutex_unlock ( nlk -> cb_mutex ) ; if ( sk_filter ( sk , skb ) ) kfree_skb ( skb ) ; else __netlink_sendskb ( sk , skb ) ; return 0 ; } nlh = nlmsg_put_answer ( skb , cb , NLMSG_DONE , sizeof ( len ) , NLM_F_MULTI ) ; if ( ! nlh ) goto errout_skb ; nl_dump_check_consistent ( cb , nlh ) ; memcpy ( nlmsg_data ( nlh ) , & len , sizeof ( len ) ) ; if ( sk_filter ( sk , skb ) ) kfree_skb ( skb ) ; else __netlink_sendskb ( sk , skb ) ; if ( cb -> done ) cb -> done ( cb ) ; nlk -> cb_running = false ; mutex_unlock ( nlk -> cb_mutex ) ; module_put ( cb -> module ) ; consume_skb ( cb -> skb ) ; return 0 ; errout_skb : mutex_unlock ( nlk -> cb_mutex ) ; kfree_skb ( skb ) ; return err ; } "," * nlh ; struct module * module ; = false ; module = cb -> module ; skb = cb -> skb ; ; module_put ( module ) ; ; consume_skb ( skb ) ; ",torvalds@linux/92964c79b357efd980812c4de5c1fd2ec8bb5520,CVE-2016-9806,https://github.com/torvalds/linux/commit/92964c79b357efd980812c4de5c1fd2ec8bb5520,2016-12-28T07:59Z 1056,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 1057,CWE-772,"CWE-772 generic_ret * chpass_principal_2_svc ( chpass_arg * arg , struct svc_req * rqstp ) { static generic_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_generic_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 ) ) { ret . code = chpass_principal_wrapper_3 ( ( void * ) handle , arg -> princ , FALSE , 0 , NULL , arg -> pass ) ; } else if ( ! ( CHANGEPW_SERVICE ( rqstp ) ) && kadm5int_acl_check ( handle -> context , rqst2name ( rqstp ) , ACL_CHANGEPW , arg -> princ , NULL ) ) { ret . code = kadm5_chpass_principal ( ( void * ) handle , arg -> princ , arg -> pass ) ; } else { log_unauth ( ""kadm5_chpass_principal"" , prime_arg , & client_name , & service_name , rqstp ) ; ret . code = KADM5_AUTH_CHANGEPW ; } if ( ret . code != KADM5_AUTH_CHANGEPW ) { if ( ret . code != 0 ) errmsg = krb5_get_error_message ( handle -> context , ret . code ) ; log_done ( ""kadm5_chpass_principal"" , 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 : gss_release_buffer ( & minor_stat , & client_name ) ; gss_release_buffer ( & minor_stat , & service_name ) ; free_server_handle ( handle ",krb5@krb5/83ed75feba32e46f736fcce0d96a0445f29b96c2,CVE-2015-8631,https://github.com/krb5/krb5/commit/83ed75feba32e46f736fcce0d96a0445f29b96c2,2016-02-13T02:59Z 1058,CWE-190,"CWE-190 static int futex_requeue ( u32 __user * uaddr1 , unsigned int flags , u32 __user * uaddr2 , int nr_wake , int nr_requeue , u32 * cmpval , int requeue_pi ) { union futex_key key1 = FUTEX_KEY_INIT , key2 = FUTEX_KEY_INIT ; int drop_count = 0 , task_count = 0 , ret ; struct futex_pi_state * pi_state = NULL ; struct futex_hash_bucket * hb1 , * hb2 ; struct futex_q * this , * next ; DEFINE_WAKE_Q ( wake_q ) ; if ( ! IS_ENABLED ( CONFIG_FUTEX_PI ) && requeue_pi ) return - ENOSYS ; if ( requeue_pi ) { if ( uaddr1 == uaddr2 ) return - EINVAL ; if ( refill_pi_state_cache ( ) ) return - ENOMEM ; if ( nr_wake != 1 ) return - EINVAL ; } retry : ret = get_futex_key ( uaddr1 , flags & FLAGS_SHARED , & key1 , VERIFY_READ ) ; if ( unlikely ( ret != 0 ) ) goto out ; ret = get_futex_key ( uaddr2 , flags & FLAGS_SHARED , & key2 , requeue_pi ? VERIFY_WRITE : VERIFY_READ ) ; if ( unlikely ( ret != 0 ) ) goto out_put_key1 ; if ( requeue_pi && match_futex ( & key1 , & key2 ) ) { ret = - EINVAL ; goto out_put_keys ; } hb1 = hash_futex ( & key1 ) ; hb2 = hash_futex ( & key2 ) ; retry_private : hb_waiters_inc ( hb2 ) ; double_lock_hb ( hb1 , hb2 ) ; if ( likely ( cmpval != NULL ) ) { u32 curval ; ret = get_futex_value_locked ( & curval , uaddr1 ) ; if ( unlikely ( ret ) ) { double_unlock_hb ( hb1 , hb2 ) ; hb_waiters_dec ( hb2 ) ; ret = get_user ( curval , uaddr1 ) ; if ( ret ) goto out_put_keys ; if ( ! ( flags & FLAGS_SHARED ) ) goto retry_private ; put_futex_key ( & key2 ) ; put_futex_key ( & key1 ) ; goto retry ; } if ( curval != * cmpval ) { ret = - EAGAIN ; goto out_unlock ; } } if ( requeue_pi && ( task_count - nr_wake < nr_requeue ) ) { ret = futex_proxy_trylock_atomic ( uaddr2 , hb1 , hb2 , & key1 , & key2 , & pi_state , nr_requeue ) ; if ( ret > 0 ) { WARN_ON ( pi_state ) ; drop_count ++ ; task_count ++ ; ret = lookup_pi_state ( uaddr2 , ret , hb2 , & key2 , & pi_state ) ; } switch ( ret ) { case 0 : break ; case - EFAULT : double_unlock_hb ( hb1 , hb2 ) ; hb_waiters_dec ( hb2 ) ; put_futex_key ( & key2 ) ; put_futex_key ( & key1 ) ; ret = fault_in_user_writeable ( uaddr2 ) ; if ( ! ret ) goto retry ; goto out ; case - EAGAIN : double_unlock_hb ( hb1 , hb2 ) ; hb_waiters_dec ( hb2 ) ; put_futex_key ( & key2 ) ; put_futex_key ( & key1 ) ; cond_resched ( ) ; goto retry ; default : goto out_unlock ; } } plist_for_each_entry_safe ( this , next , & hb1 -> chain , list ) { if ( task_count - nr_wake >= nr_requeue ) break ; if ( ! match_futex ( & this -> key , & key1 ) ) continue ; if ( ( requeue_pi && ! this -> rt_waiter ) || ( ! requeue_pi && this -> rt_waiter ) || this -> pi_state ) { ret = - EINVAL ; break ; } if ( ++ task_count <= nr_wake && ! requeue_pi ) { mark_wake_futex ( & wake_q , this ) ; continue ; } if ( requeue_pi && ! match_futex ( this -> requeue_pi_key , & key2 ) ) { ret = - EINVAL ; break ; } if ( requeue_pi ) { get_pi_state ( pi_state ) ; this -> pi_state = pi_state ; ret = rt_mutex_start_proxy_lock ( & pi_state -> pi_mutex , this -> rt_waiter , this -> task ) ; if ( ret == 1 ) { requeue_pi_wake_futex ( this , & key2 , hb2 ) ; drop_count ++ ; continue ; } else if ( ret ) { this -> pi_state = NULL ; put_pi_state ( pi_state ) ; break ; } } requeue_futex ( this , hb1 , hb2 , & key2 ) ; drop_count ++ ; } put_pi_state ( pi_state ) ; out_unlock : double_unlock_hb ( hb1 , hb2 ) ; wake_up_q ( & wake_q ) ; hb_waiters_dec ( hb2 ) ; while ( -- drop_count >= 0 ) drop_futex_key_refs ( & key1 ) ; out_put_keys : put_futex_key ( & key2 ) ; out_put_key1 : put_futex_key ( & key1 ) ; out : return ret ? ret : task_count ; } "," ( wake_q ) ; if ( nr_wake < 0 || nr_requeue < 0 ) return - EINVAL ",torvalds@linux/fbe0e839d1e22d88810f3ee3e2f1479be4c0aa4a,CVE-2018-6927,https://github.com/torvalds/linux/commit/fbe0e839d1e22d88810f3ee3e2f1479be4c0aa4a,2018-02-12T19:29Z 1059,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 1060,CWE-119,"CWE-119 bool initiate_stratum ( struct pool * pool ) { char s [ RBUFSIZE ] , * sret = NULL , * nonce1 , * sessionid ; json_t * val = NULL , * res_val , * err_val ; bool ret = false , recvd = false ; json_error_t err ; int n2size ; if ( ! setup_stratum_curl ( pool ) ) goto out ; resend : if ( pool -> sessionid ) sprintf ( s , ""{\\""id\\"":%d,\\""method\\"":\\""mining.subscribe\\"",\\""params\\"":[\\""%s\\""]}"" , swork_id ++ , pool -> sessionid ) ; else sprintf ( s , ""{\\""id\\"":%d,\\""method\\"":\\""mining.subscribe\\"",\\""params\\"":[]}"" , swork_id ++ ) ; if ( ! __stratum_send ( pool , s , strlen ( s ) ) ) { applog ( LOG_DEBUG , ""Failedtosendsininitiate_stratum"" ) ; goto out ; } if ( ! socket_full ( pool , true ) ) { 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 = json_array_string ( json_array_get ( res_val , 0 ) , 1 ) ; if ( ! sessionid ) { applog ( LOG_INFO , ""Failedtogetsessionidininitiate_stratum"" ) ; goto out ; } 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 ; } mutex_lock ( & pool -> pool_lock ) ; pool -> sessionid = sessionid ; free ( pool -> nonce1 ) ; pool -> nonce1 = nonce1 ; pool -> n1_len = strlen ( nonce1 ) / 2 ; pool -> n2size = n2size ; mutex_unlock ( & pool -> pool_lock ) ; applog ( LOG_DEBUG , ""Pool%dstratumsessionid:%s"" , pool -> pool_no , pool -> sessionid ) ; ret = true ; out : if ( val ) json_decref ( val ) ; if ( ret ) { if ( ! pool -> stratum_url ) pool -> stratum_url = pool -> sockaddr_url ; pool -> stratum_active = true ; pool -> swork . diff = 1 ; if ( opt_protocol ) { applog ( LOG_DEBUG , ""Pool%dconfirmedmining.subscribewithextranonce1%sextran2size%d"" , pool -> pool_no , pool -> nonce1 , pool -> n2size ) ; } } else { if ( recvd && pool -> sessionid ) { mutex_lock ( & pool -> pool_lock ) ; free ( pool -> sessionid ) ; free ( pool -> nonce1 ) ; pool -> sessionid = pool -> nonce1 = NULL ; mutex_unlock ( & pool -> pool_lock ) ; applog ( LOG_DEBUG , ""Failedtoresumestratum,tryingafresh"" ) ; goto resend ; } applog ( LOG_DEBUG , ""Initiatestratumfailed"" ) ; if ( pool -> sock != INVSOCK ) { shutdown ( pool -> sock , SHUT_RDWR ) ; pool -> sock = INVSOCK ; } } return ret ; } "," ; if ( n2size < 1 ) { applog ( ",luke-jr@bfgminer/ff7f30129f15f7a2213f8ced0cd65c9a331493d9,CVE-2014-4502,https://github.com/luke-jr/bfgminer/commit/ff7f30129f15f7a2213f8ced0cd65c9a331493d9,2014-07-23T14:55Z 1061,CWE-787,"CWE-787 void * adminchild ( struct clientparam * param ) { int i , res ; char * buf ; char username [ 256 ] ; char * sb ; char * req = NULL ; struct printparam pp ; int contentlen = 0 ; int isform = 0 ; pp . inbuf = 0 ; pp . cp = param ; buf = myalloc ( LINESIZE ) ; if ( ! buf ) { RETURN ( 555 ) ; } i = sockgetlinebuf ( param , CLIENT , ( unsigned char * ) buf , LINESIZE - 1 , '\\n' , conf . timeouts [ STRING_S ] ) ; if ( i < 5 || ( ( buf [ 0 ] != 'G' || buf [ 1 ] != 'E' || buf [ 2 ] != 'T' || buf [ 3 ] != '' || buf [ 4 ] != '/' ) && ( buf [ 0 ] != 'P' || buf [ 1 ] != 'O' || buf [ 2 ] != 'S' || buf [ 3 ] != 'T' || buf [ 4 ] != '' || buf [ 5 ] != '/' ) ) ) { RETURN ( 701 ) ; } buf [ i ] = 0 ; sb = strchr ( buf + 5 , '' ) ; if ( ! sb ) { RETURN ( 702 ) ; } * sb = 0 ; req = mystrdup ( buf + ( ( * buf == 'P' ) ? 6 : 5 ) ) ; while ( ( i = sockgetlinebuf ( param , CLIENT , ( unsigned char * ) buf , LINESIZE - 1 , '\\n' , conf . timeouts [ STRING_S ] ) ) > 2 ) { buf [ i ] = 0 ; if ( i > 19 && ( ! strncasecmp ( buf , ""authorization"" , 13 ) ) ) { sb = strchr ( buf , ':' ) ; if ( ! sb ) continue ; ++ sb ; while ( isspace ( * sb ) ) sb ++ ; if ( ! * sb || strncasecmp ( sb , ""basic"" , 5 ) ) { continue ; } sb += 5 ; while ( isspace ( * sb ) ) sb ++ ; i = de64 ( ( unsigned char * ) sb , ( unsigned char * ) username , 255 ) ; if ( i <= 0 ) continue ; username [ i ] = 0 ; sb = strchr ( ( char * ) username , ':' ) ; if ( sb ) { * sb = 0 ; if ( param -> password ) myfree ( param -> password ) ; param -> password = ( unsigned char * ) mystrdup ( sb + 1 ) ; } if ( param -> username ) myfree ( param -> username ) ; param -> username = ( unsigned char * ) mystrdup ( username ) ; continue ; } else if ( i > 15 && ( ! strncasecmp ( buf , ""content-length:"" , 15 ) ) ) { sb = buf + 15 ; while ( isspace ( * sb ) ) sb ++ ; contentlen = atoi ( sb ) ; } else if ( i > 13 && ( ! strncasecmp ( buf , ""content-type:"" , 13 ) ) ) { sb = buf + 13 ; while ( isspace ( * sb ) ) sb ++ ; if ( ! strncasecmp ( sb , ""x-www-form-urlencoded"" , 21 ) ) isform = 1 ; } } param -> operation = ADMIN ; if ( isform && contentlen ) { printstr ( & pp , ""HTTP/1.0100Continue\\r\\n\\r\\n"" ) ; stdpr ( & pp , NULL , 0 ) ; } res = ( * param -> srv -> authfunc ) ( param ) ; if ( res && res != 10 ) { printstr ( & pp , authreq ) ; RETURN ( res ) ; } if ( param -> srv -> singlepacket || param -> redirected ) { if ( * req == 'C' ) req [ 1 ] = 0 ; else * req = 0 ; } sprintf ( buf , ok , conf . stringtable ? ( char * ) conf . stringtable [ 2 ] : ""3proxy"" , conf . stringtable ? ( char * ) conf . stringtable [ 2 ] : ""3[APA3A]tinyproxy"" , conf . stringtable ? ( char * ) conf . stringtable [ 3 ] : """" ) ; if ( * req != 'S' ) printstr ( & pp , buf ) ; switch ( * req ) { case 'C' : printstr ( & pp , counters ) ; { struct trafcount * cp ; int num = 0 ; for ( cp = conf . trafcounter ; cp ; cp = cp -> next , num ++ ) { int inbuf = 0 ; if ( cp -> ace && ( param -> srv -> singlepacket || param -> redirected ) ) { if ( ! ACLmatches ( cp -> ace , param ) ) continue ; } if ( req [ 1 ] == 'S' && atoi ( req + 2 ) == num ) cp -> disabled = 0 ; if ( req [ 1 ] == 'D' && atoi ( req + 2 ) == num ) cp -> disabled = 1 ; inbuf += sprintf ( buf , """" ""%sHREF=\\\'/C%c%d\\\'>%s"" , ( cp -> comment ) ? cp -> comment : "" "" , ( cp -> disabled ) ? 'S' : 'D' , num , ( cp -> disabled ) ? ""NO"" : ""YES"" ) ; if ( ! cp -> ace || ! cp -> ace -> users ) { inbuf += sprintf ( buf + inbuf , ""
ANY
"" ) ; } else { inbuf += printuserlist ( buf + inbuf , LINESIZE - 800 , cp -> ace -> users , "",/>\\r\\n"" ) ; } inbuf += sprintf ( buf + inbuf , """" ) ; if ( ! cp -> ace || ! cp -> ace -> src ) { inbuf += sprintf ( buf + inbuf , ""
ANY
"" ) ; } else { inbuf += printiplist ( buf + inbuf , LINESIZE - 512 , cp -> ace -> src , "",/>\\r\\n"" ) ; } inbuf += sprintf ( buf + inbuf , """" ) ; if ( ! cp -> ace || ! cp -> ace -> dst ) { inbuf += sprintf ( buf + inbuf , ""
ANY
"" ) ; } else { inbuf += printiplist ( buf + inbuf , LINESIZE - 512 , cp -> ace -> dst , "",/>\\r\\n"" ) ; } inbuf += sprintf ( buf + inbuf , """" ) ; if ( ! cp -> ace || ! cp -> ace -> ports ) { inbuf += sprintf ( buf + inbuf , ""
ANY
"" ) ; } else { inbuf += printportlist ( buf + inbuf , LINESIZE - 128 , cp -> ace -> ports , "",/>\\r\\n"" ) ; } if ( cp -> type == NONE ) { inbuf += sprintf ( buf + inbuf , ""colspan=\\\'6\\\'align=\\\'center\\\'>excludefromlimitation\\r\\n"" ) ; } else { inbuf += sprintf ( buf + inbuf , ""%"" PRINTF_INT64_MODIFIER ""u"" ""MB%s"" ""%"" PRINTF_INT64_MODIFIER ""u"" ""%s"" , cp -> traflim64 / ( 1024 * 1024 ) , rotations [ cp -> type ] , cp -> traf64 , cp -> cleared ? ctime ( & cp -> cleared ) : ""never"" ) ; inbuf += sprintf ( buf + inbuf , ""%s"" ""%i"" ""\\r\\n"" , cp -> updated ? ctime ( & cp -> updated ) : ""never"" , cp -> number ) ; } printstr ( & pp , buf ) ; } } printstr ( & pp , counterstail ) ; break ; case 'R' : conf . needreload = 1 ; printstr ( & pp , ""

Reloadscheduled

"" ) ; break ; case 'S' : { if ( req [ 1 ] == 'X' ) { printstr ( & pp , style ) ; break ; } printstr ( & pp , xml ) ; printval ( conf . services , TYPE_SERVER , 0 , & pp ) ; printstr ( & pp , postxml ) ; } break ; case 'F' : { FILE * fp ; char buf [ 256 ] ; fp = confopen ( ) ; if ( ! fp ) { printstr ( & pp , ""

color=\\""red\\"">Failedtoopenconfigfile

"" ) ; break ; } printstr ( & pp , ""

Pleasebecarefuleditingconfigfileremotely

"" ) ; printstr ( & pp , ""method=\\""POST\\""action=\\""/U\\"">cols=\\""80\\""rows=\\""30\\""name=\\""conffile\\"">"" ) ; while ( fgets ( buf , 256 , fp ) ) { printstr ( & pp , buf ) ; } if ( ! writable ) fclose ( fp ) ; printstr ( & pp , ""
type=\\""Submit\\"">"" ) ; break ; } case 'U' : { int l = 0 ; int error = 0 ; if ( ! writable || fseek ( writable , 0 , 0 ) ) { error = 1 ; } while ( ( i = sockgetlinebuf ( param , CLIENT , ( unsigned char * ) buf , LINESIZE - 1 , '+' , conf . timeouts [ STRING_S ] ) ) > 0 ) { if ( i > ( contentlen - l ) ) i = ( contentlen - l ) ; buf [ i ] = 0 ; if ( ! l ) { if ( strncasecmp ( buf , ""conffile="" , 9 ) ) error = 1 ; } if ( ! error ) { decodeurl ( ( unsigned char * ) buf , 1 ) ; fprintf ( writable , ""%s"" , l ? buf : buf + 9 ) ; } l += i ; if ( l >= contentlen ) break ; } if ( writable && ! error ) { fflush ( writable ) ; # ifndef _WINCE ftruncate ( fileno ( writable ) , ftell ( writable ) ) ; # endif } printstr ( & pp , error ? ""

color=\\""red\\"">Configfileisnotwritable

Makesureyouhave\\""writable\\""commandinconfigurationfile"" : ""

Configurationupdated

"" ) ; } break ; default : printstr ( & pp , ( char * ) conf . stringtable [ WEBBANNERS ] ) ; break ; } if ( * req != 'S' ) printstr ( & pp , tail ) ; CLEANRET : printstr ( & pp , NULL ) ; if ( buf ) myfree ( buf ) ; ( * param -> srv -> logfunc ) ( param , ( unsigned char * ) req ) ; if ( req ) myfree ( req ) ; freeparam ( param ) ; return ( NULL ) ; } "," printparam pp ; unsigned contentlen = 0 sb ++ ; sscanf ( sb , ""%u"" , & contentlen ) ; if ( contentlen > LINESIZE * 1024 ) contentlen = 0 ; } else & pp , ""method=\\""POST\\""action=\\""/U\\""enctype=\\""application/x-www-form-urlencoded\\"">cols=\\""80\\""rows=\\""30\\""name=\\""conffile\\"">"" ) ; while 'U' : { unsigned l = 0 ! writable || ! contentlen || } while ( l < contentlen && ) buf , ( contentlen - l ) > LINESIZE - 1 ? LINESIZE - 1 : contentlen - l l ) ; if ( ! l ) { if ( i < 9 || strncasecmp ( buf error ) { buf [ i ] = 0 ; l += i ; } if ",z3APA3A@3proxy/3b67dc844789dc0f00e934270c7b349bcb547865,CVE-2019-14495,https://github.com/z3APA3A/3proxy/commit/3b67dc844789dc0f00e934270c7b349bcb547865,2019-08-01T17:15Z 1062,CWE-354,"CWE-354 void recovery_cipher_init ( bool passphrase_protection , bool pin_protection , const char * language , const char * label , bool _enforce_wordlist , uint32_t _auto_lock_delay_ms , uint32_t _u2f_counter , bool _dry_run ) { enforce_wordlist = _enforce_wordlist ; dry_run = _dry_run ; if ( ! dry_run ) { if ( pin_protection ) { if ( ! change_pin ( ) ) { recovery_abort ( ) ; fsm_sendFailure ( FailureType_Failure_ActionCancelled , ""PINsdonotmatch"" ) ; layoutHome ( ) ; return ; } } else { storage_setPin ( """" ) ; } storage_setPassphraseProtected ( passphrase_protection ) ; storage_setLanguage ( language ) ; storage_setLabel ( label ) ; storage_setAutoLockDelayMs ( _auto_lock_delay_ms ) ; storage_setU2FCounter ( _u2f_counter ) ; } else if ( ! pin_protect ( ""EnterYourPIN"" ) ) { layoutHome ( ) ; return ; } if ( ! confirm ( ButtonRequestType_ButtonRequest_Other , dry_run ? ""RecoveryDryRun"" : ""Recovery"" , ""Whenenteringyourrecoveryseed,usethesubstitutioncipher"" ""andcheckthateachwordshowsupcorrectlyonthescreen."" ) ) { fsm_sendFailure ( FailureType_Failure_ActionCancelled , ""Recoverycancelled"" ) ; if ( ! dry_run ) storage_reset ( ) ; layoutHome ( ) ; return ; } memset ( mnemonic , 0 , sizeof ( mnemonic ) / sizeof ( char ) ) ; awaiting_character = true ; next_character ( ) ; } "," = true ; recovery_started = true ; ",keepkey@keepkey-firmware/769714fcb569e7a4faff9530a2d9ac1f9d6e5680,CVE-2019-18672,https://github.com/keepkey/keepkey-firmware/commit/769714fcb569e7a4faff9530a2d9ac1f9d6e5680,2019-12-06T18:15Z 1063,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 1064,CWE-125,"CWE-125 void skb_complete_tx_timestamp ( struct sk_buff * skb , struct skb_shared_hwtstamps * hwtstamps ) { struct sock * sk = skb -> sk ; if ( ! skb_may_tx_timestamp ( sk , false ) ) return ; if ( likely ( atomic_inc_not_zero ( & sk -> sk_refcnt ) ) ) { * skb_hwtstamps ( skb ) = * hwtstamps ; __skb_complete_tx_timestamp ( skb , sk , SCM_TSTAMP_SND ) ; sock_put ( sk ) ; } } "," sk , SCM_TSTAMP_SND , false ",torvalds@linux/4ef1b2869447411ad3ef91ad7d4891a83c1a509a,CVE-2017-7277,https://github.com/torvalds/linux/commit/4ef1b2869447411ad3ef91ad7d4891a83c1a509a,2017-03-28T06:59Z 1065,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 1066,CWE-264,"CWE-264 static int kvm_iommu_unmap_memslots ( struct kvm * kvm ) { int idx ; struct kvm_memslots * slots ; struct kvm_memory_slot * memslot ; idx = srcu_read_lock ( & kvm -> srcu ) ; slots = kvm_memslots ( kvm ) ; kvm_for_each_memslot ( memslot , slots ) kvm_iommu_put_pages ( kvm , memslot -> base_gfn , memslot -> npages ) ; srcu_read_unlock ( & kvm -> srcu , idx ) ; return 0 ; } "," , slots ) kvm_iommu_unmap_pages ( kvm , kvm , memslot ) ; srcu_read_unlock ",torvalds@linux/09ca8e1173bcb12e2a449698c9ae3b86a8a10195,CVE-2012-2121,https://github.com/torvalds/linux/commit/09ca8e1173bcb12e2a449698c9ae3b86a8a10195,2012-05-17T11:00Z 1067,CWE-476,"CWE-476 INTERNAL void vterm_allocator_free ( VTerm * vt , void * ptr ) { ( * vt -> allocator -> free ) ( ptr , vt -> allocdata ) ; } "," ptr ) { if ( ptr ) ",vim@vim/cd929f7ba8cc5b6d6dcf35c8b34124e969fed6b8,CVE-2018-20786,https://github.com/vim/vim/commit/cd929f7ba8cc5b6d6dcf35c8b34124e969fed6b8,2019-02-24T14:29Z 1068,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 1069,CWE-426,"CWE-426 static void usage ( void ) { fprintf ( stderr , ""usage:ssh-agent[-c|-s][-Dd][-abind_address][-Efingerprint_hash]\\n"" ""[-tlife][command[arg...]]\\n"" ""ssh-agent[-c|-s]-k\\n"" ) ; exit ( 1 ) ; } "," stderr , ""usage:ssh-agent[-c|-s][-Dd][-abind_address][-Efingerprint_hash]\\n"" ""[-Ppkcs11_whitelist][-tlife][command[arg...]]\\n"" ""ssh-agent[-c|-s]-k\\n"" ) ; ",openbsd@src/9476ce1dd37d3c3218d5640b74c34c65e5f4efe5,CVE-2016-10009,https://github.com/openbsd/src/commit/9476ce1dd37d3c3218d5640b74c34c65e5f4efe5,2017-01-05T02:59Z 1070,CWE-000,"CWE-000 static int nfs4_intent_set_file ( struct nameidata * nd , struct path * path , struct nfs4_state * state ) { struct file * filp ; int ret ; if ( nd -> intent . open . flags & FMODE_EXEC ) { ret = nfs_may_open ( state -> inode , state -> owner -> so_cred , nd -> intent . open . flags ) ; if ( ret < 0 ) goto out_close ; } filp = lookup_instantiate_filp ( nd , path -> dentry , NULL ) ; if ( ! IS_ERR ( filp ) ) { struct nfs_open_context * ctx ; ctx = nfs_file_open_context ( filp ) ; ctx -> state = state ; return 0 ; } ret = PTR_ERR ( filp ) ; out_close : nfs4_close_sync ( path , state , nd -> intent . open . flags ) ; return ret ; } "," nfs4_state * state , fmode_t fmode ; if ( fmode & FMODE_EXEC ) , state , fmode & ( FMODE_READ | FMODE_WRITE ) ) ; return ",torvalds@linux/dc0b027dfadfcb8a5504f7d8052754bf8d501ab9,CVE-2011-4324,https://github.com/torvalds/linux/commit/dc0b027dfadfcb8a5504f7d8052754bf8d501ab9,2012-06-21T23:55Z 1071,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 1072,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 1073,CWE-200,"CWE-200 static int crypto_report_comp ( struct sk_buff * skb , struct crypto_alg * alg ) { struct crypto_report_comp rcomp ; strlcpy ( rcomp . type , ""compression"" , sizeof ( rcomp . type ) ) ; 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 . ",torvalds@linux/f43f39958beb206b53292801e216d9b8a660f087,CVE-2018-19854,https://github.com/torvalds/linux/commit/f43f39958beb206b53292801e216d9b8a660f087,2018-12-04T16:29Z 1074,CWE-190,"CWE-190 static u_int16_t concat_hash_string ( struct ndpi_packet_struct * packet , char * buf , u_int8_t client_hash ) { u_int16_t offset = 22 , buf_out_len = 0 ; if ( offset + sizeof ( u_int32_t ) >= packet -> payload_packet_len ) goto invalid_payload ; u_int32_t len = ntohl ( * ( u_int32_t * ) & packet -> payload [ offset ] ) ; offset += 4 ; if ( ( offset >= packet -> payload_packet_len ) || ( len >= packet -> payload_packet_len - offset - 1 ) ) goto invalid_payload ; strncpy ( buf , ( const char * ) & packet -> payload [ offset ] , buf_out_len = len ) ; buf [ buf_out_len ++ ] = ';' ; offset += len ; if ( offset + sizeof ( u_int32_t ) >= packet -> payload_packet_len ) goto invalid_payload ; len = ntohl ( * ( u_int32_t * ) & packet -> payload [ offset ] ) ; offset += 4 + len ; if ( offset + sizeof ( u_int32_t ) >= packet -> payload_packet_len ) goto invalid_payload ; len = ntohl ( * ( u_int32_t * ) & packet -> payload [ offset ] ) ; if ( client_hash ) { offset += 4 ; if ( ( offset >= packet -> payload_packet_len ) || ( len >= packet -> payload_packet_len - offset - 1 ) ) goto invalid_payload ; strncpy ( & buf [ buf_out_len ] , ( const char * ) & packet -> payload [ offset ] , len ) ; buf_out_len += len ; buf [ buf_out_len ++ ] = ';' ; offset += len ; } else offset += 4 + len ; if ( offset + sizeof ( u_int32_t ) >= packet -> payload_packet_len ) goto invalid_payload ; len = ntohl ( * ( u_int32_t * ) & packet -> payload [ offset ] ) ; if ( ! client_hash ) { offset += 4 ; if ( ( offset >= packet -> payload_packet_len ) || ( len >= packet -> payload_packet_len - offset - 1 ) ) goto invalid_payload ; strncpy ( & buf [ buf_out_len ] , ( const char * ) & packet -> payload [ offset ] , len ) ; buf_out_len += len ; buf [ buf_out_len ++ ] = ';' ; offset += len ; } else offset += 4 + len ; if ( offset + sizeof ( u_int32_t ) >= packet -> payload_packet_len ) goto invalid_payload ; len = ntohl ( * ( u_int32_t * ) & packet -> payload [ offset ] ) ; if ( client_hash ) { offset += 4 ; if ( ( offset >= packet -> payload_packet_len ) || ( len >= packet -> payload_packet_len - offset - 1 ) ) goto invalid_payload ; strncpy ( & buf [ buf_out_len ] , ( const char * ) & packet -> payload [ offset ] , len ) ; buf_out_len += len ; buf [ buf_out_len ++ ] = ';' ; offset += len ; } else offset += 4 + len ; if ( offset + sizeof ( u_int32_t ) >= packet -> payload_packet_len ) goto invalid_payload ; len = ntohl ( * ( u_int32_t * ) & packet -> payload [ offset ] ) ; if ( ! client_hash ) { offset += 4 ; if ( ( offset >= packet -> payload_packet_len ) || ( len >= packet -> payload_packet_len - offset - 1 ) ) goto invalid_payload ; strncpy ( & buf [ buf_out_len ] , ( const char * ) & packet -> payload [ offset ] , len ) ; buf_out_len += len ; buf [ buf_out_len ++ ] = ';' ; offset += len ; } else offset += 4 + len ; if ( offset + sizeof ( u_int32_t ) >= packet -> payload_packet_len ) goto invalid_payload ; len = ntohl ( * ( u_int32_t * ) & packet -> payload [ offset ] ) ; if ( client_hash ) { offset += 4 ; if ( ( offset >= packet -> payload_packet_len ) || ( len >= packet -> payload_packet_len - offset - 1 ) ) goto invalid_payload ; strncpy ( & buf [ buf_out_len ] , ( const char * ) & packet -> payload [ offset ] , len ) ; buf_out_len += len ; offset += len ; } else offset += 4 + len ; if ( offset + sizeof ( u_int32_t ) >= packet -> payload_packet_len ) goto invalid_payload ; len = ntohl ( * ( u_int32_t * ) & packet -> payload [ offset ] ) ; if ( ! client_hash ) { offset += 4 ; if ( ( offset >= packet -> payload_packet_len ) || ( len >= packet -> payload_packet_len - offset - 1 ) ) goto invalid_payload ; strncpy ( & buf [ buf_out_len ] , ( const char * ) & packet -> payload [ offset ] , len ) ; buf_out_len += len ; offset += len ; } else offset += 4 + len ; # ifdef SSH_DEBUG printf ( ""[SSH]%s\\n"" , buf ) ; # endif return ( buf_out_len ) ; invalid_payload : # ifdef SSH_DEBUG printf ( ""[SSH]Invalidpacketpayload\\n"" ) ; # endif return ( 0 ) ; } "," client_hash ) { u_int32_t offset = 22 ] ) ; if ( len > UINT32_MAX - 4 - offset ) goto invalid_payload ; ] ) ; offset += 4 ; client_hash ) { if ( ( = ';' ; } if ( len > UINT32_MAX - offset ) goto invalid_payload ; offset += len ; if ] ) ; offset += 4 ; client_hash ) { if ( ( = ';' ; } if ( len > UINT32_MAX - offset ) goto invalid_payload ; offset += len ; if ] ) ; offset += 4 ; client_hash ) { if ( ( = ';' ; } if ( len > UINT32_MAX - offset ) goto invalid_payload ; offset += len ; if ] ) ; offset += 4 ; client_hash ) { if ( ( = ';' ; } if ( len > UINT32_MAX - offset ) goto invalid_payload ; offset += len ; if ] ) ; offset += 4 ; client_hash ) { if ( ( += len ; } if ( len > UINT32_MAX - offset ) goto invalid_payload ; offset += len ; if ] ) ; offset += 4 ; client_hash ) { if ( ( += len ; } if ( len > UINT32_MAX - offset ) goto invalid_payload ; offset += len ; # ",ntop@nDPI/7ce478a58b4dd29a8d1e6f4e9df2f778613d9202,CVE-2020-11939,https://github.com/ntop/nDPI/commit/7ce478a58b4dd29a8d1e6f4e9df2f778613d9202,2020-04-23T15:15Z 1075,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 ; pipe_buf_mark_unmergeable ( obuf ) ; 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/6b3a707736301c2128ca85ce85fb13f60b5e350a,CVE-2019-11487,https://github.com/torvalds/linux/commit/6b3a707736301c2128ca85ce85fb13f60b5e350a,2019-04-23T22:29Z 1076,CWE-362,"CWE-362 static int get_task_ioprio ( struct task_struct * p ) { int ret ; ret = security_task_getioprio ( p ) ; if ( ret ) goto out ; ret = IOPRIO_PRIO_VALUE ( IOPRIO_CLASS_NONE , IOPRIO_NORM ) ; if ( p -> io_context ) ret = p -> io_context -> ioprio ; out : return ret ; } "," IOPRIO_NORM ) ; task_lock ( p ) ; -> ioprio ; task_unlock ( p ) ; ",torvalds@linux/8ba8682107ee2ca3347354e018865d8e1967c5f4,CVE-2016-7911,https://github.com/torvalds/linux/commit/8ba8682107ee2ca3347354e018865d8e1967c5f4,2016-11-16T05:59Z 1077,CWE-416,"CWE-416 void fe_netjoin_init ( void ) { settings_add_bool ( ""misc"" , ""hide_netsplit_quits"" , TRUE ) ; settings_add_int ( ""misc"" , ""netjoin_max_nicks"" , 10 ) ; join_tag = - 1 ; printing_joins = FALSE ; read_settings ( ) ; signal_add ( ""setupchanged"" , ( SIGNAL_FUNC ) read_settings ) ; } "," read_settings ) ; signal_add ( ""serverdisconnected"" , ( SIGNAL_FUNC ) sig_server_disconnected ) ; ",irssi@irssi/77b2631c78461965bc9a7414aae206b5c514e1b3,CVE-2017-7191,https://github.com/irssi/irssi/commit/77b2631c78461965bc9a7414aae206b5c514e1b3,2017-03-27T17:59Z 1078,CWE-119,"CWE-119 void vp8_bilinear_predict4x4_neon ( unsigned char * src_ptr , int src_pixels_per_line , int xoffset , int yoffset , unsigned char * dst_ptr , int dst_pitch ) { uint8x8_t d0u8 , d1u8 , d2u8 , d3u8 , d4u8 , d5u8 , d6u8 ; uint8x8_t d26u8 , d27u8 , d28u8 , d29u8 , d30u8 ; uint32x2_t d28u32 , d29u32 , d30u32 ; uint8x16_t q1u8 , q2u8 ; uint16x8_t q1u16 , q2u16 ; uint16x8_t q7u16 , q8u16 , q9u16 ; uint64x2_t q4u64 , q5u64 ; uint64x1_t d12u64 ; uint32x2x2_t d0u32x2 , d1u32x2 , d2u32x2 , d3u32x2 ; if ( xoffset == 0 ) { d28u32 = vld1_lane_u32 ( ( const uint32_t * ) src_ptr , d28u32 , 0 ) ; src_ptr += src_pixels_per_line ; d28u32 = vld1_lane_u32 ( ( const uint32_t * ) src_ptr , d28u32 , 1 ) ; src_ptr += src_pixels_per_line ; d29u32 = vld1_lane_u32 ( ( const uint32_t * ) src_ptr , d29u32 , 0 ) ; src_ptr += src_pixels_per_line ; d29u32 = vld1_lane_u32 ( ( const uint32_t * ) src_ptr , d29u32 , 1 ) ; src_ptr += src_pixels_per_line ; d30u32 = vld1_lane_u32 ( ( const uint32_t * ) src_ptr , d30u32 , 0 ) ; d28u8 = vreinterpret_u8_u32 ( d28u32 ) ; d29u8 = vreinterpret_u8_u32 ( d29u32 ) ; d30u8 = vreinterpret_u8_u32 ( d30u32 ) ; } else { d2u8 = vld1_u8 ( src_ptr ) ; src_ptr += src_pixels_per_line ; d3u8 = vld1_u8 ( src_ptr ) ; src_ptr += src_pixels_per_line ; d4u8 = vld1_u8 ( src_ptr ) ; src_ptr += src_pixels_per_line ; d5u8 = vld1_u8 ( src_ptr ) ; src_ptr += src_pixels_per_line ; d6u8 = vld1_u8 ( src_ptr ) ; q1u8 = vcombine_u8 ( d2u8 , d3u8 ) ; q2u8 = vcombine_u8 ( d4u8 , d5u8 ) ; d0u8 = vdup_n_u8 ( ( uint8_t ) bifilter4_coeff [ xoffset ] [ 0 ] ) ; d1u8 = vdup_n_u8 ( ( uint8_t ) bifilter4_coeff [ xoffset ] [ 1 ] ) ; q4u64 = vshrq_n_u64 ( vreinterpretq_u64_u8 ( q1u8 ) , 8 ) ; q5u64 = vshrq_n_u64 ( vreinterpretq_u64_u8 ( q2u8 ) , 8 ) ; d12u64 = vshr_n_u64 ( vreinterpret_u64_u8 ( d6u8 ) , 8 ) ; d0u32x2 = vzip_u32 ( vreinterpret_u32_u8 ( vget_low_u8 ( q1u8 ) ) , vreinterpret_u32_u8 ( vget_high_u8 ( q1u8 ) ) ) ; d1u32x2 = vzip_u32 ( vreinterpret_u32_u8 ( vget_low_u8 ( q2u8 ) ) , vreinterpret_u32_u8 ( vget_high_u8 ( q2u8 ) ) ) ; d2u32x2 = vzip_u32 ( vreinterpret_u32_u64 ( vget_low_u64 ( q4u64 ) ) , vreinterpret_u32_u64 ( vget_high_u64 ( q4u64 ) ) ) ; d3u32x2 = vzip_u32 ( vreinterpret_u32_u64 ( vget_low_u64 ( q5u64 ) ) , vreinterpret_u32_u64 ( vget_high_u64 ( q5u64 ) ) ) ; q7u16 = vmull_u8 ( vreinterpret_u8_u32 ( d0u32x2 . val [ 0 ] ) , d0u8 ) ; q8u16 = vmull_u8 ( vreinterpret_u8_u32 ( d1u32x2 . val [ 0 ] ) , d0u8 ) ; q9u16 = vmull_u8 ( d6u8 , d0u8 ) ; q7u16 = vmlal_u8 ( q7u16 , vreinterpret_u8_u32 ( d2u32x2 . val [ 0 ] ) , d1u8 ) ; q8u16 = vmlal_u8 ( q8u16 , vreinterpret_u8_u32 ( d3u32x2 . val [ 0 ] ) , d1u8 ) ; q9u16 = vmlal_u8 ( q9u16 , vreinterpret_u8_u64 ( d12u64 ) , d1u8 ) ; d28u8 = vqrshrn_n_u16 ( q7u16 , 7 ) ; d29u8 = vqrshrn_n_u16 ( q8u16 , 7 ) ; d30u8 = vqrshrn_n_u16 ( q9u16 , 7 ) ; } if ( yoffset == 0 ) { vst1_lane_u32 ( ( uint32_t * ) dst_ptr , vreinterpret_u32_u8 ( d28u8 ) , 0 ) ; dst_ptr += dst_pitch ; vst1_lane_u32 ( ( uint32_t * ) dst_ptr , vreinterpret_u32_u8 ( d28u8 ) , 1 ) ; dst_ptr += dst_pitch ; vst1_lane_u32 ( ( uint32_t * ) dst_ptr , vreinterpret_u32_u8 ( d29u8 ) , 0 ) ; dst_ptr += dst_pitch ; vst1_lane_u32 ( ( uint32_t * ) dst_ptr , vreinterpret_u32_u8 ( d29u8 ) , 1 ) ; } else { d0u8 = vdup_n_u8 ( bifilter4_coeff [ yoffset ] [ 0 ] ) ; d1u8 = vdup_n_u8 ( bifilter4_coeff [ yoffset ] [ 1 ] ) ; q1u16 = vmull_u8 ( d28u8 , d0u8 ) ; q2u16 = vmull_u8 ( d29u8 , d0u8 ) ; d26u8 = vext_u8 ( d28u8 , d29u8 , 4 ) ; d27u8 = vext_u8 ( d29u8 , d30u8 , 4 ) ; q1u16 = vmlal_u8 ( q1u16 , d26u8 , d1u8 ) ; q2u16 = vmlal_u8 ( q2u16 , d27u8 , d1u8 ) ; d2u8 = vqrshrn_n_u16 ( q1u16 , 7 ) ; d3u8 = vqrshrn_n_u16 ( q2u16 , 7 ) ; vst1_lane_u32 ( ( uint32_t * ) dst_ptr , vreinterpret_u32_u8 ( d2u8 ) , 0 ) ; dst_ptr += dst_pitch ; vst1_lane_u32 ( ( uint32_t * ) dst_ptr , vreinterpret_u32_u8 ( d2u8 ) , 1 ) ; dst_ptr += dst_pitch ; vst1_lane_u32 ( ( uint32_t * ) dst_ptr , vreinterpret_u32_u8 ( d3u8 ) , 0 ) ; dst_ptr += dst_pitch ; vst1_lane_u32 ( ( uint32_t * ) dst_ptr , vreinterpret_u32_u8 ( d3u8 ) , 1 ) ; } return ; } "," , d30u8 ; uint8x16_t q1u8 , q2u8 ; uint16x8_t q1u16 , q2u16 ; uint16x8_t q7u16 , q8u16 , q9u16 ; uint64x2_t q4u64 , q5u64 ; uint64x1_t d12u64 ; uint32x2x2_t d0u32x2 , d1u32x2 , d2u32x2 , d3u32x2 ; if ( xoffset == 0 ) { uint32x2_t d28u32 = vdup_n_u32 ( 0 ) ; uint32x2_t d29u32 = vdup_n_u32 ( 0 ) ; uint32x2_t d30u32 = vdup_n_u32 ( 0 ) ; d28u32 = vld1_lane_u32 = vdup_n_u8 ( bifilter4_coeff [ xoffset = vdup_n_u8 ( bifilter4_coeff [ xoffset ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1079,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 1080,CWE-20,"CWE-20 static inline void VectorClamp ( DDSVector4 * 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 ) ) ; value -> w = MinF ( 1.0f , MaxF ( 0.0f , value -> w ) ) ; } "," -> 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 , -> w = 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 1081,CWE-369,"CWE-369 static void change_port_settings ( struct tty_struct * tty , struct edgeport_port * edge_port , struct ktermios * old_termios ) { struct device * dev = & edge_port -> port -> dev ; struct ump_uart_config * config ; int baud ; unsigned cflag ; int status ; int port_number = edge_port -> port -> port_number ; config = kmalloc ( sizeof ( * config ) , GFP_KERNEL ) ; if ( ! config ) { tty -> termios = * old_termios ; return ; } cflag = tty -> termios . c_cflag ; config -> wFlags = 0 ; config -> wFlags |= UMP_MASK_UART_FLAGS_RECEIVE_MS_INT ; config -> wFlags |= UMP_MASK_UART_FLAGS_AUTO_START_ON_ERR ; config -> bUartMode = ( __u8 ) ( edge_port -> bUartMode ) ; switch ( cflag & CSIZE ) { case CS5 : config -> bDataBits = UMP_UART_CHAR5BITS ; dev_dbg ( dev , ""%s-databits=5\\n"" , __func__ ) ; break ; case CS6 : config -> bDataBits = UMP_UART_CHAR6BITS ; dev_dbg ( dev , ""%s-databits=6\\n"" , __func__ ) ; break ; case CS7 : config -> bDataBits = UMP_UART_CHAR7BITS ; dev_dbg ( dev , ""%s-databits=7\\n"" , __func__ ) ; break ; default : case CS8 : config -> bDataBits = UMP_UART_CHAR8BITS ; dev_dbg ( dev , ""%s-databits=8\\n"" , __func__ ) ; break ; } if ( cflag & PARENB ) { if ( cflag & PARODD ) { config -> wFlags |= UMP_MASK_UART_FLAGS_PARITY ; config -> bParity = UMP_UART_ODDPARITY ; dev_dbg ( dev , ""%s-parity=odd\\n"" , __func__ ) ; } else { config -> wFlags |= UMP_MASK_UART_FLAGS_PARITY ; config -> bParity = UMP_UART_EVENPARITY ; dev_dbg ( dev , ""%s-parity=even\\n"" , __func__ ) ; } } else { config -> bParity = UMP_UART_NOPARITY ; dev_dbg ( dev , ""%s-parity=none\\n"" , __func__ ) ; } if ( cflag & CSTOPB ) { config -> bStopBits = UMP_UART_STOPBIT2 ; dev_dbg ( dev , ""%s-stopbits=2\\n"" , __func__ ) ; } else { config -> bStopBits = UMP_UART_STOPBIT1 ; dev_dbg ( dev , ""%s-stopbits=1\\n"" , __func__ ) ; } if ( cflag & CRTSCTS ) { config -> wFlags |= UMP_MASK_UART_FLAGS_OUT_X_CTS_FLOW ; config -> wFlags |= UMP_MASK_UART_FLAGS_RTS_FLOW ; dev_dbg ( dev , ""%s-RTS/CTSisenabled\\n"" , __func__ ) ; } else { dev_dbg ( dev , ""%s-RTS/CTSisdisabled\\n"" , __func__ ) ; restart_read ( edge_port ) ; } config -> cXon = START_CHAR ( tty ) ; config -> cXoff = STOP_CHAR ( tty ) ; if ( I_IXOFF ( tty ) ) { config -> wFlags |= UMP_MASK_UART_FLAGS_IN_X ; dev_dbg ( dev , ""%s-INBOUNDXON/XOFFisenabled,XON=%2x,XOFF=%2x\\n"" , __func__ , config -> cXon , config -> cXoff ) ; } else dev_dbg ( dev , ""%s-INBOUNDXON/XOFFisdisabled\\n"" , __func__ ) ; if ( I_IXON ( tty ) ) { config -> wFlags |= UMP_MASK_UART_FLAGS_OUT_X ; dev_dbg ( dev , ""%s-OUTBOUNDXON/XOFFisenabled,XON=%2x,XOFF=%2x\\n"" , __func__ , config -> cXon , config -> cXoff ) ; } else dev_dbg ( dev , ""%s-OUTBOUNDXON/XOFFisdisabled\\n"" , __func__ ) ; tty -> termios . c_cflag &= ~ CMSPAR ; baud = tty_get_baud_rate ( tty ) ; if ( ! baud ) { baud = 9600 ; } else tty_encode_baud_rate ( tty , baud , baud ) ; edge_port -> baud_rate = baud ; config -> wBaudRate = ( __u16 ) ( ( 461550L + baud / 2 ) / baud ) ; dev_dbg ( dev , ""%s-baudrate=%d,wBaudRate=%d\\n"" , __func__ , baud , config -> wBaudRate ) ; dev_dbg ( dev , ""wBaudRate:%d\\n"" , ( int ) ( 461550L / config -> wBaudRate ) ) ; dev_dbg ( dev , ""wFlags:0x%x\\n"" , config -> wFlags ) ; dev_dbg ( dev , ""bDataBits:%d\\n"" , config -> bDataBits ) ; dev_dbg ( dev , ""bParity:%d\\n"" , config -> bParity ) ; dev_dbg ( dev , ""bStopBits:%d\\n"" , config -> bStopBits ) ; dev_dbg ( dev , ""cXon:%d\\n"" , config -> cXon ) ; dev_dbg ( dev , ""cXoff:%d\\n"" , config -> cXoff ) ; dev_dbg ( dev , ""bUartMode:%d\\n"" , config -> bUartMode ) ; cpu_to_be16s ( & config -> wFlags ) ; cpu_to_be16s ( & config -> wBaudRate ) ; status = send_cmd ( edge_port -> port -> serial -> dev , UMPC_SET_CONFIG , ( __u8 ) ( UMPM_UART1_PORT + port_number ) , 0 , ( __u8 * ) config , sizeof ( * config ) ) ; if ( status ) dev_dbg ( dev , ""%s-error%dwhentryingtowriteconfigtodevice\\n"" , __func__ , status ) ; kfree ( config ) ; } "," ; } else { baud = min ( baud , 461550 ) ; baud ) ; } ",torvalds@linux/6aeb75e6adfaed16e58780309613a578fe1ee90b,CVE-2017-18360,https://github.com/torvalds/linux/commit/6aeb75e6adfaed16e58780309613a578fe1ee90b,2019-01-31T09:29Z 1082,CWE-189,"CWE-189 struct timespec ns_to_timespec ( const s64 nsec ) { struct timespec ts ; if ( ! nsec ) return ( struct timespec ) { 0 , 0 } ; ts . tv_sec = div_long_long_rem_signed ( nsec , NSEC_PER_SEC , & ts . tv_nsec ) ; if ( unlikely ( nsec < 0 ) ) set_normalized_timespec ( & ts , ts . tv_sec , ts . tv_nsec ) ; return ts ; } "," struct timespec ts ; s32 rem . tv_sec = div_s64_rem ( nsec , NSEC_PER_SEC , & rem ) ; if ( unlikely ( rem < 0 ) 0 ) ) { ts . tv_sec ts . tv_sec -- ; rem += NSEC_PER_SEC ; } ts . tv_nsec ts . tv_nsec = rem ; return ts ",torvalds@linux/f8bd2258e2d520dff28c855658bd24bdafb5102d,CVE-2011-3209,https://github.com/torvalds/linux/commit/f8bd2258e2d520dff28c855658bd24bdafb5102d,2012-10-03T11:02Z 1083,CWE-200,"CWE-200 static int llc_ui_recvmsg ( struct kiocb * iocb , struct socket * sock , struct msghdr * msg , size_t len , int flags ) { struct sockaddr_llc * uaddr = ( struct sockaddr_llc * ) msg -> msg_name ; const int nonblock = flags & MSG_DONTWAIT ; struct sk_buff * skb = NULL ; struct sock * sk = sock -> sk ; struct llc_sock * llc = llc_sk ( sk ) ; unsigned long cpu_flags ; size_t copied = 0 ; u32 peek_seq = 0 ; u32 * seq ; unsigned long used ; int target ; long timeo ; lock_sock ( sk ) ; copied = - ENOTCONN ; if ( unlikely ( sk -> sk_type == SOCK_STREAM && sk -> sk_state == TCP_LISTEN ) ) goto out ; timeo = sock_rcvtimeo ( sk , nonblock ) ; seq = & llc -> copied_seq ; if ( flags & MSG_PEEK ) { peek_seq = llc -> copied_seq ; seq = & peek_seq ; } target = sock_rcvlowat ( sk , flags & MSG_WAITALL , len ) ; copied = 0 ; do { u32 offset ; if ( signal_pending ( current ) ) { if ( copied ) break ; copied = timeo ? sock_intr_errno ( timeo ) : - EAGAIN ; break ; } skb = skb_peek ( & sk -> sk_receive_queue ) ; if ( skb ) { offset = * seq ; goto found_ok_skb ; } if ( copied >= target && ! sk -> sk_backlog . tail ) break ; if ( copied ) { if ( sk -> sk_err || sk -> sk_state == TCP_CLOSE || ( sk -> sk_shutdown & RCV_SHUTDOWN ) || ! timeo || ( flags & MSG_PEEK ) ) break ; } else { if ( sock_flag ( sk , SOCK_DONE ) ) break ; if ( sk -> sk_err ) { copied = sock_error ( sk ) ; break ; } if ( sk -> sk_shutdown & RCV_SHUTDOWN ) break ; if ( sk -> sk_type == SOCK_STREAM && sk -> sk_state == TCP_CLOSE ) { if ( ! sock_flag ( sk , SOCK_DONE ) ) { copied = - ENOTCONN ; break ; } break ; } if ( ! timeo ) { copied = - EAGAIN ; break ; } } if ( copied >= target ) { release_sock ( sk ) ; lock_sock ( sk ) ; } else sk_wait_data ( sk , & timeo ) ; if ( ( flags & MSG_PEEK ) && peek_seq != llc -> copied_seq ) { net_dbg_ratelimited ( ""LLC(%s:%d):Applicationbug,raceinMSG_PEEK\\n"" , current -> comm , task_pid_nr ( current ) ) ; peek_seq = llc -> copied_seq ; } continue ; found_ok_skb : used = skb -> len - offset ; if ( len < used ) used = len ; if ( ! ( flags & MSG_TRUNC ) ) { int rc = skb_copy_datagram_iovec ( skb , offset , msg -> msg_iov , used ) ; if ( rc ) { if ( ! copied ) copied = - EFAULT ; break ; } } * seq += used ; copied += used ; len -= used ; if ( sk -> sk_type != SOCK_STREAM ) goto copy_uaddr ; if ( ! ( flags & MSG_PEEK ) ) { spin_lock_irqsave ( & sk -> sk_receive_queue . lock , cpu_flags ) ; sk_eat_skb ( sk , skb , false ) ; spin_unlock_irqrestore ( & sk -> sk_receive_queue . lock , cpu_flags ) ; * seq = 0 ; } if ( used + offset < skb -> len ) continue ; } while ( len > 0 ) ; out : release_sock ( sk ) ; return copied ; copy_uaddr : if ( uaddr != NULL && skb != NULL ) { memcpy ( uaddr , llc_ui_skb_cb ( skb ) , sizeof ( * uaddr ) ) ; msg -> msg_namelen = sizeof ( * uaddr ) ; } if ( llc_sk ( sk ) -> cmsg_flags ) llc_cmsg_rcv ( msg , skb ) ; if ( ! ( flags & MSG_PEEK ) ) { spin_lock_irqsave ( & sk -> sk_receive_queue . lock , cpu_flags ) ; sk_eat_skb ( sk , skb , false ) ; spin_unlock_irqrestore ( & sk -> sk_receive_queue . lock , cpu_flags ) ; * seq = 0 ; } goto out ; } "," ; long timeo ; msg -> msg_namelen = 0 ",torvalds@linux/c77a4b9cffb6215a15196ec499490d116dfad181,CVE-2013-3231,https://github.com/torvalds/linux/commit/c77a4b9cffb6215a15196ec499490d116dfad181,2013-04-22T11:41Z 1084,CWE-119,"CWE-119 int CIFSFindNext ( const int xid , struct cifs_tcon * tcon , __u16 searchHandle , struct cifs_search_info * psrch_inf ) { TRANSACTION2_FNEXT_REQ * pSMB = NULL ; TRANSACTION2_FNEXT_RSP * pSMBr = NULL ; T2_FNEXT_RSP_PARMS * parms ; char * response_data ; int rc = 0 ; int bytes_returned , name_len ; __u16 params , byte_count ; cFYI ( 1 , ""InFindNext"" ) ; if ( psrch_inf -> endOfSearch ) return - ENOENT ; rc = smb_init ( SMB_COM_TRANSACTION2 , 15 , tcon , ( void * * ) & pSMB , ( void * * ) & pSMBr ) ; if ( rc ) return rc ; params = 14 ; byte_count = 0 ; pSMB -> TotalDataCount = 0 ; pSMB -> MaxParameterCount = cpu_to_le16 ( 8 ) ; pSMB -> MaxDataCount = cpu_to_le16 ( ( tcon -> ses -> server -> maxBuf - MAX_CIFS_HDR_SIZE ) & 0xFFFFFF00 ) ; pSMB -> MaxSetupCount = 0 ; pSMB -> Reserved = 0 ; pSMB -> Flags = 0 ; pSMB -> Timeout = 0 ; pSMB -> Reserved2 = 0 ; pSMB -> ParameterOffset = cpu_to_le16 ( offsetof ( struct smb_com_transaction2_fnext_req , SearchHandle ) - 4 ) ; pSMB -> DataCount = 0 ; pSMB -> DataOffset = 0 ; pSMB -> SetupCount = 1 ; pSMB -> Reserved3 = 0 ; pSMB -> SubCommand = cpu_to_le16 ( TRANS2_FIND_NEXT ) ; pSMB -> SearchHandle = searchHandle ; pSMB -> SearchCount = cpu_to_le16 ( CIFSMaxBufSize / sizeof ( FILE_UNIX_INFO ) ) ; pSMB -> InformationLevel = cpu_to_le16 ( psrch_inf -> info_level ) ; pSMB -> ResumeKey = psrch_inf -> resume_key ; pSMB -> SearchFlags = cpu_to_le16 ( CIFS_SEARCH_CLOSE_AT_END | CIFS_SEARCH_RETURN_RESUME ) ; name_len = psrch_inf -> resume_name_len ; params += name_len ; if ( name_len < PATH_MAX ) { memcpy ( pSMB -> ResumeFileName , psrch_inf -> presume_name , name_len ) ; byte_count += name_len ; pSMB -> ResumeFileName [ name_len ] = 0 ; pSMB -> ResumeFileName [ name_len + 1 ] = 0 ; } else { rc = - EINVAL ; goto FNext2_err_exit ; } byte_count = params + 1 ; pSMB -> TotalParameterCount = cpu_to_le16 ( params ) ; pSMB -> ParameterCount = pSMB -> TotalParameterCount ; inc_rfc1001_len ( pSMB , byte_count ) ; pSMB -> ByteCount = cpu_to_le16 ( byte_count ) ; rc = SendReceive ( xid , tcon -> ses , ( struct smb_hdr * ) pSMB , ( struct smb_hdr * ) pSMBr , & bytes_returned , 0 ) ; cifs_stats_inc ( & tcon -> num_fnext ) ; if ( rc ) { if ( rc == - EBADF ) { psrch_inf -> endOfSearch = true ; cifs_buf_release ( pSMB ) ; rc = 0 ; } else cFYI ( 1 , ""FindNextreturned=%d"" , rc ) ; } else { rc = validate_t2 ( ( struct smb_t2_rsp * ) pSMBr ) ; if ( rc == 0 ) { unsigned int lnoff ; if ( pSMBr -> hdr . Flags2 & SMBFLG2_UNICODE ) psrch_inf -> unicode = true ; else psrch_inf -> unicode = false ; response_data = ( char * ) & pSMBr -> hdr . Protocol + le16_to_cpu ( pSMBr -> t2 . ParameterOffset ) ; parms = ( T2_FNEXT_RSP_PARMS * ) response_data ; response_data = ( char * ) & pSMBr -> hdr . Protocol + le16_to_cpu ( pSMBr -> t2 . DataOffset ) ; if ( psrch_inf -> smallBuf ) cifs_small_buf_release ( psrch_inf -> ntwrk_buf_start ) ; else cifs_buf_release ( psrch_inf -> ntwrk_buf_start ) ; psrch_inf -> srch_entries_start = response_data ; psrch_inf -> ntwrk_buf_start = ( char * ) pSMB ; psrch_inf -> smallBuf = 0 ; if ( parms -> EndofSearch ) psrch_inf -> endOfSearch = true ; else psrch_inf -> endOfSearch = false ; psrch_inf -> entries_in_buffer = le16_to_cpu ( parms -> SearchCount ) ; psrch_inf -> index_of_last_entry += psrch_inf -> entries_in_buffer ; lnoff = le16_to_cpu ( parms -> LastNameOffset ) ; if ( tcon -> ses -> server -> maxBuf - MAX_CIFS_HDR_SIZE < lnoff ) { cERROR ( 1 , ""ignoringcorruptresumename"" ) ; psrch_inf -> last_entry = NULL ; return rc ; } else psrch_inf -> last_entry = psrch_inf -> srch_entries_start + lnoff ; } } FNext2_err_exit : if ( rc != 0 ) cifs_buf_release ( pSMB ) ; return rc ; } "," ; int bytes_returned ; unsigned int name_len ; __u16 ",torvalds@linux/9438fabb73eb48055b58b89fc51e0bc4db22fabd,CVE-2011-3191,https://github.com/torvalds/linux/commit/9438fabb73eb48055b58b89fc51e0bc4db22fabd,2012-05-24T23:55Z 1085,CWE-119,"CWE-119 static int kill_something_info ( int sig , struct siginfo * info , pid_t pid ) { int ret ; if ( pid > 0 ) { rcu_read_lock ( ) ; ret = kill_pid_info ( sig , info , find_vpid ( pid ) ) ; rcu_read_unlock ( ) ; return ret ; } read_lock ( & tasklist_lock ) ; if ( pid != - 1 ) { ret = __kill_pgrp_info ( sig , info , pid ? find_vpid ( - pid ) : task_pgrp ( current ) ) ; } else { int retval = 0 , count = 0 ; struct task_struct * p ; for_each_process ( p ) { if ( task_pid_vnr ( p ) > 1 && ! same_thread_group ( p , current ) ) { int err = group_send_sig_info ( sig , info , p ) ; ++ count ; if ( err != - EPERM ) retval = err ; } } ret = count ? retval : - ESRCH ; } read_unlock ( & tasklist_lock ) ; return ret ; } "," ret ; } if ( pid == INT_MIN ) return - ESRCH ; ",torvalds@linux/4ea77014af0d6205b05503d1c7aac6eace11d473,CVE-2018-10124,https://github.com/torvalds/linux/commit/4ea77014af0d6205b05503d1c7aac6eace11d473,2018-04-16T14:29Z 1086,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 1087,CWE-352,"CWE-352 static HttpResponse create_HttpResponse ( Socket_T S ) { HttpResponse res = NULL ; NEW ( res ) ; res -> S = S ; res -> status = SC_OK ; res -> outputbuffer = StringBuffer_create ( 256 ) ; res -> is_committed = false ; res -> protocol = SERVER_PROTOCOL ; res -> status_msg = get_status_string ( SC_OK ) ; return res ; } "," SC_OK ) ; Util_getToken ( res -> token ) ; ",tildeslash@monit/c6ec3820e627f85417053e6336de2987f2d863e3,CVE-2016-7067,https://bitbucket.org/tildeslash/monit/commit/c6ec3820e627f85417053e6336de2987f2d863e3,2018-09-10T14:29Z 1088,CWE-119,"CWE-119 static TX_SIZE read_tx_size ( VP9_COMMON * cm , MACROBLOCKD * xd , TX_MODE tx_mode , BLOCK_SIZE bsize , int allow_select , vp9_reader * r ) { const TX_SIZE max_tx_size = max_txsize_lookup [ bsize ] ; if ( allow_select && tx_mode == TX_MODE_SELECT && bsize >= BLOCK_8X8 ) return read_selected_tx_size ( cm , xd , max_tx_size , r ) ; else return MIN ( max_tx_size , tx_mode_to_biggest_tx_size [ tx_mode ] ) ; } "," * xd , int allow_select , int allow_select , vpx_reader * r ) r ) { TX_MODE tx_mode = cm -> tx_mode ; BLOCK_SIZE bsize = xd -> mi [ 0 ] -> mbmi . sb_type ; ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1089,CWE-264,"CWE-264 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 ; 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 ; br_write_lock ( & vfsmount_lock ) ; list_add_tail ( & mnt -> mnt_instance , & sb -> s_mounts ) ; br_write_unlock ( & vfsmount_lock ) ; 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 : free_vfsmnt ( mnt ) ; return ERR_PTR ( err ) ; } "," ~ MNT_WRITE_HOLD ; if ( ( flag & CL_UNPRIVILEGED ) && ( mnt -> mnt . mnt_flags & MNT_READONLY ) ) mnt -> mnt . mnt_flags |= MNT_LOCK_READONLY ; ",torvalds@linux/132c94e31b8bca8ea921f9f96a57d684fa4ae0a9,CVE-2013-1957,https://github.com/torvalds/linux/commit/132c94e31b8bca8ea921f9f96a57d684fa4ae0a9,2013-04-24T19:55Z 1090,CWE-59,"CWE-59 int add_mibdir ( const char * dirname ) { FILE * ip ; const char * oldFile = File ; char * * filenames ; int count = 0 ; int filename_count , i ; # if ! ( defined ( WIN32 ) || defined ( cygwin ) ) char * token ; char space ; char newline ; struct stat dir_stat , idx_stat ; char tmpstr [ 300 ] ; char tmpstr1 [ 300 ] ; # endif DEBUGMSGTL ( ( ""parse-mibs"" , ""Scanningdirectory%s\\n"" , dirname ) ) ; # if ! ( defined ( WIN32 ) || defined ( cygwin ) ) token = netsnmp_mibindex_lookup ( dirname ) ; if ( token && stat ( token , & idx_stat ) == 0 && stat ( dirname , & dir_stat ) == 0 ) { if ( dir_stat . st_mtime < idx_stat . st_mtime ) { DEBUGMSGTL ( ( ""parse-mibs"" , ""Theindexisgood\\n"" ) ) ; if ( ( ip = fopen ( token , ""r"" ) ) != NULL ) { fgets ( tmpstr , sizeof ( tmpstr ) , ip ) ; while ( fscanf ( ip , ""%127s%c%299[^\\n]%c"" , token , & space , tmpstr , & newline ) == 4 ) { if ( space != '' || newline != '\\n' ) { snmp_log ( LOG_ERR , ""add_mibdir:stringsscannedinfrom%s/%s"" ""aretoolarge.count=%d\\n"" , dirname , "".index"" , count ) ; break ; } snprintf ( tmpstr1 , sizeof ( tmpstr1 ) , ""%s/%s"" , dirname , tmpstr ) ; tmpstr1 [ sizeof ( tmpstr1 ) - 1 ] = 0 ; new_module ( token , tmpstr1 ) ; count ++ ; } fclose ( ip ) ; return count ; } else DEBUGMSGTL ( ( ""parse-mibs"" , ""Can\'treadindex\\n"" ) ) ; } else DEBUGMSGTL ( ( ""parse-mibs"" , ""Indexoutdated\\n"" ) ) ; } else DEBUGMSGTL ( ( ""parse-mibs"" , ""Noindex\\n"" ) ) ; # endif filename_count = scan_directory ( & filenames , dirname ) ; if ( filename_count >= 0 ) { ip = netsnmp_mibindex_new ( dirname ) ; for ( i = 0 ; i < filename_count ; i ++ ) { if ( add_mibfile ( filenames [ i ] , strrchr ( filenames [ i ] , '/' ) , ip ) == 0 ) count ++ ; free ( filenames [ i ] ) ; } File = oldFile ; if ( ip ) fclose ( ip ) ; free ( filenames ) ; return ( count ) ; } else DEBUGMSGTL ( ( ""parse-mibs"" , ""cannotopenMIBdirectory%s\\n"" , dirname ) ) ; return ( - 1 ) ; } "," dirname ) { const char * , i ; DEBUGMSGTL ( ( ) ) ; filename_count = scan_directory 0 ) { for ( i , '/' ) ) == 0 File = oldFile ; free ( ",net-snmp@net-snmp/4fd9a450444a434a993bc72f7c3486ccce41f602,CVE-2020-15861,https://github.com/net-snmp/net-snmp/commit/4fd9a450444a434a993bc72f7c3486ccce41f602,2020-08-20T01:17Z 1091,CWE-835,"CWE-835 static int read_data ( void * opaque , uint8_t * buf , int buf_size ) { struct playlist * v = opaque ; HLSContext * c = v -> parent -> priv_data ; int ret , i ; int just_opened = 0 ; restart : if ( ! v -> needed ) return AVERROR_EOF ; if ( ! v -> input ) { int64_t reload_interval ; struct segment * seg ; if ( v -> ctx && v -> ctx -> nb_streams ) { v -> needed = 0 ; for ( i = 0 ; i < v -> n_main_streams ; i ++ ) { if ( v -> main_streams [ i ] -> discard < AVDISCARD_ALL ) { v -> needed = 1 ; break ; } } } if ( ! v -> needed ) { av_log ( v -> parent , AV_LOG_INFO , ""Nolongerreceivingplaylist%d\\n"" , v -> index ) ; return AVERROR_EOF ; } reload_interval = default_reload_interval ( v ) ; reload : if ( ! v -> finished && av_gettime_relative ( ) - v -> last_load_time >= reload_interval ) { if ( ( ret = parse_playlist ( c , v -> url , v , NULL ) ) < 0 ) { av_log ( v -> parent , AV_LOG_WARNING , ""Failedtoreloadplaylist%d\\n"" , v -> index ) ; return ret ; } reload_interval = v -> target_duration / 2 ; } if ( v -> cur_seq_no < v -> start_seq_no ) { av_log ( NULL , AV_LOG_WARNING , ""skipping%dsegmentsahead,expiredfromplaylists\\n"" , v -> start_seq_no - v -> cur_seq_no ) ; v -> cur_seq_no = v -> start_seq_no ; } if ( v -> cur_seq_no >= v -> start_seq_no + v -> n_segments ) { if ( v -> finished ) return AVERROR_EOF ; while ( av_gettime_relative ( ) - v -> last_load_time < reload_interval ) { if ( ff_check_interrupt ( c -> interrupt_callback ) ) return AVERROR_EXIT ; av_usleep ( 100 * 1000 ) ; } goto reload ; } seg = current_segment ( v ) ; ret = update_init_section ( v , seg ) ; if ( ret ) return ret ; ret = open_input ( c , v , seg ) ; if ( ret < 0 ) { if ( ff_check_interrupt ( c -> interrupt_callback ) ) return AVERROR_EXIT ; av_log ( v -> parent , AV_LOG_WARNING , ""Failedtoopensegmentofplaylist%d\\n"" , v -> index ) ; v -> cur_seq_no += 1 ; goto reload ; } just_opened = 1 ; } if ( v -> init_sec_buf_read_offset < v -> init_sec_data_len ) { int copy_size = FFMIN ( v -> init_sec_data_len - v -> init_sec_buf_read_offset , buf_size ) ; memcpy ( buf , v -> init_sec_buf , copy_size ) ; v -> init_sec_buf_read_offset += copy_size ; return copy_size ; } ret = read_from_url ( v , current_segment ( v ) , buf , buf_size , READ_NORMAL ) ; if ( ret > 0 ) { if ( just_opened && v -> is_id3_timestamped != 0 ) { intercept_id3 ( v , buf , buf_size , & ret ) ; } return ret ; } ff_format_io_close ( v -> parent , & v -> input ) ; v -> cur_seq_no ++ ; c -> cur_seq_no = v -> cur_seq_no ; goto restart ; } "," ; int just_opened = 0 ; int reload_count ; reload : reload_count ++ ; if ( reload_count > c -> max_reload ) return AVERROR_EOF ; ",FFmpeg@FFmpeg/7ec414892ddcad88313848494b6fc5f437c9ca4a,CVE-2017-14058,https://github.com/FFmpeg/FFmpeg/commit/7ec414892ddcad88313848494b6fc5f437c9ca4a,2017-08-31T15:29Z 1092,CWE-862,"CWE-862 static int rename_in_ns ( int pid , char * oldname , char * * newnamep ) { int fd = - 1 , ofd = - 1 , ret , ifindex = - 1 ; bool grab_newname = false ; ofd = lxc_preserve_ns ( getpid ( ) , ""net"" ) ; if ( ofd < 0 ) { fprintf ( stderr , ""Failedopeningnetworknamespacepathfor\'%d\'."" , getpid ( ) ) ; return - 1 ; } fd = lxc_preserve_ns ( pid , ""net"" ) ; if ( fd < 0 ) { fprintf ( stderr , ""Failedopeningnetworknamespacepathfor\'%d\'."" , pid ) ; return - 1 ; } if ( setns ( fd , 0 ) < 0 ) { fprintf ( stderr , ""setnstocontainernetworknamespace\\n"" ) ; goto out_err ; } close ( fd ) ; fd = - 1 ; if ( ! * newnamep ) { grab_newname = true ; * newnamep = VETH_DEF_NAME ; if ( ! ( ifindex = if_nametoindex ( oldname ) ) ) { fprintf ( stderr , ""failedtogetnetdevindex\\n"" ) ; goto out_err ; } } if ( ( ret = lxc_netdev_rename_by_name ( oldname , * newnamep ) ) < 0 ) { fprintf ( stderr , ""Error%drenamingnetdev%sto%sincontainer\\n"" , ret , oldname , * newnamep ) ; goto out_err ; } if ( grab_newname ) { char ifname [ IFNAMSIZ ] , * namep = ifname ; if ( ! if_indextoname ( ifindex , namep ) ) { fprintf ( stderr , ""Failedtogetnewnetdevname\\n"" ) ; goto out_err ; } * newnamep = strdup ( namep ) ; if ( ! * newnamep ) goto out_err ; } if ( setns ( ofd , 0 ) < 0 ) { fprintf ( stderr , ""Errorreturningtooriginalnetns\\n"" ) ; close ( ofd ) ; return - 1 ; } close ( ofd ) ; return 0 ; out_err : if ( ofd >= 0 ) close ( ofd ) ; if ( setns ( ofd , 0 ) < 0 ) fprintf ( stderr , ""Errorreturningtooriginalnetworknamespace\\n"" ) ; if ( fd >= 0 ) close ( fd ) ; return - 1 ; } "," newnamep ) { uid_t ruid , suid , euid ; int fret = - 1 ; int fd = - 1 , ifindex = - 1 1 , ret ; bool grab_newname 0 ) { usernic_error ( ""Failedopeningnetworknamespacepathfor\'%d\'."" , getpid ) ; return fret ; } fd 0 ) { usernic_error ( ""Failedopeningnetworknamespacepathfor\'%d\'."" , pid pid ) ; goto do_partial_cleanup ; } ret = getresuid ( & ruid , & euid , & suid ) ; if ( ret < 0 ) { usernic_error ( ""Failedtoretrievereal,effective,andsaved"" ""userIDs:%s\\n"" , strerror ( errno ) ) ; goto do_partial_cleanup ; } ret = setns ( fd ( fd , CLONE_NEWNET ) ; close ( fd fd ) ; fd = - 1 ; if ( ret < 0 ) { usernic_error ( ""Failedtosetns()tothenetworknamespaceof"" ""thecontainerwithPID%d:%s.\\n"" , pid , strerror ( errno ) ) ; goto do_partial_cleanup ; } ret = setresuid ( ruid , ruid , 0 ) ; if ( ret < 0 ) { usernic_error ( ""Failedtodropprivilegebysettingeffective"" ""useridandrealuseridto%d,andsaveduser"" ""IDto0:%s.\\n"" , ruid , strerror ( errno ) ) ; goto do_full_cleanup ; } if ( ! = VETH_DEF_NAME ; ifindex = if_nametoindex ( oldname ) ; if ( ! ifindex ) { usernic_error ( ""Failedtogetnetdevindex:%s.\\n"" , strerror ( errno ) ) ; goto do_full_cleanup ; } } ret = lxc_netdev_rename_by_name ( oldname , * newnamep ) ; if ( ret < 0 ) { usernic_error ( ""Error%drenamingnetdev%sto%sincontainer.\\n"" , ret , oldname , * * newnamep ) ; goto do_full_cleanup ; } if [ IFNAMSIZ ] ; char * namep = ) ) { usernic_error ( ""Failedtogetnewnetdevname:%s.\\n"" , strerror ( errno ) ) ; goto do_full_cleanup ; } * newnamep ) goto do_full_cleanup ; } fret = 0 ; do_full_cleanup : ret = setresuid ( ruid , euid , suid ) ; if ( ret < 0 ) { usernic_error ( ""Failedtorestoreprivilegebysettingeffective"" ""useridto%d,realuseridto%d,andsaveduser"" ""IDto%d:%s.\\n"" , ruid , euid , suid , strerror ( errno ) ) ; fret = - 1 ; } ret = setns ( ofd ( ofd , CLONE_NEWNET ) ; if ( ret < 0 ) { usernic_error ( ""Failedtosetns()tooriginalnetworknamespace"" ""ofPID%d:%s.\\n"" , ofd , strerror ( errno ) ) ; fret = - 1 ; } do_partial_cleanup : if ( fd >= 0 ) close ( fd ) ; close ( ofd ) ; ) ; return fret ; } ",lxc@lxc/16af238036a5464ae8f2420ed3af214f0de875f9,CVE-2017-5985,https://github.com/lxc/lxc/commit/16af238036a5464ae8f2420ed3af214f0de875f9,2017-03-14T17:59Z 1093,CWE-190,"CWE-190 void silk_NLSF_stabilize ( opus_int16 * NLSF_Q15 , const opus_int16 * NDeltaMin_Q15 , const opus_int L ) { opus_int i , I = 0 , k , loops ; opus_int16 center_freq_Q15 ; opus_int32 diff_Q15 , min_diff_Q15 , min_center_Q15 , max_center_Q15 ; silk_assert ( NDeltaMin_Q15 [ L ] >= 1 ) ; for ( loops = 0 ; loops < MAX_LOOPS ; loops ++ ) { min_diff_Q15 = NLSF_Q15 [ 0 ] - NDeltaMin_Q15 [ 0 ] ; I = 0 ; for ( i = 1 ; i <= L - 1 ; i ++ ) { diff_Q15 = NLSF_Q15 [ i ] - ( NLSF_Q15 [ i - 1 ] + NDeltaMin_Q15 [ i ] ) ; if ( diff_Q15 < min_diff_Q15 ) { min_diff_Q15 = diff_Q15 ; I = i ; } } diff_Q15 = ( 1 << 15 ) - ( NLSF_Q15 [ L - 1 ] + NDeltaMin_Q15 [ L ] ) ; if ( diff_Q15 < min_diff_Q15 ) { min_diff_Q15 = diff_Q15 ; I = L ; } if ( min_diff_Q15 >= 0 ) { return ; } if ( I == 0 ) { NLSF_Q15 [ 0 ] = NDeltaMin_Q15 [ 0 ] ; } else if ( I == L ) { NLSF_Q15 [ L - 1 ] = ( 1 << 15 ) - NDeltaMin_Q15 [ L ] ; } else { min_center_Q15 = 0 ; for ( k = 0 ; k < I ; k ++ ) { min_center_Q15 += NDeltaMin_Q15 [ k ] ; } min_center_Q15 += silk_RSHIFT ( NDeltaMin_Q15 [ I ] , 1 ) ; max_center_Q15 = 1 << 15 ; for ( k = L ; k > I ; k -- ) { max_center_Q15 -= NDeltaMin_Q15 [ k ] ; } max_center_Q15 -= silk_RSHIFT ( NDeltaMin_Q15 [ I ] , 1 ) ; center_freq_Q15 = ( opus_int16 ) silk_LIMIT_32 ( silk_RSHIFT_ROUND ( ( opus_int32 ) NLSF_Q15 [ I - 1 ] + ( opus_int32 ) NLSF_Q15 [ I ] , 1 ) , min_center_Q15 , max_center_Q15 ) ; NLSF_Q15 [ I - 1 ] = center_freq_Q15 - silk_RSHIFT ( NDeltaMin_Q15 [ I ] , 1 ) ; NLSF_Q15 [ I ] = NLSF_Q15 [ I - 1 ] + NDeltaMin_Q15 [ I ] ; } } if ( loops == MAX_LOOPS ) { silk_insertion_sort_increasing_all_values_int16 ( & NLSF_Q15 [ 0 ] , L ) ; NLSF_Q15 [ 0 ] = silk_max_int ( NLSF_Q15 [ 0 ] , NDeltaMin_Q15 [ 0 ] ) ; for ( i = 1 ; i < L ; i ++ ) NLSF_Q15 [ i ] = silk_max_int ( NLSF_Q15 [ i ] , NLSF_Q15 [ i - 1 ] + NDeltaMin_Q15 [ i ] ) ; NLSF_Q15 [ L - 1 ] = silk_min_int ( NLSF_Q15 [ L - 1 ] , ( 1 << 15 ) - NDeltaMin_Q15 [ L ] ) ; for ( i = L - 2 ; i >= 0 ; i -- ) NLSF_Q15 [ i ] = silk_min_int ( NLSF_Q15 [ i ] , NLSF_Q15 [ i + 1 ] - NDeltaMin_Q15 [ i + 1 ] ) ; } } "," i ] , silk_ADD_SAT16 ( NLSF_Q15 [ i - 1 ] , NDeltaMin_Q15 [ i ] ) ) ; NLSF_Q15 ",external@libopus/0d052d64480a30e83fcdda80f4774624e044beb7,CVE-2017-0381,https://android.googlesource.com/platform/external/libopus/+/0d052d64480a30e83fcdda80f4774624e044beb7,2017-01-12T20:59Z 1094,CWE-119,"CWE-119 void vp8_dequant_idct_add_c ( short * input , short * dq , unsigned char * dest , int stride ) { int i ; for ( i = 0 ; i < 16 ; i ++ ) { input [ i ] = dq [ i ] * input [ i ] ; } vp8_short_idct4x4llm_c ( input , dest , stride , dest , stride ) ; vpx_memset ( input , 0 , 32 ) ; } "," stride ) ; memset ( input , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1095,CWE-20,"CWE-20 bool_t enc624j600IrqHandler ( NetInterface * interface ) { bool_t flag ; uint16_t status ; flag = FALSE ; enc624j600ClearBit ( interface , ENC624J600_REG_EIE , EIE_INTIE ) ; status = enc624j600ReadReg ( interface , ENC624J600_REG_EIR ) ; if ( ( status & EIR_LINKIF ) != 0 ) { enc624j600ClearBit ( interface , ENC624J600_REG_EIE , EIE_LINKIE ) ; interface -> nicEvent = TRUE ; flag |= osSetEventFromIsr ( & netEvent ) ; } if ( ( status & EIR_PKTIF ) != 0 ) { enc624j600ClearBit ( interface , ENC624J600_REG_EIE , EIE_PKTIE ) ; interface -> nicEvent = TRUE ; flag |= osSetEventFromIsr ( & netEvent ) ; } if ( ( status & ( EIR_TXIF | EIR_TXABTIF ) ) != 0 ) { enc624j600ClearBit ( interface , ENC624J600_REG_EIR , EIR_TXIF | EIR_TXABTIF ) ; flag |= osSetEventFromIsr ( & interface -> nicTxEvent ) ; } enc624j600SetBit ( interface , ENC624J600_REG_EIE , EIE_INTIE ) ; return flag ; } "," ( interface , ENC624J600_EIE , ENC624J600_EIE_INTIE ) ; status ( interface , ENC624J600_EIR ) ; if ( status & ENC624J600_EIR_LINKIF ) != 0 ( interface , ENC624J600_EIE , ENC624J600_EIE_LINKIE ) ; interface ( status & ENC624J600_EIR_PKTIF ) != 0 ( interface , ENC624J600_EIE , ENC624J600_EIE_PKTIE ) ; interface status & ( ENC624J600_EIR_TXIF | ENC624J600_EIR_TXABTIF ) ) != ( interface , ENC624J600_EIR , ENC624J600_EIR_TXIF | ENC624J600_EIR_TXABTIF ) ; flag ( interface , ENC624J600_EIE , ENC624J600_EIE_INTIE ) ; return ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 1096,CWE-416,"CWE-416 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 1097,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 1098,CWE-119,"CWE-119 static int atusb_get_and_show_build ( struct atusb * atusb ) { struct usb_device * usb_dev = atusb -> usb_dev ; char build [ ATUSB_BUILD_SIZE + 1 ] ; int ret ; ret = atusb_control_msg ( atusb , usb_rcvctrlpipe ( usb_dev , 0 ) , ATUSB_BUILD , ATUSB_REQ_FROM_DEV , 0 , 0 , build , ATUSB_BUILD_SIZE , 1000 ) ; if ( ret >= 0 ) { build [ ret ] = 0 ; dev_info ( & usb_dev -> dev , ""Firmware:build%s\\n"" , build ) ; } return ret ; } "," usb_dev ; char * build ; int ret ; int ret ; build = kmalloc ( ATUSB_BUILD_SIZE + 1 , GFP_KERNEL ) ; if ( ! build ) return - ENOMEM ) ; } kfree ( build ) ; ",torvalds@linux/05a974efa4bdf6e2a150e3f27dc6fcf0a9ad5655,CVE-2017-5548,https://github.com/torvalds/linux/commit/05a974efa4bdf6e2a150e3f27dc6fcf0a9ad5655,2017-02-06T06:59Z 1099,CWE-125,"CWE-125 static node * parsetok ( struct tok_state * tok , grammar * g , int start , perrdetail * err_ret , int * flags ) { parser_state * ps ; node * n ; int started = 0 ; int col_offset , end_col_offset ; if ( ( ps = PyParser_New ( g , start ) ) == NULL ) { err_ret -> error = E_NOMEM ; PyTokenizer_Free ( tok ) ; return NULL ; } # ifdef PY_PARSER_REQUIRES_FUTURE_KEYWORD if ( * flags & PyPARSE_BARRY_AS_BDFL ) ps -> p_flags |= CO_FUTURE_BARRY_AS_BDFL ; # endif for ( ; ; ) { char * a , * b ; int type ; size_t len ; char * str ; col_offset = - 1 ; int lineno ; const char * line_start ; type = PyTokenizer_Get ( tok , & a , & b ) ; if ( type == ERRORTOKEN ) { err_ret -> error = tok -> done ; break ; } if ( type == ENDMARKER && started ) { type = NEWLINE ; started = 0 ; if ( tok -> indent && ! ( * flags & PyPARSE_DONT_IMPLY_DEDENT ) ) { tok -> pendin = - tok -> indent ; tok -> indent = 0 ; } } else started = 1 ; len = ( a != NULL && b != NULL ) ? b - a : 0 ; str = ( char * ) PyObject_MALLOC ( len + 1 ) ; if ( str == NULL ) { err_ret -> error = E_NOMEM ; break ; } if ( len > 0 ) strncpy ( str , a , len ) ; str [ len ] = '\\0' ; # ifdef PY_PARSER_REQUIRES_FUTURE_KEYWORD if ( type == NOTEQUAL ) { if ( ! ( ps -> p_flags & CO_FUTURE_BARRY_AS_BDFL ) && strcmp ( str , ""!="" ) ) { PyObject_FREE ( str ) ; err_ret -> error = E_SYNTAX ; break ; } else if ( ( ps -> p_flags & CO_FUTURE_BARRY_AS_BDFL ) && strcmp ( str , ""<>"" ) ) { PyObject_FREE ( str ) ; err_ret -> expected = NOTEQUAL ; err_ret -> error = E_SYNTAX ; break ; } } # endif lineno = type == STRING ? tok -> first_lineno : tok -> lineno ; line_start = type == STRING ? tok -> multi_line_start : tok -> line_start ; if ( a != NULL && a >= line_start ) { col_offset = Py_SAFE_DOWNCAST ( a - line_start , intptr_t , int ) ; } else { col_offset = - 1 ; } if ( b != NULL && b >= tok -> line_start ) { end_col_offset = Py_SAFE_DOWNCAST ( b - tok -> line_start , intptr_t , int ) ; } else { end_col_offset = - 1 ; } if ( ( err_ret -> error = PyParser_AddToken ( ps , ( int ) type , str , lineno , col_offset , tok -> lineno , end_col_offset , & ( err_ret -> expected ) ) ) != E_OK ) { if ( err_ret -> error != E_DONE ) { PyObject_FREE ( str ) ; err_ret -> token = type ; } break ; } } if ( err_ret -> error == E_DONE ) { n = ps -> p_tree ; ps -> p_tree = NULL ; # ifndef PGEN if ( start == single_input ) { char * cur = tok -> cur ; char c = * tok -> cur ; for ( ; ; ) { while ( c == '' || c == '\\t' || c == '\\n' || c == '\\014' ) c = * ++ cur ; if ( ! c ) break ; if ( c != '#' ) { err_ret -> error = E_BADSINGLE ; PyNode_Free ( n ) ; n = NULL ; break ; } while ( c && c != '\\n' ) c = * ++ cur ; } } # endif } else n = NULL ; # ifdef PY_PARSER_REQUIRES_FUTURE_KEYWORD * flags = ps -> p_flags ; # endif PyParser_Delete ( ps ) ; if ( n == NULL ) { if ( tok -> done == E_EOF ) err_ret -> error = E_EOF ; err_ret -> lineno = tok -> lineno ; if ( tok -> buf != NULL ) { size_t len ; assert ( tok -> cur - tok -> buf < INT_MAX ) ; err_ret -> offset = col_offset != - 1 ? col_offset + 1 : ( ( int ) ( tok -> cur - tok -> buf ) ) ; len = tok -> inp - tok -> buf ; err_ret -> text = ( char * ) PyObject_MALLOC ( len + 1 ) ; if ( err_ret -> text != NULL ) { if ( len > 0 ) strncpy ( err_ret -> text , tok -> buf , len ) ; err_ret -> text [ len ] = '\\0' ; } } } else if ( tok -> encoding != NULL ) { node * r = PyNode_New ( encoding_decl ) ; if ( r ) r -> n_str = PyObject_MALLOC ( strlen ( tok -> encoding ) + 1 ) ; if ( ! r || ! r -> n_str ) { err_ret -> error = E_NOMEM ; if ( r ) PyObject_FREE ( r ) ; n = NULL ; goto done ; } strcpy ( r -> n_str , tok -> encoding ) ; PyMem_FREE ( tok -> encoding ) ; tok -> encoding = NULL ; r -> n_nchildren = 1 ; r -> n_child = n ; n = r ; } done : PyTokenizer_Free ( tok ) ; if ( n != NULL ) { _PyNode_FinalizeEndPos ( n ) ; } return n ; } "," , end_col_offset ; growable_int_array type_ignores ; if ( ! growable_int_array_init ( & type_ignores , 10 ) ) { err_ret -> error = E_NOMEM ; PyTokenizer_Free ( tok ) ; return NULL ; } p_flags |= CO_FUTURE_BARRY_AS_BDFL ; if ( * flags & PyPARSE_TYPE_COMMENTS ) ps -> p_flags |= PyCF_TYPE_COMMENTS } if ( type == TYPE_IGNORE ) { if ( ! growable_int_array_add ( & type_ignores , tok -> lineno ) ) { err_ret -> error = E_NOMEM ; break ; } continue ; } if ( p_tree = NULL ; if ( n -> n_type == file_input ) { int num ; node * ch ; size_t i ; num = NCH ( n ) ; ch = CHILD ( n , num - 1 ) ; REQ ( ch , ENDMARKER ) ; for ( i = 0 ; i < type_ignores . num_items ; i ++ ) { PyNode_AddChild ( ch , TYPE_IGNORE , NULL , type_ignores . items [ i ] , 0 , type_ignores . items [ i ] , 0 ) ; } } growable_int_array_deallocate ( & type_ignores ) ",python@typed_ast/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,CVE-2019-19275,https://github.com/python/typed_ast/commit/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,2019-11-26T15:15Z 1100,CWE-189,"CWE-189 int do_adjtimex ( struct timex * txc ) { long mtemp , save_adjust , rem ; s64 freq_adj ; int result ; if ( txc -> modes && ! capable ( CAP_SYS_TIME ) ) return - EPERM ; if ( ( txc -> modes & ADJ_OFFSET_SINGLESHOT ) == ADJ_OFFSET_SINGLESHOT ) { if ( txc -> modes != ADJ_OFFSET_SINGLESHOT && txc -> modes != ADJ_OFFSET_SS_READ ) return - EINVAL ; } if ( txc -> modes != ADJ_OFFSET_SINGLESHOT && ( txc -> modes & ADJ_OFFSET ) ) if ( txc -> offset <= - MAXPHASE || txc -> offset >= MAXPHASE ) return - EINVAL ; if ( txc -> modes & ADJ_TICK ) if ( txc -> tick < 900000 / USER_HZ || txc -> tick > 1100000 / USER_HZ ) return - EINVAL ; write_seqlock_irq ( & xtime_lock ) ; result = time_state ; save_adjust = time_adjust ; # if 0 time_status &= ~ STA_CLOCKERR ; # endif if ( txc -> modes ) { if ( txc -> modes & ADJ_STATUS ) time_status = ( txc -> status & ~ STA_RONLY ) | ( time_status & STA_RONLY ) ; if ( txc -> modes & ADJ_FREQUENCY ) { if ( txc -> freq > MAXFREQ || txc -> freq < - MAXFREQ ) { result = - EINVAL ; goto leave ; } time_freq = ( ( s64 ) txc -> freq * NSEC_PER_USEC ) >> ( SHIFT_USEC - SHIFT_NSEC ) ; } if ( txc -> modes & ADJ_MAXERROR ) { if ( txc -> maxerror < 0 || txc -> maxerror >= NTP_PHASE_LIMIT ) { result = - EINVAL ; goto leave ; } time_maxerror = txc -> maxerror ; } if ( txc -> modes & ADJ_ESTERROR ) { if ( txc -> esterror < 0 || txc -> esterror >= NTP_PHASE_LIMIT ) { result = - EINVAL ; goto leave ; } time_esterror = txc -> esterror ; } if ( txc -> modes & ADJ_TIMECONST ) { if ( txc -> constant < 0 ) { result = - EINVAL ; goto leave ; } time_constant = min ( txc -> constant + 4 , ( long ) MAXTC ) ; } if ( txc -> modes & ADJ_OFFSET ) { if ( txc -> modes == ADJ_OFFSET_SINGLESHOT ) { time_adjust = txc -> offset ; } else if ( time_status & STA_PLL ) { time_offset = txc -> offset * NSEC_PER_USEC ; time_offset = min ( time_offset , ( s64 ) MAXPHASE * NSEC_PER_USEC ) ; time_offset = max ( time_offset , ( s64 ) - MAXPHASE * NSEC_PER_USEC ) ; if ( time_status & STA_FREQHOLD || time_reftime == 0 ) time_reftime = xtime . tv_sec ; mtemp = xtime . tv_sec - time_reftime ; time_reftime = xtime . tv_sec ; freq_adj = time_offset * mtemp ; freq_adj = shift_right ( freq_adj , time_constant * 2 + ( SHIFT_PLL + 2 ) * 2 - SHIFT_NSEC ) ; if ( mtemp >= MINSEC && ( time_status & STA_FLL || mtemp > MAXSEC ) ) freq_adj += div_s64 ( time_offset << ( SHIFT_NSEC - SHIFT_FLL ) , mtemp ) ; freq_adj += time_freq ; freq_adj = min ( freq_adj , ( s64 ) MAXFREQ_NSEC ) ; time_freq = max ( freq_adj , ( s64 ) - MAXFREQ_NSEC ) ; time_offset = div_long_long_rem_signed ( time_offset , NTP_INTERVAL_FREQ , & rem ) ; time_offset <<= SHIFT_UPDATE ; } } if ( txc -> modes & ADJ_TICK ) tick_usec = txc -> tick ; if ( txc -> modes & ( ADJ_TICK | ADJ_FREQUENCY | ADJ_OFFSET ) ) ntp_update_frequency ( ) ; } leave : if ( ( time_status & ( STA_UNSYNC | STA_CLOCKERR ) ) != 0 ) result = TIME_ERROR ; if ( ( txc -> modes == ADJ_OFFSET_SINGLESHOT ) || ( txc -> modes == ADJ_OFFSET_SS_READ ) ) txc -> offset = save_adjust ; else txc -> offset = ( ( long ) shift_right ( time_offset , SHIFT_UPDATE ) ) * NTP_INTERVAL_FREQ / 1000 ; txc -> freq = ( time_freq / NSEC_PER_USEC ) << ( SHIFT_USEC - SHIFT_NSEC ) ; txc -> maxerror = time_maxerror ; txc -> esterror = time_esterror ; txc -> status = time_status ; txc -> constant = time_constant ; txc -> precision = 1 ; txc -> tolerance = MAXFREQ ; txc -> tick = tick_usec ; txc -> ppsfreq = 0 ; txc -> jitter = 0 ; txc -> shift = 0 ; txc -> stabil = 0 ; txc -> jitcnt = 0 ; txc -> calcnt = 0 ; txc -> errcnt = 0 ; txc -> stbcnt = 0 ; write_sequnlock_irq ( & xtime_lock ) ; do_gettimeofday ( & txc -> time ) ; notify_cmos_timer ( ) ; return ( result ) ; } "," mtemp , save_adjust ; s64 freq_adj ; time_offset = div_s64 ( time_offset , time_offset , NTP_INTERVAL_FREQ ) ; time_offset ",torvalds@linux/f8bd2258e2d520dff28c855658bd24bdafb5102d,CVE-2011-3209,https://github.com/torvalds/linux/commit/f8bd2258e2d520dff28c855658bd24bdafb5102d,2012-10-03T11:02Z 1101,CWE-17,"CWE-17 static struct super_block * alloc_super ( struct file_system_type * type , int flags ) { struct super_block * s = kzalloc ( sizeof ( struct super_block ) , GFP_USER ) ; static const struct super_operations default_op ; int i ; if ( ! s ) return NULL ; if ( security_sb_alloc ( s ) ) goto fail ; # ifdef CONFIG_SMP s -> s_files = alloc_percpu ( struct list_head ) ; if ( ! s -> s_files ) goto fail ; for_each_possible_cpu ( i ) INIT_LIST_HEAD ( per_cpu_ptr ( s -> s_files , i ) ) ; # else INIT_LIST_HEAD ( & s -> s_files ) ; # endif for ( i = 0 ; i < SB_FREEZE_LEVELS ; i ++ ) { if ( percpu_counter_init ( & s -> s_writers . counter [ i ] , 0 ) < 0 ) goto fail ; lockdep_init_map ( & s -> s_writers . lock_map [ i ] , sb_writers_name [ i ] , & type -> s_writers_key [ i ] , 0 ) ; } init_waitqueue_head ( & s -> s_writers . wait ) ; init_waitqueue_head ( & s -> s_writers . wait_unfrozen ) ; s -> s_flags = flags ; s -> s_bdi = & default_backing_dev_info ; INIT_HLIST_NODE ( & s -> s_instances ) ; INIT_HLIST_BL_HEAD ( & s -> s_anon ) ; INIT_LIST_HEAD ( & s -> s_inodes ) ; if ( list_lru_init ( & s -> s_dentry_lru ) ) goto fail ; if ( list_lru_init ( & s -> s_inode_lru ) ) goto fail ; INIT_LIST_HEAD ( & s -> s_mounts ) ; init_rwsem ( & s -> s_umount ) ; lockdep_set_class ( & s -> s_umount , & type -> s_umount_key ) ; down_write_nested ( & s -> s_umount , SINGLE_DEPTH_NESTING ) ; s -> s_count = 1 ; atomic_set ( & s -> s_active , 1 ) ; mutex_init ( & s -> s_vfs_rename_mutex ) ; lockdep_set_class ( & s -> s_vfs_rename_mutex , & type -> s_vfs_rename_key ) ; mutex_init ( & s -> s_dquot . dqio_mutex ) ; mutex_init ( & s -> s_dquot . dqonoff_mutex ) ; init_rwsem ( & s -> s_dquot . dqptr_sem ) ; s -> s_maxbytes = MAX_NON_LFS ; s -> s_op = & default_op ; s -> s_time_gran = 1000000000 ; s -> cleancache_poolid = - 1 ; s -> s_shrink . seeks = DEFAULT_SEEKS ; s -> s_shrink . scan_objects = super_cache_scan ; s -> s_shrink . count_objects = super_cache_count ; s -> s_shrink . batch = 1024 ; s -> s_shrink . flags = SHRINKER_NUMA_AWARE ; return s ; fail : destroy_super ( s ) ; return NULL ; } "," goto fail ; for ( i = 0 ; i < SB_FREEZE_LEVELS ; i ++ ) { if ( percpu_counter_init ( & s -> s_writers . counter [ i ] , 0 ) < 0 ) goto fail goto fail ; lockdep_init_map ( & s -> s_writers . lock_map [ i ] , sb_writers_name [ i ] , & type -> s_writers_key [ i ] , 0 ) ; } init_waitqueue_head ( & s -> s_writers . wait ) ; init_waitqueue_head ( & s -> s_writers . wait_unfrozen ) ; s -> s_flags = flags ; s -> s_bdi = & default_backing_dev_info ; INIT_HLIST_NODE ( & s -> s_instances ) ; INIT_HLIST_BL_HEAD ( & s -> s_anon ) ; INIT_LIST_HEAD ( & s -> s_inodes ) ; if ( list_lru_init ( & s -> s_dentry_lru ) ) goto fail goto fail ; if ( list_lru_init & s -> s_inode_lru ) ) goto goto fail ; INIT_LIST_HEAD ( & ",torvalds@linux/eee5cc2702929fd41cce28058dc6d6717f723f87,CVE-2014-8172,https://github.com/torvalds/linux/commit/eee5cc2702929fd41cce28058dc6d6717f723f87,2015-03-16T10:59Z 1102,CWE-264,"CWE-264 static FILE * open_log_file ( void ) { if ( log_fp ) return log_fp ; log_fp = fopen ( log_file , ""a+"" ) ; if ( log_fp == NULL ) { if ( daemon_mode == FALSE ) { printf ( ""Warning:Cannotopenlogfile\'%s\'forwriting\\n"" , log_file ) ; } return NULL ; } ( void ) fcntl ( fileno ( log_fp ) , F_SETFD , FD_CLOEXEC ) ; return log_fp ; } "," void ) { int fh ; struct stat st ; if ( log_fp ) return log_fp ; if ( ( fh = open ( log_file , O_RDWR | O_APPEND | O_CREAT | O_NOFOLLOW , S_IRUSR | S_IWUSR ) ) == - 1 ) { if ( daemon_mode == FALSE ) printf ( ""Warning:Cannotopenlogfile\'%s\'forwriting\\n"" , log_file ) ; return NULL ; } log_fp = fdopen ( fh , ""a+"" ) == FALSE ) printf ( ""Warning:Cannotopenlogfile\'%s\'forwriting\\n"" log_file ) ; return NULL ; } if ( ( fstat ( fh , & st ) ) == - 1 ) { log_fp = NULL ; close ( fh ) ; if ( daemon_mode == FALSE ) printf ( ""Warning:Cannotfstatlogfile\'%s\'\\n"" , log_file ) ; return NULL ; } if ( st . st_nlink != 1 || ( st . st_mode & S_IFMT ) != S_IFREG ) { log_fp = NULL ; close ( fh ) ; if ( daemon_mode == FALSE ) printf ( ""Warning:logfile\'%s\'hasaninvalidmode\\n"" , log_file ) ; return NULL ; ",NagiosEnterprises@nagioscore/c29557dec91eba2306f5fb11b8da4474ba63f8c4,CVE-2016-9566,https://github.com/NagiosEnterprises/nagioscore/commit/c29557dec91eba2306f5fb11b8da4474ba63f8c4,2016-12-15T22:59Z 1103,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 1104,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 1105,CWE-264,"CWE-264 int cg_write ( const char * path , const char * buf , size_t size , off_t offset , struct fuse_file_info * fi ) { struct fuse_context * fc = fuse_get_context ( ) ; char * localbuf = NULL ; struct cgfs_files * k = NULL ; struct file_info * f = ( struct file_info * ) fi -> fh ; bool r ; if ( f -> type != LXC_TYPE_CGFILE ) { fprintf ( stderr , ""Internalerror:directorycacheinfousedincg_write\\n"" ) ; return - EIO ; } if ( offset ) return 0 ; if ( ! fc ) return - EIO ; localbuf = alloca ( size + 1 ) ; localbuf [ size ] = '\\0' ; memcpy ( localbuf , buf , size ) ; if ( ( k = cgfs_get_key ( f -> controller , f -> cgroup , f -> file ) ) == NULL ) { size = - EINVAL ; goto out ; } if ( ! fc_may_access ( fc , f -> controller , f -> cgroup , f -> file , O_WRONLY ) ) { size = - EACCES ; goto out ; } if ( strcmp ( f -> file , ""tasks"" ) == 0 || strcmp ( f -> file , ""/tasks"" ) == 0 || strcmp ( f -> file , ""/cgroup.procs"" ) == 0 || strcmp ( f -> file , ""cgroup.procs"" ) == 0 ) r = do_write_pids ( fc -> pid , f -> controller , f -> cgroup , f -> file , localbuf ) ; else r = cgfs_set_value ( f -> controller , f -> cgroup , f -> file , localbuf ) ; if ( ! r ) size = - EINVAL ; out : free_key ( k ) ; return size ; } "," -> pid , fc -> uid , ",lxc@lxcfs/8ee2a503e102b1a43ec4d83113dc275ab20a869a,CVE-2015-1344,https://github.com/lxc/lxcfs/commit/8ee2a503e102b1a43ec4d83113dc275ab20a869a,2015-12-07T20:59Z 1106,CWE-415,"CWE-415 int sc_file_set_sec_attr ( sc_file_t * file , const u8 * sec_attr , size_t sec_attr_len ) { u8 * tmp ; if ( ! sc_file_valid ( file ) ) { return SC_ERROR_INVALID_ARGUMENTS ; } if ( sec_attr == NULL ) { if ( file -> sec_attr != NULL ) free ( file -> sec_attr ) ; file -> sec_attr = NULL ; file -> sec_attr_len = 0 ; return 0 ; } tmp = ( u8 * ) realloc ( file -> sec_attr , sec_attr_len ) ; if ( ! tmp ) { if ( file -> sec_attr ) free ( file -> sec_attr ) ; file -> sec_attr = NULL ; file -> sec_attr_len = 0 ; return SC_ERROR_OUT_OF_MEMORY ; } file -> sec_attr = tmp ; memcpy ( file -> sec_attr , sec_attr , sec_attr_len ) ; file -> sec_attr_len = sec_attr_len ; return 0 ; } "," sec_attr == NULL || sec_attr_len ",OpenSC@OpenSC/360e95d45ac4123255a4c796db96337f332160ad,CVE-2018-16425,https://github.com/OpenSC/OpenSC/commit/360e95d45ac4123255a4c796db96337f332160ad,2018-09-04T00:29Z 1107,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 1108,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 1109,CWE-476,"CWE-476 static int show_stream ( WriterContext * w , AVFormatContext * fmt_ctx , int stream_idx , InputStream * ist , int in_program ) { AVStream * stream = ist -> st ; AVCodecParameters * par ; AVCodecContext * dec_ctx ; char val_str [ 128 ] ; const char * s ; AVRational sar , dar ; AVBPrint pbuf ; const AVCodecDescriptor * cd ; int ret = 0 ; const char * profile = NULL ; av_bprint_init ( & pbuf , 1 , AV_BPRINT_SIZE_UNLIMITED ) ; writer_print_section_header ( w , in_program ? SECTION_ID_PROGRAM_STREAM : SECTION_ID_STREAM ) ; print_int ( ""index"" , stream -> index ) ; par = stream -> codecpar ; dec_ctx = ist -> dec_ctx ; if ( cd = avcodec_descriptor_get ( par -> codec_id ) ) { print_str ( ""codec_name"" , cd -> name ) ; if ( ! do_bitexact ) { print_str ( ""codec_long_name"" , cd -> long_name ? cd -> long_name : ""unknown"" ) ; } } else { print_str_opt ( ""codec_name"" , ""unknown"" ) ; if ( ! do_bitexact ) { print_str_opt ( ""codec_long_name"" , ""unknown"" ) ; } } if ( ! do_bitexact && ( profile = avcodec_profile_name ( par -> codec_id , par -> profile ) ) ) print_str ( ""profile"" , profile ) ; else { if ( par -> profile != FF_PROFILE_UNKNOWN ) { char profile_num [ 12 ] ; snprintf ( profile_num , sizeof ( profile_num ) , ""%d"" , par -> profile ) ; print_str ( ""profile"" , profile_num ) ; } else print_str_opt ( ""profile"" , ""unknown"" ) ; } s = av_get_media_type_string ( par -> codec_type ) ; if ( s ) print_str ( ""codec_type"" , s ) ; else print_str_opt ( ""codec_type"" , ""unknown"" ) ; # if FF_API_LAVF_AVCTX if ( dec_ctx ) print_q ( ""codec_time_base"" , dec_ctx -> time_base , '/' ) ; # endif print_str ( ""codec_tag_string"" , av_fourcc2str ( par -> codec_tag ) ) ; print_fmt ( ""codec_tag"" , ""0x%04"" PRIx32 , par -> codec_tag ) ; switch ( par -> codec_type ) { case AVMEDIA_TYPE_VIDEO : print_int ( ""width"" , par -> width ) ; print_int ( ""height"" , par -> height ) ; if ( dec_ctx ) { print_int ( ""coded_width"" , dec_ctx -> coded_width ) ; print_int ( ""coded_height"" , dec_ctx -> coded_height ) ; } print_int ( ""has_b_frames"" , par -> video_delay ) ; sar = av_guess_sample_aspect_ratio ( fmt_ctx , stream , NULL ) ; if ( sar . den ) { print_q ( ""sample_aspect_ratio"" , sar , ':' ) ; av_reduce ( & dar . num , & dar . den , par -> width * sar . num , par -> height * sar . den , 1024 * 1024 ) ; print_q ( ""display_aspect_ratio"" , dar , ':' ) ; } else { print_str_opt ( ""sample_aspect_ratio"" , ""N/A"" ) ; print_str_opt ( ""display_aspect_ratio"" , ""N/A"" ) ; } s = av_get_pix_fmt_name ( par -> format ) ; if ( s ) print_str ( ""pix_fmt"" , s ) ; else print_str_opt ( ""pix_fmt"" , ""unknown"" ) ; print_int ( ""level"" , par -> level ) ; if ( par -> color_range != AVCOL_RANGE_UNSPECIFIED ) print_str ( ""color_range"" , av_color_range_name ( par -> color_range ) ) ; else print_str_opt ( ""color_range"" , ""N/A"" ) ; if ( par -> color_space != AVCOL_SPC_UNSPECIFIED ) print_str ( ""color_space"" , av_color_space_name ( par -> color_space ) ) ; else print_str_opt ( ""color_space"" , av_color_space_name ( par -> color_space ) ) ; if ( par -> color_trc != AVCOL_TRC_UNSPECIFIED ) print_str ( ""color_transfer"" , av_color_transfer_name ( par -> color_trc ) ) ; else print_str_opt ( ""color_transfer"" , av_color_transfer_name ( par -> color_trc ) ) ; if ( par -> color_primaries != AVCOL_PRI_UNSPECIFIED ) print_str ( ""color_primaries"" , av_color_primaries_name ( par -> color_primaries ) ) ; else print_str_opt ( ""color_primaries"" , av_color_primaries_name ( par -> color_primaries ) ) ; if ( par -> chroma_location != AVCHROMA_LOC_UNSPECIFIED ) print_str ( ""chroma_location"" , av_chroma_location_name ( par -> chroma_location ) ) ; else print_str_opt ( ""chroma_location"" , av_chroma_location_name ( par -> chroma_location ) ) ; if ( par -> field_order == AV_FIELD_PROGRESSIVE ) print_str ( ""field_order"" , ""progressive"" ) ; else if ( par -> field_order == AV_FIELD_TT ) print_str ( ""field_order"" , ""tt"" ) ; else if ( par -> field_order == AV_FIELD_BB ) print_str ( ""field_order"" , ""bb"" ) ; else if ( par -> field_order == AV_FIELD_TB ) print_str ( ""field_order"" , ""tb"" ) ; else if ( par -> field_order == AV_FIELD_BT ) print_str ( ""field_order"" , ""bt"" ) ; else print_str_opt ( ""field_order"" , ""unknown"" ) ; # if FF_API_PRIVATE_OPT if ( dec_ctx && dec_ctx -> timecode_frame_start >= 0 ) { char tcbuf [ AV_TIMECODE_STR_SIZE ] ; av_timecode_make_mpeg_tc_string ( tcbuf , dec_ctx -> timecode_frame_start ) ; print_str ( ""timecode"" , tcbuf ) ; } else { print_str_opt ( ""timecode"" , ""N/A"" ) ; } # endif if ( dec_ctx ) print_int ( ""refs"" , dec_ctx -> refs ) ; break ; case AVMEDIA_TYPE_AUDIO : s = av_get_sample_fmt_name ( par -> format ) ; if ( s ) print_str ( ""sample_fmt"" , s ) ; else print_str_opt ( ""sample_fmt"" , ""unknown"" ) ; print_val ( ""sample_rate"" , par -> sample_rate , unit_hertz_str ) ; print_int ( ""channels"" , par -> channels ) ; if ( par -> channel_layout ) { av_bprint_clear ( & pbuf ) ; av_bprint_channel_layout ( & pbuf , par -> channels , par -> channel_layout ) ; print_str ( ""channel_layout"" , pbuf . str ) ; } else { print_str_opt ( ""channel_layout"" , ""unknown"" ) ; } print_int ( ""bits_per_sample"" , av_get_bits_per_sample ( par -> codec_id ) ) ; break ; case AVMEDIA_TYPE_SUBTITLE : if ( par -> width ) print_int ( ""width"" , par -> width ) ; else print_str_opt ( ""width"" , ""N/A"" ) ; if ( par -> height ) print_int ( ""height"" , par -> height ) ; else print_str_opt ( ""height"" , ""N/A"" ) ; break ; } if ( dec_ctx && dec_ctx -> codec && dec_ctx -> codec -> priv_class && show_private_data ) { const AVOption * opt = NULL ; while ( opt = av_opt_next ( dec_ctx -> priv_data , opt ) ) { uint8_t * str ; if ( opt -> flags ) continue ; if ( av_opt_get ( dec_ctx -> priv_data , opt -> name , 0 , & str ) >= 0 ) { print_str ( opt -> name , str ) ; av_free ( str ) ; } } } if ( fmt_ctx -> iformat -> flags & AVFMT_SHOW_IDS ) print_fmt ( ""id"" , ""0x%x"" , stream -> id ) ; else print_str_opt ( ""id"" , ""N/A"" ) ; print_q ( ""r_frame_rate"" , stream -> r_frame_rate , '/' ) ; print_q ( ""avg_frame_rate"" , stream -> avg_frame_rate , '/' ) ; print_q ( ""time_base"" , stream -> time_base , '/' ) ; print_ts ( ""start_pts"" , stream -> start_time ) ; print_time ( ""start_time"" , stream -> start_time , & stream -> time_base ) ; print_ts ( ""duration_ts"" , stream -> duration ) ; print_time ( ""duration"" , stream -> duration , & stream -> time_base ) ; if ( par -> bit_rate > 0 ) print_val ( ""bit_rate"" , par -> bit_rate , unit_bit_per_second_str ) ; else print_str_opt ( ""bit_rate"" , ""N/A"" ) ; # if FF_API_LAVF_AVCTX if ( stream -> codec -> rc_max_rate > 0 ) print_val ( ""max_bit_rate"" , stream -> codec -> rc_max_rate , unit_bit_per_second_str ) ; else print_str_opt ( ""max_bit_rate"" , ""N/A"" ) ; # endif if ( dec_ctx && dec_ctx -> bits_per_raw_sample > 0 ) print_fmt ( ""bits_per_raw_sample"" , ""%d"" , dec_ctx -> bits_per_raw_sample ) ; else print_str_opt ( ""bits_per_raw_sample"" , ""N/A"" ) ; if ( stream -> nb_frames ) print_fmt ( ""nb_frames"" , ""%"" PRId64 , stream -> nb_frames ) ; else print_str_opt ( ""nb_frames"" , ""N/A"" ) ; if ( nb_streams_frames [ stream_idx ] ) print_fmt ( ""nb_read_frames"" , ""%"" PRIu64 , nb_streams_frames [ stream_idx ] ) ; else print_str_opt ( ""nb_read_frames"" , ""N/A"" ) ; if ( nb_streams_packets [ stream_idx ] ) print_fmt ( ""nb_read_packets"" , ""%"" PRIu64 , nb_streams_packets [ stream_idx ] ) ; else print_str_opt ( ""nb_read_packets"" , ""N/A"" ) ; if ( do_show_data ) writer_print_data ( w , ""extradata"" , par -> extradata , par -> extradata_size ) ; writer_print_data_hash ( w , ""extradata_hash"" , par -> extradata , par -> extradata_size ) ; # define PRINT_DISPOSITION ( flagname , name ) do { print_int ( name , ! ! ( stream -> disposition & AV_DISPOSITION_ ## flagname ) ) ; } while ( 0 ) if ( do_show_stream_disposition ) { writer_print_section_header ( w , in_program ? SECTION_ID_PROGRAM_STREAM_DISPOSITION : SECTION_ID_STREAM_DISPOSITION ) ; PRINT_DISPOSITION ( DEFAULT , ""default"" ) ; PRINT_DISPOSITION ( DUB , ""dub"" ) ; PRINT_DISPOSITION ( ORIGINAL , ""original"" ) ; PRINT_DISPOSITION ( COMMENT , ""comment"" ) ; PRINT_DISPOSITION ( LYRICS , ""lyrics"" ) ; PRINT_DISPOSITION ( KARAOKE , ""karaoke"" ) ; PRINT_DISPOSITION ( FORCED , ""forced"" ) ; PRINT_DISPOSITION ( HEARING_IMPAIRED , ""hearing_impaired"" ) ; PRINT_DISPOSITION ( VISUAL_IMPAIRED , ""visual_impaired"" ) ; PRINT_DISPOSITION ( CLEAN_EFFECTS , ""clean_effects"" ) ; PRINT_DISPOSITION ( ATTACHED_PIC , ""attached_pic"" ) ; PRINT_DISPOSITION ( TIMED_THUMBNAILS , ""timed_thumbnails"" ) ; writer_print_section_footer ( w ) ; } if ( do_show_stream_tags ) ret = show_tags ( w , stream -> metadata , in_program ? SECTION_ID_PROGRAM_STREAM_TAGS : SECTION_ID_STREAM_TAGS ) ; if ( stream -> nb_side_data ) { print_pkt_side_data ( w , stream -> codecpar , stream -> side_data , stream -> nb_side_data , SECTION_ID_STREAM_SIDE_DATA_LIST , SECTION_ID_STREAM_SIDE_DATA ) ; } writer_print_section_footer ( w ) ; av_bprint_finalize ( & pbuf , NULL ) ; fflush ( stdout ) ; return ret ; } "," ) ) ; print_primaries ( w , par -> color_primaries par -> color_primaries ) ; if ",FFmpeg@FFmpeg/837cb4325b712ff1aab531bf41668933f61d75d2,CVE-2017-14225,https://github.com/FFmpeg/FFmpeg/commit/837cb4325b712ff1aab531bf41668933f61d75d2,2017-09-09T08:29Z 1110,CWE-416,"CWE-416 static int get_task_ioprio ( struct task_struct * p ) { int ret ; ret = security_task_getioprio ( p ) ; if ( ret ) goto out ; ret = IOPRIO_PRIO_VALUE ( IOPRIO_CLASS_NONE , IOPRIO_NORM ) ; if ( p -> io_context ) ret = p -> io_context -> ioprio ; out : return ret ; } "," IOPRIO_NORM ) ; task_lock ( p ) ; -> ioprio ; task_unlock ( p ) ; ",torvalds@linux/8ba8682107ee2ca3347354e018865d8e1967c5f4,CVE-2016-7911,https://github.com/torvalds/linux/commit/8ba8682107ee2ca3347354e018865d8e1967c5f4,2016-11-16T05:59Z 1111,CWE-119,"CWE-119 static int privsep_preauth ( Authctxt * authctxt ) { int status , r ; pid_t pid ; struct ssh_sandbox * box = NULL ; pmonitor = monitor_init ( ) ; pmonitor -> m_pkex = & active_state -> kex ; if ( use_privsep == PRIVSEP_ON ) box = ssh_sandbox_init ( ) ; pid = fork ( ) ; if ( pid == - 1 ) { fatal ( ""forkofunprivilegedchildfailed"" ) ; } else if ( pid != 0 ) { debug2 ( ""Networkchildisonpid%ld"" , ( long ) pid ) ; pmonitor -> m_pid = pid ; if ( have_agent ) { r = ssh_get_authentication_socket ( & auth_sock ) ; if ( r != 0 ) { error ( ""Couldnotgetagentsocket:%s"" , ssh_err ( r ) ) ; have_agent = 0 ; } } if ( box != NULL ) ssh_sandbox_parent_preauth ( box , pid ) ; monitor_child_preauth ( authctxt , pmonitor ) ; monitor_sync ( pmonitor ) ; while ( waitpid ( pid , & status , 0 ) < 0 ) { if ( errno == EINTR ) continue ; pmonitor -> m_pid = - 1 ; fatal ( ""%s:waitpid:%s"" , __func__ , strerror ( errno ) ) ; } privsep_is_preauth = 0 ; pmonitor -> m_pid = - 1 ; if ( WIFEXITED ( status ) ) { if ( WEXITSTATUS ( status ) != 0 ) fatal ( ""%s:preauthchildexitedwithstatus%d"" , __func__ , WEXITSTATUS ( status ) ) ; } else if ( WIFSIGNALED ( status ) ) fatal ( ""%s:preauthchildterminatedbysignal%d"" , __func__ , WTERMSIG ( status ) ) ; if ( box != NULL ) ssh_sandbox_parent_finish ( box ) ; return 1 ; } else { close ( pmonitor -> m_sendfd ) ; close ( pmonitor -> m_log_recvfd ) ; set_log_handler ( mm_log_handler , pmonitor ) ; privsep_preauth_child ( ) ; setproctitle ( ""%s"" , ""[net]"" ) ; if ( box != NULL ) ssh_sandbox_child ( box ) ; return 0 ; } } "," pmonitor ) ; while ( waitpid ",openbsd@src/3095060f479b86288e31c79ecbc5131a66bcd2f9,CVE-2016-10012,https://github.com/openbsd/src/commit/3095060f479b86288e31c79ecbc5131a66bcd2f9,2017-01-05T02:59Z 1112,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 1113,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/6b3a707736301c2128ca85ce85fb13f60b5e350a,CVE-2019-11487,https://github.com/torvalds/linux/commit/6b3a707736301c2128ca85ce85fb13f60b5e350a,2019-04-23T22:29Z 1114,CWE-119,"CWE-119 static void set_segmentation_map ( VP8_COMP * cpi , unsigned char * segmentation_map ) { vpx_memcpy ( cpi -> segmentation_map , segmentation_map , ( cpi -> common . mb_rows * cpi -> common . mb_cols ) ) ; cpi -> mb . e_mbd . update_mb_segmentation_map = 1 ; cpi -> mb . e_mbd . update_mb_segmentation_data = 1 ; } "," segmentation_map ) { memcpy ( cpi -> ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1115,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 1116,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 1117,CWE-119,"CWE-119 void WT_VoiceGain ( S_WT_VOICE * pWTVoice , S_WT_INT_FRAME * pWTIntFrame ) { EAS_I32 * pMixBuffer ; EAS_PCM * pInputBuffer ; EAS_I32 gain ; EAS_I32 gainIncrement ; EAS_I32 tmp0 ; EAS_I32 tmp1 ; EAS_I32 tmp2 ; EAS_I32 numSamples ; # if ( NUM_OUTPUT_CHANNELS == 2 ) EAS_I32 gainLeft , gainRight ; # endif numSamples = pWTIntFrame -> numSamples ; if ( numSamples <= 0 ) { ALOGE ( ""b/26366256"" ) ; return ; } pMixBuffer = pWTIntFrame -> pMixBuffer ; pInputBuffer = pWTIntFrame -> pAudioBuffer ; gainIncrement = ( pWTIntFrame -> frame . gainTarget - pWTIntFrame -> prevGain ) << ( 16 - SYNTH_UPDATE_PERIOD_IN_BITS ) ; if ( gainIncrement < 0 ) gainIncrement ++ ; gain = pWTIntFrame -> prevGain << 16 ; # if ( NUM_OUTPUT_CHANNELS == 2 ) gainLeft = pWTVoice -> gainLeft ; gainRight = pWTVoice -> gainRight ; # endif while ( numSamples -- ) { tmp0 = * pInputBuffer ++ ; gain += gainIncrement ; tmp2 = gain >> 16 ; tmp2 *= tmp0 ; # if ( NUM_OUTPUT_CHANNELS == 2 ) tmp2 = tmp2 >> 14 ; tmp1 = * pMixBuffer ; tmp0 = tmp2 * gainLeft ; tmp0 = tmp0 >> NUM_MIXER_GUARD_BITS ; tmp1 += tmp0 ; * pMixBuffer ++ = tmp1 ; tmp1 = * pMixBuffer ; tmp0 = tmp2 * gainRight ; tmp0 = tmp0 >> NUM_MIXER_GUARD_BITS ; tmp1 += tmp0 ; * pMixBuffer ++ = tmp1 ; # else tmp1 = * pMixBuffer ; tmp2 = tmp2 >> ( NUM_MIXER_GUARD_BITS - 1 ) ; tmp1 += tmp2 ; * pMixBuffer ++ = tmp1 ; # endif } } "," ALOGE ( ""b/26366256"" ) ; android_errorWriteLog ( 0x534e4554 , ""26366256"" ",external@sonivox/24d7c408c52143bce7b49de82f3913fd8d1219cf,CVE-2016-0838,https://android.googlesource.com/platform/external/sonivox/+/24d7c408c52143bce7b49de82f3913fd8d1219cf,2016-04-18T00:59Z 1118,CWE-20,"CWE-20 size_t cdf_count_chain ( const cdf_sat_t * sat , cdf_secid_t sid , size_t size ) { size_t i , j ; cdf_secid_t maxsector = ( cdf_secid_t ) ( sat -> sat_len * size ) ; DPRINTF ( ( ""Chain:"" ) ) ; for ( j = i = 0 ; sid >= 0 ; i ++ , j ++ ) { DPRINTF ( ( ""%d"" , sid ) ) ; if ( j >= CDF_LOOP_LIMIT ) { DPRINTF ( ( ""Countingchainlooplimit"" ) ) ; errno = EFTYPE ; return ( size_t ) - 1 ; } if ( sid > maxsector ) { DPRINTF ( ( ""Sector%d>%d\\n"" , sid , maxsector ) ) ; errno = EFTYPE ; return ( size_t ) - 1 ; } sid = CDF_TOLE4 ( ( uint32_t ) sat -> sat_tab [ sid ] ) ; } if ( i == 0 ) { DPRINTF ( ( ""none,sid:%d\\n"" , sid ) ) ; return ( size_t ) - 1 ; } DPRINTF ( ( ""\\n"" ) ) ; return i ; } "," ( cdf_secid_t ) ( * size ) / sizeof ( maxsector ) ) if ( sid >= maxsector ) { DPRINTF ( ( ""Sector%d>=%d\\n"" , sid , ",file@file/40bade80cbe2af1d0b2cd0420cebd5d5905a2382,CVE-2014-3480,https://github.com/file/file/commit/40bade80cbe2af1d0b2cd0420cebd5d5905a2382,2014-07-09T11:07Z 1119,CWE-000,"CWE-000 static ssize_t aio_setup_vectored_rw ( struct kiocb * kiocb , int rw , char __user * buf , unsigned long * nr_segs , size_t * len , struct iovec * * iovec , bool compat ) { ssize_t ret ; * nr_segs = * len ; # ifdef CONFIG_COMPAT if ( compat ) ret = compat_rw_copy_check_uvector ( rw , ( struct compat_iovec __user * ) buf , * nr_segs , UIO_FASTIOV , * iovec , iovec ) ; else # endif ret = rw_copy_check_uvector ( rw , ( struct iovec __user * ) buf , * nr_segs , UIO_FASTIOV , * iovec , iovec ) ; if ( ret < 0 ) return ret ; * len = ret ; return 0 ; } "," , bool compat , struct iov_iter * iter = ret ; 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 1120,CWE-476,"CWE-476 static int compile_length_bag_node ( BagNode * node , regex_t * reg ) { int len ; int tlen ; if ( node -> type == BAG_OPTION ) return compile_length_option_node ( node , reg ) ; if ( NODE_BAG_BODY ( node ) ) { tlen = compile_length_tree ( NODE_BAG_BODY ( node ) , reg ) ; if ( tlen < 0 ) return tlen ; } else tlen = 0 ; switch ( node -> type ) { case BAG_MEMORY : # ifdef USE_CALL if ( node -> m . regnum == 0 && NODE_IS_CALLED ( node ) ) { len = tlen + SIZE_OP_CALL + SIZE_OP_JUMP + SIZE_OP_RETURN ; return len ; } if ( NODE_IS_CALLED ( node ) ) { len = SIZE_OP_MEMORY_START_PUSH + tlen + SIZE_OP_CALL + SIZE_OP_JUMP + SIZE_OP_RETURN ; if ( MEM_STATUS_AT0 ( reg -> bt_mem_end , node -> m . regnum ) ) len += ( NODE_IS_RECURSION ( node ) ? SIZE_OP_MEMORY_END_PUSH_REC : SIZE_OP_MEMORY_END_PUSH ) ; else len += ( NODE_IS_RECURSION ( node ) ? SIZE_OP_MEMORY_END_REC : SIZE_OP_MEMORY_END ) ; } else if ( NODE_IS_RECURSION ( node ) ) { len = SIZE_OP_MEMORY_START_PUSH ; len += tlen + ( MEM_STATUS_AT0 ( reg -> bt_mem_end , node -> m . regnum ) ? SIZE_OP_MEMORY_END_PUSH_REC : SIZE_OP_MEMORY_END_REC ) ; } else # endif { if ( MEM_STATUS_AT0 ( reg -> bt_mem_start , node -> m . regnum ) ) len = SIZE_OP_MEMORY_START_PUSH ; else len = SIZE_OP_MEMORY_START ; len += tlen + ( MEM_STATUS_AT0 ( reg -> bt_mem_end , node -> m . regnum ) ? SIZE_OP_MEMORY_END_PUSH : SIZE_OP_MEMORY_END ) ; } break ; case BAG_STOP_BACKTRACK : if ( NODE_IS_STOP_BT_SIMPLE_REPEAT ( node ) ) { int v ; QuantNode * qn ; qn = QUANT_ ( NODE_BAG_BODY ( node ) ) ; tlen = compile_length_tree ( NODE_QUANT_BODY ( qn ) , reg ) ; if ( tlen < 0 ) return tlen ; v = onig_positive_int_multiply ( qn -> lower , tlen ) ; if ( v < 0 ) return ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE ; len = v + SIZE_OP_PUSH + tlen + SIZE_OP_POP_OUT + SIZE_OP_JUMP ; } else { len = SIZE_OP_ATOMIC_START + tlen + SIZE_OP_ATOMIC_END ; } break ; case BAG_IF_ELSE : { Node * cond = NODE_BAG_BODY ( node ) ; Node * Then = node -> te . Then ; Node * Else = node -> te . Else ; len = compile_length_tree ( cond , reg ) ; if ( len < 0 ) return len ; len += SIZE_OP_PUSH ; len += SIZE_OP_ATOMIC_START + SIZE_OP_ATOMIC_END ; if ( IS_NOT_NULL ( Then ) ) { tlen = compile_length_tree ( Then , reg ) ; if ( tlen < 0 ) return tlen ; len += tlen ; } if ( IS_NOT_NULL ( Else ) ) { len += SIZE_OP_JUMP ; tlen = compile_length_tree ( Else , reg ) ; if ( tlen < 0 ) return tlen ; len += tlen ; } } break ; case BAG_OPTION : len = 0 ; break ; } return len ; } "," tlen ; } len += SIZE_OP_JUMP + SIZE_OP_ATOMIC_END ; ) ) { tlen = compile_length_tree ",kkos@oniguruma/c509265c5f6ae7264f7b8a8aae1cfa5fc59d108c,CVE-2019-13225,https://github.com/kkos/oniguruma/commit/c509265c5f6ae7264f7b8a8aae1cfa5fc59d108c,2019-07-10T14:15Z 1121,CWE-000,"CWE-000 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 1122,CWE-74,"CWE-74 static int smtp_open ( struct Connection * conn , bool esmtp ) { int rc ; if ( mutt_socket_open ( conn ) ) return - 1 ; rc = smtp_get_resp ( conn ) ; if ( rc != 0 ) return rc ; rc = smtp_helo ( conn , esmtp ) ; if ( rc != 0 ) return rc ; # ifdef USE_SSL enum QuadOption ans = MUTT_NO ; if ( conn -> ssf ) ans = MUTT_NO ; else if ( C_SslForceTls ) ans = MUTT_YES ; else if ( ( Capabilities & SMTP_CAP_STARTTLS ) && ( ( ans = query_quadoption ( C_SslStarttls , _ ( ""SecureconnectionwithTLS?"" ) ) ) == MUTT_ABORT ) ) { return - 1 ; } if ( ans == MUTT_YES ) { if ( mutt_socket_send ( conn , ""STARTTLS\\r\\n"" ) < 0 ) return SMTP_ERR_WRITE ; rc = smtp_get_resp ( conn ) ; if ( rc != 0 ) return rc ; if ( mutt_ssl_starttls ( conn ) ) { mutt_error ( _ ( ""CouldnotnegotiateTLSconnection"" ) ) ; return - 1 ; } rc = smtp_helo ( conn , esmtp ) ; if ( rc != 0 ) return rc ; } # endif if ( conn -> account . flags & MUTT_ACCT_USER ) { if ( ! ( Capabilities & SMTP_CAP_AUTH ) ) { mutt_error ( _ ( ""SMTPserverdoesnotsupportauthentication"" ) ) ; return - 1 ; } return smtp_auth ( conn ) ; } return 0 ; } "," rc = smtp_get_resp ( conn ) ; mutt_socket_empty ",neomutt@neomutt/fb013ec666759cb8a9e294347c7b4c1f597639cc,CVE-2020-14954,https://github.com/neomutt/neomutt/commit/fb013ec666759cb8a9e294347c7b4c1f597639cc,2020-06-21T17:15Z 1123,CWE-416,"CWE-416 void fe_netjoin_deinit ( void ) { while ( joinservers != NULL ) netjoin_server_remove ( joinservers -> data ) ; if ( join_tag != - 1 ) { g_source_remove ( join_tag ) ; signal_remove ( ""printstarting"" , ( SIGNAL_FUNC ) sig_print_starting ) ; } signal_remove ( ""setupchanged"" , ( SIGNAL_FUNC ) read_settings ) ; signal_remove ( ""messagequit"" , ( SIGNAL_FUNC ) msg_quit ) ; signal_remove ( ""messagejoin"" , ( SIGNAL_FUNC ) msg_join ) ; signal_remove ( ""messageircmode"" , ( SIGNAL_FUNC ) msg_mode ) ; } "," ; signal_remove ( ""serverdisconnected"" , ( SIGNAL_FUNC ) sig_server_disconnected ) ; signal_remove ( ",irssi@irssi/77b2631c78461965bc9a7414aae206b5c514e1b3,CVE-2017-7191,https://github.com/irssi/irssi/commit/77b2631c78461965bc9a7414aae206b5c514e1b3,2017-03-27T17:59Z 1124,CWE-416,"CWE-416 static int may_create_in_sticky ( struct dentry * const dir , struct inode * const inode ) { if ( ( ! sysctl_protected_fifos && S_ISFIFO ( inode -> i_mode ) ) || ( ! sysctl_protected_regular && S_ISREG ( inode -> i_mode ) ) || likely ( ! ( dir -> d_inode -> i_mode & S_ISVTX ) ) || uid_eq ( inode -> i_uid , dir -> d_inode -> i_uid ) || uid_eq ( current_fsuid ( ) , inode -> i_uid ) ) return 0 ; if ( likely ( dir -> d_inode -> i_mode & 0002 ) || ( dir -> d_inode -> i_mode & 0020 && ( ( sysctl_protected_fifos >= 2 && S_ISFIFO ( inode -> i_mode ) ) || ( sysctl_protected_regular >= 2 && S_ISREG ( inode -> i_mode ) ) ) ) ) { const char * operation = S_ISFIFO ( inode -> i_mode ) ? ""sticky_create_fifo"" : ""sticky_create_regular"" ; audit_log_path_denied ( AUDIT_ANOM_CREAT , operation ) ; return - EACCES ; } return 0 ; } "," int may_create_in_sticky ( umode_t dir_mode , kuid_t dir_uid , struct inode ( ! ( dir_mode & S_ISVTX ) -> i_uid , dir_uid ) || uid_eq ( likely ( dir_mode & 0002 ) ) || ( dir_mode & 0020 && ",torvalds@linux/d0cb50185ae942b03c4327be322055d622dc79f6,CVE-2020-8428,https://github.com/torvalds/linux/commit/d0cb50185ae942b03c4327be322055d622dc79f6,2020-01-29T00:15Z 1125,CWE-362,"CWE-362 static int mptctl_fw_download ( unsigned long arg ) { struct mpt_fw_xfer __user * ufwdl = ( void __user * ) arg ; struct mpt_fw_xfer kfwdl ; if ( copy_from_user ( & kfwdl , ufwdl , sizeof ( struct mpt_fw_xfer ) ) ) { printk ( KERN_ERR MYNAM ""%s@%d::_ioctl_fwdl-"" ""Unabletocopympt_fw_xferstruct@%p\\n"" , __FILE__ , __LINE__ , ufwdl ) ; return - EFAULT ; } return mptctl_do_fw_download ( kfwdl . iocnum , kfwdl . bufp , kfwdl . fwlen ) ; } "," int mptctl_fw_download ( MPT_ADAPTER * iocp , return mptctl_do_fw_download ( iocp , kfwdl . ",torvalds@linux/28d76df18f0ad5bcf5fa48510b225f0ed262a99b,CVE-2020-12652,https://github.com/torvalds/linux/commit/28d76df18f0ad5bcf5fa48510b225f0ed262a99b,2020-05-05T05:15Z 1126,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 1127,CWE-119,"CWE-119 void vp9_rc_postencode_update_drop_frame ( VP9_COMP * cpi ) { update_buffer_level ( cpi , 0 ) ; cpi -> common . last_frame_type = cpi -> common . frame_type ; cpi -> rc . frames_since_key ++ ; cpi -> rc . frames_to_key -- ; } "," ; cpi -> rc . frames_since_key frames_to_key -- ; cpi -> rc . rc_2_frame = 0 ; cpi -> rc . rc_1_frame = 0 ; ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1128,CWE-119,"CWE-119 static int process_plane ( uint8 * in , int width , int height , uint8 * out , int size ) { UNUSED ( size ) ; int indexw ; int indexh ; int code ; int collen ; int replen ; int color ; int x ; int revcode ; uint8 * last_line ; uint8 * this_line ; uint8 * org_in ; uint8 * org_out ; org_in = in ; org_out = out ; last_line = 0 ; indexh = 0 ; while ( indexh < height ) { out = ( org_out + width * height * 4 ) - ( ( indexh + 1 ) * width * 4 ) ; color = 0 ; this_line = out ; indexw = 0 ; if ( last_line == 0 ) { while ( indexw < width ) { code = CVAL ( in ) ; replen = code & 0xf ; collen = ( code >> 4 ) & 0xf ; revcode = ( replen << 4 ) | collen ; if ( ( revcode <= 47 ) && ( revcode >= 16 ) ) { replen = revcode ; collen = 0 ; } while ( collen > 0 ) { color = CVAL ( in ) ; * out = color ; out += 4 ; indexw ++ ; collen -- ; } while ( replen > 0 ) { * out = color ; out += 4 ; indexw ++ ; replen -- ; } } } else { while ( indexw < width ) { code = CVAL ( in ) ; replen = code & 0xf ; collen = ( code >> 4 ) & 0xf ; revcode = ( replen << 4 ) | collen ; if ( ( revcode <= 47 ) && ( revcode >= 16 ) ) { replen = revcode ; collen = 0 ; } while ( collen > 0 ) { x = CVAL ( in ) ; if ( x & 1 ) { x = x >> 1 ; x = x + 1 ; color = - x ; } else { x = x >> 1 ; color = x ; } x = last_line [ indexw * 4 ] + color ; * out = x ; out += 4 ; indexw ++ ; collen -- ; } while ( replen > 0 ) { x = last_line [ indexw * 4 ] + color ; * out = x ; out += 4 ; indexw ++ ; replen -- ; } } } indexh ++ ; last_line = this_line ; } return ( int ) ( in - org_in ) ; } "," } while ( indexw < width && } while ( indexw < width && } while ( indexw < width && } while ( indexw < width && ",rdesktop@rdesktop/4dca546d04321a610c1835010b5dad85163b65e1,CVE-2018-20182,https://github.com/rdesktop/rdesktop/commit/4dca546d04321a610c1835010b5dad85163b65e1,2019-03-15T18:29Z 1129,CWE-617,"CWE-617 void pci_populate_msicap ( struct msicap * msicap , int msgnum , int nextptr ) { int mmc ; assert ( ( msgnum & ( msgnum - 1 ) ) == 0 && msgnum >= 1 && msgnum <= 32 ) ; mmc = ffs ( msgnum ) - 1 ; bzero ( msicap , sizeof ( struct msicap ) ) ; msicap -> capid = PCIY_MSI ; msicap -> nextptr = nextptr ; msicap -> msgctrl = PCIM_MSICTRL_64BIT | ( mmc << 1 ) ; } "," int pci_populate_msicap ( struct int mmc ; if ( ( ( msgnum 1 ) ) != 0 ) || msgnum < 1 || msgnum > 32 ) { pr_err ( ""%s:invalidnumberofmsimessages!\\n"" , __func__ ) ; return - 1 ; } mmc = ffs 1 ) ; return 0 ; ",projectacrn@acrn-hypervisor/2b3dedfb9ba13f15887f22b935d373f36c9a59fa,CVE-2019-18844,https://github.com/projectacrn/acrn-hypervisor/commit/2b3dedfb9ba13f15887f22b935d373f36c9a59fa,2019-11-13T20:15Z 1130,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 1131,CWE-416,"CWE-416 static int xc2028_set_config ( struct dvb_frontend * fe , void * priv_cfg ) { struct xc2028_data * priv = fe -> tuner_priv ; struct xc2028_ctrl * p = priv_cfg ; int rc = 0 ; tuner_dbg ( ""%scalled\\n"" , __func__ ) ; mutex_lock ( & priv -> lock ) ; kfree ( priv -> ctrl . fname ) ; memcpy ( & priv -> ctrl , p , sizeof ( priv -> ctrl ) ) ; if ( p -> fname ) { priv -> ctrl . fname = kstrdup ( p -> fname , GFP_KERNEL ) ; if ( priv -> ctrl . fname == NULL ) rc = - ENOMEM ; } if ( ! firmware_name [ 0 ] && p -> fname && priv -> fname && strcmp ( p -> fname , priv -> fname ) ) free_firmware ( priv ) ; if ( priv -> ctrl . max_len < 9 ) priv -> ctrl . max_len = 13 ; if ( priv -> state == XC2028_NO_FIRMWARE ) { if ( ! firmware_name [ 0 ] ) priv -> fname = priv -> ctrl . fname ; else priv -> fname = firmware_name ; rc = request_firmware_nowait ( THIS_MODULE , 1 , priv -> fname , priv -> i2c_props . adap -> dev . parent , GFP_KERNEL , fe , load_firmware_cb ) ; if ( rc < 0 ) { tuner_err ( ""Failedtorequestfirmware%s\\n"" , priv -> fname ) ; priv -> state = XC2028_NODEV ; } else priv -> state = XC2028_WAITING_FIRMWARE ; } mutex_unlock ( & priv -> lock ) ; return rc ; } "," fname ) ; priv -> ctrl . fname = NULL ; == NULL ) return - ENOMEM ; ",torvalds@linux/8dfbcc4351a0b6d2f2d77f367552f48ffefafe18,CVE-2016-7913,https://github.com/torvalds/linux/commit/8dfbcc4351a0b6d2f2d77f367552f48ffefafe18,2016-11-16T05:59Z 1132,CWE-401,"CWE-401 static int ca8210_probe ( struct spi_device * spi_device ) { struct ca8210_priv * priv ; struct ieee802154_hw * hw ; struct ca8210_platform_data * pdata ; int ret ; dev_info ( & spi_device -> dev , ""Insertingca8210\\n"" ) ; hw = ieee802154_alloc_hw ( sizeof ( struct ca8210_priv ) , & ca8210_phy_ops ) ; if ( ! hw ) { dev_crit ( & spi_device -> dev , ""ieee802154_alloc_hwfailed\\n"" ) ; ret = - ENOMEM ; goto error ; } priv = hw -> priv ; priv -> hw = hw ; priv -> spi = spi_device ; hw -> parent = & spi_device -> dev ; spin_lock_init ( & priv -> lock ) ; priv -> async_tx_pending = false ; priv -> hw_registered = false ; priv -> sync_up = 0 ; priv -> sync_down = 0 ; priv -> promiscuous = false ; priv -> retries = 0 ; init_completion ( & priv -> ca8210_is_awake ) ; init_completion ( & priv -> spi_transfer_complete ) ; init_completion ( & priv -> sync_exchange_complete ) ; spi_set_drvdata ( priv -> spi , priv ) ; if ( IS_ENABLED ( CONFIG_IEEE802154_CA8210_DEBUGFS ) ) { cascoda_api_upstream = ca8210_test_int_driver_write ; ca8210_test_interface_init ( priv ) ; } else { cascoda_api_upstream = NULL ; } ca8210_hw_setup ( hw ) ; ieee802154_random_extended_addr ( & hw -> phy -> perm_extended_addr ) ; pdata = kmalloc ( sizeof ( * pdata ) , GFP_KERNEL ) ; if ( ! pdata ) { ret = - ENOMEM ; goto error ; } ret = ca8210_get_platform_data ( priv -> spi , pdata ) ; if ( ret ) { dev_crit ( & spi_device -> dev , ""ca8210_get_platform_datafailed\\n"" ) ; goto error ; } priv -> spi -> dev . platform_data = pdata ; ret = ca8210_dev_com_init ( priv ) ; if ( ret ) { dev_crit ( & spi_device -> dev , ""ca8210_dev_com_initfailed\\n"" ) ; goto error ; } ret = ca8210_reset_init ( priv -> spi ) ; if ( ret ) { dev_crit ( & spi_device -> dev , ""ca8210_reset_initfailed\\n"" ) ; goto error ; } ret = ca8210_interrupt_init ( priv -> spi ) ; if ( ret ) { dev_crit ( & spi_device -> dev , ""ca8210_interrupt_initfailed\\n"" ) ; goto error ; } msleep ( 100 ) ; ca8210_reset_send ( priv -> spi , 1 ) ; ret = tdme_chipinit ( priv -> spi ) ; if ( ret ) { dev_crit ( & spi_device -> dev , ""tdme_chipinitfailed\\n"" ) ; goto error ; } if ( pdata -> extclockenable ) { ret = ca8210_config_extern_clk ( pdata , priv -> spi , 1 ) ; if ( ret ) { dev_crit ( & spi_device -> dev , ""ca8210_config_extern_clkfailed\\n"" ) ; goto error ; } ret = ca8210_register_ext_clock ( priv -> spi ) ; if ( ret ) { dev_crit ( & spi_device -> dev , ""ca8210_register_ext_clockfailed\\n"" ) ; goto error ; } } ret = ieee802154_register_hw ( hw ) ; if ( ret ) { dev_crit ( & spi_device -> dev , ""ieee802154_register_hwfailed\\n"" ) ; goto error ; } priv -> hw_registered = true ; return 0 ; error : msleep ( 100 ) ; ca8210_remove ( spi_device ) ; return link_to_linux_err ( ret ) ; } "," error ; } priv -> spi ; ret = ca8210_get_platform_data ( priv -> spi , pdata ) ; if ( ret ) { dev_crit ( & spi_device -> dev , ""ca8210_get_platform_datafailed\\n"" ) ; goto error ; } ret = ",torvalds@linux/6402939ec86eaf226c8b8ae00ed983936b164908,CVE-2019-19075,https://github.com/torvalds/linux/commit/6402939ec86eaf226c8b8ae00ed983936b164908,2019-11-18T06:15Z 1133,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 ) - 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/444ca3ce7853538c577e0ec3f6146d2d65780734,CVE-2018-8754,https://github.com/libyal/libevt/commit/444ca3ce7853538c577e0ec3f6146d2d65780734,2018-03-18T03:29Z 1134,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 1135,CWE-284,"CWE-284 int bta_co_rfc_data_outgoing ( void * user_data , uint8_t * buf , uint16_t size ) { pthread_mutex_lock ( & slot_lock ) ; uint32_t id = ( uintptr_t ) user_data ; int ret = false ; rfc_slot_t * slot = find_rfc_slot_by_id ( id ) ; if ( ! slot ) goto out ; int received = recv ( slot -> fd , buf , size , 0 ) ; if ( received == size ) { ret = true ; } else { LOG_ERROR ( ""%serrorreceivingRFCOMMdatafromapp:%s"" , __func__ , strerror ( errno ) ) ; cleanup_rfc_slot ( slot ) ; } out : ; pthread_mutex_unlock ( & slot_lock ) ; return ret ; } "," int received = TEMP_FAILURE_RETRY ( size , 0 ) ",system@bt/472271b153c5dc53c28beac55480a8d8434b2d5c,CVE-2016-3839,https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c,2016-08-05T20:59Z 1136,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 1137,CWE-119,"CWE-119 static int put_chars ( u32 vtermno , const char * buf , int count ) { struct port * port ; struct scatterlist sg [ 1 ] ; if ( unlikely ( early_put_chars ) ) return early_put_chars ( vtermno , buf , count ) ; port = find_port_by_vtermno ( vtermno ) ; if ( ! port ) return - EPIPE ; sg_init_one ( sg , buf , count ) ; return __send_to_port ( port , sg , 1 , count , ( void * ) buf , false ) ; } "," [ 1 ] ; void * data ; int ret - EPIPE ; data = kmemdup ( buf , count , GFP_ATOMIC ) ; if ( ! data ) return - ENOMEM ; ( sg , data , count ) count ) ; ret = __send_to_port ( port , count , data , false ) false ) ; kfree ( data ) ; return ret ; ",torvalds@linux/c4baad50297d84bde1a7ad45e50c73adae4a2192,CVE-2017-8067,https://github.com/torvalds/linux/commit/c4baad50297d84bde1a7ad45e50c73adae4a2192,2017-04-23T05:59Z 1138,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 ) { 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 ; } "," bpp <= 8 && c -> format != CHUNKY ",FFmpeg@FFmpeg/e1b60aad77c27ed5d4dfc11e5e6a05a38c70489d,CVE-2017-9996,https://github.com/FFmpeg/FFmpeg/commit/e1b60aad77c27ed5d4dfc11e5e6a05a38c70489d,2017-06-28T06:29Z 1139,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 1140,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 1141,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 1142,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 1143,CWE-17,"CWE-17 void __fput_sync ( struct file * file ) { if ( atomic_long_dec_and_test ( & file -> f_count ) ) { struct task_struct * task = current ; file_sb_list_del ( file ) ; BUG_ON ( ! ( task -> flags & PF_KTHREAD ) ) ; __fput ( file ) ; } } "," = current ; BUG_ON ( ! ",torvalds@linux/eee5cc2702929fd41cce28058dc6d6717f723f87,CVE-2014-8172,https://github.com/torvalds/linux/commit/eee5cc2702929fd41cce28058dc6d6717f723f87,2015-03-16T10:59Z 1144,CWE-415,"CWE-415 void * gdImageWBMPPtr ( gdImagePtr im , int * size , int fg ) { void * rv ; gdIOCtx * out = gdNewDynamicCtx ( 2048 , NULL ) ; gdImageWBMPCtx ( im , fg , out ) ; rv = gdDPExtractData ( out , size ) ; out -> gd_free ( out ) ; return rv ; } "," NULL ) ; if ( ! _gdImageWBMPCtx ( 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 1145,CWE-119,"CWE-119 static Image * ReadCINImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { # define MonoColorType 1 # define RGBColorType 3 char property [ MaxTextExtent ] ; CINInfo cin ; Image * image ; MagickBooleanType status ; MagickOffsetType offset ; QuantumInfo * quantum_info ; QuantumType quantum_type ; register ssize_t i ; register PixelPacket * q ; size_t length ; ssize_t count , y ; unsigned char magick [ 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 ) ; 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"" ) ; 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 ) ; 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 ) ; 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 ) ; 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 ) ; 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 ) ; 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 = ( int ) ReadBlobLong ( 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 ) ; 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 ) ; 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 ) ; 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 ) ; 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 ) ; ( void ) ResetMagickMemory ( 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 ) ; 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 ) ; 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 ) ; 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 ) ; 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 ; profile = BlobToStringInfo ( ( const void * ) 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 ) ; profile = DestroyStringInfo ( profile ) ; } for ( ; offset < ( MagickOffsetType ) cin . file . image_offset ; offset ++ ) ( void ) ReadBlobByte ( image ) ; 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 ) { ( void ) CloseBlob ( image ) ; return ( image ) ; } 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 ; pixels = GetQuantumPixels ( quantum_info ) ; 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 == ( PixelPacket * ) NULL ) break ; count = ReadBlob ( image , length , pixels ) ; 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 ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," image_info -> ping != MagickFalse return ( 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 1146,CWE-400,"CWE-400 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 ; nmi = perf_intr_is_nmi ( regs ) ; if ( nmi ) nmi_enter ( ) ; else irq_enter ( ) ; for ( i = 0 ; i < ppmu -> n_counter ; ++ i ) { event = cpuhw -> event [ i ] ; val = read_pmc ( i ) ; if ( ( int ) val < 0 ) { if ( event ) { found = 1 ; record_and_restart ( event , val , regs , nmi ) ; } else { write_pmc ( i , 0 ) ; } } } mtmsr ( mfmsr ( ) | MSR_PMM ) ; mtpmr ( PMRN_PMGC0 , PMGC0_PMIE | PMGC0_FCECE ) ; isync ( ) ; if ( nmi ) nmi_exit ( ) ; else irq_exit ( ) ; } "," val , regs ) ; } ",torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,CVE-2011-2918,https://github.com/torvalds/linux/commit/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,2012-05-24T23:55Z 1147,CWE-125,"CWE-125 unsigned char * base64decode ( const char * buf , size_t * size ) { if ( ! buf || ! size ) return NULL ; size_t len = ( * size > 0 ) ? * size : strlen ( buf ) ; if ( len <= 0 ) return NULL ; unsigned char * outbuf = ( unsigned char * ) malloc ( ( len / 4 ) * 3 + 3 ) ; const char * ptr = buf ; int p = 0 ; size_t l = 0 ; do { ptr += strspn ( ptr , ""\\r\\n\\t"" ) ; if ( * ptr == '\\0' || ptr >= buf + len ) { break ; } l = strcspn ( ptr , ""\\r\\n\\t"" ) ; if ( l > 3 && ptr + l <= buf + len ) { p += base64decode_block ( outbuf + p , ptr , l ) ; ptr += l ; } else { break ; } } while ( 1 ) ; outbuf [ p ] = 0 ; * size = p ; return outbuf ; } "," = 0 ; int wv , w1 , w2 , w3 , w4 ; int tmpval [ 4 ] ; int tmpcnt = 0 ; ; do { while ( ptr < buf + len && ( * ptr == '' || * ptr == '\\t' || * ptr == '\\n' || * ptr == '\\r' ) ) { ptr ++ ; } if ( * break ; } if ( ( wv = base64_table [ ( int ) ( unsigned char ) * ptr ++ ] ) == - 1 ) { continue ; } tmpval [ tmpcnt ++ ] = wv ; if ( tmpcnt == 4 ) { tmpcnt = 0 ; w1 = tmpval [ 0 ] ; w2 = tmpval [ 1 ] ; w3 = tmpval [ 2 ] ; w4 = tmpval [ 3 ] ; if ( w2 >= 0 ) { outbuf [ p ++ ] = ( unsigned char ) ( ( ( w1 << 2 ) + ( w2 >> 4 ) ) & 0xFF ) ; } if ( w3 >= 0 ) { outbuf [ p ++ ] = ( unsigned char ) ( ( ( w2 << 4 ) + ( w3 >> 2 ) ) & 0xFF ) ; } if ( w4 >= 0 ) { outbuf [ p ++ ] = ( unsigned char ) ( ( ( w3 << 6 ) + w4 ) & 0xFF ) ; } } } while ",libimobiledevice@libplist/3a55ddd3c4c11ce75a86afbefd085d8d397ff957,CVE-2017-5209,https://github.com/libimobiledevice/libplist/commit/3a55ddd3c4c11ce75a86afbefd085d8d397ff957,2017-01-11T16:59Z 1148,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/3724cd76a28be1d6049b5537232e97ac,2017-01-23T21:59Z 1149,CWE-362,"CWE-362 int ipc_addid ( struct ipc_ids * ids , struct kern_ipc_perm * new , int size ) { kuid_t euid ; kgid_t egid ; int id ; int next_id = ids -> next_id ; if ( size > IPCMNI ) size = IPCMNI ; if ( ids -> in_use >= size ) return - ENOSPC ; idr_preload ( GFP_KERNEL ) ; spin_lock_init ( & new -> lock ) ; new -> deleted = false ; rcu_read_lock ( ) ; spin_lock ( & new -> lock ) ; id = idr_alloc ( & ids -> ipcs_idr , new , ( next_id < 0 ) ? 0 : ipcid_to_idx ( next_id ) , 0 , GFP_NOWAIT ) ; idr_preload_end ( ) ; if ( id < 0 ) { spin_unlock ( & new -> lock ) ; rcu_read_unlock ( ) ; return id ; } ids -> in_use ++ ; current_euid_egid ( & euid , & egid ) ; new -> cuid = new -> uid = euid ; new -> gid = new -> cgid = egid ; if ( next_id < 0 ) { new -> seq = ids -> seq ++ ; if ( ids -> seq > IPCID_SEQ_MAX ) ids -> seq = 0 ; } else { new -> seq = ipcid_to_seqx ( next_id ) ; ids -> next_id = - 1 ; } new -> id = ipc_buildid ( id , new -> seq ) ; return id ; } "," lock ) ; current_euid_egid ( & euid , & egid ) ; new -> cuid = new -> uid = euid ; new -> gid = new -> cgid = egid ; in_use ++ ; if ( next_id ",torvalds@linux/b9a532277938798b53178d5a66af6e2915cb27cf,CVE-2015-7613,https://github.com/torvalds/linux/commit/b9a532277938798b53178d5a66af6e2915cb27cf,2015-10-19T10:59Z 1150,CWE-20,"CWE-20 apr_status_t ap_http_filter ( ap_filter_t * f , apr_bucket_brigade * b , ap_input_mode_t mode , apr_read_type_e block , apr_off_t readbytes ) { core_server_config * conf ; apr_bucket * e ; http_ctx_t * ctx = f -> ctx ; apr_status_t rv ; apr_off_t totalread ; int again ; conf = ( core_server_config * ) ap_get_module_config ( f -> r -> server -> module_config , & core_module ) ; if ( mode != AP_MODE_READBYTES && mode != AP_MODE_GETLINE ) { return ap_get_brigade ( f -> next , b , mode , block , readbytes ) ; } if ( ! ctx ) { const char * tenc , * lenp ; f -> ctx = ctx = apr_pcalloc ( f -> r -> pool , sizeof ( * ctx ) ) ; ctx -> state = BODY_NONE ; if ( ! f -> r -> proxyreq ) { ctx -> limit = ap_get_limit_req_body ( f -> r ) ; } else { ctx -> limit = 0 ; } tenc = apr_table_get ( f -> r -> headers_in , ""Transfer-Encoding"" ) ; lenp = apr_table_get ( f -> r -> headers_in , ""Content-Length"" ) ; if ( tenc ) { if ( strcasecmp ( tenc , ""chunked"" ) == 0 || ap_find_last_token ( f -> r -> pool , tenc , ""chunked"" ) ) { ctx -> state = BODY_CHUNK ; } else if ( f -> r -> proxyreq == PROXYREQ_RESPONSE ) { ap_log_rerror ( APLOG_MARK , APLOG_INFO , 0 , f -> r , APLOGNO ( 02555 ) ""UnknownTransfer-Encoding:%s;"" ""usingread-until-close"" , tenc ) ; tenc = NULL ; } else { ap_log_rerror ( APLOG_MARK , APLOG_INFO , 0 , f -> r , APLOGNO ( 01585 ) ""UnknownTransfer-Encoding:%s"" , tenc ) ; return APR_EGENERAL ; } lenp = NULL ; } if ( lenp ) { char * endstr ; ctx -> state = BODY_LENGTH ; if ( apr_strtoff ( & ctx -> remaining , lenp , & endstr , 10 ) || endstr == lenp || * endstr || ctx -> remaining < 0 ) { ctx -> remaining = 0 ; ap_log_rerror ( APLOG_MARK , APLOG_INFO , 0 , f -> r , APLOGNO ( 01587 ) ""InvalidContent-Length"" ) ; return APR_ENOSPC ; } if ( ctx -> limit && ctx -> limit < ctx -> remaining ) { ap_log_rerror ( APLOG_MARK , APLOG_INFO , 0 , f -> r , APLOGNO ( 01588 ) ""Requestedcontent-lengthof%"" APR_OFF_T_FMT ""islargerthantheconfiguredlimit"" ""of%"" APR_OFF_T_FMT , ctx -> remaining , ctx -> limit ) ; return APR_ENOSPC ; } } if ( ctx -> state == BODY_NONE && f -> r -> proxyreq != PROXYREQ_RESPONSE ) { e = apr_bucket_eos_create ( f -> c -> bucket_alloc ) ; APR_BRIGADE_INSERT_TAIL ( b , e ) ; ctx -> eos_sent = 1 ; return APR_SUCCESS ; } if ( ( ctx -> state == BODY_CHUNK || ( ctx -> state == BODY_LENGTH && ctx -> remaining > 0 ) ) && f -> r -> expecting_100 && f -> r -> proto_num >= HTTP_VERSION ( 1 , 1 ) && ! ( f -> r -> eos_sent || f -> r -> bytes_sent ) ) { if ( ! ap_is_HTTP_SUCCESS ( f -> r -> status ) ) { ctx -> state = BODY_NONE ; ctx -> eos_sent = 1 ; } else { char * tmp ; int len ; apr_bucket_brigade * bb ; bb = apr_brigade_create ( f -> r -> pool , f -> c -> bucket_alloc ) ; f -> r -> expecting_100 = 0 ; tmp = apr_pstrcat ( f -> r -> pool , AP_SERVER_PROTOCOL """" , ap_get_status_line ( HTTP_CONTINUE ) , CRLF CRLF , NULL ) ; len = strlen ( tmp ) ; ap_xlate_proto_to_ascii ( tmp , len ) ; e = apr_bucket_pool_create ( tmp , len , f -> r -> pool , f -> c -> bucket_alloc ) ; APR_BRIGADE_INSERT_HEAD ( bb , e ) ; e = apr_bucket_flush_create ( f -> c -> bucket_alloc ) ; APR_BRIGADE_INSERT_TAIL ( bb , e ) ; rv = ap_pass_brigade ( f -> c -> output_filters , bb ) ; if ( rv != APR_SUCCESS ) { return AP_FILTER_ERROR ; } } } } if ( ctx -> eos_sent ) { e = apr_bucket_eos_create ( f -> c -> bucket_alloc ) ; APR_BRIGADE_INSERT_TAIL ( b , e ) ; return APR_SUCCESS ; } do { apr_brigade_cleanup ( b ) ; again = 0 ; switch ( ctx -> state ) { case BODY_CHUNK : case BODY_CHUNK_PART : case BODY_CHUNK_EXT : case BODY_CHUNK_END : { rv = ap_get_brigade ( f -> next , b , AP_MODE_GETLINE , block , 0 ) ; if ( block == APR_NONBLOCK_READ && ( ( rv == APR_SUCCESS && APR_BRIGADE_EMPTY ( b ) ) || ( APR_STATUS_IS_EAGAIN ( rv ) ) ) ) { return APR_EAGAIN ; } if ( rv == APR_EOF ) { return APR_INCOMPLETE ; } if ( rv != APR_SUCCESS ) { return rv ; } e = APR_BRIGADE_FIRST ( b ) ; while ( e != APR_BRIGADE_SENTINEL ( b ) ) { const char * buffer ; apr_size_t len ; if ( ! APR_BUCKET_IS_METADATA ( e ) ) { rv = apr_bucket_read ( e , & buffer , & len , APR_BLOCK_READ ) ; if ( rv == APR_SUCCESS ) { rv = parse_chunk_size ( ctx , buffer , len , f -> r -> server -> limit_req_fieldsize ) ; } if ( rv != APR_SUCCESS ) { ap_log_rerror ( APLOG_MARK , APLOG_INFO , rv , f -> r , APLOGNO ( 01590 ) ""Errorreadingchunk%s"" , ( APR_ENOSPC == rv ) ? ""(overflow)"" : """" ) ; return rv ; } } apr_bucket_delete ( e ) ; e = APR_BRIGADE_FIRST ( b ) ; } again = 1 ; if ( ctx -> state == BODY_CHUNK_TRAILER ) { int merge_trailers = conf -> merge_trailers == AP_MERGE_TRAILERS_ENABLE ; return read_chunked_trailers ( ctx , f , b , merge_trailers ) ; } break ; } case BODY_NONE : case BODY_LENGTH : case BODY_CHUNK_DATA : { if ( ctx -> state != BODY_NONE && ctx -> remaining < readbytes ) { readbytes = ctx -> remaining ; } if ( readbytes > 0 ) { rv = ap_get_brigade ( f -> next , b , mode , block , readbytes ) ; if ( block == APR_NONBLOCK_READ && ( ( rv == APR_SUCCESS && APR_BRIGADE_EMPTY ( b ) ) || ( APR_STATUS_IS_EAGAIN ( rv ) ) ) ) { return APR_EAGAIN ; } if ( rv == APR_EOF && ctx -> state != BODY_NONE && ctx -> remaining > 0 ) { return APR_INCOMPLETE ; } if ( rv != APR_SUCCESS ) { return rv ; } apr_brigade_length ( b , 0 , & totalread ) ; AP_DEBUG_ASSERT ( totalread >= 0 ) ; if ( ctx -> state != BODY_NONE ) { ctx -> remaining -= totalread ; if ( ctx -> remaining > 0 ) { e = APR_BRIGADE_LAST ( b ) ; if ( APR_BUCKET_IS_EOS ( e ) ) { apr_bucket_delete ( e ) ; return APR_INCOMPLETE ; } } else if ( ctx -> state == BODY_CHUNK_DATA ) { ctx -> state = BODY_CHUNK_END ; ctx -> chunk_used = 0 ; } } } if ( ctx -> state == BODY_LENGTH && ctx -> remaining == 0 ) { e = apr_bucket_eos_create ( f -> c -> bucket_alloc ) ; APR_BRIGADE_INSERT_TAIL ( b , e ) ; ctx -> eos_sent = 1 ; } if ( ctx -> limit ) { ctx -> limit_used += totalread ; if ( ctx -> limit < ctx -> limit_used ) { ap_log_rerror ( APLOG_MARK , APLOG_INFO , 0 , f -> r , APLOGNO ( 01591 ) ""Readcontent-lengthof%"" APR_OFF_T_FMT ""islargerthantheconfiguredlimit"" ""of%"" APR_OFF_T_FMT , ctx -> limit_used , ctx -> limit ) ; return APR_ENOSPC ; } } break ; } case BODY_CHUNK_TRAILER : { rv = ap_get_brigade ( f -> next , b , mode , block , readbytes ) ; if ( block == APR_NONBLOCK_READ && ( ( rv == APR_SUCCESS && APR_BRIGADE_EMPTY ( b ) ) || ( APR_STATUS_IS_EAGAIN ( rv ) ) ) ) { return APR_EAGAIN ; } if ( rv != APR_SUCCESS ) { return rv ; } break ; } default : { break ; } } } while ( again ) ; return APR_SUCCESS ; } "," ( 02555 ) ""UnknownTransfer-Encoding:%s;"" ""usingread-until-close"" , tenc ) ) ; return APR_EINVAL ; } if bb ) ; apr_brigade_cleanup ( bb ) ; BODY_CHUNK_EXT : case BODY_CHUNK_LF : case BODY_CHUNK_END : case BODY_CHUNK_END_LF : { rv BODY_CHUNK_TRAILER ) { return read_chunked_trailers ( ctx , f , b , conf -> merge_trailers == AP_MERGE_TRAILERS_ENABLE ) ; } default : { ap_log_rerror ( APLOG_MARK , APLOG_ERR , 0 , f -> r , APLOGNO ( 02901 ) ""Unexpectedbodystate(%i)"" , ( int ) ctx -> state ) ; return APR_EGENERAL ; } } ",apache@httpd/a6027e56924bb6227c1fdbf6f91e7e2438338be6,CVE-2015-3183,https://github.com/apache/httpd/commit/a6027e56924bb6227c1fdbf6f91e7e2438338be6,2015-07-20T23:59Z 1151,CWE-000,"CWE-000 bool_t xdr_krb5_tl_data ( XDR * xdrs , krb5_tl_data * * tl_data_head ) { krb5_tl_data * tl , * tl2 ; bool_t more ; unsigned int len ; switch ( xdrs -> x_op ) { case XDR_FREE : tl = tl2 = * tl_data_head ; while ( tl ) { tl2 = tl -> tl_data_next ; free ( tl -> tl_data_contents ) ; free ( tl ) ; tl = tl2 ; } break ; case XDR_ENCODE : tl = * tl_data_head ; while ( 1 ) { more = ( tl != NULL ) ; if ( ! xdr_bool ( xdrs , & more ) ) return FALSE ; if ( tl == NULL ) break ; if ( ! xdr_krb5_int16 ( xdrs , & tl -> tl_data_type ) ) return FALSE ; len = tl -> tl_data_length ; if ( ! xdr_bytes ( xdrs , ( char * * ) & tl -> tl_data_contents , & len , ~ 0 ) ) return FALSE ; tl = tl -> tl_data_next ; } break ; case XDR_DECODE : tl = NULL ; while ( 1 ) { if ( ! xdr_bool ( xdrs , & more ) ) return FALSE ; if ( more == FALSE ) break ; tl2 = ( krb5_tl_data * ) malloc ( sizeof ( krb5_tl_data ) ) ; if ( tl2 == NULL ) return FALSE ; memset ( tl2 , 0 , sizeof ( krb5_tl_data ) ) ; if ( ! xdr_krb5_int16 ( xdrs , & tl2 -> tl_data_type ) ) return FALSE ; if ( ! xdr_bytes ( xdrs , ( char * * ) & tl2 -> tl_data_contents , & len , ~ 0 ) ) return FALSE ; tl2 -> tl_data_length = len ; tl2 -> tl_data_next = tl ; tl = tl2 ; } * tl_data_head = tl ; break ; } return TRUE ; } "," tl2 ; } * tl_data_head = NULL ; ",krb5@krb5/a197e92349a4aa2141b5dff12e9dd44c2a2166e3,CVE-2014-9421,https://github.com/krb5/krb5/commit/a197e92349a4aa2141b5dff12e9dd44c2a2166e3,2015-02-19T11:59Z 1152,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 1153,CWE-787,"CWE-787 static void iriap_getvaluebyclass_indication ( struct iriap_cb * self , struct sk_buff * skb ) { struct ias_object * obj ; struct ias_attrib * attrib ; int name_len ; int attr_len ; char name [ IAS_MAX_CLASSNAME + 1 ] ; char attr [ IAS_MAX_ATTRIBNAME + 1 ] ; __u8 * fp ; int n ; IRDA_DEBUG ( 4 , ""%s()\\n"" , __func__ ) ; IRDA_ASSERT ( self != NULL , return ; ) ; IRDA_ASSERT ( self -> magic == IAS_MAGIC , return ; ) ; IRDA_ASSERT ( skb != NULL , return ; ) ; fp = skb -> data ; n = 1 ; name_len = fp [ n ++ ] ; memcpy ( name , fp + n , name_len ) ; n += name_len ; name [ name_len ] = '\\0' ; attr_len = fp [ n ++ ] ; memcpy ( attr , fp + n , attr_len ) ; n += attr_len ; attr [ attr_len ] = '\\0' ; IRDA_DEBUG ( 4 , ""LM-IAS:Lookingup%s:%s\\n"" , name , attr ) ; obj = irias_find_object ( name ) ; if ( obj == NULL ) { IRDA_DEBUG ( 2 , ""LM-IAS:Object%snotfound\\n"" , name ) ; iriap_getvaluebyclass_response ( self , 0x1235 , IAS_CLASS_UNKNOWN , & irias_missing ) ; return ; } IRDA_DEBUG ( 4 , ""LM-IAS:found%s,id=%d\\n"" , obj -> name , obj -> id ) ; attrib = irias_find_attrib ( obj , attr ) ; if ( attrib == NULL ) { IRDA_DEBUG ( 2 , ""LM-IAS:Attribute%snotfound\\n"" , attr ) ; iriap_getvaluebyclass_response ( self , obj -> id , IAS_ATTRIB_UNKNOWN , & irias_missing ) ; return ; } iriap_getvaluebyclass_response ( self , obj -> id , IAS_SUCCESS , attrib -> value ) ; } "," ++ ] ; IRDA_ASSERT ( name_len < IAS_MAX_CLASSNAME + 1 , return ; ) ; n ++ ] ; IRDA_ASSERT ( attr_len < IAS_MAX_ATTRIBNAME + 1 , return ; ) ",torvalds@linux/d370af0ef7951188daeb15bae75db7ba57c67846,CVE-2011-1180,https://github.com/torvalds/linux/commit/d370af0ef7951188daeb15bae75db7ba57c67846,2013-06-08T13:05Z 1154,CWE-617,"CWE-617 static void finish_process_as_req ( struct as_req_state * state , krb5_error_code errcode ) { krb5_key_data * server_key ; krb5_keyblock * as_encrypting_key = NULL ; krb5_data * response = NULL ; const char * emsg = 0 ; int did_log = 0 ; loop_respond_fn oldrespond ; void * oldarg ; kdc_realm_t * kdc_active_realm = state -> active_realm ; krb5_audit_state * au_state = state -> au_state ; assert ( state ) ; oldrespond = state -> respond ; oldarg = state -> arg ; if ( errcode ) goto egress ; au_state -> stage = ENCR_REP ; if ( ( errcode = validate_forwardable ( state -> request , * state -> client , * state -> server , state -> kdc_time , & state -> status ) ) ) { errcode += ERROR_TABLE_BASE_krb5 ; goto egress ; } errcode = check_indicators ( kdc_context , state -> server , state -> auth_indicators ) ; if ( errcode ) { state -> status = ""HIGHER_AUTHENTICATION_REQUIRED"" ; goto egress ; } state -> ticket_reply . enc_part2 = & state -> enc_tkt_reply ; if ( ( errcode = krb5_dbe_find_enctype ( kdc_context , state -> server , - 1 , - 1 , 0 , & server_key ) ) ) { state -> status = ""FINDING_SERVER_KEY"" ; goto egress ; } if ( ( errcode = krb5_dbe_decrypt_key_data ( kdc_context , NULL , server_key , & state -> server_keyblock , NULL ) ) ) { state -> status = ""DECRYPT_SERVER_KEY"" ; goto egress ; } state -> reply . msg_type = KRB5_AS_REP ; state -> reply . client = state -> enc_tkt_reply . client ; state -> reply . ticket = & state -> ticket_reply ; state -> reply_encpart . session = & state -> session_key ; if ( ( errcode = fetch_last_req_info ( state -> client , & state -> reply_encpart . last_req ) ) ) { state -> status = ""FETCH_LAST_REQ"" ; goto egress ; } state -> reply_encpart . nonce = state -> request -> nonce ; state -> reply_encpart . key_exp = get_key_exp ( state -> client ) ; state -> reply_encpart . flags = state -> enc_tkt_reply . flags ; state -> reply_encpart . server = state -> ticket_reply . server ; state -> reply_encpart . times = state -> enc_tkt_reply . times ; state -> reply_encpart . times . authtime = state -> authtime = state -> kdc_time ; state -> reply_encpart . caddrs = state -> enc_tkt_reply . caddrs ; state -> reply_encpart . enc_padata = NULL ; errcode = return_padata ( kdc_context , & state -> rock , state -> req_pkt , state -> request , & state -> reply , & state -> client_keyblock , & state -> pa_context ) ; if ( errcode ) { state -> status = ""KDC_RETURN_PADATA"" ; goto egress ; } if ( state -> client_keyblock . enctype == ENCTYPE_NULL ) { state -> status = ""CANT_FIND_CLIENT_KEY"" ; errcode = KRB5KDC_ERR_ETYPE_NOSUPP ; goto egress ; } errcode = handle_authdata ( kdc_context , state -> c_flags , state -> client , state -> server , NULL , state -> local_tgt , & state -> client_keyblock , & state -> server_keyblock , NULL , state -> req_pkt , state -> request , NULL , NULL , state -> auth_indicators , & state -> enc_tkt_reply ) ; if ( errcode ) { krb5_klog_syslog ( LOG_INFO , _ ( ""AS_REQ:handle_authdata(%d)"" ) , errcode ) ; state -> status = ""HANDLE_AUTHDATA"" ; goto egress ; } errcode = krb5_encrypt_tkt_part ( kdc_context , & state -> server_keyblock , & state -> ticket_reply ) ; if ( errcode ) { state -> status = ""ENCRYPT_TICKET"" ; goto egress ; } errcode = kau_make_tkt_id ( kdc_context , & state -> ticket_reply , & au_state -> tkt_out_id ) ; if ( errcode ) { state -> status = ""GENERATE_TICKET_ID"" ; goto egress ; } state -> ticket_reply . enc_part . kvno = server_key -> key_data_kvno ; errcode = kdc_fast_response_handle_padata ( state -> rstate , state -> request , & state -> reply , state -> client_keyblock . enctype ) ; if ( errcode ) { state -> status = ""MAKE_FAST_RESPONSE"" ; goto egress ; } state -> reply . enc_part . enctype = state -> client_keyblock . enctype ; errcode = kdc_fast_handle_reply_key ( state -> rstate , & state -> client_keyblock , & as_encrypting_key ) ; if ( errcode ) { state -> status = ""MAKE_FAST_REPLY_KEY"" ; goto egress ; } errcode = return_enc_padata ( kdc_context , state -> req_pkt , state -> request , as_encrypting_key , state -> server , & state -> reply_encpart , FALSE ) ; if ( errcode ) { state -> status = ""KDC_RETURN_ENC_PADATA"" ; goto egress ; } if ( kdc_fast_hide_client ( state -> rstate ) ) state -> reply . client = ( krb5_principal ) krb5_anonymous_principal ( ) ; errcode = krb5_encode_kdc_rep ( kdc_context , KRB5_AS_REP , & state -> reply_encpart , 0 , as_encrypting_key , & state -> reply , & response ) ; if ( state -> client_key != NULL ) state -> reply . enc_part . kvno = state -> client_key -> key_data_kvno ; if ( errcode ) { state -> status = ""ENCODE_KDC_REP"" ; goto egress ; } memset ( state -> reply . enc_part . ciphertext . data , 0 , state -> reply . enc_part . ciphertext . length ) ; free ( state -> reply . enc_part . ciphertext . data ) ; log_as_req ( kdc_context , state -> local_addr , state -> remote_addr , state -> request , & state -> reply , state -> client , state -> cname , state -> server , state -> sname , state -> authtime , 0 , 0 , 0 ) ; did_log = 1 ; egress : if ( errcode != 0 ) assert ( state -> status != 0 ) ; au_state -> status = state -> status ; au_state -> reply = & state -> reply ; kau_as_req ( kdc_context , ( errcode || state -> preauth_err ) ? FALSE : TRUE , au_state ) ; kau_free_kdc_req ( au_state ) ; free_padata_context ( kdc_context , state -> pa_context ) ; if ( as_encrypting_key ) krb5_free_keyblock ( kdc_context , as_encrypting_key ) ; if ( errcode ) emsg = krb5_get_error_message ( kdc_context , errcode ) ; if ( state -> status ) { log_as_req ( kdc_context , state -> local_addr , state -> remote_addr , state -> request , & state -> reply , state -> client , state -> cname , state -> server , state -> sname , state -> authtime , state -> status , errcode , emsg ) ; did_log = 1 ; } if ( errcode ) { if ( state -> status == 0 ) { state -> status = emsg ; } if ( errcode != KRB5KDC_ERR_DISCARD ) { errcode -= ERROR_TABLE_BASE_krb5 ; if ( errcode < 0 || errcode > KRB_ERR_MAX ) errcode = KRB_ERR_GENERIC ; errcode = prepare_error_as ( state -> rstate , state -> request , state -> local_tgt , errcode , state -> e_data , state -> typed_e_data , ( ( state -> client != NULL ) ? state -> client -> princ : NULL ) , & response , state -> status ) ; state -> status = 0 ; } } if ( emsg ) krb5_free_error_message ( kdc_context , emsg ) ; if ( state -> enc_tkt_reply . authorization_data != NULL ) krb5_free_authdata ( kdc_context , state -> enc_tkt_reply . authorization_data ) ; if ( state -> server_keyblock . contents != NULL ) krb5_free_keyblock_contents ( kdc_context , & state -> server_keyblock ) ; if ( state -> client_keyblock . contents != NULL ) krb5_free_keyblock_contents ( kdc_context , & state -> client_keyblock ) ; if ( state -> reply . padata != NULL ) krb5_free_pa_data ( kdc_context , state -> reply . padata ) ; if ( state -> reply_encpart . enc_padata ) krb5_free_pa_data ( kdc_context , state -> reply_encpart . enc_padata ) ; if ( state -> cname != NULL ) free ( state -> cname ) ; if ( state -> sname != NULL ) free ( state -> sname ) ; krb5_db_free_principal ( kdc_context , state -> client ) ; krb5_db_free_principal ( kdc_context , state -> server ) ; krb5_db_free_principal ( kdc_context , state -> local_tgt_storage ) ; if ( state -> session_key . contents != NULL ) krb5_free_keyblock_contents ( kdc_context , & state -> session_key ) ; if ( state -> ticket_reply . enc_part . ciphertext . data != NULL ) { memset ( state -> ticket_reply . enc_part . ciphertext . data , 0 , state -> ticket_reply . enc_part . ciphertext . length ) ; free ( state -> ticket_reply . enc_part . ciphertext . data ) ; } krb5_free_pa_data ( kdc_context , state -> e_data ) ; krb5_free_data ( kdc_context , state -> inner_body ) ; kdc_free_rstate ( state -> rstate ) ; krb5_free_kdc_req ( kdc_context , state -> request ) ; k5_free_data_ptr_list ( state -> auth_indicators ) ; assert ( did_log != 0 ) ; free ( state ) ; ( * oldrespond ) ( oldarg , errcode , response ) ; } "," errcode != 0 && state -> status == NULL ) state -> status = ""UNKNOWN_REASON"" ; au_state -> ",krb5@krb5/ffb35baac6981f9e8914f8f3bffd37f284b85970,CVE-2017-11368,https://github.com/krb5/krb5/commit/ffb35baac6981f9e8914f8f3bffd37f284b85970,2017-08-09T18:29Z 1155,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 1156,CWE-119,"CWE-119 static void wdm_in_callback ( struct urb * urb ) { struct wdm_device * desc = urb -> context ; int status = urb -> status ; spin_lock ( & desc -> iuspin ) ; clear_bit ( WDM_RESPONDING , & desc -> flags ) ; if ( status ) { switch ( status ) { case - ENOENT : dev_dbg ( & desc -> intf -> dev , ""nonzerourbstatusreceived:-ENOENT"" ) ; goto skip_error ; case - ECONNRESET : dev_dbg ( & desc -> intf -> dev , ""nonzerourbstatusreceived:-ECONNRESET"" ) ; goto skip_error ; case - ESHUTDOWN : dev_dbg ( & desc -> intf -> dev , ""nonzerourbstatusreceived:-ESHUTDOWN"" ) ; goto skip_error ; case - EPIPE : dev_err ( & desc -> intf -> dev , ""nonzerourbstatusreceived:-EPIPE\\n"" ) ; break ; default : dev_err ( & desc -> intf -> dev , ""Unexpectederror%d\\n"" , status ) ; break ; } } desc -> rerr = status ; desc -> reslength = urb -> actual_length ; memmove ( desc -> ubuf + desc -> length , desc -> inbuf , desc -> reslength ) ; desc -> length += desc -> reslength ; skip_error : wake_up ( & desc -> wait ) ; set_bit ( WDM_READ , & desc -> flags ) ; spin_unlock ( & desc -> iuspin ) ; } "," -> status ; int length = urb -> actual_length ; = status ; if ( length + desc -> length > desc -> wMaxCommand ) { set_bit ( WDM_OVERFLOW , & desc -> flags ) ; } else { if ( ! test_bit ( WDM_OVERFLOW , & desc -> flags ) ) { memmove ( desc -> inbuf , length ) ; desc -> length += length ; desc -> reslength = length ; } } skip_error : wake_up ",torvalds@linux/c0f5ecee4e741667b2493c742b60b6218d40b3aa,CVE-2013-1860,https://github.com/torvalds/linux/commit/c0f5ecee4e741667b2493c742b60b6218d40b3aa,2013-03-22T11:59Z 1157,CWE-000,"CWE-000 int DetectEngineContentInspection ( DetectEngineCtx * de_ctx , DetectEngineThreadCtx * det_ctx , const Signature * s , const SigMatchData * smd , Flow * f , uint8_t * buffer , uint32_t buffer_len , uint32_t stream_start_offset , uint8_t inspection_mode , void * data ) { SCEnter ( ) ; KEYWORD_PROFILING_START ; det_ctx -> inspection_recursion_counter ++ ; if ( det_ctx -> inspection_recursion_counter == de_ctx -> inspection_recursion_limit ) { det_ctx -> discontinue_matching = 1 ; KEYWORD_PROFILING_END ( det_ctx , smd -> type , 0 ) ; SCReturnInt ( 0 ) ; } if ( smd == NULL || buffer_len == 0 ) { KEYWORD_PROFILING_END ( det_ctx , smd -> type , 0 ) ; SCReturnInt ( 0 ) ; } if ( smd -> type == DETECT_CONTENT ) { DetectContentData * cd = ( DetectContentData * ) smd -> ctx ; SCLogDebug ( ""inspectingcontent%"" PRIu32 ""buffer_len%"" PRIu32 , cd -> id , buffer_len ) ; # ifdef DEBUG BUG_ON ( cd -> depth != 0 && cd -> depth <= cd -> offset ) ; # endif uint8_t * found = NULL ; uint32_t offset = 0 ; uint32_t depth = buffer_len ; uint32_t prev_offset = 0 ; uint32_t prev_buffer_offset = det_ctx -> buffer_offset ; do { if ( ( cd -> flags & DETECT_CONTENT_DISTANCE ) || ( cd -> flags & DETECT_CONTENT_WITHIN ) ) { SCLogDebug ( ""det_ctx->buffer_offset%"" PRIu32 , det_ctx -> buffer_offset ) ; offset = prev_buffer_offset ; depth = buffer_len ; int distance = cd -> distance ; if ( cd -> flags & DETECT_CONTENT_DISTANCE ) { if ( cd -> flags & DETECT_CONTENT_DISTANCE_BE ) { distance = det_ctx -> bj_values [ cd -> distance ] ; } if ( distance < 0 && ( uint32_t ) ( abs ( distance ) ) > offset ) offset = 0 ; else offset += distance ; SCLogDebug ( ""cd->distance%"" PRIi32 "",offset%"" PRIu32 "",depth%"" PRIu32 , distance , offset , depth ) ; } if ( cd -> flags & DETECT_CONTENT_WITHIN ) { if ( cd -> flags & DETECT_CONTENT_WITHIN_BE ) { if ( ( int32_t ) depth > ( int32_t ) ( prev_buffer_offset + det_ctx -> bj_values [ cd -> within ] + distance ) ) { depth = prev_buffer_offset + det_ctx -> bj_values [ cd -> within ] + distance ; } } else { if ( ( int32_t ) depth > ( int32_t ) ( prev_buffer_offset + cd -> within + distance ) ) { depth = prev_buffer_offset + cd -> within + distance ; } SCLogDebug ( ""cd->within%"" PRIi32 "",det_ctx->buffer_offset%"" PRIu32 "",depth%"" PRIu32 , cd -> within , prev_buffer_offset , depth ) ; } if ( stream_start_offset != 0 && prev_buffer_offset == 0 ) { if ( depth <= stream_start_offset ) { goto no_match ; } else if ( depth >= ( stream_start_offset + buffer_len ) ) { ; } else { depth = depth - stream_start_offset ; } } } if ( cd -> flags & DETECT_CONTENT_DEPTH_BE ) { if ( ( det_ctx -> bj_values [ cd -> depth ] + prev_buffer_offset ) < depth ) { depth = prev_buffer_offset + det_ctx -> bj_values [ cd -> depth ] ; } } else { if ( cd -> depth != 0 ) { if ( ( cd -> depth + prev_buffer_offset ) < depth ) { depth = prev_buffer_offset + cd -> depth ; } SCLogDebug ( ""cd->depth%"" PRIu32 "",depth%"" PRIu32 , cd -> depth , depth ) ; } } if ( cd -> flags & DETECT_CONTENT_OFFSET_BE ) { if ( det_ctx -> bj_values [ cd -> offset ] > offset ) offset = det_ctx -> bj_values [ cd -> offset ] ; } else { if ( cd -> offset > offset ) { offset = cd -> offset ; SCLogDebug ( ""settingoffset%"" PRIu32 , offset ) ; } } } else { if ( cd -> flags & DETECT_CONTENT_DEPTH_BE ) { depth = det_ctx -> bj_values [ cd -> depth ] ; } else { if ( cd -> depth != 0 ) { depth = cd -> depth ; } } if ( stream_start_offset != 0 && cd -> flags & DETECT_CONTENT_DEPTH ) { if ( depth <= stream_start_offset ) { goto no_match ; } else if ( depth >= ( stream_start_offset + buffer_len ) ) { ; } else { depth = depth - stream_start_offset ; } } if ( cd -> flags & DETECT_CONTENT_OFFSET_BE ) offset = det_ctx -> bj_values [ cd -> offset ] ; else offset = cd -> offset ; prev_buffer_offset = 0 ; } SCLogDebug ( ""offset%"" PRIu32 "",prev_offset%"" PRIu32 , offset , prev_offset ) ; if ( prev_offset != 0 ) offset = prev_offset ; SCLogDebug ( ""offset%"" PRIu32 "",depth%"" PRIu32 , offset , depth ) ; if ( depth > buffer_len ) depth = buffer_len ; if ( offset > depth || depth == 0 ) { if ( cd -> flags & DETECT_CONTENT_NEGATED ) { goto match ; } else { goto no_match ; } } uint8_t * sbuffer = buffer + offset ; uint32_t sbuffer_len = depth - offset ; uint32_t match_offset = 0 ; SCLogDebug ( ""sbuffer_len%"" PRIu32 , sbuffer_len ) ; # ifdef DEBUG BUG_ON ( sbuffer_len > buffer_len ) ; # endif found = SpmScan ( cd -> spm_ctx , det_ctx -> spm_thread_ctx , sbuffer , sbuffer_len ) ; SCLogDebug ( ""found%pcdnegated%s"" , found , cd -> flags & DETECT_CONTENT_NEGATED ? ""true"" : ""false"" ) ; if ( found == NULL && ! ( cd -> flags & DETECT_CONTENT_NEGATED ) ) { goto no_match ; } else if ( found == NULL && ( cd -> flags & DETECT_CONTENT_NEGATED ) ) { goto match ; } else if ( found != NULL && ( cd -> flags & DETECT_CONTENT_NEGATED ) ) { SCLogDebug ( ""content%"" PRIu32 ""matchedatoffset%"" PRIu32 "",butnegatedsonomatch"" , cd -> id , match_offset ) ; if ( DETECT_CONTENT_IS_SINGLE ( cd ) ) det_ctx -> discontinue_matching = 1 ; goto no_match ; } else { match_offset = ( uint32_t ) ( ( found - buffer ) + cd -> content_len ) ; SCLogDebug ( ""content%"" PRIu32 ""matchedatoffset%"" PRIu32 """" , cd -> id , match_offset ) ; det_ctx -> buffer_offset = match_offset ; if ( cd -> flags & DETECT_CONTENT_REPLACE ) { if ( inspection_mode == DETECT_ENGINE_CONTENT_INSPECTION_MODE_PAYLOAD ) { det_ctx -> replist = DetectReplaceAddToList ( det_ctx -> replist , found , cd ) ; } else { SCLogWarning ( SC_ERR_INVALID_VALUE , ""Can\'tmodifypayloadwithoutpacket"" ) ; } } if ( ! ( cd -> flags & DETECT_CONTENT_RELATIVE_NEXT ) ) { SCLogDebug ( ""norelativematchcomingup,sothisisamatch"" ) ; goto match ; } if ( smd -> is_last ) { goto no_match ; } SCLogDebug ( ""content%"" PRIu32 , cd -> id ) ; KEYWORD_PROFILING_END ( det_ctx , smd -> type , 1 ) ; int r = DetectEngineContentInspection ( de_ctx , det_ctx , s , smd + 1 , f , buffer , buffer_len , stream_start_offset , inspection_mode , data ) ; if ( r == 1 ) { SCReturnInt ( 1 ) ; } if ( det_ctx -> discontinue_matching ) goto no_match ; prev_offset = ( match_offset - ( cd -> content_len - 1 ) ) ; SCLogDebug ( ""tryingtoseeifthereisanothermatchafterprev_offset%"" PRIu32 , prev_offset ) ; } } while ( 1 ) ; } else if ( smd -> type == DETECT_ISDATAAT ) { SCLogDebug ( ""inspectingisdataat"" ) ; DetectIsdataatData * id = ( DetectIsdataatData * ) smd -> ctx ; if ( id -> flags & ISDATAAT_RELATIVE ) { if ( det_ctx -> buffer_offset + id -> dataat > buffer_len ) { SCLogDebug ( ""det_ctx->buffer_offset+id->dataat%"" PRIu32 "">%"" PRIu32 , det_ctx -> buffer_offset + id -> dataat , buffer_len ) ; if ( id -> flags & ISDATAAT_NEGATED ) goto match ; goto no_match ; } else { SCLogDebug ( ""relativeisdataatmatch"" ) ; if ( id -> flags & ISDATAAT_NEGATED ) goto no_match ; goto match ; } } else { if ( id -> dataat < buffer_len ) { SCLogDebug ( ""absoluteisdataatmatch"" ) ; if ( id -> flags & ISDATAAT_NEGATED ) goto no_match ; goto match ; } else { SCLogDebug ( ""absoluteisdataatmismatch,id->isdataat%"" PRIu32 "",buffer_len%"" PRIu32 """" , id -> dataat , buffer_len ) ; if ( id -> flags & ISDATAAT_NEGATED ) goto match ; goto no_match ; } } } else if ( smd -> type == DETECT_PCRE ) { SCLogDebug ( ""inspectingpcre"" ) ; DetectPcreData * pe = ( DetectPcreData * ) smd -> ctx ; uint32_t prev_buffer_offset = det_ctx -> buffer_offset ; uint32_t prev_offset = 0 ; int r = 0 ; det_ctx -> pcre_match_start_offset = 0 ; do { Packet * p = NULL ; if ( inspection_mode == DETECT_ENGINE_CONTENT_INSPECTION_MODE_PAYLOAD ) p = ( Packet * ) data ; r = DetectPcrePayloadMatch ( det_ctx , s , smd , p , f , buffer , buffer_len ) ; if ( r == 0 ) { goto no_match ; } if ( ! ( pe -> flags & DETECT_PCRE_RELATIVE_NEXT ) ) { SCLogDebug ( ""norelativematchcomingup,sothisisamatch"" ) ; goto match ; } KEYWORD_PROFILING_END ( det_ctx , smd -> type , 1 ) ; prev_offset = det_ctx -> pcre_match_start_offset ; r = DetectEngineContentInspection ( de_ctx , det_ctx , s , smd + 1 , f , buffer , buffer_len , stream_start_offset , inspection_mode , data ) ; if ( r == 1 ) { SCReturnInt ( 1 ) ; } if ( det_ctx -> discontinue_matching ) goto no_match ; det_ctx -> buffer_offset = prev_buffer_offset ; det_ctx -> pcre_match_start_offset = prev_offset ; } while ( 1 ) ; } else if ( smd -> type == DETECT_BYTETEST ) { DetectBytetestData * btd = ( DetectBytetestData * ) smd -> ctx ; uint8_t flags = btd -> flags ; int32_t offset = btd -> offset ; uint64_t value = btd -> value ; if ( flags & DETECT_BYTETEST_OFFSET_BE ) { offset = det_ctx -> bj_values [ offset ] ; } if ( flags & DETECT_BYTETEST_VALUE_BE ) { value = det_ctx -> bj_values [ value ] ; } if ( flags & DETECT_BYTETEST_DCE && data != NULL ) { DCERPCState * dcerpc_state = ( DCERPCState * ) data ; flags |= ( ( dcerpc_state -> dcerpc . dcerpchdr . packed_drep [ 0 ] & 0x10 ) ? DETECT_BYTETEST_LITTLE : 0 ) ; } if ( DetectBytetestDoMatch ( det_ctx , s , smd -> ctx , buffer , buffer_len , flags , offset , value ) != 1 ) { goto no_match ; } goto match ; } else if ( smd -> type == DETECT_BYTEJUMP ) { DetectBytejumpData * bjd = ( DetectBytejumpData * ) smd -> ctx ; uint8_t flags = bjd -> flags ; int32_t offset = bjd -> offset ; if ( flags & DETECT_BYTEJUMP_OFFSET_BE ) { offset = det_ctx -> bj_values [ offset ] ; } if ( flags & DETECT_BYTEJUMP_DCE && data != NULL ) { DCERPCState * dcerpc_state = ( DCERPCState * ) data ; flags |= ( ( dcerpc_state -> dcerpc . dcerpchdr . packed_drep [ 0 ] & 0x10 ) ? DETECT_BYTEJUMP_LITTLE : 0 ) ; } if ( DetectBytejumpDoMatch ( det_ctx , s , smd -> ctx , buffer , buffer_len , flags , offset ) != 1 ) { goto no_match ; } goto match ; } else if ( smd -> type == DETECT_BYTE_EXTRACT ) { DetectByteExtractData * bed = ( DetectByteExtractData * ) smd -> ctx ; uint8_t endian = bed -> endian ; if ( ( bed -> flags & DETECT_BYTE_EXTRACT_FLAG_ENDIAN ) && endian == DETECT_BYTE_EXTRACT_ENDIAN_DCE && data != NULL ) { DCERPCState * dcerpc_state = ( DCERPCState * ) data ; endian |= ( ( dcerpc_state -> dcerpc . dcerpchdr . packed_drep [ 0 ] == 0x10 ) ? DETECT_BYTE_EXTRACT_ENDIAN_LITTLE : DETECT_BYTE_EXTRACT_ENDIAN_BIG ) ; } if ( DetectByteExtractDoMatch ( det_ctx , smd , s , buffer , buffer_len , & det_ctx -> bj_values [ bed -> local_id ] , endian ) != 1 ) { goto no_match ; } goto match ; } else if ( smd -> type == DETECT_AL_URILEN ) { SCLogDebug ( ""inspectingurilen"" ) ; int r = 0 ; DetectUrilenData * urilend = ( DetectUrilenData * ) smd -> ctx ; switch ( urilend -> mode ) { case DETECT_URILEN_EQ : if ( buffer_len == urilend -> urilen1 ) r = 1 ; break ; case DETECT_URILEN_LT : if ( buffer_len < urilend -> urilen1 ) r = 1 ; break ; case DETECT_URILEN_GT : if ( buffer_len > urilend -> urilen1 ) r = 1 ; break ; case DETECT_URILEN_RA : if ( buffer_len > urilend -> urilen1 && buffer_len < urilend -> urilen2 ) { r = 1 ; } break ; } if ( r == 1 ) { goto match ; } det_ctx -> discontinue_matching = 0 ; goto no_match ; # ifdef HAVE_LUA } else if ( smd -> type == DETECT_LUA ) { SCLogDebug ( ""luastarting"" ) ; if ( DetectLuaMatchBuffer ( det_ctx , s , smd , buffer , buffer_len , det_ctx -> buffer_offset , f ) != 1 ) { SCLogDebug ( ""luano_match"" ) ; goto no_match ; } SCLogDebug ( ""luamatch"" ) ; goto match ; # endif } else if ( smd -> type == DETECT_BASE64_DECODE ) { if ( DetectBase64DecodeDoMatch ( det_ctx , s , smd , buffer , buffer_len ) ) { if ( s -> sm_arrays [ DETECT_SM_LIST_BASE64_DATA ] != NULL ) { KEYWORD_PROFILING_END ( det_ctx , smd -> type , 1 ) ; if ( DetectBase64DataDoMatch ( de_ctx , det_ctx , s , f ) ) { goto final_match ; } } } } else { SCLogDebug ( ""sm->type%u"" , smd -> type ) ; # ifdef DEBUG BUG_ON ( 1 ) ; # endif } no_match : KEYWORD_PROFILING_END ( det_ctx , smd -> type , 0 ) ; SCReturnInt ( 0 ) ; match : if ( ! smd -> is_last ) { KEYWORD_PROFILING_END ( det_ctx , smd -> type , 1 ) ; int r = DetectEngineContentInspection ( de_ctx , det_ctx , s , smd + 1 , f , buffer , buffer_len , stream_start_offset , inspection_mode , data ) ; SCReturnInt ( r ) ; } final_match : KEYWORD_PROFILING_END ( det_ctx , smd -> type , 1 ) ; SCReturnInt ( 1 ) ; } "," ) ) { if ( ( cd -> flags & ( DETECT_CONTENT_DISTANCE | DETECT_CONTENT_WITHIN ) ) == 0 ) { det_ctx -> discontinue_matching = 1 ; } } if ( smd -> is_last ) { goto match ; } SCLogDebug ) ; } SCLogDebug ( ""nomatchfor\'nextsm\'"" ) ; -> discontinue_matching ) { SCLogDebug ( ""\'nextsm\'saidtodiscontinuethisrightnow"" ) ; goto no_match ; } if ( ( cd -> flags & DETECT_CONTENT_RELATIVE_NEXT ) == 0 ) { SCLogDebug ( ""\'nextsm\'doesnotdependonme,sowecangiveup"" ) ; det_ctx -> discontinue_matching = 1 ; goto no_match ; } SCLogDebug ( ""\'nextsm\'dependsonme%p,letsseewhatwecando(flags%u)"" , cd , cd -> flags ) ; prev_offset = ",OISF@suricata/b9579fbe7dd408200ef03cbe20efddb624b73885,CVE-2017-15377,https://github.com/OISF/suricata/commit/b9579fbe7dd408200ef03cbe20efddb624b73885,2017-10-23T08:29Z 1158,CWE-310,"CWE-310 int btrfs_add_link ( struct btrfs_trans_handle * trans , struct inode * parent_inode , struct inode * inode , const char * name , int name_len , int add_backref , u64 index ) { int ret = 0 ; struct btrfs_key key ; struct btrfs_root * root = BTRFS_I ( parent_inode ) -> root ; u64 ino = btrfs_ino ( inode ) ; u64 parent_ino = btrfs_ino ( parent_inode ) ; if ( unlikely ( ino == BTRFS_FIRST_FREE_OBJECTID ) ) { memcpy ( & key , & BTRFS_I ( inode ) -> root -> root_key , sizeof ( key ) ) ; } else { key . objectid = ino ; btrfs_set_key_type ( & key , BTRFS_INODE_ITEM_KEY ) ; key . offset = 0 ; } if ( unlikely ( ino == BTRFS_FIRST_FREE_OBJECTID ) ) { ret = btrfs_add_root_ref ( trans , root -> fs_info -> tree_root , key . objectid , root -> root_key . objectid , parent_ino , index , name , name_len ) ; } else if ( add_backref ) { ret = btrfs_insert_inode_ref ( trans , root , name , name_len , ino , parent_ino , index ) ; } if ( ret ) return ret ; ret = btrfs_insert_dir_item ( trans , root , name , name_len , parent_inode , & key , btrfs_inode_type ( inode ) , index ) ; if ( ret == - EEXIST ) goto fail_dir_item ; else if ( ret ) { btrfs_abort_transaction ( trans , root , ret ) ; return ret ; } btrfs_i_size_write ( parent_inode , parent_inode -> i_size + name_len * 2 ) ; inode_inc_iversion ( parent_inode ) ; parent_inode -> i_mtime = parent_inode -> i_ctime = CURRENT_TIME ; ret = btrfs_update_inode ( trans , root , parent_inode ) ; if ( ret ) btrfs_abort_transaction ( trans , root , ret ) ; return ret ; fail_dir_item : if ( unlikely ( ino == BTRFS_FIRST_FREE_OBJECTID ) ) { u64 local_index ; int err ; err = btrfs_del_root_ref ( trans , root -> fs_info -> tree_root , key . objectid , root -> root_key . objectid , parent_ino , & local_index , name , name_len ) ; } else if ( add_backref ) { u64 local_index ; int err ; err = btrfs_del_inode_ref ( trans , root , name , name_len , ino , parent_ino , & local_index ) ; } return ret ; } "," == - EEXIST || ret == - EOVERFLOW ",torvalds@linux/9c52057c698fb96f8f07e7a4bcf4801a092bda89,CVE-2012-5375,https://github.com/torvalds/linux/commit/9c52057c698fb96f8f07e7a4bcf4801a092bda89,2013-02-18T11:56Z 1159,CWE-119,"CWE-119 static void fadst8 ( const int16_t * input , int16_t * output ) { int s0 , s1 , s2 , s3 , s4 , s5 , s6 , s7 ; int x0 = input [ 7 ] ; int x1 = input [ 0 ] ; int x2 = input [ 5 ] ; int x3 = input [ 2 ] ; int x4 = input [ 3 ] ; int x5 = input [ 4 ] ; int x6 = input [ 1 ] ; int x7 = input [ 6 ] ; s0 = cospi_2_64 * x0 + cospi_30_64 * x1 ; s1 = cospi_30_64 * x0 - cospi_2_64 * x1 ; s2 = cospi_10_64 * x2 + cospi_22_64 * x3 ; s3 = cospi_22_64 * x2 - cospi_10_64 * x3 ; s4 = cospi_18_64 * x4 + cospi_14_64 * x5 ; s5 = cospi_14_64 * x4 - cospi_18_64 * x5 ; s6 = cospi_26_64 * x6 + cospi_6_64 * x7 ; s7 = cospi_6_64 * x6 - cospi_26_64 * x7 ; x0 = fdct_round_shift ( s0 + s4 ) ; x1 = fdct_round_shift ( s1 + s5 ) ; x2 = fdct_round_shift ( s2 + s6 ) ; x3 = fdct_round_shift ( s3 + s7 ) ; x4 = fdct_round_shift ( s0 - s4 ) ; x5 = fdct_round_shift ( s1 - s5 ) ; x6 = fdct_round_shift ( s2 - s6 ) ; x7 = fdct_round_shift ( s3 - s7 ) ; s0 = x0 ; s1 = x1 ; s2 = x2 ; s3 = x3 ; s4 = cospi_8_64 * x4 + cospi_24_64 * x5 ; s5 = cospi_24_64 * x4 - cospi_8_64 * x5 ; s6 = - cospi_24_64 * x6 + cospi_8_64 * x7 ; s7 = cospi_8_64 * x6 + cospi_24_64 * x7 ; 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 ) ; s2 = cospi_16_64 * ( x2 + x3 ) ; s3 = cospi_16_64 * ( x2 - x3 ) ; s6 = cospi_16_64 * ( x6 + x7 ) ; s7 = cospi_16_64 * ( x6 - x7 ) ; x2 = fdct_round_shift ( s2 ) ; x3 = fdct_round_shift ( s3 ) ; x6 = fdct_round_shift ( s6 ) ; x7 = fdct_round_shift ( s7 ) ; output [ 0 ] = x0 ; output [ 1 ] = - x4 ; output [ 2 ] = x6 ; output [ 3 ] = - x2 ; output [ 4 ] = x3 ; output [ 5 ] = - x7 ; output [ 6 ] = x5 ; output [ 7 ] = - x1 ; } "," fadst8 ( const tran_low_t * input , tran_low_t * output ) output ) { tran_high_t s0 , s1 , s2 , s3 , s4 , s5 , s6 , s7 ; tran_high_t x0 = input 7 ] ; tran_high_t x1 = input 0 ] ; tran_high_t x2 = input 5 ] ; tran_high_t x3 = input 2 ] ; tran_high_t x4 = input 3 ] ; tran_high_t x5 = input 4 ] ; tran_high_t x6 = input 1 ] ; tran_high_t x7 = 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 ) ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1160,CWE-189,"CWE-189 static EAS_RESULT Parse_wave ( SDLS_SYNTHESIZER_DATA * pDLSData , EAS_I32 pos , EAS_U16 waveIndex ) { EAS_RESULT result ; EAS_U32 temp ; EAS_I32 size ; EAS_I32 endChunk ; EAS_I32 chunkPos ; EAS_I32 wsmpPos = 0 ; EAS_I32 fmtPos = 0 ; EAS_I32 dataPos = 0 ; EAS_I32 dataSize = 0 ; S_WSMP_DATA * p ; void * pSample ; S_WSMP_DATA wsmp ; chunkPos = pos + 12 ; if ( ( result = EAS_HWFileSeek ( pDLSData -> hwInstData , pDLSData -> fileHandle , pos ) ) != EAS_SUCCESS ) return result ; if ( ( result = NextChunk ( pDLSData , & pos , & temp , & size ) ) != EAS_SUCCESS ) return result ; if ( temp != CHUNK_WAVE ) { { } return EAS_ERROR_FILE_FORMAT ; } pos = chunkPos ; endChunk = pos + size ; while ( pos < endChunk ) { chunkPos = pos ; if ( ( result = NextChunk ( pDLSData , & pos , & temp , & size ) ) != EAS_SUCCESS ) return result ; switch ( temp ) { case CHUNK_WSMP : wsmpPos = chunkPos + 8 ; break ; case CHUNK_FMT : fmtPos = chunkPos + 8 ; break ; case CHUNK_DATA : dataPos = chunkPos + 8 ; dataSize = size ; break ; default : break ; } } if ( dataSize > MAX_DLS_WAVE_SIZE ) { return EAS_ERROR_SOUND_LIBRARY ; } if ( pDLSData -> pDLS == NULL ) p = & wsmp ; else p = & pDLSData -> wsmpData [ waveIndex ] ; p -> fineTune = 0 ; p -> unityNote = 60 ; p -> gain = 0 ; p -> loopStart = 0 ; p -> loopLength = 0 ; if ( ! fmtPos ) { { } return EAS_ERROR_UNRECOGNIZED_FORMAT ; } if ( ! dataPos ) { { } return EAS_ERROR_UNRECOGNIZED_FORMAT ; } if ( wsmpPos ) { if ( ( result = Parse_wsmp ( pDLSData , wsmpPos , p ) ) != EAS_SUCCESS ) return result ; } if ( ( result = Parse_fmt ( pDLSData , fmtPos , p ) ) != EAS_SUCCESS ) return result ; if ( bitDepth == 8 ) { if ( p -> bitsPerSample == 8 ) size = dataSize ; else size = dataSize >> 1 ; if ( p -> loopLength ) size ++ ; } else { if ( p -> bitsPerSample == 16 ) size = dataSize ; else size = dataSize << 1 ; if ( p -> loopLength ) size += 2 ; } if ( pDLSData -> pDLS == NULL ) { pDLSData -> wavePoolSize += ( EAS_U32 ) size ; return EAS_SUCCESS ; } pSample = pDLSData -> pDLS -> pDLSSamples + pDLSData -> wavePoolOffset ; pDLSData -> pDLS -> pDLSSampleOffsets [ waveIndex ] = pDLSData -> wavePoolOffset ; pDLSData -> pDLS -> pDLSSampleLen [ waveIndex ] = ( EAS_U32 ) size ; pDLSData -> wavePoolOffset += ( EAS_U32 ) size ; if ( pDLSData -> wavePoolOffset > pDLSData -> wavePoolSize ) { { } return EAS_ERROR_SOUND_LIBRARY ; } if ( ( result = Parse_data ( pDLSData , dataPos , dataSize , p , pSample ) ) != EAS_SUCCESS ) return result ; return EAS_SUCCESS ; } "," } if ( dataSize < 0 || ",external@sonivox/e999f077f6ef59d20282f1e04786816a31fb8be6,CVE-2015-3836,https://android.googlesource.com/platform/external/sonivox/+/e999f077f6ef59d20282f1e04786816a31fb8be6,2015-10-01T00:59Z 1161,CWE-120,"CWE-120 int parse_sym_line ( buf , which_set ) char * buf ; int which_set ; { int val , i ; struct symparse * symp ; char * bufp , * commentp , * altp ; mungspaces ( buf ) ; if ( ( commentp = rindex ( buf , '#' ) ) != 0 && commentp [ - 1 ] == '' ) commentp [ - 1 ] = '\\0' ; bufp = index ( buf , '=' ) ; altp = index ( buf , ':' ) ; if ( ! bufp || ( altp && altp < bufp ) ) bufp = altp ; if ( ! bufp ) { if ( strncmpi ( buf , ""finish"" , 6 ) == 0 ) { if ( chosen_symset_start ) chosen_symset_end = TRUE ; chosen_symset_start = FALSE ; return 1 ; } config_error_add ( ""No\\""finish\\"""" ) ; return 0 ; } ++ bufp ; if ( * bufp == '' ) ++ bufp ; symp = match_sym ( buf ) ; if ( ! symp ) { config_error_add ( ""Unknownsymkeyword"" ) ; return 0 ; } if ( ! symset [ which_set ] . name ) { if ( symp -> range == SYM_CONTROL ) { struct symsetentry * tmpsp , * lastsp ; for ( lastsp = symset_list ; lastsp ; lastsp = lastsp -> next ) if ( ! lastsp -> next ) break ; switch ( symp -> idx ) { case 0 : tmpsp = ( struct symsetentry * ) alloc ( sizeof * tmpsp ) ; tmpsp -> next = ( struct symsetentry * ) 0 ; if ( ! lastsp ) symset_list = tmpsp ; else lastsp -> next = tmpsp ; tmpsp -> idx = symset_count ++ ; tmpsp -> name = dupstr ( bufp ) ; tmpsp -> desc = ( char * ) 0 ; tmpsp -> handling = H_UNK ; tmpsp -> nocolor = 0 ; tmpsp -> primary = 0 ; tmpsp -> rogue = 0 ; break ; case 2 : tmpsp = lastsp ; for ( i = 0 ; known_handling [ i ] ; ++ i ) if ( ! strcmpi ( known_handling [ i ] , bufp ) ) { tmpsp -> handling = i ; break ; } break ; case 3 : tmpsp = lastsp ; if ( tmpsp && ! tmpsp -> desc ) tmpsp -> desc = dupstr ( bufp ) ; break ; case 5 : tmpsp = lastsp ; for ( i = 0 ; known_restrictions [ i ] ; ++ i ) { if ( ! strcmpi ( known_restrictions [ i ] , bufp ) ) { switch ( i ) { case 0 : tmpsp -> primary = 1 ; break ; case 1 : tmpsp -> rogue = 1 ; break ; } break ; } } break ; } } return 1 ; } if ( symp -> range ) { if ( symp -> range == SYM_CONTROL ) { switch ( symp -> idx ) { case 0 : if ( ! strcmpi ( bufp , symset [ which_set ] . name ) ) { chosen_symset_start = TRUE ; if ( which_set == ROGUESET ) init_rogue_symbols ( ) ; else if ( which_set == PRIMARY ) init_primary_symbols ( ) ; } break ; case 1 : if ( chosen_symset_start ) chosen_symset_end = TRUE ; chosen_symset_start = FALSE ; break ; case 2 : if ( chosen_symset_start ) set_symhandling ( bufp , which_set ) ; break ; case 4 : if ( chosen_symset_start ) { if ( bufp ) { if ( ! strcmpi ( bufp , ""true"" ) || ! strcmpi ( bufp , ""yes"" ) || ! strcmpi ( bufp , ""on"" ) ) symset [ which_set ] . nocolor = 0 ; else if ( ! strcmpi ( bufp , ""false"" ) || ! strcmpi ( bufp , ""no"" ) || ! strcmpi ( bufp , ""off"" ) ) symset [ which_set ] . nocolor = 1 ; } } break ; case 5 : if ( chosen_symset_start ) { int n = 0 ; while ( known_restrictions [ n ] ) { if ( ! strcmpi ( known_restrictions [ n ] , bufp ) ) { switch ( n ) { case 0 : symset [ which_set ] . primary = 1 ; break ; case 1 : symset [ which_set ] . rogue = 1 ; break ; } break ; } n ++ ; } } break ; } } else { val = sym_val ( bufp ) ; if ( chosen_symset_start ) { if ( which_set == PRIMARY ) { update_primary_symset ( symp , val ) ; } else if ( which_set == ROGUESET ) { update_rogue_symset ( symp , val ) ; } } } } return 1 ; } "," , * altp ; 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 1162,CWE-284,"CWE-284 static void command_timed_out ( UNUSED_ATTR void * context ) { pthread_mutex_lock ( & commands_pending_response_lock ) ; if ( list_is_empty ( commands_pending_response ) ) { LOG_ERROR ( ""%swithnocommandspendingresponse"" , __func__ ) ; } else { waiting_command_t * wait_entry = list_front ( commands_pending_response ) ; pthread_mutex_unlock ( & commands_pending_response_lock ) ; LOG_ERROR ( ""%shcilayertimeoutwaitingforresponsetoacommand.opcode:0x%x"" , __func__ , wait_entry -> opcode ) ; } LOG_ERROR ( ""%srestartingthebluetoothprocess."" , __func__ ) ; usleep ( 10000 ) ; kill ( getpid ( ) , SIGKILL ) ; } "," __func__ ) ; TEMP_FAILURE_RETRY ( usleep ( 10000 ) ",system@bt/472271b153c5dc53c28beac55480a8d8434b2d5c,CVE-2016-3839,https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c,2016-08-05T20:59Z 1163,CWE-119,"CWE-119 static vpx_codec_err_t ctrl_get_frame_corrupted ( vpx_codec_alg_priv_t * ctx , int ctrl_id , va_list args ) { int * corrupted = va_arg ( args , int * ) ; if ( corrupted ) { if ( ctx -> pbi ) * corrupted = ctx -> pbi -> common . frame_to_show -> corrupted ; else return VPX_CODEC_ERROR ; return VPX_CODEC_OK ; } else { return VPX_CODEC_INVALID_PARAM ; } } "," * ctx , va_list args ) ( ctx -> frame_workers ) { VPxWorker * const worker = ctx -> frame_workers ; FrameWorkerData * const frame_worker_data = ( FrameWorkerData * ) worker -> data1 ; RefCntBuffer * const frame_bufs = frame_worker_data -> pbi -> common . buffer_pool -> frame_bufs ; if ( frame_worker_data -> pbi -> common . frame_to_show == NULL ) return VPX_CODEC_ERROR ; if ( ctx -> last_show_frame >= 0 ) * corrupted = frame_bufs [ ctx -> last_show_frame ] . buf . corrupted ; return VPX_CODEC_OK else { return VPX_CODEC_ERROR ; } } ; } } return VPX_CODEC_INVALID_PARAM ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1164,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 1165,CWE-362,"CWE-362 int mi_repair ( MI_CHECK * param , register MI_INFO * info , char * name , int rep_quick ) { int error , got_error ; ha_rows start_records , new_header_length ; my_off_t del ; File new_file ; MYISAM_SHARE * share = info -> s ; char llbuff [ 22 ] , llbuff2 [ 22 ] ; SORT_INFO sort_info ; MI_SORT_PARAM sort_param ; DBUG_ENTER ( ""mi_repair"" ) ; bzero ( ( char * ) & sort_info , sizeof ( sort_info ) ) ; bzero ( ( char * ) & sort_param , sizeof ( sort_param ) ) ; start_records = info -> state -> records ; new_header_length = ( param -> testflag & T_UNPACK ) ? 0L : share -> pack . header_length ; got_error = 1 ; new_file = - 1 ; sort_param . sort_info = & sort_info ; if ( ! ( param -> testflag & T_SILENT ) ) { printf ( ""-recovering(withkeycache)MyISAM-table\'%s\'\\n"" , name ) ; printf ( ""Datarecords:%s\\n"" , llstr ( info -> state -> records , llbuff ) ) ; } param -> testflag |= T_REP ; if ( info -> s -> options & ( HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD ) ) param -> testflag |= T_CALC_CHECKSUM ; DBUG_ASSERT ( param -> use_buffers < SIZE_T_MAX ) ; if ( ! param -> using_global_keycache ) ( void ) init_key_cache ( dflt_key_cache , param -> key_cache_block_size , param -> use_buffers , 0 , 0 ) ; if ( init_io_cache ( & param -> read_cache , info -> dfile , ( uint ) param -> read_buffer_length , READ_CACHE , share -> pack . header_length , 1 , MYF ( MY_WME ) ) ) { bzero ( & info -> rec_cache , sizeof ( info -> rec_cache ) ) ; goto err ; } if ( ! rep_quick ) if ( init_io_cache ( & info -> rec_cache , - 1 , ( uint ) param -> write_buffer_length , WRITE_CACHE , new_header_length , 1 , MYF ( MY_WME | MY_WAIT_IF_FULL ) ) ) goto err ; info -> opt_flag |= WRITE_CACHE_USED ; 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 ; info -> s -> state . dellink = HA_OFFSET_ERROR ; info -> rec_cache . file = new_file ; if ( param -> testflag & T_UNPACK ) { share -> options &= ~ HA_OPTION_COMPRESS_RECORD ; mi_int2store ( share -> state . header . options , share -> options ) ; } } sort_info . info = info ; sort_info . param = param ; sort_param . read_cache = param -> read_cache ; sort_param . pos = sort_param . max_pos = share -> pack . header_length ; sort_param . filepos = new_header_length ; param -> read_cache . end_of_file = sort_info . filelength = mysql_file_seek ( info -> dfile , 0L , MY_SEEK_END , MYF ( 0 ) ) ; sort_info . dupp = 0 ; sort_param . fix_datafile = ( my_bool ) ( ! rep_quick ) ; sort_param . master = 1 ; sort_info . max_records = ~ ( ha_rows ) 0 ; set_data_file_type ( & sort_info , share ) ; del = info -> state -> del ; info -> state -> records = info -> state -> del = share -> state . split = 0 ; info -> state -> empty = 0 ; param -> glob_crc = 0 ; if ( param -> testflag & T_CALC_CHECKSUM ) sort_param . calc_checksum = 1 ; info -> update = ( short ) ( HA_STATE_CHANGED | HA_STATE_ROW_CHANGED ) ; if ( param -> testflag & T_CREATE_MISSING_KEYS ) mi_set_all_keys_active ( share -> state . key_map , share -> base . keys ) ; mi_drop_all_indexes ( param , info , TRUE ) ; lock_memory ( param ) ; while ( ! ( error = sort_get_next_record ( & sort_param ) ) ) { if ( writekeys ( & sort_param ) ) { if ( my_errno != HA_ERR_FOUND_DUPP_KEY ) goto err ; DBUG_DUMP ( ""record"" , ( uchar * ) sort_param . record , share -> base . pack_reclength ) ; mi_check_print_info ( param , ""Duplicatekey%2dforrecordat%10sagainstnewrecordat%10s"" , info -> errkey + 1 , llstr ( sort_param . start_recpos , llbuff ) , llstr ( info -> dupp_key_pos , llbuff2 ) ) ; if ( param -> testflag & T_VERBOSE ) { ( void ) _mi_make_key ( info , ( uint ) info -> errkey , info -> lastkey , sort_param . record , 0L ) ; _mi_print_key ( stdout , share -> keyinfo [ info -> errkey ] . seg , info -> lastkey , USE_WHOLE_KEY ) ; } sort_info . dupp ++ ; if ( ( param -> testflag & ( T_FORCE_UNIQUENESS | T_QUICK ) ) == T_QUICK ) { param -> testflag |= T_RETRY_WITHOUT_QUICK ; param -> error_printed = 1 ; goto err ; } continue ; } if ( sort_write_record ( & sort_param ) ) goto err ; } if ( error > 0 || write_data_suffix ( & sort_info , ( my_bool ) ! rep_quick ) || flush_io_cache ( & info -> rec_cache ) || param -> read_cache . error < 0 ) goto err ; if ( param -> testflag & T_WRITE_LOOP ) { ( void ) fputs ( ""\\r"" , stdout ) ; ( void ) fflush ( stdout ) ; } 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 ) ; goto err ; } 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 ( param -> testflag & T_SAFE_REPAIR ) { if ( info -> state -> records + 1 < start_records ) { info -> state -> records = start_records ; got_error = 1 ; goto err ; } } if ( ! rep_quick ) { mysql_file_close ( info -> dfile , MYF ( 0 ) ) ; info -> dfile = new_file ; info -> state -> data_file_length = sort_param . filepos ; share -> state . version = ( ulong ) time ( ( time_t * ) 0 ) ; } else { info -> state -> data_file_length = sort_param . max_pos ; } if ( param -> testflag & T_CALC_CHECKSUM ) info -> state -> checksum = param -> glob_crc ; 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 : if ( ! got_error ) { if ( new_file >= 0 ) { mysql_file_close ( new_file , MYF ( 0 ) ) ; info -> dfile = new_file = - 1 ; if ( info -> s -> file_map ) { ( void ) my_munmap ( ( char * ) info -> s -> file_map , ( size_t ) info -> s -> mmaped_length ) ; info -> s -> file_map = NULL ; } 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 ; param -> retry_repair = 0 ; } } if ( got_error ) { if ( ! param -> error_printed ) mi_check_print_error ( param , ""%dforrecordatpos%s"" , my_errno , llstr ( sort_param . start_recpos , llbuff ) ) ; 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 ) ) ; info -> rec_cache . file = - 1 ; } mi_mark_crashed_on_repair ( info ) ; } 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 . buff ) ; ( void ) end_io_cache ( & param -> read_cache ) ; info -> opt_flag &= ~ ( READ_CACHE_USED | WRITE_CACHE_USED ) ; ( void ) end_io_cache ( & info -> rec_cache ) ; got_error |= flush_blocks ( param , share -> key_cache , share -> kfile ) ; if ( ! got_error && param -> testflag & T_UNPACK ) { share -> state . header . options [ 0 ] &= ( uchar ) ~ HA_OPTION_COMPRESS_RECORD ; share -> pack . header_length = 0 ; share -> data_file_type = sort_info . new_data_file_type ; } share -> state . changed |= ( STATE_NOT_OPTIMIZED_KEYS | STATE_NOT_SORTED_PAGES | STATE_NOT_ANALYZED ) ; 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 1166,CWE-284,"CWE-284 static int dbConnect ( char * host , char * user , char * passwd ) { DBUG_ENTER ( ""dbConnect"" ) ; if ( verbose ) { fprintf ( stderr , ""#Connectingto%s...\\n"" , host ? host : ""localhost"" ) ; } mysql_init ( & mysql_connection ) ; if ( opt_compress ) mysql_options ( & mysql_connection , MYSQL_OPT_COMPRESS , NullS ) ; # ifdef HAVE_OPENSSL if ( opt_use_ssl ) { mysql_ssl_set ( & mysql_connection , opt_ssl_key , opt_ssl_cert , opt_ssl_ca , opt_ssl_capath , opt_ssl_cipher ) ; mysql_options ( & mysql_connection , MYSQL_OPT_SSL_CRL , opt_ssl_crl ) ; mysql_options ( & mysql_connection , MYSQL_OPT_SSL_CRLPATH , opt_ssl_crlpath ) ; } # endif if ( opt_protocol ) mysql_options ( & mysql_connection , MYSQL_OPT_PROTOCOL , ( char * ) & opt_protocol ) ; if ( opt_bind_addr ) mysql_options ( & mysql_connection , MYSQL_OPT_BIND , opt_bind_addr ) ; # if defined ( _WIN32 ) && ! defined ( EMBEDDED_LIBRARY ) if ( shared_memory_base_name ) mysql_options ( & mysql_connection , MYSQL_SHARED_MEMORY_BASE_NAME , shared_memory_base_name ) ; # endif if ( opt_plugin_dir && * opt_plugin_dir ) mysql_options ( & mysql_connection , MYSQL_PLUGIN_DIR , opt_plugin_dir ) ; if ( opt_default_auth && * opt_default_auth ) mysql_options ( & mysql_connection , MYSQL_DEFAULT_AUTH , opt_default_auth ) ; mysql_options ( & mysql_connection , MYSQL_SET_CHARSET_NAME , default_charset ) ; mysql_options ( & mysql_connection , MYSQL_OPT_CONNECT_ATTR_RESET , 0 ) ; mysql_options4 ( & mysql_connection , MYSQL_OPT_CONNECT_ATTR_ADD , ""program_name"" , ""mysqlcheck"" ) ; if ( ! ( sock = mysql_real_connect ( & mysql_connection , host , user , passwd , NULL , opt_mysql_port , opt_mysql_unix_port , 0 ) ) ) { DBerror ( & mysql_connection , ""whentryingtoconnect"" ) ; DBUG_RETURN ( 1 ) ; } mysql_connection . reconnect = 1 ; DBUG_RETURN ( 0 ) ; } "," NullS ) ; SSL_SET_OPTIONS ( & mysql_connection ) ; if ( opt_protocol ",mysql@mysql-server/3bd5589e1a5a93f9c224badf983cd65c45215390,CVE-2015-3152,https://github.com/mysql/mysql-server/commit/3bd5589e1a5a93f9c224badf983cd65c45215390,2016-05-16T10:59Z 1167,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 1168,CWE-617,"CWE-617 void deinit_pci ( struct vmctx * ctx ) { struct pci_vdev_ops * ops ; struct businfo * bi ; struct slotinfo * si ; struct funcinfo * fi ; int bus , slot , func ; size_t lowmem ; struct mem_range mr ; bzero ( & mr , sizeof ( struct mem_range ) ) ; mr . name = ""PCIECFG"" ; mr . base = PCI_EMUL_ECFG_BASE ; mr . size = PCI_EMUL_ECFG_SIZE ; unregister_mem ( & mr ) ; lowmem = vm_get_lowmem_size ( ctx ) ; bzero ( & mr , sizeof ( struct mem_range ) ) ; mr . name = ""PCIhole(32-bit)"" ; mr . base = lowmem ; mr . size = ( 4ULL * 1024 * 1024 * 1024 ) - lowmem ; unregister_mem_fallback ( & mr ) ; bzero ( & mr , sizeof ( struct mem_range ) ) ; mr . name = ""PCIhole(64-bit)"" ; mr . base = PCI_EMUL_MEMBASE64 ; mr . size = PCI_EMUL_MEMLIMIT64 - PCI_EMUL_MEMBASE64 ; unregister_mem_fallback ( & mr ) ; for ( bus = 0 ; bus < MAXBUSES ; bus ++ ) { bi = pci_businfo [ bus ] ; if ( bi == NULL ) continue ; for ( slot = 0 ; slot < MAXSLOTS ; slot ++ ) { si = & bi -> slotinfo [ slot ] ; for ( func = 0 ; func < MAXFUNCS ; func ++ ) { fi = & si -> si_funcs [ func ] ; if ( fi -> fi_name == NULL ) continue ; ops = pci_emul_finddev ( fi -> fi_name ) ; assert ( ops != NULL ) ; pr_notice ( ""pcideinit%s\\n"" , fi -> fi_name ) ; pci_emul_deinit ( ctx , ops , bus , slot , func , fi ) ; } } } } "," fi_name ) ; if ( ! ops ) { pr_warn ( ""Nodriverfordevice[%s]\\n"" , fi -> fi_name ) ; continue ; } pr_notice ( ""pcideinit%s\\n"" ",projectacrn@acrn-hypervisor/2b3dedfb9ba13f15887f22b935d373f36c9a59fa,CVE-2019-18844,https://github.com/projectacrn/acrn-hypervisor/commit/2b3dedfb9ba13f15887f22b935d373f36c9a59fa,2019-11-13T20:15Z 1169,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 1170,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 1171,CWE-476,"CWE-476 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 ) { return ; } 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 ) ; } "," parameters_size ; } if ( p4 <= 0 ) { return ; } ",radare@radare2/252afb1cff9676f3ae1f341a28448bf2c8b6e308,CVE-2017-6415,https://github.com/radare/radare2/commit/252afb1cff9676f3ae1f341a28448bf2c8b6e308,2017-03-02T01:59Z 1172,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 1173,CWE-362,"CWE-362 static int snd_ctl_elem_user_tlv ( struct snd_kcontrol * kcontrol , int op_flag , unsigned int size , unsigned int __user * tlv ) { struct user_element * ue = kcontrol -> private_data ; int change = 0 ; void * new_data ; if ( op_flag > 0 ) { if ( size > 1024 * 128 ) return - EINVAL ; new_data = memdup_user ( tlv , size ) ; if ( IS_ERR ( new_data ) ) return PTR_ERR ( new_data ) ; change = ue -> tlv_data_size != size ; if ( ! change ) change = memcmp ( ue -> tlv_data , new_data , size ) ; kfree ( ue -> tlv_data ) ; ue -> tlv_data = new_data ; ue -> tlv_data_size = size ; } else { if ( ! ue -> tlv_data_size || ! ue -> tlv_data ) return - ENXIO ; if ( size < ue -> tlv_data_size ) return - ENOSPC ; if ( copy_to_user ( tlv , ue -> tlv_data , ue -> tlv_data_size ) ) return - EFAULT ; } return change ; } "," new_data ) ; mutex_lock ( & ue -> card -> user_ctl_lock ) ; = size ; mutex_unlock ( & ue -> card -> user_ctl_lock ) ; } else { int ret = 0 ; mutex_lock ( & ue -> card -> user_ctl_lock ) ; -> tlv_data ) { ret = - ENXIO ; - ENXIO ; goto err_unlock ; } -> tlv_data_size ) { ret = - ENOSPC ; - ENOSPC ; goto err_unlock ; } tlv_data_size ) ) ret = - EFAULT ; - EFAULT ; err_unlock : mutex_unlock ( & ue -> card -> user_ctl_lock ) ; if ( ret ) return ret ; ",torvalds@linux/07f4d9d74a04aa7c72c5dae0ef97565f28f17b92,CVE-2014-4652,https://github.com/torvalds/linux/commit/07f4d9d74a04aa7c72c5dae0ef97565f28f17b92,2014-07-03T04:22Z 1174,CWE-476,"CWE-476 static int dissect_usb_ms_bulk ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * parent_tree , void * data ) { usb_conv_info_t * usb_conv_info ; usb_ms_conv_info_t * usb_ms_conv_info ; proto_tree * tree ; proto_item * ti ; guint32 signature = 0 ; int offset = 0 ; gboolean is_request ; itl_nexus_t * itl ; itlq_nexus_t * itlq ; if ( data == NULL ) return 0 ; usb_conv_info = ( usb_conv_info_t * ) data ; usb_ms_conv_info = ( usb_ms_conv_info_t * ) usb_conv_info -> class_data ; if ( ! usb_ms_conv_info ) { usb_ms_conv_info = wmem_new ( wmem_file_scope ( ) , usb_ms_conv_info_t ) ; usb_ms_conv_info -> itl = wmem_tree_new ( wmem_file_scope ( ) ) ; usb_ms_conv_info -> itlq = wmem_tree_new ( wmem_file_scope ( ) ) ; usb_conv_info -> class_data = usb_ms_conv_info ; } is_request = ( pinfo -> srcport == NO_ENDPOINT ) ; col_set_str ( pinfo -> cinfo , COL_PROTOCOL , ""USBMS"" ) ; col_clear ( pinfo -> cinfo , COL_INFO ) ; ti = proto_tree_add_protocol_format ( parent_tree , proto_usb_ms , tvb , 0 , - 1 , ""USBMassStorage"" ) ; tree = proto_item_add_subtree ( ti , ett_usb_ms ) ; signature = tvb_get_letohl ( tvb , offset ) ; if ( is_request && ( signature == 0x43425355 ) && ( tvb_reported_length ( tvb ) == 31 ) ) { tvbuff_t * cdb_tvb ; int cdbrlen , cdblen ; guint8 lun , flags ; guint32 datalen ; proto_tree_add_item ( tree , hf_usb_ms_dCBWSignature , tvb , offset , 4 , ENC_LITTLE_ENDIAN ) ; offset += 4 ; proto_tree_add_item ( tree , hf_usb_ms_dCBWTag , tvb , offset , 4 , ENC_LITTLE_ENDIAN ) ; offset += 4 ; proto_tree_add_item ( tree , hf_usb_ms_dCBWDataTransferLength , tvb , offset , 4 , ENC_LITTLE_ENDIAN ) ; datalen = tvb_get_letohl ( tvb , offset ) ; offset += 4 ; proto_tree_add_item ( tree , hf_usb_ms_dCBWFlags , tvb , offset , 1 , ENC_LITTLE_ENDIAN ) ; flags = tvb_get_guint8 ( tvb , offset ) ; offset += 1 ; proto_tree_add_item ( tree , hf_usb_ms_dCBWTarget , tvb , offset , 1 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( tree , hf_usb_ms_dCBWLUN , tvb , offset , 1 , ENC_LITTLE_ENDIAN ) ; lun = tvb_get_guint8 ( tvb , offset ) & 0x0f ; offset += 1 ; itl = ( itl_nexus_t * ) wmem_tree_lookup32 ( usb_ms_conv_info -> itl , lun ) ; if ( ! itl ) { itl = wmem_new ( wmem_file_scope ( ) , itl_nexus_t ) ; itl -> cmdset = 0xff ; itl -> conversation = NULL ; wmem_tree_insert32 ( usb_ms_conv_info -> itl , lun , itl ) ; } itlq = ( itlq_nexus_t * ) wmem_tree_lookup32 ( usb_ms_conv_info -> itlq , pinfo -> num ) ; if ( ! itlq ) { itlq = wmem_new ( wmem_file_scope ( ) , itlq_nexus_t ) ; itlq -> lun = lun ; itlq -> scsi_opcode = 0xffff ; itlq -> task_flags = 0 ; if ( datalen ) { if ( flags & 0x80 ) { itlq -> task_flags |= SCSI_DATA_READ ; } else { itlq -> task_flags |= SCSI_DATA_WRITE ; } } itlq -> data_length = datalen ; itlq -> bidir_data_length = 0 ; itlq -> fc_time = pinfo -> abs_ts ; itlq -> first_exchange_frame = pinfo -> num ; itlq -> last_exchange_frame = 0 ; itlq -> flags = 0 ; itlq -> alloc_len = 0 ; itlq -> extra_data = NULL ; wmem_tree_insert32 ( usb_ms_conv_info -> itlq , pinfo -> num , itlq ) ; } proto_tree_add_item ( tree , hf_usb_ms_dCBWCBLength , tvb , offset , 1 , ENC_LITTLE_ENDIAN ) ; cdbrlen = tvb_get_guint8 ( tvb , offset ) & 0x1f ; offset += 1 ; cdblen = cdbrlen ; if ( cdblen > tvb_captured_length_remaining ( tvb , offset ) ) { cdblen = tvb_captured_length_remaining ( tvb , offset ) ; } if ( cdblen ) { cdb_tvb = tvb_new_subset ( tvb , offset , cdblen , cdbrlen ) ; dissect_scsi_cdb ( cdb_tvb , pinfo , parent_tree , SCSI_DEV_UNKNOWN , itlq , itl ) ; } return tvb_captured_length ( tvb ) ; } if ( ( ! is_request ) && ( signature == 0x53425355 ) && ( tvb_reported_length ( tvb ) == 13 ) ) { guint8 status ; proto_tree_add_item ( tree , hf_usb_ms_dCSWSignature , tvb , offset , 4 , ENC_LITTLE_ENDIAN ) ; offset += 4 ; proto_tree_add_item ( tree , hf_usb_ms_dCBWTag , tvb , offset , 4 , ENC_LITTLE_ENDIAN ) ; offset += 4 ; proto_tree_add_item ( tree , hf_usb_ms_dCSWDataResidue , tvb , offset , 4 , ENC_LITTLE_ENDIAN ) ; offset += 4 ; proto_tree_add_item ( tree , hf_usb_ms_dCSWStatus , tvb , offset , 1 , ENC_LITTLE_ENDIAN ) ; status = tvb_get_guint8 ( tvb , offset ) ; itlq = ( itlq_nexus_t * ) wmem_tree_lookup32_le ( usb_ms_conv_info -> itlq , pinfo -> num ) ; if ( ! itlq ) { return tvb_captured_length ( tvb ) ; } itlq -> last_exchange_frame = pinfo -> num ; itl = ( itl_nexus_t * ) wmem_tree_lookup32 ( usb_ms_conv_info -> itl , itlq -> lun ) ; if ( ! itl ) { return tvb_captured_length ( tvb ) ; } if ( ! status ) { dissect_scsi_rsp ( tvb , pinfo , parent_tree , itlq , itl , 0 ) ; } else { dissect_scsi_rsp ( tvb , pinfo , parent_tree , itlq , itl , 0x02 ) ; } return tvb_captured_length ( tvb ) ; } itlq = ( itlq_nexus_t * ) wmem_tree_lookup32_le ( usb_ms_conv_info -> itlq , pinfo -> num ) ; if ( ! itlq ) { return tvb_captured_length ( tvb ) ; } itl = ( itl_nexus_t * ) wmem_tree_lookup32 ( usb_ms_conv_info -> itl , itlq -> lun ) ; if ( ! itl ) { return tvb_captured_length ( tvb ) ; } dissect_scsi_payload ( tvb , pinfo , parent_tree , is_request , itlq , itl , 0 ) ; return tvb_captured_length ( tvb ) ; } "," = usb_ms_conv_info ; usb_conv_info -> class_data_type = USB_CONV_MASS_STORAGE ; } else if ( usb_conv_info -> class_data_type != USB_CONV_MASS_STORAGE ) { return 0 ; ",wireshark@wireshark/2cb5985bf47bdc8bea78d28483ed224abdd33dc6,CVE-2016-5354,https://github.com/wireshark/wireshark/commit/2cb5985bf47bdc8bea78d28483ed224abdd33dc6,2016-08-07T16:59Z 1175,CWE-125,"CWE-125 static const uint32_t * parserep ( netdissect_options * ndo , register const struct sunrpc_msg * rp , register u_int length ) { register const uint32_t * dp ; u_int len ; enum sunrpc_accept_stat astat ; dp = ( ( const uint32_t * ) & rp -> rm_reply ) + 1 ; ND_TCHECK ( dp [ 1 ] ) ; len = EXTRACT_32BITS ( & dp [ 1 ] ) ; if ( len >= length ) return ( NULL ) ; dp += ( len + ( 2 * sizeof ( uint32_t ) + 3 ) ) / sizeof ( uint32_t ) ; ND_TCHECK2 ( dp [ 0 ] , 0 ) ; astat = ( enum sunrpc_accept_stat ) EXTRACT_32BITS ( dp ) ; if ( astat != SUNRPC_SUCCESS ) { ND_PRINT ( ( ndo , ""%s"" , tok2str ( sunrpc_str , ""ar_stat%d"" , astat ) ) ) ; nfserr = 1 ; return ( NULL ) ; } ND_TCHECK2 ( * dp , sizeof ( astat ) ) ; return ( ( const uint32_t * ) ( sizeof ( astat ) + ( ( const char * ) dp ) ) ) ; trunc : return ( 0 ) ; } "," uint32_t ) ; ND_TCHECK ( dp [ [ 0 ] ) ; astat ",the-tcpdump-group@tcpdump/19d25dd8781620cd41bf178a5e2e27fc1cf242d0,CVE-2017-12898,https://github.com/the-tcpdump-group/tcpdump/commit/19d25dd8781620cd41bf178a5e2e27fc1cf242d0,2017-09-14T06:29Z 1176,CWE-119,"CWE-119 static void encode_b ( VP9_COMP * cpi , const TileInfo * const tile , TOKENEXTRA * * tp , int mi_row , int mi_col , int output_enabled , BLOCK_SIZE bsize ) { MACROBLOCK * const x = & cpi -> mb ; if ( bsize < BLOCK_8X8 ) { if ( x -> ab_index > 0 ) return ; } set_offsets ( cpi , tile , mi_row , mi_col , bsize ) ; update_state ( cpi , get_block_context ( x , bsize ) , mi_row , mi_col , bsize , output_enabled ) ; encode_superblock ( cpi , tp , output_enabled , mi_row , mi_col , bsize ) ; if ( output_enabled ) { update_stats ( cpi ) ; ( * tp ) -> token = EOSB_TOKEN ; ( * tp ) ++ ; } } "," * const tile , ThreadData * td , BLOCK_SIZE bsize , PICK_MODE_CONTEXT * ctx x = & td -> mb ; -> mb ; set_offsets ( cpi cpi , tile , x ( cpi , td , ctx , mi_row , encode_superblock ( cpi , td mi_col , bsize , ctx { update_stats ( & cpi -> common , td ) ; ( ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1177,CWE-416,"CWE-416 static void exif_mnote_data_pentax_load ( ExifMnoteData * en , const unsigned char * buf , unsigned int buf_size ) { ExifMnoteDataPentax * n = ( ExifMnoteDataPentax * ) en ; size_t i , tcount , o , datao , base = 0 ; ExifShort c ; if ( ! n || ! buf || ! buf_size ) { exif_log ( en -> log , EXIF_LOG_CODE_CORRUPT_DATA , ""ExifMnoteDataPentax"" , ""ShortMakerNote"" ) ; return ; } datao = 6 + n -> offset ; if ( CHECKOVERFLOW ( datao , buf_size , 8 ) ) { exif_log ( en -> log , EXIF_LOG_CODE_CORRUPT_DATA , ""ExifMnoteDataPentax"" , ""ShortMakerNote"" ) ; return ; } if ( ! memcmp ( buf + datao , ""AOC"" , 4 ) ) { if ( ( buf [ datao + 4 ] == 'I' ) && ( buf [ datao + 5 ] == 'I' ) ) { n -> version = pentaxV3 ; n -> order = EXIF_BYTE_ORDER_INTEL ; } else if ( ( buf [ datao + 4 ] == 'M' ) && ( buf [ datao + 5 ] == 'M' ) ) { n -> version = pentaxV3 ; n -> order = EXIF_BYTE_ORDER_MOTOROLA ; } else { n -> version = pentaxV2 ; } exif_log ( en -> log , EXIF_LOG_CODE_DEBUG , ""ExifMnoteDataPentax"" , ""ParsingPentaxmakernotev%d..."" , ( int ) n -> version ) ; datao += 4 + 2 ; base = MNOTE_PENTAX2_TAG_BASE ; } else if ( ! memcmp ( buf + datao , ""QVC"" , 4 ) ) { exif_log ( en -> log , EXIF_LOG_CODE_DEBUG , ""ExifMnoteDataPentax"" , ""ParsingCasiomakernotev2..."" ) ; n -> version = casioV2 ; base = MNOTE_CASIO2_TAG_BASE ; datao += 4 + 2 ; } else { exif_log ( en -> log , EXIF_LOG_CODE_DEBUG , ""ExifMnoteDataPentax"" , ""ParsingPentaxmakernotev1..."" ) ; n -> version = pentaxV1 ; } c = exif_get_short ( buf + datao , n -> order ) ; datao += 2 ; exif_mnote_data_pentax_clear ( n ) ; n -> entries = exif_mem_alloc ( en -> mem , sizeof ( MnotePentaxEntry ) * c ) ; if ( ! n -> entries ) { EXIF_LOG_NO_MEMORY ( en -> log , ""ExifMnoteDataPentax"" , sizeof ( MnotePentaxEntry ) * 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 , ""ExifMnoteDataPentax"" , ""ShortMakerNote"" ) ; break ; } n -> entries [ tcount ] . tag = exif_get_short ( buf + o + 0 , n -> order ) + base ; 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 , ""ExifMnotePentax"" , ""Loadingentry0x%x(\'%s\')..."" , n -> entries [ tcount ] . tag , mnote_pentax_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 , ""ExifMnoteDataPentax"" , ""Tagsizeoverflowdetected(%u*%lu)"" , exif_format_get_size ( n -> entries [ tcount ] . format ) , n -> entries [ tcount ] . components ) ; break ; } 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 ; if ( CHECKOVERFLOW ( dataofs , buf_size , s ) ) { exif_log ( en -> log , EXIF_LOG_CODE_DEBUG , ""ExifMnoteDataPentax"" , ""Tagdatapastend"" ""ofbuffer(%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 , ""ExifMnoteDataPentax"" , s ) ; continue ; } memcpy ( n -> entries [ tcount ] . data , buf + dataofs , s ) ; } ++ tcount ; } n -> count = tcount ; } "," size_t s ; memset ( & n -> entries [ tcount ] , 0 , sizeof ( MnotePentaxEntry ) ) ; ",libexif@libexif/ec412aa4583ad71ecabb967d3c77162760169d1f,CVE-2020-13113,https://github.com/libexif/libexif/commit/ec412aa4583ad71ecabb967d3c77162760169d1f,2020-05-21T17:15Z 1178,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 1179,CWE-400,"CWE-400 static void exif_data_load_data_content ( ExifData * data , ExifIfd ifd , const unsigned char * d , unsigned int ds , unsigned int offset , unsigned int recursion_depth ) { ExifLong o , thumbnail_offset = 0 , thumbnail_length = 0 ; ExifShort n ; ExifEntry * entry ; unsigned int i ; ExifTag tag ; if ( ! data || ! data -> priv ) return ; if ( ( ( ( int ) ifd ) < 0 ) || ( ( ( int ) ifd ) >= EXIF_IFD_COUNT ) ) return ; if ( recursion_depth > 12 ) { exif_log ( data -> priv -> log , EXIF_LOG_CODE_CORRUPT_DATA , ""ExifData"" , ""Deeprecursiondetected!"" ) ; return ; } if ( ( offset + 2 < offset ) || ( offset + 2 < 2 ) || ( offset + 2 > ds ) ) { exif_log ( data -> priv -> log , EXIF_LOG_CODE_CORRUPT_DATA , ""ExifData"" , ""Tagdatapastendofbuffer(%u>%u)"" , offset + 2 , ds ) ; return ; } n = exif_get_short ( d + offset , data -> priv -> order ) ; exif_log ( data -> priv -> log , EXIF_LOG_CODE_DEBUG , ""ExifData"" , ""Loading%huentries..."" , n ) ; offset += 2 ; if ( offset + 12 * n > ds ) { n = ( ds - offset ) / 12 ; exif_log ( data -> priv -> log , EXIF_LOG_CODE_DEBUG , ""ExifData"" , ""Shortdata;onlyloading%huentries..."" , n ) ; } for ( i = 0 ; i < n ; i ++ ) { tag = exif_get_short ( d + offset + 12 * i , data -> priv -> order ) ; switch ( tag ) { case EXIF_TAG_EXIF_IFD_POINTER : case EXIF_TAG_GPS_INFO_IFD_POINTER : case EXIF_TAG_INTEROPERABILITY_IFD_POINTER : case EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH : case EXIF_TAG_JPEG_INTERCHANGE_FORMAT : o = exif_get_long ( d + offset + 12 * i + 8 , data -> priv -> order ) ; exif_log ( data -> priv -> log , EXIF_LOG_CODE_DEBUG , ""ExifData"" , ""Sub-IFDentry0x%x(\'%s\')at%u."" , tag , exif_tag_get_name ( tag ) , o ) ; switch ( tag ) { case EXIF_TAG_EXIF_IFD_POINTER : CHECK_REC ( EXIF_IFD_EXIF ) ; exif_data_load_data_content ( data , EXIF_IFD_EXIF , d , ds , o , recursion_depth + 1 ) ; break ; case EXIF_TAG_GPS_INFO_IFD_POINTER : CHECK_REC ( EXIF_IFD_GPS ) ; exif_data_load_data_content ( data , EXIF_IFD_GPS , d , ds , o , recursion_depth + 1 ) ; break ; case EXIF_TAG_INTEROPERABILITY_IFD_POINTER : CHECK_REC ( EXIF_IFD_INTEROPERABILITY ) ; exif_data_load_data_content ( data , EXIF_IFD_INTEROPERABILITY , d , ds , o , recursion_depth + 1 ) ; break ; case EXIF_TAG_JPEG_INTERCHANGE_FORMAT : thumbnail_offset = o ; if ( thumbnail_offset && thumbnail_length ) exif_data_load_data_thumbnail ( data , d , ds , thumbnail_offset , thumbnail_length ) ; break ; case EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH : thumbnail_length = o ; if ( thumbnail_offset && thumbnail_length ) exif_data_load_data_thumbnail ( data , d , ds , thumbnail_offset , thumbnail_length ) ; break ; default : return ; } break ; default : if ( ! exif_tag_get_name_in_ifd ( tag , ifd ) ) { if ( ! memcmp ( d + offset + 12 * i , ""\\0\\0\\0\\0"" , 4 ) ) { exif_log ( data -> priv -> log , EXIF_LOG_CODE_DEBUG , ""ExifData"" , ""Skippingemptyentryatposition%uin\'%s\'."" , i , exif_ifd_get_name ( ifd ) ) ; break ; } exif_log ( data -> priv -> log , EXIF_LOG_CODE_DEBUG , ""ExifData"" , ""Unknowntag0x%04x(entry%uin\'%s\').Pleasereportthistag"" ""to."" , tag , i , exif_ifd_get_name ( ifd ) ) ; if ( data -> priv -> options & EXIF_DATA_OPTION_IGNORE_UNKNOWN_TAGS ) break ; } entry = exif_entry_new_mem ( data -> priv -> mem ) ; if ( ! entry ) { exif_log ( data -> priv -> log , EXIF_LOG_CODE_NO_MEMORY , ""ExifData"" , ""Couldnotallocatememory"" ) ; return ; } if ( exif_data_load_data_entry ( data , entry , d , ds , offset + 12 * i ) ) exif_content_add_entry ( data -> ifd [ ifd ] , entry ) ; exif_entry_unref ( entry ) ; break ; } } } "," , unsigned int recursion_cost ) { ExifLong ; if ( recursion_cost > 170 ) { exif_log , ""ExifData"" , ""Deep/expensiverecursiondetected!"" ) ; return , o , recursion_cost + level_cost ( n ) ) ; break , o , recursion_cost + level_cost ( n ) ) ; break , o , recursion_cost + level_cost ( n ) ) ; break ",libexif@libexif/6aa11df549114ebda520dde4cdaea2f9357b2c89,CVE-2018-20030,https://github.com/libexif/libexif/commit/6aa11df549114ebda520dde4cdaea2f9357b2c89,2019-02-20T17:29Z 1180,CWE-190,"CWE-190 static int mem_write ( jas_stream_obj_t * obj , char * buf , int cnt ) { int n ; int ret ; jas_stream_memobj_t * m = ( jas_stream_memobj_t * ) obj ; long newbufsize ; long newpos ; assert ( buf ) ; assert ( cnt >= 0 ) ; JAS_DBGLOG ( 100 , ( ""mem_write(%p,%p,%d)\\n"" , obj , buf , cnt ) ) ; newpos = m -> pos_ + cnt ; if ( newpos > m -> bufsize_ && m -> growable_ ) { newbufsize = m -> bufsize_ ; while ( newbufsize < newpos ) { newbufsize <<= 1 ; assert ( newbufsize >= 0 ) ; } JAS_DBGLOG ( 100 , ( ""mem_writeresizingfrom%dto%z\\n"" , m -> bufsize_ , newbufsize ) ) ; JAS_DBGLOG ( 100 , ( ""mem_writeresizingfrom%dto%ul\\n"" , m -> bufsize_ , JAS_CAST ( unsigned long , newbufsize ) ) ) ; if ( mem_resize ( m , newbufsize ) ) { return - 1 ; } } if ( m -> pos_ > m -> len_ ) { n = JAS_MIN ( m -> pos_ , m -> bufsize_ ) - m -> len_ ; if ( n > 0 ) { memset ( & m -> buf_ [ m -> len_ ] , 0 , n ) ; m -> len_ += n ; } if ( m -> pos_ != m -> len_ ) { return 0 ; } } n = m -> bufsize_ - m -> pos_ ; ret = JAS_MIN ( n , cnt ) ; if ( ret > 0 ) { memcpy ( & m -> buf_ [ m -> pos_ ] , buf , ret ) ; m -> pos_ += ret ; } if ( m -> pos_ > m -> len_ ) { m -> len_ = m -> pos_ ; } assert ( ret == cnt ) ; return ret ; } "," cnt ) { size_t n ; int ) obj ; size_t newbufsize ; size_t newpos ; assert newpos ) { if ( ! jas_safe_size_mul ( newbufsize , 2 , & newbufsize ) ) { JAS_DBGLOG ( 100 100 , ( ""newbuffersizewouldcauseoverflow\\n"" ) ) ; return - 1 ; } } JAS_DBGLOG ( 100 , ( ""mem_writeresizingfrom%dto%zu\\n"" , m -> bufsize_ , newbufsize ) ) ; assert ( newbufsize > 0 ) ; if ( mem_resize ( m , newbufsize ) ) { return - 1 ; } } ",mdadams@jasper/634ce8e8a5accc0fa05dd2c20d42b4749d4b2735,CVE-2016-9262,https://github.com/mdadams/jasper/commit/634ce8e8a5accc0fa05dd2c20d42b4749d4b2735,2017-03-23T18:59Z 1181,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 1182,CWE-310,"CWE-310 static noinline int btrfs_mksubvol ( struct path * parent , char * name , int namelen , struct btrfs_root * snap_src , u64 * async_transid , bool readonly , struct btrfs_qgroup_inherit * * inherit ) { struct inode * dir = parent -> dentry -> d_inode ; struct dentry * dentry ; int error ; mutex_lock_nested ( & dir -> i_mutex , I_MUTEX_PARENT ) ; dentry = lookup_one_len ( name , parent -> dentry , namelen ) ; error = PTR_ERR ( dentry ) ; if ( IS_ERR ( dentry ) ) goto out_unlock ; error = - EEXIST ; if ( dentry -> d_inode ) goto out_dput ; error = btrfs_may_create ( dir , dentry ) ; if ( error ) goto out_dput ; down_read ( & BTRFS_I ( dir ) -> root -> fs_info -> subvol_sem ) ; if ( btrfs_root_refs ( & BTRFS_I ( dir ) -> root -> root_item ) == 0 ) goto out_up_read ; if ( snap_src ) { error = create_snapshot ( snap_src , dentry , name , namelen , async_transid , readonly , inherit ) ; } else { error = create_subvol ( BTRFS_I ( dir ) -> root , dentry , name , namelen , async_transid , inherit ) ; } if ( ! error ) fsnotify_mkdir ( dir , dentry ) ; out_up_read : up_read ( & BTRFS_I ( dir ) -> root -> fs_info -> subvol_sem ) ; out_dput : dput ( dentry ) ; out_unlock : mutex_unlock ( & dir -> i_mutex ) ; return error ; } "," goto out_dput ; error = btrfs_check_dir_item_collision ( BTRFS_I ( dir ) -> root , dir -> i_ino , name , namelen ) ; if ( error ) goto out_dput ; ",torvalds@linux/9c52057c698fb96f8f07e7a4bcf4801a092bda89,CVE-2012-5375,https://github.com/torvalds/linux/commit/9c52057c698fb96f8f07e7a4bcf4801a092bda89,2013-02-18T11:56Z 1183,CWE-119,"CWE-119 static int decompress_i ( AVCodecContext * avctx , uint32_t * dst , int linesize ) { SCPRContext * s = avctx -> priv_data ; GetByteContext * gb = & s -> gb ; int cx = 0 , cx1 = 0 , k = 0 , clr = 0 ; int run , r , g , b , off , y = 0 , x = 0 , z , ret ; unsigned backstep = linesize - avctx -> width ; const int cxshift = s -> cxshift ; unsigned lx , ly , ptype ; reinit_tables ( s ) ; bytestream2_skip ( gb , 2 ) ; init_rangecoder ( & s -> rc , gb ) ; while ( k < avctx -> width + 1 ) { ret = decode_unit ( s , & s -> pixel_model [ 0 ] [ cx + cx1 ] , 400 , & r ) ; if ( ret < 0 ) return ret ; cx1 = ( cx << 6 ) & 0xFC0 ; cx = r >> cxshift ; ret = decode_unit ( s , & s -> pixel_model [ 1 ] [ cx + cx1 ] , 400 , & g ) ; if ( ret < 0 ) return ret ; cx1 = ( cx << 6 ) & 0xFC0 ; cx = g >> cxshift ; ret = decode_unit ( s , & s -> pixel_model [ 2 ] [ cx + cx1 ] , 400 , & b ) ; if ( ret < 0 ) return ret ; cx1 = ( cx << 6 ) & 0xFC0 ; cx = b >> cxshift ; ret = decode_value ( s , s -> run_model [ 0 ] , 256 , 400 , & run ) ; if ( ret < 0 ) return ret ; clr = ( b << 16 ) + ( g << 8 ) + r ; k += run ; while ( run -- > 0 ) { dst [ y * linesize + x ] = clr ; lx = x ; ly = y ; x ++ ; if ( x >= avctx -> width ) { x = 0 ; y ++ ; } } } off = - linesize - 1 ; ptype = 0 ; while ( x < avctx -> width && y < avctx -> height ) { ret = decode_value ( s , s -> op_model [ ptype ] , 6 , 1000 , & ptype ) ; if ( ret < 0 ) return ret ; if ( ptype == 0 ) { ret = decode_unit ( s , & s -> pixel_model [ 0 ] [ cx + cx1 ] , 400 , & r ) ; if ( ret < 0 ) return ret ; cx1 = ( cx << 6 ) & 0xFC0 ; cx = r >> cxshift ; ret = decode_unit ( s , & s -> pixel_model [ 1 ] [ cx + cx1 ] , 400 , & g ) ; if ( ret < 0 ) return ret ; cx1 = ( cx << 6 ) & 0xFC0 ; cx = g >> cxshift ; ret = decode_unit ( s , & s -> pixel_model [ 2 ] [ cx + cx1 ] , 400 , & b ) ; if ( ret < 0 ) return ret ; clr = ( b << 16 ) + ( g << 8 ) + r ; } if ( ptype > 5 ) return AVERROR_INVALIDDATA ; ret = decode_value ( s , s -> run_model [ ptype ] , 256 , 400 , & run ) ; if ( ret < 0 ) return ret ; switch ( ptype ) { case 0 : while ( run -- > 0 ) { if ( y >= avctx -> height ) return AVERROR_INVALIDDATA ; dst [ y * linesize + x ] = clr ; lx = x ; ly = y ; x ++ ; if ( x >= avctx -> width ) { x = 0 ; y ++ ; } } break ; case 1 : while ( run -- > 0 ) { if ( y >= avctx -> height ) return AVERROR_INVALIDDATA ; dst [ y * linesize + x ] = dst [ ly * linesize + lx ] ; lx = x ; ly = y ; x ++ ; if ( x >= avctx -> width ) { x = 0 ; y ++ ; } } clr = dst [ ly * linesize + lx ] ; break ; case 2 : while ( run -- > 0 ) { if ( y < 1 || y >= avctx -> height ) return AVERROR_INVALIDDATA ; clr = dst [ y * linesize + x + off + 1 ] ; dst [ y * linesize + x ] = clr ; lx = x ; ly = y ; x ++ ; if ( x >= avctx -> width ) { x = 0 ; y ++ ; } } break ; case 4 : while ( run -- > 0 ) { uint8_t * odst = ( uint8_t * ) dst ; if ( y < 1 || y >= avctx -> height || ( y == 1 && x == 0 ) ) return AVERROR_INVALIDDATA ; if ( x == 0 ) { z = backstep ; } else { z = 0 ; } r = odst [ ( ly * linesize + lx ) * 4 ] + odst [ ( ( y * linesize + x ) + off - z ) * 4 + 4 ] - odst [ ( ( y * linesize + x ) + off - z ) * 4 ] ; g = odst [ ( ly * linesize + lx ) * 4 + 1 ] + odst [ ( ( y * linesize + x ) + off - z ) * 4 + 5 ] - odst [ ( ( y * linesize + x ) + off - z ) * 4 + 1 ] ; b = odst [ ( ly * linesize + lx ) * 4 + 2 ] + odst [ ( ( y * linesize + x ) + off - z ) * 4 + 6 ] - odst [ ( ( y * linesize + x ) + off - z ) * 4 + 2 ] ; clr = ( ( b & 0xFF ) << 16 ) + ( ( g & 0xFF ) << 8 ) + ( r & 0xFF ) ; dst [ y * linesize + x ] = clr ; lx = x ; ly = y ; x ++ ; if ( x >= avctx -> width ) { x = 0 ; y ++ ; } } break ; case 5 : while ( run -- > 0 ) { if ( y < 1 || y >= avctx -> height || ( y == 1 && x == 0 ) ) return AVERROR_INVALIDDATA ; if ( x == 0 ) { z = backstep ; } else { z = 0 ; } clr = dst [ y * linesize + x + off - z ] ; dst [ y * linesize + x ] = clr ; lx = x ; ly = y ; x ++ ; if ( x >= avctx -> width ) { x = 0 ; y ++ ; } } break ; } if ( avctx -> bits_per_coded_sample == 16 ) { cx1 = ( clr & 0x3F00 ) >> 2 ; cx = ( clr & 0xFFFFFF ) >> 16 ; } else { cx1 = ( clr & 0xFC00 ) >> 4 ; cx = ( clr & 0xFFFFFF ) >> 18 ; } } return 0 ; } "," 0 ) { if ( y >= avctx -> height ) return AVERROR_INVALIDDATA ; ",FFmpeg@FFmpeg/7ac5067146613997bb38442cb022d7f41321a706,CVE-2017-9995,https://github.com/FFmpeg/FFmpeg/commit/7ac5067146613997bb38442cb022d7f41321a706,2017-06-28T06:29Z 1184,CWE-295,"CWE-295 int bind_ports ( void ) { SERVICE_OPTIONS * opt ; int listening_section ; # ifdef USE_LIBWRAP libwrap_init ( ) ; # endif s_poll_init ( fds , 1 ) ; for ( opt = service_options . next ; opt ; opt = opt -> next ) { unsigned i ; for ( i = 0 ; i < opt -> local_addr . num ; ++ i ) opt -> local_fd [ i ] = INVALID_SOCKET ; } listening_section = 0 ; for ( opt = service_options . next ; opt ; opt = opt -> next ) { opt -> bound_ports = 0 ; if ( opt -> local_addr . num ) { unsigned i ; s_log ( LOG_DEBUG , ""Bindingservice[%s]"" , opt -> servname ) ; for ( i = 0 ; i < opt -> local_addr . num ; ++ i ) { SOCKET fd ; fd = bind_port ( opt , listening_section , i ) ; opt -> local_fd [ i ] = fd ; if ( fd != INVALID_SOCKET ) { s_poll_add ( fds , fd , 1 , 0 ) ; ++ opt -> bound_ports ; } } if ( ! opt -> bound_ports ) { s_log ( LOG_ERR , ""Bindingservice[%s]failed"" , opt -> servname ) ; return 1 ; } ++ listening_section ; } else if ( opt -> exec_name && opt -> connect_addr . names ) { s_log ( LOG_DEBUG , ""Skippedexec+connectservice[%s]"" , opt -> servname ) ; # ifndef OPENSSL_NO_TLSEXT } else if ( ! opt -> option . client && opt -> sni ) { s_log ( LOG_DEBUG , ""SkippedSNIslaveservice[%s]"" , opt -> servname ) ; # endif } else { s_log ( LOG_ERR , ""Invalidservice[%s]"" , opt -> servname ) ; return 1 ; } } if ( listening_section < systemd_fds ) { s_log ( LOG_ERR , ""Toomanylisteningfiledescriptorsreceivedfromsystemd,got%d"" , systemd_fds ) ; return 1 ; } return 0 ; } "," NOEXPORT ",mtrojnar@stunnel/ebad9ddc4efb2635f37174c9d800d06206f1edf9,CVE-2021-20230,https://github.com/mtrojnar/stunnel/commit/ebad9ddc4efb2635f37174c9d800d06206f1edf9,2021-02-23T17:15Z 1185,CWE-787,"CWE-787 void sec_decrypt ( uint8 * data , int length ) { if ( g_sec_decrypt_use_count == 4096 ) { sec_update ( g_sec_decrypt_key , g_sec_decrypt_update_key ) ; rdssl_rc4_set_key ( & g_rc4_decrypt_key , g_sec_decrypt_key , g_rc4_key_len ) ; g_sec_decrypt_use_count = 0 ; } rdssl_rc4_crypt ( & g_rc4_decrypt_key , data , data , length ) ; g_sec_decrypt_use_count ++ ; } "," length ) { if ( length <= 0 ) return ; ",rdesktop@rdesktop/4dca546d04321a610c1835010b5dad85163b65e1,CVE-2018-8800,https://github.com/rdesktop/rdesktop/commit/4dca546d04321a610c1835010b5dad85163b65e1,2019-02-05T20:29Z 1186,CWE-190,"CWE-190 bool copyaudiodata ( AFfilehandle infile , AFfilehandle outfile , int trackid ) { int frameSize = afGetVirtualFrameSize ( infile , trackid , 1 ) ; const int kBufferFrameCount = 65536 ; void * buffer = malloc ( kBufferFrameCount * frameSize ) ; AFframecount totalFrames = afGetFrameCount ( infile , AF_DEFAULT_TRACK ) ; AFframecount totalFramesWritten = 0 ; bool success = true ; while ( totalFramesWritten < totalFrames ) { AFframecount framesToRead = totalFrames - totalFramesWritten ; if ( framesToRead > kBufferFrameCount ) framesToRead = kBufferFrameCount ; AFframecount framesRead = afReadFrames ( infile , trackid , buffer , framesToRead ) ; if ( framesRead < framesToRead ) { fprintf ( stderr , ""Badreadofaudiotrackdata.\\n"" ) ; success = false ; break ; } AFframecount framesWritten = afWriteFrames ( outfile , trackid , buffer , framesRead ) ; if ( framesWritten < framesRead ) { fprintf ( stderr , ""Badwriteofaudiotrackdata.\\n"" ) ; success = false ; break ; } totalFramesWritten += framesWritten ; } free ( buffer ) ; return success ; } "," 1 ) ; int kBufferFrameCount = kBufferFrameCount = 65536 ; int bufferSize ; while ( multiplyCheckOverflow ( kBufferFrameCount , frameSize , & bufferSize ) ) kBufferFrameCount /= 2 = malloc ( bufferSize ) ; AFframecount ",antlarr@audiofile/7d65f89defb092b63bcbc5d98349fb222ca73b3c,CVE-2017-6838,https://github.com/antlarr/audiofile/commit/7d65f89defb092b63bcbc5d98349fb222ca73b3c,2017-03-20T16:59Z 1187,CWE-119,"CWE-119 void vpx_scale_frame ( YV12_BUFFER_CONFIG * src , YV12_BUFFER_CONFIG * dst , unsigned char * temp_area , unsigned char temp_height , unsigned int hscale , unsigned int hratio , unsigned int vscale , unsigned int vratio , unsigned int interlaced ) { int i ; int dw = ( hscale - 1 + src -> y_width * hratio ) / hscale ; int dh = ( vscale - 1 + src -> y_height * vratio ) / vscale ; Scale2D ( ( unsigned char * ) src -> y_buffer , src -> y_stride , src -> y_width , src -> y_height , ( unsigned char * ) dst -> y_buffer , dst -> y_stride , dw , dh , temp_area , temp_height , hscale , hratio , vscale , vratio , interlaced ) ; if ( dw < ( int ) dst -> y_width ) for ( i = 0 ; i < dh ; i ++ ) vpx_memset ( dst -> y_buffer + i * dst -> y_stride + dw - 1 , dst -> y_buffer [ i * dst -> y_stride + dw - 2 ] , dst -> y_width - dw + 1 ) ; if ( dh < ( int ) dst -> y_height ) for ( i = dh - 1 ; i < ( int ) dst -> y_height ; i ++ ) vpx_memcpy ( dst -> y_buffer + i * dst -> y_stride , dst -> y_buffer + ( dh - 2 ) * dst -> y_stride , dst -> y_width + 1 ) ; Scale2D ( ( unsigned char * ) src -> u_buffer , src -> uv_stride , src -> uv_width , src -> uv_height , ( unsigned char * ) dst -> u_buffer , dst -> uv_stride , dw / 2 , dh / 2 , temp_area , temp_height , hscale , hratio , vscale , vratio , interlaced ) ; if ( dw / 2 < ( int ) dst -> uv_width ) for ( i = 0 ; i < dst -> uv_height ; i ++ ) vpx_memset ( dst -> u_buffer + i * dst -> uv_stride + dw / 2 - 1 , dst -> u_buffer [ i * dst -> uv_stride + dw / 2 - 2 ] , dst -> uv_width - dw / 2 + 1 ) ; if ( dh / 2 < ( int ) dst -> uv_height ) for ( i = dh / 2 - 1 ; i < ( int ) dst -> y_height / 2 ; i ++ ) vpx_memcpy ( dst -> u_buffer + i * dst -> uv_stride , dst -> u_buffer + ( dh / 2 - 2 ) * dst -> uv_stride , dst -> uv_width ) ; Scale2D ( ( unsigned char * ) src -> v_buffer , src -> uv_stride , src -> uv_width , src -> uv_height , ( unsigned char * ) dst -> v_buffer , dst -> uv_stride , dw / 2 , dh / 2 , temp_area , temp_height , hscale , hratio , vscale , vratio , interlaced ) ; if ( dw / 2 < ( int ) dst -> uv_width ) for ( i = 0 ; i < dst -> uv_height ; i ++ ) vpx_memset ( dst -> v_buffer + i * dst -> uv_stride + dw / 2 - 1 , dst -> v_buffer [ i * dst -> uv_stride + dw / 2 - 2 ] , dst -> uv_width - dw / 2 + 1 ) ; if ( dh / 2 < ( int ) dst -> uv_height ) for ( i = dh / 2 - 1 ; i < ( int ) dst -> y_height / 2 ; i ++ ) vpx_memcpy ( dst -> v_buffer + i * dst -> uv_stride , dst -> v_buffer + ( dh / 2 - 2 ) * dst -> uv_stride , dst -> uv_width ) ; } "," i ++ ) memset ( dst -> i ++ ) memcpy ( dst -> i ++ ) memset ( dst -> i ++ ) memcpy ( dst -> i ++ ) memset ( dst -> i ++ ) memcpy ( dst -> ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1188,CWE-284,"CWE-284 int vfs_open ( const struct path * path , struct file * file , const struct cred * cred ) { struct dentry * dentry = path -> dentry ; struct inode * inode = dentry -> d_inode ; file -> f_path = * path ; if ( dentry -> d_flags & DCACHE_OP_SELECT_INODE ) { inode = dentry -> d_op -> d_select_inode ( dentry , file -> f_flags ) ; if ( IS_ERR ( inode ) ) return PTR_ERR ( inode ) ; } return do_dentry_open ( file , inode , NULL , cred ) ; } "," ) { struct inode * inode * inode = vfs_select_inode ( path -> dentry , file inode ) ; file -> f_path = * path ; return do_dentry_open ( ",torvalds@linux/54d5ca871e72f2bb172ec9323497f01cd5091ec7,CVE-2016-6198,https://github.com/torvalds/linux/commit/54d5ca871e72f2bb172ec9323497f01cd5091ec7,2016-08-06T20:59Z 1189,CWE-119,"CWE-119 static inline bool unconditional ( const struct ip6t_ip6 * ipv6 ) { static const struct ip6t_ip6 uncond ; return memcmp ( ipv6 , & uncond , sizeof ( uncond ) ) == 0 ; } "," ( const struct ip6t_entry * e ) { static uncond ; return e -> target_offset == sizeof ( struct ip6t_entry ) && memcmp ( & e -> ipv6 , & ",torvalds@linux/54d83fc74aa9ec72794373cb47432c5f7fb1a309,CVE-2016-3134,https://github.com/torvalds/linux/commit/54d83fc74aa9ec72794373cb47432c5f7fb1a309,2016-04-27T17:59Z 1190,CWE-401,"CWE-401 int htc_connect_service ( struct htc_target * target , struct htc_service_connreq * service_connreq , enum htc_endpoint_id * conn_rsp_epid ) { struct sk_buff * skb ; struct htc_endpoint * endpoint ; struct htc_conn_svc_msg * conn_msg ; int ret ; unsigned long time_left ; endpoint = get_next_avail_ep ( target -> endpoint ) ; if ( ! endpoint ) { dev_err ( target -> dev , ""Endpointisnotavailableforservice%d\\n"" , service_connreq -> service_id ) ; return - EINVAL ; } endpoint -> service_id = service_connreq -> service_id ; endpoint -> max_txqdepth = service_connreq -> max_send_qdepth ; endpoint -> ul_pipeid = service_to_ulpipe ( service_connreq -> service_id ) ; endpoint -> dl_pipeid = service_to_dlpipe ( service_connreq -> service_id ) ; endpoint -> ep_callbacks = service_connreq -> ep_callbacks ; skb = alloc_skb ( sizeof ( struct htc_conn_svc_msg ) + sizeof ( struct htc_frame_hdr ) , GFP_ATOMIC ) ; if ( ! skb ) { dev_err ( target -> dev , ""Failedtoallocatebuftosend"" ""serviceconnectreq\\n"" ) ; return - ENOMEM ; } skb_reserve ( skb , sizeof ( struct htc_frame_hdr ) ) ; conn_msg = skb_put ( skb , sizeof ( struct htc_conn_svc_msg ) ) ; conn_msg -> service_id = cpu_to_be16 ( service_connreq -> service_id ) ; conn_msg -> msg_id = cpu_to_be16 ( HTC_MSG_CONNECT_SERVICE_ID ) ; conn_msg -> con_flags = cpu_to_be16 ( service_connreq -> con_flags ) ; conn_msg -> dl_pipeid = endpoint -> dl_pipeid ; conn_msg -> ul_pipeid = endpoint -> ul_pipeid ; ret = htc_issue_send ( target , skb , skb -> len , 0 , ENDPOINT0 ) ; if ( ret ) goto err ; time_left = wait_for_completion_timeout ( & target -> cmd_wait , HZ ) ; if ( ! time_left ) { dev_err ( target -> dev , ""Serviceconnectiontimeoutfor:%d\\n"" , service_connreq -> service_id ) ; return - ETIMEDOUT ; } * conn_rsp_epid = target -> conn_rsp_epid ; return 0 ; err : kfree_skb ( skb ) ; return ret ; } "," service_id ) ; kfree_skb ( skb ) ; ",torvalds@linux/853acf7caf10b828102d92d05b5c101666a6142b,CVE-2019-19073,https://github.com/torvalds/linux/commit/853acf7caf10b828102d92d05b5c101666a6142b,2019-11-18T06:15Z 1191,CWE-119,"CWE-119 static int set_register ( pegasus_t * pegasus , __u16 indx , __u8 data ) { int ret ; ret = usb_control_msg ( pegasus -> usb , usb_sndctrlpipe ( pegasus -> usb , 0 ) , PEGASUS_REQ_SET_REG , PEGASUS_REQT_WRITE , data , indx , & data , 1 , 1000 ) ; if ( ret < 0 ) netif_dbg ( pegasus , drv , pegasus -> net , ""%sreturned%d\\n"" , __func__ , ret ) ; return ret ; } "," data ) { u8 * buf ; int ret ; buf = kmemdup ( & data , 1 , GFP_NOIO ) ; if ( ! buf ) return - ENOMEM ; ret = , indx , buf , 1 , ret ) ; kfree ( buf ) ; ",torvalds@linux/5593523f968bc86d42a035c6df47d5e0979b5ace,CVE-2017-8068,https://github.com/torvalds/linux/commit/5593523f968bc86d42a035c6df47d5e0979b5ace,2017-04-23T05:59Z 1192,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 1193,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 1194,CWE-125,"CWE-125 void cisco_autorp_print ( netdissect_options * ndo , register const u_char * bp , register u_int len ) { int type ; int numrps ; int hold ; ND_TCHECK ( bp [ 0 ] ) ; ND_PRINT ( ( ndo , ""auto-rp"" ) ) ; type = bp [ 0 ] ; switch ( type ) { case 0x11 : ND_PRINT ( ( ndo , ""candidate-advert"" ) ) ; break ; case 0x12 : ND_PRINT ( ( ndo , ""mapping"" ) ) ; break ; default : ND_PRINT ( ( ndo , ""type-0x%02x"" , type ) ) ; break ; } ND_TCHECK ( bp [ 1 ] ) ; numrps = bp [ 1 ] ; ND_TCHECK2 ( bp [ 2 ] , 2 ) ; ND_PRINT ( ( ndo , ""Hold"" ) ) ; hold = EXTRACT_16BITS ( & bp [ 2 ] ) ; if ( hold ) unsigned_relts_print ( ndo , EXTRACT_16BITS ( & bp [ 2 ] ) ) ; else ND_PRINT ( ( ndo , ""FOREVER"" ) ) ; bp += 8 ; len -= 8 ; while ( numrps -- ) { int nentries ; char s ; ND_TCHECK2 ( bp [ 0 ] , 4 ) ; ND_PRINT ( ( ndo , ""RP%s"" , ipaddr_string ( ndo , bp ) ) ) ; ND_TCHECK ( bp [ 4 ] ) ; switch ( bp [ 4 ] & 0x3 ) { case 0 : ND_PRINT ( ( ndo , ""PIMv?"" ) ) ; break ; case 1 : ND_PRINT ( ( ndo , ""PIMv1"" ) ) ; break ; case 2 : ND_PRINT ( ( ndo , ""PIMv2"" ) ) ; break ; case 3 : ND_PRINT ( ( ndo , ""PIMv1+2"" ) ) ; break ; } if ( bp [ 4 ] & 0xfc ) ND_PRINT ( ( ndo , ""[rsvd=0x%02x]"" , bp [ 4 ] & 0xfc ) ) ; ND_TCHECK ( bp [ 5 ] ) ; nentries = bp [ 5 ] ; bp += 6 ; len -= 6 ; s = '' ; for ( ; nentries ; nentries -- ) { ND_TCHECK2 ( bp [ 0 ] , 6 ) ; ND_PRINT ( ( ndo , ""%c%s%s/%d"" , s , bp [ 0 ] & 1 ? ""!"" : """" , ipaddr_string ( ndo , & bp [ 2 ] ) , bp [ 1 ] ) ) ; if ( bp [ 0 ] & 0x02 ) { ND_PRINT ( ( ndo , ""bidir"" ) ) ; } if ( bp [ 0 ] & 0xfc ) { ND_PRINT ( ( ndo , ""[rsvd=0x%02x]"" , bp [ 0 ] & 0xfc ) ) ; } s = ',' ; bp += 6 ; len -= 6 ; } } return ; trunc : ND_PRINT ( ( ndo , ""[|autorp]"" ) ) ; return ; } "," int hold ; if ( len < 8 ) goto trunc ; char s ; if ( len < 4 ) goto trunc ; ) ) ; bp += 4 ; len -= 4 ; if ( len < 1 ) goto trunc ; ( bp [ 0 ] ) ; ( bp [ 0 ] & 0x3 ( bp [ 0 ] & 0xfc , bp [ 0 ] & 0xfc ) ) ; bp += 1 ; len -= 1 ; if ( len < 1 ) goto trunc ; ( bp [ 0 ] ) ; = bp [ 0 ] ; bp ; bp += 1 ; len -= 1 ; s = -- ) { if ( len < 6 ) goto trunc ; ",the-tcpdump-group@tcpdump/5dc1860d8267b1e0cb78c9ffa2a40bea2fdb3ddc,CVE-2017-13030,https://github.com/the-tcpdump-group/tcpdump/commit/5dc1860d8267b1e0cb78c9ffa2a40bea2fdb3ddc,2017-09-14T06:29Z 1195,CWE-787,"CWE-787 static int fetch_token ( OnigToken * tok , UChar * * src , UChar * end , ScanEnv * env ) { int r , num ; OnigCodePoint c ; OnigEncoding enc = env -> enc ; OnigSyntaxType * syn = env -> syntax ; UChar * prev ; UChar * p = * src ; PFETCH_READY ; start : if ( PEND ) { tok -> type = TK_EOT ; return tok -> type ; } tok -> type = TK_STRING ; tok -> base = 0 ; tok -> backp = p ; PFETCH ( c ) ; if ( IS_MC_ESC_CODE ( c , syn ) ) { if ( PEND ) return ONIGERR_END_PATTERN_AT_ESCAPE ; tok -> backp = p ; PFETCH ( c ) ; tok -> u . c = c ; tok -> escaped = 1 ; switch ( c ) { case '*' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_ASTERISK_ZERO_INF ) ) break ; tok -> type = TK_OP_REPEAT ; tok -> u . repeat . lower = 0 ; tok -> u . repeat . upper = REPEAT_INFINITE ; goto greedy_check ; break ; case '+' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_PLUS_ONE_INF ) ) break ; tok -> type = TK_OP_REPEAT ; tok -> u . repeat . lower = 1 ; tok -> u . repeat . upper = REPEAT_INFINITE ; goto greedy_check ; break ; case '?' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_QMARK_ZERO_ONE ) ) break ; tok -> type = TK_OP_REPEAT ; tok -> u . repeat . lower = 0 ; tok -> u . repeat . upper = 1 ; greedy_check : if ( ! PEND && PPEEK_IS ( '?' ) && IS_SYNTAX_OP ( syn , ONIG_SYN_OP_QMARK_NON_GREEDY ) ) { PFETCH ( c ) ; tok -> u . repeat . greedy = 0 ; tok -> u . repeat . possessive = 0 ; } else { possessive_check : if ( ! PEND && PPEEK_IS ( '+' ) && ( ( IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_PLUS_POSSESSIVE_REPEAT ) && tok -> type != TK_INTERVAL ) || ( IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_PLUS_POSSESSIVE_INTERVAL ) && tok -> type == TK_INTERVAL ) ) ) { PFETCH ( c ) ; tok -> u . repeat . greedy = 1 ; tok -> u . repeat . possessive = 1 ; } else { tok -> u . repeat . greedy = 1 ; tok -> u . repeat . possessive = 0 ; } } break ; case '{' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_BRACE_INTERVAL ) ) break ; r = fetch_range_quantifier ( & p , end , tok , env ) ; if ( r < 0 ) return r ; if ( r == 0 ) goto greedy_check ; else if ( r == 2 ) { if ( IS_SYNTAX_BV ( syn , ONIG_SYN_FIXED_INTERVAL_IS_GREEDY_ONLY ) ) goto possessive_check ; goto greedy_check ; } break ; case '|' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_VBAR_ALT ) ) break ; tok -> type = TK_ALT ; break ; case '(' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_LPAREN_SUBEXP ) ) break ; tok -> type = TK_SUBEXP_OPEN ; break ; case ')' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_LPAREN_SUBEXP ) ) break ; tok -> type = TK_SUBEXP_CLOSE ; break ; case 'w' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_W_WORD ) ) break ; tok -> type = TK_CHAR_TYPE ; tok -> u . prop . ctype = ONIGENC_CTYPE_WORD ; tok -> u . prop . not = 0 ; break ; case 'W' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_W_WORD ) ) break ; tok -> type = TK_CHAR_TYPE ; tok -> u . prop . ctype = ONIGENC_CTYPE_WORD ; tok -> u . prop . not = 1 ; break ; case 'b' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_B_WORD_BOUND ) ) break ; tok -> type = TK_ANCHOR ; tok -> u . anchor = ANCHOR_WORD_BOUND ; break ; case 'B' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_B_WORD_BOUND ) ) break ; tok -> type = TK_ANCHOR ; tok -> u . anchor = ANCHOR_NOT_WORD_BOUND ; break ; # ifdef USE_WORD_BEGIN_END case '<' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END ) ) break ; tok -> type = TK_ANCHOR ; tok -> u . anchor = ANCHOR_WORD_BEGIN ; break ; case '>' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END ) ) break ; tok -> type = TK_ANCHOR ; tok -> u . anchor = ANCHOR_WORD_END ; break ; # endif case 's' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_S_WHITE_SPACE ) ) break ; tok -> type = TK_CHAR_TYPE ; tok -> u . prop . ctype = ONIGENC_CTYPE_SPACE ; tok -> u . prop . not = 0 ; break ; case 'S' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_S_WHITE_SPACE ) ) break ; tok -> type = TK_CHAR_TYPE ; tok -> u . prop . ctype = ONIGENC_CTYPE_SPACE ; tok -> u . prop . not = 1 ; break ; case 'd' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_D_DIGIT ) ) break ; tok -> type = TK_CHAR_TYPE ; tok -> u . prop . ctype = ONIGENC_CTYPE_DIGIT ; tok -> u . prop . not = 0 ; break ; case 'D' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_D_DIGIT ) ) break ; tok -> type = TK_CHAR_TYPE ; tok -> u . prop . ctype = ONIGENC_CTYPE_DIGIT ; tok -> u . prop . not = 1 ; break ; case 'h' : if ( ! IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_ESC_H_XDIGIT ) ) break ; tok -> type = TK_CHAR_TYPE ; tok -> u . prop . ctype = ONIGENC_CTYPE_XDIGIT ; tok -> u . prop . not = 0 ; break ; case 'H' : if ( ! IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_ESC_H_XDIGIT ) ) break ; tok -> type = TK_CHAR_TYPE ; tok -> u . prop . ctype = ONIGENC_CTYPE_XDIGIT ; tok -> u . prop . not = 1 ; break ; case 'A' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR ) ) break ; begin_buf : tok -> type = TK_ANCHOR ; tok -> u . subtype = ANCHOR_BEGIN_BUF ; break ; case 'Z' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR ) ) break ; tok -> type = TK_ANCHOR ; tok -> u . subtype = ANCHOR_SEMI_END_BUF ; break ; case 'z' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR ) ) break ; end_buf : tok -> type = TK_ANCHOR ; tok -> u . subtype = ANCHOR_END_BUF ; break ; case 'G' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_CAPITAL_G_BEGIN_ANCHOR ) ) break ; tok -> type = TK_ANCHOR ; tok -> u . subtype = ANCHOR_BEGIN_POSITION ; break ; case '`' : if ( ! IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_ESC_GNU_BUF_ANCHOR ) ) break ; goto begin_buf ; break ; case '\\'' : if ( ! IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_ESC_GNU_BUF_ANCHOR ) ) break ; goto end_buf ; break ; case 'x' : if ( PEND ) break ; prev = p ; if ( PPEEK_IS ( '{' ) && IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_X_BRACE_HEX8 ) ) { PINC ; num = scan_unsigned_hexadecimal_number ( & p , end , 8 , enc ) ; if ( num < 0 ) return ONIGERR_TOO_BIG_WIDE_CHAR_VALUE ; if ( ! PEND ) { if ( ONIGENC_IS_CODE_XDIGIT ( enc , PPEEK ) ) return ONIGERR_TOO_LONG_WIDE_CHAR_VALUE ; } if ( ( p > prev + enclen ( enc , prev ) ) && ! PEND && PPEEK_IS ( '}' ) ) { PINC ; tok -> type = TK_CODE_POINT ; tok -> u . code = ( OnigCodePoint ) num ; } else { p = prev ; } } else if ( IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_X_HEX2 ) ) { num = scan_unsigned_hexadecimal_number ( & p , end , 2 , enc ) ; if ( num < 0 ) return ONIGERR_TOO_BIG_NUMBER ; if ( p == prev ) { num = 0 ; } tok -> type = TK_RAW_BYTE ; tok -> base = 16 ; tok -> u . c = num ; } break ; case 'u' : if ( PEND ) break ; prev = p ; if ( IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_ESC_U_HEX4 ) ) { num = scan_unsigned_hexadecimal_number ( & p , end , 4 , enc ) ; if ( num < 0 ) return ONIGERR_TOO_BIG_NUMBER ; if ( p == prev ) { num = 0 ; } tok -> type = TK_CODE_POINT ; tok -> base = 16 ; tok -> u . code = ( OnigCodePoint ) num ; } break ; case '1' : case '2' : case '3' : case '4' : case '5' : case '6' : case '7' : case '8' : case '9' : PUNFETCH ; prev = p ; num = onig_scan_unsigned_number ( & p , end , enc ) ; if ( num < 0 || num > ONIG_MAX_BACKREF_NUM ) { goto skip_backref ; } if ( IS_SYNTAX_OP ( syn , ONIG_SYN_OP_DECIMAL_BACKREF ) && ( num <= env -> num_mem || num <= 9 ) ) { if ( IS_SYNTAX_BV ( syn , ONIG_SYN_STRICT_CHECK_BACKREF ) ) { if ( num > env -> num_mem || IS_NULL ( SCANENV_MEM_NODES ( env ) [ num ] ) ) return ONIGERR_INVALID_BACKREF ; } tok -> type = TK_BACKREF ; tok -> u . backref . num = 1 ; tok -> u . backref . ref1 = num ; tok -> u . backref . by_name = 0 ; # ifdef USE_BACKREF_WITH_LEVEL tok -> u . backref . exist_level = 0 ; # endif break ; } skip_backref : if ( c == '8' || c == '9' ) { p = prev ; PINC ; break ; } p = prev ; case '0' : if ( IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ESC_OCTAL3 ) ) { prev = p ; num = scan_unsigned_octal_number ( & p , end , ( c == '0' ? 2 : 3 ) , enc ) ; if ( num < 0 ) return ONIGERR_TOO_BIG_NUMBER ; if ( p == prev ) { num = 0 ; } tok -> type = TK_RAW_BYTE ; tok -> base = 8 ; tok -> u . c = num ; } else if ( c != '0' ) { PINC ; } break ; # ifdef USE_NAMED_GROUP case 'k' : if ( ! PEND && IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_ESC_K_NAMED_BACKREF ) ) { PFETCH ( c ) ; if ( c == '<' || c == '\\'' ) { UChar * name_end ; int * backs ; int back_num ; prev = p ; # ifdef USE_BACKREF_WITH_LEVEL name_end = NULL_UCHARP ; r = fetch_name_with_level ( ( OnigCodePoint ) c , & p , end , & name_end , env , & back_num , & tok -> u . backref . level ) ; if ( r == 1 ) tok -> u . backref . exist_level = 1 ; else tok -> u . backref . exist_level = 0 ; # else r = fetch_name ( & p , end , & name_end , env , & back_num , 1 ) ; # endif if ( r < 0 ) return r ; if ( back_num != 0 ) { if ( back_num < 0 ) { back_num = BACKREF_REL_TO_ABS ( back_num , env ) ; if ( back_num <= 0 ) return ONIGERR_INVALID_BACKREF ; } if ( IS_SYNTAX_BV ( syn , ONIG_SYN_STRICT_CHECK_BACKREF ) ) { if ( back_num > env -> num_mem || IS_NULL ( SCANENV_MEM_NODES ( env ) [ back_num ] ) ) return ONIGERR_INVALID_BACKREF ; } tok -> type = TK_BACKREF ; tok -> u . backref . by_name = 0 ; tok -> u . backref . num = 1 ; tok -> u . backref . ref1 = back_num ; } else { num = onig_name_to_group_numbers ( env -> reg , prev , name_end , & backs ) ; if ( num <= 0 ) { onig_scan_env_set_error_string ( env , ONIGERR_UNDEFINED_NAME_REFERENCE , prev , name_end ) ; return ONIGERR_UNDEFINED_NAME_REFERENCE ; } if ( IS_SYNTAX_BV ( syn , ONIG_SYN_STRICT_CHECK_BACKREF ) ) { int i ; for ( i = 0 ; i < num ; i ++ ) { if ( backs [ i ] > env -> num_mem || IS_NULL ( SCANENV_MEM_NODES ( env ) [ backs [ i ] ] ) ) return ONIGERR_INVALID_BACKREF ; } } tok -> type = TK_BACKREF ; tok -> u . backref . by_name = 1 ; if ( num == 1 ) { tok -> u . backref . num = 1 ; tok -> u . backref . ref1 = backs [ 0 ] ; } else { tok -> u . backref . num = num ; tok -> u . backref . refs = backs ; } } } else PUNFETCH ; } break ; # endif # ifdef USE_SUBEXP_CALL case 'g' : if ( ! PEND && IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_ESC_G_SUBEXP_CALL ) ) { PFETCH ( c ) ; if ( c == '<' || c == '\\'' ) { int gnum ; UChar * name_end ; prev = p ; r = fetch_name ( ( OnigCodePoint ) c , & p , end , & name_end , env , & gnum , 1 ) ; if ( r < 0 ) return r ; tok -> type = TK_CALL ; tok -> u . call . name = prev ; tok -> u . call . name_end = name_end ; tok -> u . call . gnum = gnum ; } else PUNFETCH ; } break ; # endif case 'Q' : if ( IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_ESC_CAPITAL_Q_QUOTE ) ) { tok -> type = TK_QUOTE_OPEN ; } break ; case 'p' : case 'P' : if ( ! PEND && PPEEK_IS ( '{' ) && IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY ) ) { PINC ; tok -> type = TK_CHAR_PROPERTY ; tok -> u . prop . not = ( c == 'P' ? 1 : 0 ) ; if ( ! PEND && IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT ) ) { PFETCH ( c ) ; if ( c == '^' ) { tok -> u . prop . not = ( tok -> u . prop . not == 0 ? 1 : 0 ) ; } else PUNFETCH ; } } break ; default : { OnigCodePoint c2 ; PUNFETCH ; num = fetch_escaped_value ( & p , end , env , & c2 ) ; if ( num < 0 ) return num ; if ( tok -> u . c != c2 ) { tok -> type = TK_CODE_POINT ; tok -> u . code = c2 ; } else { p = tok -> backp + enclen ( enc , tok -> backp ) ; } } break ; } } else { tok -> u . c = c ; tok -> escaped = 0 ; # ifdef USE_VARIABLE_META_CHARS if ( ( c != ONIG_INEFFECTIVE_META_CHAR ) && IS_SYNTAX_OP ( syn , ONIG_SYN_OP_VARIABLE_META_CHARACTERS ) ) { if ( c == MC_ANYCHAR ( syn ) ) goto any_char ; else if ( c == MC_ANYTIME ( syn ) ) goto anytime ; else if ( c == MC_ZERO_OR_ONE_TIME ( syn ) ) goto zero_or_one_time ; else if ( c == MC_ONE_OR_MORE_TIME ( syn ) ) goto one_or_more_time ; else if ( c == MC_ANYCHAR_ANYTIME ( syn ) ) { tok -> type = TK_ANYCHAR_ANYTIME ; goto out ; } } # endif switch ( c ) { case '.' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_DOT_ANYCHAR ) ) break ; # ifdef USE_VARIABLE_META_CHARS any_char : # endif tok -> type = TK_ANYCHAR ; break ; case '*' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_ASTERISK_ZERO_INF ) ) break ; # ifdef USE_VARIABLE_META_CHARS anytime : # endif tok -> type = TK_OP_REPEAT ; tok -> u . repeat . lower = 0 ; tok -> u . repeat . upper = REPEAT_INFINITE ; goto greedy_check ; break ; case '+' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_PLUS_ONE_INF ) ) break ; # ifdef USE_VARIABLE_META_CHARS one_or_more_time : # endif tok -> type = TK_OP_REPEAT ; tok -> u . repeat . lower = 1 ; tok -> u . repeat . upper = REPEAT_INFINITE ; goto greedy_check ; break ; case '?' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_QMARK_ZERO_ONE ) ) break ; # ifdef USE_VARIABLE_META_CHARS zero_or_one_time : # endif tok -> type = TK_OP_REPEAT ; tok -> u . repeat . lower = 0 ; tok -> u . repeat . upper = 1 ; goto greedy_check ; break ; case '{' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_BRACE_INTERVAL ) ) break ; r = fetch_range_quantifier ( & p , end , tok , env ) ; if ( r < 0 ) return r ; if ( r == 0 ) goto greedy_check ; else if ( r == 2 ) { if ( IS_SYNTAX_BV ( syn , ONIG_SYN_FIXED_INTERVAL_IS_GREEDY_ONLY ) ) goto possessive_check ; goto greedy_check ; } break ; case '|' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_VBAR_ALT ) ) break ; tok -> type = TK_ALT ; break ; case '(' : if ( ! PEND && PPEEK_IS ( '?' ) && IS_SYNTAX_OP2 ( syn , ONIG_SYN_OP2_QMARK_GROUP_EFFECT ) ) { PINC ; if ( ! PEND && PPEEK_IS ( '#' ) ) { PFETCH ( c ) ; while ( 1 ) { if ( PEND ) return ONIGERR_END_PATTERN_IN_GROUP ; PFETCH ( c ) ; if ( c == MC_ESC ( syn ) ) { if ( ! PEND ) PFETCH ( c ) ; } else { if ( c == ')' ) break ; } } goto start ; } PUNFETCH ; } if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_LPAREN_SUBEXP ) ) break ; tok -> type = TK_SUBEXP_OPEN ; break ; case ')' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_LPAREN_SUBEXP ) ) break ; tok -> type = TK_SUBEXP_CLOSE ; break ; case '^' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_LINE_ANCHOR ) ) break ; tok -> type = TK_ANCHOR ; tok -> u . subtype = ( IS_SINGLELINE ( env -> option ) ? ANCHOR_BEGIN_BUF : ANCHOR_BEGIN_LINE ) ; break ; case '$' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_LINE_ANCHOR ) ) break ; tok -> type = TK_ANCHOR ; tok -> u . subtype = ( IS_SINGLELINE ( env -> option ) ? ANCHOR_SEMI_END_BUF : ANCHOR_END_LINE ) ; break ; case '[' : if ( ! IS_SYNTAX_OP ( syn , ONIG_SYN_OP_BRACKET_CC ) ) break ; tok -> type = TK_CC_OPEN ; break ; case ']' : if ( * src > env -> pattern ) CLOSE_BRACKET_WITHOUT_ESC_WARN ( env , ( UChar * ) ""]"" ) ; break ; case '#' : if ( IS_EXTEND ( env -> option ) ) { while ( ! PEND ) { PFETCH ( c ) ; if ( ONIGENC_IS_CODE_NEWLINE ( enc , c ) ) break ; } goto start ; break ; } break ; case '' : case '\\t' : case '\\n' : case '\\r' : case '\\f' : if ( IS_EXTEND ( env -> option ) ) goto start ; break ; default : break ; } } # ifdef USE_VARIABLE_META_CHARS out : # endif * src = p ; return tok -> type ; } "," num < 0 || num >= 256 ",kkos@oniguruma/f015fbdd95f76438cd86366467bb2b39870dd7c6,CVE-2017-9226,https://github.com/kkos/oniguruma/commit/f015fbdd95f76438cd86366467bb2b39870dd7c6,2017-05-24T15:29Z 1196,CWE-264,"CWE-264 static int em_call ( struct x86_emulate_ctxt * ctxt ) { long rel = ctxt -> src . val ; ctxt -> src . val = ( unsigned long ) ctxt -> _eip ; jmp_rel ( ctxt , rel ) ; return em_push ( ctxt ) ; } "," ctxt ) { int rc ; -> _eip ; rc = , rel ) ; if ( rc != X86EMUL_CONTINUE ) return rc ",torvalds@linux/234f3ce485d54017f15cf5e0699cff4100121601,CVE-2014-3647,https://github.com/torvalds/linux/commit/234f3ce485d54017f15cf5e0699cff4100121601,2014-11-10T11:55Z 1197,CWE-000,"CWE-000 static void nfs4_close_prepare ( struct rpc_task * task , void * data ) { struct nfs4_closedata * calldata = data ; struct nfs4_state * state = calldata -> state ; int clear_rd , clear_wr , clear_rdwr ; if ( nfs_wait_on_sequence ( calldata -> arg . seqid , task ) != 0 ) return ; clear_rd = clear_wr = clear_rdwr = 0 ; spin_lock ( & state -> owner -> so_lock ) ; if ( state -> n_rdwr == 0 ) { if ( state -> n_rdonly == 0 ) { clear_rd |= test_and_clear_bit ( NFS_O_RDONLY_STATE , & state -> flags ) ; clear_rdwr |= test_and_clear_bit ( NFS_O_RDWR_STATE , & state -> flags ) ; } if ( state -> n_wronly == 0 ) { clear_wr |= test_and_clear_bit ( NFS_O_WRONLY_STATE , & state -> flags ) ; clear_rdwr |= test_and_clear_bit ( NFS_O_RDWR_STATE , & state -> flags ) ; } } spin_unlock ( & state -> owner -> so_lock ) ; if ( ! clear_rd && ! clear_wr && ! clear_rdwr ) { task -> tk_action = NULL ; return ; } nfs_fattr_init ( calldata -> res . fattr ) ; if ( test_bit ( NFS_O_RDONLY_STATE , & state -> flags ) != 0 ) { task -> tk_msg . rpc_proc = & nfs4_procedures [ NFSPROC4_CLNT_OPEN_DOWNGRADE ] ; calldata -> arg . open_flags = FMODE_READ ; } else if ( test_bit ( NFS_O_WRONLY_STATE , & state -> flags ) != 0 ) { task -> tk_msg . rpc_proc = & nfs4_procedures [ NFSPROC4_CLNT_OPEN_DOWNGRADE ] ; calldata -> arg . open_flags = FMODE_WRITE ; } calldata -> timestamp = jiffies ; rpc_call_start ( task ) ; } "," -> arg . fmode = FMODE_READ ; -> arg . fmode = FMODE_WRITE ; ",torvalds@linux/dc0b027dfadfcb8a5504f7d8052754bf8d501ab9,CVE-2011-4324,https://github.com/torvalds/linux/commit/dc0b027dfadfcb8a5504f7d8052754bf8d501ab9,2012-06-21T23:55Z 1198,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 1199,CWE-190,"CWE-190 static int growVTrans ( sqlite3 * db ) { const int ARRAY_INCR = 5 ; if ( ( db -> nVTrans % ARRAY_INCR ) == 0 ) { VTable * * aVTrans ; int nBytes = sizeof ( sqlite3_vtab * ) * ( db -> nVTrans + ARRAY_INCR ) ; aVTrans = sqlite3DbRealloc ( db , ( void * ) db -> aVTrans , nBytes ) ; if ( ! aVTrans ) { return SQLITE_NOMEM_BKPT ; } memset ( & aVTrans [ db -> nVTrans ] , 0 , sizeof ( sqlite3_vtab * ) * ARRAY_INCR ) ; db -> aVTrans = aVTrans ; } return SQLITE_OK ; } "," * aVTrans ; sqlite3_int64 nBytes = sizeof ) * ( ( sqlite3_int64 ) ",chromium@chromium/517ac71c9ee27f856f9becde8abea7d1604af9d4,CVE-2019-5827,https://github.com/chromium/chromium/commit/517ac71c9ee27f856f9becde8abea7d1604af9d4,2019-06-27T17:15Z 1200,CWE-254,"CWE-254 static void follow_dotdot ( struct nameidata * nd ) { if ( ! nd -> root . mnt ) set_root ( nd ) ; while ( 1 ) { struct dentry * old = nd -> path . dentry ; if ( nd -> path . dentry == nd -> root . dentry && nd -> path . mnt == nd -> root . mnt ) { break ; } if ( nd -> path . dentry != nd -> path . mnt -> mnt_root ) { nd -> path . dentry = dget_parent ( nd -> path . dentry ) ; dput ( old ) ; break ; } if ( ! follow_up ( & nd -> path ) ) break ; } follow_mount ( & nd -> path ) ; nd -> inode = nd -> path . dentry -> d_inode ; } "," static int follow_dotdot ( struct old ) ; if ( unlikely ( ! path_connected ( & nd -> path ) ) ) return - ENOENT ; -> d_inode ; return 0 ; ",torvalds@linux/397d425dc26da728396e66d392d5dcb8dac30c37,CVE-2015-2925,https://github.com/torvalds/linux/commit/397d425dc26da728396e66d392d5dcb8dac30c37,2015-11-16T11:59Z 1201,CWE-416,"CWE-416 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 1202,CWE-400,"CWE-400 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 1203,CWE-125,"CWE-125 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 ( 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 ; } "," } if ( assoc_array_ptr_is_leaf ( ptr ) && ",torvalds@linux/8d4a2ec1e0b41b0cf9a0c5cd4511da7f8e4f3de2,CVE-2016-7914,https://github.com/torvalds/linux/commit/8d4a2ec1e0b41b0cf9a0c5cd4511da7f8e4f3de2,2016-11-16T05:59Z 1204,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 1205,CWE-416,"CWE-416 static void sig_server_setup_fill_chatnet ( IRC_SERVER_CONNECT_REC * conn , IRC_CHATNET_REC * ircnet ) { if ( ! IS_IRC_SERVER_CONNECT ( conn ) ) return ; g_return_if_fail ( IS_IRCNET ( ircnet ) ) ; if ( ircnet -> alternate_nick != NULL ) { g_free_and_null ( conn -> alternate_nick ) ; conn -> alternate_nick = g_strdup ( ircnet -> alternate_nick ) ; } if ( ircnet -> usermode != NULL ) { g_free_and_null ( conn -> usermode ) ; conn -> usermode = g_strdup ( ircnet -> usermode ) ; } if ( ircnet -> max_kicks > 0 ) conn -> max_kicks = ircnet -> max_kicks ; if ( ircnet -> max_msgs > 0 ) conn -> max_msgs = ircnet -> max_msgs ; if ( ircnet -> max_modes > 0 ) conn -> max_modes = ircnet -> max_modes ; if ( ircnet -> max_whois > 0 ) conn -> max_whois = ircnet -> max_whois ; if ( ircnet -> max_cmds_at_once > 0 ) conn -> max_cmds_at_once = ircnet -> max_cmds_at_once ; if ( ircnet -> cmd_queue_speed > 0 ) conn -> cmd_queue_speed = ircnet -> cmd_queue_speed ; if ( ircnet -> max_query_chans > 0 ) conn -> max_query_chans = ircnet -> max_query_chans ; conn -> sasl_mechanism = SASL_MECHANISM_NONE ; conn -> sasl_username = NULL ; conn -> sasl_password = NULL ; if ( ircnet -> sasl_mechanism != NULL ) { if ( ! g_ascii_strcasecmp ( ircnet -> sasl_mechanism , ""plain"" ) ) { conn -> sasl_mechanism = SASL_MECHANISM_PLAIN ; if ( ircnet -> sasl_username != NULL && * ircnet -> sasl_username && ircnet -> sasl_password != NULL && * ircnet -> sasl_password ) { conn -> sasl_username = ircnet -> sasl_username ; conn -> sasl_password = ircnet -> sasl_password ; } else g_warning ( ""Thefieldssasl_usernameandsasl_passwordareeithermissingorempty"" ) ; } else if ( ! g_ascii_strcasecmp ( ircnet -> sasl_mechanism , ""external"" ) ) { conn -> sasl_mechanism = SASL_MECHANISM_EXTERNAL ; } else g_warning ( ""UnsupportedSASLmechanism\\""%s\\""selected"" , ircnet -> sasl_mechanism ) ; } } "," -> sasl_username = g_strdup ( ircnet -> sasl_username ) ; conn -> sasl_password = g_strdup ( ircnet -> sasl_password ) ; } else ",irssi@irssi/d23b0d22cc611e43c88d99192a59f413f951a955,CVE-2019-13045,https://github.com/irssi/irssi/commit/d23b0d22cc611e43c88d99192a59f413f951a955,2019-06-29T14:15Z 1206,CWE-119,"CWE-119 enum ImapAuthRes imap_auth_gss ( struct ImapData * idata , const char * method ) { gss_buffer_desc request_buf , send_token ; gss_buffer_t sec_token ; gss_name_t target_name ; gss_ctx_id_t context ; gss_OID mech_name ; char server_conf_flags ; gss_qop_t quality ; int cflags ; OM_uint32 maj_stat , min_stat ; char buf1 [ GSS_BUFSIZE ] , buf2 [ GSS_BUFSIZE ] ; unsigned long buf_size ; int rc ; if ( ! mutt_bit_isset ( idata -> capabilities , AGSSAPI ) ) return IMAP_AUTH_UNAVAIL ; if ( mutt_account_getuser ( & idata -> conn -> account ) < 0 ) return IMAP_AUTH_FAILURE ; snprintf ( buf1 , sizeof ( buf1 ) , ""imap@%s"" , idata -> conn -> account . host ) ; request_buf . value = buf1 ; request_buf . length = strlen ( buf1 ) ; maj_stat = gss_import_name ( & min_stat , & request_buf , gss_nt_service_name , & target_name ) ; if ( maj_stat != GSS_S_COMPLETE ) { mutt_debug ( 2 , ""Couldn\'tgetservicenamefor[%s]\\n"" , buf1 ) ; return IMAP_AUTH_UNAVAIL ; } else if ( DebugLevel >= 2 ) { gss_display_name ( & min_stat , target_name , & request_buf , & mech_name ) ; mutt_debug ( 2 , ""Usingservicename[%s]\\n"" , ( char * ) request_buf . value ) ; gss_release_buffer ( & min_stat , & request_buf ) ; } sec_token = GSS_C_NO_BUFFER ; context = GSS_C_NO_CONTEXT ; maj_stat = gss_init_sec_context ( & min_stat , GSS_C_NO_CREDENTIAL , & context , target_name , GSS_C_NO_OID , GSS_C_MUTUAL_FLAG | GSS_C_SEQUENCE_FLAG , 0 , GSS_C_NO_CHANNEL_BINDINGS , sec_token , NULL , & send_token , ( unsigned int * ) & cflags , NULL ) ; if ( maj_stat != GSS_S_COMPLETE && maj_stat != GSS_S_CONTINUE_NEEDED ) { print_gss_error ( maj_stat , min_stat ) ; mutt_debug ( 1 , ""Erroracquiringcredentials-noTGT?\\n"" ) ; gss_release_name ( & min_stat , & target_name ) ; return IMAP_AUTH_UNAVAIL ; } mutt_message ( _ ( ""Authenticating(GSSAPI)..."" ) ) ; imap_cmd_start ( idata , ""AUTHENTICATEGSSAPI"" ) ; do rc = imap_cmd_step ( idata ) ; while ( rc == IMAP_CMD_CONTINUE ) ; if ( rc != IMAP_CMD_RESPOND ) { mutt_debug ( 2 , ""Invalidresponsefromserver:%s\\n"" , buf1 ) ; gss_release_name ( & min_stat , & target_name ) ; goto bail ; } mutt_debug ( 2 , ""Sendingcredentials\\n"" ) ; mutt_b64_encode ( buf1 , send_token . value , send_token . length , sizeof ( buf1 ) - 2 ) ; gss_release_buffer ( & min_stat , & send_token ) ; mutt_str_strcat ( buf1 , sizeof ( buf1 ) , ""\\r\\n"" ) ; mutt_socket_send ( idata -> conn , buf1 ) ; while ( maj_stat == GSS_S_CONTINUE_NEEDED ) { do rc = imap_cmd_step ( idata ) ; while ( rc == IMAP_CMD_CONTINUE ) ; if ( rc != IMAP_CMD_RESPOND ) { mutt_debug ( 1 , ""#1Errorreceivingserverresponse.\\n"" ) ; gss_release_name ( & min_stat , & target_name ) ; goto bail ; } request_buf . length = mutt_b64_decode ( buf2 , idata -> buf + 2 ) ; request_buf . value = buf2 ; sec_token = & request_buf ; maj_stat = gss_init_sec_context ( & min_stat , GSS_C_NO_CREDENTIAL , & context , target_name , GSS_C_NO_OID , GSS_C_MUTUAL_FLAG | GSS_C_SEQUENCE_FLAG , 0 , GSS_C_NO_CHANNEL_BINDINGS , sec_token , NULL , & send_token , ( unsigned int * ) & cflags , NULL ) ; if ( maj_stat != GSS_S_COMPLETE && maj_stat != GSS_S_CONTINUE_NEEDED ) { print_gss_error ( maj_stat , min_stat ) ; mutt_debug ( 1 , ""Errorexchangingcredentials\\n"" ) ; gss_release_name ( & min_stat , & target_name ) ; goto err_abort_cmd ; } mutt_b64_encode ( buf1 , send_token . value , send_token . length , sizeof ( buf1 ) - 2 ) ; gss_release_buffer ( & min_stat , & send_token ) ; mutt_str_strcat ( buf1 , sizeof ( buf1 ) , ""\\r\\n"" ) ; mutt_socket_send ( idata -> conn , buf1 ) ; } gss_release_name ( & min_stat , & target_name ) ; do rc = imap_cmd_step ( idata ) ; while ( rc == IMAP_CMD_CONTINUE ) ; if ( rc != IMAP_CMD_RESPOND ) { mutt_debug ( 1 , ""#2Errorreceivingserverresponse.\\n"" ) ; goto bail ; } request_buf . length = mutt_b64_decode ( buf2 , idata -> buf + 2 ) ; request_buf . value = buf2 ; maj_stat = gss_unwrap ( & min_stat , context , & request_buf , & send_token , & cflags , & quality ) ; if ( maj_stat != GSS_S_COMPLETE ) { print_gss_error ( maj_stat , min_stat ) ; mutt_debug ( 2 , ""Couldn\'tunwrapsecurityleveldata\\n"" ) ; gss_release_buffer ( & min_stat , & send_token ) ; goto err_abort_cmd ; } mutt_debug ( 2 , ""Credentialexchangecomplete\\n"" ) ; server_conf_flags = ( ( char * ) send_token . value ) [ 0 ] ; if ( ! ( ( ( char * ) send_token . value ) [ 0 ] & GSS_AUTH_P_NONE ) ) { mutt_debug ( 2 , ""Serverrequiresintegrityorprivacy\\n"" ) ; gss_release_buffer ( & min_stat , & send_token ) ; goto err_abort_cmd ; } ( ( char * ) send_token . value ) [ 0 ] = '\\0' ; buf_size = ntohl ( * ( ( long * ) send_token . value ) ) ; gss_release_buffer ( & min_stat , & send_token ) ; mutt_debug ( 2 , ""Unwrappedsecuritylevelflags:%c%c%c\\n"" , ( server_conf_flags & GSS_AUTH_P_NONE ) ? 'N' : '-' , ( server_conf_flags & GSS_AUTH_P_INTEGRITY ) ? 'I' : '-' , ( server_conf_flags & GSS_AUTH_P_PRIVACY ) ? 'P' : '-' ) ; mutt_debug ( 2 , ""MaximumGSStokensizeis%ld\\n"" , buf_size ) ; buf_size = htonl ( buf_size ) ; memcpy ( buf1 , & buf_size , 4 ) ; buf1 [ 0 ] = GSS_AUTH_P_NONE ; strncpy ( buf1 + 4 , idata -> conn -> account . user , sizeof ( buf1 ) - 4 ) ; request_buf . value = buf1 ; request_buf . length = 4 + strlen ( idata -> conn -> account . user ) ; maj_stat = gss_wrap ( & min_stat , context , 0 , GSS_C_QOP_DEFAULT , & request_buf , & cflags , & send_token ) ; if ( maj_stat != GSS_S_COMPLETE ) { mutt_debug ( 2 , ""Errorcreatingloginrequest\\n"" ) ; goto err_abort_cmd ; } mutt_b64_encode ( buf1 , send_token . value , send_token . length , sizeof ( buf1 ) - 2 ) ; mutt_debug ( 2 , ""Requestingauthorisationas%s\\n"" , idata -> conn -> account . user ) ; mutt_str_strcat ( buf1 , sizeof ( buf1 ) , ""\\r\\n"" ) ; mutt_socket_send ( idata -> conn , buf1 ) ; do rc = imap_cmd_step ( idata ) ; while ( rc == IMAP_CMD_CONTINUE ) ; if ( rc == IMAP_CMD_RESPOND ) { mutt_debug ( 1 , ""Unexpectedservercontinuationrequest.\\n"" ) ; goto err_abort_cmd ; } if ( imap_code ( idata -> buf ) ) { mutt_debug ( 2 , ""ReleasingGSScredentials\\n"" ) ; maj_stat = gss_delete_sec_context ( & min_stat , & context , & send_token ) ; if ( maj_stat != GSS_S_COMPLETE ) mutt_debug ( 1 , ""Errorreleasingcredentials\\n"" ) ; gss_release_buffer ( & min_stat , & send_token ) ; return IMAP_AUTH_SUCCESS ; } else goto bail ; err_abort_cmd : mutt_socket_send ( idata -> conn , ""*\\r\\n"" ) ; do rc = imap_cmd_step ( idata ) ; while ( rc == IMAP_CMD_CONTINUE ) ; bail : mutt_error ( _ ( ""GSSAPIauthenticationfailed."" ) ) ; return IMAP_AUTH_FAILURE ; } "," buf + 2 , sizeof ( buf2 ) buf + 2 , sizeof ( buf2 ) ",neomutt@neomutt/6f163e07ae68654d7ac5268cbb7565f6df79ad85,CVE-2018-14359,https://github.com/neomutt/neomutt/commit/6f163e07ae68654d7ac5268cbb7565f6df79ad85,2018-07-17T17:29Z 1207,CWE-264,"CWE-264 static int encrypted_update ( struct key * key , struct key_preparsed_payload * prep ) { struct encrypted_key_payload * epayload = key -> payload . data [ 0 ] ; struct encrypted_key_payload * new_epayload ; char * buf ; char * new_master_desc = NULL ; const char * format = NULL ; size_t datalen = prep -> datalen ; int ret = 0 ; if ( datalen <= 0 || datalen > 32767 || ! prep -> data ) return - EINVAL ; buf = kmalloc ( datalen + 1 , GFP_KERNEL ) ; if ( ! buf ) return - ENOMEM ; buf [ datalen ] = 0 ; memcpy ( buf , prep -> data , datalen ) ; ret = datablob_parse ( buf , & format , & new_master_desc , NULL , NULL ) ; if ( ret < 0 ) goto out ; ret = valid_master_desc ( new_master_desc , epayload -> master_desc ) ; if ( ret < 0 ) goto out ; new_epayload = encrypted_key_alloc ( key , epayload -> format , new_master_desc , epayload -> datalen ) ; if ( IS_ERR ( new_epayload ) ) { ret = PTR_ERR ( new_epayload ) ; goto out ; } __ekey_init ( new_epayload , epayload -> format , new_master_desc , epayload -> datalen ) ; memcpy ( new_epayload -> iv , epayload -> iv , ivsize ) ; memcpy ( new_epayload -> payload_data , epayload -> payload_data , epayload -> payload_datalen ) ; rcu_assign_keypointer ( key , new_epayload ) ; call_rcu ( & epayload -> rcu , encrypted_rcu_free ) ; out : kfree ( buf ) ; return ret ; } "," ret = 0 ; if ( test_bit ( KEY_FLAG_NEGATIVE , & key -> flags ) ) return - ENOKEY ",torvalds@linux/096fe9eaea40a17e125569f9e657e34cdb6d73bd,CVE-2015-8539,https://github.com/torvalds/linux/commit/096fe9eaea40a17e125569f9e657e34cdb6d73bd,2016-02-08T03:59Z 1208,CWE-125,"CWE-125 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 = 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 * 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 ) ; ",dbry@WavPack/36a24c7881427d2e1e4dc1cef58f19eee0d13aec,CVE-2018-7253,https://github.com/dbry/WavPack/commit/36a24c7881427d2e1e4dc1cef58f19eee0d13aec,2018-02-19T23:29Z 1209,CWE-119,"CWE-119 static void filter_selectively_horiz ( 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 ; int count ; for ( mask = mask_16x16 | mask_8x8 | mask_4x4 | mask_4x4_int ; mask ; mask >>= count ) { const loop_filter_thresh * lfi = lfi_n -> lfthr + * lfl ; count = 1 ; if ( mask & 1 ) { if ( mask_16x16 & 1 ) { if ( ( mask_16x16 & 3 ) == 3 ) { vp9_lpf_horizontal_16 ( s , pitch , lfi -> mblim , lfi -> lim , lfi -> hev_thr , 2 ) ; count = 2 ; } else { vp9_lpf_horizontal_16 ( s , pitch , lfi -> mblim , lfi -> lim , lfi -> hev_thr , 1 ) ; } } else if ( mask_8x8 & 1 ) { if ( ( mask_8x8 & 3 ) == 3 ) { const loop_filter_thresh * lfin = lfi_n -> lfthr + * ( lfl + 1 ) ; vp9_lpf_horizontal_8_dual ( s , pitch , lfi -> mblim , lfi -> lim , lfi -> hev_thr , lfin -> mblim , lfin -> lim , lfin -> hev_thr ) ; if ( ( mask_4x4_int & 3 ) == 3 ) { vp9_lpf_horizontal_4_dual ( s + 4 * pitch , pitch , lfi -> mblim , lfi -> lim , lfi -> hev_thr , lfin -> mblim , lfin -> lim , lfin -> hev_thr ) ; } else { if ( mask_4x4_int & 1 ) vp9_lpf_horizontal_4 ( s + 4 * pitch , pitch , lfi -> mblim , lfi -> lim , lfi -> hev_thr , 1 ) ; else if ( mask_4x4_int & 2 ) vp9_lpf_horizontal_4 ( s + 8 + 4 * pitch , pitch , lfin -> mblim , lfin -> lim , lfin -> hev_thr , 1 ) ; } count = 2 ; } else { vp9_lpf_horizontal_8 ( s , pitch , lfi -> mblim , lfi -> lim , lfi -> hev_thr , 1 ) ; if ( mask_4x4_int & 1 ) vp9_lpf_horizontal_4 ( s + 4 * pitch , pitch , lfi -> mblim , lfi -> lim , lfi -> hev_thr , 1 ) ; } } else if ( mask_4x4 & 1 ) { if ( ( mask_4x4 & 3 ) == 3 ) { const loop_filter_thresh * lfin = lfi_n -> lfthr + * ( lfl + 1 ) ; vp9_lpf_horizontal_4_dual ( s , pitch , lfi -> mblim , lfi -> lim , lfi -> hev_thr , lfin -> mblim , lfin -> lim , lfin -> hev_thr ) ; if ( ( mask_4x4_int & 3 ) == 3 ) { vp9_lpf_horizontal_4_dual ( s + 4 * pitch , pitch , lfi -> mblim , lfi -> lim , lfi -> hev_thr , lfin -> mblim , lfin -> lim , lfin -> hev_thr ) ; } else { if ( mask_4x4_int & 1 ) vp9_lpf_horizontal_4 ( s + 4 * pitch , pitch , lfi -> mblim , lfi -> lim , lfi -> hev_thr , 1 ) ; else if ( mask_4x4_int & 2 ) vp9_lpf_horizontal_4 ( s + 8 + 4 * pitch , pitch , lfin -> mblim , lfin -> lim , lfin -> hev_thr , 1 ) ; } count = 2 ; } else { vp9_lpf_horizontal_4 ( s , pitch , lfi -> mblim , lfi -> lim , lfi -> hev_thr , 1 ) ; if ( mask_4x4_int & 1 ) vp9_lpf_horizontal_4 ( s + 4 * pitch , pitch , lfi -> mblim , lfi -> lim , lfi -> hev_thr , 1 ) ; } } else if ( mask_4x4_int & 1 ) { vp9_lpf_horizontal_4 ( s + 4 * pitch , pitch , lfi -> mblim , lfi -> lim , lfi -> hev_thr , 1 ) ; } } s += 8 * count ; lfl += count ; mask_16x16 >>= count ; mask_8x8 >>= count ; mask_4x4 >>= count ; mask_4x4_int >>= count ; } } "," 3 ) { vpx_lpf_horizontal_16 ( s , } else { vpx_lpf_horizontal_16 ( s , 1 ) ; vpx_lpf_horizontal_8_dual ( s , 3 ) { vpx_lpf_horizontal_4_dual ( s + 4 * pitch , pitch , lfi -> mblim , lfi -> lim , lfi -> hev_thr , lfin -> mblim , lfin -> lim , lfin -> hev_thr ) ; } else { if ( mask_4x4_int & 1 ) vpx_lpf_horizontal_4 ( s + & 2 ) vpx_lpf_horizontal_4 ( s + } else { vpx_lpf_horizontal_8 ( s , pitch , lfi -> mblim , lfi -> lim , lfi -> hev_thr , 1 ) ; if ( mask_4x4_int & 1 ) vpx_lpf_horizontal_4 ( s + 1 ) ; vpx_lpf_horizontal_4_dual ( s , 3 ) { vpx_lpf_horizontal_4_dual ( s + 4 * pitch , pitch , lfi -> mblim , lfi -> lim , lfi -> hev_thr , lfin -> mblim , lfin -> lim , lfin -> hev_thr ) ; } else { if ( mask_4x4_int & 1 ) vpx_lpf_horizontal_4 ( s + & 2 ) vpx_lpf_horizontal_4 ( s + } else { vpx_lpf_horizontal_4 ( s , pitch , lfi -> mblim , lfi -> lim , lfi -> hev_thr , 1 ) ; if ( mask_4x4_int & 1 ) vpx_lpf_horizontal_4 ( s + 4 * pitch , pitch , lfi -> mblim , lfi -> lim , lfi -> hev_thr , 1 ) ; } } else if ( mask_4x4_int & 1 ) { vpx_lpf_horizontal_4 ( s + ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1210,CWE-264,"CWE-264 static ssize_t perf_read ( struct file * file , char __user * buf , size_t count , loff_t * ppos ) { struct perf_event * event = file -> private_data ; return perf_read_hw ( event , buf , count ) ; } "," -> private_data ; struct perf_event_context * ctx ; int ret ; ctx = perf_event_ctx_lock ( event ) ; ret = perf_read_hw ( event count ) ; perf_event_ctx_unlock ( event , ctx ) ; return ret ; ",torvalds@linux/f63a8daa5812afef4f06c962351687e1ff9ccb2b,CVE-2016-6787,https://github.com/torvalds/linux/commit/f63a8daa5812afef4f06c962351687e1ff9ccb2b,2016-12-28T07:59Z 1211,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 1212,CWE-755,"CWE-755 int sqlite3WindowRewrite ( Parse * pParse , Select * p ) { int rc = SQLITE_OK ; if ( p -> pWin && p -> pPrior == 0 && ( p -> selFlags & SF_WinRewrite ) == 0 ) { Vdbe * v = sqlite3GetVdbe ( pParse ) ; sqlite3 * db = pParse -> db ; Select * pSub = 0 ; SrcList * pSrc = p -> pSrc ; Expr * pWhere = p -> pWhere ; ExprList * pGroupBy = p -> pGroupBy ; Expr * pHaving = p -> pHaving ; ExprList * pSort = 0 ; ExprList * pSublist = 0 ; Window * pMWin = p -> pWin ; Window * pWin ; Table * pTab ; pTab = sqlite3DbMallocZero ( db , sizeof ( Table ) ) ; if ( pTab == 0 ) { return SQLITE_NOMEM ; } p -> pSrc = 0 ; p -> pWhere = 0 ; p -> pGroupBy = 0 ; p -> pHaving = 0 ; p -> selFlags &= ~ SF_Aggregate ; p -> selFlags |= SF_WinRewrite ; pSort = sqlite3ExprListDup ( db , pMWin -> pPartition , 0 ) ; pSort = exprListAppendList ( pParse , pSort , pMWin -> pOrderBy , 1 ) ; if ( pSort && p -> pOrderBy && p -> pOrderBy -> nExpr <= pSort -> nExpr ) { int nSave = pSort -> nExpr ; pSort -> nExpr = p -> pOrderBy -> nExpr ; if ( sqlite3ExprListCompare ( pSort , p -> pOrderBy , - 1 ) == 0 ) { sqlite3ExprListDelete ( db , p -> pOrderBy ) ; p -> pOrderBy = 0 ; } pSort -> nExpr = nSave ; } pMWin -> iEphCsr = pParse -> nTab ++ ; pParse -> nTab += 3 ; selectWindowRewriteEList ( pParse , pMWin , pSrc , p -> pEList , pTab , & pSublist ) ; selectWindowRewriteEList ( pParse , pMWin , pSrc , p -> pOrderBy , pTab , & pSublist ) ; pMWin -> nBufferCol = ( pSublist ? pSublist -> nExpr : 0 ) ; pSublist = exprListAppendList ( pParse , pSublist , pMWin -> pPartition , 0 ) ; pSublist = exprListAppendList ( pParse , pSublist , pMWin -> pOrderBy , 0 ) ; for ( pWin = pMWin ; pWin ; pWin = pWin -> pNextWin ) { ExprList * pArgs = pWin -> pOwner -> x . pList ; if ( pWin -> pFunc -> funcFlags & SQLITE_FUNC_SUBTYPE ) { selectWindowRewriteEList ( pParse , pMWin , pSrc , pArgs , pTab , & pSublist ) ; pWin -> iArgCol = ( pSublist ? pSublist -> nExpr : 0 ) ; pWin -> bExprArgs = 1 ; } else { pWin -> iArgCol = ( pSublist ? pSublist -> nExpr : 0 ) ; pSublist = exprListAppendList ( pParse , pSublist , pArgs , 0 ) ; } if ( pWin -> pFilter ) { Expr * pFilter = sqlite3ExprDup ( db , pWin -> pFilter , 0 ) ; pSublist = sqlite3ExprListAppend ( pParse , pSublist , pFilter ) ; } pWin -> regAccum = ++ pParse -> nMem ; pWin -> regResult = ++ pParse -> nMem ; sqlite3VdbeAddOp2 ( v , OP_Null , 0 , pWin -> regAccum ) ; } if ( pSublist == 0 ) { pSublist = sqlite3ExprListAppend ( pParse , 0 , sqlite3Expr ( db , TK_INTEGER , ""0"" ) ) ; } pSub = sqlite3SelectNew ( pParse , pSublist , pSrc , pWhere , pGroupBy , pHaving , pSort , 0 , 0 ) ; p -> pSrc = sqlite3SrcListAppend ( pParse , 0 , 0 , 0 ) ; if ( p -> pSrc ) { Table * pTab2 ; p -> pSrc -> a [ 0 ] . pSelect = pSub ; sqlite3SrcListAssignCursors ( pParse , p -> pSrc ) ; pSub -> selFlags |= SF_Expanded ; pTab2 = sqlite3ResultSetOfSelect ( pParse , pSub , SQLITE_AFF_NONE ) ; if ( pTab2 == 0 ) { rc = SQLITE_NOMEM ; } else { memcpy ( pTab , pTab2 , sizeof ( Table ) ) ; pTab -> tabFlags |= TF_Ephemeral ; p -> pSrc -> a [ 0 ] . pTab = pTab ; pTab = pTab2 ; } sqlite3VdbeAddOp2 ( v , OP_OpenEphemeral , pMWin -> iEphCsr , pSublist -> nExpr ) ; sqlite3VdbeAddOp2 ( v , OP_OpenDup , pMWin -> iEphCsr + 1 , pMWin -> iEphCsr ) ; sqlite3VdbeAddOp2 ( v , OP_OpenDup , pMWin -> iEphCsr + 2 , pMWin -> iEphCsr ) ; sqlite3VdbeAddOp2 ( v , OP_OpenDup , pMWin -> iEphCsr + 3 , pMWin -> iEphCsr ) ; } else { sqlite3SelectDelete ( db , pSub ) ; } if ( db -> mallocFailed ) rc = SQLITE_NOMEM ; sqlite3DbFree ( db , pTab ) ; } return rc ; } "," ) { return sqlite3ErrorToParser ( db , SQLITE_NOMEM ) ; } p ) ; } if ( rc && pParse -> nErr == 0 ) { assert ( pParse -> db -> mallocFailed ) ; return sqlite3ErrorToParser ( pParse -> db , SQLITE_NOMEM ) ; } ",sqlite@sqlite/8654186b0236d556aa85528c2573ee0b6ab71be3,CVE-2019-19924,https://github.com/sqlite/sqlite/commit/8654186b0236d556aa85528c2573ee0b6ab71be3,2019-12-24T16:15Z 1213,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 1214,CWE-119,"CWE-119 int main ( int argc , char * * argv ) { FILE * infile , * outfile [ NUM_ENCODERS ] ; vpx_codec_ctx_t codec [ NUM_ENCODERS ] ; vpx_codec_enc_cfg_t cfg [ NUM_ENCODERS ] ; vpx_codec_pts_t frame_cnt = 0 ; vpx_image_t raw [ NUM_ENCODERS ] ; vpx_codec_err_t res [ NUM_ENCODERS ] ; int i ; long width ; long height ; int frame_avail ; int got_data ; int flags = 0 ; int arg_deadline = VPX_DL_REALTIME ; int show_psnr = 0 ; uint64_t psnr_sse_total [ NUM_ENCODERS ] = { 0 } ; uint64_t psnr_samples_total [ NUM_ENCODERS ] = { 0 } ; double psnr_totals [ NUM_ENCODERS ] [ 4 ] = { { 0 , 0 } } ; int psnr_count [ NUM_ENCODERS ] = { 0 } ; unsigned int target_bitrate [ NUM_ENCODERS ] = { 1000 , 500 , 100 } ; int framerate = 30 ; vpx_rational_t dsf [ NUM_ENCODERS ] = { { 2 , 1 } , { 2 , 1 } , { 1 , 1 } } ; if ( argc != ( 5 + NUM_ENCODERS ) ) die ( ""Usage:%spsnr?>\\n"" , argv [ 0 ] ) ; printf ( ""Using%s\\n"" , vpx_codec_iface_name ( interface ) ) ; width = strtol ( argv [ 1 ] , NULL , 0 ) ; height = strtol ( argv [ 2 ] , NULL , 0 ) ; if ( width < 16 || width % 2 || height < 16 || height % 2 ) die ( ""Invalidresolution:%ldx%ld"" , width , height ) ; if ( ! ( infile = fopen ( argv [ 3 ] , ""rb"" ) ) ) die ( ""Failedtoopen%sforreading"" , argv [ 3 ] ) ; for ( i = 0 ; i < NUM_ENCODERS ; i ++ ) { if ( ! target_bitrate [ i ] ) { outfile [ i ] = NULL ; continue ; } if ( ! ( outfile [ i ] = fopen ( argv [ i + 4 ] , ""wb"" ) ) ) die ( ""Failedtoopen%sforwriting"" , argv [ i + 4 ] ) ; } show_psnr = strtol ( argv [ NUM_ENCODERS + 4 ] , NULL , 0 ) ; for ( i = 0 ; i < NUM_ENCODERS ; i ++ ) { res [ i ] = vpx_codec_enc_config_default ( interface , & cfg [ i ] , 0 ) ; if ( res [ i ] ) { printf ( ""Failedtogetconfig:%s\\n"" , vpx_codec_err_to_string ( res [ i ] ) ) ; return EXIT_FAILURE ; } } cfg [ 0 ] . g_w = width ; cfg [ 0 ] . g_h = height ; cfg [ 0 ] . g_threads = 1 ; cfg [ 0 ] . rc_dropframe_thresh = 30 ; cfg [ 0 ] . rc_end_usage = VPX_CBR ; cfg [ 0 ] . rc_resize_allowed = 0 ; cfg [ 0 ] . rc_min_quantizer = 4 ; cfg [ 0 ] . rc_max_quantizer = 56 ; cfg [ 0 ] . rc_undershoot_pct = 98 ; cfg [ 0 ] . rc_overshoot_pct = 100 ; cfg [ 0 ] . rc_buf_initial_sz = 500 ; cfg [ 0 ] . rc_buf_optimal_sz = 600 ; cfg [ 0 ] . rc_buf_sz = 1000 ; cfg [ 0 ] . g_error_resilient = 1 ; cfg [ 0 ] . g_lag_in_frames = 0 ; cfg [ 0 ] . kf_mode = VPX_KF_AUTO ; cfg [ 0 ] . kf_min_dist = 3000 ; cfg [ 0 ] . kf_max_dist = 3000 ; cfg [ 0 ] . rc_target_bitrate = target_bitrate [ 0 ] ; cfg [ 0 ] . g_timebase . num = 1 ; cfg [ 0 ] . g_timebase . den = framerate ; for ( i = 1 ; i < NUM_ENCODERS ; i ++ ) { memcpy ( & cfg [ i ] , & cfg [ 0 ] , sizeof ( vpx_codec_enc_cfg_t ) ) ; cfg [ i ] . g_threads = 1 ; cfg [ i ] . rc_target_bitrate = target_bitrate [ i ] ; { unsigned int iw = cfg [ i - 1 ] . g_w * dsf [ i - 1 ] . den + dsf [ i - 1 ] . num - 1 ; unsigned int ih = cfg [ i - 1 ] . g_h * dsf [ i - 1 ] . den + dsf [ i - 1 ] . num - 1 ; cfg [ i ] . g_w = iw / dsf [ i - 1 ] . num ; cfg [ i ] . g_h = ih / dsf [ i - 1 ] . num ; } if ( ( cfg [ i ] . g_w ) % 2 ) cfg [ i ] . g_w ++ ; if ( ( cfg [ i ] . g_h ) % 2 ) cfg [ i ] . g_h ++ ; } for ( i = 0 ; i < NUM_ENCODERS ; i ++ ) if ( ! vpx_img_alloc ( & raw [ i ] , VPX_IMG_FMT_I420 , cfg [ i ] . g_w , cfg [ i ] . g_h , 32 ) ) die ( ""Failedtoallocateimage"" , cfg [ i ] . g_w , cfg [ i ] . g_h ) ; if ( raw [ 0 ] . stride [ VPX_PLANE_Y ] == raw [ 0 ] . d_w ) read_frame_p = read_frame ; else read_frame_p = read_frame_by_row ; for ( i = 0 ; i < NUM_ENCODERS ; i ++ ) if ( outfile [ i ] ) write_ivf_file_header ( outfile [ i ] , & cfg [ i ] , 0 ) ; if ( vpx_codec_enc_init_multi ( & codec [ 0 ] , interface , & cfg [ 0 ] , NUM_ENCODERS , ( show_psnr ? VPX_CODEC_USE_PSNR : 0 ) , & dsf [ 0 ] ) ) die_codec ( & codec [ 0 ] , ""Failedtoinitializeencoder"" ) ; for ( i = 0 ; i < NUM_ENCODERS ; i ++ ) { int speed = - 6 ; if ( vpx_codec_control ( & codec [ i ] , VP8E_SET_CPUUSED , speed ) ) die_codec ( & codec [ i ] , ""Failedtosetcpu_used"" ) ; } for ( i = 0 ; i < NUM_ENCODERS ; i ++ ) { unsigned int static_thresh = 1 ; if ( vpx_codec_control ( & codec [ i ] , VP8E_SET_STATIC_THRESHOLD , static_thresh ) ) die_codec ( & codec [ i ] , ""Failedtosetstaticthreshold"" ) ; } if ( vpx_codec_control ( & codec [ 0 ] , VP8E_SET_NOISE_SENSITIVITY , 1 ) ) die_codec ( & codec [ 0 ] , ""Failedtosetnoise_sensitivity"" ) ; for ( i = 1 ; i < NUM_ENCODERS ; i ++ ) { if ( vpx_codec_control ( & codec [ i ] , VP8E_SET_NOISE_SENSITIVITY , 0 ) ) die_codec ( & codec [ i ] , ""Failedtosetnoise_sensitivity"" ) ; } frame_avail = 1 ; got_data = 0 ; while ( frame_avail || got_data ) { vpx_codec_iter_t iter [ NUM_ENCODERS ] = { NULL } ; const vpx_codec_cx_pkt_t * pkt [ NUM_ENCODERS ] ; flags = 0 ; frame_avail = read_frame_p ( infile , & raw [ 0 ] ) ; if ( frame_avail ) { for ( i = 1 ; i < NUM_ENCODERS ; i ++ ) { I420Scale ( raw [ i - 1 ] . planes [ VPX_PLANE_Y ] , raw [ i - 1 ] . stride [ VPX_PLANE_Y ] , raw [ i - 1 ] . planes [ VPX_PLANE_U ] , raw [ i - 1 ] . stride [ VPX_PLANE_U ] , raw [ i - 1 ] . planes [ VPX_PLANE_V ] , raw [ i - 1 ] . stride [ VPX_PLANE_V ] , raw [ i - 1 ] . d_w , raw [ i - 1 ] . d_h , raw [ i ] . planes [ VPX_PLANE_Y ] , raw [ i ] . stride [ VPX_PLANE_Y ] , raw [ i ] . planes [ VPX_PLANE_U ] , raw [ i ] . stride [ VPX_PLANE_U ] , raw [ i ] . planes [ VPX_PLANE_V ] , raw [ i ] . stride [ VPX_PLANE_V ] , raw [ i ] . d_w , raw [ i ] . d_h , 1 ) ; } } if ( vpx_codec_encode ( & codec [ 0 ] , frame_avail ? & raw [ 0 ] : NULL , frame_cnt , 1 , flags , arg_deadline ) ) die_codec ( & codec [ 0 ] , ""Failedtoencodeframe"" ) ; for ( i = NUM_ENCODERS - 1 ; i >= 0 ; i -- ) { got_data = 0 ; while ( ( pkt [ i ] = vpx_codec_get_cx_data ( & codec [ i ] , & iter [ i ] ) ) ) { got_data = 1 ; switch ( pkt [ i ] -> kind ) { case VPX_CODEC_CX_FRAME_PKT : write_ivf_frame_header ( outfile [ i ] , pkt [ i ] ) ; ( void ) fwrite ( pkt [ i ] -> data . frame . buf , 1 , pkt [ i ] -> data . frame . sz , outfile [ i ] ) ; break ; case VPX_CODEC_PSNR_PKT : if ( show_psnr ) { int j ; psnr_sse_total [ i ] += pkt [ i ] -> data . psnr . sse [ 0 ] ; psnr_samples_total [ i ] += pkt [ i ] -> data . psnr . samples [ 0 ] ; for ( j = 0 ; j < 4 ; j ++ ) { psnr_totals [ i ] [ j ] += pkt [ i ] -> data . psnr . psnr [ j ] ; } psnr_count [ i ] ++ ; } break ; default : break ; } printf ( pkt [ i ] -> kind == VPX_CODEC_CX_FRAME_PKT && ( pkt [ i ] -> data . frame . flags & VPX_FRAME_IS_KEY ) ? ""K"" : ""."" ) ; fflush ( stdout ) ; } } frame_cnt ++ ; } printf ( ""\\n"" ) ; fclose ( infile ) ; printf ( ""Processed%ldframes.\\n"" , ( long int ) frame_cnt - 1 ) ; for ( i = 0 ; i < NUM_ENCODERS ; i ++ ) { if ( ( show_psnr ) && ( psnr_count [ i ] > 0 ) ) { int j ; double ovpsnr = sse_to_psnr ( psnr_samples_total [ i ] , 255.0 , psnr_sse_total [ i ] ) ; fprintf ( stderr , ""\\nENC%dPSNR(Overall/Avg/Y/U/V)"" , i ) ; fprintf ( stderr , ""%.3lf"" , ovpsnr ) ; for ( j = 0 ; j < 4 ; j ++ ) { fprintf ( stderr , ""%.3lf"" , psnr_totals [ i ] [ j ] / psnr_count [ i ] ) ; } } if ( vpx_codec_destroy ( & codec [ i ] ) ) die_codec ( & codec [ i ] , ""Failedtodestroycodec"" ) ; vpx_img_free ( & raw [ i ] ) ; if ( ! outfile [ i ] ) continue ; if ( ! fseek ( outfile [ i ] , 0 , SEEK_SET ) ) write_ivf_file_header ( outfile [ i ] , & cfg [ i ] , frame_cnt - 1 ) ; fclose ( outfile [ i ] ) ; } printf ( ""\\n"" ) ; return EXIT_SUCCESS ; } "," NUM_ENCODERS ] ; FILE * downsampled_input [ NUM_ENCODERS - 1 ] ; char filename [ 50 ] ; NUM_ENCODERS ] ; int frame_cnt = 0 height ; int length_frame ; int 0 ; int layer_id = 0 ; int layer_flags [ VPX_TS_MAX_PERIODICITY * NUM_ENCODERS ] = { 0 } ; int flag_periodicity ; int = 0 ; int key_frame_insert = 0 ; { 0 } ; double cx_time = 0 ; struct timeval tv1 , tv2 , difftv } } ; unsigned int num_temporal_layers [ NUM_ENCODERS ] = { 3 , 3 , 3 } ; argc != ( 7 + 3 * NUM_ENCODERS ) ) ) die ( ""Usage:%s"" ""psnr?>\\n"" , argv [ argv [ 2 ] , NULL , 0 ) ; framerate = strtol ( argv [ 3 ( argv [ 4 ] , ""rb"" , argv [ 4 ] ) ; [ i + 5 ] , ""wb"" ) ; } for ( i = 0 ; i < NUM_ENCODERS ; i ++ ) { target_bitrate [ i ] = strtol ( [ NUM_ENCODERS + 5 + i ] , NULL 0 ) ; } ++ ) { num_temporal_layers [ i ] = strtol ( argv [ 2 * NUM_ENCODERS + 5 + i ] , NULL , 0 ) ; if ( num_temporal_layers [ i ] < 1 || num_temporal_layers [ i ] > 3 ) die ( ""Invalidtemporallayers:%d,Mustbe1,2,or3.\\n"" , num_temporal_layers ) ; } for ( i = 0 ; i < NUM_ENCODERS - 1 ; i ++ ) { if ( sprintf ( filename , ""ds%d.yuv"" , NUM_ENCODERS - i ) < 0 ) { return EXIT_FAILURE ; EXIT_FAILURE ; } downsampled_input [ i ] = fopen ( filename , ""wb"" ) ; } key_frame_insert = strtol ( argv [ 3 * NUM_ENCODERS + 5 ] , NULL , 0 ) ; show_psnr = strtol ( argv [ 3 * NUM_ENCODERS + 6 ] , NULL , 0 ) ; for ( i = 0 ; i < NUM_ENCODERS ; i ++ ) { res [ i ] = vpx_codec_enc_config_default ( interface , & cfg [ i ] , 0 ) ; if ( res [ i ] ) { printf ( ""Failedtogetconfig:%s\\n"" , vpx_codec_err_to_string ( res [ i ] ) ) ; return EXIT_FAILURE ; } 0 ] . rc_dropframe_thresh = 0 ; cfg [ . rc_min_quantizer = 2 ; cfg [ . rc_undershoot_pct = 100 ; cfg [ . rc_overshoot_pct = 15 ; cfg [ vpx_codec_enc_cfg_t ) ) ; cfg [ ++ ; } cfg [ 0 ] . g_threads = 2 ; cfg [ 1 ] . g_threads = 1 ; cfg [ 2 ] . g_threads = 1 ; 0 ) ; for ( i = 0 ; i < NUM_ENCODERS ; i ++ ) { set_temporal_layer_pattern ( num_temporal_layers [ i ] , & cfg [ i ] , cfg [ i ] . rc_target_bitrate , & layer_flags [ i * VPX_TS_MAX_PERIODICITY ] ) ; } ; if ( i == NUM_ENCODERS - 1 ) speed = - 4 ; if ( ] , ""Failedtosetcpu_used"" ) ; } for ( i = 0 ; i < NUM_ENCODERS ; i ++ ) { if ( vpx_codec_control ( & codec [ i ] , VP8E_SET_STATIC_THRESHOLD , 1 ) ) die_codec ( & codec [ i ] , ""Failedtosetstaticthreshold"" ) ; } if ( vpx_codec_control ( & codec [ 0 ] , VP8E_SET_NOISE_SENSITIVITY , 1 ) ) die_codec ( & codec [ 0 ] , ""Failedtosetnoise_sensitivity"" ) ; for ( i = 1 ; i < NUM_ENCODERS ; i ++ ) { if ( vpx_codec_control ( & codec [ i ] , VP8E_SET_NOISE_SENSITIVITY , 0 ) ) die_codec ( & codec [ i ] , ""Failedtosetnoise_sensitivity"" ) ; } for ( i = 0 ; i < NUM_ENCODERS ; i ++ ) { if ( vpx_codec_control ( & codec [ i ] , VP8E_SET_TOKEN_PARTITIONS , 1 ) ) die_codec ( & codec [ i ] , ""Failedtosetstaticthreshold"" { unsigned int max_intra_size_pct = ( int ) ( ( ( double ) cfg [ 0 ] . rc_buf_optimal_sz * 0.5 ) * framerate / 10 ) ; if ( i ] , VP8E_SET_MAX_INTRA_BITRATE_PCT , max_intra_size_pct ) ) die_codec ] , ""Failedtosetstaticthreshold"" ) ; } 1 ) ; length_frame = cfg [ i ] . g_w * cfg [ i ] . g_h * 3 / 2 ; if ( fwrite ( raw [ i ] . planes [ 0 ] , 1 , length_frame , downsampled_input [ NUM_ENCODERS - i - 1 ] ) != length_frame ) { return EXIT_FAILURE ; } } } for ( i = 0 ; i < NUM_ENCODERS ; i ++ ) { layer_id = cfg [ i ] . ts_layer_id [ frame_cnt % cfg [ i ] . ts_periodicity ] ; flags = 0 ; flag_periodicity = periodicity_to_num_layers [ num_temporal_layers [ i ] - 1 ] ; flags = layer_flags [ i * VPX_TS_MAX_PERIODICITY + frame_cnt % flag_periodicity ] ; if ( frame_cnt == 0 ) { flags |= VPX_EFLAG_FORCE_KF ; } if ( frame_cnt > 0 && frame_cnt == key_frame_insert ) { flags = VPX_EFLAG_FORCE_KF ; } vpx_codec_control ( & codec [ i ] , VP8E_SET_FRAME_FLAGS , flags ) ; vpx_codec_control ( & codec [ i ] , VP8E_SET_TEMPORAL_LAYER_ID , layer_id ) ; } gettimeofday ( & tv1 , NULL ) ; if ( vpx_codec_encode , 1 , 0 , arg_deadline ) arg_deadline ) ) { ] , ""Failedtoencodeframe"" ) ; } gettimeofday ( & tv2 , NULL ) ; timersub ( & tv2 , & tv1 , & difftv ) ; cx_time += ( double ) ( difftv . tv_sec * 1000000 + difftv . tv_usec ? ""K"" : """" ) ; fflush printf ( ""\\n"" ) ; printf ( ""FPSforencoding%d%f%f\\n"" , frame_cnt , ( float ) cx_time / 1000000 , 1000000 * ( double ) frame_cnt / ( double ) cx_time ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1215,CWE-119,"CWE-119 bool_t xdr_nullstring ( XDR * xdrs , char * * objp ) { u_int size ; if ( xdrs -> x_op == XDR_ENCODE ) { if ( * objp == NULL ) size = 0 ; else size = strlen ( * objp ) + 1 ; } if ( ! xdr_u_int ( xdrs , & size ) ) { return FALSE ; } switch ( xdrs -> x_op ) { case XDR_DECODE : if ( size == 0 ) { * objp = NULL ; return TRUE ; } else if ( * objp == NULL ) { * objp = ( char * ) mem_alloc ( size ) ; if ( * objp == NULL ) { errno = ENOMEM ; return FALSE ; } } return ( xdr_opaque ( xdrs , * objp , size ) ) ; case XDR_ENCODE : if ( size != 0 ) return ( xdr_opaque ( xdrs , * objp , size ) ) ; return TRUE ; case XDR_FREE : if ( * objp != NULL ) mem_free ( * objp , size ) ; * objp = NULL ; return TRUE ; } return FALSE ; } "," ; } } if ( ! xdr_opaque ( xdrs size ) ) return FALSE ; if ( ( * objp ) [ size - 1 ] != '\\0' ) return FALSE ; if ( memchr ( * objp , '\\0' , size - 1 ) != NULL ) return FALSE ; return TRUE ",krb5@krb5/df17a1224a3406f57477bcd372c61e04c0e5a5bb,CVE-2015-8629,https://github.com/krb5/krb5/commit/df17a1224a3406f57477bcd372c61e04c0e5a5bb,2016-02-13T02:59Z 1216,CWE-254,"CWE-254 void test_parser ( void ) { int i , retval ; bzrtpPacket_t * zrtpPacket ; bzrtpContext_t * context87654321 = bzrtp_createBzrtpContext ( 0x87654321 ) ; bzrtpContext_t * context12345678 = bzrtp_createBzrtpContext ( 0x12345678 ) ; memcpy ( context12345678 -> channelContext [ 0 ] -> selfH [ 0 ] , H12345678 [ 0 ] , 32 ) ; memcpy ( context12345678 -> channelContext [ 0 ] -> selfH [ 1 ] , H12345678 [ 1 ] , 32 ) ; memcpy ( context12345678 -> channelContext [ 0 ] -> selfH [ 2 ] , H12345678 [ 2 ] , 32 ) ; memcpy ( context12345678 -> channelContext [ 0 ] -> selfH [ 3 ] , H12345678 [ 3 ] , 32 ) ; memcpy ( context87654321 -> channelContext [ 0 ] -> selfH [ 0 ] , H87654321 [ 0 ] , 32 ) ; memcpy ( context87654321 -> channelContext [ 0 ] -> selfH [ 1 ] , H87654321 [ 1 ] , 32 ) ; memcpy ( context87654321 -> channelContext [ 0 ] -> selfH [ 2 ] , H87654321 [ 2 ] , 32 ) ; memcpy ( context87654321 -> channelContext [ 0 ] -> selfH [ 3 ] , H87654321 [ 3 ] , 32 ) ; context87654321 -> channelContext [ 0 ] -> keyAgreementAlgo = ZRTP_KEYAGREEMENT_DH3k ; context12345678 -> channelContext [ 0 ] -> keyAgreementAlgo = ZRTP_KEYAGREEMENT_DH3k ; context87654321 -> channelContext [ 0 ] -> cipherAlgo = ZRTP_CIPHER_AES1 ; context12345678 -> channelContext [ 0 ] -> cipherAlgo = ZRTP_CIPHER_AES1 ; context87654321 -> channelContext [ 0 ] -> hashAlgo = ZRTP_HASH_S256 ; context12345678 -> channelContext [ 0 ] -> hashAlgo = ZRTP_HASH_S256 ; updateCryptoFunctionPointers ( context87654321 -> channelContext [ 0 ] ) ; updateCryptoFunctionPointers ( context12345678 -> channelContext [ 0 ] ) ; context87654321 -> channelContext [ 0 ] -> mackeyi = ( uint8_t * ) malloc ( 32 ) ; context12345678 -> channelContext [ 0 ] -> mackeyi = ( uint8_t * ) malloc ( 32 ) ; context87654321 -> channelContext [ 0 ] -> mackeyr = ( uint8_t * ) malloc ( 32 ) ; context12345678 -> channelContext [ 0 ] -> mackeyr = ( uint8_t * ) malloc ( 32 ) ; context87654321 -> channelContext [ 0 ] -> zrtpkeyi = ( uint8_t * ) malloc ( 16 ) ; context12345678 -> channelContext [ 0 ] -> zrtpkeyi = ( uint8_t * ) malloc ( 16 ) ; context87654321 -> channelContext [ 0 ] -> zrtpkeyr = ( uint8_t * ) malloc ( 16 ) ; context12345678 -> channelContext [ 0 ] -> zrtpkeyr = ( uint8_t * ) malloc ( 16 ) ; memcpy ( context12345678 -> channelContext [ 0 ] -> mackeyi , mackeyi , 32 ) ; memcpy ( context12345678 -> channelContext [ 0 ] -> mackeyr , mackeyr , 32 ) ; memcpy ( context12345678 -> channelContext [ 0 ] -> zrtpkeyi , zrtpkeyi , 16 ) ; memcpy ( context12345678 -> channelContext [ 0 ] -> zrtpkeyr , zrtpkeyr , 16 ) ; memcpy ( context87654321 -> channelContext [ 0 ] -> mackeyi , mackeyi , 32 ) ; memcpy ( context87654321 -> channelContext [ 0 ] -> mackeyr , mackeyr , 32 ) ; memcpy ( context87654321 -> channelContext [ 0 ] -> zrtpkeyi , zrtpkeyi , 16 ) ; memcpy ( context87654321 -> channelContext [ 0 ] -> zrtpkeyr , zrtpkeyr , 16 ) ; context12345678 -> channelContext [ 0 ] -> role = RESPONDER ; for ( i = 0 ; i < TEST_PACKET_NUMBER ; i ++ ) { uint8_t freePacketFlag = 1 ; zrtpPacket = bzrtp_packetCheck ( patternZRTPPackets [ i ] , patternZRTPMetaData [ i ] [ 0 ] , ( patternZRTPMetaData [ i ] [ 1 ] ) - 1 , & retval ) ; retval += bzrtp_packetParser ( ( patternZRTPMetaData [ i ] [ 2 ] == 0x87654321 ) ? context12345678 : context87654321 , ( patternZRTPMetaData [ i ] [ 2 ] == 0x87654321 ) ? context12345678 -> channelContext [ 0 ] : context87654321 -> channelContext [ 0 ] , patternZRTPPackets [ i ] , patternZRTPMetaData [ i ] [ 0 ] , zrtpPacket ) ; if ( zrtpPacket -> messageType == MSGTYPE_HELLO ) { if ( patternZRTPMetaData [ i ] [ 2 ] == 0x87654321 ) { context12345678 -> channelContext [ 0 ] -> peerPackets [ HELLO_MESSAGE_STORE_ID ] = zrtpPacket ; } else { context87654321 -> channelContext [ 0 ] -> peerPackets [ HELLO_MESSAGE_STORE_ID ] = zrtpPacket ; } freePacketFlag = 0 ; } if ( zrtpPacket -> messageType == MSGTYPE_COMMIT ) { if ( patternZRTPMetaData [ i ] [ 2 ] == 0x87654321 ) { context12345678 -> channelContext [ 0 ] -> peerPackets [ COMMIT_MESSAGE_STORE_ID ] = zrtpPacket ; } else { context87654321 -> channelContext [ 0 ] -> peerPackets [ COMMIT_MESSAGE_STORE_ID ] = zrtpPacket ; } freePacketFlag = 0 ; } if ( zrtpPacket -> messageType == MSGTYPE_DHPART1 || zrtpPacket -> messageType == MSGTYPE_DHPART2 ) { if ( patternZRTPMetaData [ i ] [ 2 ] == 0x87654321 ) { context12345678 -> channelContext [ 0 ] -> peerPackets [ DHPART_MESSAGE_STORE_ID ] = zrtpPacket ; } else { context87654321 -> channelContext [ 0 ] -> peerPackets [ DHPART_MESSAGE_STORE_ID ] = zrtpPacket ; } freePacketFlag = 0 ; } free ( zrtpPacket -> packetString ) ; retval = bzrtp_packetBuild ( ( patternZRTPMetaData [ i ] [ 2 ] == 0x12345678 ) ? context12345678 : context87654321 , ( patternZRTPMetaData [ i ] [ 2 ] == 0x12345678 ) ? context12345678 -> channelContext [ 0 ] : context87654321 -> channelContext [ 0 ] , zrtpPacket , patternZRTPMetaData [ i ] [ 1 ] ) ; if ( zrtpPacket -> packetString != NULL ) { CU_ASSERT_TRUE ( memcmp ( zrtpPacket -> packetString , patternZRTPPackets [ i ] , patternZRTPMetaData [ i ] [ 0 ] ) == 0 ) ; } else { CU_FAIL ( ""Unabletobuildpacket"" ) ; } if ( freePacketFlag == 1 ) { bzrtp_freeZrtpPacket ( zrtpPacket ) ; } } bzrtp_destroyBzrtpContext ( context87654321 , 0x87654321 ) ; bzrtp_destroyBzrtpContext ( context12345678 , 0x12345678 ) ; } "," void ) { test_parser_param ( 0 ) ; ) ; } ",BelledonneCommunications@bzrtp/bbb1e6e2f467ee4bd7b9a8c800e4f07343d7d99b,CVE-2016-6271,https://github.com/BelledonneCommunications/bzrtp/commit/bbb1e6e2f467ee4bd7b9a8c800e4f07343d7d99b,2017-01-18T22:59Z 1217,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 1218,CWE-119,"CWE-119 static void process_secondary_order ( STREAM s ) { uint16 length ; uint16 flags ; uint8 type ; uint8 * next_order ; in_uint16_le ( s , length ) ; in_uint16_le ( s , flags ) ; in_uint8 ( s , type ) ; next_order = s -> p + ( sint16 ) length + 7 ; switch ( type ) { case RDP_ORDER_RAW_BMPCACHE : process_raw_bmpcache ( s ) ; break ; case RDP_ORDER_COLCACHE : process_colcache ( s ) ; break ; case RDP_ORDER_BMPCACHE : process_bmpcache ( s ) ; break ; case RDP_ORDER_FONTCACHE : process_fontcache ( s ) ; break ; case RDP_ORDER_RAW_BMPCACHE2 : process_bmpcache2 ( s , flags , False ) ; break ; case RDP_ORDER_BMPCACHE2 : process_bmpcache2 ( s , flags , True ) ; break ; case RDP_ORDER_BRUSHCACHE : process_brushcache ( s , flags ) ; break ; default : logger ( Graphics , Warning , ""process_secondary_order(),unhandledsecondaryorder%d"" , type ) ; } s -> p = next_order ; } "," * next_order ; struct stream packet = * s ; type ) ; if ( ! s_check_rem ( s , length + 7 ) ) { rdp_protocol_error ( ""process_secondary_order(),nextorderpointerwouldoverrunstream"" , & packet ) ; } ",rdesktop@rdesktop/4dca546d04321a610c1835010b5dad85163b65e1,CVE-2018-20182,https://github.com/rdesktop/rdesktop/commit/4dca546d04321a610c1835010b5dad85163b65e1,2019-03-15T18:29Z 1219,CWE-119,"CWE-119 static PixelChannels * * AcquirePixelThreadSet ( const Image * images ) { const Image * next ; PixelChannels * * pixels ; register ssize_t i ; size_t columns , number_threads ; number_threads = ( size_t ) GetMagickResourceLimit ( ThreadResource ) ; pixels = ( PixelChannels * * ) AcquireQuantumMemory ( number_threads , sizeof ( * pixels ) ) ; if ( pixels == ( PixelChannels * * ) NULL ) return ( ( PixelChannels * * ) NULL ) ; ( void ) memset ( pixels , 0 , number_threads * sizeof ( * pixels ) ) ; columns = images -> columns ; for ( next = images ; next != ( Image * ) NULL ; next = next -> next ) columns = MagickMax ( next -> columns , columns ) ; for ( i = 0 ; i < ( ssize_t ) number_threads ; i ++ ) { register ssize_t j ; pixels [ i ] = ( PixelChannels * ) AcquireQuantumMemory ( columns , sizeof ( * * pixels ) ) ; if ( pixels [ i ] == ( PixelChannels * ) NULL ) return ( DestroyPixelThreadSet ( pixels ) ) ; for ( j = 0 ; j < ( ssize_t ) columns ; j ++ ) { register ssize_t k ; for ( k = 0 ; k < MaxPixelChannels ; k ++ ) pixels [ i ] [ j ] . channel [ k ] = 0.0 ; } } return ( pixels ) ; } "," size_t columns , rows ; rows = MagickMax ( GetImageListLength ( images ) , ( size_t ) ( ThreadResource ) ) ) AcquireQuantumMemory ( rows , sizeof ( * NULL ) ; columns = MaxPixelChannels ; for ( next = images ; next != ( Image * ) NULL ; next = next -> next ) columns = MagickMax ( next -> columns , columns ) ; for ( i = 0 ; i < ( ssize_t ) rows ; i ++ ",ImageMagick@ImageMagick/025e77fcb2f45b21689931ba3bf74eac153afa48,CVE-2019-13307,https://github.com/ImageMagick/ImageMagick/commit/025e77fcb2f45b21689931ba3bf74eac153afa48,2019-07-05T01:15Z 1220,CWE-000,"CWE-000 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 ; struct rds_transport * otrans = trans ; if ( ! is_outgoing && otrans -> t_type == RDS_TRANS_TCP ) goto new_conn ; 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 ; new_conn : 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 ; } } 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_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 ; if ( ! is_outgoing && otrans -> t_type == RDS_TRANS_TCP ) found = NULL ; else 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 { if ( ( is_outgoing && otrans -> t_type == RDS_TRANS_TCP ) || ( otrans -> t_type != RDS_TRANS_TCP ) ) { 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 ; } "," ; } } if ( trans == NULL ) { kmem_cache_free ( rds_conn_slab , conn ) ; conn = ERR_PTR ( - ENODEV ) ; goto out ; } ",torvalds@linux/74e98eb085889b0d2d4908f59f6e00026063014f,CVE-2015-6937,https://github.com/torvalds/linux/commit/74e98eb085889b0d2d4908f59f6e00026063014f,2015-10-19T10:59Z 1221,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 1222,CWE-416,"CWE-416 ExprDef * ExprAppendMultiKeysymList ( ExprDef * expr , ExprDef * append ) { unsigned nSyms = darray_size ( expr -> keysym_list . syms ) ; unsigned numEntries = darray_size ( append -> keysym_list . syms ) ; darray_append ( expr -> keysym_list . symsMapIndex , nSyms ) ; darray_append ( expr -> keysym_list . symsNumEntries , numEntries ) ; darray_concat ( expr -> keysym_list . syms , append -> keysym_list . syms ) ; FreeStmt ( ( ParseCommon * ) & append ) ; return expr ; } "," ParseCommon * ) append ) ; ",xkbcommon@libxkbcommon/c1e5ac16e77a21f87bdf3bc4dea61b037a17dddb,CVE-2018-15857,https://github.com/xkbcommon/libxkbcommon/commit/c1e5ac16e77a21f87bdf3bc4dea61b037a17dddb,2018-08-25T21:29Z 1223,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 1224,CWE-190,"CWE-190 static int Unpickler_set_memo ( UnpicklerObject * self , PyObject * obj ) { PyObject * * new_memo ; Py_ssize_t new_memo_size = 0 ; Py_ssize_t i ; if ( obj == NULL ) { PyErr_SetString ( PyExc_TypeError , ""attributedeletionisnotsupported"" ) ; return - 1 ; } if ( Py_TYPE ( obj ) == & UnpicklerMemoProxyType ) { UnpicklerObject * unpickler = ( ( UnpicklerMemoProxyObject * ) obj ) -> unpickler ; new_memo_size = unpickler -> memo_size ; new_memo = _Unpickler_NewMemo ( new_memo_size ) ; if ( new_memo == NULL ) return - 1 ; for ( i = 0 ; i < new_memo_size ; i ++ ) { Py_XINCREF ( unpickler -> memo [ i ] ) ; new_memo [ i ] = unpickler -> memo [ i ] ; } } else if ( PyDict_Check ( obj ) ) { Py_ssize_t i = 0 ; PyObject * key , * value ; new_memo_size = PyDict_GET_SIZE ( obj ) ; new_memo = _Unpickler_NewMemo ( new_memo_size ) ; if ( new_memo == NULL ) return - 1 ; while ( PyDict_Next ( obj , & i , & key , & value ) ) { Py_ssize_t idx ; if ( ! PyLong_Check ( key ) ) { PyErr_SetString ( PyExc_TypeError , ""memokeymustbeintegers"" ) ; goto error ; } idx = PyLong_AsSsize_t ( key ) ; if ( idx == - 1 && PyErr_Occurred ( ) ) goto error ; if ( idx < 0 ) { PyErr_SetString ( PyExc_ValueError , ""memokeymustbepositiveintegers."" ) ; goto error ; } if ( _Unpickler_MemoPut ( self , idx , value ) < 0 ) goto error ; } } else { PyErr_Format ( PyExc_TypeError , ""\'memo\'attributemustbeanUnpicklerMemoProxyobject"" ""ordict,not%.200s"" , Py_TYPE ( obj ) -> tp_name ) ; return - 1 ; } _Unpickler_MemoCleanup ( self ) ; self -> memo_size = new_memo_size ; self -> memo = new_memo ; return 0 ; error : if ( new_memo_size ) { i = new_memo_size ; while ( -- i >= 0 ) { Py_XDECREF ( new_memo [ i ] ) ; } PyMem_FREE ( new_memo ) ; } return - 1 ; } "," * new_memo ; size_t new_memo_size = 0 ; if ( ; for ( size_t new_memo_size ) { for ( size_t i = new_memo_size - 1 ; i != SIZE_MAX ; i -- ) { Py_XDECREF ",python@cpython/a4ae828ee416a66d8c7bf5ee71d653c2cc6a26dd,CVE-2018-20406,https://github.com/python/cpython/commit/a4ae828ee416a66d8c7bf5ee71d653c2cc6a26dd,2018-12-23T23:29Z 1225,CWE-125,"CWE-125 void qedi_dbg_warn ( 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_WARN ) ) goto ret ; if ( likely ( qedi ) && likely ( qedi -> pdev ) ) pr_warn ( ""[%s]:[%s:%d]:%d:%pV"" , dev_name ( & qedi -> pdev -> dev ) , nfunc , line , qedi -> host_no , & vaf ) ; else pr_warn ( ""[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 1226,CWE-119,"CWE-119 static int send_parameters ( struct iperf_test * test ) { int r = 0 ; cJSON * j ; j = cJSON_CreateObject ( ) ; if ( j == NULL ) { i_errno = IESENDPARAMS ; r = - 1 ; } else { if ( test -> protocol -> id == Ptcp ) cJSON_AddTrueToObject ( j , ""tcp"" ) ; else if ( test -> protocol -> id == Pudp ) cJSON_AddTrueToObject ( j , ""udp"" ) ; cJSON_AddIntToObject ( j , ""omit"" , test -> omit ) ; if ( test -> server_affinity != - 1 ) cJSON_AddIntToObject ( j , ""server_affinity"" , test -> server_affinity ) ; if ( test -> duration ) cJSON_AddIntToObject ( j , ""time"" , test -> duration ) ; if ( test -> settings -> bytes ) cJSON_AddIntToObject ( j , ""num"" , test -> settings -> bytes ) ; if ( test -> settings -> blocks ) cJSON_AddIntToObject ( j , ""blockcount"" , test -> settings -> blocks ) ; if ( test -> settings -> mss ) cJSON_AddIntToObject ( j , ""MSS"" , test -> settings -> mss ) ; if ( test -> no_delay ) cJSON_AddTrueToObject ( j , ""nodelay"" ) ; cJSON_AddIntToObject ( j , ""parallel"" , test -> num_streams ) ; if ( test -> reverse ) cJSON_AddTrueToObject ( j , ""reverse"" ) ; if ( test -> settings -> socket_bufsize ) cJSON_AddIntToObject ( j , ""window"" , test -> settings -> socket_bufsize ) ; if ( test -> settings -> blksize ) cJSON_AddIntToObject ( j , ""len"" , test -> settings -> blksize ) ; if ( test -> settings -> rate ) cJSON_AddIntToObject ( j , ""bandwidth"" , test -> settings -> rate ) ; if ( test -> settings -> burst ) cJSON_AddIntToObject ( j , ""burst"" , test -> settings -> burst ) ; if ( test -> settings -> tos ) cJSON_AddIntToObject ( j , ""TOS"" , test -> settings -> tos ) ; if ( test -> settings -> flowlabel ) cJSON_AddIntToObject ( j , ""flowlabel"" , test -> settings -> flowlabel ) ; if ( test -> title ) cJSON_AddStringToObject ( j , ""title"" , test -> title ) ; if ( test -> congestion ) cJSON_AddStringToObject ( j , ""congestion"" , test -> congestion ) ; if ( test -> get_server_output ) cJSON_AddIntToObject ( j , ""get_server_output"" , iperf_get_test_get_server_output ( test ) ) ; if ( test -> debug ) { printf ( ""send_parameters:\\n%s\\n"" , cJSON_Print ( j ) ) ; } if ( JSON_write ( test -> ctrl_sck , j ) < 0 ) { i_errno = IESENDPARAMS ; r = - 1 ; } cJSON_Delete ( j ) ; } return r ; } "," ""udp"" ) ; cJSON_AddNumberToObject ( j , - 1 ) cJSON_AddNumberToObject ( j , ""server_affinity"" , test -> server_affinity ) ; if ( test -> duration ) cJSON_AddNumberToObject ( j , ""time"" , test -> duration ) ; if ( test -> settings -> bytes ) cJSON_AddNumberToObject ( j , ""num"" , test -> settings -> bytes ) ; if ( test -> settings -> blocks ) cJSON_AddNumberToObject ( j , ""blockcount"" , test -> settings -> blocks ) ; if ( test -> settings -> mss ) cJSON_AddNumberToObject ( j , ""MSS"" , test -> settings -> mss ) ; if ( test -> no_delay ) cJSON_AddTrueToObject ( j , ""nodelay"" ) ; cJSON_AddNumberToObject ( j , ""parallel"" , test -> num_streams ) ; if ( test -> reverse ) cJSON_AddTrueToObject ( j , ""reverse"" ) ; if ( test -> settings -> socket_bufsize ) cJSON_AddNumberToObject ( j , ""window"" , test -> settings -> socket_bufsize ) ; if ( test -> settings -> blksize ) cJSON_AddNumberToObject ( j , ""len"" , test -> settings -> blksize ) ; if ( test -> settings -> rate ) cJSON_AddNumberToObject ( j , ""bandwidth"" , test -> settings -> rate ) ; if ( test -> settings -> burst ) cJSON_AddNumberToObject ( j , ""burst"" , test -> settings -> burst ) ; if ( test -> settings -> tos ) cJSON_AddNumberToObject ( j , ""TOS"" , test -> settings -> tos ) ; if ( test -> settings -> flowlabel ) cJSON_AddNumberToObject ( j , ""flowlabel"" , test -> settings -> flowlabel ) ; if ( test -> title ) cJSON_AddStringToObject ( j , ""title"" , test -> title ) ; if ( test -> congestion ) cJSON_AddStringToObject ( j , ""congestion"" , test -> congestion ) ; if ( test -> get_server_output ) << << << < HEAD ( j , ""get_server_output"" , iperf_get_test_get_server_output ( test ) ) ; == == == = cJSON_AddNumberToObject ( j , ""get_server_output"" , iperf_get_test_get_server_output ( test ) ) ; if ( test -> udp_counters_64bit ) cJSON_AddNumberToObject ( j , ""udp_counters_64bit"" , iperf_get_test_udp_counters_64bit ( test ) ) ; if ( test -> no_fq_socket_pacing ) cJSON_AddNumberToObject ( j , ""no_fq_socket_pacing"" , iperf_get_no_fq_socket_pacing ( test ) ) ; cJSON_AddStringToObject ( j ( j , ""client_version"" , IPERF_VERSION ) ; >> >> >> > ed94082 ... Fix a buffer overflow / heap corruption issue that could occur if a if ( test ",esnet@iperf/91f2fa59e8ed80dfbf400add0164ee0e508e412a,CVE-2016-4303,https://github.com/esnet/iperf/commit/91f2fa59e8ed80dfbf400add0164ee0e508e412a,2016-09-26T14:59Z 1227,CWE-20,"CWE-20 static int snd_timer_start_slave ( struct snd_timer_instance * timeri ) { unsigned long flags ; spin_lock_irqsave ( & slave_active_lock , flags ) ; timeri -> flags |= SNDRV_TIMER_IFLG_RUNNING ; if ( timeri -> master ) list_add_tail ( & timeri -> active_list , & timeri -> master -> slave_active_head ) ; spin_unlock_irqrestore ( & slave_active_lock , flags ) ; return 1 ; } "," timeri -> master && timeri -> timer ) { spin_lock ( & timeri -> timer -> lock ) ; list_add_tail ( & slave_active_head ) ; spin_unlock ( & timeri -> timer -> lock ) ; } ",torvalds@linux/b5a663aa426f4884c71cd8580adae73f33570f0d,CVE-2016-2548,https://github.com/torvalds/linux/commit/b5a663aa426f4884c71cd8580adae73f33570f0d,2016-04-27T17:59Z 1228,CWE-200,"CWE-200 static ssize_t snd_timer_user_read ( struct file * file , char __user * buffer , size_t count , loff_t * offset ) { struct snd_timer_user * tu ; long result = 0 , unit ; int qhead ; int err = 0 ; tu = file -> private_data ; unit = tu -> tread ? sizeof ( struct snd_timer_tread ) : sizeof ( struct snd_timer_read ) ; spin_lock_irq ( & tu -> qlock ) ; while ( ( long ) count - result >= unit ) { while ( ! tu -> qused ) { wait_queue_t wait ; if ( ( file -> f_flags & O_NONBLOCK ) != 0 || result > 0 ) { err = - EAGAIN ; goto _error ; } set_current_state ( TASK_INTERRUPTIBLE ) ; init_waitqueue_entry ( & wait , current ) ; add_wait_queue ( & tu -> qchange_sleep , & wait ) ; spin_unlock_irq ( & tu -> qlock ) ; schedule ( ) ; spin_lock_irq ( & tu -> qlock ) ; remove_wait_queue ( & tu -> qchange_sleep , & wait ) ; if ( tu -> disconnected ) { err = - ENODEV ; goto _error ; } if ( signal_pending ( current ) ) { err = - ERESTARTSYS ; goto _error ; } } qhead = tu -> qhead ++ ; tu -> qhead %= tu -> queue_size ; tu -> qused -- ; spin_unlock_irq ( & tu -> qlock ) ; mutex_lock ( & tu -> ioctl_lock ) ; if ( tu -> tread ) { if ( copy_to_user ( buffer , & tu -> tqueue [ qhead ] , sizeof ( struct snd_timer_tread ) ) ) err = - EFAULT ; } else { if ( copy_to_user ( buffer , & tu -> queue [ qhead ] , sizeof ( struct snd_timer_read ) ) ) err = - EFAULT ; } mutex_unlock ( & tu -> ioctl_lock ) ; spin_lock_irq ( & tu -> qlock ) ; if ( err < 0 ) goto _error ; result += unit ; buffer += unit ; } _error : spin_unlock_irq ( & tu -> qlock ) ; return result > 0 ? result : err ; } "," snd_timer_read ) ; mutex_lock ( & tu -> ioctl_lock ) ; qlock ) ; mutex_unlock ( & tu -> ioctl_lock ) ; schedule ( ) ; mutex_lock ( & tu -> ioctl_lock ) ; spin_lock_irq qlock ) ; if ( tu EFAULT ; } spin_lock_irq ( & qlock ) ; mutex_unlock ( & tu -> ioctl_lock ) ; ",torvalds@linux/d11662f4f798b50d8c8743f433842c3e40fe3378,CVE-2017-1000380,https://github.com/torvalds/linux/commit/d11662f4f798b50d8c8743f433842c3e40fe3378,2017-06-17T18:29Z 1229,CWE-399,"CWE-399 xmlAttrPtr xsltAttrTemplateProcess ( xsltTransformContextPtr ctxt , xmlNodePtr target , xmlAttrPtr attr ) { const xmlChar * value ; xmlAttrPtr ret ; if ( ( ctxt == NULL ) || ( attr == NULL ) || ( target == NULL ) ) return ( NULL ) ; if ( attr -> type != XML_ATTRIBUTE_NODE ) return ( NULL ) ; # ifdef XSLT_REFACTORED if ( attr -> psvi == xsltXSLTAttrMarker ) return ( NULL ) ; # else if ( ( attr -> ns != NULL ) && xmlStrEqual ( attr -> ns -> href , XSLT_NAMESPACE ) ) return ( NULL ) ; # 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"" ) ; return ( NULL ) ; } value = attr -> children -> content ; if ( value == NULL ) value = xmlDictLookup ( ctxt -> dict , BAD_CAST """" , 0 ) ; } else value = xmlDictLookup ( ctxt -> dict , BAD_CAST """" , 0 ) ; ret = target -> properties ; while ( ret != NULL ) { if ( ( ( attr -> ns != NULL ) == ( ret -> ns != NULL ) ) && xmlStrEqual ( ret -> name , attr -> name ) && ( ( attr -> ns == NULL ) || xmlStrEqual ( ret -> ns -> href , attr -> ns -> href ) ) ) { break ; } ret = ret -> next ; } if ( ret != NULL ) { xmlFreeNodeList ( ret -> children ) ; ret -> children = ret -> last = NULL ; if ( ( ret -> ns != NULL ) && ( ! xmlStrEqual ( ret -> ns -> prefix , attr -> ns -> prefix ) ) ) { ret -> ns = xsltGetNamespace ( ctxt , attr -> parent , attr -> ns , target ) ; } } else { if ( attr -> ns != NULL ) ret = xmlNewNsProp ( target , xsltGetNamespace ( ctxt , attr -> parent , attr -> ns , target ) , attr -> name , NULL ) ; else ret = xmlNewNsProp ( target , NULL , attr -> name , NULL ) ; } if ( ret != NULL ) { xmlNodePtr text ; text = xmlNewText ( NULL ) ; if ( text != NULL ) { ret -> last = ret -> children = text ; text -> parent = ( xmlNodePtr ) ret ; text -> doc = ret -> doc ; if ( attr -> psvi != NULL ) { xmlChar * val ; val = xsltEvalAVT ( ctxt , attr -> psvi , attr -> parent ) ; if ( val == 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 """" ) ; } else { text -> content = val ; } } else if ( ( ctxt -> internalized ) && ( target != NULL ) && ( target -> doc != NULL ) && ( target -> doc -> dict == ctxt -> dict ) ) { text -> content = ( xmlChar * ) value ; } else { text -> content = xmlStrdup ( value ) ; } } } else { 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 ) ; } } return ( ret ) ; } "," -> dict ) && xmlDictOwns ( ctxt -> dict , value ) ",chromium@chromium/2de493f4a1d48952e09230a0c32ccbd45db973b2,CVE-2012-2893,https://github.com/chromium/chromium/commit/2de493f4a1d48952e09230a0c32ccbd45db973b2,2012-09-26T10:56Z 1230,CWE-284,"CWE-284 bool btsock_thread_remove_fd_and_close ( int thread_handle , int fd ) { if ( thread_handle < 0 || thread_handle >= MAX_THREAD ) { APPL_TRACE_ERROR ( ""%sinvalidthreadhandle:%d"" , __func__ , thread_handle ) ; return false ; } if ( fd == - 1 ) { APPL_TRACE_ERROR ( ""%sinvalidfiledescriptor."" , __func__ ) ; return false ; } sock_cmd_t cmd = { CMD_REMOVE_FD , fd , 0 , 0 , 0 } ; return send ( ts [ thread_handle ] . cmd_fdw , & cmd , sizeof ( cmd ) , 0 ) == sizeof ( cmd ) ; } "," } ; return TEMP_FAILURE_RETRY ( , 0 ) ) ",system@bt/472271b153c5dc53c28beac55480a8d8434b2d5c,CVE-2016-3839,https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c,2016-08-05T20:59Z 1231,CWE-362,"CWE-362 void sock_release ( struct socket * sock ) { if ( sock -> ops ) { struct module * owner = sock -> ops -> owner ; sock -> ops -> release ( sock ) ; sock -> ops = NULL ; module_put ( owner ) ; } if ( rcu_dereference_protected ( sock -> wq , 1 ) -> fasync_list ) pr_err ( ""%s:fasynclistnotempty!\\n"" , __func__ ) ; if ( ! sock -> file ) { iput ( SOCK_INODE ( sock ) ) ; return ; } sock -> file = NULL ; } "," sock ) { __sock_release ( sock , NULL ) ; } ) ; } ",torvalds@linux/6d8c50dcb029872b298eea68cc6209c866fd3e14,CVE-2018-12232,https://github.com/torvalds/linux/commit/6d8c50dcb029872b298eea68cc6209c866fd3e14,2018-06-12T12:29Z 1232,CWE-264,"CWE-264 static NPError g_NPN_GetValue ( NPP instance , NPNVariable variable , void * value ) { D ( bug ( ""NPN_GetValueinstance=%p,variable=%d[%s]\\n"" , instance , variable , string_of_NPNVariable ( variable ) ) ) ; if ( ! thread_check ( ) ) { npw_printf ( ""WARNING:NPN_GetValuenotcalledfromthemainthread\\n"" ) ; return NPERR_INVALID_INSTANCE_ERROR ; } PluginInstance * plugin = NULL ; if ( instance ) plugin = PLUGIN_INSTANCE ( instance ) ; switch ( variable ) { case NPNVxDisplay : * ( void * * ) value = x_display ; break ; case NPNVxtAppContext : * ( void * * ) value = XtDisplayToApplicationContext ( x_display ) ; break ; case NPNVToolkit : * ( NPNToolkitType * ) value = NPW_TOOLKIT ; break ; # if USE_XPCOM case NPNVserviceManager : { nsIServiceManager * sm ; int ret = NS_GetServiceManager ( & sm ) ; if ( NS_FAILED ( ret ) ) { npw_printf ( ""WARNING:NS_GetServiceManagerfailed\\n"" ) ; return NPERR_GENERIC_ERROR ; } * ( nsIServiceManager * * ) value = sm ; break ; } case NPNVDOMWindow : case NPNVDOMElement : npw_printf ( ""WARNING:%sisnotsupportedbyNPN_GetValue()\\n"" , string_of_NPNVariable ( variable ) ) ; return NPERR_INVALID_PARAM ; # endif case NPNVnetscapeWindow : if ( plugin == NULL ) { npw_printf ( ""ERROR:NPNVnetscapeWindowrequiresanonNULLinstance\\n"" ) ; return NPERR_INVALID_INSTANCE_ERROR ; } if ( plugin -> browser_toplevel == NULL ) { GdkNativeWindow netscape_xid = None ; NPError error = g_NPN_GetValue_real ( instance , variable , & netscape_xid ) ; if ( error != NPERR_NO_ERROR ) return error ; if ( netscape_xid == None ) return NPERR_GENERIC_ERROR ; plugin -> browser_toplevel = gdk_window_foreign_new ( netscape_xid ) ; if ( plugin -> browser_toplevel == NULL ) return NPERR_GENERIC_ERROR ; } * ( ( GdkNativeWindow * ) value ) = GDK_WINDOW_XWINDOW ( plugin -> browser_toplevel ) ; break ; # if ALLOW_WINDOWLESS_PLUGINS case NPNVSupportsWindowless : # endif case NPNVSupportsXEmbedBool : case NPNVWindowNPObject : case NPNVPluginElementNPObject : return g_NPN_GetValue_real ( instance , variable , value ) ; default : switch ( variable & 0xff ) { case 13 : if ( NPW_TOOLKIT == NPNVGtk2 ) { * ( NPNToolkitType * ) value = NPW_TOOLKIT ; return NPERR_NO_ERROR ; } break ; } D ( bug ( ""WARNING:unhandledvariable%d(%s)inNPN_GetValue()\\n"" , variable , string_of_NPNVariable ( variable ) ) ) ; return NPERR_INVALID_PARAM ; } return NPERR_NO_ERROR ; } "," case NPNVPluginElementNPObject : case NPNVprivateModeBool : case NPNVsupportsAdvancedKeyHandling : ",davidben@nspluginwrapper/7e4ab8e1189846041f955e6c83f72bc1624e7a98,CVE-2011-2486,https://github.com/davidben/nspluginwrapper/commit/7e4ab8e1189846041f955e6c83f72bc1624e7a98,2012-11-19T12:10Z 1233,CWE-119,"CWE-119 WORD32 ih264d_parse_islice_data_cavlc ( dec_struct_t * ps_dec , dec_slice_params_t * ps_slice , UWORD16 u2_first_mb_in_slice ) { UWORD8 uc_more_data_flag ; UWORD8 u1_num_mbs , u1_mb_idx ; dec_mb_info_t * ps_cur_mb_info ; deblk_mb_t * ps_cur_deblk_mb ; dec_bit_stream_t * const ps_bitstrm = ps_dec -> ps_bitstrm ; UWORD32 * pu4_bitstrm_ofst = & ps_bitstrm -> u4_ofst ; UWORD32 * pu4_bitstrm_buf = ps_bitstrm -> pu4_buffer ; UWORD16 i2_pic_wdin_mbs = ps_dec -> u2_frm_wd_in_mbs ; WORD16 i2_cur_mb_addr ; UWORD8 u1_mbaff ; UWORD8 u1_num_mbs_next , u1_end_of_row , u1_tfr_n_mb ; WORD32 ret = OK ; ps_dec -> u1_qp = ps_slice -> u1_slice_qp ; ih264d_update_qp ( ps_dec , 0 ) ; u1_mbaff = ps_slice -> u1_mbaff_frame_flag ; u1_mb_idx = ps_dec -> u1_mb_idx ; u1_num_mbs = u1_mb_idx ; uc_more_data_flag = 1 ; i2_cur_mb_addr = u2_first_mb_in_slice << u1_mbaff ; do { UWORD8 u1_mb_type ; ps_dec -> pv_prev_mb_parse_tu_coeff_data = ps_dec -> pv_parse_tu_coeff_data ; if ( i2_cur_mb_addr > ps_dec -> ps_cur_sps -> u2_max_mb_addr ) { ret = ERROR_MB_ADDRESS_T ; break ; } ps_cur_mb_info = ps_dec -> ps_nmb_info + u1_num_mbs ; ps_dec -> u4_num_mbs_cur_nmb = u1_num_mbs ; ps_dec -> u4_num_pmbair = ( u1_num_mbs >> u1_mbaff ) ; ps_cur_mb_info -> u1_end_of_slice = 0 ; ps_dec -> pf_get_mb_info ( ps_dec , i2_cur_mb_addr , ps_cur_mb_info , 0 ) ; ps_cur_deblk_mb = ps_dec -> ps_deblk_mbn + u1_num_mbs ; 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_cur_deblk_mb -> u1_mb_type = ps_cur_deblk_mb -> u1_mb_type | D_INTRA_MB ; { UWORD32 u4_bitstream_offset = * pu4_bitstrm_ofst ; UWORD32 u4_word , u4_ldz , u4_temp ; NEXTBITS_32 ( u4_word , u4_bitstream_offset , pu4_bitstrm_buf ) ; u4_ldz = CLZ ( u4_word ) ; u4_bitstream_offset += ( u4_ldz + 1 ) ; u4_word = 0 ; if ( u4_ldz ) GETBITS ( u4_word , u4_bitstream_offset , pu4_bitstrm_buf , u4_ldz ) ; * pu4_bitstrm_ofst = u4_bitstream_offset ; u4_temp = ( ( 1 << u4_ldz ) + u4_word - 1 ) ; if ( u4_temp > 25 ) return ERROR_MB_TYPE ; u1_mb_type = u4_temp ; } ps_cur_mb_info -> u1_mb_type = u1_mb_type ; COPYTHECONTEXT ( ""u1_mb_type"" , u1_mb_type ) ; if ( 25 == u1_mb_type ) { ps_cur_mb_info -> ps_curmb -> u1_mb_type = I_PCM_MB ; ret = ih264d_parse_ipcm_mb ( ps_dec , ps_cur_mb_info , u1_num_mbs ) ; if ( ret != OK ) return ret ; ps_cur_deblk_mb -> u1_mb_qp = 0 ; } else { ret = ih264d_parse_imb_cavlc ( ps_dec , ps_cur_mb_info , u1_num_mbs , u1_mb_type ) ; if ( ret != OK ) return ret ; 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 ++ ; uc_more_data_flag = MORE_RBSP_DATA ( ps_bitstrm ) ; { mv_pred_t * ps_mv_nmb_start = ps_dec -> ps_mv_cur + ( u1_num_mbs << 4 ) ; mv_pred_t s_mvPred = { { 0 , 0 , 0 , 0 } , { - 1 , - 1 } , 0 , 0 } ; ih264d_rep_mv_colz ( ps_dec , & s_mvPred , ps_mv_nmb_start , 0 , ( UWORD8 ) ( ps_dec -> u1_cur_mb_fld_dec_flag << 1 ) , 4 , 4 ) ; } if ( ps_dec -> u4_num_cores < 3 ) { if ( ps_dec -> u4_app_disable_deblk_frm == 0 ) ps_dec -> pf_compute_bs ( ps_dec , ps_cur_mb_info , ( UWORD16 ) ( u1_num_mbs >> u1_mbaff ) ) ; } u1_num_mbs ++ ; ps_dec -> u2_total_mbs_coded ++ ; 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_tfr_n_mb = ( u1_num_mbs == ps_dec -> u1_recon_mb_grp ) || u1_end_of_row || ( ! uc_more_data_flag ) ; ps_cur_mb_info -> u1_end_of_slice = ( ! uc_more_data_flag ) ; if ( u1_tfr_n_mb || ( ! uc_more_data_flag ) ) { 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 ) ; } if ( u1_tfr_n_mb ) u1_num_mbs = 0 ; u1_mb_idx = u1_num_mbs ; ps_dec -> u1_mb_idx = u1_num_mbs ; } } while ( uc_more_data_flag ) ; ps_dec -> u4_num_mbs_cur_nmb = 0 ; ps_dec -> ps_cur_slice -> u4_mbs_in_slice = i2_cur_mb_addr - ( u2_first_mb_in_slice << u1_mbaff ) ; return ret ; } "," u1_num_mbs ++ ; u1_num_mbs_next = i2_pic_wdin_mbs ) ; } ps_dec -> u2_total_mbs_coded += u1_num_mbs ; ",external@libavc/4a524d3a8ae9aa20c36430008e6bd429443f8f1d,CVE-2016-0816,https://android.googlesource.com/platform/external/libavc/+/4a524d3a8ae9aa20c36430008e6bd429443f8f1d,2016-03-12T21:59Z 1234,CWE-200,"CWE-200 int x25_negotiate_facilities ( struct sk_buff * skb , struct sock * sk , struct x25_facilities * new , struct x25_dte_facilities * dte ) { struct x25_sock * x25 = x25_sk ( sk ) ; struct x25_facilities * ours = & x25 -> facilities ; struct x25_facilities theirs ; int len ; memset ( & theirs , 0 , sizeof ( theirs ) ) ; memcpy ( new , ours , sizeof ( * new ) ) ; len = x25_parse_facilities ( skb , & theirs , dte , & x25 -> vc_facil_mask ) ; if ( len < 0 ) return len ; if ( ( theirs . reverse & 0x01 ) && ( ours -> reverse & 0x01 ) ) { SOCK_DEBUG ( sk , ""X.25:rejectingreversechargingrequest\\n"" ) ; return - 1 ; } new -> reverse = theirs . reverse ; if ( theirs . throughput ) { int theirs_in = theirs . throughput & 0x0f ; int theirs_out = theirs . throughput & 0xf0 ; int ours_in = ours -> throughput & 0x0f ; int ours_out = ours -> throughput & 0xf0 ; if ( ! ours_in || theirs_in < ours_in ) { SOCK_DEBUG ( sk , ""X.25:inboundthroughputnegotiated\\n"" ) ; new -> throughput = ( new -> throughput & 0xf0 ) | theirs_in ; } if ( ! ours_out || theirs_out < ours_out ) { SOCK_DEBUG ( sk , ""X.25:outboundthroughputnegotiated\\n"" ) ; new -> throughput = ( new -> throughput & 0x0f ) | theirs_out ; } } if ( theirs . pacsize_in && theirs . pacsize_out ) { if ( theirs . pacsize_in < ours -> pacsize_in ) { SOCK_DEBUG ( sk , ""X.25:packetsizeinwardsnegotiateddown\\n"" ) ; new -> pacsize_in = theirs . pacsize_in ; } if ( theirs . pacsize_out < ours -> pacsize_out ) { SOCK_DEBUG ( sk , ""X.25:packetsizeoutwardsnegotiateddown\\n"" ) ; new -> pacsize_out = theirs . pacsize_out ; } } if ( theirs . winsize_in && theirs . winsize_out ) { if ( theirs . winsize_in < ours -> winsize_in ) { SOCK_DEBUG ( sk , ""X.25:windowsizeinwardsnegotiateddown\\n"" ) ; new -> winsize_in = theirs . winsize_in ; } if ( theirs . winsize_out < ours -> winsize_out ) { SOCK_DEBUG ( sk , ""X.25:windowsizeoutwardsnegotiateddown\\n"" ) ; new -> winsize_out = theirs . winsize_out ; } } return len ; } "," ( * new ) ) ; memset ( dte , 0 , sizeof ( * dte ",torvalds@linux/79e48650320e6fba48369fccf13fd045315b19b8,CVE-2016-4580,https://github.com/torvalds/linux/commit/79e48650320e6fba48369fccf13fd045315b19b8,2016-05-23T10:59Z 1235,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 1236,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 1237,CWE-000,"CWE-000 int sqlite3Select ( Parse * pParse , Select * p , SelectDest * pDest ) { int i , j ; WhereInfo * pWInfo ; Vdbe * v ; int isAgg ; ExprList * pEList = 0 ; SrcList * pTabList ; Expr * pWhere ; ExprList * pGroupBy ; Expr * pHaving ; int rc = 1 ; DistinctCtx sDistinct ; SortCtx sSort ; AggInfo sAggInfo ; int iEnd ; sqlite3 * db ; ExprList * pMinMaxOrderBy = 0 ; u8 minMaxFlag ; db = pParse -> db ; v = sqlite3GetVdbe ( pParse ) ; if ( p == 0 || db -> mallocFailed || pParse -> nErr ) { return 1 ; } if ( sqlite3AuthCheck ( pParse , SQLITE_SELECT , 0 , 0 , 0 ) ) return 1 ; memset ( & sAggInfo , 0 , sizeof ( sAggInfo ) ) ; # if SELECTTRACE_ENABLED SELECTTRACE ( 1 , pParse , p , ( ""beginprocessing:\\n"" , pParse -> addrExplain ) ) ; if ( sqlite3SelectTrace & 0x100 ) { sqlite3TreeViewSelect ( 0 , p , 0 ) ; } # endif assert ( p -> pOrderBy == 0 || pDest -> eDest != SRT_DistFifo ) ; assert ( p -> pOrderBy == 0 || pDest -> eDest != SRT_Fifo ) ; assert ( p -> pOrderBy == 0 || pDest -> eDest != SRT_DistQueue ) ; assert ( p -> pOrderBy == 0 || pDest -> eDest != SRT_Queue ) ; if ( IgnorableOrderby ( pDest ) ) { assert ( pDest -> eDest == SRT_Exists || pDest -> eDest == SRT_Union || pDest -> eDest == SRT_Except || pDest -> eDest == SRT_Discard || pDest -> eDest == SRT_Queue || pDest -> eDest == SRT_DistFifo || pDest -> eDest == SRT_DistQueue || pDest -> eDest == SRT_Fifo ) ; sqlite3ExprListDelete ( db , p -> pOrderBy ) ; p -> pOrderBy = 0 ; p -> selFlags &= ~ SF_Distinct ; } sqlite3SelectPrep ( pParse , p , 0 ) ; if ( pParse -> nErr || db -> mallocFailed ) { goto select_end ; } assert ( p -> pEList != 0 ) ; # if SELECTTRACE_ENABLED if ( sqlite3SelectTrace & 0x104 ) { SELECTTRACE ( 0x104 , pParse , p , ( ""afternameresolution:\\n"" ) ) ; sqlite3TreeViewSelect ( 0 , p , 0 ) ; } # endif if ( pDest -> eDest == SRT_Output ) { generateColumnNames ( pParse , p ) ; } # ifndef SQLITE_OMIT_WINDOWFUNC if ( sqlite3WindowRewrite ( pParse , p ) ) { goto select_end ; } # if SELECTTRACE_ENABLED if ( p -> pWin && ( sqlite3SelectTrace & 0x108 ) != 0 ) { SELECTTRACE ( 0x104 , pParse , p , ( ""afterwindowrewrite:\\n"" ) ) ; sqlite3TreeViewSelect ( 0 , p , 0 ) ; } # endif # endif pTabList = p -> pSrc ; isAgg = ( p -> selFlags & SF_Aggregate ) != 0 ; memset ( & sSort , 0 , sizeof ( sSort ) ) ; sSort . pOrderBy = p -> pOrderBy ; # if ! defined ( SQLITE_OMIT_SUBQUERY ) || ! defined ( SQLITE_OMIT_VIEW ) for ( i = 0 ; ! p -> pPrior && i < pTabList -> nSrc ; i ++ ) { struct SrcList_item * pItem = & pTabList -> a [ i ] ; Select * pSub = pItem -> pSelect ; Table * pTab = pItem -> pTab ; if ( ( pItem -> fg . jointype & JT_LEFT ) != 0 && sqlite3ExprImpliesNonNullRow ( p -> pWhere , pItem -> iCursor ) && OptimizationEnabled ( db , SQLITE_SimplifyJoin ) ) { SELECTTRACE ( 0x100 , pParse , p , ( ""LEFT-JOINsimplifiestoJOINonterm%d\\n"" , i ) ) ; pItem -> fg . jointype &= ~ ( JT_LEFT | JT_OUTER ) ; unsetJoinExpr ( p -> pWhere , pItem -> iCursor ) ; } if ( pSub == 0 ) continue ; if ( pTab -> nCol != pSub -> pEList -> nExpr ) { sqlite3ErrorMsg ( pParse , ""expected%dcolumnsfor\'%s\'butgot%d"" , pTab -> nCol , pTab -> zName , pSub -> pEList -> nExpr ) ; goto select_end ; } if ( ( pSub -> selFlags & SF_Aggregate ) != 0 ) continue ; assert ( pSub -> pGroupBy == 0 ) ; if ( pSub -> pOrderBy != 0 && i == 0 && ( p -> selFlags & SF_ComplexResult ) != 0 && ( pTabList -> nSrc == 1 || ( pTabList -> a [ 1 ] . fg . jointype & ( JT_LEFT | JT_CROSS ) ) != 0 ) ) { continue ; } if ( flattenSubquery ( pParse , p , i , isAgg ) ) { if ( pParse -> nErr ) goto select_end ; i = - 1 ; } pTabList = p -> pSrc ; if ( db -> mallocFailed ) goto select_end ; if ( ! IgnorableOrderby ( pDest ) ) { sSort . pOrderBy = p -> pOrderBy ; } } # endif # ifndef SQLITE_OMIT_COMPOUND_SELECT if ( p -> pPrior ) { rc = multiSelect ( pParse , p , pDest ) ; # if SELECTTRACE_ENABLED SELECTTRACE ( 0x1 , pParse , p , ( ""endcompound-selectprocessing\\n"" ) ) ; if ( ( sqlite3SelectTrace & 0x2000 ) != 0 && ExplainQueryPlanParent ( pParse ) == 0 ) { sqlite3TreeViewSelect ( 0 , p , 0 ) ; } # endif if ( p -> pNext == 0 ) ExplainQueryPlanPop ( pParse ) ; return rc ; } # endif if ( pTabList -> nSrc > 1 && OptimizationEnabled ( db , SQLITE_PropagateConst ) && propagateConstants ( pParse , p ) ) { # if SELECTTRACE_ENABLED if ( sqlite3SelectTrace & 0x100 ) { SELECTTRACE ( 0x100 , pParse , p , ( ""Afterconstantpropagation:\\n"" ) ) ; sqlite3TreeViewSelect ( 0 , p , 0 ) ; } # endif } else { SELECTTRACE ( 0x100 , pParse , p , ( ""Constantpropagationnothelpful\\n"" ) ) ; } # ifdef SQLITE_COUNTOFVIEW_OPTIMIZATION if ( OptimizationEnabled ( db , SQLITE_QueryFlattener | SQLITE_CountOfView ) && countOfViewOptimization ( pParse , p ) ) { if ( db -> mallocFailed ) goto select_end ; pEList = p -> pEList ; pTabList = p -> pSrc ; } # endif for ( i = 0 ; i < pTabList -> nSrc ; i ++ ) { struct SrcList_item * pItem = & pTabList -> a [ i ] ; SelectDest dest ; Select * pSub ; # if ! defined ( SQLITE_OMIT_SUBQUERY ) || ! defined ( SQLITE_OMIT_VIEW ) const char * zSavedAuthContext ; # endif if ( pItem -> colUsed == 0 && pItem -> zName != 0 ) { sqlite3AuthCheck ( pParse , SQLITE_READ , pItem -> zName , """" , pItem -> zDatabase ) ; } # if ! defined ( SQLITE_OMIT_SUBQUERY ) || ! defined ( SQLITE_OMIT_VIEW ) pSub = pItem -> pSelect ; if ( pSub == 0 ) continue ; testcase ( pItem -> addrFillSub != 0 ) ; pParse -> nHeight += sqlite3SelectExprHeight ( p ) ; if ( OptimizationEnabled ( db , SQLITE_PushDown ) && pushDownWhereTerms ( pParse , pSub , p -> pWhere , pItem -> iCursor , ( pItem -> fg . jointype & JT_OUTER ) != 0 ) ) { # if SELECTTRACE_ENABLED if ( sqlite3SelectTrace & 0x100 ) { SELECTTRACE ( 0x100 , pParse , p , ( ""AfterWHERE-clausepush-downintosubquery%d:\\n"" , pSub -> selId ) ) ; sqlite3TreeViewSelect ( 0 , p , 0 ) ; } # endif } else { SELECTTRACE ( 0x100 , pParse , p , ( ""Push-downnotpossible\\n"" ) ) ; } zSavedAuthContext = pParse -> zAuthContext ; pParse -> zAuthContext = pItem -> zName ; if ( i == 0 && ( pTabList -> nSrc == 1 || ( pTabList -> a [ 1 ] . fg . jointype & ( JT_LEFT | JT_CROSS ) ) != 0 ) ) { int addrTop = sqlite3VdbeCurrentAddr ( v ) + 1 ; pItem -> regReturn = ++ pParse -> nMem ; sqlite3VdbeAddOp3 ( v , OP_InitCoroutine , pItem -> regReturn , 0 , addrTop ) ; VdbeComment ( ( v , ""%s"" , pItem -> pTab -> zName ) ) ; pItem -> addrFillSub = addrTop ; sqlite3SelectDestInit ( & dest , SRT_Coroutine , pItem -> regReturn ) ; ExplainQueryPlan ( ( pParse , 1 , ""CO-ROUTINE%u"" , pSub -> selId ) ) ; sqlite3Select ( pParse , pSub , & dest ) ; pItem -> pTab -> nRowLogEst = pSub -> nSelectRow ; pItem -> fg . viaCoroutine = 1 ; pItem -> regResult = dest . iSdst ; sqlite3VdbeEndCoroutine ( v , pItem -> regReturn ) ; sqlite3VdbeJumpHere ( v , addrTop - 1 ) ; sqlite3ClearTempRegCache ( pParse ) ; } else { int topAddr ; int onceAddr = 0 ; int retAddr ; struct SrcList_item * pPrior ; testcase ( pItem -> addrFillSub == 0 ) ; pItem -> regReturn = ++ pParse -> nMem ; topAddr = sqlite3VdbeAddOp2 ( v , OP_Integer , 0 , pItem -> regReturn ) ; pItem -> addrFillSub = topAddr + 1 ; if ( pItem -> fg . isCorrelated == 0 ) { onceAddr = sqlite3VdbeAddOp0 ( v , OP_Once ) ; VdbeCoverage ( v ) ; VdbeComment ( ( v , ""materialize\\""%s\\"""" , pItem -> pTab -> zName ) ) ; } else { VdbeNoopComment ( ( v , ""materialize\\""%s\\"""" , pItem -> pTab -> zName ) ) ; } pPrior = isSelfJoinView ( pTabList , pItem ) ; if ( pPrior ) { sqlite3VdbeAddOp2 ( v , OP_OpenDup , pItem -> iCursor , pPrior -> iCursor ) ; assert ( pPrior -> pSelect != 0 ) ; pSub -> nSelectRow = pPrior -> pSelect -> nSelectRow ; } else { sqlite3SelectDestInit ( & dest , SRT_EphemTab , pItem -> iCursor ) ; ExplainQueryPlan ( ( pParse , 1 , ""MATERIALIZE%u"" , pSub -> selId ) ) ; sqlite3Select ( pParse , pSub , & dest ) ; } pItem -> pTab -> nRowLogEst = pSub -> nSelectRow ; if ( onceAddr ) sqlite3VdbeJumpHere ( v , onceAddr ) ; retAddr = sqlite3VdbeAddOp1 ( v , OP_Return , pItem -> regReturn ) ; VdbeComment ( ( v , ""end%s"" , pItem -> pTab -> zName ) ) ; sqlite3VdbeChangeP1 ( v , topAddr , retAddr ) ; sqlite3ClearTempRegCache ( pParse ) ; } if ( db -> mallocFailed ) goto select_end ; pParse -> nHeight -= sqlite3SelectExprHeight ( p ) ; pParse -> zAuthContext = zSavedAuthContext ; # endif } pEList = p -> pEList ; pWhere = p -> pWhere ; pGroupBy = p -> pGroupBy ; pHaving = p -> pHaving ; sDistinct . isTnct = ( p -> selFlags & SF_Distinct ) != 0 ; # if SELECTTRACE_ENABLED if ( sqlite3SelectTrace & 0x400 ) { SELECTTRACE ( 0x400 , pParse , p , ( ""AfterallFROM-clauseanalysis:\\n"" ) ) ; sqlite3TreeViewSelect ( 0 , p , 0 ) ; } # endif if ( ( p -> selFlags & ( SF_Distinct | SF_Aggregate ) ) == SF_Distinct && sqlite3ExprListCompare ( sSort . pOrderBy , pEList , - 1 ) == 0 ) { p -> selFlags &= ~ SF_Distinct ; pGroupBy = p -> pGroupBy = sqlite3ExprListDup ( db , pEList , 0 ) ; assert ( sDistinct . isTnct ) ; # if SELECTTRACE_ENABLED if ( sqlite3SelectTrace & 0x400 ) { SELECTTRACE ( 0x400 , pParse , p , ( ""TransformDISTINCTintoGROUPBY:\\n"" ) ) ; sqlite3TreeViewSelect ( 0 , p , 0 ) ; } # endif } if ( sSort . pOrderBy ) { KeyInfo * pKeyInfo ; pKeyInfo = sqlite3KeyInfoFromExprList ( pParse , sSort . pOrderBy , 0 , pEList -> nExpr ) ; sSort . iECursor = pParse -> nTab ++ ; sSort . addrSortIndex = sqlite3VdbeAddOp4 ( v , OP_OpenEphemeral , sSort . iECursor , sSort . pOrderBy -> nExpr + 1 + pEList -> nExpr , 0 , ( char * ) pKeyInfo , P4_KEYINFO ) ; } else { sSort . addrSortIndex = - 1 ; } if ( pDest -> eDest == SRT_EphemTab ) { sqlite3VdbeAddOp2 ( v , OP_OpenEphemeral , pDest -> iSDParm , pEList -> nExpr ) ; } iEnd = sqlite3VdbeMakeLabel ( pParse ) ; if ( ( p -> selFlags & SF_FixedLimit ) == 0 ) { p -> nSelectRow = 320 ; } computeLimitRegisters ( pParse , p , iEnd ) ; if ( p -> iLimit == 0 && sSort . addrSortIndex >= 0 ) { sqlite3VdbeChangeOpcode ( v , sSort . addrSortIndex , OP_SorterOpen ) ; sSort . sortFlags |= SORTFLAG_UseSorter ; } if ( p -> selFlags & SF_Distinct ) { sDistinct . tabTnct = pParse -> nTab ++ ; sDistinct . addrTnct = sqlite3VdbeAddOp4 ( v , OP_OpenEphemeral , sDistinct . tabTnct , 0 , 0 , ( char * ) sqlite3KeyInfoFromExprList ( pParse , p -> pEList , 0 , 0 ) , P4_KEYINFO ) ; sqlite3VdbeChangeP5 ( v , BTREE_UNORDERED ) ; sDistinct . eTnctType = WHERE_DISTINCT_UNORDERED ; } else { sDistinct . eTnctType = WHERE_DISTINCT_NOOP ; } if ( ! isAgg && pGroupBy == 0 ) { u16 wctrlFlags = ( sDistinct . isTnct ? WHERE_WANT_DISTINCT : 0 ) | ( p -> selFlags & SF_FixedLimit ) ; # ifndef SQLITE_OMIT_WINDOWFUNC Window * pWin = p -> pWin ; if ( pWin ) { sqlite3WindowCodeInit ( pParse , pWin ) ; } # endif assert ( WHERE_USE_LIMIT == SF_FixedLimit ) ; SELECTTRACE ( 1 , pParse , p , ( ""WhereBegin\\n"" ) ) ; pWInfo = sqlite3WhereBegin ( pParse , pTabList , pWhere , sSort . pOrderBy , p -> pEList , wctrlFlags , p -> nSelectRow ) ; if ( pWInfo == 0 ) goto select_end ; if ( sqlite3WhereOutputRowCount ( pWInfo ) < p -> nSelectRow ) { p -> nSelectRow = sqlite3WhereOutputRowCount ( pWInfo ) ; } if ( sDistinct . isTnct && sqlite3WhereIsDistinct ( pWInfo ) ) { sDistinct . eTnctType = sqlite3WhereIsDistinct ( pWInfo ) ; } if ( sSort . pOrderBy ) { sSort . nOBSat = sqlite3WhereIsOrdered ( pWInfo ) ; sSort . labelOBLopt = sqlite3WhereOrderByLimitOptLabel ( pWInfo ) ; if ( sSort . nOBSat == sSort . pOrderBy -> nExpr ) { sSort . pOrderBy = 0 ; } } if ( sSort . addrSortIndex >= 0 && sSort . pOrderBy == 0 ) { sqlite3VdbeChangeToNoop ( v , sSort . addrSortIndex ) ; } assert ( p -> pEList == pEList ) ; # ifndef SQLITE_OMIT_WINDOWFUNC if ( pWin ) { int addrGosub = sqlite3VdbeMakeLabel ( pParse ) ; int iCont = sqlite3VdbeMakeLabel ( pParse ) ; int iBreak = sqlite3VdbeMakeLabel ( pParse ) ; int regGosub = ++ pParse -> nMem ; sqlite3WindowCodeStep ( pParse , p , pWInfo , regGosub , addrGosub ) ; sqlite3VdbeAddOp2 ( v , OP_Goto , 0 , iBreak ) ; sqlite3VdbeResolveLabel ( v , addrGosub ) ; VdbeNoopComment ( ( v , ""inner-loopsubroutine"" ) ) ; sSort . labelOBLopt = 0 ; selectInnerLoop ( pParse , p , - 1 , & sSort , & sDistinct , pDest , iCont , iBreak ) ; sqlite3VdbeResolveLabel ( v , iCont ) ; sqlite3VdbeAddOp1 ( v , OP_Return , regGosub ) ; VdbeComment ( ( v , ""endinner-loopsubroutine"" ) ) ; sqlite3VdbeResolveLabel ( v , iBreak ) ; } else # endif { selectInnerLoop ( pParse , p , - 1 , & sSort , & sDistinct , pDest , sqlite3WhereContinueLabel ( pWInfo ) , sqlite3WhereBreakLabel ( pWInfo ) ) ; sqlite3WhereEnd ( pWInfo ) ; } } else { NameContext sNC ; int iAMem ; int iBMem ; int iUseFlag ; int iAbortFlag ; int groupBySort ; int addrEnd ; int sortPTab = 0 ; int sortOut = 0 ; int orderByGrp = 0 ; if ( pGroupBy ) { int k ; struct ExprList_item * pItem ; for ( k = p -> pEList -> nExpr , pItem = p -> pEList -> a ; k > 0 ; k -- , pItem ++ ) { pItem -> u . x . iAlias = 0 ; } for ( k = pGroupBy -> nExpr , pItem = pGroupBy -> a ; k > 0 ; k -- , pItem ++ ) { pItem -> u . x . iAlias = 0 ; } assert ( 66 == sqlite3LogEst ( 100 ) ) ; if ( p -> nSelectRow > 66 ) p -> nSelectRow = 66 ; if ( sSort . pOrderBy && pGroupBy -> nExpr == sSort . pOrderBy -> nExpr ) { int ii ; for ( ii = 0 ; ii < pGroupBy -> nExpr ; ii ++ ) { u8 sortFlags = sSort . pOrderBy -> a [ ii ] . sortFlags & KEYINFO_ORDER_DESC ; pGroupBy -> a [ ii ] . sortFlags = sortFlags ; } if ( sqlite3ExprListCompare ( pGroupBy , sSort . pOrderBy , - 1 ) == 0 ) { orderByGrp = 1 ; } } } else { assert ( 0 == sqlite3LogEst ( 1 ) ) ; p -> nSelectRow = 0 ; } addrEnd = sqlite3VdbeMakeLabel ( pParse ) ; memset ( & sNC , 0 , sizeof ( sNC ) ) ; sNC . pParse = pParse ; sNC . pSrcList = pTabList ; sNC . uNC . pAggInfo = & sAggInfo ; VVA_ONLY ( sNC . ncFlags = NC_UAggInfo ; ) sAggInfo . mnReg = pParse -> nMem + 1 ; sAggInfo . nSortingColumn = pGroupBy ? pGroupBy -> nExpr : 0 ; sAggInfo . pGroupBy = pGroupBy ; sqlite3ExprAnalyzeAggList ( & sNC , pEList ) ; sqlite3ExprAnalyzeAggList ( & sNC , sSort . pOrderBy ) ; if ( pHaving ) { if ( pGroupBy ) { assert ( pWhere == p -> pWhere ) ; assert ( pHaving == p -> pHaving ) ; assert ( pGroupBy == p -> pGroupBy ) ; havingToWhere ( pParse , p ) ; pWhere = p -> pWhere ; } sqlite3ExprAnalyzeAggregates ( & sNC , pHaving ) ; } sAggInfo . nAccumulator = sAggInfo . nColumn ; if ( p -> pGroupBy == 0 && p -> pHaving == 0 && sAggInfo . nFunc == 1 ) { minMaxFlag = minMaxQuery ( db , sAggInfo . aFunc [ 0 ] . pExpr , & pMinMaxOrderBy ) ; } else { minMaxFlag = WHERE_ORDERBY_NORMAL ; } for ( i = 0 ; i < sAggInfo . nFunc ; i ++ ) { Expr * pExpr = sAggInfo . aFunc [ i ] . pExpr ; assert ( ! ExprHasProperty ( pExpr , EP_xIsSelect ) ) ; sNC . ncFlags |= NC_InAggFunc ; sqlite3ExprAnalyzeAggList ( & sNC , pExpr -> x . pList ) ; # ifndef SQLITE_OMIT_WINDOWFUNC assert ( ! IsWindowFunc ( pExpr ) ) ; if ( ExprHasProperty ( pExpr , EP_WinFunc ) ) { sqlite3ExprAnalyzeAggregates ( & sNC , pExpr -> y . pWin -> pFilter ) ; } # endif sNC . ncFlags &= ~ NC_InAggFunc ; } sAggInfo . mxReg = pParse -> nMem ; if ( db -> mallocFailed ) goto select_end ; # if SELECTTRACE_ENABLED if ( sqlite3SelectTrace & 0x400 ) { int ii ; SELECTTRACE ( 0x400 , pParse , p , ( ""Afteraggregateanalysis:\\n"" ) ) ; sqlite3TreeViewSelect ( 0 , p , 0 ) ; for ( ii = 0 ; ii < sAggInfo . nColumn ; ii ++ ) { sqlite3DebugPrintf ( ""agg-column[%d]iMem=%d\\n"" , ii , sAggInfo . aCol [ ii ] . iMem ) ; sqlite3TreeViewExpr ( 0 , sAggInfo . aCol [ ii ] . pExpr , 0 ) ; } for ( ii = 0 ; ii < sAggInfo . nFunc ; ii ++ ) { sqlite3DebugPrintf ( ""agg-func[%d]:iMem=%d\\n"" , ii , sAggInfo . aFunc [ ii ] . iMem ) ; sqlite3TreeViewExpr ( 0 , sAggInfo . aFunc [ ii ] . pExpr , 0 ) ; } } # endif if ( pGroupBy ) { KeyInfo * pKeyInfo ; int addr1 ; int addrOutputRow ; int regOutputRow ; int addrSetAbort ; int addrTopOfLoop ; int addrSortingIdx ; int addrReset ; int regReset ; sAggInfo . sortingIdx = pParse -> nTab ++ ; pKeyInfo = sqlite3KeyInfoFromExprList ( pParse , pGroupBy , 0 , sAggInfo . nColumn ) ; addrSortingIdx = sqlite3VdbeAddOp4 ( v , OP_SorterOpen , sAggInfo . sortingIdx , sAggInfo . nSortingColumn , 0 , ( char * ) pKeyInfo , P4_KEYINFO ) ; iUseFlag = ++ pParse -> nMem ; iAbortFlag = ++ pParse -> nMem ; regOutputRow = ++ pParse -> nMem ; addrOutputRow = sqlite3VdbeMakeLabel ( pParse ) ; regReset = ++ pParse -> nMem ; addrReset = sqlite3VdbeMakeLabel ( pParse ) ; iAMem = pParse -> nMem + 1 ; pParse -> nMem += pGroupBy -> nExpr ; iBMem = pParse -> nMem + 1 ; pParse -> nMem += pGroupBy -> nExpr ; sqlite3VdbeAddOp2 ( v , OP_Integer , 0 , iAbortFlag ) ; VdbeComment ( ( v , ""clearabortflag"" ) ) ; sqlite3VdbeAddOp3 ( v , OP_Null , 0 , iAMem , iAMem + pGroupBy -> nExpr - 1 ) ; sqlite3VdbeAddOp2 ( v , OP_Gosub , regReset , addrReset ) ; SELECTTRACE ( 1 , pParse , p , ( ""WhereBegin\\n"" ) ) ; pWInfo = sqlite3WhereBegin ( pParse , pTabList , pWhere , pGroupBy , 0 , WHERE_GROUPBY | ( orderByGrp ? WHERE_SORTBYGROUP : 0 ) , 0 ) ; if ( pWInfo == 0 ) goto select_end ; if ( sqlite3WhereIsOrdered ( pWInfo ) == pGroupBy -> nExpr ) { groupBySort = 0 ; } else { int regBase ; int regRecord ; int nCol ; int nGroupBy ; explainTempTable ( pParse , ( sDistinct . isTnct && ( p -> selFlags & SF_Distinct ) == 0 ) ? ""DISTINCT"" : ""GROUPBY"" ) ; groupBySort = 1 ; nGroupBy = pGroupBy -> nExpr ; nCol = nGroupBy ; j = nGroupBy ; for ( i = 0 ; i < sAggInfo . nColumn ; i ++ ) { if ( sAggInfo . aCol [ i ] . iSorterColumn >= j ) { nCol ++ ; j ++ ; } } regBase = sqlite3GetTempRange ( pParse , nCol ) ; sqlite3ExprCodeExprList ( pParse , pGroupBy , regBase , 0 , 0 ) ; j = nGroupBy ; for ( i = 0 ; i < sAggInfo . nColumn ; i ++ ) { struct AggInfo_col * pCol = & sAggInfo . aCol [ i ] ; if ( pCol -> iSorterColumn >= j ) { int r1 = j + regBase ; sqlite3ExprCodeGetColumnOfTable ( v , pCol -> pTab , pCol -> iTable , pCol -> iColumn , r1 ) ; j ++ ; } } regRecord = sqlite3GetTempReg ( pParse ) ; sqlite3VdbeAddOp3 ( v , OP_MakeRecord , regBase , nCol , regRecord ) ; sqlite3VdbeAddOp2 ( v , OP_SorterInsert , sAggInfo . sortingIdx , regRecord ) ; sqlite3ReleaseTempReg ( pParse , regRecord ) ; sqlite3ReleaseTempRange ( pParse , regBase , nCol ) ; sqlite3WhereEnd ( pWInfo ) ; sAggInfo . sortingIdxPTab = sortPTab = pParse -> nTab ++ ; sortOut = sqlite3GetTempReg ( pParse ) ; sqlite3VdbeAddOp3 ( v , OP_OpenPseudo , sortPTab , sortOut , nCol ) ; sqlite3VdbeAddOp2 ( v , OP_SorterSort , sAggInfo . sortingIdx , addrEnd ) ; VdbeComment ( ( v , ""GROUPBYsort"" ) ) ; VdbeCoverage ( v ) ; sAggInfo . useSortingIdx = 1 ; } if ( orderByGrp && OptimizationEnabled ( db , SQLITE_GroupByOrder ) && ( groupBySort || sqlite3WhereIsSorted ( pWInfo ) ) ) { sSort . pOrderBy = 0 ; sqlite3VdbeChangeToNoop ( v , sSort . addrSortIndex ) ; } addrTopOfLoop = sqlite3VdbeCurrentAddr ( v ) ; if ( groupBySort ) { sqlite3VdbeAddOp3 ( v , OP_SorterData , sAggInfo . sortingIdx , sortOut , sortPTab ) ; } for ( j = 0 ; j < pGroupBy -> nExpr ; j ++ ) { if ( groupBySort ) { sqlite3VdbeAddOp3 ( v , OP_Column , sortPTab , j , iBMem + j ) ; } else { sAggInfo . directMode = 1 ; sqlite3ExprCode ( pParse , pGroupBy -> a [ j ] . pExpr , iBMem + j ) ; } } sqlite3VdbeAddOp4 ( v , OP_Compare , iAMem , iBMem , pGroupBy -> nExpr , ( char * ) sqlite3KeyInfoRef ( pKeyInfo ) , P4_KEYINFO ) ; addr1 = sqlite3VdbeCurrentAddr ( v ) ; sqlite3VdbeAddOp3 ( v , OP_Jump , addr1 + 1 , 0 , addr1 + 1 ) ; VdbeCoverage ( v ) ; sqlite3ExprCodeMove ( pParse , iBMem , iAMem , pGroupBy -> nExpr ) ; sqlite3VdbeAddOp2 ( v , OP_Gosub , regOutputRow , addrOutputRow ) ; VdbeComment ( ( v , ""outputonerow"" ) ) ; sqlite3VdbeAddOp2 ( v , OP_IfPos , iAbortFlag , addrEnd ) ; VdbeCoverage ( v ) ; VdbeComment ( ( v , ""checkabortflag"" ) ) ; sqlite3VdbeAddOp2 ( v , OP_Gosub , regReset , addrReset ) ; VdbeComment ( ( v , ""resetaccumulator"" ) ) ; sqlite3VdbeJumpHere ( v , addr1 ) ; updateAccumulator ( pParse , iUseFlag , & sAggInfo ) ; sqlite3VdbeAddOp2 ( v , OP_Integer , 1 , iUseFlag ) ; VdbeComment ( ( v , ""indicatedatainaccumulator"" ) ) ; if ( groupBySort ) { sqlite3VdbeAddOp2 ( v , OP_SorterNext , sAggInfo . sortingIdx , addrTopOfLoop ) ; VdbeCoverage ( v ) ; } else { sqlite3WhereEnd ( pWInfo ) ; sqlite3VdbeChangeToNoop ( v , addrSortingIdx ) ; } sqlite3VdbeAddOp2 ( v , OP_Gosub , regOutputRow , addrOutputRow ) ; VdbeComment ( ( v , ""outputfinalrow"" ) ) ; sqlite3VdbeGoto ( v , addrEnd ) ; addrSetAbort = sqlite3VdbeCurrentAddr ( v ) ; sqlite3VdbeAddOp2 ( v , OP_Integer , 1 , iAbortFlag ) ; VdbeComment ( ( v , ""setabortflag"" ) ) ; sqlite3VdbeAddOp1 ( v , OP_Return , regOutputRow ) ; sqlite3VdbeResolveLabel ( v , addrOutputRow ) ; addrOutputRow = sqlite3VdbeCurrentAddr ( v ) ; sqlite3VdbeAddOp2 ( v , OP_IfPos , iUseFlag , addrOutputRow + 2 ) ; VdbeCoverage ( v ) ; VdbeComment ( ( v , ""Groupbyresultgeneratorentrypoint"" ) ) ; sqlite3VdbeAddOp1 ( v , OP_Return , regOutputRow ) ; finalizeAggFunctions ( pParse , & sAggInfo ) ; sqlite3ExprIfFalse ( pParse , pHaving , addrOutputRow + 1 , SQLITE_JUMPIFNULL ) ; selectInnerLoop ( pParse , p , - 1 , & sSort , & sDistinct , pDest , addrOutputRow + 1 , addrSetAbort ) ; sqlite3VdbeAddOp1 ( v , OP_Return , regOutputRow ) ; VdbeComment ( ( v , ""endgroupbyresultgenerator"" ) ) ; sqlite3VdbeResolveLabel ( v , addrReset ) ; resetAccumulator ( pParse , & sAggInfo ) ; sqlite3VdbeAddOp2 ( v , OP_Integer , 0 , iUseFlag ) ; VdbeComment ( ( v , ""indicateaccumulatorempty"" ) ) ; sqlite3VdbeAddOp1 ( v , OP_Return , regReset ) ; } else { # ifndef SQLITE_OMIT_BTREECOUNT Table * pTab ; if ( ( pTab = isSimpleCount ( p , & sAggInfo ) ) != 0 ) { const int iDb = sqlite3SchemaToIndex ( pParse -> db , pTab -> pSchema ) ; const int iCsr = pParse -> nTab ++ ; Index * pIdx ; KeyInfo * pKeyInfo = 0 ; Index * pBest = 0 ; int iRoot = pTab -> tnum ; sqlite3CodeVerifySchema ( pParse , iDb ) ; sqlite3TableLock ( pParse , iDb , pTab -> tnum , 0 , pTab -> zName ) ; if ( ! HasRowid ( pTab ) ) pBest = sqlite3PrimaryKeyIndex ( pTab ) ; for ( pIdx = pTab -> pIndex ; pIdx ; pIdx = pIdx -> pNext ) { if ( pIdx -> bUnordered == 0 && pIdx -> szIdxRow < pTab -> szTabRow && pIdx -> pPartIdxWhere == 0 && ( ! pBest || pIdx -> szIdxRow < pBest -> szIdxRow ) ) { pBest = pIdx ; } } if ( pBest ) { iRoot = pBest -> tnum ; pKeyInfo = sqlite3KeyInfoOfIndex ( pParse , pBest ) ; } sqlite3VdbeAddOp4Int ( v , OP_OpenRead , iCsr , iRoot , iDb , 1 ) ; if ( pKeyInfo ) { sqlite3VdbeChangeP4 ( v , - 1 , ( char * ) pKeyInfo , P4_KEYINFO ) ; } sqlite3VdbeAddOp2 ( v , OP_Count , iCsr , sAggInfo . aFunc [ 0 ] . iMem ) ; sqlite3VdbeAddOp1 ( v , OP_Close , iCsr ) ; explainSimpleCount ( pParse , pTab , pBest ) ; } else # endif { int regAcc = 0 ; if ( sAggInfo . nAccumulator ) { for ( i = 0 ; i < sAggInfo . nFunc ; i ++ ) { if ( ExprHasProperty ( sAggInfo . aFunc [ i ] . pExpr , EP_WinFunc ) ) continue ; if ( sAggInfo . aFunc [ i ] . pFunc -> funcFlags & SQLITE_FUNC_NEEDCOLL ) break ; } if ( i == sAggInfo . nFunc ) { regAcc = ++ pParse -> nMem ; sqlite3VdbeAddOp2 ( v , OP_Integer , 0 , regAcc ) ; } } assert ( p -> pGroupBy == 0 ) ; resetAccumulator ( pParse , & sAggInfo ) ; assert ( minMaxFlag == WHERE_ORDERBY_NORMAL || pMinMaxOrderBy != 0 ) ; assert ( pMinMaxOrderBy == 0 || pMinMaxOrderBy -> nExpr == 1 ) ; SELECTTRACE ( 1 , pParse , p , ( ""WhereBegin\\n"" ) ) ; pWInfo = sqlite3WhereBegin ( pParse , pTabList , pWhere , pMinMaxOrderBy , 0 , minMaxFlag , 0 ) ; if ( pWInfo == 0 ) { goto select_end ; } updateAccumulator ( pParse , regAcc , & sAggInfo ) ; if ( regAcc ) sqlite3VdbeAddOp2 ( v , OP_Integer , 1 , regAcc ) ; if ( sqlite3WhereIsOrdered ( pWInfo ) > 0 ) { sqlite3VdbeGoto ( v , sqlite3WhereBreakLabel ( pWInfo ) ) ; VdbeComment ( ( v , ""%s()byindex"" , ( minMaxFlag == WHERE_ORDERBY_MIN ? ""min"" : ""max"" ) ) ) ; } sqlite3WhereEnd ( pWInfo ) ; finalizeAggFunctions ( pParse , & sAggInfo ) ; } sSort . pOrderBy = 0 ; sqlite3ExprIfFalse ( pParse , pHaving , addrEnd , SQLITE_JUMPIFNULL ) ; selectInnerLoop ( pParse , p , - 1 , 0 , 0 , pDest , addrEnd , addrEnd ) ; } sqlite3VdbeResolveLabel ( v , addrEnd ) ; } if ( sDistinct . eTnctType == WHERE_DISTINCT_UNORDERED ) { explainTempTable ( pParse , ""DISTINCT"" ) ; } if ( sSort . pOrderBy ) { explainTempTable ( pParse , sSort . nOBSat > 0 ? ""RIGHTPARTOFORDERBY"" : ""ORDERBY"" ) ; assert ( p -> pEList == pEList ) ; generateSortTail ( pParse , p , & sSort , pEList -> nExpr , pDest ) ; } sqlite3VdbeResolveLabel ( v , iEnd ) ; rc = ( pParse -> nErr > 0 ) ; select_end : sqlite3ExprListDelete ( db , pMinMaxOrderBy ) ; sqlite3DbFree ( db , sAggInfo . aCol ) ; sqlite3DbFree ( db , sAggInfo . aFunc ) ; # if SELECTTRACE_ENABLED SELECTTRACE ( 0x1 , pParse , p , ( ""endprocessing\\n"" ) ) ; if ( ( sqlite3SelectTrace & 0x2000 ) != 0 && ExplainQueryPlanParent ( pParse ) == 0 ) { sqlite3TreeViewSelect ( 0 , p , 0 ) ; } # endif ExplainQueryPlanPop ( pParse ) ; return rc ; } "," ) == 0 && p -> pWin == 0 ",sqlite@sqlite/e59c562b3f6894f84c715772c4b116d7b5c01348,CVE-2019-19244,https://github.com/sqlite/sqlite/commit/e59c562b3f6894f84c715772c4b116d7b5c01348,2019-11-25T20:15Z 1238,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 1239,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 1240,CWE-89,"CWE-89 static CURLcode imap_parse_url_path ( struct connectdata * conn ) { struct imap_conn * imapc = & conn -> proto . imapc ; struct SessionHandle * data = conn -> data ; const char * path = data -> state . path ; int len ; if ( ! * path ) path = ""INBOX"" ; imapc -> mailbox = curl_easy_unescape ( data , path , 0 , & len ) ; if ( ! imapc -> mailbox ) return CURLE_OUT_OF_MEMORY ; return CURLE_OK ; } "," . path ; if ( ! = ""INBOX"" ; return Curl_urldecode ( data , 0 , & imapc -> mailbox imapc -> mailbox , NULL , TRUE ) ; } ",bagder@curl/75ca568fa1c19de4c5358fed246686de8467c238,CVE-2012-0036,https://github.com/bagder/curl/commit/75ca568fa1c19de4c5358fed246686de8467c238,2012-04-13T20:55Z 1241,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 1242,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 1243,CWE-119,"CWE-119 void vp9_cyclic_refresh_update_segment ( VP9_COMP * const cpi , MB_MODE_INFO * const mbmi , int mi_row , int mi_col , BLOCK_SIZE bsize , int use_rd ) { const VP9_COMMON * const cm = & cpi -> common ; CYCLIC_REFRESH * const cr = cpi -> cyclic_refresh ; const int bw = num_8x8_blocks_wide_lookup [ bsize ] ; const int bh = num_8x8_blocks_high_lookup [ bsize ] ; const int xmis = MIN ( cm -> mi_cols - mi_col , bw ) ; const int ymis = MIN ( cm -> mi_rows - mi_row , bh ) ; const int block_index = mi_row * cm -> mi_cols + mi_col ; const int refresh_this_block = candidate_refresh_aq ( cr , mbmi , bsize , use_rd ) ; int new_map_value = cr -> map [ block_index ] ; int x = 0 ; int y = 0 ; if ( mbmi -> segment_id > 0 && ! refresh_this_block ) mbmi -> segment_id = 0 ; if ( mbmi -> segment_id == 1 ) { new_map_value = - cr -> time_for_refresh ; } else if ( refresh_this_block ) { if ( cr -> map [ block_index ] == 1 ) new_map_value = 0 ; } else { new_map_value = 1 ; } for ( y = 0 ; y < ymis ; y ++ ) for ( x = 0 ; x < xmis ; x ++ ) { cr -> map [ block_index + y * cm -> mi_cols + x ] = new_map_value ; cpi -> segmentation_map [ block_index + y * cm -> mi_cols + x ] = mbmi -> segment_id ; } if ( mbmi -> segment_id ) cr -> num_seg_blocks += xmis * ymis ; } "," BLOCK_SIZE bsize , int64_t rate , int64_t dist , int skip ) { const , mbmi , rate , dist , bsize ) ; int ; if ( cyclic_refresh_segment_id_boosted ( mbmi -> segment_id ) ) { mbmi -> segment_id = refresh_this_block ; if ( skip ) mbmi -> segment_id = CR_SEGMENT_ID_BASE ; } if ( cyclic_refresh_segment_id_boosted ( mbmi -> segment_id ) ) { new_map_value = - cr -> time_for_refresh ; } else if ( refresh_this_block ) { if ( cr -> map [ block_index ] == 1 ) == 1 ) new_map_value = 0 ++ ) { int map_offset = block_index + y mi_cols + x ; cr -> map [ map_offset -> segmentation_map [ map_offset ] = mbmi -> segment_id ; if ( ! is_inter_block ( mbmi ) || ! skip ) cr -> last_coded_q_map [ map_offset ] = clamp ( cm -> base_qindex + cr -> qindex_delta [ mbmi -> segment_id ] , 0 , MAXQ ) ; } } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1244,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 1245,CWE-264,"CWE-264 struct tcp_sock_t * tcp_open ( uint16_t port ) { struct tcp_sock_t * this = calloc ( 1 , sizeof * this ) ; if ( this == NULL ) { ERR ( ""callocingthisfailed"" ) ; goto error ; } this -> sd = - 1 ; this -> sd = socket ( AF_INET6 , SOCK_STREAM , 0 ) ; if ( this -> sd < 0 ) { ERR ( ""sockectopenfailed"" ) ; goto error ; } struct sockaddr_in6 addr ; memset ( & addr , 0 , sizeof addr ) ; addr . sin6_family = AF_INET6 ; addr . sin6_port = htons ( port ) ; addr . sin6_addr = in6addr_any ; if ( bind ( this -> sd , ( struct sockaddr * ) & addr , sizeof addr ) < 0 ) { if ( g_options . only_desired_port == 1 ) ERR ( ""Bindonportfailed."" ""Requestedportmaybetakenorrequirerootpermissions."" ) ; goto error ; } if ( listen ( this -> sd , HTTP_MAX_PENDING_CONNS ) < 0 ) { ERR ( ""listenfailedonsocket"" ) ; goto error ; } return this ; error : if ( this != NULL ) { if ( this -> sd != - 1 ) { close ( this -> sd ) ; } free ( this ) ; } return NULL ; } "," { ERR ( ""IPv4:callocingthisfailed"" ) ; goto = socket ( AF_INET , SOCK_STREAM , { ERR ( ""IPv4socketopenfailed"" ) ; goto error ; } struct sockaddr_in addr ; memset ; addr . sin_family = AF_INET ; addr . sin_port = htons ( ; addr . sin_addr . s_addr = htonl ( 0x7F000001 ) ; if ( ) ERR ( ""IPv4bindonportfailed."" ""Requestedportmaybetakenorrequirerootpermissions."" ) ; { ERR ( ""IPv4listenfailedonsocket"" ) ; goto ",tillkamppeter@ippusbxd/46844402bca7a38fc224483ba6f0a93c4613203f,CVE-2015-6520,https://github.com/tillkamppeter/ippusbxd/commit/46844402bca7a38fc224483ba6f0a93c4613203f,2015-09-01T14:59Z 1246,CWE-20,"CWE-20 void freeClient ( redisClient * c ) { listNode * ln ; sdsfree ( c -> querybuf ) ; c -> querybuf = NULL ; if ( c -> flags & REDIS_BLOCKED ) unblockClientWaitingData ( c ) ; unwatchAllKeys ( c ) ; listRelease ( c -> watched_keys ) ; pubsubUnsubscribeAllChannels ( c , 0 ) ; pubsubUnsubscribeAllPatterns ( c , 0 ) ; dictRelease ( c -> pubsub_channels ) ; listRelease ( c -> pubsub_patterns ) ; aeDeleteFileEvent ( server . el , c -> fd , AE_READABLE ) ; aeDeleteFileEvent ( server . el , c -> fd , AE_WRITABLE ) ; listRelease ( c -> reply ) ; freeClientArgv ( c ) ; close ( c -> fd ) ; ln = listSearchKey ( server . clients , c ) ; redisAssert ( ln != NULL ) ; listDelNode ( server . clients , ln ) ; if ( c -> flags & REDIS_IO_WAIT ) { redisAssert ( server . vm_enabled ) ; if ( listLength ( c -> io_keys ) == 0 ) { ln = listSearchKey ( server . io_ready_clients , c ) ; redisAssert ( ln != NULL ) ; listDelNode ( server . io_ready_clients , ln ) ; } else { while ( listLength ( c -> io_keys ) ) { ln = listFirst ( c -> io_keys ) ; dontWaitForSwappedKey ( c , ln -> value ) ; } } server . vm_blocked_clients -- ; } listRelease ( c -> io_keys ) ; if ( c -> flags & REDIS_SLAVE ) { if ( c -> replstate == REDIS_REPL_SEND_BULK && c -> repldbfd != - 1 ) close ( c -> repldbfd ) ; list * l = ( c -> flags & REDIS_MONITOR ) ? server . monitors : server . slaves ; ln = listSearchKey ( l , c ) ; redisAssert ( ln != NULL ) ; listDelNode ( l , ln ) ; } if ( c -> flags & REDIS_MASTER ) { server . master = NULL ; server . replstate = REDIS_REPL_CONNECT ; while ( listLength ( server . slaves ) ) { ln = listFirst ( server . slaves ) ; freeClient ( ( redisClient * ) ln -> value ) ; } } zfree ( c -> argv ) ; freeClientMultiState ( c ) ; zfree ( c ) ; } "," ( server . ds_enabled ) ; if } server . cache_blocked_clients -- ; } ",antirez@redis/697af434fbeb2e3ba2ba9687cd283ed1a2734fa5,CVE-2013-0178,https://github.com/antirez/redis/commit/697af434fbeb2e3ba2ba9687cd283ed1a2734fa5,2019-11-01T19:15Z 1247,CWE-189,"CWE-189 void oz_hcd_get_desc_cnf ( void * hport , u8 req_id , int status , const u8 * desc , int length , int offset , int total_size ) { struct oz_port * port = hport ; struct urb * urb ; int err = 0 ; oz_dbg ( ON , ""oz_hcd_get_desc_cnflength=%doffs=%dtot_size=%d\\n"" , length , offset , total_size ) ; urb = oz_find_urb_by_id ( port , 0 , req_id ) ; if ( ! urb ) return ; if ( status == 0 ) { int copy_len ; int required_size = urb -> transfer_buffer_length ; if ( required_size > total_size ) required_size = total_size ; copy_len = required_size - offset ; if ( length <= copy_len ) copy_len = length ; memcpy ( urb -> transfer_buffer + offset , desc , copy_len ) ; offset += copy_len ; if ( offset < required_size ) { struct usb_ctrlrequest * setup = ( struct usb_ctrlrequest * ) urb -> setup_packet ; unsigned wvalue = le16_to_cpu ( setup -> wValue ) ; if ( oz_enqueue_ep_urb ( port , 0 , 0 , urb , req_id ) ) err = - ENOMEM ; else if ( oz_usb_get_desc_req ( port -> hpd , req_id , setup -> bRequestType , ( u8 ) ( wvalue >> 8 ) , ( u8 ) wvalue , setup -> wIndex , offset , required_size - offset ) ) { oz_dequeue_ep_urb ( port , 0 , 0 , urb ) ; err = - ENOMEM ; } if ( err == 0 ) return ; } } urb -> actual_length = total_size ; oz_complete_urb ( port -> ozhcd -> hcd , urb , 0 ) ; } "," u8 req_id , u8 status , const * desc , u8 length , u16 offset , u16 total_size ) { 0 ) { unsigned int copy_len ; unsigned ",torvalds@linux/b1bb5b49373b61bf9d2c73a4d30058ba6f069e4c,CVE-2015-4001,https://github.com/torvalds/linux/commit/b1bb5b49373b61bf9d2c73a4d30058ba6f069e4c,2015-06-07T23:59Z 1248,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 1249,CWE-20,"CWE-20 int HTMLtagproc1 ( struct parsed_tag * tag , struct html_feed_environ * h_env ) { char * p , * q , * r ; int i , w , x , y , z , count , width ; struct readbuffer * obuf = h_env -> obuf ; struct environment * envs = h_env -> envs ; Str tmp ; int hseq ; int cmd ; # ifdef ID_EXT char * id = NULL ; # endif cmd = tag -> tagid ; if ( obuf -> flag & RB_PRE ) { switch ( cmd ) { case HTML_NOBR : case HTML_N_NOBR : case HTML_PRE_INT : case HTML_N_PRE_INT : return 1 ; } } switch ( cmd ) { case HTML_B : obuf -> in_bold ++ ; if ( obuf -> in_bold > 1 ) return 1 ; return 0 ; case HTML_N_B : if ( obuf -> in_bold == 1 && close_effect0 ( obuf , HTML_B ) ) obuf -> in_bold = 0 ; if ( obuf -> in_bold > 0 ) { obuf -> in_bold -- ; if ( obuf -> in_bold == 0 ) return 0 ; } return 1 ; case HTML_I : obuf -> in_italic ++ ; if ( obuf -> in_italic > 1 ) return 1 ; return 0 ; case HTML_N_I : if ( obuf -> in_italic == 1 && close_effect0 ( obuf , HTML_I ) ) obuf -> in_italic = 0 ; if ( obuf -> in_italic > 0 ) { obuf -> in_italic -- ; if ( obuf -> in_italic == 0 ) return 0 ; } return 1 ; case HTML_U : obuf -> in_under ++ ; if ( obuf -> in_under > 1 ) return 1 ; return 0 ; case HTML_N_U : if ( obuf -> in_under == 1 && close_effect0 ( obuf , HTML_U ) ) obuf -> in_under = 0 ; if ( obuf -> in_under > 0 ) { obuf -> in_under -- ; if ( obuf -> in_under == 0 ) return 0 ; } return 1 ; case HTML_EM : HTMLlineproc1 ( """" , h_env ) ; return 1 ; case HTML_N_EM : HTMLlineproc1 ( """" , h_env ) ; return 1 ; case HTML_STRONG : HTMLlineproc1 ( """" , h_env ) ; return 1 ; case HTML_N_STRONG : HTMLlineproc1 ( """" , h_env ) ; return 1 ; case HTML_Q : HTMLlineproc1 ( ""`"" , h_env ) ; return 1 ; case HTML_N_Q : HTMLlineproc1 ( ""\'"" , h_env ) ; return 1 ; case HTML_P : case HTML_N_P : CLOSE_A ; if ( ! ( obuf -> flag & RB_IGNORE_P ) ) { flushline ( h_env , obuf , envs [ h_env -> envc ] . indent , 1 , h_env -> limit ) ; do_blankline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; } obuf -> flag |= RB_IGNORE_P ; if ( cmd == HTML_P ) { set_alignment ( obuf , tag ) ; obuf -> flag |= RB_P ; } return 1 ; case HTML_BR : flushline ( h_env , obuf , envs [ h_env -> envc ] . indent , 1 , h_env -> limit ) ; h_env -> blank_lines = 0 ; return 1 ; case HTML_H : if ( ! ( obuf -> flag & ( RB_PREMODE | RB_IGNORE_P ) ) ) { flushline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; do_blankline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; } HTMLlineproc1 ( """" , h_env ) ; set_alignment ( obuf , tag ) ; return 1 ; case HTML_N_H : HTMLlineproc1 ( """" , h_env ) ; if ( ! ( obuf -> flag & RB_PREMODE ) ) { flushline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; } do_blankline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; RB_RESTORE_FLAG ( obuf ) ; close_anchor ( h_env , obuf ) ; obuf -> flag |= RB_IGNORE_P ; return 1 ; case HTML_UL : case HTML_OL : case HTML_BLQ : CLOSE_A ; if ( ! ( obuf -> flag & RB_IGNORE_P ) ) { flushline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; if ( ! ( obuf -> flag & RB_PREMODE ) && ( h_env -> envc == 0 || cmd == HTML_BLQ ) ) do_blankline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; } PUSH_ENV ( cmd ) ; if ( cmd == HTML_UL || cmd == HTML_OL ) { if ( parsedtag_get_value ( tag , ATTR_START , & count ) ) { envs [ h_env -> envc ] . count = count - 1 ; } } if ( cmd == HTML_OL ) { envs [ h_env -> envc ] . type = '1' ; if ( parsedtag_get_value ( tag , ATTR_TYPE , & p ) ) { envs [ h_env -> envc ] . type = ( int ) * p ; } } if ( cmd == HTML_UL ) envs [ h_env -> envc ] . type = ul_type ( tag , 0 ) ; flushline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; return 1 ; case HTML_N_UL : case HTML_N_OL : case HTML_N_DL : case HTML_N_BLQ : CLOSE_DT ; CLOSE_A ; if ( h_env -> envc > 0 ) { flushline ( h_env , obuf , envs [ h_env -> envc - 1 ] . indent , 0 , h_env -> limit ) ; POP_ENV ; if ( ! ( obuf -> flag & RB_PREMODE ) && ( h_env -> envc == 0 || cmd == HTML_N_DL || cmd == HTML_N_BLQ ) ) { do_blankline ( h_env , obuf , envs [ h_env -> envc ] . indent , INDENT_INCR , h_env -> limit ) ; obuf -> flag |= RB_IGNORE_P ; } } close_anchor ( h_env , obuf ) ; return 1 ; case HTML_DL : CLOSE_A ; if ( ! ( obuf -> flag & RB_IGNORE_P ) ) { flushline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; if ( ! ( obuf -> flag & RB_PREMODE ) ) do_blankline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; } PUSH_ENV ( cmd ) ; if ( parsedtag_exists ( tag , ATTR_COMPACT ) ) envs [ h_env -> envc ] . env = HTML_DL_COMPACT ; obuf -> flag |= RB_IGNORE_P ; return 1 ; case HTML_LI : CLOSE_A ; CLOSE_DT ; if ( h_env -> envc > 0 ) { Str num ; flushline ( h_env , obuf , envs [ h_env -> envc - 1 ] . indent , 0 , h_env -> limit ) ; envs [ h_env -> envc ] . count ++ ; if ( parsedtag_get_value ( tag , ATTR_VALUE , & p ) ) { count = atoi ( p ) ; if ( count > 0 ) envs [ h_env -> envc ] . count = count ; else envs [ h_env -> envc ] . count = 0 ; } switch ( envs [ h_env -> envc ] . env ) { case HTML_UL : envs [ h_env -> envc ] . type = ul_type ( tag , envs [ h_env -> envc ] . type ) ; for ( i = 0 ; i < INDENT_INCR - 3 ; i ++ ) push_charp ( obuf , 1 , NBSP , PC_ASCII ) ; tmp = Strnew ( ) ; switch ( envs [ h_env -> envc ] . type ) { case 'd' : push_symbol ( tmp , UL_SYMBOL_DISC , symbol_width , 1 ) ; break ; case 'c' : push_symbol ( tmp , UL_SYMBOL_CIRCLE , symbol_width , 1 ) ; break ; case 's' : push_symbol ( tmp , UL_SYMBOL_SQUARE , symbol_width , 1 ) ; break ; default : push_symbol ( tmp , UL_SYMBOL ( ( h_env -> envc_real - 1 ) % MAX_UL_LEVEL ) , symbol_width , 1 ) ; break ; } if ( symbol_width == 1 ) push_charp ( obuf , 1 , NBSP , PC_ASCII ) ; push_str ( obuf , symbol_width , tmp , PC_ASCII ) ; push_charp ( obuf , 1 , NBSP , PC_ASCII ) ; set_space_to_prevchar ( obuf -> prevchar ) ; break ; case HTML_OL : if ( parsedtag_get_value ( tag , ATTR_TYPE , & p ) ) envs [ h_env -> envc ] . type = ( int ) * p ; switch ( ( envs [ h_env -> envc ] . count > 0 ) ? envs [ h_env -> envc ] . type : '1' ) { case 'i' : num = romanNumeral ( envs [ h_env -> envc ] . count ) ; break ; case 'I' : num = romanNumeral ( envs [ h_env -> envc ] . count ) ; Strupper ( num ) ; break ; case 'a' : num = romanAlphabet ( envs [ h_env -> envc ] . count ) ; break ; case 'A' : num = romanAlphabet ( envs [ h_env -> envc ] . count ) ; Strupper ( num ) ; break ; default : num = Sprintf ( ""%d"" , envs [ h_env -> envc ] . count ) ; break ; } if ( INDENT_INCR >= 4 ) Strcat_charp ( num , ""."" ) ; else Strcat_char ( num , '.' ) ; push_spaces ( obuf , 1 , INDENT_INCR - num -> length ) ; push_str ( obuf , num -> length , num , PC_ASCII ) ; if ( INDENT_INCR >= 4 ) set_space_to_prevchar ( obuf -> prevchar ) ; break ; default : push_spaces ( obuf , 1 , INDENT_INCR ) ; break ; } } else { flushline ( h_env , obuf , 0 , 0 , h_env -> limit ) ; } obuf -> flag |= RB_IGNORE_P ; return 1 ; case HTML_DT : CLOSE_A ; if ( h_env -> envc == 0 || ( h_env -> envc_real < h_env -> nenv && envs [ h_env -> envc ] . env != HTML_DL && envs [ h_env -> envc ] . env != HTML_DL_COMPACT ) ) { PUSH_ENV ( HTML_DL ) ; } if ( h_env -> envc > 0 ) { flushline ( h_env , obuf , envs [ h_env -> envc - 1 ] . indent , 0 , h_env -> limit ) ; } if ( ! ( obuf -> flag & RB_IN_DT ) ) { HTMLlineproc1 ( """" , h_env ) ; obuf -> flag |= RB_IN_DT ; } obuf -> flag |= RB_IGNORE_P ; return 1 ; case HTML_DD : CLOSE_A ; CLOSE_DT ; if ( envs [ h_env -> envc ] . env == HTML_DL_COMPACT ) { if ( obuf -> pos > envs [ h_env -> envc ] . indent ) flushline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; else push_spaces ( obuf , 1 , envs [ h_env -> envc ] . indent - obuf -> pos ) ; } else flushline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; return 1 ; case HTML_TITLE : close_anchor ( h_env , obuf ) ; process_title ( tag ) ; obuf -> flag |= RB_TITLE ; obuf -> end_tag = HTML_N_TITLE ; return 1 ; case HTML_N_TITLE : if ( ! ( obuf -> flag & RB_TITLE ) ) return 1 ; obuf -> flag &= ~ RB_TITLE ; obuf -> end_tag = 0 ; tmp = process_n_title ( tag ) ; if ( tmp ) HTMLlineproc1 ( tmp -> ptr , h_env ) ; return 1 ; case HTML_TITLE_ALT : if ( parsedtag_get_value ( tag , ATTR_TITLE , & p ) ) h_env -> title = html_unquote ( p ) ; return 0 ; case HTML_FRAMESET : PUSH_ENV ( cmd ) ; push_charp ( obuf , 9 , ""--FRAME--"" , PC_ASCII ) ; flushline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; return 0 ; case HTML_N_FRAMESET : if ( h_env -> envc > 0 ) { POP_ENV ; flushline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; } return 0 ; case HTML_NOFRAMES : CLOSE_A ; flushline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; obuf -> flag |= ( RB_NOFRAMES | RB_IGNORE_P ) ; return 1 ; case HTML_N_NOFRAMES : CLOSE_A ; flushline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; obuf -> flag &= ~ RB_NOFRAMES ; return 1 ; case HTML_FRAME : q = r = NULL ; parsedtag_get_value ( tag , ATTR_SRC , & q ) ; parsedtag_get_value ( tag , ATTR_NAME , & r ) ; if ( q ) { q = html_quote ( q ) ; push_tag ( obuf , Sprintf ( ""hseq=\\""%d\\""href=\\""%s\\"">"" , cur_hseq ++ , q ) -> ptr , HTML_A ) ; if ( r ) q = html_quote ( r ) ; push_charp ( obuf , get_strwidth ( q ) , q , PC_ASCII ) ; push_tag ( obuf , """" , HTML_N_A ) ; } flushline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; return 0 ; case HTML_HR : close_anchor ( h_env , obuf ) ; tmp = process_hr ( tag , h_env -> limit , envs [ h_env -> envc ] . indent ) ; HTMLlineproc1 ( tmp -> ptr , h_env ) ; set_space_to_prevchar ( obuf -> prevchar ) ; return 1 ; case HTML_PRE : x = parsedtag_exists ( tag , ATTR_FOR_TABLE ) ; CLOSE_A ; if ( ! ( obuf -> flag & RB_IGNORE_P ) ) { flushline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; if ( ! x ) do_blankline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; } else fillline ( obuf , envs [ h_env -> envc ] . indent ) ; obuf -> flag |= ( RB_PRE | RB_IGNORE_P ) ; return 1 ; case HTML_N_PRE : flushline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; if ( ! ( obuf -> flag & RB_IGNORE_P ) ) { do_blankline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; obuf -> flag |= RB_IGNORE_P ; h_env -> blank_lines ++ ; } obuf -> flag &= ~ RB_PRE ; close_anchor ( h_env , obuf ) ; return 1 ; case HTML_PRE_INT : i = obuf -> line -> length ; append_tags ( obuf ) ; if ( ! ( obuf -> flag & RB_SPECIAL ) ) { set_breakpoint ( obuf , obuf -> line -> length - i ) ; } obuf -> flag |= RB_PRE_INT ; return 0 ; case HTML_N_PRE_INT : push_tag ( obuf , """" , HTML_N_PRE_INT ) ; obuf -> flag &= ~ RB_PRE_INT ; if ( ! ( obuf -> flag & RB_SPECIAL ) && obuf -> pos > obuf -> bp . pos ) { set_prevchar ( obuf -> prevchar , """" , 0 ) ; obuf -> prev_ctype = PC_CTRL ; } return 1 ; case HTML_NOBR : obuf -> flag |= RB_NOBR ; obuf -> nobr_level ++ ; return 0 ; case HTML_N_NOBR : if ( obuf -> nobr_level > 0 ) obuf -> nobr_level -- ; if ( obuf -> nobr_level == 0 ) obuf -> flag &= ~ RB_NOBR ; return 0 ; case HTML_PRE_PLAIN : CLOSE_A ; if ( ! ( obuf -> flag & RB_IGNORE_P ) ) { flushline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; do_blankline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; } obuf -> flag |= ( RB_PRE | RB_IGNORE_P ) ; return 1 ; case HTML_N_PRE_PLAIN : CLOSE_A ; if ( ! ( obuf -> flag & RB_IGNORE_P ) ) { flushline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; do_blankline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; obuf -> flag |= RB_IGNORE_P ; } obuf -> flag &= ~ RB_PRE ; return 1 ; case HTML_LISTING : case HTML_XMP : case HTML_PLAINTEXT : CLOSE_A ; if ( ! ( obuf -> flag & RB_IGNORE_P ) ) { flushline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; do_blankline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; } obuf -> flag |= ( RB_PLAIN | RB_IGNORE_P ) ; switch ( cmd ) { case HTML_LISTING : obuf -> end_tag = HTML_N_LISTING ; break ; case HTML_XMP : obuf -> end_tag = HTML_N_XMP ; break ; case HTML_PLAINTEXT : obuf -> end_tag = MAX_HTMLTAG ; break ; } return 1 ; case HTML_N_LISTING : case HTML_N_XMP : CLOSE_A ; if ( ! ( obuf -> flag & RB_IGNORE_P ) ) { flushline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; do_blankline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; obuf -> flag |= RB_IGNORE_P ; } obuf -> flag &= ~ RB_PLAIN ; obuf -> end_tag = 0 ; return 1 ; case HTML_SCRIPT : obuf -> flag |= RB_SCRIPT ; obuf -> end_tag = HTML_N_SCRIPT ; return 1 ; case HTML_STYLE : obuf -> flag |= RB_STYLE ; obuf -> end_tag = HTML_N_STYLE ; return 1 ; case HTML_N_SCRIPT : obuf -> flag &= ~ RB_SCRIPT ; obuf -> end_tag = 0 ; return 1 ; case HTML_N_STYLE : obuf -> flag &= ~ RB_STYLE ; obuf -> end_tag = 0 ; return 1 ; case HTML_A : if ( obuf -> anchor . url ) close_anchor ( h_env , obuf ) ; hseq = 0 ; if ( parsedtag_get_value ( tag , ATTR_HREF , & p ) ) obuf -> anchor . url = Strnew_charp ( p ) -> ptr ; if ( parsedtag_get_value ( tag , ATTR_TARGET , & p ) ) obuf -> anchor . target = Strnew_charp ( p ) -> ptr ; if ( parsedtag_get_value ( tag , ATTR_REFERER , & p ) ) obuf -> anchor . referer = Strnew_charp ( p ) -> ptr ; if ( parsedtag_get_value ( tag , ATTR_TITLE , & p ) ) obuf -> anchor . title = Strnew_charp ( p ) -> ptr ; if ( parsedtag_get_value ( tag , ATTR_ACCESSKEY , & p ) ) obuf -> anchor . accesskey = ( unsigned char ) * p ; if ( parsedtag_get_value ( tag , ATTR_HSEQ , & hseq ) ) obuf -> anchor . hseq = hseq ; if ( hseq == 0 && obuf -> anchor . url ) { obuf -> anchor . hseq = cur_hseq ; tmp = process_anchor ( tag , h_env -> tagbuf -> ptr ) ; push_tag ( obuf , tmp -> ptr , HTML_A ) ; if ( displayLinkNumber ) HTMLlineproc1 ( getLinkNumberStr ( - 1 ) -> ptr , h_env ) ; return 1 ; } return 0 ; case HTML_N_A : close_anchor ( h_env , obuf ) ; return 1 ; case HTML_IMG : tmp = process_img ( tag , h_env -> limit ) ; HTMLlineproc1 ( tmp -> ptr , h_env ) ; return 1 ; case HTML_IMG_ALT : if ( parsedtag_get_value ( tag , ATTR_SRC , & p ) ) obuf -> img_alt = Strnew_charp ( p ) ; # ifdef USE_IMAGE i = 0 ; if ( parsedtag_get_value ( tag , ATTR_TOP_MARGIN , & i ) ) { if ( i > obuf -> top_margin ) obuf -> top_margin = i ; } i = 0 ; if ( parsedtag_get_value ( tag , ATTR_BOTTOM_MARGIN , & i ) ) { if ( i > obuf -> bottom_margin ) obuf -> bottom_margin = i ; } # endif return 0 ; case HTML_N_IMG_ALT : if ( obuf -> img_alt ) { if ( ! close_effect0 ( obuf , HTML_IMG_ALT ) ) push_tag ( obuf , """" , HTML_N_IMG_ALT ) ; obuf -> img_alt = NULL ; } return 1 ; case HTML_INPUT_ALT : i = 0 ; if ( parsedtag_get_value ( tag , ATTR_TOP_MARGIN , & i ) ) { if ( i > obuf -> top_margin ) obuf -> top_margin = i ; } i = 0 ; if ( parsedtag_get_value ( tag , ATTR_BOTTOM_MARGIN , & i ) ) { if ( i > obuf -> bottom_margin ) obuf -> bottom_margin = i ; } if ( parsedtag_get_value ( tag , ATTR_HSEQ , & hseq ) ) { obuf -> input_alt . hseq = hseq ; } if ( parsedtag_get_value ( tag , ATTR_FID , & i ) ) { obuf -> input_alt . fid = i ; } if ( parsedtag_get_value ( tag , ATTR_TYPE , & p ) ) { obuf -> input_alt . type = Strnew_charp ( p ) ; } if ( parsedtag_get_value ( tag , ATTR_VALUE , & p ) ) { obuf -> input_alt . value = Strnew_charp ( p ) ; } if ( parsedtag_get_value ( tag , ATTR_NAME , & p ) ) { obuf -> input_alt . name = Strnew_charp ( p ) ; } obuf -> input_alt . in = 1 ; return 0 ; case HTML_N_INPUT_ALT : if ( obuf -> input_alt . in ) { if ( ! close_effect0 ( obuf , HTML_INPUT_ALT ) ) push_tag ( obuf , """" , HTML_N_INPUT_ALT ) ; obuf -> input_alt . hseq = 0 ; obuf -> input_alt . fid = - 1 ; obuf -> input_alt . in = 0 ; obuf -> input_alt . type = NULL ; obuf -> input_alt . name = NULL ; obuf -> input_alt . value = NULL ; } return 1 ; case HTML_TABLE : close_anchor ( h_env , obuf ) ; obuf -> table_level ++ ; if ( obuf -> table_level >= MAX_TABLE ) break ; w = BORDER_NONE ; x = 2 ; y = 1 ; z = 0 ; width = 0 ; if ( parsedtag_exists ( tag , ATTR_BORDER ) ) { if ( parsedtag_get_value ( tag , ATTR_BORDER , & w ) ) { if ( w > 2 ) w = BORDER_THICK ; else if ( w < 0 ) { w = BORDER_THIN ; } } else w = BORDER_THIN ; } if ( DisplayBorders && w == BORDER_NONE ) w = BORDER_THIN ; if ( parsedtag_get_value ( tag , ATTR_WIDTH , & i ) ) { if ( obuf -> table_level == 0 ) width = REAL_WIDTH ( i , h_env -> limit - envs [ h_env -> envc ] . indent ) ; else width = RELATIVE_WIDTH ( i ) ; } if ( parsedtag_exists ( tag , ATTR_HBORDER ) ) w = BORDER_NOWIN ; # define MAX_CELLSPACING 1000 # define MAX_CELLPADDING 1000 # define MAX_VSPACE 1000 parsedtag_get_value ( tag , ATTR_CELLSPACING , & x ) ; parsedtag_get_value ( tag , ATTR_CELLPADDING , & y ) ; parsedtag_get_value ( tag , ATTR_VSPACE , & z ) ; if ( x > MAX_CELLSPACING ) x = MAX_CELLSPACING ; if ( y > MAX_CELLPADDING ) y = MAX_CELLPADDING ; if ( z > MAX_VSPACE ) z = MAX_VSPACE ; # ifdef ID_EXT parsedtag_get_value ( tag , ATTR_ID , & id ) ; # endif tables [ obuf -> table_level ] = begin_table ( w , x , y , z ) ; # ifdef ID_EXT if ( id != NULL ) tables [ obuf -> table_level ] -> id = Strnew_charp ( id ) ; # endif table_mode [ obuf -> table_level ] . pre_mode = 0 ; table_mode [ obuf -> table_level ] . indent_level = 0 ; table_mode [ obuf -> table_level ] . nobr_level = 0 ; table_mode [ obuf -> table_level ] . caption = 0 ; table_mode [ obuf -> table_level ] . end_tag = 0 ; # ifndef TABLE_EXPAND tables [ obuf -> table_level ] -> total_width = width ; # else tables [ obuf -> table_level ] -> real_width = width ; tables [ obuf -> table_level ] -> total_width = 0 ; # endif return 1 ; case HTML_N_TABLE : return 1 ; case HTML_CENTER : CLOSE_A ; if ( ! ( obuf -> flag & ( RB_PREMODE | RB_IGNORE_P ) ) ) flushline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; RB_SAVE_FLAG ( obuf ) ; RB_SET_ALIGN ( obuf , RB_CENTER ) ; return 1 ; case HTML_N_CENTER : CLOSE_A ; if ( ! ( obuf -> flag & RB_PREMODE ) ) flushline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; RB_RESTORE_FLAG ( obuf ) ; return 1 ; case HTML_DIV : CLOSE_A ; if ( ! ( obuf -> flag & RB_IGNORE_P ) ) flushline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; set_alignment ( obuf , tag ) ; return 1 ; case HTML_N_DIV : CLOSE_A ; flushline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; RB_RESTORE_FLAG ( obuf ) ; return 1 ; case HTML_DIV_INT : CLOSE_P ; if ( ! ( obuf -> flag & RB_IGNORE_P ) ) flushline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; set_alignment ( obuf , tag ) ; return 1 ; case HTML_N_DIV_INT : CLOSE_P ; flushline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; RB_RESTORE_FLAG ( obuf ) ; return 1 ; case HTML_FORM : CLOSE_A ; if ( ! ( obuf -> flag & RB_IGNORE_P ) ) flushline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; tmp = process_form ( tag ) ; if ( tmp ) HTMLlineproc1 ( tmp -> ptr , h_env ) ; return 1 ; case HTML_N_FORM : CLOSE_A ; flushline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; obuf -> flag |= RB_IGNORE_P ; process_n_form ( ) ; return 1 ; case HTML_INPUT : close_anchor ( h_env , obuf ) ; tmp = process_input ( tag ) ; if ( tmp ) HTMLlineproc1 ( tmp -> ptr , h_env ) ; return 1 ; case HTML_BUTTON : tmp = process_button ( tag ) ; if ( tmp ) HTMLlineproc1 ( tmp -> ptr , h_env ) ; return 1 ; case HTML_N_BUTTON : tmp = process_n_button ( ) ; if ( tmp ) HTMLlineproc1 ( tmp -> ptr , h_env ) ; return 1 ; case HTML_SELECT : close_anchor ( h_env , obuf ) ; tmp = process_select ( tag ) ; if ( tmp ) HTMLlineproc1 ( tmp -> ptr , h_env ) ; obuf -> flag |= RB_INSELECT ; obuf -> end_tag = HTML_N_SELECT ; return 1 ; case HTML_N_SELECT : obuf -> flag &= ~ RB_INSELECT ; obuf -> end_tag = 0 ; tmp = process_n_select ( ) ; if ( tmp ) HTMLlineproc1 ( tmp -> ptr , h_env ) ; return 1 ; case HTML_OPTION : return 1 ; case HTML_TEXTAREA : close_anchor ( h_env , obuf ) ; tmp = process_textarea ( tag , h_env -> limit ) ; if ( tmp ) HTMLlineproc1 ( tmp -> ptr , h_env ) ; obuf -> flag |= RB_INTXTA ; obuf -> end_tag = HTML_N_TEXTAREA ; return 1 ; case HTML_N_TEXTAREA : obuf -> flag &= ~ RB_INTXTA ; obuf -> end_tag = 0 ; tmp = process_n_textarea ( ) ; if ( tmp ) HTMLlineproc1 ( tmp -> ptr , h_env ) ; return 1 ; case HTML_ISINDEX : p = """" ; q = ""!CURRENT_URL!"" ; parsedtag_get_value ( tag , ATTR_PROMPT , & p ) ; parsedtag_get_value ( tag , ATTR_ACTION , & q ) ; tmp = Strnew_m_charp ( ""method=getaction=\\"""" , html_quote ( q ) , ""\\"">"" , html_quote ( p ) , ""type=textname=\\""\\""accept>"" , NULL ) ; HTMLlineproc1 ( tmp -> ptr , h_env ) ; return 1 ; case HTML_META : p = q = r = NULL ; parsedtag_get_value ( tag , ATTR_HTTP_EQUIV , & p ) ; parsedtag_get_value ( tag , ATTR_CONTENT , & q ) ; # ifdef USE_M17N parsedtag_get_value ( tag , ATTR_CHARSET , & r ) ; if ( r ) { SKIP_BLANKS ( r ) ; meta_charset = wc_guess_charset ( r , 0 ) ; } else if ( p && q && ! strcasecmp ( p , ""Content-Type"" ) && ( q = strcasestr ( q , ""charset"" ) ) != NULL ) { q += 7 ; SKIP_BLANKS ( q ) ; if ( * q == '=' ) { q ++ ; SKIP_BLANKS ( q ) ; meta_charset = wc_guess_charset ( q , 0 ) ; } } else # endif if ( p && q && ! strcasecmp ( p , ""refresh"" ) ) { int refresh_interval ; tmp = NULL ; refresh_interval = getMetaRefreshParam ( q , & tmp ) ; if ( tmp ) { q = html_quote ( tmp -> ptr ) ; tmp = Sprintf ( ""Refresh(%dsec)href=\\""%s\\"">%s"" , refresh_interval , q , q ) ; } else if ( refresh_interval > 0 ) tmp = Sprintf ( ""Refresh(%dsec)"" , refresh_interval ) ; if ( tmp ) { HTMLlineproc1 ( tmp -> ptr , h_env ) ; do_blankline ( h_env , obuf , envs [ h_env -> envc ] . indent , 0 , h_env -> limit ) ; if ( ! is_redisplay && ! ( ( obuf -> flag & RB_NOFRAMES ) && RenderFrame ) ) { tag -> need_reconstruct = TRUE ; return 0 ; } } } return 1 ; case HTML_BASE : # if defined ( USE_M17N ) || defined ( USE_IMAGE ) p = NULL ; if ( parsedtag_get_value ( tag , ATTR_HREF , & p ) ) { cur_baseURL = New ( ParsedURL ) ; parseURL ( p , cur_baseURL , NULL ) ; } # endif case HTML_MAP : case HTML_N_MAP : case HTML_AREA : return 0 ; case HTML_DEL : switch ( displayInsDel ) { case DISPLAY_INS_DEL_SIMPLE : obuf -> flag |= RB_DEL ; break ; case DISPLAY_INS_DEL_NORMAL : HTMLlineproc1 ( ""[DEL:"" , h_env ) ; break ; case DISPLAY_INS_DEL_FONTIFY : obuf -> in_strike ++ ; if ( obuf -> in_strike == 1 ) { push_tag ( obuf , """" , HTML_S ) ; } break ; } return 1 ; case HTML_N_DEL : switch ( displayInsDel ) { case DISPLAY_INS_DEL_SIMPLE : obuf -> flag &= ~ RB_DEL ; break ; case DISPLAY_INS_DEL_NORMAL : HTMLlineproc1 ( "":DEL]"" , h_env ) ; case DISPLAY_INS_DEL_FONTIFY : if ( obuf -> in_strike == 0 ) return 1 ; if ( obuf -> in_strike == 1 && close_effect0 ( obuf , HTML_S ) ) obuf -> in_strike = 0 ; if ( obuf -> in_strike > 0 ) { obuf -> in_strike -- ; if ( obuf -> in_strike == 0 ) { push_tag ( obuf , """" , HTML_N_S ) ; } } break ; } return 1 ; case HTML_S : switch ( displayInsDel ) { case DISPLAY_INS_DEL_SIMPLE : obuf -> flag |= RB_S ; break ; case DISPLAY_INS_DEL_NORMAL : HTMLlineproc1 ( ""[S:"" , h_env ) ; break ; case DISPLAY_INS_DEL_FONTIFY : obuf -> in_strike ++ ; if ( obuf -> in_strike == 1 ) { push_tag ( obuf , """" , HTML_S ) ; } break ; } return 1 ; case HTML_N_S : switch ( displayInsDel ) { case DISPLAY_INS_DEL_SIMPLE : obuf -> flag &= ~ RB_S ; break ; case DISPLAY_INS_DEL_NORMAL : HTMLlineproc1 ( "":S]"" , h_env ) ; break ; case DISPLAY_INS_DEL_FONTIFY : if ( obuf -> in_strike == 0 ) return 1 ; if ( obuf -> in_strike == 1 && close_effect0 ( obuf , HTML_S ) ) obuf -> in_strike = 0 ; if ( obuf -> in_strike > 0 ) { obuf -> in_strike -- ; if ( obuf -> in_strike == 0 ) { push_tag ( obuf , """" , HTML_N_S ) ; } } } return 1 ; case HTML_INS : switch ( displayInsDel ) { case DISPLAY_INS_DEL_SIMPLE : break ; case DISPLAY_INS_DEL_NORMAL : HTMLlineproc1 ( ""[INS:"" , h_env ) ; break ; case DISPLAY_INS_DEL_FONTIFY : obuf -> in_ins ++ ; if ( obuf -> in_ins == 1 ) { push_tag ( obuf , """" , HTML_INS ) ; } break ; } return 1 ; case HTML_N_INS : switch ( displayInsDel ) { case DISPLAY_INS_DEL_SIMPLE : break ; case DISPLAY_INS_DEL_NORMAL : HTMLlineproc1 ( "":INS]"" , h_env ) ; break ; case DISPLAY_INS_DEL_FONTIFY : if ( obuf -> in_ins == 0 ) return 1 ; if ( obuf -> in_ins == 1 && close_effect0 ( obuf , HTML_INS ) ) obuf -> in_ins = 0 ; if ( obuf -> in_ins > 0 ) { obuf -> in_ins -- ; if ( obuf -> in_ins == 0 ) { push_tag ( obuf , """" , HTML_N_INS ) ; } } break ; } return 1 ; case HTML_SUP : if ( ! ( obuf -> flag & ( RB_DEL | RB_S ) ) ) HTMLlineproc1 ( ""^"" , h_env ) ; return 1 ; case HTML_N_SUP : return 1 ; case HTML_SUB : if ( ! ( obuf -> flag & ( RB_DEL | RB_S ) ) ) HTMLlineproc1 ( ""["" , h_env ) ; return 1 ; case HTML_N_SUB : if ( ! ( obuf -> flag & ( RB_DEL | RB_S ) ) ) HTMLlineproc1 ( ""]"" , h_env ) ; return 1 ; case HTML_FONT : case HTML_N_FONT : case HTML_NOP : return 1 ; case HTML_BGSOUND : if ( view_unseenobject ) { if ( parsedtag_get_value ( tag , ATTR_SRC , & p ) ) { Str s ; q = html_quote ( p ) ; s = Sprintf ( ""HREF=\\""%s\\"">bgsound(%s)"" , q , q ) ; HTMLlineproc1 ( s -> ptr , h_env ) ; } } return 1 ; case HTML_EMBED : if ( view_unseenobject ) { if ( parsedtag_get_value ( tag , ATTR_SRC , & p ) ) { Str s ; q = html_quote ( p ) ; s = Sprintf ( ""HREF=\\""%s\\"">embed(%s)"" , q , q ) ; HTMLlineproc1 ( s -> ptr , h_env ) ; } } return 1 ; case HTML_APPLET : if ( view_unseenobject ) { if ( parsedtag_get_value ( tag , ATTR_ARCHIVE , & p ) ) { Str s ; q = html_quote ( p ) ; s = Sprintf ( ""HREF=\\""%s\\"">appletarchive(%s)"" , q , q ) ; HTMLlineproc1 ( s -> ptr , h_env ) ; } } return 1 ; case HTML_BODY : if ( view_unseenobject ) { if ( parsedtag_get_value ( tag , ATTR_BACKGROUND , & p ) ) { Str s ; q = html_quote ( p ) ; s = Sprintf ( ""SRC=\\""%s\\""ALT=\\""bgimage(%s)\\"">
"" , q , q ) ; HTMLlineproc1 ( s -> ptr , h_env ) ; } } case HTML_N_HEAD : if ( obuf -> flag & RB_TITLE ) HTMLlineproc1 ( """" , h_env ) ; case HTML_HEAD : case HTML_N_BODY : return 1 ; default : return 0 ; } return 0 ; } "," ; if ( h_env -> envc == 0 || ( h_env -> envc_real < h_env -> nenv && envs [ h_env -> envc ] . env != HTML_DL && envs [ h_env -> envc ] . env != HTML_DL_COMPACT ) ) { PUSH_ENV ( HTML_DL ) ; } if ( ",tats@w3m/33509cc81ec5f2ba44eb6fd98bd5c1b5873e46bd,CVE-2016-9436,https://github.com/tats/w3m/commit/33509cc81ec5f2ba44eb6fd98bd5c1b5873e46bd,2017-01-20T15:59Z 1250,CWE-476,"CWE-476 static int sd_isoc_init ( struct gspca_dev * gspca_dev ) { struct usb_host_interface * alt ; int max_packet_size ; switch ( gspca_dev -> pixfmt . width ) { case 160 : max_packet_size = 450 ; break ; case 176 : max_packet_size = 600 ; break ; default : max_packet_size = 1022 ; break ; } alt = & gspca_dev -> dev -> actconfig -> intf_cache [ 0 ] -> altsetting [ 1 ] ; alt -> endpoint [ 0 ] . desc . wMaxPacketSize = cpu_to_le16 ( max_packet_size ) ; return 0 ; } "," gspca_dev ) { struct usb_interface_cache * intfc ; break ; } intfc = gspca_dev -> dev [ 0 ] ; if ( intfc -> num_altsetting < 2 ) return - ENODEV ; alt = & intfc [ 1 ] ; if ( alt -> desc . bNumEndpoints < 1 ) return - ENODEV ",torvalds@linux/a246b4d547708f33ff4d4b9a7a5dbac741dc89d8,CVE-2020-11668,https://github.com/torvalds/linux/commit/a246b4d547708f33ff4d4b9a7a5dbac741dc89d8,2020-04-09T21:15Z 1251,CWE-369,"CWE-369 static void setup_format_params ( int track ) { int n ; int il ; int count ; int head_shift ; int track_shift ; struct fparm { unsigned char track , head , sect , size ; } * here = ( struct fparm * ) floppy_track_buffer ; raw_cmd = & default_raw_cmd ; raw_cmd -> track = track ; raw_cmd -> flags = ( FD_RAW_WRITE | FD_RAW_INTR | FD_RAW_SPIN | FD_RAW_NEED_DISK | FD_RAW_NEED_SEEK ) ; raw_cmd -> rate = _floppy -> rate & 0x43 ; raw_cmd -> cmd_count = NR_F ; COMMAND = FM_MODE ( _floppy , FD_FORMAT ) ; DR_SELECT = UNIT ( current_drive ) + PH_HEAD ( _floppy , format_req . head ) ; F_SIZECODE = FD_SIZECODE ( _floppy ) ; F_SECT_PER_TRACK = _floppy -> sect << 2 >> F_SIZECODE ; F_GAP = _floppy -> fmt_gap ; F_FILL = FD_FILL_BYTE ; raw_cmd -> kernel_data = floppy_track_buffer ; raw_cmd -> length = 4 * F_SECT_PER_TRACK ; head_shift = ( F_SECT_PER_TRACK + 5 ) / 6 ; track_shift = 2 * head_shift + 3 ; n = ( track_shift * format_req . track + head_shift * format_req . head ) % F_SECT_PER_TRACK ; il = 1 ; if ( _floppy -> fmt_gap < 0x22 ) il ++ ; for ( count = 0 ; count < F_SECT_PER_TRACK ; ++ count ) { here [ count ] . track = format_req . track ; here [ count ] . head = format_req . head ; here [ count ] . sect = 0 ; here [ count ] . size = F_SIZECODE ; } for ( count = 1 ; count <= F_SECT_PER_TRACK ; ++ count ) { here [ n ] . sect = count ; n = ( n + il ) % F_SECT_PER_TRACK ; if ( here [ n ] . sect ) { ++ n ; if ( n >= F_SECT_PER_TRACK ) { n -= F_SECT_PER_TRACK ; while ( here [ n ] . sect ) ++ n ; } } } if ( _floppy -> stretch & FD_SECTBASEMASK ) { for ( count = 0 ; count < F_SECT_PER_TRACK ; count ++ ) here [ count ] . sect += FD_SECTBASE ( _floppy ) - 1 ; } } "," * F_SECT_PER_TRACK ; if ( ! F_SECT_PER_TRACK ) return ; ",torvalds@linux/f3554aeb991214cbfafd17d55e2bfddb50282e32,CVE-2019-14284,https://github.com/torvalds/linux/commit/f3554aeb991214cbfafd17d55e2bfddb50282e32,2019-07-26T13:15Z 1252,CWE-20,"CWE-20 static int sctp_getsockopt_assoc_stats ( struct sock * sk , int len , char __user * optval , int __user * optlen ) { struct sctp_assoc_stats sas ; struct sctp_association * asoc = NULL ; if ( len < sizeof ( sctp_assoc_t ) ) return - EINVAL ; if ( copy_from_user ( & sas , optval , len ) ) return - EFAULT ; asoc = sctp_id2assoc ( sk , sas . sas_assoc_id ) ; if ( ! asoc ) return - EINVAL ; sas . sas_rtxchunks = asoc -> stats . rtxchunks ; sas . sas_gapcnt = asoc -> stats . gapcnt ; sas . sas_outofseqtsns = asoc -> stats . outofseqtsns ; sas . sas_osacks = asoc -> stats . osacks ; sas . sas_isacks = asoc -> stats . isacks ; sas . sas_octrlchunks = asoc -> stats . octrlchunks ; sas . sas_ictrlchunks = asoc -> stats . ictrlchunks ; sas . sas_oodchunks = asoc -> stats . oodchunks ; sas . sas_iodchunks = asoc -> stats . iodchunks ; sas . sas_ouodchunks = asoc -> stats . ouodchunks ; sas . sas_iuodchunks = asoc -> stats . iuodchunks ; sas . sas_idupchunks = asoc -> stats . idupchunks ; sas . sas_opackets = asoc -> stats . opackets ; sas . sas_ipackets = asoc -> stats . ipackets ; sas . sas_maxrto = asoc -> stats . max_obs_rto ; memcpy ( & sas . sas_obs_rto_ipaddr , & asoc -> stats . obs_rto_ipaddr , sizeof ( struct sockaddr_storage ) ) ; asoc -> stats . max_obs_rto = asoc -> rto_min ; len = min_t ( size_t , len , sizeof ( sas ) ) ; if ( put_user ( len , optlen ) ) return - EFAULT ; SCTP_DEBUG_PRINTK ( ""sctp_getsockopt_assoc_stat(%d):%d\\n"" , len , sas . sas_assoc_id ) ; if ( copy_to_user ( optval , & sas , len ) ) return - EFAULT ; return 0 ; } "," - EINVAL ; len = min_t ( size_t , len , sizeof ( sas ) ) ; -> rto_min ; if ( put_user ",torvalds@linux/726bc6b092da4c093eb74d13c07184b18c1af0f1,CVE-2013-1828,https://github.com/torvalds/linux/commit/726bc6b092da4c093eb74d13c07184b18c1af0f1,2013-03-22T11:59Z 1253,CWE-119,"CWE-119 static ssize_t __nfs4_get_acl_uncached ( struct inode * inode , void * buf , size_t buflen ) { struct page * pages [ NFS4ACL_MAXPAGES ] = { NULL , } ; struct nfs_getaclargs args = { . fh = NFS_FH ( inode ) , . acl_pages = pages , . acl_len = buflen , } ; struct nfs_getaclres res = { . acl_len = buflen , } ; struct rpc_message msg = { . rpc_proc = & nfs4_procedures [ NFSPROC4_CLNT_GETACL ] , . rpc_argp = & args , . rpc_resp = & res , } ; unsigned int npages = DIV_ROUND_UP ( buflen , PAGE_SIZE ) ; int ret = - ENOMEM , i ; if ( npages == 0 ) npages = 1 ; if ( npages > ARRAY_SIZE ( pages ) ) return - ERANGE ; for ( i = 0 ; i < npages ; i ++ ) { pages [ i ] = alloc_page ( GFP_KERNEL ) ; if ( ! pages [ i ] ) goto out_free ; } res . acl_scratch = alloc_page ( GFP_KERNEL ) ; if ( ! res . acl_scratch ) goto out_free ; args . acl_len = npages * PAGE_SIZE ; args . acl_pgbase = 0 ; dprintk ( ""%sbuf%pbuflen%zunpages%dargs.acl_len%zu\\n"" , __func__ , buf , buflen , npages , args . acl_len ) ; ret = nfs4_call_sync ( NFS_SERVER ( inode ) -> client , NFS_SERVER ( inode ) , & msg , & args . seq_args , & res . seq_res , 0 ) ; if ( ret ) goto out_free ; if ( res . acl_flags & NFS4_ACL_TRUNC ) { if ( buf == NULL ) goto out_ok ; ret = - ERANGE ; goto out_free ; } nfs4_write_cached_acl ( inode , pages , res . acl_data_offset , res . acl_len ) ; if ( buf ) _copy_from_pages ( buf , pages , res . acl_data_offset , res . acl_len ) ; out_ok : ret = res . acl_len ; out_free : for ( i = 0 ; i < npages ; i ++ ) if ( pages [ i ] ) __free_page ( pages [ i ] ) ; if ( res . acl_scratch ) __free_page ( res . acl_scratch ) ; return ret ; } "," ( buf ) { if ( res . acl_len > buflen ) { ret = - ERANGE ; goto out_free ; } acl_len ) ; } ",torvalds@linux/7d3e91a89b7adbc2831334def9e494dd9892f9af,CVE-2013-4591,https://github.com/torvalds/linux/commit/7d3e91a89b7adbc2831334def9e494dd9892f9af,2013-11-20T13:19Z 1254,CWE-269,"CWE-269 static void copy_xauthority ( void ) { char * src = RUN_XAUTHORITY_FILE ; char * dest ; if ( asprintf ( & dest , ""%s/.Xauthority"" , 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 , getuid ( ) , getgid ( ) , S_IRUSR | S_IWUSR ) ; if ( rv ) fprintf ( stderr , ""Warning:cannottransfer.Xauthorityinprivatehomedirectory\\n"" ) ; else { fs_logger2 ( ""clone"" , dest ) ; } _exit ( 0 ) ; } waitpid ( child , NULL , 0 ) ; unlink ( src ) ; } "," ) ; } copy_file_as_user ( src , S_IWUSR ) ; fs_logger2 ( ""clone"" ""clone"" , dest ) ; unlink ",netblue30@firejail/b8a4ff9775318ca5e679183884a6a63f3da8f863,CVE-2017-5940,https://github.com/netblue30/firejail/commit/b8a4ff9775318ca5e679183884a6a63f3da8f863,2017-02-09T18:59Z 1255,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 1256,CWE-190,"CWE-190 static int bson_string_is_db_ref ( const unsigned char * string , const int length ) { int result = 0 ; if ( length >= 4 ) { if ( string [ 1 ] == 'r' && string [ 2 ] == 'e' && string [ 3 ] == 'f' ) result = 1 ; } else if ( length >= 3 ) { if ( string [ 1 ] == 'i' && string [ 2 ] == 'd' ) result = 1 ; else if ( string [ 1 ] == 'd' && string [ 2 ] == 'b' ) result = 1 ; } return result ; } "," 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 1257,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 ; } ( void ) fputc ( c , file ) ; } ( 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 ) { 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 ++ ) { if ( image_info -> ping != MagickFalse ) break ; 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 ) ; ( void ) CloseBlob ( image ) ; if ( status == MagickFalse ) return ( DestroyImageList ( image ) ) ; return ( GetFirstImageInList ( image ) ) ; } "," , message ) \\\n{ if ( info ) ) ; \\\n} char explicit_vr [ break ; } if ( fputc ( c , file ) != c ) break ",ImageMagick@ImageMagick/6b6bff054d569a77973f2140c0e86366e6168a6c,CVE-2018-16643,https://github.com/ImageMagick/ImageMagick/commit/6b6bff054d569a77973f2140c0e86366e6168a6c,2018-09-06T22:29Z 1258,CWE-119,"CWE-119 static int detect_flash ( const struct twopass_rc * twopass , int offset ) { FIRSTPASS_STATS next_frame ; int flash_detected = 0 ; if ( read_frame_stats ( twopass , & next_frame , offset ) != EOF ) { if ( next_frame . pcnt_second_ref > next_frame . pcnt_inter && next_frame . pcnt_second_ref >= 0.5 ) flash_detected = 1 ; } return flash_detected ; } "," detect_flash ( const TWO_PASS * twopass , offset ) { const FIRSTPASS_STATS * const next_frame = read_frame_stats ( twopass ( twopass , offset ) ; return next_frame != NULL && next_frame -> pcnt_second_ref > next_frame pcnt_second_ref > next_frame -> pcnt_inter && next_frame pcnt_inter && next_frame -> pcnt_second_ref >= 0.5 pcnt_second_ref >= 0.5 ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1259,CWE-269,"CWE-269 void inode_init_owner ( struct inode * inode , const struct inode * dir , umode_t mode ) { inode -> i_uid = current_fsuid ( ) ; if ( dir && dir -> i_mode & S_ISGID ) { inode -> i_gid = dir -> i_gid ; if ( S_ISDIR ( mode ) ) mode |= S_ISGID ; } else inode -> i_gid = current_fsgid ( ) ; inode -> i_mode = mode ; } "," |= S_ISGID ; else if ( ( mode & ( S_ISGID | S_IXGRP ) ) == ( S_ISGID | S_IXGRP ) && ! in_group_p ( inode -> i_gid ) && ! capable_wrt_inode_uidgid ( dir , CAP_FSETID ) ) mode &= ~ S_ISGID ; ",torvalds@linux/0fa3ecd87848c9c93c2c828ef4c3a8ca36ce46c7,CVE-2018-13405,https://github.com/torvalds/linux/commit/0fa3ecd87848c9c93c2c828ef4c3a8ca36ce46c7,2018-07-06T14:29Z 1260,CWE-787,"CWE-787 static rfbBool webSocketsHandshake ( rfbClientPtr cl , char * scheme ) { char * buf , * response , * line ; int n , linestart = 0 , len = 0 , llen , base64 = TRUE ; char prefix [ 5 ] , trailer [ 17 ] ; char * path = NULL , * host = NULL , * origin = NULL , * protocol = NULL ; char * key1 = NULL , * key2 = NULL , * key3 = NULL ; char * sec_ws_origin = NULL ; char * sec_ws_key = NULL ; char sec_ws_version = 0 ; ws_ctx_t * wsctx = NULL ; buf = ( char * ) malloc ( WEBSOCKETS_MAX_HANDSHAKE_LEN ) ; if ( ! buf ) { rfbLogPerror ( ""webSocketsHandshake:malloc"" ) ; return FALSE ; } response = ( char * ) malloc ( WEBSOCKETS_MAX_HANDSHAKE_LEN ) ; if ( ! response ) { free ( buf ) ; rfbLogPerror ( ""webSocketsHandshake:malloc"" ) ; return FALSE ; } while ( len < WEBSOCKETS_MAX_HANDSHAKE_LEN - 1 ) { if ( ( n = rfbReadExactTimeout ( cl , buf + len , 1 , WEBSOCKETS_CLIENT_SEND_WAIT_MS ) ) <= 0 ) { if ( ( n < 0 ) && ( errno == ETIMEDOUT ) ) { break ; } if ( n == 0 ) rfbLog ( ""webSocketsHandshake:clientgone\\n"" ) ; else rfbLogPerror ( ""webSocketsHandshake:read"" ) ; free ( response ) ; free ( buf ) ; return FALSE ; } len += 1 ; llen = len - linestart ; if ( ( ( llen >= 2 ) ) && ( buf [ len - 1 ] == '\\n' ) ) { line = buf + linestart ; if ( ( llen == 2 ) && ( strncmp ( ""\\r\\n"" , line , 2 ) == 0 ) ) { if ( key1 && key2 ) { if ( ( n = rfbReadExact ( cl , buf + len , 8 ) ) <= 0 ) { if ( ( n < 0 ) && ( errno == ETIMEDOUT ) ) { break ; } if ( n == 0 ) rfbLog ( ""webSocketsHandshake:clientgone\\n"" ) ; else rfbLogPerror ( ""webSocketsHandshake:read"" ) ; free ( response ) ; free ( buf ) ; return FALSE ; } rfbLog ( ""Gotkey3\\n"" ) ; key3 = buf + len ; len += 8 ; } else { buf [ len ] = '\\0' ; } break ; } else if ( ( llen >= 16 ) && ( ( strncmp ( ""GET"" , line , min ( llen , 4 ) ) ) == 0 ) ) { path = line + 4 ; buf [ len - 11 ] = '\\0' ; cl -> wspath = strdup ( path ) ; } else if ( ( strncasecmp ( ""host:"" , line , min ( llen , 6 ) ) ) == 0 ) { host = line + 6 ; buf [ len - 2 ] = '\\0' ; } else if ( ( strncasecmp ( ""origin:"" , line , min ( llen , 8 ) ) ) == 0 ) { origin = line + 8 ; buf [ len - 2 ] = '\\0' ; } else if ( ( strncasecmp ( ""sec-websocket-key1:"" , line , min ( llen , 20 ) ) ) == 0 ) { key1 = line + 20 ; buf [ len - 2 ] = '\\0' ; } else if ( ( strncasecmp ( ""sec-websocket-key2:"" , line , min ( llen , 20 ) ) ) == 0 ) { key2 = line + 20 ; buf [ len - 2 ] = '\\0' ; } else if ( ( strncasecmp ( ""sec-websocket-protocol:"" , line , min ( llen , 24 ) ) ) == 0 ) { protocol = line + 24 ; buf [ len - 2 ] = '\\0' ; rfbLog ( ""Gotprotocol:%s\\n"" , protocol ) ; } else if ( ( strncasecmp ( ""sec-websocket-origin:"" , line , min ( llen , 22 ) ) ) == 0 ) { sec_ws_origin = line + 22 ; buf [ len - 2 ] = '\\0' ; } else if ( ( strncasecmp ( ""sec-websocket-key:"" , line , min ( llen , 19 ) ) ) == 0 ) { sec_ws_key = line + 19 ; buf [ len - 2 ] = '\\0' ; } else if ( ( strncasecmp ( ""sec-websocket-version:"" , line , min ( llen , 23 ) ) ) == 0 ) { sec_ws_version = strtol ( line + 23 , NULL , 10 ) ; buf [ len - 2 ] = '\\0' ; } linestart = len ; } } if ( ! ( path && host && ( origin || sec_ws_origin ) ) ) { rfbErr ( ""webSocketsHandshake:incompleteclienthandshake\\n"" ) ; free ( response ) ; free ( buf ) ; return FALSE ; } if ( ( protocol ) && ( strstr ( protocol , ""binary"" ) ) ) { if ( ! sec_ws_version ) { rfbErr ( ""webSocketsHandshake:\'binary\'protocolnotsupportedwithHixie\\n"" ) ; free ( response ) ; free ( buf ) ; return FALSE ; } rfbLog ( ""-webSocketsHandshake:usingbinary/rawencoding\\n"" ) ; base64 = FALSE ; protocol = ""binary"" ; } else { rfbLog ( ""-webSocketsHandshake:usingbase64encoding\\n"" ) ; base64 = TRUE ; if ( ( protocol ) && ( strstr ( protocol , ""base64"" ) ) ) { protocol = ""base64"" ; } else { protocol = """" ; } } if ( sec_ws_version ) { char accept [ B64LEN ( SHA1_HASH_SIZE ) + 1 ] ; rfbLog ( ""-WebSocketsclientversionhybi-%02d\\n"" , sec_ws_version ) ; webSocketsGenSha1Key ( accept , sizeof ( accept ) , sec_ws_key ) ; if ( strlen ( protocol ) > 0 ) len = snprintf ( response , WEBSOCKETS_MAX_HANDSHAKE_LEN , SERVER_HANDSHAKE_HYBI , accept , protocol ) ; else len = snprintf ( response , WEBSOCKETS_MAX_HANDSHAKE_LEN , SERVER_HANDSHAKE_HYBI_NO_PROTOCOL , accept ) ; } else { if ( ! ( key1 && key2 && key3 ) ) { rfbLog ( ""-WebSocketsclientversionhixie-75\\n"" ) ; prefix [ 0 ] = '\\0' ; trailer [ 0 ] = '\\0' ; } else { rfbLog ( ""-WebSocketsclientversionhixie-76\\n"" ) ; snprintf ( prefix , 5 , ""Sec-"" ) ; webSocketsGenMd5 ( trailer , key1 , key2 , key3 ) ; } len = snprintf ( response , WEBSOCKETS_MAX_HANDSHAKE_LEN , SERVER_HANDSHAKE_HIXIE , prefix , origin , prefix , scheme , host , path , prefix , protocol , trailer ) ; } if ( rfbWriteExact ( cl , response , len ) < 0 ) { rfbErr ( ""webSocketsHandshake:failedsendingWebSocketsresponse\\n"" ) ; free ( response ) ; free ( buf ) ; return FALSE ; } free ( response ) ; free ( buf ) ; wsctx = calloc ( 1 , sizeof ( ws_ctx_t ) ) ; if ( sec_ws_version ) { wsctx -> version = WEBSOCKETS_VERSION_HYBI ; wsctx -> encode = webSocketsEncodeHybi ; wsctx -> decode = webSocketsDecodeHybi ; } else { wsctx -> version = WEBSOCKETS_VERSION_HIXIE ; wsctx -> encode = webSocketsEncodeHixie ; wsctx -> decode = webSocketsDecodeHixie ; } wsctx -> base64 = base64 ; cl -> wsctx = ( wsCtx * ) wsctx ; return TRUE ; } "," = base64 ; hybiDecodeCleanup ( wsctx ) ; ",LibVNC@libvncserver/aac95a9dcf4bbba87b76c72706c3221a842ca433,CVE-2017-18922,https://github.com/LibVNC/libvncserver/commit/aac95a9dcf4bbba87b76c72706c3221a842ca433,2020-06-30T11:15Z 1261,CWE-000,"CWE-000 int hugetlb_mcopy_atomic_pte ( struct mm_struct * dst_mm , pte_t * dst_pte , struct vm_area_struct * dst_vma , unsigned long dst_addr , unsigned long src_addr , struct page * * pagep ) { int vm_shared = dst_vma -> vm_flags & VM_SHARED ; struct hstate * h = hstate_vma ( dst_vma ) ; pte_t _dst_pte ; spinlock_t * ptl ; int ret ; struct page * page ; if ( ! * pagep ) { ret = - ENOMEM ; page = alloc_huge_page ( dst_vma , dst_addr , 0 ) ; if ( IS_ERR ( page ) ) goto out ; ret = copy_huge_page_from_user ( page , ( const void __user * ) src_addr , pages_per_huge_page ( h ) , false ) ; if ( unlikely ( ret ) ) { ret = - EFAULT ; * pagep = page ; goto out ; } } else { page = * pagep ; * pagep = NULL ; } __SetPageUptodate ( page ) ; set_page_huge_active ( page ) ; if ( vm_shared ) { struct address_space * mapping = dst_vma -> vm_file -> f_mapping ; pgoff_t idx = vma_hugecache_offset ( h , dst_vma , dst_addr ) ; ret = huge_add_to_page_cache ( page , mapping , idx ) ; if ( ret ) goto out_release_nounlock ; } ptl = huge_pte_lockptr ( h , dst_mm , dst_pte ) ; spin_lock ( ptl ) ; ret = - EEXIST ; if ( ! huge_pte_none ( huge_ptep_get ( dst_pte ) ) ) goto out_release_unlock ; if ( vm_shared ) { page_dup_rmap ( page , true ) ; } else { ClearPagePrivate ( page ) ; hugepage_add_new_anon_rmap ( page , dst_vma , dst_addr ) ; } _dst_pte = make_huge_pte ( dst_vma , page , dst_vma -> vm_flags & VM_WRITE ) ; if ( dst_vma -> vm_flags & VM_WRITE ) _dst_pte = huge_pte_mkdirty ( _dst_pte ) ; _dst_pte = pte_mkyoung ( _dst_pte ) ; set_huge_pte_at ( dst_mm , dst_addr , dst_pte , _dst_pte ) ; ( void ) huge_ptep_set_access_flags ( dst_vma , dst_addr , dst_pte , _dst_pte , dst_vma -> vm_flags & VM_WRITE ) ; hugetlb_count_add ( pages_per_huge_page ( h ) , dst_mm ) ; update_mmu_cache ( dst_vma , dst_addr , dst_pte ) ; spin_unlock ( ptl ) ; if ( vm_shared ) unlock_page ( page ) ; ret = 0 ; out : return ret ; out_release_unlock : spin_unlock ( ptl ) ; out_release_nounlock : if ( vm_shared ) unlock_page ( page ) ; put_page ( page ) ; goto out ; } "," ptl ) ; if ( vm_shared ) unlock_page ( page ) ; out_release_nounlock : put_page ( page ",torvalds@linux/5af10dfd0afc559bb4b0f7e3e8227a1578333995,CVE-2017-15127,https://github.com/torvalds/linux/commit/5af10dfd0afc559bb4b0f7e3e8227a1578333995,2018-01-14T06:29Z 1262,CWE-415,"CWE-415 static int csnmp_read_table ( host_definition_t * host , data_definition_t * data ) { struct snmp_pdu * req ; struct snmp_pdu * res = NULL ; struct variable_list * vb ; const data_set_t * ds ; size_t oid_list_len = data -> values_len + 1 ; oid_t oid_list [ oid_list_len ] ; _Bool oid_list_todo [ oid_list_len ] ; int status ; size_t i ; csnmp_list_instances_t * instance_list_head ; csnmp_list_instances_t * instance_list_tail ; csnmp_table_values_t * * value_list_head ; csnmp_table_values_t * * value_list_tail ; DEBUG ( ""snmpplugin:csnmp_read_table(host=%s,data=%s)"" , host -> name , data -> name ) ; if ( host -> sess_handle == NULL ) { DEBUG ( ""snmpplugin:csnmp_read_table:host->sess_handle==NULL"" ) ; return ( - 1 ) ; } ds = plugin_get_ds ( data -> type ) ; if ( ! ds ) { ERROR ( ""snmpplugin:DataSet`%s\'notdefined."" , data -> type ) ; return ( - 1 ) ; } if ( ds -> ds_num != data -> values_len ) { ERROR ( ""snmpplugin:DataSet`%s\'requires%zuvalues,butconfigtalks"" ""about%zu"" , data -> type , ds -> ds_num , data -> values_len ) ; return ( - 1 ) ; } assert ( data -> values_len > 0 ) ; memcpy ( oid_list , data -> values , data -> values_len * sizeof ( oid_t ) ) ; if ( data -> instance . oid . oid_len > 0 ) memcpy ( oid_list + data -> values_len , & data -> instance . oid , sizeof ( oid_t ) ) ; else oid_list_len -- ; for ( i = 0 ; i < oid_list_len ; i ++ ) oid_list_todo [ i ] = 1 ; value_list_head = calloc ( data -> values_len , sizeof ( * value_list_head ) ) ; value_list_tail = calloc ( data -> values_len , sizeof ( * value_list_tail ) ) ; if ( ( value_list_head == NULL ) || ( value_list_tail == NULL ) ) { ERROR ( ""snmpplugin:csnmp_read_table:callocfailed."" ) ; sfree ( value_list_head ) ; sfree ( value_list_tail ) ; return ( - 1 ) ; } instance_list_head = NULL ; instance_list_tail = NULL ; status = 0 ; while ( status == 0 ) { int oid_list_todo_num ; req = snmp_pdu_create ( SNMP_MSG_GETNEXT ) ; if ( req == NULL ) { ERROR ( ""snmpplugin:snmp_pdu_createfailed."" ) ; status = - 1 ; break ; } oid_list_todo_num = 0 ; for ( i = 0 ; i < oid_list_len ; i ++ ) { if ( ! oid_list_todo [ i ] ) continue ; oid_list_todo_num ++ ; snmp_add_null_var ( req , oid_list [ i ] . oid , oid_list [ i ] . oid_len ) ; } if ( oid_list_todo_num == 0 ) { DEBUG ( ""snmpplugin:allvariableshavelefttheirsubtree"" ) ; status = 0 ; break ; } res = NULL ; status = snmp_sess_synch_response ( host -> sess_handle , req , & res ) ; if ( ( status != STAT_SUCCESS ) || ( res == NULL ) ) { char * errstr = NULL ; snmp_sess_error ( host -> sess_handle , NULL , NULL , & errstr ) ; c_complain ( LOG_ERR , & host -> complaint , ""snmpplugin:host%s:snmp_sess_synch_responsefailed:%s"" , host -> name , ( errstr == NULL ) ? ""Unknownproblem"" : errstr ) ; if ( res != NULL ) snmp_free_pdu ( res ) ; res = NULL ; req = NULL ; sfree ( errstr ) ; csnmp_host_close_session ( host ) ; status = - 1 ; break ; } status = 0 ; assert ( res != NULL ) ; c_release ( LOG_INFO , & host -> complaint , ""snmpplugin:host%s:snmp_sess_synch_responsesuccessful."" , host -> name ) ; vb = res -> variables ; if ( vb == NULL ) { status = - 1 ; break ; } for ( vb = res -> variables , i = 0 ; ( vb != NULL ) ; vb = vb -> next_variable , i ++ ) { while ( ( i < oid_list_len ) && ! oid_list_todo [ i ] ) i ++ ; if ( ( data -> instance . oid . oid_len > 0 ) && ( i == data -> values_len ) ) { if ( ( vb -> type == SNMP_ENDOFMIBVIEW ) || ( snmp_oid_ncompare ( data -> instance . oid . oid , data -> instance . oid . oid_len , vb -> name , vb -> name_length , data -> instance . oid . oid_len ) != 0 ) ) { DEBUG ( ""snmpplugin:host=%s;data=%s;Instanceleftitssubtree."" , host -> name , data -> name ) ; oid_list_todo [ i ] = 0 ; continue ; } if ( csnmp_instance_list_add ( & instance_list_head , & instance_list_tail , res , host , data ) != 0 ) { ERROR ( ""snmpplugin:host%s:csnmp_instance_list_addfailed."" , host -> name ) ; status = - 1 ; break ; } } else { csnmp_table_values_t * vt ; oid_t vb_name ; oid_t suffix ; int ret ; csnmp_oid_init ( & vb_name , vb -> name , vb -> name_length ) ; ret = csnmp_oid_suffix ( & suffix , & vb_name , data -> values + i ) ; if ( ret != 0 ) { DEBUG ( ""snmpplugin:host=%s;data=%s;i=%zu;"" ""Valueprobablyleftitssubtree."" , host -> name , data -> name , i ) ; oid_list_todo [ i ] = 0 ; continue ; } if ( ( value_list_tail [ i ] != NULL ) && ( csnmp_oid_compare ( & suffix , & value_list_tail [ i ] -> suffix ) <= 0 ) ) { DEBUG ( ""snmpplugin:host=%s;data=%s;i=%zu;"" ""Suffixisnotincreasing."" , host -> name , data -> name , i ) ; oid_list_todo [ i ] = 0 ; continue ; } vt = calloc ( 1 , sizeof ( * vt ) ) ; if ( vt == NULL ) { ERROR ( ""snmpplugin:callocfailed."" ) ; status = - 1 ; break ; } vt -> value = csnmp_value_list_to_value ( vb , ds -> ds [ i ] . type , data -> scale , data -> shift , host -> name , data -> name ) ; memcpy ( & vt -> suffix , & suffix , sizeof ( vt -> suffix ) ) ; vt -> next = NULL ; if ( value_list_tail [ i ] == NULL ) value_list_head [ i ] = vt ; else value_list_tail [ i ] -> next = vt ; value_list_tail [ i ] = vt ; } memcpy ( oid_list [ i ] . oid , vb -> name , sizeof ( oid ) * vb -> name_length ) ; oid_list [ i ] . oid_len = vb -> name_length ; } if ( res != NULL ) snmp_free_pdu ( res ) ; res = NULL ; } if ( res != NULL ) snmp_free_pdu ( res ) ; res = NULL ; if ( req != NULL ) snmp_free_pdu ( req ) ; req = NULL ; if ( status == 0 ) csnmp_dispatch_table ( host , data , instance_list_head , value_list_head ) ; while ( instance_list_head != NULL ) { csnmp_list_instances_t * next = instance_list_head -> next ; sfree ( instance_list_head ) ; instance_list_head = next ; } for ( i = 0 ; i < data -> values_len ; i ++ ) { while ( value_list_head [ i ] != NULL ) { csnmp_table_values_t * next = value_list_head [ i ] -> next ; sfree ( value_list_head [ i ] ) ; value_list_head [ i ] = next ; } } sfree ( value_list_head ) ; sfree ( value_list_tail ) ; return ( 0 ) ; } "," DEBUG ( ""snmpplugin:allvariableshavelefttheirsubtree"" ) ; snmp_free_pdu ( req = NULL ; sfree ( errstr ; if ( status == 0 ",collectd@collectd/d16c24542b2f96a194d43a73c2e5778822b9cb47,CVE-2017-16820,https://github.com/collectd/collectd/commit/d16c24542b2f96a194d43a73c2e5778822b9cb47,2017-11-14T21:29Z 1263,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 1264,CWE-295,"CWE-295 int context_init ( SERVICE_OPTIONS * section ) { # if OPENSSL_VERSION_NUMBER >= 0x10100000L if ( section -> option . client ) section -> ctx = SSL_CTX_new ( TLS_client_method ( ) ) ; else section -> ctx = SSL_CTX_new ( TLS_server_method ( ) ) ; if ( ! SSL_CTX_set_min_proto_version ( section -> ctx , section -> min_proto_version ) ) { s_log ( LOG_ERR , ""Failedtosettheminimumprotocolversion0x%X"" , section -> min_proto_version ) ; return 1 ; } if ( ! SSL_CTX_set_max_proto_version ( section -> ctx , section -> max_proto_version ) ) { s_log ( LOG_ERR , ""Failedtosetthemaximumprotocolversion0x%X"" , section -> max_proto_version ) ; return 1 ; } # else if ( section -> option . client ) section -> ctx = SSL_CTX_new ( section -> client_method ) ; else section -> ctx = SSL_CTX_new ( section -> server_method ) ; # endif if ( ! section -> ctx ) { sslerror ( ""SSL_CTX_new"" ) ; return 1 ; } if ( ! SSL_CTX_set_ex_data ( section -> ctx , index_ssl_ctx_opt , section ) ) { sslerror ( ""SSL_CTX_set_ex_data"" ) ; return 1 ; } current_section = section ; if ( section -> cipher_list ) { s_log ( LOG_DEBUG , ""Ciphers:%s"" , section -> cipher_list ) ; if ( ! SSL_CTX_set_cipher_list ( section -> ctx , section -> cipher_list ) ) { sslerror ( ""SSL_CTX_set_cipher_list"" ) ; return 1 ; } } # ifndef OPENSSL_NO_TLS1_3 if ( section -> ciphersuites ) { s_log ( LOG_DEBUG , ""TLSv1.3ciphersuites:%s"" , section -> ciphersuites ) ; if ( ! SSL_CTX_set_ciphersuites ( section -> ctx , section -> ciphersuites ) ) { sslerror ( ""SSL_CTX_set_ciphersuites"" ) ; return 1 ; } } # endif SSL_CTX_set_options ( section -> ctx , SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 ) ; # ifdef SSL_OP_NO_COMPRESSION SSL_CTX_clear_options ( section -> ctx , SSL_OP_NO_COMPRESSION ) ; # endif SSL_CTX_set_options ( section -> ctx , ( SSL_OPTIONS_TYPE ) ( section -> ssl_options_set ) ) ; # if OPENSSL_VERSION_NUMBER >= 0x009080dfL SSL_CTX_clear_options ( section -> ctx , ( SSL_OPTIONS_TYPE ) ( section -> ssl_options_clear ) ) ; # endif # if OPENSSL_VERSION_NUMBER >= 0x009080dfL s_log ( LOG_DEBUG , ""TLSoptions:0x%08lX(+0x%08lX,-0x%08lX)"" , SSL_CTX_get_options ( section -> ctx ) , section -> ssl_options_set , section -> ssl_options_clear ) ; # else s_log ( LOG_DEBUG , ""TLSoptions:0x%08lX(+0x%08lX)"" , SSL_CTX_get_options ( section -> ctx ) , section -> ssl_options_set ) ; # endif if ( conf_init ( section ) ) return 1 ; # ifdef SSL_MODE_RELEASE_BUFFERS SSL_CTX_set_mode ( section -> ctx , SSL_MODE_ENABLE_PARTIAL_WRITE | SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER | SSL_MODE_RELEASE_BUFFERS ) ; # else SSL_CTX_set_mode ( section -> ctx , SSL_MODE_ENABLE_PARTIAL_WRITE | SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER ) ; # endif # if OPENSSL_VERSION_NUMBER >= 0x10101000L SSL_CTX_set_session_ticket_cb ( section -> ctx , generate_session_ticket_cb , decrypt_session_ticket_cb , NULL ) ; # endif # if OPENSSL_VERSION_NUMBER >= 0x10000000L if ( ( section -> ticket_key ) && ( section -> ticket_mac ) ) SSL_CTX_set_tlsext_ticket_key_cb ( section -> ctx , ssl_tlsext_ticket_key_cb ) ; # endif if ( ! section -> option . client ) { unsigned servname_len = ( unsigned ) strlen ( section -> servname ) ; if ( servname_len > SSL_MAX_SSL_SESSION_ID_LENGTH ) servname_len = SSL_MAX_SSL_SESSION_ID_LENGTH ; if ( ! SSL_CTX_set_session_id_context ( section -> ctx , ( unsigned char * ) section -> servname , servname_len ) ) { sslerror ( ""SSL_CTX_set_session_id_context"" ) ; return 1 ; } } SSL_CTX_set_session_cache_mode ( section -> ctx , SSL_SESS_CACHE_BOTH | SSL_SESS_CACHE_NO_INTERNAL_STORE ) ; SSL_CTX_sess_set_cache_size ( section -> ctx , section -> session_size ) ; SSL_CTX_set_timeout ( section -> ctx , section -> session_timeout ) ; SSL_CTX_sess_set_new_cb ( section -> ctx , sess_new_cb ) ; SSL_CTX_sess_set_get_cb ( section -> ctx , sess_get_cb ) ; SSL_CTX_sess_set_remove_cb ( section -> ctx , sess_remove_cb ) ; SSL_CTX_set_info_callback ( section -> ctx , info_callback ) ; if ( auth_init ( section ) ) return 1 ; if ( verify_init ( section ) ) return 1 ; if ( ! section -> option . client ) { # ifndef OPENSSL_NO_TLSEXT SSL_CTX_set_tlsext_servername_callback ( section -> ctx , servername_cb ) ; # endif # ifndef OPENSSL_NO_DH dh_init ( section ) ; # endif # ifndef OPENSSL_NO_ECDH ecdh_init ( section ) ; # endif } return 0 ; } "," = section ; # if OPENSSL_VERSION_NUMBER >= 0x10100000L if ( section -> security_level >= 0 ) { SSL_CTX_set_security_level ( section -> ctx , section -> security_level ) ; s_log ( LOG_INFO , ""User-specifiedsecuritylevelset:%d"" , section -> security_level ) ; } else if ( SSL_CTX_get_security_level ( section -> ctx ) < DEFAULT_SECURITY_LEVEL ) { SSL_CTX_set_security_level ( section -> ctx , DEFAULT_SECURITY_LEVEL ) ; s_log ( LOG_INFO , ""stunneldefaultsecuritylevelset:%d"" , DEFAULT_SECURITY_LEVEL ) ; } else { s_log ( LOG_INFO , ""OpenSSLsecuritylevelisused:%d"" , SSL_CTX_get_security_level ( section -> ctx ) ) ; } # endif return 1 ; # ifndef OPENSSL_NO_TLSEXT . client ) SSL_CTX_set_tlsext_servername_callback ( section ; # endif return 0 ; ",mtrojnar@stunnel/ebad9ddc4efb2635f37174c9d800d06206f1edf9,CVE-2021-20230,https://github.com/mtrojnar/stunnel/commit/ebad9ddc4efb2635f37174c9d800d06206f1edf9,2021-02-23T17:15Z 1265,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 1266,CWE-119,"CWE-119 static void calc_pframe_target_size ( VP8_COMP * cpi ) { int min_frame_target ; int old_per_frame_bandwidth = cpi -> per_frame_bandwidth ; if ( cpi -> current_layer > 0 ) cpi -> per_frame_bandwidth = cpi -> layer_context [ cpi -> current_layer ] . avg_frame_size_for_layer ; min_frame_target = 0 ; if ( cpi -> pass == 2 ) { min_frame_target = cpi -> min_frame_bandwidth ; if ( min_frame_target < ( cpi -> av_per_frame_bandwidth >> 5 ) ) min_frame_target = cpi -> av_per_frame_bandwidth >> 5 ; } else if ( min_frame_target < cpi -> per_frame_bandwidth / 4 ) min_frame_target = cpi -> per_frame_bandwidth / 4 ; if ( ( cpi -> common . refresh_alt_ref_frame ) && ( cpi -> oxcf . number_of_layers == 1 ) ) { if ( cpi -> pass == 2 ) { cpi -> per_frame_bandwidth = cpi -> twopass . gf_bits ; cpi -> this_frame_target = cpi -> per_frame_bandwidth ; } } else { if ( cpi -> pass == 2 ) { cpi -> this_frame_target = cpi -> per_frame_bandwidth ; } else { int Adjustment ; if ( cpi -> kf_overspend_bits > 0 ) { Adjustment = ( cpi -> kf_bitrate_adjustment <= cpi -> kf_overspend_bits ) ? cpi -> kf_bitrate_adjustment : cpi -> kf_overspend_bits ; if ( Adjustment > ( cpi -> per_frame_bandwidth - min_frame_target ) ) Adjustment = ( cpi -> per_frame_bandwidth - min_frame_target ) ; cpi -> kf_overspend_bits -= Adjustment ; cpi -> this_frame_target = cpi -> per_frame_bandwidth - Adjustment ; if ( cpi -> this_frame_target < min_frame_target ) cpi -> this_frame_target = min_frame_target ; } else cpi -> this_frame_target = cpi -> per_frame_bandwidth ; if ( ( cpi -> gf_overspend_bits > 0 ) && ( cpi -> this_frame_target > min_frame_target ) ) { Adjustment = ( cpi -> non_gf_bitrate_adjustment <= cpi -> gf_overspend_bits ) ? cpi -> non_gf_bitrate_adjustment : cpi -> gf_overspend_bits ; if ( Adjustment > ( cpi -> this_frame_target - min_frame_target ) ) Adjustment = ( cpi -> this_frame_target - min_frame_target ) ; cpi -> gf_overspend_bits -= Adjustment ; cpi -> this_frame_target -= Adjustment ; } if ( ( cpi -> last_boost > 150 ) && ( cpi -> frames_till_gf_update_due > 0 ) && ( cpi -> current_gf_interval >= ( MIN_GF_INTERVAL << 1 ) ) ) { Adjustment = ( cpi -> last_boost - 100 ) >> 5 ; if ( Adjustment < 1 ) Adjustment = 1 ; else if ( Adjustment > 10 ) Adjustment = 10 ; Adjustment = ( cpi -> this_frame_target * Adjustment ) / 100 ; if ( Adjustment > ( cpi -> this_frame_target - min_frame_target ) ) Adjustment = ( cpi -> this_frame_target - min_frame_target ) ; if ( cpi -> frames_since_golden == ( cpi -> current_gf_interval >> 1 ) ) cpi -> this_frame_target += ( ( cpi -> current_gf_interval - 1 ) * Adjustment ) ; else cpi -> this_frame_target -= Adjustment ; } } } if ( cpi -> this_frame_target < min_frame_target ) cpi -> this_frame_target = min_frame_target ; if ( ! cpi -> common . refresh_alt_ref_frame ) cpi -> inter_frame_target = cpi -> this_frame_target ; if ( cpi -> pass == 0 ) { if ( cpi -> buffered_mode ) { int one_percent_bits = ( int ) ( 1 + cpi -> oxcf . optimal_buffer_level / 100 ) ; if ( ( cpi -> buffer_level < cpi -> oxcf . optimal_buffer_level ) || ( cpi -> bits_off_target < cpi -> oxcf . optimal_buffer_level ) ) { int percent_low = 0 ; if ( ( cpi -> oxcf . end_usage == USAGE_STREAM_FROM_SERVER ) && ( cpi -> buffer_level < cpi -> oxcf . optimal_buffer_level ) ) { percent_low = ( int ) ( ( cpi -> oxcf . optimal_buffer_level - cpi -> buffer_level ) / one_percent_bits ) ; } else if ( cpi -> bits_off_target < 0 ) { percent_low = ( int ) ( 100 * - cpi -> bits_off_target / ( cpi -> total_byte_count * 8 ) ) ; } if ( percent_low > cpi -> oxcf . under_shoot_pct ) percent_low = cpi -> oxcf . under_shoot_pct ; else if ( percent_low < 0 ) percent_low = 0 ; cpi -> this_frame_target -= ( cpi -> this_frame_target * percent_low ) / 200 ; if ( cpi -> auto_worst_q && cpi -> ni_frames > 150 ) { int64_t critical_buffer_level ; if ( cpi -> oxcf . end_usage == USAGE_STREAM_FROM_SERVER ) { critical_buffer_level = ( cpi -> buffer_level < cpi -> bits_off_target ) ? cpi -> buffer_level : cpi -> bits_off_target ; } else { critical_buffer_level = cpi -> bits_off_target ; } if ( critical_buffer_level < cpi -> oxcf . optimal_buffer_level ) { if ( critical_buffer_level > ( cpi -> oxcf . optimal_buffer_level >> 2 ) ) { int64_t qadjustment_range = cpi -> worst_quality - cpi -> ni_av_qi ; int64_t above_base = ( critical_buffer_level - ( cpi -> oxcf . optimal_buffer_level >> 2 ) ) ; cpi -> active_worst_quality = cpi -> worst_quality - ( int ) ( ( qadjustment_range * above_base ) / ( cpi -> oxcf . optimal_buffer_level * 3 >> 2 ) ) ; } else { cpi -> active_worst_quality = cpi -> worst_quality ; } } else { cpi -> active_worst_quality = cpi -> ni_av_qi ; } } else { cpi -> active_worst_quality = cpi -> worst_quality ; } } else { int percent_high = 0 ; if ( ( cpi -> oxcf . end_usage == USAGE_STREAM_FROM_SERVER ) && ( cpi -> buffer_level > cpi -> oxcf . optimal_buffer_level ) ) { percent_high = ( int ) ( ( cpi -> buffer_level - cpi -> oxcf . optimal_buffer_level ) / one_percent_bits ) ; } else if ( cpi -> bits_off_target > cpi -> oxcf . optimal_buffer_level ) { percent_high = ( int ) ( ( 100 * cpi -> bits_off_target ) / ( cpi -> total_byte_count * 8 ) ) ; } if ( percent_high > cpi -> oxcf . over_shoot_pct ) percent_high = cpi -> oxcf . over_shoot_pct ; else if ( percent_high < 0 ) percent_high = 0 ; cpi -> this_frame_target += ( cpi -> this_frame_target * percent_high ) / 200 ; if ( cpi -> auto_worst_q && cpi -> ni_frames > 150 ) { cpi -> active_worst_quality = cpi -> ni_av_qi ; } else { cpi -> active_worst_quality = cpi -> worst_quality ; } } cpi -> active_best_quality = cpi -> best_quality ; if ( cpi -> active_worst_quality <= cpi -> active_best_quality ) cpi -> active_worst_quality = cpi -> active_best_quality + 1 ; if ( cpi -> active_worst_quality > 127 ) cpi -> active_worst_quality = 127 ; } else { cpi -> active_worst_quality = cpi -> worst_quality ; } if ( cpi -> oxcf . end_usage == USAGE_CONSTRAINED_QUALITY && cpi -> active_worst_quality < cpi -> cq_target_quality ) { cpi -> active_worst_quality = cpi -> cq_target_quality ; } } if ( cpi -> drop_frames_allowed && ( cpi -> oxcf . end_usage == USAGE_STREAM_FROM_SERVER ) && ( ( cpi -> common . frame_type != KEY_FRAME ) ) ) { if ( ( cpi -> buffer_level < 0 ) ) { # if 0 FILE * f = fopen ( ""dec.stt"" , ""a"" ) ; fprintf ( f , ""%10d%10d%10d%10d*****BUFFEREMPTY\\n"" , ( int ) cpi -> common . current_video_frame , cpi -> decimation_factor , cpi -> common . horiz_scale , ( cpi -> buffer_level * 100 ) / cpi -> oxcf . optimal_buffer_level ) ; fclose ( f ) ; # endif cpi -> drop_frame = 1 ; cpi -> bits_off_target += cpi -> av_per_frame_bandwidth ; if ( cpi -> bits_off_target > cpi -> oxcf . maximum_buffer_size ) cpi -> bits_off_target = ( int ) cpi -> oxcf . maximum_buffer_size ; cpi -> buffer_level = cpi -> bits_off_target ; if ( cpi -> oxcf . number_of_layers > 1 ) { unsigned int i ; for ( i = cpi -> current_layer + 1 ; i < cpi -> oxcf . number_of_layers ; i ++ ) { LAYER_CONTEXT * lc = & cpi -> layer_context [ i ] ; lc -> bits_off_target += ( int ) ( lc -> target_bandwidth / lc -> framerate ) ; if ( lc -> bits_off_target > lc -> maximum_buffer_size ) lc -> bits_off_target = lc -> maximum_buffer_size ; lc -> buffer_level = lc -> bits_off_target ; } } } } if ( cpi -> oxcf . error_resilient_mode == 0 && ( cpi -> frames_till_gf_update_due == 0 ) && ! cpi -> drop_frame ) { int Q = ( cpi -> oxcf . fixed_q < 0 ) ? cpi -> last_q [ INTER_FRAME ] : cpi -> oxcf . fixed_q ; int gf_frame_useage = 0 ; int tot_mbs = cpi -> recent_ref_frame_usage [ INTRA_FRAME ] + cpi -> recent_ref_frame_usage [ LAST_FRAME ] + cpi -> recent_ref_frame_usage [ GOLDEN_FRAME ] + cpi -> recent_ref_frame_usage [ ALTREF_FRAME ] ; int pct_gf_active = ( 100 * cpi -> gf_active_count ) / ( cpi -> common . mb_rows * cpi -> common . mb_cols ) ; if ( tot_mbs ) gf_frame_useage = ( cpi -> recent_ref_frame_usage [ GOLDEN_FRAME ] + cpi -> recent_ref_frame_usage [ ALTREF_FRAME ] ) * 100 / tot_mbs ; if ( pct_gf_active > gf_frame_useage ) gf_frame_useage = pct_gf_active ; if ( cpi -> auto_gold ) { if ( ( cpi -> pass == 0 ) && ( cpi -> this_frame_percent_intra < 15 || gf_frame_useage >= 5 ) ) cpi -> common . refresh_golden_frame = 1 ; else if ( cpi -> pass == 2 ) cpi -> common . refresh_golden_frame = 1 ; } # if 0 if ( 0 ) { FILE * f ; f = fopen ( ""gf_useaget.stt"" , ""a"" ) ; fprintf ( f , ""%8ld%10ld%10ld%10ld%10ld\\n"" , cpi -> common . current_video_frame , cpi -> gfu_boost , GFQ_ADJUSTMENT , cpi -> gfu_boost , gf_frame_useage ) ; fclose ( f ) ; } # endif if ( cpi -> common . refresh_golden_frame == 1 ) { # if 0 if ( 0 ) { FILE * f ; f = fopen ( ""GFexit.stt"" , ""a"" ) ; fprintf ( f , ""%8ldGFcoded\\n"" , cpi -> common . current_video_frame ) ; fclose ( f ) ; } # endif if ( cpi -> auto_adjust_gold_quantizer ) { calc_gf_params ( cpi ) ; } if ( ! cpi -> source_alt_ref_active ) { if ( cpi -> oxcf . fixed_q < 0 ) { if ( cpi -> pass == 2 ) { cpi -> this_frame_target = cpi -> per_frame_bandwidth ; } else { int Boost = cpi -> last_boost ; int frames_in_section = cpi -> frames_till_gf_update_due + 1 ; int allocation_chunks = ( frames_in_section * 100 ) + ( Boost - 100 ) ; int bits_in_section = cpi -> inter_frame_target * frames_in_section ; while ( Boost > 1000 ) { Boost /= 2 ; allocation_chunks /= 2 ; } if ( ( bits_in_section >> 7 ) > allocation_chunks ) cpi -> this_frame_target = Boost * ( bits_in_section / allocation_chunks ) ; else cpi -> this_frame_target = ( Boost * bits_in_section ) / allocation_chunks ; } } else cpi -> this_frame_target = ( estimate_bits_at_q ( 1 , Q , cpi -> common . MBs , 1.0 ) * cpi -> last_boost ) / 100 ; } else { cpi -> this_frame_target = 0 ; } cpi -> current_gf_interval = cpi -> frames_till_gf_update_due ; } } cpi -> per_frame_bandwidth = old_per_frame_bandwidth ; } "," 1 ) ) { Adjustment = ( cpi -> ) * Adjustment ; if ( Adjustment > ( 10 * cpi -> this_frame_target ) / 100 ) Adjustment = ( 10 * cpi -> this_frame_target ) / 100 ; cpi -> this_frame_target += Adjustment ; } else cpi -> ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1267,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 1268,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 1269,CWE-119,"CWE-119 static int do_ip_vs_get_ctl ( struct sock * sk , int cmd , void __user * user , int * len ) { unsigned char arg [ 128 ] ; int ret = 0 ; if ( ! capable ( CAP_NET_ADMIN ) ) return - EPERM ; if ( * len < get_arglen [ GET_CMDID ( cmd ) ] ) { pr_err ( ""get_ctl:len%u<%u\\n"" , * len , get_arglen [ GET_CMDID ( cmd ) ] ) ; return - EINVAL ; } if ( copy_from_user ( arg , user , get_arglen [ GET_CMDID ( cmd ) ] ) != 0 ) return - EFAULT ; 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 = ip_vs_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 ( 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_get ( AF_INET , entry -> fwmark ) ; else svc = __ip_vs_service_get ( 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 ; ip_vs_service_put ( svc ) ; } 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 ( get , user ) ; } break ; case IP_VS_SO_GET_TIMEOUT : { struct ip_vs_timeout_user t ; __ip_vs_get_timeouts ( & t ) ; if ( copy_to_user ( user , & t , sizeof ( t ) ) != 0 ) ret = - EFAULT ; } break ; case IP_VS_SO_GET_DAEMON : { struct ip_vs_daemon_user d [ 2 ] ; memset ( & d , 0 , sizeof ( d ) ) ; if ( ip_vs_sync_state & IP_VS_STATE_MASTER ) { d [ 0 ] . state = IP_VS_STATE_MASTER ; strlcpy ( d [ 0 ] . mcast_ifn , ip_vs_master_mcast_ifn , sizeof ( d [ 0 ] . mcast_ifn ) ) ; d [ 0 ] . syncid = ip_vs_master_syncid ; } if ( ip_vs_sync_state & IP_VS_STATE_BACKUP ) { d [ 1 ] . state = IP_VS_STATE_BACKUP ; strlcpy ( d [ 1 ] . mcast_ifn , ip_vs_backup_mcast_ifn , sizeof ( d [ 1 ] . mcast_ifn ) ) ; d [ 1 ] . syncid = ip_vs_backup_syncid ; } if ( copy_to_user ( user , & d , sizeof ( d ) ) != 0 ) ret = - EFAULT ; } break ; default : ret = - EINVAL ; } out : mutex_unlock ( & __ip_vs_mutex ) ; return ret ; } "," = 0 ; unsigned int copylen ; return - EPERM ; if ( cmd < IP_VS_BASE_CTL || cmd > IP_VS_SO_GET_MAX ) return - EINVAL EINVAL ; } copylen = get_arglen [ GET_CMDID ( cmd ) ] ; if ( copylen > 128 ) return - EINVAL ; , user , copylen ) != 0 ",torvalds@linux/04bcef2a83f40c6db24222b27a52892cba39dffb,CVE-2013-4588,https://github.com/torvalds/linux/commit/04bcef2a83f40c6db24222b27a52892cba39dffb,2013-11-20T13:19Z 1270,CWE-125,"CWE-125 void pgm_print ( netdissect_options * ndo , register const u_char * bp , register u_int length , register const u_char * bp2 ) { register const struct pgm_header * pgm ; register const struct ip * ip ; register char ch ; uint16_t sport , dport ; u_int nla_afnum ; char nla_buf [ INET6_ADDRSTRLEN ] ; register const struct ip6_hdr * ip6 ; uint8_t opt_type , opt_len ; uint32_t seq , opts_len , len , offset ; pgm = ( const struct pgm_header * ) bp ; ip = ( const struct ip * ) bp2 ; if ( IP_V ( ip ) == 6 ) ip6 = ( const struct ip6_hdr * ) bp2 ; else ip6 = NULL ; ch = '\\0' ; if ( ! ND_TTEST ( pgm -> pgm_dport ) ) { if ( ip6 ) { ND_PRINT ( ( ndo , ""%s>%s:[|pgm]"" , ip6addr_string ( ndo , & ip6 -> ip6_src ) , ip6addr_string ( ndo , & ip6 -> ip6_dst ) ) ) ; return ; } else { ND_PRINT ( ( ndo , ""%s>%s:[|pgm]"" , ipaddr_string ( ndo , & ip -> ip_src ) , ipaddr_string ( ndo , & ip -> ip_dst ) ) ) ; return ; } } sport = EXTRACT_16BITS ( & pgm -> pgm_sport ) ; dport = EXTRACT_16BITS ( & pgm -> pgm_dport ) ; if ( ip6 ) { if ( ip6 -> ip6_nxt == IPPROTO_PGM ) { ND_PRINT ( ( ndo , ""%s.%s>%s.%s:"" , ip6addr_string ( ndo , & ip6 -> ip6_src ) , tcpport_string ( ndo , sport ) , ip6addr_string ( ndo , & ip6 -> ip6_dst ) , tcpport_string ( ndo , dport ) ) ) ; } else { ND_PRINT ( ( ndo , ""%s>%s:"" , tcpport_string ( ndo , sport ) , tcpport_string ( ndo , dport ) ) ) ; } } else { if ( ip -> ip_p == IPPROTO_PGM ) { ND_PRINT ( ( ndo , ""%s.%s>%s.%s:"" , ipaddr_string ( ndo , & ip -> ip_src ) , tcpport_string ( ndo , sport ) , ipaddr_string ( ndo , & ip -> ip_dst ) , tcpport_string ( ndo , dport ) ) ) ; } else { ND_PRINT ( ( ndo , ""%s>%s:"" , tcpport_string ( ndo , sport ) , tcpport_string ( ndo , dport ) ) ) ; } } ND_TCHECK ( * pgm ) ; ND_PRINT ( ( ndo , ""PGM,length%u"" , EXTRACT_16BITS ( & pgm -> pgm_length ) ) ) ; if ( ! ndo -> ndo_vflag ) return ; ND_PRINT ( ( ndo , ""0x%02x%02x%02x%02x%02x%02x"" , pgm -> pgm_gsid [ 0 ] , pgm -> pgm_gsid [ 1 ] , pgm -> pgm_gsid [ 2 ] , pgm -> pgm_gsid [ 3 ] , pgm -> pgm_gsid [ 4 ] , pgm -> pgm_gsid [ 5 ] ) ) ; switch ( pgm -> pgm_type ) { case PGM_SPM : { const struct pgm_spm * spm ; spm = ( const struct pgm_spm * ) ( pgm + 1 ) ; ND_TCHECK ( * spm ) ; bp = ( const u_char * ) ( spm + 1 ) ; switch ( EXTRACT_16BITS ( & spm -> pgms_nla_afi ) ) { case AFNUM_INET : ND_TCHECK2 ( * bp , sizeof ( struct in_addr ) ) ; addrtostr ( bp , nla_buf , sizeof ( nla_buf ) ) ; bp += sizeof ( struct in_addr ) ; break ; case AFNUM_INET6 : ND_TCHECK2 ( * bp , sizeof ( struct in6_addr ) ) ; addrtostr6 ( bp , nla_buf , sizeof ( nla_buf ) ) ; bp += sizeof ( struct in6_addr ) ; break ; default : goto trunc ; break ; } ND_PRINT ( ( ndo , ""SPMseq%utrail%ulead%unla%s"" , EXTRACT_32BITS ( & spm -> pgms_seq ) , EXTRACT_32BITS ( & spm -> pgms_trailseq ) , EXTRACT_32BITS ( & spm -> pgms_leadseq ) , nla_buf ) ) ; break ; } case PGM_POLL : { const struct pgm_poll * poll_msg ; poll_msg = ( const struct pgm_poll * ) ( pgm + 1 ) ; ND_TCHECK ( * poll_msg ) ; ND_PRINT ( ( ndo , ""POLLseq%uround%u"" , EXTRACT_32BITS ( & poll_msg -> pgmp_seq ) , EXTRACT_16BITS ( & poll_msg -> pgmp_round ) ) ) ; bp = ( const u_char * ) ( poll_msg + 1 ) ; break ; } case PGM_POLR : { const struct pgm_polr * polr ; uint32_t ivl , rnd , mask ; polr = ( const struct pgm_polr * ) ( pgm + 1 ) ; ND_TCHECK ( * polr ) ; bp = ( const u_char * ) ( polr + 1 ) ; switch ( EXTRACT_16BITS ( & polr -> pgmp_nla_afi ) ) { case AFNUM_INET : ND_TCHECK2 ( * bp , sizeof ( struct in_addr ) ) ; addrtostr ( bp , nla_buf , sizeof ( nla_buf ) ) ; bp += sizeof ( struct in_addr ) ; break ; case AFNUM_INET6 : ND_TCHECK2 ( * bp , sizeof ( struct in6_addr ) ) ; addrtostr6 ( bp , nla_buf , sizeof ( nla_buf ) ) ; bp += sizeof ( struct in6_addr ) ; break ; default : goto trunc ; break ; } ND_TCHECK2 ( * bp , sizeof ( uint32_t ) ) ; ivl = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; ND_TCHECK2 ( * bp , sizeof ( uint32_t ) ) ; rnd = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; ND_TCHECK2 ( * bp , sizeof ( uint32_t ) ) ; mask = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; ND_PRINT ( ( ndo , ""POLRseq%uround%unla%sivl%urnd0x%08x"" ""mask0x%08x"" , EXTRACT_32BITS ( & polr -> pgmp_seq ) , EXTRACT_16BITS ( & polr -> pgmp_round ) , nla_buf , ivl , rnd , mask ) ) ; break ; } case PGM_ODATA : { const struct pgm_data * odata ; odata = ( const struct pgm_data * ) ( pgm + 1 ) ; ND_TCHECK ( * odata ) ; ND_PRINT ( ( ndo , ""ODATAtrail%useq%u"" , EXTRACT_32BITS ( & odata -> pgmd_trailseq ) , EXTRACT_32BITS ( & odata -> pgmd_seq ) ) ) ; bp = ( const u_char * ) ( odata + 1 ) ; break ; } case PGM_RDATA : { const struct pgm_data * rdata ; rdata = ( const struct pgm_data * ) ( pgm + 1 ) ; ND_TCHECK ( * rdata ) ; ND_PRINT ( ( ndo , ""RDATAtrail%useq%u"" , EXTRACT_32BITS ( & rdata -> pgmd_trailseq ) , EXTRACT_32BITS ( & rdata -> pgmd_seq ) ) ) ; bp = ( const u_char * ) ( rdata + 1 ) ; break ; } case PGM_NAK : case PGM_NULLNAK : case PGM_NCF : { const struct pgm_nak * nak ; char source_buf [ INET6_ADDRSTRLEN ] , group_buf [ INET6_ADDRSTRLEN ] ; nak = ( const struct pgm_nak * ) ( pgm + 1 ) ; ND_TCHECK ( * nak ) ; bp = ( const u_char * ) ( nak + 1 ) ; switch ( EXTRACT_16BITS ( & nak -> pgmn_source_afi ) ) { case AFNUM_INET : ND_TCHECK2 ( * bp , sizeof ( struct in_addr ) ) ; addrtostr ( bp , source_buf , sizeof ( source_buf ) ) ; bp += sizeof ( struct in_addr ) ; break ; case AFNUM_INET6 : ND_TCHECK2 ( * bp , sizeof ( struct in6_addr ) ) ; addrtostr6 ( bp , source_buf , sizeof ( source_buf ) ) ; bp += sizeof ( struct in6_addr ) ; break ; default : goto trunc ; break ; } bp += ( 2 * sizeof ( uint16_t ) ) ; switch ( EXTRACT_16BITS ( bp ) ) { case AFNUM_INET : ND_TCHECK2 ( * bp , sizeof ( struct in_addr ) ) ; addrtostr ( bp , group_buf , sizeof ( group_buf ) ) ; bp += sizeof ( struct in_addr ) ; break ; case AFNUM_INET6 : ND_TCHECK2 ( * bp , sizeof ( struct in6_addr ) ) ; addrtostr6 ( bp , group_buf , sizeof ( group_buf ) ) ; bp += sizeof ( struct in6_addr ) ; break ; default : goto trunc ; break ; } switch ( pgm -> pgm_type ) { case PGM_NAK : ND_PRINT ( ( ndo , ""NAK"" ) ) ; break ; case PGM_NULLNAK : ND_PRINT ( ( ndo , ""NNAK"" ) ) ; break ; case PGM_NCF : ND_PRINT ( ( ndo , ""NCF"" ) ) ; break ; default : break ; } ND_PRINT ( ( ndo , ""(%s->%s),seq%u"" , source_buf , group_buf , EXTRACT_32BITS ( & nak -> pgmn_seq ) ) ) ; break ; } case PGM_ACK : { const struct pgm_ack * ack ; ack = ( const struct pgm_ack * ) ( pgm + 1 ) ; ND_TCHECK ( * ack ) ; ND_PRINT ( ( ndo , ""ACKseq%u"" , EXTRACT_32BITS ( & ack -> pgma_rx_max_seq ) ) ) ; bp = ( const u_char * ) ( ack + 1 ) ; break ; } case PGM_SPMR : ND_PRINT ( ( ndo , ""SPMR"" ) ) ; break ; default : ND_PRINT ( ( ndo , ""UNKNOWNtype0x%02x"" , pgm -> pgm_type ) ) ; break ; } if ( pgm -> pgm_options & PGM_OPT_BIT_PRESENT ) { if ( ! ND_TTEST2 ( * bp , PGM_MIN_OPT_LEN ) ) { ND_PRINT ( ( ndo , ""[|OPT]"" ) ) ; return ; } opt_type = * bp ++ ; if ( ( opt_type & PGM_OPT_MASK ) != PGM_OPT_LENGTH ) { ND_PRINT ( ( ndo , ""[Firstoptionbad,shouldbePGM_OPT_LENGTH,is%u]"" , opt_type & PGM_OPT_MASK ) ) ; return ; } opt_len = * bp ++ ; if ( opt_len != 4 ) { ND_PRINT ( ( ndo , ""[BadOPT_LENGTHoption,length%u!=4]"" , opt_len ) ) ; return ; } opts_len = EXTRACT_16BITS ( bp ) ; if ( opts_len < 4 ) { ND_PRINT ( ( ndo , ""[Badtotaloptionlength%u<4]"" , opts_len ) ) ; return ; } bp += sizeof ( uint16_t ) ; ND_PRINT ( ( ndo , ""OPTSLEN%d"" , opts_len ) ) ; opts_len -= 4 ; while ( opts_len ) { if ( opts_len < PGM_MIN_OPT_LEN ) { ND_PRINT ( ( ndo , ""[Totaloptionlengthleavesnoroomforfinaloption]"" ) ) ; return ; } opt_type = * bp ++ ; opt_len = * bp ++ ; if ( opt_len < PGM_MIN_OPT_LEN ) { ND_PRINT ( ( ndo , ""[Badoption,length%u<%u]"" , opt_len , PGM_MIN_OPT_LEN ) ) ; break ; } if ( opts_len < opt_len ) { ND_PRINT ( ( ndo , ""[Totaloptionlengthleavesnoroomforfinaloption]"" ) ) ; return ; } if ( ! ND_TTEST2 ( * bp , opt_len - 2 ) ) { ND_PRINT ( ( ndo , ""[|OPT]"" ) ) ; return ; } switch ( opt_type & PGM_OPT_MASK ) { case PGM_OPT_LENGTH : if ( opt_len != 4 ) { ND_PRINT ( ( ndo , ""[BadOPT_LENGTHoption,length%u!=4]"" , opt_len ) ) ; return ; } ND_PRINT ( ( ndo , ""OPTSLEN(extra?)%d"" , EXTRACT_16BITS ( bp ) ) ) ; bp += sizeof ( uint16_t ) ; opts_len -= 4 ; break ; case PGM_OPT_FRAGMENT : if ( opt_len != 16 ) { ND_PRINT ( ( ndo , ""[BadOPT_FRAGMENToption,length%u!=16]"" , opt_len ) ) ; return ; } bp += 2 ; seq = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; offset = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; len = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; ND_PRINT ( ( ndo , ""FRAGseq%uoff%ulen%u"" , seq , offset , len ) ) ; opts_len -= 16 ; break ; case PGM_OPT_NAK_LIST : bp += 2 ; opt_len -= sizeof ( uint32_t ) ; ND_PRINT ( ( ndo , ""NAKLIST"" ) ) ; while ( opt_len ) { if ( opt_len < sizeof ( uint32_t ) ) { ND_PRINT ( ( ndo , ""[Optionlengthnotamultipleof4]"" ) ) ; return ; } ND_TCHECK2 ( * bp , sizeof ( uint32_t ) ) ; ND_PRINT ( ( ndo , ""%u"" , EXTRACT_32BITS ( bp ) ) ) ; bp += sizeof ( uint32_t ) ; opt_len -= sizeof ( uint32_t ) ; opts_len -= sizeof ( uint32_t ) ; } break ; case PGM_OPT_JOIN : if ( opt_len != 8 ) { ND_PRINT ( ( ndo , ""[BadOPT_JOINoption,length%u!=8]"" , opt_len ) ) ; return ; } bp += 2 ; seq = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; ND_PRINT ( ( ndo , ""JOIN%u"" , seq ) ) ; opts_len -= 8 ; break ; case PGM_OPT_NAK_BO_IVL : if ( opt_len != 12 ) { ND_PRINT ( ( ndo , ""[BadOPT_NAK_BO_IVLoption,length%u!=12]"" , opt_len ) ) ; return ; } bp += 2 ; offset = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; seq = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; ND_PRINT ( ( ndo , ""BACKOFFivl%uivlseq%u"" , offset , seq ) ) ; opts_len -= 12 ; break ; case PGM_OPT_NAK_BO_RNG : if ( opt_len != 12 ) { ND_PRINT ( ( ndo , ""[BadOPT_NAK_BO_RNGoption,length%u!=12]"" , opt_len ) ) ; return ; } bp += 2 ; offset = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; seq = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; ND_PRINT ( ( ndo , ""BACKOFFmax%umin%u"" , offset , seq ) ) ; opts_len -= 12 ; break ; case PGM_OPT_REDIRECT : bp += 2 ; nla_afnum = EXTRACT_16BITS ( bp ) ; bp += ( 2 * sizeof ( uint16_t ) ) ; switch ( nla_afnum ) { case AFNUM_INET : if ( opt_len != 4 + sizeof ( struct in_addr ) ) { ND_PRINT ( ( ndo , ""[BadOPT_REDIRECToption,length%u!=4+addresssize]"" , opt_len ) ) ; return ; } ND_TCHECK2 ( * bp , sizeof ( struct in_addr ) ) ; addrtostr ( bp , nla_buf , sizeof ( nla_buf ) ) ; bp += sizeof ( struct in_addr ) ; opts_len -= 4 + sizeof ( struct in_addr ) ; break ; case AFNUM_INET6 : if ( opt_len != 4 + sizeof ( struct in6_addr ) ) { ND_PRINT ( ( ndo , ""[BadOPT_REDIRECToption,length%u!=4+addresssize]"" , opt_len ) ) ; return ; } ND_TCHECK2 ( * bp , sizeof ( struct in6_addr ) ) ; addrtostr6 ( bp , nla_buf , sizeof ( nla_buf ) ) ; bp += sizeof ( struct in6_addr ) ; opts_len -= 4 + sizeof ( struct in6_addr ) ; break ; default : goto trunc ; break ; } ND_PRINT ( ( ndo , ""REDIRECT%s"" , nla_buf ) ) ; break ; case PGM_OPT_PARITY_PRM : if ( opt_len != 8 ) { ND_PRINT ( ( ndo , ""[BadOPT_PARITY_PRMoption,length%u!=8]"" , opt_len ) ) ; return ; } bp += 2 ; len = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; ND_PRINT ( ( ndo , ""PARITYMAXTGS%u"" , len ) ) ; opts_len -= 8 ; break ; case PGM_OPT_PARITY_GRP : if ( opt_len != 8 ) { ND_PRINT ( ( ndo , ""[BadOPT_PARITY_GRPoption,length%u!=8]"" , opt_len ) ) ; return ; } bp += 2 ; seq = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; ND_PRINT ( ( ndo , ""PARITYGROUP%u"" , seq ) ) ; opts_len -= 8 ; break ; case PGM_OPT_CURR_TGSIZE : if ( opt_len != 8 ) { ND_PRINT ( ( ndo , ""[BadOPT_CURR_TGSIZEoption,length%u!=8]"" , opt_len ) ) ; return ; } bp += 2 ; len = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; ND_PRINT ( ( ndo , ""PARITYATGS%u"" , len ) ) ; opts_len -= 8 ; break ; case PGM_OPT_NBR_UNREACH : if ( opt_len != 4 ) { ND_PRINT ( ( ndo , ""[BadOPT_NBR_UNREACHoption,length%u!=4]"" , opt_len ) ) ; return ; } bp += 2 ; ND_PRINT ( ( ndo , ""NBR_UNREACH"" ) ) ; opts_len -= 4 ; break ; case PGM_OPT_PATH_NLA : ND_PRINT ( ( ndo , ""PATH_NLA[%d]"" , opt_len ) ) ; bp += opt_len ; opts_len -= opt_len ; break ; case PGM_OPT_SYN : if ( opt_len != 4 ) { ND_PRINT ( ( ndo , ""[BadOPT_SYNoption,length%u!=4]"" , opt_len ) ) ; return ; } bp += 2 ; ND_PRINT ( ( ndo , ""SYN"" ) ) ; opts_len -= 4 ; break ; case PGM_OPT_FIN : if ( opt_len != 4 ) { ND_PRINT ( ( ndo , ""[BadOPT_FINoption,length%u!=4]"" , opt_len ) ) ; return ; } bp += 2 ; ND_PRINT ( ( ndo , ""FIN"" ) ) ; opts_len -= 4 ; break ; case PGM_OPT_RST : if ( opt_len != 4 ) { ND_PRINT ( ( ndo , ""[BadOPT_RSToption,length%u!=4]"" , opt_len ) ) ; return ; } bp += 2 ; ND_PRINT ( ( ndo , ""RST"" ) ) ; opts_len -= 4 ; break ; case PGM_OPT_CR : ND_PRINT ( ( ndo , ""CR"" ) ) ; bp += opt_len ; opts_len -= opt_len ; break ; case PGM_OPT_CRQST : if ( opt_len != 4 ) { ND_PRINT ( ( ndo , ""[BadOPT_CRQSToption,length%u!=4]"" , opt_len ) ) ; return ; } bp += 2 ; ND_PRINT ( ( ndo , ""CRQST"" ) ) ; opts_len -= 4 ; break ; case PGM_OPT_PGMCC_DATA : bp += 2 ; offset = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; nla_afnum = EXTRACT_16BITS ( bp ) ; bp += ( 2 * sizeof ( uint16_t ) ) ; switch ( nla_afnum ) { case AFNUM_INET : if ( opt_len != 12 + sizeof ( struct in_addr ) ) { ND_PRINT ( ( ndo , ""[BadOPT_PGMCC_DATAoption,length%u!=12+addresssize]"" , opt_len ) ) ; return ; } ND_TCHECK2 ( * bp , sizeof ( struct in_addr ) ) ; addrtostr ( bp , nla_buf , sizeof ( nla_buf ) ) ; bp += sizeof ( struct in_addr ) ; opts_len -= 12 + sizeof ( struct in_addr ) ; break ; case AFNUM_INET6 : if ( opt_len != 12 + sizeof ( struct in6_addr ) ) { ND_PRINT ( ( ndo , ""[BadOPT_PGMCC_DATAoption,length%u!=12+addresssize]"" , opt_len ) ) ; return ; } ND_TCHECK2 ( * bp , sizeof ( struct in6_addr ) ) ; addrtostr6 ( bp , nla_buf , sizeof ( nla_buf ) ) ; bp += sizeof ( struct in6_addr ) ; opts_len -= 12 + sizeof ( struct in6_addr ) ; break ; default : goto trunc ; break ; } ND_PRINT ( ( ndo , ""PGMCCDATA%u%s"" , offset , nla_buf ) ) ; break ; case PGM_OPT_PGMCC_FEEDBACK : bp += 2 ; offset = EXTRACT_32BITS ( bp ) ; bp += sizeof ( uint32_t ) ; nla_afnum = EXTRACT_16BITS ( bp ) ; bp += ( 2 * sizeof ( uint16_t ) ) ; switch ( nla_afnum ) { case AFNUM_INET : if ( opt_len != 12 + sizeof ( struct in_addr ) ) { ND_PRINT ( ( ndo , ""[BadOPT_PGMCC_DATAoption,length%u!=12+addresssize]"" , opt_len ) ) ; return ; } ND_TCHECK2 ( * bp , sizeof ( struct in_addr ) ) ; addrtostr ( bp , nla_buf , sizeof ( nla_buf ) ) ; bp += sizeof ( struct in_addr ) ; opts_len -= 12 + sizeof ( struct in_addr ) ; break ; case AFNUM_INET6 : if ( opt_len != 12 + sizeof ( struct in6_addr ) ) { ND_PRINT ( ( ndo , ""[BadOPT_PGMCC_DATAoption,length%u!=12+addresssize]"" , opt_len ) ) ; return ; } ND_TCHECK2 ( * bp , sizeof ( struct in6_addr ) ) ; addrtostr6 ( bp , nla_buf , sizeof ( nla_buf ) ) ; bp += sizeof ( struct in6_addr ) ; opts_len -= 12 + sizeof ( struct in6_addr ) ; break ; default : goto trunc ; break ; } ND_PRINT ( ( ndo , ""PGMCCFEEDBACK%u%s"" , offset , nla_buf ) ) ; break ; default : ND_PRINT ( ( ndo , ""OPT_%02X[%d]"" , opt_type , opt_len ) ) ; bp += opt_len ; opts_len -= opt_len ; break ; } if ( opt_type & PGM_OPT_END ) break ; } } ND_PRINT ( ( ndo , ""[%u]"" , length ) ) ; if ( ndo -> ndo_packettype == PT_PGM_ZMTP1 && ( pgm -> pgm_type == PGM_ODATA || pgm -> pgm_type == PGM_RDATA ) ) zmtp1_print_datagram ( ndo , bp , EXTRACT_16BITS ( & pgm -> pgm_length ) ) ; return ; trunc : ND_PRINT ( ( ndo , ""[|pgm]"" ) ) ; if ( ch != '\\0' ) ND_PRINT ( ( ndo , "">"" ) ) ; } "," return ; } if ( ! ND_TTEST2 ( * bp , 2 ) ) { ND_PRINT ( ( ndo , ""[|OPT]"" ) ) ; return ; } ",the-tcpdump-group@tcpdump/26a6799b9ca80508c05cac7a9a3bef922991520b,CVE-2017-13018,https://github.com/the-tcpdump-group/tcpdump/commit/26a6799b9ca80508c05cac7a9a3bef922991520b,2017-09-14T06:29Z 1271,CWE-119,"CWE-119 void vp9_rd_pick_intra_mode_sb ( VP9_COMP * cpi , MACROBLOCK * x , int * returnrate , int64_t * returndist , BLOCK_SIZE bsize , PICK_MODE_CONTEXT * ctx , int64_t best_rd ) { VP9_COMMON * const cm = & cpi -> common ; MACROBLOCKD * const xd = & x -> e_mbd ; int rate_y = 0 , rate_uv = 0 , rate_y_tokenonly = 0 , rate_uv_tokenonly = 0 ; int y_skip = 0 , uv_skip = 0 ; int64_t dist_y = 0 , dist_uv = 0 , tx_cache [ TX_MODES ] = { 0 } ; TX_SIZE max_uv_tx_size ; x -> skip_encode = 0 ; ctx -> skip = 0 ; xd -> mi [ 0 ] -> mbmi . ref_frame [ 0 ] = INTRA_FRAME ; if ( bsize >= BLOCK_8X8 ) { if ( rd_pick_intra_sby_mode ( cpi , x , & rate_y , & rate_y_tokenonly , & dist_y , & y_skip , bsize , tx_cache , best_rd ) >= best_rd ) { * returnrate = INT_MAX ; return ; } max_uv_tx_size = get_uv_tx_size_impl ( xd -> mi [ 0 ] -> mbmi . tx_size , bsize ) ; rd_pick_intra_sbuv_mode ( cpi , x , ctx , & rate_uv , & rate_uv_tokenonly , & dist_uv , & uv_skip , bsize , max_uv_tx_size ) ; } else { y_skip = 0 ; if ( rd_pick_intra_sub_8x8_y_mode ( cpi , x , & rate_y , & rate_y_tokenonly , & dist_y , best_rd ) >= best_rd ) { * returnrate = INT_MAX ; return ; } max_uv_tx_size = get_uv_tx_size_impl ( xd -> mi [ 0 ] -> mbmi . tx_size , bsize ) ; rd_pick_intra_sbuv_mode ( cpi , x , ctx , & rate_uv , & rate_uv_tokenonly , & dist_uv , & uv_skip , BLOCK_8X8 , max_uv_tx_size ) ; } if ( y_skip && uv_skip ) { * returnrate = rate_y + rate_uv - rate_y_tokenonly - rate_uv_tokenonly + vp9_cost_bit ( vp9_get_skip_prob ( cm , xd ) , 1 ) ; * returndist = dist_y + dist_uv ; vp9_zero ( ctx -> tx_rd_diff ) ; } else { int i ; * returnrate = rate_y + rate_uv + vp9_cost_bit ( vp9_get_skip_prob ( cm , xd ) , 0 ) ; * returndist = dist_y + dist_uv ; if ( cpi -> sf . tx_size_search_method == USE_FULL_RD ) for ( i = 0 ; i < TX_MODES ; i ++ ) { if ( tx_cache [ i ] < INT64_MAX && tx_cache [ cm -> tx_mode ] < INT64_MAX ) ctx -> tx_rd_diff [ i ] = tx_cache [ i ] - tx_cache [ cm -> tx_mode ] ; else ctx -> tx_rd_diff [ i ] = 0 ; } } ctx -> mic = * xd -> mi [ 0 ] ; } "," * x , RD_COST * rd_cost , BLOCK_SIZE bsize , -> e_mbd ; struct macroblockd_plane * const pd = xd -> plane ; dist_uv = 0 ; TX_SIZE max_uv_tx_size = INTRA_FRAME ; xd -> mi [ 0 ] -> mbmi . ref_frame [ 1 ] = NONE ; , bsize , best_rd ) >= best_rd ) { rd_cost -> rate = INT_MAX ; ; return ; } } else { y_skip = 0 ; if ( rd_pick_intra_sub_8x8_y_mode ( cpi , x , & rate_y , & rate_y_tokenonly , & dist_y , best_rd ) >= best_rd ) { rd_cost -> rate = INT_MAX ; return ; } tx_size , bsize , pd [ 1 ] . subsampling_x , pd [ 1 ] . subsampling_y & uv_skip , MAX ( BLOCK_8X8 , bsize ) , max_uv_tx_size ) ; max_uv_tx_size ) ; if ( y_skip uv_skip ) { rd_cost -> rate = rate_y + 1 ) ; rd_cost -> dist = dist_y + + dist_uv ; } else { rd_cost -> rate = rate_y + rate_uv + vp9_cost_bit ( vp9_get_skip_prob ( cm , xd ) , 0 ) ; rd_cost -> dist = dist_y + dist_uv ; } ctx -> mic = * xd -> mi [ 0 ] ; ctx -> mbmi_ext = * x -> mbmi_ext ; rd_cost -> rdcost = RDCOST ( x -> rdmult , x -> rddiv , rd_cost -> rate , rd_cost -> dist ) ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1272,CWE-20,"CWE-20 static Image * ReadCALSImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { char filename [ MagickPathExtent ] , header [ MagickPathExtent ] , message [ MagickPathExtent ] ; FILE * file ; Image * image ; ImageInfo * read_info ; int c , unique_file ; MagickBooleanType status ; register ssize_t i ; unsigned long density , direction , height , orientation , pel_path , type , width ; 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 ( header , 0 , sizeof ( header ) ) ; density = 0 ; direction = 0 ; orientation = 1 ; pel_path = 0 ; type = 1 ; width = 0 ; height = 0 ; for ( i = 0 ; i < 16 ; i ++ ) { if ( ReadBlob ( image , 128 , ( unsigned char * ) header ) != 128 ) break ; switch ( * header ) { case 'R' : case 'r' : { if ( LocaleNCompare ( header , ""rdensty:"" , 8 ) == 0 ) { ( void ) sscanf ( header + 8 , ""%lu"" , & density ) ; break ; } if ( LocaleNCompare ( header , ""rpelcnt:"" , 8 ) == 0 ) { ( void ) sscanf ( header + 8 , ""%lu,%lu"" , & width , & height ) ; break ; } if ( LocaleNCompare ( header , ""rorient:"" , 8 ) == 0 ) { ( void ) sscanf ( header + 8 , ""%lu,%lu"" , & pel_path , & direction ) ; if ( pel_path == 90 ) orientation = 5 ; else if ( pel_path == 180 ) orientation = 3 ; else if ( pel_path == 270 ) orientation = 7 ; if ( direction == 90 ) orientation ++ ; break ; } if ( LocaleNCompare ( header , ""rtype:"" , 6 ) == 0 ) { ( void ) sscanf ( header + 6 , ""%lu"" , & type ) ; break ; } break ; } } } file = ( FILE * ) NULL ; unique_file = AcquireUniqueFileResource ( filename ) ; if ( unique_file != - 1 ) file = fdopen ( unique_file , ""wb"" ) ; if ( ( unique_file == - 1 ) || ( file == ( FILE * ) NULL ) ) ThrowImageException ( FileOpenError , ""UnableToCreateTemporaryFile"" ) ; while ( ( c = ReadBlobByte ( image ) ) != EOF ) ( void ) fputc ( c , file ) ; ( void ) fclose ( file ) ; ( void ) CloseBlob ( image ) ; image = DestroyImage ( image ) ; read_info = CloneImageInfo ( image_info ) ; SetImageInfoBlob ( read_info , ( void * ) NULL , 0 ) ; ( void ) FormatLocaleString ( read_info -> filename , MagickPathExtent , ""group4:%s"" , filename ) ; ( void ) FormatLocaleString ( message , MagickPathExtent , ""%lux%lu"" , width , height ) ; ( void ) CloneString ( & read_info -> size , message ) ; ( void ) FormatLocaleString ( message , MagickPathExtent , ""%lu"" , density ) ; ( void ) CloneString ( & read_info -> density , message ) ; read_info -> orientation = ( OrientationType ) orientation ; image = ReadImage ( read_info , exception ) ; if ( image != ( Image * ) NULL ) { ( void ) CopyMagickString ( image -> filename , image_info -> filename , MagickPathExtent ) ; ( void ) CopyMagickString ( image -> magick_filename , image_info -> filename , MagickPathExtent ) ; ( void ) CopyMagickString ( image -> magick , ""CALS"" , MagickPathExtent ) ; } read_info = DestroyImageInfo ( read_info ) ; ( void ) RelinquishUniqueFileResource ( filename ) ; return ( image ) ; } "," != EOF ) if ( fputc ( c , file ) != c ) break ",ImageMagick@ImageMagick/6b6bff054d569a77973f2140c0e86366e6168a6c,CVE-2018-16643,https://github.com/ImageMagick/ImageMagick/commit/6b6bff054d569a77973f2140c0e86366e6168a6c,2018-09-06T22:29Z 1273,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 1274,CWE-264,"CWE-264 void * arm_dma_alloc ( struct device * dev , size_t size , dma_addr_t * handle , gfp_t gfp , struct dma_attrs * attrs ) { pgprot_t prot = __get_dma_pgprot ( attrs , pgprot_kernel ) ; void * memory ; if ( dma_alloc_from_coherent ( dev , size , handle , & memory ) ) return memory ; return __dma_alloc ( dev , size , handle , gfp , prot , false , __builtin_return_address ( 0 ) ) ; } "," ( attrs , PAGE_KERNEL ) ; void ",torvalds@linux/0ea1ec713f04bdfac343c9702b21cd3a7c711826,CVE-2014-9888,https://github.com/torvalds/linux/commit/0ea1ec713f04bdfac343c9702b21cd3a7c711826,2016-08-06T10:59Z 1275,CWE-617,"CWE-617 static int pci_emul_mem_handler ( struct vmctx * ctx , int vcpu , int dir , uint64_t addr , int size , uint64_t * val , void * arg1 , long arg2 ) { struct pci_vdev * pdi = arg1 ; struct pci_vdev_ops * ops = pdi -> dev_ops ; uint64_t offset ; int bidx = ( int ) arg2 ; assert ( bidx <= PCI_BARMAX ) ; assert ( pdi -> bar [ bidx ] . type == PCIBAR_MEM32 || pdi -> bar [ bidx ] . type == PCIBAR_MEM64 ) ; assert ( addr >= pdi -> bar [ bidx ] . addr && addr + size <= pdi -> bar [ bidx ] . addr + pdi -> bar [ bidx ] . size ) ; offset = addr - pdi -> bar [ bidx ] . addr ; if ( dir == MEM_F_WRITE ) { if ( size == 8 ) { ( * ops -> vdev_barwrite ) ( ctx , vcpu , pdi , bidx , offset , 4 , * val & 0xffffffff ) ; ( * ops -> vdev_barwrite ) ( ctx , vcpu , pdi , bidx , offset + 4 , 4 , * val >> 32 ) ; } else { ( * ops -> vdev_barwrite ) ( ctx , vcpu , pdi , bidx , offset , size , bar_value ( size , * val ) ) ; } } else { if ( size == 8 ) { uint64_t val_lo , val_hi ; val_lo = ( * ops -> vdev_barread ) ( ctx , vcpu , pdi , bidx , offset , 4 ) ; val_lo = bar_value ( 4 , val_lo ) ; val_hi = ( * ops -> vdev_barread ) ( ctx , vcpu , pdi , bidx , offset + 4 , 4 ) ; * val = val_lo | ( val_hi << 32 ) ; } else { * val = ( * ops -> vdev_barread ) ( ctx , vcpu , pdi , bidx , offset , size ) ; * val = bar_value ( size , * val ) ; } } return 0 ; } "," ) arg2 ; if ( addr + size > pdi -> bar bidx ] . addr + pdi -> bar bidx ] . size ) { printf ( ""%s,Outofemulatedmemoryrange.\\n"" , __func__ ) ; return - ESRCH ; } offset = addr ",projectacrn@acrn-hypervisor/6199e653418eda58cd698d8769820904453e2535,CVE-2019-18844,https://github.com/projectacrn/acrn-hypervisor/commit/6199e653418eda58cd698d8769820904453e2535,2019-11-13T20:15Z 1276,CWE-415,"CWE-415 static int sctp_wait_for_sndbuf ( struct sctp_association * asoc , long * timeo_p , size_t msg_len ) { struct sock * sk = asoc -> base . sk ; int err = 0 ; long current_timeo = * timeo_p ; DEFINE_WAIT ( wait ) ; pr_debug ( ""%s:asoc:%p,timeo:%ld,msg_len:%zu\\n"" , __func__ , asoc , * timeo_p , msg_len ) ; sctp_association_hold ( asoc ) ; for ( ; ; ) { prepare_to_wait_exclusive ( & asoc -> wait , & wait , TASK_INTERRUPTIBLE ) ; if ( ! * timeo_p ) goto do_nonblock ; if ( sk -> sk_err || asoc -> state >= SCTP_STATE_SHUTDOWN_PENDING || asoc -> base . dead ) goto do_error ; if ( signal_pending ( current ) ) goto do_interrupted ; if ( msg_len <= sctp_wspace ( asoc ) ) break ; release_sock ( sk ) ; current_timeo = schedule_timeout ( current_timeo ) ; if ( sk != asoc -> base . sk ) goto do_error ; lock_sock ( sk ) ; * timeo_p = current_timeo ; } out : finish_wait ( & asoc -> wait , & wait ) ; sctp_association_put ( asoc ) ; return err ; do_error : err = - EPIPE ; goto out ; do_interrupted : err = sock_intr_errno ( * timeo_p ) ; goto out ; do_nonblock : err = - EAGAIN ; goto out ; } "," current_timeo ) ; lock_sock ( sk ",torvalds@linux/dfcb9f4f99f1e9a49e43398a7bfbf56927544af1,CVE-2017-6353,https://github.com/torvalds/linux/commit/dfcb9f4f99f1e9a49e43398a7bfbf56927544af1,2017-03-01T20:59Z 1277,CWE-119,"CWE-119 static Image * ReadCUTImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { Image * image , * palette ; ImageInfo * clone_info ; MagickBooleanType status ; MagickOffsetType offset ; size_t EncodedByte ; unsigned char RunCount , RunValue , RunCountMasked ; CUTHeader Header ; CUTPalHeader PalHeader ; ssize_t depth ; ssize_t i , j ; ssize_t ldblk ; unsigned char * BImgBuff = NULL , * ptrB ; PixelPacket * q ; 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 ) ; } palette = NULL ; clone_info = NULL ; Header . Width = ReadBlobLSBShort ( image ) ; Header . Height = ReadBlobLSBShort ( image ) ; Header . Reserved = ReadBlobLSBShort ( image ) ; if ( Header . Width == 0 || Header . Height == 0 || Header . Reserved != 0 ) CUT_KO : ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; EncodedByte = ReadBlobLSBShort ( image ) ; RunCount = ( unsigned char ) ReadBlobByte ( image ) ; RunCountMasked = RunCount & 0x7F ; ldblk = 0 ; while ( ( int ) RunCountMasked != 0 ) { i = 1 ; if ( ( int ) RunCount < 0x80 ) i = ( ssize_t ) RunCountMasked ; offset = SeekBlob ( image , TellBlob ( image ) + i , SEEK_SET ) ; if ( offset < 0 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; if ( EOFBlob ( image ) != MagickFalse ) goto CUT_KO ; EncodedByte -= i + 1 ; ldblk += ( ssize_t ) RunCountMasked ; RunCount = ( unsigned char ) ReadBlobByte ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) goto CUT_KO ; RunCountMasked = RunCount & 0x7F ; } if ( EncodedByte != 1 ) goto CUT_KO ; i = 0 ; if ( ldblk == ( int ) Header . Width ) i = 8 ; if ( 2 * ldblk == ( int ) Header . Width ) i = 4 ; if ( 8 * ldblk == ( int ) Header . Width ) i = 1 ; if ( i == 0 ) goto CUT_KO ; depth = i ; image -> columns = Header . Width ; image -> rows = Header . Height ; image -> depth = 8 ; image -> colors = ( size_t ) ( GetQuantumRange ( 1UL * i ) + 1 ) ; if ( image_info -> ping ) goto Finish ; if ( ( clone_info = CloneImageInfo ( image_info ) ) == NULL ) goto NoPalette ; i = ( ssize_t ) strlen ( clone_info -> filename ) ; j = i ; while ( -- i > 0 ) { if ( clone_info -> filename [ i ] == '.' ) { break ; } if ( clone_info -> filename [ i ] == '/' || clone_info -> filename [ i ] == '\\\\' || clone_info -> filename [ i ] == ':' ) { i = j ; break ; } } ( void ) CopyMagickString ( clone_info -> filename + i , "".PAL"" , ( size_t ) ( MaxTextExtent - i ) ) ; if ( ( clone_info -> file = fopen_utf8 ( clone_info -> filename , ""rb"" ) ) == NULL ) { ( void ) CopyMagickString ( clone_info -> filename + i , "".pal"" , ( size_t ) ( MaxTextExtent - i ) ) ; if ( ( clone_info -> file = fopen_utf8 ( clone_info -> filename , ""rb"" ) ) == NULL ) { clone_info -> filename [ i ] = '\\0' ; if ( ( clone_info -> file = fopen_utf8 ( clone_info -> filename , ""rb"" ) ) == NULL ) { clone_info = DestroyImageInfo ( clone_info ) ; clone_info = NULL ; goto NoPalette ; } } } if ( ( palette = AcquireImage ( clone_info ) ) == NULL ) goto NoPalette ; status = OpenBlob ( clone_info , palette , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { ErasePalette : palette = DestroyImage ( palette ) ; palette = NULL ; goto NoPalette ; } if ( palette != NULL ) { ( void ) ReadBlob ( palette , 2 , ( unsigned char * ) PalHeader . FileId ) ; if ( strncmp ( PalHeader . FileId , ""AH"" , 2 ) != 0 ) goto ErasePalette ; PalHeader . Version = ReadBlobLSBShort ( palette ) ; PalHeader . Size = ReadBlobLSBShort ( palette ) ; PalHeader . FileType = ( char ) ReadBlobByte ( palette ) ; PalHeader . SubType = ( char ) ReadBlobByte ( palette ) ; PalHeader . BoardID = ReadBlobLSBShort ( palette ) ; PalHeader . GraphicsMode = ReadBlobLSBShort ( palette ) ; PalHeader . MaxIndex = ReadBlobLSBShort ( palette ) ; PalHeader . MaxRed = ReadBlobLSBShort ( palette ) ; PalHeader . MaxGreen = ReadBlobLSBShort ( palette ) ; PalHeader . MaxBlue = ReadBlobLSBShort ( palette ) ; ( void ) ReadBlob ( palette , 20 , ( unsigned char * ) PalHeader . PaletteId ) ; if ( PalHeader . MaxIndex < 1 ) goto ErasePalette ; image -> colors = PalHeader . MaxIndex + 1 ; if ( AcquireImageColormap ( image , image -> colors ) == MagickFalse ) goto NoMemory ; if ( PalHeader . MaxRed == 0 ) PalHeader . MaxRed = ( unsigned int ) QuantumRange ; if ( PalHeader . MaxGreen == 0 ) PalHeader . MaxGreen = ( unsigned int ) QuantumRange ; if ( PalHeader . MaxBlue == 0 ) PalHeader . MaxBlue = ( unsigned int ) QuantumRange ; for ( i = 0 ; i <= ( int ) PalHeader . MaxIndex ; i ++ ) { j = ( ssize_t ) TellBlob ( palette ) ; if ( ( j % 512 ) > 512 - 6 ) { j = ( ( j / 512 ) + 1 ) * 512 ; offset = SeekBlob ( palette , j , SEEK_SET ) ; if ( offset < 0 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; } image -> colormap [ i ] . red = ( Quantum ) ReadBlobLSBShort ( palette ) ; if ( QuantumRange != ( Quantum ) PalHeader . MaxRed ) { image -> colormap [ i ] . red = ClampToQuantum ( ( ( double ) image -> colormap [ i ] . red * QuantumRange + ( PalHeader . MaxRed >> 1 ) ) / PalHeader . MaxRed ) ; } image -> colormap [ i ] . green = ( Quantum ) ReadBlobLSBShort ( palette ) ; if ( QuantumRange != ( Quantum ) PalHeader . MaxGreen ) { image -> colormap [ i ] . green = ClampToQuantum ( ( ( double ) image -> colormap [ i ] . green * QuantumRange + ( PalHeader . MaxGreen >> 1 ) ) / PalHeader . MaxGreen ) ; } image -> colormap [ i ] . blue = ( Quantum ) ReadBlobLSBShort ( palette ) ; if ( QuantumRange != ( Quantum ) PalHeader . MaxBlue ) { image -> colormap [ i ] . blue = ClampToQuantum ( ( ( double ) image -> colormap [ i ] . blue * QuantumRange + ( PalHeader . MaxBlue >> 1 ) ) / PalHeader . MaxBlue ) ; } } } NoPalette : if ( palette == NULL ) { image -> colors = 256 ; if ( AcquireImageColormap ( image , image -> colors ) == MagickFalse ) { NoMemory : ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; } 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 ) ; } } BImgBuff = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) ldblk , sizeof ( * BImgBuff ) ) ; if ( BImgBuff == NULL ) goto NoMemory ; offset = SeekBlob ( image , 6 , SEEK_SET ) ; if ( offset < 0 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; for ( i = 0 ; i < ( int ) Header . Height ; i ++ ) { EncodedByte = ReadBlobLSBShort ( image ) ; ptrB = BImgBuff ; j = ldblk ; RunCount = ( unsigned char ) ReadBlobByte ( image ) ; RunCountMasked = RunCount & 0x7F ; while ( ( int ) RunCountMasked != 0 ) { if ( ( ssize_t ) RunCountMasked > j ) { RunCountMasked = ( unsigned char ) j ; if ( j == 0 ) { break ; } } if ( ( int ) RunCount > 0x80 ) { RunValue = ( unsigned char ) ReadBlobByte ( image ) ; ( void ) ResetMagickMemory ( ptrB , ( int ) RunValue , ( size_t ) RunCountMasked ) ; } else { ( void ) ReadBlob ( image , ( size_t ) RunCountMasked , ptrB ) ; } ptrB += ( int ) RunCountMasked ; j -= ( int ) RunCountMasked ; if ( EOFBlob ( image ) != MagickFalse ) goto Finish ; RunCount = ( unsigned char ) ReadBlobByte ( image ) ; RunCountMasked = RunCount & 0x7F ; } InsertRow ( depth , BImgBuff , i , image ) ; } ( void ) SyncImage ( image ) ; if ( palette == NULL ) { if ( ( image -> storage_class == PseudoClass ) && ( IsGrayImage ( image , & image -> exception ) != MagickFalse ) ) { if ( GetCutColors ( image ) == 2 ) { for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { register Quantum sample ; sample = ScaleCharToQuantum ( ( unsigned char ) i ) ; if ( image -> colormap [ i ] . red != sample ) goto Finish ; if ( image -> colormap [ i ] . green != sample ) goto Finish ; if ( image -> colormap [ i ] . blue != sample ) goto Finish ; } image -> colormap [ 1 ] . red = image -> colormap [ 1 ] . green = image -> colormap [ 1 ] . blue = QuantumRange ; for ( i = 0 ; i < ( ssize_t ) image -> rows ; i ++ ) { q = QueueAuthenticPixels ( image , 0 , i , image -> columns , 1 , exception ) ; for ( j = 0 ; j < ( ssize_t ) image -> columns ; j ++ ) { if ( GetPixelRed ( q ) == ScaleCharToQuantum ( 1 ) ) { SetPixelRed ( q , QuantumRange ) ; SetPixelGreen ( q , QuantumRange ) ; SetPixelBlue ( q , QuantumRange ) ; } q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) goto Finish ; } } } } Finish : if ( BImgBuff != NULL ) BImgBuff = ( unsigned char * ) RelinquishMagickMemory ( BImgBuff ) ; if ( palette != NULL ) palette = DestroyImage ( palette ) ; if ( clone_info != NULL ) clone_info = DestroyImageInfo ( clone_info ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowFileException ( exception , CorruptImageError , ""UnexpectedEndOfFile"" , image -> filename ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; } "," image_info -> ping != MagickFalse goto Finish ; 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 1278,CWE-119,"CWE-119 DECLAREreadFunc ( readContigTilesIntoBuffer ) { int status = 1 ; tsize_t tilesize = TIFFTileSize ( in ) ; tdata_t tilebuf ; uint32 imagew = TIFFScanlineSize ( in ) ; uint32 tilew = TIFFTileRowSize ( in ) ; int iskew = imagew - tilew ; uint8 * bufp = ( uint8 * ) buf ; uint32 tw , tl ; uint32 row ; ( void ) spp ; tilebuf = _TIFFmalloc ( tilesize ) ; if ( tilebuf == 0 ) return 0 ; _TIFFmemset ( tilebuf , 0 , tilesize ) ; ( void ) TIFFGetField ( in , TIFFTAG_TILEWIDTH , & tw ) ; ( void ) TIFFGetField ( in , TIFFTAG_TILELENGTH , & tl ) ; for ( row = 0 ; row < imagelength ; row += tl ) { uint32 nrow = ( row + tl > imagelength ) ? imagelength - row : tl ; uint32 colb = 0 ; uint32 col ; for ( col = 0 ; col < imagewidth ; col += tw ) { if ( TIFFReadTile ( in , tilebuf , col , row , 0 , 0 ) < 0 && ! ignore ) { TIFFError ( TIFFFileName ( in ) , ""Error,can\'treadtileat%lu%lu"" , ( unsigned long ) col , ( unsigned long ) row ) ; status = 0 ; goto done ; } if ( colb + tilew > imagew ) { uint32 width = imagew - colb ; uint32 oskew = tilew - width ; cpStripToTile ( bufp + colb , tilebuf , nrow , width , oskew + iskew , oskew ) ; } else cpStripToTile ( bufp + colb , tilebuf , nrow , tilew , iskew , 0 ) ; colb += tilew ; } bufp += imagew * nrow ; } done : _TIFFfree ( tilebuf ) ; return status ; } "," col < imagewidth && colb < imagew ",vadz@libtiff/5ad9d8016fbb60109302d558f7edb2cb2a3bb8e3,CVE-2016-9540,https://github.com/vadz/libtiff/commit/5ad9d8016fbb60109302d558f7edb2cb2a3bb8e3,2016-11-22T19:59Z 1279,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 * number_planes_filled * sizeof ( * pixels ) ) ; if ( pixel_info == ( MemoryInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , ""MemoryAllocationFailed"" ) ; pixel_info_length = image -> columns * image -> rows * number_planes_filled ; 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 ) ) ; } "," -> rows * MagickMax ( number_planes_filled , 4 ) * sizeof ( -> rows * MagickMax ( number_planes_filled , 4 ) ; pixels = ",ImageMagick@ImageMagick/13db820f5e24cd993ee554e99377fea02a904e18,CVE-2016-10049,https://github.com/ImageMagick/ImageMagick/commit/13db820f5e24cd993ee554e99377fea02a904e18,2017-03-23T17:59Z 1280,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 1281,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 1282,CWE-125,"CWE-125 static int parsestr ( struct compiling * c , const node * n , int * bytesmode , int * rawmode , PyObject * * result , const char * * fstr , Py_ssize_t * fstrlen ) { size_t len ; const char * s = STR ( n ) ; int quote = Py_CHARMASK ( * s ) ; int fmode = 0 ; * bytesmode = 0 ; * rawmode = 0 ; * result = NULL ; * fstr = NULL ; if ( Py_ISALPHA ( quote ) ) { while ( ! * bytesmode || ! * rawmode ) { if ( quote == 'b' || quote == 'B' ) { quote = * ++ s ; * bytesmode = 1 ; } else if ( quote == 'u' || quote == 'U' ) { quote = * ++ s ; } else if ( quote == 'r' || quote == 'R' ) { quote = * ++ s ; * rawmode = 1 ; } else if ( quote == 'f' || quote == 'F' ) { quote = * ++ s ; fmode = 1 ; } else { break ; } } } if ( fmode && * bytesmode ) { PyErr_BadInternalCall ( ) ; return - 1 ; } if ( quote != '\\'' && quote != \'\\""\' ) { PyErr_BadInternalCall ( ) ; return - 1 ; } s ++ ; len = strlen ( s ) ; if ( len > INT_MAX ) { PyErr_SetString ( PyExc_OverflowError , ""stringtoparseistoolong"" ) ; return - 1 ; } if ( s [ -- len ] != quote ) { PyErr_BadInternalCall ( ) ; return - 1 ; } if ( len >= 4 && s [ 0 ] == quote && s [ 1 ] == quote ) { s += 2 ; len -= 2 ; if ( s [ -- len ] != quote || s [ -- len ] != quote ) { PyErr_BadInternalCall ( ) ; return - 1 ; } } if ( fmode ) { * fstr = s ; * fstrlen = len ; return 0 ; } * rawmode = * rawmode || strchr ( s , '\\\\' ) == NULL ; if ( * bytesmode ) { const char * ch ; for ( ch = s ; * ch ; ch ++ ) { if ( Py_CHARMASK ( * ch ) >= 0x80 ) { ast_error ( c , n , ""bytescanonlycontainASCII"" ""literalcharacters."" ) ; return - 1 ; } } if ( * rawmode ) * result = PyBytes_FromStringAndSize ( s , len ) ; else * result = decode_bytes_with_escapes ( c , n , s , len ) ; } else { if ( * rawmode ) * result = PyUnicode_DecodeUTF8Stateful ( s , len , NULL , NULL ) ; else * result = decode_unicode_with_escapes ( c , n , s , len ) ; } return * result == NULL ? - 1 : 0 ; } "," ",python@typed_ast/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,CVE-2019-19275,https://github.com/python/typed_ast/commit/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,2019-11-26T15:15Z 1283,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 1284,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 1285,CWE-20,"CWE-20 static int cma_req_handler ( struct ib_cm_id * cm_id , struct ib_cm_event * ib_event ) { struct rdma_id_private * listen_id , * conn_id ; struct rdma_cm_event event ; int offset , ret ; u8 smac [ ETH_ALEN ] ; u8 alt_smac [ ETH_ALEN ] ; u8 * psmac = smac ; u8 * palt_smac = alt_smac ; int is_iboe = ( ( rdma_node_get_transport ( cm_id -> device -> node_type ) == RDMA_TRANSPORT_IB ) && ( rdma_port_get_link_layer ( cm_id -> device , ib_event -> param . req_rcvd . port ) == IB_LINK_LAYER_ETHERNET ) ) ; listen_id = cm_id -> context ; if ( ! cma_check_req_qp_type ( & listen_id -> id , ib_event ) ) return - EINVAL ; if ( cma_disable_callback ( listen_id , RDMA_CM_LISTEN ) ) return - ECONNABORTED ; memset ( & event , 0 , sizeof event ) ; offset = cma_user_data_offset ( listen_id ) ; event . event = RDMA_CM_EVENT_CONNECT_REQUEST ; if ( ib_event -> event == IB_CM_SIDR_REQ_RECEIVED ) { conn_id = cma_new_udp_id ( & listen_id -> id , ib_event ) ; event . param . ud . private_data = ib_event -> private_data + offset ; event . param . ud . private_data_len = IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE - offset ; } else { conn_id = cma_new_conn_id ( & listen_id -> id , ib_event ) ; cma_set_req_event_data ( & event , & ib_event -> param . req_rcvd , ib_event -> private_data , offset ) ; } if ( ! conn_id ) { ret = - ENOMEM ; goto err1 ; } mutex_lock_nested ( & conn_id -> handler_mutex , SINGLE_DEPTH_NESTING ) ; ret = cma_acquire_dev ( conn_id , listen_id ) ; if ( ret ) goto err2 ; conn_id -> cm_id . ib = cm_id ; cm_id -> context = conn_id ; cm_id -> cm_handler = cma_ib_handler ; atomic_inc ( & conn_id -> refcount ) ; ret = conn_id -> id . event_handler ( & conn_id -> id , & event ) ; if ( ret ) goto err3 ; if ( is_iboe ) { if ( ib_event -> param . req_rcvd . primary_path != NULL ) rdma_addr_find_smac_by_sgid ( & ib_event -> param . req_rcvd . primary_path -> sgid , psmac , NULL ) ; else psmac = NULL ; if ( ib_event -> param . req_rcvd . alternate_path != NULL ) rdma_addr_find_smac_by_sgid ( & ib_event -> param . req_rcvd . alternate_path -> sgid , palt_smac , NULL ) ; else palt_smac = NULL ; } mutex_lock ( & lock ) ; if ( is_iboe ) ib_update_cm_av ( cm_id , psmac , palt_smac ) ; if ( cma_comp ( conn_id , RDMA_CM_CONNECT ) && ( conn_id -> id . qp_type != IB_QPT_UD ) ) ib_send_cm_mra ( cm_id , CMA_CM_MRA_SETTING , NULL , 0 ) ; mutex_unlock ( & lock ) ; mutex_unlock ( & conn_id -> handler_mutex ) ; mutex_unlock ( & listen_id -> handler_mutex ) ; cma_deref_id ( conn_id ) ; return 0 ; err3 : cma_deref_id ( conn_id ) ; conn_id -> cm_id . ib = NULL ; err2 : cma_exch ( conn_id , RDMA_CM_DESTROYING ) ; mutex_unlock ( & conn_id -> handler_mutex ) ; err1 : mutex_unlock ( & listen_id -> handler_mutex ) ; if ( conn_id ) rdma_destroy_id ( & conn_id -> id ) ; return ret ; } "," , ret ; listen_id = cm_id goto err3 ; mutex_lock ( & ( & lock ) ; if ",torvalds@linux/b2853fd6c2d0f383dbdf7427e263eb576a633867,CVE-2014-2739,https://github.com/torvalds/linux/commit/b2853fd6c2d0f383dbdf7427e263eb576a633867,2014-04-14T23:55Z 1286,CWE-476,"CWE-476 BOOL transport_accept_nla ( rdpTransport * transport ) { freerdp * instance ; rdpSettings * settings ; if ( transport -> TlsIn == NULL ) transport -> TlsIn = tls_new ( transport -> settings ) ; if ( transport -> TlsOut == NULL ) transport -> TlsOut = transport -> TlsIn ; transport -> layer = TRANSPORT_LAYER_TLS ; transport -> TlsIn -> sockfd = transport -> TcpIn -> sockfd ; if ( tls_accept ( transport -> TlsIn , transport -> settings -> CertificateFile , transport -> settings -> PrivateKeyFile ) != TRUE ) 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 ) { fprintf ( stderr , ""clientauthenticationfailure\\n"" ) ; credssp_free ( transport -> credssp ) ; return FALSE ; } return TRUE ; } "," credssp ) ; transport -> credssp = NULL ; ",FreeRDP@FreeRDP/0773bb9303d24473fe1185d85a424dfe159aff53,CVE-2013-4119,https://github.com/FreeRDP/FreeRDP/commit/0773bb9303d24473fe1185d85a424dfe159aff53,2016-10-03T21:59Z 1287,CWE-119,"CWE-119 static int t220_frontend_attach ( struct dvb_usb_adapter * d ) { u8 obuf [ 3 ] = { 0xe , 0x87 , 0 } ; u8 ibuf [ ] = { 0 } ; if ( dvb_usb_generic_rw ( d -> dev , obuf , 3 , ibuf , 1 , 0 ) < 0 ) err ( ""command0x0etransferfailed."" ) ; obuf [ 0 ] = 0xe ; obuf [ 1 ] = 0x86 ; obuf [ 2 ] = 1 ; if ( dvb_usb_generic_rw ( d -> dev , obuf , 3 , ibuf , 1 , 0 ) < 0 ) err ( ""command0x0etransferfailed."" ) ; obuf [ 0 ] = 0xe ; obuf [ 1 ] = 0x80 ; obuf [ 2 ] = 0 ; if ( dvb_usb_generic_rw ( d -> dev , obuf , 3 , ibuf , 1 , 0 ) < 0 ) err ( ""command0x0etransferfailed."" ) ; msleep ( 50 ) ; obuf [ 0 ] = 0xe ; obuf [ 1 ] = 0x80 ; 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 ( cxd2820r_attach , & cxd2820r_config , & d -> dev -> i2c_adap , NULL ) ; if ( d -> fe_adap [ 0 ] . fe != NULL ) { if ( dvb_attach ( tda18271_attach , d -> fe_adap [ 0 ] . fe , 0x60 , & d -> dev -> i2c_adap , & tda18271_config ) ) { info ( ""AttachedTDA18271HD/CXD2820R!"" ) ; return 0 ; } } info ( ""FailedtoattachTDA18271HD/CXD2820R!"" ) ; 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 ] = 0x87 ; state -> data [ 2 ] = 0x0 ; if ( dvb_usb_generic_rw ( d , state -> data , 3 , state -> data , 1 , 0 ) < 0 ) err ( ""command0x0etransferfailed."" ) ; state -> data [ 0 ] = 0xe ; state -> data [ 1 ] = 0x86 ; state -> data [ 2 ] = 1 ; if ( dvb_usb_generic_rw ( d , state -> data , 3 , , 3 , state -> data , 1 , ""command0x0etransferfailed."" ) ; state -> data [ 0 ] = 0xe ; state -> data [ 1 ] = 0x80 ; state -> data [ 2 ] 2 ] = 0 ; if ( dvb_usb_generic_rw ( d , state -> data , 3 , , 3 , state -> data , 1 , ""command0x0etransferfailed."" ) ; msleep ( 50 ) ; state -> data [ 0 ] = 0xe ; state -> data [ 1 ] = 0x80 ; 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 , NULL ; if ( adap -> fe_adap [ ( tda18271_attach , adap -> fe_adap [ , & d -> i2c_adap , ",torvalds@linux/606142af57dad981b78707234cfbd15f9f7b7125,CVE-2017-8062,https://github.com/torvalds/linux/commit/606142af57dad981b78707234cfbd15f9f7b7125,2017-04-23T05:59Z 1288,CWE-190,"CWE-190 int ring_buffer_resize ( struct ring_buffer * buffer , unsigned long size , int cpu_id ) { struct ring_buffer_per_cpu * cpu_buffer ; unsigned long nr_pages ; int cpu , err = 0 ; if ( ! buffer ) return size ; if ( cpu_id != RING_BUFFER_ALL_CPUS && ! cpumask_test_cpu ( cpu_id , buffer -> cpumask ) ) return size ; size = DIV_ROUND_UP ( size , BUF_PAGE_SIZE ) ; size *= BUF_PAGE_SIZE ; if ( size < BUF_PAGE_SIZE * 2 ) size = BUF_PAGE_SIZE * 2 ; nr_pages = DIV_ROUND_UP ( size , BUF_PAGE_SIZE ) ; if ( atomic_read ( & buffer -> resize_disabled ) ) return - EBUSY ; mutex_lock ( & buffer -> mutex ) ; if ( cpu_id == RING_BUFFER_ALL_CPUS ) { for_each_buffer_cpu ( buffer , cpu ) { cpu_buffer = buffer -> buffers [ cpu ] ; cpu_buffer -> nr_pages_to_update = nr_pages - cpu_buffer -> nr_pages ; if ( cpu_buffer -> nr_pages_to_update <= 0 ) continue ; INIT_LIST_HEAD ( & cpu_buffer -> new_pages ) ; if ( __rb_allocate_pages ( cpu_buffer -> nr_pages_to_update , & cpu_buffer -> new_pages , cpu ) ) { err = - ENOMEM ; goto out_err ; } } get_online_cpus ( ) ; for_each_buffer_cpu ( buffer , cpu ) { cpu_buffer = buffer -> buffers [ cpu ] ; if ( ! cpu_buffer -> nr_pages_to_update ) continue ; if ( ! cpu_online ( cpu ) ) { rb_update_pages ( cpu_buffer ) ; cpu_buffer -> nr_pages_to_update = 0 ; } else { schedule_work_on ( cpu , & cpu_buffer -> update_pages_work ) ; } } for_each_buffer_cpu ( buffer , cpu ) { cpu_buffer = buffer -> buffers [ cpu ] ; if ( ! cpu_buffer -> nr_pages_to_update ) continue ; if ( cpu_online ( cpu ) ) wait_for_completion ( & cpu_buffer -> update_done ) ; cpu_buffer -> nr_pages_to_update = 0 ; } put_online_cpus ( ) ; } else { if ( ! cpumask_test_cpu ( cpu_id , buffer -> cpumask ) ) goto out ; cpu_buffer = buffer -> buffers [ cpu_id ] ; if ( nr_pages == cpu_buffer -> nr_pages ) goto out ; cpu_buffer -> nr_pages_to_update = nr_pages - cpu_buffer -> nr_pages ; INIT_LIST_HEAD ( & cpu_buffer -> new_pages ) ; if ( cpu_buffer -> nr_pages_to_update > 0 && __rb_allocate_pages ( cpu_buffer -> nr_pages_to_update , & cpu_buffer -> new_pages , cpu_id ) ) { err = - ENOMEM ; goto out_err ; } get_online_cpus ( ) ; if ( ! cpu_online ( cpu_id ) ) rb_update_pages ( cpu_buffer ) ; else { schedule_work_on ( cpu_id , & cpu_buffer -> update_pages_work ) ; wait_for_completion ( & cpu_buffer -> update_done ) ; } cpu_buffer -> nr_pages_to_update = 0 ; put_online_cpus ( ) ; } out : if ( atomic_read ( & buffer -> record_disabled ) ) { atomic_inc ( & buffer -> record_disabled ) ; synchronize_sched ( ) ; for_each_buffer_cpu ( buffer , cpu ) { cpu_buffer = buffer -> buffers [ cpu ] ; rb_check_pages ( cpu_buffer ) ; } atomic_dec ( & buffer -> record_disabled ) ; } mutex_unlock ( & buffer -> mutex ) ; return size ; out_err : for_each_buffer_cpu ( buffer , cpu ) { struct buffer_page * bpage , * tmp ; cpu_buffer = buffer -> buffers [ cpu ] ; cpu_buffer -> nr_pages_to_update = 0 ; if ( list_empty ( & cpu_buffer -> new_pages ) ) continue ; list_for_each_entry_safe ( bpage , tmp , & cpu_buffer -> new_pages , list ) { list_del_init ( & bpage -> list ) ; free_buffer_page ( bpage ) ; } } mutex_unlock ( & buffer -> mutex ) ; return err ; } "," return size ; nr_pages = DIV_ROUND_UP ( size , BUF_PAGE_SIZE ) ; if ( nr_pages < 2 ) nr_pages = 2 ; size = nr_pages * BUF_PAGE_SIZE ; if ( ",torvalds@linux/59643d1535eb220668692a5359de22545af579f6,CVE-2016-9754,https://github.com/torvalds/linux/commit/59643d1535eb220668692a5359de22545af579f6,2017-01-05T11:59Z 1289,CWE-119,"CWE-119 static void horAcc16 ( TIFF * tif , uint8 * cp0 , tmsize_t cc ) { tmsize_t stride = PredictorState ( tif ) -> stride ; uint16 * wp = ( uint16 * ) cp0 ; tmsize_t wc = cc / 2 ; assert ( ( cc % ( 2 * stride ) ) == 0 ) ; if ( wc > stride ) { wc -= stride ; do { REPEAT4 ( stride , wp [ stride ] = ( uint16 ) ( ( ( unsigned int ) wp [ stride ] + ( unsigned int ) wp [ 0 ] ) & 0xffff ) ; wp ++ ) wc -= stride ; } while ( wc > 0 ) ; } } "," static int horAcc16 ( TIFF / 2 ; if ( ( cc stride ) ) != 0 ) { TIFFErrorExt ( tif -> tif_clientdata , ""horAcc16"" , ""%s"" , ""cc%(2*stride))!=0"" ) ; return 0 ; } if ( wc ) ; } return 1 ; ",vadz@libtiff/3ca657a8793dd011bf869695d72ad31c779c3cc1,CVE-2016-9535,https://github.com/vadz/libtiff/commit/3ca657a8793dd011bf869695d72ad31c779c3cc1,2016-11-22T19:59Z 1290,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 1291,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 ) { 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 ; } "," arpt_entry ) >= limit || ( unsigned char * ) e + e -> next_offset > ",torvalds@linux/6e94e0cfb0887e4013b3b930fa6ab1fe6bb6ba91,CVE-2016-4998,https://github.com/torvalds/linux/commit/6e94e0cfb0887e4013b3b930fa6ab1fe6bb6ba91,2016-07-03T21:59Z 1292,CWE-119,"CWE-119 static void lspci_process ( STREAM s ) { unsigned int pkglen ; static char * rest = NULL ; char * buf ; pkglen = s -> end - s -> p ; buf = xmalloc ( pkglen + 1 ) ; STRNCPY ( buf , ( char * ) s -> p , pkglen + 1 ) ; str_handle_lines ( buf , & rest , lspci_process_line , NULL ) ; xfree ( buf ) ; } "," * buf ; struct stream packet = * s ; if ( ! s_check ( s ) ) { rdp_protocol_error ( ""lspci_process(),streamisinunstablestate"" , & packet ) ; } ",rdesktop@rdesktop/4dca546d04321a610c1835010b5dad85163b65e1,CVE-2018-20182,https://github.com/rdesktop/rdesktop/commit/4dca546d04321a610c1835010b5dad85163b65e1,2019-03-15T18:29Z 1293,CWE-119,"CWE-119 DECLAREwriteFunc ( writeBufferToContigTiles ) { uint32 imagew = TIFFScanlineSize ( out ) ; uint32 tilew = TIFFTileRowSize ( out ) ; int iskew = imagew - tilew ; tsize_t tilesize = TIFFTileSize ( out ) ; tdata_t obuf ; uint8 * bufp = ( uint8 * ) buf ; uint32 tl , tw ; uint32 row ; ( void ) spp ; obuf = _TIFFmalloc ( TIFFTileSize ( out ) ) ; if ( obuf == NULL ) return 0 ; _TIFFmemset ( obuf , 0 , tilesize ) ; ( void ) TIFFGetField ( out , TIFFTAG_TILELENGTH , & tl ) ; ( void ) TIFFGetField ( out , TIFFTAG_TILEWIDTH , & tw ) ; for ( row = 0 ; row < imagelength ; row += tilelength ) { uint32 nrow = ( row + tl > imagelength ) ? imagelength - row : tl ; uint32 colb = 0 ; uint32 col ; for ( col = 0 ; col < imagewidth ; col += tw ) { if ( colb + tilew > imagew ) { uint32 width = imagew - colb ; int oskew = tilew - width ; cpStripToTile ( obuf , bufp + colb , nrow , width , oskew , oskew + iskew ) ; } else cpStripToTile ( obuf , bufp + colb , nrow , tilew , 0 , iskew ) ; if ( TIFFWriteTile ( out , obuf , col , row , 0 , 0 ) < 0 ) { TIFFError ( TIFFFileName ( out ) , ""Error,can\'twritetileat%lu%lu"" , ( unsigned long ) col , ( unsigned long ) row ) ; _TIFFfree ( obuf ) ; return 0 ; } colb += tilew ; } bufp += nrow * imagew ; } _TIFFfree ( obuf ) ; return 1 ; } "," col < imagewidth && colb < imagew ",vadz@libtiff/5ad9d8016fbb60109302d558f7edb2cb2a3bb8e3,CVE-2016-9540,https://github.com/vadz/libtiff/commit/5ad9d8016fbb60109302d558f7edb2cb2a3bb8e3,2016-11-22T19:59Z 1294,CWE-119,"CWE-119 static void close_output_file ( struct stream_state * stream , unsigned int fourcc ) { const struct vpx_codec_enc_cfg * const cfg = & stream -> config . cfg ; if ( cfg -> g_pass == VPX_RC_FIRST_PASS ) return ; # if CONFIG_WEBM_IO if ( stream -> config . write_webm ) { write_webm_file_footer ( & stream -> ebml , stream -> hash ) ; free ( stream -> ebml . cue_list ) ; stream -> ebml . cue_list = NULL ; } # endif if ( ! stream -> config . write_webm ) { if ( ! fseek ( stream -> file , 0 , SEEK_SET ) ) ivf_write_file_header ( stream -> file , & stream -> config . cfg , fourcc , stream -> frames_out ) ; } fclose ( stream -> file ) ; } "," stream -> ebml ) ; } # ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1295,CWE-119,"CWE-119 static void encode_uniform ( vp9_writer * w , int v ) { const int l = 8 ; const int m = ( 1 << l ) - 191 ; if ( v < m ) { vp9_write_literal ( w , v , l - 1 ) ; } else { vp9_write_literal ( w , m + ( ( v - m ) >> 1 ) , l - 1 ) ; vp9_write_literal ( w , ( v - m ) & 1 , 1 ) ; } } "," void encode_uniform ( vpx_writer * w , m ) { vpx_write_literal ( w , } else { vpx_write_literal ( w , 1 ) ; vpx_write_literal ( w , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1296,CWE-269,"CWE-269 uint32_t virtio_config_readw ( VirtIODevice * vdev , uint32_t addr ) { VirtioDeviceClass * k = VIRTIO_DEVICE_GET_CLASS ( vdev ) ; uint16_t val ; k -> get_config ( vdev , vdev -> config ) ; if ( addr > ( vdev -> config_len - sizeof ( val ) ) ) return ( uint32_t ) - 1 ; val = lduw_p ( vdev -> config + addr ) ; return val ; } "," uint16_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 1297,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 1298,CWE-59,"CWE-59 static int setup_ttydir_console ( const struct lxc_rootfs * rootfs , const struct lxc_console * console , char * ttydir ) { char path [ MAXPATHLEN ] , lxcpath [ MAXPATHLEN ] ; int ret ; ret = snprintf ( path , sizeof ( path ) , ""%s/dev/%s"" , rootfs -> mount , ttydir ) ; if ( ret >= sizeof ( path ) ) return - 1 ; ret = mkdir ( path , 0755 ) ; if ( ret && errno != EEXIST ) { SYSERROR ( ""failedwitherrno%dtocreate%s"" , errno , path ) ; return - 1 ; } INFO ( ""created%s"" , path ) ; ret = snprintf ( lxcpath , sizeof ( lxcpath ) , ""%s/dev/%s/console"" , rootfs -> mount , ttydir ) ; if ( ret >= sizeof ( lxcpath ) ) { ERROR ( ""consolepathtoolong"" ) ; return - 1 ; } snprintf ( path , sizeof ( path ) , ""%s/dev/console"" , rootfs -> mount ) ; ret = unlink ( path ) ; if ( ret && errno != ENOENT ) { SYSERROR ( ""errorunlinking%s"" , path ) ; return - 1 ; } ret = creat ( lxcpath , 0660 ) ; if ( ret == - 1 && errno != EEXIST ) { SYSERROR ( ""error%dcreating%s"" , errno , lxcpath ) ; return - 1 ; } if ( ret >= 0 ) close ( ret ) ; if ( console -> master < 0 ) { INFO ( ""noconsole"" ) ; return 0 ; } if ( mount ( console -> name , lxcpath , ""none"" , MS_BIND , 0 ) ) { ERROR ( ""failedtomount\'%s\'on\'%s\'"" , console -> name , lxcpath ) ; return - 1 ; } ret = snprintf ( lxcpath , sizeof ( lxcpath ) , ""%s/console"" , ttydir ) ; if ( ret >= sizeof ( lxcpath ) ) { ERROR ( ""lxc/consolepathtoolong"" ) ; return - 1 ; } ret = symlink ( lxcpath , path ) ; if ( ret ) { SYSERROR ( ""failedtocreatesymlinkforconsole"" ) ; return - 1 ; } INFO ( ""consolehasbeensetupon%s"" , lxcpath ) ; return 0 ; } "," } if ( safe_mount ( console -> name , lxcpath , ""none"" , MS_BIND , 0 , rootfs -> mount ) ) { ERROR ( ""failedtomount\'%s\'on\'%s\'"" , console -> name name , lxcpath ) ; return - 1 ; } ret = snprintf ( lxcpath , sizeof ( lxcpath ) , ""%s/console"" , ttydir ) ; if ( ret >= sizeof ( lxcpath ) ) { ERROR ( ""lxc/consolepathtoolong"" ) ; return - 1 ; } ret = symlink ( lxcpath , path ) ; if ( ret ) { SYSERROR ( ""failedtocreatesymlinkforconsole"" ) ; return - 1 ; } INFO ( ""consolehasbeensetupon%s"" , lxcpath ) ; return 0 ; } ",lxc@lxc/592fd47a6245508b79fe6ac819fe6d3b2c1289be,CVE-2015-1335,https://github.com/lxc/lxc/commit/592fd47a6245508b79fe6ac819fe6d3b2c1289be,2015-10-01T20:59Z 1299,CWE-787,"CWE-787 static void nsc_decode ( NSC_CONTEXT * context ) { UINT16 x ; UINT16 y ; UINT16 rw = ROUND_UP_TO ( context -> width , 8 ) ; BYTE shift = context -> ColorLossLevel - 1 ; BYTE * bmpdata = context -> BitmapData ; for ( y = 0 ; y < context -> height ; y ++ ) { const BYTE * yplane ; const BYTE * coplane ; const BYTE * cgplane ; const BYTE * aplane = context -> priv -> PlaneBuffers [ 3 ] + y * context -> width ; if ( context -> ChromaSubsamplingLevel ) { yplane = context -> priv -> PlaneBuffers [ 0 ] + y * rw ; coplane = context -> priv -> PlaneBuffers [ 1 ] + ( y >> 1 ) * ( rw >> 1 ) ; cgplane = context -> priv -> PlaneBuffers [ 2 ] + ( y >> 1 ) * ( rw >> 1 ) ; } else { yplane = context -> priv -> PlaneBuffers [ 0 ] + y * context -> width ; coplane = context -> priv -> PlaneBuffers [ 1 ] + y * context -> width ; cgplane = context -> priv -> PlaneBuffers [ 2 ] + y * context -> width ; } for ( x = 0 ; x < context -> width ; x ++ ) { INT16 y_val = ( INT16 ) * yplane ; INT16 co_val = ( INT16 ) ( INT8 ) ( * coplane << shift ) ; INT16 cg_val = ( INT16 ) ( INT8 ) ( * cgplane << shift ) ; INT16 r_val = y_val + co_val - cg_val ; INT16 g_val = y_val + cg_val ; INT16 b_val = y_val - co_val - cg_val ; * bmpdata ++ = MINMAX ( b_val , 0 , 0xFF ) ; * bmpdata ++ = MINMAX ( g_val , 0 , 0xFF ) ; * bmpdata ++ = MINMAX ( r_val , 0 , 0xFF ) ; * bmpdata ++ = * aplane ; yplane ++ ; coplane += ( context -> ChromaSubsamplingLevel ? x % 2 : 1 ) ; cgplane += ( context -> ChromaSubsamplingLevel ? x % 2 : 1 ) ; aplane ++ ; } } } "," static BOOL nsc_decode ( NSC_CONTEXT ; UINT16 rw ; BYTE shift ; BYTE * bmpdata ; size_t pos = 0 ; if ( ! context ) return FALSE ; rw 8 ) ; shift = context - 1 ; bmpdata = context context -> BitmapData ; if ( ! bmpdata ) return FALSE - cg_val ; if ( pos + 4 > context -> BitmapDataLength ) return FALSE ; pos += 4 ; ; } } return TRUE ; ",FreeRDP@FreeRDP/d1112c279bd1a327e8e4d0b5f371458bf2579659,CVE-2018-8788,https://github.com/FreeRDP/FreeRDP/commit/d1112c279bd1a327e8e4d0b5f371458bf2579659,2018-11-29T18:29Z 1300,CWE-763,"CWE-763 static void atomic2gen ( lua_State * L , global_State * g ) { sweep2old ( L , & g -> allgc ) ; g -> reallyold = g -> old = g -> survival = g -> allgc ; sweep2old ( L , & g -> finobj ) ; g -> finobjrold = g -> finobjold = g -> finobjsur = g -> finobj ; sweep2old ( L , & g -> tobefnz ) ; g -> gckind = KGC_GEN ; g -> lastatomic = 0 ; g -> GCestimate = gettotalbytes ( g ) ; finishgencycle ( L , g ) ; } "," g ) { g -> gcstate = GCSswpallgc ; ",lua@lua/a6da1472c0c5e05ff249325f979531ad51533110,CVE-2020-24371,https://github.com/lua/lua/commit/a6da1472c0c5e05ff249325f979531ad51533110,2020-08-17T17:15Z 1301,CWE-119,"CWE-119 int vp8dx_start_decode ( BOOL_DECODER * br , const unsigned char * source , unsigned int source_sz , vp8_decrypt_cb * decrypt_cb , void * decrypt_state ) { br -> user_buffer_end = source + source_sz ; br -> user_buffer = source ; br -> value = 0 ; br -> count = - 8 ; br -> range = 255 ; br -> decrypt_cb = decrypt_cb ; br -> decrypt_state = decrypt_state ; if ( source_sz && ! source ) return 1 ; vp8dx_bool_decoder_fill ( br ) ; return 0 ; } "," int source_sz , vpx_decrypt_cb decrypt_cb , void ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1302,CWE-476,"CWE-476 static OM_uint32 acc_ctx_cont ( OM_uint32 * minstat , gss_buffer_t buf , gss_ctx_id_t * ctx , gss_buffer_t * responseToken , gss_buffer_t * mechListMIC , OM_uint32 * negState , send_token_flag * return_token ) { OM_uint32 ret , tmpmin ; gss_OID supportedMech ; spnego_gss_ctx_id_t sc ; unsigned int len ; unsigned char * ptr , * bufstart ; sc = ( spnego_gss_ctx_id_t ) * ctx ; ret = GSS_S_DEFECTIVE_TOKEN ; * negState = REJECT ; * minstat = 0 ; supportedMech = GSS_C_NO_OID ; * return_token = ERROR_TOKEN_SEND ; * responseToken = * mechListMIC = GSS_C_NO_BUFFER ; ptr = bufstart = buf -> value ; # define REMAIN ( buf -> length - ( ptr - bufstart ) ) if ( REMAIN > INT_MAX ) return GSS_S_DEFECTIVE_TOKEN ; if ( * ptr == HEADER_ID ) { ret = g_verify_token_header ( gss_mech_spnego , & len , & ptr , 0 , REMAIN ) ; if ( ret ) { * minstat = ret ; return GSS_S_DEFECTIVE_TOKEN ; } } if ( * ptr != ( CONTEXT | 0x01 ) ) { return GSS_S_DEFECTIVE_TOKEN ; } ret = get_negTokenResp ( minstat , ptr , REMAIN , negState , & supportedMech , responseToken , mechListMIC ) ; if ( ret != GSS_S_COMPLETE ) goto cleanup ; if ( * responseToken == GSS_C_NO_BUFFER && * mechListMIC == GSS_C_NO_BUFFER ) { ret = GSS_S_DEFECTIVE_TOKEN ; goto cleanup ; } if ( supportedMech != GSS_C_NO_OID ) { ret = GSS_S_DEFECTIVE_TOKEN ; goto cleanup ; } sc -> firstpass = 0 ; * negState = ACCEPT_INCOMPLETE ; * return_token = CONT_TOKEN_SEND ; cleanup : if ( supportedMech != GSS_C_NO_OID ) { generic_gss_release_oid ( & tmpmin , & supportedMech ) ; } return ret ; # undef REMAIN } "," if ( REMAIN == 0 || REMAIN ",krb5@krb5/524688ce87a15fc75f87efc8c039ba4c7d5c197b,CVE-2014-4344,https://github.com/krb5/krb5/commit/524688ce87a15fc75f87efc8c039ba4c7d5c197b,2014-08-14T05:01Z 1303,CWE-119,"CWE-119 static int check_alu_op ( struct bpf_verifier_env * env , struct bpf_insn * insn ) { struct bpf_reg_state * regs = cur_regs ( env ) ; u8 opcode = BPF_OP ( insn -> code ) ; int err ; if ( opcode == BPF_END || opcode == BPF_NEG ) { if ( opcode == BPF_NEG ) { if ( BPF_SRC ( insn -> code ) != 0 || insn -> src_reg != BPF_REG_0 || insn -> off != 0 || insn -> imm != 0 ) { verbose ( env , ""BPF_NEGusesreservedfields\\n"" ) ; return - EINVAL ; } } else { if ( insn -> src_reg != BPF_REG_0 || insn -> off != 0 || ( insn -> imm != 16 && insn -> imm != 32 && insn -> imm != 64 ) || BPF_CLASS ( insn -> code ) == BPF_ALU64 ) { verbose ( env , ""BPF_ENDusesreservedfields\\n"" ) ; return - EINVAL ; } } err = check_reg_arg ( env , insn -> dst_reg , SRC_OP ) ; if ( err ) return err ; if ( is_pointer_value ( env , insn -> dst_reg ) ) { verbose ( env , ""R%dpointerarithmeticprohibited\\n"" , insn -> dst_reg ) ; return - EACCES ; } err = check_reg_arg ( env , insn -> dst_reg , DST_OP ) ; if ( err ) return err ; } else if ( opcode == BPF_MOV ) { if ( BPF_SRC ( insn -> code ) == BPF_X ) { if ( insn -> imm != 0 || insn -> off != 0 ) { verbose ( env , ""BPF_MOVusesreservedfields\\n"" ) ; return - EINVAL ; } err = check_reg_arg ( env , insn -> src_reg , SRC_OP ) ; if ( err ) return err ; } else { if ( insn -> src_reg != BPF_REG_0 || insn -> off != 0 ) { verbose ( env , ""BPF_MOVusesreservedfields\\n"" ) ; return - EINVAL ; } } err = check_reg_arg ( env , insn -> dst_reg , DST_OP ) ; if ( err ) return err ; if ( BPF_SRC ( insn -> code ) == BPF_X ) { if ( BPF_CLASS ( insn -> code ) == BPF_ALU64 ) { regs [ insn -> dst_reg ] = regs [ insn -> src_reg ] ; regs [ insn -> dst_reg ] . live |= REG_LIVE_WRITTEN ; } else { if ( is_pointer_value ( env , insn -> src_reg ) ) { verbose ( env , ""R%dpartialcopyofpointer\\n"" , insn -> src_reg ) ; return - EACCES ; } mark_reg_unknown ( env , regs , insn -> dst_reg ) ; regs [ insn -> dst_reg ] . var_off = tnum_cast ( regs [ insn -> dst_reg ] . var_off , 4 ) ; __update_reg_bounds ( & regs [ insn -> dst_reg ] ) ; } } else { regs [ insn -> dst_reg ] . type = SCALAR_VALUE ; if ( BPF_CLASS ( insn -> code ) == BPF_ALU64 ) { __mark_reg_known ( regs + insn -> dst_reg , insn -> imm ) ; } else { __mark_reg_known ( regs + insn -> dst_reg , ( u32 ) insn -> imm ) ; } } } else if ( opcode > BPF_END ) { verbose ( env , ""invalidBPF_ALUopcode%x\\n"" , opcode ) ; return - EINVAL ; } else { if ( BPF_SRC ( insn -> code ) == BPF_X ) { if ( insn -> imm != 0 || insn -> off != 0 ) { verbose ( env , ""BPF_ALUusesreservedfields\\n"" ) ; return - EINVAL ; } err = check_reg_arg ( env , insn -> src_reg , SRC_OP ) ; if ( err ) return err ; } else { if ( insn -> src_reg != BPF_REG_0 || insn -> off != 0 ) { verbose ( env , ""BPF_ALUusesreservedfields\\n"" ) ; return - EINVAL ; } } err = check_reg_arg ( env , insn -> dst_reg , SRC_OP ) ; if ( err ) return err ; if ( ( opcode == BPF_MOD || opcode == BPF_DIV ) && BPF_SRC ( insn -> code ) == BPF_K && insn -> imm == 0 ) { verbose ( env , ""divbyzero\\n"" ) ; return - EINVAL ; } if ( ( opcode == BPF_LSH || opcode == BPF_RSH || opcode == BPF_ARSH ) && BPF_SRC ( insn -> code ) == BPF_K ) { int size = BPF_CLASS ( insn -> code ) == BPF_ALU64 ? 64 : 32 ; if ( insn -> imm < 0 || insn -> imm >= size ) { verbose ( env , ""invalidshift%d\\n"" , insn -> imm ) ; return - EINVAL ; } } err = check_reg_arg ( env , insn -> dst_reg , DST_OP_NO_MARK ) ; if ( err ) return err ; return adjust_reg_min_max_vals ( env , insn ) ; } return 0 ; } "," dst_reg ) ; coerce_reg_to_size ( & regs -> dst_reg ] , 4 ",torvalds@linux/0c17d1d2c61936401f4702e1846e2c19b200f958,CVE-2017-16996,https://github.com/torvalds/linux/commit/0c17d1d2c61936401f4702e1846e2c19b200f958,2017-12-27T17:08Z 1304,CWE-000,"CWE-000 WORD32 ih264d_end_of_pic ( dec_struct_t * ps_dec , UWORD8 u1_is_idr_slice , UWORD16 u2_frame_num ) { dec_slice_params_t * ps_cur_slice = ps_dec -> ps_cur_slice ; WORD32 ret ; ps_dec -> u2_mbx = 0xffff ; ps_dec -> u2_mby = 0 ; { dec_err_status_t * ps_err = ps_dec -> ps_dec_err_status ; if ( ps_err -> u1_err_flag & REJECT_CUR_PIC ) { ih264d_err_pic_dispbuf_mgr ( ps_dec ) ; return ERROR_NEW_FRAME_EXPECTED ; } } H264_MUTEX_LOCK ( & ps_dec -> process_disp_mutex ) ; ret = ih264d_end_of_pic_processing ( ps_dec ) ; if ( ret != OK ) return ret ; ps_dec -> u2_total_mbs_coded = 0 ; { pocstruct_t * ps_prev_poc = & ps_dec -> s_prev_pic_poc ; pocstruct_t * ps_cur_poc = & ps_dec -> s_cur_pic_poc ; if ( ( 0 == u1_is_idr_slice ) && ps_cur_slice -> u1_nal_ref_idc ) ps_dec -> u2_prev_ref_frame_num = ps_cur_slice -> u2_frame_num ; if ( u1_is_idr_slice || ps_cur_slice -> u1_mmco_equalto5 ) ps_dec -> u2_prev_ref_frame_num = 0 ; if ( ps_dec -> ps_cur_sps -> u1_gaps_in_frame_num_value_allowed_flag ) { ret = ih264d_decode_gaps_in_frame_num ( ps_dec , u2_frame_num ) ; if ( ret != OK ) return ret ; } ps_prev_poc -> i4_prev_frame_num_ofst = ps_cur_poc -> i4_prev_frame_num_ofst ; ps_prev_poc -> u2_frame_num = ps_cur_poc -> u2_frame_num ; ps_prev_poc -> u1_mmco_equalto5 = ps_cur_slice -> u1_mmco_equalto5 ; if ( ps_cur_slice -> u1_nal_ref_idc ) { 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_cur_poc -> u1_bot_field ; } } H264_MUTEX_UNLOCK ( & ps_dec -> process_disp_mutex ) ; return OK ; } "," dec_struct_t * ps_dec ) { dec_slice_params_t ; WORD32 ret ; { dec_err_status_t return ret ; H264_MUTEX_UNLOCK ( & ",external@libavc/494561291a503840f385fbcd11d9bc5f4dc502b8,CVE-2017-0551,https://android.googlesource.com/platform/external/libavc/+/494561291a503840f385fbcd11d9bc5f4dc502b8,2017-04-07T22:59Z 1305,CWE-674,"CWE-674 static void renameColumnFunc ( sqlite3_context * context , int NotUsed , sqlite3_value * * argv ) { sqlite3 * db = sqlite3_context_db_handle ( context ) ; RenameCtx sCtx ; const char * zSql = ( const char * ) sqlite3_value_text ( argv [ 0 ] ) ; const char * zDb = ( const char * ) sqlite3_value_text ( argv [ 3 ] ) ; const char * zTable = ( const char * ) sqlite3_value_text ( argv [ 4 ] ) ; int iCol = sqlite3_value_int ( argv [ 5 ] ) ; const char * zNew = ( const char * ) sqlite3_value_text ( argv [ 6 ] ) ; int bQuote = sqlite3_value_int ( argv [ 7 ] ) ; int bTemp = sqlite3_value_int ( argv [ 8 ] ) ; const char * zOld ; int rc ; Parse sParse ; Walker sWalker ; Index * pIdx ; int i ; Table * pTab ; # ifndef SQLITE_OMIT_AUTHORIZATION sqlite3_xauth xAuth = db -> xAuth ; # endif UNUSED_PARAMETER ( NotUsed ) ; if ( zSql == 0 ) return ; if ( zTable == 0 ) return ; if ( zNew == 0 ) return ; if ( iCol < 0 ) return ; sqlite3BtreeEnterAll ( db ) ; pTab = sqlite3FindTable ( db , zTable , zDb ) ; if ( pTab == 0 || iCol >= pTab -> nCol ) { sqlite3BtreeLeaveAll ( db ) ; return ; } zOld = pTab -> aCol [ iCol ] . zName ; memset ( & sCtx , 0 , sizeof ( sCtx ) ) ; sCtx . iCol = ( ( iCol == pTab -> iPKey ) ? - 1 : iCol ) ; # ifndef SQLITE_OMIT_AUTHORIZATION db -> xAuth = 0 ; # endif rc = renameParseSql ( & sParse , zDb , 0 , db , zSql , bTemp ) ; memset ( & sWalker , 0 , sizeof ( Walker ) ) ; sWalker . pParse = & sParse ; sWalker . xExprCallback = renameColumnExprCb ; sWalker . xSelectCallback = renameColumnSelectCb ; sWalker . u . pRename = & sCtx ; sCtx . pTab = pTab ; if ( rc != SQLITE_OK ) goto renameColumnFunc_done ; if ( sParse . pNewTable ) { Select * pSelect = sParse . pNewTable -> pSelect ; if ( pSelect ) { sParse . rc = SQLITE_OK ; sqlite3SelectPrep ( & sParse , sParse . pNewTable -> pSelect , 0 ) ; rc = ( db -> mallocFailed ? SQLITE_NOMEM : sParse . rc ) ; if ( rc == SQLITE_OK ) { sqlite3WalkSelect ( & sWalker , pSelect ) ; } if ( rc != SQLITE_OK ) goto renameColumnFunc_done ; } else { int bFKOnly = sqlite3_stricmp ( zTable , sParse . pNewTable -> zName ) ; FKey * pFKey ; assert ( sParse . pNewTable -> pSelect == 0 ) ; sCtx . pTab = sParse . pNewTable ; if ( bFKOnly == 0 ) { renameTokenFind ( & sParse , & sCtx , ( void * ) sParse . pNewTable -> aCol [ iCol ] . zName ) ; if ( sCtx . iCol < 0 ) { renameTokenFind ( & sParse , & sCtx , ( void * ) & sParse . pNewTable -> iPKey ) ; } sqlite3WalkExprList ( & sWalker , sParse . pNewTable -> pCheck ) ; for ( pIdx = sParse . pNewTable -> pIndex ; pIdx ; pIdx = pIdx -> pNext ) { sqlite3WalkExprList ( & sWalker , pIdx -> aColExpr ) ; } for ( pIdx = sParse . pNewIndex ; pIdx ; pIdx = pIdx -> pNext ) { sqlite3WalkExprList ( & sWalker , pIdx -> aColExpr ) ; } } # ifndef SQLITE_OMIT_GENERATED_COLUMNS for ( i = 0 ; i < sParse . pNewTable -> nCol ; i ++ ) { sqlite3WalkExpr ( & sWalker , sParse . pNewTable -> aCol [ i ] . pDflt ) ; } # endif for ( pFKey = sParse . pNewTable -> pFKey ; pFKey ; pFKey = pFKey -> pNextFrom ) { for ( i = 0 ; i < pFKey -> nCol ; i ++ ) { if ( bFKOnly == 0 && pFKey -> aCol [ i ] . iFrom == iCol ) { renameTokenFind ( & sParse , & sCtx , ( void * ) & pFKey -> aCol [ i ] ) ; } if ( 0 == sqlite3_stricmp ( pFKey -> zTo , zTable ) && 0 == sqlite3_stricmp ( pFKey -> aCol [ i ] . zCol , zOld ) ) { renameTokenFind ( & sParse , & sCtx , ( void * ) pFKey -> aCol [ i ] . zCol ) ; } } } } } else if ( sParse . pNewIndex ) { sqlite3WalkExprList ( & sWalker , sParse . pNewIndex -> aColExpr ) ; sqlite3WalkExpr ( & sWalker , sParse . pNewIndex -> pPartIdxWhere ) ; } else { TriggerStep * pStep ; rc = renameResolveTrigger ( & sParse , ( bTemp ? 0 : zDb ) ) ; if ( rc != SQLITE_OK ) goto renameColumnFunc_done ; for ( pStep = sParse . pNewTrigger -> step_list ; pStep ; pStep = pStep -> pNext ) { if ( pStep -> zTarget ) { Table * pTarget = sqlite3LocateTable ( & sParse , 0 , pStep -> zTarget , zDb ) ; if ( pTarget == pTab ) { if ( pStep -> pUpsert ) { ExprList * pUpsertSet = pStep -> pUpsert -> pUpsertSet ; renameColumnElistNames ( & sParse , & sCtx , pUpsertSet , zOld ) ; } renameColumnIdlistNames ( & sParse , & sCtx , pStep -> pIdList , zOld ) ; renameColumnElistNames ( & sParse , & sCtx , pStep -> pExprList , zOld ) ; } } } if ( sParse . pTriggerTab == pTab ) { renameColumnIdlistNames ( & sParse , & sCtx , sParse . pNewTrigger -> pColumns , zOld ) ; } renameWalkTrigger ( & sWalker , sParse . pNewTrigger ) ; } assert ( rc == SQLITE_OK ) ; rc = renameEditSql ( context , & sCtx , zSql , zNew , bQuote ) ; renameColumnFunc_done : if ( rc != SQLITE_OK ) { if ( sParse . zErrMsg ) { renameColumnParseError ( context , 0 , argv [ 1 ] , argv [ 2 ] , & sParse ) ; } else { sqlite3_result_error_code ( context , rc ) ; } } renameParseCleanup ( & sParse ) ; renameTokenFree ( db , sCtx . pList ) ; # ifndef SQLITE_OMIT_AUTHORIZATION db -> xAuth = xAuth ; # endif sqlite3BtreeLeaveAll ( db ) ; } "," pSelect ) { pSelect -> selFlags &= ~ SF_View ; & sParse , pSelect , 0 ",sqlite@sqlite/38096961c7cd109110ac21d3ed7dad7e0cb0ae06,CVE-2019-19645,https://github.com/sqlite/sqlite/commit/38096961c7cd109110ac21d3ed7dad7e0cb0ae06,2019-12-09T16:15Z 1306,CWE-552,"CWE-552 static ssize_t _consolefs_write ( oe_fd_t * file_ , const void * buf , size_t count ) { ssize_t ret = - 1 ; file_t * file = _cast_file ( file_ ) ; if ( ! file ) OE_RAISE_ERRNO ( OE_EINVAL ) ; if ( oe_syscall_write_ocall ( & ret , file -> host_fd , buf , count ) != OE_OK ) OE_RAISE_ERRNO ( OE_EINVAL ) ; done : return ret ; } "," ( ! file || 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 1307,CWE-189,"CWE-189 static int i915_gem_do_execbuffer ( struct drm_device * dev , void * data , struct drm_file * file , struct drm_i915_gem_execbuffer2 * args , struct drm_i915_gem_exec_object2 * exec ) { drm_i915_private_t * dev_priv = dev -> dev_private ; struct list_head objects ; struct eb_objects * eb ; struct drm_i915_gem_object * batch_obj ; struct drm_clip_rect * cliprects = NULL ; struct intel_ring_buffer * ring ; u32 exec_start , exec_len ; u32 seqno ; u32 mask ; int ret , mode , i ; if ( ! i915_gem_check_execbuffer ( args ) ) { DRM_DEBUG ( ""execbufwithinvalidoffset/length\\n"" ) ; return - EINVAL ; } ret = validate_exec_list ( exec , args -> buffer_count ) ; if ( ret ) return ret ; switch ( args -> flags & I915_EXEC_RING_MASK ) { case I915_EXEC_DEFAULT : case I915_EXEC_RENDER : ring = & dev_priv -> ring [ RCS ] ; break ; case I915_EXEC_BSD : if ( ! HAS_BSD ( dev ) ) { DRM_DEBUG ( ""execbufwithinvalidring(BSD)\\n"" ) ; return - EINVAL ; } ring = & dev_priv -> ring [ VCS ] ; break ; case I915_EXEC_BLT : if ( ! HAS_BLT ( dev ) ) { DRM_DEBUG ( ""execbufwithinvalidring(BLT)\\n"" ) ; return - EINVAL ; } ring = & dev_priv -> ring [ BCS ] ; break ; default : DRM_DEBUG ( ""execbufwithunknownring:%d\\n"" , ( int ) ( args -> flags & I915_EXEC_RING_MASK ) ) ; return - EINVAL ; } mode = args -> flags & I915_EXEC_CONSTANTS_MASK ; mask = I915_EXEC_CONSTANTS_MASK ; switch ( mode ) { case I915_EXEC_CONSTANTS_REL_GENERAL : case I915_EXEC_CONSTANTS_ABSOLUTE : case I915_EXEC_CONSTANTS_REL_SURFACE : if ( ring == & dev_priv -> ring [ RCS ] && mode != dev_priv -> relative_constants_mode ) { if ( INTEL_INFO ( dev ) -> gen < 4 ) return - EINVAL ; if ( INTEL_INFO ( dev ) -> gen > 5 && mode == I915_EXEC_CONSTANTS_REL_SURFACE ) return - EINVAL ; if ( INTEL_INFO ( dev ) -> gen >= 6 ) mask &= ~ I915_EXEC_CONSTANTS_REL_SURFACE ; } break ; default : DRM_DEBUG ( ""execbufwithunknownconstants:%d\\n"" , mode ) ; return - EINVAL ; } if ( args -> buffer_count < 1 ) { DRM_DEBUG ( ""execbufwith%dbuffers\\n"" , args -> buffer_count ) ; return - EINVAL ; } if ( args -> num_cliprects != 0 ) { if ( ring != & dev_priv -> ring [ RCS ] ) { DRM_DEBUG ( ""cliprectanglesareonlyvalidwiththerenderring\\n"" ) ; return - EINVAL ; } cliprects = kmalloc ( args -> num_cliprects * sizeof ( * cliprects ) , GFP_KERNEL ) ; if ( cliprects == NULL ) { ret = - ENOMEM ; goto pre_mutex_err ; } if ( copy_from_user ( cliprects , ( struct drm_clip_rect __user * ) ( uintptr_t ) args -> cliprects_ptr , sizeof ( * cliprects ) * args -> num_cliprects ) ) { ret = - EFAULT ; goto pre_mutex_err ; } } ret = i915_mutex_lock_interruptible ( dev ) ; if ( ret ) goto pre_mutex_err ; if ( dev_priv -> mm . suspended ) { mutex_unlock ( & dev -> struct_mutex ) ; ret = - EBUSY ; goto pre_mutex_err ; } eb = eb_create ( args -> buffer_count ) ; if ( eb == NULL ) { mutex_unlock ( & dev -> struct_mutex ) ; ret = - ENOMEM ; goto pre_mutex_err ; } INIT_LIST_HEAD ( & objects ) ; for ( i = 0 ; i < args -> buffer_count ; i ++ ) { struct drm_i915_gem_object * obj ; obj = to_intel_bo ( drm_gem_object_lookup ( dev , file , exec [ i ] . handle ) ) ; if ( & obj -> base == NULL ) { DRM_DEBUG ( ""Invalidobjecthandle%datindex%d\\n"" , exec [ i ] . handle , i ) ; ret = - ENOENT ; goto err ; } if ( ! list_empty ( & obj -> exec_list ) ) { DRM_DEBUG ( ""Object%p[handle%d,index%d]appearsmorethanonceinobjectlist\\n"" , obj , exec [ i ] . handle , i ) ; ret = - EINVAL ; goto err ; } list_add_tail ( & obj -> exec_list , & objects ) ; obj -> exec_handle = exec [ i ] . handle ; obj -> exec_entry = & exec [ i ] ; eb_add_object ( eb , obj ) ; } batch_obj = list_entry ( objects . prev , struct drm_i915_gem_object , exec_list ) ; ret = i915_gem_execbuffer_reserve ( ring , file , & objects ) ; if ( ret ) goto err ; ret = i915_gem_execbuffer_relocate ( dev , eb , & objects ) ; if ( ret ) { if ( ret == - EFAULT ) { ret = i915_gem_execbuffer_relocate_slow ( dev , file , ring , & objects , eb , exec , args -> buffer_count ) ; BUG_ON ( ! mutex_is_locked ( & dev -> struct_mutex ) ) ; } if ( ret ) goto err ; } if ( batch_obj -> base . pending_write_domain ) { DRM_DEBUG ( ""Attemptingtouseself-modifyingbatchbuffer\\n"" ) ; ret = - EINVAL ; goto err ; } batch_obj -> base . pending_read_domains |= I915_GEM_DOMAIN_COMMAND ; ret = i915_gem_execbuffer_move_to_gpu ( ring , & objects ) ; if ( ret ) goto err ; seqno = i915_gem_next_request_seqno ( ring ) ; for ( i = 0 ; i < ARRAY_SIZE ( ring -> sync_seqno ) ; i ++ ) { if ( seqno < ring -> sync_seqno [ i ] ) { ret = i915_gpu_idle ( dev , true ) ; if ( ret ) goto err ; BUG_ON ( ring -> sync_seqno [ i ] ) ; } } if ( ring == & dev_priv -> ring [ RCS ] && mode != dev_priv -> relative_constants_mode ) { ret = intel_ring_begin ( ring , 4 ) ; if ( ret ) goto err ; intel_ring_emit ( ring , MI_NOOP ) ; intel_ring_emit ( ring , MI_LOAD_REGISTER_IMM ( 1 ) ) ; intel_ring_emit ( ring , INSTPM ) ; intel_ring_emit ( ring , mask << 16 | mode ) ; intel_ring_advance ( ring ) ; dev_priv -> relative_constants_mode = mode ; } if ( args -> flags & I915_EXEC_GEN7_SOL_RESET ) { ret = i915_reset_gen7_sol_offsets ( dev , ring ) ; if ( ret ) goto err ; } trace_i915_gem_ring_dispatch ( ring , seqno ) ; exec_start = batch_obj -> gtt_offset + args -> batch_start_offset ; exec_len = args -> batch_len ; if ( cliprects ) { for ( i = 0 ; i < args -> num_cliprects ; i ++ ) { ret = i915_emit_box ( dev , & cliprects [ i ] , args -> DR1 , args -> DR4 ) ; if ( ret ) goto err ; ret = ring -> dispatch_execbuffer ( ring , exec_start , exec_len ) ; if ( ret ) goto err ; } } else { ret = ring -> dispatch_execbuffer ( ring , exec_start , exec_len ) ; if ( ret ) goto err ; } i915_gem_execbuffer_move_to_active ( & objects , ring , seqno ) ; i915_gem_execbuffer_retire_commands ( dev , file , ring ) ; err : eb_destroy ( eb ) ; while ( ! list_empty ( & objects ) ) { struct drm_i915_gem_object * obj ; obj = list_first_entry ( & objects , struct drm_i915_gem_object , exec_list ) ; list_del_init ( & obj -> exec_list ) ; drm_gem_object_unreference ( & obj -> base ) ; } mutex_unlock ( & dev -> struct_mutex ) ; pre_mutex_err : kfree ( cliprects ) ; return ret ; } "," DRM_DEBUG ( ""cliprectanglesareonlyvalidwiththerenderring\\n"" ) ; return - EINVAL ; } if ( args -> num_cliprects > UINT_MAX / sizeof ( * cliprects ) ) { DRM_DEBUG ( ""execbufwith%ucliprects\\n"" , args -> num_cliprects ",torvalds@linux/44afb3a04391a74309d16180d1e4f8386fdfa745,CVE-2012-2384,https://github.com/torvalds/linux/commit/44afb3a04391a74309d16180d1e4f8386fdfa745,2012-06-13T10:24Z 1308,CWE-362,"CWE-362 static inline int ldsem_cmpxchg ( long * old , long new , struct ld_semaphore * sem ) { long tmp = * old ; * old = atomic_long_cmpxchg ( & sem -> count , * old , new ) ; return * old == tmp ; } "," long tmp = atomic_long_cmpxchg ( & new ) ; if ( tmp == * old ) { * old = new ; return 1 ; } else { * old = tmp ; return 0 ; } } ",torvalds@linux/cf872776fc84128bb779ce2b83a37c884c3203ae,CVE-2015-4170,https://github.com/torvalds/linux/commit/cf872776fc84128bb779ce2b83a37c884c3203ae,2016-05-02T10:59Z 1309,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 1310,CWE-787,"CWE-787 static void numtostr ( js_State * J , const char * fmt , int w , double n ) { char buf [ 32 ] , * e ; sprintf ( buf , fmt , w , n ) ; e = strchr ( buf , 'e' ) ; if ( e ) { int exp = atoi ( e + 1 ) ; sprintf ( e , ""e%+d"" , exp ) ; } js_pushstring ( J , buf ) ; } "," char buf [ 50 ] , * ",ccxvii@mujs/da632ca08f240590d2dec786722ed08486ce1be6,CVE-2019-11411,https://github.com/ccxvii/mujs/commit/da632ca08f240590d2dec786722ed08486ce1be6,2019-04-22T11:29Z 1311,CWE-119,"CWE-119 static __u8 * nci_extract_rf_params_nfcf_passive_poll ( struct nci_dev * ndev , struct rf_tech_specific_params_nfcf_poll * nfcf_poll , __u8 * data ) { nfcf_poll -> bit_rate = * data ++ ; nfcf_poll -> sensf_res_len = * data ++ ; pr_debug ( ""bit_rate%d,sensf_res_len%d\\n"" , nfcf_poll -> bit_rate , nfcf_poll -> sensf_res_len ) ; memcpy ( nfcf_poll -> sensf_res , data , nfcf_poll -> sensf_res_len ) ; data += nfcf_poll -> sensf_res_len ; return data ; } "," -> sensf_res_len = min_t ( __u8 , * data ++ , NFC_SENSF_RES_MAXSIZE ) ",torvalds@linux/67de956ff5dc1d4f321e16cfbd63f5be3b691b43,CVE-2012-3364,https://github.com/torvalds/linux/commit/67de956ff5dc1d4f321e16cfbd63f5be3b691b43,2013-01-22T23:55Z 1312,CWE-416,"CWE-416 static ssize_t ucma_process_join ( struct ucma_file * file , struct rdma_ucm_join_mcast * cmd , int out_len ) { struct rdma_ucm_create_id_resp resp ; struct ucma_context * ctx ; struct ucma_multicast * mc ; struct sockaddr * addr ; int ret ; u8 join_state ; if ( out_len < sizeof ( resp ) ) return - ENOSPC ; addr = ( struct sockaddr * ) & cmd -> addr ; if ( cmd -> addr_size != rdma_addr_size ( addr ) ) return - EINVAL ; if ( cmd -> join_flags == RDMA_MC_JOIN_FLAG_FULLMEMBER ) join_state = BIT ( FULLMEMBER_JOIN ) ; else if ( cmd -> join_flags == RDMA_MC_JOIN_FLAG_SENDONLY_FULLMEMBER ) join_state = BIT ( SENDONLY_FULLMEMBER_JOIN ) ; else return - EINVAL ; ctx = ucma_get_ctx_dev ( file , cmd -> id ) ; if ( IS_ERR ( ctx ) ) return PTR_ERR ( ctx ) ; mutex_lock ( & file -> mut ) ; mc = ucma_alloc_multicast ( ctx ) ; if ( ! mc ) { ret = - ENOMEM ; goto err1 ; } mc -> join_state = join_state ; mc -> uid = cmd -> uid ; memcpy ( & mc -> addr , addr , cmd -> addr_size ) ; ret = rdma_join_multicast ( ctx -> cm_id , ( struct sockaddr * ) & mc -> addr , join_state , mc ) ; if ( ret ) goto err2 ; resp . id = mc -> id ; if ( copy_to_user ( u64_to_user_ptr ( cmd -> response ) , & resp , sizeof ( resp ) ) ) { ret = - EFAULT ; goto err3 ; } mutex_unlock ( & file -> mut ) ; ucma_put_ctx ( ctx ) ; return 0 ; err3 : rdma_leave_multicast ( ctx -> cm_id , ( struct sockaddr * ) & mc -> addr ) ; ucma_cleanup_mc_events ( mc ) ; err2 : mutex_lock ( & mut ) ; idr_remove ( & multicast_idr , mc -> id ) ; mutex_unlock ( & mut ) ; list_del ( & mc -> list ) ; kfree ( mc ) ; err1 : mutex_unlock ( & file -> mut ) ; ucma_put_ctx ( ctx ) ; return ret ; } "," err3 ; } mutex_lock ( & mut ) ; idr_replace ( & multicast_idr , mc , mc -> id ) ; mutex_unlock ( & mut ) ; ",torvalds@linux/cb2595c1393b4a5211534e6f0a0fbad369e21ad8,CVE-2018-14734,https://github.com/torvalds/linux/commit/cb2595c1393b4a5211534e6f0a0fbad369e21ad8,2018-07-29T23:29Z 1313,CWE-000,"CWE-000 static int selectExpander ( Walker * pWalker , Select * p ) { Parse * pParse = pWalker -> pParse ; int i , j , k ; SrcList * pTabList ; ExprList * pEList ; struct SrcList_item * pFrom ; sqlite3 * db = pParse -> db ; Expr * pE , * pRight , * pExpr ; u16 selFlags = p -> selFlags ; u32 elistFlags = 0 ; p -> selFlags |= SF_Expanded ; if ( db -> mallocFailed ) { return WRC_Abort ; } assert ( p -> pSrc != 0 ) ; if ( ( selFlags & SF_Expanded ) != 0 ) { return WRC_Prune ; } if ( pWalker -> eCode ) { p -> selId = ++ pParse -> nSelect ; } pTabList = p -> pSrc ; pEList = p -> pEList ; sqlite3WithPush ( pParse , p -> pWith , 0 ) ; sqlite3SrcListAssignCursors ( pParse , pTabList ) ; for ( i = 0 , pFrom = pTabList -> a ; i < pTabList -> nSrc ; i ++ , pFrom ++ ) { Table * pTab ; assert ( pFrom -> fg . isRecursive == 0 || pFrom -> pTab != 0 ) ; if ( pFrom -> fg . isRecursive ) continue ; assert ( pFrom -> pTab == 0 ) ; # ifndef SQLITE_OMIT_CTE if ( withExpand ( pWalker , pFrom ) ) return WRC_Abort ; if ( pFrom -> pTab ) { } else # endif if ( pFrom -> zName == 0 ) { # ifndef SQLITE_OMIT_SUBQUERY Select * pSel = pFrom -> pSelect ; assert ( pSel != 0 ) ; assert ( pFrom -> pTab == 0 ) ; if ( sqlite3WalkSelect ( pWalker , pSel ) ) return WRC_Abort ; if ( sqlite3ExpandSubquery ( pParse , pFrom ) ) return WRC_Abort ; # endif } else { assert ( pFrom -> pTab == 0 ) ; pFrom -> pTab = pTab = sqlite3LocateTableItem ( pParse , 0 , pFrom ) ; if ( pTab == 0 ) return WRC_Abort ; if ( pTab -> nTabRef >= 0xffff ) { sqlite3ErrorMsg ( pParse , ""toomanyreferencesto\\""%s\\"":max65535"" , pTab -> zName ) ; pFrom -> pTab = 0 ; return WRC_Abort ; } pTab -> nTabRef ++ ; if ( ! IsVirtual ( pTab ) && cannotBeFunction ( pParse , pFrom ) ) { return WRC_Abort ; } # if ! defined ( SQLITE_OMIT_VIEW ) || ! defined ( SQLITE_OMIT_VIRTUALTABLE ) if ( IsVirtual ( pTab ) || pTab -> pSelect ) { i16 nCol ; u8 eCodeOrig = pWalker -> eCode ; if ( sqlite3ViewGetColumnNames ( pParse , pTab ) ) return WRC_Abort ; assert ( pFrom -> pSelect == 0 ) ; if ( pTab -> pSelect && ( db -> flags & SQLITE_EnableView ) == 0 ) { sqlite3ErrorMsg ( pParse , ""accesstoview\\""%s\\""prohibited"" , pTab -> zName ) ; } pFrom -> pSelect = sqlite3SelectDup ( db , pTab -> pSelect , 0 ) ; nCol = pTab -> nCol ; pTab -> nCol = - 1 ; pWalker -> eCode = 1 ; sqlite3WalkSelect ( pWalker , pFrom -> pSelect ) ; pWalker -> eCode = eCodeOrig ; pTab -> nCol = nCol ; } # endif } if ( sqlite3IndexedByLookup ( pParse , pFrom ) ) { return WRC_Abort ; } } if ( db -> mallocFailed || sqliteProcessJoin ( pParse , p ) ) { return WRC_Abort ; } for ( k = 0 ; k < pEList -> nExpr ; k ++ ) { pE = pEList -> a [ k ] . pExpr ; if ( pE -> op == TK_ASTERISK ) break ; assert ( pE -> op != TK_DOT || pE -> pRight != 0 ) ; assert ( pE -> op != TK_DOT || ( pE -> pLeft != 0 && pE -> pLeft -> op == TK_ID ) ) ; if ( pE -> op == TK_DOT && pE -> pRight -> op == TK_ASTERISK ) break ; elistFlags |= pE -> flags ; } if ( k < pEList -> nExpr ) { struct ExprList_item * a = pEList -> a ; ExprList * pNew = 0 ; int flags = pParse -> db -> flags ; int longNames = ( flags & SQLITE_FullColNames ) != 0 && ( flags & SQLITE_ShortColNames ) == 0 ; for ( k = 0 ; k < pEList -> nExpr ; k ++ ) { pE = a [ k ] . pExpr ; elistFlags |= pE -> flags ; pRight = pE -> pRight ; assert ( pE -> op != TK_DOT || pRight != 0 ) ; if ( pE -> op != TK_ASTERISK && ( pE -> op != TK_DOT || pRight -> op != TK_ASTERISK ) ) { pNew = sqlite3ExprListAppend ( pParse , pNew , a [ k ] . pExpr ) ; if ( pNew ) { pNew -> a [ pNew -> nExpr - 1 ] . zName = a [ k ] . zName ; pNew -> a [ pNew -> nExpr - 1 ] . zSpan = a [ k ] . zSpan ; a [ k ] . zName = 0 ; a [ k ] . zSpan = 0 ; } a [ k ] . pExpr = 0 ; } else { int tableSeen = 0 ; char * zTName = 0 ; if ( pE -> op == TK_DOT ) { assert ( pE -> pLeft != 0 ) ; assert ( ! ExprHasProperty ( pE -> pLeft , EP_IntValue ) ) ; zTName = pE -> pLeft -> u . zToken ; } for ( i = 0 , pFrom = pTabList -> a ; i < pTabList -> nSrc ; i ++ , pFrom ++ ) { Table * pTab = pFrom -> pTab ; Select * pSub = pFrom -> pSelect ; char * zTabName = pFrom -> zAlias ; const char * zSchemaName = 0 ; int iDb ; if ( zTabName == 0 ) { zTabName = pTab -> zName ; } if ( db -> mallocFailed ) break ; if ( pSub == 0 || ( pSub -> selFlags & SF_NestedFrom ) == 0 ) { pSub = 0 ; if ( zTName && sqlite3StrICmp ( zTName , zTabName ) != 0 ) { continue ; } iDb = sqlite3SchemaToIndex ( db , pTab -> pSchema ) ; zSchemaName = iDb >= 0 ? db -> aDb [ iDb ] . zDbSName : ""*"" ; } for ( j = 0 ; j < pTab -> nCol ; j ++ ) { char * zName = pTab -> aCol [ j ] . zName ; char * zColname ; char * zToFree ; Token sColname ; assert ( zName ) ; if ( zTName && pSub && sqlite3MatchSpanName ( pSub -> pEList -> a [ j ] . zSpan , 0 , zTName , 0 ) == 0 ) { continue ; } if ( ( p -> selFlags & SF_IncludeHidden ) == 0 && IsHiddenColumn ( & pTab -> aCol [ j ] ) ) { continue ; } tableSeen = 1 ; if ( i > 0 && zTName == 0 ) { if ( ( pFrom -> fg . jointype & JT_NATURAL ) != 0 && tableAndColumnIndex ( pTabList , i , zName , 0 , 0 ) ) { continue ; } if ( sqlite3IdListIndex ( pFrom -> pUsing , zName ) >= 0 ) { continue ; } } pRight = sqlite3Expr ( db , TK_ID , zName ) ; zColname = zName ; zToFree = 0 ; if ( longNames || pTabList -> nSrc > 1 ) { Expr * pLeft ; pLeft = sqlite3Expr ( db , TK_ID , zTabName ) ; pExpr = sqlite3PExpr ( pParse , TK_DOT , pLeft , pRight ) ; if ( zSchemaName ) { pLeft = sqlite3Expr ( db , TK_ID , zSchemaName ) ; pExpr = sqlite3PExpr ( pParse , TK_DOT , pLeft , pExpr ) ; } if ( longNames ) { zColname = sqlite3MPrintf ( db , ""%s.%s"" , zTabName , zName ) ; zToFree = zColname ; } } else { pExpr = pRight ; } pNew = sqlite3ExprListAppend ( pParse , pNew , pExpr ) ; sqlite3TokenInit ( & sColname , zColname ) ; sqlite3ExprListSetName ( pParse , pNew , & sColname , 0 ) ; if ( pNew && ( p -> selFlags & SF_NestedFrom ) != 0 ) { struct ExprList_item * pX = & pNew -> a [ pNew -> nExpr - 1 ] ; if ( pSub ) { pX -> zSpan = sqlite3DbStrDup ( db , pSub -> pEList -> a [ j ] . zSpan ) ; testcase ( pX -> zSpan == 0 ) ; } else { pX -> zSpan = sqlite3MPrintf ( db , ""%s.%s.%s"" , zSchemaName , zTabName , zColname ) ; testcase ( pX -> zSpan == 0 ) ; } pX -> bSpanIsTab = 1 ; } sqlite3DbFree ( db , zToFree ) ; } } if ( ! tableSeen ) { if ( zTName ) { sqlite3ErrorMsg ( pParse , ""nosuchtable:%s"" , zTName ) ; } else { sqlite3ErrorMsg ( pParse , ""notablesspecified"" ) ; } } } } sqlite3ExprListDelete ( db , pEList ) ; p -> pEList = pNew ; } if ( p -> pEList ) { if ( p -> pEList -> nExpr > db -> aLimit [ SQLITE_LIMIT_COLUMN ] ) { sqlite3ErrorMsg ( pParse , ""toomanycolumnsinresultset"" ) ; return WRC_Abort ; } if ( ( elistFlags & ( EP_HasFunc | EP_Subquery ) ) != 0 ) { p -> selFlags |= SF_ComplexResult ; } } return WRC_Continue ; } "," } if ( pParse -> nErr || ",sqlite@sqlite/a6c1a71cde082e09750465d5675699062922e387,CVE-2019-20218,https://github.com/sqlite/sqlite/commit/a6c1a71cde082e09750465d5675699062922e387,2020-01-02T14:16Z 1314,CWE-000,"CWE-000 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 1315,CWE-362,"CWE-362 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 1316,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 1317,CWE-119,"CWE-119 int vp8_denoiser_allocate ( VP8_DENOISER * denoiser , int width , int height ) { int i ; assert ( denoiser ) ; for ( i = 0 ; i < MAX_REF_FRAMES ; i ++ ) { denoiser -> yv12_running_avg [ i ] . flags = 0 ; if ( vp8_yv12_alloc_frame_buffer ( & ( denoiser -> yv12_running_avg [ i ] ) , width , height , VP8BORDERINPIXELS ) < 0 ) { vp8_denoiser_free ( denoiser ) ; return 1 ; } vpx_memset ( denoiser -> yv12_running_avg [ i ] . buffer_alloc , 0 , denoiser -> yv12_running_avg [ i ] . frame_size ) ; } denoiser -> yv12_mc_running_avg . flags = 0 ; if ( vp8_yv12_alloc_frame_buffer ( & ( denoiser -> yv12_mc_running_avg ) , width , height , VP8BORDERINPIXELS ) < 0 ) { vp8_denoiser_free ( denoiser ) ; return 1 ; } vpx_memset ( denoiser -> yv12_mc_running_avg . buffer_alloc , 0 , denoiser -> yv12_mc_running_avg . frame_size ) ; return 0 ; } "," , int height , int num_mb_rows , int num_mb_cols , int mode ( denoiser ) ; denoiser -> num_mb_cols = num_mb_cols 1 ; } memset ( denoiser -> 1 ; } memset ( denoiser -> frame_size ) ; if ( vp8_yv12_alloc_frame_buffer ( & denoiser -> yv12_last_source , width , height , VP8BORDERINPIXELS ) < 0 ) { vp8_denoiser_free ( denoiser ) ; return 1 ; } memset ( denoiser -> yv12_last_source . buffer_alloc , 0 , denoiser -> yv12_last_source . frame_size ) ; denoiser -> denoise_state = vpx_calloc ( ( num_mb_rows * num_mb_cols ) , 1 ) ; memset ( denoiser -> denoise_state , 0 , ( num_mb_rows * num_mb_cols ) ) ; vp8_denoiser_set_parameters ( denoiser , mode ) ; denoiser -> nmse_source_diff = 0 ; denoiser -> nmse_source_diff_count = 0 ; denoiser -> qp_avg = 0 ; denoiser -> qp_threshold_up = 80 ; denoiser -> qp_threshold_down = 128 ; denoiser -> bitrate_threshold = 400000 ; denoiser -> threshold_aggressive_mode = 80 ; if ( width * height > 1280 * 720 ) { denoiser -> bitrate_threshold = 3000000 ; denoiser -> threshold_aggressive_mode = 200 ; } else if ( width * height > 960 * 540 ) { denoiser -> bitrate_threshold = 1200000 ; denoiser -> threshold_aggressive_mode = 120 ; } else if ( width * height > 640 * 480 ) { denoiser -> bitrate_threshold = 600000 ; denoiser -> threshold_aggressive_mode = 100 ; } return 0 ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1318,CWE-119,"CWE-119 void btif_config_flush ( void ) { assert ( config != NULL ) ; assert ( alarm_timer != NULL ) ; alarm_cancel ( alarm_timer ) ; pthread_mutex_lock ( & lock ) ; config_save ( config , CONFIG_FILE_PATH ) ; pthread_mutex_unlock ( & lock ) ; } "," alarm_timer ) ; btif_config_write ( ) ; } ",system@bt/d77f1999ecece56c1cbb333f4ddc26f0b5bac2c5,CVE-2016-0830,https://android.googlesource.com/platform/system/bt/+/d77f1999ecece56c1cbb333f4ddc26f0b5bac2c5,2016-03-12T21:59Z 1319,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 1320,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 1321,CWE-476,"CWE-476 static int mpeg4video_probe ( AVProbeData * probe_packet ) { uint32_t temp_buffer = - 1 ; int VO = 0 , VOL = 0 , VOP = 0 , VISO = 0 , res = 0 ; int i ; for ( i = 0 ; i < probe_packet -> buf_size ; i ++ ) { temp_buffer = ( temp_buffer << 8 ) + probe_packet -> buf [ i ] ; if ( ( temp_buffer & 0xffffff00 ) != 0x100 ) continue ; if ( temp_buffer == VOP_START_CODE ) VOP ++ ; else if ( temp_buffer == VISUAL_OBJECT_START_CODE ) VISO ++ ; else if ( temp_buffer < 0x120 ) VO ++ ; else if ( temp_buffer < 0x130 ) VOL ++ ; else if ( ! ( 0x1AF < temp_buffer && temp_buffer < 0x1B7 ) && ! ( 0x1B9 < temp_buffer && temp_buffer < 0x1C4 ) ) res ++ ; } if ( VOP >= VISO && VOP >= VOL && VO >= VOL && VOL > 0 && res == 0 ) return AVPROBE_SCORE_EXTENSION ; return 0 ; } "," ; if ( temp_buffer & 0xfffffe00 ) continue ; if ( temp_buffer < 2 ) continue ; if ( temp_buffer >= 0x100 && temp_buffer else if ( temp_buffer >= 0x120 && ",libav@libav/e5b019725f53b79159931d3a7317107cbbfd0860,CVE-2016-8675,https://github.com/libav/libav/commit/e5b019725f53b79159931d3a7317107cbbfd0860,2017-02-15T21:59Z 1322,CWE-362,"CWE-362 SYSCALL_DEFINE5 ( perf_event_open , struct perf_event_attr __user * , attr_uptr , pid_t , pid , int , cpu , int , group_fd , unsigned long , flags ) { struct perf_event * group_leader = NULL , * output_event = NULL ; struct perf_event * event , * sibling ; struct perf_event_attr attr ; struct perf_event_context * ctx , * uninitialized_var ( gctx ) ; struct file * event_file = NULL ; struct fd group = { NULL , 0 } ; struct task_struct * task = NULL ; struct pmu * pmu ; int event_fd ; int move_group = 0 ; int err ; int f_flags = O_RDWR ; int cgroup_fd = - 1 ; if ( flags & ~ PERF_FLAG_ALL ) return - EINVAL ; err = perf_copy_attr ( attr_uptr , & attr ) ; if ( err ) return err ; if ( ! attr . exclude_kernel ) { if ( perf_paranoid_kernel ( ) && ! capable ( CAP_SYS_ADMIN ) ) return - EACCES ; } if ( attr . freq ) { if ( attr . sample_freq > sysctl_perf_event_sample_rate ) return - EINVAL ; } else { if ( attr . sample_period & ( 1ULL << 63 ) ) return - EINVAL ; } if ( ! attr . sample_max_stack ) attr . sample_max_stack = sysctl_perf_event_max_stack ; if ( ( flags & PERF_FLAG_PID_CGROUP ) && ( pid == - 1 || cpu == - 1 ) ) return - EINVAL ; if ( flags & PERF_FLAG_FD_CLOEXEC ) f_flags |= O_CLOEXEC ; event_fd = get_unused_fd_flags ( f_flags ) ; if ( event_fd < 0 ) return event_fd ; if ( group_fd != - 1 ) { err = perf_fget_light ( group_fd , & group ) ; if ( err ) goto err_fd ; group_leader = group . file -> private_data ; if ( flags & PERF_FLAG_FD_OUTPUT ) output_event = group_leader ; if ( flags & PERF_FLAG_FD_NO_GROUP ) group_leader = NULL ; } if ( pid != - 1 && ! ( flags & PERF_FLAG_PID_CGROUP ) ) { task = find_lively_task_by_vpid ( pid ) ; if ( IS_ERR ( task ) ) { err = PTR_ERR ( task ) ; goto err_group_fd ; } } if ( task && group_leader && group_leader -> attr . inherit != attr . inherit ) { err = - EINVAL ; goto err_task ; } get_online_cpus ( ) ; if ( task ) { err = mutex_lock_interruptible ( & task -> signal -> cred_guard_mutex ) ; if ( err ) goto err_cpus ; err = - EACCES ; if ( ! ptrace_may_access ( task , PTRACE_MODE_READ_REALCREDS ) ) goto err_cred ; } if ( flags & PERF_FLAG_PID_CGROUP ) cgroup_fd = pid ; event = perf_event_alloc ( & attr , cpu , task , group_leader , NULL , NULL , NULL , cgroup_fd ) ; if ( IS_ERR ( event ) ) { err = PTR_ERR ( event ) ; goto err_cred ; } if ( is_sampling_event ( event ) ) { if ( event -> pmu -> capabilities & PERF_PMU_CAP_NO_INTERRUPT ) { err = - EOPNOTSUPP ; goto err_alloc ; } } pmu = event -> pmu ; if ( attr . use_clockid ) { err = perf_event_set_clock ( event , attr . clockid ) ; if ( err ) goto err_alloc ; } if ( pmu -> task_ctx_nr == perf_sw_context ) event -> event_caps |= PERF_EV_CAP_SOFTWARE ; if ( group_leader && ( is_software_event ( event ) != is_software_event ( group_leader ) ) ) { if ( is_software_event ( event ) ) { pmu = group_leader -> pmu ; } else if ( is_software_event ( group_leader ) && ( group_leader -> group_caps & PERF_EV_CAP_SOFTWARE ) ) { move_group = 1 ; } } ctx = find_get_context ( pmu , task , event ) ; if ( IS_ERR ( ctx ) ) { err = PTR_ERR ( ctx ) ; goto err_alloc ; } if ( ( pmu -> capabilities & PERF_PMU_CAP_EXCLUSIVE ) && group_leader ) { err = - EBUSY ; goto err_context ; } if ( group_leader ) { err = - EINVAL ; if ( group_leader -> group_leader != group_leader ) goto err_context ; if ( group_leader -> clock != event -> clock ) goto err_context ; if ( move_group ) { if ( group_leader -> ctx -> task != ctx -> task ) goto err_context ; if ( group_leader -> cpu != event -> cpu ) goto err_context ; } else { if ( group_leader -> ctx != ctx ) goto err_context ; } if ( attr . exclusive || attr . pinned ) goto err_context ; } if ( output_event ) { err = perf_event_set_output ( event , output_event ) ; if ( err ) goto err_context ; } event_file = anon_inode_getfile ( ""[perf_event]"" , & perf_fops , event , f_flags ) ; if ( IS_ERR ( event_file ) ) { err = PTR_ERR ( event_file ) ; event_file = NULL ; goto err_context ; } if ( move_group ) { gctx = group_leader -> ctx ; mutex_lock_double ( & gctx -> mutex , & ctx -> mutex ) ; if ( gctx -> task == TASK_TOMBSTONE ) { err = - ESRCH ; goto err_locked ; } } else { mutex_lock ( & ctx -> mutex ) ; } if ( ctx -> task == TASK_TOMBSTONE ) { err = - ESRCH ; goto err_locked ; } if ( ! perf_event_validate_size ( event ) ) { err = - E2BIG ; goto err_locked ; } if ( ! exclusive_event_installable ( event , ctx ) ) { WARN_ON_ONCE ( move_group ) ; err = - EBUSY ; goto err_locked ; } WARN_ON_ONCE ( ctx -> parent_ctx ) ; if ( move_group ) { perf_remove_from_context ( group_leader , 0 ) ; list_for_each_entry ( sibling , & group_leader -> sibling_list , group_entry ) { perf_remove_from_context ( sibling , 0 ) ; put_ctx ( gctx ) ; } synchronize_rcu ( ) ; list_for_each_entry ( sibling , & group_leader -> sibling_list , group_entry ) { perf_event__state_init ( sibling ) ; perf_install_in_context ( ctx , sibling , sibling -> cpu ) ; get_ctx ( ctx ) ; } perf_event__state_init ( group_leader ) ; perf_install_in_context ( ctx , group_leader , group_leader -> cpu ) ; get_ctx ( ctx ) ; put_ctx ( gctx ) ; } perf_event__header_size ( event ) ; perf_event__id_header_size ( event ) ; event -> owner = current ; perf_install_in_context ( ctx , event , event -> cpu ) ; perf_unpin_context ( ctx ) ; if ( move_group ) mutex_unlock ( & gctx -> mutex ) ; mutex_unlock ( & ctx -> mutex ) ; if ( task ) { mutex_unlock ( & task -> signal -> cred_guard_mutex ) ; put_task_struct ( task ) ; } put_online_cpus ( ) ; mutex_lock ( & current -> perf_event_mutex ) ; list_add_tail ( & event -> owner_entry , & current -> perf_event_list ) ; mutex_unlock ( & current -> perf_event_mutex ) ; fdput ( group ) ; fd_install ( event_fd , event_file ) ; return event_fd ; err_locked : if ( move_group ) mutex_unlock ( & gctx -> mutex ) ; mutex_unlock ( & ctx -> mutex ) ; fput ( event_file ) ; err_context : perf_unpin_context ( ctx ) ; put_ctx ( ctx ) ; err_alloc : if ( ! event_file ) free_event ( event ) ; err_cred : if ( task ) mutex_unlock ( & task -> signal -> cred_guard_mutex ) ; err_cpus : put_online_cpus ( ) ; err_task : if ( task ) put_task_struct ( task ) ; err_group_fd : fdput ( group ) ; err_fd : put_unused_fd ( event_fd ) ; return err ; } "," { gctx = __perf_event_ctx_lock_double ( group_leader , ctx ) ; if err_locked ; } if ( ! ( group_leader -> group_caps & PERF_EV_CAP_SOFTWARE ) ) { if ( gctx != ctx ) { err = - EINVAL ; goto err_locked ; } else { perf_event_ctx_unlock ( group_leader , gctx ) ; move_group = 0 ; } } ( move_group ) perf_event_ctx_unlock ( group_leader , gctx ) ; mutex_unlock ( move_group ) perf_event_ctx_unlock ( group_leader , gctx ) ; mutex_unlock ",torvalds@linux/321027c1fe77f892f4ea07846aeae08cefbbb290,CVE-2017-6001,https://github.com/torvalds/linux/commit/321027c1fe77f892f4ea07846aeae08cefbbb290,2017-02-18T21:59Z 1323,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 1324,CWE-264,"CWE-264 static int em_jmp_far ( struct x86_emulate_ctxt * ctxt ) { int rc ; unsigned short sel ; memcpy ( & sel , ctxt -> src . valptr + ctxt -> op_bytes , 2 ) ; rc = load_segment_descriptor ( ctxt , sel , VCPU_SREG_CS ) ; if ( rc != X86EMUL_CONTINUE ) return rc ; ctxt -> _eip = 0 ; memcpy ( & ctxt -> _eip , ctxt -> src . valptr , ctxt -> op_bytes ) ; return X86EMUL_CONTINUE ; } "," unsigned short sel , old_sel ; struct desc_struct old_desc , new_desc ; const struct x86_emulate_ops * ops = ctxt -> ops ; u8 cpl = ctxt -> ops -> cpl ( ctxt ) ; if ( ctxt -> mode == X86EMUL_MODE_PROT64 ) ops -> get_segment ( ctxt , & old_sel , & old_desc , NULL , VCPU_SREG_CS ) ; rc = __load_segment_descriptor ( ctxt , sel , VCPU_SREG_CS , cpl , false , & new_desc return rc ; rc = assign_eip_far ( ctxt , ctxt -> -> src . val , new_desc . l ) ; if ( rc != X86EMUL_CONTINUE ) { WARN_ON ( ! ctxt -> mode != X86EMUL_MODE_PROT64 ) ; ops -> set_segment ( ctxt , old_sel , & old_desc , 0 , VCPU_SREG_CS ) ; return ) ; return rc ; } return rc ; } ",torvalds@linux/d1442d85cc30ea75f7d399474ca738e0bc96f715,CVE-2014-3647,https://github.com/torvalds/linux/commit/d1442d85cc30ea75f7d399474ca738e0bc96f715,2014-11-10T11:55Z 1325,CWE-682,"CWE-682 static int find_low_bit ( unsigned int x ) { int i ; for ( i = 0 ; i <= 31 ; i ++ ) { if ( x & ( 1 << i ) ) return i ; } return 0 ; } "," x & ( 1U << ( unsigned int ) i ) ) ",jsummers@imageworsener/a00183107d4b84bc8a714290e824ca9c68dac738,CVE-2017-8326,https://github.com/jsummers/imageworsener/commit/a00183107d4b84bc8a714290e824ca9c68dac738,2017-04-29T20:59Z 1326,CWE-617,"CWE-617 int connection_exit_begin_conn ( cell_t * cell , circuit_t * circ ) { edge_connection_t * n_stream ; relay_header_t rh ; char * address = NULL ; uint16_t port = 0 ; or_circuit_t * or_circ = NULL ; const or_options_t * options = get_options ( ) ; begin_cell_t bcell ; int rv ; uint8_t end_reason = 0 ; assert_circuit_ok ( circ ) ; if ( ! CIRCUIT_IS_ORIGIN ( circ ) ) or_circ = TO_OR_CIRCUIT ( circ ) ; relay_header_unpack ( & rh , cell -> payload ) ; if ( rh . length > RELAY_PAYLOAD_SIZE ) return - END_CIRC_REASON_TORPROTOCOL ; if ( ! server_mode ( options ) && circ -> purpose != CIRCUIT_PURPOSE_S_REND_JOINED ) { log_fn ( LOG_PROTOCOL_WARN , LD_PROTOCOL , ""Relaybegincellatnon-server.Closing."" ) ; relay_send_end_cell_from_edge ( rh . stream_id , circ , END_STREAM_REASON_EXITPOLICY , NULL ) ; return 0 ; } rv = begin_cell_parse ( cell , & bcell , & end_reason ) ; if ( rv < - 1 ) { return - END_CIRC_REASON_TORPROTOCOL ; } else if ( rv == - 1 ) { tor_free ( bcell . address ) ; relay_send_end_cell_from_edge ( rh . stream_id , circ , end_reason , NULL ) ; return 0 ; } if ( ! bcell . is_begindir ) { address = bcell . address ; port = bcell . port ; if ( or_circ && or_circ -> p_chan ) { if ( ! options -> AllowSingleHopExits && ( or_circ -> is_first_hop || ( ! connection_or_digest_is_known_relay ( or_circ -> p_chan -> identity_digest ) && should_refuse_unknown_exits ( options ) ) ) ) { log_fn ( LOG_PROTOCOL_WARN , LD_PROTOCOL , ""Attemptby%stoopenastream%s.Closing."" , safe_str ( channel_get_canonical_remote_descr ( or_circ -> p_chan ) ) , or_circ -> is_first_hop ? ""onfirsthopofcircuit"" : ""fromunknownrelay"" ) ; relay_send_end_cell_from_edge ( rh . stream_id , circ , or_circ -> is_first_hop ? END_STREAM_REASON_TORPROTOCOL : END_STREAM_REASON_MISC , NULL ) ; tor_free ( address ) ; return 0 ; } } } else if ( rh . command == RELAY_COMMAND_BEGIN_DIR ) { if ( ! directory_permits_begindir_requests ( options ) || circ -> purpose != CIRCUIT_PURPOSE_OR ) { relay_send_end_cell_from_edge ( rh . stream_id , circ , END_STREAM_REASON_NOTDIRECTORY , NULL ) ; return 0 ; } if ( or_circ && or_circ -> p_chan ) address = tor_strdup ( channel_get_actual_remote_address ( or_circ -> p_chan ) ) ; else address = tor_strdup ( ""127.0.0.1"" ) ; port = 1 ; } else { log_warn ( LD_BUG , ""Gotanunexpectedcommand%d"" , ( int ) rh . command ) ; relay_send_end_cell_from_edge ( rh . stream_id , circ , END_STREAM_REASON_INTERNAL , NULL ) ; return 0 ; } if ( ! options -> IPv6Exit ) { bcell . flags &= ~ BEGIN_FLAG_IPV6_PREFERRED ; if ( bcell . flags & BEGIN_FLAG_IPV4_NOT_OK ) { tor_free ( address ) ; relay_send_end_cell_from_edge ( rh . stream_id , circ , END_STREAM_REASON_EXITPOLICY , NULL ) ; return 0 ; } } log_debug ( LD_EXIT , ""Creatingnewexitconnection."" ) ; n_stream = edge_connection_new ( CONN_TYPE_EXIT , AF_INET ) ; n_stream -> dirreq_id = circ -> dirreq_id ; n_stream -> base_ . purpose = EXIT_PURPOSE_CONNECT ; n_stream -> begincell_flags = bcell . flags ; n_stream -> stream_id = rh . stream_id ; n_stream -> base_ . port = port ; n_stream -> package_window = STREAMWINDOW_START ; n_stream -> deliver_window = STREAMWINDOW_START ; if ( circ -> purpose == CIRCUIT_PURPOSE_S_REND_JOINED ) { origin_circuit_t * origin_circ = TO_ORIGIN_CIRCUIT ( circ ) ; log_info ( LD_REND , ""beginisforrendezvous.configuringstream."" ) ; n_stream -> base_ . address = tor_strdup ( ""(rendezvous)"" ) ; n_stream -> base_ . state = EXIT_CONN_STATE_CONNECTING ; n_stream -> rend_data = rend_data_dup ( origin_circ -> rend_data ) ; tor_assert ( connection_edge_is_rendezvous_stream ( n_stream ) ) ; assert_circuit_ok ( circ ) ; const int r = rend_service_set_connection_addr_port ( n_stream , origin_circ ) ; if ( r < 0 ) { log_info ( LD_REND , ""Didn\'tfindrendezvousservice(port%d)"" , n_stream -> base_ . port ) ; relay_send_end_cell_from_edge ( rh . stream_id , circ , END_STREAM_REASON_DONE , origin_circ -> cpath -> prev ) ; connection_free ( TO_CONN ( n_stream ) ) ; tor_free ( address ) ; if ( r < - 1 ) return END_CIRC_AT_ORIGIN ; else return 0 ; } assert_circuit_ok ( circ ) ; log_debug ( LD_REND , ""Finishedassigningaddr/port"" ) ; n_stream -> cpath_layer = origin_circ -> cpath -> prev ; n_stream -> next_stream = origin_circ -> p_streams ; n_stream -> on_circuit = circ ; origin_circ -> p_streams = n_stream ; assert_circuit_ok ( circ ) ; origin_circ -> rend_data -> nr_streams ++ ; connection_exit_connect ( n_stream ) ; pathbias_mark_use_success ( origin_circ ) ; tor_free ( address ) ; return 0 ; } tor_strlower ( address ) ; n_stream -> base_ . address = address ; n_stream -> base_ . state = EXIT_CONN_STATE_RESOLVEFAILED ; if ( we_are_hibernating ( ) ) { relay_send_end_cell_from_edge ( rh . stream_id , circ , END_STREAM_REASON_HIBERNATING , NULL ) ; connection_free ( TO_CONN ( n_stream ) ) ; return 0 ; } n_stream -> on_circuit = circ ; if ( rh . command == RELAY_COMMAND_BEGIN_DIR ) { tor_addr_t tmp_addr ; tor_assert ( or_circ ) ; if ( or_circ -> p_chan && channel_get_addr_if_possible ( or_circ -> p_chan , & tmp_addr ) ) { tor_addr_copy ( & n_stream -> base_ . addr , & tmp_addr ) ; } return connection_exit_connect_dir ( n_stream ) ; } log_debug ( LD_EXIT , ""abouttostartthedns_resolve()."" ) ; switch ( dns_resolve ( n_stream ) ) { case 1 : assert_circuit_ok ( circ ) ; log_debug ( LD_EXIT , ""abouttocallconnection_exit_connect()."" ) ; connection_exit_connect ( n_stream ) ; return 0 ; case - 1 : relay_send_end_cell_from_edge ( rh . stream_id , circ , END_STREAM_REASON_RESOLVEFAILED , NULL ) ; break ; case 0 : assert_circuit_ok ( circ ) ; break ; } return 0 ; } "," or_circuit_t * or_circ = NULL ; origin_circuit_t * origin_circ = NULL ; crypt_path_t * layer_hint circ ) ) { circ ) ; } else { tor_assert ( circ -> purpose == CIRCUIT_PURPOSE_S_REND_JOINED ) ; origin_circ = TO_ORIGIN_CIRCUIT ( circ ) ; layer_hint = origin_circ -> cpath -> prev ; } , end_reason , layer_hint ) ; return , END_STREAM_REASON_NOTDIRECTORY , layer_hint ) ; return , END_STREAM_REASON_INTERNAL , layer_hint ) ; return , END_STREAM_REASON_EXITPOLICY , layer_hint ) ; return CIRCUIT_PURPOSE_S_REND_JOINED ) { tor_assert ( origin_circ ) ; log_info , END_STREAM_REASON_DONE , layer_hint ) ; connection_free ",torproject@tor/79b59a2dfcb68897ee89d98587d09e55f07e68d7,CVE-2017-0375,https://github.com/torproject/tor/commit/79b59a2dfcb68897ee89d98587d09e55f07e68d7,2017-06-09T17:29Z 1327,CWE-20,"CWE-20 static void unix_copy_addr ( struct msghdr * msg , struct sock * sk ) { struct unix_sock * u = unix_sk ( sk ) ; msg -> msg_namelen = 0 ; if ( u -> addr ) { msg -> msg_namelen = u -> addr -> len ; memcpy ( msg -> msg_name , u -> addr -> name , u -> addr -> len ) ; } } "," ( sk ) ; if ( ",torvalds@linux/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,CVE-2013-7271,https://github.com/torvalds/linux/commit/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,2014-01-06T16:55Z 1328,CWE-200,"CWE-200 int xstateregs_set ( struct task_struct * target , const struct user_regset * regset , unsigned int pos , unsigned int count , const void * kbuf , const void __user * ubuf ) { struct fpu * fpu = & target -> thread . fpu ; struct xregs_state * xsave ; int ret ; if ( ! boot_cpu_has ( X86_FEATURE_XSAVE ) ) return - ENODEV ; if ( ( pos != 0 ) || ( count < fpu_user_xstate_size ) ) return - EFAULT ; xsave = & fpu -> state . xsave ; fpu__activate_fpstate_write ( fpu ) ; if ( boot_cpu_has ( X86_FEATURE_XSAVES ) ) { if ( kbuf ) ret = copy_kernel_to_xstate ( xsave , kbuf ) ; else ret = copy_user_to_xstate ( xsave , ubuf ) ; } else { ret = user_regset_copyin ( & pos , & count , & kbuf , & ubuf , xsave , 0 , - 1 ) ; } if ( ret ) fpstate_init ( & fpu -> state ) ; xsave -> i387 . mxcsr &= mxcsr_feature_mask ; xsave -> header . xfeatures &= xfeatures_mask ; memset ( & xsave -> header . reserved , 0 , 48 ) ; return ret ; } "," 1 ) ; if ( ! ret && xsave -> header . xcomp_bv ) ret = - EINVAL ; ",torvalds@linux/814fb7bb7db5433757d76f4c4502c96fc53b0b5e,CVE-2017-15537,https://github.com/torvalds/linux/commit/814fb7bb7db5433757d76f4c4502c96fc53b0b5e,2017-10-17T18:29Z 1329,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 1330,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 1331,CWE-290,"CWE-290 static int valid_host ( cupsd_client_t * con ) { cupsd_alias_t * a ; cupsd_netif_t * netif ; const char * end ; char * ptr ; strlcpy ( con -> clientname , httpGetField ( con -> http , HTTP_FIELD_HOST ) , sizeof ( con -> clientname ) ) ; if ( ( ptr = strrchr ( con -> clientname , ':' ) ) != NULL && ! strchr ( ptr , ']' ) ) { * ptr ++ = '\\0' ; con -> clientport = atoi ( ptr ) ; } else con -> clientport = con -> serverport ; if ( httpAddrLocalhost ( httpGetAddress ( con -> http ) ) ) { return ( ! _cups_strcasecmp ( con -> clientname , ""localhost"" ) || ! _cups_strcasecmp ( con -> clientname , ""localhost."" ) || # ifdef __linux ! _cups_strcasecmp ( con -> clientname , ""localhost.localdomain"" ) || # endif ! strcmp ( con -> clientname , ""127.0.0.1"" ) || ! strcmp ( con -> clientname , ""[::1]"" ) ) ; } # if defined ( HAVE_DNSSD ) || defined ( HAVE_AVAHI ) if ( ( end = strrchr ( con -> clientname , '.' ) ) != NULL && end > con -> clientname && ! end [ 1 ] ) { for ( end -- ; end > con -> clientname && * end != '.' ; end -- ) ; } if ( end && ( ! _cups_strcasecmp ( end , "".local"" ) || ! _cups_strcasecmp ( end , "".local."" ) ) ) return ( 1 ) ; # endif if ( isdigit ( con -> clientname [ 0 ] & 255 ) || con -> clientname [ 0 ] == '[' ) { http_addrlist_t * addrlist ; if ( ( addrlist = httpAddrGetList ( con -> clientname , AF_UNSPEC , NULL ) ) != NULL ) { httpAddrFreeList ( addrlist ) ; return ( 1 ) ; } } for ( a = ( cupsd_alias_t * ) cupsArrayFirst ( ServerAlias ) ; a ; a = ( cupsd_alias_t * ) cupsArrayNext ( ServerAlias ) ) { if ( ! strcmp ( a -> name , ""*"" ) ) return ( 1 ) ; if ( ! _cups_strncasecmp ( con -> clientname , a -> name , a -> namelen ) ) { end = con -> clientname + a -> namelen ; if ( ! * end || ( * end == '.' && ! end [ 1 ] ) ) return ( 1 ) ; } } # if defined ( HAVE_DNSSD ) || defined ( HAVE_AVAHI ) for ( a = ( cupsd_alias_t * ) cupsArrayFirst ( DNSSDAlias ) ; a ; a = ( cupsd_alias_t * ) cupsArrayNext ( DNSSDAlias ) ) { if ( ! strcmp ( a -> name , ""*"" ) ) return ( 1 ) ; if ( ! _cups_strncasecmp ( con -> clientname , a -> name , a -> namelen ) ) { end = con -> clientname + a -> namelen ; if ( ! * end || ( * end == '.' && ! end [ 1 ] ) ) return ( 1 ) ; } } # endif for ( netif = ( cupsd_netif_t * ) cupsArrayFirst ( NetIFList ) ; netif ; netif = ( cupsd_netif_t * ) cupsArrayNext ( NetIFList ) ) { if ( ! _cups_strncasecmp ( con -> clientname , netif -> hostname , netif -> hostlen ) ) { end = con -> clientname + netif -> hostlen ; if ( ! * end || ( * end == '.' && ! end [ 1 ] ) ) return ( 1 ) ; } } return ( 0 ) ; } "," ""localhost."" ) || ! strcmp ( ",apple@cups/afa80cb2b457bf8d64f775bed307588610476c41,CVE-2017-18190,https://github.com/apple/cups/commit/afa80cb2b457bf8d64f775bed307588610476c41,2018-02-16T17:29Z 1332,CWE-125,"CWE-125 INST_HANDLER ( lds ) { int d = ( ( buf [ 0 ] >> 4 ) & 0xf ) | ( ( buf [ 1 ] & 0x1 ) << 4 ) ; int k = ( buf [ 3 ] << 8 ) | buf [ 2 ] ; op -> ptr = k ; __generic_ld_st ( op , ""ram"" , 0 , 1 , 0 , k , 0 ) ; ESIL_A ( ""r%d,=,"" , d ) ; } "," lds ) { if ( len < 4 ) { return ; } ",radare@radare2/041e53cab7ca33481ae45ecd65ad596976d78e68,CVE-2018-11375,https://github.com/radare/radare2/commit/041e53cab7ca33481ae45ecd65ad596976d78e68,2018-05-22T19:29Z 1333,CWE-310,"CWE-310 int ASN1_item_verify ( const ASN1_ITEM * it , X509_ALGOR * a , ASN1_BIT_STRING * signature , void * asn , EVP_PKEY * pkey ) { EVP_MD_CTX ctx ; unsigned char * buf_in = NULL ; int ret = - 1 , inl ; int mdnid , pknid ; if ( ! pkey ) { ASN1err ( ASN1_F_ASN1_ITEM_VERIFY , ERR_R_PASSED_NULL_PARAMETER ) ; return - 1 ; } EVP_MD_CTX_init ( & ctx ) ; if ( ! OBJ_find_sigid_algs ( OBJ_obj2nid ( a -> algorithm ) , & mdnid , & pknid ) ) { ASN1err ( ASN1_F_ASN1_ITEM_VERIFY , ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM ) ; goto err ; } if ( mdnid == NID_undef ) { if ( ! pkey -> ameth || ! pkey -> ameth -> item_verify ) { ASN1err ( ASN1_F_ASN1_ITEM_VERIFY , ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM ) ; goto err ; } ret = pkey -> ameth -> item_verify ( & ctx , it , asn , a , signature , pkey ) ; if ( ret != 2 ) goto err ; ret = - 1 ; } else { const EVP_MD * type ; type = EVP_get_digestbynid ( mdnid ) ; if ( type == NULL ) { ASN1err ( ASN1_F_ASN1_ITEM_VERIFY , ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM ) ; goto err ; } if ( EVP_PKEY_type ( pknid ) != pkey -> ameth -> pkey_id ) { ASN1err ( ASN1_F_ASN1_ITEM_VERIFY , ASN1_R_WRONG_PUBLIC_KEY_TYPE ) ; goto err ; } if ( ! EVP_DigestVerifyInit ( & ctx , NULL , type , NULL , pkey ) ) { ASN1err ( ASN1_F_ASN1_ITEM_VERIFY , ERR_R_EVP_LIB ) ; ret = 0 ; goto err ; } } inl = ASN1_item_i2d ( asn , & buf_in , it ) ; if ( buf_in == NULL ) { ASN1err ( ASN1_F_ASN1_ITEM_VERIFY , ERR_R_MALLOC_FAILURE ) ; goto err ; } ret = EVP_DigestVerifyUpdate ( & ctx , buf_in , inl ) ; OPENSSL_cleanse ( buf_in , ( unsigned int ) inl ) ; OPENSSL_free ( buf_in ) ; if ( ! ret ) { ASN1err ( ASN1_F_ASN1_ITEM_VERIFY , ERR_R_EVP_LIB ) ; goto err ; } ret = - 1 ; if ( EVP_DigestVerifyFinal ( & ctx , signature -> data , ( size_t ) signature -> length ) <= 0 ) { ASN1err ( ASN1_F_ASN1_ITEM_VERIFY , ERR_R_EVP_LIB ) ; ret = 0 ; goto err ; } ret = 1 ; err : EVP_MD_CTX_cleanup ( & ctx ) ; return ( ret ) ; } "," 1 ; } if ( signature -> type == V_ASN1_BIT_STRING && signature -> flags & 0x7 ) { ASN1err ( ASN1_F_ASN1_VERIFY , ASN1_R_INVALID_BIT_STRING_BITS_LEFT ) ; return - 1 ; } ",openssl@openssl/684400ce192dac51df3d3e92b61830a6ef90be3e,CVE-2014-8275,https://github.com/openssl/openssl/commit/684400ce192dac51df3d3e92b61830a6ef90be3e,2015-01-09T02:59Z 1334,CWE-000,"CWE-000 MagickExport const char * GetMagickFeatures ( void ) { return ""DPC"" # if defined ( MAGICKCORE_BUILD_MODULES ) || defined ( _DLL ) ""Modules"" # endif # if defined ( MAGICKCORE_HDRI_SUPPORT ) ""HDRI"" # endif # if defined ( MAGICKCORE_OPENCL_SUPPORT ) ""OpenCL"" # endif # if defined ( MAGICKCORE_OPENMP_SUPPORT ) ""OpenMP"" # endif ; } "," if defined ( MAGICKCORE_WINDOWS_SUPPORT ) && defined ( _DEBUG ) ""Debug"" # endif # if defined ( MAGICKCORE_CIPHER_SUPPORT ) ""Cipher"" # endif # MAGICKCORE_HDRI_SUPPORT ) ""HDRI"" # endif # if defined ( MAGICKCORE_BUILD_MODULES ) || defined ( _DLL ) ""Modules"" ""OpenMP"" # endif # if defined ( ZERO_CONFIGURATION_SUPPORT ) ""Zero-configuration"" # endif ",ImageMagick@ImageMagick/0f6fc2d5bf8f500820c3dbcf0d23ee14f2d9f734,CVE-2015-8896,https://github.com/ImageMagick/ImageMagick/commit/0f6fc2d5bf8f500820c3dbcf0d23ee14f2d9f734,2017-03-15T19:59Z 1335,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 1336,CWE-787,"CWE-787 DECLAREwriteFunc ( writeBufferToContigTiles ) { uint32 imagew = TIFFScanlineSize ( out ) ; uint32 tilew = TIFFTileRowSize ( out ) ; int iskew = imagew - tilew ; tsize_t tilesize = TIFFTileSize ( out ) ; tdata_t obuf ; uint8 * bufp = ( uint8 * ) buf ; uint32 tl , tw ; uint32 row ; ( void ) spp ; obuf = _TIFFmalloc ( TIFFTileSize ( out ) ) ; if ( obuf == NULL ) return 0 ; _TIFFmemset ( obuf , 0 , tilesize ) ; ( void ) TIFFGetField ( out , TIFFTAG_TILELENGTH , & tl ) ; ( void ) TIFFGetField ( out , TIFFTAG_TILEWIDTH , & tw ) ; for ( row = 0 ; row < imagelength ; row += tilelength ) { uint32 nrow = ( row + tl > imagelength ) ? imagelength - row : tl ; uint32 colb = 0 ; uint32 col ; for ( col = 0 ; col < imagewidth ; col += tw ) { if ( colb + tilew > imagew ) { uint32 width = imagew - colb ; int oskew = tilew - width ; cpStripToTile ( obuf , bufp + colb , nrow , width , oskew , oskew + iskew ) ; } else cpStripToTile ( obuf , bufp + colb , nrow , tilew , 0 , iskew ) ; if ( TIFFWriteTile ( out , obuf , col , row , 0 , 0 ) < 0 ) { TIFFError ( TIFFFileName ( out ) , ""Error,can\'twritetileat%lu%lu"" , ( unsigned long ) col , ( unsigned long ) row ) ; _TIFFfree ( obuf ) ; return 0 ; } colb += tilew ; } bufp += nrow * imagew ; } _TIFFfree ( obuf ) ; return 1 ; } "," col < imagewidth && colb < imagew ",vadz@libtiff/5ad9d8016fbb60109302d558f7edb2cb2a3bb8e3,CVE-2016-9540,https://github.com/vadz/libtiff/commit/5ad9d8016fbb60109302d558f7edb2cb2a3bb8e3,2016-11-22T19:59Z 1337,CWE-191,"CWE-191 int rad_packet_recv ( int fd , struct rad_packet_t * * p , struct sockaddr_in * addr ) { struct rad_packet_t * pack ; struct rad_attr_t * attr ; struct rad_dict_attr_t * da ; struct rad_dict_vendor_t * vendor ; uint8_t * ptr ; int n , id , len , vendor_id ; socklen_t addr_len = sizeof ( * addr ) ; * p = NULL ; pack = rad_packet_alloc ( 0 ) ; if ( ! pack ) return 0 ; ptr = mempool_alloc ( buf_pool ) ; if ( ptr == MAP_FAILED ) { log_emerg ( ""radius:packet:outofmemory\\n"" ) ; goto out_err ; } pack -> buf = ptr ; clock_gettime ( CLOCK_MONOTONIC , & pack -> tv ) ; while ( 1 ) { if ( addr ) n = recvfrom ( fd , pack -> buf , REQ_LENGTH_MAX , 0 , addr , & addr_len ) ; else n = read ( fd , pack -> buf , REQ_LENGTH_MAX ) ; if ( n < 0 ) { rad_packet_free ( pack ) ; if ( errno == EAGAIN ) return 1 ; if ( errno != ECONNREFUSED ) log_ppp_error ( ""radius:packet:read:%s\\n"" , strerror ( errno ) ) ; return - 1 ; } break ; } if ( n < 20 ) { log_ppp_warn ( ""radius:packet:shortpackedreceived(%i)\\n"" , n ) ; goto out_err ; } pack -> code = * ptr ; ptr ++ ; pack -> id = * ptr ; ptr ++ ; pack -> len = ntohs ( * ( uint16_t * ) ptr ) ; ptr += 2 ; if ( pack -> len > n ) { log_ppp_warn ( ""radius:packet:shortpacketreceived%i,expected%i\\n"" , pack -> len , n ) ; goto out_err ; } ptr += 16 ; n -= 20 ; while ( n > 0 ) { id = * ptr ; ptr ++ ; len = * ptr - 2 ; ptr ++ ; if ( len < 0 ) { log_ppp_warn ( ""radius:packetshortattributelenreceived\\n"" ) ; goto out_err ; } if ( 2 + len > n ) { log_ppp_warn ( ""radius:packet:toolongattributereceived(%i,%i)\\n"" , id , len ) ; goto out_err ; } if ( id == 26 ) { vendor_id = ntohl ( * ( uint32_t * ) ptr ) ; vendor = rad_dict_find_vendor_id ( vendor_id ) ; if ( vendor ) { ptr += 4 ; if ( vendor -> tag == 2 ) id = ( uint16_t ) ntohs ( * ( uint16_t * ) ptr ) ; else id = * ptr ; ptr += vendor -> tag ; if ( vendor -> len == 2 ) len = ( uint16_t ) ntohs ( * ( uint16_t * ) ptr ) ; else len = * ptr ; ptr += vendor -> len ; len -= vendor -> tag + vendor -> len ; n -= 4 + vendor -> tag + vendor -> len ; } else log_ppp_warn ( ""radius:packet:vendor%inotfound\\n"" , id ) ; } else vendor = NULL ; da = rad_dict_find_attr_id ( vendor , id ) ; if ( da ) { attr = mempool_alloc ( attr_pool ) ; if ( ! attr ) { log_emerg ( ""radius:packet:outofmemory\\n"" ) ; goto out_err ; } memset ( attr , 0 , sizeof ( * attr ) ) ; attr -> vendor = vendor ; attr -> attr = da ; attr -> len = len ; attr -> raw = ptr ; if ( ! da -> array ) { switch ( da -> type ) { case ATTR_TYPE_STRING : attr -> alloc = 1 ; attr -> val . string = _malloc ( len + 1 ) ; memcpy ( attr -> val . string , ptr , len ) ; attr -> val . string [ len ] = 0 ; break ; case ATTR_TYPE_OCTETS : case ATTR_TYPE_ETHER : case ATTR_TYPE_TLV : attr -> val . octets = ptr ; break ; case ATTR_TYPE_INTEGER : if ( len != da -> size ) log_ppp_warn ( ""radius:packet:attribute%shasinvalidlength%i(mustbe%i)\\n"" , da -> name , len , da -> size ) ; case ATTR_TYPE_DATE : if ( len == 4 ) attr -> val . integer = ntohl ( * ( uint32_t * ) ptr ) ; else if ( len == 2 ) attr -> val . integer = ntohs ( * ( uint16_t * ) ptr ) ; else if ( len == 1 ) attr -> val . integer = * ptr ; break ; case ATTR_TYPE_IPADDR : case ATTR_TYPE_IFID : case ATTR_TYPE_IPV6ADDR : memcpy ( & attr -> val . integer , ptr , len ) ; break ; case ATTR_TYPE_IPV6PREFIX : attr -> val . ipv6prefix . len = ptr [ 1 ] ; memset ( & attr -> val . ipv6prefix . prefix , 0 , sizeof ( attr -> val . ipv6prefix . prefix ) ) ; memcpy ( & attr -> val . ipv6prefix . prefix , ptr + 2 , len - 2 ) ; break ; } } list_add_tail ( & attr -> entry , & pack -> attrs ) ; } else log_ppp_warn ( ""radius:packet:unknownattributereceived(%i,%i)\\n"" , vendor ? vendor -> id : 0 , id ) ; ptr += len ; n -= 2 + len ; } * p = pack ; return 0 ; out_err : rad_packet_free ( pack ) ; return 1 ; } "," -> len ; if ( len < 0 ) { log_ppp_warn ( ""radius:packetinvalidvendorattributelenreceived\\n"" ) ; goto out_err ; } if ( 2 + len > n ) { log_ppp_warn ( ""radius:packet:toolongvendorattributereceived(%i,%i)\\n"" , id , len ) ; goto out_err ; } ",accel-ppp@accel-ppp/e9d369aa0054312b7633e964e9f7eb323f1f3d69,CVE-2020-28194,https://github.com/accel-ppp/accel-ppp/commit/e9d369aa0054312b7633e964e9f7eb323f1f3d69,2021-02-01T14:15Z 1338,CWE-000,"CWE-000 static int do_hidp_sock_ioctl ( struct socket * sock , unsigned int cmd , void __user * argp ) { struct hidp_connadd_req ca ; struct hidp_conndel_req cd ; struct hidp_connlist_req cl ; struct hidp_conninfo ci ; struct socket * csock ; struct socket * isock ; int err ; BT_DBG ( ""cmd%xarg%p"" , cmd , argp ) ; switch ( cmd ) { case HIDPCONNADD : if ( ! capable ( CAP_NET_ADMIN ) ) return - EPERM ; if ( copy_from_user ( & ca , argp , sizeof ( ca ) ) ) return - EFAULT ; csock = sockfd_lookup ( ca . ctrl_sock , & err ) ; if ( ! csock ) return err ; isock = sockfd_lookup ( ca . intr_sock , & err ) ; if ( ! isock ) { sockfd_put ( csock ) ; return err ; } err = hidp_connection_add ( & ca , csock , isock ) ; if ( ! err && copy_to_user ( argp , & ca , sizeof ( ca ) ) ) err = - EFAULT ; sockfd_put ( csock ) ; sockfd_put ( isock ) ; return err ; case HIDPCONNDEL : if ( ! capable ( CAP_NET_ADMIN ) ) return - EPERM ; if ( copy_from_user ( & cd , argp , sizeof ( cd ) ) ) return - EFAULT ; return hidp_connection_del ( & cd ) ; case HIDPGETCONNLIST : if ( copy_from_user ( & cl , argp , sizeof ( cl ) ) ) return - EFAULT ; if ( cl . cnum <= 0 ) return - EINVAL ; err = hidp_get_connlist ( & cl ) ; if ( ! err && copy_to_user ( argp , & cl , sizeof ( cl ) ) ) return - EFAULT ; return err ; case HIDPGETCONNINFO : if ( copy_from_user ( & ci , argp , sizeof ( ci ) ) ) return - EFAULT ; err = hidp_get_conninfo ( & ci ) ; if ( ! err && copy_to_user ( argp , & ci , sizeof ( ci ) ) ) return - EFAULT ; return err ; } return - EINVAL ; } "," err ; } ca . name [ sizeof ( ca . name ) - 1 ] = 0 ; ",torvalds@linux/a1616a5ac99ede5d605047a9012481ce7ff18b16,CVE-2019-11884,https://github.com/torvalds/linux/commit/a1616a5ac99ede5d605047a9012481ce7ff18b16,2019-05-10T22:29Z 1339,CWE-20,"CWE-20 static int unix_dgram_recvmsg ( struct kiocb * iocb , struct socket * sock , struct msghdr * msg , size_t size , int flags ) { struct sock_iocb * siocb = kiocb_to_siocb ( iocb ) ; struct scm_cookie tmp_scm ; struct sock * sk = sock -> sk ; struct unix_sock * u = unix_sk ( sk ) ; int noblock = flags & MSG_DONTWAIT ; struct sk_buff * skb ; int err ; int peeked , skip ; err = - EOPNOTSUPP ; if ( flags & MSG_OOB ) goto out ; msg -> msg_namelen = 0 ; err = mutex_lock_interruptible ( & u -> readlock ) ; if ( err ) { err = sock_intr_errno ( sock_rcvtimeo ( sk , noblock ) ) ; goto out ; } skip = sk_peek_offset ( sk , flags ) ; skb = __skb_recv_datagram ( sk , flags , & peeked , & skip , & err ) ; if ( ! skb ) { unix_state_lock ( sk ) ; if ( sk -> sk_type == SOCK_SEQPACKET && err == - EAGAIN && ( sk -> sk_shutdown & RCV_SHUTDOWN ) ) err = 0 ; unix_state_unlock ( sk ) ; goto out_unlock ; } wake_up_interruptible_sync_poll ( & u -> peer_wait , POLLOUT | POLLWRNORM | POLLWRBAND ) ; if ( msg -> msg_name ) unix_copy_addr ( msg , skb -> sk ) ; if ( size > skb -> len - skip ) size = skb -> len - skip ; else if ( size < skb -> len - skip ) msg -> msg_flags |= MSG_TRUNC ; err = skb_copy_datagram_iovec ( skb , skip , msg -> msg_iov , size ) ; if ( err ) goto out_free ; if ( sock_flag ( sk , SOCK_RCVTSTAMP ) ) __sock_recv_timestamp ( msg , sk , skb ) ; if ( ! siocb -> scm ) { siocb -> scm = & tmp_scm ; memset ( & tmp_scm , 0 , sizeof ( tmp_scm ) ) ; } scm_set_cred ( siocb -> scm , UNIXCB ( skb ) . pid , UNIXCB ( skb ) . uid , UNIXCB ( skb ) . gid ) ; unix_set_secdata ( siocb -> scm , skb ) ; if ( ! ( flags & MSG_PEEK ) ) { if ( UNIXCB ( skb ) . fp ) unix_detach_fds ( siocb -> scm , skb ) ; sk_peek_offset_bwd ( sk , skb -> len ) ; } else { sk_peek_offset_fwd ( sk , size ) ; if ( UNIXCB ( skb ) . fp ) siocb -> scm -> fp = scm_fp_dup ( UNIXCB ( skb ) . fp ) ; } err = ( flags & MSG_TRUNC ) ? skb -> len - skip : size ; scm_recv ( sock , msg , siocb -> scm , flags ) ; out_free : skb_free_datagram ( sk , skb ) ; out_unlock : mutex_unlock ( & u -> readlock ) ; out : return err ; } "," ) goto out ; err = ",torvalds@linux/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,CVE-2013-7271,https://github.com/torvalds/linux/commit/f3d3342602f8bcbf37d7c46641cb9bca7618eb1c,2014-01-06T16:55Z 1340,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 1341,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 1342,CWE-416,"CWE-416 static int snd_ctl_elem_write ( struct snd_card * card , struct snd_ctl_file * file , struct snd_ctl_elem_value * control ) { struct snd_kcontrol * kctl ; struct snd_kcontrol_volatile * vd ; unsigned int index_offset ; int result ; down_read ( & card -> controls_rwsem ) ; kctl = snd_ctl_find_id ( card , & control -> id ) ; if ( kctl == NULL ) { result = - ENOENT ; } else { index_offset = snd_ctl_get_ioff ( kctl , & control -> id ) ; vd = & kctl -> vd [ index_offset ] ; if ( ! ( vd -> access & SNDRV_CTL_ELEM_ACCESS_WRITE ) || kctl -> put == NULL || ( file && vd -> owner && vd -> owner != file ) ) { result = - EPERM ; } else { snd_ctl_build_ioff ( & control -> id , kctl , index_offset ) ; result = kctl -> put ( kctl , control ) ; } if ( result > 0 ) { up_read ( & card -> controls_rwsem ) ; snd_ctl_notify ( card , SNDRV_CTL_EVENT_MASK_VALUE , & control -> id ) ; return 0 ; } } up_read ( & card -> controls_rwsem ) ; return result ; } "," 0 ) { struct snd_ctl_elem_id id = control -> id ; , SNDRV_CTL_EVENT_MASK_VALUE , & id ) ; ",torvalds@linux/fd9f26e4eca5d08a27d12c0933fceef76ed9663d,CVE-2014-4653,https://github.com/torvalds/linux/commit/fd9f26e4eca5d08a27d12c0933fceef76ed9663d,2014-07-03T04:22Z 1343,CWE-190,"CWE-190 static int burl_normalize_2F_to_slash_fix ( buffer * b , int qs , int i ) { char * const s = b -> ptr ; const int blen = ( int ) buffer_string_length ( b ) ; const int used = qs < 0 ? blen : qs ; int j = i ; for ( ; i < used ; ++ i , ++ j ) { s [ j ] = s [ i ] ; if ( s [ i ] == '%' && s [ i + 1 ] == '2' && s [ i + 2 ] == 'F' ) { s [ j ] = '/' ; i += 2 ; } } if ( qs >= 0 ) { memmove ( s + j , s + qs , blen - qs ) ; j += blen - qs ; } buffer_string_set_length ( b , j ) ; return qs ; } "," 0 ) { const int qslen = blen - qs ; + qs , ( size_t ) qslen ) ; qs = j ; j += ; j += qslen ; } buffer_string_set_length ",lighttpd@lighttpd1.4/32120d5b8b3203fc21ccb9eafb0eaf824bb59354,CVE-2019-11072,https://github.com/lighttpd/lighttpd1.4/commit/32120d5b8b3203fc21ccb9eafb0eaf824bb59354,2019-04-10T22:29Z 1344,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 1345,CWE-416,"CWE-416 static zend_always_inline int process_nested_data ( UNSERIALIZE_PARAMETER , HashTable * ht , zend_long elements , int objprops ) { while ( elements -- > 0 ) { zval key , * data , d , * old_data ; zend_ulong idx ; ZVAL_UNDEF ( & key ) ; if ( ! php_var_unserialize_internal ( & key , p , max , NULL , classes ) ) { zval_dtor ( & key ) ; return 0 ; } data = NULL ; ZVAL_UNDEF ( & d ) ; if ( ! objprops ) { if ( Z_TYPE ( key ) == IS_LONG ) { idx = Z_LVAL ( key ) ; numeric_key : if ( UNEXPECTED ( ( old_data = zend_hash_index_find ( ht , idx ) ) != NULL ) ) { var_push_dtor ( var_hash , old_data ) ; data = zend_hash_index_update ( ht , idx , & d ) ; } else { data = zend_hash_index_add_new ( ht , idx , & d ) ; } } else if ( Z_TYPE ( key ) == IS_STRING ) { if ( UNEXPECTED ( ZEND_HANDLE_NUMERIC ( Z_STR ( key ) , idx ) ) ) { goto numeric_key ; } if ( UNEXPECTED ( ( old_data = zend_hash_find ( ht , Z_STR ( key ) ) ) != NULL ) ) { var_push_dtor ( var_hash , old_data ) ; data = zend_hash_update ( ht , Z_STR ( key ) , & d ) ; } else { data = zend_hash_add_new ( ht , Z_STR ( key ) , & d ) ; } } else { zval_dtor ( & key ) ; return 0 ; } } else { if ( EXPECTED ( Z_TYPE ( key ) == IS_STRING ) ) { string_key : if ( ( old_data = zend_hash_find ( ht , Z_STR ( key ) ) ) != NULL ) { if ( Z_TYPE_P ( old_data ) == IS_INDIRECT ) { old_data = Z_INDIRECT_P ( old_data ) ; } var_push_dtor ( var_hash , old_data ) ; data = zend_hash_update_ind ( ht , Z_STR ( key ) , & d ) ; } else { data = zend_hash_add_new ( ht , Z_STR ( key ) , & d ) ; } } else if ( Z_TYPE ( key ) == IS_LONG ) { convert_to_string ( & key ) ; goto string_key ; } else { zval_dtor ( & key ) ; return 0 ; } } if ( ! php_var_unserialize_internal ( data , p , max , var_hash , classes ) ) { zval_dtor ( & key ) ; return 0 ; } if ( UNEXPECTED ( Z_ISUNDEF_P ( data ) ) ) { if ( Z_TYPE ( key ) == IS_LONG ) { zend_hash_index_del ( ht , Z_LVAL ( key ) ) ; } else { zend_hash_del_ind ( ht , Z_STR ( key ) ) ; } } else { var_push_dtor ( var_hash , data ) ; } zval_dtor ( & key ) ; if ( elements && * ( * p - 1 ) != ';' && * ( * p - 1 ) != '}' ) { ( * p ) -- ; return 0 ; } } return 1 ; } "," 0 ; } var_push_dtor ( var_hash data ) ; zval_dtor ( & ",php@php-src/1a23ebc1fff59bf480ca92963b36eba5c1b904c4,CVE-2017-12932,https://github.com/php/php-src/commit/1a23ebc1fff59bf480ca92963b36eba5c1b904c4,2017-08-18T03:29Z 1346,CWE-404,"CWE-404 int install_process_keyring_to_cred ( struct cred * new ) { struct key * keyring ; if ( new -> process_keyring ) return - EEXIST ; keyring = keyring_alloc ( ""_pid"" , 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 -> process_keyring = keyring ; return 0 ; } "," process_keyring ) return 0 ; keyring = ",torvalds@linux/c9f838d104fed6f2f61d68164712e3204bf5271b,CVE-2017-7472,https://github.com/torvalds/linux/commit/c9f838d104fed6f2f61d68164712e3204bf5271b,2017-05-11T19:29Z 1347,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 1348,CWE-119,"CWE-119 void vp9_idct32x32_add ( const int16_t * input , uint8_t * dest , int stride , int eob ) { if ( eob == 1 ) vp9_idct32x32_1_add ( input , dest , stride ) ; else if ( eob <= 34 ) vp9_idct32x32_34_add ( input , dest , stride ) ; else vp9_idct32x32_1024_add ( input , dest , stride ) ; } "," vp9_idct32x32_add ( const tran_low_t * input , == 1 ) vpx_idct32x32_1_add ( input , <= 34 ) vpx_idct32x32_34_add ( input , ) ; else vpx_idct32x32_1024_add ( input , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1349,CWE-264,"CWE-264 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 1350,CWE-200,"CWE-200 static void print_bpf_insn ( struct bpf_insn * insn ) { u8 class = BPF_CLASS ( insn -> code ) ; if ( class == BPF_ALU || class == BPF_ALU64 ) { if ( BPF_SRC ( insn -> code ) == BPF_X ) verbose ( ""(%02x)%sr%d%s%sr%d\\n"" , insn -> code , class == BPF_ALU ? ""(u32)"" : """" , insn -> dst_reg , bpf_alu_string [ BPF_OP ( insn -> code ) >> 4 ] , class == BPF_ALU ? ""(u32)"" : """" , insn -> src_reg ) ; else verbose ( ""(%02x)%sr%d%s%s%d\\n"" , insn -> code , class == BPF_ALU ? ""(u32)"" : """" , insn -> dst_reg , bpf_alu_string [ BPF_OP ( insn -> code ) >> 4 ] , class == BPF_ALU ? ""(u32)"" : """" , insn -> imm ) ; } else if ( class == BPF_STX ) { if ( BPF_MODE ( insn -> code ) == BPF_MEM ) verbose ( ""(%02x)*(%s*)(r%d%+d)=r%d\\n"" , insn -> code , bpf_ldst_string [ BPF_SIZE ( insn -> code ) >> 3 ] , insn -> dst_reg , insn -> off , insn -> src_reg ) ; else if ( BPF_MODE ( insn -> code ) == BPF_XADD ) verbose ( ""(%02x)lock*(%s*)(r%d%+d)+=r%d\\n"" , insn -> code , bpf_ldst_string [ BPF_SIZE ( insn -> code ) >> 3 ] , insn -> dst_reg , insn -> off , insn -> src_reg ) ; else verbose ( ""BUG_%02x\\n"" , insn -> code ) ; } else if ( class == BPF_ST ) { if ( BPF_MODE ( insn -> code ) != BPF_MEM ) { verbose ( ""BUG_st_%02x\\n"" , insn -> code ) ; return ; } verbose ( ""(%02x)*(%s*)(r%d%+d)=%d\\n"" , insn -> code , bpf_ldst_string [ BPF_SIZE ( insn -> code ) >> 3 ] , insn -> dst_reg , insn -> off , insn -> imm ) ; } else if ( class == BPF_LDX ) { if ( BPF_MODE ( insn -> code ) != BPF_MEM ) { verbose ( ""BUG_ldx_%02x\\n"" , insn -> code ) ; return ; } verbose ( ""(%02x)r%d=*(%s*)(r%d%+d)\\n"" , insn -> code , insn -> dst_reg , bpf_ldst_string [ BPF_SIZE ( insn -> code ) >> 3 ] , insn -> src_reg , insn -> off ) ; } else if ( class == BPF_LD ) { if ( BPF_MODE ( insn -> code ) == BPF_ABS ) { verbose ( ""(%02x)r0=*(%s*)skb[%d]\\n"" , insn -> code , bpf_ldst_string [ BPF_SIZE ( insn -> code ) >> 3 ] , insn -> imm ) ; } else if ( BPF_MODE ( insn -> code ) == BPF_IND ) { verbose ( ""(%02x)r0=*(%s*)skb[r%d+%d]\\n"" , insn -> code , bpf_ldst_string [ BPF_SIZE ( insn -> code ) >> 3 ] , insn -> src_reg , insn -> imm ) ; } else if ( BPF_MODE ( insn -> code ) == BPF_IMM ) { verbose ( ""(%02x)r%d=0x%x\\n"" , insn -> code , insn -> dst_reg , insn -> imm ) ; } else { verbose ( ""BUG_ld_%02x\\n"" , insn -> code ) ; return ; } } else if ( class == BPF_JMP ) { u8 opcode = BPF_OP ( insn -> code ) ; if ( opcode == BPF_CALL ) { verbose ( ""(%02x)call%s#%d\\n"" , insn -> code , func_id_name ( insn -> imm ) , insn -> imm ) ; } else if ( insn -> code == ( BPF_JMP | BPF_JA ) ) { verbose ( ""(%02x)gotopc%+d\\n"" , insn -> code , insn -> off ) ; } else if ( insn -> code == ( BPF_JMP | BPF_EXIT ) ) { verbose ( ""(%02x)exit\\n"" , insn -> code ) ; } else if ( BPF_SRC ( insn -> code ) == BPF_X ) { verbose ( ""(%02x)ifr%d%sr%dgotopc%+d\\n"" , insn -> code , insn -> dst_reg , bpf_jmp_string [ BPF_OP ( insn -> code ) >> 4 ] , insn -> src_reg , insn -> off ) ; } else { verbose ( ""(%02x)ifr%d%s0x%xgotopc%+d\\n"" , insn -> code , insn -> dst_reg , bpf_jmp_string [ BPF_OP ( insn -> code ) >> 4 ] , insn -> imm , insn -> off ) ; } } else { verbose ( ""(%02x)%s\\n"" , insn -> code , bpf_class_string [ class ] ) ; } } "," void print_bpf_insn ( const struct bpf_verifier_env * env , const ) == BPF_IMM && BPF_SIZE ( insn -> code ) == BPF_DW ) { u64 imm = ( ( u64 ) ( insn + 1 ) -> imm << 32 ) | ( u32 ) insn -> imm ; bool map_ptr = insn -> src_reg == BPF_PSEUDO_MAP_FD ; if ( map_ptr && ! env -> allow_ptr_leaks ) imm = 0 ; verbose ( ""(%02x)r%d=0x%llx\\n"" , insn -> code , insn -> dst_reg -> dst_reg , ( unsigned long long ) imm ) ; ",torvalds@linux/0d0e57697f162da4aa218b5feafe614fb666db07,CVE-2017-9150,https://github.com/torvalds/linux/commit/0d0e57697f162da4aa218b5feafe614fb666db07,2017-05-22T22:29Z 1351,CWE-000,"CWE-000 static int irda_create ( struct net * net , struct socket * sock , int protocol , int kern ) { struct sock * sk ; struct irda_sock * self ; if ( net != & init_net ) return - EAFNOSUPPORT ; switch ( sock -> type ) { case SOCK_STREAM : case SOCK_SEQPACKET : case SOCK_DGRAM : break ; default : return - ESOCKTNOSUPPORT ; } sk = sk_alloc ( net , PF_IRDA , GFP_KERNEL , & irda_proto , kern ) ; if ( sk == NULL ) return - ENOMEM ; self = irda_sk ( sk ) ; pr_debug ( ""%s():selfis%p\\n"" , __func__ , self ) ; init_waitqueue_head ( & self -> query_wait ) ; switch ( sock -> type ) { case SOCK_STREAM : sock -> ops = & irda_stream_ops ; self -> max_sdu_size_rx = TTP_SAR_DISABLE ; break ; case SOCK_SEQPACKET : sock -> ops = & irda_seqpacket_ops ; self -> max_sdu_size_rx = TTP_SAR_UNBOUND ; break ; case SOCK_DGRAM : switch ( protocol ) { # ifdef CONFIG_IRDA_ULTRA case IRDAPROTO_ULTRA : sock -> ops = & irda_ultra_ops ; self -> max_data_size = ULTRA_MAX_DATA - LMP_PID_HEADER ; self -> max_header_size = IRDA_MAX_HEADER + LMP_PID_HEADER ; break ; # endif case IRDAPROTO_UNITDATA : sock -> ops = & irda_dgram_ops ; self -> max_sdu_size_rx = TTP_SAR_UNBOUND ; break ; default : sk_free ( sk ) ; return - ESOCKTNOSUPPORT ; } break ; default : sk_free ( sk ) ; return - ESOCKTNOSUPPORT ; } sock_init_data ( sock , sk ) ; sk -> sk_family = PF_IRDA ; sk -> sk_protocol = protocol ; self -> ckey = irlmp_register_client ( 0 , NULL , NULL , NULL ) ; self -> mask . word = 0xffff ; self -> rx_flow = self -> tx_flow = FLOW_START ; self -> nslots = DISCOVERY_DEFAULT_SLOTS ; self -> daddr = DEV_ADDR_ANY ; self -> saddr = 0x0 ; 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 1352,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#diff-c8b4b355f9b5c06d585b23138e1c185f,2016-11-22T19:59Z 1353,CWE-399,"CWE-399 static void vmx_set_constant_host_state ( struct vcpu_vmx * vmx ) { u32 low32 , high32 ; unsigned long tmpl ; struct desc_ptr dt ; vmcs_writel ( HOST_CR0 , read_cr0 ( ) & ~ X86_CR0_TS ) ; vmcs_writel ( HOST_CR4 , read_cr4 ( ) ) ; vmcs_writel ( HOST_CR3 , read_cr3 ( ) ) ; vmcs_write16 ( HOST_CS_SELECTOR , __KERNEL_CS ) ; # ifdef CONFIG_X86_64 vmcs_write16 ( HOST_DS_SELECTOR , 0 ) ; vmcs_write16 ( HOST_ES_SELECTOR , 0 ) ; # else vmcs_write16 ( HOST_DS_SELECTOR , __KERNEL_DS ) ; vmcs_write16 ( HOST_ES_SELECTOR , __KERNEL_DS ) ; # endif vmcs_write16 ( HOST_SS_SELECTOR , __KERNEL_DS ) ; vmcs_write16 ( HOST_TR_SELECTOR , GDT_ENTRY_TSS * 8 ) ; native_store_idt ( & dt ) ; vmcs_writel ( HOST_IDTR_BASE , dt . address ) ; vmx -> host_idt_base = dt . address ; vmcs_writel ( HOST_RIP , vmx_return ) ; rdmsr ( MSR_IA32_SYSENTER_CS , low32 , high32 ) ; vmcs_write32 ( HOST_IA32_SYSENTER_CS , low32 ) ; rdmsrl ( MSR_IA32_SYSENTER_EIP , tmpl ) ; vmcs_writel ( HOST_IA32_SYSENTER_EIP , tmpl ) ; if ( vmcs_config . vmexit_ctrl & VM_EXIT_LOAD_IA32_PAT ) { rdmsr ( MSR_IA32_CR_PAT , low32 , high32 ) ; vmcs_write64 ( HOST_IA32_PAT , low32 | ( ( u64 ) high32 << 32 ) ) ; } } "," desc_ptr dt ; unsigned long cr4 ; ; vmcs_writel ( HOST_CR3 , read_cr3 ( ) ) ; cr4 = read_cr4 ( ) ; vmcs_writel ( HOST_CR4 , cr4 ) ; vmx -> host_state . vmcs_host_cr4 = cr4 ; vmcs_write16 ( ",torvalds@linux/d974baa398f34393db76be45f7d4d04fbdbb4a0a,CVE-2014-3690,https://github.com/torvalds/linux/commit/d974baa398f34393db76be45f7d4d04fbdbb4a0a,2014-11-10T11:55Z 1354,CWE-787,"CWE-787 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-8800,https://github.com/rdesktop/rdesktop/commit/4dca546d04321a610c1835010b5dad85163b65e1,2019-02-05T20:29Z 1355,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@libusbmuxd/4397b3376dc4e4cb1c991d0aed61ce6482614196,CVE-2016-5104,https://github.com/libimobiledevice/libusbmuxd/commit/4397b3376dc4e4cb1c991d0aed61ce6482614196,2016-06-13T14:59Z 1356,CWE-772,"CWE-772 int virtio_gpu_object_create ( struct virtio_gpu_device * vgdev , unsigned long size , bool kernel , bool pinned , struct virtio_gpu_object * * bo_ptr ) { struct virtio_gpu_object * bo ; enum ttm_bo_type type ; size_t acc_size ; int ret ; if ( kernel ) type = ttm_bo_type_kernel ; else type = ttm_bo_type_device ; * bo_ptr = NULL ; acc_size = ttm_bo_dma_acc_size ( & vgdev -> mman . bdev , size , sizeof ( struct virtio_gpu_object ) ) ; bo = kzalloc ( sizeof ( struct virtio_gpu_object ) , GFP_KERNEL ) ; if ( bo == NULL ) return - ENOMEM ; size = roundup ( size , PAGE_SIZE ) ; ret = drm_gem_object_init ( vgdev -> ddev , & bo -> gem_base , size ) ; if ( ret != 0 ) return ret ; bo -> dumb = false ; virtio_gpu_init_ttm_placement ( bo , pinned ) ; ret = ttm_bo_init ( & vgdev -> mman . bdev , & bo -> tbo , size , type , & bo -> placement , 0 , ! kernel , NULL , acc_size , NULL , NULL , & virtio_gpu_ttm_bo_destroy ) ; if ( ret != 0 ) return ret ; * bo_ptr = bo ; return 0 ; } "," != 0 ) { kfree ( bo ) ; return ret ; } bo -> dumb ",torvalds@linux/385aee965b4e4c36551c362a334378d2985b722a,CVE-2017-10810,https://github.com/torvalds/linux/commit/385aee965b4e4c36551c362a334378d2985b722a,2017-07-04T20:29Z 1357,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 1358,CWE-20,"CWE-20 error_t nicSendPacket ( NetInterface * interface , const NetBuffer * buffer , size_t offset , NetTxAncillary * ancillary ) { error_t error ; bool_t status ; netContext . entropy += netGetSystemTickCount ( ) ; # if ( TRACE_LEVEL >= TRACE_LEVEL_DEBUG ) size_t length = netBufferGetLength ( buffer ) - offset ; TRACE_DEBUG ( ""Sendingpacket(%"" PRIuSIZE ""bytes)...\\r\\n"" , length ) ; TRACE_DEBUG_NET_BUFFER ( """" , buffer , offset , length ) ; # endif if ( interface -> configured && interface -> nicDriver != NULL ) { if ( interface -> nicDriver -> type == NIC_TYPE_LOOPBACK ) { status = TRUE ; } else { status = osWaitForEvent ( & interface -> nicTxEvent , NIC_MAX_BLOCKING_TIME ) ; } if ( status ) { interface -> nicDriver -> disableIrq ( interface ) ; error = interface -> nicDriver -> sendPacket ( interface , buffer , offset , ancillary ) ; if ( interface -> configured ) { interface -> nicDriver -> enableIrq ( interface ) ; } } else { error = NO_ERROR ; } } else { error = ERROR_INVALID_INTERFACE ; } return error ; } "," bool_t status ; # if ( TRACE_LEVEL >= TRACE_LEVEL_DEBUG ) size_t length = netBufferGetLength ( buffer ) - offset ; TRACE_DEBUG ( ""Sendingpacket(%"" PRIuSIZE ""bytes)...\\r\\n"" , length ) ; TRACE_DEBUG_NET_BUFFER ( """" , buffer , offset , length ) ; # endif ( ) ; if ( interface ",Oryx-Embedded@CycloneTCP/de5336016edbe1e90327d0ed1cba5c4e49114366,CVE-2021-26788,https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366,2021-03-08T13:15Z 1359,CWE-200,"CWE-200 static int cdrom_ioctl_drive_status ( struct cdrom_device_info * cdi , unsigned long arg ) { cd_dbg ( CD_DO_IOCTL , ""enteringCDROM_DRIVE_STATUS\\n"" ) ; if ( ! ( cdi -> ops -> capability & CDC_DRIVE_STATUS ) ) return - ENOSYS ; if ( ! CDROM_CAN ( CDC_SELECT_DISC ) || ( arg == CDSL_CURRENT || arg == CDSL_NONE ) ) return cdi -> ops -> drive_status ( cdi , CDSL_CURRENT ) ; if ( ( ( int ) arg >= cdi -> capacity ) ) return - EINVAL ; return cdrom_slot_status ( cdi , arg ) ; } "," ; if ( arg >= cdi cdi -> capacity ) return - ",torvalds@linux/8f3fafc9c2f0ece10832c25f7ffcb07c97a32ad4,CVE-2018-16658,https://github.com/torvalds/linux/commit/8f3fafc9c2f0ece10832c25f7ffcb07c97a32ad4,2018-09-07T14:29Z 1360,CWE-264,"CWE-264 static unsigned long randomize_stack_top ( unsigned long stack_top ) { unsigned int random_variable = 0 ; if ( ( current -> flags & PF_RANDOMIZE ) && ! ( current -> personality & ADDR_NO_RANDOMIZE ) ) { random_variable = get_random_int ( ) & STACK_RND_MASK ; random_variable <<= PAGE_SHIFT ; } # ifdef CONFIG_STACK_GROWSUP return PAGE_ALIGN ( stack_top ) + random_variable ; # else return PAGE_ALIGN ( stack_top ) - random_variable ; # endif } "," ) { unsigned long random_variable = 0 { random_variable = ( unsigned long ) get_random_int ( ) ; random_variable &= STACK_RND_MASK ; random_variable ",torvalds@linux/4e7c22d447bb6d7e37bfe39ff658486ae78e8d77,CVE-2015-1593,https://github.com/torvalds/linux/commit/4e7c22d447bb6d7e37bfe39ff658486ae78e8d77,2015-03-16T10:59Z 1361,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 1362,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 1363,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 1364,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 1365,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 1366,CWE-284,"CWE-284 int btsock_thread_wakeup ( int h ) { if ( h < 0 || h >= MAX_THREAD ) { APPL_TRACE_ERROR ( ""invalidbtthreadhandle:%d"" , h ) ; return FALSE ; } if ( ts [ h ] . cmd_fdw == - 1 ) { APPL_TRACE_ERROR ( ""threadhandle:%d,cmdsocketisnotcreated"" , h ) ; return FALSE ; } sock_cmd_t cmd = { CMD_WAKEUP , 0 , 0 , 0 , 0 } ; return send ( ts [ h ] . cmd_fdw , & cmd , sizeof ( cmd ) , 0 ) == sizeof ( cmd ) ; } "," } ; return TEMP_FAILURE_RETRY ( , 0 ) ) ",system@bt/472271b153c5dc53c28beac55480a8d8434b2d5c,CVE-2016-3839,https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c,2016-08-05T20:59Z 1367,CWE-264,"CWE-264 int validate_camera_metadata_structure ( const camera_metadata_t * metadata , const size_t * expected_size ) { if ( metadata == NULL ) { ALOGE ( ""%s:metadataisnull!"" , __FUNCTION__ ) ; return ERROR ; } { static const struct { const char * name ; size_t alignment ; } alignments [ ] = { { . name = ""camera_metadata"" , . alignment = METADATA_ALIGNMENT } , { . name = ""camera_metadata_buffer_entry"" , . alignment = ENTRY_ALIGNMENT } , { . name = ""camera_metadata_data"" , . alignment = DATA_ALIGNMENT } , } ; for ( size_t i = 0 ; i < sizeof ( alignments ) / sizeof ( alignments [ 0 ] ) ; ++ i ) { uintptr_t aligned_ptr = ALIGN_TO ( metadata , alignments [ i ] . alignment ) ; if ( ( uintptr_t ) metadata != aligned_ptr ) { ALOGE ( ""%s:Metadatapointerisnotaligned(actual%p,"" ""expected%p)totype%s"" , __FUNCTION__ , metadata , ( void * ) aligned_ptr , alignments [ i ] . name ) ; return ERROR ; } } } if ( expected_size != NULL && metadata -> size > * expected_size ) { ALOGE ( ""%s:Metadatasize(%"" PRIu32 "")shouldbe<=expectedsize(%zu)"" , __FUNCTION__ , metadata -> size , * expected_size ) ; return ERROR ; } if ( metadata -> entry_count > metadata -> entry_capacity ) { ALOGE ( ""%s:Entrycount(%"" PRIu32 "")shouldbe<=entrycapacity"" ""(%"" PRIu32 "")"" , __FUNCTION__ , metadata -> entry_count , metadata -> entry_capacity ) ; return ERROR ; } const metadata_uptrdiff_t entries_end = metadata -> entries_start + metadata -> entry_capacity ; if ( entries_end < metadata -> entries_start || entries_end > metadata -> data_start ) { ALOGE ( ""%s:Entrystart+capacity(%"" PRIu32 "")shouldbe<=datastart"" ""(%"" PRIu32 "")"" , __FUNCTION__ , ( metadata -> entries_start + metadata -> entry_capacity ) , metadata -> data_start ) ; return ERROR ; } const metadata_uptrdiff_t data_end = metadata -> data_start + metadata -> data_capacity ; if ( data_end < metadata -> data_start || data_end > metadata -> size ) { ALOGE ( ""%s:Datastart+capacity(%"" PRIu32 "")shouldbe<=totalsize"" ""(%"" PRIu32 "")"" , __FUNCTION__ , ( metadata -> data_start + metadata -> data_capacity ) , metadata -> size ) ; return ERROR ; } const metadata_size_t entry_count = metadata -> entry_count ; camera_metadata_buffer_entry_t * entries = get_entries ( metadata ) ; for ( size_t i = 0 ; i < entry_count ; ++ i ) { if ( ( uintptr_t ) & entries [ i ] != ALIGN_TO ( & entries [ i ] , ENTRY_ALIGNMENT ) ) { ALOGE ( ""%s:Entryindex%zuhadbadalignment(address%p),"" ""expectedalignment%zu"" , __FUNCTION__ , i , & entries [ i ] , ENTRY_ALIGNMENT ) ; return ERROR ; } camera_metadata_buffer_entry_t entry = entries [ i ] ; if ( entry . type >= NUM_TYPES ) { ALOGE ( ""%s:Entryindex%zuhadabadtype%d"" , __FUNCTION__ , i , entry . type ) ; return ERROR ; } uint32_t tag_section = entry . tag >> 16 ; int tag_type = get_camera_metadata_tag_type ( entry . tag ) ; if ( tag_type != ( int ) entry . type && tag_section < VENDOR_SECTION ) { ALOGE ( ""%s:Entryindex%zuhadtagtype%d,butthetypewas%d"" , __FUNCTION__ , i , tag_type , entry . type ) ; return ERROR ; } size_t data_size ; if ( validate_and_calculate_camera_metadata_entry_data_size ( & data_size , entry . type , entry . count ) != OK ) { ALOGE ( ""%s:Entrydatasizeisinvalid.type:%ucount:%u"" , __FUNCTION__ , entry . type , entry . count ) ; return ERROR ; } if ( data_size != 0 ) { camera_metadata_data_t * data = ( camera_metadata_data_t * ) ( get_data ( metadata ) + entry . data . offset ) ; if ( ( uintptr_t ) data != ALIGN_TO ( data , DATA_ALIGNMENT ) ) { ALOGE ( ""%s:Entryindex%zuhadbaddataalignment(address%p),"" ""expectedalign%zu,(tagname%s,datasize%zu)"" , __FUNCTION__ , i , data , DATA_ALIGNMENT , get_camera_metadata_tag_name ( entry . tag ) ? : ""unknown"" , data_size ) ; return ERROR ; } size_t data_entry_end = entry . data . offset + data_size ; if ( data_entry_end < entry . data . offset || data_entry_end > metadata -> data_capacity ) { ALOGE ( ""%s:Entryindex%zudataends(%zu)beyondthecapacity"" ""%"" PRIu32 , __FUNCTION__ , i , data_entry_end , metadata -> data_capacity ) ; return ERROR ; } } else if ( entry . count == 0 ) { if ( entry . data . offset != 0 ) { ALOGE ( ""%s:Entryindex%zuhad0items,butoffsetwasnon-0"" ""(%"" PRIu32 ""),tagname:%s"" , __FUNCTION__ , i , entry . data . offset , get_camera_metadata_tag_name ( entry . tag ) ? : ""unknown"" ) ; return ERROR ; } } } return OK ; } "," ERROR ; } if ( metadata -> data_count > metadata -> data_capacity ) { ALOGE ( ""%s:Datacount(%"" PRIu32 "")shouldbe<=datacapacity"" ""(%"" PRIu32 "")"" , __FUNCTION__ , metadata -> data_count , metadata -> data_capacity ) ; android_errorWriteLog ( SN_EVENT_LOG_ID , ""30591838"" ) ; return ERROR ; } ",system@media/e9e44f797742f52996ebf307740dad58c28fd9b5,CVE-2016-3915,https://android.googlesource.com/platform/system/media/+/e9e44f797742f52996ebf307740dad58c28fd9b5,2016-10-10T10:59Z 1368,CWE-119,"CWE-119 static int compare_img ( const vpx_image_t * const img1 , const vpx_image_t * const img2 ) { const uint32_t c_w = ( img1 -> d_w + img1 -> x_chroma_shift ) >> img1 -> x_chroma_shift ; const uint32_t c_h = ( img1 -> d_h + img1 -> y_chroma_shift ) >> img1 -> y_chroma_shift ; uint32_t i ; int match = 1 ; match &= ( img1 -> fmt == img2 -> fmt ) ; match &= ( img1 -> d_w == img2 -> d_w ) ; match &= ( img1 -> d_h == img2 -> d_h ) ; for ( i = 0 ; i < img1 -> d_h ; ++ i ) match &= ( memcmp ( img1 -> planes [ VPX_PLANE_Y ] + i * img1 -> stride [ VPX_PLANE_Y ] , img2 -> planes [ VPX_PLANE_Y ] + i * img2 -> stride [ VPX_PLANE_Y ] , img1 -> d_w ) == 0 ) ; for ( i = 0 ; i < c_h ; ++ i ) match &= ( memcmp ( img1 -> planes [ VPX_PLANE_U ] + i * img1 -> stride [ VPX_PLANE_U ] , img2 -> planes [ VPX_PLANE_U ] + i * img2 -> stride [ VPX_PLANE_U ] , c_w ) == 0 ) ; for ( i = 0 ; i < c_h ; ++ i ) match &= ( memcmp ( img1 -> planes [ VPX_PLANE_V ] + i * img1 -> stride [ VPX_PLANE_V ] , img2 -> planes [ VPX_PLANE_V ] + i * img2 -> stride [ VPX_PLANE_V ] , c_w ) == 0 ) ; return match ; } "," img2 ) { uint32_t l_w = img1 -> d_w ; uint32_t c_w = d_h ) ; # if CONFIG_VP9_HIGHBITDEPTH if ( img1 -> fmt & VPX_IMG_FMT_HIGHBITDEPTH ) { l_w *= 2 ; c_w *= 2 ; } # endif VPX_PLANE_Y ] , l_w ) == 0 ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1369,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 1370,CWE-189,"CWE-189 static int sysMapBlockFile ( FILE * mapf , MemMapping * pMap ) { char block_dev [ PATH_MAX + 1 ] ; size_t size ; unsigned int blksize ; unsigned int blocks ; unsigned int range_count ; unsigned int i ; if ( fgets ( block_dev , sizeof ( block_dev ) , mapf ) == NULL ) { LOGW ( ""failedtoreadblockdevicefromheader\\n"" ) ; return - 1 ; } for ( i = 0 ; i < sizeof ( block_dev ) ; ++ i ) { if ( block_dev [ i ] == '\\n' ) { block_dev [ i ] = 0 ; break ; } } if ( fscanf ( mapf , ""%zu%u\\n%u\\n"" , & size , & blksize , & range_count ) != 3 ) { LOGW ( ""failedtoparseblockmapheader\\n"" ) ; return - 1 ; } blocks = ( ( size - 1 ) / blksize ) + 1 ; pMap -> range_count = range_count ; pMap -> ranges = malloc ( range_count * sizeof ( MappedRange ) ) ; memset ( pMap -> ranges , 0 , range_count * sizeof ( MappedRange ) ) ; unsigned char * reserve ; reserve = mmap64 ( NULL , blocks * blksize , PROT_NONE , MAP_PRIVATE | MAP_ANON , - 1 , 0 ) ; if ( reserve == MAP_FAILED ) { LOGW ( ""failedtoreserveaddressspace:%s\\n"" , strerror ( errno ) ) ; return - 1 ; } pMap -> ranges [ range_count - 1 ] . addr = reserve ; pMap -> ranges [ range_count - 1 ] . length = blocks * blksize ; int fd = open ( block_dev , O_RDONLY ) ; if ( fd < 0 ) { LOGW ( ""failedtoopenblockdevice%s:%s\\n"" , block_dev , strerror ( errno ) ) ; return - 1 ; } unsigned char * next = reserve ; for ( i = 0 ; i < range_count ; ++ i ) { int start , end ; if ( fscanf ( mapf , ""%d%d\\n"" , & start , & end ) != 2 ) { LOGW ( ""failedtoparserange%dinblockmap\\n"" , i ) ; return - 1 ; } void * addr = mmap64 ( next , ( end - start ) * blksize , PROT_READ , MAP_PRIVATE | MAP_FIXED , fd , ( ( off64_t ) start ) * blksize ) ; if ( addr == MAP_FAILED ) { LOGW ( ""failedtomapblock%d:%s\\n"" , i , strerror ( errno ) ) ; return - 1 ; } pMap -> ranges [ i ] . addr = addr ; pMap -> ranges [ i ] . length = ( end - start ) * blksize ; next += pMap -> ranges [ i ] . length ; } pMap -> addr = reserve ; pMap -> length = size ; LOGI ( ""mmapped%dranges\\n"" , range_count ) ; return 0 ; } "," int blksize ; size_t blocks ; unsigned 1 ; } if ( blksize != 0 ) { + 1 ; } if ( size == 0 || blksize == 0 || blocks > SIZE_MAX / blksize || range_count == 0 ) { LOGE ( ""invaliddatainblockmapfile:size%zu,blksize%u,range_count%u\\n"" , size , blksize , range_count ) ; return - 1 ; } -> ranges = calloc ( range_count , sizeof ( MappedRange ) ) ; if ( pMap -> pMap -> ranges == NULL ) { LOGE ( ""calloc(%u,%zu)failed:%s\\n"" , range_count , sizeof ( MappedRange ( MappedRange ) , strerror ( errno ) ) ; return - 1 ; } unsigned char * ) ) ; free ( pMap -> ranges ) ; return - 1 ; } int fd = open ( block_dev , O_RDONLY ) ; if ( fd < 0 ) { LOGW ( ""failedtoopenblockdevice%s:%s\\n"" , block_dev , strerror ( errno ) ) ; munmap ( reserve , blocks * blksize ) ; free ( pMap -> ranges ) ; return - 1 ; } unsigned char * next = reserve ; size_t remaining_size = blocks * blksize ; bool success = true ; for ( i = 0 ; i < range_count ; ++ i ) { size_t start , end ; if ( fscanf ( mapf , ""%zu%zu\\n"" , & start , & end ) != 2 ) { LOGW ( ""failedtoparserange%dinblockmap\\n"" , i ) ; success = false ; break ; } size_t length = ( end - start ) * blksize ; if ( end <= start || ( end - start ) > SIZE_MAX / blksize || length > remaining_size ) { LOGE ( ""unexpectedrangeinblockmap:%zu%zu\\n"" , start , end ) ; success = false ; break ; } void * addr = mmap64 ( next , length , PROT_READ , MAP_PRIVATE | MAP_FIXED , fd , ( ( off64_t ) start ) * blksize ) ; if ( addr == MAP_FAILED ) { LOGW ( ""failedtomapblock%d:%s\\n"" , i , strerror ( errno ) ) ; success = false ; break -> ranges [ i ] . addr . addr = addr ; pMap -> -> ranges [ i ] . length . length = length ; next += ; next += length ; remaining_size -= length ; } if ( success && remaining_size != 0 ) { LOGE ( ""rangesinblockmapareinvalid:remaining_size=%zu\\n"" , remaining_size ) ; success = false ; } if ( ! success ) { close ( fd ) ; munmap ( reserve , blocks * blksize ) ; free ( pMap -> ranges ) ; return - 1 ; } close ( fd ) ; pMap -> addr = reserve ; pMap -> length = size ; ",bootable@recovery/28a566f7731b4cb76d2a9ba16d997ac5aeb07dad,CVE-2016-0849,https://android.googlesource.com/platform/bootable/recovery/+/28a566f7731b4cb76d2a9ba16d997ac5aeb07dad,2016-04-18T00:59Z 1371,CWE-119,"CWE-119 bool extract_sockaddr ( struct pool * pool , char * url ) { char * url_begin , * url_end , * ipv6_begin , * ipv6_end , * port_start = NULL ; char url_address [ 256 ] , port [ 6 ] ; int url_len , port_len = 0 ; url_begin = strstr ( url , ""//"" ) ; if ( ! url_begin ) url_begin = url ; else url_begin += 2 ; ipv6_begin = strstr ( url_begin , ""["" ) ; ipv6_end = strstr ( url_begin , ""]"" ) ; if ( ipv6_begin && ipv6_end && ipv6_end > ipv6_begin ) url_end = strstr ( ipv6_end , "":"" ) ; else url_end = strstr ( url_begin , "":"" ) ; if ( url_end ) { url_len = url_end - url_begin ; port_len = strlen ( url_begin ) - url_len - 1 ; if ( port_len < 1 ) return false ; port_start = url_end + 1 ; } else url_len = strlen ( url_begin ) ; if ( url_len < 1 ) return false ; sprintf ( url_address , ""%.*s"" , url_len , url_begin ) ; if ( port_len ) snprintf ( port , 6 , ""%.*s"" , port_len , port_start ) ; else strcpy ( port , ""80"" ) ; free ( pool -> stratum_port ) ; pool -> stratum_port = strdup ( port ) ; free ( pool -> sockaddr_url ) ; pool -> sockaddr_url = strdup ( url_address ) ; return true ; } "," return false ; if ( url_len >= sizeof ( url_address ) ) { applog ( LOG_WARNING , ""%s:Truncatingoverflowedaddress\'%.*s\'"" , __func__ , url_len , url_begin ) ; url_len = sizeof ( url_address ) - 1 ; } ",luke-jr@bfgminer/c80ad8548251eb0e15329fc240c89070640c9d79,CVE-2014-4501,https://github.com/luke-jr/bfgminer/commit/c80ad8548251eb0e15329fc240c89070640c9d79,2014-07-23T14:55Z 1372,CWE-119,"CWE-119 int vp9_get_raw_frame ( VP9Decoder * pbi , YV12_BUFFER_CONFIG * sd , int64_t * time_stamp , int64_t * time_end_stamp , vp9_ppflags_t * flags ) { int ret = - 1 ; if ( pbi -> ready_for_new_data == 1 ) return ret ; if ( pbi -> common . show_frame == 0 ) return ret ; pbi -> ready_for_new_data = 1 ; * time_stamp = pbi -> last_time_stamp ; * time_end_stamp = 0 ; # if CONFIG_VP9_POSTPROC ret = vp9_post_proc_frame ( & pbi -> common , sd , flags ) ; # else * sd = * pbi -> common . frame_to_show ; sd -> y_width = pbi -> common . width ; sd -> y_height = pbi -> common . height ; sd -> uv_width = sd -> y_width >> pbi -> common . subsampling_x ; sd -> uv_height = sd -> y_height >> pbi -> common . subsampling_y ; ret = 0 ; # endif vp9_clear_system_state ( ) ; return ret ; } "," * sd , vp9_ppflags_t * flags flags ) { VP9_COMMON * const cm = & pbi -> common ; - 1 ; # if ! CONFIG_VP9_POSTPROC ( void ) * flags ; # endif return ret ; pbi -> ready_for_new_data = 1 ; if ( ! cm -> show_frame ) return ret = 1 ; # if CONFIG_VP9_POSTPROC # if CONFIG_VP9_POSTPROC if ( ! cm -> show_existing_frame ) { = vp9_post_proc_frame ( cm , sd , flags ) ; } else { * sd = * cm -> frame_to_show ; ret = 0 ; } sd = * cm -> frame_to_show ; ret = ; # endif vpx_clear_system_state ( ) ; ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1373,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 , getuid ( ) , getgid ( ) , S_IRUSR | S_IWUSR ) ; if ( rv ) fprintf ( stderr , ""Warning:cannottransfer.asoundrcinprivatehomedirectory\\n"" ) ; else { fs_logger2 ( ""clone"" , dest ) ; } _exit ( 0 ) ; } waitpid ( child , NULL , 0 ) ; unlink ( src ) ; } "," ) ; } copy_file_as_user ( src , S_IWUSR ) ; fs_logger2 ( ""clone"" ""clone"" , dest ) ; unlink ",netblue30@firejail/b8a4ff9775318ca5e679183884a6a63f3da8f863,CVE-2017-5940,https://github.com/netblue30/firejail/commit/b8a4ff9775318ca5e679183884a6a63f3da8f863,2017-02-09T18:59Z 1374,CWE-119,"CWE-119 void vp9_tokenize_sb ( VP9_COMP * cpi , TOKENEXTRA * * t , int dry_run , BLOCK_SIZE bsize ) { VP9_COMMON * const cm = & cpi -> common ; MACROBLOCKD * const xd = & cpi -> mb . e_mbd ; MB_MODE_INFO * const mbmi = & xd -> mi [ 0 ] -> mbmi ; TOKENEXTRA * t_backup = * t ; const int ctx = vp9_get_skip_context ( xd ) ; const int skip_inc = ! vp9_segfeature_active ( & cm -> seg , mbmi -> segment_id , SEG_LVL_SKIP ) ; struct tokenize_b_args arg = { cpi , xd , t } ; if ( mbmi -> skip ) { if ( ! dry_run ) cm -> counts . skip [ ctx ] [ 1 ] += skip_inc ; reset_skip_context ( xd , bsize ) ; if ( dry_run ) * t = t_backup ; return ; } if ( ! dry_run ) { cm -> counts . skip [ ctx ] [ 0 ] += skip_inc ; vp9_foreach_transformed_block ( xd , bsize , tokenize_b , & arg ) ; } else { vp9_foreach_transformed_block ( xd , bsize , set_entropy_context_b , & arg ) ; * t = t_backup ; } } "," * cpi , ThreadData * td , -> common ; MACROBLOCK * const x = & td -> mb ; xd = & x -> e_mbd ; MB_MODE_INFO ] -> mbmi ; const int skip_inc = ! segfeature_active ( & cm { cpi , td , t } ! dry_run ) td -> counts -> skip [ ctx bsize ) ; return ; } dry_run ) { td -> counts -> skip [ ctx arg ) ; } } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1375,CWE-476,"CWE-476 static int tun_set_iff ( struct net * net , struct file * file , struct ifreq * ifr ) { struct tun_struct * tun ; struct tun_file * tfile = file -> private_data ; struct net_device * dev ; int err ; if ( tfile -> detached ) return - EINVAL ; dev = __dev_get_by_name ( net , ifr -> ifr_name ) ; if ( dev ) { if ( ifr -> ifr_flags & IFF_TUN_EXCL ) return - EBUSY ; if ( ( ifr -> ifr_flags & IFF_TUN ) && dev -> netdev_ops == & tun_netdev_ops ) tun = netdev_priv ( dev ) ; else if ( ( ifr -> ifr_flags & IFF_TAP ) && dev -> netdev_ops == & tap_netdev_ops ) tun = netdev_priv ( dev ) ; else return - EINVAL ; if ( ! ! ( ifr -> ifr_flags & IFF_MULTI_QUEUE ) != ! ! ( tun -> flags & IFF_MULTI_QUEUE ) ) return - EINVAL ; if ( tun_not_capable ( tun ) ) return - EPERM ; err = security_tun_dev_open ( tun -> security ) ; if ( err < 0 ) return err ; err = tun_attach ( tun , file , ifr -> ifr_flags & IFF_NOFILTER ) ; if ( err < 0 ) return err ; if ( tun -> flags & IFF_MULTI_QUEUE && ( tun -> numqueues + tun -> numdisabled > 1 ) ) { return 0 ; } } else { char * name ; unsigned long flags = 0 ; int queues = ifr -> ifr_flags & IFF_MULTI_QUEUE ? MAX_TAP_QUEUES : 1 ; if ( ! ns_capable ( net -> user_ns , CAP_NET_ADMIN ) ) return - EPERM ; err = security_tun_dev_create ( ) ; if ( err < 0 ) return err ; if ( ifr -> ifr_flags & IFF_TUN ) { flags |= IFF_TUN ; name = ""tun%d"" ; } else if ( ifr -> ifr_flags & IFF_TAP ) { flags |= IFF_TAP ; name = ""tap%d"" ; } else return - EINVAL ; if ( * ifr -> ifr_name ) name = ifr -> ifr_name ; dev = alloc_netdev_mqs ( sizeof ( struct tun_struct ) , name , NET_NAME_UNKNOWN , tun_setup , queues , queues ) ; if ( ! dev ) return - ENOMEM ; dev_net_set ( dev , net ) ; dev -> rtnl_link_ops = & tun_link_ops ; dev -> ifindex = tfile -> ifindex ; dev -> sysfs_groups [ 0 ] = & tun_attr_group ; tun = netdev_priv ( dev ) ; tun -> dev = dev ; tun -> flags = flags ; tun -> txflt . count = 0 ; tun -> vnet_hdr_sz = sizeof ( struct virtio_net_hdr ) ; tun -> align = NET_SKB_PAD ; tun -> filter_attached = false ; tun -> sndbuf = tfile -> socket . sk -> sk_sndbuf ; tun -> rx_batched = 0 ; tun -> pcpu_stats = netdev_alloc_pcpu_stats ( struct tun_pcpu_stats ) ; if ( ! tun -> pcpu_stats ) { err = - ENOMEM ; goto err_free_dev ; } spin_lock_init ( & tun -> lock ) ; err = security_tun_dev_alloc_security ( & tun -> security ) ; if ( err < 0 ) goto err_free_stat ; tun_net_init ( dev ) ; tun_flow_init ( tun ) ; dev -> hw_features = NETIF_F_SG | NETIF_F_FRAGLIST | TUN_USER_FEATURES | NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX ; dev -> features = dev -> hw_features | NETIF_F_LLTX ; dev -> vlan_features = dev -> features & ~ ( NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_STAG_TX ) ; INIT_LIST_HEAD ( & tun -> disabled ) ; err = tun_attach ( tun , file , false ) ; if ( err < 0 ) goto err_free_flow ; err = register_netdevice ( tun -> dev ) ; if ( err < 0 ) goto err_detach ; } netif_carrier_on ( tun -> dev ) ; tun_debug ( KERN_INFO , tun , ""tun_set_iff\\n"" ) ; tun -> flags = ( tun -> flags & ~ TUN_FEATURES ) | ( ifr -> ifr_flags & TUN_FEATURES ) ; if ( netif_running ( tun -> dev ) ) netif_tx_wake_all_queues ( tun -> dev ) ; strcpy ( ifr -> ifr_name , tun -> dev -> name ) ; return 0 ; err_detach : tun_detach_all ( dev ) ; goto err_free_dev ; err_free_flow : tun_flow_uninit ( tun ) ; security_tun_dev_free_security ( tun -> security ) ; err_free_stat : free_percpu ( tun -> pcpu_stats ) ; err_free_dev : free_netdev ( dev ) ; return err ; } "," - ENOMEM ; err = dev_get_valid_name ( net , dev , name ) ; if ( err ) goto err_free_dev ; ",torvalds@linux/0ad646c81b2182f7fa67ec0c8c825e0ee165696d,CVE-2018-7191,https://github.com/torvalds/linux/commit/0ad646c81b2182f7fa67ec0c8c825e0ee165696d,2019-05-17T05:29Z 1376,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 1377,CWE-125,"CWE-125 int git_delta_apply ( void * * out , size_t * out_len , const unsigned char * base , size_t base_len , const unsigned char * delta , size_t delta_len ) { const unsigned char * delta_end = delta + delta_len ; size_t base_sz , res_sz , alloc_sz ; unsigned char * res_dp ; * out = NULL ; * out_len = 0 ; if ( ( hdr_sz ( & base_sz , & delta , delta_end ) < 0 ) || ( base_sz != base_len ) ) { giterr_set ( GITERR_INVALID , ""failedtoapplydelta:basesizedoesnotmatchgivendata"" ) ; return - 1 ; } if ( hdr_sz ( & res_sz , & delta , delta_end ) < 0 ) { giterr_set ( GITERR_INVALID , ""failedtoapplydelta:basesizedoesnotmatchgivendata"" ) ; return - 1 ; } GITERR_CHECK_ALLOC_ADD ( & alloc_sz , res_sz , 1 ) ; res_dp = git__malloc ( alloc_sz ) ; GITERR_CHECK_ALLOC ( res_dp ) ; res_dp [ res_sz ] = '\\0' ; * out = res_dp ; * out_len = res_sz ; while ( delta < delta_end ) { unsigned char cmd = * delta ++ ; if ( cmd & 0x80 ) { size_t off = 0 , len = 0 ; if ( cmd & 0x01 ) off = * delta ++ ; if ( cmd & 0x02 ) off |= * delta ++ << 8UL ; if ( cmd & 0x04 ) off |= * delta ++ << 16UL ; if ( cmd & 0x08 ) off |= * delta ++ << 24UL ; if ( cmd & 0x10 ) len = * delta ++ ; if ( cmd & 0x20 ) len |= * delta ++ << 8UL ; if ( cmd & 0x40 ) len |= * delta ++ << 16UL ; if ( ! len ) len = 0x10000 ; if ( base_len < off + len || res_sz < len ) goto fail ; memcpy ( res_dp , base + off , len ) ; res_dp += len ; res_sz -= len ; } else if ( cmd ) { if ( delta_end - delta < cmd || res_sz < cmd ) goto fail ; memcpy ( res_dp , delta , cmd ) ; delta += cmd ; res_dp += cmd ; res_sz -= cmd ; } else { goto fail ; } } if ( delta != delta_end || res_sz ) goto fail ; return 0 ; fail : git__free ( * out ) ; * out = NULL ; * out_len = 0 ; giterr_set ( GITERR_INVALID , ""failedtoapplydelta"" ) ; return - 1 ; } "," ) off |= ( ( unsigned ) ++ << 24UL ) ",libgit2@libgit2/3f461902dc1072acb8b7607ee65d0a0458ffac2a,CVE-2018-10887,https://github.com/libgit2/libgit2/commit/3f461902dc1072acb8b7607ee65d0a0458ffac2a,2018-07-10T14:29Z 1378,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/660b513d99bced8783a4a5984ac2f742c74ebbdd,CVE-2017-11664,https://github.com/Mindwerks/wildmidi/commit/660b513d99bced8783a4a5984ac2f742c74ebbdd,2017-08-17T16:29Z 1379,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 1380,CWE-400,"CWE-400 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 1381,CWE-20,"CWE-20 static int flashsv_decode_frame ( AVCodecContext * avctx , void * data , int * got_frame , AVPacket * avpkt ) { int buf_size = avpkt -> size ; FlashSVContext * s = avctx -> priv_data ; int h_blocks , v_blocks , h_part , v_part , i , j , ret ; GetBitContext gb ; int last_blockwidth = s -> block_width ; int last_blockheight = s -> block_height ; if ( buf_size == 0 ) return 0 ; if ( buf_size < 4 ) return - 1 ; init_get_bits ( & gb , avpkt -> data , buf_size * 8 ) ; s -> block_width = 16 * ( get_bits ( & gb , 4 ) + 1 ) ; s -> image_width = get_bits ( & gb , 12 ) ; s -> block_height = 16 * ( get_bits ( & gb , 4 ) + 1 ) ; s -> image_height = get_bits ( & gb , 12 ) ; if ( last_blockwidth != s -> block_width || last_blockheight != s -> block_height ) av_freep ( & s -> blocks ) ; if ( s -> ver == 2 ) { skip_bits ( & gb , 6 ) ; if ( get_bits1 ( & gb ) ) { avpriv_request_sample ( avctx , ""iframe"" ) ; return AVERROR_PATCHWELCOME ; } if ( get_bits1 ( & gb ) ) { avpriv_request_sample ( avctx , ""Custompalette"" ) ; return AVERROR_PATCHWELCOME ; } } h_blocks = s -> image_width / s -> block_width ; h_part = s -> image_width % s -> block_width ; v_blocks = s -> image_height / s -> block_height ; v_part = s -> image_height % s -> block_height ; if ( s -> block_size < s -> block_width * s -> block_height ) { int tmpblock_size = 3 * s -> block_width * s -> block_height ; s -> tmpblock = av_realloc ( s -> tmpblock , tmpblock_size ) ; if ( ! s -> tmpblock ) { av_log ( avctx , AV_LOG_ERROR , ""Can\'tallocatedecompressionbuffer.\\n"" ) ; return AVERROR ( ENOMEM ) ; } if ( s -> ver == 2 ) { s -> deflate_block_size = calc_deflate_block_size ( tmpblock_size ) ; if ( s -> deflate_block_size <= 0 ) { av_log ( avctx , AV_LOG_ERROR , ""Can\'tdeterminedeflatebuffersize.\\n"" ) ; return - 1 ; } s -> deflate_block = av_realloc ( s -> deflate_block , s -> deflate_block_size ) ; if ( ! s -> deflate_block ) { av_log ( avctx , AV_LOG_ERROR , ""Can\'tallocatedeflatebuffer.\\n"" ) ; return AVERROR ( ENOMEM ) ; } } } s -> block_size = s -> block_width * s -> block_height ; if ( avctx -> width == 0 && avctx -> height == 0 ) { avcodec_set_dimensions ( avctx , s -> image_width , s -> image_height ) ; } if ( avctx -> width != s -> image_width || avctx -> height != s -> image_height ) { av_log ( avctx , AV_LOG_ERROR , ""Framewidthorheightdiffersfromfirstframe!\\n"" ) ; av_log ( avctx , AV_LOG_ERROR , ""fh=%d,fv%dvsch=%d,cv=%d\\n"" , avctx -> height , avctx -> width , s -> image_height , s -> image_width ) ; return AVERROR_INVALIDDATA ; } s -> is_keyframe = ( avpkt -> flags & AV_PKT_FLAG_KEY ) && ( s -> ver == 2 ) ; if ( s -> is_keyframe ) { s -> keyframedata = av_realloc ( s -> keyframedata , avpkt -> size ) ; memcpy ( s -> keyframedata , avpkt -> data , avpkt -> size ) ; } if ( s -> ver == 2 && ! s -> blocks ) s -> blocks = av_mallocz ( ( v_blocks + ! ! v_part ) * ( h_blocks + ! ! h_part ) * sizeof ( s -> blocks [ 0 ] ) ) ; av_dlog ( avctx , ""image:%dx%dblock:%dx%dnum:%dx%dpart:%dx%d\\n"" , s -> image_width , s -> image_height , s -> block_width , s -> block_height , h_blocks , v_blocks , h_part , v_part ) ; if ( ( ret = ff_reget_buffer ( avctx , & s -> frame ) ) < 0 ) return ret ; for ( j = 0 ; j < v_blocks + ( v_part ? 1 : 0 ) ; j ++ ) { int y_pos = j * s -> block_height ; int cur_blk_height = ( j < v_blocks ) ? s -> block_height : v_part ; for ( i = 0 ; i < h_blocks + ( h_part ? 1 : 0 ) ; i ++ ) { int x_pos = i * s -> block_width ; int cur_blk_width = ( i < h_blocks ) ? s -> block_width : h_part ; int has_diff = 0 ; int size = get_bits ( & gb , 16 ) ; s -> color_depth = 0 ; s -> zlibprime_curr = 0 ; s -> zlibprime_prev = 0 ; s -> diff_start = 0 ; s -> diff_height = cur_blk_height ; if ( 8 * size > get_bits_left ( & gb ) ) { av_frame_unref ( & s -> frame ) ; return AVERROR_INVALIDDATA ; } if ( s -> ver == 2 && size ) { skip_bits ( & gb , 3 ) ; s -> color_depth = get_bits ( & gb , 2 ) ; has_diff = get_bits1 ( & gb ) ; s -> zlibprime_curr = get_bits1 ( & gb ) ; s -> zlibprime_prev = get_bits1 ( & gb ) ; if ( s -> color_depth != 0 && s -> color_depth != 2 ) { av_log ( avctx , AV_LOG_ERROR , ""%dx%dinvalidcolordepth%d\\n"" , i , j , s -> color_depth ) ; return AVERROR_INVALIDDATA ; } if ( has_diff ) { if ( ! s -> keyframe ) { av_log ( avctx , AV_LOG_ERROR , ""interframewithoutkeyframe\\n"" ) ; return AVERROR_INVALIDDATA ; } s -> diff_start = get_bits ( & gb , 8 ) ; s -> diff_height = get_bits ( & gb , 8 ) ; av_log ( avctx , AV_LOG_DEBUG , ""%dx%ddiffstart%dheight%d\\n"" , i , j , s -> diff_start , s -> diff_height ) ; size -= 2 ; } if ( s -> zlibprime_prev ) av_log ( avctx , AV_LOG_DEBUG , ""%dx%dzlibprime_prev\\n"" , i , j ) ; if ( s -> zlibprime_curr ) { int col = get_bits ( & gb , 8 ) ; int row = get_bits ( & gb , 8 ) ; av_log ( avctx , AV_LOG_DEBUG , ""%dx%dzlibprime_curr%dx%d\\n"" , i , j , col , row ) ; size -= 2 ; avpriv_request_sample ( avctx , ""zlibprime_curr"" ) ; return AVERROR_PATCHWELCOME ; } if ( ! s -> blocks && ( s -> zlibprime_curr || s -> zlibprime_prev ) ) { av_log ( avctx , AV_LOG_ERROR , ""nodataavailableforzlib"" ""priming\\n"" ) ; return AVERROR_INVALIDDATA ; } size -- ; } if ( has_diff ) { int k ; int off = ( s -> image_height - y_pos - 1 ) * s -> frame . linesize [ 0 ] ; for ( k = 0 ; k < cur_blk_height ; k ++ ) memcpy ( s -> frame . data [ 0 ] + off - k * s -> frame . linesize [ 0 ] + x_pos * 3 , s -> keyframe + off - k * s -> frame . linesize [ 0 ] + x_pos * 3 , cur_blk_width * 3 ) ; } if ( size ) { if ( flashsv_decode_block ( avctx , avpkt , & gb , size , cur_blk_width , cur_blk_height , x_pos , y_pos , i + j * ( h_blocks + ! ! h_part ) ) ) av_log ( avctx , AV_LOG_ERROR , ""errorindecompressionofblock%dx%d\\n"" , i , j ) ; } } } if ( s -> is_keyframe && s -> ver == 2 ) { if ( ! s -> keyframe ) { s -> keyframe = av_malloc ( s -> frame . linesize [ 0 ] * avctx -> height ) ; if ( ! s -> keyframe ) { av_log ( avctx , AV_LOG_ERROR , ""Cannotallocateimagedata\\n"" ) ; return AVERROR ( ENOMEM ) ; } } memcpy ( s -> keyframe , s -> frame . data [ 0 ] , s -> frame . linesize [ 0 ] * avctx -> height ) ; } if ( ( ret = av_frame_ref ( data , & s -> frame ) ) < 0 ) return ret ; * got_frame = 1 ; if ( ( get_bits_count ( & gb ) / 8 ) != buf_size ) av_log ( avctx , AV_LOG_ERROR , ""buffernotfullyconsumed(%d!=%d)\\n"" , buf_size , ( get_bits_count ( & gb ) / 8 ) ) ; return buf_size ; } "," 8 ) ; if ( s -> diff_start + s -> diff_height > cur_blk_height ) { av_log ( avctx , AV_LOG_ERROR , ""Blockparametersinvalid\\n"" ) ; return AVERROR_INVALIDDATA ; } ",FFmpeg@FFmpeg/880c73cd76109697447fbfbaa8e5ee5683309446,CVE-2013-7015,https://github.com/FFmpeg/FFmpeg/commit/880c73cd76109697447fbfbaa8e5ee5683309446,2013-12-09T16:36Z 1382,CWE-119,"CWE-119 static long ioctl_file_dedupe_range ( struct file * file , void __user * arg ) { struct file_dedupe_range __user * argp = arg ; struct file_dedupe_range * same = NULL ; int ret ; unsigned long size ; u16 count ; if ( get_user ( count , & argp -> dest_count ) ) { ret = - EFAULT ; goto out ; } size = offsetof ( struct file_dedupe_range __user , info [ count ] ) ; same = memdup_user ( argp , size ) ; if ( IS_ERR ( same ) ) { ret = PTR_ERR ( same ) ; same = NULL ; goto out ; } ret = vfs_dedupe_file_range ( file , same ) ; if ( ret ) goto out ; ret = copy_to_user ( argp , same , size ) ; if ( ret ) ret = - EFAULT ; out : kfree ( same ) ; return ret ; } "," out ; } same -> dest_count = count ; ",torvalds@linux/10eec60ce79187686e052092e5383c99b4420a20,CVE-2016-6516,https://github.com/torvalds/linux/commit/10eec60ce79187686e052092e5383c99b4420a20,2016-08-06T20:59Z 1383,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 1384,CWE-264,"CWE-264 static int msr_open ( struct inode * inode , struct file * file ) { unsigned int cpu ; struct cpuinfo_x86 * c ; cpu = iminor ( file -> f_path . dentry -> d_inode ) ; if ( cpu >= nr_cpu_ids || ! cpu_online ( cpu ) ) return - ENXIO ; c = & cpu_data ( cpu ) ; if ( ! cpu_has ( c , X86_FEATURE_MSR ) ) return - EIO ; return 0 ; } "," cpuinfo_x86 * c ; if ( ! capable ( CAP_SYS_RAWIO ) ) return - EPERM ",torvalds@linux/c903f0456bc69176912dee6dd25c6a66ee1aed00,CVE-2013-0268,https://github.com/torvalds/linux/commit/c903f0456bc69176912dee6dd25c6a66ee1aed00,2013-02-18T04:41Z 1385,CWE-264,"CWE-264 static void bond_setup ( struct net_device * bond_dev ) { struct bonding * bond = netdev_priv ( bond_dev ) ; rwlock_init ( & bond -> lock ) ; rwlock_init ( & bond -> curr_slave_lock ) ; bond -> params = bonding_defaults ; bond -> dev = bond_dev ; INIT_LIST_HEAD ( & bond -> vlan_list ) ; ether_setup ( bond_dev ) ; bond_dev -> netdev_ops = & bond_netdev_ops ; bond_dev -> ethtool_ops = & bond_ethtool_ops ; bond_set_mode_ops ( bond , bond -> params . mode ) ; bond_dev -> destructor = bond_destructor ; bond_dev -> tx_queue_len = 0 ; bond_dev -> flags |= IFF_MASTER | IFF_MULTICAST ; bond_dev -> priv_flags |= IFF_BONDING ; bond_dev -> priv_flags &= ~ IFF_XMIT_DST_RELEASE ; bond_dev -> features |= NETIF_F_VLAN_CHALLENGED ; bond_dev -> features |= NETIF_F_LLTX ; bond_dev -> hw_features = BOND_VLAN_FEATURES | NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_FILTER ; bond_dev -> hw_features &= ~ ( NETIF_F_ALL_CSUM & ~ NETIF_F_NO_CSUM ) ; bond_dev -> features |= bond_dev -> hw_features ; } "," priv_flags &= ~ ( IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING ) ; bond_dev -> ",torvalds@linux/550fd08c2cebad61c548def135f67aba284c6162,CVE-2011-4112,https://github.com/torvalds/linux/commit/550fd08c2cebad61c548def135f67aba284c6162,2012-05-17T11:00Z 1386,CWE-119,"CWE-119 int vp9_receive_compressed_data ( VP9Decoder * pbi , size_t size , const uint8_t * * psource , int64_t time_stamp ) { VP9_COMMON * const cm = & pbi -> common ; const uint8_t * source = * psource ; int retcode = 0 ; cm -> error . error_code = VPX_CODEC_OK ; if ( size == 0 ) { if ( cm -> frame_refs [ 0 ] . idx != INT_MAX ) cm -> frame_refs [ 0 ] . buf -> corrupted = 1 ; } if ( cm -> new_fb_idx >= 0 && cm -> frame_bufs [ cm -> new_fb_idx ] . ref_count == 0 ) cm -> release_fb_cb ( cm -> cb_priv , & cm -> frame_bufs [ cm -> new_fb_idx ] . raw_frame_buffer ) ; cm -> new_fb_idx = get_free_fb ( cm ) ; if ( setjmp ( cm -> error . jmp ) ) { cm -> error . setjmp = 0 ; if ( cm -> frame_refs [ 0 ] . idx != INT_MAX ) cm -> frame_refs [ 0 ] . buf -> corrupted = 1 ; if ( cm -> frame_bufs [ cm -> new_fb_idx ] . ref_count > 0 ) cm -> frame_bufs [ cm -> new_fb_idx ] . ref_count -- ; return - 1 ; } cm -> error . setjmp = 1 ; retcode = vp9_decode_frame ( pbi , source , source + size , psource ) ; if ( retcode < 0 ) { cm -> error . error_code = VPX_CODEC_ERROR ; cm -> error . setjmp = 0 ; if ( cm -> frame_bufs [ cm -> new_fb_idx ] . ref_count > 0 ) cm -> frame_bufs [ cm -> new_fb_idx ] . ref_count -- ; return retcode ; } swap_frame_buffers ( pbi ) ; # if WRITE_RECON_BUFFER == 2 if ( cm -> show_frame ) write_dx_frame_to_file ( cm -> frame_to_show , cm -> current_video_frame ) ; else write_dx_frame_to_file ( cm -> frame_to_show , cm -> current_video_frame + 1000 ) ; # endif if ( ! pbi -> do_loopfilter_inline ) { if ( pbi -> num_tile_workers ) { vp9_loop_filter_frame_mt ( pbi , cm , & pbi -> mb , cm -> lf . filter_level , 0 , 0 ) ; } else { vp9_loop_filter_frame ( cm , & pbi -> mb , cm -> lf . filter_level , 0 , 0 ) ; } } # if WRITE_RECON_BUFFER == 2 if ( cm -> show_frame ) write_dx_frame_to_file ( cm -> frame_to_show , cm -> current_video_frame + 2000 ) ; else write_dx_frame_to_file ( cm -> frame_to_show , cm -> current_video_frame + 3000 ) ; # endif # if WRITE_RECON_BUFFER == 1 if ( cm -> show_frame ) recon_write_yuv_frame ( ""recon.yuv"" , cm -> frame_to_show , cm -> width , cm -> height ) ; # endif vp9_clear_system_state ( ) ; cm -> last_width = cm -> width ; cm -> last_height = cm -> height ; if ( ! cm -> show_existing_frame ) cm -> last_show_frame = cm -> show_frame ; if ( cm -> show_frame ) { if ( ! cm -> show_existing_frame ) vp9_swap_mi_and_prev_mi ( cm ) ; cm -> current_video_frame ++ ; } pbi -> ready_for_new_data = 0 ; pbi -> last_time_stamp = time_stamp ; cm -> error . setjmp = 0 ; return retcode ; } "," * * psource ) { VP9_COMMON { VP9_COMMON * volatile pbi -> common ; BufferPool * volatile const pool = cm -> buffer_pool ; RefCntBuffer * volatile const frame_bufs = cm -> buffer_pool -> frame_bufs ] . idx > 0 ) { assert ( cm -> frame_refs [ 0 ] . buf != NULL ) ; cm -> frame_refs 1 ; } } pbi -> ready_for_new_data = 0 ; if ( ! pbi -> frame_parallel_decode && cm -> new_fb_idx >= 0 && frame_bufs [ cm == 0 ) pool -> release_fb_cb ( -> release_fb_cb ( pool -> cb_priv , cb_priv , & frame_bufs [ cm ; if ( cm -> new_fb_idx == INVALID_IDX ) return VPX_CODEC_MEM_ERROR ; cm -> cur_frame = & pool -> frame_bufs [ cm -> new_fb_idx ] ; pbi -> hold_ref_buf = 0 ; if ( pbi -> frame_parallel_decode ) { VPxWorker * const worker = pbi -> frame_worker_owner ; vp9_frameworker_lock_stats ( worker ) ; frame_bufs [ cm -> new_fb_idx ] . frame_worker_owner = worker ; pbi -> cur_buf = & frame_bufs [ cm -> new_fb_idx ] ; pbi -> cur_buf -> row = - 1 ; pbi -> cur_buf -> col = - 1 ; vp9_frameworker_unlock_stats ( worker ) ; } else { pbi -> cur_buf = & frame_bufs [ cm -> new_fb_idx ] ; } if ( ) ) { const VPxWorkerInterface * const winterface = vpx_get_worker_interface ( ) ; int i ; = 0 ; pbi -> ready_for_new_data = 1 ; winterface -> sync ( & pbi -> lf_worker ) ; for ( i = 0 ; i < pbi -> num_tile_workers ; ++ i ) { winterface -> sync ( & pbi -> tile_workers [ i ] ) ; } lock_buffer_pool ( pool ) ; if ( pbi -> hold_ref_buf == 1 ) { int ref_index = 0 , mask ; for ( mask = pbi -> refresh_frame_flags ; mask ; mask >>= 1 ) { const int old_idx = cm -> ref_frame_map [ ref_index ] ; decrease_ref_count ( old_idx , frame_bufs , pool ) ; if ( ( mask & 1 ) && old_idx >= 0 ) { decrease_ref_count ( old_idx , frame_bufs , pool ) ; } ++ ref_index ; } for ( ; ref_index < REF_FRAMES && ! cm -> show_existing_frame ; ++ ref_index ) { const int old_idx = cm -> ref_frame_map [ ref_index ] ; decrease_ref_count ( old_idx , frame_bufs , pool ) ; } pbi -> hold_ref_buf = 0 ; } decrease_ref_count ( cm -> new_fb_idx , frame_bufs , pool ) ; unlock_buffer_pool ( pool ) ; vpx_clear_system_state ( ) ; return - = 1 ; vp9_decode_frame ( pbi psource ) ; swap_frame_buffers ( pbi ) ; vpx_clear_system_state ( ) ; if ( ! cm -> show_existing_frame ) { cm -> last_show_frame = cm -> show_frame ; cm -> prev_frame = cm -> cur_frame ; if ( cm -> seg . enabled && ! pbi -> frame_parallel_decode ) vp9_swap_current_and_last_seg_map ( cm ) ; } if ( pbi -> frame_parallel_decode ) { VPxWorker * const worker = pbi -> frame_worker_owner ; FrameWorkerData * const frame_worker_data = worker -> data1 ; vp9_frameworker_lock_stats ( worker ) ; if ( cm -> show_frame ) { cm -> current_video_frame ++ ; } frame_worker_data -> frame_decoded = 1 ; frame_worker_data -> frame_context_ready = 1 ; vp9_frameworker_signal_stats ( worker ) ; vp9_frameworker_unlock_stats ( worker ) ; } else { cm -> last_width = cm -> width ; cm -> last_height = cm -> height ; if ( cm -> show_frame ) { cm -> current_video_frame ++ ; } } cm -> error -> error . setjmp = 0 setjmp = 0 ; return retcode retcode ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1387,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 1388,CWE-119,"CWE-119 static void update_mbgraph_mb_stats ( VP9_COMP * cpi , MBGRAPH_MB_STATS * stats , YV12_BUFFER_CONFIG * buf , int mb_y_offset , YV12_BUFFER_CONFIG * golden_ref , int_mv * prev_golden_ref_mv , YV12_BUFFER_CONFIG * alt_ref , int mb_row , int mb_col ) { MACROBLOCK * const x = & cpi -> mb ; MACROBLOCKD * const xd = & x -> e_mbd ; int intra_error ; VP9_COMMON * cm = & cpi -> common ; x -> plane [ 0 ] . src . buf = buf -> y_buffer + mb_y_offset ; x -> plane [ 0 ] . src . stride = buf -> y_stride ; xd -> plane [ 0 ] . dst . buf = get_frame_new_buffer ( cm ) -> y_buffer + mb_y_offset ; xd -> plane [ 0 ] . dst . stride = get_frame_new_buffer ( cm ) -> y_stride ; intra_error = find_best_16x16_intra ( cpi , & stats -> ref [ INTRA_FRAME ] . m . mode ) ; if ( intra_error <= 0 ) intra_error = 1 ; stats -> ref [ INTRA_FRAME ] . err = intra_error ; if ( golden_ref ) { int g_motion_error ; xd -> plane [ 0 ] . pre [ 0 ] . buf = golden_ref -> y_buffer + mb_y_offset ; xd -> plane [ 0 ] . pre [ 0 ] . stride = golden_ref -> y_stride ; g_motion_error = do_16x16_motion_search ( cpi , prev_golden_ref_mv , & stats -> ref [ GOLDEN_FRAME ] . m . mv , mb_row , mb_col ) ; stats -> ref [ GOLDEN_FRAME ] . err = g_motion_error ; } else { stats -> ref [ GOLDEN_FRAME ] . err = INT_MAX ; stats -> ref [ GOLDEN_FRAME ] . m . mv . as_int = 0 ; } if ( alt_ref ) { int a_motion_error ; xd -> plane [ 0 ] . pre [ 0 ] . buf = alt_ref -> y_buffer + mb_y_offset ; xd -> plane [ 0 ] . pre [ 0 ] . stride = alt_ref -> y_stride ; a_motion_error = do_16x16_zerozero_search ( cpi , & stats -> ref [ ALTREF_FRAME ] . m . mv ) ; stats -> ref [ ALTREF_FRAME ] . err = a_motion_error ; } else { stats -> ref [ ALTREF_FRAME ] . err = INT_MAX ; stats -> ref [ ALTREF_FRAME ] . m . mv . as_int = 0 ; } } "," * golden_ref , const MV * prev_golden_ref_mv , & cpi -> td . ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1389,CWE-401,"CWE-401 static ssize_t rpmsg_eptdev_write_iter ( struct kiocb * iocb , struct iov_iter * from ) { struct file * filp = iocb -> ki_filp ; struct rpmsg_eptdev * eptdev = filp -> private_data ; size_t len = iov_iter_count ( from ) ; void * kbuf ; int ret ; kbuf = kzalloc ( len , GFP_KERNEL ) ; if ( ! kbuf ) return - ENOMEM ; if ( ! copy_from_iter_full ( kbuf , len , from ) ) return - EFAULT ; if ( mutex_lock_interruptible ( & eptdev -> ept_lock ) ) { ret = - ERESTARTSYS ; goto free_kbuf ; } if ( ! eptdev -> ept ) { ret = - EPIPE ; goto unlock_eptdev ; } if ( filp -> f_flags & O_NONBLOCK ) ret = rpmsg_trysend ( eptdev -> ept , kbuf , len ) ; else ret = rpmsg_send ( eptdev -> ept , kbuf , len ) ; unlock_eptdev : mutex_unlock ( & eptdev -> ept_lock ) ; free_kbuf : kfree ( kbuf ) ; return ret < 0 ? ret : len ; } "," from ) ) { ret = - EFAULT ; - EFAULT ; goto free_kbuf ; } ",torvalds@linux/bbe692e349e2a1edf3fe0a29a0e05899c9c94d51,CVE-2019-19053,https://github.com/torvalds/linux/commit/bbe692e349e2a1edf3fe0a29a0e05899c9c94d51,2019-11-18T06:15Z 1390,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 1391,CWE-119,"CWE-119 gboolean _pango_emoji_iter_next ( PangoEmojiIter * iter ) { PangoEmojiType current_emoji_type = PANGO_EMOJI_TYPE_INVALID ; if ( iter -> end == iter -> text_end ) return FALSE ; iter -> start = iter -> end ; for ( ; iter -> end < iter -> text_end ; iter -> end = g_utf8_next_char ( iter -> end ) ) { gunichar ch = g_utf8_get_char ( iter -> end ) ; if ( ( ! ( ch == kZeroWidthJoinerCharacter && ! iter -> is_emoji ) && ch != kVariationSelector15Character && ch != kVariationSelector16Character && ch != kCombiningEnclosingCircleBackslashCharacter && ! _pango_Is_Regional_Indicator ( ch ) && ! ( ( ch == kLeftSpeechBubbleCharacter || ch == kRainbowCharacter || ch == kMaleSignCharacter || ch == kFemaleSignCharacter || ch == kStaffOfAesculapiusCharacter ) && ! iter -> is_emoji ) ) || current_emoji_type == PANGO_EMOJI_TYPE_INVALID ) { current_emoji_type = _pango_get_emoji_type ( ch ) ; } if ( g_utf8_next_char ( iter -> end ) < iter -> text_end ) { gunichar peek_char = g_utf8_get_char ( g_utf8_next_char ( iter -> end ) ) ; if ( current_emoji_type == PANGO_EMOJI_TYPE_EMOJI_EMOJI && peek_char == kVariationSelector15Character ) { current_emoji_type = PANGO_EMOJI_TYPE_EMOJI_TEXT ; } if ( ( current_emoji_type == PANGO_EMOJI_TYPE_EMOJI_TEXT || _pango_Is_Emoji_Keycap_Base ( ch ) ) && peek_char == kVariationSelector16Character ) { current_emoji_type = PANGO_EMOJI_TYPE_EMOJI_EMOJI ; } if ( _pango_Is_Emoji_Keycap_Base ( ch ) && peek_char == kCombiningEnclosingKeycapCharacter ) { current_emoji_type = PANGO_EMOJI_TYPE_EMOJI_EMOJI ; } ; if ( _pango_Is_Regional_Indicator ( ch ) && _pango_Is_Regional_Indicator ( peek_char ) ) { current_emoji_type = PANGO_EMOJI_TYPE_EMOJI_EMOJI ; } if ( ( ch == kEyeCharacter || ch == kWavingWhiteFlagCharacter ) && peek_char == kZeroWidthJoinerCharacter ) { current_emoji_type = PANGO_EMOJI_TYPE_EMOJI_EMOJI ; } } if ( iter -> is_emoji == ( gboolean ) 2 ) iter -> is_emoji = ! PANGO_EMOJI_TYPE_IS_EMOJI ( current_emoji_type ) ; if ( iter -> is_emoji == PANGO_EMOJI_TYPE_IS_EMOJI ( current_emoji_type ) ) { iter -> is_emoji = ! PANGO_EMOJI_TYPE_IS_EMOJI ( current_emoji_type ) ; return TRUE ; } } iter -> is_emoji = PANGO_EMOJI_TYPE_IS_EMOJI ( current_emoji_type ) ; return TRUE ; } "," current_emoji_type ) ; if ( iter -> start == iter -> end ) iter -> end = g_utf8_next_char ( iter -> end ) ; ",GNOME@pango/71aaeaf020340412b8d012fe23a556c0420eda5f,CVE-2018-15120,https://github.com/GNOME/pango/commit/71aaeaf020340412b8d012fe23a556c0420eda5f,2018-08-24T19:29Z 1392,CWE-125,"CWE-125 int imagetobmp ( opj_image_t * image , const char * outfile ) { int w , h ; int i , pad ; FILE * fdest = NULL ; int adjustR , adjustG , adjustB ; if ( image -> comps [ 0 ] . prec < 8 ) { fprintf ( stderr , ""Unsupportednumberofcomponents:%d\\n"" , image -> comps [ 0 ] . prec ) ; return 1 ; } if ( image -> numcomps >= 3 && image -> comps [ 0 ] . dx == image -> comps [ 1 ] . dx && image -> comps [ 1 ] . dx == image -> comps [ 2 ] . dx && image -> comps [ 0 ] . dy == image -> comps [ 1 ] . dy && image -> comps [ 1 ] . dy == image -> comps [ 2 ] . dy && image -> comps [ 0 ] . prec == image -> comps [ 1 ] . prec && image -> comps [ 1 ] . prec == image -> comps [ 2 ] . prec ) { fdest = fopen ( outfile , ""wb"" ) ; if ( ! fdest ) { fprintf ( stderr , ""ERROR->failedtoopen%sforwriting\\n"" , outfile ) ; return 1 ; } w = ( int ) image -> comps [ 0 ] . w ; h = ( int ) image -> comps [ 0 ] . h ; fprintf ( fdest , ""BM"" ) ; fprintf ( fdest , ""%c%c%c%c"" , ( OPJ_UINT8 ) ( h * w * 3 + 3 * h * ( w % 2 ) + 54 ) & 0xff , ( OPJ_UINT8 ) ( ( h * w * 3 + 3 * h * ( w % 2 ) + 54 ) >> 8 ) & 0xff , ( OPJ_UINT8 ) ( ( h * w * 3 + 3 * h * ( w % 2 ) + 54 ) >> 16 ) & 0xff , ( OPJ_UINT8 ) ( ( h * w * 3 + 3 * h * ( w % 2 ) + 54 ) >> 24 ) & 0xff ) ; fprintf ( fdest , ""%c%c%c%c"" , ( 0 ) & 0xff , ( ( 0 ) >> 8 ) & 0xff , ( ( 0 ) >> 16 ) & 0xff , ( ( 0 ) >> 24 ) & 0xff ) ; fprintf ( fdest , ""%c%c%c%c"" , ( 54 ) & 0xff , ( ( 54 ) >> 8 ) & 0xff , ( ( 54 ) >> 16 ) & 0xff , ( ( 54 ) >> 24 ) & 0xff ) ; fprintf ( fdest , ""%c%c%c%c"" , ( 40 ) & 0xff , ( ( 40 ) >> 8 ) & 0xff , ( ( 40 ) >> 16 ) & 0xff , ( ( 40 ) >> 24 ) & 0xff ) ; fprintf ( fdest , ""%c%c%c%c"" , ( OPJ_UINT8 ) ( ( w ) & 0xff ) , ( OPJ_UINT8 ) ( ( w ) >> 8 ) & 0xff , ( OPJ_UINT8 ) ( ( w ) >> 16 ) & 0xff , ( OPJ_UINT8 ) ( ( w ) >> 24 ) & 0xff ) ; fprintf ( fdest , ""%c%c%c%c"" , ( OPJ_UINT8 ) ( ( h ) & 0xff ) , ( OPJ_UINT8 ) ( ( h ) >> 8 ) & 0xff , ( OPJ_UINT8 ) ( ( h ) >> 16 ) & 0xff , ( OPJ_UINT8 ) ( ( h ) >> 24 ) & 0xff ) ; fprintf ( fdest , ""%c%c"" , ( 1 ) & 0xff , ( ( 1 ) >> 8 ) & 0xff ) ; fprintf ( fdest , ""%c%c"" , ( 24 ) & 0xff , ( ( 24 ) >> 8 ) & 0xff ) ; fprintf ( fdest , ""%c%c%c%c"" , ( 0 ) & 0xff , ( ( 0 ) >> 8 ) & 0xff , ( ( 0 ) >> 16 ) & 0xff , ( ( 0 ) >> 24 ) & 0xff ) ; fprintf ( fdest , ""%c%c%c%c"" , ( OPJ_UINT8 ) ( 3 * h * w + 3 * h * ( w % 2 ) ) & 0xff , ( OPJ_UINT8 ) ( ( h * w * 3 + 3 * h * ( w % 2 ) ) >> 8 ) & 0xff , ( OPJ_UINT8 ) ( ( h * w * 3 + 3 * h * ( w % 2 ) ) >> 16 ) & 0xff , ( OPJ_UINT8 ) ( ( h * w * 3 + 3 * h * ( w % 2 ) ) >> 24 ) & 0xff ) ; fprintf ( fdest , ""%c%c%c%c"" , ( 7834 ) & 0xff , ( ( 7834 ) >> 8 ) & 0xff , ( ( 7834 ) >> 16 ) & 0xff , ( ( 7834 ) >> 24 ) & 0xff ) ; fprintf ( fdest , ""%c%c%c%c"" , ( 7834 ) & 0xff , ( ( 7834 ) >> 8 ) & 0xff , ( ( 7834 ) >> 16 ) & 0xff , ( ( 7834 ) >> 24 ) & 0xff ) ; fprintf ( fdest , ""%c%c%c%c"" , ( 0 ) & 0xff , ( ( 0 ) >> 8 ) & 0xff , ( ( 0 ) >> 16 ) & 0xff , ( ( 0 ) >> 24 ) & 0xff ) ; fprintf ( fdest , ""%c%c%c%c"" , ( 0 ) & 0xff , ( ( 0 ) >> 8 ) & 0xff , ( ( 0 ) >> 16 ) & 0xff , ( ( 0 ) >> 24 ) & 0xff ) ; if ( image -> comps [ 0 ] . prec > 8 ) { adjustR = ( int ) image -> comps [ 0 ] . prec - 8 ; printf ( ""BMPCONVERSION:Truncatingcomponent0from%dbitsto8bits\\n"" , image -> comps [ 0 ] . prec ) ; } else adjustR = 0 ; if ( image -> comps [ 1 ] . prec > 8 ) { adjustG = ( int ) image -> comps [ 1 ] . prec - 8 ; printf ( ""BMPCONVERSION:Truncatingcomponent1from%dbitsto8bits\\n"" , image -> comps [ 1 ] . prec ) ; } else adjustG = 0 ; if ( image -> comps [ 2 ] . prec > 8 ) { adjustB = ( int ) image -> comps [ 2 ] . prec - 8 ; printf ( ""BMPCONVERSION:Truncatingcomponent2from%dbitsto8bits\\n"" , image -> comps [ 2 ] . prec ) ; } else adjustB = 0 ; for ( i = 0 ; i < w * h ; i ++ ) { OPJ_UINT8 rc , gc , bc ; int r , g , b ; r = image -> comps [ 0 ] . data [ w * h - ( ( i ) / ( w ) + 1 ) * w + ( i ) % ( w ) ] ; r += ( image -> comps [ 0 ] . sgnd ? 1 << ( image -> comps [ 0 ] . prec - 1 ) : 0 ) ; r = ( ( r >> adjustR ) + ( ( r >> ( adjustR - 1 ) ) % 2 ) ) ; if ( r > 255 ) r = 255 ; else if ( r < 0 ) r = 0 ; rc = ( OPJ_UINT8 ) r ; g = image -> comps [ 1 ] . data [ w * h - ( ( i ) / ( w ) + 1 ) * w + ( i ) % ( w ) ] ; g += ( image -> comps [ 1 ] . sgnd ? 1 << ( image -> comps [ 1 ] . prec - 1 ) : 0 ) ; g = ( ( g >> adjustG ) + ( ( g >> ( adjustG - 1 ) ) % 2 ) ) ; if ( g > 255 ) g = 255 ; else if ( g < 0 ) g = 0 ; gc = ( OPJ_UINT8 ) g ; b = image -> comps [ 2 ] . data [ w * h - ( ( i ) / ( w ) + 1 ) * w + ( i ) % ( w ) ] ; b += ( image -> comps [ 2 ] . sgnd ? 1 << ( image -> comps [ 2 ] . prec - 1 ) : 0 ) ; b = ( ( b >> adjustB ) + ( ( b >> ( adjustB - 1 ) ) % 2 ) ) ; if ( b > 255 ) b = 255 ; else if ( b < 0 ) b = 0 ; bc = ( OPJ_UINT8 ) b ; fprintf ( fdest , ""%c%c%c"" , bc , gc , rc ) ; if ( ( i + 1 ) % w == 0 ) { for ( pad = ( ( 3 * w ) % 4 ) ? ( 4 - ( 3 * w ) % 4 ) : 0 ; pad > 0 ; pad -- ) fprintf ( fdest , ""%c"" , 0 ) ; } } fclose ( fdest ) ; } else { fdest = fopen ( outfile , ""wb"" ) ; if ( ! fdest ) { fprintf ( stderr , ""ERROR->failedtoopen%sforwriting\\n"" , outfile ) ; return 1 ; } w = ( int ) image -> comps [ 0 ] . w ; h = ( int ) image -> comps [ 0 ] . h ; fprintf ( fdest , ""BM"" ) ; fprintf ( fdest , ""%c%c%c%c"" , ( OPJ_UINT8 ) ( h * w + 54 + 1024 + h * ( w % 2 ) ) & 0xff , ( OPJ_UINT8 ) ( ( h * w + 54 + 1024 + h * ( w % 2 ) ) >> 8 ) & 0xff , ( OPJ_UINT8 ) ( ( h * w + 54 + 1024 + h * ( w % 2 ) ) >> 16 ) & 0xff , ( OPJ_UINT8 ) ( ( h * w + 54 + 1024 + w * ( w % 2 ) ) >> 24 ) & 0xff ) ; fprintf ( fdest , ""%c%c%c%c"" , ( 0 ) & 0xff , ( ( 0 ) >> 8 ) & 0xff , ( ( 0 ) >> 16 ) & 0xff , ( ( 0 ) >> 24 ) & 0xff ) ; fprintf ( fdest , ""%c%c%c%c"" , ( 54 + 1024 ) & 0xff , ( ( 54 + 1024 ) >> 8 ) & 0xff , ( ( 54 + 1024 ) >> 16 ) & 0xff , ( ( 54 + 1024 ) >> 24 ) & 0xff ) ; fprintf ( fdest , ""%c%c%c%c"" , ( 40 ) & 0xff , ( ( 40 ) >> 8 ) & 0xff , ( ( 40 ) >> 16 ) & 0xff , ( ( 40 ) >> 24 ) & 0xff ) ; fprintf ( fdest , ""%c%c%c%c"" , ( OPJ_UINT8 ) ( ( w ) & 0xff ) , ( OPJ_UINT8 ) ( ( w ) >> 8 ) & 0xff , ( OPJ_UINT8 ) ( ( w ) >> 16 ) & 0xff , ( OPJ_UINT8 ) ( ( w ) >> 24 ) & 0xff ) ; fprintf ( fdest , ""%c%c%c%c"" , ( OPJ_UINT8 ) ( ( h ) & 0xff ) , ( OPJ_UINT8 ) ( ( h ) >> 8 ) & 0xff , ( OPJ_UINT8 ) ( ( h ) >> 16 ) & 0xff , ( OPJ_UINT8 ) ( ( h ) >> 24 ) & 0xff ) ; fprintf ( fdest , ""%c%c"" , ( 1 ) & 0xff , ( ( 1 ) >> 8 ) & 0xff ) ; fprintf ( fdest , ""%c%c"" , ( 8 ) & 0xff , ( ( 8 ) >> 8 ) & 0xff ) ; fprintf ( fdest , ""%c%c%c%c"" , ( 0 ) & 0xff , ( ( 0 ) >> 8 ) & 0xff , ( ( 0 ) >> 16 ) & 0xff , ( ( 0 ) >> 24 ) & 0xff ) ; fprintf ( fdest , ""%c%c%c%c"" , ( OPJ_UINT8 ) ( h * w + h * ( w % 2 ) ) & 0xff , ( OPJ_UINT8 ) ( ( h * w + h * ( w % 2 ) ) >> 8 ) & 0xff , ( OPJ_UINT8 ) ( ( h * w + h * ( w % 2 ) ) >> 16 ) & 0xff , ( OPJ_UINT8 ) ( ( h * w + h * ( w % 2 ) ) >> 24 ) & 0xff ) ; fprintf ( fdest , ""%c%c%c%c"" , ( 7834 ) & 0xff , ( ( 7834 ) >> 8 ) & 0xff , ( ( 7834 ) >> 16 ) & 0xff , ( ( 7834 ) >> 24 ) & 0xff ) ; fprintf ( fdest , ""%c%c%c%c"" , ( 7834 ) & 0xff , ( ( 7834 ) >> 8 ) & 0xff , ( ( 7834 ) >> 16 ) & 0xff , ( ( 7834 ) >> 24 ) & 0xff ) ; fprintf ( fdest , ""%c%c%c%c"" , ( 256 ) & 0xff , ( ( 256 ) >> 8 ) & 0xff , ( ( 256 ) >> 16 ) & 0xff , ( ( 256 ) >> 24 ) & 0xff ) ; fprintf ( fdest , ""%c%c%c%c"" , ( 256 ) & 0xff , ( ( 256 ) >> 8 ) & 0xff , ( ( 256 ) >> 16 ) & 0xff , ( ( 256 ) >> 24 ) & 0xff ) ; if ( image -> comps [ 0 ] . prec > 8 ) { adjustR = ( int ) image -> comps [ 0 ] . prec - 8 ; printf ( ""BMPCONVERSION:Truncatingcomponent0from%dbitsto8bits\\n"" , image -> comps [ 0 ] . prec ) ; } else adjustR = 0 ; for ( i = 0 ; i < 256 ; i ++ ) { fprintf ( fdest , ""%c%c%c%c"" , i , i , i , 0 ) ; } for ( i = 0 ; i < w * h ; i ++ ) { int r ; r = image -> comps [ 0 ] . data [ w * h - ( ( i ) / ( w ) + 1 ) * w + ( i ) % ( w ) ] ; r += ( image -> comps [ 0 ] . sgnd ? 1 << ( image -> comps [ 0 ] . prec - 1 ) : 0 ) ; r = ( ( r >> adjustR ) + ( ( r >> ( adjustR - 1 ) ) % 2 ) ) ; if ( r > 255 ) r = 255 ; else if ( r < 0 ) r = 0 ; fprintf ( fdest , ""%c"" , ( OPJ_UINT8 ) r ) ; if ( ( i + 1 ) % w == 0 ) { for ( ( pad = w % 4 ) ? ( 4 - w % 4 ) : 0 ; pad > 0 ; pad -- ) fprintf ( fdest , ""%c"" , 0 ) ; } } fclose ( fdest ) ; } return 0 ; } "," { for ( pad = ( w % 4 ",uclouvain@openjpeg/15f081c89650dccee4aa4ae66f614c3fdb268767,CVE-2016-3183,https://github.com/uclouvain/openjpeg/commit/15f081c89650dccee4aa4ae66f614c3fdb268767,2017-02-03T16:59Z 1393,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 1394,CWE-119,"CWE-119 cJSON * cJSON_DetachItemFromArray ( cJSON * array , int which ) { cJSON * c = array -> child ; while ( c && which > 0 ) { c = c -> next ; -- which ; } if ( ! c ) return 0 ; if ( c -> prev ) c -> prev -> next = c -> next ; if ( c -> next ) c -> next -> prev = c -> prev ; if ( c == array -> child ) array -> child = c -> next ; c -> prev = c -> next = 0 ; return c ; } "," > 0 ) c = c c -> next , which -- ; if ( ! ",esnet@iperf/91f2fa59e8ed80dfbf400add0164ee0e508e412a,CVE-2016-4303,https://github.com/esnet/iperf/commit/91f2fa59e8ed80dfbf400add0164ee0e508e412a,2016-09-26T14:59Z 1395,CWE-284,"CWE-284 int sandbox ( void * sandbox_arg ) { ( void ) sandbox_arg ; pid_t child_pid = getpid ( ) ; if ( arg_debug ) printf ( ""Initializingchildprocess\\n"" ) ; close ( parent_to_child_fds [ 1 ] ) ; close ( child_to_parent_fds [ 0 ] ) ; wait_for_other ( parent_to_child_fds [ 0 ] ) ; if ( arg_debug && child_pid == 1 ) printf ( ""PIDnamespaceinstalled\\n"" ) ; if ( cfg . hostname ) { if ( sethostname ( cfg . hostname , strlen ( cfg . hostname ) ) < 0 ) errExit ( ""sethostname"" ) ; } if ( mount ( NULL , ""/"" , NULL , MS_SLAVE | MS_REC , NULL ) < 0 ) { chk_chroot ( ) ; } preproc_mount_mnt_dir ( ) ; if ( mount ( LIBDIR ""/firejail"" , RUN_FIREJAIL_LIB_DIR , ""none"" , MS_BIND , NULL ) < 0 ) errExit ( ""mounting"" RUN_FIREJAIL_LIB_DIR ) ; if ( cfg . name ) fs_logger2 ( ""sandboxname:"" , cfg . name ) ; fs_logger2int ( ""sandboxpid:"" , ( int ) sandbox_pid ) ; if ( cfg . chrootdir ) fs_logger ( ""sandboxfilesystem:chroot"" ) ; else if ( arg_overlay ) fs_logger ( ""sandboxfilesystem:overlay"" ) ; else fs_logger ( ""sandboxfilesystem:local"" ) ; fs_logger ( ""installmountnamespace"" ) ; if ( arg_netfilter && any_bridge_configured ( ) ) { netfilter ( arg_netfilter_file ) ; } if ( arg_netfilter6 && any_bridge_configured ( ) ) { netfilter6 ( arg_netfilter6_file ) ; } int gw_cfg_failed = 0 ; if ( arg_nonetwork ) { net_if_up ( ""lo"" ) ; if ( arg_debug ) printf ( ""Networknamespaceenabled,onlyloopbackinterfaceavailable\\n"" ) ; } else if ( arg_netns ) { netns ( arg_netns ) ; if ( arg_debug ) printf ( ""Networknamespace\'%s\'activated\\n"" , arg_netns ) ; } else if ( any_bridge_configured ( ) || any_interface_configured ( ) ) { net_if_up ( ""lo"" ) ; if ( mac_not_zero ( cfg . bridge0 . macsandbox ) ) net_config_mac ( cfg . bridge0 . devsandbox , cfg . bridge0 . macsandbox ) ; sandbox_if_up ( & cfg . bridge0 ) ; if ( mac_not_zero ( cfg . bridge1 . macsandbox ) ) net_config_mac ( cfg . bridge1 . devsandbox , cfg . bridge1 . macsandbox ) ; sandbox_if_up ( & cfg . bridge1 ) ; if ( mac_not_zero ( cfg . bridge2 . macsandbox ) ) net_config_mac ( cfg . bridge2 . devsandbox , cfg . bridge2 . macsandbox ) ; sandbox_if_up ( & cfg . bridge2 ) ; if ( mac_not_zero ( cfg . bridge3 . macsandbox ) ) net_config_mac ( cfg . bridge3 . devsandbox , cfg . bridge3 . macsandbox ) ; sandbox_if_up ( & cfg . bridge3 ) ; if ( cfg . interface0 . configured && cfg . interface0 . ip ) { if ( arg_debug ) printf ( ""Configuring%d.%d.%d.%daddressoninterface%s\\n"" , PRINT_IP ( cfg . interface0 . ip ) , cfg . interface0 . dev ) ; net_config_interface ( cfg . interface0 . dev , cfg . interface0 . ip , cfg . interface0 . mask , cfg . interface0 . mtu ) ; } if ( cfg . interface1 . configured && cfg . interface1 . ip ) { if ( arg_debug ) printf ( ""Configuring%d.%d.%d.%daddressoninterface%s\\n"" , PRINT_IP ( cfg . interface1 . ip ) , cfg . interface1 . dev ) ; net_config_interface ( cfg . interface1 . dev , cfg . interface1 . ip , cfg . interface1 . mask , cfg . interface1 . mtu ) ; } if ( cfg . interface2 . configured && cfg . interface2 . ip ) { if ( arg_debug ) printf ( ""Configuring%d.%d.%d.%daddressoninterface%s\\n"" , PRINT_IP ( cfg . interface2 . ip ) , cfg . interface2 . dev ) ; net_config_interface ( cfg . interface2 . dev , cfg . interface2 . ip , cfg . interface2 . mask , cfg . interface2 . mtu ) ; } if ( cfg . interface3 . configured && cfg . interface3 . ip ) { if ( arg_debug ) printf ( ""Configuring%d.%d.%d.%daddressoninterface%s\\n"" , PRINT_IP ( cfg . interface3 . ip ) , cfg . interface3 . dev ) ; net_config_interface ( cfg . interface3 . dev , cfg . interface3 . ip , cfg . interface3 . mask , cfg . interface3 . mtu ) ; } if ( cfg . defaultgw ) { if ( net_add_route ( 0 , 0 , cfg . defaultgw ) ) { fwarning ( ""cannotconfiguredefaultroute\\n"" ) ; gw_cfg_failed = 1 ; } } if ( arg_debug ) printf ( ""Networknamespaceenabled\\n"" ) ; } if ( ! arg_quiet ) { if ( any_bridge_configured ( ) || any_interface_configured ( ) || cfg . defaultgw || cfg . dns1 ) { fmessage ( ""\\n"" ) ; if ( any_bridge_configured ( ) || any_interface_configured ( ) ) { if ( arg_scan ) sbox_run ( SBOX_ROOT | SBOX_CAPS_NETWORK | SBOX_SECCOMP , 3 , PATH_FNET , ""printif"" , ""scan"" ) ; else sbox_run ( SBOX_ROOT | SBOX_CAPS_NETWORK | SBOX_SECCOMP , 2 , PATH_FNET , ""printif"" ) ; } if ( cfg . defaultgw != 0 ) { if ( gw_cfg_failed ) fmessage ( ""Defaultgatewayconfigurationfailed\\n"" ) ; else fmessage ( ""Defaultgateway%d.%d.%d.%d\\n"" , PRINT_IP ( cfg . defaultgw ) ) ; } if ( cfg . dns1 != NULL ) fmessage ( ""DNSserver%s\\n"" , cfg . dns1 ) ; if ( cfg . dns2 != NULL ) fmessage ( ""DNSserver%s\\n"" , cfg . dns2 ) ; if ( cfg . dns3 != NULL ) fmessage ( ""DNSserver%s\\n"" , cfg . dns3 ) ; if ( cfg . dns4 != NULL ) fmessage ( ""DNSserver%s\\n"" , cfg . dns4 ) ; fmessage ( ""\\n"" ) ; } } if ( arg_nonetwork || any_bridge_configured ( ) || any_interface_configured ( ) ) { } else { EUID_USER ( ) ; env_ibus_load ( ) ; EUID_ROOT ( ) ; } # ifdef HAVE_SECCOMP if ( cfg . protocol ) { if ( arg_debug ) printf ( ""Buildprotocolfilter:%s\\n"" , cfg . protocol ) ; int rv = sbox_run ( SBOX_USER | SBOX_CAPS_NONE | SBOX_SECCOMP , 5 , PATH_FSECCOMP , ""protocol"" , ""build"" , cfg . protocol , RUN_SECCOMP_PROTOCOL ) ; if ( rv ) exit ( rv ) ; } if ( arg_seccomp && ( cfg . seccomp_list || cfg . seccomp_list_drop || cfg . seccomp_list_keep ) ) arg_seccomp_postexec = 1 ; # endif bool need_preload = arg_trace || arg_tracelog || arg_seccomp_postexec ; if ( getuid ( ) != 0 && ( arg_appimage || cfg . chrootdir || arg_overlay ) ) { enforce_filters ( ) ; need_preload = arg_trace || arg_tracelog ; } if ( need_preload ) fs_trace_preload ( ) ; if ( cfg . hosts_file ) fs_store_hosts_file ( ) ; # ifdef HAVE_CHROOT if ( cfg . chrootdir ) { fs_chroot ( cfg . chrootdir ) ; if ( need_preload ) fs_trace_preload ( ) ; } else # endif # ifdef HAVE_OVERLAYFS if ( arg_overlay ) fs_overlayfs ( ) ; else # endif fs_basic_fs ( ) ; if ( arg_private ) { if ( cfg . home_private ) { if ( cfg . chrootdir ) fwarning ( ""private=directoryfeatureisdisabledinchroot\\n"" ) ; else if ( arg_overlay ) fwarning ( ""private=directoryfeatureisdisabledinoverlay\\n"" ) ; else fs_private_homedir ( ) ; } else if ( cfg . home_private_keep ) { if ( cfg . chrootdir ) fwarning ( ""private-home=featureisdisabledinchroot\\n"" ) ; else if ( arg_overlay ) fwarning ( ""private-home=featureisdisabledinoverlay\\n"" ) ; else fs_private_home_list ( ) ; } else fs_private ( ) ; } if ( arg_private_dev ) fs_private_dev ( ) ; if ( arg_private_etc ) { if ( cfg . chrootdir ) fwarning ( ""private-etcfeatureisdisabledinchroot\\n"" ) ; else if ( arg_overlay ) fwarning ( ""private-etcfeatureisdisabledinoverlay\\n"" ) ; else { fs_private_dir_list ( ""/etc"" , RUN_ETC_DIR , cfg . etc_private_keep ) ; if ( need_preload ) fs_trace_preload ( ) ; } } if ( arg_private_opt ) { if ( cfg . chrootdir ) fwarning ( ""private-optfeatureisdisabledinchroot\\n"" ) ; else if ( arg_overlay ) fwarning ( ""private-optfeatureisdisabledinoverlay\\n"" ) ; else { fs_private_dir_list ( ""/opt"" , RUN_OPT_DIR , cfg . opt_private_keep ) ; } } if ( arg_private_srv ) { if ( cfg . chrootdir ) fwarning ( ""private-srvfeatureisdisabledinchroot\\n"" ) ; else if ( arg_overlay ) fwarning ( ""private-srvfeatureisdisabledinoverlay\\n"" ) ; else { fs_private_dir_list ( ""/srv"" , RUN_SRV_DIR , cfg . srv_private_keep ) ; } } if ( arg_private_bin && ! arg_appimage ) { if ( cfg . chrootdir ) fwarning ( ""private-binfeatureisdisabledinchroot\\n"" ) ; else if ( arg_overlay ) fwarning ( ""private-binfeatureisdisabledinoverlay\\n"" ) ; else { if ( arg_x11_xorg ) { EUID_USER ( ) ; char * tmp ; if ( asprintf ( & tmp , ""%s,xauth"" , cfg . bin_private_keep ) == - 1 ) errExit ( ""asprintf"" ) ; cfg . bin_private_keep = tmp ; EUID_ROOT ( ) ; } fs_private_bin_list ( ) ; } } if ( arg_private_lib && ! arg_appimage ) { if ( cfg . chrootdir ) fwarning ( ""private-libfeatureisdisabledinchroot\\n"" ) ; else if ( arg_overlay ) fwarning ( ""private-libfeatureisdisabledinoverlay\\n"" ) ; else { fs_private_lib ( ) ; } } if ( arg_private_cache ) { if ( cfg . chrootdir ) fwarning ( ""private-cachefeatureisdisabledinchroot\\n"" ) ; else if ( arg_overlay ) fwarning ( ""private-cachefeatureisdisabledinoverlay\\n"" ) ; else fs_private_cache ( ) ; } if ( arg_private_tmp ) { EUID_USER ( ) ; fs_private_tmp ( ) ; EUID_ROOT ( ) ; } if ( arg_nodbus ) dbus_session_disable ( ) ; if ( cfg . hostname ) fs_hostname ( cfg . hostname ) ; if ( cfg . hosts_file ) fs_mount_hosts_file ( ) ; if ( arg_netns ) netns_mounts ( arg_netns ) ; fs_proc_sys_dev_boot ( ) ; if ( checkcfg ( CFG_DISABLE_MNT ) ) fs_mnt ( 1 ) ; else if ( arg_disable_mnt ) fs_mnt ( 0 ) ; fs_whitelist ( ) ; fs_blacklist ( ) ; if ( arg_nosound ) { pulseaudio_disable ( ) ; fs_dev_disable_sound ( ) ; } else if ( ! arg_noautopulse ) pulseaudio_init ( ) ; if ( arg_no3d ) fs_dev_disable_3d ( ) ; if ( arg_notv ) fs_dev_disable_tv ( ) ; if ( arg_nodvd ) fs_dev_disable_dvd ( ) ; if ( arg_nou2f ) fs_dev_disable_u2f ( ) ; if ( arg_novideo ) fs_dev_disable_video ( ) ; if ( need_preload ) fs_trace ( ) ; fs_resolvconf ( ) ; fs_logger_print ( ) ; fs_logger_change_owner ( ) ; EUID_USER ( ) ; int cwd = 0 ; if ( cfg . cwd ) { if ( chdir ( cfg . cwd ) == 0 ) cwd = 1 ; } if ( ! cwd ) { if ( chdir ( ""/"" ) < 0 ) errExit ( ""chdir"" ) ; if ( cfg . homedir ) { struct stat s ; if ( stat ( cfg . homedir , & s ) == 0 ) { if ( chdir ( cfg . homedir ) < 0 ) errExit ( ""chdir"" ) ; } } } if ( arg_debug ) { char * cpath = get_current_dir_name ( ) ; if ( cpath ) { printf ( ""Currentdirectory:%s\\n"" , cpath ) ; free ( cpath ) ; } } EUID_ROOT ( ) ; fs_x11 ( ) ; if ( arg_x11_xorg ) x11_xorg ( ) ; save_umask ( ) ; save_nonewprivs ( ) ; set_caps ( ) ; save_cpu ( ) ; save_cgroup ( ) ; # ifdef HAVE_SECCOMP # ifdef SYS_socket if ( cfg . protocol ) { if ( arg_debug ) printf ( ""Installprotocolfilter:%s\\n"" , cfg . protocol ) ; seccomp_load ( RUN_SECCOMP_PROTOCOL ) ; protocol_filter_save ( ) ; } else { int rv = unlink ( RUN_SECCOMP_PROTOCOL ) ; ( void ) rv ; } # endif if ( arg_seccomp == 1 ) { if ( cfg . seccomp_list_keep ) seccomp_filter_keep ( ) ; else seccomp_filter_drop ( ) ; } else { int rv = unlink ( RUN_SECCOMP_CFG ) ; rv |= unlink ( RUN_SECCOMP_32 ) ; ( void ) rv ; } if ( arg_memory_deny_write_execute ) { if ( arg_debug ) printf ( ""Installmemorywrite&executefilter\\n"" ) ; seccomp_load ( RUN_SECCOMP_MDWX ) ; } else { int rv = unlink ( RUN_SECCOMP_MDWX ) ; ( void ) rv ; } # endif FILE * rj = create_ready_for_join_file ( ) ; save_nogroups ( ) ; if ( arg_noroot ) { int rv = unshare ( CLONE_NEWUSER ) ; if ( rv == - 1 ) { fwarning ( ""cannotcreateanewusernamespace,goingforwardwithoutit...\\n"" ) ; arg_noroot = 0 ; } } notify_other ( child_to_parent_fds [ 1 ] ) ; close ( child_to_parent_fds [ 1 ] ) ; wait_for_other ( parent_to_child_fds [ 0 ] ) ; close ( parent_to_child_fds [ 0 ] ) ; if ( arg_noroot ) { if ( arg_debug ) printf ( ""norootusernamespaceinstalled\\n"" ) ; set_caps ( ) ; } if ( arg_nonewprivs ) { prctl ( PR_SET_NO_NEW_PRIVS , 1 , 0 , 0 , 0 ) ; if ( prctl ( PR_GET_NO_NEW_PRIVS , 0 , 0 , 0 , 0 ) != 1 ) { fwarning ( ""cannotsetNO_NEW_PRIVS,itrequiresaLinuxkernelversion3.5ornewer.\\n"" ) ; if ( force_nonewprivs ) { fprintf ( stderr , ""Error:NO_NEW_PRIVSrequiredforthissandbox,exiting...\\n"" ) ; exit ( 1 ) ; } } else if ( arg_debug ) printf ( ""NO_NEW_PRIVSset\\n"" ) ; } drop_privs ( arg_nogroups ) ; prctl ( PR_SET_PDEATHSIG , SIGKILL , 0 , 0 , 0 ) ; if ( cfg . cpus ) set_cpu_affinity ( ) ; pid_t app_pid = fork ( ) ; if ( app_pid == - 1 ) errExit ( ""fork"" ) ; if ( app_pid == 0 ) { # ifdef HAVE_APPARMOR if ( checkcfg ( CFG_APPARMOR ) && arg_apparmor ) { errno = 0 ; if ( aa_change_onexec ( ""firejail-default"" ) ) { fwarning ( ""CannotconfinetheapplicationusingAppArmor.\\n"" ""Maybefirejail-defaultAppArmorprofileisnotloadedintothekernel.\\n"" ""Asroot,run\\""aa-enforcefirejail-default\\""toloadit.\\n"" ) ; } else if ( arg_debug ) printf ( ""AppArmorenabled\\n"" ) ; } # endif if ( arg_nice ) set_nice ( cfg . nice ) ; set_rlimits ( ) ; start_application ( 0 , rj ) ; } fclose ( rj ) ; int status = monitor_application ( app_pid ) ; flush_stdin ( ) ; if ( WIFEXITED ( status ) ) { return WEXITSTATUS ( status ) ; } else { return - 1 ; } } "," ( ) ; save_cpu ( ) rv ; } fs_rdonly ( RUN_SECCOMP_DIR ) ; # endif set_caps ( ) ; FILE * rj ",netblue30@firejail/eecf35c2f8249489a1d3e512bb07f0d427183134,CVE-2019-12589,https://github.com/netblue30/firejail/commit/eecf35c2f8249489a1d3e512bb07f0d427183134,2019-06-03T03:29Z 1396,CWE-119,"CWE-119 void PNGAPI png_info_init_3 ( png_infopp ptr_ptr , png_size_t png_info_struct_size ) { png_infop info_ptr = * ptr_ptr ; png_debug ( 1 , ""inpng_info_init_3"" ) ; if ( info_ptr == NULL ) return ; if ( png_sizeof ( png_info ) > png_info_struct_size ) { png_destroy_struct ( info_ptr ) ; info_ptr = ( png_infop ) png_create_struct ( PNG_STRUCT_INFO ) ; * ptr_ptr = info_ptr ; } png_memset ( info_ptr , 0 , png_sizeof ( png_info ) ) ; } "," = info_ptr ; if ( info_ptr == NULL ) return ; ",chromium@chromium/7f3d85b096f66870a15b37c2f40b219b2e292693,CVE-2015-8126,https://github.com/chromium/chromium/commit/7f3d85b096f66870a15b37c2f40b219b2e292693,2015-11-13T03:59Z 1397,CWE-787,"CWE-787 static OPJ_BOOL opj_j2k_write_sod ( opj_j2k_t * p_j2k , opj_tcd_t * p_tile_coder , OPJ_BYTE * p_data , OPJ_UINT32 * p_data_written , OPJ_UINT32 p_total_data_size , const opj_stream_private_t * p_stream , opj_event_mgr_t * p_manager ) { opj_codestream_info_t * l_cstr_info = 00 ; OPJ_UINT32 l_remaining_data ; assert ( p_j2k != 00 ) ; assert ( p_manager != 00 ) ; assert ( p_stream != 00 ) ; OPJ_UNUSED ( p_stream ) ; opj_write_bytes ( p_data , J2K_MS_SOD , 2 ) ; p_data += 2 ; l_remaining_data = p_total_data_size - 4 ; p_tile_coder -> tp_num = p_j2k -> m_specific_param . m_encoder . m_current_poc_tile_part_number ; p_tile_coder -> cur_tp_num = p_j2k -> m_specific_param . m_encoder . m_current_tile_part_number ; # ifdef USE_JPWL assert ( 0 && ""TODO"" ) ; # endif if ( p_j2k -> m_specific_param . m_encoder . m_current_tile_part_number == 0 ) { p_tile_coder -> tcd_image -> tiles -> packno = 0 ; if ( l_cstr_info ) { l_cstr_info -> packno = 0 ; } } * p_data_written = 0 ; if ( ! opj_tcd_encode_tile ( p_tile_coder , p_j2k -> m_current_tile_number , p_data , p_data_written , l_remaining_data , l_cstr_info , p_manager ) ) { opj_event_msg ( p_manager , EVT_ERROR , ""Cannotencodetile\\n"" ) ; return OPJ_FALSE ; } * p_data_written += 2 ; return OPJ_TRUE ; } "," p_stream ) ; if ( p_total_data_size < 4 ) { opj_event_msg ( p_manager , EVT_ERROR , ""NotenoughbytesinoutputbuffertowriteSODmarker\\n"" ) ; return OPJ_FALSE ; } ",uclouvain@openjpeg/c535531f03369623b9b833ef41952c62257b507e,CVE-2017-14039,https://github.com/uclouvain/openjpeg/commit/c535531f03369623b9b833ef41952c62257b507e,2017-08-30T22:29Z 1398,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 1399,CWE-787,"CWE-787 int mwifiex_ret_wmm_get_status ( struct mwifiex_private * priv , const struct host_cmd_ds_command * resp ) { u8 * curr = ( u8 * ) & resp -> params . get_wmm_status ; uint16_t resp_len = le16_to_cpu ( resp -> size ) , tlv_len ; int mask = IEEE80211_WMM_IE_AP_QOSINFO_PARAM_SET_CNT_MASK ; bool valid = true ; struct mwifiex_ie_types_data * tlv_hdr ; struct mwifiex_ie_types_wmm_queue_status * tlv_wmm_qstatus ; struct ieee_types_wmm_parameter * wmm_param_ie = NULL ; struct mwifiex_wmm_ac_status * ac_status ; mwifiex_dbg ( priv -> adapter , INFO , ""info:WMM:WMM_GET_STATUScmdrespreceived:%d\\n"" , resp_len ) ; while ( ( resp_len >= sizeof ( tlv_hdr -> header ) ) && valid ) { tlv_hdr = ( struct mwifiex_ie_types_data * ) curr ; tlv_len = le16_to_cpu ( tlv_hdr -> header . len ) ; if ( resp_len < tlv_len + sizeof ( tlv_hdr -> header ) ) break ; switch ( le16_to_cpu ( tlv_hdr -> header . type ) ) { case TLV_TYPE_WMMQSTATUS : tlv_wmm_qstatus = ( struct mwifiex_ie_types_wmm_queue_status * ) tlv_hdr ; mwifiex_dbg ( priv -> adapter , CMD , ""info:CMD_RESP:WMM_GET_STATUS:\\t"" ""QSTATUSTLV:%d,%d,%d\\n"" , tlv_wmm_qstatus -> queue_index , tlv_wmm_qstatus -> flow_required , tlv_wmm_qstatus -> disabled ) ; ac_status = & priv -> wmm . ac_status [ tlv_wmm_qstatus -> queue_index ] ; ac_status -> disabled = tlv_wmm_qstatus -> disabled ; ac_status -> flow_required = tlv_wmm_qstatus -> flow_required ; ac_status -> flow_created = tlv_wmm_qstatus -> flow_created ; break ; case WLAN_EID_VENDOR_SPECIFIC : wmm_param_ie = ( struct ieee_types_wmm_parameter * ) ( curr + 2 ) ; wmm_param_ie -> vend_hdr . len = ( u8 ) tlv_len ; wmm_param_ie -> vend_hdr . element_id = WLAN_EID_VENDOR_SPECIFIC ; mwifiex_dbg ( priv -> adapter , CMD , ""info:CMD_RESP:WMM_GET_STATUS:\\t"" ""WMMParameterSetCount:%d\\n"" , wmm_param_ie -> qos_info_bitmap & mask ) ; memcpy ( ( u8 * ) & priv -> curr_bss_params . bss_descriptor . wmm_ie , wmm_param_ie , wmm_param_ie -> vend_hdr . len + 2 ) ; break ; default : valid = false ; break ; } curr += ( tlv_len + sizeof ( tlv_hdr -> header ) ) ; resp_len -= ( tlv_len + sizeof ( tlv_hdr -> header ) ) ; } mwifiex_wmm_setup_queue_priorities ( priv , wmm_param_ie ) ; mwifiex_wmm_setup_ac_downgrade ( priv ) ; return 0 ; } "," mask ) ; if ( wmm_param_ie -> vend_hdr . len + 2 > sizeof ( struct ieee_types_wmm_parameter ) ) break ; ",torvalds@linux/3a9b153c5591548612c3955c9600a98150c81875,CVE-2020-12654,https://github.com/torvalds/linux/commit/3a9b153c5591548612c3955c9600a98150c81875,2020-05-05T05:15Z 1400,CWE-284,"CWE-284 static void toggle_os_keylockstates ( int fd , int changedlockstates ) { BTIF_TRACE_EVENT ( ""%s:fd=%d,changedlockstates=0x%x"" , __FUNCTION__ , fd , changedlockstates ) ; UINT8 hidreport [ 9 ] ; int reportIndex ; memset ( hidreport , 0 , 9 ) ; hidreport [ 0 ] = 1 ; reportIndex = 4 ; if ( changedlockstates & BTIF_HH_KEYSTATE_MASK_CAPSLOCK ) { BTIF_TRACE_DEBUG ( ""%sSettingCAPSLOCK"" , __FUNCTION__ ) ; hidreport [ reportIndex ++ ] = ( UINT8 ) HID_REPORT_CAPSLOCK ; } if ( changedlockstates & BTIF_HH_KEYSTATE_MASK_NUMLOCK ) { BTIF_TRACE_DEBUG ( ""%sSettingNUMLOCK"" , __FUNCTION__ ) ; hidreport [ reportIndex ++ ] = ( UINT8 ) HID_REPORT_NUMLOCK ; } if ( changedlockstates & BTIF_HH_KEYSTATE_MASK_SCROLLLOCK ) { BTIF_TRACE_DEBUG ( ""%sSettingSCROLLLOCK"" , __FUNCTION__ ) ; hidreport [ reportIndex ++ ] = ( UINT8 ) HID_REPORT_SCROLLLOCK ; } BTIF_TRACE_DEBUG ( ""Writinghidreport#1toos:"" ""%s:%x%x%x"" , __FUNCTION__ , hidreport [ 0 ] , hidreport [ 1 ] , hidreport [ 2 ] ) ; BTIF_TRACE_DEBUG ( ""%s:%x%x%x"" , __FUNCTION__ , hidreport [ 3 ] , hidreport [ 4 ] , hidreport [ 5 ] ) ; BTIF_TRACE_DEBUG ( ""%s:%x%x%x"" , __FUNCTION__ , hidreport [ 6 ] , hidreport [ 7 ] , hidreport [ 8 ] ) ; bta_hh_co_write ( fd , hidreport , sizeof ( hidreport ) ) ; usleep ( 200000 ) ; memset ( hidreport , 0 , 9 ) ; hidreport [ 0 ] = 1 ; BTIF_TRACE_DEBUG ( ""Writinghidreport#2toos:"" ""%s:%x%x%x"" , __FUNCTION__ , hidreport [ 0 ] , hidreport [ 1 ] , hidreport [ 2 ] ) ; BTIF_TRACE_DEBUG ( ""%s:%x%x%x"" , __FUNCTION__ , hidreport [ 3 ] , hidreport [ 4 ] , hidreport [ 5 ] ) ; BTIF_TRACE_DEBUG ( ""%s:%x%x%x"" , __FUNCTION__ , hidreport [ 6 ] , hidreport [ 7 ] , hidreport [ 8 ] ) ; bta_hh_co_write ( fd , hidreport , sizeof ( hidreport ) ) ; } "," ) ) ; TEMP_FAILURE_RETRY ( usleep ( 200000 ) ",system@bt/472271b153c5dc53c28beac55480a8d8434b2d5c,CVE-2016-3839,https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c,2016-08-05T20:59Z 1401,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 1402,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 1403,CWE-416,"CWE-416 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 1404,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 1405,CWE-416,"CWE-416 struct sock * cookie_v6_check ( struct sock * sk , struct sk_buff * skb ) { struct tcp_options_received tcp_opt ; struct inet_request_sock * ireq ; struct tcp_request_sock * treq ; struct ipv6_pinfo * np = inet6_sk ( sk ) ; 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 dst_entry * dst ; __u8 rcv_wscale ; if ( ! sysctl_tcp_syncookies || ! th -> ack || th -> rst ) goto out ; if ( tcp_synq_no_recent_overflow ( sk ) ) goto out ; mss = __cookie_v6_check ( ipv6_hdr ( skb ) , th , cookie ) ; if ( mss == 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 , 0 , NULL ) ; if ( ! cookie_timestamp_decode ( & tcp_opt ) ) goto out ; ret = NULL ; req = inet_reqsk_alloc ( & tcp6_request_sock_ops , sk , false ) ; if ( ! req ) goto out ; ireq = inet_rsk ( req ) ; treq = tcp_rsk ( req ) ; treq -> tfo_listener = false ; if ( security_inet_conn_request ( sk , skb , req ) ) goto out_free ; req -> mss = mss ; ireq -> ir_rmt_port = th -> source ; ireq -> ir_num = ntohs ( th -> dest ) ; ireq -> ir_v6_rmt_addr = ipv6_hdr ( skb ) -> saddr ; ireq -> ir_v6_loc_addr = ipv6_hdr ( skb ) -> daddr ; if ( ipv6_opt_accepted ( sk , skb , & TCP_SKB_CB ( skb ) -> header . h6 ) || np -> rxopt . bits . rxinfo || np -> rxopt . bits . rxoinfo || np -> rxopt . bits . rxhlim || np -> rxopt . bits . rxohlim ) { atomic_inc ( & skb -> users ) ; ireq -> pktopts = skb ; } ireq -> ir_iif = sk -> sk_bound_dev_if ; if ( ! sk -> sk_bound_dev_if && ipv6_addr_type ( & ireq -> ir_v6_rmt_addr ) & IPV6_ADDR_LINKLOCAL ) ireq -> ir_iif = tcp_v6_iif ( skb ) ; ireq -> ir_mark = inet_request_mark ( sk , skb ) ; req -> num_retrans = 0 ; 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 ; treq -> snt_synack . v64 = 0 ; treq -> rcv_isn = ntohl ( th -> seq ) - 1 ; treq -> snt_isn = cookie ; { struct in6_addr * final_p , final ; struct flowi6 fl6 ; memset ( & fl6 , 0 , sizeof ( fl6 ) ) ; fl6 . flowi6_proto = IPPROTO_TCP ; fl6 . daddr = ireq -> ir_v6_rmt_addr ; final_p = fl6_update_dst ( & fl6 , np -> opt , & final ) ; fl6 . saddr = ireq -> ir_v6_loc_addr ; fl6 . flowi6_oif = sk -> sk_bound_dev_if ; fl6 . flowi6_mark = ireq -> ir_mark ; fl6 . fl6_dport = ireq -> ir_rmt_port ; fl6 . fl6_sport = inet_sk ( sk ) -> inet_sport ; security_req_classify_flow ( req , flowi6_to_flowi ( & fl6 ) ) ; dst = ip6_dst_lookup_flow ( sk , & fl6 , final_p ) ; if ( IS_ERR ( dst ) ) goto out_free ; } req -> rsk_window_clamp = tp -> window_clamp ? : dst_metric ( dst , RTAX_WINDOW ) ; tcp_select_initial_window ( tcp_full_space ( sk ) , req -> mss , & req -> rsk_rcv_wnd , & req -> rsk_window_clamp , ireq -> wscale_ok , & rcv_wscale , dst_metric ( dst , RTAX_INITRWND ) ) ; ireq -> rcv_wscale = rcv_wscale ; ireq -> ecn_ok = cookie_ecn_ok ( & tcp_opt , sock_net ( sk ) , dst ) ; ret = tcp_get_cookie_sock ( sk , skb , req , dst ) ; out : return ret ; out_free : reqsk_free ( req ) ; return NULL ; } "," & fl6 , rcu_dereference ( np -> opt ) ",torvalds@linux/45f6fad84cc305103b28d73482b344d7f5b76f39,CVE-2016-3841,https://github.com/torvalds/linux/commit/45f6fad84cc305103b28d73482b344d7f5b76f39,2016-08-06T20:59Z 1406,CWE-362,"CWE-362 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 -> 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 ; } "," ; ue -> card = card ; ue -> ",torvalds@linux/07f4d9d74a04aa7c72c5dae0ef97565f28f17b92,CVE-2014-4652,https://github.com/torvalds/linux/commit/07f4d9d74a04aa7c72c5dae0ef97565f28f17b92,2014-07-03T04:22Z 1407,CWE-362,"CWE-362 int ext4_setattr ( struct dentry * dentry , struct iattr * attr ) { struct inode * inode = d_inode ( dentry ) ; int error , rc = 0 ; int orphan = 0 ; const unsigned int ia_valid = attr -> ia_valid ; error = inode_change_ok ( inode , attr ) ; if ( error ) return error ; if ( is_quota_modification ( inode , attr ) ) { error = dquot_initialize ( inode ) ; if ( error ) return error ; } if ( ( ia_valid & ATTR_UID && ! uid_eq ( attr -> ia_uid , inode -> i_uid ) ) || ( ia_valid & ATTR_GID && ! gid_eq ( attr -> ia_gid , inode -> i_gid ) ) ) { handle_t * handle ; handle = ext4_journal_start ( inode , EXT4_HT_QUOTA , ( EXT4_MAXQUOTAS_INIT_BLOCKS ( inode -> i_sb ) + EXT4_MAXQUOTAS_DEL_BLOCKS ( inode -> i_sb ) ) + 3 ) ; if ( IS_ERR ( handle ) ) { error = PTR_ERR ( handle ) ; goto err_out ; } error = dquot_transfer ( inode , attr ) ; if ( error ) { ext4_journal_stop ( handle ) ; return error ; } if ( attr -> ia_valid & ATTR_UID ) inode -> i_uid = attr -> ia_uid ; if ( attr -> ia_valid & ATTR_GID ) inode -> i_gid = attr -> ia_gid ; error = ext4_mark_inode_dirty ( handle , inode ) ; ext4_journal_stop ( handle ) ; } if ( attr -> ia_valid & ATTR_SIZE ) { handle_t * handle ; loff_t oldsize = inode -> i_size ; int shrink = ( attr -> ia_size <= inode -> i_size ) ; if ( ! ( ext4_test_inode_flag ( inode , EXT4_INODE_EXTENTS ) ) ) { struct ext4_sb_info * sbi = EXT4_SB ( inode -> i_sb ) ; if ( attr -> ia_size > sbi -> s_bitmap_maxbytes ) return - EFBIG ; } if ( ! S_ISREG ( inode -> i_mode ) ) return - EINVAL ; if ( IS_I_VERSION ( inode ) && attr -> ia_size != inode -> i_size ) inode_inc_iversion ( inode ) ; if ( ext4_should_order_data ( inode ) && ( attr -> ia_size < inode -> i_size ) ) { error = ext4_begin_ordered_truncate ( inode , attr -> ia_size ) ; if ( error ) goto err_out ; } if ( attr -> ia_size != inode -> i_size ) { handle = ext4_journal_start ( inode , EXT4_HT_INODE , 3 ) ; if ( IS_ERR ( handle ) ) { error = PTR_ERR ( handle ) ; goto err_out ; } if ( ext4_handle_valid ( handle ) && shrink ) { error = ext4_orphan_add ( handle , inode ) ; orphan = 1 ; } if ( ! shrink ) { inode -> i_mtime = ext4_current_time ( inode ) ; inode -> i_ctime = inode -> i_mtime ; } down_write ( & EXT4_I ( inode ) -> i_data_sem ) ; EXT4_I ( inode ) -> i_disksize = attr -> ia_size ; rc = ext4_mark_inode_dirty ( handle , inode ) ; if ( ! error ) error = rc ; if ( ! error ) i_size_write ( inode , attr -> ia_size ) ; up_write ( & EXT4_I ( inode ) -> i_data_sem ) ; ext4_journal_stop ( handle ) ; if ( error ) { if ( orphan ) ext4_orphan_del ( NULL , inode ) ; goto err_out ; } } if ( ! shrink ) pagecache_isize_extended ( inode , oldsize , inode -> i_size ) ; if ( orphan ) { if ( ! ext4_should_journal_data ( inode ) ) { ext4_inode_block_unlocked_dio ( inode ) ; inode_dio_wait ( inode ) ; ext4_inode_resume_unlocked_dio ( inode ) ; } else ext4_wait_for_tail_page_commit ( inode ) ; } truncate_pagecache ( inode , inode -> i_size ) ; if ( shrink ) ext4_truncate ( inode ) ; } if ( ! rc ) { setattr_copy ( inode , attr ) ; mark_inode_dirty ( inode ) ; } if ( orphan && inode -> i_nlink ) ext4_orphan_del ( NULL , inode ) ; if ( ! rc && ( ia_valid & ATTR_MODE ) ) rc = posix_acl_chmod ( inode , inode -> i_mode ) ; err_out : ext4_std_error ( inode -> i_sb , error ) ; if ( ! error ) error = rc ; return error ; } "," ) ; } down_write ( & EXT4_I ( inode ) -> i_mmap_sem ) ; ext4_truncate ( inode ) ; up_write ( & EXT4_I ( inode ) -> i_mmap_sem ",torvalds@linux/ea3d7209ca01da209cda6f0dea8be9cc4b7a933b,CVE-2015-8839,https://github.com/torvalds/linux/commit/ea3d7209ca01da209cda6f0dea8be9cc4b7a933b,2016-05-02T10:59Z 1408,CWE-200,"CWE-200 static void save_bt_to_dump_dir ( const char * bt , const char * exe , const char * reason ) { time_t t = time ( NULL ) ; const char * iso_date = iso_date_string ( & t ) ; uid_t my_euid = ( uid_t ) - 1L ; mode_t mode = DEFAULT_DUMP_DIR_MODE | S_IROTH ; if ( ! ( g_opts & OPT_x ) ) { mode = DEFAULT_DUMP_DIR_MODE ; my_euid = geteuid ( ) ; } pid_t my_pid = getpid ( ) ; char base [ sizeof ( ""xorg-YYYY-MM-DD-hh:mm:ss-%lu-%lu"" ) + 2 * sizeof ( long ) * 3 ] ; sprintf ( base , ""xorg-%s-%lu-%u"" , iso_date , ( long ) my_pid , g_bt_count ) ; char * path = concat_path_file ( debug_dumps_dir , base ) ; struct dump_dir * dd = dd_create ( path , my_euid , mode ) ; if ( dd ) { dd_create_basic_files ( dd , my_euid , NULL ) ; dd_save_text ( dd , FILENAME_ABRT_VERSION , VERSION ) ; dd_save_text ( dd , FILENAME_ANALYZER , ""xorg"" ) ; dd_save_text ( dd , FILENAME_TYPE , ""xorg"" ) ; dd_save_text ( dd , FILENAME_REASON , reason ) ; dd_save_text ( dd , FILENAME_BACKTRACE , bt ) ; if ( ! exe ) { exe = ""/usr/bin/X"" ; if ( access ( ""/usr/bin/Xorg"" , X_OK ) == 0 ) exe = ""/usr/bin/Xorg"" ; } dd_save_text ( dd , FILENAME_EXECUTABLE , exe ) ; dd_close ( dd ) ; notify_new_path ( path ) ; } free ( path ) ; } "," ) ; } if ( g_settings_privatereports ) { if ( ( g_opts & OPT_x ) ) log ( ""NotgoingtomakedumpdirectoriesworldreadablebecausePrivateReportsison"" ) ; mode = DEFAULT_DUMP_DIR_MODE ; my_euid = 0 ; } ",abrt@abrt/8939398b82006ba1fec4ed491339fc075f43fc7c,CVE-2015-1870,https://github.com/abrt/abrt/commit/8939398b82006ba1fec4ed491339fc075f43fc7c,2017-06-26T15:29Z 1409,CWE-119,"CWE-119 IHEVCD_ERROR_T ihevcd_parse_sps ( codec_t * ps_codec ) { IHEVCD_ERROR_T ret = ( IHEVCD_ERROR_T ) IHEVCD_SUCCESS ; WORD32 value ; WORD32 i ; WORD32 vps_id ; WORD32 sps_max_sub_layers ; WORD32 sps_id ; WORD32 sps_temporal_id_nesting_flag ; sps_t * ps_sps ; profile_tier_lvl_info_t s_ptl ; bitstrm_t * ps_bitstrm = & ps_codec -> s_parse . s_bitstrm ; BITS_PARSE ( ""video_parameter_set_id"" , value , ps_bitstrm , 4 ) ; vps_id = value ; vps_id = CLIP3 ( vps_id , 0 , MAX_VPS_CNT - 1 ) ; BITS_PARSE ( ""sps_max_sub_layers_minus1"" , value , ps_bitstrm , 3 ) ; sps_max_sub_layers = value + 1 ; sps_max_sub_layers = CLIP3 ( sps_max_sub_layers , 1 , 7 ) ; BITS_PARSE ( ""sps_temporal_id_nesting_flag"" , value , ps_bitstrm , 1 ) ; sps_temporal_id_nesting_flag = value ; ret = ihevcd_profile_tier_level ( ps_bitstrm , & ( s_ptl ) , 1 , ( sps_max_sub_layers - 1 ) ) ; UEV_PARSE ( ""seq_parameter_set_id"" , value , ps_bitstrm ) ; sps_id = value ; if ( ( sps_id >= MAX_SPS_CNT ) || ( sps_id < 0 ) ) { if ( ps_codec -> i4_sps_done ) return IHEVCD_UNSUPPORTED_SPS_ID ; else sps_id = 0 ; } ps_sps = ( ps_codec -> s_parse . ps_sps_base + MAX_SPS_CNT - 1 ) ; ps_sps -> i1_sps_id = sps_id ; ps_sps -> i1_vps_id = vps_id ; ps_sps -> i1_sps_max_sub_layers = sps_max_sub_layers ; ps_sps -> i1_sps_temporal_id_nesting_flag = sps_temporal_id_nesting_flag ; ps_codec -> i4_sps_id = sps_id ; memcpy ( & ps_sps -> s_ptl , & s_ptl , sizeof ( profile_tier_lvl_info_t ) ) ; UEV_PARSE ( ""chroma_format_idc"" , value , ps_bitstrm ) ; ps_sps -> i1_chroma_format_idc = value ; if ( ps_sps -> i1_chroma_format_idc != CHROMA_FMT_IDC_YUV420 ) { ps_codec -> s_parse . i4_error_code = IHEVCD_UNSUPPORTED_CHROMA_FMT_IDC ; return ( IHEVCD_ERROR_T ) IHEVCD_UNSUPPORTED_CHROMA_FMT_IDC ; } if ( CHROMA_FMT_IDC_YUV444_PLANES == ps_sps -> i1_chroma_format_idc ) { BITS_PARSE ( ""separate_colour_plane_flag"" , value , ps_bitstrm , 1 ) ; ps_sps -> i1_separate_colour_plane_flag = value ; } else { ps_sps -> i1_separate_colour_plane_flag = 0 ; } UEV_PARSE ( ""pic_width_in_luma_samples"" , value , ps_bitstrm ) ; ps_sps -> i2_pic_width_in_luma_samples = value ; UEV_PARSE ( ""pic_height_in_luma_samples"" , value , ps_bitstrm ) ; ps_sps -> i2_pic_height_in_luma_samples = value ; if ( ( 0 >= ps_sps -> i2_pic_width_in_luma_samples ) || ( 0 >= ps_sps -> i2_pic_height_in_luma_samples ) ) return IHEVCD_INVALID_PARAMETER ; ps_sps -> i2_pic_width_in_luma_samples = ALIGN8 ( ps_sps -> i2_pic_width_in_luma_samples ) ; ps_sps -> i2_pic_height_in_luma_samples = ALIGN8 ( ps_sps -> i2_pic_height_in_luma_samples ) ; if ( ( ps_sps -> i2_pic_width_in_luma_samples > ps_codec -> i4_max_wd ) || ( ps_sps -> i2_pic_width_in_luma_samples * ps_sps -> i2_pic_height_in_luma_samples > ps_codec -> i4_max_wd * ps_codec -> i4_max_ht ) || ( ps_sps -> i2_pic_height_in_luma_samples > MAX ( ps_codec -> i4_max_wd , ps_codec -> i4_max_ht ) ) ) { ps_codec -> i4_new_max_wd = ps_sps -> i2_pic_width_in_luma_samples ; ps_codec -> i4_new_max_ht = ps_sps -> i2_pic_height_in_luma_samples ; return ( IHEVCD_ERROR_T ) IHEVCD_UNSUPPORTED_DIMENSIONS ; } BITS_PARSE ( ""pic_cropping_flag"" , value , ps_bitstrm , 1 ) ; ps_sps -> i1_pic_cropping_flag = value ; if ( ps_sps -> i1_pic_cropping_flag ) { UEV_PARSE ( ""pic_crop_left_offset"" , value , ps_bitstrm ) ; ps_sps -> i2_pic_crop_left_offset = value ; UEV_PARSE ( ""pic_crop_right_offset"" , value , ps_bitstrm ) ; ps_sps -> i2_pic_crop_right_offset = value ; UEV_PARSE ( ""pic_crop_top_offset"" , value , ps_bitstrm ) ; ps_sps -> i2_pic_crop_top_offset = value ; UEV_PARSE ( ""pic_crop_bottom_offset"" , value , ps_bitstrm ) ; ps_sps -> i2_pic_crop_bottom_offset = value ; } else { ps_sps -> i2_pic_crop_left_offset = 0 ; ps_sps -> i2_pic_crop_right_offset = 0 ; ps_sps -> i2_pic_crop_top_offset = 0 ; ps_sps -> i2_pic_crop_bottom_offset = 0 ; } UEV_PARSE ( ""bit_depth_luma_minus8"" , value , ps_bitstrm ) ; if ( 0 != value ) return IHEVCD_UNSUPPORTED_BIT_DEPTH ; UEV_PARSE ( ""bit_depth_chroma_minus8"" , value , ps_bitstrm ) ; if ( 0 != value ) return IHEVCD_UNSUPPORTED_BIT_DEPTH ; UEV_PARSE ( ""log2_max_pic_order_cnt_lsb_minus4"" , value , ps_bitstrm ) ; ps_sps -> i1_log2_max_pic_order_cnt_lsb = value + 4 ; BITS_PARSE ( ""sps_sub_layer_ordering_info_present_flag"" , value , ps_bitstrm , 1 ) ; ps_sps -> i1_sps_sub_layer_ordering_info_present_flag = value ; i = ( ps_sps -> i1_sps_sub_layer_ordering_info_present_flag ? 0 : ( ps_sps -> i1_sps_max_sub_layers - 1 ) ) ; for ( ; i < ps_sps -> i1_sps_max_sub_layers ; i ++ ) { UEV_PARSE ( ""max_dec_pic_buffering"" , value , ps_bitstrm ) ; ps_sps -> ai1_sps_max_dec_pic_buffering [ i ] = value + 1 ; UEV_PARSE ( ""num_reorder_pics"" , value , ps_bitstrm ) ; ps_sps -> ai1_sps_max_num_reorder_pics [ i ] = value ; UEV_PARSE ( ""max_latency_increase"" , value , ps_bitstrm ) ; ps_sps -> ai1_sps_max_latency_increase [ i ] = value ; } UEV_PARSE ( ""log2_min_coding_block_size_minus3"" , value , ps_bitstrm ) ; ps_sps -> i1_log2_min_coding_block_size = value + 3 ; UEV_PARSE ( ""log2_diff_max_min_coding_block_size"" , value , ps_bitstrm ) ; ps_sps -> i1_log2_diff_max_min_coding_block_size = value ; UEV_PARSE ( ""log2_min_transform_block_size_minus2"" , value , ps_bitstrm ) ; ps_sps -> i1_log2_min_transform_block_size = value + 2 ; UEV_PARSE ( ""log2_diff_max_min_transform_block_size"" , value , ps_bitstrm ) ; ps_sps -> i1_log2_diff_max_min_transform_block_size = value ; ps_sps -> i1_log2_max_transform_block_size = ps_sps -> i1_log2_min_transform_block_size + ps_sps -> i1_log2_diff_max_min_transform_block_size ; ps_sps -> i1_log2_ctb_size = ps_sps -> i1_log2_min_coding_block_size + ps_sps -> i1_log2_diff_max_min_coding_block_size ; if ( ( ps_sps -> i1_log2_min_coding_block_size < 3 ) || ( ps_sps -> i1_log2_min_transform_block_size < 2 ) || ( ps_sps -> i1_log2_diff_max_min_transform_block_size < 0 ) || ( ps_sps -> i1_log2_max_transform_block_size > ps_sps -> i1_log2_ctb_size ) || ( ps_sps -> i1_log2_ctb_size < 4 ) || ( ps_sps -> i1_log2_ctb_size > 6 ) ) { return IHEVCD_INVALID_PARAMETER ; } ps_sps -> i1_log2_min_pcm_coding_block_size = 0 ; ps_sps -> i1_log2_diff_max_min_pcm_coding_block_size = 0 ; UEV_PARSE ( ""max_transform_hierarchy_depth_inter"" , value , ps_bitstrm ) ; ps_sps -> i1_max_transform_hierarchy_depth_inter = value ; UEV_PARSE ( ""max_transform_hierarchy_depth_intra"" , value , ps_bitstrm ) ; ps_sps -> i1_max_transform_hierarchy_depth_intra = value ; BITS_PARSE ( ""scaling_list_enabled_flag"" , value , ps_bitstrm , 1 ) ; ps_sps -> i1_scaling_list_enable_flag = value ; if ( ps_sps -> i1_scaling_list_enable_flag ) { COPY_DEFAULT_SCALING_LIST ( ps_sps -> pi2_scaling_mat ) ; BITS_PARSE ( ""sps_scaling_list_data_present_flag"" , value , ps_bitstrm , 1 ) ; ps_sps -> i1_sps_scaling_list_data_present_flag = value ; if ( ps_sps -> i1_sps_scaling_list_data_present_flag ) ihevcd_scaling_list_data ( ps_codec , ps_sps -> pi2_scaling_mat ) ; } else { COPY_FLAT_SCALING_LIST ( ps_sps -> pi2_scaling_mat ) ; } BITS_PARSE ( ""asymmetric_motion_partitions_enabled_flag"" , value , ps_bitstrm , 1 ) ; ps_sps -> i1_amp_enabled_flag = value ; BITS_PARSE ( ""sample_adaptive_offset_enabled_flag"" , value , ps_bitstrm , 1 ) ; ps_sps -> i1_sample_adaptive_offset_enabled_flag = value ; BITS_PARSE ( ""pcm_enabled_flag"" , value , ps_bitstrm , 1 ) ; ps_sps -> i1_pcm_enabled_flag = value ; if ( ps_sps -> i1_pcm_enabled_flag ) { BITS_PARSE ( ""pcm_sample_bit_depth_luma"" , value , ps_bitstrm , 4 ) ; ps_sps -> i1_pcm_sample_bit_depth_luma = value + 1 ; BITS_PARSE ( ""pcm_sample_bit_depth_chroma"" , value , ps_bitstrm , 4 ) ; ps_sps -> i1_pcm_sample_bit_depth_chroma = value + 1 ; UEV_PARSE ( ""log2_min_pcm_coding_block_size_minus3"" , value , ps_bitstrm ) ; ps_sps -> i1_log2_min_pcm_coding_block_size = value + 3 ; UEV_PARSE ( ""log2_diff_max_min_pcm_coding_block_size"" , value , ps_bitstrm ) ; ps_sps -> i1_log2_diff_max_min_pcm_coding_block_size = value ; BITS_PARSE ( ""pcm_loop_filter_disable_flag"" , value , ps_bitstrm , 1 ) ; ps_sps -> i1_pcm_loop_filter_disable_flag = value ; } UEV_PARSE ( ""num_short_term_ref_pic_sets"" , value , ps_bitstrm ) ; ps_sps -> i1_num_short_term_ref_pic_sets = value ; ps_sps -> i1_num_short_term_ref_pic_sets = CLIP3 ( ps_sps -> i1_num_short_term_ref_pic_sets , 0 , MAX_STREF_PICS_SPS ) ; for ( i = 0 ; i < ps_sps -> i1_num_short_term_ref_pic_sets ; i ++ ) ihevcd_short_term_ref_pic_set ( ps_bitstrm , & ps_sps -> as_stref_picset [ 0 ] , ps_sps -> i1_num_short_term_ref_pic_sets , i , & ps_sps -> as_stref_picset [ i ] ) ; BITS_PARSE ( ""long_term_ref_pics_present_flag"" , value , ps_bitstrm , 1 ) ; ps_sps -> i1_long_term_ref_pics_present_flag = value ; if ( ps_sps -> i1_long_term_ref_pics_present_flag ) { UEV_PARSE ( ""num_long_term_ref_pics_sps"" , value , ps_bitstrm ) ; ps_sps -> i1_num_long_term_ref_pics_sps = value ; for ( i = 0 ; i < ps_sps -> i1_num_long_term_ref_pics_sps ; i ++ ) { BITS_PARSE ( ""lt_ref_pic_poc_lsb_sps[i]"" , value , ps_bitstrm , ps_sps -> i1_log2_max_pic_order_cnt_lsb ) ; ps_sps -> ai1_lt_ref_pic_poc_lsb_sps [ i ] = value ; BITS_PARSE ( ""used_by_curr_pic_lt_sps_flag[i]"" , value , ps_bitstrm , 1 ) ; ps_sps -> ai1_used_by_curr_pic_lt_sps_flag [ i ] = value ; } } BITS_PARSE ( ""sps_temporal_mvp_enable_flag"" , value , ps_bitstrm , 1 ) ; ps_sps -> i1_sps_temporal_mvp_enable_flag = value ; BITS_PARSE ( ""sps_strong_intra_smoothing_enable_flag"" , value , ps_bitstrm , 1 ) ; ps_sps -> i1_strong_intra_smoothing_enable_flag = value ; BITS_PARSE ( ""vui_parameters_present_flag"" , value , ps_bitstrm , 1 ) ; ps_sps -> i1_vui_parameters_present_flag = value ; if ( ps_sps -> i1_vui_parameters_present_flag ) ihevcd_parse_vui_parameters ( ps_bitstrm , & ps_sps -> s_vui_parameters , ps_sps -> i1_sps_max_sub_layers - 1 ) ; BITS_PARSE ( ""sps_extension_flag"" , value , ps_bitstrm , 1 ) ; { WORD32 numerator ; WORD32 ceil_offset ; ceil_offset = ( 1 << ps_sps -> i1_log2_ctb_size ) - 1 ; numerator = ps_sps -> i2_pic_width_in_luma_samples ; ps_sps -> i2_pic_wd_in_ctb = ( ( numerator + ceil_offset ) / ( 1 << ps_sps -> i1_log2_ctb_size ) ) ; numerator = ps_sps -> i2_pic_height_in_luma_samples ; ps_sps -> i2_pic_ht_in_ctb = ( ( numerator + ceil_offset ) / ( 1 << ps_sps -> i1_log2_ctb_size ) ) ; ps_sps -> i4_pic_size_in_ctb = ps_sps -> i2_pic_ht_in_ctb * ps_sps -> i2_pic_wd_in_ctb ; if ( 0 == ps_codec -> i4_sps_done ) ps_codec -> s_parse . i4_next_ctb_indx = ps_sps -> i4_pic_size_in_ctb ; numerator = ps_sps -> i2_pic_width_in_luma_samples ; ps_sps -> i2_pic_wd_in_min_cb = numerator / ( 1 << ps_sps -> i1_log2_min_coding_block_size ) ; numerator = ps_sps -> i2_pic_height_in_luma_samples ; ps_sps -> i2_pic_ht_in_min_cb = numerator / ( 1 << ps_sps -> i1_log2_min_coding_block_size ) ; } if ( ( 0 != ps_codec -> i4_first_pic_done ) && ( ( ps_codec -> i4_wd != ps_sps -> i2_pic_width_in_luma_samples ) || ( ps_codec -> i4_ht != ps_sps -> i2_pic_height_in_luma_samples ) ) ) { ps_codec -> i4_reset_flag = 1 ; ps_codec -> i4_error_code = IVD_RES_CHANGED ; return ( IHEVCD_ERROR_T ) IHEVCD_FAIL ; } { WORD32 disp_wd , disp_ht ; WORD32 crop_unit_x , crop_unit_y ; crop_unit_x = 1 ; crop_unit_y = 1 ; if ( CHROMA_FMT_IDC_YUV420 == ps_sps -> i1_chroma_format_idc ) { crop_unit_x = 2 ; crop_unit_y = 2 ; } disp_wd = ps_sps -> i2_pic_width_in_luma_samples ; disp_wd -= ps_sps -> i2_pic_crop_left_offset * crop_unit_x ; disp_wd -= ps_sps -> i2_pic_crop_right_offset * crop_unit_x ; disp_ht = ps_sps -> i2_pic_height_in_luma_samples ; disp_ht -= ps_sps -> i2_pic_crop_top_offset * crop_unit_y ; disp_ht -= ps_sps -> i2_pic_crop_bottom_offset * crop_unit_y ; if ( ( 0 >= disp_wd ) || ( 0 >= disp_ht ) ) return IHEVCD_INVALID_PARAMETER ; ps_codec -> i4_disp_wd = disp_wd ; ps_codec -> i4_disp_ht = disp_ht ; ps_codec -> i4_wd = ps_sps -> i2_pic_width_in_luma_samples ; ps_codec -> i4_ht = ps_sps -> i2_pic_height_in_luma_samples ; { WORD32 ref_strd ; ref_strd = ALIGN32 ( ps_sps -> i2_pic_width_in_luma_samples + PAD_WD ) ; if ( ps_codec -> i4_strd < ref_strd ) { ps_codec -> i4_strd = ref_strd ; } } if ( 0 == ps_codec -> i4_share_disp_buf ) { if ( ps_codec -> i4_disp_strd < ps_codec -> i4_disp_wd ) { ps_codec -> i4_disp_strd = ps_codec -> i4_disp_wd ; } } else { if ( ps_codec -> i4_disp_strd < ps_codec -> i4_strd ) { ps_codec -> i4_disp_strd = ps_codec -> i4_strd ; } } } ps_codec -> i4_sps_done = 1 ; return ret ; } "," + 1 ; if ( ps_sps -> ai1_sps_max_dec_pic_buffering [ i ] > MAX_DPB_SIZE ) { return IHEVCD_INVALID_PARAMETER ; } = value ; if ( ps_sps -> ai1_sps_max_num_reorder_pics [ i ] > ps_sps -> ai1_sps_max_dec_pic_buffering [ i ] ) { return IHEVCD_INVALID_PARAMETER ; } ",external@libhevc/1ab5ce7e42feccd49e49752e6f58f9097ac5d254,CVE-2017-0539,https://android.googlesource.com/platform/external/libhevc/+/1ab5ce7e42feccd49e49752e6f58f9097ac5d254,2017-04-07T22:59Z 1410,CWE-416,"CWE-416 static void put_crypt_info ( struct fscrypt_info * ci ) { if ( ! ci ) return ; key_put ( ci -> ci_keyring_key ) ; crypto_free_skcipher ( ci -> ci_ctfm ) ; kmem_cache_free ( fscrypt_info_cachep , ci ) ; } "," ) return ; crypto_free_skcipher ( ci ",torvalds@linux/1b53cf9815bb4744958d41f3795d5d5a1d365e2d,CVE-2017-7374,https://github.com/torvalds/linux/commit/1b53cf9815bb4744958d41f3795d5d5a1d365e2d,2017-03-31T20:59Z 1411,CWE-78,"CWE-78 int imap_subscribe ( char * path , bool subscribe ) { struct ImapData * idata = NULL ; char buf [ LONG_STRING ] ; char mbox [ LONG_STRING ] ; char errstr [ STRING ] ; struct Buffer err , token ; struct ImapMbox mx ; if ( ! mx_is_imap ( path ) || imap_parse_path ( path , & mx ) || ! mx . mbox ) { mutt_error ( _ ( ""Badmailboxname"" ) ) ; return - 1 ; } idata = imap_conn_find ( & ( mx . account ) , 0 ) ; if ( ! idata ) goto fail ; imap_fix_path ( idata , mx . mbox , buf , sizeof ( buf ) ) ; if ( ! * buf ) mutt_str_strfcpy ( buf , ""INBOX"" , sizeof ( buf ) ) ; if ( ImapCheckSubscribed ) { mutt_buffer_init ( & token ) ; mutt_buffer_init ( & err ) ; err . data = errstr ; err . dsize = sizeof ( errstr ) ; snprintf ( mbox , sizeof ( mbox ) , ""%smailboxes\\""%s\\"""" , subscribe ? """" : ""un"" , path ) ; if ( mutt_parse_rc_line ( mbox , & token , & err ) ) mutt_debug ( 1 , ""Erroraddingsubscribedmailbox:%s\\n"" , errstr ) ; FREE ( & token . data ) ; } if ( subscribe ) mutt_message ( _ ( ""Subscribingto%s..."" ) , buf ) ; else mutt_message ( _ ( ""Unsubscribingfrom%s..."" ) , buf ) ; imap_munge_mbox_name ( idata , mbox , sizeof ( mbox ) , buf ) ; snprintf ( buf , sizeof ( buf ) , ""%sSUBSCRIBE%s"" , subscribe ? """" : ""UN"" , mbox ) ; if ( imap_exec ( idata , buf , 0 ) < 0 ) goto fail ; imap_unmunge_mbox_name ( idata , mx . mbox ) ; if ( subscribe ) mutt_message ( _ ( ""Subscribedto%s"" ) , mx . mbox ) ; else mutt_message ( _ ( ""Unsubscribedfrom%s"" ) , mx . mbox ) ; FREE ( & mx . mbox ) ; return 0 ; fail : FREE ( & mx . mbox ) ; return - 1 ; } "," ImapMbox mx ; size_t len = 0 ; errstr ) ; len = mbox ) , ""%smailboxes"" , subscribe ? """" : ""un"" ) ; imap_quote_string ( mbox + len , sizeof ( mbox ) - len , path , true ) ; if ",neomutt@neomutt/95e80bf9ff10f68cb6443f760b85df4117cb15eb,CVE-2018-14354,https://github.com/neomutt/neomutt/commit/95e80bf9ff10f68cb6443f760b85df4117cb15eb,2018-07-17T17:29Z 1412,CWE-125,"CWE-125 static void handle_ppp ( netdissect_options * ndo , u_int proto , const u_char * p , int length ) { if ( ( proto & 0xff00 ) == 0x7e00 ) { ppp_hdlc ( ndo , p - 1 , length ) ; return ; } switch ( proto ) { case PPP_LCP : case PPP_IPCP : case PPP_OSICP : case PPP_MPLSCP : case PPP_IPV6CP : case PPP_CCP : case PPP_BACP : handle_ctrl_proto ( ndo , proto , p , length ) ; break ; case PPP_ML : handle_mlppp ( ndo , p , length ) ; break ; case PPP_CHAP : handle_chap ( ndo , p , length ) ; break ; case PPP_PAP : handle_pap ( ndo , p , length ) ; break ; case PPP_BAP : handle_bap ( ndo , p , length ) ; break ; case ETHERTYPE_IP : case PPP_VJNC : case PPP_IP : ip_print ( ndo , p , length ) ; break ; case ETHERTYPE_IPV6 : case PPP_IPV6 : ip6_print ( ndo , p , length ) ; break ; case ETHERTYPE_IPX : case PPP_IPX : ipx_print ( ndo , p , length ) ; break ; case PPP_OSI : isoclns_print ( ndo , p , length , length ) ; break ; case PPP_MPLS_UCAST : case PPP_MPLS_MCAST : mpls_print ( ndo , p , length ) ; break ; case PPP_COMP : ND_PRINT ( ( ndo , ""compressedPPPdata"" ) ) ; break ; default : ND_PRINT ( ( ndo , ""%s"" , tok2str ( ppptype2str , ""unknownPPPprotocol(0x%04x)"" , proto ) ) ) ; print_unknown_data ( ndo , p , ""\\n\\t"" , length ) ; break ; } } "," p , length ) ; break ",the-tcpdump-group@tcpdump/1dcd10aceabbc03bf571ea32b892c522cbe923de,CVE-2017-12897,https://github.com/the-tcpdump-group/tcpdump/commit/1dcd10aceabbc03bf571ea32b892c522cbe923de,2017-09-14T06:29Z 1413,CWE-20,"CWE-20 void big_key_describe ( const struct key * key , struct seq_file * m ) { size_t datalen = ( size_t ) key -> payload . data [ big_key_len ] ; seq_puts ( m , key -> description ) ; if ( key_is_instantiated ( key ) ) seq_printf ( m , "":%zu[%s]"" , datalen , datalen > BIG_KEY_FILE_THRESHOLD ? ""file"" : ""buff"" ) ; } "," ; if ( key_is_positive ( key ) ",torvalds@linux/363b02dab09b3226f3bd1420dad9c72b79a42a76,CVE-2017-15951,https://github.com/torvalds/linux/commit/363b02dab09b3226f3bd1420dad9c72b79a42a76,2017-10-28T02:29Z 1414,CWE-264,"CWE-264 static int read_exceptions ( struct pstore * ps , int ( * callback ) ( void * callback_context , chunk_t old , chunk_t new ) , void * callback_context ) { int r , full = 1 ; for ( ps -> current_area = 0 ; full ; ps -> current_area ++ ) { r = area_io ( ps , READ ) ; if ( r ) return r ; r = insert_exceptions ( ps , callback , callback_context , & full ) ; if ( r ) return r ; } ps -> current_area -- ; return 0 ; } "," current_area -- ; skip_metadata ( ps ) ; ",torvalds@linux/e9c6a182649f4259db704ae15a91ac820e63b0ca,CVE-2013-4299,https://github.com/torvalds/linux/commit/e9c6a182649f4259db704ae15a91ac820e63b0ca,2013-10-24T10:53Z 1415,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 1416,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 1417,CWE-119,"CWE-119 void vp9_rc_get_one_pass_cbr_params ( VP9_COMP * cpi ) { VP9_COMMON * const cm = & cpi -> common ; RATE_CONTROL * const rc = & cpi -> rc ; int target ; if ( ( cm -> current_video_frame == 0 || ( cm -> frame_flags & FRAMEFLAGS_KEY ) || rc -> frames_to_key == 0 || ( cpi -> oxcf . auto_key && test_for_kf_one_pass ( cpi ) ) ) ) { cm -> frame_type = KEY_FRAME ; rc -> this_key_frame_forced = cm -> current_video_frame != 0 && rc -> frames_to_key == 0 ; rc -> frames_to_key = cpi -> key_frame_frequency ; rc -> kf_boost = DEFAULT_KF_BOOST ; rc -> source_alt_ref_active = 0 ; target = calc_iframe_target_size_one_pass_cbr ( cpi ) ; } else { cm -> frame_type = INTER_FRAME ; target = calc_pframe_target_size_one_pass_cbr ( cpi ) ; } vp9_rc_set_frame_target ( cpi , target ) ; rc -> frames_till_gf_update_due = INT_MAX ; rc -> baseline_gf_interval = INT_MAX ; } "," 0 || ( cpi -> frame_flags & . auto_key && 0 ) ) ) = cpi -> oxcf . key_freq ; rc -> source_alt_ref_active = 0 ; } else = INTER_FRAME ; } if ( rc -> frames_till_gf_update_due == 0 ) { if ( cpi -> oxcf . aq_mode == CYCLIC_REFRESH_AQ ) vp9_cyclic_refresh_set_golden_update ( cpi ) ; else rc -> baseline_gf_interval = ( rc -> min_gf_interval + rc -> max_gf_interval ) / 2 ; rc -> frames_till_gf_update_due = rc -> baseline_gf_interval ; if ( rc -> frames_till_gf_update_due > rc -> frames_to_key ) rc -> frames_till_gf_update_due = rc -> frames_to_key ; cpi -> refresh_golden_frame = 1 ; rc -> gfu_boost = DEFAULT_GF_BOOST ; } if ( cpi -> oxcf . aq_mode == CYCLIC_REFRESH_AQ ) vp9_cyclic_refresh_update_parameters ( cpi ) ; if ( cm -> frame_type == KEY_FRAME ) target = calc_iframe_target_size_one_pass_cbr ( cpi ) ; else target = calc_pframe_target_size_one_pass_cbr ( cpi cpi ) ; vp9_rc_set_frame_target ( cpi target ) ; if ( cpi -> oxcf . resize_mode == RESIZE_DYNAMIC ) cpi -> resize_pending = vp9_resize_one_pass_cbr ( cpi ) ; else cpi -> resize_pending = 0 ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1418,CWE-476,"CWE-476 GF_Err latm_dmx_process ( GF_Filter * filter ) { GF_LATMDmxCtx * ctx = gf_filter_get_udta ( filter ) ; GF_FilterPacket * pck , * dst_pck ; u32 pos ; u8 * data , * output ; u32 pck_size , prev_pck_size ; u64 cts = GF_FILTER_NO_TS ; if ( ctx -> in_error ) return ctx -> in_error ; if ( ! ctx -> duration . num ) latm_dmx_check_dur ( filter , ctx ) ; if ( ctx -> opid && ! ctx -> is_playing ) return GF_OK ; pck = gf_filter_pid_get_packet ( ctx -> ipid ) ; if ( ! pck ) { if ( gf_filter_pid_is_eos ( ctx -> ipid ) ) { if ( ! ctx -> latm_buffer_size ) { if ( ctx -> opid ) gf_filter_pid_set_eos ( ctx -> opid ) ; if ( ctx -> src_pck ) gf_filter_pck_unref ( ctx -> src_pck ) ; ctx -> src_pck = NULL ; return GF_EOS ; } } else { return GF_OK ; } } data = ( char * ) gf_filter_pck_get_data ( pck , & pck_size ) ; if ( ctx -> timescale && pck ) { cts = gf_filter_pck_get_cts ( pck ) ; } prev_pck_size = ctx -> latm_buffer_size ; if ( pck && ! ctx -> resume_from ) { if ( ctx -> latm_buffer_size + pck_size > ctx -> latm_buffer_alloc ) { ctx -> latm_buffer_alloc = ctx -> latm_buffer_size + pck_size ; ctx -> latm_buffer = gf_realloc ( ctx -> latm_buffer , ctx -> latm_buffer_alloc ) ; } memcpy ( ctx -> latm_buffer + ctx -> latm_buffer_size , data , pck_size ) ; ctx -> latm_buffer_size += pck_size ; } if ( ! ctx -> bs ) ctx -> bs = gf_bs_new ( ctx -> latm_buffer , ctx -> latm_buffer_size , GF_BITSTREAM_READ ) ; else gf_bs_reassign_buffer ( ctx -> bs , ctx -> latm_buffer , ctx -> latm_buffer_size ) ; if ( ctx -> resume_from ) { gf_bs_seek ( ctx -> bs , ctx -> resume_from - 1 ) ; ctx -> resume_from = 0 ; } if ( cts == GF_FILTER_NO_TS ) prev_pck_size = 0 ; while ( 1 ) { pos = ( u32 ) gf_bs_get_position ( ctx -> bs ) ; u8 latm_buffer [ 4096 ] ; u32 latm_frame_size = 4096 ; if ( ! latm_dmx_sync_frame_bs ( ctx -> bs , & ctx -> acfg , & latm_frame_size , latm_buffer , NULL ) ) break ; if ( ctx -> in_seek ) { u64 nb_samples_at_seek = ( u64 ) ( ctx -> start_range * GF_M4ASampleRates [ ctx -> sr_idx ] ) ; if ( ctx -> cts + ctx -> dts_inc >= nb_samples_at_seek ) { ctx -> in_seek = GF_FALSE ; } } latm_dmx_check_pid ( filter , ctx ) ; if ( ! ctx -> is_playing ) { ctx -> resume_from = pos + 1 ; return GF_OK ; } if ( ! ctx -> in_seek ) { GF_FilterSAPType sap = GF_FILTER_SAP_1 ; dst_pck = gf_filter_pck_new_alloc ( ctx -> opid , latm_frame_size , & output ) ; if ( ctx -> src_pck ) gf_filter_pck_merge_properties ( ctx -> src_pck , dst_pck ) ; memcpy ( output , latm_buffer , latm_frame_size ) ; gf_filter_pck_set_cts ( dst_pck , ctx -> cts ) ; gf_filter_pck_set_duration ( dst_pck , ctx -> dts_inc ) ; gf_filter_pck_set_framing ( dst_pck , GF_TRUE , GF_TRUE ) ; if ( ctx -> acfg . base_object_type == GF_CODECID_USAC ) { if ( latm_frame_size && ( output [ 0 ] & 0x80 ) && ! ctx -> prev_sap ) { sap = GF_FILTER_SAP_1 ; ctx -> prev_sap = GF_TRUE ; } else { sap = GF_FILTER_SAP_NONE ; ctx -> prev_sap = GF_FALSE ; } } gf_filter_pck_set_sap ( dst_pck , sap ) ; gf_filter_pck_send ( dst_pck ) ; } latm_dmx_update_cts ( ctx ) ; if ( prev_pck_size ) { pos = ( u32 ) gf_bs_get_position ( ctx -> bs ) ; if ( prev_pck_size <= pos ) { prev_pck_size = 0 ; if ( ctx -> src_pck ) gf_filter_pck_unref ( ctx -> src_pck ) ; ctx -> src_pck = pck ; if ( pck ) gf_filter_pck_ref_props ( & ctx -> src_pck ) ; } } } if ( pck ) { pos = ( u32 ) gf_bs_get_position ( ctx -> bs ) ; assert ( ctx -> latm_buffer_size >= pos ) ; memmove ( ctx -> latm_buffer , ctx -> latm_buffer + pos , ctx -> latm_buffer_size - pos ) ; ctx -> latm_buffer_size -= pos ; gf_filter_pid_drop_packet ( ctx -> ipid ) ; assert ( ! ctx -> resume_from ) ; } else { ctx -> latm_buffer_size = 0 ; return latm_dmx_process ( filter ) ; } return GF_OK ; } "," u8 * data = NULL ; u32 pck_size = 0 ; } } else { pck_size ) ; } ",gpac@gpac/b2db2f99b4c30f96e17b9a14537c776da6cb5dca,CVE-2021-30199,https://github.com/gpac/gpac/commit/b2db2f99b4c30f96e17b9a14537c776da6cb5dca,2021-04-19T20:15Z 1419,CWE-119,"CWE-119 int VP8_UVSSE ( MACROBLOCK * x ) { unsigned char * uptr , * vptr ; unsigned char * upred_ptr = ( * ( x -> block [ 16 ] . base_src ) + x -> block [ 16 ] . src ) ; unsigned char * vpred_ptr = ( * ( x -> block [ 20 ] . base_src ) + x -> block [ 20 ] . src ) ; int uv_stride = x -> block [ 16 ] . src_stride ; unsigned int sse1 = 0 ; unsigned int sse2 = 0 ; int mv_row = x -> e_mbd . mode_info_context -> mbmi . mv . as_mv . row ; int mv_col = x -> e_mbd . mode_info_context -> mbmi . mv . as_mv . col ; int offset ; int pre_stride = x -> e_mbd . pre . uv_stride ; if ( mv_row < 0 ) mv_row -= 1 ; else mv_row += 1 ; if ( mv_col < 0 ) mv_col -= 1 ; else mv_col += 1 ; mv_row /= 2 ; mv_col /= 2 ; offset = ( mv_row >> 3 ) * pre_stride + ( mv_col >> 3 ) ; uptr = x -> e_mbd . pre . u_buffer + offset ; vptr = x -> e_mbd . pre . v_buffer + offset ; if ( ( mv_row | mv_col ) & 7 ) { vp8_sub_pixel_variance8x8 ( uptr , pre_stride , mv_col & 7 , mv_row & 7 , upred_ptr , uv_stride , & sse2 ) ; vp8_sub_pixel_variance8x8 ( vptr , pre_stride , mv_col & 7 , mv_row & 7 , vpred_ptr , uv_stride , & sse1 ) ; sse2 += sse1 ; } else { vp8_variance8x8 ( uptr , pre_stride , upred_ptr , uv_stride , & sse2 ) ; vp8_variance8x8 ( vptr , pre_stride , vpred_ptr , uv_stride , & sse1 ) ; sse2 += sse1 ; } return sse2 ; } "," 7 ) { vpx_sub_pixel_variance8x8 ( uptr , sse2 ) ; vpx_sub_pixel_variance8x8 ( vptr , } else { vpx_variance8x8 ( uptr , sse2 ) ; vpx_variance8x8 ( vptr , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1420,CWE-119,"CWE-119 static void super_block_uvrd ( const VP9_COMP * cpi , MACROBLOCK * x , int * rate , int64_t * distortion , int * skippable , int64_t * sse , BLOCK_SIZE bsize , int64_t ref_best_rd ) { MACROBLOCKD * const xd = & x -> e_mbd ; MB_MODE_INFO * const mbmi = & xd -> mi [ 0 ] -> mbmi ; TX_SIZE uv_txfm_size = get_uv_tx_size ( mbmi ) ; int plane ; int pnrate = 0 , pnskip = 1 ; int64_t pndist = 0 , pnsse = 0 ; if ( ref_best_rd < 0 ) goto term ; if ( is_inter_block ( mbmi ) ) { int plane ; for ( plane = 1 ; plane < MAX_MB_PLANE ; ++ plane ) vp9_subtract_plane ( x , bsize , plane ) ; } * rate = 0 ; * distortion = 0 ; * sse = 0 ; * skippable = 1 ; for ( plane = 1 ; plane < MAX_MB_PLANE ; ++ plane ) { txfm_rd_in_plane ( x , & pnrate , & pndist , & pnskip , & pnsse , ref_best_rd , plane , bsize , uv_txfm_size , cpi -> sf . use_fast_coef_costing ) ; if ( pnrate == INT_MAX ) goto term ; * rate += pnrate ; * distortion += pndist ; * sse += pnsse ; * skippable &= pnskip ; } return ; term : * rate = INT_MAX ; * distortion = INT64_MAX ; * sse = INT64_MAX ; * skippable = 0 ; return ; } "," static int super_block_uvrd ( const -> mbmi ; const TX_SIZE uv_tx_size = get_uv_tx_size ( get_uv_tx_size ( mbmi , & xd -> plane [ 1 ] = 0 ; int is_cost_valid = 1 ; < 0 ) is_cost_valid = 0 ; if ( ( mbmi ) && is_cost_valid , bsize , uv_tx_size , cpi -> == INT_MAX ) { is_cost_valid = 0 ; break ; } * rate += pnskip ; } if ( ! is_cost_valid ) { * rate = INT_MAX ; * distortion = INT64_MAX ; * sse = INT64_MAX ; * skippable = 0 ; } return is_cost_valid ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1421,CWE-20,"CWE-20 int sctp_verify_asconf ( const struct sctp_association * asoc , struct sctp_paramhdr * param_hdr , void * chunk_end , struct sctp_paramhdr * * errp ) { sctp_addip_param_t * asconf_param ; union sctp_params param ; int length , plen ; param . v = ( sctp_paramhdr_t * ) param_hdr ; while ( param . v <= chunk_end - sizeof ( sctp_paramhdr_t ) ) { length = ntohs ( param . p -> length ) ; * errp = param . p ; if ( param . v > chunk_end - length || length < sizeof ( sctp_paramhdr_t ) ) return 0 ; switch ( param . p -> type ) { case SCTP_PARAM_ADD_IP : case SCTP_PARAM_DEL_IP : case SCTP_PARAM_SET_PRIMARY : asconf_param = ( sctp_addip_param_t * ) param . v ; plen = ntohs ( asconf_param -> param_hdr . length ) ; if ( plen < sizeof ( sctp_addip_param_t ) + sizeof ( sctp_paramhdr_t ) ) return 0 ; break ; case SCTP_PARAM_SUCCESS_REPORT : case SCTP_PARAM_ADAPTATION_LAYER_IND : if ( length != sizeof ( sctp_addip_param_t ) ) return 0 ; break ; default : break ; } param . v += WORD_ROUND ( length ) ; } if ( param . v != chunk_end ) return 0 ; return 1 ; } "," bool sctp_verify_asconf ( const asoc , struct sctp_chunk * chunk , bool addr_param_needed , struct sctp_paramhdr errp ) { sctp_addip_chunk_t * addip = ( sctp_addip_chunk_t * ) chunk -> chunk_hdr ; union sctp_params sctp_params param ; bool addr_param_seen = false ; sctp_walk_params ( param , addip , addip_hdr . params ) { size_t length = ntohs ( param . p -> length ) ; * errp = param . p ; switch ( param . p -> type ) { case SCTP_PARAM_ERR_CAUSE : break ; case SCTP_PARAM_IPV4_ADDRESS : if ( length != sizeof ( sctp_ipv4addr_param_t ) ) return false ; addr_param_seen = true ; break ; case SCTP_PARAM_IPV6_ADDRESS : if ( length != sizeof ( sctp_ipv6addr_param_t ) ) return false ; addr_param_seen = true ; break ; case SCTP_PARAM_ADD_IP : case SCTP_PARAM_DEL_IP : case SCTP_PARAM_SET_PRIMARY : if ( addr_param_needed && ! addr_param_seen ) return false ; length = ntohs ( param . addip -> param_hdr . length ) ; if ( length < sizeof ( sctp_addip_param_t ) + sizeof ( sctp_paramhdr_t ) ) return false ; break ; case SCTP_PARAM_SUCCESS_REPORT : case SCTP_PARAM_ADAPTATION_LAYER_IND : if ( length != sizeof ( sctp_addip_param_t ) ) return false ; break ; default : return false ; } } if ( addr_param_needed && ! addr_param_seen ) return false ; if ( ! addr_param_needed && addr_param_seen ) return false ; if ( param . v param . v != chunk -> chunk_end ) return false ; return true ; } ",torvalds@linux/9de7922bc709eee2f609cd01d98aaedc4cf5ea74,CVE-2014-3673,https://github.com/torvalds/linux/commit/9de7922bc709eee2f609cd01d98aaedc4cf5ea74,2014-11-10T11:55Z 1422,CWE-000,"CWE-000 static void http_splitheader ( struct http * hp , int req ) { char * p , * q , * * hh ; int n ; char buf [ 20 ] ; CHECK_OBJ_NOTNULL ( hp , HTTP_MAGIC ) ; if ( req ) { memset ( hp -> req , 0 , sizeof hp -> req ) ; hh = hp -> req ; } else { memset ( hp -> resp , 0 , sizeof hp -> resp ) ; hh = hp -> resp ; } n = 0 ; p = hp -> rxbuf ; while ( vct_islws ( * p ) ) p ++ ; hh [ n ++ ] = p ; while ( ! vct_islws ( * p ) ) p ++ ; assert ( ! vct_iscrlf ( * p ) ) ; * p ++ = '\\0' ; while ( vct_issp ( * p ) ) p ++ ; assert ( ! vct_iscrlf ( * p ) ) ; hh [ n ++ ] = p ; while ( ! vct_islws ( * p ) ) p ++ ; if ( vct_iscrlf ( * p ) ) { hh [ n ++ ] = NULL ; q = p ; p += vct_skipcrlf ( p ) ; * q = '\\0' ; } else { * p ++ = '\\0' ; while ( vct_issp ( * p ) ) p ++ ; hh [ n ++ ] = p ; while ( ! vct_iscrlf ( * p ) ) p ++ ; q = p ; p += vct_skipcrlf ( p ) ; * q = '\\0' ; } assert ( n == 3 ) ; while ( * p != '\\0' ) { assert ( n < MAX_HDR ) ; if ( vct_iscrlf ( * p ) ) break ; hh [ n ++ ] = p ++ ; while ( * p != '\\0' && ! vct_iscrlf ( * p ) ) p ++ ; q = p ; p += vct_skipcrlf ( p ) ; * q = '\\0' ; } p += vct_skipcrlf ( p ) ; assert ( * p == '\\0' ) ; for ( n = 0 ; n < 3 || hh [ n ] != NULL ; n ++ ) { sprintf ( buf , ""http[%2d]"" , n ) ; vtc_dump ( hp -> vl , 4 , buf , hh [ n ] , - 1 ) ; } } "," ! vct_iscrlf ( p ) ) ! vct_iscrlf ( p ) ) ( vct_iscrlf ( p ) ) ! vct_iscrlf ( p ) ) ( vct_iscrlf ( p ) ) ! vct_iscrlf ( p ) ) ",varnish@Varnish-Cache/85e8468bec9416bd7e16b0d80cb820ecd2b330c3,CVE-2015-8852,https://github.com/varnish/Varnish-Cache/commit/85e8468bec9416bd7e16b0d80cb820ecd2b330c3,2016-04-25T14:59Z 1423,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 1424,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 1425,CWE-787,"CWE-787 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 1426,CWE-200,"CWE-200 static int hidp_setup_hid ( struct hidp_session * session , struct hidp_connadd_req * req ) { struct hid_device * hid ; int err ; session -> rd_data = kzalloc ( req -> rd_size , GFP_KERNEL ) ; if ( ! session -> rd_data ) return - ENOMEM ; if ( copy_from_user ( session -> rd_data , req -> rd_data , req -> rd_size ) ) { err = - EFAULT ; goto fault ; } session -> rd_size = req -> rd_size ; hid = hid_allocate_device ( ) ; if ( IS_ERR ( hid ) ) { err = PTR_ERR ( hid ) ; goto fault ; } session -> hid = hid ; hid -> driver_data = session ; hid -> bus = BUS_BLUETOOTH ; hid -> vendor = req -> vendor ; hid -> product = req -> product ; hid -> version = req -> version ; hid -> country = req -> country ; strncpy ( hid -> name , req -> name , 128 ) ; snprintf ( hid -> phys , sizeof ( hid -> phys ) , ""%pMR"" , & bt_sk ( session -> ctrl_sock -> sk ) -> src ) ; snprintf ( hid -> uniq , sizeof ( hid -> uniq ) , ""%pMR"" , & bt_sk ( session -> ctrl_sock -> sk ) -> dst ) ; hid -> dev . parent = & session -> conn -> dev ; hid -> ll_driver = & hidp_hid_driver ; hid -> hid_get_raw_report = hidp_get_raw_report ; hid -> hid_output_raw_report = hidp_output_raw_report ; if ( hid_ignore ( hid ) ) { hid_destroy_device ( session -> hid ) ; session -> hid = NULL ; return - ENODEV ; } return 0 ; fault : kfree ( session -> rd_data ) ; session -> rd_data = NULL ; return err ; } "," -> name , sizeof ( req -> name ) - 1 ) ; snprintf ",torvalds@linux/0a9ab9bdb3e891762553f667066190c1d22ad62b,CVE-2013-0349,https://github.com/torvalds/linux/commit/0a9ab9bdb3e891762553f667066190c1d22ad62b,2013-02-28T19:55Z 1427,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 1428,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 1429,CWE-416,"CWE-416 static int __ip6_datagram_connect ( struct sock * sk , struct sockaddr * uaddr , int addr_len ) { struct sockaddr_in6 * usin = ( struct sockaddr_in6 * ) uaddr ; struct inet_sock * inet = inet_sk ( sk ) ; struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct in6_addr * daddr , * final_p , final ; struct dst_entry * dst ; struct flowi6 fl6 ; struct ip6_flowlabel * flowlabel = NULL ; struct ipv6_txoptions * opt ; int addr_type ; int err ; if ( usin -> sin6_family == AF_INET ) { if ( __ipv6_only_sock ( sk ) ) return - EAFNOSUPPORT ; err = __ip4_datagram_connect ( sk , uaddr , addr_len ) ; goto ipv4_connected ; } if ( addr_len < SIN6_LEN_RFC2133 ) return - EINVAL ; if ( usin -> sin6_family != AF_INET6 ) return - EAFNOSUPPORT ; memset ( & fl6 , 0 , sizeof ( fl6 ) ) ; if ( np -> sndflow ) { fl6 . flowlabel = usin -> sin6_flowinfo & IPV6_FLOWINFO_MASK ; if ( fl6 . flowlabel & IPV6_FLOWLABEL_MASK ) { flowlabel = fl6_sock_lookup ( sk , fl6 . flowlabel ) ; if ( ! flowlabel ) return - EINVAL ; } } addr_type = ipv6_addr_type ( & usin -> sin6_addr ) ; if ( addr_type == IPV6_ADDR_ANY ) { usin -> sin6_addr . s6_addr [ 15 ] = 0x01 ; } daddr = & usin -> sin6_addr ; if ( addr_type == IPV6_ADDR_MAPPED ) { struct sockaddr_in sin ; if ( __ipv6_only_sock ( sk ) ) { err = - ENETUNREACH ; goto out ; } sin . sin_family = AF_INET ; sin . sin_addr . s_addr = daddr -> s6_addr32 [ 3 ] ; sin . sin_port = usin -> sin6_port ; err = __ip4_datagram_connect ( sk , ( struct sockaddr * ) & sin , sizeof ( sin ) ) ; ipv4_connected : if ( err ) goto out ; ipv6_addr_set_v4mapped ( inet -> inet_daddr , & sk -> sk_v6_daddr ) ; if ( ipv6_addr_any ( & np -> saddr ) || ipv6_mapped_addr_any ( & np -> saddr ) ) ipv6_addr_set_v4mapped ( inet -> inet_saddr , & np -> saddr ) ; if ( ipv6_addr_any ( & sk -> sk_v6_rcv_saddr ) || ipv6_mapped_addr_any ( & sk -> sk_v6_rcv_saddr ) ) { ipv6_addr_set_v4mapped ( inet -> inet_rcv_saddr , & sk -> sk_v6_rcv_saddr ) ; if ( sk -> sk_prot -> rehash ) sk -> sk_prot -> rehash ( sk ) ; } goto out ; } if ( __ipv6_addr_needs_scope_id ( addr_type ) ) { if ( addr_len >= sizeof ( struct sockaddr_in6 ) && usin -> sin6_scope_id ) { if ( sk -> sk_bound_dev_if && sk -> sk_bound_dev_if != usin -> sin6_scope_id ) { err = - EINVAL ; goto out ; } sk -> sk_bound_dev_if = usin -> sin6_scope_id ; } if ( ! sk -> sk_bound_dev_if && ( addr_type & IPV6_ADDR_MULTICAST ) ) sk -> sk_bound_dev_if = np -> mcast_oif ; if ( ! sk -> sk_bound_dev_if ) { err = - EINVAL ; goto out ; } } sk -> sk_v6_daddr = * daddr ; np -> flow_label = fl6 . flowlabel ; inet -> inet_dport = usin -> sin6_port ; fl6 . flowi6_proto = sk -> sk_protocol ; fl6 . daddr = sk -> sk_v6_daddr ; fl6 . saddr = np -> saddr ; 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 ; if ( ! fl6 . flowi6_oif && ( addr_type & IPV6_ADDR_MULTICAST ) ) fl6 . flowi6_oif = np -> mcast_oif ; security_sk_classify_flow ( sk , flowi6_to_flowi ( & fl6 ) ) ; opt = flowlabel ? flowlabel -> opt : np -> opt ; final_p = fl6_update_dst ( & fl6 , opt , & final ) ; dst = ip6_dst_lookup_flow ( sk , & fl6 , final_p ) ; err = 0 ; if ( IS_ERR ( dst ) ) { err = PTR_ERR ( dst ) ; goto out ; } if ( ipv6_addr_any ( & np -> saddr ) ) np -> saddr = fl6 . saddr ; if ( ipv6_addr_any ( & sk -> sk_v6_rcv_saddr ) ) { sk -> sk_v6_rcv_saddr = fl6 . saddr ; inet -> inet_rcv_saddr = LOOPBACK4_IPV6 ; if ( sk -> sk_prot -> rehash ) sk -> sk_prot -> rehash ( sk ) ; } ip6_dst_store ( sk , dst , ipv6_addr_equal ( & fl6 . daddr , & sk -> sk_v6_daddr ) ? & sk -> sk_v6_daddr : NULL , # ifdef CONFIG_IPV6_SUBTREES ipv6_addr_equal ( & fl6 . saddr , & np -> saddr ) ? & np -> saddr : # endif NULL ) ; sk -> sk_state = TCP_ESTABLISHED ; sk_set_txhash ( sk ) ; out : fl6_sock_release ( flowlabel ) ; return err ; } "," ) ) ; rcu_read_lock ( ) ; -> opt : rcu_dereference ( np -> opt ) , & final ) ; rcu_read_unlock ( ",torvalds@linux/45f6fad84cc305103b28d73482b344d7f5b76f39,CVE-2016-3841,https://github.com/torvalds/linux/commit/45f6fad84cc305103b28d73482b344d7f5b76f39,2016-08-06T20:59Z 1430,CWE-190,"CWE-190 jas_matrix_t * jas_matrix_create ( int numrows , int numcols ) { jas_matrix_t * matrix ; int i ; size_t size ; matrix = 0 ; if ( numrows < 0 || numcols < 0 ) { goto error ; } if ( ! ( matrix = jas_malloc ( sizeof ( jas_matrix_t ) ) ) ) { goto error ; } matrix -> flags_ = 0 ; matrix -> numrows_ = numrows ; matrix -> numcols_ = numcols ; matrix -> rows_ = 0 ; matrix -> maxrows_ = numrows ; matrix -> data_ = 0 ; matrix -> datasize_ = 0 ; if ( ! jas_safe_size_mul ( numrows , numcols , & size ) ) { goto error ; } matrix -> datasize_ = size ; if ( matrix -> maxrows_ > 0 ) { if ( ! ( matrix -> rows_ = jas_alloc2 ( matrix -> maxrows_ , sizeof ( jas_seqent_t * ) ) ) ) { goto error ; } } if ( matrix -> datasize_ > 0 ) { if ( ! ( matrix -> data_ = jas_alloc2 ( matrix -> datasize_ , sizeof ( jas_seqent_t ) ) ) ) { goto error ; } } 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 ; error : if ( matrix ) { jas_matrix_destroy ( matrix ) ; } return 0 ; } "," * jas_matrix_create ( jas_matind_t numrows , jas_matind_t numcols ) { * matrix ; jas_matind_t i ; size_t ",mdadams@jasper/d42b2388f7f8e0332c846675133acea151fc557a,CVE-2016-9557,https://github.com/mdadams/jasper/commit/d42b2388f7f8e0332c846675133acea151fc557a,2017-03-23T18:59Z 1431,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 1432,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 1433,CWE-000,"CWE-000 static int cypress_open ( struct tty_struct * tty , struct usb_serial_port * port ) { struct cypress_private * priv = usb_get_serial_port_data ( port ) ; struct usb_serial * serial = port -> serial ; unsigned long flags ; int result = 0 ; if ( ! priv -> comm_is_ok ) return - EIO ; usb_clear_halt ( serial -> dev , 0x81 ) ; usb_clear_halt ( serial -> dev , 0x02 ) ; spin_lock_irqsave ( & priv -> lock , flags ) ; priv -> bytes_in = 0 ; priv -> bytes_out = 0 ; priv -> cmd_count = 0 ; priv -> rx_flags = 0 ; spin_unlock_irqrestore ( & priv -> lock , flags ) ; cypress_send ( port ) ; if ( tty ) cypress_set_termios ( tty , port , & priv -> tmp_termios ) ; if ( ! port -> interrupt_in_urb ) { dev_err ( & port -> dev , ""%s-interrupt_in_urbisempty!\\n"" , __func__ ) ; return - 1 ; } usb_fill_int_urb ( port -> interrupt_in_urb , serial -> dev , usb_rcvintpipe ( serial -> dev , port -> interrupt_in_endpointAddress ) , port -> interrupt_in_urb -> transfer_buffer , port -> interrupt_in_urb -> transfer_buffer_length , cypress_read_int_callback , port , priv -> read_urb_interval ) ; result = usb_submit_urb ( port -> interrupt_in_urb , GFP_KERNEL ) ; if ( result ) { dev_err ( & port -> dev , ""%s-failedsubmittingreadurb,error%d\\n"" , __func__ , result ) ; cypress_set_dead ( port ) ; } return result ; } "," tmp_termios ) ; usb_fill_int_urb ( port ",torvalds@linux/c55aee1bf0e6b6feec8b2927b43f7a09a6d5f754,CVE-2016-3137,https://github.com/torvalds/linux/commit/c55aee1bf0e6b6feec8b2927b43f7a09a6d5f754,2016-05-02T10:59Z 1434,CWE-362,"CWE-362 static int packet_setsockopt ( struct socket * sock , int level , int optname , char __user * optval , unsigned int optlen ) { struct sock * sk = sock -> sk ; struct packet_sock * po = pkt_sk ( sk ) ; int ret ; if ( level != SOL_PACKET ) return - ENOPROTOOPT ; switch ( optname ) { case PACKET_ADD_MEMBERSHIP : case PACKET_DROP_MEMBERSHIP : { struct packet_mreq_max mreq ; int len = optlen ; memset ( & mreq , 0 , sizeof ( mreq ) ) ; if ( len < sizeof ( struct packet_mreq ) ) return - EINVAL ; if ( len > sizeof ( mreq ) ) len = sizeof ( mreq ) ; if ( copy_from_user ( & mreq , optval , len ) ) return - EFAULT ; if ( len < ( mreq . mr_alen + offsetof ( struct packet_mreq , mr_address ) ) ) return - EINVAL ; if ( optname == PACKET_ADD_MEMBERSHIP ) ret = packet_mc_add ( sk , & mreq ) ; else ret = packet_mc_drop ( sk , & mreq ) ; return ret ; } case PACKET_RX_RING : case PACKET_TX_RING : { union tpacket_req_u req_u ; int len ; switch ( po -> tp_version ) { case TPACKET_V1 : case TPACKET_V2 : len = sizeof ( req_u . req ) ; break ; case TPACKET_V3 : default : len = sizeof ( req_u . req3 ) ; break ; } if ( optlen < len ) return - EINVAL ; if ( copy_from_user ( & req_u . req , optval , len ) ) return - EFAULT ; return packet_set_ring ( sk , & req_u , 0 , optname == PACKET_TX_RING ) ; } case PACKET_COPY_THRESH : { int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; pkt_sk ( sk ) -> copy_thresh = val ; return 0 ; } case PACKET_VERSION : { int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( po -> rx_ring . pg_vec || po -> tx_ring . pg_vec ) return - EBUSY ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; switch ( val ) { case TPACKET_V1 : case TPACKET_V2 : case TPACKET_V3 : po -> tp_version = val ; return 0 ; default : return - EINVAL ; } } case PACKET_RESERVE : { unsigned int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( po -> rx_ring . pg_vec || po -> tx_ring . pg_vec ) return - EBUSY ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> tp_reserve = val ; return 0 ; } case PACKET_LOSS : { unsigned int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( po -> rx_ring . pg_vec || po -> tx_ring . pg_vec ) return - EBUSY ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> tp_loss = ! ! val ; return 0 ; } case PACKET_AUXDATA : { int val ; if ( optlen < sizeof ( val ) ) return - EINVAL ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> auxdata = ! ! val ; return 0 ; } case PACKET_ORIGDEV : { int val ; if ( optlen < sizeof ( val ) ) return - EINVAL ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> origdev = ! ! val ; return 0 ; } case PACKET_VNET_HDR : { int val ; if ( sock -> type != SOCK_RAW ) return - EINVAL ; if ( po -> rx_ring . pg_vec || po -> tx_ring . pg_vec ) return - EBUSY ; if ( optlen < sizeof ( val ) ) return - EINVAL ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> has_vnet_hdr = ! ! val ; return 0 ; } case PACKET_TIMESTAMP : { int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> tp_tstamp = val ; return 0 ; } case PACKET_FANOUT : { int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; return fanout_add ( sk , val & 0xffff , val >> 16 ) ; } case PACKET_FANOUT_DATA : { if ( ! po -> fanout ) return - EINVAL ; return fanout_set_data ( po , optval , optlen ) ; } case PACKET_TX_HAS_OFF : { unsigned int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( po -> rx_ring . pg_vec || po -> tx_ring . pg_vec ) return - EBUSY ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> tp_tx_has_off = ! ! val ; return 0 ; } case PACKET_QDISC_BYPASS : { int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> xmit = val ? packet_direct_xmit : dev_queue_xmit ; return 0 ; } default : return - ENOPROTOOPT ; } } "," ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; switch ( val ) { case TPACKET_V1 : case TPACKET_V2 : case TPACKET_V3 : break ; default : return - EINVAL ; } lock_sock ( sk ) ; if ( . pg_vec ) { ret = - EBUSY ; - EBUSY ; } else { po -> tp_version = val ; ret = 0 ; } release_sock ( sk ) ; return ret ; } case PACKET_RESERVE ",torvalds@linux/84ac7260236a49c79eede91617700174c2c19b0c,CVE-2016-8655,https://github.com/torvalds/linux/commit/84ac7260236a49c79eede91617700174c2c19b0c,2016-12-08T08:59Z 1435,CWE-119,"CWE-119 static gboolean cosine_seek_read ( wtap * wth , gint64 seek_off , struct wtap_pkthdr * phdr , Buffer * buf , int * err , gchar * * err_info ) { int pkt_len ; char line [ COSINE_LINE_LENGTH ] ; if ( file_seek ( wth -> random_fh , seek_off , SEEK_SET , err ) == - 1 ) return FALSE ; if ( file_gets ( line , COSINE_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_cosine_rec_hdr ( phdr , line , err , err_info ) ; if ( pkt_len == - 1 ) return FALSE ; return parse_cosine_hex_dump ( wth -> random_fh , phdr , pkt_len , buf , err , err_info ) ; } "," err_info ) { char line [ FALSE ; } return parse_cosine_packet ( wth -> , phdr , buf , line , err , ",wireshark@wireshark/f5ec0afb766f19519ea9623152cca3bbe2229500,CVE-2016-5356,https://github.com/wireshark/wireshark/commit/f5ec0afb766f19519ea9623152cca3bbe2229500,2016-08-07T16:59Z 1436,CWE-190,"CWE-190 SQLITE_PRIVATE int sqlite3VtabEponymousTableInit ( Parse * pParse , Module * pMod ) { const sqlite3_module * pModule = pMod -> pModule ; Table * pTab ; char * zErr = 0 ; int rc ; sqlite3 * db = pParse -> db ; if ( pMod -> pEpoTab ) return 1 ; if ( pModule -> xCreate != 0 && pModule -> xCreate != pModule -> xConnect ) return 0 ; pTab = sqlite3DbMallocZero ( db , sizeof ( Table ) ) ; if ( pTab == 0 ) return 0 ; pTab -> zName = sqlite3DbStrDup ( db , pMod -> zName ) ; if ( pTab -> zName == 0 ) { sqlite3DbFree ( db , pTab ) ; return 0 ; } pMod -> pEpoTab = pTab ; pTab -> nTabRef = 1 ; pTab -> pSchema = db -> aDb [ 0 ] . pSchema ; assert ( pTab -> nModuleArg == 0 ) ; pTab -> iPKey = - 1 ; addModuleArgument ( db , pTab , sqlite3DbStrDup ( db , pTab -> zName ) ) ; addModuleArgument ( db , pTab , 0 ) ; addModuleArgument ( db , pTab , sqlite3DbStrDup ( db , pTab -> zName ) ) ; rc = vtabCallConstructor ( db , pTab , pMod , pModule -> xConnect , & zErr ) ; if ( rc ) { sqlite3ErrorMsg ( pParse , ""%s"" , zErr ) ; sqlite3DbFree ( db , zErr ) ; sqlite3VtabEponymousTableClear ( db , pMod ) ; return 0 ; } return 1 ; } "," ; addModuleArgument ( pParse , pTab , ; addModuleArgument ( pParse , pTab , ; addModuleArgument ( pParse , pTab , ",chromium@chromium/517ac71c9ee27f856f9becde8abea7d1604af9d4,CVE-2019-5827,https://github.com/chromium/chromium/commit/517ac71c9ee27f856f9becde8abea7d1604af9d4,2019-06-27T17:15Z 1437,CWE-284,"CWE-284 int send_event ( int fd , uint16_t type , uint16_t code , int32_t value ) { struct uinput_event event ; BTIF_TRACE_DEBUG ( ""%stype:%ucode:%uvalue:%d"" , __FUNCTION__ , type , code , value ) ; memset ( & event , 0 , sizeof ( event ) ) ; event . type = type ; event . code = code ; event . value = value ; return write ( fd , & event , sizeof ( event ) ) ; } "," value ; return TEMP_FAILURE_RETRY ( event ) ) ) ",system@bt/472271b153c5dc53c28beac55480a8d8434b2d5c,CVE-2016-3839,https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c,2016-08-05T20:59Z 1438,CWE-119,"CWE-119 static int format8BIM ( Image * ifile , Image * ofile ) { char temp [ MagickPathExtent ] ; unsigned int foundOSType ; int ID , resCount , i , c ; ssize_t count ; unsigned char * PString , * str ; resCount = 0 ; foundOSType = 0 ; ( void ) foundOSType ; c = ReadBlobByte ( ifile ) ; while ( c != EOF ) { if ( c == '8' ) { unsigned char buffer [ 5 ] ; buffer [ 0 ] = ( unsigned char ) c ; for ( i = 1 ; i < 4 ; i ++ ) { c = ReadBlobByte ( ifile ) ; if ( c == EOF ) return ( - 1 ) ; buffer [ i ] = ( unsigned char ) c ; } buffer [ 4 ] = 0 ; if ( strcmp ( ( const char * ) buffer , ""8BIM"" ) == 0 ) foundOSType = 1 ; else continue ; } else { c = ReadBlobByte ( ifile ) ; continue ; } ID = ReadBlobMSBSignedShort ( ifile ) ; if ( ID < 0 ) return ( - 1 ) ; { unsigned char plen ; c = ReadBlobByte ( ifile ) ; if ( c == EOF ) return ( - 1 ) ; plen = ( unsigned char ) c ; PString = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) ( plen + MagickPathExtent ) , sizeof ( * PString ) ) ; if ( PString == ( unsigned char * ) NULL ) return 0 ; for ( i = 0 ; i < plen ; i ++ ) { c = ReadBlobByte ( ifile ) ; if ( c == EOF ) { PString = ( unsigned char * ) RelinquishMagickMemory ( PString ) ; return - 1 ; } PString [ i ] = ( unsigned char ) c ; } PString [ plen ] = 0 ; if ( ( plen & 0x01 ) == 0 ) { c = ReadBlobByte ( ifile ) ; if ( c == EOF ) { PString = ( unsigned char * ) RelinquishMagickMemory ( PString ) ; return - 1 ; } } } count = ( ssize_t ) ReadBlobMSBSignedLong ( ifile ) ; if ( ( count < 0 ) || ( count > GetBlobSize ( ifile ) ) ) { PString = ( unsigned char * ) RelinquishMagickMemory ( PString ) ; return - 1 ; } str = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) count , sizeof ( * str ) ) ; if ( str == ( unsigned char * ) NULL ) { PString = ( unsigned char * ) RelinquishMagickMemory ( PString ) ; return 0 ; } for ( i = 0 ; i < ( ssize_t ) count ; i ++ ) { c = ReadBlobByte ( ifile ) ; if ( c == EOF ) { str = ( unsigned char * ) RelinquishMagickMemory ( str ) ; PString = ( unsigned char * ) RelinquishMagickMemory ( PString ) ; return - 1 ; } str [ i ] = ( unsigned char ) c ; } if ( ID != THUMBNAIL_ID ) { if ( strlen ( ( const char * ) PString ) > 0 ) ( void ) FormatLocaleString ( temp , MagickPathExtent , ""8BIM#%d#%s="" , ID , PString ) ; else ( void ) FormatLocaleString ( temp , MagickPathExtent , ""8BIM#%d="" , ID ) ; ( void ) WriteBlobString ( ofile , temp ) ; if ( ID == IPTC_ID ) { formatString ( ofile , ""IPTC"" , 4 ) ; formatIPTCfromBuffer ( ofile , ( char * ) str , ( ssize_t ) count ) ; } else formatString ( ofile , ( char * ) str , ( ssize_t ) count ) ; } str = ( unsigned char * ) RelinquishMagickMemory ( str ) ; PString = ( unsigned char * ) RelinquishMagickMemory ( PString ) ; resCount ++ ; c = ReadBlobByte ( ifile ) ; } return resCount ; } "," size_t ) count + 1 ",ImageMagick@ImageMagick/cb1214c124e1bd61f7dd551b94a794864861592e,CVE-2019-10131,https://github.com/ImageMagick/ImageMagick/commit/cb1214c124e1bd61f7dd551b94a794864861592e,2019-04-30T19:29Z 1439,CWE-362,"CWE-362 struct dst_entry * inet_csk_route_req ( struct sock * sk , const struct request_sock * req ) { struct rtable * rt ; const struct inet_request_sock * ireq = inet_rsk ( req ) ; struct ip_options * opt = inet_rsk ( req ) -> opt ; struct net * net = sock_net ( sk ) ; struct flowi4 fl4 ; flowi4_init_output ( & fl4 , sk -> sk_bound_dev_if , sk -> sk_mark , RT_CONN_FLAGS ( sk ) , RT_SCOPE_UNIVERSE , sk -> sk_protocol , inet_sk_flowi_flags ( sk ) , ( opt && opt -> srr ) ? opt -> faddr : ireq -> rmt_addr , ireq -> loc_addr , ireq -> rmt_port , inet_sk ( sk ) -> inet_sport ) ; security_req_classify_flow ( req , flowi4_to_flowi ( & fl4 ) ) ; rt = ip_route_output_flow ( net , & fl4 , sk ) ; if ( IS_ERR ( rt ) ) goto no_route ; if ( opt && opt -> is_strictroute && rt -> rt_dst != rt -> rt_gateway ) goto route_err ; return & rt -> dst ; route_err : ip_rt_put ( rt ) ; no_route : IP_INC_STATS_BH ( net , IPSTATS_MIB_OUTNOROUTES ) ; return NULL ; } "," ) ; struct ip_options_rcu * opt = && opt -> opt . ? opt -> opt . && opt -> opt . ",torvalds@linux/f6d8bd051c391c1c0458a30b2a7abcd939329259,CVE-2012-3552,https://github.com/torvalds/linux/commit/f6d8bd051c391c1c0458a30b2a7abcd939329259,2012-10-03T11:02Z 1440,CWE-119,"CWE-119 int ParseDateTime ( char * timestr , char * lowstr , char * * field , int * ftype , int * numfields , char * * endstr ) { int nf = 0 ; char * lp = lowstr ; * endstr = timestr ; while ( * ( * endstr ) != '\\0' ) { field [ nf ] = lp ; if ( isdigit ( ( unsigned char ) * ( * endstr ) ) ) { * lp ++ = * ( * endstr ) ++ ; while ( isdigit ( ( unsigned char ) * ( * endstr ) ) ) * lp ++ = * ( * endstr ) ++ ; if ( * ( * endstr ) == ':' ) { ftype [ nf ] = DTK_TIME ; * lp ++ = * ( * endstr ) ++ ; while ( isdigit ( ( unsigned char ) * ( * endstr ) ) || ( * ( * endstr ) == ':' ) || ( * ( * endstr ) == '.' ) ) * lp ++ = * ( * endstr ) ++ ; } else if ( * ( * endstr ) == '-' || * ( * endstr ) == '/' || * ( * endstr ) == '.' ) { char * dp = ( * endstr ) ; * lp ++ = * ( * endstr ) ++ ; if ( isdigit ( ( unsigned char ) * ( * endstr ) ) ) { ftype [ nf ] = ( * dp == '.' ) ? DTK_NUMBER : DTK_DATE ; while ( isdigit ( ( unsigned char ) * ( * endstr ) ) ) * lp ++ = * ( * endstr ) ++ ; if ( * ( * endstr ) == * dp ) { ftype [ nf ] = DTK_DATE ; * lp ++ = * ( * endstr ) ++ ; while ( isdigit ( ( unsigned char ) * ( * endstr ) ) || ( * ( * endstr ) == * dp ) ) * lp ++ = * ( * endstr ) ++ ; } } else { ftype [ nf ] = DTK_DATE ; while ( isalnum ( ( unsigned char ) * ( * endstr ) ) || ( * ( * endstr ) == * dp ) ) * lp ++ = pg_tolower ( ( unsigned char ) * ( * endstr ) ++ ) ; } } else ftype [ nf ] = DTK_NUMBER ; } else if ( * ( * endstr ) == '.' ) { * lp ++ = * ( * endstr ) ++ ; while ( isdigit ( ( unsigned char ) * ( * endstr ) ) ) * lp ++ = * ( * endstr ) ++ ; ftype [ nf ] = DTK_NUMBER ; } else if ( isalpha ( ( unsigned char ) * ( * endstr ) ) ) { ftype [ nf ] = DTK_STRING ; * lp ++ = pg_tolower ( ( unsigned char ) * ( * endstr ) ++ ) ; while ( isalpha ( ( unsigned char ) * ( * endstr ) ) ) * lp ++ = pg_tolower ( ( unsigned char ) * ( * endstr ) ++ ) ; if ( * ( * endstr ) == '-' || * ( * endstr ) == '/' || * ( * endstr ) == '.' ) { char * dp = ( * endstr ) ; ftype [ nf ] = DTK_DATE ; * lp ++ = * ( * endstr ) ++ ; while ( isdigit ( ( unsigned char ) * ( * endstr ) ) || * ( * endstr ) == * dp ) * lp ++ = * ( * endstr ) ++ ; } } else if ( isspace ( ( unsigned char ) * ( * endstr ) ) ) { ( * endstr ) ++ ; continue ; } else if ( * ( * endstr ) == '+' || * ( * endstr ) == '-' ) { * lp ++ = * ( * endstr ) ++ ; while ( isspace ( ( unsigned char ) * ( * endstr ) ) ) ( * endstr ) ++ ; if ( isdigit ( ( unsigned char ) * ( * endstr ) ) ) { ftype [ nf ] = DTK_TZ ; * lp ++ = * ( * endstr ) ++ ; while ( isdigit ( ( unsigned char ) * ( * endstr ) ) || ( * ( * endstr ) == ':' ) || ( * ( * endstr ) == '.' ) ) * lp ++ = * ( * endstr ) ++ ; } else if ( isalpha ( ( unsigned char ) * ( * endstr ) ) ) { ftype [ nf ] = DTK_SPECIAL ; * lp ++ = pg_tolower ( ( unsigned char ) * ( * endstr ) ++ ) ; while ( isalpha ( ( unsigned char ) * ( * endstr ) ) ) * lp ++ = pg_tolower ( ( unsigned char ) * ( * endstr ) ++ ) ; } else return - 1 ; } else if ( ispunct ( ( unsigned char ) * ( * endstr ) ) ) { ( * endstr ) ++ ; continue ; } else return - 1 ; * lp ++ = '\\0' ; nf ++ ; if ( nf > MAXDATEFIELDS ) return - 1 ; } * numfields = nf ; return 0 ; } "," ] = lp ; if ( nf >= MAXDATEFIELDS ) return - 1 nf ++ ; } * numfields ",postgres@postgres/4318daecc959886d001a6e79c6ea853e8b1dfb4b,CVE-2014-0063,https://github.com/postgres/postgres/commit/4318daecc959886d001a6e79c6ea853e8b1dfb4b,2014-03-31T14:58Z 1441,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 ( L , 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 ( fmt , MAXALIGN ",antirez@redis/1eb08bcd4634ae42ec45e8284923ac048beaa4c3,CVE-2018-11219,https://github.com/antirez/redis/commit/1eb08bcd4634ae42ec45e8284923ac048beaa4c3,2018-06-17T17:29Z 1442,CWE-119,"CWE-119 void safe_fprintf ( FILE * f , const char * fmt , ... ) { char fmtbuff_stack [ 256 ] ; char outbuff [ 256 ] ; char * fmtbuff_heap ; char * fmtbuff ; int fmtbuff_length ; int length , n ; va_list ap ; const char * p ; unsigned i ; wchar_t wc ; char try_wc ; fmtbuff_heap = NULL ; fmtbuff_length = sizeof ( fmtbuff_stack ) ; fmtbuff = fmtbuff_stack ; va_start ( ap , fmt ) ; length = vsnprintf ( fmtbuff , fmtbuff_length , fmt , ap ) ; va_end ( ap ) ; while ( length < 0 || length >= fmtbuff_length ) { if ( length >= fmtbuff_length ) fmtbuff_length = length + 1 ; else if ( fmtbuff_length < 8192 ) fmtbuff_length *= 2 ; else if ( fmtbuff_length < 1000000 ) fmtbuff_length += fmtbuff_length / 4 ; else { length = fmtbuff_length ; fmtbuff_heap [ length - 1 ] = '\\0' ; break ; } free ( fmtbuff_heap ) ; fmtbuff_heap = malloc ( fmtbuff_length ) ; if ( fmtbuff_heap != NULL ) { fmtbuff = fmtbuff_heap ; va_start ( ap , fmt ) ; length = vsnprintf ( fmtbuff , fmtbuff_length , fmt , ap ) ; va_end ( ap ) ; } else { length = sizeof ( fmtbuff_stack ) - 1 ; break ; } } if ( mbtowc ( NULL , NULL , 1 ) == - 1 ) { free ( fmtbuff_heap ) ; return ; } p = fmtbuff ; i = 0 ; try_wc = 1 ; while ( * p != '\\0' ) { if ( try_wc && ( n = mbtowc ( & wc , p , length ) ) != - 1 ) { length -= n ; if ( iswprint ( wc ) && wc != L'\\\\' ) { while ( n -- > 0 ) outbuff [ i ++ ] = * p ++ ; } else { while ( n -- > 0 ) i += ( unsigned ) bsdtar_expand_char ( outbuff , i , * p ++ ) ; } } else { i += ( unsigned ) bsdtar_expand_char ( outbuff , i , * p ++ ) ; try_wc = 0 ; } if ( i > ( sizeof ( outbuff ) - 20 ) ) { outbuff [ i ] = '\\0' ; fprintf ( f , ""%s"" , outbuff ) ; i = 0 ; } } outbuff [ i ] = '\\0' ; fprintf ( f , ""%s"" , outbuff ) ; free ( fmtbuff_heap ) ; } "," outbuff ) - 128 ) ) { ",libarchive@libarchive/e37b620fe8f14535d737e89a4dcabaed4517bf1a,CVE-2016-8687,https://github.com/libarchive/libarchive/commit/e37b620fe8f14535d737e89a4dcabaed4517bf1a,2017-02-15T19:59Z 1443,CWE-119,"CWE-119 static int test_candidate_kf ( struct twopass_rc * twopass , const FIRSTPASS_STATS * last_frame , const FIRSTPASS_STATS * this_frame , const FIRSTPASS_STATS * next_frame ) { int is_viable_kf = 0 ; if ( ( this_frame -> pcnt_second_ref < 0.10 ) && ( next_frame -> pcnt_second_ref < 0.10 ) && ( ( this_frame -> pcnt_inter < 0.05 ) || ( ( ( this_frame -> pcnt_inter - this_frame -> pcnt_neutral ) < 0.35 ) && ( ( this_frame -> intra_error / DOUBLE_DIVIDE_CHECK ( this_frame -> coded_error ) ) < 2.5 ) && ( ( fabs ( last_frame -> coded_error - this_frame -> coded_error ) / DOUBLE_DIVIDE_CHECK ( this_frame -> coded_error ) > 0.40 ) || ( fabs ( last_frame -> intra_error - this_frame -> intra_error ) / DOUBLE_DIVIDE_CHECK ( this_frame -> intra_error ) > 0.40 ) || ( ( next_frame -> intra_error / DOUBLE_DIVIDE_CHECK ( next_frame -> coded_error ) ) > 3.5 ) ) ) ) ) { int i ; const FIRSTPASS_STATS * start_pos = twopass -> stats_in ; FIRSTPASS_STATS local_next_frame = * next_frame ; double boost_score = 0.0 ; double old_boost_score = 0.0 ; double decay_accumulator = 1.0 ; for ( i = 0 ; i < 16 ; ++ i ) { double next_iiratio = ( IIKFACTOR1 * local_next_frame . intra_error / DOUBLE_DIVIDE_CHECK ( local_next_frame . coded_error ) ) ; if ( next_iiratio > RMAX ) next_iiratio = RMAX ; if ( local_next_frame . pcnt_inter > 0.85 ) decay_accumulator *= local_next_frame . pcnt_inter ; else decay_accumulator *= ( 0.85 + local_next_frame . pcnt_inter ) / 2.0 ; boost_score += ( decay_accumulator * next_iiratio ) ; if ( ( local_next_frame . pcnt_inter < 0.05 ) || ( next_iiratio < 1.5 ) || ( ( ( local_next_frame . pcnt_inter - local_next_frame . pcnt_neutral ) < 0.20 ) && ( next_iiratio < 3.0 ) ) || ( ( boost_score - old_boost_score ) < 3.0 ) || ( local_next_frame . intra_error < 200 ) ) { break ; } old_boost_score = boost_score ; if ( EOF == input_stats ( twopass , & local_next_frame ) ) break ; } if ( boost_score > 30.0 && ( i > 3 ) ) { is_viable_kf = 1 ; } else { reset_fpf_position ( twopass , start_pos ) ; is_viable_kf = 0 ; } } return is_viable_kf ; } "," int test_candidate_kf ( TWO_PASS * twopass , = 0 ; double pcnt_intra = 1.0 - this_frame -> pcnt_inter ; double modified_pcnt_inter = this_frame -> pcnt_inter - this_frame -> pcnt_neutral ; -> pcnt_second_ref < SECOND_REF_USEAGE_THRESH ) && ( -> pcnt_second_ref < SECOND_REF_USEAGE_THRESH ) && ( ( this_frame -> pcnt_inter < VERY_LOW_INTER_THRESH ) || ( ( pcnt_intra > MIN_INTRA_LEVEL ) && ( pcnt_intra > ( INTRA_VS_INTER_THRESH * modified_pcnt_inter ) ) && ( ) ) < KF_II_ERR_THRESHOLD ) && ( coded_error ) > ERR_CHANGE_THRESHOLD ) || ( intra_error ) > ERR_CHANGE_THRESHOLD ) || ( ) ) > II_IMPROVEMENT_THRESHOLD ) ) ) next_iiratio = ( BOOST_FACTOR * local_next_frame . ( next_iiratio > KF_II_MAX ) next_iiratio = KF_II_MAX ; if ( ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1444,CWE-20,"CWE-20 static int do_check ( struct bpf_verifier_env * env ) { struct bpf_verifier_state * state ; struct bpf_insn * insns = env -> prog -> insnsi ; struct bpf_reg_state * regs ; int insn_cnt = env -> prog -> len ; int insn_idx , prev_insn_idx = 0 ; int insn_processed = 0 ; bool do_print_state = false ; state = kzalloc ( sizeof ( struct bpf_verifier_state ) , GFP_KERNEL ) ; if ( ! state ) return - ENOMEM ; env -> cur_state = state ; init_reg_state ( env , state -> regs ) ; state -> parent = NULL ; insn_idx = 0 ; for ( ; ; ) { struct bpf_insn * insn ; u8 class ; int err ; if ( insn_idx >= insn_cnt ) { verbose ( env , ""invalidinsnidx%dinsn_cnt%d\\n"" , insn_idx , insn_cnt ) ; return - EFAULT ; } insn = & insns [ insn_idx ] ; class = BPF_CLASS ( insn -> code ) ; if ( ++ insn_processed > BPF_COMPLEXITY_LIMIT_INSNS ) { verbose ( env , ""BPFprogramistoolarge.Processed%dinsn\\n"" , insn_processed ) ; return - E2BIG ; } err = is_state_visited ( env , insn_idx ) ; if ( err < 0 ) return err ; if ( err == 1 ) { if ( env -> log . level ) { if ( do_print_state ) verbose ( env , ""\\nfrom%dto%d:safe\\n"" , prev_insn_idx , insn_idx ) ; else verbose ( env , ""%d:safe\\n"" , insn_idx ) ; } goto process_bpf_exit ; } if ( need_resched ( ) ) cond_resched ( ) ; if ( env -> log . level > 1 || ( env -> log . level && do_print_state ) ) { if ( env -> log . level > 1 ) verbose ( env , ""%d:"" , insn_idx ) ; else verbose ( env , ""\\nfrom%dto%d:"" , prev_insn_idx , insn_idx ) ; print_verifier_state ( env , state ) ; do_print_state = false ; } if ( env -> log . level ) { verbose ( env , ""%d:"" , insn_idx ) ; print_bpf_insn ( verbose , env , insn , env -> allow_ptr_leaks ) ; } err = ext_analyzer_insn_hook ( env , insn_idx , prev_insn_idx ) ; if ( err ) return err ; regs = cur_regs ( env ) ; if ( class == BPF_ALU || class == BPF_ALU64 ) { err = check_alu_op ( env , insn ) ; if ( err ) return err ; } else if ( class == BPF_LDX ) { enum bpf_reg_type * prev_src_type , src_reg_type ; err = check_reg_arg ( env , insn -> src_reg , SRC_OP ) ; if ( err ) return err ; err = check_reg_arg ( env , insn -> dst_reg , DST_OP_NO_MARK ) ; if ( err ) return err ; src_reg_type = regs [ insn -> src_reg ] . type ; err = check_mem_access ( env , insn_idx , insn -> src_reg , insn -> off , BPF_SIZE ( insn -> code ) , BPF_READ , insn -> dst_reg ) ; if ( err ) return err ; prev_src_type = & env -> insn_aux_data [ insn_idx ] . ptr_type ; if ( * prev_src_type == NOT_INIT ) { * prev_src_type = src_reg_type ; } else if ( src_reg_type != * prev_src_type && ( src_reg_type == PTR_TO_CTX || * prev_src_type == PTR_TO_CTX ) ) { verbose ( env , ""sameinsncannotbeusedwithdifferentpointers\\n"" ) ; return - EINVAL ; } } else if ( class == BPF_STX ) { enum bpf_reg_type * prev_dst_type , dst_reg_type ; if ( BPF_MODE ( insn -> code ) == BPF_XADD ) { err = check_xadd ( env , insn_idx , insn ) ; if ( err ) return err ; insn_idx ++ ; continue ; } err = check_reg_arg ( env , insn -> src_reg , SRC_OP ) ; if ( err ) return err ; err = check_reg_arg ( env , insn -> dst_reg , SRC_OP ) ; if ( err ) return err ; dst_reg_type = regs [ insn -> dst_reg ] . type ; err = check_mem_access ( env , insn_idx , insn -> dst_reg , insn -> off , BPF_SIZE ( insn -> code ) , BPF_WRITE , insn -> src_reg ) ; if ( err ) return err ; prev_dst_type = & env -> insn_aux_data [ insn_idx ] . ptr_type ; if ( * prev_dst_type == NOT_INIT ) { * prev_dst_type = dst_reg_type ; } else if ( dst_reg_type != * prev_dst_type && ( dst_reg_type == PTR_TO_CTX || * prev_dst_type == PTR_TO_CTX ) ) { verbose ( env , ""sameinsncannotbeusedwithdifferentpointers\\n"" ) ; return - EINVAL ; } } else if ( class == BPF_ST ) { if ( BPF_MODE ( insn -> code ) != BPF_MEM || insn -> src_reg != BPF_REG_0 ) { verbose ( env , ""BPF_STusesreservedfields\\n"" ) ; return - EINVAL ; } err = check_reg_arg ( env , insn -> dst_reg , SRC_OP ) ; if ( err ) return err ; err = check_mem_access ( env , insn_idx , insn -> dst_reg , insn -> off , BPF_SIZE ( insn -> code ) , BPF_WRITE , - 1 ) ; if ( err ) return err ; } else if ( class == BPF_JMP ) { u8 opcode = BPF_OP ( insn -> code ) ; if ( opcode == BPF_CALL ) { if ( BPF_SRC ( insn -> code ) != BPF_K || insn -> off != 0 || insn -> src_reg != BPF_REG_0 || insn -> dst_reg != BPF_REG_0 ) { verbose ( env , ""BPF_CALLusesreservedfields\\n"" ) ; return - EINVAL ; } err = check_call ( env , insn -> imm , insn_idx ) ; if ( err ) return err ; } else if ( opcode == BPF_JA ) { if ( BPF_SRC ( insn -> code ) != BPF_K || insn -> imm != 0 || insn -> src_reg != BPF_REG_0 || insn -> dst_reg != BPF_REG_0 ) { verbose ( env , ""BPF_JAusesreservedfields\\n"" ) ; return - EINVAL ; } insn_idx += insn -> off + 1 ; continue ; } else if ( opcode == BPF_EXIT ) { if ( BPF_SRC ( insn -> code ) != BPF_K || insn -> imm != 0 || insn -> src_reg != BPF_REG_0 || insn -> dst_reg != BPF_REG_0 ) { verbose ( env , ""BPF_EXITusesreservedfields\\n"" ) ; return - EINVAL ; } err = check_reg_arg ( env , BPF_REG_0 , SRC_OP ) ; if ( err ) return err ; if ( is_pointer_value ( env , BPF_REG_0 ) ) { verbose ( env , ""R0leaksaddrasreturnvalue\\n"" ) ; return - EACCES ; } err = check_return_code ( env ) ; if ( err ) return err ; process_bpf_exit : err = pop_stack ( env , & prev_insn_idx , & insn_idx ) ; if ( err < 0 ) { if ( err != - ENOENT ) return err ; break ; } else { do_print_state = true ; continue ; } } else { err = check_cond_jmp_op ( env , insn , & insn_idx ) ; if ( err ) return err ; } } else if ( class == BPF_LD ) { u8 mode = BPF_MODE ( insn -> code ) ; if ( mode == BPF_ABS || mode == BPF_IND ) { err = check_ld_abs ( env , insn ) ; if ( err ) return err ; } else if ( mode == BPF_IMM ) { err = check_ld_imm ( env , insn ) ; if ( err ) return err ; insn_idx ++ ; } else { verbose ( env , ""invalidBPF_LDmode\\n"" ) ; return - EINVAL ; } } else { verbose ( env , ""unknowninsnclass%d\\n"" , class ) ; return - EINVAL ; } insn_idx ++ ; } verbose ( env , ""processed%dinsns,stackdepth%d\\n"" , insn_processed , env -> prog -> aux -> stack_depth ) ; return 0 ; } "," env ) ; env -> insn_aux_data [ insn_idx ] . seen = true ; insn_idx ++ ; env -> insn_aux_data [ insn_idx ] . seen = true ; ",torvalds@linux/c131187db2d3fa2f8bf32fdf4e9a4ef805168467,CVE-2017-17862,https://github.com/torvalds/linux/commit/c131187db2d3fa2f8bf32fdf4e9a4ef805168467,2017-12-27T17:08Z 1445,CWE-787,"CWE-787 void mp_encode_lua_table_as_array ( lua_State * L , mp_buf * buf , int level ) { # if LUA_VERSION_NUM < 502 size_t len = lua_objlen ( L , - 1 ) , j ; # else size_t len = lua_rawlen ( L , - 1 ) , j ; # endif mp_encode_array ( L , buf , len ) ; for ( j = 1 ; j <= len ; j ++ ) { lua_pushnumber ( L , j ) ; lua_gettable ( L , - 2 ) ; mp_encode_lua_type ( L , buf , level + 1 ) ; } } "," len ) ; luaL_checkstack ( L , 1 , ""infunctionmp_encode_lua_table_as_array"" ) ; ",antirez@redis/5ccb6f7a791bf3490357b00a898885759d98bab0,CVE-2018-11218,https://github.com/antirez/redis/commit/5ccb6f7a791bf3490357b00a898885759d98bab0,2018-06-17T17:29Z 1446,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/3724cd76a28be1d6049b5537232e97ac567ae1f5,2017-01-23T21:59Z 1447,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 1448,CWE-125,"CWE-125 PyMODINIT_FUNC PyInit__ast3 ( void ) { PyObject * m , * d ; if ( ! init_types ( ) ) return NULL ; m = PyModule_Create ( & _astmodule3 ) ; if ( ! m ) return NULL ; d = PyModule_GetDict ( m ) ; if ( PyDict_SetItemString ( d , ""AST"" , ( PyObject * ) & AST_type ) < 0 ) return NULL ; if ( PyModule_AddIntMacro ( m , PyCF_ONLY_AST ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""mod"" , ( PyObject * ) mod_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Module"" , ( PyObject * ) Module_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Interactive"" , ( PyObject * ) Interactive_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Expression"" , ( PyObject * ) Expression_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""FunctionType"" , ( PyObject * ) FunctionType_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Suite"" , ( PyObject * ) Suite_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""stmt"" , ( PyObject * ) stmt_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""FunctionDef"" , ( PyObject * ) FunctionDef_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""AsyncFunctionDef"" , ( PyObject * ) AsyncFunctionDef_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""ClassDef"" , ( PyObject * ) ClassDef_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Return"" , ( PyObject * ) Return_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Delete"" , ( PyObject * ) Delete_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Assign"" , ( PyObject * ) Assign_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""AugAssign"" , ( PyObject * ) AugAssign_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""AnnAssign"" , ( PyObject * ) AnnAssign_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""For"" , ( PyObject * ) For_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""AsyncFor"" , ( PyObject * ) AsyncFor_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""While"" , ( PyObject * ) While_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""If"" , ( PyObject * ) If_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""With"" , ( PyObject * ) With_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""AsyncWith"" , ( PyObject * ) AsyncWith_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Raise"" , ( PyObject * ) Raise_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Try"" , ( PyObject * ) Try_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Assert"" , ( PyObject * ) Assert_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Import"" , ( PyObject * ) Import_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""ImportFrom"" , ( PyObject * ) ImportFrom_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Global"" , ( PyObject * ) Global_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Nonlocal"" , ( PyObject * ) Nonlocal_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Expr"" , ( PyObject * ) Expr_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Pass"" , ( PyObject * ) Pass_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Break"" , ( PyObject * ) Break_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Continue"" , ( PyObject * ) Continue_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""expr"" , ( PyObject * ) expr_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""BoolOp"" , ( PyObject * ) BoolOp_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""BinOp"" , ( PyObject * ) BinOp_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""UnaryOp"" , ( PyObject * ) UnaryOp_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Lambda"" , ( PyObject * ) Lambda_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""IfExp"" , ( PyObject * ) IfExp_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Dict"" , ( PyObject * ) Dict_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Set"" , ( PyObject * ) Set_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""ListComp"" , ( PyObject * ) ListComp_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""SetComp"" , ( PyObject * ) SetComp_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""DictComp"" , ( PyObject * ) DictComp_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""GeneratorExp"" , ( PyObject * ) GeneratorExp_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Await"" , ( PyObject * ) Await_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Yield"" , ( PyObject * ) Yield_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""YieldFrom"" , ( PyObject * ) YieldFrom_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Compare"" , ( PyObject * ) Compare_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Call"" , ( PyObject * ) Call_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Num"" , ( PyObject * ) Num_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Str"" , ( PyObject * ) Str_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""FormattedValue"" , ( PyObject * ) FormattedValue_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""JoinedStr"" , ( PyObject * ) JoinedStr_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Bytes"" , ( PyObject * ) Bytes_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""NameConstant"" , ( PyObject * ) NameConstant_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Ellipsis"" , ( PyObject * ) Ellipsis_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Constant"" , ( PyObject * ) Constant_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Attribute"" , ( PyObject * ) Attribute_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Subscript"" , ( PyObject * ) Subscript_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Starred"" , ( PyObject * ) Starred_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Name"" , ( PyObject * ) Name_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""List"" , ( PyObject * ) List_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Tuple"" , ( PyObject * ) Tuple_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""expr_context"" , ( PyObject * ) expr_context_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Load"" , ( PyObject * ) Load_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Store"" , ( PyObject * ) Store_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Del"" , ( PyObject * ) Del_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""AugLoad"" , ( PyObject * ) AugLoad_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""AugStore"" , ( PyObject * ) AugStore_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Param"" , ( PyObject * ) Param_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""slice"" , ( PyObject * ) slice_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Slice"" , ( PyObject * ) Slice_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""ExtSlice"" , ( PyObject * ) ExtSlice_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Index"" , ( PyObject * ) Index_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""boolop"" , ( PyObject * ) boolop_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""And"" , ( PyObject * ) And_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Or"" , ( PyObject * ) Or_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""operator"" , ( PyObject * ) operator_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Add"" , ( PyObject * ) Add_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Sub"" , ( PyObject * ) Sub_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Mult"" , ( PyObject * ) Mult_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""MatMult"" , ( PyObject * ) MatMult_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Div"" , ( PyObject * ) Div_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Mod"" , ( PyObject * ) Mod_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Pow"" , ( PyObject * ) Pow_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""LShift"" , ( PyObject * ) LShift_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""RShift"" , ( PyObject * ) RShift_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""BitOr"" , ( PyObject * ) BitOr_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""BitXor"" , ( PyObject * ) BitXor_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""BitAnd"" , ( PyObject * ) BitAnd_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""FloorDiv"" , ( PyObject * ) FloorDiv_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""unaryop"" , ( PyObject * ) unaryop_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Invert"" , ( PyObject * ) Invert_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Not"" , ( PyObject * ) Not_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""UAdd"" , ( PyObject * ) UAdd_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""USub"" , ( PyObject * ) USub_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""cmpop"" , ( PyObject * ) cmpop_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Eq"" , ( PyObject * ) Eq_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""NotEq"" , ( PyObject * ) NotEq_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Lt"" , ( PyObject * ) Lt_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""LtE"" , ( PyObject * ) LtE_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Gt"" , ( PyObject * ) Gt_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""GtE"" , ( PyObject * ) GtE_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""Is"" , ( PyObject * ) Is_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""IsNot"" , ( PyObject * ) IsNot_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""In"" , ( PyObject * ) In_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""NotIn"" , ( PyObject * ) NotIn_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""comprehension"" , ( PyObject * ) comprehension_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""excepthandler"" , ( PyObject * ) excepthandler_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""ExceptHandler"" , ( PyObject * ) ExceptHandler_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""arguments"" , ( PyObject * ) arguments_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""arg"" , ( PyObject * ) arg_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""keyword"" , ( PyObject * ) keyword_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""alias"" , ( PyObject * ) alias_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""withitem"" , ( PyObject * ) withitem_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""type_ignore"" , ( PyObject * ) type_ignore_type ) < 0 ) return NULL ; if ( PyDict_SetItemString ( d , ""TypeIgnore"" , ( PyObject * ) TypeIgnore_type ) < 0 ) return NULL ; return m ; } "," PyModule_Create ( & _astmodule ) ; if ",python@typed_ast/156afcb26c198e162504a57caddfe0acd9ed7dce,CVE-2019-19275,https://github.com/python/typed_ast/commit/156afcb26c198e162504a57caddfe0acd9ed7dce,2019-11-26T15:15Z 1449,CWE-362,"CWE-362 static int ptrace_check_attach ( struct task_struct * child , bool ignore_state ) { int ret = - ESRCH ; read_lock ( & tasklist_lock ) ; if ( ( child -> ptrace & PT_PTRACED ) && child -> parent == current ) { spin_lock_irq ( & child -> sighand -> siglock ) ; WARN_ON_ONCE ( task_is_stopped ( child ) ) ; if ( ignore_state || ( task_is_traced ( child ) && ! ( child -> jobctl & JOBCTL_LISTENING ) ) ) ret = 0 ; spin_unlock_irq ( & child -> sighand -> siglock ) ; } read_unlock ( & tasklist_lock ) ; if ( ! ret && ! ignore_state ) ret = wait_task_inactive ( child , TASK_TRACED ) ? 0 : - ESRCH ; return ret ; } "," ; if ( child -> ptrace child -> ptrace && child -> current ) { WARN_ON ( child -> state == __TASK_TRACED ) ; if ( ignore_state || ptrace_freeze_traced ( child ) ) ret ret = 0 ; } read_unlock ! ignore_state ) { if ( ! wait_task_inactive ( child ( child , __TASK_TRACED ) ) { WARN_ON ( child -> state == __TASK_TRACED ) ; ret = - ESRCH ; - ESRCH ; } } ",torvalds@linux/9899d11f654474d2d54ea52ceaa2a1f4db3abd68,CVE-2013-0871,https://github.com/torvalds/linux/commit/9899d11f654474d2d54ea52ceaa2a1f4db3abd68,2013-02-18T04:41Z 1450,CWE-416,"CWE-416 static void free_user ( struct kref * ref ) { struct ipmi_user * user = container_of ( ref , struct ipmi_user , refcount ) ; kfree ( user ) ; } "," refcount ) ; cleanup_srcu_struct ( & user -> release_barrier ) ; ",torvalds@linux/77f8269606bf95fcb232ee86f6da80886f1dfae8,CVE-2019-9003,https://github.com/torvalds/linux/commit/77f8269606bf95fcb232ee86f6da80886f1dfae8,2019-02-22T15:29Z 1451,CWE-285,"CWE-285 int ext2_set_acl ( struct inode * inode , struct posix_acl * acl , int type ) { int name_index ; void * value = NULL ; size_t size = 0 ; int error ; switch ( type ) { case ACL_TYPE_ACCESS : name_index = EXT2_XATTR_INDEX_POSIX_ACL_ACCESS ; if ( acl ) { error = posix_acl_equiv_mode ( acl , & inode -> i_mode ) ; if ( error < 0 ) return error ; else { inode -> i_ctime = CURRENT_TIME_SEC ; mark_inode_dirty ( inode ) ; if ( error == 0 ) acl = NULL ; } } break ; case ACL_TYPE_DEFAULT : name_index = EXT2_XATTR_INDEX_POSIX_ACL_DEFAULT ; if ( ! S_ISDIR ( inode -> i_mode ) ) return acl ? - EACCES : 0 ; break ; default : return - EINVAL ; } if ( acl ) { value = ext2_acl_to_disk ( acl , & size ) ; if ( IS_ERR ( value ) ) return ( int ) PTR_ERR ( value ) ; } error = ext2_xattr_set ( inode , name_index , """" , value , size , 0 ) ; 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 ; inode -> i_ctime inode ) ; } break ; ",torvalds@linux/073931017b49d9458aa351605b43a7e34598caef,CVE-2016-7097,https://github.com/torvalds/linux/commit/073931017b49d9458aa351605b43a7e34598caef,2016-10-16T21:59Z 1452,CWE-78,"CWE-78 static int download ( struct SPDBDownloader * pd ) { SPDBDownloaderOpt * opt = pd -> opt ; char * curl_cmd = NULL ; char * extractor_cmd = NULL ; char * abspath_to_archive = NULL ; char * abspath_to_file = NULL ; char * archive_name = NULL ; size_t archive_name_len = 0 ; char * symbol_store_path = NULL ; char * dbg_file = NULL ; char * guid = NULL ; char * archive_name_escaped = NULL ; char * user_agent = NULL ; char * symbol_server = NULL ; int res = 0 ; int cmd_ret ; if ( ! opt -> dbg_file || ! * opt -> dbg_file ) { return 0 ; } if ( ! checkCurl ( ) ) { return 0 ; } archive_name_len = strlen ( opt -> dbg_file ) ; archive_name = malloc ( archive_name_len + 1 ) ; if ( ! archive_name ) { return 0 ; } memcpy ( archive_name , opt -> dbg_file , archive_name_len + 1 ) ; archive_name [ archive_name_len - 1 ] = '_' ; symbol_store_path = r_str_escape ( opt -> symbol_store_path ) ; dbg_file = r_str_escape ( opt -> dbg_file ) ; guid = r_str_escape ( opt -> guid ) ; archive_name_escaped = r_str_escape ( archive_name ) ; user_agent = r_str_escape ( opt -> user_agent ) ; symbol_server = r_str_escape ( opt -> symbol_server ) ; abspath_to_archive = r_str_newf ( ""%s%s%s%s%s%s%s"" , symbol_store_path , R_SYS_DIR , dbg_file , R_SYS_DIR , guid , R_SYS_DIR , archive_name_escaped ) ; abspath_to_file = strdup ( abspath_to_archive ) ; abspath_to_file [ strlen ( abspath_to_file ) - 1 ] = 'b' ; if ( r_file_exists ( abspath_to_file ) ) { eprintf ( ""Filealreadydownloaded.\\n"" ) ; R_FREE ( user_agent ) ; R_FREE ( abspath_to_archive ) ; R_FREE ( archive_name_escaped ) ; R_FREE ( symbol_store_path ) ; R_FREE ( dbg_file ) ; R_FREE ( guid ) ; R_FREE ( archive_name ) ; R_FREE ( abspath_to_file ) ; R_FREE ( symbol_server ) ; return 1 ; } if ( checkExtract ( ) || opt -> extract == 0 ) { res = 1 ; curl_cmd = r_str_newf ( ""curl-sfLA\\""%s\\""\\""%s/%s/%s/%s\\""--create-dirs-o\\""%s\\"""" , user_agent , symbol_server , dbg_file , guid , archive_name_escaped , abspath_to_archive ) ; # if __WINDOWS__ const char * cabextractor = ""expand"" ; const char * format = ""%s%s%s"" ; extractor_cmd = r_str_newf ( format , cabextractor , abspath_to_archive , abspath_to_file ) ; # else const char * cabextractor = ""cabextract"" ; const char * format = ""%s-d\\""%s\\""\\""%s\\"""" ; char * abspath_to_dir = r_file_dirname ( abspath_to_archive ) ; extractor_cmd = r_str_newf ( format , cabextractor , abspath_to_dir , abspath_to_archive ) ; R_FREE ( abspath_to_dir ) ; # endif eprintf ( ""Attemptingtodownloadcompressedpdbin%s\\n"" , abspath_to_archive ) ; if ( ( cmd_ret = r_sys_cmd ( curl_cmd ) != 0 ) ) { eprintf ( ""curlexitedwitherror%d\\n"" , cmd_ret ) ; res = 0 ; } eprintf ( ""Attemptingtodecompresspdb\\n"" ) ; if ( opt -> extract > 0 ) { if ( res && ( ( cmd_ret = r_sys_cmd ( extractor_cmd ) ) != 0 ) ) { eprintf ( ""cabextractorexitedwitherror%d\\n"" , cmd_ret ) ; res = 0 ; } r_file_rm ( abspath_to_archive ) ; } R_FREE ( curl_cmd ) ; } if ( res == 0 ) { eprintf ( ""Fallingbacktouncompressedpdb\\n"" ) ; res = 1 ; archive_name_escaped [ strlen ( archive_name_escaped ) - 1 ] = 'b' ; curl_cmd = r_str_newf ( ""curl-sfLA\\""%s\\""\\""%s/%s/%s/%s\\""--create-dirs-o\\""%s\\"""" , opt -> user_agent , opt -> symbol_server , opt -> dbg_file , opt -> guid , archive_name_escaped , abspath_to_file ) ; eprintf ( ""Attemptingtodownloaduncompressedpdbin%s\\n"" , abspath_to_file ) ; if ( ( cmd_ret = r_sys_cmd ( curl_cmd ) != 0 ) ) { eprintf ( ""curlexitedwitherror%d\\n"" , cmd_ret ) ; res = 0 ; } R_FREE ( curl_cmd ) ; } R_FREE ( abspath_to_archive ) ; R_FREE ( abspath_to_file ) ; R_FREE ( archive_name ) ; R_FREE ( extractor_cmd ) ; R_FREE ( symbol_store_path ) ; R_FREE ( dbg_file ) ; R_FREE ( guid ) ; R_FREE ( archive_name_escaped ) ; R_FREE ( user_agent ) ; R_FREE ( symbol_server ) ; return res ; } "," -> opt ; int res = 0 ; } char * abspath_to_file = r_str_newf ( ""%s%s%s%s%s%s%s"" , opt -> symbol_store_path , R_SYS_DIR , opt -> dbg_file , R_SYS_DIR , opt -> guid , R_SYS_DIR , opt -> dbg_file ) ; if ( r_file_exists ( abspath_to_file ) ) { eprintf ( ""Filealreadydownloaded.\\n"" ) ; free ( abspath_to_file ) ; return 1 ; } if ( checkExtract ( ) || opt -> extract == 0 ) { char * extractor_cmd = NULL ; char * archive_name = strdup ( opt -> dbg_file ) ; archive_name [ strlen ( archive_name ) - 1 ] = '_' ; char * abspath_to_archive = r_str_newf ( ""%s%s%s%s%s%s%s"" , opt -> symbol_store_path , R_SYS_DIR , opt -> dbg_file , R_SYS_DIR , opt -> guid , R_SYS_DIR , archive_name ) ; eprintf ( ""Attemptingtodownloadcompressedpdbin%s\\n"" , abspath_to_archive ) ; char * abs_arch_esc = r_str_escape_sh ( abspath_to_archive ) ; # if __WINDOWS__ char * abs_file_esc = r_str_escape_sh ( abspath_to_file ) ; extractor_cmd = r_str_newf ( = r_str_newf ( ""expand\\""%s\\""\\""%s\\"""" , abs_arch_esc , abs_file_esc ) ; free ( abs_file_esc ) ; # ; # else char * abspath_to_dir abspath_to_archive ) ; char * abs_dir_esc = r_str_escape_sh ( abspath_to_dir ) ; = r_str_newf ( ""cabextract-d\\""%s\\""\\""%s\\"""" , abs_arch_esc , abs_dir_esc ) ; free ( abs_dir_esc ) ; free ( abspath_to_dir ) ; # endif free ( abs_arch_esc ) ; res = download_and_write ( opt , archive_name ) ; if extract > 0 && res ) { eprintf ( ""Attemptingtodecompresspdb\\n"" ) ; if ( res && ( ( cmd_ret ) ; } free ( archive_name ) ; free ( abspath_to_archive ) ; } ""Fallingbacktouncompressedpdb\\n"" ) ; eprintf ( ""Attemptingtodownloaduncompressedpdbin%s\\n"" abspath_to_file ) ; res = download_and_write ( opt , opt -> dbg_file ) ; } free ( abspath_to_file ) ; return ",radareorg@radare2/04edfa82c1f3fa2bc3621ccdad2f93bdbf00e4f9,CVE-2020-15121,https://github.com/radareorg/radare2/commit/04edfa82c1f3fa2bc3621ccdad2f93bdbf00e4f9,2020-07-20T18:15Z 1453,CWE-416,"CWE-416 PHP_MINIT_FUNCTION ( spl_array ) { REGISTER_SPL_STD_CLASS_EX ( ArrayObject , spl_array_object_new , spl_funcs_ArrayObject ) ; REGISTER_SPL_IMPLEMENTS ( ArrayObject , Aggregate ) ; REGISTER_SPL_IMPLEMENTS ( ArrayObject , ArrayAccess ) ; REGISTER_SPL_IMPLEMENTS ( ArrayObject , Serializable ) ; REGISTER_SPL_IMPLEMENTS ( ArrayObject , Countable ) ; memcpy ( & spl_handler_ArrayObject , zend_get_std_object_handlers ( ) , sizeof ( zend_object_handlers ) ) ; spl_handler_ArrayObject . clone_obj = spl_array_object_clone ; spl_handler_ArrayObject . read_dimension = spl_array_read_dimension ; spl_handler_ArrayObject . write_dimension = spl_array_write_dimension ; spl_handler_ArrayObject . unset_dimension = spl_array_unset_dimension ; spl_handler_ArrayObject . has_dimension = spl_array_has_dimension ; spl_handler_ArrayObject . count_elements = spl_array_object_count_elements ; spl_handler_ArrayObject . get_properties = spl_array_get_properties ; spl_handler_ArrayObject . get_debug_info = spl_array_get_debug_info ; spl_handler_ArrayObject . read_property = spl_array_read_property ; spl_handler_ArrayObject . write_property = spl_array_write_property ; spl_handler_ArrayObject . get_property_ptr_ptr = spl_array_get_property_ptr_ptr ; spl_handler_ArrayObject . has_property = spl_array_has_property ; spl_handler_ArrayObject . unset_property = spl_array_unset_property ; spl_handler_ArrayObject . compare_objects = spl_array_compare_objects ; REGISTER_SPL_STD_CLASS_EX ( ArrayIterator , spl_array_object_new , spl_funcs_ArrayIterator ) ; REGISTER_SPL_IMPLEMENTS ( ArrayIterator , Iterator ) ; REGISTER_SPL_IMPLEMENTS ( ArrayIterator , ArrayAccess ) ; REGISTER_SPL_IMPLEMENTS ( ArrayIterator , SeekableIterator ) ; REGISTER_SPL_IMPLEMENTS ( ArrayIterator , Serializable ) ; REGISTER_SPL_IMPLEMENTS ( ArrayIterator , Countable ) ; memcpy ( & spl_handler_ArrayIterator , & spl_handler_ArrayObject , sizeof ( zend_object_handlers ) ) ; spl_ce_ArrayIterator -> get_iterator = spl_array_get_iterator ; REGISTER_SPL_SUB_CLASS_EX ( RecursiveArrayIterator , ArrayIterator , spl_array_object_new , spl_funcs_RecursiveArrayIterator ) ; REGISTER_SPL_IMPLEMENTS ( RecursiveArrayIterator , RecursiveIterator ) ; spl_ce_RecursiveArrayIterator -> get_iterator = spl_array_get_iterator ; REGISTER_SPL_CLASS_CONST_LONG ( ArrayObject , ""STD_PROP_LIST"" , SPL_ARRAY_STD_PROP_LIST ) ; REGISTER_SPL_CLASS_CONST_LONG ( ArrayObject , ""ARRAY_AS_PROPS"" , SPL_ARRAY_ARRAY_AS_PROPS ) ; REGISTER_SPL_CLASS_CONST_LONG ( ArrayIterator , ""STD_PROP_LIST"" , SPL_ARRAY_STD_PROP_LIST ) ; REGISTER_SPL_CLASS_CONST_LONG ( ArrayIterator , ""ARRAY_AS_PROPS"" , SPL_ARRAY_ARRAY_AS_PROPS ) ; REGISTER_SPL_CLASS_CONST_LONG ( RecursiveArrayIterator , ""CHILD_ARRAYS_ONLY"" , SPL_ARRAY_CHILD_ARRAYS_ONLY ) ; return SUCCESS ; } "," get_debug_info = spl_array_get_debug_info ; spl_handler_ArrayObject . get_gc = spl_array_get_gc ",php@php-src/3f627e580acfdaf0595ae3b115b8bec677f203ee,CVE-2016-5771,https://github.com/php/php-src/commit/3f627e580acfdaf0595ae3b115b8bec677f203ee?w=1,2016-08-07T10:59Z 1454,CWE-401,"CWE-401 int i2400m_op_rfkill_sw_toggle ( struct wimax_dev * wimax_dev , enum wimax_rf_state state ) { int result ; struct i2400m * i2400m = wimax_dev_to_i2400m ( wimax_dev ) ; struct device * dev = i2400m_dev ( i2400m ) ; struct sk_buff * ack_skb ; struct { struct i2400m_l3l4_hdr hdr ; struct i2400m_tlv_rf_operation sw_rf ; } __packed * cmd ; char strerr [ 32 ] ; d_fnstart ( 4 , dev , ""(wimax_dev%pstate%d)\\n"" , wimax_dev , state ) ; result = - ENOMEM ; cmd = kzalloc ( sizeof ( * cmd ) , GFP_KERNEL ) ; if ( cmd == NULL ) goto error_alloc ; cmd -> hdr . type = cpu_to_le16 ( I2400M_MT_CMD_RF_CONTROL ) ; cmd -> hdr . length = sizeof ( cmd -> sw_rf ) ; cmd -> hdr . version = cpu_to_le16 ( I2400M_L3L4_VERSION ) ; cmd -> sw_rf . hdr . type = cpu_to_le16 ( I2400M_TLV_RF_OPERATION ) ; cmd -> sw_rf . hdr . length = cpu_to_le16 ( sizeof ( cmd -> sw_rf . status ) ) ; switch ( state ) { case WIMAX_RF_OFF : cmd -> sw_rf . status = cpu_to_le32 ( 2 ) ; break ; case WIMAX_RF_ON : cmd -> sw_rf . status = cpu_to_le32 ( 1 ) ; break ; default : BUG ( ) ; } ack_skb = i2400m_msg_to_dev ( i2400m , cmd , sizeof ( * cmd ) ) ; result = PTR_ERR ( ack_skb ) ; if ( IS_ERR ( ack_skb ) ) { dev_err ( dev , ""Failedtoissue\'RFControl\'command:%d\\n"" , result ) ; goto error_msg_to_dev ; } result = i2400m_msg_check_status ( wimax_msg_data ( ack_skb ) , strerr , sizeof ( strerr ) ) ; if ( result < 0 ) { dev_err ( dev , ""\'RFControl\'(0x%04x)commandfailed:%d-%s\\n"" , I2400M_MT_CMD_RF_CONTROL , result , strerr ) ; goto error_cmd ; } result = wait_event_timeout ( i2400m -> state_wq , i2400m_radio_is ( i2400m , state ) , 5 * HZ ) ; if ( result == 0 ) result = - ETIMEDOUT ; if ( result < 0 ) dev_err ( dev , ""ErrorwaitingfordevicetotoggleRFstate:"" ""%d\\n"" , result ) ; result = 0 ; error_cmd : kfree ( cmd ) ; kfree_skb ( ack_skb ) ; error_msg_to_dev : error_alloc : d_fnend ( 4 , dev , ""(wimax_dev%pstate%d)=%d\\n"" , wimax_dev , state , result ) ; return result ; } "," ; error_cmd : kfree_skb ( ack_skb ) ; error_msg_to_dev : error_alloc : d_fnend ( 4 , dev , ""(wimax_dev%pstate%d)=%d\\n"" , wimax_dev , state , result ) ; kfree ( cmd ) ; return ",torvalds@linux/6f3ef5c25cc762687a7341c18cbea5af54461407,CVE-2019-19051,https://github.com/torvalds/linux/commit/6f3ef5c25cc762687a7341c18cbea5af54461407,2019-11-18T06:15Z 1455,CWE-476,"CWE-476 static void process_lru_command ( conn * c , token_t * tokens , const size_t ntokens ) { uint32_t pct_hot ; uint32_t pct_warm ; double hot_factor ; int32_t ttl ; double factor ; set_noreply_maybe ( c , tokens , ntokens ) ; if ( strcmp ( tokens [ 1 ] . value , ""tune"" ) == 0 && ntokens >= 7 ) { if ( ! safe_strtoul ( tokens [ 2 ] . value , & pct_hot ) || ! safe_strtoul ( tokens [ 3 ] . value , & pct_warm ) || ! safe_strtod ( tokens [ 4 ] . value , & hot_factor ) || ! safe_strtod ( tokens [ 5 ] . value , & factor ) ) { out_string ( c , ""ERROR"" ) ; } else { if ( pct_hot + pct_warm > 80 ) { out_string ( c , ""ERRORhotandwarmpctsmustnotexceed80"" ) ; } else if ( factor <= 0 || hot_factor <= 0 ) { out_string ( c , ""ERRORhot/warmagefactorsmustbegreaterthan0"" ) ; } else { settings . hot_lru_pct = pct_hot ; settings . warm_lru_pct = pct_warm ; settings . hot_max_factor = hot_factor ; settings . warm_max_factor = factor ; out_string ( c , ""OK"" ) ; } } } else if ( strcmp ( tokens [ 1 ] . value , ""mode"" ) == 0 && ntokens >= 3 && settings . lru_maintainer_thread ) { if ( strcmp ( tokens [ 2 ] . value , ""flat"" ) == 0 ) { settings . lru_segmented = false ; out_string ( c , ""OK"" ) ; } else if ( strcmp ( tokens [ 2 ] . value , ""segmented"" ) == 0 ) { settings . lru_segmented = true ; out_string ( c , ""OK"" ) ; } else { out_string ( c , ""ERROR"" ) ; } } else if ( strcmp ( tokens [ 1 ] . value , ""temp_ttl"" ) == 0 && ntokens >= 3 && settings . lru_maintainer_thread ) { if ( ! safe_strtol ( tokens [ 2 ] . value , & ttl ) ) { out_string ( c , ""ERROR"" ) ; } else { if ( ttl < 0 ) { settings . temp_lru = false ; } else { settings . temp_lru = true ; settings . temporary_ttl = ttl ; } out_string ( c , ""OK"" ) ; } } else { out_string ( c , ""ERROR"" ) ; } } "," && ntokens >= 4 && settings . && ntokens >= 4 && settings . ",memcached@memcached/d35334f368817a77a6bd1f33c6a5676b2c402c02,CVE-2019-11596,https://github.com/memcached/memcached/commit/d35334f368817a77a6bd1f33c6a5676b2c402c02,2019-04-29T15:29Z 1456,CWE-190,"CWE-190 void jas_matrix_divpow2 ( jas_matrix_t * matrix , int n ) { int i ; int j ; jas_seqent_t * rowstart ; int rowstep ; jas_seqent_t * data ; 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 = ( * data >= 0 ) ? ( ( * data ) >> n ) : ( - ( ( - ( * 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 1457,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 1458,CWE-476,"CWE-476 rdpCredssp * credssp_new ( freerdp * instance , rdpTransport * transport , rdpSettings * settings ) { rdpCredssp * credssp ; credssp = ( rdpCredssp * ) malloc ( sizeof ( rdpCredssp ) ) ; ZeroMemory ( credssp , sizeof ( rdpCredssp ) ) ; if ( credssp != NULL ) { HKEY hKey ; LONG status ; DWORD dwType ; DWORD dwSize ; credssp -> instance = instance ; credssp -> settings = settings ; credssp -> server = settings -> ServerMode ; credssp -> transport = transport ; credssp -> send_seq_num = 0 ; credssp -> recv_seq_num = 0 ; ZeroMemory ( & credssp -> negoToken , sizeof ( SecBuffer ) ) ; ZeroMemory ( & credssp -> pubKeyAuth , sizeof ( SecBuffer ) ) ; ZeroMemory ( & credssp -> authInfo , sizeof ( SecBuffer ) ) ; if ( credssp -> server ) { status = RegOpenKeyEx ( HKEY_LOCAL_MACHINE , _T ( ""Software\\\\FreeRDP\\\\Server"" ) , 0 , KEY_READ | KEY_WOW64_64KEY , & hKey ) ; if ( status == ERROR_SUCCESS ) { status = RegQueryValueEx ( hKey , _T ( ""SspiModule"" ) , NULL , & dwType , NULL , & dwSize ) ; if ( status == ERROR_SUCCESS ) { credssp -> SspiModule = ( LPTSTR ) malloc ( dwSize + sizeof ( TCHAR ) ) ; status = RegQueryValueEx ( hKey , _T ( ""SspiModule"" ) , NULL , & dwType , ( BYTE * ) credssp -> SspiModule , & dwSize ) ; if ( status == ERROR_SUCCESS ) { _tprintf ( _T ( ""UsingSSPIModule:%s\\n"" ) , credssp -> SspiModule ) ; RegCloseKey ( hKey ) ; } } } } } return credssp ; } "," ( SecBuffer ) ) ; SecInvalidateHandle ( & credssp -> context ",FreeRDP@FreeRDP/0773bb9303d24473fe1185d85a424dfe159aff53,CVE-2013-4119,https://github.com/FreeRDP/FreeRDP/commit/0773bb9303d24473fe1185d85a424dfe159aff53,2016-10-03T21:59Z 1459,CWE-119,"CWE-119 static void copy_fields ( const FieldMatchContext * fm , AVFrame * dst , const AVFrame * src , int field ) { int plane ; for ( plane = 0 ; plane < 4 && src -> data [ plane ] ; plane ++ ) av_image_copy_plane ( dst -> data [ plane ] + field * dst -> linesize [ plane ] , dst -> linesize [ plane ] << 1 , src -> data [ plane ] + field * src -> linesize [ plane ] , src -> linesize [ plane ] << 1 , get_width ( fm , src , plane ) , get_height ( fm , src , plane ) / 2 ) ; } "," src -> data [ plane ] && src -> linesize ",FFmpeg@FFmpeg/e43a0a232dbf6d3c161823c2e07c52e76227a1bc,CVE-2013-4263,https://github.com/FFmpeg/FFmpeg/commit/e43a0a232dbf6d3c161823c2e07c52e76227a1bc,2013-11-23T17:55Z 1460,CWE-476,"CWE-476 int sqlite3ExprCodeTarget ( Parse * pParse , Expr * pExpr , int target ) { Vdbe * v = pParse -> pVdbe ; int op ; int inReg = target ; int regFree1 = 0 ; int regFree2 = 0 ; int r1 , r2 ; Expr tempX ; int p5 = 0 ; assert ( target > 0 && target <= pParse -> nMem ) ; if ( v == 0 ) { assert ( pParse -> db -> mallocFailed ) ; return 0 ; } expr_code_doover : if ( pExpr == 0 ) { op = TK_NULL ; } else { op = pExpr -> op ; } switch ( op ) { case TK_AGG_COLUMN : { AggInfo * pAggInfo = pExpr -> pAggInfo ; struct AggInfo_col * pCol = & pAggInfo -> aCol [ pExpr -> iAgg ] ; if ( ! pAggInfo -> directMode ) { assert ( pCol -> iMem > 0 ) ; return pCol -> iMem ; } else if ( pAggInfo -> useSortingIdx ) { sqlite3VdbeAddOp3 ( v , OP_Column , pAggInfo -> sortingIdxPTab , pCol -> iSorterColumn , target ) ; return target ; } } case TK_COLUMN : { int iTab = pExpr -> iTable ; if ( ExprHasProperty ( pExpr , EP_FixedCol ) ) { int iReg = sqlite3ExprCodeTarget ( pParse , pExpr -> pLeft , target ) ; int aff = sqlite3TableColumnAffinity ( pExpr -> y . pTab , pExpr -> iColumn ) ; if ( aff > SQLITE_AFF_BLOB ) { static const char zAff [ ] = ""B\\000C\\000D\\000E"" ; assert ( SQLITE_AFF_BLOB == 'A' ) ; assert ( SQLITE_AFF_TEXT == 'B' ) ; if ( iReg != target ) { sqlite3VdbeAddOp2 ( v , OP_SCopy , iReg , target ) ; iReg = target ; } sqlite3VdbeAddOp4 ( v , OP_Affinity , iReg , 1 , 0 , & zAff [ ( aff - 'B' ) * 2 ] , P4_STATIC ) ; } return iReg ; } if ( iTab < 0 ) { if ( pParse -> iSelfTab < 0 ) { Column * pCol ; Table * pTab = pExpr -> y . pTab ; int iSrc ; int iCol = pExpr -> iColumn ; assert ( pTab != 0 ) ; assert ( iCol >= XN_ROWID ) ; assert ( iCol < pExpr -> y . pTab -> nCol ) ; if ( iCol < 0 ) { return - 1 - pParse -> iSelfTab ; } pCol = pTab -> aCol + iCol ; testcase ( iCol != sqlite3TableColumnToStorage ( pTab , iCol ) ) ; iSrc = sqlite3TableColumnToStorage ( pTab , iCol ) - pParse -> iSelfTab ; # ifndef SQLITE_OMIT_GENERATED_COLUMNS if ( pCol -> colFlags & COLFLAG_GENERATED ) { if ( pCol -> colFlags & COLFLAG_BUSY ) { sqlite3ErrorMsg ( pParse , ""generatedcolumnloopon\\""%s\\"""" , pCol -> zName ) ; return 0 ; } pCol -> colFlags |= COLFLAG_BUSY ; if ( pCol -> colFlags & COLFLAG_NOTAVAIL ) { sqlite3ExprCodeGeneratedColumn ( pParse , pCol , iSrc ) ; } pCol -> colFlags &= ~ ( COLFLAG_BUSY | COLFLAG_NOTAVAIL ) ; return iSrc ; } else # endif if ( pCol -> affinity == SQLITE_AFF_REAL ) { sqlite3VdbeAddOp2 ( v , OP_SCopy , iSrc , target ) ; sqlite3VdbeAddOp1 ( v , OP_RealAffinity , target ) ; return target ; } else { return iSrc ; } } else { iTab = pParse -> iSelfTab - 1 ; } } return sqlite3ExprCodeGetColumn ( pParse , pExpr -> y . pTab , pExpr -> iColumn , iTab , target , pExpr -> op2 ) ; } case TK_INTEGER : { codeInteger ( pParse , pExpr , 0 , target ) ; return target ; } case TK_TRUEFALSE : { sqlite3VdbeAddOp2 ( v , OP_Integer , sqlite3ExprTruthValue ( pExpr ) , target ) ; return target ; } # ifndef SQLITE_OMIT_FLOATING_POINT case TK_FLOAT : { assert ( ! ExprHasProperty ( pExpr , EP_IntValue ) ) ; codeReal ( v , pExpr -> u . zToken , 0 , target ) ; return target ; } # endif case TK_STRING : { assert ( ! ExprHasProperty ( pExpr , EP_IntValue ) ) ; sqlite3VdbeLoadString ( v , target , pExpr -> u . zToken ) ; return target ; } case TK_NULL : { sqlite3VdbeAddOp2 ( v , OP_Null , 0 , target ) ; return target ; } # ifndef SQLITE_OMIT_BLOB_LITERAL case TK_BLOB : { int n ; const char * z ; char * zBlob ; assert ( ! ExprHasProperty ( pExpr , EP_IntValue ) ) ; assert ( pExpr -> u . zToken [ 0 ] == 'x' || pExpr -> u . zToken [ 0 ] == 'X' ) ; assert ( pExpr -> u . zToken [ 1 ] == '\\'' ) ; z = & pExpr -> u . zToken [ 2 ] ; n = sqlite3Strlen30 ( z ) - 1 ; assert ( z [ n ] == '\\'' ) ; zBlob = sqlite3HexToBlob ( sqlite3VdbeDb ( v ) , z , n ) ; sqlite3VdbeAddOp4 ( v , OP_Blob , n / 2 , target , 0 , zBlob , P4_DYNAMIC ) ; return target ; } # endif case TK_VARIABLE : { assert ( ! ExprHasProperty ( pExpr , EP_IntValue ) ) ; assert ( pExpr -> u . zToken != 0 ) ; assert ( pExpr -> u . zToken [ 0 ] != 0 ) ; sqlite3VdbeAddOp2 ( v , OP_Variable , pExpr -> iColumn , target ) ; if ( pExpr -> u . zToken [ 1 ] != 0 ) { const char * z = sqlite3VListNumToName ( pParse -> pVList , pExpr -> iColumn ) ; assert ( pExpr -> u . zToken [ 0 ] == '?' || strcmp ( pExpr -> u . zToken , z ) == 0 ) ; pParse -> pVList [ 0 ] = 0 ; sqlite3VdbeAppendP4 ( v , ( char * ) z , P4_STATIC ) ; } return target ; } case TK_REGISTER : { return pExpr -> iTable ; } # ifndef SQLITE_OMIT_CAST case TK_CAST : { inReg = sqlite3ExprCodeTarget ( pParse , pExpr -> pLeft , target ) ; if ( inReg != target ) { sqlite3VdbeAddOp2 ( v , OP_SCopy , inReg , target ) ; inReg = target ; } sqlite3VdbeAddOp2 ( v , OP_Cast , target , sqlite3AffinityType ( pExpr -> u . zToken , 0 ) ) ; return inReg ; } # endif case TK_IS : case TK_ISNOT : op = ( op == TK_IS ) ? TK_EQ : TK_NE ; p5 = SQLITE_NULLEQ ; case TK_LT : case TK_LE : case TK_GT : case TK_GE : case TK_NE : case TK_EQ : { Expr * pLeft = pExpr -> pLeft ; if ( sqlite3ExprIsVector ( pLeft ) ) { codeVectorCompare ( pParse , pExpr , target , op , p5 ) ; } else { r1 = sqlite3ExprCodeTemp ( pParse , pLeft , & regFree1 ) ; r2 = sqlite3ExprCodeTemp ( pParse , pExpr -> pRight , & regFree2 ) ; codeCompare ( pParse , pLeft , pExpr -> pRight , op , r1 , r2 , inReg , SQLITE_STOREP2 | p5 , ExprHasProperty ( pExpr , EP_Commuted ) ) ; assert ( TK_LT == OP_Lt ) ; testcase ( op == OP_Lt ) ; VdbeCoverageIf ( v , op == OP_Lt ) ; assert ( TK_LE == OP_Le ) ; testcase ( op == OP_Le ) ; VdbeCoverageIf ( v , op == OP_Le ) ; assert ( TK_GT == OP_Gt ) ; testcase ( op == OP_Gt ) ; VdbeCoverageIf ( v , op == OP_Gt ) ; assert ( TK_GE == OP_Ge ) ; testcase ( op == OP_Ge ) ; VdbeCoverageIf ( v , op == OP_Ge ) ; assert ( TK_EQ == OP_Eq ) ; testcase ( op == OP_Eq ) ; VdbeCoverageIf ( v , op == OP_Eq ) ; assert ( TK_NE == OP_Ne ) ; testcase ( op == OP_Ne ) ; VdbeCoverageIf ( v , op == OP_Ne ) ; testcase ( regFree1 == 0 ) ; testcase ( regFree2 == 0 ) ; } break ; } case TK_AND : case TK_OR : case TK_PLUS : case TK_STAR : case TK_MINUS : case TK_REM : case TK_BITAND : case TK_BITOR : case TK_SLASH : case TK_LSHIFT : case TK_RSHIFT : case TK_CONCAT : { assert ( TK_AND == OP_And ) ; testcase ( op == TK_AND ) ; assert ( TK_OR == OP_Or ) ; testcase ( op == TK_OR ) ; assert ( TK_PLUS == OP_Add ) ; testcase ( op == TK_PLUS ) ; assert ( TK_MINUS == OP_Subtract ) ; testcase ( op == TK_MINUS ) ; assert ( TK_REM == OP_Remainder ) ; testcase ( op == TK_REM ) ; assert ( TK_BITAND == OP_BitAnd ) ; testcase ( op == TK_BITAND ) ; assert ( TK_BITOR == OP_BitOr ) ; testcase ( op == TK_BITOR ) ; assert ( TK_SLASH == OP_Divide ) ; testcase ( op == TK_SLASH ) ; assert ( TK_LSHIFT == OP_ShiftLeft ) ; testcase ( op == TK_LSHIFT ) ; assert ( TK_RSHIFT == OP_ShiftRight ) ; testcase ( op == TK_RSHIFT ) ; assert ( TK_CONCAT == OP_Concat ) ; testcase ( op == TK_CONCAT ) ; r1 = sqlite3ExprCodeTemp ( pParse , pExpr -> pLeft , & regFree1 ) ; r2 = sqlite3ExprCodeTemp ( pParse , pExpr -> pRight , & regFree2 ) ; sqlite3VdbeAddOp3 ( v , op , r2 , r1 , target ) ; testcase ( regFree1 == 0 ) ; testcase ( regFree2 == 0 ) ; break ; } case TK_UMINUS : { Expr * pLeft = pExpr -> pLeft ; assert ( pLeft ) ; if ( pLeft -> op == TK_INTEGER ) { codeInteger ( pParse , pLeft , 1 , target ) ; return target ; # ifndef SQLITE_OMIT_FLOATING_POINT } else if ( pLeft -> op == TK_FLOAT ) { assert ( ! ExprHasProperty ( pExpr , EP_IntValue ) ) ; codeReal ( v , pLeft -> u . zToken , 1 , target ) ; return target ; # endif } else { tempX . op = TK_INTEGER ; tempX . flags = EP_IntValue | EP_TokenOnly ; tempX . u . iValue = 0 ; r1 = sqlite3ExprCodeTemp ( pParse , & tempX , & regFree1 ) ; r2 = sqlite3ExprCodeTemp ( pParse , pExpr -> pLeft , & regFree2 ) ; sqlite3VdbeAddOp3 ( v , OP_Subtract , r2 , r1 , target ) ; testcase ( regFree2 == 0 ) ; } break ; } case TK_BITNOT : case TK_NOT : { assert ( TK_BITNOT == OP_BitNot ) ; testcase ( op == TK_BITNOT ) ; assert ( TK_NOT == OP_Not ) ; testcase ( op == TK_NOT ) ; r1 = sqlite3ExprCodeTemp ( pParse , pExpr -> pLeft , & regFree1 ) ; testcase ( regFree1 == 0 ) ; sqlite3VdbeAddOp2 ( v , op , r1 , inReg ) ; break ; } case TK_TRUTH : { int isTrue ; int bNormal ; r1 = sqlite3ExprCodeTemp ( pParse , pExpr -> pLeft , & regFree1 ) ; testcase ( regFree1 == 0 ) ; isTrue = sqlite3ExprTruthValue ( pExpr -> pRight ) ; bNormal = pExpr -> op2 == TK_IS ; testcase ( isTrue && bNormal ) ; testcase ( ! isTrue && bNormal ) ; sqlite3VdbeAddOp4Int ( v , OP_IsTrue , r1 , inReg , ! isTrue , isTrue ^ bNormal ) ; break ; } case TK_ISNULL : case TK_NOTNULL : { int addr ; assert ( TK_ISNULL == OP_IsNull ) ; testcase ( op == TK_ISNULL ) ; assert ( TK_NOTNULL == OP_NotNull ) ; testcase ( op == TK_NOTNULL ) ; sqlite3VdbeAddOp2 ( v , OP_Integer , 1 , target ) ; r1 = sqlite3ExprCodeTemp ( pParse , pExpr -> pLeft , & regFree1 ) ; testcase ( regFree1 == 0 ) ; addr = sqlite3VdbeAddOp1 ( v , op , r1 ) ; VdbeCoverageIf ( v , op == TK_ISNULL ) ; VdbeCoverageIf ( v , op == TK_NOTNULL ) ; sqlite3VdbeAddOp2 ( v , OP_Integer , 0 , target ) ; sqlite3VdbeJumpHere ( v , addr ) ; break ; } case TK_AGG_FUNCTION : { AggInfo * pInfo = pExpr -> pAggInfo ; if ( pInfo == 0 ) { assert ( ! ExprHasProperty ( pExpr , EP_IntValue ) ) ; sqlite3ErrorMsg ( pParse , ""misuseofaggregate:%s()"" , pExpr -> u . zToken ) ; } else { return pInfo -> aFunc [ pExpr -> iAgg ] . iMem ; } break ; } case TK_FUNCTION : { ExprList * pFarg ; int nFarg ; FuncDef * pDef ; const char * zId ; u32 constMask = 0 ; int i ; sqlite3 * db = pParse -> db ; u8 enc = ENC ( db ) ; CollSeq * pColl = 0 ; # ifndef SQLITE_OMIT_WINDOWFUNC if ( ExprHasProperty ( pExpr , EP_WinFunc ) ) { return pExpr -> y . pWin -> regResult ; } # endif if ( ConstFactorOk ( pParse ) && sqlite3ExprIsConstantNotJoin ( pExpr ) ) { return sqlite3ExprCodeAtInit ( pParse , pExpr , - 1 ) ; } assert ( ! ExprHasProperty ( pExpr , EP_xIsSelect ) ) ; if ( ExprHasProperty ( pExpr , EP_TokenOnly ) ) { pFarg = 0 ; } else { pFarg = pExpr -> x . pList ; } nFarg = pFarg ? pFarg -> nExpr : 0 ; assert ( ! ExprHasProperty ( pExpr , EP_IntValue ) ) ; zId = pExpr -> u . zToken ; pDef = sqlite3FindFunction ( db , zId , nFarg , enc , 0 ) ; # ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION if ( pDef == 0 && pParse -> explain ) { pDef = sqlite3FindFunction ( db , ""unknown"" , nFarg , enc , 0 ) ; } # endif if ( pDef == 0 || pDef -> xFinalize != 0 ) { sqlite3ErrorMsg ( pParse , ""unknownfunction:%s()"" , zId ) ; break ; } if ( pDef -> funcFlags & SQLITE_FUNC_COALESCE ) { int endCoalesce = sqlite3VdbeMakeLabel ( pParse ) ; assert ( nFarg >= 2 ) ; sqlite3ExprCode ( pParse , pFarg -> a [ 0 ] . pExpr , target ) ; for ( i = 1 ; i < nFarg ; i ++ ) { sqlite3VdbeAddOp2 ( v , OP_NotNull , target , endCoalesce ) ; VdbeCoverage ( v ) ; sqlite3ExprCode ( pParse , pFarg -> a [ i ] . pExpr , target ) ; } sqlite3VdbeResolveLabel ( v , endCoalesce ) ; break ; } if ( pDef -> funcFlags & SQLITE_FUNC_UNLIKELY ) { assert ( nFarg >= 1 ) ; return sqlite3ExprCodeTarget ( pParse , pFarg -> a [ 0 ] . pExpr , target ) ; } # ifdef SQLITE_DEBUG if ( pDef -> funcFlags & SQLITE_FUNC_AFFINITY ) { const char * azAff [ ] = { ""blob"" , ""text"" , ""numeric"" , ""integer"" , ""real"" } ; char aff ; assert ( nFarg == 1 ) ; aff = sqlite3ExprAffinity ( pFarg -> a [ 0 ] . pExpr ) ; sqlite3VdbeLoadString ( v , target , ( aff <= SQLITE_AFF_NONE ) ? ""none"" : azAff [ aff - SQLITE_AFF_BLOB ] ) ; return target ; } # endif for ( i = 0 ; i < nFarg ; i ++ ) { if ( i < 32 && sqlite3ExprIsConstant ( pFarg -> a [ i ] . pExpr ) ) { testcase ( i == 31 ) ; constMask |= MASKBIT32 ( i ) ; } if ( ( pDef -> funcFlags & SQLITE_FUNC_NEEDCOLL ) != 0 && ! pColl ) { pColl = sqlite3ExprCollSeq ( pParse , pFarg -> a [ i ] . pExpr ) ; } } if ( pFarg ) { if ( constMask ) { r1 = pParse -> nMem + 1 ; pParse -> nMem += nFarg ; } else { r1 = sqlite3GetTempRange ( pParse , nFarg ) ; } if ( ( pDef -> funcFlags & ( SQLITE_FUNC_LENGTH | SQLITE_FUNC_TYPEOF ) ) != 0 ) { u8 exprOp ; assert ( nFarg == 1 ) ; assert ( pFarg -> a [ 0 ] . pExpr != 0 ) ; exprOp = pFarg -> a [ 0 ] . pExpr -> op ; if ( exprOp == TK_COLUMN || exprOp == TK_AGG_COLUMN ) { assert ( SQLITE_FUNC_LENGTH == OPFLAG_LENGTHARG ) ; assert ( SQLITE_FUNC_TYPEOF == OPFLAG_TYPEOFARG ) ; testcase ( pDef -> funcFlags & OPFLAG_LENGTHARG ) ; pFarg -> a [ 0 ] . pExpr -> op2 = pDef -> funcFlags & ( OPFLAG_LENGTHARG | OPFLAG_TYPEOFARG ) ; } } sqlite3ExprCodeExprList ( pParse , pFarg , r1 , 0 , SQLITE_ECEL_DUP | SQLITE_ECEL_FACTOR ) ; } else { r1 = 0 ; } # ifndef SQLITE_OMIT_VIRTUALTABLE if ( nFarg >= 2 && ExprHasProperty ( pExpr , EP_InfixFunc ) ) { pDef = sqlite3VtabOverloadFunction ( db , pDef , nFarg , pFarg -> a [ 1 ] . pExpr ) ; } else if ( nFarg > 0 ) { pDef = sqlite3VtabOverloadFunction ( db , pDef , nFarg , pFarg -> a [ 0 ] . pExpr ) ; } # endif if ( pDef -> funcFlags & SQLITE_FUNC_NEEDCOLL ) { if ( ! pColl ) pColl = db -> pDfltColl ; sqlite3VdbeAddOp4 ( v , OP_CollSeq , 0 , 0 , 0 , ( char * ) pColl , P4_COLLSEQ ) ; } # ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC if ( pDef -> funcFlags & SQLITE_FUNC_OFFSET ) { Expr * pArg = pFarg -> a [ 0 ] . pExpr ; if ( pArg -> op == TK_COLUMN ) { sqlite3VdbeAddOp3 ( v , OP_Offset , pArg -> iTable , pArg -> iColumn , target ) ; } else { sqlite3VdbeAddOp2 ( v , OP_Null , 0 , target ) ; } } else # endif { sqlite3VdbeAddFunctionCall ( pParse , constMask , r1 , target , nFarg , pDef , pExpr -> op2 ) ; } if ( nFarg && constMask == 0 ) { sqlite3ReleaseTempRange ( pParse , r1 , nFarg ) ; } return target ; } # ifndef SQLITE_OMIT_SUBQUERY case TK_EXISTS : case TK_SELECT : { int nCol ; testcase ( op == TK_EXISTS ) ; testcase ( op == TK_SELECT ) ; if ( op == TK_SELECT && ( nCol = pExpr -> x . pSelect -> pEList -> nExpr ) != 1 ) { sqlite3SubselectError ( pParse , nCol , 1 ) ; } else { return sqlite3CodeSubselect ( pParse , pExpr ) ; } break ; } case TK_SELECT_COLUMN : { int n ; if ( pExpr -> pLeft -> iTable == 0 ) { pExpr -> pLeft -> iTable = sqlite3CodeSubselect ( pParse , pExpr -> pLeft ) ; } assert ( pExpr -> iTable == 0 || pExpr -> pLeft -> op == TK_SELECT ) ; if ( pExpr -> iTable != 0 && pExpr -> iTable != ( n = sqlite3ExprVectorSize ( pExpr -> pLeft ) ) ) { sqlite3ErrorMsg ( pParse , ""%dcolumnsassigned%dvalues"" , pExpr -> iTable , n ) ; } return pExpr -> pLeft -> iTable + pExpr -> iColumn ; } case TK_IN : { int destIfFalse = sqlite3VdbeMakeLabel ( pParse ) ; int destIfNull = sqlite3VdbeMakeLabel ( pParse ) ; sqlite3VdbeAddOp2 ( v , OP_Null , 0 , target ) ; sqlite3ExprCodeIN ( pParse , pExpr , destIfFalse , destIfNull ) ; sqlite3VdbeAddOp2 ( v , OP_Integer , 1 , target ) ; sqlite3VdbeResolveLabel ( v , destIfFalse ) ; sqlite3VdbeAddOp2 ( v , OP_AddImm , target , 0 ) ; sqlite3VdbeResolveLabel ( v , destIfNull ) ; return target ; } # endif case TK_BETWEEN : { exprCodeBetween ( pParse , pExpr , target , 0 , 0 ) ; return target ; } case TK_SPAN : case TK_COLLATE : case TK_UPLUS : { pExpr = pExpr -> pLeft ; goto expr_code_doover ; } case TK_TRIGGER : { Table * pTab = pExpr -> y . pTab ; int iCol = pExpr -> iColumn ; int p1 = pExpr -> iTable * ( pTab -> nCol + 1 ) + 1 + ( iCol >= 0 ? sqlite3TableColumnToStorage ( pTab , iCol ) : - 1 ) ; assert ( pExpr -> iTable == 0 || pExpr -> iTable == 1 ) ; assert ( iCol >= - 1 && iCol < pTab -> nCol ) ; assert ( pTab -> iPKey < 0 || iCol != pTab -> iPKey ) ; assert ( p1 >= 0 && p1 < ( pTab -> nCol * 2 + 2 ) ) ; sqlite3VdbeAddOp2 ( v , OP_Param , p1 , target ) ; VdbeComment ( ( v , ""r[%d]=%s.%s"" , target , ( pExpr -> iTable ? ""new"" : ""old"" ) , ( pExpr -> iColumn < 0 ? ""rowid"" : pExpr -> y . pTab -> aCol [ iCol ] . zName ) ) ) ; # ifndef SQLITE_OMIT_FLOATING_POINT if ( iCol >= 0 && pTab -> aCol [ iCol ] . affinity == SQLITE_AFF_REAL ) { sqlite3VdbeAddOp1 ( v , OP_RealAffinity , target ) ; } # endif break ; } case TK_VECTOR : { sqlite3ErrorMsg ( pParse , ""rowvaluemisused"" ) ; break ; } case TK_IF_NULL_ROW : { int addrINR ; u8 okConstFactor = pParse -> okConstFactor ; addrINR = sqlite3VdbeAddOp1 ( v , OP_IfNullRow , pExpr -> iTable ) ; pParse -> okConstFactor = 0 ; inReg = sqlite3ExprCodeTarget ( pParse , pExpr -> pLeft , target ) ; pParse -> okConstFactor = okConstFactor ; sqlite3VdbeJumpHere ( v , addrINR ) ; sqlite3VdbeChangeP3 ( v , addrINR , inReg ) ; break ; } default : assert ( op == TK_CASE ) ; { int endLabel ; int nextCase ; int nExpr ; int i ; ExprList * pEList ; struct ExprList_item * aListelem ; Expr opCompare ; Expr * pX ; Expr * pTest = 0 ; Expr * pDel = 0 ; sqlite3 * db = pParse -> db ; assert ( ! ExprHasProperty ( pExpr , EP_xIsSelect ) && pExpr -> x . pList ) ; assert ( pExpr -> x . pList -> nExpr > 0 ) ; pEList = pExpr -> x . pList ; aListelem = pEList -> a ; nExpr = pEList -> nExpr ; endLabel = sqlite3VdbeMakeLabel ( pParse ) ; if ( ( pX = pExpr -> pLeft ) != 0 ) { pDel = sqlite3ExprDup ( db , pX , 0 ) ; if ( db -> mallocFailed ) { sqlite3ExprDelete ( db , pDel ) ; break ; } testcase ( pX -> op == TK_COLUMN ) ; exprToRegister ( pDel , exprCodeVector ( pParse , pDel , & regFree1 ) ) ; testcase ( regFree1 == 0 ) ; memset ( & opCompare , 0 , sizeof ( opCompare ) ) ; opCompare . op = TK_EQ ; opCompare . pLeft = pDel ; pTest = & opCompare ; regFree1 = 0 ; } for ( i = 0 ; i < nExpr - 1 ; i = i + 2 ) { if ( pX ) { assert ( pTest != 0 ) ; opCompare . pRight = aListelem [ i ] . pExpr ; } else { pTest = aListelem [ i ] . pExpr ; } nextCase = sqlite3VdbeMakeLabel ( pParse ) ; testcase ( pTest -> op == TK_COLUMN ) ; sqlite3ExprIfFalse ( pParse , pTest , nextCase , SQLITE_JUMPIFNULL ) ; testcase ( aListelem [ i + 1 ] . pExpr -> op == TK_COLUMN ) ; sqlite3ExprCode ( pParse , aListelem [ i + 1 ] . pExpr , target ) ; sqlite3VdbeGoto ( v , endLabel ) ; sqlite3VdbeResolveLabel ( v , nextCase ) ; } if ( ( nExpr & 1 ) != 0 ) { sqlite3ExprCode ( pParse , pEList -> a [ nExpr - 1 ] . pExpr , target ) ; } else { sqlite3VdbeAddOp2 ( v , OP_Null , 0 , target ) ; } sqlite3ExprDelete ( db , pDel ) ; sqlite3VdbeResolveLabel ( v , endLabel ) ; break ; } # ifndef SQLITE_OMIT_TRIGGER case TK_RAISE : { assert ( pExpr -> affExpr == OE_Rollback || pExpr -> affExpr == OE_Abort || pExpr -> affExpr == OE_Fail || pExpr -> affExpr == OE_Ignore ) ; if ( ! pParse -> pTriggerTab ) { sqlite3ErrorMsg ( pParse , ""RAISE()mayonlybeusedwithinatrigger-program"" ) ; return 0 ; } if ( pExpr -> affExpr == OE_Abort ) { sqlite3MayAbort ( pParse ) ; } assert ( ! ExprHasProperty ( pExpr , EP_IntValue ) ) ; if ( pExpr -> affExpr == OE_Ignore ) { sqlite3VdbeAddOp4 ( v , OP_Halt , SQLITE_OK , OE_Ignore , 0 , pExpr -> u . zToken , 0 ) ; VdbeCoverage ( v ) ; } else { sqlite3HaltConstraint ( pParse , SQLITE_CONSTRAINT_TRIGGER , pExpr -> affExpr , pExpr -> u . zToken , 0 , 0 ) ; } break ; } # endif } sqlite3ReleaseTempReg ( pParse , regFree1 ) ; sqlite3ReleaseTempReg ( pParse , regFree2 ) ; return inReg ; } "," ; int aff ; if ( pExpr -> y . pTab ) { aff iColumn ) ; } else { aff = pExpr -> affExpr ; } ",sqlite@sqlite/57f7ece78410a8aae86aa4625fb7556897db384c,CVE-2019-19242,https://github.com/sqlite/sqlite/commit/57f7ece78410a8aae86aa4625fb7556897db384c,2019-11-27T17:15Z 1461,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 1462,CWE-125,"CWE-125 static identifier new_identifier ( const char * n , struct compiling * c ) { PyObject * id = PyUnicode_DecodeUTF8 ( n , strlen ( n ) , NULL ) ; if ( ! id ) return NULL ; assert ( PyUnicode_IS_READY ( id ) ) ; if ( ! PyUnicode_IS_ASCII ( id ) ) { PyObject * id2 ; if ( ! c -> c_normalize && ! init_normalization ( c ) ) { Py_DECREF ( id ) ; return NULL ; } PyTuple_SET_ITEM ( c -> c_normalize_args , 1 , id ) ; id2 = PyObject_Call ( c -> c_normalize , c -> c_normalize_args , NULL ) ; Py_DECREF ( id ) ; if ( ! id2 ) return NULL ; id = id2 ; } PyUnicode_InternInPlace ( & id ) ; if ( PyArena_AddPyObject ( c -> c_arena , id ) < 0 ) { Py_DECREF ( id ) ; return NULL ; } return id ; } "," * id2 ; PyObject * form ; PyObject * args [ 2 ] ; _Py_IDENTIFIER ( NFKC ) ; NULL ; } form = _PyUnicode_FromId ( & PyId_NFKC ) ; if ( form == NULL ) { Py_DECREF ( id ) ; return NULL ; } args [ 0 ] = form ; args [ 1 ] = id ; id2 = _PyObject_FastCall ( c -> -> c_normalize , args , 2 ) ; Py_DECREF ( id ) ; if ( ! id2 ) return NULL ; if ( ! PyUnicode_Check ( id2 ) ) { PyErr_Format ( PyExc_TypeError , ""unicodedata.normalize()mustreturnastring,not"" ""%.200s"" , Py_TYPE ( id2 ) -> tp_name ) ; Py_DECREF ( id2 ) ; return NULL ; } id = id2 ",python@typed_ast/156afcb26c198e162504a57caddfe0acd9ed7dce,CVE-2019-19275,https://github.com/python/typed_ast/commit/156afcb26c198e162504a57caddfe0acd9ed7dce,2019-11-26T15:15Z 1463,CWE-119,"CWE-119 void Huff_Compress ( msg_t * mbuf , int offset ) { int i , ch , size ; byte seq [ 65536 ] ; byte * buffer ; huff_t huff ; size = mbuf -> cursize - offset ; buffer = mbuf -> data + + offset ; if ( size <= 0 ) { return ; } Com_Memset ( & huff , 0 , sizeof ( huff_t ) ) ; huff . tree = huff . lhead = huff . loc [ NYT ] = & ( huff . nodeList [ huff . blocNode ++ ] ) ; huff . tree -> symbol = NYT ; huff . tree -> weight = 0 ; huff . lhead -> next = huff . lhead -> prev = NULL ; huff . tree -> parent = huff . tree -> left = huff . tree -> right = NULL ; seq [ 0 ] = ( size >> 8 ) ; seq [ 1 ] = size & 0xff ; bloc = 16 ; for ( i = 0 ; i < size ; i ++ ) { ch = buffer [ i ] ; Huff_transmit ( & huff , ch , seq ) ; Huff_addRef ( & huff , ( byte ) ch ) ; } bloc += 8 ; mbuf -> cursize = ( bloc >> 3 ) + offset ; Com_Memcpy ( mbuf -> data + offset , seq , ( bloc >> 3 ) ) ; } "," ch , seq , size << 3 ",ioquake@ioq3/d2b1d124d4055c2fcbe5126863487c52fd58cca1,CVE-2017-11721,https://github.com/ioquake/ioq3/commit/d2b1d124d4055c2fcbe5126863487c52fd58cca1,2017-08-03T08:29Z 1464,CWE-415,"CWE-415 static netsnmp_pdu * _clone_pdu_header ( netsnmp_pdu * pdu ) { netsnmp_pdu * newpdu ; struct snmp_secmod_def * sptr ; int ret ; if ( ! pdu ) return NULL ; newpdu = ( netsnmp_pdu * ) malloc ( sizeof ( netsnmp_pdu ) ) ; if ( ! newpdu ) return NULL ; memmove ( newpdu , pdu , sizeof ( netsnmp_pdu ) ) ; newpdu -> variables = NULL ; newpdu -> enterprise = NULL ; newpdu -> community = NULL ; newpdu -> securityEngineID = NULL ; newpdu -> securityName = NULL ; newpdu -> contextEngineID = NULL ; newpdu -> contextName = NULL ; newpdu -> transport_data = NULL ; if ( snmp_clone_mem ( ( void * * ) & newpdu -> enterprise , pdu -> enterprise , sizeof ( oid ) * pdu -> enterprise_length ) || snmp_clone_mem ( ( void * * ) & newpdu -> community , pdu -> community , pdu -> community_len ) || snmp_clone_mem ( ( void * * ) & newpdu -> contextEngineID , pdu -> contextEngineID , pdu -> contextEngineIDLen ) || snmp_clone_mem ( ( void * * ) & newpdu -> securityEngineID , pdu -> securityEngineID , pdu -> securityEngineIDLen ) || snmp_clone_mem ( ( void * * ) & newpdu -> contextName , pdu -> contextName , pdu -> contextNameLen ) || snmp_clone_mem ( ( void * * ) & newpdu -> securityName , pdu -> securityName , pdu -> securityNameLen ) || snmp_clone_mem ( ( void * * ) & newpdu -> transport_data , pdu -> transport_data , pdu -> transport_data_length ) ) { snmp_free_pdu ( newpdu ) ; return NULL ; } if ( pdu -> securityStateRef && pdu -> command == SNMP_MSG_TRAP2 ) { netsnmp_assert ( pdu -> securityModel == SNMP_DEFAULT_SECMODEL ) ; ret = usm_clone_usmStateReference ( ( struct usmStateReference * ) pdu -> securityStateRef , ( struct usmStateReference * * ) & newpdu -> securityStateRef ) ; if ( ret ) { snmp_free_pdu ( newpdu ) ; return NULL ; } } if ( ( sptr = find_sec_mod ( newpdu -> securityModel ) ) != NULL && sptr -> pdu_clone != NULL ) { ( * sptr -> pdu_clone ) ( pdu , newpdu ) ; } return newpdu ; } "," NULL ; } sptr = find_sec_mod ( newpdu -> securityModel ) ; if ( sptr && sptr -> pdu_clone ) { ret = sptr -> pdu_clone ( pdu , newpdu ) ; if NULL ; } } return newpdu ",net-snmp@net-snmp/5f881d3bf24599b90d67a45cae7a3eb099cd71c9,CVE-2019-20892,https://github.com/net-snmp/net-snmp/commit/5f881d3bf24599b90d67a45cae7a3eb099cd71c9,2020-06-25T10:15Z 1465,CWE-254,"CWE-254 UWORD16 impeg2d_get_mb_addr_incr ( stream_t * ps_stream ) { UWORD16 u2_mb_addr_incr = 0 ; while ( impeg2d_bit_stream_nxt ( ps_stream , MB_ESCAPE_CODE_LEN ) == MB_ESCAPE_CODE ) { impeg2d_bit_stream_flush ( ps_stream , MB_ESCAPE_CODE_LEN ) ; u2_mb_addr_incr += 33 ; } u2_mb_addr_incr += impeg2d_dec_vld_symbol ( ps_stream , gai2_impeg2d_mb_addr_incr , MB_ADDR_INCR_LEN ) + MB_ADDR_INCR_OFFSET ; return ( u2_mb_addr_incr ) ; } "," ) == MB_ESCAPE_CODE && 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 1466,CWE-119,"CWE-119 static int tt_s2_4600_frontend_attach ( struct dvb_usb_adapter * adap ) { struct dvb_usb_device * d = adap -> dev ; struct dw2102_state * state = d -> priv ; u8 obuf [ 3 ] = { 0xe , 0x80 , 0 } ; u8 ibuf [ ] = { 0 } ; struct i2c_adapter * i2c_adapter ; struct i2c_client * client ; struct i2c_board_info board_info ; struct m88ds3103_platform_data m88ds3103_pdata = { } ; struct ts2020_config ts2020_config = { } ; if ( dvb_usb_generic_rw ( d , obuf , 3 , ibuf , 1 , 0 ) < 0 ) err ( ""command0x0etransferfailed."" ) ; obuf [ 0 ] = 0xe ; obuf [ 1 ] = 0x02 ; obuf [ 2 ] = 1 ; if ( dvb_usb_generic_rw ( d , 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 , obuf , 3 , ibuf , 1 , 0 ) < 0 ) err ( ""command0x0etransferfailed."" ) ; obuf [ 0 ] = 0xe ; obuf [ 1 ] = 0x83 ; obuf [ 2 ] = 1 ; if ( dvb_usb_generic_rw ( d , obuf , 3 , ibuf , 1 , 0 ) < 0 ) err ( ""command0x0etransferfailed."" ) ; obuf [ 0 ] = 0x51 ; if ( dvb_usb_generic_rw ( d , obuf , 1 , ibuf , 1 , 0 ) < 0 ) err ( ""command0x51transferfailed."" ) ; m88ds3103_pdata . clk = 27000000 ; m88ds3103_pdata . i2c_wr_max = 33 ; m88ds3103_pdata . ts_mode = M88DS3103_TS_CI ; m88ds3103_pdata . ts_clk = 16000 ; m88ds3103_pdata . ts_clk_pol = 0 ; m88ds3103_pdata . spec_inv = 0 ; m88ds3103_pdata . agc = 0x99 ; m88ds3103_pdata . agc_inv = 0 ; m88ds3103_pdata . clk_out = M88DS3103_CLOCK_OUT_ENABLED ; m88ds3103_pdata . envelope_mode = 0 ; m88ds3103_pdata . lnb_hv_pol = 1 ; m88ds3103_pdata . lnb_en_pol = 0 ; memset ( & board_info , 0 , sizeof ( board_info ) ) ; strlcpy ( board_info . type , ""m88ds3103"" , I2C_NAME_SIZE ) ; board_info . addr = 0x68 ; board_info . platform_data = & m88ds3103_pdata ; request_module ( ""m88ds3103"" ) ; client = i2c_new_device ( & d -> i2c_adap , & board_info ) ; if ( client == NULL || client -> dev . driver == NULL ) return - ENODEV ; if ( ! try_module_get ( client -> dev . driver -> owner ) ) { i2c_unregister_device ( client ) ; return - ENODEV ; } adap -> fe_adap [ 0 ] . fe = m88ds3103_pdata . get_dvb_frontend ( client ) ; i2c_adapter = m88ds3103_pdata . get_i2c_adapter ( client ) ; state -> i2c_client_demod = client ; ts2020_config . fe = adap -> fe_adap [ 0 ] . fe ; memset ( & board_info , 0 , sizeof ( board_info ) ) ; strlcpy ( board_info . type , ""ts2022"" , I2C_NAME_SIZE ) ; board_info . addr = 0x60 ; board_info . platform_data = & ts2020_config ; request_module ( ""ts2020"" ) ; client = i2c_new_device ( i2c_adapter , & board_info ) ; if ( client == NULL || client -> dev . driver == NULL ) { dvb_frontend_detach ( adap -> fe_adap [ 0 ] . fe ) ; return - ENODEV ; } if ( ! try_module_get ( client -> dev . driver -> owner ) ) { i2c_unregister_device ( client ) ; dvb_frontend_detach ( adap -> fe_adap [ 0 ] . fe ) ; return - ENODEV ; } adap -> fe_adap [ 0 ] . fe -> ops . read_signal_strength = adap -> fe_adap [ 0 ] . fe -> ops . tuner_ops . get_rf_strength ; state -> i2c_client_tuner = client ; state -> fe_read_status = adap -> fe_adap [ 0 ] . fe -> ops . read_status ; adap -> fe_adap [ 0 ] . fe -> ops . read_status = tt_s2_4600_read_status ; state -> last_lock = 0 ; return 0 ; } "," d -> priv ; struct i2c_adapter { } ; mutex_lock ( & d -> data_mutex ) ; state -> data [ 0 ] = 0xe ; state -> data [ 1 ] = 0x80 ; state -> data [ 2 ] = 0x0 ; ( d , state -> data , 3 , , 3 , state -> data , 1 , ""command0x0etransferfailed."" ) ; state -> data [ 0 ] = 0xe ; state -> data [ 1 ] = 0x02 ; state -> data [ 2 ] ( d , state -> data , 3 , , 3 , state -> data , 1 , 300 ) ; state -> data [ 0 ] = 0xe ; state -> data [ 1 ] = 0x83 ; state -> data [ 2 ] ( d , state -> data , 3 , , 3 , state -> data , 1 , ""command0x0etransferfailed."" ) ; state -> data [ 0 ] = 0xe ; state -> data [ 1 ] = 0x83 ; state -> data [ 2 ] ( d , state -> data , 3 , , 3 , state -> data , 1 , ""command0x0etransferfailed."" ) ; state -> data [ 0 ] ( d , state -> data , 1 , state -> data , 1 , err ( ""command0x51transferfailed."" ) ; mutex_unlock ( & d -> data_mutex ",torvalds@linux/606142af57dad981b78707234cfbd15f9f7b7125,CVE-2017-8062,https://github.com/torvalds/linux/commit/606142af57dad981b78707234cfbd15f9f7b7125,2017-04-23T05:59Z 1467,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 1468,CWE-400,"CWE-400 static void handle_associated_event ( struct cpu_hw_events * cpuc , int idx , struct perf_sample_data * data , struct pt_regs * regs ) { struct perf_event * event = cpuc -> events [ idx ] ; struct hw_perf_event * hwc = & event -> hw ; mipspmu_event_update ( event , hwc , idx ) ; data -> period = event -> hw . last_period ; if ( ! mipspmu_event_set_period ( event , hwc , idx ) ) return ; if ( perf_event_overflow ( event , 0 , data , regs ) ) mipspmu -> disable_event ( idx ) ; } "," ( event , data , regs ",torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,CVE-2011-2918,https://github.com/torvalds/linux/commit/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,2012-05-24T23:55Z 1469,CWE-125,"CWE-125 static mrb_value fiber_switch ( mrb_state * mrb , mrb_value self , mrb_int len , const mrb_value * a , mrb_bool resume , mrb_bool vmexec ) { struct mrb_context * c = fiber_check ( mrb , self ) ; struct mrb_context * old_c = mrb -> c ; mrb_value value ; fiber_check_cfunc ( mrb , c ) ; if ( resume && c -> status == MRB_FIBER_TRANSFERRED ) { mrb_raise ( mrb , E_FIBER_ERROR , ""resumingtransferredfiber"" ) ; } if ( c -> status == MRB_FIBER_RUNNING || c -> status == MRB_FIBER_RESUMED ) { mrb_raise ( mrb , E_FIBER_ERROR , ""doubleresume(fib)"" ) ; } if ( c -> status == MRB_FIBER_TERMINATED ) { mrb_raise ( mrb , E_FIBER_ERROR , ""resumingdeadfiber"" ) ; } mrb -> c -> status = resume ? MRB_FIBER_RESUMED : MRB_FIBER_TRANSFERRED ; c -> prev = resume ? mrb -> c : ( c -> prev ? c -> prev : mrb -> root_c ) ; if ( c -> status == MRB_FIBER_CREATED ) { mrb_value * b , * e ; if ( len >= c -> stend - c -> stack ) { mrb_raise ( mrb , E_FIBER_ERROR , ""toomanyargumentstofiber"" ) ; } b = c -> stack + 1 ; e = b + len ; while ( b < e ) { * b ++ = * a ++ ; } c -> cibase -> argc = ( int ) len ; value = c -> stack [ 0 ] = MRB_PROC_ENV ( c -> ci -> proc ) -> stack [ 0 ] ; } else { value = fiber_result ( mrb , a , len ) ; } fiber_switch_context ( mrb , c ) ; if ( vmexec ) { c -> vmexec = TRUE ; value = mrb_vm_exec ( mrb , c -> ci [ - 1 ] . proc , c -> ci -> pc ) ; mrb -> c = old_c ; } else { MARK_CONTEXT_MODIFY ( c ) ; } return value ; } "," -> c ; enum mrb_fiber_state status ; , c ) ; status = c -> status ( resume && status == MRB_FIBER_TRANSFERRED } if ( status == MRB_FIBER_RUNNING == MRB_FIBER_RUNNING || status == MRB_FIBER_RESUMED } if ( status == MRB_FIBER_TERMINATED ) ; } old_c -> status = root_c ) ; fiber_switch_context ( mrb , c ) ; if ( status == MRB_FIBER_CREATED * e ; mrb_stack_extend ( mrb , len + 2 ) ; b = c ) ; } if ( vmexec ",mruby@mruby/778500563a9f7ceba996937dc886bd8cde29b42b,CVE-2018-12248,https://github.com/mruby/mruby/commit/778500563a9f7ceba996937dc886bd8cde29b42b,2018-06-12T14:29Z 1470,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 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 ) ; if ( s -> s3 -> tmp . message_type != SSL3_MT_SERVER_KEY_EXCHANGE ) { # ifndef OPENSSL_NO_PSK if ( s -> s3 -> tmp . new_cipher -> algorithm_mkey & 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_k = s -> s3 -> tmp . new_cipher -> algorithm_mkey ; alg_a = s -> s3 -> tmp . new_cipher -> algorithm_auth ; EVP_MD_CTX_init ( & md_ctx ) ; 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 ) ; } "," ; # endif EVP_MD_CTX_init ( & md_ctx ) ; ) n ) ; alg_k = s -> s3 -> tmp . new_cipher -> algorithm_mkey 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 ; } 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 = . new_cipher -> algorithm_auth ; al = ",openssl@openssl/b15f8769644b00ef7283521593360b7b2135cb63,CVE-2014-3572,https://github.com/openssl/openssl/commit/b15f8769644b00ef7283521593360b7b2135cb63,2015-01-09T02:59Z 1471,CWE-119,"CWE-119 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 ; if ( fputc ( c , file ) != c ) break ; } } ( 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 [ if ( length > GetBlobSize ( image ) ) ThrowPICTException ( CorruptImageError , ""InsufficientImageDataInFile"" ) ; if ( length ; if ( length > GetBlobSize ( image ) ) ThrowPICTException ( CorruptImageError , ""InsufficientImageDataInFile"" ) ; if ( ReadBlobMSBShort ( image ) ; if ( length > GetBlobSize ( image ) ) ThrowPICTException ( CorruptImageError , ""InsufficientImageDataInFile"" ReadBlobMSBShort ( image ) ; if ( length > GetBlobSize ( image ) ) ThrowPICTException ( CorruptImageError , ""InsufficientImageDataInFile"" ReadBlobMSBShort ( image ) ; if ( length > GetBlobSize ( image ) ) ThrowPICTException ( CorruptImageError , ""InsufficientImageDataInFile"" if ( length > GetBlobSize ( image ) ) ThrowPICTException ( CorruptImageError , ""InsufficientImageDataInFile"" ) ; if ( length ( length > GetBlobSize ( image ) ) ThrowPICTException ( CorruptImageError , ""InsufficientImageDataInFile"" ) ; if ( length > image ) ; if ( length > GetBlobSize ( image ) ) ThrowPICTException ( CorruptImageError , ""InsufficientImageDataInFile"" ) ; 0xff ) ; if ( length > GetBlobSize ( image ) ) ThrowPICTException ( CorruptImageError , ""InsufficientImageDataInFile"" ) ; ",ImageMagick@ImageMagick/afa878a689870c28b6994ecf3bb8dbfb2b76d135,CVE-2018-16644,https://github.com/ImageMagick/ImageMagick/commit/afa878a689870c28b6994ecf3bb8dbfb2b76d135,2018-09-06T22:29Z 1472,CWE-119,"CWE-119 static void write_mv_update ( const vp9_tree_index * tree , vp9_prob probs [ ] , const unsigned int counts [ ] , int n , vp9_writer * w ) { int i ; unsigned int branch_ct [ 32 ] [ 2 ] ; assert ( n <= 32 ) ; vp9_tree_probs_from_distribution ( tree , branch_ct , counts ) ; for ( i = 0 ; i < n - 1 ; ++ i ) update_mv ( w , branch_ct [ i ] , & probs [ i ] , MV_UPDATE_PROB ) ; } "," write_mv_update ( const vpx_tree_index * tree , * tree , vpx_prob probs [ ] int n , vpx_writer * w ) ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1473,CWE-362,"CWE-362 static int sctp_setsockopt_auto_asconf ( struct sock * sk , char __user * optval , unsigned int optlen ) { int val ; struct sctp_sock * sp = sctp_sk ( sk ) ; if ( optlen < sizeof ( int ) ) return - EINVAL ; if ( get_user ( val , ( int __user * ) optval ) ) return - EFAULT ; if ( ! sctp_is_ep_boundall ( sk ) && val ) return - EINVAL ; if ( ( val && sp -> do_auto_asconf ) || ( ! val && ! sp -> do_auto_asconf ) ) return 0 ; if ( val == 0 && sp -> do_auto_asconf ) { list_del ( & sp -> auto_asconf_list ) ; sp -> do_auto_asconf = 0 ; } else if ( val && ! sp -> do_auto_asconf ) { list_add_tail ( & sp -> auto_asconf_list , & sock_net ( sk ) -> sctp . auto_asconf_splist ) ; sp -> do_auto_asconf = 1 ; } return 0 ; } "," return 0 ; spin_lock_bh ( & sock_net ( sk ) -> sctp . addr_wq_lock ) ; 1 ; } spin_unlock_bh ( & sock_net ( sk ) -> sctp . addr_wq_lock ) ; ",torvalds@linux/2d45a02d0166caf2627fe91897c6ffc3b19514c4,CVE-2015-3212,https://github.com/torvalds/linux/commit/2d45a02d0166caf2627fe91897c6ffc3b19514c4,2015-08-31T10:59Z 1474,CWE-120,"CWE-120 void test_base64_decode ( void ) { char buffer [ 16 ] ; int len = mutt_b64_decode ( buffer , encoded ) ; if ( ! TEST_CHECK ( len == sizeof ( clear ) - 1 ) ) { TEST_MSG ( ""Expected:%zu"" , sizeof ( clear ) - 1 ) ; TEST_MSG ( ""Actual:%zu"" , len ) ; } buffer [ len ] = '\\0' ; if ( ! TEST_CHECK ( strcmp ( buffer , clear ) == 0 ) ) { TEST_MSG ( ""Expected:%s"" , clear ) ; TEST_MSG ( ""Actual:%s"" , buffer ) ; } } "," buffer , encoded , sizeof ( buffer ) ",neomutt@neomutt/6f163e07ae68654d7ac5268cbb7565f6df79ad85,CVE-2018-14359,https://github.com/neomutt/neomutt/commit/6f163e07ae68654d7ac5268cbb7565f6df79ad85,2018-07-17T17:29Z 1475,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 1476,CWE-119,"CWE-119 void vp9_iht4x4_16_add_c ( const int16_t * input , uint8_t * dest , int stride , int tx_type ) { const transform_2d IHT_4 [ ] = { { idct4 , idct4 } , { iadst4 , idct4 } , { idct4 , iadst4 } , { iadst4 , iadst4 } } ; int i , j ; int16_t out [ 4 * 4 ] ; int16_t * outptr = out ; int16_t temp_in [ 4 ] , temp_out [ 4 ] ; for ( i = 0 ; i < 4 ; ++ i ) { IHT_4 [ tx_type ] . rows ( input , outptr ) ; input += 4 ; outptr += 4 ; } for ( i = 0 ; i < 4 ; ++ i ) { for ( j = 0 ; j < 4 ; ++ j ) temp_in [ j ] = out [ j * 4 + i ] ; IHT_4 [ tx_type ] . cols ( temp_in , temp_out ) ; for ( j = 0 ; j < 4 ; ++ j ) dest [ j * stride + i ] = clip_pixel ( ROUND_POWER_OF_TWO ( temp_out [ j ] , 4 ) + dest [ j * stride + i ] ) ; } } "," vp9_iht4x4_16_add_c ( const tran_low_t * input , = { { idct4_c , idct4_c } , { iadst4_c , idct4_c } , { idct4_c , iadst4_c } , { iadst4_c , iadst4_c } } ; , j ; tran_low_t out [ 4 4 ] ; tran_low_t * outptr = = out ; tran_low_t temp_in [ 4 ++ j ) { i ] = clip_pixel_add ( dest [ j + i ] , ROUND_POWER_OF_TWO ( temp_out [ j ] , 4 ) ) ; } } } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1477,CWE-125,"CWE-125 stmt_ty Assign ( asdl_seq * targets , expr_ty value , int lineno , int col_offset , int end_lineno , int end_col_offset , PyArena * arena ) { stmt_ty p ; if ( ! value ) { PyErr_SetString ( PyExc_ValueError , ""fieldvalueisrequiredforAssign"" ) ; return NULL ; } p = ( stmt_ty ) PyArena_Malloc ( arena , sizeof ( * p ) ) ; if ( ! p ) return NULL ; p -> kind = Assign_kind ; p -> v . Assign . targets = targets ; p -> v . Assign . value = value ; p -> lineno = lineno ; p -> col_offset = col_offset ; p -> end_lineno = end_lineno ; p -> end_col_offset = end_col_offset ; return p ; } "," expr_ty value , string type_comment , ; p -> v . Assign . type_comment = type_comment ; p -> ",python@typed_ast/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,CVE-2019-19275,https://github.com/python/typed_ast/commit/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,2019-11-26T15:15Z 1478,CWE-119,"CWE-119 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 1479,CWE-22,"CWE-22 char * compose_path ( ctrl_t * ctrl , char * path ) { struct stat st ; static char rpath [ PATH_MAX ] ; char * name , * ptr ; char dir [ PATH_MAX ] = { 0 } ; strlcpy ( dir , ctrl -> cwd , sizeof ( dir ) ) ; DBG ( ""Composepathfromcwd:%s,arg:%s"" , ctrl -> cwd , path ? : """" ) ; if ( ! path || ! strlen ( path ) ) goto check ; if ( path ) { if ( path [ 0 ] != '/' ) { if ( dir [ strlen ( dir ) - 1 ] != '/' ) strlcat ( dir , ""/"" , sizeof ( dir ) ) ; } strlcat ( dir , path , sizeof ( dir ) ) ; } check : while ( ( ptr = strstr ( dir , ""//"" ) ) ) memmove ( ptr , & ptr [ 1 ] , strlen ( & ptr [ 1 ] ) + 1 ) ; if ( ! chrooted ) { size_t len = strlen ( home ) ; DBG ( ""ServerpathfromCWD:%s"" , dir ) ; if ( len > 0 && home [ len - 1 ] == '/' ) len -- ; memmove ( dir + len , dir , strlen ( dir ) + 1 ) ; memcpy ( dir , home , len ) ; DBG ( ""Resultingnon-chrootpath:%s"" , dir ) ; } if ( ! stat ( dir , & st ) && S_ISDIR ( st . st_mode ) ) { if ( ! realpath ( dir , rpath ) ) return NULL ; } else { name = basename ( path ) ; ptr = dirname ( dir ) ; memset ( rpath , 0 , sizeof ( rpath ) ) ; if ( ! realpath ( ptr , rpath ) ) { INFO ( ""Failedrealpath(%s):%m"" , ptr ) ; return NULL ; } if ( rpath [ 1 ] != 0 ) strlcat ( rpath , ""/"" , sizeof ( rpath ) ) ; strlcat ( rpath , name , sizeof ( rpath ) ) ; } if ( ! chrooted && strncmp ( dir , home , strlen ( home ) ) ) { DBG ( ""Failednon-chrootdir:%svshome:%s"" , dir , home ) ; return NULL ; } return rpath ; } "," && strncmp ( rpath , home , ",troglobit@uftpd/455b47d3756aed162d2d0ef7f40b549f3b5b30fe,CVE-2020-5221,https://github.com/troglobit/uftpd/commit/455b47d3756aed162d2d0ef7f40b549f3b5b30fe,2020-01-22T19:15Z 1480,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/251e22abde21833b3d29577e4d8c7aaccd650eee,CVE-2017-18174,https://github.com/torvalds/linux/commit/251e22abde21833b3d29577e4d8c7aaccd650eee,2018-02-11T18:29Z 1481,CWE-400,"CWE-400 static void do_perf_sw_event ( enum perf_type_id type , u32 event_id , u64 nr , int nmi , struct perf_sample_data * data , struct pt_regs * regs ) { struct swevent_htable * swhash = & __get_cpu_var ( swevent_htable ) ; struct perf_event * event ; struct hlist_node * node ; struct hlist_head * head ; rcu_read_lock ( ) ; head = find_swevent_head_rcu ( swhash , type , event_id ) ; if ( ! head ) goto end ; hlist_for_each_entry_rcu ( event , node , head , hlist_entry ) { if ( perf_swevent_match ( event , type , event_id , data , regs ) ) perf_swevent_event ( event , nr , nmi , data , regs ) ; } end : rcu_read_unlock ( ) ; } "," , u64 nr , struct perf_sample_data , nr , data , regs ",torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,CVE-2011-2918,https://github.com/torvalds/linux/commit/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,2012-05-24T23:55Z 1482,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 . src . virt . addr , walk . dst . virt . addr , nbytes ) ; return blkcipher_walk_done ( desc , & walk , 0 ) ; } while ( walk . nbytes >= 64 ) { salsa20_encrypt_bytes ( ctx , walk . src . virt . addr , walk . dst . virt . addr , walk . nbytes - ( walk . nbytes % 64 ) ) ; err = blkcipher_walk_done ( desc , & walk , walk . nbytes % 64 ) ; } if ( walk . nbytes ) { salsa20_encrypt_bytes ( ctx , walk . src . virt . addr , walk . dst . 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 1483,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 1484,CWE-125,"CWE-125 void vqp_print ( netdissect_options * ndo , register const u_char * pptr , register u_int len ) { const struct vqp_common_header_t * vqp_common_header ; const struct vqp_obj_tlv_t * vqp_obj_tlv ; const u_char * tptr ; uint16_t vqp_obj_len ; uint32_t vqp_obj_type ; int tlen ; uint8_t nitems ; tptr = pptr ; tlen = len ; vqp_common_header = ( const struct vqp_common_header_t * ) pptr ; ND_TCHECK ( * vqp_common_header ) ; if ( VQP_EXTRACT_VERSION ( vqp_common_header -> version ) != VQP_VERSION ) { ND_PRINT ( ( ndo , ""VQPversion%upacketnotsupported"" , VQP_EXTRACT_VERSION ( vqp_common_header -> version ) ) ) ; return ; } if ( ndo -> ndo_vflag < 1 ) { ND_PRINT ( ( ndo , ""VQPv%u%sMessage,error-code%s(%u),length%u"" , VQP_EXTRACT_VERSION ( vqp_common_header -> version ) , tok2str ( vqp_msg_type_values , ""unknown(%u)"" , vqp_common_header -> msg_type ) , tok2str ( vqp_error_code_values , ""unknown(%u)"" , vqp_common_header -> error_code ) , vqp_common_header -> error_code , len ) ) ; return ; } nitems = vqp_common_header -> nitems ; ND_PRINT ( ( ndo , ""\\n\\tVQPv%u,%sMessage,error-code%s(%u),seq0x%08x,items%u,length%u"" , VQP_EXTRACT_VERSION ( vqp_common_header -> version ) , tok2str ( vqp_msg_type_values , ""unknown(%u)"" , vqp_common_header -> msg_type ) , tok2str ( vqp_error_code_values , ""unknown(%u)"" , vqp_common_header -> error_code ) , vqp_common_header -> error_code , EXTRACT_32BITS ( & vqp_common_header -> sequence ) , nitems , len ) ) ; tptr += sizeof ( const struct vqp_common_header_t ) ; tlen -= sizeof ( const struct vqp_common_header_t ) ; while ( nitems > 0 && tlen > 0 ) { vqp_obj_tlv = ( const struct vqp_obj_tlv_t * ) tptr ; vqp_obj_type = EXTRACT_32BITS ( vqp_obj_tlv -> obj_type ) ; vqp_obj_len = EXTRACT_16BITS ( vqp_obj_tlv -> obj_length ) ; tptr += sizeof ( struct vqp_obj_tlv_t ) ; tlen -= sizeof ( struct vqp_obj_tlv_t ) ; ND_PRINT ( ( ndo , ""\\n\\t%sObject(0x%08x),length%u,value:"" , tok2str ( vqp_obj_values , ""Unknown"" , vqp_obj_type ) , vqp_obj_type , vqp_obj_len ) ) ; if ( vqp_obj_type == 0 || vqp_obj_len == 0 ) { return ; } ND_TCHECK2 ( * tptr , vqp_obj_len ) ; switch ( vqp_obj_type ) { case VQP_OBJ_IP_ADDRESS : ND_PRINT ( ( ndo , ""%s(0x%08x)"" , ipaddr_string ( ndo , tptr ) , EXTRACT_32BITS ( tptr ) ) ) ; break ; case VQP_OBJ_PORT_NAME : case VQP_OBJ_VLAN_NAME : case VQP_OBJ_VTP_DOMAIN : case VQP_OBJ_ETHERNET_PKT : safeputs ( ndo , tptr , vqp_obj_len ) ; break ; case VQP_OBJ_MAC_ADDRESS : case VQP_OBJ_MAC_NULL : ND_PRINT ( ( ndo , ""%s"" , etheraddr_string ( ndo , tptr ) ) ) ; break ; default : if ( ndo -> ndo_vflag <= 1 ) print_unknown_data ( ndo , tptr , ""\\n\\t"" , vqp_obj_len ) ; break ; } tptr += vqp_obj_len ; tlen -= vqp_obj_len ; nitems -- ; } return ; trunc : ND_PRINT ( ( ndo , ""\\n\\t[|VQP]"" ) ) ; } "," uint32_t vqp_obj_type ; u_int tlen ; uint8_t * vqp_common_header ) ; if ( sizeof ( struct vqp_common_header_t ) > tlen ) goto trunc ) tptr ; ND_TCHECK ( * vqp_obj_tlv ) ; if ( sizeof ( struct vqp_obj_tlv_t ) > tlen ) goto trunc ; vqp_obj_len ) ; if ( vqp_obj_len > tlen ) goto trunc ; case VQP_OBJ_IP_ADDRESS : if ( vqp_obj_len != 4 ) goto trunc ; case VQP_OBJ_MAC_NULL : if ( vqp_obj_len != ETHER_ADDR_LEN ) goto trunc ; ",the-tcpdump-group@tcpdump/3b36ec4e713dea9266db11975066c425aa669b6c,CVE-2017-13045,https://github.com/the-tcpdump-group/tcpdump/commit/3b36ec4e713dea9266db11975066c425aa669b6c,2017-09-14T06:29Z 1485,CWE-119,"CWE-119 static int filter_frame ( AVFilterLink * inlink , AVFrame * frame ) { AVFilterContext * ctx = inlink -> dst ; FieldOrderContext * s = ctx -> priv ; AVFilterLink * outlink = ctx -> outputs [ 0 ] ; int h , plane , line_step , line_size , line ; uint8_t * data ; if ( ! frame -> interlaced_frame || frame -> top_field_first == s -> dst_tff ) return ff_filter_frame ( outlink , frame ) ; av_dlog ( ctx , ""picturewillmove%soneline\\n"" , s -> dst_tff ? ""up"" : ""down"" ) ; h = frame -> height ; for ( plane = 0 ; plane < 4 && frame -> data [ plane ] ; plane ++ ) { line_step = frame -> linesize [ plane ] ; line_size = s -> line_size [ plane ] ; data = frame -> data [ plane ] ; if ( s -> dst_tff ) { for ( line = 0 ; line < h ; line ++ ) { if ( 1 + line < frame -> height ) { memcpy ( data , data + line_step , line_size ) ; } else { memcpy ( data , data - line_step - line_step , line_size ) ; } data += line_step ; } } else { data += ( h - 1 ) * line_step ; for ( line = h - 1 ; line >= 0 ; line -- ) { if ( line > 0 ) { memcpy ( data , data - line_step , line_size ) ; } else { memcpy ( data , data + line_step + line_step , line_size ) ; } data -= line_step ; } } } frame -> top_field_first = s -> dst_tff ; return ff_filter_frame ( outlink , frame ) ; } "," [ plane ] && frame -> linesize [ plane ] ",FFmpeg@FFmpeg/e43a0a232dbf6d3c161823c2e07c52e76227a1bc,CVE-2013-4263,https://github.com/FFmpeg/FFmpeg/commit/e43a0a232dbf6d3c161823c2e07c52e76227a1bc,2013-11-23T17:55Z 1486,CWE-400,"CWE-400 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 ) ; validate_creds_for_do_exit ( tsk ) ; if ( unlikely ( tsk -> flags & PF_EXITING ) ) { printk ( KERN_ALERT ""Fixingrecursivefaultbutrebootisneeded!\\n"" ) ; tsk -> flags |= PF_EXITPIDONE ; set_current_state ( TASK_UNINTERRUPTIBLE ) ; schedule ( ) ; } exit_irq_thread ( ) ; 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 ) ; group_dead = atomic_dec_and_test ( & tsk -> signal -> live ) ; if ( group_dead ) { hrtimer_cancel ( & tsk -> signal -> real_timer ) ; exit_itimers ( tsk -> signal ) ; if ( tsk -> mm ) setmax_mm_hiwater_rss ( & tsk -> signal -> maxrss , tsk -> mm ) ; } acct_collect ( code , 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 ) ; if ( group_dead && tsk -> signal -> leader ) disassociate_ctty ( 1 ) ; module_put ( task_thread_info ( tsk ) -> exec_domain -> module ) ; proc_exit_connector ( tsk ) ; perf_event_exit_task ( tsk ) ; exit_notify ( tsk , group_dead ) ; # ifdef CONFIG_NUMA mpol_put ( tsk -> mempolicy ) ; tsk -> mempolicy = NULL ; # endif # ifdef CONFIG_FUTEX 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 ) ; validate_creds_for_do_exit ( tsk ) ; preempt_disable ( ) ; exit_rcu ( ) ; tsk -> state = TASK_DEAD ; schedule ( ) ; BUG ( ) ; for ( ; ; ) cpu_relax ( ) ; } "," ) exit_io_context ( tsk ",torvalds@linux/b69f2292063d2caf37ca9aec7d63ded203701bf3,CVE-2012-0879,https://github.com/torvalds/linux/commit/b69f2292063d2caf37ca9aec7d63ded203701bf3,2012-05-17T11:00Z 1487,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 1488,CWE-20,"CWE-20 static void dns_resolver_describe ( const struct key * key , struct seq_file * m ) { seq_puts ( m , key -> description ) ; if ( key_is_instantiated ( key ) ) { int err = PTR_ERR ( key -> payload . data [ dns_key_error ] ) ; if ( err ) seq_printf ( m , "":%d"" , err ) ; else 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 1489,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 1490,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 1491,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 1492,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 1493,CWE-119,"CWE-119 int main_loop ( int argc , const char * * argv_ ) { vpx_codec_ctx_t decoder ; char * fn = NULL ; int i ; uint8_t * buf = NULL ; size_t bytes_in_buffer = 0 , buffer_size = 0 ; FILE * infile ; int frame_in = 0 , frame_out = 0 , flipuv = 0 , noblit = 0 ; int do_md5 = 0 , progress = 0 ; int stop_after = 0 , postproc = 0 , summary = 0 , quiet = 1 ; int arg_skip = 0 ; int ec_enabled = 0 ; const VpxInterface * interface = NULL ; const VpxInterface * fourcc_interface = NULL ; uint64_t dx_time = 0 ; struct arg arg ; char * * argv , * * argi , * * argj ; int single_file ; int use_y4m = 1 ; vpx_codec_dec_cfg_t cfg = { 0 } ; # if CONFIG_VP8_DECODER vp8_postproc_cfg_t vp8_pp_cfg = { 0 } ; int vp8_dbg_color_ref_frame = 0 ; int vp8_dbg_color_mb_modes = 0 ; int vp8_dbg_color_b_modes = 0 ; int vp8_dbg_display_mv = 0 ; # endif int frames_corrupted = 0 ; int dec_flags = 0 ; int do_scale = 0 ; vpx_image_t * scaled_img = NULL ; int frame_avail , got_data ; int num_external_frame_buffers = 0 ; struct ExternalFrameBufferList ext_fb_list = { 0 } ; const char * outfile_pattern = NULL ; char outfile_name [ PATH_MAX ] = { 0 } ; FILE * outfile = NULL ; MD5Context md5_ctx ; unsigned char md5_digest [ 16 ] ; struct VpxDecInputContext input = { 0 } ; struct VpxInputContext vpx_input_ctx = { 0 } ; struct WebmInputContext webm_ctx = { 0 } ; input . vpx_input_ctx = & vpx_input_ctx ; input . webm_ctx = & webm_ctx ; exec_name = argv_ [ 0 ] ; argv = argv_dup ( argc - 1 , argv_ + 1 ) ; for ( argi = argj = argv ; ( * argj = * argi ) ; argi += arg . argv_step ) { memset ( & arg , 0 , sizeof ( arg ) ) ; arg . argv_step = 1 ; if ( arg_match ( & arg , & codecarg , argi ) ) { interface = get_vpx_decoder_by_name ( arg . val ) ; if ( ! interface ) die ( ""Error:Unrecognizedargument(%s)to--codec\\n"" , arg . val ) ; } else if ( arg_match ( & arg , & looparg , argi ) ) { } else if ( arg_match ( & arg , & outputfile , argi ) ) outfile_pattern = arg . val ; else if ( arg_match ( & arg , & use_yv12 , argi ) ) { use_y4m = 0 ; flipuv = 1 ; } else if ( arg_match ( & arg , & use_i420 , argi ) ) { use_y4m = 0 ; flipuv = 0 ; } else if ( arg_match ( & arg , & flipuvarg , argi ) ) flipuv = 1 ; else if ( arg_match ( & arg , & noblitarg , argi ) ) noblit = 1 ; else if ( arg_match ( & arg , & progressarg , argi ) ) progress = 1 ; else if ( arg_match ( & arg , & limitarg , argi ) ) stop_after = arg_parse_uint ( & arg ) ; else if ( arg_match ( & arg , & skiparg , argi ) ) arg_skip = arg_parse_uint ( & arg ) ; else if ( arg_match ( & arg , & postprocarg , argi ) ) postproc = 1 ; else if ( arg_match ( & arg , & md5arg , argi ) ) do_md5 = 1 ; else if ( arg_match ( & arg , & summaryarg , argi ) ) summary = 1 ; else if ( arg_match ( & arg , & threadsarg , argi ) ) cfg . threads = arg_parse_uint ( & arg ) ; else if ( arg_match ( & arg , & verbosearg , argi ) ) quiet = 0 ; else if ( arg_match ( & arg , & scalearg , argi ) ) do_scale = 1 ; else if ( arg_match ( & arg , & fb_arg , argi ) ) num_external_frame_buffers = arg_parse_uint ( & arg ) ; # if CONFIG_VP8_DECODER else if ( arg_match ( & arg , & addnoise_level , argi ) ) { postproc = 1 ; vp8_pp_cfg . post_proc_flag |= VP8_ADDNOISE ; vp8_pp_cfg . noise_level = arg_parse_uint ( & arg ) ; } else if ( arg_match ( & arg , & demacroblock_level , argi ) ) { postproc = 1 ; vp8_pp_cfg . post_proc_flag |= VP8_DEMACROBLOCK ; vp8_pp_cfg . deblocking_level = arg_parse_uint ( & arg ) ; } else if ( arg_match ( & arg , & deblock , argi ) ) { postproc = 1 ; vp8_pp_cfg . post_proc_flag |= VP8_DEBLOCK ; } else if ( arg_match ( & arg , & mfqe , argi ) ) { postproc = 1 ; vp8_pp_cfg . post_proc_flag |= VP8_MFQE ; } else if ( arg_match ( & arg , & pp_debug_info , argi ) ) { unsigned int level = arg_parse_uint ( & arg ) ; postproc = 1 ; vp8_pp_cfg . post_proc_flag &= ~ 0x7 ; if ( level ) vp8_pp_cfg . post_proc_flag |= level ; } else if ( arg_match ( & arg , & pp_disp_ref_frame , argi ) ) { unsigned int flags = arg_parse_int ( & arg ) ; if ( flags ) { postproc = 1 ; vp8_dbg_color_ref_frame = flags ; } } else if ( arg_match ( & arg , & pp_disp_mb_modes , argi ) ) { unsigned int flags = arg_parse_int ( & arg ) ; if ( flags ) { postproc = 1 ; vp8_dbg_color_mb_modes = flags ; } } else if ( arg_match ( & arg , & pp_disp_b_modes , argi ) ) { unsigned int flags = arg_parse_int ( & arg ) ; if ( flags ) { postproc = 1 ; vp8_dbg_color_b_modes = flags ; } } else if ( arg_match ( & arg , & pp_disp_mvs , argi ) ) { unsigned int flags = arg_parse_int ( & arg ) ; if ( flags ) { postproc = 1 ; vp8_dbg_display_mv = flags ; } } else if ( arg_match ( & arg , & error_concealment , argi ) ) { ec_enabled = 1 ; } # endif else argj ++ ; } for ( argi = argv ; * argi ; argi ++ ) if ( argi [ 0 ] [ 0 ] == '-' && strlen ( argi [ 0 ] ) > 1 ) die ( ""Error:Unrecognizedoption%s\\n"" , * argi ) ; fn = argv [ 0 ] ; if ( ! fn ) usage_exit ( ) ; infile = strcmp ( fn , ""-"" ) ? fopen ( fn , ""rb"" ) : set_binary_mode ( stdin ) ; if ( ! infile ) { fprintf ( stderr , ""Failedtoopenfile\'%s\'"" , strcmp ( fn , ""-"" ) ? fn : ""stdin"" ) ; return EXIT_FAILURE ; } # if CONFIG_OS_SUPPORT if ( ! outfile_pattern && isatty ( fileno ( stdout ) ) && ! do_md5 && ! noblit ) { fprintf ( stderr , ""Notdumpingrawvideotoyourterminal.Use\'-o-\'to"" ""override.\\n"" ) ; return EXIT_FAILURE ; } # endif input . vpx_input_ctx -> file = infile ; if ( file_is_ivf ( input . vpx_input_ctx ) ) input . vpx_input_ctx -> file_type = FILE_TYPE_IVF ; # if CONFIG_WEBM_IO else if ( file_is_webm ( input . webm_ctx , input . vpx_input_ctx ) ) input . vpx_input_ctx -> file_type = FILE_TYPE_WEBM ; # endif else if ( file_is_raw ( input . vpx_input_ctx ) ) input . vpx_input_ctx -> file_type = FILE_TYPE_RAW ; else { fprintf ( stderr , ""Unrecognizedinputfiletype.\\n"" ) ; # if ! CONFIG_WEBM_IO fprintf ( stderr , ""vpxdecwasbuiltwithoutWebMcontainersupport.\\n"" ) ; # endif return EXIT_FAILURE ; } outfile_pattern = outfile_pattern ? outfile_pattern : ""-"" ; single_file = is_single_file ( outfile_pattern ) ; if ( ! noblit && single_file ) { generate_filename ( outfile_pattern , outfile_name , PATH_MAX , vpx_input_ctx . width , vpx_input_ctx . height , 0 ) ; if ( do_md5 ) MD5Init ( & md5_ctx ) ; else outfile = open_outfile ( outfile_name ) ; } if ( use_y4m && ! noblit ) { if ( ! single_file ) { fprintf ( stderr , ""YUV4MPEG2notsupportedwithoutputpatterns,"" ""try--i420or--yv12.\\n"" ) ; return EXIT_FAILURE ; } # if CONFIG_WEBM_IO if ( vpx_input_ctx . file_type == FILE_TYPE_WEBM ) { if ( webm_guess_framerate ( input . webm_ctx , input . vpx_input_ctx ) ) { fprintf ( stderr , ""Failedtoguessframerate--errorparsing"" ""webmfile?\\n"" ) ; return EXIT_FAILURE ; } } # endif } fourcc_interface = get_vpx_decoder_by_fourcc ( vpx_input_ctx . fourcc ) ; if ( interface && fourcc_interface && interface != fourcc_interface ) warn ( ""Headerindicatescodec:%s\\n"" , fourcc_interface -> name ) ; else interface = fourcc_interface ; if ( ! interface ) interface = get_vpx_decoder_by_index ( 0 ) ; dec_flags = ( postproc ? VPX_CODEC_USE_POSTPROC : 0 ) | ( ec_enabled ? VPX_CODEC_USE_ERROR_CONCEALMENT : 0 ) ; if ( vpx_codec_dec_init ( & decoder , interface -> interface ( ) , & cfg , dec_flags ) ) { fprintf ( stderr , ""Failedtoinitializedecoder:%s\\n"" , vpx_codec_error ( & decoder ) ) ; return EXIT_FAILURE ; } if ( ! quiet ) fprintf ( stderr , ""%s\\n"" , decoder . name ) ; # if CONFIG_VP8_DECODER if ( vp8_pp_cfg . post_proc_flag && vpx_codec_control ( & decoder , VP8_SET_POSTPROC , & vp8_pp_cfg ) ) { fprintf ( stderr , ""Failedtoconfigurepostproc:%s\\n"" , vpx_codec_error ( & decoder ) ) ; return EXIT_FAILURE ; } if ( vp8_dbg_color_ref_frame && vpx_codec_control ( & decoder , VP8_SET_DBG_COLOR_REF_FRAME , vp8_dbg_color_ref_frame ) ) { fprintf ( stderr , ""Failedtoconfigurereferenceblockvisualizer:%s\\n"" , vpx_codec_error ( & decoder ) ) ; return EXIT_FAILURE ; } if ( vp8_dbg_color_mb_modes && vpx_codec_control ( & decoder , VP8_SET_DBG_COLOR_MB_MODES , vp8_dbg_color_mb_modes ) ) { fprintf ( stderr , ""Failedtoconfiguremacroblockvisualizer:%s\\n"" , vpx_codec_error ( & decoder ) ) ; return EXIT_FAILURE ; } if ( vp8_dbg_color_b_modes && vpx_codec_control ( & decoder , VP8_SET_DBG_COLOR_B_MODES , vp8_dbg_color_b_modes ) ) { fprintf ( stderr , ""Failedtoconfigureblockvisualizer:%s\\n"" , vpx_codec_error ( & decoder ) ) ; return EXIT_FAILURE ; } if ( vp8_dbg_display_mv && vpx_codec_control ( & decoder , VP8_SET_DBG_DISPLAY_MV , vp8_dbg_display_mv ) ) { fprintf ( stderr , ""Failedtoconfiguremotionvectorvisualizer:%s\\n"" , vpx_codec_error ( & decoder ) ) ; return EXIT_FAILURE ; } # endif if ( arg_skip ) fprintf ( stderr , ""Skippingfirst%dframes.\\n"" , arg_skip ) ; while ( arg_skip ) { if ( read_frame ( & input , & buf , & bytes_in_buffer , & buffer_size ) ) break ; arg_skip -- ; } if ( num_external_frame_buffers > 0 ) { ext_fb_list . num_external_frame_buffers = num_external_frame_buffers ; ext_fb_list . ext_fb = ( struct ExternalFrameBuffer * ) calloc ( num_external_frame_buffers , sizeof ( * ext_fb_list . ext_fb ) ) ; if ( vpx_codec_set_frame_buffer_functions ( & decoder , get_vp9_frame_buffer , release_vp9_frame_buffer , & ext_fb_list ) ) { fprintf ( stderr , ""Failedtoconfigureexternalframebuffers:%s\\n"" , vpx_codec_error ( & decoder ) ) ; return EXIT_FAILURE ; } } frame_avail = 1 ; got_data = 0 ; while ( frame_avail || got_data ) { vpx_codec_iter_t iter = NULL ; vpx_image_t * img ; struct vpx_usec_timer timer ; int corrupted ; frame_avail = 0 ; if ( ! stop_after || frame_in < stop_after ) { if ( ! read_frame ( & input , & buf , & bytes_in_buffer , & buffer_size ) ) { frame_avail = 1 ; frame_in ++ ; vpx_usec_timer_start ( & timer ) ; if ( vpx_codec_decode ( & decoder , buf , ( unsigned int ) bytes_in_buffer , NULL , 0 ) ) { const char * detail = vpx_codec_error_detail ( & decoder ) ; warn ( ""Failedtodecodeframe%d:%s"" , frame_in , vpx_codec_error ( & decoder ) ) ; if ( detail ) warn ( ""Additionalinformation:%s"" , detail ) ; goto fail ; } vpx_usec_timer_mark ( & timer ) ; dx_time += vpx_usec_timer_elapsed ( & timer ) ; } } vpx_usec_timer_start ( & timer ) ; got_data = 0 ; if ( ( img = vpx_codec_get_frame ( & decoder , & iter ) ) ) { ++ frame_out ; got_data = 1 ; } vpx_usec_timer_mark ( & timer ) ; dx_time += ( unsigned int ) vpx_usec_timer_elapsed ( & timer ) ; if ( vpx_codec_control ( & decoder , VP8D_GET_FRAME_CORRUPTED , & corrupted ) ) { warn ( ""FailedVP8_GET_FRAME_CORRUPTED:%s"" , vpx_codec_error ( & decoder ) ) ; goto fail ; } frames_corrupted += corrupted ; if ( progress ) show_progress ( frame_in , frame_out , dx_time ) ; if ( ! noblit && img ) { const int PLANES_YUV [ ] = { VPX_PLANE_Y , VPX_PLANE_U , VPX_PLANE_V } ; const int PLANES_YVU [ ] = { VPX_PLANE_Y , VPX_PLANE_V , VPX_PLANE_U } ; const int * planes = flipuv ? PLANES_YVU : PLANES_YUV ; if ( do_scale ) { if ( frame_out == 1 ) { int display_width = vpx_input_ctx . width ; int display_height = vpx_input_ctx . height ; if ( ! display_width || ! display_height ) { int display_size [ 2 ] ; if ( vpx_codec_control ( & decoder , VP9D_GET_DISPLAY_SIZE , display_size ) ) { display_width = img -> d_w ; display_height = img -> d_h ; } else { display_width = display_size [ 0 ] ; display_height = display_size [ 1 ] ; } } scaled_img = vpx_img_alloc ( NULL , VPX_IMG_FMT_I420 , display_width , display_height , 16 ) ; } if ( img -> d_w != scaled_img -> d_w || img -> d_h != scaled_img -> d_h ) { vpx_image_scale ( img , scaled_img , kFilterBox ) ; img = scaled_img ; } } if ( single_file ) { if ( use_y4m ) { char buf [ Y4M_BUFFER_SIZE ] = { 0 } ; size_t len = 0 ; if ( frame_out == 1 ) { len = y4m_write_file_header ( buf , sizeof ( buf ) , vpx_input_ctx . width , vpx_input_ctx . height , & vpx_input_ctx . framerate , img -> fmt ) ; if ( do_md5 ) { MD5Update ( & md5_ctx , ( md5byte * ) buf , ( unsigned int ) len ) ; } else { fputs ( buf , outfile ) ; } } len = y4m_write_frame_header ( buf , sizeof ( buf ) ) ; if ( do_md5 ) { MD5Update ( & md5_ctx , ( md5byte * ) buf , ( unsigned int ) len ) ; } else { fputs ( buf , outfile ) ; } } if ( do_md5 ) { update_image_md5 ( img , planes , & md5_ctx ) ; } else { write_image_file ( img , planes , outfile ) ; } } else { generate_filename ( outfile_pattern , outfile_name , PATH_MAX , img -> d_w , img -> d_h , frame_in ) ; if ( do_md5 ) { MD5Init ( & md5_ctx ) ; update_image_md5 ( img , planes , & md5_ctx ) ; MD5Final ( md5_digest , & md5_ctx ) ; print_md5 ( md5_digest , outfile_name ) ; } else { outfile = open_outfile ( outfile_name ) ; write_image_file ( img , planes , outfile ) ; fclose ( outfile ) ; } } } if ( stop_after && frame_in >= stop_after ) break ; } if ( summary || progress ) { show_progress ( frame_in , frame_out , dx_time ) ; fprintf ( stderr , ""\\n"" ) ; } if ( frames_corrupted ) fprintf ( stderr , ""WARNING:%dframescorrupted.\\n"" , frames_corrupted ) ; fail : if ( vpx_codec_destroy ( & decoder ) ) { fprintf ( stderr , ""Failedtodestroydecoder:%s\\n"" , vpx_codec_error ( & decoder ) ) ; return EXIT_FAILURE ; } if ( ! noblit && single_file ) { if ( do_md5 ) { MD5Final ( md5_digest , & md5_ctx ) ; print_md5 ( md5_digest , outfile_name ) ; } else { fclose ( outfile ) ; } } # if CONFIG_WEBM_IO if ( input . vpx_input_ctx -> file_type == FILE_TYPE_WEBM ) webm_free ( input . webm_ctx ) ; # endif if ( input . vpx_input_ctx -> file_type != FILE_TYPE_WEBM ) free ( buf ) ; if ( scaled_img ) vpx_img_free ( scaled_img ) ; for ( i = 0 ; i < ext_fb_list . num_external_frame_buffers ; ++ i ) { free ( ext_fb_list . ext_fb [ i ] . data ) ; } free ( ext_fb_list . ext_fb ) ; fclose ( infile ) ; free ( argv ) ; return frames_corrupted ? EXIT_FAILURE : EXIT_SUCCESS ; } "," static progress = 0 , frame_parallel = 0 ; int ec_enabled = 0 ; int keep_going = 1 ; int opt_yv12 = 0 ; int opt_i420 = 0 ; = { 0 , 0 , 0 } ; # if CONFIG_VP9_HIGHBITDEPTH int output_bit_depth = 0 ; # endif # if CONFIG_VP8_DECODER = NULL ; # if CONFIG_VP9_HIGHBITDEPTH vpx_image_t * img_shifted = NULL ; # endif frame_avail , got_data , flush_decoder = 0 = { 0 , NULL input = { NULL , NULL } ; struct struct VpxInputContext vpx_input_ctx ; # if CONFIG_WEBM_IO struct WebmInputContext webm_ctx struct WebmInputContext webm_ctx ; memset ( & ( webm_ctx ) , 0 , sizeof ( webm_ctx ) ) ; input . ; input . webm_ctx = & webm_ctx ; # endif input . = & vpx_input_ctx ; exec_name = = 1 ; opt_yv12 = 1 ; # if CONFIG_VP9_HIGHBITDEPTH output_bit_depth = 8 ; # endif = 0 ; opt_i420 = 1 ; arg , & rawvideo , argi ) ) { use_y4m = 0 ; } else if ( arg_match ( & arg , & arg ) ; # if CONFIG_VP9_DECODER || CONFIG_VP10_DECODER arg , & frameparallelarg , argi ) ) frame_parallel = 1 ; # endif else if ( arg_match ( & arg , & arg ) ; else if ( arg_match ( & arg , & continuearg , argi ) ) keep_going = 1 ; # if CONFIG_VP9_HIGHBITDEPTH else if ( arg_match ( & arg , & outbitdeptharg , argi ) ) { output_bit_depth = arg_parse_uint ( & arg ) ; } # endif ! fn ) { free ( argv ) ; ( ) ; } infile ) { fatal ( ""Failedtoopeninputfile\'%s\'"" , strcmp ( : ""stdin"" ) ; } # stderr , ""YUV4MPEG2notsupportedwithoutputpatterns,"" ""try--i420or--yv12or--rawvideo.\\n"" ) ; return : 0 ) | ( frame_parallel ? VPX_CODEC_USE_FRAME_THREADING : 0 ) , interface -> codec_interface ( ) , & cfg , ; int corrupted = 0 detail ) ; if ( ! keep_going ) ) ; } else { flush_decoder = 1 ; } } else { flush_decoder = 1 ; timer ) ; if ( flush_decoder ) { if ( vpx_codec_decode ( & decoder , NULL , 0 , NULL , 0 ) ) { warn ( ""Failedtoflushdecoder:%s"" , vpx_codec_error ( & decoder ) ) ; } } ; if ( ! frame_parallel && ) ) ; if ( ! keep_going ) ( NULL , img -> fmt , display_width , , 16 ) ; scaled_img -> bit_depth = img -> bit_depth d_h ) { # if CONFIG_LIBYUV libyuv_scale ( img , = scaled_img ; # else fprintf ( stderr , ""Failedtoscaleoutputframe:%s.\\n"" ""Scalingisdisabledinthisconfiguration."" ""Toenablescaling,configurewith--enable-libyuv\\n"" , vpx_codec_error ( & decoder ) ) ; return EXIT_FAILURE ; # endif } } # if CONFIG_VP9_HIGHBITDEPTH if ( ! output_bit_depth ) { output_bit_depth = img -> bit_depth ; } if ( output_bit_depth != img -> bit_depth ) { const vpx_img_fmt_t shifted_fmt = output_bit_depth == 8 ? img -> fmt ^ ( img -> fmt & VPX_IMG_FMT_HIGHBITDEPTH ) : img -> fmt | VPX_IMG_FMT_HIGHBITDEPTH ; if ( img_shifted && img_shifted_realloc_required ( img , img_shifted , shifted_fmt ) ) { vpx_img_free ( img_shifted ) ; img_shifted = NULL ; } if ( ! img_shifted ) { img_shifted = vpx_img_alloc ( NULL , shifted_fmt , img -> d_w , img -> d_h , 16 ) ; img_shifted -> bit_depth = output_bit_depth ; } if ( output_bit_depth > img -> bit_depth ) { vpx_img_upshift ( img_shifted , img , output_bit_depth - img -> bit_depth ) ; } else { vpx_img_downshift ( img_shifted , img , img -> bit_depth - output_bit_depth ) ; } img = img_shifted ; } # endif if ( single_file ; if ( img -> fmt == VPX_IMG_FMT_I440 || img -> fmt == VPX_IMG_FMT_I44016 ) { fprintf ( stderr , ""Cannotproducey4moutputfor440sampling.\\n"" ) ; goto fail ; } if ( img -> fmt , img -> bit_depth ; } } else { if ( frame_out == 1 ) { if ( opt_i420 ) { if ( img -> fmt != VPX_IMG_FMT_I420 && img -> fmt != VPX_IMG_FMT_I42016 ) { fprintf ( stderr , ""Cannotproducei420outputforbit-stream.\\n"" ) ; goto fail ; } } if ( opt_yv12 ) { if ( ( img -> fmt != VPX_IMG_FMT_I420 && img -> fmt != VPX_IMG_FMT_YV12 ) || img -> bit_depth != 8 ) { fprintf ( stderr , ""Cannotproduceyv12outputforbit-stream.\\n"" ) ; goto fail ; } } } } } } } } if ( scaled_img ) ; # if CONFIG_VP9_HIGHBITDEPTH if ( img_shifted ) vpx_img_free ( img_shifted ) ; # endif ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1494,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 1495,CWE-125,"CWE-125 uint32_t _WM_SetupMidiEvent ( struct _mdi * mdi , uint8_t * event_data , uint8_t running_event ) { uint32_t ret_cnt = 0 ; uint8_t command = 0 ; uint8_t channel = 0 ; uint8_t data_1 = 0 ; uint8_t data_2 = 0 ; char * text = NULL ; if ( event_data [ 0 ] >= 0x80 ) { command = * event_data & 0xf0 ; channel = * event_data ++ & 0x0f ; ret_cnt ++ ; } else { command = running_event & 0xf0 ; channel = running_event & 0x0f ; } switch ( command ) { case 0x80 : _SETUP_NOTEOFF : data_1 = * event_data ++ ; data_2 = * event_data ++ ; _WM_midi_setup_noteoff ( mdi , channel , data_1 , data_2 ) ; ret_cnt += 2 ; break ; case 0x90 : if ( event_data [ 1 ] == 0 ) goto _SETUP_NOTEOFF ; data_1 = * event_data ++ ; data_2 = * event_data ++ ; midi_setup_noteon ( mdi , channel , data_1 , data_2 ) ; ret_cnt += 2 ; break ; case 0xa0 : data_1 = * event_data ++ ; data_2 = * event_data ++ ; midi_setup_aftertouch ( mdi , channel , data_1 , data_2 ) ; ret_cnt += 2 ; break ; case 0xb0 : data_1 = * event_data ++ ; data_2 = * event_data ++ ; midi_setup_control ( mdi , channel , data_1 , data_2 ) ; ret_cnt += 2 ; break ; case 0xc0 : data_1 = * event_data ++ ; midi_setup_patch ( mdi , channel , data_1 ) ; ret_cnt ++ ; break ; case 0xd0 : data_1 = * event_data ++ ; midi_setup_channel_pressure ( mdi , channel , data_1 ) ; ret_cnt ++ ; break ; case 0xe0 : data_1 = * event_data ++ ; data_2 = * event_data ++ ; midi_setup_pitch ( mdi , channel , ( ( data_2 << 7 ) | ( data_1 & 0x7f ) ) ) ; ret_cnt += 2 ; break ; case 0xf0 : if ( channel == 0x0f ) { uint32_t tmp_length = 0 ; if ( ( event_data [ 0 ] == 0x00 ) && ( event_data [ 1 ] == 0x02 ) ) { midi_setup_sequenceno ( mdi , ( ( event_data [ 2 ] << 8 ) + event_data [ 3 ] ) ) ; ret_cnt += 4 ; } else if ( event_data [ 0 ] == 0x01 ) { event_data ++ ; ret_cnt ++ ; if ( * event_data > 0x7f ) { do { tmp_length = ( tmp_length << 7 ) + ( * event_data & 0x7f ) ; event_data ++ ; ret_cnt ++ ; } while ( * event_data > 0x7f ) ; } tmp_length = ( tmp_length << 7 ) + ( * event_data & 0x7f ) ; event_data ++ ; ret_cnt ++ ; text = malloc ( tmp_length + 1 ) ; memcpy ( text , event_data , tmp_length ) ; text [ tmp_length ] = '\\0' ; midi_setup_text ( mdi , text ) ; ret_cnt += tmp_length ; } else if ( event_data [ 0 ] == 0x02 ) { event_data ++ ; ret_cnt ++ ; if ( * event_data > 0x7f ) { do { tmp_length = ( tmp_length << 7 ) + ( * event_data & 0x7f ) ; event_data ++ ; ret_cnt ++ ; } while ( * event_data > 0x7f ) ; } tmp_length = ( tmp_length << 7 ) + ( * event_data & 0x7f ) ; event_data ++ ; ret_cnt ++ ; if ( mdi -> extra_info . copyright ) { mdi -> extra_info . copyright = realloc ( mdi -> extra_info . copyright , ( strlen ( mdi -> extra_info . copyright ) + 1 + tmp_length + 1 ) ) ; memcpy ( & mdi -> extra_info . copyright [ strlen ( mdi -> extra_info . copyright ) + 1 ] , event_data , tmp_length ) ; mdi -> extra_info . copyright [ strlen ( mdi -> extra_info . copyright ) + 1 + tmp_length ] = '\\0' ; mdi -> extra_info . copyright [ strlen ( mdi -> extra_info . copyright ) ] = '\\n' ; } else { mdi -> extra_info . copyright = malloc ( tmp_length + 1 ) ; memcpy ( mdi -> extra_info . copyright , event_data , tmp_length ) ; mdi -> extra_info . copyright [ tmp_length ] = '\\0' ; } text = malloc ( tmp_length + 1 ) ; memcpy ( text , event_data , tmp_length ) ; text [ tmp_length ] = '\\0' ; midi_setup_copyright ( mdi , text ) ; ret_cnt += tmp_length ; } else if ( event_data [ 0 ] == 0x03 ) { event_data ++ ; ret_cnt ++ ; if ( * event_data > 0x7f ) { do { tmp_length = ( tmp_length << 7 ) + ( * event_data & 0x7f ) ; event_data ++ ; ret_cnt ++ ; } while ( * event_data > 0x7f ) ; } tmp_length = ( tmp_length << 7 ) + ( * event_data & 0x7f ) ; event_data ++ ; ret_cnt ++ ; text = malloc ( tmp_length + 1 ) ; memcpy ( text , event_data , tmp_length ) ; text [ tmp_length ] = '\\0' ; midi_setup_trackname ( mdi , text ) ; ret_cnt += tmp_length ; } else if ( event_data [ 0 ] == 0x04 ) { event_data ++ ; ret_cnt ++ ; if ( * event_data > 0x7f ) { do { tmp_length = ( tmp_length << 7 ) + ( * event_data & 0x7f ) ; event_data ++ ; ret_cnt ++ ; } while ( * event_data > 0x7f ) ; } tmp_length = ( tmp_length << 7 ) + ( * event_data & 0x7f ) ; event_data ++ ; ret_cnt ++ ; text = malloc ( tmp_length + 1 ) ; memcpy ( text , event_data , tmp_length ) ; text [ tmp_length ] = '\\0' ; midi_setup_instrumentname ( mdi , text ) ; ret_cnt += tmp_length ; } else if ( event_data [ 0 ] == 0x05 ) { event_data ++ ; ret_cnt ++ ; if ( * event_data > 0x7f ) { do { tmp_length = ( tmp_length << 7 ) + ( * event_data & 0x7f ) ; event_data ++ ; ret_cnt ++ ; } while ( * event_data > 0x7f ) ; } tmp_length = ( tmp_length << 7 ) + ( * event_data & 0x7f ) ; event_data ++ ; ret_cnt ++ ; text = malloc ( tmp_length + 1 ) ; memcpy ( text , event_data , tmp_length ) ; text [ tmp_length ] = '\\0' ; midi_setup_lyric ( mdi , text ) ; ret_cnt += tmp_length ; } else if ( event_data [ 0 ] == 0x06 ) { event_data ++ ; ret_cnt ++ ; if ( * event_data > 0x7f ) { do { tmp_length = ( tmp_length << 7 ) + ( * event_data & 0x7f ) ; event_data ++ ; ret_cnt ++ ; } while ( * event_data > 0x7f ) ; } tmp_length = ( tmp_length << 7 ) + ( * event_data & 0x7f ) ; event_data ++ ; ret_cnt ++ ; text = malloc ( tmp_length + 1 ) ; memcpy ( text , event_data , tmp_length ) ; text [ tmp_length ] = '\\0' ; midi_setup_marker ( mdi , text ) ; ret_cnt += tmp_length ; } else if ( event_data [ 0 ] == 0x07 ) { event_data ++ ; ret_cnt ++ ; if ( * event_data > 0x7f ) { do { tmp_length = ( tmp_length << 7 ) + ( * event_data & 0x7f ) ; event_data ++ ; ret_cnt ++ ; } while ( * event_data > 0x7f ) ; } tmp_length = ( tmp_length << 7 ) + ( * event_data & 0x7f ) ; event_data ++ ; ret_cnt ++ ; text = malloc ( tmp_length + 1 ) ; memcpy ( text , event_data , tmp_length ) ; text [ tmp_length ] = '\\0' ; midi_setup_cuepoint ( mdi , text ) ; ret_cnt += tmp_length ; } else if ( ( event_data [ 0 ] == 0x20 ) && ( event_data [ 1 ] == 0x01 ) ) { midi_setup_channelprefix ( mdi , event_data [ 2 ] ) ; ret_cnt += 3 ; } else if ( ( event_data [ 0 ] == 0x21 ) && ( event_data [ 1 ] == 0x01 ) ) { midi_setup_portprefix ( mdi , event_data [ 2 ] ) ; ret_cnt += 3 ; } else if ( ( event_data [ 0 ] == 0x2F ) && ( event_data [ 1 ] == 0x00 ) ) { _WM_midi_setup_endoftrack ( mdi ) ; ret_cnt += 2 ; } else if ( ( event_data [ 0 ] == 0x51 ) && ( event_data [ 1 ] == 0x03 ) ) { _WM_midi_setup_tempo ( mdi , ( ( event_data [ 2 ] << 16 ) + ( event_data [ 3 ] << 8 ) + event_data [ 4 ] ) ) ; ret_cnt += 5 ; } else if ( ( event_data [ 0 ] == 0x54 ) && ( event_data [ 1 ] == 0x05 ) ) { midi_setup_smpteoffset ( mdi , ( ( event_data [ 3 ] << 24 ) + ( event_data [ 4 ] << 16 ) + ( event_data [ 5 ] << 8 ) + event_data [ 6 ] ) ) ; mdi -> events [ mdi -> events_size - 1 ] . event_data . channel = event_data [ 2 ] ; ret_cnt += 7 ; } else if ( ( event_data [ 0 ] == 0x58 ) && ( event_data [ 1 ] == 0x04 ) ) { midi_setup_timesignature ( mdi , ( ( event_data [ 2 ] << 24 ) + ( event_data [ 3 ] << 16 ) + ( event_data [ 4 ] << 8 ) + event_data [ 5 ] ) ) ; ret_cnt += 6 ; } else if ( ( event_data [ 0 ] == 0x59 ) && ( event_data [ 1 ] == 0x02 ) ) { midi_setup_keysignature ( mdi , ( ( event_data [ 2 ] << 8 ) + event_data [ 3 ] ) ) ; ret_cnt += 4 ; } else { event_data ++ ; ret_cnt ++ ; if ( * event_data > 0x7f ) { do { tmp_length = ( tmp_length << 7 ) + ( * event_data & 0x7f ) ; event_data ++ ; ret_cnt ++ ; } while ( * event_data > 0x7f ) ; } tmp_length = ( tmp_length << 7 ) + ( * event_data & 0x7f ) ; ret_cnt ++ ; ret_cnt += tmp_length ; } } else if ( ( channel == 0 ) || ( channel == 7 ) ) { uint32_t sysex_len = 0 ; uint8_t * sysex_store = NULL ; if ( * event_data > 0x7f ) { do { sysex_len = ( sysex_len << 7 ) + ( * event_data & 0x7F ) ; event_data ++ ; ret_cnt ++ ; } while ( * event_data > 0x7f ) ; } sysex_len = ( sysex_len << 7 ) + ( * event_data & 0x7F ) ; event_data ++ ; if ( ! sysex_len ) break ; ret_cnt ++ ; sysex_store = malloc ( sizeof ( uint8_t ) * sysex_len ) ; memcpy ( sysex_store , event_data , sysex_len ) ; if ( sysex_store [ sysex_len - 1 ] == 0xF7 ) { uint8_t rolandsysexid [ ] = { 0x41 , 0x10 , 0x42 , 0x12 } ; if ( memcmp ( rolandsysexid , sysex_store , 4 ) == 0 ) { uint8_t sysex_cs = 0 ; uint32_t sysex_ofs = 4 ; do { sysex_cs += sysex_store [ sysex_ofs ] ; if ( sysex_cs > 0x7F ) { sysex_cs -= 0x80 ; } sysex_ofs ++ ; } while ( sysex_store [ sysex_ofs + 1 ] != 0xf7 ) ; sysex_cs = 128 - sysex_cs ; if ( sysex_cs == sysex_store [ sysex_ofs ] ) { if ( sysex_store [ 4 ] == 0x40 ) { if ( ( ( sysex_store [ 5 ] & 0xf0 ) == 0x10 ) && ( sysex_store [ 6 ] == 0x15 ) ) { uint8_t sysex_ch = 0x0f & sysex_store [ 5 ] ; if ( sysex_ch == 0x00 ) { sysex_ch = 0x09 ; } else if ( sysex_ch <= 0x09 ) { sysex_ch -= 1 ; } midi_setup_sysex_roland_drum_track ( mdi , sysex_ch , sysex_store [ 7 ] ) ; } else if ( ( sysex_store [ 5 ] == 0x00 ) && ( sysex_store [ 6 ] == 0x7F ) && ( sysex_store [ 7 ] == 0x00 ) ) { midi_setup_sysex_roland_reset ( mdi ) ; } } } } else { uint8_t gm_reset [ ] = { 0x7e , 0x7f , 0x09 , 0x01 , 0xf7 } ; uint8_t yamaha_reset [ ] = { 0x43 , 0x10 , 0x4c , 0x00 , 0x00 , 0x7e , 0x00 , 0xf7 } ; if ( memcmp ( gm_reset , sysex_store , 5 ) == 0 ) { midi_setup_sysex_gm_reset ( mdi ) ; } else if ( memcmp ( yamaha_reset , sysex_store , 8 ) == 0 ) { midi_setup_sysex_yamaha_reset ( mdi ) ; } } } free ( sysex_store ) ; sysex_store = NULL ; ret_cnt += sysex_len ; } else { _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_CORUPT , ""(unrecognizedmetatypeevent)"" , 0 ) ; return 0 ; } break ; default : ret_cnt = 0 ; break ; } if ( ret_cnt == 0 ) _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_CORUPT , ""(missingevent)"" , 0 ) ; return ret_cnt ; } "," * event_data , uint32_t siz , ; if ( ! siz ) goto shortbuf ; if ( ; ret_cnt ++ ; if ( -- siz == 0 ) goto shortbuf : _SETUP_NOTEOFF : if ( siz < 2 ) goto shortbuf ; goto _SETUP_NOTEOFF ; if ( siz < 2 ) goto shortbuf ; case 0xa0 : if ( siz < 2 ) goto shortbuf ; case 0xb0 : if ( siz < 2 ) goto shortbuf ; case 0xe0 : if ( siz < 2 ) goto shortbuf ; ) ) { if ( siz < 4 ) goto shortbuf ; ; if ( -- siz && { do { if ( ! siz ) break ; event_data ++ ; siz -- ; ) ; } if ( ! siz ) goto shortbuf ; ret_cnt ++ ; if ( -- siz < tmp_length ) goto shortbuf ; if ( ! tmp_length ) break ; ; if ( -- siz && { do { if ( ! siz ) break ; event_data ++ ; siz -- ; ) ; } if ( ! siz ) goto shortbuf ; ; ret_cnt ++ ; if ( -- siz < tmp_length ) goto shortbuf ; if ( ! tmp_length ) break ; if ( -- siz && { do { if ( ! siz ) break ; event_data ++ ; siz -- ; ) ; } if ( ! siz ) goto shortbuf ; ret_cnt ++ ; if ( -- siz < tmp_length ) goto shortbuf ; if ( ! tmp_length ) break ; ; if ( -- siz && { do { if ( ! siz ) break ; event_data ++ ; siz -- ; ) ; } if ( ! siz ) goto shortbuf ; ret_cnt ++ ; if ( -- siz < tmp_length ) goto shortbuf ; if ( ! tmp_length ) break ; ; if ( -- siz && { do { if ( ! siz ) break ; event_data ++ ; siz -- ; ) ; } if ( ! siz ) goto shortbuf ; ret_cnt ++ ; if ( -- siz < tmp_length ) goto shortbuf ; if ( ! tmp_length ) break ; ; if ( -- siz && { do { if ( ! siz ) break ; event_data ++ ; siz -- ; ) ; } if ( ! siz ) goto shortbuf ; ret_cnt ++ ; if ( -- siz < tmp_length ) goto shortbuf ; if ( ! tmp_length ) break ; ; if ( -- siz && { do { if ( ! siz ) break ; event_data ++ ; siz -- ; ) ; } if ( ! siz ) goto shortbuf ; ret_cnt ++ ; if ( -- siz < tmp_length ) goto shortbuf ; if ( ! tmp_length ) break ; ) ) { if ( siz < 3 ) goto shortbuf ; ) ) { if ( siz < 3 ) goto shortbuf ; ) ) { if ( siz < 2 ) goto shortbuf ; ) ) { if ( siz < 5 ) goto shortbuf ; ) ) { if ( siz < 7 ) goto shortbuf ; ) ) { if ( siz < 6 ) goto shortbuf ; ) ) { if ( siz < 4 ) goto shortbuf ; ; if ( -- siz && { do { if ( ! siz ) break ; event_data ++ ; siz -- ; ) ; } if ( ! siz ) goto shortbuf ; += tmp_length ; if ( -- siz < tmp_length ) goto shortbuf ; { do { if ( ! siz ) break ; event_data ++ ; siz -- ; ) ; } if ( ! siz ) goto shortbuf ; event_data ++ ; ret_cnt ++ ; if ( -- siz < sysex_len ) goto shortbuf ; sysex_len ) break ; sysex_store = return ret_cnt ; shortbuf : _WM_GLOBAL_ERROR ( __FUNCTION__ , __LINE__ , WM_ERR_CORUPT , ""(inputtooshort)"" , 0 ) ; return 0 ; ",Mindwerks@wildmidi/ad6d7cf88d6673167ca1f517248af9409a9f1be1,CVE-2017-11664,https://github.com/Mindwerks/wildmidi/commit/ad6d7cf88d6673167ca1f517248af9409a9f1be1,2017-08-17T16:29Z 1496,CWE-264,"CWE-264 static int flakey_ioctl ( struct dm_target * ti , unsigned int cmd , unsigned long arg ) { struct flakey_c * fc = ti -> private ; return __blkdev_driver_ioctl ( fc -> dev -> bdev , fc -> dev -> mode , cmd , arg ) ; } "," -> private ; struct dm_dev * dev = fc -> dev ; int r = 0 ; if ( fc -> ( fc -> 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 1497,CWE-787,"CWE-787 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 1498,CWE-787,"CWE-787 l_int32 gplotAddPlot ( GPLOT * gplot , NUMA * nax , NUMA * nay , l_int32 plotstyle , const char * plottitle ) { char buf [ L_BUF_SIZE ] ; char emptystring [ ] = """" ; char * datastr , * title ; l_int32 n , i ; l_float32 valx , valy , startx , delx ; SARRAY * sa ; PROCNAME ( ""gplotAddPlot"" ) ; if ( ! gplot ) return ERROR_INT ( ""gplotnotdefined"" , procName , 1 ) ; if ( ! nay ) return ERROR_INT ( ""naynotdefined"" , procName , 1 ) ; if ( plotstyle < 0 || plotstyle >= NUM_GPLOT_STYLES ) return ERROR_INT ( ""invalidplotstyle"" , procName , 1 ) ; if ( ( n = numaGetCount ( nay ) ) == 0 ) return ERROR_INT ( ""nopointstoplot"" , procName , 1 ) ; if ( nax && ( n != numaGetCount ( nax ) ) ) return ERROR_INT ( ""naxandnaysizesdiffer"" , procName , 1 ) ; if ( n == 1 && plotstyle == GPLOT_LINES ) { L_INFO ( ""only1pt;changingstyletopoints\\n"" , procName ) ; plotstyle = GPLOT_POINTS ; } numaGetParameters ( nay , & startx , & delx ) ; numaAddNumber ( gplot -> plotstyles , plotstyle ) ; if ( plottitle ) { title = stringNew ( plottitle ) ; sarrayAddString ( gplot -> plottitles , title , L_INSERT ) ; } else { sarrayAddString ( gplot -> plottitles , emptystring , L_COPY ) ; } gplot -> nplots ++ ; snprintf ( buf , L_BUF_SIZE , ""%s.data.%d"" , gplot -> rootname , gplot -> nplots ) ; sarrayAddString ( gplot -> datanames , buf , L_COPY ) ; sa = sarrayCreate ( n ) ; for ( i = 0 ; i < n ; i ++ ) { if ( nax ) numaGetFValue ( nax , i , & valx ) ; else valx = startx + i * delx ; numaGetFValue ( nay , i , & valy ) ; snprintf ( buf , L_BUF_SIZE , ""%f%f\\n"" , valx , valy ) ; sarrayAddString ( sa , buf , L_COPY ) ; } datastr = sarrayToString ( sa , 0 ) ; sarrayAddString ( gplot -> plotdata , datastr , L_INSERT ) ; sarrayDestroy ( & sa ) ; return 0 ; } "," char buf [ L_BUFSIZE ] ; char ( buf , L_BUFSIZE , ""%s.data.%d"" , ( buf , L_BUFSIZE , ""%f%f\\n"" , ",DanBloomberg@leptonica/ee301cb2029db8a6289c5295daa42bba7715e99a,CVE-2018-7186,https://github.com/DanBloomberg/leptonica/commit/ee301cb2029db8a6289c5295daa42bba7715e99a,2018-02-16T16:29Z 1499,CWE-000,"CWE-000 static int propagate_one ( struct mount * m ) { struct mount * child ; int type ; if ( IS_MNT_NEW ( m ) ) return 0 ; if ( ! is_subdir ( mp -> m_dentry , m -> mnt . mnt_root ) ) return 0 ; if ( peers ( m , last_dest ) ) { type = CL_MAKE_SHARED ; } else { struct mount * n , * p ; for ( n = m ; ; n = p ) { p = n -> mnt_master ; if ( p == dest_master || IS_MNT_MARKED ( p ) ) { while ( last_dest -> mnt_master != p ) { last_source = last_source -> mnt_master ; last_dest = last_source -> mnt_parent ; } if ( ! peers ( n , last_dest ) ) { last_source = last_source -> mnt_master ; last_dest = last_source -> mnt_parent ; } break ; } } type = CL_SLAVE ; if ( IS_MNT_SHARED ( m ) ) type |= CL_MAKE_SHARED ; } if ( m -> mnt_ns -> user_ns != user_ns ) type |= CL_UNPRIVILEGED ; child = copy_tree ( last_source , last_source -> mnt . mnt_root , type ) ; if ( IS_ERR ( child ) ) return PTR_ERR ( child ) ; child -> mnt . mnt_flags &= ~ MNT_LOCKED ; mnt_set_mountpoint ( m , mp , child ) ; last_dest = m ; last_source = child ; if ( m -> mnt_master != dest_master ) { read_seqlock_excl ( & mount_lock ) ; SET_MNT_MARK ( m -> mnt_master ) ; read_sequnlock_excl ( & mount_lock ) ; } hlist_add_head ( & child -> mnt_hash , list ) ; return 0 ; } "," , * p ; bool done p ) ) break ; } do { struct mount * parent = last_source -> mnt_parent ; if ( last_source == first_source ) break ; done = parent -> mnt_master == p ; if ( done && peers ( n , parent ) ) break ; last_source = last_source -> mnt_master ; } while ( ! done ) ; type = CL_SLAVE ",torvalds@linux/5ec0811d30378ae104f250bfc9b3640242d81e3f,CVE-2016-4581,https://github.com/torvalds/linux/commit/5ec0811d30378ae104f250bfc9b3640242d81e3f,2016-05-23T10:59Z 1500,CWE-200,"CWE-200 int dse_bind ( Slapi_PBlock * pb ) { ber_tag_t method ; struct berval * cred ; Slapi_Value * * bvals ; struct dse * pdse ; Slapi_Attr * attr ; Slapi_DN * sdn = NULL ; Slapi_Entry * ec = NULL ; if ( slapi_pblock_get ( pb , SLAPI_PLUGIN_PRIVATE , & pdse ) < 0 || slapi_pblock_get ( pb , SLAPI_BIND_TARGET_SDN , & sdn ) < 0 || slapi_pblock_get ( pb , SLAPI_BIND_METHOD , & method ) < 0 || slapi_pblock_get ( pb , SLAPI_BIND_CREDENTIALS , & cred ) < 0 ) { slapi_send_ldap_result ( pb , LDAP_OPERATIONS_ERROR , NULL , NULL , 0 , NULL ) ; return SLAPI_BIND_FAIL ; } if ( method == LDAP_AUTH_SIMPLE && cred -> bv_len == 0 ) { slapi_send_ldap_result ( pb , LDAP_SUCCESS , NULL , NULL , 0 , NULL ) ; return ( SLAPI_BIND_FAIL ) ; } ec = dse_get_entry_copy ( pdse , sdn , DSE_USE_LOCK ) ; if ( ec == NULL ) { slapi_send_ldap_result ( pb , LDAP_NO_SUCH_OBJECT , NULL , NULL , 0 , NULL ) ; return ( SLAPI_BIND_FAIL ) ; } switch ( method ) { case LDAP_AUTH_SIMPLE : { Slapi_Value cv ; if ( slapi_entry_attr_find ( ec , ""userpassword"" , & attr ) != 0 ) { slapi_send_ldap_result ( pb , LDAP_INAPPROPRIATE_AUTH , NULL , NULL , 0 , NULL ) ; slapi_entry_free ( ec ) ; return SLAPI_BIND_FAIL ; } bvals = attr_get_present_values ( attr ) ; slapi_value_init_berval ( & cv , cred ) ; if ( slapi_pw_find_sv ( bvals , & cv ) != 0 ) { slapi_send_ldap_result ( pb , LDAP_INVALID_CREDENTIALS , NULL , NULL , 0 , NULL ) ; slapi_entry_free ( ec ) ; value_done ( & cv ) ; return SLAPI_BIND_FAIL ; } value_done ( & cv ) ; } break ; default : slapi_send_ldap_result ( pb , LDAP_STRONG_AUTH_NOT_SUPPORTED , NULL , ""authmethodnotsupported"" , 0 , NULL ) ; slapi_entry_free ( ec ) ; return SLAPI_BIND_FAIL ; } slapi_entry_free ( ec ) ; return SLAPI_BIND_SUCCESS ; } "," NULL ) { slapi_pblock_set ( pb , SLAPI_PB_RESULT_TEXT , ""Entrydoesnotexist"" ) ; slapi_send_ldap_result ( pb , LDAP_INVALID_CREDENTIALS , NULL , 0 ) { slapi_pblock_set ( pb , SLAPI_PB_RESULT_TEXT , ""Entrydoesnothaveuserpasswordset"" ) ; slapi_send_ldap_result ( pb , LDAP_INVALID_CREDENTIALS , NULL , 0 ) { slapi_pblock_set ( pb , SLAPI_PB_RESULT_TEXT , ""Invalidcredentials"" ) ; ",389ds@389-ds-base/b6aae4d8e7c8a6ddd21646f94fef1bf7f22c3f32,CVE-2020-35518,https://github.com/389ds/389-ds-base/commit/b6aae4d8e7c8a6ddd21646f94fef1bf7f22c3f32,2021-03-26T17:15Z 1501,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 1502,CWE-119,"CWE-119 int main ( int argc , char * argv [ ] ) { opj_dinfo_t * dinfo ; opj_event_mgr_t event_mgr ; int tnum ; unsigned int snum ; opj_mj2_t * movie ; mj2_tk_t * track ; mj2_sample_t * sample ; unsigned char * frame_codestream ; FILE * file , * outfile ; char outfilename [ 50 ] ; mj2_dparameters_t parameters ; if ( argc != 3 ) { printf ( ""Usage:%smj2filenameoutput_location\\n"" , argv [ 0 ] ) ; printf ( ""Example:%sforeman.mj2output/foreman\\n"" , argv [ 0 ] ) ; return 1 ; } file = fopen ( argv [ 1 ] , ""rb"" ) ; if ( ! file ) { fprintf ( stderr , ""failedtoopen%sforreading\\n"" , argv [ 1 ] ) ; return 1 ; } memset ( & event_mgr , 0 , sizeof ( opj_event_mgr_t ) ) ; event_mgr . error_handler = error_callback ; event_mgr . warning_handler = warning_callback ; event_mgr . info_handler = info_callback ; dinfo = mj2_create_decompress ( ) ; opj_set_event_mgr ( ( opj_common_ptr ) dinfo , & event_mgr , stderr ) ; memset ( & parameters , 0 , sizeof ( mj2_dparameters_t ) ) ; movie = ( opj_mj2_t * ) dinfo -> mj2_handle ; mj2_setup_decoder ( movie , & parameters ) ; if ( mj2_read_struct ( file , movie ) ) { return 1 ; } tnum = 0 ; while ( movie -> tk [ tnum ] . track_type != 0 ) { tnum ++ ; } track = & movie -> tk [ tnum ] ; fprintf ( stdout , ""Extracting%dframesfromfile...\\n"" , track -> num_samples ) ; for ( snum = 0 ; snum < track -> num_samples ; snum ++ ) { sample = & track -> sample [ snum ] ; frame_codestream = ( unsigned char * ) malloc ( sample -> sample_size - 8 ) ; fseek ( file , sample -> offset + 8 , SEEK_SET ) ; fread ( frame_codestream , sample -> sample_size - 8 , 1 , file ) ; sprintf ( outfilename , ""%s_%05d.j2k"" , argv [ 2 ] , snum ) ; outfile = fopen ( outfilename , ""wb"" ) ; if ( ! outfile ) { fprintf ( stderr , ""failedtoopen%sforwriting\\n"" , outfilename ) ; return 1 ; } fwrite ( frame_codestream , sample -> sample_size - 8 , 1 , outfile ) ; fclose ( outfile ) ; free ( frame_codestream ) ; } fclose ( file ) ; fprintf ( stdout , ""%dframescorrectlyextracted\\n"" , snum ) ; if ( dinfo ) { mj2_destroy_decompress ( ( opj_mj2_t * ) dinfo -> mj2_handle ) ; } return 0 ; } "," file ) ; int num = snprintf ( outfilename , ( outfilename , sizeof ( outfilename ) , snum ) ; if ( num >= sizeof ( outfilename ) ) { fprintf ( stderr , ""maximumlengthofoutputprefixexceeded\\n"" ) ; return 1 ; } ",kbabioch@openjpeg/6d8c0c06ee32dc03ba80acd48334e98728e56cf5,CVE-2018-7648,https://github.com/kbabioch/openjpeg/commit/6d8c0c06ee32dc03ba80acd48334e98728e56cf5,2018-03-02T16:29Z 1503,CWE-000,"CWE-000 int propagate_mnt ( struct mount * dest_mnt , struct mountpoint * dest_mp , struct mount * source_mnt , struct hlist_head * tree_list ) { struct mount * m , * n ; int ret = 0 ; user_ns = current -> nsproxy -> mnt_ns -> user_ns ; last_dest = dest_mnt ; last_source = source_mnt ; mp = dest_mp ; list = tree_list ; dest_master = dest_mnt -> mnt_master ; for ( n = next_peer ( dest_mnt ) ; n != dest_mnt ; n = next_peer ( n ) ) { ret = propagate_one ( n ) ; if ( ret ) goto out ; } for ( m = next_group ( dest_mnt , dest_mnt ) ; m ; m = next_group ( m , dest_mnt ) ) { n = m ; do { ret = propagate_one ( n ) ; if ( ret ) goto out ; n = next_peer ( n ) ; } while ( n != m ) ; } out : read_seqlock_excl ( & mount_lock ) ; hlist_for_each_entry ( n , tree_list , mnt_hash ) { m = n -> mnt_parent ; if ( m -> mnt_master != dest_mnt -> mnt_master ) CLEAR_MNT_MARK ( m -> mnt_master ) ; } read_sequnlock_excl ( & mount_lock ) ; return ret ; } "," = dest_mnt ; first_source = source_mnt ; ",torvalds@linux/5ec0811d30378ae104f250bfc9b3640242d81e3f,CVE-2016-4581,https://github.com/torvalds/linux/commit/5ec0811d30378ae104f250bfc9b3640242d81e3f,2016-05-23T10:59Z 1504,CWE-284,"CWE-284 __be32 nfsd4_set_nfs4_acl ( struct svc_rqst * rqstp , struct svc_fh * fhp , struct nfs4_acl * acl ) { __be32 error ; int host_error ; struct dentry * dentry ; struct inode * inode ; struct posix_acl * pacl = NULL , * dpacl = NULL ; unsigned int flags = 0 ; error = fh_verify ( rqstp , fhp , 0 , NFSD_MAY_SATTR ) ; if ( error ) return error ; dentry = fhp -> fh_dentry ; inode = d_inode ( dentry ) ; if ( ! inode -> i_op -> set_acl || ! IS_POSIXACL ( inode ) ) return nfserr_attrnotsupp ; if ( S_ISDIR ( inode -> i_mode ) ) flags = NFS4_ACL_DIR ; host_error = nfs4_acl_nfsv4_to_posix ( acl , & pacl , & dpacl , flags ) ; if ( host_error == - EINVAL ) return nfserr_attrnotsupp ; if ( host_error < 0 ) goto out_nfserr ; host_error = inode -> i_op -> set_acl ( inode , pacl , ACL_TYPE_ACCESS ) ; if ( host_error < 0 ) goto out_release ; if ( S_ISDIR ( inode -> i_mode ) ) { host_error = inode -> i_op -> set_acl ( inode , dpacl , ACL_TYPE_DEFAULT ) ; } out_release : posix_acl_release ( pacl ) ; posix_acl_release ( dpacl ) ; out_nfserr : if ( host_error == - EOPNOTSUPP ) return nfserr_attrnotsupp ; else return nfserrno ( host_error ) ; } "," ; if ( S_ISDIR ( inode goto out_nfserr ; fh_lock ( fhp ) ; host_error = set_posix_acl ( inode , ACL_TYPE_ACCESS , pacl ) ; if 0 ) goto out_drop_lock ; if ( { host_error = set_posix_acl ( inode , ACL_TYPE_DEFAULT , dpacl ) ; } ) ; } out_drop_lock : fh_unlock ( fhp ) ; posix_acl_release ( pacl ",torvalds@linux/999653786df6954a31044528ac3f7a5dadca08f4,CVE-2016-1237,https://github.com/torvalds/linux/commit/999653786df6954a31044528ac3f7a5dadca08f4,2016-06-29T14:10Z 1505,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 1506,CWE-617,"CWE-617 static void pci_bus_write_dsdt ( int bus ) { struct businfo * bi ; struct slotinfo * si ; struct pci_vdev * dev ; int count , func , slot ; bi = pci_businfo [ bus ] ; if ( bi == NULL ) { if ( bus != 0 ) return ; } dsdt_line ( ""Device(PCI%01X)"" , bus ) ; dsdt_line ( ""{"" ) ; dsdt_line ( ""Name(_HID,EisaId(\\""PNP0A03\\""))"" ) ; dsdt_line ( ""Name(_ADR,Zero)"" ) ; dsdt_line ( ""Method(_BBN,0,NotSerialized)"" ) ; dsdt_line ( ""{"" ) ; dsdt_line ( ""Return(0x%08X)"" , bus ) ; dsdt_line ( ""}"" ) ; dsdt_line ( ""Name(_CRS,ResourceTemplate()"" ) ; dsdt_line ( ""{"" ) ; dsdt_line ( ""WordBusNumber(ResourceProducer,MinFixed,"" ""MaxFixed,PosDecode,"" ) ; dsdt_line ( ""0x0000,//Granularity"" ) ; dsdt_line ( ""0x%04X,//RangeMinimum"" , bus ) ; dsdt_line ( ""0x%04X,//RangeMaximum"" , bus ) ; dsdt_line ( ""0x0000,//TranslationOffset"" ) ; dsdt_line ( ""0x0001,//Length"" ) ; dsdt_line ( "",,)"" ) ; if ( bus == 0 ) { dsdt_indent ( 3 ) ; dsdt_fixed_ioport ( 0xCF8 , 8 ) ; dsdt_unindent ( 3 ) ; dsdt_line ( ""WordIO(ResourceProducer,MinFixed,MaxFixed,"" ""PosDecode,EntireRange,"" ) ; dsdt_line ( ""0x0000,//Granularity"" ) ; dsdt_line ( ""0x0000,//RangeMinimum"" ) ; dsdt_line ( ""0x0CF7,//RangeMaximum"" ) ; dsdt_line ( ""0x0000,//TranslationOffset"" ) ; dsdt_line ( ""0x0CF8,//Length"" ) ; dsdt_line ( "",,,TypeStatic)"" ) ; dsdt_line ( ""WordIO(ResourceProducer,MinFixed,MaxFixed,"" ""PosDecode,EntireRange,"" ) ; dsdt_line ( ""0x0000,//Granularity"" ) ; dsdt_line ( ""0x0D00,//RangeMinimum"" ) ; dsdt_line ( ""0x%04X,//RangeMaximum"" , PCI_EMUL_IOBASE - 1 ) ; dsdt_line ( ""0x0000,//TranslationOffset"" ) ; dsdt_line ( ""0x%04X,//Length"" , PCI_EMUL_IOBASE - 0x0D00 ) ; dsdt_line ( "",,,TypeStatic)"" ) ; if ( bi == NULL ) { dsdt_line ( ""})"" ) ; goto done ; } } assert ( bi != NULL ) ; dsdt_line ( ""WordIO(ResourceProducer,MinFixed,MaxFixed,"" ""PosDecode,EntireRange,"" ) ; dsdt_line ( ""0x0000,//Granularity"" ) ; dsdt_line ( ""0x%04X,//RangeMinimum"" , bi -> iobase ) ; dsdt_line ( ""0x%04X,//RangeMaximum"" , bi -> iolimit - 1 ) ; dsdt_line ( ""0x0000,//TranslationOffset"" ) ; dsdt_line ( ""0x%04X,//Length"" , bi -> iolimit - bi -> iobase ) ; dsdt_line ( "",,,TypeStatic)"" ) ; dsdt_line ( ""DWordMemory(ResourceProducer,PosDecode,"" ""MinFixed,MaxFixed,NonCacheable,ReadWrite,"" ) ; dsdt_line ( ""0x00000000,//Granularity"" ) ; dsdt_line ( ""0x%08X,//RangeMinimum\\n"" , bi -> membase32 ) ; dsdt_line ( ""0x%08X,//RangeMaximum\\n"" , bi -> memlimit32 - 1 ) ; dsdt_line ( ""0x00000000,//TranslationOffset"" ) ; dsdt_line ( ""0x%08X,//Length\\n"" , bi -> memlimit32 - bi -> membase32 ) ; dsdt_line ( "",,,AddressRangeMemory,TypeStatic)"" ) ; dsdt_line ( ""QWordMemory(ResourceProducer,PosDecode,"" ""MinFixed,MaxFixed,NonCacheable,ReadWrite,"" ) ; dsdt_line ( ""0x0000000000000000,//Granularity"" ) ; dsdt_line ( ""0x%016lX,//RangeMinimum\\n"" , bi -> membase64 ) ; dsdt_line ( ""0x%016lX,//RangeMaximum\\n"" , bi -> memlimit64 - 1 ) ; dsdt_line ( ""0x0000000000000000,//TranslationOffset"" ) ; dsdt_line ( ""0x%016lX,//Length\\n"" , bi -> memlimit64 - bi -> membase64 ) ; dsdt_line ( "",,,AddressRangeMemory,TypeStatic)"" ) ; dsdt_line ( ""})"" ) ; if ( ! is_rtvm ) { count = pci_count_lintr ( bus ) ; if ( count != 0 ) { dsdt_indent ( 2 ) ; dsdt_line ( ""Name(PPRT,Package()"" ) ; dsdt_line ( ""{"" ) ; pci_walk_lintr ( bus , pci_pirq_prt_entry , NULL ) ; dsdt_line ( ""})"" ) ; dsdt_line ( ""Name(APRT,Package()"" ) ; dsdt_line ( ""{"" ) ; pci_walk_lintr ( bus , pci_apic_prt_entry , NULL ) ; dsdt_line ( ""})"" ) ; dsdt_line ( ""Method(_PRT,0,NotSerialized)"" ) ; dsdt_line ( ""{"" ) ; dsdt_line ( ""If(PICM)"" ) ; dsdt_line ( ""{"" ) ; dsdt_line ( ""Return(APRT)"" ) ; dsdt_line ( ""}"" ) ; dsdt_line ( ""Else"" ) ; dsdt_line ( ""{"" ) ; dsdt_line ( ""Return(PPRT)"" ) ; dsdt_line ( ""}"" ) ; dsdt_line ( ""}"" ) ; dsdt_unindent ( 2 ) ; } } dsdt_indent ( 2 ) ; for ( slot = 0 ; slot < MAXSLOTS ; slot ++ ) { si = & bi -> slotinfo [ slot ] ; for ( func = 0 ; func < MAXFUNCS ; func ++ ) { dev = si -> si_funcs [ func ] . fi_devi ; if ( dev != NULL && dev -> dev_ops -> vdev_write_dsdt != NULL ) dev -> dev_ops -> vdev_write_dsdt ( dev ) ; } } dsdt_unindent ( 2 ) ; done : dsdt_line ( ""}"" ) ; } "," ; } } dsdt_line ( ""WordIO(ResourceProducer,MinFixed,MaxFixed,"" ",projectacrn@acrn-hypervisor/2b3dedfb9ba13f15887f22b935d373f36c9a59fa,CVE-2019-18844,https://github.com/projectacrn/acrn-hypervisor/commit/2b3dedfb9ba13f15887f22b935d373f36c9a59fa,2019-11-13T20:15Z 1507,CWE-189,"CWE-189 static int fb_mmap ( struct file * file , struct vm_area_struct * vma ) { struct fb_info * info = file_fb_info ( file ) ; struct fb_ops * fb ; unsigned long off ; unsigned long start ; u32 len ; if ( ! info ) return - ENODEV ; if ( vma -> vm_pgoff > ( ~ 0UL >> PAGE_SHIFT ) ) return - EINVAL ; off = vma -> vm_pgoff << PAGE_SHIFT ; fb = info -> fbops ; if ( ! fb ) return - ENODEV ; mutex_lock ( & info -> mm_lock ) ; if ( fb -> fb_mmap ) { int res ; res = fb -> fb_mmap ( info , vma ) ; mutex_unlock ( & info -> mm_lock ) ; return res ; } start = info -> fix . smem_start ; len = PAGE_ALIGN ( ( start & ~ PAGE_MASK ) + info -> fix . smem_len ) ; if ( off >= len ) { off -= len ; if ( info -> var . accel_flags ) { mutex_unlock ( & info -> mm_lock ) ; return - EINVAL ; } start = info -> fix . mmio_start ; len = PAGE_ALIGN ( ( start & ~ PAGE_MASK ) + info -> fix . mmio_len ) ; } mutex_unlock ( & info -> mm_lock ) ; start &= PAGE_MASK ; if ( ( vma -> vm_end - vma -> vm_start + off ) > len ) return - EINVAL ; off += start ; vma -> vm_pgoff = off >> PAGE_SHIFT ; vma -> vm_page_prot = vm_get_page_prot ( vma -> vm_flags ) ; fb_pgprotect ( file , vma , off ) ; if ( io_remap_pfn_range ( vma , vma -> vm_start , off >> PAGE_SHIFT , vma -> vm_end - vma -> vm_start , vma -> vm_page_prot ) ) return - EAGAIN ; return 0 ; } "," ; unsigned long mmio_pgoff ; unsigned long - ENODEV ; fb = info -> fbops ; if ( ! fb ) return - ENODEV ; mutex_lock ( & info -> mm_lock ) ; if ( fb -> fb_mmap ) { int res ; res = fb -> fb_mmap ( info , vma ) ; mutex_unlock ( & info -> mm_lock ) ; return res ; } start = info -> fix . smem_start ; len = info -> fix . smem_len ; mmio_pgoff = PAGE_ALIGN ( ( start & ~ PAGE_MASK ) + len ) >> PAGE_SHIFT ; if ( vma -> vm_pgoff vma -> vm_pgoff >= mmio_pgoff ) { vma -> vm_pgoff -= mmio_pgoff ; start = info -> fix . mmio_start ; len = info -> fix . mmio_len ; } mutex_unlock ( & info mm_lock ) ; vma -> vm_page_prot , vma , start ) ; return vm_iomap_memory ( vma , start , len ) ; } ",torvalds@linux/fc9bbca8f650e5f738af8806317c0a041a48ae4a,CVE-2013-2596,https://github.com/torvalds/linux/commit/fc9bbca8f650e5f738af8806317c0a041a48ae4a,2013-04-13T02:59Z 1508,CWE-200,"CWE-200 static void sg_fill_request_table ( Sg_fd * sfp , sg_req_info_t * rinfo ) { Sg_request * srp ; int val ; unsigned int ms ; val = 0 ; list_for_each_entry ( srp , & sfp -> rq_list , entry ) { if ( val > SG_MAX_QUEUE ) break ; memset ( & rinfo [ val ] , 0 , SZ_SG_REQ_INFO ) ; rinfo [ val ] . req_state = srp -> done + 1 ; rinfo [ val ] . problem = srp -> header . masked_status & srp -> header . host_status & srp -> header . driver_status ; if ( srp -> done ) rinfo [ val ] . duration = srp -> header . duration ; else { ms = jiffies_to_msecs ( jiffies ) ; rinfo [ val ] . duration = ( ms > srp -> header . duration ) ? ( ms - srp -> header . duration ) : 0 ; } rinfo [ val ] . orphan = srp -> orphan ; rinfo [ val ] . sg_io_owned = srp -> sg_io_owned ; rinfo [ val ] . pack_id = srp -> header . pack_id ; rinfo [ val ] . usr_ptr = srp -> header . usr_ptr ; val ++ ; } } "," ) break ; rinfo [ val ",torvalds@linux/3e0097499839e0fe3af380410eababe5a47c4cf9,CVE-2017-14991,https://github.com/torvalds/linux/commit/3e0097499839e0fe3af380410eababe5a47c4cf9,2017-10-04T01:29Z 1509,CWE-125,"CWE-125 int obj2ast_comprehension ( PyObject * obj , comprehension_ty * out , PyArena * arena ) { PyObject * tmp = NULL ; expr_ty target ; expr_ty iter ; asdl_seq * ifs ; int is_async ; if ( _PyObject_HasAttrId ( obj , & PyId_target ) ) { int res ; tmp = _PyObject_GetAttrId ( obj , & PyId_target ) ; if ( tmp == NULL ) goto failed ; res = obj2ast_expr ( tmp , & target , arena ) ; if ( res != 0 ) goto failed ; Py_CLEAR ( tmp ) ; } else { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""target\\""missingfromcomprehension"" ) ; return 1 ; } if ( _PyObject_HasAttrId ( obj , & PyId_iter ) ) { int res ; tmp = _PyObject_GetAttrId ( obj , & PyId_iter ) ; if ( tmp == NULL ) goto failed ; res = obj2ast_expr ( tmp , & iter , arena ) ; if ( res != 0 ) goto failed ; Py_CLEAR ( tmp ) ; } else { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""iter\\""missingfromcomprehension"" ) ; return 1 ; } if ( _PyObject_HasAttrId ( obj , & PyId_ifs ) ) { int res ; Py_ssize_t len ; Py_ssize_t i ; tmp = _PyObject_GetAttrId ( obj , & PyId_ifs ) ; if ( tmp == NULL ) goto failed ; if ( ! PyList_Check ( tmp ) ) { PyErr_Format ( PyExc_TypeError , ""comprehensionfield\\""ifs\\""mustbealist,nota%.200s"" , tmp -> ob_type -> tp_name ) ; goto failed ; } len = PyList_GET_SIZE ( tmp ) ; ifs = _Ta3_asdl_seq_new ( len , arena ) ; if ( ifs == 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 , ""comprehensionfield\\""ifs\\""changedsizeduringiteration"" ) ; goto failed ; } asdl_seq_SET ( ifs , i , value ) ; } Py_CLEAR ( tmp ) ; } else { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""ifs\\""missingfromcomprehension"" ) ; return 1 ; } if ( _PyObject_HasAttrId ( obj , & PyId_is_async ) ) { int res ; tmp = _PyObject_GetAttrId ( obj , & PyId_is_async ) ; if ( tmp == NULL ) goto failed ; res = obj2ast_int ( tmp , & is_async , arena ) ; if ( res != 0 ) goto failed ; Py_CLEAR ( tmp ) ; } else { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""is_async\\""missingfromcomprehension"" ) ; return 1 ; } * out = comprehension ( target , iter , ifs , is_async , arena ) ; return 0 ; failed : Py_XDECREF ( tmp ) ; return 1 ; } "," ; if ( lookup_attr_id ( obj , , & PyId_target , & tmp ) < 0 ) { return 1 ; } if ( tmp == NULL ) { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""target\\""missingfromcomprehension"" ) ; return 1 ; } else { int res ; res = ) ; } if ( lookup_attr_id ( obj , , & PyId_iter , & tmp ) < 0 ) { return 1 ; } if ( tmp == NULL ) { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""iter\\""missingfromcomprehension"" ) ; return 1 ; } else { int res ; res = ) ; } if ( lookup_attr_id ( obj , & PyId_ifs , & tmp ) < 0 ) { return 1 ; } if ( tmp == NULL ) { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""ifs\\""missingfromcomprehension"" ) ; return 1 ; } else { int res ; Py_ssize_t i ; if ( ) { expr_ty val ; res = ) , & val , arena ) , i , val ) ; } ) ; } if ( lookup_attr_id ( obj , , & PyId_is_async , & tmp ) < 0 ) { return 1 ; } if ( tmp == NULL ) { PyErr_SetString ( PyExc_TypeError , ""requiredfield\\""is_async\\""missingfromcomprehension"" ) ; return 1 ; } else { int res ; res = ( tmp ) ; } * ",python@typed_ast/156afcb26c198e162504a57caddfe0acd9ed7dce,CVE-2019-19275,https://github.com/python/typed_ast/commit/156afcb26c198e162504a57caddfe0acd9ed7dce,2019-11-26T15:15Z 1510,CWE-190,"CWE-190 static pngquant_error rwpng_read_image24_libpng ( FILE * infile , png24_image * mainprog_ptr , int verbose ) { png_structp png_ptr = NULL ; png_infop info_ptr = NULL ; png_size_t rowbytes ; int color_type , bit_depth ; png_ptr = png_create_read_struct ( PNG_LIBPNG_VER_STRING , mainprog_ptr , rwpng_error_handler , verbose ? rwpng_warning_stderr_handler : rwpng_warning_silent_handler ) ; if ( ! png_ptr ) { return PNG_OUT_OF_MEMORY_ERROR ; } info_ptr = png_create_info_struct ( png_ptr ) ; if ( ! info_ptr ) { png_destroy_read_struct ( & png_ptr , NULL , NULL ) ; return PNG_OUT_OF_MEMORY_ERROR ; } if ( setjmp ( mainprog_ptr -> jmpbuf ) ) { png_destroy_read_struct ( & png_ptr , & info_ptr , NULL ) ; return LIBPNG_FATAL_ERROR ; } # if defined ( PNG_SKIP_sRGB_CHECK_PROFILE ) && defined ( PNG_SET_OPTION_SUPPORTED ) png_set_option ( png_ptr , PNG_SKIP_sRGB_CHECK_PROFILE , PNG_OPTION_ON ) ; # endif # if PNG_LIBPNG_VER >= 10500 && defined ( PNG_UNKNOWN_CHUNKS_SUPPORTED ) png_set_keep_unknown_chunks ( png_ptr , PNG_HANDLE_CHUNK_IF_SAFE , ( png_const_bytep ) ""pHYs\\0iTXt\\0tEXt\\0zTXt"" , 4 ) ; # endif png_set_read_user_chunk_fn ( png_ptr , & mainprog_ptr -> chunks , read_chunk_callback ) ; struct rwpng_read_data read_data = { infile , 0 } ; png_set_read_fn ( png_ptr , & read_data , user_read_data ) ; png_read_info ( png_ptr , info_ptr ) ; png_get_IHDR ( png_ptr , info_ptr , & mainprog_ptr -> width , & mainprog_ptr -> height , & bit_depth , & color_type , NULL , NULL , NULL ) ; if ( mainprog_ptr -> width > INT_MAX / mainprog_ptr -> height ) { png_destroy_read_struct ( & png_ptr , & info_ptr , NULL ) ; return PNG_OUT_OF_MEMORY_ERROR ; } if ( ! ( color_type & PNG_COLOR_MASK_ALPHA ) ) { # ifdef PNG_READ_FILLER_SUPPORTED png_set_expand ( png_ptr ) ; png_set_filler ( png_ptr , 65535L , PNG_FILLER_AFTER ) ; # else fprintf ( stderr , ""pngquantreadpng:imageisneitherRGBAnorGA\\n"" ) ; png_destroy_read_struct ( & png_ptr , & info_ptr , NULL ) ; mainprog_ptr -> retval = WRONG_INPUT_COLOR_TYPE ; return mainprog_ptr -> retval ; # endif } if ( bit_depth == 16 ) { png_set_strip_16 ( png_ptr ) ; } if ( ! ( color_type & PNG_COLOR_MASK_COLOR ) ) { png_set_gray_to_rgb ( png_ptr ) ; } double gamma = 0.45455 ; if ( png_get_valid ( png_ptr , info_ptr , PNG_INFO_sRGB ) ) { mainprog_ptr -> input_color = RWPNG_SRGB ; mainprog_ptr -> output_color = RWPNG_SRGB ; } else { png_get_gAMA ( png_ptr , info_ptr , & gamma ) ; if ( gamma > 0 && gamma <= 1.0 ) { mainprog_ptr -> input_color = RWPNG_GAMA_ONLY ; mainprog_ptr -> output_color = RWPNG_GAMA_ONLY ; } else { fprintf ( stderr , ""pngquantreadpng:ignoredout-of-rangegamma%f\\n"" , gamma ) ; mainprog_ptr -> input_color = RWPNG_NONE ; mainprog_ptr -> output_color = RWPNG_NONE ; gamma = 0.45455 ; } } mainprog_ptr -> gamma = gamma ; png_set_interlace_handling ( png_ptr ) ; png_read_update_info ( png_ptr , info_ptr ) ; rowbytes = png_get_rowbytes ( png_ptr , info_ptr ) ; if ( ( mainprog_ptr -> rgba_data = malloc ( rowbytes * mainprog_ptr -> height ) ) == NULL ) { fprintf ( stderr , ""pngquantreadpng:unabletoallocateimagedata\\n"" ) ; png_destroy_read_struct ( & png_ptr , & info_ptr , NULL ) ; return PNG_OUT_OF_MEMORY_ERROR ; } png_bytepp row_pointers = rwpng_create_row_pointers ( info_ptr , png_ptr , mainprog_ptr -> rgba_data , mainprog_ptr -> height , 0 ) ; png_read_image ( png_ptr , row_pointers ) ; png_read_end ( png_ptr , NULL ) ; # if USE_LCMS # if PNG_LIBPNG_VER < 10500 png_charp ProfileData ; # else png_bytep ProfileData ; # endif png_uint_32 ProfileLen ; cmsHPROFILE hInProfile = NULL ; int COLOR_PNG = color_type & PNG_COLOR_MASK_COLOR ; if ( png_get_iCCP ( png_ptr , info_ptr , & ( png_charp ) { 0 } , & ( int ) { 0 } , & ProfileData , & ProfileLen ) ) { hInProfile = cmsOpenProfileFromMem ( ProfileData , ProfileLen ) ; cmsColorSpaceSignature colorspace = cmsGetColorSpace ( hInProfile ) ; if ( colorspace == cmsSigRgbData && COLOR_PNG ) { mainprog_ptr -> input_color = RWPNG_ICCP ; mainprog_ptr -> output_color = RWPNG_SRGB ; } else { if ( colorspace == cmsSigGrayData && ! COLOR_PNG ) { mainprog_ptr -> input_color = RWPNG_ICCP_WARN_GRAY ; mainprog_ptr -> output_color = RWPNG_SRGB ; } cmsCloseProfile ( hInProfile ) ; hInProfile = NULL ; } } if ( hInProfile == NULL && COLOR_PNG && ! png_get_valid ( png_ptr , info_ptr , PNG_INFO_sRGB ) && png_get_valid ( png_ptr , info_ptr , PNG_INFO_gAMA ) && png_get_valid ( png_ptr , info_ptr , PNG_INFO_cHRM ) ) { cmsCIExyY WhitePoint ; cmsCIExyYTRIPLE Primaries ; png_get_cHRM ( png_ptr , info_ptr , & WhitePoint . x , & WhitePoint . y , & Primaries . Red . x , & Primaries . Red . y , & Primaries . Green . x , & Primaries . Green . y , & Primaries . Blue . x , & Primaries . Blue . y ) ; WhitePoint . Y = Primaries . Red . Y = Primaries . Green . Y = Primaries . Blue . Y = 1.0 ; cmsToneCurve * GammaTable [ 3 ] ; GammaTable [ 0 ] = GammaTable [ 1 ] = GammaTable [ 2 ] = cmsBuildGamma ( NULL , 1 / gamma ) ; hInProfile = cmsCreateRGBProfile ( & WhitePoint , & Primaries , GammaTable ) ; cmsFreeToneCurve ( GammaTable [ 0 ] ) ; mainprog_ptr -> input_color = RWPNG_GAMA_CHRM ; mainprog_ptr -> output_color = RWPNG_SRGB ; } if ( hInProfile != NULL ) { cmsHPROFILE hOutProfile = cmsCreate_sRGBProfile ( ) ; cmsHTRANSFORM hTransform = cmsCreateTransform ( hInProfile , TYPE_RGBA_8 , hOutProfile , TYPE_RGBA_8 , INTENT_PERCEPTUAL , omp_get_max_threads ( ) > 1 ? cmsFLAGS_NOCACHE : 0 ) ; # pragma omp parallel for if ( mainprog_ptr -> height * mainprog_ptr -> width > 8000 ) schedule ( static ) for ( unsigned int i = 0 ; i < mainprog_ptr -> height ; i ++ ) { cmsDoTransform ( hTransform , row_pointers [ i ] , row_pointers [ i ] , mainprog_ptr -> width ) ; } cmsDeleteTransform ( hTransform ) ; cmsCloseProfile ( hOutProfile ) ; cmsCloseProfile ( hInProfile ) ; mainprog_ptr -> gamma = 0.45455 ; } # endif png_destroy_read_struct ( & png_ptr , & info_ptr , NULL ) ; mainprog_ptr -> file_size = read_data . bytes_read ; mainprog_ptr -> row_pointers = ( unsigned char * * ) row_pointers ; return SUCCESS ; } "," NULL ) ; if ( ! ; if ( rowbytes > INT_MAX / mainprog_ptr -> height ) { png_destroy_read_struct ( & png_ptr , & info_ptr , NULL ) ; return PNG_OUT_OF_MEMORY_ERROR ; } if ( ",pornel@pngquant/b7c217680cda02dddced245d237ebe8c383be285,CVE-2016-5735,https://github.com/pornel/pngquant/commit/b7c217680cda02dddced245d237ebe8c383be285,2017-05-23T04:29Z 1511,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 1512,CWE-125,"CWE-125 void isoclns_print ( netdissect_options * ndo , const uint8_t * p , u_int length , u_int caplen ) { if ( caplen <= 1 ) { ND_PRINT ( ( ndo , ""|OSI"" ) ) ; return ; } if ( ndo -> ndo_eflag ) ND_PRINT ( ( ndo , ""OSINLPID%s(0x%02x):"" , tok2str ( nlpid_values , ""Unknown"" , * p ) , * p ) ) ; switch ( * p ) { case NLPID_CLNP : if ( ! clnp_print ( ndo , p , length ) ) print_unknown_data ( ndo , p , ""\\n\\t"" , caplen ) ; break ; case NLPID_ESIS : esis_print ( ndo , p , length ) ; return ; case NLPID_ISIS : if ( ! isis_print ( ndo , p , length ) ) print_unknown_data ( ndo , p , ""\\n\\t"" , caplen ) ; break ; case NLPID_NULLNS : ND_PRINT ( ( ndo , ""%slength:%u"" , ndo -> ndo_eflag ? """" : "","" , length ) ) ; break ; case NLPID_Q933 : q933_print ( ndo , p + 1 , length - 1 ) ; break ; case NLPID_IP : ip_print ( ndo , p + 1 , length - 1 ) ; break ; case NLPID_IP6 : ip6_print ( ndo , p + 1 , length - 1 ) ; break ; case NLPID_PPP : ppp_print ( ndo , p + 1 , length - 1 ) ; break ; default : if ( ! ndo -> ndo_eflag ) ND_PRINT ( ( ndo , ""OSINLPID0x%02xunknown"" , * p ) ) ; ND_PRINT ( ( ndo , ""%slength:%u"" , ndo -> ndo_eflag ? """" : "","" , length ) ) ; if ( caplen > 1 ) print_unknown_data ( ndo , p , ""\\n\\t"" , caplen ) ; break ; } } "," , u_int length ) { if { if ( ! ND_TTEST ( * p ) ) { ND_PRINT , ""\\n\\t"" , length ) ; break , ""\\n\\t"" , length ) ; break ; if ( length > 1 ) , ""\\n\\t"" , length ) ; break ",the-tcpdump-group@tcpdump/1dcd10aceabbc03bf571ea32b892c522cbe923de,CVE-2017-12897,https://github.com/the-tcpdump-group/tcpdump/commit/1dcd10aceabbc03bf571ea32b892c522cbe923de,2017-09-14T06:29Z 1513,CWE-125,"CWE-125 static int xid_map_enter ( netdissect_options * ndo , const struct sunrpc_msg * rp , const u_char * bp ) { const struct ip * ip = NULL ; const struct ip6_hdr * ip6 = NULL ; struct xid_map_entry * xmep ; if ( ! ND_TTEST ( rp -> rm_call . cb_vers ) ) return ( 0 ) ; switch ( IP_V ( ( const struct ip * ) bp ) ) { case 4 : ip = ( const struct ip * ) bp ; break ; case 6 : ip6 = ( const struct ip6_hdr * ) bp ; break ; default : return ( 1 ) ; } xmep = & xid_map [ xid_map_next ] ; if ( ++ xid_map_next >= XIDMAPSIZE ) xid_map_next = 0 ; UNALIGNED_MEMCPY ( & xmep -> xid , & rp -> rm_xid , sizeof ( xmep -> xid ) ) ; if ( ip ) { xmep -> ipver = 4 ; UNALIGNED_MEMCPY ( & xmep -> client , & ip -> ip_src , sizeof ( ip -> ip_src ) ) ; UNALIGNED_MEMCPY ( & xmep -> server , & ip -> ip_dst , sizeof ( ip -> ip_dst ) ) ; } else if ( ip6 ) { xmep -> ipver = 6 ; UNALIGNED_MEMCPY ( & xmep -> client , & ip6 -> ip6_src , sizeof ( ip6 -> ip6_src ) ) ; UNALIGNED_MEMCPY ( & xmep -> server , & ip6 -> ip6_dst , sizeof ( ip6 -> ip6_dst ) ) ; } xmep -> proc = EXTRACT_32BITS ( & rp -> rm_call . cb_proc ) ; xmep -> vers = EXTRACT_32BITS ( & rp -> rm_call . cb_vers ) ; return ( 1 ) ; } "," ) ; } if ( ! ND_TTEST ( rp -> rm_call . cb_proc ) ) return ( 0 ) ; rm_call . cb_proc ) ; if ( ! ND_TTEST ( rp -> rm_call . cb_vers ) ) return ( 0 ",the-tcpdump-group@tcpdump/b45a9a167ca6a3ef2752ae9d48d56ac14b001bfd,CVE-2017-13005,https://github.com/the-tcpdump-group/tcpdump/commit/b45a9a167ca6a3ef2752ae9d48d56ac14b001bfd,2017-09-14T06:29Z 1514,CWE-125,"CWE-125 int ip6_fragment ( struct net * net , struct sock * sk , struct sk_buff * skb , int ( * output ) ( struct net * , struct sock * , struct sk_buff * ) ) { struct sk_buff * frag ; struct rt6_info * rt = ( struct rt6_info * ) skb_dst ( skb ) ; struct ipv6_pinfo * np = skb -> sk && ! dev_recursion_level ( ) ? inet6_sk ( skb -> sk ) : NULL ; struct ipv6hdr * tmp_hdr ; struct frag_hdr * fh ; unsigned int mtu , hlen , left , len ; int hroom , troom ; __be32 frag_id ; int ptr , offset = 0 , err = 0 ; u8 * prevhdr , nexthdr = 0 ; hlen = ip6_find_1stfragopt ( skb , & prevhdr ) ; nexthdr = * prevhdr ; mtu = ip6_skb_dst_mtu ( skb ) ; if ( unlikely ( ! skb -> ignore_df && skb -> len > mtu ) ) goto fail_toobig ; if ( IP6CB ( skb ) -> frag_max_size ) { if ( IP6CB ( skb ) -> frag_max_size > mtu ) goto fail_toobig ; mtu = IP6CB ( skb ) -> frag_max_size ; if ( mtu < IPV6_MIN_MTU ) mtu = IPV6_MIN_MTU ; } if ( np && np -> frag_size < mtu ) { if ( np -> frag_size ) mtu = np -> frag_size ; } if ( mtu < hlen + sizeof ( struct frag_hdr ) + 8 ) goto fail_toobig ; mtu -= hlen + sizeof ( struct frag_hdr ) ; frag_id = ipv6_select_ident ( net , & ipv6_hdr ( skb ) -> daddr , & ipv6_hdr ( skb ) -> saddr ) ; if ( skb -> ip_summed == CHECKSUM_PARTIAL && ( err = skb_checksum_help ( skb ) ) ) goto fail ; hroom = LL_RESERVED_SPACE ( rt -> dst . dev ) ; if ( skb_has_frag_list ( skb ) ) { unsigned int first_len = skb_pagelen ( skb ) ; struct sk_buff * frag2 ; if ( first_len - hlen > mtu || ( ( first_len - hlen ) & 7 ) || skb_cloned ( skb ) || skb_headroom ( skb ) < ( hroom + sizeof ( struct frag_hdr ) ) ) goto slow_path ; skb_walk_frags ( skb , frag ) { if ( frag -> len > mtu || ( ( frag -> len & 7 ) && frag -> next ) || skb_headroom ( frag ) < ( hlen + hroom + sizeof ( struct frag_hdr ) ) ) 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 ; * 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 ) ; err = - ENOMEM ; goto fail ; } frag = skb_shinfo ( skb ) -> frag_list ; skb_frag_list_init ( skb ) ; __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 ) ; fh -> nexthdr = nexthdr ; fh -> reserved = 0 ; fh -> frag_off = htons ( IP6_MF ) ; fh -> identification = frag_id ; 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 ) 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 ( net , sk , 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 ) ; ip6_rt_put ( rt ) ; return 0 ; } kfree_skb_list ( frag ) ; IP6_INC_STATS ( net , ip6_dst_idev ( & rt -> dst ) , IPSTATS_MIB_FRAGFAILS ) ; ip6_rt_put ( rt ) ; 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 ; troom = rt -> dst . dev -> needed_tailroom ; while ( left > 0 ) { u8 * fragnexthdr_offset ; len = left ; if ( len > mtu ) len = mtu ; if ( len < left ) { len &= ~ 7 ; } frag = alloc_skb ( len + hlen + sizeof ( struct frag_hdr ) + hroom + troom , GFP_ATOMIC ) ; if ( ! frag ) { 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 , hroom ) ; 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 ) ; fragnexthdr_offset = skb_network_header ( frag ) ; fragnexthdr_offset += prevhdr - skb_network_header ( skb ) ; * fragnexthdr_offset = NEXTHDR_FRAGMENT ; fh -> nexthdr = nexthdr ; fh -> reserved = 0 ; fh -> identification = frag_id ; BUG_ON ( skb_copy_bits ( skb , ptr , skb_transport_header ( frag ) , len ) ) ; 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 ( net , sk , 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 ) ; consume_skb ( skb ) ; return err ; fail_toobig : if ( skb -> sk && dst_allfrag ( skb_dst ( skb ) ) ) sk_nocaps_add ( skb -> sk , NETIF_F_GSO_MASK ) ; skb -> dev = skb_dst ( skb ) -> dev ; icmpv6_send ( skb , ICMPV6_PKT_TOOBIG , 0 , mtu ) ; err = - EMSGSIZE ; fail : IP6_INC_STATS ( net , ip6_dst_idev ( skb_dst ( skb ) ) , IPSTATS_MIB_FRAGFAILS ) ; kfree_skb ( skb ) ; return err ; } "," prevhdr ) ; if ( hlen < 0 ) { err = hlen ; goto fail ; } ",torvalds@linux/2423496af35d94a87156b063ea5cedffc10a70a1,CVE-2017-9074,https://github.com/torvalds/linux/commit/2423496af35d94a87156b063ea5cedffc10a70a1,2017-05-19T07:29Z 1515,CWE-264,"CWE-264 static bool blk_kick_flush ( struct request_queue * q , struct blk_flush_queue * fq ) { struct list_head * pending = & fq -> flush_queue [ fq -> flush_pending_idx ] ; struct request * first_rq = list_first_entry ( pending , struct request , flush . list ) ; struct request * flush_rq = fq -> flush_rq ; if ( fq -> flush_pending_idx != fq -> flush_running_idx || list_empty ( pending ) ) return false ; if ( ! list_empty ( & fq -> flush_data_in_flight ) && time_before ( jiffies , fq -> flush_pending_since + FLUSH_PENDING_TIMEOUT ) ) return false ; fq -> flush_pending_idx ^= 1 ; blk_rq_init ( q , flush_rq ) ; if ( q -> mq_ops ) { flush_rq -> mq_ctx = first_rq -> mq_ctx ; flush_rq -> tag = first_rq -> tag ; } flush_rq -> cmd_type = REQ_TYPE_FS ; flush_rq -> cmd_flags = WRITE_FLUSH | REQ_FLUSH_SEQ ; flush_rq -> rq_disk = first_rq -> rq_disk ; flush_rq -> end_io = flush_end_io ; return blk_flush_queue_rq ( flush_rq , false ) ; } "," mq_ops ) { struct blk_mq_hw_ctx * hctx ; first_rq -> tag ; fq -> orig_rq = first_rq ; hctx = q -> mq_ops -> map_queue ( q , first_rq -> mq_ctx -> cpu ) ; blk_mq_tag_set_rq ( hctx , first_rq -> tag , flush_rq ) ",torvalds@linux/0048b4837affd153897ed1222283492070027aa9,CVE-2015-9016,https://github.com/torvalds/linux/commit/0048b4837affd153897ed1222283492070027aa9,2018-04-05T18:29Z 1516,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 1517,CWE-190,"CWE-190 SYSCALL_DEFINE1 ( timer_getoverrun , timer_t , timer_id ) { struct k_itimer * timr ; int overrun ; unsigned long flags ; timr = lock_timer ( timer_id , & flags ) ; if ( ! timr ) return - EINVAL ; overrun = timr -> it_overrun_last ; unlock_timer ( timr , flags ) ; return overrun ; } "," ; overrun = timer_overrun_to_int ( timr , 0 ) ; unlock_timer ( ",torvalds@linux/78c9c4dfbf8c04883941445a195276bb4bb92c76,CVE-2018-12896,https://github.com/torvalds/linux/commit/78c9c4dfbf8c04883941445a195276bb4bb92c76,2018-07-02T17:29Z 1518,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 1519,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 1520,CWE-190,"CWE-190 static int choose_volume ( struct archive_read * a , struct iso9660 * iso9660 ) { struct file_info * file ; int64_t skipsize ; struct vd * vd ; const void * block ; char seenJoliet ; vd = & ( iso9660 -> primary ) ; if ( ! iso9660 -> opt_support_joliet ) iso9660 -> seenJoliet = 0 ; if ( iso9660 -> seenJoliet && vd -> location > iso9660 -> joliet . location ) vd = & ( iso9660 -> joliet ) ; skipsize = LOGICAL_BLOCK_SIZE * vd -> location ; skipsize = __archive_read_consume ( a , skipsize ) ; if ( skipsize < 0 ) return ( ( int ) skipsize ) ; iso9660 -> current_position = skipsize ; block = __archive_read_ahead ( a , vd -> size , NULL ) ; if ( block == NULL ) { archive_set_error ( & a -> archive , ARCHIVE_ERRNO_MISC , ""Failedtoreadfullblockwhenscanning"" ""ISO9660directorylist"" ) ; return ( ARCHIVE_FATAL ) ; } seenJoliet = iso9660 -> seenJoliet ; iso9660 -> seenJoliet = 0 ; file = parse_file_info ( a , NULL , block ) ; if ( file == NULL ) return ( ARCHIVE_FATAL ) ; iso9660 -> seenJoliet = seenJoliet ; if ( vd == & ( iso9660 -> primary ) && iso9660 -> seenRockridge && iso9660 -> seenJoliet ) iso9660 -> seenJoliet = 0 ; if ( vd == & ( iso9660 -> primary ) && ! iso9660 -> seenRockridge && iso9660 -> seenJoliet ) { vd = & ( iso9660 -> joliet ) ; skipsize = LOGICAL_BLOCK_SIZE * vd -> location ; skipsize -= iso9660 -> current_position ; skipsize = __archive_read_consume ( a , skipsize ) ; if ( skipsize < 0 ) return ( ( int ) skipsize ) ; iso9660 -> current_position += skipsize ; block = __archive_read_ahead ( a , vd -> size , NULL ) ; if ( block == NULL ) { archive_set_error ( & a -> archive , ARCHIVE_ERRNO_MISC , ""Failedtoreadfullblockwhenscanning"" ""ISO9660directorylist"" ) ; return ( ARCHIVE_FATAL ) ; } iso9660 -> seenJoliet = 0 ; file = parse_file_info ( a , NULL , block ) ; if ( file == NULL ) return ( ARCHIVE_FATAL ) ; iso9660 -> seenJoliet = seenJoliet ; } if ( add_entry ( a , iso9660 , file ) != ARCHIVE_OK ) return ( ARCHIVE_FATAL ) ; if ( iso9660 -> seenRockridge ) { a -> archive . archive_format = ARCHIVE_FORMAT_ISO9660_ROCKRIDGE ; a -> archive . archive_format_name = ""ISO9660withRockridgeextensions"" ; } return ( ARCHIVE_OK ) ; } "," = LOGICAL_BLOCK_SIZE * ( int64_t ) = LOGICAL_BLOCK_SIZE * ( int64_t ) ",libarchive@libarchive/3ad08e01b4d253c66ae56414886089684155af22,CVE-2016-5844,https://github.com/libarchive/libarchive/commit/3ad08e01b4d253c66ae56414886089684155af22,2016-09-21T14:25Z 1521,CWE-119,"CWE-119 static void single_motion_search ( VP9_COMP * cpi , MACROBLOCK * x , const TileInfo * const tile , BLOCK_SIZE bsize , int mi_row , int mi_col , int_mv * tmp_mv , int * rate_mv ) { MACROBLOCKD * xd = & x -> e_mbd ; VP9_COMMON * cm = & cpi -> common ; MB_MODE_INFO * mbmi = & xd -> mi [ 0 ] -> mbmi ; struct buf_2d backup_yv12 [ MAX_MB_PLANE ] = { { 0 } } ; int bestsme = INT_MAX ; int further_steps , step_param ; int sadpb = x -> sadperbit16 ; MV mvp_full ; int ref = mbmi -> ref_frame [ 0 ] ; MV ref_mv = mbmi -> ref_mvs [ ref ] [ 0 ] . as_mv ; 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 ; const YV12_BUFFER_CONFIG * scaled_ref_frame = vp9_get_scaled_ref_frame ( cpi , ref ) ; MV pred_mv [ 3 ] ; pred_mv [ 0 ] = mbmi -> ref_mvs [ ref ] [ 0 ] . as_mv ; pred_mv [ 1 ] = mbmi -> ref_mvs [ ref ] [ 1 ] . as_mv ; pred_mv [ 2 ] = x -> pred_mv [ ref ] . as_mv ; if ( scaled_ref_frame ) { int i ; for ( i = 0 ; i < MAX_MB_PLANE ; i ++ ) backup_yv12 [ i ] = xd -> plane [ i ] . pre [ 0 ] ; vp9_setup_pre_planes ( xd , 0 , scaled_ref_frame , mi_row , mi_col , NULL ) ; } vp9_set_mv_search_range ( x , & ref_mv ) ; if ( cpi -> sf . auto_mv_step_size && cpi -> common . show_frame ) { step_param = ( vp9_init_search_range ( cpi , x -> max_mv_context [ ref ] ) + cpi -> mv_step_param ) >> 1 ; } else { step_param = cpi -> mv_step_param ; } if ( cpi -> sf . adaptive_motion_search && bsize < BLOCK_64X64 && cpi -> common . show_frame ) { int boffset = 2 * ( b_width_log2 ( BLOCK_64X64 ) - MIN ( b_height_log2 ( bsize ) , b_width_log2 ( bsize ) ) ) ; step_param = MAX ( step_param , boffset ) ; } if ( cpi -> sf . adaptive_motion_search ) { int bwl = b_width_log2_lookup [ bsize ] ; int bhl = b_height_log2_lookup [ bsize ] ; int i ; int tlevel = x -> pred_mv_sad [ ref ] >> ( bwl + bhl + 4 ) ; if ( tlevel < 5 ) step_param += 2 ; for ( i = LAST_FRAME ; i <= ALTREF_FRAME && cpi -> common . show_frame ; ++ i ) { if ( ( x -> pred_mv_sad [ ref ] >> 3 ) > x -> pred_mv_sad [ i ] ) { x -> pred_mv [ ref ] . as_int = 0 ; tmp_mv -> as_int = INVALID_MV ; if ( scaled_ref_frame ) { int i ; for ( i = 0 ; i < MAX_MB_PLANE ; i ++ ) xd -> plane [ i ] . pre [ 0 ] = backup_yv12 [ i ] ; } return ; } } } mvp_full = pred_mv [ x -> mv_best_ref_index [ ref ] ] ; mvp_full . col >>= 3 ; mvp_full . row >>= 3 ; further_steps = ( cpi -> sf . max_step_search_steps - 1 ) - step_param ; if ( cpi -> sf . search_method == FAST_DIAMOND ) { bestsme = vp9_fast_dia_search ( x , & mvp_full , step_param , sadpb , 0 , & cpi -> fn_ptr [ bsize ] , 1 , & ref_mv , & tmp_mv -> as_mv ) ; if ( bestsme < INT_MAX ) bestsme = vp9_get_mvpred_var ( x , & tmp_mv -> as_mv , & ref_mv , & cpi -> fn_ptr [ bsize ] , 1 ) ; } else if ( cpi -> sf . search_method == FAST_HEX ) { bestsme = vp9_fast_hex_search ( x , & mvp_full , step_param , sadpb , 0 , & cpi -> fn_ptr [ bsize ] , 1 , & ref_mv , & tmp_mv -> as_mv ) ; if ( bestsme < INT_MAX ) bestsme = vp9_get_mvpred_var ( x , & tmp_mv -> as_mv , & ref_mv , & cpi -> fn_ptr [ bsize ] , 1 ) ; } else if ( cpi -> sf . search_method == HEX ) { bestsme = vp9_hex_search ( x , & mvp_full , step_param , sadpb , 1 , & cpi -> fn_ptr [ bsize ] , 1 , & ref_mv , & tmp_mv -> as_mv ) ; if ( bestsme < INT_MAX ) bestsme = vp9_get_mvpred_var ( x , & tmp_mv -> as_mv , & ref_mv , & cpi -> fn_ptr [ bsize ] , 1 ) ; } else if ( cpi -> sf . search_method == SQUARE ) { bestsme = vp9_square_search ( x , & mvp_full , step_param , sadpb , 1 , & cpi -> fn_ptr [ bsize ] , 1 , & ref_mv , & tmp_mv -> as_mv ) ; if ( bestsme < INT_MAX ) bestsme = vp9_get_mvpred_var ( x , & tmp_mv -> as_mv , & ref_mv , & cpi -> fn_ptr [ bsize ] , 1 ) ; } else if ( cpi -> sf . search_method == BIGDIA ) { bestsme = vp9_bigdia_search ( x , & mvp_full , step_param , sadpb , 1 , & cpi -> fn_ptr [ bsize ] , 1 , & ref_mv , & tmp_mv -> as_mv ) ; if ( bestsme < INT_MAX ) bestsme = vp9_get_mvpred_var ( x , & tmp_mv -> as_mv , & ref_mv , & cpi -> fn_ptr [ bsize ] , 1 ) ; } else { bestsme = vp9_full_pixel_diamond ( cpi , x , & mvp_full , step_param , sadpb , further_steps , 1 , & cpi -> fn_ptr [ bsize ] , & ref_mv , & tmp_mv -> as_mv ) ; } 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 ; cpi -> find_fractional_mv_step ( x , & tmp_mv -> as_mv , & ref_mv , cm -> allow_high_precision_mv , x -> errorperbit , & cpi -> fn_ptr [ bsize ] , cpi -> sf . subpel_force_stop , cpi -> sf . subpel_iters_per_step , x -> nmvjointcost , x -> mvcost , & dis , & x -> pred_sse [ ref ] ) ; } * rate_mv = vp9_mv_bit_cost ( & tmp_mv -> as_mv , & ref_mv , x -> nmvjointcost , x -> mvcost , MV_COST_WEIGHT ) ; if ( cpi -> sf . adaptive_motion_search && cpi -> common . show_frame ) x -> pred_mv [ ref ] . as_int = tmp_mv -> as_int ; if ( scaled_ref_frame ) { int i ; for ( i = 0 ; i < MAX_MB_PLANE ; i ++ ) xd -> plane [ i ] . pre [ 0 ] = backup_yv12 [ i ] ; } } "," * x , BLOCK_SIZE bsize , -> e_mbd ; const { { 0 , 0 INT_MAX ; int step_param ; int MV ref_mv = x -> mbmi_ext -> ref_mvs [ x -> mv_row_max ; int cost_list [ 5 ] 0 ] = x -> mbmi_ext -> ref_mvs [ 1 ] = x -> mbmi_ext -> ref_mvs [ [ ref ] ; if ( -> sf . mv . auto_mv_step_size && cm -> show_frame ) { ( vp9_init_search_range ( x -> max_mv_context -> mv_step_param ) / 2 ; } else bsize < BLOCK_64X64 ) { int 2 * ( b_width_log2_lookup [ BLOCK_64X64 ] - MIN ( - MIN ( b_height_log2_lookup [ bsize ] , b_width_log2_lookup [ bsize ] ) ) ; [ bsize ] ; int tlevel += 2 ; if ( cpi -> oxcf . resize_mode != RESIZE_DYNAMIC ) { int i ; <= ALTREF_FRAME && cm -> show_frame ; ++ ref ] . row = 0 ; x -> pred_mv [ ref ] . col = 0 ; < MAX_MB_PLANE ; ++ i ) xd -> } return ; } >>= 3 ; bestsme = vp9_full_pixel_search ( cpi , x , bsize , & mvp_full , step_param , sadpb , cond_cost_list ( cpi , cost_list ) , & ref_mv , & tmp_mv -> as_mv , INT_MAX , 1 ) ; 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 ( < INT_MAX ) { int dis ; cpi -> find_fractional_mv_step ( x , & ref_mv , cm -> allow_high_precision_mv , x -> errorperbit , bsize ] , cpi -> sf -> sf . mv . subpel_force_stop , cpi -> sf -> sf . mv . subpel_iters_per_step , cond_cost_list ( cpi , cost_list ) , x -> nmvjointcost , x -> mvcost , & dis , & x [ ref ] , NULL , 0 , 0 sf . adaptive_motion_search ) x -> [ ref ] = tmp_mv -> = tmp_mv -> as_mv ; if ( ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1522,CWE-125,"CWE-125 static INT AirPDcapDecryptWPABroadcastKey ( const EAPOL_RSN_KEY * pEAPKey , guint8 * decryption_key , PAIRPDCAP_SEC_ASSOCIATION sa , guint eapol_len ) { guint8 key_version ; guint8 * key_data ; guint8 * szEncryptedKey ; guint16 key_bytes_len = 0 ; guint16 key_len ; static AIRPDCAP_KEY_ITEM dummy_key ; AIRPDCAP_SEC_ASSOCIATION * tmp_sa ; key_version = AIRPDCAP_EAP_KEY_DESCR_VER ( pEAPKey -> key_information [ 1 ] ) ; if ( key_version == AIRPDCAP_WPA_KEY_VER_NOT_CCMP ) { key_bytes_len = pntoh16 ( pEAPKey -> key_length ) ; } else if ( key_version == AIRPDCAP_WPA_KEY_VER_AES_CCMP ) { key_bytes_len = pntoh16 ( pEAPKey -> key_data_len ) ; if ( key_bytes_len < 16 ) { return AIRPDCAP_RET_NO_VALID_HANDSHAKE ; } } if ( key_bytes_len < GROUP_KEY_MIN_LEN || key_bytes_len > eapol_len - sizeof ( EAPOL_RSN_KEY ) ) { return AIRPDCAP_RET_NO_VALID_HANDSHAKE ; } key_data = ( guint8 * ) pEAPKey + sizeof ( EAPOL_RSN_KEY ) ; szEncryptedKey = ( guint8 * ) g_memdup ( key_data , key_bytes_len ) ; DEBUG_DUMP ( ""EncryptedBroadcastkey:"" , szEncryptedKey , key_bytes_len ) ; DEBUG_DUMP ( ""KeyIV:"" , pEAPKey -> key_iv , 16 ) ; DEBUG_DUMP ( ""decryption_key:"" , decryption_key , 16 ) ; tmp_sa = ( AIRPDCAP_SEC_ASSOCIATION * ) g_malloc ( sizeof ( AIRPDCAP_SEC_ASSOCIATION ) ) ; memcpy ( tmp_sa , sa , sizeof ( AIRPDCAP_SEC_ASSOCIATION ) ) ; sa -> next = tmp_sa ; if ( key_version == AIRPDCAP_WPA_KEY_VER_NOT_CCMP ) { guint8 new_key [ 32 ] ; guint8 dummy [ 256 ] ; rc4_state_struct rc4_state ; sa -> wpa . key_ver = ( key_bytes_len >= TKIP_GROUP_KEY_LEN ) ? AIRPDCAP_WPA_KEY_VER_NOT_CCMP : AIRPDCAP_WPA_KEY_VER_AES_CCMP ; memcpy ( new_key , pEAPKey -> key_iv , 16 ) ; memcpy ( new_key + 16 , decryption_key , 16 ) ; DEBUG_DUMP ( ""FullDecrKey:"" , new_key , 32 ) ; crypt_rc4_init ( & rc4_state , new_key , sizeof ( new_key ) ) ; crypt_rc4 ( & rc4_state , dummy , 256 ) ; crypt_rc4 ( & rc4_state , szEncryptedKey , key_bytes_len ) ; } else if ( key_version == AIRPDCAP_WPA_KEY_VER_AES_CCMP ) { guint8 key_found ; guint8 key_length ; guint16 key_index ; guint8 * decrypted_data ; decrypted_data = AES_unwrap ( decryption_key , 16 , szEncryptedKey , key_bytes_len ) ; key_found = FALSE ; key_index = 0 ; while ( key_index < ( key_bytes_len - 6 ) && ! key_found ) { guint8 rsn_id ; guint32 type ; rsn_id = decrypted_data [ key_index ] ; type = ( ( decrypted_data [ key_index + 2 ] << 24 ) + ( decrypted_data [ key_index + 3 ] << 16 ) + ( decrypted_data [ key_index + 4 ] << 8 ) + ( decrypted_data [ key_index + 5 ] ) ) ; if ( rsn_id == 0xdd && type == 0x000fac01 ) { key_found = TRUE ; } else { key_index += decrypted_data [ key_index + 1 ] + 2 ; } } if ( key_found ) { key_length = decrypted_data [ key_index + 1 ] - 6 ; if ( key_index + 8 >= key_bytes_len || key_length > key_bytes_len - key_index - 8 ) { g_free ( decrypted_data ) ; g_free ( szEncryptedKey ) ; return AIRPDCAP_RET_NO_VALID_HANDSHAKE ; } memcpy ( szEncryptedKey , decrypted_data + key_index + 8 , key_length ) ; } else { g_free ( decrypted_data ) ; g_free ( szEncryptedKey ) ; return AIRPDCAP_RET_NO_VALID_HANDSHAKE ; } if ( key_length == TKIP_GROUP_KEY_LEN ) sa -> wpa . key_ver = AIRPDCAP_WPA_KEY_VER_NOT_CCMP ; else sa -> wpa . key_ver = AIRPDCAP_WPA_KEY_VER_AES_CCMP ; g_free ( decrypted_data ) ; } key_len = ( sa -> wpa . key_ver == AIRPDCAP_WPA_KEY_VER_NOT_CCMP ) ? TKIP_GROUP_KEY_LEN : CCMP_GROUP_KEY_LEN ; if ( key_len > key_bytes_len ) { g_free ( szEncryptedKey ) ; return AIRPDCAP_RET_NO_VALID_HANDSHAKE ; } DEBUG_DUMP ( ""Broadcastkey:"" , szEncryptedKey , key_len ) ; sa -> key = & dummy_key ; sa -> validKey = TRUE ; memset ( sa -> wpa . ptk , 0 , sizeof ( sa -> wpa . ptk ) ) ; memcpy ( sa -> wpa . ptk + 32 , szEncryptedKey , key_len ) ; g_free ( szEncryptedKey ) ; return AIRPDCAP_RET_SUCCESS_HANDSHAKE ; } "," } if ( ( key_bytes_len < GROUP_KEY_MIN_LEN ) || ( eapol_len < sizeof ( EAPOL_RSN_KEY ) ) || ( key_bytes_len > eapol_len sizeof ( EAPOL_RSN_KEY ) ",wireshark@wireshark/b6d838eebf4456192360654092e5587c5207f185,CVE-2016-5352,https://github.com/wireshark/wireshark/commit/b6d838eebf4456192360654092e5587c5207f185,2016-08-07T16:59Z 1523,CWE-310,"CWE-310 static int crypto_report_one ( struct crypto_alg * alg , struct crypto_user_alg * ualg , struct sk_buff * skb ) { memcpy ( & ualg -> cru_name , & alg -> cra_name , sizeof ( ualg -> cru_name ) ) ; memcpy ( & ualg -> cru_driver_name , & alg -> cra_driver_name , sizeof ( ualg -> cru_driver_name ) ) ; memcpy ( & ualg -> cru_module_name , module_name ( alg -> cra_module ) , CRYPTO_MAX_ALG_NAME ) ; ualg -> cru_flags = alg -> cra_flags ; ualg -> cru_refcnt = atomic_read ( & alg -> cra_refcnt ) ; if ( nla_put_u32 ( skb , CRYPTOCFGA_PRIORITY_VAL , alg -> cra_priority ) ) goto nla_put_failure ; if ( alg -> cra_flags & CRYPTO_ALG_LARVAL ) { struct crypto_report_larval rl ; snprintf ( rl . type , CRYPTO_MAX_ALG_NAME , ""%s"" , ""larval"" ) ; if ( nla_put ( skb , CRYPTOCFGA_REPORT_LARVAL , sizeof ( struct crypto_report_larval ) , & rl ) ) goto nla_put_failure ; goto out ; } if ( alg -> cra_type && alg -> cra_type -> report ) { if ( alg -> cra_type -> report ( skb , alg ) ) goto nla_put_failure ; goto out ; } switch ( alg -> cra_flags & ( CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_LARVAL ) ) { case CRYPTO_ALG_TYPE_CIPHER : if ( crypto_report_cipher ( skb , alg ) ) goto nla_put_failure ; break ; case CRYPTO_ALG_TYPE_COMPRESS : if ( crypto_report_comp ( skb , alg ) ) goto nla_put_failure ; break ; } out : return 0 ; nla_put_failure : return - EMSGSIZE ; } "," skb ) { strncpy ( ualg -> cru_name -> cru_name , alg -> cra_name ) ) ; strncpy ( ualg -> cru_driver_name -> cru_driver_name , alg -> cra_driver_name ) ) ; strncpy ( ualg -> cru_module_name cra_module ) , sizeof ( ualg -> cru_module_name ) ) ; ualg -> cru_type = 0 ; ualg -> cru_mask = 0 ; ualg -> crypto_report_larval rl ; strncpy ( rl . . type , ""larval"" , sizeof ( rl . type ) ) ; if ",torvalds@linux/9a5467bf7b6e9e02ec9c3da4e23747c05faeaac6,CVE-2013-2548,https://github.com/torvalds/linux/commit/9a5467bf7b6e9e02ec9c3da4e23747c05faeaac6,2013-03-15T20:55Z 1524,CWE-119,"CWE-119 int lzxd_decompress ( struct lzxd_stream * lzx , off_t out_bytes ) { register unsigned int bit_buffer ; register int bits_left , i = 0 ; unsigned char * i_ptr , * i_end ; register unsigned short sym ; int match_length , length_footer , extra , verbatim_bits , bytes_todo ; int this_run , main_element , aligned_bits , j ; unsigned char * window , * runsrc , * rundest , buf [ 12 ] ; unsigned int frame_size = 0 , end_frame , match_offset , window_posn ; unsigned int R0 , R1 , R2 ; if ( ! lzx || ( out_bytes < 0 ) ) return MSPACK_ERR_ARGS ; if ( lzx -> error ) return lzx -> error ; i = lzx -> o_end - lzx -> o_ptr ; if ( ( off_t ) i > out_bytes ) i = ( int ) out_bytes ; if ( i ) { if ( lzx -> sys -> write ( lzx -> output , lzx -> o_ptr , i ) != i ) { return lzx -> error = MSPACK_ERR_WRITE ; } lzx -> o_ptr += i ; lzx -> offset += i ; out_bytes -= i ; } if ( out_bytes == 0 ) return MSPACK_ERR_OK ; RESTORE_BITS ; window = lzx -> window ; window_posn = lzx -> window_posn ; R0 = lzx -> R0 ; R1 = lzx -> R1 ; R2 = lzx -> R2 ; end_frame = ( unsigned int ) ( ( lzx -> offset + out_bytes ) / LZX_FRAME_SIZE ) + 1 ; while ( lzx -> frame < end_frame ) { if ( lzx -> reset_interval && ( ( lzx -> frame % lzx -> reset_interval ) == 0 ) ) { if ( lzx -> block_remaining ) { D ( ( ""%dbytesremainingatresetinterval"" , lzx -> block_remaining ) ) return lzx -> error = MSPACK_ERR_DECRUNCH ; } lzxd_reset_state ( lzx ) ; R0 = lzx -> R0 ; R1 = lzx -> R1 ; R2 = lzx -> R2 ; } if ( lzx -> is_delta ) { ENSURE_BITS ( 16 ) ; REMOVE_BITS ( 16 ) ; } if ( ! lzx -> header_read ) { j = 0 ; READ_BITS ( i , 1 ) ; if ( i ) { READ_BITS ( i , 16 ) ; READ_BITS ( j , 16 ) ; } lzx -> intel_filesize = ( i << 16 ) | j ; lzx -> header_read = 1 ; } frame_size = LZX_FRAME_SIZE ; if ( lzx -> length && ( lzx -> length - lzx -> offset ) < ( off_t ) frame_size ) { frame_size = lzx -> length - lzx -> offset ; } bytes_todo = lzx -> frame_posn + frame_size - window_posn ; while ( bytes_todo > 0 ) { if ( lzx -> block_remaining == 0 ) { if ( ( lzx -> block_type == LZX_BLOCKTYPE_UNCOMPRESSED ) && ( lzx -> block_length & 1 ) ) { READ_IF_NEEDED ; i_ptr ++ ; } READ_BITS ( lzx -> block_type , 3 ) ; READ_BITS ( i , 16 ) ; READ_BITS ( j , 8 ) ; lzx -> block_remaining = lzx -> block_length = ( i << 8 ) | j ; switch ( lzx -> block_type ) { case LZX_BLOCKTYPE_ALIGNED : for ( i = 0 ; i < 8 ; i ++ ) { READ_BITS ( j , 3 ) ; lzx -> ALIGNED_len [ i ] = j ; } BUILD_TABLE ( ALIGNED ) ; case LZX_BLOCKTYPE_VERBATIM : READ_LENGTHS ( MAINTREE , 0 , 256 ) ; READ_LENGTHS ( MAINTREE , 256 , LZX_NUM_CHARS + lzx -> num_offsets ) ; BUILD_TABLE ( MAINTREE ) ; if ( lzx -> MAINTREE_len [ 0xE8 ] != 0 ) lzx -> intel_started = 1 ; READ_LENGTHS ( LENGTH , 0 , LZX_NUM_SECONDARY_LENGTHS ) ; BUILD_TABLE_MAYBE_EMPTY ( LENGTH ) ; break ; case LZX_BLOCKTYPE_UNCOMPRESSED : lzx -> intel_started = 1 ; if ( bits_left == 0 ) ENSURE_BITS ( 16 ) ; bits_left = 0 ; bit_buffer = 0 ; for ( rundest = & buf [ 0 ] , i = 0 ; i < 12 ; i ++ ) { READ_IF_NEEDED ; * rundest ++ = * i_ptr ++ ; } R0 = buf [ 0 ] | ( buf [ 1 ] << 8 ) | ( buf [ 2 ] << 16 ) | ( buf [ 3 ] << 24 ) ; R1 = buf [ 4 ] | ( buf [ 5 ] << 8 ) | ( buf [ 6 ] << 16 ) | ( buf [ 7 ] << 24 ) ; R2 = buf [ 8 ] | ( buf [ 9 ] << 8 ) | ( buf [ 10 ] << 16 ) | ( buf [ 11 ] << 24 ) ; break ; default : D ( ( ""badblocktype"" ) ) return lzx -> error = MSPACK_ERR_DECRUNCH ; } } this_run = lzx -> block_remaining ; if ( this_run > bytes_todo ) this_run = bytes_todo ; bytes_todo -= this_run ; lzx -> block_remaining -= this_run ; switch ( lzx -> block_type ) { case LZX_BLOCKTYPE_VERBATIM : while ( this_run > 0 ) { READ_HUFFSYM ( MAINTREE , main_element ) ; if ( main_element < LZX_NUM_CHARS ) { window [ window_posn ++ ] = main_element ; this_run -- ; } else { main_element -= LZX_NUM_CHARS ; match_length = main_element & LZX_NUM_PRIMARY_LENGTHS ; if ( match_length == LZX_NUM_PRIMARY_LENGTHS ) { if ( lzx -> LENGTH_empty ) { D ( ( ""LENGTHsymbolneededbuttreeisempty"" ) ) return lzx -> error = MSPACK_ERR_DECRUNCH ; } READ_HUFFSYM ( LENGTH , length_footer ) ; match_length += length_footer ; } match_length += LZX_MIN_MATCH ; switch ( ( match_offset = ( main_element >> 3 ) ) ) { case 0 : match_offset = R0 ; break ; case 1 : match_offset = R1 ; R1 = R0 ; R0 = match_offset ; break ; case 2 : match_offset = R2 ; R2 = R0 ; R0 = match_offset ; break ; case 3 : match_offset = 1 ; R2 = R1 ; R1 = R0 ; R0 = match_offset ; break ; default : extra = ( match_offset >= 36 ) ? 17 : extra_bits [ match_offset ] ; READ_BITS ( verbatim_bits , extra ) ; match_offset = position_base [ match_offset ] - 2 + verbatim_bits ; R2 = R1 ; R1 = R0 ; R0 = match_offset ; } if ( match_length == LZX_MAX_MATCH && lzx -> is_delta ) { int extra_len = 0 ; ENSURE_BITS ( 3 ) ; if ( PEEK_BITS ( 1 ) == 0 ) { REMOVE_BITS ( 1 ) ; READ_BITS ( extra_len , 8 ) ; } else if ( PEEK_BITS ( 2 ) == 2 ) { REMOVE_BITS ( 2 ) ; READ_BITS ( extra_len , 10 ) ; extra_len += 0x100 ; } else if ( PEEK_BITS ( 3 ) == 6 ) { REMOVE_BITS ( 3 ) ; READ_BITS ( extra_len , 12 ) ; extra_len += 0x500 ; } else { REMOVE_BITS ( 3 ) ; READ_BITS ( extra_len , 15 ) ; } match_length += extra_len ; } if ( ( window_posn + match_length ) > lzx -> window_size ) { D ( ( ""matchranoverwindowwrap"" ) ) return lzx -> error = MSPACK_ERR_DECRUNCH ; } rundest = & window [ window_posn ] ; i = match_length ; if ( match_offset > window_posn ) { if ( match_offset > lzx -> offset && ( match_offset - window_posn ) > lzx -> ref_data_size ) { D ( ( ""matchoffsetbeyondLZXstream"" ) ) return lzx -> error = MSPACK_ERR_DECRUNCH ; } j = match_offset - window_posn ; if ( j > ( int ) lzx -> window_size ) { D ( ( ""matchoffsetbeyondwindowboundaries"" ) ) return lzx -> error = MSPACK_ERR_DECRUNCH ; } runsrc = & window [ lzx -> window_size - j ] ; if ( j < i ) { i -= j ; while ( j -- > 0 ) * rundest ++ = * runsrc ++ ; runsrc = window ; } while ( i -- > 0 ) * rundest ++ = * runsrc ++ ; } else { runsrc = rundest - match_offset ; while ( i -- > 0 ) * rundest ++ = * runsrc ++ ; } this_run -= match_length ; window_posn += match_length ; } } break ; case LZX_BLOCKTYPE_ALIGNED : while ( this_run > 0 ) { READ_HUFFSYM ( MAINTREE , main_element ) ; if ( main_element < LZX_NUM_CHARS ) { window [ window_posn ++ ] = main_element ; this_run -- ; } else { main_element -= LZX_NUM_CHARS ; match_length = main_element & LZX_NUM_PRIMARY_LENGTHS ; if ( match_length == LZX_NUM_PRIMARY_LENGTHS ) { if ( lzx -> LENGTH_empty ) { D ( ( ""LENGTHsymbolneededbuttreeisempty"" ) ) return lzx -> error = MSPACK_ERR_DECRUNCH ; } READ_HUFFSYM ( LENGTH , length_footer ) ; match_length += length_footer ; } match_length += LZX_MIN_MATCH ; switch ( ( match_offset = ( main_element >> 3 ) ) ) { case 0 : match_offset = R0 ; break ; case 1 : match_offset = R1 ; R1 = R0 ; R0 = match_offset ; break ; case 2 : match_offset = R2 ; R2 = R0 ; R0 = match_offset ; break ; default : extra = ( match_offset >= 36 ) ? 17 : extra_bits [ match_offset ] ; match_offset = position_base [ match_offset ] - 2 ; if ( extra > 3 ) { extra -= 3 ; READ_BITS ( verbatim_bits , extra ) ; match_offset += ( verbatim_bits << 3 ) ; READ_HUFFSYM ( ALIGNED , aligned_bits ) ; match_offset += aligned_bits ; } else if ( extra == 3 ) { READ_HUFFSYM ( ALIGNED , aligned_bits ) ; match_offset += aligned_bits ; } else if ( extra > 0 ) { READ_BITS ( verbatim_bits , extra ) ; match_offset += verbatim_bits ; } else { match_offset = 1 ; } R2 = R1 ; R1 = R0 ; R0 = match_offset ; } if ( match_length == LZX_MAX_MATCH && lzx -> is_delta ) { int extra_len = 0 ; ENSURE_BITS ( 3 ) ; if ( PEEK_BITS ( 1 ) == 0 ) { REMOVE_BITS ( 1 ) ; READ_BITS ( extra_len , 8 ) ; } else if ( PEEK_BITS ( 2 ) == 2 ) { REMOVE_BITS ( 2 ) ; READ_BITS ( extra_len , 10 ) ; extra_len += 0x100 ; } else if ( PEEK_BITS ( 3 ) == 6 ) { REMOVE_BITS ( 3 ) ; READ_BITS ( extra_len , 12 ) ; extra_len += 0x500 ; } else { REMOVE_BITS ( 3 ) ; READ_BITS ( extra_len , 15 ) ; } match_length += extra_len ; } if ( ( window_posn + match_length ) > lzx -> window_size ) { D ( ( ""matchranoverwindowwrap"" ) ) return lzx -> error = MSPACK_ERR_DECRUNCH ; } rundest = & window [ window_posn ] ; i = match_length ; if ( match_offset > window_posn ) { if ( match_offset > lzx -> offset && ( match_offset - window_posn ) > lzx -> ref_data_size ) { D ( ( ""matchoffsetbeyondLZXstream"" ) ) return lzx -> error = MSPACK_ERR_DECRUNCH ; } j = match_offset - window_posn ; if ( j > ( int ) lzx -> window_size ) { D ( ( ""matchoffsetbeyondwindowboundaries"" ) ) return lzx -> error = MSPACK_ERR_DECRUNCH ; } runsrc = & window [ lzx -> window_size - j ] ; if ( j < i ) { i -= j ; while ( j -- > 0 ) * rundest ++ = * runsrc ++ ; runsrc = window ; } while ( i -- > 0 ) * rundest ++ = * runsrc ++ ; } else { runsrc = rundest - match_offset ; while ( i -- > 0 ) * rundest ++ = * runsrc ++ ; } this_run -= match_length ; window_posn += match_length ; } } break ; case LZX_BLOCKTYPE_UNCOMPRESSED : rundest = & window [ window_posn ] ; window_posn += this_run ; while ( this_run > 0 ) { if ( ( i = i_end - i_ptr ) == 0 ) { READ_IF_NEEDED ; } else { if ( i > this_run ) i = this_run ; lzx -> sys -> copy ( i_ptr , rundest , ( size_t ) i ) ; rundest += i ; i_ptr += i ; this_run -= i ; } } break ; default : return lzx -> error = MSPACK_ERR_DECRUNCH ; } if ( this_run < 0 ) { if ( ( unsigned int ) ( - this_run ) > lzx -> block_remaining ) { D ( ( ""overrunwentpastendofblockby%d(%dremaining)"" , - this_run , lzx -> block_remaining ) ) return lzx -> error = MSPACK_ERR_DECRUNCH ; } lzx -> block_remaining -= - this_run ; } } if ( ( window_posn - lzx -> frame_posn ) != frame_size ) { D ( ( ""decodebeyondoutputframelimits!%d!=%d"" , window_posn - lzx -> frame_posn , frame_size ) ) return lzx -> error = MSPACK_ERR_DECRUNCH ; } if ( bits_left > 0 ) ENSURE_BITS ( 16 ) ; if ( bits_left & 15 ) REMOVE_BITS ( bits_left & 15 ) ; if ( lzx -> o_ptr != lzx -> o_end ) { D ( ( ""%ldavailbytes,new%dframe"" , ( long ) ( lzx -> o_end - lzx -> o_ptr ) , frame_size ) ) return lzx -> error = MSPACK_ERR_DECRUNCH ; } if ( lzx -> intel_started && lzx -> intel_filesize && ( lzx -> frame <= 32768 ) && ( frame_size > 10 ) ) { unsigned char * data = & lzx -> e8_buf [ 0 ] ; unsigned char * dataend = & lzx -> e8_buf [ frame_size - 10 ] ; signed int curpos = lzx -> intel_curpos ; signed int filesize = lzx -> intel_filesize ; signed int abs_off , rel_off ; lzx -> o_ptr = data ; lzx -> sys -> copy ( & lzx -> window [ lzx -> frame_posn ] , data , frame_size ) ; while ( data < dataend ) { if ( * data ++ != 0xE8 ) { curpos ++ ; continue ; } abs_off = data [ 0 ] | ( data [ 1 ] << 8 ) | ( data [ 2 ] << 16 ) | ( data [ 3 ] << 24 ) ; if ( ( abs_off >= - curpos ) && ( abs_off < filesize ) ) { rel_off = ( abs_off >= 0 ) ? abs_off - curpos : abs_off + filesize ; data [ 0 ] = ( unsigned char ) rel_off ; data [ 1 ] = ( unsigned char ) ( rel_off >> 8 ) ; data [ 2 ] = ( unsigned char ) ( rel_off >> 16 ) ; data [ 3 ] = ( unsigned char ) ( rel_off >> 24 ) ; } data += 4 ; curpos += 5 ; } lzx -> intel_curpos += frame_size ; } else { lzx -> o_ptr = & lzx -> window [ lzx -> frame_posn ] ; if ( lzx -> intel_filesize ) lzx -> intel_curpos += frame_size ; } lzx -> o_end = & lzx -> o_ptr [ frame_size ] ; i = ( out_bytes < ( off_t ) frame_size ) ? ( unsigned int ) out_bytes : frame_size ; if ( lzx -> sys -> write ( lzx -> output , lzx -> o_ptr , i ) != i ) { return lzx -> error = MSPACK_ERR_WRITE ; } lzx -> o_ptr += i ; lzx -> offset += i ; out_bytes -= i ; lzx -> frame_posn += frame_size ; lzx -> frame ++ ; if ( window_posn == lzx -> window_size ) window_posn = 0 ; if ( lzx -> frame_posn == lzx -> window_size ) lzx -> frame_posn = 0 ; } if ( out_bytes ) { D ( ( ""byteslefttooutput"" ) ) return lzx -> error = MSPACK_ERR_DECRUNCH ; } STORE_BITS ; lzx -> window_posn = window_posn ; lzx -> R0 = R0 ; lzx -> R1 = R1 ; lzx -> R2 = R2 ; return MSPACK_ERR_OK ; } "," case LZX_BLOCKTYPE_UNCOMPRESSED : if ( window_posn + this_run > lzx -> window_size ) { D ( ( ""matchranoverwindowboundary"" ) ) return lzx -> error = MSPACK_ERR_DECRUNCH ; } ",vrtadmin@clamav-devel/a83773682e856ad6529ba6db8d1792e6d515d7f1,CVE-2017-6419,https://github.com/vrtadmin/clamav-devel/commit/a83773682e856ad6529ba6db8d1792e6d515d7f1,2017-08-07T03:29Z 1525,CWE-119,"CWE-119 static vpx_codec_err_t ctrl_set_previewpp ( vpx_codec_alg_priv_t * ctx , int ctr_id , va_list args ) { # if CONFIG_VP9_POSTPROC vp8_postproc_cfg_t * config = va_arg ( args , vp8_postproc_cfg_t * ) ; ( void ) ctr_id ; if ( config != NULL ) { ctx -> preview_ppcfg = * config ; return VPX_CODEC_OK ; } else { return VPX_CODEC_INVALID_PARAM ; } # else ( void ) ctx ; ( void ) ctr_id ; ( void ) args ; return VPX_CODEC_INCAPABLE ; # endif } "," * ctx , va_list args ) vp8_postproc_cfg_t * ) ; if ( ( void ) args ; return ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1526,CWE-119,"CWE-119 void vp9_reset_segment_features ( struct segmentation * seg ) { seg -> enabled = 0 ; seg -> update_map = 0 ; seg -> update_data = 0 ; vpx_memset ( seg -> tree_probs , 255 , sizeof ( seg -> tree_probs ) ) ; vp9_clearall_segfeatures ( seg ) ; } "," = 0 ; memset ( seg -> ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1527,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 1528,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 1529,CWE-000,"CWE-000 static int unix_dgram_sendmsg ( struct socket * sock , struct msghdr * msg , size_t len ) { struct sock * sk = sock -> sk ; struct net * net = sock_net ( sk ) ; struct unix_sock * u = unix_sk ( sk ) ; DECLARE_SOCKADDR ( struct sockaddr_un * , sunaddr , msg -> msg_name ) ; struct sock * other = NULL ; int namelen = 0 ; int err ; unsigned int hash ; struct sk_buff * skb ; long timeo ; struct scm_cookie scm ; int max_level ; int data_len = 0 ; wait_for_unix_gc ( ) ; err = scm_send ( sock , msg , & scm , false ) ; if ( err < 0 ) return err ; err = - EOPNOTSUPP ; if ( msg -> msg_flags & MSG_OOB ) goto out ; if ( msg -> msg_namelen ) { err = unix_mkname ( sunaddr , msg -> msg_namelen , & hash ) ; if ( err < 0 ) goto out ; namelen = err ; } else { sunaddr = NULL ; err = - ENOTCONN ; other = unix_peer_get ( sk ) ; if ( ! other ) goto out ; } if ( test_bit ( SOCK_PASSCRED , & sock -> flags ) && ! u -> addr && ( err = unix_autobind ( sock ) ) != 0 ) goto out ; err = - EMSGSIZE ; if ( len > sk -> sk_sndbuf - 32 ) goto out ; if ( len > SKB_MAX_ALLOC ) { data_len = min_t ( size_t , len - SKB_MAX_ALLOC , MAX_SKB_FRAGS * PAGE_SIZE ) ; data_len = PAGE_ALIGN ( data_len ) ; BUILD_BUG_ON ( SKB_MAX_ALLOC < PAGE_SIZE ) ; } skb = sock_alloc_send_pskb ( sk , len - data_len , data_len , msg -> msg_flags & MSG_DONTWAIT , & err , PAGE_ALLOC_COSTLY_ORDER ) ; if ( skb == NULL ) goto out ; err = unix_scm_to_skb ( & scm , skb , true ) ; if ( err < 0 ) goto out_free ; max_level = err + 1 ; skb_put ( skb , len - data_len ) ; skb -> data_len = data_len ; skb -> len = len ; err = skb_copy_datagram_from_iter ( skb , 0 , & msg -> msg_iter , len ) ; if ( err ) goto out_free ; timeo = sock_sndtimeo ( sk , msg -> msg_flags & MSG_DONTWAIT ) ; restart : if ( ! other ) { err = - ECONNRESET ; if ( sunaddr == NULL ) goto out_free ; other = unix_find_other ( net , sunaddr , namelen , sk -> sk_type , hash , & err ) ; if ( other == NULL ) goto out_free ; } if ( sk_filter ( other , skb ) < 0 ) { err = len ; goto out_free ; } unix_state_lock ( other ) ; err = - EPERM ; if ( ! unix_may_send ( sk , other ) ) goto out_unlock ; if ( sock_flag ( other , SOCK_DEAD ) ) { unix_state_unlock ( other ) ; sock_put ( other ) ; err = 0 ; unix_state_lock ( sk ) ; if ( unix_peer ( sk ) == other ) { unix_peer ( sk ) = NULL ; unix_state_unlock ( sk ) ; unix_dgram_disconnected ( sk , other ) ; sock_put ( other ) ; err = - ECONNREFUSED ; } else { unix_state_unlock ( sk ) ; } other = NULL ; if ( err ) goto out_free ; goto restart ; } err = - EPIPE ; if ( other -> sk_shutdown & RCV_SHUTDOWN ) goto out_unlock ; if ( sk -> sk_type != SOCK_SEQPACKET ) { err = security_unix_may_send ( sk -> sk_socket , other -> sk_socket ) ; if ( err ) goto out_unlock ; } if ( unix_peer ( other ) != sk && unix_recvq_full ( other ) ) { if ( ! timeo ) { err = - EAGAIN ; goto out_unlock ; } timeo = unix_wait_for_peer ( other , timeo ) ; err = sock_intr_errno ( timeo ) ; if ( signal_pending ( current ) ) goto out_free ; goto restart ; } if ( sock_flag ( other , SOCK_RCVTSTAMP ) ) __net_timestamp ( skb ) ; 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 ) ; sock_put ( other ) ; scm_destroy ( & scm ) ; return len ; out_unlock : unix_state_unlock ( other ) ; out_free : kfree_skb ( skb ) ; out : if ( other ) sock_put ( other ) ; scm_destroy ( & scm ) ; return err ; } "," = 0 ; int sk_locked ; out_free ; } sk_locked = 0 ; other ) ; restart_locked : ; if ( unlikely ( SOCK_DEAD ) ) ) other ) ; if ( ! sk_locked ) unix_state_lock ( sk ) ; = 0 ; if ( unix_peer ) = NULL ; unix_dgram_peer_wake_disconnect_wakeup ( sk , other ) } if ( unlikely ( other ) ) ) { if ( timeo ) { timeo = unix_wait_for_peer ( other , timeo ) ; err = sock_intr_errno ( timeo ) ; if ( signal_pending ( current ) ) goto out_free ; goto restart ; } if ( ! if ( ! sk_locked ) { unix_state_unlock ( other ) ; unix_state_double_lock ( sk , other ) ; } if ( unix_peer ( sk ) != other || unix_dgram_peer_wake_me ( sk , other ) ) { err - EAGAIN ; sk_locked = 1 ; out_unlock ; } if ( ! sk_locked ) { sk_locked = 1 ; goto restart_locked ; } } if ( unlikely ( sk_locked ) ) unix_state_unlock ( sk ) ; if ( sock_flag ; out_unlock : if ( sk_locked ) unix_state_unlock ( sk ) ; ",torvalds@linux/7d267278a9ece963d77eefec61630223fce08c6c,CVE-2013-7446,https://github.com/torvalds/linux/commit/7d267278a9ece963d77eefec61630223fce08c6c,2015-12-28T11:59Z 1530,CWE-20,"CWE-20 static future_t * init ( void ) { pthread_mutex_init ( & lock , NULL ) ; config = config_new ( CONFIG_FILE_PATH ) ; if ( ! config ) { LOG_WARN ( ""%sunabletoloadconfigfile;attemptingtotranscodelegacyfile."" , __func__ ) ; config = btif_config_transcode ( LEGACY_CONFIG_FILE_PATH ) ; if ( ! config ) { LOG_WARN ( ""%sunabletotranscodelegacyfile,startingunconfigured."" , __func__ ) ; config = config_new_empty ( ) ; if ( ! config ) { LOG_ERROR ( ""%sunabletoallocateaconfigobject."" , __func__ ) ; goto error ; } } if ( config_save ( config , CONFIG_FILE_PATH ) ) unlink ( LEGACY_CONFIG_FILE_PATH ) ; } btif_config_remove_unpaired ( config ) ; alarm_timer = alarm_new ( ) ; if ( ! alarm_timer ) { LOG_ERROR ( ""%sunabletocreatealarm."" , __func__ ) ; goto error ; } return future_new_immediate ( FUTURE_SUCCESS ) ; error : ; alarm_free ( alarm_timer ) ; config_free ( config ) ; pthread_mutex_destroy ( & lock ) ; alarm_timer = NULL ; config = NULL ; return future_new_immediate ( FUTURE_FAIL ) ; } "," config ) ; if ( ! is_restricted_mode ( ) ) btif_config_remove_restricted ( config ) ; ",system@bt/37c88107679d36c419572732b4af6e18bb2f7dce,CVE-2016-3760,https://android.googlesource.com/platform/system/bt/+/37c88107679d36c419572732b4af6e18bb2f7dce,2016-07-11T02:00Z 1531,CWE-119,"CWE-119 int main ( void ) { # line 52 ""dt_test2.pgc"" date date1 ; # line 53 ""dt_test2.pgc"" timestamp ts1 , ts2 ; # line 54 ""dt_test2.pgc"" char * text ; # line 55 ""dt_test2.pgc"" interval * i1 ; # line 56 ""dt_test2.pgc"" date * dc ; # line 57 ""dt_test2.pgc"" int i , j ; char * endptr ; ECPGdebug ( 1 , stderr ) ; ts1 = PGTYPEStimestamp_from_asc ( ""2003-12-0417:34:29"" , NULL ) ; text = PGTYPEStimestamp_to_asc ( ts1 ) ; printf ( ""timestamp:%s\\n"" , text ) ; free ( text ) ; date1 = PGTYPESdate_from_timestamp ( ts1 ) ; dc = PGTYPESdate_new ( ) ; * dc = date1 ; text = PGTYPESdate_to_asc ( * dc ) ; printf ( ""Dateoftimestamp:%s\\n"" , text ) ; free ( text ) ; PGTYPESdate_free ( dc ) ; for ( i = 0 ; dates [ i ] ; i ++ ) { bool err = false ; date1 = PGTYPESdate_from_asc ( dates [ i ] , & endptr ) ; if ( date1 == INT_MIN ) { err = true ; } text = PGTYPESdate_to_asc ( date1 ) ; printf ( ""Date[%d]:%s(%c-%c)\\n"" , i , err ? ""-"" : text , endptr ? 'N' : 'Y' , err ? 'T' : 'F' ) ; free ( text ) ; if ( ! err ) { for ( j = 0 ; times [ j ] ; j ++ ) { int length = strlen ( dates [ i ] ) + 1 + strlen ( times [ j ] ) + 1 ; char * t = malloc ( length ) ; sprintf ( t , ""%s%s"" , dates [ i ] , times [ j ] ) ; ts1 = PGTYPEStimestamp_from_asc ( t , NULL ) ; text = PGTYPEStimestamp_to_asc ( ts1 ) ; if ( i != 19 || j != 3 ) printf ( ""TS[%d,%d]:%s\\n"" , i , j , errno ? ""-"" : text ) ; free ( text ) ; free ( t ) ; } } } ts1 = PGTYPEStimestamp_from_asc ( ""2004-04-0423:23:23"" , NULL ) ; for ( i = 0 ; intervals [ i ] ; i ++ ) { interval * ic ; i1 = PGTYPESinterval_from_asc ( intervals [ i ] , & endptr ) ; if ( * endptr ) printf ( ""endptrsetto%s\\n"" , endptr ) ; if ( ! i1 ) { printf ( ""Errorparsinginterval%d\\n"" , i ) ; continue ; } j = PGTYPEStimestamp_add_interval ( & ts1 , i1 , & ts2 ) ; if ( j < 0 ) continue ; text = PGTYPESinterval_to_asc ( i1 ) ; printf ( ""interval[%d]:%s\\n"" , i , text ? text : ""-"" ) ; free ( text ) ; ic = PGTYPESinterval_new ( ) ; PGTYPESinterval_copy ( i1 , ic ) ; text = PGTYPESinterval_to_asc ( i1 ) ; printf ( ""interval_copy[%d]:%s\\n"" , i , text ? text : ""-"" ) ; free ( text ) ; PGTYPESinterval_free ( ic ) ; PGTYPESinterval_free ( i1 ) ; } return ( 0 ) ; } "," { # line 62 ""dt_test2.pgc"" date date1 ; # line 63 ""dt_test2.pgc"" timestamp ts1 ; # line 64 ""dt_test2.pgc"" char * ; # line 65 ""dt_test2.pgc"" interval * ; # line 66 ""dt_test2.pgc"" date * ; # line 67 ""dt_test2.pgc"" int i ",postgres@postgres/4318daecc959886d001a6e79c6ea853e8b1dfb4b,CVE-2014-0063,https://github.com/postgres/postgres/commit/4318daecc959886d001a6e79c6ea853e8b1dfb4b,2014-03-31T14:58Z 1532,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 1533,CWE-119,"CWE-119 void mp_decode_to_lua_array ( lua_State * L , mp_cur * c , size_t len ) { assert ( len <= UINT_MAX ) ; int index = 1 ; lua_newtable ( L ) ; while ( len -- ) { lua_pushnumber ( L , index ++ ) ; mp_decode_to_lua_type ( L , c ) ; if ( c -> err ) return ; lua_settable ( L , - 3 ) ; } } "," lua_newtable ( L ) ; luaL_checkstack ( L , 1 , ""infunctionmp_decode_to_lua_array"" ",antirez@redis/5ccb6f7a791bf3490357b00a898885759d98bab0,CVE-2018-11218,https://github.com/antirez/redis/commit/5ccb6f7a791bf3490357b00a898885759d98bab0,2018-06-17T17:29Z 1534,CWE-665,"CWE-665 static struct ib_ucontext * hns_roce_alloc_ucontext ( struct ib_device * ib_dev , struct ib_udata * udata ) { int ret = 0 ; struct hns_roce_ucontext * context ; struct hns_roce_ib_alloc_ucontext_resp resp ; struct hns_roce_dev * hr_dev = to_hr_dev ( ib_dev ) ; resp . qp_tab_size = hr_dev -> caps . num_qps ; context = kmalloc ( sizeof ( * context ) , GFP_KERNEL ) ; if ( ! context ) return ERR_PTR ( - ENOMEM ) ; ret = hns_roce_uar_alloc ( hr_dev , & context -> uar ) ; if ( ret ) goto error_fail_uar_alloc ; if ( hr_dev -> caps . flags & HNS_ROCE_CAP_FLAG_RECORD_DB ) { INIT_LIST_HEAD ( & context -> page_list ) ; mutex_init ( & context -> page_mutex ) ; } ret = ib_copy_to_udata ( udata , & resp , sizeof ( resp ) ) ; if ( ret ) goto error_fail_copy_to_udata ; return & context -> ibucontext ; error_fail_copy_to_udata : hns_roce_uar_free ( hr_dev , & context -> uar ) ; error_fail_uar_alloc : kfree ( context ) ; return ERR_PTR ( ret ) ; } "," struct hns_roce_ib_alloc_ucontext_resp resp = { } ",torvalds@linux/df7e40425813c50cd252e6f5e348a81ef1acae56,CVE-2019-16921,https://github.com/torvalds/linux/commit/df7e40425813c50cd252e6f5e348a81ef1acae56,2019-09-27T13:15Z 1535,CWE-125,"CWE-125 static int ext4_fill_super ( struct super_block * sb , void * data , int silent ) { char * orig_data = kstrdup ( data , GFP_KERNEL ) ; struct buffer_head * bh ; struct ext4_super_block * es = NULL ; struct ext4_sb_info * sbi = kzalloc ( sizeof ( * sbi ) , GFP_KERNEL ) ; ext4_fsblk_t block ; ext4_fsblk_t sb_block = get_sb_block ( & data ) ; ext4_fsblk_t logical_sb_block ; unsigned long offset = 0 ; unsigned long journal_devnum = 0 ; unsigned long def_mount_opts ; struct inode * root ; const char * descr ; int ret = - ENOMEM ; int blocksize , clustersize ; unsigned int db_count ; unsigned int i ; int needs_recovery , has_huge_files , has_bigalloc ; __u64 blocks_count ; int err = 0 ; unsigned int journal_ioprio = DEFAULT_JOURNAL_IOPRIO ; ext4_group_t first_not_zeroed ; if ( ( data && ! orig_data ) || ! sbi ) goto out_free_base ; sbi -> s_blockgroup_lock = kzalloc ( sizeof ( struct blockgroup_lock ) , GFP_KERNEL ) ; if ( ! sbi -> s_blockgroup_lock ) goto out_free_base ; sb -> s_fs_info = sbi ; sbi -> s_sb = sb ; sbi -> s_inode_readahead_blks = EXT4_DEF_INODE_READAHEAD_BLKS ; sbi -> s_sb_block = sb_block ; if ( sb -> s_bdev -> bd_part ) sbi -> s_sectors_written_start = part_stat_read ( sb -> s_bdev -> bd_part , sectors [ 1 ] ) ; strreplace ( sb -> s_id , '/' , '!' ) ; ret = - EINVAL ; blocksize = sb_min_blocksize ( sb , EXT4_MIN_BLOCK_SIZE ) ; if ( ! blocksize ) { ext4_msg ( sb , KERN_ERR , ""unabletosetblocksize"" ) ; goto out_fail ; } if ( blocksize != EXT4_MIN_BLOCK_SIZE ) { logical_sb_block = sb_block * EXT4_MIN_BLOCK_SIZE ; offset = do_div ( logical_sb_block , blocksize ) ; } else { logical_sb_block = sb_block ; } if ( ! ( bh = sb_bread_unmovable ( sb , logical_sb_block ) ) ) { ext4_msg ( sb , KERN_ERR , ""unabletoreadsuperblock"" ) ; goto out_fail ; } es = ( struct ext4_super_block * ) ( bh -> b_data + offset ) ; sbi -> s_es = es ; sb -> s_magic = le16_to_cpu ( es -> s_magic ) ; if ( sb -> s_magic != EXT4_SUPER_MAGIC ) goto cantfind_ext4 ; sbi -> s_kbytes_written = le64_to_cpu ( es -> s_kbytes_written ) ; if ( ext4_has_feature_metadata_csum ( sb ) && ext4_has_feature_gdt_csum ( sb ) ) ext4_warning ( sb , ""metadata_csumanduninit_bgare"" ""redundantflags;pleaserunfsck."" ) ; if ( ! ext4_verify_csum_type ( sb , es ) ) { ext4_msg ( sb , KERN_ERR , ""VFS:Foundext4filesystemwith"" ""unknownchecksumalgorithm."" ) ; silent = 1 ; goto cantfind_ext4 ; } if ( ext4_has_feature_metadata_csum ( sb ) ) { sbi -> s_chksum_driver = crypto_alloc_shash ( ""crc32c"" , 0 , 0 ) ; if ( IS_ERR ( sbi -> s_chksum_driver ) ) { ext4_msg ( sb , KERN_ERR , ""Cannotloadcrc32cdriver."" ) ; ret = PTR_ERR ( sbi -> s_chksum_driver ) ; sbi -> s_chksum_driver = NULL ; goto failed_mount ; } } if ( ! ext4_superblock_csum_verify ( sb , es ) ) { ext4_msg ( sb , KERN_ERR , ""VFS:Foundext4filesystemwith"" ""invalidsuperblockchecksum.Rune2fsck?"" ) ; silent = 1 ; ret = - EFSBADCRC ; goto cantfind_ext4 ; } if ( ext4_has_feature_csum_seed ( sb ) ) sbi -> s_csum_seed = le32_to_cpu ( es -> s_checksum_seed ) ; else if ( ext4_has_metadata_csum ( sb ) ) sbi -> s_csum_seed = ext4_chksum ( sbi , ~ 0 , es -> s_uuid , sizeof ( es -> s_uuid ) ) ; def_mount_opts = le32_to_cpu ( es -> s_default_mount_opts ) ; set_opt ( sb , INIT_INODE_TABLE ) ; if ( def_mount_opts & EXT4_DEFM_DEBUG ) set_opt ( sb , DEBUG ) ; if ( def_mount_opts & EXT4_DEFM_BSDGROUPS ) set_opt ( sb , GRPID ) ; if ( def_mount_opts & EXT4_DEFM_UID16 ) set_opt ( sb , NO_UID32 ) ; set_opt ( sb , XATTR_USER ) ; # ifdef CONFIG_EXT4_FS_POSIX_ACL set_opt ( sb , POSIX_ACL ) ; # endif if ( ext4_has_metadata_csum ( sb ) ) set_opt ( sb , JOURNAL_CHECKSUM ) ; if ( ( def_mount_opts & EXT4_DEFM_JMODE ) == EXT4_DEFM_JMODE_DATA ) set_opt ( sb , JOURNAL_DATA ) ; else if ( ( def_mount_opts & EXT4_DEFM_JMODE ) == EXT4_DEFM_JMODE_ORDERED ) set_opt ( sb , ORDERED_DATA ) ; else if ( ( def_mount_opts & EXT4_DEFM_JMODE ) == EXT4_DEFM_JMODE_WBACK ) set_opt ( sb , WRITEBACK_DATA ) ; if ( le16_to_cpu ( sbi -> s_es -> s_errors ) == EXT4_ERRORS_PANIC ) set_opt ( sb , ERRORS_PANIC ) ; else if ( le16_to_cpu ( sbi -> s_es -> s_errors ) == EXT4_ERRORS_CONTINUE ) set_opt ( sb , ERRORS_CONT ) ; else set_opt ( sb , ERRORS_RO ) ; set_opt ( sb , BLOCK_VALIDITY ) ; if ( def_mount_opts & EXT4_DEFM_DISCARD ) set_opt ( sb , DISCARD ) ; 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 ) ) ; sbi -> s_commit_interval = JBD2_DEFAULT_MAX_COMMIT_AGE * HZ ; sbi -> s_min_batch_time = EXT4_DEF_MIN_BATCH_TIME ; sbi -> s_max_batch_time = EXT4_DEF_MAX_BATCH_TIME ; if ( ( def_mount_opts & EXT4_DEFM_NOBARRIER ) == 0 ) set_opt ( sb , BARRIER ) ; if ( ! IS_EXT3_SB ( sb ) && ! IS_EXT2_SB ( sb ) && ( ( def_mount_opts & EXT4_DEFM_NODELALLOC ) == 0 ) ) set_opt ( sb , DELALLOC ) ; sbi -> s_li_wait_mult = EXT4_DEF_LI_WAIT_MULT ; if ( sbi -> s_es -> s_mount_opts [ 0 ] ) { char * s_mount_opts = kstrndup ( sbi -> s_es -> s_mount_opts , sizeof ( sbi -> s_es -> s_mount_opts ) , GFP_KERNEL ) ; if ( ! s_mount_opts ) goto failed_mount ; if ( ! parse_options ( s_mount_opts , sb , & journal_devnum , & journal_ioprio , 0 ) ) { ext4_msg ( sb , KERN_WARNING , ""failedtoparseoptionsinsuperblock:%s"" , s_mount_opts ) ; } kfree ( s_mount_opts ) ; } sbi -> s_def_mount_opt = sbi -> s_mount_opt ; if ( ! parse_options ( ( char * ) data , sb , & journal_devnum , & journal_ioprio , 0 ) ) goto failed_mount ; if ( test_opt ( sb , DATA_FLAGS ) == EXT4_MOUNT_JOURNAL_DATA ) { printk_once ( KERN_WARNING ""EXT4-fs:Warning:mounting"" ""withdata=journaldisablesdelayed"" ""allocationandO_DIRECTsupport!\\n"" ) ; if ( test_opt2 ( sb , EXPLICIT_DELALLOC ) ) { ext4_msg ( sb , KERN_ERR , ""can\'tmountwith"" ""bothdata=journalanddelalloc"" ) ; goto failed_mount ; } if ( test_opt ( sb , DIOREAD_NOLOCK ) ) { ext4_msg ( sb , KERN_ERR , ""can\'tmountwith"" ""bothdata=journalanddioread_nolock"" ) ; goto failed_mount ; } if ( test_opt ( sb , DAX ) ) { ext4_msg ( sb , KERN_ERR , ""can\'tmountwith"" ""bothdata=journalanddax"" ) ; goto failed_mount ; } if ( test_opt ( sb , DELALLOC ) ) clear_opt ( sb , DELALLOC ) ; } else { sb -> s_iflags |= SB_I_CGROUPWB ; } sb -> s_flags = ( sb -> s_flags & ~ MS_POSIXACL ) | ( test_opt ( sb , POSIX_ACL ) ? MS_POSIXACL : 0 ) ; if ( le32_to_cpu ( es -> s_rev_level ) == EXT4_GOOD_OLD_REV && ( ext4_has_compat_features ( sb ) || ext4_has_ro_compat_features ( sb ) || ext4_has_incompat_features ( sb ) ) ) ext4_msg ( sb , KERN_WARNING , ""featureflagssetonrev0fs,"" ""runninge2fsckisrecommended"" ) ; if ( es -> s_creator_os == cpu_to_le32 ( EXT4_OS_HURD ) ) { set_opt2 ( sb , HURD_COMPAT ) ; if ( ext4_has_feature_64bit ( sb ) ) { ext4_msg ( sb , KERN_ERR , ""TheHurdcan\'tsupport64-bitfilesystems"" ) ; goto failed_mount ; } } if ( IS_EXT2_SB ( sb ) ) { if ( ext2_feature_set_ok ( sb ) ) ext4_msg ( sb , KERN_INFO , ""mountingext2filesystem"" ""usingtheext4subsystem"" ) ; else { ext4_msg ( sb , KERN_ERR , ""couldn\'tmountasext2due"" ""tofeatureincompatibilities"" ) ; goto failed_mount ; } } if ( IS_EXT3_SB ( sb ) ) { if ( ext3_feature_set_ok ( sb ) ) ext4_msg ( sb , KERN_INFO , ""mountingext3filesystem"" ""usingtheext4subsystem"" ) ; else { ext4_msg ( sb , KERN_ERR , ""couldn\'tmountasext3due"" ""tofeatureincompatibilities"" ) ; goto failed_mount ; } } if ( ! ext4_feature_set_ok ( sb , ( sb -> s_flags & MS_RDONLY ) ) ) goto failed_mount ; blocksize = BLOCK_SIZE << le32_to_cpu ( es -> s_log_block_size ) ; if ( blocksize < EXT4_MIN_BLOCK_SIZE || blocksize > EXT4_MAX_BLOCK_SIZE ) { ext4_msg ( sb , KERN_ERR , ""Unsupportedfilesystemblocksize%d(%dlog_block_size)"" , blocksize , le32_to_cpu ( es -> s_log_block_size ) ) ; goto failed_mount ; } if ( le32_to_cpu ( es -> s_log_block_size ) > ( EXT4_MAX_BLOCK_LOG_SIZE - EXT4_MIN_BLOCK_LOG_SIZE ) ) { ext4_msg ( sb , KERN_ERR , ""Invalidlogblocksize:%u"" , le32_to_cpu ( es -> s_log_block_size ) ) ; goto failed_mount ; } if ( le16_to_cpu ( sbi -> s_es -> s_reserved_gdt_blocks ) > ( blocksize / 4 ) ) { ext4_msg ( sb , KERN_ERR , ""NumberofreservedGDTblocksinsanelylarge:%d"" , le16_to_cpu ( sbi -> s_es -> s_reserved_gdt_blocks ) ) ; goto failed_mount ; } if ( sbi -> s_mount_opt & EXT4_MOUNT_DAX ) { err = bdev_dax_supported ( sb , blocksize ) ; if ( err ) goto failed_mount ; } if ( ext4_has_feature_encrypt ( sb ) && es -> s_encryption_level ) { ext4_msg ( sb , KERN_ERR , ""Unsupportedencryptionlevel%d"" , es -> s_encryption_level ) ; goto failed_mount ; } if ( sb -> s_blocksize != blocksize ) { if ( ! sb_set_blocksize ( sb , blocksize ) ) { ext4_msg ( sb , KERN_ERR , ""badblocksize%d"" , blocksize ) ; goto failed_mount ; } brelse ( bh ) ; logical_sb_block = sb_block * EXT4_MIN_BLOCK_SIZE ; offset = do_div ( logical_sb_block , blocksize ) ; bh = sb_bread_unmovable ( sb , logical_sb_block ) ; if ( ! bh ) { ext4_msg ( sb , KERN_ERR , ""Can\'treadsuperblockon2ndtry"" ) ; goto failed_mount ; } es = ( struct ext4_super_block * ) ( bh -> b_data + offset ) ; sbi -> s_es = es ; if ( es -> s_magic != cpu_to_le16 ( EXT4_SUPER_MAGIC ) ) { ext4_msg ( sb , KERN_ERR , ""Magicmismatch,veryweird!"" ) ; goto failed_mount ; } } has_huge_files = ext4_has_feature_huge_file ( sb ) ; sbi -> s_bitmap_maxbytes = ext4_max_bitmap_size ( sb -> s_blocksize_bits , has_huge_files ) ; sb -> s_maxbytes = ext4_max_size ( sb -> s_blocksize_bits , has_huge_files ) ; if ( le32_to_cpu ( es -> s_rev_level ) == EXT4_GOOD_OLD_REV ) { sbi -> s_inode_size = EXT4_GOOD_OLD_INODE_SIZE ; sbi -> s_first_ino = EXT4_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 < EXT4_GOOD_OLD_INODE_SIZE ) || ( ! is_power_of_2 ( sbi -> s_inode_size ) ) || ( sbi -> s_inode_size > blocksize ) ) { ext4_msg ( sb , KERN_ERR , ""unsupportedinodesize:%d"" , sbi -> s_inode_size ) ; goto failed_mount ; } if ( sbi -> s_inode_size > EXT4_GOOD_OLD_INODE_SIZE ) sb -> s_time_gran = 1 << ( EXT4_EPOCH_BITS - 2 ) ; } sbi -> s_desc_size = le16_to_cpu ( es -> s_desc_size ) ; if ( ext4_has_feature_64bit ( sb ) ) { if ( sbi -> s_desc_size < EXT4_MIN_DESC_SIZE_64BIT || sbi -> s_desc_size > EXT4_MAX_DESC_SIZE || ! is_power_of_2 ( sbi -> s_desc_size ) ) { ext4_msg ( sb , KERN_ERR , ""unsupporteddescriptorsize%lu"" , sbi -> s_desc_size ) ; goto failed_mount ; } } else sbi -> s_desc_size = EXT4_MIN_DESC_SIZE ; sbi -> s_blocks_per_group = le32_to_cpu ( es -> s_blocks_per_group ) ; sbi -> s_inodes_per_group = le32_to_cpu ( es -> s_inodes_per_group ) ; sbi -> s_inodes_per_block = blocksize / EXT4_INODE_SIZE ( sb ) ; if ( sbi -> s_inodes_per_block == 0 ) goto cantfind_ext4 ; if ( sbi -> s_inodes_per_group < sbi -> s_inodes_per_block || sbi -> s_inodes_per_group > blocksize * 8 ) { ext4_msg ( sb , KERN_ERR , ""invalidinodespergroup:%lu\\n"" , sbi -> s_blocks_per_group ) ; goto failed_mount ; } sbi -> s_itb_per_group = sbi -> s_inodes_per_group / sbi -> s_inodes_per_block ; sbi -> s_desc_per_block = blocksize / EXT4_DESC_SIZE ( sb ) ; sbi -> s_sbh = bh ; sbi -> s_mount_state = le16_to_cpu ( es -> s_state ) ; sbi -> s_addr_per_block_bits = ilog2 ( EXT4_ADDR_PER_BLOCK ( sb ) ) ; sbi -> s_desc_per_block_bits = ilog2 ( EXT4_DESC_PER_BLOCK ( sb ) ) ; for ( i = 0 ; i < 4 ; i ++ ) sbi -> s_hash_seed [ i ] = le32_to_cpu ( es -> s_hash_seed [ i ] ) ; sbi -> s_def_hash_version = es -> s_def_hash_version ; if ( ext4_has_feature_dir_index ( sb ) ) { i = le32_to_cpu ( es -> s_flags ) ; if ( i & EXT2_FLAGS_UNSIGNED_HASH ) sbi -> s_hash_unsigned = 3 ; else if ( ( i & EXT2_FLAGS_SIGNED_HASH ) == 0 ) { # ifdef __CHAR_UNSIGNED__ if ( ! ( sb -> s_flags & MS_RDONLY ) ) es -> s_flags |= cpu_to_le32 ( EXT2_FLAGS_UNSIGNED_HASH ) ; sbi -> s_hash_unsigned = 3 ; # else if ( ! ( sb -> s_flags & MS_RDONLY ) ) es -> s_flags |= cpu_to_le32 ( EXT2_FLAGS_SIGNED_HASH ) ; # endif } } clustersize = BLOCK_SIZE << le32_to_cpu ( es -> s_log_cluster_size ) ; has_bigalloc = ext4_has_feature_bigalloc ( sb ) ; if ( has_bigalloc ) { if ( clustersize < blocksize ) { ext4_msg ( sb , KERN_ERR , ""clustersize(%d)smallerthan"" ""blocksize(%d)"" , clustersize , blocksize ) ; goto failed_mount ; } if ( le32_to_cpu ( es -> s_log_cluster_size ) > ( EXT4_MAX_CLUSTER_LOG_SIZE - EXT4_MIN_BLOCK_LOG_SIZE ) ) { ext4_msg ( sb , KERN_ERR , ""Invalidlogclustersize:%u"" , le32_to_cpu ( es -> s_log_cluster_size ) ) ; goto failed_mount ; } sbi -> s_cluster_bits = le32_to_cpu ( es -> s_log_cluster_size ) - le32_to_cpu ( es -> s_log_block_size ) ; sbi -> s_clusters_per_group = le32_to_cpu ( es -> s_clusters_per_group ) ; if ( sbi -> s_clusters_per_group > blocksize * 8 ) { ext4_msg ( sb , KERN_ERR , ""#clusterspergrouptoobig:%lu"" , sbi -> s_clusters_per_group ) ; goto failed_mount ; } if ( sbi -> s_blocks_per_group != ( sbi -> s_clusters_per_group * ( clustersize / blocksize ) ) ) { ext4_msg ( sb , KERN_ERR , ""blockspergroup(%lu)and"" ""clusterspergroup(%lu)inconsistent"" , sbi -> s_blocks_per_group , sbi -> s_clusters_per_group ) ; goto failed_mount ; } } else { if ( clustersize != blocksize ) { ext4_warning ( sb , ""fragment/clustersize(%d)!="" ""blocksize(%d)"" , clustersize , blocksize ) ; clustersize = blocksize ; } if ( sbi -> s_blocks_per_group > blocksize * 8 ) { ext4_msg ( sb , KERN_ERR , ""#blockspergrouptoobig:%lu"" , sbi -> s_blocks_per_group ) ; goto failed_mount ; } sbi -> s_clusters_per_group = sbi -> s_blocks_per_group ; sbi -> s_cluster_bits = 0 ; } sbi -> s_cluster_ratio = clustersize / blocksize ; if ( sbi -> s_blocks_per_group == clustersize << 3 ) set_opt2 ( sb , STD_GROUP_SIZE ) ; err = generic_check_addressable ( sb -> s_blocksize_bits , ext4_blocks_count ( es ) ) ; if ( err ) { ext4_msg ( sb , KERN_ERR , ""filesystem"" ""toolargetomountsafelyonthissystem"" ) ; if ( sizeof ( sector_t ) < 8 ) ext4_msg ( sb , KERN_WARNING , ""CONFIG_LBDAFnotenabled"" ) ; goto failed_mount ; } if ( EXT4_BLOCKS_PER_GROUP ( sb ) == 0 ) goto cantfind_ext4 ; blocks_count = sb -> s_bdev -> bd_inode -> i_size >> sb -> s_blocksize_bits ; if ( blocks_count && ext4_blocks_count ( es ) > blocks_count ) { ext4_msg ( sb , KERN_WARNING , ""badgeometry:blockcount%llu"" ""exceedssizeofdevice(%llublocks)"" , ext4_blocks_count ( es ) , blocks_count ) ; goto failed_mount ; } if ( le32_to_cpu ( es -> s_first_data_block ) >= ext4_blocks_count ( es ) ) { ext4_msg ( sb , KERN_WARNING , ""badgeometry:firstdata"" ""block%uisbeyondendoffilesystem(%llu)"" , le32_to_cpu ( es -> s_first_data_block ) , ext4_blocks_count ( es ) ) ; goto failed_mount ; } blocks_count = ( ext4_blocks_count ( es ) - le32_to_cpu ( es -> s_first_data_block ) + EXT4_BLOCKS_PER_GROUP ( sb ) - 1 ) ; do_div ( blocks_count , EXT4_BLOCKS_PER_GROUP ( sb ) ) ; if ( blocks_count > ( ( uint64_t ) 1 << 32 ) - EXT4_DESC_PER_BLOCK ( sb ) ) { ext4_msg ( sb , KERN_WARNING , ""groupscounttoolarge:%u"" ""(blockcount%llu,firstdatablock%u,"" ""blockspergroup%lu)"" , sbi -> s_groups_count , ext4_blocks_count ( es ) , le32_to_cpu ( es -> s_first_data_block ) , EXT4_BLOCKS_PER_GROUP ( sb ) ) ; goto failed_mount ; } sbi -> s_groups_count = blocks_count ; sbi -> s_blockfile_groups = min_t ( ext4_group_t , sbi -> s_groups_count , ( EXT4_MAX_BLOCK_FILE_PHYS / EXT4_BLOCKS_PER_GROUP ( sb ) ) ) ; db_count = ( sbi -> s_groups_count + EXT4_DESC_PER_BLOCK ( sb ) - 1 ) / EXT4_DESC_PER_BLOCK ( sb ) ; sbi -> s_group_desc = ext4_kvmalloc ( db_count * sizeof ( struct buffer_head * ) , GFP_KERNEL ) ; if ( sbi -> s_group_desc == NULL ) { ext4_msg ( sb , KERN_ERR , ""notenoughmemory"" ) ; ret = - ENOMEM ; goto failed_mount ; } bgl_lock_init ( sbi -> s_blockgroup_lock ) ; for ( i = 0 ; i < db_count ; i ++ ) { block = descriptor_loc ( sb , logical_sb_block , i ) ; sbi -> s_group_desc [ i ] = sb_bread_unmovable ( sb , block ) ; if ( ! sbi -> s_group_desc [ i ] ) { ext4_msg ( sb , KERN_ERR , ""can\'treadgroupdescriptor%d"" , i ) ; db_count = i ; goto failed_mount2 ; } } if ( ! ext4_check_descriptors ( sb , logical_sb_block , & first_not_zeroed ) ) { ext4_msg ( sb , KERN_ERR , ""groupdescriptorscorrupted!"" ) ; ret = - EFSCORRUPTED ; 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 ) ; setup_timer ( & sbi -> s_err_report , print_daily_error_info , ( unsigned long ) sb ) ; if ( ext4_es_register_shrinker ( sbi ) ) goto failed_mount3 ; sbi -> s_stripe = ext4_get_stripe_size ( sbi ) ; sbi -> s_extent_max_zeroout_kb = 32 ; sb -> s_op = & ext4_sops ; sb -> s_export_op = & ext4_export_ops ; sb -> s_xattr = ext4_xattr_handlers ; sb -> s_cop = & ext4_cryptops ; # ifdef CONFIG_QUOTA sb -> dq_op = & ext4_quota_operations ; if ( ext4_has_feature_quota ( sb ) ) sb -> s_qcop = & dquot_quotactl_sysfile_ops ; else sb -> s_qcop = & ext4_qctl_operations ; sb -> s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP | QTYPE_MASK_PRJ ; # endif memcpy ( sb -> s_uuid , es -> s_uuid , sizeof ( es -> s_uuid ) ) ; INIT_LIST_HEAD ( & sbi -> s_orphan ) ; mutex_init ( & sbi -> s_orphan_lock ) ; sb -> s_root = NULL ; needs_recovery = ( es -> s_last_orphan != 0 || ext4_has_feature_journal_needs_recovery ( sb ) ) ; if ( ext4_has_feature_mmp ( sb ) && ! ( sb -> s_flags & MS_RDONLY ) ) if ( ext4_multi_mount_protect ( sb , le64_to_cpu ( es -> s_mmp_block ) ) ) goto failed_mount3a ; if ( ! test_opt ( sb , NOLOAD ) && ext4_has_feature_journal ( sb ) ) { if ( ext4_load_journal ( sb , es , journal_devnum ) ) goto failed_mount3a ; } else if ( test_opt ( sb , NOLOAD ) && ! ( sb -> s_flags & MS_RDONLY ) && ext4_has_feature_journal_needs_recovery ( sb ) ) { ext4_msg ( sb , KERN_ERR , ""requiredjournalrecovery"" ""suppressedandnotmountedread-only"" ) ; goto failed_mount_wq ; } else { if ( test_opt2 ( sb , EXPLICIT_JOURNAL_CHECKSUM ) ) { ext4_msg ( sb , KERN_ERR , ""can\'tmountwith"" ""journal_checksum,fsmountedw/ojournal"" ) ; goto failed_mount_wq ; } if ( test_opt ( sb , JOURNAL_ASYNC_COMMIT ) ) { ext4_msg ( sb , KERN_ERR , ""can\'tmountwith"" ""journal_async_commit,fsmountedw/ojournal"" ) ; goto failed_mount_wq ; } if ( sbi -> s_commit_interval != JBD2_DEFAULT_MAX_COMMIT_AGE * HZ ) { ext4_msg ( sb , KERN_ERR , ""can\'tmountwith"" ""commit=%lu,fsmountedw/ojournal"" , sbi -> s_commit_interval / HZ ) ; goto failed_mount_wq ; } if ( EXT4_MOUNT_DATA_FLAGS & ( sbi -> s_mount_opt ^ sbi -> s_def_mount_opt ) ) { ext4_msg ( sb , KERN_ERR , ""can\'tmountwith"" ""data=,fsmountedw/ojournal"" ) ; goto failed_mount_wq ; } sbi -> s_def_mount_opt &= EXT4_MOUNT_JOURNAL_CHECKSUM ; clear_opt ( sb , JOURNAL_CHECKSUM ) ; clear_opt ( sb , DATA_FLAGS ) ; sbi -> s_journal = NULL ; needs_recovery = 0 ; goto no_journal ; } if ( ext4_has_feature_64bit ( sb ) && ! jbd2_journal_set_features ( EXT4_SB ( sb ) -> s_journal , 0 , 0 , JBD2_FEATURE_INCOMPAT_64BIT ) ) { ext4_msg ( sb , KERN_ERR , ""Failedtoset64-bitjournalfeature"" ) ; goto failed_mount_wq ; } if ( ! set_journal_csum_feature_set ( sb ) ) { ext4_msg ( sb , KERN_ERR , ""Failedtosetjournalchecksum"" ""featureset"" ) ; goto failed_mount_wq ; } switch ( test_opt ( sb , DATA_FLAGS ) ) { case 0 : if ( jbd2_journal_check_available_features ( sbi -> s_journal , 0 , 0 , JBD2_FEATURE_INCOMPAT_REVOKE ) ) set_opt ( sb , ORDERED_DATA ) ; else set_opt ( sb , JOURNAL_DATA ) ; break ; case EXT4_MOUNT_ORDERED_DATA : case EXT4_MOUNT_WRITEBACK_DATA : if ( ! jbd2_journal_check_available_features ( sbi -> s_journal , 0 , 0 , JBD2_FEATURE_INCOMPAT_REVOKE ) ) { ext4_msg ( sb , KERN_ERR , ""Journaldoesnotsupport"" ""requesteddatajournalingmode"" ) ; goto failed_mount_wq ; } default : break ; } set_task_ioprio ( sbi -> s_journal -> j_task , journal_ioprio ) ; sbi -> s_journal -> j_commit_callback = ext4_journal_commit_callback ; no_journal : sbi -> s_mb_cache = ext4_xattr_create_cache ( ) ; if ( ! sbi -> s_mb_cache ) { ext4_msg ( sb , KERN_ERR , ""Failedtocreateanmb_cache"" ) ; goto failed_mount_wq ; } if ( ( DUMMY_ENCRYPTION_ENABLED ( sbi ) || ext4_has_feature_encrypt ( sb ) ) && ( blocksize != PAGE_SIZE ) ) { ext4_msg ( sb , KERN_ERR , ""Unsupportedblocksizeforfsencryption"" ) ; goto failed_mount_wq ; } if ( DUMMY_ENCRYPTION_ENABLED ( sbi ) && ! ( sb -> s_flags & MS_RDONLY ) && ! ext4_has_feature_encrypt ( sb ) ) { ext4_set_feature_encrypt ( sb ) ; ext4_commit_super ( sb , 1 ) ; } if ( es -> s_overhead_clusters ) sbi -> s_overhead = le32_to_cpu ( es -> s_overhead_clusters ) ; else { err = ext4_calculate_overhead ( sb ) ; if ( err ) goto failed_mount_wq ; } EXT4_SB ( sb ) -> rsv_conversion_wq = alloc_workqueue ( ""ext4-rsv-conversion"" , WQ_MEM_RECLAIM | WQ_UNBOUND , 1 ) ; if ( ! EXT4_SB ( sb ) -> rsv_conversion_wq ) { printk ( KERN_ERR ""EXT4-fs:failedtocreateworkqueue\\n"" ) ; ret = - ENOMEM ; goto failed_mount4 ; } root = ext4_iget ( sb , EXT4_ROOT_INO ) ; if ( IS_ERR ( root ) ) { ext4_msg ( sb , KERN_ERR , ""getrootinodefailed"" ) ; ret = PTR_ERR ( root ) ; root = NULL ; goto failed_mount4 ; } if ( ! S_ISDIR ( root -> i_mode ) || ! root -> i_blocks || ! root -> i_size ) { ext4_msg ( sb , KERN_ERR , ""corruptrootinode,rune2fsck"" ) ; iput ( root ) ; goto failed_mount4 ; } sb -> s_root = d_make_root ( root ) ; if ( ! sb -> s_root ) { ext4_msg ( sb , KERN_ERR , ""getrootdentryfailed"" ) ; ret = - ENOMEM ; goto failed_mount4 ; } if ( ext4_setup_super ( sb , es , sb -> s_flags & MS_RDONLY ) ) sb -> s_flags |= MS_RDONLY ; if ( sbi -> s_inode_size > EXT4_GOOD_OLD_INODE_SIZE ) { sbi -> s_want_extra_isize = sizeof ( struct ext4_inode ) - EXT4_GOOD_OLD_INODE_SIZE ; if ( ext4_has_feature_extra_isize ( sb ) ) { if ( sbi -> s_want_extra_isize < le16_to_cpu ( es -> s_want_extra_isize ) ) sbi -> s_want_extra_isize = le16_to_cpu ( es -> s_want_extra_isize ) ; if ( sbi -> s_want_extra_isize < le16_to_cpu ( es -> s_min_extra_isize ) ) sbi -> s_want_extra_isize = le16_to_cpu ( es -> s_min_extra_isize ) ; } } if ( EXT4_GOOD_OLD_INODE_SIZE + sbi -> s_want_extra_isize > sbi -> s_inode_size ) { sbi -> s_want_extra_isize = sizeof ( struct ext4_inode ) - EXT4_GOOD_OLD_INODE_SIZE ; ext4_msg ( sb , KERN_INFO , ""requiredextrainodespacenot"" ""available"" ) ; } ext4_set_resv_clusters ( sb ) ; err = ext4_setup_system_zone ( sb ) ; if ( err ) { ext4_msg ( sb , KERN_ERR , ""failedtoinitializesystem"" ""zone(%d)"" , err ) ; goto failed_mount4a ; } ext4_ext_init ( sb ) ; err = ext4_mb_init ( sb ) ; if ( err ) { ext4_msg ( sb , KERN_ERR , ""failedtoinitializemballoc(%d)"" , err ) ; goto failed_mount5 ; } block = ext4_count_free_clusters ( sb ) ; ext4_free_blocks_count_set ( sbi -> s_es , EXT4_C2B ( sbi , block ) ) ; err = percpu_counter_init ( & sbi -> s_freeclusters_counter , block , GFP_KERNEL ) ; if ( ! err ) { unsigned long freei = ext4_count_free_inodes ( sb ) ; sbi -> s_es -> s_free_inodes_count = cpu_to_le32 ( freei ) ; err = percpu_counter_init ( & sbi -> s_freeinodes_counter , freei , GFP_KERNEL ) ; } if ( ! err ) err = percpu_counter_init ( & sbi -> s_dirs_counter , ext4_count_dirs ( sb ) , GFP_KERNEL ) ; if ( ! err ) err = percpu_counter_init ( & sbi -> s_dirtyclusters_counter , 0 , GFP_KERNEL ) ; if ( ! err ) err = percpu_init_rwsem ( & sbi -> s_journal_flag_rwsem ) ; if ( err ) { ext4_msg ( sb , KERN_ERR , ""insufficientmemory"" ) ; goto failed_mount6 ; } if ( ext4_has_feature_flex_bg ( sb ) ) if ( ! ext4_fill_flex_info ( sb ) ) { ext4_msg ( sb , KERN_ERR , ""unabletoinitialize"" ""flex_bgmetainfo!"" ) ; goto failed_mount6 ; } err = ext4_register_li_request ( sb , first_not_zeroed ) ; if ( err ) goto failed_mount6 ; err = ext4_register_sysfs ( sb ) ; if ( err ) goto failed_mount7 ; # ifdef CONFIG_QUOTA if ( ext4_has_feature_quota ( sb ) && ! ( sb -> s_flags & MS_RDONLY ) ) { err = ext4_enable_quotas ( sb ) ; if ( err ) goto failed_mount8 ; } # endif EXT4_SB ( sb ) -> s_mount_state |= EXT4_ORPHAN_FS ; ext4_orphan_cleanup ( sb , es ) ; EXT4_SB ( sb ) -> s_mount_state &= ~ EXT4_ORPHAN_FS ; if ( needs_recovery ) { ext4_msg ( sb , KERN_INFO , ""recoverycomplete"" ) ; ext4_mark_recovery_complete ( sb , es ) ; } if ( EXT4_SB ( sb ) -> s_journal ) { if ( test_opt ( sb , DATA_FLAGS ) == EXT4_MOUNT_JOURNAL_DATA ) descr = ""journalleddatamode"" ; else if ( test_opt ( sb , DATA_FLAGS ) == EXT4_MOUNT_ORDERED_DATA ) descr = ""ordereddatamode"" ; else descr = ""writebackdatamode"" ; } else descr = ""outjournal"" ; if ( test_opt ( sb , DISCARD ) ) { struct request_queue * q = bdev_get_queue ( sb -> s_bdev ) ; if ( ! blk_queue_discard ( q ) ) ext4_msg ( sb , KERN_WARNING , ""mountingwith\\""discard\\""option,but"" ""thedevicedoesnotsupportdiscard"" ) ; } if ( ___ratelimit ( & ext4_mount_msg_ratelimit , ""EXT4-fsmount"" ) ) ext4_msg ( sb , KERN_INFO , ""mountedfilesystemwith%s."" ""Opts:%.*s%s%s"" , descr , ( int ) sizeof ( sbi -> s_es -> s_mount_opts ) , sbi -> s_es -> s_mount_opts , * sbi -> s_es -> s_mount_opts ? "";"" : """" , orig_data ) ; if ( es -> s_error_count ) mod_timer ( & sbi -> s_err_report , jiffies + 300 * HZ ) ; ratelimit_state_init ( & sbi -> s_err_ratelimit_state , 5 * HZ , 10 ) ; ratelimit_state_init ( & sbi -> s_warning_ratelimit_state , 5 * HZ , 10 ) ; ratelimit_state_init ( & sbi -> s_msg_ratelimit_state , 5 * HZ , 10 ) ; kfree ( orig_data ) ; # ifdef CONFIG_EXT4_FS_ENCRYPTION memcpy ( sbi -> key_prefix , EXT4_KEY_DESC_PREFIX , EXT4_KEY_DESC_PREFIX_SIZE ) ; sbi -> key_prefix_size = EXT4_KEY_DESC_PREFIX_SIZE ; # endif return 0 ; cantfind_ext4 : if ( ! silent ) ext4_msg ( sb , KERN_ERR , ""VFS:Can\'tfindext4filesystem"" ) ; goto failed_mount ; # ifdef CONFIG_QUOTA failed_mount8 : ext4_unregister_sysfs ( sb ) ; # endif failed_mount7 : ext4_unregister_li_request ( sb ) ; failed_mount6 : ext4_mb_release ( sb ) ; if ( sbi -> s_flex_groups ) kvfree ( sbi -> s_flex_groups ) ; percpu_counter_destroy ( & sbi -> s_freeclusters_counter ) ; percpu_counter_destroy ( & sbi -> s_freeinodes_counter ) ; percpu_counter_destroy ( & sbi -> s_dirs_counter ) ; percpu_counter_destroy ( & sbi -> s_dirtyclusters_counter ) ; failed_mount5 : ext4_ext_release ( sb ) ; ext4_release_system_zone ( sb ) ; failed_mount4a : dput ( sb -> s_root ) ; sb -> s_root = NULL ; failed_mount4 : ext4_msg ( sb , KERN_ERR , ""mountfailed"" ) ; if ( EXT4_SB ( sb ) -> rsv_conversion_wq ) destroy_workqueue ( EXT4_SB ( sb ) -> rsv_conversion_wq ) ; failed_mount_wq : if ( sbi -> s_mb_cache ) { ext4_xattr_destroy_cache ( sbi -> s_mb_cache ) ; sbi -> s_mb_cache = NULL ; } if ( sbi -> s_journal ) { jbd2_journal_destroy ( sbi -> s_journal ) ; sbi -> s_journal = NULL ; } failed_mount3a : ext4_es_unregister_shrinker ( sbi ) ; failed_mount3 : del_timer_sync ( & sbi -> s_err_report ) ; if ( sbi -> s_mmp_tsk ) kthread_stop ( sbi -> s_mmp_tsk ) ; failed_mount2 : for ( i = 0 ; i < db_count ; i ++ ) brelse ( sbi -> s_group_desc [ i ] ) ; kvfree ( sbi -> s_group_desc ) ; failed_mount : if ( sbi -> s_chksum_driver ) crypto_free_shash ( sbi -> s_chksum_driver ) ; # ifdef CONFIG_QUOTA for ( i = 0 ; i < EXT4_MAXQUOTAS ; i ++ ) kfree ( sbi -> s_qf_names [ i ] ) ; # endif ext4_blkdev_remove ( sbi ) ; brelse ( bh ) ; out_fail : sb -> s_fs_info = NULL ; kfree ( sbi -> s_blockgroup_lock ) ; out_free_base : kfree ( sbi ) ; kfree ( orig_data ) ; return err ? err : ret ; } "," sb ) ; if ( ext4_has_feature_meta_bg ( sb ) ) { if ( le32_to_cpu ( es -> s_first_meta_bg ) >= db_count ) { ext4_msg ( sb , KERN_WARNING , ""firstmetablockgrouptoolarge:%u"" ""(groupdescriptorblockcount%u)"" , le32_to_cpu ( es -> s_first_meta_bg ) , db_count ) ; goto failed_mount ; } } ",torvalds@linux/3a4b77cd47bb837b8557595ec7425f281f2ca1fe,CVE-2016-10208,https://github.com/torvalds/linux/commit/3a4b77cd47bb837b8557595ec7425f281f2ca1fe,2017-02-06T06:59Z 1536,CWE-476,"CWE-476 static void ov518_mode_init_regs ( struct sd * sd ) { struct gspca_dev * gspca_dev = ( struct gspca_dev * ) sd ; int hsegs , vsegs , packet_size ; struct usb_host_interface * alt ; struct usb_interface * intf ; intf = usb_ifnum_to_if ( sd -> gspca_dev . dev , sd -> gspca_dev . iface ) ; alt = usb_altnum_to_altsetting ( intf , sd -> gspca_dev . alt ) ; if ( ! alt ) { gspca_err ( gspca_dev , ""Couldn\'tgetaltsetting\\n"" ) ; sd -> gspca_dev . usb_err = - EIO ; return ; } packet_size = le16_to_cpu ( alt -> endpoint [ 0 ] . desc . wMaxPacketSize ) ; ov518_reg_w32 ( sd , R51x_FIFO_PSIZE , packet_size & ~ 7 , 2 ) ; reg_w ( sd , 0x2b , 0 ) ; reg_w ( sd , 0x2c , 0 ) ; reg_w ( sd , 0x2d , 0 ) ; reg_w ( sd , 0x2e , 0 ) ; reg_w ( sd , 0x3b , 0 ) ; reg_w ( sd , 0x3c , 0 ) ; reg_w ( sd , 0x3d , 0 ) ; reg_w ( sd , 0x3e , 0 ) ; if ( sd -> bridge == BRIDGE_OV518 ) { reg_w_mask ( sd , 0x20 , 0x08 , 0x08 ) ; reg_w_mask ( sd , 0x28 , 0x80 , 0xf0 ) ; reg_w_mask ( sd , 0x38 , 0x80 , 0xf0 ) ; } else { reg_w ( sd , 0x28 , 0x80 ) ; reg_w ( sd , 0x38 , 0x80 ) ; } hsegs = sd -> gspca_dev . pixfmt . width / 16 ; vsegs = sd -> gspca_dev . pixfmt . height / 4 ; reg_w ( sd , 0x29 , hsegs ) ; reg_w ( sd , 0x2a , vsegs ) ; reg_w ( sd , 0x39 , hsegs ) ; reg_w ( sd , 0x3a , vsegs ) ; reg_w ( sd , 0x2f , 0x80 ) ; if ( sd -> bridge == BRIDGE_OV518PLUS && sd -> revision == 0 && sd -> sensor == SEN_OV7620AE ) sd -> clockdiv = 0 ; else sd -> clockdiv = 1 ; reg_w ( sd , 0x51 , 0x04 ) ; reg_w ( sd , 0x22 , 0x18 ) ; reg_w ( sd , 0x23 , 0xff ) ; if ( sd -> bridge == BRIDGE_OV518PLUS ) { switch ( sd -> sensor ) { case SEN_OV7620AE : if ( sd -> revision > 0 && sd -> gspca_dev . pixfmt . width == 640 ) { reg_w ( sd , 0x20 , 0x60 ) ; reg_w ( sd , 0x21 , 0x1f ) ; } else { reg_w ( sd , 0x20 , 0x00 ) ; reg_w ( sd , 0x21 , 0x19 ) ; } break ; case SEN_OV7620 : reg_w ( sd , 0x20 , 0x00 ) ; reg_w ( sd , 0x21 , 0x19 ) ; break ; default : reg_w ( sd , 0x21 , 0x19 ) ; } } else reg_w ( sd , 0x71 , 0x17 ) ; i2c_w ( sd , 0x54 , 0x23 ) ; reg_w ( sd , 0x2f , 0x80 ) ; if ( sd -> bridge == BRIDGE_OV518PLUS ) { reg_w ( sd , 0x24 , 0x94 ) ; reg_w ( sd , 0x25 , 0x90 ) ; ov518_reg_w32 ( sd , 0xc4 , 400 , 2 ) ; ov518_reg_w32 ( sd , 0xc6 , 540 , 2 ) ; ov518_reg_w32 ( sd , 0xc7 , 540 , 2 ) ; ov518_reg_w32 ( sd , 0xc8 , 108 , 2 ) ; ov518_reg_w32 ( sd , 0xca , 131098 , 3 ) ; ov518_reg_w32 ( sd , 0xcb , 532 , 2 ) ; ov518_reg_w32 ( sd , 0xcc , 2400 , 2 ) ; ov518_reg_w32 ( sd , 0xcd , 32 , 2 ) ; ov518_reg_w32 ( sd , 0xce , 608 , 2 ) ; } else { reg_w ( sd , 0x24 , 0x9f ) ; reg_w ( sd , 0x25 , 0x90 ) ; ov518_reg_w32 ( sd , 0xc4 , 400 , 2 ) ; ov518_reg_w32 ( sd , 0xc6 , 381 , 2 ) ; ov518_reg_w32 ( sd , 0xc7 , 381 , 2 ) ; ov518_reg_w32 ( sd , 0xc8 , 128 , 2 ) ; ov518_reg_w32 ( sd , 0xca , 183331 , 3 ) ; ov518_reg_w32 ( sd , 0xcb , 746 , 2 ) ; ov518_reg_w32 ( sd , 0xcc , 1750 , 2 ) ; ov518_reg_w32 ( sd , 0xcd , 45 , 2 ) ; ov518_reg_w32 ( sd , 0xce , 851 , 2 ) ; } reg_w ( sd , 0x2f , 0x80 ) ; } "," return ; } if ( alt -> desc . bNumEndpoints < 1 ) { sd -> gspca_dev . usb_err = - ENODEV ; return ; } ",torvalds@linux/998912346c0da53a6dbb71fab3a138586b596b30,CVE-2020-11608,https://github.com/torvalds/linux/commit/998912346c0da53a6dbb71fab3a138586b596b30,2020-04-07T14:15Z 1537,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 1538,CWE-264,"CWE-264 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 1539,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 1540,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 1541,CWE-190,"CWE-190 int ip6_find_1stfragopt ( struct sk_buff * skb , u8 * * nexthdr ) { u16 offset = sizeof ( struct ipv6hdr ) ; unsigned int packet_len = skb_tail_pointer ( skb ) - skb_network_header ( skb ) ; int found_rhdr = 0 ; * nexthdr = & ipv6_hdr ( skb ) -> nexthdr ; while ( offset <= packet_len ) { struct ipv6_opt_hdr * exthdr ; 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 ; } if ( offset + sizeof ( struct ipv6_opt_hdr ) > packet_len ) return - EINVAL ; exthdr = ( struct ipv6_opt_hdr * ) ( skb_network_header ( skb ) + offset ) ; offset += ipv6_optlen ( exthdr ) ; * nexthdr = & exthdr -> nexthdr ; } return - EINVAL ; } "," nexthdr ) { unsigned int offset = sizeof * exthdr ; unsigned int len ; offset ) ; len = ipv6_optlen ( exthdr ) ; if ( len + offset >= IPV6_MAXPLEN ) return - EINVAL ; offset += len ; * nexthdr ",torvalds@linux/6399f1fae4ec29fab5ec76070435555e256ca3a6,CVE-2017-7542,https://github.com/torvalds/linux/commit/6399f1fae4ec29fab5ec76070435555e256ca3a6,2017-07-21T16:29Z 1542,CWE-000,"CWE-000 static Image * handle_add_command ( GraphicsManager * self , const GraphicsCommand * g , const uint8_t * payload , bool * is_dirty , uint32_t iid ) { # define ABRT ( code , ... ) { set_add_response ( # code , __VA_ARGS__ ) ; self -> loading_image = 0 ; if ( img ) img -> data_loaded = false ; return NULL ; } # define MAX_DATA_SZ ( 4u * 100000000u ) has_add_respose = false ; bool existing , init_img = true ; Image * img = NULL ; unsigned char tt = g -> transmission_type ? g -> transmission_type : 'd' ; enum FORMATS { RGB = 24 , RGBA = 32 , PNG = 100 } ; uint32_t fmt = g -> format ? g -> format : RGBA ; if ( tt == 'd' && self -> loading_image ) init_img = false ; if ( init_img ) { self -> last_init_graphics_command = * g ; self -> last_init_graphics_command . id = iid ; self -> loading_image = 0 ; if ( g -> data_width > 10000 || g -> data_height > 10000 ) ABRT ( EINVAL , ""Imagetoolarge"" ) ; remove_images ( self , add_trim_predicate , 0 ) ; img = find_or_create_image ( self , iid , & existing ) ; if ( existing ) { free_load_data ( & img -> load_data ) ; img -> data_loaded = false ; free_refs_data ( img ) ; * is_dirty = true ; self -> layers_dirty = true ; } else { img -> internal_id = internal_id_counter ++ ; img -> client_id = iid ; } img -> atime = monotonic ( ) ; img -> used_storage = 0 ; img -> width = g -> data_width ; img -> height = g -> data_height ; switch ( fmt ) { case PNG : if ( g -> data_sz > MAX_DATA_SZ ) ABRT ( EINVAL , ""PNGdatasizetoolarge"" ) ; img -> load_data . is_4byte_aligned = true ; img -> load_data . is_opaque = false ; img -> load_data . data_sz = g -> data_sz ? g -> data_sz : 1024 * 100 ; break ; case RGB : case RGBA : img -> load_data . data_sz = ( size_t ) g -> data_width * g -> data_height * ( fmt / 8 ) ; if ( ! img -> load_data . data_sz ) ABRT ( EINVAL , ""Zerowidth/heightnotallowed"" ) ; img -> load_data . is_4byte_aligned = fmt == RGBA || ( img -> width % 4 == 0 ) ; img -> load_data . is_opaque = fmt == RGB ; break ; default : ABRT ( EINVAL , ""Unknownimageformat:%u"" , fmt ) ; } if ( tt == 'd' ) { if ( g -> more ) self -> loading_image = img -> internal_id ; img -> load_data . buf_capacity = img -> load_data . data_sz + ( g -> compressed ? 1024 : 10 ) ; img -> load_data . buf = malloc ( img -> load_data . buf_capacity ) ; img -> load_data . buf_used = 0 ; if ( img -> load_data . buf == NULL ) { ABRT ( ENOMEM , ""Outofmemory"" ) ; img -> load_data . buf_capacity = 0 ; img -> load_data . buf_used = 0 ; } } } else { self -> last_init_graphics_command . more = g -> more ; self -> last_init_graphics_command . payload_sz = g -> payload_sz ; g = & self -> last_init_graphics_command ; tt = g -> transmission_type ? g -> transmission_type : 'd' ; fmt = g -> format ? g -> format : RGBA ; img = img_by_internal_id ( self , self -> loading_image ) ; if ( img == NULL ) { self -> loading_image = 0 ; ABRT ( EILSEQ , ""Morepayloadloadingreferstonon-existentimage"" ) ; } } int fd ; static char fname [ 2056 ] = { 0 } ; switch ( tt ) { case 'd' : if ( img -> load_data . buf_capacity - img -> load_data . buf_used < g -> payload_sz ) { if ( img -> load_data . buf_used + g -> payload_sz > MAX_DATA_SZ || fmt != PNG ) ABRT ( EFBIG , ""Toomuchdata"" ) ; img -> load_data . buf_capacity = MIN ( 2 * img -> load_data . buf_capacity , MAX_DATA_SZ ) ; img -> load_data . buf = realloc ( img -> load_data . buf , img -> load_data . buf_capacity ) ; if ( img -> load_data . buf == NULL ) { ABRT ( ENOMEM , ""Outofmemory"" ) ; img -> load_data . buf_capacity = 0 ; img -> load_data . buf_used = 0 ; } } memcpy ( img -> load_data . buf + img -> load_data . buf_used , payload , g -> payload_sz ) ; img -> load_data . buf_used += g -> payload_sz ; if ( ! g -> more ) { img -> data_loaded = true ; self -> loading_image = 0 ; } break ; case 'f' : case 't' : case 's' : if ( g -> payload_sz > 2048 ) ABRT ( EINVAL , ""Filenametoolong"" ) ; snprintf ( fname , sizeof ( fname ) / sizeof ( fname [ 0 ] ) , ""%.*s"" , ( int ) g -> payload_sz , payload ) ; if ( tt == 's' ) fd = shm_open ( fname , O_RDONLY , 0 ) ; else fd = open ( fname , O_CLOEXEC | O_RDONLY ) ; if ( fd == - 1 ) ABRT ( EBADF , ""Failedtoopenfile%sforgraphicstransmissionwitherror:[%d]%s"" , fname , errno , strerror ( errno ) ) ; img -> data_loaded = mmap_img_file ( self , img , fd , g -> data_sz , g -> data_offset ) ; safe_close ( fd , __FILE__ , __LINE__ ) ; if ( tt == 't' ) { if ( global_state . boss ) { call_boss ( safe_delete_temp_file , ""s"" , fname ) ; } else unlink ( fname ) ; } else if ( tt == 's' ) shm_unlink ( fname ) ; break ; default : ABRT ( EINVAL , ""Unknowntransmissiontype:%c"" , g -> transmission_type ) ; } if ( ! img -> data_loaded ) return NULL ; self -> loading_image = 0 ; bool needs_processing = g -> compressed || fmt == PNG ; if ( needs_processing ) { uint8_t * buf ; size_t bufsz ; # define IB { if ( img -> load_data . buf ) { buf = img -> load_data . buf ; bufsz = img -> load_data . buf_used ; } else { buf = img -> load_data . mapped_file ; bufsz = img -> load_data . mapped_file_sz ; } } switch ( g -> compressed ) { case 'z' : IB ; if ( ! inflate_zlib ( self , img , buf , bufsz ) ) { img -> data_loaded = false ; return NULL ; } break ; case 0 : break ; default : ABRT ( EINVAL , ""Unknownimagecompression:%c"" , g -> compressed ) ; } switch ( fmt ) { case PNG : IB ; if ( ! inflate_png ( self , img , buf , bufsz ) ) { img -> data_loaded = false ; return NULL ; } break ; default : break ; } # undef IB img -> load_data . data = img -> load_data . buf ; if ( img -> load_data . buf_used < img -> load_data . data_sz ) { ABRT ( ENODATA , ""Insufficientimagedata:%zu<%zu"" , img -> load_data . buf_used , img -> load_data . data_sz ) ; } if ( img -> load_data . mapped_file ) { munmap ( img -> load_data . mapped_file , img -> load_data . mapped_file_sz ) ; img -> load_data . mapped_file = NULL ; img -> load_data . mapped_file_sz = 0 ; } } else { if ( tt == 'd' ) { if ( img -> load_data . buf_used < img -> load_data . data_sz ) { ABRT ( ENODATA , ""Insufficientimagedata:%zu<%zu"" , img -> load_data . buf_used , img -> load_data . data_sz ) ; } else img -> load_data . data = img -> load_data . buf ; } else { if ( img -> load_data . mapped_file_sz < img -> load_data . data_sz ) { ABRT ( ENODATA , ""Insufficientimagedata:%zu<%zu"" , img -> load_data . mapped_file_sz , img -> load_data . data_sz ) ; } else img -> load_data . data = img -> load_data . mapped_file ; } } size_t required_sz = ( size_t ) ( img -> load_data . is_opaque ? 3 : 4 ) * img -> width * img -> height ; if ( img -> load_data . data_sz != required_sz ) ABRT ( EINVAL , ""Imagedimensions:%ux%udonotmatchdatasize:%zu,expectedsize:%zu"" , img -> width , img -> height , img -> load_data . data_sz , required_sz ) ; if ( LIKELY ( img -> data_loaded && send_to_gpu ) ) { send_image_to_gpu ( & img -> texture_id , img -> load_data . data , img -> width , img -> height , img -> load_data . is_opaque , img -> load_data . is_4byte_aligned , false , REPEAT_CLAMP ) ; free_load_data ( & img -> load_data ) ; self -> used_storage += required_sz ; img -> used_storage = required_sz ; } return img ; # undef MAX_DATA_SZ # undef ABRT } "," ( EBADF , ""Failedtoopenfileforgraphicstransmissionwitherror:[%d]%s"" , errno , ",kovidgoyal@kitty/82c137878c2b99100a3cdc1c0f0efea069313901,CVE-2020-35605,https://github.com/kovidgoyal/kitty/commit/82c137878c2b99100a3cdc1c0f0efea069313901,2020-12-21T20:15Z 1543,CWE-200,"CWE-200 void rds_inc_info_copy ( struct rds_incoming * inc , struct rds_info_iterator * iter , __be32 saddr , __be32 daddr , int flip ) { struct rds_info_message minfo ; minfo . seq = be64_to_cpu ( inc -> i_hdr . h_sequence ) ; minfo . len = be32_to_cpu ( inc -> i_hdr . h_len ) ; if ( flip ) { minfo . laddr = daddr ; minfo . faddr = saddr ; minfo . lport = inc -> i_hdr . h_dport ; minfo . fport = inc -> i_hdr . h_sport ; } else { minfo . laddr = saddr ; minfo . faddr = daddr ; minfo . lport = inc -> i_hdr . h_sport ; minfo . fport = inc -> i_hdr . h_dport ; } rds_info_copy ( iter , & minfo , sizeof ( minfo ) ) ; } "," h_dport ; } minfo . flags = 0 ; ",torvalds@linux/4116def2337991b39919f3b448326e21c40e0dbb,CVE-2016-5244,https://github.com/torvalds/linux/commit/4116def2337991b39919f3b448326e21c40e0dbb,2016-06-27T10:59Z 1544,CWE-362,"CWE-362 static int ip_setup_cork ( struct sock * sk , struct inet_cork * cork , struct ipcm_cookie * ipc , struct rtable * * rtp ) { struct inet_sock * inet = inet_sk ( sk ) ; struct ip_options * opt ; struct rtable * rt ; opt = ipc -> opt ; if ( opt ) { if ( cork -> opt == NULL ) { cork -> opt = kmalloc ( sizeof ( struct ip_options ) + 40 , sk -> sk_allocation ) ; if ( unlikely ( cork -> opt == NULL ) ) return - ENOBUFS ; } memcpy ( cork -> opt , opt , sizeof ( struct ip_options ) + opt -> optlen ) ; cork -> flags |= IPCORK_OPT ; cork -> addr = ipc -> addr ; } rt = * rtp ; if ( unlikely ( ! rt ) ) return - EFAULT ; * rtp = NULL ; cork -> fragsize = inet -> pmtudisc == IP_PMTUDISC_PROBE ? rt -> dst . dev -> mtu : dst_mtu ( rt -> dst . path ) ; cork -> dst = & rt -> dst ; cork -> length = 0 ; cork -> tx_flags = ipc -> tx_flags ; cork -> page = NULL ; cork -> off = 0 ; return 0 ; } "," ) ; struct ip_options_rcu * opt ; -> opt , & opt -> + opt -> opt . ",torvalds@linux/f6d8bd051c391c1c0458a30b2a7abcd939329259,CVE-2012-3552,https://github.com/torvalds/linux/commit/f6d8bd051c391c1c0458a30b2a7abcd939329259,2012-10-03T11:02Z 1545,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 1546,CWE-200,"CWE-200 static void copy_to_user_policy ( struct xfrm_policy * xp , struct xfrm_userpolicy_info * p , int dir ) { memcpy ( & p -> sel , & xp -> selector , sizeof ( p -> sel ) ) ; memcpy ( & p -> lft , & xp -> lft , sizeof ( p -> lft ) ) ; memcpy ( & p -> curlft , & xp -> curlft , sizeof ( p -> curlft ) ) ; p -> priority = xp -> priority ; p -> index = xp -> index ; p -> sel . family = xp -> family ; p -> dir = dir ; p -> action = xp -> action ; p -> flags = xp -> flags ; p -> share = XFRM_SHARE_ANY ; } "," dir ) { memset ( p , 0 , sizeof ( * p ) ) ; ",torvalds@linux/7b789836f434c87168eab067cfbed1ec4783dffd,CVE-2012-6537,https://github.com/torvalds/linux/commit/7b789836f434c87168eab067cfbed1ec4783dffd,2013-03-15T20:55Z 1547,CWE-264,"CWE-264 static void setup_test_dir ( char * tmp_dir , const char * files , ... ) { va_list ap ; assert_se ( mkdtemp ( tmp_dir ) != NULL ) ; va_start ( ap , files ) ; while ( files != NULL ) { _cleanup_free_ char * path = strappend ( tmp_dir , files ) ; assert_se ( touch_file ( path , true , USEC_INFINITY , UID_INVALID , GID_INVALID , 0 ) == 0 ) ; files = va_arg ( ap , const char * ) ; } va_end ( ap ) ; } "," , GID_INVALID , MODE_INVALID ) == 0 ",systemd@systemd/ee735086f8670be1591fa9593e80dd60163a7a2f,CVE-2016-10156,https://github.com/systemd/systemd/commit/ee735086f8670be1591fa9593e80dd60163a7a2f,2017-01-23T07:59Z 1548,CWE-119,"CWE-119 static INLINE void add_token_no_extra ( TOKENEXTRA * * t , const vp9_prob * context_tree , uint8_t token , uint8_t skip_eob_node , unsigned int * counts ) { ( * t ) -> token = token ; ( * t ) -> context_tree = context_tree ; ( * t ) -> skip_eob_node = skip_eob_node ; ( * t ) ++ ; ++ counts [ token ] ; } "," t , const vpx_prob * context_tree , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1549,CWE-000,"CWE-000 static int crypto_report_one ( struct crypto_alg * alg , struct crypto_user_alg * ualg , struct sk_buff * skb ) { strlcpy ( ualg -> cru_name , alg -> cra_name , sizeof ( ualg -> cru_name ) ) ; strlcpy ( ualg -> cru_driver_name , alg -> cra_driver_name , sizeof ( ualg -> cru_driver_name ) ) ; strlcpy ( ualg -> cru_module_name , module_name ( alg -> cra_module ) , sizeof ( ualg -> cru_module_name ) ) ; ualg -> cru_type = 0 ; ualg -> cru_mask = 0 ; ualg -> cru_flags = alg -> cra_flags ; ualg -> cru_refcnt = refcount_read ( & alg -> cra_refcnt ) ; if ( nla_put_u32 ( skb , CRYPTOCFGA_PRIORITY_VAL , alg -> cra_priority ) ) goto nla_put_failure ; if ( alg -> cra_flags & CRYPTO_ALG_LARVAL ) { struct crypto_report_larval rl ; strlcpy ( rl . type , ""larval"" , sizeof ( rl . type ) ) ; if ( nla_put ( skb , CRYPTOCFGA_REPORT_LARVAL , sizeof ( struct crypto_report_larval ) , & rl ) ) goto nla_put_failure ; goto out ; } if ( alg -> cra_type && alg -> cra_type -> report ) { if ( alg -> cra_type -> report ( skb , alg ) ) goto nla_put_failure ; goto out ; } switch ( alg -> cra_flags & ( CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_LARVAL ) ) { case CRYPTO_ALG_TYPE_CIPHER : if ( crypto_report_cipher ( skb , alg ) ) goto nla_put_failure ; break ; case CRYPTO_ALG_TYPE_COMPRESS : if ( crypto_report_comp ( skb , alg ) ) goto nla_put_failure ; break ; case CRYPTO_ALG_TYPE_ACOMPRESS : if ( crypto_report_acomp ( skb , alg ) ) goto nla_put_failure ; break ; case CRYPTO_ALG_TYPE_AKCIPHER : if ( crypto_report_akcipher ( skb , alg ) ) goto nla_put_failure ; break ; case CRYPTO_ALG_TYPE_KPP : if ( crypto_report_kpp ( skb , alg ) ) goto nla_put_failure ; break ; } out : return 0 ; nla_put_failure : return - EMSGSIZE ; } "," skb ) { strncpy ( ualg -> ) ) ; strncpy ( ualg -> ) ) ; strncpy ( ualg -> crypto_report_larval rl ; strncpy ( rl . ",torvalds@linux/f43f39958beb206b53292801e216d9b8a660f087,CVE-2018-19854,https://github.com/torvalds/linux/commit/f43f39958beb206b53292801e216d9b8a660f087,2018-12-04T16:29Z 1550,CWE-416,"CWE-416 static int packet_setsockopt ( struct socket * sock , int level , int optname , char __user * optval , unsigned int optlen ) { struct sock * sk = sock -> sk ; struct packet_sock * po = pkt_sk ( sk ) ; int ret ; if ( level != SOL_PACKET ) return - ENOPROTOOPT ; switch ( optname ) { case PACKET_ADD_MEMBERSHIP : case PACKET_DROP_MEMBERSHIP : { struct packet_mreq_max mreq ; int len = optlen ; memset ( & mreq , 0 , sizeof ( mreq ) ) ; if ( len < sizeof ( struct packet_mreq ) ) return - EINVAL ; if ( len > sizeof ( mreq ) ) len = sizeof ( mreq ) ; if ( copy_from_user ( & mreq , optval , len ) ) return - EFAULT ; if ( len < ( mreq . mr_alen + offsetof ( struct packet_mreq , mr_address ) ) ) return - EINVAL ; if ( optname == PACKET_ADD_MEMBERSHIP ) ret = packet_mc_add ( sk , & mreq ) ; else ret = packet_mc_drop ( sk , & mreq ) ; return ret ; } case PACKET_RX_RING : case PACKET_TX_RING : { union tpacket_req_u req_u ; int len ; switch ( po -> tp_version ) { case TPACKET_V1 : case TPACKET_V2 : len = sizeof ( req_u . req ) ; break ; case TPACKET_V3 : default : len = sizeof ( req_u . req3 ) ; break ; } if ( optlen < len ) return - EINVAL ; if ( copy_from_user ( & req_u . req , optval , len ) ) return - EFAULT ; return packet_set_ring ( sk , & req_u , 0 , optname == PACKET_TX_RING ) ; } case PACKET_COPY_THRESH : { int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; pkt_sk ( sk ) -> copy_thresh = val ; return 0 ; } case PACKET_VERSION : { int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( po -> rx_ring . pg_vec || po -> tx_ring . pg_vec ) return - EBUSY ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; switch ( val ) { case TPACKET_V1 : case TPACKET_V2 : case TPACKET_V3 : po -> tp_version = val ; return 0 ; default : return - EINVAL ; } } case PACKET_RESERVE : { unsigned int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( po -> rx_ring . pg_vec || po -> tx_ring . pg_vec ) return - EBUSY ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> tp_reserve = val ; return 0 ; } case PACKET_LOSS : { unsigned int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( po -> rx_ring . pg_vec || po -> tx_ring . pg_vec ) return - EBUSY ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> tp_loss = ! ! val ; return 0 ; } case PACKET_AUXDATA : { int val ; if ( optlen < sizeof ( val ) ) return - EINVAL ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> auxdata = ! ! val ; return 0 ; } case PACKET_ORIGDEV : { int val ; if ( optlen < sizeof ( val ) ) return - EINVAL ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> origdev = ! ! val ; return 0 ; } case PACKET_VNET_HDR : { int val ; if ( sock -> type != SOCK_RAW ) return - EINVAL ; if ( po -> rx_ring . pg_vec || po -> tx_ring . pg_vec ) return - EBUSY ; if ( optlen < sizeof ( val ) ) return - EINVAL ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> has_vnet_hdr = ! ! val ; return 0 ; } case PACKET_TIMESTAMP : { int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> tp_tstamp = val ; return 0 ; } case PACKET_FANOUT : { int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; return fanout_add ( sk , val & 0xffff , val >> 16 ) ; } case PACKET_FANOUT_DATA : { if ( ! po -> fanout ) return - EINVAL ; return fanout_set_data ( po , optval , optlen ) ; } case PACKET_TX_HAS_OFF : { unsigned int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( po -> rx_ring . pg_vec || po -> tx_ring . pg_vec ) return - EBUSY ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> tp_tx_has_off = ! ! val ; return 0 ; } case PACKET_QDISC_BYPASS : { int val ; if ( optlen != sizeof ( val ) ) return - EINVAL ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; po -> xmit = val ? packet_direct_xmit : dev_queue_xmit ; return 0 ; } default : return - ENOPROTOOPT ; } } "," ; if ( copy_from_user ( & val , optval , sizeof ( val ) ) ) return - EFAULT ; switch ( val ) { case TPACKET_V1 : case TPACKET_V2 : case TPACKET_V3 : break ; default : return - EINVAL ; } lock_sock ( sk ) ; if ( . pg_vec ) { ret = - EBUSY ; - EBUSY ; } else { po -> tp_version = val ; ret = 0 ; } release_sock ( sk ) ; return ret ; } case PACKET_RESERVE ",torvalds@linux/84ac7260236a49c79eede91617700174c2c19b0c,CVE-2016-8655,https://github.com/torvalds/linux/commit/84ac7260236a49c79eede91617700174c2c19b0c,2016-12-08T08:59Z 1551,CWE-476,"CWE-476 static int dissect_u3v ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree , void * data ) { gint offset = 0 ; proto_tree * u3v_tree = NULL , * ccd_tree_flag , * u3v_telegram_tree = NULL , * ccd_tree = NULL ; gint data_length = 0 ; gint req_id = 0 ; gint command_id = - 1 ; gint status = 0 ; guint prefix = 0 ; proto_item * ti = NULL ; proto_item * item = NULL ; const char * command_string ; usb_conv_info_t * usb_conv_info ; gint stream_detected = FALSE ; gint control_detected = FALSE ; u3v_conv_info_t * u3v_conv_info = NULL ; gencp_transaction_t * gencp_trans = NULL ; usb_conv_info = ( usb_conv_info_t * ) data ; u3v_conv_info = ( u3v_conv_info_t * ) usb_conv_info -> class_data ; if ( ! u3v_conv_info ) { u3v_conv_info = wmem_new0 ( wmem_file_scope ( ) , u3v_conv_info_t ) ; usb_conv_info -> class_data = u3v_conv_info ; } prefix = tvb_get_letohl ( tvb , 0 ) ; if ( ( tvb_reported_length ( tvb ) >= 4 ) && ( ( U3V_CONTROL_PREFIX == prefix ) || ( U3V_EVENT_PREFIX == prefix ) ) ) { control_detected = TRUE ; } if ( ( ( tvb_reported_length ( tvb ) >= 4 ) && ( ( U3V_STREAM_LEADER_PREFIX == prefix ) || ( U3V_STREAM_TRAILER_PREFIX == prefix ) ) ) || ( usb_conv_info -> endpoint == u3v_conv_info -> ep_stream ) ) { stream_detected = TRUE ; } if ( control_detected || stream_detected ) { if ( usb_conv_info -> interfaceClass == IF_CLASS_UNKNOWN && usb_conv_info -> interfaceSubclass == IF_SUBCLASS_UNKNOWN ) { usb_conv_info -> interfaceClass = IF_CLASS_MISCELLANEOUS ; usb_conv_info -> interfaceSubclass = IF_SUBCLASS_MISC_U3V ; } } if ( control_detected ) { col_set_str ( pinfo -> cinfo , COL_PROTOCOL , ""U3V"" ) ; col_clear ( pinfo -> cinfo , COL_INFO ) ; ti = proto_tree_add_item ( tree , proto_u3v , tvb , offset , - 1 , ENC_NA ) ; u3v_tree = proto_item_add_subtree ( ti , ett_u3v ) ; prefix = tvb_get_letohl ( tvb , offset ) ; command_id = tvb_get_letohs ( tvb , offset + 6 ) ; if ( ( prefix == U3V_CONTROL_PREFIX || prefix == U3V_EVENT_PREFIX ) && ( ( command_id % 2 ) == 0 ) ) { command_string = val_to_str ( command_id , command_names , ""UnknownCommand(0x%x)"" ) ; item = proto_tree_add_item ( u3v_tree , hf_u3v_ccd_cmd , tvb , offset , 8 , ENC_NA ) ; proto_item_append_text ( item , "":%s"" , command_string ) ; ccd_tree = proto_item_add_subtree ( item , ett_u3v_cmd ) ; proto_tree_add_item ( ccd_tree , hf_u3v_gencp_prefix , tvb , offset , 4 , ENC_LITTLE_ENDIAN ) ; offset += 4 ; item = proto_tree_add_item ( ccd_tree , hf_u3v_flag , tvb , offset , 2 , ENC_LITTLE_ENDIAN ) ; ccd_tree_flag = proto_item_add_subtree ( item , ett_u3v_flags ) ; proto_tree_add_item ( ccd_tree_flag , hf_u3v_acknowledge_required_flag , tvb , offset , 2 , ENC_LITTLE_ENDIAN ) ; offset += 2 ; col_append_fstr ( pinfo -> cinfo , COL_INFO , "">%s"" , command_string ) ; } else if ( prefix == U3V_CONTROL_PREFIX && ( ( command_id % 2 ) == 1 ) ) { command_string = val_to_str ( command_id , command_names , ""UnknownAcknowledge(0x%x)"" ) ; item = proto_tree_add_item ( u3v_tree , hf_u3v_ccd_ack , tvb , offset , 8 , ENC_NA ) ; proto_item_append_text ( item , "":%s"" , command_string ) ; ccd_tree = proto_item_add_subtree ( item , ett_u3v_ack ) ; proto_tree_add_item ( ccd_tree , hf_u3v_gencp_prefix , tvb , offset , 4 , ENC_LITTLE_ENDIAN ) ; offset += 4 ; proto_tree_add_item ( ccd_tree , hf_u3v_status , tvb , offset , 2 , ENC_LITTLE_ENDIAN ) ; status = tvb_get_letohs ( tvb , offset ) ; offset += 2 ; col_append_fstr ( pinfo -> cinfo , COL_INFO , ""<%s%s"" , command_string , val_to_str ( status , status_names_short , ""Unknownstatus(0x%04X)"" ) ) ; } else { return 0 ; } proto_tree_add_item ( ccd_tree , hf_u3v_command_id , tvb , offset , 2 , ENC_LITTLE_ENDIAN ) ; offset += 2 ; proto_tree_add_item ( ccd_tree , hf_u3v_length , tvb , offset , 2 , ENC_LITTLE_ENDIAN ) ; data_length = tvb_get_letohs ( tvb , offset ) ; offset += 2 ; proto_tree_add_item ( ccd_tree , hf_u3v_request_id , tvb , offset , 2 , ENC_LITTLE_ENDIAN ) ; req_id = tvb_get_letohs ( tvb , offset ) ; offset += 2 ; u3v_telegram_tree = proto_item_add_subtree ( u3v_tree , ett_u3v ) ; if ( ! PINFO_FD_VISITED ( pinfo ) ) { if ( ( command_id % 2 ) == 0 ) { gencp_trans = wmem_new ( wmem_file_scope ( ) , gencp_transaction_t ) ; gencp_trans -> cmd_frame = pinfo -> fd -> num ; gencp_trans -> ack_frame = 0 ; gencp_trans -> cmd_time = pinfo -> fd -> abs_ts ; p_add_proto_data ( wmem_file_scope ( ) , pinfo , proto_u3v , req_id , gencp_trans ) ; u3v_conv_info -> trans_info = gencp_trans ; } else { gencp_trans = u3v_conv_info -> trans_info ; if ( gencp_trans ) { gencp_trans -> ack_frame = pinfo -> fd -> num ; p_add_proto_data ( wmem_file_scope ( ) , pinfo , proto_u3v , req_id , gencp_trans ) ; } } } else { gencp_trans = ( gencp_transaction_t * ) p_get_proto_data ( wmem_file_scope ( ) , pinfo , proto_u3v , req_id ) ; } if ( ! gencp_trans ) { gencp_trans = wmem_new ( wmem_packet_scope ( ) , gencp_transaction_t ) ; gencp_trans -> cmd_frame = 0 ; gencp_trans -> ack_frame = 0 ; gencp_trans -> cmd_time = pinfo -> fd -> abs_ts ; } switch ( command_id ) { case U3V_READMEM_CMD : dissect_u3v_read_mem_cmd ( u3v_telegram_tree , tvb , pinfo , offset , data_length , u3v_conv_info , gencp_trans ) ; break ; case U3V_WRITEMEM_CMD : dissect_u3v_write_mem_cmd ( u3v_telegram_tree , tvb , pinfo , offset , data_length , u3v_conv_info , gencp_trans ) ; break ; case U3V_EVENT_CMD : dissect_u3v_event_cmd ( u3v_telegram_tree , tvb , pinfo , offset , data_length ) ; break ; case U3V_READMEM_ACK : if ( U3V_STATUS_GENCP_SUCCESS == status ) { dissect_u3v_read_mem_ack ( u3v_telegram_tree , tvb , pinfo , offset , data_length , u3v_conv_info , gencp_trans ) ; } break ; case U3V_WRITEMEM_ACK : dissect_u3v_write_mem_ack ( u3v_telegram_tree , tvb , pinfo , offset , data_length , u3v_conv_info , gencp_trans ) ; break ; case U3V_PENDING_ACK : dissect_u3v_pending_ack ( u3v_telegram_tree , tvb , pinfo , offset , data_length , u3v_conv_info , gencp_trans ) ; break ; default : proto_tree_add_item ( u3v_telegram_tree , hf_u3v_payloaddata , tvb , offset , data_length , ENC_NA ) ; break ; } return data_length + 12 ; } else if ( stream_detected ) { u3v_conv_info = ( u3v_conv_info_t * ) usb_conv_info -> class_data ; u3v_conv_info -> ep_stream = usb_conv_info -> endpoint ; col_set_str ( pinfo -> cinfo , COL_PROTOCOL , ""U3V"" ) ; col_clear ( pinfo -> cinfo , COL_INFO ) ; ti = proto_tree_add_item ( tree , proto_u3v , tvb , offset , - 1 , ENC_NA ) ; u3v_tree = proto_item_add_subtree ( ti , ett_u3v ) ; if ( tvb_captured_length ( tvb ) >= 4 ) { prefix = tvb_get_letohl ( tvb , offset ) ; switch ( prefix ) { case U3V_STREAM_LEADER_PREFIX : dissect_u3v_stream_leader ( u3v_tree , tvb , pinfo , usb_conv_info ) ; break ; case U3V_STREAM_TRAILER_PREFIX : dissect_u3v_stream_trailer ( u3v_tree , tvb , pinfo , usb_conv_info ) ; break ; default : dissect_u3v_stream_payload ( u3v_tree , tvb , pinfo , usb_conv_info ) ; break ; } } return tvb_captured_length ( tvb ) ; } return 0 ; } "," class_data = u3v_conv_info ; usb_conv_info -> class_data_type = USB_CONV_U3V ; } else if ( usb_conv_info -> class_data_type != USB_CONV_U3V ) { return 0 ",wireshark@wireshark/2cb5985bf47bdc8bea78d28483ed224abdd33dc6,CVE-2016-5354,https://github.com/wireshark/wireshark/commit/2cb5985bf47bdc8bea78d28483ed224abdd33dc6,2016-08-07T16:59Z 1552,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 1553,CWE-125,"CWE-125 static void voutf ( struct GlobalConfig * config , const char * prefix , const char * fmt , va_list ap ) { size_t width = ( 79 - strlen ( prefix ) ) ; if ( ! config -> mute ) { size_t len ; char * ptr ; char * print_buffer ; print_buffer = curlx_mvaprintf ( fmt , ap ) ; if ( ! print_buffer ) return ; len = strlen ( print_buffer ) ; ptr = print_buffer ; while ( len > 0 ) { fputs ( prefix , config -> errors ) ; if ( len > width ) { size_t cut = width - 1 ; while ( ! ISSPACE ( ptr [ cut ] ) && cut ) { cut -- ; } if ( 0 == cut ) cut = width - 1 ; ( void ) fwrite ( ptr , cut + 1 , 1 , config -> errors ) ; fputs ( ""\\n"" , config -> errors ) ; ptr += cut + 1 ; len -= cut ; } else { fputs ( ptr , config -> errors ) ; len = 0 ; } } curl_free ( print_buffer ) ; } } "," len -= cut + 1 ",curl@curl/d530e92f59ae9bb2d47066c3c460b25d2ffeb211,CVE-2018-16842,https://github.com/curl/curl/commit/d530e92f59ae9bb2d47066c3c460b25d2ffeb211,2018-10-31T19:29Z 1554,CWE-119,"CWE-119 void vp9_iht8x8_64_add_c ( const int16_t * input , uint8_t * dest , int stride , int tx_type ) { int i , j ; int16_t out [ 8 * 8 ] ; int16_t * outptr = out ; int16_t temp_in [ 8 ] , temp_out [ 8 ] ; const transform_2d ht = IHT_8 [ tx_type ] ; for ( i = 0 ; i < 8 ; ++ i ) { ht . rows ( input , outptr ) ; input += 8 ; outptr += 8 ; } for ( i = 0 ; i < 8 ; ++ i ) { for ( j = 0 ; j < 8 ; ++ j ) temp_in [ j ] = out [ j * 8 + i ] ; ht . cols ( temp_in , temp_out ) ; for ( j = 0 ; j < 8 ; ++ j ) dest [ j * stride + i ] = clip_pixel ( ROUND_POWER_OF_TWO ( temp_out [ j ] , 5 ) + dest [ j * stride + i ] ) ; } } "," vp9_iht8x8_64_add_c ( const tran_low_t * input , , j ; tran_low_t out [ 8 8 ] ; tran_low_t * outptr = = out ; tran_low_t temp_in [ 8 ++ j ) { i ] = clip_pixel_add ( dest [ j + i ] , ROUND_POWER_OF_TWO ( temp_out [ j ] , 5 ) ) ; } } } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1555,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 1556,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 1557,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 1558,CWE-415,"CWE-415 int read_file ( struct sc_card * card , char * str_path , unsigned char * * data , size_t * data_len ) { struct sc_path path ; struct sc_file * file ; unsigned char * p ; int ok = 0 ; int r ; size_t len ; sc_format_path ( str_path , & path ) ; if ( SC_SUCCESS != sc_select_file ( card , & path , & file ) ) { goto err ; } len = file ? file -> size : 4096 ; p = realloc ( * data , len ) ; if ( ! p ) { goto err ; } * data = p ; * data_len = len ; r = sc_read_binary ( card , 0 , p , len , 0 ) ; if ( r < 0 ) goto err ; * data_len = r ; ok = 1 ; err : sc_file_free ( file ) ; return ok ; } "," len = file && file -> size > 0 ",OpenSC@OpenSC/360e95d45ac4123255a4c796db96337f332160ad,CVE-2018-16425,https://github.com/OpenSC/OpenSC/commit/360e95d45ac4123255a4c796db96337f332160ad,2018-09-04T00:29Z 1559,CWE-200,"CWE-200 static int irda_recvmsg_dgram ( struct kiocb * iocb , struct socket * sock , struct msghdr * msg , size_t size , int flags ) { struct sock * sk = sock -> sk ; struct irda_sock * self = irda_sk ( sk ) ; struct sk_buff * skb ; size_t copied ; int err ; IRDA_DEBUG ( 4 , ""%s()\\n"" , __func__ ) ; skb = skb_recv_datagram ( sk , flags & ~ MSG_DONTWAIT , flags & MSG_DONTWAIT , & err ) ; if ( ! skb ) return err ; skb_reset_transport_header ( skb ) ; copied = skb -> len ; if ( copied > size ) { IRDA_DEBUG ( 2 , ""%s(),Receivedtruncatedframe(%zd<%zd)!\\n"" , __func__ , copied , size ) ; copied = size ; msg -> msg_flags |= MSG_TRUNC ; } skb_copy_datagram_iovec ( skb , 0 , msg -> msg_iov , copied ) ; skb_free_datagram ( sk , skb ) ; if ( self -> rx_flow == FLOW_STOP ) { if ( ( atomic_read ( & sk -> sk_rmem_alloc ) << 2 ) <= sk -> sk_rcvbuf ) { IRDA_DEBUG ( 2 , ""%s(),StartingIrTTP\\n"" , __func__ ) ; self -> rx_flow = FLOW_START ; irttp_flow_request ( self -> tsap , FLOW_START ) ; } } return copied ; } "," __func__ ) ; msg -> msg_namelen = 0 ; ",torvalds@linux/5ae94c0d2f0bed41d6718be743985d61b7f5c47d,CVE-2013-3228,https://github.com/torvalds/linux/commit/5ae94c0d2f0bed41d6718be743985d61b7f5c47d,2013-04-22T11:41Z 1560,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 1561,CWE-119,"CWE-119 static __u8 * mr_report_fixup ( struct hid_device * hdev , __u8 * rdesc , unsigned int * rsize ) { if ( * rsize >= 30 && rdesc [ 29 ] == 0x05 && rdesc [ 30 ] == 0x09 ) { hid_info ( hdev , ""fixingupbutton/consumerinHIDreportdescriptor\\n"" ) ; rdesc [ 30 ] = 0x0c ; } return rdesc ; } "," * rsize >= 31 && rdesc [ ",torvalds@linux/4ab25786c87eb20857bbb715c3ae34ec8fd6a214,CVE-2014-3184,https://github.com/torvalds/linux/commit/4ab25786c87eb20857bbb715c3ae34ec8fd6a214,2014-09-28T10:55Z 1562,CWE-787,"CWE-787 CURLcode Curl_smtp_escape_eob ( struct connectdata * conn , const ssize_t nread ) { ssize_t i ; ssize_t si ; struct Curl_easy * data = conn -> data ; struct SMTP * smtp = data -> req . protop ; char * scratch = data -> state . scratch ; char * newscratch = NULL ; char * oldscratch = NULL ; size_t eob_sent ; if ( ! scratch || data -> set . crlf ) { oldscratch = scratch ; scratch = newscratch = malloc ( 2 * data -> set . buffer_size ) ; if ( ! newscratch ) { failf ( data , ""Failedtoallocscratchbuffer!"" ) ; return CURLE_OUT_OF_MEMORY ; } } eob_sent = smtp -> eob ; for ( i = 0 , si = 0 ; i < nread ; i ++ ) { if ( SMTP_EOB [ smtp -> eob ] == data -> req . upload_fromhere [ i ] ) { smtp -> eob ++ ; if ( 2 == smtp -> eob || SMTP_EOB_LEN == smtp -> eob ) smtp -> trailing_crlf = TRUE ; else smtp -> trailing_crlf = FALSE ; } else if ( smtp -> eob ) { memcpy ( & scratch [ si ] , & SMTP_EOB [ eob_sent ] , smtp -> eob - eob_sent ) ; si += smtp -> eob - eob_sent ; if ( SMTP_EOB [ 0 ] == data -> req . upload_fromhere [ i ] ) smtp -> eob = 1 ; else smtp -> eob = 0 ; eob_sent = 0 ; smtp -> trailing_crlf = FALSE ; } if ( SMTP_EOB_FIND_LEN == smtp -> eob ) { memcpy ( & scratch [ si ] , & SMTP_EOB_REPL [ eob_sent ] , SMTP_EOB_REPL_LEN - eob_sent ) ; si += SMTP_EOB_REPL_LEN - eob_sent ; smtp -> eob = 0 ; eob_sent = 0 ; } else if ( ! smtp -> eob ) scratch [ si ++ ] = data -> req . upload_fromhere [ i ] ; } if ( smtp -> eob - eob_sent ) { memcpy ( & scratch [ si ] , & SMTP_EOB [ eob_sent ] , smtp -> eob - eob_sent ) ; si += smtp -> eob - eob_sent ; } if ( si != nread ) { data -> req . upload_fromhere = scratch ; data -> state . scratch = scratch ; free ( oldscratch ) ; data -> req . upload_present = si ; } else free ( newscratch ) ; return CURLE_OK ; } "," ( 2 * UPLOAD_BUFSIZE ) ; if ; } } DEBUGASSERT ( UPLOAD_BUFSIZE >= nread ) ; ",curl@curl/ba1dbd78e5f1ed67c1b8d37ac89d90e5e330b628,CVE-2018-0500,https://github.com/curl/curl/commit/ba1dbd78e5f1ed67c1b8d37ac89d90e5e330b628,2018-07-11T13:29Z 1563,CWE-125,"CWE-125 mod_ty PyAST_obj2mod ( PyObject * ast , PyArena * arena , int mode ) { mod_ty res ; PyObject * req_type [ 3 ] ; char * req_name [ ] = { ""Module"" , ""Expression"" , ""Interactive"" } ; int isinstance ; req_type [ 0 ] = ( PyObject * ) Module_type ; req_type [ 1 ] = ( PyObject * ) Expression_type ; req_type [ 2 ] = ( PyObject * ) Interactive_type ; assert ( 0 <= mode && mode <= 2 ) ; if ( ! init_types ( ) ) return NULL ; isinstance = PyObject_IsInstance ( ast , req_type [ mode ] ) ; if ( isinstance == - 1 ) return NULL ; if ( ! isinstance ) { PyErr_Format ( PyExc_TypeError , ""expected%snode,got%.400s"" , req_name [ mode ] , Py_TYPE ( ast ) -> tp_name ) ; return NULL ; } if ( obj2ast_mod ( ast , & res , arena ) != 0 ) return NULL ; else return res ; } "," ""Expression"" , ""Interactive"" , ""FunctionType"" && mode <= 3 ) ; if ",python@typed_ast/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,CVE-2019-19275,https://github.com/python/typed_ast/commit/dcfcd146f8e6fc5c2fc16a4c192a0c5f5ca8c53c,2019-11-26T15:15Z 1564,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 1565,CWE-125,"CWE-125 static void bgp_capabilities_print ( netdissect_options * ndo , const u_char * opt , int caps_len ) { int cap_type , cap_len , tcap_len , cap_offset ; int i = 0 ; while ( i < caps_len ) { ND_TCHECK2 ( opt [ i ] , BGP_CAP_HEADER_SIZE ) ; cap_type = opt [ i ] ; cap_len = opt [ i + 1 ] ; tcap_len = cap_len ; ND_PRINT ( ( ndo , ""\\n\\t%s(%u),length:%u"" , tok2str ( bgp_capcode_values , ""Unknown"" , cap_type ) , cap_type , cap_len ) ) ; ND_TCHECK2 ( opt [ i + 2 ] , cap_len ) ; switch ( cap_type ) { case BGP_CAPCODE_MP : ND_PRINT ( ( ndo , ""\\n\\t\\tAFI%s(%u),SAFI%s(%u)"" , tok2str ( af_values , ""Unknown"" , EXTRACT_16BITS ( opt + i + 2 ) ) , EXTRACT_16BITS ( opt + i + 2 ) , tok2str ( bgp_safi_values , ""Unknown"" , opt [ i + 5 ] ) , opt [ i + 5 ] ) ) ; break ; case BGP_CAPCODE_RESTART : ND_TCHECK_16BITS ( opt + i + 2 ) ; ND_PRINT ( ( ndo , ""\\n\\t\\tRestartFlags:[%s],RestartTime%us"" , ( ( opt [ i + 2 ] ) & 0x80 ) ? ""R"" : ""none"" , EXTRACT_16BITS ( opt + i + 2 ) & 0xfff ) ) ; tcap_len -= 2 ; cap_offset = 4 ; while ( tcap_len >= 4 ) { ND_PRINT ( ( ndo , ""\\n\\t\\tAFI%s(%u),SAFI%s(%u),Forwardingstatepreserved:%s"" , tok2str ( af_values , ""Unknown"" , EXTRACT_16BITS ( opt + i + cap_offset ) ) , EXTRACT_16BITS ( opt + i + cap_offset ) , tok2str ( bgp_safi_values , ""Unknown"" , opt [ i + cap_offset + 2 ] ) , opt [ i + cap_offset + 2 ] , ( ( opt [ i + cap_offset + 3 ] ) & 0x80 ) ? ""yes"" : ""no"" ) ) ; tcap_len -= 4 ; cap_offset += 4 ; } break ; case BGP_CAPCODE_RR : case BGP_CAPCODE_RR_CISCO : break ; case BGP_CAPCODE_AS_NEW : if ( cap_len == 4 ) { ND_PRINT ( ( ndo , ""\\n\\t\\t4ByteAS%s"" , as_printf ( ndo , astostr , sizeof ( astostr ) , EXTRACT_32BITS ( opt + i + 2 ) ) ) ) ; } break ; case BGP_CAPCODE_ADD_PATH : cap_offset = 2 ; if ( tcap_len == 0 ) { ND_PRINT ( ( ndo , ""(bogus)"" ) ) ; break ; } while ( tcap_len > 0 ) { if ( tcap_len < 4 ) { ND_PRINT ( ( ndo , ""\\n\\t\\t(invalid)"" ) ) ; break ; } ND_PRINT ( ( ndo , ""\\n\\t\\tAFI%s(%u),SAFI%s(%u),Send/Receive:%s"" , tok2str ( af_values , ""Unknown"" , EXTRACT_16BITS ( opt + i + cap_offset ) ) , EXTRACT_16BITS ( opt + i + cap_offset ) , tok2str ( bgp_safi_values , ""Unknown"" , opt [ i + cap_offset + 2 ] ) , opt [ i + cap_offset + 2 ] , tok2str ( bgp_add_path_recvsend , ""Bogus(0x%02x)"" , opt [ i + cap_offset + 3 ] ) ) ) ; tcap_len -= 4 ; cap_offset += 4 ; } break ; default : ND_PRINT ( ( ndo , ""\\n\\t\\tnodecoderforCapability%u"" , cap_type ) ) ; if ( ndo -> ndo_vflag <= 1 ) print_unknown_data ( ndo , & opt [ i + 2 ] , ""\\n\\t\\t"" , cap_len ) ; break ; } if ( ndo -> ndo_vflag > 1 && cap_len > 0 ) { print_unknown_data ( ndo , & opt [ i + 2 ] , ""\\n\\t\\t"" , cap_len ) ; } i += BGP_CAP_HEADER_SIZE + cap_len ; } return ; trunc : ND_PRINT ( ( ndo , ""[|BGP]"" ) ) ; } "," case BGP_CAPCODE_MP : ND_TCHECK_8BITS ( opt + i + 5 ) ; ",the-tcpdump-group@tcpdump/e3f3b445e2d20ac5d5b7fcb7559ce6beb55da0c9,CVE-2018-14467,https://github.com/the-tcpdump-group/tcpdump/commit/e3f3b445e2d20ac5d5b7fcb7559ce6beb55da0c9,2019-10-03T16:15Z 1566,CWE-125,"CWE-125 static void parse_sec_attr_44 ( sc_file_t * file , const u8 * buf , size_t len ) { const int df_idx [ 8 ] = { SC_AC_OP_DELETE , SC_AC_OP_CREATE , SC_AC_OP_CREATE , SC_AC_OP_INVALIDATE , SC_AC_OP_REHABILITATE , SC_AC_OP_LOCK , SC_AC_OP_DELETE , - 1 } ; const int ef_idx [ 8 ] = { SC_AC_OP_READ , SC_AC_OP_UPDATE , SC_AC_OP_WRITE , SC_AC_OP_INVALIDATE , SC_AC_OP_REHABILITATE , - 1 , SC_AC_OP_ERASE , - 1 } ; const int efi_idx [ 8 ] = { SC_AC_OP_READ , SC_AC_OP_ERASE , SC_AC_OP_UPDATE , SC_AC_OP_INVALIDATE , SC_AC_OP_REHABILITATE , - 1 , SC_AC_OP_ERASE , - 1 } ; u8 bValue ; int i ; int iKeyRef = 0 ; int iMethod ; int iPinCount ; int iOffset = 0 ; int iOperation ; const int * p_idx ; while ( len > 1 ) { size_t iACLen = buf [ iOffset ] & 0x0F ; if ( iACLen > len ) break ; iMethod = SC_AC_NONE ; if ( buf [ iOffset ] & 0X80 ) { size_t iParmLen = 1 ; size_t iKeyLen = 0 ; if ( buf [ iOffset ] & 0x20 ) iKeyLen ++ ; if ( buf [ iOffset + 1 ] & 0x40 ) iParmLen ++ ; if ( buf [ iOffset + 1 ] & 0x20 ) iParmLen ++ ; if ( buf [ iOffset + 1 ] & 0x10 ) iParmLen ++ ; if ( buf [ iOffset + 1 ] & 0x08 ) iParmLen ++ ; if ( iKeyLen ) { int iSC ; if ( len < 1 + ( size_t ) iACLen ) break ; iSC = buf [ iOffset + iACLen ] ; switch ( ( iSC >> 5 ) & 0x03 ) { case 0 : iMethod = SC_AC_TERM ; break ; case 1 : iMethod = SC_AC_AUT ; break ; case 2 : case 3 : iMethod = SC_AC_PRO ; break ; } iKeyRef = iSC & 0x1F ; } if ( iACLen > ( 1 + iParmLen + iKeyLen ) ) { if ( len < 1 + 1 + 1 + ( size_t ) iParmLen ) break ; iKeyRef = buf [ iOffset + 1 + 1 + iParmLen ] ; iMethod = SC_AC_CHV ; } if ( len < 1 + 2 ) break ; switch ( buf [ iOffset + 2 ] ) { case 0x2A : iOperation = SC_AC_OP_CRYPTO ; break ; case 0x46 : iOperation = SC_AC_OP_UPDATE ; break ; default : iOperation = SC_AC_OP_SELECT ; break ; } sc_file_add_acl_entry ( file , iOperation , iMethod , iKeyRef ) ; } else { switch ( file -> type ) { case SC_FILE_TYPE_DF : p_idx = df_idx ; break ; case SC_FILE_TYPE_INTERNAL_EF : p_idx = efi_idx ; break ; default : p_idx = ef_idx ; break ; } iPinCount = iACLen - 1 ; if ( buf [ iOffset ] & 0x20 ) { int iSC ; if ( len < 1 + ( size_t ) iACLen ) break ; iSC = buf [ iOffset + iACLen ] ; switch ( ( iSC >> 5 ) & 0x03 ) { case 0 : iMethod = SC_AC_TERM ; break ; case 1 : iMethod = SC_AC_AUT ; break ; case 2 : case 3 : iMethod = SC_AC_PRO ; break ; } iKeyRef = iSC & 0x1F ; iPinCount -- ; } if ( iPinCount > 0 ) { if ( len < 1 + 2 ) break ; iKeyRef = buf [ iOffset + 2 ] ; iMethod = SC_AC_CHV ; } bValue = buf [ iOffset + 1 ] ; for ( i = 0 ; i < 8 ; i ++ ) { if ( ( bValue & 1 ) && ( p_idx [ i ] >= 0 ) ) sc_file_add_acl_entry ( file , p_idx [ i ] , iMethod , iKeyRef ) ; bValue >>= 1 ; } } iOffset += iACLen + 1 ; len -= iACLen + 1 ; } } "," iPinCount = iACLen > 0 ? iACLen - 1 : 0 ; if ( ",OpenSC@OpenSC/c3f23b836e5a1766c36617fe1da30d22f7b63de2,CVE-2019-19479,https://github.com/OpenSC/OpenSC/commit/c3f23b836e5a1766c36617fe1da30d22f7b63de2,2019-12-01T23:15Z 1567,CWE-20,"CWE-20 static apr_status_t parse_chunk_size ( http_ctx_t * ctx , const char * buffer , apr_size_t len , int linelimit ) { apr_size_t i = 0 ; while ( i < len ) { char c = buffer [ i ] ; ap_xlate_proto_from_ascii ( & c , 1 ) ; if ( ctx -> state == BODY_CHUNK_END ) { if ( c == LF ) { ctx -> state = BODY_CHUNK ; } i ++ ; continue ; } if ( ctx -> state == BODY_CHUNK ) { if ( ! apr_isxdigit ( c ) ) { return APR_EGENERAL ; } else { ctx -> state = BODY_CHUNK_PART ; } ctx -> remaining = 0 ; ctx -> chunkbits = sizeof ( long ) * 8 ; ctx -> chunk_used = 0 ; } if ( c == ';' || c == CR ) { ctx -> state = BODY_CHUNK_EXT ; } else if ( c == LF ) { if ( ctx -> remaining ) { ctx -> state = BODY_CHUNK_DATA ; } else { ctx -> state = BODY_CHUNK_TRAILER ; } } else if ( ctx -> state != BODY_CHUNK_EXT ) { int xvalue = 0 ; if ( ! ctx -> remaining && c == '0' ) { i ++ ; continue ; } if ( c >= '0' && c <= '9' ) { xvalue = c - '0' ; } else if ( c >= 'A' && c <= 'F' ) { xvalue = c - 'A' + 0xa ; } else if ( c >= 'a' && c <= 'f' ) { xvalue = c - 'a' + 0xa ; } else { return APR_EGENERAL ; } ctx -> remaining = ( ctx -> remaining << 4 ) | xvalue ; ctx -> chunkbits -= 4 ; if ( ctx -> chunkbits <= 0 || ctx -> remaining < 0 ) { return APR_ENOSPC ; } } i ++ ; } ctx -> chunk_used += len ; if ( ctx -> chunk_used < 0 || ctx -> chunk_used > linelimit ) { return APR_ENOSPC ; } return APR_SUCCESS ; } "," state == BODY_CHUNK_END || ctx -> state == BODY_CHUNK_END_LF state = BODY_CHUNK ; } else if ( c == CR && ctx -> state == BODY_CHUNK_END ) { ctx -> state = BODY_CHUNK_END_LF ; } else { return APR_EINVAL ) { return APR_EINVAL ; } else = sizeof ( apr_off_t ) * 8 ( c == LF ) { if ( ctx -> remaining ) { ctx -> state = BODY_CHUNK_DATA ; } else { ctx -> state = BODY_CHUNK_TRAILER ; } } else if ( ctx -> state == BODY_CHUNK_LF ) { return APR_EINVAL ; } else if ( c == CR ) { ctx -> state = BODY_CHUNK_LF ; } else if ( c == ';' ) { ctx else if ( ctx -> state == BODY_CHUNK_EXT ) { if ( c != '\\t' && apr_iscntrl ( c ) ) { return APR_EINVAL ; } } else if ( ctx -> state == BODY_CHUNK_PART ) { int { int xvalue ; if ( ++ ; continue ; } ctx -> chunkbits -= 4 ; if ( ctx -> chunkbits < 0 ) { return APR_ENOSPC else { return APR_EINVAL ; } ctx | xvalue ; if ( ctx -> remaining APR_ENOSPC ; } } else { return APR_EGENERAL ; ",apache@httpd/a6027e56924bb6227c1fdbf6f91e7e2438338be6,CVE-2015-3183,https://github.com/apache/httpd/commit/a6027e56924bb6227c1fdbf6f91e7e2438338be6,2015-07-20T23:59Z 1568,CWE-787,"CWE-787 pdf_t * pdf_new ( const char * name ) { const char * n ; pdf_t * pdf ; pdf = calloc ( 1 , sizeof ( pdf_t ) ) ; if ( name ) { if ( ( n = strrchr ( name , '/' ) ) ) ++ n ; else n = name ; pdf -> name = malloc ( strlen ( n ) + 1 ) ; strcpy ( pdf -> name , n ) ; } else { pdf -> name = malloc ( strlen ( ""Unknown"" ) + 1 ) ; strcpy ( pdf -> name , ""Unknown"" ) ; } return pdf ; } "," ; pdf = safe_calloc ( sizeof ( pdf_t -> name = safe_calloc ( strlen ( -> name = safe_calloc ( strlen ( ",enferex@pdfresurrect/0c4120fffa3dffe97b95c486a120eded82afe8a6,CVE-2019-14934,https://github.com/enferex/pdfresurrect/commit/0c4120fffa3dffe97b95c486a120eded82afe8a6,2019-08-11T22:15Z 1569,CWE-617,"CWE-617 static int pci_emul_alloc_resource ( uint64_t * baseptr , uint64_t limit , uint64_t size , uint64_t * addr ) { uint64_t base ; assert ( ( size & ( size - 1 ) ) == 0 ) ; base = roundup2 ( * baseptr , size ) ; if ( base + size <= limit ) { * addr = base ; * baseptr = base + size ; return 0 ; } else return - 1 ; } "," uint64_t base ; if ( ( size 1 ) ) != 0 ) { pr_err ( ""%s:Cannotallocinvalidsize%lldresource\\n"" , __func__ , size ) ; return - 1 ; } base = roundup2 ",projectacrn@acrn-hypervisor/2b3dedfb9ba13f15887f22b935d373f36c9a59fa,CVE-2019-18844,https://github.com/projectacrn/acrn-hypervisor/commit/2b3dedfb9ba13f15887f22b935d373f36c9a59fa,2019-11-13T20:15Z 1570,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 1571,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 1572,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 1573,CWE-284,"CWE-284 int bta_co_rfc_data_outgoing_size ( void * user_data , int * size ) { pthread_mutex_lock ( & slot_lock ) ; uint32_t id = ( uintptr_t ) user_data ; int ret = false ; * size = 0 ; rfc_slot_t * slot = find_rfc_slot_by_id ( id ) ; if ( ! slot ) goto out ; if ( ioctl ( slot -> fd , FIONREAD , size ) == 0 ) { ret = true ; } else { LOG_ERROR ( ""%sunabletodeterminebytesremainingtobereadonfd%d:%s"" , __func__ , slot -> fd , strerror ( errno ) ) ; cleanup_rfc_slot ( slot ) ; } out : ; pthread_mutex_unlock ( & slot_lock ) ; return ret ; } "," ; if ( TEMP_FAILURE_RETRY ( FIONREAD , size ) ",system@bt/472271b153c5dc53c28beac55480a8d8434b2d5c,CVE-2016-3839,https://android.googlesource.com/platform/system/bt/+/472271b153c5dc53c28beac55480a8d8434b2d5c,2016-08-05T20:59Z 1574,CWE-918,"CWE-918 static int daemon_msg_open_req ( uint8 ver , struct daemon_slpars * pars , uint32 plen , char * source , size_t sourcelen ) { char errbuf [ PCAP_ERRBUF_SIZE ] ; char errmsgbuf [ PCAP_ERRBUF_SIZE ] ; pcap_t * fp ; int nread ; char sendbuf [ RPCAP_NETBUF_SIZE ] ; int sendbufidx = 0 ; struct rpcap_openreply * openreply ; if ( plen > sourcelen - 1 ) { pcap_snprintf ( errmsgbuf , PCAP_ERRBUF_SIZE , ""Sourcestringtoolong"" ) ; goto error ; } nread = sock_recv ( pars -> sockctrl , source , plen , SOCK_RECEIVEALL_YES | SOCK_EOF_IS_ERROR , errbuf , PCAP_ERRBUF_SIZE ) ; if ( nread == - 1 ) { rpcapd_log ( LOGPRIO_ERROR , ""Readfromclientfailed:%s"" , errbuf ) ; return - 1 ; } source [ nread ] = '\\0' ; plen -= nread ; if ( ( fp = pcap_open_live ( source , 1500 , 0 , 1000 , errmsgbuf ) ) == NULL ) goto error ; 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_OPEN_REPLY , 0 , sizeof ( struct rpcap_openreply ) ) ; openreply = ( struct rpcap_openreply * ) & sendbuf [ sendbufidx ] ; if ( sock_bufferize ( NULL , sizeof ( struct rpcap_openreply ) , NULL , & sendbufidx , RPCAP_NETBUF_SIZE , SOCKBUF_CHECKONLY , errmsgbuf , PCAP_ERRBUF_SIZE ) == - 1 ) goto error ; memset ( openreply , 0 , sizeof ( struct rpcap_openreply ) ) ; openreply -> linktype = htonl ( pcap_datalink ( fp ) ) ; openreply -> tzoff = 0 ; pcap_close ( fp ) ; 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 ( rpcap_senderror ( pars -> sockctrl , ver , PCAP_ERR_OPEN , errmsgbuf , errbuf ) == - 1 ) { rpcapd_log ( LOGPRIO_ERROR , ""Sendtoclientfailed:%s"" , errbuf ) ; return - 1 ; } if ( rpcapd_discard ( pars -> sockctrl , plen ) == - 1 ) { return - 1 ; } return 0 ; } "," ; if ( is_url ( source ) ) { pcap_snprintf ( errmsgbuf , PCAP_ERRBUF_SIZE , ""Sourcestringreferstoaremotedevice"" ) ; goto error ; } if ( ",the-tcpdump-group@libpcap/33834cb2a4d035b52aa2a26742f832a112e90a0a,CVE-2019-15164,https://github.com/the-tcpdump-group/libpcap/commit/33834cb2a4d035b52aa2a26742f832a112e90a0a,2019-10-03T19:15Z 1575,CWE-416,"CWE-416 static int archive_read_format_rar_read_data ( struct archive_read * a , const void * * buff , size_t * size , int64_t * offset ) { struct rar * rar = ( struct rar * ) ( a -> format -> data ) ; int ret ; if ( rar -> has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW ) { rar -> has_encrypted_entries = 0 ; } if ( rar -> bytes_unconsumed > 0 ) { __archive_read_consume ( a , rar -> bytes_unconsumed ) ; rar -> bytes_unconsumed = 0 ; } * buff = NULL ; if ( rar -> entry_eof || rar -> offset_seek >= rar -> unp_size ) { * size = 0 ; * offset = rar -> offset ; if ( * offset < rar -> unp_size ) * offset = rar -> unp_size ; return ( ARCHIVE_EOF ) ; } switch ( rar -> compression_method ) { case COMPRESS_METHOD_STORE : ret = read_data_stored ( a , buff , size , offset ) ; break ; case COMPRESS_METHOD_FASTEST : case COMPRESS_METHOD_FAST : case COMPRESS_METHOD_NORMAL : case COMPRESS_METHOD_GOOD : case COMPRESS_METHOD_BEST : ret = read_data_compressed ( a , buff , size , offset ) ; if ( ret != ARCHIVE_OK && ret != ARCHIVE_WARN ) __archive_ppmd7_functions . Ppmd7_Free ( & rar -> ppmd7_context ) ; break ; default : archive_set_error ( & a -> archive , ARCHIVE_ERRNO_FILE_FORMAT , ""UnsupportedcompressionmethodforRARfile."" ) ; ret = ARCHIVE_FATAL ; break ; } return ( ret ) ; } "," != ARCHIVE_WARN ) { ppmd7_context ) ; rar -> start_new_table = 1 ; } ",libarchive@libarchive/b8592ecba2f9e451e1f5cb7ab6dcee8b8e7b3f60,CVE-2019-18408,https://github.com/libarchive/libarchive/commit/b8592ecba2f9e451e1f5cb7ab6dcee8b8e7b3f60,2019-10-24T14:15Z 1576,CWE-400,"CWE-400 void handle_stdfmna ( struct pt_regs * regs , unsigned long sfar , unsigned long sfsr ) { unsigned long pc = regs -> tpc ; unsigned long tstate = regs -> tstate ; u32 insn ; u64 value ; u8 freg ; int flag ; struct fpustate * f = FPUSTATE ; if ( tstate & TSTATE_PRIV ) die_if_kernel ( ""stdfmnafromkernel"" , regs ) ; perf_sw_event ( PERF_COUNT_SW_ALIGNMENT_FAULTS , 1 , 0 , regs , sfar ) ; if ( test_thread_flag ( TIF_32BIT ) ) pc = ( u32 ) pc ; if ( get_user ( insn , ( u32 __user * ) pc ) != - EFAULT ) { int asi = decode_asi ( insn , regs ) ; freg = ( ( insn >> 25 ) & 0x1e ) | ( ( insn >> 20 ) & 0x20 ) ; value = 0 ; flag = ( freg < 32 ) ? FPRS_DL : FPRS_DU ; if ( ( asi > ASI_SNFL ) || ( asi < ASI_P ) ) goto daex ; save_and_clear_fpu ( ) ; if ( current_thread_info ( ) -> fpsaved [ 0 ] & flag ) value = * ( u64 * ) & f -> regs [ freg ] ; switch ( asi ) { case ASI_P : case ASI_S : break ; case ASI_PL : case ASI_SL : value = __swab64p ( & value ) ; break ; default : goto daex ; } if ( put_user ( value >> 32 , ( u32 __user * ) sfar ) || __put_user ( ( u32 ) value , ( u32 __user * ) ( sfar + 4 ) ) ) goto daex ; } else { daex : if ( tlb_type == hypervisor ) sun4v_data_access_exception ( regs , sfar , sfsr ) ; else spitfire_data_access_exception ( regs , sfsr , sfar ) ; return ; } advance ( regs ) ; } "," PERF_COUNT_SW_ALIGNMENT_FAULTS , 1 , regs , ",torvalds@linux/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,CVE-2011-2918,https://github.com/torvalds/linux/commit/a8b0ca17b80e92faab46ee7179ba9e99ccb61233,2012-05-24T23:55Z 1577,CWE-119,"CWE-119 const vpx_codec_cx_pkt_t * vpx_codec_get_cx_data ( vpx_codec_ctx_t * ctx , vpx_codec_iter_t * iter ) { const vpx_codec_cx_pkt_t * pkt = NULL ; if ( ctx ) { if ( ! iter ) ctx -> err = VPX_CODEC_INVALID_PARAM ; else 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 pkt = ctx -> iface -> enc . get_cx_data ( ctx -> priv -> alg_priv , iter ) ; } if ( pkt && pkt -> kind == VPX_CODEC_CX_FRAME_PKT ) { vpx_codec_priv_t * const priv = ctx -> priv ; char * const dst_buf = ( char * ) priv -> enc . cx_data_dst_buf . buf ; if ( dst_buf && pkt -> data . raw . buf != dst_buf && pkt -> data . raw . sz + priv -> enc . cx_data_pad_before + priv -> enc . cx_data_pad_after <= priv -> enc . cx_data_dst_buf . sz ) { vpx_codec_cx_pkt_t * modified_pkt = & priv -> enc . cx_data_pkt ; memcpy ( dst_buf + priv -> enc . cx_data_pad_before , pkt -> data . raw . buf , pkt -> data . raw . sz ) ; * modified_pkt = * pkt ; modified_pkt -> data . raw . buf = dst_buf ; modified_pkt -> data . raw . sz += priv -> enc . cx_data_pad_before + priv -> enc . cx_data_pad_after ; pkt = modified_pkt ; } if ( dst_buf == pkt -> data . raw . buf ) { priv -> enc . cx_data_dst_buf . buf = dst_buf + pkt -> data . raw . sz ; priv -> enc . cx_data_dst_buf . sz -= pkt -> data . raw . sz ; } } return pkt ; } "," . get_cx_data ( get_alg_priv ( ctx ) , iter ) ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1578,CWE-119,"CWE-119 int vp9_get_qindex ( const struct segmentation * seg , int segment_id , int base_qindex ) { if ( vp9_segfeature_active ( seg , segment_id , SEG_LVL_ALT_Q ) ) { const int data = vp9_get_segdata ( seg , segment_id , SEG_LVL_ALT_Q ) ; const int seg_qindex = seg -> abs_delta == SEGMENT_ABSDATA ? data : base_qindex + data ; return clamp ( seg_qindex , 0 , MAXQ ) ; } else { return base_qindex ; } } "," { if ( segfeature_active ( seg , int data = get_segdata ( seg , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1579,CWE-77,"CWE-77 void imap_munge_mbox_name ( struct ImapData * idata , char * dest , size_t dlen , const char * src ) { char * buf = mutt_str_strdup ( src ) ; imap_utf_encode ( idata , & buf ) ; imap_quote_string ( dest , dlen , buf ) ; FREE ( & buf ) ; } "," dlen , buf , false ",neomutt@neomutt/e52393740334443ae0206cab2d7caef381646725,CVE-2018-14357,https://github.com/neomutt/neomutt/commit/e52393740334443ae0206cab2d7caef381646725,2018-07-17T17:29Z 1580,CWE-000,"CWE-000 int config__parse_args ( struct mosquitto_db * db , struct mosquitto__config * config , int argc , char * argv [ ] ) { int i ; int port_tmp ; for ( i = 1 ; i < argc ; i ++ ) { if ( ! strcmp ( argv [ i ] , ""-c"" ) || ! strcmp ( argv [ i ] , ""--config-file"" ) ) { if ( i < argc - 1 ) { db -> config_file = argv [ i + 1 ] ; if ( config__read ( db , config , false ) ) { log__printf ( NULL , MOSQ_LOG_ERR , ""Error:Unabletoopenconfigurationfile."" ) ; return MOSQ_ERR_INVAL ; } } else { log__printf ( NULL , MOSQ_LOG_ERR , ""Error:-cargumentgiven,butnoconfigfilespecified."" ) ; return MOSQ_ERR_INVAL ; } i ++ ; } else if ( ! strcmp ( argv [ i ] , ""-d"" ) || ! strcmp ( argv [ i ] , ""--daemon"" ) ) { config -> daemon = true ; } else if ( ! strcmp ( argv [ i ] , ""-h"" ) || ! strcmp ( argv [ i ] , ""--help"" ) ) { print_usage ( ) ; return MOSQ_ERR_INVAL ; } else if ( ! strcmp ( argv [ i ] , ""-p"" ) || ! strcmp ( argv [ i ] , ""--port"" ) ) { if ( i < argc - 1 ) { port_tmp = atoi ( argv [ i + 1 ] ) ; if ( port_tmp < 1 || port_tmp > 65535 ) { log__printf ( NULL , MOSQ_LOG_ERR , ""Error:Invalidportspecified(%d)."" , port_tmp ) ; return MOSQ_ERR_INVAL ; } else { if ( config -> default_listener . port ) { log__printf ( NULL , MOSQ_LOG_WARNING , ""Warning:Defaultlistenerportspecifiedmultipletimes.Onlythelatestwillbeused."" ) ; } config -> default_listener . port = port_tmp ; } } else { log__printf ( NULL , MOSQ_LOG_ERR , ""Error:-pargumentgiven,butnoportspecified."" ) ; return MOSQ_ERR_INVAL ; } i ++ ; } else if ( ! strcmp ( argv [ i ] , ""-v"" ) || ! strcmp ( argv [ i ] , ""--verbose"" ) ) { db -> verbose = true ; } else { fprintf ( stderr , ""Error:Unknownoption\'%s\'.\\n"" , argv [ i ] ) ; print_usage ( ) ; return MOSQ_ERR_INVAL ; } } if ( config -> listener_count == 0 # ifdef WITH_TLS || config -> default_listener . cafile || config -> default_listener . capath || config -> default_listener . certfile || config -> default_listener . keyfile || config -> default_listener . ciphers || config -> default_listener . psk_hint || config -> default_listener . require_certificate || config -> default_listener . crlfile || config -> default_listener . use_identity_as_username || config -> default_listener . use_subject_as_username # endif || config -> default_listener . use_username_as_clientid || config -> default_listener . host || config -> default_listener . port || config -> default_listener . max_connections != - 1 || config -> default_listener . mount_point || config -> default_listener . protocol != mp_mqtt || config -> default_listener . socket_domain || config -> default_listener . security_options . password_file || config -> default_listener . security_options . psk_file || config -> default_listener . security_options . auth_plugin_config_count || config -> default_listener . security_options . allow_anonymous != - 1 ) { config -> listener_count ++ ; config -> listeners = mosquitto__realloc ( config -> listeners , sizeof ( struct mosquitto__listener ) * config -> listener_count ) ; if ( ! config -> listeners ) { log__printf ( NULL , MOSQ_LOG_ERR , ""Error:Outofmemory."" ) ; return MOSQ_ERR_NOMEM ; } memset ( & config -> listeners [ config -> listener_count - 1 ] , 0 , sizeof ( struct mosquitto__listener ) ) ; if ( config -> default_listener . port ) { config -> listeners [ config -> listener_count - 1 ] . port = config -> default_listener . port ; } else { config -> listeners [ config -> listener_count - 1 ] . port = 1883 ; } if ( config -> default_listener . host ) { config -> listeners [ config -> listener_count - 1 ] . host = config -> default_listener . host ; } else { config -> listeners [ config -> listener_count - 1 ] . host = NULL ; } if ( config -> default_listener . mount_point ) { config -> listeners [ config -> listener_count - 1 ] . mount_point = config -> default_listener . mount_point ; } else { config -> listeners [ config -> listener_count - 1 ] . mount_point = NULL ; } config -> listeners [ config -> listener_count - 1 ] . max_connections = config -> default_listener . max_connections ; config -> listeners [ config -> listener_count - 1 ] . protocol = config -> default_listener . protocol ; config -> listeners [ config -> listener_count - 1 ] . socket_domain = config -> default_listener . socket_domain ; config -> listeners [ config -> listener_count - 1 ] . client_count = 0 ; config -> listeners [ config -> listener_count - 1 ] . socks = NULL ; config -> listeners [ config -> listener_count - 1 ] . sock_count = 0 ; config -> listeners [ config -> listener_count - 1 ] . client_count = 0 ; config -> listeners [ config -> listener_count - 1 ] . use_username_as_clientid = config -> default_listener . use_username_as_clientid ; # ifdef WITH_TLS config -> listeners [ config -> listener_count - 1 ] . tls_version = config -> default_listener . tls_version ; config -> listeners [ config -> listener_count - 1 ] . cafile = config -> default_listener . cafile ; config -> listeners [ config -> listener_count - 1 ] . capath = config -> default_listener . capath ; config -> listeners [ config -> listener_count - 1 ] . certfile = config -> default_listener . certfile ; config -> listeners [ config -> listener_count - 1 ] . keyfile = config -> default_listener . keyfile ; config -> listeners [ config -> listener_count - 1 ] . ciphers = config -> default_listener . ciphers ; config -> listeners [ config -> listener_count - 1 ] . psk_hint = config -> default_listener . psk_hint ; config -> listeners [ config -> listener_count - 1 ] . require_certificate = config -> default_listener . require_certificate ; config -> listeners [ config -> listener_count - 1 ] . ssl_ctx = NULL ; config -> listeners [ config -> listener_count - 1 ] . crlfile = config -> default_listener . crlfile ; config -> listeners [ config -> listener_count - 1 ] . use_identity_as_username = config -> default_listener . use_identity_as_username ; config -> listeners [ config -> listener_count - 1 ] . use_subject_as_username = config -> default_listener . use_subject_as_username ; # endif config -> listeners [ config -> listener_count - 1 ] . security_options . password_file = config -> default_listener . security_options . password_file ; config -> listeners [ config -> listener_count - 1 ] . security_options . psk_file = config -> default_listener . security_options . psk_file ; config -> listeners [ config -> listener_count - 1 ] . security_options . auth_plugin_configs = config -> default_listener . security_options . auth_plugin_configs ; config -> listeners [ config -> listener_count - 1 ] . security_options . auth_plugin_config_count = config -> default_listener . security_options . auth_plugin_config_count ; config -> listeners [ config -> listener_count - 1 ] . security_options . allow_anonymous = config -> default_listener . security_options . allow_anonymous ; } if ( ! config -> user ) { config -> user = ""mosquitto"" ; } if ( db -> verbose ) { config -> log_type = INT_MAX ; } return config__check ( config ) ; } "," . security_options . acl_file = config -> default_listener . security_options . acl_file ; config -> listeners [ config -> listener_count - 1 ] . security_options . ",eclipse@mosquitto/9097577b49b7fdcf45d30975976dd93808ccc0c4,CVE-2018-20145,https://github.com/eclipse/mosquitto/commit/9097577b49b7fdcf45d30975976dd93808ccc0c4,2018-12-13T20:29Z 1581,CWE-119,"CWE-119 static void yv12_extend_frame_bottom_c ( YV12_BUFFER_CONFIG * ybf ) { int i ; unsigned char * src_ptr1 , * src_ptr2 ; unsigned char * dest_ptr2 ; unsigned int Border ; int plane_stride ; int plane_height ; Border = ybf -> border ; plane_stride = ybf -> y_stride ; plane_height = ybf -> y_height ; src_ptr1 = ybf -> y_buffer - Border ; src_ptr2 = src_ptr1 + ( plane_height * plane_stride ) - plane_stride ; dest_ptr2 = src_ptr2 + plane_stride ; for ( i = 0 ; i < ( int ) Border ; i ++ ) { vpx_memcpy ( dest_ptr2 , src_ptr2 , plane_stride ) ; dest_ptr2 += plane_stride ; } plane_stride = ybf -> uv_stride ; plane_height = ybf -> uv_height ; Border /= 2 ; src_ptr1 = ybf -> u_buffer - Border ; src_ptr2 = src_ptr1 + ( plane_height * plane_stride ) - plane_stride ; dest_ptr2 = src_ptr2 + plane_stride ; for ( i = 0 ; i < ( int ) ( Border ) ; i ++ ) { vpx_memcpy ( dest_ptr2 , src_ptr2 , plane_stride ) ; dest_ptr2 += plane_stride ; } src_ptr1 = ybf -> v_buffer - Border ; src_ptr2 = src_ptr1 + ( plane_height * plane_stride ) - plane_stride ; dest_ptr2 = src_ptr2 + plane_stride ; for ( i = 0 ; i < ( int ) ( Border ) ; i ++ ) { vpx_memcpy ( dest_ptr2 , src_ptr2 , plane_stride ) ; dest_ptr2 += plane_stride ; } } "," ++ ) { memcpy ( dest_ptr2 , ++ ) { memcpy ( dest_ptr2 , ++ ) { memcpy ( dest_ptr2 , ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1582,CWE-119,"CWE-119 static void swabHorDiff32 ( TIFF * tif , uint8 * cp0 , tmsize_t cc ) { uint32 * wp = ( uint32 * ) cp0 ; tmsize_t wc = cc / 4 ; horDiff32 ( tif , cp0 , cc ) ; TIFFSwabArrayOfLong ( wp , wc ) ; } "," static int swabHorDiff32 ( TIFF / 4 ; if ( ! , cc ) ) return 0 wc ) ; return 1 ; ",vadz@libtiff/3ca657a8793dd011bf869695d72ad31c779c3cc1,CVE-2016-9535,https://github.com/vadz/libtiff/commit/3ca657a8793dd011bf869695d72ad31c779c3cc1,2016-11-22T19:59Z 1583,CWE-119,"CWE-119 IHEVCD_ERROR_T ihevcd_parse_sps ( codec_t * ps_codec ) { IHEVCD_ERROR_T ret = ( IHEVCD_ERROR_T ) IHEVCD_SUCCESS ; WORD32 value ; WORD32 i ; WORD32 vps_id ; WORD32 sps_max_sub_layers ; WORD32 sps_id ; WORD32 sps_temporal_id_nesting_flag ; sps_t * ps_sps ; profile_tier_lvl_info_t s_ptl ; bitstrm_t * ps_bitstrm = & ps_codec -> s_parse . s_bitstrm ; WORD32 ctb_log2_size_y = 0 ; BITS_PARSE ( ""video_parameter_set_id"" , value , ps_bitstrm , 4 ) ; vps_id = value ; vps_id = CLIP3 ( vps_id , 0 , MAX_VPS_CNT - 1 ) ; BITS_PARSE ( ""sps_max_sub_layers_minus1"" , value , ps_bitstrm , 3 ) ; sps_max_sub_layers = value + 1 ; sps_max_sub_layers = CLIP3 ( sps_max_sub_layers , 1 , 7 ) ; BITS_PARSE ( ""sps_temporal_id_nesting_flag"" , value , ps_bitstrm , 1 ) ; sps_temporal_id_nesting_flag = value ; ret = ihevcd_profile_tier_level ( ps_bitstrm , & ( s_ptl ) , 1 , ( sps_max_sub_layers - 1 ) ) ; UEV_PARSE ( ""seq_parameter_set_id"" , value , ps_bitstrm ) ; sps_id = value ; if ( ( sps_id >= MAX_SPS_CNT ) || ( sps_id < 0 ) ) { if ( ps_codec -> i4_sps_done ) return IHEVCD_UNSUPPORTED_SPS_ID ; else sps_id = 0 ; } ps_sps = ( ps_codec -> s_parse . ps_sps_base + MAX_SPS_CNT - 1 ) ; ps_sps -> i1_sps_id = sps_id ; ps_sps -> i1_vps_id = vps_id ; ps_sps -> i1_sps_max_sub_layers = sps_max_sub_layers ; ps_sps -> i1_sps_temporal_id_nesting_flag = sps_temporal_id_nesting_flag ; ps_codec -> i4_sps_id = sps_id ; memcpy ( & ps_sps -> s_ptl , & s_ptl , sizeof ( profile_tier_lvl_info_t ) ) ; UEV_PARSE ( ""chroma_format_idc"" , value , ps_bitstrm ) ; ps_sps -> i1_chroma_format_idc = value ; if ( ps_sps -> i1_chroma_format_idc != CHROMA_FMT_IDC_YUV420 ) { ps_codec -> s_parse . i4_error_code = IHEVCD_UNSUPPORTED_CHROMA_FMT_IDC ; return ( IHEVCD_ERROR_T ) IHEVCD_UNSUPPORTED_CHROMA_FMT_IDC ; } if ( CHROMA_FMT_IDC_YUV444_PLANES == ps_sps -> i1_chroma_format_idc ) { BITS_PARSE ( ""separate_colour_plane_flag"" , value , ps_bitstrm , 1 ) ; ps_sps -> i1_separate_colour_plane_flag = value ; } else { ps_sps -> i1_separate_colour_plane_flag = 0 ; } UEV_PARSE ( ""pic_width_in_luma_samples"" , value , ps_bitstrm ) ; ps_sps -> i2_pic_width_in_luma_samples = value ; UEV_PARSE ( ""pic_height_in_luma_samples"" , value , ps_bitstrm ) ; ps_sps -> i2_pic_height_in_luma_samples = value ; if ( ( 0 >= ps_sps -> i2_pic_width_in_luma_samples ) || ( 0 >= ps_sps -> i2_pic_height_in_luma_samples ) ) return IHEVCD_INVALID_PARAMETER ; ps_sps -> i2_pic_width_in_luma_samples = ALIGN8 ( ps_sps -> i2_pic_width_in_luma_samples ) ; ps_sps -> i2_pic_height_in_luma_samples = ALIGN8 ( ps_sps -> i2_pic_height_in_luma_samples ) ; BITS_PARSE ( ""pic_cropping_flag"" , value , ps_bitstrm , 1 ) ; ps_sps -> i1_pic_cropping_flag = value ; if ( ps_sps -> i1_pic_cropping_flag ) { UEV_PARSE ( ""pic_crop_left_offset"" , value , ps_bitstrm ) ; ps_sps -> i2_pic_crop_left_offset = value ; UEV_PARSE ( ""pic_crop_right_offset"" , value , ps_bitstrm ) ; ps_sps -> i2_pic_crop_right_offset = value ; UEV_PARSE ( ""pic_crop_top_offset"" , value , ps_bitstrm ) ; ps_sps -> i2_pic_crop_top_offset = value ; UEV_PARSE ( ""pic_crop_bottom_offset"" , value , ps_bitstrm ) ; ps_sps -> i2_pic_crop_bottom_offset = value ; } else { ps_sps -> i2_pic_crop_left_offset = 0 ; ps_sps -> i2_pic_crop_right_offset = 0 ; ps_sps -> i2_pic_crop_top_offset = 0 ; ps_sps -> i2_pic_crop_bottom_offset = 0 ; } UEV_PARSE ( ""bit_depth_luma_minus8"" , value , ps_bitstrm ) ; if ( 0 != value ) return IHEVCD_UNSUPPORTED_BIT_DEPTH ; UEV_PARSE ( ""bit_depth_chroma_minus8"" , value , ps_bitstrm ) ; if ( 0 != value ) return IHEVCD_UNSUPPORTED_BIT_DEPTH ; UEV_PARSE ( ""log2_max_pic_order_cnt_lsb_minus4"" , value , ps_bitstrm ) ; ps_sps -> i1_log2_max_pic_order_cnt_lsb = value + 4 ; BITS_PARSE ( ""sps_sub_layer_ordering_info_present_flag"" , value , ps_bitstrm , 1 ) ; ps_sps -> i1_sps_sub_layer_ordering_info_present_flag = value ; i = ( ps_sps -> i1_sps_sub_layer_ordering_info_present_flag ? 0 : ( ps_sps -> i1_sps_max_sub_layers - 1 ) ) ; for ( ; i < ps_sps -> i1_sps_max_sub_layers ; i ++ ) { UEV_PARSE ( ""max_dec_pic_buffering"" , value , ps_bitstrm ) ; ps_sps -> ai1_sps_max_dec_pic_buffering [ i ] = value + 1 ; if ( ps_sps -> ai1_sps_max_dec_pic_buffering [ i ] > MAX_DPB_SIZE ) { return IHEVCD_INVALID_PARAMETER ; } UEV_PARSE ( ""num_reorder_pics"" , value , ps_bitstrm ) ; ps_sps -> ai1_sps_max_num_reorder_pics [ i ] = value ; if ( ps_sps -> ai1_sps_max_num_reorder_pics [ i ] > ps_sps -> ai1_sps_max_dec_pic_buffering [ i ] ) { return IHEVCD_INVALID_PARAMETER ; } UEV_PARSE ( ""max_latency_increase"" , value , ps_bitstrm ) ; ps_sps -> ai1_sps_max_latency_increase [ i ] = value ; } UEV_PARSE ( ""log2_min_coding_block_size_minus3"" , value , ps_bitstrm ) ; ps_sps -> i1_log2_min_coding_block_size = value + 3 ; UEV_PARSE ( ""log2_diff_max_min_coding_block_size"" , value , ps_bitstrm ) ; ps_sps -> i1_log2_diff_max_min_coding_block_size = value ; ctb_log2_size_y = ps_sps -> i1_log2_min_coding_block_size + ps_sps -> i1_log2_diff_max_min_coding_block_size ; UEV_PARSE ( ""log2_min_transform_block_size_minus2"" , value , ps_bitstrm ) ; ps_sps -> i1_log2_min_transform_block_size = value + 2 ; UEV_PARSE ( ""log2_diff_max_min_transform_block_size"" , value , ps_bitstrm ) ; ps_sps -> i1_log2_diff_max_min_transform_block_size = value ; ps_sps -> i1_log2_max_transform_block_size = ps_sps -> i1_log2_min_transform_block_size + ps_sps -> i1_log2_diff_max_min_transform_block_size ; if ( ( ps_sps -> i1_log2_max_transform_block_size < 0 ) || ( ps_sps -> i1_log2_max_transform_block_size > MIN ( ctb_log2_size_y , 5 ) ) ) { return IHEVCD_INVALID_PARAMETER ; } ps_sps -> i1_log2_ctb_size = ps_sps -> i1_log2_min_coding_block_size + ps_sps -> i1_log2_diff_max_min_coding_block_size ; if ( ( ps_sps -> i1_log2_min_coding_block_size < 3 ) || ( ps_sps -> i1_log2_min_transform_block_size < 2 ) || ( ps_sps -> i1_log2_diff_max_min_transform_block_size < 0 ) || ( ps_sps -> i1_log2_max_transform_block_size > ps_sps -> i1_log2_ctb_size ) || ( ps_sps -> i1_log2_ctb_size < 4 ) || ( ps_sps -> i1_log2_ctb_size > 6 ) ) { return IHEVCD_INVALID_PARAMETER ; } ps_sps -> i1_log2_min_pcm_coding_block_size = 0 ; ps_sps -> i1_log2_diff_max_min_pcm_coding_block_size = 0 ; UEV_PARSE ( ""max_transform_hierarchy_depth_inter"" , value , ps_bitstrm ) ; ps_sps -> i1_max_transform_hierarchy_depth_inter = value ; UEV_PARSE ( ""max_transform_hierarchy_depth_intra"" , value , ps_bitstrm ) ; ps_sps -> i1_max_transform_hierarchy_depth_intra = value ; BITS_PARSE ( ""scaling_list_enabled_flag"" , value , ps_bitstrm , 1 ) ; ps_sps -> i1_scaling_list_enable_flag = value ; if ( ps_sps -> i1_scaling_list_enable_flag ) { COPY_DEFAULT_SCALING_LIST ( ps_sps -> pi2_scaling_mat ) ; BITS_PARSE ( ""sps_scaling_list_data_present_flag"" , value , ps_bitstrm , 1 ) ; ps_sps -> i1_sps_scaling_list_data_present_flag = value ; if ( ps_sps -> i1_sps_scaling_list_data_present_flag ) ihevcd_scaling_list_data ( ps_codec , ps_sps -> pi2_scaling_mat ) ; } else { COPY_FLAT_SCALING_LIST ( ps_sps -> pi2_scaling_mat ) ; } BITS_PARSE ( ""asymmetric_motion_partitions_enabled_flag"" , value , ps_bitstrm , 1 ) ; ps_sps -> i1_amp_enabled_flag = value ; BITS_PARSE ( ""sample_adaptive_offset_enabled_flag"" , value , ps_bitstrm , 1 ) ; ps_sps -> i1_sample_adaptive_offset_enabled_flag = value ; BITS_PARSE ( ""pcm_enabled_flag"" , value , ps_bitstrm , 1 ) ; ps_sps -> i1_pcm_enabled_flag = value ; if ( ps_sps -> i1_pcm_enabled_flag ) { BITS_PARSE ( ""pcm_sample_bit_depth_luma"" , value , ps_bitstrm , 4 ) ; ps_sps -> i1_pcm_sample_bit_depth_luma = value + 1 ; BITS_PARSE ( ""pcm_sample_bit_depth_chroma"" , value , ps_bitstrm , 4 ) ; ps_sps -> i1_pcm_sample_bit_depth_chroma = value + 1 ; UEV_PARSE ( ""log2_min_pcm_coding_block_size_minus3"" , value , ps_bitstrm ) ; ps_sps -> i1_log2_min_pcm_coding_block_size = value + 3 ; UEV_PARSE ( ""log2_diff_max_min_pcm_coding_block_size"" , value , ps_bitstrm ) ; ps_sps -> i1_log2_diff_max_min_pcm_coding_block_size = value ; BITS_PARSE ( ""pcm_loop_filter_disable_flag"" , value , ps_bitstrm , 1 ) ; ps_sps -> i1_pcm_loop_filter_disable_flag = value ; } UEV_PARSE ( ""num_short_term_ref_pic_sets"" , value , ps_bitstrm ) ; ps_sps -> i1_num_short_term_ref_pic_sets = value ; ps_sps -> i1_num_short_term_ref_pic_sets = CLIP3 ( ps_sps -> i1_num_short_term_ref_pic_sets , 0 , MAX_STREF_PICS_SPS ) ; for ( i = 0 ; i < ps_sps -> i1_num_short_term_ref_pic_sets ; i ++ ) ihevcd_short_term_ref_pic_set ( ps_bitstrm , & ps_sps -> as_stref_picset [ 0 ] , ps_sps -> i1_num_short_term_ref_pic_sets , i , & ps_sps -> as_stref_picset [ i ] ) ; BITS_PARSE ( ""long_term_ref_pics_present_flag"" , value , ps_bitstrm , 1 ) ; ps_sps -> i1_long_term_ref_pics_present_flag = value ; if ( ps_sps -> i1_long_term_ref_pics_present_flag ) { UEV_PARSE ( ""num_long_term_ref_pics_sps"" , value , ps_bitstrm ) ; ps_sps -> i1_num_long_term_ref_pics_sps = value ; for ( i = 0 ; i < ps_sps -> i1_num_long_term_ref_pics_sps ; i ++ ) { BITS_PARSE ( ""lt_ref_pic_poc_lsb_sps[i]"" , value , ps_bitstrm , ps_sps -> i1_log2_max_pic_order_cnt_lsb ) ; ps_sps -> ai1_lt_ref_pic_poc_lsb_sps [ i ] = value ; BITS_PARSE ( ""used_by_curr_pic_lt_sps_flag[i]"" , value , ps_bitstrm , 1 ) ; ps_sps -> ai1_used_by_curr_pic_lt_sps_flag [ i ] = value ; } } BITS_PARSE ( ""sps_temporal_mvp_enable_flag"" , value , ps_bitstrm , 1 ) ; ps_sps -> i1_sps_temporal_mvp_enable_flag = value ; BITS_PARSE ( ""sps_strong_intra_smoothing_enable_flag"" , value , ps_bitstrm , 1 ) ; ps_sps -> i1_strong_intra_smoothing_enable_flag = value ; BITS_PARSE ( ""vui_parameters_present_flag"" , value , ps_bitstrm , 1 ) ; ps_sps -> i1_vui_parameters_present_flag = value ; if ( ps_sps -> i1_vui_parameters_present_flag ) ihevcd_parse_vui_parameters ( ps_bitstrm , & ps_sps -> s_vui_parameters , ps_sps -> i1_sps_max_sub_layers - 1 ) ; BITS_PARSE ( ""sps_extension_flag"" , value , ps_bitstrm , 1 ) ; { WORD32 numerator ; WORD32 ceil_offset ; ceil_offset = ( 1 << ps_sps -> i1_log2_ctb_size ) - 1 ; numerator = ps_sps -> i2_pic_width_in_luma_samples ; ps_sps -> i2_pic_wd_in_ctb = ( ( numerator + ceil_offset ) / ( 1 << ps_sps -> i1_log2_ctb_size ) ) ; numerator = ps_sps -> i2_pic_height_in_luma_samples ; ps_sps -> i2_pic_ht_in_ctb = ( ( numerator + ceil_offset ) / ( 1 << ps_sps -> i1_log2_ctb_size ) ) ; ps_sps -> i4_pic_size_in_ctb = ps_sps -> i2_pic_ht_in_ctb * ps_sps -> i2_pic_wd_in_ctb ; if ( 0 == ps_codec -> i4_sps_done ) ps_codec -> s_parse . i4_next_ctb_indx = ps_sps -> i4_pic_size_in_ctb ; numerator = ps_sps -> i2_pic_width_in_luma_samples ; ps_sps -> i2_pic_wd_in_min_cb = numerator / ( 1 << ps_sps -> i1_log2_min_coding_block_size ) ; numerator = ps_sps -> i2_pic_height_in_luma_samples ; ps_sps -> i2_pic_ht_in_min_cb = numerator / ( 1 << ps_sps -> i1_log2_min_coding_block_size ) ; } if ( ( 0 != ps_codec -> i4_first_pic_done ) && ( ( ps_codec -> i4_wd != ps_sps -> i2_pic_width_in_luma_samples ) || ( ps_codec -> i4_ht != ps_sps -> i2_pic_height_in_luma_samples ) ) ) { ps_codec -> i4_reset_flag = 1 ; return ( IHEVCD_ERROR_T ) IVD_RES_CHANGED ; } { WORD32 disp_wd , disp_ht ; WORD32 crop_unit_x , crop_unit_y ; crop_unit_x = 1 ; crop_unit_y = 1 ; if ( CHROMA_FMT_IDC_YUV420 == ps_sps -> i1_chroma_format_idc ) { crop_unit_x = 2 ; crop_unit_y = 2 ; } disp_wd = ps_sps -> i2_pic_width_in_luma_samples ; disp_wd -= ps_sps -> i2_pic_crop_left_offset * crop_unit_x ; disp_wd -= ps_sps -> i2_pic_crop_right_offset * crop_unit_x ; disp_ht = ps_sps -> i2_pic_height_in_luma_samples ; disp_ht -= ps_sps -> i2_pic_crop_top_offset * crop_unit_y ; disp_ht -= ps_sps -> i2_pic_crop_bottom_offset * crop_unit_y ; if ( ( 0 >= disp_wd ) || ( 0 >= disp_ht ) ) return IHEVCD_INVALID_PARAMETER ; ps_codec -> i4_disp_wd = disp_wd ; ps_codec -> i4_disp_ht = disp_ht ; ps_codec -> i4_wd = ps_sps -> i2_pic_width_in_luma_samples ; ps_codec -> i4_ht = ps_sps -> i2_pic_height_in_luma_samples ; { WORD32 ref_strd ; ref_strd = ALIGN32 ( ps_sps -> i2_pic_width_in_luma_samples + PAD_WD ) ; if ( ps_codec -> i4_strd < ref_strd ) { ps_codec -> i4_strd = ref_strd ; } } if ( 0 == ps_codec -> i4_share_disp_buf ) { if ( ps_codec -> i4_disp_strd < ps_codec -> i4_disp_wd ) { ps_codec -> i4_disp_strd = ps_codec -> i4_disp_wd ; } } else { if ( ps_codec -> i4_disp_strd < ps_codec -> i4_strd ) { ps_codec -> i4_disp_strd = ps_codec -> i4_strd ; } } } ps_codec -> i4_sps_done = 1 ; return ret ; } "," 1 ) ; if ( ( UWORD8 * ) ps_bitstrm -> pu4_buf > ps_bitstrm -> pu1_buf_max ) { return IHEVCD_INVALID_PARAMETER ; } ",external@libhevc/45c97f878bee15cd97262fe7f57ecea71990fed7,CVE-2017-0590,https://android.googlesource.com/platform/external/libhevc/+/45c97f878bee15cd97262fe7f57ecea71990fed7,2017-05-12T15:29Z 1584,CWE-264,"CWE-264 static int __load_segment_descriptor ( struct x86_emulate_ctxt * ctxt , u16 selector , int seg , u8 cpl , bool in_task_switch ) { struct desc_struct seg_desc , old_desc ; u8 dpl , rpl ; unsigned err_vec = GP_VECTOR ; u32 err_code = 0 ; bool null_selector = ! ( selector & ~ 0x3 ) ; ulong desc_addr ; int ret ; u16 dummy ; u32 base3 = 0 ; memset ( & seg_desc , 0 , sizeof seg_desc ) ; if ( ctxt -> mode == X86EMUL_MODE_REAL ) { ctxt -> ops -> get_segment ( ctxt , & dummy , & seg_desc , NULL , seg ) ; set_desc_base ( & seg_desc , selector << 4 ) ; goto load ; } else if ( seg <= VCPU_SREG_GS && ctxt -> mode == X86EMUL_MODE_VM86 ) { set_desc_base ( & seg_desc , selector << 4 ) ; set_desc_limit ( & seg_desc , 0xffff ) ; seg_desc . type = 3 ; seg_desc . p = 1 ; seg_desc . s = 1 ; seg_desc . dpl = 3 ; goto load ; } rpl = selector & 3 ; if ( ( seg == VCPU_SREG_CS || ( seg == VCPU_SREG_SS && ( ctxt -> mode != X86EMUL_MODE_PROT64 || rpl != cpl ) ) || seg == VCPU_SREG_TR ) && null_selector ) goto exception ; if ( seg == VCPU_SREG_TR && ( selector & ( 1 << 2 ) ) ) goto exception ; if ( null_selector ) goto load ; ret = read_segment_descriptor ( ctxt , selector , & seg_desc , & desc_addr ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; err_code = selector & 0xfffc ; err_vec = in_task_switch ? TS_VECTOR : GP_VECTOR ; if ( seg <= VCPU_SREG_GS && ! seg_desc . s ) goto exception ; if ( ! seg_desc . p ) { err_vec = ( seg == VCPU_SREG_SS ) ? SS_VECTOR : NP_VECTOR ; goto exception ; } dpl = seg_desc . dpl ; switch ( seg ) { case VCPU_SREG_SS : if ( rpl != cpl || ( seg_desc . type & 0xa ) != 0x2 || dpl != cpl ) goto exception ; break ; case VCPU_SREG_CS : if ( ! ( seg_desc . type & 8 ) ) goto exception ; if ( seg_desc . type & 4 ) { if ( dpl > cpl ) goto exception ; } else { if ( rpl > cpl || dpl != cpl ) goto exception ; } if ( seg_desc . d && seg_desc . l ) { u64 efer = 0 ; ctxt -> ops -> get_msr ( ctxt , MSR_EFER , & efer ) ; if ( efer & EFER_LMA ) goto exception ; } selector = ( selector & 0xfffc ) | cpl ; break ; case VCPU_SREG_TR : if ( seg_desc . s || ( seg_desc . type != 1 && seg_desc . type != 9 ) ) goto exception ; old_desc = seg_desc ; seg_desc . type |= 2 ; ret = ctxt -> ops -> cmpxchg_emulated ( ctxt , desc_addr , & old_desc , & seg_desc , sizeof ( seg_desc ) , & ctxt -> exception ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; break ; case VCPU_SREG_LDTR : if ( seg_desc . s || seg_desc . type != 2 ) goto exception ; break ; default : if ( ( seg_desc . type & 0xa ) == 0x8 || ( ( ( seg_desc . type & 0xc ) != 0xc ) && ( rpl > dpl && cpl > dpl ) ) ) goto exception ; break ; } if ( seg_desc . s ) { seg_desc . type |= 1 ; ret = write_segment_descriptor ( ctxt , selector , & seg_desc ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; } else if ( ctxt -> mode == X86EMUL_MODE_PROT64 ) { ret = ctxt -> ops -> read_std ( ctxt , desc_addr + 8 , & base3 , sizeof ( base3 ) , & ctxt -> exception ) ; if ( ret != X86EMUL_CONTINUE ) return ret ; } load : ctxt -> ops -> set_segment ( ctxt , selector , & seg_desc , base3 , seg ) ; return X86EMUL_CONTINUE ; exception : return emulate_exception ( ctxt , err_vec , err_code , true ) ; } "," , bool in_task_switch , struct desc_struct * desc seg ) ; if ( desc ) * desc = seg_desc ; ",torvalds@linux/d1442d85cc30ea75f7d399474ca738e0bc96f715,CVE-2014-3647,https://github.com/torvalds/linux/commit/d1442d85cc30ea75f7d399474ca738e0bc96f715,2014-11-10T11:55Z 1585,CWE-119,"CWE-119 void vp9_encode_mv ( VP9_COMP * cpi , vp9_writer * w , const MV * mv , const MV * ref , const nmv_context * mvctx , int usehp ) { const MV diff = { mv -> row - ref -> row , mv -> col - ref -> col } ; const MV_JOINT_TYPE j = vp9_get_mv_joint ( & diff ) ; usehp = usehp && vp9_use_mv_hp ( ref ) ; vp9_write_token ( w , vp9_mv_joint_tree , mvctx -> joints , & mv_joint_encodings [ j ] ) ; if ( mv_joint_vertical ( j ) ) encode_mv_component ( w , diff . row , & mvctx -> comps [ 0 ] , usehp ) ; if ( mv_joint_horizontal ( j ) ) encode_mv_component ( w , diff . col , & mvctx -> comps [ 1 ] , usehp ) ; if ( ! cpi -> dummy_packing && cpi -> sf . auto_mv_step_size ) { unsigned int maxv = MAX ( abs ( mv -> row ) , abs ( mv -> col ) ) >> 3 ; cpi -> max_mv_magnitude = MAX ( maxv , cpi -> max_mv_magnitude ) ; } } "," * cpi , vpx_writer * w , ; if ( cpi -> sf cpi -> sf . mv ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1586,CWE-476,"CWE-476 static const char * escape_xml ( const char * text ) { static char * escaped ; static size_t escaped_size ; char * out ; size_t len ; for ( out = escaped , len = 0 ; * text ; ++ len , ++ out , ++ text ) { if ( ( len + 8 ) > escaped_size ) { char * bigger_escaped ; escaped_size += 128 ; bigger_escaped = realloc ( escaped , escaped_size ) ; if ( ! bigger_escaped ) { free ( escaped ) ; escaped = NULL ; escaped_size = 0 ; return "">>>outofmemory<<<"" ; } out = bigger_escaped + len ; escaped = bigger_escaped ; } switch ( * text ) { case '&' : strcpy ( out , ""&"" ) ; len += strlen ( out ) - 1 ; out = escaped + len ; break ; case '<' : strcpy ( out , ""<"" ) ; len += strlen ( out ) - 1 ; out = escaped + len ; break ; case '>' : strcpy ( out , "">"" ) ; len += strlen ( out ) - 1 ; out = escaped + len ; break ; default : * out = * text ; break ; } } * out = '\\x0' ; return escaped ; } "," size_t len ; if ( ! strlen ( text ) ) return ""emptystring"" ; ",libexif@exif/f6334d9d32437ef13dc902f0a88a2be0063d9d1c,CVE-2021-27815,https://github.com/libexif/exif/commit/f6334d9d32437ef13dc902f0a88a2be0063d9d1c,2021-04-14T14:15Z 1587,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 1588,CWE-119,"CWE-119 void vp9_setup_past_independence ( VP9_COMMON * cm ) { struct loopfilter * const lf = & cm -> lf ; int i ; vp9_clearall_segfeatures ( & cm -> seg ) ; cm -> seg . abs_delta = SEGMENT_DELTADATA ; if ( cm -> last_frame_seg_map ) vpx_memset ( cm -> last_frame_seg_map , 0 , ( cm -> mi_rows * cm -> mi_cols ) ) ; vp9_zero ( lf -> last_ref_deltas ) ; vp9_zero ( lf -> last_mode_deltas ) ; set_default_lf_deltas ( lf ) ; lf -> last_sharpness_level = - 1 ; vp9_default_coef_probs ( cm ) ; vp9_init_mode_probs ( & cm -> fc ) ; vp9_init_mv_probs ( cm ) ; if ( cm -> frame_type == KEY_FRAME || cm -> error_resilient_mode || cm -> reset_frame_context == 3 ) { for ( i = 0 ; i < FRAME_CONTEXTS ; ++ i ) cm -> frame_contexts [ i ] = cm -> fc ; } else if ( cm -> reset_frame_context == 2 ) { cm -> frame_contexts [ cm -> frame_context_idx ] = cm -> fc ; } if ( frame_is_intra_only ( cm ) ) vpx_memset ( cm -> prev_mip , 0 , cm -> mi_stride * ( cm -> mi_rows + 1 ) * sizeof ( * cm -> prev_mip ) ) ; vpx_memset ( cm -> mip , 0 , cm -> mi_stride * ( cm -> mi_rows + 1 ) * sizeof ( * cm -> mip ) ) ; vp9_zero ( cm -> ref_frame_sign_bias ) ; cm -> frame_context_idx = 0 ; } "," cm -> last_frame_seg_map && ! cm -> frame_parallel_decode ) memset ( cm -> cm -> last_frame_seg_map , 0 , ( cm -> mi_rows * cm -> mi_cols ) ) ; if ( cm -> current_frame_seg_map ) memset ( cm -> current_frame_seg_map cm ) ; init_mode_probs ( cm -> fc ( cm ) ; cm -> fc -> initialized = 1 i ] = * frame_context_idx ] = * ( cm ) && cm -> prev_mip cm -> prev_mip && ! cm -> frame_parallel_decode ) memset ( cm -> prev_mip , 0 , cm -> mi_stride cm -> prev_mip ) ) ; ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1589,CWE-000,"CWE-000 static void ip_expire ( unsigned long arg ) { struct ipq * qp ; struct net * net ; qp = container_of ( ( struct inet_frag_queue * ) arg , struct ipq , q ) ; net = container_of ( qp -> q . net , struct net , ipv4 . frags ) ; spin_lock ( & qp -> q . lock ) ; if ( qp -> q . last_in & INET_FRAG_COMPLETE ) goto out ; ipq_kill ( qp ) ; IP_INC_STATS_BH ( net , IPSTATS_MIB_REASMTIMEOUT ) ; IP_INC_STATS_BH ( net , IPSTATS_MIB_REASMFAILS ) ; if ( ( qp -> q . last_in & INET_FRAG_FIRST_IN ) && qp -> q . fragments != NULL ) { struct sk_buff * head = qp -> q . fragments ; rcu_read_lock ( ) ; head -> dev = dev_get_by_index_rcu ( net , qp -> iif ) ; if ( ! head -> dev ) goto out_rcu_unlock ; if ( qp -> user == IP_DEFRAG_CONNTRACK_IN && ! skb_dst ( head ) ) { const struct iphdr * iph = ip_hdr ( head ) ; int err = ip_route_input ( head , iph -> daddr , iph -> saddr , iph -> tos , head -> dev ) ; if ( unlikely ( err ) ) goto out_rcu_unlock ; if ( skb_rtable ( head ) -> rt_type != RTN_LOCAL ) goto out_rcu_unlock ; } icmp_send ( head , ICMP_TIME_EXCEEDED , ICMP_EXC_FRAGTIME , 0 ) ; out_rcu_unlock : rcu_read_unlock ( ) ; } out : spin_unlock ( & qp -> q . lock ) ; ipq_put ( qp ) ; } "," . fragments ; const struct iphdr * iph ; int err ; head -> dev ) goto out_rcu_unlock ; skb_dst_drop ( head ) ; iph = ip_hdr ( head ) ; err = ip_route_input_noref ( head , iph -> daddr , iph -> saddr , iph -> tos , head -> dev ) ; if ( err == IP_DEFRAG_CONNTRACK_IN && skb_rtable ( head goto out_rcu_unlock ; icmp_send ( head ",torvalds@linux/64f3b9e203bd06855072e295557dca1485a2ecba,CVE-2011-1927,https://github.com/torvalds/linux/commit/64f3b9e203bd06855072e295557dca1485a2ecba,2012-06-13T10:24Z 1590,CWE-119,"CWE-119 static Image * ReadBMPImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { BMPInfo bmp_info ; Image * image ; IndexPacket index ; MagickBooleanType status ; MagickOffsetType offset , start_position ; MemoryInfo * pixel_info ; register IndexPacket * indexes ; register PixelPacket * q ; register ssize_t i , x ; register unsigned char * p ; size_t bit , blue , bytes_per_line , green , length , red ; ssize_t count , y ; unsigned char magick [ 12 ] , * 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 ) ; } ( void ) ResetMagickMemory ( & bmp_info , 0 , sizeof ( bmp_info ) ) ; bmp_info . ba_offset = 0 ; start_position = 0 ; count = ReadBlob ( image , 2 , magick ) ; do { LongPixelPacket shift ; PixelPacket quantum_bits ; size_t profile_data , profile_size ; if ( bmp_info . ba_offset == 0 ) 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 == 0 ) || ( ( LocaleNCompare ( ( char * ) magick , ""BM"" , 2 ) != 0 ) && ( LocaleNCompare ( ( char * ) magick , ""CI"" , 2 ) != 0 ) ) ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; bmp_info . file_size = ReadBlobLSBLong ( image ) ; ( void ) ReadBlobLSBLong ( image ) ; if ( image -> debug != MagickFalse ) ( void ) LogMagickEvent ( CoderEvent , GetMagickModule ( ) , ""File_sizeinheader:%ubytes"" , bmp_info . file_size ) ; 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"" , MaxTextExtent ) ; 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 ) ( ( int ) ReadBlobLSBLong ( image ) ) ; bmp_info . height = ( ssize_t ) ( ( int ) ReadBlobLSBLong ( 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 ) ; bmp_info . colors_important = ReadBlobLSBLong ( image ) ; profile_data = 0 ; profile_size = 0 ; 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 ( ( int ) 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 sum ; bmp_info . alpha_mask = ReadBlobLSBLong ( image ) ; bmp_info . colorspace = ( int ) ReadBlobLSBLong ( 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 ; sum = bmp_info . red_primary . x + bmp_info . red_primary . y + bmp_info . red_primary . z ; bmp_info . red_primary . x /= sum ; bmp_info . red_primary . y /= sum ; image -> chromaticity . red_primary . x = bmp_info . red_primary . x ; image -> chromaticity . red_primary . y = bmp_info . red_primary . y ; sum = bmp_info . green_primary . x + bmp_info . green_primary . y + bmp_info . green_primary . z ; bmp_info . green_primary . x /= sum ; bmp_info . green_primary . y /= sum ; image -> chromaticity . green_primary . x = bmp_info . green_primary . x ; image -> chromaticity . green_primary . y = bmp_info . green_primary . y ; sum = bmp_info . blue_primary . x + bmp_info . blue_primary . y + bmp_info . blue_primary . z ; bmp_info . blue_primary . x /= sum ; bmp_info . blue_primary . y /= sum ; 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"" , MaxTextExtent ) ; 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 ; } } profile_data = ReadBlobLSBLong ( image ) ; profile_size = ReadBlobLSBLong ( image ) ; ( void ) profile_data ; ( void ) profile_size ; ( 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 : case BI_RLE8 : case BI_RLE4 : 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 -> matte = ( ( bmp_info . alpha_mask != 0 ) && ( bmp_info . compression == BI_BITFIELDS ) ) || ( bmp_info . bits_per_pixel == 32 ) ? MagickTrue : MagickFalse ; 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 ; } 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 ) == 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 ) ThrowReaderException ( CorruptImageError , ""ImproperImageHeader"" ) ; count = ReadBlob ( image , packet_size * image -> colors , bmp_colormap ) ; if ( count != ( ssize_t ) ( packet_size * image -> colors ) ) ThrowReaderException ( CorruptImageError , ""InsufficientImageDataInFile"" ) ; p = bmp_colormap ; for ( i = 0 ; i < ( ssize_t ) image -> colors ; i ++ ) { image -> colormap [ i ] . blue = ScaleCharToQuantum ( * p ++ ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( * p ++ ) ; image -> colormap [ i ] . red = ScaleCharToQuantum ( * p ++ ) ; if ( packet_size == 4 ) p ++ ; } bmp_colormap = ( unsigned char * ) RelinquishMagickMemory ( bmp_colormap ) ; } image -> x_resolution = ( double ) bmp_info . x_pixels / 100.0 ; image -> y_resolution = ( 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 ; 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 ; pixel_info = AcquireVirtualMemory ( ( size_t ) 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 ( ( bmp_info . compression == BI_RGB ) || ( bmp_info . compression == BI_BITFIELDS ) ) { 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 { status = DecodeImage ( image , bmp_info . compression , pixels ) ; if ( status == MagickFalse ) { pixel_info = RelinquishVirtualMemory ( pixel_info ) ; ThrowReaderException ( CorruptImageError , ""UnableToRunlengthDecodeImage"" ) ; } } if ( bmp_info . compression == BI_RGB ) { bmp_info . alpha_mask = image -> matte != MagickFalse ? 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 ; } } if ( ( bmp_info . bits_per_pixel == 16 ) || ( bmp_info . bits_per_pixel == 32 ) ) { register size_t sample ; ( void ) ResetMagickMemory ( & shift , 0 , sizeof ( shift ) ) ; ( void ) ResetMagickMemory ( & quantum_bits , 0 , sizeof ( quantum_bits ) ) ; if ( bmp_info . red_mask != 0 ) while ( ( ( bmp_info . red_mask << shift . red ) & 0x80000000UL ) == 0 ) shift . red ++ ; if ( bmp_info . green_mask != 0 ) while ( ( ( bmp_info . green_mask << shift . green ) & 0x80000000UL ) == 0 ) shift . green ++ ; if ( bmp_info . blue_mask != 0 ) while ( ( ( bmp_info . blue_mask << shift . blue ) & 0x80000000UL ) == 0 ) shift . blue ++ ; if ( bmp_info . alpha_mask != 0 ) while ( ( ( bmp_info . alpha_mask << shift . opacity ) & 0x80000000UL ) == 0 ) shift . opacity ++ ; sample = shift . red ; while ( ( ( bmp_info . red_mask << sample ) & 0x80000000UL ) != 0 ) sample ++ ; quantum_bits . red = ClampToQuantum ( ( MagickRealType ) sample - shift . red ) ; sample = shift . green ; while ( ( ( bmp_info . green_mask << sample ) & 0x80000000UL ) != 0 ) sample ++ ; quantum_bits . green = ClampToQuantum ( ( MagickRealType ) sample - shift . green ) ; sample = shift . blue ; while ( ( ( bmp_info . blue_mask << sample ) & 0x80000000UL ) != 0 ) sample ++ ; quantum_bits . blue = ClampToQuantum ( ( MagickRealType ) sample - shift . blue ) ; sample = shift . opacity ; while ( ( ( bmp_info . alpha_mask << sample ) & 0x80000000UL ) != 0 ) sample ++ ; quantum_bits . opacity = ClampToQuantum ( ( MagickRealType ) sample - shift . opacity ) ; } 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 == ( PixelPacket * ) NULL ) break ; indexes = GetAuthenticIndexQueue ( image ) ; for ( x = 0 ; x < ( ( ssize_t ) image -> columns - 7 ) ; x += 8 ) { for ( bit = 0 ; bit < 8 ; bit ++ ) { index = ( IndexPacket ) ( ( ( * p ) & ( 0x80 >> bit ) ) != 0 ? 0x01 : 0x00 ) ; SetPixelIndex ( indexes + x + bit , index ) ; q ++ ; } p ++ ; } if ( ( image -> columns % 8 ) != 0 ) { for ( bit = 0 ; bit < ( image -> columns % 8 ) ; bit ++ ) { index = ( IndexPacket ) ( ( ( * p ) & ( 0x80 >> bit ) ) != 0 ? 0x01 : 0x00 ) ; SetPixelIndex ( indexes + x + bit , index ) ; } 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 ) ; 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 == ( 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 ) ; index = ConstrainColormapIndex ( image , * p & 0x0f ) ; SetPixelIndex ( indexes + x + 1 , index ) ; p ++ ; } if ( ( image -> columns % 2 ) != 0 ) { index = ConstrainColormapIndex ( image , ( * p >> 4 ) & 0xf ) ; SetPixelIndex ( indexes + x , index ) ; 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 ) ; 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 == ( PixelPacket * ) NULL ) break ; indexes = GetAuthenticIndexQueue ( image ) ; for ( x = ( ssize_t ) image -> columns ; x != 0 ; -- x ) { index = ConstrainColormapIndex ( image , * p ) ; SetPixelIndex ( indexes , index ) ; indexes ++ ; p ++ ; q ++ ; } 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 ) ; break ; } case 16 : { size_t 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 == ( PixelPacket * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { pixel = ( size_t ) ( * 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 ) ; alpha = ( ( pixel & bmp_info . alpha_mask ) << shift . opacity ) >> 16 ; if ( quantum_bits . opacity <= 8 ) alpha |= ( ( alpha & 0xff00 ) >> 8 ) ; SetPixelRed ( q , ScaleShortToQuantum ( ( unsigned short ) red ) ) ; SetPixelGreen ( q , ScaleShortToQuantum ( ( unsigned short ) green ) ) ; SetPixelBlue ( q , ScaleShortToQuantum ( ( unsigned short ) blue ) ) ; SetPixelOpacity ( q , OpaqueOpacity ) ; if ( image -> matte != MagickFalse ) SetPixelAlpha ( q , ScaleShortToQuantum ( ( unsigned short ) alpha ) ) ; q ++ ; } 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 == ( PixelPacket * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelBlue ( q , ScaleCharToQuantum ( * p ++ ) ) ; SetPixelGreen ( q , ScaleCharToQuantum ( * p ++ ) ) ; SetPixelRed ( q , ScaleCharToQuantum ( * p ++ ) ) ; SetPixelOpacity ( q , OpaqueOpacity ) ; q ++ ; } 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 -- ) { size_t alpha , pixel ; p = pixels + ( image -> rows - y - 1 ) * bytes_per_line ; q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { pixel = ( size_t ) ( * p ++ ) ; pixel |= ( ( size_t ) * p ++ << 8 ) ; pixel |= ( ( size_t ) * p ++ << 16 ) ; pixel |= ( ( size_t ) * 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 ) ; alpha = ( ( pixel & bmp_info . alpha_mask ) << shift . opacity ) >> 16 ; if ( quantum_bits . opacity == 8 ) alpha |= ( alpha >> 8 ) ; SetPixelRed ( q , ScaleShortToQuantum ( ( unsigned short ) red ) ) ; SetPixelGreen ( q , ScaleShortToQuantum ( ( unsigned short ) green ) ) ; SetPixelBlue ( q , ScaleShortToQuantum ( ( unsigned short ) blue ) ) ; SetPixelAlpha ( q , OpaqueOpacity ) ; if ( image -> matte != MagickFalse ) SetPixelAlpha ( q , ScaleShortToQuantum ( ( unsigned short ) alpha ) ) ; q ++ ; } 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 ( 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 ) ; image = DestroyImage ( 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 ) ; 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 ( IsBMP ( magick , 2 ) != MagickFalse ) ; ( 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 1591,CWE-787,"CWE-787 VOID ixheaacd_shiftrountine_with_rnd_hq ( WORD32 * qmf_real , WORD32 * qmf_imag , WORD32 * filter_states , WORD32 len , WORD32 shift ) { WORD32 * filter_states_rev = filter_states + len ; WORD32 treal , timag ; WORD32 j ; for ( j = ( len - 1 ) ; j >= 0 ; j -= 2 ) { WORD32 r1 , r2 , i1 , i2 ; i2 = qmf_imag [ j ] ; r2 = qmf_real [ j ] ; r1 = * qmf_real ++ ; i1 = * qmf_imag ++ ; timag = ixheaacd_add32 ( i1 , r1 ) ; timag = ( ixheaacd_shl32_sat ( timag , shift ) ) ; filter_states_rev [ j ] = timag ; treal = ixheaacd_sub32 ( i2 , r2 ) ; treal = ( ixheaacd_shl32_sat ( treal , shift ) ) ; filter_states [ j ] = treal ; treal = ixheaacd_sub32 ( i1 , r1 ) ; treal = ( ixheaacd_shl32_sat ( treal , shift ) ) ; * filter_states ++ = treal ; timag = ixheaacd_add32 ( i2 , r2 ) ; timag = ( ixheaacd_shl32_sat ( timag , shift ) ) ; * filter_states_rev ++ = timag ; } } "," ; timag = ixheaacd_add32_sat ( i1 , ; treal = ixheaacd_sub32_sat ( i2 , r2 ) ; treal = ( ixheaacd_shl32_sat ( treal , shift ) ) ; filter_states [ j ] = treal ; treal = ixheaacd_sub32_sat ( i1 , r1 ) ; treal = ( ixheaacd_shl32_sat ( treal , shift ) ) ; * filter_states ++ = treal ; timag = ixheaacd_add32_sat ( i2 , ",external@libxaac/04e8cd58f075bec5892e369c8deebca9c67e855c,CVE-2018-9496,https://android.googlesource.com/platform/external/libxaac/+/04e8cd58f075bec5892e369c8deebca9c67e855c,2018-10-02T19:29Z 1592,CWE-119,"CWE-119 void vp8_yv12_extend_frame_borders_c ( YV12_BUFFER_CONFIG * ybf ) { assert ( ybf -> y_height - ybf -> y_crop_height < 16 ) ; assert ( ybf -> y_width - ybf -> y_crop_width < 16 ) ; assert ( ybf -> y_height - ybf -> y_crop_height >= 0 ) ; assert ( ybf -> y_width - ybf -> y_crop_width >= 0 ) ; extend_plane ( ybf -> y_buffer , ybf -> y_stride , ybf -> y_crop_width , ybf -> y_crop_height , ybf -> border , ybf -> border , ybf -> border + ybf -> y_height - ybf -> y_crop_height , ybf -> border + ybf -> y_width - ybf -> y_crop_width ) ; extend_plane ( ybf -> u_buffer , ybf -> uv_stride , ( ybf -> y_crop_width + 1 ) / 2 , ( ybf -> y_crop_height + 1 ) / 2 , ybf -> border / 2 , ybf -> border / 2 , ( ybf -> border + ybf -> y_height - ybf -> y_crop_height + 1 ) / 2 , ( ybf -> border + ybf -> y_width - ybf -> y_crop_width + 1 ) / 2 ) ; extend_plane ( ybf -> v_buffer , ybf -> uv_stride , ( ybf -> y_crop_width + 1 ) / 2 , ( ybf -> y_crop_height + 1 ) / 2 , ybf -> border / 2 , ybf -> border / 2 , ( ybf -> border + ybf -> y_height - ybf -> y_crop_height + 1 ) / 2 , ( ybf -> border + ybf -> y_width - ybf -> y_crop_width + 1 ) / 2 ) ; } "," ybf ) { const int uv_border = ybf -> border / 2 ; assert ( ybf -> border % 2 == 0 ) ; 0 ) ; # if CONFIG_VP9_HIGHBITDEPTH if ( ybf -> flags & YV12_FLAG_HIGHBITDEPTH ) { extend_plane_high ( ybf -> y_buffer , ybf -> y_stride , ybf -> y_crop_width , ybf -> y_crop_height , ybf -> border , ybf -> border , ybf -> border + ybf -> y_height - ybf -> y_crop_height , ybf -> border + ybf -> y_width - ybf -> y_crop_width ) ; extend_plane_high ( ybf -> u_buffer , ybf -> uv_stride , ybf -> uv_crop_width , ybf -> uv_crop_height , uv_border , uv_border , uv_border + ybf -> uv_height - ybf -> uv_crop_height , uv_border + ybf -> uv_width - ybf -> uv_crop_width ) ; extend_plane_high ( ybf -> v_buffer , ybf -> uv_stride , ybf -> uv_crop_width , ybf -> uv_crop_height , uv_border , uv_border , uv_border + ybf -> uv_height - ybf -> uv_crop_height , uv_border + ybf -> uv_width - ybf -> uv_crop_width ) ; return ; } # endif -> uv_stride , ybf -> uv_crop_width , ybf -> uv_crop_height , uv_border , uv_border , uv_border + ybf -> uv_height - ybf -> uv_crop_height , uv_border + ybf -> uv_width - ybf -> uv_crop_width ) ; extend_plane -> uv_stride , ybf -> uv_crop_width , ybf -> uv_crop_height , uv_border , uv_border , uv_border + ybf -> uv_height - ybf -> uv_crop_height , uv_border + ybf -> uv_width - ybf -> uv_crop_width ) ; } ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1593,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 1594,CWE-119,"CWE-119 static ALGobject * ALGnew ( PyObject * self , PyObject * args , PyObject * kwdict ) { unsigned char * key , * IV ; ALGobject * new = NULL ; int keylen , IVlen = 0 , mode = MODE_ECB , segment_size = 0 ; PyObject * counter = NULL ; int counter_shortcut = 0 ; # ifdef PCT_ARC2_MODULE int effective_keylen = 1024 ; # endif if ( ! PyArg_ParseTupleAndKeywords ( args , kwdict , ""s#|is#Oi"" # ifdef PCT_ARC2_MODULE ""i"" # endif , kwlist , & key , & keylen , & mode , & IV , & IVlen , & counter , & segment_size # ifdef PCT_ARC2_MODULE , & effective_keylen # endif ) ) { return NULL ; } if ( mode < MODE_ECB || mode > MODE_CTR ) { PyErr_Format ( PyExc_ValueError , ""Unknowncipherfeedbackmode%i"" , mode ) ; return NULL ; } if ( mode == MODE_PGP ) { PyErr_Format ( PyExc_ValueError , ""MODE_PGPisnotsupportedanymore"" ) ; return NULL ; } if ( KEY_SIZE != 0 && keylen != KEY_SIZE ) { PyErr_Format ( PyExc_ValueError , ""Keymustbe%ibyteslong,not%i"" , KEY_SIZE , keylen ) ; return NULL ; } if ( KEY_SIZE == 0 && keylen == 0 ) { PyErr_SetString ( PyExc_ValueError , ""Keycannotbethenullstring"" ) ; return NULL ; } if ( IVlen != BLOCK_SIZE && mode != MODE_ECB && mode != MODE_CTR ) { PyErr_Format ( PyExc_ValueError , ""IVmustbe%ibyteslong"" , BLOCK_SIZE ) ; return NULL ; } if ( mode == MODE_CFB ) { if ( segment_size == 0 ) segment_size = 8 ; if ( segment_size < 1 || segment_size > BLOCK_SIZE * 8 || ( ( segment_size & 7 ) != 0 ) ) { PyErr_Format ( PyExc_ValueError , ""segment_sizemustbemultipleof8(bits)"" ""between1and%i"" , BLOCK_SIZE * 8 ) ; return NULL ; } } if ( mode == MODE_CTR ) { if ( counter == NULL ) { PyErr_SetString ( PyExc_TypeError , ""\'counter\'keywordparameterisrequiredwithCTRmode"" ) ; return NULL ; } else if ( Py_TYPE ( counter ) == PCT_CounterBEType || Py_TYPE ( counter ) == PCT_CounterLEType ) { counter_shortcut = 1 ; } else if ( ! PyCallable_Check ( counter ) ) { PyErr_SetString ( PyExc_ValueError , ""\'counter\'parametermustbeacallableobject"" ) ; return NULL ; } } else { if ( counter != NULL ) { PyErr_SetString ( PyExc_ValueError , ""\'counter\'parameteronlyusefulwithCTRmode"" ) ; return NULL ; } } # ifdef PCT_ARC2_MODULE if ( effective_keylen < 0 || effective_keylen > 1024 ) { PyErr_Format ( PyExc_ValueError , ""RC2:effective_keylenmustbebetween0and1024,not%i"" , effective_keylen ) ; return NULL ; } # endif new = newALGobject ( ) ; new -> segment_size = segment_size ; new -> counter = counter ; Py_XINCREF ( counter ) ; new -> counter_shortcut = counter_shortcut ; # ifdef PCT_ARC2_MODULE new -> st . effective_keylen = effective_keylen ; # endif block_init ( & ( new -> st ) , key , keylen ) ; if ( PyErr_Occurred ( ) ) { Py_DECREF ( new ) ; return NULL ; } memset ( new -> IV , 0 , BLOCK_SIZE ) ; memset ( new -> oldCipher , 0 , BLOCK_SIZE ) ; memcpy ( new -> IV , IV , IVlen ) ; new -> mode = mode ; new -> count = BLOCK_SIZE ; return new ; } "," PyExc_ValueError , ""Keycannotbethenullstring"" ) ; return NULL ; } if ( IVlen != 0 && mode == MODE_ECB ) { PyErr_Format ( PyExc_ValueError , ""ECBmodedoesnotuseIV"" ) ; return NULL ; } if ( IVlen != 0 && mode == MODE_CTR ) { PyErr_Format ( PyExc_ValueError , ""CTRmodeneedscounterparameter,notIV"" ",dlitz@pycrypto/8dbe0dc3eea5c689d4f76b37b93fe216cf1f00d4,CVE-2013-7459,https://github.com/dlitz/pycrypto/commit/8dbe0dc3eea5c689d4f76b37b93fe216cf1f00d4,2017-02-15T15:59Z 1595,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 1596,CWE-476,"CWE-476 void dump_isom_sdp ( GF_ISOFile * file , char * inName , Bool is_final_name ) { const char * sdp ; u32 size , i ; FILE * dump ; if ( inName ) { char szBuf [ 1024 ] ; strcpy ( szBuf , inName ) ; if ( ! is_final_name ) { char * ext = strchr ( szBuf , '.' ) ; if ( ext ) ext [ 0 ] = 0 ; strcat ( szBuf , ""_sdp.txt"" ) ; } dump = gf_fopen ( szBuf , ""wt"" ) ; if ( ! dump ) { fprintf ( stderr , ""Failedtoopen%sfordumping\\n"" , szBuf ) ; return ; } } else { dump = stdout ; fprintf ( dump , ""*FileSDPcontent*\\n\\n"" ) ; } gf_isom_sdp_get ( file , & sdp , & size ) ; fprintf ( dump , ""%s"" , sdp ) ; fprintf ( dump , ""\\r\\n"" ) ; for ( i = 0 ; i < gf_isom_get_track_count ( file ) ; i ++ ) { if ( gf_isom_get_media_type ( file , i + 1 ) != GF_ISOM_MEDIA_HINT ) continue ; gf_isom_sdp_track_get ( file , i + 1 , & sdp , & size ) ; fprintf ( dump , ""%s"" , sdp ) ; } fprintf ( dump , ""\\n\\n"" ) ; if ( inName ) gf_fclose ( dump ) ; } "," size ) ; if ( sdp && size ) ",gpac@gpac/ce01bd15f711d4575b7424b54b3a395ec64c1784,CVE-2020-23932,https://github.com/gpac/gpac/commit/ce01bd15f711d4575b7424b54b3a395ec64c1784,2021-04-21T18:15Z 1597,CWE-908,"CWE-908 static int kvaser_usb_leaf_flush_queue ( struct kvaser_usb_net_priv * priv ) { struct kvaser_cmd * cmd ; int rc ; cmd = kmalloc ( sizeof ( * cmd ) , GFP_KERNEL ) ; if ( ! cmd ) return - ENOMEM ; cmd -> id = CMD_FLUSH_QUEUE ; cmd -> len = CMD_HEADER_LEN + sizeof ( struct kvaser_cmd_flush_queue ) ; cmd -> u . flush_queue . channel = priv -> channel ; cmd -> u . flush_queue . flags = 0x00 ; rc = kvaser_usb_send_cmd ( priv -> dev , cmd , cmd -> len ) ; kfree ( cmd ) ; return rc ; } "," ; cmd = kzalloc ( sizeof ( ",torvalds@linux/da2311a6385c3b499da2ed5d9be59ce331fa93e9,CVE-2019-19947,https://github.com/torvalds/linux/commit/da2311a6385c3b499da2ed5d9be59ce331fa93e9,2019-12-24T00:15Z 1598,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/9221b5c249f9e4843f77c7f888d5705348d179c0,CVE-2015-8012,https://github.com/vincentbernat/lldpd/commit/9221b5c249f9e4843f77c7f888d5705348d179c0,2020-01-28T19:15Z 1599,CWE-200,"CWE-200 unsigned paravirt_patch_call ( void * insnbuf , const void * target , u16 tgt_clobbers , unsigned long addr , u16 site_clobbers , unsigned len ) { struct branch * b = insnbuf ; unsigned long delta = ( unsigned long ) target - ( addr + 5 ) ; if ( tgt_clobbers & ~ site_clobbers ) return len ; if ( len < 5 ) return len ; b -> opcode = 0xe8 ; b -> delta = delta ; BUILD_BUG_ON ( sizeof ( * b ) != 5 ) ; return 5 ; } "," ; if ( len < 5 ) { # ifdef CONFIG_RETPOLINE WARN_ONCE ( ""FailingtopatchindirectCALLin%ps\\n"" , ( void * ) addr ) ; # endif return len ; return len ; } b -> opcode ",torvalds@linux/5800dc5c19f34e6e03b5adab1282535cb102fafd,CVE-2018-15594,https://github.com/torvalds/linux/commit/5800dc5c19f34e6e03b5adab1282535cb102fafd,2018-08-20T08:29Z 1600,CWE-400,"CWE-400 static struct task_struct * copy_process ( unsigned long clone_flags , unsigned long stack_start , struct pt_regs * regs , unsigned long stack_size , int __user * child_tidptr , struct pid * pid , int trace ) { int retval ; struct task_struct * p ; int cgroup_callbacks_done = 0 ; if ( ( clone_flags & ( CLONE_NEWNS | CLONE_FS ) ) == ( CLONE_NEWNS | CLONE_FS ) ) return ERR_PTR ( - EINVAL ) ; if ( ( clone_flags & CLONE_THREAD ) && ! ( clone_flags & CLONE_SIGHAND ) ) return ERR_PTR ( - EINVAL ) ; if ( ( clone_flags & CLONE_SIGHAND ) && ! ( clone_flags & CLONE_VM ) ) return ERR_PTR ( - EINVAL ) ; if ( ( clone_flags & CLONE_PARENT ) && current -> signal -> flags & SIGNAL_UNKILLABLE ) return ERR_PTR ( - EINVAL ) ; retval = security_task_create ( clone_flags ) ; if ( retval ) goto fork_out ; retval = - ENOMEM ; p = dup_task_struct ( current ) ; if ( ! p ) goto fork_out ; ftrace_graph_init_task ( p ) ; rt_mutex_init_task ( p ) ; # ifdef CONFIG_PROVE_LOCKING DEBUG_LOCKS_WARN_ON ( ! p -> hardirqs_enabled ) ; DEBUG_LOCKS_WARN_ON ( ! p -> softirqs_enabled ) ; # endif retval = - EAGAIN ; if ( atomic_read ( & p -> real_cred -> user -> processes ) >= p -> signal -> rlim [ RLIMIT_NPROC ] . rlim_cur ) { if ( ! capable ( CAP_SYS_ADMIN ) && ! capable ( CAP_SYS_RESOURCE ) && p -> real_cred -> user != INIT_USER ) goto bad_fork_free ; } retval = copy_creds ( p , clone_flags ) ; if ( retval < 0 ) goto bad_fork_free ; retval = - EAGAIN ; if ( nr_threads >= max_threads ) goto bad_fork_cleanup_count ; if ( ! try_module_get ( task_thread_info ( p ) -> exec_domain -> module ) ) goto bad_fork_cleanup_count ; p -> did_exec = 0 ; delayacct_tsk_init ( p ) ; copy_flags ( clone_flags , p ) ; INIT_LIST_HEAD ( & p -> children ) ; INIT_LIST_HEAD ( & p -> sibling ) ; rcu_copy_process ( p ) ; p -> vfork_done = NULL ; spin_lock_init ( & p -> alloc_lock ) ; init_sigpending ( & p -> pending ) ; p -> utime = cputime_zero ; p -> stime = cputime_zero ; p -> gtime = cputime_zero ; p -> utimescaled = cputime_zero ; p -> stimescaled = cputime_zero ; p -> prev_utime = cputime_zero ; p -> prev_stime = cputime_zero ; p -> default_timer_slack_ns = current -> timer_slack_ns ; task_io_accounting_init ( & p -> ioac ) ; acct_clear_integrals ( p ) ; posix_cpu_timers_init ( p ) ; p -> lock_depth = - 1 ; do_posix_clock_monotonic_gettime ( & p -> start_time ) ; p -> real_start_time = p -> start_time ; monotonic_to_bootbased ( & p -> real_start_time ) ; p -> io_context = NULL ; p -> audit_context = NULL ; cgroup_fork ( p ) ; # ifdef CONFIG_NUMA p -> mempolicy = mpol_dup ( p -> mempolicy ) ; if ( IS_ERR ( p -> mempolicy ) ) { retval = PTR_ERR ( p -> mempolicy ) ; p -> mempolicy = NULL ; goto bad_fork_cleanup_cgroup ; } mpol_fix_fork_child_flag ( p ) ; # endif # ifdef CONFIG_TRACE_IRQFLAGS p -> irq_events = 0 ; # ifdef __ARCH_WANT_INTERRUPTS_ON_CTXSW p -> hardirqs_enabled = 1 ; # else p -> hardirqs_enabled = 0 ; # endif p -> hardirq_enable_ip = 0 ; p -> hardirq_enable_event = 0 ; p -> hardirq_disable_ip = _THIS_IP_ ; p -> hardirq_disable_event = 0 ; p -> softirqs_enabled = 1 ; p -> softirq_enable_ip = _THIS_IP_ ; p -> softirq_enable_event = 0 ; p -> softirq_disable_ip = 0 ; p -> softirq_disable_event = 0 ; p -> hardirq_context = 0 ; p -> softirq_context = 0 ; # endif # ifdef CONFIG_LOCKDEP p -> lockdep_depth = 0 ; p -> curr_chain_key = 0 ; p -> lockdep_recursion = 0 ; # endif # ifdef CONFIG_DEBUG_MUTEXES p -> blocked_on = NULL ; # endif p -> bts = NULL ; p -> stack_start = stack_start ; sched_fork ( p , clone_flags ) ; retval = perf_event_init_task ( p ) ; if ( retval ) goto bad_fork_cleanup_policy ; if ( ( retval = audit_alloc ( p ) ) ) goto bad_fork_cleanup_policy ; if ( ( retval = copy_semundo ( clone_flags , p ) ) ) goto bad_fork_cleanup_audit ; if ( ( retval = copy_files ( clone_flags , p ) ) ) goto bad_fork_cleanup_semundo ; if ( ( retval = copy_fs ( clone_flags , p ) ) ) goto bad_fork_cleanup_files ; if ( ( retval = copy_sighand ( clone_flags , p ) ) ) goto bad_fork_cleanup_fs ; if ( ( retval = copy_signal ( clone_flags , p ) ) ) goto bad_fork_cleanup_sighand ; if ( ( retval = copy_mm ( clone_flags , p ) ) ) goto bad_fork_cleanup_signal ; if ( ( retval = copy_namespaces ( clone_flags , p ) ) ) goto bad_fork_cleanup_mm ; if ( ( retval = copy_io ( clone_flags , p ) ) ) goto bad_fork_cleanup_namespaces ; retval = copy_thread ( clone_flags , stack_start , stack_size , p , regs ) ; if ( retval ) goto bad_fork_cleanup_io ; if ( pid != & init_struct_pid ) { retval = - ENOMEM ; pid = alloc_pid ( p -> nsproxy -> pid_ns ) ; if ( ! pid ) goto bad_fork_cleanup_io ; if ( clone_flags & CLONE_NEWPID ) { retval = pid_ns_prepare_proc ( p -> nsproxy -> pid_ns ) ; if ( retval < 0 ) goto bad_fork_free_pid ; } } p -> pid = pid_nr ( pid ) ; p -> tgid = p -> pid ; if ( clone_flags & CLONE_THREAD ) p -> tgid = current -> tgid ; if ( current -> nsproxy != p -> nsproxy ) { retval = ns_cgroup_clone ( p , pid ) ; if ( retval ) goto bad_fork_free_pid ; } p -> set_child_tid = ( clone_flags & CLONE_CHILD_SETTID ) ? child_tidptr : NULL ; p -> clear_child_tid = ( clone_flags & CLONE_CHILD_CLEARTID ) ? child_tidptr : NULL ; # ifdef CONFIG_FUTEX p -> robust_list = NULL ; # ifdef CONFIG_COMPAT p -> compat_robust_list = NULL ; # endif INIT_LIST_HEAD ( & p -> pi_state_list ) ; p -> pi_state_cache = NULL ; # endif if ( ( clone_flags & ( CLONE_VM | CLONE_VFORK ) ) == CLONE_VM ) p -> sas_ss_sp = p -> sas_ss_size = 0 ; clear_tsk_thread_flag ( p , TIF_SYSCALL_TRACE ) ; # ifdef TIF_SYSCALL_EMU clear_tsk_thread_flag ( p , TIF_SYSCALL_EMU ) ; # endif clear_all_latency_tracing ( p ) ; p -> exit_signal = ( clone_flags & CLONE_THREAD ) ? - 1 : ( clone_flags & CSIGNAL ) ; p -> pdeath_signal = 0 ; p -> exit_state = 0 ; p -> group_leader = p ; INIT_LIST_HEAD ( & p -> thread_group ) ; cgroup_fork_callbacks ( p ) ; cgroup_callbacks_done = 1 ; write_lock_irq ( & tasklist_lock ) ; p -> cpus_allowed = current -> cpus_allowed ; p -> rt . nr_cpus_allowed = current -> rt . nr_cpus_allowed ; if ( unlikely ( ! cpu_isset ( task_cpu ( p ) , p -> cpus_allowed ) || ! cpu_online ( task_cpu ( p ) ) ) ) set_task_cpu ( p , smp_processor_id ( ) ) ; if ( clone_flags & ( CLONE_PARENT | CLONE_THREAD ) ) { p -> real_parent = current -> real_parent ; p -> parent_exec_id = current -> parent_exec_id ; } else { p -> real_parent = current ; p -> parent_exec_id = current -> self_exec_id ; } spin_lock ( & current -> sighand -> siglock ) ; recalc_sigpending ( ) ; if ( signal_pending ( current ) ) { spin_unlock ( & current -> sighand -> siglock ) ; write_unlock_irq ( & tasklist_lock ) ; retval = - ERESTARTNOINTR ; goto bad_fork_free_pid ; } if ( clone_flags & CLONE_THREAD ) { atomic_inc ( & current -> signal -> count ) ; atomic_inc ( & current -> signal -> live ) ; p -> group_leader = current -> group_leader ; list_add_tail_rcu ( & p -> thread_group , & p -> group_leader -> thread_group ) ; } if ( likely ( p -> pid ) ) { list_add_tail ( & p -> sibling , & p -> real_parent -> children ) ; tracehook_finish_clone ( p , clone_flags , trace ) ; if ( thread_group_leader ( p ) ) { if ( clone_flags & CLONE_NEWPID ) p -> nsproxy -> pid_ns -> child_reaper = p ; p -> signal -> leader_pid = pid ; tty_kref_put ( p -> signal -> tty ) ; p -> signal -> tty = tty_kref_get ( current -> signal -> tty ) ; attach_pid ( p , PIDTYPE_PGID , task_pgrp ( current ) ) ; attach_pid ( p , PIDTYPE_SID , task_session ( current ) ) ; list_add_tail_rcu ( & p -> tasks , & init_task . tasks ) ; __get_cpu_var ( process_counts ) ++ ; } attach_pid ( p , PIDTYPE_PID , pid ) ; nr_threads ++ ; } total_forks ++ ; spin_unlock ( & current -> sighand -> siglock ) ; write_unlock_irq ( & tasklist_lock ) ; proc_fork_connector ( p ) ; cgroup_post_fork ( p ) ; perf_event_fork ( p ) ; return p ; bad_fork_free_pid : if ( pid != & init_struct_pid ) free_pid ( pid ) ; bad_fork_cleanup_io : put_io_context ( p -> io_context ) ; bad_fork_cleanup_namespaces : exit_task_namespaces ( p ) ; bad_fork_cleanup_mm : if ( p -> mm ) mmput ( p -> mm ) ; bad_fork_cleanup_signal : if ( ! ( clone_flags & CLONE_THREAD ) ) __cleanup_signal ( p -> signal ) ; bad_fork_cleanup_sighand : __cleanup_sighand ( p -> sighand ) ; bad_fork_cleanup_fs : exit_fs ( p ) ; bad_fork_cleanup_files : exit_files ( p ) ; bad_fork_cleanup_semundo : exit_sem ( p ) ; bad_fork_cleanup_audit : audit_free ( p ) ; bad_fork_cleanup_policy : perf_event_free_task ( p ) ; # ifdef CONFIG_NUMA mpol_put ( p -> mempolicy ) ; bad_fork_cleanup_cgroup : # endif cgroup_exit ( p , cgroup_callbacks_done ) ; delayacct_tsk_free ( p ) ; module_put ( task_thread_info ( p ) -> exec_domain -> module ) ; bad_fork_cleanup_count : atomic_dec ( & p -> cred -> user -> processes ) ; exit_creds ( p ) ; bad_fork_free : free_task ( p ) ; fork_out : return ERR_PTR ( retval ) ; } "," ; bad_fork_cleanup_io : if ( p -> p -> io_context ) exit_io_context ( p ",torvalds@linux/b69f2292063d2caf37ca9aec7d63ded203701bf3,CVE-2012-0879,https://github.com/torvalds/linux/commit/b69f2292063d2caf37ca9aec7d63ded203701bf3,2012-05-17T11:00Z 1601,CWE-119,"CWE-119 static int decode_dds1 ( GetByteContext * gb , uint8_t * frame , int width , int height ) { const uint8_t * frame_start = frame ; const uint8_t * frame_end = frame + width * height ; int mask = 0x10000 , bitbuf = 0 ; int i , v , offset , count , segments ; segments = bytestream2_get_le16 ( gb ) ; while ( segments -- ) { if ( bytestream2_get_bytes_left ( gb ) < 2 ) return AVERROR_INVALIDDATA ; if ( mask == 0x10000 ) { bitbuf = bytestream2_get_le16u ( gb ) ; mask = 1 ; } if ( bitbuf & mask ) { v = bytestream2_get_le16 ( gb ) ; offset = ( v & 0x1FFF ) << 2 ; count = ( ( v >> 13 ) + 2 ) << 1 ; if ( frame - frame_start < offset || frame_end - frame < count * 2 + width ) return AVERROR_INVALIDDATA ; for ( i = 0 ; i < count ; i ++ ) { frame [ 0 ] = frame [ 1 ] = frame [ width ] = frame [ width + 1 ] = frame [ - offset ] ; frame += 2 ; } } else if ( bitbuf & ( mask << 1 ) ) { v = bytestream2_get_le16 ( gb ) * 2 ; if ( frame - frame_end < v ) return AVERROR_INVALIDDATA ; frame += v ; } else { if ( frame_end - frame < width + 3 ) return AVERROR_INVALIDDATA ; frame [ 0 ] = frame [ 1 ] = frame [ width ] = frame [ width + 1 ] = bytestream2_get_byte ( gb ) ; frame += 2 ; frame [ 0 ] = frame [ 1 ] = frame [ width ] = frame [ width + 1 ] = bytestream2_get_byte ( gb ) ; frame += 2 ; } mask <<= 2 ; } return 0 ; } "," < width + 4 ) return AVERROR_INVALIDDATA ",FFmpeg@FFmpeg/f52fbf4f3ed02a7d872d8a102006f29b4421f360,CVE-2017-9992,https://github.com/FFmpeg/FFmpeg/commit/f52fbf4f3ed02a7d872d8a102006f29b4421f360,2017-06-28T06:29Z 1602,CWE-369,"CWE-369 void * _TIFFmalloc ( tmsize_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 1603,CWE-125,"CWE-125 static void read_quant_matrix_ext ( MpegEncContext * s , GetBitContext * gb ) { int i , j , v ; if ( get_bits1 ( gb ) ) { for ( i = 0 ; i < 64 ; i ++ ) { v = get_bits ( gb , 8 ) ; j = s -> idsp . idct_permutation [ ff_zigzag_direct [ i ] ] ; s -> intra_matrix [ j ] = v ; s -> chroma_intra_matrix [ j ] = v ; } } if ( get_bits1 ( gb ) ) { for ( i = 0 ; i < 64 ; i ++ ) { get_bits ( gb , 8 ) ; } } if ( get_bits1 ( gb ) ) { for ( i = 0 ; i < 64 ; i ++ ) { v = get_bits ( gb , 8 ) ; j = s -> idsp . idct_permutation [ ff_zigzag_direct [ i ] ] ; s -> chroma_intra_matrix [ j ] = v ; } } if ( get_bits1 ( gb ) ) { for ( i = 0 ; i < 64 ; i ++ ) { get_bits ( gb , 8 ) ; } } next_start_code_studio ( gb ) ; } "," static int read_quant_matrix_ext ( MpegEncContext ) ) { if ( get_bits_left ( gb ) < 64 * 8 ) return AVERROR_INVALIDDATA ; ) ) { if ( get_bits_left ( gb ) < 64 * 8 ) return AVERROR_INVALIDDATA ; ) ) { if ( get_bits_left ( gb ) < 64 * 8 ) return AVERROR_INVALIDDATA ; ) ) { if ( get_bits_left ( gb ) < 64 * 8 ) return AVERROR_INVALIDDATA ; gb ) ; return 0 ; ",FFmpeg@FFmpeg/5aba5b89d0b1d73164d3b81764828bb8b20ff32a,CVE-2018-1999015,https://github.com/FFmpeg/FFmpeg/commit/5aba5b89d0b1d73164d3b81764828bb8b20ff32a,2018-07-23T15:29Z 1604,CWE-200,"CWE-200 static int l2tp_ip6_getname ( struct socket * sock , struct sockaddr * uaddr , int * uaddr_len , int peer ) { struct sockaddr_l2tpip6 * lsa = ( struct sockaddr_l2tpip6 * ) uaddr ; struct sock * sk = sock -> sk ; struct ipv6_pinfo * np = inet6_sk ( sk ) ; struct l2tp_ip6_sock * lsk = l2tp_ip6_sk ( sk ) ; lsa -> l2tp_family = AF_INET6 ; lsa -> l2tp_flowinfo = 0 ; lsa -> l2tp_scope_id = 0 ; if ( peer ) { if ( ! lsk -> peer_conn_id ) return - ENOTCONN ; lsa -> l2tp_conn_id = lsk -> peer_conn_id ; lsa -> l2tp_addr = np -> daddr ; if ( np -> sndflow ) lsa -> l2tp_flowinfo = np -> flow_label ; } else { if ( ipv6_addr_any ( & np -> rcv_saddr ) ) lsa -> l2tp_addr = np -> saddr ; else lsa -> l2tp_addr = np -> rcv_saddr ; lsa -> l2tp_conn_id = lsk -> conn_id ; } if ( ipv6_addr_type ( & lsa -> l2tp_addr ) & IPV6_ADDR_LINKLOCAL ) lsa -> l2tp_scope_id = sk -> sk_bound_dev_if ; * uaddr_len = sizeof ( * lsa ) ; return 0 ; } "," = 0 ; lsa -> l2tp_unused = 0 ; ",torvalds@linux/04d4fbca1017c11381e7d82acea21dd741e748bc,CVE-2012-6543,https://github.com/torvalds/linux/commit/04d4fbca1017c11381e7d82acea21dd741e748bc,2013-03-15T20:55Z 1605,CWE-119,"CWE-119 int phar_parse_zipfile ( php_stream * fp , char * fname , int fname_len , char * alias , int alias_len , phar_archive_data * * pphar , char * * error ) { phar_zip_dir_end locator ; char buf [ sizeof ( locator ) + 65536 ] ; zend_long size ; php_uint16 i ; phar_archive_data * mydata = NULL ; phar_entry_info entry = { 0 } ; char * p = buf , * ext , * actual_alias = NULL ; char * metadata = NULL ; size = php_stream_tell ( fp ) ; if ( size > sizeof ( locator ) + 65536 ) { size = sizeof ( locator ) + 65536 ; if ( FAILURE == php_stream_seek ( fp , - size , SEEK_END ) ) { php_stream_close ( fp ) ; if ( error ) { spprintf ( error , 4096 , ""pharerror:unabletosearchforendofcentraldirectoryinzip-basedphar\\""%s\\"""" , fname ) ; } return FAILURE ; } } else { php_stream_seek ( fp , 0 , SEEK_SET ) ; } if ( ! php_stream_read ( fp , buf , size ) ) { php_stream_close ( fp ) ; if ( error ) { spprintf ( error , 4096 , ""pharerror:unabletoreadindatatosearchforendofcentraldirectoryinzip-basedphar\\""%s\\"""" , fname ) ; } return FAILURE ; } while ( ( p = ( char * ) memchr ( p + 1 , 'P' , ( size_t ) ( size - ( p + 1 - buf ) ) ) ) != NULL ) { if ( ( p - buf ) + sizeof ( locator ) <= size && ! memcmp ( p + 1 , ""K\\5\\6"" , 3 ) ) { memcpy ( ( void * ) & locator , ( void * ) p , sizeof ( locator ) ) ; if ( PHAR_GET_16 ( locator . centraldisk ) != 0 || PHAR_GET_16 ( locator . disknumber ) != 0 ) { php_stream_close ( fp ) ; if ( error ) { spprintf ( error , 4096 , ""pharerror:splitarchivesspanningmultiplezipscannotbeprocessedinzip-basedphar\\""%s\\"""" , fname ) ; } return FAILURE ; } if ( PHAR_GET_16 ( locator . counthere ) != PHAR_GET_16 ( locator . count ) ) { if ( error ) { spprintf ( error , 4096 , ""pharerror:corruptziparchive,conflictingfilecountinendofcentraldirectoryrecordinzip-basedphar\\""%s\\"""" , fname ) ; } php_stream_close ( fp ) ; return FAILURE ; } mydata = pecalloc ( 1 , sizeof ( phar_archive_data ) , PHAR_G ( persist ) ) ; mydata -> is_persistent = PHAR_G ( persist ) ; if ( PHAR_GET_16 ( locator . comment_len ) ) { metadata = p + sizeof ( locator ) ; if ( PHAR_GET_16 ( locator . comment_len ) != size - ( metadata - buf ) ) { if ( error ) { spprintf ( error , 4096 , ""pharerror:corruptziparchive,zipfilecommenttruncatedinzip-basedphar\\""%s\\"""" , fname ) ; } php_stream_close ( fp ) ; pefree ( mydata , mydata -> is_persistent ) ; return FAILURE ; } mydata -> metadata_len = PHAR_GET_16 ( locator . comment_len ) ; if ( phar_parse_metadata ( & metadata , & mydata -> metadata , PHAR_GET_16 ( locator . comment_len ) ) == FAILURE ) { mydata -> metadata_len = 0 ; ZVAL_NEW_STR ( & mydata -> metadata , zend_string_init ( metadata , PHAR_GET_16 ( locator . comment_len ) , mydata -> is_persistent ) ) ; } } else { ZVAL_UNDEF ( & mydata -> metadata ) ; } goto foundit ; } } php_stream_close ( fp ) ; if ( error ) { spprintf ( error , 4096 , ""pharerror:endofcentraldirectorynotfoundinzip-basedphar\\""%s\\"""" , fname ) ; } return FAILURE ; foundit : mydata -> fname = pestrndup ( fname , fname_len , mydata -> is_persistent ) ; # ifdef PHP_WIN32 phar_unixify_path_separators ( mydata -> fname , fname_len ) ; # endif mydata -> is_zip = 1 ; mydata -> fname_len = fname_len ; ext = strrchr ( mydata -> fname , '/' ) ; if ( ext ) { mydata -> ext = memchr ( ext , '.' , ( mydata -> fname + fname_len ) - ext ) ; if ( mydata -> ext == ext ) { mydata -> ext = memchr ( ext + 1 , '.' , ( mydata -> fname + fname_len ) - ext - 1 ) ; } if ( mydata -> ext ) { mydata -> ext_len = ( mydata -> fname + fname_len ) - mydata -> ext ; } } php_stream_seek ( fp , PHAR_GET_32 ( locator . cdir_offset ) , SEEK_SET ) ; zend_hash_init ( & mydata -> manifest , PHAR_GET_16 ( locator . count ) , zend_get_hash_value , destroy_phar_manifest_entry , ( zend_bool ) mydata -> is_persistent ) ; zend_hash_init ( & mydata -> mounted_dirs , 5 , zend_get_hash_value , NULL , ( zend_bool ) mydata -> is_persistent ) ; zend_hash_init ( & mydata -> virtual_dirs , PHAR_GET_16 ( locator . count ) * 2 , zend_get_hash_value , NULL , ( zend_bool ) mydata -> is_persistent ) ; entry . phar = mydata ; entry . is_zip = 1 ; entry . fp_type = PHAR_FP ; entry . is_persistent = mydata -> is_persistent ; # define PHAR_ZIP_FAIL_FREE ( errmsg , save ) zend_hash_destroy ( & mydata -> manifest ) ; mydata -> manifest . u . flags = 0 ; zend_hash_destroy ( & mydata -> mounted_dirs ) ; mydata -> mounted_dirs . u . flags = 0 ; zend_hash_destroy ( & mydata -> virtual_dirs ) ; mydata -> virtual_dirs . u . flags = 0 ; php_stream_close ( fp ) ; zval_dtor ( & mydata -> metadata ) ; if ( mydata -> signature ) { efree ( mydata -> signature ) ; } if ( error ) { spprintf ( error , 4096 , ""pharerror:%sinzip-basedphar\\""%s\\"""" , errmsg , mydata -> fname ) ; } pefree ( mydata -> fname , mydata -> is_persistent ) ; if ( mydata -> alias ) { pefree ( mydata -> alias , mydata -> is_persistent ) ; } pefree ( mydata , mydata -> is_persistent ) ; efree ( save ) ; return FAILURE ; # define PHAR_ZIP_FAIL ( errmsg ) zend_hash_destroy ( & mydata -> manifest ) ; mydata -> manifest . u . flags = 0 ; zend_hash_destroy ( & mydata -> mounted_dirs ) ; mydata -> mounted_dirs . u . flags = 0 ; zend_hash_destroy ( & mydata -> virtual_dirs ) ; mydata -> virtual_dirs . u . flags = 0 ; php_stream_close ( fp ) ; zval_dtor ( & mydata -> metadata ) ; if ( mydata -> signature ) { efree ( mydata -> signature ) ; } if ( error ) { spprintf ( error , 4096 , ""pharerror:%sinzip-basedphar\\""%s\\"""" , errmsg , mydata -> fname ) ; } pefree ( mydata -> fname , mydata -> is_persistent ) ; if ( mydata -> alias ) { pefree ( mydata -> alias , mydata -> is_persistent ) ; } pefree ( mydata , mydata -> is_persistent ) ; return FAILURE ; for ( i = 0 ; i < PHAR_GET_16 ( locator . count ) ; ++ i ) { phar_zip_central_dir_file zipentry ; zend_off_t beforeus = php_stream_tell ( fp ) ; if ( sizeof ( zipentry ) != php_stream_read ( fp , ( char * ) & zipentry , sizeof ( zipentry ) ) ) { PHAR_ZIP_FAIL ( ""unabletoreadcentraldirectoryentry,truncated"" ) ; } if ( memcmp ( ""PK\\1\\2"" , zipentry . signature , 4 ) ) { PHAR_ZIP_FAIL ( ""corruptedcentraldirectoryentry,nomagicsignature"" ) ; } if ( entry . is_persistent ) { entry . manifest_pos = i ; } entry . compressed_filesize = PHAR_GET_32 ( zipentry . compsize ) ; entry . uncompressed_filesize = PHAR_GET_32 ( zipentry . uncompsize ) ; entry . crc32 = PHAR_GET_32 ( zipentry . crc32 ) ; entry . timestamp = phar_zip_d2u_time ( zipentry . timestamp , zipentry . datestamp ) ; entry . flags = PHAR_ENT_PERM_DEF_FILE ; entry . header_offset = PHAR_GET_32 ( zipentry . offset ) ; entry . offset = entry . offset_abs = PHAR_GET_32 ( zipentry . offset ) + sizeof ( phar_zip_file_header ) + PHAR_GET_16 ( zipentry . filename_len ) + PHAR_GET_16 ( zipentry . extra_len ) ; if ( PHAR_GET_16 ( zipentry . flags ) & PHAR_ZIP_FLAG_ENCRYPTED ) { PHAR_ZIP_FAIL ( ""Cannotprocessencryptedzipfiles"" ) ; } if ( ! PHAR_GET_16 ( zipentry . filename_len ) ) { PHAR_ZIP_FAIL ( ""Cannotprocesszipscreatedfromstdin(zero-lengthfilename)"" ) ; } entry . filename_len = PHAR_GET_16 ( zipentry . filename_len ) ; entry . filename = ( char * ) pemalloc ( entry . filename_len + 1 , entry . is_persistent ) ; if ( entry . filename_len != php_stream_read ( fp , entry . filename , entry . filename_len ) ) { pefree ( entry . filename , entry . is_persistent ) ; PHAR_ZIP_FAIL ( ""unabletoreadinfilenamefromcentraldirectory,truncated"" ) ; } entry . filename [ entry . filename_len ] = '\\0' ; if ( entry . filename [ entry . filename_len - 1 ] == '/' ) { entry . is_dir = 1 ; if ( entry . filename_len > 1 ) { entry . filename_len -- ; } entry . flags |= PHAR_ENT_PERM_DEF_DIR ; } else { entry . is_dir = 0 ; } if ( entry . filename_len == sizeof ( "".phar/signature.bin"" ) - 1 && ! strncmp ( entry . filename , "".phar/signature.bin"" , sizeof ( "".phar/signature.bin"" ) - 1 ) ) { size_t read ; php_stream * sigfile ; zend_off_t now ; char * sig ; now = php_stream_tell ( fp ) ; pefree ( entry . filename , entry . is_persistent ) ; sigfile = php_stream_fopen_tmpfile ( ) ; if ( ! sigfile ) { PHAR_ZIP_FAIL ( ""couldn\'topentemporaryfile"" ) ; } php_stream_seek ( fp , 0 , SEEK_SET ) ; php_stream_copy_to_stream_ex ( fp , sigfile , entry . header_offset , NULL ) ; php_stream_seek ( fp , PHAR_GET_32 ( locator . cdir_offset ) , SEEK_SET ) ; php_stream_copy_to_stream_ex ( fp , sigfile , beforeus - PHAR_GET_32 ( locator . cdir_offset ) , NULL ) ; if ( metadata ) { php_stream_write ( sigfile , metadata , PHAR_GET_16 ( locator . comment_len ) ) ; } php_stream_seek ( fp , sizeof ( phar_zip_file_header ) + entry . header_offset + entry . filename_len + PHAR_GET_16 ( zipentry . extra_len ) , SEEK_SET ) ; sig = ( char * ) emalloc ( entry . uncompressed_filesize ) ; read = php_stream_read ( fp , sig , entry . uncompressed_filesize ) ; if ( read != entry . uncompressed_filesize ) { php_stream_close ( sigfile ) ; efree ( sig ) ; PHAR_ZIP_FAIL ( ""signaturecannotberead"" ) ; } mydata -> sig_flags = PHAR_GET_32 ( sig ) ; if ( FAILURE == phar_verify_signature ( sigfile , php_stream_tell ( sigfile ) , mydata -> sig_flags , sig + 8 , entry . uncompressed_filesize - 8 , fname , & mydata -> signature , & mydata -> sig_len , error ) ) { efree ( sig ) ; if ( error ) { char * save ; php_stream_close ( sigfile ) ; spprintf ( & save , 4096 , ""signaturecannotbeverified:%s"" , * error ) ; efree ( * error ) ; PHAR_ZIP_FAIL_FREE ( save , save ) ; } else { php_stream_close ( sigfile ) ; PHAR_ZIP_FAIL ( ""signaturecannotbeverified"" ) ; } } php_stream_close ( sigfile ) ; efree ( sig ) ; if ( i != PHAR_GET_16 ( locator . count ) - 1 ) { PHAR_ZIP_FAIL ( ""entriesexistaftersignature,invalidphar"" ) ; } continue ; } phar_add_virtual_dirs ( mydata , entry . filename , entry . filename_len ) ; if ( PHAR_GET_16 ( zipentry . extra_len ) ) { zend_off_t loc = php_stream_tell ( fp ) ; if ( FAILURE == phar_zip_process_extra ( fp , & entry , PHAR_GET_16 ( zipentry . extra_len ) ) ) { pefree ( entry . filename , entry . is_persistent ) ; PHAR_ZIP_FAIL ( ""Unabletoprocessextrafieldheaderforfileincentraldirectory"" ) ; } php_stream_seek ( fp , loc + PHAR_GET_16 ( zipentry . extra_len ) , SEEK_SET ) ; } switch ( PHAR_GET_16 ( zipentry . compressed ) ) { case PHAR_ZIP_COMP_NONE : break ; case PHAR_ZIP_COMP_DEFLATE : entry . flags |= PHAR_ENT_COMPRESSED_GZ ; if ( ! PHAR_G ( has_zlib ) ) { pefree ( entry . filename , entry . is_persistent ) ; PHAR_ZIP_FAIL ( ""zlibextensionisrequired"" ) ; } break ; case PHAR_ZIP_COMP_BZIP2 : entry . flags |= PHAR_ENT_COMPRESSED_BZ2 ; if ( ! PHAR_G ( has_bz2 ) ) { pefree ( entry . filename , entry . is_persistent ) ; PHAR_ZIP_FAIL ( ""bzip2extensionisrequired"" ) ; } break ; case 1 : pefree ( entry . filename , entry . is_persistent ) ; PHAR_ZIP_FAIL ( ""unsupportedcompressionmethod(Shrunk)usedinthiszip"" ) ; case 2 : case 3 : case 4 : case 5 : pefree ( entry . filename , entry . is_persistent ) ; PHAR_ZIP_FAIL ( ""unsupportedcompressionmethod(Reduce)usedinthiszip"" ) ; case 6 : pefree ( entry . filename , entry . is_persistent ) ; PHAR_ZIP_FAIL ( ""unsupportedcompressionmethod(Implode)usedinthiszip"" ) ; case 7 : pefree ( entry . filename , entry . is_persistent ) ; PHAR_ZIP_FAIL ( ""unsupportedcompressionmethod(Tokenize)usedinthiszip"" ) ; case 9 : pefree ( entry . filename , entry . is_persistent ) ; PHAR_ZIP_FAIL ( ""unsupportedcompressionmethod(Deflate64)usedinthiszip"" ) ; case 10 : pefree ( entry . filename , entry . is_persistent ) ; PHAR_ZIP_FAIL ( ""unsupportedcompressionmethod(PKWareImplode/oldIBMTERSE)usedinthiszip"" ) ; case 14 : pefree ( entry . filename , entry . is_persistent ) ; PHAR_ZIP_FAIL ( ""unsupportedcompressionmethod(LZMA)usedinthiszip"" ) ; case 18 : pefree ( entry . filename , entry . is_persistent ) ; PHAR_ZIP_FAIL ( ""unsupportedcompressionmethod(IBMTERSE)usedinthiszip"" ) ; case 19 : pefree ( entry . filename , entry . is_persistent ) ; PHAR_ZIP_FAIL ( ""unsupportedcompressionmethod(IBMLZ77)usedinthiszip"" ) ; case 97 : pefree ( entry . filename , entry . is_persistent ) ; PHAR_ZIP_FAIL ( ""unsupportedcompressionmethod(WavPack)usedinthiszip"" ) ; case 98 : pefree ( entry . filename , entry . is_persistent ) ; PHAR_ZIP_FAIL ( ""unsupportedcompressionmethod(PPMd)usedinthiszip"" ) ; default : pefree ( entry . filename , entry . is_persistent ) ; PHAR_ZIP_FAIL ( ""unsupportedcompressionmethod(unknown)usedinthiszip"" ) ; } if ( PHAR_GET_16 ( zipentry . comment_len ) ) { if ( PHAR_GET_16 ( zipentry . comment_len ) != php_stream_read ( fp , buf , PHAR_GET_16 ( zipentry . comment_len ) ) ) { pefree ( entry . filename , entry . is_persistent ) ; PHAR_ZIP_FAIL ( ""unabletoreadinfilecomment,truncated"" ) ; } p = buf ; entry . metadata_len = PHAR_GET_16 ( zipentry . comment_len ) ; if ( phar_parse_metadata ( & p , & ( entry . metadata ) , PHAR_GET_16 ( zipentry . comment_len ) ) == FAILURE ) { entry . metadata_len = 0 ; ZVAL_NEW_STR ( & entry . metadata , zend_string_init ( buf , PHAR_GET_16 ( zipentry . comment_len ) , entry . is_persistent ) ) ; } } else { ZVAL_UNDEF ( & entry . metadata ) ; } if ( ! actual_alias && entry . filename_len == sizeof ( "".phar/alias.txt"" ) - 1 && ! strncmp ( entry . filename , "".phar/alias.txt"" , sizeof ( "".phar/alias.txt"" ) - 1 ) ) { php_stream_filter * filter ; zend_off_t saveloc ; phar_zip_file_header local ; saveloc = php_stream_tell ( fp ) ; php_stream_seek ( fp , PHAR_GET_32 ( zipentry . offset ) , SEEK_SET ) ; if ( sizeof ( local ) != php_stream_read ( fp , ( char * ) & local , sizeof ( local ) ) ) { pefree ( entry . filename , entry . is_persistent ) ; PHAR_ZIP_FAIL ( ""pharerror:internalcorruptionofzip-basedphar(cannotreadlocalfileheaderforalias)"" ) ; } if ( entry . filename_len != PHAR_GET_16 ( local . filename_len ) || entry . crc32 != PHAR_GET_32 ( local . crc32 ) || entry . uncompressed_filesize != PHAR_GET_32 ( local . uncompsize ) || entry . compressed_filesize != PHAR_GET_32 ( local . compsize ) ) { pefree ( entry . filename , entry . is_persistent ) ; PHAR_ZIP_FAIL ( ""pharerror:internalcorruptionofzip-basedphar(localheaderofaliasdoesnotmatchcentraldirectory)"" ) ; } entry . offset = entry . offset_abs = sizeof ( local ) + entry . header_offset + PHAR_GET_16 ( local . filename_len ) + PHAR_GET_16 ( local . extra_len ) ; php_stream_seek ( fp , entry . offset , SEEK_SET ) ; fp -> writepos = 0 ; fp -> readpos = 0 ; php_stream_seek ( fp , entry . offset , SEEK_SET ) ; fp -> writepos = 0 ; fp -> readpos = 0 ; mydata -> alias_len = entry . uncompressed_filesize ; if ( entry . flags & PHAR_ENT_COMPRESSED_GZ ) { filter = php_stream_filter_create ( ""zlib.inflate"" , NULL , php_stream_is_persistent ( fp ) ) ; if ( ! filter ) { pefree ( entry . filename , entry . is_persistent ) ; PHAR_ZIP_FAIL ( ""unabletodecompressalias,zlibfiltercreationfailed"" ) ; } php_stream_filter_append ( & fp -> readfilters , filter ) ; { zend_string * str = php_stream_copy_to_mem ( fp , entry . uncompressed_filesize , 0 ) ; if ( str ) { entry . uncompressed_filesize = ZSTR_LEN ( str ) ; actual_alias = estrndup ( ZSTR_VAL ( str ) , ZSTR_LEN ( str ) ) ; zend_string_release ( str ) ; } else { actual_alias = NULL ; entry . uncompressed_filesize = 0 ; } } if ( ! entry . uncompressed_filesize || ! actual_alias ) { pefree ( entry . filename , entry . is_persistent ) ; PHAR_ZIP_FAIL ( ""unabletoreadinalias,truncated"" ) ; } php_stream_filter_flush ( filter , 1 ) ; php_stream_filter_remove ( filter , 1 ) ; } else if ( entry . flags & PHAR_ENT_COMPRESSED_BZ2 ) { filter = php_stream_filter_create ( ""bzip2.decompress"" , NULL , php_stream_is_persistent ( fp ) ) ; if ( ! filter ) { pefree ( entry . filename , entry . is_persistent ) ; PHAR_ZIP_FAIL ( ""unabletoreadinalias,bzip2filtercreationfailed"" ) ; } php_stream_filter_append ( & fp -> readfilters , filter ) ; { zend_string * str = php_stream_copy_to_mem ( fp , entry . uncompressed_filesize , 0 ) ; if ( str ) { entry . uncompressed_filesize = ZSTR_LEN ( str ) ; actual_alias = estrndup ( ZSTR_VAL ( str ) , ZSTR_LEN ( str ) ) ; zend_string_release ( str ) ; } else { actual_alias = NULL ; entry . uncompressed_filesize = 0 ; } } if ( ! entry . uncompressed_filesize || ! actual_alias ) { pefree ( entry . filename , entry . is_persistent ) ; PHAR_ZIP_FAIL ( ""unabletoreadinalias,truncated"" ) ; } php_stream_filter_flush ( filter , 1 ) ; php_stream_filter_remove ( filter , 1 ) ; } else { { zend_string * str = php_stream_copy_to_mem ( fp , entry . uncompressed_filesize , 0 ) ; if ( str ) { entry . uncompressed_filesize = ZSTR_LEN ( str ) ; actual_alias = estrndup ( ZSTR_VAL ( str ) , ZSTR_LEN ( str ) ) ; zend_string_release ( str ) ; } else { actual_alias = NULL ; entry . uncompressed_filesize = 0 ; } } if ( ! entry . uncompressed_filesize || ! actual_alias ) { pefree ( entry . filename , entry . is_persistent ) ; PHAR_ZIP_FAIL ( ""unabletoreadinalias,truncated"" ) ; } } php_stream_seek ( fp , saveloc , SEEK_SET ) ; } phar_set_inode ( & entry ) ; zend_hash_str_add_mem ( & mydata -> manifest , entry . filename , entry . filename_len , ( void * ) & entry , sizeof ( phar_entry_info ) ) ; } mydata -> fp = fp ; if ( zend_hash_str_exists ( & ( mydata -> manifest ) , "".phar/stub.php"" , sizeof ( "".phar/stub.php"" ) - 1 ) ) { mydata -> is_data = 0 ; } else { mydata -> is_data = 1 ; } zend_hash_str_add_ptr ( & ( PHAR_G ( phar_fname_map ) ) , mydata -> fname , fname_len , mydata ) ; if ( actual_alias ) { phar_archive_data * fd_ptr ; if ( ! phar_validate_alias ( actual_alias , mydata -> alias_len ) ) { if ( error ) { spprintf ( error , 4096 , ""pharerror:invalidalias\\""%s\\""inzip-basedphar\\""%s\\"""" , actual_alias , fname ) ; } efree ( actual_alias ) ; zend_hash_str_del ( & ( PHAR_G ( phar_fname_map ) ) , mydata -> fname , fname_len ) ; return FAILURE ; } mydata -> is_temporary_alias = 0 ; if ( NULL != ( fd_ptr = zend_hash_str_find_ptr ( & ( PHAR_G ( phar_alias_map ) ) , actual_alias , mydata -> alias_len ) ) ) { if ( SUCCESS != phar_free_alias ( fd_ptr , actual_alias , mydata -> alias_len ) ) { if ( error ) { spprintf ( error , 4096 , ""pharerror:Unabletoaddzip-basedphar\\""%s\\""withimplicitalias,aliasisalreadyinuse"" , fname ) ; } efree ( actual_alias ) ; zend_hash_str_del ( & ( PHAR_G ( phar_fname_map ) ) , mydata -> fname , fname_len ) ; return FAILURE ; } } mydata -> alias = entry . is_persistent ? pestrndup ( actual_alias , mydata -> alias_len , 1 ) : actual_alias ; if ( entry . is_persistent ) { efree ( actual_alias ) ; } zend_hash_str_add_ptr ( & ( PHAR_G ( phar_alias_map ) ) , actual_alias , mydata -> alias_len , mydata ) ; } else { phar_archive_data * fd_ptr ; if ( alias_len ) { if ( NULL != ( fd_ptr = zend_hash_str_find_ptr ( & ( PHAR_G ( phar_alias_map ) ) , alias , alias_len ) ) ) { if ( SUCCESS != phar_free_alias ( fd_ptr , alias , alias_len ) ) { if ( error ) { spprintf ( error , 4096 , ""pharerror:Unabletoaddzip-basedphar\\""%s\\""withexplicitalias,aliasisalreadyinuse"" , fname ) ; } zend_hash_str_del ( & ( PHAR_G ( phar_fname_map ) ) , mydata -> fname , fname_len ) ; return FAILURE ; } } zend_hash_str_add_ptr ( & ( PHAR_G ( phar_alias_map ) ) , actual_alias , mydata -> alias_len , mydata ) ; mydata -> alias = pestrndup ( alias , alias_len , mydata -> is_persistent ) ; mydata -> alias_len = alias_len ; } else { mydata -> alias = pestrndup ( mydata -> fname , fname_len , mydata -> is_persistent ) ; mydata -> alias_len = fname_len ; } mydata -> is_temporary_alias = 1 ; } if ( pphar ) { * pphar = mydata ; } return SUCCESS ; } "," entry . uncompressed_filesize || read <= 8 ",php@php-src/0bfb970f43acd1e81d11be1154805f86655f15d5,CVE-2016-7414,https://github.com/php/php-src/commit/0bfb970f43acd1e81d11be1154805f86655f15d5,2016-09-17T21:59Z 1606,CWE-119,"CWE-119 static int64_t rd_sbuv_dcpred ( const VP9_COMP * cpi , MACROBLOCK * x , int * rate , int * rate_tokenonly , int64_t * distortion , int * skippable , BLOCK_SIZE bsize ) { const VP9_COMMON * cm = & cpi -> common ; int64_t unused ; x -> e_mbd . mi [ 0 ] -> mbmi . uv_mode = DC_PRED ; super_block_uvrd ( cpi , x , rate_tokenonly , distortion , skippable , & unused , bsize , INT64_MAX ) ; * rate = * rate_tokenonly + x -> intra_uv_mode_cost [ cm -> frame_type ] [ DC_PRED ] ; return RDCOST ( x -> rdmult , x -> rddiv , * rate , * distortion ) ; } "," = DC_PRED ; memset ( x -> skip_txfm , SKIP_TXFM_NONE , sizeof ( x -> skip_txfm ) ) ; * rate_tokenonly + cpi -> intra_uv_mode_cost [ ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1607,CWE-119,"CWE-119 static int translate_hex_string ( char * s , char * saved_orphan ) { int c1 = * saved_orphan ; char * start = s ; char * t = s ; for ( ; * s ; s ++ ) { if ( isspace ( * s ) ) continue ; if ( c1 ) { * t ++ = ( hexval ( c1 ) << 4 ) + hexval ( * s ) ; c1 = 0 ; } else c1 = * s ; } * saved_orphan = c1 ; return t - start ; } "," ( isspace ( ( unsigned char ) ",kohler@t1utils/6b9d1aafcb61a3663c883663eb19ccdbfcde8d33,CVE-2015-3905,https://github.com/kohler/t1utils/commit/6b9d1aafcb61a3663c883663eb19ccdbfcde8d33,2015-06-08T14:59Z 1608,CWE-119,"CWE-119 static void update_best_mode ( BEST_MODE * best_mode , int this_rd , RATE_DISTORTION * rd , int other_cost , MACROBLOCK * x ) { MB_PREDICTION_MODE this_mode = x -> e_mbd . mode_info_context -> mbmi . mode ; other_cost += x -> ref_frame_cost [ x -> e_mbd . mode_info_context -> mbmi . ref_frame ] ; best_mode -> yrd = RDCOST ( x -> rdmult , x -> rddiv , ( rd -> rate2 - rd -> rate_uv - other_cost ) , ( rd -> distortion2 - rd -> distortion_uv ) ) ; best_mode -> rd = this_rd ; vpx_memcpy ( & best_mode -> mbmode , & x -> e_mbd . mode_info_context -> mbmi , sizeof ( MB_MODE_INFO ) ) ; vpx_memcpy ( & best_mode -> partition , x -> partition_info , sizeof ( PARTITION_INFO ) ) ; if ( ( this_mode == B_PRED ) || ( this_mode == SPLITMV ) ) { int i ; for ( i = 0 ; i < 16 ; i ++ ) { best_mode -> bmodes [ i ] = x -> e_mbd . block [ i ] . bmi ; } } } "," = this_rd ; memcpy ( & best_mode ) ) ; memcpy ( & best_mode ",external@libvpx/5a9753fca56f0eeb9f61e342b2fccffc364f9426,CVE-2016-1621,https://android.googlesource.com/platform/external/libvpx/+/5a9753fca56f0eeb9f61e342b2fccffc364f9426,2016-03-12T21:59Z 1609,CWE-190,"CWE-190 gdImagePtr gdImageCreate ( int sx , int sy ) { int i ; gdImagePtr im ; if ( overflow2 ( sx , sy ) ) { return NULL ; } if ( overflow2 ( sizeof ( unsigned char * ) , sy ) ) { return NULL ; } im = ( gdImage * ) gdCalloc ( 1 , sizeof ( gdImage ) ) ; im -> pixels = ( unsigned char * * ) gdMalloc ( sizeof ( unsigned char * ) * sy ) ; im -> AA_opacity = ( unsigned char * * ) gdMalloc ( sizeof ( unsigned char * ) * sy ) ; im -> polyInts = 0 ; im -> polyAllocated = 0 ; im -> brush = 0 ; im -> tile = 0 ; im -> style = 0 ; for ( i = 0 ; i < sy ; i ++ ) { im -> pixels [ i ] = ( unsigned char * ) gdCalloc ( sx , sizeof ( unsigned char ) ) ; im -> AA_opacity [ i ] = ( unsigned char * ) gdCalloc ( sx , sizeof ( unsigned char ) ) ; } im -> sx = sx ; im -> sy = sy ; im -> colorsTotal = 0 ; im -> transparent = ( - 1 ) ; im -> interlace = 0 ; im -> thick = 1 ; im -> AA = 0 ; im -> AA_polygon = 0 ; for ( i = 0 ; i < gdMaxColors ; i ++ ) { im -> open [ i ] = 1 ; im -> red [ i ] = 0 ; im -> green [ i ] = 0 ; im -> blue [ i ] = 0 ; } im -> trueColor = 0 ; im -> tpixels = 0 ; im -> cx1 = 0 ; im -> cy1 = 0 ; im -> cx2 = im -> sx - 1 ; im -> cy2 = im -> sy - 1 ; im -> interpolation = NULL ; im -> interpolation_id = GD_BILINEAR_FIXED ; return im ; } "," NULL ; } if ( overflow2 ( sizeof ( unsigned char * ) , sx ) ) { return NULL ; } ",php@php-src/c395c6e5d7e8df37a21265ff76e48fe75ceb5ae6,CVE-2016-5767,https://github.com/php/php-src/commit/c395c6e5d7e8df37a21265ff76e48fe75ceb5ae6,2016-08-07T10:59Z 1610,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 1611,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