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 | static void disable_segmentation ( VP8_COMP * cpi ) {
cpi -> mb . e_mbd . segmentation_enabled = 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void remove_tap_listener_q931_calls ( void ) {
remove_tap_listener ( & ( the_tapinfo_struct . q931_dummy ) ) ;
have_q931_tap_listener = FALSE ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void ngsniffer_close ( wtap * wth ) {
ngsniffer_t * ngsniffer ;
ngsniffer = ( ngsniffer_t * ) wth -> priv ;
if ( ngsniffer -> rand . buf != NULL ) g_free ( ngsniffer -> rand . buf ) ;
if ( ngsniffer -> first_blob != NULL ) {
g_list_foreach ( ngsniffer -> first_blob , free_blob , NULL ) ;
g_list_free ( ngsniffer -> first_blob ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static const char * add_rule ( cmd_parms * cmd , directory_config * dcfg , int type , const char * p1 , const char * p2 , const char * p3 ) {
char * my_error_msg = NULL ;
char * rid = NULL ;
msre_rule * rule = NULL ;
extern msc_engine * modsecurity ;
int offset = 0 ;
# ifdef DEBUG_CONF ap_log_perror ( APLOG_MARK , APLOG_STARTUP | APLOG_NOERRNO , 0 , cmd -> pool , "Rule: type=%d p1='%s' p2='%s' p3='%s'" , type , p1 , p2 , p3 ) ;
# endif if ( ( dcfg -> ruleset == NULL ) || ( dcfg -> ruleset == NOT_SET_P ) ) {
dcfg -> ruleset = msre_ruleset_create ( modsecurity -> msre , cmd -> pool ) ;
if ( dcfg -> ruleset == NULL ) return FATAL_ERROR ;
}
switch ( type ) {
# if defined ( WITH_LUA ) case RULE_TYPE_LUA : rule = msre_rule_lua_create ( dcfg -> ruleset , cmd -> directive -> filename , cmd -> directive -> line_num , p1 , p2 , & my_error_msg ) ;
break ;
# endif default : rule = msre_rule_create ( dcfg -> ruleset , type , cmd -> directive -> filename , cmd -> directive -> line_num , p1 , p2 , p3 , & my_error_msg ) ;
break ;
}
if ( rule == NULL ) {
return my_error_msg ;
}
if ( # if defined ( WITH_LUA ) type != RULE_TYPE_LUA && # endif ( dcfg -> tmp_chain_starter == NULL ) ) if ( rule -> actionset == NULL ) return "ModSecurity: Rules must have at least id action" ;
if ( rule -> actionset != NULL && ( dcfg -> tmp_chain_starter == NULL ) ) {
if ( rule -> actionset -> id == NOT_SET_P # if defined ( WITH_LUA ) && ( type != RULE_TYPE_LUA ) # endif ) return "ModSecurity: No action id present within the rule" ;
# if defined ( WITH_LUA ) if ( type != RULE_TYPE_LUA ) # endif {
rid = apr_hash_get ( dcfg -> rule_id_htab , rule -> actionset -> id , APR_HASH_KEY_STRING ) ;
if ( rid != NULL ) {
return "ModSecurity: Found another rule with the same id" ;
}
else {
apr_hash_set ( dcfg -> rule_id_htab , apr_pstrdup ( dcfg -> mp , rule -> actionset -> id ) , APR_HASH_KEY_STRING , apr_pstrdup ( dcfg -> mp , "1" ) ) ;
}
}
}
if ( dcfg -> tmp_default_actionset == NULL ) {
dcfg -> tmp_default_actionset = msre_actionset_create_default ( modsecurity -> msre ) ;
if ( dcfg -> tmp_default_actionset == NULL ) return FATAL_ERROR ;
}
if ( ( rule -> actionset != NULL ) && ( dcfg -> tmp_chain_starter != NULL ) ) {
if ( rule -> actionset -> intercept_action != NOT_SET ) {
return apr_psprintf ( cmd -> pool , "ModSecurity: Disruptive actions can only " "be specified by chain starter rules." ) ;
}
if ( rule -> actionset -> skip_after != NOT_SET_P ) {
return apr_psprintf ( cmd -> pool , "ModSecurity: SkipAfter actions can only " "be specified by chain starter rules." ) ;
}
if ( rule -> actionset -> phase != NOT_SET ) {
return apr_psprintf ( cmd -> pool , "ModSecurity: Execution phases can only be " "specified by chain starter rules." ) ;
}
if ( ( rule -> actionset -> id != NOT_SET_P ) || ( rule -> actionset -> rev != NOT_SET_P ) || ( rule -> actionset -> msg != NOT_SET_P ) || ( rule -> actionset -> severity != NOT_SET ) || ( rule -> actionset -> version != NOT_SET_P ) || ( rule -> actionset -> accuracy != NOT_SET ) || ( rule -> actionset -> maturity != NOT_SET ) || ( rule -> actionset -> logdata != NOT_SET_P ) ) {
return apr_psprintf ( cmd -> pool , "ModSecurity: Metadata actions (id, rev, msg, tag, severity, ver, accuracy, maturity, logdata) " " can only be specified by chain starter rules." ) ;
}
if ( rule -> actionset -> skip_count != NOT_SET ) {
return apr_psprintf ( cmd -> pool , "ModSecurity: The skip action can only be used " " by chain starter rules. " ) ;
}
}
rule -> actionset = msre_actionset_merge ( modsecurity -> msre , dcfg -> tmp_default_actionset , rule -> actionset , 1 ) ;
rule -> actionset -> parent_intercept_action_rec = dcfg -> tmp_default_actionset -> intercept_action_rec ;
rule -> actionset -> parent_intercept_action = dcfg -> tmp_default_actionset -> intercept_action ;
if ( ( rule -> actionset != NULL ) && ( rule -> actionset -> phase == PHASE_LOGGING ) && ( rule -> actionset -> intercept_action != ACTION_ALLOW ) && ( rule -> actionset -> intercept_action != ACTION_ALLOW_REQUEST ) && ( rule -> actionset -> intercept_action != ACTION_NONE ) ) {
return apr_psprintf ( cmd -> pool , "ModSecurity: Disruptive actions " "cannot be specified in the logging phase." ) ;
}
if ( dcfg -> tmp_chain_starter != NULL ) {
rule -> chain_starter = dcfg -> tmp_chain_starter ;
rule -> actionset -> phase = rule -> chain_starter -> actionset -> phase ;
}
if ( rule -> actionset -> is_chained != 1 ) {
dcfg -> tmp_chain_starter = NULL ;
}
else {
if ( dcfg -> tmp_chain_starter == NULL ) {
dcfg -> tmp_chain_starter = rule ;
}
}
if ( ( rule -> op_name != NULL ) && ( strcasecmp ( rule -> op_name , "inspectFile" ) == 0 ) ) {
dcfg -> upload_validates_files = 1 ;
}
if ( dcfg -> tmp_rule_placeholders == NULL ) {
dcfg -> tmp_rule_placeholders = apr_table_make ( cmd -> pool , 10 ) ;
if ( dcfg -> tmp_rule_placeholders == NULL ) return FATAL_ERROR ;
}
if ( rule -> actionset -> skip_after != NOT_SET_P ) {
char * tmp_id = apr_pstrdup ( cmd -> pool , rule -> actionset -> skip_after ) ;
apr_table_setn ( dcfg -> tmp_rule_placeholders , tmp_id , tmp_id ) ;
# ifdef DEBUG_CONF ap_log_perror ( APLOG_MARK , APLOG_STARTUP | APLOG_NOERRNO , 0 , cmd -> pool , "Watching for skipafter target rule id=\"%s\"." , tmp_id ) ;
# endif }
# ifdef DEBUG_CONF ap_log_perror ( APLOG_MARK , APLOG_STARTUP | APLOG_NOERRNO , 0 , cmd -> pool , "Adding rule %pp phase=%d id=\"%s\"." , rule , rule -> actionset -> phase , ( rule -> actionset -> id == NOT_SET_P ? "(none)" : rule -> actionset -> id ) ) ;
# endif if ( msre_ruleset_rule_add ( dcfg -> ruleset , rule , rule -> actionset -> phase ) < 0 ) {
return "Internal Error: Failed to add rule to the ruleset." ;
}
if ( ( rule -> actionset -> id != NULL ) && apr_table_get ( dcfg -> tmp_rule_placeholders , rule -> actionset -> id ) ) {
msre_rule * phrule = apr_palloc ( rule -> ruleset -> mp , sizeof ( msre_rule ) ) ;
if ( phrule == NULL ) {
return FATAL_ERROR ;
}
# ifdef DEBUG_CONF ap_log_perror ( APLOG_MARK , APLOG_STARTUP | APLOG_NOERRNO , 0 , cmd -> pool , "Adding placeholder %pp for rule %pp id=\"%s\"." , phrule , rule , rule -> actionset -> id ) ;
# endif memcpy ( phrule , rule , sizeof ( msre_rule ) ) ;
phrule -> placeholder = RULE_PH_SKIPAFTER ;
if ( msre_ruleset_rule_add ( dcfg -> ruleset , phrule , phrule -> actionset -> phase ) < 0 ) {
return "Internal Error: Failed to add placeholder to the ruleset." ;
}
apr_table_unset ( dcfg -> tmp_rule_placeholders , rule -> actionset -> id ) ;
}
rule -> unparsed = msre_rule_generate_unparsed ( dcfg -> ruleset -> mp , rule , NULL , NULL , NULL ) ;
return NULL ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void set_mode_info_seg_skip ( MACROBLOCK * x , TX_MODE tx_mode , int * rate , int64_t * dist , BLOCK_SIZE bsize ) {
MACROBLOCKD * const xd = & x -> e_mbd ;
MB_MODE_INFO * const mbmi = & xd -> mi [ 0 ] -> mbmi ;
INTERP_FILTER filter_ref ;
if ( xd -> up_available ) filter_ref = xd -> mi [ - xd -> mi_stride ] -> mbmi . interp_filter ;
else if ( xd -> left_available ) filter_ref = xd -> mi [ - 1 ] -> mbmi . interp_filter ;
else filter_ref = EIGHTTAP ;
mbmi -> sb_type = bsize ;
mbmi -> mode = ZEROMV ;
mbmi -> tx_size = MIN ( max_txsize_lookup [ bsize ] , tx_mode_to_biggest_tx_size [ tx_mode ] ) ;
mbmi -> skip = 1 ;
mbmi -> uv_mode = DC_PRED ;
mbmi -> ref_frame [ 0 ] = LAST_FRAME ;
mbmi -> ref_frame [ 1 ] = NONE ;
mbmi -> mv [ 0 ] . as_int = 0 ;
mbmi -> interp_filter = filter_ref ;
xd -> mi [ 0 ] -> bmi [ 0 ] . as_mv [ 0 ] . as_int = 0 ;
x -> skip = 1 ;
* rate = 0 ;
* dist = 0 ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | IN_PROC_BROWSER_TEST_F ( ProfileBrowserTest , URLFetcherUsingMainContextDuringIncognitoTeardown ) {
Browser * incognito_browser = OpenURLOffTheRecord ( browser ( ) -> profile ( ) , GURL ( "about:blank" ) ) ;
RunURLFetcherActiveDuringIncognitoTeardownTest ( incognito_browser , incognito_browser -> profile ( ) -> GetRequestContext ( ) ) ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static __always_inline __u32 __le32_to_cpup ( const __le32 * p ) {
return ( __u32 ) * p ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static void test_bug14210 ( ) {
MYSQL_STMT * stmt ;
int rc , i ;
const char * stmt_text ;
ulong type ;
myheader ( "test_bug14210" ) ;
mysql_query ( mysql , "drop table if exists t1" ) ;
mysql_query ( mysql , "create table t1 (a varchar(255)) engine=InnoDB" ) ;
rc = mysql_query ( mysql , "insert into t1 (a) values (repeat('a', 256))" ) ;
myquery ( rc ) ;
rc = mysql_query ( mysql , "set @@session.max_heap_table_size=16384" ) ;
for ( i = 0 ;
i < 8 ;
i ++ ) {
rc = mysql_query ( mysql , "insert into t1 (a) select a from t1" ) ;
myquery ( rc ) ;
}
stmt = mysql_stmt_init ( mysql ) ;
type = ( ulong ) CURSOR_TYPE_READ_ONLY ;
mysql_stmt_attr_set ( stmt , STMT_ATTR_CURSOR_TYPE , ( const void * ) & type ) ;
stmt_text = "select a from t1" ;
rc = mysql_stmt_prepare ( stmt , stmt_text , strlen ( stmt_text ) ) ;
check_execute ( stmt , rc ) ;
rc = mysql_stmt_execute ( stmt ) ;
while ( ( rc = mysql_stmt_fetch ( stmt ) ) == 0 ) ;
DIE_UNLESS ( rc == MYSQL_NO_DATA ) ;
rc = mysql_stmt_close ( stmt ) ;
rc = mysql_query ( mysql , "drop table t1" ) ;
myquery ( rc ) ;
rc = mysql_query ( mysql , "set @@session.max_heap_table_size=default" ) ;
myquery ( rc ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void usage_exit ( ) {
fprintf ( stderr , "Usage: %s <infile> <outfile>\n" , exec_name ) ;
exit ( EXIT_FAILURE ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int mi_repair ( MI_CHECK * param , register MI_INFO * info , char * name , int rep_quick ) {
int error , got_error ;
ha_rows start_records , new_header_length ;
my_off_t del ;
File new_file ;
MYISAM_SHARE * share = info -> s ;
char llbuff [ 22 ] , llbuff2 [ 22 ] ;
SORT_INFO sort_info ;
MI_SORT_PARAM sort_param ;
DBUG_ENTER ( "mi_repair" ) ;
bzero ( ( char * ) & sort_info , sizeof ( sort_info ) ) ;
bzero ( ( char * ) & sort_param , sizeof ( sort_param ) ) ;
start_records = info -> state -> records ;
new_header_length = ( param -> testflag & T_UNPACK ) ? 0L : share -> pack . header_length ;
got_error = 1 ;
new_file = - 1 ;
sort_param . sort_info = & sort_info ;
if ( ! ( param -> testflag & T_SILENT ) ) {
printf ( "- recovering (with keycache) MyISAM-table '%s'\n" , name ) ;
printf ( "Data records: %s\n" , llstr ( info -> state -> records , llbuff ) ) ;
}
param -> testflag |= T_REP ;
if ( info -> s -> options & ( HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD ) ) param -> testflag |= T_CALC_CHECKSUM ;
DBUG_ASSERT ( param -> use_buffers < SIZE_T_MAX ) ;
if ( ! param -> using_global_keycache ) ( void ) init_key_cache ( dflt_key_cache , param -> key_cache_block_size , param -> use_buffers , 0 , 0 ) ;
if ( init_io_cache ( & param -> read_cache , info -> dfile , ( uint ) param -> read_buffer_length , READ_CACHE , share -> pack . header_length , 1 , MYF ( MY_WME ) ) ) {
bzero ( & info -> rec_cache , sizeof ( info -> rec_cache ) ) ;
goto err ;
}
if ( ! rep_quick ) if ( init_io_cache ( & info -> rec_cache , - 1 , ( uint ) param -> write_buffer_length , WRITE_CACHE , new_header_length , 1 , MYF ( MY_WME | MY_WAIT_IF_FULL ) ) ) goto err ;
info -> opt_flag |= WRITE_CACHE_USED ;
if ( ! mi_alloc_rec_buff ( info , - 1 , & sort_param . record ) || ! mi_alloc_rec_buff ( info , - 1 , & sort_param . rec_buff ) ) {
mi_check_print_error ( param , "Not enough memory for extra record" ) ;
goto err ;
}
if ( ! rep_quick ) {
if ( ( new_file = mysql_file_create ( mi_key_file_datatmp , fn_format ( param -> temp_filename , share -> data_file_name , "" , DATA_TMP_EXT , 2 + 4 ) , 0 , param -> tmpfile_createflag , MYF ( 0 ) ) ) < 0 ) {
mi_check_print_error ( param , "Can't create new tempfile: '%s'" , param -> temp_filename ) ;
goto err ;
}
if ( new_header_length && filecopy ( param , new_file , info -> dfile , 0L , new_header_length , "datafile-header" ) ) goto err ;
info -> s -> state . dellink = HA_OFFSET_ERROR ;
info -> rec_cache . file = new_file ;
if ( param -> testflag & T_UNPACK ) {
share -> options &= ~ HA_OPTION_COMPRESS_RECORD ;
mi_int2store ( share -> state . header . options , share -> options ) ;
}
}
sort_info . info = info ;
sort_info . param = param ;
sort_param . read_cache = param -> read_cache ;
sort_param . pos = sort_param . max_pos = share -> pack . header_length ;
sort_param . filepos = new_header_length ;
param -> read_cache . end_of_file = sort_info . filelength = mysql_file_seek ( info -> dfile , 0L , MY_SEEK_END , MYF ( 0 ) ) ;
sort_info . dupp = 0 ;
sort_param . fix_datafile = ( my_bool ) ( ! rep_quick ) ;
sort_param . master = 1 ;
sort_info . max_records = ~ ( ha_rows ) 0 ;
set_data_file_type ( & sort_info , share ) ;
del = info -> state -> del ;
info -> state -> records = info -> state -> del = share -> state . split = 0 ;
info -> state -> empty = 0 ;
param -> glob_crc = 0 ;
if ( param -> testflag & T_CALC_CHECKSUM ) sort_param . calc_checksum = 1 ;
info -> update = ( short ) ( HA_STATE_CHANGED | HA_STATE_ROW_CHANGED ) ;
if ( param -> testflag & T_CREATE_MISSING_KEYS ) mi_set_all_keys_active ( share -> state . key_map , share -> base . keys ) ;
mi_drop_all_indexes ( param , info , TRUE ) ;
lock_memory ( param ) ;
while ( ! ( error = sort_get_next_record ( & sort_param ) ) ) {
if ( writekeys ( & sort_param ) ) {
if ( my_errno != HA_ERR_FOUND_DUPP_KEY ) goto err ;
DBUG_DUMP ( "record" , ( uchar * ) sort_param . record , share -> base . pack_reclength ) ;
mi_check_print_info ( param , "Duplicate key %2d for record at %10s against new record at %10s" , info -> errkey + 1 , llstr ( sort_param . start_recpos , llbuff ) , llstr ( info -> dupp_key_pos , llbuff2 ) ) ;
if ( param -> testflag & T_VERBOSE ) {
( void ) _mi_make_key ( info , ( uint ) info -> errkey , info -> lastkey , sort_param . record , 0L ) ;
_mi_print_key ( stdout , share -> keyinfo [ info -> errkey ] . seg , info -> lastkey , USE_WHOLE_KEY ) ;
}
sort_info . dupp ++ ;
if ( ( param -> testflag & ( T_FORCE_UNIQUENESS | T_QUICK ) ) == T_QUICK ) {
param -> testflag |= T_RETRY_WITHOUT_QUICK ;
param -> error_printed = 1 ;
goto err ;
}
continue ;
}
if ( sort_write_record ( & sort_param ) ) goto err ;
}
if ( error > 0 || write_data_suffix ( & sort_info , ( my_bool ) ! rep_quick ) || flush_io_cache ( & info -> rec_cache ) || param -> read_cache . error < 0 ) goto err ;
if ( param -> testflag & T_WRITE_LOOP ) {
( void ) fputs ( " \r" , stdout ) ;
( void ) fflush ( stdout ) ;
}
if ( mysql_file_chsize ( share -> kfile , info -> state -> key_file_length , 0 , MYF ( 0 ) ) ) {
mi_check_print_warning ( param , "Can't change size of indexfile, error: %d" , my_errno ) ;
goto err ;
}
if ( rep_quick && del + sort_info . dupp != info -> state -> del ) {
mi_check_print_error ( param , "Couldn't fix table with quick recovery: Found wrong number of deleted records" ) ;
mi_check_print_error ( param , "Run recovery again without -q" ) ;
got_error = 1 ;
param -> retry_repair = 1 ;
param -> testflag |= T_RETRY_WITHOUT_QUICK ;
goto err ;
}
if ( param -> testflag & T_SAFE_REPAIR ) {
if ( info -> state -> records + 1 < start_records ) {
info -> state -> records = start_records ;
got_error = 1 ;
goto err ;
}
}
if ( ! rep_quick ) {
mysql_file_close ( info -> dfile , MYF ( 0 ) ) ;
info -> dfile = new_file ;
info -> state -> data_file_length = sort_param . filepos ;
share -> state . version = ( ulong ) time ( ( time_t * ) 0 ) ;
}
else {
info -> state -> data_file_length = sort_param . max_pos ;
}
if ( param -> testflag & T_CALC_CHECKSUM ) info -> state -> checksum = param -> glob_crc ;
if ( ! ( param -> testflag & T_SILENT ) ) {
if ( start_records != info -> state -> records ) printf ( "Data records: %s\n" , llstr ( info -> state -> records , llbuff ) ) ;
if ( sort_info . dupp ) mi_check_print_warning ( param , "%s records have been removed" , llstr ( sort_info . dupp , llbuff ) ) ;
}
got_error = 0 ;
if ( & share -> state . state != info -> state ) memcpy ( & share -> state . state , info -> state , sizeof ( * info -> state ) ) ;
err : if ( ! got_error ) {
if ( new_file >= 0 ) {
mysql_file_close ( new_file , MYF ( 0 ) ) ;
info -> dfile = new_file = - 1 ;
if ( info -> s -> file_map ) {
( void ) my_munmap ( ( char * ) info -> s -> file_map , ( size_t ) info -> s -> mmaped_length ) ;
info -> s -> file_map = NULL ;
}
if ( change_to_newfile ( share -> data_file_name , MI_NAME_DEXT , DATA_TMP_EXT , ( param -> testflag & T_BACKUP_DATA ? MYF ( MY_REDEL_MAKE_BACKUP ) : MYF ( 0 ) ) ) || mi_open_datafile ( info , share , name , - 1 ) ) got_error = 1 ;
param -> retry_repair = 0 ;
}
}
if ( got_error ) {
if ( ! param -> error_printed ) mi_check_print_error ( param , "%d for record at pos %s" , my_errno , llstr ( sort_param . start_recpos , llbuff ) ) ;
if ( new_file >= 0 ) {
( void ) mysql_file_close ( new_file , MYF ( 0 ) ) ;
( void ) mysql_file_delete ( mi_key_file_datatmp , param -> temp_filename , MYF ( MY_WME ) ) ;
info -> rec_cache . file = - 1 ;
}
mi_mark_crashed_on_repair ( info ) ;
}
my_free ( mi_get_rec_buff_ptr ( info , sort_param . rec_buff ) ) ;
my_free ( mi_get_rec_buff_ptr ( info , sort_param . record ) ) ;
my_free ( sort_info . buff ) ;
( void ) end_io_cache ( & param -> read_cache ) ;
info -> opt_flag &= ~ ( READ_CACHE_USED | WRITE_CACHE_USED ) ;
( void ) end_io_cache ( & info -> rec_cache ) ;
got_error |= flush_blocks ( param , share -> key_cache , share -> kfile ) ;
if ( ! got_error && param -> testflag & T_UNPACK ) {
share -> state . header . options [ 0 ] &= ( uchar ) ~ HA_OPTION_COMPRESS_RECORD ;
share -> pack . header_length = 0 ;
share -> data_file_type = sort_info . new_data_file_type ;
}
share -> state . changed |= ( STATE_NOT_OPTIMIZED_KEYS | STATE_NOT_SORTED_PAGES | STATE_NOT_ANALYZED ) ;
DBUG_RETURN ( got_error ) ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static void cleanup_pam ( int retcode ) {
int saved_errno = errno ;
if ( _pam_session_opened ) pam_close_session ( pamh , 0 ) ;
if ( _pam_cred_established ) pam_setcred ( pamh , PAM_DELETE_CRED | PAM_SILENT ) ;
pam_end ( pamh , retcode ) ;
errno = saved_errno ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int64_t cpu_get_ticks ( void ) {
if ( use_icount ) {
return cpu_get_icount ( ) ;
}
if ( ! timers_state . cpu_ticks_enabled ) {
return timers_state . cpu_ticks_offset ;
}
else {
int64_t ticks ;
ticks = cpu_get_real_ticks ( ) ;
if ( timers_state . cpu_ticks_prev > ticks ) {
timers_state . cpu_ticks_offset += timers_state . cpu_ticks_prev - ticks ;
}
timers_state . cpu_ticks_prev = ticks ;
return ticks + timers_state . cpu_ticks_offset ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void test_field_names ( ) {
int rc ;
MYSQL_RES * result ;
myheader ( "test_field_names" ) ;
if ( ! opt_silent ) fprintf ( stdout , "\n %d, %d, %d" , MYSQL_TYPE_DECIMAL , MYSQL_TYPE_NEWDATE , MYSQL_TYPE_ENUM ) ;
rc = mysql_query ( mysql , "DROP TABLE IF EXISTS test_field_names1" ) ;
myquery ( rc ) ;
rc = mysql_query ( mysql , "DROP TABLE IF EXISTS test_field_names2" ) ;
myquery ( rc ) ;
rc = mysql_query ( mysql , "CREATE TABLE test_field_names1(id int, name varchar(50))" ) ;
myquery ( rc ) ;
rc = mysql_query ( mysql , "CREATE TABLE test_field_names2(id int, name varchar(50))" ) ;
myquery ( rc ) ;
rc = mysql_query ( mysql , "SELECT id as 'id-alias' FROM test_field_names1" ) ;
myquery ( rc ) ;
result = mysql_use_result ( mysql ) ;
mytest ( result ) ;
rc = my_process_result_set ( result ) ;
DIE_UNLESS ( rc == 0 ) ;
mysql_free_result ( result ) ;
rc = mysql_query ( mysql , "SELECT t1.id as 'id-alias', test_field_names2.name FROM test_field_names1 t1, test_field_names2" ) ;
myquery ( rc ) ;
result = mysql_use_result ( mysql ) ;
mytest ( result ) ;
rc = my_process_result_set ( result ) ;
DIE_UNLESS ( rc == 0 ) ;
mysql_free_result ( result ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void bn_mul_comba4 ( BN_ULONG * r , BN_ULONG * a , BN_ULONG * b ) {
BN_ULONG t1 , t2 ;
BN_ULONG c1 , c2 , c3 ;
c1 = 0 ;
c2 = 0 ;
c3 = 0 ;
mul_add_c ( a [ 0 ] , b [ 0 ] , c1 , c2 , c3 ) ;
r [ 0 ] = c1 ;
c1 = 0 ;
mul_add_c ( a [ 0 ] , b [ 1 ] , c2 , c3 , c1 ) ;
mul_add_c ( a [ 1 ] , b [ 0 ] , c2 , c3 , c1 ) ;
r [ 1 ] = c2 ;
c2 = 0 ;
mul_add_c ( a [ 2 ] , b [ 0 ] , c3 , c1 , c2 ) ;
mul_add_c ( a [ 1 ] , b [ 1 ] , c3 , c1 , c2 ) ;
mul_add_c ( a [ 0 ] , b [ 2 ] , c3 , c1 , c2 ) ;
r [ 2 ] = c3 ;
c3 = 0 ;
mul_add_c ( a [ 0 ] , b [ 3 ] , c1 , c2 , c3 ) ;
mul_add_c ( a [ 1 ] , b [ 2 ] , c1 , c2 , c3 ) ;
mul_add_c ( a [ 2 ] , b [ 1 ] , c1 , c2 , c3 ) ;
mul_add_c ( a [ 3 ] , b [ 0 ] , c1 , c2 , c3 ) ;
r [ 3 ] = c1 ;
c1 = 0 ;
mul_add_c ( a [ 3 ] , b [ 1 ] , c2 , c3 , c1 ) ;
mul_add_c ( a [ 2 ] , b [ 2 ] , c2 , c3 , c1 ) ;
mul_add_c ( a [ 1 ] , b [ 3 ] , c2 , c3 , c1 ) ;
r [ 4 ] = c2 ;
c2 = 0 ;
mul_add_c ( a [ 2 ] , b [ 3 ] , c3 , c1 , c2 ) ;
mul_add_c ( a [ 3 ] , b [ 2 ] , c3 , c1 , c2 ) ;
r [ 5 ] = c3 ;
c3 = 0 ;
mul_add_c ( a [ 3 ] , b [ 3 ] , c1 , c2 , c3 ) ;
r [ 6 ] = c1 ;
r [ 7 ] = c2 ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_h225_Content ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
offset = dissect_per_choice ( tvb , offset , actx , tree , hf_index , ett_h225_Content , Content_choice , NULL ) ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_h245_T_forwardMultiplexAckParameters ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
# line 279 "../../asn1/h245/h245.cnf" upcoming_channel = ( upcoming_olc ) ? & upcoming_olc -> fwd_lc : NULL ;
offset = dissect_per_choice ( tvb , offset , actx , tree , hf_index , ett_h245_T_forwardMultiplexAckParameters , T_forwardMultiplexAckParameters_choice , NULL ) ;
upcoming_channel = NULL ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | hb_script_t hb_ot_tag_to_script ( hb_tag_t tag ) {
if ( unlikely ( ( tag & 0x000000FFu ) == '2' ) ) return hb_ot_new_tag_to_script ( tag ) ;
return hb_ot_old_tag_to_script ( tag ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static ossl_inline int lh_ ## type ## _error ( LHASH_OF ( type ) * lh ) {
return OPENSSL_LH_error ( ( OPENSSL_LHASH * ) lh ) ;
}
static ossl_inline unsigned long lh_ ## type ## _num_items ( LHASH_OF ( type ) * lh ) {
return OPENSSL_LH_num_items ( ( OPENSSL_LHASH * ) lh ) ;
}
static ossl_inline void lh_ ## type ## _node_stats_bio ( const LHASH_OF ( type ) * lh , BIO * out ) {
OPENSSL_LH_node_stats_bio ( ( const OPENSSL_LHASH * ) lh , out ) ;
}
static ossl_inline void lh_ ## type ## _node_usage_stats_bio ( const LHASH_OF ( type ) * lh , BIO * out ) {
OPENSSL_LH_node_usage_stats_bio ( ( const OPENSSL_LHASH * ) lh , out ) ;
}
static ossl_inline void lh_ ## type ## _stats_bio ( const LHASH_OF ( type ) * lh , BIO * out ) {
OPENSSL_LH_stats_bio ( ( const OPENSSL_LHASH * ) lh , out ) ;
}
static ossl_inline unsigned long lh_ ## type ## _get_down_load ( LHASH_OF ( type ) * lh ) {
return OPENSSL_LH_get_down_load ( ( OPENSSL_LHASH * ) lh ) ;
}
static ossl_inline void lh_ ## type ## _set_down_load ( LHASH_OF ( type ) * lh , unsigned long dl ) {
OPENSSL_LH_set_down_load ( ( OPENSSL_LHASH * ) lh , dl ) ;
}
static ossl_inline void lh_ ## type ## _doall ( LHASH_OF ( type ) * lh , void ( * doall ) ( type * ) ) {
OPENSSL_LH_doall ( ( OPENSSL_LHASH * ) lh , ( OPENSSL_LH_DOALL_FUNC ) doall ) ;
}
LHASH_OF ( type ) # define IMPLEMENT_LHASH_DOALL_ARG_CONST ( type , argtype ) int_implement_lhash_doall ( type , argtype , const type ) # define IMPLEMENT_LHASH_DOALL_ARG ( type , argtype ) int_implement_lhash_doall ( type , argtype , type ) # define int_implement_lhash_doall ( type , argtype , cbargtype ) static ossl_inline void lh_ ## type ## _doall_ ## argtype ( LHASH_OF ( type ) * lh , void ( * fn ) ( cbargtype * , argtype * ) , argtype * arg ) {
OPENSSL_LH_doall_arg ( ( OPENSSL_LHASH * ) lh , ( OPENSSL_LH_DOALL_FUNCARG ) fn , ( void * ) arg ) ;
}
LHASH_OF ( type ) DEFINE_LHASH_OF ( OPENSSL_STRING ) ;
# ifdef _MSC_VER # pragma warning ( push ) # pragma warning ( disable : 4090 ) # endif DEFINE_LHASH_OF ( OPENSSL_CSTRING ) | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int test_mont ( BIO * bp , BN_CTX * ctx ) {
BIGNUM a , b , c , d , A , B ;
BIGNUM n ;
int i ;
BN_MONT_CTX * mont ;
BN_init ( & a ) ;
BN_init ( & b ) ;
BN_init ( & c ) ;
BN_init ( & d ) ;
BN_init ( & A ) ;
BN_init ( & B ) ;
BN_init ( & n ) ;
mont = BN_MONT_CTX_new ( ) ;
if ( mont == NULL ) return 0 ;
BN_bntest_rand ( & a , 100 , 0 , 0 ) ;
BN_bntest_rand ( & b , 100 , 0 , 0 ) ;
for ( i = 0 ;
i < num2 ;
i ++ ) {
int bits = ( 200 * ( i + 1 ) ) um2 ;
if ( bits == 0 ) continue ;
BN_bntest_rand ( & n , bits , 0 , 1 ) ;
BN_MONT_CTX_set ( mont , & n , ctx ) ;
BN_nnmod ( & a , & a , & n , ctx ) ;
BN_nnmod ( & b , & b , & n , ctx ) ;
BN_to_montgomery ( & A , & a , mont , ctx ) ;
BN_to_montgomery ( & B , & b , mont , ctx ) ;
BN_mod_mul_montgomery ( & c , & A , & B , mont , ctx ) ;
BN_from_montgomery ( & A , & c , mont , ctx ) ;
if ( bp != NULL ) {
if ( ! results ) {
# ifdef undef fprintf ( stderr , "%d * %d %% %d\n" , BN_num_bits ( & a ) , BN_num_bits ( & b ) , BN_num_bits ( mont -> N ) ) ;
# endif BN_print ( bp , & a ) ;
BIO_puts ( bp , " * " ) ;
BN_print ( bp , & b ) ;
BIO_puts ( bp , " % " ) ;
BN_print ( bp , & ( mont -> N ) ) ;
BIO_puts ( bp , " - " ) ;
}
BN_print ( bp , & A ) ;
BIO_puts ( bp , "\n" ) ;
}
BN_mod_mul ( & d , & a , & b , & n , ctx ) ;
BN_sub ( & d , & d , & A ) ;
if ( ! BN_is_zero ( & d ) ) {
fprintf ( stderr , "Montgomery multiplication test failed!\n" ) ;
return 0 ;
}
}
BN_MONT_CTX_free ( mont ) ;
BN_free ( & a ) ;
BN_free ( & b ) ;
BN_free ( & c ) ;
BN_free ( & d ) ;
BN_free ( & A ) ;
BN_free ( & B ) ;
BN_free ( & n ) ;
return ( 1 ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int auth_server_connection_connect ( struct auth_server_connection * conn ) {
const char * handshake ;
int fd ;
i_assert ( ! conn -> connected ) ;
i_assert ( conn -> fd == - 1 ) ;
conn -> last_connect = ioloop_time ;
timeout_remove ( & conn -> to ) ;
fd = net_connect_unix_with_retries ( conn -> client -> auth_socket_path , 1000 ) ;
if ( fd == - 1 ) {
if ( errno == EACCES ) {
i_error ( "auth: %s" , eacces_error_get ( "connect" , conn -> client -> auth_socket_path ) ) ;
}
else {
i_error ( "auth: connect(%s) failed: %m" , conn -> client -> auth_socket_path ) ;
}
return - 1 ;
}
conn -> fd = fd ;
conn -> io = io_add ( fd , IO_READ , auth_server_connection_input , conn ) ;
conn -> input = i_stream_create_fd ( fd , AUTH_SERVER_CONN_MAX_LINE_LENGTH ) ;
conn -> output = o_stream_create_fd ( fd , ( size_t ) - 1 ) ;
conn -> connected = TRUE ;
handshake = t_strdup_printf ( "VERSION\t%u\t%u\nCPID\t%u\n" , AUTH_CLIENT_PROTOCOL_MAJOR_VERSION , AUTH_CLIENT_PROTOCOL_MINOR_VERSION , conn -> client -> client_pid ) ;
if ( o_stream_send_str ( conn -> output , handshake ) < 0 ) {
i_warning ( "Error sending handshake to auth server: %s" , o_stream_get_error ( conn -> output ) ) ;
auth_server_connection_disconnect ( conn , o_stream_get_error ( conn -> output ) ) ;
return - 1 ;
}
conn -> to = timeout_add ( AUTH_HANDSHAKE_TIMEOUT , auth_client_handshake_timeout , conn ) ;
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int shorten_decode_frame ( AVCodecContext * avctx , void * data , int * got_frame_ptr , AVPacket * avpkt ) {
AVFrame * frame = data ;
const uint8_t * buf = avpkt -> data ;
int buf_size = avpkt -> size ;
ShortenContext * s = avctx -> priv_data ;
int i , input_buf_size = 0 ;
int ret ;
if ( s -> max_framesize == 0 ) {
void * tmp_ptr ;
s -> max_framesize = 1024 ;
tmp_ptr = av_fast_realloc ( s -> bitstream , & s -> allocated_bitstream_size , s -> max_framesize ) ;
if ( ! tmp_ptr ) {
av_log ( avctx , AV_LOG_ERROR , "error allocating bitstream buffer\n" ) ;
return AVERROR ( ENOMEM ) ;
}
s -> bitstream = tmp_ptr ;
}
if ( 1 && s -> max_framesize ) {
buf_size = FFMIN ( buf_size , s -> max_framesize - s -> bitstream_size ) ;
input_buf_size = buf_size ;
if ( s -> bitstream_index + s -> bitstream_size + buf_size > s -> allocated_bitstream_size ) {
memmove ( s -> bitstream , & s -> bitstream [ s -> bitstream_index ] , s -> bitstream_size ) ;
s -> bitstream_index = 0 ;
}
if ( buf ) memcpy ( & s -> bitstream [ s -> bitstream_index + s -> bitstream_size ] , buf , buf_size ) ;
buf = & s -> bitstream [ s -> bitstream_index ] ;
buf_size += s -> bitstream_size ;
s -> bitstream_size = buf_size ;
if ( buf_size < s -> max_framesize && avpkt -> data ) {
* got_frame_ptr = 0 ;
return input_buf_size ;
}
}
init_get_bits ( & s -> gb , buf , buf_size * 8 ) ;
skip_bits ( & s -> gb , s -> bitindex ) ;
if ( ! s -> got_header ) {
if ( ( ret = read_header ( s ) ) < 0 ) return ret ;
* got_frame_ptr = 0 ;
goto finish_frame ;
}
if ( s -> got_quit_command ) {
* got_frame_ptr = 0 ;
return avpkt -> size ;
}
s -> cur_chan = 0 ;
while ( s -> cur_chan < s -> channels ) {
unsigned cmd ;
int len ;
if ( get_bits_left ( & s -> gb ) < 3 + FNSIZE ) {
* got_frame_ptr = 0 ;
break ;
}
cmd = get_ur_golomb_shorten ( & s -> gb , FNSIZE ) ;
if ( cmd > FN_VERBATIM ) {
av_log ( avctx , AV_LOG_ERROR , "unknown shorten function %d\n" , cmd ) ;
* got_frame_ptr = 0 ;
break ;
}
if ( ! is_audio_command [ cmd ] ) {
switch ( cmd ) {
case FN_VERBATIM : len = get_ur_golomb_shorten ( & s -> gb , VERBATIM_CKSIZE_SIZE ) ;
while ( len -- ) get_ur_golomb_shorten ( & s -> gb , VERBATIM_BYTE_SIZE ) ;
break ;
case FN_BITSHIFT : s -> bitshift = get_ur_golomb_shorten ( & s -> gb , BITSHIFTSIZE ) ;
break ;
case FN_BLOCKSIZE : {
unsigned blocksize = get_uint ( s , av_log2 ( s -> blocksize ) ) ;
if ( blocksize > s -> blocksize ) {
av_log ( avctx , AV_LOG_ERROR , "Increasing block size is not supported\n" ) ;
return AVERROR_PATCHWELCOME ;
}
if ( ! blocksize || blocksize > MAX_BLOCKSIZE ) {
av_log ( avctx , AV_LOG_ERROR , "invalid or unsupported " "block size: %d\n" , blocksize ) ;
return AVERROR ( EINVAL ) ;
}
s -> blocksize = blocksize ;
break ;
}
case FN_QUIT : s -> got_quit_command = 1 ;
break ;
}
if ( cmd == FN_BLOCKSIZE || cmd == FN_QUIT ) {
* got_frame_ptr = 0 ;
break ;
}
}
else {
int residual_size = 0 ;
int channel = s -> cur_chan ;
int32_t coffset ;
if ( cmd != FN_ZERO ) {
residual_size = get_ur_golomb_shorten ( & s -> gb , ENERGYSIZE ) ;
if ( s -> version == 0 ) residual_size -- ;
}
if ( s -> nmean == 0 ) coffset = s -> offset [ channel ] [ 0 ] ;
else {
int32_t sum = ( s -> version < 2 ) ? 0 : s -> nmean / 2 ;
for ( i = 0 ;
i < s -> nmean ;
i ++ ) sum += s -> offset [ channel ] [ i ] ;
coffset = sum / s -> nmean ;
if ( s -> version >= 2 ) coffset >>= FFMIN ( 1 , s -> bitshift ) ;
}
if ( cmd == FN_ZERO ) {
for ( i = 0 ;
i < s -> blocksize ;
i ++ ) s -> decoded [ channel ] [ i ] = 0 ;
}
else {
if ( ( ret = decode_subframe_lpc ( s , cmd , channel , residual_size , coffset ) ) < 0 ) return ret ;
}
if ( s -> nmean > 0 ) {
int32_t sum = ( s -> version < 2 ) ? 0 : s -> blocksize / 2 ;
for ( i = 0 ;
i < s -> blocksize ;
i ++ ) sum += s -> decoded [ channel ] [ i ] ;
for ( i = 1 ;
i < s -> nmean ;
i ++ ) s -> offset [ channel ] [ i - 1 ] = s -> offset [ channel ] [ i ] ;
if ( s -> version < 2 ) s -> offset [ channel ] [ s -> nmean - 1 ] = sum / s -> blocksize ;
else s -> offset [ channel ] [ s -> nmean - 1 ] = ( sum / s -> blocksize ) << s -> bitshift ;
}
for ( i = - s -> nwrap ;
i < 0 ;
i ++ ) s -> decoded [ channel ] [ i ] = s -> decoded [ channel ] [ i + s -> blocksize ] ;
fix_bitshift ( s , s -> decoded [ channel ] ) ;
s -> cur_chan ++ ;
if ( s -> cur_chan == s -> channels ) {
frame -> nb_samples = s -> blocksize ;
if ( ( ret = ff_get_buffer ( avctx , frame , 0 ) ) < 0 ) {
av_log ( avctx , AV_LOG_ERROR , "get_buffer() failed\n" ) ;
return ret ;
}
output_buffer ( ( int16_t * * ) frame -> extended_data , s -> channels , s -> blocksize , s -> decoded ) ;
* got_frame_ptr = 1 ;
}
}
}
if ( s -> cur_chan < s -> channels ) * got_frame_ptr = 0 ;
finish_frame : s -> bitindex = get_bits_count ( & s -> gb ) - 8 * ( get_bits_count ( & s -> gb ) / 8 ) ;
i = get_bits_count ( & s -> gb ) / 8 ;
if ( i > buf_size ) {
av_log ( s -> avctx , AV_LOG_ERROR , "overread: %d\n" , i - buf_size ) ;
s -> bitstream_size = 0 ;
s -> bitstream_index = 0 ;
return AVERROR_INVALIDDATA ;
}
if ( s -> bitstream_size ) {
s -> bitstream_index += i ;
s -> bitstream_size -= i ;
return input_buf_size ;
}
else return i ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void steamdiscover_dissect_body_authrequest ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree , gint offset , gint bytes_left ) {
guint len ;
gint64 value ;
protobuf_desc_t pb = {
tvb , offset , bytes_left }
;
protobuf_tag_t tag = {
0 , 0 , 0 }
;
wmem_allocator_t * strpool ;
strpool = wmem_allocator_new ( WMEM_ALLOCATOR_SIMPLE ) ;
guint8 * devicename ;
while ( protobuf_iter_next ( & pb , & tag ) ) {
switch ( tag . field_number ) {
case STEAMDISCOVER_FN_AUTHREQUEST_DEVICETOKEN : STEAMDISCOVER_ENSURE_WIRETYPE ( PROTOBUF_WIRETYPE_LENGTHDELIMITED ) ;
value = get_varint64 ( pb . tvb , pb . offset , pb . bytes_left , & len ) ;
proto_tree_add_item ( tree , hf_steam_ihs_discovery_body_authrequest_devicetoken , pb . tvb , pb . offset + len , ( gint ) value , ENC_NA ) ;
len += ( gint ) value ;
break ;
case STEAMDISCOVER_FN_AUTHREQUEST_DEVICENAME : STEAMDISCOVER_ENSURE_WIRETYPE ( PROTOBUF_WIRETYPE_LENGTHDELIMITED ) ;
value = get_varint64 ( pb . tvb , pb . offset , pb . bytes_left , & len ) ;
proto_tree_add_item ( tree , hf_steam_ihs_discovery_body_authrequest_devicename , pb . tvb , pb . offset + len , ( gint ) value , ENC_UTF_8 | ENC_NA ) ;
devicename = tvb_get_string_enc ( strpool , pb . tvb , pb . offset + len , ( gint ) value , ENC_UTF_8 ) ;
if ( devicename && strlen ( devicename ) ) {
col_append_fstr ( pinfo -> cinfo , COL_INFO , " from %s" , devicename ) ;
}
len += ( gint ) value ;
break ;
case STEAMDISCOVER_FN_AUTHREQUEST_ENCRYPTEDREQUEST : STEAMDISCOVER_ENSURE_WIRETYPE ( PROTOBUF_WIRETYPE_LENGTHDELIMITED ) ;
value = get_varint64 ( pb . tvb , pb . offset , pb . bytes_left , & len ) ;
proto_tree_add_item ( tree , hf_steam_ihs_discovery_body_authrequest_encryptedrequest , pb . tvb , pb . offset + len , ( gint ) value , ENC_NA ) ;
len += ( gint ) value ;
break ;
default : len = protobuf_dissect_unknown_field ( & pb , & tag , pinfo , tree , NULL ) ;
break ;
}
protobuf_seek_forward ( & pb , len ) ;
}
wmem_destroy_allocator ( strpool ) ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_rsl_ie_main_ch_ref ( tvbuff_t * tvb , packet_info * pinfo _U_ , proto_tree * tree , int offset , gboolean is_mandatory ) {
proto_tree * ie_tree ;
guint8 ie_id ;
if ( is_mandatory == FALSE ) {
ie_id = tvb_get_guint8 ( tvb , offset ) ;
if ( ie_id != RSL_IE_MAIN_CH_REF ) return offset ;
}
ie_tree = proto_tree_add_subtree ( tree , tvb , offset , 0 , ett_ie_main_ch_ref , NULL , "Main channel reference IE" ) ;
proto_tree_add_item ( ie_tree , hf_rsl_ie_id , tvb , offset , 1 , ENC_BIG_ENDIAN ) ;
offset ++ ;
proto_tree_add_item ( ie_tree , hf_rsl_ch_no_TN , tvb , offset , 1 , ENC_BIG_ENDIAN ) ;
offset ++ ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | struct mime_header_encoder_data * mime_header_encoder_new ( enum mbfl_no_encoding incode , enum mbfl_no_encoding outcode , enum mbfl_no_encoding transenc ) {
int n ;
const char * s ;
const mbfl_encoding * outencoding ;
struct mime_header_encoder_data * pe ;
outencoding = mbfl_no2encoding ( outcode ) ;
if ( outencoding == NULL || outencoding -> mime_name == NULL || outencoding -> mime_name [ 0 ] == '\0' ) {
return NULL ;
}
pe = ( struct mime_header_encoder_data * ) mbfl_malloc ( sizeof ( struct mime_header_encoder_data ) ) ;
if ( pe == NULL ) {
return NULL ;
}
mbfl_memory_device_init ( & pe -> outdev , 0 , 0 ) ;
mbfl_memory_device_init ( & pe -> tmpdev , 0 , 0 ) ;
pe -> prevpos = 0 ;
pe -> linehead = 0 ;
pe -> firstindent = 0 ;
pe -> status1 = 0 ;
pe -> status2 = 0 ;
n = 0 ;
pe -> encname [ n ++ ] = 0x3d ;
pe -> encname [ n ++ ] = 0x3f ;
s = outencoding -> mime_name ;
while ( * s ) {
pe -> encname [ n ++ ] = * s ++ ;
}
pe -> encname [ n ++ ] = 0x3f ;
if ( transenc == mbfl_no_encoding_qprint ) {
pe -> encname [ n ++ ] = 0x51 ;
}
else {
pe -> encname [ n ++ ] = 0x42 ;
transenc = mbfl_no_encoding_base64 ;
}
pe -> encname [ n ++ ] = 0x3f ;
pe -> encname [ n ] = '\0' ;
pe -> encnamelen = n ;
n = 0 ;
pe -> lwsp [ n ++ ] = 0x0d ;
pe -> lwsp [ n ++ ] = 0x0a ;
pe -> lwsp [ n ++ ] = 0x20 ;
pe -> lwsp [ n ] = '\0' ;
pe -> lwsplen = n ;
pe -> encod_filter = mbfl_convert_filter_new ( outcode , transenc , mbfl_memory_device_output , 0 , & ( pe -> outdev ) ) ;
pe -> encod_filter_backup = mbfl_convert_filter_new ( outcode , transenc , mbfl_memory_device_output , 0 , & ( pe -> outdev ) ) ;
pe -> conv2_filter = mbfl_convert_filter_new ( mbfl_no_encoding_wchar , outcode , mbfl_filter_output_pipe , 0 , pe -> encod_filter ) ;
pe -> conv2_filter_backup = mbfl_convert_filter_new ( mbfl_no_encoding_wchar , outcode , mbfl_filter_output_pipe , 0 , pe -> encod_filter ) ;
pe -> block_filter = mbfl_convert_filter_new ( mbfl_no_encoding_wchar , mbfl_no_encoding_wchar , mime_header_encoder_block_collector , 0 , pe ) ;
pe -> conv1_filter = mbfl_convert_filter_new ( incode , mbfl_no_encoding_wchar , mime_header_encoder_collector , 0 , pe ) ;
if ( pe -> encod_filter == NULL || pe -> encod_filter_backup == NULL || pe -> conv2_filter == NULL || pe -> conv2_filter_backup == NULL || pe -> conv1_filter == NULL ) {
mime_header_encoder_delete ( pe ) ;
return NULL ;
}
if ( transenc == mbfl_no_encoding_qprint ) {
pe -> encod_filter -> status |= MBFL_QPRINT_STS_MIME_HEADER ;
pe -> encod_filter_backup -> status |= MBFL_QPRINT_STS_MIME_HEADER ;
}
else {
pe -> encod_filter -> status |= MBFL_BASE64_STS_MIME_HEADER ;
pe -> encod_filter_backup -> status |= MBFL_BASE64_STS_MIME_HEADER ;
}
return pe ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int kvm_get_mce_cap_supported ( KVMState * s , uint64_t * mce_cap , int * max_banks ) {
int r ;
r = kvm_check_extension ( s , KVM_CAP_MCE ) ;
if ( r > 0 ) {
* max_banks = r ;
return kvm_ioctl ( s , KVM_X86_GET_MCE_CAP_SUPPORTED , mce_cap ) ;
}
return - ENOSYS ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void vp8_mbpost_proc_down_c ( unsigned char * dst , int pitch , int rows , int cols , int flimit ) {
int r , c , i ;
const short * rv3 = & vp8_rv [ 63 & rand ( ) ] ;
for ( c = 0 ;
c < cols ;
c ++ ) {
unsigned char * s = & dst [ c ] ;
int sumsq = 0 ;
int sum = 0 ;
unsigned char d [ 16 ] ;
const short * rv2 = rv3 + ( ( c * 17 ) & 127 ) ;
for ( i = - 8 ;
i < 0 ;
i ++ ) s [ i * pitch ] = s [ 0 ] ;
for ( i = rows ;
i < rows + 17 ;
i ++ ) s [ i * pitch ] = s [ ( rows - 1 ) * pitch ] ;
for ( i = - 8 ;
i <= 6 ;
i ++ ) {
sumsq += s [ i * pitch ] * s [ i * pitch ] ;
sum += s [ i * pitch ] ;
}
for ( r = 0 ;
r < rows + 8 ;
r ++ ) {
sumsq += s [ 7 * pitch ] * s [ 7 * pitch ] - s [ - 8 * pitch ] * s [ - 8 * pitch ] ;
sum += s [ 7 * pitch ] - s [ - 8 * pitch ] ;
d [ r & 15 ] = s [ 0 ] ;
if ( sumsq * 15 - sum * sum < flimit ) {
d [ r & 15 ] = ( rv2 [ r & 127 ] + sum + s [ 0 ] ) >> 4 ;
}
if ( r >= 8 ) s [ - 8 * pitch ] = d [ ( r - 8 ) & 15 ] ;
s += pitch ;
}
}
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | const gx_device * gs_getdefaultdevice ( void ) {
return gs_getdefaultlibdevice ( NULL ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int ReadOffset ( ArchiveHandle * AH , pgoff_t * o ) {
int i ;
int off ;
int offsetFlg ;
* o = 0 ;
if ( AH -> version < K_VERS_1_7 ) {
i = ReadInt ( AH ) ;
if ( i < 0 ) return K_OFFSET_POS_NOT_SET ;
else if ( i == 0 ) return K_OFFSET_NO_DATA ;
* o = ( pgoff_t ) i ;
return K_OFFSET_POS_SET ;
}
offsetFlg = ( * AH -> ReadBytePtr ) ( AH ) & 0xFF ;
switch ( offsetFlg ) {
case K_OFFSET_POS_NOT_SET : case K_OFFSET_NO_DATA : case K_OFFSET_POS_SET : break ;
default : exit_horribly ( modulename , "unexpected data offset flag %d\n" , offsetFlg ) ;
}
for ( off = 0 ;
off < AH -> offSize ;
off ++ ) {
if ( off < sizeof ( pgoff_t ) ) * o |= ( ( pgoff_t ) ( ( * AH -> ReadBytePtr ) ( AH ) ) ) << ( off * 8 ) ;
else {
if ( ( * AH -> ReadBytePtr ) ( AH ) != 0 ) exit_horribly ( modulename , "file offset in dump file is too large\n" ) ;
}
}
return offsetFlg ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void msyslog ( int level , const char * fmt , ... ) {
char buf [ 1024 ] ;
va_list ap ;
va_start ( ap , fmt ) ;
mvsnprintf ( buf , sizeof ( buf ) , fmt , ap ) ;
va_end ( ap ) ;
addto_syslog ( level , buf ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_h245_T_cLC_source ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
offset = dissect_per_choice ( tvb , offset , actx , tree , hf_index , ett_h245_T_cLC_source , T_cLC_source_choice , NULL ) ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void dissect_zcl_appl_idt_attr_data ( proto_tree * tree , tvbuff_t * tvb , guint * offset , guint16 attr_id , guint data_type ) {
proto_tree * sub_tree ;
guint64 value64 ;
switch ( attr_id ) {
case ZBEE_ZCL_ATTR_ID_APPL_IDT_BASIC_IDENT : value64 = tvb_get_letoh56 ( tvb , * offset ) ;
sub_tree = proto_tree_add_subtree_format ( tree , tvb , * offset , 8 , ett_zbee_zcl_appl_idt_basic , NULL , "Basic Identification: 0x%" G_GINT64_MODIFIER "x" , value64 ) ;
proto_tree_add_item ( sub_tree , hf_zbee_zcl_appl_idt_company_id , tvb , * offset , 2 , ENC_LITTLE_ENDIAN ) ;
* offset += 2 ;
proto_tree_add_item ( sub_tree , hf_zbee_zcl_appl_idt_brand_id , tvb , * offset , 2 , ENC_LITTLE_ENDIAN ) ;
* offset += 2 ;
proto_tree_add_item ( sub_tree , hf_zbee_zcl_appl_idt_prod_type_id , tvb , * offset , 2 , ENC_LITTLE_ENDIAN ) ;
* offset += 2 ;
proto_tree_add_item ( sub_tree , hf_zbee_zcl_appl_idt_ceced_spec_ver , tvb , * offset , 1 , ENC_NA ) ;
* offset += 1 ;
break ;
case ZBEE_ZCL_ATTR_ID_APPL_IDT_COMPANY_ID : proto_tree_add_item ( tree , hf_zbee_zcl_appl_idt_company_id , tvb , * offset , 2 , ENC_LITTLE_ENDIAN ) ;
* offset += 2 ;
break ;
case ZBEE_ZCL_ATTR_ID_APPL_IDT_BRAND_ID : proto_tree_add_item ( tree , hf_zbee_zcl_appl_idt_brand_id , tvb , * offset , 2 , ENC_LITTLE_ENDIAN ) ;
* offset += 2 ;
break ;
case ZBEE_ZCL_ATTR_ID_APPL_IDT_PROD_TYPE_NAME : proto_tree_add_item ( tree , hf_zbee_zcl_appl_idt_string_len , tvb , * offset , 1 , ENC_NA ) ;
* offset += 1 ;
proto_tree_add_item ( tree , hf_zbee_zcl_appl_idt_prod_type_name , tvb , * offset , 2 , ENC_BIG_ENDIAN ) ;
* offset += 2 ;
break ;
case ZBEE_ZCL_ATTR_ID_APPL_IDT_PROD_TYPE_ID : proto_tree_add_item ( tree , hf_zbee_zcl_appl_idt_prod_type_id , tvb , * offset , 2 , ENC_LITTLE_ENDIAN ) ;
* offset += 2 ;
break ;
case ZBEE_ZCL_ATTR_ID_APPL_IDT_CECED_SPEC_VER : proto_tree_add_item ( tree , hf_zbee_zcl_appl_idt_ceced_spec_ver , tvb , * offset , 1 , ENC_NA ) ;
* offset += 1 ;
break ;
default : dissect_zcl_attr_data ( tvb , tree , offset , data_type ) ;
break ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void openpic_save_IRQ_queue ( QEMUFile * f , IRQQueue * q ) {
unsigned int i ;
for ( i = 0 ;
i < ARRAY_SIZE ( q -> queue ) ;
i ++ ) {
qemu_put_be32 ( f , ( uint32_t ) q -> queue [ i ] ) ;
# if LONG_MAX > 0x7FFFFFFF qemu_put_be32 ( f , ( uint32_t ) ( q -> queue [ i ] >> 32 ) ) ;
# endif }
qemu_put_sbe32s ( f , & q -> next ) ;
qemu_put_sbe32s ( f , & q -> priority ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int auth_server_input_cookie ( struct auth_server_connection * conn , const char * const * args ) {
if ( conn -> cookie != NULL ) {
i_error ( "BUG: Authentication server already sent cookie" ) ;
return - 1 ;
}
conn -> cookie = p_strdup ( conn -> pool , args [ 0 ] ) ;
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void _InterpretPS ( IO * wrapper , EntityChar * ec , RetStack * rs ) {
SplinePointList * cur = NULL , * head = NULL ;
DBasePoint current , temp ;
int tok , i , j ;
struct psstack stack [ 100 ] ;
real dval ;
unsigned sp = 0 ;
SplinePoint * pt ;
RefChar * ref , * lastref = NULL ;
real transform [ 6 ] , t [ 6 ] ;
struct graphicsstate {
real transform [ 6 ] ;
DBasePoint current ;
real linewidth ;
int linecap , linejoin ;
Color fore ;
DashType dashes [ DASH_MAX ] ;
SplineSet * clippath ;
}
gsaves [ 30 ] ;
int gsp = 0 ;
int ccnt = 0 ;
GrowBuf gb ;
struct pskeydict dict ;
struct pskeyval * kv ;
Color fore = COLOR_INHERITED ;
int linecap = lc_inherited , linejoin = lj_inherited ;
real linewidth = WIDTH_INHERITED ;
DashType dashes [ DASH_MAX ] ;
int dash_offset = 0 ;
Entity * ent ;
int warned = 0 ;
struct garbage tofrees ;
SplineSet * clippath = NULL ;
char * tokbuf ;
const int tokbufsize = 2 * 65536 + 10 ;
tokbuf = malloc ( tokbufsize ) ;
locale_t tmplocale ;
locale_t oldlocale ;
switch_to_c_locale ( & tmplocale , & oldlocale ) ;
memset ( & gb , '\0' , sizeof ( GrowBuf ) ) ;
memset ( & dict , '\0' , sizeof ( dict ) ) ;
tofrees . cnt = 0 ;
tofrees . next = NULL ;
transform [ 0 ] = transform [ 3 ] = 1.0 ;
transform [ 1 ] = transform [ 2 ] = transform [ 4 ] = transform [ 5 ] = 0 ;
current . x = current . y = 0 ;
dashes [ 0 ] = 0 ;
dashes [ 1 ] = DASH_INHERITED ;
if ( ec -> fromtype3 ) {
stack [ 0 ] . type = stack [ 1 ] . type = ps_num ;
stack [ 0 ] . u . val = stack [ 1 ] . u . val = 0 ;
sp = 2 ;
}
while ( ( tok = nextpstoken ( wrapper , & dval , tokbuf , tokbufsize ) ) != pt_eof ) {
if ( endedstopped ( wrapper ) ) {
if ( sp < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
stack [ sp ] . type = ps_bool ;
stack [ sp ++ ] . u . tf = false ;
}
}
if ( sp > sizeof ( stack ) / sizeof ( stack [ 0 ] ) * 4 / 5 ) {
sp = forgetstack ( stack , sizeof ( stack ) / sizeof ( stack [ 0 ] ) / 3 , sp ) ;
}
if ( ccnt > 0 ) {
if ( tok == pt_closecurly ) -- ccnt ;
else if ( tok == pt_opencurly ) ++ ccnt ;
if ( ccnt > 0 ) AddTok ( & gb , tokbuf , tok == pt_namelit ) ;
else {
if ( sp < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
stack [ sp ] . type = ps_instr ;
if ( gb . pt == NULL ) stack [ sp ++ ] . u . str = copy ( "" ) ;
else {
* gb . pt = '\0' ;
gb . pt = gb . base ;
stack [ sp ++ ] . u . str = copy ( ( char * ) gb . base ) ;
}
}
}
}
else if ( tok == pt_unknown && ( kv = lookup ( & dict , tokbuf ) ) != NULL ) {
if ( kv -> type == ps_instr ) pushio ( wrapper , NULL , copy ( kv -> u . str ) , 0 ) ;
else if ( sp < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
stack [ sp ] . type = kv -> type ;
stack [ sp ++ ] . u = kv -> u ;
if ( kv -> type == ps_instr || kv -> type == ps_lit || kv -> type == ps_string ) stack [ sp - 1 ] . u . str = copy ( stack [ sp - 1 ] . u . str ) ;
else if ( kv -> type == ps_array || kv -> type == ps_dict ) {
copyarray ( & stack [ sp - 1 ] . u . dict , & stack [ sp - 1 ] . u . dict , & tofrees ) ;
if ( stack [ sp - 1 ] . u . dict . is_executable ) sp = aload ( sp , stack , sizeof ( stack ) / sizeof ( stack [ 0 ] ) , & tofrees ) ;
}
}
}
else {
if ( tok == pt_unknown ) {
if ( strcmp ( tokbuf , "Cache" ) == 0 ) tok = pt_setcachedevice ;
else if ( strcmp ( tokbuf , "SetWid" ) == 0 ) {
tok = pt_setcharwidth ;
if ( sp < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
stack [ sp ] . type = ps_num ;
stack [ sp ++ ] . u . val = 0 ;
}
}
else if ( strcmp ( tokbuf , "rrcurveto" ) == 0 ) {
if ( sp >= 6 ) {
stack [ sp - 4 ] . u . val += stack [ sp - 6 ] . u . val ;
stack [ sp - 3 ] . u . val += stack [ sp - 5 ] . u . val ;
stack [ sp - 2 ] . u . val += stack [ sp - 4 ] . u . val ;
stack [ sp - 1 ] . u . val += stack [ sp - 3 ] . u . val ;
tok = pt_rcurveto ;
}
}
else if ( strcmp ( tokbuf , "FillStroke" ) == 0 ) {
if ( sp > 0 ) -- sp ;
tok = linewidth != WIDTH_INHERITED ? pt_stroke : pt_fill ;
if ( wrapper -> top != NULL && wrapper -> top -> ps != NULL && linewidth != WIDTH_INHERITED ) linewidth /= 10.0 ;
}
else if ( strcmp ( tokbuf , "SG" ) == 0 ) {
if ( linewidth != WIDTH_INHERITED && sp > 1 ) stack [ sp - 2 ] . u . val = stack [ sp - 1 ] . u . val ;
if ( sp > 0 ) -- sp ;
if ( sp > 0 ) stack [ sp - 1 ] . u . val = ( stack [ sp - 1 ] . u . val + 99 ) / 198.0 ;
tok = pt_setgray ;
}
else if ( strcmp ( tokbuf , "ShowInt" ) == 0 ) {
if ( ( ! wrapper -> top -> fogns && sp > 0 && stack [ sp - 1 ] . type == ps_num && stack [ sp - 1 ] . u . val >= 0 && stack [ sp - 1 ] . u . val <= 255 ) || ( wrapper -> top -> fogns && sp > 6 && stack [ sp - 7 ] . type == ps_num && stack [ sp - 7 ] . u . val >= 0 && stack [ sp - 7 ] . u . val <= 255 ) ) {
ref = RefCharCreate ( ) ;
memcpy ( ref -> transform , transform , sizeof ( ref -> transform ) ) ;
if ( wrapper -> top -> fogns ) {
sp -= 6 ;
t [ 0 ] = stack [ sp + 0 ] . u . val ;
t [ 1 ] = stack [ sp + 1 ] . u . val ;
t [ 2 ] = stack [ sp + 2 ] . u . val ;
t [ 3 ] = stack [ sp + 3 ] . u . val ;
t [ 4 ] = stack [ sp + 4 ] . u . val ;
t [ 5 ] = stack [ sp + 5 ] . u . val ;
MatMultiply ( t , ref -> transform , ref -> transform ) ;
wrapper -> top -> fogns = false ;
}
ref -> orig_pos = stack [ -- sp ] . u . val ;
ref -> next = ec -> refs ;
ec -> refs = ref ;
continue ;
}
}
else if ( strcmp ( tokbuf , "togNS_" ) == 0 ) {
wrapper -> top -> fogns = ! wrapper -> top -> fogns ;
continue ;
}
}
switch ( tok ) {
case pt_number : if ( sp < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
stack [ sp ] . type = ps_num ;
stack [ sp ++ ] . u . val = dval ;
}
break ;
case pt_string : if ( sp < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
stack [ sp ] . type = ps_string ;
stack [ sp ++ ] . u . str = copyn ( tokbuf + 1 , strlen ( tokbuf ) - 2 ) ;
}
break ;
case pt_true : case pt_false : if ( sp < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
stack [ sp ] . type = ps_bool ;
stack [ sp ++ ] . u . tf = tok == pt_true ;
}
break ;
case pt_opencurly : ++ ccnt ;
break ;
case pt_closecurly : -- ccnt ;
if ( ccnt < 0 ) {
goto done ;
}
break ;
case pt_count : if ( sp < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
stack [ sp ] . type = ps_num ;
stack [ sp ] . u . val = sp ;
++ sp ;
}
break ;
case pt_pop : if ( sp > 0 ) {
-- sp ;
if ( stack [ sp ] . type == ps_string || stack [ sp ] . type == ps_instr || stack [ sp ] . type == ps_lit ) free ( stack [ sp ] . u . str ) ;
else if ( stack [ sp ] . type == ps_array || stack [ sp ] . type == ps_dict ) dictfree ( & stack [ sp ] . u . dict ) ;
}
break ;
case pt_clear : while ( sp > 0 ) {
-- sp ;
if ( stack [ sp ] . type == ps_string || stack [ sp ] . type == ps_instr || stack [ sp ] . type == ps_lit ) free ( stack [ sp ] . u . str ) ;
else if ( stack [ sp ] . type == ps_array || stack [ sp ] . type == ps_dict ) dictfree ( & stack [ sp ] . u . dict ) ;
}
break ;
case pt_dup : if ( sp > 0 && sp < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
stack [ sp ] = stack [ sp - 1 ] ;
if ( stack [ sp ] . type == ps_string || stack [ sp ] . type == ps_instr || stack [ sp ] . type == ps_lit ) stack [ sp ] . u . str = copy ( stack [ sp ] . u . str ) ;
else if ( stack [ sp ] . type == ps_array ) copyarray ( & stack [ sp ] . u . dict , & stack [ sp ] . u . dict , & tofrees ) ;
++ sp ;
}
break ;
case pt_copy : if ( sp > 0 ) {
int n = stack [ -- sp ] . u . val ;
if ( n + sp < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
int i ;
for ( i = 0 ;
i < n ;
++ i ) {
stack [ sp ] = stack [ sp - n ] ;
if ( stack [ sp ] . type == ps_string || stack [ sp ] . type == ps_instr || stack [ sp ] . type == ps_lit ) stack [ sp ] . u . str = copy ( stack [ sp ] . u . str ) ;
else if ( stack [ sp ] . type == ps_array ) copyarray ( & stack [ sp ] . u . dict , & stack [ sp ] . u . dict , & tofrees ) ;
++ sp ;
}
}
}
break ;
case pt_exch : if ( sp > 1 ) {
struct psstack temp ;
temp = stack [ sp - 1 ] ;
stack [ sp - 1 ] = stack [ sp - 2 ] ;
stack [ sp - 2 ] = temp ;
}
break ;
case pt_roll : sp = rollstack ( stack , sp ) ;
break ;
case pt_index : if ( sp > 0 ) {
i = stack [ -- sp ] . u . val ;
if ( i >= 0 && sp > ( unsigned ) i ) {
stack [ sp ] = stack [ sp - i - 1 ] ;
if ( stack [ sp ] . type == ps_string || stack [ sp ] . type == ps_instr || stack [ sp ] . type == ps_lit ) stack [ sp ] . u . str = copy ( stack [ sp ] . u . str ) ;
else if ( stack [ sp ] . type == ps_array ) copyarray ( & stack [ sp ] . u . dict , & stack [ sp ] . u . dict , & tofrees ) ;
++ sp ;
}
}
break ;
case pt_add : if ( sp >= 2 && stack [ sp - 1 ] . type == ps_num && stack [ sp - 2 ] . type == ps_num ) {
stack [ sp - 2 ] . u . val += stack [ sp - 1 ] . u . val ;
-- sp ;
}
break ;
case pt_sub : if ( sp >= 2 && stack [ sp - 1 ] . type == ps_num && stack [ sp - 2 ] . type == ps_num ) {
stack [ sp - 2 ] . u . val -= stack [ sp - 1 ] . u . val ;
-- sp ;
}
break ;
case pt_mul : if ( sp >= 2 && stack [ sp - 1 ] . type == ps_num && stack [ sp - 2 ] . type == ps_num ) {
stack [ sp - 2 ] . u . val *= stack [ sp - 1 ] . u . val ;
-- sp ;
}
break ;
case pt_div : if ( sp >= 2 && stack [ sp - 1 ] . type == ps_num && stack [ sp - 2 ] . type == ps_num ) {
if ( stack [ sp - 1 ] . u . val == 0 ) LogError ( _ ( "Divide by zero in postscript code.\n" ) ) ;
else stack [ sp - 2 ] . u . val /= stack [ sp - 1 ] . u . val ;
-- sp ;
}
break ;
case pt_idiv : if ( sp >= 2 && stack [ sp - 1 ] . type == ps_num && stack [ sp - 2 ] . type == ps_num ) {
if ( stack [ sp - 1 ] . u . val == 0 ) LogError ( _ ( "Divide by zero in postscript code.\n" ) ) ;
else stack [ sp - 2 ] . u . val = ( ( int ) stack [ sp - 2 ] . u . val ) / ( ( int ) stack [ sp - 1 ] . u . val ) ;
-- sp ;
}
break ;
case pt_mod : if ( sp >= 2 && stack [ sp - 1 ] . type == ps_num && stack [ sp - 2 ] . type == ps_num ) {
if ( stack [ sp - 1 ] . u . val == 0 ) LogError ( _ ( "Divide by zero in postscript code.\n" ) ) ;
else stack [ sp - 2 ] . u . val = ( ( int ) stack [ sp - 2 ] . u . val ) % ( ( int ) stack [ sp - 1 ] . u . val ) ;
-- sp ;
}
break ;
case pt_max : if ( sp >= 2 && stack [ sp - 1 ] . type == ps_num && stack [ sp - 2 ] . type == ps_num ) {
if ( stack [ sp - 2 ] . u . val < stack [ sp - 1 ] . u . val ) stack [ sp - 2 ] . u . val = stack [ sp - 1 ] . u . val ;
-- sp ;
}
break ;
case pt_min : if ( sp >= 2 && stack [ sp - 1 ] . type == ps_num && stack [ sp - 2 ] . type == ps_num ) {
if ( stack [ sp - 2 ] . u . val > stack [ sp - 1 ] . u . val ) stack [ sp - 2 ] . u . val = stack [ sp - 1 ] . u . val ;
-- sp ;
}
break ;
case pt_neg : if ( sp >= 1 ) {
if ( stack [ sp - 1 ] . type == ps_num ) stack [ sp - 1 ] . u . val = - stack [ sp - 1 ] . u . val ;
}
break ;
case pt_abs : if ( sp >= 1 ) {
if ( stack [ sp - 1 ] . type == ps_num ) if ( stack [ sp - 1 ] . u . val < 0 ) stack [ sp - 1 ] . u . val = - stack [ sp - 1 ] . u . val ;
}
break ;
case pt_round : if ( sp >= 1 ) {
if ( stack [ sp - 1 ] . type == ps_num ) stack [ sp - 1 ] . u . val = rint ( stack [ sp - 1 ] . u . val ) ;
}
break ;
case pt_floor : if ( sp >= 1 ) {
if ( stack [ sp - 1 ] . type == ps_num ) stack [ sp - 1 ] . u . val = floor ( stack [ sp - 1 ] . u . val ) ;
}
break ;
case pt_ceiling : if ( sp >= 1 ) {
if ( stack [ sp - 1 ] . type == ps_num ) stack [ sp - 1 ] . u . val = ceil ( stack [ sp - 1 ] . u . val ) ;
}
break ;
case pt_truncate : if ( sp >= 1 ) {
if ( stack [ sp - 1 ] . type == ps_num ) {
if ( stack [ sp - 1 ] . u . val < 0 ) stack [ sp - 1 ] . u . val = ceil ( stack [ sp - 1 ] . u . val ) ;
else stack [ sp - 1 ] . u . val = floor ( stack [ sp - 1 ] . u . val ) ;
}
}
break ;
case pt_ne : case pt_eq : if ( sp >= 2 ) {
if ( stack [ sp - 2 ] . type != stack [ sp - 1 ] . type ) stack [ sp - 2 ] . u . tf = false ;
else if ( stack [ sp - 2 ] . type == ps_num ) stack [ sp - 2 ] . u . tf = ( stack [ sp - 2 ] . u . val == stack [ sp - 1 ] . u . val ) ;
else if ( stack [ sp - 2 ] . type == ps_bool ) stack [ sp - 2 ] . u . tf = ( stack [ sp - 2 ] . u . tf == stack [ sp - 1 ] . u . tf ) ;
else stack [ sp - 2 ] . u . tf = strcmp ( stack [ sp - 2 ] . u . str , stack [ sp - 1 ] . u . str ) == 0 ;
stack [ sp - 2 ] . type = ps_bool ;
if ( tok == pt_ne ) stack [ sp - 2 ] . u . tf = ! stack [ sp - 2 ] . u . tf ;
-- sp ;
}
break ;
case pt_gt : case pt_le : case pt_lt : case pt_ge : if ( sp >= 2 ) {
if ( stack [ sp - 2 ] . type != stack [ sp - 1 ] . type ) stack [ sp - 2 ] . u . tf = false ;
else if ( stack [ sp - 2 ] . type == ps_array ) LogError ( _ ( "Can't compare arrays\n" ) ) ;
else {
int cmp ;
if ( stack [ sp - 2 ] . type == ps_num ) cmp = ( stack [ sp - 2 ] . u . val > stack [ sp - 1 ] . u . val ) ? 1 : ( stack [ sp - 2 ] . u . val == stack [ sp - 1 ] . u . val ) ? 0 : - 1 ;
else if ( stack [ sp - 2 ] . type == ps_bool ) cmp = ( stack [ sp - 2 ] . u . tf - stack [ sp - 1 ] . u . tf ) ;
else cmp = strcmp ( stack [ sp - 2 ] . u . str , stack [ sp - 1 ] . u . str ) ;
if ( tok == pt_gt ) stack [ sp - 2 ] . u . tf = cmp > 0 ;
else if ( tok == pt_lt ) stack [ sp - 2 ] . u . tf = cmp < 0 ;
else if ( tok == pt_le ) stack [ sp - 2 ] . u . tf = cmp <= 0 ;
else stack [ sp - 2 ] . u . tf = cmp >= 0 ;
}
stack [ sp - 2 ] . type = ps_bool ;
-- sp ;
}
break ;
case pt_not : if ( sp >= 1 ) {
if ( stack [ sp - 1 ] . type == ps_bool ) stack [ sp - 1 ] . u . tf = ! stack [ sp - 1 ] . u . tf ;
}
break ;
case pt_and : if ( sp >= 2 ) {
if ( stack [ sp - 2 ] . type == ps_num ) stack [ sp - 2 ] . u . val = ( ( int ) stack [ sp - 2 ] . u . val ) & ( int ) stack [ sp - 1 ] . u . val ;
else if ( stack [ sp - 2 ] . type == ps_bool ) stack [ sp - 2 ] . u . tf &= stack [ sp - 1 ] . u . tf ;
-- sp ;
}
break ;
case pt_or : if ( sp >= 2 ) {
if ( stack [ sp - 2 ] . type == ps_num ) stack [ sp - 2 ] . u . val = ( ( int ) stack [ sp - 2 ] . u . val ) | ( int ) stack [ sp - 1 ] . u . val ;
else if ( stack [ sp - 2 ] . type == ps_bool ) stack [ sp - 2 ] . u . tf |= stack [ sp - 1 ] . u . tf ;
-- sp ;
}
break ;
case pt_xor : if ( sp >= 2 ) {
if ( stack [ sp - 2 ] . type == ps_num ) stack [ sp - 2 ] . u . val = ( ( int ) stack [ sp - 2 ] . u . val ) ^ ( int ) stack [ sp - 1 ] . u . val ;
else if ( stack [ sp - 2 ] . type == ps_bool ) stack [ sp - 2 ] . u . tf ^= stack [ sp - 1 ] . u . tf ;
-- sp ;
}
break ;
case pt_exp : if ( sp >= 2 && stack [ sp - 1 ] . type == ps_num && stack [ sp - 2 ] . type == ps_num ) {
stack [ sp - 2 ] . u . val = pow ( stack [ sp - 2 ] . u . val , stack [ sp - 1 ] . u . val ) ;
-- sp ;
}
break ;
case pt_sqrt : if ( sp >= 1 && stack [ sp - 1 ] . type == ps_num ) {
stack [ sp - 1 ] . u . val = sqrt ( stack [ sp - 1 ] . u . val ) ;
}
break ;
case pt_ln : if ( sp >= 1 && stack [ sp - 1 ] . type == ps_num ) {
stack [ sp - 1 ] . u . val = log ( stack [ sp - 1 ] . u . val ) ;
}
break ;
case pt_log : if ( sp >= 1 && stack [ sp - 1 ] . type == ps_num ) {
stack [ sp - 1 ] . u . val = log10 ( stack [ sp - 1 ] . u . val ) ;
}
break ;
case pt_atan : if ( sp >= 2 && stack [ sp - 1 ] . type == ps_num && stack [ sp - 2 ] . type == ps_num ) {
stack [ sp - 2 ] . u . val = atan2 ( stack [ sp - 2 ] . u . val , stack [ sp - 1 ] . u . val ) * 180 / 3.1415926535897932 ;
-- sp ;
}
break ;
case pt_sin : if ( sp >= 1 && stack [ sp - 1 ] . type == ps_num ) {
stack [ sp - 1 ] . u . val = sin ( stack [ sp - 1 ] . u . val * 3.1415926535897932 / 180 ) ;
}
break ;
case pt_cos : if ( sp >= 1 && stack [ sp - 1 ] . type == ps_num ) {
stack [ sp - 1 ] . u . val = cos ( stack [ sp - 1 ] . u . val * 3.1415926535897932 / 180 ) ;
}
break ;
case pt_if : if ( sp >= 2 ) {
if ( ( ( stack [ sp - 2 ] . type == ps_bool && stack [ sp - 2 ] . u . tf ) || ( stack [ sp - 2 ] . type == ps_num && strstr ( stack [ sp - 1 ] . u . str , "setcachedevice" ) != NULL ) ) && stack [ sp - 1 ] . type == ps_instr ) pushio ( wrapper , NULL , stack [ sp - 1 ] . u . str , 0 ) ;
if ( stack [ sp - 1 ] . type == ps_string || stack [ sp - 1 ] . type == ps_instr || stack [ sp - 1 ] . type == ps_lit ) free ( stack [ sp - 1 ] . u . str ) ;
sp -= 2 ;
}
else if ( sp == 1 && stack [ sp - 1 ] . type == ps_instr ) {
if ( strstr ( stack [ sp - 1 ] . u . str , "setcachedevice" ) != NULL || strstr ( stack [ sp - 1 ] . u . str , "setcharwidth" ) != NULL ) pushio ( wrapper , NULL , stack [ sp - 1 ] . u . str , 0 ) ;
free ( stack [ sp - 1 ] . u . str ) ;
sp = 0 ;
}
break ;
case pt_ifelse : if ( sp >= 3 ) {
if ( stack [ sp - 3 ] . type == ps_bool && stack [ sp - 3 ] . u . tf ) {
if ( stack [ sp - 2 ] . type == ps_instr ) pushio ( wrapper , NULL , stack [ sp - 2 ] . u . str , 0 ) ;
}
else {
if ( stack [ sp - 1 ] . type == ps_instr ) pushio ( wrapper , NULL , stack [ sp - 1 ] . u . str , 0 ) ;
}
if ( stack [ sp - 1 ] . type == ps_string || stack [ sp - 1 ] . type == ps_instr || stack [ sp - 1 ] . type == ps_lit ) free ( stack [ sp - 1 ] . u . str ) ;
if ( stack [ sp - 2 ] . type == ps_string || stack [ sp - 2 ] . type == ps_instr || stack [ sp - 2 ] . type == ps_lit ) free ( stack [ sp - 2 ] . u . str ) ;
sp -= 3 ;
}
break ;
case pt_for : if ( sp >= 4 ) {
real init , incr , limit ;
char * func ;
int cnt ;
if ( stack [ sp - 4 ] . type == ps_num && stack [ sp - 3 ] . type == ps_num && stack [ sp - 2 ] . type == ps_num && stack [ sp - 1 ] . type == ps_instr ) {
init = stack [ sp - 4 ] . u . val ;
incr = stack [ sp - 3 ] . u . val ;
limit = stack [ sp - 2 ] . u . val ;
func = stack [ sp - 1 ] . u . str ;
sp -= 4 ;
cnt = 0 ;
if ( incr > 0 ) {
while ( init <= limit ) {
++ cnt ;
init += incr ;
}
}
else if ( incr < 0 ) {
while ( init >= limit ) {
++ cnt ;
init += incr ;
}
}
pushio ( wrapper , NULL , func , cnt ) ;
free ( func ) ;
}
}
break ;
case pt_loop : if ( sp >= 1 ) {
char * func ;
int cnt ;
if ( stack [ sp - 1 ] . type == ps_instr ) {
cnt = 0x7fffffff ;
func = stack [ sp - 1 ] . u . str ;
-- sp ;
pushio ( wrapper , NULL , func , cnt ) ;
free ( func ) ;
}
}
break ;
case pt_repeat : if ( sp >= 2 ) {
char * func ;
int cnt ;
if ( stack [ sp - 2 ] . type == ps_num && stack [ sp - 1 ] . type == ps_instr ) {
cnt = stack [ sp - 2 ] . u . val ;
func = stack [ sp - 1 ] . u . str ;
sp -= 2 ;
pushio ( wrapper , NULL , func , cnt ) ;
free ( func ) ;
}
}
break ;
case pt_exit : ioescapeloop ( wrapper ) ;
break ;
case pt_stopped : if ( sp >= 1 ) {
char * func ;
if ( stack [ sp - 1 ] . type == ps_instr ) {
func = stack [ sp - 1 ] . u . str ;
-- sp ;
pushio ( wrapper , NULL , func , - 1 ) ;
free ( func ) ;
}
}
break ;
case pt_stop : sp = ioescapestopped ( wrapper , stack , sp , sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) ;
break ;
case pt_load : if ( sp >= 1 && stack [ sp - 1 ] . type == ps_lit ) {
kv = lookup ( & dict , stack [ sp - 1 ] . u . str ) ;
if ( kv != NULL ) {
free ( stack [ sp - 1 ] . u . str ) ;
stack [ sp - 1 ] . type = kv -> type ;
stack [ sp - 1 ] . u = kv -> u ;
if ( kv -> type == ps_instr || kv -> type == ps_lit ) stack [ sp - 1 ] . u . str = copy ( stack [ sp - 1 ] . u . str ) ;
}
else stack [ sp - 1 ] . type = ps_instr ;
}
break ;
case pt_def : sp = AddEntry ( & dict , stack , sp ) ;
break ;
case pt_bind : break ;
case pt_setcachedevice : if ( sp >= 6 ) {
ec -> width = stack [ sp - 6 ] . u . val ;
ec -> vwidth = stack [ sp - 5 ] . u . val ;
sp -= 6 ;
}
break ;
case pt_setcharwidth : if ( sp >= 2 ) ec -> width = stack [ sp -= 2 ] . u . val ;
break ;
case pt_translate : if ( sp >= 1 && stack [ sp - 1 ] . type == ps_array ) sp = DoMatOp ( tok , sp , stack ) ;
else if ( sp >= 2 ) {
transform [ 4 ] += stack [ sp - 2 ] . u . val * transform [ 0 ] + stack [ sp - 1 ] . u . val * transform [ 2 ] ;
transform [ 5 ] += stack [ sp - 2 ] . u . val * transform [ 1 ] + stack [ sp - 1 ] . u . val * transform [ 3 ] ;
sp -= 2 ;
}
break ;
case pt_scale : if ( sp >= 1 && stack [ sp - 1 ] . type == ps_array ) sp = DoMatOp ( tok , sp , stack ) ;
else if ( sp >= 2 ) {
transform [ 0 ] *= stack [ sp - 2 ] . u . val ;
transform [ 1 ] *= stack [ sp - 2 ] . u . val ;
transform [ 2 ] *= stack [ sp - 1 ] . u . val ;
transform [ 3 ] *= stack [ sp - 1 ] . u . val ;
sp -= 2 ;
}
break ;
case pt_rotate : if ( sp >= 1 && stack [ sp - 1 ] . type == ps_array ) sp = DoMatOp ( tok , sp , stack ) ;
else if ( sp >= 1 ) {
-- sp ;
t [ 0 ] = t [ 3 ] = cos ( stack [ sp ] . u . val ) ;
t [ 1 ] = sin ( stack [ sp ] . u . val ) ;
t [ 2 ] = - t [ 1 ] ;
t [ 4 ] = t [ 5 ] = 0 ;
MatMultiply ( t , transform , transform ) ;
}
break ;
case pt_concat : if ( sp >= 1 ) {
if ( stack [ sp - 1 ] . type == ps_array ) {
if ( stack [ sp - 1 ] . u . dict . cnt == 6 && stack [ sp - 1 ] . u . dict . entries [ 0 ] . type == ps_num ) {
-- sp ;
t [ 5 ] = stack [ sp ] . u . dict . entries [ 5 ] . u . val ;
t [ 4 ] = stack [ sp ] . u . dict . entries [ 4 ] . u . val ;
t [ 3 ] = stack [ sp ] . u . dict . entries [ 3 ] . u . val ;
t [ 2 ] = stack [ sp ] . u . dict . entries [ 2 ] . u . val ;
t [ 1 ] = stack [ sp ] . u . dict . entries [ 1 ] . u . val ;
t [ 0 ] = stack [ sp ] . u . dict . entries [ 0 ] . u . val ;
dictfree ( & stack [ sp ] . u . dict ) ;
MatMultiply ( t , transform , transform ) ;
}
}
}
break ;
case pt_transform : if ( sp >= 1 && stack [ sp - 1 ] . type == ps_array ) {
if ( sp >= 3 ) {
DoMatTransform ( tok , sp , stack ) ;
-- sp ;
}
}
else if ( sp >= 2 ) {
double x = stack [ sp - 2 ] . u . val , y = stack [ sp - 1 ] . u . val ;
stack [ sp - 2 ] . u . val = transform [ 0 ] * x + transform [ 1 ] * y + transform [ 4 ] ;
stack [ sp - 1 ] . u . val = transform [ 2 ] * x + transform [ 3 ] * y + transform [ 5 ] ;
}
break ;
case pt_itransform : if ( sp >= 1 && stack [ sp - 1 ] . type == ps_array ) {
if ( sp >= 3 ) {
DoMatTransform ( tok , sp , stack ) ;
-- sp ;
}
}
else if ( sp >= 2 ) {
double x = stack [ sp - 2 ] . u . val , y = stack [ sp - 1 ] . u . val ;
MatInverse ( t , transform ) ;
stack [ sp - 2 ] . u . val = t [ 0 ] * x + t [ 1 ] * y + t [ 4 ] ;
stack [ sp - 1 ] . u . val = t [ 2 ] * x + t [ 3 ] * y + t [ 5 ] ;
}
break ;
case pt_dtransform : if ( sp >= 1 && stack [ sp - 1 ] . type == ps_array ) {
if ( sp >= 3 ) {
DoMatTransform ( tok , sp , stack ) ;
-- sp ;
}
}
else if ( sp >= 2 ) {
double x = stack [ sp - 2 ] . u . val , y = stack [ sp - 1 ] . u . val ;
stack [ sp - 2 ] . u . val = transform [ 0 ] * x + transform [ 1 ] * y ;
stack [ sp - 1 ] . u . val = transform [ 2 ] * x + transform [ 3 ] * y ;
}
break ;
case pt_idtransform : if ( sp >= 1 && stack [ sp - 1 ] . type == ps_array ) {
if ( sp >= 3 ) {
DoMatTransform ( tok , sp , stack ) ;
-- sp ;
}
}
else if ( sp >= 2 ) {
double x = stack [ sp - 2 ] . u . val , y = stack [ sp - 1 ] . u . val ;
MatInverse ( t , transform ) ;
stack [ sp - 2 ] . u . val = t [ 0 ] * x + t [ 1 ] * y ;
stack [ sp - 1 ] . u . val = t [ 2 ] * x + t [ 3 ] * y ;
}
break ;
case pt_namelit : if ( strcmp ( tokbuf , "CharProcs" ) == 0 && ec != NULL ) {
HandleType3Reference ( wrapper , ec , transform , tokbuf , tokbufsize ) ;
}
else if ( sp < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
stack [ sp ] . type = ps_lit ;
stack [ sp ++ ] . u . str = copy ( tokbuf ) ;
}
break ;
case pt_exec : if ( sp > 0 && stack [ sp - 1 ] . type == ps_lit ) {
ref = RefCharCreate ( ) ;
ref -> sc = ( SplineChar * ) stack [ -- sp ] . u . str ;
memcpy ( ref -> transform , transform , sizeof ( transform ) ) ;
if ( ec -> refs == NULL ) ec -> refs = ref ;
else lastref -> next = ref ;
lastref = ref ;
}
break ;
case pt_newpath : SplinePointListsFree ( head ) ;
head = NULL ;
cur = NULL ;
break ;
case pt_lineto : case pt_rlineto : case pt_moveto : case pt_rmoveto : if ( sp >= 2 || tok == pt_newpath ) {
if ( tok == pt_rlineto || tok == pt_rmoveto ) {
current . x += stack [ sp - 2 ] . u . val ;
current . y += stack [ sp - 1 ] . u . val ;
sp -= 2 ;
}
else if ( tok == pt_lineto || tok == pt_moveto ) {
current . x = stack [ sp - 2 ] . u . val ;
current . y = stack [ sp - 1 ] . u . val ;
sp -= 2 ;
}
pt = chunkalloc ( sizeof ( SplinePoint ) ) ;
Transform ( & pt -> me , & current , transform ) ;
pt -> noprevcp = true ;
pt -> nonextcp = true ;
if ( tok == pt_moveto || tok == pt_rmoveto ) {
SplinePointList * spl = chunkalloc ( sizeof ( SplinePointList ) ) ;
spl -> first = spl -> last = pt ;
if ( cur != NULL ) cur -> next = spl ;
else head = spl ;
cur = spl ;
}
else {
if ( cur != NULL && cur -> first != NULL && ( cur -> first != cur -> last || cur -> first -> next == NULL ) ) {
CheckMake ( cur -> last , pt ) ;
SplineMake3 ( cur -> last , pt ) ;
cur -> last = pt ;
}
}
}
else sp = 0 ;
break ;
case pt_curveto : case pt_rcurveto : if ( sp >= 6 ) {
if ( tok == pt_rcurveto ) {
stack [ sp - 1 ] . u . val += current . y ;
stack [ sp - 3 ] . u . val += current . y ;
stack [ sp - 5 ] . u . val += current . y ;
stack [ sp - 2 ] . u . val += current . x ;
stack [ sp - 4 ] . u . val += current . x ;
stack [ sp - 6 ] . u . val += current . x ;
}
current . x = stack [ sp - 2 ] . u . val ;
current . y = stack [ sp - 1 ] . u . val ;
if ( cur != NULL && cur -> first != NULL && ( cur -> first != cur -> last || cur -> first -> next == NULL ) ) {
temp . x = stack [ sp - 6 ] . u . val ;
temp . y = stack [ sp - 5 ] . u . val ;
Transform ( & cur -> last -> nextcp , & temp , transform ) ;
cur -> last -> nonextcp = false ;
pt = chunkalloc ( sizeof ( SplinePoint ) ) ;
temp . x = stack [ sp - 4 ] . u . val ;
temp . y = stack [ sp - 3 ] . u . val ;
Transform ( & pt -> prevcp , & temp , transform ) ;
Transform ( & pt -> me , & current , transform ) ;
pt -> nonextcp = true ;
CheckMake ( cur -> last , pt ) ;
SplineMake3 ( cur -> last , pt ) ;
cur -> last = pt ;
}
sp -= 6 ;
}
else sp = 0 ;
break ;
case pt_arc : case pt_arcn : if ( sp >= 5 ) {
real cx , cy , r , a1 , a2 ;
cx = stack [ sp - 5 ] . u . val ;
cy = stack [ sp - 4 ] . u . val ;
r = stack [ sp - 3 ] . u . val ;
a1 = stack [ sp - 2 ] . u . val ;
a2 = stack [ sp - 1 ] . u . val ;
sp -= 5 ;
temp . x = cx + r * cos ( a1 / 180 * 3.1415926535897932 ) ;
temp . y = cy + r * sin ( a1 / 180 * 3.1415926535897932 ) ;
if ( temp . x != current . x || temp . y != current . y || ! ( cur != NULL && cur -> first != NULL && ( cur -> first != cur -> last || cur -> first -> next == NULL ) ) ) {
pt = chunkalloc ( sizeof ( SplinePoint ) ) ;
Transform ( & pt -> me , & temp , transform ) ;
pt -> noprevcp = true ;
pt -> nonextcp = true ;
if ( cur != NULL && cur -> first != NULL && ( cur -> first != cur -> last || cur -> first -> next == NULL ) ) {
CheckMake ( cur -> last , pt ) ;
SplineMake3 ( cur -> last , pt ) ;
cur -> last = pt ;
}
else {
SplinePointList * spl = chunkalloc ( sizeof ( SplinePointList ) ) ;
spl -> first = spl -> last = pt ;
if ( cur != NULL ) cur -> next = spl ;
else head = spl ;
cur = spl ;
}
}
circlearcsto ( a1 , a2 , cx , cy , r , cur , transform , tok == pt_arcn ) ;
current . x = cx + r * cos ( a2 / 180 * 3.1415926535897932 ) ;
current . y = cy + r * sin ( a2 / 180 * 3.1415926535897932 ) ;
}
else sp = 0 ;
break ;
case pt_arct : case pt_arcto : if ( sp >= 5 ) {
real x1 , y1 , x2 , y2 , r ;
real xt1 , xt2 , yt1 , yt2 ;
x1 = stack [ sp - 5 ] . u . val ;
y1 = stack [ sp - 4 ] . u . val ;
x2 = stack [ sp - 3 ] . u . val ;
y2 = stack [ sp - 2 ] . u . val ;
r = stack [ sp - 1 ] . u . val ;
sp -= 5 ;
xt1 = xt2 = x1 ;
yt1 = yt2 = y1 ;
if ( cur == NULL || cur -> first == NULL || ( cur -> first == cur -> last && cur -> first -> next != NULL ) ) ;
else if ( current . x == x1 && current . y == y1 ) ;
else if ( ( x1 == x2 && y1 == y2 ) || ( current . x - x1 ) * ( y2 - y1 ) == ( x2 - x1 ) * ( current . y - y1 ) ) {
current . x = x1 ;
current . y = y1 ;
pt = chunkalloc ( sizeof ( SplinePoint ) ) ;
Transform ( & pt -> me , & current , transform ) ;
pt -> noprevcp = true ;
pt -> nonextcp = true ;
CheckMake ( cur -> last , pt ) ;
SplineMake3 ( cur -> last , pt ) ;
cur -> last = pt ;
}
else {
real l1 = sqrt ( ( current . x - x1 ) * ( current . x - x1 ) + ( current . y - y1 ) * ( current . y - y1 ) ) ;
real l2 = sqrt ( ( x2 - x1 ) * ( x2 - x1 ) + ( y2 - y1 ) * ( y2 - y1 ) ) ;
real dx = ( ( current . x - x1 ) / l1 + ( x2 - x1 ) / l2 ) ;
real dy = ( ( current . y - y1 ) / l1 + ( y2 - y1 ) / l2 ) ;
real l3 = sqrt ( dx * dx + dy * dy ) ;
real cx , cy , t , tmid ;
real a1 , amid , a2 ;
int clockwise = true ;
dx /= l3 ;
dy /= l3 ;
a1 = atan2 ( current . y - y1 , current . x - x1 ) ;
a2 = atan2 ( y2 - y1 , x2 - x1 ) ;
amid = atan2 ( dy , dx ) - a1 ;
tmid = r / sin ( amid ) ;
t = r / tan ( amid ) ;
if ( t < 0 ) {
clockwise = false ;
t = - t ;
tmid = - tmid ;
}
cx = x1 + tmid * dx ;
cy = y1 + tmid * dy ;
xt1 = x1 + t * ( current . x - x1 ) / l1 ;
yt1 = y1 + t * ( current . y - y1 ) / l1 ;
xt2 = x1 + t * ( x2 - x1 ) / l2 ;
yt2 = y1 + t * ( y2 - y1 ) / l2 ;
if ( xt1 != current . x || yt1 != current . y ) {
DBasePoint temp ;
temp . x = xt1 ;
temp . y = yt1 ;
pt = chunkalloc ( sizeof ( SplinePoint ) ) ;
Transform ( & pt -> me , & temp , transform ) ;
pt -> noprevcp = true ;
pt -> nonextcp = true ;
CheckMake ( cur -> last , pt ) ;
SplineMake3 ( cur -> last , pt ) ;
cur -> last = pt ;
}
a1 = 3 * 3.1415926535897932 / 2 + a1 ;
a2 = 3.1415926535897932 / 2 + a2 ;
if ( ! clockwise ) {
a1 += 3.1415926535897932 ;
a2 += 3.1415926535897932 ;
}
circlearcsto ( a1 * 180 / 3.1415926535897932 , a2 * 180 / 3.1415926535897932 , cx , cy , r , cur , transform , clockwise ) ;
}
if ( tok == pt_arcto ) {
stack [ sp ] . type = stack [ sp + 1 ] . type = stack [ sp + 2 ] . type = stack [ sp + 3 ] . type = ps_num ;
stack [ sp ++ ] . u . val = xt1 ;
stack [ sp ++ ] . u . val = yt1 ;
stack [ sp ++ ] . u . val = xt2 ;
stack [ sp ++ ] . u . val = yt2 ;
}
current . x = xt2 ;
current . y = yt2 ;
}
break ;
case pt_closepath : if ( cur != NULL && cur -> first != NULL && cur -> first != cur -> last ) {
if ( RealNear ( cur -> first -> me . x , cur -> last -> me . x ) && RealNear ( cur -> first -> me . y , cur -> last -> me . y ) ) {
SplinePoint * oldlast = cur -> last ;
cur -> first -> prevcp = oldlast -> prevcp ;
cur -> first -> prevcp . x += ( cur -> first -> me . x - oldlast -> me . x ) ;
cur -> first -> prevcp . y += ( cur -> first -> me . y - oldlast -> me . y ) ;
cur -> first -> noprevcp = oldlast -> noprevcp ;
oldlast -> prev -> from -> next = NULL ;
cur -> last = oldlast -> prev -> from ;
SplineFree ( oldlast -> prev ) ;
SplinePointFree ( oldlast ) ;
}
CheckMake ( cur -> last , cur -> first ) ;
SplineMake3 ( cur -> last , cur -> first ) ;
cur -> last = cur -> first ;
}
break ;
case pt_setlinecap : if ( sp >= 1 ) linecap = stack [ -- sp ] . u . val ;
break ;
case pt_setlinejoin : if ( sp >= 1 ) linejoin = stack [ -- sp ] . u . val ;
break ;
case pt_setlinewidth : if ( sp >= 1 ) linewidth = stack [ -- sp ] . u . val ;
break ;
case pt_setdash : if ( sp >= 2 && stack [ sp - 1 ] . type == ps_num && stack [ sp - 2 ] . type == ps_array ) {
sp -= 2 ;
dash_offset = stack [ sp + 1 ] . u . val ;
for ( i = 0 ;
i < DASH_MAX && i < stack [ sp ] . u . dict . cnt ;
++ i ) dashes [ i ] = stack [ sp ] . u . dict . entries [ i ] . u . val ;
dictfree ( & stack [ sp ] . u . dict ) ;
}
break ;
case pt_currentlinecap : case pt_currentlinejoin : if ( sp < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
stack [ sp ] . type = ps_num ;
stack [ sp ++ ] . u . val = tok == pt_currentlinecap ? linecap : linejoin ;
}
break ;
case pt_currentlinewidth : if ( sp < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
stack [ sp ] . type = ps_num ;
stack [ sp ++ ] . u . val = linewidth ;
}
break ;
case pt_currentdash : if ( sp + 1 < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
struct pskeydict dict ;
for ( i = 0 ;
i < DASH_MAX && dashes [ i ] != 0 ;
++ i ) ;
dict . cnt = dict . max = i ;
dict . entries = calloc ( i , sizeof ( struct pskeyval ) ) ;
dict . is_executable = false ;
for ( j = 0 ;
j < i ;
++ j ) {
dict . entries [ j ] . type = ps_num ;
dict . entries [ j ] . u . val = dashes [ j ] ;
}
stack [ sp ] . type = ps_array ;
stack [ sp ++ ] . u . dict = dict ;
stack [ sp ] . type = ps_num ;
stack [ sp ++ ] . u . val = dash_offset ;
}
break ;
case pt_currentgray : if ( sp < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
stack [ sp ] . type = ps_num ;
stack [ sp ++ ] . u . val = ( 3 * ( ( fore >> 16 ) & 0xff ) + 6 * ( ( fore >> 8 ) & 0xff ) + ( fore & 0xff ) ) / 2550. ;
}
break ;
case pt_setgray : if ( sp >= 1 ) {
fore = stack [ -- sp ] . u . val * 255 ;
fore *= 0x010101 ;
}
break ;
case pt_setrgbcolor : if ( sp >= 3 ) {
fore = ( ( ( int ) ( stack [ sp - 3 ] . u . val * 255 ) ) << 16 ) + ( ( ( int ) ( stack [ sp - 2 ] . u . val * 255 ) ) << 8 ) + ( int ) ( stack [ sp - 1 ] . u . val * 255 ) ;
sp -= 3 ;
}
break ;
case pt_currenthsbcolor : case pt_currentrgbcolor : if ( sp + 2 < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
stack [ sp ] . type = stack [ sp + 1 ] . type = stack [ sp + 2 ] . type = ps_num ;
if ( tok == pt_currentrgbcolor ) {
stack [ sp ++ ] . u . val = ( ( fore >> 16 ) & 0xff ) / 255. ;
stack [ sp ++ ] . u . val = ( ( fore >> 8 ) & 0xff ) / 255. ;
stack [ sp ++ ] . u . val = ( fore & 0xff ) / 255. ;
}
else {
int r = fore >> 16 , g = ( fore >> 8 ) & 0xff , bl = fore & 0xff ;
int mx , mn ;
real h , s , b ;
mx = mn = r ;
if ( mx > g ) mn = g ;
else mx = g ;
if ( mx < bl ) mx = bl ;
if ( mn > bl ) mn = bl ;
b = mx / 255. ;
s = h = 0 ;
if ( mx > 0 ) s = ( ( real ) ( mx - mn ) ) / mx ;
if ( s != 0 ) {
real rdiff = ( ( real ) ( mx - r ) ) / ( mx - mn ) ;
real gdiff = ( ( real ) ( mx - g ) ) / ( mx - mn ) ;
real bdiff = ( ( real ) ( mx - bl ) ) / ( mx - mn ) ;
if ( rdiff == 0 ) h = bdiff - gdiff ;
else if ( gdiff == 0 ) h = 2 + rdiff - bdiff ;
else h = 4 + gdiff - rdiff ;
h /= 6 ;
if ( h < 0 ) h += 1 ;
}
stack [ sp ++ ] . u . val = h ;
stack [ sp ++ ] . u . val = s ;
stack [ sp ++ ] . u . val = b ;
}
}
break ;
case pt_sethsbcolor : if ( sp >= 3 ) {
real h = stack [ sp - 3 ] . u . val , s = stack [ sp - 2 ] . u . val , b = stack [ sp - 1 ] . u . val ;
int r , g , bl ;
if ( s == 0 ) fore = ( ( int ) ( b * 255 ) ) * 0x010101 ;
else {
real sextant = ( h - floor ( h ) ) * 6 ;
real mod = sextant - floor ( sextant ) ;
real p = b * ( 1 - s ) , q = b * ( 1 - s * mod ) , t = b * ( 1 - s * ( 1 - mod ) ) ;
switch ( ( int ) sextant ) {
case 0 : r = b * 255. ;
g = t * 255. ;
bl = p * 255. ;
break ;
case 1 : r = q * 255. ;
g = b * 255. ;
bl = p * 255. ;
break ;
case 2 : r = p * 255. ;
g = b * 255. ;
bl = t * 255. ;
break ;
case 3 : r = p * 255. ;
g = q * 255. ;
bl = b * 255. ;
break ;
case 4 : r = t * 255. ;
g = p * 255. ;
bl = b * 255. ;
break ;
case 5 : r = b * 255. ;
g = p * 255. ;
bl = q * 255. ;
break ;
default : break ;
}
fore = COLOR_CREATE ( r , g , bl ) ;
}
sp -= 3 ;
}
break ;
case pt_currentcmykcolor : if ( sp + 3 < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
real c , m , y , k ;
stack [ sp ] . type = stack [ sp + 1 ] . type = stack [ sp + 2 ] . type = stack [ sp + 3 ] . type = ps_num ;
y = 1. - ( fore & 0xff ) / 255. ;
m = 1. - ( ( fore >> 8 ) & 0xff ) / 255. ;
c = 1. - ( ( fore >> 16 ) & 0xff ) / 255. ;
k = y ;
if ( k > m ) k = m ;
if ( k > c ) k = c ;
if ( k != 1 ) {
y = ( y - k ) / ( 1 - k ) ;
m = ( m - k ) / ( 1 - k ) ;
c = ( c - k ) / ( 1 - k ) ;
}
else y = m = c = 0 ;
stack [ sp ++ ] . u . val = c ;
stack [ sp ++ ] . u . val = m ;
stack [ sp ++ ] . u . val = y ;
stack [ sp ++ ] . u . val = k ;
}
break ;
case pt_setcmykcolor : if ( sp >= 4 ) {
real c = stack [ sp - 4 ] . u . val , m = stack [ sp - 3 ] . u . val , y = stack [ sp - 2 ] . u . val , k = stack [ sp - 1 ] . u . val ;
sp -= 4 ;
if ( k == 1 ) fore = 0x000000 ;
else {
if ( ( y = ( 1 - k ) * y + k ) < 0 ) y = 0 ;
else if ( y > 1 ) y = 1 ;
if ( ( m = ( 1 - k ) * m + k ) < 0 ) m = 0 ;
else if ( m > 1 ) m = 1 ;
if ( ( c = ( 1 - k ) * c + k ) < 0 ) c = 0 ;
else if ( c > 1 ) c = 1 ;
fore = ( ( int ) ( ( 1 - c ) * 255. ) << 16 ) | ( ( int ) ( ( 1 - m ) * 255. ) << 8 ) | ( ( int ) ( ( 1 - y ) * 255. ) ) ;
}
}
break ;
case pt_currentpoint : if ( sp + 1 < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
stack [ sp ] . type = ps_num ;
stack [ sp ++ ] . u . val = current . x ;
stack [ sp ] . type = ps_num ;
stack [ sp ++ ] . u . val = current . y ;
}
break ;
case pt_fill : case pt_stroke : if ( head == NULL && ec -> splines != NULL ) {
ent = ec -> splines ;
if ( tok == pt_stroke ) {
ent -> u . splines . cap = linecap ;
ent -> u . splines . join = linejoin ;
ent -> u . splines . stroke_width = linewidth ;
memcpy ( ent -> u . splines . transform , transform , sizeof ( transform ) ) ;
}
}
else {
ent = EntityCreate ( head , linecap , linejoin , linewidth , transform , clippath ) ;
ent -> next = ec -> splines ;
ec -> splines = ent ;
}
if ( tok == pt_fill ) ent -> u . splines . fill . col = fore ;
else ent -> u . splines . stroke . col = fore ;
head = NULL ;
cur = NULL ;
break ;
case pt_clip : SplinePointListsFree ( clippath ) ;
clippath = SplinePointListCopy ( head ) ;
if ( clippath != NULL && clippath -> first != clippath -> last ) {
SplineMake3 ( clippath -> last , clippath -> first ) ;
clippath -> last = clippath -> first ;
}
break ;
case pt_imagemask : i = PSAddImagemask ( ec , stack , sp , transform , fore ) ;
while ( sp > i ) {
-- sp ;
if ( stack [ sp ] . type == ps_string || stack [ sp ] . type == ps_instr || stack [ sp ] . type == ps_lit ) free ( stack [ sp ] . u . str ) ;
else if ( stack [ sp ] . type == ps_array || stack [ sp ] . type == ps_dict ) dictfree ( & stack [ sp ] . u . dict ) ;
}
break ;
case pt_save : case pt_currentmatrix : if ( sp < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
stack [ sp ] . type = ps_num ;
stack [ sp ++ ] . u . val = 0 ;
}
;
case pt_gsave : if ( gsp < 30 ) {
memcpy ( gsaves [ gsp ] . transform , transform , sizeof ( transform ) ) ;
gsaves [ gsp ] . current = current ;
gsaves [ gsp ] . linewidth = linewidth ;
gsaves [ gsp ] . linecap = linecap ;
gsaves [ gsp ] . linejoin = linejoin ;
gsaves [ gsp ] . fore = fore ;
gsaves [ gsp ] . clippath = SplinePointListCopy ( clippath ) ;
++ gsp ;
}
break ;
case pt_restore : case pt_setmatrix : if ( sp >= 1 ) -- sp ;
;
case pt_grestore : if ( gsp > 0 ) {
-- gsp ;
memcpy ( transform , gsaves [ gsp ] . transform , sizeof ( transform ) ) ;
current = gsaves [ gsp ] . current ;
linewidth = gsaves [ gsp ] . linewidth ;
linecap = gsaves [ gsp ] . linecap ;
linejoin = gsaves [ gsp ] . linejoin ;
fore = gsaves [ gsp ] . fore ;
SplinePointListsFree ( clippath ) ;
clippath = gsaves [ gsp ] . clippath ;
}
break ;
case pt_null : if ( sp < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
stack [ sp ] . u . val = 0 ;
stack [ sp ++ ] . type = ps_num ;
}
break ;
case pt_currentoverprint : if ( sp < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
stack [ sp ] . u . val = 0 ;
stack [ sp ++ ] . type = ps_bool ;
}
break ;
case pt_setoverprint : if ( sp >= 1 ) -- sp ;
break ;
case pt_currentflat : if ( sp < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
stack [ sp ] . u . val = 1.0 ;
stack [ sp ++ ] . type = ps_num ;
}
break ;
case pt_setflat : if ( sp >= 1 ) -- sp ;
break ;
case pt_currentmiterlimit : if ( sp < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
stack [ sp ] . u . val = 10.0 ;
stack [ sp ++ ] . type = ps_num ;
}
break ;
case pt_setmiterlimit : if ( sp >= 1 ) -- sp ;
break ;
case pt_currentpacking : if ( sp < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
stack [ sp ] . u . val = 0 ;
stack [ sp ++ ] . type = ps_bool ;
}
break ;
case pt_setpacking : if ( sp >= 1 ) -- sp ;
break ;
case pt_currentstrokeadjust : if ( sp < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
stack [ sp ] . u . val = 0 ;
stack [ sp ++ ] . type = ps_bool ;
}
break ;
case pt_setstrokeadjust : if ( sp >= 1 ) -- sp ;
break ;
case pt_currentsmoothness : if ( sp < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
stack [ sp ] . u . val = 1.0 ;
stack [ sp ++ ] . type = ps_num ;
}
break ;
case pt_setsmoothness : if ( sp >= 1 ) -- sp ;
break ;
case pt_currentobjectformat : if ( sp < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
stack [ sp ] . u . val = 0.0 ;
stack [ sp ++ ] . type = ps_num ;
}
break ;
case pt_setobjectformat : if ( sp >= 1 ) -- sp ;
break ;
case pt_currentglobal : case pt_currentshared : if ( sp < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
stack [ sp ] . u . val = 0 ;
stack [ sp ++ ] . type = ps_bool ;
}
break ;
case pt_setglobal : if ( sp >= 1 ) -- sp ;
break ;
case pt_openarray : case pt_mark : if ( sp < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
stack [ sp ++ ] . type = ps_mark ;
}
break ;
case pt_counttomark : for ( i = 0 ;
( unsigned ) i < sp ;
++ i ) if ( stack [ sp - 1 - i ] . type == ps_mark ) break ;
if ( ( unsigned ) i == sp ) LogError ( _ ( "No mark in counttomark\n" ) ) ;
else if ( sp < sizeof ( stack ) / sizeof ( stack [ 0 ] ) ) {
stack [ sp ] . type = ps_num ;
stack [ sp ++ ] . u . val = i ;
}
break ;
case pt_cleartomark : for ( i = 0 ;
( unsigned ) i < sp ;
++ i ) if ( stack [ sp - 1 - i ] . type == ps_mark ) break ;
if ( ( unsigned ) i == sp ) LogError ( _ ( "No mark in cleartomark\n" ) ) ;
else {
while ( sp >= i ) {
-- sp ;
if ( stack [ sp ] . type == ps_string || stack [ sp ] . type == ps_instr || stack [ sp ] . type == ps_lit ) free ( stack [ sp ] . u . str ) ;
else if ( stack [ sp ] . type == ps_array || stack [ sp ] . type == ps_dict ) dictfree ( & stack [ sp ] . u . dict ) ;
}
}
break ;
case pt_closearray : for ( i = 0 ;
( unsigned ) i < sp ;
++ i ) if ( stack [ sp - 1 - i ] . type == ps_mark ) break ;
if ( ( unsigned ) i == sp ) LogError ( _ ( "No mark in ] (close array)\n" ) ) ;
else {
struct pskeydict dict ;
dict . cnt = dict . max = i ;
dict . entries = calloc ( i , sizeof ( struct pskeyval ) ) ;
dict . is_executable = false ;
for ( j = 0 ;
j < i ;
++ j ) {
dict . entries [ j ] . type = stack [ sp - i + j ] . type ;
dict . entries [ j ] . u = stack [ sp - i + j ] . u ;
}
collectgarbage ( & tofrees , & dict ) ;
sp = sp - i ;
stack [ sp - 1 ] . type = ps_array ;
stack [ sp - 1 ] . u . dict = dict ;
}
break ;
case pt_array : if ( sp >= 1 && stack [ sp - 1 ] . type == ps_num ) {
struct pskeydict dict ;
dict . cnt = dict . max = stack [ sp - 1 ] . u . val ;
dict . entries = calloc ( dict . cnt , sizeof ( struct pskeyval ) ) ;
dict . is_executable = false ;
stack [ sp - 1 ] . type = ps_array ;
stack [ sp - 1 ] . u . dict = dict ;
}
break ;
case pt_aload : sp = aload ( sp , stack , sizeof ( stack ) / sizeof ( stack [ 0 ] ) , & tofrees ) ;
break ;
case pt_astore : if ( sp >= 1 && stack [ sp - 1 ] . type == ps_array ) {
struct pskeydict dict ;
-- sp ;
dict = stack [ sp ] . u . dict ;
if ( sp >= dict . cnt ) {
for ( i = dict . cnt - 1 ;
i >= 0 ;
-- i ) {
-- sp ;
dict . entries [ i ] . type = stack [ sp ] . type ;
dict . entries [ i ] . u = stack [ sp ] . u ;
}
}
stack [ sp ] . type = ps_array ;
stack [ sp ] . u . dict = dict ;
++ sp ;
}
break ;
case pt_output : case pt_outputd : case pt_print : if ( sp >= 1 ) {
-- sp ;
switch ( stack [ sp ] . type ) {
case ps_num : printf ( "%g" , ( double ) stack [ sp ] . u . val ) ;
break ;
case ps_bool : printf ( "%s" , stack [ sp ] . u . tf ? "true" : "false" ) ;
break ;
case ps_string : case ps_instr : case ps_lit : if ( tok == pt_outputd ) printf ( stack [ sp ] . type == ps_lit ? "/" : stack [ sp ] . type == ps_string ? "(" : "{
" ) ;
printf ( "%s" , stack [ sp ] . u . str ) ;
if ( tok == pt_outputd ) printf ( stack [ sp ] . type == ps_lit ? "" : stack [ sp ] . type == ps_string ? ")" : "}
" ) ;
free ( stack [ sp ] . u . str ) ;
break ;
case ps_void : printf ( "-- void --" ) ;
break ;
case ps_array : if ( tok == pt_outputd ) {
printarray ( & stack [ sp ] . u . dict ) ;
dictfree ( & stack [ sp ] . u . dict ) ;
break ;
}
dictfree ( & stack [ sp ] . u . dict ) ;
default : printf ( "-- nostringval --" ) ;
break ;
}
if ( tok == pt_output || tok == pt_outputd ) printf ( "\n" ) ;
}
else LogError ( _ ( "Nothing on stack to print\n" ) ) ;
break ;
case pt_cvi : case pt_cvr : if ( sp >= 1 && stack [ sp - 1 ] . type == ps_string ) {
double val = strtod ( stack [ sp - 1 ] . u . str , NULL ) ;
free ( stack [ sp - 1 ] . u . str ) ;
stack [ sp - 1 ] . u . val = val ;
stack [ sp - 1 ] . type = ps_num ;
}
break ;
case pt_cvlit : if ( sp >= 1 ) {
if ( stack [ sp - 1 ] . type == ps_array ) stack [ sp - 1 ] . u . dict . is_executable = false ;
}
case pt_cvn : if ( sp >= 1 ) {
if ( stack [ sp - 1 ] . type == ps_string ) stack [ sp - 1 ] . type = ps_lit ;
}
case pt_cvx : if ( sp >= 1 ) {
if ( stack [ sp - 1 ] . type == ps_array ) stack [ sp - 1 ] . u . dict . is_executable = true ;
}
break ;
case pt_cvrs : if ( sp >= 3 && stack [ sp - 1 ] . type == ps_string && stack [ sp - 2 ] . type == ps_num && stack [ sp - 3 ] . type == ps_num ) {
if ( stack [ sp - 2 ] . u . val == 8 ) sprintf ( stack [ sp - 1 ] . u . str , "%o" , ( int ) stack [ sp - 3 ] . u . val ) ;
else if ( stack [ sp - 2 ] . u . val == 16 ) sprintf ( stack [ sp - 1 ] . u . str , "%X" , ( int ) stack [ sp - 3 ] . u . val ) ;
else sprintf ( stack [ sp - 1 ] . u . str , "%g" , ( double ) stack [ sp - 3 ] . u . val ) ;
stack [ sp - 3 ] = stack [ sp - 1 ] ;
sp -= 2 ;
}
break ;
case pt_cvs : if ( sp >= 2 && stack [ sp - 1 ] . type == ps_string ) {
switch ( stack [ sp ] . type ) {
case ps_num : sprintf ( stack [ sp - 1 ] . u . str , "%g" , ( double ) stack [ sp - 2 ] . u . val ) ;
break ;
case ps_bool : sprintf ( stack [ sp - 1 ] . u . str , "%s" , stack [ sp - 2 ] . u . tf ? "true" : "false" ) ;
break ;
case ps_string : case ps_instr : case ps_lit : sprintf ( stack [ sp - 1 ] . u . str , "%s" , stack [ sp - 2 ] . u . str ) ;
free ( stack [ sp ] . u . str ) ;
break ;
case ps_void : printf ( "-- void --" ) ;
break ;
case ps_array : dictfree ( & stack [ sp ] . u . dict ) ;
default : sprintf ( stack [ sp - 1 ] . u . str , "-- nostringval --" ) ;
break ;
}
stack [ sp - 2 ] = stack [ sp - 1 ] ;
-- sp ;
}
break ;
case pt_stringop : if ( sp >= 1 && stack [ sp - 1 ] . type == ps_num ) {
stack [ sp - 1 ] . type = ps_string ;
stack [ sp - 1 ] . u . str = calloc ( stack [ sp - 1 ] . u . val + 1 , 1 ) ;
}
break ;
case pt_unknown : if ( ! warned ) {
LogError ( _ ( "Warning: Unable to parse token %s, some features may be lost\n" ) , tokbuf ) ;
warned = true ;
}
break ;
default : break ;
}
}
}
done : if ( rs != NULL ) {
int i , cnt , j ;
for ( i = sp - 1 ;
i >= 0 ;
-- i ) if ( stack [ i ] . type != ps_num ) break ;
cnt = sp - 1 - i ;
if ( cnt > rs -> max ) cnt = rs -> max ;
rs -> cnt = cnt ;
for ( j = i + 1 ;
( unsigned ) j < sp ;
++ j ) rs -> stack [ j - i - 1 ] = stack [ j ] . u . val ;
}
freestuff ( stack , sp , & dict , & gb , & tofrees ) ;
if ( head != NULL ) {
ent = EntityCreate ( head , linecap , linejoin , linewidth , transform , clippath ) ;
ent -> next = ec -> splines ;
ec -> splines = ent ;
}
while ( gsp > 0 ) {
-- gsp ;
SplinePointListsFree ( gsaves [ gsp ] . clippath ) ;
}
SplinePointListsFree ( clippath ) ;
ECCategorizePoints ( ec ) ;
if ( ec -> width == UNDEFINED_WIDTH ) ec -> width = wrapper -> advance_width ;
switch_to_old_locale ( & tmplocale , & oldlocale ) ;
free ( tokbuf ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void xps_insert_font ( xps_document * doc , char * name , fz_font * font ) {
xps_font_cache * cache = fz_malloc_struct ( doc -> ctx , xps_font_cache ) ;
cache -> name = fz_strdup ( doc -> ctx , name ) ;
cache -> font = fz_keep_font ( doc -> ctx , font ) ;
cache -> next = doc -> font_table ;
doc -> font_table = cache ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static Int decShiftToMost ( Unit * uar , Int digits , Int shift ) {
Unit * target , * source , * first ;
Int cut ;
uInt next ;
if ( shift == 0 ) return digits ;
if ( ( digits + shift ) <= DECDPUN ) {
* uar = ( Unit ) ( * uar * powers [ shift ] ) ;
return digits + shift ;
}
next = 0 ;
source = uar + D2U ( digits ) - 1 ;
target = source + D2U ( shift ) ;
cut = DECDPUN - MSUDIGITS ( shift ) ;
if ( cut == 0 ) {
for ( ;
source >= uar ;
source -- , target -- ) * target = * source ;
}
else {
first = uar + D2U ( digits + shift ) - 1 ;
for ( ;
source >= uar ;
source -- , target -- ) {
# if DECDPUN <= 4 uInt quot = QUOT10 ( * source , cut ) ;
uInt rem = * source - quot * powers [ cut ] ;
next += quot ;
# else uInt rem = * source % powers [ cut ] ;
next += * source / powers [ cut ] ;
# endif if ( target <= first ) * target = ( Unit ) next ;
next = rem * powers [ DECDPUN - cut ] ;
}
}
for ( ;
target >= uar ;
target -- ) {
* target = ( Unit ) next ;
next = 0 ;
}
return digits + shift ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void EVP_CIPHER_CTX_free ( EVP_CIPHER_CTX * ctx ) {
EVP_CIPHER_CTX_reset ( ctx ) ;
OPENSSL_free ( ctx ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | CURLcode Curl_gmtime ( time_t intime , struct tm * store ) {
const struct tm * tm ;
# ifdef HAVE_GMTIME_R tm = ( struct tm * ) gmtime_r ( & intime , store ) ;
# else tm = gmtime ( & intime ) ;
if ( tm ) * store = * tm ;
# endif if ( ! tm ) return CURLE_BAD_FUNCTION_ARGUMENT ;
return CURLE_OK ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void stroke_config ( private_stroke_socket_t * this , stroke_msg_t * msg , FILE * out ) {
this -> cred -> cachecrl ( this -> cred , msg -> config . cachecrl ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static gpgme_error_t _uiserver_decrypt ( void * engine , int verify , gpgme_data_t ciph , gpgme_data_t plain ) {
engine_uiserver_t uiserver = engine ;
gpgme_error_t err ;
const char * protocol ;
char * cmd ;
if ( ! uiserver ) return gpg_error ( GPG_ERR_INV_VALUE ) ;
if ( uiserver -> protocol == GPGME_PROTOCOL_DEFAULT ) protocol = "" ;
else if ( uiserver -> protocol == GPGME_PROTOCOL_OpenPGP ) protocol = " --protocol=OpenPGP" ;
else if ( uiserver -> protocol == GPGME_PROTOCOL_CMS ) protocol = " --protocol=CMS" ;
else return gpgme_error ( GPG_ERR_UNSUPPORTED_PROTOCOL ) ;
if ( asprintf ( & cmd , "DECRYPT%s%s" , protocol , verify ? "" : " --no-verify" ) < 0 ) return gpg_error_from_syserror ( ) ;
uiserver -> input_cb . data = ciph ;
err = uiserver_set_fd ( uiserver , INPUT_FD , map_data_enc ( uiserver -> input_cb . data ) ) ;
if ( err ) {
free ( cmd ) ;
return gpg_error ( GPG_ERR_GENERAL ) ;
}
uiserver -> output_cb . data = plain ;
err = uiserver_set_fd ( uiserver , OUTPUT_FD , 0 ) ;
if ( err ) {
free ( cmd ) ;
return gpg_error ( GPG_ERR_GENERAL ) ;
}
uiserver -> inline_data = NULL ;
err = start ( engine , cmd ) ;
free ( cmd ) ;
return err ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void cal ( int32_t month , int32_t year , UBool useLongNames , UErrorCode * status ) {
UCalendar * c ;
UChar * days [ DAY_COUNT ] ;
UChar * months [ MONTH_COUNT ] ;
int32_t fdow ;
if ( U_FAILURE ( * status ) ) return ;
c = ucal_open ( 0 , - 1 , uloc_getDefault ( ) , UCAL_TRADITIONAL , status ) ;
if ( month == - 1 && year != - 1 ) {
ucal_set ( c , UCAL_YEAR , year ) ;
fdow = ucal_getAttribute ( c , UCAL_FIRST_DAY_OF_WEEK ) ;
print_year ( c , days , months , useLongNames , fdow , status ) ;
}
else {
if ( month != - 1 ) ucal_set ( c , UCAL_MONTH , month ) ;
if ( year != - 1 ) ucal_set ( c , UCAL_YEAR , year ) ;
fdow = ucal_getAttribute ( c , UCAL_FIRST_DAY_OF_WEEK ) ;
print_month ( c , days , useLongNames , fdow , status ) ;
}
ucal_close ( c ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void config_filter_add_all ( struct config_filter_context * ctx , struct config_filter_parser * const * parsers ) {
ctx -> parsers = parsers ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int decode_pal_v2 ( MSS12Context * ctx , const uint8_t * buf , int buf_size ) {
int i , ncol ;
uint32_t * pal = ctx -> pal + 256 - ctx -> free_colours ;
if ( ! ctx -> free_colours ) return 0 ;
ncol = * buf ++ ;
if ( ncol > ctx -> free_colours || buf_size < 2 + ncol * 3 ) return AVERROR_INVALIDDATA ;
for ( i = 0 ;
i < ncol ;
i ++ ) * pal ++ = AV_RB24 ( buf + 3 * i ) ;
return 1 + ncol * 3 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void cmd_window_hide ( const char * data ) {
WINDOW_REC * window ;
if ( mainwindows -> next == NULL ) {
printformat_window ( active_win , MSGLEVEL_CLIENTNOTICE , TXT_CANT_HIDE_LAST ) ;
return ;
}
if ( * data == '\0' ) window = active_win ;
else if ( is_numeric ( data , 0 ) ) {
window = window_find_refnum ( atoi ( data ) ) ;
if ( window == NULL ) {
printformat_window ( active_win , MSGLEVEL_CLIENTERROR , TXT_REFNUM_NOT_FOUND , data ) ;
}
}
else {
window = window_find_item ( active_win -> active_server , data ) ;
}
if ( window == NULL || ! is_window_visible ( window ) ) return ;
if ( WINDOW_MAIN ( window ) -> sticky_windows ) {
if ( ! settings_get_bool ( "autounstick_windows" ) ) {
printformat_window ( active_win , MSGLEVEL_CLIENTERROR , TXT_CANT_HIDE_STICKY_WINDOWS ) ;
return ;
}
}
mainwindow_destroy ( WINDOW_MAIN ( window ) ) ;
if ( active_mainwin == NULL ) {
active_mainwin = WINDOW_MAIN ( active_win ) ;
window_set_active ( active_mainwin -> active ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void ialloc_reset ( gs_ref_memory_t * mem ) {
mem -> root = 0 ;
mem -> cc = NULL ;
mem -> allocated = 0 ;
mem -> changes = 0 ;
mem -> scan_limit = 0 ;
mem -> total_scanned = 0 ;
mem -> total_scanned_after_compacting = 0 ;
ialloc_reset_free ( mem ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void U_CALLCONV _LMBCSFromUnicode ( UConverterFromUnicodeArgs * args , UErrorCode * err ) {
ulmbcs_byte_t lastConverterIndex = 0 ;
UChar uniChar ;
ulmbcs_byte_t LMBCS [ ULMBCS_CHARSIZE_MAX ] ;
ulmbcs_byte_t * pLMBCS ;
int32_t bytes_written ;
UBool groups_tried [ ULMBCS_GRP_LAST + 1 ] ;
UConverterDataLMBCS * extraInfo = ( UConverterDataLMBCS * ) args -> converter -> extraInfo ;
int sourceIndex = 0 ;
ulmbcs_byte_t OldConverterIndex = 0 ;
while ( args -> source < args -> sourceLimit && ! U_FAILURE ( * err ) ) {
OldConverterIndex = extraInfo -> localeConverterIndex ;
if ( args -> target >= args -> targetLimit ) {
* err = U_BUFFER_OVERFLOW_ERROR ;
break ;
}
uniChar = * ( args -> source ) ;
bytes_written = 0 ;
pLMBCS = LMBCS ;
if ( ( uniChar >= 0x80 ) && ( uniChar <= 0xff ) && ( uniChar != 0xB1 ) && ( uniChar != 0xD7 ) && ( uniChar != 0xF7 ) && ( uniChar != 0xB0 ) && ( uniChar != 0xB4 ) && ( uniChar != 0xB6 ) && ( uniChar != 0xA7 ) && ( uniChar != 0xA8 ) ) {
extraInfo -> localeConverterIndex = ULMBCS_GRP_L1 ;
}
if ( ( ( uniChar > ULMBCS_C0END ) && ( uniChar < ULMBCS_C1START ) ) || uniChar == 0 || uniChar == ULMBCS_HT || uniChar == ULMBCS_CR || uniChar == ULMBCS_LF || uniChar == ULMBCS_123SYSTEMRANGE ) {
* pLMBCS ++ = ( ulmbcs_byte_t ) uniChar ;
bytes_written = 1 ;
}
if ( ! bytes_written ) {
ulmbcs_byte_t group = FindLMBCSUniRange ( uniChar ) ;
if ( group == ULMBCS_GRP_UNICODE ) {
pLMBCS += LMBCSConvertUni ( pLMBCS , uniChar ) ;
bytes_written = ( int32_t ) ( pLMBCS - LMBCS ) ;
}
else if ( group == ULMBCS_GRP_CTRL ) {
if ( uniChar <= ULMBCS_C0END ) {
* pLMBCS ++ = ULMBCS_GRP_CTRL ;
* pLMBCS ++ = ( ulmbcs_byte_t ) ( ULMBCS_CTRLOFFSET + uniChar ) ;
}
else if ( uniChar >= ULMBCS_C1START && uniChar <= ULMBCS_C1START + ULMBCS_CTRLOFFSET ) {
* pLMBCS ++ = ULMBCS_GRP_CTRL ;
* pLMBCS ++ = ( ulmbcs_byte_t ) ( uniChar & 0x00FF ) ;
}
bytes_written = ( int32_t ) ( pLMBCS - LMBCS ) ;
}
else if ( group < ULMBCS_GRP_UNICODE ) {
bytes_written = ( int32_t ) LMBCSConversionWorker ( extraInfo , group , pLMBCS , & uniChar , & lastConverterIndex , groups_tried ) ;
}
if ( ! bytes_written ) {
uprv_memset ( groups_tried , 0 , sizeof ( groups_tried ) ) ;
if ( ( extraInfo -> OptGroup != 1 ) && ( ULMBCS_AMBIGUOUS_MATCH ( group , extraInfo -> OptGroup ) ) ) {
if ( extraInfo -> localeConverterIndex < ULMBCS_DOUBLEOPTGROUP_START ) {
bytes_written = LMBCSConversionWorker ( extraInfo , ULMBCS_GRP_L1 , pLMBCS , & uniChar , & lastConverterIndex , groups_tried ) ;
if ( ! bytes_written ) {
bytes_written = LMBCSConversionWorker ( extraInfo , ULMBCS_GRP_EXCEPT , pLMBCS , & uniChar , & lastConverterIndex , groups_tried ) ;
}
if ( ! bytes_written ) {
bytes_written = LMBCSConversionWorker ( extraInfo , extraInfo -> localeConverterIndex , pLMBCS , & uniChar , & lastConverterIndex , groups_tried ) ;
}
}
else {
bytes_written = LMBCSConversionWorker ( extraInfo , extraInfo -> localeConverterIndex , pLMBCS , & uniChar , & lastConverterIndex , groups_tried ) ;
}
}
if ( ! bytes_written && ( extraInfo -> localeConverterIndex ) && ( ULMBCS_AMBIGUOUS_MATCH ( group , extraInfo -> localeConverterIndex ) ) ) {
bytes_written = ( int32_t ) LMBCSConversionWorker ( extraInfo , extraInfo -> localeConverterIndex , pLMBCS , & uniChar , & lastConverterIndex , groups_tried ) ;
}
if ( ! bytes_written && ( lastConverterIndex ) && ( ULMBCS_AMBIGUOUS_MATCH ( group , lastConverterIndex ) ) ) {
bytes_written = ( int32_t ) LMBCSConversionWorker ( extraInfo , lastConverterIndex , pLMBCS , & uniChar , & lastConverterIndex , groups_tried ) ;
}
if ( ! bytes_written ) {
ulmbcs_byte_t grp_start ;
ulmbcs_byte_t grp_end ;
ulmbcs_byte_t grp_ix ;
grp_start = ( ulmbcs_byte_t ) ( ( group == ULMBCS_AMBIGUOUS_MBCS ) ? ULMBCS_DOUBLEOPTGROUP_START : ULMBCS_GRP_L1 ) ;
grp_end = ( ulmbcs_byte_t ) ( ( group == ULMBCS_AMBIGUOUS_MBCS ) ? ULMBCS_GRP_LAST : ULMBCS_GRP_TH ) ;
if ( group == ULMBCS_AMBIGUOUS_ALL ) {
grp_start = ULMBCS_GRP_L1 ;
grp_end = ULMBCS_GRP_LAST ;
}
for ( grp_ix = grp_start ;
grp_ix <= grp_end && ! bytes_written ;
grp_ix ++ ) {
if ( extraInfo -> OptGrpConverter [ grp_ix ] && ! groups_tried [ grp_ix ] ) {
bytes_written = ( int32_t ) LMBCSConversionWorker ( extraInfo , grp_ix , pLMBCS , & uniChar , & lastConverterIndex , groups_tried ) ;
}
}
if ( ! bytes_written && grp_start == ULMBCS_GRP_L1 ) {
bytes_written = ( int32_t ) LMBCSConversionWorker ( extraInfo , ULMBCS_GRP_EXCEPT , pLMBCS , & uniChar , & lastConverterIndex , groups_tried ) ;
}
}
if ( ! bytes_written ) {
pLMBCS += LMBCSConvertUni ( pLMBCS , uniChar ) ;
bytes_written = ( int32_t ) ( pLMBCS - LMBCS ) ;
}
}
}
args -> source ++ ;
pLMBCS = LMBCS ;
while ( args -> target < args -> targetLimit && bytes_written -- ) {
* ( args -> target ) ++ = * pLMBCS ++ ;
if ( args -> offsets ) {
* ( args -> offsets ) ++ = sourceIndex ;
}
}
sourceIndex ++ ;
if ( bytes_written > 0 ) {
uint8_t * pErrorBuffer = args -> converter -> charErrorBuffer ;
* err = U_BUFFER_OVERFLOW_ERROR ;
args -> converter -> charErrorBufferLength = ( int8_t ) bytes_written ;
while ( bytes_written -- ) {
* pErrorBuffer ++ = * pLMBCS ++ ;
}
}
extraInfo -> localeConverterIndex = OldConverterIndex ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | IN_PROC_BROWSER_TEST_F ( SessionRestorePageLoadMetricsBrowserTest , InitialVisibilityOfSingleRestoredTab ) {
ui_test_utils : : NavigateToURL ( browser ( ) , GetTestURL ( ) ) ;
histogram_tester_ . ExpectTotalCount ( page_load_metrics : : internal : : kPageLoadStartedInForeground , 1 ) ;
histogram_tester_ . ExpectBucketCount ( page_load_metrics : : internal : : kPageLoadStartedInForeground , true , 1 ) ;
Browser * new_browser = QuitBrowserAndRestore ( browser ( ) ) ;
ASSERT_NO_FATAL_FAILURE ( WaitForTabsToLoad ( new_browser ) ) ;
histogram_tester_ . ExpectTotalCount ( page_load_metrics : : internal : : kPageLoadStartedInForeground , 2 ) ;
histogram_tester_ . ExpectBucketCount ( page_load_metrics : : internal : : kPageLoadStartedInForeground , true , 2 ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int decode_udvm_address_operand ( guint8 * buff , guint operand_address , guint16 * value , guint current_address ) {
guint32 result ;
guint16 value1 ;
gint next_operand_address ;
next_operand_address = decode_udvm_multitype_operand ( buff , operand_address , & value1 ) ;
result = value1 & 0xffff ;
result = result + current_address ;
* value = result & 0xffff ;
return next_operand_address ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | IN_PROC_BROWSER_TEST_F ( FastUnloadTest , DISABLED_ClosingLastTabFinishesUnload ) {
# if defined ( OS_WIN ) if ( base : : win : : GetVersion ( ) >= base : : win : : VERSION_WIN7 ) return ;
# endif NavigateToPage ( "no_listeners" ) ;
EXPECT_EQ ( "unloaded=ohyeah" , GetCookies ( "no_listeners" ) ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int DecodeAsn1BuildValue ( const unsigned char * * d_ptr , uint32_t * val , uint8_t numbytes , uint32_t * errcode ) {
int i ;
uint32_t value = 0 ;
if ( numbytes > 4 ) {
if ( errcode ) * errcode = ERR_DER_INVALID_SIZE ;
value = 0xffffffff ;
* val = value ;
return - 1 ;
}
else {
for ( i = 0 ;
i < numbytes ;
i ++ ) {
value = value << 8 | ( * d_ptr ) [ 0 ] ;
( * d_ptr ) ++ ;
}
}
* val = value ;
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_h245_INTEGER_1_192400 ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
offset = dissect_per_constrained_integer ( tvb , offset , actx , tree , hf_index , 1U , 192400U , NULL , FALSE ) ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void copy_bits ( PutBitContext * pb , const uint8_t * data , int size , GetBitContext * gb , int nbits ) {
int rmn_bytes , rmn_bits ;
rmn_bits = rmn_bytes = get_bits_left ( gb ) ;
if ( rmn_bits < nbits ) return ;
if ( nbits > pb -> size_in_bits - put_bits_count ( pb ) ) return ;
rmn_bits &= 7 ;
rmn_bytes >>= 3 ;
if ( ( rmn_bits = FFMIN ( rmn_bits , nbits ) ) > 0 ) put_bits ( pb , rmn_bits , get_bits ( gb , rmn_bits ) ) ;
avpriv_copy_bits ( pb , data + size - rmn_bytes , FFMIN ( nbits - rmn_bits , rmn_bytes << 3 ) ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void mainwindow_set_rsize ( MAIN_WINDOW_REC * window , int width ) {
width -= window -> width ;
if ( width < 0 ) mainwindow_rshrink ( window , - width ) ;
else mainwindow_rgrow ( window , width ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_h225_BIT_STRING ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
offset = dissect_per_bit_string ( tvb , offset , actx , tree , hf_index , NO_BOUND , NO_BOUND , FALSE , NULL , NULL ) ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void * checked_xcalloc ( size_t num , size_t size ) {
alloc_limit_assert ( "checked_xcalloc" , ( num * size ) ) ;
return xcalloc ( num , size ) ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | const gx_device_memory * gdev_mem_word_device_for_bits ( int bits_per_pixel ) {
return ( ( uint ) bits_per_pixel > 64 ? ( const gx_device_memory * ) 0 : mem_word_devices [ bits_per_pixel ] ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void steamdiscover_dissect_body_authresponse ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree , gint offset , gint bytes_left ) {
gint len ;
gint64 value ;
protobuf_desc_t pb = {
tvb , offset , bytes_left }
;
protobuf_tag_t tag = {
0 , 0 , 0 }
;
while ( protobuf_iter_next ( & pb , & tag ) ) {
switch ( tag . field_number ) {
case STEAMDISCOVER_FN_AUTHRESPONSE_AUTHRESULT : STEAMDISCOVER_ENSURE_WIRETYPE ( PROTOBUF_WIRETYPE_VARINT ) ;
value = get_varint64 ( pb . tvb , pb . offset , pb . bytes_left , & len ) ;
proto_tree_add_uint64 ( tree , hf_steam_ihs_discovery_body_authresponse_authresult , pb . tvb , pb . offset , len , ( guint64 ) value ) ;
col_add_fstr ( pinfo -> cinfo , COL_INFO , "%s Result=%" G_GUINT64_FORMAT "(%s)" , hf_steam_ihs_discovery_header_msgtype_strings [ STEAMDISCOVER_MSGTYPE_DEVICEAUTHORIZATIONRESPONSE ] . strptr , ( guint64 ) value , val64_to_str_const ( ( guint64 ) value , hf_steam_ihs_discovery_body_authresponse_authresult_strings , "Unknown" ) ) ;
break ;
default : len = protobuf_dissect_unknown_field ( & pb , & tag , pinfo , tree , NULL ) ;
break ;
}
protobuf_seek_forward ( & pb , len ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int test_encode_decode_uint32_t ( xd3_stream * stream , int unused ) {
TEST_ENCODE_DECODE_INTEGER ( uint32_t , 1U , UINT32_MAX ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void dealloc_compressor_data ( VP8_COMP * cpi ) {
vpx_free ( cpi -> tplist ) ;
cpi -> tplist = NULL ;
vpx_free ( cpi -> lfmv ) ;
cpi -> lfmv = 0 ;
vpx_free ( cpi -> lf_ref_frame_sign_bias ) ;
cpi -> lf_ref_frame_sign_bias = 0 ;
vpx_free ( cpi -> lf_ref_frame ) ;
cpi -> lf_ref_frame = 0 ;
vpx_free ( cpi -> segmentation_map ) ;
cpi -> segmentation_map = 0 ;
vpx_free ( cpi -> active_map ) ;
cpi -> active_map = 0 ;
vp8_de_alloc_frame_buffers ( & cpi -> common ) ;
vp8_yv12_de_alloc_frame_buffer ( & cpi -> pick_lf_lvl_frame ) ;
vp8_yv12_de_alloc_frame_buffer ( & cpi -> scaled_source ) ;
dealloc_raw_frame_buffers ( cpi ) ;
vpx_free ( cpi -> tok ) ;
cpi -> tok = 0 ;
vpx_free ( cpi -> gf_active_flags ) ;
cpi -> gf_active_flags = 0 ;
vpx_free ( cpi -> mb_activity_map ) ;
cpi -> mb_activity_map = 0 ;
vpx_free ( cpi -> mb . pip ) ;
cpi -> mb . pip = 0 ;
# if CONFIG_MULTITHREAD vpx_free ( cpi -> mt_current_mb_col ) ;
cpi -> mt_current_mb_col = NULL ;
# endif } | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | sf_count_t psf_get_filelen ( SF_PRIVATE * psf ) {
sf_count_t filelen ;
if ( psf -> virtual_io ) return psf -> vio . get_filelen ( psf -> vio_user_data ) ;
filelen = psf_get_filelen_fd ( psf -> file . filedes ) ;
if ( filelen == - 1 ) {
psf_log_syserr ( psf , errno ) ;
return ( sf_count_t ) - 1 ;
}
;
if ( filelen == - SFE_BAD_STAT_SIZE ) {
psf -> error = SFE_BAD_STAT_SIZE ;
return ( sf_count_t ) - 1 ;
}
;
switch ( psf -> file . mode ) {
case SFM_WRITE : filelen = filelen - psf -> fileoffset ;
break ;
case SFM_READ : if ( psf -> fileoffset > 0 && psf -> filelength > 0 ) filelen = psf -> filelength ;
break ;
case SFM_RDWR : break ;
default : filelen = - 1 ;
}
;
return filelen ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int dissect_ber_object_identifier ( gboolean implicit_tag , asn1_ctx_t * actx , proto_tree * tree , tvbuff_t * tvb , int offset , gint hf_id , tvbuff_t * * value_tvb ) {
return dissect_ber_any_oid ( implicit_tag , actx , tree , tvb , offset , hf_id , value_tvb , TRUE ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void dissect_zcl_ota_upgradeendreq ( tvbuff_t * tvb , proto_tree * tree , guint * offset ) {
proto_tree_add_item ( tree , hf_zbee_zcl_ota_status , tvb , * offset , 1 , ENC_NA ) ;
* offset += 1 ;
proto_tree_add_item ( tree , hf_zbee_zcl_ota_manufacturer_code , tvb , * offset , 2 , ENC_LITTLE_ENDIAN ) ;
* offset += 2 ;
proto_tree_add_item ( tree , hf_zbee_zcl_ota_image_type , tvb , * offset , 2 , ENC_LITTLE_ENDIAN ) ;
* offset += 2 ;
dissect_zcl_ota_file_version_field ( tvb , tree , offset ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void name ## _free ( type * a ) ;
# define DECLARE_ASN1_PRINT_FUNCTION ( stname ) DECLARE_ASN1_PRINT_FUNCTION_fname ( stname , stname ) # define DECLARE_ASN1_PRINT_FUNCTION_fname ( stname , fname ) int fname ## _print_ctx ( BIO * out , stname * x , int indent , const ASN1_PCTX * pctx ) ;
# define D2I_OF ( type ) type * ( * ) ( type * * , const unsigned char * * , long ) # define I2D_OF ( type ) int ( * ) ( type * , unsigned char * * ) # define I2D_OF_const ( type ) int ( * ) ( const type * , unsigned char * * ) # define CHECKED_D2I_OF ( type , d2i ) ( ( d2i_of_void * ) ( 1 ? d2i : ( ( D2I_OF ( type ) ) 0 ) ) ) # define CHECKED_I2D_OF ( type , i2d ) ( ( i2d_of_void * ) ( 1 ? i2d : ( ( I2D_OF ( type ) ) 0 ) ) ) # define CHECKED_NEW_OF ( type , xnew ) ( ( void * ( * ) ( void ) ) ( 1 ? xnew : ( ( type * ( * ) ( void ) ) 0 ) ) ) # define CHECKED_PTR_OF ( type , p ) ( ( void * ) ( 1 ? p : ( type * ) 0 ) ) # define CHECKED_PPTR_OF ( type , p ) ( ( void * * ) ( 1 ? p : ( type * * ) 0 ) ) # define TYPEDEF_D2I_OF ( type ) typedef type * d2i_of_ ## type ( type * * , const unsigned char * * , long ) # define TYPEDEF_I2D_OF ( type ) typedef int i2d_of_ ## type ( type * , unsigned char * * ) # define TYPEDEF_D2I2D_OF ( type ) TYPEDEF_D2I_OF ( type ) ;
TYPEDEF_I2D_OF ( type ) TYPEDEF_D2I2D_OF ( void ) ;
# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION typedef const ASN1_ITEM ASN1_ITEM_EXP ;
# define ASN1_ITEM_ptr ( iptr ) ( iptr ) # define ASN1_ITEM_ref ( iptr ) ( & ( iptr ## _it ) ) # define ASN1_ITEM_rptr ( ref ) ( & ( ref ## _it ) ) # define DECLARE_ASN1_ITEM ( name ) OPENSSL_EXTERN const ASN1_ITEM name ## _it ;
# else typedef const ASN1_ITEM * ASN1_ITEM_EXP ( void ) ;
# define ASN1_ITEM_ptr ( iptr ) ( iptr ( ) ) # define ASN1_ITEM_ref ( iptr ) ( iptr ## _it ) # define ASN1_ITEM_rptr ( ref ) ( ref ## _it ( ) ) # define DECLARE_ASN1_ITEM ( name ) const ASN1_ITEM * name ## _it ( void ) ;
# endif # define ASN1_STRFLGS_ESC_2253 1 # define ASN1_STRFLGS_ESC_CTRL 2 # define ASN1_STRFLGS_ESC_MSB 4 # define ASN1_STRFLGS_ESC_QUOTE 8 # define CHARTYPE_PRINTABLESTRING 0x10 # define CHARTYPE_FIRST_ESC_2253 0x20 # define CHARTYPE_LAST_ESC_2253 0x40 # define ASN1_STRFLGS_UTF8_CONVERT 0x10 # define ASN1_STRFLGS_IGNORE_TYPE 0x20 # define ASN1_STRFLGS_SHOW_TYPE 0x40 # define ASN1_STRFLGS_DUMP_ALL 0x80 # define ASN1_STRFLGS_DUMP_UNKNOWN 0x100 # define ASN1_STRFLGS_DUMP_DER 0x200 # define ASN1_STRFLGS_ESC_2254 0x400 # define ASN1_STRFLGS_RFC2253 ( ASN1_STRFLGS_ESC_2253 | ASN1_STRFLGS_ESC_CTRL | ASN1_STRFLGS_ESC_MSB | ASN1_STRFLGS_UTF8_CONVERT | ASN1_STRFLGS_DUMP_UNKNOWN | ASN1_STRFLGS_DUMP_DER ) DEFINE_STACK_OF ( ASN1_INTEGER ) DEFINE_STACK_OF ( ASN1_GENERALSTRING ) DEFINE_STACK_OF ( ASN1_UTF8STRING ) typedef struct asn1_type_st {
int type ;
union {
char * ptr ;
ASN1_BOOLEAN boolean ;
ASN1_STRING * asn1_string ;
ASN1_OBJECT * object ;
ASN1_INTEGER * integer ;
ASN1_ENUMERATED * enumerated ;
ASN1_BIT_STRING * bit_string ;
ASN1_OCTET_STRING * octet_string ;
ASN1_PRINTABLESTRING * printablestring ;
ASN1_T61STRING * t61string ;
ASN1_IA5STRING * ia5string ;
ASN1_GENERALSTRING * generalstring ;
ASN1_BMPSTRING * bmpstring ;
ASN1_UNIVERSALSTRING * universalstring ;
ASN1_UTCTIME * utctime ;
ASN1_GENERALIZEDTIME * generalizedtime ;
ASN1_VISIBLESTRING * visiblestring ;
ASN1_UTF8STRING * utf8string ;
ASN1_STRING * set ;
ASN1_STRING * sequence ;
ASN1_VALUE * asn1_value ;
}
value ;
}
ASN1_TYPE ;
DEFINE_STACK_OF ( ASN1_TYPE ) typedef STACK_OF ( ASN1_TYPE ) ASN1_SEQUENCE_ANY ;
DECLARE_ASN1_ENCODE_FUNCTIONS_const ( ASN1_SEQUENCE_ANY , ASN1_SEQUENCE_ANY ) DECLARE_ASN1_ENCODE_FUNCTIONS_const ( ASN1_SEQUENCE_ANY , ASN1_SET_ANY ) typedef struct BIT_STRING_BITNAME_st {
int bitnum ;
const char * lname ;
const char * sname ;
}
BIT_STRING_BITNAME ;
# define B_ASN1_TIME B_ASN1_UTCTIME | B_ASN1_GENERALIZEDTIME # define B_ASN1_PRINTABLE B_ASN1_NUMERICSTRING | B_ASN1_PRINTABLESTRING | B_ASN1_T61STRING | B_ASN1_IA5STRING | B_ASN1_BIT_STRING | B_ASN1_UNIVERSALSTRING | B_ASN1_BMPSTRING | B_ASN1_UTF8STRING | B_ASN1_SEQUENCE | B_ASN1_UNKNOWN # define B_ASN1_DIRECTORYSTRING B_ASN1_PRINTABLESTRING | B_ASN1_TELETEXSTRING | B_ASN1_BMPSTRING | B_ASN1_UNIVERSALSTRING | B_ASN1_UTF8STRING # define B_ASN1_DISPLAYTEXT B_ASN1_IA5STRING | B_ASN1_VISIBLESTRING | B_ASN1_BMPSTRING | B_ASN1_UTF8STRING DECLARE_ASN1_FUNCTIONS_fname ( ASN1_TYPE , ASN1_ANY , ASN1_TYPE ) int ASN1_TYPE_get ( const ASN1_TYPE * a ) ;
void ASN1_TYPE_set ( ASN1_TYPE * a , int type , void * value ) ;
int ASN1_TYPE_set1 ( ASN1_TYPE * a , int type , const void * value ) ;
int ASN1_TYPE_cmp ( const ASN1_TYPE * a , const ASN1_TYPE * b ) ;
ASN1_TYPE * ASN1_TYPE_pack_sequence ( const ASN1_ITEM * it , void * s , ASN1_TYPE * * t ) ;
void * ASN1_TYPE_unpack_sequence ( const ASN1_ITEM * it , const ASN1_TYPE * t ) ;
ASN1_OBJECT * ASN1_OBJECT_new ( void ) ;
void ASN1_OBJECT_free ( ASN1_OBJECT * a ) ;
int i2d_ASN1_OBJECT ( const ASN1_OBJECT * a , unsigned char * * pp ) ;
ASN1_OBJECT * d2i_ASN1_OBJECT ( ASN1_OBJECT * * a , const unsigned char * * pp , long length ) ;
DECLARE_ASN1_ITEM ( ASN1_OBJECT ) DEFINE_STACK_OF ( ASN1_OBJECT ) ASN1_STRING * ASN1_STRING_new ( void ) ;
void ASN1_STRING_free ( ASN1_STRING * a ) ;
void ASN1_STRING_clear_free ( ASN1_STRING * a ) ;
int ASN1_STRING_copy ( ASN1_STRING * dst , const ASN1_STRING * str ) ;
ASN1_STRING * ASN1_STRING_dup ( const ASN1_STRING * a ) ;
ASN1_STRING * ASN1_STRING_type_new ( int type ) ;
int ASN1_STRING_cmp ( const ASN1_STRING * a , const ASN1_STRING * b ) ;
int ASN1_STRING_set ( ASN1_STRING * str , const void * data , int len ) ;
void ASN1_STRING_set0 ( ASN1_STRING * str , void * data , int len ) ;
int ASN1_STRING_length ( const ASN1_STRING * x ) ;
void ASN1_STRING_length_set ( ASN1_STRING * x , int n ) ;
int ASN1_STRING_type ( const ASN1_STRING * x ) ;
DEPRECATEDIN_1_1_0 ( unsigned char * ASN1_STRING_data ( ASN1_STRING * x ) ) const unsigned char * ASN1_STRING_get0_data ( const ASN1_STRING * x ) ;
DECLARE_ASN1_FUNCTIONS ( ASN1_BIT_STRING ) int ASN1_BIT_STRING_set ( ASN1_BIT_STRING * a , unsigned char * d , int length ) ;
int ASN1_BIT_STRING_set_bit ( ASN1_BIT_STRING * a , int n , int value ) ;
int ASN1_BIT_STRING_get_bit ( const ASN1_BIT_STRING * a , int n ) ;
int ASN1_BIT_STRING_check ( const ASN1_BIT_STRING * a , const unsigned char * flags , int flags_len ) ;
int ASN1_BIT_STRING_name_print ( BIO * out , ASN1_BIT_STRING * bs , BIT_STRING_BITNAME * tbl , int indent ) ;
int ASN1_BIT_STRING_num_asc ( const char * name , BIT_STRING_BITNAME * tbl ) ;
int ASN1_BIT_STRING_set_asc ( ASN1_BIT_STRING * bs , const char * name , int value , BIT_STRING_BITNAME * tbl ) ;
DECLARE_ASN1_FUNCTIONS ( ASN1_INTEGER ) ASN1_INTEGER * d2i_ASN1_UINTEGER ( ASN1_INTEGER * * a , const unsigned char * * pp , long length ) ;
ASN1_INTEGER * ASN1_INTEGER_dup ( const ASN1_INTEGER * x ) ;
int ASN1_INTEGER_cmp ( const ASN1_INTEGER * x , const ASN1_INTEGER * y ) ;
DECLARE_ASN1_FUNCTIONS ( ASN1_ENUMERATED ) int ASN1_UTCTIME_check ( const ASN1_UTCTIME * a ) ;
ASN1_UTCTIME * ASN1_UTCTIME_set ( ASN1_UTCTIME * s , time_t t ) ;
ASN1_UTCTIME * ASN1_UTCTIME_adj ( ASN1_UTCTIME * s , time_t t , int offset_day , long offset_sec ) ;
int ASN1_UTCTIME_set_string ( ASN1_UTCTIME * s , const char * str ) ;
int ASN1_UTCTIME_cmp_time_t ( const ASN1_UTCTIME * s , time_t t ) ;
int ASN1_GENERALIZEDTIME_check ( const ASN1_GENERALIZEDTIME * a ) ;
ASN1_GENERALIZEDTIME * ASN1_GENERALIZEDTIME_set ( ASN1_GENERALIZEDTIME * s , time_t t ) ;
ASN1_GENERALIZEDTIME * ASN1_GENERALIZEDTIME_adj ( ASN1_GENERALIZEDTIME * s , time_t t , int offset_day , long offset_sec ) ;
int ASN1_GENERALIZEDTIME_set_string ( ASN1_GENERALIZEDTIME * s , const char * str ) ;
int ASN1_TIME_diff ( int * pday , int * psec , const ASN1_TIME * from , const ASN1_TIME * to ) ;
DECLARE_ASN1_FUNCTIONS ( ASN1_OCTET_STRING ) ASN1_OCTET_STRING * ASN1_OCTET_STRING_dup ( const ASN1_OCTET_STRING * a ) ;
int ASN1_OCTET_STRING_cmp ( const ASN1_OCTET_STRING * a , const ASN1_OCTET_STRING * b ) ;
int ASN1_OCTET_STRING_set ( ASN1_OCTET_STRING * str , const unsigned char * data , int len ) ;
DECLARE_ASN1_FUNCTIONS ( ASN1_VISIBLESTRING ) DECLARE_ASN1_FUNCTIONS ( ASN1_UNIVERSALSTRING ) DECLARE_ASN1_FUNCTIONS ( ASN1_UTF8STRING ) DECLARE_ASN1_FUNCTIONS ( ASN1_NULL ) DECLARE_ASN1_FUNCTIONS ( ASN1_BMPSTRING ) int UTF8_getc ( const unsigned char * str , int len , unsigned long * val ) ;
int UTF8_putc ( unsigned char * str , int len , unsigned long value ) ;
DECLARE_ASN1_FUNCTIONS_name ( ASN1_STRING , ASN1_PRINTABLE ) DECLARE_ASN1_FUNCTIONS_name ( ASN1_STRING , DIRECTORYSTRING ) DECLARE_ASN1_FUNCTIONS_name ( ASN1_STRING , DISPLAYTEXT ) DECLARE_ASN1_FUNCTIONS ( ASN1_PRINTABLESTRING ) DECLARE_ASN1_FUNCTIONS ( ASN1_T61STRING ) | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void link_info_stop ( NautilusDirectory * directory ) {
NautilusFile * file ;
if ( directory -> details -> link_info_read_state != NULL ) {
file = directory -> details -> link_info_read_state -> file ;
if ( file != NULL ) {
g_assert ( NAUTILUS_IS_FILE ( file ) ) ;
g_assert ( file -> details -> directory == directory ) ;
if ( is_needy ( file , lacks_link_info , REQUEST_LINK_INFO ) ) {
return ;
}
}
link_info_cancel ( directory ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int com_charset ( String * buffer __attribute__ ( ( unused ) ) , char * line ) {
char buff [ 256 ] , * param ;
CHARSET_INFO * new_cs ;
strmake_buf ( buff , line ) ;
param = get_arg ( buff , 0 ) ;
if ( ! param || ! * param ) {
return put_info ( "Usage: \\C charset_name | charset charset_name" , INFO_ERROR , 0 ) ;
}
new_cs = get_charset_by_csname ( param , MY_CS_PRIMARY , MYF ( MY_WME ) ) ;
if ( new_cs ) {
charset_info = new_cs ;
mysql_set_character_set ( & mysql , charset_info -> csname ) ;
default_charset = ( char * ) charset_info -> csname ;
put_info ( "Charset changed" , INFO_INFO ) ;
}
else put_info ( "Charset is not found" , INFO_INFO ) ;
return 0 ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static void dtap_mm_id_resp ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo _U_ , guint32 offset , guint len ) {
guint32 curr_offset ;
guint32 consumed ;
guint curr_len ;
curr_offset = offset ;
curr_len = len ;
is_uplink = IS_UPLINK_TRUE ;
ELEM_MAND_LV ( GSM_A_PDU_TYPE_COMMON , DE_MID , NULL ) ;
ELEM_OPT_TV_SHORT ( 0xE0 , GSM_A_PDU_TYPE_GM , DE_PTMSI_TYPE , NULL ) ;
ELEM_OPT_TLV ( 0x1B , GSM_A_PDU_TYPE_GM , DE_RAI_2 , " - Routing area identification" ) ;
ELEM_OPT_TLV ( 0x19 , GSM_A_PDU_TYPE_GM , DE_P_TMSI_SIG_2 , " - P-TMSI signature" ) ;
EXTRANEOUS_DATA_CHECK ( curr_len , 0 , pinfo , & ei_gsm_a_dtap_extraneous_data ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_h225_OBJECT_IDENTIFIER ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
offset = dissect_per_object_identifier ( tvb , offset , actx , tree , hf_index , NULL ) ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | PHP_FUNCTION ( uwsgi_rpc ) {
int num_args = 0 ;
int i ;
char * node = NULL ;
char * func = NULL ;
zval * * * varargs = NULL ;
zval * z_current_obj ;
char * argv [ 256 ] ;
uint16_t argvs [ 256 ] ;
uint64_t size = 0 ;
if ( zend_parse_parameters ( ZEND_NUM_ARGS ( ) TSRMLS_CC , "+" , & varargs , & num_args ) == FAILURE ) {
RETURN_NULL ( ) ;
}
if ( num_args < 2 ) goto clear ;
if ( num_args > 256 + 2 ) goto clear ;
z_current_obj = * varargs [ 0 ] ;
if ( Z_TYPE_P ( z_current_obj ) != IS_STRING ) {
goto clear ;
}
node = Z_STRVAL_P ( z_current_obj ) ;
z_current_obj = * varargs [ 1 ] ;
if ( Z_TYPE_P ( z_current_obj ) != IS_STRING ) {
goto clear ;
}
func = Z_STRVAL_P ( z_current_obj ) ;
for ( i = 0 ;
i < ( num_args - 2 ) ;
i ++ ) {
z_current_obj = * varargs [ i + 2 ] ;
if ( Z_TYPE_P ( z_current_obj ) != IS_STRING ) {
goto clear ;
}
argv [ i ] = Z_STRVAL_P ( z_current_obj ) ;
argvs [ i ] = Z_STRLEN_P ( z_current_obj ) ;
}
char * response = uwsgi_do_rpc ( node , func , num_args - 2 , argv , argvs , & size ) ;
if ( response ) {
char * ret = estrndup ( response , size ) ;
free ( response ) ;
# ifdef UWSGI_PHP7 RETURN_STRING ( ret ) ;
# else RETURN_STRING ( ret , 0 ) ;
# endif }
clear : efree ( varargs ) ;
RETURN_NULL ( ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void do_block ( enum block_cmd cmd , struct st_command * command ) {
char * p = command -> first_argument ;
const char * expr_start , * expr_end ;
VAR v ;
const char * cmd_name = ( cmd == cmd_while ? "while" : "if" ) ;
my_bool not_expr = FALSE ;
DBUG_ENTER ( "do_block" ) ;
DBUG_PRINT ( "enter" , ( "%s" , cmd_name ) ) ;
if ( cur_block == block_stack_end ) die ( "Nesting too deeply" ) ;
cur_block -> line = parser . current_line ++ ;
if ( ! cur_block -> ok ) {
cur_block ++ ;
cur_block -> cmd = cmd ;
cur_block -> ok = FALSE ;
cur_block -> delim [ 0 ] = '\0' ;
DBUG_VOID_RETURN ;
}
expr_start = strchr ( p , '(' ) ;
if ( ! expr_start ++ ) die ( "missing '(' in %s" , cmd_name ) ;
while ( my_isspace ( charset_info , * expr_start ) ) expr_start ++ ;
if ( * expr_start == '!' ) {
not_expr = TRUE ;
expr_start ++ ;
while ( * expr_start && my_isspace ( charset_info , * expr_start ) ) expr_start ++ ;
}
expr_end = strrchr ( expr_start , ')' ) ;
if ( ! expr_end ) die ( "missing ')' in %s" , cmd_name ) ;
p = ( char * ) expr_end + 1 ;
while ( * p && my_isspace ( charset_info , * p ) ) p ++ ;
if ( * p && * p != '{
' ) die ( "Missing '{
' after %s. Found \"%s\"" , cmd_name , p ) ;
var_init ( & v , 0 , 0 , 0 , 0 ) ;
if ( * expr_start == '$' ) {
const char * curr_ptr = expr_end ;
eval_expr ( & v , expr_start , & curr_ptr , true ) ;
while ( my_isspace ( charset_info , * ++ curr_ptr ) ) {
}
if ( curr_ptr == expr_end ) goto NO_COMPARE ;
enum block_op operand = find_operand ( curr_ptr ) ;
if ( operand == ILLEG_OP ) die ( "Found junk '%.*s' after $variable in condition" , ( int ) ( expr_end - curr_ptr ) , curr_ptr ) ;
if ( not_expr ) die ( "Negation and comparison should not be combined, please rewrite" ) ;
if ( operand == LT_OP || operand == GT_OP ) {
curr_ptr ++ ;
}
else {
curr_ptr += 2 ;
}
while ( my_isspace ( charset_info , * curr_ptr ) ) curr_ptr ++ ;
if ( curr_ptr == expr_end ) die ( "Missing right operand in comparison" ) ;
while ( my_isspace ( charset_info , expr_end [ - 1 ] ) ) expr_end -- ;
if ( * curr_ptr == '\'' || * curr_ptr == '"' ) {
if ( expr_end [ - 1 ] != * curr_ptr ) die ( "Unterminated string value" ) ;
curr_ptr ++ ;
expr_end -- ;
}
VAR v2 ;
var_init ( & v2 , 0 , 0 , 0 , 0 ) ;
eval_expr ( & v2 , curr_ptr , & expr_end ) ;
if ( ( operand != EQ_OP && operand != NE_OP ) && ! ( v . is_int && v2 . is_int ) ) die ( "Only == and != are supported for string values" ) ;
switch ( operand ) {
case EQ_OP : if ( v . is_int ) v . int_val = ( v2 . is_int && v2 . int_val == v . int_val ) ;
else v . int_val = ! strcmp ( v . str_val , v2 . str_val ) ;
break ;
case NE_OP : if ( v . is_int ) v . int_val = ! ( v2 . is_int && v2 . int_val == v . int_val ) ;
else v . int_val = ( strcmp ( v . str_val , v2 . str_val ) != 0 ) ;
break ;
case LT_OP : v . int_val = ( v . int_val < v2 . int_val ) ;
break ;
case LE_OP : v . int_val = ( v . int_val <= v2 . int_val ) ;
break ;
case GT_OP : v . int_val = ( v . int_val > v2 . int_val ) ;
break ;
case GE_OP : v . int_val = ( v . int_val >= v2 . int_val ) ;
break ;
case ILLEG_OP : die ( "Impossible operator, this cannot happen" ) ;
}
v . is_int = TRUE ;
var_free ( & v2 ) ;
}
else {
if ( * expr_start != '`' && ! my_isdigit ( charset_info , * expr_start ) ) die ( "Expression in if/while must beging with $, ` or a number" ) ;
eval_expr ( & v , expr_start , & expr_end ) ;
}
NO_COMPARE : cur_block ++ ;
cur_block -> cmd = cmd ;
if ( v . is_int ) {
cur_block -> ok = ( v . int_val != 0 ) ;
}
else {
p = v . str_val ;
while ( * p && ( ( my_isspace ( charset_info , * p ) || * p == '-' || * p == '+' ) ) ) p ++ ;
cur_block -> ok = ( * p && * p != '0' ) ? TRUE : FALSE ;
}
if ( not_expr ) cur_block -> ok = ! cur_block -> ok ;
if ( cur_block -> ok ) {
cur_block -> delim [ 0 ] = '\0' ;
}
else {
strcpy ( cur_block -> delim , delimiter ) ;
}
DBUG_PRINT ( "info" , ( "OK: %d" , cur_block -> ok ) ) ;
var_free ( & v ) ;
DBUG_VOID_RETURN ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | SPL_METHOD ( SplFileObject , key ) {
spl_filesystem_object * intern = ( spl_filesystem_object * ) zend_object_store_get_object ( getThis ( ) TSRMLS_CC ) ;
if ( zend_parse_parameters_none ( ) == FAILURE ) {
return ;
}
RETURN_LONG ( intern -> u . file . current_line_num ) ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static inline void timerblock_update_irq ( TimerBlock * tb ) {
qemu_set_irq ( tb -> irq , tb -> status ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void thumbnail_read_callback ( GObject * source_object , GAsyncResult * res , gpointer user_data ) {
ThumbnailState * state ;
gsize file_size ;
char * file_contents ;
gboolean result ;
NautilusDirectory * directory ;
GdkPixbuf * pixbuf ;
GFile * location ;
state = user_data ;
if ( state -> directory == NULL ) {
thumbnail_state_free ( state ) ;
return ;
}
directory = nautilus_directory_ref ( state -> directory ) ;
result = g_file_load_contents_finish ( G_FILE ( source_object ) , res , & file_contents , & file_size , NULL , NULL ) ;
pixbuf = NULL ;
if ( result ) {
pixbuf = get_pixbuf_for_content ( file_size , file_contents ) ;
g_free ( file_contents ) ;
}
if ( pixbuf == NULL && state -> trying_original ) {
state -> trying_original = FALSE ;
location = g_file_new_for_path ( state -> file -> details -> thumbnail_path ) ;
g_file_load_contents_async ( location , state -> cancellable , thumbnail_read_callback , state ) ;
g_object_unref ( location ) ;
}
else {
state -> directory -> details -> thumbnail_state = NULL ;
async_job_end ( state -> directory , "thumbnail" ) ;
thumbnail_got_pixbuf ( state -> directory , state -> file , pixbuf , state -> tried_original ) ;
thumbnail_state_free ( state ) ;
}
nautilus_directory_unref ( directory ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void alljoyn_typeid ( gchar * result , guint32 type ) {
g_snprintf ( result , ITEM_LABEL_LENGTH , "'%c' => " , type ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void PNGAPI png_set_sBIT ( png_structp png_ptr , png_infop info_ptr , png_color_8p sig_bit ) {
png_debug1 ( 1 , "in %s storage function" , "sBIT" ) ;
if ( png_ptr == NULL || info_ptr == NULL ) return ;
png_memcpy ( & ( info_ptr -> sig_bit ) , sig_bit , png_sizeof ( png_color_8 ) ) ;
info_ptr -> valid |= PNG_INFO_sBIT ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static guint32 parse_wbxml_tag_defined ( proto_tree * tree , tvbuff_t * tvb , guint32 offset , guint32 str_tbl , guint8 * level , guint8 * codepage_stag , guint8 * codepage_attr , const wbxml_decoding * map ) {
guint32 tvb_len = tvb_reported_length ( tvb ) ;
guint32 off = offset ;
guint32 len ;
guint str_len ;
guint32 ent ;
guint32 idx ;
guint8 peek ;
guint32 tag_len ;
guint8 tag_save_known = 0 ;
guint8 tag_new_known = 0 ;
const char * tag_save_literal ;
const char * tag_new_literal ;
guint8 parsing_tag_content = FALSE ;
tag_save_literal = NULL ;
DebugLog ( ( "parse_wbxml_tag_defined (level = %u, offset = %u)\n" , * level , offset ) ) ;
while ( off < tvb_len ) {
peek = tvb_get_guint8 ( tvb , off ) ;
DebugLog ( ( "STAG: (top of while) level = %3u, peek = 0x%02X, off = %u, tvb_len = %u\n" , * level , peek , off , tvb_len ) ) ;
if ( ( peek & 0x3F ) < 4 ) switch ( peek ) {
case 0x00 : * codepage_stag = tvb_get_guint8 ( tvb , off + 1 ) ;
proto_tree_add_text ( tree , tvb , off , 2 , " | Tag | T -->%3d " "| SWITCH_PAGE (Tag code page) " "|" , * codepage_stag ) ;
off += 2 ;
break ;
case 0x01 : if ( tag_save_known ) {
proto_tree_add_text ( tree , tvb , off , 1 , " %3d | Tag | T %3d " "| END (Known Tag 0x%02X) " "| %s</%s>" , * level , * codepage_stag , tag_save_known , Indent ( * level ) , tag_save_literal ) ;
}
else {
proto_tree_add_text ( tree , tvb , off , 1 , " %3d | Tag | T %3d " "| END (Literal Tag) " "| %s</%s>" , * level , * codepage_stag , Indent ( * level ) , tag_save_literal ? tag_save_literal : "" ) ;
}
( * level ) -- ;
off ++ ;
DebugLog ( ( "STAG: level = %u, Return: len = %u\n" , * level , off - offset ) ) ;
return ( off - offset ) ;
case 0x02 : ent = tvb_get_guintvar ( tvb , off + 1 , & len ) ;
proto_tree_add_text ( tree , tvb , off , 1 + len , " %3d | Tag | T %3d " "| ENTITY " "| %s'&#%u;
'" , * level , * codepage_stag , Indent ( * level ) , ent ) ;
off += 1 + len ;
break ;
case 0x03 : len = tvb_strsize ( tvb , off + 1 ) ;
proto_tree_add_text ( tree , tvb , off , 1 + len , " %3d | Tag | T %3d " "| STR_I (Inline string) " "| %s\'%s\'" , * level , * codepage_stag , Indent ( * level ) , tvb_format_text ( tvb , off + 1 , len - 1 ) ) ;
off += 1 + len ;
break ;
case 0x40 : case 0x41 : case 0x42 : len = tvb_strsize ( tvb , off + 1 ) ;
proto_tree_add_text ( tree , tvb , off , 1 + len , " %3d | Tag | T %3d " "| EXT_I_%1x (Extension Token) " "| %s(%s: \'%s\')" , * level , * codepage_stag , peek & 0x0f , Indent ( * level ) , map_token ( map -> global , 0 , peek ) , tvb_format_text ( tvb , off + 1 , len - 1 ) ) ;
off += 1 + len ;
break ;
case 0x43 : proto_tree_add_text ( tree , tvb , off , 1 , " %3d | Tag | T %3d " "| PI (XML Processing Instruction) " "| %s<?xml" , * level , * codepage_stag , Indent ( * level ) ) ;
len = parse_wbxml_attribute_list_defined ( tree , tvb , off , str_tbl , * level , codepage_attr , map ) ;
off += len ;
if ( off >= tvb_len ) {
DebugLog ( ( "STAG: level = %u, ThrowException: len = %u (short frame)\n" , * level , off - offset ) ) ;
THROW ( ReportedBoundsError ) ;
}
proto_tree_add_text ( tree , tvb , off - 1 , 1 , " %3d | Tag | T %3d " "| END (PI) " "| %s?>" , * level , * codepage_stag , Indent ( * level ) ) ;
break ;
case 0x80 : case 0x81 : case 0x82 : idx = tvb_get_guintvar ( tvb , off + 1 , & len ) ;
{
char * s ;
if ( map -> ext_t [ peek & 0x03 ] ) s = ( map -> ext_t [ peek & 0x03 ] ) ( tvb , idx , str_tbl ) ;
else s = wmem_strdup_printf ( wmem_packet_scope ( ) , "EXT_T_%1x (%s)" , peek & 0x03 , map_token ( map -> global , 0 , peek ) ) ;
proto_tree_add_text ( tree , tvb , off , 1 + len , " %3d | Tag | T %3d " "| EXT_T_%1x (Extension Token) " "| %s%s" , * level , * codepage_stag , peek & 0x0f , Indent ( * level ) , s ) ;
}
off += 1 + len ;
break ;
case 0x83 : idx = tvb_get_guintvar ( tvb , off + 1 , & len ) ;
str_len = tvb_strsize ( tvb , str_tbl + idx ) ;
proto_tree_add_text ( tree , tvb , off , 1 + len , " %3d | Tag | T %3d " "| STR_T (Tableref string) " "| %s\'%s\'" , * level , * codepage_stag , Indent ( * level ) , tvb_format_text ( tvb , str_tbl + idx , str_len - 1 ) ) ;
off += 1 + len ;
break ;
case 0xC0 : case 0xC1 : case 0xC2 : proto_tree_add_text ( tree , tvb , off , 1 , " %3d | Tag | T %3d " "| EXT_%1x (Extension Token) " "| %s(%s)" , * level , * codepage_stag , peek & 0x0f , Indent ( * level ) , map_token ( map -> global , 0 , peek ) ) ;
off ++ ;
break ;
case 0xC3 : if ( tvb_get_guint8 ( tvb , 0 ) ) {
char * str ;
if ( tag_save_known ) {
if ( map -> opaque_binary_tag ) {
str = map -> opaque_binary_tag ( tvb , off + 1 , tag_save_known , * codepage_stag , & len ) ;
}
else {
str = default_opaque_binary_tag ( tvb , off + 1 , tag_save_known , * codepage_stag , & len ) ;
}
}
else {
if ( map -> opaque_literal_tag ) {
str = map -> opaque_literal_tag ( tvb , off + 1 , tag_save_literal , * codepage_stag , & len ) ;
}
else {
str = default_opaque_literal_tag ( tvb , off + 1 , tag_save_literal , * codepage_stag , & len ) ;
}
}
proto_tree_add_text ( tree , tvb , off , 1 + len , " %3d | Tag | T %3d " "| OPAQUE (Opaque data) " "| %s%s" , * level , * codepage_stag , Indent ( * level ) , str ) ;
off += 1 + len ;
}
else {
proto_tree_add_text ( tree , tvb , off , 1 , " %3d | Tag | T %3d " "| RESERVED_2 (Invalid Token!) " "| WBXML 1.0 parsing stops here." , * level , * codepage_stag ) ;
off = tvb_len ;
DebugLog ( ( "STAG: level = %u, Return: len = %u\n" , * level , off - offset ) ) ;
return ( off - offset ) ;
}
break ;
}
else {
tag_len = 0 ;
if ( ( peek & 0x3F ) == 4 ) {
DebugLog ( ( "STAG: LITERAL tag (peek = 0x%02X, off = %u) - TableRef follows!\n" , peek , off ) ) ;
idx = tvb_get_guintvar ( tvb , off + 1 , & tag_len ) ;
str_len = tvb_strsize ( tvb , str_tbl + idx ) ;
tag_new_literal = ( const gchar * ) tvb_get_ptr ( tvb , str_tbl + idx , str_len ) ;
tag_new_known = 0 ;
}
else {
tag_new_known = peek & 0x3F ;
tag_new_literal = map_token ( map -> tags , * codepage_stag , tag_new_known ) ;
}
if ( peek & 0x40 ) {
if ( parsing_tag_content ) {
DebugLog ( ( "STAG: Tag in Tag - RECURSE! (off = %u)\n" , off ) ) ;
( * level ) ++ ;
len = parse_wbxml_tag_defined ( tree , tvb , off , str_tbl , level , codepage_stag , codepage_attr , map ) ;
off += len ;
}
else {
if ( ( peek & 0x3F ) == 4 ) {
tag_save_literal = tag_new_literal ;
tag_save_known = 0 ;
}
else {
tag_save_known = tag_new_known ;
tag_save_literal = tag_new_literal ;
}
if ( peek & 0x80 ) {
if ( tag_new_known ) {
proto_tree_add_text ( tree , tvb , off , 1 , " %3d | Tag | T %3d " "| Known Tag 0x%02X (AC) " "| %s<%s" , * level , * codepage_stag , tag_new_known , Indent ( * level ) , tag_new_literal ) ;
off ++ ;
}
else {
proto_tree_add_text ( tree , tvb , off , 1 , " %3d | Tag | T %3d " "| LITERAL_AC (Literal tag) (AC) " "| %s<%s" , * level , * codepage_stag , Indent ( * level ) , tag_new_literal ) ;
off += 1 + tag_len ;
}
len = parse_wbxml_attribute_list_defined ( tree , tvb , off , str_tbl , * level , codepage_attr , map ) ;
off += len ;
if ( off >= tvb_len ) {
DebugLog ( ( "STAG: level = %u, ThrowException: len = %u (short frame)\n" , * level , off - offset ) ) ;
THROW ( ReportedBoundsError ) ;
}
proto_tree_add_text ( tree , tvb , off - 1 , 1 , " %3d | Tag | T %3d " "| END (attribute list) " "| %s>" , * level , * codepage_stag , Indent ( * level ) ) ;
}
else {
if ( tag_new_known ) {
proto_tree_add_text ( tree , tvb , off , 1 , " %3d | Tag | T %3d " "| Known Tag 0x%02X (.C) " "| %s<%s>" , * level , * codepage_stag , tag_new_known , Indent ( * level ) , tag_new_literal ) ;
off ++ ;
}
else {
proto_tree_add_text ( tree , tvb , off , 1 , " %3d | Tag | T %3d " "| LITERAL_C (Literal Tag) (.C) " "| %s<%s>" , * level , * codepage_stag , Indent ( * level ) , tag_new_literal ) ;
off += 1 + tag_len ;
}
}
parsing_tag_content = TRUE ;
DebugLog ( ( "Tag in Tag - No recursion this time! (off = %u)\n" , off ) ) ;
}
}
else {
DebugLog ( ( "<Tag/> in Tag - No recursion! (off = %u)\n" , off ) ) ;
( * level ) ++ ;
if ( peek & 0x80 ) {
if ( tag_new_known ) {
proto_tree_add_text ( tree , tvb , off , 1 , " %3d | Tag | T %3d " "| Known Tag 0x%02X (A.) " "| %s<%s" , * level , * codepage_stag , tag_new_known , Indent ( * level ) , tag_new_literal ) ;
off ++ ;
len = parse_wbxml_attribute_list_defined ( tree , tvb , off , str_tbl , * level , codepage_attr , map ) ;
off += len ;
if ( off > tvb_len ) {
DebugLog ( ( "STAG: level = %u, ThrowException: len = %u (short frame)\n" , * level , off - offset ) ) ;
THROW ( ReportedBoundsError ) ;
}
proto_tree_add_text ( tree , tvb , off - 1 , 1 , " %3d | Tag | T %3d " "| END (Known Tag) " "| %s/>" , * level , * codepage_stag , Indent ( * level ) ) ;
}
else {
proto_tree_add_text ( tree , tvb , off , 1 , " %3d | Tag | T %3d " "| LITERAL_A (Literal Tag) (A.) " "| %s<%s" , * level , * codepage_stag , Indent ( * level ) , tag_new_literal ) ;
off += 1 + tag_len ;
len = parse_wbxml_attribute_list_defined ( tree , tvb , off , str_tbl , * level , codepage_attr , map ) ;
off += len ;
if ( off >= tvb_len ) {
DebugLog ( ( "STAG: level = %u, ThrowException: len = %u (short frame)\n" , * level , off - offset ) ) ;
THROW ( ReportedBoundsError ) ;
}
proto_tree_add_text ( tree , tvb , off - 1 , 1 , " %3d | Tag | T %3d " "| END (Literal Tag) " "| %s/>" , * level , * codepage_stag , Indent ( * level ) ) ;
}
}
else {
if ( tag_new_known ) {
proto_tree_add_text ( tree , tvb , off , 1 , " %3d | Tag | T %3d " "| Known Tag 0x%02x (..) " "| %s<%s />" , * level , * codepage_stag , tag_new_known , Indent ( * level ) , tag_new_literal ) ;
off ++ ;
}
else {
proto_tree_add_text ( tree , tvb , off , 1 , " %3d | Tag | T %3d " "| LITERAL (Literal Tag) (..) " "| %s<%s />" , * level , * codepage_stag , Indent ( * level ) , tag_new_literal ) ;
off += 1 + tag_len ;
}
}
( * level ) -- ;
}
}
}
DebugLog ( ( "STAG: level = %u, Return: len = %u (end of function body)\n" , * level , off - offset ) ) ;
return ( off - offset ) ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static void config_destroy_func ( void * data ) {
ConfigData * config = ( ConfigData * ) data ;
TSfree ( config ) ;
return ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void usage_exit ( ) {
fprintf ( stderr , "Usage: %s <codec> <width> <height> <infile> <outfile>\n" , exec_name ) ;
exit ( EXIT_FAILURE ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | const EVP_CIPHER * EVP_aes_256_wrap_pad ( void ) {
return & aes_256_wrap_pad ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void dissect_zcl_color_control_move_color ( tvbuff_t * tvb , proto_tree * tree , guint * offset ) {
proto_tree_add_item ( tree , hf_zbee_zcl_color_control_rate_X , tvb , * offset , 2 , ENC_LITTLE_ENDIAN ) ;
* offset += 2 ;
proto_tree_add_item ( tree , hf_zbee_zcl_color_control_rate_Y , tvb , * offset , 2 , ENC_LITTLE_ENDIAN ) ;
* offset += 2 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | GHashTable * prplcb_ui_info ( ) {
static GHashTable * ret ;
if ( ret == NULL ) {
ret = g_hash_table_new ( g_str_hash , g_str_equal ) ;
g_hash_table_insert ( ret , "name" , "BitlBee" ) ;
g_hash_table_insert ( ret , "version" , BITLBEE_VERSION ) ;
}
return ret ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void pk_proxy_appeared_cb ( GObject * source , GAsyncResult * res , gpointer user_data ) {
ActivateParametersInstall * parameters_install = user_data ;
char * mime_type , * name_owner ;
char * error_message ;
GtkWidget * dialog ;
GDBusProxy * proxy ;
GError * error = NULL ;
proxy = g_dbus_proxy_new_for_bus_finish ( res , & error ) ;
name_owner = g_dbus_proxy_get_name_owner ( proxy ) ;
if ( error != NULL || name_owner == NULL ) {
g_warning ( "Couldn't call Modify on the PackageKit interface: %s" , error != NULL ? error -> message : "no owner for PackageKit" ) ;
g_clear_error ( & error ) ;
show_unhandled_type_error ( parameters_install ) ;
return ;
}
g_free ( name_owner ) ;
mime_type = nautilus_file_get_mime_type ( parameters_install -> file ) ;
error_message = get_application_no_mime_type_handler_message ( parameters_install -> file , parameters_install -> uri ) ;
dialog = gtk_message_dialog_new ( parameters_install -> parent_window , 0 , GTK_MESSAGE_ERROR , GTK_BUTTONS_YES_NO , "%s" , error_message ) ;
gtk_message_dialog_format_secondary_text ( GTK_MESSAGE_DIALOG ( dialog ) , _ ( "There is no application installed for “%s” files.\n" "Do you want to search for an application to open this file?" ) , g_content_type_get_description ( mime_type ) ) ;
gtk_window_set_resizable ( GTK_WINDOW ( dialog ) , FALSE ) ;
parameters_install -> dialog = dialog ;
parameters_install -> proxy = proxy ;
g_signal_connect ( dialog , "response" , G_CALLBACK ( application_unhandled_file_install ) , parameters_install ) ;
g_signal_connect ( dialog , "delete-event" , G_CALLBACK ( delete_cb ) , NULL ) ;
gtk_widget_show_all ( dialog ) ;
g_free ( mime_type ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void dumpsid ( FILE * cfff , struct alltabs * at , char * str , int oper ) {
if ( str == NULL ) return ;
dumpint ( cfff , storesid ( at , str ) ) ;
dumpoper ( cfff , oper ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void finalize_common ( CommonJob * common ) {
nautilus_progress_info_finish ( common -> progress ) ;
if ( common -> inhibit_cookie != 0 ) {
gtk_application_uninhibit ( GTK_APPLICATION ( g_application_get_default ( ) ) , common -> inhibit_cookie ) ;
}
common -> inhibit_cookie = 0 ;
g_timer_destroy ( common -> time ) ;
if ( common -> parent_window ) {
g_object_remove_weak_pointer ( G_OBJECT ( common -> parent_window ) , ( gpointer * ) & common -> parent_window ) ;
}
if ( common -> skip_files ) {
g_hash_table_destroy ( common -> skip_files ) ;
}
if ( common -> skip_readdir_error ) {
g_hash_table_destroy ( common -> skip_readdir_error ) ;
}
if ( common -> undo_info != NULL ) {
nautilus_file_undo_manager_set_action ( common -> undo_info ) ;
g_object_unref ( common -> undo_info ) ;
}
g_object_unref ( common -> progress ) ;
g_object_unref ( common -> cancellable ) ;
g_free ( common ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | INDIC_TABLE_ELEMENT_TYPE hb_indic_get_categories ( hb_codepoint_t u ) {
switch ( u >> 12 ) {
case 0x0u : if ( hb_in_range ( u , 0x0028u , 0x003Fu ) ) return indic_table [ u - 0x0028u + indic_offset_0x0028u ] ;
if ( hb_in_range ( u , 0x00D0u , 0x00D7u ) ) return indic_table [ u - 0x00D0u + indic_offset_0x00d0u ] ;
if ( hb_in_range ( u , 0x0900u , 0x0DF7u ) ) return indic_table [ u - 0x0900u + indic_offset_0x0900u ] ;
if ( unlikely ( u == 0x00A0u ) ) return _ ( CP , x ) ;
break ;
case 0x1u : if ( hb_in_range ( u , 0x1000u , 0x109Fu ) ) return indic_table [ u - 0x1000u + indic_offset_0x1000u ] ;
if ( hb_in_range ( u , 0x1700u , 0x17EFu ) ) return indic_table [ u - 0x1700u + indic_offset_0x1700u ] ;
if ( hb_in_range ( u , 0x1900u , 0x1A9Fu ) ) return indic_table [ u - 0x1900u + indic_offset_0x1900u ] ;
if ( hb_in_range ( u , 0x1B00u , 0x1C4Fu ) ) return indic_table [ u - 0x1B00u + indic_offset_0x1b00u ] ;
if ( hb_in_range ( u , 0x1CD0u , 0x1CF7u ) ) return indic_table [ u - 0x1CD0u + indic_offset_0x1cd0u ] ;
break ;
case 0x2u : if ( hb_in_range ( u , 0x2008u , 0x2017u ) ) return indic_table [ u - 0x2008u + indic_offset_0x2008u ] ;
if ( unlikely ( u == 0x25CCu ) ) return _ ( CP , x ) ;
break ;
case 0xAu : if ( hb_in_range ( u , 0xA800u , 0xAAF7u ) ) return indic_table [ u - 0xA800u + indic_offset_0xa800u ] ;
if ( hb_in_range ( u , 0xABC0u , 0xABFFu ) ) return indic_table [ u - 0xABC0u + indic_offset_0xabc0u ] ;
break ;
case 0x10u : if ( hb_in_range ( u , 0x10A00u , 0x10A47u ) ) return indic_table [ u - 0x10A00u + indic_offset_0x10a00u ] ;
break ;
case 0x11u : if ( hb_in_range ( u , 0x11000u , 0x110BFu ) ) return indic_table [ u - 0x11000u + indic_offset_0x11000u ] ;
if ( hb_in_range ( u , 0x11100u , 0x11237u ) ) return indic_table [ u - 0x11100u + indic_offset_0x11100u ] ;
if ( hb_in_range ( u , 0x112B0u , 0x11377u ) ) return indic_table [ u - 0x112B0u + indic_offset_0x112b0u ] ;
if ( hb_in_range ( u , 0x11480u , 0x114DFu ) ) return indic_table [ u - 0x11480u + indic_offset_0x11480u ] ;
if ( hb_in_range ( u , 0x11580u , 0x115C7u ) ) return indic_table [ u - 0x11580u + indic_offset_0x11580u ] ;
if ( hb_in_range ( u , 0x11600u , 0x116CFu ) ) return indic_table [ u - 0x11600u + indic_offset_0x11600u ] ;
break ;
default : break ;
}
return _ ( x , x ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_rsl_ie_multirate_cntrl ( tvbuff_t * tvb , packet_info * pinfo _U_ , proto_tree * tree , int offset , gboolean is_mandatory ) {
proto_tree * ie_tree ;
guint8 ie_id ;
if ( is_mandatory == FALSE ) {
ie_id = tvb_get_guint8 ( tvb , offset ) ;
if ( ie_id != RSL_IE_MULTIRATE_CNTRL ) return offset ;
}
ie_tree = proto_tree_add_subtree ( tree , tvb , offset , 2 , ett_ie_multirate_cntrl , NULL , "MultiRate Control IE" ) ;
proto_tree_add_item ( ie_tree , hf_rsl_ie_id , tvb , offset , 1 , ENC_BIG_ENDIAN ) ;
offset ++ ;
offset ++ ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | const uint8_t * avpriv_mpv_find_start_code ( const uint8_t * restrict p , const uint8_t * end , uint32_t * restrict state ) {
int i ;
assert ( p <= end ) ;
if ( p >= end ) return end ;
for ( i = 0 ;
i < 3 ;
i ++ ) {
uint32_t tmp = * state << 8 ;
* state = tmp + * ( p ++ ) ;
if ( tmp == 0x100 || p == end ) return p ;
}
while ( p < end ) {
if ( p [ - 1 ] > 1 ) p += 3 ;
else if ( p [ - 2 ] ) p += 2 ;
else if ( p [ - 3 ] | ( p [ - 1 ] - 1 ) ) p ++ ;
else {
p ++ ;
break ;
}
}
p = FFMIN ( p , end ) - 4 ;
* state = AV_RB32 ( p ) ;
return p + 4 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | bool sp_revoke_privileges ( THD * thd , const char * sp_db , const char * sp_name , bool is_proc ) {
uint counter , revoked ;
int result ;
TABLE_LIST tables [ GRANT_TABLES ] ;
HASH * hash = is_proc ? & proc_priv_hash : & func_priv_hash ;
Silence_routine_definer_errors error_handler ;
bool save_binlog_row_based ;
DBUG_ENTER ( "sp_revoke_privileges" ) ;
if ( ( result = open_grant_tables ( thd , tables ) ) ) DBUG_RETURN ( result != 1 ) ;
thd -> push_internal_handler ( & error_handler ) ;
rw_wrlock ( & LOCK_grant ) ;
VOID ( pthread_mutex_lock ( & acl_cache -> lock ) ) ;
save_binlog_row_based = thd -> current_stmt_binlog_row_based ;
thd -> clear_current_stmt_binlog_row_based ( ) ;
do {
for ( counter = 0 , revoked = 0 ;
counter < hash -> records ;
) {
GRANT_NAME * grant_proc = ( GRANT_NAME * ) hash_element ( hash , counter ) ;
if ( ! my_strcasecmp ( & my_charset_utf8_bin , grant_proc -> db , sp_db ) && ! my_strcasecmp ( system_charset_info , grant_proc -> tname , sp_name ) ) {
LEX_USER lex_user ;
lex_user . user . str = grant_proc -> user ;
lex_user . user . length = strlen ( grant_proc -> user ) ;
lex_user . host . str = grant_proc -> host . hostname ? grant_proc -> host . hostname : ( char * ) "" ;
lex_user . host . length = grant_proc -> host . hostname ? strlen ( grant_proc -> host . hostname ) : 0 ;
if ( replace_routine_table ( thd , grant_proc , tables [ 4 ] . table , lex_user , grant_proc -> db , grant_proc -> tname , is_proc , ~ ( ulong ) 0 , 1 ) == 0 ) {
revoked = 1 ;
continue ;
}
}
counter ++ ;
}
}
while ( revoked ) ;
VOID ( pthread_mutex_unlock ( & acl_cache -> lock ) ) ;
rw_unlock ( & LOCK_grant ) ;
close_thread_tables ( thd ) ;
thd -> pop_internal_handler ( ) ;
thd -> current_stmt_binlog_row_based = save_binlog_row_based ;
DBUG_RETURN ( error_handler . has_errors ( ) ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | BerElement * ber_alloc_t ( int options ) {
BerElement * ber ;
ber = ( BerElement * ) LBER_CALLOC ( 1 , sizeof ( BerElement ) ) ;
if ( ber == NULL ) {
return NULL ;
}
ber -> ber_valid = LBER_VALID_BERELEMENT ;
ber -> ber_tag = LBER_DEFAULT ;
ber -> ber_options = options ;
ber -> ber_debug = ber_int_debug ;
assert ( LBER_VALID ( ber ) ) ;
return ber ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static vpx_codec_err_t extract_option ( LAYER_OPTION_TYPE type , char * input , int * value0 , int * value1 ) {
if ( type == SCALE_FACTOR ) {
* value0 = strtol ( input , & input , 10 ) ;
if ( * input ++ != '/' ) return VPX_CODEC_INVALID_PARAM ;
* value1 = strtol ( input , & input , 10 ) ;
if ( * value0 < option_min_values [ SCALE_FACTOR ] || * value1 < option_min_values [ SCALE_FACTOR ] || * value0 > option_max_values [ SCALE_FACTOR ] || * value1 > option_max_values [ SCALE_FACTOR ] || * value0 > * value1 ) return VPX_CODEC_INVALID_PARAM ;
}
else {
* value0 = atoi ( input ) ;
if ( * value0 < option_min_values [ type ] || * value0 > option_max_values [ type ] ) return VPX_CODEC_INVALID_PARAM ;
}
return VPX_CODEC_OK ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int slirp_hostfwd ( SlirpState * s , const char * redir_str , int legacy_format ) {
struct in_addr host_addr = {
. s_addr = INADDR_ANY }
;
struct in_addr guest_addr = {
. s_addr = 0 }
;
int host_port , guest_port ;
const char * p ;
char buf [ 256 ] ;
int is_udp ;
char * end ;
p = redir_str ;
if ( ! p || get_str_sep ( buf , sizeof ( buf ) , & p , ':' ) < 0 ) {
goto fail_syntax ;
}
if ( ! strcmp ( buf , "tcp" ) || buf [ 0 ] == '\0' ) {
is_udp = 0 ;
}
else if ( ! strcmp ( buf , "udp" ) ) {
is_udp = 1 ;
}
else {
goto fail_syntax ;
}
if ( ! legacy_format ) {
if ( get_str_sep ( buf , sizeof ( buf ) , & p , ':' ) < 0 ) {
goto fail_syntax ;
}
if ( buf [ 0 ] != '\0' && ! inet_aton ( buf , & host_addr ) ) {
goto fail_syntax ;
}
}
if ( get_str_sep ( buf , sizeof ( buf ) , & p , legacy_format ? ':' : '-' ) < 0 ) {
goto fail_syntax ;
}
host_port = strtol ( buf , & end , 0 ) ;
if ( * end != '\0' || host_port < 1 || host_port > 65535 ) {
goto fail_syntax ;
}
if ( get_str_sep ( buf , sizeof ( buf ) , & p , ':' ) < 0 ) {
goto fail_syntax ;
}
if ( buf [ 0 ] != '\0' && ! inet_aton ( buf , & guest_addr ) ) {
goto fail_syntax ;
}
guest_port = strtol ( p , & end , 0 ) ;
if ( * end != '\0' || guest_port < 1 || guest_port > 65535 ) {
goto fail_syntax ;
}
if ( slirp_add_hostfwd ( s -> slirp , is_udp , host_addr , host_port , guest_addr , guest_port ) < 0 ) {
error_report ( "could not set up host forwarding rule '%s'" , redir_str ) ;
return - 1 ;
}
return 0 ;
fail_syntax : error_report ( "invalid host forwarding rule '%s'" , redir_str ) ;
return - 1 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static Asn1Generic * Asn1GenericNew ( void ) {
Asn1Generic * obj ;
obj = SCMalloc ( sizeof ( Asn1Generic ) ) ;
if ( obj != NULL ) memset ( obj , 0 , sizeof ( Asn1Generic ) ) ;
return obj ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static __always_inline __be16 __cpu_to_be16p ( const __u16 * p ) {
return ( __be16 ) __swab16p ( p ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int myisamchk ( MI_CHECK * param , char * filename ) {
int error , lock_type , recreate ;
int rep_quick = param -> testflag & ( T_QUICK | T_FORCE_UNIQUENESS ) ;
MI_INFO * info ;
File datafile ;
char llbuff [ 22 ] , llbuff2 [ 22 ] ;
my_bool state_updated = 0 ;
MYISAM_SHARE * share ;
DBUG_ENTER ( "myisamchk" ) ;
param -> out_flag = error = param -> warning_printed = param -> error_printed = recreate = 0 ;
datafile = 0 ;
param -> isam_file_name = filename ;
if ( ! ( info = mi_open ( filename , ( param -> testflag & ( T_DESCRIPT | T_READONLY ) ) ? O_RDONLY : O_RDWR , HA_OPEN_FOR_REPAIR | ( ( param -> testflag & T_WAIT_FOREVER ) ? HA_OPEN_WAIT_IF_LOCKED : ( param -> testflag & T_DESCRIPT ) ? HA_OPEN_IGNORE_IF_LOCKED : HA_OPEN_ABORT_IF_LOCKED ) ) ) ) {
param -> error_printed = 1 ;
switch ( my_errno ) {
case HA_ERR_CRASHED : mi_check_print_error ( param , "'%s' doesn't have a correct index definition. You need to recreate it before you can do a repair" , filename ) ;
break ;
case HA_ERR_NOT_A_TABLE : mi_check_print_error ( param , "'%s' is not a MyISAM-table" , filename ) ;
break ;
case HA_ERR_CRASHED_ON_USAGE : mi_check_print_error ( param , "'%s' is marked as crashed" , filename ) ;
break ;
case HA_ERR_CRASHED_ON_REPAIR : mi_check_print_error ( param , "'%s' is marked as crashed after last repair" , filename ) ;
break ;
case HA_ERR_OLD_FILE : mi_check_print_error ( param , "'%s' is an old type of MyISAM-table" , filename ) ;
break ;
case HA_ERR_END_OF_FILE : mi_check_print_error ( param , "Couldn't read complete header from '%s'" , filename ) ;
break ;
case EAGAIN : mi_check_print_error ( param , "'%s' is locked. Use -w to wait until unlocked" , filename ) ;
break ;
case ENOENT : mi_check_print_error ( param , "File '%s' doesn't exist" , filename ) ;
break ;
case EACCES : mi_check_print_error ( param , "You don't have permission to use '%s'" , filename ) ;
break ;
default : mi_check_print_error ( param , "%d when opening MyISAM-table '%s'" , my_errno , filename ) ;
break ;
}
DBUG_RETURN ( 1 ) ;
}
share = info -> s ;
share -> options &= ~ HA_OPTION_READ_ONLY_DATA ;
share -> tot_locks -= share -> r_locks ;
share -> r_locks = 0 ;
if ( param -> testflag & ( T_FAST | T_CHECK_ONLY_CHANGED ) ) {
my_bool need_to_check = mi_is_crashed ( info ) || share -> state . open_count != 0 ;
if ( ( param -> testflag & ( T_REP_ANY | T_SORT_RECORDS ) ) && ( ( share -> state . changed & ( STATE_CHANGED | STATE_CRASHED | STATE_CRASHED_ON_REPAIR ) || ! ( param -> testflag & T_CHECK_ONLY_CHANGED ) ) ) ) need_to_check = 1 ;
if ( info -> s -> base . keys && info -> state -> records ) {
if ( ( param -> testflag & T_STATISTICS ) && ( share -> state . changed & STATE_NOT_ANALYZED ) ) need_to_check = 1 ;
if ( ( param -> testflag & T_SORT_INDEX ) && ( share -> state . changed & STATE_NOT_SORTED_PAGES ) ) need_to_check = 1 ;
if ( ( param -> testflag & T_REP_BY_SORT ) && ( share -> state . changed & STATE_NOT_OPTIMIZED_KEYS ) ) need_to_check = 1 ;
}
if ( ( param -> testflag & T_CHECK_ONLY_CHANGED ) && ( share -> state . changed & ( STATE_CHANGED | STATE_CRASHED | STATE_CRASHED_ON_REPAIR ) ) ) need_to_check = 1 ;
if ( ! need_to_check ) {
if ( ! ( param -> testflag & T_SILENT ) || param -> testflag & T_INFO ) printf ( "MyISAM file: %s is already checked\n" , filename ) ;
if ( mi_close ( info ) ) {
mi_check_print_error ( param , "%d when closing MyISAM-table '%s'" , my_errno , filename ) ;
DBUG_RETURN ( 1 ) ;
}
DBUG_RETURN ( 0 ) ;
}
}
if ( ( param -> testflag & ( T_REP_ANY | T_STATISTICS | T_SORT_RECORDS | T_SORT_INDEX ) ) && ( ( ( param -> testflag & T_UNPACK ) && share -> data_file_type == COMPRESSED_RECORD ) || mi_uint2korr ( share -> state . header . state_info_length ) != MI_STATE_INFO_SIZE || mi_uint2korr ( share -> state . header . base_info_length ) != MI_BASE_INFO_SIZE || mi_is_any_intersect_keys_active ( param -> keys_in_use , share -> base . keys , ~ share -> state . key_map ) || test_if_almost_full ( info ) || info -> s -> state . header . file_version [ 3 ] != myisam_file_magic [ 3 ] || ( set_collation && set_collation -> number != share -> state . header . language ) || myisam_block_size != MI_KEY_BLOCK_LENGTH ) ) {
if ( set_collation ) param -> language = set_collation -> number ;
if ( recreate_table ( param , & info , filename ) ) {
( void ) fprintf ( stderr , "MyISAM-table '%s' is not fixed because of errors\n" , filename ) ;
return ( - 1 ) ;
}
recreate = 1 ;
if ( ! ( param -> testflag & T_REP_ANY ) ) {
param -> testflag |= T_REP_BY_SORT ;
if ( ! ( param -> testflag & T_SILENT ) ) printf ( "- '%s' has old table-format. Recreating index\n" , filename ) ;
rep_quick |= T_QUICK ;
}
share = info -> s ;
share -> tot_locks -= share -> r_locks ;
share -> r_locks = 0 ;
}
if ( param -> testflag & T_DESCRIPT ) {
param -> total_files ++ ;
param -> total_records += info -> state -> records ;
param -> total_deleted += info -> state -> del ;
descript ( param , info , filename ) ;
}
else {
if ( ! stopwords_inited ++ ) ft_init_stopwords ( ) ;
if ( ! ( param -> testflag & T_READONLY ) ) lock_type = F_WRLCK ;
else lock_type = F_RDLCK ;
if ( info -> lock_type == F_RDLCK ) info -> lock_type = F_UNLCK ;
if ( _mi_readinfo ( info , lock_type , 0 ) ) {
mi_check_print_error ( param , "Can't lock indexfile of '%s', error: %d" , filename , my_errno ) ;
param -> error_printed = 0 ;
goto end2 ;
}
mi_lock_database ( info , F_EXTRA_LCK ) ;
datafile = info -> dfile ;
if ( param -> testflag & ( T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX ) ) {
if ( param -> testflag & T_REP_ANY ) {
ulonglong tmp = share -> state . key_map ;
mi_copy_keys_active ( share -> state . key_map , share -> base . keys , param -> keys_in_use ) ;
if ( tmp != share -> state . key_map ) info -> update |= HA_STATE_CHANGED ;
}
if ( rep_quick && chk_del ( param , info , param -> testflag & ~ T_VERBOSE ) ) {
if ( param -> testflag & T_FORCE_CREATE ) {
rep_quick = 0 ;
mi_check_print_info ( param , "Creating new data file\n" ) ;
}
else {
error = 1 ;
mi_check_print_error ( param , "Quick-recover aborted;
Run recovery without switch 'q'" ) ;
}
}
if ( ! error ) {
if ( ( param -> testflag & ( T_REP_BY_SORT | T_REP_PARALLEL ) ) && ( mi_is_any_key_active ( share -> state . key_map ) || ( rep_quick && ! param -> keys_in_use && ! recreate ) ) && mi_test_if_sort_rep ( info , info -> state -> records , info -> s -> state . key_map , param -> force_sort ) ) {
if ( param -> testflag & T_REP_BY_SORT ) error = mi_repair_by_sort ( param , info , filename , rep_quick ) ;
else error = mi_repair_parallel ( param , info , filename , rep_quick ) ;
state_updated = 1 ;
}
else if ( param -> testflag & T_REP_ANY ) error = mi_repair ( param , info , filename , rep_quick ) ;
}
if ( ! error && param -> testflag & T_SORT_RECORDS ) {
# ifndef TO_BE_REMOVED if ( param -> out_flag & O_NEW_DATA ) {
( void ) my_close ( info -> dfile , MYF ( MY_WME ) ) ;
error |= change_to_newfile ( filename , MI_NAME_DEXT , DATA_TMP_EXT , MYF ( 0 ) ) ;
if ( mi_open_datafile ( info , info -> s , NULL , - 1 ) ) error = 1 ;
param -> out_flag &= ~ O_NEW_DATA ;
param -> read_cache . file = info -> dfile ;
}
# endif if ( ! error ) {
uint key ;
my_bool update_index = 1 ;
for ( key = 0 ;
key < share -> base . keys ;
key ++ ) if ( share -> keyinfo [ key ] . flag & ( HA_BINARY_PACK_KEY | HA_FULLTEXT ) ) update_index = 0 ;
error = mi_sort_records ( param , info , filename , param -> opt_sort_key , ( my_bool ) ! ( param -> testflag & T_REP ) , update_index ) ;
datafile = info -> dfile ;
if ( ! error && ! update_index ) {
if ( param -> verbose ) puts ( "Table had a compressed index;
We must now recreate the index" ) ;
error = mi_repair_by_sort ( param , info , filename , 1 ) ;
}
}
}
if ( ! error && param -> testflag & T_SORT_INDEX ) error = mi_sort_index ( param , info , filename ) ;
if ( ! error ) share -> state . changed &= ~ ( STATE_CHANGED | STATE_CRASHED | STATE_CRASHED_ON_REPAIR ) ;
else mi_mark_crashed ( info ) ;
}
else if ( ( param -> testflag & T_CHECK ) || ! ( param -> testflag & T_AUTO_INC ) ) {
if ( ! ( param -> testflag & T_SILENT ) || param -> testflag & T_INFO ) printf ( "Checking MyISAM file: %s\n" , filename ) ;
if ( ! ( param -> testflag & T_SILENT ) ) printf ( "Data records: %7s Deleted blocks: %7s\n" , llstr ( info -> state -> records , llbuff ) , llstr ( info -> state -> del , llbuff2 ) ) ;
error = chk_status ( param , info ) ;
mi_intersect_keys_active ( share -> state . key_map , param -> keys_in_use ) ;
error = chk_size ( param , info ) ;
if ( ! error || ! ( param -> testflag & ( T_FAST | T_FORCE_CREATE ) ) ) error |= chk_del ( param , info , param -> testflag ) ;
if ( ( ! error || ( ! ( param -> testflag & ( T_FAST | T_FORCE_CREATE ) ) && ! param -> start_check_pos ) ) ) {
error |= chk_key ( param , info ) ;
if ( ! error && ( param -> testflag & ( T_STATISTICS | T_AUTO_INC ) ) ) error = update_state_info ( param , info , ( ( param -> testflag & T_STATISTICS ) ? UPDATE_STAT : 0 ) | ( ( param -> testflag & T_AUTO_INC ) ? UPDATE_AUTO_INC : 0 ) ) ;
}
if ( ( ! rep_quick && ! error ) || ! ( param -> testflag & ( T_FAST | T_FORCE_CREATE ) ) ) {
if ( param -> testflag & ( T_EXTEND | T_MEDIUM ) ) ( void ) init_key_cache ( dflt_key_cache , opt_key_cache_block_size , param -> use_buffers , 0 , 0 ) ;
( void ) init_io_cache ( & param -> read_cache , datafile , ( uint ) param -> read_buffer_length , READ_CACHE , ( param -> start_check_pos ? param -> start_check_pos : share -> pack . header_length ) , 1 , MYF ( MY_WME ) ) ;
lock_memory ( param ) ;
if ( ( info -> s -> options & ( HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD ) ) || ( param -> testflag & ( T_EXTEND | T_MEDIUM ) ) ) error |= chk_data_link ( param , info , param -> testflag & T_EXTEND ) ;
error |= flush_blocks ( param , share -> key_cache , share -> kfile ) ;
( void ) end_io_cache ( & param -> read_cache ) ;
}
if ( ! error ) {
if ( ( share -> state . changed & STATE_CHANGED ) && ( param -> testflag & T_UPDATE_STATE ) ) info -> update |= HA_STATE_CHANGED | HA_STATE_ROW_CHANGED ;
share -> state . changed &= ~ ( STATE_CHANGED | STATE_CRASHED | STATE_CRASHED_ON_REPAIR ) ;
}
else if ( ! mi_is_crashed ( info ) && ( param -> testflag & T_UPDATE_STATE ) ) {
mi_mark_crashed ( info ) ;
info -> update |= HA_STATE_CHANGED | HA_STATE_ROW_CHANGED ;
}
}
}
if ( ( param -> testflag & T_AUTO_INC ) || ( ( param -> testflag & T_REP_ANY ) && info -> s -> base . auto_key ) ) update_auto_increment_key ( param , info , ( my_bool ) ! test ( param -> testflag & T_AUTO_INC ) ) ;
if ( ! ( param -> testflag & T_DESCRIPT ) ) {
if ( info -> update & HA_STATE_CHANGED && ! ( param -> testflag & T_READONLY ) ) error |= update_state_info ( param , info , UPDATE_OPEN_COUNT | ( ( ( param -> testflag & T_REP_ANY ) ? UPDATE_TIME : 0 ) | ( state_updated ? UPDATE_STAT : 0 ) | ( ( param -> testflag & T_SORT_RECORDS ) ? UPDATE_SORT : 0 ) ) ) ;
( void ) lock_file ( param , share -> kfile , 0L , F_UNLCK , "indexfile" , filename ) ;
info -> update &= ~ HA_STATE_CHANGED ;
}
mi_lock_database ( info , F_UNLCK ) ;
end2 : if ( mi_close ( info ) ) {
mi_check_print_error ( param , "%d when closing MyISAM-table '%s'" , my_errno , filename ) ;
DBUG_RETURN ( 1 ) ;
}
if ( error == 0 ) {
if ( param -> out_flag & O_NEW_DATA ) error |= change_to_newfile ( filename , MI_NAME_DEXT , DATA_TMP_EXT , ( ( param -> testflag & T_BACKUP_DATA ) ? MYF ( MY_REDEL_MAKE_BACKUP ) : MYF ( 0 ) ) ) ;
if ( param -> out_flag & O_NEW_INDEX ) error |= change_to_newfile ( filename , MI_NAME_IEXT , INDEX_TMP_EXT , MYF ( 0 ) ) ;
}
( void ) fflush ( stdout ) ;
( void ) fflush ( stderr ) ;
if ( param -> error_printed ) {
if ( param -> testflag & ( T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX ) ) {
( void ) fprintf ( stderr , "MyISAM-table '%s' is not fixed because of errors\n" , filename ) ;
if ( param -> testflag & T_REP_ANY ) ( void ) fprintf ( stderr , "Try fixing it by using the --safe-recover (-o), the --force (-f) option or by not using the --quick (-q) flag\n" ) ;
}
else if ( ! ( param -> error_printed & 2 ) && ! ( param -> testflag & T_FORCE_CREATE ) ) ( void ) fprintf ( stderr , "MyISAM-table '%s' is corrupted\nFix it using switch \"-r\" or \"-o\"\n" , filename ) ;
}
else if ( param -> warning_printed && ! ( param -> testflag & ( T_REP_ANY | T_SORT_RECORDS | T_SORT_INDEX | T_FORCE_CREATE ) ) ) ( void ) fprintf ( stderr , "MyISAM-table '%s' is usable but should be fixed\n" , filename ) ;
( void ) fflush ( stderr ) ;
DBUG_RETURN ( error ) ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static char * get_icu_value_internal ( const char * loc_name , char * tag_name , int * result , int fromParseLocale ) {
char * tag_value = NULL ;
int32_t tag_value_len = 512 ;
int singletonPos = 0 ;
char * mod_loc_name = NULL ;
int grOffset = 0 ;
int32_t buflen = 512 ;
UErrorCode status = U_ZERO_ERROR ;
if ( strcmp ( tag_name , LOC_CANONICALIZE_TAG ) != 0 ) {
grOffset = findOffset ( LOC_GRANDFATHERED , loc_name ) ;
if ( grOffset >= 0 ) {
if ( strcmp ( tag_name , LOC_LANG_TAG ) == 0 ) {
return estrdup ( loc_name ) ;
}
else {
return NULL ;
}
}
if ( fromParseLocale == 1 ) {
if ( strcmp ( tag_name , LOC_LANG_TAG ) == 0 ) {
if ( strlen ( loc_name ) > 1 && ( isIDPrefix ( loc_name ) == 1 ) ) {
return estrdup ( loc_name ) ;
}
}
singletonPos = getSingletonPos ( loc_name ) ;
if ( singletonPos == 0 ) {
return NULL ;
}
else if ( singletonPos > 0 ) {
mod_loc_name = estrndup ( loc_name , singletonPos - 1 ) ;
}
}
}
if ( mod_loc_name == NULL ) {
mod_loc_name = estrdup ( loc_name ) ;
}
do {
tag_value = erealloc ( tag_value , buflen ) ;
tag_value_len = buflen ;
if ( strcmp ( tag_name , LOC_SCRIPT_TAG ) == 0 ) {
buflen = uloc_getScript ( mod_loc_name , tag_value , tag_value_len , & status ) ;
}
if ( strcmp ( tag_name , LOC_LANG_TAG ) == 0 ) {
buflen = uloc_getLanguage ( mod_loc_name , tag_value , tag_value_len , & status ) ;
}
if ( strcmp ( tag_name , LOC_REGION_TAG ) == 0 ) {
buflen = uloc_getCountry ( mod_loc_name , tag_value , tag_value_len , & status ) ;
}
if ( strcmp ( tag_name , LOC_VARIANT_TAG ) == 0 ) {
buflen = uloc_getVariant ( mod_loc_name , tag_value , tag_value_len , & status ) ;
}
if ( strcmp ( tag_name , LOC_CANONICALIZE_TAG ) == 0 ) {
buflen = uloc_canonicalize ( mod_loc_name , tag_value , tag_value_len , & status ) ;
}
if ( U_FAILURE ( status ) ) {
if ( status == U_BUFFER_OVERFLOW_ERROR ) {
status = U_ZERO_ERROR ;
buflen ++ ;
continue ;
}
* result = 0 ;
if ( tag_value ) {
efree ( tag_value ) ;
}
if ( mod_loc_name ) {
efree ( mod_loc_name ) ;
}
return NULL ;
}
}
while ( buflen > tag_value_len ) ;
if ( buflen == 0 ) {
* result = - 1 ;
if ( tag_value ) {
efree ( tag_value ) ;
}
if ( mod_loc_name ) {
efree ( mod_loc_name ) ;
}
return NULL ;
}
else {
* result = 1 ;
}
if ( mod_loc_name ) {
efree ( mod_loc_name ) ;
}
return tag_value ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void pdf_set_cmap_wmode ( fz_context * ctx , pdf_cmap * cmap , int wmode ) {
cmap -> wmode = wmode ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void dissect_t38_tcp ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree ) {
primary_part = TRUE ;
if ( t38_tpkt_usage == T38_TPKT_ALWAYS ) {
dissect_tpkt_encap ( tvb , pinfo , tree , t38_tpkt_reassembly , t38_tcp_pdu_handle ) ;
}
else if ( ( t38_tpkt_usage == T38_TPKT_NEVER ) || ( is_tpkt ( tvb , 1 ) == - 1 ) ) {
dissect_t38_tcp_pdu ( tvb , pinfo , tree ) ;
}
else {
dissect_tpkt_encap ( tvb , pinfo , tree , t38_tpkt_reassembly , t38_tcp_pdu_handle ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int runandhide_restore_hidden ( i_ctx_t * i_ctx_p , ref * obj , ref * attrs ) {
os_ptr op = osp ;
push ( 1 ) ;
ref_assign ( op , obj ) ;
r_clear_attrs ( op , a_all ) ;
r_set_attrs ( op , attrs -> value . intval ) ;
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static size_t wrap_fread ( void * ptr , size_t size , size_t nmemb , FILE * stream ) {
return fread ( ptr , size , nmemb , stream ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | xmlAttrPtr xsltAttrTemplateProcess ( xsltTransformContextPtr ctxt , xmlNodePtr target , xmlAttrPtr attr ) {
const xmlChar * value ;
xmlAttrPtr ret ;
if ( ( ctxt == NULL ) || ( attr == NULL ) || ( target == NULL ) ) return ( NULL ) ;
if ( attr -> type != XML_ATTRIBUTE_NODE ) return ( NULL ) ;
# ifdef XSLT_REFACTORED if ( attr -> psvi == xsltXSLTAttrMarker ) return ( NULL ) ;
# else if ( ( attr -> ns != NULL ) && xmlStrEqual ( attr -> ns -> href , XSLT_NAMESPACE ) ) return ( NULL ) ;
# endif if ( attr -> children != NULL ) {
if ( ( attr -> children -> type != XML_TEXT_NODE ) || ( attr -> children -> next != NULL ) ) {
xsltTransformError ( ctxt , NULL , attr -> parent , "Internal error: The children of an attribute node of a " "literal result element are not in the expected form.\n" ) ;
return ( NULL ) ;
}
value = attr -> children -> content ;
if ( value == NULL ) value = xmlDictLookup ( ctxt -> dict , BAD_CAST "" , 0 ) ;
}
else value = xmlDictLookup ( ctxt -> dict , BAD_CAST "" , 0 ) ;
ret = target -> properties ;
while ( ret != NULL ) {
if ( ( ( attr -> ns != NULL ) == ( ret -> ns != NULL ) ) && xmlStrEqual ( ret -> name , attr -> name ) && ( ( attr -> ns == NULL ) || xmlStrEqual ( ret -> ns -> href , attr -> ns -> href ) ) ) {
break ;
}
ret = ret -> next ;
}
if ( ret != NULL ) {
xmlFreeNodeList ( ret -> children ) ;
ret -> children = ret -> last = NULL ;
if ( ( ret -> ns != NULL ) && ( ! xmlStrEqual ( ret -> ns -> prefix , attr -> ns -> prefix ) ) ) {
ret -> ns = xsltGetNamespace ( ctxt , attr -> parent , attr -> ns , target ) ;
}
}
else {
if ( attr -> ns != NULL ) ret = xmlNewNsProp ( target , xsltGetNamespace ( ctxt , attr -> parent , attr -> ns , target ) , attr -> name , NULL ) ;
else ret = xmlNewNsProp ( target , NULL , attr -> name , NULL ) ;
}
if ( ret != NULL ) {
xmlNodePtr text ;
text = xmlNewText ( NULL ) ;
if ( text != NULL ) {
ret -> last = ret -> children = text ;
text -> parent = ( xmlNodePtr ) ret ;
text -> doc = ret -> doc ;
if ( attr -> psvi != NULL ) {
xmlChar * val ;
val = xsltEvalAVT ( ctxt , attr -> psvi , attr -> parent ) ;
if ( val == NULL ) {
if ( attr -> ns ) {
xsltTransformError ( ctxt , NULL , attr -> parent , "Internal error: Failed to evaluate the AVT " "of attribute '{
%s}
%s'.\n" , attr -> ns -> href , attr -> name ) ;
}
else {
xsltTransformError ( ctxt , NULL , attr -> parent , "Internal error: Failed to evaluate the AVT " "of attribute '%s'.\n" , attr -> name ) ;
}
text -> content = xmlStrdup ( BAD_CAST "" ) ;
}
else {
text -> content = val ;
}
}
else if ( ( ctxt -> internalized ) && ( target != NULL ) && ( target -> doc != NULL ) && ( target -> doc -> dict == ctxt -> dict ) && xmlDictOwns ( ctxt -> dict , value ) ) {
text -> content = ( xmlChar * ) value ;
}
else {
text -> content = xmlStrdup ( value ) ;
}
}
}
else {
if ( attr -> ns ) {
xsltTransformError ( ctxt , NULL , attr -> parent , "Internal error: Failed to create attribute '{
%s}
%s'.\n" , attr -> ns -> href , attr -> name ) ;
}
else {
xsltTransformError ( ctxt , NULL , attr -> parent , "Internal error: Failed to create attribute '%s'.\n" , attr -> name ) ;
}
}
return ( ret ) ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | int jas_image_writecmpt ( jas_image_t * image , int cmptno , jas_image_coord_t x , jas_image_coord_t y , jas_image_coord_t width , jas_image_coord_t height , jas_matrix_t * data ) {
jas_image_cmpt_t * cmpt ;
jas_image_coord_t i ;
jas_image_coord_t j ;
jas_seqent_t * d ;
jas_seqent_t * dr ;
int drs ;
jas_seqent_t v ;
int k ;
int c ;
if ( cmptno < 0 || cmptno >= image -> numcmpts_ ) {
return - 1 ;
}
cmpt = image -> cmpts_ [ cmptno ] ;
if ( x >= cmpt -> width_ || y >= cmpt -> height_ || x + width > cmpt -> width_ || y + height > cmpt -> height_ ) {
return - 1 ;
}
if ( ! jas_matrix_numrows ( data ) || ! jas_matrix_numcols ( data ) ) {
return - 1 ;
}
if ( jas_matrix_numrows ( data ) != height || jas_matrix_numcols ( data ) != width ) {
return - 1 ;
}
dr = jas_matrix_getref ( data , 0 , 0 ) ;
drs = jas_matrix_rowstep ( data ) ;
for ( i = 0 ;
i < height ;
++ i , dr += drs ) {
d = dr ;
if ( jas_stream_seek ( cmpt -> stream_ , ( cmpt -> width_ * ( y + i ) + x ) * cmpt -> cps_ , SEEK_SET ) < 0 ) {
return - 1 ;
}
for ( j = width ;
j > 0 ;
-- j , ++ d ) {
v = inttobits ( * d , cmpt -> prec_ , cmpt -> sgnd_ ) ;
for ( k = cmpt -> cps_ ;
k > 0 ;
-- k ) {
c = ( v >> ( 8 * ( cmpt -> cps_ - 1 ) ) ) & 0xff ;
if ( jas_stream_putc ( cmpt -> stream_ , ( unsigned char ) c ) == EOF ) {
return - 1 ;
}
v <<= 8 ;
}
}
}
return 0 ;
} | 0False
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.