instruction
stringclasses
1 value
input
stringlengths
31
235k
output
class label
2 classes
Categorize the following code snippet as vulnerable or not. True or False
u_short ctlpeerstatus ( register struct peer * p ) { u_short status ; status = p -> status ; if ( FLAG_CONFIG & p -> flags ) status |= CTL_PST_CONFIG ; if ( p -> keyid ) status |= CTL_PST_AUTHENABLE ; if ( FLAG_AUTHENTIC & p -> flags ) status |= CTL_PST_AUTHENTIC ; if ( p -> reach ) status |= CTL_PST_REACH ; if ( MDF_TXONLY_MASK & p -> cast_flags ) status |= CTL_PST_BCAST ; return CTL_PEER_STATUS ( status , p -> num_events , p -> last_event ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
int EVP_CIPHER_CTX_set_key_length ( EVP_CIPHER_CTX * c , int keylen ) { if ( c -> cipher -> flags & EVP_CIPH_CUSTOM_KEY_LENGTH ) return EVP_CIPHER_CTX_ctrl ( c , EVP_CTRL_SET_KEY_LENGTH , keylen , NULL ) ; if ( c -> key_len == keylen ) return 1 ; if ( ( keylen > 0 ) && ( c -> cipher -> flags & EVP_CIPH_VARIABLE_LENGTH ) ) { c -> key_len = keylen ; return 1 ; } EVPerr ( EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH , EVP_R_INVALID_KEY_LENGTH ) ; return 0 ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static bool script_support_content ( struct mail_user * user , const char * * content_type , const char * filename ) { struct fts_parser_script_user * suser = SCRIPT_USER_CONTEXT ( user ) ; const struct content * content ; const char * extension ; if ( suser == NULL ) { suser = p_new ( user -> pool , struct fts_parser_script_user , 1 ) ; p_array_init ( & suser -> content , user -> pool , 32 ) ; MODULE_CONTEXT_SET ( user , fts_parser_script_user_module , suser ) ; } if ( array_count ( & suser -> content ) == 0 ) { if ( script_contents_read ( user ) < 0 ) return FALSE ; } if ( strcmp ( * content_type , "application/octet-stream" ) == 0 ) { if ( filename == NULL ) return FALSE ; extension = strrchr ( filename , '.' ) ; if ( extension == NULL ) return FALSE ; extension = filename + 1 ; array_foreach ( & suser -> content , content ) { if ( content -> extensions != NULL && str_array_icase_find ( content -> extensions , extension ) ) { * content_type = content -> content_type ; return TRUE ; } } } else { array_foreach ( & suser -> content , content ) { if ( strcmp ( content -> content_type , * content_type ) == 0 ) return TRUE ; } } return FALSE ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static inline void NVRAM_set_word ( m48t59_t * nvram , uint32_t addr , uint16_t value ) { m48t59_set_addr ( nvram , addr ) ; m48t59_write ( nvram , value >> 8 ) ; m48t59_set_addr ( nvram , addr + 1 ) ; m48t59_write ( nvram , value & 0xFF ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
void vp9_read_frame_size ( struct vp9_read_bit_buffer * rb , int * width , int * height ) { const int w = vp9_rb_read_literal ( rb , 16 ) + 1 ; const int h = vp9_rb_read_literal ( rb , 16 ) + 1 ; * width = w ; * height = h ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static void create_new_objects ( void ) { int dbnum ; prep_status ( "Restoring database schemas in the new cluster\n" ) ; for ( dbnum = 0 ; dbnum < old_cluster . dbarr . ndbs ; dbnum ++ ) { char sql_file_name [ MAXPGPATH ] , log_file_name [ MAXPGPATH ] ; DbInfo * old_db = & old_cluster . dbarr . dbs [ dbnum ] ; pg_log ( PG_STATUS , "%s" , old_db -> db_name ) ; snprintf ( sql_file_name , sizeof ( sql_file_name ) , DB_DUMP_FILE_MASK , old_db -> db_oid ) ; snprintf ( log_file_name , sizeof ( log_file_name ) , DB_DUMP_LOG_FILE_MASK , old_db -> db_oid ) ; parallel_exec_prog ( log_file_name , NULL , "\"%s/pg_restore\" %s --exit-on-error --verbose --dbname \"%s\" \"%s\"" , new_cluster . bindir , cluster_conn_opts ( & new_cluster ) , old_db -> db_name , sql_file_name ) ; } while ( reap_child ( true ) == true ) ; end_progress_output ( ) ; check_ok ( ) ; if ( GET_MAJOR_VERSION ( old_cluster . major_version ) < 903 ) set_frozenxids ( true ) ; get_db_and_rel_infos ( & new_cluster ) ; }
1True
Categorize the following code snippet as vulnerable or not. True or False
static int decode_nal_units ( H264Context * h , const uint8_t * buf , int buf_size , int parse_extradata ) { AVCodecContext * const avctx = h -> avctx ; H264Context * hx ; int buf_index ; int context_count ; int next_avc ; int pass = ! ( avctx -> active_thread_type & FF_THREAD_FRAME ) ; int nals_needed = 0 ; int nal_index ; int idr_cleared = 0 ; int first_slice = 0 ; int ret = 0 ; h -> nal_unit_type = 0 ; if ( ! h -> slice_context_count ) h -> slice_context_count = 1 ; h -> max_contexts = h -> slice_context_count ; if ( ! ( avctx -> flags2 & CODEC_FLAG2_CHUNKS ) ) { h -> current_slice = 0 ; if ( ! h -> first_field ) h -> cur_pic_ptr = NULL ; ff_h264_reset_sei ( h ) ; } if ( h -> nal_length_size == 4 ) { if ( buf_size > 8 && AV_RB32 ( buf ) == 1 && AV_RB32 ( buf + 5 ) > ( unsigned ) buf_size ) { h -> is_avc = 0 ; } else if ( buf_size > 3 && AV_RB32 ( buf ) > 1 && AV_RB32 ( buf ) <= ( unsigned ) buf_size ) h -> is_avc = 1 ; } for ( ; pass <= 1 ; pass ++ ) { buf_index = 0 ; context_count = 0 ; next_avc = h -> is_avc ? 0 : buf_size ; nal_index = 0 ; for ( ; ; ) { int consumed ; int dst_length ; int bit_length ; const uint8_t * ptr ; int i , nalsize = 0 ; int err ; if ( buf_index >= next_avc ) { if ( buf_index >= buf_size - h -> nal_length_size ) break ; nalsize = 0 ; for ( i = 0 ; i < h -> nal_length_size ; i ++ ) nalsize = ( nalsize << 8 ) | buf [ buf_index ++ ] ; if ( nalsize <= 0 || nalsize > buf_size - buf_index ) { av_log ( h -> avctx , AV_LOG_ERROR , "AVC: nal size %d\n" , nalsize ) ; break ; } next_avc = buf_index + nalsize ; } else { for ( ; buf_index + 3 < next_avc ; buf_index ++ ) if ( buf [ buf_index ] == 0 && buf [ buf_index + 1 ] == 0 && buf [ buf_index + 2 ] == 1 ) break ; if ( buf_index + 3 >= buf_size ) { buf_index = buf_size ; break ; } buf_index += 3 ; if ( buf_index >= next_avc ) continue ; } hx = h -> thread_context [ context_count ] ; ptr = ff_h264_decode_nal ( hx , buf + buf_index , & dst_length , & consumed , next_avc - buf_index ) ; if ( ptr == NULL || dst_length < 0 ) { ret = - 1 ; goto end ; } i = buf_index + consumed ; if ( ( h -> workaround_bugs & FF_BUG_AUTODETECT ) && i + 3 < next_avc && buf [ i ] == 0x00 && buf [ i + 1 ] == 0x00 && buf [ i + 2 ] == 0x01 && buf [ i + 3 ] == 0xE0 ) h -> workaround_bugs |= FF_BUG_TRUNCATED ; if ( ! ( h -> workaround_bugs & FF_BUG_TRUNCATED ) ) while ( dst_length > 0 && ptr [ dst_length - 1 ] == 0 ) dst_length -- ; bit_length = ! dst_length ? 0 : ( 8 * dst_length - decode_rbsp_trailing ( h , ptr + dst_length - 1 ) ) ; if ( h -> avctx -> debug & FF_DEBUG_STARTCODE ) av_log ( h -> avctx , AV_LOG_DEBUG , "NAL %d/%d at %d/%d length %d pass %d\n" , hx -> nal_unit_type , hx -> nal_ref_idc , buf_index , buf_size , dst_length , pass ) ; if ( h -> is_avc && ( nalsize != consumed ) && nalsize ) av_log ( h -> avctx , AV_LOG_DEBUG , "AVC: Consumed only %d bytes instead of %d\n" , consumed , nalsize ) ; buf_index += consumed ; nal_index ++ ; if ( pass == 0 ) { switch ( hx -> nal_unit_type ) { case NAL_SPS : case NAL_PPS : nals_needed = nal_index ; break ; case NAL_DPA : case NAL_IDR_SLICE : case NAL_SLICE : init_get_bits ( & hx -> gb , ptr , bit_length ) ; if ( ! get_ue_golomb ( & hx -> gb ) || ! first_slice ) nals_needed = nal_index ; if ( ! first_slice ) first_slice = hx -> nal_unit_type ; } continue ; } if ( ! first_slice ) switch ( hx -> nal_unit_type ) { case NAL_DPA : case NAL_IDR_SLICE : case NAL_SLICE : first_slice = hx -> nal_unit_type ; } if ( avctx -> skip_frame >= AVDISCARD_NONREF && h -> nal_ref_idc == 0 && h -> nal_unit_type != NAL_SEI ) continue ; again : if ( parse_extradata ) { switch ( hx -> nal_unit_type ) { case NAL_IDR_SLICE : case NAL_SLICE : case NAL_DPA : case NAL_DPB : case NAL_DPC : av_log ( h -> avctx , AV_LOG_WARNING , "Ignoring NAL %d in global header/extradata\n" , hx -> nal_unit_type ) ; case NAL_AUXILIARY_SLICE : hx -> nal_unit_type = NAL_FF_IGNORE ; } } err = 0 ; switch ( hx -> nal_unit_type ) { case NAL_IDR_SLICE : if ( first_slice != NAL_IDR_SLICE ) { av_log ( h -> avctx , AV_LOG_ERROR , "Invalid mix of idr and non-idr slices\n" ) ; ret = - 1 ; goto end ; } if ( ! idr_cleared ) idr ( h ) ; idr_cleared = 1 ; case NAL_SLICE : init_get_bits ( & hx -> gb , ptr , bit_length ) ; hx -> intra_gb_ptr = hx -> inter_gb_ptr = & hx -> gb ; hx -> data_partitioning = 0 ; if ( ( err = decode_slice_header ( hx , h ) ) ) break ; if ( h -> sei_recovery_frame_cnt >= 0 ) { if ( h -> frame_num != h -> sei_recovery_frame_cnt || hx -> slice_type_nos != AV_PICTURE_TYPE_I ) h -> valid_recovery_point = 1 ; if ( h -> recovery_frame < 0 || ( ( h -> recovery_frame - h -> frame_num ) & ( ( 1 << h -> sps . log2_max_frame_num ) - 1 ) ) > h -> sei_recovery_frame_cnt ) { h -> recovery_frame = ( h -> frame_num + h -> sei_recovery_frame_cnt ) & ( ( 1 << h -> sps . log2_max_frame_num ) - 1 ) ; if ( ! h -> valid_recovery_point ) h -> recovery_frame = h -> frame_num ; } } h -> cur_pic_ptr -> f . key_frame |= ( hx -> nal_unit_type == NAL_IDR_SLICE ) ; if ( hx -> nal_unit_type == NAL_IDR_SLICE || h -> recovery_frame == h -> frame_num ) { h -> recovery_frame = - 1 ; h -> cur_pic_ptr -> recovered = 1 ; } if ( hx -> nal_unit_type == NAL_IDR_SLICE ) h -> frame_recovered |= FRAME_RECOVERED_IDR ; h -> frame_recovered |= 3 * ! ! ( avctx -> flags2 & CODEC_FLAG2_SHOW_ALL ) ; h -> frame_recovered |= 3 * ! ! ( avctx -> flags & CODEC_FLAG_OUTPUT_CORRUPT ) ; # if 1 h -> cur_pic_ptr -> recovered |= h -> frame_recovered ; # else h -> cur_pic_ptr -> recovered |= ! ! ( h -> frame_recovered & FRAME_RECOVERED_IDR ) ; # endif if ( h -> current_slice == 1 ) { if ( ! ( avctx -> flags2 & CODEC_FLAG2_CHUNKS ) ) decode_postinit ( h , nal_index >= nals_needed ) ; if ( h -> avctx -> hwaccel && ( ret = h -> avctx -> hwaccel -> start_frame ( h -> avctx , NULL , 0 ) ) < 0 ) return ret ; if ( CONFIG_H264_VDPAU_DECODER && h -> avctx -> codec -> capabilities & CODEC_CAP_HWACCEL_VDPAU ) ff_vdpau_h264_picture_start ( h ) ; } if ( hx -> redundant_pic_count == 0 && ( avctx -> skip_frame < AVDISCARD_NONREF || hx -> nal_ref_idc ) && ( avctx -> skip_frame < AVDISCARD_BIDIR || hx -> slice_type_nos != AV_PICTURE_TYPE_B ) && ( avctx -> skip_frame < AVDISCARD_NONKEY || hx -> slice_type_nos == AV_PICTURE_TYPE_I ) && avctx -> skip_frame < AVDISCARD_ALL ) { if ( avctx -> hwaccel ) { ret = avctx -> hwaccel -> decode_slice ( avctx , & buf [ buf_index - consumed ] , consumed ) ; if ( ret < 0 ) return ret ; } else if ( CONFIG_H264_VDPAU_DECODER && h -> avctx -> codec -> capabilities & CODEC_CAP_HWACCEL_VDPAU ) { ff_vdpau_add_data_chunk ( h -> cur_pic_ptr -> f . data [ 0 ] , start_code , sizeof ( start_code ) ) ; ff_vdpau_add_data_chunk ( h -> cur_pic_ptr -> f . data [ 0 ] , & buf [ buf_index - consumed ] , consumed ) ; } else context_count ++ ; } break ; case NAL_DPA : init_get_bits ( & hx -> gb , ptr , bit_length ) ; hx -> intra_gb_ptr = hx -> inter_gb_ptr = NULL ; if ( ( err = decode_slice_header ( hx , h ) ) < 0 ) break ; hx -> data_partitioning = 1 ; break ; case NAL_DPB : init_get_bits ( & hx -> intra_gb , ptr , bit_length ) ; hx -> intra_gb_ptr = & hx -> intra_gb ; break ; case NAL_DPC : init_get_bits ( & hx -> inter_gb , ptr , bit_length ) ; hx -> inter_gb_ptr = & hx -> inter_gb ; av_log ( h -> avctx , AV_LOG_ERROR , "Partitioned H.264 support is incomplete\n" ) ; break ; if ( hx -> redundant_pic_count == 0 && hx -> intra_gb_ptr && hx -> data_partitioning && h -> cur_pic_ptr && h -> context_initialized && ( avctx -> skip_frame < AVDISCARD_NONREF || hx -> nal_ref_idc ) && ( avctx -> skip_frame < AVDISCARD_BIDIR || hx -> slice_type_nos != AV_PICTURE_TYPE_B ) && ( avctx -> skip_frame < AVDISCARD_NONKEY || hx -> slice_type_nos == AV_PICTURE_TYPE_I ) && avctx -> skip_frame < AVDISCARD_ALL ) context_count ++ ; break ; case NAL_SEI : init_get_bits ( & h -> gb , ptr , bit_length ) ; ff_h264_decode_sei ( h ) ; break ; case NAL_SPS : init_get_bits ( & h -> gb , ptr , bit_length ) ; if ( ff_h264_decode_seq_parameter_set ( h ) < 0 && ( h -> is_avc ? nalsize : 1 ) ) { av_log ( h -> avctx , AV_LOG_DEBUG , "SPS decoding failure, trying again with the complete NAL\n" ) ; if ( h -> is_avc ) av_assert0 ( next_avc - buf_index + consumed == nalsize ) ; if ( ( next_avc - buf_index + consumed - 1 ) >= INT_MAX / 8 ) break ; init_get_bits ( & h -> gb , & buf [ buf_index + 1 - consumed ] , 8 * ( next_avc - buf_index + consumed - 1 ) ) ; ff_h264_decode_seq_parameter_set ( h ) ; } break ; case NAL_PPS : init_get_bits ( & h -> gb , ptr , bit_length ) ; ff_h264_decode_picture_parameter_set ( h , bit_length ) ; break ; case NAL_AUD : case NAL_END_SEQUENCE : case NAL_END_STREAM : case NAL_FILLER_DATA : case NAL_SPS_EXT : case NAL_AUXILIARY_SLICE : break ; case NAL_FF_IGNORE : break ; default : av_log ( avctx , AV_LOG_DEBUG , "Unknown NAL code: %d (%d bits)\n" , hx -> nal_unit_type , bit_length ) ; } if ( context_count == h -> max_contexts ) { execute_decode_slices ( h , context_count ) ; context_count = 0 ; } if ( err < 0 ) av_log ( h -> avctx , AV_LOG_ERROR , "decode_slice_header error\n" ) ; else if ( err == 1 ) { h -> nal_unit_type = hx -> nal_unit_type ; h -> nal_ref_idc = hx -> nal_ref_idc ; hx = h ; goto again ; } } } if ( context_count ) execute_decode_slices ( h , context_count ) ; end : if ( h -> cur_pic_ptr && ! h -> droppable ) { ff_thread_report_progress ( & h -> cur_pic_ptr -> tf , INT_MAX , h -> picture_structure == PICT_BOTTOM_FIELD ) ; } return ( ret < 0 ) ? ret : buf_index ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
void vp9_print_modes_and_motion_vectors ( VP9_COMMON * cm , const char * file ) { int mi_row ; int mi_col ; int mi_index = 0 ; FILE * mvs = fopen ( file , "a" ) ; MODE_INFO * * mi = NULL ; int rows = cm -> mi_rows ; int cols = cm -> mi_cols ; print_mi_data ( cm , mvs , "Partitions:" , offsetof ( MB_MODE_INFO , sb_type ) ) ; print_mi_data ( cm , mvs , "Modes:" , offsetof ( MB_MODE_INFO , mode ) ) ; print_mi_data ( cm , mvs , "Skips:" , offsetof ( MB_MODE_INFO , skip ) ) ; print_mi_data ( cm , mvs , "Ref frame:" , offsetof ( MB_MODE_INFO , ref_frame [ 0 ] ) ) ; print_mi_data ( cm , mvs , "Transform:" , offsetof ( MB_MODE_INFO , tx_size ) ) ; print_mi_data ( cm , mvs , "UV Modes:" , offsetof ( MB_MODE_INFO , uv_mode ) ) ; log_frame_info ( cm , "Vectors " , mvs ) ; for ( mi_row = 0 ; mi_row < rows ; mi_row ++ ) { fprintf ( mvs , "V " ) ; for ( mi_col = 0 ; mi_col < cols ; mi_col ++ ) { fprintf ( mvs , "%4d:%4d " , mi [ mi_index ] -> mbmi . mv [ 0 ] . as_mv . row , mi [ mi_index ] -> mbmi . mv [ 0 ] . as_mv . col ) ; mi_index ++ ; } fprintf ( mvs , "\n" ) ; mi_index += 8 ; } fprintf ( mvs , "\n" ) ; fclose ( mvs ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
TEST ( DownloadPrefsTest , NoAutoOpenForFilesWithNoExtension ) { const base : : FilePath kFileWithNoExtension ( FILE_PATH_LITERAL ( "abcd" ) ) ; content : : TestBrowserThreadBundle threads_are_required_for_testing_profile ; TestingProfile profile ; DownloadPrefs prefs ( & profile ) ; EXPECT_FALSE ( prefs . EnableAutoOpenBasedOnExtension ( kFileWithNoExtension ) ) ; EXPECT_FALSE ( prefs . IsAutoOpenEnabledBasedOnExtension ( kFileWithNoExtension ) ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
TEST_F ( NativeBackendLibsecretTest , GetAllLogins ) { NativeBackendLibsecret backend ( 42 ) ; VerifiedAdd ( & backend , form_google_ ) ; VerifiedAdd ( & backend , form_facebook_ ) ; ScopedVector < autofill : : PasswordForm > form_list ; EXPECT_TRUE ( backend . GetAllLogins ( & form_list ) ) ; ASSERT_EQ ( 2u , form_list . size ( ) ) ; EXPECT_THAT ( form_list , UnorderedElementsAre ( Pointee ( form_google_ ) , Pointee ( form_facebook_ ) ) ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static void qemuMonitorJSONHandleVNCDisconnect ( qemuMonitorPtr mon , virJSONValuePtr data ) { qemuMonitorJSONHandleVNC ( mon , data , VIR_DOMAIN_EVENT_GRAPHICS_DISCONNECT ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static StkId tryfuncTM ( lua_State * L , StkId func ) { const TValue * tm = luaT_gettmbyobj ( L , func , TM_CALL ) ; StkId p ; ptrdiff_t funcr = savestack ( L , func ) ; if ( ! ttisfunction ( tm ) ) luaG_typeerror ( L , func , "call" ) ; for ( p = L -> top ; p > func ; p -- ) setobjs2s ( L , p , p - 1 ) ; incr_top ( L ) ; func = restorestack ( L , funcr ) ; setobj2s ( L , func , tm ) ; return func ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
TEST_F ( ShortcutsBackendTest , SanitizeMatchCore ) { struct { std : : string input_contents_class ; std : : string input_description_class ; AutocompleteMatch : : Type input_type ; std : : string output_contents_class ; std : : string output_description_class ; AutocompleteMatch : : Type output_type ; } cases [ ] = { { "0,1,4,0" , "0,3,4,1" , AutocompleteMatchType : : URL_WHAT_YOU_TYPED , "0,1,4,0" , "0,1" , AutocompleteMatchType : : HISTORY_URL } , { "0,3,5,1" , "0,2,5,0" , AutocompleteMatchType : : NAVSUGGEST , "0,1" , "0,0" , AutocompleteMatchType : : HISTORY_URL } , { "0,1" , "0,0,11,2,15,0" , AutocompleteMatchType : : SEARCH_WHAT_YOU_TYPED , "0,1" , "0,0" , AutocompleteMatchType : : SEARCH_HISTORY } , { "0,1" , "0,0" , AutocompleteMatchType : : SEARCH_SUGGEST , "0,1" , "0,0" , AutocompleteMatchType : : SEARCH_HISTORY } , { "0,1" , "0,0" , AutocompleteMatchType : : SEARCH_SUGGEST_ENTITY , "" , "" , AutocompleteMatchType : : SEARCH_HISTORY } , { "0,1" , "0,0" , AutocompleteMatchType : : SEARCH_SUGGEST_TAIL , "" , "" , AutocompleteMatchType : : SEARCH_HISTORY } , { "0,1" , "0,0" , AutocompleteMatchType : : SEARCH_SUGGEST_PERSONALIZED , "" , "" , AutocompleteMatchType : : SEARCH_HISTORY } , { "0,1" , "0,0" , AutocompleteMatchType : : SEARCH_SUGGEST_PROFILE , "" , "" , AutocompleteMatchType : : SEARCH_HISTORY } , } ; for ( size_t i = 0 ; i < arraysize ( cases ) ; ++ i ) { ShortcutsDatabase : : Shortcut : : MatchCore match_core ( MatchCoreForTesting ( std : : string ( ) , cases [ i ] . input_contents_class , cases [ i ] . input_description_class , cases [ i ] . input_type ) ) ; EXPECT_EQ ( cases [ i ] . output_contents_class , match_core . contents_class ) << ":i:" << i << ":type:" << cases [ i ] . input_type ; EXPECT_EQ ( cases [ i ] . output_description_class , match_core . description_class ) << ":i:" << i << ":type:" << cases [ i ] . input_type ; EXPECT_EQ ( cases [ i ] . output_type , match_core . type ) << ":i:" << i << ":type:" << cases [ i ] . input_type ; } }
0False
Categorize the following code snippet as vulnerable or not. True or False
static HashTable * spl_filesystem_object_get_debug_info ( zval * obj , int * is_temp TSRMLS_DC ) { spl_filesystem_object * intern = ( spl_filesystem_object * ) zend_object_store_get_object ( obj TSRMLS_CC ) ; HashTable * rv ; zval * tmp , zrv ; char * pnstr , * path ; int pnlen , path_len ; char stmp [ 2 ] ; * is_temp = 1 ; if ( ! intern -> std . properties ) { rebuild_object_properties ( & intern -> std ) ; } ALLOC_HASHTABLE ( rv ) ; ZEND_INIT_SYMTABLE_EX ( rv , zend_hash_num_elements ( intern -> std . properties ) + 3 , 0 ) ; INIT_PZVAL ( & zrv ) ; Z_ARRVAL ( zrv ) = rv ; zend_hash_copy ( rv , intern -> std . properties , ( copy_ctor_func_t ) zval_add_ref , ( void * ) & tmp , sizeof ( zval * ) ) ; pnstr = spl_gen_private_prop_name ( spl_ce_SplFileInfo , "pathName" , sizeof ( "pathName" ) - 1 , & pnlen TSRMLS_CC ) ; path = spl_filesystem_object_get_pathname ( intern , & path_len TSRMLS_CC ) ; add_assoc_stringl_ex ( & zrv , pnstr , pnlen + 1 , path , path_len , 1 ) ; efree ( pnstr ) ; if ( intern -> file_name ) { pnstr = spl_gen_private_prop_name ( spl_ce_SplFileInfo , "fileName" , sizeof ( "fileName" ) - 1 , & pnlen TSRMLS_CC ) ; spl_filesystem_object_get_path ( intern , & path_len TSRMLS_CC ) ; if ( path_len && path_len < intern -> file_name_len ) { add_assoc_stringl_ex ( & zrv , pnstr , pnlen + 1 , intern -> file_name + path_len + 1 , intern -> file_name_len - ( path_len + 1 ) , 1 ) ; } else { add_assoc_stringl_ex ( & zrv , pnstr , pnlen + 1 , intern -> file_name , intern -> file_name_len , 1 ) ; } efree ( pnstr ) ; } if ( intern -> type == SPL_FS_DIR ) { # ifdef HAVE_GLOB pnstr = spl_gen_private_prop_name ( spl_ce_DirectoryIterator , "glob" , sizeof ( "glob" ) - 1 , & pnlen TSRMLS_CC ) ; if ( php_stream_is ( intern -> u . dir . dirp , & php_glob_stream_ops ) ) { add_assoc_stringl_ex ( & zrv , pnstr , pnlen + 1 , intern -> _path , intern -> _path_len , 1 ) ; } else { add_assoc_bool_ex ( & zrv , pnstr , pnlen + 1 , 0 ) ; } efree ( pnstr ) ; # endif pnstr = spl_gen_private_prop_name ( spl_ce_RecursiveDirectoryIterator , "subPathName" , sizeof ( "subPathName" ) - 1 , & pnlen TSRMLS_CC ) ; if ( intern -> u . dir . sub_path ) { add_assoc_stringl_ex ( & zrv , pnstr , pnlen + 1 , intern -> u . dir . sub_path , intern -> u . dir . sub_path_len , 1 ) ; } else { add_assoc_stringl_ex ( & zrv , pnstr , pnlen + 1 , "" , 0 , 1 ) ; } efree ( pnstr ) ; } if ( intern -> type == SPL_FS_FILE ) { pnstr = spl_gen_private_prop_name ( spl_ce_SplFileObject , "openMode" , sizeof ( "openMode" ) - 1 , & pnlen TSRMLS_CC ) ; add_assoc_stringl_ex ( & zrv , pnstr , pnlen + 1 , intern -> u . file . open_mode , intern -> u . file . open_mode_len , 1 ) ; efree ( pnstr ) ; stmp [ 1 ] = '\0' ; stmp [ 0 ] = intern -> u . file . delimiter ; pnstr = spl_gen_private_prop_name ( spl_ce_SplFileObject , "delimiter" , sizeof ( "delimiter" ) - 1 , & pnlen TSRMLS_CC ) ; add_assoc_stringl_ex ( & zrv , pnstr , pnlen + 1 , stmp , 1 , 1 ) ; efree ( pnstr ) ; stmp [ 0 ] = intern -> u . file . enclosure ; pnstr = spl_gen_private_prop_name ( spl_ce_SplFileObject , "enclosure" , sizeof ( "enclosure" ) - 1 , & pnlen TSRMLS_CC ) ; add_assoc_stringl_ex ( & zrv , pnstr , pnlen + 1 , stmp , 1 , 1 ) ; efree ( pnstr ) ; } return rv ; }
1True
Categorize the following code snippet as vulnerable or not. True or False
TEST_F ( TemplateURLTest , URLRefTestEncoding2 ) { TemplateURLData data ; data . SetURL ( "http://foo{ searchTerms} x{ inputEncoding} y{ outputEncoding} a" ) ; TemplateURL url ( data ) ; EXPECT_TRUE ( url . url_ref ( ) . IsValid ( search_terms_data_ ) ) ; ASSERT_TRUE ( url . url_ref ( ) . SupportsReplacement ( search_terms_data_ ) ) ; GURL result ( url . url_ref ( ) . ReplaceSearchTerms ( TemplateURLRef : : SearchTermsArgs ( ASCIIToUTF16 ( "X" ) ) , search_terms_data_ ) ) ; ASSERT_TRUE ( result . is_valid ( ) ) ; EXPECT_EQ ( "http://fooxxutf-8yutf-8a/" , result . spec ( ) ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static PyObject * checkPassword ( PyObject * self , PyObject * args ) { const char * user = NULL ; const char * pswd = NULL ; const char * service = NULL ; const char * default_realm = NULL ; const int verify = 1 ; int result = 0 ; if ( ! PyArg_ParseTuple ( args , "ssssb" , & user , & pswd , & service , & default_realm , & verify ) ) return NULL ; result = authenticate_user_krb5pwd ( user , pswd , service , default_realm , verify ) ; if ( result ) return Py_INCREF ( Py_True ) , Py_True ; else return NULL ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static int encode_picture_lossless ( AVCodecContext * avctx , AVPacket * pkt , const AVFrame * pict , int * got_packet ) { MpegEncContext * const s = avctx -> priv_data ; MJpegContext * const m = s -> mjpeg_ctx ; const int width = s -> width ; const int height = s -> height ; AVFrame * const p = & s -> current_picture . f ; const int predictor = avctx -> prediction_method + 1 ; const int mb_width = ( width + s -> mjpeg_hsample [ 0 ] - 1 ) / s -> mjpeg_hsample [ 0 ] ; const int mb_height = ( height + s -> mjpeg_vsample [ 0 ] - 1 ) / s -> mjpeg_vsample [ 0 ] ; int ret , max_pkt_size = FF_MIN_BUFFER_SIZE ; if ( avctx -> pix_fmt == AV_PIX_FMT_BGRA ) max_pkt_size += width * height * 3 * 4 ; else { max_pkt_size += mb_width * mb_height * 3 * 4 * s -> mjpeg_hsample [ 0 ] * s -> mjpeg_vsample [ 0 ] ; } if ( ( ret = ff_alloc_packet ( pkt , max_pkt_size ) ) < 0 ) { av_log ( avctx , AV_LOG_ERROR , "Error getting output packet of size %d.\n" , max_pkt_size ) ; return ret ; } init_put_bits ( & s -> pb , pkt -> data , pkt -> size ) ; * p = * pict ; p -> pict_type = AV_PICTURE_TYPE_I ; p -> key_frame = 1 ; ff_mjpeg_encode_picture_header ( s ) ; s -> header_bits = put_bits_count ( & s -> pb ) ; if ( avctx -> pix_fmt == AV_PIX_FMT_BGRA ) { int x , y , i ; const int linesize = p -> linesize [ 0 ] ; uint16_t ( * buffer ) [ 4 ] = ( void * ) s -> rd_scratchpad ; int left [ 3 ] , top [ 3 ] , topleft [ 3 ] ; for ( i = 0 ; i < 3 ; i ++ ) { buffer [ 0 ] [ i ] = 1 << ( 9 - 1 ) ; } for ( y = 0 ; y < height ; y ++ ) { const int modified_predictor = y ? predictor : 1 ; uint8_t * ptr = p -> data [ 0 ] + ( linesize * y ) ; if ( s -> pb . buf_end - s -> pb . buf - ( put_bits_count ( & s -> pb ) >> 3 ) < width * 3 * 4 ) { av_log ( s -> avctx , AV_LOG_ERROR , "encoded frame too large\n" ) ; return - 1 ; } for ( i = 0 ; i < 3 ; i ++ ) { top [ i ] = left [ i ] = topleft [ i ] = buffer [ 0 ] [ i ] ; } for ( x = 0 ; x < width ; x ++ ) { buffer [ x ] [ 1 ] = ptr [ 4 * x + 0 ] - ptr [ 4 * x + 1 ] + 0x100 ; buffer [ x ] [ 2 ] = ptr [ 4 * x + 2 ] - ptr [ 4 * x + 1 ] + 0x100 ; buffer [ x ] [ 0 ] = ( ptr [ 4 * x + 0 ] + 2 * ptr [ 4 * x + 1 ] + ptr [ 4 * x + 2 ] ) >> 2 ; for ( i = 0 ; i < 3 ; i ++ ) { int pred , diff ; PREDICT ( pred , topleft [ i ] , top [ i ] , left [ i ] , modified_predictor ) ; topleft [ i ] = top [ i ] ; top [ i ] = buffer [ x + 1 ] [ i ] ; left [ i ] = buffer [ x ] [ i ] ; diff = ( ( left [ i ] - pred + 0x100 ) & 0x1FF ) - 0x100 ; if ( i == 0 ) ff_mjpeg_encode_dc ( s , diff , m -> huff_size_dc_luminance , m -> huff_code_dc_luminance ) ; else ff_mjpeg_encode_dc ( s , diff , m -> huff_size_dc_chrominance , m -> huff_code_dc_chrominance ) ; } } } } else { int mb_x , mb_y , i ; for ( mb_y = 0 ; mb_y < mb_height ; mb_y ++ ) { if ( s -> pb . buf_end - s -> pb . buf - ( put_bits_count ( & s -> pb ) >> 3 ) < mb_width * 4 * 3 * s -> mjpeg_hsample [ 0 ] * s -> mjpeg_vsample [ 0 ] ) { av_log ( s -> avctx , AV_LOG_ERROR , "encoded frame too large\n" ) ; return - 1 ; } for ( mb_x = 0 ; mb_x < mb_width ; mb_x ++ ) { if ( mb_x == 0 || mb_y == 0 ) { for ( i = 0 ; i < 3 ; i ++ ) { uint8_t * ptr ; int x , y , h , v , linesize ; h = s -> mjpeg_hsample [ i ] ; v = s -> mjpeg_vsample [ i ] ; linesize = p -> linesize [ i ] ; for ( y = 0 ; y < v ; y ++ ) { for ( x = 0 ; x < h ; x ++ ) { int pred ; ptr = p -> data [ i ] + ( linesize * ( v * mb_y + y ) ) + ( h * mb_x + x ) ; if ( y == 0 && mb_y == 0 ) { if ( x == 0 && mb_x == 0 ) { pred = 128 ; } else { pred = ptr [ - 1 ] ; } } else { if ( x == 0 && mb_x == 0 ) { pred = ptr [ - linesize ] ; } else { PREDICT ( pred , ptr [ - linesize - 1 ] , ptr [ - linesize ] , ptr [ - 1 ] , predictor ) ; } } if ( i == 0 ) ff_mjpeg_encode_dc ( s , * ptr - pred , m -> huff_size_dc_luminance , m -> huff_code_dc_luminance ) ; else ff_mjpeg_encode_dc ( s , * ptr - pred , m -> huff_size_dc_chrominance , m -> huff_code_dc_chrominance ) ; } } } } else { for ( i = 0 ; i < 3 ; i ++ ) { uint8_t * ptr ; int x , y , h , v , linesize ; h = s -> mjpeg_hsample [ i ] ; v = s -> mjpeg_vsample [ i ] ; linesize = p -> linesize [ i ] ; for ( y = 0 ; y < v ; y ++ ) { for ( x = 0 ; x < h ; x ++ ) { int pred ; ptr = p -> data [ i ] + ( linesize * ( v * mb_y + y ) ) + ( h * mb_x + x ) ; PREDICT ( pred , ptr [ - linesize - 1 ] , ptr [ - linesize ] , ptr [ - 1 ] , predictor ) ; if ( i == 0 ) ff_mjpeg_encode_dc ( s , * ptr - pred , m -> huff_size_dc_luminance , m -> huff_code_dc_luminance ) ; else ff_mjpeg_encode_dc ( s , * ptr - pred , m -> huff_size_dc_chrominance , m -> huff_code_dc_chrominance ) ; } } } } } } } emms_c ( ) ; ff_mjpeg_encode_picture_trailer ( s ) ; s -> picture_number ++ ; flush_put_bits ( & s -> pb ) ; pkt -> size = put_bits_ptr ( & s -> pb ) - s -> pb . buf ; pkt -> flags |= AV_PKT_FLAG_KEY ; * got_packet = 1 ; return 0 ; }
1True
Categorize the following code snippet as vulnerable or not. True or False
double vp9_vaq_inv_q_ratio ( int energy ) { ENERGY_IN_BOUNDS ( energy ) ; vp9_clear_system_state ( ) ; return Q_RATIO ( - energy ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static int update_index ( AVFormatContext * s , int start_sec , uint32_t packet_number , uint16_t packet_count , uint64_t packet_offset ) { ASFContext * asf = s -> priv_data ; if ( start_sec > asf -> next_start_sec ) { int i ; if ( ! asf -> next_start_sec ) { asf -> next_packet_number = packet_number ; asf -> next_packet_count = packet_count ; asf -> next_packet_offset = packet_offset ; } if ( start_sec > asf -> nb_index_memory_alloc ) { int err ; asf -> nb_index_memory_alloc = ( start_sec + ASF_INDEX_BLOCK ) & ~ ( ASF_INDEX_BLOCK - 1 ) ; if ( ( err = av_reallocp_array ( & asf -> index_ptr , asf -> nb_index_memory_alloc , sizeof ( * asf -> index_ptr ) ) ) < 0 ) { asf -> nb_index_memory_alloc = 0 ; return err ; } } for ( i = asf -> next_start_sec ; i < start_sec ; i ++ ) { asf -> index_ptr [ i ] . packet_number = asf -> next_packet_number ; asf -> index_ptr [ i ] . packet_count = asf -> next_packet_count ; asf -> index_ptr [ i ] . send_time = asf -> next_start_sec * INT64_C ( 10000000 ) ; asf -> index_ptr [ i ] . offset = asf -> next_packet_offset ; } } asf -> maximum_packet = FFMAX ( asf -> maximum_packet , packet_count ) ; asf -> next_packet_number = packet_number ; asf -> next_packet_count = packet_count ; asf -> next_packet_offset = packet_offset ; asf -> next_start_sec = start_sec ; return 0 ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static void export_pamenv ( void ) { char * * env ; env = pam_getenvlist ( pamh ) ; while ( env && * env ) { if ( putenv ( * env ) != 0 ) err ( EXIT_FAILURE , NULL ) ; env ++ ; } }
0False
Categorize the following code snippet as vulnerable or not. True or False
int mask62plen ( const u_char * mask ) { u_char bitmasks [ 9 ] = { 0x00 , 0x80 , 0xc0 , 0xe0 , 0xf0 , 0xf8 , 0xfc , 0xfe , 0xff } ; int byte ; int cidr_len = 0 ; for ( byte = 0 ; byte < 16 ; byte ++ ) { u_int bits ; for ( bits = 0 ; bits < ( sizeof ( bitmasks ) / sizeof ( bitmasks [ 0 ] ) ) ; bits ++ ) { if ( mask [ byte ] == bitmasks [ bits ] ) { cidr_len += bits ; break ; } } if ( mask [ byte ] != 0xff ) break ; } return ( cidr_len ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static Image * ReadTGAImage ( const ImageInfo * image_info , ExceptionInfo * exception ) { Image * image ; IndexPacket index ; MagickBooleanType status ; PixelPacket pixel ; register IndexPacket * indexes ; register PixelPacket * q ; register ssize_t i , x ; size_t base , flag , offset , real , skip ; ssize_t count , y ; TGAInfo tga_info ; unsigned char j , k , pixels [ 4 ] , runlength ; unsigned int alpha_bits ; assert ( image_info != ( const ImageInfo * ) NULL ) ; assert ( image_info -> signature == MagickSignature ) ; if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , "%s" , image_info -> filename ) ; assert ( exception != ( ExceptionInfo * ) NULL ) ; assert ( exception -> signature == MagickSignature ) ; image = AcquireImage ( image_info ) ; status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ; if ( status == MagickFalse ) { image = DestroyImageList ( image ) ; return ( ( Image * ) NULL ) ; } count = ReadBlob ( image , 1 , & tga_info . id_length ) ; tga_info . colormap_type = ( unsigned char ) ReadBlobByte ( image ) ; tga_info . image_type = ( TGAImageType ) ReadBlobByte ( image ) ; if ( ( count != 1 ) || ( ( tga_info . image_type != TGAColormap ) && ( tga_info . image_type != TGARGB ) && ( tga_info . image_type != TGAMonochrome ) && ( tga_info . image_type != TGARLEColormap ) && ( tga_info . image_type != TGARLERGB ) && ( tga_info . image_type != TGARLEMonochrome ) ) || ( ( ( tga_info . image_type == TGAColormap ) || ( tga_info . image_type == TGARLEColormap ) ) && ( tga_info . colormap_type == 0 ) ) ) ThrowReaderException ( CorruptImageError , "ImproperImageHeader" ) ; tga_info . colormap_index = ReadBlobLSBShort ( image ) ; tga_info . colormap_length = ReadBlobLSBShort ( image ) ; tga_info . colormap_size = ( unsigned char ) ReadBlobByte ( image ) ; tga_info . x_origin = ReadBlobLSBShort ( image ) ; tga_info . y_origin = ReadBlobLSBShort ( image ) ; tga_info . width = ( unsigned short ) ReadBlobLSBShort ( image ) ; tga_info . height = ( unsigned short ) ReadBlobLSBShort ( image ) ; tga_info . bits_per_pixel = ( unsigned char ) ReadBlobByte ( image ) ; tga_info . attributes = ( unsigned char ) ReadBlobByte ( image ) ; if ( EOFBlob ( image ) != MagickFalse ) ThrowReaderException ( CorruptImageError , "UnableToReadImageData" ) ; if ( ( ( ( tga_info . bits_per_pixel <= 1 ) || ( tga_info . bits_per_pixel >= 17 ) ) && ( tga_info . bits_per_pixel != 24 ) && ( tga_info . bits_per_pixel != 32 ) ) ) ThrowReaderException ( CorruptImageError , "ImproperImageHeader" ) ; image -> columns = tga_info . width ; image -> rows = tga_info . height ; alpha_bits = ( tga_info . attributes & 0x0FU ) ; image -> matte = ( alpha_bits > 0 ) || ( tga_info . bits_per_pixel == 32 ) || ( tga_info . colormap_size == 32 ) ? MagickTrue : MagickFalse ; if ( ( tga_info . image_type != TGAColormap ) && ( tga_info . image_type != TGARLEColormap ) ) image -> depth = ( size_t ) ( ( tga_info . bits_per_pixel <= 8 ) ? 8 : ( tga_info . bits_per_pixel <= 16 ) ? 5 : 8 ) ; else image -> depth = ( size_t ) ( ( tga_info . colormap_size <= 8 ) ? 8 : ( tga_info . colormap_size <= 16 ) ? 5 : 8 ) ; if ( ( tga_info . image_type == TGAColormap ) || ( tga_info . image_type == TGAMonochrome ) || ( tga_info . image_type == TGARLEColormap ) || ( tga_info . image_type == TGARLEMonochrome ) ) image -> storage_class = PseudoClass ; image -> compression = NoCompression ; if ( ( tga_info . image_type == TGARLEColormap ) || ( tga_info . image_type == TGARLEMonochrome ) || ( tga_info . image_type == TGARLERGB ) ) image -> compression = RLECompression ; if ( image -> storage_class == PseudoClass ) { if ( tga_info . colormap_type != 0 ) image -> colors = tga_info . colormap_index + tga_info . colormap_length ; else { size_t one ; one = 1 ; image -> colors = one << tga_info . bits_per_pixel ; if ( AcquireImageColormap ( image , image -> colors ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , "MemoryAllocationFailed" ) ; } } if ( tga_info . id_length != 0 ) { char * comment ; size_t length ; length = ( size_t ) tga_info . id_length ; comment = ( char * ) NULL ; if ( ~ length >= ( MaxTextExtent - 1 ) ) comment = ( char * ) AcquireQuantumMemory ( length + MaxTextExtent , sizeof ( * comment ) ) ; if ( comment == ( char * ) NULL ) ThrowReaderException ( ResourceLimitError , "MemoryAllocationFailed" ) ; ( void ) ReadBlob ( image , tga_info . id_length , ( unsigned char * ) comment ) ; comment [ tga_info . id_length ] = '\0' ; ( void ) SetImageProperty ( image , "comment" , comment ) ; comment = DestroyString ( comment ) ; } if ( tga_info . attributes & ( 1UL << 4 ) ) { if ( tga_info . attributes & ( 1UL << 5 ) ) SetImageArtifact ( image , "tga:image-origin" , "TopRight" ) ; else SetImageArtifact ( image , "tga:image-origin" , "BottomRight" ) ; } else { if ( tga_info . attributes & ( 1UL << 5 ) ) SetImageArtifact ( image , "tga:image-origin" , "TopLeft" ) ; else SetImageArtifact ( image , "tga:image-origin" , "BottomLeft" ) ; } if ( image_info -> ping != MagickFalse ) { ( void ) CloseBlob ( image ) ; return ( image ) ; } status = SetImageExtent ( image , image -> columns , image -> rows ) ; if ( status == MagickFalse ) { InheritException ( exception , & image -> exception ) ; return ( DestroyImageList ( image ) ) ; } ( void ) ResetMagickMemory ( & pixel , 0 , sizeof ( pixel ) ) ; pixel . opacity = ( Quantum ) OpaqueOpacity ; if ( tga_info . colormap_type != 0 ) { if ( image -> colors < tga_info . colormap_index ) image -> colors = tga_info . colormap_index ; if ( AcquireImageColormap ( image , image -> colors ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , "MemoryAllocationFailed" ) ; for ( i = 0 ; i < ( ssize_t ) tga_info . colormap_index ; i ++ ) image -> colormap [ i ] = pixel ; for ( ; i < ( ssize_t ) image -> colors ; i ++ ) { switch ( tga_info . colormap_size ) { case 8 : default : { pixel . red = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; pixel . green = pixel . red ; pixel . blue = pixel . red ; break ; } case 15 : case 16 : { QuantumAny range ; j = ( unsigned char ) ReadBlobByte ( image ) ; k = ( unsigned char ) ReadBlobByte ( image ) ; range = GetQuantumRange ( 5UL ) ; pixel . red = ScaleAnyToQuantum ( 1UL * ( k & 0x7c ) >> 2 , range ) ; pixel . green = ScaleAnyToQuantum ( ( 1UL * ( k & 0x03 ) << 3 ) + ( 1UL * ( j & 0xe0 ) >> 5 ) , range ) ; pixel . blue = ScaleAnyToQuantum ( 1UL * ( j & 0x1f ) , range ) ; break ; } case 24 : { pixel . blue = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; pixel . green = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; pixel . red = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; break ; } case 32 : { pixel . blue = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; pixel . green = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; pixel . red = ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ; pixel . opacity = ( Quantum ) ( QuantumRange - ScaleCharToQuantum ( ( unsigned char ) ReadBlobByte ( image ) ) ) ; break ; } } image -> colormap [ i ] = pixel ; } } base = 0 ; flag = 0 ; skip = MagickFalse ; real = 0 ; index = ( IndexPacket ) 0 ; runlength = 0 ; offset = 0 ; for ( y = 0 ; y < ( ssize_t ) image -> rows ; y ++ ) { real = offset ; if ( ( ( unsigned char ) ( tga_info . attributes & 0x20 ) >> 5 ) == 0 ) real = image -> rows - real - 1 ; q = QueueAuthenticPixels ( image , 0 , ( ssize_t ) real , image -> columns , 1 , exception ) ; if ( q == ( PixelPacket * ) NULL ) break ; indexes = GetAuthenticIndexQueue ( image ) ; for ( x = 0 ; x < ( ssize_t ) image -> columns ; x ++ ) { if ( ( tga_info . image_type == TGARLEColormap ) || ( tga_info . image_type == TGARLERGB ) || ( tga_info . image_type == TGARLEMonochrome ) ) { if ( runlength != 0 ) { runlength -- ; skip = flag != 0 ; } else { count = ReadBlob ( image , 1 , & runlength ) ; if ( count != 1 ) ThrowReaderException ( CorruptImageError , "UnableToReadImageData" ) ; flag = runlength & 0x80 ; if ( flag != 0 ) runlength -= 128 ; skip = MagickFalse ; } } if ( skip == MagickFalse ) switch ( tga_info . bits_per_pixel ) { case 8 : default : { index = ( IndexPacket ) ReadBlobByte ( image ) ; if ( tga_info . colormap_type != 0 ) pixel = image -> colormap [ ( ssize_t ) ConstrainColormapIndex ( image , 1UL * index ) ] ; else { pixel . red = ScaleCharToQuantum ( ( unsigned char ) index ) ; pixel . green = ScaleCharToQuantum ( ( unsigned char ) index ) ; pixel . blue = ScaleCharToQuantum ( ( unsigned char ) index ) ; } break ; } case 15 : case 16 : { QuantumAny range ; if ( ReadBlob ( image , 2 , pixels ) != 2 ) ThrowReaderException ( CorruptImageError , "UnableToReadImageData" ) ; j = pixels [ 0 ] ; k = pixels [ 1 ] ; range = GetQuantumRange ( 5UL ) ; pixel . red = ScaleAnyToQuantum ( 1UL * ( k & 0x7c ) >> 2 , range ) ; pixel . green = ScaleAnyToQuantum ( ( 1UL * ( k & 0x03 ) << 3 ) + ( 1UL * ( j & 0xe0 ) >> 5 ) , range ) ; pixel . blue = ScaleAnyToQuantum ( 1UL * ( j & 0x1f ) , range ) ; if ( image -> matte != MagickFalse ) pixel . opacity = ( k & 0x80 ) == 0 ? ( Quantum ) TransparentOpacity : ( Quantum ) OpaqueOpacity ; if ( image -> storage_class == PseudoClass ) index = ConstrainColormapIndex ( image , ( ( size_t ) k << 8 ) + j ) ; break ; } case 24 : { if ( ReadBlob ( image , 3 , pixels ) != 3 ) ThrowReaderException ( CorruptImageError , "UnableToReadImageData" ) ; pixel . blue = ScaleCharToQuantum ( pixels [ 0 ] ) ; pixel . green = ScaleCharToQuantum ( pixels [ 1 ] ) ; pixel . red = ScaleCharToQuantum ( pixels [ 2 ] ) ; break ; } case 32 : { if ( ReadBlob ( image , 4 , pixels ) != 4 ) ThrowReaderException ( CorruptImageError , "UnableToReadImageData" ) ; pixel . blue = ScaleCharToQuantum ( pixels [ 0 ] ) ; pixel . green = ScaleCharToQuantum ( pixels [ 1 ] ) ; pixel . red = ScaleCharToQuantum ( pixels [ 2 ] ) ; pixel . opacity = ( Quantum ) ( QuantumRange - ScaleCharToQuantum ( pixels [ 3 ] ) ) ; break ; } } if ( status == MagickFalse ) ThrowReaderException ( CorruptImageError , "UnableToReadImageData" ) ; if ( image -> storage_class == PseudoClass ) SetPixelIndex ( indexes + x , index ) ; SetPixelRed ( q , pixel . red ) ; SetPixelGreen ( q , pixel . green ) ; SetPixelBlue ( q , pixel . blue ) ; if ( image -> matte != MagickFalse ) SetPixelOpacity ( q , pixel . opacity ) ; q ++ ; } if ( ( ( unsigned char ) ( tga_info . attributes & 0xc0 ) >> 6 ) == 2 ) offset += 2 ; else offset ++ ; if ( offset >= image -> rows ) { base ++ ; offset = base ; } if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ; if ( image -> previous == ( Image * ) NULL ) { status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ; if ( status == MagickFalse ) break ; } } if ( EOFBlob ( image ) != MagickFalse ) ThrowFileException ( exception , CorruptImageError , "UnexpectedEndOfFile" , image -> filename ) ; ( void ) CloseBlob ( image ) ; return ( GetFirstImageInList ( image ) ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static void test_bug4231 ( ) { MYSQL_STMT * stmt ; MYSQL_BIND my_bind [ 2 ] ; MYSQL_TIME tm [ 2 ] ; const char * stmt_text ; int rc ; myheader ( "test_bug4231" ) ; stmt_text = "DROP TABLE IF EXISTS t1" ; rc = mysql_real_query ( mysql , stmt_text , strlen ( stmt_text ) ) ; myquery ( rc ) ; stmt_text = "CREATE TABLE t1 (a int)" ; rc = mysql_real_query ( mysql , stmt_text , strlen ( stmt_text ) ) ; myquery ( rc ) ; stmt_text = "INSERT INTO t1 VALUES (1)" ; rc = mysql_real_query ( mysql , stmt_text , strlen ( stmt_text ) ) ; myquery ( rc ) ; stmt = mysql_stmt_init ( mysql ) ; stmt_text = "SELECT a FROM t1 WHERE ? = ?" ; rc = mysql_stmt_prepare ( stmt , stmt_text , strlen ( stmt_text ) ) ; check_execute ( stmt , rc ) ; memset ( my_bind , 0 , sizeof ( my_bind ) ) ; memset ( tm , 0 , sizeof ( tm ) ) ; my_bind [ 0 ] . buffer_type = MYSQL_TYPE_DATE ; my_bind [ 0 ] . buffer = & tm [ 0 ] ; my_bind [ 1 ] . buffer_type = MYSQL_TYPE_DATE ; my_bind [ 1 ] . buffer = & tm [ 1 ] ; mysql_stmt_bind_param ( stmt , my_bind ) ; check_execute ( stmt , rc ) ; tm [ 0 ] . time_type = MYSQL_TIMESTAMP_DATE ; tm [ 0 ] . year = 2000 ; tm [ 0 ] . month = 1 ; tm [ 0 ] . day = 1 ; tm [ 1 ] = tm [ 0 ] ; -- tm [ 1 ] . year ; rc = mysql_stmt_execute ( stmt ) ; check_execute ( stmt , rc ) ; rc = mysql_stmt_fetch ( stmt ) ; DIE_UNLESS ( rc == MYSQL_NO_DATA ) ; tm [ 0 ] . year = tm [ 0 ] . month = tm [ 0 ] . day = 0 ; tm [ 1 ] = tm [ 0 ] ; mysql_stmt_execute ( stmt ) ; rc = mysql_stmt_fetch ( stmt ) ; DIE_UNLESS ( rc == 0 ) ; mysql_stmt_close ( stmt ) ; stmt_text = "DROP TABLE t1" ; rc = mysql_real_query ( mysql , stmt_text , strlen ( stmt_text ) ) ; myquery ( rc ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
void vp9_new_framerate ( VP9_COMP * cpi , double framerate ) { cpi -> framerate = framerate < 0.1 ? 30 : framerate ; vp9_rc_update_framerate ( cpi ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static gint dissect_adb ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree , void * data ) { proto_item * main_item ; proto_tree * main_tree ; proto_item * arg0_item ; proto_tree * arg0_tree ; proto_item * arg1_item ; proto_tree * arg1_tree ; proto_item * magic_item ; proto_item * crc_item ; proto_tree * crc_tree = NULL ; proto_item * sub_item ; gint offset = 0 ; guint32 command ; guint32 arg0 ; guint32 arg1 ; guint32 data_length = 0 ; guint32 crc32 = 0 ; usb_conv_info_t * usb_conv_info = NULL ; wmem_tree_key_t key [ 5 ] ; guint32 interface_id ; guint32 bus_id ; guint32 device_address ; guint32 side_id ; guint32 frame_number ; gboolean is_command = TRUE ; gboolean is_next_fragment = FALSE ; gboolean is_service = FALSE ; gint proto ; gint direction = P2P_DIR_UNKNOWN ; wmem_tree_t * wmem_tree ; command_data_t * command_data = NULL ; service_data_t * service_data = NULL ; col_set_str ( pinfo -> cinfo , COL_PROTOCOL , "ADB" ) ; col_clear ( pinfo -> cinfo , COL_INFO ) ; main_item = proto_tree_add_item ( tree , proto_adb , tvb , offset , - 1 , ENC_NA ) ; main_tree = proto_item_add_subtree ( main_item , ett_adb ) ; frame_number = pinfo -> num ; proto = ( gint ) GPOINTER_TO_INT ( wmem_list_frame_data ( ( wmem_list_tail ( pinfo -> layers ) ) ) ) ; if ( proto != proto_usb ) { proto = ( gint ) GPOINTER_TO_INT ( wmem_list_frame_data ( wmem_list_frame_prev ( wmem_list_tail ( pinfo -> layers ) ) ) ) ; } if ( proto == proto_usb ) { usb_conv_info = ( usb_conv_info_t * ) data ; DISSECTOR_ASSERT ( usb_conv_info ) ; direction = usb_conv_info -> direction ; } else if ( proto == proto_tcp ) { if ( pinfo -> destport == ADB_TCP_PORT ) direction = P2P_DIR_SENT ; else direction = P2P_DIR_RECV ; } else { return offset ; } if ( pinfo -> phdr -> presence_flags & WTAP_HAS_INTERFACE_ID ) interface_id = pinfo -> phdr -> interface_id ; else interface_id = 0 ; if ( proto == proto_usb ) { bus_id = usb_conv_info -> bus_id ; device_address = usb_conv_info -> device_address ; key [ 0 ] . length = 1 ; key [ 0 ] . key = & interface_id ; key [ 1 ] . length = 1 ; key [ 1 ] . key = & bus_id ; key [ 2 ] . length = 1 ; key [ 2 ] . key = & device_address ; key [ 3 ] . length = 0 ; key [ 3 ] . key = NULL ; } else { key [ 0 ] . length = 1 ; key [ 0 ] . key = & interface_id ; key [ 1 ] . length = 1 ; key [ 2 ] . length = 1 ; if ( direction == P2P_DIR_SENT ) { key [ 1 ] . key = & pinfo -> srcport ; key [ 2 ] . key = & pinfo -> destport ; } else { key [ 1 ] . key = & pinfo -> destport ; key [ 2 ] . key = & pinfo -> srcport ; } key [ 3 ] . length = 0 ; key [ 3 ] . key = NULL ; } wmem_tree = ( wmem_tree_t * ) wmem_tree_lookup32_array ( command_info , key ) ; if ( wmem_tree ) { command_data = ( command_data_t * ) wmem_tree_lookup32_le ( wmem_tree , frame_number ) ; if ( command_data && command_data -> completed_in_frame >= frame_number && command_data -> command_in_frame <= frame_number ) { if ( command_data -> command_in_frame != frame_number ) { is_command = FALSE ; is_next_fragment = TRUE ; } data_length = command_data -> data_length ; crc32 = command_data -> crc32 ; if ( direction == P2P_DIR_SENT ) if ( command_data -> command == A_CLSE ) side_id = command_data -> arg1 ; else side_id = command_data -> arg0 ; else if ( command_data -> command == A_OKAY ) { side_id = command_data -> arg1 ; } else side_id = command_data -> arg1 ; key [ 3 ] . length = 1 ; key [ 3 ] . key = & side_id ; key [ 4 ] . length = 0 ; key [ 4 ] . key = NULL ; wmem_tree = ( wmem_tree_t * ) wmem_tree_lookup32_array ( service_info , key ) ; if ( wmem_tree ) { service_data = ( service_data_t * ) wmem_tree_lookup32_le ( wmem_tree , frame_number ) ; if ( service_data && command_data -> command == A_OPEN ) { is_service = TRUE ; } } } } if ( ( command_data && command_data -> completed_in_frame <= frame_number ) || ! command_data ) { if ( tvb_reported_length ( tvb ) < 24 ) { is_command = FALSE ; } else if ( tvb_reported_length ( tvb ) >= 24 ) { command = tvb_get_letohl ( tvb , offset ) ; if ( command != A_SYNC && command != A_CLSE && command != A_WRTE && command != A_AUTH && command != A_CNXN && command != A_OPEN && command != A_OKAY ) is_command = FALSE ; else if ( command != ( 0xFFFFFFFF ^ tvb_get_letohl ( tvb , offset + 20 ) ) ) is_command = FALSE ; if ( is_command ) { data_length = tvb_get_letohl ( tvb , offset + 12 ) ; crc32 = tvb_get_letohl ( tvb , offset + 16 ) ; } if ( command == A_OPEN ) is_service = TRUE ; } } if ( service_data && ! ( command_data -> command == A_OPEN && is_next_fragment ) ) { sub_item = proto_tree_add_string ( main_tree , hf_service , tvb , offset , 0 , service_data -> service ) ; PROTO_ITEM_SET_GENERATED ( sub_item ) ; } if ( service_data ) { sub_item = proto_tree_add_uint ( main_tree , hf_service_start_in_frame , tvb , offset , 0 , service_data -> start_in_frame ) ; PROTO_ITEM_SET_GENERATED ( sub_item ) ; if ( service_data -> close_local_in_frame < max_in_frame ) { sub_item = proto_tree_add_uint ( main_tree , hf_close_local_in_frame , tvb , offset , 0 , service_data -> close_local_in_frame ) ; PROTO_ITEM_SET_GENERATED ( sub_item ) ; } if ( service_data -> close_remote_in_frame < max_in_frame ) { sub_item = proto_tree_add_uint ( main_tree , hf_close_remote_in_frame , tvb , offset , 0 , service_data -> close_remote_in_frame ) ; PROTO_ITEM_SET_GENERATED ( sub_item ) ; } } if ( is_command ) { proto_tree_add_item ( main_tree , hf_command , tvb , offset , 4 , ENC_LITTLE_ENDIAN ) ; command = tvb_get_letohl ( tvb , offset ) ; offset += 4 ; col_append_str ( pinfo -> cinfo , COL_INFO , val_to_str_const ( command , command_vals , "Unknown command" ) ) ; arg0_item = proto_tree_add_item ( main_tree , hf_argument_0 , tvb , offset , 4 , ENC_LITTLE_ENDIAN ) ; arg0_tree = proto_item_add_subtree ( arg0_item , ett_adb_arg0 ) ; arg0 = tvb_get_letohl ( tvb , offset ) ; offset += 4 ; arg1_item = proto_tree_add_item ( main_tree , hf_argument_1 , tvb , offset , 4 , ENC_LITTLE_ENDIAN ) ; arg1_tree = proto_item_add_subtree ( arg1_item , ett_adb_arg1 ) ; arg1 = tvb_get_letohl ( tvb , offset ) ; offset += 4 ; switch ( command ) { case A_CNXN : proto_tree_add_item ( arg0_tree , hf_version , tvb , offset - 8 , 4 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( arg1_tree , hf_max_data , tvb , offset - 4 , 4 , ENC_LITTLE_ENDIAN ) ; col_append_fstr ( pinfo -> cinfo , COL_INFO , "(version=%u.%u.%u, max_data=%u)" , tvb_get_guint8 ( tvb , offset - 5 ) , tvb_get_guint8 ( tvb , offset - 6 ) , tvb_get_letohs ( tvb , offset - 7 ) , tvb_get_letohl ( tvb , offset - 4 ) ) ; break ; case A_AUTH : proto_tree_add_item ( arg0_tree , hf_auth_type , tvb , offset - 8 , 4 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( arg1_tree , hf_zero , tvb , offset - 4 , 4 , ENC_LITTLE_ENDIAN ) ; col_append_fstr ( pinfo -> cinfo , COL_INFO , "(type=%s, 0)" , val_to_str_const ( tvb_get_letohl ( tvb , offset - 8 ) , auth_type_vals , "Unknown" ) ) ; break ; case A_OPEN : proto_tree_add_item ( arg0_tree , hf_local_id , tvb , offset - 8 , 4 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( arg1_tree , hf_zero , tvb , offset - 4 , 4 , ENC_LITTLE_ENDIAN ) ; col_append_fstr ( pinfo -> cinfo , COL_INFO , "(local=%u, 0)" , tvb_get_letohl ( tvb , offset - 8 ) ) ; break ; case A_WRTE : proto_tree_add_item ( arg0_tree , hf_zero , tvb , offset - 8 , 4 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( arg1_tree , hf_remote_id , tvb , offset - 4 , 4 , ENC_LITTLE_ENDIAN ) ; col_append_fstr ( pinfo -> cinfo , COL_INFO , "(0, remote=%u)" , tvb_get_letohl ( tvb , offset - 4 ) ) ; break ; case A_CLSE : case A_OKAY : proto_tree_add_item ( arg0_tree , hf_local_id , tvb , offset - 8 , 4 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( arg1_tree , hf_remote_id , tvb , offset - 4 , 4 , ENC_LITTLE_ENDIAN ) ; col_append_fstr ( pinfo -> cinfo , COL_INFO , "(local=%u, remote=%u)" , tvb_get_letohl ( tvb , offset - 8 ) , tvb_get_letohl ( tvb , offset - 4 ) ) ; break ; case A_SYNC : proto_tree_add_item ( arg0_tree , hf_online , tvb , offset - 8 , 4 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( arg1_tree , hf_sequence , tvb , offset - 4 , 4 , ENC_LITTLE_ENDIAN ) ; col_append_fstr ( pinfo -> cinfo , COL_INFO , "(online=%s, sequence=%u)" , tvb_get_letohl ( tvb , offset - 8 ) ? "Yes" : "No" , tvb_get_letohl ( tvb , offset - 4 ) ) ; break ; } proto_tree_add_item ( main_tree , hf_data_length , tvb , offset , 4 , ENC_LITTLE_ENDIAN ) ; offset += 4 ; if ( data_length > 0 ) col_append_fstr ( pinfo -> cinfo , COL_INFO , " length=%u " , data_length ) ; crc_item = proto_tree_add_item ( main_tree , hf_data_crc32 , tvb , offset , 4 , ENC_LITTLE_ENDIAN ) ; crc_tree = proto_item_add_subtree ( crc_item , ett_adb_crc ) ; crc32 = tvb_get_letohl ( tvb , offset ) ; offset += 4 ; magic_item = proto_tree_add_item ( main_tree , hf_magic , tvb , offset , 4 , ENC_LITTLE_ENDIAN ) ; if ( ( tvb_get_letohl ( tvb , offset ) ^ 0xFFFFFFFF ) != command ) { proto_tree * expert_tree ; expert_tree = proto_item_add_subtree ( magic_item , ett_adb_magic ) ; proto_tree_add_expert ( expert_tree , pinfo , & ei_invalid_magic , tvb , offset , 4 ) ; } if ( ! pinfo -> fd -> flags . visited ) save_command ( command , arg0 , arg1 , data_length , crc32 , service_data , proto , data , pinfo , & service_data , & command_data ) ; offset += 4 ; } if ( ! pinfo -> fd -> flags . visited && command_data ) { if ( command_data -> command_in_frame != frame_number ) { is_command = FALSE ; is_next_fragment = TRUE ; } data_length = command_data -> data_length ; crc32 = command_data -> crc32 ; if ( ( command_data -> command_in_frame != frame_number && tvb_captured_length ( tvb ) == data_length ) || ( command_data -> command_in_frame == frame_number && tvb_captured_length ( tvb ) == data_length + 24 ) ) { command_data -> reassemble_data_length = command_data -> data_length ; command_data -> completed_in_frame = frame_number ; } } if ( is_next_fragment && command_data ) { sub_item = proto_tree_add_uint ( main_tree , hf_command_in_frame , tvb , offset , 0 , command_data -> command_in_frame ) ; PROTO_ITEM_SET_GENERATED ( sub_item ) ; sub_item = proto_tree_add_uint ( main_tree , hf_command , tvb , offset , 0 , command_data -> command ) ; PROTO_ITEM_SET_GENERATED ( sub_item ) ; sub_item = proto_tree_add_uint ( main_tree , hf_data_length , tvb , offset , 0 , command_data -> data_length ) ; PROTO_ITEM_SET_GENERATED ( sub_item ) ; crc_item = proto_tree_add_uint ( main_tree , hf_data_crc32 , tvb , offset , 0 , command_data -> crc32 ) ; crc_tree = proto_item_add_subtree ( crc_item , ett_adb_crc ) ; PROTO_ITEM_SET_GENERATED ( crc_item ) ; } if ( command_data && command_data -> completed_in_frame != frame_number ) { sub_item = proto_tree_add_uint ( main_tree , hf_completed_in_frame , tvb , offset , 0 , command_data -> completed_in_frame ) ; PROTO_ITEM_SET_GENERATED ( sub_item ) ; } if ( tvb_captured_length_remaining ( tvb , offset ) > 0 && ( ! is_command || data_length > 0 ) ) { guint32 crc = 0 ; guint32 i_offset ; if ( ! pinfo -> fd -> flags . visited && command_data && command_data -> reassemble_data_length < command_data -> data_length ) { guint chunklen = tvb_captured_length_remaining ( tvb , offset ) ; if ( chunklen > command_data -> data_length - command_data -> reassemble_data_length ) { chunklen = command_data -> data_length - command_data -> reassemble_data_length ; command_data -> reassemble_error_in_frame = frame_number ; } tvb_memcpy ( tvb , command_data -> reassemble_data + command_data -> reassemble_data_length , offset , chunklen ) ; command_data -> reassemble_data_length += chunklen ; if ( command_data -> reassemble_data_length >= command_data -> data_length ) command_data -> completed_in_frame = frame_number ; } if ( frame_number == command_data -> reassemble_error_in_frame ) { proto_tree_add_expert ( main_tree , pinfo , & ei_invalid_data , tvb , offset , - 1 ) ; } if ( ( ! pinfo -> fd -> flags . visited && command_data && command_data -> reassemble_data_length < command_data -> data_length ) || data_length > ( guint32 ) tvb_captured_length_remaining ( tvb , offset ) ) { proto_tree_add_item ( main_tree , hf_data_fragment , tvb , offset , - 1 , ENC_NA ) ; col_append_str ( pinfo -> cinfo , COL_INFO , "Data Fragment" ) ; offset = tvb_captured_length ( tvb ) ; if ( service_data && command_data && command_data -> reassemble_data_length >= command_data -> data_length && frame_number == command_data -> completed_in_frame ) { tvbuff_t * next_tvb ; adb_service_data_t adb_service_data ; next_tvb = tvb_new_child_real_data ( tvb , command_data -> reassemble_data , command_data -> reassemble_data_length , command_data -> reassemble_data_length ) ; add_new_data_source ( pinfo , next_tvb , "ADB Reassembled Data" ) ; adb_service_data . service = service_data -> service ; adb_service_data . direction = direction ; adb_service_data . session_key_length = 3 ; adb_service_data . session_key = ( guint32 * ) wmem_alloc ( wmem_packet_scope ( ) , adb_service_data . session_key_length * sizeof ( guint32 ) ) ; adb_service_data . session_key [ 0 ] = interface_id ; if ( proto == proto_usb ) { adb_service_data . session_key [ 1 ] = usb_conv_info -> bus_id ; adb_service_data . session_key [ 2 ] = usb_conv_info -> device_address ; } else { if ( direction == P2P_DIR_SENT ) { adb_service_data . session_key [ 1 ] = pinfo -> srcport ; adb_service_data . session_key [ 2 ] = pinfo -> destport ; } else { adb_service_data . session_key [ 1 ] = pinfo -> destport ; adb_service_data . session_key [ 2 ] = pinfo -> srcport ; } } call_dissector_with_data ( adb_service_handle , next_tvb , pinfo , tree , & adb_service_data ) ; } } else { for ( i_offset = 0 ; i_offset < data_length ; ++ i_offset ) crc += tvb_get_guint8 ( tvb , offset + i_offset ) ; if ( crc32 > 0 && crc32 != crc ) proto_tree_add_expert ( crc_tree , pinfo , & ei_invalid_crc , tvb , offset , - 1 ) ; if ( is_service ) { proto_tree_add_item ( main_tree , hf_service , tvb , offset , - 1 , ENC_ASCII | ENC_NA ) ; if ( ! pinfo -> fd -> flags . visited && service_data ) { service_data -> service = tvb_get_stringz_enc ( wmem_file_scope ( ) , tvb , offset , NULL , ENC_ASCII ) ; } col_append_fstr ( pinfo -> cinfo , COL_INFO , "Service: %s" , tvb_get_stringz_enc ( wmem_packet_scope ( ) , tvb , offset , NULL , ENC_ASCII ) ) ; offset = tvb_captured_length ( tvb ) ; } else if ( command_data && command_data -> command == A_CNXN ) { gchar * info ; gint len ; info = tvb_get_stringz_enc ( wmem_packet_scope ( ) , tvb , offset , & len , ENC_ASCII ) ; col_append_fstr ( pinfo -> cinfo , COL_INFO , "Connection Info: %s" , info ) ; proto_tree_add_item ( main_tree , hf_connection_info , tvb , offset , len , ENC_ASCII | ENC_NA ) ; offset += len ; } else { col_append_str ( pinfo -> cinfo , COL_INFO , "Data" ) ; if ( service_data ) { tvbuff_t * next_tvb ; adb_service_data_t adb_service_data ; adb_service_data . service = service_data -> service ; adb_service_data . direction = direction ; adb_service_data . session_key_length = 3 ; adb_service_data . session_key = ( guint32 * ) wmem_alloc ( wmem_packet_scope ( ) , adb_service_data . session_key_length * sizeof ( guint32 ) ) ; adb_service_data . session_key [ 0 ] = interface_id ; if ( proto == proto_usb ) { adb_service_data . session_key [ 1 ] = usb_conv_info -> bus_id ; adb_service_data . session_key [ 2 ] = usb_conv_info -> device_address ; } else { if ( direction == P2P_DIR_SENT ) { adb_service_data . session_key [ 1 ] = pinfo -> srcport ; adb_service_data . session_key [ 2 ] = pinfo -> destport ; } else { adb_service_data . session_key [ 1 ] = pinfo -> destport ; adb_service_data . session_key [ 2 ] = pinfo -> srcport ; } } next_tvb = tvb_new_subset ( tvb , offset , tvb_captured_length_remaining ( tvb , offset ) , tvb_captured_length_remaining ( tvb , offset ) ) ; call_dissector_with_data ( adb_service_handle , next_tvb , pinfo , tree , & adb_service_data ) ; } else { proto_item * data_item ; gchar * data_str ; data_item = proto_tree_add_item ( main_tree , hf_data , tvb , offset , data_length , ENC_NA ) ; data_str = tvb_format_text ( tvb , offset , data_length ) ; proto_item_append_text ( data_item , ": %s" , data_str ) ; col_append_fstr ( pinfo -> cinfo , COL_INFO , " Raw: %s" , data_str ) ; } offset = tvb_captured_length ( tvb ) ; } } } return offset ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static int selinux_bprm_set_creds ( struct linux_binprm * bprm ) { const struct task_security_struct * old_tsec ; struct task_security_struct * new_tsec ; struct inode_security_struct * isec ; struct common_audit_data ad ; struct inode * inode = file_inode ( bprm -> file ) ; int rc ; if ( bprm -> cred_prepared ) return 0 ; old_tsec = current_security ( ) ; new_tsec = bprm -> cred -> security ; isec = inode_security ( inode ) ; new_tsec -> sid = old_tsec -> sid ; new_tsec -> osid = old_tsec -> sid ; new_tsec -> create_sid = 0 ; new_tsec -> keycreate_sid = 0 ; new_tsec -> sockcreate_sid = 0 ; if ( old_tsec -> exec_sid ) { new_tsec -> sid = old_tsec -> exec_sid ; new_tsec -> exec_sid = 0 ; rc = check_nnp_nosuid ( bprm , old_tsec , new_tsec ) ; if ( rc ) return rc ; } else { rc = security_transition_sid ( old_tsec -> sid , isec -> sid , SECCLASS_PROCESS , NULL , & new_tsec -> sid ) ; if ( rc ) return rc ; rc = check_nnp_nosuid ( bprm , old_tsec , new_tsec ) ; if ( rc ) new_tsec -> sid = old_tsec -> sid ; } ad . type = LSM_AUDIT_DATA_FILE ; ad . u . file = bprm -> file ; if ( new_tsec -> sid == old_tsec -> sid ) { rc = avc_has_perm ( old_tsec -> sid , isec -> sid , SECCLASS_FILE , FILE__EXECUTE_NO_TRANS , & ad ) ; if ( rc ) return rc ; } else { rc = avc_has_perm ( old_tsec -> sid , new_tsec -> sid , SECCLASS_PROCESS , PROCESS__TRANSITION , & ad ) ; if ( rc ) return rc ; rc = avc_has_perm ( new_tsec -> sid , isec -> sid , SECCLASS_FILE , FILE__ENTRYPOINT , & ad ) ; if ( rc ) return rc ; if ( bprm -> unsafe & LSM_UNSAFE_SHARE ) { rc = avc_has_perm ( old_tsec -> sid , new_tsec -> sid , SECCLASS_PROCESS , PROCESS__SHARE , NULL ) ; if ( rc ) return - EPERM ; } if ( bprm -> unsafe & ( LSM_UNSAFE_PTRACE | LSM_UNSAFE_PTRACE_CAP ) ) { u32 ptsid = ptrace_parent_sid ( current ) ; if ( ptsid != 0 ) { rc = avc_has_perm ( ptsid , new_tsec -> sid , SECCLASS_PROCESS , PROCESS__PTRACE , NULL ) ; if ( rc ) return - EPERM ; } } bprm -> per_clear |= PER_CLEAR_ON_SETID ; } return 0 ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static GVariant * _g_variant_new_maybe_string ( const gchar * value ) { if ( value == NULL ) return g_variant_new_string ( "" ) ; return g_variant_new_string ( value ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static unsigned long get_logmask ( char * s ) { char * t ; unsigned long offset ; unsigned long mask ; t = s ; offset = get_pfxmatch ( & t , logcfg_class ) ; mask = get_match ( t , logcfg_item ) ; if ( mask ) return mask << offset ; else msyslog ( LOG_ERR , "logconfig: illegal argument %s - ignored" , s ) ; return 0 ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
unsigned int vp9_sad ## m ## x ## n ## _c ( const uint8_t * src , int src_stride , const uint8_t * ref , int ref_stride ) { return sad ( src , src_stride , ref , ref_stride , m , n ) ; \ } unsigned int vp9_sad ## m ## x ## n ## _avg_c ( const uint8_t * src , int src_stride , const uint8_t * ref , int ref_stride , const uint8_t * second_pred ) { uint8_t comp_pred [ m * n ] ; vp9_comp_avg_pred ( comp_pred , second_pred , m , n , ref , ref_stride ) ; return sad ( src , src_stride , comp_pred , m , m , n ) ; \ } # define sadMxNxK ( m , n , k ) void vp9_sad ## m ## x ## n ## x ## k ## _c ( const uint8_t * src , int src_stride , const uint8_t * ref , int ref_stride , unsigned int * sads ) { int i ; for ( i = 0 ; i < k ; ++ i ) sads [ i ] = vp9_sad ## m ## x ## n ## _c ( src , src_stride , & ref [ i ] , ref_stride ) ; \ } # define sadMxNx4D ( m , n ) void vp9_sad ## m ## x ## n ## x4d_c ( const uint8_t * src , int src_stride , const uint8_t * const refs [ ] , int ref_stride , unsigned int * sads ) { int i ; for ( i = 0 ; i < 4 ; ++ i ) sads [ i ] = vp9_sad ## m ## x ## n ## _c ( src , src_stride , refs [ i ] , ref_stride ) ; \ } sadMxN ( 64 , 64 ) sadMxNxK ( 64 , 64 , 3 ) sadMxNxK ( 64 , 64 , 8 ) sadMxNx4D ( 64 , 64 ) sadMxN ( 64 , 32 ) sadMxNx4D ( 64 , 32 ) sadMxN ( 32 , 64 ) sadMxNx4D ( 32 , 64 ) sadMxN ( 32 , 32 ) sadMxNxK ( 32 , 32 , 3 ) sadMxNxK ( 32 , 32 , 8 ) sadMxNx4D ( 32 , 32 ) sadMxN ( 32 , 16 ) sadMxNx4D ( 32 , 16 ) sadMxN ( 16 , 32 ) sadMxNx4D ( 16 , 32 ) sadMxN ( 16 , 16 ) sadMxNxK ( 16 , 16 , 3 ) sadMxNxK ( 16 , 16 , 8 ) sadMxNx4D ( 16 , 16 ) sadMxN ( 16 , 8 ) sadMxNxK ( 16 , 8 , 3 ) sadMxNxK ( 16 , 8 , 8 ) sadMxNx4D ( 16 , 8 ) sadMxN ( 8 , 16 ) sadMxNxK ( 8 , 16 , 3 ) sadMxNxK ( 8 , 16 , 8 ) sadMxNx4D ( 8 , 16 ) sadMxN ( 8 , 8 )
0False
Categorize the following code snippet as vulnerable or not. True or False
static int dissect_h245_T_mcCapability ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) { offset = dissect_per_sequence ( tvb , offset , actx , tree , hf_index , ett_h245_T_mcCapability , T_mcCapability_sequence ) ; return offset ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static void pxa2xx_fir_event ( void * opaque , int event ) { }
0False
Categorize the following code snippet as vulnerable or not. True or False
static cmsBool BuildAbsolutePath ( const char * relPath , const char * basePath , char * buffer , cmsUInt32Number MaxLen ) { char * tail ; cmsUInt32Number len ; if ( isabsolutepath ( relPath ) ) { strncpy ( buffer , relPath , MaxLen ) ; buffer [ MaxLen - 1 ] = 0 ; return TRUE ; } strncpy ( buffer , basePath , MaxLen ) ; buffer [ MaxLen - 1 ] = 0 ; tail = strrchr ( buffer , DIR_CHAR ) ; if ( tail == NULL ) return FALSE ; len = ( cmsUInt32Number ) ( tail - buffer ) ; if ( len >= MaxLen ) return FALSE ; strncpy ( tail + 1 , relPath , MaxLen - len ) ; return TRUE ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static int best_effort_strncat_from_utf16be ( struct archive_string * as , const void * _p , size_t bytes , struct archive_string_conv * sc ) { return ( best_effort_strncat_from_utf16 ( as , _p , bytes , sc , 1 ) ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static void timelib_eat_until_separator ( char * * ptr ) { while ( strchr ( " \t.,:; /-0123456789" , * * ptr ) == NULL ) { ++ * ptr ; } }
0False
Categorize the following code snippet as vulnerable or not. True or False
static void proto_tree_set_ipv4 ( field_info * fi , guint32 value ) { fvalue_set_uinteger ( & fi -> value , value ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
gboolean imcb_file_recv_start ( struct im_connection * ic , file_transfer_t * ft ) { bee_t * bee = ic -> bee ; if ( bee -> ui -> ft_out_start ) { return bee -> ui -> ft_out_start ( ic , ft ) ; } else { return FALSE ; } }
0False
Categorize the following code snippet as vulnerable or not. True or False
static header_field_info * hfinfo_same_name_get_prev ( const header_field_info * hfinfo ) { header_field_info * dup_hfinfo ; if ( hfinfo -> same_name_prev_id == - 1 ) return NULL ; PROTO_REGISTRAR_GET_NTH ( hfinfo -> same_name_prev_id , dup_hfinfo ) ; return dup_hfinfo ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
void vp9_find_best_ref_mvs ( MACROBLOCKD * xd , int allow_hp , int_mv * mvlist , int_mv * nearest , int_mv * near ) { int i ; for ( i = 0 ; i < MAX_MV_REF_CANDIDATES ; ++ i ) { lower_mv_precision ( & mvlist [ i ] . as_mv , allow_hp ) ; clamp_mv2 ( & mvlist [ i ] . as_mv , xd ) ; } * nearest = mvlist [ 0 ] ; * near = mvlist [ 1 ] ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static size_t q_encoder ( char * str , const char * buf , size_t buflen , const char * tocode ) { static const char hex [ ] = "0123456789ABCDEF" ; char * s0 = str ; memcpy ( str , "=?" , 2 ) ; str += 2 ; memcpy ( str , tocode , strlen ( tocode ) ) ; str += strlen ( tocode ) ; memcpy ( str , "?Q?" , 3 ) ; str += 3 ; while ( buflen -- ) { unsigned char c = * buf ++ ; if ( c == ' ' ) * str ++ = '_' ; else if ( ( c >= 0x7f ) || ( c < 0x20 ) || ( c == '_' ) || strchr ( MimeSpecials , c ) ) { * str ++ = '=' ; * str ++ = hex [ ( c & 0xf0 ) >> 4 ] ; * str ++ = hex [ c & 0x0f ] ; } else * str ++ = c ; } memcpy ( str , "?=" , 2 ) ; str += 2 ; return ( str - s0 ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
int TSMimeHdrFieldLengthGet ( TSMBuffer bufp , TSMLoc hdr , TSMLoc field ) { sdk_assert ( sdk_sanity_check_mbuffer ( bufp ) == TS_SUCCESS ) ; sdk_assert ( ( sdk_sanity_check_mime_hdr_handle ( hdr ) == TS_SUCCESS ) || ( sdk_sanity_check_http_hdr_handle ( hdr ) == TS_SUCCESS ) ) ; sdk_assert ( sdk_sanity_check_field_handle ( field , hdr ) == TS_SUCCESS ) ; MIMEFieldSDKHandle * handle = ( MIMEFieldSDKHandle * ) field ; return mime_field_length_get ( handle -> field_ptr ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static void prplcb_conn_connected ( PurpleConnection * gc ) { struct im_connection * ic = purple_ic_by_gc ( gc ) ; const char * dn ; set_t * s ; imcb_connected ( ic ) ; if ( ( dn = purple_connection_get_display_name ( gc ) ) && ( s = set_find ( & ic -> acc -> set , "display_name" ) ) ) { g_free ( s -> value ) ; s -> value = g_strdup ( dn ) ; } purple_gg_buddylist_import ( gc ) ; ic -> flags |= OPT_DOES_HTML ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static int mainwindows_compare ( MAIN_WINDOW_REC * w1 , MAIN_WINDOW_REC * w2 ) { return w1 -> first_line < w2 -> first_line ? - 1 : w1 -> first_line > w2 -> first_line ? 1 : w1 -> first_column < w2 -> first_column ? - 1 : w1 -> first_column > w2 -> first_column ? 1 : 0 ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static inline int get_duration ( AVIStream * ast , int len ) { if ( ast -> sample_size ) return len ; else if ( ast -> dshow_block_align ) return ( len + ast -> dshow_block_align - 1 ) / ast -> dshow_block_align ; else return 1 ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
int vp8_set_roimap ( VP8_COMP * cpi , unsigned char * map , unsigned int rows , unsigned int cols , int delta_q [ 4 ] , int delta_lf [ 4 ] , unsigned int threshold [ 4 ] ) { signed char feature_data [ MB_LVL_MAX ] [ MAX_MB_SEGMENTS ] ; int internal_delta_q [ MAX_MB_SEGMENTS ] ; const int range = 63 ; int i ; if ( cpi -> cyclic_refresh_mode_enabled ) return - 1 ; if ( cpi -> common . mb_rows != rows || cpi -> common . mb_cols != cols ) return - 1 ; if ( ( abs ( delta_q [ 0 ] ) > range ) || ( abs ( delta_q [ 1 ] ) > range ) || ( abs ( delta_q [ 2 ] ) > range ) || ( abs ( delta_q [ 3 ] ) > range ) ) return - 1 ; if ( ( abs ( delta_lf [ 0 ] ) > range ) || ( abs ( delta_lf [ 1 ] ) > range ) || ( abs ( delta_lf [ 2 ] ) > range ) || ( abs ( delta_lf [ 3 ] ) > range ) ) return - 1 ; if ( ! map ) { disable_segmentation ( cpi ) ; return 0 ; } for ( i = 0 ; i < MAX_MB_SEGMENTS ; i ++ ) internal_delta_q [ i ] = ( delta_q [ i ] >= 0 ) ? q_trans [ delta_q [ i ] ] : - q_trans [ - delta_q [ i ] ] ; set_segmentation_map ( cpi , map ) ; enable_segmentation ( cpi ) ; feature_data [ MB_LVL_ALT_Q ] [ 0 ] = internal_delta_q [ 0 ] ; feature_data [ MB_LVL_ALT_Q ] [ 1 ] = internal_delta_q [ 1 ] ; feature_data [ MB_LVL_ALT_Q ] [ 2 ] = internal_delta_q [ 2 ] ; feature_data [ MB_LVL_ALT_Q ] [ 3 ] = internal_delta_q [ 3 ] ; feature_data [ MB_LVL_ALT_LF ] [ 0 ] = delta_lf [ 0 ] ; feature_data [ MB_LVL_ALT_LF ] [ 1 ] = delta_lf [ 1 ] ; feature_data [ MB_LVL_ALT_LF ] [ 2 ] = delta_lf [ 2 ] ; feature_data [ MB_LVL_ALT_LF ] [ 3 ] = delta_lf [ 3 ] ; cpi -> segment_encode_breakout [ 0 ] = threshold [ 0 ] ; cpi -> segment_encode_breakout [ 1 ] = threshold [ 1 ] ; cpi -> segment_encode_breakout [ 2 ] = threshold [ 2 ] ; cpi -> segment_encode_breakout [ 3 ] = threshold [ 3 ] ; set_segment_data ( cpi , & feature_data [ 0 ] [ 0 ] , SEGMENT_DELTADATA ) ; return 0 ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static void HandleType3Reference ( IO * wrapper , EntityChar * ec , real transform [ 6 ] , char * tokbuf , int toksize ) { int tok ; real dval ; char * glyphname ; RefChar * ref ; tok = nextpstoken ( wrapper , & dval , tokbuf , toksize ) ; if ( strcmp ( tokbuf , "get" ) != 0 ) return ; tok = nextpstoken ( wrapper , & dval , tokbuf , toksize ) ; if ( tok != pt_namelit ) return ; glyphname = copy ( tokbuf ) ; tok = nextpstoken ( wrapper , & dval , tokbuf , toksize ) ; if ( strcmp ( tokbuf , "get" ) != 0 ) { free ( glyphname ) ; return ; } tok = nextpstoken ( wrapper , & dval , tokbuf , toksize ) ; if ( strcmp ( tokbuf , "exec" ) != 0 ) { free ( glyphname ) ; return ; } ref = RefCharCreate ( ) ; memcpy ( ref -> transform , transform , sizeof ( ref -> transform ) ) ; ref -> sc = ( SplineChar * ) glyphname ; ref -> next = ec -> refs ; ec -> refs = ref ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static int ebml_read_float ( AVIOContext * pb , int size , double * num ) { if ( size == 0 ) * num = 0 ; else if ( size == 4 ) * num = av_int2float ( avio_rb32 ( pb ) ) ; else if ( size == 8 ) * num = av_int2double ( avio_rb64 ( pb ) ) ; else return AVERROR_INVALIDDATA ; return 0 ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
char * Curl_memdup ( const char * src , size_t length ) { char * buffer = malloc ( length ) ; if ( ! buffer ) return NULL ; memcpy ( buffer , src , length ) ; return buffer ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
void xmlHashScanFull3 ( xmlHashTablePtr table , const xmlChar * name , const xmlChar * name2 , const xmlChar * name3 , xmlHashScannerFull f , void * data ) { int i ; xmlHashEntryPtr iter ; xmlHashEntryPtr next ; if ( table == NULL ) return ; if ( f == NULL ) return ; if ( table -> table ) { for ( i = 0 ; i < table -> size ; i ++ ) { if ( table -> table [ i ] . valid == 0 ) continue ; iter = & ( table -> table [ i ] ) ; while ( iter ) { next = iter -> next ; if ( ( ( name == NULL ) || ( xmlStrEqual ( name , iter -> name ) ) ) && ( ( name2 == NULL ) || ( xmlStrEqual ( name2 , iter -> name2 ) ) ) && ( ( name3 == NULL ) || ( xmlStrEqual ( name3 , iter -> name3 ) ) ) && ( iter -> payload != NULL ) ) { f ( iter -> payload , data , iter -> name , iter -> name2 , iter -> name3 ) ; } iter = next ; } } } }
0False
Categorize the following code snippet as vulnerable or not. True or False
void traverse_commit_list ( struct rev_info * revs , show_commit_fn show_commit , show_object_fn show_object , void * data ) { int i ; struct commit * commit ; struct strbuf base ; strbuf_init ( & base , PATH_MAX ) ; while ( ( commit = get_revision ( revs ) ) != NULL ) { if ( commit -> tree ) add_pending_tree ( revs , commit -> tree ) ; show_commit ( commit , data ) ; } for ( i = 0 ; i < revs -> pending . nr ; i ++ ) { struct object_array_entry * pending = revs -> pending . objects + i ; struct object * obj = pending -> item ; const char * name = pending -> name ; const char * path = pending -> path ; if ( obj -> flags & ( UNINTERESTING | SEEN ) ) continue ; if ( obj -> type == OBJ_TAG ) { obj -> flags |= SEEN ; show_object ( obj , name , data ) ; continue ; } if ( ! path ) path = "" ; if ( obj -> type == OBJ_TREE ) { process_tree ( revs , ( struct tree * ) obj , show_object , & base , path , data ) ; continue ; } if ( obj -> type == OBJ_BLOB ) { process_blob ( revs , ( struct blob * ) obj , show_object , & base , path , data ) ; continue ; } die ( "unknown pending object %s (%s)" , oid_to_hex ( & obj -> oid ) , name ) ; } object_array_clear ( & revs -> pending ) ; strbuf_release ( & base ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
int chk_data_link ( MI_CHECK * param , MI_INFO * info , int extend ) { int error , got_error , flag ; uint key , UNINIT_VAR ( left_length ) , b_type , field ; ha_rows records , del_blocks ; my_off_t used , empty , pos , splits , UNINIT_VAR ( start_recpos ) , del_length , link_used , start_block ; uchar * record = 0 , * UNINIT_VAR ( to ) ; char llbuff [ 22 ] , llbuff2 [ 22 ] , llbuff3 [ 22 ] ; ha_checksum intern_record_checksum ; ha_checksum key_checksum [ HA_MAX_POSSIBLE_KEY ] ; my_bool static_row_size ; MI_KEYDEF * keyinfo ; MI_BLOCK_INFO block_info ; DBUG_ENTER ( "chk_data_link" ) ; if ( ! ( param -> testflag & T_SILENT ) ) { if ( extend ) puts ( "- check records and index references" ) ; else puts ( "- check record links" ) ; } if ( ! mi_alloc_rec_buff ( info , - 1 , & record ) ) { mi_check_print_error ( param , "Not enough memory for record" ) ; DBUG_RETURN ( - 1 ) ; } records = del_blocks = 0 ; used = link_used = splits = del_length = 0 ; intern_record_checksum = param -> glob_crc = 0 ; got_error = error = 0 ; empty = info -> s -> pack . header_length ; static_row_size = 1 ; if ( info -> s -> data_file_type == COMPRESSED_RECORD ) { for ( field = 0 ; field < info -> s -> base . fields ; field ++ ) { if ( info -> s -> rec [ field ] . base_type == FIELD_BLOB || info -> s -> rec [ field ] . base_type == FIELD_VARCHAR ) { static_row_size = 0 ; break ; } } } pos = my_b_tell ( & param -> read_cache ) ; bzero ( ( char * ) key_checksum , info -> s -> base . keys * sizeof ( key_checksum [ 0 ] ) ) ; while ( pos < info -> state -> data_file_length ) { if ( * killed_ptr ( param ) ) goto err2 ; switch ( info -> s -> data_file_type ) { case STATIC_RECORD : if ( my_b_read ( & param -> read_cache , ( uchar * ) record , info -> s -> base . pack_reclength ) ) goto err ; start_recpos = pos ; pos += info -> s -> base . pack_reclength ; splits ++ ; if ( * record == '\0' ) { del_blocks ++ ; del_length += info -> s -> base . pack_reclength ; continue ; } param -> glob_crc += mi_static_checksum ( info , record ) ; used += info -> s -> base . pack_reclength ; break ; case DYNAMIC_RECORD : flag = block_info . second_read = 0 ; block_info . next_filepos = pos ; do { if ( _mi_read_cache ( & param -> read_cache , ( uchar * ) block_info . header , ( start_block = block_info . next_filepos ) , sizeof ( block_info . header ) , ( flag ? 0 : READING_NEXT ) | READING_HEADER ) ) goto err ; if ( start_block & ( MI_DYN_ALIGN_SIZE - 1 ) ) { mi_check_print_error ( param , "Wrong aligned block at %s" , llstr ( start_block , llbuff ) ) ; goto err2 ; } b_type = _mi_get_block_info ( & block_info , - 1 , start_block ) ; if ( b_type & ( BLOCK_DELETED | BLOCK_ERROR | BLOCK_SYNC_ERROR | BLOCK_FATAL_ERROR ) ) { if ( b_type & BLOCK_SYNC_ERROR ) { if ( flag ) { mi_check_print_error ( param , "Unexpected byte: %d at link: %s" , ( int ) block_info . header [ 0 ] , llstr ( start_block , llbuff ) ) ; goto err2 ; } pos = block_info . filepos + block_info . block_len ; goto next ; } if ( b_type & BLOCK_DELETED ) { if ( block_info . block_len < info -> s -> base . min_block_length ) { mi_check_print_error ( param , "Deleted block with impossible length %lu at %s" , block_info . block_len , llstr ( pos , llbuff ) ) ; goto err2 ; } if ( ( block_info . next_filepos != HA_OFFSET_ERROR && block_info . next_filepos >= info -> state -> data_file_length ) || ( block_info . prev_filepos != HA_OFFSET_ERROR && block_info . prev_filepos >= info -> state -> data_file_length ) ) { mi_check_print_error ( param , "Delete link points outside datafile at %s" , llstr ( pos , llbuff ) ) ; goto err2 ; } del_blocks ++ ; del_length += block_info . block_len ; pos = block_info . filepos + block_info . block_len ; splits ++ ; goto next ; } mi_check_print_error ( param , "Wrong bytesec: %d-%d-%d at linkstart: %s" , block_info . header [ 0 ] , block_info . header [ 1 ] , block_info . header [ 2 ] , llstr ( start_block , llbuff ) ) ; goto err2 ; } if ( info -> state -> data_file_length < block_info . filepos + block_info . block_len ) { mi_check_print_error ( param , "Recordlink that points outside datafile at %s" , llstr ( pos , llbuff ) ) ; got_error = 1 ; break ; } splits ++ ; if ( ! flag ++ ) { start_recpos = pos ; pos = block_info . filepos + block_info . block_len ; if ( block_info . rec_len > ( uint ) info -> s -> base . max_pack_length ) { mi_check_print_error ( param , "Found too long record (%lu) at %s" , ( ulong ) block_info . rec_len , llstr ( start_recpos , llbuff ) ) ; got_error = 1 ; break ; } if ( info -> s -> base . blobs ) { if ( ! ( to = mi_alloc_rec_buff ( info , block_info . rec_len , & info -> rec_buff ) ) ) { mi_check_print_error ( param , "Not enough memory (%lu) for blob at %s" , ( ulong ) block_info . rec_len , llstr ( start_recpos , llbuff ) ) ; got_error = 1 ; break ; } } else to = info -> rec_buff ; left_length = block_info . rec_len ; } if ( left_length < block_info . data_len ) { mi_check_print_error ( param , "Found too long record (%lu) at %s" , ( ulong ) block_info . data_len , llstr ( start_recpos , llbuff ) ) ; got_error = 1 ; break ; } if ( _mi_read_cache ( & param -> read_cache , ( uchar * ) to , block_info . filepos , ( uint ) block_info . data_len , flag == 1 ? READING_NEXT : 0 ) ) goto err ; to += block_info . data_len ; link_used += block_info . filepos - start_block ; used += block_info . filepos - start_block + block_info . data_len ; empty += block_info . block_len - block_info . data_len ; left_length -= block_info . data_len ; if ( left_length ) { if ( b_type & BLOCK_LAST ) { mi_check_print_error ( param , "Wrong record length %s of %s at %s" , llstr ( block_info . rec_len - left_length , llbuff ) , llstr ( block_info . rec_len , llbuff2 ) , llstr ( start_recpos , llbuff3 ) ) ; got_error = 1 ; break ; } if ( info -> state -> data_file_length < block_info . next_filepos ) { mi_check_print_error ( param , "Found next-recordlink that points outside datafile at %s" , llstr ( block_info . filepos , llbuff ) ) ; got_error = 1 ; break ; } } } while ( left_length ) ; if ( ! got_error ) { if ( _mi_rec_unpack ( info , record , info -> rec_buff , block_info . rec_len ) == MY_FILE_ERROR ) { mi_check_print_error ( param , "Found wrong record at %s" , llstr ( start_recpos , llbuff ) ) ; got_error = 1 ; } else { info -> checksum = mi_checksum ( info , record ) ; if ( param -> testflag & ( T_EXTEND | T_MEDIUM | T_VERBOSE ) ) { if ( _mi_rec_check ( info , record , info -> rec_buff , block_info . rec_len , test ( info -> s -> calc_checksum ) ) ) { mi_check_print_error ( param , "Found wrong packed record at %s" , llstr ( start_recpos , llbuff ) ) ; got_error = 1 ; } } if ( ! got_error ) param -> glob_crc += info -> checksum ; } } else if ( ! flag ) pos = block_info . filepos + block_info . block_len ; break ; case COMPRESSED_RECORD : if ( _mi_read_cache ( & param -> read_cache , ( uchar * ) block_info . header , pos , info -> s -> pack . ref_length , READING_NEXT ) ) goto err ; start_recpos = pos ; splits ++ ; ( void ) _mi_pack_get_block_info ( info , & info -> bit_buff , & block_info , & info -> rec_buff , - 1 , start_recpos ) ; pos = block_info . filepos + block_info . rec_len ; if ( block_info . rec_len < ( uint ) info -> s -> min_pack_length || block_info . rec_len > ( uint ) info -> s -> max_pack_length ) { mi_check_print_error ( param , "Found block with wrong recordlength: %d at %s" , block_info . rec_len , llstr ( start_recpos , llbuff ) ) ; got_error = 1 ; break ; } if ( _mi_read_cache ( & param -> read_cache , ( uchar * ) info -> rec_buff , block_info . filepos , block_info . rec_len , READING_NEXT ) ) goto err ; if ( _mi_pack_rec_unpack ( info , & info -> bit_buff , record , info -> rec_buff , block_info . rec_len ) ) { mi_check_print_error ( param , "Found wrong record at %s" , llstr ( start_recpos , llbuff ) ) ; got_error = 1 ; } if ( static_row_size ) param -> glob_crc += mi_static_checksum ( info , record ) ; else param -> glob_crc += mi_checksum ( info , record ) ; link_used += ( block_info . filepos - start_recpos ) ; used += ( pos - start_recpos ) ; break ; case BLOCK_RECORD : assert ( 0 ) ; } if ( ! got_error ) { intern_record_checksum += ( ha_checksum ) start_recpos ; records ++ ; if ( param -> testflag & T_WRITE_LOOP && records % WRITE_COUNT == 0 ) { printf ( "%s\r" , llstr ( records , llbuff ) ) ; ( void ) fflush ( stdout ) ; } for ( key = 0 , keyinfo = info -> s -> keyinfo ; key < info -> s -> base . keys ; key ++ , keyinfo ++ ) { if ( mi_is_key_active ( info -> s -> state . key_map , key ) ) { if ( ! ( keyinfo -> flag & HA_FULLTEXT ) ) { uint key_length = _mi_make_key ( info , key , info -> lastkey , record , start_recpos ) ; if ( extend ) { int search_result = # ifdef HAVE_RTREE_KEYS ( keyinfo -> flag & HA_SPATIAL ) ? rtree_find_first ( info , key , info -> lastkey , key_length , MBR_EQUAL | MBR_DATA ) : # endif _mi_search ( info , keyinfo , info -> lastkey , key_length , SEARCH_SAME , info -> s -> state . key_root [ key ] ) ; if ( search_result ) { mi_check_print_error ( param , "Record at: %10s " "Can't find key for index: %2d" , llstr ( start_recpos , llbuff ) , key + 1 ) ; if ( error ++ > MAXERR || ! ( param -> testflag & T_VERBOSE ) ) goto err2 ; } } else key_checksum [ key ] += mi_byte_checksum ( ( uchar * ) info -> lastkey , key_length ) ; } } } } else { got_error = 0 ; if ( error ++ > MAXERR || ! ( param -> testflag & T_VERBOSE ) ) goto err2 ; } next : ; } if ( param -> testflag & T_WRITE_LOOP ) { ( void ) fputs ( " \r" , stdout ) ; ( void ) fflush ( stdout ) ; } if ( records != info -> state -> records ) { mi_check_print_error ( param , "Record-count is not ok; is %-10s Should be: %s" , llstr ( records , llbuff ) , llstr ( info -> state -> records , llbuff2 ) ) ; error = 1 ; } else if ( param -> record_checksum && param -> record_checksum != intern_record_checksum ) { mi_check_print_error ( param , "Keypointers and record positions doesn't match" ) ; error = 1 ; } else if ( param -> glob_crc != info -> state -> checksum && ( info -> s -> options & ( HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD ) ) ) { mi_check_print_warning ( param , "Record checksum is not the same as checksum stored in the index file\n" ) ; error = 1 ; } else if ( ! extend ) { for ( key = 0 ; key < info -> s -> base . keys ; key ++ ) { if ( key_checksum [ key ] != param -> key_crc [ key ] && ! ( info -> s -> keyinfo [ key ] . flag & ( HA_FULLTEXT | HA_SPATIAL ) ) ) { mi_check_print_error ( param , "Checksum for key: %2d doesn't match checksum for records" , key + 1 ) ; error = 1 ; } } } if ( del_length != info -> state -> empty ) { mi_check_print_warning ( param , "Found %s deleted space. Should be %s" , llstr ( del_length , llbuff2 ) , llstr ( info -> state -> empty , llbuff ) ) ; } if ( used + empty + del_length != info -> state -> data_file_length ) { mi_check_print_warning ( param , "Found %s record-data and %s unused data and %s deleted-data" , llstr ( used , llbuff ) , llstr ( empty , llbuff2 ) , llstr ( del_length , llbuff3 ) ) ; mi_check_print_warning ( param , "Total %s, Should be: %s" , llstr ( ( used + empty + del_length ) , llbuff ) , llstr ( info -> state -> data_file_length , llbuff2 ) ) ; } if ( del_blocks != info -> state -> del ) { mi_check_print_warning ( param , "Found %10s deleted blocks Should be: %s" , llstr ( del_blocks , llbuff ) , llstr ( info -> state -> del , llbuff2 ) ) ; } if ( splits != info -> s -> state . split ) { mi_check_print_warning ( param , "Found %10s key parts. Should be: %s" , llstr ( splits , llbuff ) , llstr ( info -> s -> state . split , llbuff2 ) ) ; } if ( param -> testflag & T_INFO ) { if ( param -> warning_printed || param -> error_printed ) puts ( "" ) ; if ( used != 0 && ! param -> error_printed ) { printf ( "Records:%18s M.recordlength:%9lu Packed:%14.0f%%\n" , llstr ( records , llbuff ) , ( long ) ( ( used - link_used ) / records ) , ( info -> s -> base . blobs ? 0.0 : ( ulonglong2double ( ( ulonglong ) info -> s -> base . reclength * records ) - my_off_t2double ( used ) ) / ulonglong2double ( ( ulonglong ) info -> s -> base . reclength * records ) * 100.0 ) ) ; printf ( "Recordspace used:%9.0f%% Empty space:%12d%% Blocks/Record: %6.2f\n" , ( ulonglong2double ( used - link_used ) / ulonglong2double ( used - link_used + empty ) * 100.0 ) , ( ! records ? 100 : ( int ) ( ulonglong2double ( del_length + empty ) / my_off_t2double ( used ) * 100.0 ) ) , ulonglong2double ( splits - del_blocks ) / records ) ; } printf ( "Record blocks:%12s Delete blocks:%10s\n" , llstr ( splits - del_blocks , llbuff ) , llstr ( del_blocks , llbuff2 ) ) ; printf ( "Record data: %12s Deleted data: %10s\n" , llstr ( used - link_used , llbuff ) , llstr ( del_length , llbuff2 ) ) ; printf ( "Lost space: %12s Linkdata: %10s\n" , llstr ( empty , llbuff ) , llstr ( link_used , llbuff2 ) ) ; } my_free ( mi_get_rec_buff_ptr ( info , record ) ) ; DBUG_RETURN ( error ) ; err : mi_check_print_error ( param , "got error: %d when reading datafile at record: %s" , my_errno , llstr ( records , llbuff ) ) ; err2 : my_free ( mi_get_rec_buff_ptr ( info , record ) ) ; param -> testflag |= T_RETRY_WITHOUT_QUICK ; DBUG_RETURN ( 1 ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static char * convert_string_datum ( Datum value , Oid typid ) { char * val ; switch ( typid ) { case CHAROID : val = ( char * ) palloc ( 2 ) ; val [ 0 ] = DatumGetChar ( value ) ; val [ 1 ] = '\0' ; break ; case BPCHAROID : case VARCHAROID : case TEXTOID : val = TextDatumGetCString ( value ) ; break ; case NAMEOID : { NameData * nm = ( NameData * ) DatumGetPointer ( value ) ; val = pstrdup ( NameStr ( * nm ) ) ; break ; } default : elog ( ERROR , "unsupported type: %u" , typid ) ; return NULL ; } if ( ! lc_collate_is_c ( DEFAULT_COLLATION_OID ) ) { char * xfrmstr ; size_t xfrmlen ; size_t xfrmlen2 PG_USED_FOR_ASSERTS_ONLY ; # if _MSC_VER == 1400 { char x [ 1 ] ; xfrmlen = strxfrm ( x , val , 0 ) ; } # else xfrmlen = strxfrm ( NULL , val , 0 ) ; # endif # ifdef WIN32 if ( xfrmlen == INT_MAX ) return val ; # endif xfrmstr = ( char * ) palloc ( xfrmlen + 1 ) ; xfrmlen2 = strxfrm ( xfrmstr , val , xfrmlen + 1 ) ; Assert ( xfrmlen2 <= xfrmlen ) ; pfree ( val ) ; val = xfrmstr ; } return val ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static void cmd_window_left ( const char * data , SERVER_REC * server , void * item ) { int refnum ; refnum = window_refnum_left ( active_win -> refnum , TRUE ) ; if ( refnum != - 1 ) window_set_active ( window_find_refnum ( refnum ) ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static VALUE decode_bool ( unsigned char * der , long length ) { const unsigned char * p = der ; if ( length != 3 ) ossl_raise ( eASN1Error , "invalid length for BOOLEAN" ) ; if ( p [ 0 ] != 1 || p [ 1 ] != 1 ) ossl_raise ( eASN1Error , "invalid BOOLEAN" ) ; return p [ 2 ] ? Qtrue : Qfalse ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static inline void e1000e_write_hdr_to_rx_buffers ( E1000ECore * core , hwaddr ( * ba ) [ MAX_PS_BUFFERS ] , e1000e_ba_state * bastate , const char * data , dma_addr_t data_len ) { assert ( data_len <= core -> rxbuf_sizes [ 0 ] - bastate -> written [ 0 ] ) ; pci_dma_write ( core -> owner , ( * ba ) [ 0 ] + bastate -> written [ 0 ] , data , data_len ) ; bastate -> written [ 0 ] += data_len ; bastate -> cur_idx = 1 ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
void vp9_idct32x32_add ( const tran_low_t * input , uint8_t * dest , int stride , int eob ) { if ( eob == 1 ) vp9_idct32x32_1_add ( input , dest , stride ) ; else if ( eob <= 34 ) vp9_idct32x32_34_add ( input , dest , stride ) ; else vp9_idct32x32_1024_add ( input , dest , stride ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static void end_packfile ( void ) { static int running ; if ( running || ! pack_data ) return ; running = 1 ; clear_delta_base_cache ( ) ; if ( object_count ) { struct packed_git * new_p ; unsigned char cur_pack_sha1 [ 20 ] ; char * idx_name ; int i ; struct branch * b ; struct tag * t ; close_pack_windows ( pack_data ) ; sha1close ( pack_file , cur_pack_sha1 , 0 ) ; fixup_pack_header_footer ( pack_data -> pack_fd , pack_data -> sha1 , pack_data -> pack_name , object_count , cur_pack_sha1 , pack_size ) ; close ( pack_data -> pack_fd ) ; idx_name = keep_pack ( create_index ( ) ) ; new_p = add_packed_git ( idx_name , strlen ( idx_name ) , 1 ) ; if ( ! new_p ) die ( "core git rejected index %s" , idx_name ) ; all_packs [ pack_id ] = new_p ; install_packed_git ( new_p ) ; if ( pack_edges ) { fprintf ( pack_edges , "%s:" , new_p -> pack_name ) ; for ( i = 0 ; i < branch_table_sz ; i ++ ) { for ( b = branch_table [ i ] ; b ; b = b -> table_next_branch ) { if ( b -> pack_id == pack_id ) fprintf ( pack_edges , " %s" , sha1_to_hex ( b -> sha1 ) ) ; } } for ( t = first_tag ; t ; t = t -> next_tag ) { if ( t -> pack_id == pack_id ) fprintf ( pack_edges , " %s" , sha1_to_hex ( t -> sha1 ) ) ; } fputc ( '\n' , pack_edges ) ; fflush ( pack_edges ) ; } pack_id ++ ; } else { close ( pack_data -> pack_fd ) ; unlink_or_warn ( pack_data -> pack_name ) ; } free ( pack_data ) ; pack_data = NULL ; running = 0 ; strbuf_release ( & last_blob . data ) ; last_blob . offset = 0 ; last_blob . depth = 0 ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
TSAction TSCacheRemove ( TSCont contp , TSCacheKey key ) { sdk_assert ( sdk_sanity_check_iocore_structure ( contp ) == TS_SUCCESS ) ; sdk_assert ( sdk_sanity_check_cachekey ( key ) == TS_SUCCESS ) ; FORCE_PLUGIN_SCOPED_MUTEX ( contp ) ; CacheInfo * info = ( CacheInfo * ) key ; INKContInternal * i = ( INKContInternal * ) contp ; return ( TSAction ) cacheProcessor . remove ( i , & info -> cache_key , true , info -> frag_type , info -> hostname , info -> len ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
void xps_parse_linear_gradient_brush ( xps_document * doc , const fz_matrix * ctm , const fz_rect * area , char * base_uri , xps_resource * dict , fz_xml * root ) { xps_parse_gradient_brush ( doc , ctm , area , base_uri , dict , root , xps_draw_linear_gradient ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static ram_addr_t s390_virtio_device_num_vq ( VirtIOS390Device * dev ) { VirtIODevice * vdev = dev -> vdev ; int num_vq ; for ( num_vq = 0 ; num_vq < VIRTIO_PCI_QUEUE_MAX ; num_vq ++ ) { if ( ! virtio_queue_get_num ( vdev , num_vq ) ) { break ; } } return num_vq ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
TEST_F ( SSLErrorAssistantTest , DynamicInterstitialListMatchBlank ) { ASSERT_TRUE ( embedded_test_server ( ) -> Start ( ) ) ; EXPECT_EQ ( 1u , ssl_info ( ) . public_key_hashes . size ( ) ) ; auto config_proto = std : : make_unique < chrome_browser_ssl : : SSLErrorAssistantConfig > ( ) ; config_proto -> set_version_id ( kLargeVersionId ) ; chrome_browser_ssl : : DynamicInterstitial * filter = config_proto -> add_dynamic_interstitial ( ) ; filter -> set_interstitial_type ( chrome_browser_ssl : : DynamicInterstitial : : INTERSTITIAL_PAGE_SSL ) ; error_assistant ( ) -> SetErrorAssistantProto ( std : : move ( config_proto ) ) ; base : : Optional < DynamicInterstitialInfo > dynamic_interstitial = error_assistant ( ) -> MatchDynamicInterstitial ( ssl_info ( ) ) ; ASSERT_TRUE ( dynamic_interstitial ) ; EXPECT_EQ ( chrome_browser_ssl : : DynamicInterstitial : : INTERSTITIAL_PAGE_SSL , dynamic_interstitial -> interstitial_type ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static block_t * Encode ( encoder_t * p_enc , picture_t * p_pic ) { encoder_sys_t * p_sys = p_enc -> p_sys ; block_t * p_block , * p_output_chain = NULL ; SchroFrame * p_frame ; bool b_go = true ; if ( ! p_pic ) { if ( ! p_sys -> started || p_sys -> b_eos_pulled ) return NULL ; if ( ! p_sys -> b_eos_signalled ) { p_sys -> b_eos_signalled = 1 ; schro_encoder_end_of_stream ( p_sys -> p_schro ) ; } } else { p_sys -> p_format -> interlaced = ! p_pic -> b_progressive ; p_sys -> p_format -> top_field_first = p_pic -> b_top_field_first ; if ( p_sys -> b_auto_field_coding ) schro_encoder_setting_set_double ( p_sys -> p_schro , "interlaced_coding" , ! p_pic -> b_progressive ) ; } if ( ! p_sys -> started ) { date_t date ; if ( p_pic -> format . i_chroma != p_enc -> fmt_in . i_codec ) { char chroma_in [ 5 ] , chroma_out [ 5 ] ; vlc_fourcc_to_char ( p_pic -> format . i_chroma , chroma_in ) ; chroma_in [ 4 ] = '\0' ; chroma_out [ 4 ] = '\0' ; vlc_fourcc_to_char ( p_enc -> fmt_in . i_codec , chroma_out ) ; msg_Warn ( p_enc , "Resetting chroma from %s to %s" , chroma_out , chroma_in ) ; if ( ! SetEncChromaFormat ( p_enc , p_pic -> format . i_chroma ) ) { msg_Err ( p_enc , "Could not reset chroma format to %s" , chroma_in ) ; return NULL ; } } date_Init ( & date , p_enc -> fmt_in . video . i_frame_rate , p_enc -> fmt_in . video . i_frame_rate_base ) ; date_Increment ( & date , 1 ) ; p_sys -> i_pts_offset = date_Get ( & date ) ; if ( schro_encoder_setting_get_double ( p_sys -> p_schro , "interlaced_coding" ) > 0.0 ) { date_Set ( & date , 0 ) ; date_Increment ( & date , 1 ) ; p_sys -> i_field_time = date_Get ( & date ) / 2 ; } schro_video_format_set_std_signal_range ( p_sys -> p_format , SCHRO_SIGNAL_RANGE_8BIT_VIDEO ) ; schro_encoder_set_video_format ( p_sys -> p_schro , p_sys -> p_format ) ; schro_encoder_start ( p_sys -> p_schro ) ; p_sys -> started = 1 ; } if ( ! p_sys -> b_eos_signalled ) { picture_Hold ( p_pic ) ; p_frame = CreateSchroFrameFromInputPic ( p_enc , p_pic ) ; if ( ! p_frame ) return NULL ; schro_encoder_push_frame ( p_sys -> p_schro , p_frame ) ; StorePicturePTS ( p_enc , p_sys -> i_input_picnum , p_pic -> date ) ; p_sys -> i_input_picnum ++ ; p_block = block_Alloc ( 1 ) ; if ( ! p_block ) return NULL ; p_block -> i_dts = p_pic -> date - p_sys -> i_pts_offset ; block_FifoPut ( p_sys -> p_dts_fifo , p_block ) ; p_block = NULL ; if ( schro_encoder_setting_get_double ( p_sys -> p_schro , "interlaced_coding" ) > 0.0 ) { StorePicturePTS ( p_enc , p_sys -> i_input_picnum , p_pic -> date + p_sys -> i_field_time ) ; p_sys -> i_input_picnum ++ ; p_block = block_Alloc ( 1 ) ; if ( ! p_block ) return NULL ; p_block -> i_dts = p_pic -> date - p_sys -> i_pts_offset + p_sys -> i_field_time ; block_FifoPut ( p_sys -> p_dts_fifo , p_block ) ; p_block = NULL ; } } do { SchroStateEnum state ; state = schro_encoder_wait ( p_sys -> p_schro ) ; switch ( state ) { case SCHRO_STATE_NEED_FRAME : b_go = false ; break ; case SCHRO_STATE_AGAIN : break ; case SCHRO_STATE_END_OF_STREAM : p_sys -> b_eos_pulled = 1 ; b_go = false ; break ; case SCHRO_STATE_HAVE_BUFFER : { SchroBuffer * p_enc_buf ; uint32_t u_pic_num ; int i_presentation_frame ; p_enc_buf = schro_encoder_pull ( p_sys -> p_schro , & i_presentation_frame ) ; p_block = block_Alloc ( p_enc_buf -> length ) ; if ( ! p_block ) return NULL ; memcpy ( p_block -> p_buffer , p_enc_buf -> data , p_enc_buf -> length ) ; schro_buffer_unref ( p_enc_buf ) ; if ( 0 == p_block -> p_buffer [ 4 ] ) { p_block -> i_flags |= BLOCK_FLAG_TYPE_I ; if ( ! p_enc -> fmt_out . p_extra ) { const uint8_t eos [ ] = { 'B' , 'B' , 'C' , 'D' , 0x10 , 0 , 0 , 0 , 13 , 0 , 0 , 0 , 0 } ; uint32_t len = GetDWBE ( p_block -> p_buffer + 5 ) ; p_enc -> fmt_out . p_extra = malloc ( len + sizeof ( eos ) ) ; if ( ! p_enc -> fmt_out . p_extra ) return NULL ; memcpy ( p_enc -> fmt_out . p_extra , p_block -> p_buffer , len ) ; memcpy ( ( uint8_t * ) p_enc -> fmt_out . p_extra + len , eos , sizeof ( eos ) ) ; SetDWBE ( ( uint8_t * ) p_enc -> fmt_out . p_extra + len + sizeof ( eos ) - 4 , len ) ; p_enc -> fmt_out . i_extra = len + sizeof ( eos ) ; } } if ( ReadDiracPictureNumber ( & u_pic_num , p_block ) ) { block_t * p_dts_block = block_FifoGet ( p_sys -> p_dts_fifo ) ; p_block -> i_dts = p_dts_block -> i_dts ; p_block -> i_pts = GetPicturePTS ( p_enc , u_pic_num ) ; block_Release ( p_dts_block ) ; block_ChainAppend ( & p_output_chain , p_block ) ; } else { block_ChainAppend ( & p_output_chain , p_block ) ; } break ; } default : break ; } } while ( b_go ) ; return p_output_chain ; }
1True
Categorize the following code snippet as vulnerable or not. True or False
static void dissect_zcl_part_multiack ( tvbuff_t * tvb , proto_tree * tree , guint * offset ) { guint tvb_len = tvb_reported_length ( tvb ) ; guint i = 0 ; guint8 options ; guint16 first_frame_id ; guint16 nack_id ; static const int * ack_opts [ ] = { & hf_zbee_zcl_part_ack_opt_nack_id_len , & hf_zbee_zcl_part_ack_opt_res , NULL } ; options = tvb_get_guint8 ( tvb , * offset ) ; proto_tree_add_bitmask ( tree , tvb , * offset , hf_zbee_zcl_part_ack_opt , ett_zbee_zcl_part_ack_opts , ack_opts , ENC_NA ) ; * offset += 1 ; if ( ( options & ZBEE_ZCL_PART_ACK_OPT_NACK_LEN ) == 0 ) { first_frame_id = ( guint16 ) tvb_get_guint8 ( tvb , * offset ) ; proto_tree_add_item ( tree , hf_zbee_zcl_part_first_frame_id , tvb , * offset , 1 , ( first_frame_id & 0xFF ) ) ; * offset += 1 ; } else { first_frame_id = tvb_get_letohs ( tvb , * offset ) ; proto_tree_add_item ( tree , hf_zbee_zcl_part_first_frame_id , tvb , * offset , 2 , first_frame_id ) ; * offset += 2 ; } while ( * offset < tvb_len && i < ZBEE_ZCL_PART_NUM_NACK_ID_ETT ) { if ( ( options & ZBEE_ZCL_PART_ACK_OPT_NACK_LEN ) == 0 ) { nack_id = ( guint16 ) tvb_get_guint8 ( tvb , * offset ) ; proto_tree_add_item ( tree , hf_zbee_zcl_part_nack_id , tvb , * offset , 1 , ( nack_id & 0xFF ) ) ; * offset += 1 ; } else { nack_id = tvb_get_letohs ( tvb , * offset ) ; proto_tree_add_item ( tree , hf_zbee_zcl_part_nack_id , tvb , * offset , 2 , nack_id ) ; * offset += 2 ; } i ++ ; } }
0False
Categorize the following code snippet as vulnerable or not. True or False
static int aura_decode_frame ( AVCodecContext * avctx , void * data , int * got_frame , AVPacket * pkt ) { AVFrame * frame = data ; uint8_t * Y , * U , * V ; uint8_t val ; int x , y , ret ; const uint8_t * buf = pkt -> data ; const int8_t * delta_table = ( const int8_t * ) buf + 16 ; if ( pkt -> size != 48 + avctx -> height * avctx -> width ) { av_log ( avctx , AV_LOG_ERROR , "got a buffer with %d bytes when %d were expected\n" , pkt -> size , 48 + avctx -> height * avctx -> width ) ; return AVERROR_INVALIDDATA ; } buf += 48 ; if ( ( ret = ff_get_buffer ( avctx , frame , 0 ) ) < 0 ) { av_log ( avctx , AV_LOG_ERROR , "get_buffer() failed\n" ) ; return ret ; } Y = frame -> data [ 0 ] ; U = frame -> data [ 1 ] ; V = frame -> data [ 2 ] ; for ( y = 0 ; y < avctx -> height ; y ++ ) { val = * buf ++ ; U [ 0 ] = val & 0xF0 ; Y [ 0 ] = val << 4 ; val = * buf ++ ; V [ 0 ] = val & 0xF0 ; Y [ 1 ] = Y [ 0 ] + delta_table [ val & 0xF ] ; Y += 2 ; U ++ ; V ++ ; for ( x = 1 ; x < ( avctx -> width >> 1 ) ; x ++ ) { val = * buf ++ ; U [ 0 ] = U [ - 1 ] + delta_table [ val >> 4 ] ; Y [ 0 ] = Y [ - 1 ] + delta_table [ val & 0xF ] ; val = * buf ++ ; V [ 0 ] = V [ - 1 ] + delta_table [ val >> 4 ] ; Y [ 1 ] = Y [ 0 ] + delta_table [ val & 0xF ] ; Y += 2 ; U ++ ; V ++ ; } Y += frame -> linesize [ 0 ] - avctx -> width ; U += frame -> linesize [ 1 ] - ( avctx -> width >> 1 ) ; V += frame -> linesize [ 2 ] - ( avctx -> width >> 1 ) ; } * got_frame = 1 ; return pkt -> size ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static int show_default_keycache ( THD * thd , SHOW_VAR * var , char * buff ) { struct st_data { KEY_CACHE_STATISTICS stats ; SHOW_VAR var [ 8 ] ; } * data ; SHOW_VAR * v ; data = ( st_data * ) buff ; v = data -> var ; var -> type = SHOW_ARRAY ; var -> value = ( char * ) v ; get_key_cache_statistics ( dflt_key_cache , 0 , & data -> stats ) ; # define set_one_keycache_var ( X , Y ) v -> name = X ; v -> type = SHOW_LONGLONG ; v -> value = ( char * ) & data -> stats . Y ; v ++ ; set_one_keycache_var ( "blocks_not_flushed" , blocks_changed ) ; set_one_keycache_var ( "blocks_unused" , blocks_unused ) ; set_one_keycache_var ( "blocks_used" , blocks_used ) ; set_one_keycache_var ( "blocks_warm" , blocks_warm ) ; set_one_keycache_var ( "read_requests" , read_requests ) ; set_one_keycache_var ( "reads" , reads ) ; set_one_keycache_var ( "write_requests" , write_requests ) ; set_one_keycache_var ( "writes" , writes ) ; v -> name = 0 ; DBUG_ASSERT ( ( char * ) ( v + 1 ) <= buff + SHOW_VAR_FUNC_BUFF_SIZE ) ; # undef set_one_keycache_var return 0 ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static bool config_filter_match_local_name ( const struct config_filter * mask , const char * filter_local_name ) { const char * const * local_name = t_strsplit_spaces ( mask -> local_name , " " ) ; for ( ; * local_name != NULL ; local_name ++ ) { if ( dns_match_wildcard ( filter_local_name , * local_name ) == 0 ) return TRUE ; } return FALSE ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
void Curl_add_buffer_free ( Curl_send_buffer * buff ) { if ( buff ) free ( buff -> buffer ) ; free ( buff ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
void tb_flush ( CPUArchState * env1 ) { CPUArchState * env ; # if defined ( DEBUG_FLUSH ) printf ( "qemu: flush code_size=%ld nb_tbs=%d avg_tb_size=%ld\n" , ( unsigned long ) ( tcg_ctx . code_gen_ptr - tcg_ctx . code_gen_buffer ) , tcg_ctx . tb_ctx . nb_tbs , tcg_ctx . tb_ctx . nb_tbs > 0 ? ( ( unsigned long ) ( tcg_ctx . code_gen_ptr - tcg_ctx . code_gen_buffer ) ) / tcg_ctx . tb_ctx . nb_tbs : 0 ) ; # endif if ( ( unsigned long ) ( tcg_ctx . code_gen_ptr - tcg_ctx . code_gen_buffer ) > tcg_ctx . code_gen_buffer_size ) { cpu_abort ( env1 , "Internal error: code buffer overflow\n" ) ; } tcg_ctx . tb_ctx . nb_tbs = 0 ; for ( env = first_cpu ; env != NULL ; env = env -> next_cpu ) { memset ( env -> tb_jmp_cache , 0 , TB_JMP_CACHE_SIZE * sizeof ( void * ) ) ; } memset ( tcg_ctx . tb_ctx . tb_phys_hash , 0 , CODE_GEN_PHYS_HASH_SIZE * sizeof ( void * ) ) ; page_flush_tb ( ) ; tcg_ctx . code_gen_ptr = tcg_ctx . code_gen_buffer ; tcg_ctx . tb_ctx . tb_flush_count ++ ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static void dissect_q931_ns_facilities_ie ( tvbuff_t * tvb , int offset , int len , proto_tree * tree ) { guint8 octet ; int netid_len ; if ( len == 0 ) return ; octet = tvb_get_guint8 ( tvb , offset ) ; netid_len = octet & 0x7F ; proto_tree_add_item ( tree , hf_q931_netid_length , tvb , offset , 1 , ENC_BIG_ENDIAN ) ; offset += 1 ; len -= 1 ; if ( netid_len != 0 ) { if ( len == 0 ) return ; proto_tree_add_item ( tree , hf_q931_netid_type , tvb , offset , 1 , ENC_BIG_ENDIAN ) ; proto_tree_add_item ( tree , hf_q931_netid_plan , tvb , offset , 1 , ENC_BIG_ENDIAN ) ; offset += 1 ; len -= 1 ; netid_len -- ; if ( len == 0 ) return ; if ( netid_len > len ) netid_len = len ; if ( netid_len != 0 ) { proto_tree_add_item ( tree , hf_q931_netid , tvb , offset , netid_len , ENC_NA | ENC_ASCII ) ; offset += netid_len ; len -= netid_len ; } } if ( len == 0 ) return ; proto_tree_add_item ( tree , hf_q931_netid_facility_specification , tvb , offset , len , ENC_NA ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static void _enableTriggersIfNecessary ( ArchiveHandle * AH , TocEntry * te ) { RestoreOptions * ropt = AH -> public . ropt ; if ( ! ropt -> dataOnly || ! ropt -> disable_triggers ) return ; ahlog ( AH , 1 , "enabling triggers for %s\n" , te -> tag ) ; _becomeUser ( AH , ropt -> superuser ) ; _selectOutputSchema ( AH , te -> namespace ) ; ahprintf ( AH , "ALTER TABLE %s ENABLE TRIGGER ALL; \n\n" , fmtId ( te -> tag ) ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static void dissect_cip_safety_data ( proto_tree * tree , proto_item * item , tvbuff_t * tvb , int item_length , packet_info * pinfo ) { int base_length , io_data_size ; gboolean multicast = ( ( ( pntoh32 ( pinfo -> dst . data ) ) & 0xf0000000 ) == 0xe0000000 ) ; gboolean server_dir = FALSE ; enum enip_connid_type conn_type = ECIDT_UNKNOWN ; enum cip_safety_format_type format = CIP_SAFETY_BASE_FORMAT ; cip_safety_info_t * safety_info = ( cip_safety_info_t * ) p_get_proto_data ( wmem_file_scope ( ) , pinfo , proto_cipsafety , 0 ) ; col_set_str ( pinfo -> cinfo , COL_PROTOCOL , "CIP Safety" ) ; if ( safety_info != NULL ) { conn_type = safety_info -> conn_type ; format = safety_info -> format ; server_dir = safety_info -> server_dir ; } base_length = multicast ? 12 : 6 ; if ( ( ( conn_type == ECIDT_O2T ) && ( server_dir == FALSE ) ) || ( ( conn_type == ECIDT_T2O ) && ( server_dir == TRUE ) ) ) { dissect_ack_byte ( tree , tvb , 0 , pinfo ) ; proto_tree_add_item ( tree , hf_cipsafety_consumer_time_value , tvb , 1 , 2 , ENC_LITTLE_ENDIAN ) ; switch ( format ) { case CIP_SAFETY_BASE_FORMAT : proto_tree_add_item ( tree , hf_cipsafety_ack_byte2 , tvb , 3 , 1 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( tree , hf_cipsafety_crc_s3 , tvb , 4 , 2 , ENC_LITTLE_ENDIAN ) ; break ; case CIP_SAFETY_EXTENDED_FORMAT : proto_tree_add_item ( tree , hf_cipsafety_crc_s5_0 , tvb , 3 , 1 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( tree , hf_cipsafety_crc_s5_1 , tvb , 4 , 1 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( tree , hf_cipsafety_crc_s5_2 , tvb , 5 , 1 , ENC_LITTLE_ENDIAN ) ; break ; } } else if ( ( ( conn_type == ECIDT_O2T ) && ( server_dir == TRUE ) ) || ( ( conn_type == ECIDT_T2O ) && ( server_dir == FALSE ) ) ) { switch ( format ) { case CIP_SAFETY_BASE_FORMAT : if ( item_length - base_length <= 2 ) { proto_tree_add_item ( tree , hf_cipsafety_data , tvb , 0 , item_length - base_length , ENC_NA ) ; dissect_mode_byte ( tree , tvb , item_length - base_length , pinfo ) ; proto_tree_add_item ( tree , hf_cipsafety_crc_s1 , tvb , item_length - base_length + 1 , 1 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( tree , hf_cipsafety_crc_s2 , tvb , item_length - base_length + 2 , 1 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( tree , hf_cipsafety_timestamp , tvb , item_length - base_length + 3 , 2 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( tree , hf_cipsafety_crc_s1 , tvb , item_length - base_length + 5 , 1 , ENC_LITTLE_ENDIAN ) ; if ( multicast ) { dissect_mcast_byte ( tree , tvb , item_length - 6 , pinfo ) ; proto_tree_add_item ( tree , hf_cipsafety_time_correction , tvb , item_length - 5 , 2 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( tree , hf_cipsafety_mcast_byte2 , tvb , item_length - 3 , 1 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( tree , hf_cipsafety_crc_s3 , tvb , item_length - 2 , 2 , ENC_LITTLE_ENDIAN ) ; } } else { if ( item_length % 2 == 1 ) { expert_add_info ( pinfo , item , & ei_mal_io ) ; return ; } io_data_size = multicast ? ( ( item_length - 14 ) / 2 ) : ( ( item_length - 8 ) / 2 ) ; proto_tree_add_item ( tree , hf_cipsafety_data , tvb , 0 , io_data_size , ENC_NA ) ; dissect_mode_byte ( tree , tvb , io_data_size , pinfo ) ; proto_tree_add_item ( tree , hf_cipsafety_crc_s3 , tvb , io_data_size + 1 , 2 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( tree , hf_cipsafety_complement_data , tvb , io_data_size + 3 , io_data_size , ENC_NA ) ; proto_tree_add_item ( tree , hf_cipsafety_crc_s3 , tvb , ( io_data_size * 2 ) + 3 , 2 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( tree , hf_cipsafety_timestamp , tvb , ( io_data_size * 2 ) + 5 , 2 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( tree , hf_cipsafety_crc_s1 , tvb , ( io_data_size * 2 ) + 7 , 1 , ENC_LITTLE_ENDIAN ) ; if ( multicast ) { dissect_mcast_byte ( tree , tvb , ( io_data_size * 2 ) + 5 , pinfo ) ; proto_tree_add_item ( tree , hf_cipsafety_time_correction , tvb , ( io_data_size * 2 ) + 6 , 2 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( tree , hf_cipsafety_mcast_byte2 , tvb , ( io_data_size * 2 ) + 8 , 1 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( tree , hf_cipsafety_crc_s3 , tvb , ( io_data_size * 2 ) + 9 , 2 , ENC_LITTLE_ENDIAN ) ; } } break ; case CIP_SAFETY_EXTENDED_FORMAT : if ( item_length - base_length <= 2 ) { proto_tree_add_item ( tree , hf_cipsafety_data , tvb , 0 , item_length - base_length , ENC_NA ) ; dissect_mode_byte ( tree , tvb , item_length - base_length , pinfo ) ; proto_tree_add_item ( tree , hf_cipsafety_crc_s5_0 , tvb , item_length - base_length + 1 , 1 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( tree , hf_cipsafety_crc_s5_1 , tvb , item_length - base_length + 2 , 1 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( tree , hf_cipsafety_timestamp , tvb , item_length - base_length + 3 , 2 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( tree , hf_cipsafety_crc_s5_2 , tvb , item_length - base_length + 5 , 1 , ENC_LITTLE_ENDIAN ) ; if ( multicast ) { dissect_mcast_byte ( tree , tvb , item_length - 6 , pinfo ) ; proto_tree_add_item ( tree , hf_cipsafety_time_correction , tvb , item_length - 5 , 2 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( tree , hf_cipsafety_crc_s5_0 , tvb , item_length - 3 , 1 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( tree , hf_cipsafety_crc_s5_1 , tvb , item_length - 2 , 1 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( tree , hf_cipsafety_crc_s5_2 , tvb , item_length - 1 , 1 , ENC_LITTLE_ENDIAN ) ; } } else { if ( item_length % 2 == 1 ) { expert_add_info ( pinfo , item , & ei_mal_io ) ; return ; } io_data_size = multicast ? ( ( item_length - 14 ) / 2 ) : ( ( item_length - 8 ) / 2 ) ; proto_tree_add_item ( tree , hf_cipsafety_data , tvb , 0 , io_data_size , ENC_NA ) ; dissect_mode_byte ( tree , tvb , io_data_size , pinfo ) ; proto_tree_add_item ( tree , hf_cipsafety_crc_s3 , tvb , io_data_size + 1 , 2 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( tree , hf_cipsafety_complement_data , tvb , io_data_size + 3 , io_data_size , ENC_NA ) ; proto_tree_add_item ( tree , hf_cipsafety_crc_s5_0 , tvb , ( io_data_size * 2 ) + 3 , 1 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( tree , hf_cipsafety_crc_s5_1 , tvb , ( io_data_size * 2 ) + 4 , 1 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( tree , hf_cipsafety_timestamp , tvb , ( io_data_size * 2 ) + 5 , 2 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( tree , hf_cipsafety_crc_s5_2 , tvb , ( io_data_size * 2 ) + 7 , 1 , ENC_LITTLE_ENDIAN ) ; if ( multicast ) { dissect_mcast_byte ( tree , tvb , ( io_data_size * 2 ) + 8 , pinfo ) ; proto_tree_add_item ( tree , hf_cipsafety_time_correction , tvb , ( io_data_size * 2 ) + 9 , 2 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( tree , hf_cipsafety_crc_s5_0 , tvb , ( io_data_size * 2 ) + 11 , 1 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( tree , hf_cipsafety_crc_s5_1 , tvb , ( io_data_size * 2 ) + 12 , 1 , ENC_LITTLE_ENDIAN ) ; proto_tree_add_item ( tree , hf_cipsafety_crc_s5_2 , tvb , ( io_data_size * 2 ) + 13 , 1 , ENC_LITTLE_ENDIAN ) ; } } break ; } } else { proto_tree_add_item ( tree , hf_cipsafety_data , tvb , 0 , item_length , ENC_NA ) ; } }
1True
Categorize the following code snippet as vulnerable or not. True or False
static int s_aes_process ( stream_state * ss , stream_cursor_read * pr , stream_cursor_write * pw , bool last ) { stream_aes_state * const state = ( stream_aes_state * ) ss ; const unsigned char * limit ; const long in_size = pr -> limit - pr -> ptr ; const long out_size = pw -> limit - pw -> ptr ; unsigned char temp [ 16 ] ; int status = 0 ; if ( in_size > out_size ) { limit = pr -> ptr + out_size ; status = 1 ; } else { limit = pr -> limit ; status = last ? EOFC : 0 ; } if ( state -> ctx == NULL ) { state -> ctx = ( aes_context * ) gs_alloc_bytes_immovable ( state -> memory , sizeof ( aes_context ) , "aes context structure" ) ; if ( state -> ctx == NULL ) { gs_throw ( gs_error_VMerror , "could not allocate aes context" ) ; return ERRC ; } if ( state -> keylength < 1 || state -> keylength > SAES_MAX_KEYLENGTH ) { gs_throw1 ( gs_error_rangecheck , "invalid aes key length (%d bytes)" , state -> keylength ) ; return ERRC ; } aes_setkey_dec ( state -> ctx , state -> key , state -> keylength * 8 ) ; } if ( ! state -> initialized ) { if ( in_size < 16 ) return 0 ; memcpy ( state -> iv , pr -> ptr + 1 , 16 ) ; state -> initialized = 1 ; pr -> ptr += 16 ; } while ( pr -> ptr + 16 <= limit ) { aes_crypt_cbc ( state -> ctx , AES_DECRYPT , 16 , state -> iv , pr -> ptr + 1 , temp ) ; pr -> ptr += 16 ; if ( last && pr -> ptr == pr -> limit ) { int pad ; if ( state -> use_padding ) { pad = temp [ 15 ] ; if ( pad < 1 || pad > 16 ) { gs_warn1 ( "invalid aes padding byte (0x%02x)" , ( unsigned char ) pad ) ; pad = 0 ; } } else { pad = 0 ; } memcpy ( pw -> ptr + 1 , temp , 16 - pad ) ; pw -> ptr += 16 - pad ; return EOFC ; } memcpy ( pw -> ptr + 1 , temp , 16 ) ; pw -> ptr += 16 ; } if ( status == EOFC ) { gs_throw ( gs_error_rangecheck , "aes stream isn't a multiple of 16 bytes" ) ; return 0 ; } return status ; }
1True
Categorize the following code snippet as vulnerable or not. True or False
static int parsedate ( const char * date , time_t * output ) { time_t t = 0 ; int wdaynum = - 1 ; int monnum = - 1 ; int mdaynum = - 1 ; int hournum = - 1 ; int minnum = - 1 ; int secnum = - 1 ; int yearnum = - 1 ; int tzoff = - 1 ; struct my_tm tm ; enum assume dignext = DATE_MDAY ; const char * indate = date ; int part = 0 ; while ( * date && ( part < 6 ) ) { bool found = FALSE ; skip ( & date ) ; if ( ISALPHA ( * date ) ) { char buf [ 32 ] = "" ; size_t len ; if ( sscanf ( date , "%31[ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz]" , buf ) ) len = strlen ( buf ) ; else len = 0 ; if ( wdaynum == - 1 ) { wdaynum = checkday ( buf , len ) ; if ( wdaynum != - 1 ) found = TRUE ; } if ( ! found && ( monnum == - 1 ) ) { monnum = checkmonth ( buf ) ; if ( monnum != - 1 ) found = TRUE ; } if ( ! found && ( tzoff == - 1 ) ) { tzoff = checktz ( buf ) ; if ( tzoff != - 1 ) found = TRUE ; } if ( ! found ) return PARSEDATE_FAIL ; date += len ; } else if ( ISDIGIT ( * date ) ) { int val ; char * end ; int len = 0 ; if ( ( secnum == - 1 ) && ( 3 == sscanf ( date , "%02d:%02d:%02d%n" , & hournum , & minnum , & secnum , & len ) ) ) { date += len ; } else if ( ( secnum == - 1 ) && ( 2 == sscanf ( date , "%02d:%02d%n" , & hournum , & minnum , & len ) ) ) { date += len ; secnum = 0 ; } else { long lval ; int error ; int old_errno ; old_errno = ERRNO ; SET_ERRNO ( 0 ) ; lval = strtol ( date , & end , 10 ) ; error = ERRNO ; if ( error != old_errno ) SET_ERRNO ( old_errno ) ; if ( error ) return PARSEDATE_FAIL ; # if LONG_MAX != INT_MAX if ( ( lval > ( long ) INT_MAX ) || ( lval < ( long ) INT_MIN ) ) return PARSEDATE_FAIL ; # endif val = curlx_sltosi ( lval ) ; if ( ( tzoff == - 1 ) && ( ( end - date ) == 4 ) && ( val <= 1400 ) && ( indate < date ) && ( ( date [ - 1 ] == '+' || date [ - 1 ] == '-' ) ) ) { found = TRUE ; tzoff = ( val / 100 * 60 + val % 100 ) * 60 ; tzoff = date [ - 1 ] == '+' ? - tzoff : tzoff ; } if ( ( ( end - date ) == 8 ) && ( yearnum == - 1 ) && ( monnum == - 1 ) && ( mdaynum == - 1 ) ) { found = TRUE ; yearnum = val / 10000 ; monnum = ( val % 10000 ) / 100 - 1 ; mdaynum = val % 100 ; } if ( ! found && ( dignext == DATE_MDAY ) && ( mdaynum == - 1 ) ) { if ( ( val > 0 ) && ( val < 32 ) ) { mdaynum = val ; found = TRUE ; } dignext = DATE_YEAR ; } if ( ! found && ( dignext == DATE_YEAR ) && ( yearnum == - 1 ) ) { yearnum = val ; found = TRUE ; if ( yearnum < 1900 ) { if ( yearnum > 70 ) yearnum += 1900 ; else yearnum += 2000 ; } if ( mdaynum == - 1 ) dignext = DATE_MDAY ; } if ( ! found ) return PARSEDATE_FAIL ; date = end ; } } part ++ ; } if ( - 1 == secnum ) secnum = minnum = hournum = 0 ; if ( ( - 1 == mdaynum ) || ( - 1 == monnum ) || ( - 1 == yearnum ) ) return PARSEDATE_FAIL ; # if SIZEOF_TIME_T < 5 if ( yearnum > 2037 ) { * output = 0x7fffffff ; return PARSEDATE_LATER ; } # endif if ( yearnum < 1970 ) { * output = 0 ; return PARSEDATE_SOONER ; } if ( ( mdaynum > 31 ) || ( monnum > 11 ) || ( hournum > 23 ) || ( minnum > 59 ) || ( secnum > 60 ) ) return PARSEDATE_FAIL ; tm . tm_sec = secnum ; tm . tm_min = minnum ; tm . tm_hour = hournum ; tm . tm_mday = mdaynum ; tm . tm_mon = monnum ; tm . tm_year = yearnum - 1900 ; t = my_timegm ( & tm ) ; if ( - 1 != ( int ) t ) { long delta = ( long ) ( tzoff != - 1 ? tzoff : 0 ) ; if ( ( delta > 0 ) && ( t > LONG_MAX - delta ) ) { * output = 0x7fffffff ; return PARSEDATE_LATER ; } t += delta ; } * output = t ; return PARSEDATE_OK ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
ParseResult mime_parser_parse ( MIMEParser * parser , HdrHeap * heap , MIMEHdrImpl * mh , const char * * real_s , const char * real_e , bool must_copy_strings , bool eof ) { ParseResult err ; bool line_is_real ; const char * colon ; const char * line_c ; const char * line_s = nullptr ; const char * line_e = nullptr ; const char * field_name_first ; const char * field_name_last ; const char * field_value_first ; const char * field_value_last ; const char * field_line_first ; const char * field_line_last ; int field_name_length , field_value_length ; MIMEScanner * scanner = & parser -> m_scanner ; while ( true ) { err = mime_scanner_get ( scanner , real_s , real_e , & line_s , & line_e , & line_is_real , eof , MIME_SCANNER_TYPE_FIELD ) ; if ( err != PARSE_RESULT_OK ) { return err ; } line_c = line_s ; if ( ( line_e - line_c >= 2 ) && ( line_c [ 0 ] == ParseRules : : CHAR_CR ) && ( line_c [ 1 ] == ParseRules : : CHAR_LF ) ) { return PARSE_RESULT_DONE ; } if ( ( line_e - line_c >= 1 ) && ( line_c [ 0 ] == ParseRules : : CHAR_LF ) ) { return PARSE_RESULT_DONE ; } field_line_first = line_c ; field_line_last = line_e - 1 ; field_name_first = line_c ; if ( ( ! ParseRules : : is_token ( * field_name_first ) ) && ( * field_name_first != '@' ) ) { continue ; } colon = ( char * ) memchr ( line_c , ':' , ( line_e - line_c ) ) ; if ( ! colon ) { continue ; } field_name_last = colon - 1 ; if ( ( field_name_last >= field_name_first ) && is_ws ( * field_name_last ) ) { return PARSE_RESULT_ERROR ; } field_value_first = colon + 1 ; while ( ( field_value_first < line_e ) && is_ws ( * field_value_first ) ) { ++ field_value_first ; } field_value_last = line_e - 1 ; while ( ( field_value_last >= field_value_first ) && ParseRules : : is_wslfcr ( * field_value_last ) ) { -- field_value_last ; } field_name_length = ( int ) ( field_name_last - field_name_first + 1 ) ; field_value_length = ( int ) ( field_value_last - field_value_first + 1 ) ; if ( field_name_length >= UINT16_MAX || field_value_length >= UINT16_MAX ) { return PARSE_RESULT_ERROR ; } int total_line_length = ( int ) ( field_line_last - field_line_first + 1 ) ; if ( must_copy_strings || ( ! line_is_real ) ) { int length = total_line_length ; char * dup = heap -> duplicate_str ( field_name_first , length ) ; intptr_t delta = dup - field_name_first ; field_name_first += delta ; field_value_first += delta ; } int field_name_wks_idx = hdrtoken_tokenize ( field_name_first , field_name_length ) ; MIMEField * field = mime_field_create ( heap , mh ) ; mime_field_name_value_set ( heap , mh , field , field_name_wks_idx , field_name_first , field_name_length , field_value_first , field_value_length , true , total_line_length , false ) ; mime_hdr_field_attach ( mh , field , 1 , nullptr ) ; } }
0False
Categorize the following code snippet as vulnerable or not. True or False
static PyObject * authGSSClientInit ( PyObject * self , PyObject * args , PyObject * keywds ) { const char * service = NULL ; const char * principal = NULL ; gss_client_state * state ; PyObject * pystate ; static char * kwlist [ ] = { "service" , "principal" , "gssflags" , NULL } ; long int gss_flags = GSS_C_MUTUAL_FLAG | GSS_C_SEQUENCE_FLAG ; int result = 0 ; if ( ! PyArg_ParseTupleAndKeywords ( args , keywds , "s|zl" , kwlist , & service , & principal , & gss_flags ) ) return NULL ; state = ( gss_client_state * ) malloc ( sizeof ( gss_client_state ) ) ; # if PY_MAJOR_VERSION >= 3 pystate = PyCapsule_New ( state , NULL , NULL ) ; # else pystate = PyCObject_FromVoidPtr ( state , NULL ) ; # endif result = authenticate_gss_client_init ( service , principal , gss_flags , state ) ; if ( result == AUTH_GSS_ERROR ) return NULL ; return Py_BuildValue ( "(iO)" , result , pystate ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
afs_int32 UpdateEntry ( struct rx_call * call , afs_int32 aid , char * name , struct PrUpdateEntry * uentry , afs_int32 * cid ) { afs_int32 code ; struct ubik_trans * tt ; struct prentry tentry ; afs_int32 loc ; int id = 0 ; code = Initdb ( ) ; if ( code ) return code ; if ( code != PRSUCCESS ) return code ; if ( aid ) { id = aid ; if ( aid == SYSADMINID || aid == ANYUSERID || aid == AUTHUSERID || aid == ANONYMOUSID ) return PRPERM ; } code = ubik_BeginTrans ( dbase , UBIK_WRITETRANS , & tt ) ; if ( code ) return code ; code = ubik_SetLock ( tt , 1 , 1 , LOCKWRITE ) ; if ( code ) ABORT_WITH ( tt , code ) ; code = read_DbHeader ( tt ) ; if ( code ) ABORT_WITH ( tt , code ) ; code = WhoIsThis ( call , tt , cid ) ; if ( code ) ABORT_WITH ( tt , PRPERM ) ; code = IsAMemberOf ( tt , * cid , SYSADMINID ) ; if ( ! code && ! pr_noAuth ) ABORT_WITH ( tt , PRPERM ) ; if ( id ) { loc = FindByID ( tt , aid ) ; } else { loc = FindByName ( tt , name , & tentry ) ; } if ( loc == 0 ) ABORT_WITH ( tt , PRNOENT ) ; code = pr_ReadEntry ( tt , 0 , loc , & tentry ) ; if ( code ) ABORT_WITH ( tt , PRDBFAIL ) ; if ( uentry -> Mask & PRUPDATE_NAMEHASH ) { int tloc ; code = RemoveFromNameHash ( tt , tentry . name , & tloc ) ; if ( code != PRSUCCESS ) ABORT_WITH ( tt , PRDBFAIL ) ; code = AddToNameHash ( tt , tentry . name , loc ) ; if ( code ) ABORT_WITH ( tt , code ) ; } if ( uentry -> Mask & PRUPDATE_IDHASH ) { int tloc ; if ( ! id ) id = tentry . id ; code = RemoveFromIDHash ( tt , id , & tloc ) ; if ( code != PRSUCCESS ) ABORT_WITH ( tt , PRDBFAIL ) ; code = AddToIDHash ( tt , id , loc ) ; if ( code ) ABORT_WITH ( tt , code ) ; } code = ubik_EndTrans ( tt ) ; if ( code ) return code ; return PRSUCCESS ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static int svq1_encode_frame ( AVCodecContext * avctx , AVPacket * pkt , const AVFrame * pict , int * got_packet ) { SVQ1Context * const s = avctx -> priv_data ; AVFrame * const p = & s -> picture ; AVFrame temp ; int i , ret ; if ( ! pkt -> data && ( ret = av_new_packet ( pkt , s -> y_block_width * s -> y_block_height * MAX_MB_BYTES * 3 + FF_MIN_BUFFER_SIZE ) ) < 0 ) { av_log ( avctx , AV_LOG_ERROR , "Error getting output packet.\n" ) ; return ret ; } if ( avctx -> pix_fmt != AV_PIX_FMT_YUV410P ) { av_log ( avctx , AV_LOG_ERROR , "unsupported pixel format\n" ) ; return - 1 ; } if ( ! s -> current_picture . data [ 0 ] ) { ff_get_buffer ( avctx , & s -> current_picture , 0 ) ; ff_get_buffer ( avctx , & s -> last_picture , 0 ) ; s -> scratchbuf = av_malloc ( s -> current_picture . linesize [ 0 ] * 16 * 2 ) ; } temp = s -> current_picture ; s -> current_picture = s -> last_picture ; s -> last_picture = temp ; init_put_bits ( & s -> pb , pkt -> data , pkt -> size ) ; * p = * pict ; p -> pict_type = avctx -> gop_size && avctx -> frame_number % avctx -> gop_size ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I ; p -> key_frame = p -> pict_type == AV_PICTURE_TYPE_I ; svq1_write_header ( s , p -> pict_type ) ; for ( i = 0 ; i < 3 ; i ++ ) if ( svq1_encode_plane ( s , i , s -> picture . data [ i ] , s -> last_picture . data [ i ] , s -> current_picture . data [ i ] , s -> frame_width / ( i ? 4 : 1 ) , s -> frame_height / ( i ? 4 : 1 ) , s -> picture . linesize [ i ] , s -> current_picture . linesize [ i ] ) < 0 ) return - 1 ; while ( put_bits_count ( & s -> pb ) & 31 ) put_bits ( & s -> pb , 1 , 0 ) ; flush_put_bits ( & s -> pb ) ; pkt -> size = put_bits_count ( & s -> pb ) / 8 ; if ( p -> pict_type == AV_PICTURE_TYPE_I ) pkt -> flags |= AV_PKT_FLAG_KEY ; * got_packet = 1 ; return 0 ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static VALUE ossl_asn1obj_get_sn ( VALUE self ) { VALUE val , ret = Qnil ; int nid ; val = ossl_asn1_get_value ( self ) ; if ( ( nid = OBJ_txt2nid ( StringValueCStr ( val ) ) ) != NID_undef ) ret = rb_str_new2 ( OBJ_nid2sn ( nid ) ) ; return ret ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static int file_path_add ( gs_main_instance * minst , gs_file_path * pfp , const char * dirs ) { uint len = r_size ( & pfp -> list ) ; const char * dpath = dirs ; int code ; if ( dirs == 0 ) return 0 ; for ( ; ; ) { const char * npath = dpath ; while ( * npath != 0 && * npath != gp_file_name_list_separator ) npath ++ ; if ( npath > dpath ) { if ( len == r_size ( & pfp -> container ) ) { code = extend_path_list_container ( minst , pfp ) ; if ( code < 0 ) { emprintf ( minst -> heap , "\nAdding path to search paths failed.\n" ) ; return ( code ) ; } } make_const_string ( & pfp -> container . value . refs [ len ] , avm_foreign | a_readonly , npath - dpath , ( const byte * ) dpath ) ; ++ len ; } if ( ! * npath ) break ; dpath = npath + 1 ; } r_set_size ( & pfp -> list , len ) ; return 0 ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static void evsignal_handler ( int sig ) { int save_errno = errno ; if ( evsignal_base == NULL ) { event_warn ( "%s: received signal %d, but have no base configured" , __func__ , sig ) ; return ; } evsignal_base -> sig . evsigcaught [ sig ] ++ ; evsignal_base -> sig . evsignal_caught = 1 ; # ifndef HAVE_SIGACTION signal ( sig , evsignal_handler ) ; # endif send ( evsignal_base -> sig . ev_signal_pair [ 0 ] , "a" , 1 , 0 ) ; errno = save_errno ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
int dissect_ber_integer ( gboolean implicit_tag , asn1_ctx_t * actx , proto_tree * tree , tvbuff_t * tvb , int offset , gint hf_id , guint32 * value ) { gint64 val ; offset = dissect_ber_integer64 ( implicit_tag , actx , tree , tvb , offset , hf_id , & val ) ; if ( value ) { * value = ( guint32 ) val ; } return offset ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
fz_path * xps_parse_path_geometry ( xps_document * doc , xps_resource * dict , fz_xml * root , int stroking , int * fill_rule ) { fz_xml * node ; char * figures_att ; char * fill_rule_att ; char * transform_att ; fz_xml * transform_tag = NULL ; fz_xml * figures_tag = NULL ; fz_matrix transform ; fz_path * path ; figures_att = fz_xml_att ( root , "Figures" ) ; fill_rule_att = fz_xml_att ( root , "FillRule" ) ; transform_att = fz_xml_att ( root , "Transform" ) ; for ( node = fz_xml_down ( root ) ; node ; node = fz_xml_next ( node ) ) { if ( ! strcmp ( fz_xml_tag ( node ) , "PathGeometry.Transform" ) ) transform_tag = fz_xml_down ( node ) ; } xps_resolve_resource_reference ( doc , dict , & transform_att , & transform_tag , NULL ) ; xps_resolve_resource_reference ( doc , dict , & figures_att , & figures_tag , NULL ) ; if ( fill_rule_att ) { if ( ! strcmp ( fill_rule_att , "NonZero" ) ) * fill_rule = 1 ; if ( ! strcmp ( fill_rule_att , "EvenOdd" ) ) * fill_rule = 0 ; } transform = fz_identity ; if ( transform_att ) xps_parse_render_transform ( doc , transform_att , & transform ) ; if ( transform_tag ) xps_parse_matrix_transform ( doc , transform_tag , & transform ) ; if ( figures_att ) path = xps_parse_abbreviated_geometry ( doc , figures_att , fill_rule ) ; else path = fz_new_path ( doc -> ctx ) ; if ( figures_tag ) xps_parse_path_figure ( doc -> ctx , path , figures_tag , stroking ) ; for ( node = fz_xml_down ( root ) ; node ; node = fz_xml_next ( node ) ) { if ( ! strcmp ( fz_xml_tag ( node ) , "PathFigure" ) ) xps_parse_path_figure ( doc -> ctx , path , node , stroking ) ; } if ( transform_att || transform_tag ) fz_transform_path ( doc -> ctx , path , & transform ) ; return path ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static ossl_inline void sk_ ## t1 ## _zero ( STACK_OF ( t1 ) * sk ) { OPENSSL_sk_zero ( ( OPENSSL_STACK * ) sk ) ; } static ossl_inline t2 * sk_ ## t1 ## _delete ( STACK_OF ( t1 ) * sk , int i ) { return ( t2 * ) OPENSSL_sk_delete ( ( OPENSSL_STACK * ) sk , i ) ; } static ossl_inline t2 * sk_ ## t1 ## _delete_ptr ( STACK_OF ( t1 ) * sk , t2 * ptr ) { return ( t2 * ) OPENSSL_sk_delete_ptr ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr ) ; } static ossl_inline int sk_ ## t1 ## _push ( STACK_OF ( t1 ) * sk , t2 * ptr ) { return OPENSSL_sk_push ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr ) ; } static ossl_inline int sk_ ## t1 ## _unshift ( STACK_OF ( t1 ) * sk , t2 * ptr ) { return OPENSSL_sk_unshift ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr ) ; } static ossl_inline t2 * sk_ ## t1 ## _pop ( STACK_OF ( t1 ) * sk ) { return ( t2 * ) OPENSSL_sk_pop ( ( OPENSSL_STACK * ) sk ) ; } static ossl_inline t2 * sk_ ## t1 ## _shift ( STACK_OF ( t1 ) * sk ) { return ( t2 * ) OPENSSL_sk_shift ( ( OPENSSL_STACK * ) sk ) ; } static ossl_inline void sk_ ## t1 ## _pop_free ( STACK_OF ( t1 ) * sk , sk_ ## t1 ## _freefunc freefunc ) { OPENSSL_sk_pop_free ( ( OPENSSL_STACK * ) sk , ( OPENSSL_sk_freefunc ) freefunc ) ; } static ossl_inline int sk_ ## t1 ## _insert ( STACK_OF ( t1 ) * sk , t2 * ptr , int idx ) { return OPENSSL_sk_insert ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr , idx ) ; } static ossl_inline t2 * sk_ ## t1 ## _set ( STACK_OF ( t1 ) * sk , int idx , t2 * ptr ) { return ( t2 * ) OPENSSL_sk_set ( ( OPENSSL_STACK * ) sk , idx , ( const void * ) ptr ) ; } static ossl_inline int sk_ ## t1 ## _find ( STACK_OF ( t1 ) * sk , t2 * ptr ) { return OPENSSL_sk_find ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr ) ; } static ossl_inline int sk_ ## t1 ## _find_ex ( STACK_OF ( t1 ) * sk , t2 * ptr ) { return OPENSSL_sk_find_ex ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr ) ; } static ossl_inline void sk_ ## t1 ## _sort ( STACK_OF ( t1 ) * sk ) { OPENSSL_sk_sort ( ( OPENSSL_STACK * ) sk ) ; } static ossl_inline int sk_ ## t1 ## _is_sorted ( const STACK_OF ( t1 ) * sk ) { return OPENSSL_sk_is_sorted ( ( const OPENSSL_STACK * ) sk ) ; } static ossl_inline STACK_OF ( t1 ) * sk_ ## t1 ## _dup ( const STACK_OF ( t1 ) * sk ) { return ( STACK_OF ( t1 ) * ) OPENSSL_sk_dup ( ( const OPENSSL_STACK * ) sk ) ; } static ossl_inline STACK_OF ( t1 ) * sk_ ## t1 ## _deep_copy ( const STACK_OF ( t1 ) * sk , sk_ ## t1 ## _copyfunc copyfunc , sk_ ## t1 ## _freefunc freefunc ) { return ( STACK_OF ( t1 ) * ) OPENSSL_sk_deep_copy ( ( const OPENSSL_STACK * ) sk , ( OPENSSL_sk_copyfunc ) copyfunc , ( OPENSSL_sk_freefunc ) freefunc ) ; } static ossl_inline sk_ ## t1 ## _compfunc sk_ ## t1 ## _set_cmp_func ( STACK_OF ( t1 ) * sk , sk_ ## t1 ## _compfunc compare ) { return ( sk_ ## t1 ## _compfunc ) OPENSSL_sk_set_cmp_func ( ( OPENSSL_STACK * ) sk , ( OPENSSL_sk_compfunc ) compare ) ; } # define DEFINE_SPECIAL_STACK_OF ( t1 , t2 ) SKM_DEFINE_STACK_OF ( t1 , t2 , t2 ) # define DEFINE_STACK_OF ( t ) SKM_DEFINE_STACK_OF ( t , t , t ) # define DEFINE_SPECIAL_STACK_OF_CONST ( t1 , t2 ) SKM_DEFINE_STACK_OF ( t1 , const t2 , t2 ) # define DEFINE_STACK_OF_CONST ( t ) SKM_DEFINE_STACK_OF ( t , const t , t ) typedef char * OPENSSL_STRING ; typedef const char * OPENSSL_CSTRING ; DEFINE_SPECIAL_STACK_OF ( OPENSSL_STRING , char ) DEFINE_SPECIAL_STACK_OF_CONST ( OPENSSL_CSTRING , char ) typedef void * OPENSSL_BLOCK ; DEFINE_SPECIAL_STACK_OF ( OPENSSL_BLOCK , void )
1True
Categorize the following code snippet as vulnerable or not. True or False
void vp9_convolve8_avg_c ( const uint8_t * src , ptrdiff_t src_stride , uint8_t * dst , ptrdiff_t dst_stride , const int16_t * filter_x , int x_step_q4 , const int16_t * filter_y , int y_step_q4 , int w , int h ) { DECLARE_ALIGNED_ARRAY ( 16 , uint8_t , temp , 64 * 64 ) ; assert ( w <= 64 ) ; assert ( h <= 64 ) ; vp9_convolve8_c ( src , src_stride , temp , 64 , filter_x , x_step_q4 , filter_y , y_step_q4 , w , h ) ; vp9_convolve_avg_c ( temp , 64 , dst , dst_stride , NULL , 0 , NULL , 0 , w , h ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static vpx_codec_err_t ctrl_set_svc_layer_id ( vpx_codec_alg_priv_t * ctx , va_list args ) { vpx_svc_layer_id_t * const data = va_arg ( args , vpx_svc_layer_id_t * ) ; VP9_COMP * const cpi = ( VP9_COMP * ) ctx -> cpi ; SVC * const svc = & cpi -> svc ; svc -> spatial_layer_id = data -> spatial_layer_id ; svc -> temporal_layer_id = data -> temporal_layer_id ; if ( svc -> temporal_layer_id < 0 || svc -> temporal_layer_id >= ( int ) ctx -> cfg . ts_number_layers ) { return VPX_CODEC_INVALID_PARAM ; } if ( svc -> spatial_layer_id < 0 || svc -> spatial_layer_id >= ( int ) ctx -> cfg . ss_number_layers ) { return VPX_CODEC_INVALID_PARAM ; } return VPX_CODEC_OK ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
PHP_FUNCTION ( uwsgi_setprocname ) { char * name ; int name_len ; if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) TSRMLS_CC , "s" , & name , & name_len ) == FAILURE ) { RETURN_NULL ( ) ; } uwsgi_set_processname ( estrndup ( name , name_len ) ) ; RETURN_NULL ( ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static void block_rd_txfm ( int plane , int block , BLOCK_SIZE plane_bsize , TX_SIZE tx_size , void * arg ) { struct rdcost_block_args * args = arg ; MACROBLOCK * const x = args -> x ; MACROBLOCKD * const xd = & x -> e_mbd ; MB_MODE_INFO * const mbmi = & xd -> mi [ 0 ] . src_mi -> mbmi ; int64_t rd1 , rd2 , rd ; if ( args -> skip ) return ; if ( ! is_inter_block ( mbmi ) ) { vp9_encode_block_intra ( x , plane , block , plane_bsize , tx_size , & mbmi -> skip ) ; dist_block ( plane , block , tx_size , args ) ; } else if ( max_txsize_lookup [ plane_bsize ] == tx_size ) { if ( x -> skip_txfm [ ( plane << 2 ) + ( block >> ( tx_size << 1 ) ) ] == 0 ) { vp9_xform_quant ( x , plane , block , plane_bsize , tx_size ) ; dist_block ( plane , block , tx_size , args ) ; } else if ( x -> skip_txfm [ ( plane << 2 ) + ( block >> ( tx_size << 1 ) ) ] == 2 ) { tran_low_t * const coeff = BLOCK_OFFSET ( x -> plane [ plane ] . coeff , block ) ; tran_low_t * const dqcoeff = BLOCK_OFFSET ( xd -> plane [ plane ] . dqcoeff , block ) ; vp9_xform_quant_dc ( x , plane , block , plane_bsize , tx_size ) ; args -> sse = x -> bsse [ ( plane << 2 ) + ( block >> ( tx_size << 1 ) ) ] << 4 ; args -> dist = args -> sse ; if ( ! x -> plane [ plane ] . eobs [ block ] ) args -> dist = args -> sse - ( ( coeff [ 0 ] * coeff [ 0 ] - ( coeff [ 0 ] - dqcoeff [ 0 ] ) * ( coeff [ 0 ] - dqcoeff [ 0 ] ) ) >> 2 ) ; } else { x -> plane [ plane ] . eobs [ block ] = 0 ; args -> sse = x -> bsse [ ( plane << 2 ) + ( block >> ( tx_size << 1 ) ) ] << 4 ; args -> dist = args -> sse ; } } else { vp9_xform_quant ( x , plane , block , plane_bsize , tx_size ) ; dist_block ( plane , block , tx_size , args ) ; } rate_block ( plane , block , plane_bsize , tx_size , args ) ; rd1 = RDCOST ( x -> rdmult , x -> rddiv , args -> rate , args -> dist ) ; rd2 = RDCOST ( x -> rdmult , x -> rddiv , 0 , args -> sse ) ; rd = MIN ( rd1 , rd2 ) ; if ( plane == 0 ) x -> zcoeff_blk [ tx_size ] [ block ] = ! x -> plane [ plane ] . eobs [ block ] || ( rd1 > rd2 && ! xd -> lossless ) ; args -> this_rate += args -> rate ; args -> this_dist += args -> dist ; args -> this_sse += args -> sse ; args -> this_rd += rd ; if ( args -> this_rd > args -> best_rd ) { args -> skip = 1 ; return ; } }
0False
Categorize the following code snippet as vulnerable or not. True or False
extern int name ( int ) __THROW __exctype ( isalnum ) ; __exctype ( isalpha ) ; __exctype ( iscntrl ) ; __exctype ( isdigit ) ; __exctype ( islower ) ; __exctype ( isgraph ) ; __exctype ( isprint ) ; __exctype ( ispunct ) ; __exctype ( isspace ) ; __exctype ( isupper ) ; __exctype ( isxdigit ) ; extern int tolower ( int __c ) __THROW ; extern int toupper ( int __c ) __THROW ; # ifdef __USE_ISOC99 __exctype ( isblank ) ; # endif # ifdef __USE_GNU extern int isctype ( int __c , int __mask ) __THROW ; # endif # if defined __USE_MISC || defined __USE_XOPEN extern int isascii ( int __c ) __THROW ; extern int toascii ( int __c ) __THROW ; __exctype ( _toupper ) ; __exctype ( _tolower )
1True
Categorize the following code snippet as vulnerable or not. True or False
static slurm_addr_t * _build_node_addr ( char * node_list , uint32_t node_cnt , uint32_t pack_job_id ) { hostlist_t host_list = NULL ; struct node_record * node_ptr ; slurm_addr_t * node_addr ; char * this_node_name ; int error_code = SLURM_SUCCESS , node_inx = 0 ; if ( ( host_list = hostlist_create ( node_list ) ) == NULL ) { error ( "%s hostlist_create error for pack job %u (%s): %m" , __func__ , pack_job_id , node_list ) ; return NULL ; } node_addr = xmalloc ( sizeof ( slurm_addr_t ) * node_cnt ) ; while ( ( this_node_name = hostlist_shift ( host_list ) ) ) { if ( ( node_ptr = find_node_record ( this_node_name ) ) ) { memcpy ( node_addr + node_inx , & node_ptr -> slurm_addr , sizeof ( slurm_addr_t ) ) ; node_inx ++ ; } else { error ( "%s: Invalid node %s in pack job %u" , __func__ , this_node_name , pack_job_id ) ; error_code = SLURM_ERROR ; } free ( this_node_name ) ; if ( error_code != SLURM_SUCCESS ) break ; } hostlist_destroy ( host_list ) ; if ( error_code != SLURM_SUCCESS ) xfree ( node_addr ) ; return node_addr ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static int dissect_h245_MaintenanceLoopReject ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) { offset = dissect_per_sequence ( tvb , offset , actx , tree , hf_index , ett_h245_MaintenanceLoopReject , MaintenanceLoopReject_sequence ) ; return offset ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
void * _TSrealloc ( void * ptr , size_t size , const char * ) { return ats_realloc ( ptr , size ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static gpg_err_code_t make_space ( struct make_space_ctx * c , size_t n ) { size_t used = c -> pos - c -> sexp -> d ; if ( used + n + sizeof ( DATALEN ) + 1 >= c -> allocated ) { gcry_sexp_t newsexp ; byte * newhead ; size_t newsize ; newsize = c -> allocated + 2 * ( n + sizeof ( DATALEN ) + 1 ) ; if ( newsize <= c -> allocated ) return GPG_ERR_TOO_LARGE ; newsexp = gcry_realloc ( c -> sexp , sizeof * newsexp + newsize - 1 ) ; if ( ! newsexp ) return gpg_err_code_from_errno ( errno ) ; c -> allocated = newsize ; newhead = newsexp -> d ; c -> pos = newhead + used ; c -> sexp = newsexp ; } return 0 ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
METHOD ( x509_t , create_ipAddrBlock_enumerator , enumerator_t * , private_x509_cert_t * this ) { return this -> ipAddrBlocks -> create_enumerator ( this -> ipAddrBlocks ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static void handle_null_request ( int tun_fd , int dns_fd , struct query * q , int domain_len ) { struct in_addr tempip ; char in [ 512 ] ; char logindata [ 16 ] ; char out [ 64 * 1024 ] ; char unpacked [ 64 * 1024 ] ; char * tmp [ 2 ] ; int userid ; int read ; userid = - 1 ; if ( domain_len < 2 ) return ; memcpy ( in , q -> name , MIN ( domain_len , sizeof ( in ) ) ) ; if ( in [ 0 ] == 'V' || in [ 0 ] == 'v' ) { int version = 0 ; read = unpack_data ( unpacked , sizeof ( unpacked ) , & ( in [ 1 ] ) , domain_len - 1 , b32 ) ; if ( read > 4 ) { version = ( ( ( unpacked [ 0 ] & 0xff ) << 24 ) | ( ( unpacked [ 1 ] & 0xff ) << 16 ) | ( ( unpacked [ 2 ] & 0xff ) << 8 ) | ( ( unpacked [ 3 ] & 0xff ) ) ) ; } if ( version == VERSION ) { userid = find_available_user ( ) ; if ( userid >= 0 ) { int i ; struct sockaddr_in * tempin ; users [ userid ] . seed = rand ( ) ; tempin = ( struct sockaddr_in * ) & ( q -> from ) ; memcpy ( & ( users [ userid ] . host ) , & ( tempin -> sin_addr ) , sizeof ( struct in_addr ) ) ; memcpy ( & ( users [ userid ] . q ) , q , sizeof ( struct query ) ) ; users [ userid ] . encoder = get_base32_encoder ( ) ; users [ userid ] . downenc = 'T' ; send_version_response ( dns_fd , VERSION_ACK , users [ userid ] . seed , userid , q ) ; syslog ( LOG_INFO , "accepted version for user #%d from %s" , userid , format_addr ( & q -> from , q -> fromlen ) ) ; users [ userid ] . q . id = 0 ; users [ userid ] . q . id2 = 0 ; users [ userid ] . q_sendrealsoon . id = 0 ; users [ userid ] . q_sendrealsoon . id2 = 0 ; users [ userid ] . q_sendrealsoon_new = 0 ; users [ userid ] . outpacket . len = 0 ; users [ userid ] . outpacket . offset = 0 ; users [ userid ] . outpacket . sentlen = 0 ; users [ userid ] . outpacket . seqno = 0 ; users [ userid ] . outpacket . fragment = 0 ; users [ userid ] . outfragresent = 0 ; users [ userid ] . inpacket . len = 0 ; users [ userid ] . inpacket . offset = 0 ; users [ userid ] . inpacket . seqno = 0 ; users [ userid ] . inpacket . fragment = 0 ; users [ userid ] . fragsize = 100 ; users [ userid ] . conn = CONN_DNS_NULL ; users [ userid ] . lazy = 0 ; # ifdef OUTPACKETQ_LEN users [ userid ] . outpacketq_nexttouse = 0 ; users [ userid ] . outpacketq_filled = 0 ; # endif # ifdef DNSCACHE_LEN { for ( i = 0 ; i < DNSCACHE_LEN ; i ++ ) { users [ userid ] . dnscache_q [ i ] . id = 0 ; users [ userid ] . dnscache_answerlen [ i ] = 0 ; } } users [ userid ] . dnscache_lastfilled = 0 ; # endif for ( i = 0 ; i < QMEMPING_LEN ; i ++ ) users [ userid ] . qmemping_type [ i ] = T_UNSET ; users [ userid ] . qmemping_lastfilled = 0 ; for ( i = 0 ; i < QMEMDATA_LEN ; i ++ ) users [ userid ] . qmemdata_type [ i ] = T_UNSET ; users [ userid ] . qmemdata_lastfilled = 0 ; } else { send_version_response ( dns_fd , VERSION_FULL , created_users , 0 , q ) ; syslog ( LOG_INFO , "dropped user from %s, server full" , format_addr ( & q -> from , q -> fromlen ) ) ; } } else { send_version_response ( dns_fd , VERSION_NACK , VERSION , 0 , q ) ; syslog ( LOG_INFO , "dropped user from %s, sent bad version %08X" , format_addr ( & q -> from , q -> fromlen ) , version ) ; } return ; } else if ( in [ 0 ] == 'L' || in [ 0 ] == 'l' ) { read = unpack_data ( unpacked , sizeof ( unpacked ) , & ( in [ 1 ] ) , domain_len - 1 , b32 ) ; if ( read < 17 ) { write_dns ( dns_fd , q , "BADLEN" , 6 , 'T' ) ; return ; } userid = unpacked [ 0 ] ; if ( check_user_and_ip ( userid , q ) != 0 ) { write_dns ( dns_fd , q , "BADIP" , 5 , 'T' ) ; syslog ( LOG_WARNING , "dropped login request from user #%d from unexpected source %s" , userid , format_addr ( & q -> from , q -> fromlen ) ) ; return ; } else { users [ userid ] . last_pkt = time ( NULL ) ; login_calculate ( logindata , 16 , password , users [ userid ] . seed ) ; if ( read >= 18 && ( memcmp ( logindata , unpacked + 1 , 16 ) == 0 ) ) { users [ userid ] . authenticated = 1 ; tempip . s_addr = my_ip ; tmp [ 0 ] = strdup ( inet_ntoa ( tempip ) ) ; tempip . s_addr = users [ userid ] . tun_ip ; tmp [ 1 ] = strdup ( inet_ntoa ( tempip ) ) ; read = snprintf ( out , sizeof ( out ) , "%s-%s-%d-%d" , tmp [ 0 ] , tmp [ 1 ] , my_mtu , netmask ) ; write_dns ( dns_fd , q , out , read , users [ userid ] . downenc ) ; q -> id = 0 ; syslog ( LOG_NOTICE , "accepted password from user #%d, given IP %s" , userid , tmp [ 1 ] ) ; free ( tmp [ 1 ] ) ; free ( tmp [ 0 ] ) ; } else { write_dns ( dns_fd , q , "LNAK" , 4 , 'T' ) ; syslog ( LOG_WARNING , "rejected login request from user #%d from %s, bad password" , userid , format_addr ( & q -> from , q -> fromlen ) ) ; } } return ; } else if ( in [ 0 ] == 'I' || in [ 0 ] == 'i' ) { in_addr_t replyaddr ; unsigned addr ; char reply [ 5 ] ; userid = b32_8to5 ( in [ 1 ] ) ; if ( check_authenticated_user_and_ip ( userid , q ) != 0 ) { write_dns ( dns_fd , q , "BADIP" , 5 , 'T' ) ; return ; } if ( ns_ip != INADDR_ANY ) { replyaddr = ns_ip ; } else { memcpy ( & replyaddr , & q -> destination . s_addr , sizeof ( in_addr_t ) ) ; } addr = htonl ( replyaddr ) ; reply [ 0 ] = 'I' ; reply [ 1 ] = ( addr >> 24 ) & 0xFF ; reply [ 2 ] = ( addr >> 16 ) & 0xFF ; reply [ 3 ] = ( addr >> 8 ) & 0xFF ; reply [ 4 ] = ( addr >> 0 ) & 0xFF ; write_dns ( dns_fd , q , reply , sizeof ( reply ) , 'T' ) ; } else if ( in [ 0 ] == 'Z' || in [ 0 ] == 'z' ) { write_dns ( dns_fd , q , in , domain_len , 'T' ) ; return ; } else if ( in [ 0 ] == 'S' || in [ 0 ] == 's' ) { int codec ; struct encoder * enc ; if ( domain_len < 3 ) { write_dns ( dns_fd , q , "BADLEN" , 6 , 'T' ) ; return ; } userid = b32_8to5 ( in [ 1 ] ) ; if ( check_authenticated_user_and_ip ( userid , q ) != 0 ) { write_dns ( dns_fd , q , "BADIP" , 5 , 'T' ) ; return ; } codec = b32_8to5 ( in [ 2 ] ) ; switch ( codec ) { case 5 : enc = get_base32_encoder ( ) ; user_switch_codec ( userid , enc ) ; write_dns ( dns_fd , q , enc -> name , strlen ( enc -> name ) , users [ userid ] . downenc ) ; break ; case 6 : enc = get_base64_encoder ( ) ; user_switch_codec ( userid , enc ) ; write_dns ( dns_fd , q , enc -> name , strlen ( enc -> name ) , users [ userid ] . downenc ) ; break ; case 26 : enc = get_base64u_encoder ( ) ; user_switch_codec ( userid , enc ) ; write_dns ( dns_fd , q , enc -> name , strlen ( enc -> name ) , users [ userid ] . downenc ) ; break ; case 7 : enc = get_base128_encoder ( ) ; user_switch_codec ( userid , enc ) ; write_dns ( dns_fd , q , enc -> name , strlen ( enc -> name ) , users [ userid ] . downenc ) ; break ; default : write_dns ( dns_fd , q , "BADCODEC" , 8 , users [ userid ] . downenc ) ; break ; } return ; } else if ( in [ 0 ] == 'O' || in [ 0 ] == 'o' ) { if ( domain_len < 3 ) { write_dns ( dns_fd , q , "BADLEN" , 6 , 'T' ) ; return ; } userid = b32_8to5 ( in [ 1 ] ) ; if ( check_authenticated_user_and_ip ( userid , q ) != 0 ) { write_dns ( dns_fd , q , "BADIP" , 5 , 'T' ) ; return ; } switch ( in [ 2 ] ) { case 'T' : case 't' : users [ userid ] . downenc = 'T' ; write_dns ( dns_fd , q , "Base32" , 6 , users [ userid ] . downenc ) ; break ; case 'S' : case 's' : users [ userid ] . downenc = 'S' ; write_dns ( dns_fd , q , "Base64" , 6 , users [ userid ] . downenc ) ; break ; case 'U' : case 'u' : users [ userid ] . downenc = 'U' ; write_dns ( dns_fd , q , "Base64u" , 7 , users [ userid ] . downenc ) ; break ; case 'V' : case 'v' : users [ userid ] . downenc = 'V' ; write_dns ( dns_fd , q , "Base128" , 7 , users [ userid ] . downenc ) ; break ; case 'R' : case 'r' : users [ userid ] . downenc = 'R' ; write_dns ( dns_fd , q , "Raw" , 3 , users [ userid ] . downenc ) ; break ; case 'L' : case 'l' : users [ userid ] . lazy = 1 ; write_dns ( dns_fd , q , "Lazy" , 4 , users [ userid ] . downenc ) ; break ; case 'I' : case 'i' : users [ userid ] . lazy = 0 ; write_dns ( dns_fd , q , "Immediate" , 9 , users [ userid ] . downenc ) ; break ; default : write_dns ( dns_fd , q , "BADCODEC" , 8 , users [ userid ] . downenc ) ; break ; } return ; } else if ( in [ 0 ] == 'Y' || in [ 0 ] == 'y' ) { int i ; char * datap ; int datalen ; if ( domain_len < 6 ) { write_dns ( dns_fd , q , "BADLEN" , 6 , 'T' ) ; return ; } i = b32_8to5 ( in [ 2 ] ) ; switch ( i ) { case 1 : datap = DOWNCODECCHECK1 ; datalen = DOWNCODECCHECK1_LEN ; break ; default : write_dns ( dns_fd , q , "BADLEN" , 6 , 'T' ) ; return ; } switch ( in [ 1 ] ) { case 'T' : case 't' : if ( q -> type == T_TXT || q -> type == T_SRV || q -> type == T_MX || q -> type == T_CNAME || q -> type == T_A ) { write_dns ( dns_fd , q , datap , datalen , 'T' ) ; return ; } break ; case 'S' : case 's' : if ( q -> type == T_TXT || q -> type == T_SRV || q -> type == T_MX || q -> type == T_CNAME || q -> type == T_A ) { write_dns ( dns_fd , q , datap , datalen , 'S' ) ; return ; } break ; case 'U' : case 'u' : if ( q -> type == T_TXT || q -> type == T_SRV || q -> type == T_MX || q -> type == T_CNAME || q -> type == T_A ) { write_dns ( dns_fd , q , datap , datalen , 'U' ) ; return ; } break ; case 'V' : case 'v' : if ( q -> type == T_TXT || q -> type == T_SRV || q -> type == T_MX || q -> type == T_CNAME || q -> type == T_A ) { write_dns ( dns_fd , q , datap , datalen , 'V' ) ; return ; } break ; case 'R' : case 'r' : if ( q -> type == T_NULL || q -> type == T_TXT ) { write_dns ( dns_fd , q , datap , datalen , 'R' ) ; return ; } break ; } write_dns ( dns_fd , q , "BADCODEC" , 8 , 'T' ) ; return ; } else if ( in [ 0 ] == 'R' || in [ 0 ] == 'r' ) { int req_frag_size ; if ( domain_len < 16 ) { write_dns ( dns_fd , q , "BADLEN" , 6 , 'T' ) ; return ; } userid = ( b32_8to5 ( in [ 1 ] ) >> 1 ) & 15 ; if ( check_authenticated_user_and_ip ( userid , q ) != 0 ) { write_dns ( dns_fd , q , "BADIP" , 5 , 'T' ) ; return ; } req_frag_size = ( ( b32_8to5 ( in [ 1 ] ) & 1 ) << 10 ) | ( ( b32_8to5 ( in [ 2 ] ) & 31 ) << 5 ) | ( b32_8to5 ( in [ 3 ] ) & 31 ) ; if ( req_frag_size < 2 || req_frag_size > 2047 ) { write_dns ( dns_fd , q , "BADFRAG" , 7 , users [ userid ] . downenc ) ; } else { char buf [ 2048 ] ; int i ; unsigned int v = ( ( unsigned int ) rand ( ) ) & 0xff ; memset ( buf , 0 , sizeof ( buf ) ) ; buf [ 0 ] = ( req_frag_size >> 8 ) & 0xff ; buf [ 1 ] = req_frag_size & 0xff ; buf [ 2 ] = 107 ; for ( i = 3 ; i < 2048 ; i ++ , v = ( v + 107 ) & 0xff ) buf [ i ] = v ; write_dns ( dns_fd , q , buf , req_frag_size , users [ userid ] . downenc ) ; } return ; } else if ( in [ 0 ] == 'N' || in [ 0 ] == 'n' ) { int max_frag_size ; read = unpack_data ( unpacked , sizeof ( unpacked ) , & ( in [ 1 ] ) , domain_len - 1 , b32 ) ; if ( read < 3 ) { write_dns ( dns_fd , q , "BADLEN" , 6 , 'T' ) ; return ; } userid = unpacked [ 0 ] ; if ( check_authenticated_user_and_ip ( userid , q ) != 0 ) { write_dns ( dns_fd , q , "BADIP" , 5 , 'T' ) ; return ; } max_frag_size = ( ( unpacked [ 1 ] & 0xff ) << 8 ) | ( unpacked [ 2 ] & 0xff ) ; if ( max_frag_size < 2 ) { write_dns ( dns_fd , q , "BADFRAG" , 7 , users [ userid ] . downenc ) ; } else { users [ userid ] . fragsize = max_frag_size ; write_dns ( dns_fd , q , & unpacked [ 1 ] , 2 , users [ userid ] . downenc ) ; } return ; } else if ( in [ 0 ] == 'P' || in [ 0 ] == 'p' ) { int dn_seq ; int dn_frag ; int didsend = 0 ; if ( q -> id == 0 ) return ; read = unpack_data ( unpacked , sizeof ( unpacked ) , & ( in [ 1 ] ) , domain_len - 1 , b32 ) ; if ( read < 4 ) return ; userid = unpacked [ 0 ] ; if ( check_authenticated_user_and_ip ( userid , q ) != 0 ) { write_dns ( dns_fd , q , "BADIP" , 5 , 'T' ) ; return ; } # ifdef DNSCACHE_LEN if ( answer_from_dnscache ( dns_fd , userid , q ) ) return ; # endif if ( answer_from_qmem ( dns_fd , q , users [ userid ] . qmemping_cmc , users [ userid ] . qmemping_type , QMEMPING_LEN , ( void * ) unpacked ) ) return ; if ( users [ userid ] . q . id != 0 && q -> type == users [ userid ] . q . type && ! strcmp ( q -> name , users [ userid ] . q . name ) && users [ userid ] . lazy ) { if ( debug >= 2 ) { fprintf ( stderr , "PING pkt from user %d = dupe from impatient DNS server, remembering\n" , userid ) ; } users [ userid ] . q . id2 = q -> id ; users [ userid ] . q . fromlen2 = q -> fromlen ; memcpy ( & ( users [ userid ] . q . from2 ) , & ( q -> from ) , q -> fromlen ) ; return ; } if ( users [ userid ] . q_sendrealsoon . id != 0 && q -> type == users [ userid ] . q_sendrealsoon . type && ! strcmp ( q -> name , users [ userid ] . q_sendrealsoon . name ) ) { if ( debug >= 2 ) { fprintf ( stderr , "PING pkt from user %d = dupe from impatient DNS server, remembering\n" , userid ) ; } users [ userid ] . q_sendrealsoon . id2 = q -> id ; users [ userid ] . q_sendrealsoon . fromlen2 = q -> fromlen ; memcpy ( & ( users [ userid ] . q_sendrealsoon . from2 ) , & ( q -> from ) , q -> fromlen ) ; return ; } dn_seq = unpacked [ 1 ] >> 4 ; dn_frag = unpacked [ 1 ] & 15 ; if ( debug >= 1 ) { fprintf ( stderr , "PING pkt from user %d, ack for downstream %d/%d\n" , userid , dn_seq , dn_frag ) ; } process_downstream_ack ( userid , dn_seq , dn_frag ) ; if ( debug >= 3 ) { fprintf ( stderr , "PINGret (if any) will ack upstream %d/%d\n" , users [ userid ] . inpacket . seqno , users [ userid ] . inpacket . fragment ) ; } if ( users [ userid ] . q_sendrealsoon . id != 0 ) { send_chunk_or_dataless ( dns_fd , userid , & users [ userid ] . q_sendrealsoon ) ; } if ( users [ userid ] . q . id != 0 ) { didsend = 1 ; if ( send_chunk_or_dataless ( dns_fd , userid , & users [ userid ] . q ) == 1 ) didsend = 0 ; } memcpy ( & ( users [ userid ] . q ) , q , sizeof ( struct query ) ) ; users [ userid ] . last_pkt = time ( NULL ) ; if ( ( ! didsend && users [ userid ] . outpacket . len > 0 ) || ! users [ userid ] . lazy ) send_chunk_or_dataless ( dns_fd , userid , & users [ userid ] . q ) ; } else if ( ( in [ 0 ] >= '0' && in [ 0 ] <= '9' ) || ( in [ 0 ] >= 'a' && in [ 0 ] <= 'f' ) || ( in [ 0 ] >= 'A' && in [ 0 ] <= 'F' ) ) { int up_seq , up_frag , dn_seq , dn_frag , lastfrag ; int upstream_ok = 1 ; int didsend = 0 ; int code = - 1 ; if ( domain_len < 6 ) return ; if ( q -> id == 0 ) return ; if ( ( in [ 0 ] >= '0' && in [ 0 ] <= '9' ) ) code = in [ 0 ] - '0' ; if ( ( in [ 0 ] >= 'a' && in [ 0 ] <= 'f' ) ) code = in [ 0 ] - 'a' + 10 ; if ( ( in [ 0 ] >= 'A' && in [ 0 ] <= 'F' ) ) code = in [ 0 ] - 'A' + 10 ; userid = code ; if ( check_authenticated_user_and_ip ( userid , q ) != 0 ) { write_dns ( dns_fd , q , "BADIP" , 5 , 'T' ) ; return ; } # ifdef DNSCACHE_LEN if ( answer_from_dnscache ( dns_fd , userid , q ) ) return ; # endif if ( answer_from_qmem_data ( dns_fd , userid , q ) ) return ; if ( users [ userid ] . q . id != 0 && q -> type == users [ userid ] . q . type && ! strcmp ( q -> name , users [ userid ] . q . name ) && users [ userid ] . lazy ) { if ( debug >= 2 ) { fprintf ( stderr , "IN pkt from user %d = dupe from impatient DNS server, remembering\n" , userid ) ; } users [ userid ] . q . id2 = q -> id ; users [ userid ] . q . fromlen2 = q -> fromlen ; memcpy ( & ( users [ userid ] . q . from2 ) , & ( q -> from ) , q -> fromlen ) ; return ; } if ( users [ userid ] . q_sendrealsoon . id != 0 && q -> type == users [ userid ] . q_sendrealsoon . type && ! strcmp ( q -> name , users [ userid ] . q_sendrealsoon . name ) ) { if ( debug >= 2 ) { fprintf ( stderr , "IN pkt from user %d = dupe from impatient DNS server, remembering\n" , userid ) ; } users [ userid ] . q_sendrealsoon . id2 = q -> id ; users [ userid ] . q_sendrealsoon . fromlen2 = q -> fromlen ; memcpy ( & ( users [ userid ] . q_sendrealsoon . from2 ) , & ( q -> from ) , q -> fromlen ) ; return ; } up_seq = ( b32_8to5 ( in [ 1 ] ) >> 2 ) & 7 ; up_frag = ( ( b32_8to5 ( in [ 1 ] ) & 3 ) << 2 ) | ( ( b32_8to5 ( in [ 2 ] ) >> 3 ) & 3 ) ; dn_seq = ( b32_8to5 ( in [ 2 ] ) & 7 ) ; dn_frag = b32_8to5 ( in [ 3 ] ) >> 1 ; lastfrag = b32_8to5 ( in [ 3 ] ) & 1 ; process_downstream_ack ( userid , dn_seq , dn_frag ) ; if ( up_seq == users [ userid ] . inpacket . seqno && up_frag <= users [ userid ] . inpacket . fragment ) { if ( debug >= 1 ) { fprintf ( stderr , "IN pkt seq# %d, frag %d, dropped duplicate frag\n" , up_seq , up_frag ) ; } upstream_ok = 0 ; } else if ( up_seq != users [ userid ] . inpacket . seqno && recent_seqno ( users [ userid ] . inpacket . seqno , up_seq ) ) { if ( debug >= 1 ) { fprintf ( stderr , "IN pkt seq# %d, frag %d, dropped duplicate recent seqno\n" , up_seq , up_frag ) ; } upstream_ok = 0 ; } else if ( up_seq != users [ userid ] . inpacket . seqno ) { users [ userid ] . inpacket . seqno = up_seq ; users [ userid ] . inpacket . fragment = up_frag ; users [ userid ] . inpacket . len = 0 ; users [ userid ] . inpacket . offset = 0 ; } else { users [ userid ] . inpacket . fragment = up_frag ; } if ( debug >= 3 ) { fprintf ( stderr , "INpack with upstream %d/%d, we are going to ack upstream %d/%d\n" , up_seq , up_frag , users [ userid ] . inpacket . seqno , users [ userid ] . inpacket . fragment ) ; } if ( upstream_ok ) { read = unpack_data ( unpacked , sizeof ( unpacked ) , & ( in [ 5 ] ) , domain_len - 5 , users [ userid ] . encoder ) ; read = MIN ( read , sizeof ( users [ userid ] . inpacket . data ) - users [ userid ] . inpacket . offset ) ; memcpy ( users [ userid ] . inpacket . data + users [ userid ] . inpacket . offset , unpacked , read ) ; users [ userid ] . inpacket . len += read ; users [ userid ] . inpacket . offset += read ; if ( debug >= 1 ) { fprintf ( stderr , "IN pkt seq# %d, frag %d (last=%d), fragsize %d, total %d, from user %d\n" , up_seq , up_frag , lastfrag , read , users [ userid ] . inpacket . len , userid ) ; } } if ( upstream_ok && lastfrag ) { handle_full_packet ( tun_fd , dns_fd , userid ) ; } if ( users [ userid ] . q_sendrealsoon . id != 0 ) { didsend = 1 ; if ( send_chunk_or_dataless ( dns_fd , userid , & users [ userid ] . q_sendrealsoon ) == 1 ) didsend = 0 ; } if ( users [ userid ] . q . id != 0 ) { if ( ( users [ userid ] . outpacket . len > 0 && ! didsend ) || ( upstream_ok && ! lastfrag && ! didsend ) || ( ! upstream_ok && ! didsend ) || ! users [ userid ] . lazy ) { didsend = 1 ; if ( send_chunk_or_dataless ( dns_fd , userid , & users [ userid ] . q ) == 1 ) didsend = 0 ; } else { memcpy ( & ( users [ userid ] . q_sendrealsoon ) , & ( users [ userid ] . q ) , sizeof ( struct query ) ) ; users [ userid ] . q_sendrealsoon_new = 1 ; users [ userid ] . q . id = 0 ; didsend = 1 ; } } memcpy ( & ( users [ userid ] . q ) , q , sizeof ( struct query ) ) ; users [ userid ] . last_pkt = time ( NULL ) ; if ( users [ userid ] . outpacket . len > 0 && ! didsend ) send_chunk_or_dataless ( dns_fd , userid , & users [ userid ] . q ) ; else if ( ! didsend || ! users [ userid ] . lazy ) { if ( upstream_ok && lastfrag ) { memcpy ( & ( users [ userid ] . q_sendrealsoon ) , & ( users [ userid ] . q ) , sizeof ( struct query ) ) ; users [ userid ] . q_sendrealsoon_new = 1 ; users [ userid ] . q . id = 0 ; } else { send_chunk_or_dataless ( dns_fd , userid , & users [ userid ] . q ) ; } } } }
0False
Categorize the following code snippet as vulnerable or not. True or False
static const char * lookup_uname ( struct cpio * cpio , uid_t uid ) { return ( lookup_name ( cpio , & cpio -> uname_cache , & lookup_uname_helper , ( id_t ) uid ) ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static int dissect_s_supervisor_exception_detail_alarm ( packet_info * pinfo , proto_tree * tree , proto_item * item , tvbuff_t * tvb , int offset , int total_len ) { proto_item * pi ; proto_tree * item_tree ; int total_size = 0 , size ; item_tree = proto_tree_add_subtree ( tree , tvb , offset , 1 , ett_exception_detail_alarm_common , & pi , "Common Exception Detail" ) ; size = dissect_s_supervisor_exception_detail ( item_tree , pi , tvb , offset , hf_cip_ssupervisor_exception_detail_alarm_ced_size , hf_cip_ssupervisor_exception_detail_alarm_ced_detail ) ; if ( size == 0 ) { expert_add_info ( pinfo , item , & ei_mal_ssupervisor_exception_detail_alarm_ced ) ; return total_len ; } total_size += size ; item_tree = proto_tree_add_subtree ( tree , tvb , offset , 1 , ett_exception_detail_alarm_device , & pi , "Device Exception Detail" ) ; size = dissect_s_supervisor_exception_detail ( item_tree , pi , tvb , offset , hf_cip_ssupervisor_exception_detail_alarm_ded_size , hf_cip_ssupervisor_exception_detail_alarm_ded_detail ) ; if ( size == 0 ) { expert_add_info ( pinfo , item , & ei_mal_ssupervisor_exception_detail_alarm_ded ) ; return total_len ; } total_size += size ; item_tree = proto_tree_add_subtree ( tree , tvb , offset , 1 , ett_exception_detail_alarm_manufacturer , & pi , "Manufacturer Exception Detail" ) ; size = dissect_s_supervisor_exception_detail ( item_tree , pi , tvb , offset , hf_cip_ssupervisor_exception_detail_alarm_med_size , hf_cip_ssupervisor_exception_detail_alarm_med_detail ) ; if ( size == 0 ) { expert_add_info ( pinfo , item , & ei_mal_ssupervisor_exception_detail_alarm_med ) ; return total_len ; } total_size += size ; return total_size ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static cmsTagTypeSignature DecideCurveType ( cmsFloat64Number ICCVersion , const void * Data ) { cmsToneCurve * Curve = ( cmsToneCurve * ) Data ; if ( ICCVersion < 4.0 ) return cmsSigCurveType ; if ( Curve -> nSegments != 1 ) return cmsSigCurveType ; if ( Curve -> Segments [ 0 ] . Type < 0 ) return cmsSigCurveType ; if ( Curve -> Segments [ 0 ] . Type > 5 ) return cmsSigCurveType ; return cmsSigParametricCurveType ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static gint round_to_8byte ( gint current_offset , gint starting_offset ) { gint length = current_offset - starting_offset ; return starting_offset + ROUND_TO_8BYTE ( length ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static void ini_print_int ( WriterContext * wctx , const char * key , long long int value ) { printf ( "%s=%lld\n" , key , value ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
IN_PROC_BROWSER_TEST_F ( PageLoadMetricsBrowserTest , NoStatePrefetchObserverCacheable ) { ASSERT_TRUE ( embedded_test_server ( ) -> Start ( ) ) ; auto waiter = CreatePageLoadMetricsWaiter ( ) ; waiter -> AddPageExpectation ( TimingField : : FIRST_CONTENTFUL_PAINT ) ; ui_test_utils : : NavigateToURL ( browser ( ) , embedded_test_server ( ) -> GetURL ( "/title1.html" ) ) ; waiter -> Wait ( ) ; histogram_tester_ . ExpectTotalCount ( "Prerender.none_PrefetchTTFCP.Reference.NoStore.Visible" , 0 ) ; histogram_tester_ . ExpectTotalCount ( "Prerender.none_PrefetchTTFCP.Reference.Cacheable.Visible" , 1 ) ; }
0False
Categorize the following code snippet as vulnerable or not. True or False
static uint64_t xhci_cap_read ( void * ptr , hwaddr reg , unsigned size ) { XHCIState * xhci = ptr ; uint32_t ret ; switch ( reg ) { case 0x00 : ret = 0x01000000 | LEN_CAP ; break ; case 0x04 : ret = ( ( xhci -> numports_2 + xhci -> numports_3 ) << 24 ) | ( xhci -> numintrs << 8 ) | xhci -> numslots ; break ; case 0x08 : ret = 0x0000000f ; break ; case 0x0c : ret = 0x00000000 ; break ; case 0x10 : if ( sizeof ( dma_addr_t ) == 4 ) { ret = 0x00080000 | ( xhci -> max_pstreams_mask << 12 ) ; } else { ret = 0x00080001 | ( xhci -> max_pstreams_mask << 12 ) ; } break ; case 0x14 : ret = OFF_DOORBELL ; break ; case 0x18 : ret = OFF_RUNTIME ; break ; case 0x20 : ret = 0x02000402 ; break ; case 0x24 : ret = 0x20425355 ; break ; case 0x28 : if ( xhci_get_flag ( xhci , XHCI_FLAG_SS_FIRST ) ) { ret = ( xhci -> numports_2 << 8 ) | ( xhci -> numports_3 + 1 ) ; } else { ret = ( xhci -> numports_2 << 8 ) | 1 ; } break ; case 0x2c : ret = 0x00000000 ; break ; case 0x30 : ret = 0x03000002 ; break ; case 0x34 : ret = 0x20425355 ; break ; case 0x38 : if ( xhci_get_flag ( xhci , XHCI_FLAG_SS_FIRST ) ) { ret = ( xhci -> numports_3 << 8 ) | 1 ; } else { ret = ( xhci -> numports_3 << 8 ) | ( xhci -> numports_2 + 1 ) ; } break ; case 0x3c : ret = 0x00000000 ; break ; default : trace_usb_xhci_unimplemented ( "cap read" , reg ) ; ret = 0 ; } trace_usb_xhci_cap_read ( reg , ret ) ; return ret ; }
0False