Unnamed: 0
int64
0
3.87k
source
stringlengths
85
89.9k
target
stringlengths
1
30.7k
0
CWE-119 bool initiate_stratum ( struct pool * pool ) { bool ret = false , recvd = false , noresume = false , sockd = false ; char s [ RBUFSIZE ] , * sret = NULL , * nonce1 , * sessionid ; json_t * val = NULL , * res_val , * err_val ; json_error_t err ; int n2size ; resend : if ( ! setup_stratum_socket ( pool ) ) { sockd = false ; goto out ; } sockd = true ; if ( recvd ) { clear_sock ( pool ) ; sprintf ( s , "{\\"id\\":<S2SV_blank>%d,<S2SV_blank>\\"method\\":<S2SV_blank>\\"mining.subscribe\\",<S2SV_blank>\\"params\\":<S2SV_blank>[]}" , swork_id ++ ) ; } else { if ( pool -> sessionid ) sprintf ( s , "{\\"id\\":<S2SV_blank>%d,<S2SV_blank>\\"method\\":<S2SV_blank>\\"mining.subscribe\\",<S2SV_blank>\\"params\\":<S2SV_blank>[\\"" PACKAGE "/" VERSION "\\",<S2SV_blank>\\"%s\\"]}" , swork_id ++ , pool -> sessionid ) ; else sprintf ( s , "{\\"id\\":<S2SV_blank>%d,<S2SV_blank>\\"method\\":<S2SV_blank>\\"mining.subscribe\\",<S2SV_blank>\\"params\\":<S2SV_blank>[\\"" PACKAGE "/" VERSION "\\"]}" , swork_id ++ ) ; } if ( __stratum_send ( pool , s , strlen ( s ) ) != SEND_OK ) { applog ( LOG_DEBUG , "Failed<S2SV_blank>to<S2SV_blank>send<S2SV_blank>s<S2SV_blank>in<S2SV_blank>initiate_stratum" ) ; goto out ; } if ( ! socket_full ( pool , DEFAULT_SOCKWAIT ) ) { applog ( LOG_DEBUG , "Timed<S2SV_blank>out<S2SV_blank>waiting<S2SV_blank>for<S2SV_blank>response<S2SV_blank>in<S2SV_blank>initiate_stratum" ) ; goto out ; } sret = recv_line ( pool ) ; if ( ! sret ) goto out ; recvd = true ; val = JSON_LOADS ( sret , & err ) ; free ( sret ) ; if ( ! val ) { applog ( LOG_INFO , "JSON<S2SV_blank>decode<S2SV_blank>failed(%d):<S2SV_blank>%s" , err . line , err . text ) ; goto out ; } res_val = json_object_get ( val , "result" ) ; err_val = json_object_get ( val , "error" ) ; if ( ! res_val || json_is_null ( res_val ) || ( err_val && ! json_is_null ( err_val ) ) ) { char * ss ; if ( err_val ) ss = json_dumps ( err_val , JSON_INDENT ( 3 ) ) ; else ss = strdup ( "(unknown<S2SV_blank>reason)" ) ; applog ( LOG_INFO , "JSON-RPC<S2SV_blank>decode<S2SV_blank>failed:<S2SV_blank>%s" , ss ) ; free ( ss ) ; goto out ; } sessionid = get_sessionid ( res_val ) ; if ( ! sessionid ) applog ( LOG_DEBUG , "Failed<S2SV_blank>to<S2SV_blank>get<S2SV_blank>sessionid<S2SV_blank>in<S2SV_blank>initiate_stratum" ) ; nonce1 = json_array_string ( res_val , 1 ) ; if ( ! <S2SV_StartBug> nonce1 ) { <S2SV_StartBug> <S2SV_EndBug> applog ( LOG_INFO , "Failed<S2SV_blank>to<S2SV_blank>get<S2SV_blank>nonce1<S2SV_blank>in<S2SV_blank>initiate_stratum" ) ; free ( <S2SV_EndBug> sessionid ) ; goto out ; } n2size = json_integer_value ( json_array_get ( res_val , 2 ) ) ; if ( ! n2size <S2SV_EndBug> <S2SV_StartBug> ) { applog ( LOG_INFO <S2SV_StartBug> <S2SV_EndBug> , "Failed<S2SV_blank>to<S2SV_blank>get<S2SV_blank>n2size<S2SV_blank>in<S2SV_blank>initiate_stratum" ) ; free ( sessionid ) ; free ( nonce1 ) ; goto out ; } cg_wlock ( & pool -> data_lock ) ; pool -> sessionid = sessionid ; pool -> nonce1 = nonce1 ; pool -> n1_len = strlen ( nonce1 ) / 2 ; free ( pool -> nonce1bin ) ; pool -> nonce1bin = calloc ( pool -> n1_len , 1 ) ; if ( unlikely ( ! pool -> nonce1bin ) ) quithere ( 1 , "Failed<S2SV_blank>to<S2SV_blank>calloc<S2SV_blank>pool->nonce1bin" ) ; hex2bin ( pool -> nonce1bin , pool -> nonce1 , pool -> n1_len ) ; pool -> n2size = n2size ; cg_wunlock ( & pool -> data_lock ) ; if ( sessionid ) applog ( LOG_DEBUG , "Pool<S2SV_blank>%d<S2SV_blank>stratum<S2SV_blank>session<S2SV_blank>id:<S2SV_blank>%s" , pool -> pool_no , pool -> sessionid ) ; ret = true ; out : if ( ret ) { if ( ! pool -> stratum_url ) pool -> stratum_url = pool -> sockaddr_url ; pool -> stratum_active = true ; pool -> sdiff = 1 ; if ( opt_protocol ) { applog ( LOG_DEBUG , "Pool<S2SV_blank>%d<S2SV_blank>confirmed<S2SV_blank>mining.subscribe<S2SV_blank>with<S2SV_blank>extranonce1<S2SV_blank>%s<S2SV_blank>extran2size<S2SV_blank>%d" , pool -> pool_no , pool -> nonce1 , pool -> n2size ) ; } } else { if ( recvd && ! noresume ) { cg_wlock ( & pool -> data_lock ) ; free ( pool -> sessionid ) ; free ( pool -> nonce1 ) ; pool -> sessionid = pool -> nonce1 = NULL ; cg_wunlock ( & pool -> data_lock ) ; applog ( LOG_DEBUG , "Failed<S2SV_blank>to<S2SV_blank>resume<S2SV_blank>stratum,<S2SV_blank>trying<S2SV_blank>afresh" ) ; noresume = true ; json_decref ( val ) ; goto resend ; } applog ( LOG_DEBUG , "Initiate<S2SV_blank>stratum<S2SV_blank>failed" ) ; if ( sockd ) suspend_stratum ( pool ) ; } json_decref ( val ) ; return ret ; }
<S2SV_ModStart> if ( ! valid_hex ( nonce1 ) <S2SV_ModEnd> ) { applog <S2SV_ModStart> ( LOG_INFO , "Failed<S2SV_blank>to<S2SV_blank>get<S2SV_blank>valid<S2SV_blank>nonce1<S2SV_blank>in<S2SV_blank>initiate_stratum" <S2SV_ModEnd> ) ; free <S2SV_ModStart> ; if ( n2size < 2 || n2size > 16 <S2SV_ModEnd> ) { applog <S2SV_ModStart> ( LOG_INFO , "Failed<S2SV_blank>to<S2SV_blank>get<S2SV_blank>valid<S2SV_blank>n2size<S2SV_blank>in<S2SV_blank>initiate_stratum" <S2SV_ModEnd> ) ; free
1
CWE-000 static void unix_release_sock ( struct sock * sk , int embrion ) { struct unix_sock * u = unix_sk ( sk ) ; struct path path ; struct sock * skpair ; struct sk_buff * skb ; int state ; unix_remove_socket ( sk ) ; unix_state_lock ( sk ) ; sock_orphan ( sk ) ; sk -> sk_shutdown = SHUTDOWN_MASK ; path = u -> path ; u -> path . dentry = NULL ; u -> path . mnt = NULL ; state = sk -> sk_state ; sk -> sk_state = TCP_CLOSE ; unix_state_unlock ( sk ) ; wake_up_interruptible_all ( & u -> peer_wait ) ; skpair = unix_peer ( sk ) ; if ( skpair != NULL ) { if ( sk -> sk_type == SOCK_STREAM || sk -> sk_type == SOCK_SEQPACKET ) { unix_state_lock ( skpair ) ; skpair -> sk_shutdown = SHUTDOWN_MASK ; if ( ! skb_queue_empty ( & sk -> sk_receive_queue ) || embrion ) skpair -> sk_err = ECONNRESET ; unix_state_unlock ( skpair ) ; skpair -> sk_state_change ( skpair ) ; sk_wake_async ( skpair , SOCK_WAKE_WAITD , POLL_HUP ) ; } sock_put <S2SV_EndBug> <S2SV_StartBug> ( skpair ) ; unix_peer ( sk ) = NULL ; } while ( ( skb = skb_dequeue ( & sk -> sk_receive_queue ) ) != NULL ) { if ( state == TCP_LISTEN ) unix_release_sock ( skb -> sk , 1 ) ; UNIXCB ( skb ) . consumed = skb -> len ; kfree_skb ( skb ) ; } if ( path . dentry ) path_put ( & path ) ; sock_put ( sk ) ; if ( unix_tot_inflight ) unix_gc ( ) ; }
<S2SV_ModStart> ) ; } unix_dgram_peer_wake_disconnect ( sk , skpair ) ;
2
CWE-125 void eap_print ( netdissect_options * ndo , register const u_char * cp , u_int length ) { const struct eap_frame_t * eap ; const u_char * tptr ; u_int tlen , type , subtype ; int count = 0 , len ; tptr = cp ; tlen = length ; eap = ( const struct eap_frame_t * ) cp ; ND_TCHECK ( * eap ) ; if ( ndo -> ndo_vflag < 1 ) { ND_PRINT ( ( ndo , "%s<S2SV_blank>(%u)<S2SV_blank>v%u,<S2SV_blank>len<S2SV_blank>%u" , tok2str ( eap_frame_type_values , "unknown" , eap -> type ) , eap -> type , eap -> version , EXTRACT_16BITS ( eap -> length ) ) ) ; return ; } ND_PRINT ( ( ndo , "%s<S2SV_blank>(%u)<S2SV_blank>v%u,<S2SV_blank>len<S2SV_blank>%u" , tok2str ( eap_frame_type_values , "unknown" , eap -> type ) , eap -> type , eap -> version , EXTRACT_16BITS ( eap -> length ) ) ) ; tptr += sizeof ( const struct eap_frame_t ) ; tlen -= sizeof ( const struct eap_frame_t ) ; switch ( eap -> type ) { <S2SV_StartBug> case EAP_FRAME_TYPE_PACKET : type = * ( tptr ) ; <S2SV_EndBug> len = EXTRACT_16BITS ( tptr + 2 ) ; ND_PRINT ( ( ndo , ",<S2SV_blank>%s<S2SV_blank>(%u),<S2SV_blank>id<S2SV_blank>%u,<S2SV_blank>len<S2SV_blank>%u" , tok2str ( eap_code_values , "unknown" , type ) , type , * ( tptr + 1 ) , len ) ) ; ND_TCHECK2 ( * tptr , len ) ; if ( <S2SV_StartBug> type <= 2 ) { subtype = * ( tptr + 4 ) ; ND_PRINT ( ( <S2SV_EndBug> ndo , "\\n\\t\\t<S2SV_blank>Type<S2SV_blank>%s<S2SV_blank>(%u)" , tok2str ( eap_type_values , "unknown" <S2SV_StartBug> , * ( tptr + 4 ) ) , * ( tptr <S2SV_EndBug> + 4 ) ) ) ; switch ( subtype ) { case EAP_TYPE_IDENTITY : if ( len - 5 > 0 ) { ND_PRINT ( ( ndo , ",<S2SV_blank>Identity:<S2SV_blank>" ) ) ; safeputs ( ndo , tptr + 5 , len - 5 ) ; } break ; case EAP_TYPE_NOTIFICATION : if ( len - 5 > 0 ) { ND_PRINT ( ( ndo , ",<S2SV_blank>Notification:<S2SV_blank>" ) ) ; safeputs ( ndo , tptr + 5 , len - 5 ) ; } break ; case EAP_TYPE_NAK : count = 5 ; while ( count < len ) { ND_PRINT ( ( ndo <S2SV_StartBug> , "<S2SV_blank>%s<S2SV_blank>(%u)," , tok2str ( eap_type_values <S2SV_EndBug> , "unknown" , * ( tptr + count ) ) , * ( tptr + count ) ) ) ; count ++ ; } break ; <S2SV_StartBug> case EAP_TYPE_TTLS : ND_PRINT ( ( <S2SV_EndBug> ndo , "<S2SV_blank>TTLSv%u" , EAP_TTLS_VERSION ( * ( tptr + 5 ) ) ) ) ; case EAP_TYPE_TLS : <S2SV_StartBug> ND_PRINT ( ( <S2SV_EndBug> ndo , "<S2SV_blank>flags<S2SV_blank>[%s]<S2SV_blank>0x%02x," , bittok2str ( eap_tls_flags_values , "none" , * ( tptr + 5 ) ) , * ( tptr + 5 ) ) ) ; if ( EAP_TLS_EXTRACT_BIT_L ( * ( tptr + 5 ) ) <S2SV_StartBug> ) { ND_PRINT ( ( ndo , "<S2SV_blank>len<S2SV_blank>%u" , EXTRACT_32BITS ( tptr + 6 ) ) ) ; <S2SV_EndBug> } break <S2SV_StartBug> ; case EAP_TYPE_FAST : ND_PRINT ( ( ndo , "<S2SV_blank>FASTv%u" <S2SV_EndBug> , EAP_TTLS_VERSION ( * ( tptr + 5 ) ) ) ) ; ND_PRINT ( ( ndo , "<S2SV_blank>flags<S2SV_blank>[%s]<S2SV_blank>0x%02x," , bittok2str ( eap_tls_flags_values , "none" , * ( tptr + 5 ) ) , * ( tptr + 5 ) ) ) ; if ( EAP_TLS_EXTRACT_BIT_L ( * ( tptr + 5 ) ) ) { ND_PRINT ( ( ndo <S2SV_StartBug> , "<S2SV_blank>len<S2SV_blank>%u" , EXTRACT_32BITS ( tptr + 6 ) ) ) ; } break ; case <S2SV_EndBug> <S2SV_StartBug> EAP_TYPE_AKA : case EAP_TYPE_SIM : ND_PRINT ( ( ndo , "<S2SV_blank>subtype<S2SV_blank>[%s]<S2SV_blank>0x%02x," , tok2str ( <S2SV_EndBug> eap_aka_subtype_values , "unknown" , * ( tptr + 5 ) ) , * ( tptr + 5 ) ) ) ; break ; case EAP_TYPE_MD5_CHALLENGE : case EAP_TYPE_OTP : case EAP_TYPE_GTC : case EAP_TYPE_EXPANDED_TYPES : case EAP_TYPE_EXPERIMENTAL : default : break ; } } break ; case EAP_FRAME_TYPE_LOGOFF : case EAP_FRAME_TYPE_ENCAP_ASF_ALERT : default : break ; } return ; trunc : ND_PRINT ( ( ndo , "\\n\\t[|EAP]" ) ) ; }
<S2SV_ModStart> case EAP_FRAME_TYPE_PACKET : ND_TCHECK_8BITS ( tptr ) ; <S2SV_ModStart> * ( tptr ) ; ND_TCHECK_16BITS ( tptr + 2 <S2SV_ModStart> 2 ) { ND_TCHECK_8BITS ( tptr + 4 ) ; <S2SV_ModStart> , "unknown" , subtype ) , subtype <S2SV_ModEnd> ) ) ; <S2SV_ModStart> len ) { ND_TCHECK_8BITS ( tptr + count ) ; <S2SV_ModStart> case EAP_TYPE_TTLS : case EAP_TYPE_TLS : ND_TCHECK_8BITS ( tptr + 5 ) ; if ( subtype == EAP_TYPE_TTLS ) <S2SV_ModStart> ) ) ; <S2SV_ModEnd> ND_PRINT ( ( <S2SV_ModStart> ) ) { ND_TCHECK_32BITS ( tptr + 6 ) ; <S2SV_ModStart> case EAP_TYPE_FAST : ND_TCHECK_8BITS ( tptr + 5 ) ; <S2SV_ModStart> ) ) { ND_TCHECK_32BITS ( tptr + 6 ) ; <S2SV_ModStart> case EAP_TYPE_SIM : ND_TCHECK_8BITS ( tptr + 5 ) ;
3
CWE-119 static void store_coding_context ( MACROBLOCK * x , PICK_MODE_CONTEXT * ctx , int mode_index , int_mv * ref_mv <S2SV_EndBug> <S2SV_StartBug> , int_mv * second_ref_mv , int64_t comp_pred_diff [ REFERENCE_MODES ] <S2SV_StartBug> , int64_t tx_size_diff [ TX_MODES ] , <S2SV_StartBug> <S2SV_EndBug> int64_t best_filter_diff [ SWITCHABLE_FILTER_CONTEXTS ] ) { MACROBLOCKD * const <S2SV_EndBug> xd = & x -> e_mbd ; ctx -> skip = x -> skip <S2SV_StartBug> ; ctx <S2SV_EndBug> -> best_mode_index = mode_index ; ctx -> mic = * xd -> mi [ 0 ] ; ctx -> best_ref_mv [ 0 <S2SV_StartBug> ] . as_int = ref_mv -> as_int ; ctx <S2SV_EndBug> -> best_ref_mv [ 1 ] . as_int = second_ref_mv -> as_int ; ctx -> single_pred_diff = ( int ) comp_pred_diff [ SINGLE_REFERENCE ] ; ctx -> comp_pred_diff = ( int ) comp_pred_diff [ COMPOUND_REFERENCE ] ; ctx -> hybrid_pred_diff = ( int ) comp_pred_diff [ REFERENCE_MODE_SELECT ] ; vpx_memcpy ( ctx -> tx_rd_diff <S2SV_StartBug> , tx_size_diff , sizeof ( ctx -> tx_rd_diff ) ) ; vpx_memcpy ( ctx -> <S2SV_EndBug> best_filter_diff , best_filter_diff , sizeof ( * best_filter_diff ) * SWITCHABLE_FILTER_CONTEXTS ) ; }
<S2SV_ModStart> int mode_index , <S2SV_ModEnd> int64_t comp_pred_diff [ <S2SV_ModStart> ] , int64_t <S2SV_ModEnd> best_filter_diff [ SWITCHABLE_FILTER_CONTEXTS <S2SV_ModStart> [ SWITCHABLE_FILTER_CONTEXTS ] , int skippable <S2SV_ModStart> ; ctx -> skippable = skippable ; ctx -> <S2SV_ModStart> ; ctx -> mbmi_ext = * x -> mbmi_ext <S2SV_ModEnd> ; ctx -> <S2SV_ModStart> REFERENCE_MODE_SELECT ] ; memcpy <S2SV_ModEnd> ( ctx ->
4
CWE-000 static int ext4_write_begin ( struct file * file , struct address_space * mapping , loff_t pos , unsigned len , unsigned flags , struct page * * pagep , void * * fsdata ) { struct inode * inode = mapping -> host ; int ret , needed_blocks ; handle_t * handle ; int retries = 0 ; struct page * page ; pgoff_t index ; unsigned from , to ; trace_ext4_write_begin ( inode , pos , len , flags ) ; needed_blocks = ext4_writepage_trans_blocks ( inode ) + 1 ; index = pos >> PAGE_CACHE_SHIFT ; from = pos & ( PAGE_CACHE_SIZE - 1 ) ; to = from + len ; retry : handle = ext4_journal_start ( inode , needed_blocks ) ; if ( IS_ERR ( handle ) ) { ret = PTR_ERR ( handle ) ; goto out ; } flags |= AOP_FLAG_NOFS ; page = grab_cache_page_write_begin ( mapping , index , flags ) ; if ( ! page ) { ext4_journal_stop ( handle ) ; ret = - ENOMEM ; goto out ; } * pagep = page ; ret <S2SV_StartBug> = block_write_begin ( file , mapping , pos , len , flags , pagep , fsdata <S2SV_StartBug> <S2SV_EndBug> , ext4_get_block ) ; <S2SV_EndBug> if ( ! ret && ext4_should_journal_data ( inode ) ) { ret = walk_page_buffers ( handle , page_buffers ( page ) , from , to , NULL , do_journal_get_write_access ) ; } if ( ret ) { unlock_page ( page ) ; page_cache_release ( page ) ; if ( pos + len > inode -> i_size && ext4_can_truncate ( inode ) ) ext4_orphan_add ( handle , inode ) ; ext4_journal_stop ( handle ) ; if ( pos + len > inode -> i_size ) { ext4_truncate_failed_write ( inode ) ; if ( inode -> i_nlink ) ext4_orphan_del ( NULL , inode ) ; } } if ( ret == - ENOSPC && ext4_should_retry_alloc ( inode -> i_sb , & retries ) ) goto retry ; out : return ret ; }
<S2SV_ModStart> = page ; if ( ext4_should_dioread_nolock ( inode ) ) <S2SV_ModStart> , fsdata , ext4_get_block_write ) ; else ret = block_write_begin ( file , mapping , pos , len , flags , pagep , fsdata ,
5
<S2SV_StartBug> CWE-119 int16_t vp9_ac_quant ( int qindex , int delta ) { return ac_qlookup [ <S2SV_EndBug> clamp ( qindex + delta , 0 , MAXQ ) ] ; } <S2SV_EndBug> <S2SV_StartBug>
<S2SV_ModStart> , int delta , vpx_bit_depth_t bit_depth ) { # if CONFIG_VP9_HIGHBITDEPTH switch ( bit_depth ) { case VPX_BITS_8 : <S2SV_ModEnd> return ac_qlookup [ <S2SV_ModStart> ) ] ; case VPX_BITS_10 : return ac_qlookup_10 [ clamp ( qindex + delta , 0 , MAXQ ) ] ; case VPX_BITS_12 : return ac_qlookup_12 [ clamp ( qindex + delta , 0 , MAXQ ) ] ; default : assert ( 0 && "bit_depth<S2SV_blank>should<S2SV_blank>be<S2SV_blank>VPX_BITS_8,<S2SV_blank>VPX_BITS_10<S2SV_blank>or<S2SV_blank>VPX_BITS_12" ) ; return - 1 ; } # else ( void ) bit_depth ; return ac_qlookup [ clamp ( qindex + delta , 0 , MAXQ ) ] ; # endif
6
CWE-59 int <S2SV_StartBug> add_mibfile ( const char * tmpstr , const char * d_name , FILE * ip ) <S2SV_EndBug> { FILE * fp ; char token [ MAXTOKEN ] , token2 [ MAXTOKEN ] ; if ( ( fp = fopen ( tmpstr , "r" ) ) == NULL ) { snmp_log_perror ( tmpstr ) ; return 1 ; } DEBUGMSGTL ( ( "parse-mibs" , "Checking<S2SV_blank>file:<S2SV_blank>%s...\\n" , tmpstr ) ) ; mibLine = 1 ; File = tmpstr ; if ( get_token ( fp , token , MAXTOKEN ) != LABEL ) { fclose ( fp ) ; return 1 ; } if ( get_token ( fp , token2 , MAXTOKEN ) == DEFINITIONS ) { new_module ( token , tmpstr ) ; <S2SV_StartBug> if ( ip ) <S2SV_EndBug> fprintf ( ip , "%s<S2SV_blank>%s\\n" , token , d_name ) ; fclose ( fp ) ; return 0 ; } else { fclose ( fp ) ; return 1 ; } }
<S2SV_ModStart> char * d_name <S2SV_ModEnd> ) { FILE <S2SV_ModStart> tmpstr ) ; <S2SV_ModEnd> fclose ( fp
7
CWE-20 static enum try_read_result try_read_network ( conn * c ) { enum try_read_result gotdata = READ_NO_DATA_RECEIVED ; <S2SV_StartBug> int res ; assert ( c != NULL ) ; if <S2SV_EndBug> ( c -> rcurr != c -> rbuf ) { if ( c -> rbytes != 0 ) memmove ( c -> rbuf , c -> rcurr , c -> rbytes ) ; c -> rcurr = c -> rbuf ; } while ( 1 ) { if ( c -> rbytes <S2SV_StartBug> >= c <S2SV_EndBug> -> rsize ) { char * new_rbuf = realloc ( c -> rbuf , c -> rsize * 2 ) ; if ( ! new_rbuf ) { if ( settings . verbose > 0 ) fprintf ( stderr , "Couldn\'t<S2SV_blank>realloc<S2SV_blank>input<S2SV_blank>buffer\\n" ) ; c -> rbytes = 0 ; out_string ( c , "SERVER_ERROR<S2SV_blank>out<S2SV_blank>of<S2SV_blank>memory<S2SV_blank>reading<S2SV_blank>request" ) ; c -> write_and_go = conn_closing ; return READ_MEMORY_ERROR ; } c -> rcurr = c -> rbuf = new_rbuf ; c -> rsize *= 2 ; } int avail = c -> rsize - c -> rbytes ; res = read ( c -> sfd , c -> rbuf + c -> rbytes , avail ) ; if ( res > 0 ) { pthread_mutex_lock ( & c -> thread -> stats . mutex ) ; c -> thread -> stats . bytes_read += res ; pthread_mutex_unlock ( & c -> thread -> stats . mutex ) ; gotdata = READ_DATA_RECEIVED ; c -> rbytes += res ; if ( res == avail ) { continue ; } else { break ; } } if ( res == 0 ) { return READ_ERROR ; } if ( res == - 1 ) { if ( errno == EAGAIN || errno == EWOULDBLOCK ) { break ; } return READ_ERROR ; } } return gotdata ; }
<S2SV_ModStart> int res ; int num_allocs = 0 ; <S2SV_ModStart> rsize ) { if ( num_allocs == 4 ) { return gotdata ; } ++ num_allocs ;
8
CWE-400 static Image * ReadWPGImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { typedef struct { size_t FileId ; MagickOffsetType DataOffset ; unsigned int ProductType ; unsigned int FileType ; unsigned char MajorVersion ; unsigned char MinorVersion ; unsigned int EncryptKey ; unsigned int Reserved ; } WPGHeader ; typedef struct { unsigned char RecType ; size_t RecordLength ; } WPGRecord ; typedef struct { unsigned char Class ; unsigned char RecType ; size_t Extension ; size_t RecordLength ; } WPG2Record ; typedef struct { unsigned HorizontalUnits ; unsigned VerticalUnits ; unsigned char PosSizePrecision ; } WPG2Start ; typedef struct { unsigned int Width ; unsigned int Height ; unsigned int Depth ; unsigned int HorzRes ; unsigned int VertRes ; } WPGBitmapType1 ; typedef struct { unsigned int Width ; unsigned int Height ; unsigned char Depth ; unsigned char Compression ; } WPG2BitmapType1 ; typedef struct { unsigned int RotAngle ; unsigned int LowLeftX ; unsigned int LowLeftY ; unsigned int UpRightX ; unsigned int UpRightY ; unsigned int Width ; unsigned int Height ; unsigned int Depth ; unsigned int HorzRes ; unsigned int VertRes ; } WPGBitmapType2 ; typedef struct { unsigned int StartIndex ; unsigned int NumOfEntries ; } WPGColorMapRec ; Image * image ; unsigned int status ; WPGHeader Header ; WPGRecord Rec ; WPG2Record Rec2 ; WPG2Start StartWPG ; WPGBitmapType1 BitmapHeader1 ; WPG2BitmapType1 Bitmap2Header1 ; WPGBitmapType2 BitmapHeader2 ; WPGColorMapRec WPG_Palette ; int i , bpp , WPG2Flags ; ssize_t ldblk ; size_t one ; unsigned char * BImgBuff ; tCTM CTM ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; one = 1 ; image = AcquireImage ( image_info ) ; image -> depth = 8 ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } Header . FileId = ReadBlobLSBLong ( image ) ; Header . DataOffset = ( MagickOffsetType ) ReadBlobLSBLong ( image ) ; Header . ProductType = ReadBlobLSBShort ( image ) ; Header . FileType = ReadBlobLSBShort ( image ) ; Header . MajorVersion = ReadBlobByte ( image ) ; Header . MinorVersion = ReadBlobByte ( image ) ; Header . EncryptKey = ReadBlobLSBShort ( image ) ; Header . Reserved = ReadBlobLSBShort ( image ) ; if ( Header . FileId != 0x435057FF || ( Header . ProductType >> 8 ) != 0x16 ) ThrowReaderException ( CorruptImageError , "ImproperImageHeader" ) ; if ( Header . EncryptKey != 0 ) ThrowReaderException ( CoderError , "EncryptedWPGImageFileNotSupported" ) ; image -> columns = 1 ; image -> rows = 1 ; image -> colors = 0 ; bpp = 0 ; BitmapHeader2 . RotAngle = 0 ; Rec2 . RecordLength = 0 ; switch ( Header . FileType ) { case 1 : while ( ! EOFBlob ( image ) ) { ( void ) SeekBlob ( image , Header . DataOffset , SEEK_SET ) ; if ( EOFBlob ( image ) ) break ; Rec . RecType = ( i = ReadBlobByte ( image ) ) ; if ( i <S2SV_StartBug> == EOF ) break ; Rd_WP_DWORD ( image , & <S2SV_EndBug> Rec . RecordLength ) ; if ( EOFBlob ( image ) ) break ; Header . DataOffset = TellBlob ( image ) + Rec . RecordLength ; switch ( Rec . RecType ) { case 0x0B : BitmapHeader1 . Width = ReadBlobLSBShort ( image ) ; BitmapHeader1 . Height = ReadBlobLSBShort ( image ) ; if ( ( BitmapHeader1 . Width == 0 ) || ( BitmapHeader1 . Height == 0 ) ) ThrowReaderException ( CorruptImageError , "ImproperImageHeader" ) ; BitmapHeader1 . Depth = ReadBlobLSBShort ( image ) ; BitmapHeader1 . HorzRes = ReadBlobLSBShort ( image ) ; BitmapHeader1 . VertRes = ReadBlobLSBShort ( image ) ; if ( BitmapHeader1 . HorzRes && BitmapHeader1 . VertRes ) { image -> units = PixelsPerCentimeterResolution ; image -> x_resolution = BitmapHeader1 . HorzRes / 470.0 ; image -> y_resolution = BitmapHeader1 . VertRes / 470.0 ; } image -> columns = BitmapHeader1 . Width ; image -> rows = BitmapHeader1 . Height ; bpp = BitmapHeader1 . Depth ; goto UnpackRaster ; case 0x0E : WPG_Palette . StartIndex = ReadBlobLSBShort ( image ) ; WPG_Palette . NumOfEntries = ReadBlobLSBShort ( image ) ; if ( ( WPG_Palette . NumOfEntries - WPG_Palette . StartIndex ) > ( Rec2 . RecordLength - 2 - 2 ) / 3 ) ThrowReaderException ( CorruptImageError , "InvalidColormapIndex" ) ; image -> colors = WPG_Palette . NumOfEntries ; if ( ! AcquireImageColormap ( image , image -> colors ) ) goto NoMemory ; for ( i = WPG_Palette . StartIndex ; i < ( int ) WPG_Palette . NumOfEntries ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; } break ; case 0x11 : if ( Rec . RecordLength > 8 ) image = ExtractPostscript ( image , image_info , TellBlob ( image ) + 8 , ( ssize_t ) Rec . RecordLength - 8 , exception ) ; break ; case 0x14 : BitmapHeader2 . RotAngle = ReadBlobLSBShort ( image ) ; BitmapHeader2 . LowLeftX = ReadBlobLSBShort ( image ) ; BitmapHeader2 . LowLeftY = ReadBlobLSBShort ( image ) ; BitmapHeader2 . UpRightX = ReadBlobLSBShort ( image ) ; BitmapHeader2 . UpRightY = ReadBlobLSBShort ( image ) ; BitmapHeader2 . Width = ReadBlobLSBShort ( image ) ; BitmapHeader2 . Height = ReadBlobLSBShort ( image ) ; if ( ( BitmapHeader2 . Width == 0 ) || ( BitmapHeader2 . Height == 0 ) ) ThrowReaderException ( CorruptImageError , "ImproperImageHeader" ) ; BitmapHeader2 . Depth = ReadBlobLSBShort ( image ) ; BitmapHeader2 . HorzRes = ReadBlobLSBShort ( image ) ; BitmapHeader2 . VertRes = ReadBlobLSBShort ( image ) ; image -> units = PixelsPerCentimeterResolution ; image -> page . width = ( unsigned int ) ( ( BitmapHeader2 . LowLeftX - BitmapHeader2 . UpRightX ) / 470.0 ) ; image -> page . height = ( unsigned int ) ( ( BitmapHeader2 . LowLeftX - BitmapHeader2 . UpRightY ) / 470.0 ) ; image -> page . x = ( int ) ( BitmapHeader2 . LowLeftX / 470.0 ) ; image -> page . y = ( int ) ( BitmapHeader2 . LowLeftX / 470.0 ) ; if ( BitmapHeader2 . HorzRes && BitmapHeader2 . VertRes ) { image -> x_resolution = BitmapHeader2 . HorzRes / 470.0 ; image -> y_resolution = BitmapHeader2 . VertRes / 470.0 ; } image -> columns = BitmapHeader2 . Width ; image -> rows = BitmapHeader2 . Height ; bpp = BitmapHeader2 . Depth ; UnpackRaster : status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) break ; if ( ( image -> colors == 0 ) && ( bpp != 24 ) ) { image -> colors = one << bpp ; if ( ! AcquireImageColormap ( image , image -> colors ) ) { NoMemory : ThrowReaderException ( ResourceLimitError , "MemoryAllocationFailed" ) ; } for ( i = 0 ; ( i < ( int ) image -> colors ) && ( i < 256 ) ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( WPG1_Palette [ i ] . Red ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( WPG1_Palette [ i ] . Green ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( WPG1_Palette [ i ] . Blue ) ; } } else { if ( bpp < 24 ) if ( ( image -> colors < ( one << bpp ) ) && ( bpp != 24 ) ) image -> colormap = ( PixelPacket * ) ResizeQuantumMemory ( image -> colormap , ( size_t ) ( one << bpp ) , sizeof ( * image -> colormap ) ) ; } if ( bpp == 1 ) { if ( image -> colormap [ 0 ] . red == 0 && image -> colormap [ 0 ] . green == 0 && image -> colormap [ 0 ] . blue == 0 && image -> colormap [ 1 ] . red == 0 && image -> colormap [ 1 ] . green == 0 && image -> colormap [ 1 ] . blue == 0 ) { image -> colormap [ 1 ] . red = image -> colormap [ 1 ] . green = image -> colormap [ 1 ] . blue = QuantumRange ; } } if ( UnpackWPGRaster ( image , bpp ) < 0 ) { DecompressionFailed : ThrowReaderException ( CoderError , "UnableToDecompressImage" ) ; } if ( Rec . RecType == 0x14 && BitmapHeader2 . RotAngle != 0 && ! image_info -> ping ) { if ( BitmapHeader2 . RotAngle & 0x8000 ) { Image * flop_image ; flop_image = FlopImage ( image , exception ) ; if ( flop_image != ( Image * ) NULL ) { DuplicateBlob ( flop_image , image ) ; ReplaceImageInList ( & image , flop_image ) ; } } if ( BitmapHeader2 . RotAngle & 0x2000 ) { Image * flip_image ; flip_image = FlipImage ( image , exception ) ; if ( flip_image != ( Image * ) NULL ) { DuplicateBlob ( flip_image , image ) ; ReplaceImageInList ( & image , flip_image ) ; } } if ( BitmapHeader2 . RotAngle & 0x0FFF ) { Image * rotate_image ; rotate_image = RotateImage ( image , ( BitmapHeader2 . RotAngle & 0x0FFF ) , exception ) ; if ( rotate_image != ( Image * ) NULL ) { DuplicateBlob ( rotate_image , image ) ; ReplaceImageInList ( & image , rotate_image ) ; } } } AcquireNextImage ( image_info , image ) ; image -> depth = 8 ; if ( image -> next == ( Image * ) NULL ) goto Finish ; image = SyncNextImageInList ( image ) ; image -> columns = image -> rows = 1 ; image -> colors = 0 ; break ; case 0x1B : if ( Rec . RecordLength > 0x3C ) image = ExtractPostscript ( image , image_info , TellBlob ( image ) + 0x3C , ( ssize_t ) Rec . RecordLength - 0x3C , exception ) ; break ; } } break ; case 2 : ( void ) memset ( CTM , 0 , sizeof ( CTM ) ) ; StartWPG . PosSizePrecision = 0 ; while ( ! EOFBlob ( image ) ) { ( void ) SeekBlob ( image , Header . DataOffset , SEEK_SET ) ; if ( EOFBlob ( image ) ) break ; Rec2 . Class = ( i = ReadBlobByte ( image ) ) ; if ( i == EOF ) break ; Rec2 . RecType = ( i = ReadBlobByte ( image ) ) ; if ( i == EOF ) break ; Rd_WP_DWORD ( image , & Rec2 . Extension ) ; Rd_WP_DWORD ( image , & Rec2 . RecordLength ) ; if ( EOFBlob ( image ) ) break ; Header . DataOffset = TellBlob ( image ) + Rec2 . RecordLength ; switch ( Rec2 . RecType ) { case 1 : StartWPG . HorizontalUnits = ReadBlobLSBShort ( image ) ; StartWPG . VerticalUnits = ReadBlobLSBShort ( image ) ; StartWPG . PosSizePrecision = ReadBlobByte ( image ) ; break ; case 0x0C : WPG_Palette . StartIndex = ReadBlobLSBShort ( image ) ; WPG_Palette . NumOfEntries = ReadBlobLSBShort ( image ) ; if ( ( WPG_Palette . NumOfEntries - WPG_Palette . StartIndex ) > ( Rec2 . RecordLength - 2 - 2 ) / 3 ) ThrowReaderException ( CorruptImageError , "InvalidColormapIndex" ) ; image -> colors = WPG_Palette . NumOfEntries ; if ( AcquireImageColormap ( image , image -> colors ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , "MemoryAllocationFailed" ) ; for ( i = WPG_Palette . StartIndex ; i < ( int ) WPG_Palette . NumOfEntries ; i ++ ) { image -> colormap [ i ] . red = ScaleCharToQuantum ( ( char ) ReadBlobByte ( image ) ) ; image -> colormap [ i ] . green = ScaleCharToQuantum ( ( char ) ReadBlobByte ( image ) ) ; image -> colormap [ i ] . blue = ScaleCharToQuantum ( ( char ) ReadBlobByte ( image ) ) ; ( void ) ReadBlobByte ( image ) ; } break ; case 0x0E : Bitmap2Header1 . Width = ReadBlobLSBShort ( image ) ; Bitmap2Header1 . Height = ReadBlobLSBShort ( image ) ; if ( ( Bitmap2Header1 . Width == 0 ) || ( Bitmap2Header1 . Height == 0 ) ) ThrowReaderException ( CorruptImageError , "ImproperImageHeader" ) ; Bitmap2Header1 . Depth = ReadBlobByte ( image ) ; Bitmap2Header1 . Compression = ReadBlobByte ( image ) ; if ( Bitmap2Header1 . Compression > 1 ) continue ; switch ( Bitmap2Header1 . Depth ) { case 1 : bpp = 1 ; break ; case 2 : bpp = 2 ; break ; case 3 : bpp = 4 ; break ; case 4 : bpp = 8 ; break ; case 8 : bpp = 24 ; break ; default : continue ; } image -> columns = Bitmap2Header1 . Width ; image -> rows = Bitmap2Header1 . Height ; status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) break ; if ( ( image -> colors == 0 ) && ( bpp != 24 ) ) { size_t one ; one = 1 ; image -> colors = one << bpp ; if ( ! AcquireImageColormap ( image , image -> colors ) ) goto NoMemory ; } else { if ( bpp < 24 ) if ( image -> colors < ( one << bpp ) && bpp != 24 ) image -> colormap = ( PixelPacket * ) ResizeQuantumMemory ( image -> colormap , ( size_t ) ( one << bpp ) , sizeof ( * image -> colormap ) ) ; } switch ( Bitmap2Header1 . Compression ) { case 0 : { ldblk = ( ssize_t ) ( ( bpp * image -> columns + 7 ) / 8 ) ; BImgBuff = ( unsigned char * ) AcquireQuantumMemory ( ( size_t ) ldblk + 1 , sizeof ( * BImgBuff ) ) ; if ( BImgBuff == ( unsigned char * ) NULL ) goto NoMemory ; for ( i = 0 ; i < ( ssize_t ) image -> rows ; i ++ ) { ( void ) ReadBlob ( image , ldblk , BImgBuff ) ; InsertRow ( BImgBuff , i , image , bpp ) ; } if ( BImgBuff ) BImgBuff = ( unsigned char * ) RelinquishMagickMemory ( BImgBuff ) ; break ; } case 1 : { if ( UnpackWPG2Raster ( image , bpp ) < 0 ) goto DecompressionFailed ; break ; } } if ( CTM [ 0 ] [ 0 ] < 0 && ! image_info -> ping ) { Image * flop_image ; flop_image = FlopImage ( image , exception ) ; if ( flop_image != ( Image * ) NULL ) { DuplicateBlob ( flop_image , image ) ; ReplaceImageInList ( & image , flop_image ) ; } } if ( CTM [ 1 ] [ 1 ] < 0 && ! image_info -> ping ) { Image * flip_image ; flip_image = FlipImage ( image , exception ) ; if ( flip_image != ( Image * ) NULL ) { DuplicateBlob ( flip_image , image ) ; ReplaceImageInList ( & image , flip_image ) ; } } AcquireNextImage ( image_info , image ) ; image -> depth = 8 ; if ( image -> next == ( Image * ) NULL ) goto Finish ; image = SyncNextImageInList ( image ) ; image -> columns = image -> rows = 1 ; image -> colors = 0 ; break ; case 0x12 : i = ReadBlobLSBShort ( image ) ; if ( Rec2 . RecordLength > ( unsigned int ) i ) image = ExtractPostscript ( image , image_info , TellBlob ( image ) + i , ( ssize_t ) ( Rec2 . RecordLength - i - 2 ) , exception ) ; break ; case 0x1B : WPG2Flags = LoadWPG2Flags ( image , StartWPG . PosSizePrecision , NULL , & CTM ) ; ( void ) WPG2Flags ; break ; } } break ; default : { ThrowReaderException ( CoderError , "DataEncodingSchemeIsNotSupported" ) ; } } Finish : ( void ) CloseBlob ( image ) ; { Image * p ; ssize_t scene = 0 ; p = image ; image = NULL ; while ( p != ( Image * ) NULL ) { Image * tmp = p ; if ( ( p -> rows == 0 ) || ( p -> columns == 0 ) ) { p = p -> previous ; DeleteImageFromList ( & tmp ) ; } else { image = p ; p = p -> previous ; } } for ( p = image ; p != ( Image * ) NULL ; p = p -> next ) p -> scene = ( size_t ) scene ++ ; } if ( image == ( Image * ) NULL ) ThrowReaderException ( CorruptImageError , "ImageFileDoesNotContainAnyImageData" ) ; return ( image ) ; }
<S2SV_ModStart> Rec . RecordLength ) ; if ( Rec . RecordLength > GetBlobSize ( image ) ) ThrowReaderException ( CorruptImageError , "ImproperImageHeader"
9
CWE-401 int ath9k_wmi_cmd ( struct wmi * wmi , enum wmi_cmd_id cmd_id , u8 * cmd_buf , u32 cmd_len , u8 * rsp_buf , u32 rsp_len , u32 timeout ) { struct ath_hw * ah = wmi -> drv_priv -> ah ; struct ath_common * common = ath9k_hw_common ( ah ) ; u16 headroom = sizeof ( struct htc_frame_hdr ) + sizeof ( struct wmi_cmd_hdr ) ; struct sk_buff * skb ; unsigned long time_left ; int ret = 0 ; if ( ah -> ah_flags & AH_UNPLUGGED ) return 0 ; skb = alloc_skb ( headroom + cmd_len , GFP_ATOMIC ) ; if ( ! skb ) return - ENOMEM ; skb_reserve ( skb , headroom ) ; if ( cmd_len != 0 && cmd_buf != NULL ) { skb_put_data ( skb , cmd_buf , cmd_len ) ; } mutex_lock ( & wmi -> op_mutex ) ; if ( unlikely ( wmi -> stopped ) ) { ret = - EPROTO ; goto out ; } wmi -> cmd_rsp_buf = rsp_buf ; wmi -> cmd_rsp_len = rsp_len ; ret = ath9k_wmi_cmd_issue ( wmi , skb , cmd_id , cmd_len ) ; if ( ret ) goto out ; time_left = wait_for_completion_timeout ( & wmi -> cmd_wait , timeout ) ; if ( ! time_left ) { ath_dbg ( common , WMI , "Timeout<S2SV_blank>waiting<S2SV_blank>for<S2SV_blank>WMI<S2SV_blank>command:<S2SV_blank>%s\\n" , wmi_cmd_to_name ( cmd_id ) ) ; mutex_unlock ( & wmi -> op_mutex <S2SV_StartBug> ) ; return - <S2SV_EndBug> ETIMEDOUT ; } mutex_unlock ( & wmi -> op_mutex ) ; return 0 ; out : ath_dbg ( common , WMI , "WMI<S2SV_blank>failure<S2SV_blank>for:<S2SV_blank>%s\\n" , wmi_cmd_to_name ( cmd_id ) ) ; mutex_unlock ( & wmi -> op_mutex ) ; kfree_skb ( skb ) ; return ret ; }
<S2SV_ModStart> op_mutex ) ; kfree_skb ( skb ) ;
10
CWE-269 qboolean S_AL_Init ( soundInterface_t * si ) { # ifdef USE_OPENAL const char * device = NULL ; const char * inputdevice = NULL ; int i ; if ( ! si ) { return qfalse ; } for ( i = 0 ; i < MAX_RAW_STREAMS ; i ++ ) { streamSourceHandles [ i ] = - 1 ; streamPlaying [ i ] = qfalse ; streamSources [ i ] = 0 ; streamNumBuffers [ i ] = 0 ; streamBufIndex [ i ] = 0 ; } s_alPrecache = Cvar_Get ( "s_alPrecache" , "1" , CVAR_ARCHIVE ) ; s_alGain = Cvar_Get ( "s_alGain" , "1.0" , CVAR_ARCHIVE ) ; s_alSources = Cvar_Get ( "s_alSources" , "96" , CVAR_ARCHIVE ) ; s_alDopplerFactor = Cvar_Get ( "s_alDopplerFactor" , "1.0" , CVAR_ARCHIVE ) ; s_alDopplerSpeed = Cvar_Get ( "s_alDopplerSpeed" , "9000" , CVAR_ARCHIVE ) ; s_alMinDistance = Cvar_Get ( "s_alMinDistance" , "120" , CVAR_CHEAT ) ; s_alMaxDistance = Cvar_Get ( "s_alMaxDistance" , "1024" , CVAR_CHEAT ) ; s_alRolloff = Cvar_Get ( "s_alRolloff" , "2" , CVAR_CHEAT ) ; s_alGraceDistance = Cvar_Get ( "s_alGraceDistance" , "512" <S2SV_StartBug> , CVAR_CHEAT ) ; s_alDriver = Cvar_Get ( "s_alDriver" , ALDRIVER_DEFAULT , CVAR_ARCHIVE | CVAR_LATCH ) ; s_alInputDevice = Cvar_Get <S2SV_EndBug> ( "s_alInputDevice" , "" , CVAR_ARCHIVE | CVAR_LATCH ) ; s_alDevice = Cvar_Get ( <S2SV_StartBug> "s_alDevice" , "" , CVAR_ARCHIVE | CVAR_LATCH ) ; if ( ! QAL_Init ( <S2SV_EndBug> s_alDriver -> string ) ) { Com_Printf ( "Failed<S2SV_blank>to<S2SV_blank>load<S2SV_blank>library:<S2SV_blank>\\"%s\\".\\n" , s_alDriver -> string ) ; if ( ! Q_stricmp ( s_alDriver -> string , ALDRIVER_DEFAULT ) || ! QAL_Init ( ALDRIVER_DEFAULT ) ) { return qfalse ; } } device = s_alDevice -> string ; if ( device && ! * device ) device = NULL ; inputdevice = s_alInputDevice -> string ; if ( inputdevice && ! * inputdevice ) inputdevice = NULL ; enumeration_all_ext = qalcIsExtensionPresent ( NULL , "ALC_ENUMERATE_ALL_EXT" ) ; enumeration_ext = qalcIsExtensionPresent ( NULL , "ALC_ENUMERATION_EXT" ) ; if ( enumeration_ext || enumeration_all_ext ) { char devicenames [ 16384 ] = "" ; const char * devicelist ; # ifdef _WIN32 const char * defaultdevice ; # endif int curlen ; if ( enumeration_all_ext ) { devicelist = qalcGetString ( NULL , ALC_ALL_DEVICES_SPECIFIER ) ; # ifdef _WIN32 defaultdevice = qalcGetString ( NULL , ALC_DEFAULT_ALL_DEVICES_SPECIFIER ) ; # endif } else { devicelist = qalcGetString ( NULL , ALC_DEVICE_SPECIFIER ) ; # ifdef _WIN32 defaultdevice = qalcGetString ( NULL , ALC_DEFAULT_DEVICE_SPECIFIER ) ; # endif enumeration_ext = qtrue ; } # ifdef _WIN32 if ( ! device && defaultdevice && ! strcmp ( defaultdevice , "Generic<S2SV_blank>Hardware" ) ) device = "Generic<S2SV_blank>Software" ; # endif if ( devicelist ) { while ( ( curlen = strlen ( devicelist ) ) ) { Q_strcat ( devicenames , sizeof ( devicenames ) , devicelist ) ; Q_strcat ( devicenames , sizeof ( devicenames ) , "\\n" ) ; devicelist += curlen + 1 ; } } s_alAvailableDevices = Cvar_Get ( "s_alAvailableDevices" , devicenames , CVAR_ROM | CVAR_NORESTART ) ; } alDevice = qalcOpenDevice ( device ) ; if ( ! alDevice && device ) { Com_Printf ( "Failed<S2SV_blank>to<S2SV_blank>open<S2SV_blank>OpenAL<S2SV_blank>device<S2SV_blank>\'%s\',<S2SV_blank>trying<S2SV_blank>default.\\n" , device ) ; alDevice = qalcOpenDevice ( NULL ) ; } if ( ! alDevice ) { QAL_Shutdown ( ) ; Com_Printf ( "Failed<S2SV_blank>to<S2SV_blank>open<S2SV_blank>OpenAL<S2SV_blank>device.\\n" ) ; return qfalse ; } alContext = qalcCreateContext ( alDevice , NULL ) ; if ( ! alContext ) { QAL_Shutdown ( ) ; qalcCloseDevice ( alDevice ) ; Com_Printf ( "Failed<S2SV_blank>to<S2SV_blank>create<S2SV_blank>OpenAL<S2SV_blank>context.\\n" ) ; return qfalse ; } qalcMakeContextCurrent ( alContext ) ; S_AL_BufferInit ( ) ; S_AL_SrcInit ( ) ; qalDistanceModel ( AL_INVERSE_DISTANCE_CLAMPED ) ; qalDopplerFactor ( s_alDopplerFactor -> value ) ; qalSpeedOfSound ( s_alDopplerSpeed -> value ) ; # ifdef USE_VOIP s_alCapture = Cvar_Get ( "s_alCapture" , "1" , CVAR_ARCHIVE | CVAR_LATCH ) ; if ( ! s_alCapture -> integer ) { Com_Printf ( "OpenAL<S2SV_blank>capture<S2SV_blank>support<S2SV_blank>disabled<S2SV_blank>by<S2SV_blank>user<S2SV_blank>(\'+set<S2SV_blank>s_alCapture<S2SV_blank>1\'<S2SV_blank>to<S2SV_blank>enable)\\n" ) ; } # if USE_MUMBLE else if ( cl_useMumble -> integer ) { Com_Printf ( "OpenAL<S2SV_blank>capture<S2SV_blank>support<S2SV_blank>disabled<S2SV_blank>for<S2SV_blank>Mumble<S2SV_blank>support\\n" ) ; } # endif else { # ifdef __APPLE__ if ( qalcCaptureOpenDevice == NULL ) # else if ( ! qalcIsExtensionPresent ( NULL , "ALC_EXT_capture" ) ) # endif { Com_Printf ( "No<S2SV_blank>ALC_EXT_capture<S2SV_blank>support,<S2SV_blank>can\'t<S2SV_blank>record<S2SV_blank>audio.\\n" ) ; } else { char inputdevicenames [ 16384 ] = "" ; const char * inputdevicelist ; const char * defaultinputdevice ; int curlen ; capture_ext = qtrue ; inputdevicelist = qalcGetString ( NULL , ALC_CAPTURE_DEVICE_SPECIFIER ) ; defaultinputdevice = qalcGetString ( NULL , ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER ) ; if ( inputdevicelist ) { while ( ( curlen = strlen ( inputdevicelist ) ) ) { Q_strcat ( inputdevicenames , sizeof ( inputdevicenames ) , inputdevicelist ) ; Q_strcat ( inputdevicenames , sizeof ( inputdevicenames ) , "\\n" ) ; inputdevicelist += curlen + 1 ; } } s_alAvailableInputDevices = Cvar_Get ( "s_alAvailableInputDevices" , inputdevicenames , CVAR_ROM | CVAR_NORESTART ) ; Com_Printf ( "OpenAL<S2SV_blank>default<S2SV_blank>capture<S2SV_blank>device<S2SV_blank>is<S2SV_blank>\'%s\'\\n" , defaultinputdevice ? defaultinputdevice : "none" ) ; alCaptureDevice = qalcCaptureOpenDevice ( inputdevice , 48000 , AL_FORMAT_MONO16 , VOIP_MAX_PACKET_SAMPLES * 4 ) ; if ( ! alCaptureDevice && inputdevice ) { Com_Printf ( "Failed<S2SV_blank>to<S2SV_blank>open<S2SV_blank>OpenAL<S2SV_blank>Input<S2SV_blank>device<S2SV_blank>\'%s\',<S2SV_blank>trying<S2SV_blank>default.\\n" , inputdevice ) ; alCaptureDevice = qalcCaptureOpenDevice ( NULL , 48000 , AL_FORMAT_MONO16 , VOIP_MAX_PACKET_SAMPLES * 4 ) ; } Com_Printf ( "OpenAL<S2SV_blank>capture<S2SV_blank>device<S2SV_blank>%s.\\n" , ( alCaptureDevice == NULL ) ? "failed<S2SV_blank>to<S2SV_blank>open" : "opened" ) ; } } # endif si -> Shutdown = S_AL_Shutdown ; si -> StartSound = S_AL_StartSound ; si -> StartLocalSound = S_AL_StartLocalSound ; si -> StartBackgroundTrack = S_AL_StartBackgroundTrack ; si -> StopBackgroundTrack = S_AL_StopBackgroundTrack ; si -> RawSamples = S_AL_RawSamples ; si -> StopAllSounds = S_AL_StopAllSounds ; si -> ClearLoopingSounds = S_AL_ClearLoopingSounds ; si -> AddLoopingSound = S_AL_AddLoopingSound ; si -> AddRealLoopingSound = S_AL_AddRealLoopingSound ; si -> StopLoopingSound = S_AL_StopLoopingSound ; si -> Respatialize = S_AL_Respatialize ; si -> UpdateEntityPosition = S_AL_UpdateEntityPosition ; si -> Update = S_AL_Update ; si -> DisableSounds = S_AL_DisableSounds ; si -> BeginRegistration = S_AL_BeginRegistration ; si -> RegisterSound = S_AL_RegisterSound ; si -> ClearSoundBuffer = S_AL_ClearSoundBuffer ; si -> SoundInfo = S_AL_SoundInfo ; si -> SoundList = S_AL_SoundList ; # ifdef USE_VOIP si -> StartCapture = S_AL_StartCapture ; si -> AvailableCaptureSamples = S_AL_AvailableCaptureSamples ; si -> Capture = S_AL_Capture ; si -> StopCapture = S_AL_StopCapture ; si -> MasterGain = S_AL_MasterGain ; # endif return qtrue ; # else return qfalse ; # endif }
<S2SV_ModStart> CVAR_ARCHIVE | CVAR_LATCH | CVAR_PROTECTED <S2SV_ModStart> CVAR_LATCH ) ; if ( COM_CompareExtension ( s_alDriver -> string , ".pk3" ) ) { Com_Printf ( "Rejecting<S2SV_blank>DLL<S2SV_blank>named<S2SV_blank>\\"%s\\"" , s_alDriver -> string ) ; return qfalse ; }
11
CWE-399 static int yam_ioctl ( struct net_device * dev , struct ifreq * ifr , int cmd ) { struct yam_port * yp = netdev_priv ( dev ) ; struct yamdrv_ioctl_cfg yi ; struct yamdrv_ioctl_mcs * ym ; int ioctl_cmd ; if ( copy_from_user ( & ioctl_cmd , ifr -> ifr_data , sizeof ( int ) ) ) return - EFAULT ; if ( yp -> magic != YAM_MAGIC ) return - EINVAL ; if ( ! capable ( CAP_NET_ADMIN ) ) return - EPERM ; if ( cmd != SIOCDEVPRIVATE ) return - EINVAL ; switch ( ioctl_cmd ) { case SIOCYAMRESERVED : return - EINVAL ; case SIOCYAMSMCS : if ( netif_running ( dev ) ) return - EINVAL ; if ( ( ym = kmalloc ( sizeof ( struct yamdrv_ioctl_mcs ) , GFP_KERNEL ) ) == NULL ) return - ENOBUFS ; if ( copy_from_user ( ym , ifr -> ifr_data , sizeof ( struct yamdrv_ioctl_mcs ) ) ) { kfree ( ym ) ; return - EFAULT ; } if ( ym -> bitrate > YAM_MAXBITRATE ) { kfree ( ym ) ; return - EINVAL ; } add_mcs ( ym -> bits , ym -> bitrate , 0 ) ; kfree ( ym ) ; break ; case SIOCYAMSCFG : if ( ! capable ( CAP_SYS_RAWIO ) ) return - EPERM ; if ( copy_from_user ( & yi , ifr -> ifr_data , sizeof ( struct yamdrv_ioctl_cfg ) ) ) return - EFAULT ; if ( ( yi . cfg . mask & YAM_IOBASE ) && netif_running ( dev ) ) return - EINVAL ; if ( ( yi . cfg . mask & YAM_IRQ ) && netif_running ( dev ) ) return - EINVAL ; if ( ( yi . cfg . mask & YAM_BITRATE ) && netif_running ( dev ) ) return - EINVAL ; if ( ( yi . cfg . mask & YAM_BAUDRATE ) && netif_running ( dev ) ) return - EINVAL ; if ( yi . cfg . mask & YAM_IOBASE ) { yp -> iobase = yi . cfg . iobase ; dev -> base_addr = yi . cfg . iobase ; } if ( yi . cfg . mask & YAM_IRQ ) { if ( yi . cfg . irq > 15 ) return - EINVAL ; yp -> irq = yi . cfg . irq ; dev -> irq = yi . cfg . irq ; } if ( yi . cfg . mask & YAM_BITRATE ) { if ( yi . cfg . bitrate > YAM_MAXBITRATE ) return - EINVAL ; yp -> bitrate = yi . cfg . bitrate ; } if ( yi . cfg . mask & YAM_BAUDRATE ) { if ( yi . cfg . baudrate > YAM_MAXBAUDRATE ) return - EINVAL ; yp -> baudrate = yi . cfg . baudrate ; } if ( yi . cfg . mask & YAM_MODE ) { if ( yi . cfg . mode > YAM_MAXMODE ) return - EINVAL ; yp -> dupmode = yi . cfg . mode ; } if ( yi . cfg . mask & YAM_HOLDDLY ) { if ( yi . cfg . holddly > YAM_MAXHOLDDLY ) return - EINVAL ; yp -> holdd = yi . cfg . holddly ; } if ( yi . cfg . mask & YAM_TXDELAY ) { if ( yi . cfg . txdelay > YAM_MAXTXDELAY ) return - EINVAL ; yp -> txd = yi . cfg . txdelay ; } if ( yi . cfg . mask & YAM_TXTAIL ) { if ( yi . cfg . txtail > YAM_MAXTXTAIL ) return - EINVAL ; yp -> txtail = yi . cfg . txtail ; } if ( yi . cfg . mask & YAM_PERSIST ) { if ( yi . cfg . persist > YAM_MAXPERSIST ) return - EINVAL ; yp -> pers = yi . cfg . persist ; } if ( yi . cfg . mask & YAM_SLOTTIME ) { if ( yi . cfg . slottime > YAM_MAXSLOTTIME ) return - EINVAL ; yp -> slot = yi . cfg . slottime ; yp -> slotcnt = yp -> slot / 10 ; } break ; case <S2SV_StartBug> SIOCYAMGCFG : yi . cfg . <S2SV_EndBug> mask = 0xffffffff ; yi . cfg . iobase = yp -> iobase ; yi . cfg . irq = yp -> irq ; yi . cfg . bitrate = yp -> bitrate ; yi . cfg . baudrate = yp -> baudrate ; yi . cfg . mode = yp -> dupmode ; yi . cfg . txdelay = yp -> txd ; yi . cfg . holddly = yp -> holdd ; yi . cfg . txtail = yp -> txtail ; yi . cfg . persist = yp -> pers ; yi . cfg . slottime = yp -> slot ; if ( copy_to_user ( ifr -> ifr_data , & yi , sizeof ( struct yamdrv_ioctl_cfg ) ) ) return - EFAULT ; break ; default : return - EINVAL ; } return 0 ; }
<S2SV_ModStart> case SIOCYAMGCFG : memset ( & yi , 0 , sizeof ( yi ) ) ;
12
CWE-78 static int r_core_cmd_subst_i ( RCore * core , char * cmd , char * colon , bool * tmpseek ) { RList * tmpenvs = r_list_newf ( tmpenvs_free ) ; const char * quotestr = "`" ; const char * tick = NULL ; char * ptr , * ptr2 , * str ; char * arroba = NULL ; char * grep = NULL ; RIODesc * tmpdesc = NULL ; int pamode = ! core -> io -> va ; int i , ret = 0 , pipefd ; bool usemyblock = false ; int scr_html = - 1 ; int scr_color = - 1 ; bool eos = false ; bool haveQuote = false ; bool oldfixedarch = core -> fixedarch ; bool oldfixedbits = core -> fixedbits ; bool cmd_tmpseek = false ; ut64 tmpbsz = core -> blocksize ; int cmd_ignbithints = - 1 ; if ( ! cmd ) { r_list_free ( tmpenvs ) ; return 0 ; } cmd = r_str_trim_head_tail ( cmd ) ; char * $0 = strstr ( cmd , "$(" ) ; if ( $0 ) { char * $1 = strchr ( $0 + 2 , ')' ) ; if ( $1 ) { * $0 = '`' ; * $1 = '`' ; memmove ( $0 + 1 , $0 + 2 , strlen ( $0 + 2 ) + 1 ) ; } else { eprintf ( "Unterminated<S2SV_blank>$()<S2SV_blank>block\\n" ) ; } } switch ( * cmd ) { case '.' : if ( cmd [ 1 ] == \'"\' ) { r_list_free ( tmpenvs ) ; return r_cmd_call ( core -> rcmd , cmd ) ; } break ; case \'"\' : for ( ; * cmd ; ) { int pipefd = - 1 ; ut64 oseek = UT64_MAX ; char * line , * p ; haveQuote = * cmd == \'"\' ; if ( haveQuote ) { cmd ++ ; p = * cmd ? find_eoq ( cmd ) : NULL ; if ( ! p || ! * p ) { eprintf ( "Missing<S2SV_blank>\\"<S2SV_blank>in<S2SV_blank>(%s)." , cmd ) ; r_list_free ( tmpenvs ) ; return false ; } * p ++ = 0 ; if ( ! * p ) { eos = true ; } } else { char * sc = strchr ( cmd , ';' ) ; if ( sc ) { * sc = 0 ; } r_core_cmd0 ( core , cmd ) ; if ( ! sc ) { break ; } cmd = sc + 1 ; continue <S2SV_StartBug> ; } if ( * p ) { if ( p <S2SV_EndBug> [ 0 ] == '@' ) { p -- ; } while ( p [ 1 ] == ';' || IS_WHITESPACE ( p [ 1 ] ) ) { p ++ ; } if ( p [ 1 ] == '@' || ( p [ 1 ] && p [ 2 ] == '@' ) ) { char * q = strchr ( p + 1 , \'"\' ) ; <S2SV_StartBug> if ( q ) { * q = 0 ; } haveQuote = <S2SV_EndBug> q != NULL ; oseek = core -> offset ; r_core_seek ( core , r_num_math ( core -> num , p + 2 ) , 1 ) ; if ( q ) { * p = \'"\' ; p = q ; } else { p = strchr ( p + 1 , ';' ) ; } } if ( p && * p && p [ 1 ] == '>' ) { str = p + 2 ; while ( * str == '>' ) { str ++ ; } str = ( char * ) r_str_trim_ro ( str ) ; r_cons_flush ( ) ; const bool append = p [ 2 ] == '>' ; pipefd = r_cons_pipe_open ( str , 1 , append ) ; } } line = strdup ( cmd ) ; line = r_str_replace ( line , "\\\\\\"" , "\\"" , true ) ; if ( p && * p && p [ 1 ] == '|' ) { str = p + 2 ; while ( IS_WHITESPACE ( * str ) ) { str ++ ; } r_core_cmd_pipe ( core , cmd , str ) ; } else { r_cmd_call ( core -> rcmd , line ) ; } free ( line ) ; if ( oseek != UT64_MAX ) { r_core_seek ( core , oseek , 1 ) ; } if ( pipefd != - 1 ) { r_cons_flush ( ) ; r_cons_pipe_close ( pipefd ) ; } if ( ! p ) { break ; } if ( eos ) { break ; } if ( haveQuote ) { if ( * p == ';' ) { cmd = p + 1 ; } else { if ( * p == \'"\' ) { <S2SV_StartBug> cmd = p + 1 ; } else { <S2SV_StartBug> <S2SV_EndBug> * <S2SV_EndBug> p = \'"\' ; cmd = p ; } } } else { cmd = p + 1 ; } } r_list_free ( tmpenvs ) ; return true ; case '(' : if ( cmd [ 1 ] != '*' && ! strstr ( cmd , ")()" ) ) { r_list_free ( tmpenvs ) ; return r_cmd_call ( core -> rcmd , cmd ) ; } break ; case '?' : if ( cmd [ 1 ] == '>' ) { r_core_cmd_help ( core , help_msg_greater_sign ) ; r_list_free ( tmpenvs ) ; return true ; } } if ( * cmd != '#' ) { ptr = ( char * ) r_str_firstbut ( cmd , '#' , "`\\"" ) ; if ( ptr && ( ptr [ 1 ] == '<S2SV_blank>' || ptr [ 1 ] == '\\t' ) ) { * ptr = '\\0' ; } } if ( * cmd != '#' ) { ptr = ( char * ) r_str_lastbut ( cmd , ';' , quotestr ) ; if ( colon && ptr ) { int ret ; * ptr = '\\0' ; if ( r_core_cmd_subst ( core , cmd ) == - 1 ) { r_list_free ( tmpenvs ) ; return - 1 ; } cmd = ptr + 1 ; ret = r_core_cmd_subst ( core , cmd ) ; * ptr = ';' ; r_list_free ( tmpenvs ) ; return ret ; } } ptr = ( char * ) r_str_lastbut ( cmd , '|' , quotestr ) ; if ( ptr ) { if ( ptr > cmd ) { char * ch = ptr - 1 ; if ( * ch == '\\\\' ) { memmove ( ch , ptr , strlen ( ptr ) + 1 ) ; goto escape_pipe ; } } char * ptr2 = strchr ( cmd , '`' ) ; if ( ! ptr2 || ( ptr2 && ptr2 > ptr ) ) { if ( ! tick || ( tick && tick > ptr ) ) { * ptr = '\\0' ; cmd = r_str_trim_nc ( cmd ) ; if ( ! strcmp ( ptr + 1 , "?" ) ) { r_core_cmd_help ( core , help_msg_vertical_bar ) ; r_list_free ( tmpenvs ) ; return ret ; } else if ( ! strncmp ( ptr + 1 , "H" , 1 ) ) { scr_html = r_config_get_i ( core -> config , "scr.html" ) ; r_config_set_i ( core -> config , "scr.html" , true ) ; } else if ( ! strcmp ( ptr + 1 , "T" ) ) { scr_color = r_config_get_i ( core -> config , "scr.color" ) ; r_config_set_i ( core -> config , "scr.color" , COLOR_MODE_DISABLED ) ; core -> cons -> use_tts = true ; } else if ( ! strcmp ( ptr + 1 , "." ) ) { ret = * cmd ? r_core_cmdf ( core , ".%s" , cmd ) : 0 ; r_list_free ( tmpenvs ) ; return ret ; } else if ( ptr [ 1 ] ) { int value = core -> num -> value ; if ( * cmd ) { r_core_cmd_pipe ( core , cmd , ptr + 1 ) ; } else { char * res = r_io_system ( core -> io , ptr + 1 ) ; if ( res ) { r_cons_printf ( "%s\\n" , res ) ; free ( res ) ; } } core -> num -> value = value ; r_list_free ( tmpenvs ) ; return 0 ; } else { scr_html = r_config_get_i ( core -> config , "scr.html" ) ; r_config_set_i ( core -> config , "scr.html" , 0 ) ; scr_color = r_config_get_i ( core -> config , "scr.color" ) ; r_config_set_i ( core -> config , "scr.color" , COLOR_MODE_DISABLED ) ; } } } } escape_pipe : ptr = ( char * ) r_str_lastbut ( cmd , '&' , quotestr ) ; while ( ptr && * ptr && ptr [ 1 ] == '&' ) { * ptr = '\\0' ; ret = r_cmd_call ( core -> rcmd , cmd ) ; if ( ret == - 1 ) { eprintf ( "command<S2SV_blank>error(%s)\\n" , cmd ) ; if ( scr_html != - 1 ) { r_config_set_i ( core -> config , "scr.html" , scr_html ) ; } if ( scr_color != - 1 ) { r_config_set_i ( core -> config , "scr.color" , scr_color ) ; } r_list_free ( tmpenvs ) ; return ret ; } for ( cmd = ptr + 2 ; cmd && * cmd == '<S2SV_blank>' ; cmd ++ ) { ; } ptr = strchr ( cmd , '&' ) ; } R_FREE ( core -> oobi ) ; ptr = strstr ( cmd , "?*" ) ; if ( ptr && ( ptr == cmd || ptr [ - 1 ] != '~' ) ) { ptr [ 0 ] = 0 ; if ( * cmd != '#' ) { int detail = 0 ; if ( cmd < ptr && ptr [ - 1 ] == '?' ) { detail ++ ; if ( cmd < ptr - 1 && ptr [ - 2 ] == '?' ) { detail ++ ; } } r_cons_break_push ( NULL , NULL ) ; recursive_help ( core , detail , cmd ) ; r_cons_break_pop ( ) ; r_cons_grep_parsecmd ( ptr + 2 , "`" ) ; if ( scr_html != - 1 ) { r_config_set_i ( core -> config , "scr.html" , scr_html ) ; } if ( scr_color != - 1 ) { r_config_set_i ( core -> config , "scr.color" , scr_color ) ; } r_list_free ( tmpenvs ) ; return 0 ; } } # if 0 ptr = strchr ( cmd , '<' ) ; if ( ptr ) { ptr [ 0 ] = '\\0' ; if ( r_cons_singleton ( ) -> is_interactive ) { if ( ptr [ 1 ] == '<' ) { for ( str = ptr + 2 ; str [ 0 ] == '<S2SV_blank>' ; str ++ ) { } eprintf ( "==><S2SV_blank>Reading<S2SV_blank>from<S2SV_blank>stdin<S2SV_blank>until<S2SV_blank>\'%s\'\\n" , str ) ; free ( core -> oobi ) ; core -> oobi = malloc ( 1 ) ; if ( core -> oobi ) { core -> oobi [ 0 ] = '\\0' ; } core -> oobi_len = 0 ; for ( ; ; ) { char buf [ 1024 ] ; int ret ; write ( 1 , "><S2SV_blank>" , 2 ) ; fgets ( buf , sizeof ( buf ) - 1 , stdin ) ; if ( feof ( stdin ) ) { break ; } if ( * buf ) buf [ strlen ( buf ) - 1 ] = '\\0' ; ret = strlen ( buf ) ; core -> oobi_len += ret ; core -> oobi = realloc ( core -> oobi , core -> oobi_len + 1 ) ; if ( core -> oobi ) { if ( ! strcmp ( buf , str ) ) { break ; } strcat ( ( char * ) core -> oobi , buf ) ; } } } else { for ( str = ptr + 1 ; * str == '<S2SV_blank>' ; str ++ ) { } if ( ! * str ) { goto next ; } eprintf ( "Slurping<S2SV_blank>file<S2SV_blank>\'%s\'\\n" , str ) ; free ( core -> oobi ) ; core -> oobi = ( ut8 * ) r_file_slurp ( str , & core -> oobi_len ) ; if ( ! core -> oobi ) { eprintf ( "cannot<S2SV_blank>open<S2SV_blank>file\\n" ) ; } else if ( ptr == cmd ) { return r_core_cmd_buffer ( core , ( const char * ) core -> oobi ) ; } } } else { eprintf ( "Cannot<S2SV_blank>slurp<S2SV_blank>with<S2SV_blank><<<S2SV_blank>in<S2SV_blank>non-interactive<S2SV_blank>mode\\n" ) ; r_list_free ( tmpenvs ) ; return 0 ; } } next : # endif ptr = ( char * ) r_str_firstbut ( cmd , '>' , "\\"" ) ; if ( ptr ) { if ( ptr > cmd ) { char * ch = ptr - 1 ; if ( * ch == '\\\\' ) { memmove ( ch , ptr , strlen ( ptr ) + 1 ) ; goto escape_redir ; } } if ( ptr [ 0 ] && ptr [ 1 ] == '?' ) { r_core_cmd_help ( core , help_msg_greater_sign ) ; r_list_free ( tmpenvs ) ; return true ; } int fdn = 1 ; int pipecolor = r_config_get_i ( core -> config , "scr.color.pipe" ) ; int use_editor = false ; int ocolor = r_config_get_i ( core -> config , "scr.color" ) ; * ptr = '\\0' ; str = r_str_trim_head_tail ( ptr + 1 + ( ptr [ 1 ] == '>' ) ) ; if ( ! * str ) { eprintf ( "No<S2SV_blank>output?\\n" ) ; goto next2 ; } if ( ptr > ( cmd + 1 ) && IS_WHITECHAR ( ptr [ - 2 ] ) ) { char * fdnum = ptr - 1 ; if ( * fdnum == 'H' ) { scr_html = r_config_get_i ( core -> config , "scr.html" ) ; r_config_set_i ( core -> config , "scr.html" , true ) ; pipecolor = true ; * fdnum = 0 ; } else { if ( IS_DIGIT ( * fdnum ) ) { fdn = * fdnum - '0' ; } * fdnum = 0 ; } } r_cons_set_interactive ( false ) ; if ( ! strcmp ( str , "-" ) ) { use_editor = true ; str = r_file_temp ( "dumpedit" ) ; r_config_set_i ( core -> config , "scr.color" , COLOR_MODE_DISABLED ) ; } const bool appendResult = ( ptr [ 1 ] == '>' ) ; if ( * str == '$' ) { char * o = r_core_cmd_str ( core , cmd ) ; if ( appendResult ) { char * oldText = r_cmd_alias_get ( core -> rcmd , str , 1 ) ; if ( oldText ) { char * two = r_str_newf ( "%s%s" , oldText , o ) ; if ( two ) { r_cmd_alias_set ( core -> rcmd , str , two , 1 ) ; free ( two ) ; } } else { char * n = r_str_newf ( "$%s" , o ) ; r_cmd_alias_set ( core -> rcmd , str , n , 1 ) ; free ( n ) ; } } else { char * n = r_str_newf ( "$%s" , o ) ; r_cmd_alias_set ( core -> rcmd , str , n , 1 ) ; free ( n ) ; } ret = 0 ; free ( o ) ; } else if ( fdn > 0 ) { pipefd = r_cons_pipe_open ( str , fdn , appendResult ) ; if ( pipefd != - 1 ) { if ( ! pipecolor ) { r_config_set_i ( core -> config , "scr.color" , COLOR_MODE_DISABLED ) ; } ret = r_core_cmd_subst ( core , cmd ) ; r_cons_flush ( ) ; r_cons_pipe_close ( pipefd ) ; } } r_cons_set_last_interactive ( ) ; if ( ! pipecolor ) { r_config_set_i ( core -> config , "scr.color" , ocolor ) ; } if ( use_editor ) { const char * editor = r_config_get ( core -> config , "cfg.editor" ) ; if ( editor && * editor ) { r_sys_cmdf ( "%s<S2SV_blank>\'%s\'" , editor , str ) ; r_file_rm ( str ) ; } else { eprintf ( "No<S2SV_blank>cfg.editor<S2SV_blank>configured\\n" ) ; } r_config_set_i ( core -> config , "scr.color" , ocolor ) ; free ( str ) ; } if ( scr_html != - 1 ) { r_config_set_i ( core -> config , "scr.html" , scr_html ) ; } if ( scr_color != - 1 ) { r_config_set_i ( core -> config , "scr.color" , scr_color ) ; } core -> cons -> use_tts = false ; r_list_free ( tmpenvs ) ; return ret ; } escape_redir : next2 : ptr = strchr ( cmd , '`' ) ; if ( ptr ) { if ( ptr > cmd ) { char * ch = ptr - 1 ; if ( * ch == '\\\\' ) { memmove ( ch , ptr , strlen ( ptr ) + 1 ) ; goto escape_backtick ; } } bool empty = false ; int oneline = 1 ; if ( ptr [ 1 ] == '`' ) { memmove ( ptr , ptr + 1 , strlen ( ptr ) ) ; oneline = 0 ; empty = true ; } ptr2 = strchr ( ptr + 1 , '`' ) ; if ( empty ) { } else if ( ! ptr2 ) { eprintf ( "parse:<S2SV_blank>Missing<S2SV_blank>backtick<S2SV_blank>in<S2SV_blank>expression.\\n" ) ; goto fail ; } else { int value = core -> num -> value ; * ptr = '\\0' ; * ptr2 = '\\0' ; if ( ptr [ 1 ] == '!' ) { str = r_core_cmd_str_pipe ( core , ptr + 1 ) ; } else { int ocolor = r_config_get_i ( core -> config , "scr.color" ) ; r_config_set_i ( core -> config , "scr.color" , 0 ) ; core -> cmd_in_backticks = true ; str = r_core_cmd_str ( core , ptr + 1 ) ; core -> cmd_in_backticks = false ; r_config_set_i ( core -> config , "scr.color" , ocolor ) ; } if ( ! str ) { goto fail ; } if ( * str == '|' || * str == '*' ) { eprintf ( "r_core_cmd_subst_i:<S2SV_blank>invalid<S2SV_blank>backticked<S2SV_blank>command\\n" ) ; free ( str ) ; goto fail ; } if ( oneline && str ) { for ( i = 0 ; str [ i ] ; i ++ ) { if ( str [ i ] == '\\n' ) { str [ i ] = '<S2SV_blank>' ; } } } str = r_str_append ( str , ptr2 + 1 ) ; cmd = r_str_append ( strdup ( cmd ) , str ) ; core -> num -> value = value ; ret = r_core_cmd_subst ( core , cmd ) ; free ( cmd ) ; if ( scr_html != - 1 ) { r_config_set_i ( core -> config , "scr.html" , scr_html ) ; } free ( str ) ; r_list_free ( tmpenvs ) ; return ret ; } } escape_backtick : if ( * cmd != \'"\' && * cmd ) { const char * s = strstr ( cmd , "~?" ) ; if ( s ) { bool showHelp = false ; if ( cmd == s ) { showHelp = true ; } else { if ( ! strcmp ( s , "~??" ) ) { showHelp = true ; } } if ( showHelp ) { r_cons_grep_help ( ) ; r_list_free ( tmpenvs ) ; return true ; } } } if ( * cmd != '.' ) { grep = r_cons_grep_strip ( cmd , quotestr ) ; } if ( * cmd != \'"\' ) { ptr = strchr ( cmd , '@' ) ; if ( ptr == cmd + 1 && * cmd == '?' ) { ptr = NULL ; } } else { ptr = NULL ; } cmd_tmpseek = core -> tmpseek = ptr ? true : false ; int rc = 0 ; if ( ptr ) { char * f , * ptr2 = strchr ( ptr + 1 , '!' ) ; ut64 addr = core -> offset ; bool addr_is_set = false ; char * tmpbits = NULL ; const char * offstr = NULL ; bool is_bits_set = false ; bool is_arch_set = false ; char * tmpeval = NULL ; char * tmpasm = NULL ; bool flgspc_changed = false ; int tmpfd = - 1 ; int sz , len ; ut8 * buf ; * ptr ++ = '\\0' ; repeat_arroba : arroba = ( ptr [ 0 ] && ptr [ 1 ] && ptr [ 2 ] ) ? strchr ( ptr + 2 , '@' ) : NULL ; if ( arroba ) { * arroba = 0 ; } for ( ; * ptr == '<S2SV_blank>' ; ptr ++ ) { } if ( * ptr && ptr [ 1 ] == ':' ) { } else { ptr -- ; } ptr = r_str_trim_tail ( ptr ) ; if ( ptr [ 1 ] == '?' ) { r_core_cmd_help ( core , help_msg_at ) ; } else if ( ptr [ 1 ] == '%' ) { char * k = strdup ( ptr + 2 ) ; char * v = strchr ( k , '=' ) ; if ( v ) { * v ++ = 0 ; r_sys_setenv ( k , v ) ; r_list_append ( tmpenvs , k ) ; } else { free ( k ) ; } } else if ( ptr [ 1 ] == '.' ) { if ( ptr [ 2 ] == '.' ) { if ( ptr [ 3 ] == '.' ) { ut64 addr = r_num_tail ( core -> num , core -> offset , ptr + 4 ) ; r_core_block_size ( core , R_ABS ( ( st64 ) addr - ( st64 ) core -> offset ) ) ; goto fuji ; } else { addr = r_num_tail ( core -> num , core -> offset , ptr + 3 ) ; r_core_seek ( core , addr , 1 ) ; cmd_tmpseek = core -> tmpseek = true ; goto fuji ; } } else { eprintf ( "TODO:<S2SV_blank>what<S2SV_blank>do<S2SV_blank>you<S2SV_blank>expect<S2SV_blank>for<S2SV_blank>@.<S2SV_blank>import<S2SV_blank>offset<S2SV_blank>from<S2SV_blank>file<S2SV_blank>maybe?\\n" ) ; } } else if ( ptr [ 0 ] && ptr [ 1 ] == ':' && ptr [ 2 ] ) { switch ( ptr [ 0 ] ) { case 'F' : flgspc_changed = r_flag_space_push ( core -> flags , ptr + 2 ) ; break ; case 'B' : { int index = ( int ) r_num_math ( core -> num , ptr + 2 ) ; RAnalBlock * bb = r_anal_bb_from_offset ( core -> anal , core -> offset ) ; if ( bb ) { if ( index < 0 ) { index = bb -> ninstr + index ; } if ( index >= 0 && index < bb -> ninstr ) { ut16 inst_off = r_anal_bb_offset_inst ( bb , index ) ; r_core_seek ( core , bb -> addr + inst_off , 1 ) ; cmd_tmpseek = core -> tmpseek = true ; } else { eprintf ( "The<S2SV_blank>current<S2SV_blank>basic<S2SV_blank>block<S2SV_blank>has<S2SV_blank>%d<S2SV_blank>instructions\\n" , bb -> ninstr ) ; } } else { eprintf ( "Can\'t<S2SV_blank>find<S2SV_blank>a<S2SV_blank>basic<S2SV_blank>block<S2SV_blank>for<S2SV_blank>0x%08" PFMT64x "\\n" , core -> offset ) ; } break ; } break ; case 'f' : f = r_file_slurp ( ptr + 2 , & sz ) ; if ( f ) { { RBuffer * b = r_buf_new_with_bytes ( ( const ut8 * ) f , sz ) ; RIODesc * d = r_io_open_buffer ( core -> io , b , R_PERM_RWX , 0 ) ; if ( d ) { if ( tmpdesc ) { r_io_desc_close ( tmpdesc ) ; } tmpdesc = d ; if ( pamode ) { r_config_set_i ( core -> config , "io.va" , 1 ) ; } r_io_map_new ( core -> io , d -> fd , d -> perm , 0 , core -> offset , r_buf_size ( b ) ) ; } } # if 0 buf = malloc ( sz ) ; if ( buf ) { free ( core -> block ) ; core -> block = buf ; core -> blocksize = sz ; memcpy ( core -> block , f , sz ) ; usemyblock = true ; } else { eprintf ( "cannot<S2SV_blank>alloc<S2SV_blank>%d" , sz ) ; } free ( f ) ; # endif } else { eprintf ( "cannot<S2SV_blank>open<S2SV_blank>\'%s\'\\n" , ptr + 3 ) ; } break ; case 'r' : if ( ptr [ 1 ] == ':' ) { ut64 regval ; char * mander = strdup ( ptr + 2 ) ; char * sep = findSeparator ( mander ) ; if ( sep ) { char ch = * sep ; * sep = 0 ; regval = r_debug_reg_get ( core -> dbg , mander ) ; * sep = ch ; char * numexpr = r_str_newf ( "0x%" PFMT64x "%s" , regval , sep ) ; regval = r_num_math ( core -> num , numexpr ) ; free ( numexpr ) ; } else { regval = r_debug_reg_get ( core -> dbg , ptr + 2 ) ; } r_core_seek ( core , regval , 1 ) ; cmd_tmpseek = core -> tmpseek = true ; free ( mander ) ; } break ; case 'b' : is_bits_set = set_tmp_bits ( core , r_num_math ( core -> num , ptr + 2 ) , & tmpbits ) ; cmd_ignbithints = r_config_get_i ( core -> config , "anal.ignbithints" ) ; r_config_set_i ( core -> config , "anal.ignbithints" , 1 ) ; break ; case 'i' : { ut64 addr = r_num_math ( core -> num , ptr + 2 ) ; if ( addr ) { r_core_cmdf ( core , "so<S2SV_blank>%s" , ptr + 2 ) ; cmd_tmpseek = core -> tmpseek = true ; } } break ; case 'e' : { char * cmd = parse_tmp_evals ( core , ptr + 2 ) ; if ( ! tmpeval ) { tmpeval = cmd ; } else { tmpeval = r_str_prepend ( tmpeval , cmd ) ; free ( cmd ) ; } } break ; case 'x' : if ( ptr [ 1 ] == ':' ) { buf = malloc ( strlen ( ptr + 2 ) + 1 ) ; if ( buf ) { len = r_hex_str2bin ( ptr + 2 , buf ) ; r_core_block_size ( core , R_ABS ( len ) ) ; if ( len > 0 ) { RBuffer * b = r_buf_new_with_bytes ( buf , len ) ; RIODesc * d = r_io_open_buffer ( core -> io , b , R_PERM_RWX , 0 ) ; if ( d ) { if ( tmpdesc ) { r_io_desc_close ( tmpdesc ) ; } tmpdesc = d ; if ( pamode ) { r_config_set_i ( core -> config , "io.va" , 1 ) ; } r_io_map_new ( core -> io , d -> fd , d -> perm , 0 , core -> offset , r_buf_size ( b ) ) ; r_core_block_size ( core , len ) ; r_core_block_read ( core ) ; } } else { eprintf ( "Error:<S2SV_blank>Invalid<S2SV_blank>hexpairs<S2SV_blank>for<S2SV_blank>@x:\\n" ) ; } free ( buf ) ; } else { eprintf ( "cannot<S2SV_blank>allocate\\n" ) ; } } else { eprintf ( "Invalid<S2SV_blank>@x:<S2SV_blank>syntax\\n" ) ; } break ; case 'k' : { char * out = sdb_querys ( core -> sdb , NULL , 0 , ptr + ( ( ptr [ 1 ] ) ? 2 : 1 ) ) ; if ( out ) { r_core_seek ( core , r_num_math ( core -> num , out ) , 1 ) ; free ( out ) ; usemyblock = true ; } } break ; case 'o' : if ( ptr [ 1 ] == ':' ) { tmpfd = core -> io -> desc ? core -> io -> desc -> fd : - 1 ; r_io_use_fd ( core -> io , atoi ( ptr + 2 ) ) ; } break ; case 'a' : if ( ptr [ 1 ] == ':' ) { char * q = strchr ( ptr + 2 , ':' ) ; if ( q ) { * q ++ = 0 ; int bits = r_num_math ( core -> num , q ) ; is_bits_set = set_tmp_bits ( core , bits , & tmpbits ) ; } is_arch_set = set_tmp_arch ( core , ptr + 2 , & tmpasm ) ; } else { eprintf ( "Usage:<S2SV_blank>pd<S2SV_blank>10<S2SV_blank>@a:arm:32\\n" ) ; } break ; case 's' : { len = strlen ( ptr + 2 ) ; r_core_block_size ( core , len ) ; const ut8 * buf = ( const ut8 * ) r_str_trim_ro ( ptr + 2 ) ; if ( len > 0 ) { RBuffer * b = r_buf_new_with_bytes ( buf , len ) ; RIODesc * d = r_io_open_buffer ( core -> io , b , R_PERM_RWX , 0 ) ; if ( ! core -> io -> va ) { r_config_set_i ( core -> config , "io.va" , 1 ) ; } if ( d ) { if ( tmpdesc ) { r_io_desc_close ( tmpdesc ) ; } tmpdesc = d ; if ( pamode ) { r_config_set_i ( core -> config , "io.va" , 1 ) ; } r_io_map_new ( core -> io , d -> fd , d -> perm , 0 , core -> offset , r_buf_size ( b ) ) ; r_core_block_size ( core , len ) ; } } } break ; default : goto ignore ; } * ptr = '@' ; char * trim = ptr - 2 ; while ( trim > cmd ) { if ( ! IS_WHITESPACE ( * trim ) ) { break ; } * trim = 0 ; trim -- ; } goto next_arroba ; } ignore : ptr = r_str_trim_head ( ptr + 1 ) - 1 ; cmd = r_str_trim_nc ( cmd ) ; if ( ptr2 ) { if ( strlen ( ptr + 1 ) == 13 && strlen ( ptr2 + 1 ) == 6 && ! memcmp ( ptr + 1 , "0x" , 2 ) && ! memcmp ( ptr2 + 1 , "0x" , 2 ) ) { } else if ( strlen ( ptr + 1 ) == 9 && strlen ( ptr2 + 1 ) == 4 ) { } else { * ptr2 = '\\0' ; if ( ! ptr2 [ 1 ] ) { goto fail ; } r_core_block_size ( core , r_num_math ( core -> num , ptr2 + 1 ) ) ; } } offstr = r_str_trim_head ( ptr + 1 ) ; addr = r_num_math ( core -> num , offstr ) ; addr_is_set = true ; if ( isalpha ( ( ut8 ) ptr [ 1 ] ) && ! addr ) { if ( ! r_flag_get ( core -> flags , ptr + 1 ) ) { eprintf ( "Invalid<S2SV_blank>address<S2SV_blank>(%s)\\n" , ptr + 1 ) ; goto fail ; } } else { char ch = * offstr ; if ( ch == '-' || ch == '+' ) { addr = core -> offset + addr ; } } if ( addr ) { RIODesc * d = tmpdesc ; if ( d ) { r_io_map_new ( core -> io , d -> fd , d -> perm , 0 , addr , r_io_desc_size ( d ) ) ; } } next_arroba : if ( arroba ) { ptr = arroba + 1 ; * arroba = '@' ; arroba = NULL ; goto repeat_arroba ; } core -> fixedblock = ! ! tmpdesc ; if ( core -> fixedblock ) { r_core_block_read ( core ) ; } if ( ptr [ 1 ] == '@' ) { if ( ptr [ 2 ] == '@' ) { char * rule = ptr + 3 ; while ( * rule && * rule == '<S2SV_blank>' ) { rule ++ ; } ret = r_core_cmd_foreach3 ( core , cmd , rule ) ; } else { ret = r_core_cmd_foreach ( core , cmd , ptr + 2 ) ; } } else { bool tmpseek = false ; const char * fromvars [ ] = { "anal.from" , "diff.from" , "graph.from" , "io.buffer.from" , "lines.from" , "search.from" , "zoom.from" , NULL } ; const char * tovars [ ] = { "anal.to" , "diff.to" , "graph.to" , "io.buffer.to" , "lines.to" , "search.to" , "zoom.to" , NULL } ; ut64 curfrom [ R_ARRAY_SIZE ( fromvars ) - 1 ] , curto [ R_ARRAY_SIZE ( tovars ) - 1 ] ; if ( ptr [ 1 ] == '(' ) { char * range = ptr + 3 ; char * p = strchr ( range , '<S2SV_blank>' ) ; if ( ! p ) { eprintf ( "Usage:<S2SV_blank>/<S2SV_blank>ABCD<S2SV_blank>@..0x1000<S2SV_blank>0x3000\\n" ) ; free ( tmpeval ) ; free ( tmpasm ) ; free ( tmpbits ) ; goto fail ; } * p = '\\x00' ; ut64 from = r_num_math ( core -> num , range ) ; ut64 to = r_num_math ( core -> num , p + 1 ) ; for ( i = 0 ; fromvars [ i ] ; i ++ ) { curfrom [ i ] = r_config_get_i ( core -> config , fromvars [ i ] ) ; } for ( i = 0 ; tovars [ i ] ; i ++ ) { curto [ i ] = r_config_get_i ( core -> config , tovars [ i ] ) ; } for ( i = 0 ; fromvars [ i ] ; i ++ ) { r_config_set_i ( core -> config , fromvars [ i ] , from ) ; } for ( i = 0 ; tovars [ i ] ; i ++ ) { r_config_set_i ( core -> config , tovars [ i ] , to ) ; } tmpseek = true ; } if ( usemyblock ) { if ( addr_is_set ) { core -> offset = addr ; } ret = r_cmd_call ( core -> rcmd , r_str_trim_head ( cmd ) ) ; } else { if ( addr_is_set ) { if ( ptr [ 1 ] ) { r_core_seek ( core , addr , 1 ) ; r_core_block_read ( core ) ; } } ret = r_cmd_call ( core -> rcmd , r_str_trim_head ( cmd ) ) ; } if ( tmpseek ) { for ( i = 0 ; fromvars [ i ] ; i ++ ) { r_config_set_i ( core -> config , fromvars [ i ] , curfrom [ i ] ) ; } for ( i = 0 ; tovars [ i ] ; i ++ ) { r_config_set_i ( core -> config , tovars [ i ] , curto [ i ] ) ; } } } if ( ptr2 ) { * ptr2 = '!' ; r_core_block_size ( core , tmpbsz ) ; } if ( is_arch_set ) { core -> fixedarch = oldfixedarch ; r_config_set ( core -> config , "asm.arch" , tmpasm ) ; R_FREE ( tmpasm ) ; } if ( tmpfd != - 1 ) { r_io_use_fd ( core -> io , tmpfd ) ; } if ( tmpdesc ) { if ( pamode ) { r_config_set_i ( core -> config , "io.va" , 0 ) ; } r_io_desc_close ( tmpdesc ) ; tmpdesc = NULL ; } if ( is_bits_set ) { r_config_set ( core -> config , "asm.bits" , tmpbits ) ; core -> fixedbits = oldfixedbits ; } if ( tmpbsz != core -> blocksize ) { r_core_block_size ( core , tmpbsz ) ; } if ( tmpeval ) { r_core_cmd0 ( core , tmpeval ) ; R_FREE ( tmpeval ) ; } if ( flgspc_changed ) { r_flag_space_pop ( core -> flags ) ; } * ptr = '@' ; rc = ret ; goto beach ; } fuji : rc = cmd ? r_cmd_call ( core -> rcmd , r_str_trim_head ( cmd ) ) : false ; beach : r_cons_grep_process ( grep ) ; if ( scr_html != - 1 ) { r_cons_flush ( ) ; r_config_set_i ( core -> config , "scr.html" , scr_html ) ; } if ( scr_color != - 1 ) { r_config_set_i ( core -> config , "scr.color" , scr_color ) ; } r_list_free ( tmpenvs ) ; if ( tmpdesc ) { r_io_desc_close ( tmpdesc ) ; tmpdesc = NULL ; } core -> fixedarch = oldfixedarch ; core -> fixedbits = oldfixedbits ; if ( tmpseek ) { * tmpseek = cmd_tmpseek ; } if ( cmd_ignbithints != - 1 ) { r_config_set_i ( core -> config , "anal.ignbithints" , cmd_ignbithints ) ; } return rc ; fail : rc = - 1 ; goto beach ; }
<S2SV_ModStart> continue ; } char op0 = 0 ; <S2SV_ModStart> q ) { op0 = * q ; <S2SV_ModStart> cmd = p <S2SV_ModEnd> ; } else <S2SV_ModStart> * p = op0 <S2SV_ModEnd> ; cmd =
13
CWE-200 int check_user_token ( const char * authfile , const char * username , const char * otp_id , int verbose , FILE * debug_file ) { char buf [ 1024 ] ; char * s_user , * s_token ; int retval = AUTH_ERROR ; int fd ; struct stat st ; FILE * opwfile ; fd = open ( authfile , O_RDONLY , 0 ) ; if ( fd < 0 ) { if ( verbose ) D ( debug_file , "Cannot<S2SV_blank>open<S2SV_blank>file:<S2SV_blank>%s<S2SV_blank>(%s)" , authfile , strerror ( errno ) ) ; return retval ; } if ( fstat ( fd , & st ) < 0 ) { if ( verbose ) D ( debug_file , "Cannot<S2SV_blank>stat<S2SV_blank>file:<S2SV_blank>%s<S2SV_blank>(%s)" , authfile , strerror ( errno ) ) ; close ( fd ) ; return retval ; } if ( ! S_ISREG ( st . st_mode ) ) { if ( verbose ) D ( debug_file , "%s<S2SV_blank>is<S2SV_blank>not<S2SV_blank>a<S2SV_blank>regular<S2SV_blank>file" , authfile ) ; close ( fd ) ; return retval ; } opwfile = fdopen ( fd , "r" ) ; if ( opwfile == NULL ) { if ( verbose ) D ( debug_file , "fdopen:<S2SV_blank>%s" , strerror ( errno ) ) ; close ( fd ) ; return retval ; } retval = AUTH_NO_TOKENS ; while ( fgets ( buf , 1024 , opwfile ) ) { char * saveptr = NULL ; if ( buf [ strlen ( buf ) - 1 ] == '\\n' ) buf [ strlen ( buf ) - 1 ] = '\\0' ; if ( buf [ 0 ] == '#' ) { if ( verbose ) D ( debug_file , "Skipping<S2SV_blank>comment<S2SV_blank>line:<S2SV_blank>%s" , buf ) ; continue ; } if ( verbose ) D ( debug_file , "Authorization<S2SV_blank>line:<S2SV_blank>%s" , buf ) ; s_user = strtok_r ( buf , ":" , & saveptr ) ; if ( s_user && strcmp ( username , s_user ) == 0 ) { if ( verbose ) D ( debug_file , "Matched<S2SV_blank>user:<S2SV_blank>%s" , s_user ) ; retval = AUTH_NOT_FOUND ; do { s_token = strtok_r ( NULL , ":" , & saveptr ) ; if ( verbose ) D ( debug_file , "Authorization<S2SV_blank>token:<S2SV_blank>%s" , s_token ) ; if ( s_token && otp_id && strcmp ( otp_id , s_token ) == 0 ) { if ( verbose ) D ( debug_file , "Match<S2SV_blank>user/token<S2SV_blank>as<S2SV_blank>%s/%s" , username , otp_id <S2SV_StartBug> ) ; return AUTH_FOUND ; <S2SV_EndBug> } } while ( s_token != NULL ) ; } } fclose ( opwfile ) ; return retval ; }
<S2SV_ModStart> otp_id ) ; fclose ( opwfile ) ;
14
CWE-125 static int PARSER_FLAGS ( PyCompilerFlags * flags ) { int parser_flags = 0 ; if ( ! flags ) return 0 ; if ( flags -> cf_flags & PyCF_DONT_IMPLY_DEDENT ) parser_flags |= PyPARSE_DONT_IMPLY_DEDENT ; if ( flags -> cf_flags & PyCF_IGNORE_COOKIE ) parser_flags |= PyPARSE_IGNORE_COOKIE ; if ( flags -> cf_flags & CO_FUTURE_BARRY_AS_BDFL ) parser_flags |= PyPARSE_BARRY_AS_BDFL ; <S2SV_StartBug> return parser_flags ; } <S2SV_EndBug>
<S2SV_ModStart> |= PyPARSE_BARRY_AS_BDFL ; if ( flags -> cf_flags & PyCF_TYPE_COMMENTS ) parser_flags |= PyPARSE_TYPE_COMMENTS ;
15
CWE-834 static int read_tfra ( MOVContext * mov , AVIOContext * f ) { MOVFragmentIndex * index = NULL ; int version , fieldlength , i , j ; int64_t pos = avio_tell ( f ) ; uint32_t size = avio_rb32 ( f ) ; void * tmp ; if ( avio_rb32 ( f ) != MKBETAG ( 't' , 'f' , 'r' , 'a' ) ) { return 1 ; } av_log ( mov -> fc , AV_LOG_VERBOSE , "found<S2SV_blank>tfra\\n" ) ; index = av_mallocz ( sizeof ( MOVFragmentIndex ) ) ; if ( ! index ) { return AVERROR ( ENOMEM ) ; } tmp = av_realloc_array ( mov -> fragment_index_data , mov -> fragment_index_count + 1 , sizeof ( MOVFragmentIndex * ) ) ; if ( ! tmp ) { av_freep ( & index ) ; return AVERROR ( ENOMEM ) ; } mov -> fragment_index_data = tmp ; mov -> fragment_index_data [ mov -> fragment_index_count ++ ] = index ; version = avio_r8 ( f ) ; avio_rb24 ( f ) ; index -> track_id = avio_rb32 ( f ) ; fieldlength = avio_rb32 ( f ) ; index -> item_count = avio_rb32 ( f ) ; index -> items = av_mallocz_array ( index -> item_count , sizeof ( MOVFragmentIndexItem ) ) ; if ( ! index -> items ) { index -> item_count = 0 ; return AVERROR ( ENOMEM ) ; } for ( i = 0 ; i < index -> item_count ; i ++ ) { int64_t time , <S2SV_StartBug> offset ; if ( version <S2SV_EndBug> == 1 ) { time = avio_rb64 ( f ) ; offset = avio_rb64 ( f ) ; } else { time = avio_rb32 ( f ) ; offset = avio_rb32 ( f ) ; } index -> items [ i ] . time = time ; index -> items [ i ] . moof_offset = offset ; for ( j = 0 ; j < ( ( fieldlength >> 4 ) & 3 ) + 1 ; j ++ ) avio_r8 ( f ) ; for ( j = 0 ; j < ( ( fieldlength >> 2 ) & 3 ) + 1 ; j ++ ) avio_r8 ( f ) ; for ( j = 0 ; j < ( ( fieldlength >> 0 ) & 3 ) + 1 ; j ++ ) avio_r8 ( f ) ; } avio_seek ( f , pos + size , SEEK_SET ) ; return 0 ; }
<S2SV_ModStart> , offset ; if ( avio_feof ( f ) ) { index -> item_count = 0 ; av_freep ( & index -> items ) ; return AVERROR_INVALIDDATA ; }
16
CWE-125 void bootp_print ( netdissect_options * ndo , register const u_char * cp , u_int length ) { register const struct bootp * bp ; static const u_char vm_cmu [ 4 ] = VM_CMU ; static const u_char vm_rfc1048 [ 4 ] = VM_RFC1048 ; bp = ( const struct bootp * ) cp ; ND_TCHECK ( bp -> bp_op ) ; ND_PRINT ( ( ndo , "BOOTP/DHCP,<S2SV_blank>%s" , tok2str ( bootp_op_values , "unknown<S2SV_blank>(0x%02x)" , bp -> bp_op ) ) ) ; ND_TCHECK ( bp -> bp_hlen ) ; if ( bp -> bp_htype == 1 && bp -> bp_hlen == 6 && bp -> bp_op == BOOTPREQUEST ) { ND_TCHECK2 ( bp -> bp_chaddr [ 0 ] , 6 ) ; ND_PRINT ( ( ndo , "<S2SV_blank>from<S2SV_blank>%s" , etheraddr_string ( ndo , bp -> bp_chaddr ) ) ) ; } ND_PRINT ( ( ndo , ",<S2SV_blank>length<S2SV_blank>%u" , length ) ) ; if ( ! ndo -> ndo_vflag ) return ; ND_TCHECK ( bp -> bp_secs ) ; if ( bp -> bp_htype != 1 ) ND_PRINT ( ( ndo , ",<S2SV_blank>htype<S2SV_blank>%d" , bp -> bp_htype ) ) ; if ( bp -> bp_htype != 1 || bp -> bp_hlen != 6 ) ND_PRINT ( ( ndo , ",<S2SV_blank>hlen<S2SV_blank>%d" , bp -> bp_hlen ) ) ; if ( bp -> bp_hops ) ND_PRINT ( ( ndo , ",<S2SV_blank>hops<S2SV_blank>%d" , bp -> bp_hops ) ) ; if ( EXTRACT_32BITS ( & bp -> bp_xid ) ) ND_PRINT ( ( ndo , ",<S2SV_blank>xid<S2SV_blank>0x%x" , EXTRACT_32BITS ( & bp -> bp_xid ) ) ) ; if ( EXTRACT_16BITS ( & bp -> bp_secs ) ) ND_PRINT ( ( ndo , ",<S2SV_blank>secs<S2SV_blank>%d" , EXTRACT_16BITS ( & bp -> <S2SV_StartBug> bp_secs ) ) ) ; ND_PRINT ( <S2SV_EndBug> ( ndo , ",<S2SV_blank>Flags<S2SV_blank>[%s]" , bittok2str ( bootp_flag_values , "none" , EXTRACT_16BITS ( & bp -> bp_flags ) ) ) ) ; if ( ndo -> ndo_vflag > 1 ) ND_PRINT ( ( ndo , "<S2SV_blank>(0x%04x)" , EXTRACT_16BITS ( & bp -> bp_flags ) ) ) ; ND_TCHECK ( bp -> bp_ciaddr ) ; if ( EXTRACT_32BITS ( & bp -> bp_ciaddr . s_addr ) ) ND_PRINT ( ( ndo , "\\n\\t<S2SV_blank><S2SV_blank>Client-IP<S2SV_blank>%s" , ipaddr_string ( ndo , & bp -> bp_ciaddr ) ) ) ; ND_TCHECK ( bp -> bp_yiaddr ) ; if ( EXTRACT_32BITS ( & bp -> bp_yiaddr . s_addr ) ) ND_PRINT ( ( ndo , "\\n\\t<S2SV_blank><S2SV_blank>Your-IP<S2SV_blank>%s" , ipaddr_string ( ndo , & bp -> bp_yiaddr ) ) ) ; ND_TCHECK ( bp -> bp_siaddr ) ; if ( EXTRACT_32BITS ( & bp -> bp_siaddr . s_addr ) ) ND_PRINT ( ( ndo , "\\n\\t<S2SV_blank><S2SV_blank>Server-IP<S2SV_blank>%s" , ipaddr_string ( ndo , & bp -> bp_siaddr ) ) ) ; ND_TCHECK ( bp -> bp_giaddr ) ; if ( EXTRACT_32BITS ( & bp -> bp_giaddr . s_addr ) ) ND_PRINT ( ( ndo , "\\n\\t<S2SV_blank><S2SV_blank>Gateway-IP<S2SV_blank>%s" , ipaddr_string ( ndo , & bp -> bp_giaddr ) ) ) ; if ( bp -> bp_htype == 1 && bp -> bp_hlen == 6 ) { ND_TCHECK2 ( bp -> bp_chaddr [ 0 ] , 6 ) ; ND_PRINT ( ( ndo , "\\n\\t<S2SV_blank><S2SV_blank>Client-Ethernet-Address<S2SV_blank>%s" , etheraddr_string ( ndo , bp -> bp_chaddr ) ) ) ; } ND_TCHECK2 ( bp -> bp_sname [ 0 ] , 1 ) ; if ( * bp -> bp_sname ) { ND_PRINT ( ( ndo , "\\n\\t<S2SV_blank><S2SV_blank>sname<S2SV_blank>\\"" ) ) ; if ( fn_printztn ( ndo , bp -> bp_sname , ( u_int ) sizeof bp -> bp_sname , ndo -> ndo_snapend ) ) { ND_PRINT ( ( ndo , "\\"" ) ) ; ND_PRINT ( ( ndo , "%s" , tstr + 1 ) ) ; return ; } ND_PRINT ( ( ndo , "\\"" ) ) ; } ND_TCHECK2 ( bp -> bp_file [ 0 ] , 1 ) ; if ( * bp -> bp_file ) { ND_PRINT ( ( ndo , "\\n\\t<S2SV_blank><S2SV_blank>file<S2SV_blank>\\"" ) ) ; if ( fn_printztn ( ndo , bp -> bp_file , ( u_int ) sizeof bp -> bp_file , ndo -> ndo_snapend ) ) { ND_PRINT ( ( ndo , "\\"" ) ) ; ND_PRINT ( ( ndo , "%s" , tstr + 1 ) ) ; return ; } ND_PRINT ( ( ndo , "\\"" ) ) ; } ND_TCHECK ( bp -> bp_vend [ 0 ] ) ; if ( memcmp ( ( const char * ) bp -> bp_vend , vm_rfc1048 , sizeof ( uint32_t ) ) == 0 ) rfc1048_print ( ndo , bp -> bp_vend ) ; else if ( memcmp ( ( const char * ) bp -> bp_vend , vm_cmu , sizeof ( uint32_t ) ) == 0 ) cmu_print ( ndo , bp -> bp_vend ) ; else { uint32_t ul ; ul = EXTRACT_32BITS ( & bp -> bp_vend ) ; if ( ul != 0 ) ND_PRINT ( ( ndo , "\\n\\t<S2SV_blank><S2SV_blank>Vendor-#0x%x" , ul ) ) ; } return ; trunc : ND_PRINT ( ( ndo , "%s" , tstr ) ) ; }
<S2SV_ModStart> ) ) ; ND_TCHECK ( bp -> bp_flags ) ;
17
CWE-416 void CleanWriters ( GF_List * writers ) { while ( gf_list_count ( writers ) ) { TrackWriter * writer = <S2SV_StartBug> ( TrackWriter * ) gf_list_get ( writers , 0 ) ; gf_isom_box_del ( writer -> stco <S2SV_EndBug> ) ; gf_isom_box_del ( ( GF_Box * ) writer -> stsc ) ; gf_free ( writer ) ; gf_list_rem ( writers , 0 ) ; } }
<S2SV_ModStart> writers , 0 ) ; gf_list_del_item ( writer -> stbl -> child_boxes , writer -> stco ) ; gf_list_del_item ( writer -> stbl -> child_boxes , writer -> stsc
18
CWE-20 void kvm_lapic_sync_from_vapic ( struct kvm_vcpu * vcpu ) { <S2SV_StartBug> u32 data ; void * vapic ; <S2SV_EndBug> if ( test_bit ( KVM_APIC_PV_EOI_PENDING , & vcpu -> arch . apic_attention ) ) apic_sync_pv_eoi_from_guest ( vcpu , vcpu -> arch . apic ) ; if ( ! test_bit ( KVM_APIC_CHECK_VAPIC , & vcpu -> arch . apic_attention ) ) return <S2SV_StartBug> ; vapic = kmap_atomic ( vcpu -> arch . apic -> vapic_page ) ; data = * <S2SV_EndBug> ( u32 * ) ( vapic + offset_in_page ( vcpu -> arch . apic -> vapic_addr ) ) ; kunmap_atomic ( vapic ) ; apic_set_tpr ( vcpu -> arch . apic , data & 0xff ) ; }
<S2SV_ModStart> { u32 data <S2SV_ModEnd> ; if ( <S2SV_ModStart> ) return ; kvm_read_guest_cached ( vcpu -> kvm , & <S2SV_ModEnd> vcpu -> arch <S2SV_ModStart> . apic -> vapic_cache , & data , sizeof ( u32 ) <S2SV_ModEnd> ) ; apic_set_tpr
19
CWE-476 static int dnxhd_find_frame_end ( DNXHDParserContext * dctx , const uint8_t * buf , int buf_size ) { ParseContext * pc = & dctx -> pc ; uint64_t state = pc -> state64 ; int pic_found = pc -> frame_start_found ; int i = 0 ; int interlaced = dctx -> interlaced ; int cur_field = dctx -> cur_field ; if ( ! pic_found ) { for ( i = 0 ; i < buf_size ; i ++ ) { state = ( state << 8 ) | buf [ i ] ; if ( ff_dnxhd_check_header_prefix ( state & 0xffffffffff00LL ) != 0 ) { i ++ ; pic_found = 1 ; interlaced = ( state & 2 ) >> 1 ; cur_field = state & 1 ; dctx -> cur_byte = 0 ; dctx -> remaining = 0 ; break ; } } } if ( pic_found && ! dctx -> remaining ) { if ( ! buf_size ) return 0 ; for ( ; i < buf_size ; i ++ ) { dctx -> cur_byte ++ ; state = ( state << 8 ) | buf [ i ] ; if ( dctx -> cur_byte == 24 ) { dctx -> h = ( state >> 32 ) & 0xFFFF ; } else if ( dctx -> cur_byte == 26 ) { dctx -> w = ( state >> 32 ) & 0xFFFF ; } else if ( dctx -> cur_byte == 42 ) { int cid = ( state >> 32 ) <S2SV_StartBug> & 0xFFFFFFFF ; if <S2SV_EndBug> ( cid <= 0 ) continue ; dctx -> <S2SV_StartBug> remaining = avpriv_dnxhd_get_frame_size ( cid <S2SV_EndBug> ) ; <S2SV_StartBug> if ( dctx -> remaining <= 0 ) { <S2SV_StartBug> dctx -> remaining = <S2SV_EndBug> dnxhd_get_hr_frame_size ( cid , dctx -> w , dctx -> <S2SV_EndBug> h ) ; if ( dctx -> <S2SV_StartBug> remaining <= 0 ) <S2SV_StartBug> return dctx -> remaining <S2SV_EndBug> ; <S2SV_EndBug> } if ( buf_size - i >= dctx -> remaining && ( ! dctx -> interlaced || dctx -> cur_field ) ) { int remaining = dctx -> remaining ; pc -> frame_start_found = 0 ; pc -> state64 = - 1 ; dctx -> interlaced = interlaced ; dctx -> cur_field = 0 ; dctx -> cur_byte = 0 ; dctx -> remaining = 0 ; return remaining ; } else { dctx -> remaining -= buf_size ; } } } } else if ( pic_found ) { if ( dctx -> remaining > buf_size ) { dctx -> remaining -= buf_size ; } else { int remaining = dctx -> remaining ; pc -> frame_start_found = 0 ; pc -> state64 = - 1 ; dctx -> interlaced = interlaced ; dctx -> cur_field = 0 ; dctx -> cur_byte = 0 ; dctx -> remaining = 0 ; return remaining ; } } pc -> frame_start_found = pic_found ; pc -> state64 = state ; dctx -> interlaced = interlaced ; dctx -> cur_field = cur_field ; return END_NOT_FOUND ; }
<S2SV_ModStart> & 0xFFFFFFFF ; int remaining ; <S2SV_ModStart> ) continue ; <S2SV_ModEnd> remaining = avpriv_dnxhd_get_frame_size <S2SV_ModStart> ; if ( <S2SV_ModEnd> remaining <= 0 <S2SV_ModStart> 0 ) { <S2SV_ModEnd> remaining = dnxhd_get_hr_frame_size <S2SV_ModStart> ; if ( <S2SV_ModEnd> remaining <= 0 <S2SV_ModStart> <= 0 ) continue ; } dctx -> remaining = remaining ; <S2SV_ModEnd> if ( buf_size
20
CWE-787 grub_ssize_t grub_fshelp_read_file ( grub_disk_t disk , grub_fshelp_node_t node , void ( * read_hook ) ( grub_disk_addr_t sector , unsigned offset , unsigned length , void * closure ) , void * closure , int flags , grub_off_t pos , grub_size_t len , char * buf , grub_disk_addr_t ( * get_block ) ( grub_fshelp_node_t node , grub_disk_addr_t block ) , grub_off_t filesize , int log2blocksize ) { grub_disk_addr_t i , blockcnt ; int blocksize = 1 << ( log2blocksize + GRUB_DISK_SECTOR_BITS ) ; if ( pos + len > filesize ) len = filesize - pos ; blockcnt = ( <S2SV_StartBug> ( len + pos ) + blocksize - <S2SV_EndBug> 1 ) >> ( log2blocksize + GRUB_DISK_SECTOR_BITS ) ; for ( i = pos >> ( log2blocksize + GRUB_DISK_SECTOR_BITS ) ; i < blockcnt ; i ++ ) { grub_disk_addr_t blknr ; int blockoff = pos & ( blocksize - 1 ) ; int blockend = blocksize ; int skipfirst = 0 ; blknr = get_block ( node , i ) ; if ( grub_errno ) return - 1 ; blknr = blknr << log2blocksize ; if ( i == blockcnt - 1 ) { blockend = ( len + pos ) & ( blocksize - 1 ) ; if ( ! blockend ) blockend = blocksize ; } if ( i == ( pos >> ( log2blocksize + GRUB_DISK_SECTOR_BITS ) ) ) { skipfirst = blockoff ; blockend -= skipfirst ; } if ( blknr ) { disk -> read_hook = read_hook ; disk -> closure = closure ; grub_hack_lastoff = blknr * 512 ; grub_disk_read_ex ( disk , blknr , skipfirst , blockend , buf , flags ) ; disk -> read_hook = 0 ; if ( grub_errno ) return - 1 ; } else if ( buf ) grub_memset ( buf , 0 , blockend ) ; if ( buf ) buf += blocksize - skipfirst ; } return len ; }
<S2SV_ModStart> - pos ; if ( len < 1 || len == 0xffffffff ) { return - 1 ; }
21
CWE-20 int arch_dup_task_struct ( struct task_struct * dst , struct task_struct * src ) { flush_fp_to_thread ( src ) ; flush_altivec_to_thread ( src ) ; flush_vsx_to_thread ( src ) ; flush_spe_to_thread ( src ) ; * <S2SV_StartBug> dst = * src ; clear_task_ebb ( dst <S2SV_EndBug> ) ; return 0 ; }
<S2SV_ModStart> src ) ; __switch_to_tm ( src ) ; tm_recheckpoint_new_task ( src ) ;
22
CWE-476 int migrate_page_move_mapping ( struct address_space * mapping , struct page * newpage , struct page * page , struct buffer_head * head , enum migrate_mode mode , int extra_count <S2SV_StartBug> ) { int expected_count = 1 + extra_count <S2SV_EndBug> ; void * * pslot ; if ( ! mapping ) { if ( page_count ( page ) != expected_count ) return - EAGAIN ; set_page_memcg ( newpage , page_memcg ( page ) ) ; newpage -> index = page -> index ; newpage -> mapping = page -> mapping ; if ( PageSwapBacked ( page ) ) SetPageSwapBacked ( newpage ) <S2SV_StartBug> ; return <S2SV_EndBug> MIGRATEPAGE_SUCCESS ; } spin_lock_irq ( & mapping -> tree_lock ) ; pslot = radix_tree_lookup_slot ( & mapping -> page_tree , page_index ( page ) ) ; expected_count += 1 + page_has_private ( page ) ; if ( page_count ( page ) != expected_count || radix_tree_deref_slot_protected ( pslot , & mapping -> tree_lock ) != page ) { spin_unlock_irq ( & mapping -> tree_lock ) ; return - EAGAIN ; } if ( ! page_freeze_refs ( page , expected_count ) ) { spin_unlock_irq ( & mapping -> tree_lock ) ; return - EAGAIN ; } if ( mode == MIGRATE_ASYNC && head && ! buffer_migrate_lock_buffers ( head , mode ) ) { page_unfreeze_refs ( page , expected_count ) ; spin_unlock_irq ( & mapping -> tree_lock ) ; return - EAGAIN ; } set_page_memcg ( newpage , page_memcg ( page ) ) ; newpage -> index = page -> index ; newpage -> mapping = page -> mapping ; if ( PageSwapBacked ( page ) ) SetPageSwapBacked ( newpage ) ; get_page ( newpage ) ; if ( PageSwapCache ( page ) ) { SetPageSwapCache ( newpage ) ; set_page_private ( newpage , page_private ( page ) <S2SV_StartBug> ) ; } radix_tree_replace_slot ( <S2SV_EndBug> pslot , newpage ) ; page_unfreeze_refs ( page , expected_count - 1 ) ; __dec_zone_page_state ( page , NR_FILE_PAGES <S2SV_EndBug> <S2SV_StartBug> <S2SV_StartBug> ) ; __inc_zone_page_state ( newpage <S2SV_EndBug> , NR_FILE_PAGES ) ; if ( ! <S2SV_StartBug> PageSwapCache ( page ) && PageSwapBacked ( page ) ) { <S2SV_EndBug> __dec_zone_page_state ( page , NR_SHMEM ) ; __inc_zone_page_state ( newpage , NR_SHMEM ) ; } spin_unlock_irq ( & mapping -> tree_lock ) ; return MIGRATEPAGE_SUCCESS ; }
<S2SV_ModStart> extra_count ) { struct zone * oldzone , * newzone ; int dirty ; <S2SV_ModStart> MIGRATEPAGE_SUCCESS ; } oldzone = page_zone ( page ) ; newzone = page_zone ( newpage ) ; <S2SV_ModStart> ) ; } dirty = PageDirty ( page ) ; if ( dirty ) { ClearPageDirty ( page ) ; SetPageDirty ( newpage ) ; } <S2SV_ModStart> 1 ) ; spin_unlock ( & mapping -> tree_lock ) ; if ( newzone != oldzone ) { __dec_zone_state ( oldzone <S2SV_ModEnd> , NR_FILE_PAGES ) <S2SV_ModStart> NR_FILE_PAGES ) ; __inc_zone_state ( newzone <S2SV_ModEnd> , NR_FILE_PAGES ) <S2SV_ModStart> ; if ( PageSwapBacked ( page ) && <S2SV_ModStart> ( page ) ) { __dec_zone_state ( oldzone , NR_SHMEM ) ; __inc_zone_state ( newzone , NR_SHMEM ) ; } if ( dirty && mapping_cap_account_dirty ( mapping ) ) { __dec_zone_state ( oldzone , NR_FILE_DIRTY ) ; __inc_zone_state ( newzone , NR_FILE_DIRTY ) ; } } local_irq_enable ( <S2SV_ModEnd> ) ; return
23
CWE-119 cJSON * cJSON_GetArrayItem ( cJSON * array , int item <S2SV_StartBug> ) { cJSON * c = array -> child ; <S2SV_StartBug> <S2SV_EndBug> while ( c && item > 0 ) { -- item ; <S2SV_EndBug> c = c -> next <S2SV_EndBug> <S2SV_StartBug> ; } return c ; }
<S2SV_ModStart> c = array ? array -> child : 0 <S2SV_ModEnd> ; while ( <S2SV_ModStart> > 0 ) item -- , <S2SV_ModEnd> c = c <S2SV_ModStart> -> next ; <S2SV_ModEnd> return c ;
24
CWE-20 static ext3_fsblk_t get_sb_block ( void * * data , struct super_block * sb ) { ext3_fsblk_t sb_block ; char * options = ( char * ) * data ; if ( ! options || strncmp ( options , "sb=" , 3 ) != 0 ) return 1 ; options += 3 ; sb_block = simple_strtoul ( options , & options , 0 ) ; if ( * options && * options != ',' ) { ext3_msg ( sb , <S2SV_StartBug> "error:<S2SV_blank>invalid<S2SV_blank>sb<S2SV_blank>specification:<S2SV_blank>%s" , <S2SV_EndBug> ( char * ) * data ) ; return 1 ; } if ( * options == ',' ) options ++ ; * data = ( void * ) options ; return sb_block ; }
<S2SV_ModStart> ( sb , KERN_ERR ,
25
CWE-119 static guint32 parse_wbxml_attribute_list_defined ( proto_tree * tree , tvbuff_t * tvb , guint32 offset , guint32 str_tbl , guint8 level , guint8 * codepage_attr , const wbxml_decoding * map ) { guint32 tvb_len = tvb_reported_length ( tvb ) ; guint32 off = <S2SV_EndBug> <S2SV_StartBug> offset ; guint32 len ; guint str_len ; guint32 ent ; guint32 idx ; guint8 peek ; guint8 attr_save_known = 0 ; const char * attr_save_literal = NULL ; DebugLog ( ( "parse_wbxml_attr_defined<S2SV_blank>(level<S2SV_blank>=<S2SV_blank>%u,<S2SV_blank>offset<S2SV_blank>=<S2SV_blank>%u)\\n" <S2SV_StartBug> , level <S2SV_EndBug> , offset ) ) ; while ( off < tvb_len ) { peek = tvb_get_guint8 ( tvb , off ) ; DebugLog ( ( "ATTR:<S2SV_blank>(top<S2SV_blank>of<S2SV_blank>while)<S2SV_blank>level<S2SV_blank>=<S2SV_blank>%3u,<S2SV_blank>peek<S2SV_blank>=<S2SV_blank>0x%02X,<S2SV_blank>" "off<S2SV_blank>=<S2SV_blank>%u,<S2SV_blank>tvb_len<S2SV_blank>=<S2SV_blank>%u\\n" , level , peek , off , tvb_len ) ) ; if ( ( peek & 0x3F ) < 5 ) switch ( peek ) { case 0x00 : * codepage_attr = tvb_get_guint8 ( tvb , off + 1 ) ; proto_tree_add_text ( tree , tvb , off , 2 , "<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>|<S2SV_blank><S2SV_blank>Attr<S2SV_blank>|<S2SV_blank>A<S2SV_blank>-->%3d<S2SV_blank>" "|<S2SV_blank>SWITCH_PAGE<S2SV_blank>(Attr<S2SV_blank>code<S2SV_blank>page)<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>|" , * codepage_attr ) ; off += 2 ; break ; case 0x01 : off ++ ; DebugLog ( ( "ATTR:<S2SV_blank>level<S2SV_blank>=<S2SV_blank>%u,<S2SV_blank>Return:<S2SV_blank>len<S2SV_blank>=<S2SV_blank>%u\\n" , level , off - offset ) ) ; return ( off - offset ) ; case 0x02 : ent = tvb_get_guintvar ( tvb , off + 1 , & len ) ; proto_tree_add_text ( tree , tvb , off , 1 + len , "<S2SV_blank><S2SV_blank>%3d<S2SV_blank>|<S2SV_blank><S2SV_blank>Attr<S2SV_blank>|<S2SV_blank>A<S2SV_blank>%3d<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>" "|<S2SV_blank>ENTITY<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>" "|<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>%s\'&#%u;\'" , level , * codepage_attr , Indent ( level ) , ent ) ; off += 1 + len ; break ; case 0x03 : len = tvb_strsize ( tvb , off + 1 ) ; proto_tree_add_text ( tree , tvb , off , 1 + len , "<S2SV_blank><S2SV_blank>%3d<S2SV_blank>|<S2SV_blank><S2SV_blank>Attr<S2SV_blank>|<S2SV_blank>A<S2SV_blank>%3d<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>" "|<S2SV_blank>STR_I<S2SV_blank>(Inline<S2SV_blank>string)<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>" "|<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>%s\\\'%s\\\'" , level , * codepage_attr , Indent ( level ) , tvb_format_text ( tvb , off + 1 , len - 1 ) ) ; off += 1 + len ; break ; case 0x04 : idx = tvb_get_guintvar ( tvb , off + 1 , & len ) ; str_len = tvb_strsize ( tvb , str_tbl + idx ) ; attr_save_known = 0 ; attr_save_literal = tvb_format_text ( tvb , str_tbl + idx , str_len - 1 ) ; proto_tree_add_text ( tree , tvb , off , 1 + len , "<S2SV_blank><S2SV_blank>%3d<S2SV_blank>|<S2SV_blank><S2SV_blank>Attr<S2SV_blank>|<S2SV_blank>A<S2SV_blank>%3d<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>" "|<S2SV_blank>LITERAL<S2SV_blank>(Literal<S2SV_blank>Attribute)<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>" "|<S2SV_blank><S2SV_blank><S2SV_blank>%s<%s<S2SV_blank>/>" , level , * codepage_attr , Indent ( level ) , attr_save_literal ) ; off += 1 + len ; break ; case 0x40 : case 0x41 : case 0x42 : len = tvb_strsize ( tvb , off + 1 ) ; proto_tree_add_text ( tree , tvb , off , 1 + len , "<S2SV_blank><S2SV_blank>%3d<S2SV_blank>|<S2SV_blank><S2SV_blank>Attr<S2SV_blank>|<S2SV_blank>A<S2SV_blank>%3d<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>" "|<S2SV_blank>EXT_I_%1x<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>(Extension<S2SV_blank>Token)<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>" "|<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>%s(%s:<S2SV_blank>\\\'%s\\\')" , level , * codepage_attr , peek & 0x0f , Indent ( level ) , map_token ( map -> global , 0 , peek ) , tvb_format_text ( tvb , off + 1 , len - 1 ) ) ; off += 1 + len ; break ; case 0x80 : case 0x81 : case 0x82 : idx = tvb_get_guintvar ( tvb , off + 1 , & len ) ; { char * s ; if ( map -> ext_t [ peek & 0x03 ] ) s = ( map -> ext_t [ peek & 0x03 ] ) ( tvb , idx , str_tbl ) ; else s = wmem_strdup_printf ( wmem_packet_scope ( ) , "EXT_T_%1x<S2SV_blank>(%s)" , peek & 0x03 , map_token ( map -> global , 0 , peek ) ) ; proto_tree_add_text ( tree , tvb , off , 1 + len , "<S2SV_blank><S2SV_blank>%3d<S2SV_blank>|<S2SV_blank>Tag<S2SV_blank><S2SV_blank><S2SV_blank>|<S2SV_blank>T<S2SV_blank>%3d<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>" "|<S2SV_blank>EXT_T_%1x<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>(Extension<S2SV_blank>Token)<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>" "|<S2SV_blank>%s%s)" , level , * codepage_attr , peek & 0x0f , Indent ( level ) , s ) ; } off += 1 + len ; break ; case 0x83 : idx = tvb_get_guintvar ( tvb , off + 1 , & len ) ; str_len = tvb_strsize ( tvb , str_tbl + idx ) ; proto_tree_add_text ( tree , tvb , off , 1 + len , "<S2SV_blank><S2SV_blank>%3d<S2SV_blank>|<S2SV_blank><S2SV_blank>Attr<S2SV_blank>|<S2SV_blank>A<S2SV_blank>%3d<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>" "|<S2SV_blank>STR_T<S2SV_blank>(Tableref<S2SV_blank>string)<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>" "|<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>%s\\\'%s\\\'" , level , * codepage_attr , Indent ( level ) , tvb_format_text ( tvb , str_tbl + idx , str_len - 1 ) ) ; off += 1 + len ; break ; case 0xC0 : case 0xC1 : case 0xC2 : proto_tree_add_text ( tree , tvb , off , 1 , "<S2SV_blank><S2SV_blank>%3d<S2SV_blank>|<S2SV_blank><S2SV_blank>Attr<S2SV_blank>|<S2SV_blank>A<S2SV_blank>%3d<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>" "|<S2SV_blank>EXT_%1x<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>(Extension<S2SV_blank>Token)<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>" "|<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>%s(%s)" , level , * codepage_attr , peek & 0x0f , Indent ( level ) , map_token ( map -> global , 0 , peek ) ) ; off ++ ; break ; case 0xC3 : if ( tvb_get_guint8 ( tvb , 0 ) ) { char * str ; if ( attr_save_known ) { if ( map -> opaque_binary_attr ) { str = map -> opaque_binary_attr ( tvb , off + 1 , attr_save_known , * codepage_attr , & len ) ; } else { str = default_opaque_binary_attr ( tvb , off + 1 , attr_save_known , * codepage_attr , & len ) ; } } else { if ( map -> opaque_literal_tag ) { str = map -> opaque_literal_attr ( tvb , off + 1 , attr_save_literal , * codepage_attr , & len ) ; } else { str = default_opaque_literal_attr ( tvb , off + 1 , attr_save_literal , * codepage_attr , & len ) ; } } proto_tree_add_text ( tree , tvb , off , 1 + len , "<S2SV_blank><S2SV_blank>%3d<S2SV_blank>|<S2SV_blank><S2SV_blank>Attr<S2SV_blank>|<S2SV_blank>A<S2SV_blank>%3d<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>" "|<S2SV_blank>OPAQUE<S2SV_blank>(Opaque<S2SV_blank>data)<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>" "|<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>%s%s" , level , * codepage_attr , Indent ( level ) , str ) ; off += 1 + len ; } else { proto_tree_add_text ( tree , tvb , off , 1 , "<S2SV_blank><S2SV_blank>%3d<S2SV_blank>|<S2SV_blank><S2SV_blank>Attr<S2SV_blank>|<S2SV_blank>A<S2SV_blank>%3d<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>" "|<S2SV_blank>RESERVED_2<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>(Invalid<S2SV_blank>Token!)<S2SV_blank>" "|<S2SV_blank>WBXML<S2SV_blank>1.0<S2SV_blank>parsing<S2SV_blank>stops<S2SV_blank>here." , level , * codepage_attr ) ; off = tvb_len ; DebugLog ( ( "ATTR:<S2SV_blank>level<S2SV_blank>=<S2SV_blank>%u,<S2SV_blank>Return:<S2SV_blank>len<S2SV_blank>=<S2SV_blank>%u\\n" , level , off - offset ) ) ; return ( off - offset ) ; } break ; default : proto_tree_add_text ( tree , tvb , off , 1 , "<S2SV_blank><S2SV_blank>%3d<S2SV_blank>|<S2SV_blank><S2SV_blank>Attr<S2SV_blank>|<S2SV_blank>A<S2SV_blank>%3d<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>" "|<S2SV_blank>%-10s<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>(Invalid<S2SV_blank>Token!)<S2SV_blank>" "|<S2SV_blank>WBXML<S2SV_blank>parsing<S2SV_blank>stops<S2SV_blank>here." , level , * codepage_attr , val_to_str_ext ( peek , & vals_wbxml1x_global_tokens_ext , "(unknown<S2SV_blank>0x%x)" ) ) ; off = tvb_len ; break ; } else { if ( peek & 0x80 ) { proto_tree_add_text ( tree , tvb , off , 1 , "<S2SV_blank><S2SV_blank>%3d<S2SV_blank>|<S2SV_blank><S2SV_blank>Attr<S2SV_blank>|<S2SV_blank>A<S2SV_blank>%3d<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>" "|<S2SV_blank><S2SV_blank><S2SV_blank>Known<S2SV_blank>attrValue<S2SV_blank>0x%02X<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>" "|<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>%s%s" , level , * codepage_attr , peek & 0x7f , Indent ( level ) , map_token ( map -> attrValue , * codepage_attr , peek ) ) ; off ++ ; } else { attr_save_known = peek & 0x7f ; proto_tree_add_text ( tree , tvb , off , 1 , "<S2SV_blank><S2SV_blank>%3d<S2SV_blank>|<S2SV_blank><S2SV_blank>Attr<S2SV_blank>|<S2SV_blank>A<S2SV_blank>%3d<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>" "|<S2SV_blank><S2SV_blank><S2SV_blank>Known<S2SV_blank>attrStart<S2SV_blank>0x%02X<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>" "|<S2SV_blank><S2SV_blank><S2SV_blank>%s%s" , level , * codepage_attr , attr_save_known , Indent ( level ) , map_token ( map -> attrStart , * codepage_attr , peek ) ) ; off ++ ; <S2SV_StartBug> } } } <S2SV_EndBug> DebugLog ( ( "ATTR:<S2SV_blank>level<S2SV_blank>=<S2SV_blank>%u,<S2SV_blank>Return:<S2SV_blank>len<S2SV_blank>=<S2SV_blank>%u<S2SV_blank>(end<S2SV_blank>of<S2SV_blank>function<S2SV_blank>body)\\n" , level , off - offset ) ) ; return ( off - offset ) ; }
<S2SV_ModStart> off = offset , last_off <S2SV_ModStart> offset ) ) ; last_off = off <S2SV_ModStart> ; } } if ( off < last_off ) { THROW ( ReportedBoundsError ) ; } last_off = off ;
26
CWE-119 void vp9_encode_frame ( VP9_COMP * cpi ) { VP9_COMMON * const cm = & cpi -> common ; if ( ! frame_is_intra_only ( cm ) ) { if ( ( cm -> ref_frame_sign_bias [ ALTREF_FRAME ] == cm -> ref_frame_sign_bias [ GOLDEN_FRAME ] ) || ( cm -> ref_frame_sign_bias [ ALTREF_FRAME ] == cm -> ref_frame_sign_bias [ LAST_FRAME ] ) <S2SV_StartBug> ) { cm -> allow_comp_inter_inter = 0 ; } else { <S2SV_StartBug> cm -> allow_comp_inter_inter <S2SV_EndBug> = 1 ; cm -> comp_fixed_ref = ALTREF_FRAME <S2SV_EndBug> ; cm -> comp_var_ref [ 0 ] = LAST_FRAME ; cm -> comp_var_ref [ 1 ] = GOLDEN_FRAME ; } } if ( cpi -> sf . <S2SV_StartBug> frame_parameter_update ) { int i ; const MV_REFERENCE_FRAME frame_type = get_frame_type <S2SV_EndBug> <S2SV_StartBug> ( cpi ) ; const int64_t * mode_thresh = cpi -> rd_prediction_type_threshes [ frame_type ] ; <S2SV_StartBug> <S2SV_EndBug> const int64_t * filter_thresh = cpi -> rd_filter_threshes <S2SV_EndBug> [ <S2SV_StartBug> frame_type ] ; if ( frame_type == ALTREF_FRAME || ! cm -> allow_comp_inter_inter ) cm -> reference_mode = SINGLE_REFERENCE <S2SV_StartBug> <S2SV_EndBug> ; else if ( mode_thresh [ COMPOUND_REFERENCE ] > mode_thresh [ SINGLE_REFERENCE ] && <S2SV_EndBug> <S2SV_StartBug> mode_thresh [ COMPOUND_REFERENCE ] > <S2SV_StartBug> mode_thresh [ <S2SV_EndBug> <S2SV_EndBug> REFERENCE_MODE_SELECT ] && check_dual_ref_flags ( cpi ) && cpi -> static_mb_pct == 100 ) cm -> reference_mode = COMPOUND_REFERENCE ; else if ( mode_thresh <S2SV_StartBug> [ SINGLE_REFERENCE ] > mode_thresh [ <S2SV_EndBug> REFERENCE_MODE_SELECT ] ) cm -> reference_mode = SINGLE_REFERENCE ; else cm -> reference_mode = REFERENCE_MODE_SELECT ; if ( <S2SV_StartBug> cm -> <S2SV_EndBug> interp_filter == SWITCHABLE ) { if ( frame_type != ALTREF_FRAME && filter_thresh [ EIGHTTAP_SMOOTH ] > filter_thresh [ EIGHTTAP ] && filter_thresh [ EIGHTTAP_SMOOTH ] > filter_thresh [ EIGHTTAP_SHARP ] && filter_thresh [ EIGHTTAP_SMOOTH ] > filter_thresh [ SWITCHABLE - 1 ] ) { cm <S2SV_StartBug> -> interp_filter = EIGHTTAP_SMOOTH ; } else if ( <S2SV_EndBug> filter_thresh [ EIGHTTAP_SHARP ] > filter_thresh [ EIGHTTAP ] && filter_thresh [ EIGHTTAP_SHARP ] > filter_thresh [ SWITCHABLE - 1 ] ) { cm -> interp_filter = EIGHTTAP_SHARP ; } else if ( filter_thresh [ EIGHTTAP ] > filter_thresh [ SWITCHABLE - 1 ] ) { cm -> interp_filter = EIGHTTAP ; } } encode_frame_internal ( cpi ) ; for ( <S2SV_StartBug> i = 0 ; i < REFERENCE_MODES ; ++ i ) { <S2SV_StartBug> <S2SV_EndBug> const int diff = ( int ) ( cpi -> rd_comp_pred_diff [ i ] / cm <S2SV_EndBug> -> MBs ) ; cpi -> rd_prediction_type_threshes [ frame_type ] [ i ] += diff ; cpi -> rd_prediction_type_threshes [ frame_type ] [ i ] >>= 1 ; } for ( i = <S2SV_StartBug> 0 ; i < SWITCHABLE_FILTER_CONTEXTS ; i ++ <S2SV_StartBug> <S2SV_EndBug> ) { const int64_t diff = cpi -> rd_filter_diff [ i ] / cm -> MBs ; cpi -> rd_filter_threshes [ <S2SV_EndBug> frame_type ] [ i ] = ( cpi -> rd_filter_threshes [ frame_type ] [ i ] + diff ) / 2 ; <S2SV_StartBug> } for <S2SV_EndBug> ( i = 0 ; i < TX_MODES ; ++ i ) { int64_t pd = cpi -> rd_tx_select_diff [ i ] ; int diff ; if ( i == TX_MODE_SELECT ) pd -= RDCOST ( cpi -> mb . rdmult , cpi -> mb . rddiv , 2048 * ( TX_SIZES - 1 ) , 0 ) ; diff = ( int ) ( pd / cm -> MBs ) ; cpi -> rd_tx_select_threshes [ frame_type ] [ i ] += diff ; cpi -> rd_tx_select_threshes [ frame_type ] [ i ] /= 2 ; } if ( cm -> reference_mode == REFERENCE_MODE_SELECT ) { int single_count_zero = 0 ; int comp_count_zero = 0 ; for ( i = 0 ; i < COMP_INTER_CONTEXTS ; i ++ ) { <S2SV_StartBug> single_count_zero += cm -> counts . comp_inter [ i ] [ 0 ] ; <S2SV_StartBug> comp_count_zero += <S2SV_EndBug> cm -> counts . comp_inter [ i ] [ <S2SV_EndBug> 1 ] ; } if ( comp_count_zero == 0 ) { cm -> reference_mode = SINGLE_REFERENCE ; vp9_zero ( cm <S2SV_StartBug> -> <S2SV_EndBug> counts . comp_inter ) ; } else if ( single_count_zero == 0 ) { cm <S2SV_StartBug> -> reference_mode = COMPOUND_REFERENCE ; vp9_zero ( cm -> counts <S2SV_EndBug> . comp_inter ) ; } } if ( cm -> tx_mode == TX_MODE_SELECT ) { int count4x4 = 0 ; int count8x8_lp = 0 , count8x8_8x8p = 0 ; int count16x16_16x16p = 0 , count16x16_lp = 0 ; int count32x32 = 0 ; for ( i = 0 ; i < TX_SIZE_CONTEXTS ; <S2SV_StartBug> ++ i ) { count4x4 += cm -> counts . tx . p32x32 [ i ] [ TX_4X4 ] ; <S2SV_StartBug> <S2SV_EndBug> count4x4 += cm -> counts . tx . p16x16 [ i ] <S2SV_StartBug> <S2SV_EndBug> [ TX_4X4 ] ; count4x4 += cm -> counts . tx . p8x8 [ i ] [ TX_4X4 ] ; <S2SV_StartBug> <S2SV_EndBug> count8x8_lp += cm -> counts . tx . p32x32 [ i ] <S2SV_EndBug> [ TX_8X8 <S2SV_StartBug> ] ; count8x8_lp += cm -> counts . tx . p16x16 [ i <S2SV_EndBug> ] [ TX_8X8 ] ; count8x8_8x8p <S2SV_StartBug> += cm -> counts . tx . p8x8 [ i ] [ TX_8X8 ] ; <S2SV_StartBug> count16x16_16x16p += <S2SV_EndBug> cm -> counts . tx . p16x16 [ i ] [ TX_16X16 ] <S2SV_EndBug> ; count16x16_lp += cm -> <S2SV_StartBug> counts . tx . p32x32 [ i ] [ TX_16X16 ] ; <S2SV_StartBug> <S2SV_EndBug> count32x32 += cm -> counts . tx . p32x32 [ i ] [ <S2SV_EndBug> TX_32X32 ] ; } if ( count4x4 == 0 && count16x16_lp == 0 && count16x16_16x16p == 0 && count32x32 == 0 ) { cm -> <S2SV_StartBug> tx_mode = ALLOW_8X8 ; reset_skip_txfm_size ( cm , TX_8X8 ) ; } else if ( <S2SV_EndBug> count8x8_8x8p == 0 && count16x16_16x16p == 0 && count8x8_lp == 0 && count16x16_lp == 0 && count32x32 == 0 ) { cm -> tx_mode = ONLY_4X4 ; reset_skip_txfm_size ( cm <S2SV_StartBug> , TX_4X4 <S2SV_EndBug> ) ; } else if ( count8x8_lp == 0 && count16x16_lp == 0 && count4x4 == 0 ) { cm -> tx_mode = ALLOW_32X32 ; } else if ( count32x32 == 0 && count8x8_lp == 0 && count4x4 == 0 ) { cm -> tx_mode <S2SV_StartBug> = ALLOW_16X16 ; reset_skip_txfm_size ( cm , TX_16X16 <S2SV_EndBug> ) ; } } } else { cm <S2SV_StartBug> -> reference_mode = SINGLE_REFERENCE ; cm -> interp_filter = SWITCHABLE ; <S2SV_EndBug> encode_frame_internal ( cpi ) ; } }
<S2SV_ModStart> ) ) { cpi <S2SV_ModEnd> -> allow_comp_inter_inter = <S2SV_ModStart> } else { cpi <S2SV_ModEnd> -> allow_comp_inter_inter = <S2SV_ModStart> { int i ; RD_OPT * const rd_opt = & cpi -> rd ; FRAME_COUNTS * counts = cpi -> td . counts ; RD_COUNTS * const rdc = & cpi -> td . rd_counts <S2SV_ModStart> cpi ) ; int64_t * const mode_thrs = rd_opt -> prediction_type_threshes <S2SV_ModEnd> [ frame_type ] <S2SV_ModStart> frame_type ] ; int64_t * const filter_thrs = rd_opt -> filter_threshes <S2SV_ModEnd> [ frame_type ] <S2SV_ModStart> frame_type ] ; const int is_alt_ref = <S2SV_ModEnd> frame_type == ALTREF_FRAME <S2SV_ModStart> frame_type == ALTREF_FRAME ; if ( is_alt_ref || ! cpi <S2SV_ModEnd> -> allow_comp_inter_inter ) <S2SV_ModStart> else if ( mode_thrs <S2SV_ModEnd> [ COMPOUND_REFERENCE ] <S2SV_ModStart> COMPOUND_REFERENCE ] > mode_thrs <S2SV_ModEnd> [ SINGLE_REFERENCE ] <S2SV_ModStart> SINGLE_REFERENCE ] && mode_thrs <S2SV_ModEnd> [ COMPOUND_REFERENCE ] <S2SV_ModStart> COMPOUND_REFERENCE ] > mode_thrs <S2SV_ModEnd> [ REFERENCE_MODE_SELECT ] <S2SV_ModStart> else if ( mode_thrs <S2SV_ModEnd> [ SINGLE_REFERENCE ] <S2SV_ModStart> SINGLE_REFERENCE ] > mode_thrs <S2SV_ModEnd> [ REFERENCE_MODE_SELECT ] <S2SV_ModStart> == SWITCHABLE ) <S2SV_ModEnd> cm -> interp_filter <S2SV_ModStart> -> interp_filter = get_interp_filter ( filter_thrs , is_alt_ref ) ; <S2SV_ModEnd> encode_frame_internal ( cpi <S2SV_ModStart> ++ i ) mode_thrs [ i ] = ( mode_thrs [ i ] + rdc -> comp_pred_diff <S2SV_ModEnd> [ i ] <S2SV_ModStart> -> MBs ) / 2 ; <S2SV_ModEnd> for ( i <S2SV_ModStart> < SWITCHABLE_FILTER_CONTEXTS ; ++ i ) filter_thrs [ i ] = ( filter_thrs [ i ] + rdc -> filter_diff <S2SV_ModEnd> [ i ] <S2SV_ModStart> cm -> MBs <S2SV_ModEnd> ) / 2 <S2SV_ModStart> / 2 ; <S2SV_ModEnd> if ( cm <S2SV_ModStart> { single_count_zero += counts -> <S2SV_ModEnd> comp_inter [ i <S2SV_ModStart> ; comp_count_zero += counts -> <S2SV_ModEnd> comp_inter [ i <S2SV_ModStart> ; vp9_zero ( counts -> <S2SV_ModEnd> comp_inter ) ; <S2SV_ModStart> ; vp9_zero ( counts -> <S2SV_ModEnd> comp_inter ) ; <S2SV_ModStart> { count4x4 += counts -> <S2SV_ModEnd> tx . p32x32 <S2SV_ModStart> ; count4x4 += counts -> <S2SV_ModEnd> tx . p16x16 <S2SV_ModStart> ; count4x4 += counts -> <S2SV_ModEnd> tx . p8x8 <S2SV_ModStart> ; count8x8_lp += counts -> <S2SV_ModEnd> tx . p32x32 <S2SV_ModStart> ; count8x8_lp += counts -> <S2SV_ModEnd> tx . p16x16 <S2SV_ModStart> ; count8x8_8x8p += counts -> <S2SV_ModEnd> tx . p8x8 <S2SV_ModStart> ; count16x16_16x16p += counts -> <S2SV_ModEnd> tx . p16x16 <S2SV_ModStart> ; count16x16_lp += counts -> <S2SV_ModEnd> tx . p32x32 <S2SV_ModStart> ; count32x32 += counts -> <S2SV_ModEnd> tx . p32x32 <S2SV_ModStart> = ALLOW_8X8 ; reset_skip_tx_size <S2SV_ModEnd> ( cm , <S2SV_ModStart> = ONLY_4X4 ; reset_skip_tx_size <S2SV_ModEnd> ( cm , <S2SV_ModStart> = ALLOW_16X16 ; reset_skip_tx_size <S2SV_ModEnd> ( cm , <S2SV_ModStart> = SINGLE_REFERENCE ; <S2SV_ModEnd> encode_frame_internal ( cpi
27
CWE-787 int input_set_keycode ( struct input_dev * dev , const struct input_keymap_entry * ke ) { unsigned long flags ; unsigned int old_keycode ; int retval ; if ( ke -> keycode > KEY_MAX ) return - EINVAL ; spin_lock_irqsave ( & dev -> event_lock , flags ) ; retval = dev -> setkeycode ( dev , ke , & old_keycode ) ; if ( retval ) goto out ; __clear_bit ( KEY_RESERVED , dev -> keybit ) ; if ( test_bit ( EV_KEY <S2SV_StartBug> , <S2SV_EndBug> dev -> evbit ) && ! is_event_supported ( old_keycode , dev -> keybit , KEY_MAX ) && __test_and_clear_bit ( old_keycode , dev -> key ) ) { struct input_value vals [ ] = { { EV_KEY , old_keycode , 0 } , input_value_sync } ; input_pass_values ( dev , vals , ARRAY_SIZE ( vals ) ) ; } out : spin_unlock_irqrestore ( & dev -> event_lock , flags ) ; return retval ; }
<S2SV_ModStart> keybit ) ; if ( old_keycode > KEY_MAX ) { dev_warn ( dev -> dev . parent ? : & dev -> dev , "%s:<S2SV_blank>got<S2SV_blank>too<S2SV_blank>big<S2SV_blank>old<S2SV_blank>keycode<S2SV_blank>%#x\\n" , __func__ , old_keycode ) ; } else
28
CWE-000 static struct sk_buff * udp6_ufo_fragment ( struct sk_buff * skb , u32 features ) { struct sk_buff * segs = ERR_PTR ( - EINVAL ) ; unsigned int mss ; unsigned int unfrag_ip6hlen , unfrag_len ; struct frag_hdr * fptr ; u8 * mac_start , * prevhdr ; u8 nexthdr ; u8 frag_hdr_sz = sizeof ( struct frag_hdr ) ; int offset ; __wsum csum ; mss = skb_shinfo ( skb ) -> gso_size ; if ( unlikely ( skb -> len <= mss ) ) goto out ; if ( skb_gso_ok ( skb , features | NETIF_F_GSO_ROBUST ) ) { int type = skb_shinfo ( skb ) -> gso_type ; if ( unlikely ( type & ~ ( SKB_GSO_UDP | SKB_GSO_DODGY ) || ! ( type & ( SKB_GSO_UDP ) ) ) ) goto out ; skb_shinfo ( skb ) -> gso_segs = DIV_ROUND_UP ( skb -> len , mss ) ; segs = NULL ; goto out ; } offset = skb_checksum_start_offset ( skb ) ; csum = skb_checksum ( skb , offset , skb -> len - offset , 0 ) ; offset += skb -> csum_offset ; * ( __sum16 * ) ( skb -> data + offset ) = csum_fold ( csum ) ; skb -> ip_summed = CHECKSUM_NONE ; if ( ( skb_mac_header ( skb ) < skb -> head + frag_hdr_sz ) && pskb_expand_head ( skb , frag_hdr_sz , 0 , GFP_ATOMIC ) ) goto out ; unfrag_ip6hlen = ip6_find_1stfragopt ( skb , & prevhdr ) ; nexthdr = * prevhdr ; * prevhdr = NEXTHDR_FRAGMENT ; unfrag_len = skb_network_header ( skb ) - skb_mac_header ( skb ) + unfrag_ip6hlen ; mac_start = skb_mac_header ( skb ) ; memmove ( mac_start - frag_hdr_sz , mac_start , unfrag_len ) ; skb -> mac_header -= frag_hdr_sz ; skb -> network_header -= frag_hdr_sz ; fptr = ( struct frag_hdr * ) ( skb_network_header ( skb ) + unfrag_ip6hlen ) ; fptr -> nexthdr = nexthdr ; fptr -> reserved = 0 ; ipv6_select_ident <S2SV_StartBug> ( fptr ) ; <S2SV_EndBug> segs = skb_segment ( skb , features ) ; out : return segs ; }
<S2SV_ModStart> ipv6_select_ident ( fptr , ( struct rt6_info * ) skb_dst ( skb )
29
CWE-189 BOOL license_read_scope_list ( wStream * s , SCOPE_LIST * scopeList ) { UINT32 i ; UINT32 scopeCount ; if ( Stream_GetRemainingLength ( s ) < 4 ) return FALSE ; Stream_Read_UINT32 <S2SV_StartBug> ( s , scopeCount ) <S2SV_EndBug> ; scopeList -> count = scopeCount ; scopeList -> array = ( LICENSE_BLOB * ) malloc ( sizeof ( LICENSE_BLOB ) * scopeCount ) ; for ( i = 0 ; i < scopeCount ; i ++ ) { scopeList -> array [ i ] . type = BB_SCOPE_BLOB ; if ( ! license_read_binary_blob ( s , & scopeList -> array [ i ] ) ) return FALSE ; } return TRUE ; }
<S2SV_ModStart> , scopeCount ) ; if ( Stream_GetRemainingLength ( s ) / sizeof ( LICENSE_BLOB ) < scopeCount ) return FALSE
30
CWE-400 void __perf_sw_event <S2SV_StartBug> ( u32 event_id , u64 nr , int nmi , struct <S2SV_EndBug> pt_regs * regs , u64 addr ) { struct perf_sample_data data ; int rctx ; preempt_disable_notrace ( ) ; rctx = perf_swevent_get_recursion_context ( ) ; if ( rctx < 0 ) return ; perf_sample_data_init ( & data , addr ) ; do_perf_sw_event ( PERF_TYPE_SOFTWARE , <S2SV_StartBug> event_id , nr , nmi , & data , regs ) ; perf_swevent_put_recursion_context ( rctx ) <S2SV_EndBug> ; preempt_enable_notrace ( ) ; }
<S2SV_ModStart> u64 nr , <S2SV_ModEnd> struct pt_regs * <S2SV_ModStart> , nr , <S2SV_ModEnd> & data ,
31
CWE-000 struct key * key_alloc ( struct key_type * type , const char * desc , kuid_t uid , kgid_t gid , const struct cred * cred , key_perm_t perm , unsigned long flags , struct key_restriction * restrict_link ) { struct key_user * user = NULL ; struct key * key ; size_t desclen , quotalen ; int ret ; key = ERR_PTR ( - EINVAL ) ; if ( ! desc || ! * desc ) goto error ; if ( type -> vet_description ) { ret = type -> vet_description ( desc ) ; if ( ret < 0 ) { key = ERR_PTR ( ret ) ; goto error ; } } desclen = strlen ( desc ) ; quotalen = desclen + 1 + type -> def_datalen ; user = key_user_lookup ( uid ) ; if ( ! user ) goto no_memory_1 ; if ( ! ( flags & KEY_ALLOC_NOT_IN_QUOTA ) ) { unsigned maxkeys = uid_eq ( uid , GLOBAL_ROOT_UID ) ? key_quota_root_maxkeys : key_quota_maxkeys ; unsigned maxbytes = uid_eq ( uid , GLOBAL_ROOT_UID ) ? key_quota_root_maxbytes : key_quota_maxbytes ; spin_lock ( & user -> lock ) ; if ( ! ( flags & KEY_ALLOC_QUOTA_OVERRUN ) ) { if ( user -> qnkeys + 1 >= maxkeys || user -> qnbytes + quotalen >= maxbytes || user -> qnbytes + quotalen < user -> qnbytes ) goto no_quota ; } user -> qnkeys ++ ; user -> qnbytes += quotalen ; spin_unlock ( & user -> lock ) ; } key = kmem_cache_zalloc ( key_jar , GFP_KERNEL ) ; if ( ! key ) goto no_memory_2 ; key -> index_key . desc_len = desclen ; key -> index_key . description = kmemdup ( desc , desclen + 1 , GFP_KERNEL ) ; if ( ! key -> index_key . description ) goto no_memory_3 ; refcount_set ( & key -> usage , 1 ) ; init_rwsem ( & key -> sem ) ; lockdep_set_class ( & key -> sem , & type -> lock_class ) ; key -> index_key . type = type ; key -> user = user ; key -> quotalen = quotalen ; key -> datalen = type -> def_datalen ; key -> uid = uid ; key -> gid = gid ; key -> perm = perm ; key -> restrict_link = restrict_link ; if ( ! ( flags & KEY_ALLOC_NOT_IN_QUOTA ) ) key -> flags |= 1 << KEY_FLAG_IN_QUOTA ; if ( flags & KEY_ALLOC_BUILT_IN ) key -> flags |= 1 << KEY_FLAG_BUILTIN <S2SV_StartBug> ; # ifdef KEY_DEBUGGING <S2SV_EndBug> key -> magic = KEY_DEBUG_MAGIC ; # endif ret = security_key_alloc ( key , cred , flags ) ; if ( ret < 0 ) goto security_error ; atomic_inc ( & user -> nkeys ) ; key_alloc_serial ( key ) ; error : return key ; security_error : kfree ( key -> description ) ; kmem_cache_free ( key_jar , key ) ; if ( ! ( flags & KEY_ALLOC_NOT_IN_QUOTA ) ) { spin_lock ( & user -> lock ) ; user -> qnkeys -- ; user -> qnbytes -= quotalen ; spin_unlock ( & user -> lock ) ; } key_user_put ( user ) ; key = ERR_PTR ( ret ) ; goto error ; no_memory_3 : kmem_cache_free ( key_jar , key ) ; no_memory_2 : if ( ! ( flags & KEY_ALLOC_NOT_IN_QUOTA ) ) { spin_lock ( & user -> lock ) ; user -> qnkeys -- ; user -> qnbytes -= quotalen ; spin_unlock ( & user -> lock ) ; } key_user_put ( user ) ; no_memory_1 : key = ERR_PTR ( - ENOMEM ) ; goto error ; no_quota : spin_unlock ( & user -> lock ) ; key_user_put ( user ) ; key = ERR_PTR ( - EDQUOT ) ; goto error ; }
<S2SV_ModStart> << KEY_FLAG_BUILTIN ; if ( flags & KEY_ALLOC_UID_KEYRING ) key -> flags |= 1 << KEY_FLAG_UID_KEYRING ;
32
CWE-20 int tls1_mac ( SSL * ssl , SSL3_RECORD * rec , unsigned char * md , int send ) { unsigned char * seq ; EVP_MD_CTX * hash ; size_t md_size ; int i ; EVP_MD_CTX * hmac = NULL , * mac_ctx ; unsigned char header [ 13 ] ; int stream_mac = ( send ? ( ssl -> mac_flags & SSL_MAC_FLAG_WRITE_MAC_STREAM ) : ( ssl -> mac_flags & SSL_MAC_FLAG_READ_MAC_STREAM ) ) ; int t ; if ( send ) { seq = RECORD_LAYER_get_write_sequence ( & ssl -> rlayer ) ; hash = ssl -> write_hash ; } else { seq = RECORD_LAYER_get_read_sequence ( & ssl -> rlayer ) ; hash = ssl -> read_hash ; } t = EVP_MD_CTX_size ( hash ) ; OPENSSL_assert ( t >= 0 ) ; md_size = t ; if ( stream_mac ) { mac_ctx = hash ; } else { hmac = EVP_MD_CTX_new ( ) ; if ( hmac == NULL || ! EVP_MD_CTX_copy ( hmac , hash ) ) return - 1 ; mac_ctx = hmac ; } if ( SSL_IS_DTLS ( ssl ) ) { unsigned char dtlsseq [ 8 ] , * p = dtlsseq ; s2n ( send ? DTLS_RECORD_LAYER_get_w_epoch ( & ssl -> rlayer ) : DTLS_RECORD_LAYER_get_r_epoch ( & ssl -> rlayer ) , p ) ; memcpy ( p , & seq [ 2 ] , 6 ) ; memcpy ( header , dtlsseq , 8 ) ; } else memcpy ( header , seq , 8 ) ; header [ 8 ] = rec -> type ; header [ 9 ] = ( unsigned char ) ( ssl -> version >> 8 ) ; header [ 10 ] = ( unsigned char ) ( ssl -> version ) ; header [ 11 ] = ( rec -> length ) >> 8 ; header [ 12 ] = ( rec -> length ) & 0xff ; if <S2SV_StartBug> ( ! send && ! SSL_USE_ETM ( ssl ) && EVP_CIPHER_CTX_mode ( <S2SV_EndBug> ssl -> enc_read_ctx ) == EVP_CIPH_CBC_MODE && ssl3_cbc_record_digest_supported ( mac_ctx ) ) { if ( ssl3_cbc_digest_record ( mac_ctx , md , & md_size , header , rec -> input , rec -> length + md_size , rec -> orig_len , ssl -> s3 -> read_mac_secret , ssl -> s3 -> read_mac_secret_size , 0 ) <= 0 ) { EVP_MD_CTX_free ( hmac ) ; return - 1 ; } } else { if ( EVP_DigestSignUpdate ( mac_ctx , header , sizeof ( header ) ) <= 0 || EVP_DigestSignUpdate ( mac_ctx , rec -> input , rec -> length ) <= 0 || EVP_DigestSignFinal ( mac_ctx , md , & md_size ) <= 0 ) { EVP_MD_CTX_free ( hmac ) ; return <S2SV_StartBug> - 1 ; } if ( ! send && ! SSL_USE_ETM ( ssl ) && FIPS_mode <S2SV_EndBug> ( ) ) if ( ! tls_fips_digest_extra ( ssl -> enc_read_ctx , mac_ctx , rec -> input , rec -> length , rec -> orig_len ) ) { EVP_MD_CTX_free ( hmac ) ; return - 1 ; } } EVP_MD_CTX_free ( hmac ) ; # ifdef SSL_DEBUG fprintf ( stderr , "seq=" ) ; { int z ; for ( z = 0 ; z < 8 ; z ++ ) fprintf ( stderr , "%02X<S2SV_blank>" , seq [ z ] ) ; fprintf ( stderr , "\\n" ) ; } fprintf ( stderr , "rec=" ) ; { unsigned int z ; for ( z = 0 ; z < rec -> length ; z ++ ) fprintf ( stderr , "%02X<S2SV_blank>" , rec -> data [ z ] ) ; fprintf ( stderr , "\\n" ) ; } # endif if ( ! SSL_IS_DTLS ( ssl ) ) { for ( i = 7 ; i >= 0 ; i -- ) { ++ seq [ i ] ; if ( seq [ i ] != 0 ) break ; } } # ifdef SSL_DEBUG { unsigned int z ; for ( z = 0 ; z < md_size ; z ++ ) fprintf ( stderr , "%02X<S2SV_blank>" , md [ z ] ) ; fprintf ( stderr , "\\n" ) ; } # endif return ( md_size ) ; }
<S2SV_ModStart> send && ! SSL_READ_ETM <S2SV_ModEnd> ( ssl ) <S2SV_ModStart> send && ! SSL_READ_ETM <S2SV_ModEnd> ( ssl )
33
CWE-17 int do_remount_sb ( struct super_block * sb , int flags , void * data , int force ) { int retval ; int remount_ro ; if ( sb -> s_writers . frozen != SB_UNFROZEN ) return - EBUSY ; # ifdef CONFIG_BLOCK if ( ! ( flags & MS_RDONLY ) && bdev_read_only ( sb -> s_bdev ) ) return - EACCES ; # endif if ( flags & MS_RDONLY ) acct_auto_close ( sb ) ; shrink_dcache_sb ( sb ) ; sync_filesystem ( sb ) ; remount_ro = ( flags & MS_RDONLY ) && ! ( sb -> s_flags & MS_RDONLY ) ; if ( remount_ro ) { if ( force ) { <S2SV_StartBug> mark_files_ro ( sb ) ; <S2SV_EndBug> } else { retval = sb_prepare_remount_readonly ( sb ) ; if ( retval ) return retval ; } } if ( sb -> s_op -> remount_fs ) { retval = sb -> s_op -> remount_fs ( sb , & flags , data ) ; if ( retval ) { if ( ! force ) goto cancel_readonly ; WARN ( 1 , "forced<S2SV_blank>remount<S2SV_blank>of<S2SV_blank>a<S2SV_blank>%s<S2SV_blank>fs<S2SV_blank>returned<S2SV_blank>%i\\n" , sb -> s_type -> name , retval ) ; } } sb -> s_flags = ( sb -> s_flags & ~ MS_RMT_MASK ) | ( flags & MS_RMT_MASK ) ; smp_wmb ( ) ; sb -> s_readonly_remount = 0 ; if ( remount_ro && sb -> s_bdev ) invalidate_bdev ( sb -> s_bdev ) ; return 0 ; cancel_readonly : sb -> s_readonly_remount = 0 ; return retval ; }
<S2SV_ModStart> force ) { sb -> s_readonly_remount = 1 ; smp_wmb ( <S2SV_ModEnd> ) ; }
34
CWE-476 static GsfInfileTar * tar_directory_for_file ( GsfInfileTar * dir , const char * name , gboolean last ) { const char * s = name ; while ( 1 ) { const char * s0 = s ; char * dirname ; while ( 1 ) { if ( * s == 0 ) { if ( last && s != s0 ) break ; else return dir ; } if ( * s == '/' ) break ; s ++ ; } dirname = g_strndup ( s0 , s - s0 ) ; while ( * s == '/' ) s ++ ; if ( strcmp ( dirname , "." ) != 0 ) { GsfInput * subdir = gsf_infile_child_by_name ( GSF_INFILE ( dir ) , dirname ) ; if ( subdir ) { <S2SV_StartBug> g_object_unref ( subdir <S2SV_EndBug> ) ; dir = GSF_INFILE_TAR ( subdir <S2SV_StartBug> ) ; } else <S2SV_EndBug> dir = tar_create_dir ( dir , dirname ) ; } g_free ( dirname ) ; } }
<S2SV_ModStart> subdir ) { dir = GSF_IS_INFILE_TAR ( subdir ) ? GSF_INFILE_TAR ( subdir ) : dir ; <S2SV_ModStart> subdir ) ; <S2SV_ModEnd> } else dir
35
CWE-119 static grub_disk_addr_t grub_ext2_read_block ( grub_fshelp_node_t node , grub_disk_addr_t fileblock ) { struct grub_ext2_data * data = node -> data ; struct grub_ext2_inode * inode = & node -> inode ; int blknr = - 1 ; unsigned int blksz = EXT2_BLOCK_SIZE ( data ) ; int log2_blksz = LOG2_EXT2_BLOCK_SIZE ( data ) ; if ( grub_le_to_cpu32 ( inode -> flags ) & <S2SV_StartBug> EXT4_EXTENTS_FLAG ) { # ifndef _MSC_VER <S2SV_StartBug> char buf [ EXT2_BLOCK_SIZE <S2SV_EndBug> ( data <S2SV_EndBug> ) ] ; # else char * buf = grub_malloc ( EXT2_BLOCK_SIZE ( data ) ) ; # endif struct grub_ext4_extent_header * leaf ; struct grub_ext4_extent * ext ; int i ; leaf = grub_ext4_find_leaf ( data , buf , ( struct grub_ext4_extent_header * ) inode -> blocks . dir_blocks , fileblock ) ; if ( <S2SV_StartBug> ! leaf ) { grub_error ( GRUB_ERR_BAD_FS , "invalid<S2SV_blank>extent" ) ; return - <S2SV_EndBug> 1 ; } ext = ( struct grub_ext4_extent * ) ( leaf + 1 ) ; for ( i = 0 ; i < grub_le_to_cpu16 ( leaf -> entries ) ; i ++ ) { if ( fileblock < grub_le_to_cpu32 ( ext [ i ] . block ) ) break ; } if ( -- i >= 0 ) { fileblock -= grub_le_to_cpu32 ( ext [ i ] . block ) <S2SV_StartBug> ; if ( fileblock >= grub_le_to_cpu16 ( ext [ i ] . len ) ) return 0 ; <S2SV_StartBug> <S2SV_EndBug> else { <S2SV_EndBug> grub_disk_addr_t start ; start = grub_le_to_cpu16 ( ext [ i ] . start_hi ) ; start = ( start << 32 ) + grub_le_to_cpu32 ( ext [ i ] . start ) ; return fileblock <S2SV_EndBug> <S2SV_StartBug> + start ; } } else { grub_error ( GRUB_ERR_BAD_FS , "something<S2SV_blank>wrong<S2SV_blank>with<S2SV_blank>extent" ) ; return - <S2SV_StartBug> 1 ; <S2SV_EndBug> } <S2SV_EndBug> <S2SV_StartBug> } if ( fileblock < INDIRECT_BLOCKS ) { blknr = grub_le_to_cpu32 ( inode -> blocks . dir_blocks [ fileblock ] ) ; } else if ( fileblock < INDIRECT_BLOCKS + blksz / 4 ) { grub_uint32_t * indir ; indir = grub_malloc ( blksz <S2SV_StartBug> ) ; if ( ! indir ) <S2SV_StartBug> <S2SV_EndBug> return grub_errno ; <S2SV_EndBug> if ( grub_disk_read ( data -> disk , ( ( grub_disk_addr_t ) grub_le_to_cpu32 ( inode -> blocks . indir_block ) <S2SV_StartBug> ) << log2_blksz , 0 , blksz , indir ) ) <S2SV_EndBug> return grub_errno ; <S2SV_EndBug> <S2SV_StartBug> blknr = grub_le_to_cpu32 ( indir [ fileblock - INDIRECT_BLOCKS ] ) ; grub_free ( indir ) ; } else if ( fileblock < ( grub_disk_addr_t ) ( INDIRECT_BLOCKS + blksz / 4 ) * ( grub_disk_addr_t ) ( blksz / 4 + 1 ) ) { unsigned int perblock = blksz / 4 ; unsigned int rblock = fileblock - ( INDIRECT_BLOCKS + blksz / 4 ) ; grub_uint32_t * indir ; indir = grub_malloc <S2SV_StartBug> ( blksz ) ; if ( ! indir <S2SV_EndBug> ) return <S2SV_StartBug> grub_errno <S2SV_EndBug> ; if ( grub_disk_read ( data -> disk , ( ( grub_disk_addr_t ) grub_le_to_cpu32 ( inode -> blocks . double_indir_block ) ) << log2_blksz , 0 <S2SV_StartBug> , blksz , indir ) ) <S2SV_StartBug> return <S2SV_EndBug> grub_errno ; if ( grub_disk_read ( data <S2SV_EndBug> -> disk , ( ( grub_disk_addr_t ) grub_le_to_cpu32 ( indir [ rblock / perblock ] ) ) << log2_blksz , 0 , blksz , <S2SV_StartBug> <S2SV_EndBug> indir ) ) return <S2SV_StartBug> grub_errno ; blknr <S2SV_EndBug> = grub_le_to_cpu32 ( indir [ rblock % perblock ] ) ; grub_free ( indir ) ; } else { grub_error ( GRUB_ERR_NOT_IMPLEMENTED_YET , "ext2fs<S2SV_blank>doesn\'t<S2SV_blank>support<S2SV_blank>triple<S2SV_blank>indirect<S2SV_blank>blocks" ) ; } return blknr ; }
<S2SV_ModStart> EXT4_EXTENTS_FLAG ) { char * buf = grub_malloc ( <S2SV_ModEnd> EXT2_BLOCK_SIZE ( data <S2SV_ModStart> ( data ) ) ; if ( ! buf ) { return - 1 ; } <S2SV_ModEnd> struct grub_ext4_extent_header * <S2SV_ModStart> GRUB_ERR_BAD_FS , "invalid<S2SV_blank>extent" ) ; free ( buf <S2SV_ModStart> len ) ) { free ( buf ) ; <S2SV_ModStart> return 0 ; } <S2SV_ModStart> start ) ; free ( buf ) ; <S2SV_ModStart> "something<S2SV_blank>wrong<S2SV_blank>with<S2SV_blank>extent" ) ; free ( buf ) ; <S2SV_ModStart> 1 ; } free ( buf ) ; <S2SV_ModStart> ! indir ) { <S2SV_ModStart> return grub_errno ; } <S2SV_ModStart> indir ) ) { <S2SV_ModStart> return grub_errno ; } <S2SV_ModStart> ! indir ) { <S2SV_ModStart> return grub_errno ; } <S2SV_ModStart> indir ) ) { <S2SV_ModStart> return grub_errno ; } <S2SV_ModStart> indir ) ) { <S2SV_ModStart> return grub_errno ; }
36
CWE-125 static RList * r_bin_wasm_get_global_entries ( RBinWasmObj * bin , RBinWasmSection * sec ) { RList * ret = NULL ; RBinWasmGlobalEntry * <S2SV_StartBug> ptr = NULL ; int buflen = bin -> <S2SV_EndBug> buf -> length ; if ( sec -> payload_data + 32 > buflen ) { return NULL ; } if ( ! ( ret = r_list_newf ( ( RListFree ) free ) ) ) { return NULL ; } ut8 * buf = bin -> buf -> buf + ( ut32 ) sec -> payload_data ; ut32 len = sec -> payload_len ; ut32 count = sec -> count ; ut32 i = 0 , r = 0 ; while ( i < len && len < buflen && r < count ) { if ( ! ( ptr = R_NEW0 ( RBinWasmGlobalEntry ) ) ) { return ret ; } if ( len + 8 > buflen || ! ( consume_u8 ( buf + i , buf + len , ( ut8 * ) & ptr -> content_type , & i ) ) ) { goto beach ; } if ( len + 8 > buflen || ! ( consume_u8 ( buf + i , buf + len , & ptr -> mutability , & i ) ) ) { goto beach ; } if ( len + 8 > buflen || ! ( consume_init_expr ( buf + i , buf + len , R_BIN_WASM_END_OF_CODE , NULL , & i ) ) ) { goto beach ; } r_list_append ( ret , ptr ) ; r ++ ; } return ret ; beach : free ( ptr ) ; return ret ; }
<S2SV_ModStart> = NULL ; if ( ! ( ret = r_list_newf ( ( RListFree ) free ) ) ) { return NULL ; } ut8 * buf = bin -> buf -> buf + ( ut32 ) sec -> payload_data ; <S2SV_ModStart> buf -> length - <S2SV_ModEnd> ( ut32 )
37
CWE-119 static void fdct16 ( <S2SV_StartBug> const int16_t in [ 16 ] , int16_t out [ 16 ] ) { <S2SV_EndBug> int step1 [ <S2SV_StartBug> 8 ] <S2SV_EndBug> ; <S2SV_StartBug> int step2 [ 8 <S2SV_EndBug> ] ; int step3 [ 8 ] <S2SV_StartBug> ; <S2SV_StartBug> int input [ <S2SV_EndBug> <S2SV_EndBug> 8 ] ; int <S2SV_StartBug> temp1 <S2SV_EndBug> , temp2 ; input [ 0 ] = in [ 0 ] + in [ 15 ] ; input [ 1 ] = in [ 1 ] + in [ 14 ] ; input [ 2 ] = in [ 2 ] + in [ 13 ] ; input [ 3 ] = in [ 3 ] + in [ 12 ] ; input [ 4 ] = in [ 4 ] + in [ 11 ] ; input [ 5 ] = in [ 5 ] + in [ 10 ] ; input [ 6 ] = in [ 6 ] + in [ 9 ] ; input [ 7 ] = in [ 7 ] + in [ 8 ] ; step1 [ 0 ] = in [ 7 ] - in [ 8 ] ; step1 [ 1 ] = in [ 6 ] - in [ 9 ] ; step1 [ 2 ] = in [ 5 ] - in [ 10 ] ; step1 [ 3 ] = in [ 4 ] - in [ 11 ] ; step1 [ 4 ] = in [ 3 ] - in [ 12 ] ; step1 [ 5 ] = in [ 2 ] - in [ 13 ] ; step1 [ 6 ] = in [ 1 ] - in [ 14 ] ; step1 [ 7 ] = in [ 0 ] - in [ 15 ] ; { int s0 , s1 , <S2SV_StartBug> s2 , s3 , s4 , s5 <S2SV_EndBug> , s6 , s7 ; int t0 , t1 <S2SV_StartBug> <S2SV_EndBug> , t2 , <S2SV_StartBug> t3 ; int x0 , x1 , x2 , x3 ; s0 = input <S2SV_EndBug> [ 0 ] + input [ 7 ] ; s1 = input [ 1 ] + input [ 6 ] ; s2 = input [ 2 ] + input [ 5 ] ; s3 = input [ 3 ] + input [ 4 ] ; s4 = input [ 3 ] - input [ 4 ] ; s5 = input [ 2 ] - input [ 5 ] ; s6 = input [ 1 ] - input [ 6 ] ; s7 = input [ 0 ] - input [ 7 ] ; x0 = s0 + s3 ; x1 = s1 + s2 ; x2 = s1 - s2 ; x3 = s0 - s3 ; t0 = ( x0 + x1 ) * cospi_16_64 ; t1 = ( x0 - x1 ) * cospi_16_64 ; t2 = x3 * cospi_8_64 + x2 * cospi_24_64 ; t3 = x3 * cospi_24_64 - x2 * cospi_8_64 ; out [ 0 ] = <S2SV_StartBug> fdct_round_shift ( t0 ) ; <S2SV_StartBug> <S2SV_EndBug> out [ 4 ] = fdct_round_shift ( t2 ) ; <S2SV_StartBug> <S2SV_EndBug> out [ 8 ] = fdct_round_shift ( t1 ) ; <S2SV_StartBug> out <S2SV_EndBug> [ 12 ] = fdct_round_shift ( t3 ) ; t0 <S2SV_EndBug> = ( s6 - s5 ) * cospi_16_64 ; t1 = ( s6 + s5 ) * cospi_16_64 ; t2 = fdct_round_shift ( t0 ) ; t3 = fdct_round_shift ( t1 ) ; x0 = s4 + t2 ; x1 = s4 - t2 ; x2 = s7 - t3 ; x3 = s7 + t3 ; t0 = x0 * cospi_28_64 + x3 * cospi_4_64 ; t1 = x1 * cospi_12_64 + x2 * cospi_20_64 ; t2 = x2 * cospi_12_64 + x1 * - cospi_20_64 ; t3 = x3 * cospi_28_64 + x0 * - cospi_4_64 ; out [ 2 ] = <S2SV_StartBug> fdct_round_shift <S2SV_EndBug> ( t0 ) ; out [ 6 <S2SV_StartBug> ] = fdct_round_shift ( <S2SV_EndBug> t2 ) <S2SV_StartBug> ; out [ 10 ] = fdct_round_shift ( t1 ) ; <S2SV_EndBug> out <S2SV_StartBug> [ 14 ] = fdct_round_shift <S2SV_EndBug> ( t3 ) ; } temp1 = ( step1 [ 5 ] - step1 [ 2 ] ) * cospi_16_64 ; temp2 = ( step1 [ 4 ] - step1 [ 3 ] ) * cospi_16_64 ; step2 [ 2 ] = fdct_round_shift ( temp1 ) ; step2 [ 3 ] = fdct_round_shift ( temp2 ) ; temp1 = ( step1 [ 4 ] + step1 [ 3 ] ) * cospi_16_64 ; temp2 = ( step1 [ 5 ] + step1 [ 2 ] ) * cospi_16_64 ; step2 [ 4 ] = fdct_round_shift ( temp1 ) ; step2 [ 5 ] = fdct_round_shift ( temp2 ) ; step3 [ 0 ] = step1 [ 0 ] + step2 [ 3 ] ; step3 [ 1 ] = step1 [ 1 ] + step2 [ 2 ] ; step3 [ 2 ] = step1 [ 1 ] - step2 [ 2 ] ; step3 [ 3 ] = step1 [ 0 ] - step2 [ 3 ] ; step3 [ 4 ] = step1 [ 7 ] - step2 [ 4 ] ; step3 [ 5 ] = step1 [ 6 ] - step2 [ 5 ] ; step3 [ 6 ] = step1 [ 6 ] + step2 [ 5 ] ; step3 [ 7 ] = step1 [ 7 ] + step2 [ 4 ] ; temp1 = step3 [ 1 ] * - cospi_8_64 + step3 [ 6 ] * <S2SV_StartBug> cospi_24_64 ; temp2 = step3 [ 2 ] * - cospi_24_64 - step3 [ 5 ] * cospi_8_64 <S2SV_EndBug> ; step2 [ 1 ] = fdct_round_shift ( temp1 ) ; step2 [ 2 ] = fdct_round_shift ( <S2SV_StartBug> temp2 ) ; temp1 = step3 [ 2 ] * - cospi_8_64 + step3 [ 5 <S2SV_EndBug> ] * cospi_24_64 ; temp2 = step3 [ 1 ] * cospi_24_64 + step3 [ 6 ] * cospi_8_64 ; step2 [ 5 ] = fdct_round_shift ( temp1 ) ; step2 [ 6 ] = fdct_round_shift ( temp2 ) ; step1 [ 0 ] = step3 [ 0 ] + step2 [ 1 ] ; step1 [ 1 ] = step3 [ 0 ] - step2 [ 1 ] ; <S2SV_StartBug> step1 [ 2 ] = step3 [ 3 ] - <S2SV_EndBug> step2 [ 2 ] ; step1 [ 3 ] = step3 [ 3 ] + step2 [ 2 ] ; step1 [ 4 ] = step3 [ 4 ] + step2 [ 5 ] ; step1 [ 5 ] = step3 [ 4 ] - step2 [ 5 ] ; step1 [ 6 ] = step3 [ 7 ] - step2 [ 6 ] ; step1 [ 7 ] = step3 [ 7 ] + step2 [ 6 ] ; temp1 = step1 [ 0 ] * cospi_30_64 + step1 [ 7 ] * cospi_2_64 ; temp2 = step1 [ 1 ] * cospi_14_64 + step1 [ 6 ] * cospi_18_64 ; <S2SV_StartBug> out [ 1 ] = fdct_round_shift ( temp1 ) ; <S2SV_StartBug> <S2SV_EndBug> out [ 9 ] = fdct_round_shift ( temp2 ) ; temp1 = step1 [ <S2SV_EndBug> 2 ] * cospi_22_64 + step1 [ 5 ] * cospi_10_64 ; temp2 = step1 [ 3 ] * cospi_6_64 + step1 [ 4 ] * <S2SV_StartBug> cospi_26_64 ; out [ 5 ] = fdct_round_shift ( temp1 ) ; <S2SV_EndBug> out <S2SV_StartBug> [ 13 ] = fdct_round_shift ( <S2SV_EndBug> temp2 ) ; temp1 = step1 [ 3 ] * - cospi_26_64 + step1 [ 4 ] * cospi_6_64 ; temp2 = step1 [ 2 ] * - cospi_10_64 + step1 [ <S2SV_StartBug> 5 ] * cospi_22_64 ; out [ 3 ] = fdct_round_shift <S2SV_EndBug> ( temp1 ) ; out [ 11 ] <S2SV_StartBug> = fdct_round_shift ( temp2 ) ; temp1 <S2SV_EndBug> = step1 [ 1 ] * - cospi_18_64 + step1 [ 6 ] * cospi_14_64 ; temp2 = step1 [ 0 ] * - cospi_2_64 + step1 [ 7 ] * cospi_30_64 ; out [ 7 ] = <S2SV_StartBug> fdct_round_shift ( temp1 ) ; <S2SV_StartBug> out [ 15 ] = <S2SV_EndBug> fdct_round_shift ( temp2 ) ; <S2SV_EndBug> }
<S2SV_ModStart> fdct16 ( const tran_low_t <S2SV_ModEnd> in [ 16 <S2SV_ModStart> 16 ] , tran_low_t <S2SV_ModEnd> out [ 16 <S2SV_ModStart> ] ) { tran_high_t <S2SV_ModEnd> step1 [ 8 <S2SV_ModStart> 8 ] ; tran_high_t <S2SV_ModEnd> step2 [ 8 <S2SV_ModStart> 8 ] ; tran_high_t <S2SV_ModEnd> step3 [ 8 <S2SV_ModStart> 8 ] ; tran_high_t <S2SV_ModEnd> input [ 8 <S2SV_ModStart> 8 ] ; tran_high_t <S2SV_ModEnd> temp1 , temp2 <S2SV_ModStart> ] ; { tran_high_t <S2SV_ModEnd> s0 , s1 <S2SV_ModStart> , s7 ; tran_high_t <S2SV_ModEnd> t0 , t1 <S2SV_ModStart> , t3 ; tran_high_t <S2SV_ModEnd> x0 , x1 <S2SV_ModStart> 0 ] = ( tran_low_t ) <S2SV_ModStart> 4 ] = ( tran_low_t ) <S2SV_ModStart> 8 ] = ( tran_low_t ) <S2SV_ModStart> 12 ] = ( tran_low_t ) <S2SV_ModStart> 2 ] = ( tran_low_t ) <S2SV_ModStart> 6 ] = ( tran_low_t ) <S2SV_ModStart> 10 ] = ( tran_low_t ) <S2SV_ModStart> 14 ] = ( tran_low_t ) <S2SV_ModStart> 2 ] * cospi_24_64 + <S2SV_ModEnd> step3 [ 5 <S2SV_ModStart> 2 ] * cospi_8_64 - <S2SV_ModEnd> step3 [ 5 <S2SV_ModStart> [ 3 ] + step2 [ 2 ] ; step1 [ 3 ] = step3 [ 3 ] - step2 [ 2 ] ; step1 [ 4 ] = step3 [ 4 ] - step2 [ 5 ] ; step1 [ 5 ] = step3 [ 4 ] + <S2SV_ModEnd> step2 [ 5 <S2SV_ModStart> 1 ] = ( tran_low_t ) <S2SV_ModStart> 9 ] = ( tran_low_t ) <S2SV_ModStart> 5 ] = ( tran_low_t ) <S2SV_ModStart> 13 ] = ( tran_low_t ) <S2SV_ModStart> 3 ] = ( tran_low_t ) <S2SV_ModStart> 11 ] = ( tran_low_t ) <S2SV_ModStart> 7 ] = ( tran_low_t ) <S2SV_ModStart> 15 ] = ( tran_low_t )
38
CWE-20 int bpf_check ( struct bpf_prog * * prog , union bpf_attr * attr ) { struct bpf_verifier_env * env ; struct bpf_verifer_log * log ; int ret = - EINVAL ; if ( ARRAY_SIZE ( bpf_verifier_ops ) == 0 ) return - EINVAL ; env = kzalloc ( sizeof ( struct bpf_verifier_env ) , GFP_KERNEL ) ; if ( ! env ) return - ENOMEM ; log = & env -> log ; env -> insn_aux_data = vzalloc ( sizeof ( struct bpf_insn_aux_data ) * ( * prog ) -> len ) ; ret = - ENOMEM ; if ( ! env -> insn_aux_data ) goto err_free_env ; env -> prog = * prog ; env -> ops = bpf_verifier_ops [ env -> prog -> type ] ; mutex_lock ( & bpf_verifier_lock ) ; if ( attr -> log_level || attr -> log_buf || attr -> log_size ) { log -> level = attr -> log_level ; log -> ubuf = ( char __user * ) ( unsigned long ) attr -> log_buf ; log -> len_total = attr -> log_size ; ret = - EINVAL ; if ( log -> len_total < 128 || log -> len_total > UINT_MAX >> 8 || ! log -> level || ! log -> ubuf ) goto err_unlock ; } env -> strict_alignment = ! ! ( attr -> prog_flags & BPF_F_STRICT_ALIGNMENT ) ; if ( ! IS_ENABLED ( CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS ) ) env -> strict_alignment = true ; if ( env -> prog -> aux -> offload ) { ret = bpf_prog_offload_verifier_prep ( env ) ; if ( ret ) goto err_unlock ; } ret = replace_map_fd_with_map_ptr ( env ) ; if ( ret < 0 ) goto skip_full_check ; env -> explored_states = kcalloc ( env -> prog -> len , sizeof ( struct bpf_verifier_state_list * ) , GFP_USER ) ; ret = - ENOMEM ; if ( ! env -> explored_states ) goto skip_full_check ; ret = check_cfg ( env ) ; if ( ret < 0 ) goto skip_full_check ; env -> allow_ptr_leaks = capable ( CAP_SYS_ADMIN ) ; ret = do_check ( env ) ; if ( env -> cur_state ) { free_verifier_state ( env -> cur_state , true ) ; env -> cur_state = NULL ; } skip_full_check : while ( ! pop_stack ( env , NULL , NULL ) ) ; free_states ( env ) ; if ( ret == 0 ) <S2SV_StartBug> ret = convert_ctx_accesses ( env ) ; <S2SV_EndBug> if ( ret == 0 ) ret = fixup_bpf_calls ( env ) ; if ( log -> level && bpf_verifier_log_full ( log ) ) ret = - ENOSPC ; if ( log -> level && ! log -> ubuf ) { ret = - EFAULT ; goto err_release_maps ; } if ( ret == 0 && env -> used_map_cnt ) { env -> prog -> aux -> used_maps = kmalloc_array ( env -> used_map_cnt , sizeof ( env -> used_maps [ 0 ] ) , GFP_KERNEL ) ; if ( ! env -> prog -> aux -> used_maps ) { ret = - ENOMEM ; goto err_release_maps ; } memcpy ( env -> prog -> aux -> used_maps , env -> used_maps , sizeof ( env -> used_maps [ 0 ] ) * env -> used_map_cnt ) ; env -> prog -> aux -> used_map_cnt = env -> used_map_cnt ; convert_pseudo_ld_imm64 ( env ) ; } err_release_maps : if ( ! env -> prog -> aux -> used_maps ) release_maps ( env ) ; * prog = env -> prog ; err_unlock : mutex_unlock ( & bpf_verifier_lock ) ; vfree ( env -> insn_aux_data ) ; err_free_env : kfree ( env ) ; return ret ; }
<S2SV_ModStart> == 0 ) sanitize_dead_code ( env ) ; if ( ret == 0 )
39
CWE-399 static gdImagePtr gdImageScaleTwoPass ( const gdImagePtr src , const unsigned int new_width , const unsigned int new_height ) { const unsigned int src_width = src -> sx ; const unsigned int src_height = src -> sy ; gdImagePtr tmp_im = NULL ; gdImagePtr dst = NULL ; if ( src_width == new_width && src_height == new_height ) { return gdImageClone ( src ) ; } if ( ! src -> trueColor ) { gdImagePaletteToTrueColor ( src ) ; } if ( src_width == new_width ) { tmp_im = src ; } else { tmp_im = gdImageCreateTrueColor ( new_width , src_height ) ; if ( tmp_im == NULL ) { return NULL ; } gdImageSetInterpolationMethod ( tmp_im , src -> interpolation_id ) ; _gdScalePass ( src , src_width , tmp_im , new_width , src_height , HORIZONTAL ) ; } if ( src_height == new_height ) { assert ( tmp_im != src ) ; return tmp_im ; } dst = gdImageCreateTrueColor ( new_width , new_height ) ; if ( dst != NULL ) { gdImageSetInterpolationMethod ( dst , src -> interpolation_id ) ; _gdScalePass ( tmp_im , src_height , dst , new_height , new_width , VERTICAL ) ; } if ( src != tmp_im ) { <S2SV_StartBug> gdFree ( tmp_im ) ; } return dst ; <S2SV_EndBug> }
<S2SV_ModStart> tmp_im ) { gdImageDestroy <S2SV_ModEnd> ( tmp_im )
40
CWE-200 static int pn_recvmsg ( struct kiocb * iocb , struct sock * sk , struct msghdr * msg , size_t len , int noblock , int flags , int * addr_len ) { struct sk_buff * skb = NULL ; struct sockaddr_pn sa ; int rval = - EOPNOTSUPP ; int copylen ; if ( flags & ~ ( MSG_PEEK | MSG_TRUNC | MSG_DONTWAIT | MSG_NOSIGNAL | MSG_CMSG_COMPAT ) ) goto out_nofree <S2SV_StartBug> ; <S2SV_EndBug> if ( addr_len ) * addr_len = sizeof ( sa ) ; skb = skb_recv_datagram ( sk , flags , noblock , & rval ) ; if ( skb == NULL ) goto out_nofree ; pn_skb_get_src_sockaddr ( skb , & sa ) ; copylen = skb -> len ; if ( len < copylen ) { msg -> msg_flags |= MSG_TRUNC ; copylen = len ; } rval = skb_copy_datagram_iovec ( skb , 0 , msg -> msg_iov , copylen ) ; if ( rval ) { rval = - EFAULT ; goto out ; } rval = ( flags & MSG_TRUNC ) ? skb -> len : copylen ; if <S2SV_StartBug> ( msg -> msg_name != NULL <S2SV_EndBug> ) memcpy ( <S2SV_StartBug> msg -> msg_name , & sa , sizeof ( struct sockaddr_pn ) <S2SV_EndBug> ) ; out : skb_free_datagram ( sk , skb ) ; out_nofree : return rval ; }
<S2SV_ModStart> ) goto out_nofree <S2SV_ModEnd> ; skb = <S2SV_ModStart> != NULL ) { <S2SV_ModStart> , sizeof ( sa ) ) ; * addr_len = sizeof ( sa ) ; } <S2SV_ModEnd> out : skb_free_datagram
41
CWE-125 sctp_disposition_t sctp_sf_ootb ( struct net * net , const struct sctp_endpoint * ep , const struct sctp_association * asoc , const sctp_subtype_t type , void * arg , sctp_cmd_seq_t * commands ) { struct sctp_chunk * chunk = arg ; struct sk_buff * skb = chunk -> skb ; sctp_chunkhdr_t * ch ; sctp_errhdr_t * err ; __u8 * ch_end ; int ootb_shut_ack = 0 ; int ootb_cookie_ack = 0 ; SCTP_INC_STATS ( net , SCTP_MIB_OUTOFBLUES ) ; ch = ( sctp_chunkhdr_t * ) chunk -> chunk_hdr ; do { if ( ntohs ( ch -> length ) < sizeof ( sctp_chunkhdr_t ) ) return sctp_sf_violation_chunklen ( net , ep , asoc , type , <S2SV_StartBug> arg , commands ) ; if ( SCTP_CID_SHUTDOWN_ACK == <S2SV_EndBug> ch -> type ) ootb_shut_ack = 1 ; if ( SCTP_CID_ABORT == ch -> type ) return sctp_sf_pdiscard ( net , ep , asoc , type , arg , commands ) ; if ( SCTP_CID_COOKIE_ACK == ch -> type ) ootb_cookie_ack = 1 ; if ( SCTP_CID_ERROR == ch -> type ) { sctp_walk_errors ( err , ch ) { if ( SCTP_ERROR_STALE_COOKIE == err -> cause ) { ootb_cookie_ack = 1 ; break ; } } } ch_end = ( ( __u8 * ) ch ) + SCTP_PAD4 ( ntohs ( ch -> length ) ) ; if ( ch_end > skb_tail_pointer ( skb ) ) return sctp_sf_violation_chunklen ( net , ep , asoc , type , arg , commands ) <S2SV_StartBug> ; ch = ( sctp_chunkhdr_t * ) ch_end ; } while ( <S2SV_EndBug> ch_end < skb_tail_pointer ( skb ) ) ; if ( ootb_shut_ack ) return sctp_sf_shut_8_4_5 ( net , ep , asoc , type , arg , commands ) ; else if ( ootb_cookie_ack ) return sctp_sf_pdiscard ( net , ep , asoc , type , arg , commands ) ; else return sctp_sf_tabort_8_4_8 ( net , ep , asoc , type , arg , commands ) ; }
<S2SV_ModStart> commands ) ; <S2SV_ModEnd> ch_end = ( <S2SV_ModStart> commands ) ; if ( SCTP_CID_SHUTDOWN_ACK == ch -> type ) ootb_shut_ack = 1 ; if ( SCTP_CID_ABORT == ch -> type ) return sctp_sf_pdiscard ( net , ep , asoc , type , arg , commands ) ; if ( SCTP_CID_COOKIE_ACK == ch -> type ) ootb_cookie_ack = 1 ; if ( SCTP_CID_ERROR == ch -> type ) { sctp_walk_errors ( err , ch ) { if ( SCTP_ERROR_STALE_COOKIE == err -> cause ) { ootb_cookie_ack = 1 ; break ; } } }
42
CWE-119 static vpx_codec_err_t ctrl_set_scale_mode ( vpx_codec_alg_priv_t * <S2SV_StartBug> ctx , int ctr_id , <S2SV_EndBug> va_list args ) { vpx_scaling_mode_t * const mode = va_arg ( args , vpx_scaling_mode_t * ) ; if ( mode ) { const int res = vp9_set_internal_size ( ctx -> cpi , ( VPX_SCALING ) mode -> h_scaling_mode , ( VPX_SCALING ) mode -> v_scaling_mode ) ; return ( res == 0 ) ? VPX_CODEC_OK : VPX_CODEC_INVALID_PARAM ; } else { return VPX_CODEC_INVALID_PARAM ; } }
<S2SV_ModStart> * ctx , <S2SV_ModEnd> va_list args )
43
CWE-787 static inline int l2cap_config_req ( struct l2cap_conn * conn , struct l2cap_cmd_hdr * cmd , u16 cmd_len , u8 * data ) { struct l2cap_conf_req * req = ( struct l2cap_conf_req * ) data ; u16 dcid , flags ; u8 rsp [ 64 ] ; struct sock * sk ; int len ; dcid = __le16_to_cpu ( req -> dcid ) ; flags = __le16_to_cpu ( req -> flags ) ; BT_DBG ( "dcid<S2SV_blank>0x%4.4x<S2SV_blank>flags<S2SV_blank>0x%2.2x" , dcid , flags ) ; sk = l2cap_get_chan_by_scid ( & conn -> chan_list , dcid ) ; if ( ! sk ) return - ENOENT ; if ( sk -> sk_state == BT_DISCONN ) goto unlock ; len = cmd_len - sizeof ( * req ) ; if ( l2cap_pi ( sk ) -> conf_len + len > sizeof ( l2cap_pi ( sk ) -> conf_req ) ) { l2cap_send_cmd ( conn , cmd -> ident , L2CAP_CONF_RSP , l2cap_build_conf_rsp ( sk , rsp , L2CAP_CONF_REJECT , flags ) , rsp ) ; goto unlock ; } memcpy ( l2cap_pi ( sk ) -> conf_req + l2cap_pi ( sk ) -> conf_len , req -> data , len ) ; l2cap_pi ( sk ) -> conf_len += len ; if ( flags & 0x0001 ) { l2cap_send_cmd ( conn , cmd -> ident , L2CAP_CONF_RSP , l2cap_build_conf_rsp ( sk , rsp , L2CAP_CONF_SUCCESS , 0x0001 ) , rsp ) ; goto unlock ; } len = l2cap_parse_conf_req ( <S2SV_StartBug> sk , rsp ) ; if ( len < 0 ) goto unlock ; <S2SV_StartBug> l2cap_send_cmd ( conn , <S2SV_EndBug> cmd -> ident , L2CAP_CONF_RSP , <S2SV_EndBug> len , rsp ) ; l2cap_pi ( sk ) -> conf_len = 0 ; if ( ! ( l2cap_pi ( sk ) -> conf_state & L2CAP_CONF_OUTPUT_DONE ) ) goto unlock ; if ( l2cap_pi ( sk ) -> conf_state & L2CAP_CONF_INPUT_DONE ) { sk -> sk_state = BT_CONNECTED ; l2cap_chan_ready ( sk ) ; goto unlock ; } if ( ! ( l2cap_pi ( sk ) -> conf_state & L2CAP_CONF_REQ_SENT ) ) { u8 buf [ 64 ] ; l2cap_send_cmd ( conn , l2cap_get_ident ( conn ) , L2CAP_CONF_REQ , l2cap_build_conf_req ( sk , buf ) , buf ) ; <S2SV_StartBug> } unlock : bh_unlock_sock ( sk <S2SV_EndBug> ) ; return 0 ; }
<S2SV_ModStart> < 0 ) { struct l2cap_disconn_req req ; req . dcid = cpu_to_le16 ( l2cap_pi ( sk ) -> dcid ) ; req . scid = cpu_to_le16 ( l2cap_pi ( sk ) -> scid ) ; l2cap_send_cmd ( conn , l2cap_get_ident ( conn ) , L2CAP_DISCONN_REQ , sizeof ( req ) , & req ) ; <S2SV_ModStart> goto unlock ; } <S2SV_ModStart> , rsp ) ; l2cap_pi ( sk ) -> num_conf_rsp ++ <S2SV_ModStart> buf ) ; l2cap_pi ( sk ) -> num_conf_req ++ ;
44
CWE-20 static int parse_rock_ridge_inode_internal ( struct iso_directory_record * de , struct inode * inode , <S2SV_EndBug> <S2SV_StartBug> int regard_xa ) { int symlink_len = 0 ; <S2SV_StartBug> int cnt , sig ; struct inode * reloc <S2SV_EndBug> ; struct rock_ridge * rr ; int rootflag ; struct rock_state rs ; int ret = 0 ; if ( ! ISOFS_SB ( inode -> i_sb ) -> s_rock ) return 0 ; init_rock_state ( & rs , inode ) ; setup_rock_ridge ( de , inode , & rs ) ; if ( <S2SV_StartBug> regard_xa ) { rs . chr += 14 <S2SV_EndBug> ; rs . len -= 14 ; if ( rs . len < 0 ) rs . len = 0 ; } repeat : while ( rs . len > 2 ) { rr = ( struct rock_ridge * ) rs . chr ; if ( rr -> len < 3 ) goto out ; sig = isonum_721 ( rs . chr ) ; if ( rock_check_overflow ( & rs , sig ) ) goto eio ; rs . chr += rr -> len ; rs . len -= rr -> len ; if ( rs . len < 0 ) goto out ; switch ( sig ) { # ifndef CONFIG_ZISOFS case SIG ( 'R' , 'R' ) : if ( ( rr -> u . RR . flags [ 0 ] & ( RR_PX | RR_TF | RR_SL | RR_CL ) ) == 0 ) goto out ; break ; # endif case SIG ( 'S' , 'P' ) : if ( check_sp ( rr , inode ) ) goto out ; break ; case SIG ( 'C' , 'E' ) : rs . cont_extent = isonum_733 ( rr -> u . CE . extent ) ; rs . cont_offset = isonum_733 ( rr -> u . CE . offset ) ; rs . cont_size = isonum_733 ( rr -> u . CE . size ) ; break ; case SIG ( 'E' , 'R' ) : ISOFS_SB ( inode -> i_sb ) -> s_rock = 1 ; printk ( KERN_DEBUG "ISO<S2SV_blank>9660<S2SV_blank>Extensions:<S2SV_blank>" ) ; { int p ; for ( p = 0 ; p < rr -> u . ER . len_id ; p ++ ) printk ( "%c" , rr -> u . ER . data [ p ] ) ; } printk ( "\\n" ) ; break ; case SIG ( 'P' , 'X' ) : inode -> i_mode = isonum_733 ( rr -> u . PX . mode ) ; set_nlink ( inode , isonum_733 ( rr -> u . PX . n_links ) ) ; i_uid_write ( inode , isonum_733 ( rr -> u . PX . uid ) ) ; i_gid_write ( inode , isonum_733 ( rr -> u . PX . gid ) ) ; break ; case SIG ( 'P' , 'N' ) : { int high , low ; high = isonum_733 ( rr -> u . PN . dev_high ) ; low = isonum_733 ( rr -> u . PN . dev_low ) ; if ( ( low & ~ 0xff ) && high == 0 ) { inode -> i_rdev = MKDEV ( low >> 8 , low & 0xff ) ; } else { inode -> i_rdev = MKDEV ( high , low ) ; } } break ; case SIG ( 'T' , 'F' ) : cnt = 0 ; if ( rr -> u . TF . flags & TF_CREATE ) { inode -> i_ctime . tv_sec = iso_date ( rr -> u . TF . times [ cnt ++ ] . time , 0 ) ; inode -> i_ctime . tv_nsec = 0 ; } if ( rr -> u . TF . flags & TF_MODIFY ) { inode -> i_mtime . tv_sec = iso_date ( rr -> u . TF . times [ cnt ++ ] . time , 0 ) ; inode -> i_mtime . tv_nsec = 0 ; } if ( rr -> u . TF . flags & TF_ACCESS ) { inode -> i_atime . tv_sec = iso_date ( rr -> u . TF . times [ cnt ++ ] . time , 0 ) ; inode -> i_atime . tv_nsec = 0 ; } if ( rr -> u . TF . flags & TF_ATTRIBUTES ) { inode -> i_ctime . tv_sec = iso_date ( rr -> u . TF . times [ cnt ++ ] . time , 0 ) ; inode -> i_ctime . tv_nsec = 0 ; } break ; case SIG ( 'S' , 'L' ) : { int slen ; struct SL_component * slp ; struct SL_component * oldslp ; slen = rr -> len - 5 ; slp = & rr -> u . SL . link ; inode -> i_size = symlink_len ; while ( slen > 1 ) { rootflag = 0 ; switch ( slp -> flags & ~ 1 ) { case 0 : inode -> i_size += slp -> len ; break ; case 2 : inode -> i_size += 1 ; break ; case 4 : inode -> i_size += 2 ; break ; case 8 : rootflag = 1 ; inode -> i_size += 1 ; break ; default : printk ( "Symlink<S2SV_blank>component<S2SV_blank>flag<S2SV_blank>" "not<S2SV_blank>implemented\\n" ) ; } slen -= slp -> len + 2 ; oldslp = slp ; slp = ( struct SL_component * ) ( ( ( char * ) slp ) + slp -> len + 2 ) ; if ( slen < 2 ) { if ( ( ( rr -> u . SL . flags & 1 ) != 0 ) && ( ( oldslp -> flags & 1 ) == 0 ) ) inode -> i_size += 1 ; break ; } if ( ! rootflag && ( oldslp -> flags & 1 ) == 0 ) inode -> i_size += 1 ; } } symlink_len = inode -> i_size ; break ; case SIG ( 'R' , 'E' ) : printk ( KERN_WARNING "Attempt<S2SV_blank>to<S2SV_blank>read<S2SV_blank>inode<S2SV_blank>for<S2SV_blank>" "relocated<S2SV_blank>directory\\n" ) ; goto out ; case SIG ( 'C' , 'L' ) : ISOFS_I ( <S2SV_StartBug> <S2SV_EndBug> inode ) -> i_first_extent = isonum_733 ( rr -> u . CL . location ) ; <S2SV_StartBug> reloc = isofs_iget ( inode -> i_sb , <S2SV_StartBug> <S2SV_EndBug> ISOFS_I ( inode ) -> i_first_extent , 0 <S2SV_EndBug> ) ; if ( IS_ERR ( reloc ) ) { ret = PTR_ERR ( reloc ) ; goto out ; } inode -> i_mode = reloc -> i_mode ; set_nlink ( inode , reloc -> i_nlink ) ; inode -> i_uid = reloc -> i_uid ; inode -> i_gid = reloc -> i_gid ; inode -> i_rdev = reloc -> i_rdev ; inode -> i_size = reloc -> i_size ; inode -> i_blocks = reloc -> i_blocks ; inode -> i_atime = reloc -> i_atime ; inode -> i_ctime = reloc -> i_ctime ; inode -> i_mtime = reloc -> i_mtime ; iput ( reloc ) ; break ; # ifdef CONFIG_ZISOFS case SIG ( 'Z' , 'F' ) : { int algo ; if ( ISOFS_SB ( inode -> i_sb ) -> s_nocompress ) break ; algo = isonum_721 ( rr -> u . ZF . algorithm ) ; if ( algo == SIG ( 'p' , 'z' ) ) { int block_shift = isonum_711 ( & rr -> u . ZF . parms [ 1 ] ) ; if ( block_shift > 17 ) { printk ( KERN_WARNING "isofs:<S2SV_blank>" "Can\'t<S2SV_blank>handle<S2SV_blank>ZF<S2SV_blank>block<S2SV_blank>" "size<S2SV_blank>of<S2SV_blank>2^%d\\n" , block_shift ) ; } else { ISOFS_I ( inode ) -> i_file_format = isofs_file_compressed ; ISOFS_I ( inode ) -> i_format_parm [ 0 ] = isonum_711 ( & rr -> u . ZF . parms [ 0 ] ) ; ISOFS_I ( inode ) -> i_format_parm [ 1 ] = isonum_711 ( & rr -> u . ZF . parms [ 1 ] ) ; inode -> i_size = isonum_733 ( rr -> u . ZF . real_size ) ; } } else { printk ( KERN_WARNING "isofs:<S2SV_blank>Unknown<S2SV_blank>ZF<S2SV_blank>compression<S2SV_blank>" "algorithm:<S2SV_blank>%c%c\\n" , rr -> u . ZF . algorithm [ 0 ] , rr -> u . ZF . algorithm [ 1 ] ) ; } break ; } # endif default : break ; } } ret = rock_continue ( & rs ) ; if ( ret == 0 ) goto repeat ; if ( ret == 1 ) ret = 0 ; out : kfree ( rs . buffer ) ; return ret ; eio : ret = - EIO ; goto out ; }
<S2SV_ModStart> inode , int flags <S2SV_ModEnd> ) { int <S2SV_ModStart> cnt , sig ; unsigned int reloc_block <S2SV_ModStart> ; if ( flags & RR_REGARD_XA <S2SV_ModEnd> ) { rs <S2SV_ModStart> 'L' ) : if ( flags & RR_RELOC_DE ) { printk ( KERN_ERR "ISOFS:<S2SV_blank>Recursive<S2SV_blank>directory<S2SV_blank>relocation<S2SV_blank>" "is<S2SV_blank>not<S2SV_blank>supported\\n" ) ; goto eio ; } reloc_block = isonum_733 ( rr -> u . CL . location ) ; if ( reloc_block == <S2SV_ModStart> inode ) -> i_iget5_block && ISOFS_I ( inode ) -> i_iget5_offset == 0 ) { printk ( KERN_ERR "ISOFS:<S2SV_blank>Directory<S2SV_blank>relocation<S2SV_blank>points<S2SV_blank>to<S2SV_blank>" "itself\\n" ) ; goto eio ; } ISOFS_I ( inode ) -> i_first_extent = reloc_block <S2SV_ModEnd> ; reloc = <S2SV_ModStart> ; reloc = isofs_iget_reloc <S2SV_ModEnd> ( inode -> <S2SV_ModStart> -> i_sb , reloc_block , <S2SV_ModEnd> 0 ) ;
45
CWE-119 CURLcode Curl_auth_create_plain_message ( struct Curl_easy * data , const char * userp , const char * passwdp , char * * outptr , size_t * outlen ) { CURLcode result ; char * plainauth ; size_t ulen ; size_t plen ; size_t plainlen ; * outlen = 0 ; * outptr = NULL ; ulen = strlen ( userp ) ; plen = strlen ( passwdp <S2SV_StartBug> ) ; if ( ( ulen > SIZE_T_MAX / 2 ) || ( plen > ( SIZE_T_MAX / 2 - 2 ) ) ) return CURLE_OUT_OF_MEMORY ; plainlen = <S2SV_EndBug> 2 * ulen + plen + 2 ; plainauth = malloc ( plainlen ) ; if ( ! plainauth ) return CURLE_OUT_OF_MEMORY ; memcpy ( plainauth , userp , ulen ) ; plainauth [ ulen ] = '\\0' ; memcpy ( plainauth + ulen + 1 , userp , ulen ) ; plainauth [ 2 * ulen + 1 ] = '\\0' ; memcpy ( plainauth + 2 * ulen + 2 , passwdp , plen ) ; result = Curl_base64_encode ( data , plainauth , plainlen , outptr , outlen ) ; free ( plainauth ) ; return result ; }
<S2SV_ModStart> > SIZE_T_MAX / 4 <S2SV_ModEnd> ) || (
46
CWE-835 int WavpackSetConfiguration64 ( WavpackContext * wpc , WavpackConfig * config , int64_t total_samples , const unsigned char * chan_ids ) { uint32_t flags , bps = 0 ; uint32_t chan_mask = config -> channel_mask ; int num_chans = config -> <S2SV_StartBug> num_channels ; int <S2SV_EndBug> i ; wpc -> stream_version = ( config -> flags & CONFIG_COMPATIBLE_WRITE ) ? CUR_STREAM_VERS : MAX_STREAM_VERS ; if ( ( config -> qmode & QMODE_DSD_AUDIO ) && config -> bytes_per_sample == 1 && config -> bits_per_sample == 8 ) { # ifdef ENABLE_DSD wpc -> dsd_multiplier = 1 ; flags = DSD_FLAG ; for ( i = 14 ; i >= 0 ; -- i ) if ( config -> sample_rate % sample_rates [ i ] == 0 ) { int divisor = config -> sample_rate / sample_rates [ i ] ; if ( divisor && ( divisor & ( divisor - 1 ) ) == 0 ) { config -> sample_rate /= divisor ; wpc -> dsd_multiplier = divisor ; break ; } } if ( config -> flags & CONFIG_HYBRID_FLAG ) { strcpy ( wpc -> error_message , "hybrid<S2SV_blank>mode<S2SV_blank>not<S2SV_blank>available<S2SV_blank>for<S2SV_blank>DSD!" ) ; return FALSE ; } config -> flags &= ( CONFIG_HIGH_FLAG | CONFIG_MD5_CHECKSUM | CONFIG_PAIR_UNDEF_CHANS ) ; config -> float_norm_exp = config -> xmode = 0 ; # else strcpy ( wpc -> error_message , "libwavpack<S2SV_blank>not<S2SV_blank>configured<S2SV_blank>for<S2SV_blank>DSD!" ) ; return FALSE ; # endif } else flags = config -> bytes_per_sample - 1 ; wpc -> total_samples = total_samples ; wpc -> config . sample_rate = config -> sample_rate ; wpc -> config . num_channels = config -> num_channels ; wpc -> config . channel_mask = config -> channel_mask ; wpc -> config . bits_per_sample = config -> bits_per_sample ; wpc -> config . bytes_per_sample = config -> bytes_per_sample ; wpc -> config . block_samples = config -> block_samples ; wpc -> config . flags = config -> flags ; wpc -> config . qmode = config -> qmode ; if ( config -> flags & CONFIG_VERY_HIGH_FLAG ) wpc -> config . flags |= CONFIG_HIGH_FLAG ; for ( i = 0 ; i < 15 ; ++ i ) if ( wpc -> config . sample_rate == sample_rates [ i ] ) break ; flags |= i << SRATE_LSB ; if ( ! ( flags & DSD_FLAG ) ) { if ( config -> float_norm_exp ) { wpc -> config . float_norm_exp = config -> float_norm_exp ; wpc -> config . flags |= CONFIG_FLOAT_DATA ; flags |= FLOAT_DATA ; } else flags |= ( ( config -> bytes_per_sample * 8 ) - config -> bits_per_sample ) << SHIFT_LSB ; if ( config -> flags & CONFIG_HYBRID_FLAG ) { flags |= HYBRID_FLAG | HYBRID_BITRATE | HYBRID_BALANCE ; if ( ! ( wpc -> config . flags & CONFIG_SHAPE_OVERRIDE ) ) { wpc -> config . flags |= CONFIG_HYBRID_SHAPE | CONFIG_AUTO_SHAPING ; flags |= HYBRID_SHAPE | NEW_SHAPING ; } else if ( wpc -> config . flags & CONFIG_HYBRID_SHAPE ) { wpc -> config . shaping_weight = config -> shaping_weight ; flags |= HYBRID_SHAPE | NEW_SHAPING ; } if ( wpc -> config . flags & ( CONFIG_CROSS_DECORR | CONFIG_OPTIMIZE_WVC ) ) flags |= CROSS_DECORR ; if ( config -> flags & CONFIG_BITRATE_KBPS ) { bps = ( uint32_t ) floor ( config -> bitrate * 256000.0 / config -> sample_rate / config -> num_channels + 0.5 ) ; if ( bps > ( 64 << 8 ) ) bps = 64 << 8 ; } else bps = ( uint32_t ) floor ( config -> bitrate * 256.0 + 0.5 ) ; } else flags |= CROSS_DECORR ; if ( ! ( config -> flags & CONFIG_JOINT_OVERRIDE ) || ( config -> flags & CONFIG_JOINT_STEREO ) ) flags |= JOINT_STEREO ; if ( config -> flags & CONFIG_CREATE_WVC ) wpc -> wvc_flag = TRUE ; } if ( chan_ids ) { int lastchan = 0 , mask_copy = chan_mask ; if ( ( int ) strlen ( ( char * ) chan_ids ) > num_chans ) { strcpy ( wpc -> error_message , "chan_ids<S2SV_blank>longer<S2SV_blank>than<S2SV_blank>num<S2SV_blank>channels!" ) ; return FALSE ; } while ( * chan_ids ) if ( * chan_ids <= 32 && * chan_ids > lastchan && ( mask_copy & ( 1 << ( * chan_ids - 1 ) ) ) ) { mask_copy &= ~ ( 1 << ( * chan_ids - 1 ) ) ; lastchan = * chan_ids ++ ; } else break ; for ( i = 0 ; chan_ids [ i ] ; i ++ ) if ( chan_ids [ i ] != 0xff ) { wpc -> channel_identities = ( unsigned char * ) strdup ( ( char * ) chan_ids ) ; break ; } } for ( wpc -> current_stream = 0 ; num_chans ; wpc -> current_stream ++ ) { WavpackStream * wps = malloc ( sizeof ( WavpackStream ) ) ; unsigned char left_chan_id = 0 , right_chan_id = 0 ; int pos , chans = 1 ; wpc -> streams = realloc ( wpc -> streams , ( wpc -> current_stream + 1 ) * sizeof ( wpc -> streams [ 0 ] ) ) ; wpc -> streams [ wpc -> current_stream ] = wps ; CLEAR ( * wps ) ; if ( chan_mask ) for ( pos = 0 ; pos < 32 ; ++ pos ) if ( chan_mask & ( 1 << pos ) ) { if ( left_chan_id ) { right_chan_id = pos + 1 ; break ; } else { chan_mask &= ~ ( 1 << pos ) ; left_chan_id = pos + 1 ; } } while ( ! right_chan_id && chan_ids && * chan_ids ) if ( left_chan_id ) right_chan_id = * chan_ids ; else left_chan_id = * chan_ids ++ ; if ( ! left_chan_id ) left_chan_id = right_chan_id = 0xff ; else if ( ! right_chan_id ) right_chan_id = 0xff ; if ( num_chans >= 2 ) { if ( ( config -> flags & CONFIG_PAIR_UNDEF_CHANS ) && left_chan_id == 0xff && right_chan_id == 0xff ) chans = 2 ; else for ( i = 0 ; i < NUM_STEREO_PAIRS ; ++ i ) if ( ( left_chan_id == stereo_pairs [ i ] . a && right_chan_id == stereo_pairs [ i ] . b ) || ( left_chan_id == stereo_pairs [ i ] . b && right_chan_id == stereo_pairs [ i ] . a ) ) { if ( right_chan_id <= 32 && ( chan_mask & ( 1 << ( right_chan_id - 1 ) ) ) ) chan_mask &= ~ ( 1 << ( right_chan_id - 1 ) ) ; else if ( chan_ids && * chan_ids == right_chan_id ) chan_ids ++ ; chans = 2 ; break ; } } num_chans -= chans ; if ( num_chans && wpc -> current_stream == NEW_MAX_STREAMS - 1 ) break ; memcpy ( wps -> wphdr . ckID , "wvpk" , 4 ) ; wps -> wphdr . ckSize = sizeof ( WavpackHeader ) - 8 ; SET_TOTAL_SAMPLES ( wps -> wphdr , wpc -> total_samples ) ; wps -> wphdr . version = wpc -> stream_version ; wps -> wphdr . flags = flags ; wps -> bits = bps ; if ( ! wpc -> current_stream ) wps -> wphdr . flags |= INITIAL_BLOCK ; if ( ! num_chans ) wps -> wphdr . flags |= FINAL_BLOCK ; if ( chans == 1 ) { wps -> wphdr . flags &= ~ ( JOINT_STEREO | CROSS_DECORR | HYBRID_BALANCE ) ; wps -> wphdr . flags |= MONO_FLAG ; } } wpc -> num_streams = wpc -> current_stream ; wpc -> current_stream = 0 ; if ( num_chans ) { strcpy ( wpc -> error_message , "too<S2SV_blank>many<S2SV_blank>channels!" ) ; return FALSE ; } if ( config -> flags & CONFIG_EXTRA_MODE ) wpc -> config . xmode = config -> xmode ? config -> xmode : 1 ; return TRUE ; }
<S2SV_ModStart> int i ; if ( ! config -> sample_rate ) { strcpy ( wpc -> error_message , "sample<S2SV_blank>rate<S2SV_blank>cannot<S2SV_blank>be<S2SV_blank>zero!" ) ; return FALSE ; }
47
CWE-20 void httpClientParseQopParam ( const HttpParam * param , HttpWwwAuthenticateHeader * authHeader ) { # if ( HTTP_CLIENT_DIGEST_AUTH_SUPPORT == ENABLED ) size_t i ; size_t n ; authHeader -> qop = HTTP_AUTH_QOP_NONE ; for ( i = 0 ; i < param -> valueLen ; i += ( n + 1 ) ) { for ( n = 0 ; ( i + n ) < param -> valueLen ; n ++ ) { if ( strchr ( <S2SV_StartBug> ",<S2SV_blank>\\t" , param -> value [ i + n ] ) ) break ; } <S2SV_EndBug> if ( n == 4 && ! osStrncasecmp ( param -> value + i , "auth" , 4 ) ) { authHeader -> qop = HTTP_AUTH_QOP_AUTH ; } } if ( authHeader -> qop == HTTP_AUTH_QOP_NONE ) { authHeader -> mode = HTTP_AUTH_MODE_NONE ; } # endif }
<S2SV_ModStart> { if ( osStrchr <S2SV_ModEnd> ( ",<S2SV_blank>\\t" , <S2SV_ModStart> n ] ) != NULL ) { break ; } <S2SV_ModEnd> } if (
48
CWE-787 int sr_do_ioctl ( Scsi_CD * cd , struct packet_command * cgc ) { struct scsi_device * SDev ; struct scsi_sense_hdr sshdr ; int result , err = 0 , <S2SV_StartBug> retries = 0 ; SDev = cd -> device ; retry <S2SV_EndBug> : if ( ! scsi_block_when_processing_errors ( SDev ) ) { err = - ENODEV ; goto out ; } result = scsi_execute ( SDev , cgc -> cmd , cgc -> data_direction , cgc -> buffer , cgc -> buflen , ( unsigned <S2SV_StartBug> char * ) cgc -> sense , & sshdr , cgc -> timeout , IOCTL_RETRIES <S2SV_EndBug> , 0 , 0 , NULL ) ; if ( driver_byte ( result ) != 0 ) { switch ( sshdr . sense_key ) { case UNIT_ATTENTION : SDev -> changed = 1 ; if ( ! cgc -> quiet ) sr_printk ( KERN_INFO , cd , "disc<S2SV_blank>change<S2SV_blank>detected.\\n" ) ; if ( retries ++ < 10 ) goto retry ; err = - ENOMEDIUM ; break ; case NOT_READY : if ( sshdr . asc == 0x04 && sshdr . ascq == 0x01 ) { if ( ! cgc -> quiet ) sr_printk ( KERN_INFO , cd , "CDROM<S2SV_blank>not<S2SV_blank>ready<S2SV_blank>yet.\\n" ) ; if ( retries ++ < 10 ) { ssleep ( 2 ) ; goto retry ; } else { err = - ENOMEDIUM ; break ; } } if ( ! cgc -> quiet ) sr_printk ( KERN_INFO , cd , "CDROM<S2SV_blank>not<S2SV_blank>ready.<S2SV_blank><S2SV_blank>Make<S2SV_blank>sure<S2SV_blank>there<S2SV_blank>" "is<S2SV_blank>a<S2SV_blank>disc<S2SV_blank>in<S2SV_blank>the<S2SV_blank>drive.\\n" ) ; err = - ENOMEDIUM ; break ; case ILLEGAL_REQUEST : err = - EIO ; if ( sshdr . asc == 0x20 && sshdr . ascq == 0x00 ) err = - EDRIVE_CANT_DO_THIS ; break ; default : err = - EIO ; } } out : cgc -> stat = err ; return err ; }
<S2SV_ModStart> = 0 ; unsigned char sense_buffer [ SCSI_SENSE_BUFFERSIZE ] , * senseptr = NULL ; <S2SV_ModStart> cd -> device ; if ( cgc -> sense ) senseptr = sense_buffer <S2SV_ModStart> -> buflen , senseptr , & sshdr , cgc -> timeout , IOCTL_RETRIES , 0 , 0 , NULL ) ; if ( cgc -> sense ) memcpy ( cgc -> sense , sense_buffer , sizeof ( * <S2SV_ModEnd> cgc -> sense <S2SV_ModStart> cgc -> sense ) <S2SV_ModEnd> ) ; if
49
CWE-119 int CLASS parse_jpeg ( int offset ) { int len , save , hlen , mark ; fseek ( ifp , offset , SEEK_SET ) ; if ( fgetc ( ifp ) != 0xff || fgetc ( ifp ) != 0xd8 ) return 0 ; while ( fgetc ( ifp ) == 0xff && ( mark = fgetc ( ifp ) ) != 0xda ) { order = 0x4d4d ; len = get2 ( ) - 2 ; save = ftell ( ifp ) ; if ( mark == 0xc0 || mark == 0xc3 || mark == 0xc9 ) { fgetc ( ifp ) ; raw_height = get2 ( ) ; raw_width = get2 ( ) ; } order = get2 ( ) ; hlen = get4 ( ) ; if <S2SV_StartBug> ( get4 ( ) == 0x48454150 ) { # ifdef <S2SV_EndBug> LIBRAW_LIBRARY_BUILD imgdata . lens . <S2SV_StartBug> makernotes . CameraMount = LIBRAW_MOUNT_FixedLens <S2SV_EndBug> ; imgdata . lens . makernotes . LensMount = LIBRAW_MOUNT_FixedLens ; # endif parse_ciff ( save + hlen , len - hlen , 0 ) ; } if ( parse_tiff ( save + 6 ) ) apply_tiff ( ) ; fseek ( ifp , save + len , SEEK_SET ) ; } return 1 ; }
<S2SV_ModStart> ) == 0x48454150 <S2SV_ModEnd> # ifdef LIBRAW_LIBRARY_BUILD <S2SV_ModStart> # ifdef LIBRAW_LIBRARY_BUILD && ( save + hlen ) >= 0 && ( save + hlen ) <= ifp -> size ( ) # endif ) { # ifdef LIBRAW_LIBRARY_BUILD
50
CWE-399 static int scm_fp_copy ( struct cmsghdr * cmsg , struct scm_fp_list * * fplp ) { int * fdp = ( int * ) CMSG_DATA ( cmsg ) ; struct scm_fp_list * fpl = * fplp ; struct file * * fpp ; int i , num ; num = ( cmsg -> cmsg_len - CMSG_ALIGN ( sizeof ( struct cmsghdr ) ) ) / sizeof ( int ) ; if ( num <= 0 ) return 0 ; if ( num > SCM_MAX_FD ) return - EINVAL ; if ( ! fpl ) { fpl = kmalloc ( sizeof ( struct scm_fp_list ) , GFP_KERNEL ) ; if ( ! fpl ) return - ENOMEM ; * fplp = fpl ; fpl -> count = 0 ; fpl -> max = SCM_MAX_FD ; } <S2SV_EndBug> <S2SV_StartBug> fpp = & fpl -> fp [ fpl -> count ] ; if ( fpl -> count + num > fpl -> max ) return - EINVAL ; for ( i = 0 ; i < num ; i ++ ) { int fd = fdp [ i ] ; struct file * file ; if ( fd < 0 || ! ( file = fget_raw ( fd ) ) ) return - EBADF ; * fpp ++ = file ; fpl -> count ++ ; } return <S2SV_StartBug> num ; <S2SV_EndBug> }
<S2SV_ModStart> = SCM_MAX_FD ; fpl -> user = NULL ; <S2SV_ModStart> ++ ; } if ( ! fpl -> user ) fpl -> user = get_uid ( current_user ( ) ) ;
51
CWE-119 static <S2SV_StartBug> void search_filter_level ( const YV12_BUFFER_CONFIG * sd , VP9_COMP * cpi <S2SV_EndBug> , int partial_frame ) { VP9_COMMON * const <S2SV_StartBug> cm = & cpi -> common ; <S2SV_StartBug> struct loopfilter <S2SV_EndBug> * const lf = & cm -> lf ; <S2SV_EndBug> const int min_filter_level = 0 ; const int max_filter_level = get_max_filter_level ( <S2SV_StartBug> cpi ) <S2SV_EndBug> ; int best_err ; int <S2SV_StartBug> filt_best ; int <S2SV_EndBug> filt_direction = 0 ; int filt_mid = clamp ( lf -> filter_level , min_filter_level , max_filter_level ) ; int filter_step = filt_mid < 16 ? 4 : filt_mid / 4 ; int ss_err <S2SV_StartBug> [ MAX_LOOP_FILTER <S2SV_EndBug> + 1 ] ; vpx_memset ( <S2SV_StartBug> ss_err , 0xFF , sizeof ( ss_err ) ) ; <S2SV_EndBug> vpx_yv12_copy_y ( cm -> frame_to_show , & cpi -> last_frame_uf ) ; best_err = try_filter_frame ( sd , cpi , filt_mid , partial_frame ) ; filt_best = filt_mid ; ss_err [ filt_mid ] = best_err ; while ( filter_step > 0 ) { const int filt_high = MIN ( filt_mid + filter_step , max_filter_level ) ; const int filt_low = MAX ( filt_mid - filter_step , min_filter_level ) ; int filt_err ; <S2SV_EndBug> <S2SV_StartBug> int bias = ( best_err >> ( 15 - ( filt_mid / 8 ) ) ) * filter_step ; if ( cpi <S2SV_StartBug> -> twopass . <S2SV_EndBug> section_intra_rating < <S2SV_StartBug> 20 ) bias = bias * cpi -> twopass . section_intra_rating / 20 ; <S2SV_EndBug> if ( cm -> tx_mode != ONLY_4X4 ) bias >>= 1 ; if ( filt_direction <= 0 && filt_low != filt_mid ) { if ( ss_err [ filt_low <S2SV_StartBug> ] < 0 ) { filt_err = try_filter_frame ( sd , cpi , filt_low , partial_frame ) ; <S2SV_StartBug> <S2SV_EndBug> ss_err [ filt_low ] = filt_err <S2SV_EndBug> ; } else { filt_err = ss_err [ filt_low ] ; } if ( ( filt_err - bias ) < best_err ) { if ( <S2SV_StartBug> filt_err < best_err ) best_err = <S2SV_EndBug> filt_err ; filt_best = filt_low ; } } if ( filt_direction >= 0 && filt_high != filt_mid ) { if ( ss_err [ filt_high ] < 0 ) { <S2SV_StartBug> filt_err = try_filter_frame ( sd , cpi , filt_high , partial_frame <S2SV_EndBug> ) ; <S2SV_StartBug> ss_err [ filt_high ] = filt_err ; } else { <S2SV_EndBug> filt_err = ss_err [ filt_high ] ; } if ( filt_err < ( best_err - bias ) ) { best_err = filt_err <S2SV_StartBug> ; filt_best <S2SV_EndBug> = filt_high ; } } if ( filt_best == filt_mid ) { filter_step /= 2 ; filt_direction = 0 ; } else { filt_direction = ( filt_best < filt_mid ) ? - 1 : 1 ; filt_mid = filt_best ; <S2SV_StartBug> } } lf -> filter_level = filt_best ; } <S2SV_EndBug>
<S2SV_ModStart> <S2SV_null> <S2SV_null> static int <S2SV_ModEnd> search_filter_level ( const <S2SV_ModStart> partial_frame ) { const <S2SV_ModStart> -> common ; const <S2SV_ModStart> ) ; int <S2SV_ModEnd> filt_direction = 0 <S2SV_ModStart> filt_direction = 0 ; int64_t best_err ; int filt_best <S2SV_ModStart> / 4 ; int64_t <S2SV_ModEnd> ss_err [ MAX_LOOP_FILTER <S2SV_ModStart> 1 ] ; memset <S2SV_ModEnd> ( ss_err , <S2SV_ModStart> min_filter_level ) ; int64_t <S2SV_ModEnd> bias = ( <S2SV_ModStart> filter_step ; if ( ( cpi -> oxcf . pass == 2 ) && <S2SV_ModStart> < 20 ) ) bias = ( <S2SV_ModEnd> bias * cpi <S2SV_ModStart> twopass . section_intra_rating ) <S2SV_ModStart> 0 ) { ss_err [ filt_low ] <S2SV_ModEnd> = try_filter_frame ( <S2SV_ModStart> partial_frame ) ; } if ( ( ss_err [ filt_low ] <S2SV_ModEnd> - bias ) <S2SV_ModStart> { if ( ss_err [ filt_low ] < best_err ) best_err = ss_err [ filt_low ] <S2SV_ModEnd> ; filt_best = <S2SV_ModStart> 0 ) { ss_err [ filt_high ] <S2SV_ModEnd> = try_filter_frame ( <S2SV_ModStart> partial_frame ) ; } if ( ss_err [ filt_high ] <S2SV_ModEnd> < ( best_err <S2SV_ModStart> { best_err = ss_err [ filt_high ] <S2SV_ModEnd> ; filt_best = <S2SV_ModStart> ; } } return <S2SV_ModEnd> filt_best ; }
52
CWE-399 static Image * ReadCAPTIONImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { char * caption , geometry [ MaxTextExtent ] , * property , * text ; const char * gravity , * option ; DrawInfo * draw_info ; Image * image ; MagickBooleanType split , status ; register ssize_t i ; size_t height , width ; TypeMetric metrics ; 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 ) ; ( void ) ResetImagePage ( image , "0x0+0+0" ) ; option = GetImageOption ( image_info , "filename" ) ; if ( option == ( const char * ) NULL ) property = InterpretImageProperties ( image_info , image , image_info -> filename ) ; else if ( LocaleNCompare ( option , "caption:" , 8 ) == 0 ) property = InterpretImageProperties ( image_info , image , option + 8 ) ; else property = InterpretImageProperties ( image_info , image , option ) ; ( void ) SetImageProperty ( image , "caption" , property ) ; property = DestroyString ( property ) ; caption = ConstantString ( GetImageProperty ( image , "caption" ) ) ; draw_info = CloneDrawInfo ( image_info , ( DrawInfo * ) NULL ) ; ( void ) CloneString ( & draw_info -> text , caption ) ; gravity = GetImageOption ( image_info , "gravity" ) ; if ( gravity != ( char * ) NULL ) draw_info -> gravity = ( GravityType ) ParseCommandOption ( MagickGravityOptions , MagickFalse , gravity ) ; split = MagickFalse ; status = MagickTrue ; if ( image -> columns == 0 ) { text = AcquireString ( caption ) ; i = FormatMagickCaption ( image , draw_info , split , & metrics , & text ) ; ( void ) CloneString ( & draw_info -> text , text ) ; text = DestroyString ( text ) ; ( void ) FormatLocaleString ( geometry , MaxTextExtent , "%+g%+g" , - metrics . bounds . x1 , metrics . ascent ) ; if ( draw_info -> gravity == UndefinedGravity ) ( void ) CloneString ( & draw_info -> geometry , geometry ) ; status = GetMultilineTypeMetrics ( image , draw_info , & metrics ) ; width = ( size_t ) floor ( metrics . width + draw_info -> stroke_width + 0.5 ) ; image -> columns = width ; } if ( image -> rows == 0 ) { split = MagickTrue ; text = AcquireString ( caption ) ; i = FormatMagickCaption ( image , draw_info , split , & metrics , & text ) ; ( void ) CloneString ( & draw_info -> text , text ) ; text = DestroyString ( text ) ; ( void ) FormatLocaleString ( geometry , MaxTextExtent , "%+g%+g" , - metrics . bounds . x1 , metrics . ascent ) ; if ( draw_info -> gravity == UndefinedGravity ) ( void ) CloneString ( & draw_info -> geometry , geometry ) ; status = GetMultilineTypeMetrics ( image , draw_info , & metrics ) ; image -> rows = ( size_t ) ( ( i + 1 ) * ( metrics . ascent - metrics . descent + draw_info -> interline_spacing + draw_info -> stroke_width ) + 0.5 ) ; } if ( status != MagickFalse ) status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { draw_info = DestroyDrawInfo ( draw_info ) ; InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; } if ( SetImageBackgroundColor ( image ) == MagickFalse ) { draw_info = DestroyDrawInfo ( draw_info ) ; InheritException ( exception , & image -> exception ) ; image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } if ( ( fabs ( image_info -> pointsize ) < MagickEpsilon ) && ( strlen ( caption ) > 0 ) ) { double high , low ; for ( ; ; draw_info -> pointsize *= 2.0 ) { text = AcquireString ( caption ) ; i = FormatMagickCaption ( image , draw_info , split , & metrics , & text ) ; ( void ) CloneString ( & draw_info -> text , text ) ; text = DestroyString ( text ) ; ( void ) FormatLocaleString ( geometry , MaxTextExtent , "%+g%+g" , - metrics . bounds . x1 , metrics . ascent ) ; if ( draw_info -> gravity == UndefinedGravity ) ( void ) CloneString ( & draw_info -> geometry , geometry ) ; status = GetMultilineTypeMetrics ( image , draw_info , & metrics ) ; ( void ) status ; width = ( size_t ) floor ( metrics . width + draw_info -> stroke_width + 0.5 ) ; height = ( size_t ) floor ( metrics . height + draw_info -> stroke_width + 0.5 ) ; if ( ( image -> columns != 0 ) && ( image -> rows != 0 ) ) { if ( ( width >= image -> columns ) && ( height >= image -> rows ) ) break ; } else if ( ( ( image -> columns != 0 ) && ( width >= image -> columns ) ) || ( ( image -> rows != 0 ) && ( height >= image -> rows ) ) ) break ; } high = draw_info -> pointsize ; for ( low = 1.0 ; ( high - low ) > 0.5 ; ) { draw_info -> pointsize = ( low + high ) / 2.0 ; text = AcquireString ( caption ) ; i = FormatMagickCaption ( image , draw_info , split , & metrics , & text ) ; ( void ) CloneString ( & draw_info -> text , text ) ; text = DestroyString ( text ) ; ( void ) FormatLocaleString ( geometry , MaxTextExtent , "%+g%+g" , - metrics . bounds . x1 , metrics . ascent ) ; if ( draw_info -> gravity == UndefinedGravity ) ( void ) CloneString ( & draw_info -> geometry , geometry ) ; ( void ) GetMultilineTypeMetrics ( image , draw_info , & metrics ) ; width = ( size_t ) floor ( metrics . width + draw_info -> stroke_width + 0.5 ) ; height = ( size_t ) floor ( metrics . height + draw_info -> stroke_width + 0.5 ) ; if ( ( image -> columns != 0 ) && ( image -> rows != 0 ) ) { if ( ( width < image -> columns ) && ( height < image -> rows ) ) low = draw_info -> pointsize + 0.5 ; else high = draw_info -> pointsize - 0.5 ; } else if ( ( ( image -> columns != 0 ) && ( width < image -> columns ) ) || ( ( image -> rows != 0 ) && ( height < image -> rows ) ) ) low = draw_info -> pointsize + 0.5 ; else high = draw_info -> pointsize - 0.5 ; } draw_info -> pointsize = floor ( ( low + high ) / 2.0 - 0.5 ) ; } i = FormatMagickCaption ( image , draw_info , split , & metrics , & caption ) ; ( void ) CloneString ( & draw_info -> text , caption ) ; ( void ) FormatLocaleString ( geometry , MaxTextExtent , "%+g%+g" , MagickMax ( draw_info -> direction == RightToLeftDirection ? image -> columns - metrics . bounds . x2 : - metrics . bounds . x1 , 0.0 ) , draw_info -> gravity == UndefinedGravity ? metrics . ascent : 0.0 ) ; <S2SV_StartBug> draw_info -> geometry = AcquireString ( geometry ) ; <S2SV_EndBug> status = AnnotateImage ( image , draw_info ) ; if ( image_info -> pointsize == 0.0 ) { char pointsize [ MaxTextExtent ] ; ( void ) FormatLocaleString ( pointsize , MaxTextExtent , "%.20g" , draw_info -> pointsize ) ; ( void ) SetImageProperty ( image , "caption:pointsize" , pointsize ) ; } draw_info = DestroyDrawInfo ( draw_info ) ; caption = DestroyString ( caption ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } return ( GetFirstImageInList ( image ) ) ; }
<S2SV_ModStart> 0.0 ) ; ( void ) CloneString ( & <S2SV_ModStart> draw_info -> geometry , <S2SV_ModEnd> geometry ) ;
53
CWE-129 int snmp_helper ( void * context , size_t hdrlen , unsigned char tag , const void * data , size_t datalen ) { struct snmp_ctx * ctx = ( struct snmp_ctx * ) <S2SV_StartBug> context ; __be32 * pdata = ( <S2SV_EndBug> __be32 * ) data ; if ( * pdata == ctx -> from ) { pr_debug ( "%s:<S2SV_blank>%pI4<S2SV_blank>to<S2SV_blank>%pI4\\n" , __func__ , ( void * ) & ctx -> from , ( void * ) & ctx -> to ) ; if ( * ctx -> check ) fast_csum ( ctx , ( unsigned char * ) data - ctx -> begin ) ; * pdata = ctx -> to ; } return 1 ; }
<S2SV_ModStart> ; __be32 * pdata ; if ( datalen != 4 ) return - EINVAL ;
54
CWE-787 int mp_unpack_full ( lua_State * L , int limit , int offset ) { size_t len ; const char * s ; mp_cur c ; int cnt ; int decode_all = ( ! limit && ! offset ) ; s = luaL_checklstring ( L , 1 , & len ) ; if ( offset < 0 || limit < 0 ) return luaL_error ( L , "Invalid<S2SV_blank>request<S2SV_blank>to<S2SV_blank>unpack<S2SV_blank>with<S2SV_blank>offset<S2SV_blank>of<S2SV_blank>%d<S2SV_blank>and<S2SV_blank>limit<S2SV_blank>of<S2SV_blank>%d." , offset , len ) ; else if ( offset > len ) return luaL_error ( L , "Start<S2SV_blank>offset<S2SV_blank>%d<S2SV_blank>greater<S2SV_blank>than<S2SV_blank>input<S2SV_blank>length<S2SV_blank>%d." , offset , len ) ; if ( decode_all ) limit = INT_MAX ; mp_cur_init ( & c , ( const unsigned char * ) s + offset , len - offset ) ; for ( cnt = 0 ; c . left > 0 && cnt < limit ; cnt ++ ) { mp_decode_to_lua_type ( L , & c ) ; if ( c . err == MP_CUR_ERROR_EOF ) { return luaL_error ( L , "Missing<S2SV_blank>bytes<S2SV_blank>in<S2SV_blank>input." ) ; } else if ( c . err == MP_CUR_ERROR_BADFMT ) { return luaL_error ( L , "Bad<S2SV_blank>data<S2SV_blank>format<S2SV_blank>in<S2SV_blank>input." ) ; } } if ( ! decode_all ) { int offset = len - c . <S2SV_StartBug> left ; lua_pushinteger ( L , c . left == 0 ? - 1 : offset ) <S2SV_EndBug> ; lua_insert ( L , 2 ) ; cnt += 1 ; } return cnt ; }
<S2SV_ModStart> . left ; luaL_checkstack ( L , 1 , "in<S2SV_blank>function<S2SV_blank>mp_unpack_full" ) ;
55
CWE-000 static int ghash_update ( struct shash_desc * desc , const u8 * src , unsigned int srclen ) { struct ghash_desc_ctx * dctx = shash_desc_ctx ( desc ) ; struct ghash_ctx * ctx = crypto_shash_ctx ( desc -> tfm ) ; u8 * dst = dctx -> buffer ; if <S2SV_StartBug> ( dctx -> bytes ) { <S2SV_EndBug> int n = min ( srclen , dctx -> bytes ) ; u8 * pos = dst + ( GHASH_BLOCK_SIZE - dctx -> bytes ) ; dctx -> bytes -= n ; srclen -= n ; while ( n -- ) * pos ++ ^= * src ++ ; if ( ! dctx -> bytes ) gf128mul_4k_lle ( ( be128 * ) dst , ctx -> gf128 ) ; } while ( srclen >= GHASH_BLOCK_SIZE ) { crypto_xor ( dst , src , GHASH_BLOCK_SIZE ) ; gf128mul_4k_lle ( ( be128 * ) dst , ctx -> gf128 ) ; src += GHASH_BLOCK_SIZE ; srclen -= GHASH_BLOCK_SIZE ; } if ( srclen ) { dctx -> bytes = GHASH_BLOCK_SIZE - srclen ; while ( srclen -- ) * dst ++ ^= * src ++ ; } return 0 ; }
<S2SV_ModStart> ; if ( ! ctx -> gf128 ) return - ENOKEY ; if (
56
CWE-125 static stmt_ty ast_for_funcdef ( struct compiling * c , const node * n , asdl_seq * decorator_seq ) { return ast_for_funcdef_impl ( c , n , decorator_seq , <S2SV_StartBug> <S2SV_EndBug> 0 ) ; }
<S2SV_ModStart> , decorator_seq , false <S2SV_ModEnd> ) ; }
57
CWE-119 static void scsi_write_complete ( void * opaque , int ret ) { SCSIDiskReq * r = ( SCSIDiskReq * ) opaque ; SCSIDiskState * s = DO_UPCAST ( SCSIDiskState , qdev , r -> req . <S2SV_StartBug> dev ) ; uint32_t len <S2SV_EndBug> ; uint32_t n ; if ( r -> req . aiocb != NULL ) { r -> req . aiocb = NULL ; bdrv_acct_done ( s -> bs , & r -> acct ) ; } if ( ret ) { if ( scsi_handle_rw_error ( r , - ret , SCSI_REQ_STATUS_RETRY_WRITE ) ) { return <S2SV_StartBug> ; } } n = r -> iov . iov_len / 512 ; <S2SV_EndBug> r -> sector += n ; r -> sector_count -= n ; if ( r -> sector_count == 0 ) { scsi_req_complete ( & r -> req , GOOD ) ; } else { len = r -> <S2SV_StartBug> sector_count * 512 <S2SV_EndBug> ; if ( len > SCSI_DMA_BUF_SIZE ) { len = SCSI_DMA_BUF_SIZE ; } r -> iov . iov_len <S2SV_StartBug> = len ; DPRINTF ( "Write<S2SV_blank>complete<S2SV_blank>tag=0x%x<S2SV_blank>more=%d\\n" , r -> req . tag , len ) <S2SV_StartBug> <S2SV_EndBug> ; scsi_req_data ( & r -> req , <S2SV_EndBug> len ) ; } }
<S2SV_ModStart> ) ; uint32_t <S2SV_ModEnd> n ; if <S2SV_ModStart> = r -> qiov . size <S2SV_ModEnd> / 512 ; <S2SV_ModStart> } else { scsi_init_iovec ( r ) <S2SV_ModEnd> ; DPRINTF ( <S2SV_ModStart> . tag , r -> qiov . size <S2SV_ModEnd> ) ; scsi_req_data <S2SV_ModStart> -> req , r -> qiov . size <S2SV_ModEnd> ) ; }
58
CWE-119 void vp8_create_common ( VP8_COMMON * oci ) { vp8_machine_specific_config ( oci ) ; vp8_init_mbmode_probs ( oci ) ; vp8_default_bmode_probs ( oci -> fc . bmode_prob ) ; oci -> mb_no_coeff_skip = 1 ; oci -> no_lpf = 0 ; oci -> filter_type = NORMAL_LOOPFILTER ; oci -> use_bilinear_mc_filter = 0 ; oci -> full_pixel = 0 ; oci -> multi_token_partition = ONE_PARTITION ; oci -> <S2SV_StartBug> clamp_type = RECON_CLAMP_REQUIRED ; vpx_memset ( oci -> ref_frame_sign_bias , 0 , sizeof ( oci <S2SV_EndBug> -> ref_frame_sign_bias ) ) ; oci -> copy_buffer_to_gf = 0 ; oci -> copy_buffer_to_arf = 0 ; }
<S2SV_ModStart> = RECON_CLAMP_REQUIRED ; memset <S2SV_ModEnd> ( oci ->
59
CWE-125 void icmp_print ( netdissect_options * ndo , const u_char * bp , u_int plen , const u_char * bp2 , int fragmented ) { char * cp ; const struct icmp * dp ; const struct icmp_ext_t * ext_dp ; const struct ip * ip ; const char * str , * fmt ; const struct ip * oip ; const struct udphdr * ouh ; const uint8_t * obj_tptr ; uint32_t raw_label ; const u_char * snapend_save ; const struct icmp_mpls_ext_object_header_t * icmp_mpls_ext_object_header ; u_int hlen , dport , mtu , obj_tlen , obj_class_num , obj_ctype ; char buf [ MAXHOSTNAMELEN + 100 ] ; struct cksum_vec vec [ 1 ] ; dp = ( const struct icmp * ) bp ; ext_dp = ( const struct icmp_ext_t * ) bp ; ip = ( const struct ip * ) bp2 ; str = buf ; ND_TCHECK ( dp -> icmp_code ) ; switch ( dp -> icmp_type ) { case ICMP_ECHO : case ICMP_ECHOREPLY : ND_TCHECK ( dp -> icmp_seq ) ; ( void ) snprintf ( buf , sizeof ( buf ) , "echo<S2SV_blank>%s,<S2SV_blank>id<S2SV_blank>%u,<S2SV_blank>seq<S2SV_blank>%u" , dp -> icmp_type == ICMP_ECHO ? "request" : "reply" , EXTRACT_16BITS ( & dp -> icmp_id ) , EXTRACT_16BITS ( & dp -> icmp_seq ) ) ; break ; case ICMP_UNREACH : ND_TCHECK ( dp -> icmp_ip . ip_dst ) ; switch ( dp -> icmp_code ) { case ICMP_UNREACH_PROTOCOL : ND_TCHECK ( dp -> icmp_ip . ip_p ) ; ( void ) snprintf ( buf , sizeof ( buf ) , "%s<S2SV_blank>protocol<S2SV_blank>%d<S2SV_blank>unreachable" , ipaddr_string ( ndo , & dp -> icmp_ip . ip_dst ) , dp -> icmp_ip . ip_p ) ; break ; case ICMP_UNREACH_PORT : ND_TCHECK ( dp -> icmp_ip . ip_p ) ; oip = & dp -> icmp_ip ; hlen = IP_HL ( oip ) * 4 ; ouh = ( const struct udphdr * ) ( ( ( const u_char * ) oip ) + hlen ) ; ND_TCHECK ( ouh -> uh_dport ) ; dport = EXTRACT_16BITS ( & ouh -> uh_dport ) ; switch ( oip -> ip_p ) { case IPPROTO_TCP : ( void ) snprintf ( buf , sizeof ( buf ) , "%s<S2SV_blank>tcp<S2SV_blank>port<S2SV_blank>%s<S2SV_blank>unreachable" , ipaddr_string ( ndo , & oip -> ip_dst ) , tcpport_string ( ndo , dport ) ) ; break ; case IPPROTO_UDP : ( void ) snprintf ( buf , sizeof ( buf ) , "%s<S2SV_blank>udp<S2SV_blank>port<S2SV_blank>%s<S2SV_blank>unreachable" , ipaddr_string ( ndo , & oip -> ip_dst ) , udpport_string ( ndo , dport ) ) ; break ; default : ( void ) snprintf ( buf , sizeof ( buf ) , "%s<S2SV_blank>protocol<S2SV_blank>%d<S2SV_blank>port<S2SV_blank>%d<S2SV_blank>unreachable" , ipaddr_string ( ndo , & oip -> ip_dst ) , oip -> ip_p , dport ) ; break ; } break ; case ICMP_UNREACH_NEEDFRAG : { register const struct mtu_discovery * mp ; mp = ( const struct mtu_discovery * ) ( const u_char * ) & dp -> icmp_void ; mtu = EXTRACT_16BITS ( & mp -> nexthopmtu ) ; if ( mtu ) { ( void ) snprintf ( buf , sizeof ( buf ) , "%s<S2SV_blank>unreachable<S2SV_blank>-<S2SV_blank>need<S2SV_blank>to<S2SV_blank>frag<S2SV_blank>(mtu<S2SV_blank>%d)" , ipaddr_string ( ndo , & dp -> icmp_ip . ip_dst ) , mtu ) ; } else { ( void ) snprintf ( buf , sizeof ( buf ) , "%s<S2SV_blank>unreachable<S2SV_blank>-<S2SV_blank>need<S2SV_blank>to<S2SV_blank>frag" , ipaddr_string ( ndo , & dp -> icmp_ip . ip_dst ) ) ; } } break ; default : fmt = tok2str ( unreach2str , "#%d<S2SV_blank>%%s<S2SV_blank>unreachable" , dp -> icmp_code ) ; ( void ) snprintf ( buf , sizeof ( buf ) , fmt , ipaddr_string ( ndo , & dp -> icmp_ip . ip_dst ) ) ; break ; } break ; case ICMP_REDIRECT : ND_TCHECK ( dp -> icmp_ip . ip_dst ) ; fmt = tok2str ( type2str , "redirect-#%d<S2SV_blank>%%s<S2SV_blank>to<S2SV_blank>net<S2SV_blank>%%s" , dp -> icmp_code ) ; ( void ) snprintf ( buf , sizeof ( buf ) , fmt , ipaddr_string ( ndo , & dp -> icmp_ip . ip_dst ) , ipaddr_string ( ndo , & dp -> icmp_gwaddr ) ) ; break ; case ICMP_ROUTERADVERT : { register const struct ih_rdiscovery * ihp ; register const struct id_rdiscovery * idp ; u_int lifetime , num , size ; ( void ) snprintf ( buf , sizeof ( buf ) , "router<S2SV_blank>advertisement" ) ; cp = buf + strlen ( buf ) ; ihp = ( const struct ih_rdiscovery * ) & dp -> icmp_void ; ND_TCHECK ( * ihp ) ; ( void ) strncpy ( cp , "<S2SV_blank>lifetime<S2SV_blank>" , sizeof ( buf ) - ( cp - buf ) ) ; cp = buf + strlen ( buf ) ; lifetime = EXTRACT_16BITS ( & ihp -> ird_lifetime ) ; if ( lifetime < 60 ) { ( void ) snprintf ( cp , sizeof ( buf ) - ( cp - buf ) , "%u" , lifetime ) ; } else if ( lifetime < 60 * 60 ) { ( void ) snprintf ( cp , sizeof ( buf ) - ( cp - buf ) , "%u:%02u" , lifetime / 60 , lifetime % 60 ) ; } else { ( void ) snprintf ( cp , sizeof ( buf ) - ( cp - buf ) , "%u:%02u:%02u" , lifetime / 3600 , ( lifetime % 3600 ) / 60 , lifetime % 60 ) ; } cp = buf + strlen ( buf ) ; num = ihp -> ird_addrnum ; ( void ) snprintf ( cp , sizeof ( buf ) - ( cp - buf ) , "<S2SV_blank>%d:" , num ) ; cp = buf + strlen ( buf ) ; size = ihp -> ird_addrsiz ; if ( size != 2 ) { ( void ) snprintf ( cp , sizeof ( buf ) - ( cp - buf ) , "<S2SV_blank>[size<S2SV_blank>%d]" , size ) ; break ; } idp = ( const struct id_rdiscovery * ) & dp -> icmp_data ; while ( num -- > 0 ) { ND_TCHECK ( * idp ) ; ( void ) snprintf ( cp , sizeof ( buf ) - ( cp - buf ) , "<S2SV_blank>{%s<S2SV_blank>%u}" , ipaddr_string ( ndo , & idp -> ird_addr ) , EXTRACT_32BITS ( & idp -> ird_pref ) ) ; cp = buf + strlen ( buf ) ; ++ idp ; } } break ; case ICMP_TIMXCEED : ND_TCHECK ( dp -> icmp_ip . ip_dst ) ; switch ( dp -> icmp_code ) { case ICMP_TIMXCEED_INTRANS : str = "time<S2SV_blank>exceeded<S2SV_blank>in-transit" ; break ; case ICMP_TIMXCEED_REASS : str = "ip<S2SV_blank>reassembly<S2SV_blank>time<S2SV_blank>exceeded" ; break ; default : ( void ) snprintf ( buf , sizeof ( buf ) , "time<S2SV_blank>exceeded-#%d" , dp -> icmp_code ) ; break ; } break ; case ICMP_PARAMPROB : if ( dp -> icmp_code ) ( void ) snprintf ( buf , sizeof ( buf ) , "parameter<S2SV_blank>problem<S2SV_blank>-<S2SV_blank>code<S2SV_blank>%d" , dp -> icmp_code ) ; else { ND_TCHECK ( dp -> icmp_pptr ) ; ( void ) snprintf ( buf , sizeof ( buf ) , "parameter<S2SV_blank>problem<S2SV_blank>-<S2SV_blank>octet<S2SV_blank>%d" , dp -> icmp_pptr ) ; } break ; case ICMP_MASKREPLY : ND_TCHECK ( dp -> icmp_mask ) ; ( void ) snprintf ( buf , sizeof ( buf ) , "address<S2SV_blank>mask<S2SV_blank>is<S2SV_blank>0x%08x" , EXTRACT_32BITS ( & dp -> icmp_mask ) ) ; break ; case ICMP_TSTAMP : ND_TCHECK ( dp -> icmp_seq ) ; ( void ) snprintf ( buf , sizeof ( buf ) , "time<S2SV_blank>stamp<S2SV_blank>query<S2SV_blank>id<S2SV_blank>%u<S2SV_blank>seq<S2SV_blank>%u" , EXTRACT_16BITS ( & dp -> icmp_id ) , EXTRACT_16BITS ( & dp -> icmp_seq ) ) ; break ; case ICMP_TSTAMPREPLY : ND_TCHECK ( dp -> icmp_ttime ) ; ( void ) snprintf ( buf , sizeof ( buf ) , "time<S2SV_blank>stamp<S2SV_blank>reply<S2SV_blank>id<S2SV_blank>%u<S2SV_blank>seq<S2SV_blank>%u:<S2SV_blank>org<S2SV_blank>%s" , EXTRACT_16BITS ( & dp -> icmp_id ) , EXTRACT_16BITS ( & dp -> icmp_seq ) , icmp_tstamp_print ( EXTRACT_32BITS ( & dp -> icmp_otime ) ) ) ; ( void ) snprintf ( buf + strlen ( buf ) , sizeof ( buf ) - strlen ( buf ) , ",<S2SV_blank>recv<S2SV_blank>%s" , icmp_tstamp_print ( EXTRACT_32BITS ( & dp -> icmp_rtime ) ) ) ; ( void ) snprintf ( buf + strlen ( buf ) , sizeof ( buf ) - strlen ( buf ) , ",<S2SV_blank>xmit<S2SV_blank>%s" , icmp_tstamp_print ( EXTRACT_32BITS ( & dp -> icmp_ttime ) ) ) ; break ; default : str = tok2str ( icmp2str , "type-#%d" , dp -> icmp_type ) ; break ; } ND_PRINT ( ( ndo , "ICMP<S2SV_blank>%s,<S2SV_blank>length<S2SV_blank>%u" , str , plen ) ) ; if ( ndo -> ndo_vflag && ! fragmented ) { uint16_t sum , icmp_sum ; if ( ND_TTEST2 ( * bp , plen ) ) { vec [ 0 ] . ptr = ( const uint8_t * ) ( const void * ) dp ; vec [ 0 ] . len = plen ; sum = in_cksum ( vec , 1 ) ; if ( sum != 0 ) { icmp_sum = EXTRACT_16BITS ( & dp -> icmp_cksum ) ; ND_PRINT ( ( ndo , "<S2SV_blank>(wrong<S2SV_blank>icmp<S2SV_blank>cksum<S2SV_blank>%x<S2SV_blank>(->%x)!)" , icmp_sum , in_cksum_shouldbe ( icmp_sum , sum ) ) ) ; } } } if ( ndo -> ndo_vflag >= 1 && ICMP_ERRTYPE ( dp -> icmp_type ) ) { bp += 8 ; ND_PRINT ( ( ndo , "\\n\\t" ) ) ; ip = ( const struct ip * ) bp ; snapend_save = ndo -> ndo_snapend ; ip_print ( ndo , bp , EXTRACT_16BITS ( & ip -> ip_len ) ) ; ndo -> ndo_snapend = snapend_save ; } if ( ndo -> ndo_vflag >= 1 && plen > ICMP_EXTD_MINLEN && ICMP_MPLS_EXT_TYPE ( dp -> icmp_type ) ) { ND_TCHECK ( * ext_dp ) ; <S2SV_StartBug> if ( ! ext_dp -> <S2SV_EndBug> icmp_length ) { vec [ 0 ] . ptr = ( const uint8_t * ) ( const void * ) & ext_dp -> icmp_ext_version_res ; vec [ 0 ] . len = plen - ICMP_EXTD_MINLEN ; if ( in_cksum ( vec , 1 ) ) { return ; } } ND_PRINT ( ( ndo , "\\n\\tMPLS<S2SV_blank>extension<S2SV_blank>v%u" , ICMP_MPLS_EXT_EXTRACT_VERSION ( * ( ext_dp -> icmp_ext_version_res ) ) ) ) ; if ( ICMP_MPLS_EXT_EXTRACT_VERSION ( * ( ext_dp -> icmp_ext_version_res ) ) != ICMP_MPLS_EXT_VERSION ) { ND_PRINT ( ( ndo , "<S2SV_blank>packet<S2SV_blank>not<S2SV_blank>supported" ) ) ; return ; } hlen <S2SV_StartBug> = plen - ICMP_EXTD_MINLEN ; vec [ 0 ] . ptr = ( const uint8_t * ) ( const void * ) & ext_dp -> icmp_ext_version_res ; <S2SV_EndBug> vec [ 0 ] . len = hlen ; ND_PRINT ( ( ndo , ",<S2SV_blank>checksum<S2SV_blank>0x%04x<S2SV_blank>(%scorrect),<S2SV_blank>length<S2SV_blank>%u" , EXTRACT_16BITS ( ext_dp -> icmp_ext_checksum ) , in_cksum ( vec , 1 ) ? "in" : "" , hlen ) ) <S2SV_StartBug> ; hlen -= 4 ; obj_tptr = ( <S2SV_EndBug> const uint8_t * ) ext_dp -> icmp_ext_data ; while ( hlen > sizeof ( struct icmp_mpls_ext_object_header_t ) ) { icmp_mpls_ext_object_header = ( const struct icmp_mpls_ext_object_header_t * ) obj_tptr ; ND_TCHECK ( * icmp_mpls_ext_object_header ) ; obj_tlen = EXTRACT_16BITS ( icmp_mpls_ext_object_header -> length ) ; obj_class_num = icmp_mpls_ext_object_header -> class_num ; obj_ctype = icmp_mpls_ext_object_header -> ctype ; obj_tptr += sizeof ( struct icmp_mpls_ext_object_header_t ) ; ND_PRINT ( ( ndo , "\\n\\t<S2SV_blank><S2SV_blank>%s<S2SV_blank>Object<S2SV_blank>(%u),<S2SV_blank>Class-Type:<S2SV_blank>%u,<S2SV_blank>length<S2SV_blank>%u" , tok2str ( icmp_mpls_ext_obj_values , "unknown" , obj_class_num ) , obj_class_num , obj_ctype , obj_tlen ) ) ; hlen -= sizeof ( struct icmp_mpls_ext_object_header_t ) ; if ( ( obj_class_num == 0 ) || ( obj_tlen < sizeof ( struct icmp_mpls_ext_object_header_t ) ) ) { return ; } obj_tlen -= sizeof ( struct icmp_mpls_ext_object_header_t ) ; switch ( obj_class_num ) { case 1 : switch ( obj_ctype ) { case 1 : ND_TCHECK2 ( * obj_tptr , 4 ) ; raw_label = EXTRACT_32BITS ( obj_tptr ) ; ND_PRINT ( ( ndo , "\\n\\t<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>label<S2SV_blank>%u,<S2SV_blank>exp<S2SV_blank>%u" , MPLS_LABEL ( raw_label ) , MPLS_EXP ( raw_label ) ) ) ; if ( MPLS_STACK ( raw_label ) ) ND_PRINT ( ( ndo , ",<S2SV_blank>[S]" ) ) ; ND_PRINT ( ( ndo , ",<S2SV_blank>ttl<S2SV_blank>%u" , MPLS_TTL ( raw_label ) ) ) ; break ; default : print_unknown_data ( ndo , obj_tptr , "\\n\\t<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>" , obj_tlen ) ; } break ; case 2 : default : print_unknown_data ( ndo , obj_tptr , "\\n\\t<S2SV_blank><S2SV_blank><S2SV_blank><S2SV_blank>" , obj_tlen ) ; break ; } if ( hlen < obj_tlen ) break ; hlen -= obj_tlen ; obj_tptr += obj_tlen ; } } return ; trunc : ND_PRINT ( ( ndo , "[|icmp]" ) ) ; }
<S2SV_ModStart> ext_dp -> icmp_length && ND_TTEST2 ( ext_dp -> icmp_ext_version_res , plen - ICMP_EXTD_MINLEN ) <S2SV_ModStart> - ICMP_EXTD_MINLEN ; if ( ND_TTEST2 ( ext_dp -> icmp_ext_version_res , hlen ) ) { <S2SV_ModStart> ) ) ; }
60
<S2SV_StartBug> CWE-119 static void encode_mv_component ( vp9_writer * w <S2SV_EndBug> , int comp , const nmv_component * mvcomp , int usehp ) { int offset ; const int sign = comp < 0 ; const int mag = sign ? - comp : comp ; const int mv_class = vp9_get_mv_class ( mag - 1 , & offset ) ; const int d = offset >> 3 ; const int fr = ( offset >> 1 ) & 3 ; const int hp = offset & 1 ; assert ( comp != 0 ) ; vp9_write ( <S2SV_StartBug> w , sign , mvcomp -> sign ) <S2SV_EndBug> ; vp9_write_token ( w , vp9_mv_class_tree , mvcomp -> classes , & mv_class_encodings [ mv_class ] ) ; if ( mv_class == MV_CLASS_0 ) { vp9_write_token ( w , vp9_mv_class0_tree , mvcomp -> class0 , & mv_class0_encodings [ d ] ) ; } else { int i ; const int n = mv_class + CLASS0_BITS - 1 ; for ( i = 0 ; i < n ; ++ i <S2SV_StartBug> ) vp9_write ( w , ( d >> i ) & 1 , mvcomp -> bits [ i ] ) ; <S2SV_EndBug> } vp9_write_token ( w , vp9_mv_fp_tree , mv_class == MV_CLASS_0 ? mvcomp -> class0_fp [ d ] : mvcomp -> fp , & mv_fp_encodings [ fr ] ) ; if ( usehp ) vp9_write ( w <S2SV_StartBug> , hp , <S2SV_EndBug> mv_class == MV_CLASS_0 ? mvcomp -> class0_hp : mvcomp -> hp ) ; }
<S2SV_ModStart> void encode_mv_component ( vpx_writer <S2SV_ModEnd> * w , <S2SV_ModStart> 0 ) ; vpx_write <S2SV_ModEnd> ( w , <S2SV_ModStart> ++ i ) vpx_write <S2SV_ModEnd> ( w , <S2SV_ModStart> ( usehp ) vpx_write <S2SV_ModEnd> ( w ,
61
CWE-476 static unsigned int seedsize ( struct crypto_alg * alg ) { struct rng_alg * ralg = container_of ( alg , struct rng_alg , base ) ; return alg -> <S2SV_StartBug> cra_rng . <S2SV_EndBug> rng_make_random ? alg -> cra_rng . seedsize : ralg -> seedsize ; }
<S2SV_ModStart> ) ; return <S2SV_ModEnd> ralg -> seedsize
62
CWE-200 static int pptp_connect ( struct socket * sock , struct sockaddr * uservaddr , int sockaddr_len , int flags ) { struct sock * sk = sock -> sk ; struct sockaddr_pppox * sp = ( struct sockaddr_pppox * ) uservaddr ; struct pppox_sock * po = pppox_sk ( sk ) ; struct pptp_opt * opt = & po -> proto . pptp ; struct rtable * rt ; struct flowi4 fl4 ; int error = 0 ; if ( sp <S2SV_StartBug> -> sa_protocol <S2SV_EndBug> != PX_PROTO_PPTP ) return - EINVAL ; if ( lookup_chan_dst ( sp -> sa_addr . pptp . call_id , sp -> sa_addr . pptp . sin_addr . s_addr ) ) return - EALREADY ; lock_sock ( sk ) ; if ( sk -> sk_state & PPPOX_CONNECTED ) { error = - EBUSY ; goto end ; } if ( sk -> sk_state & PPPOX_DEAD ) { error = - EALREADY ; goto end ; } if ( ! opt -> src_addr . sin_addr . s_addr || ! sp -> sa_addr . pptp . sin_addr . s_addr ) { error = - EINVAL ; goto end ; } po -> chan . private = sk ; po -> chan . ops = & pptp_chan_ops ; rt = ip_route_output_ports ( sock_net ( sk ) , & fl4 , sk , opt -> dst_addr . sin_addr . s_addr , opt -> src_addr . sin_addr . s_addr , 0 , 0 , IPPROTO_GRE , RT_CONN_FLAGS ( sk ) , 0 ) ; if ( IS_ERR ( rt ) ) { error = - EHOSTUNREACH ; goto end ; } sk_setup_caps ( sk , & rt -> dst ) ; po -> chan . mtu = dst_mtu ( & rt -> dst ) ; if ( ! po -> chan . mtu ) po -> chan . mtu = PPP_MRU ; ip_rt_put ( rt ) ; po -> chan . mtu -= PPTP_HEADER_OVERHEAD ; po -> chan . hdrlen = 2 + sizeof ( struct pptp_gre_header ) ; error = ppp_register_channel ( & po -> chan ) ; if ( error ) { pr_err ( "PPTP:<S2SV_blank>failed<S2SV_blank>to<S2SV_blank>register<S2SV_blank>PPP<S2SV_blank>channel<S2SV_blank>(%d)\\n" , error ) ; goto end ; } opt -> dst_addr = sp -> sa_addr . pptp ; sk -> sk_state = PPPOX_CONNECTED ; end : release_sock ( sk ) ; return error ; }
<S2SV_ModStart> ; if ( sockaddr_len < sizeof ( struct sockaddr_pppox ) ) return - EINVAL ; if (
63
CWE-189 void jiffies_to_timespec ( const unsigned long jiffies , struct timespec * value ) <S2SV_StartBug> { u64 nsec = ( u64 ) jiffies * TICK_NSEC ; <S2SV_StartBug> value -> tv_sec = <S2SV_EndBug> div_long_long_rem ( nsec , NSEC_PER_SEC , & value -> tv_nsec ) ; } <S2SV_EndBug>
<S2SV_ModStart> value ) { u32 rem ; value -> tv_sec = div_u64_rem ( <S2SV_ModEnd> ( u64 ) <S2SV_ModStart> jiffies * TICK_NSEC , NSEC_PER_SEC , & rem ) <S2SV_ModStart> ; value -> tv_nsec = rem <S2SV_ModEnd> ; } <S2SV_null>
64
CWE-20 error_t coapClientSetRxBlockSize ( CoapClientRequest * request , uint_t blockSize ) { if ( request == NULL ) return ERROR_INVALID_PARAMETER ; osAcquireMutex ( & request -> context -> mutex ) ; if <S2SV_StartBug> ( blockSize == 16 ) request -> rxBlockSzx = COAP_BLOCK_SIZE_16 ; <S2SV_StartBug> <S2SV_EndBug> else if ( blockSize == 32 ) <S2SV_StartBug> <S2SV_EndBug> request -> rxBlockSzx = COAP_BLOCK_SIZE_32 ; <S2SV_EndBug> else <S2SV_StartBug> if ( blockSize == 64 ) <S2SV_StartBug> <S2SV_EndBug> request -> rxBlockSzx = <S2SV_StartBug> <S2SV_EndBug> COAP_BLOCK_SIZE_64 ; else if ( blockSize == 128 ) <S2SV_StartBug> <S2SV_EndBug> request -> rxBlockSzx = COAP_BLOCK_SIZE_128 ; <S2SV_StartBug> else if ( blockSize == <S2SV_EndBug> <S2SV_EndBug> 256 ) request -> rxBlockSzx = COAP_BLOCK_SIZE_256 <S2SV_StartBug> <S2SV_StartBug> <S2SV_EndBug> ; else if ( blockSize == 512 ) <S2SV_StartBug> <S2SV_EndBug> request -> rxBlockSzx = COAP_BLOCK_SIZE_512 ; <S2SV_StartBug> <S2SV_EndBug> <S2SV_EndBug> else <S2SV_StartBug> request -> rxBlockSzx = COAP_BLOCK_SIZE_1024 ; if <S2SV_EndBug> ( request -> rxBlockSzx > coapClientGetMaxBlockSize ( ) ) <S2SV_StartBug> request -> rxBlockSzx <S2SV_EndBug> = coapClientGetMaxBlockSize ( ) ; osReleaseMutex ( & request -> context -> mutex ) ; return NO_ERROR ; }
<S2SV_ModStart> == 16 ) { <S2SV_ModStart> = COAP_BLOCK_SIZE_16 ; } <S2SV_ModStart> == 32 ) { <S2SV_ModStart> = COAP_BLOCK_SIZE_32 ; } <S2SV_ModStart> == 64 ) { <S2SV_ModStart> = COAP_BLOCK_SIZE_64 ; } <S2SV_ModStart> == 128 ) { <S2SV_ModStart> = COAP_BLOCK_SIZE_128 ; } <S2SV_ModStart> == 256 ) { <S2SV_ModStart> = COAP_BLOCK_SIZE_256 ; } <S2SV_ModStart> == 512 ) { <S2SV_ModStart> = COAP_BLOCK_SIZE_512 ; } else { <S2SV_ModEnd> request -> rxBlockSzx <S2SV_ModStart> = COAP_BLOCK_SIZE_1024 ; } <S2SV_ModStart> ( ) ) { <S2SV_ModStart> ( ) ; }
65
CWE-476 int main ( int argc , char * * argv ) { int fmtid ; int id ; char * infile ; jas_stream_t * instream ; jas_image_t * image ; int width ; int height ; int depth ; int numcmpts ; int verbose ; <S2SV_StartBug> char * fmtname ; if ( jas_init ( ) <S2SV_EndBug> ) { abort ( ) ; } cmdname = argv [ 0 ] ; infile = 0 ; verbose = 0 ; while ( ( <S2SV_StartBug> id = jas_getopt ( argc , argv , opts ) ) <S2SV_EndBug> >= 0 ) { switch ( id ) { case OPT_VERBOSE : verbose = 1 ; break ; case OPT_VERSION : printf ( "%s\\n" , JAS_VERSION ) ; exit ( EXIT_SUCCESS ) ; break ; case OPT_INFILE : <S2SV_EndBug> <S2SV_StartBug> infile = jas_optarg ; break ; case OPT_HELP : default : usage ( ) ; <S2SV_StartBug> break ; } } if ( <S2SV_EndBug> infile ) { if ( ! ( instream = jas_stream_fopen ( infile , "rb" ) ) ) { fprintf ( stderr , "cannot<S2SV_blank>open<S2SV_blank>input<S2SV_blank>image<S2SV_blank>file<S2SV_blank>%s\\n" , infile ) ; exit ( EXIT_FAILURE ) ; } } else { if ( ! ( instream = jas_stream_fdopen ( 0 , "rb" ) ) ) { fprintf ( stderr , "cannot<S2SV_blank>open<S2SV_blank>standard<S2SV_blank>input\\n" ) ; exit ( EXIT_FAILURE ) ; } } if ( ( fmtid = jas_image_getfmt ( instream ) ) < 0 ) { fprintf ( stderr , "unknown<S2SV_blank>image<S2SV_blank>format\\n" ) <S2SV_StartBug> ; } if ( ! ( image = jas_image_decode ( instream , fmtid , 0 ) ) ) { <S2SV_EndBug> fprintf ( stderr , "cannot<S2SV_blank>load<S2SV_blank>image\\n" ) ; return EXIT_FAILURE ; } jas_stream_close ( instream ) ; numcmpts = jas_image_numcmpts ( image ) ; width = jas_image_cmptwidth ( image , 0 ) ; height = jas_image_cmptheight ( image , 0 ) ; depth = jas_image_cmptprec ( image , 0 ) ; if ( ! ( fmtname = jas_image_fmttostr ( fmtid ) ) ) { abort ( ) ; } printf ( "%s<S2SV_blank>%d<S2SV_blank>%d<S2SV_blank>%d<S2SV_blank>%d<S2SV_blank>%ld\\n" , fmtname , numcmpts , width , height , depth , ( long ) jas_image_rawsize ( image ) ) ; jas_image_destroy ( image ) ; jas_image_clearfmts ( ) ; return EXIT_SUCCESS ; }
<S2SV_ModStart> char * fmtname ; int debug <S2SV_ModStart> = 0 ; debug = 0 ; <S2SV_ModStart> break ; case OPT_DEBUG : debug = atoi ( jas_optarg ) ; break ; case <S2SV_ModStart> ; } } jas_setdbglevel ( debug ) ; <S2SV_ModStart> ) ) { jas_stream_close ( instream ) ;
66
CWE-20 void enc624j600UpdateMacConfig ( NetInterface * interface ) { uint16_t duplexMode ; duplexMode = enc624j600ReadReg ( <S2SV_StartBug> interface , <S2SV_EndBug> ENC624J600_REG_ESTAT ) & ESTAT_PHYDPX ; if <S2SV_StartBug> ( duplexMode ) { enc624j600WriteReg ( interface , ENC624J600_REG_MACON2 , MACON2_DEFER | MACON2_PADCFG2 | <S2SV_EndBug> MACON2_PADCFG0 | MACON2_TXCRCEN | MACON2_R1 | MACON2_FULDPX ) ; enc624j600WriteReg ( <S2SV_StartBug> interface , ENC624J600_REG_MABBIPG , 0x15 ) ; } else { <S2SV_StartBug> <S2SV_EndBug> enc624j600WriteReg ( interface , ENC624J600_REG_MACON2 , MACON2_DEFER | <S2SV_EndBug> MACON2_PADCFG2 | MACON2_PADCFG0 | MACON2_TXCRCEN | MACON2_R1 ) ; enc624j600WriteReg ( interface <S2SV_StartBug> , ENC624J600_REG_MABBIPG , 0x12 <S2SV_EndBug> ) ; } }
<S2SV_ModStart> ( interface , ENC624J600_ESTAT ) & ENC624J600_ESTAT_PHYDPX <S2SV_ModEnd> ; if ( <S2SV_ModStart> ( interface , ENC624J600_MACON2 , ENC624J600_MACON2_DEFER | ENC624J600_MACON2_PADCFG_AUTO | ENC624J600_MACON2_TXCRCEN | ENC624J600_MACON2_R1_DEFAULT | ENC624J600_MACON2_FULDPX <S2SV_ModEnd> ) ; enc624j600WriteReg <S2SV_ModStart> ( interface , ENC624J600_MABBIPG , ENC624J600_MABBIPG_BBIPG_DEFAULT_FD <S2SV_ModEnd> ) ; } <S2SV_ModStart> ( interface , ENC624J600_MACON2 , ENC624J600_MACON2_DEFER | ENC624J600_MACON2_PADCFG_AUTO | ENC624J600_MACON2_TXCRCEN | ENC624J600_MACON2_R1_DEFAULT <S2SV_ModEnd> ) ; enc624j600WriteReg <S2SV_ModStart> ( interface , ENC624J600_MABBIPG , ENC624J600_MABBIPG_BBIPG_DEFAULT_HD <S2SV_ModEnd> ) ; }
67
CWE-787 GF_Err adts_dmx_process ( GF_Filter * filter ) { GF_ADTSDmxCtx * ctx = gf_filter_get_udta ( filter ) ; GF_FilterPacket * pck , * dst_pck ; u8 * data , * output ; u8 * start ; u32 pck_size , remain , prev_pck_size ; u64 cts = GF_FILTER_NO_TS ; if ( ! ctx -> duration . num ) adts_dmx_check_dur ( filter , ctx ) ; if ( ctx -> opid && ! ctx -> is_playing ) return GF_OK ; pck = gf_filter_pid_get_packet ( ctx -> ipid ) ; if ( ! pck ) { if ( gf_filter_pid_is_eos ( ctx -> ipid ) ) { if ( ! ctx -> adts_buffer_size ) { if ( ctx -> opid ) gf_filter_pid_set_eos ( ctx -> opid ) ; if ( ctx -> src_pck ) gf_filter_pck_unref ( ctx -> src_pck ) ; ctx -> src_pck = NULL ; return GF_EOS ; } } else { return GF_OK ; } } prev_pck_size = ctx -> adts_buffer_size ; if ( pck && ! ctx -> resume_from ) { data = ( char * ) gf_filter_pck_get_data ( pck , & pck_size ) ; if ( ! pck_size ) { gf_filter_pid_drop_packet ( ctx -> ipid ) ; return GF_OK ; } if ( ctx -> byte_offset != GF_FILTER_NO_BO ) { u64 byte_offset = gf_filter_pck_get_byte_offset ( pck ) ; if ( ! ctx -> adts_buffer_size ) { ctx -> byte_offset = byte_offset ; } else if ( ctx -> byte_offset + ctx -> adts_buffer_size != byte_offset ) { ctx -> byte_offset = GF_FILTER_NO_BO ; if ( ( byte_offset != GF_FILTER_NO_BO ) && ( byte_offset > ctx -> adts_buffer_size ) ) { ctx -> byte_offset = byte_offset - ctx -> adts_buffer_size ; } } } if ( ctx -> adts_buffer_size + pck_size > ctx -> adts_buffer_alloc ) { ctx -> adts_buffer_alloc = ctx -> adts_buffer_size + pck_size ; ctx -> adts_buffer = gf_realloc ( ctx -> adts_buffer , ctx -> adts_buffer_alloc ) ; } memcpy ( ctx -> adts_buffer + ctx -> adts_buffer_size , data , pck_size ) ; ctx -> adts_buffer_size += pck_size ; } if ( ctx -> timescale && pck ) { cts = gf_filter_pck_get_cts ( pck ) ; } if ( cts == GF_FILTER_NO_TS ) { prev_pck_size = 0 ; } remain = ctx -> adts_buffer_size ; start = ctx -> adts_buffer ; if ( ctx -> resume_from ) { start += ctx -> resume_from - 1 ; remain -= ctx -> resume_from - 1 ; ctx -> resume_from = 0 ; } while ( remain ) { u8 * sync ; u32 sync_pos , size , offset , bytes_to_drop = 0 , nb_blocks_per_frame ; if ( ! ctx -> tag_size && ( remain > 3 ) ) { if ( start [ 0 ] == 'I' && start [ 1 ] == 'D' && start [ 2 ] == '3' ) { if ( remain < 10 ) return GF_OK ; ctx -> tag_size = ( ( start [ 9 ] & 0x7f ) + ( ( start [ 8 ] & 0x7f ) << 7 ) + ( ( start [ 7 ] & 0x7f ) << 14 ) + ( ( start [ 6 ] & 0x7f ) << 21 ) ) ; bytes_to_drop = 10 ; if ( ctx -> id3_buffer_alloc < ctx -> tag_size + 10 ) { ctx -> id3_buffer = gf_realloc ( ctx -> id3_buffer , ctx -> tag_size + 10 ) ; ctx -> id3_buffer_alloc = ctx -> tag_size + 10 ; } memcpy ( ctx -> id3_buffer , start , 10 ) ; ctx -> id3_buffer_size = 10 ; goto drop_byte ; } } if ( ctx -> tag_size ) { if ( ctx -> tag_size > remain ) { bytes_to_drop = remain ; ctx -> tag_size -= remain ; } else { bytes_to_drop = ctx -> tag_size ; ctx -> tag_size = 0 ; } memcpy ( ctx -> id3_buffer + ctx -> id3_buffer_size , start , bytes_to_drop ) ; ctx -> id3_buffer_size += bytes_to_drop ; if ( ! ctx -> tag_size && ctx -> opid ) { id3dmx_flush ( filter , ctx -> id3_buffer , ctx -> id3_buffer_size , ctx -> opid , ctx -> expart ? & ctx -> vpid : NULL ) ; ctx -> id3_buffer_size = 0 ; } goto drop_byte ; } sync = memchr ( start , 0xFF , remain ) ; sync_pos = ( u32 ) ( sync ? sync - start : remain ) ; if ( remain - sync_pos < 7 ) { break ; } if ( ( sync [ 1 ] & 0xF0 ) != 0xF0 ) { GF_LOG ( ctx -> nb_frames ? GF_LOG_WARNING : GF_LOG_DEBUG , GF_LOG_PARSER , ( "[ADTSDmx]<S2SV_blank>invalid<S2SV_blank>ADTS<S2SV_blank>sync<S2SV_blank>bytes,<S2SV_blank>resyncing\\n" ) ) ; ctx -> nb_frames = 0 ; goto drop_byte ; } if ( ! ctx -> bs ) { ctx -> bs = gf_bs_new ( sync + 1 , remain - sync_pos - 1 , GF_BITSTREAM_READ ) ; } else { gf_bs_reassign_buffer ( ctx -> bs , sync + 1 , remain - sync_pos - 1 ) ; } gf_bs_read_int ( ctx -> bs , 4 ) ; ctx -> hdr . is_mp2 = ( Bool ) gf_bs_read_int ( ctx -> bs , 1 ) ; ctx -> hdr . is_mp2 = 0 ; gf_bs_read_int ( ctx -> bs , 2 ) ; ctx -> hdr . no_crc = ( Bool ) gf_bs_read_int ( ctx -> bs , 1 ) ; ctx -> hdr . profile = 1 + gf_bs_read_int ( ctx -> bs , 2 ) ; ctx -> hdr . sr_idx = gf_bs_read_int ( ctx -> bs , 4 ) ; gf_bs_read_int ( ctx -> bs , 1 ) ; ctx -> hdr . nb_ch = gf_bs_read_int ( ctx -> bs , 3 ) ; gf_bs_read_int ( ctx -> bs , 4 ) ; ctx -> hdr . frame_size = gf_bs_read_int ( ctx -> bs , 13 ) ; gf_bs_read_int ( ctx -> bs , 11 ) ; nb_blocks_per_frame = gf_bs_read_int ( ctx -> bs , 2 ) ; ctx -> hdr . hdr_size = 7 ; if ( ! ctx -> hdr . no_crc ) { u32 skip ; if ( ! nb_blocks_per_frame ) { skip = 2 ; } else { skip = 2 + 2 * nb_blocks_per_frame ; } ctx -> hdr . hdr_size += skip ; gf_bs_skip_bytes ( ctx -> bs , skip ) ; } if ( ! ctx -> hdr . frame_size || ! GF_M4ASampleRates [ ctx -> hdr . sr_idx ] ) { GF_LOG ( GF_LOG_DEBUG , GF_LOG_PARSER , ( "[ADTSDmx]<S2SV_blank>Invalid<S2SV_blank>ADTS<S2SV_blank>frame<S2SV_blank>header,<S2SV_blank>resyncing\\n" ) ) ; ctx -> nb_frames = 0 ; goto drop_byte ; } if ( ( nb_blocks_per_frame > 2 ) || ( nb_blocks_per_frame && ctx -> hdr . nb_ch ) ) { GF_LOG ( GF_LOG_ERROR , GF_LOG_PARSER , ( "[ADTSDmx]<S2SV_blank>Unsupported<S2SV_blank>multi-block<S2SV_blank>ADTS<S2SV_blank>frame<S2SV_blank>header<S2SV_blank>-<S2SV_blank>patch<S2SV_blank>welcome\\n" ) ) ; ctx -> nb_frames = 0 ; goto drop_byte ; } else if ( ! nb_blocks_per_frame ) { if ( ctx -> aacchcfg < 0 ) ctx -> hdr . nb_ch = - ctx -> aacchcfg ; else if ( ! ctx -> hdr . nb_ch ) ctx -> hdr . nb_ch = ctx -> aacchcfg ; if ( ! ctx -> hdr . nb_ch ) { GF_LOG ( GF_LOG_WARNING , GF_LOG_PARSER , ( "[ADTSDmx]<S2SV_blank>Missing<S2SV_blank>channel<S2SV_blank>configuration<S2SV_blank>in<S2SV_blank>ADTS<S2SV_blank>frame<S2SV_blank>header,<S2SV_blank>defaulting<S2SV_blank>to<S2SV_blank>stereo<S2SV_blank>-<S2SV_blank>use<S2SV_blank>`--aacchcfg`<S2SV_blank>to<S2SV_blank>force<S2SV_blank>config\\n" ) ) ; ctx -> hdr . nb_ch = ctx -> aacchcfg = 2 ; } } if ( nb_blocks_per_frame == 2 ) { u32 pos = ( u32 ) gf_bs_get_position ( ctx -> bs ) ; gf_m4a_parse_program_config_element ( ctx -> bs , & ctx -> acfg ) ; if ( ! ctx -> hdr . no_crc ) gf_bs_skip_bytes ( ctx -> bs , 2 ) ; ctx -> hdr . hdr_size += ( u32 ) gf_bs_get_position ( ctx -> bs ) - pos ; } if ( ctx -> hdr . nb_ch == 7 ) ctx -> hdr . nb_ch = 8 ; if ( ctx -> hdr . frame_size + 1 < remain ) { u32 next_frame = ctx -> hdr . frame_size ; if ( ( sync [ next_frame ] != 0xFF ) || ( ( sync [ next_frame + 1 ] & 0xF0 ) != 0xF0 ) ) { GF_LOG ( ctx -> nb_frames ? GF_LOG_WARNING : GF_LOG_DEBUG , GF_LOG_PARSER , ( "[ADTSDmx]<S2SV_blank>invalid<S2SV_blank>next<S2SV_blank>ADTS<S2SV_blank>frame<S2SV_blank>sync,<S2SV_blank>resyncing\\n" ) ) ; ctx -> nb_frames = 0 ; goto drop_byte ; } } else if ( pck ) { if ( ctx -> timescale && ! prev_pck_size && ( cts != GF_FILTER_NO_TS ) ) { ctx -> cts = cts ; } break ; } adts_dmx_check_pid ( filter , <S2SV_EndBug> <S2SV_StartBug> ctx ) ; if ( ! ctx -> is_playing ) { ctx -> resume_from = 1 + ctx -> adts_buffer_size - remain ; return GF_OK ; } ctx -> nb_frames ++ ; size = ctx -> hdr . frame_size - ctx -> hdr . hdr_size ; offset = ctx -> hdr . hdr_size ; if ( ( nb_blocks_per_frame == 2 ) && ! ctx -> hdr . no_crc ) size -= 2 ; if ( ctx -> in_seek ) { u64 nb_samples_at_seek = ( u64 ) ( ctx -> start_range * GF_M4ASampleRates [ ctx -> sr_idx ] ) ; if ( ctx -> cts + ctx -> dts_inc >= nb_samples_at_seek ) { ctx -> in_seek = GF_FALSE ; } } bytes_to_drop = ctx -> hdr . frame_size ; if ( ctx -> timescale && ! prev_pck_size && ( cts != GF_FILTER_NO_TS ) ) { ctx -> cts = cts ; cts = GF_FILTER_NO_TS ; } if ( ! ctx -> in_seek ) { dst_pck = gf_filter_pck_new_alloc ( ctx -> opid , size , & output ) ; if ( ctx -> src_pck ) gf_filter_pck_merge_properties ( ctx -> src_pck , dst_pck ) ; memcpy ( output , sync + offset , size ) ; gf_filter_pck_set_dts ( dst_pck , ctx -> cts ) ; gf_filter_pck_set_cts ( dst_pck , ctx -> cts ) ; gf_filter_pck_set_duration ( dst_pck , ctx -> dts_inc ) ; gf_filter_pck_set_framing ( dst_pck , GF_TRUE , GF_TRUE ) ; gf_filter_pck_set_sap ( dst_pck , GF_FILTER_SAP_1 ) ; if ( ctx -> byte_offset != GF_FILTER_NO_BO ) { gf_filter_pck_set_byte_offset ( dst_pck , ctx -> byte_offset + ctx -> hdr . hdr_size ) ; } gf_filter_pck_send ( dst_pck ) ; } adts_dmx_update_cts ( ctx ) ; if ( bytes_to_drop > remain ) { GF_LOG ( GF_LOG_WARNING , GF_LOG_PARSER , ( "[ADTSDmx]<S2SV_blank>truncated<S2SV_blank>ADTS<S2SV_blank>frame!\\n" ) ) ; bytes_to_drop = remain ; } drop_byte : if ( ! bytes_to_drop ) { bytes_to_drop = 1 ; } start += bytes_to_drop ; remain -= bytes_to_drop ; if ( prev_pck_size ) { if ( prev_pck_size > bytes_to_drop ) prev_pck_size -= bytes_to_drop ; else { prev_pck_size = 0 ; if ( ctx -> src_pck ) gf_filter_pck_unref ( ctx -> src_pck ) ; ctx -> src_pck = pck ; if ( pck ) gf_filter_pck_ref_props ( & ctx -> src_pck ) ; } } if ( ctx -> byte_offset != GF_FILTER_NO_BO ) ctx -> byte_offset += bytes_to_drop ; } if ( ! pck ) { ctx -> adts_buffer_size = 0 ; return adts_dmx_process ( filter ) ; } else { if ( remain ) { memmove ( ctx -> adts_buffer , start , remain ) ; } ctx -> adts_buffer_size = remain ; gf_filter_pid_drop_packet ( ctx -> ipid ) ; } return GF_OK ; }
<S2SV_ModStart> break ; } if ( ctx -> hdr . frame_size < ctx -> hdr . hdr_size ) { GF_LOG ( GF_LOG_WARNING , GF_LOG_PARSER , ( "[ADTSDmx]<S2SV_blank>Corrupted<S2SV_blank>ADTS<S2SV_blank>frame<S2SV_blank>header,<S2SV_blank>resyncing\\n" ) ) ; ctx -> nb_frames = 0 ; goto drop_byte ; }
68
<S2SV_StartBug> CWE-119 void vp9_rc_update_rate_correction_factors ( VP9_COMP * cpi , int damp_var <S2SV_EndBug> ) { const VP9_COMMON * const cm = & cpi -> common ; int correction_factor = 100 ; double rate_correction_factor = get_rate_correction_factor ( cpi ) ; double adjustment_limit ; int projected_size_based_on_q = 0 ; vp9_clear_system_state ( <S2SV_StartBug> ) ; projected_size_based_on_q = estimate_bits_at_q ( cm <S2SV_EndBug> -> frame_type , cm -> base_qindex , cm <S2SV_StartBug> -> MBs , rate_correction_factor ) ; <S2SV_StartBug> if ( <S2SV_EndBug> <S2SV_EndBug> projected_size_based_on_q > 0 ) correction_factor = ( 100 * cpi -> rc . projected_frame_size ) / projected_size_based_on_q ; switch ( damp_var ) { case 0 : adjustment_limit = 0.75 ; break ; case 1 : adjustment_limit = 0.375 ; break ; case 2 : default : adjustment_limit = 0.25 ; break ; } if ( correction_factor > 102 ) { correction_factor = ( int ) ( 100 + ( ( correction_factor - 100 ) * adjustment_limit ) ) ; rate_correction_factor = ( rate_correction_factor * correction_factor ) / 100 ; if ( rate_correction_factor > MAX_BPB_FACTOR ) rate_correction_factor = MAX_BPB_FACTOR ; } else if ( correction_factor < 99 ) { correction_factor = ( int ) ( 100 - ( ( 100 - correction_factor ) * adjustment_limit ) ) ; rate_correction_factor = ( rate_correction_factor * correction_factor ) / 100 ; if ( rate_correction_factor < MIN_BPB_FACTOR ) rate_correction_factor = MIN_BPB_FACTOR ; } set_rate_correction_factor ( cpi , rate_correction_factor ) ; }
<S2SV_ModStart> VP9_COMP * cpi <S2SV_ModEnd> ) { const <S2SV_ModStart> = 0 ; if ( cpi -> rc . is_src_frame_alt_ref ) return ; vpx_clear_system_state ( ) ; if ( cpi -> oxcf . aq_mode == CYCLIC_REFRESH_AQ && cpi -> common . seg . enabled ) { projected_size_based_on_q = vp9_cyclic_refresh_estimate_bits_at_q ( cpi , rate_correction_factor ) ; } else { projected_size_based_on_q = vp9_estimate_bits_at_q ( cpi -> common . <S2SV_ModEnd> frame_type , cm <S2SV_ModStart> MBs , rate_correction_factor , cm -> bit_depth ) ; } <S2SV_ModEnd> if ( projected_size_based_on_q <S2SV_ModStart> ( projected_size_based_on_q > FRAME_OVERHEAD_BITS ) correction_factor = ( int ) ( ( 100 * ( int64_t ) cpi -> rc . projected_frame_size ) / projected_size_based_on_q ) ; adjustment_limit = 0.25 + 0.5 * MIN ( 1 , fabs ( log10 ( 0.01 * correction_factor ) ) ) ; cpi -> rc . q_2_frame = cpi -> rc . q_1_frame ; cpi -> rc . q_1_frame = cm -> base_qindex ; cpi -> rc . rc_2_frame = cpi -> rc . rc_1_frame ; if ( correction_factor > 110 ) cpi -> rc . rc_1_frame = - 1 ; else if ( correction_factor < 90 ) cpi -> rc . rc_1_frame = 1 ; else cpi -> rc . rc_1_frame = 0 ; <S2SV_ModEnd> if ( correction_factor
69
CWE-79 void interprete ( char * lbook , char * path ) { int status , i , j , n , message_id , inactive ; char list [ 1000 ] , section [ 256 ] , str [ NAME_LENGTH ] , str1 [ NAME_LENGTH ] , str2 [ NAME_LENGTH ] , edit_id [ 80 ] , file_name [ 256 ] , command [ 256 ] , enc_path [ 256 ] , dec_path [ 256 ] , uname [ 80 ] , full_name [ 256 ] , user_email [ 256 ] , logbook [ 256 ] , logbook_enc [ 256 ] , * experiment , group [ 256 ] , css [ 256 ] , * pfile , attachment [ MAX_PATH_LENGTH ] , str3 [ NAME_LENGTH ] , thumb_name [ 256 ] , sid [ 32 ] , error_str [ 256 ] , subdir [ 256 ] , * s ; LOGBOOK * lbs ; FILE * f ; strcpy ( dec_path , path ) ; url_decode ( dec_path ) ; strcpy ( enc_path , dec_path ) ; url_encode ( enc_path , sizeof ( enc_path ) ) ; strencode2 ( command , isparam ( "cmd" ) ? getparam ( "cmd" ) : "" , sizeof ( command ) ) ; strencode2 ( group , isparam ( "group" ) ? getparam ( "group" ) : "" , sizeof ( group ) ) ; experiment = getparam ( "exp" ) ; if ( getcfg ( lbook , "Logging<S2SV_blank>Level" , str , sizeof ( str ) ) ) _logging_level = atoi ( str ) ; else _logging_level = 2 ; set_condition ( "" ) ; message_id = atoi ( dec_path ) ; if ( isparam ( "jcmd" ) && * getparam ( "jcmd" ) ) strlcpy ( command , getparam ( "jcmd" ) , sizeof ( command ) ) ; if ( stricmp ( command , "loc" ) == 0 ) { show_http_header ( NULL , FALSE , NULL ) ; if ( isparam <S2SV_StartBug> ( "value" ) && * getparam <S2SV_EndBug> ( "value" <S2SV_StartBug> ) ) rsputs ( loc ( getparam ( "value" ) ) ) ; s = loc ( "Drop<S2SV_blank>attachments<S2SV_blank>here..." <S2SV_EndBug> ) ; s = loc ( "Insert<S2SV_blank>Timestamp" ) ; if ( s ) s = NULL ; return ; } if ( experiment && experiment [ 0 ] ) { strcpy ( logbook_enc , experiment ) ; strcpy ( logbook , experiment ) ; url_decode ( logbook ) ; for ( i = 0 ; ; i ++ ) { if ( ! enumgrp ( i , str ) ) break ; if ( strieq ( logbook , str ) ) break ; } if ( ! strieq ( logbook , str ) ) { sprintf ( str , "Error:<S2SV_blank>logbook<S2SV_blank>\\"%s\\"<S2SV_blank>not<S2SV_blank>defined<S2SV_blank>in<S2SV_blank>%s" , logbook_enc , CFGFILE ) ; show_error ( str ) ; return ; } } else { strcpy ( logbook_enc , lbook ) ; strcpy ( logbook , lbook ) ; url_decode ( logbook ) ; } setcfg_topgroup ( "" ) ; sprintf ( str , "Top<S2SV_blank>group<S2SV_blank>%s" , logbook ) ; if ( getcfg ( "global" , str , list , sizeof ( list ) ) ) { setcfg_topgroup ( logbook ) ; logbook [ 0 ] = 0 ; } for ( i = j = 0 ; ; i ++ ) { if ( ! enumgrp ( i , str ) ) break ; if ( is_logbook ( str ) ) { if ( ! strieq ( str , lb_list [ j ++ ] . name ) ) { el_index_logbooks ( ) ; break ; } } } if ( lb_list [ j ] . name [ 0 ] != 0 ) el_index_logbooks ( ) ; if ( ! logbook [ 0 ] ) { if ( getcfg ( group , "Self<S2SV_blank>register" , str , sizeof ( str ) ) && atoi ( str ) > 0 ) { if ( ! do_self_register ( NULL , getparam ( "cmd" ) ) ) return ; } if ( strieq ( command , loc ( "Activate" ) ) && isparam ( "new_user_name" ) && isparam ( "code" ) ) { if ( ! activate_user ( NULL , getparam ( "new_user_name" ) , atoi ( getparam ( "code" ) ) ) ) return ; setparam ( "cfg_user" , getparam ( "new_user_name" ) ) ; get_user_line ( NULL , getparam ( "new_user_name" ) , NULL , full_name , user_email , NULL , NULL , NULL ) ; sprintf ( str , "%s<S2SV_blank><b>&lt;%s&gt;</b>" , full_name , user_email ) ; sprintf ( str2 , loc ( "Activation<S2SV_blank>notice<S2SV_blank>has<S2SV_blank>been<S2SV_blank>sent<S2SV_blank>to<S2SV_blank>%s" ) , str ) ; setparam ( "notice" , str2 ) ; show_config_page ( NULL ) ; return ; } if ( strieq ( command , loc ( "Save" ) ) ) { if ( isparam ( "config" ) ) { if ( ! isparam ( "config" ) || ! save_user_config ( NULL , getparam ( "config" ) , FALSE ) ) return ; } redirect ( NULL , "." ) ; return ; } if ( isparam ( "cmd" ) || isparam ( "newpwd" ) ) { if ( isparam ( "newpwd" ) || strieq ( command , loc ( "Change<S2SV_blank>password" ) ) ) { if ( sid_check ( getparam ( "sid" ) , uname ) ) setparam ( "unm" , uname ) ; show_change_pwd_page ( NULL ) ; return ; } } if ( isparam ( "uname" ) && isparam ( "upassword" ) ) { strlcpy ( uname , getparam ( "uname" ) , sizeof ( uname ) ) ; sprintf ( str , "LOGIN<S2SV_blank>user<S2SV_blank>\\"%s\\"<S2SV_blank>(attempt)<S2SV_blank>for<S2SV_blank>logbook<S2SV_blank>selection<S2SV_blank>page" , uname ) ; write_logfile ( NULL , str ) ; if ( isparam ( "redir" ) ) strlcpy ( str , getparam ( "redir" ) , sizeof ( str ) ) ; else strlcpy ( str , isparam ( "cmdline" ) ? getparam ( "cmdline" ) : "" , sizeof ( str ) ) ; if ( ! auth_verify_password ( NULL , uname , getparam ( "upassword" ) , error_str , sizeof ( error_str ) ) ) { if ( error_str [ 0 ] ) show_error ( error_str ) ; else show_login_page ( NULL , str , 1 ) ; return ; } if ( get_user_line ( NULL , uname , NULL , full_name , NULL , NULL , NULL , NULL ) == 2 ) { if ( ! getcfg ( group , "Self<S2SV_blank>register" , str , sizeof ( str ) ) || atoi ( str ) == 0 ) { show_login_page ( NULL , str , 1 ) ; return ; } # ifdef HAVE_PAM getcfg ( NULL , "Authentication" , str , sizeof ( str ) ) ; if ( stristr ( str , "PAM" ) ) { show_new_user_page ( NULL , uname ) ; return ; } # endif } set_user_password ( NULL , uname , getparam ( "upassword" ) ) ; sprintf ( str , "LOGIN<S2SV_blank>user<S2SV_blank>\\"%s\\"<S2SV_blank>(success)" , uname ) ; write_logfile ( NULL , str ) ; sid_new ( NULL , uname , ( char * ) inet_ntoa ( rem_addr ) , sid ) ; set_sid_cookie ( NULL , sid , full_name ) ; return ; } if ( ! logbook [ 0 ] && getcfg ( "global" , "Selection<S2SV_blank>page" , str , sizeof ( str ) ) ) { if ( strstr ( str , "http://" ) || strstr ( str , "https://" ) ) { redirect ( NULL , str ) ; return ; } if ( str [ 0 ] == DIR_SEPARATOR || str [ 1 ] == ':' ) strlcpy ( file_name , str , sizeof ( file_name ) ) ; else { strlcpy ( file_name , logbook_dir , sizeof ( file_name ) ) ; strlcat ( file_name , str , sizeof ( file_name ) ) ; } send_file_direct ( file_name ) ; return ; } if ( strieq ( command , "Synchronize" ) ) { synchronize ( NULL , SYNC_HTML ) ; return ; } } for ( n = 0 ; lb_list [ n ] . name [ 0 ] ; n ++ ) ; if ( ! logbook [ 0 ] && ! path [ 0 ] ) { if ( n > 1 ) { if ( strieq ( command , loc ( "Forgot" ) ) ) { show_forgot_pwd_page ( NULL ) ; return ; } show_selection_page ( ) ; return ; } strcpy ( logbook , lb_list [ 0 ] . name ) ; strcpy ( logbook_enc , logbook ) ; url_encode ( logbook_enc , sizeof ( logbook_enc ) ) ; } for ( i = 0 ; lb_list [ i ] . name [ 0 ] ; i ++ ) if ( strieq ( logbook , lb_list [ i ] . name ) ) break ; lbs = & lb_list [ i ] ; if ( lbs -> top_group [ 0 ] ) setcfg_topgroup ( lbs -> top_group ) ; if ( getcfg ( logbook , "Theme" , str , sizeof ( str ) ) ) strlcpy ( theme_name , str , sizeof ( theme_name ) ) ; else strlcpy ( theme_name , "default" , sizeof ( theme_name ) ) ; lbs = lb_list + i ; lbs -> n_attr = scan_attributes ( lbs -> name ) ; if ( lbs -> n_attr < 0 ) return ; if ( isparam ( "acmd" ) && * getparam ( "acmd" ) ) { if ( strieq ( getparam ( "acmd" ) , "Upload" ) ) show_uploader_json ( lbs ) ; return ; } getcfg ( lbs -> name , "Authentication" , str , sizeof ( str ) ) ; if ( stristr ( str , "Webserver" ) ) { if ( http_user [ 0 ] ) { if ( ! sid_check ( getparam ( "sid" ) , http_user ) ) { sid_new ( lbs , http_user , ( char * ) inet_ntoa ( rem_addr ) , sid ) ; set_sid_cookie ( lbs , sid , http_user ) ; } } else { sprintf ( str , "Error:<S2SV_blank>Misconfigured<S2SV_blank>webserver,<S2SV_blank>did<S2SV_blank>not<S2SV_blank>get<S2SV_blank>X-Forwarded-User<S2SV_blank>from<S2SV_blank>it." ) ; show_error ( str ) ; return ; } } if ( isparam ( "uname" ) && isparam ( "upassword" ) ) { strlcpy ( uname , getparam ( "uname" ) , sizeof ( uname ) ) ; sprintf ( str , "LOGIN<S2SV_blank>user<S2SV_blank>\\"%s\\"<S2SV_blank>(attempt)" , uname ) ; write_logfile ( lbs , str ) ; if ( isparam ( "redir" ) ) strlcpy ( str , getparam ( "redir" ) , sizeof ( str ) ) ; else strlcpy ( str , isparam ( "cmdline" ) ? getparam ( "cmdline" ) : "" , sizeof ( str ) ) ; if ( ! auth_verify_password ( lbs , uname , getparam ( "upassword" ) , error_str , sizeof ( error_str ) ) ) { if ( error_str [ 0 ] ) show_error ( error_str ) ; else show_login_page ( lbs , str , 1 ) ; return ; } if ( get_user_line ( lbs , uname , NULL , full_name , NULL , NULL , NULL , & inactive ) == 2 ) { if ( ! getcfg ( lbs -> name , "Self<S2SV_blank>register" , str , sizeof ( str ) ) || atoi ( str ) == 0 ) { show_login_page ( lbs , str , 1 ) ; return ; } # ifdef HAVE_PAM getcfg ( lbs -> name , "Authentication" , str , sizeof ( str ) ) ; if ( stristr ( str , "PAM" ) ) { show_new_user_page ( lbs , uname ) ; return ; } # endif } if ( inactive ) { show_error ( "This<S2SV_blank>account<S2SV_blank>is<S2SV_blank>currently<S2SV_blank>deactivated" ) ; return ; } if ( ! check_login_user ( lbs , getparam ( "uname" ) ) ) { show_error ( "User<S2SV_blank>has<S2SV_blank>no<S2SV_blank>access<S2SV_blank>to<S2SV_blank>this<S2SV_blank>logbook" ) ; return ; } set_user_password ( lbs , uname , getparam ( "upassword" ) ) ; sprintf ( str , "LOGIN<S2SV_blank>user<S2SV_blank>\\"%s\\"<S2SV_blank>(success)" , uname ) ; write_logfile ( lbs , str ) ; sid_new ( lbs , uname , ( char * ) inet_ntoa ( rem_addr ) , sid ) ; set_sid_cookie ( lbs , sid , full_name ) ; return ; } if ( chkext ( path , ".gif" ) || chkext ( path , ".jpg" ) || chkext ( path , ".png" ) || chkext ( path , ".ico" ) || chkext ( path , ".htm" ) || chkext ( path , ".css" ) ) { strlcpy ( str , resource_dir , sizeof ( str ) ) ; strlcat ( str , path , sizeof ( str ) ) ; if ( exist_file ( str ) ) { send_file_direct ( str ) ; return ; } else { strlcpy ( str , resource_dir , sizeof ( str ) ) ; strlcat ( str , "themes" , sizeof ( str ) ) ; strlcat ( str , DIR_SEPARATOR_STR , sizeof ( str ) ) ; strlcat ( str , theme_name , sizeof ( str ) ) ; strlcat ( str , DIR_SEPARATOR_STR , sizeof ( str ) ) ; strlcat ( str , path , sizeof ( str ) ) ; if ( exist_file ( str ) ) { send_file_direct ( str ) ; return ; } } } if ( ! logbook [ 0 ] ) { strencode2 ( str2 , path , sizeof ( str2 ) ) ; sprintf ( str , "%s:<S2SV_blank><b>%s</b>" , loc ( "Invalid<S2SV_blank>URL" ) , str2 ) ; show_error ( str ) ; return ; } if ( strieq ( command , loc ( "Activate" ) ) && isparam ( "unm" ) && isparam ( "code" ) && ! isparam ( "new_user_name" ) ) { strlcpy ( uname , getparam ( "unm" ) , sizeof ( uname ) ) ; if ( ! activate_user ( lbs , uname , atoi ( getparam ( "code" ) ) ) ) return ; sprintf ( str , "ACTIVATE<S2SV_blank>user<S2SV_blank>\\"%s\\"<S2SV_blank>(success)" , uname ) ; write_logfile ( lbs , str ) ; sid_new ( lbs , uname , ( char * ) inet_ntoa ( rem_addr ) , sid ) ; sprintf ( str , "?cmd=%s&notice=%s.<S2SV_blank>%s" , loc ( "Config" ) , loc ( "Your<S2SV_blank>account<S2SV_blank>has<S2SV_blank>been<S2SV_blank>activated" ) , loc ( "Please<S2SV_blank>subscribe<S2SV_blank>to<S2SV_blank>logbooks<S2SV_blank>if<S2SV_blank>you<S2SV_blank>want<S2SV_blank>to<S2SV_blank>receive<S2SV_blank>automatic<S2SV_blank>email<S2SV_blank>notifications" ) ) ; setparam ( "redir" , str ) ; set_sid_cookie ( lbs , sid , uname ) ; return ; } # ifdef HAVE_PAM if ( strieq ( command , loc ( "Save" ) ) && isparam ( "new_user_name" ) && ! isparam ( "config" ) ) { save_user_config ( NULL , getparam ( "new_user_name" ) , 1 ) ; redirect ( lbs , "" ) ; check_login ( lbs , NULL ) ; return ; } # endif if ( getcfg ( lbs -> name , "Password<S2SV_blank>file" , str , sizeof ( str ) ) ) { strlcpy ( css , "elog.css" , sizeof ( css ) ) ; if ( lbs != NULL && getcfg ( lbs -> name , "CSS" , str , sizeof ( str ) ) ) strlcpy ( css , str , sizeof ( css ) ) ; else if ( lbs == NULL && getcfg ( "global" , "CSS" , str , sizeof ( str ) ) ) strlcpy ( css , str , sizeof ( css ) ) ; if ( getcfg ( lbs -> name , "Guest<S2SV_blank>menu<S2SV_blank>commands" , str , sizeof ( str ) ) ) { if ( sid_check ( getparam ( "sid" ) , uname ) ) setparam ( "unm" , uname ) ; } if ( uname [ 0 ] && ! isparam ( "new_user_name" ) ) { if ( ! set_user_login_time ( lbs , uname ) ) { show_error ( loc ( "File<S2SV_blank>system<S2SV_blank>full,<S2SV_blank>ELOG<S2SV_blank>cannot<S2SV_blank>continue<S2SV_blank>to<S2SV_blank>work" ) ) ; return ; } } if ( ! ( getcfg ( lbs -> name , "Guest<S2SV_blank>menu<S2SV_blank>commands" , str , sizeof ( str ) ) && ! isparam ( "fail" ) ) ) { if ( strcmp ( path , css ) != 0 ) { if ( getcfg ( lbs -> name , "Self<S2SV_blank>register" , str , sizeof ( str ) ) && atoi ( str ) > 0 ) { if ( ! do_self_register ( lbs , command ) ) return ; } if ( ! check_login ( lbs , getparam ( "sid" ) ) ) return ; } } } if ( strieq ( command , loc ( "Login" ) ) ) { check_login ( lbs , "" ) ; return ; } if ( strieq ( command , loc ( "New" ) ) || strieq ( command , loc ( "Edit" ) ) || strieq ( command , loc ( "Reply" ) ) || strieq ( command , loc ( "Duplicate" ) ) || strieq ( command , loc ( "Delete" ) ) || strieq ( command , loc ( "Upload" ) ) || strieq ( command , loc ( "Submit" ) ) || strieq ( command , loc ( "Preview" ) ) ) { sprintf ( str , "%s?cmd=%s" , path , command ) ; } if ( strieq ( command , loc ( "Delete" ) ) || strieq ( command , loc ( "Config" ) ) || strieq ( command , loc ( "Copy<S2SV_blank>to" ) ) || strieq ( command , loc ( "Move<S2SV_blank>to" ) ) ) { sprintf ( str , "%s?cmd=%s" , path , command ) ; } if ( strieq ( command , loc ( "Back" ) ) ) { if ( isparam ( "edit_id" ) ) { el_lock_message ( lbs , atoi ( getparam ( "edit_id" ) ) , NULL , FALSE ) ; el_draft_message ( lbs , atoi ( getparam ( "edit_id" ) ) , NULL , FALSE ) ; strlcpy ( edit_id , getparam ( "edit_id" ) , sizeof ( edit_id ) ) ; sprintf ( str , "../%s/%s" , logbook_enc , edit_id ) ; } else sprintf ( str , "../%s/" , logbook_enc ) ; if ( getcfg ( lbs -> name , "Back<S2SV_blank>to<S2SV_blank>main" , str , sizeof ( str ) ) && atoi ( str ) == 1 ) strcpy ( str , "../" ) ; redirect ( lbs , str ) ; return ; } if ( strieq ( command , "XDelete" ) ) { if ( getparam ( "edit_id" ) ) { status = el_delete_message ( lbs , atoi ( getparam ( "edit_id" ) ) , TRUE , NULL , TRUE , TRUE ) ; if ( status != EL_SUCCESS ) { sprintf ( str , "%s<S2SV_blank>=<S2SV_blank>%d" , loc ( "Error<S2SV_blank>deleting<S2SV_blank>message:<S2SV_blank>status" ) , status ) ; show_error ( str ) ; return ; } } redirect ( lbs , "" ) ; return ; } if ( strieq ( command , "Unlock" ) ) { if ( isparam ( "edit_id" ) ) { el_lock_message ( lbs , atoi ( getparam ( "edit_id" ) ) , NULL , FALSE ) ; strlcpy ( edit_id , getparam ( "edit_id" ) , sizeof ( edit_id ) ) ; sprintf ( str , "../%s/%s" , logbook_enc , edit_id ) ; } else sprintf ( str , "../%s/" , logbook_enc ) ; if ( getcfg ( lbs -> name , "Back<S2SV_blank>to<S2SV_blank>main" , str , sizeof ( str ) ) && atoi ( str ) == 1 ) strcpy ( str , "../" ) ; redirect ( lbs , str ) ; return ; } if ( strieq ( command , loc ( "List" ) ) ) { if ( getcfg ( lbs -> name , "Back<S2SV_blank>to<S2SV_blank>main" , str , sizeof ( str ) ) && atoi ( str ) == 1 ) { redirect ( lbs , "../" ) ; return ; } show_elog_list ( lbs , 0 , 0 , 0 , TRUE , NULL ) ; return ; } if ( strieq ( command , loc ( "Cancel" ) ) ) { sprintf ( str , "../%s/%s" , logbook_enc , path ) ; redirect ( lbs , str ) ; return ; } strlcpy ( str , isparam ( "last" ) ? getparam ( "last" ) : "" , sizeof ( str ) ) ; if ( strchr ( str , '<S2SV_blank>' ) ) { i = atoi ( strchr ( str , '<S2SV_blank>' ) ) ; sprintf ( str , "last%d" , i ) ; if ( isparam ( "mode" ) ) { sprintf ( str + strlen ( str ) , "?mode=" ) ; strlcat ( str , getparam ( "mode" ) , sizeof ( str ) ) ; } redirect ( lbs , str ) ; return ; } strlcpy ( str , isparam ( "past" ) ? getparam ( "past" ) : "" , sizeof ( str ) ) ; if ( strchr ( str , '<S2SV_blank>' ) ) { i = atoi ( strchr ( str , '<S2SV_blank>' ) ) ; sprintf ( str , "past%d" , i ) ; redirect ( lbs , str ) ; return ; } if ( strncmp ( path , "past" , 4 ) == 0 && ( isdigit ( path [ 4 ] ) || isdigit ( path [ 5 ] ) ) && isparam ( "cmd" ) == 0 ) { show_elog_list ( lbs , atoi ( path + 4 ) , 0 , 0 , FALSE , NULL ) ; return ; } if ( strncmp ( path , "last" , 4 ) == 0 && ! chkext ( path , ".png" ) && ( ! isparam ( "cmd" ) || strieq ( getparam ( "cmd" ) , loc ( "Select" ) ) ) && ! isparam ( "newpwd" ) && atoi ( path + 4 ) > 0 ) { show_elog_list ( lbs , 0 , atoi ( path + 4 ) , 0 , FALSE , NULL ) ; return ; } if ( strncmp ( path , "page" , 4 ) == 0 && isparam ( "cmd" ) == 0 ) { if ( ! path [ 4 ] ) show_elog_list ( lbs , 0 , 0 , - 1 , FALSE , NULL ) ; else show_elog_list ( lbs , 0 , 0 , atoi ( path + 4 ) , FALSE , NULL ) ; return ; } if ( strieq ( dec_path , "cal.html" ) ) { show_calendar ( lbs ) ; return ; } if ( strieq ( dec_path , "elog.rdf" ) ) { show_rss_feed ( lbs ) ; return ; } if ( strieq ( dec_path , "upload.html" ) ) { show_uploader ( lbs ) ; return ; } if ( isparam ( "jcmd" ) && isparam ( "jcmd" ) && strieq ( getparam ( "jcmd" ) , "JUpload" ) ) { show_uploader_finished ( lbs ) ; return ; } pfile = dec_path ; if ( strchr ( pfile , '/' ) && pfile [ 13 ] != '/' && isdigit ( pfile [ 0 ] ) ) pfile = strchr ( pfile , '/' ) + 1 ; if ( ( strlen ( pfile ) > 13 && pfile [ 6 ] == '_' && pfile [ 13 ] == '_' ) || ( strlen ( pfile ) > 13 && pfile [ 6 ] == '_' && pfile [ 13 ] == '/' ) || chkext ( pfile , ".gif" ) || chkext ( pfile , ".ico" ) || chkext ( pfile , ".jpg" ) || chkext ( pfile , ".jpeg" ) || chkext ( pfile , ".png" ) || chkext ( pfile , ".css" ) || chkext ( pfile , ".js" ) || chkext ( pfile , ".html" ) ) { if ( ( strlen ( pfile ) > 13 && pfile [ 6 ] == '_' && pfile [ 13 ] == '_' ) || ( strlen ( pfile ) > 13 && pfile [ 6 ] == '_' && pfile [ 13 ] == '/' ) ) { if ( pfile [ 13 ] == '/' ) pfile [ 13 ] = '_' ; strlcpy ( file_name , lbs -> data_dir , sizeof ( file_name ) ) ; generate_subdir_name ( pfile , subdir , sizeof ( subdir ) ) ; strlcat ( file_name , subdir , sizeof ( file_name ) ) ; strlcat ( file_name , pfile , sizeof ( file_name ) ) ; } else { strlcpy ( file_name , resource_dir , sizeof ( file_name ) ) ; if ( file_name [ 0 ] && file_name [ strlen ( file_name ) - 1 ] != DIR_SEPARATOR ) strlcat ( file_name , DIR_SEPARATOR_STR , sizeof ( file_name ) ) ; strlcat ( file_name , "themes" , sizeof ( file_name ) ) ; strlcat ( file_name , DIR_SEPARATOR_STR , sizeof ( file_name ) ) ; if ( theme_name [ 0 ] ) { strlcat ( file_name , theme_name , sizeof ( file_name ) ) ; strlcat ( file_name , DIR_SEPARATOR_STR , sizeof ( file_name ) ) ; } strlcat ( file_name , pfile , sizeof ( file_name ) ) ; } if ( isparam ( "thumb" ) ) { get_thumb_name ( file_name , thumb_name , sizeof ( thumb_name ) , 0 ) ; if ( thumb_name [ 0 ] ) send_file_direct ( thumb_name ) ; else send_file_direct ( file_name ) ; } else send_file_direct ( file_name ) ; return ; } if ( ! logbook [ 0 ] ) { show_selection_page ( ) ; return ; } if ( strchr ( dec_path , '/' ) ) { message_id = atoi ( dec_path ) ; n = atoi ( strchr ( dec_path , '/' ) + 1 ) - 1 ; status = el_retrieve_attachment ( lbs , message_id , n , attachment ) ; if ( status != EL_SUCCESS || n >= MAX_ATTACHMENTS ) { sprintf ( str , "Attachment<S2SV_blank>#%d<S2SV_blank>of<S2SV_blank>entry<S2SV_blank>#%d<S2SV_blank>not<S2SV_blank>found" , n + 1 , message_id ) ; show_error ( str ) ; } else { if ( isparam ( "thumb" ) ) strlcat ( attachment , "?thumb=1" , sizeof ( attachment ) ) ; redirect ( lbs , attachment ) ; } return ; } if ( getcfg ( lbs -> name , "Types" , str , sizeof ( str ) ) ) { show_upgrade_page ( lbs ) ; return ; } if ( isparam ( "cmd_first.x" ) ) strcpy ( command , loc ( "First" ) ) ; if ( isparam ( "cmd_previous.x" ) ) strcpy ( command , loc ( "Previous" ) ) ; if ( isparam ( "cmd_next.x" ) ) strcpy ( command , loc ( "Next" ) ) ; if ( isparam ( "cmd_last.x" ) ) strcpy ( command , loc ( "Last" ) ) ; if ( command [ 0 ] && ! is_user_allowed ( lbs , command ) ) { if ( isparam ( "uname" ) ) get_full_name ( lbs , getparam ( "uname" ) , full_name ) ; else full_name [ 0 ] = 0 ; strencode2 ( str2 , command , sizeof ( str2 ) ) ; strencode2 ( str3 , full_name , sizeof ( str3 ) ) ; sprintf ( str , loc ( "Error:<S2SV_blank>Command<S2SV_blank>\\"<b>%s</b>\\"<S2SV_blank>is<S2SV_blank>not<S2SV_blank>allowed<S2SV_blank>for<S2SV_blank>user<S2SV_blank>\\"<b>%s</b>\\"" ) , str2 , str3 ) ; show_error ( str ) ; return ; } if ( ! is_command_allowed ( lbs , command , message_id ) ) { if ( strieq ( command , loc ( "New" ) ) && ! isparam ( "unm" ) ) { show_login_page ( lbs , _cmdline , 0 ) ; return ; } strencode2 ( str2 , command , sizeof ( str3 ) ) ; sprintf ( str , loc ( "Error:<S2SV_blank>Command<S2SV_blank>\\"<b>%s</b>\\"<S2SV_blank>not<S2SV_blank>allowed" ) , str2 ) ; show_error ( str ) ; return ; } if ( strieq ( command , loc ( "Help" ) ) ) { if ( getcfg ( lbs -> name , "Help<S2SV_blank>URL" , str , sizeof ( str ) ) ) { if ( strstr ( str , "http://" ) || strstr ( str , "https://" ) ) { redirect ( lbs , str ) ; return ; } strlcpy ( file_name , resource_dir , sizeof ( file_name ) ) ; strlcat ( file_name , "resources" , sizeof ( file_name ) ) ; strlcat ( file_name , DIR_SEPARATOR_STR , sizeof ( file_name ) ) ; strlcat ( file_name , str , sizeof ( file_name ) ) ; f = fopen ( file_name , "r" ) ; if ( f == NULL ) { sprintf ( str , "Cannot<S2SV_blank>find<S2SV_blank>file<S2SV_blank>\\"%s\\"" , file_name ) ; show_error ( str ) ; } else { fclose ( f ) ; send_file_direct ( file_name ) ; } return ; } strlcpy ( file_name , resource_dir , sizeof ( file_name ) ) ; strlcat ( file_name , "resources" , sizeof ( file_name ) ) ; strlcat ( file_name , DIR_SEPARATOR_STR , sizeof ( file_name ) ) ; strlcat ( file_name , "eloghelp_" , sizeof ( file_name ) ) ; if ( getcfg ( "global" , "Language" , str , sizeof ( str ) ) ) { for ( i = 0 ; i < ( int ) strlen ( str ) ; i ++ ) str [ i ] = my_tolower ( str [ i ] ) ; strlcat ( file_name , str , sizeof ( file_name ) ) ; } else strlcat ( file_name , "english" , sizeof ( file_name ) ) ; strlcat ( file_name , ".html" , sizeof ( file_name ) ) ; f = fopen ( file_name , "r" ) ; if ( f == NULL ) redirect ( lbs , "https://elog.psi.ch/elog/eloghelp_english.html" ) ; else { fclose ( f ) ; send_file_direct ( file_name ) ; } return ; } if ( strieq ( command , loc ( "HelpELCode" ) ) ) { strlcpy ( file_name , resource_dir , sizeof ( file_name ) ) ; strlcat ( file_name , "resources" , sizeof ( file_name ) ) ; strlcat ( file_name , DIR_SEPARATOR_STR , sizeof ( file_name ) ) ; strlcat ( file_name , "elcode_" , sizeof ( file_name ) ) ; if ( getcfg ( "global" , "Language" , str , sizeof ( str ) ) ) { for ( i = 0 ; i < ( int ) strlen ( str ) ; i ++ ) str [ i ] = my_tolower ( str [ i ] ) ; strlcat ( file_name , str , sizeof ( file_name ) ) ; } else strlcat ( file_name , "english" , sizeof ( file_name ) ) ; strlcat ( file_name , ".html" , sizeof ( file_name ) ) ; f = fopen ( file_name , "r" ) ; if ( f == NULL ) redirect ( lbs , "https://elog.psi.ch/elog/elcode_english.html" ) ; else { fclose ( f ) ; send_file_direct ( file_name ) ; } return ; } if ( strieq ( command , loc ( "New" ) ) ) { if ( check_drafts ( lbs ) ) return ; show_edit_form ( lbs , 0 , FALSE , FALSE , FALSE , FALSE , FALSE , FALSE ) ; return ; } for ( i = 0 ; i < MAX_ATTACHMENTS ; i ++ ) { sprintf ( str , "delatt%d" , i ) ; if ( isparam ( str ) || ( isparam ( "smcmd" ) && stricmp ( getparam ( "smcmd" ) , str ) == 0 ) ) { sprintf ( str , "attachment%d" , i ) ; strlcpy ( file_name , getparam ( str ) , sizeof ( file_name ) ) ; el_delete_attachment ( lbs , file_name ) ; for ( j = i ; j < MAX_ATTACHMENTS ; j ++ ) { sprintf ( str , "attachment%d" , j + 1 ) ; if ( isparam ( str ) ) strlcpy ( file_name , getparam ( str ) , sizeof ( file_name ) ) ; else file_name [ 0 ] = 0 ; sprintf ( str , "attachment%d" , j ) ; if ( file_name [ 0 ] ) setparam ( str , file_name ) ; else unsetparam ( str ) ; } show_edit_form ( lbs , isparam ( "edit_id" ) ? atoi ( getparam ( "edit_id" ) ) : 0 , FALSE , TRUE , TRUE , FALSE , FALSE , FALSE ) ; return ; } } if ( strieq ( command , loc ( "Upload" ) ) || strieq ( command , "Upload" ) ) { show_edit_form ( lbs , isparam ( "edit_id" ) ? atoi ( getparam ( "edit_id" ) ) : 0 , FALSE , TRUE , TRUE , FALSE , FALSE , FALSE ) ; return ; } if ( strieq ( command , loc ( "Edit" ) ) ) { if ( message_id ) { show_edit_form ( lbs , message_id , FALSE , TRUE , FALSE , FALSE , FALSE , FALSE ) ; return ; } else if ( isparam ( "nsel" ) ) { show_edit_form ( lbs , 0 , FALSE , TRUE , FALSE , FALSE , FALSE , FALSE ) ; return ; } } if ( strieq ( command , loc ( "Reply" ) ) ) { show_edit_form ( lbs , message_id , TRUE , FALSE , FALSE , FALSE , FALSE , FALSE ) ; return ; } if ( strieq ( command , loc ( "Update" ) ) ) { show_edit_form ( lbs , isparam ( "edit_id" ) ? atoi ( getparam ( "edit_id" ) ) : 0 , FALSE , TRUE , FALSE , TRUE , FALSE , FALSE ) ; return ; } if ( ( strieq ( command , loc ( "Save" ) ) || strieq ( command , "Save" ) ) && ! isparam ( "cfgpage" ) && ! isparam ( "new_user_name" ) ) { if ( isparam ( "unm" ) ) strlcpy ( str , getparam ( "unm" ) , sizeof ( str ) ) ; else strlcpy ( str , loc ( "user" ) , sizeof ( str ) ) ; setparam ( "draft" , str ) ; submit_elog ( lbs ) ; return ; } if ( strieq ( command , loc ( "Duplicate" ) ) ) { if ( message_id ) { show_edit_form ( lbs , message_id , FALSE , FALSE , FALSE , FALSE , TRUE , FALSE ) ; return ; } } if ( strieq ( command , loc ( "Preview" ) ) ) { show_edit_form ( lbs , isparam ( "edit_id" ) ? atoi ( getparam ( "edit_id" ) ) : 0 , FALSE , TRUE , FALSE , TRUE , FALSE , TRUE ) ; return ; } if ( strieq ( command , loc ( "Submit" ) ) || strieq ( command , "Submit" ) ) { if ( isparam ( "mirror_id" ) ) submit_elog_mirror ( lbs ) ; else submit_elog ( lbs ) ; if ( isparam ( "sidclose" ) ) sid_remove ( getparam ( "sid" ) ) ; return ; } if ( strieq ( command , loc ( "Find" ) ) ) { if ( dec_path [ 0 ] ) { sprintf ( str , "../%s/?cmd=%s" , lbs -> name_enc , loc ( "Find" ) ) ; redirect ( lbs , str ) ; return ; } show_find_form ( lbs ) ; return ; } if ( strieq ( command , loc ( "Search" ) ) ) { if ( dec_path [ 0 ] && atoi ( dec_path ) == 0 && strchr ( dec_path , '/' ) != NULL ) { strencode2 ( str2 , dec_path , sizeof ( str2 ) ) ; sprintf ( str , "%s:<S2SV_blank><b>%s</b>" , loc ( "Invalid<S2SV_blank>URL" ) , str2 ) ; show_error ( str ) ; return ; } show_elog_list ( lbs , 0 , 0 , 0 , TRUE , NULL ) ; return ; } if ( strieq ( command , loc ( "Last<S2SV_blank>day" ) ) ) { redirect ( lbs , "past1" ) ; return ; } if ( strieq ( command , loc ( "Last<S2SV_blank>10" ) ) ) { redirect ( lbs , "last10" ) ; return ; } if ( strieq ( command , loc ( "Copy<S2SV_blank>to" ) ) ) { copy_to ( lbs , message_id , isparam ( "destc" ) ? getparam ( "destc" ) : "" , 0 , 0 ) ; return ; } if ( strieq ( command , loc ( "Move<S2SV_blank>to" ) ) ) { copy_to ( lbs , message_id , isparam ( "destm" ) ? getparam ( "destm" ) : "" , 1 , 0 ) ; return ; } if ( strieq ( command , loc ( "Admin" ) ) || strieq ( command , loc ( "Change<S2SV_blank>config<S2SV_blank>file" ) ) ) { show_admin_page ( lbs , NULL ) ; return ; } sprintf ( str , loc ( "Change<S2SV_blank>%s" ) , "[global]" ) ; if ( strieq ( command , str ) ) { show_admin_page ( lbs , "global" ) ; return ; } sprintf ( str2 , "[global<S2SV_blank>%s]" , lbs -> top_group ) ; sprintf ( str , loc ( "Change<S2SV_blank>%s" ) , str2 ) ; if ( strieq ( command , str ) ) { show_admin_page ( lbs , lbs -> top_group ) ; return ; } if ( strieq ( command , loc ( "Delete<S2SV_blank>this<S2SV_blank>logbook" ) ) ) { show_logbook_delete ( lbs ) ; return ; } if ( strieq ( command , loc ( "Rename<S2SV_blank>this<S2SV_blank>logbook" ) ) ) { show_logbook_rename ( lbs ) ; return ; } if ( strieq ( command , loc ( "Create<S2SV_blank>new<S2SV_blank>logbook" ) ) ) { if ( isparam ( "tmp" ) && strieq ( getparam ( "tmp" ) , "Cancel" ) ) { if ( getcfg ( lbs -> name , "Password<S2SV_blank>file" , str , sizeof ( str ) ) ) sprintf ( str , "?cmd=%s" , loc ( "Change<S2SV_blank>config<S2SV_blank>file" ) ) ; else sprintf ( str , "?cmd=%s" , loc ( "Config" ) ) ; redirect ( lbs , str ) ; return ; } show_logbook_new ( lbs ) ; return ; } if ( strieq ( command , "GetPwdFile" ) ) { char allow [ 256 ] ; allow [ 0 ] = 0 ; getcfg ( "global" , "Allow<S2SV_blank>clone" , allow , sizeof ( allow ) ) ; if ( atoi ( allow ) == 1 ) { if ( get_password_file ( lbs , file_name , sizeof ( file_name ) ) ) send_file_direct ( file_name ) ; } else { show_http_header ( NULL , FALSE , NULL ) ; rsputs ( loc ( "Cloning<S2SV_blank>not<S2SV_blank>allowed.<S2SV_blank>Set<S2SV_blank>\\"Allow<S2SV_blank>clone<S2SV_blank>=<S2SV_blank>1\\"<S2SV_blank>to<S2SV_blank>enable<S2SV_blank>cloning." ) ) ; rsputs ( "\\r\\n" ) ; return ; } return ; } if ( strieq ( command , loc ( "Change<S2SV_blank>password" ) ) || ( isparam ( "newpwd" ) && ! strieq ( command , loc ( "Cancel" ) ) && ! strieq ( command , loc ( "Save" ) ) ) ) { show_change_pwd_page ( lbs ) ; return ; } if ( strieq ( command , loc ( "Save" ) ) && ( isparam ( "cfgpage" ) || isparam ( "new_user_name" ) ) ) { if ( isparam ( "config" ) && isparam ( "new_user_name" ) ) { if ( ! strieq ( getparam ( "config" ) , getparam ( "new_user_name" ) ) ) { if ( get_user_line ( lbs , getparam ( "new_user_name" ) , NULL , NULL , NULL , NULL , NULL , NULL ) == 1 ) { sprintf ( str , "%s<S2SV_blank>\\"%s\\"<S2SV_blank>%s" , loc ( "Login<S2SV_blank>name" ) , getparam ( "new_user_name" ) , loc ( "exists<S2SV_blank>already" ) ) ; show_error ( str ) ; return ; } } if ( ! save_user_config ( lbs , isparam ( "config" ) ? getparam ( "config" ) : "" , FALSE ) ) return ; redirect ( lbs , "" ) ; return ; } else if ( isparam ( "new_user_name" ) ) { if ( ! save_user_config ( lbs , getparam ( "new_user_name" ) , TRUE ) ) return ; } else { if ( isparam ( "global" ) ) { if ( strieq ( getparam ( "global" ) , "global" ) ) strcpy ( section , "global" ) ; else { sprintf ( section , "global<S2SV_blank>" ) ; strlcat ( section , getparam ( "global" ) , sizeof ( section ) ) ; } } else strlcpy ( section , lbs -> name , sizeof ( section ) ) ; if ( ! save_admin_config ( section , _mtext , str ) ) { show_error ( str ) ; return ; } } if ( lbs ) sprintf ( str , "../%s/" , lbs -> name_enc ) ; else sprintf ( str , "." ) ; if ( isparam ( "new_user_name" ) ) { sprintf ( str + strlen ( str ) , "?cmd=%s&cfg_user=" , loc ( "Config" ) ) ; strlcat ( str , getparam ( "new_user_name" ) , sizeof ( str ) ) ; } else if ( isparam ( "cfg_user" ) ) { sprintf ( str + strlen ( str ) , "?cmd=%s&cfg_user=" , loc ( "Config" ) ) ; strlcat ( str , getparam ( "cfg_user" ) , sizeof ( str ) ) ; } else if ( getcfg ( lbs -> name , "password<S2SV_blank>file" , str2 , sizeof ( str2 ) ) ) sprintf ( str + strlen ( str ) , "?cmd=%s" , loc ( "Config" ) ) ; redirect ( lbs , str ) ; return ; } if ( strieq ( command , loc ( "Activate" ) ) && isparam ( "new_user_name" ) && isparam ( "code" ) ) { if ( ! activate_user ( lbs , getparam ( "new_user_name" ) , atoi ( getparam ( "code" ) ) ) ) return ; setparam ( "cfg_user" , getparam ( "new_user_name" ) ) ; get_user_line ( lbs , getparam ( "new_user_name" ) , NULL , full_name , user_email , NULL , NULL , NULL ) ; sprintf ( str , "%s<S2SV_blank><b>&lt;%s&gt;</b>" , full_name , user_email ) ; sprintf ( str2 , loc ( "Activation<S2SV_blank>notice<S2SV_blank>has<S2SV_blank>been<S2SV_blank>sent<S2SV_blank>to<S2SV_blank>%s" ) , str ) ; setparam ( "notice" , str2 ) ; show_config_page ( lbs ) ; return ; } if ( strieq ( command , loc ( "Remove<S2SV_blank>user" ) ) && isparam ( "config" ) ) { if ( ! remove_user ( lbs , getparam ( "config" ) ) ) return ; if ( isparam ( "unm" ) && strieq ( getparam ( "config" ) , getparam ( "unm" ) ) ) { write_logfile ( lbs , "LOGOUT" ) ; sid_remove ( getparam ( "sid" ) ) ; set_sid_cookie ( lbs , "" , "" ) ; } unsetparam ( "cfg_user" ) ; show_config_page ( lbs ) ; return ; } if ( strieq ( command , loc ( "New<S2SV_blank>user" ) ) ) { show_new_user_page ( lbs , NULL ) ; return ; } if ( strieq ( command , loc ( "Forgot" ) ) ) { show_forgot_pwd_page ( lbs ) ; return ; } if ( strieq ( command , loc ( "Config" ) ) ) { if ( ! getcfg ( lbs -> name , "Password<S2SV_blank>file" , str , sizeof ( str ) ) ) show_admin_page ( lbs , NULL ) ; else show_config_page ( lbs ) ; return ; } if ( strieq ( command , loc ( "Download" ) ) || strieq ( command , "Download" ) ) { show_download_page ( lbs , dec_path ) ; return ; } if ( strieq ( command , loc ( "Import" ) ) ) { strcpy ( str , loc ( "CSV<S2SV_blank>Import" ) ) ; url_encode ( str , sizeof ( str ) ) ; sprintf ( str1 , "?cmd=%s" , str ) ; strcpy ( str , loc ( "XML<S2SV_blank>Import" ) ) ; url_encode ( str , sizeof ( str ) ) ; sprintf ( str2 , "?cmd=%s" , str ) ; show_query ( lbs , loc ( "ELOG<S2SV_blank>import" ) , loc ( "Please<S2SV_blank>choose<S2SV_blank>format<S2SV_blank>to<S2SV_blank>import:" ) , "CSV" , str1 , "XML" , str2 ) ; return ; } if ( strieq ( command , loc ( "CSV<S2SV_blank>Import" ) ) ) { show_import_page_csv ( lbs ) ; return ; } if ( strieq ( command , loc ( "XML<S2SV_blank>Import" ) ) ) { show_import_page_xml ( lbs ) ; return ; } if ( strieq ( command , "getmd5" ) ) { show_md5_page ( lbs ) ; return ; } if ( strieq ( command , loc ( "Synchronize" ) ) ) { synchronize ( lbs , SYNC_HTML ) ; return ; } if ( strieq ( command , loc ( "Logout" ) ) ) { write_logfile ( lbs , "LOGOUT" ) ; if ( getcfg ( lbs -> name , "Logout<S2SV_blank>to<S2SV_blank>main" , str , sizeof ( str ) ) && atoi ( str ) == 1 ) { sprintf ( str , "../" ) ; setparam ( "redir" , str ) ; } else { if ( getcfg ( lbs -> name , "Logout<S2SV_blank>to<S2SV_blank>URL" , str , sizeof ( str ) ) ) setparam ( "redir" , str ) ; } set_sid_cookie ( lbs , "" , "" ) ; sid_remove ( getparam ( "sid" ) ) ; return ; } if ( strieq ( command , loc ( "Delete" ) ) ) { show_elog_delete ( lbs , message_id ) ; return ; } if ( strieq ( command , "IM" ) ) { call_image_magick ( lbs ) ; return ; } if ( ! _cmdline [ 0 ] && getcfg ( lbs -> name , "Welcome<S2SV_blank>page" , str , sizeof ( str ) ) && str [ 0 ] ) { if ( str [ 0 ] == DIR_SEPARATOR || str [ 1 ] == ':' ) strcpy ( file_name , str ) ; else { strlcpy ( file_name , resource_dir , sizeof ( file_name ) ) ; strlcat ( file_name , str , sizeof ( file_name ) ) ; } send_file_direct ( file_name ) ; return ; } if ( ! _cmdline [ 0 ] && getcfg ( lbs -> name , "Start<S2SV_blank>page" , str , sizeof ( str ) ) && str [ 0 ] ) { redirect ( lbs , str ) ; return ; } if ( dec_path [ 0 ] == 0 ) show_elog_list ( lbs , 0 , 0 , 0 , TRUE , NULL ) ; else show_elog_entry ( lbs , dec_path , command ) ; return ; }
<S2SV_ModStart> "value" ) ) { strencode2 ( str , getparam ( "value" ) , sizeof ( str ) ) ; <S2SV_ModStart> ( loc ( str ) ) ; } <S2SV_ModEnd> s = loc
70
CWE-119 static int header_gets ( SF_PRIVATE * psf , char * ptr , int bufsize ) { int k ; for <S2SV_StartBug> ( k = 0 ; k < bufsize - 1 ; k ++ <S2SV_StartBug> <S2SV_EndBug> ) { if ( psf -> headindex < psf -> <S2SV_EndBug> headend ) { ptr [ k ] = psf -> header [ psf -> headindex ] ; psf -> headindex ++ ; } else { psf -> headend += <S2SV_StartBug> psf_fread ( psf -> header + psf -> headend , 1 , 1 , psf ) <S2SV_StartBug> <S2SV_EndBug> ; ptr [ k ] = psf -> header [ psf <S2SV_EndBug> -> headindex ] ; psf -> headindex = psf -> headend ; } ; if ( ptr [ k ] == '\\n' ) break ; } ; ptr [ k ] = 0 ; return k ; }
<S2SV_ModStart> int k ; if ( psf -> header . indx + bufsize >= psf -> header . len && psf_bump_header_allocation ( psf , bufsize ) ) return 0 ; <S2SV_ModStart> ( psf -> header . indx <S2SV_ModEnd> < psf -> <S2SV_ModStart> < psf -> header . end ) { ptr [ k ] = psf -> header . ptr [ psf -> header . indx ] ; psf -> header . indx <S2SV_ModEnd> ++ ; } <S2SV_ModStart> { psf -> header . end <S2SV_ModEnd> += psf_fread ( <S2SV_ModStart> psf -> header . ptr <S2SV_ModStart> + psf -> header . end <S2SV_ModEnd> , 1 , <S2SV_ModStart> psf -> header . ptr [ psf -> header . indx ] ; psf -> header . indx = psf -> header . end <S2SV_ModEnd> ; } ;
71
CWE-78 static int compile_search ( struct Context * ctx , const struct Pattern * pat , struct Buffer * buf ) { if ( do_search ( pat , 0 ) == 0 ) return 0 ; if ( pat -> not ) mutt_buffer_addstr ( buf , "NOT<S2SV_blank>" ) ; if ( pat -> child ) { int clauses ; clauses = do_search ( pat -> child , 1 ) ; if ( clauses > 0 ) { const struct Pattern * clause = pat -> child ; mutt_buffer_addch ( buf , '(' ) ; while ( clauses ) { if ( do_search ( clause , 0 ) ) { if ( pat -> op == MUTT_OR && clauses > 1 ) mutt_buffer_addstr ( buf , "OR<S2SV_blank>" ) ; clauses -- ; if ( compile_search ( ctx , clause , buf ) < 0 ) return - 1 ; if ( clauses ) mutt_buffer_addch ( buf , '<S2SV_blank>' ) ; } clause = clause -> next ; } mutt_buffer_addch ( buf , ')' ) ; } } else { char term [ STRING ] ; char * delim = NULL ; switch ( pat -> op ) { case MUTT_HEADER : mutt_buffer_addstr ( buf , "HEADER<S2SV_blank>" ) ; delim = strchr ( pat -> p . str , ':' ) ; if ( ! delim ) { mutt_error ( _ ( "Header<S2SV_blank>search<S2SV_blank>without<S2SV_blank>header<S2SV_blank>name:<S2SV_blank>%s" ) , pat -> p . str ) ; return - 1 ; } * delim = <S2SV_StartBug> '\\0' ; imap_quote_string ( term , sizeof ( term ) , pat -> p . str ) ; mutt_buffer_addstr ( buf , <S2SV_EndBug> term ) ; mutt_buffer_addch ( buf , '<S2SV_blank>' ) ; * delim = ':' ; delim ++ ; SKIPWS ( delim ) ; <S2SV_StartBug> imap_quote_string ( term , sizeof ( term ) , delim ) ; mutt_buffer_addstr <S2SV_EndBug> ( buf , term ) ; break ; case MUTT_BODY : mutt_buffer_addstr ( buf , "BODY<S2SV_blank>" ) ; imap_quote_string ( term <S2SV_StartBug> , sizeof ( term ) , pat -> <S2SV_EndBug> p . str ) ; mutt_buffer_addstr ( buf , term ) ; break ; case MUTT_WHOLE_MSG : mutt_buffer_addstr ( buf , "TEXT<S2SV_blank>" ) <S2SV_StartBug> ; imap_quote_string ( term , sizeof ( term ) , pat -> p <S2SV_EndBug> . str ) ; mutt_buffer_addstr ( buf , term ) ; break ; case MUTT_SERVERSEARCH : { struct ImapData * idata = ctx -> data ; if ( ! mutt_bit_isset ( idata -> capabilities , X_GM_EXT1 ) ) { mutt_error ( _ ( "Server-side<S2SV_blank>custom<S2SV_blank>search<S2SV_blank>not<S2SV_blank>supported:<S2SV_blank>%s" ) , pat -> p . str ) ; return - 1 ; } } mutt_buffer_addstr ( <S2SV_StartBug> buf , "X-GM-RAW<S2SV_blank>" ) ; imap_quote_string ( term , sizeof ( term ) , pat -> p . str ) ; mutt_buffer_addstr <S2SV_EndBug> ( buf , term ) ; break ; } } return 0 ; }
<S2SV_ModStart> p . str , false <S2SV_ModStart> ) , delim , false <S2SV_ModStart> p . str , false <S2SV_ModStart> p . str , false <S2SV_ModStart> p . str , false
72
CWE-000 asmlinkage void bad_mode ( struct pt_regs * regs , int reason , unsigned int esr <S2SV_EndBug> <S2SV_StartBug> ) { console_verbose ( ) ; pr_crit ( "Bad<S2SV_blank>mode<S2SV_blank>in<S2SV_blank>%s<S2SV_blank>handler<S2SV_blank>detected,<S2SV_blank>code<S2SV_blank>0x%08x\\n" , handler [ reason <S2SV_StartBug> ] , esr ) ; die ( "Oops<S2SV_blank>-<S2SV_blank>bad<S2SV_blank>mode" , regs , 0 <S2SV_EndBug> ) ; local_irq_disable ( ) ; panic ( "bad<S2SV_blank>mode" ) ; }
<S2SV_ModStart> esr ) { siginfo_t info ; void __user * pc = ( void __user * ) instruction_pointer ( regs ) ; <S2SV_ModStart> esr ) ; __show_regs ( regs ) ; info . si_signo = SIGILL ; info . si_errno = 0 ; info . si_code = ILL_ILLOPC ; info . si_addr = pc ; arm64_notify_die <S2SV_ModEnd> ( "Oops<S2SV_blank>-<S2SV_blank>bad<S2SV_blank>mode" , <S2SV_ModStart> , regs , & info , 0 <S2SV_ModEnd> ) ; }
73
CWE-190 <S2SV_StartBug> int jas_matrix_resize ( jas_matrix_t * matrix , int numrows , int <S2SV_EndBug> numcols ) { int size ; <S2SV_EndBug> <S2SV_StartBug> int i ; size = numrows * numcols ; if ( size > matrix -> datasize_ || numrows > matrix -> maxrows_ ) { return - 1 ; } matrix -> numrows_ = numrows ; matrix -> numcols_ = numcols ; for ( i = 0 ; i < numrows ; ++ i ) { matrix -> rows_ [ i ] = & matrix -> data_ [ numcols * i ] ; } return 0 ; }
<S2SV_ModStart> * matrix , jas_matind_t numrows , jas_matind_t <S2SV_ModEnd> numcols ) { <S2SV_ModStart> numcols ) { jas_matind_t size ; jas_matind_t <S2SV_ModEnd> i ; size
74
CWE-20 int res_inverse ( vorbis_dsp_state * vd , vorbis_info_residue * info , ogg_int32_t * * in , int * nonzero , int ch ) { int i , j , k , s , used = 0 ; codec_setup_info * ci = ( codec_setup_info * ) vd -> vi -> codec_setup ; codebook * phrasebook = ci -> book_param + info -> groupbook ; int samples_per_partition = info -> grouping ; int partitions_per_word = phrasebook -> dim ; int pcmend = ci -> blocksizes [ vd -> W ] ; if ( info -> type < 2 ) { int max = pcmend >> 1 ; int end = ( info -> end < max ? info -> end : max ) ; int n = end - info -> begin ; if ( n > 0 ) { int partvals = n / samples_per_partition ; int partwords = ( partvals + partitions_per_word - 1 ) / partitions_per_word ; for ( i = 0 ; i < ch ; i ++ ) if ( nonzero [ i ] ) in [ used ++ ] = in [ i ] ; ch = used ; if ( used ) { char * * partword = ( char * * ) alloca ( ch * sizeof ( * partword ) ) ; for ( j = 0 ; j < ch ; j ++ ) partword [ j ] = ( char * ) alloca ( partwords * partitions_per_word * sizeof ( * partword [ j ] ) ) ; for ( s = 0 ; s < info -> stages ; s ++ ) { for ( i = 0 ; i < partvals ; ) { if ( s == 0 ) { partword [ 0 ] [ i + partitions_per_word - 1 ] = 1 ; for ( k = partitions_per_word - 2 ; k >= 0 ; k -- ) partword [ 0 ] [ i + k ] = partword [ 0 ] [ i + k + 1 ] * info -> partitions ; for ( j = 1 ; j < ch ; j ++ ) for ( k = partitions_per_word - 1 ; k >= 0 ; k -- ) partword [ j ] [ i + k ] = partword [ j - 1 ] [ i + k ] ; for ( j = 0 ; j < ch ; j ++ ) { int temp = vorbis_book_decode ( phrasebook , & vd -> opb ) ; if ( temp == - 1 ) goto eopbreak ; for ( k = 0 ; k < partitions_per_word ; k ++ ) { ogg_uint32_t div = partword [ j ] [ i + k ] ; partword [ j ] [ i + k ] = temp / div ; temp -= partword [ j ] [ i + k ] * div ; } } } for ( k = 0 ; k < partitions_per_word && i < partvals ; k ++ , i ++ ) for ( j = 0 ; j < ch ; j ++ ) { long offset = info -> begin + i * samples_per_partition ; if ( info -> stagemasks <S2SV_StartBug> [ ( int ) partword [ j ] [ i ] ] & ( 1 << s ) ) { <S2SV_EndBug> codebook * stagebook = ci -> book_param + info -> stagebooks [ ( partword [ j ] [ i ] << 3 ) + s ] ; if ( info -> type ) { if ( vorbis_book_decodev_add ( stagebook , in [ j ] + offset , & vd -> opb , samples_per_partition , - 8 ) == - 1 ) goto eopbreak ; } else { if ( vorbis_book_decodevs_add ( stagebook , in [ j ] + offset , & vd -> opb , samples_per_partition , - 8 ) == - 1 ) goto eopbreak ; } } } } } } } } else { int max = ( pcmend * ch ) >> 1 ; int end = ( info -> end < max ? info -> end : max ) ; int n = end - info -> begin ; if ( n > 0 ) { int partvals = n / samples_per_partition ; int partwords = ( partvals + partitions_per_word - 1 ) / partitions_per_word ; char * partword = ( char * ) alloca ( partwords * partitions_per_word * sizeof ( * partword ) ) ; int beginoff = info -> begin / ch ; for ( i = 0 ; i < ch ; i ++ ) if ( nonzero [ i ] ) break ; if ( i == ch ) return ( 0 ) ; samples_per_partition /= ch ; for ( s = 0 ; s < info -> stages ; s ++ ) { for ( i = 0 ; i < partvals ; ) { if ( s == 0 ) { int temp ; partword [ i + partitions_per_word - 1 ] = 1 ; for ( k = partitions_per_word - 2 ; k >= 0 ; k -- ) partword [ i + k ] = partword [ i + k + 1 ] * info -> partitions ; temp = vorbis_book_decode ( phrasebook , & vd -> opb ) ; if ( temp == - 1 ) goto eopbreak ; for ( k = 0 ; k < partitions_per_word ; k ++ ) { ogg_uint32_t div = partword [ i + k ] ; partword [ i + k ] = temp / div ; temp -= partword [ i + k ] * div ; } } for ( k = 0 ; k < partitions_per_word && i < partvals ; k ++ , i ++ ) if ( info -> stagemasks [ ( int ) partword [ i ] ] & ( 1 << s ) ) { codebook * stagebook = ci -> book_param + info -> stagebooks [ ( partword [ i ] << 3 ) + s ] ; if ( vorbis_book_decodevv_add ( stagebook , in , i * samples_per_partition + beginoff , ch , & vd -> opb , samples_per_partition , - 8 ) == - 1 ) goto eopbreak ; } } } } } eopbreak : return 0 ; }
<S2SV_ModStart> * samples_per_partition ; int idx = ( int ) partword [ j ] [ i ] ; if ( idx < info -> partitions && <S2SV_ModEnd> info -> stagemasks <S2SV_ModStart> -> stagemasks [ idx <S2SV_ModEnd> ] & (
75
CWE-552 ssize_t oe_recvfrom ( int sockfd , void * buf , size_t len , <S2SV_StartBug> int flags , const struct oe_sockaddr * src_addr <S2SV_EndBug> , oe_socklen_t * addrlen ) { ssize_t ret = - 1 ; oe_fd_t * sock ; if ( ! ( sock = oe_fdtable_get ( sockfd , OE_FD_TYPE_SOCKET ) ) ) OE_RAISE_ERRNO ( oe_errno ) ; ret = sock -> ops . socket . recvfrom ( sock , buf , len , flags , src_addr , addrlen ) ; done : return ret ; }
<S2SV_ModStart> int flags , <S2SV_ModEnd> struct oe_sockaddr *
76
CWE-125 static void l2tp_ppp_discon_cc_print ( netdissect_options * ndo , const u_char * dat , u_int length ) { const uint16_t * ptr = ( const uint16_t * ) dat ; ND_PRINT ( ( <S2SV_StartBug> ndo , "%04x,<S2SV_blank>" , EXTRACT_16BITS ( ptr ) ) ) ; ptr ++ ; <S2SV_StartBug> <S2SV_EndBug> ND_PRINT ( ( ndo , "%04x<S2SV_blank>" , EXTRACT_16BITS ( ptr ) ) ) ; <S2SV_EndBug> ptr ++ ; ND_PRINT ( ( ndo , "%s" , tok2str ( l2tp_cc_direction2str , "Direction-#%u" , * ( <S2SV_StartBug> ( const u_char * ) ptr ++ ) ) ) <S2SV_StartBug> <S2SV_EndBug> ) ; if ( length <S2SV_EndBug> > 5 ) { ND_PRINT ( ( ndo , "<S2SV_blank>" ) ) ; <S2SV_StartBug> print_string ( ndo , ( const u_char * ) ptr , length <S2SV_EndBug> - 5 ) ; } }
<S2SV_ModStart> ) dat ; if ( length < 5 ) { ND_PRINT ( ( ndo , "AVP<S2SV_blank>too<S2SV_blank>short" ) ) ; return ; } <S2SV_ModStart> , EXTRACT_16BITS ( dat <S2SV_ModEnd> ) ) ) <S2SV_ModStart> ) ) ; dat += 2 ; length -= 2 <S2SV_ModEnd> ; ND_PRINT ( <S2SV_ModStart> , EXTRACT_16BITS ( dat <S2SV_ModEnd> ) ) ) <S2SV_ModStart> ) ) ; dat += 2 ; length -= 2 <S2SV_ModEnd> ; ND_PRINT ( <S2SV_ModStart> , "Direction-#%u" , EXTRACT_8BITS ( ptr <S2SV_ModEnd> ) ) ) <S2SV_ModStart> ) ) ; ptr ++ ; length -- ; <S2SV_ModStart> if ( length != 0 <S2SV_ModEnd> ) { ND_PRINT <S2SV_ModStart> ptr , length <S2SV_ModEnd> ) ; }
77
CWE-399 static int dcbnl_cee_fill ( struct sk_buff * skb , struct net_device * netdev ) { struct nlattr * cee , * app ; struct dcb_app_type * itr ; const struct dcbnl_rtnl_ops * ops = netdev -> dcbnl_ops ; int dcbx , i , err = - EMSGSIZE ; u8 value ; if ( nla_put_string ( skb , DCB_ATTR_IFNAME , netdev -> name ) ) goto nla_put_failure ; cee = nla_nest_start ( skb , DCB_ATTR_CEE ) ; if ( ! cee ) goto nla_put_failure ; if ( ops -> getpgtccfgtx && ops -> getpgbwgcfgtx ) { err = dcbnl_cee_pg_fill ( skb , netdev , 1 ) ; if ( err ) goto nla_put_failure ; } if ( ops -> getpgtccfgrx && ops -> getpgbwgcfgrx ) { err = dcbnl_cee_pg_fill ( skb , netdev , 0 ) ; if ( err ) goto nla_put_failure ; } if ( ops -> getpfccfg ) { struct nlattr * pfc_nest = nla_nest_start ( skb , DCB_ATTR_CEE_PFC ) ; if ( ! pfc_nest ) goto nla_put_failure ; for ( i = DCB_PFC_UP_ATTR_0 ; i <= DCB_PFC_UP_ATTR_7 ; i ++ ) { ops -> getpfccfg ( netdev , i - DCB_PFC_UP_ATTR_0 , & value ) ; if ( nla_put_u8 ( skb , i , value ) ) goto nla_put_failure ; } nla_nest_end ( skb , pfc_nest ) ; } spin_lock ( & dcb_lock ) ; app = nla_nest_start ( skb , DCB_ATTR_CEE_APP_TABLE ) ; if ( ! app ) goto dcb_unlock ; list_for_each_entry ( itr , & dcb_app_list , list ) { if ( itr -> ifindex == netdev -> ifindex ) { struct nlattr * app_nest = nla_nest_start ( skb , DCB_ATTR_APP ) ; if ( ! app_nest ) goto dcb_unlock ; err = nla_put_u8 ( skb , DCB_APP_ATTR_IDTYPE , itr -> app . selector ) ; if ( err ) goto dcb_unlock ; err = nla_put_u16 ( skb , DCB_APP_ATTR_ID , itr -> app . protocol ) ; if ( err ) goto dcb_unlock ; err = nla_put_u8 ( skb , DCB_APP_ATTR_PRIORITY , itr -> app . priority ) ; if ( err ) goto dcb_unlock ; nla_nest_end ( skb , app_nest ) ; } } nla_nest_end ( skb , app ) ; if ( netdev -> dcbnl_ops -> getdcbx ) dcbx = netdev -> dcbnl_ops -> getdcbx ( netdev ) ; else dcbx = - EOPNOTSUPP ; spin_unlock ( & dcb_lock ) ; if ( ops -> getfeatcfg ) { struct nlattr * feat = nla_nest_start ( skb , DCB_ATTR_CEE_FEAT ) ; if ( ! feat ) goto nla_put_failure ; for ( i = DCB_FEATCFG_ATTR_ALL + 1 ; i <= DCB_FEATCFG_ATTR_MAX ; i ++ ) if ( ! ops -> getfeatcfg ( netdev , i , & value ) && nla_put_u8 ( skb , i , value ) ) goto nla_put_failure ; nla_nest_end ( skb , feat ) ; } if ( ops -> cee_peer_getpg ) { struct cee_pg pg ; <S2SV_StartBug> err = ops -> cee_peer_getpg ( netdev , & pg ) ; if ( ! err && <S2SV_EndBug> nla_put ( skb , DCB_ATTR_CEE_PEER_PG , sizeof ( pg ) , & pg ) ) goto nla_put_failure ; } if ( ops -> cee_peer_getpfc <S2SV_StartBug> ) { struct cee_pfc pfc <S2SV_EndBug> ; err = ops -> cee_peer_getpfc ( netdev , & pfc ) ; if ( ! err && nla_put ( skb , DCB_ATTR_CEE_PEER_PFC , sizeof ( pfc ) , & pfc ) ) goto nla_put_failure ; } if ( ops -> peer_getappinfo && ops -> peer_getapptable ) { err = dcbnl_build_peer_app ( netdev , skb , DCB_ATTR_CEE_PEER_APP_TABLE , DCB_ATTR_CEE_PEER_APP_INFO , DCB_ATTR_CEE_PEER_APP ) ; if ( err ) goto nla_put_failure ; } nla_nest_end ( skb , cee ) ; if ( dcbx >= 0 ) { err = nla_put_u8 ( skb , DCB_ATTR_DCBX , dcbx ) ; if ( err ) goto nla_put_failure ; } return 0 ; dcb_unlock : spin_unlock ( & dcb_lock ) ; nla_put_failure : return err ; }
<S2SV_ModStart> cee_pg pg ; memset ( & pg , 0 , sizeof ( pg ) ) ; <S2SV_ModStart> struct cee_pfc pfc ; memset ( & pfc , 0 , sizeof ( pfc ) )
78
CWE-119 static int complete_emulated_mmio ( struct kvm_vcpu * vcpu ) { struct kvm_run * run = vcpu -> run ; struct kvm_mmio_fragment * frag ; unsigned len ; BUG_ON ( ! vcpu -> mmio_needed ) ; frag = & vcpu -> mmio_fragments [ vcpu -> mmio_cur_fragment ] ; len = min ( 8u , frag -> len ) ; if ( ! vcpu -> mmio_is_write ) memcpy ( frag -> data , run -> mmio . data , len ) ; if ( frag -> len <= 8 ) { frag ++ ; vcpu -> mmio_cur_fragment ++ ; } else { frag -> data += len ; frag -> gpa += len ; frag -> len -= len ; } <S2SV_StartBug> if ( vcpu -> mmio_cur_fragment == vcpu -> mmio_nr_fragments ) <S2SV_EndBug> { vcpu -> mmio_needed = 0 ; if ( vcpu -> mmio_is_write ) return 1 ; vcpu -> mmio_read_completed = 1 ; return complete_emulated_io ( vcpu ) ; } run -> exit_reason = KVM_EXIT_MMIO ; run -> mmio . phys_addr = frag -> gpa ; if ( vcpu -> mmio_is_write ) memcpy ( run -> mmio . data , frag -> data , min ( 8u , frag -> len ) ) ; run -> mmio . len = min ( 8u , frag -> len ) ; run -> mmio . is_write = vcpu -> mmio_is_write ; vcpu -> arch . complete_userspace_io = complete_emulated_mmio ; return 0 ; }
<S2SV_ModStart> vcpu -> mmio_cur_fragment >= <S2SV_ModEnd> vcpu -> mmio_nr_fragments
79
CWE-674 static krb5_error_code split_der ( asn1buf * buf , uint8_t * const * der , size_t len , taginfo * tag_out ) { krb5_error_code ret ; const uint8_t * contents , * remainder ; size_t clen , rlen ; ret = get_tag <S2SV_StartBug> ( * der , len , tag_out , & contents , & clen , & remainder , & <S2SV_EndBug> rlen ) ; if ( ret ) return ret ; if ( rlen != 0 ) return ASN1_BAD_LENGTH ; insert_bytes ( buf , contents , clen ) ; return 0 ; }
<S2SV_ModStart> , & rlen , 0
80
CWE-125 static int uas_switch_interface ( struct usb_device * udev , struct usb_interface * intf ) { int alt ; <S2SV_EndBug> alt = uas_find_uas_alt_setting <S2SV_StartBug> ( intf <S2SV_StartBug> ) ; if ( alt < 0 ) return alt ; return <S2SV_EndBug> usb_set_interface ( udev , <S2SV_StartBug> intf -> altsetting [ 0 ] . desc . bInterfaceNumber , <S2SV_EndBug> alt ) ; }
<S2SV_ModStart> intf ) { struct usb_host_interface * <S2SV_ModEnd> alt ; alt <S2SV_ModStart> ; if ( ! alt ) return - ENODEV <S2SV_ModEnd> ; return usb_set_interface <S2SV_ModStart> ( udev , alt -> <S2SV_ModEnd> desc . bInterfaceNumber <S2SV_ModStart> bInterfaceNumber , alt -> desc . bAlternateSetting
81
CWE-17 <S2SV_StartBug> static void udf_pc_to_char ( struct super_block * sb , unsigned char * from , <S2SV_StartBug> int fromlen , <S2SV_EndBug> unsigned char * <S2SV_EndBug> to ) { struct pathComponent * pc ; int elen = 0 ; unsigned char <S2SV_StartBug> * p = to ; while ( elen <S2SV_EndBug> < fromlen ) { pc = ( struct pathComponent * ) ( from + elen ) ; switch ( pc -> componentType ) { case 1 : if ( pc -> lengthComponentIdent > 0 ) break ; case 2 : p = to ; <S2SV_EndBug> <S2SV_StartBug> * p ++ = '/' ; <S2SV_StartBug> break ; case 3 <S2SV_EndBug> : memcpy ( p , "../" , 3 ) ; p += <S2SV_EndBug> <S2SV_StartBug> 3 ; break ; case 4 : memcpy ( <S2SV_StartBug> p , "./" , 2 ) ; p += 2 <S2SV_StartBug> <S2SV_EndBug> ; break ; case <S2SV_StartBug> <S2SV_EndBug> 5 : p += udf_get_filename ( sb , pc -> componentIdent , p <S2SV_EndBug> , pc -> lengthComponentIdent ) ; <S2SV_StartBug> * p ++ = '/' ; break ; } elen += <S2SV_EndBug> sizeof ( struct pathComponent ) + pc -> lengthComponentIdent ; } if ( p > to + 1 ) p [ - 1 ] = '\\0' ; else p [ 0 ] = '\\0' ; <S2SV_StartBug> } <S2SV_EndBug>
<S2SV_ModStart> <S2SV_null> <S2SV_null> static int <S2SV_ModEnd> udf_pc_to_char ( struct <S2SV_ModStart> char * to , int tolen <S2SV_ModStart> = 0 ; int comp_len ; <S2SV_ModStart> p = to ; tolen -- <S2SV_ModStart> case 2 : if ( tolen == 0 ) return - ENAMETOOLONG ; <S2SV_ModStart> = '/' ; tolen -- ; break ; case 3 : if ( tolen < 3 ) return - ENAMETOOLONG ; <S2SV_ModEnd> memcpy ( p <S2SV_ModStart> += 3 ; tolen -= 3 ; <S2SV_ModStart> case 4 : if ( tolen < 2 ) return - ENAMETOOLONG ; <S2SV_ModStart> += 2 ; tolen -= 2 ; <S2SV_ModStart> case 5 : comp_len = udf_get_filename ( sb , pc -> componentIdent , pc -> lengthComponentIdent , p , tolen ) ; p += comp_len ; tolen -= comp_len ; if ( tolen == 0 ) return - ENAMETOOLONG <S2SV_ModEnd> ; * p <S2SV_ModStart> ++ = '/' ; tolen -- <S2SV_ModStart> = '\\0' ; return 0 ;
82
CWE-264 static void chase_port ( struct edgeport_port * port , unsigned long timeout , int flush ) { int baud_rate ; struct tty_struct * tty = tty_port_tty_get ( & port -> port -> port ) ; struct usb_serial * serial = port -> port -> serial ; <S2SV_StartBug> wait_queue_t wait <S2SV_EndBug> ; unsigned long flags ; if ( ! timeout ) timeout = ( HZ * EDGE_CLOSING_WAIT ) / 100 ; spin_lock_irqsave ( & port -> ep_lock , flags ) ; init_waitqueue_entry ( & wait , current ) ; add_wait_queue ( & tty -> write_wait , & wait ) ; for ( ; ; ) { set_current_state ( TASK_INTERRUPTIBLE ) ; if ( kfifo_len ( & port -> write_fifo ) == 0 || timeout == 0 || signal_pending ( current ) || serial -> disconnected ) break ; spin_unlock_irqrestore ( & port -> ep_lock , flags ) ; timeout = schedule_timeout ( timeout ) ; spin_lock_irqsave ( & port -> ep_lock , flags ) ; } set_current_state ( TASK_RUNNING ) ; remove_wait_queue ( & tty -> write_wait , & wait ) ; if ( flush ) kfifo_reset_out ( & port -> write_fifo ) ; spin_unlock_irqrestore ( & port -> ep_lock , flags ) ; tty_kref_put ( tty ) ; timeout += jiffies ; while ( ( long ) ( jiffies - timeout ) < 0 && ! signal_pending ( current ) && ! serial -> disconnected ) { if ( ! tx_active ( port ) ) break ; msleep ( 10 ) ; } if ( serial -> disconnected ) return ; baud_rate = port -> baud_rate ; if ( baud_rate == 0 ) baud_rate = 50 ; msleep ( max ( 1 , DIV_ROUND_UP ( 10000 , baud_rate ) ) ) ; }
<S2SV_ModStart> unsigned long flags ; if ( ! tty ) return
83
CWE-119 static int atusb_get_and_show_revision ( struct atusb * atusb ) { struct usb_device * usb_dev = <S2SV_StartBug> atusb -> usb_dev ; unsigned char buffer [ 3 <S2SV_EndBug> ] ; int ret ; ret = atusb_control_msg ( atusb , usb_rcvctrlpipe ( usb_dev , 0 ) , ATUSB_ID , ATUSB_REQ_FROM_DEV , 0 , 0 , buffer , 3 , 1000 ) ; if ( ret >= 0 ) { atusb -> fw_ver_maj = buffer [ 0 ] ; atusb -> fw_ver_min = buffer [ 1 ] ; atusb -> fw_hw_type = buffer [ 2 ] ; dev_info ( & usb_dev -> dev , "Firmware:<S2SV_blank>major:<S2SV_blank>%u,<S2SV_blank>minor:<S2SV_blank>%u,<S2SV_blank>hardware<S2SV_blank>type:<S2SV_blank>%u\\n" , atusb -> fw_ver_maj , atusb -> fw_ver_min , atusb -> fw_hw_type ) ; } if ( atusb -> fw_ver_maj == 0 && atusb -> fw_ver_min < 2 ) { dev_info ( & usb_dev -> dev , "Firmware<S2SV_blank>version<S2SV_blank>(%u.%u)<S2SV_blank>predates<S2SV_blank>our<S2SV_blank>first<S2SV_blank>public<S2SV_blank>release." , atusb -> fw_ver_maj , atusb -> fw_ver_min ) ; dev_info ( & usb_dev -> dev , "Please<S2SV_blank>update<S2SV_blank>to<S2SV_blank>version<S2SV_blank>0.2<S2SV_blank>or<S2SV_blank>newer" ) ; } return <S2SV_EndBug> <S2SV_StartBug> ret ; }
<S2SV_ModStart> ; unsigned char * buffer ; int ret ; buffer = kmalloc ( 3 , GFP_KERNEL ) ; if ( ! buffer ) return - ENOMEM <S2SV_ModEnd> ; ret = <S2SV_ModStart> ) ; } kfree ( buffer ) ;
84
CWE-345 static int daemon_AuthUserPwd ( char * username , char * password , char * errbuf ) { # ifdef <S2SV_StartBug> _WIN32 HANDLE Token ; <S2SV_StartBug> if ( LogonUser <S2SV_EndBug> ( username , "." , password , LOGON32_LOGON_NETWORK , LOGON32_PROVIDER_DEFAULT , & Token ) == 0 ) { <S2SV_StartBug> pcap_fmt_errmsg_for_win32_err ( errbuf <S2SV_EndBug> , <S2SV_EndBug> PCAP_ERRBUF_SIZE , <S2SV_StartBug> GetLastError ( ) , "LogonUser()<S2SV_blank>failed" ) ; return - 1 ; <S2SV_EndBug> } if ( <S2SV_StartBug> ImpersonateLoggedOnUser ( <S2SV_EndBug> Token ) == 0 ) { pcap_fmt_errmsg_for_win32_err ( errbuf , PCAP_ERRBUF_SIZE , GetLastError ( ) , "ImpersonateLoggedOnUser()<S2SV_blank>failed" ) ; CloseHandle ( Token ) <S2SV_StartBug> <S2SV_EndBug> ; return - 1 ; } CloseHandle ( Token ) ; return 0 ; <S2SV_StartBug> <S2SV_EndBug> # else struct passwd * user ; char * user_password ; # ifdef HAVE_GETSPNAM struct spwd * usersp ; # endif char * crypt_password ; if ( ( user = getpwnam ( username ) ) == NULL ) { pcap_snprintf ( <S2SV_StartBug> errbuf , PCAP_ERRBUF_SIZE , <S2SV_EndBug> "Authentication<S2SV_blank>failed:<S2SV_blank>user<S2SV_blank>name<S2SV_blank>or<S2SV_blank>password<S2SV_blank>incorrect" ) ; return - 1 ; } # ifdef HAVE_GETSPNAM if ( ( usersp = getspnam ( username ) ) == NULL <S2SV_StartBug> ) { pcap_snprintf ( errbuf , PCAP_ERRBUF_SIZE , "Authentication<S2SV_blank>failed:<S2SV_blank>user<S2SV_blank>name<S2SV_blank>or<S2SV_blank>password<S2SV_blank>incorrect" ) <S2SV_EndBug> ; return - 1 ; } user_password = usersp -> sp_pwdp ; # else user_password = user -> pw_passwd ; # <S2SV_StartBug> endif crypt_password = crypt ( password , user_password ) <S2SV_EndBug> ; if ( crypt_password == NULL ) { pcap_snprintf ( errbuf <S2SV_StartBug> , PCAP_ERRBUF_SIZE , "Authentication<S2SV_blank>failed" ) ; return <S2SV_EndBug> - 1 ; } if ( strcmp ( user_password , crypt_password ) != 0 ) { pcap_snprintf <S2SV_StartBug> ( errbuf , PCAP_ERRBUF_SIZE , "Authentication<S2SV_blank>failed:<S2SV_blank>user<S2SV_blank>name<S2SV_blank>or<S2SV_blank>password<S2SV_blank>incorrect" ) ; <S2SV_EndBug> return - 1 ; } if ( setuid ( user -> pw_uid ) ) { pcap_fmt_errmsg_for_errno ( errbuf , <S2SV_StartBug> PCAP_ERRBUF_SIZE , <S2SV_StartBug> errno , "setuid" <S2SV_EndBug> <S2SV_EndBug> ) ; return - 1 <S2SV_EndBug> <S2SV_StartBug> ; } return 0 ; # endif }
<S2SV_ModStart> # ifdef _WIN32 DWORD error ; <S2SV_ModStart> HANDLE Token ; char errmsgbuf [ PCAP_ERRBUF_SIZE ] ; <S2SV_ModStart> 0 ) { pcap_snprintf ( errbuf , PCAP_ERRBUF_SIZE , "Authentication<S2SV_blank>failed" ) ; error = GetLastError ( ) ; if ( error != ERROR_LOGON_FAILURE ) { pcap_fmt_errmsg_for_win32_err ( errmsgbuf , PCAP_ERRBUF_SIZE , error , "LogonUser()<S2SV_blank>failed" ) ; rpcapd_log ( LOGPRIO_ERROR , "%s" , errmsgbuf ) ; } return - 1 ; } if ( ImpersonateLoggedOnUser ( Token ) == 0 ) { pcap_snprintf ( errbuf , PCAP_ERRBUF_SIZE , "Authentication<S2SV_blank>failed" ) ; pcap_fmt_errmsg_for_win32_err ( errmsgbuf <S2SV_ModEnd> , PCAP_ERRBUF_SIZE , <S2SV_ModStart> ( ) , "ImpersonateLoggedOnUser()<S2SV_blank>failed" ) ; rpcapd_log ( LOGPRIO_ERROR , "%s" , errmsgbuf ) ; CloseHandle <S2SV_ModEnd> ( Token ) <S2SV_ModStart> ( Token ) ; return - 1 ; } <S2SV_ModEnd> CloseHandle ( Token <S2SV_ModStart> ) ; return <S2SV_ModEnd> 0 ; # <S2SV_ModStart> ; # else int error ; <S2SV_ModStart> , PCAP_ERRBUF_SIZE , "Authentication<S2SV_blank>failed" <S2SV_ModEnd> ) ; return <S2SV_ModStart> , PCAP_ERRBUF_SIZE , "Authentication<S2SV_blank>failed" <S2SV_ModEnd> ) ; return <S2SV_ModStart> ; # endif errno = 0 ; <S2SV_ModStart> NULL ) { error = errno ; pcap_snprintf ( errbuf , PCAP_ERRBUF_SIZE , "Authentication<S2SV_blank>failed" ) ; if ( error == 0 ) { rpcapd_log ( LOGPRIO_ERROR , "crypt()<S2SV_blank>failed" ) ; } else { rpcapd_log ( LOGPRIO_ERROR , "crypt()<S2SV_blank>failed:<S2SV_blank>%s" , strerror ( error ) ) ; } <S2SV_ModEnd> return - 1 <S2SV_ModStart> , PCAP_ERRBUF_SIZE , "Authentication<S2SV_blank>failed" <S2SV_ModEnd> ) ; return <S2SV_ModStart> ) ) { error = errno ; <S2SV_ModStart> , PCAP_ERRBUF_SIZE , error <S2SV_ModEnd> , "setuid" ) <S2SV_ModStart> "setuid" ) ; rpcapd_log ( LOGPRIO_ERROR , "setuid()<S2SV_blank>failed:<S2SV_blank>%s" , strerror ( error ) ) ;
85
<S2SV_StartBug> CWE-190 static PyObject * _Unpickler_MemoGet ( UnpicklerObject * self , Py_ssize_t <S2SV_EndBug> idx ) { if ( idx < <S2SV_StartBug> 0 || idx >= <S2SV_EndBug> self -> memo_size ) return NULL ; return self -> memo [ idx ] ; }
<S2SV_ModStart> * self , size_t <S2SV_ModEnd> idx ) { <S2SV_ModStart> { if ( <S2SV_ModEnd> idx >= self
86
CWE-000 void sas_deform_port ( struct asd_sas_phy * phy , int gone ) { struct sas_ha_struct * sas_ha = phy -> ha ; struct asd_sas_port * port = phy -> port ; struct sas_internal * si = to_sas_internal ( sas_ha -> core . shost -> transportt ) ; struct domain_device * dev ; unsigned long flags ; if ( ! port ) return ; dev = port -> port_dev ; if ( dev ) dev -> pathways -- ; if ( port -> num_phys == 1 ) { sas_unregister_domain_devices ( port , <S2SV_StartBug> gone ) ; sas_port_delete ( port -> port ) ; port -> <S2SV_EndBug> port = NULL ; } else { sas_port_delete_phy ( port -> port , phy -> phy ) ; sas_device_set_phy ( dev , port -> port ) ; } if ( si -> dft -> lldd_port_deformed ) si -> dft -> lldd_port_deformed ( phy ) ; spin_lock_irqsave ( & sas_ha -> phy_port_lock , flags ) ; spin_lock ( & port -> phy_list_lock ) ; list_del_init ( & phy -> port_phy_el ) ; sas_phy_set_target ( phy , NULL ) ; phy -> port = NULL ; port -> num_phys -- ; port -> phy_mask &= ~ ( 1U << phy -> id ) ; if ( port -> num_phys == 0 ) { INIT_LIST_HEAD ( & port -> phy_list ) ; memset ( port -> sas_addr , 0 , SAS_ADDR_SIZE ) ; memset ( port -> attached_sas_addr , 0 , SAS_ADDR_SIZE ) ; port -> class = 0 ; port -> iproto = 0 ; port -> tproto = 0 ; port -> oob_mode = 0 ; port -> phy_mask = 0 ; } spin_unlock ( & port -> phy_list_lock ) ; spin_unlock_irqrestore ( & sas_ha -> phy_port_lock , flags ) ; return ; }
<S2SV_ModStart> gone ) ; sas_destruct_devices ( port ) ;
87
CWE-125 static stmt_ty ast_for_with_stmt ( struct compiling * <S2SV_StartBug> c , const node * n , int is_async ) <S2SV_EndBug> <S2SV_StartBug> <S2SV_EndBug> { int i , n_items , nch_minus_type , has_type_comment ; asdl_seq * items , * body ; string type_comment ; if ( is_async && c -> c_feature_version < 5 ) { ast_error ( c , n , "Async<S2SV_blank>with<S2SV_blank>statements<S2SV_blank>are<S2SV_blank>only<S2SV_blank>supported<S2SV_blank>in<S2SV_blank>Python<S2SV_blank>3.5<S2SV_blank>and<S2SV_blank>greater" ) ; return NULL ; } REQ ( n , with_stmt ) ; has_type_comment = TYPE ( CHILD ( n , NCH ( n ) - 2 ) ) == TYPE_COMMENT ; nch_minus_type = NCH ( n ) - has_type_comment ; n_items = ( nch_minus_type - 2 ) / 2 ; items = _Ta3_asdl_seq_new ( n_items , c -> c_arena ) ; if ( ! items ) return NULL ; for ( i = 1 ; i < nch_minus_type - 2 ; i += 2 ) { withitem_ty item = ast_for_with_item ( c , CHILD ( n , i ) ) ; if ( ! item ) return NULL ; asdl_seq_SET ( items , ( i - 1 ) / 2 , item ) ; } body = ast_for_suite ( c , CHILD ( n , NCH ( n ) - 1 ) ) ; if ( ! body ) return NULL ; if ( has_type_comment ) type_comment = NEW_TYPE_COMMENT ( CHILD ( n , NCH ( n ) - 2 ) ) ; else type_comment = NULL ; if ( is_async ) return AsyncWith <S2SV_StartBug> ( items , body , type_comment , LINENO ( n ) , n -> n_col_offset , c <S2SV_EndBug> -> c_arena ) ; else return With ( items , body , type_comment , LINENO ( n ) , n -> n_col_offset , c -> c_arena ) ; }
<S2SV_ModStart> const node * n0 , bool <S2SV_ModEnd> is_async ) { <S2SV_ModStart> is_async ) { const node * const n = is_async ? CHILD ( n0 , 1 ) : n0 ; <S2SV_ModStart> , LINENO ( n0 ) , n0 <S2SV_ModEnd> -> n_col_offset ,
88
CWE-362 struct request * blk_mq_tag_to_rq ( struct blk_mq_tags * tags , unsigned int tag ) { struct request <S2SV_StartBug> * rq = tags -> rqs [ tag ] ; <S2SV_StartBug> struct blk_flush_queue * fq = <S2SV_EndBug> blk_get_flush_queue ( rq -> q , rq -> mq_ctx ) <S2SV_EndBug> ; if ( ! is_flush_request ( rq , fq , tag ) ) return rq ; return fq -> flush_rq ; }
<S2SV_ModStart> tag ) { return <S2SV_ModEnd> tags -> rqs <S2SV_ModStart> tag ] ; <S2SV_ModEnd> } <S2SV_null> <S2SV_null>
89
CWE-119 static struct nvmet_fc_tgt_queue * nvmet_fc_find_target_queue ( struct nvmet_fc_tgtport * tgtport , u64 connection_id ) { struct nvmet_fc_tgt_assoc * assoc ; struct nvmet_fc_tgt_queue * queue ; u64 association_id = nvmet_fc_getassociationid ( connection_id ) ; u16 qid = nvmet_fc_getqueueid ( <S2SV_StartBug> connection_id ) ; unsigned long flags ; spin_lock_irqsave <S2SV_EndBug> ( & tgtport -> lock , flags ) ; list_for_each_entry ( assoc , & tgtport -> assoc_list , a_list ) { if ( association_id == assoc -> association_id ) { queue = assoc -> queues [ qid ] ; if ( queue && ( ! atomic_read ( & queue -> connected ) || ! nvmet_fc_tgt_q_get ( queue ) ) ) queue = NULL ; spin_unlock_irqrestore ( & tgtport -> lock , flags ) ; return queue ; } } spin_unlock_irqrestore ( & tgtport -> lock , flags ) ; return NULL ; }
<S2SV_ModStart> unsigned long flags ; if ( qid > NVMET_NR_QUEUES ) return NULL
90
CWE-284 int socket_create ( uint16_t port ) { int sfd = - 1 ; int yes = 1 ; # ifdef WIN32 WSADATA wsa_data ; if ( ! wsa_init ) { if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsa_data ) != ERROR_SUCCESS ) { fprintf ( stderr , "WSAStartup<S2SV_blank>failed!\\n" ) ; ExitProcess ( - 1 ) ; } wsa_init = 1 ; } # endif struct sockaddr_in saddr ; if ( 0 > ( sfd = socket ( PF_INET , SOCK_STREAM , IPPROTO_TCP ) ) ) { perror ( "socket()" ) ; return - 1 ; } if ( setsockopt ( sfd , SOL_SOCKET , SO_REUSEADDR , ( void * ) & yes , sizeof ( int ) ) == - 1 ) { perror ( "setsockopt()" ) ; socket_close ( sfd ) ; return - 1 ; } # ifdef SO_NOSIGPIPE if ( setsockopt ( sfd , SOL_SOCKET , SO_NOSIGPIPE , ( void * ) & yes , sizeof ( int ) ) == - 1 ) { perror ( "setsockopt()" ) ; socket_close ( sfd ) ; return - 1 ; } # endif memset ( ( void * ) & saddr , 0 , sizeof ( saddr ) ) ; saddr . sin_family = <S2SV_StartBug> AF_INET ; saddr . sin_addr . s_addr = htonl ( INADDR_ANY ) ; <S2SV_EndBug> saddr . sin_port = htons ( port ) ; if ( 0 > bind ( sfd , ( struct sockaddr * ) & saddr , sizeof ( saddr ) ) ) { perror ( "bind()" ) ; socket_close ( sfd ) ; return - 1 ; } if ( listen ( sfd , 1 ) == - 1 ) { perror ( "listen()" ) ; socket_close ( sfd ) ; return - 1 ; } return sfd ; }
<S2SV_ModStart> = htonl ( INADDR_LOOPBACK <S2SV_ModEnd> ) ; saddr
91
CWE-119 static int nl80211_start_sched_scan ( struct sk_buff * skb , struct genl_info * info ) { struct cfg80211_sched_scan_request * request ; struct cfg80211_registered_device * rdev = info -> user_ptr [ 0 ] ; struct net_device * dev = info -> user_ptr [ 1 ] ; struct nlattr * attr ; struct wiphy * wiphy ; int err , tmp , n_ssids = 0 , n_channels , i ; u32 interval ; enum ieee80211_band band ; size_t ie_len ; if ( ! ( rdev -> wiphy . flags & WIPHY_FLAG_SUPPORTS_SCHED_SCAN ) || ! rdev -> ops -> sched_scan_start ) return - EOPNOTSUPP ; if ( ! is_valid_ie_attr ( info -> attrs [ NL80211_ATTR_IE ] ) ) return - EINVAL ; if ( rdev -> sched_scan_req ) return - EINPROGRESS ; if ( ! info -> attrs [ NL80211_ATTR_SCHED_SCAN_INTERVAL ] ) return - EINVAL ; interval = nla_get_u32 ( info -> attrs [ NL80211_ATTR_SCHED_SCAN_INTERVAL ] ) ; if ( interval == 0 ) return - EINVAL ; wiphy = & rdev -> wiphy ; if ( info -> attrs [ NL80211_ATTR_SCAN_FREQUENCIES ] ) { n_channels = validate_scan_freqs ( info -> attrs [ NL80211_ATTR_SCAN_FREQUENCIES ] ) ; if ( ! n_channels ) return - EINVAL ; } else { n_channels = 0 ; for ( band = 0 ; band < IEEE80211_NUM_BANDS ; band ++ ) if ( wiphy -> bands [ band ] ) n_channels += wiphy -> bands [ band ] -> n_channels ; } if ( info -> attrs [ NL80211_ATTR_SCAN_SSIDS ] ) nla_for_each_nested ( attr , info -> attrs [ NL80211_ATTR_SCAN_SSIDS ] , tmp ) n_ssids ++ ; if ( n_ssids > wiphy -> max_scan_ssids ) return - EINVAL ; if ( info -> attrs [ NL80211_ATTR_IE ] ) ie_len = nla_len ( info -> attrs [ NL80211_ATTR_IE ] ) ; else ie_len = 0 ; if ( ie_len > wiphy -> max_scan_ie_len ) return - EINVAL ; request = kzalloc ( sizeof ( * request ) + sizeof ( * request -> ssids ) * n_ssids + sizeof ( * request -> channels ) * n_channels + ie_len , GFP_KERNEL ) ; if ( ! request ) return - ENOMEM ; if ( n_ssids ) request -> ssids = ( void * ) & request -> channels [ n_channels ] ; request -> n_ssids = n_ssids ; if ( ie_len ) { if ( request -> ssids ) request -> ie = ( void * ) ( request -> ssids + n_ssids ) ; else request -> ie = ( void * ) ( request -> channels + n_channels ) ; } i = 0 ; if ( info -> attrs [ NL80211_ATTR_SCAN_FREQUENCIES ] ) { nla_for_each_nested ( attr , info -> attrs [ NL80211_ATTR_SCAN_FREQUENCIES ] , tmp ) { struct ieee80211_channel * chan ; chan = ieee80211_get_channel ( wiphy , nla_get_u32 ( attr ) ) ; if ( ! chan ) { err = - EINVAL ; goto out_free ; } if ( chan -> flags & IEEE80211_CHAN_DISABLED ) continue ; request -> channels [ i ] = chan ; i ++ ; } } else { for ( band = 0 ; band < IEEE80211_NUM_BANDS ; band ++ ) { int j ; if ( ! wiphy -> bands [ band ] ) continue ; for ( j = 0 ; j < wiphy -> bands [ band ] -> n_channels ; j ++ ) { struct ieee80211_channel * chan ; chan = & wiphy -> bands [ band ] -> channels [ j ] ; if ( chan -> flags & IEEE80211_CHAN_DISABLED ) continue ; request -> channels [ i ] = chan ; i ++ ; } } } if ( ! i ) { err = - EINVAL ; goto out_free ; } request -> n_channels = i ; i = 0 ; if ( info -> attrs [ NL80211_ATTR_SCAN_SSIDS ] ) { nla_for_each_nested ( attr , info -> attrs [ NL80211_ATTR_SCAN_SSIDS ] , <S2SV_StartBug> tmp ) { if ( request -> ssids [ i <S2SV_EndBug> ] . ssid_len > IEEE80211_MAX_SSID_LEN ) { err = - EINVAL ; goto out_free ; } memcpy ( request -> ssids [ i ] . ssid , nla_data ( attr ) , nla_len ( attr ) ) ; request -> ssids [ i <S2SV_StartBug> ] . ssid_len = nla_len ( attr ) ; i ++ ; } <S2SV_EndBug> } if ( info -> attrs [ NL80211_ATTR_IE ] ) { request -> ie_len = nla_len ( info -> attrs [ NL80211_ATTR_IE ] ) ; memcpy ( ( void * ) request -> ie , nla_data ( info -> attrs [ NL80211_ATTR_IE ] ) , request -> ie_len ) ; } request -> dev = dev ; request -> wiphy = & rdev -> wiphy ; request -> interval = interval ; err = rdev -> ops -> sched_scan_start ( & rdev -> wiphy , dev , request ) ; if ( ! err ) { rdev -> sched_scan_req = request ; nl80211_send_sched_scan ( rdev , dev , NL80211_CMD_START_SCHED_SCAN ) ; goto out ; } out_free : kfree ( request ) ; out : return err ; }
<S2SV_ModStart> tmp ) { request -> ssids [ i ] . ssid_len = nla_len ( attr ) ; <S2SV_ModStart> ) ) ; <S2SV_ModEnd> i ++ ;
92
CWE-476 static int tower_probe ( struct usb_interface * interface , const struct usb_device_id * id ) { struct device * idev = & interface -> dev ; struct usb_device * udev = interface_to_usbdev ( interface ) ; struct lego_usb_tower * dev = NULL ; struct usb_host_interface * iface_desc ; struct usb_endpoint_descriptor * endpoint ; struct tower_get_version_reply get_version_reply ; int i ; int retval = - ENOMEM ; int result ; dev = kmalloc ( sizeof ( struct lego_usb_tower ) , GFP_KERNEL ) ; if ( ! dev ) goto exit ; mutex_init ( & dev -> lock ) ; dev -> udev = udev ; dev -> open_count = 0 ; dev -> read_buffer = NULL ; dev -> read_buffer_length = 0 ; dev -> read_packet_length = 0 ; spin_lock_init ( & dev -> read_buffer_lock ) ; dev -> packet_timeout_jiffies = msecs_to_jiffies ( packet_timeout ) ; dev -> read_last_arrival = jiffies ; init_waitqueue_head ( & dev -> read_wait ) ; init_waitqueue_head ( & dev -> write_wait ) ; dev -> interrupt_in_buffer = NULL ; dev -> interrupt_in_endpoint = NULL ; dev -> interrupt_in_urb = NULL ; dev -> interrupt_in_running = 0 ; dev -> interrupt_in_done = 0 ; dev -> interrupt_out_buffer = NULL ; dev -> interrupt_out_endpoint = NULL ; dev -> interrupt_out_urb = NULL ; dev -> interrupt_out_busy = 0 ; iface_desc = interface -> cur_altsetting ; for ( i = 0 ; i < iface_desc -> desc . bNumEndpoints ; ++ i ) { endpoint = & iface_desc -> endpoint [ i ] . desc ; if ( usb_endpoint_xfer_int ( endpoint ) ) { if ( usb_endpoint_dir_in ( endpoint ) ) dev -> interrupt_in_endpoint = endpoint ; else dev -> interrupt_out_endpoint = endpoint ; } } if ( dev -> interrupt_in_endpoint == NULL ) { dev_err ( idev , "interrupt<S2SV_blank>in<S2SV_blank>endpoint<S2SV_blank>not<S2SV_blank>found\\n" ) ; goto error ; } if ( dev -> interrupt_out_endpoint == NULL ) { dev_err ( idev , "interrupt<S2SV_blank>out<S2SV_blank>endpoint<S2SV_blank>not<S2SV_blank>found\\n" ) ; goto error ; } dev -> read_buffer = kmalloc ( read_buffer_size , GFP_KERNEL ) ; if ( ! dev -> read_buffer ) goto error ; dev -> interrupt_in_buffer = kmalloc ( usb_endpoint_maxp ( dev -> interrupt_in_endpoint ) , GFP_KERNEL ) ; if ( ! dev -> interrupt_in_buffer ) goto error ; dev -> interrupt_in_urb = usb_alloc_urb ( 0 , GFP_KERNEL ) ; if ( ! dev -> interrupt_in_urb ) goto error ; dev -> interrupt_out_buffer = kmalloc ( write_buffer_size , GFP_KERNEL ) ; if ( ! dev -> interrupt_out_buffer ) goto error ; dev -> interrupt_out_urb = usb_alloc_urb ( 0 , GFP_KERNEL ) ; if ( ! dev -> interrupt_out_urb ) goto error ; dev -> interrupt_in_interval = interrupt_in_interval ? interrupt_in_interval : dev -> interrupt_in_endpoint -> bInterval ; dev -> interrupt_out_interval = interrupt_out_interval ? interrupt_out_interval : dev -> interrupt_out_endpoint -> bInterval ; <S2SV_StartBug> usb_set_intfdata ( interface , dev ) <S2SV_EndBug> ; retval = usb_register_dev ( interface , & tower_class ) ; if ( retval ) { dev_err ( idev , "Not<S2SV_blank>able<S2SV_blank>to<S2SV_blank>get<S2SV_blank>a<S2SV_blank>minor<S2SV_blank>for<S2SV_blank>this<S2SV_blank>device.\\n" ) ; usb_set_intfdata ( interface , NULL ) ; goto error ; } dev -> minor = interface -> minor ; dev_info ( & interface -> dev , "LEGO<S2SV_blank>USB<S2SV_blank>Tower<S2SV_blank>#%d<S2SV_blank>now<S2SV_blank>attached<S2SV_blank>to<S2SV_blank>major<S2SV_blank>" "%d<S2SV_blank>minor<S2SV_blank>%d\\n" , ( dev -> minor - LEGO_USB_TOWER_MINOR_BASE ) , USB_MAJOR , dev -> minor ) ; result = usb_control_msg ( udev , usb_rcvctrlpipe ( udev , 0 ) , LEGO_USB_TOWER_REQUEST_GET_VERSION , USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_DEVICE , 0 , 0 , & get_version_reply , sizeof ( get_version_reply ) , 1000 ) ; if ( result < 0 ) { dev_err ( idev , "LEGO<S2SV_blank>USB<S2SV_blank>Tower<S2SV_blank>get<S2SV_blank>version<S2SV_blank>control<S2SV_blank>request<S2SV_blank>failed\\n" ) ; retval = result ; goto error ; } dev_info ( & interface -> dev , "LEGO<S2SV_blank>USB<S2SV_blank>Tower<S2SV_blank>firmware<S2SV_blank>version<S2SV_blank>is<S2SV_blank>%d.%d<S2SV_blank>" "build<S2SV_blank>%d\\n" , get_version_reply . major , get_version_reply . minor , le16_to_cpu ( get_version_reply . <S2SV_StartBug> build_no ) ) ; exit : return retval ; <S2SV_EndBug> error : tower_delete ( dev ) ; return retval ; }
<S2SV_ModStart> -> bInterval ; <S2SV_ModEnd> result = usb_control_msg <S2SV_ModStart> ) ) ; usb_set_intfdata ( interface , dev ) ; retval = usb_register_dev ( interface , & tower_class ) ; if ( retval ) { dev_err ( idev , "Not<S2SV_blank>able<S2SV_blank>to<S2SV_blank>get<S2SV_blank>a<S2SV_blank>minor<S2SV_blank>for<S2SV_blank>this<S2SV_blank>device.\\n" ) ; usb_set_intfdata ( interface , NULL ) ; goto error ; } dev -> minor = interface -> minor ; dev_info ( & interface -> dev , "LEGO<S2SV_blank>USB<S2SV_blank>Tower<S2SV_blank>#%d<S2SV_blank>now<S2SV_blank>attached<S2SV_blank>to<S2SV_blank>major<S2SV_blank>" "%d<S2SV_blank>minor<S2SV_blank>%d\\n" , ( dev -> minor - LEGO_USB_TOWER_MINOR_BASE ) , USB_MAJOR , dev -> minor ) ;
93
CWE-119 static int netlbl_cipsov4_add_common ( struct genl_info * info , struct cipso_v4_doi * doi_def ) { struct nlattr * nla ; int nla_rem ; u32 iter = 0 ; doi_def -> doi = nla_get_u32 ( info -> attrs [ NLBL_CIPSOV4_A_DOI ] ) ; if ( nla_validate_nested ( info -> attrs [ NLBL_CIPSOV4_A_TAGLST ] , NLBL_CIPSOV4_A_MAX , netlbl_cipsov4_genl_policy ) != 0 ) return - EINVAL ; nla_for_each_nested ( nla , info -> attrs [ NLBL_CIPSOV4_A_TAGLST ] , nla_rem ) if ( nla -> nla_type <S2SV_StartBug> == NLBL_CIPSOV4_A_TAG ) { if ( iter > CIPSO_V4_TAG_MAXCNT ) return - EINVAL ; <S2SV_EndBug> doi_def -> tags [ iter ++ ] = nla_get_u8 ( nla ) ; } if ( iter < CIPSO_V4_TAG_MAXCNT <S2SV_StartBug> ) <S2SV_StartBug> <S2SV_EndBug> doi_def -> tags [ iter ] = CIPSO_V4_TAG_INVALID ; return 0 ; <S2SV_EndBug> }
<S2SV_ModStart> if ( iter >= <S2SV_ModEnd> CIPSO_V4_TAG_MAXCNT ) return <S2SV_ModStart> ) ; } while <S2SV_ModEnd> ( iter < <S2SV_ModStart> tags [ iter ++
94
CWE-125 static int count_comp_fors ( struct compiling * c , const node * n ) { int n_fors = 0 ; int is_async <S2SV_StartBug> ; count_comp_for : <S2SV_EndBug> is_async = 0 ; n_fors ++ ; REQ ( n , comp_for ) ; <S2SV_StartBug> if ( TYPE ( CHILD ( n , 0 ) ) == ASYNC ) { is_async = 1 ; <S2SV_EndBug> } if ( NCH ( <S2SV_StartBug> n ) == ( 5 + is_async <S2SV_EndBug> ) ) { n = CHILD ( n <S2SV_StartBug> , 4 + is_async ) ; } else <S2SV_EndBug> { return n_fors ; } count_comp_iter : REQ ( n , comp_iter ) ; n = CHILD ( n , 0 ) ; if ( TYPE ( n ) == comp_for ) goto count_comp_for ; else if ( TYPE ( n ) == comp_if ) { if ( NCH ( n ) == 3 ) { n = CHILD ( n , 2 ) ; goto count_comp_iter ; } else <S2SV_StartBug> return n_fors ; } PyErr_SetString <S2SV_EndBug> ( PyExc_SystemError , "logic<S2SV_blank>error<S2SV_blank>in<S2SV_blank>count_comp_fors" ) ; return - 1 ; }
<S2SV_ModStart> = 0 ; count_comp_for : <S2SV_ModEnd> n_fors ++ ; <S2SV_ModStart> ; if ( NCH ( n ) == 2 ) { REQ ( CHILD ( n , 0 ) , NAME ) ; assert ( strcmp ( STR ( CHILD ( n , 0 ) ) , "async" ) == 0 ) ; n = CHILD ( n , 1 ) ; } else if ( NCH ( n ) == 1 ) { n = CHILD ( n , 0 ) ; } else { goto error <S2SV_ModEnd> ; } if <S2SV_ModStart> == ( 5 <S2SV_ModEnd> ) ) { <S2SV_ModStart> n , 4 <S2SV_ModEnd> ) ; } <S2SV_ModStart> n_fors ; } error :
95
CWE-476 static Sdb * store_versioninfo_gnu_verdef ( ELFOBJ * bin , Elf_ ( Shdr ) * shdr , int sz ) { const char * section_name = "" ; const char * link_section_name = "" ; char * end = NULL ; Elf_ ( Shdr ) * link_shdr = NULL ; ut8 dfs [ sizeof ( Elf_ ( Verdef ) ) ] = { 0 } ; Sdb * sdb ; int cnt , i ; if ( shdr -> sh_link > bin -> ehdr . e_shnum ) { return false ; } link_shdr = & bin -> shdr [ shdr -> sh_link ] ; if ( shdr -> sh_size < 1 || shdr -> sh_size > SIZE_MAX ) { return false ; } Elf_ ( Verdef ) * defs = calloc ( shdr -> sh_size , sizeof ( char ) ) ; if ( ! defs ) { return false ; } if ( bin -> shstrtab && shdr -> sh_name < bin -> shstrtab_size ) { section_name = & bin -> shstrtab [ shdr -> sh_name ] ; } if ( link_shdr && bin -> shstrtab && link_shdr -> sh_name < bin -> shstrtab_size ) { link_section_name = & bin -> shstrtab [ link_shdr -> sh_name ] ; } if ( ! defs ) { bprintf ( "Warning:<S2SV_blank>Cannot<S2SV_blank>allocate<S2SV_blank>memory<S2SV_blank>(Check<S2SV_blank>Elf_(Verdef))\\n" ) ; return NULL ; } sdb = sdb_new0 ( ) ; end = ( char * ) defs + shdr -> sh_size ; sdb_set ( sdb , "section_name" , section_name , 0 ) ; sdb_num_set ( sdb , "entries" , shdr -> sh_info , 0 ) ; sdb_num_set ( sdb , "addr" , shdr -> sh_addr , 0 ) ; sdb_num_set ( sdb , "offset" , shdr -> sh_offset , 0 ) ; sdb_num_set ( sdb , "link" , shdr -> sh_link , 0 ) ; sdb_set ( sdb , "link_section_name" , link_section_name , 0 ) ; for ( cnt = 0 , i = 0 ; i >= 0 && cnt < shdr -> sh_info && ( end - ( char * ) defs > i ) ; ++ cnt ) { Sdb * sdb_verdef = sdb_new0 ( ) ; char * vstart = ( ( char * ) defs ) + i ; char key [ 32 ] = { 0 } ; Elf_ ( Verdef ) * verdef = ( Elf_ ( Verdef ) * ) vstart ; Elf_ ( Verdaux ) aux = { 0 } ; int j = 0 ; int isum = 0 ; r_buf_read_at ( bin -> b , shdr -> sh_offset + i , dfs , sizeof ( Elf_ ( Verdef ) ) ) ; verdef -> vd_version = READ16 ( dfs , j ) verdef -> vd_flags = READ16 ( dfs , j ) verdef -> vd_ndx = READ16 ( dfs , j ) verdef -> vd_cnt = READ16 ( dfs , j ) verdef -> vd_hash = READ32 ( dfs , j ) verdef -> vd_aux = READ32 ( dfs , j ) verdef -> vd_next = READ32 ( dfs , j ) int vdaux = verdef -> vd_aux ; if ( <S2SV_StartBug> vdaux < 1 || ( char * ) UINTPTR_MAX - vstart < vdaux ) { sdb_free ( sdb_verdef <S2SV_EndBug> ) ; goto out_error ; } vstart += vdaux ; if ( vstart > end || end - vstart < sizeof ( Elf_ ( Verdaux ) ) ) { sdb_free ( sdb_verdef ) ; goto out_error ; } j = 0 ; aux . vda_name = READ32 ( vstart , j ) aux . vda_next = READ32 ( vstart , j ) isum = i + verdef -> vd_aux ; if ( aux . vda_name > bin -> dynstr_size ) { sdb_free ( sdb_verdef ) ; goto out_error ; } sdb_num_set ( sdb_verdef , "idx" , i , 0 ) ; sdb_num_set ( sdb_verdef , "vd_version" , verdef -> vd_version , 0 ) ; sdb_num_set ( sdb_verdef , "vd_ndx" , verdef -> vd_ndx , 0 ) ; sdb_num_set ( sdb_verdef , "vd_cnt" , verdef -> vd_cnt , 0 ) ; sdb_set ( sdb_verdef , "vda_name" , & bin -> dynstr [ aux . vda_name ] , 0 ) ; sdb_set ( sdb_verdef , "flags" , get_ver_flags ( verdef -> vd_flags ) , 0 ) ; for ( j = 1 ; j < verdef -> vd_cnt ; ++ j ) { int k ; Sdb * sdb_parent = sdb_new0 ( ) ; isum += aux . vda_next ; vstart += aux . vda_next ; if ( vstart > end || end - vstart < sizeof ( Elf_ ( Verdaux ) ) ) { sdb_free ( sdb_verdef ) ; sdb_free ( sdb_parent ) ; goto out_error ; } k = 0 ; aux . vda_name = READ32 ( vstart , k ) aux . vda_next = READ32 ( vstart , k ) if ( aux . vda_name > bin -> dynstr_size ) { sdb_free ( sdb_verdef ) ; sdb_free ( sdb_parent ) ; goto out_error ; } sdb_num_set ( sdb_parent , "idx" , isum , 0 ) ; sdb_num_set ( sdb_parent , "parent" , j , 0 ) ; sdb_set ( sdb_parent , "vda_name" , & bin -> dynstr [ aux . vda_name ] , 0 ) ; snprintf ( key , sizeof ( key ) , "parent%d" , j - 1 ) ; sdb_ns_set ( sdb_verdef , key , sdb_parent ) ; } snprintf ( key , sizeof ( key ) , "verdef%d" , cnt ) ; sdb_ns_set ( sdb , key , sdb_verdef ) ; if ( ! verdef -> vd_next ) { sdb_free ( sdb_verdef ) ; goto out_error ; } if ( ( st32 ) verdef -> vd_next < 1 ) { eprintf ( "Warning:<S2SV_blank>Invalid<S2SV_blank>vd_next<S2SV_blank>in<S2SV_blank>the<S2SV_blank>ELF<S2SV_blank>version\\n" ) ; break ; } i += verdef -> vd_next ; } free ( defs ) ; return sdb ; out_error : free ( defs ) ; sdb_free ( sdb ) ; return NULL ; }
<S2SV_ModStart> < 1 || vstart + vdaux < vstart <S2SV_ModEnd> ) { sdb_free
96
CWE-835 static const u_char * ikev1_nonce_print ( netdissect_options * ndo , u_char tpay _U_ , const struct isakmp_gen * ext , u_int item_len _U_ , const u_char * ep , uint32_t phase _U_ , uint32_t doi _U_ , uint32_t proto _U_ , int depth _U_ ) { struct isakmp_gen e ; ND_PRINT ( ( ndo , "%s:" , NPSTR ( ISAKMP_NPTYPE_NONCE ) ) ) ; ND_TCHECK ( * ext ) ; UNALIGNED_MEMCPY ( & e , ext , sizeof ( e ) ) ; ND_PRINT <S2SV_StartBug> ( ( ndo , "<S2SV_blank>n<S2SV_blank>len=%d" , ntohs ( e . len ) - 4 ) ) ; <S2SV_StartBug> if ( 2 < <S2SV_EndBug> ndo -> ndo_vflag && 4 < ntohs ( e . len ) ) { <S2SV_EndBug> ND_PRINT ( ( ndo , "<S2SV_blank>" ) ) ; if ( ! rawprint ( ndo , ( const uint8_t * ) ( ext + 1 ) , ntohs ( e . len ) - 4 ) ) goto <S2SV_StartBug> trunc ; } else if ( 1 < ndo -> ndo_vflag && 4 < ntohs ( e . len ) ) { <S2SV_EndBug> ND_PRINT ( ( ndo , "<S2SV_blank>" ) ) ; if ( ! <S2SV_StartBug> ike_show_somedata ( ndo , ( const u_char * ) ( const uint8_t * ) ( ext + 1 ) <S2SV_EndBug> , ep ) ) goto trunc ; } return ( const <S2SV_StartBug> u_char * ) ext + ntohs ( e . len ) ; trunc : ND_PRINT ( ( <S2SV_EndBug> ndo , "<S2SV_blank>[|%s]" , NPSTR ( ISAKMP_NPTYPE_NONCE ) ) ) ; return NULL ; }
<S2SV_ModStart> ( ndo , "<S2SV_blank>n<S2SV_blank>len=%u" <S2SV_ModEnd> , ntohs ( <S2SV_ModStart> ; if ( ntohs ( e . len ) > 4 ) { if ( <S2SV_ModEnd> ndo -> ndo_vflag <S2SV_ModStart> ndo -> ndo_vflag > 2 <S2SV_ModEnd> ) { ND_PRINT <S2SV_ModStart> else if ( <S2SV_ModEnd> ndo -> ndo_vflag <S2SV_ModStart> ndo -> ndo_vflag > 1 <S2SV_ModEnd> ) { ND_PRINT <S2SV_ModStart> * ) ( <S2SV_ModEnd> ext + 1 <S2SV_ModStart> trunc ; } }
97
CWE-264 static int futex_wait_requeue_pi ( u32 __user * uaddr , unsigned int flags , u32 val , ktime_t * abs_time , u32 bitset , u32 __user * uaddr2 ) { struct hrtimer_sleeper timeout , * to = NULL ; struct rt_mutex_waiter rt_waiter ; struct rt_mutex * pi_mutex = NULL ; struct futex_hash_bucket * hb ; union futex_key key2 = FUTEX_KEY_INIT ; struct futex_q q = futex_q_init ; int res , ret ; if ( uaddr == uaddr2 ) return - EINVAL ; if ( ! bitset ) return - EINVAL ; if ( abs_time ) { to = & timeout ; hrtimer_init_on_stack ( & to -> timer , ( flags & FLAGS_CLOCKRT ) ? CLOCK_REALTIME : CLOCK_MONOTONIC , HRTIMER_MODE_ABS ) ; hrtimer_init_sleeper ( to , current ) ; hrtimer_set_expires_range_ns ( & to -> timer , * abs_time , current -> timer_slack_ns ) ; } debug_rt_mutex_init_waiter ( & rt_waiter ) ; RB_CLEAR_NODE ( & rt_waiter . pi_tree_entry ) ; RB_CLEAR_NODE ( & rt_waiter . tree_entry ) ; rt_waiter . task = NULL ; ret = get_futex_key ( uaddr2 , flags & FLAGS_SHARED , & key2 , VERIFY_WRITE ) ; if ( unlikely ( ret != 0 ) ) goto out ; q . bitset = bitset ; q . rt_waiter = & rt_waiter ; q . requeue_pi_key = & key2 ; ret = futex_wait_setup ( uaddr , val , flags , & q , & hb ) ; if ( ret ) goto out_key2 <S2SV_StartBug> ; futex_wait_queue_me ( hb , & q , <S2SV_EndBug> to ) ; spin_lock ( & hb -> lock ) ; ret = handle_early_requeue_pi_wakeup ( hb , & q , & key2 , to ) ; spin_unlock ( & hb -> lock ) ; if ( ret ) goto out_put_keys ; if ( ! q . rt_waiter ) { if ( q . pi_state && ( q . pi_state -> owner != current ) ) { spin_lock ( q . lock_ptr ) ; ret = fixup_pi_state_owner ( uaddr2 , & q , current ) ; spin_unlock ( q . lock_ptr ) ; } } else { WARN_ON ( ! q . pi_state ) ; pi_mutex = & q . pi_state -> pi_mutex ; ret = rt_mutex_finish_proxy_lock ( pi_mutex , to , & rt_waiter , 1 ) ; debug_rt_mutex_free_waiter ( & rt_waiter ) ; spin_lock ( q . lock_ptr ) ; res = fixup_owner ( uaddr2 , & q , ! ret ) ; if ( res ) ret = ( res < 0 ) ? res : 0 ; unqueue_me_pi ( & q ) ; } if ( ret == - EFAULT ) { if ( pi_mutex && rt_mutex_owner ( pi_mutex ) == current ) rt_mutex_unlock ( pi_mutex ) ; } else if ( ret == - EINTR ) { ret = - EWOULDBLOCK ; } out_put_keys : put_futex_key ( & q . key ) ; out_key2 : put_futex_key ( & key2 ) ; out : if ( to ) { hrtimer_cancel ( & to -> timer ) ; destroy_hrtimer_on_stack ( & to -> timer ) ; } return ret ; }
<S2SV_ModStart> goto out_key2 ; if ( match_futex ( & q . key , & key2 ) ) { ret = - EINVAL ; goto out_put_keys ; }
98
CWE-862 <S2SV_StartBug> static void construct_get_dest_keyring ( struct key * * <S2SV_EndBug> _dest_keyring ) { struct request_key_auth * rka ; const struct cred * cred = current_cred ( ) ; struct key * dest_keyring = * _dest_keyring , * authkey ; kenter ( "%p" , dest_keyring <S2SV_StartBug> ) ; if ( dest_keyring <S2SV_EndBug> ) { key_get ( dest_keyring ) ; } else { <S2SV_EndBug> <S2SV_StartBug> switch ( cred -> jit_keyring ) { case KEY_REQKEY_DEFL_DEFAULT : case KEY_REQKEY_DEFL_REQUESTOR_KEYRING : if ( cred -> request_key_auth ) { authkey = cred -> request_key_auth ; down_read ( & authkey -> sem ) ; rka = authkey -> payload . data [ 0 ] ; if ( ! test_bit ( KEY_FLAG_REVOKED , & authkey -> flags ) ) dest_keyring = key_get ( rka -> dest_keyring ) ; up_read ( & authkey -> sem ) ; if ( dest_keyring ) break ; <S2SV_EndBug> <S2SV_StartBug> } case KEY_REQKEY_DEFL_THREAD_KEYRING : dest_keyring = key_get ( cred -> thread_keyring ) ; if ( dest_keyring ) break ; case KEY_REQKEY_DEFL_PROCESS_KEYRING : dest_keyring = key_get ( cred -> process_keyring ) ; if ( dest_keyring ) break ; case KEY_REQKEY_DEFL_SESSION_KEYRING : rcu_read_lock ( ) ; dest_keyring = key_get ( rcu_dereference ( cred -> session_keyring ) ) ; rcu_read_unlock ( ) ; if ( dest_keyring ) break ; case KEY_REQKEY_DEFL_USER_SESSION_KEYRING : dest_keyring = key_get ( cred -> user -> session_keyring ) ; break ; case KEY_REQKEY_DEFL_USER_KEYRING : dest_keyring = key_get ( cred -> user -> uid_keyring ) ; break ; case KEY_REQKEY_DEFL_GROUP_KEYRING : default : BUG ( ) ; } } <S2SV_EndBug> <S2SV_StartBug> * _dest_keyring = dest_keyring ; kleave ( "<S2SV_blank>[dk<S2SV_blank>%d]" , key_serial ( dest_keyring ) ) ; return ; <S2SV_EndBug> <S2SV_StartBug> }
<S2SV_ModStart> <S2SV_null> <S2SV_null> static int <S2SV_ModEnd> construct_get_dest_keyring ( struct <S2SV_ModStart> * authkey ; int ret ; <S2SV_ModStart> } else { bool do_perm_check = true ; <S2SV_ModStart> ( dest_keyring ) { do_perm_check = false ; break ; } <S2SV_ModEnd> } case KEY_REQKEY_DEFL_THREAD_KEYRING <S2SV_ModStart> ) ; } if ( dest_keyring && do_perm_check ) { ret = key_permission ( make_key_ref ( dest_keyring , 1 ) , KEY_NEED_WRITE ) ; if ( ret ) { key_put ( dest_keyring ) ; return ret ; } } <S2SV_ModStart> ) ; return 0
99
CWE-763 static OM_uint32 init_ctx_new ( OM_uint32 * minor_status , spnego_gss_cred_id_t spcred , gss_ctx_id_t * ctx , send_token_flag * tokflag ) { OM_uint32 ret ; spnego_gss_ctx_id_t sc = NULL ; <S2SV_StartBug> sc = create_spnego_ctx <S2SV_EndBug> ( ) ; if ( sc == NULL ) return GSS_S_FAILURE ; ret = get_negotiable_mechs ( minor_status , spcred , GSS_C_INITIATE , & sc -> mech_set ) ; if ( ret != GSS_S_COMPLETE ) goto cleanup ; sc -> internal_mech = & sc -> mech_set -> elements [ 0 ] ; if ( put_mech_set ( sc -> mech_set , & sc -> DER_mechTypes ) < 0 ) { ret = GSS_S_FAILURE ; goto cleanup ; } sc -> ctx_handle = GSS_C_NO_CONTEXT ; * ctx = ( gss_ctx_id_t ) sc ; sc = NULL ; * tokflag = INIT_TOKEN_SEND ; ret = GSS_S_CONTINUE_NEEDED ; cleanup : release_spnego_ctx ( & sc ) ; return ret ; }
<S2SV_ModStart> = create_spnego_ctx ( 1