Unnamed: 0
int64 0
3.91k
| source
stringlengths 77
51.3k
| target
stringlengths 9
28.3k
|
|---|---|---|
0
|
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 ; } <vul-start> } if ( trans == NULL ) { kmem_cache_free ( rds_conn_slab , conn ) ; conn = ERR_PTR ( - ENODEV ) ; goto out ; <vul-end> } 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 ( "allocated conn %p for %pI4 -> %pI4 over %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 ; }
|
<vul-sep>
|
1
|
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 ) ; <vul-start> <vul-end> 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 ) ; }
|
<vul-sep> count = be32_to_cpu ( aclp -> acl_cnt ) ; <vul-start> if ( count > XFS_ACL_MAX_ENTRIES ) return ERR_PTR ( - EFSCORRUPTED ) ; <vul-end> acl = posix_acl_alloc ( count , GFP_KERNEL ) ; <vul-sep>
|
2
|
CWE-119 static void rd_auto_partition_range ( VP9_COMP * cpi , const TileInfo * const tile , <vul-start> <vul-end> int mi_row , int mi_col , BLOCK_SIZE * min_block_size , BLOCK_SIZE * max_block_size ) { VP9_COMMON * const cm = & cpi -> common ; <vul-start> MACROBLOCKD * const xd = & cpi -> mb . e_mbd ; MODE_INFO * * mi_8x8 = xd -> mi ; const int left_in_image = xd -> left_available && mi_8x8 [ - 1 ] ; const int above_in_image = xd -> up_available && mi_8x8 [ - xd -> mi_stride ] ; MODE_INFO * * above_sb64_mi_8x8 ; MODE_INFO * * left_sb64_mi_8x8 ; int row8x8_remaining = tile -> mi_row_end - mi_row ; int col8x8_remaining = tile -> mi_col_end - mi_col ; <vul-end> int bh , bw ; BLOCK_SIZE min_size = BLOCK_4X4 ; BLOCK_SIZE max_size = BLOCK_64X64 ; <vul-start> <vul-end> if ( left_in_image || above_in_image || cm -> frame_type != KEY_FRAME ) { min_size = BLOCK_64X64 ; max_size = BLOCK_4X4 ; if ( cm -> frame_type != KEY_FRAME ) { <vul-start> MODE_INFO * * const prev_mi = <vul-end> & cm -> prev_mi_grid_visible [ mi_row * xd -> mi_stride + mi_col ] ; <vul-start> get_sb_partition_size_range ( cpi , prev_mi , & min_size , & max_size ) ; <vul-end> } if ( left_in_image ) { <vul-start> left_sb64_mi_8x8 = & mi_8x8 [ - MI_BLOCK_SIZE ] ; get_sb_partition_size_range ( cpi , left_sb64_mi_8x8 , & min_size , & max_size ) ; <vul-end> } if ( above_in_image ) { <vul-start> above_sb64_mi_8x8 = & mi_8x8 [ - xd -> mi_stride * MI_BLOCK_SIZE ] ; get_sb_partition_size_range ( cpi , above_sb64_mi_8x8 , & min_size , & max_size ) ; <vul-end> } if ( cpi -> sf . auto_min_max_partition_size == RELAXED_NEIGHBORING_MIN_MAX ) { min_size = min_partition_size [ min_size ] ; max_size = max_partition_size [ max_size ] ; } } max_size = find_partition_size ( max_size , row8x8_remaining , col8x8_remaining , & bh , & bw ) ; <vul-start> min_size = MIN ( min_size , max_size ) ; <vul-end> if ( cpi -> sf . use_square_partition_only && next_square_size [ max_size ] < min_size ) { min_size = next_square_size [ max_size ] ; } * min_block_size = min_size ; * max_block_size = max_size ; }
|
<vul-sep> static void rd_auto_partition_range ( VP9_COMP * cpi , const TileInfo * const tile , <vul-start> MACROBLOCKD * const xd , <vul-end> int mi_row , int mi_col , <vul-sep> VP9_COMMON * const cm = & cpi -> common ; <vul-start> MODE_INFO * * mi = xd -> mi ; const int left_in_image = xd -> left_available && mi [ - 1 ] ; const int above_in_image = xd -> up_available && mi [ - xd -> mi_stride ] ; const int row8x8_remaining = tile -> mi_row_end - mi_row ; const int col8x8_remaining = tile -> mi_col_end - mi_col ; <vul-end> int bh , bw ; <vul-sep> BLOCK_SIZE max_size = BLOCK_64X64 ; <vul-start> int bs_hist [ BLOCK_SIZES ] = { 0 } ; <vul-end> if ( left_in_image || above_in_image || cm -> frame_type != KEY_FRAME ) { <vul-sep> if ( cm -> frame_type != KEY_FRAME ) { <vul-start> MODE_INFO * * prev_mi = <vul-end> & cm -> prev_mi_grid_visible [ mi_row * xd -> mi_stride + mi_col ] ; <vul-sep> <vul-end> & cm -> prev_mi_grid_visible [ mi_row * xd -> mi_stride + mi_col ] ; <vul-start> get_sb_partition_size_range ( xd , prev_mi , & min_size , & max_size , bs_hist ) ; <vul-end> } <vul-sep> if ( left_in_image ) { <vul-start> MODE_INFO * * left_sb64_mi = & mi [ - MI_BLOCK_SIZE ] ; get_sb_partition_size_range ( xd , left_sb64_mi , & min_size , & max_size , bs_hist ) ; <vul-end> } <vul-sep> if ( above_in_image ) { <vul-start> MODE_INFO * * above_sb64_mi = & mi [ - xd -> mi_stride * MI_BLOCK_SIZE ] ; get_sb_partition_size_range ( xd , above_sb64_mi , & min_size , & max_size , bs_hist ) ; <vul-end> } <vul-sep> & bh , & bw ) ; <vul-start> if ( vp9_active_edge_sb ( cpi , mi_row , mi_col ) ) { min_size = BLOCK_4X4 ; } else { min_size = MIN ( cpi -> sf . rd_auto_partition_min_limit , MIN ( min_size , max_size ) ) ; } <vul-end> if ( cpi -> sf . use_square_partition_only && <vul-sep>
|
3
|
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 , "Incorrect TPDU length indicator." ) ; return FALSE ; } if ( ! nego_read_request_token_or_cookie ( nego , s ) ) { WLog_ERR ( TAG , "Failed to parse routing token or cookie." ) ; return FALSE ; } if ( Stream_GetRemainingLength ( s ) >= 8 ) { Stream_Read_UINT8 ( s , type ) ; if ( type != TYPE_RDP_NEG_REQ ) { WLog_ERR ( TAG , "Incorrect negotiation request type %" PRIu8 "" , type ) ; return FALSE ; } <vul-start> nego_process_negotiation_request ( nego , s ) ; <vul-end> } return tpkt_ensure_stream_consumed ( s , length ) ; }
|
<vul-sep> } <vul-start> if ( ! nego_process_negotiation_request ( nego , s ) ) return FALSE ; <vul-end> } <vul-sep>
|
4
|
CWE-200 static void pipe_advance ( struct iov_iter * i , size_t size ) { struct pipe_inode_info * pipe = i -> pipe ; <vul-start> struct pipe_buffer * buf ; int idx = i -> idx ; size_t off = i -> iov_offset , orig_sz ; <vul-end> if ( unlikely ( i -> count < size ) ) size = i -> count ; <vul-start> orig_sz = size ; <vul-end> if ( size ) { <vul-start> <vul-end> if ( off ) <vul-start> size += off - pipe -> bufs [ idx ] . offset ; <vul-end> while ( 1 ) { buf = & pipe -> bufs [ idx ] ; <vul-start> if ( size <= buf -> len ) <vul-end> break ; <vul-start> size -= buf -> len ; <vul-end> idx = next_idx ( idx , pipe ) ; } <vul-start> buf -> len = size ; <vul-end> i -> idx = idx ; <vul-start> off = i -> iov_offset = buf -> offset + size ; <vul-end> } <vul-start> if ( off ) idx = next_idx ( idx , pipe ) ; if ( pipe -> nrbufs ) { int unused = ( pipe -> curbuf + pipe -> nrbufs ) & ( pipe -> buffers - 1 ) ; while ( idx != unused ) { pipe_buf_release ( pipe , & pipe -> bufs [ idx ] ) ; idx = next_idx ( idx , pipe ) ; pipe -> nrbufs -- ; } } i -> count -= orig_sz ; <vul-end> }
|
<vul-sep> if ( size ) { <vul-start> struct pipe_buffer * buf ; size_t off = i -> iov_offset , left = size ; int idx = i -> idx ; <vul-end> if ( off ) <vul-sep> <vul-end> if ( off ) <vul-start> left += off - pipe -> bufs [ idx ] . offset ; <vul-end> while ( 1 ) { <vul-sep> buf = & pipe -> bufs [ idx ] ; <vul-start> if ( left <= buf -> len ) <vul-end> break ; <vul-sep> <vul-end> break ; <vul-start> left -= buf -> len ; <vul-end> idx = next_idx ( idx , pipe ) ; <vul-sep> i -> idx = idx ; <vul-start> i -> iov_offset = buf -> offset + left ; <vul-end> } <vul-sep> <vul-end> } <vul-start> i -> count -= size ; pipe_truncate ( i ) ; <vul-end> } <vul-sep>
|
5
|
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 , "cannot open CSR file!\\n" ) ; return ; } while ( fgets ( l_line , l_line_length , l_csr_file_handle ) != NULL ) { if ( strlen ( l_line ) == l_line_length ) { fprintf ( stderr , "could not read file length!\\n" ) ; return ; } if ( l_line [ 0 ] == '%' ) { continue ; } else { if ( l_header_read == 0 ) { <vul-start> if ( sscanf ( l_line , "%u %u %u" , o_row_count , o_column_count , o_element_count ) == 3 ) { <vul-end> * 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 , "could not allocate sp data!\\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 , "could not csr description!\\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 , "could not read element!\\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 , "we were not able to read all elements!\\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 ] ; }
|
<vul-sep> if ( l_header_read == 0 ) { <vul-start> if ( 3 == sscanf ( l_line , "%u %u %u" , o_row_count , o_column_count , o_element_count ) && 0 != * o_row_count && 0 != * o_column_count && 0 != * o_element_count ) { <vul-end> * o_column_idx = ( unsigned int * ) malloc ( sizeof ( unsigned int ) * ( * o_element_count ) ) ; <vul-sep>
|
6
|
CWE-399 -static int __perf_event_overflow ( struct perf_event * event , int nmi , +static int __perf_event_overflow ( struct perf_event * event , int throttle , struct perf_sample_data * data , struct pt_regs * regs ) { int events = atomic_read ( & event -> event_limit ) ; struct hw_perf_event * hwc = & event -> hw ; int ret = 0 ; if ( unlikely ( ! is_sampling_event ( event ) ) ) return 0 ; if ( unlikely ( hwc -> interrupts >= max_samples_per_tick ) ) { if ( throttle ) { hwc -> interrupts = MAX_INTERRUPTS ; perf_log_throttle ( event , 0 ) ; ret = 1 ; } } else hwc -> interrupts ++ ; if ( event -> attr . freq ) { u64 now = perf_clock ( ) ; s64 delta = now - hwc -> freq_time_stamp ; hwc -> freq_time_stamp = now ; if ( delta > 0 && delta < 2 * TICK_NSEC ) perf_adjust_period ( event , delta , hwc -> last_period ) ; } event -> pending_kill = POLL_IN ; if ( events && atomic_dec_and_test ( & event -> event_limit ) ) { ret = 1 ; event -> pending_kill = POLL_HUP ; <vul-start> if ( nmi ) { <vul-end> event -> pending_disable = 1 ; irq_work_queue ( & event -> pending ) ; <vul-start> } else perf_event_disable ( event ) ; <vul-end> } if ( event -> overflow_handler ) <vul-start> event -> overflow_handler ( event , nmi , data , regs ) ; <vul-end> else <vul-start> perf_event_output ( event , nmi , data , regs ) ; <vul-end> if ( event -> fasync && event -> pending_kill ) { <vul-start> if ( nmi ) { <vul-end> event -> pending_wakeup = 1 ; irq_work_queue ( & event -> pending ) ; <vul-start> } else perf_event_wakeup ( event ) ; <vul-end> } return ret ; }
|
<vul-sep> if ( event -> overflow_handler ) <vul-start> event -> overflow_handler ( event , data , regs ) ; <vul-end> else <vul-sep> <vul-end> else <vul-start> perf_event_output ( event , data , regs ) ; <vul-end> if ( event -> fasync && event -> pending_kill ) { <vul-sep>
|
7
|
CWE-119 SNDFILE * sf_open_fd ( int fd , int mode , SF_INFO * sfinfo , int close_desc ) { SF_PRIVATE * psf ; if ( ( SF_CONTAINER ( sfinfo -> format ) ) == SF_FORMAT_SD2 ) { sf_errno = SFE_SD2_FD_DISALLOWED ; return NULL ; } ; <vul-start> if ( ( psf = calloc ( 1 , sizeof ( SF_PRIVATE ) ) ) == NULL ) <vul-end> { sf_errno = SFE_MALLOC_FAILED ; return NULL ; } ; psf_init_files ( psf ) ; copy_filename ( psf , "" ) ; psf -> file . mode = mode ; psf_set_file ( psf , fd ) ; psf -> is_pipe = psf_is_pipe ( psf ) ; psf -> fileoffset = psf_ftell ( psf ) ; if ( ! close_desc ) psf -> file . do_not_close_descriptor = SF_TRUE ; return psf_open_file ( psf , sfinfo ) ; }
|
<vul-sep> } ; <vul-start> if ( ( psf = psf_allocate ( ) ) == NULL ) <vul-end> { sf_errno = SFE_MALLOC_FAILED ; <vul-sep>
|
8
|
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 ; <vul-start> for ( plane = 0 ; plane < 4 && frame -> data [ plane ] ; plane ++ ) { <vul-end> 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:%s pts_time:%s pos:%" PRId64 " " "fmt:%s sar:%d/%d s:%dx%d i:%c iskey:%d type:%c " "checksum:%08X plane_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 ] ) ; <vul-start> for ( plane = 1 ; plane < 4 && frame -> data [ plane ] ; plane ++ ) <vul-end> 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 ) ; }
|
<vul-sep> int i , plane , vsub = desc -> log2_chroma_h ; <vul-start> for ( plane = 0 ; plane < 4 && frame -> data [ plane ] && frame -> linesize [ plane ] ; plane ++ ) { <vul-end> int64_t linesize = av_image_get_linesize ( frame -> format , frame -> width , plane ) ; <vul-sep> checksum , plane_checksum [ 0 ] ) ; <vul-start> for ( plane = 1 ; plane < 4 && frame -> data [ plane ] && frame -> linesize [ plane ] ; plane ++ ) <vul-end> av_log ( ctx , AV_LOG_INFO , " %08X" , plane_checksum [ plane ] ) ; <vul-sep>
|
9
|
CWE-119 u4_pos = pu1_scan [ u4_numCoeffs ++ & 63 ] ; pu1_pos [ * pi4_num_coeffs ] = u4_pos ; pi2_outAddr [ * pi4_num_coeffs ] = u4_level ; ( * pi4_num_coeffs ) ++ ; } else if ( u2_mpeg2 == 1 ) { u4_sym_len = 6 ; FLUSH_BITS ( u4_offset , u4_buf , u4_buf_nxt , u4_sym_len , pu4_buf_aligned ) IBITS_GET ( u4_buf , u4_buf_nxt , u4_offset , u4_bits , pu4_buf_aligned , 18 ) u4_decoded_value = u4_bits ; u4_run = ( u4_decoded_value >> 12 ) ; u4_level = ( u4_decoded_value & 0x0FFF ) ; if ( u4_level ) u4_level = ( u4_level - ( ( u4_level & 0x0800 ) << 1 ) ) ; u4_numCoeffs += u4_run ; u4_pos = pu1_scan [ u4_numCoeffs ++ & 63 ] ; pu1_pos [ * pi4_num_coeffs ] = u4_pos ; pi2_outAddr [ * pi4_num_coeffs ] = u4_level ; ( * pi4_num_coeffs ) ++ ; } else { u4_sym_len = 6 ; FLUSH_BITS ( u4_offset , u4_buf , u4_buf_nxt , u4_sym_len , pu4_buf_aligned ) IBITS_GET ( u4_buf , u4_buf_nxt , u4_offset , u4_bits , pu4_buf_aligned , 14 ) u4_decoded_value = u4_bits ; u4_run = ( u4_decoded_value >> 8 ) ; u4_level_first_byte = ( u4_decoded_value & 0x0FF ) ; if ( u4_level_first_byte & 0x7F ) { u4_level = ( u4_level_first_byte - ( ( u4_level_first_byte & 0x80 ) << 1 ) ) ; } else { IBITS_GET ( u4_buf , u4_buf_nxt , u4_offset , u4_bits , pu4_buf_aligned , 8 ) u4_level = u4_bits ; u4_level = ( u4_level - ( u4_level_first_byte << 1 ) ) ; } u4_numCoeffs += u4_run ; u4_pos = pu1_scan [ u4_numCoeffs ++ & 63 ] ; pu1_pos [ * pi4_num_coeffs ] = u4_pos ; pi2_outAddr [ * pi4_num_coeffs ] = u4_level ; ( * pi4_num_coeffs ) ++ ; } } } u4_nz_cols |= 1 << ( u4_pos & 0x7 ) ; u4_nz_rows |= 1 << ( u4_pos >> 0x3 ) ; <vul-start> <vul-end> } IBITS_GET ( u4_buf , u4_buf_nxt , u4_offset , u4_bits , pu4_buf_aligned , u4_sym_len ) <vul-start> if ( u4_numCoeffs > 64 ) { return IMPEG2D_MB_TEX_DECODE_ERR ; } <vul-end> } else { while ( 1 ) { UWORD32 lead_zeros ; UWORD16 DecodedValue ; u4_sym_len = 17 ; IBITS_NXT ( u4_buf , u4_buf_nxt , u4_offset , u4_bits , u4_sym_len ) DecodedValue = gau2_impeg2d_tab_zero_1_9 [ u4_bits >> 8 ] ; u4_sym_len = BITS ( DecodedValue , 3 , 0 ) ; u4_level = ( ( WORD16 ) DecodedValue ) >> 9 ; if ( 0 != u4_level ) { u4_run = BITS ( DecodedValue , 8 , 4 ) ; u4_numCoeffs += u4_run ; u4_pos = pu1_scan [ u4_numCoeffs ++ & 63 ] ; pu1_pos [ * pi4_num_coeffs ] = u4_pos ; FLUSH_BITS ( u4_offset , u4_buf , u4_buf_nxt , u4_sym_len , pu4_buf_aligned ) pi2_outAddr [ * pi4_num_coeffs ] = u4_level ; ( * pi4_num_coeffs ) ++ ; } else { if ( DecodedValue == END_OF_BLOCK_ZERO ) { u4_sym_len = 2 ; break ; } else { lead_zeros = CLZ ( u4_bits ) - 20 ; if ( 0 != lead_zeros ) { u4_bits = ( u4_bits >> ( 6 - lead_zeros ) ) & 0x001F ; u4_sym_len = 11 + lead_zeros ; u4_bits = ( ( lead_zeros - 1 ) << 5 ) + u4_bits ; DecodedValue = gau2_impeg2d_tab_zero_10_16 [ u4_bits ] ; u4_run = BITS ( DecodedValue , 8 , 4 ) ; u4_level = ( ( WORD16 ) DecodedValue ) >> 9 ; u4_numCoeffs += u4_run ; u4_pos = pu1_scan [ u4_numCoeffs ++ & 63 ] ; pu1_pos [ * pi4_num_coeffs ] = u4_pos ; if ( 1 == lead_zeros ) u4_sym_len -- ; FLUSH_BITS ( u4_offset , u4_buf , u4_buf_nxt , u4_sym_len , pu4_buf_aligned ) pi2_outAddr [ * pi4_num_coeffs ] = u4_level ; ( * pi4_num_coeffs ) ++ ; } else if ( u2_mpeg2 == 1 ) { u4_sym_len = 6 ; FLUSH_BITS ( u4_offset , u4_buf , u4_buf_nxt , u4_sym_len , pu4_buf_aligned ) IBITS_GET ( u4_buf , u4_buf_nxt , u4_offset , u4_bits , pu4_buf_aligned , 18 ) u4_decoded_value = u4_bits ; u4_run = ( u4_decoded_value >> 12 ) ; u4_level = ( u4_decoded_value & 0x0FFF ) ; if ( u4_level ) u4_level = ( u4_level - ( ( u4_level & 0x0800 ) << 1 ) ) ; u4_numCoeffs += u4_run ; u4_pos = pu1_scan [ u4_numCoeffs ++ & 63 ] ; pu1_pos [ * pi4_num_coeffs ] = u4_pos ; pi2_outAddr [ * pi4_num_coeffs ] = u4_level ; ( * pi4_num_coeffs ) ++ ; } else { u4_sym_len = 6 ; FLUSH_BITS ( u4_offset , u4_buf , u4_buf_nxt , u4_sym_len , pu4_buf_aligned ) IBITS_GET ( u4_buf , u4_buf_nxt , u4_offset , u4_bits , pu4_buf_aligned , 14 ) u4_decoded_value = u4_bits ; u4_run = ( u4_decoded_value >> 8 ) ; u4_level_first_byte = ( u4_decoded_value & 0x0FF ) ; if ( u4_level_first_byte & 0x7F ) { u4_level = ( u4_level_first_byte - ( ( u4_level_first_byte & 0x80 ) << 1 ) ) ; } else { IBITS_GET ( u4_buf , u4_buf_nxt , u4_offset , u4_bits , pu4_buf_aligned , 8 ) u4_level = u4_bits ; u4_level = ( u4_level - ( u4_level_first_byte << 1 ) ) ; } u4_numCoeffs += u4_run ; u4_pos = pu1_scan [ u4_numCoeffs ++ & 63 ] ; pu1_pos [ * pi4_num_coeffs ] = u4_pos ; pi2_outAddr [ * pi4_num_coeffs ] = u4_level ; ( * pi4_num_coeffs ) ++ ; } } } u4_nz_cols |= 1 << ( u4_pos & 0x7 ) ; u4_nz_rows |= 1 << ( u4_pos >> 0x3 ) ; <vul-start> } <vul-end> if ( u4_numCoeffs > 64 ) { return IMPEG2D_MB_TEX_DECODE_ERR ; <vul-start> <vul-end> } IBITS_GET ( u4_buf , u4_buf_nxt , u4_offset , u4_bits , pu4_buf_aligned , u4_sym_len ) } PUT_TEMP_STREAM_DATA ( u4_buf , u4_buf_nxt , u4_offset , pu4_buf_aligned , ps_stream ) ps_dec -> u4_non_zero_cols = u4_nz_cols ; ps_dec -> u4_non_zero_rows = u4_nz_rows ; return ( IMPEG2D_ERROR_CODES_T ) IVD_ERROR_NONE ; }
|
<vul-sep> u4_nz_rows |= 1 << ( u4_pos >> 0x3 ) ; <vul-start> if ( u4_numCoeffs > 64 ) { return IMPEG2D_MB_TEX_DECODE_ERR ; } <vul-end> } <vul-sep> return IMPEG2D_MB_TEX_DECODE_ERR ; <vul-start> } <vul-end> } <vul-sep>
|
10
|
CWE-19 STATIC int xfs_attr_calc_size ( struct xfs_inode * ip , int namelen , int valuelen , int * local ) { struct xfs_mount * mp = ip -> i_mount ; int size ; int nblks ; size = xfs_attr_leaf_newentsize ( namelen , valuelen , mp -> m_sb . sb_blocksize , local ) ; nblks = XFS_DAENTER_SPACE_RES ( mp , XFS_ATTR_FORK ) ; if ( * local ) { if ( size > ( mp -> m_sb . sb_blocksize >> 1 ) ) { nblks *= 2 ; } } else { <vul-start> uint dblocks = XFS_B_TO_FSB ( mp , valuelen ) ; <vul-end> nblks += dblocks ; nblks += XFS_NEXTENTADD_SPACE_RES ( mp , dblocks , XFS_ATTR_FORK ) ; } return nblks ; }
|
<vul-sep> } else { <vul-start> uint dblocks = xfs_attr3_rmt_blocks ( mp , valuelen ) ; <vul-end> nblks += dblocks ; <vul-sep>
|
11
|
NVD-CWE-noinfo static int list_fields ( MYSQL * mysql , const char * db , const char * table , const char * wild ) { <vul-start> char query [ 1024 ] , * end ; <vul-end> MYSQL_RES * result ; MYSQL_ROW row ; ulong UNINIT_VAR ( rows ) ; if ( mysql_select_db ( mysql , db ) ) { fprintf ( stderr , "%s: Cannot connect to db: %s: %s\\n" , my_progname , db , mysql_error ( mysql ) ) ; return 1 ; } if ( opt_count ) { <vul-start> sprintf ( query , "select count(*) from `%s`" , table ) ; <vul-end> if ( mysql_query ( mysql , query ) || ! ( result = mysql_store_result ( mysql ) ) ) { fprintf ( stderr , "%s: Cannot get record count for db: %s, table: %s: %s\\n" , my_progname , db , table , mysql_error ( mysql ) ) ; return 1 ; } row = mysql_fetch_row ( result ) ; rows = ( ulong ) strtoull ( row [ 0 ] , ( char * * ) 0 , 10 ) ; mysql_free_result ( result ) ; } <vul-start> end = strmov ( strmov ( strmov ( query , "show /*!32332 FULL */ columns from `" ) , table ) , "`" ) ; if ( wild && wild [ 0 ] ) strxmov ( end , " like \'" , wild , "\'" , NullS ) ; <vul-end> if ( mysql_query ( mysql , query ) || ! ( result = mysql_store_result ( mysql ) ) ) { fprintf ( stderr , "%s: Cannot list columns in db: %s, table: %s: %s\\n" , my_progname , db , table , mysql_error ( mysql ) ) ; return 1 ; } printf ( "Database: %s Table: %s" , db , table ) ; if ( opt_count ) printf ( " Rows: %lu" , rows ) ; if ( wild && wild [ 0 ] ) printf ( " Wildcard: %s" , wild ) ; putchar ( '\\n' ) ; print_res_header ( result ) ; while ( ( row = mysql_fetch_row ( result ) ) ) print_res_row ( result , row ) ; print_res_top ( result ) ; if ( opt_show_keys ) { <vul-start> end = strmov ( strmov ( strmov ( query , "show keys from `" ) , table ) , "`" ) ; <vul-end> if ( mysql_query ( mysql , query ) || ! ( result = mysql_store_result ( mysql ) ) ) { fprintf ( stderr , "%s: Cannot list keys in db: %s, table: %s: %s\\n" , my_progname , db , table , mysql_error ( mysql ) ) ; return 1 ; } if ( mysql_num_rows ( result ) ) { print_res_header ( result ) ; while ( ( row = mysql_fetch_row ( result ) ) ) print_res_row ( result , row ) ; print_res_top ( result ) ; } else puts ( "Table has no keys" ) ; } mysql_free_result ( result ) ; return 0 ; }
|
<vul-sep> { <vul-start> char query [ NAME_LEN + 100 ] ; int len ; <vul-end> MYSQL_RES * result ; <vul-sep> { <vul-start> my_snprintf ( query , sizeof ( query ) , "select count(*) from `%s`" , table ) ; <vul-end> if ( mysql_query ( mysql , query ) || ! ( result = mysql_store_result ( mysql ) ) ) <vul-sep> } <vul-start> len = sizeof ( query ) ; len -= my_snprintf ( query , len , "show /*!32332 FULL */ columns from `%s`" , table ) ; if ( wild && wild [ 0 ] && len ) strxnmov ( query + strlen ( query ) , len , " like \'" , wild , "\'" , NullS ) ; <vul-end> if ( mysql_query ( mysql , query ) || ! ( result = mysql_store_result ( mysql ) ) ) <vul-sep> { <vul-start> my_snprintf ( query , sizeof ( query ) , "show keys from `%s`" , table ) ; <vul-end> if ( mysql_query ( mysql , query ) || ! ( result = mysql_store_result ( mysql ) ) ) <vul-sep>
|
12
|
CWE-119 int process ( register int code , unsigned char * * fill ) { int incode ; static unsigned char firstchar ; if ( code == clear ) { codesize = datasize + 1 ; codemask = ( 1 << codesize ) - 1 ; avail = clear + 2 ; oldcode = - 1 ; return 1 ; } if ( oldcode == - 1 ) { <vul-start> <vul-end> * ( * fill ) ++ = suffix [ code ] ; firstchar = oldcode = code ; return 1 ; } if ( code > avail ) { fprintf ( stderr , "code %d too large for %d\\n" , code , avail ) ; return 0 ; } incode = code ; if ( code == avail ) { * stackp ++ = firstchar ; code = oldcode ; } while ( code > clear ) { * stackp ++ = suffix [ code ] ; code = prefix [ code ] ; } * stackp ++ = firstchar = suffix [ code ] ; prefix [ avail ] = oldcode ; suffix [ avail ] = firstchar ; avail ++ ; if ( ( ( avail & codemask ) == 0 ) && ( avail < 4096 ) ) { codesize ++ ; codemask += avail ; } oldcode = incode ; do { * ( * fill ) ++ = * -- stackp ; } while ( stackp > stack ) ; return 1 ; }
|
<vul-sep> if ( oldcode == - 1 ) { <vul-start> if ( code >= clear ) { fprintf ( stderr , "bad input: code=%d is larger than clear=%d\\n" , code , clear ) ; return 0 ; } <vul-end> * ( * fill ) ++ = suffix [ code ] ; <vul-sep>
|
13
|
CWE-19 int xfs_attr_rmtval_get ( struct xfs_da_args * args ) { struct xfs_bmbt_irec map [ ATTR_RMTVALUE_MAPSIZE ] ; struct xfs_mount * mp = args -> dp -> i_mount ; struct xfs_buf * bp ; xfs_dablk_t lblkno = args -> rmtblkno ; __uint8_t * dst = args -> value ; <vul-start> int valuelen = args -> valuelen ; <vul-end> int nmap ; int error ; int blkcnt = args -> rmtblkcnt ; int i ; int offset = 0 ; trace_xfs_attr_rmtval_get ( args ) ; ASSERT ( ! ( args -> flags & ATTR_KERNOVAL ) ) ; <vul-start> <vul-end> while ( valuelen > 0 ) { nmap = ATTR_RMTVALUE_MAPSIZE ; error = xfs_bmapi_read ( args -> dp , ( xfs_fileoff_t ) lblkno , blkcnt , map , & nmap , XFS_BMAPI_ATTRFORK ) ; if ( error ) return error ; ASSERT ( nmap >= 1 ) ; for ( i = 0 ; ( i < nmap ) && ( valuelen > 0 ) ; i ++ ) { xfs_daddr_t dblkno ; int dblkcnt ; ASSERT ( ( map [ i ] . br_startblock != DELAYSTARTBLOCK ) && ( map [ i ] . br_startblock != HOLESTARTBLOCK ) ) ; dblkno = XFS_FSB_TO_DADDR ( mp , map [ i ] . br_startblock ) ; dblkcnt = XFS_FSB_TO_BB ( mp , map [ i ] . br_blockcount ) ; error = xfs_trans_read_buf ( mp , NULL , mp -> m_ddev_targp , dblkno , dblkcnt , 0 , & bp , & xfs_attr3_rmt_buf_ops ) ; if ( error ) return error ; error = xfs_attr_rmtval_copyout ( mp , bp , args -> dp -> i_ino , & offset , & valuelen , & dst ) ; xfs_buf_relse ( bp ) ; if ( error ) return error ; lblkno += map [ i ] . br_blockcount ; blkcnt -= map [ i ] . br_blockcount ; } } ASSERT ( valuelen == 0 ) ; return 0 ; }
|
<vul-sep> __uint8_t * dst = args -> value ; <vul-start> int valuelen ; <vul-end> int nmap ; <vul-sep> ASSERT ( ! ( args -> flags & ATTR_KERNOVAL ) ) ; <vul-start> ASSERT ( args -> rmtvaluelen == args -> valuelen ) ; valuelen = args -> rmtvaluelen ; <vul-end> while ( valuelen > 0 ) { <vul-sep>
|
14
|
CWE-125 static BOOL update_read_icon_info ( wStream * s , ICON_INFO * iconInfo ) { BYTE * newBitMask ; if ( Stream_GetRemainingLength ( s ) < 8 ) return FALSE ; Stream_Read_UINT16 ( s , iconInfo -> cacheEntry ) ; Stream_Read_UINT8 ( s , iconInfo -> cacheId ) ; Stream_Read_UINT8 ( s , iconInfo -> bpp ) ; if ( ( iconInfo -> bpp < 1 ) || ( iconInfo -> bpp > 32 ) ) { WLog_ERR ( TAG , "invalid bpp value %" PRIu32 "" , iconInfo -> bpp ) ; return FALSE ; } Stream_Read_UINT16 ( s , iconInfo -> width ) ; Stream_Read_UINT16 ( s , iconInfo -> height ) ; switch ( iconInfo -> bpp ) { case 1 : case 4 : case 8 : if ( Stream_GetRemainingLength ( s ) < 2 ) return FALSE ; Stream_Read_UINT16 ( s , iconInfo -> cbColorTable ) ; break ; default : iconInfo -> cbColorTable = 0 ; break ; } if ( Stream_GetRemainingLength ( s ) < 4 ) return FALSE ; Stream_Read_UINT16 ( s , iconInfo -> cbBitsMask ) ; Stream_Read_UINT16 ( s , iconInfo -> cbBitsColor ) ; <vul-start> if ( Stream_GetRemainingLength ( s ) < iconInfo -> cbBitsMask + iconInfo -> cbBitsColor ) return FALSE ; <vul-end> newBitMask = ( BYTE * ) realloc ( iconInfo -> bitsMask , iconInfo -> cbBitsMask ) ; if ( ! newBitMask ) { free ( iconInfo -> bitsMask ) ; iconInfo -> bitsMask = NULL ; return FALSE ; } iconInfo -> bitsMask = newBitMask ; <vul-start> <vul-end> Stream_Read ( s , iconInfo -> bitsMask , iconInfo -> cbBitsMask ) ; if ( iconInfo -> colorTable == NULL ) { if ( iconInfo -> cbColorTable ) { iconInfo -> colorTable = ( BYTE * ) malloc ( iconInfo -> cbColorTable ) ; if ( ! iconInfo -> colorTable ) return FALSE ; } } else if ( iconInfo -> cbColorTable ) { BYTE * new_tab ; new_tab = ( BYTE * ) realloc ( iconInfo -> colorTable , iconInfo -> cbColorTable ) ; if ( ! new_tab ) { free ( iconInfo -> colorTable ) ; iconInfo -> colorTable = NULL ; return FALSE ; } iconInfo -> colorTable = new_tab ; } else { free ( iconInfo -> colorTable ) ; iconInfo -> colorTable = NULL ; } if ( iconInfo -> colorTable ) <vul-start> <vul-end> Stream_Read ( s , iconInfo -> colorTable , iconInfo -> cbColorTable ) ; <vul-start> <vul-end> newBitMask = ( BYTE * ) realloc ( iconInfo -> bitsColor , iconInfo -> cbBitsColor ) ; if ( ! newBitMask ) { free ( iconInfo -> bitsColor ) ; iconInfo -> bitsColor = NULL ; return FALSE ; } iconInfo -> bitsColor = newBitMask ; <vul-start> <vul-end> Stream_Read ( s , iconInfo -> bitsColor , iconInfo -> cbBitsColor ) ; return TRUE ; }
|
<vul-sep> iconInfo -> bitsMask = newBitMask ; <vul-start> if ( Stream_GetRemainingLength ( s ) < iconInfo -> cbBitsMask ) return FALSE ; <vul-end> Stream_Read ( s , iconInfo -> bitsMask , iconInfo -> cbBitsMask ) ; <vul-sep> if ( iconInfo -> colorTable ) <vul-start> { if ( Stream_GetRemainingLength ( s ) < iconInfo -> cbColorTable ) return FALSE ; <vul-end> Stream_Read ( s , iconInfo -> colorTable , iconInfo -> cbColorTable ) ; <vul-sep> <vul-end> Stream_Read ( s , iconInfo -> colorTable , iconInfo -> cbColorTable ) ; <vul-start> } <vul-end> newBitMask = ( BYTE * ) realloc ( iconInfo -> bitsColor , iconInfo -> cbBitsColor ) ; <vul-sep> iconInfo -> bitsColor = newBitMask ; <vul-start> if ( Stream_GetRemainingLength ( s ) < iconInfo -> cbBitsColor ) return FALSE ; <vul-end> Stream_Read ( s , iconInfo -> bitsColor , iconInfo -> cbBitsColor ) ; <vul-sep>
|
15
|
CWE-415 static int sg_common_write ( Sg_fd * sfp , Sg_request * srp , unsigned char * cmnd , int timeout , int blocking ) { int k , at_head ; Sg_device * sdp = sfp -> parentdp ; sg_io_hdr_t * hp = & srp -> header ; srp -> data . cmd_opcode = cmnd [ 0 ] ; hp -> status = 0 ; hp -> masked_status = 0 ; hp -> msg_status = 0 ; hp -> info = 0 ; hp -> host_status = 0 ; hp -> driver_status = 0 ; hp -> resid = 0 ; SCSI_LOG_TIMEOUT ( 4 , sg_printk ( KERN_INFO , sfp -> parentdp , "sg_common_write: scsi opcode=0x%02x, cmd_size=%d\\n" , ( int ) cmnd [ 0 ] , ( int ) hp -> cmd_len ) ) ; k = sg_start_req ( srp , cmnd ) ; if ( k ) { SCSI_LOG_TIMEOUT ( 1 , sg_printk ( KERN_INFO , sfp -> parentdp , "sg_common_write: start_req err=%d\\n" , k ) ) ; sg_finish_rem_req ( srp ) ; return k ; } if ( atomic_read ( & sdp -> detaching ) ) { <vul-start> if ( srp -> bio ) <vul-end> blk_end_request_all ( srp -> rq , - EIO ) ; <vul-start> <vul-end> sg_finish_rem_req ( srp ) ; return - ENODEV ; } hp -> duration = jiffies_to_msecs ( jiffies ) ; if ( hp -> interface_id != '\\0' && ( SG_FLAG_Q_AT_TAIL & hp -> flags ) ) at_head = 0 ; else at_head = 1 ; srp -> rq -> timeout = timeout ; kref_get ( & sfp -> f_ref ) ; blk_execute_rq_nowait ( sdp -> device -> request_queue , sdp -> disk , srp -> rq , at_head , sg_rq_end_io ) ; return 0 ; }
|
<vul-sep> if ( atomic_read ( & sdp -> detaching ) ) { <vul-start> if ( srp -> bio ) { if ( srp -> rq -> cmd != srp -> rq -> __cmd ) kfree ( srp -> rq -> cmd ) ; <vul-end> blk_end_request_all ( srp -> rq , - EIO ) ; <vul-sep> <vul-end> blk_end_request_all ( srp -> rq , - EIO ) ; <vul-start> srp -> rq = NULL ; } <vul-end> sg_finish_rem_req ( srp ) ; <vul-sep>
|
16
|
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 ) ) { <vul-start> <vul-end> bool disconnect ; p = list_first_entry ( & tmp_list , struct mount , mnt_list ) ; list_del_init ( & p -> mnt_expire ) ; list_del_init ( & p -> mnt_list ) ; <vul-start> __touch_mnt_namespace ( p -> mnt_ns ) ; <vul-end> 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 ) ; } }
|
<vul-sep> while ( ! list_empty ( & tmp_list ) ) { <vul-start> struct mnt_namespace * ns ; <vul-end> bool disconnect ; <vul-sep> list_del_init ( & p -> mnt_list ) ; <vul-start> ns = p -> mnt_ns ; if ( ns ) { ns -> mounts -- ; __touch_mnt_namespace ( ns ) ; } <vul-end> p -> mnt_ns = NULL ; <vul-sep>
|
17
|
CWE-399 int do_fpu_inst ( unsigned short inst , struct pt_regs * regs ) { struct task_struct * tsk = current ; struct sh_fpu_soft_struct * fpu = & ( tsk -> thread . xstate -> softfpu ) ; <vul-start> perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , 0 , regs , 0 ) ; <vul-end> if ( ! ( task_thread_info ( tsk ) -> status & TS_USEDFPU ) ) { fpu_init ( fpu ) ; task_thread_info ( tsk ) -> status |= TS_USEDFPU ; } return fpu_emulate ( inst , fpu , regs ) ; }
|
<vul-sep> struct sh_fpu_soft_struct * fpu = & ( tsk -> thread . xstate -> softfpu ) ; <vul-start> perf_sw_event ( PERF_COUNT_SW_EMULATION_FAULTS , 1 , regs , 0 ) ; <vul-end> if ( ! ( task_thread_info ( tsk ) -> status & TS_USEDFPU ) ) { <vul-sep>
|
18
|
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 ) ) ) ; <vul-start> return ; <vul-end> } else { ND_PRINT ( ( ndo , "%s > %s: [|pgm]" , ipaddr_string ( ndo , & ip -> ip_src ) , ipaddr_string ( ndo , & ip -> ip_dst ) ) ) ; <vul-start> return ; } <vul-end> } 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 :
|
<vul-sep> ipaddr_string ( ndo , & ip -> ip_dst ) ) ) ; <vul-start> } return ; <vul-end> } <vul-sep>
|
19
|
CWE-401 goto out_controller_put ; } } controller -> cs_gpios = fsl_lpspi -> chipselect ; controller -> prepare_message = fsl_lpspi_prepare_message ; } controller -> bits_per_word_mask = SPI_BPW_RANGE_MASK ( 8 , 32 ) ; controller -> transfer_one = fsl_lpspi_transfer_one ; controller -> prepare_transfer_hardware = lpspi_prepare_xfer_hardware ; controller -> unprepare_transfer_hardware = lpspi_unprepare_xfer_hardware ; controller -> mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH ; controller -> flags = SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX ; controller -> dev . of_node = pdev -> dev . of_node ; controller -> bus_num = pdev -> id ; controller -> slave_abort = fsl_lpspi_slave_abort ; init_completion ( & fsl_lpspi -> xfer_done ) ; res = platform_get_resource ( pdev , IORESOURCE_MEM , 0 ) ; fsl_lpspi -> base = devm_ioremap_resource ( & pdev -> dev , res ) ; if ( IS_ERR ( fsl_lpspi -> base ) ) { ret = PTR_ERR ( fsl_lpspi -> base ) ; goto out_controller_put ; } fsl_lpspi -> base_phys = res -> start ; irq = platform_get_irq ( pdev , 0 ) ; if ( irq < 0 ) { ret = irq ; goto out_controller_put ; } ret = devm_request_irq ( & pdev -> dev , irq , fsl_lpspi_isr , 0 , dev_name ( & pdev -> dev ) , fsl_lpspi ) ; if ( ret ) { dev_err ( & pdev -> dev , "can\'t get irq%d: %d\\n" , irq , ret ) ; goto out_controller_put ; } fsl_lpspi -> clk_per = devm_clk_get ( & pdev -> dev , "per" ) ; if ( IS_ERR ( fsl_lpspi -> clk_per ) ) { ret = PTR_ERR ( fsl_lpspi -> clk_per ) ; goto out_controller_put ; } fsl_lpspi -> clk_ipg = devm_clk_get ( & pdev -> dev , "ipg" ) ; if ( IS_ERR ( fsl_lpspi -> clk_ipg ) ) { ret = PTR_ERR ( fsl_lpspi -> clk_ipg ) ; goto out_controller_put ; } ret = fsl_lpspi_init_rpm ( fsl_lpspi ) ; if ( ret ) goto out_controller_put ; ret = pm_runtime_get_sync ( fsl_lpspi -> dev ) ; if ( ret < 0 ) { dev_err ( fsl_lpspi -> dev , "failed to enable clock\\n" ) ; <vul-start> return ret ; <vul-end> } temp = readl ( fsl_lpspi -> base + IMX7ULP_PARAM ) ; fsl_lpspi -> txfifosize = 1 << ( temp & 0x0f ) ; fsl_lpspi -> rxfifosize = 1 << ( ( temp >> 8 ) & 0x0f ) ; ret = fsl_lpspi_dma_init ( & pdev -> dev , fsl_lpspi , controller ) ; if ( ret == - EPROBE_DEFER ) goto out_controller_put ; if ( ret < 0 ) dev_err ( & pdev -> dev , "dma setup error %d, use pio\\n" , ret ) ; ret = devm_spi_register_controller ( & pdev -> dev , controller ) ; if ( ret < 0 ) { dev_err ( & pdev -> dev , "spi_register_controller error.\\n" ) ; goto out_controller_put ; } return 0 ; out_controller_put : spi_controller_put ( controller ) ; return ret ; }
|
<vul-sep> dev_err ( fsl_lpspi -> dev , "failed to enable clock\\n" ) ; <vul-start> goto out_controller_put ; <vul-end> } <vul-sep>
|
20
|
CWE-119 static int picolcd_raw_event ( struct hid_device * hdev , struct hid_report * report , u8 * raw_data , int size ) { struct picolcd_data * data = hid_get_drvdata ( hdev ) ; unsigned long flags ; int ret = 0 ; if ( ! data ) return 1 ; <vul-start> <vul-end> if ( report -> id == REPORT_KEY_STATE ) { if ( data -> input_keys ) ret = picolcd_raw_keypad ( data , report , raw_data + 1 , size - 1 ) ; } else if ( report -> id == REPORT_IR_DATA ) { ret = picolcd_raw_cir ( data , report , raw_data + 1 , size - 1 ) ; } else { spin_lock_irqsave ( & data -> lock , flags ) ; if ( data -> pending ) { memcpy ( data -> pending -> raw_data , raw_data + 1 , size - 1 ) ; data -> pending -> raw_size = size - 1 ; data -> pending -> in_report = report ; complete ( & data -> pending -> ready ) ; } spin_unlock_irqrestore ( & data -> lock , flags ) ; } picolcd_debug_raw_event ( data , hdev , report , raw_data , size ) ; return 1 ; }
|
<vul-sep> return 1 ; <vul-start> if ( size > 64 ) { hid_warn ( hdev , "invalid size value (%d) for picolcd raw event\\n" , size ) ; return 0 ; } <vul-end> if ( report -> id == REPORT_KEY_STATE ) { <vul-sep>
|
21
|
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 ; <vul-start> msg -> msg_namelen = 0 ; <vul-end> 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 :
|
<vul-sep>
|
22
|
NVD-CWE-Other 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 ; <vul-start> <vul-end> 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 ; }
|
<vul-sep> last_dest = dest_mnt ; <vul-start> first_source = source_mnt ; <vul-end> last_source = source_mnt ; <vul-sep>
|
23
|
CWE-119 int psf_binheader_readf ( SF_PRIVATE * psf , char const * format , ... ) { va_list argptr ; sf_count_t * countptr , countdata ; unsigned char * ucptr , sixteen_bytes [ 16 ] ; unsigned int * intptr , intdata ; unsigned short * shortptr ; char * charptr ; float * floatptr ; double * doubleptr ; char c ; <vul-start> int byte_count = 0 , count ; <vul-end> if ( ! format ) return psf_ftell ( psf ) ; va_start ( argptr , format ) ; while ( ( c = * format ++ ) ) <vul-start> { switch ( c ) <vul-end> { case 'e' : psf -> rwf_endian = SF_ENDIAN_LITTLE ; break ; case 'E' : psf -> rwf_endian = SF_ENDIAN_BIG ; break ; case 'm' : intptr = va_arg ( argptr , unsigned int * ) ; <vul-start> <vul-end> ucptr = ( unsigned char * ) intptr ; byte_count += header_read ( psf , ucptr , sizeof ( int ) ) ; * intptr = GET_MARKER ( ucptr ) ; break ; case 'h' : intptr = va_arg ( argptr , unsigned int * ) ; <vul-start> <vul-end> ucptr = ( unsigned char * ) intptr ; byte_count += header_read ( psf , sixteen_bytes , sizeof ( sixteen_bytes ) ) ; { int k ; intdata = 0 ; for ( k = 0 ; k < 16 ; k ++ ) intdata ^= sixteen_bytes [ k ] << k ; } * intptr = intdata ; break ; case '1' : charptr = va_arg ( argptr , char * ) ; * charptr = 0 ; byte_count += header_read ( psf , charptr , sizeof ( char ) ) ; break ; case '2' : shortptr = va_arg ( argptr , unsigned short * ) ; * shortptr = 0 ; ucptr = ( unsigned char * ) shortptr ; byte_count += header_read ( psf , ucptr , sizeof ( short ) ) ; if ( psf -> rwf_endian == SF_ENDIAN_BIG ) * shortptr = GET_BE_SHORT ( ucptr ) ; else * shortptr = GET_LE_SHORT ( ucptr ) ; break ; case '3' : intptr = va_arg ( argptr , unsigned int * ) ; * intptr = 0 ; byte_count += header_read ( psf , sixteen_bytes , 3 ) ; if ( psf -> rwf_endian == SF_ENDIAN_BIG ) * intptr = GET_BE_3BYTE ( sixteen_bytes ) ; else * intptr = GET_LE_3BYTE ( sixteen_bytes ) ; break ; case '4' : intptr = va_arg ( argptr , unsigned int * ) ; * intptr = 0 ; ucptr = ( unsigned char * ) intptr ; byte_count += header_read ( psf , ucptr , sizeof ( int ) ) ; if ( psf -> rwf_endian == SF_ENDIAN_BIG ) * intptr = psf_get_be32 ( ucptr , 0 ) ; else * intptr = psf_get_le32 ( ucptr , 0 ) ; break ; case '8' : countptr = va_arg ( argptr , sf_count_t * ) ; * countptr = 0 ; byte_count += header_read ( psf , sixteen_bytes , 8 ) ; if ( psf -> rwf_endian == SF_ENDIAN_BIG ) countdata = psf_get_be64 ( sixteen_bytes , 0 ) ; else countdata = psf_get_le64 ( sixteen_bytes , 0 ) ; * countptr = countdata ; break ; case 'f' : floatptr = va_arg ( argptr , float * ) ; * floatptr = 0.0 ; byte_count += header_read ( psf , floatptr , sizeof ( float ) ) ; if ( psf -> rwf_endian == SF_ENDIAN_BIG ) * floatptr = float32_be_read ( ( unsigned char * ) floatptr ) ; else * floatptr = float32_le_read ( ( unsigned char * ) floatptr ) ; break ; case 'd' : doubleptr = va_arg ( argptr , double * ) ; * doubleptr = 0.0 ; byte_count += header_read ( psf , doubleptr , sizeof ( double ) ) ; if ( psf -> rwf_endian == SF_ENDIAN_BIG ) * doubleptr = double64_be_read ( ( unsigned char * ) doubleptr ) ; else * doubleptr = double64_le_read ( ( unsigned char * ) doubleptr ) ; break ; case 's' : psf_log_printf ( psf , "Format conversion \'s\' not implemented yet.\\n" ) ; break ; case 'b' : charptr = va_arg ( argptr , char * ) ; count = va_arg ( argptr , size_t ) ; <vul-start> if ( count > 0 ) <vul-end> byte_count += header_read ( psf , charptr , count ) ; break ; case 'G' : charptr = va_arg ( argptr , char * ) ; count = va_arg ( argptr , size_t ) ; <vul-start> if ( count > 0 ) <vul-end> byte_count += header_gets ( psf , charptr , count ) ; break ; case 'z' : psf_log_printf ( psf , "Format conversion \'z\' not implemented yet.\\n" ) ; break ; case 'p' : count = va_arg ( argptr , size_t ) ; header_seek ( psf , count , SEEK_SET ) ; byte_count = count ; break ; case 'j' : count = va_arg ( argptr , size_t ) ; <vul-start> if ( count ) { header_seek ( psf , count , SEEK_CUR ) ; <vul-end> byte_count += count ; <vul-start> } ; <vul-end> break ; default : psf_log_printf ( psf , "*** Invalid format specifier `%c\'\\n" , c ) ; psf -> error = SFE_INTERNAL ; break ; } ; } ; va_end ( argptr ) ; return byte_count ; }
|
<vul-sep> char c ; <vul-start> int byte_count = 0 , count = 0 ; <vul-end> if ( ! format ) <vul-sep> while ( ( c = * format ++ ) ) <vul-start> { if ( psf -> header . indx + 16 >= psf -> header . len && psf_bump_header_allocation ( psf , 16 ) ) return count ; switch ( c ) <vul-end> { case 'e' : <vul-sep> intptr = va_arg ( argptr , unsigned int * ) ; <vul-start> * intptr = 0 ; <vul-end> ucptr = ( unsigned char * ) intptr ; <vul-sep> intptr = va_arg ( argptr , unsigned int * ) ; <vul-start> * intptr = 0 ; <vul-end> ucptr = ( unsigned char * ) intptr ; <vul-sep> count = va_arg ( argptr , size_t ) ; <vul-start> memset ( charptr , 0 , count ) ; <vul-end> byte_count += header_read ( psf , charptr , count ) ; <vul-sep> count = va_arg ( argptr , size_t ) ; <vul-start> memset ( charptr , 0 , count ) ; if ( psf -> header . indx + count >= psf -> header . len && psf_bump_header_allocation ( psf , count ) ) return 0 ; <vul-end> byte_count += header_gets ( psf , charptr , count ) ; <vul-sep> count = va_arg ( argptr , size_t ) ; <vul-start> header_seek ( psf , count , SEEK_CUR ) ; <vul-end> byte_count += count ; <vul-sep>
|
24
|
CWE-20 -int parse_rock_ridge_inode ( struct iso_directory_record * de , struct inode * inode ) +int parse_rock_ridge_inode ( struct iso_directory_record * de , struct inode * inode , <vul-start> <vul-end> { <vul-start> int result = parse_rock_ridge_inode_internal ( de , inode , 0 ) ; <vul-end> if ( ( ISOFS_SB ( inode -> i_sb ) -> s_rock_offset == - 1 ) && ( ISOFS_SB ( inode -> i_sb ) -> s_rock == 2 ) ) { <vul-start> result = parse_rock_ridge_inode_internal ( de , inode , 14 ) ; <vul-end> } return result ; }
|
<vul-sep> +int parse_rock_ridge_inode ( struct iso_directory_record * de , struct inode * inode , <vul-start> int relocated ) <vul-end> { <vul-sep> <vul-end> { <vul-start> int flags = relocated ? RR_RELOC_DE : 0 ; int result = parse_rock_ridge_inode_internal ( de , inode , flags ) ; <vul-end> if ( ( ISOFS_SB ( inode -> i_sb ) -> s_rock_offset == - 1 ) <vul-sep> && ( ISOFS_SB ( inode -> i_sb ) -> s_rock == 2 ) ) { <vul-start> result = parse_rock_ridge_inode_internal ( de , inode , flags | RR_REGARD_XA ) ; <vul-end> } <vul-sep>
|
25
|
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 ) ; <vul-start> <vul-end> 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 , "Cannot encode tile\\n" ) ; return OPJ_FALSE ; } * p_data_written += 2 ; return OPJ_TRUE ; }
|
<vul-sep> OPJ_UNUSED ( p_stream ) ; <vul-start> if ( p_total_data_size < 4 ) { opj_event_msg ( p_manager , EVT_ERROR , "Not enough bytes in output buffer to write SOD marker\\n" ) ; return OPJ_FALSE ; } <vul-end> opj_write_bytes ( p_data , J2K_MS_SOD , <vul-sep>
|
26
|
CWE-119 -static void duplicate_mode_info_in_sb ( VP9_COMMON * const cm , <vul-start> MACROBLOCKD * const xd , int mi_row , int mi_col , <vul-end>+static void duplicate_mode_info_in_sb ( VP9_COMMON * cm , MACROBLOCKD * xd , <vul-start> <vul-end> BLOCK_SIZE bsize ) { const int block_width = num_8x8_blocks_wide_lookup [ bsize ] ; const int block_height = num_8x8_blocks_high_lookup [ bsize ] ; int i , j ; for ( j = 0 ; j < block_height ; ++ j ) for ( i = 0 ; i < block_width ; ++ i ) { if ( mi_row + j < cm -> mi_rows && mi_col + i < cm -> mi_cols ) xd -> mi [ j * xd -> mi_stride + i ] = xd -> mi [ 0 ] ; } }
|
<vul-sep> +static void duplicate_mode_info_in_sb ( VP9_COMMON * cm , MACROBLOCKD * xd , <vul-start> int mi_row , int mi_col , <vul-end> BLOCK_SIZE bsize ) { <vul-sep>
|
27
|
CWE-415 static bool disconnect_cb ( struct io * io , void * user_data ) { struct bt_att_chan * chan = user_data ; struct bt_att * att = chan -> att ; int err ; socklen_t len ; len = sizeof ( err ) ; if ( getsockopt ( chan -> fd , SOL_SOCKET , SO_ERROR , & err , & len ) < 0 ) { util_debug ( chan -> att -> debug_callback , chan -> att -> debug_data , "(chan %p) Failed to obtain disconnect" " error: %s" , chan , strerror ( errno ) ) ; err = 0 ; } util_debug ( chan -> att -> debug_callback , chan -> att -> debug_data , "Channel %p disconnected: %s" , chan , strerror ( err ) ) ; queue_remove ( att -> chans , chan ) ; <vul-start> queue_remove_all ( att -> req_queue , NULL , NULL , disc_att_send_op ) ; queue_remove_all ( att -> ind_queue , NULL , NULL , disc_att_send_op ) ; queue_remove_all ( att -> write_queue , NULL , NULL , disc_att_send_op ) ; <vul-end> if ( chan -> pending_req ) { disc_att_send_op ( chan -> pending_req ) ; chan -> pending_req = NULL ; } if ( chan -> pending_ind ) { disc_att_send_op ( chan -> pending_ind ) ; chan -> pending_ind = NULL ; } bt_att_chan_free ( chan ) ; if ( ! queue_isempty ( att -> chans ) ) return false ; bt_att_ref ( att ) ; <vul-start> <vul-end> queue_foreach ( att -> disconn_list , disconn_handler , INT_TO_PTR ( err ) ) ; bt_att_unregister_all ( att ) ; bt_att_unref ( att ) ; return false ; }
|
<vul-sep> bt_att_ref ( att ) ; <vul-start> att -> in_disc = true ; queue_remove_all ( att -> req_queue , NULL , NULL , disc_att_send_op ) ; queue_remove_all ( att -> ind_queue , NULL , NULL , disc_att_send_op ) ; queue_remove_all ( att -> write_queue , NULL , NULL , disc_att_send_op ) ; att -> in_disc = false ; <vul-end> queue_foreach ( att -> disconn_list , disconn_handler , INT_TO_PTR ( err ) ) ; <vul-sep>
|
28
|
NVD-CWE-noinfo -static int can_open_delegated ( struct nfs_delegation * delegation , mode_t open_flags ) +static int can_open_delegated ( struct nfs_delegation * delegation , fmode_t fmode ) { <vul-start> if ( ( delegation -> type & open_flags ) != open_flags ) <vul-end> return 0 ; if ( test_bit ( NFS_DELEGATION_NEED_RECLAIM , & delegation -> flags ) ) return 0 ; nfs_mark_delegation_referenced ( delegation ) ; return 1 ; }
|
<vul-sep> { <vul-start> if ( ( delegation -> type & fmode ) != fmode ) <vul-end> return 0 ; <vul-sep>
|
29
|
CWE-125 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 , " post dattr:" ) ) ; 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 , " post dattr:" ) ) ; 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 ; <vul-start> if ( ! er ) <vul-end> ND_PRINT ( ( ndo , " c %04x" , EXTRACT_32BITS ( & dp [ 0 ] ) ) ) ; <vul-start> <vul-end> 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 , " %u bytes" , 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 , " %u bytes" , 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 {
|
<vul-sep> break ; <vul-start> if ( ! er ) { ND_TCHECK ( dp [ 0 ] ) ; <vul-end> ND_PRINT ( ( ndo , " c %04x" , EXTRACT_32BITS ( & dp [ 0 ] ) ) ) ; <vul-sep> <vul-end> ND_PRINT ( ( ndo , " c %04x" , EXTRACT_32BITS ( & dp [ 0 ] ) ) ) ; <vul-start> } <vul-end> return ; <vul-sep>
|
30
|
CWE-119 static int futex_wait ( u32 __user * uaddr , int fshared , u32 val , ktime_t * abs_time , u32 bitset , int clockrt ) { struct hrtimer_sleeper timeout , * to = NULL ; struct restart_block * restart ; struct futex_hash_bucket * hb ; struct futex_q q ; int ret ; if ( ! bitset ) return - EINVAL ; q . pi_state = NULL ; q . bitset = bitset ; q . rt_waiter = NULL ; q . requeue_pi_key = NULL ; if ( abs_time ) { to = & timeout ; hrtimer_init_on_stack ( & to -> timer , 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 ) ; } retry : ret = futex_wait_setup ( uaddr , val , fshared , & q , & hb ) ; if ( ret ) goto out ; futex_wait_queue_me ( hb , & q , to ) ; ret = 0 ; if ( ! unqueue_me ( & q ) ) <vul-start> goto out_put_key ; <vul-end> ret = - ETIMEDOUT ; if ( to && ! to -> task ) <vul-start> goto out_put_key ; if ( ! signal_pending ( current ) ) { put_futex_key ( fshared , & q . key ) ; <vul-end> goto retry ; <vul-start> } <vul-end> ret = - ERESTARTSYS ; if ( ! abs_time ) <vul-start> goto out_put_key ; <vul-end> restart = & current_thread_info ( ) -> restart_block ; restart -> fn = futex_wait_restart ; restart -> futex . uaddr = ( u32 * ) uaddr ; restart -> futex . val = val ; restart -> futex . time = abs_time -> tv64 ; restart -> futex . bitset = bitset ; restart -> futex . flags = FLAGS_HAS_TIMEOUT ; if ( fshared ) restart -> futex . flags |= FLAGS_SHARED ; if ( clockrt ) restart -> futex . flags |= FLAGS_CLOCKRT ; ret = - ERESTART_RESTARTBLOCK ; <vul-start> out_put_key : put_futex_key ( fshared , & q . key ) ; <vul-end> out : if ( to ) { hrtimer_cancel ( & to -> timer ) ; destroy_hrtimer_on_stack ( & to -> timer ) ; } return ret ; }
|
<vul-sep> if ( ! unqueue_me ( & q ) ) <vul-start> goto out ; <vul-end> ret = - ETIMEDOUT ; <vul-sep> if ( to && ! to -> task ) <vul-start> goto out ; if ( ! signal_pending ( current ) ) <vul-end> goto retry ; <vul-sep> if ( ! abs_time ) <vul-start> goto out ; <vul-end> restart = & current_thread_info ( ) -> restart_block ; <vul-sep>
|
31
|
CWE-416 case '-' : if ( esil ) { sdb_reset ( esil -> stats ) ; } break ; } break ; case 'f' : { RListIter * iter ; RAnalBlock * bb ; RAnalFunction * fcn = r_anal_get_fcn_in ( core -> anal , core -> offset , R_ANAL_FCN_TYPE_FCN | R_ANAL_FCN_TYPE_SYM ) ; if ( fcn ) { r_list_foreach ( fcn -> bbs , iter , bb ) { ut64 pc = bb -> addr ; ut64 end = bb -> addr + bb -> size ; RAnalOp op ; ut8 * buf ; int ret , bbs = end - pc ; if ( bbs < 1 || bbs > 0xfffff ) { eprintf ( "Invalid block size\\n" ) ; } buf = calloc ( 1 , bbs + 1 ) ; r_io_read_at ( core -> io , pc , buf , bbs ) ; int left ; while ( pc < end ) { left = R_MIN ( end - pc , 32 ) ; r_asm_set_pc ( core -> assembler , pc ) ; ret = r_anal_op ( core -> anal , & op , addr , buf , left , R_ANAL_OP_MASK_ALL ) ; if ( ret ) { r_reg_set_value_by_role ( core -> anal -> reg , R_REG_NAME_PC , pc ) ; r_anal_esil_parse ( esil , R_STRBUF_SAFEGET ( & op . esil ) ) ; r_anal_esil_dumpstack ( esil ) ; r_anal_esil_stack_free ( esil ) ; pc += op . size ; } else { pc += 4 ; } } } } else { eprintf ( "Cannot find function at 0x%08" PFMT64x "\\n" , core -> offset ) ; } } break ; case 't' : switch ( input [ 1 ] ) { case 'r' : { RAnalEsil * esil = r_anal_esil_new ( stacksize , iotrap , addrsize ) ; <vul-start> if ( ! esil ) <vul-end> return ; <vul-start> <vul-end> r_anal_esil_to_reil_setup ( esil , core -> anal , romem , stats ) ; r_anal_esil_set_pc ( esil , core -> offset ) ; r_anal_esil_parse ( esil , input + 2 ) ; r_anal_esil_dumpstack ( esil ) ; r_anal_esil_free ( esil ) ; break ; } case 's' : switch ( input [ 2 ] ) { case 0 : r_anal_esil_session_list ( esil ) ; break ; case '+' : r_anal_esil_session_add ( esil ) ; break ; default : r_core_cmd_help ( core , help_msg_aets ) ; break ; } break ; default : eprintf ( "Unknown command. Use `aetr`.\\n" ) ; break ; } break ; case 'A' : if ( input [ 1 ] == '?' ) { r_core_cmd_help ( core , help_msg_aea ) ; } else if ( input [ 1 ] == 'r' ) { cmd_aea ( core , 1 + ( 1 << 1 ) , core -> offset , r_num_math ( core -> num , input + 2 ) ) ; } else if ( input [ 1 ] == 'w' ) { cmd_aea ( core , 1 + ( 1 << 2 ) , core -> offset , r_num_math ( core -> num , input + 2 ) ) ; } else if ( input [ 1 ] == 'n' ) { cmd_aea ( core , 1 + ( 1 << 3 ) , core -> offset , r_num_math ( core -> num , input + 2 ) ) ; } else if ( input [ 1 ] == 'j' ) { cmd_aea ( core , 1 + ( 1 << 4 ) , core -> offset , r_num_math ( core -> num , input + 2 ) ) ; } else if ( input [ 1 ] == '*' ) { cmd_aea ( core , 1 + ( 1 << 5 ) , core -> offset , r_num_math ( core -> num , input + 2 ) ) ; } else if ( input [ 1 ] == 'f' ) { RAnalFunction * fcn = r_anal_get_fcn_in ( core -> anal , core -> offset , - 1 ) ; if ( fcn ) { cmd_aea ( core , 1 , fcn -> addr , r_anal_fcn_size ( fcn ) ) ; } } else { cmd_aea ( core , 1 , core -> offset , ( int ) r_num_math ( core -> num , input + 2 ) ) ; } break ; case 'a' : if ( input [ 1 ] == '?' ) { r_core_cmd_help ( core , help_msg_aea ) ;
|
<vul-sep> RAnalEsil * esil = r_anal_esil_new ( stacksize , iotrap , addrsize ) ; <vul-start> if ( ! esil ) { <vul-end> return ; <vul-sep> <vul-end> return ; <vul-start> } <vul-end> r_anal_esil_to_reil_setup ( esil , core -> anal , romem , stats ) ; <vul-sep>
|
32
|
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 '(' : <vul-start> if ( top - op_stack > nr_parens ) return ERR_PTR ( - EINVAL ) ; <vul-end> * ( ++ 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 ; }
|
<vul-sep> case '(' : <vul-start> if ( top - op_stack > nr_parens ) { ret = - EINVAL ; goto out_free ; } <vul-end> * ( ++ top ) = invert ; <vul-sep>
|
33
|
CWE-125 static UINT printer_process_irp_write ( PRINTER_DEVICE * printer_dev , IRP * irp ) { UINT32 Length ; UINT64 Offset ; rdpPrintJob * printjob = NULL ; UINT error = CHANNEL_RC_OK ; <vul-start> <vul-end> Stream_Read_UINT32 ( irp -> input , Length ) ; Stream_Read_UINT64 ( irp -> input , Offset ) ; Stream_Seek ( irp -> input , 20 ) ; <vul-start> <vul-end> if ( printer_dev -> printer ) printjob = printer_dev -> printer -> FindPrintJob ( printer_dev -> printer , irp -> FileId ) ; if ( ! printjob ) { irp -> IoStatus = STATUS_UNSUCCESSFUL ; Length = 0 ; } else { <vul-start> error = printjob -> Write ( printjob , Stream_Pointer ( irp -> input ) , Length ) ; <vul-end> } if ( error ) { WLog_ERR ( TAG , "printjob->Write failed with error %" PRIu32 "!" , error ) ; return error ; } Stream_Write_UINT32 ( irp -> output , Length ) ; Stream_Write_UINT8 ( irp -> output , 0 ) ; return irp -> Complete ( irp ) ; }
|
<vul-sep> UINT error = CHANNEL_RC_OK ; <vul-start> void * ptr ; if ( Stream_GetRemainingLength ( irp -> input ) < 32 ) return ERROR_INVALID_DATA ; <vul-end> Stream_Read_UINT32 ( irp -> input , Length ) ; <vul-sep> Stream_Seek ( irp -> input , 20 ) ; <vul-start> ptr = Stream_Pointer ( irp -> input ) ; if ( ! Stream_SafeSeek ( irp -> input , Length ) ) return ERROR_INVALID_DATA ; <vul-end> if ( printer_dev -> printer ) <vul-sep> { <vul-start> error = printjob -> Write ( printjob , ptr , Length ) ; <vul-end> } <vul-sep>
|
34
|
CWE-200 int vmw_gb_surface_define_ioctl ( struct drm_device * dev , void * data , struct drm_file * file_priv ) { struct vmw_private * dev_priv = vmw_priv ( dev ) ; struct vmw_user_surface * user_srf ; struct vmw_surface * srf ; struct vmw_resource * res ; struct vmw_resource * tmp ; union drm_vmw_gb_surface_create_arg * arg = ( union drm_vmw_gb_surface_create_arg * ) data ; struct drm_vmw_gb_surface_create_req * req = & arg -> req ; struct drm_vmw_gb_surface_create_rep * rep = & arg -> rep ; struct ttm_object_file * tfile = vmw_fpriv ( file_priv ) -> tfile ; int ret ; uint32_t size ; <vul-start> uint32_t backup_handle ; <vul-end> if ( req -> multisample_count != 0 ) return - EINVAL ; if ( req -> mip_levels > DRM_VMW_MAX_MIP_LEVELS ) return - EINVAL ; if ( unlikely ( vmw_user_surface_size == 0 ) ) vmw_user_surface_size = ttm_round_pot ( sizeof ( * user_srf ) ) + 128 ; size = vmw_user_surface_size + 128 ; ret = vmw_surface_gb_priv_define ( dev , size , req -> svga3d_flags , req -> format , req -> drm_surface_flags & drm_vmw_surface_flag_scanout , req -> mip_levels , req -> multisample_count , req -> array_size , req -> base_size , & srf ) ; if ( unlikely ( ret != 0 ) ) return ret ; user_srf = container_of ( srf , struct vmw_user_surface , srf ) ; if ( drm_is_primary_client ( file_priv ) ) user_srf -> master = drm_master_get ( file_priv -> master ) ; ret = ttm_read_lock ( & dev_priv -> reservation_sem , true ) ; if ( unlikely ( ret != 0 ) ) return ret ; res = & user_srf -> srf . res ; if ( req -> buffer_handle != SVGA3D_INVALID_ID ) { ret = vmw_user_dmabuf_lookup ( tfile , req -> buffer_handle , & res -> backup , & user_srf -> backup_base ) ; <vul-start> if ( ret == 0 && res -> backup -> base . num_pages * PAGE_SIZE < <vul-end> res -> backup_size ) { DRM_ERROR ( "Surface backup buffer is too small.\\n" ) ; vmw_dmabuf_unreference ( & res -> backup ) ; ret = - EINVAL ; goto out_unlock ; <vul-start> <vul-end> } } else if ( req -> drm_surface_flags & drm_vmw_surface_flag_create_buffer ) ret = vmw_user_dmabuf_alloc ( dev_priv , tfile , res -> backup_size , req -> drm_surface_flags & drm_vmw_surface_flag_shareable , & backup_handle , & res -> backup , & user_srf -> backup_base ) ; if ( unlikely ( ret != 0 ) ) { vmw_resource_unreference ( & res ) ; goto out_unlock ; } tmp = vmw_resource_reference ( res ) ; ret = ttm_prime_object_init ( tfile , res -> backup_size , & user_srf -> prime , req -> drm_surface_flags & drm_vmw_surface_flag_shareable , VMW_RES_SURFACE , & vmw_user_surface_base_release , NULL ) ; if ( unlikely ( ret != 0 ) ) { vmw_resource_unreference ( & tmp ) ; vmw_resource_unreference ( & res ) ; goto out_unlock ; } rep -> handle = user_srf -> prime . base . hash . key ; rep -> backup_size = res -> backup_size ; if ( res -> backup ) { rep -> buffer_map_handle = drm_vma_node_offset_addr ( & res -> backup -> base . vma_node ) ; rep -> buffer_size = res -> backup -> base . num_pages * PAGE_SIZE ; rep -> buffer_handle = backup_handle ; } else { rep -> buffer_map_handle = 0 ; rep -> buffer_size = 0 ; rep -> buffer_handle = SVGA3D_INVALID_ID ; } vmw_resource_unreference ( & res ) ; out_unlock : ttm_read_unlock ( & dev_priv -> reservation_sem ) ; return ret ; }
|
<vul-sep> uint32_t size ; <vul-start> uint32_t backup_handle = 0 ; <vul-end> if ( req -> multisample_count != 0 ) <vul-sep> & user_srf -> backup_base ) ; <vul-start> if ( ret == 0 ) { if ( res -> backup -> base . num_pages * PAGE_SIZE < <vul-end> res -> backup_size ) { <vul-sep> goto out_unlock ; <vul-start> } else { backup_handle = req -> buffer_handle ; } <vul-end> } <vul-sep>
|
35
|
CWE-119 unsigned char * pixels ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , "%s" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; if ( ( image -> columns == 0 ) || ( image -> rows == 0 ) ) ThrowReaderException ( OptionError , "MustSpecifyImageSize" ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } if ( DiscardBlobBytes ( image , ( size_t ) image -> offset ) == MagickFalse ) ThrowFileException ( exception , CorruptImageError , "UnexpectedEndOfFile" , image -> filename ) ; SetImageColorspace ( image , GRAYColorspace ) ; canvas_image = CloneImage ( image , image -> extract_info . width , 1 , MagickFalse , exception ) ; ( void ) SetImageVirtualPixelMethod ( canvas_image , BlackVirtualPixelMethod ) ; quantum_type = GrayQuantum ; quantum_info = AcquireQuantumInfo ( image_info , canvas_image ) ; if ( quantum_info == ( QuantumInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , "MemoryAllocationFailed" ) ; pixels = GetQuantumPixels ( quantum_info ) ; if ( image_info -> number_scenes != 0 ) while ( image -> scene < image_info -> scene ) { image -> scene ++ ; length = GetQuantumExtent ( canvas_image , quantum_info , quantum_type ) ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { count = ReadBlob ( image , length , pixels ) ; if ( count != ( ssize_t ) length ) break ; } } scene = 0 ; count = 0 ; length = 0 ; do { if ( ( image_info -> ping != MagickFalse ) && ( image_info -> number_scenes != 0 ) ) if ( image -> scene >= ( image_info -> scene + image_info -> number_scenes - 1 ) ) break ; <vul-start> <vul-end> SetImageColorspace ( image , GRAYColorspace ) ; if ( scene == 0 ) { length = GetQuantumExtent ( canvas_image , quantum_info , quantum_type ) ; count = ReadBlob ( image , length , pixels ) ; } for ( y = 0 ; y < ( ssize_t ) image -> extract_info . height ; y ++ ) { register const PixelPacket * restrict p ; register ssize_t x ; register PixelPacket * restrict q ; if ( count != ( ssize_t ) length ) { ThrowFileException ( exception , CorruptImageError , "UnexpectedEndOfFile" , image -> filename ) ; break ; } q = GetAuthenticPixels ( canvas_image , 0 , 0 , canvas_image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; length = ImportQuantumPixels ( canvas_image , ( CacheView * ) NULL , quantum_info , quantum_type , pixels , exception ) ; if ( SyncAuthenticPixels ( canvas_image , exception ) == MagickFalse ) break ; if ( ( ( y - image -> extract_info . y ) >= 0 ) && ( ( y - image -> extract_info . y ) < ( ssize_t ) image -> rows ) ) { p = GetVirtualPixels ( canvas_image , canvas_image -> extract_info . x , 0 , image -> columns , 1 , exception ) ; q = QueueAuthenticPixels ( image , 0 , y - image -> extract_info . y , image -> columns , 1 , exception ) ; if ( ( p == ( const PixelPacket * ) NULL ) || ( q == ( PixelPacket * ) NULL ) ) break ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { SetPixelRed ( q , GetPixelRed ( p ) ) ; SetPixelGreen ( q , GetPixelGreen ( p ) ) ; SetPixelBlue ( q , GetPixelBlue ( p ) ) ; p ++ ; q ++ ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; } if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y ,
|
<vul-sep> break ; <vul-start> status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; } <vul-end> SetImageColorspace ( image , GRAYColorspace ) ; <vul-sep>
|
36
|
CWE-119 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 ) ; <vul-start> cork -> length += length ; if ( length > mtu ) { int proto = sk -> sk_protocol ; if ( dontfrag && ( proto == IPPROTO_UDP || proto == IPPROTO_RAW ) ) { <vul-end> ipv6_local_rxpmtu ( sk , fl6 , mtu - exthdrlen ) ; return - EMSGSIZE ; } <vul-start> if ( proto == IPPROTO_UDP && <vul-end> ( 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 ; } <vul-start> } if ( ( skb = skb_peek_tail ( & sk -> sk_write_queue ) ) == NULL ) <vul-end> 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 , np -> pmtudisc == IPV6_PMTUDISC_PROBE ) ; 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 ;
|
<vul-sep> sock_tx_timestamp ( sk , & tx_flags ) ; <vul-start> if ( ( length > mtu ) && dontfrag && ( sk -> sk_protocol == IPPROTO_UDP || sk -> sk_protocol == IPPROTO_RAW ) ) { <vul-end> ipv6_local_rxpmtu ( sk , fl6 , mtu - exthdrlen ) ; <vul-sep> } <vul-start> skb = skb_peek_tail ( & sk -> sk_write_queue ) ; cork -> length += length ; if ( ( ( length > mtu ) || ( skb && skb_is_gso ( skb ) ) ) && ( sk -> sk_protocol == IPPROTO_UDP ) && <vul-end> ( rt -> dst . dev -> features & NETIF_F_UFO ) ) { <vul-sep> } <vul-start> if ( ! skb ) <vul-end> goto alloc_new_skb ; <vul-sep>
|
37
|
CWE-119 -static void inc_mvs ( const MB_MODE_INFO * mbmi , const int_mv mvs [ 2 ] , +static void inc_mvs ( const MB_MODE_INFO * mbmi , const MB_MODE_INFO_EXT * mbmi_ext , <vul-start> <vul-end> nmv_context_counts * counts ) { int i ; for ( i = 0 ; i < 1 + has_second_ref ( mbmi ) ; ++ i ) { <vul-start> const MV * ref = & mbmi -> ref_mvs [ mbmi -> ref_frame [ i ] ] [ 0 ] . as_mv ; <vul-end> const MV diff = { mvs [ i ] . as_mv . row - ref -> row , mvs [ i ] . as_mv . col - ref -> col } ; vp9_inc_mv ( & diff , counts ) ; } }
|
<vul-sep> +static void inc_mvs ( const MB_MODE_INFO * mbmi , const MB_MODE_INFO_EXT * mbmi_ext , <vul-start> const int_mv mvs [ 2 ] , <vul-end> nmv_context_counts * counts ) { <vul-sep> for ( i = 0 ; i < 1 + has_second_ref ( mbmi ) ; ++ i ) { <vul-start> const MV * ref = & mbmi_ext -> ref_mvs [ mbmi -> ref_frame [ i ] ] [ 0 ] . as_mv ; <vul-end> const MV diff = { mvs [ i ] . as_mv . row - ref -> row , <vul-sep>
|
38
|
CWE-400 static int usb_enumerate_device_otg ( struct usb_device * udev ) { int err = 0 ; # ifdef CONFIG_USB_OTG if ( ! udev -> bus -> is_b_host && udev -> config && udev -> parent == udev -> bus -> root_hub ) { struct usb_otg_descriptor * desc = NULL ; struct usb_bus * bus = udev -> bus ; unsigned port1 = udev -> portnum ; err = __usb_get_extra_descriptor ( udev -> rawdescriptors [ 0 ] , le16_to_cpu ( udev -> config [ 0 ] . desc . wTotalLength ) , <vul-start> USB_DT_OTG , ( void * * ) & desc ) ; <vul-end> if ( err || ! ( desc -> bmAttributes & USB_OTG_HNP ) ) return 0 ; dev_info ( & udev -> dev , "Dual-Role OTG device on %sHNP port\\n" , ( port1 == bus -> otg_port ) ? "" : "non-" ) ; if ( port1 == bus -> otg_port ) { bus -> b_hnp_enable = 1 ; err = usb_control_msg ( udev , usb_sndctrlpipe ( udev , 0 ) , USB_REQ_SET_FEATURE , 0 , USB_DEVICE_B_HNP_ENABLE , 0 , NULL , 0 , USB_CTRL_SET_TIMEOUT ) ; if ( err < 0 ) { dev_err ( & udev -> dev , "can\'t set HNP mode: %d\\n" , err ) ; bus -> b_hnp_enable = 0 ; } } else if ( desc -> bLength == sizeof ( struct usb_otg_descriptor ) ) { err = usb_control_msg ( udev , usb_sndctrlpipe ( udev , 0 ) , USB_REQ_SET_FEATURE , 0 , USB_DEVICE_A_ALT_HNP_SUPPORT , 0 , NULL , 0 , USB_CTRL_SET_TIMEOUT ) ; if ( err < 0 ) dev_err ( & udev -> dev , "set a_alt_hnp_support failed: %d\\n" , err ) ; } } # endif return err ; }
|
<vul-sep> le16_to_cpu ( udev -> config [ 0 ] . desc . wTotalLength ) , <vul-start> USB_DT_OTG , ( void * * ) & desc , sizeof ( * desc ) ) ; <vul-end> if ( err || ! ( desc -> bmAttributes & USB_OTG_HNP ) ) <vul-sep>
|
39
|
CWE-189 static inline void x86_assign_hw_event ( struct perf_event * event , struct cpu_hw_events * cpuc , int i ) { struct hw_perf_event * hwc = & event -> hw ; hwc -> idx = cpuc -> assign [ i ] ; hwc -> last_cpu = smp_processor_id ( ) ; hwc -> last_tag = ++ cpuc -> tags [ i ] ; if ( hwc -> idx == X86_PMC_IDX_FIXED_BTS ) { hwc -> config_base = 0 ; hwc -> event_base = 0 ; } else if ( hwc -> idx >= X86_PMC_IDX_FIXED ) { hwc -> config_base = MSR_ARCH_PERFMON_FIXED_CTR_CTRL ; <vul-start> hwc -> event_base = MSR_ARCH_PERFMON_FIXED_CTR0 ; <vul-end> } else { hwc -> config_base = x86_pmu_config_addr ( hwc -> idx ) ; hwc -> event_base = x86_pmu_event_addr ( hwc -> idx ) ; } }
|
<vul-sep> hwc -> config_base = MSR_ARCH_PERFMON_FIXED_CTR_CTRL ; <vul-start> hwc -> event_base = MSR_ARCH_PERFMON_FIXED_CTR0 + ( hwc -> idx - X86_PMC_IDX_FIXED ) ; <vul-end> } else { <vul-sep>
|
40
|
CWE-264 int lxc_attach ( const char * name , const char * lxcpath , lxc_attach_exec_t exec_function , void * exec_payload , lxc_attach_options_t * options , pid_t * attached_process ) { int ret , status ; pid_t init_pid , pid , attached_pid , expected ; struct lxc_proc_context_info * init_ctx ; char * cwd ; char * new_cwd ; int ipc_sockets [ 2 ] ; <vul-start> int procfd ; <vul-end> signed long personality ; if ( ! options ) options = & attach_static_default_options ; init_pid = lxc_cmd_get_init_pid ( name , lxcpath ) ; if ( init_pid < 0 ) { ERROR ( "failed to get the init pid" ) ; return - 1 ; } init_ctx = lxc_proc_get_context_info ( init_pid ) ; if ( ! init_ctx ) { ERROR ( "failed to get context of the init process, pid = %ld" , ( long ) init_pid ) ; return - 1 ; } personality = get_personality ( name , lxcpath ) ; if ( init_ctx -> personality < 0 ) { ERROR ( "Failed to get personality of the container" ) ; lxc_proc_put_context_info ( init_ctx ) ; return - 1 ; } init_ctx -> personality = personality ; init_ctx -> container = lxc_container_new ( name , lxcpath ) ; if ( ! init_ctx -> container ) return - 1 ; if ( ! fetch_seccomp ( init_ctx -> container , options ) ) WARN ( "Failed to get seccomp policy" ) ; if ( ! no_new_privs ( init_ctx -> container , options ) ) WARN ( "Could not determine whether PR_SET_NO_NEW_PRIVS is set." ) ; cwd = getcwd ( NULL , 0 ) ; if ( options -> namespaces == - 1 ) { options -> namespaces = lxc_cmd_get_clone_flags ( name , lxcpath ) ; if ( options -> namespaces == - 1 ) { ERROR ( "failed to automatically determine the " "namespaces which the container unshared" ) ; free ( cwd ) ; lxc_proc_put_context_info ( init_ctx ) ; return - 1 ; } } ret = socketpair ( PF_LOCAL , SOCK_STREAM | SOCK_CLOEXEC , 0 , ipc_sockets ) ; if ( ret < 0 ) { SYSERROR ( "could not set up required IPC mechanism for attaching" ) ; free ( cwd ) ; lxc_proc_put_context_info ( init_ctx ) ; return - 1 ; } pid = fork ( ) ; if ( pid < 0 ) { SYSERROR ( "failed to create first subprocess" ) ; free ( cwd ) ; lxc_proc_put_context_info ( init_ctx ) ; return - 1 ; } if ( pid ) { <vul-start> <vul-end> pid_t to_cleanup_pid = pid ; close ( ipc_sockets [ 1 ] ) ; free ( cwd ) ; if ( options -> attach_flags & LXC_ATTACH_MOVE_TO_CGROUP ) { if ( ! cgroup_attach ( name , lxcpath , pid ) ) <vul-start> <vul-end> goto cleanup_error ; } status = 0 ; ret = lxc_write_nointr ( ipc_sockets [ 0 ] , & status , sizeof ( status ) ) ; if ( ret <= 0 ) { ERROR ( "error using IPC to notify attached process for initialization (0)" ) ; goto cleanup_error ; } ret = lxc_read_nointr_expect ( ipc_sockets [ 0 ] , & attached_pid , sizeof ( attached_pid ) , NULL ) ; if ( ret <= 0 ) { if ( ret != 0 ) ERROR ( "error using IPC to receive pid of attached process" ) ; goto cleanup_error ; } if ( options -> stdin_fd == 0 ) { signal ( SIGINT , SIG_IGN ) ; signal ( SIGQUIT , SIG_IGN ) ; } ret = wait_for_pid ( pid ) ; if ( ret < 0 ) goto cleanup_error ; to_cleanup_pid = attached_pid ; status = 0 ; ret = lxc_write_nointr ( ipc_sockets [ 0 ] , & status , sizeof ( status ) ) ; if ( ret <= 0 ) { ERROR ( "error using IPC to notify attached process for initialization (0)" ) ; goto cleanup_error ; } expected = 1 ; ret = lxc_read_nointr_expect ( ipc_sockets [ 0 ] , & status , sizeof ( status ) , & expected ) ; if ( ret <= 0 ) { if ( ret != 0 ) <vul-start> ERROR ( "error using IPC to receive notification from attached process (1)" ) ; <vul-end> goto cleanup_error ; } status = 2 ; ret = lxc_write_nointr ( ipc_sockets [ 0 ] , & status , sizeof ( status ) ) ; if ( ret <= 0 ) { <vul-start> ERROR ( "error using IPC to notify attached process for initialization (2)" ) ; <vul-end> goto cleanup_error ; <vul-start> <vul-end> } shutdown ( ipc_sockets [ 0 ] , SHUT_RDWR ) ; close ( ipc_sockets [ 0 ] ) ; lxc_proc_put_context_info ( init_ctx ) ; * attached_process = attached_pid ; return 0 ; cleanup_error : <vul-start> <vul-end> shutdown ( ipc_sockets [ 0 ] , SHUT_RDWR ) ; close ( ipc_sockets [ 0 ] ) ; if ( to_cleanup_pid ) ( void ) wait_for_pid ( to_cleanup_pid ) ; lxc_proc_put_context_info ( init_ctx ) ; return - 1 ; } close ( ipc_sockets [ 0 ] ) ; expected = 0 ; status = - 1 ; ret = lxc_read_nointr_expect ( ipc_sockets [ 1 ] , & status , sizeof ( status ) , & expected ) ; if ( ret <= 0 ) { ERROR ( "error communicating with child process" ) ; shutdown ( ipc_sockets [ 1 ] , SHUT_RDWR ) ; rexit ( - 1 ) ; } if ( ( options -> attach_flags & LXC_ATTACH_MOVE_TO_CGROUP ) && cgns_supported ( ) ) options -> namespaces |= CLONE_NEWCGROUP ; <vul-start> procfd = open ( "/proc" , O_DIRECTORY | O_RDONLY ) ; if ( procfd < 0 ) { SYSERROR ( "Unable to open /proc" ) ; shutdown ( ipc_sockets [ 1 ] , SHUT_RDWR ) ; rexit ( - 1 ) ; } <vul-end> ret = lxc_attach_to_ns ( init_pid , options -> namespaces ) ; if ( ret < 0 ) { ERROR ( "failed to enter the namespace" ) ; shutdown ( ipc_sockets [ 1 ] , SHUT_RDWR ) ; rexit ( - 1 ) ; } if ( options -> initial_cwd ) new_cwd = options -> initial_cwd ; else new_cwd = cwd ; ret = chdir ( new_cwd ) ; if ( ret < 0 ) WARN ( "could not change directory to \'%s\'" , new_cwd ) ; free ( cwd ) ; { struct attach_clone_payload payload = { . ipc_socket = ipc_sockets [ 1 ] , . options = options , . init_ctx = init_ctx , . exec_function = exec_function , . exec_payload = exec_payload , <vul-start> . procfd = procfd <vul-end> } ; pid = lxc_clone ( attach_child_main , & payload , CLONE_PARENT ) ; } if ( pid <= 0 ) { SYSERROR ( "failed to create subprocess" ) ; shutdown ( ipc_sockets [ 1 ] , SHUT_RDWR ) ; rexit ( - 1 ) ; } ret = lxc_write_nointr ( ipc_sockets [ 1 ] , & pid , sizeof ( pid ) ) ; if ( ret != sizeof ( pid ) ) { ERROR ( "error using IPC to notify main process of pid of the attached process" ) ; shutdown ( ipc_sockets [ 1 ] , SHUT_RDWR ) ; rexit ( - 1 ) ; } rexit ( 0 ) ; }
|
<vul-sep> if ( pid ) { <vul-start> int procfd = - 1 ; <vul-end> pid_t to_cleanup_pid = pid ; <vul-sep> if ( ! cgroup_attach ( name , lxcpath , pid ) ) <vul-start> goto cleanup_error ; } procfd = open ( "/proc" , O_DIRECTORY | O_RDONLY | O_CLOEXEC ) ; if ( procfd < 0 ) { SYSERROR ( "Unable to open /proc." ) ; <vul-end> goto cleanup_error ; <vul-sep> if ( ret != 0 ) <vul-start> ERROR ( "error using IPC to receive notification " "from attached process (1)" ) ; <vul-end> goto cleanup_error ; <vul-sep> if ( ret <= 0 ) { <vul-start> ERROR ( "Error using IPC to notify attached process for " "initialization (2): %s." , strerror ( errno ) ) ; <vul-end> goto cleanup_error ; <vul-sep> <vul-end> goto cleanup_error ; <vul-start> } expected = 3 ; ret = lxc_read_nointr_expect ( ipc_sockets [ 0 ] , & status , sizeof ( status ) , & expected ) ; if ( ret <= 0 ) { ERROR ( "Error using IPC for the child to tell us to open LSM fd (3): %s." , strerror ( errno ) ) ; goto cleanup_error ; } if ( ( options -> namespaces & CLONE_NEWNS ) && ( options -> attach_flags & LXC_ATTACH_LSM ) && init_ctx -> lsm_label ) { int on_exec , labelfd ; on_exec = options -> attach_flags & LXC_ATTACH_LSM_EXEC ? 1 : 0 ; labelfd = lsm_openat ( procfd , attached_pid , on_exec ) ; if ( labelfd < 0 ) goto cleanup_error ; ret = lxc_abstract_unix_send_fd ( ipc_sockets [ 0 ] , labelfd , NULL , 0 ) ; if ( ret <= 0 ) { ERROR ( "Error using IPC to send child LSM fd (4): %s." , strerror ( errno ) ) ; goto cleanup_error ; } <vul-end> } <vul-sep> cleanup_error : <vul-start> if ( procfd >= 0 ) close ( procfd ) ; <vul-end> shutdown ( ipc_sockets [ 0 ] , SHUT_RDWR ) ; <vul-sep>
|
41
|
CWE-190 static int b_unpack ( lua_State * L ) { Header h ; const char * fmt = luaL_checkstring ( L , 1 ) ; size_t ld ; const char * data = luaL_checklstring ( L , 2 , & ld ) ; <vul-start> size_t pos = luaL_optinteger ( L , 3 , 1 ) - 1 ; <vul-end> int n = 0 ; defaultoptions ( & h ) ; while ( * fmt ) { int opt = * fmt ++ ; size_t size = optsize ( L , opt , & fmt ) ; pos += gettoalign ( pos , & h , opt , size ) ; <vul-start> luaL_argcheck ( L , pos + size <= ld , 2 , "data string too short" ) ; <vul-end> luaL_checkstack ( L , 2 , "too many results" ) ; switch ( opt ) { case 'b' : case 'B' : case 'h' : case 'H' : case 'l' : case 'L' : case 'T' : case 'i' : case 'I' : { int issigned = islower ( opt ) ; lua_Number res = getinteger ( data + pos , h . endian , issigned , size ) ; lua_pushnumber ( L , res ) ; n ++ ; break ; } case 'x' : { break ; } case 'f' : { float f ; memcpy ( & f , data + pos , size ) ; correctbytes ( ( char * ) & f , sizeof ( f ) , h . endian ) ; lua_pushnumber ( L , f ) ; n ++ ; break ; } case 'd' : { double d ; memcpy ( & d , data + pos , size ) ; correctbytes ( ( char * ) & d , sizeof ( d ) , h . endian ) ; lua_pushnumber ( L , d ) ; n ++ ; break ; } case 'c' : { if ( size == 0 ) { if ( n == 0 || ! lua_isnumber ( L , - 1 ) ) luaL_error ( L , "format \'c0\' needs a previous size" ) ; size = lua_tonumber ( L , - 1 ) ; lua_pop ( L , 1 ) ; n -- ; luaL_argcheck ( L , size <= ld && pos <= ld - size , 2 , "data string too short" ) ; } lua_pushlstring ( L , data + pos , size ) ; n ++ ; break ; } case 's' : { const char * e = ( const char * ) memchr ( data + pos , '\\0' , ld - pos ) ; if ( e == NULL ) luaL_error ( L , "unfinished string in data" ) ; size = ( e - ( data + pos ) ) + 1 ; lua_pushlstring ( L , data + pos , size - 1 ) ; n ++ ; break ; } default : controloptions ( L , opt , & fmt , & h ) ; } pos += size ; }
|
<vul-sep> const char * data = luaL_checklstring ( L , 2 , & ld ) ; <vul-start> size_t pos = luaL_optinteger ( L , 3 , 1 ) ; luaL_argcheck ( L , pos > 0 , 3 , "offset must be 1 or greater" ) ; pos -- ; <vul-end> int n = 0 ; <vul-sep> pos += gettoalign ( pos , & h , opt , size ) ; <vul-start> luaL_argcheck ( L , size <= ld && pos <= ld - size , 2 , "data string too short" ) ; <vul-end> luaL_checkstack ( L , 2 , "too many results" ) ; <vul-sep>
|
42
|
NVD-CWE-Other 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 ) ; <vul-start> <vul-end> goto skip_normal_probe ; } if ( ! buffer ) { dev_err ( & intf -> dev , "Weird descriptor references\\n" ) ; return - EINVAL ; } if ( ! buflen ) { if ( intf -> cur_altsetting -> endpoint && intf -> cur_altsetting -> endpoint -> extralen && intf -> cur_altsetting -> endpoint -> extra ) { dev_dbg ( & intf -> dev , "Seeking extra descriptors on endpoint\\n" ) ; buflen = intf -> cur_altsetting -> endpoint -> extralen ; buffer = intf -> cur_altsetting -> endpoint -> extra ; } else { dev_err ( & intf -> dev , "Zero length descriptor references\\n" ) ; return - EINVAL ; } } while ( buflen > 0 ) { elength = buffer [ 0 ] ; if ( ! elength ) { dev_err ( & intf -> dev , "skipping garbage byte\\n" ) ; elength = 1 ; goto next_desc ; } if ( buffer [ 1 ] != USB_DT_CS_INTERFACE ) { dev_err ( & intf -> dev , "skipping garbage\\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 , "More than one " "union descriptor, 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 :
|
<vul-sep> control_interface = usb_ifnum_to_if ( usb_dev , 0 ) ; <vul-start> if ( ! data_interface || ! control_interface ) return - ENODEV ; <vul-end> goto skip_normal_probe ; <vul-sep>
|
43
|
NVD-CWE-Other PyObject * error ; switch ( type ) { case 1 : { double d ; if ( max < 8 ) { goto invalid ; } memcpy ( & d , buffer + * position , 8 ) ; value = PyFloat_FromDouble ( d ) ; if ( ! value ) { return NULL ; } * position += 8 ; break ; } case 2 : case 14 : { int value_length = ( ( int * ) ( buffer + * position ) ) [ 0 ] - 1 ; if ( max < value_length ) { goto invalid ; } * position += 4 ; value = PyUnicode_DecodeUTF8 ( buffer + * position , value_length , "strict" ) ; if ( ! value ) { return NULL ; } * position += value_length + 1 ; break ; } case 3 : { int size ; memcpy ( & size , buffer + * position , 4 ) ; if ( max < size ) { goto invalid ; } value = elements_to_dict ( self , buffer + * position + 4 , size - 5 , as_class , tz_aware , uuid_subtype ) ; if ( ! value ) { return NULL ; } if ( strcmp ( buffer + * position + 5 , "$ref" ) == 0 ) { PyObject * dbref ; PyObject * collection = PyDict_GetItemString ( value , "$ref" ) ; PyObject * id = PyDict_GetItemString ( value , "$id" ) ; PyObject * database = PyDict_GetItemString ( value , "$db" ) ; Py_INCREF ( collection ) ; PyDict_DelItemString ( value , "$ref" ) ; <vul-start> <vul-end> Py_INCREF ( id ) ; PyDict_DelItemString ( value , "$id" ) ; <vul-start> <vul-end> if ( database == NULL ) { database = Py_None ; Py_INCREF ( database ) ; } else { Py_INCREF ( database ) ; PyDict_DelItemString ( value , "$db" ) ; } dbref = PyObject_CallFunctionObjArgs ( state -> DBRef , collection , id , database , value , NULL ) ; Py_DECREF ( value ) ; value = dbref ; Py_DECREF ( id ) ; Py_DECREF ( collection ) ; Py_DECREF ( database ) ; if ( ! value ) { return NULL ; } } * position += size ; break ; } case 4 : { int size , end ; memcpy ( & size , buffer + * position , 4 ) ; if ( max < size ) { goto invalid ; } end = * position + size - 1 ; * position += 4 ; value = PyList_New ( 0 ) ; if ( ! value ) { return NULL ; } while ( * position < end ) { PyObject * to_append ; int type = ( int ) buffer [ ( * position ) ++ ] ; int key_size = strlen ( buffer + * position ) ; * position += key_size + 1 ; to_append = get_value ( self , buffer , position , type , max - key_size , as_class , tz_aware , uuid_subtype ) ; if ( ! to_append ) { Py_DECREF ( value ) ; return NULL ; } PyList_Append ( value , to_append ) ; Py_DECREF ( to_append ) ; } ( * position ) ++ ; break ;
|
<vul-sep> PyDict_DelItemString ( value , "$ref" ) ; <vul-start> if ( id == NULL ) { id = Py_None ; Py_INCREF ( id ) ; } else { <vul-end> Py_INCREF ( id ) ; <vul-sep> PyDict_DelItemString ( value , "$id" ) ; <vul-start> } <vul-end> if ( database == NULL ) { <vul-sep>
|
44
|
CWE-119 static ssize_t macvtap_get_user ( struct macvtap_queue * q , struct msghdr * m , const struct iovec * iv , unsigned long total_len , size_t count , int noblock ) { struct sk_buff * skb ; struct macvlan_dev * vlan ; unsigned long len = total_len ; int err ; struct virtio_net_hdr vnet_hdr = { 0 } ; int vnet_hdr_len = 0 ; <vul-start> int copylen ; <vul-end> bool zerocopy = false ; if ( q -> flags & IFF_VNET_HDR ) { vnet_hdr_len = q -> vnet_hdr_sz ; err = - EINVAL ; if ( len < vnet_hdr_len ) goto err ; len -= vnet_hdr_len ; err = memcpy_fromiovecend ( ( void * ) & vnet_hdr , iv , 0 , sizeof ( vnet_hdr ) ) ; if ( err < 0 ) goto err ; if ( ( vnet_hdr . flags & VIRTIO_NET_HDR_F_NEEDS_CSUM ) && vnet_hdr . csum_start + vnet_hdr . csum_offset + 2 > vnet_hdr . hdr_len ) vnet_hdr . hdr_len = vnet_hdr . csum_start + vnet_hdr . csum_offset + 2 ; err = - EINVAL ; if ( vnet_hdr . hdr_len > len ) goto err ; } err = - EINVAL ; if ( unlikely ( len < ETH_HLEN ) ) goto err ; <vul-start> <vul-end> if ( m && m -> msg_control && sock_flag ( & q -> sk , SOCK_ZEROCOPY ) ) zerocopy = true ; if ( zerocopy ) { <vul-start> <vul-end> copylen = vnet_hdr . hdr_len ; if ( ! copylen ) copylen = GOODCOPY_LEN ; } else copylen = len ; skb = macvtap_alloc_skb ( & q -> sk , NET_IP_ALIGN , copylen , vnet_hdr . hdr_len , noblock , & err ) ; if ( ! skb ) goto err ; if ( zerocopy ) err = zerocopy_sg_from_iovec ( skb , iv , vnet_hdr_len , count ) ; else err = skb_copy_datagram_from_iovec ( skb , 0 , iv , vnet_hdr_len , len ) ; if ( err ) goto err_kfree ; skb_set_network_header ( skb , ETH_HLEN ) ; skb_reset_mac_header ( skb ) ; skb -> protocol = eth_hdr ( skb ) -> h_proto ; if ( vnet_hdr_len ) { err = macvtap_skb_from_vnet_hdr ( skb , & vnet_hdr ) ; if ( err ) goto err_kfree ; } rcu_read_lock_bh ( ) ; vlan = rcu_dereference_bh ( q -> vlan ) ; if ( zerocopy ) { skb_shinfo ( skb ) -> destructor_arg = m -> msg_control ; skb_shinfo ( skb ) -> tx_flags |= SKBTX_DEV_ZEROCOPY ; } if ( vlan ) macvlan_start_xmit ( skb , vlan -> dev ) ; else kfree_skb ( skb ) ; rcu_read_unlock_bh ( ) ; return total_len ; err_kfree : kfree_skb ( skb ) ; err : rcu_read_lock_bh ( ) ; vlan = rcu_dereference_bh ( q -> vlan ) ; if ( vlan ) vlan -> dev -> stats . tx_dropped ++ ; rcu_read_unlock_bh ( ) ; return err ; }
|
<vul-sep> int vnet_hdr_len = 0 ; <vul-start> int copylen = 0 ; <vul-end> bool zerocopy = false ; <vul-sep> goto err ; <vul-start> err = - EMSGSIZE ; if ( unlikely ( count > UIO_MAXIOV ) ) goto err ; <vul-end> if ( m && m -> msg_control && sock_flag ( & q -> sk , SOCK_ZEROCOPY ) ) <vul-sep> if ( zerocopy ) { <vul-start> if ( count > MAX_SKB_FRAGS ) { copylen = iov_length ( iv , count - MAX_SKB_FRAGS ) ; if ( copylen < vnet_hdr_len ) copylen = 0 ; else copylen -= vnet_hdr_len ; } if ( copylen < vnet_hdr . hdr_len ) <vul-end> copylen = vnet_hdr . hdr_len ; <vul-sep>
|
45
|
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 ) ; <vul-start> <vul-end> 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 , "PPS id out of range: %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 , "PPS changed between slices.\\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 ) ;
|
<vul-sep> sh -> first_slice_in_pic_flag = get_bits1 ( gb ) ; <vul-start> if ( s -> ref && sh -> first_slice_in_pic_flag ) { av_log ( s -> avctx , AV_LOG_ERROR , "Two slices reporting being the first in the same frame.\\n" ) ; return 1 ; } <vul-end> if ( ( IS_IDR ( s ) || IS_BLA ( s ) ) && sh -> first_slice_in_pic_flag ) { <vul-sep>
|
46
|
CWE-18 static krb5_error_code <vul-start> iakerb_alloc_context ( iakerb_ctx_id_t * pctx ) <vul-end> { iakerb_ctx_id_t ctx ; krb5_error_code code ; * pctx = NULL ; ctx = k5alloc ( sizeof ( * ctx ) , & code ) ; if ( ctx == NULL ) goto cleanup ; ctx -> defcred = GSS_C_NO_CREDENTIAL ; ctx -> magic = KG_IAKERB_CONTEXT ; ctx -> state = IAKERB_AS_REQ ; ctx -> count = 0 ; <vul-start> <vul-end> code = krb5_gss_init_context ( & ctx -> k5c ) ; if ( code != 0 ) goto cleanup ; * pctx = ctx ; cleanup : if ( code != 0 ) iakerb_release_context ( ctx ) ; return code ; }
|
<vul-sep> static krb5_error_code <vul-start> iakerb_alloc_context ( iakerb_ctx_id_t * pctx , int initiate ) <vul-end> { <vul-sep> ctx -> count = 0 ; <vul-start> ctx -> initiate = initiate ; ctx -> established = 0 ; <vul-end> code = krb5_gss_init_context ( & ctx -> k5c ) ; <vul-sep>
|
47
|
CWE-119 int dbd_bind_ph ( SV * sth , imp_sth_t * imp_sth , SV * param , SV * value , IV sql_type , SV * attribs , int is_inout , IV maxlen ) { dTHX ; int rc ; int param_num = SvIV ( param ) ; int idx = param_num - 1 ; <vul-start> char err_msg [ 64 ] ; <vul-end> D_imp_xxh ( sth ) ; # if MYSQL_VERSION_ID >= SERVER_PREPARE_VERSION STRLEN slen ; char * buffer = NULL ; int buffer_is_null = 0 ; int buffer_length = slen ; unsigned int buffer_type = 0 ; IV tmp ; # endif D_imp_dbh_from_sth ; ASYNC_CHECK_RETURN ( sth , FALSE ) ; if ( DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , " Called: dbd_bind_ph\\n" ) ; attribs = attribs ; maxlen = maxlen ; if ( param_num <= 0 || param_num > DBIc_NUM_PARAMS ( imp_sth ) ) { do_error ( sth , JW_ERR_ILLEGAL_PARAM_NUM , "Illegal parameter number" , NULL ) ; return FALSE ; } if ( SvOK ( value ) && ( sql_type == SQL_NUMERIC || sql_type == SQL_DECIMAL || sql_type == SQL_INTEGER || sql_type == SQL_SMALLINT || sql_type == SQL_FLOAT || sql_type == SQL_REAL || sql_type == SQL_DOUBLE ) ) { if ( ! looks_like_number ( value ) ) { <vul-start> sprintf ( err_msg , <vul-end> "Binding non-numeric field %d, value %s as a numeric!" , <vul-start> param_num , neatsvpv ( value , 0 ) ) ; <vul-end> do_error ( sth , JW_ERR_ILLEGAL_PARAM_NUM , err_msg , NULL ) ; } } if ( is_inout ) { do_error ( sth , JW_ERR_NOT_IMPLEMENTED , "Output parameters not implemented" , NULL ) ; return FALSE ; } rc = bind_param ( & imp_sth -> params [ idx ] , value , sql_type ) ; # if MYSQL_VERSION_ID >= SERVER_PREPARE_VERSION if ( imp_sth -> use_server_side_prepare ) { switch ( sql_type ) { case SQL_NUMERIC : case SQL_INTEGER : case SQL_SMALLINT : case SQL_BIGINT : case SQL_TINYINT : buffer_type = MYSQL_TYPE_LONG ; break ; case SQL_DOUBLE : case SQL_DECIMAL : case SQL_FLOAT : case SQL_REAL : buffer_type = MYSQL_TYPE_DOUBLE ; break ; case SQL_CHAR : case SQL_VARCHAR : case SQL_DATE : case SQL_TIME : case SQL_TIMESTAMP : case SQL_LONGVARCHAR : case SQL_BINARY : case SQL_VARBINARY : case SQL_LONGVARBINARY : buffer_type = MYSQL_TYPE_BLOB ; break ; default : buffer_type = MYSQL_TYPE_STRING ; } buffer_is_null = ! ( SvOK ( imp_sth -> params [ idx ] . value ) && imp_sth -> params [ idx ] . value ) ; if ( ! buffer_is_null ) { switch ( buffer_type ) { case MYSQL_TYPE_LONG : if ( ! SvIOK ( imp_sth -> params [ idx ] . value ) && DBIc_TRACE_LEVEL ( imp_xxh ) >= 2 ) PerlIO_printf ( DBIc_LOGPIO ( imp_xxh ) , "\\t\\tTRY TO BIND AN INT NUMBER\\n" ) ; buffer_length = sizeof imp_sth -> fbind [ idx ] . numeric_val . lval ; tmp = SvIV ( imp_sth -> params [ idx ] . value ) ; if ( tmp > INT32_MAX ) croak ( "Could not bind %ld: Integer too large for MYSQL_TYPE_LONG" , tmp ) ;
|
<vul-sep> int idx = param_num - 1 ; <vul-start> char * err_msg ; <vul-end> D_imp_xxh ( sth ) ; <vul-sep> { <vul-start> err_msg = SvPVX ( sv_2mortal ( newSVpvf ( <vul-end> "Binding non-numeric field %d, value %s as a numeric!" , <vul-sep> <vul-end> "Binding non-numeric field %d, value %s as a numeric!" , <vul-start> param_num , neatsvpv ( value , 0 ) ) ) ) ; <vul-end> do_error ( sth , JW_ERR_ILLEGAL_PARAM_NUM , err_msg , NULL ) ; <vul-sep>
|
48
|
CWE-119 static vpx_codec_err_t vp8_get_frame_corrupted ( vpx_codec_alg_priv_t * ctx , <vul-start> int ctrl_id , <vul-end> va_list args ) { int * corrupted = va_arg ( args , int * ) ; VP8D_COMP * pbi = ( VP8D_COMP * ) ctx -> yv12_frame_buffers . pbi [ 0 ] ; if ( corrupted && pbi ) { <vul-start> * corrupted = pbi -> common . frame_to_show -> corrupted ; <vul-end> return VPX_CODEC_OK ; } else return VPX_CODEC_INVALID_PARAM ; }
|
<vul-sep> { <vul-start> const YV12_BUFFER_CONFIG * const frame = pbi -> common . frame_to_show ; if ( frame == NULL ) return VPX_CODEC_ERROR ; * corrupted = frame -> corrupted ; <vul-end> return VPX_CODEC_OK ; <vul-sep>
|
49
|
CWE-119 vcnt ++ ; if ( cpi -> lf_ref_frame [ mb_offset - 1 ] != INTRA_FRAME ) { near_mvs [ vcnt ] . as_int = cpi -> lfmv [ mb_offset - 1 ] . as_int ; mv_bias ( cpi -> lf_ref_frame_sign_bias [ mb_offset - 1 ] , refframe , & near_mvs [ vcnt ] , ref_frame_sign_bias ) ; near_ref [ vcnt ] = cpi -> lf_ref_frame [ mb_offset - 1 ] ; } vcnt ++ ; if ( cpi -> lf_ref_frame [ mb_offset + 1 ] != INTRA_FRAME ) { near_mvs [ vcnt ] . as_int = cpi -> lfmv [ mb_offset + 1 ] . as_int ; mv_bias ( cpi -> lf_ref_frame_sign_bias [ mb_offset + 1 ] , refframe , & near_mvs [ vcnt ] , ref_frame_sign_bias ) ; near_ref [ vcnt ] = cpi -> lf_ref_frame [ mb_offset + 1 ] ; } vcnt ++ ; if ( cpi -> lf_ref_frame [ mb_offset + xd -> mode_info_stride + 1 ] != INTRA_FRAME ) { near_mvs [ vcnt ] . as_int = cpi -> lfmv [ mb_offset + xd -> mode_info_stride + 1 ] . as_int ; mv_bias ( cpi -> lf_ref_frame_sign_bias [ mb_offset + xd -> mode_info_stride + 1 ] , refframe , & near_mvs [ vcnt ] , ref_frame_sign_bias ) ; near_ref [ vcnt ] = cpi -> lf_ref_frame [ mb_offset + xd -> mode_info_stride + 1 ] ; } vcnt ++ ; } for ( i = 0 ; i < vcnt ; i ++ ) { if ( near_ref [ near_sadidx [ i ] ] != INTRA_FRAME ) { if ( here -> mbmi . ref_frame == near_ref [ near_sadidx [ i ] ] ) { mv . as_int = near_mvs [ near_sadidx [ i ] ] . as_int ; find = 1 ; if ( i < 3 ) * sr = 3 ; else * sr = 2 ; break ; } } } if ( ! find ) { for ( i = 0 ; i < vcnt ; i ++ ) { mvx [ i ] = near_mvs [ i ] . as_mv . row ; mvy [ i ] = near_mvs [ i ] . as_mv . col ; } insertsortmv ( mvx , vcnt ) ; insertsortmv ( mvy , vcnt ) ; mv . as_mv . row = mvx [ vcnt / 2 ] ; mv . as_mv . col = mvy [ vcnt / 2 ] ; <vul-start> find = 1 ; <vul-end> * sr = 0 ; } } mvp -> as_int = mv . as_int ; vp8_clamp_mv2 ( mvp , xd ) ; }
|
<vul-sep>
|
50
|
CWE-264 static struct dentry * aio_mount ( struct file_system_type * fs_type , int flags , const char * dev_name , void * data ) { static const struct dentry_operations ops = { . d_dname = simple_dname , } ; <vul-start> return mount_pseudo ( fs_type , "aio:" , NULL , & ops , AIO_RING_MAGIC ) ; <vul-end> }
|
<vul-sep> } ; <vul-start> struct dentry * root = mount_pseudo ( fs_type , "aio:" , NULL , & ops , AIO_RING_MAGIC ) ; if ( ! IS_ERR ( root ) ) root -> d_sb -> s_iflags |= SB_I_NOEXEC ; return root ; <vul-end> } <vul-sep>
|
51
|
CWE-352 -void set_header ( HttpResponse res , const char * name , const char * value ) { +void set_header ( HttpResponse res , const char * name , const char * value , ... ) { HttpHeader h = NULL ; ASSERT ( res ) ; ASSERT ( name ) ; NEW ( h ) ; h -> name = Str_dup ( name ) ; <vul-start> h -> value = Str_dup ( value ) ; <vul-end> if ( res -> headers ) { HttpHeader n , p ; for ( n = p = res -> headers ; p ; n = p , p = p -> next ) { if ( IS ( p -> name , name ) ) { FREE ( p -> value ) ; p -> value = Str_dup ( value ) ; destroy_entry ( h ) ; return ; } } n -> next = h ; } else { res -> headers = h ; } }
|
<vul-sep> h -> name = Str_dup ( name ) ; <vul-start> va_list ap ; va_start ( ap , value ) ; h -> value = Str_vcat ( value , ap ) ; va_end ( ap ) ; <vul-end> if ( res -> headers ) { <vul-sep>
|
52
|
CWE-189 TSQuery parse_tsquery ( char * buf , PushFunction pushval , Datum opaque , bool isplain ) { struct TSQueryParserStateData state ; int i ; TSQuery query ; int commonlen ; QueryItem * ptr ; ListCell * cell ; state . buffer = buf ; state . buf = buf ; state . state = ( isplain ) ? WAITSINGLEOPERAND : WAITFIRSTOPERAND ; state . count = 0 ; state . polstr = NIL ; state . valstate = init_tsvector_parser ( state . buffer , true , true ) ; state . sumlen = 0 ; state . lenop = 64 ; state . curop = state . op = ( char * ) palloc ( state . lenop ) ; * ( state . curop ) = '\\0' ; makepol ( & state , pushval , opaque ) ; close_tsvector_parser ( state . valstate ) ; if ( list_length ( state . polstr ) == 0 ) { ereport ( NOTICE , ( errmsg ( "text-search query doesn\'t contain lexemes: \\"%s\\"" , state . buffer ) ) ) ; query = ( TSQuery ) palloc ( HDRSIZETQ ) ; SET_VARSIZE ( query , HDRSIZETQ ) ; query -> size = 0 ; return query ; } <vul-start> <vul-end> commonlen = COMPUTESIZE ( list_length ( state . polstr ) , state . sumlen ) ; query = ( TSQuery ) palloc0 ( commonlen ) ; SET_VARSIZE ( query , commonlen ) ; query -> size = list_length ( state . polstr ) ; ptr = GETQUERY ( query ) ; i = 0 ; foreach ( cell , state . polstr ) { QueryItem * item = ( QueryItem * ) lfirst ( cell ) ; switch ( item -> type ) { case QI_VAL : memcpy ( & ptr [ i ] , item , sizeof ( QueryOperand ) ) ; break ; case QI_VALSTOP : ptr [ i ] . type = QI_VALSTOP ; break ; case QI_OPR : memcpy ( & ptr [ i ] , item , sizeof ( QueryOperator ) ) ; break ; default : elog ( ERROR , "unrecognized QueryItem type: %d" , item -> type ) ; } i ++ ; } memcpy ( ( void * ) GETOPERAND ( query ) , ( void * ) state . op , state . sumlen ) ; pfree ( state . op ) ; findoprnd ( ptr , query -> size ) ; return query ; }
|
<vul-sep> } <vul-start> if ( TSQUERY_TOO_BIG ( list_length ( state . polstr ) , state . sumlen ) ) ereport ( ERROR , ( errcode ( ERRCODE_PROGRAM_LIMIT_EXCEEDED ) , errmsg ( "tsquery is too large" ) ) ) ; <vul-end> commonlen = COMPUTESIZE ( list_length ( state . polstr ) , state . sumlen ) ; <vul-sep>
|
53
|
CWE-119 -static LAYER_CONTEXT * get_layer_context ( SVC * svc ) { <vul-start> return svc -> number_temporal_layers > 1 ? & svc -> layer_context [ svc -> temporal_layer_id ] : & svc -> layer_context [ svc -> spatial_layer_id ] ; <vul-end>+static LAYER_CONTEXT * get_layer_context ( VP9_COMP * const cpi ) { <vul-start> <vul-end> }
|
<vul-sep> +static LAYER_CONTEXT * get_layer_context ( VP9_COMP * const cpi ) { <vul-start> if ( is_one_pass_cbr_svc ( cpi ) ) return & cpi -> svc . layer_context [ cpi -> svc . spatial_layer_id * cpi -> svc . number_temporal_layers + cpi -> svc . temporal_layer_id ] ; else return ( cpi -> svc . number_temporal_layers > 1 && cpi -> oxcf . rc_mode == VPX_CBR ) ? & cpi -> svc . layer_context [ cpi -> svc . temporal_layer_id ] : & cpi -> svc . layer_context [ cpi -> svc . spatial_layer_id ] ; <vul-end> } <vul-sep>
|
54
|
CWE-476 static void ov511_mode_init_regs ( struct sd * sd ) { struct gspca_dev * gspca_dev = ( struct gspca_dev * ) sd ; int hsegs , vsegs , packet_size , fps , needed ; int interlaced = 0 ; 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\'t get altsetting\\n" ) ; sd -> gspca_dev . usb_err = - EIO ; <vul-start> <vul-end> return ; } packet_size = le16_to_cpu ( alt -> endpoint [ 0 ] . desc . wMaxPacketSize ) ; reg_w ( sd , R51x_FIFO_PSIZE , packet_size >> 5 ) ; reg_w ( sd , R511_CAM_UV_EN , 0x01 ) ; reg_w ( sd , R511_SNAP_UV_EN , 0x01 ) ; reg_w ( sd , R511_SNAP_OPTS , 0x03 ) ; hsegs = ( sd -> gspca_dev . pixfmt . width >> 3 ) - 1 ; vsegs = ( sd -> gspca_dev . pixfmt . height >> 3 ) - 1 ; reg_w ( sd , R511_CAM_PXCNT , hsegs ) ; reg_w ( sd , R511_CAM_LNCNT , vsegs ) ; reg_w ( sd , R511_CAM_PXDIV , 0x00 ) ; reg_w ( sd , R511_CAM_LNDIV , 0x00 ) ; reg_w ( sd , R511_CAM_OPTS , 0x03 ) ; reg_w ( sd , R511_SNAP_PXCNT , hsegs ) ; reg_w ( sd , R511_SNAP_LNCNT , vsegs ) ; reg_w ( sd , R511_SNAP_PXDIV , 0x00 ) ; reg_w ( sd , R511_SNAP_LNDIV , 0x00 ) ; if ( frame_rate > 0 ) sd -> frame_rate = frame_rate ; switch ( sd -> sensor ) { case SEN_OV6620 : sd -> clockdiv = 3 ; break ; case SEN_OV7620 : case SEN_OV7620AE : case SEN_OV7640 : case SEN_OV7648 : case SEN_OV76BE : if ( sd -> gspca_dev . pixfmt . width == 320 ) interlaced = 1 ; case SEN_OV6630 : case SEN_OV7610 : case SEN_OV7670 : switch ( sd -> frame_rate ) { case 30 : case 25 : if ( sd -> gspca_dev . pixfmt . width != 640 ) { sd -> clockdiv = 0 ; break ; } default : sd -> clockdiv = 1 ; break ; case 10 : sd -> clockdiv = 2 ; break ; case 5 : sd -> clockdiv = 5 ; break ;
|
<vul-sep> sd -> gspca_dev . usb_err = - EIO ; <vul-start> return ; } if ( alt -> desc . bNumEndpoints < 1 ) { sd -> gspca_dev . usb_err = - ENODEV ; <vul-end> return ; <vul-sep>
|
55
|
CWE-190 jas_matrix_t * jas_matrix_create ( int numrows , int numcols ) { jas_matrix_t * matrix ; int i ; <vul-start> <vul-end> if ( numrows < 0 || numcols < 0 ) { <vul-start> return 0 ; <vul-end> } if ( ! ( matrix = jas_malloc ( sizeof ( jas_matrix_t ) ) ) ) { <vul-start> return 0 ; <vul-end> } matrix -> flags_ = 0 ; matrix -> numrows_ = numrows ; matrix -> numcols_ = numcols ; matrix -> rows_ = 0 ; matrix -> maxrows_ = numrows ; matrix -> data_ = 0 ; <vul-start> matrix -> datasize_ = numrows * numcols ; <vul-end> if ( matrix -> maxrows_ > 0 ) { if ( ! ( matrix -> rows_ = jas_alloc2 ( matrix -> maxrows_ , sizeof ( jas_seqent_t * ) ) ) ) { <vul-start> jas_matrix_destroy ( matrix ) ; return 0 ; <vul-end> } } if ( matrix -> datasize_ > 0 ) { if ( ! ( matrix -> data_ = jas_alloc2 ( matrix -> datasize_ , sizeof ( jas_seqent_t ) ) ) ) { <vul-start> jas_matrix_destroy ( matrix ) ; return 0 ; <vul-end> } } 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 ; <vul-start> <vul-end> }
|
<vul-sep> int i ; <vul-start> size_t size ; matrix = 0 ; <vul-end> if ( numrows < 0 || numcols < 0 ) { <vul-sep> <vul-end> if ( numrows < 0 || numcols < 0 ) { <vul-start> goto error ; <vul-end> } <vul-sep> if ( ! ( matrix = jas_malloc ( sizeof ( jas_matrix_t ) ) ) ) { <vul-start> goto error ; <vul-end> } <vul-sep> matrix -> data_ = 0 ; <vul-start> matrix -> datasize_ = 0 ; if ( ! jas_safe_size_mul ( numrows , numcols , & size ) ) { goto error ; } matrix -> datasize_ = size ; <vul-end> if ( matrix -> maxrows_ > 0 ) { <vul-sep> sizeof ( jas_seqent_t * ) ) ) ) { <vul-start> goto error ; <vul-end> } <vul-sep> sizeof ( jas_seqent_t ) ) ) ) { <vul-start> goto error ; <vul-end> } <vul-sep> return matrix ; <vul-start> error : if ( matrix ) { jas_matrix_destroy ( matrix ) ; } return 0 ; <vul-end> } <vul-sep>
|
56
|
CWE-125 static int ng_pkt ( git_pkt * * out , const char * line , size_t len ) { git_pkt_ng * pkt ; const char * ptr ; size_t alloclen ; pkt = git__malloc ( sizeof ( * pkt ) ) ; GITERR_CHECK_ALLOC ( pkt ) ; pkt -> ref = NULL ; pkt -> type = GIT_PKT_NG ; <vul-start> <vul-end> line += 3 ; <vul-start> if ( ! ( ptr = strchr ( line , ' ' ) ) ) <vul-end> goto out_err ; len = ptr - line ; GITERR_CHECK_ALLOC_ADD ( & alloclen , len , 1 ) ; pkt -> ref = git__malloc ( alloclen ) ; GITERR_CHECK_ALLOC ( pkt -> ref ) ; memcpy ( pkt -> ref , line , len ) ; pkt -> ref [ len ] = '\\0' ; <vul-start> <vul-end> line = ptr + 1 ; <vul-start> if ( ! ( ptr = strchr ( line , '\\n' ) ) ) <vul-end> goto out_err ; len = ptr - line ; GITERR_CHECK_ALLOC_ADD ( & alloclen , len , 1 ) ; pkt -> msg = git__malloc ( alloclen ) ; GITERR_CHECK_ALLOC ( pkt -> msg ) ; memcpy ( pkt -> msg , line , len ) ; pkt -> msg [ len ] = '\\0' ; * out = ( git_pkt * ) pkt ; return 0 ; out_err : giterr_set ( GITERR_NET , "invalid packet line" ) ; git__free ( pkt -> ref ) ; git__free ( pkt ) ; return - 1 ; }
|
<vul-sep> pkt -> type = GIT_PKT_NG ; <vul-start> if ( len < 3 ) goto out_err ; <vul-end> line += 3 ; <vul-sep> <vul-end> line += 3 ; <vul-start> len -= 3 ; if ( ! ( ptr = memchr ( line , ' ' , len ) ) ) <vul-end> goto out_err ; <vul-sep> pkt -> ref [ len ] = '\\0' ; <vul-start> if ( len < 1 ) goto out_err ; <vul-end> line = ptr + 1 ; <vul-sep> <vul-end> line = ptr + 1 ; <vul-start> len -= 1 ; if ( ! ( ptr = memchr ( line , '\\n' , len ) ) ) <vul-end> goto out_err ; <vul-sep>
|
57
|
CWE-134 rrd_set_error ( "invalid y-grid format" ) ; return ; } break ; case 1007 : im -> draw_3d_border = atoi ( optarg ) ; break ; case 1008 : if ( sscanf ( optarg , "%[-0-9.e+]:%[-0-9.e+]" , double_str , double_str2 ) != 2 ) { if ( rrd_strtodbl ( double_str , 0 , & ( im -> grid_dash_on ) , NULL ) != 2 || rrd_strtodbl ( double_str2 , 0 , & ( im -> grid_dash_off ) , NULL ) != 2 ) { rrd_set_error ( "expected grid-dash format float:float" ) ; return ; } } break ; case 1009 : im -> dynamic_labels = 1 ; break ; case 1010 : strncpy ( week_fmt , optarg , sizeof week_fmt ) ; week_fmt [ ( sizeof week_fmt ) - 1 ] = '\\0' ; break ; case 1002 : if ( sscanf ( optarg , "%[-0-9.e+]:%[-0-9.e+]" , double_str , double_str2 ) == 2 && rrd_strtodbl ( double_str , 0 , & ( im -> second_axis_scale ) , NULL ) == 2 && rrd_strtodbl ( double_str2 , 0 , & ( im -> second_axis_shift ) , NULL ) == 2 ) { if ( im -> second_axis_scale == 0 ) { rrd_set_error ( "the second_axis_scale must not be 0" ) ; return ; } } else { rrd_set_error ( "invalid right-axis format expected scale:shift" ) ; return ; } break ; case 1003 : im -> second_axis_legend = strdup ( optarg ) ; if ( ! im -> second_axis_legend ) { rrd_set_error ( "cannot allocate memory for second_axis_legend" ) ; return ; } break ; case 1004 : <vul-start> if ( bad_format ( optarg ) ) { rrd_set_error ( "use either %le or %lf formats" ) ; <vul-end> return ; } im -> second_axis_format = strdup ( optarg ) ; if ( ! im -> second_axis_format ) { rrd_set_error ( "cannot allocate memory for second_axis_format" ) ; return ; } break ; case 1012 : <vul-start> if ( bad_format ( optarg ) ) { rrd_set_error ( "use either %le or %lf formats" ) ; <vul-end> return ; } im -> primary_axis_format = strdup ( optarg ) ; if ( ! im -> primary_axis_format ) { rrd_set_error ( "cannot allocate memory for primary_axis_format" ) ; return ; } break ; case 'v' : im -> ylegend = strdup ( optarg ) ; if ( ! im -> ylegend ) { rrd_set_error ( "cannot allocate memory for ylegend" ) ; return ; } break ; case 'u' : if ( rrd_strtodbl ( optarg , 0 , & ( im -> maxval ) , "option -u" ) != 2 ) { return ; } break ; case 'l' : if ( rrd_strtodbl ( optarg , 0 , & ( im -> minval ) , "option -l" ) != 2 ) { return ; } break ; case 'b' : im -> base = atol ( optarg ) ; if ( im -> base != 1024 && im -> base != 1000 ) { rrd_set_error ( "the only sensible value for base apart from 1000 is 1024" ) ; return ; } break ; case 'w' : long_tmp = atol ( optarg ) ; if ( long_tmp < 10 ) { rrd_set_error ( "width below 10 pixels" ) ; return ; } im -> xsize = long_tmp ; break ; case 'h' : long_tmp = atol ( optarg ) ; if ( long_tmp < 10 ) { rrd_set_error ( "height below 10 pixels" ) ; return ; } im -> ysize = long_tmp ; break ; case 'D' :
|
<vul-sep> case 1004 : <vul-start> if ( bad_format_axis ( optarg ) ) { <vul-end> return ; <vul-sep> case 1012 : <vul-start> if ( bad_format_axis ( optarg ) ) { <vul-end> return ; <vul-sep>
|
58
|
CWE-119 static RD_BOOL mcs_recv_connect_response ( STREAM mcs_data ) { UNUSED ( mcs_data ) ; uint8 result ; <vul-start> int length ; <vul-end> STREAM s ; <vul-start> <vul-end> RD_BOOL is_fastpath ; uint8 fastpath_hdr ; logger ( Protocol , Debug , "%s()" , __func__ ) ; s = iso_recv ( & is_fastpath , & fastpath_hdr ) ; if ( s == NULL ) return False ; <vul-start> <vul-end> ber_parse_header ( s , MCS_CONNECT_RESPONSE , & length ) ; ber_parse_header ( s , BER_TAG_RESULT , & length ) ; in_uint8 ( s , result ) ; if ( result != 0 ) { logger ( Protocol , Error , "mcs_recv_connect_response(), result=%d" , result ) ; return False ; } ber_parse_header ( s , BER_TAG_INTEGER , & length ) ; in_uint8s ( s , length ) ; <vul-start> <vul-end> mcs_parse_domain_params ( s ) ; ber_parse_header ( s , BER_TAG_OCTET_STRING , & length ) ; sec_process_mcs_data ( s ) ; return s_check_end ( s ) ; }
|
<vul-sep> uint8 result ; <vul-start> uint32 length ; <vul-end> STREAM s ; <vul-sep> <vul-end> STREAM s ; <vul-start> struct stream packet ; <vul-end> RD_BOOL is_fastpath ; <vul-sep> return False ; <vul-start> packet = * s ; <vul-end> ber_parse_header ( s , MCS_CONNECT_RESPONSE , & length ) ; <vul-sep> in_uint8s ( s , length ) ; <vul-start> if ( ! s_check_rem ( s , length ) ) { rdp_protocol_error ( "mcs_recv_connect_response(), consume connect id from stream would overrun" , & packet ) ; } <vul-end> mcs_parse_domain_params ( s ) ; <vul-sep>
|
59
|
CWE-476 } YY_BREAK case 12 : YY_RULE_SETUP # line 227 "re_lexer.l" { return _DIGIT_ ; } YY_BREAK case 13 : YY_RULE_SETUP # line 232 "re_lexer.l" { return _NON_DIGIT_ ; } YY_BREAK case 14 : YY_RULE_SETUP # line 237 "re_lexer.l" { return _WORD_BOUNDARY_ ; } YY_BREAK case 15 : YY_RULE_SETUP # line 241 "re_lexer.l" { return _NON_WORD_BOUNDARY_ ; } YY_BREAK case 16 : YY_RULE_SETUP # line 246 "re_lexer.l" { yyerror ( yyscanner , lex_env , "backreferences are not allowed" ) ; yyterminate ( ) ; } YY_BREAK case 17 : YY_RULE_SETUP # line 253 "re_lexer.l" { uint8_t c ; if ( read_escaped_char ( yyscanner , & c ) ) { yylval -> integer = c ; return _CHAR_ ; } else { <vul-start> yyerror ( yyscanner , lex_env , "unexpected end of buffer" ) ; <vul-end> yyterminate ( ) ; } } YY_BREAK case 18 : YY_RULE_SETUP # line 270 "re_lexer.l" { int i ; yylval -> class_vector = ( uint8_t * ) yr_malloc ( 32 ) ; memcpy ( yylval -> class_vector , LEX_ENV -> class_vector , 32 ) ; if ( LEX_ENV -> negated_class ) { for ( i = 0 ; i < 32 ; i ++ ) yylval -> class_vector [ i ] = ~ yylval -> class_vector [ i ] ; } BEGIN ( INITIAL ) ; return _CLASS_ ; } YY_BREAK case 19 : YY_RULE_SETUP # line 291 "re_lexer.l" { uint16_t c ; uint8_t start = yytext [ 0 ] ; uint8_t end = yytext [ 2 ] ; if ( start == '\\\\' ) { start = escaped_char_value ( yytext ) ; if ( yytext [ 1 ] == 'x' ) end = yytext [ 5 ] ; else end = yytext [ 3 ] ; } if ( end == '\\\\' ) { if ( ! read_escaped_char ( yyscanner , & end ) ) { <vul-start> yyerror ( yyscanner , lex_env , "unexpected end of buffer" ) ; <vul-end> yyterminate ( ) ; } } if ( end < start ) { yyerror ( yyscanner , lex_env , "bad character range" ) ; yyterminate ( ) ; } for ( c = start ; c <= end ; c ++ ) { LEX_ENV -> class_vector [ c / 8 ] |= 1 << c % 8 ; } } YY_BREAK case 20 : YY_RULE_SETUP # line 333 "re_lexer.l" { int i ; for ( i = 0 ; i < 32 ; i ++ ) LEX_ENV -> class_vector [ i ] |= word_chars [ i ] ; } YY_BREAK case 21 : YY_RULE_SETUP # line 342 "re_lexer.l" { int i ; for ( i = 0 ; i < 32 ; i ++ ) LEX_ENV -> class_vector [ i ] |= ~ word_chars [ i ] ; } YY_BREAK case 22 : YY_RULE_SETUP # line 351 "re_lexer.l" { LEX_ENV -> class_vector [ ' ' / 8 ] |= 1 << ' ' % 8 ; LEX_ENV -> class_vector [ '\\t' / 8 ] |= 1 << '\\t' % 8 ; } YY_BREAK case 23 : YY_RULE_SETUP # line 358 "re_lexer.l" { int i ; for ( i = 0 ; i < 32 ; i ++ ) { if ( i == ' ' / 8 ) LEX_ENV -> class_vector [ i ] |= ~ ( 1 << ' ' % 8 ) ; else if ( i == '\\t' / 8 ) LEX_ENV -> class_vector [ i ] |= ~ ( 1 << '\\t' % 8 ) ; else LEX_ENV -> class_vector [ i ] = 0xFF ; } } YY_BREAK case 24 : YY_RULE_SETUP # line 374 "re_lexer.l" { char c ; for ( c = '0' ; c <= '9' ; c ++ ) LEX_ENV -> class_vector [ c / 8 ] |= 1 << c % 8 ; } YY_BREAK case 25 : YY_RULE_SETUP # line 383 "re_lexer.l" { int i ; for ( i = 0 ; i < 32 ; i ++ ) { if ( i == 6 ) continue ; if ( i == 7 ) LEX_ENV -> class_vector [ i ] |= 0xFC ; else LEX_ENV -> class_vector [ i ] = 0xFF ; } } YY_BREAK case 26 : YY_RULE_SETUP # line 403 "re_lexer.l" { uint8_t c ; if ( read_escaped_char ( yyscanner , & c ) ) { LEX_ENV -> class_vector [ c / 8 ] |= 1 << c % 8 ; } else { <vul-start> yyerror ( yyscanner , lex_env , "unexpected end of buffer" ) ; <vul-end> yyterminate ( ) ; } } YY_BREAK case 27 : YY_RULE_SETUP # line 419 "re_lexer.l" { if ( yytext [ 0 ] >= 32 && yytext [ 0 ] < 127 ) { LEX_ENV -> class_vector [ yytext [ 0 ] / 8 ] |= 1 << yytext [ 0 ] % 8 ; } else { yyerror ( yyscanner , lex_env , "non-ascii character" ) ; yyterminate ( ) ; } } YY_BREAK case YY_STATE_EOF ( char_class ) : # line 436 "re_lexer.l" { yyerror ( yyscanner , lex_env , "missing terminating ] for character class" ) ; yyterminate ( ) ; } YY_BREAK case 28 : YY_RULE_SETUP # line 445 "re_lexer.l" { if ( yytext [ 0 ] >= 32 && yytext [ 0 ] < 127 ) { return yytext [ 0 ] ; } else { yyerror ( yyscanner , lex_env , "non-ascii character" ) ; yyterminate ( ) ; } } YY_BREAK case YY_STATE_EOF ( INITIAL ) : # line 459 "re_lexer.l" { yyterminate ( ) ; } YY_BREAK case 29 : YY_RULE_SETUP # line 464 "re_lexer.l"
|
<vul-sep> { <vul-start> yyerror ( yyscanner , lex_env , "illegal escape sequence" ) ; <vul-end> yyterminate ( ) ; <vul-sep> { <vul-start> yyerror ( yyscanner , lex_env , "illegal escape sequence" ) ; <vul-end> yyterminate ( ) ; <vul-sep> { <vul-start> yyerror ( yyscanner , lex_env , "illegal escape sequence" ) ; <vul-end> yyterminate ( ) ; <vul-sep>
|
60
|
CWE-119 -void vp9_write_prob_diff_update ( vp9_writer * w , vp9_prob newp , vp9_prob oldp ) { +void vp9_write_prob_diff_update ( vpx_writer * w , vpx_prob newp , vpx_prob oldp ) { const int delp = remap_prob ( newp , oldp ) ; encode_term_subexp ( w , delp ) ; }
|
<vul-sep>
|
61
|
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 ( "Unable to get gateway certificate.\\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 <vul-start> 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 ) <vul-end> cert_valid = 1 ; # endif if ( cert_valid && SSL_get_verify_result ( tunnel -> ssl_handle ) == X509_V_OK ) { log_debug ( "Gateway certificate validation succeeded.\\n" ) ; ret = 0 ; goto free_cert ; } log_debug ( "Gateway certificate validation failed.\\n" ) ; if ( X509_digest ( cert , EVP_sha256 ( ) , digest , & len ) <= 0 || len != SHA256LEN ) { log_error ( "Could not compute certificate sha256 digest.\\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 ( "Gateway certificate digest found in white list.\\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 ( "Gateway certificate validation failed, and the certificate digest in not in the local whitelist. If you trust it, rerun with:\\n" ) ; log_error ( " --trusted-cert %s\\n" , digest_str ) ; log_error ( "or add this line to your config file:\\n" ) ; log_error ( " trusted-cert = %s\\n" , digest_str ) ; log_error ( "Gateway certificate:\\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 ( " sha256 digest:\\n" ) ; log_error ( " %s\\n" , digest_str ) ; free_cert : X509_free ( cert ) ; return ret ; }
|
<vul-sep> # else <vul-start> if ( validate_hostname ( tunnel -> config -> gateway_host , cert ) == MatchFound ) <vul-end> cert_valid = 1 ; <vul-sep>
|
62
|
CWE-362 static int snd_timer_user_release ( struct inode * inode , struct file * file ) { struct snd_timer_user * tu ; if ( file -> private_data ) { tu = file -> private_data ; file -> private_data = NULL ; <vul-start> <vul-end> if ( tu -> timeri ) snd_timer_close ( tu -> timeri ) ; <vul-start> <vul-end> kfree ( tu -> queue ) ; kfree ( tu -> tqueue ) ; kfree ( tu ) ; } return 0 ; }
|
<vul-sep> file -> private_data = NULL ; <vul-start> mutex_lock ( & tu -> ioctl_lock ) ; <vul-end> if ( tu -> timeri ) <vul-sep> snd_timer_close ( tu -> timeri ) ; <vul-start> mutex_unlock ( & tu -> ioctl_lock ) ; <vul-end> kfree ( tu -> queue ) ; <vul-sep>
|
63
|
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 ] ) ; <vul-start> l_current_data = p_j2k -> m_specific_param . m_encoder . m_header_tile_data ; <vul-end> 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 , "Not enough memory to write MCO marker\\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 ; } <vul-start> <vul-end> 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 ; }
|
<vul-sep> } <vul-start> l_current_data = p_j2k -> m_specific_param . m_encoder . m_header_tile_data ; <vul-end> opj_write_bytes ( l_current_data , J2K_MS_MCO , 2 ) ; <vul-sep>
|
64
|
CWE-190 -static int getnum ( lua_State * L , const char * * fmt , int df ) { +static int getnum ( const char * * fmt , int df ) { if ( ! isdigit ( * * fmt ) ) return df ; else { int a = 0 ; do { <vul-start> if ( a > ( INT_MAX / 10 ) || a * 10 > ( INT_MAX - ( * * fmt - '0' ) ) ) luaL_error ( L , "integral size overflow" ) ; <vul-end> a = a * 10 + * ( ( * fmt ) ++ ) - '0' ; } while ( isdigit ( * * fmt ) ) ; return a ; } }
|
<vul-sep>
|
65
|
CWE-119 void ssh_kex2 ( char * host , struct sockaddr * hostaddr , u_short port ) { char * myproposal [ PROPOSAL_MAX ] = { KEX_CLIENT } ; char * s ; struct kex * kex ; int r ; xxx_host = host ; xxx_hostaddr = hostaddr ; if ( ( s = kex_names_cat ( options . kex_algorithms , "ext-info-c" ) ) == NULL ) fatal ( "%s: kex_names_cat" , __func__ ) ; myproposal [ PROPOSAL_KEX_ALGS ] = compat_kex_proposal ( s ) ; myproposal [ PROPOSAL_ENC_ALGS_CTOS ] = compat_cipher_proposal ( options . ciphers ) ; myproposal [ PROPOSAL_ENC_ALGS_STOC ] = compat_cipher_proposal ( options . ciphers ) ; myproposal [ PROPOSAL_COMP_ALGS_CTOS ] = myproposal [ PROPOSAL_COMP_ALGS_STOC ] = options . compression ? <vul-start> "[email protected],zlib,none" : "none,[email protected],zlib" ; <vul-end> myproposal [ PROPOSAL_MAC_ALGS_CTOS ] = myproposal [ PROPOSAL_MAC_ALGS_STOC ] = options . macs ; if ( options . hostkeyalgorithms != NULL ) { if ( kex_assemble_names ( KEX_DEFAULT_PK_ALG , & options . hostkeyalgorithms ) != 0 ) fatal ( "%s: kex_assemble_namelist" , __func__ ) ; myproposal [ PROPOSAL_SERVER_HOST_KEY_ALGS ] = compat_pkalg_proposal ( options . hostkeyalgorithms ) ; } else { options . hostkeyalgorithms = xstrdup ( KEX_DEFAULT_PK_ALG ) ; myproposal [ PROPOSAL_SERVER_HOST_KEY_ALGS ] = compat_pkalg_proposal ( order_hostkeyalgs ( host , hostaddr , port ) ) ; } if ( options . rekey_limit || options . rekey_interval ) packet_set_rekey_limits ( ( u_int32_t ) options . rekey_limit , ( time_t ) options . rekey_interval ) ; 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_client ; kex -> kex [ KEX_DH_GRP14_SHA1 ] = kexdh_client ; kex -> kex [ KEX_DH_GRP14_SHA256 ] = kexdh_client ; kex -> kex [ KEX_DH_GRP16_SHA512 ] = kexdh_client ; kex -> kex [ KEX_DH_GRP18_SHA512 ] = kexdh_client ; kex -> kex [ KEX_DH_GEX_SHA1 ] = kexgex_client ; kex -> kex [ KEX_DH_GEX_SHA256 ] = kexgex_client ; kex -> kex [ KEX_ECDH_SHA2 ] = kexecdh_client ; # endif kex -> kex [ KEX_C25519_SHA256 ] = kexc25519_client ; kex -> client_version_string = client_version_string ; kex -> server_version_string = server_version_string ; kex -> verify_host_key = & verify_host_key_callback ; dispatch_run ( DISPATCH_BLOCK , & kex -> done , active_state ) ; myproposal [ PROPOSAL_KEX_ALGS ] = compat_kex_proposal ( options . kex_algorithms ) ; if ( ( r = kex_prop2buf ( kex -> my , myproposal ) ) != 0 ) fatal ( "kex_prop2buf: %s" , ssh_err ( r ) ) ; 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 }
|
<vul-sep> myproposal [ PROPOSAL_COMP_ALGS_STOC ] = options . compression ? <vul-start> "[email protected],none" : "none,[email protected]" ; <vul-end> myproposal [ PROPOSAL_MAC_ALGS_CTOS ] = <vul-sep>
|
66
|
CWE-119 static vpx_codec_err_t vp8e_use_reference ( vpx_codec_alg_priv_t * ctx , <vul-start> int ctr_id , <vul-end> va_list args ) { int reference_flag = va_arg ( args , int ) ; vp8_use_as_reference ( ctx -> cpi , reference_flag ) ; return VPX_CODEC_OK ; }
|
<vul-sep>
|
67
|
CWE-787 opj_image_t * pgxtoimage ( const char * filename , opj_cparameters_t * parameters ) { FILE * f = NULL ; int w , h , prec ; int i , numcomps , max ; OPJ_COLOR_SPACE color_space ; opj_image_cmptparm_t cmptparm ; opj_image_t * image = NULL ; int adjustS , ushift , dshift , force8 ; char endian1 , endian2 , sign ; char signtmp [ 32 ] ; char temp [ 32 ] ; int bigendian ; opj_image_comp_t * comp = NULL ; numcomps = 1 ; color_space = OPJ_CLRSPC_GRAY ; memset ( & cmptparm , 0 , sizeof ( opj_image_cmptparm_t ) ) ; max = 0 ; f = fopen ( filename , "rb" ) ; if ( ! f ) { fprintf ( stderr , "Failed to open %s for reading !\\n" , filename ) ; return NULL ; } fseek ( f , 0 , SEEK_SET ) ; <vul-start> if ( fscanf ( f , "PG%[ \\t]%c%c%[ \\t+-]%d%[ \\t]%d%[ \\t]%d" , temp , & endian1 , <vul-end> & endian2 , signtmp , & prec , temp , & w , temp , & h ) != 9 ) { fclose ( f ) ; fprintf ( stderr , "ERROR: Failed to read the right number of element from the fscanf() function!\\n" ) ; return NULL ; } i = 0 ; sign = '+' ; while ( signtmp [ i ] != '\\0' ) { if ( signtmp [ i ] == '-' ) { sign = '-' ; } i ++ ; } fgetc ( f ) ; if ( endian1 == 'M' && endian2 == 'L' ) { bigendian = 1 ; } else if ( endian2 == 'M' && endian1 == 'L' ) { bigendian = 0 ; } else { fclose ( f ) ; fprintf ( stderr , "Bad pgx header, please check input file\\n" ) ; return NULL ; } cmptparm . x0 = ( OPJ_UINT32 ) parameters -> image_offset_x0 ; cmptparm . y0 = ( OPJ_UINT32 ) parameters -> image_offset_y0 ; cmptparm . w = ! cmptparm . x0 ? ( OPJ_UINT32 ) ( ( w - 1 ) * parameters -> subsampling_dx + 1 ) : cmptparm . x0 + ( OPJ_UINT32 ) ( w - 1 ) * ( OPJ_UINT32 ) parameters -> subsampling_dx + 1 ; cmptparm . h = ! cmptparm . y0 ? ( OPJ_UINT32 ) ( ( h - 1 ) * parameters -> subsampling_dy + 1 ) : cmptparm . y0 + ( OPJ_UINT32 ) ( h - 1 ) * ( OPJ_UINT32 ) parameters -> subsampling_dy + 1 ; if ( sign == '-' ) { cmptparm . sgnd = 1 ; } else { cmptparm . sgnd = 0 ; } if ( prec < 8 ) { force8 = 1 ; ushift = 8 - prec ; dshift = prec - ushift ; if ( cmptparm . sgnd ) { adjustS = ( 1 << ( prec - 1 ) ) ; } else { adjustS = 0 ; } cmptparm . sgnd = 0 ; prec = 8 ; } else { ushift = dshift = force8 = adjustS = 0 ;
|
<vul-sep> fseek ( f , 0 , SEEK_SET ) ; <vul-start> if ( fscanf ( f , "PG%31[ \\t]%c%c%31[ \\t+-]%d%31[ \\t]%d%31[ \\t]%d" , temp , & endian1 , <vul-end> & endian2 , signtmp , & prec , temp , & w , temp , & h ) != 9 ) { <vul-sep>
|
68
|
NVD-CWE-noinfo static void SaltTextAway ( XtermWidget xw , int which , CELL * cellc , CELL * cell ) { TScreen * screen = TScreenOf ( xw ) ; SelectedCells * scp ; int i ; int eol ; int need = 0 ; <vul-start> <vul-end> Char * line ; Char * lp ; CELL first = * cellc ; CELL last = * cell ; if ( which < 0 || which >= MAX_SELECTIONS ) { TRACE ( ( "SaltTextAway - which selection?\\n" ) ) ; return ; } scp = & ( screen -> selected_cells [ which ] ) ; TRACE ( ( "SaltTextAway which=%d, first=%d,%d, last=%d,%d\\n" , which , first . row , first . col , last . row , last . col ) ) ; if ( isSameRow ( & first , & last ) && first . col > last . col ) { int tmp ; EXCHANGE ( first . col , last . col , tmp ) ; } -- last . col ; if ( isSameRow ( & last , & first ) ) { need = Length ( screen , first . row , first . col , last . col ) ; } else { need += Length ( screen , first . row , first . col , screen -> max_col ) + 1 ; for ( i = first . row + 1 ; i < last . row ; i ++ ) need += Length ( screen , i , 0 , screen -> max_col ) + 1 ; if ( last . col >= 0 ) need += Length ( screen , last . row , 0 , last . col ) ; } if_OPT_WIDE_CHARS ( screen , { <vul-start> need *= 4 ; <vul-end> } ) ; if ( need < 0 ) return ; if ( scp -> data_limit <= ( unsigned ) need ) { if ( ( line = ( Char * ) malloc ( ( size_t ) need + 1 ) ) == 0 ) SysError ( ERROR_BMALLOC2 ) ; free ( scp -> data_buffer ) ; scp -> data_buffer = line ; scp -> data_limit = ( size_t ) ( need + 1 ) ; } else { line = scp -> data_buffer ; } if ( line == 0 ) return ; line [ need ] = '\\0' ; lp = line ; if ( isSameRow ( & last , & first ) ) { lp = SaveText ( screen , last . row , first . col , last . col , lp , & eol ) ; } else { lp = SaveText ( screen , first . row , first . col , screen -> max_col , lp , & eol ) ; if ( eol ) * lp ++ = '\\n' ; for ( i = first . row + 1 ; i < last . row ; i ++ ) { lp = SaveText ( screen , i , 0 , screen -> max_col , lp , & eol ) ; if ( eol ) * lp ++ = '\\n' ; } if ( last . col >= 0 ) lp = SaveText ( screen , last . row , 0 , last . col , lp , & eol ) ; } * lp = '\\0' ; <vul-start> TRACE ( ( "Salted TEXT:%u:%s\\n" , ( unsigned ) ( lp - line ) , visibleChars ( line , ( unsigned ) ( lp - line ) ) ) ) ; scp -> data_length = ( size_t ) ( lp - line ) ; <vul-end> }
|
<vul-sep> int need = 0 ; <vul-start> size_t have = 0 ; <vul-end> Char * line ; <vul-sep> if_OPT_WIDE_CHARS ( screen , { <vul-start> if ( need > 0 ) { if ( screen -> max_combining > 0 ) need += screen -> max_combining ; need *= 6 ; } <vul-end> } ) ; <vul-sep> * lp = '\\0' ; <vul-start> have = ( size_t ) ( lp - line ) ; if ( ( have * 2 ) < ( size_t ) need ) { scp -> data_limit = have + 1 ; line = realloc ( line , scp -> data_limit ) ; } TRACE ( ( "Salted TEXT:%u:%s\\n" , ( unsigned ) have , visibleChars ( line , ( unsigned ) have ) ) ) ; scp -> data_length = have ; <vul-end> } <vul-sep>
|
69
|
CWE-59 static gchar * read_file ( gchar * filepath ) { FILE * f ; size_t length ; gchar * ret = NULL ; <vul-start> f = fopen ( filepath , "rb" ) ; <vul-end> if ( f ) { fseek ( f , 0 , SEEK_END ) ; length = ( size_t ) ftell ( f ) ; fseek ( f , 0 , SEEK_SET ) ; ret = MALLOC ( length + 1 ) ; if ( ret ) { if ( fread ( ret , length , 1 , f ) != 1 ) { log_message ( LOG_INFO , "Failed to read all of %s" , filepath ) ; } ret [ length ] = '\\0' ; } else log_message ( LOG_INFO , "Unable to read Dbus file %s" , filepath ) ; fclose ( f ) ; } return ret ; }
|
<vul-sep> gchar * ret = NULL ; <vul-start> f = fopen ( filepath , "r" ) ; <vul-end> if ( f ) { <vul-sep>
|
70
|
CWE-310 int DSA_verify ( int type , const unsigned char * dgst , int dgst_len , const unsigned char * sigbuf , int siglen , DSA * dsa ) { DSA_SIG * s ; <vul-start> <vul-end> int ret = - 1 ; s = DSA_SIG_new ( ) ; if ( s == NULL ) return ( ret ) ; <vul-start> if ( d2i_DSA_SIG ( & s , & sigbuf , siglen ) == NULL ) goto err ; <vul-end> ret = DSA_do_verify ( dgst , dgst_len , s , dsa ) ; err : <vul-start> <vul-end> DSA_SIG_free ( s ) ; return ( ret ) ; }
|
<vul-sep> DSA_SIG * s ; <vul-start> const unsigned char * p = sigbuf ; unsigned char * der = NULL ; int derlen = - 1 ; <vul-end> int ret = - 1 ; <vul-sep> if ( s == NULL ) return ( ret ) ; <vul-start> if ( d2i_DSA_SIG ( & s , & p , siglen ) == NULL ) goto err ; derlen = i2d_DSA_SIG ( s , & der ) ; if ( derlen != siglen || memcmp ( sigbuf , der , derlen ) ) goto err ; <vul-end> ret = DSA_do_verify ( dgst , dgst_len , s , dsa ) ; <vul-sep> err : <vul-start> if ( derlen > 0 ) { OPENSSL_cleanse ( der , derlen ) ; OPENSSL_free ( der ) ; } <vul-end> DSA_SIG_free ( s ) ; <vul-sep>
|
71
|
CWE-295 -int bind_ports ( void ) { +NOEXPORT 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 , "Binding service [%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 , "Binding service [%s] failed" , opt -> servname ) ; return 1 ; } ++ listening_section ; } else if ( opt -> exec_name && opt -> connect_addr . names ) { s_log ( LOG_DEBUG , "Skipped exec+connect service [%s]" , opt -> servname ) ; # ifndef OPENSSL_NO_TLSEXT } else if ( ! opt -> option . client && opt -> sni ) { s_log ( LOG_DEBUG , "Skipped SNI slave service [%s]" , opt -> servname ) ; # endif } else { s_log ( LOG_ERR , "Invalid service [%s]" , opt -> servname ) ; return 1 ; } } if ( listening_section < systemd_fds ) { s_log ( LOG_ERR , "Too many listening file descriptors received from systemd, got %d" , systemd_fds ) ; return 1 ; } return 0 ; }
|
<vul-sep>
|
72
|
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 ) ; <vul-start> if ( ret == - EEXIST ) <vul-end> 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 ; }
|
<vul-sep> btrfs_inode_type ( inode ) , index ) ; <vul-start> if ( ret == - EEXIST || ret == - EOVERFLOW ) <vul-end> goto fail_dir_item ; <vul-sep>
|
73
|
CWE-125 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 ) { <vul-start> <vul-end> op -> regs [ reg_index ] = reg ; op -> scale [ reg_index ] = temp ; <vul-start> <vul-end> ++ reg_index ; } else { op -> offset += temp ; <vul-start> <vul-end> op -> regs [ reg_index ] = X86R_UNDEFINED ; <vul-start> <vul-end> } 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 , ']' ) ;
|
<vul-sep> if ( reg != X86R_UNDEFINED ) { <vul-start> if ( reg_index < 2 ) { <vul-end> op -> regs [ reg_index ] = reg ; <vul-sep> op -> scale [ reg_index ] = temp ; <vul-start> } <vul-end> ++ reg_index ; <vul-sep> op -> offset += temp ; <vul-start> if ( reg_index < 2 ) { <vul-end> op -> regs [ reg_index ] = X86R_UNDEFINED ; <vul-sep> <vul-end> op -> regs [ reg_index ] = X86R_UNDEFINED ; <vul-start> } <vul-end> } <vul-sep>
|
74
|
CWE-362 static int <vul-start> mptctl_readtest ( unsigned long arg ) <vul-end> { struct mpt_ioctl_test __user * uarg = ( void __user * ) arg ; struct mpt_ioctl_test karg ; <vul-start> MPT_ADAPTER * ioc ; int iocnum ; <vul-end> if ( copy_from_user ( & karg , uarg , sizeof ( struct mpt_ioctl_test ) ) ) { printk ( KERN_ERR MYNAM "%s@%d::mptctl_readtest - " "Unable to read in mpt_ioctl_test struct @ %p\\n" , __FILE__ , __LINE__ , uarg ) ; return - EFAULT ; <vul-start> } if ( ( ( iocnum = mpt_verify_adapter ( karg . hdr . iocnum , & ioc ) ) < 0 ) || ( ioc == NULL ) ) { printk ( KERN_DEBUG MYNAM "%s::mptctl_readtest() @%d - ioc%d not found!\\n" , __FILE__ , __LINE__ , iocnum ) ; return - ENODEV ; <vul-end> } dctlprintk ( ioc , printk ( MYIOC_s_DEBUG_FMT "mptctl_readtest called.\\n" , ioc -> name ) ) ; # ifdef MFCNT karg . chip_type = ioc -> mfcnt ; # else karg . chip_type = ioc -> pcidev -> device ; # endif strncpy ( karg . name , ioc -> name , MPT_MAX_NAME ) ; karg . name [ MPT_MAX_NAME - 1 ] = '\\0' ; strncpy ( karg . product , ioc -> prod_name , MPT_PRODUCT_LENGTH ) ; karg . product [ MPT_PRODUCT_LENGTH - 1 ] = '\\0' ; if ( copy_to_user ( ( char __user * ) arg , & karg , sizeof ( struct mpt_ioctl_test ) ) ) { printk ( MYIOC_s_ERR_FMT "%s@%d::mptctl_readtest - " "Unable to write out mpt_ioctl_test struct @ %p\\n" , ioc -> name , __FILE__ , __LINE__ , uarg ) ; return - EFAULT ; } return 0 ; }
|
<vul-sep> static int <vul-start> mptctl_readtest ( MPT_ADAPTER * ioc , unsigned long arg ) <vul-end> { <vul-sep>
|
75
|
CWE-119 void WT_NoiseGenerator ( S_WT_VOICE * pWTVoice , S_WT_INT_FRAME * pWTIntFrame ) { EAS_PCM * pOutputBuffer ; EAS_I32 phaseInc ; EAS_I32 tmp0 ; EAS_I32 tmp1 ; EAS_I32 nInterpolatedSample ; EAS_I32 numSamples ; numSamples = pWTIntFrame -> numSamples ; <vul-start> <vul-end> pOutputBuffer = pWTIntFrame -> pAudioBuffer ; phaseInc = pWTIntFrame -> frame . phaseIncrement ; tmp0 = ( EAS_I32 ) ( pWTVoice -> phaseAccum ) >> 18 ; tmp1 = ( EAS_I32 ) ( pWTVoice -> loopEnd ) >> 18 ; while ( numSamples -- ) { nInterpolatedSample = MULT_AUDIO_COEF ( tmp0 , ( PHASE_ONE - pWTVoice -> phaseFrac ) ) ; nInterpolatedSample += MULT_AUDIO_COEF ( tmp1 , pWTVoice -> phaseFrac ) ; * pOutputBuffer ++ = ( EAS_PCM ) nInterpolatedSample ; pWTVoice -> phaseFrac += ( EAS_U32 ) phaseInc ; if ( GET_PHASE_INT_PART ( pWTVoice -> phaseFrac ) ) { tmp0 = tmp1 ; pWTVoice -> phaseAccum = pWTVoice -> loopEnd ; pWTVoice -> loopEnd = ( 5 * pWTVoice -> loopEnd + 1 ) ; tmp1 = ( EAS_I32 ) ( pWTVoice -> loopEnd ) >> 18 ; pWTVoice -> phaseFrac = GET_PHASE_FRAC_PART ( pWTVoice -> phaseFrac ) ; } } }
|
<vul-sep> numSamples = pWTIntFrame -> numSamples ; <vul-start> if ( numSamples <= 0 ) { ALOGE ( "b/26366256" ) ; return ; } <vul-end> pOutputBuffer = pWTIntFrame -> pAudioBuffer ; <vul-sep>
|
76
|
CWE-617 void pci_lintr_assert ( struct pci_vdev * dev ) { <vul-start> assert ( dev -> lintr . pin > 0 ) ; <vul-end> pthread_mutex_lock ( & dev -> lintr . lock ) ; if ( dev -> lintr . state == IDLE ) { if ( pci_lintr_permitted ( dev ) ) { dev -> lintr . state = ASSERTED ; pci_irq_assert ( dev ) ; } else dev -> lintr . state = PENDING ; } pthread_mutex_unlock ( & dev -> lintr . lock ) ; }
|
<vul-sep> { <vul-start> if ( dev -> lintr . pin <= 0 ) { pr_warn ( "%s: Invalid intr pin on dev [%s]\\n" , __func__ , dev -> name ) ; return ; } <vul-end> pthread_mutex_lock ( & dev -> lintr . lock ) ; <vul-sep>
|
77
|
CWE-787 MYSOFA_EXPORT struct MYSOFA_HRTF * mysofa_load ( const char * filename , int * err ) { struct READER reader ; struct MYSOFA_HRTF * hrtf = NULL ; if ( filename == NULL ) filename = CMAKE_INSTALL_PREFIX "/share/libmysofa/default.sofa" ; if ( strcmp ( filename , "-" ) ) reader . fhd = fopen ( filename , "rb" ) ; else reader . fhd = stdin ; if ( ! reader . fhd ) { log ( "cannot open file %s\\n" , filename ) ; * err = errno ; return NULL ; } reader . gcol = NULL ; reader . all = NULL ; <vul-start> <vul-end> * err = superblockRead ( & reader , & reader . superblock ) ; if ( ! * err ) { hrtf = getHrtf ( & reader , err ) ; } superblockFree ( & reader , & reader . superblock ) ; gcolFree ( reader . gcol ) ; if ( strcmp ( filename , "-" ) ) fclose ( reader . fhd ) ; return hrtf ; }
|
<vul-sep> reader . all = NULL ; <vul-start> reader . recursive_counter = 0 ; <vul-end> * err = superblockRead ( & reader , & reader . superblock ) ; <vul-sep>
|
78
|
CWE-20 static int proc_sys_readdir ( struct file * file , struct dir_context * ctx ) { struct ctl_table_header * head = grab_header ( file_inode ( file ) ) ; struct ctl_table_header * h = NULL ; struct ctl_table * entry ; struct ctl_dir * ctl_dir ; unsigned long pos ; if ( IS_ERR ( head ) ) return PTR_ERR ( head ) ; ctl_dir = container_of ( head , struct ctl_dir , header ) ; if ( ! dir_emit_dots ( file , ctx ) ) <vul-start> return 0 ; <vul-end> pos = 2 ; for ( first_entry ( ctl_dir , & h , & entry ) ; h ; next_entry ( & h , & entry ) ) { if ( ! scan ( h , entry , & pos , file , ctx ) ) { sysctl_head_finish ( h ) ; break ; } } <vul-start> <vul-end> sysctl_head_finish ( head ) ; return 0 ; }
|
<vul-sep> if ( ! dir_emit_dots ( file , ctx ) ) <vul-start> goto out ; <vul-end> pos = 2 ; <vul-sep> } <vul-start> out : <vul-end> sysctl_head_finish ( head ) ; <vul-sep>
|
79
|
CWE-20 static MagickBooleanType ConcatenateImages ( int argc , char * * argv , ExceptionInfo * exception ) { FILE * input , * output ; <vul-start> <vul-end> int c ; register ssize_t i ; if ( ExpandFilenames ( & argc , & argv ) == MagickFalse ) ThrowFileException ( exception , ResourceLimitError , "MemoryAllocationFailed" , GetExceptionMessage ( errno ) ) ; output = fopen_utf8 ( argv [ argc - 1 ] , "wb" ) ; <vul-start> if ( output == ( FILE * ) NULL ) { ThrowFileException ( exception , FileOpenError , "UnableToOpenFile" , argv [ argc - 1 ] ) ; <vul-end> return ( MagickFalse ) ; } <vul-start> for ( i = 2 ; i < ( ssize_t ) ( argc - 1 ) ; i ++ ) { # if 0 fprintf ( stderr , "DEBUG: Concatenate Image: \\"%s\\"\\n" , argv [ i ] ) ; # endif <vul-end> input = fopen_utf8 ( argv [ i ] , "rb" ) ; <vul-start> if ( input == ( FILE * ) NULL ) { <vul-end> ThrowFileException ( exception , FileOpenError , "UnableToOpenFile" , argv [ i ] ) ; continue ; } for ( c = fgetc ( input ) ; c != EOF ; c = fgetc ( input ) ) <vul-start> ( void ) fputc ( ( char ) c , output ) ; <vul-end> ( void ) fclose ( input ) ; ( void ) remove_utf8 ( argv [ i ] ) ; } ( void ) fclose ( output ) ; <vul-start> return ( MagickTrue ) ; <vul-end> }
|
<vul-sep> * output ; <vul-start> MagickBooleanType status ; <vul-end> int <vul-sep> output = fopen_utf8 ( argv [ argc - 1 ] , "wb" ) ; <vul-start> if ( output == ( FILE * ) NULL ) { ThrowFileException ( exception , FileOpenError , "UnableToOpenFile" , argv [ argc - 1 ] ) ; <vul-end> return ( MagickFalse ) ; <vul-sep> } <vul-start> status = MagickTrue ; for ( i = 2 ; i < ( ssize_t ) ( argc - 1 ) ; i ++ ) { <vul-end> input = fopen_utf8 ( argv [ i ] , "rb" ) ; <vul-sep> <vul-end> input = fopen_utf8 ( argv [ i ] , "rb" ) ; <vul-start> if ( input == ( FILE * ) NULL ) { <vul-end> ThrowFileException ( exception , FileOpenError , "UnableToOpenFile" , argv [ i ] ) ; <vul-sep> for ( c = fgetc ( input ) ; c != EOF ; c = fgetc ( input ) ) <vul-start> if ( fputc ( ( char ) c , output ) != c ) status = MagickFalse ; <vul-end> ( void ) fclose ( input ) ; <vul-sep> ( void ) fclose ( output ) ; <vul-start> return ( status ) ; <vul-end> } <vul-sep>
|
80
|
CWE-416 void usb_sg_cancel ( struct usb_sg_request * io ) { unsigned long flags ; int i , retval ; spin_lock_irqsave ( & io -> lock , flags ) ; <vul-start> if ( io -> status ) { <vul-end> spin_unlock_irqrestore ( & io -> lock , flags ) ; return ; } io -> status = - ECONNRESET ; <vul-start> <vul-end> spin_unlock_irqrestore ( & io -> lock , flags ) ; for ( i = io -> entries - 1 ; i >= 0 ; -- i ) { usb_block_urb ( io -> urbs [ i ] ) ; retval = usb_unlink_urb ( io -> urbs [ i ] ) ; if ( retval != - EINPROGRESS && retval != - ENODEV && retval != - EBUSY && retval != - EIDRM ) dev_warn ( & io -> dev -> dev , "%s, unlink --> %d\\n" , __func__ , retval ) ; } <vul-start> <vul-end> }
|
<vul-sep> spin_lock_irqsave ( & io -> lock , flags ) ; <vul-start> if ( io -> status || io -> count == 0 ) { <vul-end> spin_unlock_irqrestore ( & io -> lock , flags ) ; <vul-sep> io -> status = - ECONNRESET ; <vul-start> io -> count ++ ; <vul-end> spin_unlock_irqrestore ( & io -> lock , flags ) ; <vul-sep> } <vul-start> spin_lock_irqsave ( & io -> lock , flags ) ; io -> count -- ; if ( ! io -> count ) complete ( & io -> complete ) ; spin_unlock_irqrestore ( & io -> lock , flags ) ; <vul-end> } <vul-sep>
|
81
|
CWE-125 const uint8_t * dst , * snpa , * neta ; u_int dstl , snpal , netal ; ND_TCHECK ( * pptr ) ; if ( li < 1 ) { ND_PRINT ( ( ndo , ", bad redirect/li" ) ) ; return ; } dstl = * pptr ; pptr ++ ; li -- ; ND_TCHECK2 ( * pptr , dstl ) ; if ( li < dstl ) { ND_PRINT ( ( ndo , ", bad redirect/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 , ", bad redirect/li" ) ) ; return ; } snpal = * pptr ; pptr ++ ; li -- ; ND_TCHECK2 ( * pptr , snpal ) ; if ( li < snpal ) { ND_PRINT ( ( ndo , ", bad redirect/li" ) ) ; return ; } snpa = pptr ; pptr += snpal ; li -= snpal ; ND_TCHECK ( * pptr ) ; if ( li < 1 ) { ND_PRINT ( ( ndo , ", bad redirect/li" ) ) ; return ; } netal = * pptr ; pptr ++ ; ND_TCHECK2 ( * pptr , netal ) ; if ( li < netal ) { ND_PRINT ( ( ndo , ", bad redirect/li" ) ) ; return ; } neta = pptr ; pptr += netal ; li -= netal ; <vul-start> if ( netal == 0 ) ND_PRINT ( ( ndo , "\\n\\t %s" , etheraddr_string ( ndo , snpa ) ) ) ; <vul-end> else <vul-start> ND_PRINT ( ( ndo , "\\n\\t %s" , isonsap_string ( ndo , neta , netal ) ) ) ; <vul-end> break ; } case ESIS_PDU_ESH : ND_TCHECK ( * pptr ) ; if ( li < 1 ) { ND_PRINT ( ( ndo , ", bad esh/li" ) ) ; return ; } source_address_number = * pptr ; pptr ++ ; li -- ; ND_PRINT ( ( ndo , "\\n\\t Number of Source Addresses: %u" , source_address_number ) ) ; while ( source_address_number > 0 ) { ND_TCHECK ( * pptr ) ; if ( li < 1 ) { ND_PRINT ( ( ndo , ", bad esh/li" ) ) ; return ; } source_address_length = * pptr ; pptr ++ ; li -- ; ND_TCHECK2 ( * pptr , source_address_length ) ; if ( li < source_address_length ) { ND_PRINT ( ( ndo , ", bad esh/li" ) ) ; return ; } ND_PRINT ( ( ndo , "\\n\\t NET (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 , ", bad ish/li" ) ) ; return ; } source_address_length = * pptr ; pptr ++ ; li -- ; ND_TCHECK2 ( * pptr , source_address_length ) ; if ( li < source_address_length ) { ND_PRINT ( ( ndo , ", bad ish/li" ) ) ; return ; } ND_PRINT ( ( ndo , "\\n\\t NET (length: %u): %s" , source_address_length , isonsap_string ( ndo , pptr , source_address_length ) ) ) ; pptr += source_address_length ;
|
<vul-sep> li -= netal ; <vul-start> if ( snpal == 6 ) ND_PRINT ( ( ndo , "\\n\\t SNPA (length: %u): %s" , snpal , etheraddr_string ( ndo , snpa ) ) ) ; <vul-end> else <vul-sep> <vul-end> else <vul-start> ND_PRINT ( ( ndo , "\\n\\t SNPA (length: %u): %s" , snpal , linkaddr_string ( ndo , snpa , LINKADDR_OTHER , snpal ) ) ) ; if ( netal != 0 ) ND_PRINT ( ( ndo , "\\n\\t NET (length: %u) %s" , netal , isonsap_string ( ndo , neta , netal ) ) ) ; <vul-end> break ; <vul-sep>
|
82
|
CWE-476 static int resize ( int new_rows , int new_cols , VTermPos * delta , void * user ) { VTermScreen * screen = user ; int is_altscreen = ( screen -> buffers [ 1 ] && screen -> buffer == screen -> buffers [ 1 ] ) ; int old_rows = screen -> rows ; int old_cols = screen -> cols ; int first_blank_row ; if ( ! is_altscreen && new_rows < old_rows ) { VTermPos pos = { 0 , 0 } ; VTermPos cursor = screen -> state -> pos ; for ( pos . row = old_rows - 1 ; pos . row >= new_rows ; pos . row -- ) if ( ! vterm_screen_is_eol ( screen , pos ) || cursor . row == pos . row ) break ; first_blank_row = pos . row + 1 ; if ( first_blank_row > new_rows ) { VTermRect rect = { 0 , 0 , 0 , 0 } ; rect . end_row = old_rows ; rect . end_col = old_cols ; scrollrect ( rect , first_blank_row - new_rows , 0 , user ) ; vterm_screen_flush_damage ( screen ) ; delta -> row -= first_blank_row - new_rows ; } } screen -> buffers [ 0 ] = realloc_buffer ( screen , screen -> buffers [ 0 ] , new_rows , new_cols ) ; if ( screen -> buffers [ 1 ] ) screen -> buffers [ 1 ] = realloc_buffer ( screen , screen -> buffers [ 1 ] , new_rows , new_cols ) ; screen -> buffer = is_altscreen ? screen -> buffers [ 1 ] : screen -> buffers [ 0 ] ; screen -> rows = new_rows ; screen -> cols = new_cols ; <vul-start> if ( screen -> sb_buffer ) <vul-end> vterm_allocator_free ( screen -> vt , screen -> sb_buffer ) ; screen -> sb_buffer = vterm_allocator_malloc ( screen -> vt , sizeof ( VTermScreenCell ) * new_cols ) ; if ( new_cols > old_cols ) { VTermRect rect ; rect . start_row = 0 ; rect . end_row = old_rows ; rect . start_col = old_cols ; rect . end_col = new_cols ; damagerect ( screen , rect ) ; } if ( new_rows > old_rows ) { if ( ! is_altscreen && screen -> callbacks && screen -> callbacks -> sb_popline ) { int rows = new_rows - old_rows ; while ( rows ) { VTermRect rect = { 0 , 0 , 0 , 0 } ; VTermPos pos = { 0 , 0 } ; if ( ! ( screen -> callbacks -> sb_popline ( screen -> cols , screen -> sb_buffer , screen -> cbdata ) ) ) break ; rect . end_row = screen -> rows ; rect . end_col = screen -> cols ; scrollrect ( rect , - 1 , 0 , user ) ; for ( pos . col = 0 ; pos . col < screen -> cols ; pos . col += screen -> sb_buffer [ pos . col ] . width ) vterm_screen_set_cell ( screen , pos , screen -> sb_buffer + pos . col ) ; rect . end_row = 1 ; damagerect ( screen , rect ) ; vterm_screen_flush_damage ( screen ) ; rows -- ; delta -> row ++ ; } } { VTermRect rect ; rect . start_row = old_rows ; rect . end_row = new_rows ; rect . start_col = 0 ; rect . end_col = new_cols ; damagerect ( screen , rect ) ; } } if ( screen -> callbacks && screen -> callbacks -> resize ) return ( * screen -> callbacks -> resize ) ( new_rows , new_cols , screen -> cbdata ) ; return 1 ; }
|
<vul-sep>
|
83
|
CWE-119 int vp9_get_qindex ( const struct segmentation * seg , int segment_id , int base_qindex ) { <vul-start> if ( vp9_segfeature_active ( seg , segment_id , SEG_LVL_ALT_Q ) ) { const int data = vp9_get_segdata ( seg , segment_id , SEG_LVL_ALT_Q ) ; <vul-end> const int seg_qindex = seg -> abs_delta == SEGMENT_ABSDATA ? data : base_qindex + data ; return clamp ( seg_qindex , 0 , MAXQ ) ; } else { return base_qindex ; } }
|
<vul-sep> int base_qindex ) { <vul-start> if ( segfeature_active ( seg , segment_id , SEG_LVL_ALT_Q ) ) { const int data = get_segdata ( seg , segment_id , SEG_LVL_ALT_Q ) ; <vul-end> const int seg_qindex = seg -> abs_delta == SEGMENT_ABSDATA ? <vul-sep>
|
84
|
CWE-20 if ( settings . verbose > 1 ) { fprintf ( stderr , "%d: Realign input buffer\\n" , c -> sfd ) ; } } # endif protocol_binary_request_header * req ; req = ( protocol_binary_request_header * ) c -> rcurr ; if ( settings . verbose > 1 ) { int ii ; fprintf ( stderr , "<%d Read binary protocol data:" , 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 , "Invalid magic: %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_ERROR out of memory" ) ; 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 ) ; <vul-start> if ( ! el ) <vul-end> return 0 ; <vul-start> <vul-end> 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 ; }
|
<vul-sep> el = memchr ( c -> rcurr , '\\n' , c -> rbytes ) ; <vul-start> 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 ; } } <vul-end> return 0 ; <vul-sep> <vul-end> return 0 ; <vul-start> } <vul-end> cont = el + 1 ; <vul-sep>
|
85
|
CWE-125 static void <vul-start> l2tp_msgtype_print ( netdissect_options * ndo , const u_char * dat ) <vul-end> { const uint16_t * ptr = ( const uint16_t * ) dat ; <vul-start> <vul-end> ND_PRINT ( ( ndo , "%s" , tok2str ( l2tp_msgtype2str , "MSGTYPE-#%u" , EXTRACT_16BITS ( ptr ) ) ) ) ; }
|
<vul-sep> static void <vul-start> l2tp_msgtype_print ( netdissect_options * ndo , const u_char * dat , u_int length ) <vul-end> { <vul-sep> const uint16_t * ptr = ( const uint16_t * ) dat ; <vul-start> if ( length < 2 ) { ND_PRINT ( ( ndo , "AVP too short" ) ) ; return ; } <vul-end> ND_PRINT ( ( ndo , "%s" , tok2str ( l2tp_msgtype2str , "MSGTYPE-#%u" , <vul-sep>
|
86
|
CWE-119 static int key_notify_sa_flush ( const struct km_event * c ) { struct sk_buff * skb ; struct sadb_msg * hdr ; skb = alloc_skb ( sizeof ( struct sadb_msg ) + 16 , GFP_ATOMIC ) ; if ( ! skb ) return - ENOBUFS ; hdr = ( struct sadb_msg * ) skb_put ( skb , sizeof ( struct sadb_msg ) ) ; hdr -> sadb_msg_satype = pfkey_proto2satype ( c -> data . proto ) ; hdr -> sadb_msg_type = SADB_FLUSH ; 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 ) ) ; <vul-start> <vul-end> pfkey_broadcast ( skb , GFP_ATOMIC , BROADCAST_ALL , NULL , c -> net ) ; return 0 ; }
|
<vul-sep> hdr -> sadb_msg_len = ( sizeof ( struct sadb_msg ) / sizeof ( uint64_t ) ) ; <vul-start> hdr -> sadb_msg_reserved = 0 ; <vul-end> pfkey_broadcast ( skb , GFP_ATOMIC , BROADCAST_ALL , NULL , c -> net ) ; <vul-sep>
|
87
|
CWE-119 -static int tile_worker_hook ( void * arg1 , void * arg2 ) { <vul-start> TileWorkerData * const tile_data = ( TileWorkerData * ) arg1 ; const TileInfo * const tile = ( TileInfo * ) arg2 ; <vul-end>+static int tile_worker_hook ( TileWorkerData * const tile_data , <vul-start> <vul-end> int mi_row , mi_col ; <vul-start> <vul-end> 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 ) { <vul-start> decode_partition ( tile_data -> cm , & tile_data -> xd , tile , mi_row , mi_col , & tile_data -> bit_reader , BLOCK_64X64 ) ; <vul-end> } } return ! tile_data -> xd . corrupted ; }
|
<vul-sep> +static int tile_worker_hook ( TileWorkerData * const tile_data , <vul-start> const TileInfo * const tile ) { <vul-end> int mi_row , mi_col ; <vul-sep> <vul-end> int mi_row , mi_col ; <vul-start> 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 ; <vul-end> for ( mi_row = tile -> mi_row_start ; mi_row < tile -> mi_row_end ; <vul-sep> mi_col += MI_BLOCK_SIZE ) { <vul-start> decode_partition ( tile_data -> pbi , & tile_data -> xd , mi_row , mi_col , & tile_data -> bit_reader , BLOCK_64X64 , 4 ) ; <vul-end> } <vul-sep>
|
88
|
CWE-125 authrealmlen = authinfolen - 20 ; if ( authrealmlen > 0 ) { ND_PRINT ( ( ndo , ", realm: " ) ) ; } for ( i = 0 ; i < authrealmlen ; i ++ , tp ++ ) ND_PRINT ( ( ndo , "%02x" , * tp ) ) ; ND_PRINT ( ( ndo , ", key ID: %08x" , EXTRACT_32BITS ( tp ) ) ) ; tp += 4 ; ND_PRINT ( ( ndo , ", HMAC-MD5:" ) ) ; for ( i = 0 ; i < 4 ; i ++ , tp += 4 ) ND_PRINT ( ( ndo , " %08x" , EXTRACT_32BITS ( tp ) ) ) ; break ; case DH6OPT_AUTHPROTO_RECONFIG : if ( authinfolen != 17 ) { ND_PRINT ( ( ndo , " ??" ) ) ; break ; } switch ( * tp ++ ) { case DH6OPT_AUTHRECONFIG_KEY : ND_PRINT ( ( ndo , " reconfig-key" ) ) ; break ; case DH6OPT_AUTHRECONFIG_HMACMD5 : ND_PRINT ( ( ndo , " type: HMAC-MD5" ) ) ; break ; default : ND_PRINT ( ( ndo , " type: ??" ) ) ; break ; } ND_PRINT ( ( ndo , " value:" ) ) ; for ( i = 0 ; i < 4 ; i ++ , tp += 4 ) ND_PRINT ( ( ndo , " %08x" , EXTRACT_32BITS ( tp ) ) ) ; break ; default : ND_PRINT ( ( ndo , " ??" ) ) ; break ; } ND_PRINT ( ( ndo , ")" ) ) ; break ; case DH6OPT_RAPID_COMMIT : ND_PRINT ( ( ndo , ")" ) ) ; break ; case DH6OPT_INTERFACE_ID : case DH6OPT_SUBSCRIBER_ID : tp = ( const u_char * ) ( dh6o + 1 ) ; ND_PRINT ( ( ndo , " " ) ) ; for ( i = 0 ; i < optlen && i < 10 ; i ++ ) ND_PRINT ( ( ndo , "%02x" , tp [ i ] ) ) ; ND_PRINT ( ( ndo , "...)" ) ) ; break ; case DH6OPT_RECONF_MSG : <vul-start> <vul-end> tp = ( const u_char * ) ( dh6o + 1 ) ; switch ( * tp ) { case DH6_RENEW : ND_PRINT ( ( ndo , " for renew)" ) ) ; break ; case DH6_INFORM_REQ : ND_PRINT ( ( ndo , " for inf-req)" ) ) ; break ; default : ND_PRINT ( ( ndo , " for ?\\?\\?(%02x))" , * tp ) ) ; break ; } break ; case DH6OPT_RECONF_ACCEPT : ND_PRINT ( ( ndo , ")" ) ) ; break ; case DH6OPT_SIP_SERVER_A : case DH6OPT_DNS_SERVERS : case DH6OPT_SNTP_SERVERS : case DH6OPT_NIS_SERVERS : case DH6OPT_NISP_SERVERS : case DH6OPT_BCMCS_SERVER_A : case DH6OPT_PANA_AGENT : case DH6OPT_LQ_CLIENT_LINK : if ( optlen % 16 ) { ND_PRINT ( ( ndo , " ?)" ) ) ; break ; } tp = ( const u_char * ) ( dh6o + 1 ) ; for ( i = 0 ; i < optlen ; i += 16 ) ND_PRINT ( ( ndo , " %s" , ip6addr_string ( ndo , & tp [ i ] ) ) ) ; ND_PRINT ( ( ndo , ")" ) ) ; break ; case DH6OPT_SIP_SERVER_D : case DH6OPT_DOMAIN_LIST : tp = ( const u_char * ) ( dh6o + 1 ) ; while ( tp < cp + sizeof ( * dh6o ) + optlen ) { ND_PRINT ( ( ndo , " " ) ) ; if ( ( tp = ns_nprint ( ndo , tp , cp + sizeof ( * dh6o ) + optlen ) ) == NULL ) goto trunc ; } ND_PRINT ( ( ndo , ")" ) ) ; break ; case DH6OPT_STATUS_CODE : if ( optlen < 2 ) { ND_PRINT ( ( ndo , " ?)" ) ) ; break ; } tp = ( const u_char * ) ( dh6o + 1 ) ; ND_PRINT ( ( ndo , " %s)" , dhcp6stcode ( EXTRACT_16BITS ( & tp [ 0 ] ) ) ) ) ;
|
<vul-sep> case DH6OPT_RECONF_MSG : <vul-start> if ( optlen != 1 ) { ND_PRINT ( ( ndo , " ?)" ) ) ; break ; } <vul-end> tp = ( const u_char * ) ( dh6o + 1 ) ; <vul-sep>
|
89
|
CWE-119 static int set_register ( pegasus_t * pegasus , __u16 indx , __u8 data ) { <vul-start> <vul-end> int ret ; <vul-start> <vul-end> ret = usb_control_msg ( pegasus -> usb , usb_sndctrlpipe ( pegasus -> usb , 0 ) , PEGASUS_REQ_SET_REG , PEGASUS_REQT_WRITE , data , <vul-start> indx , & data , 1 , 1000 ) ; <vul-end> if ( ret < 0 ) netif_dbg ( pegasus , drv , pegasus -> net , "%s returned %d\\n" , __func__ , ret ) ; <vul-start> <vul-end> return ret ; }
|
<vul-sep> { <vul-start> u8 * buf ; <vul-end> int ret ; <vul-sep> <vul-end> int ret ; <vul-start> buf = kmemdup ( & data , 1 , GFP_NOIO ) ; if ( ! buf ) return - ENOMEM ; <vul-end> ret = usb_control_msg ( pegasus -> usb , usb_sndctrlpipe ( pegasus -> usb , 0 ) , <vul-sep> PEGASUS_REQ_SET_REG , PEGASUS_REQT_WRITE , data , <vul-start> indx , buf , 1 , 1000 ) ; <vul-end> if ( ret < 0 ) <vul-sep> "%s returned %d\\n" , __func__ , ret ) ; <vul-start> kfree ( buf ) ; <vul-end> return ret ; <vul-sep>
|
90
|
CWE-90 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_timestamp 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 ( entry == NULL ) return EINVAL ; 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 ) && entry -> policy == NULL ) 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 ; <vul-start> <vul-end> 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 = calloc ( 1 , sizeof ( * kdb ) ) ; if ( kdb == NULL ) return ENOMEM ; 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 = ts_incr ( now , polent . pw_max_life ) ; else
|
<vul-sep> return KADM5_BAD_MASK ; <vul-start> if ( mask & KADM5_TL_DATA ) { for ( tl_data_tail = entry -> tl_data ; tl_data_tail != NULL ; tl_data_tail = tl_data_tail -> tl_data_next ) { if ( tl_data_tail -> tl_data_type < 256 ) return KADM5_BAD_TL_TYPE ; } } <vul-end> ret = kdb_get_entry ( handle , entry -> principal , & kdb , & adb ) ; <vul-sep>
|
91
|
CWE-416 buf_copy_options ( wp -> w_buffer , BCO_ENTER | BCO_NOHELP ) ; if ( ! curwin_invalid ) { prevwin = curwin ; curwin -> w_redr_status = TRUE ; } curwin = wp ; curbuf = wp -> w_buffer ; check_cursor ( ) ; if ( ! virtual_active ( ) ) curwin -> w_cursor . coladd = 0 ; changed_line_abv_curs ( ) ; if ( curwin -> w_localdir != NULL || curtab -> tp_localdir != NULL ) { char_u * dirname ; if ( globaldir == NULL ) { char_u cwd [ MAXPATHL ] ; if ( mch_dirname ( cwd , MAXPATHL ) == OK ) globaldir = vim_strsave ( cwd ) ; } if ( curwin -> w_localdir != NULL ) dirname = curwin -> w_localdir ; else dirname = curtab -> tp_localdir ; if ( mch_chdir ( ( char * ) dirname ) == 0 ) shorten_fnames ( TRUE ) ; } else if ( globaldir != NULL ) { vim_ignored = mch_chdir ( ( char * ) globaldir ) ; VIM_CLEAR ( globaldir ) ; shorten_fnames ( TRUE ) ; } # ifdef FEAT_JOB_CHANNEL entering_window ( curwin ) ; # endif if ( trigger_new_autocmds ) apply_autocmds ( EVENT_WINNEW , NULL , NULL , FALSE , curbuf ) ; if ( trigger_enter_autocmds ) { apply_autocmds ( EVENT_WINENTER , NULL , NULL , FALSE , curbuf ) ; if ( other_buffer ) apply_autocmds ( EVENT_BUFENTER , NULL , NULL , FALSE , curbuf ) ; } # ifdef FEAT_TITLE maketitle ( ) ; # endif curwin -> w_redr_status = TRUE ; # ifdef FEAT_TERMINAL <vul-start> if ( bt_terminal ( wp -> w_buffer ) ) <vul-end> redraw_mode = TRUE ; # endif redraw_tabline = TRUE ; if ( restart_edit ) redraw_later ( VALID ) ; if ( curwin -> w_height < p_wh && ! curwin -> w_p_wfh # ifdef FEAT_TEXT_PROP && ! popup_is_popup ( curwin ) # endif ) win_setheight ( ( int ) p_wh ) ; else if ( curwin -> w_height == 0 ) win_setheight ( 1 ) ; if ( curwin -> w_width < p_wiw && ! curwin -> w_p_wfw ) win_setwidth ( ( int ) p_wiw ) ; setmouse ( ) ; DO_AUTOCHDIR ; }
|
<vul-sep> # ifdef FEAT_TERMINAL <vul-start> if ( bt_terminal ( curwin -> w_buffer ) ) <vul-end> redraw_mode = TRUE ; <vul-sep>
|
92
|
CWE-787 static int tcos_decipher ( sc_card_t * card , const u8 * crgram , size_t crgram_len , u8 * out , size_t outlen ) { sc_context_t * ctx ; sc_apdu_t apdu ; u8 rbuf [ SC_MAX_APDU_BUFFER_SIZE ] ; u8 sbuf [ SC_MAX_APDU_BUFFER_SIZE ] ; tcos_data * data ; int tcos3 , r ; assert ( card != NULL && crgram != NULL && out != NULL ) ; ctx = card -> ctx ; tcos3 = ( card -> type == SC_CARD_TYPE_TCOS_V3 ) ; data = ( tcos_data * ) card -> drv_data ; LOG_FUNC_CALLED ( ctx ) ; sc_log ( ctx , "TCOS3:%d PKCS1:%d\\n" , tcos3 , ! ! ( data -> pad_flags & SC_ALGORITHM_RSA_PAD_PKCS1 ) ) ; sc_format_apdu ( card , & apdu , crgram_len > 255 ? SC_APDU_CASE_4_EXT : SC_APDU_CASE_4_SHORT , 0x2A , 0x80 , 0x86 ) ; apdu . resp = rbuf ; apdu . resplen = sizeof ( rbuf ) ; apdu . le = crgram_len ; apdu . data = sbuf ; apdu . lc = apdu . datalen = crgram_len + 1 ; sbuf [ 0 ] = tcos3 ? 0x00 : ( ( data -> pad_flags & SC_ALGORITHM_RSA_PAD_PKCS1 ) ? 0x81 : 0x02 ) ; <vul-start> <vul-end> memcpy ( sbuf + 1 , crgram , crgram_len ) ; r = sc_transmit_apdu ( card , & apdu ) ; LOG_TEST_RET ( card -> ctx , r , "APDU transmit failed" ) ; if ( apdu . sw1 == 0x90 && apdu . sw2 == 0x00 ) { size_t len = ( apdu . resplen > outlen ) ? outlen : apdu . resplen ; unsigned int offset = 0 ; if ( tcos3 && ( data -> pad_flags & SC_ALGORITHM_RSA_PAD_PKCS1 ) && apdu . resp [ 0 ] == 0 && apdu . resp [ 1 ] == 2 ) { offset = 2 ; while ( offset < len && apdu . resp [ offset ] != 0 ) ++ offset ; offset = ( offset < len - 1 ) ? offset + 1 : 0 ; } memcpy ( out , apdu . resp + offset , len - offset ) ; SC_FUNC_RETURN ( card -> ctx , SC_LOG_DEBUG_VERBOSE , len - offset ) ; } SC_FUNC_RETURN ( card -> ctx , SC_LOG_DEBUG_VERBOSE , sc_check_sw ( card , apdu . sw1 , apdu . sw2 ) ) ; }
|
<vul-sep> sbuf [ 0 ] = tcos3 ? 0x00 : ( ( data -> pad_flags & SC_ALGORITHM_RSA_PAD_PKCS1 ) ? 0x81 : 0x02 ) ; <vul-start> if ( sizeof sbuf - 1 < crgram_len ) return SC_ERROR_INVALID_ARGUMENTS ; <vul-end> memcpy ( sbuf + 1 , crgram , crgram_len ) ; <vul-sep>
|
93
|
CWE-125 static expr_ty ast_for_trailer ( struct compiling * c , const node * n , expr_ty left_expr ) { REQ ( n , trailer ) ; if ( TYPE ( CHILD ( n , 0 ) ) == LPAR ) { if ( NCH ( n ) == 2 ) return Call ( left_expr , NULL , NULL , LINENO ( n ) , n -> n_col_offset , c -> c_arena ) ; else <vul-start> return ast_for_call ( c , CHILD ( n , 1 ) , left_expr ) ; <vul-end> } else if ( TYPE ( CHILD ( n , 0 ) ) == DOT ) { PyObject * attr_id = NEW_IDENTIFIER ( CHILD ( n , 1 ) ) ; if ( ! attr_id ) return NULL ; return Attribute ( left_expr , attr_id , Load , LINENO ( n ) , n -> n_col_offset , c -> c_arena ) ; } else { REQ ( CHILD ( n , 0 ) , LSQB ) ; REQ ( CHILD ( n , 2 ) , RSQB ) ; n = CHILD ( n , 1 ) ; if ( NCH ( n ) == 1 ) { slice_ty slc = ast_for_slice ( c , CHILD ( n , 0 ) ) ; if ( ! slc ) return NULL ; return Subscript ( left_expr , slc , Load , LINENO ( n ) , n -> n_col_offset , c -> c_arena ) ; } else { int j ; slice_ty slc ; expr_ty e ; int simple = 1 ; asdl_seq * slices , * elts ; slices = _Ta3_asdl_seq_new ( ( NCH ( n ) + 1 ) / 2 , c -> c_arena ) ; if ( ! slices ) return NULL ; for ( j = 0 ; j < NCH ( n ) ; j += 2 ) { slc = ast_for_slice ( c , CHILD ( n , j ) ) ; if ( ! slc ) return NULL ; if ( slc -> kind != Index_kind ) simple = 0 ; asdl_seq_SET ( slices , j / 2 , slc ) ; } if ( ! simple ) { return Subscript ( left_expr , ExtSlice ( slices , c -> c_arena ) , Load , LINENO ( n ) , n -> n_col_offset , c -> c_arena ) ; } elts = _Ta3_asdl_seq_new ( asdl_seq_LEN ( slices ) , c -> c_arena ) ; if ( ! elts ) return NULL ; for ( j = 0 ; j < asdl_seq_LEN ( slices ) ; ++ j ) { slc = ( slice_ty ) asdl_seq_GET ( slices , j ) ; assert ( slc -> kind == Index_kind && slc -> v . Index . value ) ; asdl_seq_SET ( elts , j , slc -> v . Index . value ) ; } e = Tuple ( elts , Load , LINENO ( n ) , n -> n_col_offset , c -> c_arena ) ; if ( ! e )
|
<vul-sep> else <vul-start> return ast_for_call ( c , CHILD ( n , 1 ) , left_expr , true ) ; <vul-end> } <vul-sep>
|
94
|
CWE-119 static bool check_underflow ( const struct ipt_entry * e ) { const struct xt_entry_target * t ; unsigned int verdict ; <vul-start> if ( ! unconditional ( & e -> ip ) ) <vul-end> return false ; t = ipt_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 ; }
|
<vul-sep> unsigned int verdict ; <vul-start> if ( ! unconditional ( e ) ) <vul-end> return false ; <vul-sep>
|
95
|
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 ; <vul-start> msg -> msg_namelen = 0 ; <vul-end> 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 ; }
|
<vul-sep>
|
End of preview. Expand
in Data Studio
No dataset card yet
- Downloads last month
- 10