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 | void vapic_report_tpr_access ( DeviceState * dev , CPUState * cs , target_ulong ip , TPRAccess access ) {
VAPICROMState * s = DO_UPCAST ( VAPICROMState , busdev . qdev , dev ) ;
X86CPU * cpu = X86_CPU ( cs ) ;
CPUX86State * env = & cpu -> env ;
cpu_synchronize_state ( cs ) ;
if ( evaluate_tpr_instruction ( s , env , & ip , access ) < 0 ) {
if ( s -> state == VAPIC_ACTIVE ) {
vapic_enable ( s , env ) ;
}
return ;
}
if ( update_rom_mapping ( s , env , ip ) < 0 ) {
return ;
}
if ( vapic_enable ( s , env ) < 0 ) {
return ;
}
patch_instruction ( s , cpu , ip ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | PyObject * PyString_FromStringAndSize ( const char * str , Py_ssize_t size ) {
register PyStringObject * op ;
if ( size < 0 ) {
PyErr_SetString ( PyExc_SystemError , "Negative size passed to PyString_FromStringAndSize" ) ;
return NULL ;
}
if ( size == 0 && ( op = nullstring ) != NULL ) {
# ifdef COUNT_ALLOCS null_strings ++ ;
# endif Py_INCREF ( op ) ;
return ( PyObject * ) op ;
}
if ( size == 1 && str != NULL && ( op = characters [ * str & UCHAR_MAX ] ) != NULL ) {
# ifdef COUNT_ALLOCS one_strings ++ ;
# endif Py_INCREF ( op ) ;
return ( PyObject * ) op ;
}
if ( size > PY_SSIZE_T_MAX - PyStringObject_SIZE ) {
PyErr_SetString ( PyExc_OverflowError , "string is too large" ) ;
return NULL ;
}
op = ( PyStringObject * ) PyObject_MALLOC ( PyStringObject_SIZE + size ) ;
if ( op == NULL ) return PyErr_NoMemory ( ) ;
( void ) PyObject_INIT_VAR ( op , & PyString_Type , size ) ;
op -> ob_shash = - 1 ;
op -> ob_sstate = SSTATE_NOT_INTERNED ;
if ( str != NULL ) Py_MEMCPY ( op -> ob_sval , str , size ) ;
op -> ob_sval [ size ] = '\0' ;
if ( size == 0 ) {
PyObject * t = ( PyObject * ) op ;
PyString_InternInPlace ( & t ) ;
op = ( PyStringObject * ) t ;
nullstring = op ;
Py_INCREF ( op ) ;
}
else if ( size == 1 && str != NULL ) {
PyObject * t = ( PyObject * ) op ;
PyString_InternInPlace ( & t ) ;
op = ( PyStringObject * ) t ;
characters [ * str & UCHAR_MAX ] = op ;
Py_INCREF ( op ) ;
}
return ( PyObject * ) op ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void encode_frame_internal ( VP9_COMP * cpi ) {
SPEED_FEATURES * const sf = & cpi -> sf ;
RD_OPT * const rd_opt = & cpi -> rd ;
MACROBLOCK * const x = & cpi -> mb ;
VP9_COMMON * const cm = & cpi -> common ;
MACROBLOCKD * const xd = & x -> e_mbd ;
xd -> mi = cm -> mi ;
xd -> mi [ 0 ] . src_mi = & xd -> mi [ 0 ] ;
vp9_zero ( cm -> counts ) ;
vp9_zero ( cpi -> coef_counts ) ;
vp9_zero ( rd_opt -> comp_pred_diff ) ;
vp9_zero ( rd_opt -> filter_diff ) ;
vp9_zero ( rd_opt -> tx_select_diff ) ;
vp9_zero ( rd_opt -> tx_select_threshes ) ;
xd -> lossless = cm -> base_qindex == 0 && cm -> y_dc_delta_q == 0 && cm -> uv_dc_delta_q == 0 && cm -> uv_ac_delta_q == 0 ;
cm -> tx_mode = select_tx_mode ( cpi ) ;
x -> fwd_txm4x4 = xd -> lossless ? vp9_fwht4x4 : vp9_fdct4x4 ;
x -> itxm_add = xd -> lossless ? vp9_iwht4x4_add : vp9_idct4x4_add ;
if ( xd -> lossless ) {
x -> optimize = 0 ;
cm -> lf . filter_level = 0 ;
cpi -> zbin_mode_boost_enabled = 0 ;
}
vp9_frame_init_quantizer ( cpi ) ;
vp9_initialize_rd_consts ( cpi ) ;
vp9_initialize_me_consts ( cpi , cm -> base_qindex ) ;
init_encode_frame_mb_context ( cpi ) ;
set_prev_mi ( cm ) ;
x -> quant_fp = cpi -> sf . use_quant_fp ;
vp9_zero ( x -> skip_txfm ) ;
if ( sf -> use_nonrd_pick_mode ) {
int i ;
struct macroblock_plane * const p = x -> plane ;
struct macroblockd_plane * const pd = xd -> plane ;
PICK_MODE_CONTEXT * ctx = & cpi -> pc_root -> none ;
for ( i = 0 ;
i < MAX_MB_PLANE ;
++ i ) {
p [ i ] . coeff = ctx -> coeff_pbuf [ i ] [ 0 ] ;
p [ i ] . qcoeff = ctx -> qcoeff_pbuf [ i ] [ 0 ] ;
pd [ i ] . dqcoeff = ctx -> dqcoeff_pbuf [ i ] [ 0 ] ;
p [ i ] . eobs = ctx -> eobs_pbuf [ i ] [ 0 ] ;
}
vp9_zero ( x -> zcoeff_blk ) ;
if ( sf -> partition_search_type == SOURCE_VAR_BASED_PARTITION ) source_var_based_partition_search_method ( cpi ) ;
}
{
struct vpx_usec_timer emr_timer ;
vpx_usec_timer_start ( & emr_timer ) ;
# if CONFIG_FP_MB_STATS if ( cpi -> use_fp_mb_stats ) {
input_fpmb_stats ( & cpi -> twopass . firstpass_mb_stats , cm , & cpi -> twopass . this_frame_mb_stats ) ;
}
# endif encode_tiles ( cpi ) ;
vpx_usec_timer_mark ( & emr_timer ) ;
cpi -> time_encode_sb_row += vpx_usec_timer_elapsed ( & emr_timer ) ;
}
sf -> skip_encode_frame = sf -> skip_encode_sb ? get_skip_encode_frame ( cm ) : 0 ;
# if 0 cpi -> last_frame_distortion = cpi -> frame_distortion ;
# endif } | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | SPL_METHOD ( SplFileInfo , func_name ) \ {
\ spl_filesystem_object * intern = ( spl_filesystem_object * ) zend_object_store_get_object ( getThis ( ) TSRMLS_CC ) ;
\ zend_error_handling error_handling ;
\ if ( zend_parse_parameters_none ( ) == FAILURE ) {
\ return ;
\ }
\ \ zend_replace_error_handling ( EH_THROW , spl_ce_RuntimeException , & error_handling TSRMLS_CC ) ;
\ spl_filesystem_object_get_file_name ( intern TSRMLS_CC ) ;
\ php_stat ( intern -> file_name , intern -> file_name_len , func_num , return_value TSRMLS_CC ) ;
\ zend_restore_error_handling ( & error_handling TSRMLS_CC ) ;
\ }
FileInfoFunction ( getPerms , FS_PERMS ) FileInfoFunction ( getInode , FS_INODE ) | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | TEST_F ( ProtocolHandlerRegistryTest , TestSilentlyRegisterHandler ) {
ProtocolHandler ph1 = CreateProtocolHandler ( "test" , GURL ( "http://test/%s" ) , "test1" ) ;
ProtocolHandler ph2 = CreateProtocolHandler ( "test" , GURL ( "http://test/%s" ) , "test2" ) ;
ProtocolHandler ph3 = CreateProtocolHandler ( "ignore" , GURL ( "http://test/%s" ) , "ignore1" ) ;
ProtocolHandler ph4 = CreateProtocolHandler ( "ignore" , GURL ( "http://test/%s" ) , "ignore2" ) ;
ASSERT_FALSE ( registry ( ) -> SilentlyHandleRegisterHandlerRequest ( ph1 ) ) ;
ASSERT_FALSE ( registry ( ) -> IsRegistered ( ph1 ) ) ;
registry ( ) -> OnAcceptRegisterProtocolHandler ( ph1 ) ;
ASSERT_TRUE ( registry ( ) -> IsRegistered ( ph1 ) ) ;
ASSERT_TRUE ( registry ( ) -> SilentlyHandleRegisterHandlerRequest ( ph2 ) ) ;
ASSERT_FALSE ( registry ( ) -> IsRegistered ( ph1 ) ) ;
ASSERT_TRUE ( registry ( ) -> IsRegistered ( ph2 ) ) ;
ASSERT_FALSE ( registry ( ) -> SilentlyHandleRegisterHandlerRequest ( ph3 ) ) ;
ASSERT_FALSE ( registry ( ) -> IsRegistered ( ph3 ) ) ;
registry ( ) -> OnIgnoreRegisterProtocolHandler ( ph3 ) ;
ASSERT_FALSE ( registry ( ) -> IsRegistered ( ph3 ) ) ;
ASSERT_TRUE ( registry ( ) -> IsIgnored ( ph3 ) ) ;
ASSERT_TRUE ( registry ( ) -> SilentlyHandleRegisterHandlerRequest ( ph4 ) ) ;
ASSERT_FALSE ( registry ( ) -> IsRegistered ( ph4 ) ) ;
ASSERT_TRUE ( registry ( ) -> HasIgnoredEquivalent ( ph4 ) ) ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_h225_SEQUENCE_OF_RTPSession ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
offset = dissect_per_sequence_of ( tvb , offset , actx , tree , hf_index , ett_h225_SEQUENCE_OF_RTPSession , SEQUENCE_OF_RTPSession_sequence_of ) ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void set_ref ( VP9_COMMON * const cm , MACROBLOCKD * const xd , int idx , int mi_row , int mi_col ) {
MB_MODE_INFO * const mbmi = & xd -> mi [ 0 ] . src_mi -> mbmi ;
RefBuffer * ref_buffer = & cm -> frame_refs [ mbmi -> ref_frame [ idx ] - LAST_FRAME ] ;
xd -> block_refs [ idx ] = ref_buffer ;
if ( ! vp9_is_valid_scale ( & ref_buffer -> sf ) ) vpx_internal_error ( & cm -> error , VPX_CODEC_UNSUP_BITSTREAM , "Invalid scale factors" ) ;
if ( ref_buffer -> buf -> corrupted ) vpx_internal_error ( & cm -> error , VPX_CODEC_CORRUPT_FRAME , "Block reference is corrupt" ) ;
vp9_setup_pre_planes ( xd , idx , ref_buffer -> buf , mi_row , mi_col , & ref_buffer -> sf ) ;
xd -> corrupted |= ref_buffer -> buf -> corrupted ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void final_reordering ( const hb_ot_shape_plan_t * plan , hb_font_t * font HB_UNUSED , hb_buffer_t * buffer ) {
unsigned int count = buffer -> len ;
if ( unlikely ( ! count ) ) return ;
foreach_syllable ( buffer , start , end ) final_reordering_syllable ( plan , buffer , start , end ) ;
HB_BUFFER_DEALLOCATE_VAR ( buffer , indic_category ) ;
HB_BUFFER_DEALLOCATE_VAR ( buffer , indic_position ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int read_gab2_sub ( AVFormatContext * s , AVStream * st , AVPacket * pkt ) {
if ( pkt -> size >= 7 && pkt -> size < INT_MAX - AVPROBE_PADDING_SIZE && ! strcmp ( pkt -> data , "GAB2" ) && AV_RL16 ( pkt -> data + 5 ) == 2 ) {
uint8_t desc [ 256 ] ;
int score = AVPROBE_SCORE_EXTENSION , ret ;
AVIStream * ast = st -> priv_data ;
AVInputFormat * sub_demuxer ;
AVRational time_base ;
int size ;
AVIOContext * pb = avio_alloc_context ( pkt -> data + 7 , pkt -> size - 7 , 0 , NULL , NULL , NULL , NULL ) ;
AVProbeData pd ;
unsigned int desc_len = avio_rl32 ( pb ) ;
if ( desc_len > pb -> buf_end - pb -> buf_ptr ) goto error ;
ret = avio_get_str16le ( pb , desc_len , desc , sizeof ( desc ) ) ;
avio_skip ( pb , desc_len - ret ) ;
if ( * desc ) av_dict_set ( & st -> metadata , "title" , desc , 0 ) ;
avio_rl16 ( pb ) ;
avio_rl32 ( pb ) ;
size = pb -> buf_end - pb -> buf_ptr ;
pd = ( AVProbeData ) {
. buf = av_mallocz ( size + AVPROBE_PADDING_SIZE ) , . buf_size = size }
;
if ( ! pd . buf ) goto error ;
memcpy ( pd . buf , pb -> buf_ptr , size ) ;
sub_demuxer = av_probe_input_format2 ( & pd , 1 , & score ) ;
av_freep ( & pd . buf ) ;
if ( ! sub_demuxer ) goto error ;
if ( ! ( ast -> sub_ctx = avformat_alloc_context ( ) ) ) goto error ;
ast -> sub_ctx -> pb = pb ;
if ( ff_copy_whiteblacklists ( ast -> sub_ctx , s ) < 0 ) goto error ;
if ( ! avformat_open_input ( & ast -> sub_ctx , "" , sub_demuxer , NULL ) ) {
if ( ast -> sub_ctx -> nb_streams != 1 ) goto error ;
ff_read_packet ( ast -> sub_ctx , & ast -> sub_pkt ) ;
avcodec_parameters_copy ( st -> codecpar , ast -> sub_ctx -> streams [ 0 ] -> codecpar ) ;
time_base = ast -> sub_ctx -> streams [ 0 ] -> time_base ;
avpriv_set_pts_info ( st , 64 , time_base . num , time_base . den ) ;
}
ast -> sub_buffer = pkt -> data ;
memset ( pkt , 0 , sizeof ( * pkt ) ) ;
return 1 ;
error : av_freep ( & ast -> sub_ctx ) ;
av_freep ( & pb ) ;
}
return 0 ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | extern int name ( int ) __THROW __exctype ( isalnum ) ;
__exctype ( isalpha ) ;
__exctype ( iscntrl ) ;
__exctype ( isdigit ) | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int xmlThrDefIndentTreeOutput ( int v ) {
int ret ;
xmlMutexLock ( xmlThrDefMutex ) ;
ret = xmlIndentTreeOutputThrDef ;
xmlIndentTreeOutputThrDef = v ;
xmlMutexUnlock ( xmlThrDefMutex ) ;
return ret ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void decode_transform_coeffs_ch ( AC3DecodeContext * s , int blk , int ch , mant_groups * m ) {
if ( ! s -> channel_uses_aht [ ch ] ) {
ac3_decode_transform_coeffs_ch ( s , ch , m ) ;
}
else {
int bin ;
if ( ! blk && CONFIG_EAC3_DECODER ) ff_eac3_decode_transform_coeffs_aht_ch ( s , ch ) ;
for ( bin = s -> start_freq [ ch ] ;
bin < s -> end_freq [ ch ] ;
bin ++ ) {
s -> fixed_coeffs [ ch ] [ bin ] = s -> pre_mantissa [ ch ] [ bin ] [ blk ] >> s -> dexps [ ch ] [ bin ] ;
}
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | proto_item * proto_tree_add_bytes_format_value ( proto_tree * tree , int hfindex , tvbuff_t * tvb , gint start , gint length , const guint8 * start_ptr , const char * format , ... ) {
proto_item * pi ;
va_list ap ;
header_field_info * hfinfo ;
gint item_length ;
PROTO_REGISTRAR_GET_NTH ( hfindex , hfinfo ) ;
get_hfi_length ( hfinfo , tvb , start , & length , & item_length ) ;
test_length ( hfinfo , tvb , start , item_length ) ;
CHECK_FOR_NULL_TREE ( tree ) ;
TRY_TO_FAKE_THIS_ITEM ( tree , hfindex , hfinfo ) ;
if ( start_ptr ) pi = proto_tree_add_bytes ( tree , hfindex , tvb , start , length , start_ptr ) ;
else pi = proto_tree_add_bytes ( tree , hfindex , tvb , start , length , tvb_get_ptr ( tvb , start , length ) ) ;
va_start ( ap , format ) ;
proto_tree_set_representation_value ( pi , format , ap ) ;
va_end ( ap ) ;
return pi ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static time_t _zip_d2u_time ( int dtime , int ddate ) {
struct tm tm ;
memset ( & tm , 0 , sizeof ( tm ) ) ;
tm . tm_isdst = - 1 ;
tm . tm_year = ( ( ddate >> 9 ) & 127 ) + 1980 - 1900 ;
tm . tm_mon = ( ( ddate >> 5 ) & 15 ) - 1 ;
tm . tm_mday = ddate & 31 ;
tm . tm_hour = ( dtime >> 11 ) & 31 ;
tm . tm_min = ( dtime >> 5 ) & 63 ;
tm . tm_sec = ( dtime << 1 ) & 62 ;
return mktime ( & tm ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void imc_decode_level_coefficients ( IMCContext * q , int * levlCoeffBuf , float * flcoeffs1 , float * flcoeffs2 ) {
int i , level ;
float tmp , tmp2 ;
flcoeffs1 [ 0 ] = 20000.0 / pow ( 2 , levlCoeffBuf [ 0 ] * 0.18945 ) ;
flcoeffs2 [ 0 ] = log2f ( flcoeffs1 [ 0 ] ) ;
tmp = flcoeffs1 [ 0 ] ;
tmp2 = flcoeffs2 [ 0 ] ;
for ( i = 1 ;
i < BANDS ;
i ++ ) {
level = levlCoeffBuf [ i ] ;
if ( level == 16 ) {
flcoeffs1 [ i ] = 1.0 ;
flcoeffs2 [ i ] = 0.0 ;
}
else {
if ( level < 17 ) level -= 7 ;
else if ( level <= 24 ) level -= 32 ;
else level -= 16 ;
tmp *= imc_exp_tab [ 15 + level ] ;
tmp2 += 0.83048 * level ;
flcoeffs1 [ i ] = tmp ;
flcoeffs2 [ i ] = tmp2 ;
}
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static Datum ExecEvalNullIf ( FuncExprState * nullIfExpr , ExprContext * econtext , bool * isNull , ExprDoneCond * isDone ) {
Datum result ;
FunctionCallInfo fcinfo ;
ExprDoneCond argDone ;
if ( isDone ) * isDone = ExprSingleResult ;
if ( nullIfExpr -> func . fn_oid == InvalidOid ) {
NullIfExpr * op = ( NullIfExpr * ) nullIfExpr -> xprstate . expr ;
init_fcache ( op -> opfuncid , op -> inputcollid , nullIfExpr , econtext -> ecxt_per_query_memory , true ) ;
Assert ( ! nullIfExpr -> func . fn_retset ) ;
}
fcinfo = & nullIfExpr -> fcinfo_data ;
argDone = ExecEvalFuncArgs ( fcinfo , nullIfExpr -> args , econtext ) ;
if ( argDone != ExprSingleResult ) ereport ( ERROR , ( errcode ( ERRCODE_DATATYPE_MISMATCH ) , errmsg ( "NULLIF does not support set arguments" ) ) ) ;
Assert ( fcinfo -> nargs == 2 ) ;
if ( ! fcinfo -> argnull [ 0 ] && ! fcinfo -> argnull [ 1 ] ) {
fcinfo -> isnull = false ;
result = FunctionCallInvoke ( fcinfo ) ;
if ( ! fcinfo -> isnull && DatumGetBool ( result ) ) {
* isNull = true ;
return ( Datum ) 0 ;
}
}
* isNull = fcinfo -> argnull [ 0 ] ;
return fcinfo -> arg [ 0 ] ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void dissect_u3v_stream_trailer ( proto_tree * u3v_telegram_tree , tvbuff_t * tvb , packet_info * pinfo , usb_conv_info_t * usb_conv_info _U_ ) {
gint offset = 0 ;
guint64 block_id ;
proto_item * item = NULL ;
item = proto_tree_add_item ( u3v_telegram_tree , hf_u3v_stream_trailer , tvb , 0 , - 1 , ENC_NA ) ;
u3v_telegram_tree = proto_item_add_subtree ( item , ett_u3v_stream_trailer ) ;
proto_tree_add_item ( u3v_telegram_tree , hf_u3v_stream_prefix , tvb , offset , 4 , ENC_LITTLE_ENDIAN ) ;
offset += 4 ;
proto_tree_add_item ( u3v_telegram_tree , hf_u3v_stream_reserved , tvb , offset , 2 , ENC_NA ) ;
offset += 2 ;
proto_tree_add_item ( u3v_telegram_tree , hf_u3v_stream_trailer_size , tvb , offset , 2 , ENC_LITTLE_ENDIAN ) ;
offset += 2 ;
block_id = tvb_get_letoh64 ( tvb , offset ) ;
proto_tree_add_item ( u3v_telegram_tree , hf_u3v_stream_block_id , tvb , offset , 8 , ENC_LITTLE_ENDIAN ) ;
offset += 8 ;
proto_tree_add_item ( u3v_telegram_tree , hf_u3v_stream_status , tvb , offset , 2 , ENC_LITTLE_ENDIAN ) ;
offset += 2 ;
proto_tree_add_item ( u3v_telegram_tree , hf_u3v_stream_reserved , tvb , offset , 2 , ENC_NA ) ;
offset += 2 ;
proto_tree_add_item ( u3v_telegram_tree , hf_u3v_stream_valid_payload_size , tvb , offset , 8 , ENC_LITTLE_ENDIAN ) ;
offset += 8 ;
col_append_fstr ( pinfo -> cinfo , COL_INFO , "Stream Trailer [ Block ID: %" G_GINT64_MODIFIER "u]" , block_id ) ;
if ( tvb_captured_length_remaining ( tvb , offset ) >= 4 ) {
proto_tree_add_item ( u3v_telegram_tree , hf_u3v_stream_size_y , tvb , offset , 4 , ENC_LITTLE_ENDIAN ) ;
offset += 4 ;
}
if ( tvb_captured_length_remaining ( tvb , offset ) >= 4 ) {
proto_tree_add_item ( u3v_telegram_tree , hf_u3v_stream_chunk_layout_id , tvb , offset , 4 , ENC_LITTLE_ENDIAN ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void xmlrpc_char_encode ( char * outbuffer , const char * s1 ) {
long unsigned int i ;
unsigned char c ;
char buf2 [ 15 ] ;
mowgli_string_t * s = mowgli_string_create ( ) ;
* buf2 = '\0' ;
* outbuffer = '\0' ;
if ( ( ! ( s1 ) || ( * ( s1 ) == '\0' ) ) ) {
return ;
}
for ( i = 0 ;
s1 [ i ] != '\0' ;
i ++ ) {
c = s1 [ i ] ;
if ( c > 127 ) {
snprintf ( buf2 , sizeof buf2 , "&#%d;
" , c ) ;
s -> append ( s , buf2 , strlen ( buf2 ) ) ;
}
else if ( c == '&' ) {
s -> append ( s , "&
" , 5 ) ;
}
else if ( c == '<' ) {
s -> append ( s , "<
" , 4 ) ;
}
else if ( c == '>' ) {
s -> append ( s , ">
" , 4 ) ;
}
else if ( c == '"' ) {
s -> append ( s , ""
" , 6 ) ;
}
else {
s -> append_char ( s , c ) ;
}
}
memcpy ( outbuffer , s -> str , XMLRPC_BUFSIZE ) ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static gboolean has_trash_files ( GMount * mount ) {
GList * dirs , * l ;
GFile * dir ;
gboolean res ;
dirs = get_trash_dirs_for_mount ( mount ) ;
res = FALSE ;
for ( l = dirs ;
l != NULL ;
l = l -> next ) {
dir = l -> data ;
if ( dir_has_files ( dir ) ) {
res = TRUE ;
break ;
}
}
g_list_free_full ( dirs , g_object_unref ) ;
return res ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | u_short ctlsysstatus ( void ) {
register u_char this_clock ;
this_clock = CTL_SST_TS_UNSPEC ;
# ifdef REFCLOCK if ( sys_peer != NULL ) {
if ( CTL_SST_TS_UNSPEC != sys_peer -> sstclktype ) this_clock = sys_peer -> sstclktype ;
else if ( sys_peer -> refclktype < COUNTOF ( clocktypes ) ) this_clock = clocktypes [ sys_peer -> refclktype ] ;
}
# else if ( sys_peer != 0 ) this_clock = CTL_SST_TS_NTP ;
# endif return CTL_SYS_STATUS ( sys_leap , this_clock , ctl_sys_num_events , ctl_sys_last_event ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void sql_inline_error_callback ( void * arg ) {
inline_error_callback_arg * callback_arg = ( inline_error_callback_arg * ) arg ;
int syntaxerrposition ;
syntaxerrposition = geterrposition ( ) ;
if ( syntaxerrposition > 0 ) {
errposition ( 0 ) ;
internalerrposition ( syntaxerrposition ) ;
internalerrquery ( callback_arg -> prosrc ) ;
}
errcontext ( "SQL function \"%s\" during inlining" , callback_arg -> proname ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_h245_EncryptionCommand ( 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_EncryptionCommand , EncryptionCommand_choice , NULL ) ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void http_connection_test ( int persistent ) {
short port = - 1 ;
struct evhttp_connection * evcon = NULL ;
struct evhttp_request * req = NULL ;
test_ok = 0 ;
fprintf ( stdout , "Testing Request Connection Pipeline %s: " , persistent ? "(persistent)" : "" ) ;
http = http_setup ( & port , NULL ) ;
evcon = evhttp_connection_new ( "127.0.0.1" , port ) ;
if ( evcon == NULL ) {
fprintf ( stdout , "FAILED\n" ) ;
exit ( 1 ) ;
}
req = evhttp_request_new ( http_request_done , NULL ) ;
evhttp_add_header ( req -> output_headers , "Host" , "somehost" ) ;
if ( evhttp_make_request ( evcon , req , EVHTTP_REQ_GET , "/test" ) == - 1 ) {
fprintf ( stdout , "FAILED\n" ) ;
exit ( 1 ) ;
}
event_dispatch ( ) ;
if ( test_ok != 1 ) {
fprintf ( stdout , "FAILED\n" ) ;
exit ( 1 ) ;
}
test_ok = 0 ;
req = evhttp_request_new ( http_request_done , NULL ) ;
evhttp_add_header ( req -> output_headers , "Host" , "somehost" ) ;
if ( ! persistent ) evhttp_add_header ( req -> output_headers , "Connection" , "close" ) ;
if ( evhttp_make_request ( evcon , req , EVHTTP_REQ_GET , "/test" ) == - 1 ) {
fprintf ( stdout , "FAILED\n" ) ;
exit ( 1 ) ;
}
event_dispatch ( ) ;
test_ok = 0 ;
req = evhttp_request_new ( http_request_empty_done , NULL ) ;
evhttp_add_header ( req -> output_headers , "Empty" , "itis" ) ;
if ( evhttp_make_request ( evcon , req , EVHTTP_REQ_GET , "/test" ) == - 1 ) {
fprintf ( stdout , "FAILED\n" ) ;
exit ( 1 ) ;
}
event_dispatch ( ) ;
if ( test_ok != 1 ) {
fprintf ( stdout , "FAILED\n" ) ;
exit ( 1 ) ;
}
evhttp_connection_free ( evcon ) ;
evhttp_free ( http ) ;
fprintf ( stdout , "OK\n" ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void stop_server ( char * prefix , char * port ) {
char * path = NULL ;
int pid , path_size = strlen ( prefix ) + strlen ( port ) + 20 ;
path = ss_malloc ( path_size ) ;
snprintf ( path , path_size , "%s/.shadowsocks_%s.pid" , prefix , port ) ;
FILE * f = fopen ( path , "r" ) ;
if ( f == NULL ) {
if ( verbose ) {
LOGE ( "unable to open pid file" ) ;
}
ss_free ( path ) ;
return ;
}
if ( fscanf ( f , "%d" , & pid ) != EOF ) {
kill ( pid , SIGTERM ) ;
}
fclose ( f ) ;
ss_free ( path ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void test_multiplesignal ( void ) {
struct event ev_one , ev_two ;
struct itimerval itv ;
setup_test ( "Multiple signal: " ) ;
signal_set ( & ev_one , SIGALRM , signal_cb , & ev_one ) ;
signal_add ( & ev_one , NULL ) ;
signal_set ( & ev_two , SIGALRM , signal_cb , & ev_two ) ;
signal_add ( & ev_two , NULL ) ;
memset ( & itv , 0 , sizeof ( itv ) ) ;
itv . it_value . tv_sec = 1 ;
if ( setitimer ( ITIMER_REAL , & itv , NULL ) == - 1 ) goto skip_simplesignal ;
event_dispatch ( ) ;
skip_simplesignal : if ( signal_del ( & ev_one ) == - 1 ) test_ok = 0 ;
if ( signal_del ( & ev_two ) == - 1 ) test_ok = 0 ;
cleanup_test ( ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | TSAction TSHttpSchedule ( TSCont contp , TSHttpTxn txnp , ink_hrtime timeout ) {
sdk_assert ( sdk_sanity_check_iocore_structure ( contp ) == TS_SUCCESS ) ;
FORCE_PLUGIN_SCOPED_MUTEX ( contp ) ;
INKContInternal * i = ( INKContInternal * ) contp ;
if ( ink_atomic_increment ( ( int * ) & i -> m_event_count , 1 ) < 0 ) {
ink_assert ( ! "not reached" ) ;
}
TSAction action ;
Continuation * cont = ( Continuation * ) contp ;
HttpSM * sm = ( HttpSM * ) txnp ;
sm -> set_http_schedule ( cont ) ;
if ( timeout == 0 ) {
action = reinterpret_cast < TSAction > ( eventProcessor . schedule_imm ( sm , ET_NET ) ) ;
}
else {
action = reinterpret_cast < TSAction > ( eventProcessor . schedule_in ( sm , HRTIME_MSECONDS ( timeout ) , ET_NET ) ) ;
}
action = ( TSAction ) ( ( uintptr_t ) action | 0x1 ) ;
return action ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | bool metakey_h ( connection_t * c ) {
char buffer [ MAX_STRING_SIZE ] ;
int cipher , digest , maclength , compression ;
int len ;
if ( sscanf ( c -> buffer , "%*d %d %d %d %d " MAX_STRING , & cipher , & digest , & maclength , & compression , buffer ) != 5 ) {
logger ( LOG_ERR , "Got bad %s from %s (%s)" , "METAKEY" , c -> name , c -> hostname ) ;
return false ;
}
len = RSA_size ( myself -> connection -> rsa_key ) ;
if ( strlen ( buffer ) != ( size_t ) len * 2 ) {
logger ( LOG_ERR , "Possible intruder %s (%s): %s" , c -> name , c -> hostname , "wrong keylength" ) ;
return false ;
}
c -> inkey = xrealloc ( c -> inkey , len ) ;
if ( ! c -> inctx ) {
c -> inctx = EVP_CIPHER_CTX_new ( ) ;
if ( ! c -> inctx ) {
abort ( ) ;
}
}
if ( ! hex2bin ( buffer , buffer , len ) ) {
logger ( LOG_ERR , "Got bad %s from %s(%s): %s" , "METAKEY" , c -> name , c -> hostname , "invalid key" ) ;
return false ;
}
if ( RSA_private_decrypt ( len , ( unsigned char * ) buffer , ( unsigned char * ) c -> inkey , myself -> connection -> rsa_key , RSA_NO_PADDING ) != len ) {
logger ( LOG_ERR , "Error during decryption of meta key for %s (%s): %s" , c -> name , c -> hostname , ERR_error_string ( ERR_get_error ( ) , NULL ) ) ;
return false ;
}
ifdebug ( SCARY_THINGS ) {
bin2hex ( c -> inkey , buffer , len ) ;
buffer [ len * 2 ] = '\0' ;
logger ( LOG_DEBUG , "Received random meta key (unencrypted): %s" , buffer ) ;
}
if ( cipher ) {
c -> incipher = EVP_get_cipherbynid ( cipher ) ;
if ( ! c -> incipher ) {
logger ( LOG_ERR , "%s (%s) uses unknown cipher!" , c -> name , c -> hostname ) ;
return false ;
}
if ( ! EVP_DecryptInit ( c -> inctx , c -> incipher , ( unsigned char * ) c -> inkey + len - EVP_CIPHER_key_length ( c -> incipher ) , ( unsigned char * ) c -> inkey + len - EVP_CIPHER_key_length ( c -> incipher ) - EVP_CIPHER_iv_length ( c -> incipher ) ) ) {
logger ( LOG_ERR , "Error during initialisation of cipher from %s (%s): %s" , c -> name , c -> hostname , ERR_error_string ( ERR_get_error ( ) , NULL ) ) ;
return false ;
}
c -> inbudget = byte_budget ( c -> incipher ) ;
c -> status . decryptin = true ;
}
else {
logger ( LOG_ERR , "%s (%s) uses null cipher!" , c -> name , c -> hostname ) ;
return false ;
}
c -> inmaclength = maclength ;
if ( digest ) {
c -> indigest = EVP_get_digestbynid ( digest ) ;
if ( ! c -> indigest ) {
logger ( LOG_ERR , "Node %s (%s) uses unknown digest!" , c -> name , c -> hostname ) ;
return false ;
}
if ( c -> inmaclength > EVP_MD_size ( c -> indigest ) || c -> inmaclength < 0 ) {
logger ( LOG_ERR , "%s (%s) uses bogus MAC length!" , c -> name , c -> hostname ) ;
return false ;
}
}
else {
logger ( LOG_ERR , "%s (%s) uses null digest!" , c -> name , c -> hostname ) ;
return false ;
}
c -> incompression = compression ;
c -> allow_request = CHALLENGE ;
return send_challenge ( c ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static xmlLinkPtr xmlListLowerSearch ( xmlListPtr l , void * data ) {
xmlLinkPtr lk ;
if ( l == NULL ) return ( NULL ) ;
for ( lk = l -> sentinel -> next ;
lk != l -> sentinel && l -> linkCompare ( lk -> data , data ) < 0 ;
lk = lk -> next ) ;
return lk ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | UBool ufmt_isdigit ( UChar c , int32_t radix ) {
int digitVal = ufmt_digitvalue ( c ) ;
return ( UBool ) ( digitVal < radix && digitVal >= 0 ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_h225_SEQUENCE_OF_AlternateGK ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
offset = dissect_per_sequence_of ( tvb , offset , actx , tree , hf_index , ett_h225_SEQUENCE_OF_AlternateGK , SEQUENCE_OF_AlternateGK_sequence_of ) ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static bool astream_want_attachment ( struct attachment_istream * astream , struct message_part * part ) {
struct istream_attachment_header ahdr ;
if ( ( part -> flags & MESSAGE_PART_FLAG_MULTIPART ) != 0 ) {
return FALSE ;
}
if ( astream -> set . want_attachment == NULL ) return TRUE ;
i_zero ( & ahdr ) ;
ahdr . part = part ;
ahdr . content_type = astream -> part . content_type ;
ahdr . content_disposition = astream -> part . content_disposition ;
return astream -> set . want_attachment ( & ahdr , astream -> context ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_h225_RehomingModel ( 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_RehomingModel , RehomingModel_choice , NULL ) ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | PHP_FUNCTION ( locale_get_display_language ) {
get_icu_disp_value_src_php ( LOC_LANG_TAG , INTERNAL_FUNCTION_PARAM_PASSTHRU ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void decode_422_bitstream ( HYuvContext * s , int count ) {
int i ;
count /= 2 ;
if ( count >= ( get_bits_left ( & s -> gb ) ) / ( 31 * 4 ) ) {
for ( i = 0 ;
i < count && get_bits_left ( & s -> gb ) > 0 ;
i ++ ) {
READ_2PIX ( s -> temp [ 0 ] [ 2 * i ] , s -> temp [ 1 ] [ i ] , 1 ) ;
READ_2PIX ( s -> temp [ 0 ] [ 2 * i + 1 ] , s -> temp [ 2 ] [ i ] , 2 ) ;
}
}
else {
for ( i = 0 ;
i < count ;
i ++ ) {
READ_2PIX ( s -> temp [ 0 ] [ 2 * i ] , s -> temp [ 1 ] [ i ] , 1 ) ;
READ_2PIX ( s -> temp [ 0 ] [ 2 * i + 1 ] , s -> temp [ 2 ] [ i ] , 2 ) ;
}
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void dump_layeringinfo ( jpc_enc_t * enc ) {
jpc_enc_tcmpt_t * tcmpt ;
int tcmptno ;
jpc_enc_rlvl_t * rlvl ;
int rlvlno ;
jpc_enc_band_t * band ;
int bandno ;
jpc_enc_prc_t * prc ;
int prcno ;
jpc_enc_cblk_t * cblk ;
int cblkno ;
jpc_enc_pass_t * pass ;
int passno ;
int lyrno ;
jpc_enc_tile_t * tile ;
tile = enc -> curtile ;
for ( lyrno = 0 ;
lyrno < tile -> numlyrs ;
++ lyrno ) {
jas_eprintf ( "lyrno = %02d\n" , lyrno ) ;
for ( tcmptno = 0 , tcmpt = tile -> tcmpts ;
tcmptno < tile -> numtcmpts ;
++ tcmptno , ++ tcmpt ) {
for ( rlvlno = 0 , rlvl = tcmpt -> rlvls ;
rlvlno < tcmpt -> numrlvls ;
++ rlvlno , ++ rlvl ) {
if ( ! rlvl -> bands ) {
continue ;
}
for ( bandno = 0 , band = rlvl -> bands ;
bandno < rlvl -> numbands ;
++ bandno , ++ band ) {
if ( ! band -> data ) {
continue ;
}
for ( prcno = 0 , prc = band -> prcs ;
prcno < rlvl -> numprcs ;
++ prcno , ++ prc ) {
if ( ! prc -> cblks ) {
continue ;
}
for ( cblkno = 0 , cblk = prc -> cblks ;
cblkno < prc -> numcblks ;
++ cblkno , ++ cblk ) {
for ( passno = 0 , pass = cblk -> passes ;
passno < cblk -> numpasses && pass -> lyrno == lyrno ;
++ passno , ++ pass ) {
jas_eprintf ( "lyrno=%02d cmptno=%02d rlvlno=%02d bandno=%02d prcno=%02d cblkno=%03d passno=%03d\n" , lyrno , tcmptno , rlvlno , bandno , prcno , cblkno , passno ) ;
}
}
}
}
}
}
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int32_t u_scanf_scientific_handler ( UFILE * input , u_scanf_spec_info * info , ufmt_args * args , const UChar * fmt , int32_t * fmtConsumed , int32_t * argConverted ) {
( void ) fmt ;
( void ) fmtConsumed ;
int32_t len ;
double num ;
UNumberFormat * format ;
int32_t parsePos = 0 ;
int32_t skipped ;
UErrorCode status = U_ZERO_ERROR ;
UChar srcExpBuf [ UPRINTF_SYMBOL_BUFFER_SIZE ] ;
int32_t srcLen , expLen ;
UChar expBuf [ UPRINTF_SYMBOL_BUFFER_SIZE ] ;
skipped = u_scanf_skip_leading_ws ( input , info -> fPadChar ) ;
ufile_fill_uchar_buffer ( input ) ;
len = ( int32_t ) ( input -> str . fLimit - input -> str . fPos ) ;
if ( info -> fWidth != - 1 ) len = ufmt_min ( len , info -> fWidth ) ;
format = u_locbund_getNumberFormat ( & input -> str . fBundle , UNUM_SCIENTIFIC ) ;
if ( format == 0 ) return 0 ;
srcLen = unum_getSymbol ( format , UNUM_EXPONENTIAL_SYMBOL , srcExpBuf , sizeof ( srcExpBuf ) , & status ) ;
if ( info -> fSpec == ( UChar ) 0x65 ) {
expLen = u_strToLower ( expBuf , ( int32_t ) sizeof ( expBuf ) , srcExpBuf , srcLen , input -> str . fBundle . fLocale , & status ) ;
}
else {
expLen = u_strToUpper ( expBuf , ( int32_t ) sizeof ( expBuf ) , srcExpBuf , srcLen , input -> str . fBundle . fLocale , & status ) ;
}
unum_setSymbol ( format , UNUM_EXPONENTIAL_SYMBOL , expBuf , expLen , & status ) ;
skipped += u_scanf_skip_leading_positive_sign ( input , format , & status ) ;
num = unum_parseDouble ( format , input -> str . fPos , len , & parsePos , & status ) ;
if ( ! info -> fSkipArg ) {
if ( info -> fIsLong ) * ( double * ) ( args [ 0 ] . ptrValue ) = num ;
else if ( info -> fIsLongDouble ) * ( long double * ) ( args [ 0 ] . ptrValue ) = num ;
else * ( float * ) ( args [ 0 ] . ptrValue ) = ( float ) num ;
}
input -> str . fPos += parsePos ;
* argConverted = ! info -> fSkipArg ;
return parsePos + skipped ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void update_golden_frame_stats ( VP9_COMP * cpi ) {
RATE_CONTROL * const rc = & cpi -> rc ;
if ( cpi -> refresh_golden_frame ) {
rc -> frames_since_golden = 0 ;
if ( cpi -> oxcf . pass == 2 ) {
if ( ! rc -> source_alt_ref_pending && cpi -> twopass . gf_group . rf_level [ 0 ] == GF_ARF_STD ) rc -> source_alt_ref_active = 0 ;
}
else if ( ! rc -> source_alt_ref_pending ) {
rc -> source_alt_ref_active = 0 ;
}
if ( rc -> frames_till_gf_update_due > 0 ) rc -> frames_till_gf_update_due -- ;
}
else if ( ! cpi -> refresh_alt_ref_frame ) {
if ( rc -> frames_till_gf_update_due > 0 ) rc -> frames_till_gf_update_due -- ;
rc -> frames_since_golden ++ ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_h245_MultiplexTableEntryNumber ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
# line 65 "../../asn1/h245/h245.cnf" guint32 value ;
offset = dissect_per_constrained_integer ( tvb , offset , actx , tree , hf_index , 1U , 15U , & value , FALSE ) ;
h223_mc = value & 0xf ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | TEST_F ( BrowsingDataRemoverImplTest , RemoveQuotaManagedProtectedOrigins ) {
# if BUILDFLAG ( ENABLE_EXTENSIONS ) MockExtensionSpecialStoragePolicy * policy = CreateMockPolicy ( ) ;
policy -> AddProtected ( kOrigin1 . GetOrigin ( ) ) ;
# endif BlockUntilBrowsingDataRemoved ( base : : Time ( ) , base : : Time : : Max ( ) , BrowsingDataRemover : : REMOVE_APPCACHE | BrowsingDataRemover : : REMOVE_SERVICE_WORKERS | BrowsingDataRemover : : REMOVE_CACHE_STORAGE | BrowsingDataRemover : : REMOVE_FILE_SYSTEMS | BrowsingDataRemover : : REMOVE_INDEXEDDB | BrowsingDataRemover : : REMOVE_WEBSQL , true ) ;
EXPECT_EQ ( BrowsingDataRemover : : REMOVE_APPCACHE | BrowsingDataRemover : : REMOVE_SERVICE_WORKERS | BrowsingDataRemover : : REMOVE_CACHE_STORAGE | BrowsingDataRemover : : REMOVE_FILE_SYSTEMS | BrowsingDataRemover : : REMOVE_INDEXEDDB | BrowsingDataRemover : : REMOVE_WEBSQL , GetRemovalMask ( ) ) ;
EXPECT_EQ ( BrowsingDataHelper : : PROTECTED_WEB | BrowsingDataHelper : : UNPROTECTED_WEB , GetOriginTypeMask ( ) ) ;
StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData ( ) ;
EXPECT_EQ ( removal_data . remove_mask , StoragePartition : : REMOVE_DATA_MASK_FILE_SYSTEMS | StoragePartition : : REMOVE_DATA_MASK_WEBSQL | StoragePartition : : REMOVE_DATA_MASK_APPCACHE | StoragePartition : : REMOVE_DATA_MASK_SERVICE_WORKERS | StoragePartition : : REMOVE_DATA_MASK_CACHE_STORAGE | StoragePartition : : REMOVE_DATA_MASK_INDEXEDDB ) ;
EXPECT_EQ ( removal_data . quota_storage_remove_mask , StoragePartition : : QUOTA_MANAGED_STORAGE_MASK_ALL ) ;
EXPECT_TRUE ( removal_data . origin_matcher . Run ( kOrigin1 , mock_policy ( ) ) ) ;
EXPECT_TRUE ( removal_data . origin_matcher . Run ( kOrigin2 , mock_policy ( ) ) ) ;
EXPECT_TRUE ( removal_data . origin_matcher . Run ( kOrigin3 , mock_policy ( ) ) ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void tvb_composite_append ( tvbuff_t * tvb , tvbuff_t * member ) {
struct tvb_composite * composite_tvb = ( struct tvb_composite * ) tvb ;
tvb_comp_t * composite ;
DISSECTOR_ASSERT ( tvb && ! tvb -> initialized ) ;
DISSECTOR_ASSERT ( tvb -> ops == & tvb_composite_ops ) ;
DISSECTOR_ASSERT ( member -> length ) ;
composite = & composite_tvb -> composite ;
composite -> tvbs = g_slist_append ( composite -> tvbs , member ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int DSA_sign ( int type , const unsigned char * dgst , int dlen , unsigned char * sig , unsigned int * siglen , DSA * dsa ) {
DSA_SIG * s ;
RAND_seed ( dgst , dlen ) ;
s = DSA_do_sign ( dgst , dlen , dsa ) ;
if ( s == NULL ) {
* siglen = 0 ;
return ( 0 ) ;
}
* siglen = i2d_DSA_SIG ( s , & sig ) ;
DSA_SIG_free ( s ) ;
return ( 1 ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static const char * gpgsm_get_req_version ( void ) {
return "2.0.4" ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | const EVP_CIPHER * EVP_aes_ ## keylen ## _ ## mode ( void ) \ {
return & aes_ ## keylen ## _ ## mode ;
}
# endif # if defined ( OPENSSL_CPUID_OBJ ) && ( defined ( __arm__ ) || defined ( __arm ) || defined ( __aarch64__ ) ) # include "arm_arch.h" # if __ARM_MAX_ARCH__ >= 7 # if defined ( BSAES_ASM ) # define BSAES_CAPABLE ( OPENSSL_armcap_P & ARMV7_NEON ) # endif # if defined ( VPAES_ASM ) # define VPAES_CAPABLE ( OPENSSL_armcap_P & ARMV7_NEON ) # endif # define HWAES_CAPABLE ( OPENSSL_armcap_P & ARMV8_AES ) # define HWAES_set_encrypt_key aes_v8_set_encrypt_key # define HWAES_set_decrypt_key aes_v8_set_decrypt_key # define HWAES_encrypt aes_v8_encrypt # define HWAES_decrypt aes_v8_decrypt # define HWAES_cbc_encrypt aes_v8_cbc_encrypt # define HWAES_ctr32_encrypt_blocks aes_v8_ctr32_encrypt_blocks # endif # endif # if defined ( HWAES_CAPABLE ) int HWAES_set_encrypt_key ( const unsigned char * userKey , const int bits , AES_KEY * key ) ;
int HWAES_set_decrypt_key ( const unsigned char * userKey , const int bits , AES_KEY * key ) ;
void HWAES_encrypt ( const unsigned char * in , unsigned char * out , const AES_KEY * key ) ;
void HWAES_decrypt ( const unsigned char * in , unsigned char * out , const AES_KEY * key ) ;
void HWAES_cbc_encrypt ( const unsigned char * in , unsigned char * out , size_t length , const AES_KEY * key , unsigned char * ivec , const int enc ) ;
void HWAES_ctr32_encrypt_blocks ( const unsigned char * in , unsigned char * out , size_t len , const AES_KEY * key , const unsigned char ivec [ 16 ] ) ;
void HWAES_xts_encrypt ( const unsigned char * inp , unsigned char * out , size_t len , const AES_KEY * key1 , const AES_KEY * key2 , const unsigned char iv [ 16 ] ) ;
void HWAES_xts_decrypt ( const unsigned char * inp , unsigned char * out , size_t len , const AES_KEY * key1 , const AES_KEY * key2 , const unsigned char iv [ 16 ] ) ;
# endif # define BLOCK_CIPHER_generic_pack ( nid , keylen , flags ) \ BLOCK_CIPHER_generic ( nid , keylen , 16 , 16 , cbc , cbc , CBC , flags | EVP_CIPH_FLAG_DEFAULT_ASN1 ) \ BLOCK_CIPHER_generic ( nid , keylen , 16 , 0 , ecb , ecb , ECB , flags | EVP_CIPH_FLAG_DEFAULT_ASN1 ) \ BLOCK_CIPHER_generic ( nid , keylen , 1 , 16 , ofb128 , ofb , OFB , flags | EVP_CIPH_FLAG_DEFAULT_ASN1 ) \ BLOCK_CIPHER_generic ( nid , keylen , 1 , 16 , cfb128 , cfb , CFB , flags | EVP_CIPH_FLAG_DEFAULT_ASN1 ) \ BLOCK_CIPHER_generic ( nid , keylen , 1 , 16 , cfb1 , cfb1 , CFB , flags ) \ BLOCK_CIPHER_generic ( nid , keylen , 1 , 16 , cfb8 , cfb8 , CFB , flags ) \ BLOCK_CIPHER_generic ( nid , keylen , 1 , 16 , ctr , ctr , CTR , flags ) static int aes_init_key ( EVP_CIPHER_CTX * ctx , const unsigned char * key , const unsigned char * iv , int enc ) {
int ret , mode ;
EVP_AES_KEY * dat = EVP_C_DATA ( EVP_AES_KEY , ctx ) ;
mode = EVP_CIPHER_CTX_mode ( ctx ) ;
if ( ( mode == EVP_CIPH_ECB_MODE || mode == EVP_CIPH_CBC_MODE ) && ! enc ) {
# ifdef HWAES_CAPABLE if ( HWAES_CAPABLE ) {
ret = HWAES_set_decrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 8 , & dat -> ks . ks ) ;
dat -> block = ( block128_f ) HWAES_decrypt ;
dat -> stream . cbc = NULL ;
# ifdef HWAES_cbc_encrypt if ( mode == EVP_CIPH_CBC_MODE ) dat -> stream . cbc = ( cbc128_f ) HWAES_cbc_encrypt ;
# endif }
else # endif # ifdef BSAES_CAPABLE if ( BSAES_CAPABLE && mode == EVP_CIPH_CBC_MODE ) {
ret = AES_set_decrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 8 , & dat -> ks . ks ) ;
dat -> block = ( block128_f ) AES_decrypt ;
dat -> stream . cbc = ( cbc128_f ) bsaes_cbc_encrypt ;
}
else # endif # ifdef VPAES_CAPABLE if ( VPAES_CAPABLE ) {
ret = vpaes_set_decrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 8 , & dat -> ks . ks ) ;
dat -> block = ( block128_f ) vpaes_decrypt ;
dat -> stream . cbc = mode == EVP_CIPH_CBC_MODE ? ( cbc128_f ) vpaes_cbc_encrypt : NULL ;
}
else # endif {
ret = AES_set_decrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 8 , & dat -> ks . ks ) ;
dat -> block = ( block128_f ) AES_decrypt ;
dat -> stream . cbc = mode == EVP_CIPH_CBC_MODE ? ( cbc128_f ) AES_cbc_encrypt : NULL ;
}
}
else # ifdef HWAES_CAPABLE if ( HWAES_CAPABLE ) {
ret = HWAES_set_encrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 8 , & dat -> ks . ks ) ;
dat -> block = ( block128_f ) HWAES_encrypt ;
dat -> stream . cbc = NULL ;
# ifdef HWAES_cbc_encrypt if ( mode == EVP_CIPH_CBC_MODE ) dat -> stream . cbc = ( cbc128_f ) HWAES_cbc_encrypt ;
else # endif # ifdef HWAES_ctr32_encrypt_blocks if ( mode == EVP_CIPH_CTR_MODE ) dat -> stream . ctr = ( ctr128_f ) HWAES_ctr32_encrypt_blocks ;
else # endif ( void ) 0 ;
}
else # endif # ifdef BSAES_CAPABLE if ( BSAES_CAPABLE && mode == EVP_CIPH_CTR_MODE ) {
ret = AES_set_encrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 8 , & dat -> ks . ks ) ;
dat -> block = ( block128_f ) AES_encrypt ;
dat -> stream . ctr = ( ctr128_f ) bsaes_ctr32_encrypt_blocks ;
}
else # endif # ifdef VPAES_CAPABLE if ( VPAES_CAPABLE ) {
ret = vpaes_set_encrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 8 , & dat -> ks . ks ) ;
dat -> block = ( block128_f ) vpaes_encrypt ;
dat -> stream . cbc = mode == EVP_CIPH_CBC_MODE ? ( cbc128_f ) vpaes_cbc_encrypt : NULL ;
}
else # endif {
ret = AES_set_encrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 8 , & dat -> ks . ks ) ;
dat -> block = ( block128_f ) AES_encrypt ;
dat -> stream . cbc = mode == EVP_CIPH_CBC_MODE ? ( cbc128_f ) AES_cbc_encrypt : NULL ;
# ifdef AES_CTR_ASM if ( mode == EVP_CIPH_CTR_MODE ) dat -> stream . ctr = ( ctr128_f ) AES_ctr32_encrypt ;
# endif }
if ( ret < 0 ) {
EVPerr ( EVP_F_AES_INIT_KEY , EVP_R_AES_KEY_SETUP_FAILED ) ;
return 0 ;
}
return 1 ;
}
static int aes_cbc_cipher ( EVP_CIPHER_CTX * ctx , unsigned char * out , const unsigned char * in , size_t len ) {
EVP_AES_KEY * dat = EVP_C_DATA ( EVP_AES_KEY , ctx ) ;
if ( dat -> stream . cbc ) ( * dat -> stream . cbc ) ( in , out , len , & dat -> ks , EVP_CIPHER_CTX_iv_noconst ( ctx ) , EVP_CIPHER_CTX_encrypting ( ctx ) ) ;
else if ( EVP_CIPHER_CTX_encrypting ( ctx ) ) CRYPTO_cbc128_encrypt ( in , out , len , & dat -> ks , EVP_CIPHER_CTX_iv_noconst ( ctx ) , dat -> block ) ;
else CRYPTO_cbc128_decrypt ( in , out , len , & dat -> ks , EVP_CIPHER_CTX_iv_noconst ( ctx ) , dat -> block ) ;
return 1 ;
}
static int aes_ecb_cipher ( EVP_CIPHER_CTX * ctx , unsigned char * out , const unsigned char * in , size_t len ) {
size_t bl = EVP_CIPHER_CTX_block_size ( ctx ) ;
size_t i ;
EVP_AES_KEY * dat = EVP_C_DATA ( EVP_AES_KEY , ctx ) ;
if ( len < bl ) return 1 ;
for ( i = 0 , len -= bl ;
i <= len ;
i += bl ) ( * dat -> block ) ( in + i , out + i , & dat -> ks ) ;
return 1 ;
}
static int aes_ofb_cipher ( EVP_CIPHER_CTX * ctx , unsigned char * out , const unsigned char * in , size_t len ) {
EVP_AES_KEY * dat = EVP_C_DATA ( EVP_AES_KEY , ctx ) ;
int num = EVP_CIPHER_CTX_num ( ctx ) ;
CRYPTO_ofb128_encrypt ( in , out , len , & dat -> ks , EVP_CIPHER_CTX_iv_noconst ( ctx ) , & num , dat -> block ) ;
EVP_CIPHER_CTX_set_num ( ctx , num ) ;
return 1 ;
}
static int aes_cfb_cipher ( EVP_CIPHER_CTX * ctx , unsigned char * out , const unsigned char * in , size_t len ) {
EVP_AES_KEY * dat = EVP_C_DATA ( EVP_AES_KEY , ctx ) ;
int num = EVP_CIPHER_CTX_num ( ctx ) ;
CRYPTO_cfb128_encrypt ( in , out , len , & dat -> ks , EVP_CIPHER_CTX_iv_noconst ( ctx ) , & num , EVP_CIPHER_CTX_encrypting ( ctx ) , dat -> block ) ;
EVP_CIPHER_CTX_set_num ( ctx , num ) ;
return 1 ;
}
static int aes_cfb8_cipher ( EVP_CIPHER_CTX * ctx , unsigned char * out , const unsigned char * in , size_t len ) {
EVP_AES_KEY * dat = EVP_C_DATA ( EVP_AES_KEY , ctx ) ;
int num = EVP_CIPHER_CTX_num ( ctx ) ;
CRYPTO_cfb128_8_encrypt ( in , out , len , & dat -> ks , EVP_CIPHER_CTX_iv_noconst ( ctx ) , & num , EVP_CIPHER_CTX_encrypting ( ctx ) , dat -> block ) ;
EVP_CIPHER_CTX_set_num ( ctx , num ) ;
return 1 ;
}
static int aes_cfb1_cipher ( EVP_CIPHER_CTX * ctx , unsigned char * out , const unsigned char * in , size_t len ) {
EVP_AES_KEY * dat = EVP_C_DATA ( EVP_AES_KEY , ctx ) ;
if ( EVP_CIPHER_CTX_test_flags ( ctx , EVP_CIPH_FLAG_LENGTH_BITS ) ) {
int num = EVP_CIPHER_CTX_num ( ctx ) ;
CRYPTO_cfb128_1_encrypt ( in , out , len , & dat -> ks , EVP_CIPHER_CTX_iv_noconst ( ctx ) , & num , EVP_CIPHER_CTX_encrypting ( ctx ) , dat -> block ) ;
EVP_CIPHER_CTX_set_num ( ctx , num ) ;
return 1 ;
}
while ( len >= MAXBITCHUNK ) {
int num = EVP_CIPHER_CTX_num ( ctx ) ;
CRYPTO_cfb128_1_encrypt ( in , out , MAXBITCHUNK * 8 , & dat -> ks , EVP_CIPHER_CTX_iv_noconst ( ctx ) , & num , EVP_CIPHER_CTX_encrypting ( ctx ) , dat -> block ) ;
EVP_CIPHER_CTX_set_num ( ctx , num ) ;
len -= MAXBITCHUNK ;
}
if ( len ) {
int num = EVP_CIPHER_CTX_num ( ctx ) ;
CRYPTO_cfb128_1_encrypt ( in , out , len * 8 , & dat -> ks , EVP_CIPHER_CTX_iv_noconst ( ctx ) , & num , EVP_CIPHER_CTX_encrypting ( ctx ) , dat -> block ) ;
EVP_CIPHER_CTX_set_num ( ctx , num ) ;
}
return 1 ;
}
static int aes_ctr_cipher ( EVP_CIPHER_CTX * ctx , unsigned char * out , const unsigned char * in , size_t len ) {
unsigned int num = EVP_CIPHER_CTX_num ( ctx ) ;
EVP_AES_KEY * dat = EVP_C_DATA ( EVP_AES_KEY , ctx ) ;
if ( dat -> stream . ctr ) CRYPTO_ctr128_encrypt_ctr32 ( in , out , len , & dat -> ks , EVP_CIPHER_CTX_iv_noconst ( ctx ) , EVP_CIPHER_CTX_buf_noconst ( ctx ) , & num , dat -> stream . ctr ) ;
else CRYPTO_ctr128_encrypt ( in , out , len , & dat -> ks , EVP_CIPHER_CTX_iv_noconst ( ctx ) , EVP_CIPHER_CTX_buf_noconst ( ctx ) , & num , dat -> block ) ;
EVP_CIPHER_CTX_set_num ( ctx , num ) ;
return 1 ;
}
BLOCK_CIPHER_generic_pack ( NID_aes , 128 , 0 ) BLOCK_CIPHER_generic_pack ( NID_aes , 192 , 0 ) BLOCK_CIPHER_generic_pack ( NID_aes , 256 , 0 ) static int aes_gcm_cleanup ( EVP_CIPHER_CTX * c ) {
EVP_AES_GCM_CTX * gctx = EVP_C_DATA ( EVP_AES_GCM_CTX , c ) ;
OPENSSL_cleanse ( & gctx -> gcm , sizeof ( gctx -> gcm ) ) ;
if ( gctx -> iv != EVP_CIPHER_CTX_iv_noconst ( c ) ) OPENSSL_free ( gctx -> iv ) ;
return 1 ;
}
static void ctr64_inc ( unsigned char * counter ) {
int n = 8 ;
unsigned char c ;
do {
-- n ;
c = counter [ n ] ;
++ c ;
counter [ n ] = c ;
if ( c ) return ;
}
while ( n ) ;
}
static int aes_gcm_ctrl ( EVP_CIPHER_CTX * c , int type , int arg , void * ptr ) {
EVP_AES_GCM_CTX * gctx = EVP_C_DATA ( EVP_AES_GCM_CTX , c ) ;
switch ( type ) {
case EVP_CTRL_INIT : gctx -> key_set = 0 ;
gctx -> iv_set = 0 ;
gctx -> ivlen = EVP_CIPHER_CTX_iv_length ( c ) ;
gctx -> iv = EVP_CIPHER_CTX_iv_noconst ( c ) ;
gctx -> taglen = - 1 ;
gctx -> iv_gen = 0 ;
gctx -> tls_aad_len = - 1 ;
return 1 ;
case EVP_CTRL_AEAD_SET_IVLEN : if ( arg <= 0 ) return 0 ;
if ( ( arg > EVP_MAX_IV_LENGTH ) && ( arg > gctx -> ivlen ) ) {
if ( gctx -> iv != EVP_CIPHER_CTX_iv_noconst ( c ) ) OPENSSL_free ( gctx -> iv ) ;
gctx -> iv = OPENSSL_malloc ( arg ) ;
if ( gctx -> iv == NULL ) return 0 ;
}
gctx -> ivlen = arg ;
return 1 ;
case EVP_CTRL_AEAD_SET_TAG : if ( arg <= 0 || arg > 16 || EVP_CIPHER_CTX_encrypting ( c ) ) return 0 ;
memcpy ( EVP_CIPHER_CTX_buf_noconst ( c ) , ptr , arg ) ;
gctx -> taglen = arg ;
return 1 ;
case EVP_CTRL_AEAD_GET_TAG : if ( arg <= 0 || arg > 16 || ! EVP_CIPHER_CTX_encrypting ( c ) || gctx -> taglen < 0 ) return 0 ;
memcpy ( ptr , EVP_CIPHER_CTX_buf_noconst ( c ) , arg ) ;
return 1 ;
case EVP_CTRL_GCM_SET_IV_FIXED : if ( arg == - 1 ) {
memcpy ( gctx -> iv , ptr , gctx -> ivlen ) ;
gctx -> iv_gen = 1 ;
return 1 ;
}
if ( ( arg < 4 ) || ( gctx -> ivlen - arg ) < 8 ) return 0 ;
if ( arg ) memcpy ( gctx -> iv , ptr , arg ) ;
if ( EVP_CIPHER_CTX_encrypting ( c ) && RAND_bytes ( gctx -> iv + arg , gctx -> ivlen - arg ) <= 0 ) return 0 ;
gctx -> iv_gen = 1 ;
return 1 ;
case EVP_CTRL_GCM_IV_GEN : if ( gctx -> iv_gen == 0 || gctx -> key_set == 0 ) return 0 ;
CRYPTO_gcm128_setiv ( & gctx -> gcm , gctx -> iv , gctx -> ivlen ) ;
if ( arg <= 0 || arg > gctx -> ivlen ) arg = gctx -> ivlen ;
memcpy ( ptr , gctx -> iv + gctx -> ivlen - arg , arg ) ;
ctr64_inc ( gctx -> iv + gctx -> ivlen - 8 ) ;
gctx -> iv_set = 1 ;
return 1 ;
case EVP_CTRL_GCM_SET_IV_INV : if ( gctx -> iv_gen == 0 || gctx -> key_set == 0 || EVP_CIPHER_CTX_encrypting ( c ) ) return 0 ;
memcpy ( gctx -> iv + gctx -> ivlen - arg , ptr , arg ) ;
CRYPTO_gcm128_setiv ( & gctx -> gcm , gctx -> iv , gctx -> ivlen ) ;
gctx -> iv_set = 1 ;
return 1 ;
case EVP_CTRL_AEAD_TLS1_AAD : if ( arg != EVP_AEAD_TLS1_AAD_LEN ) return 0 ;
memcpy ( EVP_CIPHER_CTX_buf_noconst ( c ) , ptr , arg ) ;
gctx -> tls_aad_len = arg ;
{
unsigned int len = EVP_CIPHER_CTX_buf_noconst ( c ) [ arg - 2 ] << 8 | EVP_CIPHER_CTX_buf_noconst ( c ) [ arg - 1 ] ;
len -= EVP_GCM_TLS_EXPLICIT_IV_LEN ;
if ( ! EVP_CIPHER_CTX_encrypting ( c ) ) len -= EVP_GCM_TLS_TAG_LEN ;
EVP_CIPHER_CTX_buf_noconst ( c ) [ arg - 2 ] = len >> 8 ;
EVP_CIPHER_CTX_buf_noconst ( c ) [ arg - 1 ] = len & 0xff ;
}
return EVP_GCM_TLS_TAG_LEN ;
case EVP_CTRL_COPY : {
EVP_CIPHER_CTX * out = ptr ;
EVP_AES_GCM_CTX * gctx_out = EVP_C_DATA ( EVP_AES_GCM_CTX , out ) ;
if ( gctx -> gcm . key ) {
if ( gctx -> gcm . key != & gctx -> ks ) return 0 ;
gctx_out -> gcm . key = & gctx_out -> ks ;
}
if ( gctx -> iv == EVP_CIPHER_CTX_iv_noconst ( c ) ) gctx_out -> iv = EVP_CIPHER_CTX_iv_noconst ( out ) ;
else {
gctx_out -> iv = OPENSSL_malloc ( gctx -> ivlen ) ;
if ( gctx_out -> iv == NULL ) return 0 ;
memcpy ( gctx_out -> iv , gctx -> iv , gctx -> ivlen ) ;
}
return 1 ;
}
default : return - 1 ;
}
}
static int aes_gcm_init_key ( EVP_CIPHER_CTX * ctx , const unsigned char * key , const unsigned char * iv , int enc ) {
EVP_AES_GCM_CTX * gctx = EVP_C_DATA ( EVP_AES_GCM_CTX , ctx ) ;
if ( ! iv && ! key ) return 1 ;
if ( key ) {
do {
# ifdef HWAES_CAPABLE if ( HWAES_CAPABLE ) {
HWAES_set_encrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 8 , & gctx -> ks . ks ) ;
CRYPTO_gcm128_init ( & gctx -> gcm , & gctx -> ks , ( block128_f ) HWAES_encrypt ) ;
# ifdef HWAES_ctr32_encrypt_blocks gctx -> ctr = ( ctr128_f ) HWAES_ctr32_encrypt_blocks ;
# else gctx -> ctr = NULL ;
# endif break ;
}
else # endif # ifdef BSAES_CAPABLE if ( BSAES_CAPABLE ) {
AES_set_encrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 8 , & gctx -> ks . ks ) ;
CRYPTO_gcm128_init ( & gctx -> gcm , & gctx -> ks , ( block128_f ) AES_encrypt ) ;
gctx -> ctr = ( ctr128_f ) bsaes_ctr32_encrypt_blocks ;
break ;
}
else # endif # ifdef VPAES_CAPABLE if ( VPAES_CAPABLE ) {
vpaes_set_encrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 8 , & gctx -> ks . ks ) ;
CRYPTO_gcm128_init ( & gctx -> gcm , & gctx -> ks , ( block128_f ) vpaes_encrypt ) ;
gctx -> ctr = NULL ;
break ;
}
else # endif ( void ) 0 ;
AES_set_encrypt_key ( key , EVP_CIPHER_CTX_key_length ( ctx ) * 8 , & gctx -> ks . ks ) ;
CRYPTO_gcm128_init ( & gctx -> gcm , & gctx -> ks , ( block128_f ) AES_encrypt ) ;
# ifdef AES_CTR_ASM gctx -> ctr = ( ctr128_f ) AES_ctr32_encrypt ;
# else gctx -> ctr = NULL ;
# endif }
while ( 0 ) ;
if ( iv == NULL && gctx -> iv_set ) iv = gctx -> iv ;
if ( iv ) {
CRYPTO_gcm128_setiv ( & gctx -> gcm , iv , gctx -> ivlen ) ;
gctx -> iv_set = 1 ;
}
gctx -> key_set = 1 ;
}
else {
if ( gctx -> key_set ) CRYPTO_gcm128_setiv ( & gctx -> gcm , iv , gctx -> ivlen ) ;
else memcpy ( gctx -> iv , iv , gctx -> ivlen ) ;
gctx -> iv_set = 1 ;
gctx -> iv_gen = 0 ;
}
return 1 ;
}
static int aes_gcm_tls_cipher ( EVP_CIPHER_CTX * ctx , unsigned char * out , const unsigned char * in , size_t len ) {
EVP_AES_GCM_CTX * gctx = EVP_C_DATA ( EVP_AES_GCM_CTX , ctx ) ;
int rv = - 1 ;
if ( out != in || len < ( EVP_GCM_TLS_EXPLICIT_IV_LEN + EVP_GCM_TLS_TAG_LEN ) ) return - 1 ;
if ( EVP_CIPHER_CTX_ctrl ( ctx , EVP_CIPHER_CTX_encrypting ( ctx ) ? EVP_CTRL_GCM_IV_GEN : EVP_CTRL_GCM_SET_IV_INV , EVP_GCM_TLS_EXPLICIT_IV_LEN , out ) <= 0 ) goto err ;
if ( CRYPTO_gcm128_aad ( & gctx -> gcm , EVP_CIPHER_CTX_buf_noconst ( ctx ) , gctx -> tls_aad_len ) ) goto err ;
in += EVP_GCM_TLS_EXPLICIT_IV_LEN ;
out += EVP_GCM_TLS_EXPLICIT_IV_LEN ;
len -= EVP_GCM_TLS_EXPLICIT_IV_LEN + EVP_GCM_TLS_TAG_LEN ;
if ( EVP_CIPHER_CTX_encrypting ( ctx ) ) {
if ( gctx -> ctr ) {
size_t bulk = 0 ;
# if defined ( AES_GCM_ASM ) if ( len >= 32 && AES_GCM_ASM ( gctx ) ) {
if ( CRYPTO_gcm128_encrypt ( & gctx -> gcm , NULL , NULL , 0 ) ) return - 1 ;
bulk = AES_gcm_encrypt ( in , out , len , gctx -> gcm . key , gctx -> gcm . Yi . c , gctx -> gcm . Xi . u ) ;
gctx -> gcm . len . u [ 1 ] += bulk ;
}
# endif if ( CRYPTO_gcm128_encrypt_ctr32 ( & gctx -> gcm , in + bulk , out + bulk , len - bulk , gctx -> ctr ) ) goto err ;
}
else {
size_t bulk = 0 ;
# if defined ( AES_GCM_ASM2 ) if ( len >= 32 && AES_GCM_ASM2 ( gctx ) ) {
if ( CRYPTO_gcm128_encrypt ( & gctx -> gcm , NULL , NULL , 0 ) ) return - 1 ;
bulk = AES_gcm_encrypt ( in , out , len , gctx -> gcm . key , gctx -> gcm . Yi . c , gctx -> gcm . Xi . u ) ;
gctx -> gcm . len . u [ 1 ] += bulk ;
}
# endif if ( CRYPTO_gcm128_encrypt ( & gctx -> gcm , in + bulk , out + bulk , len - bulk ) ) goto err ;
}
out += len ;
CRYPTO_gcm128_tag ( & gctx -> gcm , out , EVP_GCM_TLS_TAG_LEN ) ;
rv = len + EVP_GCM_TLS_EXPLICIT_IV_LEN + EVP_GCM_TLS_TAG_LEN ;
}
else {
if ( gctx -> ctr ) {
size_t bulk = 0 ;
# if defined ( AES_GCM_ASM ) if ( len >= 16 && AES_GCM_ASM ( gctx ) ) {
if ( CRYPTO_gcm128_decrypt ( & gctx -> gcm , NULL , NULL , 0 ) ) return - 1 ;
bulk = AES_gcm_decrypt ( in , out , len , gctx -> gcm . key , gctx -> gcm . Yi . c , gctx -> gcm . Xi . u ) ;
gctx -> gcm . len . u [ 1 ] += bulk ;
}
# endif if ( CRYPTO_gcm128_decrypt_ctr32 ( & gctx -> gcm , in + bulk , out + bulk , len - bulk , gctx -> ctr ) ) goto err ;
}
else {
size_t bulk = 0 ;
# if defined ( AES_GCM_ASM2 ) if ( len >= 16 && AES_GCM_ASM2 ( gctx ) ) {
if ( CRYPTO_gcm128_decrypt ( & gctx -> gcm , NULL , NULL , 0 ) ) return - 1 ;
bulk = AES_gcm_decrypt ( in , out , len , gctx -> gcm . key , gctx -> gcm . Yi . c , gctx -> gcm . Xi . u ) ;
gctx -> gcm . len . u [ 1 ] += bulk ;
}
# endif if ( CRYPTO_gcm128_decrypt ( & gctx -> gcm , in + bulk , out + bulk , len - bulk ) ) goto err ;
}
CRYPTO_gcm128_tag ( & gctx -> gcm , EVP_CIPHER_CTX_buf_noconst ( ctx ) , EVP_GCM_TLS_TAG_LEN ) ;
if ( CRYPTO_memcmp ( EVP_CIPHER_CTX_buf_noconst ( ctx ) , in + len , EVP_GCM_TLS_TAG_LEN ) ) {
OPENSSL_cleanse ( out , len ) ;
goto err ;
}
rv = len ;
}
err : gctx -> iv_set = 0 ;
gctx -> tls_aad_len = - 1 ;
return rv ;
}
static int aes_gcm_cipher ( EVP_CIPHER_CTX * ctx , unsigned char * out , const unsigned char * in , size_t len ) {
EVP_AES_GCM_CTX * gctx = EVP_C_DATA ( EVP_AES_GCM_CTX , ctx ) ;
if ( ! gctx -> key_set ) return - 1 ;
if ( gctx -> tls_aad_len >= 0 ) return aes_gcm_tls_cipher ( ctx , out , in , len ) ;
if ( ! gctx -> iv_set ) return - 1 ;
if ( in ) {
if ( out == NULL ) {
if ( CRYPTO_gcm128_aad ( & gctx -> gcm , in , len ) ) return - 1 ;
}
else if ( EVP_CIPHER_CTX_encrypting ( ctx ) ) {
if ( gctx -> ctr ) {
size_t bulk = 0 ;
# if defined ( AES_GCM_ASM ) if ( len >= 32 && AES_GCM_ASM ( gctx ) ) {
size_t res = ( 16 - gctx -> gcm . mres ) % 16 ;
if ( CRYPTO_gcm128_encrypt ( & gctx -> gcm , in , out , res ) ) return - 1 ;
bulk = AES_gcm_encrypt ( in + res , out + res , len - res , gctx -> gcm . key , gctx -> gcm . Yi . c , gctx -> gcm . Xi . u ) ;
gctx -> gcm . len . u [ 1 ] += bulk ;
bulk += res ;
}
# endif if ( CRYPTO_gcm128_encrypt_ctr32 ( & gctx -> gcm , in + bulk , out + bulk , len - bulk , gctx -> ctr ) ) return - 1 ;
}
else {
size_t bulk = 0 ;
# if defined ( AES_GCM_ASM2 ) if ( len >= 32 && AES_GCM_ASM2 ( gctx ) ) {
size_t res = ( 16 - gctx -> gcm . mres ) % 16 ;
if ( CRYPTO_gcm128_encrypt ( & gctx -> gcm , in , out , res ) ) return - 1 ;
bulk = AES_gcm_encrypt ( in + res , out + res , len - res , gctx -> gcm . key , gctx -> gcm . Yi . c , gctx -> gcm . Xi . u ) ;
gctx -> gcm . len . u [ 1 ] += bulk ;
bulk += res ;
}
# endif if ( CRYPTO_gcm128_encrypt ( & gctx -> gcm , in + bulk , out + bulk , len - bulk ) ) return - 1 ;
}
}
else {
if ( gctx -> ctr ) {
size_t bulk = 0 ;
# if defined ( AES_GCM_ASM ) if ( len >= 16 && AES_GCM_ASM ( gctx ) ) {
size_t res = ( 16 - gctx -> gcm . mres ) % 16 ;
if ( CRYPTO_gcm128_decrypt ( & gctx -> gcm , in , out , res ) ) return - 1 ;
bulk = AES_gcm_decrypt ( in + res , out + res , len - res , gctx -> gcm . key , gctx -> gcm . Yi . c , gctx -> gcm . Xi . u ) ;
gctx -> gcm . len . u [ 1 ] += bulk ;
bulk += res ;
}
# endif if ( CRYPTO_gcm128_decrypt_ctr32 ( & gctx -> gcm , in + bulk , out + bulk , len - bulk , gctx -> ctr ) ) return - 1 ;
}
else {
size_t bulk = 0 ;
# if defined ( AES_GCM_ASM2 ) if ( len >= 16 && AES_GCM_ASM2 ( gctx ) ) {
size_t res = ( 16 - gctx -> gcm . mres ) % 16 ;
if ( CRYPTO_gcm128_decrypt ( & gctx -> gcm , in , out , res ) ) return - 1 ;
bulk = AES_gcm_decrypt ( in + res , out + res , len - res , gctx -> gcm . key , gctx -> gcm . Yi . c , gctx -> gcm . Xi . u ) ;
gctx -> gcm . len . u [ 1 ] += bulk ;
bulk += res ;
}
# endif if ( CRYPTO_gcm128_decrypt ( & gctx -> gcm , in + bulk , out + bulk , len - bulk ) ) return - 1 ;
}
}
return len ;
}
else {
if ( ! EVP_CIPHER_CTX_encrypting ( ctx ) ) {
if ( gctx -> taglen < 0 ) return - 1 ;
if ( CRYPTO_gcm128_finish ( & gctx -> gcm , EVP_CIPHER_CTX_buf_noconst ( ctx ) , gctx -> taglen ) != 0 ) return - 1 ;
gctx -> iv_set = 0 ;
return 0 ;
}
CRYPTO_gcm128_tag ( & gctx -> gcm , EVP_CIPHER_CTX_buf_noconst ( ctx ) , 16 ) ;
gctx -> taglen = 16 ;
gctx -> iv_set = 0 ;
return 0 ;
}
}
# define CUSTOM_FLAGS ( EVP_CIPH_FLAG_DEFAULT_ASN1 \ | EVP_CIPH_CUSTOM_IV | EVP_CIPH_FLAG_CUSTOM_CIPHER \ | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CTRL_INIT \ | EVP_CIPH_CUSTOM_COPY ) BLOCK_CIPHER_custom ( NID_aes , 128 , 1 , 12 , gcm , GCM , EVP_CIPH_FLAG_AEAD_CIPHER | CUSTOM_FLAGS ) BLOCK_CIPHER_custom ( NID_aes , 192 , 1 , 12 , gcm , GCM , EVP_CIPH_FLAG_AEAD_CIPHER | CUSTOM_FLAGS ) BLOCK_CIPHER_custom ( NID_aes , 256 , 1 , 12 , gcm , GCM , EVP_CIPH_FLAG_AEAD_CIPHER | CUSTOM_FLAGS ) | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static void U_CALLCONV T_UConverter_toUnicode_UTF32_LE ( UConverterToUnicodeArgs * args , UErrorCode * err ) {
const unsigned char * mySource = ( unsigned char * ) args -> source ;
UChar * myTarget = args -> target ;
const unsigned char * sourceLimit = ( unsigned char * ) args -> sourceLimit ;
const UChar * targetLimit = args -> targetLimit ;
unsigned char * toUBytes = args -> converter -> toUBytes ;
uint32_t ch , i ;
if ( args -> converter -> toUnicodeStatus && myTarget < targetLimit ) {
i = args -> converter -> toULength ;
args -> converter -> toULength = 0 ;
ch = args -> converter -> toUnicodeStatus - 1 ;
args -> converter -> toUnicodeStatus = 0 ;
goto morebytes ;
}
while ( mySource < sourceLimit && myTarget < targetLimit ) {
i = 0 ;
ch = 0 ;
morebytes : while ( i < sizeof ( uint32_t ) ) {
if ( mySource < sourceLimit ) {
ch |= ( ( uint8_t ) ( * mySource ) ) << ( i * 8 ) ;
toUBytes [ i ++ ] = ( char ) * ( mySource ++ ) ;
}
else {
args -> converter -> toUnicodeStatus = ch + 1 ;
args -> converter -> toULength = ( int8_t ) i ;
goto donefornow ;
}
}
if ( ch <= MAXIMUM_UTF && ! U_IS_SURROGATE ( ch ) ) {
if ( ch <= MAXIMUM_UCS2 ) {
* ( myTarget ++ ) = ( UChar ) ch ;
}
else {
* ( myTarget ++ ) = U16_LEAD ( ch ) ;
ch = U16_TRAIL ( ch ) ;
if ( myTarget < targetLimit ) {
* ( myTarget ++ ) = ( UChar ) ch ;
}
else {
args -> converter -> UCharErrorBuffer [ 0 ] = ( UChar ) ch ;
args -> converter -> UCharErrorBufferLength = 1 ;
* err = U_BUFFER_OVERFLOW_ERROR ;
break ;
}
}
}
else {
args -> converter -> toULength = ( int8_t ) i ;
* err = U_ILLEGAL_CHAR_FOUND ;
break ;
}
}
donefornow : if ( mySource < sourceLimit && myTarget >= targetLimit && U_SUCCESS ( * err ) ) {
* err = U_BUFFER_OVERFLOW_ERROR ;
}
args -> target = myTarget ;
args -> source = ( const char * ) mySource ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int test_setup ( void ) {
static int x = 0 ;
x ++ ;
snprintf_func ( TEST_TARGET_FILE , TESTFILESIZE , "/tmp/xdtest.target.%d" , x ) ;
snprintf_func ( TEST_SOURCE_FILE , TESTFILESIZE , "/tmp/xdtest.source.%d" , x ) ;
snprintf_func ( TEST_DELTA_FILE , TESTFILESIZE , "/tmp/xdtest.delta.%d" , x ) ;
snprintf_func ( TEST_RECON_FILE , TESTFILESIZE , "/tmp/xdtest.recon.%d" , x ) ;
snprintf_func ( TEST_RECON2_FILE , TESTFILESIZE , "/tmp/xdtest.recon2.%d" , x ) ;
snprintf_func ( TEST_COPY_FILE , TESTFILESIZE , "/tmp/xdtest.copy.%d" , x ) ;
snprintf_func ( TEST_NOPERM_FILE , TESTFILESIZE , "/tmp/xdtest.noperm.%d" , x ) ;
test_cleanup ( ) ;
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void pdf_process_gsave ( fz_context * ctx , pdf_processor * proc , pdf_csi * csi ) {
if ( proc -> op_q ) proc -> op_q ( ctx , proc ) ;
++ csi -> gstate ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void brincostestimate ( PlannerInfo * root , IndexPath * path , double loop_count , Cost * indexStartupCost , Cost * indexTotalCost , Selectivity * indexSelectivity , double * indexCorrelation ) {
IndexOptInfo * index = path -> indexinfo ;
List * indexQuals = path -> indexquals ;
List * indexOrderBys = path -> indexorderbys ;
double numPages = index -> pages ;
double numTuples = index -> tuples ;
List * qinfos ;
Cost spc_seq_page_cost ;
Cost spc_random_page_cost ;
double qual_op_cost ;
double qual_arg_cost ;
qinfos = deconstruct_indexquals ( path ) ;
get_tablespace_page_costs ( index -> reltablespace , & spc_random_page_cost , & spc_seq_page_cost ) ;
* indexStartupCost = spc_seq_page_cost * numPages * loop_count ;
* indexTotalCost = spc_random_page_cost * numPages * loop_count ;
* indexSelectivity = clauselist_selectivity ( root , indexQuals , path -> indexinfo -> rel -> relid , JOIN_INNER , NULL ) ;
* indexCorrelation = 1 ;
qual_arg_cost = other_operands_eval_cost ( root , qinfos ) + orderby_operands_eval_cost ( root , path ) ;
qual_op_cost = cpu_operator_cost * ( list_length ( indexQuals ) + list_length ( indexOrderBys ) ) ;
* indexStartupCost += qual_arg_cost ;
* indexTotalCost += qual_arg_cost ;
* indexTotalCost += ( numTuples * * indexSelectivity ) * ( cpu_index_tuple_cost + qual_op_cost ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static UBool _isAlphaNumericString ( const char * s , int32_t len ) {
int32_t i ;
for ( i = 0 ;
i < len ;
i ++ ) {
if ( ! ISALPHA ( * ( s + i ) ) && ! ISNUMERIC ( * ( s + i ) ) ) {
return FALSE ;
}
}
return TRUE ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void mpi_set_cond ( MPI w , MPI u , unsigned long set ) {
mpi_size_t i ;
mpi_size_t nlimbs = u -> alloced ;
mpi_limb_t mask = ( ( mpi_limb_t ) 0 ) - ! ! set ;
mpi_limb_t x ;
if ( w -> alloced != u -> alloced ) log_bug ( "mpi_set_cond: different sizes\n" ) ;
for ( i = 0 ;
i < nlimbs ;
i ++ ) {
x = mask & ( w -> d [ i ] ^ u -> d [ i ] ) ;
w -> d [ i ] = w -> d [ i ] ^ x ;
}
x = mask & ( w -> nlimbs ^ u -> nlimbs ) ;
w -> nlimbs = w -> nlimbs ^ x ;
x = mask & ( w -> nbits ^ u -> nbits ) ;
w -> nbits = w -> nbits ^ x ;
x = mask & ( w -> sign ^ u -> sign ) ;
w -> sign = w -> sign ^ x ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void get_image_md5 ( const vpx_image_t * img , unsigned char digest [ 16 ] ) {
int plane , y ;
MD5Context md5 ;
MD5Init ( & md5 ) ;
for ( plane = 0 ;
plane < 3 ;
++ plane ) {
const unsigned char * buf = img -> planes [ plane ] ;
const int stride = img -> stride [ plane ] ;
const int w = plane ? ( img -> d_w + 1 ) >> 1 : img -> d_w ;
const int h = plane ? ( img -> d_h + 1 ) >> 1 : img -> d_h ;
for ( y = 0 ;
y < h ;
++ y ) {
MD5Update ( & md5 , buf , w ) ;
buf += stride ;
}
}
MD5Final ( digest , & md5 ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static inline const guint8 * get_uint_string_value ( wmem_allocator_t * scope , proto_tree * tree , tvbuff_t * tvb , gint start , gint length , gint * ret_length , const guint encoding ) {
guint32 n ;
const guint8 * value ;
n = get_uint_value ( tree , tvb , start , length , encoding & ~ ENC_CHARENCODING_MASK ) ;
value = tvb_get_string_enc ( scope , tvb , start + length , n , encoding ) ;
length += n ;
* ret_length = length ;
return value ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int roq_encode_frame ( AVCodecContext * avctx , AVPacket * pkt , const AVFrame * frame , int * got_packet ) {
RoqContext * enc = avctx -> priv_data ;
int size , ret ;
enc -> avctx = avctx ;
enc -> frame_to_enc = frame ;
if ( frame -> quality ) enc -> lambda = frame -> quality - 1 ;
else enc -> lambda = 2 * ROQ_LAMBDA_SCALE ;
size = ( ( enc -> width * enc -> height / 64 ) * 138 + 7 ) / 8 + 256 * ( 6 + 4 ) + 8 ;
if ( ( ret = ff_alloc_packet ( pkt , size ) ) < 0 ) {
av_log ( avctx , AV_LOG_ERROR , "Error getting output packet with size %d.\n" , size ) ;
return ret ;
}
enc -> out_buf = pkt -> data ;
if ( enc -> framesSinceKeyframe == avctx -> gop_size ) enc -> framesSinceKeyframe = 0 ;
if ( enc -> first_frame ) {
if ( ff_get_buffer ( avctx , enc -> current_frame ) || ff_get_buffer ( avctx , enc -> last_frame ) ) {
av_log ( avctx , AV_LOG_ERROR , " RoQ: get_buffer() failed\n" ) ;
return - 1 ;
}
roq_write_video_info_chunk ( enc ) ;
enc -> first_frame = 0 ;
}
roq_encode_video ( enc ) ;
pkt -> size = enc -> out_buf - pkt -> data ;
if ( enc -> framesSinceKeyframe == 1 ) pkt -> flags |= AV_PKT_FLAG_KEY ;
* got_packet = 1 ;
return 0 ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | void ivalidate_clean_spaces ( i_ctx_t * i_ctx_p ) {
if ( gs_debug_c ( '?' ) ) {
ref_stack_cleanup ( & d_stack ) ;
ref_stack_cleanup ( & e_stack ) ;
ref_stack_cleanup ( & o_stack ) ;
ivalidate_spaces ( ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void activate_desktop_file ( ActivateParameters * parameters , NautilusFile * file ) {
ActivateParametersDesktop * parameters_desktop ;
char * primary , * secondary , * display_name ;
GtkWidget * dialog ;
GdkScreen * screen ;
char * uri ;
screen = gtk_widget_get_screen ( GTK_WIDGET ( parameters -> parent_window ) ) ;
if ( ! nautilus_file_is_trusted_link ( file ) ) {
parameters_desktop = g_new0 ( ActivateParametersDesktop , 1 ) ;
if ( parameters -> parent_window ) {
parameters_desktop -> parent_window = parameters -> parent_window ;
g_object_add_weak_pointer ( G_OBJECT ( parameters_desktop -> parent_window ) , ( gpointer * ) & parameters_desktop -> parent_window ) ;
}
parameters_desktop -> file = nautilus_file_ref ( file ) ;
primary = _ ( "Untrusted application launcher" ) ;
display_name = nautilus_file_get_display_name ( file ) ;
secondary = g_strdup_printf ( _ ( "The application launcher “%s” has not been marked as trusted. " "If you do not know the source of this file, launching it may be unsafe." ) , display_name ) ;
dialog = gtk_message_dialog_new ( parameters -> parent_window , 0 , GTK_MESSAGE_WARNING , GTK_BUTTONS_NONE , NULL ) ;
g_object_set ( dialog , "text" , primary , "secondary-text" , secondary , NULL ) ;
gtk_dialog_add_button ( GTK_DIALOG ( dialog ) , _ ( "_Cancel" ) , GTK_RESPONSE_CANCEL ) ;
gtk_dialog_set_default_response ( GTK_DIALOG ( dialog ) , GTK_RESPONSE_CANCEL ) ;
if ( nautilus_file_can_set_permissions ( file ) ) {
gtk_dialog_add_button ( GTK_DIALOG ( dialog ) , _ ( "Trust and _Launch" ) , GTK_RESPONSE_OK ) ;
}
g_signal_connect ( dialog , "response" , G_CALLBACK ( untrusted_launcher_response_callback ) , parameters_desktop ) ;
gtk_widget_show ( dialog ) ;
g_free ( display_name ) ;
g_free ( secondary ) ;
return ;
}
uri = nautilus_file_get_uri ( file ) ;
DEBUG ( "Launching trusted launcher %s" , uri ) ;
nautilus_launch_desktop_file ( screen , uri , NULL , parameters -> parent_window ) ;
g_free ( uri ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void ff_fix_long_p_mvs ( MpegEncContext * s ) {
MotionEstContext * const c = & s -> me ;
const int f_code = s -> f_code ;
int y , range ;
assert ( s -> pict_type == AV_PICTURE_TYPE_P ) ;
range = ( ( ( s -> out_format == FMT_MPEG1 || s -> msmpeg4_version ) ? 8 : 16 ) << f_code ) ;
assert ( range <= 16 || ! s -> msmpeg4_version ) ;
assert ( range <= 256 || ! ( s -> codec_id == AV_CODEC_ID_MPEG2VIDEO && s -> avctx -> strict_std_compliance >= FF_COMPLIANCE_NORMAL ) ) ;
if ( c -> avctx -> me_range && range > c -> avctx -> me_range ) range = c -> avctx -> me_range ;
if ( s -> flags & CODEC_FLAG_4MV ) {
const int wrap = s -> b8_stride ;
for ( y = 0 ;
y < s -> mb_height ;
y ++ ) {
int xy = y * 2 * wrap ;
int i = y * s -> mb_stride ;
int x ;
for ( x = 0 ;
x < s -> mb_width ;
x ++ ) {
if ( s -> mb_type [ i ] & CANDIDATE_MB_TYPE_INTER4V ) {
int block ;
for ( block = 0 ;
block < 4 ;
block ++ ) {
int off = ( block & 1 ) + ( block >> 1 ) * wrap ;
int mx = s -> current_picture . f . motion_val [ 0 ] [ xy + off ] [ 0 ] ;
int my = s -> current_picture . f . motion_val [ 0 ] [ xy + off ] [ 1 ] ;
if ( mx >= range || mx < - range || my >= range || my < - range ) {
s -> mb_type [ i ] &= ~ CANDIDATE_MB_TYPE_INTER4V ;
s -> mb_type [ i ] |= CANDIDATE_MB_TYPE_INTRA ;
s -> current_picture . f . mb_type [ i ] = CANDIDATE_MB_TYPE_INTRA ;
}
}
}
xy += 2 ;
i ++ ;
}
}
}
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static void binkb_init_bundles ( BinkContext * c ) {
int i ;
for ( i = 0 ;
i < BINKB_NB_SRC ;
i ++ ) binkb_init_bundle ( c , i ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void fix_history ( String * final_command ) {
int total_lines = 1 ;
char * ptr = final_command -> c_ptr ( ) ;
String fixed_buffer ;
char str_char = '\0' ;
while ( * ptr != '\0' ) {
switch ( * ptr ) {
case '"' : case '\'' : case '`' : if ( str_char == '\0' ) str_char = * ptr ;
else if ( str_char == * ptr ) str_char = '\0' ;
fixed_buffer . append ( ptr , 1 ) ;
break ;
case '\n' : fixed_buffer . append ( str_char == '\0' ? " " : "\n" ) ;
total_lines ++ ;
break ;
case '\\' : fixed_buffer . append ( '\\' ) ;
if ( str_char ) {
ptr ++ ;
if ( * ptr == '\'' || * ptr == '"' || * ptr == '\\' ) fixed_buffer . append ( ptr , 1 ) ;
else ptr -- ;
}
break ;
default : fixed_buffer . append ( ptr , 1 ) ;
}
ptr ++ ;
}
if ( total_lines > 1 ) add_history ( fixed_buffer . ptr ( ) ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void test_bug9520 ( ) {
MYSQL_STMT * stmt ;
MYSQL_BIND my_bind [ 1 ] ;
char a [ 6 ] ;
ulong a_len ;
int rc , row_count = 0 ;
myheader ( "test_bug9520" ) ;
mysql_query ( mysql , "drop table if exists t1" ) ;
mysql_query ( mysql , "create table t1 (a char(5), b char(5), c char(5)," " primary key (a, b, c))" ) ;
rc = mysql_query ( mysql , "insert into t1 values ('x', 'y', 'z'), " " ('a', 'b', 'c'), ('k', 'l', 'm')" ) ;
myquery ( rc ) ;
stmt = open_cursor ( "select distinct b from t1" ) ;
rc = mysql_stmt_execute ( stmt ) ;
check_execute ( stmt , rc ) ;
memset ( my_bind , 0 , sizeof ( my_bind ) ) ;
my_bind [ 0 ] . buffer_type = MYSQL_TYPE_STRING ;
my_bind [ 0 ] . buffer = ( char * ) a ;
my_bind [ 0 ] . buffer_length = sizeof ( a ) ;
my_bind [ 0 ] . length = & a_len ;
mysql_stmt_bind_result ( stmt , my_bind ) ;
while ( ! ( rc = mysql_stmt_fetch ( stmt ) ) ) row_count ++ ;
DIE_UNLESS ( rc == MYSQL_NO_DATA ) ;
if ( ! opt_silent ) printf ( "Fetched %d rows\n" , row_count ) ;
DBUG_ASSERT ( row_count == 3 ) ;
mysql_stmt_close ( stmt ) ;
rc = mysql_query ( mysql , "drop table t1" ) ;
myquery ( rc ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static mac_is_sdu * get_sdu ( guint frame_num , guint16 tsn , guint8 type , mac_is_channel * ch ) {
mac_is_sdu * sdu = NULL ;
GHashTable * sdus = NULL ;
mac_is_fragment frag_lookup_key ;
sdus = ( GHashTable * ) g_hash_table_lookup ( mac_is_sdus , ch ) ;
if ( sdus ) {
frag_lookup_key . frame_num = frame_num ;
frag_lookup_key . tsn = tsn ;
frag_lookup_key . type = type ;
sdu = ( mac_is_sdu * ) g_hash_table_lookup ( sdus , & frag_lookup_key ) ;
return sdu ;
}
return NULL ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void vp9_decode_frame ( VP9Decoder * pbi , const uint8_t * data , const uint8_t * data_end , const uint8_t * * p_data_end ) {
VP9_COMMON * const cm = & pbi -> common ;
MACROBLOCKD * const xd = & pbi -> mb ;
struct vp9_read_bit_buffer rb = {
NULL , NULL , 0 , NULL , 0 }
;
uint8_t clear_data [ MAX_VP9_HEADER_SIZE ] ;
const size_t first_partition_size = read_uncompressed_header ( pbi , init_read_bit_buffer ( pbi , & rb , data , data_end , clear_data ) ) ;
const int tile_rows = 1 << cm -> log2_tile_rows ;
const int tile_cols = 1 << cm -> log2_tile_cols ;
YV12_BUFFER_CONFIG * const new_fb = get_frame_new_buffer ( cm ) ;
xd -> cur_buf = new_fb ;
if ( ! first_partition_size ) {
* p_data_end = data + 1 ;
return ;
}
data += vp9_rb_bytes_read ( & rb ) ;
if ( ! read_is_valid ( data , first_partition_size , data_end ) ) vpx_internal_error ( & cm -> error , VPX_CODEC_CORRUPT_FRAME , "Truncated packet or corrupt header length" ) ;
init_macroblockd ( cm , & pbi -> mb ) ;
if ( cm -> coding_use_prev_mi ) set_prev_mi ( cm ) ;
else cm -> prev_mi = NULL ;
setup_plane_dequants ( cm , xd , cm -> base_qindex ) ;
vp9_setup_block_planes ( xd , cm -> subsampling_x , cm -> subsampling_y ) ;
cm -> fc = cm -> frame_contexts [ cm -> frame_context_idx ] ;
vp9_zero ( cm -> counts ) ;
vp9_zero ( xd -> dqcoeff ) ;
xd -> corrupted = 0 ;
new_fb -> corrupted = read_compressed_header ( pbi , data , first_partition_size ) ;
if ( pbi -> max_threads > 1 && tile_rows == 1 && tile_cols > 1 && cm -> frame_parallel_decoding_mode ) {
* p_data_end = decode_tiles_mt ( pbi , data + first_partition_size , data_end ) ;
vp9_loop_filter_frame_mt ( new_fb , pbi , cm , cm -> lf . filter_level , 0 ) ;
}
else {
* p_data_end = decode_tiles ( pbi , data + first_partition_size , data_end ) ;
}
new_fb -> corrupted |= xd -> corrupted ;
if ( ! new_fb -> corrupted ) {
if ( ! cm -> error_resilient_mode && ! cm -> frame_parallel_decoding_mode ) {
vp9_adapt_coef_probs ( cm ) ;
if ( ! frame_is_intra_only ( cm ) ) {
vp9_adapt_mode_probs ( cm ) ;
vp9_adapt_mv_probs ( cm , cm -> allow_high_precision_mv ) ;
}
}
else {
debug_check_frame_counts ( cm ) ;
}
}
else {
vpx_internal_error ( & cm -> error , VPX_CODEC_CORRUPT_FRAME , "Decode failed. Frame data is corrupted." ) ;
}
if ( cm -> refresh_frame_context ) cm -> frame_contexts [ cm -> frame_context_idx ] = cm -> fc ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int ipvideo_decode_block_opcode_0x6 ( IpvideoContext * s , AVFrame * frame ) {
av_log ( s -> avctx , AV_LOG_ERROR , " Interplay video: Help! Mystery opcode 0x6 seen\n" ) ;
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static unsigned int hc_str ( const char * s , size_t len ) {
unsigned int r = 0 ;
while ( len -- > 0 ) r = r * 31 + * s ++ ;
return r ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int qemuMonitorTextSystemPowerdown ( qemuMonitorPtr mon ) {
char * info ;
if ( qemuMonitorHMPCommand ( mon , "system_powerdown" , & info ) < 0 ) {
qemuReportError ( VIR_ERR_OPERATION_FAILED , "%s" , _ ( "system shutdown operation failed" ) ) ;
return - 1 ;
}
VIR_FREE ( info ) ;
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static hb_ ## name ## _t * _hb_ ## name ## _reference ( const hb_ ## name ## _t * l ) {
hb_ ## name ## _t * c = ( hb_ ## name ## _t * ) calloc ( 1 , sizeof ( hb_ ## name ## _t ) ) ;
if ( unlikely ( ! c ) ) return NULL ;
* c = * l ;
return c ;
}
static void _hb_ ## name ## _destroy ( hb_ ## name ## _t * l ) {
free ( l ) ;
}
HB_DEFINE_BOXED_TYPE ( name , _hb_ ## name ## _reference , _hb_ ## name ## _destroy ) ;
HB_DEFINE_OBJECT_TYPE ( buffer ) HB_DEFINE_OBJECT_TYPE ( blob ) HB_DEFINE_OBJECT_TYPE ( face ) HB_DEFINE_OBJECT_TYPE ( font ) HB_DEFINE_OBJECT_TYPE ( font_funcs ) HB_DEFINE_OBJECT_TYPE ( set ) HB_DEFINE_OBJECT_TYPE ( shape_plan ) HB_DEFINE_OBJECT_TYPE ( unicode_funcs ) HB_DEFINE_VALUE_TYPE ( feature ) HB_DEFINE_VALUE_TYPE ( glyph_info ) | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void convert_bytea_to_scalar ( Datum value , double * scaledvalue , Datum lobound , double * scaledlobound , Datum hibound , double * scaledhibound ) {
int rangelo , rangehi , valuelen = VARSIZE ( DatumGetPointer ( value ) ) - VARHDRSZ , loboundlen = VARSIZE ( DatumGetPointer ( lobound ) ) - VARHDRSZ , hiboundlen = VARSIZE ( DatumGetPointer ( hibound ) ) - VARHDRSZ , i , minlen ;
unsigned char * valstr = ( unsigned char * ) VARDATA ( DatumGetPointer ( value ) ) , * lostr = ( unsigned char * ) VARDATA ( DatumGetPointer ( lobound ) ) , * histr = ( unsigned char * ) VARDATA ( DatumGetPointer ( hibound ) ) ;
rangelo = 0 ;
rangehi = 255 ;
minlen = Min ( Min ( valuelen , loboundlen ) , hiboundlen ) ;
for ( i = 0 ;
i < minlen ;
i ++ ) {
if ( * lostr != * histr || * lostr != * valstr ) break ;
lostr ++ , histr ++ , valstr ++ ;
loboundlen -- , hiboundlen -- , valuelen -- ;
}
* scaledvalue = convert_one_bytea_to_scalar ( valstr , valuelen , rangelo , rangehi ) ;
* scaledlobound = convert_one_bytea_to_scalar ( lostr , loboundlen , rangelo , rangehi ) ;
* scaledhibound = convert_one_bytea_to_scalar ( histr , hiboundlen , rangelo , rangehi ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int isofile_register_hardlink ( struct archive_write * a , struct isofile * file ) {
struct iso9660 * iso9660 = a -> format_data ;
struct hardlink * hl ;
const char * pathname ;
archive_entry_set_nlink ( file -> entry , 1 ) ;
pathname = archive_entry_hardlink ( file -> entry ) ;
if ( pathname == NULL ) {
hl = malloc ( sizeof ( * hl ) ) ;
if ( hl == NULL ) {
archive_set_error ( & a -> archive , ENOMEM , "Can't allocate memory" ) ;
return ( ARCHIVE_FATAL ) ;
}
hl -> nlink = 1 ;
file -> hlnext = NULL ;
hl -> file_list . first = file ;
hl -> file_list . last = & ( file -> hlnext ) ;
__archive_rb_tree_insert_node ( & ( iso9660 -> hardlink_rbtree ) , ( struct archive_rb_node * ) hl ) ;
}
else {
hl = ( struct hardlink * ) __archive_rb_tree_find_node ( & ( iso9660 -> hardlink_rbtree ) , pathname ) ;
if ( hl != NULL ) {
file -> hlnext = NULL ;
* hl -> file_list . last = file ;
hl -> file_list . last = & ( file -> hlnext ) ;
hl -> nlink ++ ;
}
archive_entry_unset_size ( file -> entry ) ;
}
return ( ARCHIVE_OK ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int decode_frame ( WmallDecodeCtx * s ) {
GetBitContext * gb = & s -> gb ;
int more_frames = 0 , len = 0 , i , ret ;
s -> frame . nb_samples = s -> samples_per_frame ;
if ( ( ret = ff_get_buffer ( s -> avctx , & s -> frame ) ) < 0 ) {
av_log ( s -> avctx , AV_LOG_ERROR , "not enough space for the output samples\n" ) ;
s -> packet_loss = 1 ;
return ret ;
}
for ( i = 0 ;
i < s -> num_channels ;
i ++ ) {
s -> samples_16 [ i ] = ( int16_t * ) s -> frame . extended_data [ i ] ;
s -> samples_32 [ i ] = ( int32_t * ) s -> frame . extended_data [ i ] ;
}
if ( s -> len_prefix ) len = get_bits ( gb , s -> log2_frame_size ) ;
if ( decode_tilehdr ( s ) ) {
s -> packet_loss = 1 ;
return 0 ;
}
if ( s -> dynamic_range_compression ) s -> drc_gain = get_bits ( gb , 8 ) ;
if ( get_bits1 ( gb ) ) {
int av_unused skip ;
if ( get_bits1 ( gb ) ) {
skip = get_bits ( gb , av_log2 ( s -> samples_per_frame * 2 ) ) ;
av_dlog ( s -> avctx , "start skip: %i\n" , skip ) ;
}
if ( get_bits1 ( gb ) ) {
skip = get_bits ( gb , av_log2 ( s -> samples_per_frame * 2 ) ) ;
av_dlog ( s -> avctx , "end skip: %i\n" , skip ) ;
}
}
s -> parsed_all_subframes = 0 ;
for ( i = 0 ;
i < s -> num_channels ;
i ++ ) {
s -> channel [ i ] . decoded_samples = 0 ;
s -> channel [ i ] . cur_subframe = 0 ;
}
while ( ! s -> parsed_all_subframes ) {
if ( decode_subframe ( s ) < 0 ) {
s -> packet_loss = 1 ;
return 0 ;
}
}
av_dlog ( s -> avctx , "Frame done\n" ) ;
if ( s -> skip_frame ) s -> skip_frame = 0 ;
if ( s -> len_prefix ) {
if ( len != ( get_bits_count ( gb ) - s -> frame_offset ) + 2 ) {
av_log ( s -> avctx , AV_LOG_ERROR , "frame[%i] would have to skip %i bits\n" , s -> frame_num , len - ( get_bits_count ( gb ) - s -> frame_offset ) - 1 ) ;
s -> packet_loss = 1 ;
return 0 ;
}
skip_bits_long ( gb , len - ( get_bits_count ( gb ) - s -> frame_offset ) - 1 ) ;
}
more_frames = get_bits1 ( gb ) ;
++ s -> frame_num ;
return more_frames ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static void model256_update ( Model256 * m , int val ) {
int i , sum = 0 ;
unsigned scale ;
int send , sidx = 1 ;
m -> weights [ val ] ++ ;
m -> till_rescale -- ;
if ( m -> till_rescale ) return ;
m -> tot_weight += m -> upd_val ;
if ( m -> tot_weight > 0x8000 ) {
m -> tot_weight = 0 ;
for ( i = 0 ;
i < 256 ;
i ++ ) {
m -> weights [ i ] = ( m -> weights [ i ] + 1 ) >> 1 ;
m -> tot_weight += m -> weights [ i ] ;
}
}
scale = 0x80000000u / m -> tot_weight ;
m -> secondary [ 0 ] = 0 ;
for ( i = 0 ;
i < 256 ;
i ++ ) {
m -> freqs [ i ] = sum * scale >> 16 ;
sum += m -> weights [ i ] ;
send = m -> freqs [ i ] >> MODEL256_SEC_SCALE ;
while ( sidx <= send ) m -> secondary [ sidx ++ ] = i - 1 ;
}
while ( sidx < m -> sec_size ) m -> secondary [ sidx ++ ] = 255 ;
m -> upd_val = m -> upd_val * 5 >> 2 ;
if ( m -> upd_val > m -> max_upd_val ) m -> upd_val = m -> max_upd_val ;
m -> till_rescale = m -> upd_val ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void tb_invalidate_phys_page ( tb_page_addr_t addr , uintptr_t pc , void * puc ) {
TranslationBlock * tb ;
PageDesc * p ;
int n ;
# ifdef TARGET_HAS_PRECISE_SMC TranslationBlock * current_tb = NULL ;
CPUState * cpu = current_cpu ;
CPUArchState * env = NULL ;
int current_tb_modified = 0 ;
target_ulong current_pc = 0 ;
target_ulong current_cs_base = 0 ;
int current_flags = 0 ;
# endif addr &= TARGET_PAGE_MASK ;
p = page_find ( addr >> TARGET_PAGE_BITS ) ;
if ( ! p ) {
return ;
}
tb = p -> first_tb ;
# ifdef TARGET_HAS_PRECISE_SMC if ( tb && pc != 0 ) {
current_tb = tb_find_pc ( pc ) ;
}
if ( cpu != NULL ) {
env = cpu -> env_ptr ;
}
# endif while ( tb != NULL ) {
n = ( uintptr_t ) tb & 3 ;
tb = ( TranslationBlock * ) ( ( uintptr_t ) tb & ~ 3 ) ;
# ifdef TARGET_HAS_PRECISE_SMC if ( current_tb == tb && ( current_tb -> cflags & CF_COUNT_MASK ) != 1 ) {
current_tb_modified = 1 ;
cpu_restore_state_from_tb ( current_tb , env , pc ) ;
cpu_get_tb_cpu_state ( env , & current_pc , & current_cs_base , & current_flags ) ;
}
# endif tb_phys_invalidate ( tb , addr ) ;
tb = tb -> page_next [ n ] ;
}
p -> first_tb = NULL ;
# ifdef TARGET_HAS_PRECISE_SMC if ( current_tb_modified ) {
cpu -> current_tb = NULL ;
tb_gen_code ( env , current_pc , current_cs_base , current_flags , 1 ) ;
cpu_resume_from_signal ( env , puc ) ;
}
# endif } | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int record_hardlink ( struct archive_read * a , struct cpio * cpio , struct archive_entry * entry ) {
struct links_entry * le ;
dev_t dev ;
int64_t ino ;
if ( archive_entry_nlink ( entry ) <= 1 ) return ( ARCHIVE_OK ) ;
dev = archive_entry_dev ( entry ) ;
ino = archive_entry_ino64 ( entry ) ;
for ( le = cpio -> links_head ;
le ;
le = le -> next ) {
if ( le -> dev == dev && le -> ino == ino ) {
archive_entry_copy_hardlink ( entry , le -> name ) ;
if ( -- le -> links <= 0 ) {
if ( le -> previous != NULL ) le -> previous -> next = le -> next ;
if ( le -> next != NULL ) le -> next -> previous = le -> previous ;
if ( cpio -> links_head == le ) cpio -> links_head = le -> next ;
free ( le -> name ) ;
free ( le ) ;
}
return ( ARCHIVE_OK ) ;
}
}
le = ( struct links_entry * ) malloc ( sizeof ( struct links_entry ) ) ;
if ( le == NULL ) {
archive_set_error ( & a -> archive , ENOMEM , "Out of memory adding file to list" ) ;
return ( ARCHIVE_FATAL ) ;
}
if ( cpio -> links_head != NULL ) cpio -> links_head -> previous = le ;
le -> next = cpio -> links_head ;
le -> previous = NULL ;
cpio -> links_head = le ;
le -> dev = dev ;
le -> ino = ino ;
le -> links = archive_entry_nlink ( entry ) - 1 ;
le -> name = strdup ( archive_entry_pathname ( entry ) ) ;
if ( le -> name == NULL ) {
archive_set_error ( & a -> archive , ENOMEM , "Out of memory adding file to list" ) ;
return ( ARCHIVE_FATAL ) ;
}
return ( ARCHIVE_OK ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | kadm5_ret_t kadm5_create_principal_3 ( void * server_handle , kadm5_principal_ent_t entry , long mask , int n_ks_tuple , krb5_key_salt_tuple * ks_tuple , char * password ) {
krb5_db_entry * kdb ;
osa_princ_ent_rec adb ;
kadm5_policy_ent_rec polent ;
krb5_boolean have_polent = FALSE ;
krb5_int32 now ;
krb5_tl_data * tl_data_tail ;
unsigned int ret ;
kadm5_server_handle_t handle = server_handle ;
krb5_keyblock * act_mkey ;
krb5_kvno act_kvno ;
int new_n_ks_tuple = 0 ;
krb5_key_salt_tuple * new_ks_tuple = NULL ;
CHECK_HANDLE ( server_handle ) ;
krb5_clear_error_message ( handle -> context ) ;
check_1_6_dummy ( entry , mask , n_ks_tuple , ks_tuple , & password ) ;
if ( ! ( mask & KADM5_PRINCIPAL ) || ( mask & KADM5_MOD_NAME ) || ( mask & KADM5_MOD_TIME ) || ( mask & KADM5_LAST_PWD_CHANGE ) || ( mask & KADM5_MKVNO ) || ( mask & KADM5_AUX_ATTRIBUTES ) || ( mask & KADM5_LAST_SUCCESS ) || ( mask & KADM5_LAST_FAILED ) || ( mask & KADM5_FAIL_AUTH_COUNT ) ) return KADM5_BAD_MASK ;
if ( ( mask & KADM5_KEY_DATA ) && entry -> n_key_data != 0 ) return KADM5_BAD_MASK ;
if ( ( mask & KADM5_POLICY ) && ( mask & KADM5_POLICY_CLR ) ) return KADM5_BAD_MASK ;
if ( ( mask & ~ ALL_PRINC_MASK ) ) return KADM5_BAD_MASK ;
if ( entry == NULL ) return EINVAL ;
ret = kdb_get_entry ( handle , entry -> principal , & kdb , & adb ) ;
switch ( ret ) {
case KADM5_UNK_PRINC : break ;
case 0 : kdb_free_entry ( handle , kdb , & adb ) ;
return KADM5_DUP ;
default : return ret ;
}
kdb = krb5_db_alloc ( handle -> context , NULL , sizeof ( * kdb ) ) ;
if ( kdb == NULL ) return ENOMEM ;
memset ( kdb , 0 , sizeof ( * kdb ) ) ;
memset ( & adb , 0 , sizeof ( osa_princ_ent_rec ) ) ;
if ( ( mask & KADM5_POLICY ) ) {
ret = get_policy ( handle , entry -> policy , & polent , & have_polent ) ;
if ( ret ) goto cleanup ;
}
if ( password ) {
ret = passwd_check ( handle , password , have_polent ? & polent : NULL , entry -> principal ) ;
if ( ret ) goto cleanup ;
}
if ( ( ret = krb5_timeofday ( handle -> context , & now ) ) ) goto cleanup ;
kdb -> magic = KRB5_KDB_MAGIC_NUMBER ;
kdb -> len = KRB5_KDB_V1_BASE_LENGTH ;
if ( ( mask & KADM5_ATTRIBUTES ) ) kdb -> attributes = entry -> attributes ;
else kdb -> attributes = handle -> params . flags ;
if ( ( mask & KADM5_MAX_LIFE ) ) kdb -> max_life = entry -> max_life ;
else kdb -> max_life = handle -> params . max_life ;
if ( mask & KADM5_MAX_RLIFE ) kdb -> max_renewable_life = entry -> max_renewable_life ;
else kdb -> max_renewable_life = handle -> params . max_rlife ;
if ( ( mask & KADM5_PRINC_EXPIRE_TIME ) ) kdb -> expiration = entry -> princ_expire_time ;
else kdb -> expiration = handle -> params . expiration ;
kdb -> pw_expiration = 0 ;
if ( have_polent ) {
if ( polent . pw_max_life ) kdb -> pw_expiration = now + polent . pw_max_life ;
else kdb -> pw_expiration = 0 ;
}
if ( ( mask & KADM5_PW_EXPIRATION ) ) kdb -> pw_expiration = entry -> pw_expiration ;
kdb -> last_success = 0 ;
kdb -> last_failed = 0 ;
kdb -> fail_auth_count = 0 ;
if ( ( ret = kadm5_copy_principal ( handle -> context , entry -> principal , & ( kdb -> princ ) ) ) ) goto cleanup ;
if ( ( ret = krb5_dbe_update_last_pwd_change ( handle -> context , kdb , now ) ) ) goto cleanup ;
if ( mask & KADM5_TL_DATA ) {
for ( tl_data_tail = entry -> tl_data ;
tl_data_tail ;
tl_data_tail = tl_data_tail -> tl_data_next ) {
ret = krb5_dbe_update_tl_data ( handle -> context , kdb , tl_data_tail ) ;
if ( ret ) goto cleanup ;
}
}
ret = apply_keysalt_policy ( handle , entry -> policy , n_ks_tuple , ks_tuple , & new_n_ks_tuple , & new_ks_tuple ) ;
if ( ret ) goto cleanup ;
ret = kdb_get_active_mkey ( handle , & act_kvno , & act_mkey ) ;
if ( ret ) goto cleanup ;
if ( mask & KADM5_KEY_DATA ) {
assert ( entry -> n_key_data == 0 ) ;
}
else if ( password ) {
ret = krb5_dbe_cpw ( handle -> context , act_mkey , new_ks_tuple , new_n_ks_tuple , password , ( mask & KADM5_KVNO ) ? entry -> kvno : 1 , FALSE , kdb ) ;
}
else {
ret = krb5_dbe_crk ( handle -> context , & master_keyblock , new_ks_tuple , new_n_ks_tuple , FALSE , kdb ) ;
}
if ( ret ) goto cleanup ;
ret = krb5_dbe_update_mkvno ( handle -> context , kdb , act_kvno ) ;
if ( ret ) goto cleanup ;
ret = k5_kadm5_hook_create ( handle -> context , handle -> hook_handles , KADM5_HOOK_STAGE_PRECOMMIT , entry , mask , new_n_ks_tuple , new_ks_tuple , password ) ;
if ( ret ) goto cleanup ;
adb . admin_history_kvno = INITIAL_HIST_KVNO ;
if ( mask & KADM5_POLICY ) {
adb . aux_attributes = KADM5_POLICY ;
adb . policy = entry -> policy ;
}
kdb -> mask = mask | KADM5_KEY_DATA | KADM5_PRINCIPAL ;
ret = kdb_put_entry ( handle , kdb , & adb ) ;
( void ) k5_kadm5_hook_create ( handle -> context , handle -> hook_handles , KADM5_HOOK_STAGE_POSTCOMMIT , entry , mask , new_n_ks_tuple , new_ks_tuple , password ) ;
cleanup : free ( new_ks_tuple ) ;
krb5_db_free_principal ( handle -> context , kdb ) ;
if ( have_polent ) ( void ) kadm5_free_policy_ent ( handle -> lhandle , & polent ) ;
return ret ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | size_t Curl_FormReader ( char * buffer , size_t size , size_t nitems , FILE * mydata ) {
struct Form * form ;
size_t wantedsize ;
size_t gotsize = 0 ;
form = ( struct Form * ) mydata ;
wantedsize = size * nitems ;
if ( ! form -> data ) return 0 ;
if ( ( form -> data -> type == FORM_FILE ) || ( form -> data -> type == FORM_CALLBACK ) ) {
gotsize = readfromfile ( form , buffer , wantedsize ) ;
if ( gotsize ) return gotsize ;
}
do {
if ( ( form -> data -> length - form -> sent ) > wantedsize - gotsize ) {
memcpy ( buffer + gotsize , form -> data -> line + form -> sent , wantedsize - gotsize ) ;
form -> sent += wantedsize - gotsize ;
return wantedsize ;
}
memcpy ( buffer + gotsize , form -> data -> line + form -> sent , ( form -> data -> length - form -> sent ) ) ;
gotsize += form -> data -> length - form -> sent ;
form -> sent = 0 ;
form -> data = form -> data -> next ;
}
while ( form -> data && ( form -> data -> type < FORM_CALLBACK ) ) ;
return gotsize ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int vp9_pattern_search ( const MACROBLOCK * x , MV * ref_mv , int search_param , int sad_per_bit , int do_init_search , int * sad_list , const vp9_variance_fn_ptr_t * vfp , int use_mvcost , const MV * center_mv , MV * best_mv , const int num_candidates [ MAX_PATTERN_SCALES ] , const MV candidates [ MAX_PATTERN_SCALES ] [ MAX_PATTERN_CANDIDATES ] ) {
const MACROBLOCKD * const xd = & x -> e_mbd ;
static const int search_param_to_steps [ MAX_MVSEARCH_STEPS ] = {
10 , 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 , }
;
int i , s , t ;
const struct buf_2d * const what = & x -> plane [ 0 ] . src ;
const struct buf_2d * const in_what = & xd -> plane [ 0 ] . pre [ 0 ] ;
int br , bc ;
int bestsad = INT_MAX ;
int thissad ;
int k = - 1 ;
const MV fcenter_mv = {
center_mv -> row >> 3 , center_mv -> col >> 3 }
;
int best_init_s = search_param_to_steps [ search_param ] ;
clamp_mv ( ref_mv , x -> mv_col_min , x -> mv_col_max , x -> mv_row_min , x -> mv_row_max ) ;
br = ref_mv -> row ;
bc = ref_mv -> col ;
bestsad = vfp -> sdf ( what -> buf , what -> stride , get_buf_from_mv ( in_what , ref_mv ) , in_what -> stride ) + mvsad_err_cost ( x , ref_mv , & fcenter_mv , sad_per_bit ) ;
if ( do_init_search ) {
s = best_init_s ;
best_init_s = - 1 ;
for ( t = 0 ;
t <= s ;
++ t ) {
int best_site = - 1 ;
if ( check_bounds ( x , br , bc , 1 << t ) ) {
for ( i = 0 ;
i < num_candidates [ t ] ;
i ++ ) {
const MV this_mv = {
br + candidates [ t ] [ i ] . row , bc + candidates [ t ] [ i ] . col }
;
thissad = vfp -> sdf ( what -> buf , what -> stride , get_buf_from_mv ( in_what , & this_mv ) , in_what -> stride ) ;
CHECK_BETTER }
}
else {
for ( i = 0 ;
i < num_candidates [ t ] ;
i ++ ) {
const MV this_mv = {
br + candidates [ t ] [ i ] . row , bc + candidates [ t ] [ i ] . col }
;
if ( ! is_mv_in ( x , & this_mv ) ) continue ;
thissad = vfp -> sdf ( what -> buf , what -> stride , get_buf_from_mv ( in_what , & this_mv ) , in_what -> stride ) ;
CHECK_BETTER }
}
if ( best_site == - 1 ) {
continue ;
}
else {
best_init_s = t ;
k = best_site ;
}
}
if ( best_init_s != - 1 ) {
br += candidates [ best_init_s ] [ k ] . row ;
bc += candidates [ best_init_s ] [ k ] . col ;
}
}
if ( best_init_s != - 1 ) {
int best_site = - 1 ;
s = best_init_s ;
do {
if ( ! do_init_search || s != best_init_s ) {
if ( check_bounds ( x , br , bc , 1 << s ) ) {
for ( i = 0 ;
i < num_candidates [ s ] ;
i ++ ) {
const MV this_mv = {
br + candidates [ s ] [ i ] . row , bc + candidates [ s ] [ i ] . col }
;
thissad = vfp -> sdf ( what -> buf , what -> stride , get_buf_from_mv ( in_what , & this_mv ) , in_what -> stride ) ;
CHECK_BETTER }
}
else {
for ( i = 0 ;
i < num_candidates [ s ] ;
i ++ ) {
const MV this_mv = {
br + candidates [ s ] [ i ] . row , bc + candidates [ s ] [ i ] . col }
;
if ( ! is_mv_in ( x , & this_mv ) ) continue ;
thissad = vfp -> sdf ( what -> buf , what -> stride , get_buf_from_mv ( in_what , & this_mv ) , in_what -> stride ) ;
CHECK_BETTER }
}
if ( best_site == - 1 ) {
continue ;
}
else {
br += candidates [ s ] [ best_site ] . row ;
bc += candidates [ s ] [ best_site ] . col ;
k = best_site ;
}
}
do {
int next_chkpts_indices [ PATTERN_CANDIDATES_REF ] ;
best_site = - 1 ;
next_chkpts_indices [ 0 ] = ( k == 0 ) ? num_candidates [ s ] - 1 : k - 1 ;
next_chkpts_indices [ 1 ] = k ;
next_chkpts_indices [ 2 ] = ( k == num_candidates [ s ] - 1 ) ? 0 : k + 1 ;
if ( check_bounds ( x , br , bc , 1 << s ) ) {
for ( i = 0 ;
i < PATTERN_CANDIDATES_REF ;
i ++ ) {
const MV this_mv = {
br + candidates [ s ] [ next_chkpts_indices [ i ] ] . row , bc + candidates [ s ] [ next_chkpts_indices [ i ] ] . col }
;
thissad = vfp -> sdf ( what -> buf , what -> stride , get_buf_from_mv ( in_what , & this_mv ) , in_what -> stride ) ;
CHECK_BETTER }
}
else {
for ( i = 0 ;
i < PATTERN_CANDIDATES_REF ;
i ++ ) {
const MV this_mv = {
br + candidates [ s ] [ next_chkpts_indices [ i ] ] . row , bc + candidates [ s ] [ next_chkpts_indices [ i ] ] . col }
;
if ( ! is_mv_in ( x , & this_mv ) ) continue ;
thissad = vfp -> sdf ( what -> buf , what -> stride , get_buf_from_mv ( in_what , & this_mv ) , in_what -> stride ) ;
CHECK_BETTER }
}
if ( best_site != - 1 ) {
k = next_chkpts_indices [ best_site ] ;
br += candidates [ s ] [ k ] . row ;
bc += candidates [ s ] [ k ] . col ;
}
}
while ( best_site != - 1 ) ;
}
while ( s -- ) ;
}
if ( sad_list ) {
static const MV neighbors [ 4 ] = {
{
0 , - 1 }
, {
1 , 0 }
, {
0 , 1 }
, {
- 1 , 0 }
}
;
sad_list [ 0 ] = bestsad ;
if ( check_bounds ( x , br , bc , 1 ) ) {
for ( i = 0 ;
i < 4 ;
i ++ ) {
const MV this_mv = {
br + neighbors [ i ] . row , bc + neighbors [ i ] . col }
;
sad_list [ i + 1 ] = vfp -> sdf ( what -> buf , what -> stride , get_buf_from_mv ( in_what , & this_mv ) , in_what -> stride ) + ( use_mvcost ? mvsad_err_cost ( x , & this_mv , & fcenter_mv , sad_per_bit ) : 0 ) ;
}
}
else {
for ( i = 0 ;
i < 4 ;
i ++ ) {
const MV this_mv = {
br + neighbors [ i ] . row , bc + neighbors [ i ] . col }
;
if ( ! is_mv_in ( x , & this_mv ) ) sad_list [ i + 1 ] = INT_MAX ;
else sad_list [ i + 1 ] = vfp -> sdf ( what -> buf , what -> stride , get_buf_from_mv ( in_what , & this_mv ) , in_what -> stride ) + ( use_mvcost ? mvsad_err_cost ( x , & this_mv , & fcenter_mv , sad_per_bit ) : 0 ) ;
}
}
}
best_mv -> row = br ;
best_mv -> col = bc ;
return bestsad ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void U_CALLCONV T_UConverter_toUnicode_UTF32_BE_OFFSET_LOGIC ( UConverterToUnicodeArgs * args , UErrorCode * err ) {
const unsigned char * mySource = ( unsigned char * ) args -> source ;
UChar * myTarget = args -> target ;
int32_t * myOffsets = args -> offsets ;
const unsigned char * sourceLimit = ( unsigned char * ) args -> sourceLimit ;
const UChar * targetLimit = args -> targetLimit ;
unsigned char * toUBytes = args -> converter -> toUBytes ;
uint32_t ch , i ;
int32_t offsetNum = 0 ;
if ( args -> converter -> toUnicodeStatus && myTarget < targetLimit ) {
i = args -> converter -> toULength ;
args -> converter -> toULength = 0 ;
ch = args -> converter -> toUnicodeStatus - 1 ;
args -> converter -> toUnicodeStatus = 0 ;
goto morebytes ;
}
while ( mySource < sourceLimit && myTarget < targetLimit ) {
i = 0 ;
ch = 0 ;
morebytes : while ( i < sizeof ( uint32_t ) ) {
if ( mySource < sourceLimit ) {
ch = ( ch << 8 ) | ( uint8_t ) ( * mySource ) ;
toUBytes [ i ++ ] = ( char ) * ( mySource ++ ) ;
}
else {
args -> converter -> toUnicodeStatus = ch + 1 ;
args -> converter -> toULength = ( int8_t ) i ;
goto donefornow ;
}
}
if ( ch <= MAXIMUM_UTF && ! U_IS_SURROGATE ( ch ) ) {
if ( ch <= MAXIMUM_UCS2 ) {
* ( myTarget ++ ) = ( UChar ) ch ;
* ( myOffsets ++ ) = offsetNum ;
}
else {
* ( myTarget ++ ) = U16_LEAD ( ch ) ;
* myOffsets ++ = offsetNum ;
ch = U16_TRAIL ( ch ) ;
if ( myTarget < targetLimit ) {
* ( myTarget ++ ) = ( UChar ) ch ;
* ( myOffsets ++ ) = offsetNum ;
}
else {
args -> converter -> UCharErrorBuffer [ 0 ] = ( UChar ) ch ;
args -> converter -> UCharErrorBufferLength = 1 ;
* err = U_BUFFER_OVERFLOW_ERROR ;
break ;
}
}
}
else {
args -> converter -> toULength = ( int8_t ) i ;
* err = U_ILLEGAL_CHAR_FOUND ;
break ;
}
offsetNum += i ;
}
donefornow : if ( mySource < sourceLimit && myTarget >= targetLimit && U_SUCCESS ( * err ) ) {
* err = U_BUFFER_OVERFLOW_ERROR ;
}
args -> target = myTarget ;
args -> source = ( const char * ) mySource ;
args -> offsets = myOffsets ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void dissect_t38_udp ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree ) {
guint8 octet1 ;
proto_item * it ;
proto_tree * tr ;
guint32 offset = 0 ;
if ( dissect_possible_rtpv2_packets_as_rtp ) {
octet1 = tvb_get_guint8 ( tvb , offset ) ;
if ( RTP_VERSION ( octet1 ) == 2 ) {
call_dissector ( rtp_handle , tvb , pinfo , tree ) ;
return ;
}
}
col_set_str ( pinfo -> cinfo , COL_PROTOCOL , "T.38" ) ;
col_clear ( pinfo -> cinfo , COL_INFO ) ;
primary_part = TRUE ;
Data_Field_item_num = 0 ;
it = proto_tree_add_protocol_format ( tree , proto_t38 , tvb , 0 , - 1 , "ITU-T Recommendation T.38" ) ;
tr = proto_item_add_subtree ( it , ett_t38 ) ;
init_t38_info_conv ( pinfo ) ;
if ( global_t38_show_setup_info ) {
show_setup_info ( tvb , tr , p_t38_packet_conv ) ;
}
col_append_str ( pinfo -> cinfo , COL_INFO , "UDP: UDPTLPacket " ) ;
offset = dissect_UDPTLPacket_PDU ( tvb , pinfo , tr , NULL ) ;
if ( tvb_reported_length_remaining ( tvb , offset ) > 0 ) {
proto_tree_add_expert_format ( tr , pinfo , & ei_t38_malformed , tvb , offset , tvb_reported_length_remaining ( tvb , offset ) , "[MALFORMED PACKET or wrong preference settings]" ) ;
col_append_str ( pinfo -> cinfo , COL_INFO , " [Malformed?]" ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | TEST ( BuildTime , DoesntCrash ) {
base : : GetBuildTime ( ) ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | void qdev_machine_creation_done ( void ) {
qdev_hotplug = 1 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void get_rela_elf64 ( Dwarf_Small * data , unsigned int i , int endianness , int machine , struct Dwarf_Elf_Rela * relap ) {
# ifdef HAVE_ELF64_RELA Elf64_Rela * relp = ( Elf64_Rela * ) ( data + ( i * sizeof ( Elf64_Rela ) ) ) ;
relap -> r_offset = relp -> r_offset ;
# define ELF64MIPS_REL_SYM ( i ) ( ( i ) & 0xffffffff ) # define ELF64MIPS_REL_TYPE ( i ) ( ( i >> 56 ) & 0xff ) if ( machine == EM_MIPS && endianness == DW_OBJECT_LSB ) {
relap -> r_type = ELF64MIPS_REL_TYPE ( relp -> r_info ) ;
relap -> r_symidx = ELF64MIPS_REL_SYM ( relp -> r_info ) ;
# undef MIPS64SYM # undef MIPS64TYPE }
else {
relap -> r_type = ELF64_R_TYPE ( relp -> r_info ) ;
relap -> r_symidx = ELF64_R_SYM ( relp -> r_info ) ;
}
relap -> r_addend = relp -> r_addend ;
# endif } | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static gboolean call_ready_callbacks ( NautilusDirectory * directory ) {
gboolean found_any ;
GList * node , * next ;
ReadyCallback * callback ;
found_any = FALSE ;
for ( node = directory -> details -> call_when_ready_list ;
node != NULL ;
node = next ) {
next = node -> next ;
callback = node -> data ;
if ( callback -> active && request_is_satisfied ( directory , callback -> file , callback -> request ) ) {
callback -> active = FALSE ;
found_any = TRUE ;
}
}
if ( found_any ) {
schedule_call_ready_callbacks ( directory ) ;
}
return found_any ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void mct_log ( const char * format , ... ) {
va_list args ;
va_start ( args , format ) ;
vprintf ( format , args ) ;
va_end ( args ) ;
if ( mct_log_file ) {
va_list args ;
va_start ( args , format ) ;
vfprintf ( mct_log_file , format , args ) ;
va_end ( args ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static const char * _warc_find_eol ( const char * buf , size_t bsz ) {
static const char _marker [ ] = "\r\n" ;
const char * hit = xmemmem ( buf , bsz , _marker , sizeof ( _marker ) - 1U ) ;
return hit ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | xmlChar * xsltAttrTemplateValueProcessNode ( xsltTransformContextPtr ctxt , const xmlChar * str , xmlNodePtr inst ) {
xmlChar * ret = NULL ;
const xmlChar * cur ;
xmlChar * expr , * val ;
xmlNsPtr * nsList = NULL ;
int nsNr = 0 ;
if ( str == NULL ) return ( NULL ) ;
if ( * str == 0 ) return ( xmlStrndup ( ( xmlChar * ) "" , 0 ) ) ;
cur = str ;
while ( * cur != 0 ) {
if ( * cur == '{
' ) {
if ( * ( cur + 1 ) == '{
' ) {
cur ++ ;
ret = xmlStrncat ( ret , str , cur - str ) ;
cur ++ ;
str = cur ;
continue ;
}
ret = xmlStrncat ( ret , str , cur - str ) ;
str = cur ;
cur ++ ;
while ( ( * cur != 0 ) && ( * cur != '}
' ) ) cur ++ ;
if ( * cur == 0 ) {
xsltTransformError ( ctxt , NULL , inst , "xsltAttrTemplateValueProcessNode: unmatched '{
'\n" ) ;
ret = xmlStrncat ( ret , str , cur - str ) ;
return ( ret ) ;
}
str ++ ;
expr = xmlStrndup ( str , cur - str ) ;
if ( expr == NULL ) return ( ret ) ;
else if ( * expr == '{
' ) {
ret = xmlStrcat ( ret , expr ) ;
xmlFree ( expr ) ;
}
else {
xmlXPathCompExprPtr comp ;
if ( ( nsList == NULL ) && ( inst != NULL ) ) {
int i = 0 ;
nsList = xmlGetNsList ( inst -> doc , inst ) ;
if ( nsList != NULL ) {
while ( nsList [ i ] != NULL ) i ++ ;
nsNr = i ;
}
}
comp = xmlXPathCompile ( expr ) ;
val = xsltEvalXPathStringNs ( ctxt , comp , nsNr , nsList ) ;
xmlXPathFreeCompExpr ( comp ) ;
xmlFree ( expr ) ;
if ( val != NULL ) {
ret = xmlStrcat ( ret , val ) ;
xmlFree ( val ) ;
}
}
cur ++ ;
str = cur ;
}
else if ( * cur == '}
' ) {
cur ++ ;
if ( * cur == '}
' ) {
ret = xmlStrncat ( ret , str , cur - str ) ;
cur ++ ;
str = cur ;
continue ;
}
else {
xsltTransformError ( ctxt , NULL , inst , "xsltAttrTemplateValueProcessNode: unmatched '}
'\n" ) ;
}
}
else cur ++ ;
}
if ( cur != str ) {
ret = xmlStrncat ( ret , str , cur - str ) ;
}
if ( nsList != NULL ) xmlFree ( nsList ) ;
return ( ret ) ;
} | 1True
|
Categorize the following code snippet as vulnerable or not. True or False | static char * * create_argv_command ( struct rule * rule , struct process * process , struct iovec * * argv ) {
size_t count , i , j , stdin_arg ;
char * * req_argv = NULL ;
const char * program ;
for ( count = 0 ;
argv [ count ] != NULL ;
count ++ ) ;
if ( rule -> sudo_user == NULL ) req_argv = xcalloc ( count + 1 , sizeof ( char * ) ) ;
else req_argv = xcalloc ( count + 5 , sizeof ( char * ) ) ;
if ( rule -> sudo_user != NULL ) {
req_argv [ 0 ] = xstrdup ( PATH_SUDO ) ;
req_argv [ 1 ] = xstrdup ( "-u" ) ;
req_argv [ 2 ] = xstrdup ( rule -> sudo_user ) ;
req_argv [ 3 ] = xstrdup ( "--" ) ;
req_argv [ 4 ] = xstrdup ( rule -> program ) ;
j = 5 ;
}
else {
program = strrchr ( rule -> program , '/' ) ;
if ( program == NULL ) program = rule -> program ;
else program ++ ;
req_argv [ 0 ] = xstrdup ( program ) ;
j = 1 ;
}
if ( rule -> stdin_arg == - 1 ) stdin_arg = count - 1 ;
else stdin_arg = ( size_t ) rule -> stdin_arg ;
for ( i = 1 ;
i < count ;
i ++ ) {
const char * data = argv [ i ] -> iov_base ;
size_t length = argv [ i ] -> iov_len ;
if ( i == stdin_arg ) {
process -> input = evbuffer_new ( ) ;
if ( process -> input == NULL ) die ( "internal error: cannot create input buffer" ) ;
if ( evbuffer_add ( process -> input , data , length ) < 0 ) die ( "internal error: cannot add data to input buffer" ) ;
continue ;
}
if ( length == 0 ) req_argv [ j ] = xstrdup ( "" ) ;
else req_argv [ j ] = xstrndup ( data , length ) ;
j ++ ;
}
req_argv [ j ] = NULL ;
return req_argv ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int vapic_init ( SysBusDevice * dev ) {
VAPICROMState * s = VAPIC ( dev ) ;
memory_region_init_io ( & s -> io , OBJECT ( s ) , & vapic_ops , s , "kvmvapic" , 2 ) ;
sysbus_add_io ( dev , VAPIC_IO_PORT , & s -> io ) ;
sysbus_init_ioports ( dev , VAPIC_IO_PORT , 2 ) ;
option_rom [ nb_option_roms ] . name = "kvmvapic.bin" ;
option_rom [ nb_option_roms ] . bootindex = - 1 ;
nb_option_roms ++ ;
return 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | TSReturnCode TSTextLogObjectRollingEnabledSet ( TSTextLogObject the_object , int rolling_enabled ) {
sdk_assert ( sdk_sanity_check_iocore_structure ( the_object ) == TS_SUCCESS ) ;
if ( LogRollingEnabledIsValid ( rolling_enabled ) ) {
( ( TextLogObject * ) the_object ) -> set_rolling_enabled ( ( Log : : RollingEnabledValues ) rolling_enabled ) ;
return TS_SUCCESS ;
}
return TS_ERROR ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | void evdns_shutdown ( int fail_requests ) {
struct nameserver * server , * server_next ;
struct search_domain * dom , * dom_next ;
while ( req_head ) {
if ( fail_requests ) reply_callback ( req_head , 0 , DNS_ERR_SHUTDOWN , NULL ) ;
request_finished ( req_head , & req_head ) ;
}
while ( req_waiting_head ) {
if ( fail_requests ) reply_callback ( req_waiting_head , 0 , DNS_ERR_SHUTDOWN , NULL ) ;
request_finished ( req_waiting_head , & req_waiting_head ) ;
}
global_requests_inflight = global_requests_waiting = 0 ;
for ( server = server_head ;
server ;
server = server_next ) {
server_next = server -> next ;
if ( server -> socket >= 0 ) CLOSE_SOCKET ( server -> socket ) ;
( void ) event_del ( & server -> event ) ;
if ( server -> state == 0 ) ( void ) event_del ( & server -> timeout_event ) ;
free ( server ) ;
if ( server_next == server_head ) break ;
}
server_head = NULL ;
global_good_nameservers = 0 ;
if ( global_search_state ) {
for ( dom = global_search_state -> head ;
dom ;
dom = dom_next ) {
dom_next = dom -> next ;
free ( dom ) ;
}
free ( global_search_state ) ;
global_search_state = NULL ;
}
evdns_log_fn = NULL ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int dissect_btgatt_microbit_temperature_value ( tvbuff_t * tvb , packet_info * pinfo _U_ , proto_tree * tree , void * data ) {
btatt_data_t * att_data = ( btatt_data_t * ) data ;
gint offset = 0 ;
if ( bluetooth_gatt_has_no_parameter ( att_data -> opcode ) ) return - 1 ;
proto_tree_add_item ( tree , hf_gatt_microbit_temperature_value , tvb , offset , 1 , ENC_NA ) ;
offset += 1 ;
return offset ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | char * xmlrpc_integer ( char * buf , int value ) {
* buf = '\0' ;
if ( ! xmlrpc . inttagstart || ! xmlrpc . inttagend ) {
snprintf ( buf , XMLRPC_BUFSIZE , "<i4>%d</i4>" , value ) ;
}
else {
snprintf ( buf , XMLRPC_BUFSIZE , "%s%d%s" , xmlrpc . inttagstart , value , xmlrpc . inttagend ) ;
free ( xmlrpc . inttagstart ) ;
if ( xmlrpc . inttagend ) {
free ( xmlrpc . inttagend ) ;
xmlrpc . inttagend = NULL ;
}
xmlrpc . inttagstart = NULL ;
}
return buf ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | int event_pending ( struct event * ev , short event , struct timeval * tv ) {
struct timeval now , res ;
int flags = 0 ;
if ( ev -> ev_flags & EVLIST_INSERTED ) flags |= ( ev -> ev_events & ( EV_READ | EV_WRITE | EV_SIGNAL ) ) ;
if ( ev -> ev_flags & EVLIST_ACTIVE ) flags |= ev -> ev_res ;
if ( ev -> ev_flags & EVLIST_TIMEOUT ) flags |= EV_TIMEOUT ;
event &= ( EV_TIMEOUT | EV_READ | EV_WRITE | EV_SIGNAL ) ;
if ( tv != NULL && ( flags & event & EV_TIMEOUT ) ) {
gettime ( ev -> ev_base , & now ) ;
evutil_timersub ( & ev -> ev_timeout , & now , & res ) ;
evutil_gettimeofday ( & now , NULL ) ;
evutil_timeradd ( & now , & res , tv ) ;
}
return ( flags & event ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void test_view_star ( ) {
MYSQL_STMT * stmt ;
int rc , i ;
MYSQL_BIND my_bind [ 8 ] ;
char parms [ 8 ] [ 100 ] ;
ulong length [ 8 ] ;
const char * query = "SELECT * FROM vt1 WHERE a IN (?,?)" ;
myheader ( "test_view_star" ) ;
rc = mysql_query ( mysql , "DROP TABLE IF EXISTS t1, vt1" ) ;
myquery ( rc ) ;
rc = mysql_query ( mysql , "DROP VIEW IF EXISTS t1, vt1" ) ;
myquery ( rc ) ;
rc = mysql_query ( mysql , "CREATE TABLE t1 (a int)" ) ;
myquery ( rc ) ;
rc = mysql_query ( mysql , "CREATE VIEW vt1 AS SELECT a FROM t1" ) ;
myquery ( rc ) ;
memset ( my_bind , 0 , sizeof ( my_bind ) ) ;
for ( i = 0 ;
i < 2 ;
i ++ ) {
sprintf ( ( char * ) & parms [ i ] , "%d" , i ) ;
my_bind [ i ] . buffer_type = MYSQL_TYPE_VAR_STRING ;
my_bind [ i ] . buffer = ( char * ) & parms [ i ] ;
my_bind [ i ] . buffer_length = 100 ;
my_bind [ i ] . is_null = 0 ;
my_bind [ i ] . length = & length [ i ] ;
length [ i ] = 1 ;
}
stmt = mysql_stmt_init ( mysql ) ;
rc = mysql_stmt_prepare ( stmt , query , strlen ( query ) ) ;
check_execute ( stmt , rc ) ;
rc = mysql_stmt_bind_param ( stmt , my_bind ) ;
check_execute ( stmt , rc ) ;
for ( i = 0 ;
i < 3 ;
i ++ ) {
rc = mysql_stmt_execute ( stmt ) ;
check_execute ( stmt , rc ) ;
rc = my_process_stmt_result ( stmt ) ;
DIE_UNLESS ( 0 == rc ) ;
}
mysql_stmt_close ( stmt ) ;
rc = mysql_query ( mysql , "DROP TABLE t1" ) ;
myquery ( rc ) ;
rc = mysql_query ( mysql , "DROP VIEW vt1" ) ;
myquery ( rc ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | IN_PROC_BROWSER_TEST_F ( PageLoadMetricsBrowserTest , NonHtmlMainResource ) {
ASSERT_TRUE ( embedded_test_server ( ) -> Start ( ) ) ;
ui_test_utils : : NavigateToURL ( browser ( ) , embedded_test_server ( ) -> GetURL ( "/circle.svg" ) ) ;
NavigateToUntrackedUrl ( ) ;
EXPECT_TRUE ( NoPageLoadMetricsRecorded ( ) ) << "Recorded metrics: " << GetRecordedPageLoadMetricNames ( ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void test_bug3117 ( ) {
MYSQL_STMT * stmt ;
MYSQL_BIND buffer ;
longlong lii ;
ulong length ;
my_bool is_null ;
int rc ;
myheader ( "test_bug3117" ) ;
rc = mysql_query ( mysql , "DROP TABLE IF EXISTS t1" ) ;
myquery ( rc ) ;
rc = mysql_query ( mysql , "CREATE TABLE t1 (id int auto_increment primary key)" ) ;
myquery ( rc ) ;
stmt = mysql_simple_prepare ( mysql , "SELECT LAST_INSERT_ID()" ) ;
check_stmt ( stmt ) ;
rc = mysql_query ( mysql , "INSERT INTO t1 VALUES (NULL)" ) ;
myquery ( rc ) ;
rc = mysql_stmt_execute ( stmt ) ;
check_execute ( stmt , rc ) ;
memset ( & buffer , 0 , sizeof ( buffer ) ) ;
buffer . buffer_type = MYSQL_TYPE_LONGLONG ;
buffer . buffer_length = sizeof ( lii ) ;
buffer . buffer = ( void * ) & lii ;
buffer . length = & length ;
buffer . is_null = & is_null ;
rc = mysql_stmt_bind_result ( stmt , & buffer ) ;
check_execute ( stmt , rc ) ;
rc = mysql_stmt_store_result ( stmt ) ;
check_execute ( stmt , rc ) ;
rc = mysql_stmt_fetch ( stmt ) ;
check_execute ( stmt , rc ) ;
DIE_UNLESS ( is_null == 0 && lii == 1 ) ;
if ( ! opt_silent ) fprintf ( stdout , "\n\tLAST_INSERT_ID()= 1 ok\n" ) ;
rc = mysql_query ( mysql , "INSERT INTO t1 VALUES (NULL)" ) ;
myquery ( rc ) ;
rc = mysql_stmt_execute ( stmt ) ;
check_execute ( stmt , rc ) ;
rc = mysql_stmt_fetch ( stmt ) ;
check_execute ( stmt , rc ) ;
DIE_UNLESS ( is_null == 0 && lii == 2 ) ;
if ( ! opt_silent ) fprintf ( stdout , "\tLAST_INSERT_ID()= 2 ok\n" ) ;
mysql_stmt_close ( stmt ) ;
rc = mysql_query ( mysql , "DROP TABLE t1" ) ;
myquery ( rc ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int file_compare_by_parent_uri ( NautilusFile * file_a , NautilusFile * file_b ) {
char * parent_uri_a , * parent_uri_b ;
int ret ;
parent_uri_a = nautilus_file_get_parent_uri ( file_a ) ;
parent_uri_b = nautilus_file_get_parent_uri ( file_b ) ;
ret = strcmp ( parent_uri_a , parent_uri_b ) ;
g_free ( parent_uri_a ) ;
g_free ( parent_uri_b ) ;
return ret ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | SPL_METHOD ( SplDoublyLinkedList , next ) {
spl_dllist_object * intern = ( spl_dllist_object * ) zend_object_store_get_object ( getThis ( ) TSRMLS_CC ) ;
if ( zend_parse_parameters_none ( ) == FAILURE ) {
return ;
}
spl_dllist_it_helper_move_forward ( & intern -> traverse_pointer , & intern -> traverse_position , intern -> llist , intern -> flags TSRMLS_CC ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int ioescapestopped ( IO * wrapper , struct psstack * stack , int sp , const size_t bsize ) {
_IO * io = wrapper -> top , * iop ;
int wasstopped ;
while ( io -> prev != NULL ) {
iop = io -> prev ;
wasstopped = io -> isstopped ;
if ( io -> start != NULL ) free ( io -> start ) ;
io -> start = NULL ;
free ( io ) ;
if ( wasstopped ) {
wrapper -> top = iop ;
if ( sp < ( int ) bsize ) {
stack [ sp ] . type = ps_bool ;
stack [ sp ++ ] . u . tf = true ;
}
return ( sp ) ;
}
io = iop ;
}
LogError ( _ ( "Use of \"stop\" when not in a stopped\n" ) ) ;
wrapper -> top = io ;
return ( sp ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | IN_PROC_BROWSER_TEST_F ( SessionRestorePageLoadMetricsBrowserTest , RestoreForeignTab ) {
sessions : : SerializedNavigationEntry nav = sessions : : SerializedNavigationEntryTestHelper : : CreateNavigation ( GetTestURL ( ) . spec ( ) , "one" ) ;
sync_pb : : SessionTab sync_data ;
sync_data . set_tab_visual_index ( 0 ) ;
sync_data . set_current_navigation_index ( 1 ) ;
sync_data . set_pinned ( false ) ;
sync_data . add_navigation ( ) -> CopyFrom ( nav . ToSyncData ( ) ) ;
sessions : : SessionTab tab ;
tab . SetFromSyncData ( sync_data , base : : Time : : Now ( ) ) ;
ASSERT_EQ ( 1 , browser ( ) -> tab_strip_model ( ) -> count ( ) ) ;
content : : WebContents * tab_contents = nullptr ;
{
SessionRestorePaintWaiter session_restore_paint_waiter ;
tab_contents = SessionRestore : : RestoreForeignSessionTab ( browser ( ) -> tab_strip_model ( ) -> GetActiveWebContents ( ) , tab , WindowOpenDisposition : : CURRENT_TAB ) ;
ASSERT_EQ ( 1 , browser ( ) -> tab_strip_model ( ) -> count ( ) ) ;
ASSERT_TRUE ( tab_contents ) ;
ASSERT_EQ ( GetTestURL ( ) , tab_contents -> GetURL ( ) ) ;
session_restore_paint_waiter . WaitForForegroundTabs ( 1 ) ;
ExpectFirstPaintMetricsTotalCount ( 1 ) ;
}
{
SessionRestorePaintWaiter session_restore_paint_waiter ;
tab_contents = SessionRestore : : RestoreForeignSessionTab ( browser ( ) -> tab_strip_model ( ) -> GetActiveWebContents ( ) , tab , WindowOpenDisposition : : NEW_FOREGROUND_TAB ) ;
ASSERT_EQ ( 2 , browser ( ) -> tab_strip_model ( ) -> count ( ) ) ;
ASSERT_EQ ( 1 , browser ( ) -> tab_strip_model ( ) -> active_index ( ) ) ;
ASSERT_TRUE ( tab_contents ) ;
ASSERT_EQ ( GetTestURL ( ) , tab_contents -> GetURL ( ) ) ;
session_restore_paint_waiter . WaitForForegroundTabs ( 1 ) ;
ExpectFirstPaintMetricsTotalCount ( 2 ) ;
}
{
tab_contents = SessionRestore : : RestoreForeignSessionTab ( browser ( ) -> tab_strip_model ( ) -> GetActiveWebContents ( ) , tab , WindowOpenDisposition : : NEW_BACKGROUND_TAB ) ;
ASSERT_EQ ( 3 , browser ( ) -> tab_strip_model ( ) -> count ( ) ) ;
ASSERT_EQ ( 1 , browser ( ) -> tab_strip_model ( ) -> active_index ( ) ) ;
ASSERT_TRUE ( tab_contents ) ;
ASSERT_EQ ( GetTestURL ( ) , tab_contents -> GetURL ( ) ) ;
ASSERT_NO_FATAL_FAILURE ( WaitForTabsToLoad ( browser ( ) ) ) ;
ExpectFirstPaintMetricsTotalCount ( 2 ) ;
}
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static struct mswsp_ct * get_create_converstation_data ( packet_info * pinfo ) {
struct mswsp_ct * ct = NULL ;
conversation_t * conversation ;
conversation = find_or_create_conversation ( pinfo ) ;
if ( ! conversation ) {
return NULL ;
}
ct = ( struct mswsp_ct * ) conversation_get_proto_data ( conversation , proto_mswsp ) ;
if ( ! ct ) {
ct = wmem_new ( wmem_file_scope ( ) , struct mswsp_ct ) ;
ct -> GSL_message_data = NULL ;
conversation_add_proto_data ( conversation , proto_mswsp , ct ) ;
}
return ct ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void astream_part_reset ( struct attachment_istream * astream ) {
struct attachment_istream_part * part = & astream -> part ;
if ( part -> temp_output != NULL ) o_stream_destroy ( & part -> temp_output ) ;
if ( part -> temp_fd != - 1 ) i_close_fd ( & part -> temp_fd ) ;
i_free_and_null ( part -> content_type ) ;
i_free_and_null ( part -> content_disposition ) ;
if ( part -> part_buf != NULL ) buffer_free ( & part -> part_buf ) ;
i_zero ( part ) ;
part -> temp_fd = - 1 ;
hash_format_reset ( astream -> set . hash_format ) ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static void ps2_mouse_reset ( void * opaque ) {
PS2MouseState * s = ( PS2MouseState * ) opaque ;
trace_ps2_mouse_reset ( opaque ) ;
ps2_common_reset ( & s -> common ) ;
s -> mouse_status = 0 ;
s -> mouse_resolution = 0 ;
s -> mouse_sample_rate = 0 ;
s -> mouse_wrap = 0 ;
s -> mouse_type = 0 ;
s -> mouse_detect_state = 0 ;
s -> mouse_dx = 0 ;
s -> mouse_dy = 0 ;
s -> mouse_dz = 0 ;
s -> mouse_buttons = 0 ;
} | 0False
|
Categorize the following code snippet as vulnerable or not. True or False | static int zsethalftone5 ( i_ctx_t * i_ctx_p ) {
os_ptr op = osp ;
uint count ;
gs_halftone_component * phtc = 0 ;
gs_halftone_component * pc ;
int code = 0 ;
int j ;
bool have_default ;
gs_halftone * pht = 0 ;
gx_device_halftone * pdht = 0 ;
ref sprocs [ GS_CLIENT_COLOR_MAX_COMPONENTS + 1 ] ;
ref tprocs [ GS_CLIENT_COLOR_MAX_COMPONENTS + 1 ] ;
gs_memory_t * mem ;
uint edepth = ref_stack_count ( & e_stack ) ;
int npop = 2 ;
int dict_enum = dict_first ( op ) ;
ref rvalue [ 2 ] ;
int cname , colorant_number ;
byte * pname ;
uint name_size ;
int halftonetype , type = 0 ;
gs_gstate * pgs = igs ;
int space_index = r_space_index ( op - 1 ) ;
mem = ( gs_memory_t * ) idmemory -> spaces_indexed [ space_index ] ;
check_type ( * op , t_dictionary ) ;
check_dict_read ( * op ) ;
check_type ( op [ - 1 ] , t_dictionary ) ;
check_dict_read ( op [ - 1 ] ) ;
code = dict_int_param ( op - 1 , "HalftoneType" , 1 , 100 , 0 , & type ) ;
if ( code < 0 ) return code ;
halftonetype = ( type == 2 || type == 4 ) ? ht_type_multiple_colorscreen : ht_type_multiple ;
have_default = false ;
for ( count = 0 ;
;
) {
if ( ( dict_enum = dict_next ( op , dict_enum , rvalue ) ) == - 1 ) break ;
if ( ! r_has_type ( & rvalue [ 0 ] , t_name ) ) continue ;
if ( ! r_has_type ( & rvalue [ 1 ] , t_dictionary ) ) continue ;
cname = name_index ( mem , & rvalue [ 0 ] ) ;
code = gs_get_colorname_string ( mem , cname , & pname , & name_size ) ;
if ( code < 0 ) break ;
colorant_number = gs_cname_to_colorant_number ( pgs , pname , name_size , halftonetype ) ;
if ( colorant_number < 0 ) continue ;
else if ( colorant_number == GX_DEVICE_COLOR_MAX_COMPONENTS ) {
if ( have_default ) return_error ( gs_error_rangecheck ) ;
have_default = true ;
}
count ++ ;
if ( count > GS_CLIENT_COLOR_MAX_COMPONENTS + 1 ) {
code = gs_note_error ( gs_error_rangecheck ) ;
break ;
}
}
if ( count == 0 || ( halftonetype == ht_type_multiple && ! have_default ) ) code = gs_note_error ( gs_error_rangecheck ) ;
if ( code >= 0 ) {
check_estack ( 5 ) ;
refset_null ( sprocs , count ) ;
refset_null ( tprocs , count ) ;
rc_alloc_struct_0 ( pht , gs_halftone , & st_halftone , imemory , pht = 0 , ".sethalftone5" ) ;
phtc = gs_alloc_struct_array ( mem , count , gs_halftone_component , & st_ht_component_element , ".sethalftone5" ) ;
rc_alloc_struct_0 ( pdht , gx_device_halftone , & st_device_halftone , imemory , pdht = 0 , ".sethalftone5" ) ;
if ( pht == 0 || phtc == 0 || pdht == 0 ) {
j = 0 ;
code = gs_note_error ( gs_error_VMerror ) ;
}
}
if ( code >= 0 ) {
dict_enum = dict_first ( op ) ;
for ( j = 0 , pc = phtc ;
;
) {
int type ;
if ( ( dict_enum = dict_next ( op , dict_enum , rvalue ) ) == - 1 ) break ;
if ( ! r_has_type ( & rvalue [ 0 ] , t_name ) ) continue ;
if ( ! r_has_type ( & rvalue [ 1 ] , t_dictionary ) ) continue ;
cname = name_index ( mem , & rvalue [ 0 ] ) ;
code = gs_get_colorname_string ( mem , cname , & pname , & name_size ) ;
if ( code < 0 ) break ;
colorant_number = gs_cname_to_colorant_number ( pgs , pname , name_size , halftonetype ) ;
if ( colorant_number < 0 ) continue ;
pc -> cname = cname ;
pc -> comp_number = colorant_number ;
check_dict_read ( rvalue [ 1 ] ) ;
if ( dict_int_param ( & rvalue [ 1 ] , "HalftoneType" , 1 , 7 , 0 , & type ) < 0 ) {
code = gs_note_error ( gs_error_typecheck ) ;
break ;
}
switch ( type ) {
default : code = gs_note_error ( gs_error_rangecheck ) ;
break ;
case 1 : code = dict_spot_params ( & rvalue [ 1 ] , & pc -> params . spot , sprocs + j , tprocs + j , mem ) ;
pc -> params . spot . screen . spot_function = spot1_dummy ;
pc -> type = ht_type_spot ;
break ;
case 3 : code = dict_threshold_params ( & rvalue [ 1 ] , & pc -> params . threshold , tprocs + j ) ;
pc -> type = ht_type_threshold ;
break ;
case 7 : code = dict_threshold2_params ( & rvalue [ 1 ] , & pc -> params . threshold2 , tprocs + j , imemory ) ;
pc -> type = ht_type_threshold2 ;
break ;
}
if ( code < 0 ) break ;
pc ++ ;
j ++ ;
}
}
if ( code >= 0 ) {
pht -> type = halftonetype ;
pht -> params . multiple . components = phtc ;
pht -> params . multiple . num_comp = j ;
pht -> params . multiple . get_colorname_string = gs_get_colorname_string ;
code = gs_sethalftone_prepare ( igs , pht , pdht ) ;
}
if ( code >= 0 ) {
dict_enum = dict_first ( op ) ;
for ( pc = phtc ;
;
) {
if ( ( dict_enum = dict_next ( op , dict_enum , rvalue ) ) == - 1 ) break ;
if ( ! r_has_type ( & rvalue [ 0 ] , t_name ) ) continue ;
if ( ! r_has_type ( & rvalue [ 1 ] , t_dictionary ) ) continue ;
cname = name_index ( mem , & rvalue [ 0 ] ) ;
code = gs_get_colorname_string ( mem , cname , & pname , & name_size ) ;
if ( code < 0 ) break ;
colorant_number = gs_cname_to_colorant_number ( pgs , pname , name_size , halftonetype ) ;
if ( colorant_number < 0 ) continue ;
if ( pc -> type == ht_type_spot ) {
code = dict_spot_results ( i_ctx_p , & rvalue [ 1 ] , & pc -> params . spot ) ;
if ( code < 0 ) break ;
}
pc ++ ;
}
}
if ( code >= 0 ) {
uint odepth = ref_stack_count ( & o_stack ) ;
ref odict , odict5 ;
odict = op [ - 1 ] ;
odict5 = * op ;
pop ( 2 ) ;
op = osp ;
esp += 5 ;
make_mark_estack ( esp - 4 , es_other , sethalftone_cleanup ) ;
esp [ - 3 ] = odict ;
make_istruct ( esp - 2 , 0 , pht ) ;
make_istruct ( esp - 1 , 0 , pdht ) ;
make_op_estack ( esp , sethalftone_finish ) ;
for ( j = 0 ;
j < count ;
j ++ ) {
gx_ht_order * porder = NULL ;
if ( pdht -> components == 0 ) porder = & pdht -> order ;
else {
int k ;
int comp_number = phtc [ j ] . comp_number ;
for ( k = 0 ;
k < count ;
k ++ ) {
if ( pdht -> components [ k ] . comp_number == comp_number ) {
porder = & pdht -> components [ k ] . corder ;
break ;
}
}
}
switch ( phtc [ j ] . type ) {
case ht_type_spot : code = zscreen_enum_init ( i_ctx_p , porder , & phtc [ j ] . params . spot . screen , & sprocs [ j ] , 0 , 0 , space_index ) ;
if ( code < 0 ) break ;
case ht_type_threshold : if ( ! r_has_type ( tprocs + j , t__invalid ) ) {
check_ostack ( zcolor_remap_one_ostack ) ;
check_estack ( zcolor_remap_one_estack ) ;
code = zcolor_remap_one ( i_ctx_p , tprocs + j , porder -> transfer , igs , zcolor_remap_one_finish ) ;
op = osp ;
}
break ;
default : ;
}
if ( code < 0 ) {
ref_stack_pop_to ( & o_stack , odepth ) ;
ref_stack_pop_to ( & e_stack , edepth ) ;
op = osp ;
op [ - 1 ] = odict ;
* op = odict5 ;
break ;
}
npop = 0 ;
}
}
if ( code < 0 ) {
gs_free_object ( mem , pdht , ".sethalftone5" ) ;
gs_free_object ( mem , phtc , ".sethalftone5" ) ;
gs_free_object ( mem , pht , ".sethalftone5" ) ;
return code ;
}
pop ( npop ) ;
return ( ref_stack_count ( & e_stack ) > edepth ? o_push_estack : 0 ) ;
} | 1True
|